@termiq/cli 1.3.3 → 1.4.0
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/bin.js +27 -29
- package/package.json +1 -1
package/dist/bin.js
CHANGED
|
@@ -1,12 +1,10 @@
|
|
|
1
1
|
#!/usr/bin/env node
|
|
2
|
-
"use strict";var dd=Object.create;var _o=Object.defineProperty;var pd=Object.getOwnPropertyDescriptor;var gd=Object.getOwnPropertyNames;var _d=Object.getPrototypeOf,md=Object.prototype.hasOwnProperty;var Nt=(r,e)=>()=>(r&&(e=r(r=0)),e);var F=(r,e)=>()=>(e||r((e={exports:{}}).exports,e),e.exports),yd=(r,e)=>{for(var t in e)_o(r,t,{get:e[t],enumerable:!0})},Ed=(r,e,t,n)=>{if(e&&typeof e=="object"||typeof e=="function")for(let s of gd(e))!md.call(r,s)&&s!==t&&_o(r,s,{get:()=>e[s],enumerable:!(n=pd(e,s))||n.enumerable});return r};var we=(r,e,t)=>(t=r!=null?dd(_d(r)):{},Ed(e||!r||!r.__esModule?_o(t,"default",{value:r,enumerable:!0}):t,r));var yo=F((Yn,mo)=>{(function(r,e){typeof Yn=="object"&&typeof mo=="object"?mo.exports=e(require("child_process"),require("crypto")):typeof define=="function"&&define.amd?define(["child_process","crypto"],e):typeof Yn=="object"?Yn["electron-machine-id"]=e(require("child_process"),require("crypto")):r["electron-machine-id"]=e(r.child_process,r.crypto)})(Yn,function(r,e){return(function(t){function n(i){if(s[i])return s[i].exports;var a=s[i]={exports:{},id:i,loaded:!1};return t[i].call(a.exports,a,a.exports,n),a.loaded=!0,a.exports}var s={};return n.m=t,n.c=s,n.p="",n(0)})([function(t,n,s){t.exports=s(34)},function(t,n,s){var i=s(29)("wks"),a=s(33),f=s(2).Symbol,u=typeof f=="function",d=t.exports=function(g){return i[g]||(i[g]=u&&f[g]||(u?f:a)("Symbol."+g))};d.store=i},function(t,n){var s=t.exports=typeof window<"u"&&window.Math==Math?window:typeof self<"u"&&self.Math==Math?self:Function("return this")();typeof __g=="number"&&(__g=s)},function(t,n,s){var i=s(9);t.exports=function(a){if(!i(a))throw TypeError(a+" is not an object!");return a}},function(t,n,s){t.exports=!s(24)(function(){return Object.defineProperty({},"a",{get:function(){return 7}}).a!=7})},function(t,n,s){var i=s(12),a=s(17);t.exports=s(4)?function(f,u,d){return i.f(f,u,a(1,d))}:function(f,u,d){return f[u]=d,f}},function(t,n){var s=t.exports={version:"2.4.0"};typeof __e=="number"&&(__e=s)},function(t,n,s){var i=s(14);t.exports=function(a,f,u){if(i(a),f===void 0)return a;switch(u){case 1:return function(d){return a.call(f,d)};case 2:return function(d,g){return a.call(f,d,g)};case 3:return function(d,g,_){return a.call(f,d,g,_)}}return function(){return a.apply(f,arguments)}}},function(t,n){var s={}.hasOwnProperty;t.exports=function(i,a){return s.call(i,a)}},function(t,n){t.exports=function(s){return typeof s=="object"?s!==null:typeof s=="function"}},function(t,n){t.exports={}},function(t,n){var s={}.toString;t.exports=function(i){return s.call(i).slice(8,-1)}},function(t,n,s){var i=s(3),a=s(26),f=s(32),u=Object.defineProperty;n.f=s(4)?Object.defineProperty:function(d,g,_){if(i(d),g=f(g,!0),i(_),a)try{return u(d,g,_)}catch{}if("get"in _||"set"in _)throw TypeError("Accessors not supported!");return"value"in _&&(d[g]=_.value),d}},function(t,n,s){var i=s(42),a=s(15);t.exports=function(f){return i(a(f))}},function(t,n){t.exports=function(s){if(typeof s!="function")throw TypeError(s+" is not a function!");return s}},function(t,n){t.exports=function(s){if(s==null)throw TypeError("Can't call method on "+s);return s}},function(t,n,s){var i=s(9),a=s(2).document,f=i(a)&&i(a.createElement);t.exports=function(u){return f?a.createElement(u):{}}},function(t,n){t.exports=function(s,i){return{enumerable:!(1&s),configurable:!(2&s),writable:!(4&s),value:i}}},function(t,n,s){var i=s(12).f,a=s(8),f=s(1)("toStringTag");t.exports=function(u,d,g){u&&!a(u=g?u:u.prototype,f)&&i(u,f,{configurable:!0,value:d})}},function(t,n,s){var i=s(29)("keys"),a=s(33);t.exports=function(f){return i[f]||(i[f]=a(f))}},function(t,n){var s=Math.ceil,i=Math.floor;t.exports=function(a){return isNaN(a=+a)?0:(a>0?i:s)(a)}},function(t,n,s){var i=s(11),a=s(1)("toStringTag"),f=i((function(){return arguments})())=="Arguments",u=function(d,g){try{return d[g]}catch{}};t.exports=function(d){var g,_,y;return d===void 0?"Undefined":d===null?"Null":typeof(_=u(g=Object(d),a))=="string"?_:f?i(g):(y=i(g))=="Object"&&typeof g.callee=="function"?"Arguments":y}},function(t,n){t.exports="constructor,hasOwnProperty,isPrototypeOf,propertyIsEnumerable,toLocaleString,toString,valueOf".split(",")},function(t,n,s){var i=s(2),a=s(6),f=s(7),u=s(5),d="prototype",g=function(_,y,x){var S,C,H,z=_&g.F,X=_&g.G,T=_&g.S,M=_&g.P,Q=_&g.B,B=_&g.W,ie=X?a:a[y]||(a[y]={}),he=ie[d],de=X?i:T?i[y]:(i[y]||{})[d];X&&(x=y);for(S in x)C=!z&&de&&de[S]!==void 0,C&&S in ie||(H=C?de[S]:x[S],ie[S]=X&&typeof de[S]!="function"?x[S]:Q&&C?f(H,i):B&&de[S]==H?(function(Pe){var qe=function(Ge,xe,Ye){if(this instanceof Pe){switch(arguments.length){case 0:return new Pe;case 1:return new Pe(Ge);case 2:return new Pe(Ge,xe)}return new Pe(Ge,xe,Ye)}return Pe.apply(this,arguments)};return qe[d]=Pe[d],qe})(H):M&&typeof H=="function"?f(Function.call,H):H,M&&((ie.virtual||(ie.virtual={}))[S]=H,_&g.R&&he&&!he[S]&&u(he,S,H)))};g.F=1,g.G=2,g.S=4,g.P=8,g.B=16,g.W=32,g.U=64,g.R=128,t.exports=g},function(t,n){t.exports=function(s){try{return!!s()}catch{return!0}}},function(t,n,s){t.exports=s(2).document&&document.documentElement},function(t,n,s){t.exports=!s(4)&&!s(24)(function(){return Object.defineProperty(s(16)("div"),"a",{get:function(){return 7}}).a!=7})},function(t,n,s){"use strict";var i=s(28),a=s(23),f=s(57),u=s(5),d=s(8),g=s(10),_=s(45),y=s(18),x=s(52),S=s(1)("iterator"),C=!([].keys&&"next"in[].keys()),H="@@iterator",z="keys",X="values",T=function(){return this};t.exports=function(M,Q,B,ie,he,de,Pe){_(B,Q,ie);var qe,Ge,xe,Ye=function(j){if(!C&&j in pe)return pe[j];switch(j){case z:return function(){return new B(this,j)};case X:return function(){return new B(this,j)}}return function(){return new B(this,j)}},De=Q+" Iterator",J=he==X,ye=!1,pe=M.prototype,rt=pe[S]||pe[H]||he&&pe[he],Ze=rt||Ye(he),qt=he?J?Ye("entries"):Ze:void 0,N=Q=="Array"&&pe.entries||rt;if(N&&(xe=x(N.call(new M)),xe!==Object.prototype&&(y(xe,De,!0),i||d(xe,S)||u(xe,S,T))),J&&rt&&rt.name!==X&&(ye=!0,Ze=function(){return rt.call(this)}),i&&!Pe||!C&&!ye&&pe[S]||u(pe,S,Ze),g[Q]=Ze,g[De]=T,he)if(qe={values:J?Ze:Ye(X),keys:de?Ze:Ye(z),entries:qt},Pe)for(Ge in qe)Ge in pe||f(pe,Ge,qe[Ge]);else a(a.P+a.F*(C||ye),Q,qe);return qe}},function(t,n){t.exports=!0},function(t,n,s){var i=s(2),a="__core-js_shared__",f=i[a]||(i[a]={});t.exports=function(u){return f[u]||(f[u]={})}},function(t,n,s){var i,a,f,u=s(7),d=s(41),g=s(25),_=s(16),y=s(2),x=y.process,S=y.setImmediate,C=y.clearImmediate,H=y.MessageChannel,z=0,X={},T="onreadystatechange",M=function(){var B=+this;if(X.hasOwnProperty(B)){var ie=X[B];delete X[B],ie()}},Q=function(B){M.call(B.data)};S&&C||(S=function(B){for(var ie=[],he=1;arguments.length>he;)ie.push(arguments[he++]);return X[++z]=function(){d(typeof B=="function"?B:Function(B),ie)},i(z),z},C=function(B){delete X[B]},s(11)(x)=="process"?i=function(B){x.nextTick(u(M,B,1))}:H?(a=new H,f=a.port2,a.port1.onmessage=Q,i=u(f.postMessage,f,1)):y.addEventListener&&typeof postMessage=="function"&&!y.importScripts?(i=function(B){y.postMessage(B+"","*")},y.addEventListener("message",Q,!1)):i=T in _("script")?function(B){g.appendChild(_("script"))[T]=function(){g.removeChild(this),M.call(B)}}:function(B){setTimeout(u(M,B,1),0)}),t.exports={set:S,clear:C}},function(t,n,s){var i=s(20),a=Math.min;t.exports=function(f){return f>0?a(i(f),9007199254740991):0}},function(t,n,s){var i=s(9);t.exports=function(a,f){if(!i(a))return a;var u,d;if(f&&typeof(u=a.toString)=="function"&&!i(d=u.call(a))||typeof(u=a.valueOf)=="function"&&!i(d=u.call(a))||!f&&typeof(u=a.toString)=="function"&&!i(d=u.call(a)))return d;throw TypeError("Can't convert object to primitive value")}},function(t,n){var s=0,i=Math.random();t.exports=function(a){return"Symbol(".concat(a===void 0?"":a,")_",(++s+i).toString(36))}},function(t,n,s){"use strict";function i(T){return T&&T.__esModule?T:{default:T}}function a(){return process.platform!=="win32"?"":process.arch==="ia32"&&process.env.hasOwnProperty("PROCESSOR_ARCHITEW6432")?"mixed":"native"}function f(T){return(0,S.createHash)("sha256").update(T).digest("hex")}function u(T){switch(H){case"darwin":return T.split("IOPlatformUUID")[1].split(`
|
|
3
|
-
`)[0].replace(/\=|\s+|\"/gi,"").toLowerCase();case"win32":return T.toString().split("REG_SZ")[1].replace(/\r+|\n+|\s+/gi,"").toLowerCase();case"linux":return T.toString().replace(/\r+|\n+|\s+/gi,"").toLowerCase();case"freebsd":return T.toString().replace(/\r+|\n+|\s+/gi,"").toLowerCase();default:throw new Error("Unsupported platform: "+process.platform)}}function d(T){var M=u((0,x.execSync)(X[H]).toString());return T?M:f(M)}function g(T){return new y.default(function(M,Q){return(0,x.exec)(X[H],{},function(B,ie,he){if(B)return Q(new Error("Error while obtaining machine id: "+B.stack));var de=u(ie.toString());return M(T?de:f(de))})})}Object.defineProperty(n,"__esModule",{value:!0});var _=s(35),y=i(_);n.machineIdSync=d,n.machineId=g;var x=s(70),S=s(71),C=process,H=C.platform,z={native:"%windir%\\System32",mixed:"%windir%\\sysnative\\cmd.exe /c %windir%\\System32"},X={darwin:"ioreg -rd1 -c IOPlatformExpertDevice",win32:z[a()]+"\\REG.exe QUERY HKEY_LOCAL_MACHINE\\SOFTWARE\\Microsoft\\Cryptography /v MachineGuid",linux:"( cat /var/lib/dbus/machine-id /etc/machine-id 2> /dev/null || hostname ) | head -n 1 || :",freebsd:"kenv -q smbios.system.uuid || sysctl -n kern.hostuuid"}},function(t,n,s){t.exports={default:s(36),__esModule:!0}},function(t,n,s){s(66),s(68),s(69),s(67),t.exports=s(6).Promise},function(t,n){t.exports=function(){}},function(t,n){t.exports=function(s,i,a,f){if(!(s instanceof i)||f!==void 0&&f in s)throw TypeError(a+": incorrect invocation!");return s}},function(t,n,s){var i=s(13),a=s(31),f=s(62);t.exports=function(u){return function(d,g,_){var y,x=i(d),S=a(x.length),C=f(_,S);if(u&&g!=g){for(;S>C;)if(y=x[C++],y!=y)return!0}else for(;S>C;C++)if((u||C in x)&&x[C]===g)return u||C||0;return!u&&-1}}},function(t,x,s){var i=s(7),a=s(44),f=s(43),u=s(3),d=s(31),g=s(64),_={},y={},x=t.exports=function(S,C,H,z,X){var T,M,Q,B,ie=X?function(){return S}:g(S),he=i(H,z,C?2:1),de=0;if(typeof ie!="function")throw TypeError(S+" is not iterable!");if(f(ie)){for(T=d(S.length);T>de;de++)if(B=C?he(u(M=S[de])[0],M[1]):he(S[de]),B===_||B===y)return B}else for(Q=ie.call(S);!(M=Q.next()).done;)if(B=a(Q,he,M.value,C),B===_||B===y)return B};x.BREAK=_,x.RETURN=y},function(t,n){t.exports=function(s,i,a){var f=a===void 0;switch(i.length){case 0:return f?s():s.call(a);case 1:return f?s(i[0]):s.call(a,i[0]);case 2:return f?s(i[0],i[1]):s.call(a,i[0],i[1]);case 3:return f?s(i[0],i[1],i[2]):s.call(a,i[0],i[1],i[2]);case 4:return f?s(i[0],i[1],i[2],i[3]):s.call(a,i[0],i[1],i[2],i[3])}return s.apply(a,i)}},function(t,n,s){var i=s(11);t.exports=Object("z").propertyIsEnumerable(0)?Object:function(a){return i(a)=="String"?a.split(""):Object(a)}},function(t,n,s){var i=s(10),a=s(1)("iterator"),f=Array.prototype;t.exports=function(u){return u!==void 0&&(i.Array===u||f[a]===u)}},function(t,n,s){var i=s(3);t.exports=function(a,f,u,d){try{return d?f(i(u)[0],u[1]):f(u)}catch(_){var g=a.return;throw g!==void 0&&i(g.call(a)),_}}},function(t,n,s){"use strict";var i=s(49),a=s(17),f=s(18),u={};s(5)(u,s(1)("iterator"),function(){return this}),t.exports=function(d,g,_){d.prototype=i(u,{next:a(1,_)}),f(d,g+" Iterator")}},function(t,n,s){var i=s(1)("iterator"),a=!1;try{var f=[7][i]();f.return=function(){a=!0},Array.from(f,function(){throw 2})}catch{}t.exports=function(u,d){if(!d&&!a)return!1;var g=!1;try{var _=[7],y=_[i]();y.next=function(){return{done:g=!0}},_[i]=function(){return y},u(_)}catch{}return g}},function(t,n){t.exports=function(s,i){return{value:i,done:!!s}}},function(t,n,s){var i=s(2),a=s(30).set,f=i.MutationObserver||i.WebKitMutationObserver,u=i.process,d=i.Promise,g=s(11)(u)=="process";t.exports=function(){var _,y,x,S=function(){var X,T;for(g&&(X=u.domain)&&X.exit();_;){T=_.fn,_=_.next;try{T()}catch(M){throw _?x():y=void 0,M}}y=void 0,X&&X.enter()};if(g)x=function(){u.nextTick(S)};else if(f){var C=!0,H=document.createTextNode("");new f(S).observe(H,{characterData:!0}),x=function(){H.data=C=!C}}else if(d&&d.resolve){var z=d.resolve();x=function(){z.then(S)}}else x=function(){a.call(i,S)};return function(X){var T={fn:X,next:void 0};y&&(y.next=T),_||(_=T,x()),y=T}}},function(t,n,s){var i=s(3),a=s(50),f=s(22),u=s(19)("IE_PROTO"),d=function(){},g="prototype",_=function(){var y,x=s(16)("iframe"),S=f.length,C=">";for(x.style.display="none",s(25).appendChild(x),x.src="javascript:",y=x.contentWindow.document,y.open(),y.write("<script>document.F=Object</script"+C),y.close(),_=y.F;S--;)delete _[g][f[S]];return _()};t.exports=Object.create||function(y,x){var S;return y!==null?(d[g]=i(y),S=new d,d[g]=null,S[u]=y):S=_(),x===void 0?S:a(S,x)}},function(t,n,s){var i=s(12),a=s(3),f=s(54);t.exports=s(4)?Object.defineProperties:function(u,d){a(u);for(var g,_=f(d),y=_.length,x=0;y>x;)i.f(u,g=_[x++],d[g]);return u}},function(t,n,s){var i=s(55),a=s(17),f=s(13),u=s(32),d=s(8),g=s(26),_=Object.getOwnPropertyDescriptor;n.f=s(4)?_:function(y,x){if(y=f(y),x=u(x,!0),g)try{return _(y,x)}catch{}if(d(y,x))return a(!i.f.call(y,x),y[x])}},function(t,n,s){var i=s(8),a=s(63),f=s(19)("IE_PROTO"),u=Object.prototype;t.exports=Object.getPrototypeOf||function(d){return d=a(d),i(d,f)?d[f]:typeof d.constructor=="function"&&d instanceof d.constructor?d.constructor.prototype:d instanceof Object?u:null}},function(t,n,s){var i=s(8),a=s(13),f=s(39)(!1),u=s(19)("IE_PROTO");t.exports=function(d,g){var _,y=a(d),x=0,S=[];for(_ in y)_!=u&&i(y,_)&&S.push(_);for(;g.length>x;)i(y,_=g[x++])&&(~f(S,_)||S.push(_));return S}},function(t,n,s){var i=s(53),a=s(22);t.exports=Object.keys||function(f){return i(f,a)}},function(t,n){n.f={}.propertyIsEnumerable},function(t,n,s){var i=s(5);t.exports=function(a,f,u){for(var d in f)u&&a[d]?a[d]=f[d]:i(a,d,f[d]);return a}},function(t,n,s){t.exports=s(5)},function(t,n,s){var i=s(9),a=s(3),f=function(u,d){if(a(u),!i(d)&&d!==null)throw TypeError(d+": can't set as prototype!")};t.exports={set:Object.setPrototypeOf||("__proto__"in{}?(function(u,d,g){try{g=s(7)(Function.call,s(51).f(Object.prototype,"__proto__").set,2),g(u,[]),d=!(u instanceof Array)}catch{d=!0}return function(_,y){return f(_,y),d?_.__proto__=y:g(_,y),_}})({},!1):void 0),check:f}},function(t,n,s){"use strict";var i=s(2),a=s(6),f=s(12),u=s(4),d=s(1)("species");t.exports=function(g){var _=typeof a[g]=="function"?a[g]:i[g];u&&_&&!_[d]&&f.f(_,d,{configurable:!0,get:function(){return this}})}},function(t,n,s){var i=s(3),a=s(14),f=s(1)("species");t.exports=function(u,d){var g,_=i(u).constructor;return _===void 0||(g=i(_)[f])==null?d:a(g)}},function(t,n,s){var i=s(20),a=s(15);t.exports=function(f){return function(u,d){var g,_,y=String(a(u)),x=i(d),S=y.length;return x<0||x>=S?f?"":void 0:(g=y.charCodeAt(x),g<55296||g>56319||x+1===S||(_=y.charCodeAt(x+1))<56320||_>57343?f?y.charAt(x):g:f?y.slice(x,x+2):(g-55296<<10)+(_-56320)+65536)}}},function(t,n,s){var i=s(20),a=Math.max,f=Math.min;t.exports=function(u,d){return u=i(u),u<0?a(u+d,0):f(u,d)}},function(t,n,s){var i=s(15);t.exports=function(a){return Object(i(a))}},function(t,n,s){var i=s(21),a=s(1)("iterator"),f=s(10);t.exports=s(6).getIteratorMethod=function(u){if(u!=null)return u[a]||u["@@iterator"]||f[i(u)]}},function(t,n,s){"use strict";var i=s(37),a=s(47),f=s(10),u=s(13);t.exports=s(27)(Array,"Array",function(d,g){this._t=u(d),this._i=0,this._k=g},function(){var d=this._t,g=this._k,_=this._i++;return!d||_>=d.length?(this._t=void 0,a(1)):g=="keys"?a(0,_):g=="values"?a(0,d[_]):a(0,[_,d[_]])},"values"),f.Arguments=f.Array,i("keys"),i("values"),i("entries")},function(t,n){},function(t,n,s){"use strict";var i,a,f,u=s(28),d=s(2),g=s(7),_=s(21),y=s(23),x=s(9),S=(s(3),s(14)),C=s(38),H=s(40),z=(s(58).set,s(60)),X=s(30).set,T=s(48)(),M="Promise",Q=d.TypeError,ie=d.process,B=d[M],ie=d.process,he=_(ie)=="process",de=function(){},Pe=!!(function(){try{var N=B.resolve(1),j=(N.constructor={})[s(1)("species")]=function(A){A(de,de)};return(he||typeof PromiseRejectionEvent=="function")&&N.then(de)instanceof j}catch{}})(),qe=function(N,j){return N===j||N===B&&j===f},Ge=function(N){var j;return!(!x(N)||typeof(j=N.then)!="function")&&j},xe=function(N){return qe(B,N)?new Ye(N):new a(N)},Ye=a=function(N){var j,A;this.promise=new N(function(oe,Ae){if(j!==void 0||A!==void 0)throw Q("Bad Promise constructor");j=oe,A=Ae}),this.resolve=S(j),this.reject=S(A)},De=function(N){try{N()}catch(j){return{error:j}}},J=function(N,j){if(!N._n){N._n=!0;var A=N._c;T(function(){for(var oe=N._v,Ae=N._s==1,ft=0,gt=function(_t){var mt,rr,yr=Ae?_t.ok:_t.fail,Br=_t.resolve,Er=_t.reject,hn=_t.domain;try{yr?(Ae||(N._h==2&&rt(N),N._h=1),yr===!0?mt=oe:(hn&&hn.enter(),mt=yr(oe),hn&&hn.exit()),mt===_t.promise?Er(Q("Promise-chain cycle")):(rr=Ge(mt))?rr.call(mt,Br,Er):Br(mt)):Er(oe)}catch(Ts){Er(Ts)}};A.length>ft;)gt(A[ft++]);N._c=[],N._n=!1,j&&!N._h&&ye(N)})}},ye=function(N){X.call(d,function(){var j,A,oe,Ae=N._v;if(pe(N)&&(j=De(function(){he?ie.emit("unhandledRejection",Ae,N):(A=d.onunhandledrejection)?A({promise:N,reason:Ae}):(oe=d.console)&&oe.error&&oe.error("Unhandled promise rejection",Ae)}),N._h=he||pe(N)?2:1),N._a=void 0,j)throw j.error})},pe=function(N){if(N._h==1)return!1;for(var j,A=N._a||N._c,oe=0;A.length>oe;)if(j=A[oe++],j.fail||!pe(j.promise))return!1;return!0},rt=function(N){X.call(d,function(){var j;he?ie.emit("rejectionHandled",N):(j=d.onrejectionhandled)&&j({promise:N,reason:N._v})})},Ze=function(N){var j=this;j._d||(j._d=!0,j=j._w||j,j._v=N,j._s=2,j._a||(j._a=j._c.slice()),J(j,!0))},qt=function(N){var j,A=this;if(!A._d){A._d=!0,A=A._w||A;try{if(A===N)throw Q("Promise can't be resolved itself");(j=Ge(N))?T(function(){var oe={_w:A,_d:!1};try{j.call(N,g(qt,oe,1),g(Ze,oe,1))}catch(Ae){Ze.call(oe,Ae)}}):(A._v=N,A._s=1,J(A,!1))}catch(oe){Ze.call({_w:A,_d:!1},oe)}}};Pe||(B=function(N){C(this,B,M,"_h"),S(N),i.call(this);try{N(g(qt,this,1),g(Ze,this,1))}catch(j){Ze.call(this,j)}},i=function(N){this._c=[],this._a=void 0,this._s=0,this._d=!1,this._v=void 0,this._h=0,this._n=!1},i.prototype=s(56)(B.prototype,{then:function(N,j){var A=xe(z(this,B));return A.ok=typeof N!="function"||N,A.fail=typeof j=="function"&&j,A.domain=he?ie.domain:void 0,this._c.push(A),this._a&&this._a.push(A),this._s&&J(this,!1),A.promise},catch:function(N){return this.then(void 0,N)}}),Ye=function(){var N=new i;this.promise=N,this.resolve=g(qt,N,1),this.reject=g(Ze,N,1)}),y(y.G+y.W+y.F*!Pe,{Promise:B}),s(18)(B,M),s(59)(M),f=s(6)[M],y(y.S+y.F*!Pe,M,{reject:function(N){var j=xe(this),A=j.reject;return A(N),j.promise}}),y(y.S+y.F*(u||!Pe),M,{resolve:function(N){if(N instanceof B&&qe(N.constructor,this))return N;var j=xe(this),A=j.resolve;return A(N),j.promise}}),y(y.S+y.F*!(Pe&&s(46)(function(N){B.all(N).catch(de)})),M,{all:function(N){var j=this,A=xe(j),oe=A.resolve,Ae=A.reject,ft=De(function(){var gt=[],_t=0,mt=1;H(N,!1,function(rr){var yr=_t++,Br=!1;gt.push(void 0),mt++,j.resolve(rr).then(function(Er){Br||(Br=!0,gt[yr]=Er,--mt||oe(gt))},Ae)}),--mt||oe(gt)});return ft&&Ae(ft.error),A.promise},race:function(N){var j=this,A=xe(j),oe=A.reject,Ae=De(function(){H(N,!1,function(ft){j.resolve(ft).then(A.resolve,oe)})});return Ae&&oe(Ae.error),A.promise}})},function(t,n,s){"use strict";var i=s(61)(!0);s(27)(String,"String",function(a){this._t=String(a),this._i=0},function(){var a,f=this._t,u=this._i;return u>=f.length?{value:void 0,done:!0}:(a=i(f,u),this._i+=a.length,{value:a,done:!1})})},function(t,n,s){s(65);for(var i=s(2),a=s(5),f=s(10),u=s(1)("toStringTag"),d=["NodeList","DOMTokenList","MediaList","StyleSheetList","CSSRuleList"],g=0;g<5;g++){var _=d[g],y=i[_],x=y&&y.prototype;x&&!x[u]&&a(x,u,_),f[_]=f.Array}},function(t,n){t.exports=require("child_process")},function(t,n){t.exports=require("crypto")}])})});function xd(){try{return wo.default.statSync("/.dockerenv"),!0}catch{return!1}}function vd(){try{return wo.default.readFileSync("/proc/self/cgroup","utf8").includes("docker")}catch{return!1}}function xo(){return Eo===void 0&&(Eo=xd()||vd()),Eo}var wo,Eo,$c=Nt(()=>{wo=we(require("node:fs"),1)});function gn(){return vo===void 0&&(vo=bd()||xo()),vo}var zc,vo,bd,bo=Nt(()=>{zc=we(require("node:fs"),1);$c();bd=()=>{try{return zc.default.statSync("/run/.containerenv"),!0}catch{return!1}}});var So,Yc,Xc,Gc,wr,To=Nt(()=>{So=we(require("node:process"),1),Yc=we(require("node:os"),1),Xc=we(require("node:fs"),1);bo();Gc=()=>{if(So.default.platform!=="linux")return!1;if(Yc.default.release().toLowerCase().includes("microsoft"))return!gn();try{return Xc.default.readFileSync("/proc/version","utf8").toLowerCase().includes("microsoft")?!gn():!1}catch{return!1}},wr=So.default.env.__IS_WSL_TEST__?Gc:Gc()});var Oo,Zn,Sd,Td,Co,Jc=Nt(()=>{Oo=we(require("node:process"),1),Zn=we(require("node:fs/promises"),1);To();To();Sd=(()=>{let r="/mnt/",e;return async function(){if(e)return e;let t="/etc/wsl.conf",n=!1;try{await Zn.default.access(t,Zn.constants.F_OK),n=!0}catch{}if(!n)return r;let s=await Zn.default.readFile(t,{encoding:"utf8"}),i=/(?<!#.*)root\s*=\s*(?<mountPoint>.*)/g.exec(s);return i?(e=i.groups.mountPoint.trim(),e=e.endsWith("/")?e:`${e}/`,e):r}})(),Td=async()=>`${await Sd()}c/Windows/System32/WindowsPowerShell/v1.0/powershell.exe`,Co=async()=>wr?Td():`${Oo.default.env.SYSTEMROOT||Oo.default.env.windir||String.raw`C:\Windows`}\\System32\\WindowsPowerShell\\v1.0\\powershell.exe`});function xr(r,e,t){let n=s=>Object.defineProperty(r,e,{value:s,enumerable:!0,writable:!0});return Object.defineProperty(r,e,{configurable:!0,enumerable:!0,get(){let s=t();return n(s),s},set(s){n(s)}}),r}var Zc=Nt(()=>{});async function ko(){if(ef.default.platform!=="darwin")throw new Error("macOS only");let{stdout:r}=await Od("defaults",["read","com.apple.LaunchServices/com.apple.launchservices.secure","LSHandlers"]),t=/LSHandlerRoleAll = "(?!-)(?<id>[^"]+?)";\s+?LSHandlerURLScheme = (?:http|https);/.exec(r)?.groups.id??"com.apple.Safari";return t==="com.apple.safari"?"com.apple.Safari":t}var Qc,ef,tf,Od,rf=Nt(()=>{Qc=require("node:util"),ef=we(require("node:process"),1),tf=require("node:child_process"),Od=(0,Qc.promisify)(tf.execFile)});async function of(r,{humanReadableOutput:e=!0,signal:t}={}){if(nf.default.platform!=="darwin")throw new Error("macOS only");let n=e?[]:["-ss"],s={};t&&(s.signal=t);let{stdout:i}=await Cd("osascript",["-e",r,n],s);return i.trim()}var nf,sf,Po,Cd,af=Nt(()=>{nf=we(require("node:process"),1),sf=require("node:util"),Po=require("node:child_process"),Cd=(0,sf.promisify)(Po.execFile)});async function Ro(r){return of(`tell application "Finder" to set app_path to application file id "${r}" as string
|
|
4
|
-
tell application "System Events" to get value of property list item "CFBundleName" of property list file (app_path & ":Contents:Info.plist")`)}var cf=Nt(()=>{af()});async function Io(r=kd){let{stdout:e}=await r("reg",["QUERY"," HKEY_CURRENT_USER\\Software\\Microsoft\\Windows\\Shell\\Associations\\UrlAssociations\\http\\UserChoice","/v","ProgId"]),t=/ProgId\s*REG_SZ\s*(?<id>\S+)/.exec(e);if(!t)throw new Ao(`Cannot find Windows browser in stdout: ${JSON.stringify(e)}`);let{id:n}=t.groups,s=n.lastIndexOf("."),i=n.lastIndexOf("-"),a=s===-1?void 0:n.slice(0,s),f=i===-1?void 0:n.slice(0,i);return Ds[n]??Ds[a]??Ds[f]??{name:n,id:n}}var ff,uf,kd,Ds,uE,Ao,lf=Nt(()=>{ff=require("node:util"),uf=require("node:child_process"),kd=(0,ff.promisify)(uf.execFile),Ds={MSEdgeHTM:{name:"Edge",id:"com.microsoft.edge"},MSEdgeBHTML:{name:"Edge Beta",id:"com.microsoft.edge.beta"},MSEdgeDHTML:{name:"Edge Dev",id:"com.microsoft.edge.dev"},AppXq0fevzme2pys62n3e0fbqa7peapykr8v:{name:"Edge",id:"com.microsoft.edge.old"},ChromeHTML:{name:"Chrome",id:"com.google.chrome"},ChromeBHTML:{name:"Chrome Beta",id:"com.google.chrome.beta"},ChromeDHTML:{name:"Chrome Dev",id:"com.google.chrome.dev"},ChromiumHTM:{name:"Chromium",id:"org.chromium.Chromium"},BraveHTML:{name:"Brave",id:"com.brave.Browser"},BraveBHTML:{name:"Brave Beta",id:"com.brave.Browser.beta"},BraveDHTML:{name:"Brave Dev",id:"com.brave.Browser.dev"},BraveSSHTM:{name:"Brave Nightly",id:"com.brave.Browser.nightly"},FirefoxURL:{name:"Firefox",id:"org.mozilla.firefox"},OperaStable:{name:"Opera",id:"com.operasoftware.Opera"},VivaldiHTM:{name:"Vivaldi",id:"com.vivaldi.Vivaldi"},"IE.HTTP":{name:"Internet Explorer",id:"com.microsoft.ie"}},uE=new Map(Object.entries(Ds)),Ao=class extends Error{}});async function No(){if(Fs.default.platform==="darwin"){let r=await ko();return{name:await Ro(r),id:r}}if(Fs.default.platform==="linux"){let{stdout:r}=await Pd("xdg-mime",["query","default","x-scheme-handler/http"]),e=r.trim();return{name:Rd(e.replace(/.desktop$/,"").replace("-"," ")),id:e}}if(Fs.default.platform==="win32")return Io();throw new Error("Only macOS, Linux, and Windows are supported")}var hf,Fs,df,Pd,Rd,pf=Nt(()=>{hf=require("node:util"),Fs=we(require("node:process"),1),df=require("node:child_process");rf();cf();lf();Pd=(0,hf.promisify)(df.execFile),Rd=r=>r.toLowerCase().replaceAll(/(?:^|\s|-)\S/g,e=>e.toUpperCase())});var xf={};yd(xf,{apps:()=>vr,default:()=>Dd,openApp:()=>Ld});async function Id(){let r=await Co(),e=String.raw`(Get-ItemProperty -Path "HKCU:\Software\Microsoft\Windows\Shell\Associations\UrlAssociations\http\UserChoice").ProgId`,t=Fo.Buffer.from(e,"utf16le").toString("base64"),{stdout:n}=await Ad(r,["-NoProfile","-NonInteractive","-ExecutionPolicy","Bypass","-EncodedCommand",t],{encoding:"utf8"}),s=n.trim(),i={ChromeHTML:"com.google.chrome",BraveHTML:"com.brave.Browser",MSEdgeHTM:"com.microsoft.edge",FirefoxURL:"org.mozilla.firefox"};return i[s]?{id:i[s]}:{}}function yf(r){if(typeof r=="string"||Array.isArray(r))return r;let{[_f]:e}=r;if(!e)throw new Error(`${_f} is not supported`);return e}function Bs({[_n]:r},{wsl:e}){if(e&&wr)return yf(e);if(!r)throw new Error(`${_n} is not supported`);return yf(r)}var Do,Fo,Mo,Ef,wf,Bo,Ms,Fd,Ad,Lo,gf,_n,_f,mf,Qn,Nd,Ld,vr,Dd,vf=Nt(()=>{Do=we(require("node:process"),1),Fo=require("node:buffer"),Mo=we(require("node:path"),1),Ef=require("node:url"),wf=require("node:util"),Bo=we(require("node:child_process"),1),Ms=we(require("node:fs/promises"),1);Jc();Zc();pf();bo();Fd={},Ad=(0,wf.promisify)(Bo.default.execFile),Lo=Mo.default.dirname((0,Ef.fileURLToPath)(Fd.url)),gf=Mo.default.join(Lo,"xdg-open"),{platform:_n,arch:_f}=Do.default;mf=async(r,e)=>{let t;for(let n of r)try{return await e(n)}catch(s){t=s}throw t},Qn=async r=>{if(r={wait:!1,background:!1,newInstance:!1,allowNonzeroExitCode:!1,...r},Array.isArray(r.app))return mf(r.app,f=>Qn({...r,app:f}));let{name:e,arguments:t=[]}=r.app??{};if(t=[...t],Array.isArray(e))return mf(e,f=>Qn({...r,app:{name:f,arguments:t}}));if(e==="browser"||e==="browserPrivate"){let f={"com.google.chrome":"chrome","google-chrome.desktop":"chrome","com.brave.Browser":"brave","org.mozilla.firefox":"firefox","firefox.desktop":"firefox","com.microsoft.msedge":"edge","com.microsoft.edge":"edge","com.microsoft.edgemac":"edge","microsoft-edge.desktop":"edge"},u={chrome:"--incognito",brave:"--incognito",firefox:"--private-window",edge:"--inPrivate"},d=wr?await Id():await No();if(d.id in f){let g=f[d.id];return e==="browserPrivate"&&t.push(u[g]),Qn({...r,app:{name:vr[g],arguments:t}})}throw new Error(`${d.name} is not supported as a default browser`)}let n,s=[],i={};if(_n==="darwin")n="open",r.wait&&s.push("--wait-apps"),r.background&&s.push("--background"),r.newInstance&&s.push("--new"),e&&s.push("-a",e);else if(_n==="win32"||wr&&!gn()&&!e){n=await Co(),s.push("-NoProfile","-NonInteractive","-ExecutionPolicy","Bypass","-EncodedCommand"),wr||(i.windowsVerbatimArguments=!0);let f=["Start"];r.wait&&f.push("-Wait"),e?(f.push(`"\`"${e}\`""`),r.target&&t.push(r.target)):r.target&&f.push(`"${r.target}"`),t.length>0&&(t=t.map(u=>`"\`"${u}\`""`),f.push("-ArgumentList",t.join(","))),r.target=Fo.Buffer.from(f.join(" "),"utf16le").toString("base64")}else{if(e)n=e;else{let f=!Lo||Lo==="/",u=!1;try{await Ms.default.access(gf,Ms.constants.X_OK),u=!0}catch{}n=Do.default.versions.electron??(_n==="android"||f||!u)?"xdg-open":gf}t.length>0&&s.push(...t),r.wait||(i.stdio="ignore",i.detached=!0)}_n==="darwin"&&t.length>0&&s.push("--args",...t),r.target&&s.push(r.target);let a=Bo.default.spawn(n,s,i);return r.wait?new Promise((f,u)=>{a.once("error",u),a.once("close",d=>{if(!r.allowNonzeroExitCode&&d>0){u(new Error(`Exited with code ${d}`));return}f(a)})}):(a.unref(),a)},Nd=(r,e)=>{if(typeof r!="string")throw new TypeError("Expected a `target`");return Qn({...e,target:r})},Ld=(r,e)=>{if(typeof r!="string"&&!Array.isArray(r))throw new TypeError("Expected a valid `name`");let{arguments:t=[]}=e??{};if(t!=null&&!Array.isArray(t))throw new TypeError("Expected `appArguments` as Array type");return Qn({...e,app:{name:r,arguments:t}})};vr={};xr(vr,"chrome",()=>Bs({darwin:"google chrome",win32:"chrome",linux:["google-chrome","google-chrome-stable","chromium"]},{wsl:{ia32:"/mnt/c/Program Files (x86)/Google/Chrome/Application/chrome.exe",x64:["/mnt/c/Program Files/Google/Chrome/Application/chrome.exe","/mnt/c/Program Files (x86)/Google/Chrome/Application/chrome.exe"]}}));xr(vr,"brave",()=>Bs({darwin:"brave browser",win32:"brave",linux:["brave-browser","brave"]},{wsl:{ia32:"/mnt/c/Program Files (x86)/BraveSoftware/Brave-Browser/Application/brave.exe",x64:["/mnt/c/Program Files/BraveSoftware/Brave-Browser/Application/brave.exe","/mnt/c/Program Files (x86)/BraveSoftware/Brave-Browser/Application/brave.exe"]}}));xr(vr,"firefox",()=>Bs({darwin:"firefox",win32:String.raw`C:\Program Files\Mozilla Firefox\firefox.exe`,linux:"firefox"},{wsl:"/mnt/c/Program Files/Mozilla Firefox/firefox.exe"}));xr(vr,"edge",()=>Bs({darwin:"microsoft edge",win32:"msedge",linux:["microsoft-edge","microsoft-edge-dev"]},{wsl:"/mnt/c/Program Files (x86)/Microsoft/Edge/Application/msedge.exe"}));xr(vr,"browser",()=>"browser");xr(vr,"browserPrivate",()=>"browserPrivate");Dd=Nd});var bf=F(js=>{"use strict";Object.defineProperty(js,"__esModule",{value:!0});js.CircularBuffer=void 0;var jo=class{buffer=[];totalSize=0;maxSize;constructor(e=100){this.maxSize=e*1024}append(e){for(this.buffer.push(e),this.totalSize+=e.length;this.totalSize>this.maxSize&&this.buffer.length>1;){let t=this.buffer.shift();t&&(this.totalSize-=t.length)}}getContent(){return this.buffer.join("")}getLastBytes(e){let t=this.getContent();return t.length<=e?t:t.slice(-e)}getSize(){return this.totalSize}clear(){this.buffer=[],this.totalSize=0}};js.CircularBuffer=jo});var qs=F(Us=>{"use strict";Object.defineProperty(Us,"__esModule",{value:!0});Us.getApiUrl=Md;Us.getWsUrl=Bd;function Md(r){return`${r.getServerUrl()}/api`}function Bd(r){let e=r.getServerUrl();return e.startsWith("https://")?e.replace(/^https:\/\//,"wss://"):e.replace(/^http:\/\//,"ws://")}});var Tf=F(br=>{"use strict";Object.defineProperty(br,"__esModule",{value:!0});br.getWsUrl=br.getApiUrl=br.CircularBuffer=void 0;var jd=bf();Object.defineProperty(br,"CircularBuffer",{enumerable:!0,get:function(){return jd.CircularBuffer}});var Sf=qs();Object.defineProperty(br,"getApiUrl",{enumerable:!0,get:function(){return Sf.getApiUrl}});Object.defineProperty(br,"getWsUrl",{enumerable:!0,get:function(){return Sf.getWsUrl}})});var Cf=F(Of=>{"use strict";Object.defineProperty(Of,"__esModule",{value:!0})});var Pf=F(kf=>{"use strict";Object.defineProperty(kf,"__esModule",{value:!0})});var Rf=F(Ws=>{"use strict";Object.defineProperty(Ws,"__esModule",{value:!0});Ws.PLAN_LIMITS=void 0;Ws.PLAN_LIMITS={free:{maxAgents:1,maxTerminals:2,maxTeamMembers:1,historyDays:1},basic:{maxAgents:3,maxTerminals:10,maxTeamMembers:1,historyDays:7},pro:{maxAgents:10,maxTerminals:50,maxTeamMembers:5,historyDays:30}}});var If=F(Af=>{"use strict";Object.defineProperty(Af,"__esModule",{value:!0})});var Nf=F(Wt=>{"use strict";var Ud=Wt&&Wt.__createBinding||(Object.create?(function(r,e,t,n){n===void 0&&(n=t);var s=Object.getOwnPropertyDescriptor(e,t);(!s||("get"in s?!e.__esModule:s.writable||s.configurable))&&(s={enumerable:!0,get:function(){return e[t]}}),Object.defineProperty(r,n,s)}):(function(r,e,t,n){n===void 0&&(n=t),r[n]=e[t]})),Hs=Wt&&Wt.__exportStar||function(r,e){for(var t in r)t!=="default"&&!Object.prototype.hasOwnProperty.call(e,t)&&Ud(e,r,t)};Object.defineProperty(Wt,"__esModule",{value:!0});Hs(Cf(),Wt);Hs(Pf(),Wt);Hs(Rf(),Wt);Hs(If(),Wt)});var Lf=F(St=>{"use strict";Object.defineProperty(St,"__esModule",{value:!0});St.API_VERSION=St.WS_NAMESPACES=St.TIMEOUTS=St.STATUS_PATTERNS=St.TERMINAL_STATUSES=void 0;St.TERMINAL_STATUSES={idle:{label:"Idle",color:"gray",icon:"\u25CF"},working:{label:"Working",color:"blue",icon:"\u27F3"},waiting:{label:"Awaiting input",color:"orange",icon:"\u26A0"},completed:{label:"Completed",color:"green",icon:"\u2713"},error:{label:"Error",color:"red",icon:"\u2715"},offline:{label:"Offline",color:"black",icon:"\u26AB"}};St.STATUS_PATTERNS={idle:[/[❯$]\s*$/,/>\s*$/],waiting:[/\[Y\/n\]/i,/\(y\/N\)/i,/Continue\?/i,/proceed\?/i],completed:[/✓/,/Done/,/Completed/,/Success/],error:[/Error/,/Failed/,/✕/,/Exception/]};St.TIMEOUTS={HEARTBEAT_INTERVAL:3e4,OFFLINE_THRESHOLD:6e4,DEVICE_CODE_EXPIRY:9e5,DEVICE_CODE_POLL_INTERVAL:5e3};St.WS_NAMESPACES={AGENT:"/agent",CLIENT:"/client"};St.API_VERSION="v1"});var Df=F(Vs=>{"use strict";Object.defineProperty(Vs,"__esModule",{value:!0});Vs.isMultiRecipientPayload=qd;Vs.isEncryptedPayload=Wd;function qd(r){return typeof r=="object"&&r!==null&&"v"in r&&r.v===2&&"recipients"in r&&Array.isArray(r.recipients)}function Wd(r){if(typeof r!="object"||r===null||!("encrypted"in r))return!1;let e=r.encrypted;if(typeof e!="object"||e===null)return!1;let t=e;return typeof t.v=="number"&&typeof t.sid=="string"&&typeof t.n=="string"&&typeof t.c=="string"}});var Uo=F((BE,Ks)=>{(function(r){"use strict";var e=function(c){var h,l=new Float64Array(16);if(c)for(h=0;h<c.length;h++)l[h]=c[h];return l},t=function(){throw new Error("no PRNG")},n=new Uint8Array(16),s=new Uint8Array(32);s[0]=9;var i=e(),a=e([1]),f=e([56129,1]),u=e([30883,4953,19914,30187,55467,16705,2637,112,59544,30585,16505,36039,65139,11119,27886,20995]),d=e([61785,9906,39828,60374,45398,33411,5274,224,53552,61171,33010,6542,64743,22239,55772,9222]),g=e([54554,36645,11616,51542,42930,38181,51040,26924,56412,64982,57905,49316,21502,52590,14035,8553]),_=e([26200,26214,26214,26214,26214,26214,26214,26214,26214,26214,26214,26214,26214,26214,26214,26214]),y=e([41136,18958,6951,50414,58488,44335,6150,12099,55207,15867,153,11085,57099,20417,9344,11139]);function x(c,h,l,o){c[h]=l>>24&255,c[h+1]=l>>16&255,c[h+2]=l>>8&255,c[h+3]=l&255,c[h+4]=o>>24&255,c[h+5]=o>>16&255,c[h+6]=o>>8&255,c[h+7]=o&255}function S(c,h,l,o,p){var E,w=0;for(E=0;E<p;E++)w|=c[h+E]^l[o+E];return(1&w-1>>>8)-1}function C(c,h,l,o){return S(c,h,l,o,16)}function H(c,h,l,o){return S(c,h,l,o,32)}function z(c,h,l,o){for(var p=o[0]&255|(o[1]&255)<<8|(o[2]&255)<<16|(o[3]&255)<<24,E=l[0]&255|(l[1]&255)<<8|(l[2]&255)<<16|(l[3]&255)<<24,w=l[4]&255|(l[5]&255)<<8|(l[6]&255)<<16|(l[7]&255)<<24,k=l[8]&255|(l[9]&255)<<8|(l[10]&255)<<16|(l[11]&255)<<24,D=l[12]&255|(l[13]&255)<<8|(l[14]&255)<<16|(l[15]&255)<<24,Y=o[4]&255|(o[5]&255)<<8|(o[6]&255)<<16|(o[7]&255)<<24,q=h[0]&255|(h[1]&255)<<8|(h[2]&255)<<16|(h[3]&255)<<24,Te=h[4]&255|(h[5]&255)<<8|(h[6]&255)<<16|(h[7]&255)<<24,V=h[8]&255|(h[9]&255)<<8|(h[10]&255)<<16|(h[11]&255)<<24,te=h[12]&255|(h[13]&255)<<8|(h[14]&255)<<16|(h[15]&255)<<24,re=o[8]&255|(o[9]&255)<<8|(o[10]&255)<<16|(o[11]&255)<<24,fe=l[16]&255|(l[17]&255)<<8|(l[18]&255)<<16|(l[19]&255)<<24,ce=l[20]&255|(l[21]&255)<<8|(l[22]&255)<<16|(l[23]&255)<<24,ne=l[24]&255|(l[25]&255)<<8|(l[26]&255)<<16|(l[27]&255)<<24,ae=l[28]&255|(l[29]&255)<<8|(l[30]&255)<<16|(l[31]&255)<<24,se=o[12]&255|(o[13]&255)<<8|(o[14]&255)<<16|(o[15]&255)<<24,K=p,Z=E,W=w,$=k,G=D,U=Y,v=q,b=Te,R=V,O=te,P=re,L=fe,ee=ce,ue=ne,ge=ae,le=se,m,me=0;me<20;me+=2)m=K+ee|0,G^=m<<7|m>>>25,m=G+K|0,R^=m<<9|m>>>23,m=R+G|0,ee^=m<<13|m>>>19,m=ee+R|0,K^=m<<18|m>>>14,m=U+Z|0,O^=m<<7|m>>>25,m=O+U|0,ue^=m<<9|m>>>23,m=ue+O|0,Z^=m<<13|m>>>19,m=Z+ue|0,U^=m<<18|m>>>14,m=P+v|0,ge^=m<<7|m>>>25,m=ge+P|0,W^=m<<9|m>>>23,m=W+ge|0,v^=m<<13|m>>>19,m=v+W|0,P^=m<<18|m>>>14,m=le+L|0,$^=m<<7|m>>>25,m=$+le|0,b^=m<<9|m>>>23,m=b+$|0,L^=m<<13|m>>>19,m=L+b|0,le^=m<<18|m>>>14,m=K+$|0,Z^=m<<7|m>>>25,m=Z+K|0,W^=m<<9|m>>>23,m=W+Z|0,$^=m<<13|m>>>19,m=$+W|0,K^=m<<18|m>>>14,m=U+G|0,v^=m<<7|m>>>25,m=v+U|0,b^=m<<9|m>>>23,m=b+v|0,G^=m<<13|m>>>19,m=G+b|0,U^=m<<18|m>>>14,m=P+O|0,L^=m<<7|m>>>25,m=L+P|0,R^=m<<9|m>>>23,m=R+L|0,O^=m<<13|m>>>19,m=O+R|0,P^=m<<18|m>>>14,m=le+ge|0,ee^=m<<7|m>>>25,m=ee+le|0,ue^=m<<9|m>>>23,m=ue+ee|0,ge^=m<<13|m>>>19,m=ge+ue|0,le^=m<<18|m>>>14;K=K+p|0,Z=Z+E|0,W=W+w|0,$=$+k|0,G=G+D|0,U=U+Y|0,v=v+q|0,b=b+Te|0,R=R+V|0,O=O+te|0,P=P+re|0,L=L+fe|0,ee=ee+ce|0,ue=ue+ne|0,ge=ge+ae|0,le=le+se|0,c[0]=K>>>0&255,c[1]=K>>>8&255,c[2]=K>>>16&255,c[3]=K>>>24&255,c[4]=Z>>>0&255,c[5]=Z>>>8&255,c[6]=Z>>>16&255,c[7]=Z>>>24&255,c[8]=W>>>0&255,c[9]=W>>>8&255,c[10]=W>>>16&255,c[11]=W>>>24&255,c[12]=$>>>0&255,c[13]=$>>>8&255,c[14]=$>>>16&255,c[15]=$>>>24&255,c[16]=G>>>0&255,c[17]=G>>>8&255,c[18]=G>>>16&255,c[19]=G>>>24&255,c[20]=U>>>0&255,c[21]=U>>>8&255,c[22]=U>>>16&255,c[23]=U>>>24&255,c[24]=v>>>0&255,c[25]=v>>>8&255,c[26]=v>>>16&255,c[27]=v>>>24&255,c[28]=b>>>0&255,c[29]=b>>>8&255,c[30]=b>>>16&255,c[31]=b>>>24&255,c[32]=R>>>0&255,c[33]=R>>>8&255,c[34]=R>>>16&255,c[35]=R>>>24&255,c[36]=O>>>0&255,c[37]=O>>>8&255,c[38]=O>>>16&255,c[39]=O>>>24&255,c[40]=P>>>0&255,c[41]=P>>>8&255,c[42]=P>>>16&255,c[43]=P>>>24&255,c[44]=L>>>0&255,c[45]=L>>>8&255,c[46]=L>>>16&255,c[47]=L>>>24&255,c[48]=ee>>>0&255,c[49]=ee>>>8&255,c[50]=ee>>>16&255,c[51]=ee>>>24&255,c[52]=ue>>>0&255,c[53]=ue>>>8&255,c[54]=ue>>>16&255,c[55]=ue>>>24&255,c[56]=ge>>>0&255,c[57]=ge>>>8&255,c[58]=ge>>>16&255,c[59]=ge>>>24&255,c[60]=le>>>0&255,c[61]=le>>>8&255,c[62]=le>>>16&255,c[63]=le>>>24&255}function X(c,h,l,o){for(var p=o[0]&255|(o[1]&255)<<8|(o[2]&255)<<16|(o[3]&255)<<24,E=l[0]&255|(l[1]&255)<<8|(l[2]&255)<<16|(l[3]&255)<<24,w=l[4]&255|(l[5]&255)<<8|(l[6]&255)<<16|(l[7]&255)<<24,k=l[8]&255|(l[9]&255)<<8|(l[10]&255)<<16|(l[11]&255)<<24,D=l[12]&255|(l[13]&255)<<8|(l[14]&255)<<16|(l[15]&255)<<24,Y=o[4]&255|(o[5]&255)<<8|(o[6]&255)<<16|(o[7]&255)<<24,q=h[0]&255|(h[1]&255)<<8|(h[2]&255)<<16|(h[3]&255)<<24,Te=h[4]&255|(h[5]&255)<<8|(h[6]&255)<<16|(h[7]&255)<<24,V=h[8]&255|(h[9]&255)<<8|(h[10]&255)<<16|(h[11]&255)<<24,te=h[12]&255|(h[13]&255)<<8|(h[14]&255)<<16|(h[15]&255)<<24,re=o[8]&255|(o[9]&255)<<8|(o[10]&255)<<16|(o[11]&255)<<24,fe=l[16]&255|(l[17]&255)<<8|(l[18]&255)<<16|(l[19]&255)<<24,ce=l[20]&255|(l[21]&255)<<8|(l[22]&255)<<16|(l[23]&255)<<24,ne=l[24]&255|(l[25]&255)<<8|(l[26]&255)<<16|(l[27]&255)<<24,ae=l[28]&255|(l[29]&255)<<8|(l[30]&255)<<16|(l[31]&255)<<24,se=o[12]&255|(o[13]&255)<<8|(o[14]&255)<<16|(o[15]&255)<<24,K=p,Z=E,W=w,$=k,G=D,U=Y,v=q,b=Te,R=V,O=te,P=re,L=fe,ee=ce,ue=ne,ge=ae,le=se,m,me=0;me<20;me+=2)m=K+ee|0,G^=m<<7|m>>>25,m=G+K|0,R^=m<<9|m>>>23,m=R+G|0,ee^=m<<13|m>>>19,m=ee+R|0,K^=m<<18|m>>>14,m=U+Z|0,O^=m<<7|m>>>25,m=O+U|0,ue^=m<<9|m>>>23,m=ue+O|0,Z^=m<<13|m>>>19,m=Z+ue|0,U^=m<<18|m>>>14,m=P+v|0,ge^=m<<7|m>>>25,m=ge+P|0,W^=m<<9|m>>>23,m=W+ge|0,v^=m<<13|m>>>19,m=v+W|0,P^=m<<18|m>>>14,m=le+L|0,$^=m<<7|m>>>25,m=$+le|0,b^=m<<9|m>>>23,m=b+$|0,L^=m<<13|m>>>19,m=L+b|0,le^=m<<18|m>>>14,m=K+$|0,Z^=m<<7|m>>>25,m=Z+K|0,W^=m<<9|m>>>23,m=W+Z|0,$^=m<<13|m>>>19,m=$+W|0,K^=m<<18|m>>>14,m=U+G|0,v^=m<<7|m>>>25,m=v+U|0,b^=m<<9|m>>>23,m=b+v|0,G^=m<<13|m>>>19,m=G+b|0,U^=m<<18|m>>>14,m=P+O|0,L^=m<<7|m>>>25,m=L+P|0,R^=m<<9|m>>>23,m=R+L|0,O^=m<<13|m>>>19,m=O+R|0,P^=m<<18|m>>>14,m=le+ge|0,ee^=m<<7|m>>>25,m=ee+le|0,ue^=m<<9|m>>>23,m=ue+ee|0,ge^=m<<13|m>>>19,m=ge+ue|0,le^=m<<18|m>>>14;c[0]=K>>>0&255,c[1]=K>>>8&255,c[2]=K>>>16&255,c[3]=K>>>24&255,c[4]=U>>>0&255,c[5]=U>>>8&255,c[6]=U>>>16&255,c[7]=U>>>24&255,c[8]=P>>>0&255,c[9]=P>>>8&255,c[10]=P>>>16&255,c[11]=P>>>24&255,c[12]=le>>>0&255,c[13]=le>>>8&255,c[14]=le>>>16&255,c[15]=le>>>24&255,c[16]=v>>>0&255,c[17]=v>>>8&255,c[18]=v>>>16&255,c[19]=v>>>24&255,c[20]=b>>>0&255,c[21]=b>>>8&255,c[22]=b>>>16&255,c[23]=b>>>24&255,c[24]=R>>>0&255,c[25]=R>>>8&255,c[26]=R>>>16&255,c[27]=R>>>24&255,c[28]=O>>>0&255,c[29]=O>>>8&255,c[30]=O>>>16&255,c[31]=O>>>24&255}function T(c,h,l,o){z(c,h,l,o)}function M(c,h,l,o){X(c,h,l,o)}var Q=new Uint8Array([101,120,112,97,110,100,32,51,50,45,98,121,116,101,32,107]);function B(c,h,l,o,p,E,w){var k=new Uint8Array(16),D=new Uint8Array(64),Y,q;for(q=0;q<16;q++)k[q]=0;for(q=0;q<8;q++)k[q]=E[q];for(;p>=64;){for(T(D,k,w,Q),q=0;q<64;q++)c[h+q]=l[o+q]^D[q];for(Y=1,q=8;q<16;q++)Y=Y+(k[q]&255)|0,k[q]=Y&255,Y>>>=8;p-=64,h+=64,o+=64}if(p>0)for(T(D,k,w,Q),q=0;q<p;q++)c[h+q]=l[o+q]^D[q];return 0}function ie(c,h,l,o,p){var E=new Uint8Array(16),w=new Uint8Array(64),k,D;for(D=0;D<16;D++)E[D]=0;for(D=0;D<8;D++)E[D]=o[D];for(;l>=64;){for(T(w,E,p,Q),D=0;D<64;D++)c[h+D]=w[D];for(k=1,D=8;D<16;D++)k=k+(E[D]&255)|0,E[D]=k&255,k>>>=8;l-=64,h+=64}if(l>0)for(T(w,E,p,Q),D=0;D<l;D++)c[h+D]=w[D];return 0}function he(c,h,l,o,p){var E=new Uint8Array(32);M(E,o,p,Q);for(var w=new Uint8Array(8),k=0;k<8;k++)w[k]=o[k+16];return ie(c,h,l,w,E)}function de(c,h,l,o,p,E,w){var k=new Uint8Array(32);M(k,E,w,Q);for(var D=new Uint8Array(8),Y=0;Y<8;Y++)D[Y]=E[Y+16];return B(c,h,l,o,p,D,k)}var Pe=function(c){this.buffer=new Uint8Array(16),this.r=new Uint16Array(10),this.h=new Uint16Array(10),this.pad=new Uint16Array(8),this.leftover=0,this.fin=0;var h,l,o,p,E,w,k,D;h=c[0]&255|(c[1]&255)<<8,this.r[0]=h&8191,l=c[2]&255|(c[3]&255)<<8,this.r[1]=(h>>>13|l<<3)&8191,o=c[4]&255|(c[5]&255)<<8,this.r[2]=(l>>>10|o<<6)&7939,p=c[6]&255|(c[7]&255)<<8,this.r[3]=(o>>>7|p<<9)&8191,E=c[8]&255|(c[9]&255)<<8,this.r[4]=(p>>>4|E<<12)&255,this.r[5]=E>>>1&8190,w=c[10]&255|(c[11]&255)<<8,this.r[6]=(E>>>14|w<<2)&8191,k=c[12]&255|(c[13]&255)<<8,this.r[7]=(w>>>11|k<<5)&8065,D=c[14]&255|(c[15]&255)<<8,this.r[8]=(k>>>8|D<<8)&8191,this.r[9]=D>>>5&127,this.pad[0]=c[16]&255|(c[17]&255)<<8,this.pad[1]=c[18]&255|(c[19]&255)<<8,this.pad[2]=c[20]&255|(c[21]&255)<<8,this.pad[3]=c[22]&255|(c[23]&255)<<8,this.pad[4]=c[24]&255|(c[25]&255)<<8,this.pad[5]=c[26]&255|(c[27]&255)<<8,this.pad[6]=c[28]&255|(c[29]&255)<<8,this.pad[7]=c[30]&255|(c[31]&255)<<8};Pe.prototype.blocks=function(c,h,l){for(var o=this.fin?0:2048,p,E,w,k,D,Y,q,Te,V,te,re,fe,ce,ne,ae,se,K,Z,W,$=this.h[0],G=this.h[1],U=this.h[2],v=this.h[3],b=this.h[4],R=this.h[5],O=this.h[6],P=this.h[7],L=this.h[8],ee=this.h[9],ue=this.r[0],ge=this.r[1],le=this.r[2],m=this.r[3],me=this.r[4],Oe=this.r[5],Ce=this.r[6],_e=this.r[7],ve=this.r[8],be=this.r[9];l>=16;)p=c[h+0]&255|(c[h+1]&255)<<8,$+=p&8191,E=c[h+2]&255|(c[h+3]&255)<<8,G+=(p>>>13|E<<3)&8191,w=c[h+4]&255|(c[h+5]&255)<<8,U+=(E>>>10|w<<6)&8191,k=c[h+6]&255|(c[h+7]&255)<<8,v+=(w>>>7|k<<9)&8191,D=c[h+8]&255|(c[h+9]&255)<<8,b+=(k>>>4|D<<12)&8191,R+=D>>>1&8191,Y=c[h+10]&255|(c[h+11]&255)<<8,O+=(D>>>14|Y<<2)&8191,q=c[h+12]&255|(c[h+13]&255)<<8,P+=(Y>>>11|q<<5)&8191,Te=c[h+14]&255|(c[h+15]&255)<<8,L+=(q>>>8|Te<<8)&8191,ee+=Te>>>5|o,V=0,te=V,te+=$*ue,te+=G*(5*be),te+=U*(5*ve),te+=v*(5*_e),te+=b*(5*Ce),V=te>>>13,te&=8191,te+=R*(5*Oe),te+=O*(5*me),te+=P*(5*m),te+=L*(5*le),te+=ee*(5*ge),V+=te>>>13,te&=8191,re=V,re+=$*ge,re+=G*ue,re+=U*(5*be),re+=v*(5*ve),re+=b*(5*_e),V=re>>>13,re&=8191,re+=R*(5*Ce),re+=O*(5*Oe),re+=P*(5*me),re+=L*(5*m),re+=ee*(5*le),V+=re>>>13,re&=8191,fe=V,fe+=$*le,fe+=G*ge,fe+=U*ue,fe+=v*(5*be),fe+=b*(5*ve),V=fe>>>13,fe&=8191,fe+=R*(5*_e),fe+=O*(5*Ce),fe+=P*(5*Oe),fe+=L*(5*me),fe+=ee*(5*m),V+=fe>>>13,fe&=8191,ce=V,ce+=$*m,ce+=G*le,ce+=U*ge,ce+=v*ue,ce+=b*(5*be),V=ce>>>13,ce&=8191,ce+=R*(5*ve),ce+=O*(5*_e),ce+=P*(5*Ce),ce+=L*(5*Oe),ce+=ee*(5*me),V+=ce>>>13,ce&=8191,ne=V,ne+=$*me,ne+=G*m,ne+=U*le,ne+=v*ge,ne+=b*ue,V=ne>>>13,ne&=8191,ne+=R*(5*be),ne+=O*(5*ve),ne+=P*(5*_e),ne+=L*(5*Ce),ne+=ee*(5*Oe),V+=ne>>>13,ne&=8191,ae=V,ae+=$*Oe,ae+=G*me,ae+=U*m,ae+=v*le,ae+=b*ge,V=ae>>>13,ae&=8191,ae+=R*ue,ae+=O*(5*be),ae+=P*(5*ve),ae+=L*(5*_e),ae+=ee*(5*Ce),V+=ae>>>13,ae&=8191,se=V,se+=$*Ce,se+=G*Oe,se+=U*me,se+=v*m,se+=b*le,V=se>>>13,se&=8191,se+=R*ge,se+=O*ue,se+=P*(5*be),se+=L*(5*ve),se+=ee*(5*_e),V+=se>>>13,se&=8191,K=V,K+=$*_e,K+=G*Ce,K+=U*Oe,K+=v*me,K+=b*m,V=K>>>13,K&=8191,K+=R*le,K+=O*ge,K+=P*ue,K+=L*(5*be),K+=ee*(5*ve),V+=K>>>13,K&=8191,Z=V,Z+=$*ve,Z+=G*_e,Z+=U*Ce,Z+=v*Oe,Z+=b*me,V=Z>>>13,Z&=8191,Z+=R*m,Z+=O*le,Z+=P*ge,Z+=L*ue,Z+=ee*(5*be),V+=Z>>>13,Z&=8191,W=V,W+=$*be,W+=G*ve,W+=U*_e,W+=v*Ce,W+=b*Oe,V=W>>>13,W&=8191,W+=R*me,W+=O*m,W+=P*le,W+=L*ge,W+=ee*ue,V+=W>>>13,W&=8191,V=(V<<2)+V|0,V=V+te|0,te=V&8191,V=V>>>13,re+=V,$=te,G=re,U=fe,v=ce,b=ne,R=ae,O=se,P=K,L=Z,ee=W,h+=16,l-=16;this.h[0]=$,this.h[1]=G,this.h[2]=U,this.h[3]=v,this.h[4]=b,this.h[5]=R,this.h[6]=O,this.h[7]=P,this.h[8]=L,this.h[9]=ee},Pe.prototype.finish=function(c,h){var l=new Uint16Array(10),o,p,E,w;if(this.leftover){for(w=this.leftover,this.buffer[w++]=1;w<16;w++)this.buffer[w]=0;this.fin=1,this.blocks(this.buffer,0,16)}for(o=this.h[1]>>>13,this.h[1]&=8191,w=2;w<10;w++)this.h[w]+=o,o=this.h[w]>>>13,this.h[w]&=8191;for(this.h[0]+=o*5,o=this.h[0]>>>13,this.h[0]&=8191,this.h[1]+=o,o=this.h[1]>>>13,this.h[1]&=8191,this.h[2]+=o,l[0]=this.h[0]+5,o=l[0]>>>13,l[0]&=8191,w=1;w<10;w++)l[w]=this.h[w]+o,o=l[w]>>>13,l[w]&=8191;for(l[9]-=8192,p=(o^1)-1,w=0;w<10;w++)l[w]&=p;for(p=~p,w=0;w<10;w++)this.h[w]=this.h[w]&p|l[w];for(this.h[0]=(this.h[0]|this.h[1]<<13)&65535,this.h[1]=(this.h[1]>>>3|this.h[2]<<10)&65535,this.h[2]=(this.h[2]>>>6|this.h[3]<<7)&65535,this.h[3]=(this.h[3]>>>9|this.h[4]<<4)&65535,this.h[4]=(this.h[4]>>>12|this.h[5]<<1|this.h[6]<<14)&65535,this.h[5]=(this.h[6]>>>2|this.h[7]<<11)&65535,this.h[6]=(this.h[7]>>>5|this.h[8]<<8)&65535,this.h[7]=(this.h[8]>>>8|this.h[9]<<5)&65535,E=this.h[0]+this.pad[0],this.h[0]=E&65535,w=1;w<8;w++)E=(this.h[w]+this.pad[w]|0)+(E>>>16)|0,this.h[w]=E&65535;c[h+0]=this.h[0]>>>0&255,c[h+1]=this.h[0]>>>8&255,c[h+2]=this.h[1]>>>0&255,c[h+3]=this.h[1]>>>8&255,c[h+4]=this.h[2]>>>0&255,c[h+5]=this.h[2]>>>8&255,c[h+6]=this.h[3]>>>0&255,c[h+7]=this.h[3]>>>8&255,c[h+8]=this.h[4]>>>0&255,c[h+9]=this.h[4]>>>8&255,c[h+10]=this.h[5]>>>0&255,c[h+11]=this.h[5]>>>8&255,c[h+12]=this.h[6]>>>0&255,c[h+13]=this.h[6]>>>8&255,c[h+14]=this.h[7]>>>0&255,c[h+15]=this.h[7]>>>8&255},Pe.prototype.update=function(c,h,l){var o,p;if(this.leftover){for(p=16-this.leftover,p>l&&(p=l),o=0;o<p;o++)this.buffer[this.leftover+o]=c[h+o];if(l-=p,h+=p,this.leftover+=p,this.leftover<16)return;this.blocks(this.buffer,0,16),this.leftover=0}if(l>=16&&(p=l-l%16,this.blocks(c,h,p),h+=p,l-=p),l){for(o=0;o<l;o++)this.buffer[this.leftover+o]=c[h+o];this.leftover+=l}};function qe(c,h,l,o,p,E){var w=new Pe(E);return w.update(l,o,p),w.finish(c,h),0}function Ge(c,h,l,o,p,E){var w=new Uint8Array(16);return qe(w,0,l,o,p,E),C(c,h,w,0)}function xe(c,h,l,o,p){var E;if(l<32)return-1;for(de(c,0,h,0,l,o,p),qe(c,16,c,32,l-32,c),E=0;E<16;E++)c[E]=0;return 0}function Ye(c,h,l,o,p){var E,w=new Uint8Array(32);if(l<32||(he(w,0,32,o,p),Ge(h,16,h,32,l-32,w)!==0))return-1;for(de(c,0,h,0,l,o,p),E=0;E<32;E++)c[E]=0;return 0}function De(c,h){var l;for(l=0;l<16;l++)c[l]=h[l]|0}function J(c){var h,l,o=1;for(h=0;h<16;h++)l=c[h]+o+65535,o=Math.floor(l/65536),c[h]=l-o*65536;c[0]+=o-1+37*(o-1)}function ye(c,h,l){for(var o,p=~(l-1),E=0;E<16;E++)o=p&(c[E]^h[E]),c[E]^=o,h[E]^=o}function pe(c,h){var l,o,p,E=e(),w=e();for(l=0;l<16;l++)w[l]=h[l];for(J(w),J(w),J(w),o=0;o<2;o++){for(E[0]=w[0]-65517,l=1;l<15;l++)E[l]=w[l]-65535-(E[l-1]>>16&1),E[l-1]&=65535;E[15]=w[15]-32767-(E[14]>>16&1),p=E[15]>>16&1,E[14]&=65535,ye(w,E,1-p)}for(l=0;l<16;l++)c[2*l]=w[l]&255,c[2*l+1]=w[l]>>8}function rt(c,h){var l=new Uint8Array(32),o=new Uint8Array(32);return pe(l,c),pe(o,h),H(l,0,o,0)}function Ze(c){var h=new Uint8Array(32);return pe(h,c),h[0]&1}function qt(c,h){var l;for(l=0;l<16;l++)c[l]=h[2*l]+(h[2*l+1]<<8);c[15]&=32767}function N(c,h,l){for(var o=0;o<16;o++)c[o]=h[o]+l[o]}function j(c,h,l){for(var o=0;o<16;o++)c[o]=h[o]-l[o]}function A(c,h,l){var o,p,E=0,w=0,k=0,D=0,Y=0,q=0,Te=0,V=0,te=0,re=0,fe=0,ce=0,ne=0,ae=0,se=0,K=0,Z=0,W=0,$=0,G=0,U=0,v=0,b=0,R=0,O=0,P=0,L=0,ee=0,ue=0,ge=0,le=0,m=l[0],me=l[1],Oe=l[2],Ce=l[3],_e=l[4],ve=l[5],be=l[6],ze=l[7],Re=l[8],He=l[9],Ve=l[10],Ke=l[11],Je=l[12],st=l[13],it=l[14],ot=l[15];o=h[0],E+=o*m,w+=o*me,k+=o*Oe,D+=o*Ce,Y+=o*_e,q+=o*ve,Te+=o*be,V+=o*ze,te+=o*Re,re+=o*He,fe+=o*Ve,ce+=o*Ke,ne+=o*Je,ae+=o*st,se+=o*it,K+=o*ot,o=h[1],w+=o*m,k+=o*me,D+=o*Oe,Y+=o*Ce,q+=o*_e,Te+=o*ve,V+=o*be,te+=o*ze,re+=o*Re,fe+=o*He,ce+=o*Ve,ne+=o*Ke,ae+=o*Je,se+=o*st,K+=o*it,Z+=o*ot,o=h[2],k+=o*m,D+=o*me,Y+=o*Oe,q+=o*Ce,Te+=o*_e,V+=o*ve,te+=o*be,re+=o*ze,fe+=o*Re,ce+=o*He,ne+=o*Ve,ae+=o*Ke,se+=o*Je,K+=o*st,Z+=o*it,W+=o*ot,o=h[3],D+=o*m,Y+=o*me,q+=o*Oe,Te+=o*Ce,V+=o*_e,te+=o*ve,re+=o*be,fe+=o*ze,ce+=o*Re,ne+=o*He,ae+=o*Ve,se+=o*Ke,K+=o*Je,Z+=o*st,W+=o*it,$+=o*ot,o=h[4],Y+=o*m,q+=o*me,Te+=o*Oe,V+=o*Ce,te+=o*_e,re+=o*ve,fe+=o*be,ce+=o*ze,ne+=o*Re,ae+=o*He,se+=o*Ve,K+=o*Ke,Z+=o*Je,W+=o*st,$+=o*it,G+=o*ot,o=h[5],q+=o*m,Te+=o*me,V+=o*Oe,te+=o*Ce,re+=o*_e,fe+=o*ve,ce+=o*be,ne+=o*ze,ae+=o*Re,se+=o*He,K+=o*Ve,Z+=o*Ke,W+=o*Je,$+=o*st,G+=o*it,U+=o*ot,o=h[6],Te+=o*m,V+=o*me,te+=o*Oe,re+=o*Ce,fe+=o*_e,ce+=o*ve,ne+=o*be,ae+=o*ze,se+=o*Re,K+=o*He,Z+=o*Ve,W+=o*Ke,$+=o*Je,G+=o*st,U+=o*it,v+=o*ot,o=h[7],V+=o*m,te+=o*me,re+=o*Oe,fe+=o*Ce,ce+=o*_e,ne+=o*ve,ae+=o*be,se+=o*ze,K+=o*Re,Z+=o*He,W+=o*Ve,$+=o*Ke,G+=o*Je,U+=o*st,v+=o*it,b+=o*ot,o=h[8],te+=o*m,re+=o*me,fe+=o*Oe,ce+=o*Ce,ne+=o*_e,ae+=o*ve,se+=o*be,K+=o*ze,Z+=o*Re,W+=o*He,$+=o*Ve,G+=o*Ke,U+=o*Je,v+=o*st,b+=o*it,R+=o*ot,o=h[9],re+=o*m,fe+=o*me,ce+=o*Oe,ne+=o*Ce,ae+=o*_e,se+=o*ve,K+=o*be,Z+=o*ze,W+=o*Re,$+=o*He,G+=o*Ve,U+=o*Ke,v+=o*Je,b+=o*st,R+=o*it,O+=o*ot,o=h[10],fe+=o*m,ce+=o*me,ne+=o*Oe,ae+=o*Ce,se+=o*_e,K+=o*ve,Z+=o*be,W+=o*ze,$+=o*Re,G+=o*He,U+=o*Ve,v+=o*Ke,b+=o*Je,R+=o*st,O+=o*it,P+=o*ot,o=h[11],ce+=o*m,ne+=o*me,ae+=o*Oe,se+=o*Ce,K+=o*_e,Z+=o*ve,W+=o*be,$+=o*ze,G+=o*Re,U+=o*He,v+=o*Ve,b+=o*Ke,R+=o*Je,O+=o*st,P+=o*it,L+=o*ot,o=h[12],ne+=o*m,ae+=o*me,se+=o*Oe,K+=o*Ce,Z+=o*_e,W+=o*ve,$+=o*be,G+=o*ze,U+=o*Re,v+=o*He,b+=o*Ve,R+=o*Ke,O+=o*Je,P+=o*st,L+=o*it,ee+=o*ot,o=h[13],ae+=o*m,se+=o*me,K+=o*Oe,Z+=o*Ce,W+=o*_e,$+=o*ve,G+=o*be,U+=o*ze,v+=o*Re,b+=o*He,R+=o*Ve,O+=o*Ke,P+=o*Je,L+=o*st,ee+=o*it,ue+=o*ot,o=h[14],se+=o*m,K+=o*me,Z+=o*Oe,W+=o*Ce,$+=o*_e,G+=o*ve,U+=o*be,v+=o*ze,b+=o*Re,R+=o*He,O+=o*Ve,P+=o*Ke,L+=o*Je,ee+=o*st,ue+=o*it,ge+=o*ot,o=h[15],K+=o*m,Z+=o*me,W+=o*Oe,$+=o*Ce,G+=o*_e,U+=o*ve,v+=o*be,b+=o*ze,R+=o*Re,O+=o*He,P+=o*Ve,L+=o*Ke,ee+=o*Je,ue+=o*st,ge+=o*it,le+=o*ot,E+=38*Z,w+=38*W,k+=38*$,D+=38*G,Y+=38*U,q+=38*v,Te+=38*b,V+=38*R,te+=38*O,re+=38*P,fe+=38*L,ce+=38*ee,ne+=38*ue,ae+=38*ge,se+=38*le,p=1,o=E+p+65535,p=Math.floor(o/65536),E=o-p*65536,o=w+p+65535,p=Math.floor(o/65536),w=o-p*65536,o=k+p+65535,p=Math.floor(o/65536),k=o-p*65536,o=D+p+65535,p=Math.floor(o/65536),D=o-p*65536,o=Y+p+65535,p=Math.floor(o/65536),Y=o-p*65536,o=q+p+65535,p=Math.floor(o/65536),q=o-p*65536,o=Te+p+65535,p=Math.floor(o/65536),Te=o-p*65536,o=V+p+65535,p=Math.floor(o/65536),V=o-p*65536,o=te+p+65535,p=Math.floor(o/65536),te=o-p*65536,o=re+p+65535,p=Math.floor(o/65536),re=o-p*65536,o=fe+p+65535,p=Math.floor(o/65536),fe=o-p*65536,o=ce+p+65535,p=Math.floor(o/65536),ce=o-p*65536,o=ne+p+65535,p=Math.floor(o/65536),ne=o-p*65536,o=ae+p+65535,p=Math.floor(o/65536),ae=o-p*65536,o=se+p+65535,p=Math.floor(o/65536),se=o-p*65536,o=K+p+65535,p=Math.floor(o/65536),K=o-p*65536,E+=p-1+37*(p-1),p=1,o=E+p+65535,p=Math.floor(o/65536),E=o-p*65536,o=w+p+65535,p=Math.floor(o/65536),w=o-p*65536,o=k+p+65535,p=Math.floor(o/65536),k=o-p*65536,o=D+p+65535,p=Math.floor(o/65536),D=o-p*65536,o=Y+p+65535,p=Math.floor(o/65536),Y=o-p*65536,o=q+p+65535,p=Math.floor(o/65536),q=o-p*65536,o=Te+p+65535,p=Math.floor(o/65536),Te=o-p*65536,o=V+p+65535,p=Math.floor(o/65536),V=o-p*65536,o=te+p+65535,p=Math.floor(o/65536),te=o-p*65536,o=re+p+65535,p=Math.floor(o/65536),re=o-p*65536,o=fe+p+65535,p=Math.floor(o/65536),fe=o-p*65536,o=ce+p+65535,p=Math.floor(o/65536),ce=o-p*65536,o=ne+p+65535,p=Math.floor(o/65536),ne=o-p*65536,o=ae+p+65535,p=Math.floor(o/65536),ae=o-p*65536,o=se+p+65535,p=Math.floor(o/65536),se=o-p*65536,o=K+p+65535,p=Math.floor(o/65536),K=o-p*65536,E+=p-1+37*(p-1),c[0]=E,c[1]=w,c[2]=k,c[3]=D,c[4]=Y,c[5]=q,c[6]=Te,c[7]=V,c[8]=te,c[9]=re,c[10]=fe,c[11]=ce,c[12]=ne,c[13]=ae,c[14]=se,c[15]=K}function oe(c,h){A(c,h,h)}function Ae(c,h){var l=e(),o;for(o=0;o<16;o++)l[o]=h[o];for(o=253;o>=0;o--)oe(l,l),o!==2&&o!==4&&A(l,l,h);for(o=0;o<16;o++)c[o]=l[o]}function ft(c,h){var l=e(),o;for(o=0;o<16;o++)l[o]=h[o];for(o=250;o>=0;o--)oe(l,l),o!==1&&A(l,l,h);for(o=0;o<16;o++)c[o]=l[o]}function gt(c,h,l){var o=new Uint8Array(32),p=new Float64Array(80),E,w,k=e(),D=e(),Y=e(),q=e(),Te=e(),V=e();for(w=0;w<31;w++)o[w]=h[w];for(o[31]=h[31]&127|64,o[0]&=248,qt(p,l),w=0;w<16;w++)D[w]=p[w],q[w]=k[w]=Y[w]=0;for(k[0]=q[0]=1,w=254;w>=0;--w)E=o[w>>>3]>>>(w&7)&1,ye(k,D,E),ye(Y,q,E),N(Te,k,Y),j(k,k,Y),N(Y,D,q),j(D,D,q),oe(q,Te),oe(V,k),A(k,Y,k),A(Y,D,Te),N(Te,k,Y),j(k,k,Y),oe(D,k),j(Y,q,V),A(k,Y,f),N(k,k,q),A(Y,Y,k),A(k,q,V),A(q,D,p),oe(D,Te),ye(k,D,E),ye(Y,q,E);for(w=0;w<16;w++)p[w+16]=k[w],p[w+32]=Y[w],p[w+48]=D[w],p[w+64]=q[w];var te=p.subarray(32),re=p.subarray(16);return Ae(te,te),A(re,re,te),pe(c,re),0}function _t(c,h){return gt(c,h,s)}function mt(c,h){return t(h,32),_t(c,h)}function rr(c,h,l){var o=new Uint8Array(32);return gt(o,l,h),M(c,n,o,Q)}var yr=xe,Br=Ye;function Er(c,h,l,o,p,E){var w=new Uint8Array(32);return rr(w,p,E),yr(c,h,l,o,w)}function hn(c,h,l,o,p,E){var w=new Uint8Array(32);return rr(w,p,E),Br(c,h,l,o,w)}var Ts=[1116352408,3609767458,1899447441,602891725,3049323471,3964484399,3921009573,2173295548,961987163,4081628472,1508970993,3053834265,2453635748,2937671579,2870763221,3664609560,3624381080,2734883394,310598401,1164996542,607225278,1323610764,1426881987,3590304994,1925078388,4068182383,2162078206,991336113,2614888103,633803317,3248222580,3479774868,3835390401,2666613458,4022224774,944711139,264347078,2341262773,604807628,2007800933,770255983,1495990901,1249150122,1856431235,1555081692,3175218132,1996064986,2198950837,2554220882,3999719339,2821834349,766784016,2952996808,2566594879,3210313671,3203337956,3336571891,1034457026,3584528711,2466948901,113926993,3758326383,338241895,168717936,666307205,1188179964,773529912,1546045734,1294757372,1522805485,1396182291,2643833823,1695183700,2343527390,1986661051,1014477480,2177026350,1206759142,2456956037,344077627,2730485921,1290863460,2820302411,3158454273,3259730800,3505952657,3345764771,106217008,3516065817,3606008344,3600352804,1432725776,4094571909,1467031594,275423344,851169720,430227734,3100823752,506948616,1363258195,659060556,3750685593,883997877,3785050280,958139571,3318307427,1322822218,3812723403,1537002063,2003034995,1747873779,3602036899,1955562222,1575990012,2024104815,1125592928,2227730452,2716904306,2361852424,442776044,2428436474,593698344,2756734187,3733110249,3204031479,2999351573,3329325298,3815920427,3391569614,3928383900,3515267271,566280711,3940187606,3454069534,4118630271,4000239992,116418474,1914138554,174292421,2731055270,289380356,3203993006,460393269,320620315,685471733,587496836,852142971,1086792851,1017036298,365543100,1126000580,2618297676,1288033470,3409855158,1501505948,4234509866,1607167915,987167468,1816402316,1246189591];function Fc(c,h,l,o){for(var p=new Int32Array(16),E=new Int32Array(16),w,k,D,Y,q,Te,V,te,re,fe,ce,ne,ae,se,K,Z,W,$,G,U,v,b,R,O,P,L,ee=c[0],ue=c[1],ge=c[2],le=c[3],m=c[4],me=c[5],Oe=c[6],Ce=c[7],_e=h[0],ve=h[1],be=h[2],ze=h[3],Re=h[4],He=h[5],Ve=h[6],Ke=h[7],Je=0;o>=128;){for(G=0;G<16;G++)U=8*G+Je,p[G]=l[U+0]<<24|l[U+1]<<16|l[U+2]<<8|l[U+3],E[G]=l[U+4]<<24|l[U+5]<<16|l[U+6]<<8|l[U+7];for(G=0;G<80;G++)if(w=ee,k=ue,D=ge,Y=le,q=m,Te=me,V=Oe,te=Ce,re=_e,fe=ve,ce=be,ne=ze,ae=Re,se=He,K=Ve,Z=Ke,v=Ce,b=Ke,R=b&65535,O=b>>>16,P=v&65535,L=v>>>16,v=(m>>>14|Re<<18)^(m>>>18|Re<<14)^(Re>>>9|m<<23),b=(Re>>>14|m<<18)^(Re>>>18|m<<14)^(m>>>9|Re<<23),R+=b&65535,O+=b>>>16,P+=v&65535,L+=v>>>16,v=m&me^~m&Oe,b=Re&He^~Re&Ve,R+=b&65535,O+=b>>>16,P+=v&65535,L+=v>>>16,v=Ts[G*2],b=Ts[G*2+1],R+=b&65535,O+=b>>>16,P+=v&65535,L+=v>>>16,v=p[G%16],b=E[G%16],R+=b&65535,O+=b>>>16,P+=v&65535,L+=v>>>16,O+=R>>>16,P+=O>>>16,L+=P>>>16,W=P&65535|L<<16,$=R&65535|O<<16,v=W,b=$,R=b&65535,O=b>>>16,P=v&65535,L=v>>>16,v=(ee>>>28|_e<<4)^(_e>>>2|ee<<30)^(_e>>>7|ee<<25),b=(_e>>>28|ee<<4)^(ee>>>2|_e<<30)^(ee>>>7|_e<<25),R+=b&65535,O+=b>>>16,P+=v&65535,L+=v>>>16,v=ee&ue^ee&ge^ue&ge,b=_e&ve^_e&be^ve&be,R+=b&65535,O+=b>>>16,P+=v&65535,L+=v>>>16,O+=R>>>16,P+=O>>>16,L+=P>>>16,te=P&65535|L<<16,Z=R&65535|O<<16,v=Y,b=ne,R=b&65535,O=b>>>16,P=v&65535,L=v>>>16,v=W,b=$,R+=b&65535,O+=b>>>16,P+=v&65535,L+=v>>>16,O+=R>>>16,P+=O>>>16,L+=P>>>16,Y=P&65535|L<<16,ne=R&65535|O<<16,ue=w,ge=k,le=D,m=Y,me=q,Oe=Te,Ce=V,ee=te,ve=re,be=fe,ze=ce,Re=ne,He=ae,Ve=se,Ke=K,_e=Z,G%16===15)for(U=0;U<16;U++)v=p[U],b=E[U],R=b&65535,O=b>>>16,P=v&65535,L=v>>>16,v=p[(U+9)%16],b=E[(U+9)%16],R+=b&65535,O+=b>>>16,P+=v&65535,L+=v>>>16,W=p[(U+1)%16],$=E[(U+1)%16],v=(W>>>1|$<<31)^(W>>>8|$<<24)^W>>>7,b=($>>>1|W<<31)^($>>>8|W<<24)^($>>>7|W<<25),R+=b&65535,O+=b>>>16,P+=v&65535,L+=v>>>16,W=p[(U+14)%16],$=E[(U+14)%16],v=(W>>>19|$<<13)^($>>>29|W<<3)^W>>>6,b=($>>>19|W<<13)^(W>>>29|$<<3)^($>>>6|W<<26),R+=b&65535,O+=b>>>16,P+=v&65535,L+=v>>>16,O+=R>>>16,P+=O>>>16,L+=P>>>16,p[U]=P&65535|L<<16,E[U]=R&65535|O<<16;v=ee,b=_e,R=b&65535,O=b>>>16,P=v&65535,L=v>>>16,v=c[0],b=h[0],R+=b&65535,O+=b>>>16,P+=v&65535,L+=v>>>16,O+=R>>>16,P+=O>>>16,L+=P>>>16,c[0]=ee=P&65535|L<<16,h[0]=_e=R&65535|O<<16,v=ue,b=ve,R=b&65535,O=b>>>16,P=v&65535,L=v>>>16,v=c[1],b=h[1],R+=b&65535,O+=b>>>16,P+=v&65535,L+=v>>>16,O+=R>>>16,P+=O>>>16,L+=P>>>16,c[1]=ue=P&65535|L<<16,h[1]=ve=R&65535|O<<16,v=ge,b=be,R=b&65535,O=b>>>16,P=v&65535,L=v>>>16,v=c[2],b=h[2],R+=b&65535,O+=b>>>16,P+=v&65535,L+=v>>>16,O+=R>>>16,P+=O>>>16,L+=P>>>16,c[2]=ge=P&65535|L<<16,h[2]=be=R&65535|O<<16,v=le,b=ze,R=b&65535,O=b>>>16,P=v&65535,L=v>>>16,v=c[3],b=h[3],R+=b&65535,O+=b>>>16,P+=v&65535,L+=v>>>16,O+=R>>>16,P+=O>>>16,L+=P>>>16,c[3]=le=P&65535|L<<16,h[3]=ze=R&65535|O<<16,v=m,b=Re,R=b&65535,O=b>>>16,P=v&65535,L=v>>>16,v=c[4],b=h[4],R+=b&65535,O+=b>>>16,P+=v&65535,L+=v>>>16,O+=R>>>16,P+=O>>>16,L+=P>>>16,c[4]=m=P&65535|L<<16,h[4]=Re=R&65535|O<<16,v=me,b=He,R=b&65535,O=b>>>16,P=v&65535,L=v>>>16,v=c[5],b=h[5],R+=b&65535,O+=b>>>16,P+=v&65535,L+=v>>>16,O+=R>>>16,P+=O>>>16,L+=P>>>16,c[5]=me=P&65535|L<<16,h[5]=He=R&65535|O<<16,v=Oe,b=Ve,R=b&65535,O=b>>>16,P=v&65535,L=v>>>16,v=c[6],b=h[6],R+=b&65535,O+=b>>>16,P+=v&65535,L+=v>>>16,O+=R>>>16,P+=O>>>16,L+=P>>>16,c[6]=Oe=P&65535|L<<16,h[6]=Ve=R&65535|O<<16,v=Ce,b=Ke,R=b&65535,O=b>>>16,P=v&65535,L=v>>>16,v=c[7],b=h[7],R+=b&65535,O+=b>>>16,P+=v&65535,L+=v>>>16,O+=R>>>16,P+=O>>>16,L+=P>>>16,c[7]=Ce=P&65535|L<<16,h[7]=Ke=R&65535|O<<16,Je+=128,o-=128}return o}function jr(c,h,l){var o=new Int32Array(8),p=new Int32Array(8),E=new Uint8Array(256),w,k=l;for(o[0]=1779033703,o[1]=3144134277,o[2]=1013904242,o[3]=2773480762,o[4]=1359893119,o[5]=2600822924,o[6]=528734635,o[7]=1541459225,p[0]=4089235720,p[1]=2227873595,p[2]=4271175723,p[3]=1595750129,p[4]=2917565137,p[5]=725511199,p[6]=4215389547,p[7]=327033209,Fc(o,p,h,l),l%=128,w=0;w<l;w++)E[w]=h[k-l+w];for(E[l]=128,l=256-128*(l<112?1:0),E[l-9]=0,x(E,l-8,k/536870912|0,k<<3),Fc(o,p,E,l),w=0;w<8;w++)x(c,8*w,o[w],p[w]);return 0}function Os(c,h){var l=e(),o=e(),p=e(),E=e(),w=e(),k=e(),D=e(),Y=e(),q=e();j(l,c[1],c[0]),j(q,h[1],h[0]),A(l,l,q),N(o,c[0],c[1]),N(q,h[0],h[1]),A(o,o,q),A(p,c[3],h[3]),A(p,p,d),A(E,c[2],h[2]),N(E,E,E),j(w,o,l),j(k,E,p),N(D,E,p),N(Y,o,l),A(c[0],w,k),A(c[1],Y,D),A(c[2],D,k),A(c[3],w,Y)}function Mc(c,h,l){var o;for(o=0;o<4;o++)ye(c[o],h[o],l)}function io(c,h){var l=e(),o=e(),p=e();Ae(p,h[2]),A(l,h[0],p),A(o,h[1],p),pe(c,o),c[31]^=Ze(l)<<7}function oo(c,h,l){var o,p;for(De(c[0],i),De(c[1],a),De(c[2],a),De(c[3],i),p=255;p>=0;--p)o=l[p/8|0]>>(p&7)&1,Mc(c,h,o),Os(h,c),Os(c,c),Mc(c,h,o)}function Cs(c,h){var l=[e(),e(),e(),e()];De(l[0],g),De(l[1],_),De(l[2],a),A(l[3],g,_),oo(c,l,h)}function ao(c,h,l){var o=new Uint8Array(64),p=[e(),e(),e(),e()],E;for(l||t(h,32),jr(o,h,32),o[0]&=248,o[31]&=127,o[31]|=64,Cs(p,o),io(c,p),E=0;E<32;E++)h[E+32]=c[E];return 0}var ks=new Float64Array([237,211,245,92,26,99,18,88,214,156,247,162,222,249,222,20,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,16]);function co(c,h){var l,o,p,E;for(o=63;o>=32;--o){for(l=0,p=o-32,E=o-12;p<E;++p)h[p]+=l-16*h[o]*ks[p-(o-32)],l=Math.floor((h[p]+128)/256),h[p]-=l*256;h[p]+=l,h[o]=0}for(l=0,p=0;p<32;p++)h[p]+=l-(h[31]>>4)*ks[p],l=h[p]>>8,h[p]&=255;for(p=0;p<32;p++)h[p]-=l*ks[p];for(o=0;o<32;o++)h[o+1]+=h[o]>>8,c[o]=h[o]&255}function fo(c){var h=new Float64Array(64),l;for(l=0;l<64;l++)h[l]=c[l];for(l=0;l<64;l++)c[l]=0;co(c,h)}function Bc(c,h,l,o){var p=new Uint8Array(64),E=new Uint8Array(64),w=new Uint8Array(64),k,D,Y=new Float64Array(64),q=[e(),e(),e(),e()];jr(p,o,32),p[0]&=248,p[31]&=127,p[31]|=64;var Te=l+64;for(k=0;k<l;k++)c[64+k]=h[k];for(k=0;k<32;k++)c[32+k]=p[32+k];for(jr(w,c.subarray(32),l+32),fo(w),Cs(q,w),io(c,q),k=32;k<64;k++)c[k]=o[k];for(jr(E,c,l+64),fo(E),k=0;k<64;k++)Y[k]=0;for(k=0;k<32;k++)Y[k]=w[k];for(k=0;k<32;k++)for(D=0;D<32;D++)Y[k+D]+=E[k]*p[D];return co(c.subarray(32),Y),Te}function fd(c,h){var l=e(),o=e(),p=e(),E=e(),w=e(),k=e(),D=e();return De(c[2],a),qt(c[1],h),oe(p,c[1]),A(E,p,u),j(p,p,c[2]),N(E,c[2],E),oe(w,E),oe(k,w),A(D,k,w),A(l,D,p),A(l,l,E),ft(l,l),A(l,l,p),A(l,l,E),A(l,l,E),A(c[0],l,E),oe(o,c[0]),A(o,o,E),rt(o,p)&&A(c[0],c[0],y),oe(o,c[0]),A(o,o,E),rt(o,p)?-1:(Ze(c[0])===h[31]>>7&&j(c[0],i,c[0]),A(c[3],c[0],c[1]),0)}function uo(c,h,l,o){var p,E=new Uint8Array(32),w=new Uint8Array(64),k=[e(),e(),e(),e()],D=[e(),e(),e(),e()];if(l<64||fd(D,o))return-1;for(p=0;p<l;p++)c[p]=h[p];for(p=0;p<32;p++)c[p+32]=o[p];if(jr(w,c,l),fo(w),oo(k,D,w),Cs(D,h.subarray(32)),Os(k,D),io(E,k),l-=64,H(h,0,E,0)){for(p=0;p<l;p++)c[p]=0;return-1}for(p=0;p<l;p++)c[p]=h[p+64];return l}var lo=32,Ps=24,Wn=32,dn=16,Hn=32,Rs=32,Vn=32,Kn=32,ho=32,jc=Ps,ud=Wn,ld=dn,nr=64,Ur=32,pn=64,po=32,go=64;r.lowlevel={crypto_core_hsalsa20:M,crypto_stream_xor:de,crypto_stream:he,crypto_stream_salsa20_xor:B,crypto_stream_salsa20:ie,crypto_onetimeauth:qe,crypto_onetimeauth_verify:Ge,crypto_verify_16:C,crypto_verify_32:H,crypto_secretbox:xe,crypto_secretbox_open:Ye,crypto_scalarmult:gt,crypto_scalarmult_base:_t,crypto_box_beforenm:rr,crypto_box_afternm:yr,crypto_box:Er,crypto_box_open:hn,crypto_box_keypair:mt,crypto_hash:jr,crypto_sign:Bc,crypto_sign_keypair:ao,crypto_sign_open:uo,crypto_secretbox_KEYBYTES:lo,crypto_secretbox_NONCEBYTES:Ps,crypto_secretbox_ZEROBYTES:Wn,crypto_secretbox_BOXZEROBYTES:dn,crypto_scalarmult_BYTES:Hn,crypto_scalarmult_SCALARBYTES:Rs,crypto_box_PUBLICKEYBYTES:Vn,crypto_box_SECRETKEYBYTES:Kn,crypto_box_BEFORENMBYTES:ho,crypto_box_NONCEBYTES:jc,crypto_box_ZEROBYTES:ud,crypto_box_BOXZEROBYTES:ld,crypto_sign_BYTES:nr,crypto_sign_PUBLICKEYBYTES:Ur,crypto_sign_SECRETKEYBYTES:pn,crypto_sign_SEEDBYTES:po,crypto_hash_BYTES:go,gf:e,D:u,L:ks,pack25519:pe,unpack25519:qt,M:A,A:N,S:oe,Z:j,pow2523:ft,add:Os,set25519:De,modL:co,scalarmult:oo,scalarbase:Cs};function Uc(c,h){if(c.length!==lo)throw new Error("bad key size");if(h.length!==Ps)throw new Error("bad nonce size")}function hd(c,h){if(c.length!==Vn)throw new Error("bad public key size");if(h.length!==Kn)throw new Error("bad secret key size")}function yt(){for(var c=0;c<arguments.length;c++)if(!(arguments[c]instanceof Uint8Array))throw new TypeError("unexpected type, use Uint8Array")}function qc(c){for(var h=0;h<c.length;h++)c[h]=0}r.randomBytes=function(c){var h=new Uint8Array(c);return t(h,c),h},r.secretbox=function(c,h,l){yt(c,h,l),Uc(l,h);for(var o=new Uint8Array(Wn+c.length),p=new Uint8Array(o.length),E=0;E<c.length;E++)o[E+Wn]=c[E];return xe(p,o,o.length,h,l),p.subarray(dn)},r.secretbox.open=function(c,h,l){yt(c,h,l),Uc(l,h);for(var o=new Uint8Array(dn+c.length),p=new Uint8Array(o.length),E=0;E<c.length;E++)o[E+dn]=c[E];return o.length<32||Ye(p,o,o.length,h,l)!==0?null:p.subarray(Wn)},r.secretbox.keyLength=lo,r.secretbox.nonceLength=Ps,r.secretbox.overheadLength=dn,r.scalarMult=function(c,h){if(yt(c,h),c.length!==Rs)throw new Error("bad n size");if(h.length!==Hn)throw new Error("bad p size");var l=new Uint8Array(Hn);return gt(l,c,h),l},r.scalarMult.base=function(c){if(yt(c),c.length!==Rs)throw new Error("bad n size");var h=new Uint8Array(Hn);return _t(h,c),h},r.scalarMult.scalarLength=Rs,r.scalarMult.groupElementLength=Hn,r.box=function(c,h,l,o){var p=r.box.before(l,o);return r.secretbox(c,h,p)},r.box.before=function(c,h){yt(c,h),hd(c,h);var l=new Uint8Array(ho);return rr(l,c,h),l},r.box.after=r.secretbox,r.box.open=function(c,h,l,o){var p=r.box.before(l,o);return r.secretbox.open(c,h,p)},r.box.open.after=r.secretbox.open,r.box.keyPair=function(){var c=new Uint8Array(Vn),h=new Uint8Array(Kn);return mt(c,h),{publicKey:c,secretKey:h}},r.box.keyPair.fromSecretKey=function(c){if(yt(c),c.length!==Kn)throw new Error("bad secret key size");var h=new Uint8Array(Vn);return _t(h,c),{publicKey:h,secretKey:new Uint8Array(c)}},r.box.publicKeyLength=Vn,r.box.secretKeyLength=Kn,r.box.sharedKeyLength=ho,r.box.nonceLength=jc,r.box.overheadLength=r.secretbox.overheadLength,r.sign=function(c,h){if(yt(c,h),h.length!==pn)throw new Error("bad secret key size");var l=new Uint8Array(nr+c.length);return Bc(l,c,c.length,h),l},r.sign.open=function(c,h){if(yt(c,h),h.length!==Ur)throw new Error("bad public key size");var l=new Uint8Array(c.length),o=uo(l,c,c.length,h);if(o<0)return null;for(var p=new Uint8Array(o),E=0;E<p.length;E++)p[E]=l[E];return p},r.sign.detached=function(c,h){for(var l=r.sign(c,h),o=new Uint8Array(nr),p=0;p<o.length;p++)o[p]=l[p];return o},r.sign.detached.verify=function(c,h,l){if(yt(c,h,l),h.length!==nr)throw new Error("bad signature size");if(l.length!==Ur)throw new Error("bad public key size");var o=new Uint8Array(nr+c.length),p=new Uint8Array(nr+c.length),E;for(E=0;E<nr;E++)o[E]=h[E];for(E=0;E<c.length;E++)o[E+nr]=c[E];return uo(p,o,o.length,l)>=0},r.sign.keyPair=function(){var c=new Uint8Array(Ur),h=new Uint8Array(pn);return ao(c,h),{publicKey:c,secretKey:h}},r.sign.keyPair.fromSecretKey=function(c){if(yt(c),c.length!==pn)throw new Error("bad secret key size");for(var h=new Uint8Array(Ur),l=0;l<h.length;l++)h[l]=c[32+l];return{publicKey:h,secretKey:new Uint8Array(c)}},r.sign.keyPair.fromSeed=function(c){if(yt(c),c.length!==po)throw new Error("bad seed size");for(var h=new Uint8Array(Ur),l=new Uint8Array(pn),o=0;o<32;o++)l[o]=c[o];return ao(h,l,!0),{publicKey:h,secretKey:l}},r.sign.publicKeyLength=Ur,r.sign.secretKeyLength=pn,r.sign.seedLength=po,r.sign.signatureLength=nr,r.hash=function(c){yt(c);var h=new Uint8Array(go);return jr(h,c,c.length),h},r.hash.hashLength=go,r.verify=function(c,h){return yt(c,h),c.length===0||h.length===0||c.length!==h.length?!1:S(c,0,h,0,c.length)===0},r.setPRNG=function(c){t=c},(function(){var c=typeof self<"u"?self.crypto||self.msCrypto:null;if(c&&c.getRandomValues){var h=65536;r.setPRNG(function(l,o){var p,E=new Uint8Array(o);for(p=0;p<o;p+=h)c.getRandomValues(E.subarray(p,p+Math.min(o-p,h)));for(p=0;p<o;p++)l[p]=E[p];qc(E)})}else typeof require<"u"&&(c=require("crypto"),c&&c.randomBytes&&r.setPRNG(function(l,o){var p,E=c.randomBytes(o);for(p=0;p<o;p++)l[p]=E[p];qc(E)}))})()})(typeof Ks<"u"&&Ks.exports?Ks.exports:self.nacl=self.nacl||{})});var qo=F((Ff,$s)=>{(function(r,e){"use strict";typeof $s<"u"&&$s.exports?$s.exports=e():(r.nacl||(r.nacl={}),r.nacl.util=e())})(Ff,function(){"use strict";var r={};function e(t){if(!/^(?:[A-Za-z0-9+\/]{2}[A-Za-z0-9+\/]{2})*(?:[A-Za-z0-9+\/]{2}==|[A-Za-z0-9+\/]{3}=)?$/.test(t))throw new TypeError("invalid encoding")}return r.decodeUTF8=function(t){if(typeof t!="string")throw new TypeError("expected string");var n,s=unescape(encodeURIComponent(t)),i=new Uint8Array(s.length);for(n=0;n<s.length;n++)i[n]=s.charCodeAt(n);return i},r.encodeUTF8=function(t){var n,s=[];for(n=0;n<t.length;n++)s.push(String.fromCharCode(t[n]));return decodeURIComponent(escape(s.join("")))},typeof atob>"u"?typeof Buffer.from<"u"?(r.encodeBase64=function(t){return Buffer.from(t).toString("base64")},r.decodeBase64=function(t){return e(t),new Uint8Array(Array.prototype.slice.call(Buffer.from(t,"base64"),0))}):(r.encodeBase64=function(t){return new Buffer(t).toString("base64")},r.decodeBase64=function(t){return e(t),new Uint8Array(Array.prototype.slice.call(new Buffer(t,"base64"),0))}):(r.encodeBase64=function(t){var n,s=[],i=t.length;for(n=0;n<i;n++)s.push(String.fromCharCode(t[n]));return btoa(s.join(""))},r.decodeBase64=function(t){e(t);var n,s=atob(t),i=new Uint8Array(s.length);for(n=0;n<s.length;n++)i[n]=s.charCodeAt(n);return i}),r})});var Mf=F(Tr=>{"use strict";var Hd=Tr&&Tr.__importDefault||function(r){return r&&r.__esModule?r:{default:r}};Object.defineProperty(Tr,"__esModule",{value:!0});Tr.encrypt=Vd;Tr.decrypt=Kd;Tr.encryptBinary=$d;Tr.decryptBinary=zd;var or=Hd(Uo()),Sr=qo();function Vd(r,e,t){let n=or.default.randomBytes(or.default.secretbox.nonceLength),s=new TextEncoder().encode(r),i=or.default.secretbox(s,n,e);return{v:1,sid:t,n:(0,Sr.encodeBase64)(n),c:(0,Sr.encodeBase64)(i)}}function Kd(r,e){if(r.v!==1)throw new Error(`Unsupported encryption version: ${r.v}`);let t=(0,Sr.decodeBase64)(r.n),n=(0,Sr.decodeBase64)(r.c);if(t.length!==or.default.secretbox.nonceLength)throw new Error(`Invalid nonce length: ${t.length}`);let s=or.default.secretbox.open(n,t,e);if(!s)throw new Error("Decryption failed: invalid ciphertext or wrong key");return new TextDecoder().decode(s)}function $d(r,e,t){let n=or.default.randomBytes(or.default.secretbox.nonceLength),s=or.default.secretbox(r,n,e);return{v:1,sid:t,n:(0,Sr.encodeBase64)(n),c:(0,Sr.encodeBase64)(s)}}function zd(r,e){if(r.v!==1)throw new Error(`Unsupported encryption version: ${r.v}`);let t=(0,Sr.decodeBase64)(r.n),n=(0,Sr.decodeBase64)(r.c),s=or.default.secretbox.open(n,t,e);if(!s)throw new Error("Decryption failed: invalid ciphertext or wrong key");return s}});var Bf=F(Ht=>{"use strict";var Gd=Ht&&Ht.__importDefault||function(r){return r&&r.__esModule?r:{default:r}};Object.defineProperty(Ht,"__esModule",{value:!0});Ht.generateKeyPair=Yd;Ht.deriveSharedSecret=Xd;Ht.isValidPublicKey=Jd;Ht.clearKey=Zd;Ht.keyToBase64=Qd;Ht.base64ToKey=ep;var ts=Gd(Uo()),qr=qo();function Yd(){let r=ts.default.box.keyPair();return{publicKey:(0,qr.encodeBase64)(r.publicKey),secretKey:(0,qr.encodeBase64)(r.secretKey)}}function Xd(r,e){let t=(0,qr.decodeBase64)(r),n=(0,qr.decodeBase64)(e);if(t.length!==ts.default.box.publicKeyLength)throw new Error(`Invalid public key length: ${t.length}`);if(n.length!==ts.default.box.secretKeyLength)throw new Error(`Invalid secret key length: ${n.length}`);return ts.default.box.before(t,n)}function Jd(r){try{return(0,qr.decodeBase64)(r).length===ts.default.box.publicKeyLength}catch{return!1}}function Zd(r){r.fill(0)}function Qd(r){return(0,qr.encodeBase64)(r)}function ep(r){return(0,qr.decodeBase64)(r)}});var Uf=F(Le=>{"use strict";Object.defineProperty(Le,"__esModule",{value:!0});Le.base64ToKey=Le.keyToBase64=Le.clearKey=Le.isValidPublicKey=Le.deriveSharedSecret=Le.generateKeyPair=Le.decryptBinary=Le.encryptBinary=Le.decrypt=Le.encrypt=Le.isMultiRecipientPayload=Le.isEncryptedPayload=void 0;var jf=Df();Object.defineProperty(Le,"isEncryptedPayload",{enumerable:!0,get:function(){return jf.isEncryptedPayload}});Object.defineProperty(Le,"isMultiRecipientPayload",{enumerable:!0,get:function(){return jf.isMultiRecipientPayload}});var zs=Mf();Object.defineProperty(Le,"encrypt",{enumerable:!0,get:function(){return zs.encrypt}});Object.defineProperty(Le,"decrypt",{enumerable:!0,get:function(){return zs.decrypt}});Object.defineProperty(Le,"encryptBinary",{enumerable:!0,get:function(){return zs.encryptBinary}});Object.defineProperty(Le,"decryptBinary",{enumerable:!0,get:function(){return zs.decryptBinary}});var mn=Bf();Object.defineProperty(Le,"generateKeyPair",{enumerable:!0,get:function(){return mn.generateKeyPair}});Object.defineProperty(Le,"deriveSharedSecret",{enumerable:!0,get:function(){return mn.deriveSharedSecret}});Object.defineProperty(Le,"isValidPublicKey",{enumerable:!0,get:function(){return mn.isValidPublicKey}});Object.defineProperty(Le,"clearKey",{enumerable:!0,get:function(){return mn.clearKey}});Object.defineProperty(Le,"keyToBase64",{enumerable:!0,get:function(){return mn.keyToBase64}});Object.defineProperty(Le,"base64ToKey",{enumerable:!0,get:function(){return mn.base64ToKey}})});var qf=F(Et=>{"use strict";Object.defineProperty(Et,"__esModule",{value:!0});Et.MIN_CLIENT_VERSION=Et.PROTOCOL_VERSION_MINOR=Et.PROTOCOL_VERSION_MAJOR=Et.PROTOCOL_VERSION=void 0;Et.isCompatibleVersion=tp;Et.compareVersions=rp;Et.PROTOCOL_VERSION="2.0";Et.PROTOCOL_VERSION_MAJOR=2;Et.PROTOCOL_VERSION_MINOR=0;Et.MIN_CLIENT_VERSION="2.0";function tp(r){let[e]=r.split(".").map(Number);return e===Et.PROTOCOL_VERSION_MAJOR}function rp(r,e){let[t,n]=r.split(".").map(Number),[s,i]=e.split(".").map(Number);return t!==s?t<s?-1:1:n!==i?n<i?-1:1:0}});var Wf=F(Vt=>{"use strict";Object.defineProperty(Vt,"__esModule",{value:!0});Vt.SERVER_CAPABILITIES=Vt.DEFAULT_CLIENT_CAPABILITIES=Vt.Capability=void 0;Vt.hasCapability=np;Vt.negotiateCapabilities=sp;var rs;(function(r){r.FILE_TRANSFER="file-transfer",r.RELIABLE_MESSAGING="reliable-messaging",r.COMPRESSION="compression",r.E2E_ENCRYPTION="e2e-encryption",r.PRIORITY_QUEUES="priority-queues",r.OFFLINE_QUEUE="offline-queue",r.MULTI_DEVICE="multi-device",r.TERMINAL_EVENTS="terminal-events",r.E2E_PRIVACY="e2e-privacy"})(rs||(Vt.Capability=rs={}));Vt.DEFAULT_CLIENT_CAPABILITIES=[rs.E2E_ENCRYPTION,rs.TERMINAL_EVENTS];Vt.SERVER_CAPABILITIES=Object.values(rs);function np(r,e){return r.includes(e)}function sp(r,e){return r.filter(t=>e.includes(t))}});var Hf=F(ar=>{"use strict";Object.defineProperty(ar,"__esModule",{value:!0});ar.DEFAULT_PRIORITY=ar.PRIORITY_NAMES=ar.Priority=void 0;ar.comparePriority=ip;var Wr;(function(r){r[r.CRITICAL=0]="CRITICAL",r[r.HIGH=1]="HIGH",r[r.NORMAL=2]="NORMAL",r[r.LOW=3]="LOW"})(Wr||(ar.Priority=Wr={}));ar.PRIORITY_NAMES={[Wr.CRITICAL]:"CRITICAL",[Wr.HIGH]:"HIGH",[Wr.NORMAL]:"NORMAL",[Wr.LOW]:"LOW"};ar.DEFAULT_PRIORITY=Wr.NORMAL;function ip(r,e){return r-e}});var Vf=F(Kt=>{"use strict";Object.defineProperty(Kt,"__esModule",{value:!0});Kt.DEFAULT_RELIABILITY=Kt.RELIABILITY_NAMES=Kt.Reliability=void 0;Kt.requiresAck=op;Kt.requiresBuffer=ap;var Or;(function(r){r[r.FIRE_FORGET=0]="FIRE_FORGET",r[r.BUFFERED=1]="BUFFERED",r[r.GUARANTEED=2]="GUARANTEED"})(Or||(Kt.Reliability=Or={}));Kt.RELIABILITY_NAMES={[Or.FIRE_FORGET]:"FIRE_FORGET",[Or.BUFFERED]:"BUFFERED",[Or.GUARANTEED]:"GUARANTEED"};Kt.DEFAULT_RELIABILITY=Or.FIRE_FORGET;function op(r){return r===Or.GUARANTEED}function ap(r){return r>=Or.BUFFERED}});var Kf=F(Wo=>{"use strict";Object.defineProperty(Wo,"__esModule",{value:!0});Wo.createMessage=cp;function cp(r,e,t={}){return{id:crypto.randomUUID(),type:r,payload:e,priority:t.priority??2,reliability:t.reliability??0,seq:t.seq,timestamp:new Date().toISOString()}}});var $f=F(Hr=>{"use strict";Object.defineProperty(Hr,"__esModule",{value:!0});Hr.TerminalEventType=void 0;Hr.deriveStatusFromEvent=fp;Hr.shouldTriggerPushNotification=up;Hr.getPushNotificationMessage=lp;var ut;(function(r){r.SESSION_START="session_start",r.SESSION_END="session_end",r.MESSAGE="message",r.TOOL_START="tool_start",r.TOOL_END="tool_end",r.WAITING_INPUT="waiting_input",r.ERROR="error"})(ut||(Hr.TerminalEventType=ut={}));function fp(r){switch(r.type){case ut.SESSION_START:case ut.TOOL_START:case ut.MESSAGE:return"working";case ut.WAITING_INPUT:return"waiting";case ut.SESSION_END:return r.status==="success"?"completed":"error";case ut.ERROR:return r.severity==="fatal"?"error":"working";case ut.TOOL_END:return r.status==="error"?"error":"working";default:return"idle"}}function up(r){switch(r.type){case ut.WAITING_INPUT:return!0;case ut.SESSION_END:return!0;case ut.ERROR:return r.severity!=="warning";default:return!1}}function lp(r,e){switch(r.type){case ut.WAITING_INPUT:return{title:`${e}: Input Required`,body:r.question.slice(0,100)};case ut.SESSION_END:{let t=r;return t.status==="success"?{title:`${e}: Task Completed`,body:t.summary||"Session finished successfully"}:{title:`${e}: Task Failed`,body:t.summary||"Session ended with error"}}case ut.ERROR:{let t=r;return t.severity==="warning"?null:{title:`${e}: Error`,body:t.message.slice(0,100)}}default:return null}}});var Yf=F(Be=>{"use strict";Object.defineProperty(Be,"__esModule",{value:!0});Be.TransferDirection=Be.TransferStatus=Be.CHUNK_TTL_SECONDS=Be.TRANSFER_TTL_SECONDS=Be.MAX_RETRIES=Be.ACK_TIMEOUT_MS=Be.WINDOW_SIZE=Be.DEFAULT_MAX_FILE_SIZE=Be.CHUNK_SIZE=void 0;Be.calculateTotalChunks=hp;Be.getMissingChunks=dp;Be.isTransferComplete=pp;Be.CHUNK_SIZE=64*1024;Be.DEFAULT_MAX_FILE_SIZE=100*1024*1024;Be.WINDOW_SIZE=10;Be.ACK_TIMEOUT_MS=3e4;Be.MAX_RETRIES=3;Be.TRANSFER_TTL_SECONDS=1440*60;Be.CHUNK_TTL_SECONDS=1440*60;var zf;(function(r){r.PENDING="pending",r.ACTIVE="active",r.PAUSED="paused",r.COMPLETED="completed",r.FAILED="failed",r.CANCELLED="cancelled",r.EXPIRED="expired"})(zf||(Be.TransferStatus=zf={}));var Gf;(function(r){r.DOWNLOAD="download",r.UPLOAD="upload"})(Gf||(Be.TransferDirection=Gf={}));function hp(r,e=Be.CHUNK_SIZE){return Math.ceil(r/e)}function dp(r,e){let t=new Set(e),n=[];for(let s=0;s<r;s++)t.has(s)||n.push(s);return n}function pp(r,e){return e.length===r}});var Xf=F(cr=>{"use strict";Object.defineProperty(cr,"__esModule",{value:!0});cr.ERROR_MESSAGES=cr.ErrorCode=void 0;cr.createError=gp;cr.isRetryableError=_p;var ke;(function(r){r.AUTH_FAILED="E001",r.TOKEN_EXPIRED="E002",r.TOKEN_INVALID="E003",r.NOT_FOUND="E011",r.ALREADY_EXISTS="E012",r.ACCESS_DENIED="E021",r.FORBIDDEN="E022",r.RATE_LIMITED="E031",r.TOO_MANY_CONNECTIONS="E032",r.QUOTA_EXCEEDED="E041",r.FILE_TOO_LARGE="E042",r.QUEUE_FULL="E043",r.TRANSFERS_LIMIT="E044",r.TRANSFER_FAILED="E051",r.TRANSFER_EXPIRED="E052",r.TRANSFER_CANCELLED="E053",r.CHECKSUM_MISMATCH="E054",r.CHUNK_MISSING="E055",r.INVALID_MESSAGE="E061",r.UNSUPPORTED_VERSION="E062",r.CAPABILITY_REQUIRED="E063",r.INVALID_STATE="E071",r.TIMEOUT="E072",r.CONNECTION_LOST="E073",r.INTERNAL_ERROR="E091",r.SERVICE_UNAVAILABLE="E092"})(ke||(cr.ErrorCode=ke={}));cr.ERROR_MESSAGES={[ke.AUTH_FAILED]:"Authentication failed",[ke.TOKEN_EXPIRED]:"Token expired",[ke.TOKEN_INVALID]:"Invalid token",[ke.NOT_FOUND]:"Resource not found",[ke.ALREADY_EXISTS]:"Resource already exists",[ke.ACCESS_DENIED]:"Access denied",[ke.FORBIDDEN]:"Operation forbidden",[ke.RATE_LIMITED]:"Rate limit exceeded",[ke.TOO_MANY_CONNECTIONS]:"Too many connections",[ke.QUOTA_EXCEEDED]:"Plan quota exceeded",[ke.FILE_TOO_LARGE]:"File size exceeds limit",[ke.QUEUE_FULL]:"Message queue is full",[ke.TRANSFERS_LIMIT]:"Daily transfers limit reached",[ke.TRANSFER_FAILED]:"File transfer failed",[ke.TRANSFER_EXPIRED]:"Transfer expired",[ke.TRANSFER_CANCELLED]:"Transfer cancelled",[ke.CHECKSUM_MISMATCH]:"File checksum mismatch",[ke.CHUNK_MISSING]:"Chunk missing or corrupted",[ke.INVALID_MESSAGE]:"Invalid message format",[ke.UNSUPPORTED_VERSION]:"Unsupported protocol version",[ke.CAPABILITY_REQUIRED]:"Required capability not supported",[ke.INVALID_STATE]:"Invalid state for this operation",[ke.TIMEOUT]:"Operation timed out",[ke.CONNECTION_LOST]:"Connection lost",[ke.INTERNAL_ERROR]:"Internal server error",[ke.SERVICE_UNAVAILABLE]:"Service temporarily unavailable"};function gp(r,e={}){return{code:r,message:e.message||cr.ERROR_MESSAGES[r],details:e.details,retryable:e.retryable??!1,retryAfter:e.retryAfter}}function _p(r){return[ke.RATE_LIMITED,ke.TIMEOUT,ke.CONNECTION_LOST,ke.SERVICE_UNAVAILABLE].includes(r)}});var eu=F(wt=>{"use strict";Object.defineProperty(wt,"__esModule",{value:!0});wt.FileEntryType=wt.DiffBase=wt.FileViewType=wt.FileChangeType=void 0;wt.getLanguageFromPath=mp;wt.parseUnifiedDiff=yp;wt.createSimpleDiff=Ep;var Cr;(function(r){r.CREATE="create",r.MODIFY="modify",r.DELETE="delete"})(Cr||(wt.FileChangeType=Cr={}));var Jf;(function(r){r.CONTENT="content",r.DIFF="diff"})(Jf||(wt.FileViewType=Jf={}));var Zf;(function(r){r.GIT="git",r.PREVIOUS="previous"})(Zf||(wt.DiffBase=Zf={}));function mp(r){let e=r.split(".").pop()?.toLowerCase(),t={js:"javascript",jsx:"javascript",ts:"typescript",tsx:"typescript",mjs:"javascript",cjs:"javascript",html:"html",htm:"html",css:"css",scss:"scss",sass:"scss",less:"less",json:"json",yaml:"yaml",yml:"yaml",xml:"xml",toml:"toml",md:"markdown",mdx:"markdown",env:"plaintext",gitignore:"plaintext",dockerignore:"plaintext",sh:"bash",bash:"bash",zsh:"bash",fish:"bash",py:"python",pyw:"python",pyi:"python",go:"go",rs:"rust",java:"java",kt:"kotlin",kts:"kotlin",c:"c",h:"c",cpp:"cpp",cc:"cpp",cxx:"cpp",hpp:"cpp",sql:"sql",graphql:"graphql",gql:"graphql",prisma:"prisma",dockerfile:"dockerfile"},n=r.split("/").pop()?.toLowerCase()||"";return{dockerfile:"dockerfile",makefile:"makefile",".gitignore":"plaintext",".env":"plaintext",".env.local":"plaintext",".env.development":"plaintext",".env.production":"plaintext"}[n]||t[e||""]||"plaintext"}function yp(r,e){let t=r.split(`
|
|
5
|
-
`),n=[],s=0,i=0,a=null,f=0,u=0;for(let g of t){if(g.startsWith("diff ")||g.startsWith("index ")||g.startsWith("---")||g.startsWith("+++"))continue;let _=g.match(/^@@ -(\d+),?(\d*) \+(\d+),?(\d*) @@/);if(_){a&&n.push(a);let y=parseInt(_[1],10),x=parseInt(_[2]||"1",10),S=parseInt(_[3],10),C=parseInt(_[4]||"1",10);a={oldStart:y,oldLines:x,newStart:S,newLines:C,lines:[]},f=y,u=S;continue}a&&(g.startsWith("+")?(a.lines.push({type:"add",content:g.slice(1),oldLineNumber:null,newLineNumber:u++}),s++):g.startsWith("-")?(a.lines.push({type:"remove",content:g.slice(1),oldLineNumber:f++,newLineNumber:null}),i++):(g.startsWith(" ")||g==="")&&a.lines.push({type:"context",content:g.startsWith(" ")?g.slice(1):g,oldLineNumber:f++,newLineNumber:u++}))}a&&n.push(a);let d;return i===0&&s>0&&n.length===1&&n[0].oldLines===0?d=Cr.CREATE:s===0&&i>0&&n.length===1&&n[0].newLines===0?d=Cr.DELETE:d=Cr.MODIFY,{path:e,changeType:d,hunks:n,additions:s,deletions:i,isBinary:!1}}function Ep(r,e,t){let n=r.split(`
|
|
2
|
+
"use strict";var kd=Object.create;var vo=Object.defineProperty;var Pd=Object.getOwnPropertyDescriptor;var Rd=Object.getOwnPropertyNames;var Ad=Object.getPrototypeOf,Id=Object.prototype.hasOwnProperty;var Nt=(r,e)=>()=>(r&&(e=r(r=0)),e);var D=(r,e)=>()=>(e||r((e={exports:{}}).exports,e),e.exports),Ld=(r,e)=>{for(var t in e)vo(r,t,{get:e[t],enumerable:!0})},Nd=(r,e,t,n)=>{if(e&&typeof e=="object"||typeof e=="function")for(let s of Rd(e))!Id.call(r,s)&&s!==t&&vo(r,s,{get:()=>e[s],enumerable:!(n=Pd(e,s))||n.enumerable});return r};var me=(r,e,t)=>(t=r!=null?kd(Ad(r)):{},Nd(e||!r||!r.__esModule?vo(t,"default",{value:r,enumerable:!0}):t,r));var tf=D(yn=>{"use strict";Object.defineProperty(yn,"__esModule",{value:!0});yn.LOG_LEVELS=void 0;yn.shouldLog=Fd;yn.formatLogLine=Md;yn.LOG_LEVELS=["silent","error","warn","info","debug"];var ef={silent:0,error:1,warn:2,info:3,debug:4};function Fd(r,e){return ef[r]<=ef[e]}function Md(r,e,t,n){let s={ts:new Date().toISOString(),level:r,src:e,msg:t},i=n;i.length>0&&typeof i[0]=="object"&&i[0]!==null&&!(i[0]instanceof Error)&&!Array.isArray(i[0])&&(s.ctx=i[0],i=i.slice(1));let a=[...i].reverse().find(f=>f instanceof Error);a&&(s.err={message:a.message,stack:a.stack,name:a.name},i=i.filter(f=>f!==a)),i.length>0&&(s.args=i);try{return JSON.stringify(s)}catch{return JSON.stringify({ts:s.ts,level:r,src:e,msg:t,_unserializable:!0})}}});var rf=D(vr=>{"use strict";Object.defineProperty(vr,"__esModule",{value:!0});vr.formatLogLine=vr.shouldLog=vr.LOG_LEVELS=void 0;var xo=tf();Object.defineProperty(vr,"LOG_LEVELS",{enumerable:!0,get:function(){return xo.LOG_LEVELS}});Object.defineProperty(vr,"shouldLog",{enumerable:!0,get:function(){return xo.shouldLog}});Object.defineProperty(vr,"formatLogLine",{enumerable:!0,get:function(){return xo.formatLogLine}})});var nf=D(Us=>{"use strict";Object.defineProperty(Us,"__esModule",{value:!0});Us.CircularBuffer=void 0;var bo=class{buffer=[];totalSize=0;maxSize;constructor(e=100){this.maxSize=e*1024}append(e){for(this.buffer.push(e),this.totalSize+=e.length;this.totalSize>this.maxSize&&this.buffer.length>1;){let t=this.buffer.shift();t&&(this.totalSize-=t.length)}}getContent(){return this.buffer.join("")}getLastBytes(e){let t=this.getContent();return t.length<=e?t:t.slice(-e)}getSize(){return this.totalSize}clear(){this.buffer=[],this.totalSize=0}};Us.CircularBuffer=bo});var Ws=D(qs=>{"use strict";Object.defineProperty(qs,"__esModule",{value:!0});qs.getApiUrl=Bd;qs.getWsUrl=jd;function Bd(r){return`${r.getServerUrl()}/api`}function jd(r){let e=r.getServerUrl();return e.startsWith("https://")?e.replace(/^https:\/\//,"wss://"):e.replace(/^http:\/\//,"ws://")}});var of=D(xr=>{"use strict";Object.defineProperty(xr,"__esModule",{value:!0});xr.getWsUrl=xr.getApiUrl=xr.CircularBuffer=void 0;var Ud=nf();Object.defineProperty(xr,"CircularBuffer",{enumerable:!0,get:function(){return Ud.CircularBuffer}});var sf=Ws();Object.defineProperty(xr,"getApiUrl",{enumerable:!0,get:function(){return sf.getApiUrl}});Object.defineProperty(xr,"getWsUrl",{enumerable:!0,get:function(){return sf.getWsUrl}})});var cf=D(af=>{"use strict";Object.defineProperty(af,"__esModule",{value:!0})});var uf=D(ff=>{"use strict";Object.defineProperty(ff,"__esModule",{value:!0})});var lf=D(Hs=>{"use strict";Object.defineProperty(Hs,"__esModule",{value:!0});Hs.PLAN_LIMITS=void 0;Hs.PLAN_LIMITS={free:{maxAgents:1,maxTerminals:2,maxTeamMembers:1,historyDays:1},basic:{maxAgents:3,maxTerminals:10,maxTeamMembers:1,historyDays:7},pro:{maxAgents:10,maxTerminals:50,maxTeamMembers:5,historyDays:30}}});var df=D(hf=>{"use strict";Object.defineProperty(hf,"__esModule",{value:!0})});var pf=D(Ht=>{"use strict";var qd=Ht&&Ht.__createBinding||(Object.create?(function(r,e,t,n){n===void 0&&(n=t);var s=Object.getOwnPropertyDescriptor(e,t);(!s||("get"in s?!e.__esModule:s.writable||s.configurable))&&(s={enumerable:!0,get:function(){return e[t]}}),Object.defineProperty(r,n,s)}):(function(r,e,t,n){n===void 0&&(n=t),r[n]=e[t]})),Vs=Ht&&Ht.__exportStar||function(r,e){for(var t in r)t!=="default"&&!Object.prototype.hasOwnProperty.call(e,t)&&qd(e,r,t)};Object.defineProperty(Ht,"__esModule",{value:!0});Vs(cf(),Ht);Vs(uf(),Ht);Vs(lf(),Ht);Vs(df(),Ht)});var gf=D(Tt=>{"use strict";Object.defineProperty(Tt,"__esModule",{value:!0});Tt.API_VERSION=Tt.WS_NAMESPACES=Tt.TIMEOUTS=Tt.STATUS_PATTERNS=Tt.TERMINAL_STATUSES=void 0;Tt.TERMINAL_STATUSES={idle:{label:"Idle",color:"gray",icon:"\u25CF"},working:{label:"Working",color:"blue",icon:"\u27F3"},waiting:{label:"Awaiting input",color:"orange",icon:"\u26A0"},completed:{label:"Completed",color:"green",icon:"\u2713"},error:{label:"Error",color:"red",icon:"\u2715"},offline:{label:"Offline",color:"black",icon:"\u26AB"}};Tt.STATUS_PATTERNS={idle:[/[❯$]\s*$/,/>\s*$/],waiting:[/\[Y\/n\]/i,/\(y\/N\)/i,/Continue\?/i,/proceed\?/i],completed:[/✓/,/Done/,/Completed/,/Success/],error:[/Error/,/Failed/,/✕/,/Exception/]};Tt.TIMEOUTS={HEARTBEAT_INTERVAL:3e4,OFFLINE_THRESHOLD:6e4,DEVICE_CODE_EXPIRY:9e5,DEVICE_CODE_POLL_INTERVAL:5e3};Tt.WS_NAMESPACES={AGENT:"/agent",CLIENT:"/client"};Tt.API_VERSION="v1"});var _f=D(Ks=>{"use strict";Object.defineProperty(Ks,"__esModule",{value:!0});Ks.isMultiRecipientPayload=Wd;Ks.isEncryptedPayload=Hd;function Wd(r){return typeof r=="object"&&r!==null&&"v"in r&&r.v===2&&"recipients"in r&&Array.isArray(r.recipients)}function Hd(r){if(typeof r!="object"||r===null||!("encrypted"in r))return!1;let e=r.encrypted;if(typeof e!="object"||e===null)return!1;let t=e;return typeof t.v=="number"&&typeof t.sid=="string"&&typeof t.n=="string"&&typeof t.c=="string"}});var So=D((RE,$s)=>{(function(r){"use strict";var e=function(c){var h,l=new Float64Array(16);if(c)for(h=0;h<c.length;h++)l[h]=c[h];return l},t=function(){throw new Error("no PRNG")},n=new Uint8Array(16),s=new Uint8Array(32);s[0]=9;var i=e(),a=e([1]),f=e([56129,1]),u=e([30883,4953,19914,30187,55467,16705,2637,112,59544,30585,16505,36039,65139,11119,27886,20995]),d=e([61785,9906,39828,60374,45398,33411,5274,224,53552,61171,33010,6542,64743,22239,55772,9222]),g=e([54554,36645,11616,51542,42930,38181,51040,26924,56412,64982,57905,49316,21502,52590,14035,8553]),_=e([26200,26214,26214,26214,26214,26214,26214,26214,26214,26214,26214,26214,26214,26214,26214,26214]),y=e([41136,18958,6951,50414,58488,44335,6150,12099,55207,15867,153,11085,57099,20417,9344,11139]);function v(c,h,l,o){c[h]=l>>24&255,c[h+1]=l>>16&255,c[h+2]=l>>8&255,c[h+3]=l&255,c[h+4]=o>>24&255,c[h+5]=o>>16&255,c[h+6]=o>>8&255,c[h+7]=o&255}function S(c,h,l,o,p){var E,w=0;for(E=0;E<p;E++)w|=c[h+E]^l[o+E];return(1&w-1>>>8)-1}function C(c,h,l,o){return S(c,h,l,o,16)}function H(c,h,l,o){return S(c,h,l,o,32)}function z(c,h,l,o){for(var p=o[0]&255|(o[1]&255)<<8|(o[2]&255)<<16|(o[3]&255)<<24,E=l[0]&255|(l[1]&255)<<8|(l[2]&255)<<16|(l[3]&255)<<24,w=l[4]&255|(l[5]&255)<<8|(l[6]&255)<<16|(l[7]&255)<<24,k=l[8]&255|(l[9]&255)<<8|(l[10]&255)<<16|(l[11]&255)<<24,F=l[12]&255|(l[13]&255)<<8|(l[14]&255)<<16|(l[15]&255)<<24,Y=o[4]&255|(o[5]&255)<<8|(o[6]&255)<<16|(o[7]&255)<<24,q=h[0]&255|(h[1]&255)<<8|(h[2]&255)<<16|(h[3]&255)<<24,Te=h[4]&255|(h[5]&255)<<8|(h[6]&255)<<16|(h[7]&255)<<24,V=h[8]&255|(h[9]&255)<<8|(h[10]&255)<<16|(h[11]&255)<<24,te=h[12]&255|(h[13]&255)<<8|(h[14]&255)<<16|(h[15]&255)<<24,re=o[8]&255|(o[9]&255)<<8|(o[10]&255)<<16|(o[11]&255)<<24,fe=l[16]&255|(l[17]&255)<<8|(l[18]&255)<<16|(l[19]&255)<<24,ce=l[20]&255|(l[21]&255)<<8|(l[22]&255)<<16|(l[23]&255)<<24,ne=l[24]&255|(l[25]&255)<<8|(l[26]&255)<<16|(l[27]&255)<<24,ae=l[28]&255|(l[29]&255)<<8|(l[30]&255)<<16|(l[31]&255)<<24,se=o[12]&255|(o[13]&255)<<8|(o[14]&255)<<16|(o[15]&255)<<24,K=p,Z=E,W=w,$=k,G=F,U=Y,x=q,b=Te,R=V,O=te,P=re,N=fe,ee=ce,ue=ne,ge=ae,le=se,m,ye=0;ye<20;ye+=2)m=K+ee|0,G^=m<<7|m>>>25,m=G+K|0,R^=m<<9|m>>>23,m=R+G|0,ee^=m<<13|m>>>19,m=ee+R|0,K^=m<<18|m>>>14,m=U+Z|0,O^=m<<7|m>>>25,m=O+U|0,ue^=m<<9|m>>>23,m=ue+O|0,Z^=m<<13|m>>>19,m=Z+ue|0,U^=m<<18|m>>>14,m=P+x|0,ge^=m<<7|m>>>25,m=ge+P|0,W^=m<<9|m>>>23,m=W+ge|0,x^=m<<13|m>>>19,m=x+W|0,P^=m<<18|m>>>14,m=le+N|0,$^=m<<7|m>>>25,m=$+le|0,b^=m<<9|m>>>23,m=b+$|0,N^=m<<13|m>>>19,m=N+b|0,le^=m<<18|m>>>14,m=K+$|0,Z^=m<<7|m>>>25,m=Z+K|0,W^=m<<9|m>>>23,m=W+Z|0,$^=m<<13|m>>>19,m=$+W|0,K^=m<<18|m>>>14,m=U+G|0,x^=m<<7|m>>>25,m=x+U|0,b^=m<<9|m>>>23,m=b+x|0,G^=m<<13|m>>>19,m=G+b|0,U^=m<<18|m>>>14,m=P+O|0,N^=m<<7|m>>>25,m=N+P|0,R^=m<<9|m>>>23,m=R+N|0,O^=m<<13|m>>>19,m=O+R|0,P^=m<<18|m>>>14,m=le+ge|0,ee^=m<<7|m>>>25,m=ee+le|0,ue^=m<<9|m>>>23,m=ue+ee|0,ge^=m<<13|m>>>19,m=ge+ue|0,le^=m<<18|m>>>14;K=K+p|0,Z=Z+E|0,W=W+w|0,$=$+k|0,G=G+F|0,U=U+Y|0,x=x+q|0,b=b+Te|0,R=R+V|0,O=O+te|0,P=P+re|0,N=N+fe|0,ee=ee+ce|0,ue=ue+ne|0,ge=ge+ae|0,le=le+se|0,c[0]=K>>>0&255,c[1]=K>>>8&255,c[2]=K>>>16&255,c[3]=K>>>24&255,c[4]=Z>>>0&255,c[5]=Z>>>8&255,c[6]=Z>>>16&255,c[7]=Z>>>24&255,c[8]=W>>>0&255,c[9]=W>>>8&255,c[10]=W>>>16&255,c[11]=W>>>24&255,c[12]=$>>>0&255,c[13]=$>>>8&255,c[14]=$>>>16&255,c[15]=$>>>24&255,c[16]=G>>>0&255,c[17]=G>>>8&255,c[18]=G>>>16&255,c[19]=G>>>24&255,c[20]=U>>>0&255,c[21]=U>>>8&255,c[22]=U>>>16&255,c[23]=U>>>24&255,c[24]=x>>>0&255,c[25]=x>>>8&255,c[26]=x>>>16&255,c[27]=x>>>24&255,c[28]=b>>>0&255,c[29]=b>>>8&255,c[30]=b>>>16&255,c[31]=b>>>24&255,c[32]=R>>>0&255,c[33]=R>>>8&255,c[34]=R>>>16&255,c[35]=R>>>24&255,c[36]=O>>>0&255,c[37]=O>>>8&255,c[38]=O>>>16&255,c[39]=O>>>24&255,c[40]=P>>>0&255,c[41]=P>>>8&255,c[42]=P>>>16&255,c[43]=P>>>24&255,c[44]=N>>>0&255,c[45]=N>>>8&255,c[46]=N>>>16&255,c[47]=N>>>24&255,c[48]=ee>>>0&255,c[49]=ee>>>8&255,c[50]=ee>>>16&255,c[51]=ee>>>24&255,c[52]=ue>>>0&255,c[53]=ue>>>8&255,c[54]=ue>>>16&255,c[55]=ue>>>24&255,c[56]=ge>>>0&255,c[57]=ge>>>8&255,c[58]=ge>>>16&255,c[59]=ge>>>24&255,c[60]=le>>>0&255,c[61]=le>>>8&255,c[62]=le>>>16&255,c[63]=le>>>24&255}function X(c,h,l,o){for(var p=o[0]&255|(o[1]&255)<<8|(o[2]&255)<<16|(o[3]&255)<<24,E=l[0]&255|(l[1]&255)<<8|(l[2]&255)<<16|(l[3]&255)<<24,w=l[4]&255|(l[5]&255)<<8|(l[6]&255)<<16|(l[7]&255)<<24,k=l[8]&255|(l[9]&255)<<8|(l[10]&255)<<16|(l[11]&255)<<24,F=l[12]&255|(l[13]&255)<<8|(l[14]&255)<<16|(l[15]&255)<<24,Y=o[4]&255|(o[5]&255)<<8|(o[6]&255)<<16|(o[7]&255)<<24,q=h[0]&255|(h[1]&255)<<8|(h[2]&255)<<16|(h[3]&255)<<24,Te=h[4]&255|(h[5]&255)<<8|(h[6]&255)<<16|(h[7]&255)<<24,V=h[8]&255|(h[9]&255)<<8|(h[10]&255)<<16|(h[11]&255)<<24,te=h[12]&255|(h[13]&255)<<8|(h[14]&255)<<16|(h[15]&255)<<24,re=o[8]&255|(o[9]&255)<<8|(o[10]&255)<<16|(o[11]&255)<<24,fe=l[16]&255|(l[17]&255)<<8|(l[18]&255)<<16|(l[19]&255)<<24,ce=l[20]&255|(l[21]&255)<<8|(l[22]&255)<<16|(l[23]&255)<<24,ne=l[24]&255|(l[25]&255)<<8|(l[26]&255)<<16|(l[27]&255)<<24,ae=l[28]&255|(l[29]&255)<<8|(l[30]&255)<<16|(l[31]&255)<<24,se=o[12]&255|(o[13]&255)<<8|(o[14]&255)<<16|(o[15]&255)<<24,K=p,Z=E,W=w,$=k,G=F,U=Y,x=q,b=Te,R=V,O=te,P=re,N=fe,ee=ce,ue=ne,ge=ae,le=se,m,ye=0;ye<20;ye+=2)m=K+ee|0,G^=m<<7|m>>>25,m=G+K|0,R^=m<<9|m>>>23,m=R+G|0,ee^=m<<13|m>>>19,m=ee+R|0,K^=m<<18|m>>>14,m=U+Z|0,O^=m<<7|m>>>25,m=O+U|0,ue^=m<<9|m>>>23,m=ue+O|0,Z^=m<<13|m>>>19,m=Z+ue|0,U^=m<<18|m>>>14,m=P+x|0,ge^=m<<7|m>>>25,m=ge+P|0,W^=m<<9|m>>>23,m=W+ge|0,x^=m<<13|m>>>19,m=x+W|0,P^=m<<18|m>>>14,m=le+N|0,$^=m<<7|m>>>25,m=$+le|0,b^=m<<9|m>>>23,m=b+$|0,N^=m<<13|m>>>19,m=N+b|0,le^=m<<18|m>>>14,m=K+$|0,Z^=m<<7|m>>>25,m=Z+K|0,W^=m<<9|m>>>23,m=W+Z|0,$^=m<<13|m>>>19,m=$+W|0,K^=m<<18|m>>>14,m=U+G|0,x^=m<<7|m>>>25,m=x+U|0,b^=m<<9|m>>>23,m=b+x|0,G^=m<<13|m>>>19,m=G+b|0,U^=m<<18|m>>>14,m=P+O|0,N^=m<<7|m>>>25,m=N+P|0,R^=m<<9|m>>>23,m=R+N|0,O^=m<<13|m>>>19,m=O+R|0,P^=m<<18|m>>>14,m=le+ge|0,ee^=m<<7|m>>>25,m=ee+le|0,ue^=m<<9|m>>>23,m=ue+ee|0,ge^=m<<13|m>>>19,m=ge+ue|0,le^=m<<18|m>>>14;c[0]=K>>>0&255,c[1]=K>>>8&255,c[2]=K>>>16&255,c[3]=K>>>24&255,c[4]=U>>>0&255,c[5]=U>>>8&255,c[6]=U>>>16&255,c[7]=U>>>24&255,c[8]=P>>>0&255,c[9]=P>>>8&255,c[10]=P>>>16&255,c[11]=P>>>24&255,c[12]=le>>>0&255,c[13]=le>>>8&255,c[14]=le>>>16&255,c[15]=le>>>24&255,c[16]=x>>>0&255,c[17]=x>>>8&255,c[18]=x>>>16&255,c[19]=x>>>24&255,c[20]=b>>>0&255,c[21]=b>>>8&255,c[22]=b>>>16&255,c[23]=b>>>24&255,c[24]=R>>>0&255,c[25]=R>>>8&255,c[26]=R>>>16&255,c[27]=R>>>24&255,c[28]=O>>>0&255,c[29]=O>>>8&255,c[30]=O>>>16&255,c[31]=O>>>24&255}function T(c,h,l,o){z(c,h,l,o)}function M(c,h,l,o){X(c,h,l,o)}var Q=new Uint8Array([101,120,112,97,110,100,32,51,50,45,98,121,116,101,32,107]);function B(c,h,l,o,p,E,w){var k=new Uint8Array(16),F=new Uint8Array(64),Y,q;for(q=0;q<16;q++)k[q]=0;for(q=0;q<8;q++)k[q]=E[q];for(;p>=64;){for(T(F,k,w,Q),q=0;q<64;q++)c[h+q]=l[o+q]^F[q];for(Y=1,q=8;q<16;q++)Y=Y+(k[q]&255)|0,k[q]=Y&255,Y>>>=8;p-=64,h+=64,o+=64}if(p>0)for(T(F,k,w,Q),q=0;q<p;q++)c[h+q]=l[o+q]^F[q];return 0}function ie(c,h,l,o,p){var E=new Uint8Array(16),w=new Uint8Array(64),k,F;for(F=0;F<16;F++)E[F]=0;for(F=0;F<8;F++)E[F]=o[F];for(;l>=64;){for(T(w,E,p,Q),F=0;F<64;F++)c[h+F]=w[F];for(k=1,F=8;F<16;F++)k=k+(E[F]&255)|0,E[F]=k&255,k>>>=8;l-=64,h+=64}if(l>0)for(T(w,E,p,Q),F=0;F<l;F++)c[h+F]=w[F];return 0}function he(c,h,l,o,p){var E=new Uint8Array(32);M(E,o,p,Q);for(var w=new Uint8Array(8),k=0;k<8;k++)w[k]=o[k+16];return ie(c,h,l,w,E)}function de(c,h,l,o,p,E,w){var k=new Uint8Array(32);M(k,E,w,Q);for(var F=new Uint8Array(8),Y=0;Y<8;Y++)F[Y]=E[Y+16];return B(c,h,l,o,p,F,k)}var Pe=function(c){this.buffer=new Uint8Array(16),this.r=new Uint16Array(10),this.h=new Uint16Array(10),this.pad=new Uint16Array(8),this.leftover=0,this.fin=0;var h,l,o,p,E,w,k,F;h=c[0]&255|(c[1]&255)<<8,this.r[0]=h&8191,l=c[2]&255|(c[3]&255)<<8,this.r[1]=(h>>>13|l<<3)&8191,o=c[4]&255|(c[5]&255)<<8,this.r[2]=(l>>>10|o<<6)&7939,p=c[6]&255|(c[7]&255)<<8,this.r[3]=(o>>>7|p<<9)&8191,E=c[8]&255|(c[9]&255)<<8,this.r[4]=(p>>>4|E<<12)&255,this.r[5]=E>>>1&8190,w=c[10]&255|(c[11]&255)<<8,this.r[6]=(E>>>14|w<<2)&8191,k=c[12]&255|(c[13]&255)<<8,this.r[7]=(w>>>11|k<<5)&8065,F=c[14]&255|(c[15]&255)<<8,this.r[8]=(k>>>8|F<<8)&8191,this.r[9]=F>>>5&127,this.pad[0]=c[16]&255|(c[17]&255)<<8,this.pad[1]=c[18]&255|(c[19]&255)<<8,this.pad[2]=c[20]&255|(c[21]&255)<<8,this.pad[3]=c[22]&255|(c[23]&255)<<8,this.pad[4]=c[24]&255|(c[25]&255)<<8,this.pad[5]=c[26]&255|(c[27]&255)<<8,this.pad[6]=c[28]&255|(c[29]&255)<<8,this.pad[7]=c[30]&255|(c[31]&255)<<8};Pe.prototype.blocks=function(c,h,l){for(var o=this.fin?0:2048,p,E,w,k,F,Y,q,Te,V,te,re,fe,ce,ne,ae,se,K,Z,W,$=this.h[0],G=this.h[1],U=this.h[2],x=this.h[3],b=this.h[4],R=this.h[5],O=this.h[6],P=this.h[7],N=this.h[8],ee=this.h[9],ue=this.r[0],ge=this.r[1],le=this.r[2],m=this.r[3],ye=this.r[4],Oe=this.r[5],Ce=this.r[6],_e=this.r[7],xe=this.r[8],be=this.r[9];l>=16;)p=c[h+0]&255|(c[h+1]&255)<<8,$+=p&8191,E=c[h+2]&255|(c[h+3]&255)<<8,G+=(p>>>13|E<<3)&8191,w=c[h+4]&255|(c[h+5]&255)<<8,U+=(E>>>10|w<<6)&8191,k=c[h+6]&255|(c[h+7]&255)<<8,x+=(w>>>7|k<<9)&8191,F=c[h+8]&255|(c[h+9]&255)<<8,b+=(k>>>4|F<<12)&8191,R+=F>>>1&8191,Y=c[h+10]&255|(c[h+11]&255)<<8,O+=(F>>>14|Y<<2)&8191,q=c[h+12]&255|(c[h+13]&255)<<8,P+=(Y>>>11|q<<5)&8191,Te=c[h+14]&255|(c[h+15]&255)<<8,N+=(q>>>8|Te<<8)&8191,ee+=Te>>>5|o,V=0,te=V,te+=$*ue,te+=G*(5*be),te+=U*(5*xe),te+=x*(5*_e),te+=b*(5*Ce),V=te>>>13,te&=8191,te+=R*(5*Oe),te+=O*(5*ye),te+=P*(5*m),te+=N*(5*le),te+=ee*(5*ge),V+=te>>>13,te&=8191,re=V,re+=$*ge,re+=G*ue,re+=U*(5*be),re+=x*(5*xe),re+=b*(5*_e),V=re>>>13,re&=8191,re+=R*(5*Ce),re+=O*(5*Oe),re+=P*(5*ye),re+=N*(5*m),re+=ee*(5*le),V+=re>>>13,re&=8191,fe=V,fe+=$*le,fe+=G*ge,fe+=U*ue,fe+=x*(5*be),fe+=b*(5*xe),V=fe>>>13,fe&=8191,fe+=R*(5*_e),fe+=O*(5*Ce),fe+=P*(5*Oe),fe+=N*(5*ye),fe+=ee*(5*m),V+=fe>>>13,fe&=8191,ce=V,ce+=$*m,ce+=G*le,ce+=U*ge,ce+=x*ue,ce+=b*(5*be),V=ce>>>13,ce&=8191,ce+=R*(5*xe),ce+=O*(5*_e),ce+=P*(5*Ce),ce+=N*(5*Oe),ce+=ee*(5*ye),V+=ce>>>13,ce&=8191,ne=V,ne+=$*ye,ne+=G*m,ne+=U*le,ne+=x*ge,ne+=b*ue,V=ne>>>13,ne&=8191,ne+=R*(5*be),ne+=O*(5*xe),ne+=P*(5*_e),ne+=N*(5*Ce),ne+=ee*(5*Oe),V+=ne>>>13,ne&=8191,ae=V,ae+=$*Oe,ae+=G*ye,ae+=U*m,ae+=x*le,ae+=b*ge,V=ae>>>13,ae&=8191,ae+=R*ue,ae+=O*(5*be),ae+=P*(5*xe),ae+=N*(5*_e),ae+=ee*(5*Ce),V+=ae>>>13,ae&=8191,se=V,se+=$*Ce,se+=G*Oe,se+=U*ye,se+=x*m,se+=b*le,V=se>>>13,se&=8191,se+=R*ge,se+=O*ue,se+=P*(5*be),se+=N*(5*xe),se+=ee*(5*_e),V+=se>>>13,se&=8191,K=V,K+=$*_e,K+=G*Ce,K+=U*Oe,K+=x*ye,K+=b*m,V=K>>>13,K&=8191,K+=R*le,K+=O*ge,K+=P*ue,K+=N*(5*be),K+=ee*(5*xe),V+=K>>>13,K&=8191,Z=V,Z+=$*xe,Z+=G*_e,Z+=U*Ce,Z+=x*Oe,Z+=b*ye,V=Z>>>13,Z&=8191,Z+=R*m,Z+=O*le,Z+=P*ge,Z+=N*ue,Z+=ee*(5*be),V+=Z>>>13,Z&=8191,W=V,W+=$*be,W+=G*xe,W+=U*_e,W+=x*Ce,W+=b*Oe,V=W>>>13,W&=8191,W+=R*ye,W+=O*m,W+=P*le,W+=N*ge,W+=ee*ue,V+=W>>>13,W&=8191,V=(V<<2)+V|0,V=V+te|0,te=V&8191,V=V>>>13,re+=V,$=te,G=re,U=fe,x=ce,b=ne,R=ae,O=se,P=K,N=Z,ee=W,h+=16,l-=16;this.h[0]=$,this.h[1]=G,this.h[2]=U,this.h[3]=x,this.h[4]=b,this.h[5]=R,this.h[6]=O,this.h[7]=P,this.h[8]=N,this.h[9]=ee},Pe.prototype.finish=function(c,h){var l=new Uint16Array(10),o,p,E,w;if(this.leftover){for(w=this.leftover,this.buffer[w++]=1;w<16;w++)this.buffer[w]=0;this.fin=1,this.blocks(this.buffer,0,16)}for(o=this.h[1]>>>13,this.h[1]&=8191,w=2;w<10;w++)this.h[w]+=o,o=this.h[w]>>>13,this.h[w]&=8191;for(this.h[0]+=o*5,o=this.h[0]>>>13,this.h[0]&=8191,this.h[1]+=o,o=this.h[1]>>>13,this.h[1]&=8191,this.h[2]+=o,l[0]=this.h[0]+5,o=l[0]>>>13,l[0]&=8191,w=1;w<10;w++)l[w]=this.h[w]+o,o=l[w]>>>13,l[w]&=8191;for(l[9]-=8192,p=(o^1)-1,w=0;w<10;w++)l[w]&=p;for(p=~p,w=0;w<10;w++)this.h[w]=this.h[w]&p|l[w];for(this.h[0]=(this.h[0]|this.h[1]<<13)&65535,this.h[1]=(this.h[1]>>>3|this.h[2]<<10)&65535,this.h[2]=(this.h[2]>>>6|this.h[3]<<7)&65535,this.h[3]=(this.h[3]>>>9|this.h[4]<<4)&65535,this.h[4]=(this.h[4]>>>12|this.h[5]<<1|this.h[6]<<14)&65535,this.h[5]=(this.h[6]>>>2|this.h[7]<<11)&65535,this.h[6]=(this.h[7]>>>5|this.h[8]<<8)&65535,this.h[7]=(this.h[8]>>>8|this.h[9]<<5)&65535,E=this.h[0]+this.pad[0],this.h[0]=E&65535,w=1;w<8;w++)E=(this.h[w]+this.pad[w]|0)+(E>>>16)|0,this.h[w]=E&65535;c[h+0]=this.h[0]>>>0&255,c[h+1]=this.h[0]>>>8&255,c[h+2]=this.h[1]>>>0&255,c[h+3]=this.h[1]>>>8&255,c[h+4]=this.h[2]>>>0&255,c[h+5]=this.h[2]>>>8&255,c[h+6]=this.h[3]>>>0&255,c[h+7]=this.h[3]>>>8&255,c[h+8]=this.h[4]>>>0&255,c[h+9]=this.h[4]>>>8&255,c[h+10]=this.h[5]>>>0&255,c[h+11]=this.h[5]>>>8&255,c[h+12]=this.h[6]>>>0&255,c[h+13]=this.h[6]>>>8&255,c[h+14]=this.h[7]>>>0&255,c[h+15]=this.h[7]>>>8&255},Pe.prototype.update=function(c,h,l){var o,p;if(this.leftover){for(p=16-this.leftover,p>l&&(p=l),o=0;o<p;o++)this.buffer[this.leftover+o]=c[h+o];if(l-=p,h+=p,this.leftover+=p,this.leftover<16)return;this.blocks(this.buffer,0,16),this.leftover=0}if(l>=16&&(p=l-l%16,this.blocks(c,h,p),h+=p,l-=p),l){for(o=0;o<l;o++)this.buffer[this.leftover+o]=c[h+o];this.leftover+=l}};function We(c,h,l,o,p,E){var w=new Pe(E);return w.update(l,o,p),w.finish(c,h),0}function Ge(c,h,l,o,p,E){var w=new Uint8Array(16);return We(w,0,l,o,p,E),C(c,h,w,0)}function ve(c,h,l,o,p){var E;if(l<32)return-1;for(de(c,0,h,0,l,o,p),We(c,16,c,32,l-32,c),E=0;E<16;E++)c[E]=0;return 0}function Ye(c,h,l,o,p){var E,w=new Uint8Array(32);if(l<32||(he(w,0,32,o,p),Ge(h,16,h,32,l-32,w)!==0))return-1;for(de(c,0,h,0,l,o,p),E=0;E<32;E++)c[E]=0;return 0}function Fe(c,h){var l;for(l=0;l<16;l++)c[l]=h[l]|0}function J(c){var h,l,o=1;for(h=0;h<16;h++)l=c[h]+o+65535,o=Math.floor(l/65536),c[h]=l-o*65536;c[0]+=o-1+37*(o-1)}function Ee(c,h,l){for(var o,p=~(l-1),E=0;E<16;E++)o=p&(c[E]^h[E]),c[E]^=o,h[E]^=o}function pe(c,h){var l,o,p,E=e(),w=e();for(l=0;l<16;l++)w[l]=h[l];for(J(w),J(w),J(w),o=0;o<2;o++){for(E[0]=w[0]-65517,l=1;l<15;l++)E[l]=w[l]-65535-(E[l-1]>>16&1),E[l-1]&=65535;E[15]=w[15]-32767-(E[14]>>16&1),p=E[15]>>16&1,E[14]&=65535,Ee(w,E,1-p)}for(l=0;l<16;l++)c[2*l]=w[l]&255,c[2*l+1]=w[l]>>8}function nt(c,h){var l=new Uint8Array(32),o=new Uint8Array(32);return pe(l,c),pe(o,h),H(l,0,o,0)}function Ze(c){var h=new Uint8Array(32);return pe(h,c),h[0]&1}function Wt(c,h){var l;for(l=0;l<16;l++)c[l]=h[2*l]+(h[2*l+1]<<8);c[15]&=32767}function L(c,h,l){for(var o=0;o<16;o++)c[o]=h[o]+l[o]}function j(c,h,l){for(var o=0;o<16;o++)c[o]=h[o]-l[o]}function A(c,h,l){var o,p,E=0,w=0,k=0,F=0,Y=0,q=0,Te=0,V=0,te=0,re=0,fe=0,ce=0,ne=0,ae=0,se=0,K=0,Z=0,W=0,$=0,G=0,U=0,x=0,b=0,R=0,O=0,P=0,N=0,ee=0,ue=0,ge=0,le=0,m=l[0],ye=l[1],Oe=l[2],Ce=l[3],_e=l[4],xe=l[5],be=l[6],ze=l[7],Re=l[8],Ve=l[9],Ke=l[10],$e=l[11],Je=l[12],it=l[13],ot=l[14],at=l[15];o=h[0],E+=o*m,w+=o*ye,k+=o*Oe,F+=o*Ce,Y+=o*_e,q+=o*xe,Te+=o*be,V+=o*ze,te+=o*Re,re+=o*Ve,fe+=o*Ke,ce+=o*$e,ne+=o*Je,ae+=o*it,se+=o*ot,K+=o*at,o=h[1],w+=o*m,k+=o*ye,F+=o*Oe,Y+=o*Ce,q+=o*_e,Te+=o*xe,V+=o*be,te+=o*ze,re+=o*Re,fe+=o*Ve,ce+=o*Ke,ne+=o*$e,ae+=o*Je,se+=o*it,K+=o*ot,Z+=o*at,o=h[2],k+=o*m,F+=o*ye,Y+=o*Oe,q+=o*Ce,Te+=o*_e,V+=o*xe,te+=o*be,re+=o*ze,fe+=o*Re,ce+=o*Ve,ne+=o*Ke,ae+=o*$e,se+=o*Je,K+=o*it,Z+=o*ot,W+=o*at,o=h[3],F+=o*m,Y+=o*ye,q+=o*Oe,Te+=o*Ce,V+=o*_e,te+=o*xe,re+=o*be,fe+=o*ze,ce+=o*Re,ne+=o*Ve,ae+=o*Ke,se+=o*$e,K+=o*Je,Z+=o*it,W+=o*ot,$+=o*at,o=h[4],Y+=o*m,q+=o*ye,Te+=o*Oe,V+=o*Ce,te+=o*_e,re+=o*xe,fe+=o*be,ce+=o*ze,ne+=o*Re,ae+=o*Ve,se+=o*Ke,K+=o*$e,Z+=o*Je,W+=o*it,$+=o*ot,G+=o*at,o=h[5],q+=o*m,Te+=o*ye,V+=o*Oe,te+=o*Ce,re+=o*_e,fe+=o*xe,ce+=o*be,ne+=o*ze,ae+=o*Re,se+=o*Ve,K+=o*Ke,Z+=o*$e,W+=o*Je,$+=o*it,G+=o*ot,U+=o*at,o=h[6],Te+=o*m,V+=o*ye,te+=o*Oe,re+=o*Ce,fe+=o*_e,ce+=o*xe,ne+=o*be,ae+=o*ze,se+=o*Re,K+=o*Ve,Z+=o*Ke,W+=o*$e,$+=o*Je,G+=o*it,U+=o*ot,x+=o*at,o=h[7],V+=o*m,te+=o*ye,re+=o*Oe,fe+=o*Ce,ce+=o*_e,ne+=o*xe,ae+=o*be,se+=o*ze,K+=o*Re,Z+=o*Ve,W+=o*Ke,$+=o*$e,G+=o*Je,U+=o*it,x+=o*ot,b+=o*at,o=h[8],te+=o*m,re+=o*ye,fe+=o*Oe,ce+=o*Ce,ne+=o*_e,ae+=o*xe,se+=o*be,K+=o*ze,Z+=o*Re,W+=o*Ve,$+=o*Ke,G+=o*$e,U+=o*Je,x+=o*it,b+=o*ot,R+=o*at,o=h[9],re+=o*m,fe+=o*ye,ce+=o*Oe,ne+=o*Ce,ae+=o*_e,se+=o*xe,K+=o*be,Z+=o*ze,W+=o*Re,$+=o*Ve,G+=o*Ke,U+=o*$e,x+=o*Je,b+=o*it,R+=o*ot,O+=o*at,o=h[10],fe+=o*m,ce+=o*ye,ne+=o*Oe,ae+=o*Ce,se+=o*_e,K+=o*xe,Z+=o*be,W+=o*ze,$+=o*Re,G+=o*Ve,U+=o*Ke,x+=o*$e,b+=o*Je,R+=o*it,O+=o*ot,P+=o*at,o=h[11],ce+=o*m,ne+=o*ye,ae+=o*Oe,se+=o*Ce,K+=o*_e,Z+=o*xe,W+=o*be,$+=o*ze,G+=o*Re,U+=o*Ve,x+=o*Ke,b+=o*$e,R+=o*Je,O+=o*it,P+=o*ot,N+=o*at,o=h[12],ne+=o*m,ae+=o*ye,se+=o*Oe,K+=o*Ce,Z+=o*_e,W+=o*xe,$+=o*be,G+=o*ze,U+=o*Re,x+=o*Ve,b+=o*Ke,R+=o*$e,O+=o*Je,P+=o*it,N+=o*ot,ee+=o*at,o=h[13],ae+=o*m,se+=o*ye,K+=o*Oe,Z+=o*Ce,W+=o*_e,$+=o*xe,G+=o*be,U+=o*ze,x+=o*Re,b+=o*Ve,R+=o*Ke,O+=o*$e,P+=o*Je,N+=o*it,ee+=o*ot,ue+=o*at,o=h[14],se+=o*m,K+=o*ye,Z+=o*Oe,W+=o*Ce,$+=o*_e,G+=o*xe,U+=o*be,x+=o*ze,b+=o*Re,R+=o*Ve,O+=o*Ke,P+=o*$e,N+=o*Je,ee+=o*it,ue+=o*ot,ge+=o*at,o=h[15],K+=o*m,Z+=o*ye,W+=o*Oe,$+=o*Ce,G+=o*_e,U+=o*xe,x+=o*be,b+=o*ze,R+=o*Re,O+=o*Ve,P+=o*Ke,N+=o*$e,ee+=o*Je,ue+=o*it,ge+=o*ot,le+=o*at,E+=38*Z,w+=38*W,k+=38*$,F+=38*G,Y+=38*U,q+=38*x,Te+=38*b,V+=38*R,te+=38*O,re+=38*P,fe+=38*N,ce+=38*ee,ne+=38*ue,ae+=38*ge,se+=38*le,p=1,o=E+p+65535,p=Math.floor(o/65536),E=o-p*65536,o=w+p+65535,p=Math.floor(o/65536),w=o-p*65536,o=k+p+65535,p=Math.floor(o/65536),k=o-p*65536,o=F+p+65535,p=Math.floor(o/65536),F=o-p*65536,o=Y+p+65535,p=Math.floor(o/65536),Y=o-p*65536,o=q+p+65535,p=Math.floor(o/65536),q=o-p*65536,o=Te+p+65535,p=Math.floor(o/65536),Te=o-p*65536,o=V+p+65535,p=Math.floor(o/65536),V=o-p*65536,o=te+p+65535,p=Math.floor(o/65536),te=o-p*65536,o=re+p+65535,p=Math.floor(o/65536),re=o-p*65536,o=fe+p+65535,p=Math.floor(o/65536),fe=o-p*65536,o=ce+p+65535,p=Math.floor(o/65536),ce=o-p*65536,o=ne+p+65535,p=Math.floor(o/65536),ne=o-p*65536,o=ae+p+65535,p=Math.floor(o/65536),ae=o-p*65536,o=se+p+65535,p=Math.floor(o/65536),se=o-p*65536,o=K+p+65535,p=Math.floor(o/65536),K=o-p*65536,E+=p-1+37*(p-1),p=1,o=E+p+65535,p=Math.floor(o/65536),E=o-p*65536,o=w+p+65535,p=Math.floor(o/65536),w=o-p*65536,o=k+p+65535,p=Math.floor(o/65536),k=o-p*65536,o=F+p+65535,p=Math.floor(o/65536),F=o-p*65536,o=Y+p+65535,p=Math.floor(o/65536),Y=o-p*65536,o=q+p+65535,p=Math.floor(o/65536),q=o-p*65536,o=Te+p+65535,p=Math.floor(o/65536),Te=o-p*65536,o=V+p+65535,p=Math.floor(o/65536),V=o-p*65536,o=te+p+65535,p=Math.floor(o/65536),te=o-p*65536,o=re+p+65535,p=Math.floor(o/65536),re=o-p*65536,o=fe+p+65535,p=Math.floor(o/65536),fe=o-p*65536,o=ce+p+65535,p=Math.floor(o/65536),ce=o-p*65536,o=ne+p+65535,p=Math.floor(o/65536),ne=o-p*65536,o=ae+p+65535,p=Math.floor(o/65536),ae=o-p*65536,o=se+p+65535,p=Math.floor(o/65536),se=o-p*65536,o=K+p+65535,p=Math.floor(o/65536),K=o-p*65536,E+=p-1+37*(p-1),c[0]=E,c[1]=w,c[2]=k,c[3]=F,c[4]=Y,c[5]=q,c[6]=Te,c[7]=V,c[8]=te,c[9]=re,c[10]=fe,c[11]=ce,c[12]=ne,c[13]=ae,c[14]=se,c[15]=K}function oe(c,h){A(c,h,h)}function Ae(c,h){var l=e(),o;for(o=0;o<16;o++)l[o]=h[o];for(o=253;o>=0;o--)oe(l,l),o!==2&&o!==4&&A(l,l,h);for(o=0;o<16;o++)c[o]=l[o]}function ut(c,h){var l=e(),o;for(o=0;o<16;o++)l[o]=h[o];for(o=250;o>=0;o--)oe(l,l),o!==1&&A(l,l,h);for(o=0;o<16;o++)c[o]=l[o]}function mt(c,h,l){var o=new Uint8Array(32),p=new Float64Array(80),E,w,k=e(),F=e(),Y=e(),q=e(),Te=e(),V=e();for(w=0;w<31;w++)o[w]=h[w];for(o[31]=h[31]&127|64,o[0]&=248,Wt(p,l),w=0;w<16;w++)F[w]=p[w],q[w]=k[w]=Y[w]=0;for(k[0]=q[0]=1,w=254;w>=0;--w)E=o[w>>>3]>>>(w&7)&1,Ee(k,F,E),Ee(Y,q,E),L(Te,k,Y),j(k,k,Y),L(Y,F,q),j(F,F,q),oe(q,Te),oe(V,k),A(k,Y,k),A(Y,F,Te),L(Te,k,Y),j(k,k,Y),oe(F,k),j(Y,q,V),A(k,Y,f),L(k,k,q),A(Y,Y,k),A(k,q,V),A(q,F,p),oe(F,Te),Ee(k,F,E),Ee(Y,q,E);for(w=0;w<16;w++)p[w+16]=k[w],p[w+32]=Y[w],p[w+48]=F[w],p[w+64]=q[w];var te=p.subarray(32),re=p.subarray(16);return Ae(te,te),A(re,re,te),pe(c,re),0}function yt(c,h){return mt(c,h,s)}function Et(c,h){return t(h,32),yt(c,h)}function nr(c,h,l){var o=new Uint8Array(32);return mt(o,l,h),M(c,n,o,Q)}var Er=ve,qr=Ye;function wr(c,h,l,o,p,E){var w=new Uint8Array(32);return nr(w,p,E),Er(c,h,l,o,w)}function gn(c,h,l,o,p,E){var w=new Uint8Array(32);return nr(w,p,E),qr(c,h,l,o,w)}var Rs=[1116352408,3609767458,1899447441,602891725,3049323471,3964484399,3921009573,2173295548,961987163,4081628472,1508970993,3053834265,2453635748,2937671579,2870763221,3664609560,3624381080,2734883394,310598401,1164996542,607225278,1323610764,1426881987,3590304994,1925078388,4068182383,2162078206,991336113,2614888103,633803317,3248222580,3479774868,3835390401,2666613458,4022224774,944711139,264347078,2341262773,604807628,2007800933,770255983,1495990901,1249150122,1856431235,1555081692,3175218132,1996064986,2198950837,2554220882,3999719339,2821834349,766784016,2952996808,2566594879,3210313671,3203337956,3336571891,1034457026,3584528711,2466948901,113926993,3758326383,338241895,168717936,666307205,1188179964,773529912,1546045734,1294757372,1522805485,1396182291,2643833823,1695183700,2343527390,1986661051,1014477480,2177026350,1206759142,2456956037,344077627,2730485921,1290863460,2820302411,3158454273,3259730800,3505952657,3345764771,106217008,3516065817,3606008344,3600352804,1432725776,4094571909,1467031594,275423344,851169720,430227734,3100823752,506948616,1363258195,659060556,3750685593,883997877,3785050280,958139571,3318307427,1322822218,3812723403,1537002063,2003034995,1747873779,3602036899,1955562222,1575990012,2024104815,1125592928,2227730452,2716904306,2361852424,442776044,2428436474,593698344,2756734187,3733110249,3204031479,2999351573,3329325298,3815920427,3391569614,3928383900,3515267271,566280711,3940187606,3454069534,4118630271,4000239992,116418474,1914138554,174292421,2731055270,289380356,3203993006,460393269,320620315,685471733,587496836,852142971,1086792851,1017036298,365543100,1126000580,2618297676,1288033470,3409855158,1501505948,4234509866,1607167915,987167468,1816402316,1246189591];function $c(c,h,l,o){for(var p=new Int32Array(16),E=new Int32Array(16),w,k,F,Y,q,Te,V,te,re,fe,ce,ne,ae,se,K,Z,W,$,G,U,x,b,R,O,P,N,ee=c[0],ue=c[1],ge=c[2],le=c[3],m=c[4],ye=c[5],Oe=c[6],Ce=c[7],_e=h[0],xe=h[1],be=h[2],ze=h[3],Re=h[4],Ve=h[5],Ke=h[6],$e=h[7],Je=0;o>=128;){for(G=0;G<16;G++)U=8*G+Je,p[G]=l[U+0]<<24|l[U+1]<<16|l[U+2]<<8|l[U+3],E[G]=l[U+4]<<24|l[U+5]<<16|l[U+6]<<8|l[U+7];for(G=0;G<80;G++)if(w=ee,k=ue,F=ge,Y=le,q=m,Te=ye,V=Oe,te=Ce,re=_e,fe=xe,ce=be,ne=ze,ae=Re,se=Ve,K=Ke,Z=$e,x=Ce,b=$e,R=b&65535,O=b>>>16,P=x&65535,N=x>>>16,x=(m>>>14|Re<<18)^(m>>>18|Re<<14)^(Re>>>9|m<<23),b=(Re>>>14|m<<18)^(Re>>>18|m<<14)^(m>>>9|Re<<23),R+=b&65535,O+=b>>>16,P+=x&65535,N+=x>>>16,x=m&ye^~m&Oe,b=Re&Ve^~Re&Ke,R+=b&65535,O+=b>>>16,P+=x&65535,N+=x>>>16,x=Rs[G*2],b=Rs[G*2+1],R+=b&65535,O+=b>>>16,P+=x&65535,N+=x>>>16,x=p[G%16],b=E[G%16],R+=b&65535,O+=b>>>16,P+=x&65535,N+=x>>>16,O+=R>>>16,P+=O>>>16,N+=P>>>16,W=P&65535|N<<16,$=R&65535|O<<16,x=W,b=$,R=b&65535,O=b>>>16,P=x&65535,N=x>>>16,x=(ee>>>28|_e<<4)^(_e>>>2|ee<<30)^(_e>>>7|ee<<25),b=(_e>>>28|ee<<4)^(ee>>>2|_e<<30)^(ee>>>7|_e<<25),R+=b&65535,O+=b>>>16,P+=x&65535,N+=x>>>16,x=ee&ue^ee&ge^ue&ge,b=_e&xe^_e&be^xe&be,R+=b&65535,O+=b>>>16,P+=x&65535,N+=x>>>16,O+=R>>>16,P+=O>>>16,N+=P>>>16,te=P&65535|N<<16,Z=R&65535|O<<16,x=Y,b=ne,R=b&65535,O=b>>>16,P=x&65535,N=x>>>16,x=W,b=$,R+=b&65535,O+=b>>>16,P+=x&65535,N+=x>>>16,O+=R>>>16,P+=O>>>16,N+=P>>>16,Y=P&65535|N<<16,ne=R&65535|O<<16,ue=w,ge=k,le=F,m=Y,ye=q,Oe=Te,Ce=V,ee=te,xe=re,be=fe,ze=ce,Re=ne,Ve=ae,Ke=se,$e=K,_e=Z,G%16===15)for(U=0;U<16;U++)x=p[U],b=E[U],R=b&65535,O=b>>>16,P=x&65535,N=x>>>16,x=p[(U+9)%16],b=E[(U+9)%16],R+=b&65535,O+=b>>>16,P+=x&65535,N+=x>>>16,W=p[(U+1)%16],$=E[(U+1)%16],x=(W>>>1|$<<31)^(W>>>8|$<<24)^W>>>7,b=($>>>1|W<<31)^($>>>8|W<<24)^($>>>7|W<<25),R+=b&65535,O+=b>>>16,P+=x&65535,N+=x>>>16,W=p[(U+14)%16],$=E[(U+14)%16],x=(W>>>19|$<<13)^($>>>29|W<<3)^W>>>6,b=($>>>19|W<<13)^(W>>>29|$<<3)^($>>>6|W<<26),R+=b&65535,O+=b>>>16,P+=x&65535,N+=x>>>16,O+=R>>>16,P+=O>>>16,N+=P>>>16,p[U]=P&65535|N<<16,E[U]=R&65535|O<<16;x=ee,b=_e,R=b&65535,O=b>>>16,P=x&65535,N=x>>>16,x=c[0],b=h[0],R+=b&65535,O+=b>>>16,P+=x&65535,N+=x>>>16,O+=R>>>16,P+=O>>>16,N+=P>>>16,c[0]=ee=P&65535|N<<16,h[0]=_e=R&65535|O<<16,x=ue,b=xe,R=b&65535,O=b>>>16,P=x&65535,N=x>>>16,x=c[1],b=h[1],R+=b&65535,O+=b>>>16,P+=x&65535,N+=x>>>16,O+=R>>>16,P+=O>>>16,N+=P>>>16,c[1]=ue=P&65535|N<<16,h[1]=xe=R&65535|O<<16,x=ge,b=be,R=b&65535,O=b>>>16,P=x&65535,N=x>>>16,x=c[2],b=h[2],R+=b&65535,O+=b>>>16,P+=x&65535,N+=x>>>16,O+=R>>>16,P+=O>>>16,N+=P>>>16,c[2]=ge=P&65535|N<<16,h[2]=be=R&65535|O<<16,x=le,b=ze,R=b&65535,O=b>>>16,P=x&65535,N=x>>>16,x=c[3],b=h[3],R+=b&65535,O+=b>>>16,P+=x&65535,N+=x>>>16,O+=R>>>16,P+=O>>>16,N+=P>>>16,c[3]=le=P&65535|N<<16,h[3]=ze=R&65535|O<<16,x=m,b=Re,R=b&65535,O=b>>>16,P=x&65535,N=x>>>16,x=c[4],b=h[4],R+=b&65535,O+=b>>>16,P+=x&65535,N+=x>>>16,O+=R>>>16,P+=O>>>16,N+=P>>>16,c[4]=m=P&65535|N<<16,h[4]=Re=R&65535|O<<16,x=ye,b=Ve,R=b&65535,O=b>>>16,P=x&65535,N=x>>>16,x=c[5],b=h[5],R+=b&65535,O+=b>>>16,P+=x&65535,N+=x>>>16,O+=R>>>16,P+=O>>>16,N+=P>>>16,c[5]=ye=P&65535|N<<16,h[5]=Ve=R&65535|O<<16,x=Oe,b=Ke,R=b&65535,O=b>>>16,P=x&65535,N=x>>>16,x=c[6],b=h[6],R+=b&65535,O+=b>>>16,P+=x&65535,N+=x>>>16,O+=R>>>16,P+=O>>>16,N+=P>>>16,c[6]=Oe=P&65535|N<<16,h[6]=Ke=R&65535|O<<16,x=Ce,b=$e,R=b&65535,O=b>>>16,P=x&65535,N=x>>>16,x=c[7],b=h[7],R+=b&65535,O+=b>>>16,P+=x&65535,N+=x>>>16,O+=R>>>16,P+=O>>>16,N+=P>>>16,c[7]=Ce=P&65535|N<<16,h[7]=$e=R&65535|O<<16,Je+=128,o-=128}return o}function Wr(c,h,l){var o=new Int32Array(8),p=new Int32Array(8),E=new Uint8Array(256),w,k=l;for(o[0]=1779033703,o[1]=3144134277,o[2]=1013904242,o[3]=2773480762,o[4]=1359893119,o[5]=2600822924,o[6]=528734635,o[7]=1541459225,p[0]=4089235720,p[1]=2227873595,p[2]=4271175723,p[3]=1595750129,p[4]=2917565137,p[5]=725511199,p[6]=4215389547,p[7]=327033209,$c(o,p,h,l),l%=128,w=0;w<l;w++)E[w]=h[k-l+w];for(E[l]=128,l=256-128*(l<112?1:0),E[l-9]=0,v(E,l-8,k/536870912|0,k<<3),$c(o,p,E,l),w=0;w<8;w++)v(c,8*w,o[w],p[w]);return 0}function As(c,h){var l=e(),o=e(),p=e(),E=e(),w=e(),k=e(),F=e(),Y=e(),q=e();j(l,c[1],c[0]),j(q,h[1],h[0]),A(l,l,q),L(o,c[0],c[1]),L(q,h[0],h[1]),A(o,o,q),A(p,c[3],h[3]),A(p,p,d),A(E,c[2],h[2]),L(E,E,E),j(w,o,l),j(k,E,p),L(F,E,p),L(Y,o,l),A(c[0],w,k),A(c[1],Y,F),A(c[2],F,k),A(c[3],w,Y)}function zc(c,h,l){var o;for(o=0;o<4;o++)Ee(c[o],h[o],l)}function uo(c,h){var l=e(),o=e(),p=e();Ae(p,h[2]),A(l,h[0],p),A(o,h[1],p),pe(c,o),c[31]^=Ze(l)<<7}function lo(c,h,l){var o,p;for(Fe(c[0],i),Fe(c[1],a),Fe(c[2],a),Fe(c[3],i),p=255;p>=0;--p)o=l[p/8|0]>>(p&7)&1,zc(c,h,o),As(h,c),As(c,c),zc(c,h,o)}function Is(c,h){var l=[e(),e(),e(),e()];Fe(l[0],g),Fe(l[1],_),Fe(l[2],a),A(l[3],g,_),lo(c,l,h)}function ho(c,h,l){var o=new Uint8Array(64),p=[e(),e(),e(),e()],E;for(l||t(h,32),Wr(o,h,32),o[0]&=248,o[31]&=127,o[31]|=64,Is(p,o),uo(c,p),E=0;E<32;E++)h[E+32]=c[E];return 0}var Ls=new Float64Array([237,211,245,92,26,99,18,88,214,156,247,162,222,249,222,20,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,16]);function po(c,h){var l,o,p,E;for(o=63;o>=32;--o){for(l=0,p=o-32,E=o-12;p<E;++p)h[p]+=l-16*h[o]*Ls[p-(o-32)],l=Math.floor((h[p]+128)/256),h[p]-=l*256;h[p]+=l,h[o]=0}for(l=0,p=0;p<32;p++)h[p]+=l-(h[31]>>4)*Ls[p],l=h[p]>>8,h[p]&=255;for(p=0;p<32;p++)h[p]-=l*Ls[p];for(o=0;o<32;o++)h[o+1]+=h[o]>>8,c[o]=h[o]&255}function go(c){var h=new Float64Array(64),l;for(l=0;l<64;l++)h[l]=c[l];for(l=0;l<64;l++)c[l]=0;po(c,h)}function Gc(c,h,l,o){var p=new Uint8Array(64),E=new Uint8Array(64),w=new Uint8Array(64),k,F,Y=new Float64Array(64),q=[e(),e(),e(),e()];Wr(p,o,32),p[0]&=248,p[31]&=127,p[31]|=64;var Te=l+64;for(k=0;k<l;k++)c[64+k]=h[k];for(k=0;k<32;k++)c[32+k]=p[32+k];for(Wr(w,c.subarray(32),l+32),go(w),Is(q,w),uo(c,q),k=32;k<64;k++)c[k]=o[k];for(Wr(E,c,l+64),go(E),k=0;k<64;k++)Y[k]=0;for(k=0;k<32;k++)Y[k]=w[k];for(k=0;k<32;k++)for(F=0;F<32;F++)Y[k+F]+=E[k]*p[F];return po(c.subarray(32),Y),Te}function Sd(c,h){var l=e(),o=e(),p=e(),E=e(),w=e(),k=e(),F=e();return Fe(c[2],a),Wt(c[1],h),oe(p,c[1]),A(E,p,u),j(p,p,c[2]),L(E,c[2],E),oe(w,E),oe(k,w),A(F,k,w),A(l,F,p),A(l,l,E),ut(l,l),A(l,l,p),A(l,l,E),A(l,l,E),A(c[0],l,E),oe(o,c[0]),A(o,o,E),nt(o,p)&&A(c[0],c[0],y),oe(o,c[0]),A(o,o,E),nt(o,p)?-1:(Ze(c[0])===h[31]>>7&&j(c[0],i,c[0]),A(c[3],c[0],c[1]),0)}function _o(c,h,l,o){var p,E=new Uint8Array(32),w=new Uint8Array(64),k=[e(),e(),e(),e()],F=[e(),e(),e(),e()];if(l<64||Sd(F,o))return-1;for(p=0;p<l;p++)c[p]=h[p];for(p=0;p<32;p++)c[p+32]=o[p];if(Wr(w,c,l),go(w),lo(k,F,w),Is(F,h.subarray(32)),As(k,F),uo(E,k),l-=64,H(h,0,E,0)){for(p=0;p<l;p++)c[p]=0;return-1}for(p=0;p<l;p++)c[p]=h[p+64];return l}var mo=32,Ns=24,$n=32,_n=16,zn=32,Ds=32,Gn=32,Yn=32,yo=32,Yc=Ns,Td=$n,Od=_n,sr=64,Hr=32,mn=64,Eo=32,wo=64;r.lowlevel={crypto_core_hsalsa20:M,crypto_stream_xor:de,crypto_stream:he,crypto_stream_salsa20_xor:B,crypto_stream_salsa20:ie,crypto_onetimeauth:We,crypto_onetimeauth_verify:Ge,crypto_verify_16:C,crypto_verify_32:H,crypto_secretbox:ve,crypto_secretbox_open:Ye,crypto_scalarmult:mt,crypto_scalarmult_base:yt,crypto_box_beforenm:nr,crypto_box_afternm:Er,crypto_box:wr,crypto_box_open:gn,crypto_box_keypair:Et,crypto_hash:Wr,crypto_sign:Gc,crypto_sign_keypair:ho,crypto_sign_open:_o,crypto_secretbox_KEYBYTES:mo,crypto_secretbox_NONCEBYTES:Ns,crypto_secretbox_ZEROBYTES:$n,crypto_secretbox_BOXZEROBYTES:_n,crypto_scalarmult_BYTES:zn,crypto_scalarmult_SCALARBYTES:Ds,crypto_box_PUBLICKEYBYTES:Gn,crypto_box_SECRETKEYBYTES:Yn,crypto_box_BEFORENMBYTES:yo,crypto_box_NONCEBYTES:Yc,crypto_box_ZEROBYTES:Td,crypto_box_BOXZEROBYTES:Od,crypto_sign_BYTES:sr,crypto_sign_PUBLICKEYBYTES:Hr,crypto_sign_SECRETKEYBYTES:mn,crypto_sign_SEEDBYTES:Eo,crypto_hash_BYTES:wo,gf:e,D:u,L:Ls,pack25519:pe,unpack25519:Wt,M:A,A:L,S:oe,Z:j,pow2523:ut,add:As,set25519:Fe,modL:po,scalarmult:lo,scalarbase:Is};function Xc(c,h){if(c.length!==mo)throw new Error("bad key size");if(h.length!==Ns)throw new Error("bad nonce size")}function Cd(c,h){if(c.length!==Gn)throw new Error("bad public key size");if(h.length!==Yn)throw new Error("bad secret key size")}function wt(){for(var c=0;c<arguments.length;c++)if(!(arguments[c]instanceof Uint8Array))throw new TypeError("unexpected type, use Uint8Array")}function Jc(c){for(var h=0;h<c.length;h++)c[h]=0}r.randomBytes=function(c){var h=new Uint8Array(c);return t(h,c),h},r.secretbox=function(c,h,l){wt(c,h,l),Xc(l,h);for(var o=new Uint8Array($n+c.length),p=new Uint8Array(o.length),E=0;E<c.length;E++)o[E+$n]=c[E];return ve(p,o,o.length,h,l),p.subarray(_n)},r.secretbox.open=function(c,h,l){wt(c,h,l),Xc(l,h);for(var o=new Uint8Array(_n+c.length),p=new Uint8Array(o.length),E=0;E<c.length;E++)o[E+_n]=c[E];return o.length<32||Ye(p,o,o.length,h,l)!==0?null:p.subarray($n)},r.secretbox.keyLength=mo,r.secretbox.nonceLength=Ns,r.secretbox.overheadLength=_n,r.scalarMult=function(c,h){if(wt(c,h),c.length!==Ds)throw new Error("bad n size");if(h.length!==zn)throw new Error("bad p size");var l=new Uint8Array(zn);return mt(l,c,h),l},r.scalarMult.base=function(c){if(wt(c),c.length!==Ds)throw new Error("bad n size");var h=new Uint8Array(zn);return yt(h,c),h},r.scalarMult.scalarLength=Ds,r.scalarMult.groupElementLength=zn,r.box=function(c,h,l,o){var p=r.box.before(l,o);return r.secretbox(c,h,p)},r.box.before=function(c,h){wt(c,h),Cd(c,h);var l=new Uint8Array(yo);return nr(l,c,h),l},r.box.after=r.secretbox,r.box.open=function(c,h,l,o){var p=r.box.before(l,o);return r.secretbox.open(c,h,p)},r.box.open.after=r.secretbox.open,r.box.keyPair=function(){var c=new Uint8Array(Gn),h=new Uint8Array(Yn);return Et(c,h),{publicKey:c,secretKey:h}},r.box.keyPair.fromSecretKey=function(c){if(wt(c),c.length!==Yn)throw new Error("bad secret key size");var h=new Uint8Array(Gn);return yt(h,c),{publicKey:h,secretKey:new Uint8Array(c)}},r.box.publicKeyLength=Gn,r.box.secretKeyLength=Yn,r.box.sharedKeyLength=yo,r.box.nonceLength=Yc,r.box.overheadLength=r.secretbox.overheadLength,r.sign=function(c,h){if(wt(c,h),h.length!==mn)throw new Error("bad secret key size");var l=new Uint8Array(sr+c.length);return Gc(l,c,c.length,h),l},r.sign.open=function(c,h){if(wt(c,h),h.length!==Hr)throw new Error("bad public key size");var l=new Uint8Array(c.length),o=_o(l,c,c.length,h);if(o<0)return null;for(var p=new Uint8Array(o),E=0;E<p.length;E++)p[E]=l[E];return p},r.sign.detached=function(c,h){for(var l=r.sign(c,h),o=new Uint8Array(sr),p=0;p<o.length;p++)o[p]=l[p];return o},r.sign.detached.verify=function(c,h,l){if(wt(c,h,l),h.length!==sr)throw new Error("bad signature size");if(l.length!==Hr)throw new Error("bad public key size");var o=new Uint8Array(sr+c.length),p=new Uint8Array(sr+c.length),E;for(E=0;E<sr;E++)o[E]=h[E];for(E=0;E<c.length;E++)o[E+sr]=c[E];return _o(p,o,o.length,l)>=0},r.sign.keyPair=function(){var c=new Uint8Array(Hr),h=new Uint8Array(mn);return ho(c,h),{publicKey:c,secretKey:h}},r.sign.keyPair.fromSecretKey=function(c){if(wt(c),c.length!==mn)throw new Error("bad secret key size");for(var h=new Uint8Array(Hr),l=0;l<h.length;l++)h[l]=c[32+l];return{publicKey:h,secretKey:new Uint8Array(c)}},r.sign.keyPair.fromSeed=function(c){if(wt(c),c.length!==Eo)throw new Error("bad seed size");for(var h=new Uint8Array(Hr),l=new Uint8Array(mn),o=0;o<32;o++)l[o]=c[o];return ho(h,l,!0),{publicKey:h,secretKey:l}},r.sign.publicKeyLength=Hr,r.sign.secretKeyLength=mn,r.sign.seedLength=Eo,r.sign.signatureLength=sr,r.hash=function(c){wt(c);var h=new Uint8Array(wo);return Wr(h,c,c.length),h},r.hash.hashLength=wo,r.verify=function(c,h){return wt(c,h),c.length===0||h.length===0||c.length!==h.length?!1:S(c,0,h,0,c.length)===0},r.setPRNG=function(c){t=c},(function(){var c=typeof self<"u"?self.crypto||self.msCrypto:null;if(c&&c.getRandomValues){var h=65536;r.setPRNG(function(l,o){var p,E=new Uint8Array(o);for(p=0;p<o;p+=h)c.getRandomValues(E.subarray(p,p+Math.min(o-p,h)));for(p=0;p<o;p++)l[p]=E[p];Jc(E)})}else typeof require<"u"&&(c=require("crypto"),c&&c.randomBytes&&r.setPRNG(function(l,o){var p,E=c.randomBytes(o);for(p=0;p<o;p++)l[p]=E[p];Jc(E)}))})()})(typeof $s<"u"&&$s.exports?$s.exports:self.nacl=self.nacl||{})});var To=D((mf,zs)=>{(function(r,e){"use strict";typeof zs<"u"&&zs.exports?zs.exports=e():(r.nacl||(r.nacl={}),r.nacl.util=e())})(mf,function(){"use strict";var r={};function e(t){if(!/^(?:[A-Za-z0-9+\/]{2}[A-Za-z0-9+\/]{2})*(?:[A-Za-z0-9+\/]{2}==|[A-Za-z0-9+\/]{3}=)?$/.test(t))throw new TypeError("invalid encoding")}return r.decodeUTF8=function(t){if(typeof t!="string")throw new TypeError("expected string");var n,s=unescape(encodeURIComponent(t)),i=new Uint8Array(s.length);for(n=0;n<s.length;n++)i[n]=s.charCodeAt(n);return i},r.encodeUTF8=function(t){var n,s=[];for(n=0;n<t.length;n++)s.push(String.fromCharCode(t[n]));return decodeURIComponent(escape(s.join("")))},typeof atob>"u"?typeof Buffer.from<"u"?(r.encodeBase64=function(t){return Buffer.from(t).toString("base64")},r.decodeBase64=function(t){return e(t),new Uint8Array(Array.prototype.slice.call(Buffer.from(t,"base64"),0))}):(r.encodeBase64=function(t){return new Buffer(t).toString("base64")},r.decodeBase64=function(t){return e(t),new Uint8Array(Array.prototype.slice.call(new Buffer(t,"base64"),0))}):(r.encodeBase64=function(t){var n,s=[],i=t.length;for(n=0;n<i;n++)s.push(String.fromCharCode(t[n]));return btoa(s.join(""))},r.decodeBase64=function(t){e(t);var n,s=atob(t),i=new Uint8Array(s.length);for(n=0;n<s.length;n++)i[n]=s.charCodeAt(n);return i}),r})});var yf=D(Sr=>{"use strict";var Vd=Sr&&Sr.__importDefault||function(r){return r&&r.__esModule?r:{default:r}};Object.defineProperty(Sr,"__esModule",{value:!0});Sr.encrypt=Kd;Sr.decrypt=$d;Sr.encryptBinary=zd;Sr.decryptBinary=Gd;var ar=Vd(So()),br=To();function Kd(r,e,t){let n=ar.default.randomBytes(ar.default.secretbox.nonceLength),s=new TextEncoder().encode(r),i=ar.default.secretbox(s,n,e);return{v:1,sid:t,n:(0,br.encodeBase64)(n),c:(0,br.encodeBase64)(i)}}function $d(r,e){if(r.v!==1)throw new Error(`Unsupported encryption version: ${r.v}`);let t=(0,br.decodeBase64)(r.n),n=(0,br.decodeBase64)(r.c);if(t.length!==ar.default.secretbox.nonceLength)throw new Error(`Invalid nonce length: ${t.length}`);let s=ar.default.secretbox.open(n,t,e);if(!s)throw new Error("Decryption failed: invalid ciphertext or wrong key");return new TextDecoder().decode(s)}function zd(r,e,t){let n=ar.default.randomBytes(ar.default.secretbox.nonceLength),s=ar.default.secretbox(r,n,e);return{v:1,sid:t,n:(0,br.encodeBase64)(n),c:(0,br.encodeBase64)(s)}}function Gd(r,e){if(r.v!==1)throw new Error(`Unsupported encryption version: ${r.v}`);let t=(0,br.decodeBase64)(r.n),n=(0,br.decodeBase64)(r.c),s=ar.default.secretbox.open(n,t,e);if(!s)throw new Error("Decryption failed: invalid ciphertext or wrong key");return s}});var Ef=D(Vt=>{"use strict";var Yd=Vt&&Vt.__importDefault||function(r){return r&&r.__esModule?r:{default:r}};Object.defineProperty(Vt,"__esModule",{value:!0});Vt.generateKeyPair=Xd;Vt.deriveSharedSecret=Jd;Vt.isValidPublicKey=Zd;Vt.clearKey=Qd;Vt.keyToBase64=ep;Vt.base64ToKey=tp;var Zn=Yd(So()),Vr=To();function Xd(){let r=Zn.default.box.keyPair();return{publicKey:(0,Vr.encodeBase64)(r.publicKey),secretKey:(0,Vr.encodeBase64)(r.secretKey)}}function Jd(r,e){let t=(0,Vr.decodeBase64)(r),n=(0,Vr.decodeBase64)(e);if(t.length!==Zn.default.box.publicKeyLength)throw new Error(`Invalid public key length: ${t.length}`);if(n.length!==Zn.default.box.secretKeyLength)throw new Error(`Invalid secret key length: ${n.length}`);return Zn.default.box.before(t,n)}function Zd(r){try{return(0,Vr.decodeBase64)(r).length===Zn.default.box.publicKeyLength}catch{return!1}}function Qd(r){r.fill(0)}function ep(r){return(0,Vr.encodeBase64)(r)}function tp(r){return(0,Vr.decodeBase64)(r)}});var vf=D(De=>{"use strict";Object.defineProperty(De,"__esModule",{value:!0});De.base64ToKey=De.keyToBase64=De.clearKey=De.isValidPublicKey=De.deriveSharedSecret=De.generateKeyPair=De.decryptBinary=De.encryptBinary=De.decrypt=De.encrypt=De.isMultiRecipientPayload=De.isEncryptedPayload=void 0;var wf=_f();Object.defineProperty(De,"isEncryptedPayload",{enumerable:!0,get:function(){return wf.isEncryptedPayload}});Object.defineProperty(De,"isMultiRecipientPayload",{enumerable:!0,get:function(){return wf.isMultiRecipientPayload}});var Gs=yf();Object.defineProperty(De,"encrypt",{enumerable:!0,get:function(){return Gs.encrypt}});Object.defineProperty(De,"decrypt",{enumerable:!0,get:function(){return Gs.decrypt}});Object.defineProperty(De,"encryptBinary",{enumerable:!0,get:function(){return Gs.encryptBinary}});Object.defineProperty(De,"decryptBinary",{enumerable:!0,get:function(){return Gs.decryptBinary}});var En=Ef();Object.defineProperty(De,"generateKeyPair",{enumerable:!0,get:function(){return En.generateKeyPair}});Object.defineProperty(De,"deriveSharedSecret",{enumerable:!0,get:function(){return En.deriveSharedSecret}});Object.defineProperty(De,"isValidPublicKey",{enumerable:!0,get:function(){return En.isValidPublicKey}});Object.defineProperty(De,"clearKey",{enumerable:!0,get:function(){return En.clearKey}});Object.defineProperty(De,"keyToBase64",{enumerable:!0,get:function(){return En.keyToBase64}});Object.defineProperty(De,"base64ToKey",{enumerable:!0,get:function(){return En.base64ToKey}})});var xf=D(vt=>{"use strict";Object.defineProperty(vt,"__esModule",{value:!0});vt.MIN_CLIENT_VERSION=vt.PROTOCOL_VERSION_MINOR=vt.PROTOCOL_VERSION_MAJOR=vt.PROTOCOL_VERSION=void 0;vt.isCompatibleVersion=rp;vt.compareVersions=np;vt.PROTOCOL_VERSION="2.0";vt.PROTOCOL_VERSION_MAJOR=2;vt.PROTOCOL_VERSION_MINOR=0;vt.MIN_CLIENT_VERSION="2.0";function rp(r){let[e]=r.split(".").map(Number);return e===vt.PROTOCOL_VERSION_MAJOR}function np(r,e){let[t,n]=r.split(".").map(Number),[s,i]=e.split(".").map(Number);return t!==s?t<s?-1:1:n!==i?n<i?-1:1:0}});var bf=D(Kt=>{"use strict";Object.defineProperty(Kt,"__esModule",{value:!0});Kt.SERVER_CAPABILITIES=Kt.DEFAULT_CLIENT_CAPABILITIES=Kt.Capability=void 0;Kt.hasCapability=sp;Kt.negotiateCapabilities=ip;var Qn;(function(r){r.FILE_TRANSFER="file-transfer",r.RELIABLE_MESSAGING="reliable-messaging",r.COMPRESSION="compression",r.E2E_ENCRYPTION="e2e-encryption",r.PRIORITY_QUEUES="priority-queues",r.OFFLINE_QUEUE="offline-queue",r.MULTI_DEVICE="multi-device",r.TERMINAL_EVENTS="terminal-events",r.E2E_PRIVACY="e2e-privacy"})(Qn||(Kt.Capability=Qn={}));Kt.DEFAULT_CLIENT_CAPABILITIES=[Qn.E2E_ENCRYPTION,Qn.TERMINAL_EVENTS];Kt.SERVER_CAPABILITIES=Object.values(Qn);function sp(r,e){return r.includes(e)}function ip(r,e){return r.filter(t=>e.includes(t))}});var Sf=D(cr=>{"use strict";Object.defineProperty(cr,"__esModule",{value:!0});cr.DEFAULT_PRIORITY=cr.PRIORITY_NAMES=cr.Priority=void 0;cr.comparePriority=op;var Kr;(function(r){r[r.CRITICAL=0]="CRITICAL",r[r.HIGH=1]="HIGH",r[r.NORMAL=2]="NORMAL",r[r.LOW=3]="LOW"})(Kr||(cr.Priority=Kr={}));cr.PRIORITY_NAMES={[Kr.CRITICAL]:"CRITICAL",[Kr.HIGH]:"HIGH",[Kr.NORMAL]:"NORMAL",[Kr.LOW]:"LOW"};cr.DEFAULT_PRIORITY=Kr.NORMAL;function op(r,e){return r-e}});var Tf=D($t=>{"use strict";Object.defineProperty($t,"__esModule",{value:!0});$t.DEFAULT_RELIABILITY=$t.RELIABILITY_NAMES=$t.Reliability=void 0;$t.requiresAck=ap;$t.requiresBuffer=cp;var Tr;(function(r){r[r.FIRE_FORGET=0]="FIRE_FORGET",r[r.BUFFERED=1]="BUFFERED",r[r.GUARANTEED=2]="GUARANTEED"})(Tr||($t.Reliability=Tr={}));$t.RELIABILITY_NAMES={[Tr.FIRE_FORGET]:"FIRE_FORGET",[Tr.BUFFERED]:"BUFFERED",[Tr.GUARANTEED]:"GUARANTEED"};$t.DEFAULT_RELIABILITY=Tr.FIRE_FORGET;function ap(r){return r===Tr.GUARANTEED}function cp(r){return r>=Tr.BUFFERED}});var Of=D(Oo=>{"use strict";Object.defineProperty(Oo,"__esModule",{value:!0});Oo.createMessage=fp;function fp(r,e,t={}){return{id:crypto.randomUUID(),type:r,payload:e,priority:t.priority??2,reliability:t.reliability??0,seq:t.seq,timestamp:new Date().toISOString()}}});var Cf=D($r=>{"use strict";Object.defineProperty($r,"__esModule",{value:!0});$r.TerminalEventType=void 0;$r.deriveStatusFromEvent=up;$r.shouldTriggerPushNotification=lp;$r.getPushNotificationMessage=hp;var lt;(function(r){r.SESSION_START="session_start",r.SESSION_END="session_end",r.MESSAGE="message",r.TOOL_START="tool_start",r.TOOL_END="tool_end",r.WAITING_INPUT="waiting_input",r.ERROR="error"})(lt||($r.TerminalEventType=lt={}));function up(r){switch(r.type){case lt.SESSION_START:case lt.TOOL_START:case lt.MESSAGE:return"working";case lt.WAITING_INPUT:return"waiting";case lt.SESSION_END:return r.status==="success"?"completed":"error";case lt.ERROR:return r.severity==="fatal"?"error":"working";case lt.TOOL_END:return r.status==="error"?"error":"working";default:return"idle"}}function lp(r){switch(r.type){case lt.WAITING_INPUT:return!0;case lt.SESSION_END:return!0;case lt.ERROR:return r.severity!=="warning";default:return!1}}function hp(r,e){switch(r.type){case lt.WAITING_INPUT:return{title:`${e}: Input Required`,body:r.question.slice(0,100)};case lt.SESSION_END:{let t=r;return t.status==="success"?{title:`${e}: Task Completed`,body:t.summary||"Session finished successfully"}:{title:`${e}: Task Failed`,body:t.summary||"Session ended with error"}}case lt.ERROR:{let t=r;return t.severity==="warning"?null:{title:`${e}: Error`,body:t.message.slice(0,100)}}default:return null}}});var Rf=D(je=>{"use strict";Object.defineProperty(je,"__esModule",{value:!0});je.TransferDirection=je.TransferStatus=je.CHUNK_TTL_SECONDS=je.TRANSFER_TTL_SECONDS=je.MAX_RETRIES=je.ACK_TIMEOUT_MS=je.WINDOW_SIZE=je.DEFAULT_MAX_FILE_SIZE=je.CHUNK_SIZE=void 0;je.calculateTotalChunks=dp;je.getMissingChunks=pp;je.isTransferComplete=gp;je.CHUNK_SIZE=64*1024;je.DEFAULT_MAX_FILE_SIZE=100*1024*1024;je.WINDOW_SIZE=10;je.ACK_TIMEOUT_MS=3e4;je.MAX_RETRIES=3;je.TRANSFER_TTL_SECONDS=1440*60;je.CHUNK_TTL_SECONDS=1440*60;var kf;(function(r){r.PENDING="pending",r.ACTIVE="active",r.PAUSED="paused",r.COMPLETED="completed",r.FAILED="failed",r.CANCELLED="cancelled",r.EXPIRED="expired"})(kf||(je.TransferStatus=kf={}));var Pf;(function(r){r.DOWNLOAD="download",r.UPLOAD="upload"})(Pf||(je.TransferDirection=Pf={}));function dp(r,e=je.CHUNK_SIZE){return Math.ceil(r/e)}function pp(r,e){let t=new Set(e),n=[];for(let s=0;s<r;s++)t.has(s)||n.push(s);return n}function gp(r,e){return e.length===r}});var Af=D(fr=>{"use strict";Object.defineProperty(fr,"__esModule",{value:!0});fr.ERROR_MESSAGES=fr.ErrorCode=void 0;fr.createError=_p;fr.isRetryableError=mp;var ke;(function(r){r.AUTH_FAILED="E001",r.TOKEN_EXPIRED="E002",r.TOKEN_INVALID="E003",r.NOT_FOUND="E011",r.ALREADY_EXISTS="E012",r.ACCESS_DENIED="E021",r.FORBIDDEN="E022",r.RATE_LIMITED="E031",r.TOO_MANY_CONNECTIONS="E032",r.QUOTA_EXCEEDED="E041",r.FILE_TOO_LARGE="E042",r.QUEUE_FULL="E043",r.TRANSFERS_LIMIT="E044",r.TRANSFER_FAILED="E051",r.TRANSFER_EXPIRED="E052",r.TRANSFER_CANCELLED="E053",r.CHECKSUM_MISMATCH="E054",r.CHUNK_MISSING="E055",r.INVALID_MESSAGE="E061",r.UNSUPPORTED_VERSION="E062",r.CAPABILITY_REQUIRED="E063",r.INVALID_STATE="E071",r.TIMEOUT="E072",r.CONNECTION_LOST="E073",r.INTERNAL_ERROR="E091",r.SERVICE_UNAVAILABLE="E092"})(ke||(fr.ErrorCode=ke={}));fr.ERROR_MESSAGES={[ke.AUTH_FAILED]:"Authentication failed",[ke.TOKEN_EXPIRED]:"Token expired",[ke.TOKEN_INVALID]:"Invalid token",[ke.NOT_FOUND]:"Resource not found",[ke.ALREADY_EXISTS]:"Resource already exists",[ke.ACCESS_DENIED]:"Access denied",[ke.FORBIDDEN]:"Operation forbidden",[ke.RATE_LIMITED]:"Rate limit exceeded",[ke.TOO_MANY_CONNECTIONS]:"Too many connections",[ke.QUOTA_EXCEEDED]:"Plan quota exceeded",[ke.FILE_TOO_LARGE]:"File size exceeds limit",[ke.QUEUE_FULL]:"Message queue is full",[ke.TRANSFERS_LIMIT]:"Daily transfers limit reached",[ke.TRANSFER_FAILED]:"File transfer failed",[ke.TRANSFER_EXPIRED]:"Transfer expired",[ke.TRANSFER_CANCELLED]:"Transfer cancelled",[ke.CHECKSUM_MISMATCH]:"File checksum mismatch",[ke.CHUNK_MISSING]:"Chunk missing or corrupted",[ke.INVALID_MESSAGE]:"Invalid message format",[ke.UNSUPPORTED_VERSION]:"Unsupported protocol version",[ke.CAPABILITY_REQUIRED]:"Required capability not supported",[ke.INVALID_STATE]:"Invalid state for this operation",[ke.TIMEOUT]:"Operation timed out",[ke.CONNECTION_LOST]:"Connection lost",[ke.INTERNAL_ERROR]:"Internal server error",[ke.SERVICE_UNAVAILABLE]:"Service temporarily unavailable"};function _p(r,e={}){return{code:r,message:e.message||fr.ERROR_MESSAGES[r],details:e.details,retryable:e.retryable??!1,retryAfter:e.retryAfter}}function mp(r){return[ke.RATE_LIMITED,ke.TIMEOUT,ke.CONNECTION_LOST,ke.SERVICE_UNAVAILABLE].includes(r)}});var Df=D(xt=>{"use strict";Object.defineProperty(xt,"__esModule",{value:!0});xt.FileEntryType=xt.DiffBase=xt.FileViewType=xt.FileChangeType=void 0;xt.getLanguageFromPath=yp;xt.parseUnifiedDiff=Ep;xt.createSimpleDiff=wp;var Or;(function(r){r.CREATE="create",r.MODIFY="modify",r.DELETE="delete"})(Or||(xt.FileChangeType=Or={}));var If;(function(r){r.CONTENT="content",r.DIFF="diff"})(If||(xt.FileViewType=If={}));var Lf;(function(r){r.GIT="git",r.PREVIOUS="previous"})(Lf||(xt.DiffBase=Lf={}));function yp(r){let e=r.split(".").pop()?.toLowerCase(),t={js:"javascript",jsx:"javascript",ts:"typescript",tsx:"typescript",mjs:"javascript",cjs:"javascript",html:"html",htm:"html",css:"css",scss:"scss",sass:"scss",less:"less",json:"json",yaml:"yaml",yml:"yaml",xml:"xml",toml:"toml",md:"markdown",mdx:"markdown",env:"plaintext",gitignore:"plaintext",dockerignore:"plaintext",sh:"bash",bash:"bash",zsh:"bash",fish:"bash",py:"python",pyw:"python",pyi:"python",go:"go",rs:"rust",java:"java",kt:"kotlin",kts:"kotlin",c:"c",h:"c",cpp:"cpp",cc:"cpp",cxx:"cpp",hpp:"cpp",sql:"sql",graphql:"graphql",gql:"graphql",prisma:"prisma",dockerfile:"dockerfile"},n=r.split("/").pop()?.toLowerCase()||"";return{dockerfile:"dockerfile",makefile:"makefile",".gitignore":"plaintext",".env":"plaintext",".env.local":"plaintext",".env.development":"plaintext",".env.production":"plaintext"}[n]||t[e||""]||"plaintext"}function Ep(r,e){let t=r.split(`
|
|
3
|
+
`),n=[],s=0,i=0,a=null,f=0,u=0;for(let g of t){if(g.startsWith("diff ")||g.startsWith("index ")||g.startsWith("---")||g.startsWith("+++"))continue;let _=g.match(/^@@ -(\d+),?(\d*) \+(\d+),?(\d*) @@/);if(_){a&&n.push(a);let y=parseInt(_[1],10),v=parseInt(_[2]||"1",10),S=parseInt(_[3],10),C=parseInt(_[4]||"1",10);a={oldStart:y,oldLines:v,newStart:S,newLines:C,lines:[]},f=y,u=S;continue}a&&(g.startsWith("+")?(a.lines.push({type:"add",content:g.slice(1),oldLineNumber:null,newLineNumber:u++}),s++):g.startsWith("-")?(a.lines.push({type:"remove",content:g.slice(1),oldLineNumber:f++,newLineNumber:null}),i++):(g.startsWith(" ")||g==="")&&a.lines.push({type:"context",content:g.startsWith(" ")?g.slice(1):g,oldLineNumber:f++,newLineNumber:u++}))}a&&n.push(a);let d;return i===0&&s>0&&n.length===1&&n[0].oldLines===0?d=Or.CREATE:s===0&&i>0&&n.length===1&&n[0].newLines===0?d=Or.DELETE:d=Or.MODIFY,{path:e,changeType:d,hunks:n,additions:s,deletions:i,isBinary:!1}}function wp(r,e,t){let n=r.split(`
|
|
6
4
|
`),s=e.split(`
|
|
7
|
-
`),i=[],a=0,f=0,u=Math.max(n.length,s.length);for(let g=0;g<u;g++){let _=n[g],y=s[g];_===y?_!==void 0&&i.push({type:"context",content:_,oldLineNumber:g+1,newLineNumber:g+1}):(_!==void 0&&(i.push({type:"remove",content:_,oldLineNumber:g+1,newLineNumber:null}),f++),y!==void 0&&(i.push({type:"add",content:y,oldLineNumber:null,newLineNumber:g+1}),a++))}let d;return r===""?d=Cr.CREATE:e===""?d=Cr.DELETE:d=Cr.MODIFY,{path:t,changeType:d,hunks:[{oldStart:1,oldLines:n.length,newStart:1,newLines:s.length,lines:i}],additions:a,deletions:f,isBinary:!1}}var Qf;(function(r){r.FILE="file",r.DIRECTORY="directory"})(Qf||(wt.FileEntryType=Qf={}))});var tu=F(I=>{"use strict";Object.defineProperty(I,"__esModule",{value:!0});I.createSimpleDiff=I.parseUnifiedDiff=I.getLanguageFromPath=I.FileEntryType=I.DiffBase=I.FileViewType=I.FileChangeType=I.isRetryableError=I.createError=I.ERROR_MESSAGES=I.ErrorCode=I.isTransferComplete=I.getMissingChunks=I.calculateTotalChunks=I.TransferDirection=I.TransferStatus=I.CHUNK_TTL_SECONDS=I.TRANSFER_TTL_SECONDS=I.MAX_RETRIES=I.ACK_TIMEOUT_MS=I.WINDOW_SIZE=I.DEFAULT_MAX_FILE_SIZE=I.CHUNK_SIZE=I.getPushNotificationMessage=I.shouldTriggerPushNotification=I.deriveStatusFromEvent=I.TerminalEventType=I.createMessage=I.requiresBuffer=I.requiresAck=I.DEFAULT_RELIABILITY=I.RELIABILITY_NAMES=I.Reliability=I.comparePriority=I.DEFAULT_PRIORITY=I.PRIORITY_NAMES=I.Priority=I.negotiateCapabilities=I.hasCapability=I.SERVER_CAPABILITIES=I.DEFAULT_CLIENT_CAPABILITIES=I.Capability=I.compareVersions=I.isCompatibleVersion=I.MIN_CLIENT_VERSION=I.PROTOCOL_VERSION_MINOR=I.PROTOCOL_VERSION_MAJOR=I.PROTOCOL_VERSION=void 0;var yn=qf();Object.defineProperty(I,"PROTOCOL_VERSION",{enumerable:!0,get:function(){return yn.PROTOCOL_VERSION}});Object.defineProperty(I,"PROTOCOL_VERSION_MAJOR",{enumerable:!0,get:function(){return yn.PROTOCOL_VERSION_MAJOR}});Object.defineProperty(I,"PROTOCOL_VERSION_MINOR",{enumerable:!0,get:function(){return yn.PROTOCOL_VERSION_MINOR}});Object.defineProperty(I,"MIN_CLIENT_VERSION",{enumerable:!0,get:function(){return yn.MIN_CLIENT_VERSION}});Object.defineProperty(I,"isCompatibleVersion",{enumerable:!0,get:function(){return yn.isCompatibleVersion}});Object.defineProperty(I,"compareVersions",{enumerable:!0,get:function(){return yn.compareVersions}});var ns=Wf();Object.defineProperty(I,"Capability",{enumerable:!0,get:function(){return ns.Capability}});Object.defineProperty(I,"DEFAULT_CLIENT_CAPABILITIES",{enumerable:!0,get:function(){return ns.DEFAULT_CLIENT_CAPABILITIES}});Object.defineProperty(I,"SERVER_CAPABILITIES",{enumerable:!0,get:function(){return ns.SERVER_CAPABILITIES}});Object.defineProperty(I,"hasCapability",{enumerable:!0,get:function(){return ns.hasCapability}});Object.defineProperty(I,"negotiateCapabilities",{enumerable:!0,get:function(){return ns.negotiateCapabilities}});var Gs=Hf();Object.defineProperty(I,"Priority",{enumerable:!0,get:function(){return Gs.Priority}});Object.defineProperty(I,"PRIORITY_NAMES",{enumerable:!0,get:function(){return Gs.PRIORITY_NAMES}});Object.defineProperty(I,"DEFAULT_PRIORITY",{enumerable:!0,get:function(){return Gs.DEFAULT_PRIORITY}});Object.defineProperty(I,"comparePriority",{enumerable:!0,get:function(){return Gs.comparePriority}});var ss=Vf();Object.defineProperty(I,"Reliability",{enumerable:!0,get:function(){return ss.Reliability}});Object.defineProperty(I,"RELIABILITY_NAMES",{enumerable:!0,get:function(){return ss.RELIABILITY_NAMES}});Object.defineProperty(I,"DEFAULT_RELIABILITY",{enumerable:!0,get:function(){return ss.DEFAULT_RELIABILITY}});Object.defineProperty(I,"requiresAck",{enumerable:!0,get:function(){return ss.requiresAck}});Object.defineProperty(I,"requiresBuffer",{enumerable:!0,get:function(){return ss.requiresBuffer}});var wp=Kf();Object.defineProperty(I,"createMessage",{enumerable:!0,get:function(){return wp.createMessage}});var Ys=$f();Object.defineProperty(I,"TerminalEventType",{enumerable:!0,get:function(){return Ys.TerminalEventType}});Object.defineProperty(I,"deriveStatusFromEvent",{enumerable:!0,get:function(){return Ys.deriveStatusFromEvent}});Object.defineProperty(I,"shouldTriggerPushNotification",{enumerable:!0,get:function(){return Ys.shouldTriggerPushNotification}});Object.defineProperty(I,"getPushNotificationMessage",{enumerable:!0,get:function(){return Ys.getPushNotificationMessage}});var Tt=Yf();Object.defineProperty(I,"CHUNK_SIZE",{enumerable:!0,get:function(){return Tt.CHUNK_SIZE}});Object.defineProperty(I,"DEFAULT_MAX_FILE_SIZE",{enumerable:!0,get:function(){return Tt.DEFAULT_MAX_FILE_SIZE}});Object.defineProperty(I,"WINDOW_SIZE",{enumerable:!0,get:function(){return Tt.WINDOW_SIZE}});Object.defineProperty(I,"ACK_TIMEOUT_MS",{enumerable:!0,get:function(){return Tt.ACK_TIMEOUT_MS}});Object.defineProperty(I,"MAX_RETRIES",{enumerable:!0,get:function(){return Tt.MAX_RETRIES}});Object.defineProperty(I,"TRANSFER_TTL_SECONDS",{enumerable:!0,get:function(){return Tt.TRANSFER_TTL_SECONDS}});Object.defineProperty(I,"CHUNK_TTL_SECONDS",{enumerable:!0,get:function(){return Tt.CHUNK_TTL_SECONDS}});Object.defineProperty(I,"TransferStatus",{enumerable:!0,get:function(){return Tt.TransferStatus}});Object.defineProperty(I,"TransferDirection",{enumerable:!0,get:function(){return Tt.TransferDirection}});Object.defineProperty(I,"calculateTotalChunks",{enumerable:!0,get:function(){return Tt.calculateTotalChunks}});Object.defineProperty(I,"getMissingChunks",{enumerable:!0,get:function(){return Tt.getMissingChunks}});Object.defineProperty(I,"isTransferComplete",{enumerable:!0,get:function(){return Tt.isTransferComplete}});var Xs=Xf();Object.defineProperty(I,"ErrorCode",{enumerable:!0,get:function(){return Xs.ErrorCode}});Object.defineProperty(I,"ERROR_MESSAGES",{enumerable:!0,get:function(){return Xs.ERROR_MESSAGES}});Object.defineProperty(I,"createError",{enumerable:!0,get:function(){return Xs.createError}});Object.defineProperty(I,"isRetryableError",{enumerable:!0,get:function(){return Xs.isRetryableError}});var Vr=eu();Object.defineProperty(I,"FileChangeType",{enumerable:!0,get:function(){return Vr.FileChangeType}});Object.defineProperty(I,"FileViewType",{enumerable:!0,get:function(){return Vr.FileViewType}});Object.defineProperty(I,"DiffBase",{enumerable:!0,get:function(){return Vr.DiffBase}});Object.defineProperty(I,"FileEntryType",{enumerable:!0,get:function(){return Vr.FileEntryType}});Object.defineProperty(I,"getLanguageFromPath",{enumerable:!0,get:function(){return Vr.getLanguageFromPath}});Object.defineProperty(I,"parseUnifiedDiff",{enumerable:!0,get:function(){return Vr.parseUnifiedDiff}});Object.defineProperty(I,"createSimpleDiff",{enumerable:!0,get:function(){return Vr.createSimpleDiff}})});var Kr=F($t=>{"use strict";var xp=$t&&$t.__createBinding||(Object.create?(function(r,e,t,n){n===void 0&&(n=t);var s=Object.getOwnPropertyDescriptor(e,t);(!s||("get"in s?!e.__esModule:s.writable||s.configurable))&&(s={enumerable:!0,get:function(){return e[t]}}),Object.defineProperty(r,n,s)}):(function(r,e,t,n){n===void 0&&(n=t),r[n]=e[t]})),Js=$t&&$t.__exportStar||function(r,e){for(var t in r)t!=="default"&&!Object.prototype.hasOwnProperty.call(e,t)&&xp(e,r,t)};Object.defineProperty($t,"__esModule",{value:!0});Js(Nf(),$t);Js(Lf(),$t);Js(Uf(),$t);Js(tu(),$t)});var nu=F(Zs=>{"use strict";Object.defineProperty(Zs,"__esModule",{value:!0});Zs.CryptoService=void 0;var at=Kr(),vp=3600*1e3,ru=10,Ho=class{storage;logger;sessions=new Map;agentSessions=new Map;keyPair=null;publicKeyKey;secretKeyKey;keyVersionKey;constructor(e,t,n,s){this.storage=e,this.logger=t;let i=`termiq.${n}.${s}`;this.publicKeyKey=`${i}.crypto.publicKey`,this.secretKeyKey=`${i}.crypto.secretKey`,this.keyVersionKey=`${i}.crypto.keyVersion`,this.logger.info("CryptoService namespace",n,s)}async initialize(){let e=await this.storage.get(this.publicKeyKey),t=await this.storage.get(this.secretKeyKey);e&&t?(this.keyPair={publicKey:e,secretKey:t},this.logger.info("Loaded existing identity key pair")):await this.generateIdentityKeyPair()}async generateIdentityKeyPair(){this.logger.info("Generating new identity key pair"),this.keyPair=(0,at.generateKeyPair)(),await this.storage.set(this.publicKeyKey,this.keyPair.publicKey),await this.storage.set(this.secretKeyKey,this.keyPair.secretKey);let e=await this.getKeyVersion();return await this.storage.set(this.keyVersionKey,String(e+1)),this.logger.info("Identity key pair generated and stored"),this.keyPair}async getPublicKey(){return this.keyPair?this.keyPair.publicKey:await this.storage.get(this.publicKeyKey)||null}async getKeyVersion(){let e=await this.storage.get(this.keyVersionKey);return e?parseInt(e,10):1}async handleKeyExchange(e,t,n){if(!this.keyPair&&(this.logger.warn("Key pair missing, attempting re-initialization"),await this.initialize(),!this.keyPair))return this.logger.error("No identity key pair available after re-initialization"),!1;this.logger.info("Starting key exchange",e,n);try{let s=this.sessions.get(e);s||(s=new Map,this.sessions.set(e,s));let i=(0,at.deriveSharedSecret)(t,this.keyPair.secretKey),a={terminalId:e,clientPublicKey:t,sharedSecret:i,createdAt:Date.now(),sessionId:n};return s.set(n,a),this.logger.info("Key exchange completed",e,n,"total:",s.size),!0}catch(s){return this.logger.error("Key exchange failed",s),!1}}encryptOutput(e,t){let n=this.sessions.get(e);if(!n||n.size===0)return null;try{if(n.size===1){let i=n.values().next().value;return i?(0,at.encrypt)(t,i.sharedSecret,i.sessionId):null}let s=[];for(let i of n.values()){let a=(0,at.encrypt)(t,i.sharedSecret,i.sessionId);s.push({sid:a.sid,n:a.n,c:a.c})}return{v:2,recipients:s}}catch(s){return this.logger.error("Encryption failed",s),null}}decryptInput(e,t){let n=this.sessions.get(e);if(!n)return this.logger.error("No sessions for terminal",e),null;let s=n.get(t.sid);if(!s)return this.logger.error("No session for sessionId",t.sid),null;try{return(0,at.decrypt)(t,s.sharedSecret)}catch(i){return this.logger.error("Decryption failed",i),null}}hasSession(e){let t=this.sessions.get(e);return t!==void 0&&t.size>0}removeSession(e,t){let n=this.sessions.get(e);if(n)if(t){let s=n.get(t);s&&((0,at.clearKey)(s.sharedSecret),n.delete(t),this.logger.info("Session removed",e,t)),n.size===0&&this.sessions.delete(e)}else{for(let s of n.values())(0,at.clearKey)(s.sharedSecret);this.sessions.delete(e),this.logger.debug("All sessions removed for terminal",e)}}clearAllSessions(){for(let e of this.sessions.values())for(let t of e.values())(0,at.clearKey)(t.sharedSecret);this.sessions.clear(),this.logger.debug("All sessions cleared")}cleanupStaleSessions(e){let t=this.sessions.get(e);if(!t||t.size===0)return;let n=Date.now(),s=[];for(let[i,a]of t)n-a.createdAt>vp&&s.push(i);for(let i of s){let a=t.get(i);a&&((0,at.clearKey)(a.sharedSecret),t.delete(i))}if(t.size>ru){let a=Array.from(t.entries()).sort((f,u)=>f[1].createdAt-u[1].createdAt).slice(0,t.size-ru);for(let[,f]of a)(0,at.clearKey)(f.sharedSecret),t.delete(f.sessionId)}t.size===0&&this.sessions.delete(e)}cleanupAllStaleSessions(){for(let e of this.sessions.keys())this.cleanupStaleSessions(e)}getSessionInfo(){let e=[];for(let[t,n]of this.sessions.entries())for(let s of n.values())e.push({terminalId:t,createdAt:s.createdAt,sessionId:s.sessionId});return e}async handleAgentKeyExchange(e,t){if(!this.keyPair&&(this.logger.warn("Key pair missing for agent key exchange"),await this.initialize(),!this.keyPair))return this.logger.error("No identity key pair available for agent key exchange"),!1;try{let n=this.agentSessions.get(t);n&&(this.logger.info("Rekeying existing agent session",t),(0,at.clearKey)(n.sharedSecret));let s=(0,at.deriveSharedSecret)(e,this.keyPair.secretKey),i={sessionId:t,clientPublicKey:e,sharedSecret:s,createdAt:Date.now()};return this.agentSessions.set(t,i),this.logger.info("Agent key exchange completed",t,"total:",this.agentSessions.size),!0}catch(n){return this.logger.error("Agent key exchange failed",n),!1}}removeAgentSession(e){let t=this.agentSessions.get(e);t&&((0,at.clearKey)(t.sharedSecret),this.agentSessions.delete(e),this.logger.info("Agent session removed",e))}hasAgentSessions(){return this.agentSessions.size>0}encryptWorkspaceInfo(e){if(this.agentSessions.size===0)return null;let t=JSON.stringify(e),n=this.encryptForAllAgentSessions(t);return n?{encrypted:n}:null}encryptTerminalInfo(e){if(this.agentSessions.size===0)return null;let t=JSON.stringify(e),n=this.encryptForAllAgentSessions(t);return n?{encrypted:n}:null}encryptPromptInfo(e){if(this.agentSessions.size===0)return null;let t=JSON.stringify(e),n=this.encryptForAllAgentSessions(t);return n?{encrypted:n}:null}encryptForAllAgentSessions(e){if(this.agentSessions.size===0)return null;try{if(this.agentSessions.size===1){let n=this.agentSessions.values().next().value;return n?(0,at.encrypt)(e,n.sharedSecret,n.sessionId):null}let t=[];for(let n of this.agentSessions.values()){let s=(0,at.encrypt)(e,n.sharedSecret,n.sessionId);t.push({sid:s.sid,n:s.n,c:s.c})}return{v:2,recipients:t}}catch(t){return this.logger.error("Encryption for agent sessions failed",t),null}}clearAllAgentSessions(){for(let e of this.agentSessions.values())(0,at.clearKey)(e.sharedSecret);this.agentSessions.clear(),this.logger.debug("All agent sessions cleared")}async deleteKeys(){await this.storage.delete(this.publicKeyKey),await this.storage.delete(this.secretKeyKey),await this.storage.delete(this.keyVersionKey),this.keyPair=null,this.clearAllSessions(),this.clearAllAgentSessions(),this.logger.info("All crypto keys deleted")}};Zs.CryptoService=Ho});var su=F(Qs=>{"use strict";Object.defineProperty(Qs,"__esModule",{value:!0});Qs.AuthService=void 0;var is=qs(),Vo=class{storage;cryptoService;machineId;config;logger;notification;browser;pollingAbortController=null;tokenKey;refreshTokenKey;agentIdKey;constructor(e,t,n,s,i,a,f,u,d){this.storage=e,this.cryptoService=t,this.machineId=n,this.config=s,this.logger=i,this.notification=a,this.browser=f;let g=`termiq.${u}.${d}`;this.tokenKey=`${g}.accessToken`,this.refreshTokenKey=`${g}.refreshToken`,this.agentIdKey=`${g}.agentId`,this.logger.info("AuthService namespace",u,d)}cancelPolling(){this.pollingAbortController&&(this.logger.info("Cancelling active polling"),this.pollingAbortController.abort(),this.pollingAbortController=null)}async startDeviceCodeFlow(){this.cancelPolling();let e=(0,is.getApiUrl)(this.config),t=await this.machineId.getMachineId(),n=this.machineId.getMachineName(),s=await this.cryptoService.getPublicKey();s||(await this.cryptoService.generateIdentityKeyPair(),s=await this.cryptoService.getPublicKey()),this.logger.info("Starting device code flow",t,n);let i=await fetch(`${e}/auth/device/code`,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({machineId:t,machineName:n,publicKey:s})});if(!i.ok){let a=await i.text();throw new Error(`Failed to get device code: ${a}`)}return i.json()}async pollForToken(e){this.cancelPolling();let t=(0,is.getApiUrl)(this.config),n=5e3,s=60;this.pollingAbortController=new AbortController;let i=this.pollingAbortController.signal;this.logger.info("Starting token polling");for(let a=0;a<s;a++){if(i.aborted)return this.logger.info("Polling was cancelled"),null;if(await this.sleep(n),i.aborted)return this.logger.info("Polling was cancelled"),null;try{let f=await fetch(`${t}/auth/device/poll`,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({deviceCode:e}),signal:i});if(!f.ok){if(f.status===403)try{let d=await f.json();if(d.error==="AGENT_LIMIT_EXCEEDED")return this.logger.warn("Agent limit exceeded",String(d.current),"/",String(d.max)),this.notification.warn(`Agent limit reached (${d.current}/${d.max}). Upgrade your plan to add more devices.`),null}catch{}this.logger.warn("Poll request failed",String(f.status));continue}let u=await f.json();if(u.status==="success"&&u.accessToken)return this.logger.info("Token received successfully"),this.pollingAbortController=null,await this.saveTokens(u),u;if(u.status==="expired")return this.logger.warn("Device code expired"),null;if(u.status==="limit_exceeded")return this.logger.warn("Agent limit exceeded",String(u.current),"/",String(u.max)),this.notification.warn(`Agent limit reached (${u.current}/${u.max}). Remove an old agent or upgrade your plan.`),null;this.logger.debug("Token pending, continuing poll",String(a))}catch(f){if(i.aborted)return this.logger.info("Polling was cancelled"),null;let u=f instanceof Error?f.message:String(f);this.logger.warn(`Poll error: ${u}`)}}return this.logger.warn("Polling timed out"),this.pollingAbortController=null,null}async loginWithApiKey(e){let t=(0,is.getApiUrl)(this.config),n=await this.machineId.getMachineId(),s=this.machineId.getMachineName(),i=await this.cryptoService.getPublicKey();i||(await this.cryptoService.generateIdentityKeyPair(),i=await this.cryptoService.getPublicKey()),this.logger.info("Logging in with API key");try{let a=await fetch(`${t}/auth/api-key/login`,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({apiKey:e,machineId:n,machineName:s,publicKey:i})});if(!a.ok){let u=await a.text();return this.logger.error("API key login failed",u),!1}let f=await a.json();return f.accessToken?(await this.saveTokens(f),this.logger.info("API key login successful"),!0):!1}catch(a){return this.logger.error("API key login error",a),!1}}async hasValidToken(){let e=await this.storage.get(this.tokenKey);if(!e)return!1;try{let n=JSON.parse(Buffer.from(e.split(".")[1],"base64").toString()).exp*1e3;return Date.now()<n}catch{return!1}}async getAccessToken(){return await this.storage.get(this.tokenKey)||null}async getAgentId(){return await this.storage.get(this.agentIdKey)||null}async refreshAccessToken(){let e=await this.storage.get(this.refreshTokenKey);if(!e)return this.logger.debug("No refresh token available"),null;let t=(0,is.getApiUrl)(this.config);try{this.logger.info("Refreshing access token");let n=await fetch(`${t}/auth/refresh`,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({refreshToken:e})});if(!n.ok)return this.logger.warn("Token refresh failed",String(n.status)),n.status===401&&await this.storage.delete(this.refreshTokenKey),null;let s=await n.json();return await this.storage.set(this.tokenKey,s.accessToken),await this.storage.set(this.refreshTokenKey,s.refreshToken),this.logger.info("Access token refreshed successfully"),s.accessToken}catch(n){return this.logger.warn("Token refresh error",n),null}}async logout(){this.logger.info("Logging out"),this.cancelPolling(),await this.storage.delete(this.tokenKey),await this.storage.delete(this.refreshTokenKey),await this.storage.delete(this.agentIdKey),await this.cryptoService.deleteKeys()}async saveTokens(e){e.accessToken&&await this.storage.set(this.tokenKey,e.accessToken),e.refreshToken&&await this.storage.set(this.refreshTokenKey,e.refreshToken),e.agentId&&await this.storage.set(this.agentIdKey,e.agentId)}async getLimits(){let e=await this.getAccessToken();if(!e)return this.logger.warn("Cannot fetch limits: no access token"),null;let t=(0,is.getApiUrl)(this.config);try{let n=await fetch(`${t}/users/me/limits`,{headers:{Authorization:`Bearer ${e}`,"Content-Type":"application/json"}});return n.ok?await n.json():(this.logger.error("Failed to fetch limits",String(n.status)),null)}catch(n){let s=n instanceof Error?n.message:String(n);return this.logger.error(`Error fetching limits: ${s}`),null}}async openUrl(e){await this.browser.openUrl(e)}async canCreateTerminal(){let e=await this.getLimits();return e?e.terminals.unlimited?{allowed:!0,limits:e}:e.terminals.current>=e.terminals.max?{allowed:!1,reason:`Terminal limit reached (${e.terminals.current}/${e.terminals.max}). Upgrade your plan to create more terminals.`,limits:e}:{allowed:!0,limits:e}:{allowed:!0}}sleep(e){return new Promise(t=>setTimeout(t,e))}};Qs.AuthService=Vo});var iu=F(ti=>{"use strict";Object.defineProperty(ti,"__esModule",{value:!0});ti.StatusDetector=void 0;var ei={working:[/✶/,/⠋|⠙|⠹|⠸|⠼|⠴|⠦|⠧|⠇|⠏/],idle:[/[❯$#>]\s*$/,/^\s*\d+\s*[❯$#>]\s*$/,/\(base\)\s*[❯$#>]\s*$/,/\)\s*[❯$#>]\s*$/],waiting:[/\[Y\/n\]/i,/\[y\/N\]/i,/\(y\/n\)/i,/\(yes\/no\)/i,/Continue\?/i,/Proceed\?/i,/Are you sure\?/i,/Confirm\?/i,/Press Enter to continue/i,/Press any key/i,/\[Enter\]/i,/Do you want to/i,/Would you like to/i,/Shall I/i,/^\s*\d+[.)]\s+.+$/m,/Select.*:/i,/Choose.*:/i,/Which.*\?/i,/Какой вариант/i,/Выберите/i],completed:[/✓\s*(Done|Complete|Success|Finished)/i,/\[done\]/i,/\[success\]/i,/completed successfully/i,/Build succeeded/i,/All tests passed/i],error:[/✕\s*(Error|Failed|Failure)/i,/\[error\]/i,/\[failed\]/i,/Error:/i,/Exception:/i,/FATAL:/i,/Build failed/i,/Tests failed/i,/command not found/i,/Permission denied/i,/No such file or directory/i]},os={IDLE_TIMEOUT_MS:5e3,DEBOUNCE_MS:500,BUFFER_SIZE:2e3,WORKING_TIMEOUT_MS:3e4},Ko=class{states=new Map;onStatusChange;constructor(e){this.onStatusChange=e}startTracking(e){if(this.states.has(e))return;let t={status:"idle",lastUpdate:Date.now(),lastOutput:Date.now(),outputBuffer:"",pendingUpdate:null,workingTimeout:null};this.states.set(e,t),this.emitStatus(e,"idle")}stopTracking(e){let t=this.states.get(e);t&&(t.pendingUpdate&&clearTimeout(t.pendingUpdate),t.workingTimeout&&clearTimeout(t.workingTimeout)),this.states.delete(e)}processOutput(e,t){let n=this.states.get(e);if(!n)return;n.lastOutput=Date.now(),n.outputBuffer+=t,n.outputBuffer.length>os.BUFFER_SIZE&&(n.outputBuffer=n.outputBuffer.slice(-os.BUFFER_SIZE));let s=this.analyzeOutput(n.outputBuffer);s&&this.scheduleStatusUpdate(e,s),this.resetWorkingTimeout(e,n)}onCommandStart(e){let t=this.states.get(e);t&&(t.outputBuffer="",this.scheduleStatusUpdate(e,"working"),this.resetWorkingTimeout(e,t))}onCommandEnd(e,t){let n=this.states.get(e);if(!n)return;n.workingTimeout&&(clearTimeout(n.workingTimeout),n.workingTimeout=null);let s;if(t!==void 0&&t!==0)s="error";else{let i=this.analyzeOutput(n.outputBuffer);i==="waiting"?s="waiting":i==="error"?s="error":i==="completed"?s="completed":s="idle"}this.scheduleStatusUpdate(e,s),(s==="completed"||s==="error")&&setTimeout(()=>{let i=this.states.get(e);i&&(i.status==="completed"||i.status==="error")&&this.scheduleStatusUpdate(e,"idle")},os.IDLE_TIMEOUT_MS)}analyzeOutput(e){let t=e.split(`
|
|
5
|
+
`),i=[],a=0,f=0,u=Math.max(n.length,s.length);for(let g=0;g<u;g++){let _=n[g],y=s[g];_===y?_!==void 0&&i.push({type:"context",content:_,oldLineNumber:g+1,newLineNumber:g+1}):(_!==void 0&&(i.push({type:"remove",content:_,oldLineNumber:g+1,newLineNumber:null}),f++),y!==void 0&&(i.push({type:"add",content:y,oldLineNumber:null,newLineNumber:g+1}),a++))}let d;return r===""?d=Or.CREATE:e===""?d=Or.DELETE:d=Or.MODIFY,{path:t,changeType:d,hunks:[{oldStart:1,oldLines:n.length,newStart:1,newLines:s.length,lines:i}],additions:a,deletions:f,isBinary:!1}}var Nf;(function(r){r.FILE="file",r.DIRECTORY="directory"})(Nf||(xt.FileEntryType=Nf={}))});var Ff=D(I=>{"use strict";Object.defineProperty(I,"__esModule",{value:!0});I.createSimpleDiff=I.parseUnifiedDiff=I.getLanguageFromPath=I.FileEntryType=I.DiffBase=I.FileViewType=I.FileChangeType=I.isRetryableError=I.createError=I.ERROR_MESSAGES=I.ErrorCode=I.isTransferComplete=I.getMissingChunks=I.calculateTotalChunks=I.TransferDirection=I.TransferStatus=I.CHUNK_TTL_SECONDS=I.TRANSFER_TTL_SECONDS=I.MAX_RETRIES=I.ACK_TIMEOUT_MS=I.WINDOW_SIZE=I.DEFAULT_MAX_FILE_SIZE=I.CHUNK_SIZE=I.getPushNotificationMessage=I.shouldTriggerPushNotification=I.deriveStatusFromEvent=I.TerminalEventType=I.createMessage=I.requiresBuffer=I.requiresAck=I.DEFAULT_RELIABILITY=I.RELIABILITY_NAMES=I.Reliability=I.comparePriority=I.DEFAULT_PRIORITY=I.PRIORITY_NAMES=I.Priority=I.negotiateCapabilities=I.hasCapability=I.SERVER_CAPABILITIES=I.DEFAULT_CLIENT_CAPABILITIES=I.Capability=I.compareVersions=I.isCompatibleVersion=I.MIN_CLIENT_VERSION=I.PROTOCOL_VERSION_MINOR=I.PROTOCOL_VERSION_MAJOR=I.PROTOCOL_VERSION=void 0;var wn=xf();Object.defineProperty(I,"PROTOCOL_VERSION",{enumerable:!0,get:function(){return wn.PROTOCOL_VERSION}});Object.defineProperty(I,"PROTOCOL_VERSION_MAJOR",{enumerable:!0,get:function(){return wn.PROTOCOL_VERSION_MAJOR}});Object.defineProperty(I,"PROTOCOL_VERSION_MINOR",{enumerable:!0,get:function(){return wn.PROTOCOL_VERSION_MINOR}});Object.defineProperty(I,"MIN_CLIENT_VERSION",{enumerable:!0,get:function(){return wn.MIN_CLIENT_VERSION}});Object.defineProperty(I,"isCompatibleVersion",{enumerable:!0,get:function(){return wn.isCompatibleVersion}});Object.defineProperty(I,"compareVersions",{enumerable:!0,get:function(){return wn.compareVersions}});var es=bf();Object.defineProperty(I,"Capability",{enumerable:!0,get:function(){return es.Capability}});Object.defineProperty(I,"DEFAULT_CLIENT_CAPABILITIES",{enumerable:!0,get:function(){return es.DEFAULT_CLIENT_CAPABILITIES}});Object.defineProperty(I,"SERVER_CAPABILITIES",{enumerable:!0,get:function(){return es.SERVER_CAPABILITIES}});Object.defineProperty(I,"hasCapability",{enumerable:!0,get:function(){return es.hasCapability}});Object.defineProperty(I,"negotiateCapabilities",{enumerable:!0,get:function(){return es.negotiateCapabilities}});var Ys=Sf();Object.defineProperty(I,"Priority",{enumerable:!0,get:function(){return Ys.Priority}});Object.defineProperty(I,"PRIORITY_NAMES",{enumerable:!0,get:function(){return Ys.PRIORITY_NAMES}});Object.defineProperty(I,"DEFAULT_PRIORITY",{enumerable:!0,get:function(){return Ys.DEFAULT_PRIORITY}});Object.defineProperty(I,"comparePriority",{enumerable:!0,get:function(){return Ys.comparePriority}});var ts=Tf();Object.defineProperty(I,"Reliability",{enumerable:!0,get:function(){return ts.Reliability}});Object.defineProperty(I,"RELIABILITY_NAMES",{enumerable:!0,get:function(){return ts.RELIABILITY_NAMES}});Object.defineProperty(I,"DEFAULT_RELIABILITY",{enumerable:!0,get:function(){return ts.DEFAULT_RELIABILITY}});Object.defineProperty(I,"requiresAck",{enumerable:!0,get:function(){return ts.requiresAck}});Object.defineProperty(I,"requiresBuffer",{enumerable:!0,get:function(){return ts.requiresBuffer}});var vp=Of();Object.defineProperty(I,"createMessage",{enumerable:!0,get:function(){return vp.createMessage}});var Xs=Cf();Object.defineProperty(I,"TerminalEventType",{enumerable:!0,get:function(){return Xs.TerminalEventType}});Object.defineProperty(I,"deriveStatusFromEvent",{enumerable:!0,get:function(){return Xs.deriveStatusFromEvent}});Object.defineProperty(I,"shouldTriggerPushNotification",{enumerable:!0,get:function(){return Xs.shouldTriggerPushNotification}});Object.defineProperty(I,"getPushNotificationMessage",{enumerable:!0,get:function(){return Xs.getPushNotificationMessage}});var Ot=Rf();Object.defineProperty(I,"CHUNK_SIZE",{enumerable:!0,get:function(){return Ot.CHUNK_SIZE}});Object.defineProperty(I,"DEFAULT_MAX_FILE_SIZE",{enumerable:!0,get:function(){return Ot.DEFAULT_MAX_FILE_SIZE}});Object.defineProperty(I,"WINDOW_SIZE",{enumerable:!0,get:function(){return Ot.WINDOW_SIZE}});Object.defineProperty(I,"ACK_TIMEOUT_MS",{enumerable:!0,get:function(){return Ot.ACK_TIMEOUT_MS}});Object.defineProperty(I,"MAX_RETRIES",{enumerable:!0,get:function(){return Ot.MAX_RETRIES}});Object.defineProperty(I,"TRANSFER_TTL_SECONDS",{enumerable:!0,get:function(){return Ot.TRANSFER_TTL_SECONDS}});Object.defineProperty(I,"CHUNK_TTL_SECONDS",{enumerable:!0,get:function(){return Ot.CHUNK_TTL_SECONDS}});Object.defineProperty(I,"TransferStatus",{enumerable:!0,get:function(){return Ot.TransferStatus}});Object.defineProperty(I,"TransferDirection",{enumerable:!0,get:function(){return Ot.TransferDirection}});Object.defineProperty(I,"calculateTotalChunks",{enumerable:!0,get:function(){return Ot.calculateTotalChunks}});Object.defineProperty(I,"getMissingChunks",{enumerable:!0,get:function(){return Ot.getMissingChunks}});Object.defineProperty(I,"isTransferComplete",{enumerable:!0,get:function(){return Ot.isTransferComplete}});var Js=Af();Object.defineProperty(I,"ErrorCode",{enumerable:!0,get:function(){return Js.ErrorCode}});Object.defineProperty(I,"ERROR_MESSAGES",{enumerable:!0,get:function(){return Js.ERROR_MESSAGES}});Object.defineProperty(I,"createError",{enumerable:!0,get:function(){return Js.createError}});Object.defineProperty(I,"isRetryableError",{enumerable:!0,get:function(){return Js.isRetryableError}});var zr=Df();Object.defineProperty(I,"FileChangeType",{enumerable:!0,get:function(){return zr.FileChangeType}});Object.defineProperty(I,"FileViewType",{enumerable:!0,get:function(){return zr.FileViewType}});Object.defineProperty(I,"DiffBase",{enumerable:!0,get:function(){return zr.DiffBase}});Object.defineProperty(I,"FileEntryType",{enumerable:!0,get:function(){return zr.FileEntryType}});Object.defineProperty(I,"getLanguageFromPath",{enumerable:!0,get:function(){return zr.getLanguageFromPath}});Object.defineProperty(I,"parseUnifiedDiff",{enumerable:!0,get:function(){return zr.parseUnifiedDiff}});Object.defineProperty(I,"createSimpleDiff",{enumerable:!0,get:function(){return zr.createSimpleDiff}})});var Gr=D(zt=>{"use strict";var xp=zt&&zt.__createBinding||(Object.create?(function(r,e,t,n){n===void 0&&(n=t);var s=Object.getOwnPropertyDescriptor(e,t);(!s||("get"in s?!e.__esModule:s.writable||s.configurable))&&(s={enumerable:!0,get:function(){return e[t]}}),Object.defineProperty(r,n,s)}):(function(r,e,t,n){n===void 0&&(n=t),r[n]=e[t]})),Zs=zt&&zt.__exportStar||function(r,e){for(var t in r)t!=="default"&&!Object.prototype.hasOwnProperty.call(e,t)&&xp(e,r,t)};Object.defineProperty(zt,"__esModule",{value:!0});Zs(pf(),zt);Zs(gf(),zt);Zs(vf(),zt);Zs(Ff(),zt)});var Bf=D(Qs=>{"use strict";Object.defineProperty(Qs,"__esModule",{value:!0});Qs.CryptoService=void 0;var ct=Gr(),bp=3600*1e3,Mf=10,Co=class{storage;logger;sessions=new Map;agentSessions=new Map;keyPair=null;publicKeyKey;secretKeyKey;keyVersionKey;constructor(e,t,n,s){this.storage=e,this.logger=t;let i=`termiq.${n}.${s}`;this.publicKeyKey=`${i}.crypto.publicKey`,this.secretKeyKey=`${i}.crypto.secretKey`,this.keyVersionKey=`${i}.crypto.keyVersion`,this.logger.info("CryptoService namespace",n,s)}async initialize(){let e=await this.storage.get(this.publicKeyKey),t=await this.storage.get(this.secretKeyKey);e&&t?(this.keyPair={publicKey:e,secretKey:t},this.logger.info("Loaded existing identity key pair")):await this.generateIdentityKeyPair()}async generateIdentityKeyPair(){this.logger.info("Generating new identity key pair"),this.keyPair=(0,ct.generateKeyPair)(),await this.storage.set(this.publicKeyKey,this.keyPair.publicKey),await this.storage.set(this.secretKeyKey,this.keyPair.secretKey);let e=await this.getKeyVersion();return await this.storage.set(this.keyVersionKey,String(e+1)),this.logger.info("Identity key pair generated and stored"),this.keyPair}async getPublicKey(){return this.keyPair?this.keyPair.publicKey:await this.storage.get(this.publicKeyKey)||null}async getKeyVersion(){let e=await this.storage.get(this.keyVersionKey);return e?parseInt(e,10):1}async handleKeyExchange(e,t,n){if(!this.keyPair&&(this.logger.warn("Key pair missing, attempting re-initialization"),await this.initialize(),!this.keyPair))return this.logger.error("No identity key pair available after re-initialization"),!1;this.logger.info("Starting key exchange",e,n);try{let s=this.sessions.get(e);s||(s=new Map,this.sessions.set(e,s));let i=(0,ct.deriveSharedSecret)(t,this.keyPair.secretKey),a={terminalId:e,clientPublicKey:t,sharedSecret:i,createdAt:Date.now(),sessionId:n};return s.set(n,a),this.logger.info("Key exchange completed",e,n,"total:",s.size),!0}catch(s){return this.logger.error("Key exchange failed",s),!1}}encryptOutput(e,t){let n=this.sessions.get(e);if(!n||n.size===0)return null;try{if(n.size===1){let i=n.values().next().value;return i?(0,ct.encrypt)(t,i.sharedSecret,i.sessionId):null}let s=[];for(let i of n.values()){let a=(0,ct.encrypt)(t,i.sharedSecret,i.sessionId);s.push({sid:a.sid,n:a.n,c:a.c})}return{v:2,recipients:s}}catch(s){return this.logger.error("Encryption failed",s),null}}decryptInput(e,t){let n=this.sessions.get(e);if(!n)return this.logger.error("No sessions for terminal",e),null;let s=n.get(t.sid);if(!s)return this.logger.error("No session for sessionId",t.sid),null;try{return(0,ct.decrypt)(t,s.sharedSecret)}catch(i){return this.logger.error("Decryption failed",i),null}}hasSession(e){let t=this.sessions.get(e);return t!==void 0&&t.size>0}removeSession(e,t){let n=this.sessions.get(e);if(n)if(t){let s=n.get(t);s&&((0,ct.clearKey)(s.sharedSecret),n.delete(t),this.logger.info("Session removed",e,t)),n.size===0&&this.sessions.delete(e)}else{for(let s of n.values())(0,ct.clearKey)(s.sharedSecret);this.sessions.delete(e),this.logger.debug("All sessions removed for terminal",e)}}clearAllSessions(){for(let e of this.sessions.values())for(let t of e.values())(0,ct.clearKey)(t.sharedSecret);this.sessions.clear(),this.logger.debug("All sessions cleared")}cleanupStaleSessions(e){let t=this.sessions.get(e);if(!t||t.size===0)return;let n=Date.now(),s=[];for(let[i,a]of t)n-a.createdAt>bp&&s.push(i);for(let i of s){let a=t.get(i);a&&((0,ct.clearKey)(a.sharedSecret),t.delete(i))}if(t.size>Mf){let a=Array.from(t.entries()).sort((f,u)=>f[1].createdAt-u[1].createdAt).slice(0,t.size-Mf);for(let[,f]of a)(0,ct.clearKey)(f.sharedSecret),t.delete(f.sessionId)}t.size===0&&this.sessions.delete(e)}cleanupAllStaleSessions(){for(let e of this.sessions.keys())this.cleanupStaleSessions(e)}getSessionInfo(){let e=[];for(let[t,n]of this.sessions.entries())for(let s of n.values())e.push({terminalId:t,createdAt:s.createdAt,sessionId:s.sessionId});return e}async handleAgentKeyExchange(e,t){if(!this.keyPair&&(this.logger.warn("Key pair missing for agent key exchange"),await this.initialize(),!this.keyPair))return this.logger.error("No identity key pair available for agent key exchange"),!1;try{let n=this.agentSessions.get(t);n&&(this.logger.info("Rekeying existing agent session",t),(0,ct.clearKey)(n.sharedSecret));let s=(0,ct.deriveSharedSecret)(e,this.keyPair.secretKey),i={sessionId:t,clientPublicKey:e,sharedSecret:s,createdAt:Date.now()};return this.agentSessions.set(t,i),this.logger.info("Agent key exchange completed",t,"total:",this.agentSessions.size),!0}catch(n){return this.logger.error("Agent key exchange failed",n),!1}}removeAgentSession(e){let t=this.agentSessions.get(e);t&&((0,ct.clearKey)(t.sharedSecret),this.agentSessions.delete(e),this.logger.info("Agent session removed",e))}hasAgentSessions(){return this.agentSessions.size>0}encryptWorkspaceInfo(e){if(this.agentSessions.size===0)return null;let t=JSON.stringify(e),n=this.encryptForAllAgentSessions(t);return n?{encrypted:n}:null}encryptTerminalInfo(e){if(this.agentSessions.size===0)return null;let t=JSON.stringify(e),n=this.encryptForAllAgentSessions(t);return n?{encrypted:n}:null}encryptPromptInfo(e){if(this.agentSessions.size===0)return null;let t=JSON.stringify(e),n=this.encryptForAllAgentSessions(t);return n?{encrypted:n}:null}encryptForAllAgentSessions(e){if(this.agentSessions.size===0)return null;try{if(this.agentSessions.size===1){let n=this.agentSessions.values().next().value;return n?(0,ct.encrypt)(e,n.sharedSecret,n.sessionId):null}let t=[];for(let n of this.agentSessions.values()){let s=(0,ct.encrypt)(e,n.sharedSecret,n.sessionId);t.push({sid:s.sid,n:s.n,c:s.c})}return{v:2,recipients:t}}catch(t){return this.logger.error("Encryption for agent sessions failed",t),null}}clearAllAgentSessions(){for(let e of this.agentSessions.values())(0,ct.clearKey)(e.sharedSecret);this.agentSessions.clear(),this.logger.debug("All agent sessions cleared")}async deleteKeys(){await this.storage.delete(this.publicKeyKey),await this.storage.delete(this.secretKeyKey),await this.storage.delete(this.keyVersionKey),this.keyPair=null,this.clearAllSessions(),this.clearAllAgentSessions(),this.logger.info("All crypto keys deleted")}};Qs.CryptoService=Co});var jf=D(ei=>{"use strict";Object.defineProperty(ei,"__esModule",{value:!0});ei.AuthService=void 0;var rs=Ws(),ko=class{storage;cryptoService;machineId;config;logger;notification;browser;pollingAbortController=null;tokenKey;refreshTokenKey;agentIdKey;constructor(e,t,n,s,i,a,f,u,d){this.storage=e,this.cryptoService=t,this.machineId=n,this.config=s,this.logger=i,this.notification=a,this.browser=f;let g=`termiq.${u}.${d}`;this.tokenKey=`${g}.accessToken`,this.refreshTokenKey=`${g}.refreshToken`,this.agentIdKey=`${g}.agentId`,this.logger.info("AuthService namespace",u,d)}cancelPolling(){this.pollingAbortController&&(this.logger.info("Cancelling active polling"),this.pollingAbortController.abort(),this.pollingAbortController=null)}async startDeviceCodeFlow(){this.cancelPolling();let e=(0,rs.getApiUrl)(this.config),t=await this.machineId.getMachineId(),n=this.machineId.getMachineName(),s=await this.cryptoService.getPublicKey();s||(await this.cryptoService.generateIdentityKeyPair(),s=await this.cryptoService.getPublicKey()),this.logger.info("Starting device code flow",t,n);let i=await fetch(`${e}/auth/device/code`,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({machineId:t,machineName:n,publicKey:s})});if(!i.ok){let a=await i.text();throw new Error(`Failed to get device code: ${a}`)}return i.json()}async pollForToken(e){this.cancelPolling();let t=(0,rs.getApiUrl)(this.config),n=5e3,s=60;this.pollingAbortController=new AbortController;let i=this.pollingAbortController.signal;this.logger.info("Starting token polling");for(let a=0;a<s;a++){if(i.aborted)return this.logger.info("Polling was cancelled"),null;if(await this.sleep(n),i.aborted)return this.logger.info("Polling was cancelled"),null;try{let f=await fetch(`${t}/auth/device/poll`,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({deviceCode:e}),signal:i});if(!f.ok){if(f.status===403)try{let d=await f.json();if(d.error==="AGENT_LIMIT_EXCEEDED")return this.logger.warn("Agent limit exceeded",String(d.current),"/",String(d.max)),this.notification.warn(`Agent limit reached (${d.current}/${d.max}). Upgrade your plan to add more devices.`),null}catch{}this.logger.warn("Poll request failed",String(f.status));continue}let u=await f.json();if(u.status==="success"&&u.accessToken)return this.logger.info("Token received successfully"),this.pollingAbortController=null,await this.saveTokens(u),u;if(u.status==="expired")return this.logger.warn("Device code expired"),null;if(u.status==="limit_exceeded")return this.logger.warn("Agent limit exceeded",String(u.current),"/",String(u.max)),this.notification.warn(`Agent limit reached (${u.current}/${u.max}). Remove an old agent or upgrade your plan.`),null;this.logger.debug("Token pending, continuing poll",String(a))}catch(f){if(i.aborted)return this.logger.info("Polling was cancelled"),null;let u=f instanceof Error?f.message:String(f);this.logger.warn(`Poll error: ${u}`)}}return this.logger.warn("Polling timed out"),this.pollingAbortController=null,null}async loginWithApiKey(e){let t=(0,rs.getApiUrl)(this.config),n=await this.machineId.getMachineId(),s=this.machineId.getMachineName(),i=await this.cryptoService.getPublicKey();i||(await this.cryptoService.generateIdentityKeyPair(),i=await this.cryptoService.getPublicKey()),this.logger.info("Logging in with API key");try{let a=await fetch(`${t}/auth/api-key/login`,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({apiKey:e,machineId:n,machineName:s,publicKey:i})});if(!a.ok){let u=await a.text();return this.logger.error("API key login failed",u),!1}let f=await a.json();return f.accessToken?(await this.saveTokens(f),this.logger.info("API key login successful"),!0):!1}catch(a){return this.logger.error("API key login error",a),!1}}async hasValidToken(){let e=await this.storage.get(this.tokenKey);if(!e)return!1;try{let n=JSON.parse(Buffer.from(e.split(".")[1],"base64").toString()).exp*1e3;return Date.now()<n}catch{return!1}}async getAccessToken(){return await this.storage.get(this.tokenKey)||null}async getAgentId(){return await this.storage.get(this.agentIdKey)||null}async refreshAccessToken(){let e=await this.storage.get(this.refreshTokenKey);if(!e)return this.logger.debug("No refresh token available"),null;let t=(0,rs.getApiUrl)(this.config);try{this.logger.info("Refreshing access token");let n=await fetch(`${t}/auth/refresh`,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({refreshToken:e})});if(!n.ok)return this.logger.warn("Token refresh failed",String(n.status)),n.status===401&&await this.storage.delete(this.refreshTokenKey),null;let s=await n.json();return await this.storage.set(this.tokenKey,s.accessToken),await this.storage.set(this.refreshTokenKey,s.refreshToken),this.logger.info("Access token refreshed successfully"),s.accessToken}catch(n){return this.logger.warn("Token refresh error",n),null}}async logout(){this.logger.info("Logging out"),this.cancelPolling(),await this.storage.delete(this.tokenKey),await this.storage.delete(this.refreshTokenKey),await this.storage.delete(this.agentIdKey),await this.cryptoService.deleteKeys()}async saveTokens(e){e.accessToken&&await this.storage.set(this.tokenKey,e.accessToken),e.refreshToken&&await this.storage.set(this.refreshTokenKey,e.refreshToken),e.agentId&&await this.storage.set(this.agentIdKey,e.agentId)}async getLimits(){let e=await this.getAccessToken();if(!e)return this.logger.warn("Cannot fetch limits: no access token"),null;let t=(0,rs.getApiUrl)(this.config);try{let n=await fetch(`${t}/users/me/limits`,{headers:{Authorization:`Bearer ${e}`,"Content-Type":"application/json"}});return n.ok?await n.json():(this.logger.error("Failed to fetch limits",String(n.status)),null)}catch(n){let s=n instanceof Error?n.message:String(n);return this.logger.error(`Error fetching limits: ${s}`),null}}async openUrl(e){await this.browser.openUrl(e)}async canCreateTerminal(){let e=await this.getLimits();return e?e.terminals.unlimited?{allowed:!0,limits:e}:e.terminals.current>=e.terminals.max?{allowed:!1,reason:`Terminal limit reached (${e.terminals.current}/${e.terminals.max}). Upgrade your plan to create more terminals.`,limits:e}:{allowed:!0,limits:e}:{allowed:!0}}sleep(e){return new Promise(t=>setTimeout(t,e))}};ei.AuthService=ko});var Uf=D(ri=>{"use strict";Object.defineProperty(ri,"__esModule",{value:!0});ri.StatusDetector=void 0;var ti={working:[/✶/,/⠋|⠙|⠹|⠸|⠼|⠴|⠦|⠧|⠇|⠏/],idle:[/[❯$#>]\s*$/,/^\s*\d+\s*[❯$#>]\s*$/,/\(base\)\s*[❯$#>]\s*$/,/\)\s*[❯$#>]\s*$/],waiting:[/\[Y\/n\]/i,/\[y\/N\]/i,/\(y\/n\)/i,/\(yes\/no\)/i,/Continue\?/i,/Proceed\?/i,/Are you sure\?/i,/Confirm\?/i,/Press Enter to continue/i,/Press any key/i,/\[Enter\]/i,/Do you want to/i,/Would you like to/i,/Shall I/i,/^\s*\d+[.)]\s+.+$/m,/Select.*:/i,/Choose.*:/i,/Which.*\?/i,/Какой вариант/i,/Выберите/i],completed:[/✓\s*(Done|Complete|Success|Finished)/i,/\[done\]/i,/\[success\]/i,/completed successfully/i,/Build succeeded/i,/All tests passed/i],error:[/✕\s*(Error|Failed|Failure)/i,/\[error\]/i,/\[failed\]/i,/Error:/i,/Exception:/i,/FATAL:/i,/Build failed/i,/Tests failed/i,/command not found/i,/Permission denied/i,/No such file or directory/i]},ns={IDLE_TIMEOUT_MS:5e3,DEBOUNCE_MS:500,BUFFER_SIZE:2e3,WORKING_TIMEOUT_MS:3e4},Po=class{states=new Map;onStatusChange;constructor(e){this.onStatusChange=e}startTracking(e){if(this.states.has(e))return;let t={status:"idle",lastUpdate:Date.now(),lastOutput:Date.now(),outputBuffer:"",pendingUpdate:null,workingTimeout:null};this.states.set(e,t),this.emitStatus(e,"idle")}stopTracking(e){let t=this.states.get(e);t&&(t.pendingUpdate&&clearTimeout(t.pendingUpdate),t.workingTimeout&&clearTimeout(t.workingTimeout)),this.states.delete(e)}processOutput(e,t){let n=this.states.get(e);if(!n)return;n.lastOutput=Date.now(),n.outputBuffer+=t,n.outputBuffer.length>ns.BUFFER_SIZE&&(n.outputBuffer=n.outputBuffer.slice(-ns.BUFFER_SIZE));let s=this.analyzeOutput(n.outputBuffer);s&&this.scheduleStatusUpdate(e,s),this.resetWorkingTimeout(e,n)}onCommandStart(e){let t=this.states.get(e);t&&(t.outputBuffer="",this.scheduleStatusUpdate(e,"working"),this.resetWorkingTimeout(e,t))}onCommandEnd(e,t){let n=this.states.get(e);if(!n)return;n.workingTimeout&&(clearTimeout(n.workingTimeout),n.workingTimeout=null);let s;if(t!==void 0&&t!==0)s="error";else{let i=this.analyzeOutput(n.outputBuffer);i==="waiting"?s="waiting":i==="error"?s="error":i==="completed"?s="completed":s="idle"}this.scheduleStatusUpdate(e,s),(s==="completed"||s==="error")&&setTimeout(()=>{let i=this.states.get(e);i&&(i.status==="completed"||i.status==="error")&&this.scheduleStatusUpdate(e,"idle")},ns.IDLE_TIMEOUT_MS)}analyzeOutput(e){let t=e.split(`
|
|
8
6
|
`).slice(-10),n=t.join(`
|
|
9
|
-
`),s=t[t.length-1]||"";for(let i of
|
|
7
|
+
`),s=t[t.length-1]||"";for(let i of ti.waiting)if(i.test(n))return"waiting";for(let i of ti.working)if(i.test(s))return"working";for(let i of ti.completed)if(i.test(n))return"completed";for(let i of ti.idle)if(i.test(s))return"idle";return null}detectPrompt(e){let s=this.normalizeBuffer(this.stripAnsi(e)).split(`
|
|
10
8
|
`).slice(-20),i=s.join(`
|
|
11
9
|
`),a=s[s.length-1]||"",f=this.extractNumberedChoices(e);if(f.length>=2)return{type:"numbered-choice",question:this.extractQuestion(i)||"Select an option:",choices:f};let u=[/\[Y\/n\]/i,/\[y\/N\]/i,/\(y\/n\)/i,/\(yes\/no\)/i];for(let _ of u)if(_.test(i))return{type:"yes-no",question:this.extractQuestion(i)||"Confirm?"};let d=[/Press Enter to continue/i,/Press Enter/i,/Hit Enter/i,/\[Enter\]/i,/press return/i];for(let _ of d)if(_.test(i))return{type:"enter",question:this.extractQuestion(i)||"Press Enter to continue"};let g=[/Press any key/i,/press a key/i];for(let _ of g)if(_.test(i))return{type:"any-key",question:this.extractQuestion(i)||"Press any key"};return(a.endsWith("?")||a.endsWith(":"))&&!a.startsWith("/")&&!a.includes("error")&&a.length<100?{type:"free-input",question:a}:null}extractNumberedChoices(e){let t=[],s=this.normalizeBuffer(this.stripAnsi(e)).split(`
|
|
12
10
|
`),i=/^\s*[❯>*]?\s*(?:(\d+)[.)]\s*|\[(\d+)\]\s*)(.+)$/;for(let a of s){let f=a.match(i);if(f){let u=f[1]||f[2],d=f[3].trim();if(u&&d&&d.length<100&&!d.includes("error")){let g=t.length+1;parseInt(u)===g&&t.push({key:u,label:d})}}}return t}extractQuestion(e){let t=e.split(`
|
|
@@ -14,28 +12,28 @@ tell application "System Events" to get value of property list item "CFBundleNam
|
|
|
14
12
|
`).replace(/\r/g,`
|
|
15
13
|
`).replace(/\n{3,}/g,`
|
|
16
14
|
|
|
17
|
-
`)}scheduleStatusUpdate(e,t){let n=this.states.get(e);n&&n.status!==t&&(n.pendingUpdate&&clearTimeout(n.pendingUpdate),n.pendingUpdate=setTimeout(()=>{this.emitStatus(e,t),n.pendingUpdate=null},
|
|
18
|
-
`);return T.substr(0,T.length-2)},this.getRequestHeader=function(T){return typeof T=="string"&&d[T]?d[T]:""},this.send=function(T){if(this.readyState!=this.OPENED)throw new Error("INVALID_STATE_ERR: connection must be opened before send() is called");if(y)throw new Error("INVALID_STATE_ERR: send has already been called");var M=!1,Q=!1,B=ou.parse(a.url),ie;switch(B.protocol){case"https:":M=!0;case"http:":ie=B.hostname;break;case"file:":Q=!0;break;case void 0:case"":ie="localhost";break;default:throw new Error("Protocol not supported.")}if(Q){if(a.method!=="GET")throw new Error("XMLHttpRequest: Only GET method is supported");if(a.async)En.readFile(unescape(B.pathname),function(A,oe){A?e.handleError(A,A.errno||-1):(e.status=200,e.responseText=oe.toString("utf8"),e.response=oe,X(e.DONE))});else try{this.response=En.readFileSync(unescape(B.pathname)),this.responseText=this.response.toString("utf8"),this.status=200,X(e.DONE)}catch(A){this.handleError(A,A.errno||-1)}return}var he=B.port||(M?443:80),de=B.pathname+(B.search?B.search:"");if(d.Host=ie,M&&he===443||he===80||(d.Host+=":"+B.port),a.user){typeof a.password>"u"&&(a.password="");var Pe=new Buffer(a.user+":"+a.password);d.Authorization="Basic "+Pe.toString("base64")}if(a.method==="GET"||a.method==="HEAD")T=null;else if(T){d["Content-Length"]=Buffer.isBuffer(T)?T.length:Buffer.byteLength(T);var qe=Object.keys(d);qe.some(function(A){return A.toLowerCase()==="content-type"})||(d["Content-Type"]="text/plain;charset=UTF-8")}else a.method==="POST"&&(d["Content-Length"]=0);var Ge=r.agent||!1,xe={host:ie,port:he,path:de,method:a.method,headers:d,agent:Ge};if(M&&(xe.pfx=r.pfx,xe.key=r.key,xe.passphrase=r.passphrase,xe.cert=r.cert,xe.ca=r.ca,xe.ciphers=r.ciphers,xe.rejectUnauthorized=r.rejectUnauthorized!==!1),x=!1,a.async){var Ye=M?n.request:t.request;y=!0,e.dispatchEvent("readystatechange");var De=function(A){if(i=A,i.statusCode===302||i.statusCode===303||i.statusCode===307){a.url=i.headers.location;var oe=ou.parse(a.url);ie=oe.hostname;var Ae={hostname:oe.hostname,port:oe.port,path:oe.path,method:i.statusCode===303?"GET":a.method,headers:d};M&&(Ae.pfx=r.pfx,Ae.key=r.key,Ae.passphrase=r.passphrase,Ae.cert=r.cert,Ae.ca=r.ca,Ae.ciphers=r.ciphers,Ae.rejectUnauthorized=r.rejectUnauthorized!==!1),s=Ye(Ae,De).on("error",J),s.end();return}X(e.HEADERS_RECEIVED),e.status=i.statusCode,i.on("data",function(ft){if(ft){var gt=Buffer.from(ft);e.response=Buffer.concat([e.response,gt])}y&&X(e.LOADING)}),i.on("end",function(){y&&(y=!1,X(e.DONE),e.responseText=e.response.toString("utf8"))}),i.on("error",function(ft){e.handleError(ft)})},J=function(A){if(s.reusedSocket&&A.code==="ECONNRESET")return Ye(xe,De).on("error",J);e.handleError(A)};s=Ye(xe,De).on("error",J),r.autoUnref&&s.on("socket",A=>{A.unref()}),T&&s.write(T),s.end(),e.dispatchEvent("loadstart")}else{var ye=".node-xmlhttprequest-content-"+process.pid,pe=".node-xmlhttprequest-sync-"+process.pid;En.writeFileSync(pe,"","utf8");for(var rt="var http = require('http'), https = require('https'), fs = require('fs');var doRequest = http"+(M?"s":"")+".request;var options = "+JSON.stringify(xe)+";var responseText = '';var responseData = Buffer.alloc(0);var req = doRequest(options, function(response) {response.on('data', function(chunk) { var data = Buffer.from(chunk); responseText += data.toString('utf8'); responseData = Buffer.concat([responseData, data]);});response.on('end', function() {fs.writeFileSync('"+ye+"', JSON.stringify({err: null, data: {statusCode: response.statusCode, headers: response.headers, text: responseText, data: responseData.toString('base64')}}), 'utf8');fs.unlinkSync('"+pe+"');});response.on('error', function(error) {fs.writeFileSync('"+ye+"', 'NODE-XMLHTTPREQUEST-ERROR:' + JSON.stringify(error), 'utf8');fs.unlinkSync('"+pe+"');});}).on('error', function(error) {fs.writeFileSync('"+ye+"', 'NODE-XMLHTTPREQUEST-ERROR:' + JSON.stringify(error), 'utf8');fs.unlinkSync('"+pe+"');});"+(T?"req.write('"+JSON.stringify(T).slice(1,-1).replace(/'/g,"\\'")+"');":"")+"req.end();",Ze=bp(process.argv[0],["-e",rt]),qt;En.existsSync(pe););if(e.responseText=En.readFileSync(ye,"utf8"),Ze.stdin.end(),En.unlinkSync(ye),e.responseText.match(/^NODE-XMLHTTPREQUEST-ERROR:/)){var N=JSON.parse(e.responseText.replace(/^NODE-XMLHTTPREQUEST-ERROR:/,""));e.handleError(N,503)}else{e.status=e.responseText.replace(/^NODE-XMLHTTPREQUEST-STATUS:([0-9]*),.*/,"$1");var j=JSON.parse(e.responseText.replace(/^NODE-XMLHTTPREQUEST-STATUS:[0-9]*,(.*)/,"$1"));i={statusCode:e.status,headers:j.data.headers},e.responseText=j.data.text,e.response=Buffer.from(j.data.data,"base64"),X(e.DONE,!0)}}},this.handleError=function(T,M){this.status=M||0,this.statusText=T,this.responseText=T.stack,x=!0,X(this.DONE)},this.abort=function(){s&&(s.abort(),s=null),d=Object.assign({},u),this.responseText="",this.responseXML="",this.response=Buffer.alloc(0),x=S=!0,this.readyState!==this.UNSENT&&(this.readyState!==this.OPENED||y)&&this.readyState!==this.DONE&&(y=!1,X(this.DONE)),this.readyState=this.UNSENT},this.addEventListener=function(T,M){T in C||(C[T]=[]),C[T].push(M)},this.removeEventListener=function(T,M){T in C&&(C[T]=C[T].filter(function(Q){return Q!==M}))},this.dispatchEvent=function(T){if(typeof e["on"+T]=="function"&&(this.readyState===this.DONE&&a.async?setTimeout(function(){e["on"+T]()},0):e["on"+T]()),T in C)for(let M=0,Q=C[T].length;M<Q;M++)this.readyState===this.DONE?setTimeout(function(){C[T][M].call(e)},0):C[T][M].call(e)};var X=function(T){if(!(e.readyState===T||e.readyState===e.UNSENT&&S)&&(e.readyState=T,(a.async||e.readyState<e.OPENED||e.readyState===e.DONE)&&e.dispatchEvent("readystatechange"),e.readyState===e.DONE)){let M;S?M="abort":x?M="error":M="load",e.dispatchEvent(M),e.dispatchEvent("loadend")}}}});var ri=F(kr=>{"use strict";Object.defineProperty(kr,"__esModule",{value:!0});kr.ERROR_PACKET=kr.PACKET_TYPES_REVERSE=kr.PACKET_TYPES=void 0;var zt=Object.create(null);kr.PACKET_TYPES=zt;zt.open="0";zt.close="1";zt.ping="2";zt.pong="3";zt.message="4";zt.upgrade="5";zt.noop="6";var fu=Object.create(null);kr.PACKET_TYPES_REVERSE=fu;Object.keys(zt).forEach(r=>{fu[zt[r]]=r});var Sp={type:"error",data:"parser error"};kr.ERROR_PACKET=Sp});var lu=F(wn=>{"use strict";Object.defineProperty(wn,"__esModule",{value:!0});wn.encodePacket=void 0;wn.encodePacketToBinary=Cp;var Tp=ri(),Op=({type:r,data:e},t,n)=>e instanceof ArrayBuffer||ArrayBuffer.isView(e)?n(t?e:"b"+uu(e,!0).toString("base64")):n(Tp.PACKET_TYPES[r]+(e||""));wn.encodePacket=Op;var uu=(r,e)=>Buffer.isBuffer(r)||r instanceof Uint8Array&&!e?r:r instanceof ArrayBuffer?Buffer.from(r):Buffer.from(r.buffer,r.byteOffset,r.byteLength),zo;function Cp(r,e){if(r.data instanceof ArrayBuffer||ArrayBuffer.isView(r.data))return e(uu(r.data,!1));(0,wn.encodePacket)(r,!0,t=>{zo||(zo=new TextEncoder),e(zo.encode(t))})}});var du=F(si=>{"use strict";Object.defineProperty(si,"__esModule",{value:!0});si.decodePacket=void 0;var ni=ri(),kp=(r,e)=>{if(typeof r!="string")return{type:"message",data:hu(r,e)};let t=r.charAt(0);if(t==="b"){let n=Buffer.from(r.substring(1),"base64");return{type:"message",data:hu(n,e)}}return ni.PACKET_TYPES_REVERSE[t]?r.length>1?{type:ni.PACKET_TYPES_REVERSE[t],data:r.substring(1)}:{type:ni.PACKET_TYPES_REVERSE[t]}:ni.ERROR_PACKET};si.decodePacket=kp;var hu=(r,e)=>e==="arraybuffer"?r instanceof ArrayBuffer?r:Buffer.isBuffer(r)?r.buffer.slice(r.byteOffset,r.byteOffset+r.byteLength):r.buffer:Buffer.isBuffer(r)?r:Buffer.from(r)});var xn=F(ht=>{"use strict";Object.defineProperty(ht,"__esModule",{value:!0});ht.decodePayload=ht.decodePacket=ht.encodePayload=ht.encodePacket=ht.protocol=void 0;ht.createPacketEncoderStream=Ap;ht.createPacketDecoderStream=Ip;var Yo=lu();Object.defineProperty(ht,"encodePacket",{enumerable:!0,get:function(){return Yo.encodePacket}});var Xo=du();Object.defineProperty(ht,"decodePacket",{enumerable:!0,get:function(){return Xo.decodePacket}});var pu=ri(),gu="",Pp=(r,e)=>{let t=r.length,n=new Array(t),s=0;r.forEach((i,a)=>{(0,Yo.encodePacket)(i,!1,f=>{n[a]=f,++s===t&&e(n.join(gu))})})};ht.encodePayload=Pp;var Rp=(r,e)=>{let t=r.split(gu),n=[];for(let s=0;s<t.length;s++){let i=(0,Xo.decodePacket)(t[s],e);if(n.push(i),i.type==="error")break}return n};ht.decodePayload=Rp;function Ap(){return new TransformStream({transform(r,e){(0,Yo.encodePacketToBinary)(r,t=>{let n=t.length,s;if(n<126)s=new Uint8Array(1),new DataView(s.buffer).setUint8(0,n);else if(n<65536){s=new Uint8Array(3);let i=new DataView(s.buffer);i.setUint8(0,126),i.setUint16(1,n)}else{s=new Uint8Array(9);let i=new DataView(s.buffer);i.setUint8(0,127),i.setBigUint64(1,BigInt(n))}r.data&&typeof r.data!="string"&&(s[0]|=128),e.enqueue(s),e.enqueue(t)})}})}var Go;function ii(r){return r.reduce((e,t)=>e+t.length,0)}function oi(r,e){if(r[0].length===e)return r.shift();let t=new Uint8Array(e),n=0;for(let s=0;s<e;s++)t[s]=r[0][n++],n===r[0].length&&(r.shift(),n=0);return r.length&&n<r[0].length&&(r[0]=r[0].slice(n)),t}function Ip(r,e){Go||(Go=new TextDecoder);let t=[],n=0,s=-1,i=!1;return new TransformStream({transform(a,f){for(t.push(a);;){if(n===0){if(ii(t)<1)break;let u=oi(t,1);i=(u[0]&128)===128,s=u[0]&127,s<126?n=3:s===126?n=1:n=2}else if(n===1){if(ii(t)<2)break;let u=oi(t,2);s=new DataView(u.buffer,u.byteOffset,u.length).getUint16(0),n=3}else if(n===2){if(ii(t)<8)break;let u=oi(t,8),d=new DataView(u.buffer,u.byteOffset,u.length),g=d.getUint32(0);if(g>Math.pow(2,21)-1){f.enqueue(pu.ERROR_PACKET);break}s=g*Math.pow(2,32)+d.getUint32(4),n=3}else{if(ii(t)<s)break;let u=oi(t,s);f.enqueue((0,Xo.decodePacket)(i?u:Go.decode(u),e)),n=0}if(s===0||s>r){f.enqueue(pu.ERROR_PACKET);break}}}})}ht.protocol=4});var $r=F(_u=>{_u.Emitter=lt;function lt(r){if(r)return Np(r)}function Np(r){for(var e in lt.prototype)r[e]=lt.prototype[e];return r}lt.prototype.on=lt.prototype.addEventListener=function(r,e){return this._callbacks=this._callbacks||{},(this._callbacks["$"+r]=this._callbacks["$"+r]||[]).push(e),this};lt.prototype.once=function(r,e){function t(){this.off(r,t),e.apply(this,arguments)}return t.fn=e,this.on(r,t),this};lt.prototype.off=lt.prototype.removeListener=lt.prototype.removeAllListeners=lt.prototype.removeEventListener=function(r,e){if(this._callbacks=this._callbacks||{},arguments.length==0)return this._callbacks={},this;var t=this._callbacks["$"+r];if(!t)return this;if(arguments.length==1)return delete this._callbacks["$"+r],this;for(var n,s=0;s<t.length;s++)if(n=t[s],n===e||n.fn===e){t.splice(s,1);break}return t.length===0&&delete this._callbacks["$"+r],this};lt.prototype.emit=function(r){this._callbacks=this._callbacks||{};for(var e=new Array(arguments.length-1),t=this._callbacks["$"+r],n=1;n<arguments.length;n++)e[n-1]=arguments[n];if(t){t=t.slice(0);for(var n=0,s=t.length;n<s;++n)t[n].apply(this,e)}return this};lt.prototype.emitReserved=lt.prototype.emit;lt.prototype.listeners=function(r){return this._callbacks=this._callbacks||{},this._callbacks["$"+r]||[]};lt.prototype.hasListeners=function(r){return!!this.listeners(r).length}});var zr=F(Ot=>{"use strict";Object.defineProperty(Ot,"__esModule",{value:!0});Ot.CookieJar=Ot.defaultBinaryType=Ot.globalThisShim=Ot.nextTick=void 0;Ot.createCookieJar=Lp;Ot.parse=mu;Ot.nextTick=process.nextTick;Ot.globalThisShim=global;Ot.defaultBinaryType="nodebuffer";function Lp(){return new ai}function mu(r){let e=r.split("; "),t=e[0].indexOf("=");if(t===-1)return;let n=e[0].substring(0,t).trim();if(!n.length)return;let s=e[0].substring(t+1).trim();s.charCodeAt(0)===34&&(s=s.slice(1,-1));let i={name:n,value:s};for(let a=1;a<e.length;a++){let f=e[a].split("=");if(f.length!==2)continue;let u=f[0].trim(),d=f[1].trim();switch(u){case"Expires":i.expires=new Date(d);break;case"Max-Age":let g=new Date;g.setUTCSeconds(g.getUTCSeconds()+parseInt(d,10)),i.expires=g;break;default:}}return i}var ai=class{constructor(){this._cookies=new Map}parseCookies(e){e&&e.forEach(t=>{let n=mu(t);n&&this._cookies.set(n.name,n)})}get cookies(){let e=Date.now();return this._cookies.forEach((t,n)=>{var s;((s=t.expires)===null||s===void 0?void 0:s.getTime())<e&&this._cookies.delete(n)}),this._cookies.entries()}addCookies(e){let t=[];for(let[n,s]of this.cookies)t.push(`${n}=${s.value}`);t.length&&(e.setDisableHeaderCheck(!0),e.setRequestHeader("cookie",t.join("; ")))}appendCookies(e){for(let[t,n]of this.cookies)e.append("cookie",`${t}=${n.value}`)}};Ot.CookieJar=ai});var Gr=F(vn=>{"use strict";Object.defineProperty(vn,"__esModule",{value:!0});vn.pick=Dp;vn.installTimerFunctions=Bp;vn.byteLength=Up;vn.randomString=Wp;var Pr=zr();function Dp(r,...e){return e.reduce((t,n)=>(r.hasOwnProperty(n)&&(t[n]=r[n]),t),{})}var Fp=Pr.globalThisShim.setTimeout,Mp=Pr.globalThisShim.clearTimeout;function Bp(r,e){e.useNativeTimers?(r.setTimeoutFn=Fp.bind(Pr.globalThisShim),r.clearTimeoutFn=Mp.bind(Pr.globalThisShim)):(r.setTimeoutFn=Pr.globalThisShim.setTimeout.bind(Pr.globalThisShim),r.clearTimeoutFn=Pr.globalThisShim.clearTimeout.bind(Pr.globalThisShim))}var jp=1.33;function Up(r){return typeof r=="string"?qp(r):Math.ceil((r.byteLength||r.size)*jp)}function qp(r){let e=0,t=0;for(let n=0,s=r.length;n<s;n++)e=r.charCodeAt(n),e<128?t+=1:e<2048?t+=2:e<55296||e>=57344?t+=3:(n++,t+=4);return t}function Wp(){return Date.now().toString(36).substring(3)+Math.random().toString(36).substring(2,5)}});var Jo=F(ci=>{"use strict";Object.defineProperty(ci,"__esModule",{value:!0});ci.encode=Hp;ci.decode=Vp;function Hp(r){let e="";for(let t in r)r.hasOwnProperty(t)&&(e.length&&(e+="&"),e+=encodeURIComponent(t)+"="+encodeURIComponent(r[t]));return e}function Vp(r){let e={},t=r.split("&");for(let n=0,s=t.length;n<s;n++){let i=t[n].split("=");e[decodeURIComponent(i[0])]=decodeURIComponent(i[1])}return e}});var Eu=F((lw,yu)=>{var bn=1e3,Sn=bn*60,Tn=Sn*60,Yr=Tn*24,Kp=Yr*7,$p=Yr*365.25;yu.exports=function(r,e){e=e||{};var t=typeof r;if(t==="string"&&r.length>0)return zp(r);if(t==="number"&&isFinite(r))return e.long?Yp(r):Gp(r);throw new Error("val is not a non-empty string or a valid number. val="+JSON.stringify(r))};function zp(r){if(r=String(r),!(r.length>100)){var e=/^(-?(?:\d+)?\.?\d+) *(milliseconds?|msecs?|ms|seconds?|secs?|s|minutes?|mins?|m|hours?|hrs?|h|days?|d|weeks?|w|years?|yrs?|y)?$/i.exec(r);if(e){var t=parseFloat(e[1]),n=(e[2]||"ms").toLowerCase();switch(n){case"years":case"year":case"yrs":case"yr":case"y":return t*$p;case"weeks":case"week":case"w":return t*Kp;case"days":case"day":case"d":return t*Yr;case"hours":case"hour":case"hrs":case"hr":case"h":return t*Tn;case"minutes":case"minute":case"mins":case"min":case"m":return t*Sn;case"seconds":case"second":case"secs":case"sec":case"s":return t*bn;case"milliseconds":case"millisecond":case"msecs":case"msec":case"ms":return t;default:return}}}}function Gp(r){var e=Math.abs(r);return e>=Yr?Math.round(r/Yr)+"d":e>=Tn?Math.round(r/Tn)+"h":e>=Sn?Math.round(r/Sn)+"m":e>=bn?Math.round(r/bn)+"s":r+"ms"}function Yp(r){var e=Math.abs(r);return e>=Yr?fi(r,e,Yr,"day"):e>=Tn?fi(r,e,Tn,"hour"):e>=Sn?fi(r,e,Sn,"minute"):e>=bn?fi(r,e,bn,"second"):r+" ms"}function fi(r,e,t,n){var s=e>=t*1.5;return Math.round(r/t)+" "+n+(s?"s":"")}});var Zo=F((hw,wu)=>{function Xp(r){t.debug=t,t.default=t,t.coerce=u,t.disable=a,t.enable=s,t.enabled=f,t.humanize=Eu(),t.destroy=d,Object.keys(r).forEach(g=>{t[g]=r[g]}),t.names=[],t.skips=[],t.formatters={};function e(g){let _=0;for(let y=0;y<g.length;y++)_=(_<<5)-_+g.charCodeAt(y),_|=0;return t.colors[Math.abs(_)%t.colors.length]}t.selectColor=e;function t(g){let _,y=null,x,S;function C(...H){if(!C.enabled)return;let z=C,X=Number(new Date),T=X-(_||X);z.diff=T,z.prev=_,z.curr=X,_=X,H[0]=t.coerce(H[0]),typeof H[0]!="string"&&H.unshift("%O");let M=0;H[0]=H[0].replace(/%([a-zA-Z%])/g,(B,ie)=>{if(B==="%%")return"%";M++;let he=t.formatters[ie];if(typeof he=="function"){let de=H[M];B=he.call(z,de),H.splice(M,1),M--}return B}),t.formatArgs.call(z,H),(z.log||t.log).apply(z,H)}return C.namespace=g,C.useColors=t.useColors(),C.color=t.selectColor(g),C.extend=n,C.destroy=t.destroy,Object.defineProperty(C,"enabled",{enumerable:!0,configurable:!1,get:()=>y!==null?y:(x!==t.namespaces&&(x=t.namespaces,S=t.enabled(g)),S),set:H=>{y=H}}),typeof t.init=="function"&&t.init(C),C}function n(g,_){let y=t(this.namespace+(typeof _>"u"?":":_)+g);return y.log=this.log,y}function s(g){t.save(g),t.namespaces=g,t.names=[],t.skips=[];let _=(typeof g=="string"?g:"").trim().replace(/\s+/g,",").split(",").filter(Boolean);for(let y of _)y[0]==="-"?t.skips.push(y.slice(1)):t.names.push(y)}function i(g,_){let y=0,x=0,S=-1,C=0;for(;y<g.length;)if(x<_.length&&(_[x]===g[y]||_[x]==="*"))_[x]==="*"?(S=x,C=y,x++):(y++,x++);else if(S!==-1)x=S+1,C++,y=C;else return!1;for(;x<_.length&&_[x]==="*";)x++;return x===_.length}function a(){let g=[...t.names,...t.skips.map(_=>"-"+_)].join(",");return t.enable(""),g}function f(g){for(let _ of t.skips)if(i(g,_))return!1;for(let _ of t.names)if(i(g,_))return!0;return!1}function u(g){return g instanceof Error?g.stack||g.message:g}function d(){console.warn("Instance method `debug.destroy()` is deprecated and no longer does anything. It will be removed in the next major version of `debug`.")}return t.enable(t.load()),t}wu.exports=Xp});var xu=F((dt,ui)=>{dt.formatArgs=Zp;dt.save=Qp;dt.load=eg;dt.useColors=Jp;dt.storage=tg();dt.destroy=(()=>{let r=!1;return()=>{r||(r=!0,console.warn("Instance method `debug.destroy()` is deprecated and no longer does anything. It will be removed in the next major version of `debug`."))}})();dt.colors=["#0000CC","#0000FF","#0033CC","#0033FF","#0066CC","#0066FF","#0099CC","#0099FF","#00CC00","#00CC33","#00CC66","#00CC99","#00CCCC","#00CCFF","#3300CC","#3300FF","#3333CC","#3333FF","#3366CC","#3366FF","#3399CC","#3399FF","#33CC00","#33CC33","#33CC66","#33CC99","#33CCCC","#33CCFF","#6600CC","#6600FF","#6633CC","#6633FF","#66CC00","#66CC33","#9900CC","#9900FF","#9933CC","#9933FF","#99CC00","#99CC33","#CC0000","#CC0033","#CC0066","#CC0099","#CC00CC","#CC00FF","#CC3300","#CC3333","#CC3366","#CC3399","#CC33CC","#CC33FF","#CC6600","#CC6633","#CC9900","#CC9933","#CCCC00","#CCCC33","#FF0000","#FF0033","#FF0066","#FF0099","#FF00CC","#FF00FF","#FF3300","#FF3333","#FF3366","#FF3399","#FF33CC","#FF33FF","#FF6600","#FF6633","#FF9900","#FF9933","#FFCC00","#FFCC33"];function Jp(){if(typeof window<"u"&&window.process&&(window.process.type==="renderer"||window.process.__nwjs))return!0;if(typeof navigator<"u"&&navigator.userAgent&&navigator.userAgent.toLowerCase().match(/(edge|trident)\/(\d+)/))return!1;let r;return typeof document<"u"&&document.documentElement&&document.documentElement.style&&document.documentElement.style.WebkitAppearance||typeof window<"u"&&window.console&&(window.console.firebug||window.console.exception&&window.console.table)||typeof navigator<"u"&&navigator.userAgent&&(r=navigator.userAgent.toLowerCase().match(/firefox\/(\d+)/))&&parseInt(r[1],10)>=31||typeof navigator<"u"&&navigator.userAgent&&navigator.userAgent.toLowerCase().match(/applewebkit\/(\d+)/)}function Zp(r){if(r[0]=(this.useColors?"%c":"")+this.namespace+(this.useColors?" %c":" ")+r[0]+(this.useColors?"%c ":" ")+"+"+ui.exports.humanize(this.diff),!this.useColors)return;let e="color: "+this.color;r.splice(1,0,e,"color: inherit");let t=0,n=0;r[0].replace(/%[a-zA-Z%]/g,s=>{s!=="%%"&&(t++,s==="%c"&&(n=t))}),r.splice(n,0,e)}dt.log=console.debug||console.log||(()=>{});function Qp(r){try{r?dt.storage.setItem("debug",r):dt.storage.removeItem("debug")}catch{}}function eg(){let r;try{r=dt.storage.getItem("debug")||dt.storage.getItem("DEBUG")}catch{}return!r&&typeof process<"u"&&"env"in process&&(r=process.env.DEBUG),r}function tg(){try{return localStorage}catch{}}ui.exports=Zo()(dt);var{formatters:rg}=ui.exports;rg.j=function(r){try{return JSON.stringify(r)}catch(e){return"[UnexpectedJSONParseError]: "+e.message}}});var bu=F((dw,vu)=>{"use strict";vu.exports=(r,e=process.argv)=>{let t=r.startsWith("-")?"":r.length===1?"-":"--",n=e.indexOf(t+r),s=e.indexOf("--");return n!==-1&&(s===-1||n<s)}});var Ou=F((pw,Tu)=>{"use strict";var ng=require("os"),Su=require("tty"),Ct=bu(),{env:Qe}=process,Rr;Ct("no-color")||Ct("no-colors")||Ct("color=false")||Ct("color=never")?Rr=0:(Ct("color")||Ct("colors")||Ct("color=true")||Ct("color=always"))&&(Rr=1);"FORCE_COLOR"in Qe&&(Qe.FORCE_COLOR==="true"?Rr=1:Qe.FORCE_COLOR==="false"?Rr=0:Rr=Qe.FORCE_COLOR.length===0?1:Math.min(parseInt(Qe.FORCE_COLOR,10),3));function Qo(r){return r===0?!1:{level:r,hasBasic:!0,has256:r>=2,has16m:r>=3}}function ea(r,e){if(Rr===0)return 0;if(Ct("color=16m")||Ct("color=full")||Ct("color=truecolor"))return 3;if(Ct("color=256"))return 2;if(r&&!e&&Rr===void 0)return 0;let t=Rr||0;if(Qe.TERM==="dumb")return t;if(process.platform==="win32"){let n=ng.release().split(".");return Number(n[0])>=10&&Number(n[2])>=10586?Number(n[2])>=14931?3:2:1}if("CI"in Qe)return["TRAVIS","CIRCLECI","APPVEYOR","GITLAB_CI","GITHUB_ACTIONS","BUILDKITE"].some(n=>n in Qe)||Qe.CI_NAME==="codeship"?1:t;if("TEAMCITY_VERSION"in Qe)return/^(9\.(0*[1-9]\d*)\.|\d{2,}\.)/.test(Qe.TEAMCITY_VERSION)?1:0;if(Qe.COLORTERM==="truecolor")return 3;if("TERM_PROGRAM"in Qe){let n=parseInt((Qe.TERM_PROGRAM_VERSION||"").split(".")[0],10);switch(Qe.TERM_PROGRAM){case"iTerm.app":return n>=3?3:2;case"Apple_Terminal":return 2}}return/-256(color)?$/i.test(Qe.TERM)?2:/^screen|^xterm|^vt100|^vt220|^rxvt|color|ansi|cygwin|linux/i.test(Qe.TERM)||"COLORTERM"in Qe?1:t}function sg(r){let e=ea(r,r&&r.isTTY);return Qo(e)}Tu.exports={supportsColor:sg,stdout:Qo(ea(!0,Su.isatty(1))),stderr:Qo(ea(!0,Su.isatty(2)))}});var ku=F((et,hi)=>{var ig=require("tty"),li=require("util");et.init=hg;et.log=fg;et.formatArgs=ag;et.save=ug;et.load=lg;et.useColors=og;et.destroy=li.deprecate(()=>{},"Instance method `debug.destroy()` is deprecated and no longer does anything. It will be removed in the next major version of `debug`.");et.colors=[6,2,3,4,5,1];try{let r=Ou();r&&(r.stderr||r).level>=2&&(et.colors=[20,21,26,27,32,33,38,39,40,41,42,43,44,45,56,57,62,63,68,69,74,75,76,77,78,79,80,81,92,93,98,99,112,113,128,129,134,135,148,149,160,161,162,163,164,165,166,167,168,169,170,171,172,173,178,179,184,185,196,197,198,199,200,201,202,203,204,205,206,207,208,209,214,215,220,221])}catch{}et.inspectOpts=Object.keys(process.env).filter(r=>/^debug_/i.test(r)).reduce((r,e)=>{let t=e.substring(6).toLowerCase().replace(/_([a-z])/g,(s,i)=>i.toUpperCase()),n=process.env[e];return/^(yes|on|true|enabled)$/i.test(n)?n=!0:/^(no|off|false|disabled)$/i.test(n)?n=!1:n==="null"?n=null:n=Number(n),r[t]=n,r},{});function og(){return"colors"in et.inspectOpts?!!et.inspectOpts.colors:ig.isatty(process.stderr.fd)}function ag(r){let{namespace:e,useColors:t}=this;if(t){let n=this.color,s="\x1B[3"+(n<8?n:"8;5;"+n),i=` ${s};1m${e} \x1B[0m`;r[0]=i+r[0].split(`
|
|
15
|
+
`)}scheduleStatusUpdate(e,t){let n=this.states.get(e);n&&n.status!==t&&(n.pendingUpdate&&clearTimeout(n.pendingUpdate),n.pendingUpdate=setTimeout(()=>{this.emitStatus(e,t),n.pendingUpdate=null},ns.DEBOUNCE_MS))}emitStatus(e,t){let n=this.states.get(e);if(!n||n.status===t)return;n.status=t,n.lastUpdate=Date.now();let s;t==="waiting"&&(s=this.detectPrompt(n.outputBuffer)||void 0),this.onStatusChange(e,t,s)}resetWorkingTimeout(e,t){t.workingTimeout&&clearTimeout(t.workingTimeout),t.status==="working"&&(t.workingTimeout=setTimeout(()=>{let n=this.states.get(e);n&&n.status==="working"&&(this.analyzeOutput(n.outputBuffer)==="waiting"?this.emitStatus(e,"waiting"):this.onStatusChange(e,"working",void 0))},ns.WORKING_TIMEOUT_MS))}forceStatus(e,t){this.emitStatus(e,t)}getStatus(e){return this.states.get(e)?.status??null}dispose(){for(let e of this.states.keys())this.stopTracking(e)}};ri.StatusDetector=Po});var Hf=D((GE,Wf)=>{var vn=require("fs"),qf=require("url"),Sp=require("child_process").spawn;Wf.exports=Ro;Ro.XMLHttpRequest=Ro;function Ro(r){"use strict";r=r||{};var e=this,t=require("http"),n=require("https"),s,i,a={},f=!1,u={"User-Agent":"node-XMLHttpRequest",Accept:"*/*"},d=Object.assign({},u),g=["accept-charset","accept-encoding","access-control-request-headers","access-control-request-method","connection","content-length","content-transfer-encoding","cookie","cookie2","date","expect","host","keep-alive","origin","referer","te","trailer","transfer-encoding","upgrade","via"],_=["TRACE","TRACK","CONNECT"],y=!1,v=!1,S=!1,C={};this.UNSENT=0,this.OPENED=1,this.HEADERS_RECEIVED=2,this.LOADING=3,this.DONE=4,this.readyState=this.UNSENT,this.onreadystatechange=null,this.responseText="",this.responseXML="",this.response=Buffer.alloc(0),this.status=null,this.statusText=null;var H=function(T){return f||T&&g.indexOf(T.toLowerCase())===-1},z=function(T){return T&&_.indexOf(T)===-1};this.open=function(T,M,Q,B,ie){if(this.abort(),v=!1,S=!1,!z(T))throw new Error("SecurityError: Request method not allowed");a={method:T,url:M.toString(),async:typeof Q!="boolean"?!0:Q,user:B||null,password:ie||null},X(this.OPENED)},this.setDisableHeaderCheck=function(T){f=T},this.setRequestHeader=function(T,M){if(this.readyState!=this.OPENED)throw new Error("INVALID_STATE_ERR: setRequestHeader can only be called when state is OPEN");if(!H(T))return console.warn('Refused to set unsafe header "'+T+'"'),!1;if(y)throw new Error("INVALID_STATE_ERR: send flag is true");return d[T]=M,!0},this.getResponseHeader=function(T){return typeof T=="string"&&this.readyState>this.OPENED&&i.headers[T.toLowerCase()]&&!v?i.headers[T.toLowerCase()]:null},this.getAllResponseHeaders=function(){if(this.readyState<this.HEADERS_RECEIVED||v)return"";var T="";for(var M in i.headers)M!=="set-cookie"&&M!=="set-cookie2"&&(T+=M+": "+i.headers[M]+`\r
|
|
16
|
+
`);return T.substr(0,T.length-2)},this.getRequestHeader=function(T){return typeof T=="string"&&d[T]?d[T]:""},this.send=function(T){if(this.readyState!=this.OPENED)throw new Error("INVALID_STATE_ERR: connection must be opened before send() is called");if(y)throw new Error("INVALID_STATE_ERR: send has already been called");var M=!1,Q=!1,B=qf.parse(a.url),ie;switch(B.protocol){case"https:":M=!0;case"http:":ie=B.hostname;break;case"file:":Q=!0;break;case void 0:case"":ie="localhost";break;default:throw new Error("Protocol not supported.")}if(Q){if(a.method!=="GET")throw new Error("XMLHttpRequest: Only GET method is supported");if(a.async)vn.readFile(unescape(B.pathname),function(A,oe){A?e.handleError(A,A.errno||-1):(e.status=200,e.responseText=oe.toString("utf8"),e.response=oe,X(e.DONE))});else try{this.response=vn.readFileSync(unescape(B.pathname)),this.responseText=this.response.toString("utf8"),this.status=200,X(e.DONE)}catch(A){this.handleError(A,A.errno||-1)}return}var he=B.port||(M?443:80),de=B.pathname+(B.search?B.search:"");if(d.Host=ie,M&&he===443||he===80||(d.Host+=":"+B.port),a.user){typeof a.password>"u"&&(a.password="");var Pe=new Buffer(a.user+":"+a.password);d.Authorization="Basic "+Pe.toString("base64")}if(a.method==="GET"||a.method==="HEAD")T=null;else if(T){d["Content-Length"]=Buffer.isBuffer(T)?T.length:Buffer.byteLength(T);var We=Object.keys(d);We.some(function(A){return A.toLowerCase()==="content-type"})||(d["Content-Type"]="text/plain;charset=UTF-8")}else a.method==="POST"&&(d["Content-Length"]=0);var Ge=r.agent||!1,ve={host:ie,port:he,path:de,method:a.method,headers:d,agent:Ge};if(M&&(ve.pfx=r.pfx,ve.key=r.key,ve.passphrase=r.passphrase,ve.cert=r.cert,ve.ca=r.ca,ve.ciphers=r.ciphers,ve.rejectUnauthorized=r.rejectUnauthorized!==!1),v=!1,a.async){var Ye=M?n.request:t.request;y=!0,e.dispatchEvent("readystatechange");var Fe=function(A){if(i=A,i.statusCode===302||i.statusCode===303||i.statusCode===307){a.url=i.headers.location;var oe=qf.parse(a.url);ie=oe.hostname;var Ae={hostname:oe.hostname,port:oe.port,path:oe.path,method:i.statusCode===303?"GET":a.method,headers:d};M&&(Ae.pfx=r.pfx,Ae.key=r.key,Ae.passphrase=r.passphrase,Ae.cert=r.cert,Ae.ca=r.ca,Ae.ciphers=r.ciphers,Ae.rejectUnauthorized=r.rejectUnauthorized!==!1),s=Ye(Ae,Fe).on("error",J),s.end();return}X(e.HEADERS_RECEIVED),e.status=i.statusCode,i.on("data",function(ut){if(ut){var mt=Buffer.from(ut);e.response=Buffer.concat([e.response,mt])}y&&X(e.LOADING)}),i.on("end",function(){y&&(y=!1,X(e.DONE),e.responseText=e.response.toString("utf8"))}),i.on("error",function(ut){e.handleError(ut)})},J=function(A){if(s.reusedSocket&&A.code==="ECONNRESET")return Ye(ve,Fe).on("error",J);e.handleError(A)};s=Ye(ve,Fe).on("error",J),r.autoUnref&&s.on("socket",A=>{A.unref()}),T&&s.write(T),s.end(),e.dispatchEvent("loadstart")}else{var Ee=".node-xmlhttprequest-content-"+process.pid,pe=".node-xmlhttprequest-sync-"+process.pid;vn.writeFileSync(pe,"","utf8");for(var nt="var http = require('http'), https = require('https'), fs = require('fs');var doRequest = http"+(M?"s":"")+".request;var options = "+JSON.stringify(ve)+";var responseText = '';var responseData = Buffer.alloc(0);var req = doRequest(options, function(response) {response.on('data', function(chunk) { var data = Buffer.from(chunk); responseText += data.toString('utf8'); responseData = Buffer.concat([responseData, data]);});response.on('end', function() {fs.writeFileSync('"+Ee+"', JSON.stringify({err: null, data: {statusCode: response.statusCode, headers: response.headers, text: responseText, data: responseData.toString('base64')}}), 'utf8');fs.unlinkSync('"+pe+"');});response.on('error', function(error) {fs.writeFileSync('"+Ee+"', 'NODE-XMLHTTPREQUEST-ERROR:' + JSON.stringify(error), 'utf8');fs.unlinkSync('"+pe+"');});}).on('error', function(error) {fs.writeFileSync('"+Ee+"', 'NODE-XMLHTTPREQUEST-ERROR:' + JSON.stringify(error), 'utf8');fs.unlinkSync('"+pe+"');});"+(T?"req.write('"+JSON.stringify(T).slice(1,-1).replace(/'/g,"\\'")+"');":"")+"req.end();",Ze=Sp(process.argv[0],["-e",nt]),Wt;vn.existsSync(pe););if(e.responseText=vn.readFileSync(Ee,"utf8"),Ze.stdin.end(),vn.unlinkSync(Ee),e.responseText.match(/^NODE-XMLHTTPREQUEST-ERROR:/)){var L=JSON.parse(e.responseText.replace(/^NODE-XMLHTTPREQUEST-ERROR:/,""));e.handleError(L,503)}else{e.status=e.responseText.replace(/^NODE-XMLHTTPREQUEST-STATUS:([0-9]*),.*/,"$1");var j=JSON.parse(e.responseText.replace(/^NODE-XMLHTTPREQUEST-STATUS:[0-9]*,(.*)/,"$1"));i={statusCode:e.status,headers:j.data.headers},e.responseText=j.data.text,e.response=Buffer.from(j.data.data,"base64"),X(e.DONE,!0)}}},this.handleError=function(T,M){this.status=M||0,this.statusText=T,this.responseText=T.stack,v=!0,X(this.DONE)},this.abort=function(){s&&(s.abort(),s=null),d=Object.assign({},u),this.responseText="",this.responseXML="",this.response=Buffer.alloc(0),v=S=!0,this.readyState!==this.UNSENT&&(this.readyState!==this.OPENED||y)&&this.readyState!==this.DONE&&(y=!1,X(this.DONE)),this.readyState=this.UNSENT},this.addEventListener=function(T,M){T in C||(C[T]=[]),C[T].push(M)},this.removeEventListener=function(T,M){T in C&&(C[T]=C[T].filter(function(Q){return Q!==M}))},this.dispatchEvent=function(T){if(typeof e["on"+T]=="function"&&(this.readyState===this.DONE&&a.async?setTimeout(function(){e["on"+T]()},0):e["on"+T]()),T in C)for(let M=0,Q=C[T].length;M<Q;M++)this.readyState===this.DONE?setTimeout(function(){C[T][M].call(e)},0):C[T][M].call(e)};var X=function(T){if(!(e.readyState===T||e.readyState===e.UNSENT&&S)&&(e.readyState=T,(a.async||e.readyState<e.OPENED||e.readyState===e.DONE)&&e.dispatchEvent("readystatechange"),e.readyState===e.DONE)){let M;S?M="abort":v?M="error":M="load",e.dispatchEvent(M),e.dispatchEvent("loadend")}}}});var ni=D(Cr=>{"use strict";Object.defineProperty(Cr,"__esModule",{value:!0});Cr.ERROR_PACKET=Cr.PACKET_TYPES_REVERSE=Cr.PACKET_TYPES=void 0;var Gt=Object.create(null);Cr.PACKET_TYPES=Gt;Gt.open="0";Gt.close="1";Gt.ping="2";Gt.pong="3";Gt.message="4";Gt.upgrade="5";Gt.noop="6";var Vf=Object.create(null);Cr.PACKET_TYPES_REVERSE=Vf;Object.keys(Gt).forEach(r=>{Vf[Gt[r]]=r});var Tp={type:"error",data:"parser error"};Cr.ERROR_PACKET=Tp});var $f=D(xn=>{"use strict";Object.defineProperty(xn,"__esModule",{value:!0});xn.encodePacket=void 0;xn.encodePacketToBinary=kp;var Op=ni(),Cp=({type:r,data:e},t,n)=>e instanceof ArrayBuffer||ArrayBuffer.isView(e)?n(t?e:"b"+Kf(e,!0).toString("base64")):n(Op.PACKET_TYPES[r]+(e||""));xn.encodePacket=Cp;var Kf=(r,e)=>Buffer.isBuffer(r)||r instanceof Uint8Array&&!e?r:r instanceof ArrayBuffer?Buffer.from(r):Buffer.from(r.buffer,r.byteOffset,r.byteLength),Ao;function kp(r,e){if(r.data instanceof ArrayBuffer||ArrayBuffer.isView(r.data))return e(Kf(r.data,!1));(0,xn.encodePacket)(r,!0,t=>{Ao||(Ao=new TextEncoder),e(Ao.encode(t))})}});var Gf=D(ii=>{"use strict";Object.defineProperty(ii,"__esModule",{value:!0});ii.decodePacket=void 0;var si=ni(),Pp=(r,e)=>{if(typeof r!="string")return{type:"message",data:zf(r,e)};let t=r.charAt(0);if(t==="b"){let n=Buffer.from(r.substring(1),"base64");return{type:"message",data:zf(n,e)}}return si.PACKET_TYPES_REVERSE[t]?r.length>1?{type:si.PACKET_TYPES_REVERSE[t],data:r.substring(1)}:{type:si.PACKET_TYPES_REVERSE[t]}:si.ERROR_PACKET};ii.decodePacket=Pp;var zf=(r,e)=>e==="arraybuffer"?r instanceof ArrayBuffer?r:Buffer.isBuffer(r)?r.buffer.slice(r.byteOffset,r.byteOffset+r.byteLength):r.buffer:Buffer.isBuffer(r)?r:Buffer.from(r)});var bn=D(pt=>{"use strict";Object.defineProperty(pt,"__esModule",{value:!0});pt.decodePayload=pt.decodePacket=pt.encodePayload=pt.encodePacket=pt.protocol=void 0;pt.createPacketEncoderStream=Ip;pt.createPacketDecoderStream=Lp;var Lo=$f();Object.defineProperty(pt,"encodePacket",{enumerable:!0,get:function(){return Lo.encodePacket}});var No=Gf();Object.defineProperty(pt,"decodePacket",{enumerable:!0,get:function(){return No.decodePacket}});var Yf=ni(),Xf="",Rp=(r,e)=>{let t=r.length,n=new Array(t),s=0;r.forEach((i,a)=>{(0,Lo.encodePacket)(i,!1,f=>{n[a]=f,++s===t&&e(n.join(Xf))})})};pt.encodePayload=Rp;var Ap=(r,e)=>{let t=r.split(Xf),n=[];for(let s=0;s<t.length;s++){let i=(0,No.decodePacket)(t[s],e);if(n.push(i),i.type==="error")break}return n};pt.decodePayload=Ap;function Ip(){return new TransformStream({transform(r,e){(0,Lo.encodePacketToBinary)(r,t=>{let n=t.length,s;if(n<126)s=new Uint8Array(1),new DataView(s.buffer).setUint8(0,n);else if(n<65536){s=new Uint8Array(3);let i=new DataView(s.buffer);i.setUint8(0,126),i.setUint16(1,n)}else{s=new Uint8Array(9);let i=new DataView(s.buffer);i.setUint8(0,127),i.setBigUint64(1,BigInt(n))}r.data&&typeof r.data!="string"&&(s[0]|=128),e.enqueue(s),e.enqueue(t)})}})}var Io;function oi(r){return r.reduce((e,t)=>e+t.length,0)}function ai(r,e){if(r[0].length===e)return r.shift();let t=new Uint8Array(e),n=0;for(let s=0;s<e;s++)t[s]=r[0][n++],n===r[0].length&&(r.shift(),n=0);return r.length&&n<r[0].length&&(r[0]=r[0].slice(n)),t}function Lp(r,e){Io||(Io=new TextDecoder);let t=[],n=0,s=-1,i=!1;return new TransformStream({transform(a,f){for(t.push(a);;){if(n===0){if(oi(t)<1)break;let u=ai(t,1);i=(u[0]&128)===128,s=u[0]&127,s<126?n=3:s===126?n=1:n=2}else if(n===1){if(oi(t)<2)break;let u=ai(t,2);s=new DataView(u.buffer,u.byteOffset,u.length).getUint16(0),n=3}else if(n===2){if(oi(t)<8)break;let u=ai(t,8),d=new DataView(u.buffer,u.byteOffset,u.length),g=d.getUint32(0);if(g>Math.pow(2,21)-1){f.enqueue(Yf.ERROR_PACKET);break}s=g*Math.pow(2,32)+d.getUint32(4),n=3}else{if(oi(t)<s)break;let u=ai(t,s);f.enqueue((0,No.decodePacket)(i?u:Io.decode(u),e)),n=0}if(s===0||s>r){f.enqueue(Yf.ERROR_PACKET);break}}}})}pt.protocol=4});var Yr=D(Jf=>{Jf.Emitter=ht;function ht(r){if(r)return Np(r)}function Np(r){for(var e in ht.prototype)r[e]=ht.prototype[e];return r}ht.prototype.on=ht.prototype.addEventListener=function(r,e){return this._callbacks=this._callbacks||{},(this._callbacks["$"+r]=this._callbacks["$"+r]||[]).push(e),this};ht.prototype.once=function(r,e){function t(){this.off(r,t),e.apply(this,arguments)}return t.fn=e,this.on(r,t),this};ht.prototype.off=ht.prototype.removeListener=ht.prototype.removeAllListeners=ht.prototype.removeEventListener=function(r,e){if(this._callbacks=this._callbacks||{},arguments.length==0)return this._callbacks={},this;var t=this._callbacks["$"+r];if(!t)return this;if(arguments.length==1)return delete this._callbacks["$"+r],this;for(var n,s=0;s<t.length;s++)if(n=t[s],n===e||n.fn===e){t.splice(s,1);break}return t.length===0&&delete this._callbacks["$"+r],this};ht.prototype.emit=function(r){this._callbacks=this._callbacks||{};for(var e=new Array(arguments.length-1),t=this._callbacks["$"+r],n=1;n<arguments.length;n++)e[n-1]=arguments[n];if(t){t=t.slice(0);for(var n=0,s=t.length;n<s;++n)t[n].apply(this,e)}return this};ht.prototype.emitReserved=ht.prototype.emit;ht.prototype.listeners=function(r){return this._callbacks=this._callbacks||{},this._callbacks["$"+r]||[]};ht.prototype.hasListeners=function(r){return!!this.listeners(r).length}});var Xr=D(Ct=>{"use strict";Object.defineProperty(Ct,"__esModule",{value:!0});Ct.CookieJar=Ct.defaultBinaryType=Ct.globalThisShim=Ct.nextTick=void 0;Ct.createCookieJar=Dp;Ct.parse=Zf;Ct.nextTick=process.nextTick;Ct.globalThisShim=global;Ct.defaultBinaryType="nodebuffer";function Dp(){return new ci}function Zf(r){let e=r.split("; "),t=e[0].indexOf("=");if(t===-1)return;let n=e[0].substring(0,t).trim();if(!n.length)return;let s=e[0].substring(t+1).trim();s.charCodeAt(0)===34&&(s=s.slice(1,-1));let i={name:n,value:s};for(let a=1;a<e.length;a++){let f=e[a].split("=");if(f.length!==2)continue;let u=f[0].trim(),d=f[1].trim();switch(u){case"Expires":i.expires=new Date(d);break;case"Max-Age":let g=new Date;g.setUTCSeconds(g.getUTCSeconds()+parseInt(d,10)),i.expires=g;break;default:}}return i}var ci=class{constructor(){this._cookies=new Map}parseCookies(e){e&&e.forEach(t=>{let n=Zf(t);n&&this._cookies.set(n.name,n)})}get cookies(){let e=Date.now();return this._cookies.forEach((t,n)=>{var s;((s=t.expires)===null||s===void 0?void 0:s.getTime())<e&&this._cookies.delete(n)}),this._cookies.entries()}addCookies(e){let t=[];for(let[n,s]of this.cookies)t.push(`${n}=${s.value}`);t.length&&(e.setDisableHeaderCheck(!0),e.setRequestHeader("cookie",t.join("; ")))}appendCookies(e){for(let[t,n]of this.cookies)e.append("cookie",`${t}=${n.value}`)}};Ct.CookieJar=ci});var Jr=D(Sn=>{"use strict";Object.defineProperty(Sn,"__esModule",{value:!0});Sn.pick=Fp;Sn.installTimerFunctions=jp;Sn.byteLength=qp;Sn.randomString=Hp;var kr=Xr();function Fp(r,...e){return e.reduce((t,n)=>(r.hasOwnProperty(n)&&(t[n]=r[n]),t),{})}var Mp=kr.globalThisShim.setTimeout,Bp=kr.globalThisShim.clearTimeout;function jp(r,e){e.useNativeTimers?(r.setTimeoutFn=Mp.bind(kr.globalThisShim),r.clearTimeoutFn=Bp.bind(kr.globalThisShim)):(r.setTimeoutFn=kr.globalThisShim.setTimeout.bind(kr.globalThisShim),r.clearTimeoutFn=kr.globalThisShim.clearTimeout.bind(kr.globalThisShim))}var Up=1.33;function qp(r){return typeof r=="string"?Wp(r):Math.ceil((r.byteLength||r.size)*Up)}function Wp(r){let e=0,t=0;for(let n=0,s=r.length;n<s;n++)e=r.charCodeAt(n),e<128?t+=1:e<2048?t+=2:e<55296||e>=57344?t+=3:(n++,t+=4);return t}function Hp(){return Date.now().toString(36).substring(3)+Math.random().toString(36).substring(2,5)}});var Do=D(fi=>{"use strict";Object.defineProperty(fi,"__esModule",{value:!0});fi.encode=Vp;fi.decode=Kp;function Vp(r){let e="";for(let t in r)r.hasOwnProperty(t)&&(e.length&&(e+="&"),e+=encodeURIComponent(t)+"="+encodeURIComponent(r[t]));return e}function Kp(r){let e={},t=r.split("&");for(let n=0,s=t.length;n<s;n++){let i=t[n].split("=");e[decodeURIComponent(i[0])]=decodeURIComponent(i[1])}return e}});var eu=D((nw,Qf)=>{var Tn=1e3,On=Tn*60,Cn=On*60,Zr=Cn*24,$p=Zr*7,zp=Zr*365.25;Qf.exports=function(r,e){e=e||{};var t=typeof r;if(t==="string"&&r.length>0)return Gp(r);if(t==="number"&&isFinite(r))return e.long?Xp(r):Yp(r);throw new Error("val is not a non-empty string or a valid number. val="+JSON.stringify(r))};function Gp(r){if(r=String(r),!(r.length>100)){var e=/^(-?(?:\d+)?\.?\d+) *(milliseconds?|msecs?|ms|seconds?|secs?|s|minutes?|mins?|m|hours?|hrs?|h|days?|d|weeks?|w|years?|yrs?|y)?$/i.exec(r);if(e){var t=parseFloat(e[1]),n=(e[2]||"ms").toLowerCase();switch(n){case"years":case"year":case"yrs":case"yr":case"y":return t*zp;case"weeks":case"week":case"w":return t*$p;case"days":case"day":case"d":return t*Zr;case"hours":case"hour":case"hrs":case"hr":case"h":return t*Cn;case"minutes":case"minute":case"mins":case"min":case"m":return t*On;case"seconds":case"second":case"secs":case"sec":case"s":return t*Tn;case"milliseconds":case"millisecond":case"msecs":case"msec":case"ms":return t;default:return}}}}function Yp(r){var e=Math.abs(r);return e>=Zr?Math.round(r/Zr)+"d":e>=Cn?Math.round(r/Cn)+"h":e>=On?Math.round(r/On)+"m":e>=Tn?Math.round(r/Tn)+"s":r+"ms"}function Xp(r){var e=Math.abs(r);return e>=Zr?ui(r,e,Zr,"day"):e>=Cn?ui(r,e,Cn,"hour"):e>=On?ui(r,e,On,"minute"):e>=Tn?ui(r,e,Tn,"second"):r+" ms"}function ui(r,e,t,n){var s=e>=t*1.5;return Math.round(r/t)+" "+n+(s?"s":"")}});var Fo=D((sw,tu)=>{function Jp(r){t.debug=t,t.default=t,t.coerce=u,t.disable=a,t.enable=s,t.enabled=f,t.humanize=eu(),t.destroy=d,Object.keys(r).forEach(g=>{t[g]=r[g]}),t.names=[],t.skips=[],t.formatters={};function e(g){let _=0;for(let y=0;y<g.length;y++)_=(_<<5)-_+g.charCodeAt(y),_|=0;return t.colors[Math.abs(_)%t.colors.length]}t.selectColor=e;function t(g){let _,y=null,v,S;function C(...H){if(!C.enabled)return;let z=C,X=Number(new Date),T=X-(_||X);z.diff=T,z.prev=_,z.curr=X,_=X,H[0]=t.coerce(H[0]),typeof H[0]!="string"&&H.unshift("%O");let M=0;H[0]=H[0].replace(/%([a-zA-Z%])/g,(B,ie)=>{if(B==="%%")return"%";M++;let he=t.formatters[ie];if(typeof he=="function"){let de=H[M];B=he.call(z,de),H.splice(M,1),M--}return B}),t.formatArgs.call(z,H),(z.log||t.log).apply(z,H)}return C.namespace=g,C.useColors=t.useColors(),C.color=t.selectColor(g),C.extend=n,C.destroy=t.destroy,Object.defineProperty(C,"enabled",{enumerable:!0,configurable:!1,get:()=>y!==null?y:(v!==t.namespaces&&(v=t.namespaces,S=t.enabled(g)),S),set:H=>{y=H}}),typeof t.init=="function"&&t.init(C),C}function n(g,_){let y=t(this.namespace+(typeof _>"u"?":":_)+g);return y.log=this.log,y}function s(g){t.save(g),t.namespaces=g,t.names=[],t.skips=[];let _=(typeof g=="string"?g:"").trim().replace(/\s+/g,",").split(",").filter(Boolean);for(let y of _)y[0]==="-"?t.skips.push(y.slice(1)):t.names.push(y)}function i(g,_){let y=0,v=0,S=-1,C=0;for(;y<g.length;)if(v<_.length&&(_[v]===g[y]||_[v]==="*"))_[v]==="*"?(S=v,C=y,v++):(y++,v++);else if(S!==-1)v=S+1,C++,y=C;else return!1;for(;v<_.length&&_[v]==="*";)v++;return v===_.length}function a(){let g=[...t.names,...t.skips.map(_=>"-"+_)].join(",");return t.enable(""),g}function f(g){for(let _ of t.skips)if(i(g,_))return!1;for(let _ of t.names)if(i(g,_))return!0;return!1}function u(g){return g instanceof Error?g.stack||g.message:g}function d(){console.warn("Instance method `debug.destroy()` is deprecated and no longer does anything. It will be removed in the next major version of `debug`.")}return t.enable(t.load()),t}tu.exports=Jp});var ru=D((gt,li)=>{gt.formatArgs=Qp;gt.save=eg;gt.load=tg;gt.useColors=Zp;gt.storage=rg();gt.destroy=(()=>{let r=!1;return()=>{r||(r=!0,console.warn("Instance method `debug.destroy()` is deprecated and no longer does anything. It will be removed in the next major version of `debug`."))}})();gt.colors=["#0000CC","#0000FF","#0033CC","#0033FF","#0066CC","#0066FF","#0099CC","#0099FF","#00CC00","#00CC33","#00CC66","#00CC99","#00CCCC","#00CCFF","#3300CC","#3300FF","#3333CC","#3333FF","#3366CC","#3366FF","#3399CC","#3399FF","#33CC00","#33CC33","#33CC66","#33CC99","#33CCCC","#33CCFF","#6600CC","#6600FF","#6633CC","#6633FF","#66CC00","#66CC33","#9900CC","#9900FF","#9933CC","#9933FF","#99CC00","#99CC33","#CC0000","#CC0033","#CC0066","#CC0099","#CC00CC","#CC00FF","#CC3300","#CC3333","#CC3366","#CC3399","#CC33CC","#CC33FF","#CC6600","#CC6633","#CC9900","#CC9933","#CCCC00","#CCCC33","#FF0000","#FF0033","#FF0066","#FF0099","#FF00CC","#FF00FF","#FF3300","#FF3333","#FF3366","#FF3399","#FF33CC","#FF33FF","#FF6600","#FF6633","#FF9900","#FF9933","#FFCC00","#FFCC33"];function Zp(){if(typeof window<"u"&&window.process&&(window.process.type==="renderer"||window.process.__nwjs))return!0;if(typeof navigator<"u"&&navigator.userAgent&&navigator.userAgent.toLowerCase().match(/(edge|trident)\/(\d+)/))return!1;let r;return typeof document<"u"&&document.documentElement&&document.documentElement.style&&document.documentElement.style.WebkitAppearance||typeof window<"u"&&window.console&&(window.console.firebug||window.console.exception&&window.console.table)||typeof navigator<"u"&&navigator.userAgent&&(r=navigator.userAgent.toLowerCase().match(/firefox\/(\d+)/))&&parseInt(r[1],10)>=31||typeof navigator<"u"&&navigator.userAgent&&navigator.userAgent.toLowerCase().match(/applewebkit\/(\d+)/)}function Qp(r){if(r[0]=(this.useColors?"%c":"")+this.namespace+(this.useColors?" %c":" ")+r[0]+(this.useColors?"%c ":" ")+"+"+li.exports.humanize(this.diff),!this.useColors)return;let e="color: "+this.color;r.splice(1,0,e,"color: inherit");let t=0,n=0;r[0].replace(/%[a-zA-Z%]/g,s=>{s!=="%%"&&(t++,s==="%c"&&(n=t))}),r.splice(n,0,e)}gt.log=console.debug||console.log||(()=>{});function eg(r){try{r?gt.storage.setItem("debug",r):gt.storage.removeItem("debug")}catch{}}function tg(){let r;try{r=gt.storage.getItem("debug")||gt.storage.getItem("DEBUG")}catch{}return!r&&typeof process<"u"&&"env"in process&&(r=process.env.DEBUG),r}function rg(){try{return localStorage}catch{}}li.exports=Fo()(gt);var{formatters:ng}=li.exports;ng.j=function(r){try{return JSON.stringify(r)}catch(e){return"[UnexpectedJSONParseError]: "+e.message}}});var su=D((iw,nu)=>{"use strict";nu.exports=(r,e=process.argv)=>{let t=r.startsWith("-")?"":r.length===1?"-":"--",n=e.indexOf(t+r),s=e.indexOf("--");return n!==-1&&(s===-1||n<s)}});var au=D((ow,ou)=>{"use strict";var sg=require("os"),iu=require("tty"),kt=su(),{env:Qe}=process,Pr;kt("no-color")||kt("no-colors")||kt("color=false")||kt("color=never")?Pr=0:(kt("color")||kt("colors")||kt("color=true")||kt("color=always"))&&(Pr=1);"FORCE_COLOR"in Qe&&(Qe.FORCE_COLOR==="true"?Pr=1:Qe.FORCE_COLOR==="false"?Pr=0:Pr=Qe.FORCE_COLOR.length===0?1:Math.min(parseInt(Qe.FORCE_COLOR,10),3));function Mo(r){return r===0?!1:{level:r,hasBasic:!0,has256:r>=2,has16m:r>=3}}function Bo(r,e){if(Pr===0)return 0;if(kt("color=16m")||kt("color=full")||kt("color=truecolor"))return 3;if(kt("color=256"))return 2;if(r&&!e&&Pr===void 0)return 0;let t=Pr||0;if(Qe.TERM==="dumb")return t;if(process.platform==="win32"){let n=sg.release().split(".");return Number(n[0])>=10&&Number(n[2])>=10586?Number(n[2])>=14931?3:2:1}if("CI"in Qe)return["TRAVIS","CIRCLECI","APPVEYOR","GITLAB_CI","GITHUB_ACTIONS","BUILDKITE"].some(n=>n in Qe)||Qe.CI_NAME==="codeship"?1:t;if("TEAMCITY_VERSION"in Qe)return/^(9\.(0*[1-9]\d*)\.|\d{2,}\.)/.test(Qe.TEAMCITY_VERSION)?1:0;if(Qe.COLORTERM==="truecolor")return 3;if("TERM_PROGRAM"in Qe){let n=parseInt((Qe.TERM_PROGRAM_VERSION||"").split(".")[0],10);switch(Qe.TERM_PROGRAM){case"iTerm.app":return n>=3?3:2;case"Apple_Terminal":return 2}}return/-256(color)?$/i.test(Qe.TERM)?2:/^screen|^xterm|^vt100|^vt220|^rxvt|color|ansi|cygwin|linux/i.test(Qe.TERM)||"COLORTERM"in Qe?1:t}function ig(r){let e=Bo(r,r&&r.isTTY);return Mo(e)}ou.exports={supportsColor:ig,stdout:Mo(Bo(!0,iu.isatty(1))),stderr:Mo(Bo(!0,iu.isatty(2)))}});var fu=D((et,di)=>{var og=require("tty"),hi=require("util");et.init=dg;et.log=ug;et.formatArgs=cg;et.save=lg;et.load=hg;et.useColors=ag;et.destroy=hi.deprecate(()=>{},"Instance method `debug.destroy()` is deprecated and no longer does anything. It will be removed in the next major version of `debug`.");et.colors=[6,2,3,4,5,1];try{let r=au();r&&(r.stderr||r).level>=2&&(et.colors=[20,21,26,27,32,33,38,39,40,41,42,43,44,45,56,57,62,63,68,69,74,75,76,77,78,79,80,81,92,93,98,99,112,113,128,129,134,135,148,149,160,161,162,163,164,165,166,167,168,169,170,171,172,173,178,179,184,185,196,197,198,199,200,201,202,203,204,205,206,207,208,209,214,215,220,221])}catch{}et.inspectOpts=Object.keys(process.env).filter(r=>/^debug_/i.test(r)).reduce((r,e)=>{let t=e.substring(6).toLowerCase().replace(/_([a-z])/g,(s,i)=>i.toUpperCase()),n=process.env[e];return/^(yes|on|true|enabled)$/i.test(n)?n=!0:/^(no|off|false|disabled)$/i.test(n)?n=!1:n==="null"?n=null:n=Number(n),r[t]=n,r},{});function ag(){return"colors"in et.inspectOpts?!!et.inspectOpts.colors:og.isatty(process.stderr.fd)}function cg(r){let{namespace:e,useColors:t}=this;if(t){let n=this.color,s="\x1B[3"+(n<8?n:"8;5;"+n),i=` ${s};1m${e} \x1B[0m`;r[0]=i+r[0].split(`
|
|
19
17
|
`).join(`
|
|
20
|
-
`+i),r.push(s+"m+"+
|
|
21
|
-
`)}function
|
|
22
|
-
`).map(e=>e.trim()).join(" ")};Cu.O=function(r){return this.inspectOpts.colors=this.useColors,li.inspect(r,this.inspectOpts)}});var kt=F((gw,ta)=>{typeof process>"u"||process.type==="renderer"||process.browser===!0||process.__nwjs?ta.exports=xu():ta.exports=ku()});var as=F(Ar=>{"use strict";var dg=Ar&&Ar.__importDefault||function(r){return r&&r.__esModule?r:{default:r}};Object.defineProperty(Ar,"__esModule",{value:!0});Ar.Transport=Ar.TransportError=void 0;var pg=xn(),gg=$r(),_g=Gr(),mg=Jo(),yg=dg(kt()),Eg=(0,yg.default)("engine.io-client:transport"),di=class extends Error{constructor(e,t,n){super(e),this.description=t,this.context=n,this.type="TransportError"}};Ar.TransportError=di;var ra=class extends gg.Emitter{constructor(e){super(),this.writable=!1,(0,_g.installTimerFunctions)(this,e),this.opts=e,this.query=e.query,this.socket=e.socket,this.supportsBinary=!e.forceBase64}onError(e,t,n){return super.emitReserved("error",new di(e,t,n)),this}open(){return this.readyState="opening",this.doOpen(),this}close(){return(this.readyState==="opening"||this.readyState==="open")&&(this.doClose(),this.onClose()),this}send(e){this.readyState==="open"?this.write(e):Eg("transport is not open, discarding packets")}onOpen(){this.readyState="open",this.writable=!0,super.emitReserved("open")}onData(e){let t=(0,pg.decodePacket)(e,this.socket.binaryType);this.onPacket(t)}onPacket(e){super.emitReserved("packet",e)}onClose(e){this.readyState="closed",super.emitReserved("close",e)}pause(e){}createUri(e,t={}){return e+"://"+this._hostname()+this._port()+this.opts.path+this._query(t)}_hostname(){let e=this.opts.hostname;return e.indexOf(":")===-1?e:"["+e+"]"}_port(){return this.opts.port&&(this.opts.secure&&Number(this.opts.port)!==443||!this.opts.secure&&Number(this.opts.port)!==80)?":"+this.opts.port:""}_query(e){let t=(0,mg.encode)(e);return t.length?"?"+t:""}};Ar.Transport=ra});var sa=F(On=>{"use strict";var wg=On&&On.__importDefault||function(r){return r&&r.__esModule?r:{default:r}};Object.defineProperty(On,"__esModule",{value:!0});On.Polling=void 0;var xg=as(),vg=Gr(),Pu=xn(),bg=wg(kt()),Lt=(0,bg.default)("engine.io-client:polling"),na=class extends xg.Transport{constructor(){super(...arguments),this._polling=!1}get name(){return"polling"}doOpen(){this._poll()}pause(e){this.readyState="pausing";let t=()=>{Lt("paused"),this.readyState="paused",e()};if(this._polling||!this.writable){let n=0;this._polling&&(Lt("we are currently polling - waiting to pause"),n++,this.once("pollComplete",function(){Lt("pre-pause polling complete"),--n||t()})),this.writable||(Lt("we are currently writing - waiting to pause"),n++,this.once("drain",function(){Lt("pre-pause writing complete"),--n||t()}))}else t()}_poll(){Lt("polling"),this._polling=!0,this.doPoll(),this.emitReserved("poll")}onData(e){Lt("polling got data %s",e);let t=n=>{if(this.readyState==="opening"&&n.type==="open"&&this.onOpen(),n.type==="close")return this.onClose({description:"transport closed by the server"}),!1;this.onPacket(n)};(0,Pu.decodePayload)(e,this.socket.binaryType).forEach(t),this.readyState!=="closed"&&(this._polling=!1,this.emitReserved("pollComplete"),this.readyState==="open"?this._poll():Lt('ignoring poll - transport state "%s"',this.readyState))}doClose(){let e=()=>{Lt("writing close packet"),this.write([{type:"close"}])};this.readyState==="open"?(Lt("transport open - closing"),e()):(Lt("transport not open - deferring close"),this.once("open",e))}write(e){this.writable=!1,(0,Pu.encodePayload)(e,t=>{this.doWrite(t,()=>{this.writable=!0,this.emitReserved("drain")})})}uri(){let e=this.opts.secure?"https":"http",t=this.query||{};return this.opts.timestampRequests!==!1&&(t[this.opts.timestampParam]=(0,vg.randomString)()),!this.supportsBinary&&!t.sid&&(t.b64=1),this.createUri(e,t)}};On.Polling=na});var Au=F(pi=>{"use strict";Object.defineProperty(pi,"__esModule",{value:!0});pi.hasCORS=void 0;var Ru=!1;try{Ru=typeof XMLHttpRequest<"u"&&"withCredentials"in new XMLHttpRequest}catch{}pi.hasCORS=Ru});var aa=F(Gt=>{"use strict";var Sg=Gt&&Gt.__importDefault||function(r){return r&&r.__esModule?r:{default:r}};Object.defineProperty(Gt,"__esModule",{value:!0});Gt.XHR=Gt.Request=Gt.BaseXHR=void 0;var Tg=sa(),Og=$r(),Iu=Gr(),Lu=zr(),Cg=Au(),kg=Sg(kt()),ia=(0,kg.default)("engine.io-client:polling");function Pg(){}var gi=class extends Tg.Polling{constructor(e){if(super(e),typeof location<"u"){let t=location.protocol==="https:",n=location.port;n||(n=t?"443":"80"),this.xd=typeof location<"u"&&e.hostname!==location.hostname||n!==e.port}}doWrite(e,t){let n=this.request({method:"POST",data:e});n.on("success",t),n.on("error",(s,i)=>{this.onError("xhr post error",s,i)})}doPoll(){ia("xhr poll");let e=this.request();e.on("data",this.onData.bind(this)),e.on("error",(t,n)=>{this.onError("xhr poll error",t,n)}),this.pollXhr=e}};Gt.BaseXHR=gi;var fr=class r extends Og.Emitter{constructor(e,t,n){super(),this.createRequest=e,(0,Iu.installTimerFunctions)(this,n),this._opts=n,this._method=n.method||"GET",this._uri=t,this._data=n.data!==void 0?n.data:null,this._create()}_create(){var e;let t=(0,Iu.pick)(this._opts,"agent","pfx","key","passphrase","cert","ca","ciphers","rejectUnauthorized","autoUnref");t.xdomain=!!this._opts.xd;let n=this._xhr=this.createRequest(t);try{ia("xhr open %s: %s",this._method,this._uri),n.open(this._method,this._uri,!0);try{if(this._opts.extraHeaders){n.setDisableHeaderCheck&&n.setDisableHeaderCheck(!0);for(let s in this._opts.extraHeaders)this._opts.extraHeaders.hasOwnProperty(s)&&n.setRequestHeader(s,this._opts.extraHeaders[s])}}catch{}if(this._method==="POST")try{n.setRequestHeader("Content-type","text/plain;charset=UTF-8")}catch{}try{n.setRequestHeader("Accept","*/*")}catch{}(e=this._opts.cookieJar)===null||e===void 0||e.addCookies(n),"withCredentials"in n&&(n.withCredentials=this._opts.withCredentials),this._opts.requestTimeout&&(n.timeout=this._opts.requestTimeout),n.onreadystatechange=()=>{var s;n.readyState===3&&((s=this._opts.cookieJar)===null||s===void 0||s.parseCookies(n.getResponseHeader("set-cookie"))),n.readyState===4&&(n.status===200||n.status===1223?this._onLoad():this.setTimeoutFn(()=>{this._onError(typeof n.status=="number"?n.status:0)},0))},ia("xhr data %s",this._data),n.send(this._data)}catch(s){this.setTimeoutFn(()=>{this._onError(s)},0);return}typeof document<"u"&&(this._index=r.requestsCount++,r.requests[this._index]=this)}_onError(e){this.emitReserved("error",e,this._xhr),this._cleanup(!0)}_cleanup(e){if(!(typeof this._xhr>"u"||this._xhr===null)){if(this._xhr.onreadystatechange=Pg,e)try{this._xhr.abort()}catch{}typeof document<"u"&&delete r.requests[this._index],this._xhr=null}}_onLoad(){let e=this._xhr.responseText;e!==null&&(this.emitReserved("data",e),this.emitReserved("success"),this._cleanup())}abort(){this._cleanup()}};Gt.Request=fr;fr.requestsCount=0;fr.requests={};if(typeof document<"u"){if(typeof attachEvent=="function")attachEvent("onunload",Nu);else if(typeof addEventListener=="function"){let r="onpagehide"in Lu.globalThisShim?"pagehide":"unload";addEventListener(r,Nu,!1)}}function Nu(){for(let r in fr.requests)fr.requests.hasOwnProperty(r)&&fr.requests[r].abort()}var Rg=(function(){let r=Du({xdomain:!1});return r&&r.responseType!==null})(),oa=class extends gi{constructor(e){super(e);let t=e&&e.forceBase64;this.supportsBinary=Rg&&!t}request(e={}){return Object.assign(e,{xd:this.xd},this.opts),new fr(Du,this.uri(),e)}};Gt.XHR=oa;function Du(r){let e=r.xdomain;try{if(typeof XMLHttpRequest<"u"&&(!e||Cg.hasCORS))return new XMLHttpRequest}catch{}if(!e)try{return new Lu.globalThisShim[["Active"].concat("Object").join("X")]("Microsoft.XMLHTTP")}catch{}}});var fa=F(Yt=>{"use strict";var Ag=Yt&&Yt.__createBinding||(Object.create?(function(r,e,t,n){n===void 0&&(n=t);var s=Object.getOwnPropertyDescriptor(e,t);(!s||("get"in s?!e.__esModule:s.writable||s.configurable))&&(s={enumerable:!0,get:function(){return e[t]}}),Object.defineProperty(r,n,s)}):(function(r,e,t,n){n===void 0&&(n=t),r[n]=e[t]})),Ig=Yt&&Yt.__setModuleDefault||(Object.create?(function(r,e){Object.defineProperty(r,"default",{enumerable:!0,value:e})}):function(r,e){r.default=e}),Ng=Yt&&Yt.__importStar||function(r){if(r&&r.__esModule)return r;var e={};if(r!=null)for(var t in r)t!=="default"&&Object.prototype.hasOwnProperty.call(r,t)&&Ag(e,r,t);return Ig(e,r),e};Object.defineProperty(Yt,"__esModule",{value:!0});Yt.XHR=void 0;var Fu=Ng(cu()),Mu=aa(),Lg=Fu.default||Fu,ca=class extends Mu.BaseXHR{request(e={}){var t;return Object.assign(e,{xd:this.xd,cookieJar:(t=this.socket)===null||t===void 0?void 0:t._cookieJar},this.opts),new Mu.Request(n=>new Lg(n),this.uri(),e)}};Yt.XHR=ca});var ur=F((xw,Uu)=>{"use strict";var Bu=["nodebuffer","arraybuffer","fragments"],ju=typeof Blob<"u";ju&&Bu.push("blob");Uu.exports={BINARY_TYPES:Bu,EMPTY_BUFFER:Buffer.alloc(0),GUID:"258EAFA5-E914-47DA-95CA-C5AB0DC85B11",hasBlob:ju,kForOnEventAttribute:Symbol("kIsForOnEventAttribute"),kListener:Symbol("kListener"),kStatusCode:Symbol("status-code"),kWebSocket:Symbol("websocket"),NOOP:()=>{}}});var cs=F((vw,_i)=>{"use strict";var{EMPTY_BUFFER:Dg}=ur(),ua=Buffer[Symbol.species];function Fg(r,e){if(r.length===0)return Dg;if(r.length===1)return r[0];let t=Buffer.allocUnsafe(e),n=0;for(let s=0;s<r.length;s++){let i=r[s];t.set(i,n),n+=i.length}return n<e?new ua(t.buffer,t.byteOffset,n):t}function qu(r,e,t,n,s){for(let i=0;i<s;i++)t[n+i]=r[i]^e[i&3]}function Wu(r,e){for(let t=0;t<r.length;t++)r[t]^=e[t&3]}function Mg(r){return r.length===r.buffer.byteLength?r.buffer:r.buffer.slice(r.byteOffset,r.byteOffset+r.length)}function la(r){if(la.readOnly=!0,Buffer.isBuffer(r))return r;let e;return r instanceof ArrayBuffer?e=new ua(r):ArrayBuffer.isView(r)?e=new ua(r.buffer,r.byteOffset,r.byteLength):(e=Buffer.from(r),la.readOnly=!1),e}_i.exports={concat:Fg,mask:qu,toArrayBuffer:Mg,toBuffer:la,unmask:Wu};if(!process.env.WS_NO_BUFFER_UTIL)try{let r=require("bufferutil");_i.exports.mask=function(e,t,n,s,i){i<48?qu(e,t,n,s,i):r.mask(e,t,n,s,i)},_i.exports.unmask=function(e,t){e.length<32?Wu(e,t):r.unmask(e,t)}}catch{}});var Ku=F((bw,Vu)=>{"use strict";var Hu=Symbol("kDone"),ha=Symbol("kRun"),da=class{constructor(e){this[Hu]=()=>{this.pending--,this[ha]()},this.concurrency=e||1/0,this.jobs=[],this.pending=0}add(e){this.jobs.push(e),this[ha]()}[ha](){if(this.pending!==this.concurrency&&this.jobs.length){let e=this.jobs.shift();this.pending++,e(this[Hu])}}};Vu.exports=da});var us=F((Sw,Yu)=>{"use strict";var fs=require("zlib"),$u=cs(),Bg=Ku(),{kStatusCode:zu}=ur(),jg=Buffer[Symbol.species],Ug=Buffer.from([0,0,255,255]),yi=Symbol("permessage-deflate"),lr=Symbol("total-length"),Cn=Symbol("callback"),Ir=Symbol("buffers"),kn=Symbol("error"),mi,pa=class{constructor(e,t,n){if(this._maxPayload=n|0,this._options=e||{},this._threshold=this._options.threshold!==void 0?this._options.threshold:1024,this._isServer=!!t,this._deflate=null,this._inflate=null,this.params=null,!mi){let s=this._options.concurrencyLimit!==void 0?this._options.concurrencyLimit:10;mi=new Bg(s)}}static get extensionName(){return"permessage-deflate"}offer(){let e={};return this._options.serverNoContextTakeover&&(e.server_no_context_takeover=!0),this._options.clientNoContextTakeover&&(e.client_no_context_takeover=!0),this._options.serverMaxWindowBits&&(e.server_max_window_bits=this._options.serverMaxWindowBits),this._options.clientMaxWindowBits?e.client_max_window_bits=this._options.clientMaxWindowBits:this._options.clientMaxWindowBits==null&&(e.client_max_window_bits=!0),e}accept(e){return e=this.normalizeParams(e),this.params=this._isServer?this.acceptAsServer(e):this.acceptAsClient(e),this.params}cleanup(){if(this._inflate&&(this._inflate.close(),this._inflate=null),this._deflate){let e=this._deflate[Cn];this._deflate.close(),this._deflate=null,e&&e(new Error("The deflate stream was closed while data was being processed"))}}acceptAsServer(e){let t=this._options,n=e.find(s=>!(t.serverNoContextTakeover===!1&&s.server_no_context_takeover||s.server_max_window_bits&&(t.serverMaxWindowBits===!1||typeof t.serverMaxWindowBits=="number"&&t.serverMaxWindowBits>s.server_max_window_bits)||typeof t.clientMaxWindowBits=="number"&&!s.client_max_window_bits));if(!n)throw new Error("None of the extension offers can be accepted");return t.serverNoContextTakeover&&(n.server_no_context_takeover=!0),t.clientNoContextTakeover&&(n.client_no_context_takeover=!0),typeof t.serverMaxWindowBits=="number"&&(n.server_max_window_bits=t.serverMaxWindowBits),typeof t.clientMaxWindowBits=="number"?n.client_max_window_bits=t.clientMaxWindowBits:(n.client_max_window_bits===!0||t.clientMaxWindowBits===!1)&&delete n.client_max_window_bits,n}acceptAsClient(e){let t=e[0];if(this._options.clientNoContextTakeover===!1&&t.client_no_context_takeover)throw new Error('Unexpected parameter "client_no_context_takeover"');if(!t.client_max_window_bits)typeof this._options.clientMaxWindowBits=="number"&&(t.client_max_window_bits=this._options.clientMaxWindowBits);else if(this._options.clientMaxWindowBits===!1||typeof this._options.clientMaxWindowBits=="number"&&t.client_max_window_bits>this._options.clientMaxWindowBits)throw new Error('Unexpected or invalid parameter "client_max_window_bits"');return t}normalizeParams(e){return e.forEach(t=>{Object.keys(t).forEach(n=>{let s=t[n];if(s.length>1)throw new Error(`Parameter "${n}" must have only a single value`);if(s=s[0],n==="client_max_window_bits"){if(s!==!0){let i=+s;if(!Number.isInteger(i)||i<8||i>15)throw new TypeError(`Invalid value for parameter "${n}": ${s}`);s=i}else if(!this._isServer)throw new TypeError(`Invalid value for parameter "${n}": ${s}`)}else if(n==="server_max_window_bits"){let i=+s;if(!Number.isInteger(i)||i<8||i>15)throw new TypeError(`Invalid value for parameter "${n}": ${s}`);s=i}else if(n==="client_no_context_takeover"||n==="server_no_context_takeover"){if(s!==!0)throw new TypeError(`Invalid value for parameter "${n}": ${s}`)}else throw new Error(`Unknown parameter "${n}"`);t[n]=s})}),e}decompress(e,t,n){mi.add(s=>{this._decompress(e,t,(i,a)=>{s(),n(i,a)})})}compress(e,t,n){mi.add(s=>{this._compress(e,t,(i,a)=>{s(),n(i,a)})})}_decompress(e,t,n){let s=this._isServer?"client":"server";if(!this._inflate){let i=`${s}_max_window_bits`,a=typeof this.params[i]!="number"?fs.Z_DEFAULT_WINDOWBITS:this.params[i];this._inflate=fs.createInflateRaw({...this._options.zlibInflateOptions,windowBits:a}),this._inflate[yi]=this,this._inflate[lr]=0,this._inflate[Ir]=[],this._inflate.on("error",Wg),this._inflate.on("data",Gu)}this._inflate[Cn]=n,this._inflate.write(e),t&&this._inflate.write(Ug),this._inflate.flush(()=>{let i=this._inflate[kn];if(i){this._inflate.close(),this._inflate=null,n(i);return}let a=$u.concat(this._inflate[Ir],this._inflate[lr]);this._inflate._readableState.endEmitted?(this._inflate.close(),this._inflate=null):(this._inflate[lr]=0,this._inflate[Ir]=[],t&&this.params[`${s}_no_context_takeover`]&&this._inflate.reset()),n(null,a)})}_compress(e,t,n){let s=this._isServer?"server":"client";if(!this._deflate){let i=`${s}_max_window_bits`,a=typeof this.params[i]!="number"?fs.Z_DEFAULT_WINDOWBITS:this.params[i];this._deflate=fs.createDeflateRaw({...this._options.zlibDeflateOptions,windowBits:a}),this._deflate[lr]=0,this._deflate[Ir]=[],this._deflate.on("data",qg)}this._deflate[Cn]=n,this._deflate.write(e),this._deflate.flush(fs.Z_SYNC_FLUSH,()=>{if(!this._deflate)return;let i=$u.concat(this._deflate[Ir],this._deflate[lr]);t&&(i=new jg(i.buffer,i.byteOffset,i.length-4)),this._deflate[Cn]=null,this._deflate[lr]=0,this._deflate[Ir]=[],t&&this.params[`${s}_no_context_takeover`]&&this._deflate.reset(),n(null,i)})}};Yu.exports=pa;function qg(r){this[Ir].push(r),this[lr]+=r.length}function Gu(r){if(this[lr]+=r.length,this[yi]._maxPayload<1||this[lr]<=this[yi]._maxPayload){this[Ir].push(r);return}this[kn]=new RangeError("Max payload size exceeded"),this[kn].code="WS_ERR_UNSUPPORTED_MESSAGE_LENGTH",this[kn][zu]=1009,this.removeListener("data",Gu),this.reset()}function Wg(r){if(this[yi]._inflate=null,this[kn]){this[Cn](this[kn]);return}r[zu]=1007,this[Cn](r)}});var Pn=F((Tw,Ei)=>{"use strict";var{isUtf8:Xu}=require("buffer"),{hasBlob:Hg}=ur(),Vg=[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 Kg(r){return r>=1e3&&r<=1014&&r!==1004&&r!==1005&&r!==1006||r>=3e3&&r<=4999}function ga(r){let e=r.length,t=0;for(;t<e;)if((r[t]&128)===0)t++;else if((r[t]&224)===192){if(t+1===e||(r[t+1]&192)!==128||(r[t]&254)===192)return!1;t+=2}else if((r[t]&240)===224){if(t+2>=e||(r[t+1]&192)!==128||(r[t+2]&192)!==128||r[t]===224&&(r[t+1]&224)===128||r[t]===237&&(r[t+1]&224)===160)return!1;t+=3}else if((r[t]&248)===240){if(t+3>=e||(r[t+1]&192)!==128||(r[t+2]&192)!==128||(r[t+3]&192)!==128||r[t]===240&&(r[t+1]&240)===128||r[t]===244&&r[t+1]>143||r[t]>244)return!1;t+=4}else return!1;return!0}function $g(r){return Hg&&typeof r=="object"&&typeof r.arrayBuffer=="function"&&typeof r.type=="string"&&typeof r.stream=="function"&&(r[Symbol.toStringTag]==="Blob"||r[Symbol.toStringTag]==="File")}Ei.exports={isBlob:$g,isValidStatusCode:Kg,isValidUTF8:ga,tokenChars:Vg};if(Xu)Ei.exports.isValidUTF8=function(r){return r.length<24?ga(r):Xu(r)};else if(!process.env.WS_NO_UTF_8_VALIDATE)try{let r=require("utf-8-validate");Ei.exports.isValidUTF8=function(e){return e.length<32?ga(e):r(e)}}catch{}});var wa=F((Ow,nl)=>{"use strict";var{Writable:zg}=require("stream"),Ju=us(),{BINARY_TYPES:Gg,EMPTY_BUFFER:Zu,kStatusCode:Yg,kWebSocket:Xg}=ur(),{concat:_a,toArrayBuffer:Jg,unmask:Zg}=cs(),{isValidStatusCode:Qg,isValidUTF8:Qu}=Pn(),wi=Buffer[Symbol.species],Pt=0,el=1,tl=2,rl=3,ma=4,ya=5,xi=6,Ea=class extends zg{constructor(e={}){super(),this._allowSynchronousEvents=e.allowSynchronousEvents!==void 0?e.allowSynchronousEvents:!0,this._binaryType=e.binaryType||Gg[0],this._extensions=e.extensions||{},this._isServer=!!e.isServer,this._maxPayload=e.maxPayload|0,this._skipUTF8Validation=!!e.skipUTF8Validation,this[Xg]=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=Pt}_write(e,t,n){if(this._opcode===8&&this._state==Pt)return n();this._bufferedBytes+=e.length,this._buffers.push(e),this.startLoop(n)}consume(e){if(this._bufferedBytes-=e,e===this._buffers[0].length)return this._buffers.shift();if(e<this._buffers[0].length){let n=this._buffers[0];return this._buffers[0]=new wi(n.buffer,n.byteOffset+e,n.length-e),new wi(n.buffer,n.byteOffset,e)}let t=Buffer.allocUnsafe(e);do{let n=this._buffers[0],s=t.length-e;e>=n.length?t.set(this._buffers.shift(),s):(t.set(new Uint8Array(n.buffer,n.byteOffset,e),s),this._buffers[0]=new wi(n.buffer,n.byteOffset+e,n.length-e)),e-=n.length}while(e>0);return t}startLoop(e){this._loop=!0;do switch(this._state){case Pt:this.getInfo(e);break;case el:this.getPayloadLength16(e);break;case tl:this.getPayloadLength64(e);break;case rl:this.getMask();break;case ma:this.getData(e);break;case ya:case xi:this._loop=!1;return}while(this._loop);this._errored||e()}getInfo(e){if(this._bufferedBytes<2){this._loop=!1;return}let t=this.consume(2);if((t[0]&48)!==0){let s=this.createError(RangeError,"RSV2 and RSV3 must be clear",!0,1002,"WS_ERR_UNEXPECTED_RSV_2_3");e(s);return}let n=(t[0]&64)===64;if(n&&!this._extensions[Ju.extensionName]){let s=this.createError(RangeError,"RSV1 must be clear",!0,1002,"WS_ERR_UNEXPECTED_RSV_1");e(s);return}if(this._fin=(t[0]&128)===128,this._opcode=t[0]&15,this._payloadLength=t[1]&127,this._opcode===0){if(n){let s=this.createError(RangeError,"RSV1 must be clear",!0,1002,"WS_ERR_UNEXPECTED_RSV_1");e(s);return}if(!this._fragmented){let s=this.createError(RangeError,"invalid opcode 0",!0,1002,"WS_ERR_INVALID_OPCODE");e(s);return}this._opcode=this._fragmented}else if(this._opcode===1||this._opcode===2){if(this._fragmented){let s=this.createError(RangeError,`invalid opcode ${this._opcode}`,!0,1002,"WS_ERR_INVALID_OPCODE");e(s);return}this._compressed=n}else if(this._opcode>7&&this._opcode<11){if(!this._fin){let s=this.createError(RangeError,"FIN must be set",!0,1002,"WS_ERR_EXPECTED_FIN");e(s);return}if(n){let s=this.createError(RangeError,"RSV1 must be clear",!0,1002,"WS_ERR_UNEXPECTED_RSV_1");e(s);return}if(this._payloadLength>125||this._opcode===8&&this._payloadLength===1){let s=this.createError(RangeError,`invalid payload length ${this._payloadLength}`,!0,1002,"WS_ERR_INVALID_CONTROL_PAYLOAD_LENGTH");e(s);return}}else{let s=this.createError(RangeError,`invalid opcode ${this._opcode}`,!0,1002,"WS_ERR_INVALID_OPCODE");e(s);return}if(!this._fin&&!this._fragmented&&(this._fragmented=this._opcode),this._masked=(t[1]&128)===128,this._isServer){if(!this._masked){let s=this.createError(RangeError,"MASK must be set",!0,1002,"WS_ERR_EXPECTED_MASK");e(s);return}}else if(this._masked){let s=this.createError(RangeError,"MASK must be clear",!0,1002,"WS_ERR_UNEXPECTED_MASK");e(s);return}this._payloadLength===126?this._state=el:this._payloadLength===127?this._state=tl:this.haveLength(e)}getPayloadLength16(e){if(this._bufferedBytes<2){this._loop=!1;return}this._payloadLength=this.consume(2).readUInt16BE(0),this.haveLength(e)}getPayloadLength64(e){if(this._bufferedBytes<8){this._loop=!1;return}let t=this.consume(8),n=t.readUInt32BE(0);if(n>Math.pow(2,21)-1){let s=this.createError(RangeError,"Unsupported WebSocket frame: payload length > 2^53 - 1",!1,1009,"WS_ERR_UNSUPPORTED_DATA_PAYLOAD_LENGTH");e(s);return}this._payloadLength=n*Math.pow(2,32)+t.readUInt32BE(4),this.haveLength(e)}haveLength(e){if(this._payloadLength&&this._opcode<8&&(this._totalPayloadLength+=this._payloadLength,this._totalPayloadLength>this._maxPayload&&this._maxPayload>0)){let t=this.createError(RangeError,"Max payload size exceeded",!1,1009,"WS_ERR_UNSUPPORTED_MESSAGE_LENGTH");e(t);return}this._masked?this._state=rl:this._state=ma}getMask(){if(this._bufferedBytes<4){this._loop=!1;return}this._mask=this.consume(4),this._state=ma}getData(e){let t=Zu;if(this._payloadLength){if(this._bufferedBytes<this._payloadLength){this._loop=!1;return}t=this.consume(this._payloadLength),this._masked&&(this._mask[0]|this._mask[1]|this._mask[2]|this._mask[3])!==0&&Zg(t,this._mask)}if(this._opcode>7){this.controlMessage(t,e);return}if(this._compressed){this._state=ya,this.decompress(t,e);return}t.length&&(this._messageLength=this._totalPayloadLength,this._fragments.push(t)),this.dataMessage(e)}decompress(e,t){this._extensions[Ju.extensionName].decompress(e,this._fin,(s,i)=>{if(s)return t(s);if(i.length){if(this._messageLength+=i.length,this._messageLength>this._maxPayload&&this._maxPayload>0){let a=this.createError(RangeError,"Max payload size exceeded",!1,1009,"WS_ERR_UNSUPPORTED_MESSAGE_LENGTH");t(a);return}this._fragments.push(i)}this.dataMessage(t),this._state===Pt&&this.startLoop(t)})}dataMessage(e){if(!this._fin){this._state=Pt;return}let t=this._messageLength,n=this._fragments;if(this._totalPayloadLength=0,this._messageLength=0,this._fragmented=0,this._fragments=[],this._opcode===2){let s;this._binaryType==="nodebuffer"?s=_a(n,t):this._binaryType==="arraybuffer"?s=Jg(_a(n,t)):this._binaryType==="blob"?s=new Blob(n):s=n,this._allowSynchronousEvents?(this.emit("message",s,!0),this._state=Pt):(this._state=xi,setImmediate(()=>{this.emit("message",s,!0),this._state=Pt,this.startLoop(e)}))}else{let s=_a(n,t);if(!this._skipUTF8Validation&&!Qu(s)){let i=this.createError(Error,"invalid UTF-8 sequence",!0,1007,"WS_ERR_INVALID_UTF8");e(i);return}this._state===ya||this._allowSynchronousEvents?(this.emit("message",s,!1),this._state=Pt):(this._state=xi,setImmediate(()=>{this.emit("message",s,!1),this._state=Pt,this.startLoop(e)}))}}controlMessage(e,t){if(this._opcode===8){if(e.length===0)this._loop=!1,this.emit("conclude",1005,Zu),this.end();else{let n=e.readUInt16BE(0);if(!Qg(n)){let i=this.createError(RangeError,`invalid status code ${n}`,!0,1002,"WS_ERR_INVALID_CLOSE_CODE");t(i);return}let s=new wi(e.buffer,e.byteOffset+2,e.length-2);if(!this._skipUTF8Validation&&!Qu(s)){let i=this.createError(Error,"invalid UTF-8 sequence",!0,1007,"WS_ERR_INVALID_UTF8");t(i);return}this._loop=!1,this.emit("conclude",n,s),this.end()}this._state=Pt;return}this._allowSynchronousEvents?(this.emit(this._opcode===9?"ping":"pong",e),this._state=Pt):(this._state=xi,setImmediate(()=>{this.emit(this._opcode===9?"ping":"pong",e),this._state=Pt,this.startLoop(t)}))}createError(e,t,n,s,i){this._loop=!1,this._errored=!0;let a=new e(n?`Invalid WebSocket frame: ${t}`:t);return Error.captureStackTrace(a,this.createError),a.code=i,a[Yg]=s,a}};nl.exports=Ea});var ba=F((kw,ol)=>{"use strict";var{Duplex:Cw}=require("stream"),{randomFillSync:e0}=require("crypto"),sl=us(),{EMPTY_BUFFER:t0,kWebSocket:r0,NOOP:n0}=ur(),{isBlob:Rn,isValidStatusCode:s0}=Pn(),{mask:il,toBuffer:Xr}=cs(),Rt=Symbol("kByteLength"),i0=Buffer.alloc(4),vi=8*1024,Jr,An=vi,Dt=0,o0=1,a0=2,xa=class r{constructor(e,t,n){this._extensions=t||{},n&&(this._generateMask=n,this._maskBuffer=Buffer.alloc(4)),this._socket=e,this._firstFragment=!0,this._compress=!1,this._bufferedBytes=0,this._queue=[],this._state=Dt,this.onerror=n0,this[r0]=void 0}static frame(e,t){let n,s=!1,i=2,a=!1;t.mask&&(n=t.maskBuffer||i0,t.generateMask?t.generateMask(n):(An===vi&&(Jr===void 0&&(Jr=Buffer.alloc(vi)),e0(Jr,0,vi),An=0),n[0]=Jr[An++],n[1]=Jr[An++],n[2]=Jr[An++],n[3]=Jr[An++]),a=(n[0]|n[1]|n[2]|n[3])===0,i=6);let f;typeof e=="string"?(!t.mask||a)&&t[Rt]!==void 0?f=t[Rt]:(e=Buffer.from(e),f=e.length):(f=e.length,s=t.mask&&t.readOnly&&!a);let u=f;f>=65536?(i+=8,u=127):f>125&&(i+=2,u=126);let d=Buffer.allocUnsafe(s?f+i:i);return d[0]=t.fin?t.opcode|128:t.opcode,t.rsv1&&(d[0]|=64),d[1]=u,u===126?d.writeUInt16BE(f,2):u===127&&(d[2]=d[3]=0,d.writeUIntBE(f,4,6)),t.mask?(d[1]|=128,d[i-4]=n[0],d[i-3]=n[1],d[i-2]=n[2],d[i-1]=n[3],a?[d,e]:s?(il(e,n,d,i,f),[d]):(il(e,n,e,0,f),[d,e])):[d,e]}close(e,t,n,s){let i;if(e===void 0)i=t0;else{if(typeof e!="number"||!s0(e))throw new TypeError("First argument must be a valid error code number");if(t===void 0||!t.length)i=Buffer.allocUnsafe(2),i.writeUInt16BE(e,0);else{let f=Buffer.byteLength(t);if(f>123)throw new RangeError("The message must not be greater than 123 bytes");i=Buffer.allocUnsafe(2+f),i.writeUInt16BE(e,0),typeof t=="string"?i.write(t,2):i.set(t,2)}}let a={[Rt]:i.length,fin:!0,generateMask:this._generateMask,mask:n,maskBuffer:this._maskBuffer,opcode:8,readOnly:!1,rsv1:!1};this._state!==Dt?this.enqueue([this.dispatch,i,!1,a,s]):this.sendFrame(r.frame(i,a),s)}ping(e,t,n){let s,i;if(typeof e=="string"?(s=Buffer.byteLength(e),i=!1):Rn(e)?(s=e.size,i=!1):(e=Xr(e),s=e.length,i=Xr.readOnly),s>125)throw new RangeError("The data size must not be greater than 125 bytes");let a={[Rt]:s,fin:!0,generateMask:this._generateMask,mask:t,maskBuffer:this._maskBuffer,opcode:9,readOnly:i,rsv1:!1};Rn(e)?this._state!==Dt?this.enqueue([this.getBlobData,e,!1,a,n]):this.getBlobData(e,!1,a,n):this._state!==Dt?this.enqueue([this.dispatch,e,!1,a,n]):this.sendFrame(r.frame(e,a),n)}pong(e,t,n){let s,i;if(typeof e=="string"?(s=Buffer.byteLength(e),i=!1):Rn(e)?(s=e.size,i=!1):(e=Xr(e),s=e.length,i=Xr.readOnly),s>125)throw new RangeError("The data size must not be greater than 125 bytes");let a={[Rt]:s,fin:!0,generateMask:this._generateMask,mask:t,maskBuffer:this._maskBuffer,opcode:10,readOnly:i,rsv1:!1};Rn(e)?this._state!==Dt?this.enqueue([this.getBlobData,e,!1,a,n]):this.getBlobData(e,!1,a,n):this._state!==Dt?this.enqueue([this.dispatch,e,!1,a,n]):this.sendFrame(r.frame(e,a),n)}send(e,t,n){let s=this._extensions[sl.extensionName],i=t.binary?2:1,a=t.compress,f,u;typeof e=="string"?(f=Buffer.byteLength(e),u=!1):Rn(e)?(f=e.size,u=!1):(e=Xr(e),f=e.length,u=Xr.readOnly),this._firstFragment?(this._firstFragment=!1,a&&s&&s.params[s._isServer?"server_no_context_takeover":"client_no_context_takeover"]&&(a=f>=s._threshold),this._compress=a):(a=!1,i=0),t.fin&&(this._firstFragment=!0);let d={[Rt]:f,fin:t.fin,generateMask:this._generateMask,mask:t.mask,maskBuffer:this._maskBuffer,opcode:i,readOnly:u,rsv1:a};Rn(e)?this._state!==Dt?this.enqueue([this.getBlobData,e,this._compress,d,n]):this.getBlobData(e,this._compress,d,n):this._state!==Dt?this.enqueue([this.dispatch,e,this._compress,d,n]):this.dispatch(e,this._compress,d,n)}getBlobData(e,t,n,s){this._bufferedBytes+=n[Rt],this._state=a0,e.arrayBuffer().then(i=>{if(this._socket.destroyed){let f=new Error("The socket was closed while the blob was being read");process.nextTick(va,this,f,s);return}this._bufferedBytes-=n[Rt];let a=Xr(i);t?this.dispatch(a,t,n,s):(this._state=Dt,this.sendFrame(r.frame(a,n),s),this.dequeue())}).catch(i=>{process.nextTick(c0,this,i,s)})}dispatch(e,t,n,s){if(!t){this.sendFrame(r.frame(e,n),s);return}let i=this._extensions[sl.extensionName];this._bufferedBytes+=n[Rt],this._state=o0,i.compress(e,n.fin,(a,f)=>{if(this._socket.destroyed){let u=new Error("The socket was closed while data was being compressed");va(this,u,s);return}this._bufferedBytes-=n[Rt],this._state=Dt,n.readOnly=!1,this.sendFrame(r.frame(f,n),s),this.dequeue()})}dequeue(){for(;this._state===Dt&&this._queue.length;){let e=this._queue.shift();this._bufferedBytes-=e[3][Rt],Reflect.apply(e[0],this,e.slice(1))}}enqueue(e){this._bufferedBytes+=e[3][Rt],this._queue.push(e)}sendFrame(e,t){e.length===2?(this._socket.cork(),this._socket.write(e[0]),this._socket.write(e[1],t),this._socket.uncork()):this._socket.write(e[0],t)}};ol.exports=xa;function va(r,e,t){typeof t=="function"&&t(e);for(let n=0;n<r._queue.length;n++){let s=r._queue[n],i=s[s.length-1];typeof i=="function"&&i(e)}}function c0(r,e,t){va(r,e,t),r.onerror(e)}});var gl=F((Pw,pl)=>{"use strict";var{kForOnEventAttribute:ls,kListener:Sa}=ur(),al=Symbol("kCode"),cl=Symbol("kData"),fl=Symbol("kError"),ul=Symbol("kMessage"),ll=Symbol("kReason"),In=Symbol("kTarget"),hl=Symbol("kType"),dl=Symbol("kWasClean"),hr=class{constructor(e){this[In]=null,this[hl]=e}get target(){return this[In]}get type(){return this[hl]}};Object.defineProperty(hr.prototype,"target",{enumerable:!0});Object.defineProperty(hr.prototype,"type",{enumerable:!0});var Zr=class extends hr{constructor(e,t={}){super(e),this[al]=t.code===void 0?0:t.code,this[ll]=t.reason===void 0?"":t.reason,this[dl]=t.wasClean===void 0?!1:t.wasClean}get code(){return this[al]}get reason(){return this[ll]}get wasClean(){return this[dl]}};Object.defineProperty(Zr.prototype,"code",{enumerable:!0});Object.defineProperty(Zr.prototype,"reason",{enumerable:!0});Object.defineProperty(Zr.prototype,"wasClean",{enumerable:!0});var Nn=class extends hr{constructor(e,t={}){super(e),this[fl]=t.error===void 0?null:t.error,this[ul]=t.message===void 0?"":t.message}get error(){return this[fl]}get message(){return this[ul]}};Object.defineProperty(Nn.prototype,"error",{enumerable:!0});Object.defineProperty(Nn.prototype,"message",{enumerable:!0});var hs=class extends hr{constructor(e,t={}){super(e),this[cl]=t.data===void 0?null:t.data}get data(){return this[cl]}};Object.defineProperty(hs.prototype,"data",{enumerable:!0});var f0={addEventListener(r,e,t={}){for(let s of this.listeners(r))if(!t[ls]&&s[Sa]===e&&!s[ls])return;let n;if(r==="message")n=function(i,a){let f=new hs("message",{data:a?i:i.toString()});f[In]=this,bi(e,this,f)};else if(r==="close")n=function(i,a){let f=new Zr("close",{code:i,reason:a.toString(),wasClean:this._closeFrameReceived&&this._closeFrameSent});f[In]=this,bi(e,this,f)};else if(r==="error")n=function(i){let a=new Nn("error",{error:i,message:i.message});a[In]=this,bi(e,this,a)};else if(r==="open")n=function(){let i=new hr("open");i[In]=this,bi(e,this,i)};else return;n[ls]=!!t[ls],n[Sa]=e,t.once?this.once(r,n):this.on(r,n)},removeEventListener(r,e){for(let t of this.listeners(r))if(t[Sa]===e&&!t[ls]){this.removeListener(r,t);break}}};pl.exports={CloseEvent:Zr,ErrorEvent:Nn,Event:hr,EventTarget:f0,MessageEvent:hs};function bi(r,e,t){typeof r=="object"&&r.handleEvent?r.handleEvent.call(r,t):r.call(e,t)}});var Ta=F((Rw,_l)=>{"use strict";var{tokenChars:ds}=Pn();function Xt(r,e,t){r[e]===void 0?r[e]=[t]:r[e].push(t)}function u0(r){let e=Object.create(null),t=Object.create(null),n=!1,s=!1,i=!1,a,f,u=-1,d=-1,g=-1,_=0;for(;_<r.length;_++)if(d=r.charCodeAt(_),a===void 0)if(g===-1&&ds[d]===1)u===-1&&(u=_);else if(_!==0&&(d===32||d===9))g===-1&&u!==-1&&(g=_);else if(d===59||d===44){if(u===-1)throw new SyntaxError(`Unexpected character at index ${_}`);g===-1&&(g=_);let x=r.slice(u,g);d===44?(Xt(e,x,t),t=Object.create(null)):a=x,u=g=-1}else throw new SyntaxError(`Unexpected character at index ${_}`);else if(f===void 0)if(g===-1&&ds[d]===1)u===-1&&(u=_);else if(d===32||d===9)g===-1&&u!==-1&&(g=_);else if(d===59||d===44){if(u===-1)throw new SyntaxError(`Unexpected character at index ${_}`);g===-1&&(g=_),Xt(t,r.slice(u,g),!0),d===44&&(Xt(e,a,t),t=Object.create(null),a=void 0),u=g=-1}else if(d===61&&u!==-1&&g===-1)f=r.slice(u,_),u=g=-1;else throw new SyntaxError(`Unexpected character at index ${_}`);else if(s){if(ds[d]!==1)throw new SyntaxError(`Unexpected character at index ${_}`);u===-1?u=_:n||(n=!0),s=!1}else if(i)if(ds[d]===1)u===-1&&(u=_);else if(d===34&&u!==-1)i=!1,g=_;else if(d===92)s=!0;else throw new SyntaxError(`Unexpected character at index ${_}`);else if(d===34&&r.charCodeAt(_-1)===61)i=!0;else if(g===-1&&ds[d]===1)u===-1&&(u=_);else if(u!==-1&&(d===32||d===9))g===-1&&(g=_);else if(d===59||d===44){if(u===-1)throw new SyntaxError(`Unexpected character at index ${_}`);g===-1&&(g=_);let x=r.slice(u,g);n&&(x=x.replace(/\\/g,""),n=!1),Xt(t,f,x),d===44&&(Xt(e,a,t),t=Object.create(null),a=void 0),f=void 0,u=g=-1}else throw new SyntaxError(`Unexpected character at index ${_}`);if(u===-1||i||d===32||d===9)throw new SyntaxError("Unexpected end of input");g===-1&&(g=_);let y=r.slice(u,g);return a===void 0?Xt(e,y,t):(f===void 0?Xt(t,y,!0):n?Xt(t,f,y.replace(/\\/g,"")):Xt(t,f,y),Xt(e,a,t)),e}function l0(r){return Object.keys(r).map(e=>{let t=r[e];return Array.isArray(t)||(t=[t]),t.map(n=>[e].concat(Object.keys(n).map(s=>{let i=n[s];return Array.isArray(i)||(i=[i]),i.map(a=>a===!0?s:`${s}=${a}`).join("; ")})).join("; ")).join(", ")}).join(", ")}_l.exports={format:l0,parse:u0}});var Ci=F((Nw,kl)=>{"use strict";var h0=require("events"),d0=require("https"),p0=require("http"),El=require("net"),g0=require("tls"),{randomBytes:_0,createHash:m0}=require("crypto"),{Duplex:Aw,Readable:Iw}=require("stream"),{URL:Oa}=require("url"),Nr=us(),y0=wa(),E0=ba(),{isBlob:w0}=Pn(),{BINARY_TYPES:ml,EMPTY_BUFFER:Si,GUID:x0,kForOnEventAttribute:Ca,kListener:v0,kStatusCode:b0,kWebSocket:tt,NOOP:wl}=ur(),{EventTarget:{addEventListener:S0,removeEventListener:T0}}=gl(),{format:O0,parse:C0}=Ta(),{toBuffer:k0}=cs(),P0=30*1e3,xl=Symbol("kAborted"),ka=[8,13],dr=["CONNECTING","OPEN","CLOSING","CLOSED"],R0=/^[!#$%&'*+\-.0-9A-Z^_`|a-z~]+$/,je=class r extends h0{constructor(e,t,n){super(),this._binaryType=ml[0],this._closeCode=1006,this._closeFrameReceived=!1,this._closeFrameSent=!1,this._closeMessage=Si,this._closeTimer=null,this._errorEmitted=!1,this._extensions={},this._paused=!1,this._protocol="",this._readyState=r.CONNECTING,this._receiver=null,this._sender=null,this._socket=null,e!==null?(this._bufferedAmount=0,this._isServer=!1,this._redirects=0,t===void 0?t=[]:Array.isArray(t)||(typeof t=="object"&&t!==null?(n=t,t=[]):t=[t]),vl(this,e,t,n)):(this._autoPong=n.autoPong,this._isServer=!0)}get binaryType(){return this._binaryType}set binaryType(e){ml.includes(e)&&(this._binaryType=e,this._receiver&&(this._receiver._binaryType=e))}get bufferedAmount(){return this._socket?this._socket._writableState.length+this._sender._bufferedBytes:this._bufferedAmount}get extensions(){return Object.keys(this._extensions).join()}get isPaused(){return this._paused}get onclose(){return null}get onerror(){return null}get onopen(){return null}get onmessage(){return null}get protocol(){return this._protocol}get readyState(){return this._readyState}get url(){return this._url}setSocket(e,t,n){let s=new y0({allowSynchronousEvents:n.allowSynchronousEvents,binaryType:this.binaryType,extensions:this._extensions,isServer:this._isServer,maxPayload:n.maxPayload,skipUTF8Validation:n.skipUTF8Validation}),i=new E0(e,this._extensions,n.generateMask);this._receiver=s,this._sender=i,this._socket=e,s[tt]=this,i[tt]=this,e[tt]=this,s.on("conclude",N0),s.on("drain",L0),s.on("error",D0),s.on("message",F0),s.on("ping",M0),s.on("pong",B0),i.onerror=j0,e.setTimeout&&e.setTimeout(0),e.setNoDelay&&e.setNoDelay(),t.length>0&&e.unshift(t),e.on("close",Tl),e.on("data",Oi),e.on("end",Ol),e.on("error",Cl),this._readyState=r.OPEN,this.emit("open")}emitClose(){if(!this._socket){this._readyState=r.CLOSED,this.emit("close",this._closeCode,this._closeMessage);return}this._extensions[Nr.extensionName]&&this._extensions[Nr.extensionName].cleanup(),this._receiver.removeAllListeners(),this._readyState=r.CLOSED,this.emit("close",this._closeCode,this._closeMessage)}close(e,t){if(this.readyState!==r.CLOSED){if(this.readyState===r.CONNECTING){xt(this,this._req,"WebSocket was closed before the connection was established");return}if(this.readyState===r.CLOSING){this._closeFrameSent&&(this._closeFrameReceived||this._receiver._writableState.errorEmitted)&&this._socket.end();return}this._readyState=r.CLOSING,this._sender.close(e,t,!this._isServer,n=>{n||(this._closeFrameSent=!0,(this._closeFrameReceived||this._receiver._writableState.errorEmitted)&&this._socket.end())}),Sl(this)}}pause(){this.readyState===r.CONNECTING||this.readyState===r.CLOSED||(this._paused=!0,this._socket.pause())}ping(e,t,n){if(this.readyState===r.CONNECTING)throw new Error("WebSocket is not open: readyState 0 (CONNECTING)");if(typeof e=="function"?(n=e,e=t=void 0):typeof t=="function"&&(n=t,t=void 0),typeof e=="number"&&(e=e.toString()),this.readyState!==r.OPEN){Pa(this,e,n);return}t===void 0&&(t=!this._isServer),this._sender.ping(e||Si,t,n)}pong(e,t,n){if(this.readyState===r.CONNECTING)throw new Error("WebSocket is not open: readyState 0 (CONNECTING)");if(typeof e=="function"?(n=e,e=t=void 0):typeof t=="function"&&(n=t,t=void 0),typeof e=="number"&&(e=e.toString()),this.readyState!==r.OPEN){Pa(this,e,n);return}t===void 0&&(t=!this._isServer),this._sender.pong(e||Si,t,n)}resume(){this.readyState===r.CONNECTING||this.readyState===r.CLOSED||(this._paused=!1,this._receiver._writableState.needDrain||this._socket.resume())}send(e,t,n){if(this.readyState===r.CONNECTING)throw new Error("WebSocket is not open: readyState 0 (CONNECTING)");if(typeof t=="function"&&(n=t,t={}),typeof e=="number"&&(e=e.toString()),this.readyState!==r.OPEN){Pa(this,e,n);return}let s={binary:typeof e!="string",mask:!this._isServer,compress:!0,fin:!0,...t};this._extensions[Nr.extensionName]||(s.compress=!1),this._sender.send(e||Si,s,n)}terminate(){if(this.readyState!==r.CLOSED){if(this.readyState===r.CONNECTING){xt(this,this._req,"WebSocket was closed before the connection was established");return}this._socket&&(this._readyState=r.CLOSING,this._socket.destroy())}}};Object.defineProperty(je,"CONNECTING",{enumerable:!0,value:dr.indexOf("CONNECTING")});Object.defineProperty(je.prototype,"CONNECTING",{enumerable:!0,value:dr.indexOf("CONNECTING")});Object.defineProperty(je,"OPEN",{enumerable:!0,value:dr.indexOf("OPEN")});Object.defineProperty(je.prototype,"OPEN",{enumerable:!0,value:dr.indexOf("OPEN")});Object.defineProperty(je,"CLOSING",{enumerable:!0,value:dr.indexOf("CLOSING")});Object.defineProperty(je.prototype,"CLOSING",{enumerable:!0,value:dr.indexOf("CLOSING")});Object.defineProperty(je,"CLOSED",{enumerable:!0,value:dr.indexOf("CLOSED")});Object.defineProperty(je.prototype,"CLOSED",{enumerable:!0,value:dr.indexOf("CLOSED")});["binaryType","bufferedAmount","extensions","isPaused","protocol","readyState","url"].forEach(r=>{Object.defineProperty(je.prototype,r,{enumerable:!0})});["open","error","close","message"].forEach(r=>{Object.defineProperty(je.prototype,`on${r}`,{enumerable:!0,get(){for(let e of this.listeners(r))if(e[Ca])return e[v0];return null},set(e){for(let t of this.listeners(r))if(t[Ca]){this.removeListener(r,t);break}typeof e=="function"&&this.addEventListener(r,e,{[Ca]:!0})}})});je.prototype.addEventListener=S0;je.prototype.removeEventListener=T0;kl.exports=je;function vl(r,e,t,n){let s={allowSynchronousEvents:!0,autoPong:!0,protocolVersion:ka[1],maxPayload:104857600,skipUTF8Validation:!1,perMessageDeflate:!0,followRedirects:!1,maxRedirects:10,...n,socketPath:void 0,hostname:void 0,protocol:void 0,timeout:void 0,method:"GET",host:void 0,path:void 0,port:void 0};if(r._autoPong=s.autoPong,!ka.includes(s.protocolVersion))throw new RangeError(`Unsupported protocol version: ${s.protocolVersion} (supported versions: ${ka.join(", ")})`);let i;if(e instanceof Oa)i=e;else try{i=new Oa(e)}catch{throw new SyntaxError(`Invalid URL: ${e}`)}i.protocol==="http:"?i.protocol="ws:":i.protocol==="https:"&&(i.protocol="wss:"),r._url=i.href;let a=i.protocol==="wss:",f=i.protocol==="ws+unix:",u;if(i.protocol!=="ws:"&&!a&&!f?u=`The URL's protocol must be one of "ws:", "wss:", "http:", "https:", or "ws+unix:"`:f&&!i.pathname?u="The URL's pathname is empty":i.hash&&(u="The URL contains a fragment identifier"),u){let C=new SyntaxError(u);if(r._redirects===0)throw C;Ti(r,C);return}let d=a?443:80,g=_0(16).toString("base64"),_=a?d0.request:p0.request,y=new Set,x;if(s.createConnection=s.createConnection||(a?I0:A0),s.defaultPort=s.defaultPort||d,s.port=i.port||d,s.host=i.hostname.startsWith("[")?i.hostname.slice(1,-1):i.hostname,s.headers={...s.headers,"Sec-WebSocket-Version":s.protocolVersion,"Sec-WebSocket-Key":g,Connection:"Upgrade",Upgrade:"websocket"},s.path=i.pathname+i.search,s.timeout=s.handshakeTimeout,s.perMessageDeflate&&(x=new Nr(s.perMessageDeflate!==!0?s.perMessageDeflate:{},!1,s.maxPayload),s.headers["Sec-WebSocket-Extensions"]=O0({[Nr.extensionName]:x.offer()})),t.length){for(let C of t){if(typeof C!="string"||!R0.test(C)||y.has(C))throw new SyntaxError("An invalid or duplicated subprotocol was specified");y.add(C)}s.headers["Sec-WebSocket-Protocol"]=t.join(",")}if(s.origin&&(s.protocolVersion<13?s.headers["Sec-WebSocket-Origin"]=s.origin:s.headers.Origin=s.origin),(i.username||i.password)&&(s.auth=`${i.username}:${i.password}`),f){let C=s.path.split(":");s.socketPath=C[0],s.path=C[1]}let S;if(s.followRedirects){if(r._redirects===0){r._originalIpc=f,r._originalSecure=a,r._originalHostOrSocketPath=f?s.socketPath:i.host;let C=n&&n.headers;if(n={...n,headers:{}},C)for(let[H,z]of Object.entries(C))n.headers[H.toLowerCase()]=z}else if(r.listenerCount("redirect")===0){let C=f?r._originalIpc?s.socketPath===r._originalHostOrSocketPath:!1:r._originalIpc?!1:i.host===r._originalHostOrSocketPath;(!C||r._originalSecure&&!a)&&(delete s.headers.authorization,delete s.headers.cookie,C||delete s.headers.host,s.auth=void 0)}s.auth&&!n.headers.authorization&&(n.headers.authorization="Basic "+Buffer.from(s.auth).toString("base64")),S=r._req=_(s),r._redirects&&r.emit("redirect",r.url,S)}else S=r._req=_(s);s.timeout&&S.on("timeout",()=>{xt(r,S,"Opening handshake has timed out")}),S.on("error",C=>{S===null||S[xl]||(S=r._req=null,Ti(r,C))}),S.on("response",C=>{let H=C.headers.location,z=C.statusCode;if(H&&s.followRedirects&&z>=300&&z<400){if(++r._redirects>s.maxRedirects){xt(r,S,"Maximum redirects exceeded");return}S.abort();let X;try{X=new Oa(H,e)}catch{let M=new SyntaxError(`Invalid URL: ${H}`);Ti(r,M);return}vl(r,X,t,n)}else r.emit("unexpected-response",S,C)||xt(r,S,`Unexpected server response: ${C.statusCode}`)}),S.on("upgrade",(C,H,z)=>{if(r.emit("upgrade",C),r.readyState!==je.CONNECTING)return;S=r._req=null;let X=C.headers.upgrade;if(X===void 0||X.toLowerCase()!=="websocket"){xt(r,H,"Invalid Upgrade header");return}let T=m0("sha1").update(g+x0).digest("base64");if(C.headers["sec-websocket-accept"]!==T){xt(r,H,"Invalid Sec-WebSocket-Accept header");return}let M=C.headers["sec-websocket-protocol"],Q;if(M!==void 0?y.size?y.has(M)||(Q="Server sent an invalid subprotocol"):Q="Server sent a subprotocol but none was requested":y.size&&(Q="Server sent no subprotocol"),Q){xt(r,H,Q);return}M&&(r._protocol=M);let B=C.headers["sec-websocket-extensions"];if(B!==void 0){if(!x){xt(r,H,"Server sent a Sec-WebSocket-Extensions header but no extension was requested");return}let ie;try{ie=C0(B)}catch{xt(r,H,"Invalid Sec-WebSocket-Extensions header");return}let he=Object.keys(ie);if(he.length!==1||he[0]!==Nr.extensionName){xt(r,H,"Server indicated an extension that was not requested");return}try{x.accept(ie[Nr.extensionName])}catch{xt(r,H,"Invalid Sec-WebSocket-Extensions header");return}r._extensions[Nr.extensionName]=x}r.setSocket(H,z,{allowSynchronousEvents:s.allowSynchronousEvents,generateMask:s.generateMask,maxPayload:s.maxPayload,skipUTF8Validation:s.skipUTF8Validation})}),s.finishRequest?s.finishRequest(S,r):S.end()}function Ti(r,e){r._readyState=je.CLOSING,r._errorEmitted=!0,r.emit("error",e),r.emitClose()}function A0(r){return r.path=r.socketPath,El.connect(r)}function I0(r){return r.path=void 0,!r.servername&&r.servername!==""&&(r.servername=El.isIP(r.host)?"":r.host),g0.connect(r)}function xt(r,e,t){r._readyState=je.CLOSING;let n=new Error(t);Error.captureStackTrace(n,xt),e.setHeader?(e[xl]=!0,e.abort(),e.socket&&!e.socket.destroyed&&e.socket.destroy(),process.nextTick(Ti,r,n)):(e.destroy(n),e.once("error",r.emit.bind(r,"error")),e.once("close",r.emitClose.bind(r)))}function Pa(r,e,t){if(e){let n=w0(e)?e.size:k0(e).length;r._socket?r._sender._bufferedBytes+=n:r._bufferedAmount+=n}if(t){let n=new Error(`WebSocket is not open: readyState ${r.readyState} (${dr[r.readyState]})`);process.nextTick(t,n)}}function N0(r,e){let t=this[tt];t._closeFrameReceived=!0,t._closeMessage=e,t._closeCode=r,t._socket[tt]!==void 0&&(t._socket.removeListener("data",Oi),process.nextTick(bl,t._socket),r===1005?t.close():t.close(r,e))}function L0(){let r=this[tt];r.isPaused||r._socket.resume()}function D0(r){let e=this[tt];e._socket[tt]!==void 0&&(e._socket.removeListener("data",Oi),process.nextTick(bl,e._socket),e.close(r[b0])),e._errorEmitted||(e._errorEmitted=!0,e.emit("error",r))}function yl(){this[tt].emitClose()}function F0(r,e){this[tt].emit("message",r,e)}function M0(r){let e=this[tt];e._autoPong&&e.pong(r,!this._isServer,wl),e.emit("ping",r)}function B0(r){this[tt].emit("pong",r)}function bl(r){r.resume()}function j0(r){let e=this[tt];e.readyState!==je.CLOSED&&(e.readyState===je.OPEN&&(e._readyState=je.CLOSING,Sl(e)),this._socket.end(),e._errorEmitted||(e._errorEmitted=!0,e.emit("error",r)))}function Sl(r){r._closeTimer=setTimeout(r._socket.destroy.bind(r._socket),P0)}function Tl(){let r=this[tt];this.removeListener("close",Tl),this.removeListener("data",Oi),this.removeListener("end",Ol),r._readyState=je.CLOSING;let e;!this._readableState.endEmitted&&!r._closeFrameReceived&&!r._receiver._writableState.errorEmitted&&(e=r._socket.read())!==null&&r._receiver.write(e),r._receiver.end(),this[tt]=void 0,clearTimeout(r._closeTimer),r._receiver._writableState.finished||r._receiver._writableState.errorEmitted?r.emitClose():(r._receiver.on("error",yl),r._receiver.on("finish",yl))}function Oi(r){this[tt]._receiver.write(r)||this.pause()}function Ol(){let r=this[tt];r._readyState=je.CLOSING,r._receiver.end(),this.end()}function Cl(){let r=this[tt];this.removeListener("error",Cl),this.on("error",wl),r&&(r._readyState=je.CLOSING,this.destroy())}});var Il=F((Dw,Al)=>{"use strict";var Lw=Ci(),{Duplex:U0}=require("stream");function Pl(r){r.emit("close")}function q0(){!this.destroyed&&this._writableState.finished&&this.destroy()}function Rl(r){this.removeListener("error",Rl),this.destroy(),this.listenerCount("error")===0&&this.emit("error",r)}function W0(r,e){let t=!0,n=new U0({...e,autoDestroy:!1,emitClose:!1,objectMode:!1,writableObjectMode:!1});return r.on("message",function(i,a){let f=!a&&n._readableState.objectMode?i.toString():i;n.push(f)||r.pause()}),r.once("error",function(i){n.destroyed||(t=!1,n.destroy(i))}),r.once("close",function(){n.destroyed||n.push(null)}),n._destroy=function(s,i){if(r.readyState===r.CLOSED){i(s),process.nextTick(Pl,n);return}let a=!1;r.once("error",function(u){a=!0,i(u)}),r.once("close",function(){a||i(s),process.nextTick(Pl,n)}),t&&r.terminate()},n._final=function(s){if(r.readyState===r.CONNECTING){r.once("open",function(){n._final(s)});return}r._socket!==null&&(r._socket._writableState.finished?(s(),n._readableState.endEmitted&&n.destroy()):(r._socket.once("finish",function(){s()}),r.close()))},n._read=function(){r.isPaused&&r.resume()},n._write=function(s,i,a){if(r.readyState===r.CONNECTING){r.once("open",function(){n._write(s,i,a)});return}r.send(s,a)},n.on("end",q0),n.on("error",Rl),n}Al.exports=W0});var Ll=F((Fw,Nl)=>{"use strict";var{tokenChars:H0}=Pn();function V0(r){let e=new Set,t=-1,n=-1,s=0;for(s;s<r.length;s++){let a=r.charCodeAt(s);if(n===-1&&H0[a]===1)t===-1&&(t=s);else if(s!==0&&(a===32||a===9))n===-1&&t!==-1&&(n=s);else if(a===44){if(t===-1)throw new SyntaxError(`Unexpected character at index ${s}`);n===-1&&(n=s);let f=r.slice(t,n);if(e.has(f))throw new SyntaxError(`The "${f}" subprotocol is duplicated`);e.add(f),t=n=-1}else throw new SyntaxError(`Unexpected character at index ${s}`)}if(t===-1||n!==-1)throw new SyntaxError("Unexpected end of input");let i=r.slice(t,s);if(e.has(i))throw new SyntaxError(`The "${i}" subprotocol is duplicated`);return e.add(i),e}Nl.exports={parse:V0}});var ql=F((Bw,Ul)=>{"use strict";var K0=require("events"),ki=require("http"),{Duplex:Mw}=require("stream"),{createHash:$0}=require("crypto"),Dl=Ta(),Qr=us(),z0=Ll(),G0=Ci(),{GUID:Y0,kWebSocket:X0}=ur(),J0=/^[+/0-9A-Za-z]{22}==$/,Fl=0,Ml=1,jl=2,Ra=class extends K0{constructor(e,t){if(super(),e={allowSynchronousEvents:!0,autoPong:!0,maxPayload:100*1024*1024,skipUTF8Validation:!1,perMessageDeflate:!1,handleProtocols:null,clientTracking:!0,verifyClient:null,noServer:!1,backlog:null,server:null,host:null,path:null,port:null,WebSocket:G0,...e},e.port==null&&!e.server&&!e.noServer||e.port!=null&&(e.server||e.noServer)||e.server&&e.noServer)throw new TypeError('One and only one of the "port", "server", or "noServer" options must be specified');if(e.port!=null?(this._server=ki.createServer((n,s)=>{let i=ki.STATUS_CODES[426];s.writeHead(426,{"Content-Length":i.length,"Content-Type":"text/plain"}),s.end(i)}),this._server.listen(e.port,e.host,e.backlog,t)):e.server&&(this._server=e.server),this._server){let n=this.emit.bind(this,"connection");this._removeListeners=Z0(this._server,{listening:this.emit.bind(this,"listening"),error:this.emit.bind(this,"error"),upgrade:(s,i,a)=>{this.handleUpgrade(s,i,a,n)}})}e.perMessageDeflate===!0&&(e.perMessageDeflate={}),e.clientTracking&&(this.clients=new Set,this._shouldEmitClose=!1),this.options=e,this._state=Fl}address(){if(this.options.noServer)throw new Error('The server is operating in "noServer" mode');return this._server?this._server.address():null}close(e){if(this._state===jl){e&&this.once("close",()=>{e(new Error("The server is not running"))}),process.nextTick(ps,this);return}if(e&&this.once("close",e),this._state!==Ml)if(this._state=Ml,this.options.noServer||this.options.server)this._server&&(this._removeListeners(),this._removeListeners=this._server=null),this.clients?this.clients.size?this._shouldEmitClose=!0:process.nextTick(ps,this):process.nextTick(ps,this);else{let t=this._server;this._removeListeners(),this._removeListeners=this._server=null,t.close(()=>{ps(this)})}}shouldHandle(e){if(this.options.path){let t=e.url.indexOf("?");if((t!==-1?e.url.slice(0,t):e.url)!==this.options.path)return!1}return!0}handleUpgrade(e,t,n,s){t.on("error",Bl);let i=e.headers["sec-websocket-key"],a=e.headers.upgrade,f=+e.headers["sec-websocket-version"];if(e.method!=="GET"){en(this,e,t,405,"Invalid HTTP method");return}if(a===void 0||a.toLowerCase()!=="websocket"){en(this,e,t,400,"Invalid Upgrade header");return}if(i===void 0||!J0.test(i)){en(this,e,t,400,"Missing or invalid Sec-WebSocket-Key header");return}if(f!==13&&f!==8){en(this,e,t,400,"Missing or invalid Sec-WebSocket-Version header",{"Sec-WebSocket-Version":"13, 8"});return}if(!this.shouldHandle(e)){gs(t,400);return}let u=e.headers["sec-websocket-protocol"],d=new Set;if(u!==void 0)try{d=z0.parse(u)}catch{en(this,e,t,400,"Invalid Sec-WebSocket-Protocol header");return}let g=e.headers["sec-websocket-extensions"],_={};if(this.options.perMessageDeflate&&g!==void 0){let y=new Qr(this.options.perMessageDeflate,!0,this.options.maxPayload);try{let x=Dl.parse(g);x[Qr.extensionName]&&(y.accept(x[Qr.extensionName]),_[Qr.extensionName]=y)}catch{en(this,e,t,400,"Invalid or unacceptable Sec-WebSocket-Extensions header");return}}if(this.options.verifyClient){let y={origin:e.headers[`${f===8?"sec-websocket-origin":"origin"}`],secure:!!(e.socket.authorized||e.socket.encrypted),req:e};if(this.options.verifyClient.length===2){this.options.verifyClient(y,(x,S,C,H)=>{if(!x)return gs(t,S||401,C,H);this.completeUpgrade(_,i,d,e,t,n,s)});return}if(!this.options.verifyClient(y))return gs(t,401)}this.completeUpgrade(_,i,d,e,t,n,s)}completeUpgrade(e,t,n,s,i,a,f){if(!i.readable||!i.writable)return i.destroy();if(i[X0])throw new Error("server.handleUpgrade() was called more than once with the same socket, possibly due to a misconfiguration");if(this._state>Fl)return gs(i,503);let d=["HTTP/1.1 101 Switching Protocols","Upgrade: websocket","Connection: Upgrade",`Sec-WebSocket-Accept: ${$0("sha1").update(t+Y0).digest("base64")}`],g=new this.options.WebSocket(null,void 0,this.options);if(n.size){let _=this.options.handleProtocols?this.options.handleProtocols(n,s):n.values().next().value;_&&(d.push(`Sec-WebSocket-Protocol: ${_}`),g._protocol=_)}if(e[Qr.extensionName]){let _=e[Qr.extensionName].params,y=Dl.format({[Qr.extensionName]:[_]});d.push(`Sec-WebSocket-Extensions: ${y}`),g._extensions=e}this.emit("headers",d,s),i.write(d.concat(`\r
|
|
18
|
+
`+i),r.push(s+"m+"+di.exports.humanize(this.diff)+"\x1B[0m")}else r[0]=fg()+e+" "+r[0]}function fg(){return et.inspectOpts.hideDate?"":new Date().toISOString()+" "}function ug(...r){return process.stderr.write(hi.formatWithOptions(et.inspectOpts,...r)+`
|
|
19
|
+
`)}function lg(r){r?process.env.DEBUG=r:delete process.env.DEBUG}function hg(){return process.env.DEBUG}function dg(r){r.inspectOpts={};let e=Object.keys(et.inspectOpts);for(let t=0;t<e.length;t++)r.inspectOpts[e[t]]=et.inspectOpts[e[t]]}di.exports=Fo()(et);var{formatters:cu}=di.exports;cu.o=function(r){return this.inspectOpts.colors=this.useColors,hi.inspect(r,this.inspectOpts).split(`
|
|
20
|
+
`).map(e=>e.trim()).join(" ")};cu.O=function(r){return this.inspectOpts.colors=this.useColors,hi.inspect(r,this.inspectOpts)}});var Pt=D((aw,jo)=>{typeof process>"u"||process.type==="renderer"||process.browser===!0||process.__nwjs?jo.exports=ru():jo.exports=fu()});var ss=D(Rr=>{"use strict";var pg=Rr&&Rr.__importDefault||function(r){return r&&r.__esModule?r:{default:r}};Object.defineProperty(Rr,"__esModule",{value:!0});Rr.Transport=Rr.TransportError=void 0;var gg=bn(),_g=Yr(),mg=Jr(),yg=Do(),Eg=pg(Pt()),wg=(0,Eg.default)("engine.io-client:transport"),pi=class extends Error{constructor(e,t,n){super(e),this.description=t,this.context=n,this.type="TransportError"}};Rr.TransportError=pi;var Uo=class extends _g.Emitter{constructor(e){super(),this.writable=!1,(0,mg.installTimerFunctions)(this,e),this.opts=e,this.query=e.query,this.socket=e.socket,this.supportsBinary=!e.forceBase64}onError(e,t,n){return super.emitReserved("error",new pi(e,t,n)),this}open(){return this.readyState="opening",this.doOpen(),this}close(){return(this.readyState==="opening"||this.readyState==="open")&&(this.doClose(),this.onClose()),this}send(e){this.readyState==="open"?this.write(e):wg("transport is not open, discarding packets")}onOpen(){this.readyState="open",this.writable=!0,super.emitReserved("open")}onData(e){let t=(0,gg.decodePacket)(e,this.socket.binaryType);this.onPacket(t)}onPacket(e){super.emitReserved("packet",e)}onClose(e){this.readyState="closed",super.emitReserved("close",e)}pause(e){}createUri(e,t={}){return e+"://"+this._hostname()+this._port()+this.opts.path+this._query(t)}_hostname(){let e=this.opts.hostname;return e.indexOf(":")===-1?e:"["+e+"]"}_port(){return this.opts.port&&(this.opts.secure&&Number(this.opts.port)!==443||!this.opts.secure&&Number(this.opts.port)!==80)?":"+this.opts.port:""}_query(e){let t=(0,yg.encode)(e);return t.length?"?"+t:""}};Rr.Transport=Uo});var Wo=D(kn=>{"use strict";var vg=kn&&kn.__importDefault||function(r){return r&&r.__esModule?r:{default:r}};Object.defineProperty(kn,"__esModule",{value:!0});kn.Polling=void 0;var xg=ss(),bg=Jr(),uu=bn(),Sg=vg(Pt()),Dt=(0,Sg.default)("engine.io-client:polling"),qo=class extends xg.Transport{constructor(){super(...arguments),this._polling=!1}get name(){return"polling"}doOpen(){this._poll()}pause(e){this.readyState="pausing";let t=()=>{Dt("paused"),this.readyState="paused",e()};if(this._polling||!this.writable){let n=0;this._polling&&(Dt("we are currently polling - waiting to pause"),n++,this.once("pollComplete",function(){Dt("pre-pause polling complete"),--n||t()})),this.writable||(Dt("we are currently writing - waiting to pause"),n++,this.once("drain",function(){Dt("pre-pause writing complete"),--n||t()}))}else t()}_poll(){Dt("polling"),this._polling=!0,this.doPoll(),this.emitReserved("poll")}onData(e){Dt("polling got data %s",e);let t=n=>{if(this.readyState==="opening"&&n.type==="open"&&this.onOpen(),n.type==="close")return this.onClose({description:"transport closed by the server"}),!1;this.onPacket(n)};(0,uu.decodePayload)(e,this.socket.binaryType).forEach(t),this.readyState!=="closed"&&(this._polling=!1,this.emitReserved("pollComplete"),this.readyState==="open"?this._poll():Dt('ignoring poll - transport state "%s"',this.readyState))}doClose(){let e=()=>{Dt("writing close packet"),this.write([{type:"close"}])};this.readyState==="open"?(Dt("transport open - closing"),e()):(Dt("transport not open - deferring close"),this.once("open",e))}write(e){this.writable=!1,(0,uu.encodePayload)(e,t=>{this.doWrite(t,()=>{this.writable=!0,this.emitReserved("drain")})})}uri(){let e=this.opts.secure?"https":"http",t=this.query||{};return this.opts.timestampRequests!==!1&&(t[this.opts.timestampParam]=(0,bg.randomString)()),!this.supportsBinary&&!t.sid&&(t.b64=1),this.createUri(e,t)}};kn.Polling=qo});var hu=D(gi=>{"use strict";Object.defineProperty(gi,"__esModule",{value:!0});gi.hasCORS=void 0;var lu=!1;try{lu=typeof XMLHttpRequest<"u"&&"withCredentials"in new XMLHttpRequest}catch{}gi.hasCORS=lu});var Ko=D(Yt=>{"use strict";var Tg=Yt&&Yt.__importDefault||function(r){return r&&r.__esModule?r:{default:r}};Object.defineProperty(Yt,"__esModule",{value:!0});Yt.XHR=Yt.Request=Yt.BaseXHR=void 0;var Og=Wo(),Cg=Yr(),du=Jr(),gu=Xr(),kg=hu(),Pg=Tg(Pt()),Ho=(0,Pg.default)("engine.io-client:polling");function Rg(){}var _i=class extends Og.Polling{constructor(e){if(super(e),typeof location<"u"){let t=location.protocol==="https:",n=location.port;n||(n=t?"443":"80"),this.xd=typeof location<"u"&&e.hostname!==location.hostname||n!==e.port}}doWrite(e,t){let n=this.request({method:"POST",data:e});n.on("success",t),n.on("error",(s,i)=>{this.onError("xhr post error",s,i)})}doPoll(){Ho("xhr poll");let e=this.request();e.on("data",this.onData.bind(this)),e.on("error",(t,n)=>{this.onError("xhr poll error",t,n)}),this.pollXhr=e}};Yt.BaseXHR=_i;var ur=class r extends Cg.Emitter{constructor(e,t,n){super(),this.createRequest=e,(0,du.installTimerFunctions)(this,n),this._opts=n,this._method=n.method||"GET",this._uri=t,this._data=n.data!==void 0?n.data:null,this._create()}_create(){var e;let t=(0,du.pick)(this._opts,"agent","pfx","key","passphrase","cert","ca","ciphers","rejectUnauthorized","autoUnref");t.xdomain=!!this._opts.xd;let n=this._xhr=this.createRequest(t);try{Ho("xhr open %s: %s",this._method,this._uri),n.open(this._method,this._uri,!0);try{if(this._opts.extraHeaders){n.setDisableHeaderCheck&&n.setDisableHeaderCheck(!0);for(let s in this._opts.extraHeaders)this._opts.extraHeaders.hasOwnProperty(s)&&n.setRequestHeader(s,this._opts.extraHeaders[s])}}catch{}if(this._method==="POST")try{n.setRequestHeader("Content-type","text/plain;charset=UTF-8")}catch{}try{n.setRequestHeader("Accept","*/*")}catch{}(e=this._opts.cookieJar)===null||e===void 0||e.addCookies(n),"withCredentials"in n&&(n.withCredentials=this._opts.withCredentials),this._opts.requestTimeout&&(n.timeout=this._opts.requestTimeout),n.onreadystatechange=()=>{var s;n.readyState===3&&((s=this._opts.cookieJar)===null||s===void 0||s.parseCookies(n.getResponseHeader("set-cookie"))),n.readyState===4&&(n.status===200||n.status===1223?this._onLoad():this.setTimeoutFn(()=>{this._onError(typeof n.status=="number"?n.status:0)},0))},Ho("xhr data %s",this._data),n.send(this._data)}catch(s){this.setTimeoutFn(()=>{this._onError(s)},0);return}typeof document<"u"&&(this._index=r.requestsCount++,r.requests[this._index]=this)}_onError(e){this.emitReserved("error",e,this._xhr),this._cleanup(!0)}_cleanup(e){if(!(typeof this._xhr>"u"||this._xhr===null)){if(this._xhr.onreadystatechange=Rg,e)try{this._xhr.abort()}catch{}typeof document<"u"&&delete r.requests[this._index],this._xhr=null}}_onLoad(){let e=this._xhr.responseText;e!==null&&(this.emitReserved("data",e),this.emitReserved("success"),this._cleanup())}abort(){this._cleanup()}};Yt.Request=ur;ur.requestsCount=0;ur.requests={};if(typeof document<"u"){if(typeof attachEvent=="function")attachEvent("onunload",pu);else if(typeof addEventListener=="function"){let r="onpagehide"in gu.globalThisShim?"pagehide":"unload";addEventListener(r,pu,!1)}}function pu(){for(let r in ur.requests)ur.requests.hasOwnProperty(r)&&ur.requests[r].abort()}var Ag=(function(){let r=_u({xdomain:!1});return r&&r.responseType!==null})(),Vo=class extends _i{constructor(e){super(e);let t=e&&e.forceBase64;this.supportsBinary=Ag&&!t}request(e={}){return Object.assign(e,{xd:this.xd},this.opts),new ur(_u,this.uri(),e)}};Yt.XHR=Vo;function _u(r){let e=r.xdomain;try{if(typeof XMLHttpRequest<"u"&&(!e||kg.hasCORS))return new XMLHttpRequest}catch{}if(!e)try{return new gu.globalThisShim[["Active"].concat("Object").join("X")]("Microsoft.XMLHTTP")}catch{}}});var zo=D(Xt=>{"use strict";var Ig=Xt&&Xt.__createBinding||(Object.create?(function(r,e,t,n){n===void 0&&(n=t);var s=Object.getOwnPropertyDescriptor(e,t);(!s||("get"in s?!e.__esModule:s.writable||s.configurable))&&(s={enumerable:!0,get:function(){return e[t]}}),Object.defineProperty(r,n,s)}):(function(r,e,t,n){n===void 0&&(n=t),r[n]=e[t]})),Lg=Xt&&Xt.__setModuleDefault||(Object.create?(function(r,e){Object.defineProperty(r,"default",{enumerable:!0,value:e})}):function(r,e){r.default=e}),Ng=Xt&&Xt.__importStar||function(r){if(r&&r.__esModule)return r;var e={};if(r!=null)for(var t in r)t!=="default"&&Object.prototype.hasOwnProperty.call(r,t)&&Ig(e,r,t);return Lg(e,r),e};Object.defineProperty(Xt,"__esModule",{value:!0});Xt.XHR=void 0;var mu=Ng(Hf()),yu=Ko(),Dg=mu.default||mu,$o=class extends yu.BaseXHR{request(e={}){var t;return Object.assign(e,{xd:this.xd,cookieJar:(t=this.socket)===null||t===void 0?void 0:t._cookieJar},this.opts),new yu.Request(n=>new Dg(n),this.uri(),e)}};Xt.XHR=$o});var lr=D((dw,vu)=>{"use strict";var Eu=["nodebuffer","arraybuffer","fragments"],wu=typeof Blob<"u";wu&&Eu.push("blob");vu.exports={BINARY_TYPES:Eu,EMPTY_BUFFER:Buffer.alloc(0),GUID:"258EAFA5-E914-47DA-95CA-C5AB0DC85B11",hasBlob:wu,kForOnEventAttribute:Symbol("kIsForOnEventAttribute"),kListener:Symbol("kListener"),kStatusCode:Symbol("status-code"),kWebSocket:Symbol("websocket"),NOOP:()=>{}}});var is=D((pw,mi)=>{"use strict";var{EMPTY_BUFFER:Fg}=lr(),Go=Buffer[Symbol.species];function Mg(r,e){if(r.length===0)return Fg;if(r.length===1)return r[0];let t=Buffer.allocUnsafe(e),n=0;for(let s=0;s<r.length;s++){let i=r[s];t.set(i,n),n+=i.length}return n<e?new Go(t.buffer,t.byteOffset,n):t}function xu(r,e,t,n,s){for(let i=0;i<s;i++)t[n+i]=r[i]^e[i&3]}function bu(r,e){for(let t=0;t<r.length;t++)r[t]^=e[t&3]}function Bg(r){return r.length===r.buffer.byteLength?r.buffer:r.buffer.slice(r.byteOffset,r.byteOffset+r.length)}function Yo(r){if(Yo.readOnly=!0,Buffer.isBuffer(r))return r;let e;return r instanceof ArrayBuffer?e=new Go(r):ArrayBuffer.isView(r)?e=new Go(r.buffer,r.byteOffset,r.byteLength):(e=Buffer.from(r),Yo.readOnly=!1),e}mi.exports={concat:Mg,mask:xu,toArrayBuffer:Bg,toBuffer:Yo,unmask:bu};if(!process.env.WS_NO_BUFFER_UTIL)try{let r=require("bufferutil");mi.exports.mask=function(e,t,n,s,i){i<48?xu(e,t,n,s,i):r.mask(e,t,n,s,i)},mi.exports.unmask=function(e,t){e.length<32?bu(e,t):r.unmask(e,t)}}catch{}});var Ou=D((gw,Tu)=>{"use strict";var Su=Symbol("kDone"),Xo=Symbol("kRun"),Jo=class{constructor(e){this[Su]=()=>{this.pending--,this[Xo]()},this.concurrency=e||1/0,this.jobs=[],this.pending=0}add(e){this.jobs.push(e),this[Xo]()}[Xo](){if(this.pending!==this.concurrency&&this.jobs.length){let e=this.jobs.shift();this.pending++,e(this[Su])}}};Tu.exports=Jo});var as=D((_w,Ru)=>{"use strict";var os=require("zlib"),Cu=is(),jg=Ou(),{kStatusCode:ku}=lr(),Ug=Buffer[Symbol.species],qg=Buffer.from([0,0,255,255]),Ei=Symbol("permessage-deflate"),hr=Symbol("total-length"),Pn=Symbol("callback"),Ar=Symbol("buffers"),Rn=Symbol("error"),yi,Zo=class{constructor(e,t,n){if(this._maxPayload=n|0,this._options=e||{},this._threshold=this._options.threshold!==void 0?this._options.threshold:1024,this._isServer=!!t,this._deflate=null,this._inflate=null,this.params=null,!yi){let s=this._options.concurrencyLimit!==void 0?this._options.concurrencyLimit:10;yi=new jg(s)}}static get extensionName(){return"permessage-deflate"}offer(){let e={};return this._options.serverNoContextTakeover&&(e.server_no_context_takeover=!0),this._options.clientNoContextTakeover&&(e.client_no_context_takeover=!0),this._options.serverMaxWindowBits&&(e.server_max_window_bits=this._options.serverMaxWindowBits),this._options.clientMaxWindowBits?e.client_max_window_bits=this._options.clientMaxWindowBits:this._options.clientMaxWindowBits==null&&(e.client_max_window_bits=!0),e}accept(e){return e=this.normalizeParams(e),this.params=this._isServer?this.acceptAsServer(e):this.acceptAsClient(e),this.params}cleanup(){if(this._inflate&&(this._inflate.close(),this._inflate=null),this._deflate){let e=this._deflate[Pn];this._deflate.close(),this._deflate=null,e&&e(new Error("The deflate stream was closed while data was being processed"))}}acceptAsServer(e){let t=this._options,n=e.find(s=>!(t.serverNoContextTakeover===!1&&s.server_no_context_takeover||s.server_max_window_bits&&(t.serverMaxWindowBits===!1||typeof t.serverMaxWindowBits=="number"&&t.serverMaxWindowBits>s.server_max_window_bits)||typeof t.clientMaxWindowBits=="number"&&!s.client_max_window_bits));if(!n)throw new Error("None of the extension offers can be accepted");return t.serverNoContextTakeover&&(n.server_no_context_takeover=!0),t.clientNoContextTakeover&&(n.client_no_context_takeover=!0),typeof t.serverMaxWindowBits=="number"&&(n.server_max_window_bits=t.serverMaxWindowBits),typeof t.clientMaxWindowBits=="number"?n.client_max_window_bits=t.clientMaxWindowBits:(n.client_max_window_bits===!0||t.clientMaxWindowBits===!1)&&delete n.client_max_window_bits,n}acceptAsClient(e){let t=e[0];if(this._options.clientNoContextTakeover===!1&&t.client_no_context_takeover)throw new Error('Unexpected parameter "client_no_context_takeover"');if(!t.client_max_window_bits)typeof this._options.clientMaxWindowBits=="number"&&(t.client_max_window_bits=this._options.clientMaxWindowBits);else if(this._options.clientMaxWindowBits===!1||typeof this._options.clientMaxWindowBits=="number"&&t.client_max_window_bits>this._options.clientMaxWindowBits)throw new Error('Unexpected or invalid parameter "client_max_window_bits"');return t}normalizeParams(e){return e.forEach(t=>{Object.keys(t).forEach(n=>{let s=t[n];if(s.length>1)throw new Error(`Parameter "${n}" must have only a single value`);if(s=s[0],n==="client_max_window_bits"){if(s!==!0){let i=+s;if(!Number.isInteger(i)||i<8||i>15)throw new TypeError(`Invalid value for parameter "${n}": ${s}`);s=i}else if(!this._isServer)throw new TypeError(`Invalid value for parameter "${n}": ${s}`)}else if(n==="server_max_window_bits"){let i=+s;if(!Number.isInteger(i)||i<8||i>15)throw new TypeError(`Invalid value for parameter "${n}": ${s}`);s=i}else if(n==="client_no_context_takeover"||n==="server_no_context_takeover"){if(s!==!0)throw new TypeError(`Invalid value for parameter "${n}": ${s}`)}else throw new Error(`Unknown parameter "${n}"`);t[n]=s})}),e}decompress(e,t,n){yi.add(s=>{this._decompress(e,t,(i,a)=>{s(),n(i,a)})})}compress(e,t,n){yi.add(s=>{this._compress(e,t,(i,a)=>{s(),n(i,a)})})}_decompress(e,t,n){let s=this._isServer?"client":"server";if(!this._inflate){let i=`${s}_max_window_bits`,a=typeof this.params[i]!="number"?os.Z_DEFAULT_WINDOWBITS:this.params[i];this._inflate=os.createInflateRaw({...this._options.zlibInflateOptions,windowBits:a}),this._inflate[Ei]=this,this._inflate[hr]=0,this._inflate[Ar]=[],this._inflate.on("error",Hg),this._inflate.on("data",Pu)}this._inflate[Pn]=n,this._inflate.write(e),t&&this._inflate.write(qg),this._inflate.flush(()=>{let i=this._inflate[Rn];if(i){this._inflate.close(),this._inflate=null,n(i);return}let a=Cu.concat(this._inflate[Ar],this._inflate[hr]);this._inflate._readableState.endEmitted?(this._inflate.close(),this._inflate=null):(this._inflate[hr]=0,this._inflate[Ar]=[],t&&this.params[`${s}_no_context_takeover`]&&this._inflate.reset()),n(null,a)})}_compress(e,t,n){let s=this._isServer?"server":"client";if(!this._deflate){let i=`${s}_max_window_bits`,a=typeof this.params[i]!="number"?os.Z_DEFAULT_WINDOWBITS:this.params[i];this._deflate=os.createDeflateRaw({...this._options.zlibDeflateOptions,windowBits:a}),this._deflate[hr]=0,this._deflate[Ar]=[],this._deflate.on("data",Wg)}this._deflate[Pn]=n,this._deflate.write(e),this._deflate.flush(os.Z_SYNC_FLUSH,()=>{if(!this._deflate)return;let i=Cu.concat(this._deflate[Ar],this._deflate[hr]);t&&(i=new Ug(i.buffer,i.byteOffset,i.length-4)),this._deflate[Pn]=null,this._deflate[hr]=0,this._deflate[Ar]=[],t&&this.params[`${s}_no_context_takeover`]&&this._deflate.reset(),n(null,i)})}};Ru.exports=Zo;function Wg(r){this[Ar].push(r),this[hr]+=r.length}function Pu(r){if(this[hr]+=r.length,this[Ei]._maxPayload<1||this[hr]<=this[Ei]._maxPayload){this[Ar].push(r);return}this[Rn]=new RangeError("Max payload size exceeded"),this[Rn].code="WS_ERR_UNSUPPORTED_MESSAGE_LENGTH",this[Rn][ku]=1009,this.removeListener("data",Pu),this.reset()}function Hg(r){if(this[Ei]._inflate=null,this[Rn]){this[Pn](this[Rn]);return}r[ku]=1007,this[Pn](r)}});var An=D((mw,wi)=>{"use strict";var{isUtf8:Au}=require("buffer"),{hasBlob:Vg}=lr(),Kg=[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 $g(r){return r>=1e3&&r<=1014&&r!==1004&&r!==1005&&r!==1006||r>=3e3&&r<=4999}function Qo(r){let e=r.length,t=0;for(;t<e;)if((r[t]&128)===0)t++;else if((r[t]&224)===192){if(t+1===e||(r[t+1]&192)!==128||(r[t]&254)===192)return!1;t+=2}else if((r[t]&240)===224){if(t+2>=e||(r[t+1]&192)!==128||(r[t+2]&192)!==128||r[t]===224&&(r[t+1]&224)===128||r[t]===237&&(r[t+1]&224)===160)return!1;t+=3}else if((r[t]&248)===240){if(t+3>=e||(r[t+1]&192)!==128||(r[t+2]&192)!==128||(r[t+3]&192)!==128||r[t]===240&&(r[t+1]&240)===128||r[t]===244&&r[t+1]>143||r[t]>244)return!1;t+=4}else return!1;return!0}function zg(r){return Vg&&typeof r=="object"&&typeof r.arrayBuffer=="function"&&typeof r.type=="string"&&typeof r.stream=="function"&&(r[Symbol.toStringTag]==="Blob"||r[Symbol.toStringTag]==="File")}wi.exports={isBlob:zg,isValidStatusCode:$g,isValidUTF8:Qo,tokenChars:Kg};if(Au)wi.exports.isValidUTF8=function(r){return r.length<24?Qo(r):Au(r)};else if(!process.env.WS_NO_UTF_8_VALIDATE)try{let r=require("utf-8-validate");wi.exports.isValidUTF8=function(e){return e.length<32?Qo(e):r(e)}}catch{}});var sa=D((yw,Bu)=>{"use strict";var{Writable:Gg}=require("stream"),Iu=as(),{BINARY_TYPES:Yg,EMPTY_BUFFER:Lu,kStatusCode:Xg,kWebSocket:Jg}=lr(),{concat:ea,toArrayBuffer:Zg,unmask:Qg}=is(),{isValidStatusCode:e0,isValidUTF8:Nu}=An(),vi=Buffer[Symbol.species],Rt=0,Du=1,Fu=2,Mu=3,ta=4,ra=5,xi=6,na=class extends Gg{constructor(e={}){super(),this._allowSynchronousEvents=e.allowSynchronousEvents!==void 0?e.allowSynchronousEvents:!0,this._binaryType=e.binaryType||Yg[0],this._extensions=e.extensions||{},this._isServer=!!e.isServer,this._maxPayload=e.maxPayload|0,this._skipUTF8Validation=!!e.skipUTF8Validation,this[Jg]=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=Rt}_write(e,t,n){if(this._opcode===8&&this._state==Rt)return n();this._bufferedBytes+=e.length,this._buffers.push(e),this.startLoop(n)}consume(e){if(this._bufferedBytes-=e,e===this._buffers[0].length)return this._buffers.shift();if(e<this._buffers[0].length){let n=this._buffers[0];return this._buffers[0]=new vi(n.buffer,n.byteOffset+e,n.length-e),new vi(n.buffer,n.byteOffset,e)}let t=Buffer.allocUnsafe(e);do{let n=this._buffers[0],s=t.length-e;e>=n.length?t.set(this._buffers.shift(),s):(t.set(new Uint8Array(n.buffer,n.byteOffset,e),s),this._buffers[0]=new vi(n.buffer,n.byteOffset+e,n.length-e)),e-=n.length}while(e>0);return t}startLoop(e){this._loop=!0;do switch(this._state){case Rt:this.getInfo(e);break;case Du:this.getPayloadLength16(e);break;case Fu:this.getPayloadLength64(e);break;case Mu:this.getMask();break;case ta:this.getData(e);break;case ra:case xi:this._loop=!1;return}while(this._loop);this._errored||e()}getInfo(e){if(this._bufferedBytes<2){this._loop=!1;return}let t=this.consume(2);if((t[0]&48)!==0){let s=this.createError(RangeError,"RSV2 and RSV3 must be clear",!0,1002,"WS_ERR_UNEXPECTED_RSV_2_3");e(s);return}let n=(t[0]&64)===64;if(n&&!this._extensions[Iu.extensionName]){let s=this.createError(RangeError,"RSV1 must be clear",!0,1002,"WS_ERR_UNEXPECTED_RSV_1");e(s);return}if(this._fin=(t[0]&128)===128,this._opcode=t[0]&15,this._payloadLength=t[1]&127,this._opcode===0){if(n){let s=this.createError(RangeError,"RSV1 must be clear",!0,1002,"WS_ERR_UNEXPECTED_RSV_1");e(s);return}if(!this._fragmented){let s=this.createError(RangeError,"invalid opcode 0",!0,1002,"WS_ERR_INVALID_OPCODE");e(s);return}this._opcode=this._fragmented}else if(this._opcode===1||this._opcode===2){if(this._fragmented){let s=this.createError(RangeError,`invalid opcode ${this._opcode}`,!0,1002,"WS_ERR_INVALID_OPCODE");e(s);return}this._compressed=n}else if(this._opcode>7&&this._opcode<11){if(!this._fin){let s=this.createError(RangeError,"FIN must be set",!0,1002,"WS_ERR_EXPECTED_FIN");e(s);return}if(n){let s=this.createError(RangeError,"RSV1 must be clear",!0,1002,"WS_ERR_UNEXPECTED_RSV_1");e(s);return}if(this._payloadLength>125||this._opcode===8&&this._payloadLength===1){let s=this.createError(RangeError,`invalid payload length ${this._payloadLength}`,!0,1002,"WS_ERR_INVALID_CONTROL_PAYLOAD_LENGTH");e(s);return}}else{let s=this.createError(RangeError,`invalid opcode ${this._opcode}`,!0,1002,"WS_ERR_INVALID_OPCODE");e(s);return}if(!this._fin&&!this._fragmented&&(this._fragmented=this._opcode),this._masked=(t[1]&128)===128,this._isServer){if(!this._masked){let s=this.createError(RangeError,"MASK must be set",!0,1002,"WS_ERR_EXPECTED_MASK");e(s);return}}else if(this._masked){let s=this.createError(RangeError,"MASK must be clear",!0,1002,"WS_ERR_UNEXPECTED_MASK");e(s);return}this._payloadLength===126?this._state=Du:this._payloadLength===127?this._state=Fu:this.haveLength(e)}getPayloadLength16(e){if(this._bufferedBytes<2){this._loop=!1;return}this._payloadLength=this.consume(2).readUInt16BE(0),this.haveLength(e)}getPayloadLength64(e){if(this._bufferedBytes<8){this._loop=!1;return}let t=this.consume(8),n=t.readUInt32BE(0);if(n>Math.pow(2,21)-1){let s=this.createError(RangeError,"Unsupported WebSocket frame: payload length > 2^53 - 1",!1,1009,"WS_ERR_UNSUPPORTED_DATA_PAYLOAD_LENGTH");e(s);return}this._payloadLength=n*Math.pow(2,32)+t.readUInt32BE(4),this.haveLength(e)}haveLength(e){if(this._payloadLength&&this._opcode<8&&(this._totalPayloadLength+=this._payloadLength,this._totalPayloadLength>this._maxPayload&&this._maxPayload>0)){let t=this.createError(RangeError,"Max payload size exceeded",!1,1009,"WS_ERR_UNSUPPORTED_MESSAGE_LENGTH");e(t);return}this._masked?this._state=Mu:this._state=ta}getMask(){if(this._bufferedBytes<4){this._loop=!1;return}this._mask=this.consume(4),this._state=ta}getData(e){let t=Lu;if(this._payloadLength){if(this._bufferedBytes<this._payloadLength){this._loop=!1;return}t=this.consume(this._payloadLength),this._masked&&(this._mask[0]|this._mask[1]|this._mask[2]|this._mask[3])!==0&&Qg(t,this._mask)}if(this._opcode>7){this.controlMessage(t,e);return}if(this._compressed){this._state=ra,this.decompress(t,e);return}t.length&&(this._messageLength=this._totalPayloadLength,this._fragments.push(t)),this.dataMessage(e)}decompress(e,t){this._extensions[Iu.extensionName].decompress(e,this._fin,(s,i)=>{if(s)return t(s);if(i.length){if(this._messageLength+=i.length,this._messageLength>this._maxPayload&&this._maxPayload>0){let a=this.createError(RangeError,"Max payload size exceeded",!1,1009,"WS_ERR_UNSUPPORTED_MESSAGE_LENGTH");t(a);return}this._fragments.push(i)}this.dataMessage(t),this._state===Rt&&this.startLoop(t)})}dataMessage(e){if(!this._fin){this._state=Rt;return}let t=this._messageLength,n=this._fragments;if(this._totalPayloadLength=0,this._messageLength=0,this._fragmented=0,this._fragments=[],this._opcode===2){let s;this._binaryType==="nodebuffer"?s=ea(n,t):this._binaryType==="arraybuffer"?s=Zg(ea(n,t)):this._binaryType==="blob"?s=new Blob(n):s=n,this._allowSynchronousEvents?(this.emit("message",s,!0),this._state=Rt):(this._state=xi,setImmediate(()=>{this.emit("message",s,!0),this._state=Rt,this.startLoop(e)}))}else{let s=ea(n,t);if(!this._skipUTF8Validation&&!Nu(s)){let i=this.createError(Error,"invalid UTF-8 sequence",!0,1007,"WS_ERR_INVALID_UTF8");e(i);return}this._state===ra||this._allowSynchronousEvents?(this.emit("message",s,!1),this._state=Rt):(this._state=xi,setImmediate(()=>{this.emit("message",s,!1),this._state=Rt,this.startLoop(e)}))}}controlMessage(e,t){if(this._opcode===8){if(e.length===0)this._loop=!1,this.emit("conclude",1005,Lu),this.end();else{let n=e.readUInt16BE(0);if(!e0(n)){let i=this.createError(RangeError,`invalid status code ${n}`,!0,1002,"WS_ERR_INVALID_CLOSE_CODE");t(i);return}let s=new vi(e.buffer,e.byteOffset+2,e.length-2);if(!this._skipUTF8Validation&&!Nu(s)){let i=this.createError(Error,"invalid UTF-8 sequence",!0,1007,"WS_ERR_INVALID_UTF8");t(i);return}this._loop=!1,this.emit("conclude",n,s),this.end()}this._state=Rt;return}this._allowSynchronousEvents?(this.emit(this._opcode===9?"ping":"pong",e),this._state=Rt):(this._state=xi,setImmediate(()=>{this.emit(this._opcode===9?"ping":"pong",e),this._state=Rt,this.startLoop(t)}))}createError(e,t,n,s,i){this._loop=!1,this._errored=!0;let a=new e(n?`Invalid WebSocket frame: ${t}`:t);return Error.captureStackTrace(a,this.createError),a.code=i,a[Xg]=s,a}};Bu.exports=na});var aa=D((ww,qu)=>{"use strict";var{Duplex:Ew}=require("stream"),{randomFillSync:t0}=require("crypto"),ju=as(),{EMPTY_BUFFER:r0,kWebSocket:n0,NOOP:s0}=lr(),{isBlob:In,isValidStatusCode:i0}=An(),{mask:Uu,toBuffer:Qr}=is(),At=Symbol("kByteLength"),o0=Buffer.alloc(4),bi=8*1024,en,Ln=bi,Ft=0,a0=1,c0=2,ia=class r{constructor(e,t,n){this._extensions=t||{},n&&(this._generateMask=n,this._maskBuffer=Buffer.alloc(4)),this._socket=e,this._firstFragment=!0,this._compress=!1,this._bufferedBytes=0,this._queue=[],this._state=Ft,this.onerror=s0,this[n0]=void 0}static frame(e,t){let n,s=!1,i=2,a=!1;t.mask&&(n=t.maskBuffer||o0,t.generateMask?t.generateMask(n):(Ln===bi&&(en===void 0&&(en=Buffer.alloc(bi)),t0(en,0,bi),Ln=0),n[0]=en[Ln++],n[1]=en[Ln++],n[2]=en[Ln++],n[3]=en[Ln++]),a=(n[0]|n[1]|n[2]|n[3])===0,i=6);let f;typeof e=="string"?(!t.mask||a)&&t[At]!==void 0?f=t[At]:(e=Buffer.from(e),f=e.length):(f=e.length,s=t.mask&&t.readOnly&&!a);let u=f;f>=65536?(i+=8,u=127):f>125&&(i+=2,u=126);let d=Buffer.allocUnsafe(s?f+i:i);return d[0]=t.fin?t.opcode|128:t.opcode,t.rsv1&&(d[0]|=64),d[1]=u,u===126?d.writeUInt16BE(f,2):u===127&&(d[2]=d[3]=0,d.writeUIntBE(f,4,6)),t.mask?(d[1]|=128,d[i-4]=n[0],d[i-3]=n[1],d[i-2]=n[2],d[i-1]=n[3],a?[d,e]:s?(Uu(e,n,d,i,f),[d]):(Uu(e,n,e,0,f),[d,e])):[d,e]}close(e,t,n,s){let i;if(e===void 0)i=r0;else{if(typeof e!="number"||!i0(e))throw new TypeError("First argument must be a valid error code number");if(t===void 0||!t.length)i=Buffer.allocUnsafe(2),i.writeUInt16BE(e,0);else{let f=Buffer.byteLength(t);if(f>123)throw new RangeError("The message must not be greater than 123 bytes");i=Buffer.allocUnsafe(2+f),i.writeUInt16BE(e,0),typeof t=="string"?i.write(t,2):i.set(t,2)}}let a={[At]:i.length,fin:!0,generateMask:this._generateMask,mask:n,maskBuffer:this._maskBuffer,opcode:8,readOnly:!1,rsv1:!1};this._state!==Ft?this.enqueue([this.dispatch,i,!1,a,s]):this.sendFrame(r.frame(i,a),s)}ping(e,t,n){let s,i;if(typeof e=="string"?(s=Buffer.byteLength(e),i=!1):In(e)?(s=e.size,i=!1):(e=Qr(e),s=e.length,i=Qr.readOnly),s>125)throw new RangeError("The data size must not be greater than 125 bytes");let a={[At]:s,fin:!0,generateMask:this._generateMask,mask:t,maskBuffer:this._maskBuffer,opcode:9,readOnly:i,rsv1:!1};In(e)?this._state!==Ft?this.enqueue([this.getBlobData,e,!1,a,n]):this.getBlobData(e,!1,a,n):this._state!==Ft?this.enqueue([this.dispatch,e,!1,a,n]):this.sendFrame(r.frame(e,a),n)}pong(e,t,n){let s,i;if(typeof e=="string"?(s=Buffer.byteLength(e),i=!1):In(e)?(s=e.size,i=!1):(e=Qr(e),s=e.length,i=Qr.readOnly),s>125)throw new RangeError("The data size must not be greater than 125 bytes");let a={[At]:s,fin:!0,generateMask:this._generateMask,mask:t,maskBuffer:this._maskBuffer,opcode:10,readOnly:i,rsv1:!1};In(e)?this._state!==Ft?this.enqueue([this.getBlobData,e,!1,a,n]):this.getBlobData(e,!1,a,n):this._state!==Ft?this.enqueue([this.dispatch,e,!1,a,n]):this.sendFrame(r.frame(e,a),n)}send(e,t,n){let s=this._extensions[ju.extensionName],i=t.binary?2:1,a=t.compress,f,u;typeof e=="string"?(f=Buffer.byteLength(e),u=!1):In(e)?(f=e.size,u=!1):(e=Qr(e),f=e.length,u=Qr.readOnly),this._firstFragment?(this._firstFragment=!1,a&&s&&s.params[s._isServer?"server_no_context_takeover":"client_no_context_takeover"]&&(a=f>=s._threshold),this._compress=a):(a=!1,i=0),t.fin&&(this._firstFragment=!0);let d={[At]:f,fin:t.fin,generateMask:this._generateMask,mask:t.mask,maskBuffer:this._maskBuffer,opcode:i,readOnly:u,rsv1:a};In(e)?this._state!==Ft?this.enqueue([this.getBlobData,e,this._compress,d,n]):this.getBlobData(e,this._compress,d,n):this._state!==Ft?this.enqueue([this.dispatch,e,this._compress,d,n]):this.dispatch(e,this._compress,d,n)}getBlobData(e,t,n,s){this._bufferedBytes+=n[At],this._state=c0,e.arrayBuffer().then(i=>{if(this._socket.destroyed){let f=new Error("The socket was closed while the blob was being read");process.nextTick(oa,this,f,s);return}this._bufferedBytes-=n[At];let a=Qr(i);t?this.dispatch(a,t,n,s):(this._state=Ft,this.sendFrame(r.frame(a,n),s),this.dequeue())}).catch(i=>{process.nextTick(f0,this,i,s)})}dispatch(e,t,n,s){if(!t){this.sendFrame(r.frame(e,n),s);return}let i=this._extensions[ju.extensionName];this._bufferedBytes+=n[At],this._state=a0,i.compress(e,n.fin,(a,f)=>{if(this._socket.destroyed){let u=new Error("The socket was closed while data was being compressed");oa(this,u,s);return}this._bufferedBytes-=n[At],this._state=Ft,n.readOnly=!1,this.sendFrame(r.frame(f,n),s),this.dequeue()})}dequeue(){for(;this._state===Ft&&this._queue.length;){let e=this._queue.shift();this._bufferedBytes-=e[3][At],Reflect.apply(e[0],this,e.slice(1))}}enqueue(e){this._bufferedBytes+=e[3][At],this._queue.push(e)}sendFrame(e,t){e.length===2?(this._socket.cork(),this._socket.write(e[0]),this._socket.write(e[1],t),this._socket.uncork()):this._socket.write(e[0],t)}};qu.exports=ia;function oa(r,e,t){typeof t=="function"&&t(e);for(let n=0;n<r._queue.length;n++){let s=r._queue[n],i=s[s.length-1];typeof i=="function"&&i(e)}}function f0(r,e,t){oa(r,e,t),r.onerror(e)}});var Xu=D((vw,Yu)=>{"use strict";var{kForOnEventAttribute:cs,kListener:ca}=lr(),Wu=Symbol("kCode"),Hu=Symbol("kData"),Vu=Symbol("kError"),Ku=Symbol("kMessage"),$u=Symbol("kReason"),Nn=Symbol("kTarget"),zu=Symbol("kType"),Gu=Symbol("kWasClean"),dr=class{constructor(e){this[Nn]=null,this[zu]=e}get target(){return this[Nn]}get type(){return this[zu]}};Object.defineProperty(dr.prototype,"target",{enumerable:!0});Object.defineProperty(dr.prototype,"type",{enumerable:!0});var tn=class extends dr{constructor(e,t={}){super(e),this[Wu]=t.code===void 0?0:t.code,this[$u]=t.reason===void 0?"":t.reason,this[Gu]=t.wasClean===void 0?!1:t.wasClean}get code(){return this[Wu]}get reason(){return this[$u]}get wasClean(){return this[Gu]}};Object.defineProperty(tn.prototype,"code",{enumerable:!0});Object.defineProperty(tn.prototype,"reason",{enumerable:!0});Object.defineProperty(tn.prototype,"wasClean",{enumerable:!0});var Dn=class extends dr{constructor(e,t={}){super(e),this[Vu]=t.error===void 0?null:t.error,this[Ku]=t.message===void 0?"":t.message}get error(){return this[Vu]}get message(){return this[Ku]}};Object.defineProperty(Dn.prototype,"error",{enumerable:!0});Object.defineProperty(Dn.prototype,"message",{enumerable:!0});var fs=class extends dr{constructor(e,t={}){super(e),this[Hu]=t.data===void 0?null:t.data}get data(){return this[Hu]}};Object.defineProperty(fs.prototype,"data",{enumerable:!0});var u0={addEventListener(r,e,t={}){for(let s of this.listeners(r))if(!t[cs]&&s[ca]===e&&!s[cs])return;let n;if(r==="message")n=function(i,a){let f=new fs("message",{data:a?i:i.toString()});f[Nn]=this,Si(e,this,f)};else if(r==="close")n=function(i,a){let f=new tn("close",{code:i,reason:a.toString(),wasClean:this._closeFrameReceived&&this._closeFrameSent});f[Nn]=this,Si(e,this,f)};else if(r==="error")n=function(i){let a=new Dn("error",{error:i,message:i.message});a[Nn]=this,Si(e,this,a)};else if(r==="open")n=function(){let i=new dr("open");i[Nn]=this,Si(e,this,i)};else return;n[cs]=!!t[cs],n[ca]=e,t.once?this.once(r,n):this.on(r,n)},removeEventListener(r,e){for(let t of this.listeners(r))if(t[ca]===e&&!t[cs]){this.removeListener(r,t);break}}};Yu.exports={CloseEvent:tn,ErrorEvent:Dn,Event:dr,EventTarget:u0,MessageEvent:fs};function Si(r,e,t){typeof r=="object"&&r.handleEvent?r.handleEvent.call(r,t):r.call(e,t)}});var fa=D((xw,Ju)=>{"use strict";var{tokenChars:us}=An();function Jt(r,e,t){r[e]===void 0?r[e]=[t]:r[e].push(t)}function l0(r){let e=Object.create(null),t=Object.create(null),n=!1,s=!1,i=!1,a,f,u=-1,d=-1,g=-1,_=0;for(;_<r.length;_++)if(d=r.charCodeAt(_),a===void 0)if(g===-1&&us[d]===1)u===-1&&(u=_);else if(_!==0&&(d===32||d===9))g===-1&&u!==-1&&(g=_);else if(d===59||d===44){if(u===-1)throw new SyntaxError(`Unexpected character at index ${_}`);g===-1&&(g=_);let v=r.slice(u,g);d===44?(Jt(e,v,t),t=Object.create(null)):a=v,u=g=-1}else throw new SyntaxError(`Unexpected character at index ${_}`);else if(f===void 0)if(g===-1&&us[d]===1)u===-1&&(u=_);else if(d===32||d===9)g===-1&&u!==-1&&(g=_);else if(d===59||d===44){if(u===-1)throw new SyntaxError(`Unexpected character at index ${_}`);g===-1&&(g=_),Jt(t,r.slice(u,g),!0),d===44&&(Jt(e,a,t),t=Object.create(null),a=void 0),u=g=-1}else if(d===61&&u!==-1&&g===-1)f=r.slice(u,_),u=g=-1;else throw new SyntaxError(`Unexpected character at index ${_}`);else if(s){if(us[d]!==1)throw new SyntaxError(`Unexpected character at index ${_}`);u===-1?u=_:n||(n=!0),s=!1}else if(i)if(us[d]===1)u===-1&&(u=_);else if(d===34&&u!==-1)i=!1,g=_;else if(d===92)s=!0;else throw new SyntaxError(`Unexpected character at index ${_}`);else if(d===34&&r.charCodeAt(_-1)===61)i=!0;else if(g===-1&&us[d]===1)u===-1&&(u=_);else if(u!==-1&&(d===32||d===9))g===-1&&(g=_);else if(d===59||d===44){if(u===-1)throw new SyntaxError(`Unexpected character at index ${_}`);g===-1&&(g=_);let v=r.slice(u,g);n&&(v=v.replace(/\\/g,""),n=!1),Jt(t,f,v),d===44&&(Jt(e,a,t),t=Object.create(null),a=void 0),f=void 0,u=g=-1}else throw new SyntaxError(`Unexpected character at index ${_}`);if(u===-1||i||d===32||d===9)throw new SyntaxError("Unexpected end of input");g===-1&&(g=_);let y=r.slice(u,g);return a===void 0?Jt(e,y,t):(f===void 0?Jt(t,y,!0):n?Jt(t,f,y.replace(/\\/g,"")):Jt(t,f,y),Jt(e,a,t)),e}function h0(r){return Object.keys(r).map(e=>{let t=r[e];return Array.isArray(t)||(t=[t]),t.map(n=>[e].concat(Object.keys(n).map(s=>{let i=n[s];return Array.isArray(i)||(i=[i]),i.map(a=>a===!0?s:`${s}=${a}`).join("; ")})).join("; ")).join(", ")}).join(", ")}Ju.exports={format:h0,parse:l0}});var ki=D((Tw,fl)=>{"use strict";var d0=require("events"),p0=require("https"),g0=require("http"),el=require("net"),_0=require("tls"),{randomBytes:m0,createHash:y0}=require("crypto"),{Duplex:bw,Readable:Sw}=require("stream"),{URL:ua}=require("url"),Ir=as(),E0=sa(),w0=aa(),{isBlob:v0}=An(),{BINARY_TYPES:Zu,EMPTY_BUFFER:Ti,GUID:x0,kForOnEventAttribute:la,kListener:b0,kStatusCode:S0,kWebSocket:tt,NOOP:tl}=lr(),{EventTarget:{addEventListener:T0,removeEventListener:O0}}=Xu(),{format:C0,parse:k0}=fa(),{toBuffer:P0}=is(),R0=30*1e3,rl=Symbol("kAborted"),ha=[8,13],pr=["CONNECTING","OPEN","CLOSING","CLOSED"],A0=/^[!#$%&'*+\-.0-9A-Z^_`|a-z~]+$/,Ue=class r extends d0{constructor(e,t,n){super(),this._binaryType=Zu[0],this._closeCode=1006,this._closeFrameReceived=!1,this._closeFrameSent=!1,this._closeMessage=Ti,this._closeTimer=null,this._errorEmitted=!1,this._extensions={},this._paused=!1,this._protocol="",this._readyState=r.CONNECTING,this._receiver=null,this._sender=null,this._socket=null,e!==null?(this._bufferedAmount=0,this._isServer=!1,this._redirects=0,t===void 0?t=[]:Array.isArray(t)||(typeof t=="object"&&t!==null?(n=t,t=[]):t=[t]),nl(this,e,t,n)):(this._autoPong=n.autoPong,this._isServer=!0)}get binaryType(){return this._binaryType}set binaryType(e){Zu.includes(e)&&(this._binaryType=e,this._receiver&&(this._receiver._binaryType=e))}get bufferedAmount(){return this._socket?this._socket._writableState.length+this._sender._bufferedBytes:this._bufferedAmount}get extensions(){return Object.keys(this._extensions).join()}get isPaused(){return this._paused}get onclose(){return null}get onerror(){return null}get onopen(){return null}get onmessage(){return null}get protocol(){return this._protocol}get readyState(){return this._readyState}get url(){return this._url}setSocket(e,t,n){let s=new E0({allowSynchronousEvents:n.allowSynchronousEvents,binaryType:this.binaryType,extensions:this._extensions,isServer:this._isServer,maxPayload:n.maxPayload,skipUTF8Validation:n.skipUTF8Validation}),i=new w0(e,this._extensions,n.generateMask);this._receiver=s,this._sender=i,this._socket=e,s[tt]=this,i[tt]=this,e[tt]=this,s.on("conclude",N0),s.on("drain",D0),s.on("error",F0),s.on("message",M0),s.on("ping",B0),s.on("pong",j0),i.onerror=U0,e.setTimeout&&e.setTimeout(0),e.setNoDelay&&e.setNoDelay(),t.length>0&&e.unshift(t),e.on("close",ol),e.on("data",Ci),e.on("end",al),e.on("error",cl),this._readyState=r.OPEN,this.emit("open")}emitClose(){if(!this._socket){this._readyState=r.CLOSED,this.emit("close",this._closeCode,this._closeMessage);return}this._extensions[Ir.extensionName]&&this._extensions[Ir.extensionName].cleanup(),this._receiver.removeAllListeners(),this._readyState=r.CLOSED,this.emit("close",this._closeCode,this._closeMessage)}close(e,t){if(this.readyState!==r.CLOSED){if(this.readyState===r.CONNECTING){bt(this,this._req,"WebSocket was closed before the connection was established");return}if(this.readyState===r.CLOSING){this._closeFrameSent&&(this._closeFrameReceived||this._receiver._writableState.errorEmitted)&&this._socket.end();return}this._readyState=r.CLOSING,this._sender.close(e,t,!this._isServer,n=>{n||(this._closeFrameSent=!0,(this._closeFrameReceived||this._receiver._writableState.errorEmitted)&&this._socket.end())}),il(this)}}pause(){this.readyState===r.CONNECTING||this.readyState===r.CLOSED||(this._paused=!0,this._socket.pause())}ping(e,t,n){if(this.readyState===r.CONNECTING)throw new Error("WebSocket is not open: readyState 0 (CONNECTING)");if(typeof e=="function"?(n=e,e=t=void 0):typeof t=="function"&&(n=t,t=void 0),typeof e=="number"&&(e=e.toString()),this.readyState!==r.OPEN){da(this,e,n);return}t===void 0&&(t=!this._isServer),this._sender.ping(e||Ti,t,n)}pong(e,t,n){if(this.readyState===r.CONNECTING)throw new Error("WebSocket is not open: readyState 0 (CONNECTING)");if(typeof e=="function"?(n=e,e=t=void 0):typeof t=="function"&&(n=t,t=void 0),typeof e=="number"&&(e=e.toString()),this.readyState!==r.OPEN){da(this,e,n);return}t===void 0&&(t=!this._isServer),this._sender.pong(e||Ti,t,n)}resume(){this.readyState===r.CONNECTING||this.readyState===r.CLOSED||(this._paused=!1,this._receiver._writableState.needDrain||this._socket.resume())}send(e,t,n){if(this.readyState===r.CONNECTING)throw new Error("WebSocket is not open: readyState 0 (CONNECTING)");if(typeof t=="function"&&(n=t,t={}),typeof e=="number"&&(e=e.toString()),this.readyState!==r.OPEN){da(this,e,n);return}let s={binary:typeof e!="string",mask:!this._isServer,compress:!0,fin:!0,...t};this._extensions[Ir.extensionName]||(s.compress=!1),this._sender.send(e||Ti,s,n)}terminate(){if(this.readyState!==r.CLOSED){if(this.readyState===r.CONNECTING){bt(this,this._req,"WebSocket was closed before the connection was established");return}this._socket&&(this._readyState=r.CLOSING,this._socket.destroy())}}};Object.defineProperty(Ue,"CONNECTING",{enumerable:!0,value:pr.indexOf("CONNECTING")});Object.defineProperty(Ue.prototype,"CONNECTING",{enumerable:!0,value:pr.indexOf("CONNECTING")});Object.defineProperty(Ue,"OPEN",{enumerable:!0,value:pr.indexOf("OPEN")});Object.defineProperty(Ue.prototype,"OPEN",{enumerable:!0,value:pr.indexOf("OPEN")});Object.defineProperty(Ue,"CLOSING",{enumerable:!0,value:pr.indexOf("CLOSING")});Object.defineProperty(Ue.prototype,"CLOSING",{enumerable:!0,value:pr.indexOf("CLOSING")});Object.defineProperty(Ue,"CLOSED",{enumerable:!0,value:pr.indexOf("CLOSED")});Object.defineProperty(Ue.prototype,"CLOSED",{enumerable:!0,value:pr.indexOf("CLOSED")});["binaryType","bufferedAmount","extensions","isPaused","protocol","readyState","url"].forEach(r=>{Object.defineProperty(Ue.prototype,r,{enumerable:!0})});["open","error","close","message"].forEach(r=>{Object.defineProperty(Ue.prototype,`on${r}`,{enumerable:!0,get(){for(let e of this.listeners(r))if(e[la])return e[b0];return null},set(e){for(let t of this.listeners(r))if(t[la]){this.removeListener(r,t);break}typeof e=="function"&&this.addEventListener(r,e,{[la]:!0})}})});Ue.prototype.addEventListener=T0;Ue.prototype.removeEventListener=O0;fl.exports=Ue;function nl(r,e,t,n){let s={allowSynchronousEvents:!0,autoPong:!0,protocolVersion:ha[1],maxPayload:104857600,skipUTF8Validation:!1,perMessageDeflate:!0,followRedirects:!1,maxRedirects:10,...n,socketPath:void 0,hostname:void 0,protocol:void 0,timeout:void 0,method:"GET",host:void 0,path:void 0,port:void 0};if(r._autoPong=s.autoPong,!ha.includes(s.protocolVersion))throw new RangeError(`Unsupported protocol version: ${s.protocolVersion} (supported versions: ${ha.join(", ")})`);let i;if(e instanceof ua)i=e;else try{i=new ua(e)}catch{throw new SyntaxError(`Invalid URL: ${e}`)}i.protocol==="http:"?i.protocol="ws:":i.protocol==="https:"&&(i.protocol="wss:"),r._url=i.href;let a=i.protocol==="wss:",f=i.protocol==="ws+unix:",u;if(i.protocol!=="ws:"&&!a&&!f?u=`The URL's protocol must be one of "ws:", "wss:", "http:", "https:", or "ws+unix:"`:f&&!i.pathname?u="The URL's pathname is empty":i.hash&&(u="The URL contains a fragment identifier"),u){let C=new SyntaxError(u);if(r._redirects===0)throw C;Oi(r,C);return}let d=a?443:80,g=m0(16).toString("base64"),_=a?p0.request:g0.request,y=new Set,v;if(s.createConnection=s.createConnection||(a?L0:I0),s.defaultPort=s.defaultPort||d,s.port=i.port||d,s.host=i.hostname.startsWith("[")?i.hostname.slice(1,-1):i.hostname,s.headers={...s.headers,"Sec-WebSocket-Version":s.protocolVersion,"Sec-WebSocket-Key":g,Connection:"Upgrade",Upgrade:"websocket"},s.path=i.pathname+i.search,s.timeout=s.handshakeTimeout,s.perMessageDeflate&&(v=new Ir(s.perMessageDeflate!==!0?s.perMessageDeflate:{},!1,s.maxPayload),s.headers["Sec-WebSocket-Extensions"]=C0({[Ir.extensionName]:v.offer()})),t.length){for(let C of t){if(typeof C!="string"||!A0.test(C)||y.has(C))throw new SyntaxError("An invalid or duplicated subprotocol was specified");y.add(C)}s.headers["Sec-WebSocket-Protocol"]=t.join(",")}if(s.origin&&(s.protocolVersion<13?s.headers["Sec-WebSocket-Origin"]=s.origin:s.headers.Origin=s.origin),(i.username||i.password)&&(s.auth=`${i.username}:${i.password}`),f){let C=s.path.split(":");s.socketPath=C[0],s.path=C[1]}let S;if(s.followRedirects){if(r._redirects===0){r._originalIpc=f,r._originalSecure=a,r._originalHostOrSocketPath=f?s.socketPath:i.host;let C=n&&n.headers;if(n={...n,headers:{}},C)for(let[H,z]of Object.entries(C))n.headers[H.toLowerCase()]=z}else if(r.listenerCount("redirect")===0){let C=f?r._originalIpc?s.socketPath===r._originalHostOrSocketPath:!1:r._originalIpc?!1:i.host===r._originalHostOrSocketPath;(!C||r._originalSecure&&!a)&&(delete s.headers.authorization,delete s.headers.cookie,C||delete s.headers.host,s.auth=void 0)}s.auth&&!n.headers.authorization&&(n.headers.authorization="Basic "+Buffer.from(s.auth).toString("base64")),S=r._req=_(s),r._redirects&&r.emit("redirect",r.url,S)}else S=r._req=_(s);s.timeout&&S.on("timeout",()=>{bt(r,S,"Opening handshake has timed out")}),S.on("error",C=>{S===null||S[rl]||(S=r._req=null,Oi(r,C))}),S.on("response",C=>{let H=C.headers.location,z=C.statusCode;if(H&&s.followRedirects&&z>=300&&z<400){if(++r._redirects>s.maxRedirects){bt(r,S,"Maximum redirects exceeded");return}S.abort();let X;try{X=new ua(H,e)}catch{let M=new SyntaxError(`Invalid URL: ${H}`);Oi(r,M);return}nl(r,X,t,n)}else r.emit("unexpected-response",S,C)||bt(r,S,`Unexpected server response: ${C.statusCode}`)}),S.on("upgrade",(C,H,z)=>{if(r.emit("upgrade",C),r.readyState!==Ue.CONNECTING)return;S=r._req=null;let X=C.headers.upgrade;if(X===void 0||X.toLowerCase()!=="websocket"){bt(r,H,"Invalid Upgrade header");return}let T=y0("sha1").update(g+x0).digest("base64");if(C.headers["sec-websocket-accept"]!==T){bt(r,H,"Invalid Sec-WebSocket-Accept header");return}let M=C.headers["sec-websocket-protocol"],Q;if(M!==void 0?y.size?y.has(M)||(Q="Server sent an invalid subprotocol"):Q="Server sent a subprotocol but none was requested":y.size&&(Q="Server sent no subprotocol"),Q){bt(r,H,Q);return}M&&(r._protocol=M);let B=C.headers["sec-websocket-extensions"];if(B!==void 0){if(!v){bt(r,H,"Server sent a Sec-WebSocket-Extensions header but no extension was requested");return}let ie;try{ie=k0(B)}catch{bt(r,H,"Invalid Sec-WebSocket-Extensions header");return}let he=Object.keys(ie);if(he.length!==1||he[0]!==Ir.extensionName){bt(r,H,"Server indicated an extension that was not requested");return}try{v.accept(ie[Ir.extensionName])}catch{bt(r,H,"Invalid Sec-WebSocket-Extensions header");return}r._extensions[Ir.extensionName]=v}r.setSocket(H,z,{allowSynchronousEvents:s.allowSynchronousEvents,generateMask:s.generateMask,maxPayload:s.maxPayload,skipUTF8Validation:s.skipUTF8Validation})}),s.finishRequest?s.finishRequest(S,r):S.end()}function Oi(r,e){r._readyState=Ue.CLOSING,r._errorEmitted=!0,r.emit("error",e),r.emitClose()}function I0(r){return r.path=r.socketPath,el.connect(r)}function L0(r){return r.path=void 0,!r.servername&&r.servername!==""&&(r.servername=el.isIP(r.host)?"":r.host),_0.connect(r)}function bt(r,e,t){r._readyState=Ue.CLOSING;let n=new Error(t);Error.captureStackTrace(n,bt),e.setHeader?(e[rl]=!0,e.abort(),e.socket&&!e.socket.destroyed&&e.socket.destroy(),process.nextTick(Oi,r,n)):(e.destroy(n),e.once("error",r.emit.bind(r,"error")),e.once("close",r.emitClose.bind(r)))}function da(r,e,t){if(e){let n=v0(e)?e.size:P0(e).length;r._socket?r._sender._bufferedBytes+=n:r._bufferedAmount+=n}if(t){let n=new Error(`WebSocket is not open: readyState ${r.readyState} (${pr[r.readyState]})`);process.nextTick(t,n)}}function N0(r,e){let t=this[tt];t._closeFrameReceived=!0,t._closeMessage=e,t._closeCode=r,t._socket[tt]!==void 0&&(t._socket.removeListener("data",Ci),process.nextTick(sl,t._socket),r===1005?t.close():t.close(r,e))}function D0(){let r=this[tt];r.isPaused||r._socket.resume()}function F0(r){let e=this[tt];e._socket[tt]!==void 0&&(e._socket.removeListener("data",Ci),process.nextTick(sl,e._socket),e.close(r[S0])),e._errorEmitted||(e._errorEmitted=!0,e.emit("error",r))}function Qu(){this[tt].emitClose()}function M0(r,e){this[tt].emit("message",r,e)}function B0(r){let e=this[tt];e._autoPong&&e.pong(r,!this._isServer,tl),e.emit("ping",r)}function j0(r){this[tt].emit("pong",r)}function sl(r){r.resume()}function U0(r){let e=this[tt];e.readyState!==Ue.CLOSED&&(e.readyState===Ue.OPEN&&(e._readyState=Ue.CLOSING,il(e)),this._socket.end(),e._errorEmitted||(e._errorEmitted=!0,e.emit("error",r)))}function il(r){r._closeTimer=setTimeout(r._socket.destroy.bind(r._socket),R0)}function ol(){let r=this[tt];this.removeListener("close",ol),this.removeListener("data",Ci),this.removeListener("end",al),r._readyState=Ue.CLOSING;let e;!this._readableState.endEmitted&&!r._closeFrameReceived&&!r._receiver._writableState.errorEmitted&&(e=r._socket.read())!==null&&r._receiver.write(e),r._receiver.end(),this[tt]=void 0,clearTimeout(r._closeTimer),r._receiver._writableState.finished||r._receiver._writableState.errorEmitted?r.emitClose():(r._receiver.on("error",Qu),r._receiver.on("finish",Qu))}function Ci(r){this[tt]._receiver.write(r)||this.pause()}function al(){let r=this[tt];r._readyState=Ue.CLOSING,r._receiver.end(),this.end()}function cl(){let r=this[tt];this.removeListener("error",cl),this.on("error",tl),r&&(r._readyState=Ue.CLOSING,this.destroy())}});var dl=D((Cw,hl)=>{"use strict";var Ow=ki(),{Duplex:q0}=require("stream");function ul(r){r.emit("close")}function W0(){!this.destroyed&&this._writableState.finished&&this.destroy()}function ll(r){this.removeListener("error",ll),this.destroy(),this.listenerCount("error")===0&&this.emit("error",r)}function H0(r,e){let t=!0,n=new q0({...e,autoDestroy:!1,emitClose:!1,objectMode:!1,writableObjectMode:!1});return r.on("message",function(i,a){let f=!a&&n._readableState.objectMode?i.toString():i;n.push(f)||r.pause()}),r.once("error",function(i){n.destroyed||(t=!1,n.destroy(i))}),r.once("close",function(){n.destroyed||n.push(null)}),n._destroy=function(s,i){if(r.readyState===r.CLOSED){i(s),process.nextTick(ul,n);return}let a=!1;r.once("error",function(u){a=!0,i(u)}),r.once("close",function(){a||i(s),process.nextTick(ul,n)}),t&&r.terminate()},n._final=function(s){if(r.readyState===r.CONNECTING){r.once("open",function(){n._final(s)});return}r._socket!==null&&(r._socket._writableState.finished?(s(),n._readableState.endEmitted&&n.destroy()):(r._socket.once("finish",function(){s()}),r.close()))},n._read=function(){r.isPaused&&r.resume()},n._write=function(s,i,a){if(r.readyState===r.CONNECTING){r.once("open",function(){n._write(s,i,a)});return}r.send(s,a)},n.on("end",W0),n.on("error",ll),n}hl.exports=H0});var gl=D((kw,pl)=>{"use strict";var{tokenChars:V0}=An();function K0(r){let e=new Set,t=-1,n=-1,s=0;for(s;s<r.length;s++){let a=r.charCodeAt(s);if(n===-1&&V0[a]===1)t===-1&&(t=s);else if(s!==0&&(a===32||a===9))n===-1&&t!==-1&&(n=s);else if(a===44){if(t===-1)throw new SyntaxError(`Unexpected character at index ${s}`);n===-1&&(n=s);let f=r.slice(t,n);if(e.has(f))throw new SyntaxError(`The "${f}" subprotocol is duplicated`);e.add(f),t=n=-1}else throw new SyntaxError(`Unexpected character at index ${s}`)}if(t===-1||n!==-1)throw new SyntaxError("Unexpected end of input");let i=r.slice(t,s);if(e.has(i))throw new SyntaxError(`The "${i}" subprotocol is duplicated`);return e.add(i),e}pl.exports={parse:K0}});var xl=D((Rw,vl)=>{"use strict";var $0=require("events"),Pi=require("http"),{Duplex:Pw}=require("stream"),{createHash:z0}=require("crypto"),_l=fa(),rn=as(),G0=gl(),Y0=ki(),{GUID:X0,kWebSocket:J0}=lr(),Z0=/^[+/0-9A-Za-z]{22}==$/,ml=0,yl=1,wl=2,pa=class extends $0{constructor(e,t){if(super(),e={allowSynchronousEvents:!0,autoPong:!0,maxPayload:100*1024*1024,skipUTF8Validation:!1,perMessageDeflate:!1,handleProtocols:null,clientTracking:!0,verifyClient:null,noServer:!1,backlog:null,server:null,host:null,path:null,port:null,WebSocket:Y0,...e},e.port==null&&!e.server&&!e.noServer||e.port!=null&&(e.server||e.noServer)||e.server&&e.noServer)throw new TypeError('One and only one of the "port", "server", or "noServer" options must be specified');if(e.port!=null?(this._server=Pi.createServer((n,s)=>{let i=Pi.STATUS_CODES[426];s.writeHead(426,{"Content-Length":i.length,"Content-Type":"text/plain"}),s.end(i)}),this._server.listen(e.port,e.host,e.backlog,t)):e.server&&(this._server=e.server),this._server){let n=this.emit.bind(this,"connection");this._removeListeners=Q0(this._server,{listening:this.emit.bind(this,"listening"),error:this.emit.bind(this,"error"),upgrade:(s,i,a)=>{this.handleUpgrade(s,i,a,n)}})}e.perMessageDeflate===!0&&(e.perMessageDeflate={}),e.clientTracking&&(this.clients=new Set,this._shouldEmitClose=!1),this.options=e,this._state=ml}address(){if(this.options.noServer)throw new Error('The server is operating in "noServer" mode');return this._server?this._server.address():null}close(e){if(this._state===wl){e&&this.once("close",()=>{e(new Error("The server is not running"))}),process.nextTick(ls,this);return}if(e&&this.once("close",e),this._state!==yl)if(this._state=yl,this.options.noServer||this.options.server)this._server&&(this._removeListeners(),this._removeListeners=this._server=null),this.clients?this.clients.size?this._shouldEmitClose=!0:process.nextTick(ls,this):process.nextTick(ls,this);else{let t=this._server;this._removeListeners(),this._removeListeners=this._server=null,t.close(()=>{ls(this)})}}shouldHandle(e){if(this.options.path){let t=e.url.indexOf("?");if((t!==-1?e.url.slice(0,t):e.url)!==this.options.path)return!1}return!0}handleUpgrade(e,t,n,s){t.on("error",El);let i=e.headers["sec-websocket-key"],a=e.headers.upgrade,f=+e.headers["sec-websocket-version"];if(e.method!=="GET"){nn(this,e,t,405,"Invalid HTTP method");return}if(a===void 0||a.toLowerCase()!=="websocket"){nn(this,e,t,400,"Invalid Upgrade header");return}if(i===void 0||!Z0.test(i)){nn(this,e,t,400,"Missing or invalid Sec-WebSocket-Key header");return}if(f!==13&&f!==8){nn(this,e,t,400,"Missing or invalid Sec-WebSocket-Version header",{"Sec-WebSocket-Version":"13, 8"});return}if(!this.shouldHandle(e)){hs(t,400);return}let u=e.headers["sec-websocket-protocol"],d=new Set;if(u!==void 0)try{d=G0.parse(u)}catch{nn(this,e,t,400,"Invalid Sec-WebSocket-Protocol header");return}let g=e.headers["sec-websocket-extensions"],_={};if(this.options.perMessageDeflate&&g!==void 0){let y=new rn(this.options.perMessageDeflate,!0,this.options.maxPayload);try{let v=_l.parse(g);v[rn.extensionName]&&(y.accept(v[rn.extensionName]),_[rn.extensionName]=y)}catch{nn(this,e,t,400,"Invalid or unacceptable Sec-WebSocket-Extensions header");return}}if(this.options.verifyClient){let y={origin:e.headers[`${f===8?"sec-websocket-origin":"origin"}`],secure:!!(e.socket.authorized||e.socket.encrypted),req:e};if(this.options.verifyClient.length===2){this.options.verifyClient(y,(v,S,C,H)=>{if(!v)return hs(t,S||401,C,H);this.completeUpgrade(_,i,d,e,t,n,s)});return}if(!this.options.verifyClient(y))return hs(t,401)}this.completeUpgrade(_,i,d,e,t,n,s)}completeUpgrade(e,t,n,s,i,a,f){if(!i.readable||!i.writable)return i.destroy();if(i[J0])throw new Error("server.handleUpgrade() was called more than once with the same socket, possibly due to a misconfiguration");if(this._state>ml)return hs(i,503);let d=["HTTP/1.1 101 Switching Protocols","Upgrade: websocket","Connection: Upgrade",`Sec-WebSocket-Accept: ${z0("sha1").update(t+X0).digest("base64")}`],g=new this.options.WebSocket(null,void 0,this.options);if(n.size){let _=this.options.handleProtocols?this.options.handleProtocols(n,s):n.values().next().value;_&&(d.push(`Sec-WebSocket-Protocol: ${_}`),g._protocol=_)}if(e[rn.extensionName]){let _=e[rn.extensionName].params,y=_l.format({[rn.extensionName]:[_]});d.push(`Sec-WebSocket-Extensions: ${y}`),g._extensions=e}this.emit("headers",d,s),i.write(d.concat(`\r
|
|
23
21
|
`).join(`\r
|
|
24
|
-
`)),i.removeListener("error",
|
|
22
|
+
`)),i.removeListener("error",El),g.setSocket(i,a,{allowSynchronousEvents:this.options.allowSynchronousEvents,maxPayload:this.options.maxPayload,skipUTF8Validation:this.options.skipUTF8Validation}),this.clients&&(this.clients.add(g),g.on("close",()=>{this.clients.delete(g),this._shouldEmitClose&&!this.clients.size&&process.nextTick(ls,this)})),f(g,s)}};vl.exports=pa;function Q0(r,e){for(let t of Object.keys(e))r.on(t,e[t]);return function(){for(let n of Object.keys(e))r.removeListener(n,e[n])}}function ls(r){r._state=wl,r.emit("close")}function El(){this.destroy()}function hs(r,e,t,n){t=t||Pi.STATUS_CODES[e],n={Connection:"close","Content-Type":"text/html","Content-Length":Buffer.byteLength(t),...n},r.once("finish",r.destroy),r.end(`HTTP/1.1 ${e} ${Pi.STATUS_CODES[e]}\r
|
|
25
23
|
`+Object.keys(n).map(s=>`${s}: ${n[s]}`).join(`\r
|
|
26
24
|
`)+`\r
|
|
27
25
|
\r
|
|
28
|
-
`+t)}function en(r,e,t,n,s,i){if(r.listenerCount("wsClientError")){let a=new Error(s);Error.captureStackTrace(a,en),r.emit("wsClientError",a,t,e)}else gs(t,n,s,i)}});var Hl=F((jw,Wl)=>{"use strict";var pr=Ci();pr.createWebSocketStream=Il();pr.Server=ql();pr.Receiver=wa();pr.Sender=ba();pr.WebSocket=pr;pr.WebSocketServer=pr.Server;Wl.exports=pr});var La=F(Lr=>{"use strict";var Q0=Lr&&Lr.__importDefault||function(r){return r&&r.__esModule?r:{default:r}};Object.defineProperty(Lr,"__esModule",{value:!0});Lr.WS=Lr.BaseWS=void 0;var e_=as(),Vl=Gr(),t_=xn(),Ia=zr(),r_=Q0(kt()),n_=(0,r_.default)("engine.io-client:websocket"),Kl=typeof navigator<"u"&&typeof navigator.product=="string"&&navigator.product.toLowerCase()==="reactnative",Pi=class extends e_.Transport{get name(){return"websocket"}doOpen(){let e=this.uri(),t=this.opts.protocols,n=Kl?{}:(0,Vl.pick)(this.opts,"agent","perMessageDeflate","pfx","key","passphrase","cert","ca","ciphers","rejectUnauthorized","localAddress","protocolVersion","origin","maxPayload","family","checkServerIdentity");this.opts.extraHeaders&&(n.headers=this.opts.extraHeaders);try{this.ws=this.createSocket(e,t,n)}catch(s){return this.emitReserved("error",s)}this.ws.binaryType=this.socket.binaryType,this.addEventListeners()}addEventListeners(){this.ws.onopen=()=>{this.opts.autoUnref&&this.ws._socket.unref(),this.onOpen()},this.ws.onclose=e=>this.onClose({description:"websocket connection closed",context:e}),this.ws.onmessage=e=>this.onData(e.data),this.ws.onerror=e=>this.onError("websocket error",e)}write(e){this.writable=!1;for(let t=0;t<e.length;t++){let n=e[t],s=t===e.length-1;(0,t_.encodePacket)(n,this.supportsBinary,i=>{try{this.doWrite(n,i)}catch{n_("websocket closed before onclose event")}s&&(0,Ia.nextTick)(()=>{this.writable=!0,this.emitReserved("drain")},this.setTimeoutFn)})}}doClose(){typeof this.ws<"u"&&(this.ws.onerror=()=>{},this.ws.close(),this.ws=null)}uri(){let e=this.opts.secure?"wss":"ws",t=this.query||{};return this.opts.timestampRequests&&(t[this.opts.timestampParam]=(0,Vl.randomString)()),this.supportsBinary||(t.b64=1),this.createUri(e,t)}};Lr.BaseWS=Pi;var Aa=Ia.globalThisShim.WebSocket||Ia.globalThisShim.MozWebSocket,Na=class extends Pi{createSocket(e,t,n){return Kl?new Aa(e,t,n):t?new Aa(e,t):new Aa(e)}doWrite(e,t){this.ws.send(t)}};Lr.WS=Na});var Fa=F(Jt=>{"use strict";var s_=Jt&&Jt.__createBinding||(Object.create?(function(r,e,t,n){n===void 0&&(n=t);var s=Object.getOwnPropertyDescriptor(e,t);(!s||("get"in s?!e.__esModule:s.writable||s.configurable))&&(s={enumerable:!0,get:function(){return e[t]}}),Object.defineProperty(r,n,s)}):(function(r,e,t,n){n===void 0&&(n=t),r[n]=e[t]})),i_=Jt&&Jt.__setModuleDefault||(Object.create?(function(r,e){Object.defineProperty(r,"default",{enumerable:!0,value:e})}):function(r,e){r.default=e}),o_=Jt&&Jt.__importStar||function(r){if(r&&r.__esModule)return r;var e={};if(r!=null)for(var t in r)t!=="default"&&Object.prototype.hasOwnProperty.call(r,t)&&s_(e,r,t);return i_(e,r),e};Object.defineProperty(Jt,"__esModule",{value:!0});Jt.WS=void 0;var a_=o_(Hl()),c_=La(),Da=class extends c_.BaseWS{createSocket(e,t,n){var s;if(!((s=this.socket)===null||s===void 0)&&s._cookieJar){n.headers=n.headers||{},n.headers.cookie=typeof n.headers.cookie=="string"?[n.headers.cookie]:n.headers.cookie||[];for(let[i,a]of this.socket._cookieJar.cookies)n.headers.cookie.push(`${i}=${a.value}`)}return new a_.WebSocket(e,t,n)}doWrite(e,t){let n={};e.options&&(n.compress=e.options.compress),this.opts.perMessageDeflate&&(typeof t=="string"?Buffer.byteLength(t):t.length)<this.opts.perMessageDeflate.threshold&&(n.compress=!1),this.ws.send(t,n)}};Jt.WS=Da});var Ba=F(Ln=>{"use strict";var f_=Ln&&Ln.__importDefault||function(r){return r&&r.__esModule?r:{default:r}};Object.defineProperty(Ln,"__esModule",{value:!0});Ln.WT=void 0;var u_=as(),l_=zr(),$l=xn(),h_=f_(kt()),_s=(0,h_.default)("engine.io-client:webtransport"),Ma=class extends u_.Transport{get name(){return"webtransport"}doOpen(){try{this._transport=new WebTransport(this.createUri("https"),this.opts.transportOptions[this.name])}catch(e){return this.emitReserved("error",e)}this._transport.closed.then(()=>{_s("transport closed gracefully"),this.onClose()}).catch(e=>{_s("transport closed due to %s",e),this.onError("webtransport error",e)}),this._transport.ready.then(()=>{this._transport.createBidirectionalStream().then(e=>{let t=(0,$l.createPacketDecoderStream)(Number.MAX_SAFE_INTEGER,this.socket.binaryType),n=e.readable.pipeThrough(t).getReader(),s=(0,$l.createPacketEncoderStream)();s.readable.pipeTo(e.writable),this._writer=s.writable.getWriter();let i=()=>{n.read().then(({done:f,value:u})=>{if(f){_s("session is closed");return}_s("received chunk: %o",u),this.onPacket(u),i()}).catch(f=>{_s("an error occurred while reading: %s",f)})};i();let a={type:"open"};this.query.sid&&(a.data=`{"sid":"${this.query.sid}"}`),this._writer.write(a).then(()=>this.onOpen())})})}write(e){this.writable=!1;for(let t=0;t<e.length;t++){let n=e[t],s=t===e.length-1;this._writer.write(n).then(()=>{s&&(0,l_.nextTick)(()=>{this.writable=!0,this.emitReserved("drain")},this.setTimeoutFn)})}}doClose(){var e;(e=this._transport)===null||e===void 0||e.close()}};Ln.WT=Ma});var ja=F(Ri=>{"use strict";Object.defineProperty(Ri,"__esModule",{value:!0});Ri.transports=void 0;var d_=fa(),p_=Fa(),g_=Ba();Ri.transports={websocket:p_.WS,webtransport:g_.WT,polling:d_.XHR}});var qa=F(Ua=>{"use strict";Object.defineProperty(Ua,"__esModule",{value:!0});Ua.parse=y_;var __=/^(?:(?![^:@\/?#]+:[^:@\/]*@)(http|https|ws|wss):\/\/)?((?:(([^:@\/?#]*)(?::([^:@\/?#]*))?)?@)?((?:[a-f0-9]{0,4}:){2,7}[a-f0-9]{0,4}|[^:\/?#]*)(?::(\d*))?)(((\/(?:[^?#](?![^?#\/]*\.[^?#\/.]+(?:[?#]|$)))*\/?)?([^?#\/]*))(?:\?([^#]*))?(?:#(.*))?)/,m_=["source","protocol","authority","userInfo","user","password","host","port","relative","path","directory","file","query","anchor"];function y_(r){if(r.length>8e3)throw"URI too long";let e=r,t=r.indexOf("["),n=r.indexOf("]");t!=-1&&n!=-1&&(r=r.substring(0,t)+r.substring(t,n).replace(/:/g,";")+r.substring(n,r.length));let s=__.exec(r||""),i={},a=14;for(;a--;)i[m_[a]]=s[a]||"";return t!=-1&&n!=-1&&(i.source=e,i.host=i.host.substring(1,i.host.length-1).replace(/;/g,":"),i.authority=i.authority.replace("[","").replace("]","").replace(/;/g,":"),i.ipv6uri=!0),i.pathNames=E_(i,i.path),i.queryKey=w_(i,i.query),i}function E_(r,e){let t=/\/{2,9}/g,n=e.replace(t,"/").split("/");return(e.slice(0,1)=="/"||e.length===0)&&n.splice(0,1),e.slice(-1)=="/"&&n.splice(n.length-1,1),n}function w_(r,e){let t={};return e.replace(/(?:^|&)([^&=]*)=?([^&]*)/g,function(n,s,i){s&&(t[s]=i)}),t}});var Ka=F(Zt=>{"use strict";var x_=Zt&&Zt.__importDefault||function(r){return r&&r.__esModule?r:{default:r}};Object.defineProperty(Zt,"__esModule",{value:!0});Zt.Socket=Zt.SocketWithUpgrade=Zt.SocketWithoutUpgrade=void 0;var v_=ja(),zl=Gr(),b_=Jo(),Gl=qa(),S_=$r(),Yl=xn(),Wa=zr(),T_=x_(kt()),Ne=(0,T_.default)("engine.io-client:socket"),Ha=typeof addEventListener=="function"&&typeof removeEventListener=="function",ms=[];Ha&&addEventListener("offline",()=>{Ne("closing %d connection(s) because the network was lost",ms.length),ms.forEach(r=>r())},!1);var tn=class r extends S_.Emitter{constructor(e,t){if(super(),this.binaryType=Wa.defaultBinaryType,this.writeBuffer=[],this._prevBufferLen=0,this._pingInterval=-1,this._pingTimeout=-1,this._maxPayload=-1,this._pingTimeoutTime=1/0,e&&typeof e=="object"&&(t=e,e=null),e){let n=(0,Gl.parse)(e);t.hostname=n.host,t.secure=n.protocol==="https"||n.protocol==="wss",t.port=n.port,n.query&&(t.query=n.query)}else t.host&&(t.hostname=(0,Gl.parse)(t.host).host);(0,zl.installTimerFunctions)(this,t),this.secure=t.secure!=null?t.secure:typeof location<"u"&&location.protocol==="https:",t.hostname&&!t.port&&(t.port=this.secure?"443":"80"),this.hostname=t.hostname||(typeof location<"u"?location.hostname:"localhost"),this.port=t.port||(typeof location<"u"&&location.port?location.port:this.secure?"443":"80"),this.transports=[],this._transportsByName={},t.transports.forEach(n=>{let s=n.prototype.name;this.transports.push(s),this._transportsByName[s]=n}),this.opts=Object.assign({path:"/engine.io",agent:!1,withCredentials:!1,upgrade:!0,timestampParam:"t",rememberUpgrade:!1,addTrailingSlash:!0,rejectUnauthorized:!0,perMessageDeflate:{threshold:1024},transportOptions:{},closeOnBeforeunload:!1},t),this.opts.path=this.opts.path.replace(/\/$/,"")+(this.opts.addTrailingSlash?"/":""),typeof this.opts.query=="string"&&(this.opts.query=(0,b_.decode)(this.opts.query)),Ha&&(this.opts.closeOnBeforeunload&&(this._beforeunloadEventListener=()=>{this.transport&&(this.transport.removeAllListeners(),this.transport.close())},addEventListener("beforeunload",this._beforeunloadEventListener,!1)),this.hostname!=="localhost"&&(Ne("adding listener for the 'offline' event"),this._offlineEventListener=()=>{this._onClose("transport close",{description:"network connection lost"})},ms.push(this._offlineEventListener))),this.opts.withCredentials&&(this._cookieJar=(0,Wa.createCookieJar)()),this._open()}createTransport(e){Ne('creating transport "%s"',e);let t=Object.assign({},this.opts.query);t.EIO=Yl.protocol,t.transport=e,this.id&&(t.sid=this.id);let n=Object.assign({},this.opts,{query:t,socket:this,hostname:this.hostname,secure:this.secure,port:this.port},this.opts.transportOptions[e]);return Ne("options: %j",n),new this._transportsByName[e](n)}_open(){if(this.transports.length===0){this.setTimeoutFn(()=>{this.emitReserved("error","No transports available")},0);return}let e=this.opts.rememberUpgrade&&r.priorWebsocketSuccess&&this.transports.indexOf("websocket")!==-1?"websocket":this.transports[0];this.readyState="opening";let t=this.createTransport(e);t.open(),this.setTransport(t)}setTransport(e){Ne("setting transport %s",e.name),this.transport&&(Ne("clearing existing transport %s",this.transport.name),this.transport.removeAllListeners()),this.transport=e,e.on("drain",this._onDrain.bind(this)).on("packet",this._onPacket.bind(this)).on("error",this._onError.bind(this)).on("close",t=>this._onClose("transport close",t))}onOpen(){Ne("socket open"),this.readyState="open",r.priorWebsocketSuccess=this.transport.name==="websocket",this.emitReserved("open"),this.flush()}_onPacket(e){if(this.readyState==="opening"||this.readyState==="open"||this.readyState==="closing")switch(Ne('socket receive: type "%s", data "%s"',e.type,e.data),this.emitReserved("packet",e),this.emitReserved("heartbeat"),e.type){case"open":this.onHandshake(JSON.parse(e.data));break;case"ping":this._sendPacket("pong"),this.emitReserved("ping"),this.emitReserved("pong"),this._resetPingTimeout();break;case"error":let t=new Error("server error");t.code=e.data,this._onError(t);break;case"message":this.emitReserved("data",e.data),this.emitReserved("message",e.data);break}else Ne('packet received with socket readyState "%s"',this.readyState)}onHandshake(e){this.emitReserved("handshake",e),this.id=e.sid,this.transport.query.sid=e.sid,this._pingInterval=e.pingInterval,this._pingTimeout=e.pingTimeout,this._maxPayload=e.maxPayload,this.onOpen(),this.readyState!=="closed"&&this._resetPingTimeout()}_resetPingTimeout(){this.clearTimeoutFn(this._pingTimeoutTimer);let e=this._pingInterval+this._pingTimeout;this._pingTimeoutTime=Date.now()+e,this._pingTimeoutTimer=this.setTimeoutFn(()=>{this._onClose("ping timeout")},e),this.opts.autoUnref&&this._pingTimeoutTimer.unref()}_onDrain(){this.writeBuffer.splice(0,this._prevBufferLen),this._prevBufferLen=0,this.writeBuffer.length===0?this.emitReserved("drain"):this.flush()}flush(){if(this.readyState!=="closed"&&this.transport.writable&&!this.upgrading&&this.writeBuffer.length){let e=this._getWritablePackets();Ne("flushing %d packets in socket",e.length),this.transport.send(e),this._prevBufferLen=e.length,this.emitReserved("flush")}}_getWritablePackets(){if(!(this._maxPayload&&this.transport.name==="polling"&&this.writeBuffer.length>1))return this.writeBuffer;let t=1;for(let n=0;n<this.writeBuffer.length;n++){let s=this.writeBuffer[n].data;if(s&&(t+=(0,zl.byteLength)(s)),n>0&&t>this._maxPayload)return Ne("only send %d out of %d packets",n,this.writeBuffer.length),this.writeBuffer.slice(0,n);t+=2}return Ne("payload size is %d (max: %d)",t,this._maxPayload),this.writeBuffer}_hasPingExpired(){if(!this._pingTimeoutTime)return!0;let e=Date.now()>this._pingTimeoutTime;return e&&(Ne("throttled timer detected, scheduling connection close"),this._pingTimeoutTime=0,(0,Wa.nextTick)(()=>{this._onClose("ping timeout")},this.setTimeoutFn)),e}write(e,t,n){return this._sendPacket("message",e,t,n),this}send(e,t,n){return this._sendPacket("message",e,t,n),this}_sendPacket(e,t,n,s){if(typeof t=="function"&&(s=t,t=void 0),typeof n=="function"&&(s=n,n=null),this.readyState==="closing"||this.readyState==="closed")return;n=n||{},n.compress=n.compress!==!1;let i={type:e,data:t,options:n};this.emitReserved("packetCreate",i),this.writeBuffer.push(i),s&&this.once("flush",s),this.flush()}close(){let e=()=>{this._onClose("forced close"),Ne("socket closing - telling transport to close"),this.transport.close()},t=()=>{this.off("upgrade",t),this.off("upgradeError",t),e()},n=()=>{this.once("upgrade",t),this.once("upgradeError",t)};return(this.readyState==="opening"||this.readyState==="open")&&(this.readyState="closing",this.writeBuffer.length?this.once("drain",()=>{this.upgrading?n():e()}):this.upgrading?n():e()),this}_onError(e){if(Ne("socket error %j",e),r.priorWebsocketSuccess=!1,this.opts.tryAllTransports&&this.transports.length>1&&this.readyState==="opening")return Ne("trying next transport"),this.transports.shift(),this._open();this.emitReserved("error",e),this._onClose("transport error",e)}_onClose(e,t){if(this.readyState==="opening"||this.readyState==="open"||this.readyState==="closing"){if(Ne('socket close with reason: "%s"',e),this.clearTimeoutFn(this._pingTimeoutTimer),this.transport.removeAllListeners("close"),this.transport.close(),this.transport.removeAllListeners(),Ha&&(this._beforeunloadEventListener&&removeEventListener("beforeunload",this._beforeunloadEventListener,!1),this._offlineEventListener)){let n=ms.indexOf(this._offlineEventListener);n!==-1&&(Ne("removing listener for the 'offline' event"),ms.splice(n,1))}this.readyState="closed",this.id=null,this.emitReserved("close",e,t),this.writeBuffer=[],this._prevBufferLen=0}}};Zt.SocketWithoutUpgrade=tn;tn.protocol=Yl.protocol;var Ai=class extends tn{constructor(){super(...arguments),this._upgrades=[]}onOpen(){if(super.onOpen(),this.readyState==="open"&&this.opts.upgrade){Ne("starting upgrade probes");for(let e=0;e<this._upgrades.length;e++)this._probe(this._upgrades[e])}}_probe(e){Ne('probing transport "%s"',e);let t=this.createTransport(e),n=!1;tn.priorWebsocketSuccess=!1;let s=()=>{n||(Ne('probe transport "%s" opened',e),t.send([{type:"ping",data:"probe"}]),t.once("packet",_=>{if(!n)if(_.type==="pong"&&_.data==="probe"){if(Ne('probe transport "%s" pong',e),this.upgrading=!0,this.emitReserved("upgrading",t),!t)return;tn.priorWebsocketSuccess=t.name==="websocket",Ne('pausing current transport "%s"',this.transport.name),this.transport.pause(()=>{n||this.readyState!=="closed"&&(Ne("changing transport and sending upgrade packet"),g(),this.setTransport(t),t.send([{type:"upgrade"}]),this.emitReserved("upgrade",t),t=null,this.upgrading=!1,this.flush())})}else{Ne('probe transport "%s" failed',e);let y=new Error("probe error");y.transport=t.name,this.emitReserved("upgradeError",y)}}))};function i(){n||(n=!0,g(),t.close(),t=null)}let a=_=>{let y=new Error("probe error: "+_);y.transport=t.name,i(),Ne('probe transport "%s" failed because of error: %s',e,_),this.emitReserved("upgradeError",y)};function f(){a("transport closed")}function u(){a("socket closed")}function d(_){t&&_.name!==t.name&&(Ne('"%s" works - aborting "%s"',_.name,t.name),i())}let g=()=>{t.removeListener("open",s),t.removeListener("error",a),t.removeListener("close",f),this.off("close",u),this.off("upgrading",d)};t.once("open",s),t.once("error",a),t.once("close",f),this.once("close",u),this.once("upgrading",d),this._upgrades.indexOf("webtransport")!==-1&&e!=="webtransport"?this.setTimeoutFn(()=>{n||t.open()},200):t.open()}onHandshake(e){this._upgrades=this._filterUpgrades(e.upgrades),super.onHandshake(e)}_filterUpgrades(e){let t=[];for(let n=0;n<e.length;n++)~this.transports.indexOf(e[n])&&t.push(e[n]);return t}};Zt.SocketWithUpgrade=Ai;var Va=class extends Ai{constructor(e,t={}){let n=typeof e=="object"?e:t;(!n.transports||n.transports&&typeof n.transports[0]=="string")&&(n.transports=(n.transports||["polling","websocket","webtransport"]).map(s=>v_.transports[s]).filter(s=>!!s)),super(e,n)}};Zt.Socket=Va});var Xl=F(Ii=>{"use strict";Object.defineProperty(Ii,"__esModule",{value:!0});Ii.Fetch=void 0;var O_=sa(),$a=class extends O_.Polling{doPoll(){this._fetch().then(e=>{if(!e.ok)return this.onError("fetch read error",e.status,e);e.text().then(t=>this.onData(t))}).catch(e=>{this.onError("fetch read error",e)})}doWrite(e,t){this._fetch(e).then(n=>{if(!n.ok)return this.onError("fetch write error",n.status,n);t()}).catch(n=>{this.onError("fetch write error",n)})}_fetch(e){var t;let n=e!==void 0,s=new Headers(this.opts.extraHeaders);return n&&s.set("content-type","text/plain;charset=UTF-8"),(t=this.socket._cookieJar)===null||t===void 0||t.appendCookies(s),fetch(this.uri(),{method:n?"POST":"GET",body:n?e:null,headers:s,credentials:this.opts.withCredentials?"include":"omit"}).then(i=>{var a;return(a=this.socket._cookieJar)===null||a===void 0||a.parseCookies(i.headers.getSetCookie()),i})}};Ii.Fetch=$a});var Ni=F(Se=>{"use strict";Object.defineProperty(Se,"__esModule",{value:!0});Se.WebTransport=Se.WebSocket=Se.NodeWebSocket=Se.XHR=Se.NodeXHR=Se.Fetch=Se.nextTick=Se.parse=Se.installTimerFunctions=Se.transports=Se.TransportError=Se.Transport=Se.protocol=Se.SocketWithUpgrade=Se.SocketWithoutUpgrade=Se.Socket=void 0;var Jl=Ka();Object.defineProperty(Se,"Socket",{enumerable:!0,get:function(){return Jl.Socket}});var Zl=Ka();Object.defineProperty(Se,"SocketWithoutUpgrade",{enumerable:!0,get:function(){return Zl.SocketWithoutUpgrade}});Object.defineProperty(Se,"SocketWithUpgrade",{enumerable:!0,get:function(){return Zl.SocketWithUpgrade}});Se.protocol=Jl.Socket.protocol;var Ql=as();Object.defineProperty(Se,"Transport",{enumerable:!0,get:function(){return Ql.Transport}});Object.defineProperty(Se,"TransportError",{enumerable:!0,get:function(){return Ql.TransportError}});var C_=ja();Object.defineProperty(Se,"transports",{enumerable:!0,get:function(){return C_.transports}});var k_=Gr();Object.defineProperty(Se,"installTimerFunctions",{enumerable:!0,get:function(){return k_.installTimerFunctions}});var P_=qa();Object.defineProperty(Se,"parse",{enumerable:!0,get:function(){return P_.parse}});var R_=zr();Object.defineProperty(Se,"nextTick",{enumerable:!0,get:function(){return R_.nextTick}});var A_=Xl();Object.defineProperty(Se,"Fetch",{enumerable:!0,get:function(){return A_.Fetch}});var I_=fa();Object.defineProperty(Se,"NodeXHR",{enumerable:!0,get:function(){return I_.XHR}});var N_=aa();Object.defineProperty(Se,"XHR",{enumerable:!0,get:function(){return N_.XHR}});var L_=Fa();Object.defineProperty(Se,"NodeWebSocket",{enumerable:!0,get:function(){return L_.WS}});var D_=La();Object.defineProperty(Se,"WebSocket",{enumerable:!0,get:function(){return D_.WS}});var F_=Ba();Object.defineProperty(Se,"WebTransport",{enumerable:!0,get:function(){return F_.WT}})});var th=F(ys=>{"use strict";var M_=ys&&ys.__importDefault||function(r){return r&&r.__esModule?r:{default:r}};Object.defineProperty(ys,"__esModule",{value:!0});ys.url=U_;var B_=Ni(),j_=M_(kt()),eh=(0,j_.default)("socket.io-client:url");function U_(r,e="",t){let n=r;t=t||typeof location<"u"&&location,r==null&&(r=t.protocol+"//"+t.host),typeof r=="string"&&(r.charAt(0)==="/"&&(r.charAt(1)==="/"?r=t.protocol+r:r=t.host+r),/^(https?|wss?):\/\//.test(r)||(eh("protocol-less url %s",r),typeof t<"u"?r=t.protocol+"//"+r:r="https://"+r),eh("parse %s",r),n=(0,B_.parse)(r)),n.port||(/^(http|ws)$/.test(n.protocol)?n.port="80":/^(http|ws)s$/.test(n.protocol)&&(n.port="443")),n.path=n.path||"/";let i=n.host.indexOf(":")!==-1?"["+n.host+"]":n.host;return n.id=n.protocol+"://"+i+":"+n.port+e,n.href=n.protocol+"://"+i+(t&&t.port===n.port?"":":"+n.port),n}});var za=F(Di=>{"use strict";Object.defineProperty(Di,"__esModule",{value:!0});Di.isBinary=nh;Di.hasBinary=Li;var q_=typeof ArrayBuffer=="function",W_=r=>typeof ArrayBuffer.isView=="function"?ArrayBuffer.isView(r):r.buffer instanceof ArrayBuffer,rh=Object.prototype.toString,H_=typeof Blob=="function"||typeof Blob<"u"&&rh.call(Blob)==="[object BlobConstructor]",V_=typeof File=="function"||typeof File<"u"&&rh.call(File)==="[object FileConstructor]";function nh(r){return q_&&(r instanceof ArrayBuffer||W_(r))||H_&&r instanceof Blob||V_&&r instanceof File}function Li(r,e){if(!r||typeof r!="object")return!1;if(Array.isArray(r)){for(let t=0,n=r.length;t<n;t++)if(Li(r[t]))return!0;return!1}if(nh(r))return!0;if(r.toJSON&&typeof r.toJSON=="function"&&arguments.length===1)return Li(r.toJSON(),!0);for(let t in r)if(Object.prototype.hasOwnProperty.call(r,t)&&Li(r[t]))return!0;return!1}});var sh=F(Fi=>{"use strict";Object.defineProperty(Fi,"__esModule",{value:!0});Fi.deconstructPacket=$_;Fi.reconstructPacket=z_;var K_=za();function $_(r){let e=[],t=r.data,n=r;return n.data=Ga(t,e),n.attachments=e.length,{packet:n,buffers:e}}function Ga(r,e){if(!r)return r;if((0,K_.isBinary)(r)){let t={_placeholder:!0,num:e.length};return e.push(r),t}else if(Array.isArray(r)){let t=new Array(r.length);for(let n=0;n<r.length;n++)t[n]=Ga(r[n],e);return t}else if(typeof r=="object"&&!(r instanceof Date)){let t={};for(let n in r)Object.prototype.hasOwnProperty.call(r,n)&&(t[n]=Ga(r[n],e));return t}return r}function z_(r,e){return r.data=Ya(r.data,e),delete r.attachments,r}function Ya(r,e){if(!r)return r;if(r&&r._placeholder===!0){if(typeof r.num=="number"&&r.num>=0&&r.num<e.length)return e[r.num];throw new Error("illegal attachments")}else if(Array.isArray(r))for(let t=0;t<r.length;t++)r[t]=Ya(r[t],e);else if(typeof r=="object")for(let t in r)Object.prototype.hasOwnProperty.call(r,t)&&(r[t]=Ya(r[t],e));return r}});var Bi=F(Ft=>{"use strict";Object.defineProperty(Ft,"__esModule",{value:!0});Ft.Decoder=Ft.Encoder=Ft.PacketType=Ft.protocol=void 0;Ft.isPacketValid=em;var G_=$r(),ih=sh(),oh=za(),Y_=kt(),Xa=(0,Y_.default)("socket.io-parser"),ah=["connect","connect_error","disconnect","disconnecting","newListener","removeListener"];Ft.protocol=5;var Ie;(function(r){r[r.CONNECT=0]="CONNECT",r[r.DISCONNECT=1]="DISCONNECT",r[r.EVENT=2]="EVENT",r[r.ACK=3]="ACK",r[r.CONNECT_ERROR=4]="CONNECT_ERROR",r[r.BINARY_EVENT=5]="BINARY_EVENT",r[r.BINARY_ACK=6]="BINARY_ACK"})(Ie||(Ft.PacketType=Ie={}));var Ja=class{constructor(e){this.replacer=e}encode(e){return Xa("encoding packet %j",e),(e.type===Ie.EVENT||e.type===Ie.ACK)&&(0,oh.hasBinary)(e)?this.encodeAsBinary({type:e.type===Ie.EVENT?Ie.BINARY_EVENT:Ie.BINARY_ACK,nsp:e.nsp,data:e.data,id:e.id}):[this.encodeAsString(e)]}encodeAsString(e){let t=""+e.type;return(e.type===Ie.BINARY_EVENT||e.type===Ie.BINARY_ACK)&&(t+=e.attachments+"-"),e.nsp&&e.nsp!=="/"&&(t+=e.nsp+","),e.id!=null&&(t+=e.id),e.data!=null&&(t+=JSON.stringify(e.data,this.replacer)),Xa("encoded %j as %s",e,t),t}encodeAsBinary(e){let t=(0,ih.deconstructPacket)(e),n=this.encodeAsString(t.packet),s=t.buffers;return s.unshift(n),s}};Ft.Encoder=Ja;var Za=class r extends G_.Emitter{constructor(e){super(),this.reviver=e}add(e){let t;if(typeof e=="string"){if(this.reconstructor)throw new Error("got plaintext data when reconstructing a packet");t=this.decodeString(e);let n=t.type===Ie.BINARY_EVENT;n||t.type===Ie.BINARY_ACK?(t.type=n?Ie.EVENT:Ie.ACK,this.reconstructor=new Qa(t),t.attachments===0&&super.emitReserved("decoded",t)):super.emitReserved("decoded",t)}else if((0,oh.isBinary)(e)||e.base64)if(this.reconstructor)t=this.reconstructor.takeBinaryData(e),t&&(this.reconstructor=null,super.emitReserved("decoded",t));else throw new Error("got binary data when not reconstructing a packet");else throw new Error("Unknown type: "+e)}decodeString(e){let t=0,n={type:Number(e.charAt(0))};if(Ie[n.type]===void 0)throw new Error("unknown packet type "+n.type);if(n.type===Ie.BINARY_EVENT||n.type===Ie.BINARY_ACK){let i=t+1;for(;e.charAt(++t)!=="-"&&t!=e.length;);let a=e.substring(i,t);if(a!=Number(a)||e.charAt(t)!=="-")throw new Error("Illegal attachments");n.attachments=Number(a)}if(e.charAt(t+1)==="/"){let i=t+1;for(;++t&&!(e.charAt(t)===","||t===e.length););n.nsp=e.substring(i,t)}else n.nsp="/";let s=e.charAt(t+1);if(s!==""&&Number(s)==s){let i=t+1;for(;++t;){let a=e.charAt(t);if(a==null||Number(a)!=a){--t;break}if(t===e.length)break}n.id=Number(e.substring(i,t+1))}if(e.charAt(++t)){let i=this.tryParse(e.substr(t));if(r.isPayloadValid(n.type,i))n.data=i;else throw new Error("invalid payload")}return Xa("decoded %s as %j",e,n),n}tryParse(e){try{return JSON.parse(e,this.reviver)}catch{return!1}}static isPayloadValid(e,t){switch(e){case Ie.CONNECT:return Mi(t);case Ie.DISCONNECT:return t===void 0;case Ie.CONNECT_ERROR:return typeof t=="string"||Mi(t);case Ie.EVENT:case Ie.BINARY_EVENT:return Array.isArray(t)&&(typeof t[0]=="number"||typeof t[0]=="string"&&ah.indexOf(t[0])===-1);case Ie.ACK:case Ie.BINARY_ACK:return Array.isArray(t)}}destroy(){this.reconstructor&&(this.reconstructor.finishedReconstruction(),this.reconstructor=null)}};Ft.Decoder=Za;var Qa=class{constructor(e){this.packet=e,this.buffers=[],this.reconPack=e}takeBinaryData(e){if(this.buffers.push(e),this.buffers.length===this.reconPack.attachments){let t=(0,ih.reconstructPacket)(this.reconPack,this.buffers);return this.finishedReconstruction(),t}return null}finishedReconstruction(){this.reconPack=null,this.buffers=[]}};function X_(r){return typeof r=="string"}var J_=Number.isInteger||function(r){return typeof r=="number"&&isFinite(r)&&Math.floor(r)===r};function Z_(r){return r===void 0||J_(r)}function Mi(r){return Object.prototype.toString.call(r)==="[object Object]"}function Q_(r,e){switch(r){case Ie.CONNECT:return e===void 0||Mi(e);case Ie.DISCONNECT:return e===void 0;case Ie.EVENT:return Array.isArray(e)&&(typeof e[0]=="number"||typeof e[0]=="string"&&ah.indexOf(e[0])===-1);case Ie.ACK:return Array.isArray(e);case Ie.CONNECT_ERROR:return typeof e=="string"||Mi(e);default:return!1}}function em(r){return X_(r.nsp)&&Z_(r.id)&&Q_(r.type,r.data)}});var tc=F(ec=>{"use strict";Object.defineProperty(ec,"__esModule",{value:!0});ec.on=tm;function tm(r,e,t){return r.on(e,t),function(){r.off(e,t)}}});var nc=F(Dn=>{"use strict";var rm=Dn&&Dn.__importDefault||function(r){return r&&r.__esModule?r:{default:r}};Object.defineProperty(Dn,"__esModule",{value:!0});Dn.Socket=void 0;var Mt=Bi(),ji=tc(),nm=$r(),sm=rm(kt()),Xe=(0,sm.default)("socket.io-client:socket"),im=Object.freeze({connect:1,connect_error:1,disconnect:1,disconnecting:1,newListener:1,removeListener:1}),rc=class extends nm.Emitter{constructor(e,t,n){super(),this.connected=!1,this.recovered=!1,this.receiveBuffer=[],this.sendBuffer=[],this._queue=[],this._queueSeq=0,this.ids=0,this.acks={},this.flags={},this.io=e,this.nsp=t,n&&n.auth&&(this.auth=n.auth),this._opts=Object.assign({},n),this.io._autoConnect&&this.open()}get disconnected(){return!this.connected}subEvents(){if(this.subs)return;let e=this.io;this.subs=[(0,ji.on)(e,"open",this.onopen.bind(this)),(0,ji.on)(e,"packet",this.onpacket.bind(this)),(0,ji.on)(e,"error",this.onerror.bind(this)),(0,ji.on)(e,"close",this.onclose.bind(this))]}get active(){return!!this.subs}connect(){return this.connected?this:(this.subEvents(),this.io._reconnecting||this.io.open(),this.io._readyState==="open"&&this.onopen(),this)}open(){return this.connect()}send(...e){return e.unshift("message"),this.emit.apply(this,e),this}emit(e,...t){var n,s,i;if(im.hasOwnProperty(e))throw new Error('"'+e.toString()+'" is a reserved event name');if(t.unshift(e),this._opts.retries&&!this.flags.fromQueue&&!this.flags.volatile)return this._addToQueue(t),this;let a={type:Mt.PacketType.EVENT,data:t};if(a.options={},a.options.compress=this.flags.compress!==!1,typeof t[t.length-1]=="function"){let g=this.ids++;Xe("emitting packet with ack id %d",g);let _=t.pop();this._registerAckCallback(g,_),a.id=g}let f=(s=(n=this.io.engine)===null||n===void 0?void 0:n.transport)===null||s===void 0?void 0:s.writable,u=this.connected&&!(!((i=this.io.engine)===null||i===void 0)&&i._hasPingExpired());return this.flags.volatile&&!f?Xe("discard packet as the transport is not currently writable"):u?(this.notifyOutgoingListeners(a),this.packet(a)):this.sendBuffer.push(a),this.flags={},this}_registerAckCallback(e,t){var n;let s=(n=this.flags.timeout)!==null&&n!==void 0?n:this._opts.ackTimeout;if(s===void 0){this.acks[e]=t;return}let i=this.io.setTimeoutFn(()=>{delete this.acks[e];for(let f=0;f<this.sendBuffer.length;f++)this.sendBuffer[f].id===e&&(Xe("removing packet with ack id %d from the buffer",e),this.sendBuffer.splice(f,1));Xe("event with ack id %d has timed out after %d ms",e,s),t.call(this,new Error("operation has timed out"))},s),a=(...f)=>{this.io.clearTimeoutFn(i),t.apply(this,f)};a.withError=!0,this.acks[e]=a}emitWithAck(e,...t){return new Promise((n,s)=>{let i=(a,f)=>a?s(a):n(f);i.withError=!0,t.push(i),this.emit(e,...t)})}_addToQueue(e){let t;typeof e[e.length-1]=="function"&&(t=e.pop());let n={id:this._queueSeq++,tryCount:0,pending:!1,args:e,flags:Object.assign({fromQueue:!0},this.flags)};e.push((s,...i)=>n!==this._queue[0]?Xe("packet [%d] already acknowledged",n.id):(s!==null?n.tryCount>this._opts.retries&&(Xe("packet [%d] is discarded after %d tries",n.id,n.tryCount),this._queue.shift(),t&&t(s)):(Xe("packet [%d] was successfully sent",n.id),this._queue.shift(),t&&t(null,...i)),n.pending=!1,this._drainQueue())),this._queue.push(n),this._drainQueue()}_drainQueue(e=!1){if(Xe("draining queue"),!this.connected||this._queue.length===0)return;let t=this._queue[0];if(t.pending&&!e){Xe("packet [%d] has already been sent and is waiting for an ack",t.id);return}t.pending=!0,t.tryCount++,Xe("sending packet [%d] (try n\xB0%d)",t.id,t.tryCount),this.flags=t.flags,this.emit.apply(this,t.args)}packet(e){e.nsp=this.nsp,this.io._packet(e)}onopen(){Xe("transport is open - connecting"),typeof this.auth=="function"?this.auth(e=>{this._sendConnectPacket(e)}):this._sendConnectPacket(this.auth)}_sendConnectPacket(e){this.packet({type:Mt.PacketType.CONNECT,data:this._pid?Object.assign({pid:this._pid,offset:this._lastOffset},e):e})}onerror(e){this.connected||this.emitReserved("connect_error",e)}onclose(e,t){Xe("close (%s)",e),this.connected=!1,delete this.id,this.emitReserved("disconnect",e,t),this._clearAcks()}_clearAcks(){Object.keys(this.acks).forEach(e=>{if(!this.sendBuffer.some(n=>String(n.id)===e)){let n=this.acks[e];delete this.acks[e],n.withError&&n.call(this,new Error("socket has been disconnected"))}})}onpacket(e){if(e.nsp===this.nsp)switch(e.type){case Mt.PacketType.CONNECT:e.data&&e.data.sid?this.onconnect(e.data.sid,e.data.pid):this.emitReserved("connect_error",new Error("It seems you are trying to reach a Socket.IO server in v2.x with a v3.x client, but they are not compatible (more information here: https://socket.io/docs/v3/migrating-from-2-x-to-3-0/)"));break;case Mt.PacketType.EVENT:case Mt.PacketType.BINARY_EVENT:this.onevent(e);break;case Mt.PacketType.ACK:case Mt.PacketType.BINARY_ACK:this.onack(e);break;case Mt.PacketType.DISCONNECT:this.ondisconnect();break;case Mt.PacketType.CONNECT_ERROR:this.destroy();let n=new Error(e.data.message);n.data=e.data.data,this.emitReserved("connect_error",n);break}}onevent(e){let t=e.data||[];Xe("emitting event %j",t),e.id!=null&&(Xe("attaching ack callback to event"),t.push(this.ack(e.id))),this.connected?this.emitEvent(t):this.receiveBuffer.push(Object.freeze(t))}emitEvent(e){if(this._anyListeners&&this._anyListeners.length){let t=this._anyListeners.slice();for(let n of t)n.apply(this,e)}super.emit.apply(this,e),this._pid&&e.length&&typeof e[e.length-1]=="string"&&(this._lastOffset=e[e.length-1])}ack(e){let t=this,n=!1;return function(...s){n||(n=!0,Xe("sending ack %j",s),t.packet({type:Mt.PacketType.ACK,id:e,data:s}))}}onack(e){let t=this.acks[e.id];if(typeof t!="function"){Xe("bad ack %s",e.id);return}delete this.acks[e.id],Xe("calling ack %s with %j",e.id,e.data),t.withError&&e.data.unshift(null),t.apply(this,e.data)}onconnect(e,t){Xe("socket connected with id %s",e),this.id=e,this.recovered=t&&this._pid===t,this._pid=t,this.connected=!0,this.emitBuffered(),this._drainQueue(!0),this.emitReserved("connect")}emitBuffered(){this.receiveBuffer.forEach(e=>this.emitEvent(e)),this.receiveBuffer=[],this.sendBuffer.forEach(e=>{this.notifyOutgoingListeners(e),this.packet(e)}),this.sendBuffer=[]}ondisconnect(){Xe("server disconnect (%s)",this.nsp),this.destroy(),this.onclose("io server disconnect")}destroy(){this.subs&&(this.subs.forEach(e=>e()),this.subs=void 0),this.io._destroy(this)}disconnect(){return this.connected&&(Xe("performing disconnect (%s)",this.nsp),this.packet({type:Mt.PacketType.DISCONNECT})),this.destroy(),this.connected&&this.onclose("io client disconnect"),this}close(){return this.disconnect()}compress(e){return this.flags.compress=e,this}get volatile(){return this.flags.volatile=!0,this}timeout(e){return this.flags.timeout=e,this}onAny(e){return this._anyListeners=this._anyListeners||[],this._anyListeners.push(e),this}prependAny(e){return this._anyListeners=this._anyListeners||[],this._anyListeners.unshift(e),this}offAny(e){if(!this._anyListeners)return this;if(e){let t=this._anyListeners;for(let n=0;n<t.length;n++)if(e===t[n])return t.splice(n,1),this}else this._anyListeners=[];return this}listenersAny(){return this._anyListeners||[]}onAnyOutgoing(e){return this._anyOutgoingListeners=this._anyOutgoingListeners||[],this._anyOutgoingListeners.push(e),this}prependAnyOutgoing(e){return this._anyOutgoingListeners=this._anyOutgoingListeners||[],this._anyOutgoingListeners.unshift(e),this}offAnyOutgoing(e){if(!this._anyOutgoingListeners)return this;if(e){let t=this._anyOutgoingListeners;for(let n=0;n<t.length;n++)if(e===t[n])return t.splice(n,1),this}else this._anyOutgoingListeners=[];return this}listenersAnyOutgoing(){return this._anyOutgoingListeners||[]}notifyOutgoingListeners(e){if(this._anyOutgoingListeners&&this._anyOutgoingListeners.length){let t=this._anyOutgoingListeners.slice();for(let n of t)n.apply(this,e.data)}}};Dn.Socket=rc});var ch=F(sc=>{"use strict";Object.defineProperty(sc,"__esModule",{value:!0});sc.Backoff=Fn;function Fn(r){r=r||{},this.ms=r.min||100,this.max=r.max||1e4,this.factor=r.factor||2,this.jitter=r.jitter>0&&r.jitter<=1?r.jitter:0,this.attempts=0}Fn.prototype.duration=function(){var r=this.ms*Math.pow(this.factor,this.attempts++);if(this.jitter){var e=Math.random(),t=Math.floor(e*this.jitter*r);r=(Math.floor(e*10)&1)==0?r-t:r+t}return Math.min(r,this.max)|0};Fn.prototype.reset=function(){this.attempts=0};Fn.prototype.setMin=function(r){this.ms=r};Fn.prototype.setMax=function(r){this.max=r};Fn.prototype.setJitter=function(r){this.jitter=r}});var fh=F(At=>{"use strict";var om=At&&At.__createBinding||(Object.create?(function(r,e,t,n){n===void 0&&(n=t);var s=Object.getOwnPropertyDescriptor(e,t);(!s||("get"in s?!e.__esModule:s.writable||s.configurable))&&(s={enumerable:!0,get:function(){return e[t]}}),Object.defineProperty(r,n,s)}):(function(r,e,t,n){n===void 0&&(n=t),r[n]=e[t]})),am=At&&At.__setModuleDefault||(Object.create?(function(r,e){Object.defineProperty(r,"default",{enumerable:!0,value:e})}):function(r,e){r.default=e}),cm=At&&At.__importStar||function(r){if(r&&r.__esModule)return r;var e={};if(r!=null)for(var t in r)t!=="default"&&Object.prototype.hasOwnProperty.call(r,t)&&om(e,r,t);return am(e,r),e},fm=At&&At.__importDefault||function(r){return r&&r.__esModule?r:{default:r}};Object.defineProperty(At,"__esModule",{value:!0});At.Manager=void 0;var ic=Ni(),um=nc(),lm=cm(Bi()),rn=tc(),hm=ch(),dm=$r(),pm=fm(kt()),nt=(0,pm.default)("socket.io-client:manager"),oc=class extends dm.Emitter{constructor(e,t){var n;super(),this.nsps={},this.subs=[],e&&typeof e=="object"&&(t=e,e=void 0),t=t||{},t.path=t.path||"/socket.io",this.opts=t,(0,ic.installTimerFunctions)(this,t),this.reconnection(t.reconnection!==!1),this.reconnectionAttempts(t.reconnectionAttempts||1/0),this.reconnectionDelay(t.reconnectionDelay||1e3),this.reconnectionDelayMax(t.reconnectionDelayMax||5e3),this.randomizationFactor((n=t.randomizationFactor)!==null&&n!==void 0?n:.5),this.backoff=new hm.Backoff({min:this.reconnectionDelay(),max:this.reconnectionDelayMax(),jitter:this.randomizationFactor()}),this.timeout(t.timeout==null?2e4:t.timeout),this._readyState="closed",this.uri=e;let s=t.parser||lm;this.encoder=new s.Encoder,this.decoder=new s.Decoder,this._autoConnect=t.autoConnect!==!1,this._autoConnect&&this.open()}reconnection(e){return arguments.length?(this._reconnection=!!e,e||(this.skipReconnect=!0),this):this._reconnection}reconnectionAttempts(e){return e===void 0?this._reconnectionAttempts:(this._reconnectionAttempts=e,this)}reconnectionDelay(e){var t;return e===void 0?this._reconnectionDelay:(this._reconnectionDelay=e,(t=this.backoff)===null||t===void 0||t.setMin(e),this)}randomizationFactor(e){var t;return e===void 0?this._randomizationFactor:(this._randomizationFactor=e,(t=this.backoff)===null||t===void 0||t.setJitter(e),this)}reconnectionDelayMax(e){var t;return e===void 0?this._reconnectionDelayMax:(this._reconnectionDelayMax=e,(t=this.backoff)===null||t===void 0||t.setMax(e),this)}timeout(e){return arguments.length?(this._timeout=e,this):this._timeout}maybeReconnectOnOpen(){!this._reconnecting&&this._reconnection&&this.backoff.attempts===0&&this.reconnect()}open(e){if(nt("readyState %s",this._readyState),~this._readyState.indexOf("open"))return this;nt("opening %s",this.uri),this.engine=new ic.Socket(this.uri,this.opts);let t=this.engine,n=this;this._readyState="opening",this.skipReconnect=!1;let s=(0,rn.on)(t,"open",function(){n.onopen(),e&&e()}),i=f=>{nt("error"),this.cleanup(),this._readyState="closed",this.emitReserved("error",f),e?e(f):this.maybeReconnectOnOpen()},a=(0,rn.on)(t,"error",i);if(this._timeout!==!1){let f=this._timeout;nt("connect attempt will timeout after %d",f);let u=this.setTimeoutFn(()=>{nt("connect attempt timed out after %d",f),s(),i(new Error("timeout")),t.close()},f);this.opts.autoUnref&&u.unref(),this.subs.push(()=>{this.clearTimeoutFn(u)})}return this.subs.push(s),this.subs.push(a),this}connect(e){return this.open(e)}onopen(){nt("open"),this.cleanup(),this._readyState="open",this.emitReserved("open");let e=this.engine;this.subs.push((0,rn.on)(e,"ping",this.onping.bind(this)),(0,rn.on)(e,"data",this.ondata.bind(this)),(0,rn.on)(e,"error",this.onerror.bind(this)),(0,rn.on)(e,"close",this.onclose.bind(this)),(0,rn.on)(this.decoder,"decoded",this.ondecoded.bind(this)))}onping(){this.emitReserved("ping")}ondata(e){try{this.decoder.add(e)}catch(t){this.onclose("parse error",t)}}ondecoded(e){(0,ic.nextTick)(()=>{this.emitReserved("packet",e)},this.setTimeoutFn)}onerror(e){nt("error",e),this.emitReserved("error",e)}socket(e,t){let n=this.nsps[e];return n?this._autoConnect&&!n.active&&n.connect():(n=new um.Socket(this,e,t),this.nsps[e]=n),n}_destroy(e){let t=Object.keys(this.nsps);for(let n of t)if(this.nsps[n].active){nt("socket %s is still active, skipping close",n);return}this._close()}_packet(e){nt("writing packet %j",e);let t=this.encoder.encode(e);for(let n=0;n<t.length;n++)this.engine.write(t[n],e.options)}cleanup(){nt("cleanup"),this.subs.forEach(e=>e()),this.subs.length=0,this.decoder.destroy()}_close(){nt("disconnect"),this.skipReconnect=!0,this._reconnecting=!1,this.onclose("forced close")}disconnect(){return this._close()}onclose(e,t){var n;nt("closed due to %s",e),this.cleanup(),(n=this.engine)===null||n===void 0||n.close(),this.backoff.reset(),this._readyState="closed",this.emitReserved("close",e,t),this._reconnection&&!this.skipReconnect&&this.reconnect()}reconnect(){if(this._reconnecting||this.skipReconnect)return this;let e=this;if(this.backoff.attempts>=this._reconnectionAttempts)nt("reconnect failed"),this.backoff.reset(),this.emitReserved("reconnect_failed"),this._reconnecting=!1;else{let t=this.backoff.duration();nt("will wait %dms before reconnect attempt",t),this._reconnecting=!0;let n=this.setTimeoutFn(()=>{e.skipReconnect||(nt("attempting reconnect"),this.emitReserved("reconnect_attempt",e.backoff.attempts),!e.skipReconnect&&e.open(s=>{s?(nt("reconnect attempt error"),e._reconnecting=!1,e.reconnect(),this.emitReserved("reconnect_error",s)):(nt("reconnect success"),e.onreconnect())}))},t);this.opts.autoUnref&&n.unref(),this.subs.push(()=>{this.clearTimeoutFn(n)})}}onreconnect(){let e=this.backoff.attempts;this._reconnecting=!1,this.backoff.reset(),this.emitReserved("reconnect",e)}};At.Manager=oc});var dh=F((Fe,hh)=>{"use strict";var gm=Fe&&Fe.__importDefault||function(r){return r&&r.__esModule?r:{default:r}};Object.defineProperty(Fe,"__esModule",{value:!0});Fe.WebTransport=Fe.WebSocket=Fe.NodeWebSocket=Fe.XHR=Fe.NodeXHR=Fe.Fetch=Fe.Socket=Fe.Manager=Fe.protocol=void 0;Fe.io=nn;Fe.connect=nn;Fe.default=nn;var _m=th(),Ui=fh();Object.defineProperty(Fe,"Manager",{enumerable:!0,get:function(){return Ui.Manager}});var lh=nc();Object.defineProperty(Fe,"Socket",{enumerable:!0,get:function(){return lh.Socket}});var mm=gm(kt()),uh=(0,mm.default)("socket.io-client"),Es={};function nn(r,e){typeof r=="object"&&(e=r,r=void 0),e=e||{};let t=(0,_m.url)(r,e.path||"/socket.io"),n=t.source,s=t.id,i=t.path,a=Es[s]&&i in Es[s].nsps,f=e.forceNew||e["force new connection"]||e.multiplex===!1||a,u;return f?(uh("ignoring socket cache for %s",n),u=new Ui.Manager(n,e)):(Es[s]||(uh("new io instance for %s",n),Es[s]=new Ui.Manager(n,e)),u=Es[s]),t.query&&!e.query&&(e.query=t.queryKey),u.socket(t.path,e)}Object.assign(nn,{Manager:Ui.Manager,Socket:lh.Socket,io:nn,connect:nn});var ym=Bi();Object.defineProperty(Fe,"protocol",{enumerable:!0,get:function(){return ym.protocol}});var Mn=Ni();Object.defineProperty(Fe,"Fetch",{enumerable:!0,get:function(){return Mn.Fetch}});Object.defineProperty(Fe,"NodeXHR",{enumerable:!0,get:function(){return Mn.NodeXHR}});Object.defineProperty(Fe,"XHR",{enumerable:!0,get:function(){return Mn.XHR}});Object.defineProperty(Fe,"NodeWebSocket",{enumerable:!0,get:function(){return Mn.NodeWebSocket}});Object.defineProperty(Fe,"WebSocket",{enumerable:!0,get:function(){return Mn.WebSocket}});Object.defineProperty(Fe,"WebTransport",{enumerable:!0,get:function(){return Mn.WebTransport}});hh.exports=nn});var _h=F(qi=>{"use strict";Object.defineProperty(qi,"__esModule",{value:!0});qi.WebSocketService=void 0;var Em=dh(),ph=Kr(),gh=qs(),ac=class{authService;cryptoService;config;logger;notification;deviceId;platform;socket=null;inputHandler=null;createTerminalHandler=null;getBufferHandler=null;redrawHandler=null;resizeHandler=null;reconnectHandlers=[];authFailureHandler=null;fileViewRequestHandler=null;fileListRequestHandler=null;fileDownloadRequestHandler=null;statusChangeHandler=null;agentNameSyncHandler=null;agentId=null;hasConnectedOnce=!1;isRemoteRename=!1;negotiatedCapabilities=[];HEARTBEAT_INTERVAL=3e4;HEARTBEAT_TIMEOUT=1e4;heartbeatTimer=null;pongTimer=null;lastPongTime=0;isManualDisconnect=!1;reconnectAttempts=0;reconnectTimer=null;networkCheckTimer=null;isOnline=!0;lastNetworkCheck=0;rekeyingTerminals=new Set;outputBuffer=new Map;OUTPUT_BUFFER_MAX_SIZE=1e3;RECONNECT_BASE_DELAY=1e3;RECONNECT_MAX_DELAY=3e4;RECONNECT_JITTER=.2;NETWORK_CHECK_INTERVAL=5e3;constructor(e,t,n,s,i,a,f="vscode"){this.authService=e,this.cryptoService=t,this.config=n,this.logger=s,this.notification=i,this.deviceId=a,this.platform=f}async connect(){let e=await this.authService.getAccessToken();if(!e)throw new Error("No access token available");this.isManualDisconnect=!1,this.stopReconnect(),this.reconnectAttempts=0,this.agentId=await this.authService.getAgentId();let t=(0,gh.getWsUrl)(this.config);this.logger.info("Connecting to WebSocket",t),this.statusChangeHandler?.("connecting");let n=await this.cryptoService.getPublicKey();return new Promise((s,i)=>{this.socket=(0,Em.io)(`${t}/agent`,{auth:{token:e,protocolVersion:ph.PROTOCOL_VERSION,deviceId:this.deviceId,platform:this.platform,capabilities:ph.DEFAULT_CLIENT_CAPABILITIES,publicKey:n},transports:["websocket"],reconnection:!1}),this.socket.on("connect",()=>{if(this.logger.info("WebSocket connected"),this.reconnectAttempts=0,this.statusChangeHandler?.("connected",this.agentId??void 0),this.startHeartbeat(),this.cryptoService.cleanupAllStaleSessions(),this.hasConnectedOnce){this.logger.info("Reconnected - triggering workspace re-registration");for(let a of this.reconnectHandlers)a()}else this.hasConnectedOnce=!0,s()}),this.socket.on("error",a=>{this.logger.error(`Server error [${a.code}]: ${a.message}`),a.code==="E401"&&(this.logger.warn("Auth failure (E401)"),this.authFailureHandler?.())}),this.socket.on("disconnect",a=>{this.logger.warn("WebSocket disconnected",a),this.stopHeartbeat(),this.statusChangeHandler?.("disconnected"),this.isManualDisconnect||(a==="transport close"?(this.logger.info("Transport close - attempting immediate reconnect"),this.attemptReconnect(!0)):this.scheduleReconnect())}),this.socket.on("protocol:info",a=>{this.logger.info("Protocol info received",a.protocolVersion),this.negotiatedCapabilities=a.negotiatedCapabilities,a.agentName&&this.config.getAgentName()!==a.agentName&&(this.isRemoteRename=!0,this.config.setAgentName(a.agentName).then(()=>{setTimeout(()=>{this.isRemoteRename=!1},100)}),this.agentNameSyncHandler?.(a.agentName),this.logger.info("Agent name synced from server",a.agentName))}),this.socket.on("pong",()=>{this.lastPongTime=Date.now(),this.clearPongTimeout(),this.logger.debug("Heartbeat pong received")}),this.socket.on("connect_error",a=>{this.logger.error("WebSocket connection error",a),this.statusChangeHandler?.("error"),this.hasConnectedOnce||i(a),this.scheduleReconnect()}),this.socket.on("terminal:input",a=>{this.handleTerminalInput(a)}),this.socket.on("crypto:keyExchange",async(a,f)=>{this.logger.info("Received key exchange request",a.terminalId,a.sessionId),this.rekeyingTerminals.add(a.terminalId),this.outputBuffer.set(a.terminalId,[]);try{if(await this.cryptoService.handleKeyExchange(a.terminalId,a.clientPublicKey,a.sessionId)){let d=await this.cryptoService.getPublicKey();f?.({success:!0,agentPublicKey:d||void 0}),this.flushOutputBuffer(a.terminalId)}else f?.({success:!1,error:"Key exchange failed"})}catch(u){this.logger.error("Key exchange error",u),f?.({success:!1,error:String(u)})}finally{this.rekeyingTerminals.delete(a.terminalId),this.outputBuffer.delete(a.terminalId)}}),this.socket.on("crypto:sessionCleanup",a=>{this.cryptoService.removeSession(a.terminalId,a.sessionId)}),this.socket.on("agent:keyExchangeRequest",async a=>{try{let f=await this.cryptoService.handleAgentKeyExchange(a.clientPublicKey,a.sessionId),u={agentId:a.agentId,sessionId:a.sessionId,ok:f,error:f?void 0:"Key exchange failed"};this.socket?.emit("agent:keyExchangeAck",u)}catch(f){this.logger.error("Agent key exchange error",f);let u={agentId:a.agentId,sessionId:a.sessionId,ok:!1,error:String(f)};this.socket?.emit("agent:keyExchangeAck",u)}}),this.socket.on("agent:sessionEnd",a=>{this.cryptoService.removeAgentSession(a.sessionId)}),this.socket.on("agent:renamed",a=>{this.logger.info("Agent renamed from web client",a.name),this.isRemoteRename=!0,this.config.setAgentName(a.name).then(()=>{setTimeout(()=>{this.isRemoteRename=!1},100)}),this.agentNameSyncHandler?.(a.name)}),this.socket.on("terminal:createRequest",a=>{this.createTerminalHandler?.(a.name)}),this.socket.on("terminal:getBuffer",(a,f)=>{if(!this.getBufferHandler){f?.({success:!1,error:"Buffer handler not set"});return}let u=this.getBufferHandler(a.terminalId);if(u===null){f?.({success:!1,error:"Terminal not found"});return}let d=this.cryptoService.encryptOutput(a.terminalId,u);f?.(d?{success:!0,encrypted:d}:{success:!0,data:u}),this.redrawHandler?.(a.terminalId)}),this.socket.on("terminal:resize",a=>{this.resizeHandler?.(a.terminalId,a.cols,a.rows)}),this.socket.on("file:view",a=>{this.fileViewRequestHandler?.(a.terminalId,a.request)}),this.socket.on("file:list",a=>{this.fileListRequestHandler?.(a.terminalId,a.request)}),this.socket.on("file:download:request",a=>{this.fileDownloadRequestHandler?.(a.terminalId,a.path,a.requestId)})})}disconnect(){this.isManualDisconnect=!0,this.hasConnectedOnce=!1,this.stopReconnect(),this.stopHeartbeat(),this.cryptoService.clearAllSessions(),this.socket&&(this.logger.info("Disconnecting WebSocket"),this.socket.disconnect(),this.socket=null)}softDisconnect(){this.stopReconnect(),this.stopHeartbeat(),this.socket&&(this.logger.info("Soft disconnecting WebSocket (for reconnect)"),this.socket.disconnect(),this.socket=null)}getStatus(){return{connected:this.socket?.connected??!1,agentId:this.agentId}}onInput(e){this.inputHandler=e}onCreateTerminalRequest(e){this.createTerminalHandler=e}onGetBufferRequest(e){this.getBufferHandler=e}onRedrawRequest(e){this.redrawHandler=e}onResizeRequest(e){this.resizeHandler=e}onReconnect(e){this.reconnectHandlers.push(e)}onAuthFailure(e){this.authFailureHandler=e}onFileViewRequest(e){this.fileViewRequestHandler=e}onFileListRequest(e){this.fileListRequestHandler=e}onFileDownloadRequest(e){this.fileDownloadRequestHandler=e}onStatusChange(e){this.statusChangeHandler=e}onAgentNameSync(e){this.agentNameSyncHandler=e}async registerWorkspace(e){return this.emit("workspace:register",e)}async unregisterWorkspace(e){await this.emit("workspace:unregister",{instanceId:e})}async terminalCreated(e){return this.emit("terminal:created",e)}async terminalClosed(e){this.cryptoService.removeSession(e.terminalId),await this.emit("terminal:closed",e)}terminalNotFound(e){this.socket?.emit("terminal:notFound",{terminalId:e})}sendOutput(e,t,n){if(!this.socket?.connected)return;if(this.rekeyingTerminals.has(t)){let a=this.outputBuffer.get(t);a&&a.length<this.OUTPUT_BUFFER_MAX_SIZE&&a.push({instanceId:e,data:n});return}let s=this.cryptoService.encryptOutput(t,n),i={instanceId:e,terminalId:t,...s?{encrypted:s}:{data:n}};this.socket?.emit("terminal:output",i)}flushOutputBuffer(e){let t=this.outputBuffer.get(e);if(!(!t||t.length===0)){this.logger.info("Flushing output buffer after rekey",e,String(t.length));for(let{instanceId:n,data:s}of t){let i=this.cryptoService.encryptOutput(e,s),a={instanceId:n,terminalId:e,...i?{encrypted:i}:{data:s}};this.socket?.emit("terminal:output",a)}}}async updateStatus(e){await this.emit("terminal:status",e)}sendTerminalEvent(e,t,n){let s={instanceId:e,terminalId:t,event:n};this.socket?.emit("terminal:event",s)}hasCapability(e){return this.negotiatedCapabilities.includes(e)}sendFileChangedEvent(e,t,n){let s={instanceId:e,terminalId:t,event:n};this.socket?.emit("file:changed",s)}sendFileListResponse(e,t){let n={instanceId:e,response:t};this.socket?.emit("file:list:response",n)}sendAgentRename(e){this.socket?.emit("agent:rename",{name:e})}isRemoteRenameInProgress(){return this.isRemoteRename}getSocket(){return this.socket}emit(e,t){return new Promise((n,s)=>{if(!this.socket?.connected){s(new Error("WebSocket not connected"));return}this.socket.emit(e,t,i=>{i.success?n(i):s(new Error(i.error||"Unknown error"))})})}startHeartbeat(){this.stopHeartbeat(),this.lastPongTime=Date.now(),this.heartbeatTimer=setInterval(()=>{if(!this.socket?.connected){this.stopHeartbeat();return}if(Date.now()-this.lastPongTime>this.HEARTBEAT_INTERVAL+this.HEARTBEAT_TIMEOUT){this.logger.warn("Heartbeat timeout"),this.socket.disconnect();return}this.socket.emit("ping"),this.pongTimer=setTimeout(()=>{this.logger.warn("Pong timeout - server not responding"),this.statusChangeHandler?.("error")},this.HEARTBEAT_TIMEOUT)},this.HEARTBEAT_INTERVAL)}stopHeartbeat(){this.heartbeatTimer&&(clearInterval(this.heartbeatTimer),this.heartbeatTimer=null),this.clearPongTimeout()}clearPongTimeout(){this.pongTimer&&(clearTimeout(this.pongTimer),this.pongTimer=null)}handleTerminalInput(e){let t;if(e.encrypted){let n=this.cryptoService.decryptInput(e.terminalId,e.encrypted);if(!n){this.logger.error("Failed to decrypt terminal input",e.terminalId);return}t=n}else if(e.data)t=Buffer.from(e.data,"base64").toString("utf8");else{this.logger.error("Invalid terminal input payload");return}this.inputHandler?.(e.terminalId,t,e.dbTerminalId)}hasE2ESession(e){return this.cryptoService.hasSession(e)}getReconnectDelay(){let e=Math.min(this.RECONNECT_BASE_DELAY*Math.pow(2,this.reconnectAttempts),this.RECONNECT_MAX_DELAY),t=1+(Math.random()*2-1)*this.RECONNECT_JITTER;return Math.floor(e*t)}scheduleReconnect(){if(this.isManualDisconnect)return;this.stopReconnect();let e=this.getReconnectDelay();if(this.logger.info("Scheduling reconnect",String(this.reconnectAttempts+1),"delay:",String(e)),!this.isOnline){this.statusChangeHandler?.("disconnected"),this.startNetworkCheck();return}this.statusChangeHandler?.("connecting"),this.reconnectTimer=setTimeout(()=>{this.attemptReconnect()},e)}async attemptReconnect(e=!1){if(this.isManualDisconnect||this.socket?.connected)return;let t=await this.authService.hasValidToken();if(!t){if(this.logger.info("Access token expired, attempting refresh"),!await this.authService.refreshAccessToken()){this.logger.info("Token refresh failed, stopping reconnect"),this.stopReconnect(),this.statusChangeHandler?.("disconnected"),this.notification.warn("Session expired. Please log in again."),this.authFailureHandler?.();return}t=!0}this.reconnectAttempts++;try{if(this.socket&&(this.socket.disconnect(),this.socket=null),!e&&!await this.checkNetwork()){this.isOnline=!1,this.scheduleReconnect();return}this.isOnline=!0,await this.connect(),this.reconnectAttempts=0}catch(n){this.logger.warn("Reconnect failed",n),this.statusChangeHandler?.("error"),this.scheduleReconnect()}}stopReconnect(){this.reconnectTimer&&(clearTimeout(this.reconnectTimer),this.reconnectTimer=null),this.stopNetworkCheck()}async checkNetwork(){let e=Date.now();if(e-this.lastNetworkCheck<1e3)return this.isOnline;this.lastNetworkCheck=e;try{let t=`${(0,gh.getApiUrl)(this.config)}/health`,n=new AbortController,s=setTimeout(()=>n.abort(),5e3),i=await fetch(t,{method:"GET",signal:n.signal});return clearTimeout(s),this.logger.debug("Network check OK",String(i.status)),!0}catch{return this.logger.debug("Network check failed (offline)"),!1}}startNetworkCheck(){this.stopNetworkCheck(),this.networkCheckTimer=setInterval(async()=>{if(this.isManualDisconnect){this.stopNetworkCheck();return}if(this.socket?.connected){this.stopNetworkCheck();return}let e=await this.checkNetwork();e&&!this.isOnline?(this.logger.info("Network restored! Triggering immediate reconnect"),this.isOnline=!0,this.stopNetworkCheck(),this.reconnectAttempts=0,this.attemptReconnect()):e&&this.isOnline?(this.stopNetworkCheck(),this.attemptReconnect()):e||(this.isOnline=!1)},this.NETWORK_CHECK_INTERVAL)}stopNetworkCheck(){this.networkCheckTimer&&(clearInterval(this.networkCheckTimer),this.networkCheckTimer=null)}};qi.WebSocketService=ac});var yh=F(Qt=>{"use strict";var wm=Qt&&Qt.__createBinding||(Object.create?(function(r,e,t,n){n===void 0&&(n=t);var s=Object.getOwnPropertyDescriptor(e,t);(!s||("get"in s?!e.__esModule:s.writable||s.configurable))&&(s={enumerable:!0,get:function(){return e[t]}}),Object.defineProperty(r,n,s)}):(function(r,e,t,n){n===void 0&&(n=t),r[n]=e[t]})),xm=Qt&&Qt.__setModuleDefault||(Object.create?(function(r,e){Object.defineProperty(r,"default",{enumerable:!0,value:e})}):function(r,e){r.default=e}),fc=Qt&&Qt.__importStar||(function(){var r=function(e){return r=Object.getOwnPropertyNames||function(t){var n=[];for(var s in t)Object.prototype.hasOwnProperty.call(t,s)&&(n[n.length]=s);return n},r(e)};return function(e){if(e&&e.__esModule)return e;var t={};if(e!=null)for(var n=r(e),s=0;s<n.length;s++)n[s]!=="default"&&wm(t,e,n[s]);return xm(t,e),t}})();Object.defineProperty(Qt,"__esModule",{value:!0});Qt.FileTransferService=void 0;var Wi=fc(require("fs")),vm=fc(require("path")),mh=fc(require("crypto")),Me=Kr(),cc=class{socket=null;activeTransfers=new Map;instanceId="";logger;fallbackDir;constructor(e,t="/tmp"){this.logger=e,this.fallbackDir=t}attach(e,t){this.socket=e,this.instanceId=t,this.setupEventHandlers(),this.logger.info("FileTransferService attached")}detach(){this.socket=null;for(let[e]of this.activeTransfers)this.cancelTransfer(e,"Disconnected");this.logger.info("FileTransferService detached")}async sendFile(e,t,n,s,i){let a=Wi.readFileSync(t),f=t.split("/").pop()||"file";return this.initAndSendChunks(e,a,f,{mimeType:this.getMimeType(f),requestId:i,onProgress:n,onComplete:s})}async sendBuffer(e,t,n,s,i){return this.initAndSendChunks(e,t,n,{mimeType:s,purpose:i?.purpose,viewMetadata:i?.viewMetadata,requestId:i?.requestId,onProgress:i?.onProgress,onComplete:i?.onComplete})}async initAndSendChunks(e,t,n,s){if(!this.socket)throw new Error("Socket not connected");let i=t.length,a=(0,Me.calculateTotalChunks)(i),f=this.calculateChecksum(t),u=mh.randomUUID(),d={id:u,terminalId:e,filename:n,size:i,totalChunks:a,direction:Me.TransferDirection.DOWNLOAD,status:Me.TransferStatus.PENDING,deliveredChunks:new Set,pendingChunks:new Map,checksum:f,checksumAlgorithm:"sha256",onProgress:s.onProgress?(_,y)=>s.onProgress(u,_,y):void 0,onComplete:s.onComplete?(_,y)=>s.onComplete(u,_,y):void 0,ackTimeouts:new Map};d.chunks=[];for(let _=0;_<a;_++){let y=_*Me.CHUNK_SIZE,x=Math.min(y+Me.CHUNK_SIZE,i);d.chunks.push(t.subarray(y,x))}this.activeTransfers.set(u,d);let g={transferId:u,terminalId:e,filename:n,size:i,totalChunks:a,mimeType:s.mimeType||"application/octet-stream",checksum:f,direction:Me.TransferDirection.DOWNLOAD,instanceId:this.instanceId};return s.requestId&&(g.requestId=s.requestId),s.purpose&&(g.purpose=s.purpose),s.viewMetadata&&(g.viewMetadata=s.viewMetadata),new Promise((_,y)=>{this.socket.emit("file:init",g,x=>{x.accepted?(d.status=Me.TransferStatus.ACTIVE,this.startSendingChunks(u),_(u)):(this.activeTransfers.delete(u),y(new Error(x.error||"Transfer rejected")))})})}async receiveFile(e,t,n,s,i,a,f,u="sha256",d,g){let _={id:e,terminalId:t,filename:n,filePath:f,size:s,totalChunks:i,direction:Me.TransferDirection.UPLOAD,status:Me.TransferStatus.ACTIVE,deliveredChunks:new Set,pendingChunks:new Map,chunks:new Array(i).fill(null),checksum:a,checksumAlgorithm:u,onProgress:d?(y,x)=>d(e,y,x):void 0,onComplete:g?(y,x)=>g(e,y,x):void 0,ackTimeouts:new Map};this.activeTransfers.set(e,_)}cancelTransfer(e,t){let n=this.activeTransfers.get(e);if(n){for(let s of n.ackTimeouts.values())clearTimeout(s);if(n.status=Me.TransferStatus.CANCELLED,n.onComplete?.(!1,t),this.socket){let s={transferId:e,reason:t};this.socket.emit("file:cancel",s)}this.activeTransfers.delete(e)}}async resumeTransfer(e){let t=this.activeTransfers.get(e);!t||!this.socket||this.socket.emit("file:sync",{transferId:e},n=>{if(n.status===Me.TransferStatus.EXPIRED){t.onComplete?.(!1,"Transfer expired"),this.activeTransfers.delete(e);return}if(n.deliveredChunks)for(let s of n.deliveredChunks)t.deliveredChunks.add(s);if(t.direction===Me.TransferDirection.DOWNLOAD&&n.missingChunks){t.status=Me.TransferStatus.ACTIVE;for(let s of n.missingChunks)this.sendChunk(t,s)}})}getTransferStatus(e){return this.activeTransfers.get(e)?.status??null}getTransferProgress(e){let t=this.activeTransfers.get(e);return t?{delivered:t.deliveredChunks.size,total:t.totalChunks}:null}setupEventHandlers(){this.socket&&(this.socket.on("file:chunk",e=>{this.handleIncomingChunk(e)}),this.socket.on("file:chunk:ack",e=>{this.handleChunkAck(e)}),this.socket.on("file:complete",e=>{this.handleComplete(e)}),this.socket.on("file:progress",e=>{this.handleProgress(e)}),this.socket.on("file:init",(e,t)=>{this.handleIncomingFileInit(e,t)}),this.socket.on("file:cancel",e=>{let t=this.activeTransfers.get(e.transferId);if(t){for(let n of t.ackTimeouts.values())clearTimeout(n);t.status=Me.TransferStatus.CANCELLED,t.onComplete?.(!1,e.reason||"Cancelled by remote"),this.activeTransfers.delete(e.transferId)}}))}startSendingChunks(e){let t=this.activeTransfers.get(e);if(!(!t||!t.chunks))for(let n=0;n<Math.min(Me.WINDOW_SIZE,t.totalChunks);n++)t.deliveredChunks.has(n)||this.sendChunk(t,n)}sendChunk(e,t){if(!this.socket||!e.chunks)return;let n=e.chunks[t];if(!n)return;let s=e.pendingChunks.get(t),i={seq:t,data:n,retries:s?s.retries:0,sentAt:Date.now()};e.pendingChunks.set(t,i);let a={transferId:e.id,seq:t,data:n.buffer.slice(n.byteOffset,n.byteOffset+n.byteLength)};this.socket.emit("file:chunk",a,u=>{u&&!u.success&&this.cancelTransfer(e.id,u.error||"Server rejected chunk")});let f=setTimeout(()=>{this.handleAckTimeout(e.id,t)},Me.ACK_TIMEOUT_MS);e.ackTimeouts.set(t,f)}handleChunkAck(e){let t=this.activeTransfers.get(e.transferId);if(!t||t.status===Me.TransferStatus.COMPLETED)return;let n=t.ackTimeouts.get(e.seq);n&&(clearTimeout(n),t.ackTimeouts.delete(e.seq)),t.deliveredChunks.add(e.seq),t.pendingChunks.delete(e.seq),t.onProgress?.(t.deliveredChunks.size,t.totalChunks);let s=e.seq+Me.WINDOW_SIZE;s<t.totalChunks&&!t.deliveredChunks.has(s)&&this.sendChunk(t,s),t.deliveredChunks.size===t.totalChunks&&this.finishSending(t)}handleAckTimeout(e,t){let n=this.activeTransfers.get(e);if(!n)return;let s=n.pendingChunks.get(t);s&&(s.retries<Me.MAX_RETRIES?(s.retries++,this.sendChunk(n,t)):this.cancelTransfer(e,"Max retries exceeded"))}finishSending(e){if(!this.socket)return;e.status=Me.TransferStatus.COMPLETED;let t={transferId:e.id,checksum:e.checksum};this.socket.emit("file:end",t)}handleIncomingChunk(e){let t=this.activeTransfers.get(e.transferId);if(!(!t||!t.chunks)){if(t.chunks[e.seq]=Buffer.from(e.data),t.deliveredChunks.add(e.seq),this.socket){let n={transferId:e.transferId,seq:e.seq};this.socket.emit("file:chunk:ack",n)}t.onProgress?.(t.deliveredChunks.size,t.totalChunks),t.deliveredChunks.size===t.totalChunks&&this.finishReceiving(t)}}finishReceiving(e){if(!e.chunks||!e.filePath)return;let t=Buffer.concat(e.chunks);if(this.calculateChecksum(t,e.checksumAlgorithm)!==e.checksum){e.status=Me.TransferStatus.FAILED,e.onComplete?.(!1,"Checksum mismatch"),this.socket&&this.socket.emit("file:complete",{transferId:e.id,success:!1,error:"Checksum mismatch"});return}try{let s=vm.dirname(e.filePath);Wi.existsSync(s)||Wi.mkdirSync(s,{recursive:!0}),Wi.writeFileSync(e.filePath,t),e.status=Me.TransferStatus.COMPLETED,e.onComplete?.(!0),this.socket&&this.socket.emit("file:complete",{transferId:e.id,success:!0})}catch(s){let i=s instanceof Error?s.message:String(s);e.status=Me.TransferStatus.FAILED,e.onComplete?.(!1,`Failed to save file: ${i}`),this.socket&&this.socket.emit("file:complete",{transferId:e.id,success:!1,error:`Failed to save file: ${i}`})}this.activeTransfers.delete(e.id)}handleComplete(e){let t=this.activeTransfers.get(e.transferId);if(t){e.success?(t.status=Me.TransferStatus.COMPLETED,t.onComplete?.(!0)):(t.status=Me.TransferStatus.FAILED,t.onComplete?.(!1,e.error));for(let n of t.ackTimeouts.values())clearTimeout(n);this.activeTransfers.delete(e.transferId)}}handleProgress(e){let t=this.activeTransfers.get(e.transferId);t&&t.onProgress?.(e.deliveredChunks,e.totalChunks)}handleIncomingFileInit(e,t){let s=`${e.targetPath||this.fallbackDir}/${e.filename}`;this.receiveFile(e.transferId,e.terminalId,e.filename,e.size,e.totalChunks,e.checksum,s,e.checksumAlgorithm||"sha256").then(()=>t({accepted:!0})).catch(i=>t({accepted:!1,error:i.message}))}calculateChecksum(e,t="sha256"){return t==="fnv1a"?this.fnv1aHash(e):mh.createHash("sha256").update(e).digest("hex")}fnv1aHash(e){let t=2166136261;for(let s=0;s<e.length;s++)t^=e[s],t=Math.imul(t,16777619);return(t>>>0).toString(16).padStart(8,"0").repeat(8)}getMimeType(e){let t=e.split(".").pop()?.toLowerCase();return{txt:"text/plain",json:"application/json",js:"application/javascript",ts:"application/typescript",html:"text/html",css:"text/css",md:"text/markdown",png:"image/png",jpg:"image/jpeg",jpeg:"image/jpeg",gif:"image/gif",webp:"image/webp",svg:"image/svg+xml",pdf:"application/pdf",zip:"application/zip",tar:"application/x-tar",gz:"application/gzip"}[t||""]||"application/octet-stream"}};Qt.FileTransferService=cc});var _c=F((sx,Ki)=>{function xh(r){return Array.isArray(r)?r:[r]}var bm=void 0,lc="",Eh=" ",uc="\\",Sm=/^\s+$/,Tm=/(?:[^\\]|^)\\$/,Om=/^\\!/,Cm=/^\\#/,km=/\r?\n/g,Pm=/^\.{0,2}\/|^\.{1,2}$/,Rm=/\/$/,Bn="/",vh="node-ignore";typeof Symbol<"u"&&(vh=Symbol.for("node-ignore"));var bh=vh,jn=(r,e,t)=>(Object.defineProperty(r,e,{value:t}),t),Am=/([0-z])-([0-z])/g,Sh=()=>!1,Im=r=>r.replace(Am,(e,t,n)=>t.charCodeAt(0)<=n.charCodeAt(0)?e:lc),Nm=r=>{let{length:e}=r;return r.slice(0,e-e%2)},Lm=[[/^\uFEFF/,()=>lc],[/((?:\\\\)*?)(\\?\s+)$/,(r,e,t)=>e+(t.indexOf("\\")===0?Eh:lc)],[/(\\+?)\s/g,(r,e)=>{let{length:t}=e;return e.slice(0,t-t%2)+Eh}],[/[\\$.|*+(){^]/g,r=>`\\${r}`],[/(?!\\)\?/g,()=>"[^/]"],[/^\//,()=>"^"],[/\//g,()=>"\\/"],[/^\^*\\\*\\\*\\\//,()=>"^(?:.*\\/)?"],[/^(?=[^^])/,function(){return/\/(?!$)/.test(this)?"^":"(?:^|\\/)"}],[/\\\/\\\*\\\*(?=\\\/|$)/g,(r,e,t)=>e+6<t.length?"(?:\\/[^\\/]+)*":"\\/.+"],[/(^|[^\\]+)(\\\*)+(?=.+)/g,(r,e,t)=>{let n=t.replace(/\\\*/g,"[^\\/]*");return e+n}],[/\\\\\\(?=[$.|*+(){^])/g,()=>uc],[/\\\\/g,()=>uc],[/(\\)?\[([^\]/]*?)(\\*)($|\])/g,(r,e,t,n,s)=>e===uc?`\\[${t}${Nm(n)}${s}`:s==="]"&&n.length%2===0?`[${Im(t)}${n}]`:"[]"],[/(?:[^*])$/,r=>/\/$/.test(r)?`${r}$`:`${r}(?=$|\\/$)`]],Dm=/(^|\\\/)?\\\*$/,ws="regex",Hi="checkRegex",wh="_",Fm={[ws](r,e){return`${e?`${e}[^/]+`:"[^/]*"}(?=$|\\/$)`},[Hi](r,e){return`${e?`${e}[^/]*`:"[^/]*"}(?=$|\\/$)`}},Mm=r=>Lm.reduce((e,[t,n])=>e.replace(t,n.bind(r)),r),Vi=r=>typeof r=="string",Bm=r=>r&&Vi(r)&&!Sm.test(r)&&!Tm.test(r)&&r.indexOf("#")!==0,jm=r=>r.split(km).filter(Boolean),hc=class{constructor(e,t,n,s,i,a){this.pattern=e,this.mark=t,this.negative=i,jn(this,"body",n),jn(this,"ignoreCase",s),jn(this,"regexPrefix",a)}get regex(){let e=wh+ws;return this[e]?this[e]:this._make(ws,e)}get checkRegex(){let e=wh+Hi;return this[e]?this[e]:this._make(Hi,e)}_make(e,t){let n=this.regexPrefix.replace(Dm,Fm[e]),s=this.ignoreCase?new RegExp(n,"i"):new RegExp(n);return jn(this,t,s)}},Um=({pattern:r,mark:e},t)=>{let n=!1,s=r;s.indexOf("!")===0&&(n=!0,s=s.substr(1)),s=s.replace(Om,"!").replace(Cm,"#");let i=Mm(s);return new hc(r,e,s,t,n,i)},dc=class{constructor(e){this._ignoreCase=e,this._rules=[]}_add(e){if(e&&e[bh]){this._rules=this._rules.concat(e._rules._rules),this._added=!0;return}if(Vi(e)&&(e={pattern:e}),Bm(e.pattern)){let t=Um(e,this._ignoreCase);this._added=!0,this._rules.push(t)}}add(e){return this._added=!1,xh(Vi(e)?jm(e):e).forEach(this._add,this),this._added}test(e,t,n){let s=!1,i=!1,a;this._rules.forEach(u=>{let{negative:d}=u;i===d&&s!==i||d&&!s&&!i&&!t||!u[n].test(e)||(s=!d,i=d,a=d?bm:u)});let f={ignored:s,unignored:i};return a&&(f.rule=a),f}},qm=(r,e)=>{throw new e(r)},gr=(r,e,t)=>Vi(r)?r?gr.isNotRelative(r)?t(`path should be a \`path.relative()\`d string, but got "${e}"`,RangeError):!0:t("path must not be empty",TypeError):t(`path must be a string, but got \`${e}\``,TypeError),Th=r=>Pm.test(r);gr.isNotRelative=Th;gr.convert=r=>r;var pc=class{constructor({ignorecase:e=!0,ignoreCase:t=e,allowRelativePaths:n=!1}={}){jn(this,bh,!0),this._rules=new dc(t),this._strictPathCheck=!n,this._initCache()}_initCache(){this._ignoreCache=Object.create(null),this._testCache=Object.create(null)}add(e){return this._rules.add(e)&&this._initCache(),this}addPattern(e){return this.add(e)}_test(e,t,n,s){let i=e&&gr.convert(e);return gr(i,e,this._strictPathCheck?qm:Sh),this._t(i,t,n,s)}checkIgnore(e){if(!Rm.test(e))return this.test(e);let t=e.split(Bn).filter(Boolean);if(t.pop(),t.length){let n=this._t(t.join(Bn)+Bn,this._testCache,!0,t);if(n.ignored)return n}return this._rules.test(e,!1,Hi)}_t(e,t,n,s){if(e in t)return t[e];if(s||(s=e.split(Bn).filter(Boolean)),s.pop(),!s.length)return t[e]=this._rules.test(e,n,ws);let i=this._t(s.join(Bn)+Bn,t,n,s);return t[e]=i.ignored?i:this._rules.test(e,n,ws)}ignores(e){return this._test(e,this._ignoreCache,!1).ignored}createFilter(){return e=>!this.ignores(e)}filter(e){return xh(e).filter(this.createFilter())}test(e){return this._test(e,this._testCache,!0)}},gc=r=>new pc(r),Wm=r=>gr(r&&gr.convert(r),r,Sh),Oh=()=>{let r=t=>/^\\\\\?\\/.test(t)||/["<>|\u0000-\u001F]+/u.test(t)?t:t.replace(/\\/g,"/");gr.convert=r;let e=/^[a-z]:\//i;gr.isNotRelative=t=>e.test(t)||Th(t)};typeof process<"u"&&process.platform==="win32"&&Oh();Ki.exports=gc;gc.default=gc;Ki.exports.isPathValid=Wm;jn(Ki.exports,Symbol.for("setupWindows"),Oh)});var kh=F(It=>{"use strict";var Hm=It&&It.__createBinding||(Object.create?(function(r,e,t,n){n===void 0&&(n=t);var s=Object.getOwnPropertyDescriptor(e,t);(!s||("get"in s?!e.__esModule:s.writable||s.configurable))&&(s={enumerable:!0,get:function(){return e[t]}}),Object.defineProperty(r,n,s)}):(function(r,e,t,n){n===void 0&&(n=t),r[n]=e[t]})),Vm=It&&It.__setModuleDefault||(Object.create?(function(r,e){Object.defineProperty(r,"default",{enumerable:!0,value:e})}):function(r,e){r.default=e}),Ch=It&&It.__importStar||(function(){var r=function(e){return r=Object.getOwnPropertyNames||function(t){var n=[];for(var s in t)Object.prototype.hasOwnProperty.call(t,s)&&(n[n.length]=s);return n},r(e)};return function(e){if(e&&e.__esModule)return e;var t={};if(e!=null)for(var n=r(e),s=0;s<n.length;s++)n[s]!=="default"&&Hm(t,e,n[s]);return Vm(t,e),t}})(),Km=It&&It.__importDefault||function(r){return r&&r.__esModule?r:{default:r}};Object.defineProperty(It,"__esModule",{value:!0});It.FileListService=void 0;var xs=Ch(require("path")),mc=Ch(require("fs/promises")),$m=Km(_c()),yc=Kr(),zm=["node_modules",".pnpm","vendor",".git","dist","build","out",".next",".nuxt",".output",".cache",".turbo",".idea",".vscode",".DS_Store","Thumbs.db"],Ec=class{ignoreFilter;workspaceRoot;onResponseCallback=null;logger;constructor(e,t){this.logger=e,this.workspaceRoot=t,this.ignoreFilter=(0,$m.default)(),this.ignoreFilter.add(zm),this.workspaceRoot&&this.loadGitignore(),this.logger.info("FileListService initialized",t||"null")}async loadGitignore(){if(!this.workspaceRoot)return;let e=xs.join(this.workspaceRoot,".gitignore");try{let t=await mc.readFile(e,"utf-8");this.ignoreFilter.add(t)}catch{}}onResponse(e){this.onResponseCallback=e}async handleListRequest(e){if(!this.workspaceRoot){this.sendResponse({requestId:e.requestId,path:e.path,entries:[],error:"No workspace root"});return}try{let t=this.resolvePath(e.path),n=await this.listDirectory(t,e.path);this.sendResponse({requestId:e.requestId,path:e.path,entries:n})}catch(t){this.logger.error("Failed to list directory",String(t)),this.sendResponse({requestId:e.requestId,path:e.path,entries:[],error:t instanceof Error?t.message:"Unknown error"})}}async listDirectory(e,t){let n=await mc.readdir(e,{withFileTypes:!0}),s=[];for(let i of n){let a=t==="."||t===""?i.name:xs.join(t,i.name);if(this.shouldHide(a,i.isDirectory()))continue;let f=xs.join(e,i.name),u={name:i.name,path:a,type:i.isDirectory()?yc.FileEntryType.DIRECTORY:yc.FileEntryType.FILE};if(!i.isDirectory())try{let d=await mc.stat(f);u.size=d.size,u.modified=d.mtime.toISOString()}catch{}s.push(u)}return s.sort((i,a)=>i.type!==a.type?i.type===yc.FileEntryType.DIRECTORY?-1:1:i.name.localeCompare(a.name))}shouldHide(e,t){let n=e.split(xs.sep).join("/"),s=t?`${n}/`:n;return this.ignoreFilter.ignores(s)}resolvePath(e){if(!this.workspaceRoot)throw new Error("No workspace root");if(e==="."||e==="")return this.workspaceRoot;let t=xs.join(this.workspaceRoot,e);if(!t.startsWith(this.workspaceRoot))throw new Error("Path outside workspace");return t}sendResponse(e){this.onResponseCallback?.(e)}dispose(){this.onResponseCallback=null}};It.FileListService=Ec});var Rh=F(er=>{"use strict";var Gm=er&&er.__createBinding||(Object.create?(function(r,e,t,n){n===void 0&&(n=t);var s=Object.getOwnPropertyDescriptor(e,t);(!s||("get"in s?!e.__esModule:s.writable||s.configurable))&&(s={enumerable:!0,get:function(){return e[t]}}),Object.defineProperty(r,n,s)}):(function(r,e,t,n){n===void 0&&(n=t),r[n]=e[t]})),Ym=er&&er.__setModuleDefault||(Object.create?(function(r,e){Object.defineProperty(r,"default",{enumerable:!0,value:e})}):function(r,e){r.default=e}),Ph=er&&er.__importStar||(function(){var r=function(e){return r=Object.getOwnPropertyNames||function(t){var n=[];for(var s in t)Object.prototype.hasOwnProperty.call(t,s)&&(n[n.length]=s);return n},r(e)};return function(e){if(e&&e.__esModule)return e;var t={};if(e!=null)for(var n=r(e),s=0;s<n.length;s++)n[s]!=="default"&&Gm(t,e,n[s]);return Ym(t,e),t}})();Object.defineProperty(er,"__esModule",{value:!0});er.FileTrackerService=void 0;var wc=Ph(require("path")),sn=Ph(require("fs/promises")),Xm=require("child_process"),Jm=require("util"),Bt=Kr(),xc=(0,Jm.promisify)(Xm.exec),vc={toolStart:/⏺\s*(Write|Edit|NotebookEdit)\s*\(\s*(?:file_path|notebook_path)\s*=\s*"([^"]+)"/,toolSuccess:/[✓✔]\s*(?:Wrote|Edited|Updated|Created)\s+([^\s\n]+)/,toolError:/[✗✘]\s*(?:Failed|Error)/i},bc=class{trackedFiles=new Map;pendingToolCalls=new Map;outputBuffers=new Map;workspaceRoot;onFileChangedCallback=null;onFileViewTransferCallback=null;logger;constructor(e,t){this.logger=e,this.workspaceRoot=t}onFileChanged(e){this.onFileChangedCallback=e}onFileViewTransfer(e){this.onFileViewTransferCallback=e}async processOutput(e,t){let n=this.outputBuffers.get(e)||"";n+=t,n.length>10240&&(n=n.slice(-10240)),this.outputBuffers.set(e,n);try{await this.parseToolCalls(e,n)}catch(s){this.logger.error("Error parsing tool calls",s)}}async parseToolCalls(e,t){let n=this.stripAnsi(t),s=n.match(vc.toolStart);if(s){let a=s[1],f=s[2],u=`${a}_${Date.now()}_${f}`;this.pendingToolCalls.has(u)||await this.handleToolStart(e,u,a,{file_path:f})}let i=n.match(vc.toolSuccess);if(i){let a=i[1];for(let[f,u]of this.pendingToolCalls)if(u.filePath===a||a.endsWith(u.filePath)||u.filePath.endsWith(a)){await this.handleToolEnd(e,f,u.toolName,"success");break}}if(vc.toolError.test(n))for(let[a,f]of this.pendingToolCalls)await this.handleToolEnd(e,a,f.toolName,"error")}stripAnsi(e){return e.replace(/\x1b\[[0-9;?]*[a-zA-Z]/g,"").replace(/\x1b\][^\x07]*\x07/g,"").replace(/\x1b[()][AB012]/g,"").replace(/\x1b[=>]/g,"").replace(/\x1b[78DMEHc]/g,"")}async handleToolStart(e,t,n,s){if(!this.isFileModifyingTool(n))return;let i=this.extractFilePath(n,s);if(!i)return;let a=this.resolveFilePath(i),f={toolId:t,toolName:n,filePath:i,timestamp:new Date().toISOString()};this.pendingToolCalls.set(t,f);let u;try{u=await sn.readFile(a,"utf-8")}catch{u=void 0}let d={path:i,changeType:u===void 0?Bt.FileChangeType.CREATE:Bt.FileChangeType.MODIFY,toolName:n,toolId:t,timestamp:f.timestamp,previousContent:u},g=this.trackedFiles.get(e)||[];g.push(d),this.trackedFiles.set(e,g)}async handleToolEnd(e,t,n,s){if(!this.isFileModifyingTool(n)||!this.pendingToolCalls.get(t))return;if(this.pendingToolCalls.delete(t),s==="error"){let g=this.trackedFiles.get(e)||[],_=g.findIndex(y=>y.toolId===t);_!==-1&&g.splice(_,1);return}let f=(this.trackedFiles.get(e)||[]).find(g=>g.toolId===t);if(!f)return;let u=this.resolveFilePath(f.path);try{let g=await sn.stat(u);f.size=g.size}catch{f.changeType=Bt.FileChangeType.DELETE,f.size=void 0}let d={path:f.path,changeType:f.changeType,timestamp:new Date().toISOString(),source:"tool-call",toolName:f.toolName,toolId:f.toolId,size:f.size};this.onFileChangedCallback?.(e,d)}async handleViewRequest(e,t){let n=this.resolveFilePath(t.path),s=this.getViewableMimeType(t.path);if(s&&this.onFileViewTransferCallback){try{let a=await sn.readFile(n),f={requestId:t.requestId,path:t.path,viewType:"content",mimeType:s};this.onFileViewTransferCallback(e,Buffer.from(a),f)}catch(a){let f={requestId:t.requestId,path:t.path,viewType:"content",mimeType:s,error:a instanceof Error?a.message:"Unknown error"};this.onFileViewTransferCallback(e,Buffer.alloc(0),f)}return}let i;try{t.type===Bt.FileViewType.CONTENT?i=await this.getFileContent(t,n):i=await this.getFileDiff(e,t,n)}catch(a){i={requestId:t.requestId,path:t.path,type:t.type,error:a instanceof Error?a.message:"Unknown error"}}if(this.onFileViewTransferCallback){let a={requestId:t.requestId,path:t.path,viewType:i.type===Bt.FileViewType.CONTENT?"content":"diff",language:i.language,truncated:i.truncated,error:i.error},f=Buffer.from(i.content||"","utf-8");this.onFileViewTransferCallback(e,f,a)}}getViewableMimeType(e){let t=e.split(".").pop()?.toLowerCase();return{png:"image/png",jpg:"image/jpeg",jpeg:"image/jpeg",gif:"image/gif",webp:"image/webp",svg:"image/svg+xml",pdf:"application/pdf"}[t||""]||null}async getFileContent(e,t){let n=e.maxSize||1048576,s=await sn.stat(t),i=await sn.readFile(t,"utf-8"),a=!1,f=i;return i.length>n&&(f=i.slice(0,n),a=!0),{requestId:e.requestId,path:e.path,type:Bt.FileViewType.CONTENT,content:f,language:(0,Bt.getLanguageFromPath)(e.path),size:s.size,truncated:a}}async getFileDiff(e,t,n){let s=t.diffBase||Bt.DiffBase.GIT,i;return s===Bt.DiffBase.GIT?i=await this.getGitDiff(n):i=await this.getPreviousDiff(e,t.path,n),{requestId:t.requestId,path:t.path,type:Bt.FileViewType.DIFF,content:i,language:"diff"}}async getGitDiff(e){if(!this.workspaceRoot)throw new Error("No workspace root");try{let{stdout:t}=await xc(`git diff --cached -- "${e}"`,{cwd:this.workspaceRoot});if(t.trim())return t;let{stdout:n}=await xc(`git diff -- "${e}"`,{cwd:this.workspaceRoot});if(n.trim())return n;let{stdout:s}=await xc(`git status --porcelain -- "${e}"`,{cwd:this.workspaceRoot});if(s.startsWith("??")||s.startsWith("A ")){let a=(await sn.readFile(e,"utf-8")).split(`
|
|
29
|
-
`),f=
|
|
30
|
-
`)}return"(no changes)"}catch{throw new Error("Git not available")}}async getPreviousDiff(e,t,n){let a=(this.trackedFiles.get(e)||[]).find(d=>d.path===t&&d.previousContent!==void 0)?.previousContent||"",f;try{f=await
|
|
31
|
-
`)}clearTerminal(e){this.trackedFiles.delete(e),this.outputBuffers.delete(e)}getChangedFiles(e){return(this.trackedFiles.get(e)||[]).map(n=>({path:n.path,changeType:n.changeType,timestamp:n.timestamp,source:"tool-call",toolName:n.toolName,toolId:n.toolId,size:n.size}))}isFileModifyingTool(e){return["Write","Edit","NotebookEdit"].includes(e)}extractFilePath(e,t){return t?e==="Write"||e==="Edit"?t.file_path||null:e==="NotebookEdit"&&t.notebook_path||null:null}resolveFilePath(e){return wc.isAbsolute(e)?e:this.workspaceRoot?wc.join(this.workspaceRoot,e):e}dispose(){this.trackedFiles.clear(),this.pendingToolCalls.clear(),this.onFileChangedCallback=null,this.onFileViewTransferCallback=null}};er.FileTrackerService=bc});var Ah=F(ct=>{"use strict";Object.defineProperty(ct,"__esModule",{value:!0});ct.FileTrackerService=ct.FileListService=ct.FileTransferService=ct.WebSocketService=ct.StatusDetector=ct.AuthService=ct.CryptoService=void 0;var Zm=nu();Object.defineProperty(ct,"CryptoService",{enumerable:!0,get:function(){return Zm.CryptoService}});var Qm=su();Object.defineProperty(ct,"AuthService",{enumerable:!0,get:function(){return Qm.AuthService}});var ey=iu();Object.defineProperty(ct,"StatusDetector",{enumerable:!0,get:function(){return ey.StatusDetector}});var ty=_h();Object.defineProperty(ct,"WebSocketService",{enumerable:!0,get:function(){return ty.WebSocketService}});var ry=yh();Object.defineProperty(ct,"FileTransferService",{enumerable:!0,get:function(){return ry.FileTransferService}});var ny=kh();Object.defineProperty(ct,"FileListService",{enumerable:!0,get:function(){return ny.FileListService}});var sy=Rh();Object.defineProperty(ct,"FileTrackerService",{enumerable:!0,get:function(){return sy.FileTrackerService}})});var $i=F($e=>{"use strict";Object.defineProperty($e,"__esModule",{value:!0});$e.FileTrackerService=$e.FileListService=$e.FileTransferService=$e.WebSocketService=$e.StatusDetector=$e.AuthService=$e.CryptoService=$e.getWsUrl=$e.getApiUrl=$e.CircularBuffer=void 0;var Sc=Tf();Object.defineProperty($e,"CircularBuffer",{enumerable:!0,get:function(){return Sc.CircularBuffer}});Object.defineProperty($e,"getApiUrl",{enumerable:!0,get:function(){return Sc.getApiUrl}});Object.defineProperty($e,"getWsUrl",{enumerable:!0,get:function(){return Sc.getWsUrl}});var on=Ah();Object.defineProperty($e,"CryptoService",{enumerable:!0,get:function(){return on.CryptoService}});Object.defineProperty($e,"AuthService",{enumerable:!0,get:function(){return on.AuthService}});Object.defineProperty($e,"StatusDetector",{enumerable:!0,get:function(){return on.StatusDetector}});Object.defineProperty($e,"WebSocketService",{enumerable:!0,get:function(){return on.WebSocketService}});Object.defineProperty($e,"FileTransferService",{enumerable:!0,get:function(){return on.FileTransferService}});Object.defineProperty($e,"FileListService",{enumerable:!0,get:function(){return on.FileListService}});Object.defineProperty($e,"FileTrackerService",{enumerable:!0,get:function(){return on.FileTrackerService}})});var sr=we(require("fs")),Ns=we(require("path"));var Wc=we(require("os")),Hc=we(require("path")),As=we(require("fs"));function Is(){let r=Hc.join(Wc.homedir(),".termiq");return As.existsSync(r)||As.mkdirSync(r,{recursive:!0,mode:448}),r}var $n=class{filePath;data={};constructor(){this.filePath=Ns.join(Is(),"credentials"),this.load()}async get(e){return this.data[e]}async set(e,t){this.data[e]=t,this.save()}async delete(e){delete this.data[e],this.save()}load(){try{if(sr.existsSync(this.filePath)){let e=sr.readFileSync(this.filePath,"utf-8");this.data=JSON.parse(e)}}catch{this.data={}}}save(){let e=Ns.dirname(this.filePath);sr.existsSync(e)||sr.mkdirSync(e,{recursive:!0,mode:448}),sr.writeFileSync(this.filePath,JSON.stringify(this.data,null,2),{mode:384})}};var ir=we(require("fs")),Ls=we(require("path"));var wd={serverUrl:"https://termiq.io",agentName:""},zn=class{config;filePath;constructor(e){this.filePath=Ls.join(Is(),"config.json"),this.config={...wd,...this.loadFromFile(),...e}}getServerUrl(){return this.config.serverUrl}getAgentName(){return this.config.agentName}isAutoConnect(){return!0}async setAgentName(e){this.config.agentName=e,this.saveToFile()}loadFromFile(){try{if(ir.existsSync(this.filePath)){let e=ir.readFileSync(this.filePath,"utf-8");return JSON.parse(e)}}catch{}return{}}saveToFile(){let e=Ls.dirname(this.filePath);ir.existsSync(e)||ir.mkdirSync(e,{recursive:!0,mode:448}),ir.writeFileSync(this.filePath,JSON.stringify(this.config,null,2))}};var Gn=class{verbose;constructor(e=!1){this.verbose=e}info(e,...t){this.verbose&&process.stderr.write(`[info] ${e} ${t.length?JSON.stringify(t):""}
|
|
32
|
-
`)}warn(e,...t){process.stderr.write(`[warn] ${e} ${t.length?JSON.stringify(t):""}
|
|
33
|
-
`)}
|
|
34
|
-
|
|
35
|
-
`)}};var
|
|
26
|
+
`+t)}function nn(r,e,t,n,s,i){if(r.listenerCount("wsClientError")){let a=new Error(s);Error.captureStackTrace(a,nn),r.emit("wsClientError",a,t,e)}else hs(t,n,s,i)}});var Sl=D((Aw,bl)=>{"use strict";var gr=ki();gr.createWebSocketStream=dl();gr.Server=xl();gr.Receiver=sa();gr.Sender=aa();gr.WebSocket=gr;gr.WebSocketServer=gr.Server;bl.exports=gr});var ya=D(Lr=>{"use strict";var e_=Lr&&Lr.__importDefault||function(r){return r&&r.__esModule?r:{default:r}};Object.defineProperty(Lr,"__esModule",{value:!0});Lr.WS=Lr.BaseWS=void 0;var t_=ss(),Tl=Jr(),r_=bn(),_a=Xr(),n_=e_(Pt()),s_=(0,n_.default)("engine.io-client:websocket"),Ol=typeof navigator<"u"&&typeof navigator.product=="string"&&navigator.product.toLowerCase()==="reactnative",Ri=class extends t_.Transport{get name(){return"websocket"}doOpen(){let e=this.uri(),t=this.opts.protocols,n=Ol?{}:(0,Tl.pick)(this.opts,"agent","perMessageDeflate","pfx","key","passphrase","cert","ca","ciphers","rejectUnauthorized","localAddress","protocolVersion","origin","maxPayload","family","checkServerIdentity");this.opts.extraHeaders&&(n.headers=this.opts.extraHeaders);try{this.ws=this.createSocket(e,t,n)}catch(s){return this.emitReserved("error",s)}this.ws.binaryType=this.socket.binaryType,this.addEventListeners()}addEventListeners(){this.ws.onopen=()=>{this.opts.autoUnref&&this.ws._socket.unref(),this.onOpen()},this.ws.onclose=e=>this.onClose({description:"websocket connection closed",context:e}),this.ws.onmessage=e=>this.onData(e.data),this.ws.onerror=e=>this.onError("websocket error",e)}write(e){this.writable=!1;for(let t=0;t<e.length;t++){let n=e[t],s=t===e.length-1;(0,r_.encodePacket)(n,this.supportsBinary,i=>{try{this.doWrite(n,i)}catch{s_("websocket closed before onclose event")}s&&(0,_a.nextTick)(()=>{this.writable=!0,this.emitReserved("drain")},this.setTimeoutFn)})}}doClose(){typeof this.ws<"u"&&(this.ws.onerror=()=>{},this.ws.close(),this.ws=null)}uri(){let e=this.opts.secure?"wss":"ws",t=this.query||{};return this.opts.timestampRequests&&(t[this.opts.timestampParam]=(0,Tl.randomString)()),this.supportsBinary||(t.b64=1),this.createUri(e,t)}};Lr.BaseWS=Ri;var ga=_a.globalThisShim.WebSocket||_a.globalThisShim.MozWebSocket,ma=class extends Ri{createSocket(e,t,n){return Ol?new ga(e,t,n):t?new ga(e,t):new ga(e)}doWrite(e,t){this.ws.send(t)}};Lr.WS=ma});var wa=D(Zt=>{"use strict";var i_=Zt&&Zt.__createBinding||(Object.create?(function(r,e,t,n){n===void 0&&(n=t);var s=Object.getOwnPropertyDescriptor(e,t);(!s||("get"in s?!e.__esModule:s.writable||s.configurable))&&(s={enumerable:!0,get:function(){return e[t]}}),Object.defineProperty(r,n,s)}):(function(r,e,t,n){n===void 0&&(n=t),r[n]=e[t]})),o_=Zt&&Zt.__setModuleDefault||(Object.create?(function(r,e){Object.defineProperty(r,"default",{enumerable:!0,value:e})}):function(r,e){r.default=e}),a_=Zt&&Zt.__importStar||function(r){if(r&&r.__esModule)return r;var e={};if(r!=null)for(var t in r)t!=="default"&&Object.prototype.hasOwnProperty.call(r,t)&&i_(e,r,t);return o_(e,r),e};Object.defineProperty(Zt,"__esModule",{value:!0});Zt.WS=void 0;var c_=a_(Sl()),f_=ya(),Ea=class extends f_.BaseWS{createSocket(e,t,n){var s;if(!((s=this.socket)===null||s===void 0)&&s._cookieJar){n.headers=n.headers||{},n.headers.cookie=typeof n.headers.cookie=="string"?[n.headers.cookie]:n.headers.cookie||[];for(let[i,a]of this.socket._cookieJar.cookies)n.headers.cookie.push(`${i}=${a.value}`)}return new c_.WebSocket(e,t,n)}doWrite(e,t){let n={};e.options&&(n.compress=e.options.compress),this.opts.perMessageDeflate&&(typeof t=="string"?Buffer.byteLength(t):t.length)<this.opts.perMessageDeflate.threshold&&(n.compress=!1),this.ws.send(t,n)}};Zt.WS=Ea});var xa=D(Fn=>{"use strict";var u_=Fn&&Fn.__importDefault||function(r){return r&&r.__esModule?r:{default:r}};Object.defineProperty(Fn,"__esModule",{value:!0});Fn.WT=void 0;var l_=ss(),h_=Xr(),Cl=bn(),d_=u_(Pt()),ds=(0,d_.default)("engine.io-client:webtransport"),va=class extends l_.Transport{get name(){return"webtransport"}doOpen(){try{this._transport=new WebTransport(this.createUri("https"),this.opts.transportOptions[this.name])}catch(e){return this.emitReserved("error",e)}this._transport.closed.then(()=>{ds("transport closed gracefully"),this.onClose()}).catch(e=>{ds("transport closed due to %s",e),this.onError("webtransport error",e)}),this._transport.ready.then(()=>{this._transport.createBidirectionalStream().then(e=>{let t=(0,Cl.createPacketDecoderStream)(Number.MAX_SAFE_INTEGER,this.socket.binaryType),n=e.readable.pipeThrough(t).getReader(),s=(0,Cl.createPacketEncoderStream)();s.readable.pipeTo(e.writable),this._writer=s.writable.getWriter();let i=()=>{n.read().then(({done:f,value:u})=>{if(f){ds("session is closed");return}ds("received chunk: %o",u),this.onPacket(u),i()}).catch(f=>{ds("an error occurred while reading: %s",f)})};i();let a={type:"open"};this.query.sid&&(a.data=`{"sid":"${this.query.sid}"}`),this._writer.write(a).then(()=>this.onOpen())})})}write(e){this.writable=!1;for(let t=0;t<e.length;t++){let n=e[t],s=t===e.length-1;this._writer.write(n).then(()=>{s&&(0,h_.nextTick)(()=>{this.writable=!0,this.emitReserved("drain")},this.setTimeoutFn)})}}doClose(){var e;(e=this._transport)===null||e===void 0||e.close()}};Fn.WT=va});var ba=D(Ai=>{"use strict";Object.defineProperty(Ai,"__esModule",{value:!0});Ai.transports=void 0;var p_=zo(),g_=wa(),__=xa();Ai.transports={websocket:g_.WS,webtransport:__.WT,polling:p_.XHR}});var Ta=D(Sa=>{"use strict";Object.defineProperty(Sa,"__esModule",{value:!0});Sa.parse=E_;var m_=/^(?:(?![^:@\/?#]+:[^:@\/]*@)(http|https|ws|wss):\/\/)?((?:(([^:@\/?#]*)(?::([^:@\/?#]*))?)?@)?((?:[a-f0-9]{0,4}:){2,7}[a-f0-9]{0,4}|[^:\/?#]*)(?::(\d*))?)(((\/(?:[^?#](?![^?#\/]*\.[^?#\/.]+(?:[?#]|$)))*\/?)?([^?#\/]*))(?:\?([^#]*))?(?:#(.*))?)/,y_=["source","protocol","authority","userInfo","user","password","host","port","relative","path","directory","file","query","anchor"];function E_(r){if(r.length>8e3)throw"URI too long";let e=r,t=r.indexOf("["),n=r.indexOf("]");t!=-1&&n!=-1&&(r=r.substring(0,t)+r.substring(t,n).replace(/:/g,";")+r.substring(n,r.length));let s=m_.exec(r||""),i={},a=14;for(;a--;)i[y_[a]]=s[a]||"";return t!=-1&&n!=-1&&(i.source=e,i.host=i.host.substring(1,i.host.length-1).replace(/;/g,":"),i.authority=i.authority.replace("[","").replace("]","").replace(/;/g,":"),i.ipv6uri=!0),i.pathNames=w_(i,i.path),i.queryKey=v_(i,i.query),i}function w_(r,e){let t=/\/{2,9}/g,n=e.replace(t,"/").split("/");return(e.slice(0,1)=="/"||e.length===0)&&n.splice(0,1),e.slice(-1)=="/"&&n.splice(n.length-1,1),n}function v_(r,e){let t={};return e.replace(/(?:^|&)([^&=]*)=?([^&]*)/g,function(n,s,i){s&&(t[s]=i)}),t}});var Pa=D(Qt=>{"use strict";var x_=Qt&&Qt.__importDefault||function(r){return r&&r.__esModule?r:{default:r}};Object.defineProperty(Qt,"__esModule",{value:!0});Qt.Socket=Qt.SocketWithUpgrade=Qt.SocketWithoutUpgrade=void 0;var b_=ba(),kl=Jr(),S_=Do(),Pl=Ta(),T_=Yr(),Rl=bn(),Oa=Xr(),O_=x_(Pt()),Ne=(0,O_.default)("engine.io-client:socket"),Ca=typeof addEventListener=="function"&&typeof removeEventListener=="function",ps=[];Ca&&addEventListener("offline",()=>{Ne("closing %d connection(s) because the network was lost",ps.length),ps.forEach(r=>r())},!1);var sn=class r extends T_.Emitter{constructor(e,t){if(super(),this.binaryType=Oa.defaultBinaryType,this.writeBuffer=[],this._prevBufferLen=0,this._pingInterval=-1,this._pingTimeout=-1,this._maxPayload=-1,this._pingTimeoutTime=1/0,e&&typeof e=="object"&&(t=e,e=null),e){let n=(0,Pl.parse)(e);t.hostname=n.host,t.secure=n.protocol==="https"||n.protocol==="wss",t.port=n.port,n.query&&(t.query=n.query)}else t.host&&(t.hostname=(0,Pl.parse)(t.host).host);(0,kl.installTimerFunctions)(this,t),this.secure=t.secure!=null?t.secure:typeof location<"u"&&location.protocol==="https:",t.hostname&&!t.port&&(t.port=this.secure?"443":"80"),this.hostname=t.hostname||(typeof location<"u"?location.hostname:"localhost"),this.port=t.port||(typeof location<"u"&&location.port?location.port:this.secure?"443":"80"),this.transports=[],this._transportsByName={},t.transports.forEach(n=>{let s=n.prototype.name;this.transports.push(s),this._transportsByName[s]=n}),this.opts=Object.assign({path:"/engine.io",agent:!1,withCredentials:!1,upgrade:!0,timestampParam:"t",rememberUpgrade:!1,addTrailingSlash:!0,rejectUnauthorized:!0,perMessageDeflate:{threshold:1024},transportOptions:{},closeOnBeforeunload:!1},t),this.opts.path=this.opts.path.replace(/\/$/,"")+(this.opts.addTrailingSlash?"/":""),typeof this.opts.query=="string"&&(this.opts.query=(0,S_.decode)(this.opts.query)),Ca&&(this.opts.closeOnBeforeunload&&(this._beforeunloadEventListener=()=>{this.transport&&(this.transport.removeAllListeners(),this.transport.close())},addEventListener("beforeunload",this._beforeunloadEventListener,!1)),this.hostname!=="localhost"&&(Ne("adding listener for the 'offline' event"),this._offlineEventListener=()=>{this._onClose("transport close",{description:"network connection lost"})},ps.push(this._offlineEventListener))),this.opts.withCredentials&&(this._cookieJar=(0,Oa.createCookieJar)()),this._open()}createTransport(e){Ne('creating transport "%s"',e);let t=Object.assign({},this.opts.query);t.EIO=Rl.protocol,t.transport=e,this.id&&(t.sid=this.id);let n=Object.assign({},this.opts,{query:t,socket:this,hostname:this.hostname,secure:this.secure,port:this.port},this.opts.transportOptions[e]);return Ne("options: %j",n),new this._transportsByName[e](n)}_open(){if(this.transports.length===0){this.setTimeoutFn(()=>{this.emitReserved("error","No transports available")},0);return}let e=this.opts.rememberUpgrade&&r.priorWebsocketSuccess&&this.transports.indexOf("websocket")!==-1?"websocket":this.transports[0];this.readyState="opening";let t=this.createTransport(e);t.open(),this.setTransport(t)}setTransport(e){Ne("setting transport %s",e.name),this.transport&&(Ne("clearing existing transport %s",this.transport.name),this.transport.removeAllListeners()),this.transport=e,e.on("drain",this._onDrain.bind(this)).on("packet",this._onPacket.bind(this)).on("error",this._onError.bind(this)).on("close",t=>this._onClose("transport close",t))}onOpen(){Ne("socket open"),this.readyState="open",r.priorWebsocketSuccess=this.transport.name==="websocket",this.emitReserved("open"),this.flush()}_onPacket(e){if(this.readyState==="opening"||this.readyState==="open"||this.readyState==="closing")switch(Ne('socket receive: type "%s", data "%s"',e.type,e.data),this.emitReserved("packet",e),this.emitReserved("heartbeat"),e.type){case"open":this.onHandshake(JSON.parse(e.data));break;case"ping":this._sendPacket("pong"),this.emitReserved("ping"),this.emitReserved("pong"),this._resetPingTimeout();break;case"error":let t=new Error("server error");t.code=e.data,this._onError(t);break;case"message":this.emitReserved("data",e.data),this.emitReserved("message",e.data);break}else Ne('packet received with socket readyState "%s"',this.readyState)}onHandshake(e){this.emitReserved("handshake",e),this.id=e.sid,this.transport.query.sid=e.sid,this._pingInterval=e.pingInterval,this._pingTimeout=e.pingTimeout,this._maxPayload=e.maxPayload,this.onOpen(),this.readyState!=="closed"&&this._resetPingTimeout()}_resetPingTimeout(){this.clearTimeoutFn(this._pingTimeoutTimer);let e=this._pingInterval+this._pingTimeout;this._pingTimeoutTime=Date.now()+e,this._pingTimeoutTimer=this.setTimeoutFn(()=>{this._onClose("ping timeout")},e),this.opts.autoUnref&&this._pingTimeoutTimer.unref()}_onDrain(){this.writeBuffer.splice(0,this._prevBufferLen),this._prevBufferLen=0,this.writeBuffer.length===0?this.emitReserved("drain"):this.flush()}flush(){if(this.readyState!=="closed"&&this.transport.writable&&!this.upgrading&&this.writeBuffer.length){let e=this._getWritablePackets();Ne("flushing %d packets in socket",e.length),this.transport.send(e),this._prevBufferLen=e.length,this.emitReserved("flush")}}_getWritablePackets(){if(!(this._maxPayload&&this.transport.name==="polling"&&this.writeBuffer.length>1))return this.writeBuffer;let t=1;for(let n=0;n<this.writeBuffer.length;n++){let s=this.writeBuffer[n].data;if(s&&(t+=(0,kl.byteLength)(s)),n>0&&t>this._maxPayload)return Ne("only send %d out of %d packets",n,this.writeBuffer.length),this.writeBuffer.slice(0,n);t+=2}return Ne("payload size is %d (max: %d)",t,this._maxPayload),this.writeBuffer}_hasPingExpired(){if(!this._pingTimeoutTime)return!0;let e=Date.now()>this._pingTimeoutTime;return e&&(Ne("throttled timer detected, scheduling connection close"),this._pingTimeoutTime=0,(0,Oa.nextTick)(()=>{this._onClose("ping timeout")},this.setTimeoutFn)),e}write(e,t,n){return this._sendPacket("message",e,t,n),this}send(e,t,n){return this._sendPacket("message",e,t,n),this}_sendPacket(e,t,n,s){if(typeof t=="function"&&(s=t,t=void 0),typeof n=="function"&&(s=n,n=null),this.readyState==="closing"||this.readyState==="closed")return;n=n||{},n.compress=n.compress!==!1;let i={type:e,data:t,options:n};this.emitReserved("packetCreate",i),this.writeBuffer.push(i),s&&this.once("flush",s),this.flush()}close(){let e=()=>{this._onClose("forced close"),Ne("socket closing - telling transport to close"),this.transport.close()},t=()=>{this.off("upgrade",t),this.off("upgradeError",t),e()},n=()=>{this.once("upgrade",t),this.once("upgradeError",t)};return(this.readyState==="opening"||this.readyState==="open")&&(this.readyState="closing",this.writeBuffer.length?this.once("drain",()=>{this.upgrading?n():e()}):this.upgrading?n():e()),this}_onError(e){if(Ne("socket error %j",e),r.priorWebsocketSuccess=!1,this.opts.tryAllTransports&&this.transports.length>1&&this.readyState==="opening")return Ne("trying next transport"),this.transports.shift(),this._open();this.emitReserved("error",e),this._onClose("transport error",e)}_onClose(e,t){if(this.readyState==="opening"||this.readyState==="open"||this.readyState==="closing"){if(Ne('socket close with reason: "%s"',e),this.clearTimeoutFn(this._pingTimeoutTimer),this.transport.removeAllListeners("close"),this.transport.close(),this.transport.removeAllListeners(),Ca&&(this._beforeunloadEventListener&&removeEventListener("beforeunload",this._beforeunloadEventListener,!1),this._offlineEventListener)){let n=ps.indexOf(this._offlineEventListener);n!==-1&&(Ne("removing listener for the 'offline' event"),ps.splice(n,1))}this.readyState="closed",this.id=null,this.emitReserved("close",e,t),this.writeBuffer=[],this._prevBufferLen=0}}};Qt.SocketWithoutUpgrade=sn;sn.protocol=Rl.protocol;var Ii=class extends sn{constructor(){super(...arguments),this._upgrades=[]}onOpen(){if(super.onOpen(),this.readyState==="open"&&this.opts.upgrade){Ne("starting upgrade probes");for(let e=0;e<this._upgrades.length;e++)this._probe(this._upgrades[e])}}_probe(e){Ne('probing transport "%s"',e);let t=this.createTransport(e),n=!1;sn.priorWebsocketSuccess=!1;let s=()=>{n||(Ne('probe transport "%s" opened',e),t.send([{type:"ping",data:"probe"}]),t.once("packet",_=>{if(!n)if(_.type==="pong"&&_.data==="probe"){if(Ne('probe transport "%s" pong',e),this.upgrading=!0,this.emitReserved("upgrading",t),!t)return;sn.priorWebsocketSuccess=t.name==="websocket",Ne('pausing current transport "%s"',this.transport.name),this.transport.pause(()=>{n||this.readyState!=="closed"&&(Ne("changing transport and sending upgrade packet"),g(),this.setTransport(t),t.send([{type:"upgrade"}]),this.emitReserved("upgrade",t),t=null,this.upgrading=!1,this.flush())})}else{Ne('probe transport "%s" failed',e);let y=new Error("probe error");y.transport=t.name,this.emitReserved("upgradeError",y)}}))};function i(){n||(n=!0,g(),t.close(),t=null)}let a=_=>{let y=new Error("probe error: "+_);y.transport=t.name,i(),Ne('probe transport "%s" failed because of error: %s',e,_),this.emitReserved("upgradeError",y)};function f(){a("transport closed")}function u(){a("socket closed")}function d(_){t&&_.name!==t.name&&(Ne('"%s" works - aborting "%s"',_.name,t.name),i())}let g=()=>{t.removeListener("open",s),t.removeListener("error",a),t.removeListener("close",f),this.off("close",u),this.off("upgrading",d)};t.once("open",s),t.once("error",a),t.once("close",f),this.once("close",u),this.once("upgrading",d),this._upgrades.indexOf("webtransport")!==-1&&e!=="webtransport"?this.setTimeoutFn(()=>{n||t.open()},200):t.open()}onHandshake(e){this._upgrades=this._filterUpgrades(e.upgrades),super.onHandshake(e)}_filterUpgrades(e){let t=[];for(let n=0;n<e.length;n++)~this.transports.indexOf(e[n])&&t.push(e[n]);return t}};Qt.SocketWithUpgrade=Ii;var ka=class extends Ii{constructor(e,t={}){let n=typeof e=="object"?e:t;(!n.transports||n.transports&&typeof n.transports[0]=="string")&&(n.transports=(n.transports||["polling","websocket","webtransport"]).map(s=>b_.transports[s]).filter(s=>!!s)),super(e,n)}};Qt.Socket=ka});var Al=D(Li=>{"use strict";Object.defineProperty(Li,"__esModule",{value:!0});Li.Fetch=void 0;var C_=Wo(),Ra=class extends C_.Polling{doPoll(){this._fetch().then(e=>{if(!e.ok)return this.onError("fetch read error",e.status,e);e.text().then(t=>this.onData(t))}).catch(e=>{this.onError("fetch read error",e)})}doWrite(e,t){this._fetch(e).then(n=>{if(!n.ok)return this.onError("fetch write error",n.status,n);t()}).catch(n=>{this.onError("fetch write error",n)})}_fetch(e){var t;let n=e!==void 0,s=new Headers(this.opts.extraHeaders);return n&&s.set("content-type","text/plain;charset=UTF-8"),(t=this.socket._cookieJar)===null||t===void 0||t.appendCookies(s),fetch(this.uri(),{method:n?"POST":"GET",body:n?e:null,headers:s,credentials:this.opts.withCredentials?"include":"omit"}).then(i=>{var a;return(a=this.socket._cookieJar)===null||a===void 0||a.parseCookies(i.headers.getSetCookie()),i})}};Li.Fetch=Ra});var Ni=D(Se=>{"use strict";Object.defineProperty(Se,"__esModule",{value:!0});Se.WebTransport=Se.WebSocket=Se.NodeWebSocket=Se.XHR=Se.NodeXHR=Se.Fetch=Se.nextTick=Se.parse=Se.installTimerFunctions=Se.transports=Se.TransportError=Se.Transport=Se.protocol=Se.SocketWithUpgrade=Se.SocketWithoutUpgrade=Se.Socket=void 0;var Il=Pa();Object.defineProperty(Se,"Socket",{enumerable:!0,get:function(){return Il.Socket}});var Ll=Pa();Object.defineProperty(Se,"SocketWithoutUpgrade",{enumerable:!0,get:function(){return Ll.SocketWithoutUpgrade}});Object.defineProperty(Se,"SocketWithUpgrade",{enumerable:!0,get:function(){return Ll.SocketWithUpgrade}});Se.protocol=Il.Socket.protocol;var Nl=ss();Object.defineProperty(Se,"Transport",{enumerable:!0,get:function(){return Nl.Transport}});Object.defineProperty(Se,"TransportError",{enumerable:!0,get:function(){return Nl.TransportError}});var k_=ba();Object.defineProperty(Se,"transports",{enumerable:!0,get:function(){return k_.transports}});var P_=Jr();Object.defineProperty(Se,"installTimerFunctions",{enumerable:!0,get:function(){return P_.installTimerFunctions}});var R_=Ta();Object.defineProperty(Se,"parse",{enumerable:!0,get:function(){return R_.parse}});var A_=Xr();Object.defineProperty(Se,"nextTick",{enumerable:!0,get:function(){return A_.nextTick}});var I_=Al();Object.defineProperty(Se,"Fetch",{enumerable:!0,get:function(){return I_.Fetch}});var L_=zo();Object.defineProperty(Se,"NodeXHR",{enumerable:!0,get:function(){return L_.XHR}});var N_=Ko();Object.defineProperty(Se,"XHR",{enumerable:!0,get:function(){return N_.XHR}});var D_=wa();Object.defineProperty(Se,"NodeWebSocket",{enumerable:!0,get:function(){return D_.WS}});var F_=ya();Object.defineProperty(Se,"WebSocket",{enumerable:!0,get:function(){return F_.WS}});var M_=xa();Object.defineProperty(Se,"WebTransport",{enumerable:!0,get:function(){return M_.WT}})});var Fl=D(gs=>{"use strict";var B_=gs&&gs.__importDefault||function(r){return r&&r.__esModule?r:{default:r}};Object.defineProperty(gs,"__esModule",{value:!0});gs.url=q_;var j_=Ni(),U_=B_(Pt()),Dl=(0,U_.default)("socket.io-client:url");function q_(r,e="",t){let n=r;t=t||typeof location<"u"&&location,r==null&&(r=t.protocol+"//"+t.host),typeof r=="string"&&(r.charAt(0)==="/"&&(r.charAt(1)==="/"?r=t.protocol+r:r=t.host+r),/^(https?|wss?):\/\//.test(r)||(Dl("protocol-less url %s",r),typeof t<"u"?r=t.protocol+"//"+r:r="https://"+r),Dl("parse %s",r),n=(0,j_.parse)(r)),n.port||(/^(http|ws)$/.test(n.protocol)?n.port="80":/^(http|ws)s$/.test(n.protocol)&&(n.port="443")),n.path=n.path||"/";let i=n.host.indexOf(":")!==-1?"["+n.host+"]":n.host;return n.id=n.protocol+"://"+i+":"+n.port+e,n.href=n.protocol+"://"+i+(t&&t.port===n.port?"":":"+n.port),n}});var Aa=D(Fi=>{"use strict";Object.defineProperty(Fi,"__esModule",{value:!0});Fi.isBinary=Bl;Fi.hasBinary=Di;var W_=typeof ArrayBuffer=="function",H_=r=>typeof ArrayBuffer.isView=="function"?ArrayBuffer.isView(r):r.buffer instanceof ArrayBuffer,Ml=Object.prototype.toString,V_=typeof Blob=="function"||typeof Blob<"u"&&Ml.call(Blob)==="[object BlobConstructor]",K_=typeof File=="function"||typeof File<"u"&&Ml.call(File)==="[object FileConstructor]";function Bl(r){return W_&&(r instanceof ArrayBuffer||H_(r))||V_&&r instanceof Blob||K_&&r instanceof File}function Di(r,e){if(!r||typeof r!="object")return!1;if(Array.isArray(r)){for(let t=0,n=r.length;t<n;t++)if(Di(r[t]))return!0;return!1}if(Bl(r))return!0;if(r.toJSON&&typeof r.toJSON=="function"&&arguments.length===1)return Di(r.toJSON(),!0);for(let t in r)if(Object.prototype.hasOwnProperty.call(r,t)&&Di(r[t]))return!0;return!1}});var jl=D(Mi=>{"use strict";Object.defineProperty(Mi,"__esModule",{value:!0});Mi.deconstructPacket=z_;Mi.reconstructPacket=G_;var $_=Aa();function z_(r){let e=[],t=r.data,n=r;return n.data=Ia(t,e),n.attachments=e.length,{packet:n,buffers:e}}function Ia(r,e){if(!r)return r;if((0,$_.isBinary)(r)){let t={_placeholder:!0,num:e.length};return e.push(r),t}else if(Array.isArray(r)){let t=new Array(r.length);for(let n=0;n<r.length;n++)t[n]=Ia(r[n],e);return t}else if(typeof r=="object"&&!(r instanceof Date)){let t={};for(let n in r)Object.prototype.hasOwnProperty.call(r,n)&&(t[n]=Ia(r[n],e));return t}return r}function G_(r,e){return r.data=La(r.data,e),delete r.attachments,r}function La(r,e){if(!r)return r;if(r&&r._placeholder===!0){if(typeof r.num=="number"&&r.num>=0&&r.num<e.length)return e[r.num];throw new Error("illegal attachments")}else if(Array.isArray(r))for(let t=0;t<r.length;t++)r[t]=La(r[t],e);else if(typeof r=="object")for(let t in r)Object.prototype.hasOwnProperty.call(r,t)&&(r[t]=La(r[t],e));return r}});var ji=D(Mt=>{"use strict";Object.defineProperty(Mt,"__esModule",{value:!0});Mt.Decoder=Mt.Encoder=Mt.PacketType=Mt.protocol=void 0;Mt.isPacketValid=tm;var Y_=Yr(),Ul=jl(),ql=Aa(),X_=Pt(),Na=(0,X_.default)("socket.io-parser"),Wl=["connect","connect_error","disconnect","disconnecting","newListener","removeListener"];Mt.protocol=5;var Ie;(function(r){r[r.CONNECT=0]="CONNECT",r[r.DISCONNECT=1]="DISCONNECT",r[r.EVENT=2]="EVENT",r[r.ACK=3]="ACK",r[r.CONNECT_ERROR=4]="CONNECT_ERROR",r[r.BINARY_EVENT=5]="BINARY_EVENT",r[r.BINARY_ACK=6]="BINARY_ACK"})(Ie||(Mt.PacketType=Ie={}));var Da=class{constructor(e){this.replacer=e}encode(e){return Na("encoding packet %j",e),(e.type===Ie.EVENT||e.type===Ie.ACK)&&(0,ql.hasBinary)(e)?this.encodeAsBinary({type:e.type===Ie.EVENT?Ie.BINARY_EVENT:Ie.BINARY_ACK,nsp:e.nsp,data:e.data,id:e.id}):[this.encodeAsString(e)]}encodeAsString(e){let t=""+e.type;return(e.type===Ie.BINARY_EVENT||e.type===Ie.BINARY_ACK)&&(t+=e.attachments+"-"),e.nsp&&e.nsp!=="/"&&(t+=e.nsp+","),e.id!=null&&(t+=e.id),e.data!=null&&(t+=JSON.stringify(e.data,this.replacer)),Na("encoded %j as %s",e,t),t}encodeAsBinary(e){let t=(0,Ul.deconstructPacket)(e),n=this.encodeAsString(t.packet),s=t.buffers;return s.unshift(n),s}};Mt.Encoder=Da;var Fa=class r extends Y_.Emitter{constructor(e){super(),this.reviver=e}add(e){let t;if(typeof e=="string"){if(this.reconstructor)throw new Error("got plaintext data when reconstructing a packet");t=this.decodeString(e);let n=t.type===Ie.BINARY_EVENT;n||t.type===Ie.BINARY_ACK?(t.type=n?Ie.EVENT:Ie.ACK,this.reconstructor=new Ma(t),t.attachments===0&&super.emitReserved("decoded",t)):super.emitReserved("decoded",t)}else if((0,ql.isBinary)(e)||e.base64)if(this.reconstructor)t=this.reconstructor.takeBinaryData(e),t&&(this.reconstructor=null,super.emitReserved("decoded",t));else throw new Error("got binary data when not reconstructing a packet");else throw new Error("Unknown type: "+e)}decodeString(e){let t=0,n={type:Number(e.charAt(0))};if(Ie[n.type]===void 0)throw new Error("unknown packet type "+n.type);if(n.type===Ie.BINARY_EVENT||n.type===Ie.BINARY_ACK){let i=t+1;for(;e.charAt(++t)!=="-"&&t!=e.length;);let a=e.substring(i,t);if(a!=Number(a)||e.charAt(t)!=="-")throw new Error("Illegal attachments");n.attachments=Number(a)}if(e.charAt(t+1)==="/"){let i=t+1;for(;++t&&!(e.charAt(t)===","||t===e.length););n.nsp=e.substring(i,t)}else n.nsp="/";let s=e.charAt(t+1);if(s!==""&&Number(s)==s){let i=t+1;for(;++t;){let a=e.charAt(t);if(a==null||Number(a)!=a){--t;break}if(t===e.length)break}n.id=Number(e.substring(i,t+1))}if(e.charAt(++t)){let i=this.tryParse(e.substr(t));if(r.isPayloadValid(n.type,i))n.data=i;else throw new Error("invalid payload")}return Na("decoded %s as %j",e,n),n}tryParse(e){try{return JSON.parse(e,this.reviver)}catch{return!1}}static isPayloadValid(e,t){switch(e){case Ie.CONNECT:return Bi(t);case Ie.DISCONNECT:return t===void 0;case Ie.CONNECT_ERROR:return typeof t=="string"||Bi(t);case Ie.EVENT:case Ie.BINARY_EVENT:return Array.isArray(t)&&(typeof t[0]=="number"||typeof t[0]=="string"&&Wl.indexOf(t[0])===-1);case Ie.ACK:case Ie.BINARY_ACK:return Array.isArray(t)}}destroy(){this.reconstructor&&(this.reconstructor.finishedReconstruction(),this.reconstructor=null)}};Mt.Decoder=Fa;var Ma=class{constructor(e){this.packet=e,this.buffers=[],this.reconPack=e}takeBinaryData(e){if(this.buffers.push(e),this.buffers.length===this.reconPack.attachments){let t=(0,Ul.reconstructPacket)(this.reconPack,this.buffers);return this.finishedReconstruction(),t}return null}finishedReconstruction(){this.reconPack=null,this.buffers=[]}};function J_(r){return typeof r=="string"}var Z_=Number.isInteger||function(r){return typeof r=="number"&&isFinite(r)&&Math.floor(r)===r};function Q_(r){return r===void 0||Z_(r)}function Bi(r){return Object.prototype.toString.call(r)==="[object Object]"}function em(r,e){switch(r){case Ie.CONNECT:return e===void 0||Bi(e);case Ie.DISCONNECT:return e===void 0;case Ie.EVENT:return Array.isArray(e)&&(typeof e[0]=="number"||typeof e[0]=="string"&&Wl.indexOf(e[0])===-1);case Ie.ACK:return Array.isArray(e);case Ie.CONNECT_ERROR:return typeof e=="string"||Bi(e);default:return!1}}function tm(r){return J_(r.nsp)&&Q_(r.id)&&em(r.type,r.data)}});var ja=D(Ba=>{"use strict";Object.defineProperty(Ba,"__esModule",{value:!0});Ba.on=rm;function rm(r,e,t){return r.on(e,t),function(){r.off(e,t)}}});var qa=D(Mn=>{"use strict";var nm=Mn&&Mn.__importDefault||function(r){return r&&r.__esModule?r:{default:r}};Object.defineProperty(Mn,"__esModule",{value:!0});Mn.Socket=void 0;var Bt=ji(),Ui=ja(),sm=Yr(),im=nm(Pt()),Xe=(0,im.default)("socket.io-client:socket"),om=Object.freeze({connect:1,connect_error:1,disconnect:1,disconnecting:1,newListener:1,removeListener:1}),Ua=class extends sm.Emitter{constructor(e,t,n){super(),this.connected=!1,this.recovered=!1,this.receiveBuffer=[],this.sendBuffer=[],this._queue=[],this._queueSeq=0,this.ids=0,this.acks={},this.flags={},this.io=e,this.nsp=t,n&&n.auth&&(this.auth=n.auth),this._opts=Object.assign({},n),this.io._autoConnect&&this.open()}get disconnected(){return!this.connected}subEvents(){if(this.subs)return;let e=this.io;this.subs=[(0,Ui.on)(e,"open",this.onopen.bind(this)),(0,Ui.on)(e,"packet",this.onpacket.bind(this)),(0,Ui.on)(e,"error",this.onerror.bind(this)),(0,Ui.on)(e,"close",this.onclose.bind(this))]}get active(){return!!this.subs}connect(){return this.connected?this:(this.subEvents(),this.io._reconnecting||this.io.open(),this.io._readyState==="open"&&this.onopen(),this)}open(){return this.connect()}send(...e){return e.unshift("message"),this.emit.apply(this,e),this}emit(e,...t){var n,s,i;if(om.hasOwnProperty(e))throw new Error('"'+e.toString()+'" is a reserved event name');if(t.unshift(e),this._opts.retries&&!this.flags.fromQueue&&!this.flags.volatile)return this._addToQueue(t),this;let a={type:Bt.PacketType.EVENT,data:t};if(a.options={},a.options.compress=this.flags.compress!==!1,typeof t[t.length-1]=="function"){let g=this.ids++;Xe("emitting packet with ack id %d",g);let _=t.pop();this._registerAckCallback(g,_),a.id=g}let f=(s=(n=this.io.engine)===null||n===void 0?void 0:n.transport)===null||s===void 0?void 0:s.writable,u=this.connected&&!(!((i=this.io.engine)===null||i===void 0)&&i._hasPingExpired());return this.flags.volatile&&!f?Xe("discard packet as the transport is not currently writable"):u?(this.notifyOutgoingListeners(a),this.packet(a)):this.sendBuffer.push(a),this.flags={},this}_registerAckCallback(e,t){var n;let s=(n=this.flags.timeout)!==null&&n!==void 0?n:this._opts.ackTimeout;if(s===void 0){this.acks[e]=t;return}let i=this.io.setTimeoutFn(()=>{delete this.acks[e];for(let f=0;f<this.sendBuffer.length;f++)this.sendBuffer[f].id===e&&(Xe("removing packet with ack id %d from the buffer",e),this.sendBuffer.splice(f,1));Xe("event with ack id %d has timed out after %d ms",e,s),t.call(this,new Error("operation has timed out"))},s),a=(...f)=>{this.io.clearTimeoutFn(i),t.apply(this,f)};a.withError=!0,this.acks[e]=a}emitWithAck(e,...t){return new Promise((n,s)=>{let i=(a,f)=>a?s(a):n(f);i.withError=!0,t.push(i),this.emit(e,...t)})}_addToQueue(e){let t;typeof e[e.length-1]=="function"&&(t=e.pop());let n={id:this._queueSeq++,tryCount:0,pending:!1,args:e,flags:Object.assign({fromQueue:!0},this.flags)};e.push((s,...i)=>n!==this._queue[0]?Xe("packet [%d] already acknowledged",n.id):(s!==null?n.tryCount>this._opts.retries&&(Xe("packet [%d] is discarded after %d tries",n.id,n.tryCount),this._queue.shift(),t&&t(s)):(Xe("packet [%d] was successfully sent",n.id),this._queue.shift(),t&&t(null,...i)),n.pending=!1,this._drainQueue())),this._queue.push(n),this._drainQueue()}_drainQueue(e=!1){if(Xe("draining queue"),!this.connected||this._queue.length===0)return;let t=this._queue[0];if(t.pending&&!e){Xe("packet [%d] has already been sent and is waiting for an ack",t.id);return}t.pending=!0,t.tryCount++,Xe("sending packet [%d] (try n\xB0%d)",t.id,t.tryCount),this.flags=t.flags,this.emit.apply(this,t.args)}packet(e){e.nsp=this.nsp,this.io._packet(e)}onopen(){Xe("transport is open - connecting"),typeof this.auth=="function"?this.auth(e=>{this._sendConnectPacket(e)}):this._sendConnectPacket(this.auth)}_sendConnectPacket(e){this.packet({type:Bt.PacketType.CONNECT,data:this._pid?Object.assign({pid:this._pid,offset:this._lastOffset},e):e})}onerror(e){this.connected||this.emitReserved("connect_error",e)}onclose(e,t){Xe("close (%s)",e),this.connected=!1,delete this.id,this.emitReserved("disconnect",e,t),this._clearAcks()}_clearAcks(){Object.keys(this.acks).forEach(e=>{if(!this.sendBuffer.some(n=>String(n.id)===e)){let n=this.acks[e];delete this.acks[e],n.withError&&n.call(this,new Error("socket has been disconnected"))}})}onpacket(e){if(e.nsp===this.nsp)switch(e.type){case Bt.PacketType.CONNECT:e.data&&e.data.sid?this.onconnect(e.data.sid,e.data.pid):this.emitReserved("connect_error",new Error("It seems you are trying to reach a Socket.IO server in v2.x with a v3.x client, but they are not compatible (more information here: https://socket.io/docs/v3/migrating-from-2-x-to-3-0/)"));break;case Bt.PacketType.EVENT:case Bt.PacketType.BINARY_EVENT:this.onevent(e);break;case Bt.PacketType.ACK:case Bt.PacketType.BINARY_ACK:this.onack(e);break;case Bt.PacketType.DISCONNECT:this.ondisconnect();break;case Bt.PacketType.CONNECT_ERROR:this.destroy();let n=new Error(e.data.message);n.data=e.data.data,this.emitReserved("connect_error",n);break}}onevent(e){let t=e.data||[];Xe("emitting event %j",t),e.id!=null&&(Xe("attaching ack callback to event"),t.push(this.ack(e.id))),this.connected?this.emitEvent(t):this.receiveBuffer.push(Object.freeze(t))}emitEvent(e){if(this._anyListeners&&this._anyListeners.length){let t=this._anyListeners.slice();for(let n of t)n.apply(this,e)}super.emit.apply(this,e),this._pid&&e.length&&typeof e[e.length-1]=="string"&&(this._lastOffset=e[e.length-1])}ack(e){let t=this,n=!1;return function(...s){n||(n=!0,Xe("sending ack %j",s),t.packet({type:Bt.PacketType.ACK,id:e,data:s}))}}onack(e){let t=this.acks[e.id];if(typeof t!="function"){Xe("bad ack %s",e.id);return}delete this.acks[e.id],Xe("calling ack %s with %j",e.id,e.data),t.withError&&e.data.unshift(null),t.apply(this,e.data)}onconnect(e,t){Xe("socket connected with id %s",e),this.id=e,this.recovered=t&&this._pid===t,this._pid=t,this.connected=!0,this.emitBuffered(),this._drainQueue(!0),this.emitReserved("connect")}emitBuffered(){this.receiveBuffer.forEach(e=>this.emitEvent(e)),this.receiveBuffer=[],this.sendBuffer.forEach(e=>{this.notifyOutgoingListeners(e),this.packet(e)}),this.sendBuffer=[]}ondisconnect(){Xe("server disconnect (%s)",this.nsp),this.destroy(),this.onclose("io server disconnect")}destroy(){this.subs&&(this.subs.forEach(e=>e()),this.subs=void 0),this.io._destroy(this)}disconnect(){return this.connected&&(Xe("performing disconnect (%s)",this.nsp),this.packet({type:Bt.PacketType.DISCONNECT})),this.destroy(),this.connected&&this.onclose("io client disconnect"),this}close(){return this.disconnect()}compress(e){return this.flags.compress=e,this}get volatile(){return this.flags.volatile=!0,this}timeout(e){return this.flags.timeout=e,this}onAny(e){return this._anyListeners=this._anyListeners||[],this._anyListeners.push(e),this}prependAny(e){return this._anyListeners=this._anyListeners||[],this._anyListeners.unshift(e),this}offAny(e){if(!this._anyListeners)return this;if(e){let t=this._anyListeners;for(let n=0;n<t.length;n++)if(e===t[n])return t.splice(n,1),this}else this._anyListeners=[];return this}listenersAny(){return this._anyListeners||[]}onAnyOutgoing(e){return this._anyOutgoingListeners=this._anyOutgoingListeners||[],this._anyOutgoingListeners.push(e),this}prependAnyOutgoing(e){return this._anyOutgoingListeners=this._anyOutgoingListeners||[],this._anyOutgoingListeners.unshift(e),this}offAnyOutgoing(e){if(!this._anyOutgoingListeners)return this;if(e){let t=this._anyOutgoingListeners;for(let n=0;n<t.length;n++)if(e===t[n])return t.splice(n,1),this}else this._anyOutgoingListeners=[];return this}listenersAnyOutgoing(){return this._anyOutgoingListeners||[]}notifyOutgoingListeners(e){if(this._anyOutgoingListeners&&this._anyOutgoingListeners.length){let t=this._anyOutgoingListeners.slice();for(let n of t)n.apply(this,e.data)}}};Mn.Socket=Ua});var Hl=D(Wa=>{"use strict";Object.defineProperty(Wa,"__esModule",{value:!0});Wa.Backoff=Bn;function Bn(r){r=r||{},this.ms=r.min||100,this.max=r.max||1e4,this.factor=r.factor||2,this.jitter=r.jitter>0&&r.jitter<=1?r.jitter:0,this.attempts=0}Bn.prototype.duration=function(){var r=this.ms*Math.pow(this.factor,this.attempts++);if(this.jitter){var e=Math.random(),t=Math.floor(e*this.jitter*r);r=(Math.floor(e*10)&1)==0?r-t:r+t}return Math.min(r,this.max)|0};Bn.prototype.reset=function(){this.attempts=0};Bn.prototype.setMin=function(r){this.ms=r};Bn.prototype.setMax=function(r){this.max=r};Bn.prototype.setJitter=function(r){this.jitter=r}});var Vl=D(It=>{"use strict";var am=It&&It.__createBinding||(Object.create?(function(r,e,t,n){n===void 0&&(n=t);var s=Object.getOwnPropertyDescriptor(e,t);(!s||("get"in s?!e.__esModule:s.writable||s.configurable))&&(s={enumerable:!0,get:function(){return e[t]}}),Object.defineProperty(r,n,s)}):(function(r,e,t,n){n===void 0&&(n=t),r[n]=e[t]})),cm=It&&It.__setModuleDefault||(Object.create?(function(r,e){Object.defineProperty(r,"default",{enumerable:!0,value:e})}):function(r,e){r.default=e}),fm=It&&It.__importStar||function(r){if(r&&r.__esModule)return r;var e={};if(r!=null)for(var t in r)t!=="default"&&Object.prototype.hasOwnProperty.call(r,t)&&am(e,r,t);return cm(e,r),e},um=It&&It.__importDefault||function(r){return r&&r.__esModule?r:{default:r}};Object.defineProperty(It,"__esModule",{value:!0});It.Manager=void 0;var Ha=Ni(),lm=qa(),hm=fm(ji()),on=ja(),dm=Hl(),pm=Yr(),gm=um(Pt()),st=(0,gm.default)("socket.io-client:manager"),Va=class extends pm.Emitter{constructor(e,t){var n;super(),this.nsps={},this.subs=[],e&&typeof e=="object"&&(t=e,e=void 0),t=t||{},t.path=t.path||"/socket.io",this.opts=t,(0,Ha.installTimerFunctions)(this,t),this.reconnection(t.reconnection!==!1),this.reconnectionAttempts(t.reconnectionAttempts||1/0),this.reconnectionDelay(t.reconnectionDelay||1e3),this.reconnectionDelayMax(t.reconnectionDelayMax||5e3),this.randomizationFactor((n=t.randomizationFactor)!==null&&n!==void 0?n:.5),this.backoff=new dm.Backoff({min:this.reconnectionDelay(),max:this.reconnectionDelayMax(),jitter:this.randomizationFactor()}),this.timeout(t.timeout==null?2e4:t.timeout),this._readyState="closed",this.uri=e;let s=t.parser||hm;this.encoder=new s.Encoder,this.decoder=new s.Decoder,this._autoConnect=t.autoConnect!==!1,this._autoConnect&&this.open()}reconnection(e){return arguments.length?(this._reconnection=!!e,e||(this.skipReconnect=!0),this):this._reconnection}reconnectionAttempts(e){return e===void 0?this._reconnectionAttempts:(this._reconnectionAttempts=e,this)}reconnectionDelay(e){var t;return e===void 0?this._reconnectionDelay:(this._reconnectionDelay=e,(t=this.backoff)===null||t===void 0||t.setMin(e),this)}randomizationFactor(e){var t;return e===void 0?this._randomizationFactor:(this._randomizationFactor=e,(t=this.backoff)===null||t===void 0||t.setJitter(e),this)}reconnectionDelayMax(e){var t;return e===void 0?this._reconnectionDelayMax:(this._reconnectionDelayMax=e,(t=this.backoff)===null||t===void 0||t.setMax(e),this)}timeout(e){return arguments.length?(this._timeout=e,this):this._timeout}maybeReconnectOnOpen(){!this._reconnecting&&this._reconnection&&this.backoff.attempts===0&&this.reconnect()}open(e){if(st("readyState %s",this._readyState),~this._readyState.indexOf("open"))return this;st("opening %s",this.uri),this.engine=new Ha.Socket(this.uri,this.opts);let t=this.engine,n=this;this._readyState="opening",this.skipReconnect=!1;let s=(0,on.on)(t,"open",function(){n.onopen(),e&&e()}),i=f=>{st("error"),this.cleanup(),this._readyState="closed",this.emitReserved("error",f),e?e(f):this.maybeReconnectOnOpen()},a=(0,on.on)(t,"error",i);if(this._timeout!==!1){let f=this._timeout;st("connect attempt will timeout after %d",f);let u=this.setTimeoutFn(()=>{st("connect attempt timed out after %d",f),s(),i(new Error("timeout")),t.close()},f);this.opts.autoUnref&&u.unref(),this.subs.push(()=>{this.clearTimeoutFn(u)})}return this.subs.push(s),this.subs.push(a),this}connect(e){return this.open(e)}onopen(){st("open"),this.cleanup(),this._readyState="open",this.emitReserved("open");let e=this.engine;this.subs.push((0,on.on)(e,"ping",this.onping.bind(this)),(0,on.on)(e,"data",this.ondata.bind(this)),(0,on.on)(e,"error",this.onerror.bind(this)),(0,on.on)(e,"close",this.onclose.bind(this)),(0,on.on)(this.decoder,"decoded",this.ondecoded.bind(this)))}onping(){this.emitReserved("ping")}ondata(e){try{this.decoder.add(e)}catch(t){this.onclose("parse error",t)}}ondecoded(e){(0,Ha.nextTick)(()=>{this.emitReserved("packet",e)},this.setTimeoutFn)}onerror(e){st("error",e),this.emitReserved("error",e)}socket(e,t){let n=this.nsps[e];return n?this._autoConnect&&!n.active&&n.connect():(n=new lm.Socket(this,e,t),this.nsps[e]=n),n}_destroy(e){let t=Object.keys(this.nsps);for(let n of t)if(this.nsps[n].active){st("socket %s is still active, skipping close",n);return}this._close()}_packet(e){st("writing packet %j",e);let t=this.encoder.encode(e);for(let n=0;n<t.length;n++)this.engine.write(t[n],e.options)}cleanup(){st("cleanup"),this.subs.forEach(e=>e()),this.subs.length=0,this.decoder.destroy()}_close(){st("disconnect"),this.skipReconnect=!0,this._reconnecting=!1,this.onclose("forced close")}disconnect(){return this._close()}onclose(e,t){var n;st("closed due to %s",e),this.cleanup(),(n=this.engine)===null||n===void 0||n.close(),this.backoff.reset(),this._readyState="closed",this.emitReserved("close",e,t),this._reconnection&&!this.skipReconnect&&this.reconnect()}reconnect(){if(this._reconnecting||this.skipReconnect)return this;let e=this;if(this.backoff.attempts>=this._reconnectionAttempts)st("reconnect failed"),this.backoff.reset(),this.emitReserved("reconnect_failed"),this._reconnecting=!1;else{let t=this.backoff.duration();st("will wait %dms before reconnect attempt",t),this._reconnecting=!0;let n=this.setTimeoutFn(()=>{e.skipReconnect||(st("attempting reconnect"),this.emitReserved("reconnect_attempt",e.backoff.attempts),!e.skipReconnect&&e.open(s=>{s?(st("reconnect attempt error"),e._reconnecting=!1,e.reconnect(),this.emitReserved("reconnect_error",s)):(st("reconnect success"),e.onreconnect())}))},t);this.opts.autoUnref&&n.unref(),this.subs.push(()=>{this.clearTimeoutFn(n)})}}onreconnect(){let e=this.backoff.attempts;this._reconnecting=!1,this.backoff.reset(),this.emitReserved("reconnect",e)}};It.Manager=Va});var Gl=D((Me,zl)=>{"use strict";var _m=Me&&Me.__importDefault||function(r){return r&&r.__esModule?r:{default:r}};Object.defineProperty(Me,"__esModule",{value:!0});Me.WebTransport=Me.WebSocket=Me.NodeWebSocket=Me.XHR=Me.NodeXHR=Me.Fetch=Me.Socket=Me.Manager=Me.protocol=void 0;Me.io=an;Me.connect=an;Me.default=an;var mm=Fl(),qi=Vl();Object.defineProperty(Me,"Manager",{enumerable:!0,get:function(){return qi.Manager}});var $l=qa();Object.defineProperty(Me,"Socket",{enumerable:!0,get:function(){return $l.Socket}});var ym=_m(Pt()),Kl=(0,ym.default)("socket.io-client"),_s={};function an(r,e){typeof r=="object"&&(e=r,r=void 0),e=e||{};let t=(0,mm.url)(r,e.path||"/socket.io"),n=t.source,s=t.id,i=t.path,a=_s[s]&&i in _s[s].nsps,f=e.forceNew||e["force new connection"]||e.multiplex===!1||a,u;return f?(Kl("ignoring socket cache for %s",n),u=new qi.Manager(n,e)):(_s[s]||(Kl("new io instance for %s",n),_s[s]=new qi.Manager(n,e)),u=_s[s]),t.query&&!e.query&&(e.query=t.queryKey),u.socket(t.path,e)}Object.assign(an,{Manager:qi.Manager,Socket:$l.Socket,io:an,connect:an});var Em=ji();Object.defineProperty(Me,"protocol",{enumerable:!0,get:function(){return Em.protocol}});var jn=Ni();Object.defineProperty(Me,"Fetch",{enumerable:!0,get:function(){return jn.Fetch}});Object.defineProperty(Me,"NodeXHR",{enumerable:!0,get:function(){return jn.NodeXHR}});Object.defineProperty(Me,"XHR",{enumerable:!0,get:function(){return jn.XHR}});Object.defineProperty(Me,"NodeWebSocket",{enumerable:!0,get:function(){return jn.NodeWebSocket}});Object.defineProperty(Me,"WebSocket",{enumerable:!0,get:function(){return jn.WebSocket}});Object.defineProperty(Me,"WebTransport",{enumerable:!0,get:function(){return jn.WebTransport}});zl.exports=an});var Jl=D(Wi=>{"use strict";Object.defineProperty(Wi,"__esModule",{value:!0});Wi.WebSocketService=void 0;var wm=Gl(),Yl=Gr(),Xl=Ws(),Ka=class{authService;cryptoService;config;logger;notification;deviceId;platform;socket=null;inputHandler=null;createTerminalHandler=null;getBufferHandler=null;redrawHandler=null;resizeHandler=null;reconnectHandlers=[];authFailureHandler=null;fileViewRequestHandler=null;fileListRequestHandler=null;fileDownloadRequestHandler=null;statusChangeHandler=null;agentNameSyncHandler=null;agentId=null;hasConnectedOnce=!1;isRemoteRename=!1;negotiatedCapabilities=[];HEARTBEAT_INTERVAL=3e4;HEARTBEAT_TIMEOUT=1e4;heartbeatTimer=null;pongTimer=null;lastPongTime=0;isManualDisconnect=!1;reconnectAttempts=0;reconnectTimer=null;networkCheckTimer=null;isOnline=!0;lastNetworkCheck=0;rekeyingTerminals=new Set;outputBuffer=new Map;OUTPUT_BUFFER_MAX_SIZE=1e3;RECONNECT_BASE_DELAY=1e3;RECONNECT_MAX_DELAY=3e4;RECONNECT_JITTER=.2;NETWORK_CHECK_INTERVAL=5e3;constructor(e,t,n,s,i,a,f="vscode"){this.authService=e,this.cryptoService=t,this.config=n,this.logger=s,this.notification=i,this.deviceId=a,this.platform=f}async connect(){let e=await this.authService.getAccessToken();if(!e)throw new Error("No access token available");this.isManualDisconnect=!1,this.stopReconnect(),this.reconnectAttempts=0,this.agentId=await this.authService.getAgentId();let t=(0,Xl.getWsUrl)(this.config);this.logger.info("Connecting to WebSocket",t),this.statusChangeHandler?.("connecting");let n=await this.cryptoService.getPublicKey();return new Promise((s,i)=>{this.socket=(0,wm.io)(`${t}/agent`,{auth:{token:e,protocolVersion:Yl.PROTOCOL_VERSION,deviceId:this.deviceId,platform:this.platform,capabilities:Yl.DEFAULT_CLIENT_CAPABILITIES,publicKey:n},transports:["websocket"],reconnection:!1}),this.socket.on("connect",()=>{if(this.logger.info("WebSocket connected"),this.reconnectAttempts=0,this.statusChangeHandler?.("connected",this.agentId??void 0),this.startHeartbeat(),this.cryptoService.cleanupAllStaleSessions(),this.hasConnectedOnce){this.logger.info("Reconnected - triggering workspace re-registration");for(let a of this.reconnectHandlers)a()}else this.hasConnectedOnce=!0,s()}),this.socket.on("error",a=>{this.logger.error(`Server error [${a.code}]: ${a.message}`),a.code==="E401"&&(this.logger.warn("Auth failure (E401)"),this.authFailureHandler?.())}),this.socket.on("disconnect",a=>{this.logger.warn("WebSocket disconnected",a),this.stopHeartbeat(),this.statusChangeHandler?.("disconnected"),this.isManualDisconnect||(a==="transport close"?(this.logger.info("Transport close - attempting immediate reconnect"),this.attemptReconnect(!0)):this.scheduleReconnect())}),this.socket.on("protocol:info",a=>{this.logger.info("Protocol info received",a.protocolVersion),this.negotiatedCapabilities=a.negotiatedCapabilities,a.agentName&&this.config.getAgentName()!==a.agentName&&(this.isRemoteRename=!0,this.config.setAgentName(a.agentName).then(()=>{setTimeout(()=>{this.isRemoteRename=!1},100)}),this.agentNameSyncHandler?.(a.agentName),this.logger.info("Agent name synced from server",a.agentName))}),this.socket.on("pong",()=>{this.lastPongTime=Date.now(),this.clearPongTimeout(),this.logger.debug("Heartbeat pong received")}),this.socket.on("connect_error",a=>{this.logger.error("WebSocket connection error",a),this.statusChangeHandler?.("error"),this.hasConnectedOnce||i(a),this.scheduleReconnect()}),this.socket.on("terminal:input",a=>{this.handleTerminalInput(a)}),this.socket.on("crypto:keyExchange",async(a,f)=>{this.logger.info("Received key exchange request",a.terminalId,a.sessionId),this.rekeyingTerminals.add(a.terminalId),this.outputBuffer.set(a.terminalId,[]);try{if(await this.cryptoService.handleKeyExchange(a.terminalId,a.clientPublicKey,a.sessionId)){let d=await this.cryptoService.getPublicKey();f?.({success:!0,agentPublicKey:d||void 0}),this.flushOutputBuffer(a.terminalId)}else f?.({success:!1,error:"Key exchange failed"})}catch(u){this.logger.error("Key exchange error",u),f?.({success:!1,error:String(u)})}finally{this.rekeyingTerminals.delete(a.terminalId),this.outputBuffer.delete(a.terminalId)}}),this.socket.on("crypto:sessionCleanup",a=>{this.cryptoService.removeSession(a.terminalId,a.sessionId)}),this.socket.on("agent:keyExchangeRequest",async a=>{try{let f=await this.cryptoService.handleAgentKeyExchange(a.clientPublicKey,a.sessionId),u={agentId:a.agentId,sessionId:a.sessionId,ok:f,error:f?void 0:"Key exchange failed"};this.socket?.emit("agent:keyExchangeAck",u)}catch(f){this.logger.error("Agent key exchange error",f);let u={agentId:a.agentId,sessionId:a.sessionId,ok:!1,error:String(f)};this.socket?.emit("agent:keyExchangeAck",u)}}),this.socket.on("agent:sessionEnd",a=>{this.cryptoService.removeAgentSession(a.sessionId)}),this.socket.on("agent:renamed",a=>{this.logger.info("Agent renamed from web client",a.name),this.isRemoteRename=!0,this.config.setAgentName(a.name).then(()=>{setTimeout(()=>{this.isRemoteRename=!1},100)}),this.agentNameSyncHandler?.(a.name)}),this.socket.on("terminal:createRequest",a=>{this.createTerminalHandler?.(a.name)}),this.socket.on("terminal:getBuffer",(a,f)=>{if(!this.getBufferHandler){f?.({success:!1,error:"Buffer handler not set"});return}let u=this.getBufferHandler(a.terminalId);if(u===null){f?.({success:!1,error:"Terminal not found"});return}let d=this.cryptoService.encryptOutput(a.terminalId,u);f?.(d?{success:!0,encrypted:d}:{success:!0,data:u}),this.redrawHandler?.(a.terminalId)}),this.socket.on("terminal:resize",a=>{this.resizeHandler?.(a.terminalId,a.cols,a.rows)}),this.socket.on("file:view",a=>{this.fileViewRequestHandler?.(a.terminalId,a.request)}),this.socket.on("file:list",a=>{this.fileListRequestHandler?.(a.terminalId,a.request)}),this.socket.on("file:download:request",a=>{this.fileDownloadRequestHandler?.(a.terminalId,a.path,a.requestId)})})}disconnect(){this.isManualDisconnect=!0,this.hasConnectedOnce=!1,this.stopReconnect(),this.stopHeartbeat(),this.cryptoService.clearAllSessions(),this.socket&&(this.logger.info("Disconnecting WebSocket"),this.socket.disconnect(),this.socket=null)}softDisconnect(){this.stopReconnect(),this.stopHeartbeat(),this.socket&&(this.logger.info("Soft disconnecting WebSocket (for reconnect)"),this.socket.disconnect(),this.socket=null)}getStatus(){return{connected:this.socket?.connected??!1,agentId:this.agentId}}onInput(e){this.inputHandler=e}onCreateTerminalRequest(e){this.createTerminalHandler=e}onGetBufferRequest(e){this.getBufferHandler=e}onRedrawRequest(e){this.redrawHandler=e}onResizeRequest(e){this.resizeHandler=e}onReconnect(e){this.reconnectHandlers.push(e)}onAuthFailure(e){this.authFailureHandler=e}onFileViewRequest(e){this.fileViewRequestHandler=e}onFileListRequest(e){this.fileListRequestHandler=e}onFileDownloadRequest(e){this.fileDownloadRequestHandler=e}onStatusChange(e){this.statusChangeHandler=e}onAgentNameSync(e){this.agentNameSyncHandler=e}async registerWorkspace(e){return this.emit("workspace:register",e)}async unregisterWorkspace(e){await this.emit("workspace:unregister",{instanceId:e})}async terminalCreated(e){return this.emit("terminal:created",e)}async terminalClosed(e){this.cryptoService.removeSession(e.terminalId),await this.emit("terminal:closed",e)}terminalNotFound(e){this.socket?.emit("terminal:notFound",{terminalId:e})}sendOutput(e,t,n){if(!this.socket?.connected)return;if(this.rekeyingTerminals.has(t)){let a=this.outputBuffer.get(t);a&&a.length<this.OUTPUT_BUFFER_MAX_SIZE&&a.push({instanceId:e,data:n});return}let s=this.cryptoService.encryptOutput(t,n),i={instanceId:e,terminalId:t,...s?{encrypted:s}:{data:n}};this.socket?.emit("terminal:output",i)}flushOutputBuffer(e){let t=this.outputBuffer.get(e);if(!(!t||t.length===0)){this.logger.info("Flushing output buffer after rekey",e,String(t.length));for(let{instanceId:n,data:s}of t){let i=this.cryptoService.encryptOutput(e,s),a={instanceId:n,terminalId:e,...i?{encrypted:i}:{data:s}};this.socket?.emit("terminal:output",a)}}}async updateStatus(e){await this.emit("terminal:status",e)}sendTerminalEvent(e,t,n){let s={instanceId:e,terminalId:t,event:n};this.socket?.emit("terminal:event",s)}hasCapability(e){return this.negotiatedCapabilities.includes(e)}sendFileChangedEvent(e,t,n){let s={instanceId:e,terminalId:t,event:n};this.socket?.emit("file:changed",s)}sendFileListResponse(e,t){let n={instanceId:e,response:t};this.socket?.emit("file:list:response",n)}sendAgentRename(e){this.socket?.emit("agent:rename",{name:e})}isRemoteRenameInProgress(){return this.isRemoteRename}getSocket(){return this.socket}emit(e,t){return new Promise((n,s)=>{if(!this.socket?.connected){s(new Error("WebSocket not connected"));return}this.socket.emit(e,t,i=>{i.success?n(i):s(new Error(i.error||"Unknown error"))})})}startHeartbeat(){this.stopHeartbeat(),this.lastPongTime=Date.now(),this.heartbeatTimer=setInterval(()=>{if(!this.socket?.connected){this.stopHeartbeat();return}if(Date.now()-this.lastPongTime>this.HEARTBEAT_INTERVAL+this.HEARTBEAT_TIMEOUT){this.logger.warn("Heartbeat timeout"),this.socket.disconnect();return}this.socket.emit("ping"),this.pongTimer=setTimeout(()=>{this.logger.warn("Pong timeout - server not responding"),this.statusChangeHandler?.("error")},this.HEARTBEAT_TIMEOUT)},this.HEARTBEAT_INTERVAL)}stopHeartbeat(){this.heartbeatTimer&&(clearInterval(this.heartbeatTimer),this.heartbeatTimer=null),this.clearPongTimeout()}clearPongTimeout(){this.pongTimer&&(clearTimeout(this.pongTimer),this.pongTimer=null)}handleTerminalInput(e){let t;if(e.encrypted){let n=this.cryptoService.decryptInput(e.terminalId,e.encrypted);if(!n){this.logger.error("Failed to decrypt terminal input",e.terminalId);return}t=n}else if(e.data)t=Buffer.from(e.data,"base64").toString("utf8");else{this.logger.error("Invalid terminal input payload");return}this.inputHandler?.(e.terminalId,t,e.dbTerminalId)}hasE2ESession(e){return this.cryptoService.hasSession(e)}getReconnectDelay(){let e=Math.min(this.RECONNECT_BASE_DELAY*Math.pow(2,this.reconnectAttempts),this.RECONNECT_MAX_DELAY),t=1+(Math.random()*2-1)*this.RECONNECT_JITTER;return Math.floor(e*t)}scheduleReconnect(){if(this.isManualDisconnect)return;this.stopReconnect();let e=this.getReconnectDelay();if(this.logger.info("Scheduling reconnect",String(this.reconnectAttempts+1),"delay:",String(e)),!this.isOnline){this.statusChangeHandler?.("disconnected"),this.startNetworkCheck();return}this.statusChangeHandler?.("connecting"),this.reconnectTimer=setTimeout(()=>{this.attemptReconnect()},e)}async attemptReconnect(e=!1){if(this.isManualDisconnect||this.socket?.connected)return;let t=await this.authService.hasValidToken();if(!t){if(this.logger.info("Access token expired, attempting refresh"),!await this.authService.refreshAccessToken()){this.logger.info("Token refresh failed, stopping reconnect"),this.stopReconnect(),this.statusChangeHandler?.("disconnected"),this.notification.warn("Session expired. Please log in again."),this.authFailureHandler?.();return}t=!0}this.reconnectAttempts++;try{if(this.socket&&(this.socket.disconnect(),this.socket=null),!e&&!await this.checkNetwork()){this.isOnline=!1,this.scheduleReconnect();return}this.isOnline=!0,await this.connect(),this.reconnectAttempts=0}catch(n){this.logger.warn("Reconnect failed",n),this.statusChangeHandler?.("error"),this.scheduleReconnect()}}stopReconnect(){this.reconnectTimer&&(clearTimeout(this.reconnectTimer),this.reconnectTimer=null),this.stopNetworkCheck()}async checkNetwork(){let e=Date.now();if(e-this.lastNetworkCheck<1e3)return this.isOnline;this.lastNetworkCheck=e;try{let t=`${(0,Xl.getApiUrl)(this.config)}/health`,n=new AbortController,s=setTimeout(()=>n.abort(),5e3),i=await fetch(t,{method:"GET",signal:n.signal});return clearTimeout(s),this.logger.debug("Network check OK",String(i.status)),!0}catch{return this.logger.debug("Network check failed (offline)"),!1}}startNetworkCheck(){this.stopNetworkCheck(),this.networkCheckTimer=setInterval(async()=>{if(this.isManualDisconnect){this.stopNetworkCheck();return}if(this.socket?.connected){this.stopNetworkCheck();return}let e=await this.checkNetwork();e&&!this.isOnline?(this.logger.info("Network restored! Triggering immediate reconnect"),this.isOnline=!0,this.stopNetworkCheck(),this.reconnectAttempts=0,this.attemptReconnect()):e&&this.isOnline?(this.stopNetworkCheck(),this.attemptReconnect()):e||(this.isOnline=!1)},this.NETWORK_CHECK_INTERVAL)}stopNetworkCheck(){this.networkCheckTimer&&(clearInterval(this.networkCheckTimer),this.networkCheckTimer=null)}};Wi.WebSocketService=Ka});var Ql=D(er=>{"use strict";var vm=er&&er.__createBinding||(Object.create?(function(r,e,t,n){n===void 0&&(n=t);var s=Object.getOwnPropertyDescriptor(e,t);(!s||("get"in s?!e.__esModule:s.writable||s.configurable))&&(s={enumerable:!0,get:function(){return e[t]}}),Object.defineProperty(r,n,s)}):(function(r,e,t,n){n===void 0&&(n=t),r[n]=e[t]})),xm=er&&er.__setModuleDefault||(Object.create?(function(r,e){Object.defineProperty(r,"default",{enumerable:!0,value:e})}):function(r,e){r.default=e}),za=er&&er.__importStar||(function(){var r=function(e){return r=Object.getOwnPropertyNames||function(t){var n=[];for(var s in t)Object.prototype.hasOwnProperty.call(t,s)&&(n[n.length]=s);return n},r(e)};return function(e){if(e&&e.__esModule)return e;var t={};if(e!=null)for(var n=r(e),s=0;s<n.length;s++)n[s]!=="default"&&vm(t,e,n[s]);return xm(t,e),t}})();Object.defineProperty(er,"__esModule",{value:!0});er.FileTransferService=void 0;var Hi=za(require("fs")),bm=za(require("path")),Zl=za(require("crypto")),Be=Gr(),$a=class{socket=null;activeTransfers=new Map;instanceId="";logger;fallbackDir;constructor(e,t="/tmp"){this.logger=e,this.fallbackDir=t}attach(e,t){this.socket=e,this.instanceId=t,this.setupEventHandlers(),this.logger.info("FileTransferService attached")}detach(){this.socket=null;for(let[e]of this.activeTransfers)this.cancelTransfer(e,"Disconnected");this.logger.info("FileTransferService detached")}async sendFile(e,t,n,s,i){let a=Hi.readFileSync(t),f=t.split("/").pop()||"file";return this.initAndSendChunks(e,a,f,{mimeType:this.getMimeType(f),requestId:i,onProgress:n,onComplete:s})}async sendBuffer(e,t,n,s,i){return this.initAndSendChunks(e,t,n,{mimeType:s,purpose:i?.purpose,viewMetadata:i?.viewMetadata,requestId:i?.requestId,onProgress:i?.onProgress,onComplete:i?.onComplete})}async initAndSendChunks(e,t,n,s){if(!this.socket)throw new Error("Socket not connected");let i=t.length,a=(0,Be.calculateTotalChunks)(i),f=this.calculateChecksum(t),u=Zl.randomUUID(),d={id:u,terminalId:e,filename:n,size:i,totalChunks:a,direction:Be.TransferDirection.DOWNLOAD,status:Be.TransferStatus.PENDING,deliveredChunks:new Set,pendingChunks:new Map,checksum:f,checksumAlgorithm:"sha256",onProgress:s.onProgress?(_,y)=>s.onProgress(u,_,y):void 0,onComplete:s.onComplete?(_,y)=>s.onComplete(u,_,y):void 0,ackTimeouts:new Map};d.chunks=[];for(let _=0;_<a;_++){let y=_*Be.CHUNK_SIZE,v=Math.min(y+Be.CHUNK_SIZE,i);d.chunks.push(t.subarray(y,v))}this.activeTransfers.set(u,d);let g={transferId:u,terminalId:e,filename:n,size:i,totalChunks:a,mimeType:s.mimeType||"application/octet-stream",checksum:f,direction:Be.TransferDirection.DOWNLOAD,instanceId:this.instanceId};return s.requestId&&(g.requestId=s.requestId),s.purpose&&(g.purpose=s.purpose),s.viewMetadata&&(g.viewMetadata=s.viewMetadata),new Promise((_,y)=>{this.socket.emit("file:init",g,v=>{v.accepted?(d.status=Be.TransferStatus.ACTIVE,this.startSendingChunks(u),_(u)):(this.activeTransfers.delete(u),y(new Error(v.error||"Transfer rejected")))})})}async receiveFile(e,t,n,s,i,a,f,u="sha256",d,g){let _={id:e,terminalId:t,filename:n,filePath:f,size:s,totalChunks:i,direction:Be.TransferDirection.UPLOAD,status:Be.TransferStatus.ACTIVE,deliveredChunks:new Set,pendingChunks:new Map,chunks:new Array(i).fill(null),checksum:a,checksumAlgorithm:u,onProgress:d?(y,v)=>d(e,y,v):void 0,onComplete:g?(y,v)=>g(e,y,v):void 0,ackTimeouts:new Map};this.activeTransfers.set(e,_)}cancelTransfer(e,t){let n=this.activeTransfers.get(e);if(n){for(let s of n.ackTimeouts.values())clearTimeout(s);if(n.status=Be.TransferStatus.CANCELLED,n.onComplete?.(!1,t),this.socket){let s={transferId:e,reason:t};this.socket.emit("file:cancel",s)}this.activeTransfers.delete(e)}}async resumeTransfer(e){let t=this.activeTransfers.get(e);!t||!this.socket||this.socket.emit("file:sync",{transferId:e},n=>{if(n.status===Be.TransferStatus.EXPIRED){t.onComplete?.(!1,"Transfer expired"),this.activeTransfers.delete(e);return}if(n.deliveredChunks)for(let s of n.deliveredChunks)t.deliveredChunks.add(s);if(t.direction===Be.TransferDirection.DOWNLOAD&&n.missingChunks){t.status=Be.TransferStatus.ACTIVE;for(let s of n.missingChunks)this.sendChunk(t,s)}})}getTransferStatus(e){return this.activeTransfers.get(e)?.status??null}getTransferProgress(e){let t=this.activeTransfers.get(e);return t?{delivered:t.deliveredChunks.size,total:t.totalChunks}:null}setupEventHandlers(){this.socket&&(this.socket.on("file:chunk",e=>{this.handleIncomingChunk(e)}),this.socket.on("file:chunk:ack",e=>{this.handleChunkAck(e)}),this.socket.on("file:complete",e=>{this.handleComplete(e)}),this.socket.on("file:progress",e=>{this.handleProgress(e)}),this.socket.on("file:init",(e,t)=>{this.handleIncomingFileInit(e,t)}),this.socket.on("file:cancel",e=>{let t=this.activeTransfers.get(e.transferId);if(t){for(let n of t.ackTimeouts.values())clearTimeout(n);t.status=Be.TransferStatus.CANCELLED,t.onComplete?.(!1,e.reason||"Cancelled by remote"),this.activeTransfers.delete(e.transferId)}}))}startSendingChunks(e){let t=this.activeTransfers.get(e);if(!(!t||!t.chunks))for(let n=0;n<Math.min(Be.WINDOW_SIZE,t.totalChunks);n++)t.deliveredChunks.has(n)||this.sendChunk(t,n)}sendChunk(e,t){if(!this.socket||!e.chunks)return;let n=e.chunks[t];if(!n)return;let s=e.pendingChunks.get(t),i={seq:t,data:n,retries:s?s.retries:0,sentAt:Date.now()};e.pendingChunks.set(t,i);let a={transferId:e.id,seq:t,data:n.buffer.slice(n.byteOffset,n.byteOffset+n.byteLength)};this.socket.emit("file:chunk",a,u=>{u&&!u.success&&this.cancelTransfer(e.id,u.error||"Server rejected chunk")});let f=setTimeout(()=>{this.handleAckTimeout(e.id,t)},Be.ACK_TIMEOUT_MS);e.ackTimeouts.set(t,f)}handleChunkAck(e){let t=this.activeTransfers.get(e.transferId);if(!t||t.status===Be.TransferStatus.COMPLETED)return;let n=t.ackTimeouts.get(e.seq);n&&(clearTimeout(n),t.ackTimeouts.delete(e.seq)),t.deliveredChunks.add(e.seq),t.pendingChunks.delete(e.seq),t.onProgress?.(t.deliveredChunks.size,t.totalChunks);let s=e.seq+Be.WINDOW_SIZE;s<t.totalChunks&&!t.deliveredChunks.has(s)&&this.sendChunk(t,s),t.deliveredChunks.size===t.totalChunks&&this.finishSending(t)}handleAckTimeout(e,t){let n=this.activeTransfers.get(e);if(!n)return;let s=n.pendingChunks.get(t);s&&(s.retries<Be.MAX_RETRIES?(s.retries++,this.sendChunk(n,t)):this.cancelTransfer(e,"Max retries exceeded"))}finishSending(e){if(!this.socket)return;e.status=Be.TransferStatus.COMPLETED;let t={transferId:e.id,checksum:e.checksum};this.socket.emit("file:end",t)}handleIncomingChunk(e){let t=this.activeTransfers.get(e.transferId);if(!(!t||!t.chunks)){if(t.chunks[e.seq]=Buffer.from(e.data),t.deliveredChunks.add(e.seq),this.socket){let n={transferId:e.transferId,seq:e.seq};this.socket.emit("file:chunk:ack",n)}t.onProgress?.(t.deliveredChunks.size,t.totalChunks),t.deliveredChunks.size===t.totalChunks&&this.finishReceiving(t)}}finishReceiving(e){if(!e.chunks||!e.filePath)return;let t=Buffer.concat(e.chunks);if(this.calculateChecksum(t,e.checksumAlgorithm)!==e.checksum){e.status=Be.TransferStatus.FAILED,e.onComplete?.(!1,"Checksum mismatch"),this.socket&&this.socket.emit("file:complete",{transferId:e.id,success:!1,error:"Checksum mismatch"});return}try{let s=bm.dirname(e.filePath);Hi.existsSync(s)||Hi.mkdirSync(s,{recursive:!0}),Hi.writeFileSync(e.filePath,t),e.status=Be.TransferStatus.COMPLETED,e.onComplete?.(!0),this.socket&&this.socket.emit("file:complete",{transferId:e.id,success:!0})}catch(s){let i=s instanceof Error?s.message:String(s);e.status=Be.TransferStatus.FAILED,e.onComplete?.(!1,`Failed to save file: ${i}`),this.socket&&this.socket.emit("file:complete",{transferId:e.id,success:!1,error:`Failed to save file: ${i}`})}this.activeTransfers.delete(e.id)}handleComplete(e){let t=this.activeTransfers.get(e.transferId);if(t){e.success?(t.status=Be.TransferStatus.COMPLETED,t.onComplete?.(!0)):(t.status=Be.TransferStatus.FAILED,t.onComplete?.(!1,e.error));for(let n of t.ackTimeouts.values())clearTimeout(n);this.activeTransfers.delete(e.transferId)}}handleProgress(e){let t=this.activeTransfers.get(e.transferId);t&&t.onProgress?.(e.deliveredChunks,e.totalChunks)}handleIncomingFileInit(e,t){let s=`${e.targetPath||this.fallbackDir}/${e.filename}`;this.receiveFile(e.transferId,e.terminalId,e.filename,e.size,e.totalChunks,e.checksum,s,e.checksumAlgorithm||"sha256").then(()=>t({accepted:!0})).catch(i=>t({accepted:!1,error:i.message}))}calculateChecksum(e,t="sha256"){return t==="fnv1a"?this.fnv1aHash(e):Zl.createHash("sha256").update(e).digest("hex")}fnv1aHash(e){let t=2166136261;for(let s=0;s<e.length;s++)t^=e[s],t=Math.imul(t,16777619);return(t>>>0).toString(16).padStart(8,"0").repeat(8)}getMimeType(e){let t=e.split(".").pop()?.toLowerCase();return{txt:"text/plain",json:"application/json",js:"application/javascript",ts:"application/typescript",html:"text/html",css:"text/css",md:"text/markdown",png:"image/png",jpg:"image/jpeg",jpeg:"image/jpeg",gif:"image/gif",webp:"image/webp",svg:"image/svg+xml",pdf:"application/pdf",zip:"application/zip",tar:"application/x-tar",gz:"application/gzip"}[t||""]||"application/octet-stream"}};er.FileTransferService=$a});var ec=D((Xw,$i)=>{function rh(r){return Array.isArray(r)?r:[r]}var Sm=void 0,Ya="",eh=" ",Ga="\\",Tm=/^\s+$/,Om=/(?:[^\\]|^)\\$/,Cm=/^\\!/,km=/^\\#/,Pm=/\r?\n/g,Rm=/^\.{0,2}\/|^\.{1,2}$/,Am=/\/$/,Un="/",nh="node-ignore";typeof Symbol<"u"&&(nh=Symbol.for("node-ignore"));var sh=nh,qn=(r,e,t)=>(Object.defineProperty(r,e,{value:t}),t),Im=/([0-z])-([0-z])/g,ih=()=>!1,Lm=r=>r.replace(Im,(e,t,n)=>t.charCodeAt(0)<=n.charCodeAt(0)?e:Ya),Nm=r=>{let{length:e}=r;return r.slice(0,e-e%2)},Dm=[[/^\uFEFF/,()=>Ya],[/((?:\\\\)*?)(\\?\s+)$/,(r,e,t)=>e+(t.indexOf("\\")===0?eh:Ya)],[/(\\+?)\s/g,(r,e)=>{let{length:t}=e;return e.slice(0,t-t%2)+eh}],[/[\\$.|*+(){^]/g,r=>`\\${r}`],[/(?!\\)\?/g,()=>"[^/]"],[/^\//,()=>"^"],[/\//g,()=>"\\/"],[/^\^*\\\*\\\*\\\//,()=>"^(?:.*\\/)?"],[/^(?=[^^])/,function(){return/\/(?!$)/.test(this)?"^":"(?:^|\\/)"}],[/\\\/\\\*\\\*(?=\\\/|$)/g,(r,e,t)=>e+6<t.length?"(?:\\/[^\\/]+)*":"\\/.+"],[/(^|[^\\]+)(\\\*)+(?=.+)/g,(r,e,t)=>{let n=t.replace(/\\\*/g,"[^\\/]*");return e+n}],[/\\\\\\(?=[$.|*+(){^])/g,()=>Ga],[/\\\\/g,()=>Ga],[/(\\)?\[([^\]/]*?)(\\*)($|\])/g,(r,e,t,n,s)=>e===Ga?`\\[${t}${Nm(n)}${s}`:s==="]"&&n.length%2===0?`[${Lm(t)}${n}]`:"[]"],[/(?:[^*])$/,r=>/\/$/.test(r)?`${r}$`:`${r}(?=$|\\/$)`]],Fm=/(^|\\\/)?\\\*$/,ms="regex",Vi="checkRegex",th="_",Mm={[ms](r,e){return`${e?`${e}[^/]+`:"[^/]*"}(?=$|\\/$)`},[Vi](r,e){return`${e?`${e}[^/]*`:"[^/]*"}(?=$|\\/$)`}},Bm=r=>Dm.reduce((e,[t,n])=>e.replace(t,n.bind(r)),r),Ki=r=>typeof r=="string",jm=r=>r&&Ki(r)&&!Tm.test(r)&&!Om.test(r)&&r.indexOf("#")!==0,Um=r=>r.split(Pm).filter(Boolean),Xa=class{constructor(e,t,n,s,i,a){this.pattern=e,this.mark=t,this.negative=i,qn(this,"body",n),qn(this,"ignoreCase",s),qn(this,"regexPrefix",a)}get regex(){let e=th+ms;return this[e]?this[e]:this._make(ms,e)}get checkRegex(){let e=th+Vi;return this[e]?this[e]:this._make(Vi,e)}_make(e,t){let n=this.regexPrefix.replace(Fm,Mm[e]),s=this.ignoreCase?new RegExp(n,"i"):new RegExp(n);return qn(this,t,s)}},qm=({pattern:r,mark:e},t)=>{let n=!1,s=r;s.indexOf("!")===0&&(n=!0,s=s.substr(1)),s=s.replace(Cm,"!").replace(km,"#");let i=Bm(s);return new Xa(r,e,s,t,n,i)},Ja=class{constructor(e){this._ignoreCase=e,this._rules=[]}_add(e){if(e&&e[sh]){this._rules=this._rules.concat(e._rules._rules),this._added=!0;return}if(Ki(e)&&(e={pattern:e}),jm(e.pattern)){let t=qm(e,this._ignoreCase);this._added=!0,this._rules.push(t)}}add(e){return this._added=!1,rh(Ki(e)?Um(e):e).forEach(this._add,this),this._added}test(e,t,n){let s=!1,i=!1,a;this._rules.forEach(u=>{let{negative:d}=u;i===d&&s!==i||d&&!s&&!i&&!t||!u[n].test(e)||(s=!d,i=d,a=d?Sm:u)});let f={ignored:s,unignored:i};return a&&(f.rule=a),f}},Wm=(r,e)=>{throw new e(r)},_r=(r,e,t)=>Ki(r)?r?_r.isNotRelative(r)?t(`path should be a \`path.relative()\`d string, but got "${e}"`,RangeError):!0:t("path must not be empty",TypeError):t(`path must be a string, but got \`${e}\``,TypeError),oh=r=>Rm.test(r);_r.isNotRelative=oh;_r.convert=r=>r;var Za=class{constructor({ignorecase:e=!0,ignoreCase:t=e,allowRelativePaths:n=!1}={}){qn(this,sh,!0),this._rules=new Ja(t),this._strictPathCheck=!n,this._initCache()}_initCache(){this._ignoreCache=Object.create(null),this._testCache=Object.create(null)}add(e){return this._rules.add(e)&&this._initCache(),this}addPattern(e){return this.add(e)}_test(e,t,n,s){let i=e&&_r.convert(e);return _r(i,e,this._strictPathCheck?Wm:ih),this._t(i,t,n,s)}checkIgnore(e){if(!Am.test(e))return this.test(e);let t=e.split(Un).filter(Boolean);if(t.pop(),t.length){let n=this._t(t.join(Un)+Un,this._testCache,!0,t);if(n.ignored)return n}return this._rules.test(e,!1,Vi)}_t(e,t,n,s){if(e in t)return t[e];if(s||(s=e.split(Un).filter(Boolean)),s.pop(),!s.length)return t[e]=this._rules.test(e,n,ms);let i=this._t(s.join(Un)+Un,t,n,s);return t[e]=i.ignored?i:this._rules.test(e,n,ms)}ignores(e){return this._test(e,this._ignoreCache,!1).ignored}createFilter(){return e=>!this.ignores(e)}filter(e){return rh(e).filter(this.createFilter())}test(e){return this._test(e,this._testCache,!0)}},Qa=r=>new Za(r),Hm=r=>_r(r&&_r.convert(r),r,ih),ah=()=>{let r=t=>/^\\\\\?\\/.test(t)||/["<>|\u0000-\u001F]+/u.test(t)?t:t.replace(/\\/g,"/");_r.convert=r;let e=/^[a-z]:\//i;_r.isNotRelative=t=>e.test(t)||oh(t)};typeof process<"u"&&process.platform==="win32"&&ah();$i.exports=Qa;Qa.default=Qa;$i.exports.isPathValid=Hm;qn($i.exports,Symbol.for("setupWindows"),ah)});var fh=D(Lt=>{"use strict";var Vm=Lt&&Lt.__createBinding||(Object.create?(function(r,e,t,n){n===void 0&&(n=t);var s=Object.getOwnPropertyDescriptor(e,t);(!s||("get"in s?!e.__esModule:s.writable||s.configurable))&&(s={enumerable:!0,get:function(){return e[t]}}),Object.defineProperty(r,n,s)}):(function(r,e,t,n){n===void 0&&(n=t),r[n]=e[t]})),Km=Lt&&Lt.__setModuleDefault||(Object.create?(function(r,e){Object.defineProperty(r,"default",{enumerable:!0,value:e})}):function(r,e){r.default=e}),ch=Lt&&Lt.__importStar||(function(){var r=function(e){return r=Object.getOwnPropertyNames||function(t){var n=[];for(var s in t)Object.prototype.hasOwnProperty.call(t,s)&&(n[n.length]=s);return n},r(e)};return function(e){if(e&&e.__esModule)return e;var t={};if(e!=null)for(var n=r(e),s=0;s<n.length;s++)n[s]!=="default"&&Vm(t,e,n[s]);return Km(t,e),t}})(),$m=Lt&&Lt.__importDefault||function(r){return r&&r.__esModule?r:{default:r}};Object.defineProperty(Lt,"__esModule",{value:!0});Lt.FileListService=void 0;var ys=ch(require("path")),tc=ch(require("fs/promises")),zm=$m(ec()),rc=Gr(),Gm=["node_modules",".pnpm","vendor",".git","dist","build","out",".next",".nuxt",".output",".cache",".turbo",".idea",".vscode",".DS_Store","Thumbs.db"],nc=class{ignoreFilter;workspaceRoot;onResponseCallback=null;logger;constructor(e,t){this.logger=e,this.workspaceRoot=t,this.ignoreFilter=(0,zm.default)(),this.ignoreFilter.add(Gm),this.workspaceRoot&&this.loadGitignore(),this.logger.info("FileListService initialized",t||"null")}async loadGitignore(){if(!this.workspaceRoot)return;let e=ys.join(this.workspaceRoot,".gitignore");try{let t=await tc.readFile(e,"utf-8");this.ignoreFilter.add(t)}catch{}}onResponse(e){this.onResponseCallback=e}async handleListRequest(e){if(!this.workspaceRoot){this.sendResponse({requestId:e.requestId,path:e.path,entries:[],error:"No workspace root"});return}try{let t=this.resolvePath(e.path),n=await this.listDirectory(t,e.path);this.sendResponse({requestId:e.requestId,path:e.path,entries:n})}catch(t){this.logger.error("Failed to list directory",String(t)),this.sendResponse({requestId:e.requestId,path:e.path,entries:[],error:t instanceof Error?t.message:"Unknown error"})}}async listDirectory(e,t){let n=await tc.readdir(e,{withFileTypes:!0}),s=[];for(let i of n){let a=t==="."||t===""?i.name:ys.join(t,i.name);if(this.shouldHide(a,i.isDirectory()))continue;let f=ys.join(e,i.name),u={name:i.name,path:a,type:i.isDirectory()?rc.FileEntryType.DIRECTORY:rc.FileEntryType.FILE};if(!i.isDirectory())try{let d=await tc.stat(f);u.size=d.size,u.modified=d.mtime.toISOString()}catch{}s.push(u)}return s.sort((i,a)=>i.type!==a.type?i.type===rc.FileEntryType.DIRECTORY?-1:1:i.name.localeCompare(a.name))}shouldHide(e,t){let n=e.split(ys.sep).join("/"),s=t?`${n}/`:n;return this.ignoreFilter.ignores(s)}resolvePath(e){if(!this.workspaceRoot)throw new Error("No workspace root");if(e==="."||e==="")return this.workspaceRoot;let t=ys.join(this.workspaceRoot,e);if(!t.startsWith(this.workspaceRoot))throw new Error("Path outside workspace");return t}sendResponse(e){this.onResponseCallback?.(e)}dispose(){this.onResponseCallback=null}};Lt.FileListService=nc});var lh=D(tr=>{"use strict";var Ym=tr&&tr.__createBinding||(Object.create?(function(r,e,t,n){n===void 0&&(n=t);var s=Object.getOwnPropertyDescriptor(e,t);(!s||("get"in s?!e.__esModule:s.writable||s.configurable))&&(s={enumerable:!0,get:function(){return e[t]}}),Object.defineProperty(r,n,s)}):(function(r,e,t,n){n===void 0&&(n=t),r[n]=e[t]})),Xm=tr&&tr.__setModuleDefault||(Object.create?(function(r,e){Object.defineProperty(r,"default",{enumerable:!0,value:e})}):function(r,e){r.default=e}),uh=tr&&tr.__importStar||(function(){var r=function(e){return r=Object.getOwnPropertyNames||function(t){var n=[];for(var s in t)Object.prototype.hasOwnProperty.call(t,s)&&(n[n.length]=s);return n},r(e)};return function(e){if(e&&e.__esModule)return e;var t={};if(e!=null)for(var n=r(e),s=0;s<n.length;s++)n[s]!=="default"&&Ym(t,e,n[s]);return Xm(t,e),t}})();Object.defineProperty(tr,"__esModule",{value:!0});tr.FileTrackerService=void 0;var sc=uh(require("path")),cn=uh(require("fs/promises")),Jm=require("child_process"),Zm=require("util"),jt=Gr(),ic=(0,Zm.promisify)(Jm.exec),oc={toolStart:/⏺\s*(Write|Edit|NotebookEdit)\s*\(\s*(?:file_path|notebook_path)\s*=\s*"([^"]+)"/,toolSuccess:/[✓✔]\s*(?:Wrote|Edited|Updated|Created)\s+([^\s\n]+)/,toolError:/[✗✘]\s*(?:Failed|Error)/i},ac=class{trackedFiles=new Map;pendingToolCalls=new Map;outputBuffers=new Map;workspaceRoot;onFileChangedCallback=null;onFileViewTransferCallback=null;logger;constructor(e,t){this.logger=e,this.workspaceRoot=t}onFileChanged(e){this.onFileChangedCallback=e}onFileViewTransfer(e){this.onFileViewTransferCallback=e}async processOutput(e,t){let n=this.outputBuffers.get(e)||"";n+=t,n.length>10240&&(n=n.slice(-10240)),this.outputBuffers.set(e,n);try{await this.parseToolCalls(e,n)}catch(s){this.logger.error("Error parsing tool calls",s)}}async parseToolCalls(e,t){let n=this.stripAnsi(t),s=n.match(oc.toolStart);if(s){let a=s[1],f=s[2],u=`${a}_${Date.now()}_${f}`;this.pendingToolCalls.has(u)||await this.handleToolStart(e,u,a,{file_path:f})}let i=n.match(oc.toolSuccess);if(i){let a=i[1];for(let[f,u]of this.pendingToolCalls)if(u.filePath===a||a.endsWith(u.filePath)||u.filePath.endsWith(a)){await this.handleToolEnd(e,f,u.toolName,"success");break}}if(oc.toolError.test(n))for(let[a,f]of this.pendingToolCalls)await this.handleToolEnd(e,a,f.toolName,"error")}stripAnsi(e){return e.replace(/\x1b\[[0-9;?]*[a-zA-Z]/g,"").replace(/\x1b\][^\x07]*\x07/g,"").replace(/\x1b[()][AB012]/g,"").replace(/\x1b[=>]/g,"").replace(/\x1b[78DMEHc]/g,"")}async handleToolStart(e,t,n,s){if(!this.isFileModifyingTool(n))return;let i=this.extractFilePath(n,s);if(!i)return;let a=this.resolveFilePath(i),f={toolId:t,toolName:n,filePath:i,timestamp:new Date().toISOString()};this.pendingToolCalls.set(t,f);let u;try{u=await cn.readFile(a,"utf-8")}catch{u=void 0}let d={path:i,changeType:u===void 0?jt.FileChangeType.CREATE:jt.FileChangeType.MODIFY,toolName:n,toolId:t,timestamp:f.timestamp,previousContent:u},g=this.trackedFiles.get(e)||[];g.push(d),this.trackedFiles.set(e,g)}async handleToolEnd(e,t,n,s){if(!this.isFileModifyingTool(n)||!this.pendingToolCalls.get(t))return;if(this.pendingToolCalls.delete(t),s==="error"){let g=this.trackedFiles.get(e)||[],_=g.findIndex(y=>y.toolId===t);_!==-1&&g.splice(_,1);return}let f=(this.trackedFiles.get(e)||[]).find(g=>g.toolId===t);if(!f)return;let u=this.resolveFilePath(f.path);try{let g=await cn.stat(u);f.size=g.size}catch{f.changeType=jt.FileChangeType.DELETE,f.size=void 0}let d={path:f.path,changeType:f.changeType,timestamp:new Date().toISOString(),source:"tool-call",toolName:f.toolName,toolId:f.toolId,size:f.size};this.onFileChangedCallback?.(e,d)}async handleViewRequest(e,t){let n=this.resolveFilePath(t.path),s=this.getViewableMimeType(t.path);if(s&&this.onFileViewTransferCallback){try{let a=await cn.readFile(n),f={requestId:t.requestId,path:t.path,viewType:"content",mimeType:s};this.onFileViewTransferCallback(e,Buffer.from(a),f)}catch(a){let f={requestId:t.requestId,path:t.path,viewType:"content",mimeType:s,error:a instanceof Error?a.message:"Unknown error"};this.onFileViewTransferCallback(e,Buffer.alloc(0),f)}return}let i;try{t.type===jt.FileViewType.CONTENT?i=await this.getFileContent(t,n):i=await this.getFileDiff(e,t,n)}catch(a){i={requestId:t.requestId,path:t.path,type:t.type,error:a instanceof Error?a.message:"Unknown error"}}if(this.onFileViewTransferCallback){let a={requestId:t.requestId,path:t.path,viewType:i.type===jt.FileViewType.CONTENT?"content":"diff",language:i.language,truncated:i.truncated,error:i.error},f=Buffer.from(i.content||"","utf-8");this.onFileViewTransferCallback(e,f,a)}}getViewableMimeType(e){let t=e.split(".").pop()?.toLowerCase();return{png:"image/png",jpg:"image/jpeg",jpeg:"image/jpeg",gif:"image/gif",webp:"image/webp",svg:"image/svg+xml",pdf:"application/pdf"}[t||""]||null}async getFileContent(e,t){let n=e.maxSize||1048576,s=await cn.stat(t),i=await cn.readFile(t,"utf-8"),a=!1,f=i;return i.length>n&&(f=i.slice(0,n),a=!0),{requestId:e.requestId,path:e.path,type:jt.FileViewType.CONTENT,content:f,language:(0,jt.getLanguageFromPath)(e.path),size:s.size,truncated:a}}async getFileDiff(e,t,n){let s=t.diffBase||jt.DiffBase.GIT,i;return s===jt.DiffBase.GIT?i=await this.getGitDiff(n):i=await this.getPreviousDiff(e,t.path,n),{requestId:t.requestId,path:t.path,type:jt.FileViewType.DIFF,content:i,language:"diff"}}async getGitDiff(e){if(!this.workspaceRoot)throw new Error("No workspace root");try{let{stdout:t}=await ic(`git diff --cached -- "${e}"`,{cwd:this.workspaceRoot});if(t.trim())return t;let{stdout:n}=await ic(`git diff -- "${e}"`,{cwd:this.workspaceRoot});if(n.trim())return n;let{stdout:s}=await ic(`git status --porcelain -- "${e}"`,{cwd:this.workspaceRoot});if(s.startsWith("??")||s.startsWith("A ")){let a=(await cn.readFile(e,"utf-8")).split(`
|
|
27
|
+
`),f=sc.relative(this.workspaceRoot,e);return[`diff --git a/${f} b/${f}`,"new file mode 100644","--- /dev/null",`+++ b/${f}`,`@@ -0,0 +1,${a.length} @@`,...a.map(u=>`+${u}`)].join(`
|
|
28
|
+
`)}return"(no changes)"}catch{throw new Error("Git not available")}}async getPreviousDiff(e,t,n){let a=(this.trackedFiles.get(e)||[]).find(d=>d.path===t&&d.previousContent!==void 0)?.previousContent||"",f;try{f=await cn.readFile(n,"utf-8")}catch{f=""}let u=(0,jt.createSimpleDiff)(a,f,t);return this.diffContentToUnifiedText(u)}diffContentToUnifiedText(e){let t=[];t.push(`--- a/${e.path}`),t.push(`+++ b/${e.path}`);for(let n of e.hunks){t.push(`@@ -${n.oldStart},${n.oldLines} +${n.newStart},${n.newLines} @@`);for(let s of n.lines)switch(s.type){case"add":t.push(`+${s.content}`);break;case"remove":t.push(`-${s.content}`);break;case"context":t.push(` ${s.content}`);break}}return t.join(`
|
|
29
|
+
`)}clearTerminal(e){this.trackedFiles.delete(e),this.outputBuffers.delete(e)}getChangedFiles(e){return(this.trackedFiles.get(e)||[]).map(n=>({path:n.path,changeType:n.changeType,timestamp:n.timestamp,source:"tool-call",toolName:n.toolName,toolId:n.toolId,size:n.size}))}isFileModifyingTool(e){return["Write","Edit","NotebookEdit"].includes(e)}extractFilePath(e,t){return t?e==="Write"||e==="Edit"?t.file_path||null:e==="NotebookEdit"&&t.notebook_path||null:null}resolveFilePath(e){return sc.isAbsolute(e)?e:this.workspaceRoot?sc.join(this.workspaceRoot,e):e}dispose(){this.trackedFiles.clear(),this.pendingToolCalls.clear(),this.onFileChangedCallback=null,this.onFileViewTransferCallback=null}};tr.FileTrackerService=ac});var hh=D(ft=>{"use strict";Object.defineProperty(ft,"__esModule",{value:!0});ft.FileTrackerService=ft.FileListService=ft.FileTransferService=ft.WebSocketService=ft.StatusDetector=ft.AuthService=ft.CryptoService=void 0;var Qm=Bf();Object.defineProperty(ft,"CryptoService",{enumerable:!0,get:function(){return Qm.CryptoService}});var ey=jf();Object.defineProperty(ft,"AuthService",{enumerable:!0,get:function(){return ey.AuthService}});var ty=Uf();Object.defineProperty(ft,"StatusDetector",{enumerable:!0,get:function(){return ty.StatusDetector}});var ry=Jl();Object.defineProperty(ft,"WebSocketService",{enumerable:!0,get:function(){return ry.WebSocketService}});var ny=Ql();Object.defineProperty(ft,"FileTransferService",{enumerable:!0,get:function(){return ny.FileTransferService}});var sy=fh();Object.defineProperty(ft,"FileListService",{enumerable:!0,get:function(){return sy.FileListService}});var iy=lh();Object.defineProperty(ft,"FileTrackerService",{enumerable:!0,get:function(){return iy.FileTrackerService}})});var Es=D(Le=>{"use strict";Object.defineProperty(Le,"__esModule",{value:!0});Le.FileTrackerService=Le.FileListService=Le.FileTransferService=Le.WebSocketService=Le.StatusDetector=Le.AuthService=Le.CryptoService=Le.getWsUrl=Le.getApiUrl=Le.CircularBuffer=Le.formatLogLine=Le.shouldLog=Le.LOG_LEVELS=void 0;var cc=rf();Object.defineProperty(Le,"LOG_LEVELS",{enumerable:!0,get:function(){return cc.LOG_LEVELS}});Object.defineProperty(Le,"shouldLog",{enumerable:!0,get:function(){return cc.shouldLog}});Object.defineProperty(Le,"formatLogLine",{enumerable:!0,get:function(){return cc.formatLogLine}});var fc=of();Object.defineProperty(Le,"CircularBuffer",{enumerable:!0,get:function(){return fc.CircularBuffer}});Object.defineProperty(Le,"getApiUrl",{enumerable:!0,get:function(){return fc.getApiUrl}});Object.defineProperty(Le,"getWsUrl",{enumerable:!0,get:function(){return fc.getWsUrl}});var fn=hh();Object.defineProperty(Le,"CryptoService",{enumerable:!0,get:function(){return fn.CryptoService}});Object.defineProperty(Le,"AuthService",{enumerable:!0,get:function(){return fn.AuthService}});Object.defineProperty(Le,"StatusDetector",{enumerable:!0,get:function(){return fn.StatusDetector}});Object.defineProperty(Le,"WebSocketService",{enumerable:!0,get:function(){return fn.WebSocketService}});Object.defineProperty(Le,"FileTransferService",{enumerable:!0,get:function(){return fn.FileTransferService}});Object.defineProperty(Le,"FileListService",{enumerable:!0,get:function(){return fn.FileListService}});Object.defineProperty(Le,"FileTrackerService",{enumerable:!0,get:function(){return fn.FileTrackerService}})});var dc=D((vs,hc)=>{(function(r,e){typeof vs=="object"&&typeof hc=="object"?hc.exports=e(require("child_process"),require("crypto")):typeof define=="function"&&define.amd?define(["child_process","crypto"],e):typeof vs=="object"?vs["electron-machine-id"]=e(require("child_process"),require("crypto")):r["electron-machine-id"]=e(r.child_process,r.crypto)})(vs,function(r,e){return(function(t){function n(i){if(s[i])return s[i].exports;var a=s[i]={exports:{},id:i,loaded:!1};return t[i].call(a.exports,a,a.exports,n),a.loaded=!0,a.exports}var s={};return n.m=t,n.c=s,n.p="",n(0)})([function(t,n,s){t.exports=s(34)},function(t,n,s){var i=s(29)("wks"),a=s(33),f=s(2).Symbol,u=typeof f=="function",d=t.exports=function(g){return i[g]||(i[g]=u&&f[g]||(u?f:a)("Symbol."+g))};d.store=i},function(t,n){var s=t.exports=typeof window<"u"&&window.Math==Math?window:typeof self<"u"&&self.Math==Math?self:Function("return this")();typeof __g=="number"&&(__g=s)},function(t,n,s){var i=s(9);t.exports=function(a){if(!i(a))throw TypeError(a+" is not an object!");return a}},function(t,n,s){t.exports=!s(24)(function(){return Object.defineProperty({},"a",{get:function(){return 7}}).a!=7})},function(t,n,s){var i=s(12),a=s(17);t.exports=s(4)?function(f,u,d){return i.f(f,u,a(1,d))}:function(f,u,d){return f[u]=d,f}},function(t,n){var s=t.exports={version:"2.4.0"};typeof __e=="number"&&(__e=s)},function(t,n,s){var i=s(14);t.exports=function(a,f,u){if(i(a),f===void 0)return a;switch(u){case 1:return function(d){return a.call(f,d)};case 2:return function(d,g){return a.call(f,d,g)};case 3:return function(d,g,_){return a.call(f,d,g,_)}}return function(){return a.apply(f,arguments)}}},function(t,n){var s={}.hasOwnProperty;t.exports=function(i,a){return s.call(i,a)}},function(t,n){t.exports=function(s){return typeof s=="object"?s!==null:typeof s=="function"}},function(t,n){t.exports={}},function(t,n){var s={}.toString;t.exports=function(i){return s.call(i).slice(8,-1)}},function(t,n,s){var i=s(3),a=s(26),f=s(32),u=Object.defineProperty;n.f=s(4)?Object.defineProperty:function(d,g,_){if(i(d),g=f(g,!0),i(_),a)try{return u(d,g,_)}catch{}if("get"in _||"set"in _)throw TypeError("Accessors not supported!");return"value"in _&&(d[g]=_.value),d}},function(t,n,s){var i=s(42),a=s(15);t.exports=function(f){return i(a(f))}},function(t,n){t.exports=function(s){if(typeof s!="function")throw TypeError(s+" is not a function!");return s}},function(t,n){t.exports=function(s){if(s==null)throw TypeError("Can't call method on "+s);return s}},function(t,n,s){var i=s(9),a=s(2).document,f=i(a)&&i(a.createElement);t.exports=function(u){return f?a.createElement(u):{}}},function(t,n){t.exports=function(s,i){return{enumerable:!(1&s),configurable:!(2&s),writable:!(4&s),value:i}}},function(t,n,s){var i=s(12).f,a=s(8),f=s(1)("toStringTag");t.exports=function(u,d,g){u&&!a(u=g?u:u.prototype,f)&&i(u,f,{configurable:!0,value:d})}},function(t,n,s){var i=s(29)("keys"),a=s(33);t.exports=function(f){return i[f]||(i[f]=a(f))}},function(t,n){var s=Math.ceil,i=Math.floor;t.exports=function(a){return isNaN(a=+a)?0:(a>0?i:s)(a)}},function(t,n,s){var i=s(11),a=s(1)("toStringTag"),f=i((function(){return arguments})())=="Arguments",u=function(d,g){try{return d[g]}catch{}};t.exports=function(d){var g,_,y;return d===void 0?"Undefined":d===null?"Null":typeof(_=u(g=Object(d),a))=="string"?_:f?i(g):(y=i(g))=="Object"&&typeof g.callee=="function"?"Arguments":y}},function(t,n){t.exports="constructor,hasOwnProperty,isPrototypeOf,propertyIsEnumerable,toLocaleString,toString,valueOf".split(",")},function(t,n,s){var i=s(2),a=s(6),f=s(7),u=s(5),d="prototype",g=function(_,y,v){var S,C,H,z=_&g.F,X=_&g.G,T=_&g.S,M=_&g.P,Q=_&g.B,B=_&g.W,ie=X?a:a[y]||(a[y]={}),he=ie[d],de=X?i:T?i[y]:(i[y]||{})[d];X&&(v=y);for(S in v)C=!z&&de&&de[S]!==void 0,C&&S in ie||(H=C?de[S]:v[S],ie[S]=X&&typeof de[S]!="function"?v[S]:Q&&C?f(H,i):B&&de[S]==H?(function(Pe){var We=function(Ge,ve,Ye){if(this instanceof Pe){switch(arguments.length){case 0:return new Pe;case 1:return new Pe(Ge);case 2:return new Pe(Ge,ve)}return new Pe(Ge,ve,Ye)}return Pe.apply(this,arguments)};return We[d]=Pe[d],We})(H):M&&typeof H=="function"?f(Function.call,H):H,M&&((ie.virtual||(ie.virtual={}))[S]=H,_&g.R&&he&&!he[S]&&u(he,S,H)))};g.F=1,g.G=2,g.S=4,g.P=8,g.B=16,g.W=32,g.U=64,g.R=128,t.exports=g},function(t,n){t.exports=function(s){try{return!!s()}catch{return!0}}},function(t,n,s){t.exports=s(2).document&&document.documentElement},function(t,n,s){t.exports=!s(4)&&!s(24)(function(){return Object.defineProperty(s(16)("div"),"a",{get:function(){return 7}}).a!=7})},function(t,n,s){"use strict";var i=s(28),a=s(23),f=s(57),u=s(5),d=s(8),g=s(10),_=s(45),y=s(18),v=s(52),S=s(1)("iterator"),C=!([].keys&&"next"in[].keys()),H="@@iterator",z="keys",X="values",T=function(){return this};t.exports=function(M,Q,B,ie,he,de,Pe){_(B,Q,ie);var We,Ge,ve,Ye=function(j){if(!C&&j in pe)return pe[j];switch(j){case z:return function(){return new B(this,j)};case X:return function(){return new B(this,j)}}return function(){return new B(this,j)}},Fe=Q+" Iterator",J=he==X,Ee=!1,pe=M.prototype,nt=pe[S]||pe[H]||he&&pe[he],Ze=nt||Ye(he),Wt=he?J?Ye("entries"):Ze:void 0,L=Q=="Array"&&pe.entries||nt;if(L&&(ve=v(L.call(new M)),ve!==Object.prototype&&(y(ve,Fe,!0),i||d(ve,S)||u(ve,S,T))),J&&nt&&nt.name!==X&&(Ee=!0,Ze=function(){return nt.call(this)}),i&&!Pe||!C&&!Ee&&pe[S]||u(pe,S,Ze),g[Q]=Ze,g[Fe]=T,he)if(We={values:J?Ze:Ye(X),keys:de?Ze:Ye(z),entries:Wt},Pe)for(Ge in We)Ge in pe||f(pe,Ge,We[Ge]);else a(a.P+a.F*(C||Ee),Q,We);return We}},function(t,n){t.exports=!0},function(t,n,s){var i=s(2),a="__core-js_shared__",f=i[a]||(i[a]={});t.exports=function(u){return f[u]||(f[u]={})}},function(t,n,s){var i,a,f,u=s(7),d=s(41),g=s(25),_=s(16),y=s(2),v=y.process,S=y.setImmediate,C=y.clearImmediate,H=y.MessageChannel,z=0,X={},T="onreadystatechange",M=function(){var B=+this;if(X.hasOwnProperty(B)){var ie=X[B];delete X[B],ie()}},Q=function(B){M.call(B.data)};S&&C||(S=function(B){for(var ie=[],he=1;arguments.length>he;)ie.push(arguments[he++]);return X[++z]=function(){d(typeof B=="function"?B:Function(B),ie)},i(z),z},C=function(B){delete X[B]},s(11)(v)=="process"?i=function(B){v.nextTick(u(M,B,1))}:H?(a=new H,f=a.port2,a.port1.onmessage=Q,i=u(f.postMessage,f,1)):y.addEventListener&&typeof postMessage=="function"&&!y.importScripts?(i=function(B){y.postMessage(B+"","*")},y.addEventListener("message",Q,!1)):i=T in _("script")?function(B){g.appendChild(_("script"))[T]=function(){g.removeChild(this),M.call(B)}}:function(B){setTimeout(u(M,B,1),0)}),t.exports={set:S,clear:C}},function(t,n,s){var i=s(20),a=Math.min;t.exports=function(f){return f>0?a(i(f),9007199254740991):0}},function(t,n,s){var i=s(9);t.exports=function(a,f){if(!i(a))return a;var u,d;if(f&&typeof(u=a.toString)=="function"&&!i(d=u.call(a))||typeof(u=a.valueOf)=="function"&&!i(d=u.call(a))||!f&&typeof(u=a.toString)=="function"&&!i(d=u.call(a)))return d;throw TypeError("Can't convert object to primitive value")}},function(t,n){var s=0,i=Math.random();t.exports=function(a){return"Symbol(".concat(a===void 0?"":a,")_",(++s+i).toString(36))}},function(t,n,s){"use strict";function i(T){return T&&T.__esModule?T:{default:T}}function a(){return process.platform!=="win32"?"":process.arch==="ia32"&&process.env.hasOwnProperty("PROCESSOR_ARCHITEW6432")?"mixed":"native"}function f(T){return(0,S.createHash)("sha256").update(T).digest("hex")}function u(T){switch(H){case"darwin":return T.split("IOPlatformUUID")[1].split(`
|
|
30
|
+
`)[0].replace(/\=|\s+|\"/gi,"").toLowerCase();case"win32":return T.toString().split("REG_SZ")[1].replace(/\r+|\n+|\s+/gi,"").toLowerCase();case"linux":return T.toString().replace(/\r+|\n+|\s+/gi,"").toLowerCase();case"freebsd":return T.toString().replace(/\r+|\n+|\s+/gi,"").toLowerCase();default:throw new Error("Unsupported platform: "+process.platform)}}function d(T){var M=u((0,v.execSync)(X[H]).toString());return T?M:f(M)}function g(T){return new y.default(function(M,Q){return(0,v.exec)(X[H],{},function(B,ie,he){if(B)return Q(new Error("Error while obtaining machine id: "+B.stack));var de=u(ie.toString());return M(T?de:f(de))})})}Object.defineProperty(n,"__esModule",{value:!0});var _=s(35),y=i(_);n.machineIdSync=d,n.machineId=g;var v=s(70),S=s(71),C=process,H=C.platform,z={native:"%windir%\\System32",mixed:"%windir%\\sysnative\\cmd.exe /c %windir%\\System32"},X={darwin:"ioreg -rd1 -c IOPlatformExpertDevice",win32:z[a()]+"\\REG.exe QUERY HKEY_LOCAL_MACHINE\\SOFTWARE\\Microsoft\\Cryptography /v MachineGuid",linux:"( cat /var/lib/dbus/machine-id /etc/machine-id 2> /dev/null || hostname ) | head -n 1 || :",freebsd:"kenv -q smbios.system.uuid || sysctl -n kern.hostuuid"}},function(t,n,s){t.exports={default:s(36),__esModule:!0}},function(t,n,s){s(66),s(68),s(69),s(67),t.exports=s(6).Promise},function(t,n){t.exports=function(){}},function(t,n){t.exports=function(s,i,a,f){if(!(s instanceof i)||f!==void 0&&f in s)throw TypeError(a+": incorrect invocation!");return s}},function(t,n,s){var i=s(13),a=s(31),f=s(62);t.exports=function(u){return function(d,g,_){var y,v=i(d),S=a(v.length),C=f(_,S);if(u&&g!=g){for(;S>C;)if(y=v[C++],y!=y)return!0}else for(;S>C;C++)if((u||C in v)&&v[C]===g)return u||C||0;return!u&&-1}}},function(t,v,s){var i=s(7),a=s(44),f=s(43),u=s(3),d=s(31),g=s(64),_={},y={},v=t.exports=function(S,C,H,z,X){var T,M,Q,B,ie=X?function(){return S}:g(S),he=i(H,z,C?2:1),de=0;if(typeof ie!="function")throw TypeError(S+" is not iterable!");if(f(ie)){for(T=d(S.length);T>de;de++)if(B=C?he(u(M=S[de])[0],M[1]):he(S[de]),B===_||B===y)return B}else for(Q=ie.call(S);!(M=Q.next()).done;)if(B=a(Q,he,M.value,C),B===_||B===y)return B};v.BREAK=_,v.RETURN=y},function(t,n){t.exports=function(s,i,a){var f=a===void 0;switch(i.length){case 0:return f?s():s.call(a);case 1:return f?s(i[0]):s.call(a,i[0]);case 2:return f?s(i[0],i[1]):s.call(a,i[0],i[1]);case 3:return f?s(i[0],i[1],i[2]):s.call(a,i[0],i[1],i[2]);case 4:return f?s(i[0],i[1],i[2],i[3]):s.call(a,i[0],i[1],i[2],i[3])}return s.apply(a,i)}},function(t,n,s){var i=s(11);t.exports=Object("z").propertyIsEnumerable(0)?Object:function(a){return i(a)=="String"?a.split(""):Object(a)}},function(t,n,s){var i=s(10),a=s(1)("iterator"),f=Array.prototype;t.exports=function(u){return u!==void 0&&(i.Array===u||f[a]===u)}},function(t,n,s){var i=s(3);t.exports=function(a,f,u,d){try{return d?f(i(u)[0],u[1]):f(u)}catch(_){var g=a.return;throw g!==void 0&&i(g.call(a)),_}}},function(t,n,s){"use strict";var i=s(49),a=s(17),f=s(18),u={};s(5)(u,s(1)("iterator"),function(){return this}),t.exports=function(d,g,_){d.prototype=i(u,{next:a(1,_)}),f(d,g+" Iterator")}},function(t,n,s){var i=s(1)("iterator"),a=!1;try{var f=[7][i]();f.return=function(){a=!0},Array.from(f,function(){throw 2})}catch{}t.exports=function(u,d){if(!d&&!a)return!1;var g=!1;try{var _=[7],y=_[i]();y.next=function(){return{done:g=!0}},_[i]=function(){return y},u(_)}catch{}return g}},function(t,n){t.exports=function(s,i){return{value:i,done:!!s}}},function(t,n,s){var i=s(2),a=s(30).set,f=i.MutationObserver||i.WebKitMutationObserver,u=i.process,d=i.Promise,g=s(11)(u)=="process";t.exports=function(){var _,y,v,S=function(){var X,T;for(g&&(X=u.domain)&&X.exit();_;){T=_.fn,_=_.next;try{T()}catch(M){throw _?v():y=void 0,M}}y=void 0,X&&X.enter()};if(g)v=function(){u.nextTick(S)};else if(f){var C=!0,H=document.createTextNode("");new f(S).observe(H,{characterData:!0}),v=function(){H.data=C=!C}}else if(d&&d.resolve){var z=d.resolve();v=function(){z.then(S)}}else v=function(){a.call(i,S)};return function(X){var T={fn:X,next:void 0};y&&(y.next=T),_||(_=T,v()),y=T}}},function(t,n,s){var i=s(3),a=s(50),f=s(22),u=s(19)("IE_PROTO"),d=function(){},g="prototype",_=function(){var y,v=s(16)("iframe"),S=f.length,C=">";for(v.style.display="none",s(25).appendChild(v),v.src="javascript:",y=v.contentWindow.document,y.open(),y.write("<script>document.F=Object</script"+C),y.close(),_=y.F;S--;)delete _[g][f[S]];return _()};t.exports=Object.create||function(y,v){var S;return y!==null?(d[g]=i(y),S=new d,d[g]=null,S[u]=y):S=_(),v===void 0?S:a(S,v)}},function(t,n,s){var i=s(12),a=s(3),f=s(54);t.exports=s(4)?Object.defineProperties:function(u,d){a(u);for(var g,_=f(d),y=_.length,v=0;y>v;)i.f(u,g=_[v++],d[g]);return u}},function(t,n,s){var i=s(55),a=s(17),f=s(13),u=s(32),d=s(8),g=s(26),_=Object.getOwnPropertyDescriptor;n.f=s(4)?_:function(y,v){if(y=f(y),v=u(v,!0),g)try{return _(y,v)}catch{}if(d(y,v))return a(!i.f.call(y,v),y[v])}},function(t,n,s){var i=s(8),a=s(63),f=s(19)("IE_PROTO"),u=Object.prototype;t.exports=Object.getPrototypeOf||function(d){return d=a(d),i(d,f)?d[f]:typeof d.constructor=="function"&&d instanceof d.constructor?d.constructor.prototype:d instanceof Object?u:null}},function(t,n,s){var i=s(8),a=s(13),f=s(39)(!1),u=s(19)("IE_PROTO");t.exports=function(d,g){var _,y=a(d),v=0,S=[];for(_ in y)_!=u&&i(y,_)&&S.push(_);for(;g.length>v;)i(y,_=g[v++])&&(~f(S,_)||S.push(_));return S}},function(t,n,s){var i=s(53),a=s(22);t.exports=Object.keys||function(f){return i(f,a)}},function(t,n){n.f={}.propertyIsEnumerable},function(t,n,s){var i=s(5);t.exports=function(a,f,u){for(var d in f)u&&a[d]?a[d]=f[d]:i(a,d,f[d]);return a}},function(t,n,s){t.exports=s(5)},function(t,n,s){var i=s(9),a=s(3),f=function(u,d){if(a(u),!i(d)&&d!==null)throw TypeError(d+": can't set as prototype!")};t.exports={set:Object.setPrototypeOf||("__proto__"in{}?(function(u,d,g){try{g=s(7)(Function.call,s(51).f(Object.prototype,"__proto__").set,2),g(u,[]),d=!(u instanceof Array)}catch{d=!0}return function(_,y){return f(_,y),d?_.__proto__=y:g(_,y),_}})({},!1):void 0),check:f}},function(t,n,s){"use strict";var i=s(2),a=s(6),f=s(12),u=s(4),d=s(1)("species");t.exports=function(g){var _=typeof a[g]=="function"?a[g]:i[g];u&&_&&!_[d]&&f.f(_,d,{configurable:!0,get:function(){return this}})}},function(t,n,s){var i=s(3),a=s(14),f=s(1)("species");t.exports=function(u,d){var g,_=i(u).constructor;return _===void 0||(g=i(_)[f])==null?d:a(g)}},function(t,n,s){var i=s(20),a=s(15);t.exports=function(f){return function(u,d){var g,_,y=String(a(u)),v=i(d),S=y.length;return v<0||v>=S?f?"":void 0:(g=y.charCodeAt(v),g<55296||g>56319||v+1===S||(_=y.charCodeAt(v+1))<56320||_>57343?f?y.charAt(v):g:f?y.slice(v,v+2):(g-55296<<10)+(_-56320)+65536)}}},function(t,n,s){var i=s(20),a=Math.max,f=Math.min;t.exports=function(u,d){return u=i(u),u<0?a(u+d,0):f(u,d)}},function(t,n,s){var i=s(15);t.exports=function(a){return Object(i(a))}},function(t,n,s){var i=s(21),a=s(1)("iterator"),f=s(10);t.exports=s(6).getIteratorMethod=function(u){if(u!=null)return u[a]||u["@@iterator"]||f[i(u)]}},function(t,n,s){"use strict";var i=s(37),a=s(47),f=s(10),u=s(13);t.exports=s(27)(Array,"Array",function(d,g){this._t=u(d),this._i=0,this._k=g},function(){var d=this._t,g=this._k,_=this._i++;return!d||_>=d.length?(this._t=void 0,a(1)):g=="keys"?a(0,_):g=="values"?a(0,d[_]):a(0,[_,d[_]])},"values"),f.Arguments=f.Array,i("keys"),i("values"),i("entries")},function(t,n){},function(t,n,s){"use strict";var i,a,f,u=s(28),d=s(2),g=s(7),_=s(21),y=s(23),v=s(9),S=(s(3),s(14)),C=s(38),H=s(40),z=(s(58).set,s(60)),X=s(30).set,T=s(48)(),M="Promise",Q=d.TypeError,ie=d.process,B=d[M],ie=d.process,he=_(ie)=="process",de=function(){},Pe=!!(function(){try{var L=B.resolve(1),j=(L.constructor={})[s(1)("species")]=function(A){A(de,de)};return(he||typeof PromiseRejectionEvent=="function")&&L.then(de)instanceof j}catch{}})(),We=function(L,j){return L===j||L===B&&j===f},Ge=function(L){var j;return!(!v(L)||typeof(j=L.then)!="function")&&j},ve=function(L){return We(B,L)?new Ye(L):new a(L)},Ye=a=function(L){var j,A;this.promise=new L(function(oe,Ae){if(j!==void 0||A!==void 0)throw Q("Bad Promise constructor");j=oe,A=Ae}),this.resolve=S(j),this.reject=S(A)},Fe=function(L){try{L()}catch(j){return{error:j}}},J=function(L,j){if(!L._n){L._n=!0;var A=L._c;T(function(){for(var oe=L._v,Ae=L._s==1,ut=0,mt=function(yt){var Et,nr,Er=Ae?yt.ok:yt.fail,qr=yt.resolve,wr=yt.reject,gn=yt.domain;try{Er?(Ae||(L._h==2&&nt(L),L._h=1),Er===!0?Et=oe:(gn&&gn.enter(),Et=Er(oe),gn&&gn.exit()),Et===yt.promise?wr(Q("Promise-chain cycle")):(nr=Ge(Et))?nr.call(Et,qr,wr):qr(Et)):wr(oe)}catch(Rs){wr(Rs)}};A.length>ut;)mt(A[ut++]);L._c=[],L._n=!1,j&&!L._h&&Ee(L)})}},Ee=function(L){X.call(d,function(){var j,A,oe,Ae=L._v;if(pe(L)&&(j=Fe(function(){he?ie.emit("unhandledRejection",Ae,L):(A=d.onunhandledrejection)?A({promise:L,reason:Ae}):(oe=d.console)&&oe.error&&oe.error("Unhandled promise rejection",Ae)}),L._h=he||pe(L)?2:1),L._a=void 0,j)throw j.error})},pe=function(L){if(L._h==1)return!1;for(var j,A=L._a||L._c,oe=0;A.length>oe;)if(j=A[oe++],j.fail||!pe(j.promise))return!1;return!0},nt=function(L){X.call(d,function(){var j;he?ie.emit("rejectionHandled",L):(j=d.onrejectionhandled)&&j({promise:L,reason:L._v})})},Ze=function(L){var j=this;j._d||(j._d=!0,j=j._w||j,j._v=L,j._s=2,j._a||(j._a=j._c.slice()),J(j,!0))},Wt=function(L){var j,A=this;if(!A._d){A._d=!0,A=A._w||A;try{if(A===L)throw Q("Promise can't be resolved itself");(j=Ge(L))?T(function(){var oe={_w:A,_d:!1};try{j.call(L,g(Wt,oe,1),g(Ze,oe,1))}catch(Ae){Ze.call(oe,Ae)}}):(A._v=L,A._s=1,J(A,!1))}catch(oe){Ze.call({_w:A,_d:!1},oe)}}};Pe||(B=function(L){C(this,B,M,"_h"),S(L),i.call(this);try{L(g(Wt,this,1),g(Ze,this,1))}catch(j){Ze.call(this,j)}},i=function(L){this._c=[],this._a=void 0,this._s=0,this._d=!1,this._v=void 0,this._h=0,this._n=!1},i.prototype=s(56)(B.prototype,{then:function(L,j){var A=ve(z(this,B));return A.ok=typeof L!="function"||L,A.fail=typeof j=="function"&&j,A.domain=he?ie.domain:void 0,this._c.push(A),this._a&&this._a.push(A),this._s&&J(this,!1),A.promise},catch:function(L){return this.then(void 0,L)}}),Ye=function(){var L=new i;this.promise=L,this.resolve=g(Wt,L,1),this.reject=g(Ze,L,1)}),y(y.G+y.W+y.F*!Pe,{Promise:B}),s(18)(B,M),s(59)(M),f=s(6)[M],y(y.S+y.F*!Pe,M,{reject:function(L){var j=ve(this),A=j.reject;return A(L),j.promise}}),y(y.S+y.F*(u||!Pe),M,{resolve:function(L){if(L instanceof B&&We(L.constructor,this))return L;var j=ve(this),A=j.resolve;return A(L),j.promise}}),y(y.S+y.F*!(Pe&&s(46)(function(L){B.all(L).catch(de)})),M,{all:function(L){var j=this,A=ve(j),oe=A.resolve,Ae=A.reject,ut=Fe(function(){var mt=[],yt=0,Et=1;H(L,!1,function(nr){var Er=yt++,qr=!1;mt.push(void 0),Et++,j.resolve(nr).then(function(wr){qr||(qr=!0,mt[Er]=wr,--Et||oe(mt))},Ae)}),--Et||oe(mt)});return ut&&Ae(ut.error),A.promise},race:function(L){var j=this,A=ve(j),oe=A.reject,Ae=Fe(function(){H(L,!1,function(ut){j.resolve(ut).then(A.resolve,oe)})});return Ae&&oe(Ae.error),A.promise}})},function(t,n,s){"use strict";var i=s(61)(!0);s(27)(String,"String",function(a){this._t=String(a),this._i=0},function(){var a,f=this._t,u=this._i;return u>=f.length?{value:void 0,done:!0}:(a=i(f,u),this._i+=a.length,{value:a,done:!1})})},function(t,n,s){s(65);for(var i=s(2),a=s(5),f=s(10),u=s(1)("toStringTag"),d=["NodeList","DOMTokenList","MediaList","StyleSheetList","CSSRuleList"],g=0;g<5;g++){var _=d[g],y=i[_],v=y&&y.prototype;v&&!v[u]&&a(v,u,_),f[_]=f.Array}},function(t,n){t.exports=require("child_process")},function(t,n){t.exports=require("crypto")}])})});function uy(){try{return gc.default.statSync("/.dockerenv"),!0}catch{return!1}}function ly(){try{return gc.default.readFileSync("/proc/self/cgroup","utf8").includes("docker")}catch{return!1}}function _c(){return pc===void 0&&(pc=uy()||ly()),pc}var gc,pc,mh=Nt(()=>{gc=me(require("node:fs"),1)});function Wn(){return mc===void 0&&(mc=hy()||_c()),mc}var yh,mc,hy,yc=Nt(()=>{yh=me(require("node:fs"),1);mh();hy=()=>{try{return yh.default.statSync("/run/.containerenv"),!0}catch{return!1}}});var Ec,wh,vh,Eh,Dr,wc=Nt(()=>{Ec=me(require("node:process"),1),wh=me(require("node:os"),1),vh=me(require("node:fs"),1);yc();Eh=()=>{if(Ec.default.platform!=="linux")return!1;if(wh.default.release().toLowerCase().includes("microsoft"))return!Wn();try{return vh.default.readFileSync("/proc/version","utf8").toLowerCase().includes("microsoft")?!Wn():!1}catch{return!1}},Dr=Ec.default.env.__IS_WSL_TEST__?Eh:Eh()});var vc,Ss,dy,py,xc,xh=Nt(()=>{vc=me(require("node:process"),1),Ss=me(require("node:fs/promises"),1);wc();wc();dy=(()=>{let r="/mnt/",e;return async function(){if(e)return e;let t="/etc/wsl.conf",n=!1;try{await Ss.default.access(t,Ss.constants.F_OK),n=!0}catch{}if(!n)return r;let s=await Ss.default.readFile(t,{encoding:"utf8"}),i=/(?<!#.*)root\s*=\s*(?<mountPoint>.*)/g.exec(s);return i?(e=i.groups.mountPoint.trim(),e=e.endsWith("/")?e:`${e}/`,e):r}})(),py=async()=>`${await dy()}c/Windows/System32/WindowsPowerShell/v1.0/powershell.exe`,xc=async()=>Dr?py():`${vc.default.env.SYSTEMROOT||vc.default.env.windir||String.raw`C:\Windows`}\\System32\\WindowsPowerShell\\v1.0\\powershell.exe`});function Fr(r,e,t){let n=s=>Object.defineProperty(r,e,{value:s,enumerable:!0,writable:!0});return Object.defineProperty(r,e,{configurable:!0,enumerable:!0,get(){let s=t();return n(s),s},set(s){n(s)}}),r}var bh=Nt(()=>{});async function bc(){if(Th.default.platform!=="darwin")throw new Error("macOS only");let{stdout:r}=await gy("defaults",["read","com.apple.LaunchServices/com.apple.launchservices.secure","LSHandlers"]),t=/LSHandlerRoleAll = "(?!-)(?<id>[^"]+?)";\s+?LSHandlerURLScheme = (?:http|https);/.exec(r)?.groups.id??"com.apple.Safari";return t==="com.apple.safari"?"com.apple.Safari":t}var Sh,Th,Oh,gy,Ch=Nt(()=>{Sh=require("node:util"),Th=me(require("node:process"),1),Oh=require("node:child_process"),gy=(0,Sh.promisify)(Oh.execFile)});async function Rh(r,{humanReadableOutput:e=!0,signal:t}={}){if(kh.default.platform!=="darwin")throw new Error("macOS only");let n=e?[]:["-ss"],s={};t&&(s.signal=t);let{stdout:i}=await _y("osascript",["-e",r,n],s);return i.trim()}var kh,Ph,Sc,_y,Ah=Nt(()=>{kh=me(require("node:process"),1),Ph=require("node:util"),Sc=require("node:child_process"),_y=(0,Ph.promisify)(Sc.execFile)});async function Tc(r){return Rh(`tell application "Finder" to set app_path to application file id "${r}" as string
|
|
31
|
+
tell application "System Events" to get value of property list item "CFBundleName" of property list file (app_path & ":Contents:Info.plist")`)}var Ih=Nt(()=>{Ah()});async function Cc(r=my){let{stdout:e}=await r("reg",["QUERY"," HKEY_CURRENT_USER\\Software\\Microsoft\\Windows\\Shell\\Associations\\UrlAssociations\\http\\UserChoice","/v","ProgId"]),t=/ProgId\s*REG_SZ\s*(?<id>\S+)/.exec(e);if(!t)throw new Oc(`Cannot find Windows browser in stdout: ${JSON.stringify(e)}`);let{id:n}=t.groups,s=n.lastIndexOf("."),i=n.lastIndexOf("-"),a=s===-1?void 0:n.slice(0,s),f=i===-1?void 0:n.slice(0,i);return Gi[n]??Gi[a]??Gi[f]??{name:n,id:n}}var Lh,Nh,my,Gi,mv,Oc,Dh=Nt(()=>{Lh=require("node:util"),Nh=require("node:child_process"),my=(0,Lh.promisify)(Nh.execFile),Gi={MSEdgeHTM:{name:"Edge",id:"com.microsoft.edge"},MSEdgeBHTML:{name:"Edge Beta",id:"com.microsoft.edge.beta"},MSEdgeDHTML:{name:"Edge Dev",id:"com.microsoft.edge.dev"},AppXq0fevzme2pys62n3e0fbqa7peapykr8v:{name:"Edge",id:"com.microsoft.edge.old"},ChromeHTML:{name:"Chrome",id:"com.google.chrome"},ChromeBHTML:{name:"Chrome Beta",id:"com.google.chrome.beta"},ChromeDHTML:{name:"Chrome Dev",id:"com.google.chrome.dev"},ChromiumHTM:{name:"Chromium",id:"org.chromium.Chromium"},BraveHTML:{name:"Brave",id:"com.brave.Browser"},BraveBHTML:{name:"Brave Beta",id:"com.brave.Browser.beta"},BraveDHTML:{name:"Brave Dev",id:"com.brave.Browser.dev"},BraveSSHTM:{name:"Brave Nightly",id:"com.brave.Browser.nightly"},FirefoxURL:{name:"Firefox",id:"org.mozilla.firefox"},OperaStable:{name:"Opera",id:"com.operasoftware.Opera"},VivaldiHTM:{name:"Vivaldi",id:"com.vivaldi.Vivaldi"},"IE.HTTP":{name:"Internet Explorer",id:"com.microsoft.ie"}},mv=new Map(Object.entries(Gi)),Oc=class extends Error{}});async function kc(){if(Yi.default.platform==="darwin"){let r=await bc();return{name:await Tc(r),id:r}}if(Yi.default.platform==="linux"){let{stdout:r}=await yy("xdg-mime",["query","default","x-scheme-handler/http"]),e=r.trim();return{name:Ey(e.replace(/.desktop$/,"").replace("-"," ")),id:e}}if(Yi.default.platform==="win32")return Cc();throw new Error("Only macOS, Linux, and Windows are supported")}var Fh,Yi,Mh,yy,Ey,Bh=Nt(()=>{Fh=require("node:util"),Yi=me(require("node:process"),1),Mh=require("node:child_process");Ch();Ih();Dh();yy=(0,Fh.promisify)(Mh.execFile),Ey=r=>r.toLowerCase().replaceAll(/(?:^|\s|-)\S/g,e=>e.toUpperCase())});var Kh={};Ld(Kh,{apps:()=>Mr,default:()=>Sy,openApp:()=>by});async function vy(){let r=await xc(),e=String.raw`(Get-ItemProperty -Path "HKCU:\Software\Microsoft\Windows\Shell\Associations\UrlAssociations\http\UserChoice").ProgId`,t=Ac.Buffer.from(e,"utf16le").toString("base64"),{stdout:n}=await wy(r,["-NoProfile","-NonInteractive","-ExecutionPolicy","Bypass","-EncodedCommand",t],{encoding:"utf8"}),s=n.trim(),i={ChromeHTML:"com.google.chrome",BraveHTML:"com.brave.Browser",MSEdgeHTM:"com.microsoft.edge",FirefoxURL:"org.mozilla.firefox"};return i[s]?{id:i[s]}:{}}function Wh(r){if(typeof r=="string"||Array.isArray(r))return r;let{[Uh]:e}=r;if(!e)throw new Error(`${Uh} is not supported`);return e}function Ji({[Hn]:r},{wsl:e}){if(e&&Dr)return Wh(e);if(!r)throw new Error(`${Hn} is not supported`);return Wh(r)}var Rc,Ac,Ic,Hh,Vh,Lc,Xi,Ty,wy,Pc,jh,Hn,Uh,qh,Ts,xy,by,Mr,Sy,$h=Nt(()=>{Rc=me(require("node:process"),1),Ac=require("node:buffer"),Ic=me(require("node:path"),1),Hh=require("node:url"),Vh=require("node:util"),Lc=me(require("node:child_process"),1),Xi=me(require("node:fs/promises"),1);xh();bh();Bh();yc();Ty={},wy=(0,Vh.promisify)(Lc.default.execFile),Pc=Ic.default.dirname((0,Hh.fileURLToPath)(Ty.url)),jh=Ic.default.join(Pc,"xdg-open"),{platform:Hn,arch:Uh}=Rc.default;qh=async(r,e)=>{let t;for(let n of r)try{return await e(n)}catch(s){t=s}throw t},Ts=async r=>{if(r={wait:!1,background:!1,newInstance:!1,allowNonzeroExitCode:!1,...r},Array.isArray(r.app))return qh(r.app,f=>Ts({...r,app:f}));let{name:e,arguments:t=[]}=r.app??{};if(t=[...t],Array.isArray(e))return qh(e,f=>Ts({...r,app:{name:f,arguments:t}}));if(e==="browser"||e==="browserPrivate"){let f={"com.google.chrome":"chrome","google-chrome.desktop":"chrome","com.brave.Browser":"brave","org.mozilla.firefox":"firefox","firefox.desktop":"firefox","com.microsoft.msedge":"edge","com.microsoft.edge":"edge","com.microsoft.edgemac":"edge","microsoft-edge.desktop":"edge"},u={chrome:"--incognito",brave:"--incognito",firefox:"--private-window",edge:"--inPrivate"},d=Dr?await vy():await kc();if(d.id in f){let g=f[d.id];return e==="browserPrivate"&&t.push(u[g]),Ts({...r,app:{name:Mr[g],arguments:t}})}throw new Error(`${d.name} is not supported as a default browser`)}let n,s=[],i={};if(Hn==="darwin")n="open",r.wait&&s.push("--wait-apps"),r.background&&s.push("--background"),r.newInstance&&s.push("--new"),e&&s.push("-a",e);else if(Hn==="win32"||Dr&&!Wn()&&!e){n=await xc(),s.push("-NoProfile","-NonInteractive","-ExecutionPolicy","Bypass","-EncodedCommand"),Dr||(i.windowsVerbatimArguments=!0);let f=["Start"];r.wait&&f.push("-Wait"),e?(f.push(`"\`"${e}\`""`),r.target&&t.push(r.target)):r.target&&f.push(`"${r.target}"`),t.length>0&&(t=t.map(u=>`"\`"${u}\`""`),f.push("-ArgumentList",t.join(","))),r.target=Ac.Buffer.from(f.join(" "),"utf16le").toString("base64")}else{if(e)n=e;else{let f=!Pc||Pc==="/",u=!1;try{await Xi.default.access(jh,Xi.constants.X_OK),u=!0}catch{}n=Rc.default.versions.electron??(Hn==="android"||f||!u)?"xdg-open":jh}t.length>0&&s.push(...t),r.wait||(i.stdio="ignore",i.detached=!0)}Hn==="darwin"&&t.length>0&&s.push("--args",...t),r.target&&s.push(r.target);let a=Lc.default.spawn(n,s,i);return r.wait?new Promise((f,u)=>{a.once("error",u),a.once("close",d=>{if(!r.allowNonzeroExitCode&&d>0){u(new Error(`Exited with code ${d}`));return}f(a)})}):(a.unref(),a)},xy=(r,e)=>{if(typeof r!="string")throw new TypeError("Expected a `target`");return Ts({...e,target:r})},by=(r,e)=>{if(typeof r!="string"&&!Array.isArray(r))throw new TypeError("Expected a valid `name`");let{arguments:t=[]}=e??{};if(t!=null&&!Array.isArray(t))throw new TypeError("Expected `appArguments` as Array type");return Ts({...e,app:{name:r,arguments:t}})};Mr={};Fr(Mr,"chrome",()=>Ji({darwin:"google chrome",win32:"chrome",linux:["google-chrome","google-chrome-stable","chromium"]},{wsl:{ia32:"/mnt/c/Program Files (x86)/Google/Chrome/Application/chrome.exe",x64:["/mnt/c/Program Files/Google/Chrome/Application/chrome.exe","/mnt/c/Program Files (x86)/Google/Chrome/Application/chrome.exe"]}}));Fr(Mr,"brave",()=>Ji({darwin:"brave browser",win32:"brave",linux:["brave-browser","brave"]},{wsl:{ia32:"/mnt/c/Program Files (x86)/BraveSoftware/Brave-Browser/Application/brave.exe",x64:["/mnt/c/Program Files/BraveSoftware/Brave-Browser/Application/brave.exe","/mnt/c/Program Files (x86)/BraveSoftware/Brave-Browser/Application/brave.exe"]}}));Fr(Mr,"firefox",()=>Ji({darwin:"firefox",win32:String.raw`C:\Program Files\Mozilla Firefox\firefox.exe`,linux:"firefox"},{wsl:"/mnt/c/Program Files/Mozilla Firefox/firefox.exe"}));Fr(Mr,"edge",()=>Ji({darwin:"microsoft edge",win32:"msedge",linux:["microsoft-edge","microsoft-edge-dev"]},{wsl:"/mnt/c/Program Files (x86)/Microsoft/Edge/Application/msedge.exe"}));Fr(Mr,"browser",()=>"browser");Fr(Mr,"browserPrivate",()=>"browserPrivate");Sy=xy});var ir=me(require("fs")),Bs=me(require("path"));var Zc=me(require("os")),Qc=me(require("path")),Fs=me(require("fs"));function Ms(){let r=Qc.join(Zc.homedir(),".termiq");return Fs.existsSync(r)||Fs.mkdirSync(r,{recursive:!0,mode:448}),r}var Xn=class{filePath;data={};constructor(){this.filePath=Bs.join(Ms(),"credentials"),this.load()}async get(e){return this.data[e]}async set(e,t){this.data[e]=t,this.save()}async delete(e){delete this.data[e],this.save()}load(){try{if(ir.existsSync(this.filePath)){let e=ir.readFileSync(this.filePath,"utf-8");this.data=JSON.parse(e)}}catch{this.data={}}}save(){let e=Bs.dirname(this.filePath);ir.existsSync(e)||ir.mkdirSync(e,{recursive:!0,mode:448}),ir.writeFileSync(this.filePath,JSON.stringify(this.data,null,2),{mode:384})}};var or=me(require("fs")),js=me(require("path"));var Dd={serverUrl:"https://termiq.io",agentName:""},Jn=class{config;filePath;constructor(e){this.filePath=js.join(Ms(),"config.json"),this.config={...Dd,...this.loadFromFile(),...e}}getServerUrl(){return this.config.serverUrl}getAgentName(){return this.config.agentName}isAutoConnect(){return!0}async setAgentName(e){this.config.agentName=e,this.saveToFile()}loadFromFile(){try{if(or.existsSync(this.filePath)){let e=or.readFileSync(this.filePath,"utf-8");return JSON.parse(e)}}catch{}return{}}saveToFile(){let e=js.dirname(this.filePath);or.existsSync(e)||or.mkdirSync(e,{recursive:!0,mode:448}),or.writeFileSync(this.filePath,JSON.stringify(this.config,null,2))}};var dt=me(require("fs")),lc=me(require("path")),ph=me(require("os")),zi=me(Es()),oy="cli",uc=lc.join(ph.homedir(),".termiq","logs"),Nr=lc.join(uc,"cli.log"),ay=5*1024*1024,dh=3;function cy(){try{if(!dt.existsSync(Nr)||dt.statSync(Nr).size<ay)return;for(let e=dh-1;e>=1;e--){let t=`${Nr}.${e}`,n=`${Nr}.${e+1}`;dt.existsSync(t)&&(e+1>dh?dt.unlinkSync(t):dt.renameSync(t,n))}dt.renameSync(Nr,`${Nr}.1`)}catch{}}function fy(r){try{dt.existsSync(uc)||dt.mkdirSync(uc,{recursive:!0}),cy(),dt.appendFileSync(Nr,r+`
|
|
32
|
+
`,{encoding:"utf8"})}catch{}}var ws=class{level;toFile;constructor(e="silent",t=!1){typeof e=="boolean"?this.level=e?"info":"silent":this.level=e,this.toFile=t}static getLogFilePath(){return Nr}write(e,t,n){if(!(0,zi.shouldLog)(e,this.level))return;let s=(0,zi.formatLogLine)(e,oy,t,n);process.stderr.write(s+`
|
|
33
|
+
`),this.toFile&&fy(s)}info(e,...t){this.write("info",e,t)}warn(e,...t){this.write("warn",e,t)}error(e,...t){this.write("error",e,t)}debug(e,...t){this.write("debug",e,t)}};var gh=me(require("os")),_h=me(dc()),xs=class{cachedId=null;name;constructor(e){this.name=e||gh.hostname()||"CLI"}async getMachineId(){if(this.cachedId)return this.cachedId;try{this.cachedId=(0,_h.machineIdSync)()}catch{this.cachedId=`cli_${Date.now()}_${Math.random().toString(36).slice(2,9)}`}return this.cachedId}getMachineName(){return this.name}};var bs=class{info(e){process.stderr.write(`TermIQ: ${e}
|
|
36
34
|
`)}warn(e){process.stderr.write(`TermIQ [warn]: ${e}
|
|
37
35
|
`)}error(e){process.stderr.write(`TermIQ [error]: ${e}
|
|
38
|
-
`)}};var es=class{async openUrl(e){let{default:t}=await Promise.resolve().then(()=>(vf(),xf));await t(e)}};var nd=we(require("path")),pt=we($i());var Ih=we(require("os")),Nh=we(require("node-pty")),Lh=we($i()),zi=class{ptyProcess=null;outputBuffer=new Lh.CircularBuffer(100);logger;onOutput=null;onExit=null;constructor(e){this.logger=e}spawn(e){let t=process.env.SHELL||(Ih.platform()==="win32"?"powershell.exe":"/bin/bash"),n=process.stdout.columns||80,s=process.stdout.rows||24;this.ptyProcess=Nh.spawn(t,[],{name:"xterm-256color",cols:n,rows:s,cwd:e,env:process.env});let i=`cli_${this.ptyProcess.pid}`;return this.ptyProcess.onData(a=>{process.stdout.write(a),this.outputBuffer.append(a),this.onOutput?.(a)}),this.ptyProcess.onExit(({exitCode:a})=>{this.logger.info("Shell exited",String(a)),this.onExit?.(a)}),process.stdin.isTTY&&process.stdin.setRawMode(!0),process.stdin.resume(),process.stdin.on("data",a=>{this.ptyProcess?.write(a.toString())}),process.on("SIGWINCH",()=>{let a=process.stdout.columns||80,f=process.stdout.rows||24;this.ptyProcess?.resize(a,f)}),this.logger.info("Shell spawned",t,i),i}write(e){this.ptyProcess?.write(e)}resize(e,t){this.ptyProcess?.resize(e,t)}getBuffer(){return this.outputBuffer.getContent()}getLastBytes(e){return this.outputBuffer.getLastBytes(e)}setOnOutput(e){this.onOutput=e}setOnExit(e){this.onExit=e}kill(){this.ptyProcess?.kill(),this.ptyProcess=null}dispose(){this.kill(),process.stdin.isTTY&&process.stdin.setRawMode(!1),process.stdin.pause()}};var Dr=we(require("path")),qn=we(require("fs"));var Xh=require("node:events"),Jh=require("node:fs"),to=require("node:fs/promises"),Ee=we(require("node:path"),1);var _r=require("node:fs/promises"),mr=require("node:path"),Bh=require("node:stream"),vt={FILE_TYPE:"files",DIR_TYPE:"directories",FILE_DIR_TYPE:"files_directories",EVERYTHING_TYPE:"all"},Tc={root:".",fileFilter:r=>!0,directoryFilter:r=>!0,type:vt.FILE_TYPE,lstat:!1,depth:2147483648,alwaysStat:!1,highWaterMark:4096};Object.freeze(Tc);var jh="READDIRP_RECURSIVE_ERROR",iy=new Set(["ENOENT","EPERM","EACCES","ELOOP",jh]),Dh=[vt.DIR_TYPE,vt.EVERYTHING_TYPE,vt.FILE_DIR_TYPE,vt.FILE_TYPE],oy=new Set([vt.DIR_TYPE,vt.EVERYTHING_TYPE,vt.FILE_DIR_TYPE]),ay=new Set([vt.EVERYTHING_TYPE,vt.FILE_DIR_TYPE,vt.FILE_TYPE]),cy=r=>iy.has(r.code),fy=process.platform==="win32",Fh=r=>!0,Mh=r=>{if(r===void 0)return Fh;if(typeof r=="function")return r;if(typeof r=="string"){let e=r.trim();return t=>t.basename===e}if(Array.isArray(r)){let e=r.map(t=>t.trim());return t=>e.some(n=>t.basename===n)}return Fh},Oc=class extends Bh.Readable{parents;reading;parent;_stat;_maxDepth;_wantsDir;_wantsFile;_wantsEverything;_root;_isDirent;_statsProp;_rdOptions;_fileFilter;_directoryFilter;constructor(e={}){super({objectMode:!0,autoDestroy:!0,highWaterMark:e.highWaterMark});let t={...Tc,...e},{root:n,type:s}=t;this._fileFilter=Mh(t.fileFilter),this._directoryFilter=Mh(t.directoryFilter);let i=t.lstat?_r.lstat:_r.stat;fy?this._stat=a=>i(a,{bigint:!0}):this._stat=i,this._maxDepth=t.depth!=null&&Number.isSafeInteger(t.depth)?t.depth:Tc.depth,this._wantsDir=s?oy.has(s):!1,this._wantsFile=s?ay.has(s):!1,this._wantsEverything=s===vt.EVERYTHING_TYPE,this._root=(0,mr.resolve)(n),this._isDirent=!t.alwaysStat,this._statsProp=this._isDirent?"dirent":"stats",this._rdOptions={encoding:"utf8",withFileTypes:this._isDirent},this.parents=[this._exploreDir(n,1)],this.reading=!1,this.parent=void 0}async _read(e){if(!this.reading){this.reading=!0;try{for(;!this.destroyed&&e>0;){let t=this.parent,n=t&&t.files;if(n&&n.length>0){let{path:s,depth:i}=t,a=n.splice(0,e).map(u=>this._formatEntry(u,s)),f=await Promise.all(a);for(let u of f){if(!u)continue;if(this.destroyed)return;let d=await this._getEntryType(u);d==="directory"&&this._directoryFilter(u)?(i<=this._maxDepth&&this.parents.push(this._exploreDir(u.fullPath,i+1)),this._wantsDir&&(this.push(u),e--)):(d==="file"||this._includeAsFile(u))&&this._fileFilter(u)&&this._wantsFile&&(this.push(u),e--)}}else{let s=this.parents.pop();if(!s){this.push(null);break}if(this.parent=await s,this.destroyed)return}}}catch(t){this.destroy(t)}finally{this.reading=!1}}}async _exploreDir(e,t){let n;try{n=await(0,_r.readdir)(e,this._rdOptions)}catch(s){this._onError(s)}return{files:n,depth:t,path:e}}async _formatEntry(e,t){let n,s=this._isDirent?e.name:e;try{let i=(0,mr.resolve)((0,mr.join)(t,s));n={path:(0,mr.relative)(this._root,i),fullPath:i,basename:s},n[this._statsProp]=this._isDirent?e:await this._stat(i)}catch(i){this._onError(i);return}return n}_onError(e){cy(e)&&!this.destroyed?this.emit("warn",e):this.destroy(e)}async _getEntryType(e){if(!e&&this._statsProp in e)return"";let t=e[this._statsProp];if(t.isFile())return"file";if(t.isDirectory())return"directory";if(t&&t.isSymbolicLink()){let n=e.fullPath;try{let s=await(0,_r.realpath)(n),i=await(0,_r.lstat)(s);if(i.isFile())return"file";if(i.isDirectory()){let a=s.length;if(n.startsWith(s)&&n.substr(a,1)===mr.sep){let f=new Error(`Circular symlink detected: "${n}" points to "${s}"`);return f.code=jh,this._onError(f)}return"directory"}}catch(s){return this._onError(s),""}}}_includeAsFile(e){let t=e&&e[this._statsProp];return t&&this._wantsEverything&&!t.isDirectory()}};function Uh(r,e={}){let t=e.entryType||e.type;if(t==="both"&&(t=vt.FILE_DIR_TYPE),t&&(e.type=t),r){if(typeof r!="string")throw new TypeError("readdirp: root argument must be a string. Usage: readdirp(root, options)");if(t&&!Dh.includes(t))throw new Error(`readdirp: Invalid type passed. Use one of ${Dh.join(", ")}`)}else throw new Error("readdirp: root argument is required. Usage: readdirp(root, options)");return e.root=r,new Oc(e)}var cn=require("node:fs"),Ut=require("node:fs/promises"),Wh=require("node:os"),Ue=we(require("node:path"),1),uy="data",Pc="end",Hh="close",Zi=()=>{};var Qi=process.platform,Rc=Qi==="win32",ly=Qi==="darwin",hy=Qi==="linux",dy=Qi==="freebsd",Vh=(0,Wh.type)()==="OS400",We={ALL:"all",READY:"ready",ADD:"add",CHANGE:"change",ADD_DIR:"addDir",UNLINK:"unlink",UNLINK_DIR:"unlinkDir",RAW:"raw",ERROR:"error"},jt=We,py="watch",gy={lstat:Ut.lstat,stat:Ut.stat},an="listeners",Gi="errHandlers",Un="rawEmitters",_y=[an,Gi,Un],my=new Set(["3dm","3ds","3g2","3gp","7z","a","aac","adp","afdesign","afphoto","afpub","ai","aif","aiff","alz","ape","apk","appimage","ar","arj","asf","au","avi","bak","baml","bh","bin","bk","bmp","btif","bz2","bzip2","cab","caf","cgm","class","cmx","cpio","cr2","cur","dat","dcm","deb","dex","djvu","dll","dmg","dng","doc","docm","docx","dot","dotm","dra","DS_Store","dsk","dts","dtshd","dvb","dwg","dxf","ecelp4800","ecelp7470","ecelp9600","egg","eol","eot","epub","exe","f4v","fbs","fh","fla","flac","flatpak","fli","flv","fpx","fst","fvt","g3","gh","gif","graffle","gz","gzip","h261","h263","h264","icns","ico","ief","img","ipa","iso","jar","jpeg","jpg","jpgv","jpm","jxr","key","ktx","lha","lib","lvp","lz","lzh","lzma","lzo","m3u","m4a","m4v","mar","mdi","mht","mid","midi","mj2","mka","mkv","mmr","mng","mobi","mov","movie","mp3","mp4","mp4a","mpeg","mpg","mpga","mxu","nef","npx","numbers","nupkg","o","odp","ods","odt","oga","ogg","ogv","otf","ott","pages","pbm","pcx","pdb","pdf","pea","pgm","pic","png","pnm","pot","potm","potx","ppa","ppam","ppm","pps","ppsm","ppsx","ppt","pptm","pptx","psd","pya","pyc","pyo","pyv","qt","rar","ras","raw","resources","rgb","rip","rlc","rmf","rmvb","rpm","rtf","rz","s3m","s7z","scpt","sgi","shar","snap","sil","sketch","slk","smv","snk","so","stl","suo","sub","swf","tar","tbz","tbz2","tga","tgz","thmx","tif","tiff","tlz","ttc","ttf","txz","udf","uvh","uvi","uvm","uvp","uvs","uvu","viv","vob","war","wav","wax","wbmp","wdp","weba","webm","webp","whl","wim","wm","wma","wmv","wmx","woff","woff2","wrm","wvx","xbm","xif","xla","xlam","xls","xlsb","xlsm","xlsx","xlt","xltm","xltx","xm","xmind","xpi","xpm","xwd","xz","z","zip","zipx"]),yy=r=>my.has(Ue.extname(r).slice(1).toLowerCase()),kc=(r,e)=>{r instanceof Set?r.forEach(e):e(r)},vs=(r,e,t)=>{let n=r[e];n instanceof Set||(r[e]=n=new Set([n])),n.add(t)},Ey=r=>e=>{let t=r[e];t instanceof Set?t.clear():delete r[e]},bs=(r,e,t)=>{let n=r[e];n instanceof Set?n.delete(t):n===t&&delete r[e]},Kh=r=>r instanceof Set?r.size===0:!r,Yi=new Map;function qh(r,e,t,n,s){let i=(a,f)=>{t(r),s(a,f,{watchedPath:r}),f&&r!==f&&Xi(Ue.resolve(r,f),an,Ue.join(r,f))};try{return(0,cn.watch)(r,{persistent:e.persistent},i)}catch(a){n(a);return}}var Xi=(r,e,t,n,s)=>{let i=Yi.get(r);i&&kc(i[e],a=>{a(t,n,s)})},wy=(r,e,t,n)=>{let{listener:s,errHandler:i,rawEmitter:a}=n,f=Yi.get(e),u;if(!t.persistent)return u=qh(r,t,s,i,a),u?u.close.bind(u):void 0;if(f)vs(f,an,s),vs(f,Gi,i),vs(f,Un,a);else{if(u=qh(r,t,Xi.bind(null,e,an),i,Xi.bind(null,e,Un)),!u)return;u.on(jt.ERROR,async d=>{let g=Xi.bind(null,e,Gi);if(f&&(f.watcherUnusable=!0),Rc&&d.code==="EPERM")try{await(await(0,Ut.open)(r,"r")).close(),g(d)}catch{}else g(d)}),f={listeners:s,errHandlers:i,rawEmitters:a,watcher:u},Yi.set(e,f)}return()=>{bs(f,an,s),bs(f,Gi,i),bs(f,Un,a),Kh(f.listeners)&&(f.watcher.close(),Yi.delete(e),_y.forEach(Ey(f)),f.watcher=void 0,Object.freeze(f))}},Cc=new Map,xy=(r,e,t,n)=>{let{listener:s,rawEmitter:i}=n,a=Cc.get(e),f=a&&a.options;return f&&(f.persistent<t.persistent||f.interval>t.interval)&&((0,cn.unwatchFile)(e),a=void 0),a?(vs(a,an,s),vs(a,Un,i)):(a={listeners:s,rawEmitters:i,options:t,watcher:(0,cn.watchFile)(e,t,(u,d)=>{kc(a.rawEmitters,_=>{_(jt.CHANGE,e,{curr:u,prev:d})});let g=u.mtimeMs;(u.size!==d.size||g>d.mtimeMs||g===0)&&kc(a.listeners,_=>_(r,u))})},Cc.set(e,a)),()=>{bs(a,an,s),bs(a,Un,i),Kh(a.listeners)&&(Cc.delete(e),(0,cn.unwatchFile)(e),a.options=a.watcher=void 0,Object.freeze(a))}},Ji=class{fsw;_boundHandleError;constructor(e){this.fsw=e,this._boundHandleError=t=>e._handleError(t)}_watchWithNodeFs(e,t){let n=this.fsw.options,s=Ue.dirname(e),i=Ue.basename(e);this.fsw._getWatchedDir(s).add(i);let f=Ue.resolve(e),u={persistent:n.persistent};t||(t=Zi);let d;if(n.usePolling){let g=n.interval!==n.binaryInterval;u.interval=g&&yy(i)?n.binaryInterval:n.interval,d=xy(e,f,u,{listener:t,rawEmitter:this.fsw._emitRaw})}else d=wy(e,f,u,{listener:t,errHandler:this._boundHandleError,rawEmitter:this.fsw._emitRaw});return d}_handleFile(e,t,n){if(this.fsw.closed)return;let s=Ue.dirname(e),i=Ue.basename(e),a=this.fsw._getWatchedDir(s),f=t;if(a.has(i))return;let u=async(g,_)=>{if(this.fsw._throttle(py,e,5)){if(!_||_.mtimeMs===0)try{let y=await(0,Ut.stat)(e);if(this.fsw.closed)return;let x=y.atimeMs,S=y.mtimeMs;if((!x||x<=S||S!==f.mtimeMs)&&this.fsw._emit(jt.CHANGE,e,y),(ly||hy||dy)&&f.ino!==y.ino){this.fsw._closeFile(g),f=y;let C=this._watchWithNodeFs(e,u);C&&this.fsw._addPathCloser(g,C)}else f=y}catch{this.fsw._remove(s,i)}else if(a.has(i)){let y=_.atimeMs,x=_.mtimeMs;(!y||y<=x||x!==f.mtimeMs)&&this.fsw._emit(jt.CHANGE,e,_),f=_}}},d=this._watchWithNodeFs(e,u);if(!(n&&this.fsw.options.ignoreInitial)&&this.fsw._isntIgnored(e)){if(!this.fsw._throttle(jt.ADD,e,0))return;this.fsw._emit(jt.ADD,e,t)}return d}async _handleSymlink(e,t,n,s){if(this.fsw.closed)return;let i=e.fullPath,a=this.fsw._getWatchedDir(t);if(!this.fsw.options.followSymlinks){this.fsw._incrReadyCount();let f;try{f=await(0,Ut.realpath)(n)}catch{return this.fsw._emitReady(),!0}return this.fsw.closed?void 0:(a.has(s)?this.fsw._symlinkPaths.get(i)!==f&&(this.fsw._symlinkPaths.set(i,f),this.fsw._emit(jt.CHANGE,n,e.stats)):(a.add(s),this.fsw._symlinkPaths.set(i,f),this.fsw._emit(jt.ADD,n,e.stats)),this.fsw._emitReady(),!0)}if(this.fsw._symlinkPaths.has(i))return!0;this.fsw._symlinkPaths.set(i,!0)}_handleRead(e,t,n,s,i,a,f){e=Ue.join(e,"");let u=s?`${e}:${s}`:e;if(f=this.fsw._throttle("readdir",u,1e3),!f)return;let d=this.fsw._getWatchedDir(n.path),g=new Set,_=this.fsw._readdirp(e,{fileFilter:y=>n.filterPath(y),directoryFilter:y=>n.filterDir(y)});if(_)return _.on(uy,async y=>{if(this.fsw.closed){_=void 0;return}let x=y.path,S=Ue.join(e,x);if(g.add(x),!(y.stats.isSymbolicLink()&&await this._handleSymlink(y,e,S,x))){if(this.fsw.closed){_=void 0;return}(x===s||!s&&!d.has(x))&&(this.fsw._incrReadyCount(),S=Ue.join(i,Ue.relative(i,S)),this._addToNodeFs(S,t,n,a+1))}}).on(jt.ERROR,this._boundHandleError),new Promise((y,x)=>{if(!_)return x();_.once(Pc,()=>{if(this.fsw.closed){_=void 0;return}let S=f?f.clear():!1;y(void 0),d.getChildren().filter(C=>C!==e&&!g.has(C)).forEach(C=>{this.fsw._remove(e,C)}),_=void 0,S&&this._handleRead(e,!1,n,s,i,a,f)})})}async _handleDir(e,t,n,s,i,a,f){let u=this.fsw._getWatchedDir(Ue.dirname(e)),d=u.has(Ue.basename(e));!(n&&this.fsw.options.ignoreInitial)&&!i&&!d&&this.fsw._emit(jt.ADD_DIR,e,t),u.add(Ue.basename(e)),this.fsw._getWatchedDir(e);let g,_,y=this.fsw.options.depth;if((y==null||s<=y)&&!this.fsw._symlinkPaths.has(f)){if(!i&&(await this._handleRead(e,n,a,i,e,s,g),this.fsw.closed))return;_=this._watchWithNodeFs(e,(x,S)=>{S&&S.mtimeMs===0||this._handleRead(x,!1,a,i,e,s,g)})}return _}async _addToNodeFs(e,t,n,s,i){let a=this.fsw._emitReady;if(this.fsw._isIgnored(e)||this.fsw.closed)return a(),!1;let f=this.fsw._getWatchHelpers(e);n&&(f.filterPath=u=>n.filterPath(u),f.filterDir=u=>n.filterDir(u));try{let u=await gy[f.statMethod](f.watchPath);if(this.fsw.closed)return;if(this.fsw._isIgnored(f.watchPath,u))return a(),!1;let d=this.fsw.options.followSymlinks,g;if(u.isDirectory()){let _=Ue.resolve(e),y=d?await(0,Ut.realpath)(e):e;if(this.fsw.closed||(g=await this._handleDir(f.watchPath,u,t,s,i,f,y),this.fsw.closed))return;_!==y&&y!==void 0&&this.fsw._symlinkPaths.set(_,y)}else if(u.isSymbolicLink()){let _=d?await(0,Ut.realpath)(e):e;if(this.fsw.closed)return;let y=Ue.dirname(f.watchPath);if(this.fsw._getWatchedDir(y).add(f.watchPath),this.fsw._emit(jt.ADD,f.watchPath,u),g=await this._handleDir(y,u,t,s,e,f,_),this.fsw.closed)return;_!==void 0&&this.fsw._symlinkPaths.set(Ue.resolve(e),_)}else g=this._handleFile(f.watchPath,u,t);return a(),g&&this.fsw._addPathCloser(e,g),!1}catch(u){if(this.fsw._handleError(u))return a(),e}}};var Ac="/",vy="//",Zh=".",by="..",Sy="string",Ty=/\\/g,Qh=/\/\//g,Oy=/\..*\.(sw[px])$|~$|\.subl.*\.tmp/,Cy=/^\.[/\\]/;function eo(r){return Array.isArray(r)?r:[r]}var Ic=r=>typeof r=="object"&&r!==null&&!(r instanceof RegExp);function ky(r){return typeof r=="function"?r:typeof r=="string"?e=>r===e:r instanceof RegExp?e=>r.test(e):typeof r=="object"&&r!==null?e=>{if(r.path===e)return!0;if(r.recursive){let t=Ee.relative(r.path,e);return t?!t.startsWith("..")&&!Ee.isAbsolute(t):!1}return!1}:()=>!1}function Py(r){if(typeof r!="string")throw new Error("string expected");r=Ee.normalize(r),r=r.replace(/\\/g,"/");let e=!1;return r.startsWith("//")&&(e=!0),r=r.replace(Qh,"/"),e&&(r="/"+r),r}function $h(r,e,t){let n=Py(e);for(let s=0;s<r.length;s++){let i=r[s];if(i(n,t))return!0}return!1}function Ry(r,e){if(r==null)throw new TypeError("anymatch: specify first argument");let n=eo(r).map(s=>ky(s));return e==null?(s,i)=>$h(n,s,i):$h(n,e)}var zh=r=>{let e=eo(r).flat();if(!e.every(t=>typeof t===Sy))throw new TypeError(`Non-string provided as watch path: ${e}`);return e.map(ed)},Gh=r=>{let e=r.replace(Ty,Ac),t=!1;return e.startsWith(vy)&&(t=!0),e=e.replace(Qh,Ac),t&&(e=Ac+e),e},ed=r=>Gh(Ee.normalize(Gh(r))),Yh=(r="")=>e=>typeof e=="string"?ed(Ee.isAbsolute(e)?e:Ee.join(r,e)):e,Ay=(r,e)=>Ee.isAbsolute(r)?r:Ee.join(e,r),Iy=Object.freeze(new Set),Nc=class{path;_removeWatcher;items;constructor(e,t){this.path=e,this._removeWatcher=t,this.items=new Set}add(e){let{items:t}=this;t&&e!==Zh&&e!==by&&t.add(e)}async remove(e){let{items:t}=this;if(!t||(t.delete(e),t.size>0))return;let n=this.path;try{await(0,to.readdir)(n)}catch{this._removeWatcher&&this._removeWatcher(Ee.dirname(n),Ee.basename(n))}}has(e){let{items:t}=this;if(t)return t.has(e)}getChildren(){let{items:e}=this;return e?[...e.values()]:[]}dispose(){this.items.clear(),this.path="",this._removeWatcher=Zi,this.items=Iy,Object.freeze(this)}},Ny="stat",Ly="lstat",Lc=class{fsw;path;watchPath;fullWatchPath;dirParts;followSymlinks;statMethod;constructor(e,t,n){this.fsw=n;let s=e;this.path=e=e.replace(Cy,""),this.watchPath=s,this.fullWatchPath=Ee.resolve(s),this.dirParts=[],this.dirParts.forEach(i=>{i.length>1&&i.pop()}),this.followSymlinks=t,this.statMethod=t?Ny:Ly}entryPath(e){return Ee.join(this.watchPath,Ee.relative(this.watchPath,e.fullPath))}filterPath(e){let{stats:t}=e;if(t&&t.isSymbolicLink())return this.filterDir(e);let n=this.entryPath(e);return this.fsw._isntIgnored(n,t)&&this.fsw._hasReadPermissions(t)}filterDir(e){return this.fsw._isntIgnored(this.entryPath(e),e.stats)}},Dc=class extends Xh.EventEmitter{closed;options;_closers;_ignoredPaths;_throttled;_streams;_symlinkPaths;_watched;_pendingWrites;_pendingUnlinks;_readyCount;_emitReady;_closePromise;_userIgnored;_readyEmitted;_emitRaw;_boundRemove;_nodeFsHandler;constructor(e={}){super(),this.closed=!1,this._closers=new Map,this._ignoredPaths=new Set,this._throttled=new Map,this._streams=new Set,this._symlinkPaths=new Map,this._watched=new Map,this._pendingWrites=new Map,this._pendingUnlinks=new Map,this._readyCount=0,this._readyEmitted=!1;let t=e.awaitWriteFinish,n={stabilityThreshold:2e3,pollInterval:100},s={persistent:!0,ignoreInitial:!1,ignorePermissionErrors:!1,interval:100,binaryInterval:300,followSymlinks:!0,usePolling:!1,atomic:!0,...e,ignored:e.ignored?eo(e.ignored):eo([]),awaitWriteFinish:t===!0?n:typeof t=="object"?{...n,...t}:!1};Vh&&(s.usePolling=!0),s.atomic===void 0&&(s.atomic=!s.usePolling);let i=process.env.CHOKIDAR_USEPOLLING;if(i!==void 0){let u=i.toLowerCase();u==="false"||u==="0"?s.usePolling=!1:u==="true"||u==="1"?s.usePolling=!0:s.usePolling=!!u}let a=process.env.CHOKIDAR_INTERVAL;a&&(s.interval=Number.parseInt(a,10));let f=0;this._emitReady=()=>{f++,f>=this._readyCount&&(this._emitReady=Zi,this._readyEmitted=!0,process.nextTick(()=>this.emit(We.READY)))},this._emitRaw=(...u)=>this.emit(We.RAW,...u),this._boundRemove=this._remove.bind(this),this.options=s,this._nodeFsHandler=new Ji(this),Object.freeze(s)}_addIgnoredPath(e){if(Ic(e)){for(let t of this._ignoredPaths)if(Ic(t)&&t.path===e.path&&t.recursive===e.recursive)return}this._ignoredPaths.add(e)}_removeIgnoredPath(e){if(this._ignoredPaths.delete(e),typeof e=="string")for(let t of this._ignoredPaths)Ic(t)&&t.path===e&&this._ignoredPaths.delete(t)}add(e,t,n){let{cwd:s}=this.options;this.closed=!1,this._closePromise=void 0;let i=zh(e);return s&&(i=i.map(a=>Ay(a,s))),i.forEach(a=>{this._removeIgnoredPath(a)}),this._userIgnored=void 0,this._readyCount||(this._readyCount=0),this._readyCount+=i.length,Promise.all(i.map(async a=>{let f=await this._nodeFsHandler._addToNodeFs(a,!n,void 0,0,t);return f&&this._emitReady(),f})).then(a=>{this.closed||a.forEach(f=>{f&&this.add(Ee.dirname(f),Ee.basename(t||f))})}),this}unwatch(e){if(this.closed)return this;let t=zh(e),{cwd:n}=this.options;return t.forEach(s=>{!Ee.isAbsolute(s)&&!this._closers.has(s)&&(n&&(s=Ee.join(n,s)),s=Ee.resolve(s)),this._closePath(s),this._addIgnoredPath(s),this._watched.has(s)&&this._addIgnoredPath({path:s,recursive:!0}),this._userIgnored=void 0}),this}close(){if(this._closePromise)return this._closePromise;this.closed=!0,this.removeAllListeners();let e=[];return this._closers.forEach(t=>t.forEach(n=>{let s=n();s instanceof Promise&&e.push(s)})),this._streams.forEach(t=>t.destroy()),this._userIgnored=void 0,this._readyCount=0,this._readyEmitted=!1,this._watched.forEach(t=>t.dispose()),this._closers.clear(),this._watched.clear(),this._streams.clear(),this._symlinkPaths.clear(),this._throttled.clear(),this._closePromise=e.length?Promise.all(e).then(()=>{}):Promise.resolve(),this._closePromise}getWatched(){let e={};return this._watched.forEach((t,n)=>{let i=(this.options.cwd?Ee.relative(this.options.cwd,n):n)||Zh;e[i]=t.getChildren().sort()}),e}emitWithAll(e,t){this.emit(e,...t),e!==We.ERROR&&this.emit(We.ALL,e,...t)}async _emit(e,t,n){if(this.closed)return;let s=this.options;Rc&&(t=Ee.normalize(t)),s.cwd&&(t=Ee.relative(s.cwd,t));let i=[t];n!=null&&i.push(n);let a=s.awaitWriteFinish,f;if(a&&(f=this._pendingWrites.get(t)))return f.lastChange=new Date,this;if(s.atomic){if(e===We.UNLINK)return this._pendingUnlinks.set(t,[e,...i]),setTimeout(()=>{this._pendingUnlinks.forEach((u,d)=>{this.emit(...u),this.emit(We.ALL,...u),this._pendingUnlinks.delete(d)})},typeof s.atomic=="number"?s.atomic:100),this;e===We.ADD&&this._pendingUnlinks.has(t)&&(e=We.CHANGE,this._pendingUnlinks.delete(t))}if(a&&(e===We.ADD||e===We.CHANGE)&&this._readyEmitted){let u=(d,g)=>{d?(e=We.ERROR,i[0]=d,this.emitWithAll(e,i)):g&&(i.length>1?i[1]=g:i.push(g),this.emitWithAll(e,i))};return this._awaitWriteFinish(t,a.stabilityThreshold,e,u),this}if(e===We.CHANGE&&!this._throttle(We.CHANGE,t,50))return this;if(s.alwaysStat&&n===void 0&&(e===We.ADD||e===We.ADD_DIR||e===We.CHANGE)){let u=s.cwd?Ee.join(s.cwd,t):t,d;try{d=await(0,to.stat)(u)}catch{}if(!d||this.closed)return;i.push(d)}return this.emitWithAll(e,i),this}_handleError(e){let t=e&&e.code;return e&&t!=="ENOENT"&&t!=="ENOTDIR"&&(!this.options.ignorePermissionErrors||t!=="EPERM"&&t!=="EACCES")&&this.emit(We.ERROR,e),e||this.closed}_throttle(e,t,n){this._throttled.has(e)||this._throttled.set(e,new Map);let s=this._throttled.get(e);if(!s)throw new Error("invalid throttle");let i=s.get(t);if(i)return i.count++,!1;let a,f=()=>{let d=s.get(t),g=d?d.count:0;return s.delete(t),clearTimeout(a),d&&clearTimeout(d.timeoutObject),g};a=setTimeout(f,n);let u={timeoutObject:a,clear:f,count:0};return s.set(t,u),u}_incrReadyCount(){return this._readyCount++}_awaitWriteFinish(e,t,n,s){let i=this.options.awaitWriteFinish;if(typeof i!="object")return;let a=i.pollInterval,f,u=e;this.options.cwd&&!Ee.isAbsolute(e)&&(u=Ee.join(this.options.cwd,e));let d=new Date,g=this._pendingWrites;function _(y){(0,Jh.stat)(u,(x,S)=>{if(x||!g.has(e)){x&&x.code!=="ENOENT"&&s(x);return}let C=Number(new Date);y&&S.size!==y.size&&(g.get(e).lastChange=C);let H=g.get(e);C-H.lastChange>=t?(g.delete(e),s(void 0,S)):f=setTimeout(_,a,S)})}g.has(e)||(g.set(e,{lastChange:d,cancelWait:()=>(g.delete(e),clearTimeout(f),n)}),f=setTimeout(_,a))}_isIgnored(e,t){if(this.options.atomic&&Oy.test(e))return!0;if(!this._userIgnored){let{cwd:n}=this.options,i=(this.options.ignored||[]).map(Yh(n)),f=[...[...this._ignoredPaths].map(Yh(n)),...i];this._userIgnored=Ry(f,void 0)}return this._userIgnored(e,t)}_isntIgnored(e,t){return!this._isIgnored(e,t)}_getWatchHelpers(e){return new Lc(e,this.options.followSymlinks,this)}_getWatchedDir(e){let t=Ee.resolve(e);return this._watched.has(t)||this._watched.set(t,new Nc(t,this._boundRemove)),this._watched.get(t)}_hasReadPermissions(e){return this.options.ignorePermissionErrors?!0:!!(Number(e.mode)&256)}_remove(e,t,n){let s=Ee.join(e,t),i=Ee.resolve(s);if(n=n??(this._watched.has(s)||this._watched.has(i)),!this._throttle("remove",s,100))return;!n&&this._watched.size===1&&this.add(e,t,!0),this._getWatchedDir(s).getChildren().forEach(y=>this._remove(s,y));let u=this._getWatchedDir(e),d=u.has(t);u.remove(t),this._symlinkPaths.has(i)&&this._symlinkPaths.delete(i);let g=s;if(this.options.cwd&&(g=Ee.relative(this.options.cwd,s)),this.options.awaitWriteFinish&&this._pendingWrites.has(g)&&this._pendingWrites.get(g).cancelWait()===We.ADD)return;this._watched.delete(s),this._watched.delete(i);let _=n?We.UNLINK_DIR:We.UNLINK;d&&!this._isIgnored(s)&&this._emit(_,s),this._closePath(s)}_closePath(e){this._closeFile(e);let t=Ee.dirname(e);this._getWatchedDir(t).remove(Ee.basename(e))}_closeFile(e){let t=this._closers.get(e);t&&(t.forEach(n=>n()),this._closers.delete(e))}_addPathCloser(e,t){if(!t)return;let n=this._closers.get(e);n||(n=[],this._closers.set(e,n)),n.push(t)}_readdirp(e,t){if(this.closed)return;let n={type:We.ALL,alwaysStat:!0,lstat:!0,...t,depth:0},s=Uh(e,n);return this._streams.add(s),s.once(Hh,()=>{s=void 0}),s.once(Pc,()=>{s&&(this._streams.delete(s),s=void 0)}),s}};function td(r,e={}){let t=new Dc(e);return t.add(r),t}var rd=we(_c()),tr=we(Kr()),Dy=["**/node_modules/**","**/.git/**","**/dist/**","**/.next/**","**/.turbo/**","**/.cache/**","**/coverage/**","**/*.log"],Fy=300,ro=class{watcher=null;ignoreFilter;workspaceRoot;logger;onFileChangedCallback=null;pendingEvents=new Map;pendingTypes=new Map;constructor(e,t){this.logger=e,this.workspaceRoot=t,this.ignoreFilter=(0,rd.default)(),this.initializeIgnoreFilter()}initializeIgnoreFilter(){this.ignoreFilter.add(Dy);let e=Dr.join(this.workspaceRoot,".gitignore");try{if(qn.existsSync(e)){let t=qn.readFileSync(e,"utf-8");this.ignoreFilter.add(t)}}catch{}}onFileChanged(e){this.onFileChangedCallback=e}start(){this.watcher||(this.watcher=td(this.workspaceRoot,{ignored:e=>{let t=Dr.relative(this.workspaceRoot,e);if(!t||t===".")return!1;let n=t.split(Dr.sep).join("/");return this.ignoreFilter.ignores(n)},persistent:!0,ignoreInitial:!0,awaitWriteFinish:{stabilityThreshold:200,pollInterval:50}}),this.watcher.on("add",e=>this.handleEvent(e,tr.FileChangeType.CREATE)),this.watcher.on("change",e=>this.handleEvent(e,tr.FileChangeType.MODIFY)),this.watcher.on("unlink",e=>this.handleEvent(e,tr.FileChangeType.DELETE)),this.watcher.on("error",e=>this.logger.error("File watcher error",e)),this.logger.info("File watcher started"))}stop(){this.watcher?.close(),this.watcher=null;for(let e of this.pendingEvents.values())clearTimeout(e);this.pendingEvents.clear(),this.pendingTypes.clear()}handleEvent(e,t){let n=Dr.relative(this.workspaceRoot,e);if(!n)return;let s=this.pendingEvents.get(n);s&&clearTimeout(s);let i=this.pendingTypes.get(n);this.pendingTypes.set(n,this.mergeTypes(i,t));let a=setTimeout(()=>{this.emit(n,this.pendingTypes.get(n)||t),this.pendingEvents.delete(n),this.pendingTypes.delete(n)},Fy);this.pendingEvents.set(n,a)}mergeTypes(e,t){return e?t===tr.FileChangeType.DELETE||e===tr.FileChangeType.DELETE?tr.FileChangeType.DELETE:e===tr.FileChangeType.CREATE?tr.FileChangeType.CREATE:t:t}emit(e,t){let n={path:e,changeType:t,timestamp:new Date().toISOString(),source:"watcher"};if(t!==tr.FileChangeType.DELETE)try{let s=Dr.join(this.workspaceRoot,e),i=qn.statSync(s);n.size=i.size}catch{}this.onFileChangedCallback?.(n)}dispose(){this.stop(),this.onFileChangedCallback=null}};async function no(r,e,t,n){if(n)return process.stderr.write(`Logging in with API key...
|
|
36
|
+
`)}};var Os=class{async openUrl(e){let{default:t}=await Promise.resolve().then(()=>($h(),Kh));await t(e)}};var yd=me(require("path")),_t=me(Es());var zh=me(require("os")),Gh=me(require("node-pty")),Yh=me(Es()),Zi=class{ptyProcess=null;outputBuffer=new Yh.CircularBuffer(100);logger;onOutput=null;onExit=null;constructor(e){this.logger=e}spawn(e){let t=process.env.SHELL||(zh.platform()==="win32"?"powershell.exe":"/bin/bash"),n=process.stdout.columns||80,s=process.stdout.rows||24;this.ptyProcess=Gh.spawn(t,[],{name:"xterm-256color",cols:n,rows:s,cwd:e,env:process.env});let i=`cli_${this.ptyProcess.pid}`;return this.ptyProcess.onData(a=>{process.stdout.write(a),this.outputBuffer.append(a),this.onOutput?.(a)}),this.ptyProcess.onExit(({exitCode:a})=>{this.logger.info("Shell exited",String(a)),this.onExit?.(a)}),process.stdin.isTTY&&process.stdin.setRawMode(!0),process.stdin.resume(),process.stdin.on("data",a=>{this.ptyProcess?.write(a.toString())}),process.on("SIGWINCH",()=>{let a=process.stdout.columns||80,f=process.stdout.rows||24;this.ptyProcess?.resize(a,f)}),this.logger.info("Shell spawned",t,i),i}write(e){this.ptyProcess?.write(e)}resize(e,t){this.ptyProcess?.resize(e,t)}getBuffer(){return this.outputBuffer.getContent()}getLastBytes(e){return this.outputBuffer.getLastBytes(e)}setOnOutput(e){this.onOutput=e}setOnExit(e){this.onExit=e}kill(){this.ptyProcess?.kill(),this.ptyProcess=null}dispose(){this.kill(),process.stdin.isTTY&&process.stdin.setRawMode(!1),process.stdin.pause()}};var Br=me(require("path")),Kn=me(require("fs"));var ld=require("node:events"),hd=require("node:fs"),oo=require("node:fs/promises"),we=me(require("node:path"),1);var mr=require("node:fs/promises"),yr=require("node:path"),Qh=require("node:stream"),St={FILE_TYPE:"files",DIR_TYPE:"directories",FILE_DIR_TYPE:"files_directories",EVERYTHING_TYPE:"all"},Nc={root:".",fileFilter:r=>!0,directoryFilter:r=>!0,type:St.FILE_TYPE,lstat:!1,depth:2147483648,alwaysStat:!1,highWaterMark:4096};Object.freeze(Nc);var ed="READDIRP_RECURSIVE_ERROR",Oy=new Set(["ENOENT","EPERM","EACCES","ELOOP",ed]),Xh=[St.DIR_TYPE,St.EVERYTHING_TYPE,St.FILE_DIR_TYPE,St.FILE_TYPE],Cy=new Set([St.DIR_TYPE,St.EVERYTHING_TYPE,St.FILE_DIR_TYPE]),ky=new Set([St.EVERYTHING_TYPE,St.FILE_DIR_TYPE,St.FILE_TYPE]),Py=r=>Oy.has(r.code),Ry=process.platform==="win32",Jh=r=>!0,Zh=r=>{if(r===void 0)return Jh;if(typeof r=="function")return r;if(typeof r=="string"){let e=r.trim();return t=>t.basename===e}if(Array.isArray(r)){let e=r.map(t=>t.trim());return t=>e.some(n=>t.basename===n)}return Jh},Dc=class extends Qh.Readable{parents;reading;parent;_stat;_maxDepth;_wantsDir;_wantsFile;_wantsEverything;_root;_isDirent;_statsProp;_rdOptions;_fileFilter;_directoryFilter;constructor(e={}){super({objectMode:!0,autoDestroy:!0,highWaterMark:e.highWaterMark});let t={...Nc,...e},{root:n,type:s}=t;this._fileFilter=Zh(t.fileFilter),this._directoryFilter=Zh(t.directoryFilter);let i=t.lstat?mr.lstat:mr.stat;Ry?this._stat=a=>i(a,{bigint:!0}):this._stat=i,this._maxDepth=t.depth!=null&&Number.isSafeInteger(t.depth)?t.depth:Nc.depth,this._wantsDir=s?Cy.has(s):!1,this._wantsFile=s?ky.has(s):!1,this._wantsEverything=s===St.EVERYTHING_TYPE,this._root=(0,yr.resolve)(n),this._isDirent=!t.alwaysStat,this._statsProp=this._isDirent?"dirent":"stats",this._rdOptions={encoding:"utf8",withFileTypes:this._isDirent},this.parents=[this._exploreDir(n,1)],this.reading=!1,this.parent=void 0}async _read(e){if(!this.reading){this.reading=!0;try{for(;!this.destroyed&&e>0;){let t=this.parent,n=t&&t.files;if(n&&n.length>0){let{path:s,depth:i}=t,a=n.splice(0,e).map(u=>this._formatEntry(u,s)),f=await Promise.all(a);for(let u of f){if(!u)continue;if(this.destroyed)return;let d=await this._getEntryType(u);d==="directory"&&this._directoryFilter(u)?(i<=this._maxDepth&&this.parents.push(this._exploreDir(u.fullPath,i+1)),this._wantsDir&&(this.push(u),e--)):(d==="file"||this._includeAsFile(u))&&this._fileFilter(u)&&this._wantsFile&&(this.push(u),e--)}}else{let s=this.parents.pop();if(!s){this.push(null);break}if(this.parent=await s,this.destroyed)return}}}catch(t){this.destroy(t)}finally{this.reading=!1}}}async _exploreDir(e,t){let n;try{n=await(0,mr.readdir)(e,this._rdOptions)}catch(s){this._onError(s)}return{files:n,depth:t,path:e}}async _formatEntry(e,t){let n,s=this._isDirent?e.name:e;try{let i=(0,yr.resolve)((0,yr.join)(t,s));n={path:(0,yr.relative)(this._root,i),fullPath:i,basename:s},n[this._statsProp]=this._isDirent?e:await this._stat(i)}catch(i){this._onError(i);return}return n}_onError(e){Py(e)&&!this.destroyed?this.emit("warn",e):this.destroy(e)}async _getEntryType(e){if(!e&&this._statsProp in e)return"";let t=e[this._statsProp];if(t.isFile())return"file";if(t.isDirectory())return"directory";if(t&&t.isSymbolicLink()){let n=e.fullPath;try{let s=await(0,mr.realpath)(n),i=await(0,mr.lstat)(s);if(i.isFile())return"file";if(i.isDirectory()){let a=s.length;if(n.startsWith(s)&&n.substr(a,1)===yr.sep){let f=new Error(`Circular symlink detected: "${n}" points to "${s}"`);return f.code=ed,this._onError(f)}return"directory"}}catch(s){return this._onError(s),""}}}_includeAsFile(e){let t=e&&e[this._statsProp];return t&&this._wantsEverything&&!t.isDirectory()}};function td(r,e={}){let t=e.entryType||e.type;if(t==="both"&&(t=St.FILE_DIR_TYPE),t&&(e.type=t),r){if(typeof r!="string")throw new TypeError("readdirp: root argument must be a string. Usage: readdirp(root, options)");if(t&&!Xh.includes(t))throw new Error(`readdirp: Invalid type passed. Use one of ${Xh.join(", ")}`)}else throw new Error("readdirp: root argument is required. Usage: readdirp(root, options)");return e.root=r,new Dc(e)}var ln=require("node:fs"),qt=require("node:fs/promises"),nd=require("node:os"),qe=me(require("node:path"),1),Ay="data",Bc="end",sd="close",no=()=>{};var so=process.platform,jc=so==="win32",Iy=so==="darwin",Ly=so==="linux",Ny=so==="freebsd",id=(0,nd.type)()==="OS400",He={ALL:"all",READY:"ready",ADD:"add",CHANGE:"change",ADD_DIR:"addDir",UNLINK:"unlink",UNLINK_DIR:"unlinkDir",RAW:"raw",ERROR:"error"},Ut=He,Dy="watch",Fy={lstat:qt.lstat,stat:qt.stat},un="listeners",Qi="errHandlers",Vn="rawEmitters",My=[un,Qi,Vn],By=new Set(["3dm","3ds","3g2","3gp","7z","a","aac","adp","afdesign","afphoto","afpub","ai","aif","aiff","alz","ape","apk","appimage","ar","arj","asf","au","avi","bak","baml","bh","bin","bk","bmp","btif","bz2","bzip2","cab","caf","cgm","class","cmx","cpio","cr2","cur","dat","dcm","deb","dex","djvu","dll","dmg","dng","doc","docm","docx","dot","dotm","dra","DS_Store","dsk","dts","dtshd","dvb","dwg","dxf","ecelp4800","ecelp7470","ecelp9600","egg","eol","eot","epub","exe","f4v","fbs","fh","fla","flac","flatpak","fli","flv","fpx","fst","fvt","g3","gh","gif","graffle","gz","gzip","h261","h263","h264","icns","ico","ief","img","ipa","iso","jar","jpeg","jpg","jpgv","jpm","jxr","key","ktx","lha","lib","lvp","lz","lzh","lzma","lzo","m3u","m4a","m4v","mar","mdi","mht","mid","midi","mj2","mka","mkv","mmr","mng","mobi","mov","movie","mp3","mp4","mp4a","mpeg","mpg","mpga","mxu","nef","npx","numbers","nupkg","o","odp","ods","odt","oga","ogg","ogv","otf","ott","pages","pbm","pcx","pdb","pdf","pea","pgm","pic","png","pnm","pot","potm","potx","ppa","ppam","ppm","pps","ppsm","ppsx","ppt","pptm","pptx","psd","pya","pyc","pyo","pyv","qt","rar","ras","raw","resources","rgb","rip","rlc","rmf","rmvb","rpm","rtf","rz","s3m","s7z","scpt","sgi","shar","snap","sil","sketch","slk","smv","snk","so","stl","suo","sub","swf","tar","tbz","tbz2","tga","tgz","thmx","tif","tiff","tlz","ttc","ttf","txz","udf","uvh","uvi","uvm","uvp","uvs","uvu","viv","vob","war","wav","wax","wbmp","wdp","weba","webm","webp","whl","wim","wm","wma","wmv","wmx","woff","woff2","wrm","wvx","xbm","xif","xla","xlam","xls","xlsb","xlsm","xlsx","xlt","xltm","xltx","xm","xmind","xpi","xpm","xwd","xz","z","zip","zipx"]),jy=r=>By.has(qe.extname(r).slice(1).toLowerCase()),Mc=(r,e)=>{r instanceof Set?r.forEach(e):e(r)},Cs=(r,e,t)=>{let n=r[e];n instanceof Set||(r[e]=n=new Set([n])),n.add(t)},Uy=r=>e=>{let t=r[e];t instanceof Set?t.clear():delete r[e]},ks=(r,e,t)=>{let n=r[e];n instanceof Set?n.delete(t):n===t&&delete r[e]},od=r=>r instanceof Set?r.size===0:!r,eo=new Map;function rd(r,e,t,n,s){let i=(a,f)=>{t(r),s(a,f,{watchedPath:r}),f&&r!==f&&to(qe.resolve(r,f),un,qe.join(r,f))};try{return(0,ln.watch)(r,{persistent:e.persistent},i)}catch(a){n(a);return}}var to=(r,e,t,n,s)=>{let i=eo.get(r);i&&Mc(i[e],a=>{a(t,n,s)})},qy=(r,e,t,n)=>{let{listener:s,errHandler:i,rawEmitter:a}=n,f=eo.get(e),u;if(!t.persistent)return u=rd(r,t,s,i,a),u?u.close.bind(u):void 0;if(f)Cs(f,un,s),Cs(f,Qi,i),Cs(f,Vn,a);else{if(u=rd(r,t,to.bind(null,e,un),i,to.bind(null,e,Vn)),!u)return;u.on(Ut.ERROR,async d=>{let g=to.bind(null,e,Qi);if(f&&(f.watcherUnusable=!0),jc&&d.code==="EPERM")try{await(await(0,qt.open)(r,"r")).close(),g(d)}catch{}else g(d)}),f={listeners:s,errHandlers:i,rawEmitters:a,watcher:u},eo.set(e,f)}return()=>{ks(f,un,s),ks(f,Qi,i),ks(f,Vn,a),od(f.listeners)&&(f.watcher.close(),eo.delete(e),My.forEach(Uy(f)),f.watcher=void 0,Object.freeze(f))}},Fc=new Map,Wy=(r,e,t,n)=>{let{listener:s,rawEmitter:i}=n,a=Fc.get(e),f=a&&a.options;return f&&(f.persistent<t.persistent||f.interval>t.interval)&&((0,ln.unwatchFile)(e),a=void 0),a?(Cs(a,un,s),Cs(a,Vn,i)):(a={listeners:s,rawEmitters:i,options:t,watcher:(0,ln.watchFile)(e,t,(u,d)=>{Mc(a.rawEmitters,_=>{_(Ut.CHANGE,e,{curr:u,prev:d})});let g=u.mtimeMs;(u.size!==d.size||g>d.mtimeMs||g===0)&&Mc(a.listeners,_=>_(r,u))})},Fc.set(e,a)),()=>{ks(a,un,s),ks(a,Vn,i),od(a.listeners)&&(Fc.delete(e),(0,ln.unwatchFile)(e),a.options=a.watcher=void 0,Object.freeze(a))}},ro=class{fsw;_boundHandleError;constructor(e){this.fsw=e,this._boundHandleError=t=>e._handleError(t)}_watchWithNodeFs(e,t){let n=this.fsw.options,s=qe.dirname(e),i=qe.basename(e);this.fsw._getWatchedDir(s).add(i);let f=qe.resolve(e),u={persistent:n.persistent};t||(t=no);let d;if(n.usePolling){let g=n.interval!==n.binaryInterval;u.interval=g&&jy(i)?n.binaryInterval:n.interval,d=Wy(e,f,u,{listener:t,rawEmitter:this.fsw._emitRaw})}else d=qy(e,f,u,{listener:t,errHandler:this._boundHandleError,rawEmitter:this.fsw._emitRaw});return d}_handleFile(e,t,n){if(this.fsw.closed)return;let s=qe.dirname(e),i=qe.basename(e),a=this.fsw._getWatchedDir(s),f=t;if(a.has(i))return;let u=async(g,_)=>{if(this.fsw._throttle(Dy,e,5)){if(!_||_.mtimeMs===0)try{let y=await(0,qt.stat)(e);if(this.fsw.closed)return;let v=y.atimeMs,S=y.mtimeMs;if((!v||v<=S||S!==f.mtimeMs)&&this.fsw._emit(Ut.CHANGE,e,y),(Iy||Ly||Ny)&&f.ino!==y.ino){this.fsw._closeFile(g),f=y;let C=this._watchWithNodeFs(e,u);C&&this.fsw._addPathCloser(g,C)}else f=y}catch{this.fsw._remove(s,i)}else if(a.has(i)){let y=_.atimeMs,v=_.mtimeMs;(!y||y<=v||v!==f.mtimeMs)&&this.fsw._emit(Ut.CHANGE,e,_),f=_}}},d=this._watchWithNodeFs(e,u);if(!(n&&this.fsw.options.ignoreInitial)&&this.fsw._isntIgnored(e)){if(!this.fsw._throttle(Ut.ADD,e,0))return;this.fsw._emit(Ut.ADD,e,t)}return d}async _handleSymlink(e,t,n,s){if(this.fsw.closed)return;let i=e.fullPath,a=this.fsw._getWatchedDir(t);if(!this.fsw.options.followSymlinks){this.fsw._incrReadyCount();let f;try{f=await(0,qt.realpath)(n)}catch{return this.fsw._emitReady(),!0}return this.fsw.closed?void 0:(a.has(s)?this.fsw._symlinkPaths.get(i)!==f&&(this.fsw._symlinkPaths.set(i,f),this.fsw._emit(Ut.CHANGE,n,e.stats)):(a.add(s),this.fsw._symlinkPaths.set(i,f),this.fsw._emit(Ut.ADD,n,e.stats)),this.fsw._emitReady(),!0)}if(this.fsw._symlinkPaths.has(i))return!0;this.fsw._symlinkPaths.set(i,!0)}_handleRead(e,t,n,s,i,a,f){e=qe.join(e,"");let u=s?`${e}:${s}`:e;if(f=this.fsw._throttle("readdir",u,1e3),!f)return;let d=this.fsw._getWatchedDir(n.path),g=new Set,_=this.fsw._readdirp(e,{fileFilter:y=>n.filterPath(y),directoryFilter:y=>n.filterDir(y)});if(_)return _.on(Ay,async y=>{if(this.fsw.closed){_=void 0;return}let v=y.path,S=qe.join(e,v);if(g.add(v),!(y.stats.isSymbolicLink()&&await this._handleSymlink(y,e,S,v))){if(this.fsw.closed){_=void 0;return}(v===s||!s&&!d.has(v))&&(this.fsw._incrReadyCount(),S=qe.join(i,qe.relative(i,S)),this._addToNodeFs(S,t,n,a+1))}}).on(Ut.ERROR,this._boundHandleError),new Promise((y,v)=>{if(!_)return v();_.once(Bc,()=>{if(this.fsw.closed){_=void 0;return}let S=f?f.clear():!1;y(void 0),d.getChildren().filter(C=>C!==e&&!g.has(C)).forEach(C=>{this.fsw._remove(e,C)}),_=void 0,S&&this._handleRead(e,!1,n,s,i,a,f)})})}async _handleDir(e,t,n,s,i,a,f){let u=this.fsw._getWatchedDir(qe.dirname(e)),d=u.has(qe.basename(e));!(n&&this.fsw.options.ignoreInitial)&&!i&&!d&&this.fsw._emit(Ut.ADD_DIR,e,t),u.add(qe.basename(e)),this.fsw._getWatchedDir(e);let g,_,y=this.fsw.options.depth;if((y==null||s<=y)&&!this.fsw._symlinkPaths.has(f)){if(!i&&(await this._handleRead(e,n,a,i,e,s,g),this.fsw.closed))return;_=this._watchWithNodeFs(e,(v,S)=>{S&&S.mtimeMs===0||this._handleRead(v,!1,a,i,e,s,g)})}return _}async _addToNodeFs(e,t,n,s,i){let a=this.fsw._emitReady;if(this.fsw._isIgnored(e)||this.fsw.closed)return a(),!1;let f=this.fsw._getWatchHelpers(e);n&&(f.filterPath=u=>n.filterPath(u),f.filterDir=u=>n.filterDir(u));try{let u=await Fy[f.statMethod](f.watchPath);if(this.fsw.closed)return;if(this.fsw._isIgnored(f.watchPath,u))return a(),!1;let d=this.fsw.options.followSymlinks,g;if(u.isDirectory()){let _=qe.resolve(e),y=d?await(0,qt.realpath)(e):e;if(this.fsw.closed||(g=await this._handleDir(f.watchPath,u,t,s,i,f,y),this.fsw.closed))return;_!==y&&y!==void 0&&this.fsw._symlinkPaths.set(_,y)}else if(u.isSymbolicLink()){let _=d?await(0,qt.realpath)(e):e;if(this.fsw.closed)return;let y=qe.dirname(f.watchPath);if(this.fsw._getWatchedDir(y).add(f.watchPath),this.fsw._emit(Ut.ADD,f.watchPath,u),g=await this._handleDir(y,u,t,s,e,f,_),this.fsw.closed)return;_!==void 0&&this.fsw._symlinkPaths.set(qe.resolve(e),_)}else g=this._handleFile(f.watchPath,u,t);return a(),g&&this.fsw._addPathCloser(e,g),!1}catch(u){if(this.fsw._handleError(u))return a(),e}}};var Uc="/",Hy="//",dd=".",Vy="..",Ky="string",$y=/\\/g,pd=/\/\//g,zy=/\..*\.(sw[px])$|~$|\.subl.*\.tmp/,Gy=/^\.[/\\]/;function io(r){return Array.isArray(r)?r:[r]}var qc=r=>typeof r=="object"&&r!==null&&!(r instanceof RegExp);function Yy(r){return typeof r=="function"?r:typeof r=="string"?e=>r===e:r instanceof RegExp?e=>r.test(e):typeof r=="object"&&r!==null?e=>{if(r.path===e)return!0;if(r.recursive){let t=we.relative(r.path,e);return t?!t.startsWith("..")&&!we.isAbsolute(t):!1}return!1}:()=>!1}function Xy(r){if(typeof r!="string")throw new Error("string expected");r=we.normalize(r),r=r.replace(/\\/g,"/");let e=!1;return r.startsWith("//")&&(e=!0),r=r.replace(pd,"/"),e&&(r="/"+r),r}function ad(r,e,t){let n=Xy(e);for(let s=0;s<r.length;s++){let i=r[s];if(i(n,t))return!0}return!1}function Jy(r,e){if(r==null)throw new TypeError("anymatch: specify first argument");let n=io(r).map(s=>Yy(s));return e==null?(s,i)=>ad(n,s,i):ad(n,e)}var cd=r=>{let e=io(r).flat();if(!e.every(t=>typeof t===Ky))throw new TypeError(`Non-string provided as watch path: ${e}`);return e.map(gd)},fd=r=>{let e=r.replace($y,Uc),t=!1;return e.startsWith(Hy)&&(t=!0),e=e.replace(pd,Uc),t&&(e=Uc+e),e},gd=r=>fd(we.normalize(fd(r))),ud=(r="")=>e=>typeof e=="string"?gd(we.isAbsolute(e)?e:we.join(r,e)):e,Zy=(r,e)=>we.isAbsolute(r)?r:we.join(e,r),Qy=Object.freeze(new Set),Wc=class{path;_removeWatcher;items;constructor(e,t){this.path=e,this._removeWatcher=t,this.items=new Set}add(e){let{items:t}=this;t&&e!==dd&&e!==Vy&&t.add(e)}async remove(e){let{items:t}=this;if(!t||(t.delete(e),t.size>0))return;let n=this.path;try{await(0,oo.readdir)(n)}catch{this._removeWatcher&&this._removeWatcher(we.dirname(n),we.basename(n))}}has(e){let{items:t}=this;if(t)return t.has(e)}getChildren(){let{items:e}=this;return e?[...e.values()]:[]}dispose(){this.items.clear(),this.path="",this._removeWatcher=no,this.items=Qy,Object.freeze(this)}},eE="stat",tE="lstat",Hc=class{fsw;path;watchPath;fullWatchPath;dirParts;followSymlinks;statMethod;constructor(e,t,n){this.fsw=n;let s=e;this.path=e=e.replace(Gy,""),this.watchPath=s,this.fullWatchPath=we.resolve(s),this.dirParts=[],this.dirParts.forEach(i=>{i.length>1&&i.pop()}),this.followSymlinks=t,this.statMethod=t?eE:tE}entryPath(e){return we.join(this.watchPath,we.relative(this.watchPath,e.fullPath))}filterPath(e){let{stats:t}=e;if(t&&t.isSymbolicLink())return this.filterDir(e);let n=this.entryPath(e);return this.fsw._isntIgnored(n,t)&&this.fsw._hasReadPermissions(t)}filterDir(e){return this.fsw._isntIgnored(this.entryPath(e),e.stats)}},Vc=class extends ld.EventEmitter{closed;options;_closers;_ignoredPaths;_throttled;_streams;_symlinkPaths;_watched;_pendingWrites;_pendingUnlinks;_readyCount;_emitReady;_closePromise;_userIgnored;_readyEmitted;_emitRaw;_boundRemove;_nodeFsHandler;constructor(e={}){super(),this.closed=!1,this._closers=new Map,this._ignoredPaths=new Set,this._throttled=new Map,this._streams=new Set,this._symlinkPaths=new Map,this._watched=new Map,this._pendingWrites=new Map,this._pendingUnlinks=new Map,this._readyCount=0,this._readyEmitted=!1;let t=e.awaitWriteFinish,n={stabilityThreshold:2e3,pollInterval:100},s={persistent:!0,ignoreInitial:!1,ignorePermissionErrors:!1,interval:100,binaryInterval:300,followSymlinks:!0,usePolling:!1,atomic:!0,...e,ignored:e.ignored?io(e.ignored):io([]),awaitWriteFinish:t===!0?n:typeof t=="object"?{...n,...t}:!1};id&&(s.usePolling=!0),s.atomic===void 0&&(s.atomic=!s.usePolling);let i=process.env.CHOKIDAR_USEPOLLING;if(i!==void 0){let u=i.toLowerCase();u==="false"||u==="0"?s.usePolling=!1:u==="true"||u==="1"?s.usePolling=!0:s.usePolling=!!u}let a=process.env.CHOKIDAR_INTERVAL;a&&(s.interval=Number.parseInt(a,10));let f=0;this._emitReady=()=>{f++,f>=this._readyCount&&(this._emitReady=no,this._readyEmitted=!0,process.nextTick(()=>this.emit(He.READY)))},this._emitRaw=(...u)=>this.emit(He.RAW,...u),this._boundRemove=this._remove.bind(this),this.options=s,this._nodeFsHandler=new ro(this),Object.freeze(s)}_addIgnoredPath(e){if(qc(e)){for(let t of this._ignoredPaths)if(qc(t)&&t.path===e.path&&t.recursive===e.recursive)return}this._ignoredPaths.add(e)}_removeIgnoredPath(e){if(this._ignoredPaths.delete(e),typeof e=="string")for(let t of this._ignoredPaths)qc(t)&&t.path===e&&this._ignoredPaths.delete(t)}add(e,t,n){let{cwd:s}=this.options;this.closed=!1,this._closePromise=void 0;let i=cd(e);return s&&(i=i.map(a=>Zy(a,s))),i.forEach(a=>{this._removeIgnoredPath(a)}),this._userIgnored=void 0,this._readyCount||(this._readyCount=0),this._readyCount+=i.length,Promise.all(i.map(async a=>{let f=await this._nodeFsHandler._addToNodeFs(a,!n,void 0,0,t);return f&&this._emitReady(),f})).then(a=>{this.closed||a.forEach(f=>{f&&this.add(we.dirname(f),we.basename(t||f))})}),this}unwatch(e){if(this.closed)return this;let t=cd(e),{cwd:n}=this.options;return t.forEach(s=>{!we.isAbsolute(s)&&!this._closers.has(s)&&(n&&(s=we.join(n,s)),s=we.resolve(s)),this._closePath(s),this._addIgnoredPath(s),this._watched.has(s)&&this._addIgnoredPath({path:s,recursive:!0}),this._userIgnored=void 0}),this}close(){if(this._closePromise)return this._closePromise;this.closed=!0,this.removeAllListeners();let e=[];return this._closers.forEach(t=>t.forEach(n=>{let s=n();s instanceof Promise&&e.push(s)})),this._streams.forEach(t=>t.destroy()),this._userIgnored=void 0,this._readyCount=0,this._readyEmitted=!1,this._watched.forEach(t=>t.dispose()),this._closers.clear(),this._watched.clear(),this._streams.clear(),this._symlinkPaths.clear(),this._throttled.clear(),this._closePromise=e.length?Promise.all(e).then(()=>{}):Promise.resolve(),this._closePromise}getWatched(){let e={};return this._watched.forEach((t,n)=>{let i=(this.options.cwd?we.relative(this.options.cwd,n):n)||dd;e[i]=t.getChildren().sort()}),e}emitWithAll(e,t){this.emit(e,...t),e!==He.ERROR&&this.emit(He.ALL,e,...t)}async _emit(e,t,n){if(this.closed)return;let s=this.options;jc&&(t=we.normalize(t)),s.cwd&&(t=we.relative(s.cwd,t));let i=[t];n!=null&&i.push(n);let a=s.awaitWriteFinish,f;if(a&&(f=this._pendingWrites.get(t)))return f.lastChange=new Date,this;if(s.atomic){if(e===He.UNLINK)return this._pendingUnlinks.set(t,[e,...i]),setTimeout(()=>{this._pendingUnlinks.forEach((u,d)=>{this.emit(...u),this.emit(He.ALL,...u),this._pendingUnlinks.delete(d)})},typeof s.atomic=="number"?s.atomic:100),this;e===He.ADD&&this._pendingUnlinks.has(t)&&(e=He.CHANGE,this._pendingUnlinks.delete(t))}if(a&&(e===He.ADD||e===He.CHANGE)&&this._readyEmitted){let u=(d,g)=>{d?(e=He.ERROR,i[0]=d,this.emitWithAll(e,i)):g&&(i.length>1?i[1]=g:i.push(g),this.emitWithAll(e,i))};return this._awaitWriteFinish(t,a.stabilityThreshold,e,u),this}if(e===He.CHANGE&&!this._throttle(He.CHANGE,t,50))return this;if(s.alwaysStat&&n===void 0&&(e===He.ADD||e===He.ADD_DIR||e===He.CHANGE)){let u=s.cwd?we.join(s.cwd,t):t,d;try{d=await(0,oo.stat)(u)}catch{}if(!d||this.closed)return;i.push(d)}return this.emitWithAll(e,i),this}_handleError(e){let t=e&&e.code;return e&&t!=="ENOENT"&&t!=="ENOTDIR"&&(!this.options.ignorePermissionErrors||t!=="EPERM"&&t!=="EACCES")&&this.emit(He.ERROR,e),e||this.closed}_throttle(e,t,n){this._throttled.has(e)||this._throttled.set(e,new Map);let s=this._throttled.get(e);if(!s)throw new Error("invalid throttle");let i=s.get(t);if(i)return i.count++,!1;let a,f=()=>{let d=s.get(t),g=d?d.count:0;return s.delete(t),clearTimeout(a),d&&clearTimeout(d.timeoutObject),g};a=setTimeout(f,n);let u={timeoutObject:a,clear:f,count:0};return s.set(t,u),u}_incrReadyCount(){return this._readyCount++}_awaitWriteFinish(e,t,n,s){let i=this.options.awaitWriteFinish;if(typeof i!="object")return;let a=i.pollInterval,f,u=e;this.options.cwd&&!we.isAbsolute(e)&&(u=we.join(this.options.cwd,e));let d=new Date,g=this._pendingWrites;function _(y){(0,hd.stat)(u,(v,S)=>{if(v||!g.has(e)){v&&v.code!=="ENOENT"&&s(v);return}let C=Number(new Date);y&&S.size!==y.size&&(g.get(e).lastChange=C);let H=g.get(e);C-H.lastChange>=t?(g.delete(e),s(void 0,S)):f=setTimeout(_,a,S)})}g.has(e)||(g.set(e,{lastChange:d,cancelWait:()=>(g.delete(e),clearTimeout(f),n)}),f=setTimeout(_,a))}_isIgnored(e,t){if(this.options.atomic&&zy.test(e))return!0;if(!this._userIgnored){let{cwd:n}=this.options,i=(this.options.ignored||[]).map(ud(n)),f=[...[...this._ignoredPaths].map(ud(n)),...i];this._userIgnored=Jy(f,void 0)}return this._userIgnored(e,t)}_isntIgnored(e,t){return!this._isIgnored(e,t)}_getWatchHelpers(e){return new Hc(e,this.options.followSymlinks,this)}_getWatchedDir(e){let t=we.resolve(e);return this._watched.has(t)||this._watched.set(t,new Wc(t,this._boundRemove)),this._watched.get(t)}_hasReadPermissions(e){return this.options.ignorePermissionErrors?!0:!!(Number(e.mode)&256)}_remove(e,t,n){let s=we.join(e,t),i=we.resolve(s);if(n=n??(this._watched.has(s)||this._watched.has(i)),!this._throttle("remove",s,100))return;!n&&this._watched.size===1&&this.add(e,t,!0),this._getWatchedDir(s).getChildren().forEach(y=>this._remove(s,y));let u=this._getWatchedDir(e),d=u.has(t);u.remove(t),this._symlinkPaths.has(i)&&this._symlinkPaths.delete(i);let g=s;if(this.options.cwd&&(g=we.relative(this.options.cwd,s)),this.options.awaitWriteFinish&&this._pendingWrites.has(g)&&this._pendingWrites.get(g).cancelWait()===He.ADD)return;this._watched.delete(s),this._watched.delete(i);let _=n?He.UNLINK_DIR:He.UNLINK;d&&!this._isIgnored(s)&&this._emit(_,s),this._closePath(s)}_closePath(e){this._closeFile(e);let t=we.dirname(e);this._getWatchedDir(t).remove(we.basename(e))}_closeFile(e){let t=this._closers.get(e);t&&(t.forEach(n=>n()),this._closers.delete(e))}_addPathCloser(e,t){if(!t)return;let n=this._closers.get(e);n||(n=[],this._closers.set(e,n)),n.push(t)}_readdirp(e,t){if(this.closed)return;let n={type:He.ALL,alwaysStat:!0,lstat:!0,...t,depth:0},s=td(e,n);return this._streams.add(s),s.once(sd,()=>{s=void 0}),s.once(Bc,()=>{s&&(this._streams.delete(s),s=void 0)}),s}};function _d(r,e={}){let t=new Vc(e);return t.add(r),t}var md=me(ec()),rr=me(Gr()),rE=["**/node_modules/**","**/.git/**","**/dist/**","**/.next/**","**/.turbo/**","**/.cache/**","**/coverage/**","**/*.log"],nE=300,ao=class{watcher=null;ignoreFilter;workspaceRoot;logger;onFileChangedCallback=null;pendingEvents=new Map;pendingTypes=new Map;constructor(e,t){this.logger=e,this.workspaceRoot=t,this.ignoreFilter=(0,md.default)(),this.initializeIgnoreFilter()}initializeIgnoreFilter(){this.ignoreFilter.add(rE);let e=Br.join(this.workspaceRoot,".gitignore");try{if(Kn.existsSync(e)){let t=Kn.readFileSync(e,"utf-8");this.ignoreFilter.add(t)}}catch{}}onFileChanged(e){this.onFileChangedCallback=e}start(){this.watcher||(this.watcher=_d(this.workspaceRoot,{ignored:e=>{let t=Br.relative(this.workspaceRoot,e);if(!t||t===".")return!1;let n=t.split(Br.sep).join("/");return this.ignoreFilter.ignores(n)},persistent:!0,ignoreInitial:!0,awaitWriteFinish:{stabilityThreshold:200,pollInterval:50}}),this.watcher.on("add",e=>this.handleEvent(e,rr.FileChangeType.CREATE)),this.watcher.on("change",e=>this.handleEvent(e,rr.FileChangeType.MODIFY)),this.watcher.on("unlink",e=>this.handleEvent(e,rr.FileChangeType.DELETE)),this.watcher.on("error",e=>this.logger.error("File watcher error",e)),this.logger.info("File watcher started"))}stop(){this.watcher?.close(),this.watcher=null;for(let e of this.pendingEvents.values())clearTimeout(e);this.pendingEvents.clear(),this.pendingTypes.clear()}handleEvent(e,t){let n=Br.relative(this.workspaceRoot,e);if(!n)return;let s=this.pendingEvents.get(n);s&&clearTimeout(s);let i=this.pendingTypes.get(n);this.pendingTypes.set(n,this.mergeTypes(i,t));let a=setTimeout(()=>{this.emit(n,this.pendingTypes.get(n)||t),this.pendingEvents.delete(n),this.pendingTypes.delete(n)},nE);this.pendingEvents.set(n,a)}mergeTypes(e,t){return e?t===rr.FileChangeType.DELETE||e===rr.FileChangeType.DELETE?rr.FileChangeType.DELETE:e===rr.FileChangeType.CREATE?rr.FileChangeType.CREATE:t:t}emit(e,t){let n={path:e,changeType:t,timestamp:new Date().toISOString(),source:"watcher"};if(t!==rr.FileChangeType.DELETE)try{let s=Br.join(this.workspaceRoot,e),i=Kn.statSync(s);n.size=i.size}catch{}this.onFileChangedCallback?.(n)}dispose(){this.stop(),this.onFileChangedCallback=null}};async function co(r,e,t,n){if(n)return process.stderr.write(`Logging in with API key...
|
|
39
37
|
`),await r.loginWithApiKey(n)?(process.stderr.write(`Login successful.
|
|
40
38
|
`),!0):(process.stderr.write(`Login failed. Check your API key.
|
|
41
39
|
`),!1);try{let s=await r.startDeviceCodeFlow();process.stderr.write(`
|
|
@@ -48,17 +46,17 @@ tell application "System Events" to get value of property list item "CFBundleNam
|
|
|
48
46
|
`),!0):(process.stderr.write(` Login failed or expired.
|
|
49
47
|
|
|
50
48
|
`),!1)}catch(s){return t.error("Login error",s),process.stderr.write(`Login error: ${s instanceof Error?s.message:String(s)}
|
|
51
|
-
`),!1}}async function
|
|
52
|
-
`),await
|
|
49
|
+
`),!1}}async function Ed(r){let{storage:e,config:t,logger:n,machineId:s,notification:i,browser:a,cwd:f,watch:u}=r,d=t.getServerUrl(),g=new URL(d).host,_=await s.getMachineId(),y=new _t.CryptoService(e,n,g,_);await y.initialize();let v=new _t.AuthService(e,y,s,t,n,i,a,g,_),S=await v.hasValidToken();S||await v.refreshAccessToken()||(process.stderr.write(`Not logged in. Starting login flow...
|
|
50
|
+
`),await co(v,a,n)||process.exit(1),S=!0);let C;try{let{machineIdSync:J}=await Promise.resolve().then(()=>me(dc()));C=J()}catch{C=`cli_${Date.now()}_${Math.random().toString(36).slice(2,9)}`}let H=new _t.StatusDetector((J,Ee,pe)=>{z.getStatus().connected&&z.updateStatus({instanceId:T,terminalId:J,status:Ee,prompt:pe||void 0,encryptedPrompt:pe&&y.encryptPromptInfo(pe)||void 0}).catch(()=>{})}),z=new _t.WebSocketService(v,y,t,n,i,C,"cli");z.onStatusChange(J=>{J==="connected"?process.stderr.write(`Connected to termiq.io
|
|
53
51
|
`):J==="disconnected"&&process.stderr.write(`Disconnected from termiq.io
|
|
54
52
|
`)}),z.onAuthFailure(()=>{process.stderr.write(`Session expired. Please run "termiq login" again.
|
|
55
|
-
`),
|
|
56
|
-
`),process.exit(1)}let X=
|
|
57
|
-
`)}async function
|
|
53
|
+
`),Fe(),process.exit(1)});try{await z.connect()}catch(J){process.stderr.write(`Connection failed: ${J instanceof Error?J.message:String(J)}
|
|
54
|
+
`),process.exit(1)}let X=yd.basename(f),T=`cli_${Date.now()}`,M=y.encryptWorkspaceInfo({name:X,path:f});await z.registerWorkspace({instanceId:T,name:M?void 0:X,path:M?void 0:f,encryptedInfo:M||void 0});let Q=new Zi(n),B=Q.spawn(f),ie=`CLI: ${X}`,he=process.env.SHELL||"/bin/bash",de=y.encryptTerminalInfo({name:ie,command:he,cwd:f});await z.terminalCreated({instanceId:T,terminalId:B,name:de?void 0:ie,command:de?void 0:he,cwd:de?void 0:f,encryptedInfo:de||void 0});let Pe=new _t.FileTransferService(n),We=new _t.FileTrackerService(n,f),Ge=new _t.FileListService(n,f),ve=u?new ao(n,f):null,Ye=z.getSocket();Ye&&Pe.attach(Ye,T),We.onFileChanged((J,Ee)=>{z.sendFileChangedEvent(T,J,Ee)}),We.onFileViewTransfer(async(J,Ee,pe)=>{try{await Pe.sendBuffer(J,Ee,pe.path.split("/").pop()||"view",pe.mimeType||"text/plain",{purpose:"view",viewMetadata:pe})}catch(nt){n.error("File view transfer failed",nt)}}),z.onFileViewRequest((J,Ee)=>{We.handleViewRequest(J,Ee)}),z.onFileListRequest((J,Ee)=>{Ge.handleListRequest(Ee)}),Ge.onResponse(J=>{z.sendFileListResponse(T,J)}),z.onFileDownloadRequest(async(J,Ee,pe)=>{try{await Pe.sendFile(J,Ee,void 0,void 0,pe)}catch(nt){n.error("File download failed",nt)}}),ve&&(ve.onFileChanged(J=>{z.sendFileChangedEvent(T,B,J)}),ve.start()),H.startTracking(B),Q.setOnOutput(J=>{z.sendOutput(T,B,J),H.processOutput(B,J),We.processOutput(B,J)}),z.onInput((J,Ee)=>{J===B&&Q.write(Ee)}),z.onResizeRequest((J,Ee,pe)=>{J===B&&Q.resize(Ee,pe)}),z.onGetBufferRequest(J=>J===B?Q.getBuffer():null),z.onRedrawRequest(J=>{if(J===B){let Ee=process.stdout.columns||80,pe=process.stdout.rows||24;Q.resize(Ee,pe)}}),z.onReconnect(async()=>{try{await z.registerWorkspace({instanceId:T,name:M?void 0:X,path:M?void 0:f,encryptedInfo:M||void 0}),await z.terminalCreated({instanceId:T,terminalId:B,name:de?void 0:ie,command:de?void 0:he,cwd:de?void 0:f,encryptedInfo:de||void 0});let J=z.getSocket();J&&Pe.attach(J,T)}catch(J){n.error("Failed to re-register on reconnect",J)}});function Fe(){ve?.dispose(),Pe.detach(),We.dispose(),Ge.dispose(),H.stopTracking(B),H.dispose(),z.terminalClosed({instanceId:T,terminalId:B}).catch(()=>{}),z.unregisterWorkspace(T).catch(()=>{}),z.disconnect(),Q.dispose()}Q.setOnExit(()=>{Fe(),process.exit(0)}),process.on("SIGINT",()=>{Fe(),process.exit(0)}),process.on("SIGTERM",()=>{Fe(),process.exit(0)})}async function wd(r){await r.logout(),process.stderr.write(`Logged out.
|
|
55
|
+
`)}async function vd(r){let e=await r.hasValidToken(),t=await r.getAgentId();e?(process.stderr.write(`Status: logged in
|
|
58
56
|
`),t&&process.stderr.write(`Agent ID: ${t}
|
|
59
57
|
`)):(process.stderr.write(`Status: not logged in
|
|
60
58
|
`),process.stderr.write(`Run 'termiq login' to authenticate.
|
|
61
|
-
`))}var
|
|
59
|
+
`))}var Ur=me(Es()),rt=process.argv.slice(2),xd=rt[0]||"start",sE=rt.includes("--verbose")||rt.includes("-v"),iE=rt.includes("--watch")||rt.includes("-w"),oE=rt.includes("--log-to-file"),aE=rt.find(r=>r.startsWith("--token="))?.split("=")[1]||(rt.includes("--token")?rt[rt.indexOf("--token")+1]:void 0),bd=rt.find(r=>r.startsWith("--server="))?.split("=")[1]||(rt.includes("--server")?rt[rt.indexOf("--server")+1]:void 0),Kc=rt.find(r=>r.startsWith("--log-level="))?.split("=")[1]||(rt.includes("--log-level")?rt[rt.indexOf("--log-level")+1]:void 0),cE=["silent","error","warn","info","debug"],fE=Kc&&cE.includes(Kc)?Kc:sE?"info":"silent",uE=process.env.TERMIQ_TOKEN,jr=new ws(fE,oE),hn=new Xn,dn=new Jn(bd?{serverUrl:bd}:void 0),pn=new xs,fo=new bs,Ps=new Os;async function lE(){switch(xd){case"start":case void 0:{await Ed({storage:hn,config:dn,logger:jr,machineId:pn,notification:fo,browser:Ps,cwd:process.cwd(),watch:iE});break}case"login":{let r=new URL(dn.getServerUrl()).host,e=await pn.getMachineId(),t=new Ur.CryptoService(hn,jr,r,e);await t.initialize();let n=new Ur.AuthService(hn,t,pn,dn,jr,fo,Ps,r,e),s=await co(n,Ps,jr,aE||uE);process.exit(s?0:1);break}case"logout":{let r=new URL(dn.getServerUrl()).host,e=await pn.getMachineId(),t=new Ur.CryptoService(hn,jr,r,e);await t.initialize();let n=new Ur.AuthService(hn,t,pn,dn,jr,fo,Ps,r,e);await wd(n),process.exit(0);break}case"status":{let r=new URL(dn.getServerUrl()).host,e=await pn.getMachineId(),t=new Ur.CryptoService(hn,jr,r,e);await t.initialize();let n=new Ur.AuthService(hn,t,pn,dn,jr,fo,Ps,r,e);await vd(n),process.exit(0);break}case"--help":case"-h":case"help":{process.stderr.write(`
|
|
62
60
|
termiq \u2014 Access terminals from anywhere
|
|
63
61
|
|
|
64
62
|
Usage:
|
|
@@ -78,9 +76,9 @@ tell application "System Events" to get value of property list item "CFBundleNam
|
|
|
78
76
|
Environment:
|
|
79
77
|
TERMIQ_TOKEN API key (equivalent to --token)
|
|
80
78
|
|
|
81
|
-
`),process.exit(0);break}default:process.stderr.write(`Unknown command: ${
|
|
79
|
+
`),process.exit(0);break}default:process.stderr.write(`Unknown command: ${xd}
|
|
82
80
|
Run 'termiq --help' for usage.
|
|
83
|
-
`),process.exit(1)}}
|
|
81
|
+
`),process.exit(1)}}lE().catch(r=>{process.stderr.write(`Fatal error: ${r instanceof Error?r.message:String(r)}
|
|
84
82
|
`),process.exit(1)});
|
|
85
83
|
/*! Bundled license information:
|
|
86
84
|
|