coze-bridge 0.1.44 → 0.1.48
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/index.js +65 -60
- package/package.json +1 -1
package/dist/index.js
CHANGED
|
@@ -5,25 +5,25 @@ import { dirname as __coze_dirname } from 'node:path';
|
|
|
5
5
|
const require = __coze_createRequire(import.meta.url);
|
|
6
6
|
const __filename = __coze_fileURLToPath(import.meta.url);
|
|
7
7
|
const __dirname = __coze_dirname(__filename);
|
|
8
|
-
var
|
|
9
|
-
|
|
10
|
-
`):
|
|
11
|
-
`)}function R(n){return{debug:(e,s)=>gn("debug",n,e,s),info:(e,s)=>gn("info",n,e,s),warn:(e,s)=>gn("warn",n,e,s),error:(e,s)=>gn("error",n,e,s),child:e=>R(`${n}.${e}`)}}var pn,as,mc,wc,cs,U=qe(()=>{"use strict";pn={debug:10,info:20,warn:30,error:40},as=(()=>{let n=process.env.COZE_BRIDGE_LOG_LEVEL;return n==="debug"||n==="info"||n==="warn"||n==="error"?n:"info"})(),mc=process.stdout,wc=process.stderr,cs={}});import{promises as ds}from"node:fs";import{homedir as _c}from"node:os";import{sep as yc,join as ie,resolve as us}from"node:path";function q(n){let e=n??_c(),s=ie(e,".coze"),o=ie(s,"bridge"),c=ie(o,"lib");return{cozeRoot:s,bridgeRoot:o,libDir:c,libEntry:ie(c,"index.js"),binDir:ie(o,"bin"),pidFile:ie(o,"bridge.pid"),portFile:ie(o,"bridge.port"),tokenFile:ie(o,"bridge.token"),patTokenFile:ie(o,"pat-token"),logFile:ie(o,"bridge.log"),installLock:ie(o,"install.lock"),configFile:ie(o,"config.json"),agentsRoot:ie(s,"agents")}}function Ke(n,e=q()){let s=ie(e.agentsRoot,n);return{root:s,config:ie(s,"config.json"),workspace:ie(s,"workspace"),logs:ie(s,"logs")}}async function fs(n,e){let s=await ds.realpath(us(n)).catch(()=>null);if(!s)return!1;let o=await ds.realpath(us(e)).catch(()=>null);if(!o)return!1;let c=process.platform==="win32"?s.toLowerCase():s,x=process.platform==="win32"?o.toLowerCase():o;return c===x||c.startsWith(x+yc)}var se=qe(()=>{"use strict"});var yn={};is(yn,{AGENT_CONFIG_FILE_MODE:()=>wn,enforceAgentConfigMode:()=>Sc,loadAgentConfig:()=>pe,persistAgentSessions:()=>Nr,persistAgentSkills:()=>_n,saveAgentConfig:()=>Pe});import{chmod as vc,stat as bc}from"node:fs/promises";function pe(n,e){return yt(Ke(n,e).config)}function Pe(n,e){return ln(Ke(n.agentId,e).config,n,{mode:wn})}async function Sc(n,e){if(process.platform==="win32")return;let s=Ke(n,e).config;try{let o=await bc(s);if(!o.isFile())return;let c=o.mode&511;c!==wn&&(await vc(s,wn),ls.warn("agent config mode auto-corrected to 0600",{path:s,from:c.toString(8)}))}catch(o){if(o.code==="ENOENT")return;ls.warn("enforceAgentConfigMode: chmod failed (ignored)",{path:s,err:String(o)})}}async function Nr(n,e,s){let o=await pe(n,s);o&&(o.sessions=Object.fromEntries(e),await Pe(o,s))}async function _n(n,e,s){let o=await pe(n,s);o&&(o.skills=e,await Pe(o,s))}var ls,wn,Ze=qe(()=>{"use strict";hn();U();se();ls=R("agent-config"),wn=384});var Lo=le(Z=>{"use strict";var C=D;(function(n,e){let s=D,o=n();for(;;)try{if(-parseInt(s(1530))/1*(parseInt(s(1539))/2)+-parseInt(s(1047))/3*(parseInt(s(890))/4)+-parseInt(s(531))/5+-parseInt(s(788))/6*(parseInt(s(680))/7)+parseInt(s(1620))/8+-parseInt(s(572))/9*(-parseInt(s(758))/10)+parseInt(s(1730))/11===e)break;o.push(o.shift())}catch{o.push(o.shift())}})(Xn,563023);var zd=Object[C(1665)+C(1755)],Fd=Object[C(1227)+C(892)+C(528)],Po=(n,e)=>function(){return n&&(e=(0,n[{aJmFo:function(c,x){return c(x)}}.aJmFo(Fd,n)[0]])(n=0)),e},Ud=(n,e)=>{let s={SYHEV:function(c,x,u,l){return c(x,u,l)}};for(var o in e)s.SYHEV(zd,n,o,{get:e[o],enumerable:!0})};function qd(){return So||(So=[IDBDatabase,IDBObjectStore,IDBIndex,IDBCursor,IDBTransaction])}function Hd(){let n=C;return Eo||(Eo=[IDBCursor[n(1382)+"e"][n(1086)],IDBCursor.prototype.continue,IDBCursor[n(1382)+"e"][n(1046)+n(936)+"ey"]])}function Kd(n){let e=C,s={PrtzK:e(1771),MiMGW:e(1017),RTOBE:function(c,x){return c===x},ggJoB:e(578),HYmNM:e(564),wpEYQ:function(c,x){return c(x)},RJtaM:function(c){return c()},zDfdM:function(c,x){return c(x)},bvmKf:function(c,x){return c!==x},rnRGu:"HnIns",lLllY:function(c){return c()},HWUFQ:function(c,x){return c instanceof x},dMirs:function(c,x){return c===x},bmcwV:e(811),SYzrQ:"shyXN"},o=new Promise((c,x)=>{let u=e,l={MMfdQ:function(y,E){return s[D(1687)](y,E)},mCtut:function(y,E){return s[D(1387)](y,E)},LejOh:s[u(992)],akiia:u(1798),KPxKm:function(y){return s[u(946)](y)}},m=()=>{let y=u;n["removeEv"+y(978)+"ner"](s[y(1628)],w),n[y(633)+y(978)+y(885)](s[y(1531)],v)},w=()=>{let y=u;if(s[y(984)](s[y(1125)],s[y(593)]))return this[y(1454)].protocol;s[y(433)](c,Me(n[y(801)])),s[y(997)](m)},v=()=>{let y=u;if(l.mCtut(l[y(571)],l.akiia))l.MMfdQ(x,n[y(1017)]),l.KPxKm(m);else return l[y(1546)](_0x130a4b,_0x5c561f)};n[u(1114)+u(429)](u(1771),w),n[u(1114)+u(429)](s.MiMGW,v)});return o[e(1455)](c=>{let x=e;if(s[x(581)](c,IDBCursor)){if(s[x(1189)](s[x(1160)],s[x(1397)]))return!!this[x(704)];Xr.set(c,n)}})[e(1013)](()=>{}),$n[e(1541)](o,n),o}function jd(n){let e=C,s={zDxCV:function(c,x,u){return c(x,u)},yKwDG:function(c,x){return c===x},KQPvC:e(1027),JTJpu:e(1667),AWCAC:"complete",IBxvL:e(1017),SIgBe:e(670),qAlYF:e(1818),NIFnn:function(c){return c()},rBJJQ:"NJSOi",tliSV:function(c,x){return c(x)}};if(Vn[e(662)](n))return;let o=new Promise((c,x)=>{let u=e,l={IxaUJ:function(y,E,k){return s[D(1790)](y,E,k)},VOchV:s[u(1201)],bJVrR:function(y){return s.NIFnn(y)},BOflz:function(y){return s.NIFnn(y)},eZgsI:function(y,E){return y!==E},VYhXI:s.rBJJQ,iCBpf:function(y,E){return s[u(903)](y,E)},ZWEwH:u(845)+"or"},m=()=>{let y=u,E={IQQbg:function(k,P,T){return s[D(1790)](k,P,T)}};s.yKwDG(s.KQPvC,s.JTJpu)?(_0x2d1b5b(_0x11412e,74),E[y(1370)](_0xa49747,_0x461f73,_0x5e7068)):(n["removeEv"+y(978)+y(885)](s[y(1637)],w),n[y(633)+"entListe"+y(885)](s[y(1480)],v),n[y(633)+"entListener"](s[y(408)],v))},w=()=>{let y=u,E={MYBZV:function(k,P,T){return l[D(1188)](k,P,T)}};l[y(1591)]===l[y(1591)]?(l[y(1203)](c),l[y(1833)](m)):(_0x335416(this[y(1301)+y(1509)+"Id"]),this[y(1301)+y(1509)+"Id"]=E[y(913)](_0x48a79f,()=>{let k=y;this[k(1710)+k(464)]()},this._interval))},v=()=>{let y=u;l[y(1575)](l[y(444)],l[y(444)])?_0xa686de[y(590)](_0x4fa41b):(l[y(448)](x,n.error||new DOMException(l[y(1545)],l.ZWEwH)),m())};n[u(1114)+u(429)](s[u(1637)],w),n["addEvent"+u(429)](s.IBxvL,v),n[u(1114)+u(429)](s.SIgBe,v)});Vn[e(1541)](n,o)}function Gd(n){Yn={QFJgH:function(o,c){return o(c)}}[C(1870)](n,Yn)}function Wd(n){let e=C,s={KGuQV:function(o,c){return o(c)},wmgFJ:function(o,c){return o(c)},GdgzD:function(o,c){return o(c)},JqCcz:function(o,c){return o(c)},OCIdt:function(o,c){return o===c},akedo:function(o,c){return o in c},CaTZw:e(1838)+e(1247),rciEJ:function(o){return o()}};return s[e(714)](n,IDBDatabase[e(1382)+"e"][e(1785)+e(1663)])&&!s[e(1438)](s[e(417)],IDBTransaction[e(1382)+"e"])?function(o,...c){let x=e,u=n.call(s[x(1230)](tn,this),o,...c);return Yr[x(1541)](u,o[x(1725)]?o[x(1725)]():[o]),Me(u)}:s[e(1880)](Hd)[e(1369)](n)?function(...o){let c=e;return n[c(1623)](s.wmgFJ(tn,this),o),Me(Xr[c(893)](this))}:function(...o){let c=e;return s[c(1582)](Me,n[c(1623)](s[c(1011)](tn,this),o))}}function Jd(n){let e=C,s={iafjk:function(o,c){return o===c},bOIoj:function(o,c){return o(c)},xeBQX:function(o,c){return o instanceof c},mBRic:function(o,c,x){return o(c,x)},kPJwu:function(o){return o()}};return s[e(1284)](typeof n,e(1733))?s[e(1273)](Wd,n):(s[e(923)](n,IDBTransaction)&&s.bOIoj(jd,n),s[e(1635)](ko,n,s[e(526)](qd))?new Proxy(n,Yn):n)}function D(n,e){n=n-401;let s=Xn(),o=s[n];if(D.CMkUOp===void 0){var c=function(m){let w="abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789+/=",v="",y="";for(let E=0,k,P,T=0;P=m.charAt(T++);~P&&(k=E%4?k*64+P:P,E++%4)?v+=String.fromCharCode(255&k>>(-2*E&6)):0)P=w.indexOf(P);for(let E=0,k=v.length;E<k;E++)y+="%"+("00"+v.charCodeAt(E).toString(16)).slice(-2);return decodeURIComponent(y)};D.kwQLPl=c,D.noRlZA={},D.CMkUOp=!0}let x=s[0],u=n+x,l=D.noRlZA[u];return l?o=l:(o=D.kwQLPl(o),D.noRlZA[u]=o),o}function Me(n){let e=C,s={lsvmF:function(c,x){return c(x)},NBboz:function(c,x){return c(x)},mNjvN:function(c,x){return c!==x}};if(n instanceof IDBRequest)return s[e(1072)](Kd,n);if(Wn[e(662)](n))return Wn[e(893)](n);let o=s[e(980)](Jd,n);return s[e(1866)](o,n)&&(Wn[e(1541)](n,o),$n[e(1541)](o,n)),o}var ko,So,Eo,Xr,Vn,Yr,Wn,$n,Yn,tn,Co=Po({"node_modules/idb/build/wrap-idb-value.js"(){let n=C,e={ePzvr:function(s,o){return s===o},pwtzQ:n(506),pnkDm:"objectStoreNames",XnezH:"store",gyOXr:function(s,o){return s(o)},koYtm:function(s,o){return s instanceof o},RiMEj:function(s,o){return s===o},ZbQNW:function(s,o){return s in o}};ko=(s,o)=>o.some(c=>s instanceof c),Xr=new WeakMap,Vn=new WeakMap,Yr=new WeakMap,Wn=new WeakMap,$n=new WeakMap,Yn={get(s,o,c){let x=n;if(s instanceof IDBTransaction){if(e.ePzvr(o,e[x(765)]))return Vn[x(893)](s);if(o===e[x(616)])return s[x(1838)+x(1247)]||Yr[x(893)](s);if(o===e.XnezH)return c[x(1838)+"oreNames"][1]?void 0:c[x(1838)+x(1533)](c[x(1838)+x(1247)][0])}return e[x(675)](Me,s[o])},set(s,o,c){return s[o]=c,!0},has(s,o){let c=n;return e[c(1613)](s,IDBTransaction)&&(o===e[c(765)]||e[c(1435)](o,e.XnezH))?!0:e[c(1621)](o,s)}},tn=s=>$n[n(893)](s)}}),To={};Ud(To,{deleteDB:()=>$d,openDB:()=>Vd,unwrap:()=>tn,wrap:()=>Me});function Vd(n,e,{blocked:s,upgrade:o,blocking:c,terminated:x}={}){let u=C,l={ZFMBO:"error",sUnRf:function(v,y){return v+y},pHFSE:function(v,y,E,k,P){return v(y,E,k,P)},DUnJd:function(v,y){return v(y)},RVvHL:u(750),WRhIF:"versionc"+u(931),isjYO:function(v,y){return v!==y},lRucP:u(1461),csDOb:"upgraden"+u(1180)},m=indexedDB[u(436)](n,e),w=Me(m);if(o)if(l[u(1183)]("nwizc",l[u(1141)])){let v=_0x58cd66.buffer.slice(_0x49f24.byteOffset,l[u(1504)](_0x4362b3[u(1041)+"th"],_0xde6eb1[u(861)+"et"]));this[u(1454)]&&this[u(1454)][u(784)]({data:v,fail:y=>{let E=u;this[E(1630)](l[E(1625)],_0x9ac71a(l[E(1625)],{message:this[E(1750)+E(1532)+"age"](y)}))}})}else m[u(1114)+u(429)](l[u(1726)],v=>{let y=u;l.pHFSE(o,l.DUnJd(Me,m.result),v[y(1150)+"on"],v[y(549)+"on"],Me(m["transact"+y(1663)]))});return s&&m[u(1114)+u(429)]("blocked",()=>s()),w[u(1455)](v=>{let y=u;x&&v[y(1114)+y(429)](l.RVvHL,()=>x()),c&&v[y(1114)+"Listener"](l[y(1127)],()=>c())})[u(1013)](()=>{}),w}function $d(n,{blocked:e}={}){let s=C,o={iruuK:s(1337)},c=indexedDB["deleteDa"+s(1256)](n);return e&&c[s(1114)+"Listener"](o[s(407)],()=>e()),Me(c).then(()=>{})}function Io(n,e){let s=C,o={INSmI:s(626)+"e",uvZad:s(423),nUdMu:function(m,w){return m instanceof w},rjPif:function(m,w){return m in w},vveOZ:function(m,w){return m===w},bqlAv:function(m,w){return m!==w}};if(!(o.nUdMu(n,IDBDatabase)&&!o.rjPif(e,n)&&o[s(641)](typeof e,s(1586))))return;if(Jn[s(893)](e))return Jn[s(893)](e);let c=e.replace(/FromIndex$/,""),x=o[s(1015)](e,c),u=Ro[s(1369)](c);if(!o[s(1165)](c,(x?IDBIndex:IDBObjectStore)[s(1382)+"e"])||!(u||Do.includes(c)))return;let l=async function(m,...w){let v=s,y=this[v(1785)+v(1663)](m,u?o[v(1762)]:o[v(728)]),E=y[v(1101)];return x&&(E=E[v(1737)](w[v(1309)]())),(await Promise[v(554)]([E[c](...w),u&&y[v(506)]]))[0]};return Jn[s(1541)](e,l),l}var Do,Ro,Jn,Yd=Po({"node_modules/idb/build/index.js"(){let n=C,e={wxQqO:n(1506),pSpGK:n(525),HEjlv:"getAllKeys",niYcd:"put",cuwpk:n(987),SfvSC:n(614),CpjRr:n(1823),ACyfI:function(c){return c()}},s=(n(480)+n(428))[n(1884)]("|"),o=0;for(;;){switch(s[o++]){case"0":Gd(c=>({...c,get:(x,u,l)=>Io(x,u)||c[n(893)](x,u,l),has:(x,u)=>!!Io(x,u)||c[n(662)](x,u)}));continue;case"1":Do=["get",e[n(1502)],e[n(1764)],e.HEjlv,"count"];continue;case"2":Ro=[e[n(684)],e[n(1012)],e[n(1153)],e[n(575)]];continue;case"3":e[n(1682)](Co);continue;case"4":e[n(1682)](Co);continue;case"5":Jn=new Map;continue}break}}}),Xd={idb:function(n){let e=C;n[e(462)]=Promise[e(908)]()[e(1455)](()=>(Yd(),To))[e(1455)](function(s){return s})}},Ao={};function Be(n){let e=C,s={JxEvj:function(x,u){return x!==u}};var o=Ao[n];if(s.JxEvj(void 0,o))return o[e(462)];var c=Ao[n]={exports:{}};return Xd[n](c,c[e(462)],Be),c[e(462)]}Be.d=(n,e)=>{let s=D;for(var o in e)Be.o(e,o)&&!Be.o(n,o)&&Object["definePr"+s(1755)](n,o,{enumerable:!0,get:e[o]})},(()=>{let n=C;Be.o=(e,s)=>Object[n(1382)+"e"][n(687)+n(1755)][n(873)](e,s)})(),(()=>{let n=C,e={mZWVS:function(s,o){return s!=o},gPXtF:n(1163)+"d",SuUgH:"Module"};Be.r=s=>{let o=n;e[o(754)](e[o(1489)],typeof Symbol)&&Symbol[o(1477)+o(1894)]&&Object[o(1665)+"operty"](s,Symbol[o(1477)+o(1894)],{value:e.SuUgH}),Object[o(1665)+o(1755)](s,o(563)+"le",{value:!0})}})();function Xn(){let n=["B25TzxnZywC","CNnVCKzPBgu","C3vJy2vZCW","AwXLx25HBwu","vvjWEei","vhPuBKu","igzHAwWSig0","C2jNBee","B1zXrMy","s2XRDfu","C2vUDa","z2v0q3vYCMu","reviCwG","x2HHBMrSzva","tLnRtMm","DxbNCMfKzw4","DhjHBNnHy3q","yMr2tLe","s1rtqxG","y3jLyxrLuMu","vLrMtKS","EKr4q1y","BNrLCG","x0rctMfTzq","AefJA01LC3m","qvzst3O","CM92AwrLige","y3vYC29Y","mNWWFdf8nhW","tefTBKm","AxnbCNjHEq","yw1L","AwXK","DxvuCxq","C3vIyxjYyxK","y3vYC29YlNm","Bezzz1C","C3nHz2vfDMu","tuv3Awu","s3fVzhq","DKnYBe0","y2XVC2veqG","AMritNC","tNvvqKS","veTUy20","tuvtu0fhrv8","D3jPDgu","z2v0q3vYC28","rwrqsM4","D1v0BNG","DgvmB2Djre4","ywnOzwqSihC","AvfcC3K","AuLSt0e","y2XLyxi","B1DsywC","wePKCfy","rM9sq04","yMLUza","C0T1t1q","zw5JB2rPBMC","CLjjz2C","zNjVBunOyxi","x29WDgLVBNm","qK9MBhO","Bwv0Ag9K","s1HkDKq","y29UBMvJDfm","EMz5qwy","B2jQzwn0u3q","BMCGB3iGyw4","CgLUz19VBMm","q21vEvq","C3nMA2y","rMnjwhu","ywnRpwzYB24","vhvwBhi","zxjFDhrS","C2vYDMLJzq","sxfKExG","rurnzfq","ExzAwxa","yxnZAwDU","AenSB3nLrxy","s3Hds0G","z29sCNq","DxrVuMvJB24","BLvkBe4","s0Hqq3a","vwrYsvK","t3bLBKv2zw4","vwntuKu","zM9Yy2u","A0v3qNu","lcbxzwjtB2m","B25mAw5L","C2v0q3vYC28","Bu5QDK4","rNjVBNrPzxi","zMLN","rKPtzui","uuzkz0G","s2rdthu","x2n1CNnVCK4","t1zvA0W","zxmGCMvHy2G","CNzHBa","Dg9cExrLCW","r2vlBwm","t2fRswW","D3Ltze0","CMnPruO","BM5Ly3q","q3bnAMy","v21dyKu","C3bSAxq","x2jPBMfYEvq","qw1VDw50","BxzMAfO","ihrPBwvZ","tuDVz2G","s2nyEMC","AgrlEuK","C1bjvvK","rfrYqLm","vgfN","CuDStLe","C2nYAxb0","B3nLza","AKn5wxO","BgLTAxq","y29UBMvJDa","y3r4","ywDLrxzLBNq","sxfqvva","C3bSAwnL","AgvHzgvYCW","Axj1DuS","u0LNqMu","BgX3zNG","B3LtEwC","B3bLBKrc","rLLRAMy","B0zvAK4","C0jf","zhn3uLO","EfH0u00","q2fuwNC","ywnRDxbfBMq","x2LUAxq","CgjICdi","q0vQt3C","B2fitfe","CMvHzg9UBhK","q0Xpu0ve","suXjC0S","zLPRvfG","x3jLy29UBMu","nxWW","tgLZDgvUzxi","x2HHBMrSzu8","BeHLALO","wLDqyNi","D3bfwve","tNrUB3u","sMPkANm","B3bLBG","x2vUzhbVAw4","q1nNwgi","ANr5zu8","v2LUzg93","qKjIzxi","zw5NDgG","zwn0","vLLOweK","BMDuAw1LCG","CMvUDevUzha","t0H6B3q","AuncCgy","C2vYDMvYvgK","EfPfz2O","mdaWmdaWmda","Dw5AC1i","Bwf4twvZC2e","CgXUCfq","ywnRx2LK","CM9YrxzLBNq","tw1iwgO","B1rrCe4","shPVuNy","AKznBxa","t1H2Eu0","zxHWB3j0CW","EvHgBuq","AxjLza","yNLL","ihbYB3rVy28","r3vvteO","rvrPtMS","Cwfjq1G","AuzvD3y","uennu0y","qMvhA3O","x3bPBMDqB24","y1L0qvG","BMvJDa","ywnRtxnNswq","tKHAshG","wMTYqMy","CMvKDwnL","m3W0Fdf8mNW","rfbht1q","twvZC2fNzuu","uwnXB1q","zNjVBu51Bwi","BfHywwG","BK1ZtLG","yw1Lu3bHy2u","B2nRzxq","vMzODgW","sNPSBeq","CfPJwgK","uxHuEMC","B3jRzxjhBg8","x21PBMLoyxy","Bwj1su4","x1fVu01HBMe","Aurvsfa","y2HLy2TdDxi","y29UDgv4Da","CMfTzq","Ae1LC3nHz2u","rfnIzvO","t0nUDue","AwDHDg9Yt24","wLvJv0i","zg9Uzq","B25fCNjVCG","teLwzuG","u0r0twG","tgnAshm","BMrWB2LUDfq","vM5Zq0C","r0jLEhG","uefwD1e","DxrMofDYAxq","EerXsgu","De1uywm","B3rgBuK","tfjgr1O","q291BNq","y0vSBwS","tgrcvu4","C3rlALu","DMXZyLy","z2v0qwXS","A1bkD3u","yxKSihrYEsa","BwvZ","ywDLsgLKzq","CM92AwrLihC","ndu3ody4nvnQEKP3AW","Bfruv3m","ChDdBxq","wNzNu00","seH2BNe","zw5HyMXLqxu","zw1Puvy","yNvhDwm","yKLqv2G","C2v0sxrLBq","B2nRzxrgywK","rNfgBue","sfL1qMC","Dhr3Awq","B2zMBgLUzq","B3jRig9MzMW","x2XPC3rLBMu","uuDbu3i","BMv3vMvYC2K","z2zvCfC","CYbPBNn0yw4","DwXyzNy","Cg9PBNrbBMq","ywXS","q2r3r2y","rLjHBee","y2vZC0HHBMq","q3nXAK0","AgrHsva","yMj0uha","z2u6ia","DgLTzw91DcW","x19LC01Vzhu","q2vTs2u","zNjVBNrPzxi","C3vIC3rYAw4","ywPXzfi","zw1LBNq","q2flq1O","BMCGDxjSoIa","tgvQt2G","nZiYndK0ofjVAeTPAa","svrnuM4","BgLZDgvUtMu","q3bQuNi","x3bPBMDmB3m","BLDuwwm","Ber5uw4","Dgv4Dc9Qyxy","lcbTyxGGCMu","sfDvrLe","AhnXEKO","zeTTC0O","EvjLy29UBMu","v2L0rhO","yMfJA3vWigu","vKrZrhm","CYbWyxjHBxm","x2rYB3bhBg8","Bg9N","DuryyvK","vvvpEgC","sfLTtK0","sLfpyKq","wMTyvhi","D0Tbz0O","Cg9W","sNzMDfm","s2vOExa","AvHqwM4","Aw50zwDLCIa","yMvxy0C","u2HyqLO","v25Ks0m","x2LZtwLUAvC","uLneuLO","C1b4t2C","DeX5qvu","zwrPyxrLBhK","AKrkrwq","Cg9PBNrdB24","rgvKAwnHDgu","EwfqDuG","zgvSzxrL","s2XmqvO","Cg5Rrg0","EerOtuK","x29UugfNzu4","z2zruvO","zw50","zfbyzxy","sw10Dva","wgPqsxe","Aw9Ul2PZB24","AuX2Ewu","CMvHzhDYAxq","reLLvg0","t2PxAvu","ENjctg0","mNWZ","u1nRB0u","rvfTqxy","CMvTB3zLrxy","B25tDg9Wsw0","rNb6BNC","zMLSDgvY","qMLyzge","DcbSAw1PDa","uw1lvwq","sxb0zxa","DNzLt1O","BM9Uzv9UB24","zgLZywjSzue","uw9owwO","rLDPvKG","rvD6rvy","C05PCuu","sfz3AxG","t2rKrMy","CuHkCvG","zMvY","AeDis2q","ueDgEg0","BLvuvMO","vuflCvO","wurTBeq","EKfdufy","AM9PBG","vg1fsxC","qMXpqK8","t1bftG","AgfZ","yLPPuwO","zgvS","sMXSwgW","CMvXDwLYzwq","DuDLugG","yuzcz0S","ExDQvfq","ywjVCNq","AKXnz0K","ve9pr2y","zfDVCMTLCKC","Dgn4rM4","z3Lpwhi","uLjpuG","r2LLCg0","ChH0tui","uKXvu0W","ndCWnta0m0LfBhLYAG","D0L1yum","DMHwA3i","AvzXzha","BMLzy2q","mdaWma","B0PxwM8","AgfZt3DUuhi","Bg9Nsurhzw4","zufJAW","q29Kzq","quP1v3a","CvrkAeS","B3bLBIa","zg1juhK","y3jLyxrLtwu","zMDcCfC","x3DZsw5ZDge","zgrjrcWGzgu","tMnzyNC","DhjPzxmGCMu","wxriC2O","seXxwhi","tvndC1G","x3fVC0rc","uMvJB25Uzwm","sfnurhu","Cu1mzM0","m3W2Fdr8nxW","CMvHzfvjBNq","zMXVB3i","C2v0y3vYC28","twvquui","CvjeAMe","t0njzhq","uvfICeS","vvbeEeK","B25LCNjVCG","x2nYzwf0zvm","vuvoquG","qvjuBhy","ChbL","CgXLyxnLiha","DfHsrhi","x2rLyNvN","CMvHzhLtDge","qNvOq3a","BgX1ugS","DxzAywq","qu5QAe0","wgzpzuS","CNr3Evm","whrmse0","DK5Uz1i","zw5fDMvUDa","Dg9cExrLC0W","yLLUzKC","sNPhCNm","zxjFAxnFywm","ihzHBgLKihm","shjeC2C","BNzVzwe","qxfduxK","C3rVCcbPBw0","vw5xsLi","y29UBMvJDeu","BuXpDLi","q0fZwxi","BNrJzMm","y3rODxa","y2XVC2u","uxLOuxK","s1z1BKu","B25VCgvU","BvPxvLm","Avj0CxO","AwzoBNK","Dxbktvm","mtb4CffjquG","q3LtruC","A1n0yxr1C0m","uer5BuC","whDfrwO","sKTjBKu","AwXPD3q","ChD0ELe","vhjOyLG","AMrst2K","t1Dkvhy","y2HnyxHdB3u","EfzdCNy","zxjFCw9Zx2e","DvjkEMC","zhPer2O","mNWXFdn8nhW","v0DnANq","CerUtMu","zfz2Chu","D3nZDNe","y3jLyxrLrxi","q09otKvdveK","CxbyD0W","AunUzge","sxHJqxa","C2vUza","y2H5EKO","DgLLCKPtt04","v1fxqw0","nKfxrhnUyG","y3vYC29Yx2y","r25hz1y","x2DLDeLUDgu","ysbTDxn0igi","vK1jB2i","wgvkwNy","vK1bqLi","rK1pAwS","DMHfDhi","Cg9ry20","thLpv0G","CNz0u3q","CMvZDwX0","zNjVBuj5Dgu","ywnOzwq","BMvLzf9Hy2S","D24GCMvHC28","rxzLBNq","CMfUzg9T","q0Xpu0LorW","r05MDhC","rfjwA2W","ue1zAfm","DMLJzuLeig8","BfrNrvO","BKrty3e","BKH2AfK","zgv2AwnLx2K","BKXSBey","qMrqtey","x2DLBMvYyxq","zgLiAhu","s3LcBve","ENnkDNC","yw51Ce1LC3m","zNnms04","zxH0zw5ZAw8","Ec1TC2CTCw8","x29UvgLTzw8","CeP6BMG","zxvRB0S","Cgf5Bg9Hzfq","quXm","r2X6qLa","tejmrMu","yuXMvxe","tKTxugS","uNjlD08","BvvgEvK","t0jRCvq","vxbKyxrLq28","Cgf5Bg9Hzeu","zxjFCw9Z","BxnNsuq","y3jLyxrLt2i","AuLqDM8","qwjVCNrfCNi","qxfzuMO","CMjuzui","Eu1kEgi","DcbVzIbYyw4","vxPUtu0","r05kzNG","DNDywfm","uw9jtLC","tev4ALm","B3LtD3i","BMDiD3G","AMTcyNG","ze1yuKy","Aw5N","AevYCM9Yrxy","yNL0zu9MzNm","Bg93","AxnszwfKEq","Dg9hzw5LCMe","ALLQz0q","z1fRrvy","zwnVBM5Ly3q","t0jIzM8","vgLOAK4","B2XOzeG","pxv0zI04","ug5Ouem","y2fSBa","ChjVy2vZCW","B2zM","wuzyzwC","A2v5CW","z2LmD1y","u2Lntvy","y291BNq","yw5Hz2vY","vuTrvem","x2LZqNjVD3m","v0jbzNe","BMvY","zuToEvK","Ahr0Ca","Dg1buLG","DeLK","mtjIwxrNrLi","uxnktwG","B3bLCNr5tMe","z2v0","sLnptLa","CLvcq24","zxPJwxG","y3jLyxrLrwW","BwLUzW","q3zrz1O","ve1LEve","reiGzMfPBgu","Aw47y2HHCNm","DgXPu1y","sw1ytMO","CNnVCL92ywW","yMfSu2nVCgu","B2nRzxrtDwm","CMvZB2X2zq","ugnwDvO","CgvYC2LZDgu","z2v0u3rVCMe","tMTevLq","tvLcwLy","EgXfv04","BNrbBMrvCgq","zv90Aw1LB3u","vNPnwvC","C0XPC3rLBMu","AxnFywnR","suj5DwK","BMCGzMfPBgu","wKfrrgy","EgvcuvG","DhjPBq","EgvHwwW","zcWG","DgLTzw91Da","s1vkzNy","twLZC2LUzYa","igzPzwXKoIa","AgfUz2u","swDUy3q","wvjku1i","yxLVEe4","A21gB2y","uhjPBwfYEuS","C2v0zgi","uKjWt2G","vKnqquC","DMvUDa","vgLTzw91Da","uujOs2G","rhnfy1m","vLfvsKW","A1LwA3y","BeXSBfK","mNWZFdf8mhW","ihrPBwvVDxq","BfDfvLm","BMnLq2XVC2u","DeLUDgvYy2u","yxnL","rxjYB3jdB2q","Axnby2TdBgu","BMrWB2LUDca","CgfYC2u","uhvRt1K","v3LcEvy","EgnJyM8","u2vXsuq","ru5Pz1m","zNjVBuHHC2G","vgvqrvG","y3jLyxrLq2W","rLjptLrjrvi","y29UC3rYDwm","rvnXEfy","ywzL","Bg9IywXty28","zcWGDw5RBM8","r29Isg4","z3rMz04","EeTVzLa","wwvMDNG","zgLZCgf0y2G","B01KsfK","t2jQzwn0","zw50tgLZDgu","B3nLrxzLBNq","tKjIB3O","BwvZC2fNztO","ywWGy3vYC28","DMfSDwvZ","uLrpqKu","uLD2rfa","C1b5wva","ywrK","CM92AwrLigi","BhrttuC","tgnLyve","vMz1r0W","CM5sr3u","vLbmz0q","D2vI","rK9oDui","BKrszhG","uKP0yu0","y29eENC","EgDqz1m","q1bzvvO","rMTOsuC","vg5uExO","r1jSBLK","B0z3Eu4","AxnrB1nnzxm","zwnJEKS","zhLLD0u","igfYCMf5yNu","zg9MCNa","zwjdu0W","sNfdy3O","y3v3CgS","y2f0y2G","qLzUu28","yNfSqxy","ALHIEKq","zxjYB3i","uLrnDMW","AefUC3O","qLvgzxC","Bg9NsurozxC","D3rTsxK","zffIz20","D2fZq2XLyw4","qM91v2K","AKnPswq","zfPwsgq","DxjWC1u","C09lEhu","tfbUu2e","rKDfDe4","Bwf4tg9ZC0m","Dw50","x2LZtM9Kzq","ihzHBgLKigq","rNPHtvO","AgnZquq","Dg9cExrLC0i","y3vYC29Yx24","DMfS","yNL0zuXLBMC","Cw1eBg8","vvrywwe","m3WXFdj8mhW","AwXLtMfTzq","y29UDgLUDwu","mJKZndiXvejgzKny","DxjS","D3jPDgvvAw4","ufHizu0","AMvJDfn0B3i","uxvqtwq","sLbrzuG","zxq9DxrMltG","EM5SDMC","AgT5rwW","uxjID1G","CKXLDvm","u3rYyxrLz3K","vNLuCw8","B2fTv2y","C0TTs0e","AxzdDvK","yxbWBgLJyxq","z0HywMG","zLb5r0K","C2XPy2u","vw5Oyw5KBgu","yNPVDuS","AgvKtwf4uMu","y2HnyxHuCMK","Bhn2Buy","EevtEMi","uKzLzgu","x3DZ","q2zjtfu","s1DhyuW","BKTQEva","EwXWC0K","v095AfK","sMzwyve","z2DhuNu","BgLUzw5V","EvztwNu","Cgz3vLK","ywr2yw5Jzq","lcbOB3n0BMe","Dhfuy3K","zvjZu3u","y09Wzw4","CMvQzwn0","wez6Cxm","ugHetgu","vLfgwvq","x29Ut3bLBG","qLHHufu","Cxz2z1C","y3vYDMfSDwu","Avrluge","zxjHDg9Y","C3rVCMu","sxn3C0e","C3HUALC","CwDcv28","zMvnBem","BM93","ruDpwfu","CMvZzxrfBMq","yw9MDfy","t3vKDfu","uxvLDwu","CgLUz0LUDgu","D3nZoI8V","ywrKrxzLBNq","BvP2B1i","x29UrxjYB3i","BKzptLK","De9JuvC","uM5bqLm","BwnTsMe","C3DMq2O","v1DHqwC","EvHwt1K","uvzND0C","z2DkB0i","x3nLCuLK","v1jOsuy","rNPmtee","zxbXv0e","DhjPzxm","Dg9oDw1Izxi","x0vysvnu","uLPWuKG","BMnVzgLUzW","AxnrB1nby2S","sgrtzwG","yxjYyxLIDwy","qxDeCNm","z2vY","q2nwsKW","Bfj1y1a","Du9kuNC","wKnyveq","teflBvi","DxPxB3e","tg9JAW","EsbJBg9Zzwq","zMv2vMC","CKnWB28","B2XKvMvYC2K","CMvHC29U","rM9xAMy","u2z2u0m","ufbUq00","y2XLyxjtDg8","yNL0zxm","B2zMC2v0","qvb0EuS","yMLUyxj5vhK","yM1JD1y","zK9pv3u","y1zKAMu","Dw5KzwzPBMu","uK5jseK","CMPqAwy","B1LiEK0","yKPmrg4","t25xwvm","zw5HyMXLuw8","weTTzvq","Dg9Y","ueL5D2m","Bw5wv2e","wKfQzK0","CxnQvKm","yNvMzMvY","zgvJB2rLzey","x3jLywr5q2W","yNPVyKO","zwvKzwq","rM1XExO","EvjsuwG","AxnQwu8","Dgv4Dc9WBge","x2HHBMrSzvi","id4G","ELj5vMe","sxHHvuO","ze1PCNm","DLjxvwu","rNzuz2y","wvrHz2W","q0nvq3m","yMrFzgLK","DMfSDwu","wK1MvLq","sK9TuvC","rhHqu3u","BwLZzq","tKjAr1y","CufSwuy","A2LJCfO","yKPwCLi","vhnzzuG","CwrjCLy","z2v0sxrLBq","CMv0CNLdB3u","Dg9VigXHCMC","B3fXwem","x2LUAxrhBg8","x3bHDgHlzxK","tg9Nsuq","ufDpEwO","tLbUAMO","seHpwMW","AK5Pr1u","m3WXFdj8nxW","BMfTzq","ueDiANy","Ec11C2uT","tgfYwfG","zKDvsxy","ChrVCG","D2LSBfjLy28","qNjPzgDL","CgfNzxnOB3C","z2v0t3DUuhi","DwjYzLu","x2LUAxrqCM8","s0D1uvy","y2HLy2Tszwe","zfz4sgi","DMvYC2LVBG","y29Kzq","BML0AwfSAxO","qxb3q2m","y2DWu0e","s3LLzwK","ChH3v0W","z29PBMCGyxC","q3vZDg9Tq2W","t1z5uu8","Aw5KzxHpzG","tKnnqxe","x2nVBM5Ly3q","Dw5ZAwDUzwq","B3jLtMfTzxm","tfzlCLm","D0XMueO","BwvY","rvjst1i","Ec1TC2CTy3u","B25pCgvU","DLPYt28","AMLTwKK","DgfIyxnL","txjTAvC","y3nsBLq","tg9NsurozxC","qNP6ugq","uu9AEKm","D2reALy","wxvLAKy","x3bPBMC","CLb4D3C","sLHOC2W","uxbzufa","BwvZC2fNzq","sePTzgO","DgDxtwC","txPTqLC","z2v0qwXSs2u","yK9jB2O","sgXxuMm","su9rrLy","icSG","vLPKB04","ywDL","zK9Iwu8","y2XVC2uSihC","ChvZAa","suvtx0vsuK8","rwvesMm","AwfMAMS","zM9YrwfJAa","u2vYDMLJzvC","x2nSzwfYugK","x2LZv29YA2u","Bwu6ia","B2f3sLK","zLjtt2u","v0jgC3y","x3bYzwzPEa","BgvUz3rO","mxWYFda","zLnfsxK","C0Xf","x2rPC3bHDgm","ywDLu2HVDW","v2LivfK","x2LUDgvYDMe","txLhAKG","Be9ztLy","yxrHlcbKyxq","x3jLBw92zvC","yLfksuC","B0DKz3y","qNfjwgi","C2HPzNq","CKPSDhG","zKDdyuu","zxjYtM8","DgvZDa","A3b0rKS","vNrpC3q","Dev2zw50","AwD4zvK","D095qvC","Dhf1D0S","BhnqC1a","ihrYEsbYzwm","EuPYsKS","rNrurgS","x3bYB3rVy28","q0Hez1O","Bvvutgy","DfbHy3C","zw5JB2rLrNi","DurkqM8","sxDtAgu","BgzNzhi","BNrfBMrWB2K","Ce9fvNm","B2fK","Au1cDMS","BgjMuKy","yMXVy2TLza","wwrgr1K","x2LZsw5PDa","DfbezNi","x3DHAxq","EePKEMu","y3jLyxrLt3a","zv9ZDwnJzxm","CMvJzwL2zwq","D3m6lY8","zNnmBvG","CMLLC0nVDw4","zMLUza","DvnvCw8","u0nOAMO","ELzurwi","zKDurKC","vwfuDu8","DNLirgS","DhbizwfKzxi","swTPuxO","sMzsDvy","B3blC00","weT1C2G","CMvWBgfJzui","tuPcD3C","BwfW","B25szwnLAxy","ywXSzwqGBxu","Dw5zq1K","D1PwB0y","uMDkzMW","Aw5JBhvKzxm","svfryMC","EM1qEuu","BvfVzKm","B1LqA2S","Dg1br1a","x2fKzfDZtgK","rwf2ELe","BgXrt3y","txrRBfq","BLf6vgu","A0P5uwS","yw5Nzq","ChjVDg90Exa","qNPLwhi","BwfUDwfSihi","q2ftyLm","CLzHBhvLCW","yNzTs2y","z1bHzuu","whHxD1u","zwnjtha","z1rPBwvVDxq","BwvZC2fNzv8","zvvYBa","vw1qruu","B25tDgfYDfi","sMnwrhe","u1L6CLe","zgf0yq","q2XTy0y","x21LC3nHz2u","EM9fChe","y3LMDwu","Cw9Zx18","q1nwq1e","yLLlsKe","ywnnu1e","u01IEhK","BuDLDw0","v2vPEgLUsLm","Dhj1y3rVCIa","s01dwNy","y3vYCMvUDeK","uMHftvG","z01qyNe","DhLWzq","sMHPBe4","yNjirxu","tLrRCe8","y05Nuvq","txnVuxC","Aw5KzxGGB3u","v1LmEwe","uwnssLa","AgrKzgy","uKzrzg0","CNnVCL9Uyw0","B25ozxr3B3i","B3jUChO","zKPND0G","yxKSig5LDhC","z01ss1m","zwXbCeW","x2TLEvbHDgG","mxW1","uMLnrwO","zhHNEuq","yM9L","ywTLzg8","tMLPwfK","sfzdwhu","DvPfuNe","we9TrxG","z1HOu3a","DhbXt04","yw5ZzM9YBvq","aaaaaaaaaaa","AgLNAa","yNvMzMvYzwq","vKXTCeC","AMr5r0C","y1z5Bem","nhWW","BufjrLK","x3nVy2TLDa","DgHLBG","z2vtEw5J","ENvsEwe","x2rPC2nVBM4","DhDVCMTdAge","BKXPBMu","BNDPEMm","AfrcvNe","tvvStLG","DfHNz2O","Cgf5Bg9Hza","rLDt","vuzywKC","Bwf4uMv0CMK","vNj0ugq","yxv0B21HDgK","Cu5jshG","zw5KCg9PBNq","tKfusvzfx0u","yxrLq291BNq","CwzVEKq","ChPkBuO","Dg9tDhjPBMC","Chv0","tKLPzxe","suj4DKW","EgPYz0y","Dgv4DfbHEwW","uezcrvK","yNHWsu4","uNrRtuO","yw1LoIa","CujkrKC","t3DnEfi","z1byDey","Dhndy20","tLL6weG","vgXrzKW","tuDlAKm","ihjLy29UBMu","EvLZseO","vfDWq0i","DMjXDve","BgLUzq","shDKwuW","AMT4D2G","ExPeB1a","D3HrCu8","z0Hwq0y","C1vUuMy","CMvJB25Uzwm","z2v0s2v5","EwT2uuW","BMjfr2y","BfrPBwvVDxq","ignVzgu6ia","uNf1q0e","wu1YqLi","CMfTugfYyw0","BhPotMG","ELP4zgi","BeHHBMrSzxi","zxH0ugf5Bg8","rNPuq3m","rKjbywK","EKTxtM8","o2nOyxjZzxq","ALHsvwu","vw5ttw8","zNj6D1i","uujRwMm","A2v5","Ef9MCM9UDgK","qKTyqwK","BMjiBfy","m3rStLzLtW","twLnr1C","CNjVCK1LC3m","B3jL","BMrLEa","zvvREMW","C2vYDMLJzs0","De1HBMfNzxi","Egzss3q","mJi5mtiYzuHQBu94","zNjVBujPDhm","C2v0","ig1LC3nHz2u","zhLiBLi","EervzLK","wLDfD0G","tu1Mzfe","yMfSrxzLBNq","CfL3s3K","rLnSteq","BfbOAw0","CvbeBhu","q0LXq3m","B25nzxnZywC","ruvMug4","AhzmELm","x2rLC3rYB3K","vKvgv2W","ywnRx2nVzgu","BezSDxnO","B25JBg9Zzq","Dg9wDge","B3jpBMXPBMu","x3vYBa","tePhsMq","AKLLEvu","Ae9Wzw5fDMu","BgHezg8","zxjYtxnN","x25HDMLNyxq","y29Uy2f0","teHwCxq","t0jpvgq","C2fNzq","qujAzve","zvPNC0K","x29UtwvZC2e","vePWuhC","AhzlvK8","DNPWALm","uMLbyNa","CNzHBfzHBhu","r2rNEKq","vujtzhC","z2vrDwv1zuW","EM1ODgm","C3rYAw5N","rLvfD2m","x29Uq2XVC2u","zNfxthK","Cg93","vK9JAfy","zhflsxK","CgfNzwHPzgu","v1P0ywW","x2n1CNnVCK0","vw5PBxbSzw0","yxGGCMv0CMK","sujrAfe","v05AtNi","ugvRDgu","BvvTq0e","C25Ry0W","ELfrCgy","B25SAw5L","y2HHCKnVzgu","AxvvsMK","Dg9mB3DLCKm","s1vfuKq","z0HutMO","yNj5zwe","zgLNCum","v3rUwMC","A29zDg0","B3vUDa","CwnfC3u","CMvWBgfJzq","BgvNwK8","zKTIA0K","CMjvuLG","nZi5otCYogv5tLn6za","wMjrtLC","ExrRqxa","yxbWBhK","v0HOB1O","wKznqK8","zNzSAue","x2nSzwfYvgK","uhj0EKS","vfrQv1q","zw1PDa","C3rLBMvYCW","DxbKyxrLq3u","CgLUz1rPBwu","EgjsENe","BujsAwm","nhWYFdb8m3W","qvDdqum","tvDWqxi","BNfTvhu","yM9KEq","ywnR","AKDOr3a","AgvHzgvY","C0voBK8","Ew9Ws3K","y3vZDg9Tshq","BgfVALK","y0rnB0u","CgH6tge","uKHhExu","Ewr6Bge","EKXrugW","CfrMzwW","AeDkBLm","y29SBM8","rNjbuvO","C3jJ","sMfTA2y","B3v0sw50zxi","vLrUq0G","ChjVDg9JB2W","nxWWFdr8mxW","Aw9U","B1bTswe","zgvMAw5Luhi","EhLpDMu","AxbSvKi","yxnJCMLWDa","CM92AwrLihy","uxPStNK","CwviAMy","CLn4u2W","zMzmAw5L","BwvKAwf0zwW","B3b0sMe","u3nAtuu","zgzMC28","ChL1Eei","rw1XCKC","y29UBMvJDca","B2H3t1G","qun5zKK","u3nmsKC","B2z3Ewy","ruDSAuy","verdExm","EKrMze0","ugT1Buy","thPIvLm","wwPTzw0","wNHgz2u","zeTtEwW","qwPXteq","v3nuuNi","Dxrjza","ENftDMG","C0nVDw50zxi","tufyx1jfvfi","sgDpu3a","vw9mAfy","C2vUzf9Hy2S","q29UzMLN","BNruCMLLC0m","ywXSB2nvBNm","v1v6vMK","wxbSyva","y3ruAw1LB3u","x2LZtwLUAvq","C0ToueK","zMX1C2HfEha","zgvmuNq","vuDcA3q","y29UBMvJDgK","CMvZzxrdB3u","A25Or2y","B2LUDfjLywm","q3vZDg9Trxi","B1LOq2K","qwvOEKe","DNHHwKq","B0HzDxO","y3vYCMvUDeu","C3rYAw5NAwy","tMrAEvi","C29YDa","y3net2i","ywrKq291BNq","BgvY","x2rItMfTzq","mte4mda1mJvQBgTvvKS","su1SAw8","qLbzu00","zNvUy3rPB24","uMfvyKC","zwvbr2y","vgDPq3G","Aw5KzxG","q2L6EvG","q01rv00","ExHbAKW","t1bftL9fuLi","rK5ty1q","tMfTzq","y01JDxq","BIWGAg9ZDg4","z2vjBMzVu3K","DhjoBKC","qwjgA0G","ExbL","x2zVCM1HDeu","B2fguw8","C1DJtLm","AxnmB25N","C3HzB3a","B3bLCNr5","zNjHBwvuExa","r2nTDeS","seryze4","BvfNuuS","BwzNy2e","v2vIu29JA2u","su5tBuK","BwLUAvbYB2C","CfnWr0S","whfLzKG","z21etKO","Aw9UvgLTzw8","x2n1CNnVCKy"];return Xn=function(){return n},Xn()}var Y={};(()=>{let n=C,e={ydzla:function(i,t){return i(t)},dKSyl:function(i,t){return i+t},jYjgD:function(i,t){return i*t},VMABR:function(i,t){return i*t},MsoQw:function(i,t,r){return i(t,r)},UnWJR:function(i,t){return i(t)},tqTcy:function(i,t){return i(t)},oFUjN:n(685),dJBZE:"ffff",tXggj:function(i,t){return i>t},zACPV:function(i,t){return i<t},Iqdyx:function(i,t){return i!==t},HSTDu:function(i,t){return i-t},BlOBO:function(i,t){return i<t},ohwOX:function(i,t){return i===t},FzTCs:function(i,t){return i!==t},ssfkf:"uacVQ",CMQWM:n(1068)+"d error.",WBAfq:function(i,t){return i===t},JcVDq:n(1523),oHYuz:function(i,t){return i(t)},jimZI:function(i,t,r){return i(t,r)},URpxB:function(i,t){return i===t},vYFOU:"Missing "+n(666)+n(930)+n(1195),RHGyu:function(i){return i()},XKmeT:function(i,t,r){return i(t,r)},KXJvD:function(i,t){return i<=t},CAsYr:function(i,t){return i+t},ntcfc:function(i,t){return i!==t},KtrhV:n(1404),RgJfl:function(i,t,r){return i(t,r)},oySyg:function(i,t){return i!==t},EEfPn:function(i,t,r){return i(t,r)},hdKyI:function(i,t){return i!==t},fSEIy:function(i,t,r){return i(t,r)},OBkqT:function(i,t,r){return i(t,r)},rJltx:function(i,t){return i(t)},ecczK:function(i,t){return i!==t},pTfel:function(i,t,r){return i(t,r)},unZsR:function(i,t){return i!==t},LBLFe:function(i,t,r){return i(t,r)},dmIPy:function(i,t){return i(t)},ulXfv:function(i,t,r){return i(t,r)},TmEIw:function(i,t){return i!==t},bIPWh:function(i,t,r){return i(t,r)},EmqrG:function(i,t,r){return i(t,r)},ggGRu:function(i,t,r){return i(t,r)},LExjS:function(i,t){return i(t)},EavzQ:n(1017),vwXXS:function(i,t){return i(t)},BuhCp:n(1592),CsqjM:"jPVqK",Kehyp:function(i,t,r){return i(t,r)},tOcQW:function(i,t){return i(t)},fmeun:function(i,t){return i(t)},ywjTT:function(i,t){return i(t)},kicpZ:function(i,t){return i(t)},NTkpO:function(i,t,r){return i(t,r)},UcSRE:function(i,t){return i(t)},KczmL:function(i,t,r){return i(t,r)},GnGgV:function(i,t){return i(t)},RZpRH:function(i,t,r){return i(t,r)},nvoea:function(i,t){return i(t)},lFYgW:function(i,t){return i(t)},PKYUX:function(i,t,r){return i(t,r)},MtklT:function(i,t){return i===t},ODthK:n(929)+n(666)+n(930)+n(960),GNJfx:function(i,t){return i===t},VQFYT:n(929)+"required"+n(930)+n(1212),WGMjt:function(i,t){return i===t},yvZYp:n(929)+n(666)+n(930)+"service",laojY:"Missing "+n(666)+n(930)+n(1834),YRJSR:function(i,t){return i+t},iCnda:function(i,t){return i===t},llQOv:n(1634),chyzJ:function(i,t){return i&t},gXhSp:function(i,t,r){return i(t,r)},OudtU:function(i,t,r){return i(t,r)},RrKwO:function(i,t){return i>>t},MGAGv:function(i,t){return i>=t},xfRKt:function(i,t){return i+t},WyByV:function(i,t){return i>t},UznMM:function(i,t){return i*t},gHTNj:n(749),fqWLy:n(1138),jCyYz:"Read pas"+n(638),yJrJK:function(i,t){return i+t},Vfhtl:function(i,t,r){return i(t,r)},oaFQo:function(i,t){return i<t},iuUJi:function(i,t){return i+t},YDmlD:function(i,t){return i(t)},BeGkz:function(i,t){return i===t},KUERD:function(i,t){return i&t},QoNYj:function(i,t){return i+t},FBAai:function(i,t){return i!==t},QBhKh:function(i,t){return i|t},fKbkI:function(i,t){return i<<t},ESqxV:function(i,t){return i&t},JllXl:function(i,t){return i&t},bbtPp:function(i,t){return i(t)},MUlNX:function(i,t){return i&t},CEjOw:function(i,t){return i>=t},pfwVY:function(i,t){return i+t},MJBww:function(i,t){return i+t},TWpCB:function(i,t){return i+t},KxCKH:function(i,t){return i&t},TuVlr:function(i,t){return i<<t},ETiNk:function(i,t){return i!==t},nqmTu:n(1148),bYKJA:function(i,t){return i<<t},VCPAG:function(i,t){return i&t},knhGf:function(i,t){return i<=t},gQkEV:function(i,t){return i!==t},uGePh:"CaKCZ",dyHnR:function(i,t){return i==t},iliwt:function(i,t){return i&t},dVxHb:function(i,t){return i+t},pzJmJ:function(i,t){return i+t},tXRDr:function(i,t){return i+t},LdBUN:function(i,t){return i+t},UGBkt:function(i,t){return i|t},oTQpN:function(i,t){return i<<t},UAKqZ:function(i,t){return i<<t},ILIsK:function(i,t){return i&t},BniQP:function(i,t){return i(t)},CizyX:n(1771),ovpVy:n(1840)+n(1344)+"s",QyhQy:n(1840)+n(916)+"t",oaHLQ:function(i,t){return i<=t},mcmJa:function(i,t){return i|t},UaTuO:function(i,t){return i&t},olhdH:function(i,t){return i|t},PZvUV:function(i,t){return i&t},cElmk:function(i,t){return i<t},lPhim:n(1603),jdyGG:function(i,t){return i<=t},iIlOA:function(i,t){return i<t},mLZlc:function(i,t){return i+t},fGTFG:function(i,t){return i<t},yaPuH:function(i,t,r){return i(t,r)},TTjWT:function(i,t){return i<t},yxAjL:function(i,t){return i>=t},YFXeg:function(i,t){return i<t},hdaIP:function(i,t){return i-t},xeaYl:function(i,t){return i<<t},CsdHL:function(i,t){return i<t},iDUHP:function(i,t){return i>>t},PFBEY:n(1512),JXCGS:function(i,t){return i<t},nbEGf:function(i,t){return i|t},FvVwq:function(i,t){return i&t},sOKxu:function(i,t){return i|t},bryea:function(i,t){return i>>t},dKmsJ:function(i,t){return i&t},zmPyE:function(i,t){return i>>t},DccvT:function(i,t){return i<=t},BPYSM:n(1776),Jamkf:function(i,t){return i<t},nQzTe:function(i,t,r){return i(t,r)},UKQTC:n(436),NTDIG:"vZrOo",DPGOT:function(i,t){return i<<t},KlktU:function(i,t){return i&t},UTfbq:function(i,t){return i===t},EDMdT:n(1838)+n(1247),FoRCN:"store",epqWA:function(i,t){return i&t},urpsU:function(i,t){return i&t},SMbxy:function(i,t){return i!==t},lTgEZ:n(654),ZtpUN:n(912),OHzot:function(i,t){return i<<t},RiAbp:function(i,t){return i&t},IswsA:function(i,t){return i<<t},oPmIa:function(i,t){return i&t},CaSbS:function(i,t){return i!==t},jBhGF:n(1622),CSgXb:function(i,t){return i(t)},zrBLm:function(i,t){return i&t},Kqodt:function(i,t){return i&t},fGUIv:function(i,t){return i<<t},qBJFG:function(i,t){return i&t},gtfgN:function(i,t){return i&t},RFede:function(i,t){return i(t)},swfCj:function(i,t){return i<<t},SChjj:function(i,t){return i&t},oYHzM:n(1694),bYnfG:function(i,t){return i&t},VMIob:function(i,t){return i|t},nFONY:function(i,t){return i>>>t},yMJxb:function(i,t){return i<<t},tPDfr:function(i,t){return i===t},qcEsu:function(i,t){return i<t},eUkzl:function(i,t){return i<t},ZUcWB:function(i,t){return i<t},IqPUP:function(i,t){return i+t},dQbgm:function(i,t){return i&t},yTait:function(i,t){return i>>>t},uDXaY:function(i,t){return i+t},GBexx:function(i,t){return i>>>t},tmAGP:function(i,t){return i>>>t},ivCuY:function(i,t){return i+t},TzTnE:function(i,t){return i!==t},ubrfU:function(i,t){return i&t},TrhbX:function(i,t){return i+t},ZAjfM:function(i,t){return i|t},oqqXC:function(i,t){return i!==t},qsjVC:function(i,t){return i>>>t},hvKVO:function(i,t){return i|t},NYzXH:function(i,t){return i&t},uSUqo:function(i,t){return i>>>t},bJLDn:function(i,t){return i(t)},zmhtc:function(i,t){return i===t},XOmEx:function(i,t){return i|t},xjrgF:function(i,t){return i<<t},bZiQj:function(i,t){return i|t},WtnZg:function(i,t){return i|t},vxaZD:function(i,t){return i<<t},UFXZG:function(i,t){return i<<t},pxwWL:function(i,t){return i|t},NNxSn:function(i,t){return i<<t},SsZME:function(i,t){return i<<t},MGogh:function(i,t){return i>>>t},QVgwG:function(i,t){return i|t},ifNny:function(i,t){return i<<t},EeDJc:function(i,t){return i<<t},WOyhY:function(i,t){return i>>>t},ngHwx:function(i,t){return i|t},WQWAm:function(i,t){return i&t},gMRKS:function(i,t){return i>>>t},TlQfL:function(i,t){return i&t},ecILp:function(i,t){return i&t},FJSeB:function(i,t){return i>>>t},hGHKd:function(i,t){return i>>>t},wdDjV:function(i,t){return i>>>t},TihjN:n(757),lXXYh:function(i,t){return i|t},seBiO:function(i,t){return i%t},iIYWK:function(i,t){return i/t},TMeyQ:function(i,t){return i===t},yqreZ:function(i,t){return i&t},BdPLF:function(i,t){return i>>>t},aLfUq:function(i,t){return i&t},vhVkr:function(i,t){return i&t},xDUfY:function(i,t){return i>>>t},xJdze:function(i,t){return i+t},jMwNy:function(i,t){return i>>>t},HLWXr:function(i,t){return i<<t},dxgyD:function(i,t){return i!==t},vzpjS:function(i,t){return i>>>t},NKWPk:function(i,t){return i===t},GcmtK:function(i,t){return i*t},VDsDs:"whwVt",ImtuP:n(1359),OnWYS:function(i,t){return i===t},uDJBo:function(i,t){return i===t},JvftS:n(927),vCrlM:n(439),sPcLs:n(1215),aFBgK:n(1453),sKNPI:function(i,t){return i&t},cDMoE:function(i,t){return i>>>t},IlQFC:function(i,t){return i&t},ZZXkQ:function(i,t){return i>>>t},VfuGL:function(i,t){return i&t},mUmCA:function(i,t){return i>>>t},TKncm:function(i,t){return i>>>t},YplaP:function(i,t){return i&t},RhEMX:function(i,t){return i&t},vnXLo:n(1662)+n(630),CgsMB:n(780)+"NG_ERROR",BzeXr:n(1814)+"ERROR",EGliF:"OPEN_ERROR",LarXX:n(1698)+"IES_ERROR",fGCaE:n(1473)+n(676),WZtal:function(i,t){return i===t},fOOWu:"LPnSa",cgpSA:function(i,t){return i!==t},TePEX:n(469),QpYPP:n(708)+n(1295),zsJvw:function(i,t){return i|t},zRyVa:function(i,t){return i&t},uhEqK:function(i,t){return i<t},dyewE:function(i,t){return i(t)},fJgwH:function(i,t){return i!==t},VnsCG:"ijyNq",CPYUZ:n(548),rwoWT:"2|3|4|1|0",WYLya:n(1268),gfUpW:n(1617),BkbXN:n(855),hkgXN:function(i,t){return i-t},PGHjv:function(i,t){return i===t},QzlNy:function(i,t){return i>t},FoWjf:function(i,t,r){return i(t,r)},tmARX:function(i,t){return i<t},iTKPa:function(i,t){return i+t},kEwBu:n(973),XxWwU:function(i,t){return i instanceof t},RaUbG:function(i,t){return i+t},sKuOT:function(i,t){return i===t},oMdHY:function(i,t){return i===t},xDhMI:function(i,t){return i<t},jDJEd:"CQRvF",RTMvl:n(1136),sxYop:function(i,t){return i!==t},yzqni:n(1424),pYwKy:n(538),qNIHx:"lRtrF",kJNki:function(i,t,r){return i(t,r)},tMTac:n(465),CIqCs:n(1240)+n(1430)+n(546)+"ine",vhEtr:function(i,t){return i+t},sxnjW:function(i,t){return i|t},llwfx:function(i,t){return i<<t},ZvgSM:function(i,t){return i&t},vyHDk:n(1173),DsEcS:function(i,t,r){return i(t,r)},FUEwc:n(750),ShXBZ:n(503),CcVJL:n(814),zwVkz:function(i,t){return i===t},KHPCp:"anEus",DEHqh:n(1043),rUBCn:function(i,t){return i===t},zgMgP:n(1401),ESHOq:function(i,t,r){return i(t,r)},ZxFge:function(i,t){return i&t},mQgQK:function(i,t,r){return i(t,r)},sPyYP:function(i,t){return i!==t},jOprG:"nyIcY",goRrt:n(1779),NcYbw:function(i,t){return i!==t},QQbpK:n(594),Pekte:n(640),UUOxg:n(1053),QBkZc:function(i,t){return i||t},KdCLu:function(i,t){return i!=t},RWvDP:n(1163)+"d",qLxbQ:n(1797)+"3",QuPMd:"next() c"+n(1365)+"ltiple times in "+n(874),WiHTY:function(i,t){return i<t},OVyQO:function(i,t){return i<t},sPxOg:function(i,t){return i<<t},nDRdx:function(i,t){return i>=t},wssvq:function(i,t){return i<<t},JzllD:function(i,t){return i-t},BXaPU:function(i,t){return i<<t},PhDLe:function(i,t){return i<<t},QrbwX:function(i,t){return i&t},XJdpV:function(i,t){return i&t},IOQFV:function(i,t){return i&t},xMllb:function(i,t){return i+t},tcxFn:function(i,t){return i+t},PGsUx:function(i,t){return i&t},QoINW:function(i,t){return i<t},OtfeA:function(i,t){return i<t},PPnCM:function(i,t){return i<t},qvvgW:function(i,t){return i|t},kJyQk:function(i,t){return i>>t},GlzBP:function(i,t){return i&t},FNScT:function(i,t){return i===t},ZkXTr:function(i,t){return i&t},bnEvY:function(i,t){return i|t},BUFew:function(i,t){return i&t},xRXNx:function(i,t){return i|t},zqSvh:function(i,t){return i+t},iQBsy:function(i,t){return i|t},ARTlv:function(i,t){return i|t},CvQgZ:function(i,t){return i>>t},DTrBS:function(i,t){return i|t},elApL:function(i,t){return i&t},hcsAD:function(i,t){return i|t},fgBpW:function(i,t){return i==t},cyfue:n(1586),RNIHI:function(i,t){return i||t},eRsSu:function(i,t){return i===t},mfgca:n(1882),VtOst:"sLJIx",bGRCY:n(1092),beWcG:function(i,t){return i!=t},uZERq:function(i,t){return i instanceof t},JPpEw:function(i,t){return i instanceof t},EQmAv:"application/json",gfQQZ:function(i,t){return i!==t},Cejpq:n(1358),Giepm:"fGfEH",Srtlo:function(i,t){return i==t},LIVeH:n(1184)+"in;charset=utf-8",AVROz:n(1437),KyBmQ:function(i,t){return i===t},zZxdb:n(1081),fZkTX:function(i,t){return i(t)},QcRJP:"unknown "+n(1151),ENigS:n(1896),jdHNw:n(579)+n(1668),rbTeB:function(i,t){return i+t},VLmpG:n(887),PtAzB:"&jscallb"+n(1844)+n(786)+"P",PCMSF:function(i,t){return i===t},gUyhy:n(1198),FdLAz:"idb",JKInE:function(i){return i()},nKjyP:function(i,t,r,a){return i(t,r,a)},cMcut:n(1711),bxpIN:"dQuRo",yXVOY:"versionc"+n(931),RFQdm:n(1499),nMsNX:function(i,t){return i||t},jLMgI:function(i,t){return i||t},fRSOe:function(i,t,r){return i(t,r)},IBQhQ:"hQoMc",CySEG:function(i,t){return i||t},HrDsg:function(i,t){return i||t},YTagl:function(i,t){return i<t},CmUyT:function(i,t){return i===t},xSTkz:n(1887),ZpIAw:function(i,t){return i||t},lTTWs:function(i,t){return i||t},mQofC:function(i,t){return i!=t},YuejF:"init QoS"+n(901)+"d",ltpgL:function(i,t,r){return i(t,r)},hkyEl:"qos",RgTng:n(621),GeKmc:function(i,t,r){return i(t,r)},OddFf:n(878),Hsnwe:function(i,t,r){return i(t,r)},uyxah:"sLvXA",lsIHL:function(i,t){return i+t},vRWUe:function(i,t){return i!==t},XtLHM:n(896),AbFkH:function(i,t){return i(t)},dswRZ:function(i,t){return i===t},rwUFP:function(i,t){return i instanceof t},DUybW:n(1408),sNiqE:function(i,t,r,a){return i(t,r,a)},hYsAu:"x_fronti"+n(738)+"k",plnpT:function(i,t,r){return i(t,r)},Ntnou:n(1527)+"er_ack_msgid",Ignct:n(767),IByui:function(i,t,r,a){return i(t,r,a)},KcXzg:n(804),wySdM:function(i,t){return i&&t},HevUc:n(455),iwDnf:n(1558),uOJRw:function(i){return i()},Yefvx:n(1197),yYsHJ:n(1345),Yjmem:function(i){return i()},lWfXl:n(1064)+n(624)+n(1521)+n(871),BVnSo:n(642)+"e",ITMRn:"binary",MAEnX:function(i,t){return i(t)},APtyK:function(i,t){return i+t},zDxEz:function(i,t){return i|t},rvtSt:function(i,t){return i(t)},BiXda:function(i,t){return i+t},gjZvf:n(1276),nbHlV:function(i,t){return i||t},PGFxm:n(1186),bzouK:n(1604),WmCbE:"seBSS",OSCZF:n(601)+n(1208)+"e",sENnO:function(i,t){return i&t},ornpz:function(i,t,r,a){return i(t,r,a)},tgWMg:function(i,t){return i+t},NdZyR:n(1636)+"1",tsCcm:function(i,t){return i+t},LVKrS:function(i,t){return i+t},jXRUe:function(i,t){return i+t},cVylC:function(i,t){return i<<t},SDtMh:function(i,t){return i+t},hTBVq:function(i,t){return i<<t},AqCQy:function(i,t){return i<<t},yopKy:function(i,t){return i<<t},uzWoq:function(i,t){return i+t},toVta:function(i,t){return i>>>t},gDwWR:function(i,t){return i&t},pyuxB:function(i,t){return i+t},jIeyU:function(i,t){return i>>>t},PkumF:function(i,t){return i&t},stKjU:function(i,t){return i+t},TnTyz:function(i,t){return i&t},qPDlu:function(i,t){return i&t},klinm:function(i,t){return i>>>t},VzMYW:function(i,t){return i>>>t},jFMmp:function(i,t){return i|t},PcVuZ:function(i,t){return i&t},tquwK:function(i,t){return i<t},XqefH:function(i,t){return i|t},xVCrv:function(i,t){return i>>>t},RLUSL:function(i,t){return i&t},xZEgj:function(i,t){return i>t},LHVqt:n(1856),xLwZM:function(i,t,r,a){return i(t,r,a)},isKyP:function(i,t){return i<t},pJznh:function(i,t){return i(t)},HvqlN:function(i,t){return i+t},FnJXm:n(1804)+"ervice",AJuWp:n(1643),rtwyS:n(1847),DIeTm:n(1536)+n(1218),WZknv:function(i,t,r,a){return i(t,r,a)},FkhIG:function(i,t){return i(t)},iFUwv:function(i,t){return i(t)},MSCsX:n(789)+n(1772),xlEWN:"FILE_NOT"+n(1132),zuRya:"allCurso"+n(1386),UENAH:n(831),Mzkav:"INSTANT",GobHn:"CONTINUE",YdFGY:function(i){return i()},MmHXj:n(937),qmDlo:function(i,t){return i>t},xyOve:n(1574),iVqdp:n(711)+"r",oGdgv:function(i,t){return i||t},dffso:function(i,t){return i!=t},RgQlH:function(i,t){return i instanceof t},LceaQ:function(i,t,r,a){return i(t,r,a)},FcIXu:function(i,t){return i(t)},poQcm:n(1252)+n(1426)+"e",EGOXU:"x-msg-cu"+n(905)+"ue",Ltgcm:function(i,t){return i>t},IwShe:"aqCdH",NBZGV:"lFRQd",UoLhV:n(1503),iXPZn:function(i,t){return i<t},imkHX:function(i){return i()},zUmHz:function(i,t){return i&t},KWGaL:function(i,t){return i&t},JYBen:function(i,t){return i<=t},jJVVH:function(i,t){return i===t},rLeuS:function(i,t,r){return i(t,r)},BKXAi:function(i){return i()},XKush:function(i,t){return i(t)},BBber:function(i,t){return i!==t},mbuIN:function(i,t){return i(t)},FGEtN:function(i,t,r){return i(t,r)},FzaMZ:"iHxPU",SxJtp:n(1119),PXHeM:function(i,t,r){return i(t,r)},OWJTv:function(i,t){return i(t)},vrBqK:function(i,t){return i!==t},LHPav:n(474),gBeIn:function(i,t){return i===t},rcEWT:"always",FzLLA:"auto",kmFof:function(i,t,r,a){return i(t,r,a)},VEFWl:function(i,t,r){return i(t,r)},phzLa:function(i,t){return i||t},vlsbV:function(i,t){return i||t},JzGrs:function(i,t){return i||t},vbquQ:function(i,t){return i===t},MzmBW:n(1137)+n(651),nzpSj:function(i,t){return i===t},Fpznw:n(722)+n(1669)+"alid url",lsPsP:n(722)+n(530)+n(588)+n(1863)+"ket cons"+n(1410)+"is undefined",mUTLf:"sPirD",vkxHt:n(743)+n(609)+n(1494)+"ct",lWEVS:function(i,t){return i===t},HDXdN:n(545),otFmI:n(1217)+n(1452),LJGJd:function(i,t){return i|t},XMdzZ:function(i,t){return i&t},eKNyY:function(i,t){return i+t},ukTLb:function(i,t){return i>>t},dofrp:function(i,t){return i&t},wLfPJ:"IgEts",RmpJx:function(i,t){return i<=t},PukOY:n(1213),LNVVg:"pageshow",EmPYS:"curvalue",xgPgS:function(i,t){return i!==t},DHPiZ:n(707),bwlbn:n(922),hsqzJ:"https:",HJmdj:n(1346),qdIrV:n(1194),QOZzC:n(816)+"d",kLXas:"please p"+n(988)+n(698)+n(812)+"r ttwID",dVvpu:function(i,t){return i==t},PIywc:function(i,t,r){return i(t,r)},FYkjf:n(994),cHJTx:"fws_1.0.0",WUzVi:function(i,t,r){return i(t,r)},SSkoE:"start",uRJzg:function(i,t){return i(t)},wZVoF:function(i,t){return i(t)},MyGjH:function(i,t){return i-t},KTSAx:function(i,t){return i>t},rPxww:function(i,t){return i!==t},MFSMN:function(i,t,r){return i(t,r)},zLQPl:function(i,t){return i!==t},gMPbq:n(1619),nHvhY:n(1240)+n(527)+n(1505)+"ting server",xESzb:n(562)+n(1321)+"onnecting",lluPk:function(i,t){return i+t},IMlio:function(i,t){return i+t},NCMAq:function(i,t){return i+t},trNnG:function(i,t){return i|t},hAnsz:function(i,t){return i<<t},fsLKN:function(i,t){return i|t},FONuB:function(i,t){return i|t},NiiXY:function(i,t){return i<<t},QxTzg:function(i,t){return i<<t},JXhsl:function(i,t){return i&t},lHejZ:function(i,t){return i&t},mhCGr:function(i,t){return i+t},sPIUY:function(i,t){return i+t},HVwix:function(i,t){return i!==t},wtmIy:"sDkkT",MBzDr:function(i,t){return i(t)},lhDdo:n(774)+"0",fswNV:function(i,t){return i!==t},OwMxR:function(i,t,r){return i(t,r)},HqmBd:"OoaWY",ClmcF:n(1641),TsYeH:n(1514),oFwyN:"PXVhJ",YtHsj:n(1113),eZFTX:n(639),HlWRc:n(1493),NuUBK:function(i,t){return i+t},ObFvb:n(519),qfozD:n(1642),ANjhM:function(i,t){return i-t},oivDV:function(i,t){return i<=t},dMXRF:function(i,t){return i>=t},CFixh:function(i,t){return i&t},OBOTd:function(i,t){return i|t},BzzPd:function(i,t){return i|t},hyYfP:function(i,t){return i<<t},fPyGI:function(i,t){return i<<t},xDqHe:function(i,t){return i&t},oJWZo:function(i,t){return i>=t},vNngR:function(i,t){return i-t},cVdje:function(i,t){return i<<t},xXtSM:function(i,t){return i<<t},wIuaC:function(i,t){return i<<t},cVKLc:function(i,t){return i+t},BqIXb:function(i,t){return i+t},UPDxI:"BUSDw",CCUCs:n(1280)+"s alread"+n(1147),HgOSp:function(i,t){return i(t)},yXFmD:function(i,t){return i+t},oKFxI:function(i,t){return i+t},OakIl:n(1421)+n(849)+n(561),LAKmR:function(i,t){return i||t},Qudqc:n(722)+"rovide a"+n(1035)+n(1304)+n(792)+"e a stri"+n(1839)+n(1008)+"ffer",AqYRj:function(i,t){return i==t},hGJnS:"number",fNnjG:function(i,t){return i instanceof t},eeAGf:function(i,t){return i(t)},PnhPC:function(i,t){return i||t},kYVkv:n(722)+n(1795)+n(739)+"ervice",nWTYc:function(i,t){return i instanceof t},HtTlT:"enqueue",dzDGj:"KxiTZ",mabrR:function(i,t){return i!==t},diHhu:function(i,t){return i===t},DRVkl:n(1626),FvTgf:n(1044)+"4",FqFmA:function(i,t,r){return i(t,r)},VZdoN:function(i,t){return i!==t},OBbfo:n(1602),WBFsv:function(i,t){return i(t)},VTfNK:n(998),pZcXi:n(478),yVSZu:function(i,t,r){return i(t,r)},cCeMW:n(615),MWpAr:n(1446),FRalA:function(i,t){return i/t},tPacw:function(i,t){return i===t},RquCA:function(i,t){return i===t},WHhoZ:n(440),PoWoa:function(i,t){return i!=t},NPnjj:function(i,t){return i===t},OjWiU:n(612)+n(673)+n(969)+"pe",qRDja:n(977),ZWPbr:function(i,t){return i!=t},FEpFT:function(i,t){return i!=t},wKAgJ:function(i,t){return i===t},JhilN:"SharedWorkerGlobalScope",RSDRZ:function(i,t){return i===t},QogQH:function(i,t){return i!=t},CHDgZ:"__x_msg_"+n(1403)};Be.r(Y),Be.d(Y,{FWS:()=>rc,CustomErrorEvent:()=>qi,createCloseEvent:()=>Ae,ReconnectEvent:()=>Ui,createErrorEvent:()=>ye,decodedFrame:()=>Ie,createOpenEvent:()=>Ji,CustomCloseEvent:()=>Hi,createReconnectEvent:()=>Cr,FrontierMessageEvent:()=>ji,encodeFrame:()=>Er,createMessageEvent:()=>Wi,OpenEvent:()=>Gi,ErrorCode:()=>Xe,Event:()=>gt,MessageEvent:()=>Ki});let s="";function o(i=""){let t=n,r="02",a=""+Date[t(1106)](),d=s||(s=e.ydzla(m,i)),h=Math[t(807)]()[t(1477)](16)[t(1067)](-6);return e.dKSyl(r,a)+d+h}function c(){let i=n;return e.dKSyl(e[i(865)](1e4,Date[i(1106)]()),Math[i(710)](e[i(795)](1e4,Math[i(807)]())))}function x(i){let t=n;return(Array(8).join("0")+e[t(1420)](parseInt,i,10)[t(1477)](2))[t(1067)](-8)}function u(i){let t=n;return e[t(1692)](e[t(744)](Array,4)[t(658)]("0"),e[t(1420)](parseInt,i,2).toString(16))[t(1067)](-4)}function l(i){let t=n,r=i[t(1884)](/\./)[t(1363)](h=>x(h)),a=[];return a[0]=e[t(744)](u,e[t(1692)](r[0],r[1])),a[1]=e.tqTcy(u,r[2]+r[3]),[e.oFUjN,e.oFUjN,e[t(413)],"0000",e.oFUjN,e.dJBZE,a[0],a[1]][t(658)]("")}function m(i){let t=n,r=/(25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?)(\.(25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?)){3}/[t(1313)](i),a=/(([0-9a-fA-F]{1,4}:){7,7}[0-9a-fA-F]{1,4}|([0-9a-fA-F]{1,4}:){1,7}:|([0-9a-fA-F]{1,4}:){1,6}:[0-9a-fA-F]{1,4}|([0-9a-fA-F]{1,4}:){1,5}(:[0-9a-fA-F]{1,4}){1,2}|([0-9a-fA-F]{1,4}:){1,4}(:[0-9a-fA-F]{1,4}){1,3}|([0-9a-fA-F]{1,4}:){1,3}(:[0-9a-fA-F]{1,4}){1,4}|([0-9a-fA-F]{1,4}:){1,2}(:[0-9a-fA-F]{1,4}){1,5}|[0-9a-fA-F]{1,4}:((:[0-9a-fA-F]{1,4}){1,6})|:((:[0-9a-fA-F]{1,4}){1,7}|:)|fe80:(:[0-9a-fA-F]{0,4}){0,4}%[0-9a-zA-Z]{1,}|::(ffff(:0{1,4}){0,1}:){0,1}((25[0-5]|(2[0-4]|1{0,1}[0-9]){0,1}[0-9])\.){3,3}(25[0-5]|(2[0-4]|1{0,1}[0-9]){0,1}[0-9])|([0-9a-fA-F]{1,4}:){1,4}:((25[0-5]|(2[0-4]|1{0,1}[0-9]){0,1}[0-9])\.){3,3}(25[0-5]|(2[0-4]|1{0,1}[0-9]){0,1}[0-9]))/[t(1313)](i);return r?l(i):a?w(i):t(451)+t(451)+t(451)+t(451)}function w(i){let t=n,r="",a=[],d=0,h=0,p=!0,g=e[t(413)];if(e[t(1464)](i[t(1243)]("::"),-1)){let f=i[t(1884)]("::");for(let b=0;b<f[t(1294)];b++){let I=f[b];if(I[t(1243)](":")>0){let L=I[t(1884)](":");p&&(d=L[t(1294)]),h+=L[t(1294)];for(let B=0;e[t(657)](B,L[t(1294)]);B++)if(e[t(1848)](4,L[B][t(1294)])){let O=g[t(566)+"g"](0,4-L[B].length),ve=O[t(1570)](L[B]);a[t(1281)](ve)}else a[t(1281)](L[B]);p=!1}else{if(e[t(1848)](4,I[t(1294)])){let L=g[t(566)+"g"](0,e[t(706)](4,I[t(1294)])),B=L[t(1570)](I);a[t(1281)](B)}else a[t(1281)](I);p&&(d+=1),h+=1,p=!1}}let _="";for(let b=0;e[t(660)](b,e[t(706)](8,h));b++)_=_.concat(g);for(let b=0;e[t(657)](b,a[t(1294)]);b++)e.ohwOX(b,d)?(r=r[t(1570)](_),r=r.concat(a[b])):r=r[t(1570)](a[b]);return r}{let f=i.split(":");for(let _=0;e[t(657)](_,f[t(1294)]);_++){let b=f[_];if(f[_][t(1294)]!==4){let I=g[t(566)+"g"](0,e[t(706)](4,f[_].length)),L=I[t(1570)](b);r=r.concat(L)}else r=r[t(1570)](b)}return r}}function v(i,t){let r=n,a=i[r(1526)];e.FzTCs(void 0,a)&&(X(t,10),ge(t,a));let d=i[r(1195)];if(e[r(1848)](void 0,d)){if(e.FzTCs(e.ssfkf,e[r(1842)]))return new _0x26ea30(h=>{_0x56556b(h,this._getIntervalValue(_0x3a40cf))});X(t,18),ge(t,d)}}function y(i){let t=n,r={};e:for(;!e.ydzla(z,i);)if(e[t(884)](t(1523),e[t(1396)])){let a=e[t(1721)](G,i);switch(a>>>3){case 0:break e;case 1:r.key=e.jimZI(fe,i,e[t(744)](G,i));break;case 2:r[t(1195)]=e[t(1255)](fe,i,e.UnWJR(G,i));break;default:re(i,7&a)}}else{let a=_0x39f506.length&&_0x164fb9[0];if(a instanceof _0x43192d)throw a;let d=new _0x21092a(e[t(1692)](e[t(1739)],a?e[t(1692)](" (",a[t(1268)])+")":""));throw d[t(499)]=a,a}if(e[t(1681)](void 0,r.key))throw new Error("Missing "+t(666)+" field: "+t(1526));if(e.URpxB(void 0,r[t(1195)]))throw new Error(e.vYFOU);return r}function E(i){let t=n,r=e[t(1650)](ee);return e.XKmeT(k,i,r),A(r)}function k(i,t){let r=n,a={SsLJG:function(be,Se){return e[D(1835)](be,Se)},OXvyM:function(be,Se){return e[D(747)](be,Se)}},d=i[r(960)];if(e[r(748)](void 0,d))if(e.WBAfq(e.KtrhV,r(1777))){if(a[r(1683)](_0x363dad,-_0x38e9bf))return _0x396717;if(a[r(461)](_0x303570,1)>=_0x3ed56f)return _0x4a4ee4}else e[r(1368)](X,t,8),e[r(1170)](Ue,t,d);let h=i[r(1212)];e.oySyg(void 0,h)&&(X(t,16),e[r(1554)](Ue,t,h));let p=i[r(1847)];e[r(1891)](void 0,p)&&(e.fSEIy(X,t,24),e[r(838)](Ue,t,e.rJltx(J,p)));let g=i[r(1834)];e[r(1006)](void 0,g)&&(e[r(1653)](X,t,32),e.XKmeT(Ue,t,J(g)));let f=i[r(406)];if(e.unZsR(void 0,f))for(let be of f){e[r(833)](X,t,42);let Se=ee();v(be,Se),X(t,Se[r(1899)]),st(t,Se),e[r(694)](oe,Se)}let _=i.payloadEncoding;e[r(410)](void 0,_)&&(e[r(1554)](X,t,50),e[r(552)](ge,t,_));let b=i[r(830)+r(1749)];b!==void 0&&(e[r(1420)](X,t,58),e[r(833)](ge,t,b));let I=i[r(1465)];I!==void 0&&(e[r(1296)](X,t,66),X(t,I[r(1294)]),e[r(1653)](Fe,t,I));let L=i[r(1259)];e[r(659)](void 0,L)&&(X(t,74),e[r(1170)](ge,t,L));let B=i[r(449)+r(898)];B!==void 0&&(e.bIPWh(X,t,82),e[r(1679)](ge,t,B));let O=i[r(842)];e.TmEIw(void 0,O)&&(e[r(1082)](X,t,90),ge(t,O));let ve=i.frameType;ve!==void 0&&(e[r(833)](X,t,96),e[r(1170)](Ue,t,e[r(1721)](J,ve)))}function P(i){let t=n;return e[t(1310)](T,e[t(854)](ae,i))}function T(i){let t=n,r={};e:for(;!e[t(852)](z,i);)if(e[t(748)](e[t(726)],e[t(558)])){let a=G(i);switch(a>>>3){case 0:break e;case 1:r[t(960)]=e[t(599)](ce,i,!0);break;case 2:r[t(1212)]=e[t(833)](ce,i,!0);break;case 3:r[t(1847)]=e[t(1118)](G,i);break;case 4:r[t(1834)]=e.fmeun(G,i);break;case 5:{let d=e[t(669)](F,i);(r[t(406)]||(r[t(406)]=[]))[t(1281)](y(i)),i.limit=d;break}case 6:r["payloadE"+t(1134)]=e.bIPWh(fe,i,e[t(1202)](G,i));break;case 7:r[t(830)+t(1749)]=e.NTkpO(fe,i,e.UcSRE(G,i));break;case 8:r[t(1465)]=e.KczmL(Te,i,G(i));break;case 9:r[t(1259)]=e[t(1679)](fe,i,e.GnGgV(G,i));break;case 10:r[t(449)+t(898)]=e[t(1133)](fe,i,e[t(741)](G,i));break;case 11:r[t(842)]=e[t(1296)](fe,i,e[t(854)](G,i));break;case 12:r[t(1756)+"e"]=e[t(1805)](G,i);break;default:e.PKYUX(re,i,7&a)}}else this[t(1630)](t(1017),_0x14157a(e[t(1376)],{..._0x4f3e17,message:_0x5a0466[t(1568)]||""}));if(e[t(1378)](void 0,r[t(960)]))throw new Error(e.ODthK);if(e[t(851)](void 0,r[t(1212)]))throw new Error(e[t(1094)]);if(e.WGMjt(void 0,r[t(1847)]))throw new Error(e[t(1850)]);if(r[t(1834)]===void 0)throw new Error(e[t(1647)]);return r}function F(i){let t=n,r=e[t(1651)](G,i),a=i.limit;return i[t(1899)]=e.YRJSR(i[t(1157)],r),a}function re(i,t){let r=n;if(e[r(782)](e[r(1377)],e[r(1377)]))switch(t){case 0:for(;e[r(785)](128,e[r(854)](te,i)););break;case 2:e[r(1443)](N,i,e[r(1651)](G,i));break;case 5:e[r(1110)](N,i,4);break;case 1:N(i,8);break;default:throw new Error(e[r(1692)](r(1596)+"ented type: ",t))}else return this[r(704)].isReady}function J(i){let t=n;return i|=0,{low:i,high:e[t(836)](i,31),unsigned:e.MGAGv(i,0)}}let we=[];function ee(){let i=n,t=we[i(597)]();return t?(t[i(1157)]=t[i(1899)]=0,t):{bytes:new Uint8Array(64),offset:0,limit:0}}function oe(i){we[n(1281)](i)}function ae(i){return{bytes:i,offset:0,limit:i[n(1294)]}}function A(i){let t=n,r=i[t(1156)],a=i.limit;return r[t(1294)]===a?r:r[t(1803)](0,a)}function N(i,t){let r=n;if(e[r(1464)](e.xfRKt(i[r(1157)],t),i.limit))throw new Error("Skip pas"+r(638));i.offset+=t}function z(i){let t=n;return e.MGAGv(i[t(1157)],i.limit)}function V(i,t){let r=n,a=i[r(1156)],d=i.offset,h=i.limit,p=e[r(933)](d,t);if(e[r(958)](p,a[r(1294)])){let g=new Uint8Array(e[r(850)](2,p));g[r(1541)](a),i[r(1156)]=g}return i[r(1157)]=p,e.WyByV(p,h)&&(i[r(1899)]=p),d}function _e(i,t){let r=n;if(e[r(851)](e[r(1609)],e[r(1589)]))this[r(1472)+"s"]=_0x213f35,this[r(1468)+"es"]=_0x330d38,this["currentI"+r(1534)]=0,this[r(1722)+"ndpointTriesCount"]=0;else{let a=i[r(1157)];if(e[r(1464)](e[r(1692)](a,t),i[r(1899)]))throw new Error(e[r(1898)]);return i[r(1157)]+=t,a}}function Te(i,t){let r=n,a=e.jimZI(_e,i,t);return i.bytes.subarray(a,e[r(1322)](a,t))}function Fe(i,t){let r=n,a=e[r(599)](V,i,t.length);i[r(1156)][r(1541)](t,a)}function fe(i,t){let r=n,a={EWzEV:function(_,b){return _(b)},tPpSW:function(_,b){return e[D(1088)](_,b)}},d=e[r(489)](_e,i,t),h=String[r(1831)+r(690)],p=i[r(1156)],g="\uFFFD",f="";for(let _=0;e[r(1751)](_,t);_++){let b=p[e[r(1606)](_,d)],I,L,B,O;e[r(785)](128,b)===0?f+=e[r(656)](h,b):e[r(472)](e[r(1608)](224,b),192)?e[r(1322)](_,1)>=t?f+=g:(I=p[e[r(1692)](e[r(644)](_,d),1)],e[r(1519)](192&I,128)?f+=g:(O=e.QBhKh(e[r(1618)](e[r(967)](31,b),6),e[r(665)](63,I)),e[r(1751)](O,128)?f+=g:(f+=e[r(560)](h,O),_++))):e[r(1463)](240,b)==224?e[r(421)](e[r(1085)](_,2),t)?f+=g:(I=p[e[r(1322)](e[r(1606)](_,d),1)],L=p[e[r(1362)](e[r(1496)](_,d),2)],e[r(1853)](I|e[r(1845)](L,8),49344)!==32896?f+=g:e.ETiNk(e[r(1639)],r(817))?(O=e[r(942)](e[r(942)](e[r(1405)](15&b,12),e[r(1618)](e[r(1608)](63,I),6)),e[r(939)](63,L)),O<2048||O>=55296&&e[r(1715)](O,57343)?f+=g:e[r(866)](e[r(667)],r(569))?_0x1a52fc[r(590)](_0x2595e6):(f+=h(O),_+=2)):(a[r(646)](_0x39463e,this[r(473)+r(1391)+"Id"]),a.tPpSW(_0x19323f,this["_reconnectTimeou"+r(889)]),this[r(473)+r(1391)+"Id"]=null,this[r(427)+r(1707)+r(889)]=null)):e[r(1543)](e.iliwt(248,b),240)?e[r(421)](e[r(644)](_,3),t)?f+=g:(I=p[e[r(1232)](e[r(1322)](_,d),1)],L=p[e[r(1476)](_+d,2)],B=p[e[r(723)](e[r(522)](_,d),3)],e[r(1848)](e[r(1463)](e.UGBkt(e.UGBkt(I,e[r(1845)](L,8)),e[r(1618)](B,16)),12632256),8421504)?f+=g:(O=e[r(942)](e[r(1712)](e[r(942)]((7&b)<<18,e[r(458)](e[r(1463)](63,I),12)),e[r(655)](e[r(425)](63,L),6)),e[r(785)](63,B)),e.zACPV(O,65536)||O>1114111?f+=g:(O-=65536,f+=h(e.RrKwO(O,10)+55296,e[r(939)](1023,O)+56320),_+=3))):f+=g}return f}function ge(i,t){let r=n,a={unYCY:function(f,_){return e.CEjOw(f,_)},BouWi:function(f,_){return e[D(422)](f,_)},VPLgD:function(f,_){return f<_},TgiCx:function(f,_){return f-_},ebCSL:function(f,_){return e[D(1120)](f,_)},MEwie:function(f,_){return e[D(785)](f,_)},iiahU:function(f,_){return e[D(836)](f,_)},fsLmX:function(f,_){return e[D(1354)](f,_)},LyOWH:function(f,_){return f>>_},OalvH:function(f,_){return e[D(870)](f,_)},fObYO:function(f,_){return e.PZvUV(f,_)}},d=t.length,h=0;for(let f=0;e[r(521)](f,d);f++)if(e[r(1550)]!==r(1603))e.BniQP(_0x16fe38,e[r(1738)]),this[r(875)](e.ovpVy,_0x317ba4),this[r(875)](e[r(751)],_0x4adeea);else{let _=t[r(1605)+"At"](f);e[r(421)](_,55296)&&e[r(1450)](_,56319)&&e[r(1822)](e[r(1476)](f,1),d)&&(_=e.mLZlc(_<<10,t[r(1605)+"At"](++f))-56613888),h+=e[r(1822)](_,128)?1:e[r(1822)](_,2048)?2:e[r(1353)](_,65536)?3:4}e[r(1420)](X,i,h);let p=e[r(613)](V,i,h),g=i.bytes;for(let f=0;e[r(1629)](f,d);f++){let _=t.charCodeAt(f);if(e[r(1740)](_,55296)&&e.oaHLQ(_,56319)&&e.YFXeg(f+1,d)&&(_=e[r(559)](e[r(925)](_,10)+t.charCodeAt(++f),56613888)),_<128)g[p++]=_;else{if(e.CsdHL(_,2048))g[p++]=e[r(942)](e[r(764)](e.iDUHP(_,6),31),192);else if(e[r(851)](e[r(1483)],e[r(1483)]))e.JXCGS(_,65536)?g[p++]=e[r(1508)](e.FvVwq(e.iDUHP(_,12),15),224):(g[p++]=e.sOKxu(_>>18&7,240),g[p++]=e[r(1610)](_,12)&63|128),g[p++]=e.dKmsJ(e[r(1371)](_,6),63)|128;else{let b=_0x424b90[r(1605)+"At"](_0x48244c);a[r(1366)](b,55296)&&a[r(1025)](b,56319)&&a[r(993)](_0x54294a+1,_0x5fced4)&&(b=a[r(1736)]((b<<10)+_0x2dab1e.charCodeAt(++_0x1e5c8c),56613888)),b<128?_0x3e6df5[_0x2f4c62++]=b:(a[r(993)](b,2048)?_0x34e1af[_0x149136++]=a.ebCSL(a.MEwie(b>>6,31),192):(a[r(993)](b,65536)?_0x14503d[_0x3b487f++]=a.ebCSL(a.iiahU(b,12)&15,224):(_0x286f42[_0x57b3b5++]=a[r(1010)](a[r(1347)](b>>18,7),240),_0x4e2ee3[_0x2fe09d++]=b>>12&63|128),_0x1d9ea9[_0x1bb319++]=a[r(1010)](a[r(1807)](a[r(799)](b,6),63),128)),_0x26493e[_0x26141d++]=a.OalvH(a[r(1279)](63,b),128))}g[p++]=e[r(870)](63&_,128)}}}function st(i,t){let r=n,a={digqC:function(d,h){return e[D(870)](d,h)},iMBvk:function(d,h){return e[D(665)](d,h)},TOOGf:function(d,h){return e[D(1618)](d,h)},FrAQZ:function(d,h){return d>=h},oamWf:function(d,h){return e.DccvT(d,h)},ApwCc:function(d,h){return d(h)}};if(e[r(1773)](r(535),e[r(1732)]))_0x5c6dff=epOMWO[r(1611)](epOMWO[r(1611)](epOMWO[r(1335)](15,_0x22a05c)<<12,epOMWO[r(672)](63&_0x38c38d,6)),63&_0x1a1aaf),_0xa2591a<2048||epOMWO[r(1656)](_0x2ad40f,55296)&&epOMWO[r(1061)](_0x61e417,57343)?_0x5e642d+=_0x2f0bb8:(_0x1ff2b8+=epOMWO[r(1236)](_0x393070,_0x4ee857),_0x1c9d76+=2);else{let d=e[r(833)](V,i,t[r(1899)]),h=i[r(1156)],p=t[r(1156)];for(let g=0,f=t[r(1899)];e[r(1658)](g,f);g++)h[g+d]=p[g]}}function te(i){let t=n;return i[t(1156)][e[t(1379)](_e,i,1)]}function ot(i,t){let r=n;if(e[r(851)](e.NTDIG,r(1254))){let a=e[r(539)](V,i,1);i[r(1156)][a]=t}else this[r(1630)](e[r(882)],_0x24f4c8),this[r(753)]&&this.onopen(_0x2cdf44)}function G(i){let t=n,r=0,a=0,d;do d=te(i),e.iIlOA(r,32)&&(a|=e[t(481)](e[t(1778)](127,d),r)),r+=7;while(128&d);return a}function X(i,t){let r=n;for(t>>>=0;e.CEjOw(t,128);)e[r(613)](ot,i,e.nbEGf(e.ESqxV(127,t),128)),t>>>=7;e[r(833)](ot,i,t)}function ce(i,t){let r=n,a={rCpoo:function(f,_){return f instanceof _},LcZHs:function(f,_){return f===_},pDnNe:r(506),JjJjs:function(f,_){return e.UTfbq(f,_)},zVTEb:e[r(1849)],fZMrW:e[r(1826)],ofwyf:function(f,_){return e.ywjTT(f,_)}},d=0,h=0,p=0,g;if(g=e[r(790)](te,i),d=127&g,e.PZvUV(128,g)&&(g=te(i),d|=e[r(1129)](127,g)<<7,e[r(1028)](128,g)))if(e[r(1407)](e[r(813)],e.ZtpUN)){if(g=e[r(1805)](te,i),d|=e[r(447)](e[r(1580)](127,g),14),e[r(665)](128,g)&&(g=te(i),d|=e[r(1102)](e[r(1664)](127,g),21),128&g)){if(e[r(1385)](e.jBhGF,r(1622)))return _0x4e6e11[r(908)]();if(g=e.CSgXb(te,i),h=e.zrBLm(127,g),e[r(1808)](128,g)&&(g=e.tqTcy(te,i),h|=e[r(1222)](e[r(1487)](127,g),7),e[r(972)](128,g)&&(g=e[r(1074)](te,i),h|=e.swfCj(e[r(1853)](127,g),14),e[r(764)](128,g)&&(g=te(i),h|=(127&g)<<21,e[r(1351)](128,g)&&(g=te(i),p=e[r(583)](127,g),e.JllXl(128,g))))))if(e.FBAai(r(762),e[r(1166)]))g=te(i),p|=e[r(1845)](e.bYnfG(127,g),7);else{if(uUCFFF[r(1149)](_0x3f1588,_0xdcf515)){if(uUCFFF[r(510)](_0xee7810,uUCFFF[r(776)]))return _0xf09813[r(893)](_0x3155d9);if(uUCFFF[r(435)](_0x28a528,uUCFFF[r(1352)]))return _0x128d8c[r(1838)+r(1247)]||_0x5868f8[r(893)](_0x4d31a7);if(uUCFFF[r(510)](_0x31afca,uUCFFF.fZMrW))return _0x299ab2[r(1838)+"oreNames"][1]?void 0:_0x4578e0[r(1838)+r(1533)](_0x42bbc3[r(1838)+r(1247)][0])}return uUCFFF[r(1684)](_0x334548,_0x7034f8[_0x49806e])}}}else _0x52b656[r(633)+r(978)+r(885)](r(1771),_0xdb19a2),_0x339557[r(633)+r(978)+r(885)](UGDtHK[r(1376)],_0x4a0cae);return{low:e[r(793)](d,e[r(925)](h,28)),high:e[r(1712)](e[r(1117)](h,4),e[r(848)](p,24)),unsigned:t}}function Ue(i,t){let r=n,a=e.nFONY(t[r(862)],0),d=e[r(1117)](e[r(1029)](e[r(1117)](t[r(862)],28),e.TuVlr(t[r(1447)],4)),0),h=e[r(1117)](t.high,24),p=h===0?e[r(1340)](0,d)?e[r(1615)](a,16384)?e[r(1535)](a,128)?1:2:a<2097152?3:4:e[r(505)](d,16384)?e[r(1658)](d,128)?5:6:d<2097152?7:8:e.ZUcWB(h,128)?9:10,g=e[r(1420)](V,i,p),f=i[r(1156)];switch(p){case 10:f[e.IqPUP(g,9)]=e[r(1023)](e.yTait(h,7),1);case 9:f[e[r(591)](g,8)]=p!==9?128|h:e[r(939)](127,h);case 8:f[g+7]=p!==8?e[r(793)](e[r(513)](d,21),128):e.tmAGP(d,21)&127;case 7:f[e[r(1063)](g,6)]=e.TzTnE(7,p)?e.nFONY(d,14)|128:e[r(1228)](d>>>14,127);case 6:f[e.iuUJi(g,5)]=e[r(1519)](6,p)?e[r(1374)](d,7)|128:e[r(764)](d>>>7,127);case 5:f[e[r(766)](g,4)]=e[r(1518)](5,p)?e[r(1174)](128,d):e[r(1808)](127,d);case 4:f[e.xfRKt(g,3)]=e[r(1209)](4,p)?e.qsjVC(a,21)|128:a>>>21&127;case 3:f[e[r(1476)](g,2)]=e[r(748)](3,p)?e[r(513)](a,14)|128:e[r(1175)](a,14)&127;case 2:f[e[r(1362)](g,1)]=e[r(452)](2,p)?e.hvKVO(e[r(1117)](a,7),128):e[r(1491)](e[r(1350)](a,7),127);case 1:f[g]=p!==1?e[r(1508)](128,a):127&a}}function Ie(i){return P(i)}function Er(i){return e[n(1167)](E,i)}let Bi=65536,h0=e[n(1638)],ht=Bi*Bi,Mi=e[n(850)](ht,ht),zi=e[n(556)](Mi,2),Ye=String.prototype[n(1605)+"At"];class K{constructor(t,r,a){let d=n;this[d(1753)]=!0,this.low=e.QBhKh(0,t),this.high=e[d(1712)](0,r),this[d(1246)]=!!a}static isLong(t){let r=n;return t&&e[r(1585)](!0,t[r(1753)])}static[n(1540)](t,r,a){return new K(t,r,a)}static fromBytes(t,r,a){let d=n;return a?K[d(802)+"sLE"](t,r):K["fromByte"+d(414)](t,r)}static[n(802)+"sLE"](t,r){let a=n;return new K(e.olhdH(e[a(1442)](e.XOmEx(t[0],e[a(1405)](t[1],8)),e.xeaYl(t[2],16)),e[a(1481)](t[3],24)),e.nbEGf(e.sOKxu(t[4],e[a(1618)](t[5],8))|t[6]<<16,e[a(1481)](t[7],24)),r)}static fromBytesBE(t,r){let a=n;return new K(e[a(942)](e[a(663)](e[a(1612)](e[a(1720)](t[4],24),e[a(1467)](t[5],16)),t[6]<<8),t[7]),e[a(1239)](e[a(1508)](e[a(1508)](t[0]<<24,e.NNxSn(t[1],16)),e[a(1676)](t[2],8)),t[3]),r)}static[n(962)](t){let r=n;return t===h0?Fi:new K(e.MGogh(e[r(1124)](e[r(1508)](e[r(1712)](Ye[r(873)](t,0),e[r(756)](Ye[r(873)](t,1),8)),e[r(1283)](Ye[r(873)](t,2),16)),e[r(1121)](Ye[r(873)](t,3),24)),0),e[r(1080)](e.pxwWL(e[r(856)](Ye.call(t,4)|e.SsZME(Ye[r(873)](t,5),8),e[r(447)](Ye[r(873)](t,6),16)),e[r(1121)](Ye.call(t,7),24)),0),!0)}toHash(){let t=n;return String[t(1831)+"Code"](255&this[t(862)],e[t(787)](e.gMRKS(this[t(862)],8),255),e.TlQfL(e[t(1350)](this[t(862)],16),255),e[t(1175)](this[t(862)],24),255&this[t(1447)],e[t(1390)](e[t(1869)](this[t(1447)],8),255),e.chyzJ(e.hGHKd(this[t(1447)],16),255),e[t(1262)](this[t(1447)],24))}static[n(484)+"er"](t,r=!0){let a=n,d={RtkMJ:e[a(1376)]};if(e[a(854)](isNaN,t))return r?g0:Fi;if(r){if(e[a(869)]!==e[a(869)]){let h=_0x22edc9(d[a(1485)],{message:_0x1352fd[a(1268)],code:_0x3a772e[a(1814)+a(1251)],error:_0x35a2e2});this[a(1298)+a(860)+a(620)](h)}else if(t>=Mi)return m0}else{if(t<=-zi)return w0;if(e[a(421)](e[a(1606)](t,1),zi))return p0}return K.fromBits(e[a(485)](e.seBiO(t,ht),0),e[a(1612)](e.iIYWK(t,ht),0),r)}[n(1131)](){let t=n;return this[t(1246)]?e.VMABR(e[t(1889)](this[t(1447)],0),ht)+(this[t(862)]>>>0):e[t(644)](e[t(795)](this[t(1447)],ht),e[t(1889)](this[t(862)],0))}isZero(){let t=n;return this[t(1447)]===0&&e[t(900)](0,this[t(862)])}add(t){let r=n;K[r(1753)](t)||(t=K.fromNumber(t));let a=this[r(1447)]>>>16,d=e.yqreZ(65535,this[r(1447)]),h=e.BdPLF(this[r(862)],16),p=e.aLfUq(65535,this[r(862)]),g=t[r(1447)]>>>16,f=e.vhVkr(65535,t[r(1447)]),_=e.BdPLF(t[r(862)],16),b=65535&t[r(862)],I=0,L=0,B=0,O=0;return O+=e[r(723)](p,b),B+=e[r(1544)](O,16),O&=65535,B+=e[r(1342)](h,_),L+=e.jMwNy(B,16),B&=65535,L+=e[r(1063)](d,f),I+=e[r(818)](L,16),L&=65535,I+=a+g,I&=65535,K[r(1540)](e[r(870)](e[r(655)](B,16),O),e[r(702)](I,16)|L,this.unsigned)}equals(t){let r=n;return K[r(1753)](t)||(t=K[r(484)+"er"](t)),e[r(1436)](this[r(1246)],t[r(1246)])&&e[r(851)](e.jMwNy(this[r(1447)],31),1)&&e[r(851)](e[r(1579)](t[r(1447)],31),1)?!1:e.NKWPk(this[r(1447)],t[r(1447)])&&e[r(1681)](this[r(862)],t[r(862)])}addOne(){let t=n,r={hvLzS:function(a,d){return e[D(1757)](a,d)},zfyAf:function(a,d){return a>>>d},WKGCB:function(a,d){return a+d},QcqoT:function(a,d){return e[D(1117)](a,d)}};return e[t(587)]!==e[t(622)]?e[t(1168)](-1,this[t(862)])&&e[t(775)](-1,this[t(1447)])?K[t(1540)](0,0,this[t(1246)]):e[t(1329)](-1,this[t(862)])?K[t(1540)](0,e[t(1362)](this[t(1447)],1),this[t(1246)]):K[t(1540)](this[t(862)]+1,this.high,this[t(1246)]):this.unsigned?kHLHTi[t(1555)](kHLHTi[t(1837)](this[t(1447)],0),_0x2488bc)+(this[t(862)]>>>0):kHLHTi.WKGCB(kHLHTi[t(1555)](this[t(1447)],_0x323d25),kHLHTi[t(483)](this.low,0))}[n(1876)](t){let r=n,a={ksydM:e[r(751)],ImXNj:e[r(598)]};if(e[r(1168)](e.vCrlM,e[r(1809)]))return t?this[r(735)+"E"]():this[r(1038)+"E"]();this[r(576)+r(1697)]?.addCount(),this[r(1630)](a.ksydM,a[r(904)]),this[r(576)+r(1697)]?.[r(1231)+r(769)+"nt"]()?this[r(1185)+r(867)]():this._ping()}[n(735)+"E"](){let t=n;if(e.sPcLs===e[t(668)])return new _0x12204d(_0x44c1c8);{let r=this[t(1447)],a=this[t(862)];return[e[t(1709)](255,a),e.VCPAG(e[t(1579)](a,8),255),e.yqreZ(e[t(1350)](a,16),255),e[t(1648)](a,24),255&r,e.IlQFC(r>>>8,255),e[t(1390)](e[t(513)](r,16),255),r>>>24]}}toBytesBE(){let t=n,r=this.high,a=this.low;return[r>>>24,e.IlQFC(e.ZZXkQ(r,16),255),e[t(991)](e[t(1601)](r,8),255),e[t(1129)](255,r),e[t(1813)](a,24),e[t(1706)](a>>>16,255),e[t(1463)](e[t(1374)](a,8),255),e[t(1413)](255,a)]}}let Fi=new K(0,0,!1),g0=new K(0,0,!0),p0=K[n(1540)](-1,2147483647,!1),m0=K[n(1540)](-1,-1,!0),w0=K[n(1540)](0,-2147483648,!1);var Xe=(function(i){let t=n,r=e.vnXLo.split("|"),a=0;for(;;){switch(r[a++]){case"0":i[i[e.CgsMB]=5002]=e.CgsMB;continue;case"1":i[i[e[t(1383)]]=5004]=e[t(1383)];continue;case"2":i[i[e[t(1685)]]=5005]=e.EGliF;continue;case"3":return i;case"4":i[i[e[t(1221)]]=5003]=e.LarXX;continue;case"5":i[i[e[t(1311)]]=5001]=e.fGCaE;continue}break}})({});class gt{constructor(t){let r=n;this[r(1415)]=t,this.target=null}}class Ui extends gt{constructor(t,r){let a=n;if(e[a(1594)](a(1030),e[a(1161)]))super(t),this[a(1268)]=r&&r[a(1268)]||null;else return 0}}class qi extends gt{constructor(t,r){let a=n;if(e.cgpSA(e[a(963)],e[a(963)]))return _0x3bac09[a(1838)+"oreNames"]||_0x59b745.get(_0x12629b);{let d=e[a(1267)][a(1884)]("|"),h=0;for(;;){switch(d[h++]){case"0":this[a(1234)]=r&&r.code||5001;continue;case"1":this[a(1083)]=r&&r[a(1083)]||0;continue;case"2":this[a(1268)]=r&&r[a(1268)]||"";continue;case"3":super(t);continue;case"4":this.colno=r&&r[a(1655)]||0;continue;case"5":this.filename=r&&r.filename||"";continue;case"6":this.error=r&&r[a(1017)]||null;continue}break}}}}class Hi extends gt{constructor(t,r){let a=n,d={GRlnY:function(h,p){return e[D(822)](h,p)},aqLSD:function(h,p){return e[D(1481)](h,p)},emiQV:function(h,p){return e[D(1187)](h,p)},OVUkL:function(h,p){return e.uhEqK(h,p)},XfOeK:function(h,p){return e[D(1007)](h,p)}};if(e[a(1429)](e[a(512)],e[a(1e3)])){let h=e.rwoWT[a(1884)]("|"),p=0;for(;;){switch(h[p++]){case"0":this[a(1224)+a(1881)]=r&&r[a(1224)+a(1881)]||!1;continue;case"1":this[a(1024)]=r&&r.wasClean||!1;continue;case"2":super(t);continue;case"3":this.code=r&&r[a(1234)]||0;continue;case"4":this[a(1151)]=r&&r.reason||"";continue}break}}else _0x637165=rBCqTN[a(1003)](rBCqTN.aqLSD(rBCqTN[a(537)](31,_0x38daad),6),63&_0x1ae035),rBCqTN[a(1873)](_0x312932,128)?_0x13d798+=_0xb89364:(_0x3b51da+=rBCqTN[a(730)](_0x3852fd,_0x347fd0),_0x247744++)}}class Ki extends gt{constructor(t,r){let a=n;super(t),this.data=r&&r[a(1398)]||null}}class ji extends Ki{constructor(t,r){let a=n;super(t),this.data=r&&r.data||null,this[a(1268)]=r&&r.message||null}}class Gi extends gt{constructor(t,r){let a=n,d={bdvNQ:e.WYLya,IkiQz:function(h,p,g){return h(p,g)}};e[a(1519)]("legZO",e[a(550)])?this[a(1630)](d[a(1786)],d[a(1357)](_0x5b0441,a(1268),{..._0x40e606})):(super(t),this.data=r&&r.data||null)}}function ye(i,{message:t,code:r,error:a}){return new qi(i,{message:t,code:r,error:a})}function Ae(i,{code:t,reason:r,wasClean:a,willReconnect:d}){return new Hi(i,{code:t,reason:r,wasClean:a,willReconnect:d})}function Wi(i,{data:t,message:r}){return new ji(i,{data:t,message:r})}function Ji(i,{data:t}){return new Gi(i,{data:t})}function Cr(i,{message:t}){return new Ui(i,{message:t})}class Vi{constructor(t,r){let a=n;this[a(1472)+"s"]=t,this[a(1468)+"es"]=r,this["currentI"+a(1534)]=0,this[a(1722)+"ndpointT"+a(1348)+"t"]=0}["resetEnd"+n(611)+"fig"](){let t=n,r={jXbzD:function(a,d,h){return a(d,h)}};if(e[t(1237)]("oySwr",e.BkbXN)){let a=this[t(437)+t(1537)]?.["getCurre"+t(1332)+"nt"]();this["_dispatc"+t(1852)+t(620)](r[t(1016)](_0x1f707b,"close",{code:_0x5a20b0.code,reason:t(1713)+"ng faile"+t(970)+t(805)+t(1745)+t(1486)+a})),this[t(437)+t(1537)]?.[t(1108)+t(611)+t(1868)](),this[t(576)+t(1697)]?.[t(1714)+t(1791)]();return}else this[t(1412)+t(1534)]=0,this["currentE"+t(511)+t(1348)+"t"]=0}resetTries(){let t=n;this[t(1722)+t(511)+t(1348)+"t"]=0}[n(1780)+n(1332)+"nt"](){let t=n;return this[t(1472)+"s"][this["currentI"+t(1534)]]}["getCurre"+n(1332)+"ntTriesC"+n(1614)](){return this[n(1722)+"ndpointTriesCount"]}["checkRea"+n(1071)+"es"](){let t=n;return!!(this["currentI"+t(1534)]>=this.endpoints.length||this[t(1412)+t(1534)]===e.hkgXN(this[t(1472)+"s"][t(1294)],1)&&e[t(1219)](this["currentE"+t(511)+t(1348)+"t"],this[t(1468)+"es"]))}[n(498)+"rentEndp"+n(1716)+"hedMaxRetries"](){let t=n;return this["currentI"+t(1534)]==this[t(1472)+"s"][t(1294)]?!0:e.QzlNy(this["currentE"+t(511)+t(1348)+"t"],this[t(1468)+"es"])}[n(1361)+n(418)+n(553)+n(839)+n(1033)](){let t=n;return this[t(1722)+t(511)+t(1348)+"t"]=1,this[t(1412)+t(1534)]++,this.endpoints[this["currentI"+t(1534)]]}[n(1780)+"ntEndpoi"+n(915)+n(1474)](){let t=n;return this[t(1722)+t(511)+t(1348)+"t"]++,this[t(1780)+t(1332)+"nt"]()}}let pt=(e.RWvDP!=typeof globalThis&&e[n(1327)](n(440),globalThis[n(966)+n(1171)][n(1218)])||e.mQofC(e[n(985)],typeof window)&&e[n(1511)](e[n(1624)],window[n(966)+"tor"][n(1218)]))&&e.beWcG(e[n(985)],typeof document),at=e.PoWoa(e[n(985)],typeof globalThis)&&(e[n(884)]("Object",globalThis[n(966)+n(1171)][n(1218)])||e[n(1214)](e[n(628)],globalThis[n(966)+n(1171)][n(1218)]))&&n(1163)+"d"!=typeof tt,Ft=(e[n(985)]!=typeof globalThis&&e.qRDja===globalThis[n(966)+n(1171)][n(1218)]||e[n(696)](e[n(985)],typeof globalThis)||e.RWvDP!=typeof globalThis&&!!globalThis[n(1409)+n(1225)])&&e[n(432)](n(1163)+"d",typeof wx),Ut=e.FEpFT(n(1163)+"d",typeof globalThis)&&(e[n(820)](e[n(628)],globalThis[n(966)+n(1171)].name)||e[n(596)](e[n(1416)],globalThis[n(966)+n(1171)].name)||e[n(606)](n(1286)+n(493)+n(906),globalThis[n(966)+n(1171)][n(1218)]))&&e.QogQH(e[n(985)],typeof self),_0=e[n(1871)](n(1163)+"d",typeof globalThis)&&e[n(1168)](e[n(713)],globalThis["construc"+n(1171)][n(1218)])&&e.RWvDP!=typeof global&&e[n(596)](e[n(713)],global["construc"+n(1171)][n(1218)])&&e[n(602)](e[n(985)],typeof process)&&!!process[n(1233)];class Ir{constructor(){let t=n;this[t(547)+"rs"]={}}[n(1630)](t,...r){let a=n,d=this[a(547)+"rs"][t];if(d)d[a(1067)]()[a(1285)](h=>h.fn[a(1623)](h[a(402)],r));else if(e[a(1376)]===t&&!this[a(717)])if(e[a(1209)](e[a(1862)],a(514))){let h=r[a(1294)]&&r[0];if(e[a(1389)](h,Error))throw h;let p=new Error(e.IqPUP(e.CMQWM,h?e[a(1734)](" ("+h[a(1268)],")"):""));throw p[a(499)]=h,h}else{let h=e[a(1152)](_0x257c75,_0x34f54b,_0x3cb3a4[a(1899)]),p=_0x4720fb[a(1156)],g=_0x4e443b[a(1156)];for(let f=0,_=_0x4f5a75[a(1899)];e[a(888)](f,_);f++)p[e[a(1099)](f,h)]=g[f]}return this}[n(875)](t,r){let a=n;if(e[a(1828)](void 0,t))this[a(547)+"rs"]={};else if(e[a(976)](void 0,r))this[a(547)+"rs"][t]=null;else{let d=this[a(547)+"rs"][t];if(d)for(let h=0;e[a(617)](h,d[a(1294)]);)e[a(782)](d[h].fn,r)?d[a(405)](h,1):++h}return this}on(t,r,a){let d=n;return(this[d(547)+"rs"][t]||(this[d(547)+"rs"][t]=[]))[d(1281)]({fn:r,ctx:a||this}),this}}class y0 extends Ir{[n(1750)+n(1532)+n(1278)](t){let r=n,a={EdPJn:function(d,h,p){return e[D(1296)](d,h,p)}};if(e[r(610)]!==e[r(1018)])return t.errMsg||t[r(1312)]?(r(981)+" "+(t.errMsg||"")+r(1510)+(t[r(1312)]||""))[r(924)]():JSON[r(1723)+"y"](t);XCFoyS[r(1817)](_0xd21966,_0x8588e6,90),XCFoyS[r(1817)](_0x5f0b4b,_0x394265,_0x13e68b)}constructor(t,r,a){let d=n,h={oawJY:function(p,g,f,_,b){return p(g,f,_,b)}};if(e[d(1754)](e.yzqni,d(1524)))super(),this[d(1454)]=null,Ft&&wx[d(1836)+d(488)]&&(this._socket=wx[d(1836)+"ocket"]({url:t,protocols:r,header:a,fail:this[d(718)+d(541)+"lHandler"][d(1827)](this),success:this[d(718)+d(907)+"cessHand"+d(1728)][d(1827)](this)})),at&&tt[d(1836)+d(488)]&&(this[d(1454)]=tt[d(1836)+d(488)]({url:t,protocols:r,header:a,fail:this["_createS"+d(541)+d(1516)].bind(this),success:this[d(718)+d(907)+d(557)+d(1728)][d(1827)](this)}));else{let p={Fmqyz:function(g,f,_,b,I){let L=d;return rzpaIU[L(1290)](g,f,_,b,I)},PDymG:function(g,f){return g(f)}};_0x20e8db[d(1114)+"Listener"](d(1784)+d(1180),g=>{let f=d;p[f(1181)](_0x45d04e,p[f(761)](_0x2404c4,_0x5bd9ec[f(801)]),g.oldVersion,g.newVersion,p[f(761)](_0x3c522c,_0x48ca10[f(1785)+f(1663)]))})}}[n(718)+n(907)+"cessHand"+n(1728)](){let t=n,r={ylpsI:function(a,d,h){return e.kJNki(a,d,h)},csRnT:t(750),WndKC:e[t(517)],gPaeE:e.CIqCs};Promise[t(908)]()[t(1455)](()=>{let a=t;if(e[a(1773)](e[a(1548)],e[a(1471)])){if(this[a(1287)+a(445)](),this[a(1627)+"mer"](),this[a(1305)+a(918)+"rs"](),this[a(697)+"nceClose"](1e3,_0x4f527f),this[a(1245)+"Lock"]=!1,_0x152d04&&this[a(1569)+a(1562)]()&&!this[a(1178)+a(1897)]){if(this[a(437)+a(1537)]?.[a(1231)+"chMaxTries"]()){let h=this["_endpoin"+a(1537)]?.[a(1780)+a(1332)+"nt"]();this[a(1298)+a(1852)+a(620)](r.ylpsI(_0x281107,a(750),{code:1006,reason:a(1680)+h+(" timeout"+a(580)+a(700)+a(803)),wasClean:!0}))}else{let h=this[a(1832)][a(1505)+a(951)+a(1223)](_0x185179,_0x21e183);this["_dispatchCloseEv"+a(620)](_0x321a3d(a(750),{code:_0x41a81b,reason:_0x3da119,wasClean:!0,willReconnect:h})),h&&this._connect()}return}this[a(1569)+a(1562)]()||this[a(1178)+a(1897)]?this["_dispatc"+a(1852)+a(620)](r[a(1079)](_0x4520c5,r[a(1258)],{code:_0x293962,reason:r[a(604)]})):this[a(1298)+a(1852)+a(620)](_0x5b6789(a(750),{code:1006,reason:r[a(1388)]})),this[a(1075)]=null,this[a(437)+"tManager"]?.[a(1108)+"pointConfig"](),this[a(576)+"sCounter"]?.[a(1714)+a(1791)]()}else this[a(1375)+a(1631)]()})}[n(718)+n(541)+n(1516)](t){let r=n;e[r(1828)](e[r(603)],e[r(1140)])?(_0x27e281=_0x4f24fd[e[r(797)](_0x335187,_0x2802a)+1],e[r(1436)](192&_0x5f4a14,128)?_0x940dba+=_0x1d1511:(_0x2a2ceb=e[r(1103)](e[r(409)](e[r(534)](31,_0x190179),6),e.RhEMX(63,_0x44e86b)),e.BlOBO(_0x199c35,128)?_0x2eb1fa+=_0x2875ae:(_0x2a4fbf+=e[r(1088)](_0x5331d8,_0x53ae01),_0x2f0640++))):Promise[r(908)]()[r(1455)](()=>{let a=r;if(e[a(1237)](e[a(1355)],e.vyHDk)){let d=this[a(437)+a(1537)]?.["getCurre"+a(1332)+"nt"]();this[a(724)](a(1680)+d+a(948)),this["_disconn"+a(443)](1001,a(562)+" try reconnecting",!0)}else{let d=e[a(943)](ye,e[a(1376)],{message:this[a(1750)+a(1532)+"age"](t)});this[a(1630)](e.EavzQ,d);let h=e.MsoQw(Ae,e.FUEwc,{reason:this[a(1750)+"rrorMess"+a(1278)](t)});this[a(1630)](e[a(1587)],h)}})}["_addWsLi"+n(1631)](){let t=n,r={VrtPd:function(a,d){return e.ydzla(a,d)},ndeFC:function(a,d){return e.NNxSn(a,d)},FMOik:function(a,d){return e[D(736)](a,d)},KVunE:function(a,d){return e[D(1007)](a,d)},feMlC:function(a,d){return e.ZxFge(a,d)},eukoK:e[t(1587)],KUJfv:function(a,d,h){return e[t(1759)](a,d,h)}};this[t(1454)][t(1253)](a=>{let d=t;e.zwVkz(e[d(1857)],e[d(1781)])?(_0x4d4a91=xoekKG[d(1469)](_0x3dff64,_0x2e86f8),_0x2dfe40|=xoekKG.ndeFC(xoekKG[d(796)](127,_0x4b70bc),21),xoekKG[d(796)](128,_0x1fb7b7)&&(_0x2804e2=xoekKG[d(752)](_0xfeb1e3,_0x59d562),_0x4a274f=xoekKG.FMOik(127,_0x323278),128&_0x4f446f&&(_0x534e3b=_0x22f771(_0x5ee9de),_0x4da643|=xoekKG[d(1105)](127,_0x4ca75c)<<7))):this[d(1630)](e.UKQTC,Ji(e[d(882)],{...a,data:a.errMsg||""}))}),this[t(1454)].onClose(a=>{let d=t;this.emit(r[d(829)],r[d(928)](Ae,r[d(829)],{...a}))}),this[t(1454)][t(1553)+"e"](a=>{let d=t,h={kptFK:function(p,g){return e[D(1202)](p,g)}};e[d(895)](e.zgMgP,e.zgMgP)?this[d(1630)](e.WYLya,e.nQzTe(Wi,e[d(1422)],{...a})):(_0x242044=h[d(1314)](_0x43c237,_0x32ae2f),_0x15b8f8=0)}),this[t(1454)][t(507)](a=>{let d=t;this[d(1630)](e.EavzQ,e.ESHOq(ye,e[d(1376)],{...a,message:a[d(1568)]||""}))})}[n(784)](t){let r=n,a={JmyTi:function(d,h,p){return e[D(539)](d,h,p)},pwCmt:function(d,h){return d(h)}};if(t instanceof Uint8Array)if(e[r(986)](e.jOprG,r(1182))){let d=t[r(1176)][r(1067)](t[r(861)+"et"],t[r(1041)+"th"]+t[r(861)+"et"]);this._socket&&this[r(1454)].send({data:d,fail:h=>{let p=r;this[p(1630)]("error",a.JmyTi(ye,p(1017),{message:this[p(1750)+p(1532)+p(1278)](h)}))}})}else{let d={jNiGU:function(h,p){let g=r;return RpKnat[g(533)](h,p)}};return function(h,...p){let g=r,f=_0x584b0f[g(873)](d.jNiGU(_0x19457b,this),h,...p);return _0x58af0e[g(1541)](f,h[g(1725)]?h[g(1725)]():[h]),d[g(1216)](_0x3c6e4e,f)}}else this[r(1454)]&&this[r(1454)][r(784)]({data:t,fail:d=>{let h=r;this[h(1630)](e[h(1376)],e.Vfhtl(ye,h(1017),{message:this[h(1750)+h(1532)+"age"](d)}))}})}[n(750)](t,r){let a=n;this[a(1454)]&&this._socket[a(750)]({code:t,reason:r})}[n(1114)+n(429)](t,r){this.on(t,r)}[n(633)+n(978)+"ner"](t,r){this[n(875)](t,r)}get[n(725)+"te"](){let t=n;if(e[t(699)](e[t(715)],e[t(1600)]))return this[t(1454)][t(725)+"te"];this._ws&&this[t(1075)][t(784)](_0x1af438),this[t(724)](e[t(1854)],_0x2c62be)}get[n(1159)+"pe"](){let t=n;return e[t(976)](e[t(592)],"pOrJr")?this._ws?this._ws.readyState:this[t(1832)][t(1470)+t(1090)]?this[t(780)+"NG"]:this[t(424)]:this[t(1454)][t(1159)+"pe"]}set[n(1159)+"pe"](t){}get[n(1048)](){let t=n;return this[t(1454)][t(1048)]}get[n(1661)](){let t=n;return this[t(1454)][t(1661)]}get[n(825)+"ns"](){return this[n(1454)].extensions}get[n(1448)+n(1886)](){return 0}}function v0(i,t){let r=n;if(t)return new t(i[r(1048)],i[r(1661)]);if(e[r(1525)](Ft,at))return new y0(i[r(1048)],i.protocol,i[r(406)]);if(e[r(1525)](pt,Ut)&&e.KdCLu(e[r(985)],typeof WebSocket)&&WebSocket)return new WebSocket(i[r(1048)],i[r(1661)+"s"])}function b0(i){let t=n,r=e.qLxbQ[t(1884)]("|"),a=0;for(;;){switch(r[a++]){case"0":if(Ft&&wx[t(1836)+t(488)])return!0;continue;case"1":if(at&&tt[t(1836)+t(488)])return!0;continue;case"2":if(i)return!0;continue;case"3":return!1;case"4":if((pt||Ut)&&e[t(985)]!=typeof WebSocket&&WebSocket)return!0;continue}break}}function $i(i,t,r){let a=n,d={qeHjf:function(g,f){return e[D(1450)](g,f)},faxvE:e[a(1052)],tLyAU:function(g,f){return g===f},HzoRv:function(g,f){return e.mLZlc(g,f)}},h=-1;async function p(g){let f=a;return d[f(1671)](g,h)?Promise.reject(new Error(d.faxvE)):(h=g,d[f(608)](g,r[f(1294)])?Promise[f(908)]():r[g][f(1827)](i)(t,p[f(1827)](null,d[f(459)](g,1))))}e[a(741)](p,0)}function Yi(i){let t=n,r=0,a=0;for(let d=0;d<i[t(1294)];++d)a=i.charCodeAt(d),e[t(617)](a,128)?r+=1:e[t(876)](a,2048)?r+=2:e[t(1378)](e[t(1351)](64512,a),55296)&&(64512&i[t(1605)+"At"](d+1))===56320?(++d,r+=4):r+=3;return r}function Xi(i,t,r){let a=n;if(e[a(1300)](e[a(559)](r,t),1))return"";let d="";for(let h=t;h<r;){let p=i[h++];if(p<=127)d+=String[a(1831)+a(690)](p);else if(e.CEjOw(p,192)&&e[a(1242)](p,224))d+=String[a(1831)+"Code"](e[a(1103)](e[a(607)](e.VCPAG(31,p),6),e[a(629)](63,i[h++])));else if(e[a(996)](p,224)&&e.WiHTY(p,240))d+=String[a(1831)+a(690)](e.bZiQj(e[a(1103)](e[a(778)](15&p,12),e[a(607)](e[a(785)](63,i[h++]),6)),63&i[h++]));else if(e[a(421)](p,240)){let g=e[a(490)](e[a(1578)](e[a(1096)](e[a(1129)](7,p),18),e[a(1093)](e[a(1057)](63,i[h++]),12))|e[a(1825)](63,i[h++])<<6|e[a(1275)](63,i[h++]),65536);d+=String[a(1831)+a(690)](e.xMllb(55296,e.zmPyE(g,10))),d+=String[a(1831)+a(690)](e[a(674)](56320,e.PGsUx(1023,g)))}}return d}function Ar(i,t,r){let a=n,d=r,h,p;for(let g=0;e[a(853)](g,i.length);++g)if(h=i[a(1605)+"At"](g),e.OtfeA(h,128))t[r++]=h;else if(e[a(1154)](h,2048))t[r++]=e[a(1097)](e.kJyQk(h,6),192),t[r++]=e[a(1442)](e[a(682)](63,h),128);else if(e.GNJfx(e[a(832)](64512,h),55296)&&e[a(1742)](e[a(1778)](64512,p=i.charCodeAt(e[a(1342)](g,1))),56320)){let f=("3|4|2|0|"+a(1434))[a(1884)]("|"),_=0;for(;;){switch(f[_++]){case"0":t[r++]=e[a(942)](e.ZkXTr(h>>12,63),128);continue;case"1":t[r++]=e.bnEvY(e[a(1020)](h>>6,63),128);continue;case"2":t[r++]=e.xRXNx(e[a(497)](h,18),240);continue;case"3":h=e.xMllb(e[a(1696)](65536,e[a(409)](e[a(1187)](1023,h),10)),e[a(1463)](1023,p));continue;case"4":++g;continue;case"5":t[r++]=e[a(1821)](63&h,128);continue}break}}else t[r++]=e[a(720)](e[a(899)](h,12),224),t[r++]=e[a(1893)](e[a(1432)](e[a(836)](h,6),63),128),t[r++]=e[a(1037)](63&h,128);return e[a(490)](r,d)}async function Qi(i){let t=n;if(e[t(696)](e.cyfue,typeof i)){let r=new Uint8Array(e[t(854)](Yi,i));return Ar(i,r,0),r}return e[t(1389)](i,ArrayBuffer)?new Uint8Array(i):new Uint8Array(i.buffer,i[t(861)+"et"],i[t(1041)+"th"])}function S0(i){let t=n,r={oNEGr:function(a,d){return e[D(1164)](a,d)},lOYNV:function(a,d){return e[D(850)](a,d)}};if(e[t(1089)](e[t(1760)],e[t(1315)]))this[t(1339)]=!0,this[t(1245)]();else try{if(e.bGRCY===t(1440)){let a=this[t(704)][t(911)+"geInfoSync"](this._prefix),d=_0x5993bf[t(956)](r.oNEGr(a,"{}"));return _0x528a60[t(983)](d)}else return e[t(602)](e.cyfue,typeof i)&&(e[t(1441)](i,ArrayBuffer)||i[t(1176)]&&e.JPpEw(i[t(1176)],ArrayBuffer))||typeof i!="string"?"":(JSON[t(956)](i),e[t(632)])}catch{return e[t(619)](e.Cejpq,e[t(677)])?e.Srtlo(e.cyfue,typeof i)?e[t(508)]:"":1e4*_0xa8651b[t(1106)]()+_0x2f017b[t(710)](JAWjZn[t(1303)](1e4,_0x2a6780[t(807)]()))}}let E0=(i,t)=>{let r=n;switch(i){case e[r(1794)]:case r(721):return{[r(1220)+i]:1,"x-tt-env":t};default:return{}}};class C0{constructor(t){let r=n;this[r(1032)+r(1614)]=t,this[r(880)]=0}[n(1727)](){let t=n;this[t(880)]++}[n(1231)+"chMaxCount"](){let t=n;if(e[t(821)](e[t(1515)],e[t(1515)]))return this.count>=this[t(1032)+t(1614)];{let r=t(1680)+_0x55d447+(t(948)+", max re"+t(700)+t(803));this[t(724)](r),this[t(1298)+"hErrorEv"+t(620)](e[t(489)](_0x2b6b16,t(1017),{message:r,code:_0x5890dc[t(1698)+t(1282)+"R"]}));return}}[n(1714)+"nter"](t=0){let r=n;this[r(1032)+r(1614)]=t,this[r(880)]=0}}async function I0(i){let t=n,r={vJyiD:function(a,d){return e[D(471)](a,d)},WitDz:e.gUyhy,QsJMh:function(a,d){return a(d)},gmDNJ:e[t(1423)]};return new Promise(a=>{let d=t;if(!pt)return e[d(426)](a,e[d(1423)]);try{let h=document[d(897)+d(568)](e[d(961)]);window[d(565)+d(894)]=p=>{let g=d;if(r.vJyiD(r[g(585)],r[g(585)]))document[g(1640)]["removeCh"+g(1801)](h),window[g(565)+g(894)]=void 0,r[g(891)](a,p&&p.msg||r[g(1766)]);else return _0x33a1fb?this[g(735)+"E"]():this[g(1038)+"E"]()},h.type=e[d(1811)],h[d(1657)]=e[d(847)](i[d(1616)](/^ws/,e[d(1449)]),e.PtAzB);try{document[d(1640)]["appendCh"+d(1801)](h)}catch{document[d(1640)]["removeCh"+d(1801)](h)}}catch{window[d(565)+d(894)]=void 0,a(e[d(1423)])}})}function Qe(i,t,r){let a=n;return!!i?.find(d=>d.key===t&&d[a(1195)]===r)}function mt(i,t){let r=n;return i?.[r(1349)](a=>a[r(1526)]===t)?.value}let Pr=null;async function A0(){let i=n;return Pr||(Pr=Promise[i(908)]()[i(1455)](Be[i(1827)](Be,e.FdLAz))),Pr}class P0 extends Ir{constructor(t,r){let a=n;super(),this[a(1729)]=t,this[a(1433)]=r,this[a(704)]=void 0,this[a(1229)+a(1199)]=null}async[n(411)](){await this[n(419)]()}async[n(419)](){let t=n;if(!this[t(704)]){if(this[t(1229)+t(1199)])return this[t(1229)+t(1199)];try{let r=this[t(1729)],a=this[t(1433)];this["_initPro"+t(1199)]=(async()=>{let d=t,{openDB:h}=await e.JKInE(A0);this[d(704)]=await e[d(1078)](h,d(565)+"_"+r,1,{upgrade(p){let g=d;p[g(843)+g(1051)+"e"](r,{keyPath:a})}})})(),await this[t(1229)+"mise"]}catch(r){console.log(r)}finally{this._initPromise=null}}}async get(t){let r=n;if(e[r(866)](e.cMcut,e[r(1744)]))for(var a in _0xeb871c)_0x391dd8.o(_0x1b5a06,a)&&!_0x2173d1.o(_0x3026e0,a)&&_0x3102ec["definePr"+r(1755)](_0x51f291,a,{enumerable:!0,get:_0x1a167e[a]});else try{return await this._init(),this[r(704)]?.get(this[r(1729)],t)}catch(d){console[r(590)](d)}}async set(t,r){let a=n;return await this[a(419)](),this[a(704)]?.[a(1478)](this._dbName,t)}async[n(664)](t){let r=n;try{return await this[r(419)](),this[r(704)]?.delete(this[r(1729)],t)}catch(a){console[r(590)](a)}}async clear(){let t=n;try{return await this._init(),this[t(704)]?.[t(1823)](this[t(1729)])}catch(r){console[t(590)](r)}}async[n(877)](){let t=n;if(e.oMdHY(e[t(1484)],e[t(1484)]))return await this._init(),this._qosDB?.[t(1272)+"ys"](this[t(1729)]);this[t(1885)+t(1749)]=_0x30e9ae,this._ws&&(this._ws[t(1159)+"pe"]=_0x302abe)}async[n(525)](){let t=n;return await this[t(419)](),this[t(704)]?.getAll(this[t(1729)])}async[n(1810)](){let t=n;try{this[t(704)]?.[t(750)](),this[t(704)]=void 0}catch(r){console[t(590)](r)}}get[n(863)](){let t=n;try{return!!this[t(704)]}catch(r){if(t(1479)!==e[t(1425)])return console[t(590)](r),!1;_0x3db1f1&&_0x23ed44["addEvent"+t(429)](UGDtHK[t(1587)],()=>_0x17cd6d()),_0x5d55c7&&_0xbb49a4[t(1114)+t(429)](UGDtHK[t(1123)],()=>_0x3d4756())}}}class k0{constructor(t,r){let a=n;this._DBName=t,this._pathKey=r,this[a(704)]=localStorage}async[n(411)](){}get[n(1293)](){let t=n;return t(565)+"_"+this[t(1792)]}async[n(893)](t){let r=n,a=this._qosDB.getItem(this[r(1293)]);return JSON[r(956)](e.QBkZc(a,"{}"))[t]}async set(t,r){let a=n,d=this[a(704)][a(1206)](this[a(1293)]),h=JSON[a(956)](e[a(1164)](d,"{}"));return h[r||t[this[a(1211)]]]=t,this[a(704)][a(540)](this._prefix,JSON[a(1723)+"y"](h)),r||t[this._pathKey]}async[n(664)](t){let r=n,a=this._qosDB[r(1206)](this._prefix),d=JSON.parse(e[r(486)](a,"{}"));return d[t]=void 0,this[r(704)][r(540)](this[r(1293)],JSON[r(1723)+"y"](d))}async clear(){let t=n;return this[t(704)][t(1823)]()}async keys(){let t=n,r=this[t(704)][t(1206)](this[t(1293)]),a=JSON[t(956)](e.jLMgI(r,"{}"));return Object[t(877)](a)}async[n(525)](){let t=n,r=this._qosDB[t(1206)](this._prefix),a=JSON.parse(e[t(1525)](r,"{}"));return Object[t(983)](a)}closeDB(){return Promise[n(908)]()}get[n(863)](){return!!this[n(704)]}}class T0{constructor(t,r){let a=n;this[a(1792)]=t,this._pathKey=r,this[a(704)]=at?tt:Ft?wx:null}async[n(411)](){}get[n(1293)](){let t=n;if(e[t(1828)](e[t(1598)],e[t(1598)]))return t(565)+"_"+this[t(1792)];{let r=this[t(437)+t(1537)]?.["getCurre"+t(1332)+"nt"]();this[t(1298)+t(1852)+t(620)](e[t(1291)](_0x45548d,e[t(1587)],{code:1006,reason:"connect "+r+(t(948)+t(580)+t(700)+"ached"),wasClean:!0}))}}async[n(893)](t){let r=n,a=this._qosDB["getStora"+r(1456)](this[r(1293)]);return JSON[r(956)](e.RNIHI(a,"{}"))[t]}async[n(1541)](t,r){let a=n,d=this[a(704)][a(911)+a(1456)](this[a(1293)]),h=JSON[a(956)](e[a(759)](d,"{}"));return h[r||t[this._pathKey]]=t,this[a(704)]["setStora"+a(1456)](this._prefix,JSON[a(1723)+"y"](h)),r||t[this[a(1211)]]}async del(t){let r=n,a=this[r(704)][r(911)+"geSync"](this[r(1293)]),d=JSON[r(956)](a||"{}");return d[t]=void 0,this[r(704)].setStorageSync(this[r(1293)],JSON[r(1723)+"y"](d))}async[n(1823)](){let t=n;return this[t(704)][t(1155)+"rageSync"]()}async keys(){let t=n,r=this[t(704)][t(911)+t(1746)+"nc"](this[t(1293)]),a=JSON.parse(e[t(671)](r,"{}"));return Object[t(877)](a)}async[n(525)](){let t=n,r=this._qosDB[t(911)+t(1746)+"nc"](this._prefix),a=JSON.parse(e[t(740)](r,"{}"));return Object.values(a)}closeDB(){let t=n,r={UdrIY:function(a,d){return e[D(656)](a,d)},ltSMG:function(a,d){return e[D(1192)](a,d)}};if(e[t(1841)](t(837),e.xSTkz)){let a=0,d=0,h;do h=XBCSnG[t(1858)](_0x55b8e4,_0x4630cf),XBCSnG[t(989)](a,32)&&(d|=(127&h)<<a),a+=7;while(128&h);return d}else return Promise[t(908)]()}get isReady(){return!!this[n(704)]}}function Zi(i,t){let r=n;if(e.ZpIAw(at,at))return new T0(i,t);if(e.lTTWs(pt,Ut)&&e[r(985)]!=typeof indexedDB)return new P0(i,t);if(e[r(532)](pt,Ut)&&e[r(1372)](e[r(985)],typeof localStorage))return new k0(i,t);throw new Error(e[r(1263)])}class D0{constructor(){let t=n;this[t(1301)+t(1509)+"Id"]=null,this._interval=36e5,this[t(704)]=e.ltpgL(Zi,e[t(1056)],t(1392)+"id")}async[n(1301)+"lFlush"](){let t=n;e.ywjTT(clearInterval,this[t(1301)+t(1509)+"Id"]),this[t(1301)+t(1509)+"Id"]=e[t(1877)](setInterval,()=>{let r=t;if(e[r(1774)](r(621),e.RgTng)){let a=_0x494257[r(597)]();return a?(a.offset=a[r(1899)]=0,a):{bytes:new _0x588267(64),offset:0,limit:0}}else this[r(1710)+"ired"]()},this._interval)}async[n(411)](){let t=n;await this[t(704)][t(411)]()[t(1455)](()=>{this["_interva"+t(1559)]()})}async[n(1710)+n(464)](){let t=n;(await this._qosDB?.[t(525)]()||[])[t(636)](({timestamp:d})=>d<Date[t(1106)]()).forEach(d=>{let h=t,p={WWaAg:h(927),FWiVH:function(g,f,_){return e[h(1759)](g,f,_)},BCwsb:e.ovpVy,CfILU:h(1771),MrmiW:e[h(751)]};if(e[h(1436)](e[h(649)],e[h(649)])){let g={brHEu:p[h(1076)],xMhLn:h(1840)+h(1344)+"s",sWcNS:p[h(1257)]};return new _0x2c3185((f,_)=>{let b=h,I={mZvoR:function(O,ve){return O(ve)},XeJZv:p[b(1122)],KPQxs:b(1840)+b(1344)+"s",EYuQt:b(1840)+b(916)+"t"};this[b(1287)+b(445)](),this[b(473)+b(1391)+"Id"]=p[b(645)](_0x5c3b23,this[b(1264)].bind(this),this._options[b(1112)+b(1875)]);let L=()=>{let O=b;f(g[O(1417)]),this[O(875)](g.xMhLn,L),this[O(875)](g[O(1752)],B)},B=()=>{let O=b;I[O(1115)](_,I[O(794)]),this[O(875)](I.KPQxs,L),this[O(875)](I.EYuQt,B)};this.on(p.BCwsb,L),this.on(b(1840)+b(916)+"t",B),this[b(1264)]()})}else this[h(704)]?.[h(664)](d.message_id)})}async[n(664)](t){let r=n,a={GNftw:function(d,h,p){return e.Hsnwe(d,h,p)}};if(e.uyxah!==r(1179))return this._qosDB?.[r(664)](t);DZTDmY[r(809)](_0x5d6fb8,_0x1a40b5,10),DZTDmY[r(809)](_0x47d6c0,_0x24b477,_0xd4bd8a)}async set(t,r){let a=n;if(e[a(1190)](e[a(732)],e[a(732)])){let d=e[a(1759)](_0x2e4cc8,_0x2c9c08,_0x1ca5b5);return _0x1072f1[a(1156)][a(1803)](d,e.lsIHL(d,_0x2ac73a))}else return this[a(704)]?.[a(1541)]({message_id:t,timestamp:r})}async[n(893)](t){let r=n;return this._qosDB?.[r(893)](t)}async[n(1810)](){let t=n;e[t(1748)](clearInterval,this[t(1301)+t(1509)+"Id"]),await this[t(704)]?.[t(1810)]()}get isReady(){let t=n;return this[t(704)]?.[t(863)]}}function kr(i){let t=n,r={NSkNc:function(a,d){return e[D(415)](a,d)},zbSbS:function(a,d){return e.rwUFP(a,d)},PobAU:function(a,d){return e[D(790)](a,d)},KMCZv:function(a,d,h){return e.fRSOe(a,d,h)},igxeY:function(a){return e.JKInE(a)}};if(t(1408)===e.DUybW){let a=!!this._options.enableQoS;if(!a)return{enabled:a,isQoSMessage:!1,isQoSAck:!1,isAckCleanupMessage:!1,ackMsgIds:[]};let d=Qe(i[t(1268)][t(406)],t(1527)+t(841),"2"),h=d&&e[t(1078)](Qe,i[t(1268)][t(406)],t(1527)+t(771)+"ck","1"),p=d&&e[t(647)](Qe,i[t(1268)][t(406)],e.hYsAu,"1"),g=p?e[t(454)](mt,i[t(1268)][t(406)],e[t(434)])?.split(",").filter(Boolean)||[]:[];return{enabled:a,isQoSMessage:d,isQoSAck:h,isAckCleanupMessage:p,ackMsgIds:g}}else return NqFDdX[t(1783)](typeof _0x1ddb63,t(1733))?_0x5ad6f7(_0x233ba8):(NqFDdX.zbSbS(_0x3ab6a7,_0x4fc4f1)&&NqFDdX.PobAU(_0x12f19b,_0x26cb42),NqFDdX[t(1411)](_0x5e1e63,_0x571a03,NqFDdX[t(1317)](_0xe63c1))?new _0x39b732(_0xa343c7,_0x3c2bfd):_0x49d724)}async function es(){let i=n;return this[i(496)+"ger"]||(this[i(496)+i(1139)]=new D0),this[i(496)+i(1139)][i(863)]||await this[i(496)+"ger"][i(411)](),this._QoSManager}async function R0(i,t){let r=n,a={ajqdR:function(d,h,p){return e.kJNki(d,h,p)},LzbVS:function(d,h,p){return e[D(1291)](d,h,p)},IxcAp:function(d,h,p,g){return e.sNiqE(d,h,p,g)},iIPvo:function(d,h){return d+h},PLhjJ:function(d,h,p){return d(h,p)}};if(e[r(884)](r(857),e[r(932)])){let{offset:d}=a.ajqdR(_0x2912e8,_0x4c1426,_0x5dbf2c);_0x8d0003=d;let h={cursor_name:"",cursor:0,service:0},{value:p,offset:g}=a[r(567)](_0xa6e224,_0x5775ed,_0x59c296);h[r(1847)]=p,_0x3ad530=g;let{value:f,offset:_}=a[r(1689)](_0x56fe63,_0x3cafef,_0x38383e);_0x1639e2=_,h[r(1039)+r(1800)]=a[r(783)](_0x4c0100,_0x4635e4,_0x449e25,a[r(844)](_0x2e5cfc,f)),_0x4b22c5+=f;let{value:b,offset:I}=a.PLhjJ(_0x90a4b2,_0x1e0369,_0x53e81a);h[r(1796)]=b[r(1131)](),_0x8a6366=I,_0x1c2105[r(1281)](h)}else{let{enableAutoAck:d}=this[r(1832)],h=e[r(920)](Qe,i[r(1268)].headers,e[r(1890)],"1"),p=e.nKjyP(Qe,i[r(1268)][r(406)],"is_ack","1"),g=kr[r(873)](this,i);if(e[r(1879)](d,h)){let{SeqID:f,LogID:_,service:b,LogIDNew:I,method:L}=i[r(1268)];this._sendAck({SeqID:f,LogID:_,LogIDNew:I,service:b,method:L,headers:[{key:r(919),value:"1"},{key:e.HevUc,value:I||""},{key:e.iwDnf,value:"0"}]})}p&&!g.isQoSAck&&this["_dispatc"+r(1793)+r(403)](i),e[r(1142)](t)}}async function L0(i,t){let r=n;if(e[r(974)]!==e.Yefvx)return new _0x1eb6f1(_0x2b7edd,{message:_0x35ee43});this[r(724)](e[r(1495)],i[r(1268)]),e[r(1690)](t)}async function O0(i,t){let r=n,a=e[r(1007)](Ie,await e[r(438)](Qi,i[r(1398)]));try{if(a[r(1465)]instanceof Uint8Array){let d=e.uZERq(this._options[r(840)+"ncoding"],Object)?{force:!!this[r(1832)][r(840)+r(1134)][r(1861)],encoding:this._options[r(840)+"ncoding"][r(1829)]?this._options[r(840)+r(1134)][r(1829)][r(1616)](/\s/g,"")[r(1607)+r(952)]():""}:{force:!1,encoding:this._options[r(840)+r(1134)]?this[r(1832)][r(840)+"ncoding"].replace(/\s/g,"")[r(1607)+r(952)]():""},h=a[r(840)+r(1134)]?a[r(840)+r(1134)][r(1616)](/\s/g,"")[r(1607)+r(952)]():"",p=this[r(1832)].payloadType instanceof Object?{force:!!this[r(1832)]["payloadT"+r(1749)][r(1861)],type:this[r(1832)][r(830)+r(1749)].type?this[r(1832)][r(830)+r(1749)].type[r(1616)](/\s/g,"")[r(1607)+r(952)]():""}:{force:!1,type:this[r(1832)]["payloadT"+r(1749)]?this._options[r(830)+r(1749)][r(1616)](/\s/g,"")[r(1607)+r(952)]():""},g=a[r(830)+r(1749)]?a["payloadT"+r(1749)].replace(/\s/g,"")[r(1607)+r(952)]():"",f=p[r(1861)]?p.type:g||p[r(1415)],_=d.force?d[r(1829)]:h||d.encoding,b=[e[r(508)],e[r(632)],e.lWfXl,e[r(1402)]],I=[e[r(1014)],e[r(573)]];this[r(1832)]["enableTr"+r(1445)+r(1517)+"ad"]&&b[r(1369)](f)&&(!_||I.includes(_))?a[r(1482)+r(1334)]=Xi(a[r(1465)],0,a[r(1465)][r(1041)+"th"]):a[r(1482)+r(1334)]=""}else a[r(1482)+r(1334)]=""}catch(d){a.textPayload="",console[r(590)](d)}i[r(1268)]=a,e[r(1690)](t)}function N0(i,t,r){let a=e.RNIHI(r,8192),d=e.wdDjV(a,1),h=null,p=a;return function(g){let f=D;if(g<1||e[f(1670)](g,d))return e.MAEnX(i,g);e[f(958)](e[f(1158)](p,g),a)&&(h=e[f(854)](i,a),p=0);let _=t[f(873)](h,p,p+=g);return e.WQWAm(7,p)&&(p=e.TrhbX(e.zDxEz(7,p),1)),_}}let B0=4294967295;function M0(i,t,r){let a=n;return e[a(800)](RangeError,e.dKSyl(e[a(637)](e[a(797)](e[a(1063)](a(1421)+a(849)+a(561),i),e.gjZvf)+e[a(1529)](t,1),e.PGFxm),r))}function z0(i,t,r){let a=n,d={VyTqo:function(h,p){return e.TzTnE(h,p)},KtBVp:e[a(1069)],NLnpW:"offline"};if(e[a(1891)]("chdqP",e[a(1883)])){if(r>B0)throw new Error(e.OSCZF);let h=3;for(;h>=0;){let p=e[a(1644)](255,r);e[a(1428)](Dr,p,i,e[a(933)](t,h)),r>>>=8,h--}return e[a(1270)](t,4)}else this[a(1569)+a(1562)]()&&(!this._ws||d[a(1060)](this._ws[a(725)+"te"],this[a(661)])||d[a(1060)](this._ws.readyState,this[a(780)+"NG"]))&&this[a(430)+a(1460)](),this[a(883)+"er"]&&_0x59937e[a(1114)+a(429)](d.KtBVp,this[a(430)+a(1460)]),this._isBrowser&&_0xb6d1f6[a(1114)+"Listener"](d.NLnpW,this[a(430)+a(1673)])}function F0(i,t){let r=n,a=0,d=t,h=t+4;for(;e[r(853)](d,h);){let{value:p,offset:g}=e[r(1418)](Tr,i,d);d=g,a=a<<8>>>0,a+=p}return{value:a,offset:h}}function U0(i,t,r){let a=n,d=e[a(1724)][a(1884)]("|"),h=0;for(;;){switch(d[h++]){case"0":if(t[a(515)+"e"])return e[a(1490)](t[a(515)+"e"](i,r),r);continue;case"1":return e[a(1248)](Ar(i,t,r),r);case"2":if(i[a(1294)]<40)return e.pzJmJ(e[a(1428)](Ar,i,t,r),r);continue;case"3":if(t[a(1815)])return e[a(1522)](t[a(1815)](i,r),r);continue;case"4":if(!i)return r;continue}break}}function q0(i,t){let r=n,a=new K(e[r(663)](e[r(870)](e[r(856)](e[r(1451)](i[e[r(509)](t,4)],24),i[e.iuUJi(t,5)]<<16),e[r(1462)](i[e[r(1085)](t,6)],8)),i[t+7]),e.iQBsy(e[r(1037)](e[r(1029)](e.hTBVq(i[t+0],24),e[r(742)](i[e[r(404)](t,1)],16)),e[r(1645)](i[e[r(1362)](t,2)],8)),i[e[r(1145)](t,3)]),!0);return t+=8,{value:a,offset:t+8}}function H0(i,t,r){let a=n,d=i[a(862)],h=i[a(1447)];return t[r]=e[a(1561)](h,24),t[e.QoNYj(r,1)]=e.gDwWR(e[a(652)](h,16),255),t[r+2]=e[a(595)](e[a(1431)](h,8),255),t[r+3]=e.ESqxV(255,h),t[e[a(1678)](r,4)]=e[a(1565)](d,24),t[e.iuUJi(r,5)]=e[a(1688)](d>>>16,255),t[e[a(1270)](r,6)]=e[a(1691)](e[a(818)](d,8),255),t[e[a(523)](r,7)]=e[a(1002)](255,d),r+=8,r}function Tr(i,t){let r=n;return i.readUInt8?{value:i[r(709)+"8"](t),offset:e.IqPUP(t,1)}:{value:e[r(583)](255,i[t]),offset:t+1}}function Dr(i,t,r){let a=n;return t[a(1049)+"t8"]?t[a(1049)+"t8"](i,r):t[r]=e[a(1551)](255,i),r+1}let K0=function(i){return new Uint8Array(i)},j0=e[n(985)]!=typeof Buffer?Buffer[n(1704)+n(968)]:N0(K0,Uint8Array.prototype[n(1803)]),G0=16,Rr=32;function W0(i){let t=n,r=0,a={};for(let d=0;e.isKyP(d,i[t(1294)]);d++)a[i[d][t(1039)+t(1800)]]=e[t(828)](Yi,i[d]["cursor_n"+t(1800)]),r+=e.HvqlN(14,a[i[d][t(1039)+t(1800)]]);return[r,a]}function ts(i,t,r){let a=n,d={UmPEE:e.FnJXm,KUFJi:e[a(691)],wOyAW:function(_,b,I,L){return _(b,I,L)},TJpPw:e.rtwyS,acMSQ:e[a(627)],rRIgg:function(_,b,I,L){return e.WZknv(_,b,I,L)},ZCXTD:a(1098)},[h,p]=e[a(1001)](W0,i),g=e[a(470)](j0,h),f=0;return i[a(1285)](_=>{let b=a;console.log(d[b(1394)],_,_[b(1847)]),f=Dr(0,g,f),console[b(590)](d.KUFJi,f),f=d[b(1318)](z0,g,f,_[b(1847)]||0),console[b(590)](d[b(1577)],f),f=Dr(p[_[b(1039)+b(1800)]],g,f),console.log(d[b(1406)],f),f=d.wOyAW(U0,_[b(1039)+b(1800)],g,f),console[b(590)](b(1218),f),f=d[b(1830)](H0,K.fromNumber(_[b(1796)]||t),g,f),console[b(590)](d[b(1143)],f)}),{frameType:Rr,headers:[{key:e[a(703)],value:r}],payload:g}}function J0(i){let t=n,r=0,a=[];for(;e.xDhMI(r,i.byteLength);){let{offset:d}=Tr(i,r);r=d;let h={cursor_name:"",cursor:0,service:0},{value:p,offset:g}=F0(i,r);h[t(1847)]=p,r=g;let{value:f,offset:_}=e[t(1296)](Tr,i,r);r=_,h["cursor_n"+t(1800)]=e[t(1428)](Xi,i,r,e.APtyK(r,f)),r+=f;let{value:b,offset:I}=e[t(539)](q0,i,r);h[t(1796)]=b[t(1131)](),r=I,a[t(1281)](h)}return a}function V0(){let i=n;return{frameType:Rr,headers:[{key:i(789)+i(1772),value:e[i(914)]}],payload:void 0}}class $0{constructor(t,r,a){let d=n;this._cursorNameSpace=t,this[d(1768)+"ileName"]=r,this[d(1400)+d(1059)]=a,this[d(704)]=e[d(1152)](Zi,this[d(1872)+d(487)],"cursor_n"+d(1800))}async[n(411)](){let t=n;await this[t(704)][t(411)]()}async[n(1816)+"rs"](){let t=n;if(!this[t(704)][t(863)])return;let r=this[t(1400)+"Strategy"],a=await this[t(704)][t(525)]();switch(console[t(590)](e[t(1457)],a),r){case e[t(719)]:return a&&a[t(1294)]?e.IByui(ts,a,0,this[t(1768)+t(1045)]):void 0;case e.Mzkav:return;case e[t(971)]:return a&&a.length?e.nKjyP(ts,a,0,this[t(1768)+t(1045)]):e[t(1338)](V0)}}async[n(1541)](t,r,a){let d=n;return console[d(590)](e[d(457)],t,r,a),this._qosDB[d(1541)]({cursor_name:t,cursor:r,service:a})}async[n(1865)+"rs"](t){let r=n,a=e.oHYuz(J0,t);for(let d of a)if(e[r(1666)]===e[r(1666)])console[r(590)](e[r(683)],a),await this._qosDB[r(1541)](d);else{let{initReconnectInterval:h,maxReconnectInterval:p,reconnectIntervalGrowFactor:g}=this[r(1832)],f=e[r(865)](h,_0x4c6ed0[r(1590)](g,_0x4354c4-1));return e[r(1042)](f,p)?p:f}}async[n(893)](t){let r=n;return(await this[r(704)][r(893)](t))?.[r(1796)]}async[n(1810)](){let t=n;await this[t(704)][t(1810)]()}[n(1632)+n(1770)+n(1743)](t){let r=n;this["_cursorF"+r(1045)]=t}get[n(863)](){return this[n(704)].isReady}}let Y0=e[n(1325)];async function ns(i){let t=n;if(!this._options[t(1169)+"S"])return null;let{aID:r,fpID:a,messageStrategy:d}=this[t(1832)],h=e[t(1307)](i,Y0);try{return this[t(1595)+t(881)]?i&&this[t(1595)+t(881)][t(1632)+t(1770)+t(1743)](i):this[t(1595)+t(881)]=new $0(a+"_"+r+"_"+h,h,d),this["_cursorM"+t(881)][t(863)]||await this[t(1595)+"anager"][t(411)](),this["_cursorM"+t(881)]}catch{return null}}async function X0(i,t){let r=n,a={XjPIq:function(B,O){return e[D(1677)](B,O)},TAuVS:function(B,O){return e.RgQlH(B,O)},Kyeei:function(B,O){return B instanceof O},DSbeZ:e[r(1402)],UbDcr:e.EQmAv,iRtqz:function(B,O){return B==O}},d=e[r(990)](Qe,i[r(1268)].headers,r(1234),"-1"),h=Qe(i[r(1268)].headers,r(919),"1"),p=e.OBkqT(mt,i[r(1268)][r(406)],r(1527)+"er_msgid"),g=e.FcIXu(Number,e[r(1110)](mt,i.message[r(406)],r(1527)+r(1846)))||0,f=kr[r(873)](this,i),_=e.sNiqE(Qe,i[r(1268)].headers,r(826)+"s","2"),b=mt(i.message[r(406)],e[r(798)]),I=Number(mt(i[r(1268)].headers,e[r(1107)]));if(f[r(1135)])return e.uOJRw(t);let L=f[r(1005)+r(1573)]?await es[r(873)](this):null;if(e.Ltgcm(i[r(1268)][r(1847)],0)&&h&&!d||e.WyByV(i[r(1268)][r(1847)],0)){if(p&&f[r(1005)+"sage"]&&L)if(e.gQkEV(e[r(1330)],e[r(1330)]))try{return mueAHS[r(623)](r(1586),typeof _0x5b244a)&&(mueAHS.TAuVS(_0x355c12,_0x59d564)||_0x40bb92[r(1176)]&&mueAHS[r(1238)](_0x34c5d1[r(1176)],_0x332b5e))||mueAHS[r(623)](mueAHS[r(502)],typeof _0xf130ea)?"":(_0x2a5abd.parse(_0x1032d0),mueAHS.UbDcr)}catch{return mueAHS[r(755)](r(1586),typeof _0x452a24)?"text/pla"+r(902)+r(1054):""}else return!!!await L[r(893)](p)&&(e[r(1200)]!==e[r(1700)]?(this[r(1298)+"hMessageEvent"](i),await L[r(1541)](p,e[r(1158)](Date[r(1106)](),g))):(_0x40c36c[r(565)+r(894)]=void 0,_0x4d31e2(e.QcRJP))),e[r(1690)](t);if(_){let B=await ns[r(873)](this);if(!B)return this[r(1298)+r(501)+r(806)](i),e[r(763)](t);let O=await B.get(b)??-1;if(e[r(600)](O,I))this[r(1298)+r(501)+"Event"](i),B[r(1541)](b,I,i[r(1268)][r(1847)]);else throw new Error("recevied"+r(1542)+" cursor "+I+(" larger than loc"+r(982)+"r ")+O);return e.imkHX(t)}return this[r(1298)+r(501)+r(806)](i),e[r(1142)](t)}}async function Q0(i,t){let r=n,a=kr[r(873)](this,i);if(!a[r(1005)+"sage"])return t();let d=await es.call(this);if(a[r(954)+r(823)+r(1278)]&&a[r(476)+"s"][r(1294)])for(let h of a.ackMsgIds)await d.del(h);t()}async function Z0(i,t){let r=n,a={oYPkk:function(f,_){return e[D(1476)](f,_)},gHXZh:function(f,_){return e[D(452)](f,_)},xccbo:function(f,_){return e[D(967)](f,_)},qGlNQ:function(f,_){return f|_},SiMMV:function(f,_){return e[D(1102)](f,_)},AehzA:function(f,_){return f|_},lbfRF:function(f,_){return e.zUmHz(f,_)},qFybs:function(f,_){return e[D(1077)](f,_)},DvvzO:function(f,_){return e.yxAjL(f,_)},AjqLD:function(f,_){return e.JYBen(f,_)}},d=e.WZtal(i[r(1268)][r(1756)+"e"],G0),h=e.jJVVH(i.message[r(1756)+"e"],Rr);if(e.wySdM(!d,!h))return e[r(1690)](t);let p=e[r(1058)](mt,i[r(1268)].headers,e.MSCsX);if(!p)return e[r(763)](t);let g=await ns[r(873)](this,p);if(!g)return e[r(1528)](t);if(d){let f=await g[r(1816)+"rs"](),_={frameType:f?.[r(1756)+"e"],SeqID:K[r(484)+"er"](this[r(1126)]++),LogID:K[r(484)+"er"](this[r(1832)][r(688)+r(1100)]()),service:9e3,method:5,headers:f?.[r(406)],payload:f?.[r(1465)]},b=e[r(1360)](E,_);this[r(1075)]&&this[r(1075)][r(725)+"te"]&&this[r(1075)][r(784)](b)}if(h)if(e[r(441)](r(944),r(944)))_0x25509b=_0x4afa65[mUjYBA.oYPkk(_0x513831,_0x3d68d7)+1],_0x3d5f09=_0x495f66[mUjYBA[r(1373)](mUjYBA.oYPkk(_0x301809,_0x13602b),2)],mUjYBA[r(1065)](mUjYBA[r(959)](mUjYBA[r(1895)](_0x180744,mUjYBA[r(879)](_0x1f5174,8)),49344),32896)?_0x1148de+=_0x81ea34:(_0x4f1c4d=mUjYBA.AehzA(mUjYBA[r(1719)](mUjYBA[r(1336)](15,_0x910570)<<12,mUjYBA[r(879)](mUjYBA.qFybs(63,_0x478102),6)),mUjYBA[r(959)](63,_0xdf60be)),_0x1a75b7<2048||mUjYBA.DvvzO(_0x1ee7b3,55296)&&mUjYBA[r(1693)](_0x4a4799,57343)?_0x133914+=_0xcefb5f:(_0x593479+=_0x4e4c91(_0xb37dd),_0x32d9a2+=2));else{let f=i[r(1268)][r(1465)];f&&g[r(1865)+"rs"](f)}}let ec=async function(i,t){let r=n;this[r(1339)]=!1,e[r(495)](clearTimeout,this["_connect"+r(1767)+"utId"]),t()},tc=async function(i,t){let r=n;if(!this._ws||e[r(410)](this[r(1075)].readyState,this[r(661)]))return t();let{pingInterval:a}=this[r(1832)];this["_endpoin"+r(1537)]?.[r(1108)+r(611)+r(1868)]();for(let h=0;e[r(660)](h,this[r(1400)+r(1111)][r(1294)]);h++){let p=this[r(1400)+r(1111)][h];if(this[r(1075)][r(725)+"te"]===this[r(661)]&&e[r(866)](null,p))e[r(1848)](e[r(1036)],e.SxJtp)?(this[r(1075)]&&this[r(1075)][r(784)](p),this[r(1400)+"Queue"][h]=null):(_0x184674(_0x39c292,66),e[r(1031)](_0x4bcb0b,_0x1809c9,_0xd04841[r(1294)]),_0x243c95(_0x5b8e44,_0x187b17));else break}this[r(1400)+r(1111)]=this[r(1400)+r(1111)][r(636)](h=>!!h),this[r(473)+r(1391)+"Id"]=setTimeout(()=>this[r(1264)](),a),this[r(1298)+r(1566)+"nt"](i),this[r(883)+"er"]&&this[r(1075)]&&(this[r(1075)].binaryType=this[r(1885)+r(1749)]);let d=this._endpointManager?.[r(1780)+r(1332)+"nt"]();this[r(724)](r(693)+d+" success"),e[r(1142)](t)},nc=async function(i,t){let r=n,a=this[r(437)+r(1537)]?.[r(1780)+"ntEndpoint"]();this._debug(r(693)+a),e[r(1338)](t)};class rc extends Ir{constructor(t){let r=n,a={zKWNo:function(g,f,_){return e[D(1133)](g,f,_)},ykvQL:function(g,f){return e.vbquQ(g,f)},rSxSl:function(g,f,_){return e[D(1152)](g,f,_)}};super(),this[r(494)+"igatorOn"+r(1498)]=!0,this[r(883)+"er"]=pt,this[r(1034)]=_0,this[r(1708)+"T"]=at,this[r(605)+"X"]=Ft,this._isWorker=Ut,this["_message"+r(1111)]=[],this._endpointManager=null,this[r(1178)+"osed"]=!1,this[r(1885)+r(1749)]=e[r(1271)],this[r(1245)+r(1146)]=!1,this["_connect"+r(1767)+r(1695)]=null,this[r(427)+"ctTimeoutId"]=null,this[r(473)+r(1391)+"Id"]=null,this[r(1126)]=0,this[r(1339)]=!1,this[r(1563)]="",this["_QoSMana"+r(1139)]=null,this[r(1595)+r(881)]=null,this._pingLossCounter=null,this[r(1324)+"ls"]=r(420),this[r(424)]=3,this[r(780)+"NG"]=0,this[r(661)]=1,this[r(808)]=2,this[r(1095)]=g=>{let f=r;try{e[f(920)]($i,this,g,[ec,tc,nc])}catch(_){let b=e[f(1050)](ye,f(1017),{message:_[f(1268)],code:Xe[f(1741)+"OR"],error:_});this[f(1298)+f(860)+f(620)](b)}},this[r(1576)+"ge"]=async g=>{let f=r,_={HYuBg:function(b,I){return e.OWJTv(b,I)}};if(e.vrBqK("DPTHk",e.LHPav)){let{pingInterval:b,pingFrequency:I}=this[f(1832)];if((e[f(1841)]("hi",g[f(1398)])&&e.gBeIn(e.rcEWT,I)||e.FzLLA===I)&&(this["_clearPi"+f(445)](),this.emit(f(1840)+f(1344)+"s",e.CizyX),this[f(473)+f(1391)+"Id"]=e[f(489)](setTimeout,this[f(1264)][f(1827)](this),b)),g[f(1398)]==="hi")return;try{e[f(935)]($i,this,g,[O0,R0,Q0,Z0,X0,L0])}catch(L){let B=e.Kehyp(ye,e[f(1376)],{message:L[f(1268)],code:Xe[f(1814)+f(1251)],error:L});this["_dispatc"+f(860)+"ent"](B)}}else return KSVZqA[f(543)](_0x23976d,_0x25594d[f(1623)](KSVZqA[f(543)](_0x4d4419,this),_0x5ab5a6))},this._onError=g=>{let f=r,_=this[f(437)+f(1537)]?.["checkRea"+f(1071)+"es"](),b=this[f(437)+f(1537)]?.[f(1780)+f(1332)+"nt"]();if(_&&!g[f(1268)]){let I=f(1680)+b+(f(1775)+f(1597)+f(1874)+"ed");this["_dispatc"+f(860)+f(620)](a[f(1520)](ye,f(1017),{message:I,code:Xe[f(1698)+"IES_ERROR"],error:g}));return}this[f(1075)]&&a[f(1507)](this[f(1075)][f(725)+"te"],this[f(661)])&&this[f(1458)+f(443)](),this["_dispatc"+f(860)+f(620)](a[f(1672)](ye,f(1017),{message:g[f(1268)],code:Xe[f(1473)+f(676)],error:g}))},this[r(1588)]=async g=>{let f=r;this[f(1627)+"mer"](),this[f(1287)+f(445)](),this["_removeW"+f(918)+"rs"](),this._ws=null,this[f(1245)+f(1146)]=!1;let _=this._endpointManager?.[f(1231)+f(1071)+"es"]();if(!_&&this[f(1569)+f(1562)]()&&!this[f(1178)+f(1897)]){let b=this["_endpoin"+f(1537)]?.[f(1780)+f(1332)+"nt"](),I=this[f(1832)]["reconnec"+f(951)+"ptor"](g[f(1234)],g[f(1151)]);this[f(1298)+"hCloseEv"+f(620)](e[f(1679)](Ae,e[f(1587)],{code:1006,reason:g[f(1151)]||"connecti"+f(921)+f(970)+f(805)+"n, hostn"+f(1486)+b,willReconnect:I})),I&&this[f(1245)]();return}if(g.code!==1e3&&this[f(1178)+f(1897)])if(f(1802)!=="RTdqn"){this[f(1298)+f(1852)+"ent"](Ae(e[f(1587)],{code:1e3,reason:e[f(517)]})),this[f(437)+f(1537)]?.["resetEnd"+f(611)+f(1868)](),this[f(576)+f(1697)]?.[f(1714)+f(1791)]();return}else{let b=this[f(704)][f(1206)](this._prefix),I=_0x2bcc53[f(956)](b||"{}");return _0x6b0593[f(983)](I)}if(g.code!==1e3&&_){let b=this[f(437)+f(1537)]?.[f(1780)+f(1332)+"nt"](),I=g.reason;I||(I=await e[f(694)](I0,this._url)),I=f(1713)+f(921)+f(926)+I+(f(1087)+f(1289))+b+(f(580)+f(700)+f(803)),this[f(1298)+f(1852)+"ent"](e[f(1557)](Ae,e[f(1587)],{code:g[f(1234)],reason:I}));let L=f(1680)+b+(" fail, m"+f(1597)+f(1874)+"ed");this[f(1298)+"hErrorEvent"](e[f(1557)](ye,e[f(1376)],{message:L,code:Xe[f(1698)+f(1282)+"R"]})),this[f(437)+f(1537)]?.[f(1108)+"pointCon"+f(1868)](),this[f(576)+f(1697)]?.[f(1714)+"nter"]();return}if(e[f(441)](1e3,g.code)&&!g.reason){let b=this[f(437)+f(1537)]?.[f(1780)+f(1332)+"nt"]();this[f(1298)+f(1852)+"ent"](Ae(f(750),{code:g[f(1234)],reason:f(1713)+f(921)+f(970)+f(805)+f(1745)+f(1486)+b})),this[f(437)+f(1537)]?.[f(1108)+"pointCon"+f(1868)](),this[f(576)+f(1697)]?.[f(1714)+f(1791)]();return}this[f(1298)+f(1852)+f(620)](g),this[f(437)+f(1537)]?.["resetEnd"+f(611)+f(1868)](),this[f(576)+f(1697)]?.[f(1714)+f(1791)]()},this[r(1560)]=null,this[r(717)]=null,this.onmessage=null,this[r(753)]=null,this[r(1395)+r(867)]=null,this[r(1364)+"eAck"]=null,this[r(634)+r(1674)+r(584)+"ct"]=null,this[r(430)+r(1460)]=this[r(430)+r(1460)].bind(this),this["_handleO"+r(1673)]=this[r(430)+r(1673)][r(1827)](this),this[r(1782)+"ageHide"]=this[r(1782)+r(529)][r(1827)](this),this[r(1782)+r(1299)]=this[r(1782)+r(1299)][r(1827)](this),this[r(1832)]={url:"",automaticOpen:!0,initReconnectInterval:1e3,maxReconnectInterval:1e4,reconnectIntervalGrowFactor:2,timeoutInterval:5e3,maxRetries:5,debug:!1,maxMessageQueueLength:e.iIYWK(1,0),service:0,logIDGenerator:c,headers:void 0,payloadEncoding:"",payloadType:"",fpID:"",deviceID:"",accessKey:"",ttwID:"",bddID:"",aID:"",disableAutoReconnect:!1,customParams:{},pingInterval:15e3,pingTimeoutInterval:4e3,pingFrequency:e[r(1128)],pingLossCount:2,enableTransformTextPayload:!1,logIDNewConfig:{enableAutoGenerateLogIDNew:!1,userIp:""},miniProgramParams:{customHttpHeader:{}},enableAutoAck:!1,reconnectInterceptor:()=>!0,enableQoS:!1,QoSLevel:2,messageStrategy:e.GobHn,env:{xTTEnv:"",xUseEnv:""},listenNetworkChanged:!0};let{url:d,ws:h}=t,p=Array[r(1799)](d)?d:e.Srtlo(e[r(1402)],typeof d)?[d]:[];if(!p||e.nzpSj(0,p.length))throw new Error(e[r(635)]);if(!e[r(669)](b0,h))throw new Error(e[r(1320)]);if(Object[r(1851)](this[r(1832)],t),this[r(437)+"tManager"]=new Vi(p,this[r(1832)][r(1468)+"es"]),this["_pingLos"+r(1697)]=new C0(this[r(1832)]["pingLoss"+r(520)]),this[r(1832)]["automati"+r(1090)])if(e.sxYop(e[r(1326)],r(1501)))this[r(1339)]=!0,this[r(1245)]();else{if(e[r(1649)](_0x4d2b87,_0x168ec1))return new _0x1fd813(_0x5711fa,_0x176097);if(e[r(524)](_0x3b085e,_0x18e640)&&e[r(985)]!=typeof _0x56dba3)return new _0x30d4c8(_0x29f902,_0x2c4f02);if(e[r(737)](_0x1e02ce,_0x4248c7)&&e[r(1677)](e.RWvDP,typeof _0x540785))return new _0xbb417e(_0xf727c6,_0x14f8d5);throw new _0x5232a8(e[r(1263)])}this[r(1832)][r(574)+r(1459)+"nged"]&&(this._isMiniTT||this[r(605)+"X"]?this[r(618)+"etWorkChange"]():this[r(883)+"er"]&&this[r(1210)+r(1547)+"Listener"]())}["_handleO"+n(1460)](){let t=n;this[t(1832)][t(643)+t(1855)+t(475)]||this[t(1178)+t(1897)]||this[t(1185)+t(867)]()}[n(430)+n(1673)](){let t=n;this["_destroy"+t(1761)+"t"]();let r=Cr(t(1505)+"t",{message:e.vkxHt});this[t(634)+"mediatel"+t(584)+"ct"]&&this[t(634)+t(1674)+"yReconnect"](r)}[n(1210)+n(1547)+n(429)](){let t=n;e.lWEVS("oYhCi",t(1718))?(this[t(883)+"er"]&&window[t(1114)+t(429)](e[t(1069)],this["_handleO"+t(1460)]),this[t(883)+"er"]&&window[t(1114)+t(429)](e[t(1758)],this[t(430)+"ffLine"]),this[t(883)+"er"]&&window[t(1114)+t(429)](t(1593),this[t(1782)+t(529)]),this._isBrowser&&window["addEvent"+t(429)](t(1226),this[t(1782)+"ageShow"])):_0x5bb109[t(843)+t(1051)+"e"](_0x3a3648,{keyPath:_0x51213f})}[n(589)+n(1547)+"Listener"](){let t=n;if(e[t(659)](e.wLfPJ,e[t(1249)])){let r=e[t(518)][t(1884)]("|"),a=0;for(;;){switch(r[a++]){case"0":_0x8e1ac9[_0x15b7f3++]=e.LJGJd(e.XMdzZ(63,_0x2b64c4),128);continue;case"1":++_0x4fd07d;continue;case"2":_0x58604c[_0x4b2b2e++]=e[t(1564)](e.kJyQk(_0xc90253,18),240);continue;case"3":_0x5a64a1=e[t(886)](e[t(797)](65536,(1023&_0x302d78)<<10),e[t(1354)](1023,_0x365bd9));continue;case"4":_0x1e9d1a[_0x5130b2++]=e[t(1029)](e.ukTLb(_0x460588,6)&63,128);continue;case"5":_0x5e2336[_0x245e8b++]=e[t(1009)](e.iDUHP(_0x11421a,12),63)|128;continue}break}}else this[t(883)+"er"]&&window[t(633)+t(978)+t(885)]("online",this[t(430)+t(1460)]),this._isBrowser&&window[t(633)+"entListener"](e[t(1758)],this[t(430)+"ffLine"]),this[t(883)+"er"]&&window[t(633)+t(978)+t(885)](t(1593),this[t(1782)+t(529)]),this[t(883)+"er"]&&window[t(633)+t(978)+t(885)]("pageshow",this[t(1782)+t(1299)])}[n(1782)+n(529)](t){let r=n,a={VTnCH:function(d,h){return e.RmpJx(d,h)},OZgjv:e.QuPMd,ayoxN:function(d,h){return e[D(949)](d,h)},EncXg:function(d,h){return d+h}};if(e[r(957)]!==e[r(957)])return RvhUXt[r(1660)](_0x30883a,_0x1ac0a2)?_0x1e877c[r(1091)](new _0x2d4d85(RvhUXt.OZgjv)):(_0x548d90=_0x417c14,RvhUXt[r(934)](_0x22b85a,_0x5e5092[r(1294)])?_0x38f534.resolve():_0x3583de[_0x208c07][r(1827)](_0xe14a7f)(_0x404df0,_0x129f9c[r(1827)](null,RvhUXt.EncXg(_0x355349,1))));!t[r(910)+"d"]&&(this[r(883)+"er"]&&window[r(633)+"entListener"]("pagehide",this[r(1782)+r(529)]),this[r(883)+"er"]&&window["removeEventListe"+r(885)](e.LNVVg,this[r(1782)+r(1299)]),this[r(750)]()),this[r(883)+"er"]&&window[r(633)+r(978)+"ner"](e[r(1069)],this[r(430)+"nLine"]),this[r(883)+"er"]&&window[r(633)+r(978)+"ner"](r(545),this._handleOffLine)}["_handleP"+n(1299)](t){let r=n;t[r(910)+"d"]&&(this[r(1569)+r(1562)]()&&(!this[r(1075)]||e[r(1190)](this._ws[r(725)+"te"],this[r(661)])||e[r(1774)](this[r(1075)][r(725)+"te"],this[r(780)+"NG"]))&&this[r(430)+r(1460)](),this._isBrowser&&window["addEvent"+r(429)](e[r(1069)],this[r(430)+r(1460)]),this[r(883)+"er"]&&window[r(1114)+"Listener"](e[r(1758)],this[r(430)+"ffLine"]))}async[n(819)+"eUrl"](t){let r=n,a={tpqON:e.FnJXm,qTJhK:function(d,h,p,g){return d(h,p,g)},aoftV:e[r(691)],qpXwL:function(d,h,p,g){return d(h,p,g)},qgBWo:e[r(731)],optJa:e[r(627)],mLOvR:e.EmPYS};if(e[r(999)](e.DHPiZ,r(1419))){let{fpID:d,deviceID:h,bddID:p,ttwID:g,accessKey:f,aID:_,customParams:b={},enableAutoAck:I,enableQoS:L,QoSLevel:B,env:O}=this[r(1832)],ve,be,Se;if(this._isBrowser||this._isMiniWX||this._isMiniTT)if(e[r(1594)](r(1026),e.bwlbn)){let[qt,Ht]=e[r(1843)](_0x4a065e,_0xa3133c),wt=e[r(1860)](_0x21276f,qt),de=0;return _0xad007f[r(1285)](_t=>{let Q=r;_0x1ff658[Q(590)](rVAcuW[Q(1444)],_t,_t.service),de=rVAcuW[Q(692)](_0x2e28b6,0,wt,de),_0x3ad99a[Q(590)](rVAcuW[Q(1109)],de),de=rVAcuW[Q(781)](_0x1325e0,wt,de,_t[Q(1847)]||0),_0x10c708[Q(590)](rVAcuW[Q(1104)],de),de=_0x335a97(Ht[_t[Q(1039)+"ame"]],wt,de),_0x55dc6c[Q(590)](rVAcuW[Q(1675)],de),de=_0x3e05e2(_t[Q(1039)+Q(1800)],wt,de),_0x3a1e0f[Q(590)](Q(1218),de),de=_0x24a1f2(_0x14b2e8[Q(484)+"er"](_t[Q(1796)]||_0x234576),wt,de),_0x509e64.log(rVAcuW[Q(746)],de)}),{frameType:_0x16b08a,headers:[{key:e[r(703)],value:_0x44884f}],payload:wt}}else ve=location&&e[r(1543)](e[r(582)],location[r(1661)])?r(1113):e[r(1269)],be=t.replace(/((^ws)|(^http))((?:[s]*:\/\/))/,""),Se=/^wss(.*:\/\/)/[r(1313)](t)?t:""+ve+be;else ve=r(1113),be=t[r(1616)](/(^http)((?:[s]*:\/\/))/,""),Se=/(^ws)((?:[s]*:\/\/))/.test(be)?be:""+ve+be;let fn=p?e[r(1205)]:g?r(544):e[r(1261)],rs=p||g||h;if(!rs||!fn)throw new Error(e.kLXas);let ic=e[r(777)]("function",typeof b)?await e[r(1528)](b):b,sc=O?e[r(1172)](E0,O.xUseEnv,O.xTTEnv):{},Lr=Object.assign({device_platform:e[r(412)],version_code:e.cHJTx,access_key:f,fpid:d,aid:_,[fn]:rs,xsack:I?1:0,xaack:I?1:0,xsqos:L?1:0,qos_level:L?B:void 0,qos_sdk_version:2,...sc},ic),oc=Object[r(877)](Lr)[r(479)]((qt,Ht)=>Lr[Ht]!==void 0?""+qt+(qt?"&":"?")+Ht+"="+Lr[Ht]:qt,"");return Se+"/ws/v2"+oc}else return _0x223cae||(_0x1a2958=[_0x3a8691[r(1382)+"e"][r(1086)],_0x557590[r(1382)+"e"].continue,_0x5b05f1[r(1382)+"e"][r(1046)+r(936)+"ey"]])}async[n(1245)](){let t=n;if(!(this[t(1245)+"Lock"]||this[t(1178)+"osed"])){this[t(1245)+t(1146)]=!0;try{let r=this[t(437)+"tManager"]?.["checkCur"+t(446)+t(1716)+t(1070)+t(1130)](),{timeoutInterval:a}=this[t(1832)];if(r){let h=this[t(437)+t(1537)]?.[t(1780)+t(1332)+"nt"](),p=this["_endpoin"+t(1537)]?.["replaceB"+t(418)+t(553)+t(839)+t(1033)](),g=this["_endpoin"+t(1537)]?.[t(1780)+t(1332)+"ntTriesC"+t(1614)]();if(p){let f="connect "+h+(t(948)+t(580)+"tries re"+t(1820)+"ill use "+t(586)+t(955))+p+" to retry",_=ye(e[t(1376)],{message:f,code:Xe[t(1698)+"IES_ERROR"]});this[t(724)](f),this[t(1298)+t(860)+t(620)](_),this._url=await this[t(819)+t(1393)](p),this[t(724)](t(1680)+p+" "+g+t(1888)),this[t(1305)+t(918)+"rs"]()}else{let f=t(1680)+h+(t(948)+", max re"+t(700)+"ached");this[t(724)](f),this["_dispatc"+t(860)+t(620)](ye(e[t(1376)],{message:f,code:Xe[t(1698)+t(1282)+"R"]}));return}}else{let h=this[t(437)+"tManager"]?.[t(1780)+t(1332)+t(915)+t(1474)](),p=this[t(437)+t(1537)]?.[t(1780)+t(1332)+t(1703)+t(1614)]();this[t(1563)]=await this[t(819)+t(1393)](e[t(1529)](h,"")),this[t(724)](t(1680)+h+" "+p+t(1888)),this[t(1305)+"sListeners"]()}if(this[t(1339)])this[t(1339)]=!1;else{let h=e[t(1705)](Cr,t(1505)+"t",{message:e[t(631)]});this[t(1395)+t(867)]&&this[t(1395)+t(867)](h)}let d=this[t(437)+t(1537)]?.[t(1780)+t(1332)+t(1703)+t(1614)]()||0;d>1&&await this[t(1341)](d-1),this._debug(t(1713)+t(570)+this[t(1563)]+(t(466)+"ls: ")+this[t(1324)+"ls"]),this[t(1075)]=e.Hsnwe(v0,{url:this[t(1563)],protocols:[this[t(1324)+"ls"]],headers:this._options[t(1763)+t(1513)+"s"][t(1646)+t(1356)]},this[t(1832)].ws),(this[t(883)+"er"]||this[t(1288)+"r"])&&this._ws&&(this[t(1075)][t(1159)+"pe"]=this[t(1885)+t(1749)]),this._addWsListeners(),this["_connect"+t(1767)+t(1695)]=e[t(1653)](setTimeout,this._onTimeout[t(1827)](this),a)}catch(r){throw this[t(1245)+"Lock"]=!1,r}}}[n(1627)+n(1250)](){let t=n;e[t(772)](clearTimeout,this[t(1245)+t(1767)+t(1695)]),this["_connect"+t(1767)+t(1695)]=null}[n(1287)+n(445)](){let t=n;e[t(1367)](clearTimeout,this[t(473)+t(1391)+"Id"]),e.rvtSt(clearTimeout,this["_reconne"+t(1707)+t(889)]),this[t(473)+t(1391)+"Id"]=null,this["_reconne"+t(1707)+t(889)]=null}[n(724)](...t){let r=n;this[r(1832)].debug&&console[r(590)].apply(console,[r(965)+">",...t])}[n(791)+"rvalValue"](t){let r=n,{initReconnectInterval:a,maxReconnectInterval:d,reconnectIntervalGrowFactor:h}=this[r(1832)],p=e.jYjgD(a,Math.pow(h,e[r(1302)](t,1)));return e[r(1787)](p,d)?d:p}[n(1264)](){let t=n;if(this[t(1075)]&&this._ws.readyState===this.CONNECTING){this[t(1287)+"ngTimer"](),this[t(473)+"gTimeoutId"]=e[t(1058)](setTimeout,this[t(1264)][t(1827)](this),this[t(1832)].pingInterval);return}if(!this[t(1075)]||e[t(1265)](this._ws.readyState,this[t(661)]))return void this[t(1185)+t(867)]();this[t(1075)]&&this._ws[t(784)]("hi"),this["_reconne"+t(1707)+t(889)]=e.MFSMN(setTimeout,this[t(1185)+t(867)+t(941)][t(1827)](this),this[t(1832)][t(1633)+t(1659)+t(1040)])}[n(1185)+n(867)+n(941)](){let t=n;e[t(1652)](t(1196),e[t(1414)])?(this[t(576)+t(1697)]?.addCount(),this.emit(t(1840)+t(916)+"t",e[t(598)]),this._pingLossCounter?.checkReachMaxCount()?this[t(1185)+t(867)]():this[t(1264)]()):(this[t(1032)+t(1614)]=_0x596b09,this[t(880)]=0)}[n(1569)+n(1562)](){let t=n;return this._isMiniTT||this[t(605)+"X"]?this["_miniNav"+t(504)+t(1498)]:(this._isBrowser||this._isWorker)&&this[t(1832)][t(574)+t(1459)+"nged"]?navigator[t(1864)]:!0}[n(1185)+n(867)](){let t=n;!this["_navigat"+t(1562)]()||this[t(1178)+t(1897)]||(this[t(437)+t(1537)]?.[t(1108)+t(611)+t(1868)](),this[t(576)+t(1697)]?.[t(1714)+t(1791)](),this[t(1075)]?this[t(1458)+t(443)](1001,e[t(815)],!0):this[t(1245)]())}[n(618)+"etWorkCh"+n(1381)](){let t=n;this[t(1708)+"T"]?tt["onNetworkStatusC"+t(931)](({isConnected:r})=>{let a=t;this[a(494)+a(504)+"line"]=r,r?this[a(430)+a(1460)]():this["_handleO"+a(1673)]()}):this._isMiniWX&&wx[t(1427)+t(760)+"hange"](({isConnected:r})=>{let a=t;this[a(494)+"igatorOn"+a(1498)]=r,r?this[a(430)+a(1460)]():this[a(430)+"ffLine"]()})}[n(1341)](t){let r={pOEVs:function(a,d,h){return e[D(539)](a,d,h)}};return new Promise(a=>{let d=D;r[d(1333)](setTimeout,a,this[d(791)+d(1581)+"e"](t))})}["_disconn"+n(443)](t=1e3,r="",a=!1){let d=n;this[d(1075)]&&this[d(1556)+d(1761)+"t"](t,r,a)}[n(827)+"ut"](){let t=n,r=this[t(437)+t(1537)]?.[t(1780)+t(1332)+"nt"]();this[t(724)](t(1680)+r+t(948)),this[t(1458)+t(443)](1001,e[t(1073)],!0)}_sendAck(t){let r=n;if(e[r(648)](e[r(1022)],e[r(1022)]))_0x1288f2=_0x555d93[e[r(933)](_0x364359,_0xa8d85b)+1],_0x2d86c4=_0x447b45[e[r(727)](e[r(1731)](_0x27a78a,_0x53e453),2)],_0x11e237=_0x6ad26f[e[r(1244)](e[r(1538)](_0x17a16e,_0xcbb597),3)],e[r(468)](e.epqWA(e[r(1747)](_0xa07ed5,e[r(1019)](_0x5b8749,8))|_0x49ea59<<16,12632256),8421504)?_0x3caea1+=_0x35d947:(_0x3c209=e[r(824)](e[r(995)](e[r(1124)](e[r(1439)](7&_0x145151,18),e[r(492)](e[r(1266)](63,_0x425e5e),12)),e[r(1462)](63&_0x55780c,6)),e[r(431)](63,_0x1ee502)),e.tmARX(_0x27dac9,65536)||e[r(1787)](_0x56c273,1114111)?_0x395d9f+=_0x1c5b59:(_0x515204-=65536,_0xebf2a7+=_0x1dd754(e.mhCGr(e[r(1380)](_0xe27c48,10),55296),e[r(1892)](1023&_0x2315fa,56320)),_0x13022a+=3));else{let a=e.MBzDr(Er,t);this[r(1075)]&&e[r(1497)](this._ws.readyState,this.OPEN)&&(this[r(1075)]&&this._ws[r(784)](a),this[r(724)](r(1701),t))}}["_removeW"+n(918)+"rs"](){let t=n,r=e[t(1567)].split("|"),a=0;for(;;){switch(r[a++]){case"0":this[t(1075)]["removeEventListe"+t(885)](e[t(1376)],this[t(1116)]);continue;case"1":this[t(1075)][t(633)+"entListe"+t(885)](e[t(882)],this[t(1095)]);continue;case"2":if(!this._ws)return;continue;case"3":this[t(1075)]["removeEv"+t(978)+t(885)](e[t(1587)],this[t(1588)]);continue;case"4":this[t(1075)][t(633)+t(978)+"ner"](e[t(1422)],this._onMessage);continue}break}}[n(1375)+n(1631)](){let t=n,r=(t(947)+"4")[t(1884)]("|"),a=0;for(;;){switch(r[a++]){case"0":this[t(1075)][t(1114)+t(429)](t(1268),this[t(1576)+"ge"]);continue;case"1":this._ws["addEvent"+t(429)](e[t(1587)],this[t(1588)]);continue;case"2":if(!this[t(1075)])return;continue;case"3":this[t(1075)].addEventListener(t(436),this[t(1095)]);continue;case"4":this[t(1075)][t(1114)+t(429)](e.EavzQ,this[t(1116)]);continue}break}}[n(697)+"nceClose"](t=1e3,r=""){let a=n;if(e.fswNV(a(1824),a(1331)))try{this[a(1075)]&&this._ws[a(750)](t,r)}catch{}else return _0x246be0?_0x27d93e["fromByte"+a(1297)](_0x4ddeaf,_0x23ff11):_0x46b3e0[a(802)+"sBE"](_0x434ddf,_0x31875e)}["_destroy"+n(1761)+"t"](t=1e3,r="",a=!1){let d=n;if(this._clearPingTimer(),this[d(1627)+d(1250)](),this[d(1305)+d(918)+"rs"](),this[d(697)+d(950)](1e3,r),this["_connect"+d(1146)]=!1,a&&this[d(1569)+d(1562)]()&&!this[d(1178)+d(1897)]){if(this[d(437)+d(1537)]?.[d(1231)+d(1071)+"es"]()){let p=this[d(437)+"tManager"]?.[d(1780)+d(1332)+"nt"]();this["_dispatc"+d(1852)+"ent"](e[d(1488)](Ae,e[d(1587)],{code:1006,reason:d(1680)+p+(" timeout"+d(580)+d(700)+d(803)),wasClean:!0}))}else if(e[d(835)](e.HqmBd,e.HqmBd)){let p=this[d(1832)][d(1505)+"tInterce"+d(1223)](t,r);this["_dispatc"+d(1852)+d(620)](Ae(e[d(1587)],{code:t,reason:r,wasClean:!0,willReconnect:p})),p&&this[d(1245)]()}else this[d(1630)](e[d(1376)],_0x49efd1(e[d(1376)],{message:this["_formatE"+d(1532)+d(1278)](_0x2bdc8c)}));return}this[d(1569)+d(1562)]()||this[d(1178)+d(1897)]?this[d(1298)+d(1852)+d(620)](Ae(e.FUEwc,{code:t,reason:d(465)})):this[d(1298)+"hCloseEvent"](e[d(1152)](Ae,e[d(1587)],{code:1006,reason:e[d(1552)]})),this[d(1075)]=null,this[d(437)+d(1537)]?.[d(1108)+d(611)+"fig"](),this["_pingLos"+d(1697)]?.[d(1714)+"nter"]()}[n(1298)+"hOpenEvent"](t){let r=n;this[r(1630)](e.UKQTC,t),this[r(753)]&&this[r(753)](t)}[n(1298)+n(501)+"Event"](t){let r=n;this[r(1630)](e[r(1422)],t),this[r(1769)+"e"]&&this[r(1769)+"e"](t)}[n(1298)+n(1793)+n(403)](t){let r=n;this[r(1630)](e[r(1399)],t),this[r(1364)+r(689)]&&this["onReceiv"+r(689)](t)}[n(1298)+n(860)+n(620)](t){let r=n,a={qHJqX:r(436),HLLDP:e[r(1422)],jHmAJ:e[r(1376)]};if(e[r(619)](e[r(1204)],e[r(1204)])){if(!this[r(1075)])return;this._ws[r(1114)+r(429)](rEJVPj[r(650)],this._onOpen),this[r(1075)][r(1114)+"Listener"]("close",this[r(1588)]),this[r(1075)]["addEvent"+r(429)](rEJVPj.HLLDP,this._onMessage),this[r(1075)][r(1114)+r(429)](rEJVPj.jHmAJ,this._onError)}else this[r(1630)](e[r(1376)],t),this.onerror&&this[r(717)](t)}["_dispatc"+n(1852)+n(620)](t){let r=n;e[r(866)](r(467),e[r(1004)])?(this[r(1630)]("close",t),this[r(1560)]&&this[r(1560)](t)):this[r(1722)+r(511)+r(1348)+"t"]=0}get binaryType(){let t=n;return this[t(1075)]?this._ws[t(1159)+"pe"]:this[t(1885)+t(1749)]}set[n(1159)+"pe"](t){let r=n;this[r(1885)+"ype"]=t,this[r(1075)]&&(this._ws[r(1159)+"pe"]=t)}get[n(1207)+"nt"](){let t=n;return this["_endpoin"+t(1537)]?.[t(1780)+t(1332)+"ntTriesC"+t(1614)]()||0}get["buffered"+n(1886)](){let t=n,r={CdwGf:e[t(701)]};if(e[t(1407)](e.eZFTX,e[t(1274)])){let a=this["_message"+t(1111)][t(479)]((d,h)=>(d+=h&&h[t(1041)+"th"]||0,d),0);return e[t(1812)](a,this[t(1075)]?this[t(1075)][t(1448)+t(1886)]:0)}else _0x57bd5b=YQkQIr[t(555)],_0x4726d8=_0x324a34[t(1616)](/(^http)((?:[s]*:\/\/))/,""),_0x1936ca=/(^ws)((?:[s]*:\/\/))/[t(1313)](_0x39b1df)?_0x52ee19:""+_0x521342+_0x23fc33}get[n(825)+"ns"](){let t=n;return this[t(1075)]?this[t(1075)][t(825)+"ns"]:""}get[n(1661)](){let t=n;return this[t(1075)]?this[t(1075)][t(1661)]:""}get[n(725)+"te"](){let t=n;return this[t(1075)]?this._ws.readyState:this._options[t(1470)+t(1090)]?this[t(780)+"NG"]:this[t(424)]}get[n(1048)](){let t=n;if(e.ObFvb!==e[t(1475)])return this[t(1075)]?this[t(1075)][t(1048)]:this[t(1563)];this[t(880)]++}close(t=1e3,r){let a=n;if(e[a(716)]===e[a(716)]){if(this[a(1178)+a(1897)]=!0,this[a(1627)+"mer"](),this._clearPingTimer(),this[a(589)+a(1547)+a(429)](),this[a(496)+"ger"]?.[a(1810)](),!this._ws)return void this[a(724)](a(1280)+a(551)+"ce not i"+a(1235)+"ed");if(e[a(472)](this[a(1075)][a(725)+"te"],this.CLOSED)||this[a(1075)][a(725)+"te"]===this[a(808)])return void this[a(724)](e[a(1193)]);this[a(1556)+a(1761)+"t"](t,r)}else{if(e.cElmk(e[a(729)](_0xc0a53,_0x4b20f2),1))return"";let d="";for(let h=_0x23f663;h<_0x3a7936;){let p=_0x218932[h++];if(e.oivDV(p,127))d+=_0x549a79[a(1831)+"Code"](p);else if(e[a(858)](p,192)&&e[a(888)](p,224))d+=_0x9402fe.fromCharCode(e[a(1564)](e[a(425)](31,p)<<6,e.CFixh(63,_0x3cacd4[h++])));else if(p>=224&&p<240)d+=_0x279a6f[a(1831)+"Code"](e[a(1572)](e[a(1260)](e.hyYfP(e[a(425)](15,p),12),e[a(1066)](63&_0x2c17fe[h++],6)),e[a(516)](63,_0x4261cd[h++])));else if(e[a(686)](p,240)){let g=e[a(733)](e[a(1162)](e[a(1492)](7,p),18)|e[a(416)](e[a(1432)](63,_0x44dc1f[h++]),12)|e[a(681)](e[a(834)](63,_0x58fcc0[h++]),6)|63&_0x443c9e[h++],65536);d+=_0x44e98b[a(1831)+"Code"](e.cVKLc(55296,e.iDUHP(g,10))),d+=_0x269d07[a(1831)+a(690)](e[a(1308)](56320,1023&g))}}return d}}async send(t,r){let a=n;if(e[a(777)](null,t))throw new Error(e.Qudqc);e[a(846)](e[a(1654)],typeof t)&&(t=JSON[a(1723)+"y"](t)),e.dffso(e[a(1402)],typeof t)&&!(t instanceof ArrayBuffer)&&!(t[a(1176)]&&e.fNnjG(t[a(1176)],ArrayBuffer))&&(t=JSON[a(1723)+"y"](t));let d=await e[a(1735)](Qi,t),h=e[a(768)](S0,t),{method:p=0,service:g=this._options[a(1847)],logID:f=this[a(1832)]["logIDGen"+a(1100)](),headers:_=this[a(1832)][a(406)],payloadEncoding:b=this[a(1832)][a(840)+"ncoding"],payloadType:I=this[a(1832)].payloadType,logIDNew:L=this._options[a(1021)+a(1702)][a(536)+a(864)+a(1819)+"ew"]?o(this._options[a(1021)+a(1702)].userIp):""}=e[a(872)](r,{});if(!g)throw new Error(e[a(945)]);let B={SeqID:K[a(484)+"er"](this[a(1126)]++),LogID:K[a(484)+"er"](f),service:g,method:p,headers:_,payloadEncoding:b instanceof Object?b[a(1829)]?b[a(1829)]:"":b,payloadType:e[a(577)](I,Object)?I.type?I.type:h:I||h,payload:d,LogIDNew:L},O=e[a(741)](Er,B);if(this._ws&&e[a(1585)](this[a(1075)][a(725)+"te"],this.OPEN))this._ws&&this[a(1075)].send(O),this[a(724)](e[a(1854)],B);else if(e[a(1822)](this[a(1400)+a(1111)][a(1294)],this[a(1832)][a(453)+a(1584)+a(442)]))this[a(1400)+"Queue"][a(1281)](O),this._debug(e.HtTlT,B);else{if(e[a(1436)](e[a(773)],e.dzDGj))return e[a(1699)](_0x4ba15a,e[a(463)](e[a(1692)](e[a(1362)](e[a(637)](e.oKFxI(e[a(1878)],_0x49f9ef),a(1276)),e[a(1144)](_0x1d998d,1)),e[a(653)]),_0x17c2f9));this[a(1400)+"Queue"][a(1309)](),this["_message"+a(1111)][a(1281)](O)}return{seqID:this._seqId,logID:f,logIDNew:L}}async reconnect(t){let r=n,{url:a}=e.CySEG(t,{}),d=Array[r(1799)](a)?a:e[r(777)](e.cyfue,typeof a)?[a]:[];t&&Object[r(1851)](this[r(1832)],t),d&&d[r(1294)]?this._endpointManager=new Vi(d,this[r(1832)][r(1468)+"es"]):this[r(437)+"tManager"]?.[r(1108)+r(611)+r(1868)](),this[r(576)+r(1697)]?.[r(1714)+r(1791)](this[r(1832)].pingLossCount),this[r(1178)+"osed"]=!1,this[r(1075)]&&e.mabrR(this._ws.readyState,this[r(424)])?this[r(1458)+"ect"](1e3,r(1384)+r(867)+r(859),!0):(this[r(1339)]=!0,this[r(1245)]())}async[n(401)](){let t=n;if(e[t(820)](e[t(810)],e[t(810)])){if(!this[t(1245)+t(1146)]){let r=e[t(1191)][t(1884)]("|"),a=0;for(;;){switch(r[a++]){case"0":this[t(1339)]=!0;continue;case"1":this[t(576)+"sCounter"]?.[t(1714)+t(1791)]();continue;case"2":this[t(1178)+t(1897)]=!1;continue;case"3":this["_endpoin"+t(1537)]?.[t(1108)+t(611)+t(1868)]();continue;case"4":this[t(1245)]();continue}break}}}else _0x506545=UGDtHK[t(1699)](_0x347cf4,_0x4c55f6)}[n(1114)+n(429)](t,r){this.on(t,r)}[n(975)+n(806)](t){let r=n;if(e[r(1277)](e[r(868)],e[r(868)])){let a=_0x29b772(e.EavzQ,{message:this[r(1750)+"rrorMessage"](_0x42b527)});this.emit(r(1017),a);let d=e[r(542)](_0x11c4f5,e[r(1587)],{reason:this["_formatE"+r(1532)+r(1278)](_0x3df1dd)});this[r(1630)](r(750),d)}else{let{type:a}=t;this[r(1630)](a,t)}}removeEventListener(t,r){this[n(875)](t,r)}pingOnce(){let t=n,r={iLvye:function(a,d){return a(d)},FtTDk:e[t(1738)],NHZHx:t(1840)+t(916)+"t",WNZNr:function(a,d){return a===d},pxtMB:e[t(1789)],jkxwh:e.JvftS,znlvg:e[t(491)],HiQIC:function(a,d,h){return e[t(1084)](a,d,h)}};return t(615)!==e.cCeMW?e[t(1292)](_0x3ec559,_0x34b336):new Promise((a,d)=>{let h=t,p={CdZUa:function(g,f){return r[D(625)](g,f)},TDCys:r[h(1323)],dWZss:r[h(477)],FSlLD:function(g,f){return r[h(1599)](g,f)},UBSdw:r[h(678)],MePQB:r[h(1500)],bQJIG:"ping_onc"+h(1344)+"s"};if(r[h(1055)]===h(478)){this._clearPingTimer(),this._pingPongTimeoutId=r.HiQIC(setTimeout,this[h(1264)][h(1827)](this),this[h(1832)][h(1112)+h(1875)]);let g=()=>{let _=h;p.CdZUa(a,p[_(1686)]),this.off("ping_onc"+_(1344)+"s",g),this[_(875)](p.dWZss,f)},f=()=>{let _=h,b={sKmKA:function(I,L){return p[D(1549)](I,L)}};if(p[_(1583)]===_(938))return zyfAAm[_(1062)](0,this[_(1447)])&&zyfAAm[_(1062)](0,this[_(862)]);p.CdZUa(d,p[_(712)]),this[_(875)](p[_(1306)],g),this[_(875)](p.dWZss,f)};this.on(h(1840)+h(1344)+"s",g),this.on(r[h(477)],f),this[h(1264)]()}else _0x34f07a[h(908)]()[h(1455)](()=>{let g=h;this[g(1375)+g(1631)]()})})}}})(),Z["CustomCl"+C(979)]=Y["CustomCl"+C(979)],Z["CustomEr"+C(456)]=Y[C(1717)+"rorEvent"],Z[C(953)+"e"]=Y[C(953)+"e"],Z.Event=Y[C(806)],Z[C(1466)]=Y[C(1466)],Z["Frontier"+C(482)+C(940)]=Y[C(1867)+C(482)+C(940)],Z["MessageE"+C(940)]=Y[C(482)+C(940)],Z[C(1859)+"t"]=Y.OpenEvent,Z["Reconnec"+C(1316)]=Y["Reconnec"+C(1316)],Z[C(964)+C(979)]=Y[C(964)+"oseEvent"],Z[C(779)+"rorEvent"]=Y["createEr"+C(456)],Z[C(695)+C(1806)+"nt"]=Y[C(695)+C(1806)+"nt"],Z[C(1343)+C(734)]=Y[C(1343)+C(734)],Z[C(1788)+C(745)+"vent"]=Y["createRe"+C(745)+C(940)],Z[C(1177)+"rame"]=Y[C(1177)+C(500)],Z[C(1328)+C(1800)]=Y[C(1328)+"ame"];for(Gn in Y)[C(1241)+"oseEvent",C(1717)+"rorEvent",C(953)+"e",C(806),C(1466),C(1867)+C(482)+"vent",C(482)+C(940),C(1859)+"t",C(705)+C(1316),C(964)+"oseEvent",C(779)+C(456),C(695)+C(1806)+"nt",C(1343)+"enEvent",C(1788)+C(745)+C(940),C(1177)+C(500),C(1328)+C(1800)][C(1243)](Gn)===-1&&(Z[Gn]=Y[Gn]);var Gn;Object[C(1665)+C(1755)](Z,C(563)+"le",{value:!0})});var Ge=le((dm,Bo)=>{"use strict";var Oo=["nodebuffer","arraybuffer","fragments"],No=typeof Blob<"u";No&&Oo.push("blob");Bo.exports={BINARY_TYPES:Oo,CLOSE_TIMEOUT:3e4,EMPTY_BUFFER:Buffer.alloc(0),GUID:"258EAFA5-E914-47DA-95CA-C5AB0DC85B11",hasBlob:No,kForOnEventAttribute:Symbol("kIsForOnEventAttribute"),kListener:Symbol("kListener"),kStatusCode:Symbol("status-code"),kWebSocket:Symbol("websocket"),NOOP:()=>{}}});var nn=le((um,Qn)=>{"use strict";var{EMPTY_BUFFER:Qd}=Ge(),Qr=Buffer[Symbol.species];function Zd(n,e){if(n.length===0)return Qd;if(n.length===1)return n[0];let s=Buffer.allocUnsafe(e),o=0;for(let c=0;c<n.length;c++){let x=n[c];s.set(x,o),o+=x.length}return o<e?new Qr(s.buffer,s.byteOffset,o):s}function Mo(n,e,s,o,c){for(let x=0;x<c;x++)s[o+x]=n[x]^e[x&3]}function zo(n,e){for(let s=0;s<n.length;s++)n[s]^=e[s&3]}function eu(n){return n.length===n.buffer.byteLength?n.buffer:n.buffer.slice(n.byteOffset,n.byteOffset+n.length)}function Zr(n){if(Zr.readOnly=!0,Buffer.isBuffer(n))return n;let e;return n instanceof ArrayBuffer?e=new Qr(n):ArrayBuffer.isView(n)?e=new Qr(n.buffer,n.byteOffset,n.byteLength):(e=Buffer.from(n),Zr.readOnly=!1),e}Qn.exports={concat:Zd,mask:Mo,toArrayBuffer:eu,toBuffer:Zr,unmask:zo};if(!process.env.WS_NO_BUFFER_UTIL)try{let n=$("bufferutil");Qn.exports.mask=function(e,s,o,c,x){x<48?Mo(e,s,o,c,x):n.mask(e,s,o,c,x)},Qn.exports.unmask=function(e,s){e.length<32?zo(e,s):n.unmask(e,s)}}catch{}});var qo=le((fm,Uo)=>{"use strict";var Fo=Symbol("kDone"),ei=Symbol("kRun"),ti=class{constructor(e){this[Fo]=()=>{this.pending--,this[ei]()},this.concurrency=e||1/0,this.jobs=[],this.pending=0}add(e){this.jobs.push(e),this[ei]()}[ei](){if(this.pending!==this.concurrency&&this.jobs.length){let e=this.jobs.shift();this.pending++,e(this[Fo])}}};Uo.exports=ti});var Rt=le((lm,Go)=>{"use strict";var rn=$("zlib"),Ho=nn(),tu=qo(),{kStatusCode:Ko}=Ge(),nu=Buffer[Symbol.species],ru=Buffer.from([0,0,255,255]),er=Symbol("permessage-deflate"),We=Symbol("total-length"),Tt=Symbol("callback"),rt=Symbol("buffers"),Dt=Symbol("error"),Zn,ni=class{constructor(e){if(this._options=e||{},this._threshold=this._options.threshold!==void 0?this._options.threshold:1024,this._maxPayload=this._options.maxPayload|0,this._isServer=!!this._options.isServer,this._deflate=null,this._inflate=null,this.params=null,!Zn){let s=this._options.concurrencyLimit!==void 0?this._options.concurrencyLimit:10;Zn=new tu(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[Tt];this._deflate.close(),this._deflate=null,e&&e(new Error("The deflate stream was closed while data was being processed"))}}acceptAsServer(e){let s=this._options,o=e.find(c=>!(s.serverNoContextTakeover===!1&&c.server_no_context_takeover||c.server_max_window_bits&&(s.serverMaxWindowBits===!1||typeof s.serverMaxWindowBits=="number"&&s.serverMaxWindowBits>c.server_max_window_bits)||typeof s.clientMaxWindowBits=="number"&&!c.client_max_window_bits));if(!o)throw new Error("None of the extension offers can be accepted");return s.serverNoContextTakeover&&(o.server_no_context_takeover=!0),s.clientNoContextTakeover&&(o.client_no_context_takeover=!0),typeof s.serverMaxWindowBits=="number"&&(o.server_max_window_bits=s.serverMaxWindowBits),typeof s.clientMaxWindowBits=="number"?o.client_max_window_bits=s.clientMaxWindowBits:(o.client_max_window_bits===!0||s.clientMaxWindowBits===!1)&&delete o.client_max_window_bits,o}acceptAsClient(e){let s=e[0];if(this._options.clientNoContextTakeover===!1&&s.client_no_context_takeover)throw new Error('Unexpected parameter "client_no_context_takeover"');if(!s.client_max_window_bits)typeof this._options.clientMaxWindowBits=="number"&&(s.client_max_window_bits=this._options.clientMaxWindowBits);else if(this._options.clientMaxWindowBits===!1||typeof this._options.clientMaxWindowBits=="number"&&s.client_max_window_bits>this._options.clientMaxWindowBits)throw new Error('Unexpected or invalid parameter "client_max_window_bits"');return s}normalizeParams(e){return e.forEach(s=>{Object.keys(s).forEach(o=>{let c=s[o];if(c.length>1)throw new Error(`Parameter "${o}" must have only a single value`);if(c=c[0],o==="client_max_window_bits"){if(c!==!0){let x=+c;if(!Number.isInteger(x)||x<8||x>15)throw new TypeError(`Invalid value for parameter "${o}": ${c}`);c=x}else if(!this._isServer)throw new TypeError(`Invalid value for parameter "${o}": ${c}`)}else if(o==="server_max_window_bits"){let x=+c;if(!Number.isInteger(x)||x<8||x>15)throw new TypeError(`Invalid value for parameter "${o}": ${c}`);c=x}else if(o==="client_no_context_takeover"||o==="server_no_context_takeover"){if(c!==!0)throw new TypeError(`Invalid value for parameter "${o}": ${c}`)}else throw new Error(`Unknown parameter "${o}"`);s[o]=c})}),e}decompress(e,s,o){Zn.add(c=>{this._decompress(e,s,(x,u)=>{c(),o(x,u)})})}compress(e,s,o){Zn.add(c=>{this._compress(e,s,(x,u)=>{c(),o(x,u)})})}_decompress(e,s,o){let c=this._isServer?"client":"server";if(!this._inflate){let x=`${c}_max_window_bits`,u=typeof this.params[x]!="number"?rn.Z_DEFAULT_WINDOWBITS:this.params[x];this._inflate=rn.createInflateRaw({...this._options.zlibInflateOptions,windowBits:u}),this._inflate[er]=this,this._inflate[We]=0,this._inflate[rt]=[],this._inflate.on("error",su),this._inflate.on("data",jo)}this._inflate[Tt]=o,this._inflate.write(e),s&&this._inflate.write(ru),this._inflate.flush(()=>{let x=this._inflate[Dt];if(x){this._inflate.close(),this._inflate=null,o(x);return}let u=Ho.concat(this._inflate[rt],this._inflate[We]);this._inflate._readableState.endEmitted?(this._inflate.close(),this._inflate=null):(this._inflate[We]=0,this._inflate[rt]=[],s&&this.params[`${c}_no_context_takeover`]&&this._inflate.reset()),o(null,u)})}_compress(e,s,o){let c=this._isServer?"server":"client";if(!this._deflate){let x=`${c}_max_window_bits`,u=typeof this.params[x]!="number"?rn.Z_DEFAULT_WINDOWBITS:this.params[x];this._deflate=rn.createDeflateRaw({...this._options.zlibDeflateOptions,windowBits:u}),this._deflate[We]=0,this._deflate[rt]=[],this._deflate.on("data",iu)}this._deflate[Tt]=o,this._deflate.write(e),this._deflate.flush(rn.Z_SYNC_FLUSH,()=>{if(!this._deflate)return;let x=Ho.concat(this._deflate[rt],this._deflate[We]);s&&(x=new nu(x.buffer,x.byteOffset,x.length-4)),this._deflate[Tt]=null,this._deflate[We]=0,this._deflate[rt]=[],s&&this.params[`${c}_no_context_takeover`]&&this._deflate.reset(),o(null,x)})}};Go.exports=ni;function iu(n){this[rt].push(n),this[We]+=n.length}function jo(n){if(this[We]+=n.length,this[er]._maxPayload<1||this[We]<=this[er]._maxPayload){this[rt].push(n);return}this[Dt]=new RangeError("Max payload size exceeded"),this[Dt].code="WS_ERR_UNSUPPORTED_MESSAGE_LENGTH",this[Dt][Ko]=1009,this.removeListener("data",jo),this.reset()}function su(n){if(this[er]._inflate=null,this[Dt]){this[Tt](this[Dt]);return}n[Ko]=1007,this[Tt](n)}});var Lt=le((hm,tr)=>{"use strict";var{isUtf8:Wo}=$("buffer"),{hasBlob:ou}=Ge(),au=[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 cu(n){return n>=1e3&&n<=1014&&n!==1004&&n!==1005&&n!==1006||n>=3e3&&n<=4999}function ri(n){let e=n.length,s=0;for(;s<e;)if((n[s]&128)===0)s++;else if((n[s]&224)===192){if(s+1===e||(n[s+1]&192)!==128||(n[s]&254)===192)return!1;s+=2}else if((n[s]&240)===224){if(s+2>=e||(n[s+1]&192)!==128||(n[s+2]&192)!==128||n[s]===224&&(n[s+1]&224)===128||n[s]===237&&(n[s+1]&224)===160)return!1;s+=3}else if((n[s]&248)===240){if(s+3>=e||(n[s+1]&192)!==128||(n[s+2]&192)!==128||(n[s+3]&192)!==128||n[s]===240&&(n[s+1]&240)===128||n[s]===244&&n[s+1]>143||n[s]>244)return!1;s+=4}else return!1;return!0}function xu(n){return ou&&typeof n=="object"&&typeof n.arrayBuffer=="function"&&typeof n.type=="string"&&typeof n.stream=="function"&&(n[Symbol.toStringTag]==="Blob"||n[Symbol.toStringTag]==="File")}tr.exports={isBlob:xu,isValidStatusCode:cu,isValidUTF8:ri,tokenChars:au};if(Wo)tr.exports.isValidUTF8=function(n){return n.length<24?ri(n):Wo(n)};else if(!process.env.WS_NO_UTF_8_VALIDATE)try{let n=$("utf-8-validate");tr.exports.isValidUTF8=function(e){return e.length<32?ri(e):n(e)}}catch{}});var ci=le((gm,Zo)=>{"use strict";var{Writable:du}=$("stream"),Jo=Rt(),{BINARY_TYPES:uu,EMPTY_BUFFER:Vo,kStatusCode:fu,kWebSocket:lu}=Ge(),{concat:ii,toArrayBuffer:hu,unmask:gu}=nn(),{isValidStatusCode:pu,isValidUTF8:$o}=Lt(),nr=Buffer[Symbol.species],Ee=0,Yo=1,Xo=2,Qo=3,si=4,oi=5,rr=6,ai=class extends du{constructor(e={}){super(),this._allowSynchronousEvents=e.allowSynchronousEvents!==void 0?e.allowSynchronousEvents:!0,this._binaryType=e.binaryType||uu[0],this._extensions=e.extensions||{},this._isServer=!!e.isServer,this._maxPayload=e.maxPayload|0,this._skipUTF8Validation=!!e.skipUTF8Validation,this[lu]=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=Ee}_write(e,s,o){if(this._opcode===8&&this._state==Ee)return o();this._bufferedBytes+=e.length,this._buffers.push(e),this.startLoop(o)}consume(e){if(this._bufferedBytes-=e,e===this._buffers[0].length)return this._buffers.shift();if(e<this._buffers[0].length){let o=this._buffers[0];return this._buffers[0]=new nr(o.buffer,o.byteOffset+e,o.length-e),new nr(o.buffer,o.byteOffset,e)}let s=Buffer.allocUnsafe(e);do{let o=this._buffers[0],c=s.length-e;e>=o.length?s.set(this._buffers.shift(),c):(s.set(new Uint8Array(o.buffer,o.byteOffset,e),c),this._buffers[0]=new nr(o.buffer,o.byteOffset+e,o.length-e)),e-=o.length}while(e>0);return s}startLoop(e){this._loop=!0;do switch(this._state){case Ee:this.getInfo(e);break;case Yo:this.getPayloadLength16(e);break;case Xo:this.getPayloadLength64(e);break;case Qo:this.getMask();break;case si:this.getData(e);break;case oi:case rr:this._loop=!1;return}while(this._loop);this._errored||e()}getInfo(e){if(this._bufferedBytes<2){this._loop=!1;return}let s=this.consume(2);if((s[0]&48)!==0){let c=this.createError(RangeError,"RSV2 and RSV3 must be clear",!0,1002,"WS_ERR_UNEXPECTED_RSV_2_3");e(c);return}let o=(s[0]&64)===64;if(o&&!this._extensions[Jo.extensionName]){let c=this.createError(RangeError,"RSV1 must be clear",!0,1002,"WS_ERR_UNEXPECTED_RSV_1");e(c);return}if(this._fin=(s[0]&128)===128,this._opcode=s[0]&15,this._payloadLength=s[1]&127,this._opcode===0){if(o){let c=this.createError(RangeError,"RSV1 must be clear",!0,1002,"WS_ERR_UNEXPECTED_RSV_1");e(c);return}if(!this._fragmented){let c=this.createError(RangeError,"invalid opcode 0",!0,1002,"WS_ERR_INVALID_OPCODE");e(c);return}this._opcode=this._fragmented}else if(this._opcode===1||this._opcode===2){if(this._fragmented){let c=this.createError(RangeError,`invalid opcode ${this._opcode}`,!0,1002,"WS_ERR_INVALID_OPCODE");e(c);return}this._compressed=o}else if(this._opcode>7&&this._opcode<11){if(!this._fin){let c=this.createError(RangeError,"FIN must be set",!0,1002,"WS_ERR_EXPECTED_FIN");e(c);return}if(o){let c=this.createError(RangeError,"RSV1 must be clear",!0,1002,"WS_ERR_UNEXPECTED_RSV_1");e(c);return}if(this._payloadLength>125||this._opcode===8&&this._payloadLength===1){let c=this.createError(RangeError,`invalid payload length ${this._payloadLength}`,!0,1002,"WS_ERR_INVALID_CONTROL_PAYLOAD_LENGTH");e(c);return}}else{let c=this.createError(RangeError,`invalid opcode ${this._opcode}`,!0,1002,"WS_ERR_INVALID_OPCODE");e(c);return}if(!this._fin&&!this._fragmented&&(this._fragmented=this._opcode),this._masked=(s[1]&128)===128,this._isServer){if(!this._masked){let c=this.createError(RangeError,"MASK must be set",!0,1002,"WS_ERR_EXPECTED_MASK");e(c);return}}else if(this._masked){let c=this.createError(RangeError,"MASK must be clear",!0,1002,"WS_ERR_UNEXPECTED_MASK");e(c);return}this._payloadLength===126?this._state=Yo:this._payloadLength===127?this._state=Xo: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 s=this.consume(8),o=s.readUInt32BE(0);if(o>Math.pow(2,21)-1){let c=this.createError(RangeError,"Unsupported WebSocket frame: payload length > 2^53 - 1",!1,1009,"WS_ERR_UNSUPPORTED_DATA_PAYLOAD_LENGTH");e(c);return}this._payloadLength=o*Math.pow(2,32)+s.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 s=this.createError(RangeError,"Max payload size exceeded",!1,1009,"WS_ERR_UNSUPPORTED_MESSAGE_LENGTH");e(s);return}this._masked?this._state=Qo:this._state=si}getMask(){if(this._bufferedBytes<4){this._loop=!1;return}this._mask=this.consume(4),this._state=si}getData(e){let s=Vo;if(this._payloadLength){if(this._bufferedBytes<this._payloadLength){this._loop=!1;return}s=this.consume(this._payloadLength),this._masked&&(this._mask[0]|this._mask[1]|this._mask[2]|this._mask[3])!==0&&gu(s,this._mask)}if(this._opcode>7){this.controlMessage(s,e);return}if(this._compressed){this._state=oi,this.decompress(s,e);return}s.length&&(this._messageLength=this._totalPayloadLength,this._fragments.push(s)),this.dataMessage(e)}decompress(e,s){this._extensions[Jo.extensionName].decompress(e,this._fin,(c,x)=>{if(c)return s(c);if(x.length){if(this._messageLength+=x.length,this._messageLength>this._maxPayload&&this._maxPayload>0){let u=this.createError(RangeError,"Max payload size exceeded",!1,1009,"WS_ERR_UNSUPPORTED_MESSAGE_LENGTH");s(u);return}this._fragments.push(x)}this.dataMessage(s),this._state===Ee&&this.startLoop(s)})}dataMessage(e){if(!this._fin){this._state=Ee;return}let s=this._messageLength,o=this._fragments;if(this._totalPayloadLength=0,this._messageLength=0,this._fragmented=0,this._fragments=[],this._opcode===2){let c;this._binaryType==="nodebuffer"?c=ii(o,s):this._binaryType==="arraybuffer"?c=hu(ii(o,s)):this._binaryType==="blob"?c=new Blob(o):c=o,this._allowSynchronousEvents?(this.emit("message",c,!0),this._state=Ee):(this._state=rr,setImmediate(()=>{this.emit("message",c,!0),this._state=Ee,this.startLoop(e)}))}else{let c=ii(o,s);if(!this._skipUTF8Validation&&!$o(c)){let x=this.createError(Error,"invalid UTF-8 sequence",!0,1007,"WS_ERR_INVALID_UTF8");e(x);return}this._state===oi||this._allowSynchronousEvents?(this.emit("message",c,!1),this._state=Ee):(this._state=rr,setImmediate(()=>{this.emit("message",c,!1),this._state=Ee,this.startLoop(e)}))}}controlMessage(e,s){if(this._opcode===8){if(e.length===0)this._loop=!1,this.emit("conclude",1005,Vo),this.end();else{let o=e.readUInt16BE(0);if(!pu(o)){let x=this.createError(RangeError,`invalid status code ${o}`,!0,1002,"WS_ERR_INVALID_CLOSE_CODE");s(x);return}let c=new nr(e.buffer,e.byteOffset+2,e.length-2);if(!this._skipUTF8Validation&&!$o(c)){let x=this.createError(Error,"invalid UTF-8 sequence",!0,1007,"WS_ERR_INVALID_UTF8");s(x);return}this._loop=!1,this.emit("conclude",o,c),this.end()}this._state=Ee;return}this._allowSynchronousEvents?(this.emit(this._opcode===9?"ping":"pong",e),this._state=Ee):(this._state=rr,setImmediate(()=>{this.emit(this._opcode===9?"ping":"pong",e),this._state=Ee,this.startLoop(s)}))}createError(e,s,o,c,x){this._loop=!1,this._errored=!0;let u=new e(o?`Invalid WebSocket frame: ${s}`:s);return Error.captureStackTrace(u,this.createError),u.code=x,u[fu]=c,u}};Zo.exports=ai});var ui=le((mm,na)=>{"use strict";var{Duplex:pm}=$("stream"),{randomFillSync:mu}=$("crypto"),ea=Rt(),{EMPTY_BUFFER:wu,kWebSocket:_u,NOOP:yu}=Ge(),{isBlob:Ot,isValidStatusCode:vu}=Lt(),{mask:ta,toBuffer:xt}=nn(),Ce=Symbol("kByteLength"),bu=Buffer.alloc(4),ir=8*1024,dt,Nt=ir,ke=0,Su=1,Eu=2,xi=class n{constructor(e,s,o){this._extensions=s||{},o&&(this._generateMask=o,this._maskBuffer=Buffer.alloc(4)),this._socket=e,this._firstFragment=!0,this._compress=!1,this._bufferedBytes=0,this._queue=[],this._state=ke,this.onerror=yu,this[_u]=void 0}static frame(e,s){let o,c=!1,x=2,u=!1;s.mask&&(o=s.maskBuffer||bu,s.generateMask?s.generateMask(o):(Nt===ir&&(dt===void 0&&(dt=Buffer.alloc(ir)),mu(dt,0,ir),Nt=0),o[0]=dt[Nt++],o[1]=dt[Nt++],o[2]=dt[Nt++],o[3]=dt[Nt++]),u=(o[0]|o[1]|o[2]|o[3])===0,x=6);let l;typeof e=="string"?(!s.mask||u)&&s[Ce]!==void 0?l=s[Ce]:(e=Buffer.from(e),l=e.length):(l=e.length,c=s.mask&&s.readOnly&&!u);let m=l;l>=65536?(x+=8,m=127):l>125&&(x+=2,m=126);let w=Buffer.allocUnsafe(c?l+x:x);return w[0]=s.fin?s.opcode|128:s.opcode,s.rsv1&&(w[0]|=64),w[1]=m,m===126?w.writeUInt16BE(l,2):m===127&&(w[2]=w[3]=0,w.writeUIntBE(l,4,6)),s.mask?(w[1]|=128,w[x-4]=o[0],w[x-3]=o[1],w[x-2]=o[2],w[x-1]=o[3],u?[w,e]:c?(ta(e,o,w,x,l),[w]):(ta(e,o,e,0,l),[w,e])):[w,e]}close(e,s,o,c){let x;if(e===void 0)x=wu;else{if(typeof e!="number"||!vu(e))throw new TypeError("First argument must be a valid error code number");if(s===void 0||!s.length)x=Buffer.allocUnsafe(2),x.writeUInt16BE(e,0);else{let l=Buffer.byteLength(s);if(l>123)throw new RangeError("The message must not be greater than 123 bytes");x=Buffer.allocUnsafe(2+l),x.writeUInt16BE(e,0),typeof s=="string"?x.write(s,2):x.set(s,2)}}let u={[Ce]:x.length,fin:!0,generateMask:this._generateMask,mask:o,maskBuffer:this._maskBuffer,opcode:8,readOnly:!1,rsv1:!1};this._state!==ke?this.enqueue([this.dispatch,x,!1,u,c]):this.sendFrame(n.frame(x,u),c)}ping(e,s,o){let c,x;if(typeof e=="string"?(c=Buffer.byteLength(e),x=!1):Ot(e)?(c=e.size,x=!1):(e=xt(e),c=e.length,x=xt.readOnly),c>125)throw new RangeError("The data size must not be greater than 125 bytes");let u={[Ce]:c,fin:!0,generateMask:this._generateMask,mask:s,maskBuffer:this._maskBuffer,opcode:9,readOnly:x,rsv1:!1};Ot(e)?this._state!==ke?this.enqueue([this.getBlobData,e,!1,u,o]):this.getBlobData(e,!1,u,o):this._state!==ke?this.enqueue([this.dispatch,e,!1,u,o]):this.sendFrame(n.frame(e,u),o)}pong(e,s,o){let c,x;if(typeof e=="string"?(c=Buffer.byteLength(e),x=!1):Ot(e)?(c=e.size,x=!1):(e=xt(e),c=e.length,x=xt.readOnly),c>125)throw new RangeError("The data size must not be greater than 125 bytes");let u={[Ce]:c,fin:!0,generateMask:this._generateMask,mask:s,maskBuffer:this._maskBuffer,opcode:10,readOnly:x,rsv1:!1};Ot(e)?this._state!==ke?this.enqueue([this.getBlobData,e,!1,u,o]):this.getBlobData(e,!1,u,o):this._state!==ke?this.enqueue([this.dispatch,e,!1,u,o]):this.sendFrame(n.frame(e,u),o)}send(e,s,o){let c=this._extensions[ea.extensionName],x=s.binary?2:1,u=s.compress,l,m;typeof e=="string"?(l=Buffer.byteLength(e),m=!1):Ot(e)?(l=e.size,m=!1):(e=xt(e),l=e.length,m=xt.readOnly),this._firstFragment?(this._firstFragment=!1,u&&c&&c.params[c._isServer?"server_no_context_takeover":"client_no_context_takeover"]&&(u=l>=c._threshold),this._compress=u):(u=!1,x=0),s.fin&&(this._firstFragment=!0);let w={[Ce]:l,fin:s.fin,generateMask:this._generateMask,mask:s.mask,maskBuffer:this._maskBuffer,opcode:x,readOnly:m,rsv1:u};Ot(e)?this._state!==ke?this.enqueue([this.getBlobData,e,this._compress,w,o]):this.getBlobData(e,this._compress,w,o):this._state!==ke?this.enqueue([this.dispatch,e,this._compress,w,o]):this.dispatch(e,this._compress,w,o)}getBlobData(e,s,o,c){this._bufferedBytes+=o[Ce],this._state=Eu,e.arrayBuffer().then(x=>{if(this._socket.destroyed){let l=new Error("The socket was closed while the blob was being read");process.nextTick(di,this,l,c);return}this._bufferedBytes-=o[Ce];let u=xt(x);s?this.dispatch(u,s,o,c):(this._state=ke,this.sendFrame(n.frame(u,o),c),this.dequeue())}).catch(x=>{process.nextTick(Cu,this,x,c)})}dispatch(e,s,o,c){if(!s){this.sendFrame(n.frame(e,o),c);return}let x=this._extensions[ea.extensionName];this._bufferedBytes+=o[Ce],this._state=Su,x.compress(e,o.fin,(u,l)=>{if(this._socket.destroyed){let m=new Error("The socket was closed while data was being compressed");di(this,m,c);return}this._bufferedBytes-=o[Ce],this._state=ke,o.readOnly=!1,this.sendFrame(n.frame(l,o),c),this.dequeue()})}dequeue(){for(;this._state===ke&&this._queue.length;){let e=this._queue.shift();this._bufferedBytes-=e[3][Ce],Reflect.apply(e[0],this,e.slice(1))}}enqueue(e){this._bufferedBytes+=e[3][Ce],this._queue.push(e)}sendFrame(e,s){e.length===2?(this._socket.cork(),this._socket.write(e[0]),this._socket.write(e[1],s),this._socket.uncork()):this._socket.write(e[0],s)}};na.exports=xi;function di(n,e,s){typeof s=="function"&&s(e);for(let o=0;o<n._queue.length;o++){let c=n._queue[o],x=c[c.length-1];typeof x=="function"&&x(e)}}function Cu(n,e,s){di(n,e,s),n.onerror(e)}});var ua=le((wm,da)=>{"use strict";var{kForOnEventAttribute:sn,kListener:fi}=Ge(),ra=Symbol("kCode"),ia=Symbol("kData"),sa=Symbol("kError"),oa=Symbol("kMessage"),aa=Symbol("kReason"),Bt=Symbol("kTarget"),ca=Symbol("kType"),xa=Symbol("kWasClean"),Je=class{constructor(e){this[Bt]=null,this[ca]=e}get target(){return this[Bt]}get type(){return this[ca]}};Object.defineProperty(Je.prototype,"target",{enumerable:!0});Object.defineProperty(Je.prototype,"type",{enumerable:!0});var ut=class extends Je{constructor(e,s={}){super(e),this[ra]=s.code===void 0?0:s.code,this[aa]=s.reason===void 0?"":s.reason,this[xa]=s.wasClean===void 0?!1:s.wasClean}get code(){return this[ra]}get reason(){return this[aa]}get wasClean(){return this[xa]}};Object.defineProperty(ut.prototype,"code",{enumerable:!0});Object.defineProperty(ut.prototype,"reason",{enumerable:!0});Object.defineProperty(ut.prototype,"wasClean",{enumerable:!0});var Mt=class extends Je{constructor(e,s={}){super(e),this[sa]=s.error===void 0?null:s.error,this[oa]=s.message===void 0?"":s.message}get error(){return this[sa]}get message(){return this[oa]}};Object.defineProperty(Mt.prototype,"error",{enumerable:!0});Object.defineProperty(Mt.prototype,"message",{enumerable:!0});var on=class extends Je{constructor(e,s={}){super(e),this[ia]=s.data===void 0?null:s.data}get data(){return this[ia]}};Object.defineProperty(on.prototype,"data",{enumerable:!0});var Iu={addEventListener(n,e,s={}){for(let c of this.listeners(n))if(!s[sn]&&c[fi]===e&&!c[sn])return;let o;if(n==="message")o=function(x,u){let l=new on("message",{data:u?x:x.toString()});l[Bt]=this,sr(e,this,l)};else if(n==="close")o=function(x,u){let l=new ut("close",{code:x,reason:u.toString(),wasClean:this._closeFrameReceived&&this._closeFrameSent});l[Bt]=this,sr(e,this,l)};else if(n==="error")o=function(x){let u=new Mt("error",{error:x,message:x.message});u[Bt]=this,sr(e,this,u)};else if(n==="open")o=function(){let x=new Je("open");x[Bt]=this,sr(e,this,x)};else return;o[sn]=!!s[sn],o[fi]=e,s.once?this.once(n,o):this.on(n,o)},removeEventListener(n,e){for(let s of this.listeners(n))if(s[fi]===e&&!s[sn]){this.removeListener(n,s);break}}};da.exports={CloseEvent:ut,ErrorEvent:Mt,Event:Je,EventTarget:Iu,MessageEvent:on};function sr(n,e,s){typeof n=="object"&&n.handleEvent?n.handleEvent.call(n,s):n.call(e,s)}});var or=le((_m,fa)=>{"use strict";var{tokenChars:an}=Lt();function ze(n,e,s){n[e]===void 0?n[e]=[s]:n[e].push(s)}function Au(n){let e=Object.create(null),s=Object.create(null),o=!1,c=!1,x=!1,u,l,m=-1,w=-1,v=-1,y=0;for(;y<n.length;y++)if(w=n.charCodeAt(y),u===void 0)if(v===-1&&an[w]===1)m===-1&&(m=y);else if(y!==0&&(w===32||w===9))v===-1&&m!==-1&&(v=y);else if(w===59||w===44){if(m===-1)throw new SyntaxError(`Unexpected character at index ${y}`);v===-1&&(v=y);let k=n.slice(m,v);w===44?(ze(e,k,s),s=Object.create(null)):u=k,m=v=-1}else throw new SyntaxError(`Unexpected character at index ${y}`);else if(l===void 0)if(v===-1&&an[w]===1)m===-1&&(m=y);else if(w===32||w===9)v===-1&&m!==-1&&(v=y);else if(w===59||w===44){if(m===-1)throw new SyntaxError(`Unexpected character at index ${y}`);v===-1&&(v=y),ze(s,n.slice(m,v),!0),w===44&&(ze(e,u,s),s=Object.create(null),u=void 0),m=v=-1}else if(w===61&&m!==-1&&v===-1)l=n.slice(m,y),m=v=-1;else throw new SyntaxError(`Unexpected character at index ${y}`);else if(c){if(an[w]!==1)throw new SyntaxError(`Unexpected character at index ${y}`);m===-1?m=y:o||(o=!0),c=!1}else if(x)if(an[w]===1)m===-1&&(m=y);else if(w===34&&m!==-1)x=!1,v=y;else if(w===92)c=!0;else throw new SyntaxError(`Unexpected character at index ${y}`);else if(w===34&&n.charCodeAt(y-1)===61)x=!0;else if(v===-1&&an[w]===1)m===-1&&(m=y);else if(m!==-1&&(w===32||w===9))v===-1&&(v=y);else if(w===59||w===44){if(m===-1)throw new SyntaxError(`Unexpected character at index ${y}`);v===-1&&(v=y);let k=n.slice(m,v);o&&(k=k.replace(/\\/g,""),o=!1),ze(s,l,k),w===44&&(ze(e,u,s),s=Object.create(null),u=void 0),l=void 0,m=v=-1}else throw new SyntaxError(`Unexpected character at index ${y}`);if(m===-1||x||w===32||w===9)throw new SyntaxError("Unexpected end of input");v===-1&&(v=y);let E=n.slice(m,v);return u===void 0?ze(e,E,s):(l===void 0?ze(s,E,!0):o?ze(s,l,E.replace(/\\/g,"")):ze(s,l,E),ze(e,u,s)),e}function Pu(n){return Object.keys(n).map(e=>{let s=n[e];return Array.isArray(s)||(s=[s]),s.map(o=>[e].concat(Object.keys(o).map(c=>{let x=o[c];return Array.isArray(x)||(x=[x]),x.map(u=>u===!0?c:`${c}=${u}`).join("; ")})).join("; ")).join(", ")}).join(", ")}fa.exports={format:Pu,parse:Au}});var dr=le((bm,Ea)=>{"use strict";var ku=$("events"),Tu=$("https"),Du=$("http"),ga=$("net"),Ru=$("tls"),{randomBytes:Lu,createHash:Ou}=$("crypto"),{Duplex:ym,Readable:vm}=$("stream"),{URL:li}=$("url"),it=Rt(),Nu=ci(),Bu=ui(),{isBlob:Mu}=Lt(),{BINARY_TYPES:la,CLOSE_TIMEOUT:zu,EMPTY_BUFFER:ar,GUID:Fu,kForOnEventAttribute:hi,kListener:Uu,kStatusCode:qu,kWebSocket:ne,NOOP:pa}=Ge(),{EventTarget:{addEventListener:Hu,removeEventListener:Ku}}=ua(),{format:ju,parse:Gu}=or(),{toBuffer:Wu}=nn(),ma=Symbol("kAborted"),gi=[8,13],Ve=["CONNECTING","OPEN","CLOSING","CLOSED"],Ju=/^[!#$%&'*+\-.0-9A-Z^_`|a-z~]+$/,W=class n extends ku{constructor(e,s,o){super(),this._binaryType=la[0],this._closeCode=1006,this._closeFrameReceived=!1,this._closeFrameSent=!1,this._closeMessage=ar,this._closeTimer=null,this._errorEmitted=!1,this._extensions={},this._paused=!1,this._protocol="",this._readyState=n.CONNECTING,this._receiver=null,this._sender=null,this._socket=null,e!==null?(this._bufferedAmount=0,this._isServer=!1,this._redirects=0,s===void 0?s=[]:Array.isArray(s)||(typeof s=="object"&&s!==null?(o=s,s=[]):s=[s]),wa(this,e,s,o)):(this._autoPong=o.autoPong,this._closeTimeout=o.closeTimeout,this._isServer=!0)}get binaryType(){return this._binaryType}set binaryType(e){la.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,s,o){let c=new Nu({allowSynchronousEvents:o.allowSynchronousEvents,binaryType:this.binaryType,extensions:this._extensions,isServer:this._isServer,maxPayload:o.maxPayload,skipUTF8Validation:o.skipUTF8Validation}),x=new Bu(e,this._extensions,o.generateMask);this._receiver=c,this._sender=x,this._socket=e,c[ne]=this,x[ne]=this,e[ne]=this,c.on("conclude",Yu),c.on("drain",Xu),c.on("error",Qu),c.on("message",Zu),c.on("ping",ef),c.on("pong",tf),x.onerror=nf,e.setTimeout&&e.setTimeout(0),e.setNoDelay&&e.setNoDelay(),s.length>0&&e.unshift(s),e.on("close",va),e.on("data",xr),e.on("end",ba),e.on("error",Sa),this._readyState=n.OPEN,this.emit("open")}emitClose(){if(!this._socket){this._readyState=n.CLOSED,this.emit("close",this._closeCode,this._closeMessage);return}this._extensions[it.extensionName]&&this._extensions[it.extensionName].cleanup(),this._receiver.removeAllListeners(),this._readyState=n.CLOSED,this.emit("close",this._closeCode,this._closeMessage)}close(e,s){if(this.readyState!==n.CLOSED){if(this.readyState===n.CONNECTING){me(this,this._req,"WebSocket was closed before the connection was established");return}if(this.readyState===n.CLOSING){this._closeFrameSent&&(this._closeFrameReceived||this._receiver._writableState.errorEmitted)&&this._socket.end();return}this._readyState=n.CLOSING,this._sender.close(e,s,!this._isServer,o=>{o||(this._closeFrameSent=!0,(this._closeFrameReceived||this._receiver._writableState.errorEmitted)&&this._socket.end())}),ya(this)}}pause(){this.readyState===n.CONNECTING||this.readyState===n.CLOSED||(this._paused=!0,this._socket.pause())}ping(e,s,o){if(this.readyState===n.CONNECTING)throw new Error("WebSocket is not open: readyState 0 (CONNECTING)");if(typeof e=="function"?(o=e,e=s=void 0):typeof s=="function"&&(o=s,s=void 0),typeof e=="number"&&(e=e.toString()),this.readyState!==n.OPEN){pi(this,e,o);return}s===void 0&&(s=!this._isServer),this._sender.ping(e||ar,s,o)}pong(e,s,o){if(this.readyState===n.CONNECTING)throw new Error("WebSocket is not open: readyState 0 (CONNECTING)");if(typeof e=="function"?(o=e,e=s=void 0):typeof s=="function"&&(o=s,s=void 0),typeof e=="number"&&(e=e.toString()),this.readyState!==n.OPEN){pi(this,e,o);return}s===void 0&&(s=!this._isServer),this._sender.pong(e||ar,s,o)}resume(){this.readyState===n.CONNECTING||this.readyState===n.CLOSED||(this._paused=!1,this._receiver._writableState.needDrain||this._socket.resume())}send(e,s,o){if(this.readyState===n.CONNECTING)throw new Error("WebSocket is not open: readyState 0 (CONNECTING)");if(typeof s=="function"&&(o=s,s={}),typeof e=="number"&&(e=e.toString()),this.readyState!==n.OPEN){pi(this,e,o);return}let c={binary:typeof e!="string",mask:!this._isServer,compress:!0,fin:!0,...s};this._extensions[it.extensionName]||(c.compress=!1),this._sender.send(e||ar,c,o)}terminate(){if(this.readyState!==n.CLOSED){if(this.readyState===n.CONNECTING){me(this,this._req,"WebSocket was closed before the connection was established");return}this._socket&&(this._readyState=n.CLOSING,this._socket.destroy())}}};Object.defineProperty(W,"CONNECTING",{enumerable:!0,value:Ve.indexOf("CONNECTING")});Object.defineProperty(W.prototype,"CONNECTING",{enumerable:!0,value:Ve.indexOf("CONNECTING")});Object.defineProperty(W,"OPEN",{enumerable:!0,value:Ve.indexOf("OPEN")});Object.defineProperty(W.prototype,"OPEN",{enumerable:!0,value:Ve.indexOf("OPEN")});Object.defineProperty(W,"CLOSING",{enumerable:!0,value:Ve.indexOf("CLOSING")});Object.defineProperty(W.prototype,"CLOSING",{enumerable:!0,value:Ve.indexOf("CLOSING")});Object.defineProperty(W,"CLOSED",{enumerable:!0,value:Ve.indexOf("CLOSED")});Object.defineProperty(W.prototype,"CLOSED",{enumerable:!0,value:Ve.indexOf("CLOSED")});["binaryType","bufferedAmount","extensions","isPaused","protocol","readyState","url"].forEach(n=>{Object.defineProperty(W.prototype,n,{enumerable:!0})});["open","error","close","message"].forEach(n=>{Object.defineProperty(W.prototype,`on${n}`,{enumerable:!0,get(){for(let e of this.listeners(n))if(e[hi])return e[Uu];return null},set(e){for(let s of this.listeners(n))if(s[hi]){this.removeListener(n,s);break}typeof e=="function"&&this.addEventListener(n,e,{[hi]:!0})}})});W.prototype.addEventListener=Hu;W.prototype.removeEventListener=Ku;Ea.exports=W;function wa(n,e,s,o){let c={allowSynchronousEvents:!0,autoPong:!0,closeTimeout:zu,protocolVersion:gi[1],maxPayload:104857600,skipUTF8Validation:!1,perMessageDeflate:!0,followRedirects:!1,maxRedirects:10,...o,socketPath:void 0,hostname:void 0,protocol:void 0,timeout:void 0,method:"GET",host:void 0,path:void 0,port:void 0};if(n._autoPong=c.autoPong,n._closeTimeout=c.closeTimeout,!gi.includes(c.protocolVersion))throw new RangeError(`Unsupported protocol version: ${c.protocolVersion} (supported versions: ${gi.join(", ")})`);let x;if(e instanceof li)x=e;else try{x=new li(e)}catch{throw new SyntaxError(`Invalid URL: ${e}`)}x.protocol==="http:"?x.protocol="ws:":x.protocol==="https:"&&(x.protocol="wss:"),n._url=x.href;let u=x.protocol==="wss:",l=x.protocol==="ws+unix:",m;if(x.protocol!=="ws:"&&!u&&!l?m=`The URL's protocol must be one of "ws:", "wss:", "http:", "https:", or "ws+unix:"`:l&&!x.pathname?m="The URL's pathname is empty":x.hash&&(m="The URL contains a fragment identifier"),m){let T=new SyntaxError(m);if(n._redirects===0)throw T;cr(n,T);return}let w=u?443:80,v=Lu(16).toString("base64"),y=u?Tu.request:Du.request,E=new Set,k;if(c.createConnection=c.createConnection||(u?$u:Vu),c.defaultPort=c.defaultPort||w,c.port=x.port||w,c.host=x.hostname.startsWith("[")?x.hostname.slice(1,-1):x.hostname,c.headers={...c.headers,"Sec-WebSocket-Version":c.protocolVersion,"Sec-WebSocket-Key":v,Connection:"Upgrade",Upgrade:"websocket"},c.path=x.pathname+x.search,c.timeout=c.handshakeTimeout,c.perMessageDeflate&&(k=new it({...c.perMessageDeflate,isServer:!1,maxPayload:c.maxPayload}),c.headers["Sec-WebSocket-Extensions"]=ju({[it.extensionName]:k.offer()})),s.length){for(let T of s){if(typeof T!="string"||!Ju.test(T)||E.has(T))throw new SyntaxError("An invalid or duplicated subprotocol was specified");E.add(T)}c.headers["Sec-WebSocket-Protocol"]=s.join(",")}if(c.origin&&(c.protocolVersion<13?c.headers["Sec-WebSocket-Origin"]=c.origin:c.headers.Origin=c.origin),(x.username||x.password)&&(c.auth=`${x.username}:${x.password}`),l){let T=c.path.split(":");c.socketPath=T[0],c.path=T[1]}let P;if(c.followRedirects){if(n._redirects===0){n._originalIpc=l,n._originalSecure=u,n._originalHostOrSocketPath=l?c.socketPath:x.host;let T=o&&o.headers;if(o={...o,headers:{}},T)for(let[F,re]of Object.entries(T))o.headers[F.toLowerCase()]=re}else if(n.listenerCount("redirect")===0){let T=l?n._originalIpc?c.socketPath===n._originalHostOrSocketPath:!1:n._originalIpc?!1:x.host===n._originalHostOrSocketPath;(!T||n._originalSecure&&!u)&&(delete c.headers.authorization,delete c.headers.cookie,T||delete c.headers.host,c.auth=void 0)}c.auth&&!o.headers.authorization&&(o.headers.authorization="Basic "+Buffer.from(c.auth).toString("base64")),P=n._req=y(c),n._redirects&&n.emit("redirect",n.url,P)}else P=n._req=y(c);c.timeout&&P.on("timeout",()=>{me(n,P,"Opening handshake has timed out")}),P.on("error",T=>{P===null||P[ma]||(P=n._req=null,cr(n,T))}),P.on("response",T=>{let F=T.headers.location,re=T.statusCode;if(F&&c.followRedirects&&re>=300&&re<400){if(++n._redirects>c.maxRedirects){me(n,P,"Maximum redirects exceeded");return}P.abort();let J;try{J=new li(F,e)}catch{let ee=new SyntaxError(`Invalid URL: ${F}`);cr(n,ee);return}wa(n,J,s,o)}else n.emit("unexpected-response",P,T)||me(n,P,`Unexpected server response: ${T.statusCode}`)}),P.on("upgrade",(T,F,re)=>{if(n.emit("upgrade",T),n.readyState!==W.CONNECTING)return;P=n._req=null;let J=T.headers.upgrade;if(J===void 0||J.toLowerCase()!=="websocket"){me(n,F,"Invalid Upgrade header");return}let we=Ou("sha1").update(v+Fu).digest("base64");if(T.headers["sec-websocket-accept"]!==we){me(n,F,"Invalid Sec-WebSocket-Accept header");return}let ee=T.headers["sec-websocket-protocol"],oe;if(ee!==void 0?E.size?E.has(ee)||(oe="Server sent an invalid subprotocol"):oe="Server sent a subprotocol but none was requested":E.size&&(oe="Server sent no subprotocol"),oe){me(n,F,oe);return}ee&&(n._protocol=ee);let ae=T.headers["sec-websocket-extensions"];if(ae!==void 0){if(!k){me(n,F,"Server sent a Sec-WebSocket-Extensions header but no extension was requested");return}let A;try{A=Gu(ae)}catch{me(n,F,"Invalid Sec-WebSocket-Extensions header");return}let N=Object.keys(A);if(N.length!==1||N[0]!==it.extensionName){me(n,F,"Server indicated an extension that was not requested");return}try{k.accept(A[it.extensionName])}catch{me(n,F,"Invalid Sec-WebSocket-Extensions header");return}n._extensions[it.extensionName]=k}n.setSocket(F,re,{allowSynchronousEvents:c.allowSynchronousEvents,generateMask:c.generateMask,maxPayload:c.maxPayload,skipUTF8Validation:c.skipUTF8Validation})}),c.finishRequest?c.finishRequest(P,n):P.end()}function cr(n,e){n._readyState=W.CLOSING,n._errorEmitted=!0,n.emit("error",e),n.emitClose()}function Vu(n){return n.path=n.socketPath,ga.connect(n)}function $u(n){return n.path=void 0,!n.servername&&n.servername!==""&&(n.servername=ga.isIP(n.host)?"":n.host),Ru.connect(n)}function me(n,e,s){n._readyState=W.CLOSING;let o=new Error(s);Error.captureStackTrace(o,me),e.setHeader?(e[ma]=!0,e.abort(),e.socket&&!e.socket.destroyed&&e.socket.destroy(),process.nextTick(cr,n,o)):(e.destroy(o),e.once("error",n.emit.bind(n,"error")),e.once("close",n.emitClose.bind(n)))}function pi(n,e,s){if(e){let o=Mu(e)?e.size:Wu(e).length;n._socket?n._sender._bufferedBytes+=o:n._bufferedAmount+=o}if(s){let o=new Error(`WebSocket is not open: readyState ${n.readyState} (${Ve[n.readyState]})`);process.nextTick(s,o)}}function Yu(n,e){let s=this[ne];s._closeFrameReceived=!0,s._closeMessage=e,s._closeCode=n,s._socket[ne]!==void 0&&(s._socket.removeListener("data",xr),process.nextTick(_a,s._socket),n===1005?s.close():s.close(n,e))}function Xu(){let n=this[ne];n.isPaused||n._socket.resume()}function Qu(n){let e=this[ne];e._socket[ne]!==void 0&&(e._socket.removeListener("data",xr),process.nextTick(_a,e._socket),e.close(n[qu])),e._errorEmitted||(e._errorEmitted=!0,e.emit("error",n))}function ha(){this[ne].emitClose()}function Zu(n,e){this[ne].emit("message",n,e)}function ef(n){let e=this[ne];e._autoPong&&e.pong(n,!this._isServer,pa),e.emit("ping",n)}function tf(n){this[ne].emit("pong",n)}function _a(n){n.resume()}function nf(n){let e=this[ne];e.readyState!==W.CLOSED&&(e.readyState===W.OPEN&&(e._readyState=W.CLOSING,ya(e)),this._socket.end(),e._errorEmitted||(e._errorEmitted=!0,e.emit("error",n)))}function ya(n){n._closeTimer=setTimeout(n._socket.destroy.bind(n._socket),n._closeTimeout)}function va(){let n=this[ne];if(this.removeListener("close",va),this.removeListener("data",xr),this.removeListener("end",ba),n._readyState=W.CLOSING,!this._readableState.endEmitted&&!n._closeFrameReceived&&!n._receiver._writableState.errorEmitted&&this._readableState.length!==0){let e=this.read(this._readableState.length);n._receiver.write(e)}n._receiver.end(),this[ne]=void 0,clearTimeout(n._closeTimer),n._receiver._writableState.finished||n._receiver._writableState.errorEmitted?n.emitClose():(n._receiver.on("error",ha),n._receiver.on("finish",ha))}function xr(n){this[ne]._receiver.write(n)||this.pause()}function ba(){let n=this[ne];n._readyState=W.CLOSING,n._receiver.end(),this.end()}function Sa(){let n=this[ne];this.removeListener("error",Sa),this.on("error",pa),n&&(n._readyState=W.CLOSING,this.destroy())}});var Pa=le((Em,Aa)=>{"use strict";var Sm=dr(),{Duplex:rf}=$("stream");function Ca(n){n.emit("close")}function sf(){!this.destroyed&&this._writableState.finished&&this.destroy()}function Ia(n){this.removeListener("error",Ia),this.destroy(),this.listenerCount("error")===0&&this.emit("error",n)}function of(n,e){let s=!0,o=new rf({...e,autoDestroy:!1,emitClose:!1,objectMode:!1,writableObjectMode:!1});return n.on("message",function(x,u){let l=!u&&o._readableState.objectMode?x.toString():x;o.push(l)||n.pause()}),n.once("error",function(x){o.destroyed||(s=!1,o.destroy(x))}),n.once("close",function(){o.destroyed||o.push(null)}),o._destroy=function(c,x){if(n.readyState===n.CLOSED){x(c),process.nextTick(Ca,o);return}let u=!1;n.once("error",function(m){u=!0,x(m)}),n.once("close",function(){u||x(c),process.nextTick(Ca,o)}),s&&n.terminate()},o._final=function(c){if(n.readyState===n.CONNECTING){n.once("open",function(){o._final(c)});return}n._socket!==null&&(n._socket._writableState.finished?(c(),o._readableState.endEmitted&&o.destroy()):(n._socket.once("finish",function(){c()}),n.close()))},o._read=function(){n.isPaused&&n.resume()},o._write=function(c,x,u){if(n.readyState===n.CONNECTING){n.once("open",function(){o._write(c,x,u)});return}n.send(c,u)},o.on("end",sf),o.on("error",Ia),o}Aa.exports=of});var mi=le((Cm,ka)=>{"use strict";var{tokenChars:af}=Lt();function cf(n){let e=new Set,s=-1,o=-1,c=0;for(c;c<n.length;c++){let u=n.charCodeAt(c);if(o===-1&&af[u]===1)s===-1&&(s=c);else if(c!==0&&(u===32||u===9))o===-1&&s!==-1&&(o=c);else if(u===44){if(s===-1)throw new SyntaxError(`Unexpected character at index ${c}`);o===-1&&(o=c);let l=n.slice(s,o);if(e.has(l))throw new SyntaxError(`The "${l}" subprotocol is duplicated`);e.add(l),s=o=-1}else throw new SyntaxError(`Unexpected character at index ${c}`)}if(s===-1||o!==-1)throw new SyntaxError("Unexpected end of input");let x=n.slice(s,c);if(e.has(x))throw new SyntaxError(`The "${x}" subprotocol is duplicated`);return e.add(x),e}ka.exports={parse:cf}});var Ba=le((Am,Na)=>{"use strict";var xf=$("events"),ur=$("http"),{Duplex:Im}=$("stream"),{createHash:df}=$("crypto"),Ta=or(),ft=Rt(),uf=mi(),ff=dr(),{CLOSE_TIMEOUT:lf,GUID:hf,kWebSocket:gf}=Ge(),pf=/^[+/0-9A-Za-z]{22}==$/,Da=0,Ra=1,Oa=2,wi=class extends xf{constructor(e,s){if(super(),e={allowSynchronousEvents:!0,autoPong:!0,maxPayload:100*1024*1024,skipUTF8Validation:!1,perMessageDeflate:!1,handleProtocols:null,clientTracking:!0,closeTimeout:lf,verifyClient:null,noServer:!1,backlog:null,server:null,host:null,path:null,port:null,WebSocket:ff,...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=ur.createServer((o,c)=>{let x=ur.STATUS_CODES[426];c.writeHead(426,{"Content-Length":x.length,"Content-Type":"text/plain"}),c.end(x)}),this._server.listen(e.port,e.host,e.backlog,s)):e.server&&(this._server=e.server),this._server){let o=this.emit.bind(this,"connection");this._removeListeners=mf(this._server,{listening:this.emit.bind(this,"listening"),error:this.emit.bind(this,"error"),upgrade:(c,x,u)=>{this.handleUpgrade(c,x,u,o)}})}e.perMessageDeflate===!0&&(e.perMessageDeflate={}),e.clientTracking&&(this.clients=new Set,this._shouldEmitClose=!1),this.options=e,this._state=Da}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===Oa){e&&this.once("close",()=>{e(new Error("The server is not running"))}),process.nextTick(cn,this);return}if(e&&this.once("close",e),this._state!==Ra)if(this._state=Ra,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(cn,this):process.nextTick(cn,this);else{let s=this._server;this._removeListeners(),this._removeListeners=this._server=null,s.close(()=>{cn(this)})}}shouldHandle(e){if(this.options.path){let s=e.url.indexOf("?");if((s!==-1?e.url.slice(0,s):e.url)!==this.options.path)return!1}return!0}handleUpgrade(e,s,o,c){s.on("error",La);let x=e.headers["sec-websocket-key"],u=e.headers.upgrade,l=+e.headers["sec-websocket-version"];if(e.method!=="GET"){lt(this,e,s,405,"Invalid HTTP method");return}if(u===void 0||u.toLowerCase()!=="websocket"){lt(this,e,s,400,"Invalid Upgrade header");return}if(x===void 0||!pf.test(x)){lt(this,e,s,400,"Missing or invalid Sec-WebSocket-Key header");return}if(l!==13&&l!==8){lt(this,e,s,400,"Missing or invalid Sec-WebSocket-Version header",{"Sec-WebSocket-Version":"13, 8"});return}if(!this.shouldHandle(e)){xn(s,400);return}let m=e.headers["sec-websocket-protocol"],w=new Set;if(m!==void 0)try{w=uf.parse(m)}catch{lt(this,e,s,400,"Invalid Sec-WebSocket-Protocol header");return}let v=e.headers["sec-websocket-extensions"],y={};if(this.options.perMessageDeflate&&v!==void 0){let E=new ft({...this.options.perMessageDeflate,isServer:!0,maxPayload:this.options.maxPayload});try{let k=Ta.parse(v);k[ft.extensionName]&&(E.accept(k[ft.extensionName]),y[ft.extensionName]=E)}catch{lt(this,e,s,400,"Invalid or unacceptable Sec-WebSocket-Extensions header");return}}if(this.options.verifyClient){let E={origin:e.headers[`${l===8?"sec-websocket-origin":"origin"}`],secure:!!(e.socket.authorized||e.socket.encrypted),req:e};if(this.options.verifyClient.length===2){this.options.verifyClient(E,(k,P,T,F)=>{if(!k)return xn(s,P||401,T,F);this.completeUpgrade(y,x,w,e,s,o,c)});return}if(!this.options.verifyClient(E))return xn(s,401)}this.completeUpgrade(y,x,w,e,s,o,c)}completeUpgrade(e,s,o,c,x,u,l){if(!x.readable||!x.writable)return x.destroy();if(x[gf])throw new Error("server.handleUpgrade() was called more than once with the same socket, possibly due to a misconfiguration");if(this._state>Da)return xn(x,503);let w=["HTTP/1.1 101 Switching Protocols","Upgrade: websocket","Connection: Upgrade",`Sec-WebSocket-Accept: ${df("sha1").update(s+hf).digest("base64")}`],v=new this.options.WebSocket(null,void 0,this.options);if(o.size){let y=this.options.handleProtocols?this.options.handleProtocols(o,c):o.values().next().value;y&&(w.push(`Sec-WebSocket-Protocol: ${y}`),v._protocol=y)}if(e[ft.extensionName]){let y=e[ft.extensionName].params,E=Ta.format({[ft.extensionName]:[y]});w.push(`Sec-WebSocket-Extensions: ${E}`),v._extensions=e}this.emit("headers",w,c),x.write(w.concat(`\r
|
|
8
|
+
var D0=Object.create;var jr=Object.defineProperty;var R0=Object.getOwnPropertyDescriptor;var L0=Object.getOwnPropertyNames;var O0=Object.getPrototypeOf,N0=Object.prototype.hasOwnProperty;var ee=(n=>typeof require<"u"?require:typeof Proxy<"u"?new Proxy(n,{get:(e,s)=>(typeof require<"u"?require:e)[s]}):n)(function(n){if(typeof require<"u")return require.apply(this,arguments);throw Error('Dynamic require of "'+n+'" is not supported')});var Ae=(n,e)=>()=>(n&&(e=n(n=0)),e);var _e=(n,e)=>()=>(e||n((e={exports:{}}).exports,e),e.exports),Kr=(n,e)=>{for(var s in e)jr(n,s,{get:e[s],enumerable:!0})},M0=(n,e,s,o)=>{if(e&&typeof e=="object"||typeof e=="function")for(let c of L0(e))!N0.call(n,c)&&c!==s&&jr(n,c,{get:()=>e[c],enumerable:!(o=R0(e,c))||o.enumerable});return n};var Ke=(n,e,s)=>(s=n!=null?D0(O0(n)):{},M0(e||!n||!n.__esModule?jr(s,"default",{value:n,enumerable:!0}):s,n));function hs(n){return _n[ls]<=_n[n]}function yn(n){gs={...n}}function wn(n,e,s,o){if(_n[n]<_n[ls])return;let c=JSON.stringify({ts:new Date().toISOString(),level:n,module:e,msg:s,...gs,...o});n==="error"||n==="warn"?z0.write(`${c}
|
|
9
|
+
`):B0.write(`${c}
|
|
10
|
+
`)}function D(n){return{debug:(e,s)=>wn("debug",n,e,s),info:(e,s)=>wn("info",n,e,s),warn:(e,s)=>wn("warn",n,e,s),error:(e,s)=>wn("error",n,e,s),child:e=>D(`${n}.${e}`)}}var _n,ls,B0,z0,gs,U=Ae(()=>{"use strict";_n={debug:10,info:20,warn:30,error:40},ls=(()=>{let n=process.env.COZE_BRIDGE_LOG_LEVEL;return n==="debug"||n==="info"||n==="warn"||n==="error"?n:"info"})(),B0=process.stdout,z0=process.stderr,gs={}});import{chmod as X0,mkdir as Q0,readFile as Z0,rename as ys,writeFile as bs}from"node:fs/promises";import{dirname as ex}from"node:path";async function Et(n){try{let e=await Z0(n,"utf8");return JSON.parse(e)}catch(e){if(e.code==="ENOENT")return null;throw e}}async function In(n,e,s){await Q0(ex(n),{recursive:!0});let o=`${JSON.stringify(e,null,2)}
|
|
11
|
+
`,c=`${n}.tmp-${process.pid}-${Math.random().toString(36).slice(2,10)}`;try{s?.mode!==void 0?await bs(c,o,{encoding:"utf8",mode:s.mode}):await bs(c,o,"utf8"),await ys(c,n),s?.mode!==void 0&&await X0(n,s.mode)}catch(d){await ys(c,c).catch(()=>{});let{rm:u}=await import("node:fs/promises");throw await u(c,{force:!0}).catch(()=>{}),d}}var An=Ae(()=>{"use strict"});import{promises as vs}from"node:fs";import{homedir as tx}from"node:os";import{sep as nx,join as fe,resolve as Ss}from"node:path";function q(n){let e=n??tx(),s=fe(e,".coze"),o=fe(s,"bridge"),c=fe(o,"lib");return{cozeRoot:s,bridgeRoot:o,libDir:c,libEntry:fe(c,"index.js"),binDir:fe(o,"bin"),pidFile:fe(o,"bridge.pid"),portFile:fe(o,"bridge.port"),tokenFile:fe(o,"bridge.token"),patTokenFile:fe(o,"pat-token"),logFile:fe(o,"bridge.log"),installLock:fe(o,"install.lock"),configFile:fe(o,"config.json"),agentsRoot:fe(s,"agents")}}function Ge(n,e=q()){let s=fe(e.agentsRoot,n);return{root:s,config:fe(s,"config.json"),workspace:fe(s,"workspace"),logs:fe(s,"logs")}}async function Es(n,e){let s=await vs.realpath(Ss(n)).catch(()=>null);if(!s)return!1;let o=await vs.realpath(Ss(e)).catch(()=>null);if(!o)return!1;let c=process.platform==="win32"?s.toLowerCase():s,d=process.platform==="win32"?o.toLowerCase():o;return c===d||c.startsWith(d+nx)}var ie=Ae(()=>{"use strict"});var kn={};Kr(kn,{AGENT_CONFIG_FILE_MODE:()=>Cn,enforceAgentConfigMode:()=>sx,loadAgentConfig:()=>me,persistAgentSessions:()=>Wr,persistAgentSkills:()=>Pn,saveAgentConfig:()=>Ce});import{chmod as rx,stat as ix}from"node:fs/promises";function me(n,e){return Et(Ge(n,e).config)}function Ce(n,e){return In(Ge(n.agentId,e).config,n,{mode:Cn})}async function sx(n,e){if(process.platform==="win32")return;let s=Ge(n,e).config;try{let o=await ix(s);if(!o.isFile())return;let c=o.mode&511;c!==Cn&&(await rx(s,Cn),Is.warn("agent config mode auto-corrected to 0600",{path:s,from:c.toString(8)}))}catch(o){if(o.code==="ENOENT")return;Is.warn("enforceAgentConfigMode: chmod failed (ignored)",{path:s,err:String(o)})}}async function Wr(n,e,s){let o=await me(n,s);o&&(o.sessions=Object.fromEntries(e),await Ce(o,s))}async function Pn(n,e,s){let o=await me(n,s);o&&(o.skills=e,await Ce(o,s))}var Is,Cn,nt=Ae(()=>{"use strict";An();U();ie();Is=D("agent-config"),Cn=384});function Io(n){let e=n?.sessionIdleTimeoutMs;return typeof e!="number"||!Number.isFinite(e)||e<=0?Kd:e}function at(n){return Et(n??q().configFile)}function ze(n,e){return In(e??q().configFile,n)}var Kd,Lt=Ae(()=>{"use strict";An();ie();Kd=10*6e4});var Qo=_e(Y=>{"use strict";var E=k;(function(n,e){let s=k,o=n();for(;;)try{if(-parseInt(s(920))/1+parseInt(s(760))/2*(-parseInt(s(1375))/3)+-parseInt(s(1436))/4*(-parseInt(s(1702))/5)+parseInt(s(1610))/6+parseInt(s(865))/7*(parseInt(s(1077))/8)+-parseInt(s(1595))/9+parseInt(s(1135))/10===e)break;o.push(o.shift())}catch{o.push(o.shift())}})(Zn,501112);var ju=Object[E(1512)+E(1778)],Ku=Object[E(324)+"opertyNa"+E(1776)],Jo=(n,e)=>function(){return n&&(e=(0,n[{hkZbc:function(d,u){return d(u)}}[E(563)](Ku,n)[0]])(n=0)),e},Gu=(n,e)=>{let s=E,o={lSBmM:function(d,u,l,p){return d(u,l,p)}};for(var c in e)o[s(608)](ju,n,c,{get:e[c],enumerable:!0})};function Wu(){return Ho||(Ho=[IDBDatabase,IDBObjectStore,IDBIndex,IDBCursor,IDBTransaction])}function Ju(){let n=E;return jo||(jo=[IDBCursor[n(1349)+"e"][n(630)],IDBCursor[n(1349)+"e"][n(965)],IDBCursor[n(1349)+"e"][n(965)+n(1279)+"ey"]])}function $u(n){let e=E,s={rIfAb:e(321),kvZcc:function(c,d){return c===d},jChUo:e(1504),cyIpI:function(c,d){return c(d)},LeEFx:function(c){return c()},mJDme:e(1255),eeoHQ:function(c,d){return c instanceof d}},o=new Promise((c,d)=>{let u=e,l={aAxbJ:function(y,I){return y|I}},p=()=>{let y=k;n[y(605)+y(720)+y(396)](y(1255),m),n[y(605)+y(720)+"ner"](s[y(881)],_)},m=()=>{let y=k;s[y(1585)](s[y(347)],s[y(347)])?(c(s[y(467)](Ue,n[y(679)])),s[y(591)](p)):(_0x108c45[_0x45056c++]=l[y(1638)](_0x3364e2>>6,192),_0x45ad11[_0x5a78b6++]=l[y(1638)](63&_0x259db0,128))},_=()=>{let y=k;s[y(467)](d,n.error),s[y(591)](p)};n[u(884)+"Listener"](s.mJDme,m),n[u(884)+"Listener"](s[u(881)],_)});return o[e(317)](c=>{let d=e;s[d(1729)](c,IDBCursor)&&xi[d(1651)](c,n)}).catch(()=>{}),tr[e(1651)](o,n),o}function Zn(){let n=["uxL1ze8","twvZC2fNzuu","v3bUDNO","A1L5zMu","t05yEfq","DK1dq3q","tKnqsxq","tuD2swe","A2v5CW","re55EMW","C2nYAxb0","A1L3u2C","BxnN","BxjvEvy","zKHTsgW","veP4sfG","suvtx0vsuK8","z29sD0C","DfDut08","BgLTAxq","DwDiq2K","zw5NDgG","BLH2D2m","ELzMuxi","C3rYAw5NAwy","igzPzwXKoIa","q09otKvdveK","wfH0EuG","t3HbCwq","yNL0zxm","yw5Nzq","CKnwEgi","A3zAy2m","zgLZCgf0y2G","D2fZq2XLyw4","Dev2zw50","vwztEKe","B2nRzxrtDwm","ENfzt0q","B2nRzxq","revvuwO","u3juuuq","mtiYotCWnNncBgnwDa","zLrrBMy","svf0Cge","rxnluu0","z3LpsfG","ruXkzhu","zxfPwMC","aaaaaaaaaaa","Bwf4tg9ZC0m","y2uGBM90igK","Dg9tDhjPBMC","vLjNCM8","q1HXz2W","vhjVq0e","CevftwO","mtyXmJi3oe9rrxbSDW","DvLyqwO","shnJA0u","ENPAAw0","r1fytwu","EvvWugO","A2TyzLi","zxH0zw5ZAw8","zxPtzMe","Ewnst0S","D1DisKW","tLzhBLm","B2XKvMvYC2K","AKzMDwS","Cg9PBNrbBMq","D1rZEhK","EvzNwgu","y1b2EgS","y0nhyMi","zgHJq1O","B3jRig9MzMW","Dw5KzwzPBMu","y25tuu8","BvjiANC","wvj4zu0","BMfVr0W","AgLxtNi","EvjLy29UBMu","yuf4yKO","vgnPzK4","DhnrBNa","DeXIEu4","A2v5","zhrYtNi","y3jLyxrLt2i","EMDTr3K","DgvZDa","Aw9UvgLTzw8","AefJA01LC3m","uLDhwNu","zMX1C2HfEha","C2v0","wLv3Ce4","ywXty29Wzq","uhvitvq","B3bLBG","t3fyEfG","z2v0","CLjwC3G","t1HZsu8","EeL5rey","zgf0yq","y2XVC2uSihC","Cvf5vNy","t1bftG","q1bdv3q","BvLkDgi","q3Lvruq","m3W1Fdb8mxW","yM9L","y3jLyxrLt3a","u3HlAwy","DNn6uNq","Eu9cv2i","sMzpzgC","AuXMuvq","ANb3B3q","mxWW","z0Tvq20","uvnVque","Chv0","nxWYFdn8nhW","CNvMr3C","DLb1AvO","tKrXuKO","yxv0BW","C29YDa","vevSD1C","s0Xsuhq","wxL4BLm","q1rzrwG","C0LmvwO","u2HHCMvKv28","tLnjALC","sKDmquy","r1DMrKi","Ew1kwM4","BwvZC2fNzq","D3m6lY8","BwLUzW","q29Kzq","ANvSs1O","mtK0mdvczerLrgW","Dw9hu0q","yMLUyxj5vhK","v2vPEgLUsLm","x2DLDeLUDgu","DxntsvC","sLLUvuO","r2r5EgK","ENbxsNq","B2nRzxrgywK","svjevgG","ywDLrxzLBNq","yMXVy2TLza","zwvKzwq","yxnJCMLWDa","zwn0","vw1dsgm","zxPbqvy","C0P6vuq","BNruCMLLC0m","ywDLsgLKzq","CgLUz19VBMm","u2HLqLq","zxrxB3jRq2G","tw1xr08","C2vYDMvYvgK","zwzPDgi","zwvVsfe","Euz0seu","z29PBMCGyxC","D3LYAwC","wMHXC3m","D29PDMC","tKvruuC","C2vYDMLJzs0","DhLWzq","ufvzsei","teX0qwm","DgLTzw91Da","tw5xu3e","BhrPCgXLihq","BMCGDxjSoIa","tMfQyMO","BgfgvNC","zwD3qKe","Dvjiu1i","BwvZC2fNzv8","zxjHDg9Y","x2XPC3rLBMu","yLD1ufO","veLgzKG","yvzQDvK","uKjvwey","u2vXsuq","txDZy1q","wMPUzxm","s3jkCg0","u1HODMW","AhzpA2u","BeTNBu0","DNDrEw4","vgLTzw91Da","zNDZxZeUmc4","BxnNsuq","u0T2shK","Cg5cwMe","ChrVCG","ruHXCNy","Dgv4Dc9Qyxy","Cg93","sKP5zw4","AvP0uwC","ChvZAa","AvnOAeC","BwvZ","AwXLtMfTzq","B3bLCNr5","z05gDfa","BM93","DxjS","ve5htwS","Aw5KzxGGB3u","EgzTuvC","Dg9cExrLCW","yxnL","y0TPvhe","BMDLza","r0jfCxK","ywjVCNq","thHxuxG","EK9zChq","A05iqu4","CMvHzhLtDge","tg9JAW","A3v0ChO","Dg9mB3DLCKm","uMjTu0K","wKTsCwu","A2Hqyui","zMLSDgvY","FdeXFdj8ohW","swvhChq","reiGzMfPBgu","yxKSig5LDhC","zwjzwxm","B3bLBIa","yuzmqKO","C2Hks24","rhnYBMK","qLPdseC","sLDUEMK","ve52Bgm","BMrWB2LUDca","Bxv3wvO","x29Ut3bLBG","CMLMzxG","o2nOyxjZzxq","CMvZzxrfBMq","wMTYuK8","BNvTyMvY","x194x21Zz18","BejeshC","B3j3zwS","yM9KEq","DxnLCKLW","tg9NsurozxC","CxfPqvi","qLrtENO","mdaWma","DxrMofDYAxq","wfLJyMq","x2vUzhbVAw4","y3jLyxrLq2W","EffLBeO","BfLcDva","suzMA1m","BwvY","vxblze0","uff2ENm","v2PYtve","AgHmBui","zM9ZCK4","uLPWteO","sw9Xsu4","DM1zDMC","zNjVBuHHC2G","y2vZC0HHBMq","DMvY","yvnMCgy","rgvKAwnHDgu","CuL2y2y","ihzHBgLKihm","Euf0vLa","swHvsuO","s3PQvMe","BxrKtge","sLnhEe4","EujqtKy","vxbKyxrLq28","zxLhD1i","rvjst1i","zxj2AwnL","BwvZC2fNztO","ihrVihjLDhi","x3bPBMDmB3m","DhjPBq","AeHYz0C","sfzXy2G","zMLN","zev5u1G","B25pCgvU","AenQCg8","CLzjsKu","sKznzMm","z2vY","Aw5PDcbrB1m","y3vYCMvUDeu","CMvWBgfJzui","BM5Ly3q","vMTWu2W","x3DZ","qNbZAgu","DLjpz2W","y29UBMvJDeu","ExnfD2e","s09RsKG","C0jf","r2XJAuS","uuDMCvG","s2PjBgy","CgLUz0XVC3m","rKjWCve","zxjFAxnFywm","De1HBMfNzxi","uxrItvG","qvHezeu","yNbHwM4","DufeEwe","ALHzqu8","AfLZs0S","ANrVALC","BMfTzq","z2v0qwXSs2u","DvzZChu","CxjTAg4","wxr0tNe","r3vSvxG","CNzHBa","DgHLBG","CgLUz0LUDgu","sMvWwKK","BvDhufm","zxjYB3i","A1vJzNa","AwrI","z2v0t3DUuhi","AgvKtwf4uMu","tenwt3G","BMrWB2LUDfq","quXLAgi","seTSyuq","mNW1Fdf8mhW","sLngrwu","C21tDxC","AKHYA04","EuHwCKG","ENjAAuO","ug5ptfG","tLHlC3m","zw5JB2rLrNi","qxfJq24","Aw5L","Dgv4Dc9WBge","vgT5vxC","y3bKtg8","ywXSq3vYC28","B2LUDfjLywm","sePoCNa","AKnOvw8","zgL6yxG","zw5jywu","yvnsEvi","y3Hzzw4","wKD5Bvy","ChvsAgO","B3jLtMfTzxm","BxHwre0","EfLJEvm","sMr1v08","AenSB3nLrxy","BgvY","Efrurw52","y1DjB0i","uu9PBee","EgLpAeW","sxjZwvm","BgLfD2u","ueDeu3q","txjdzvi","sfn6CMm","BwzyDwu","AxLMuhC","tLL4t04","qLvtz3O","yw1LoIa","z3LdDuK","x2nSzwfYugK","vu1gBuu","x3bPBMDqB24","EgvdyuO","y29UC3rYDwm","EsbJBg9Zzwq","uMvcyKe","sg91Eve","AMP6qMe","Cgf5Bg9Hzfq","zgvJB2rLzey","DffPEu8","y3jLyxrLuMu","x29WDgLVBNm","rvPprgG","zvvYBa","ihrYEsbYzwm","Eu5iyMm","x2LZsw5PDa","Cu9vCem","x3DHAxq","BMvY","B2zMC2v0","qvjuzxC","tufyx1jfvfi","v3zJyLa","B2ncy3i","BwHXq0e","weTrEfq","Cg9PBNrdB24","y05UueW","D25PuK8","C2v0u3rVCMe","C2fNzq","x1fVu01HBMe","C3rYAw5N","EeTtsfm","B0Tivhy","vMndzhq","t1bftL9fuLi","v3PNDKW","zxHWB3j0CW","r2jvtM8","BMfIBNG","y3r4","vhLKrhK","z2v0u3rVCMe","vxjPqvC","DKHjwLO","De1ct08","sNbpuuW","AuXAqvi","B3jRzxjhBg8","oxW3Fdf8nhW","CNPSB0O","Bwv0Ag9K","z3fMANe","tgHrwg8","x2HHBMrSzu8","AKD2r2i","CMvTB3zLq2G","u0zgwge","shPVwMK","zMzMzG","CMvQzwn0","B25LCNjVCG","shDnvvu","DMfSDwvZ","x2rPC3bHDgm","CNzHBfzHBhu","ywnRx2LK","y29UDgv4Da","tgjsr20","ww1Rvvm","x2LUAxrhBg8","Cg1Jt1y","r0D6sxO","BNPVuNe","q3Dwr24","DM9JtMO","s0zgz3q","vurXsfe","A3rhz0e","D2Dyv1K","BNrbBMrvCgq","rMfND2m","ruz6Euy","BNjjzgK","zw5HyMXLqxu","zw5KCg9PBNq","A09et2m","sfvvDhO","y3LjCeK","tgHAyLC","A2v0ignVBNm","tw1qDKu","v2vIu29JA2u","BgTbtLu","A1r5D2e","DhLIquK","BNrsueu","DMfS","AwXK","yxKSihrYEsa","y3vYC29Yx2y","wKP4C3K","BMvLzf9Hy2S","D25lswS","BMnLq2XVC2u","CvrfAvK","wgH4seu","C29Tzq","q0Phyui","wLHjuuO","BMvJDa","ufLjBM8","verrDLa","ufvey0C","sK1Krey","tgfUugm","Aw5KzxHpzG","AK1sELi","yuLNtgi","D2vI","AKrgA3C","CgXLyxnLiha","zgrcBhO","BvzJr0q","s3bWrfu","uKrKveq","DKrtDNy","x2rLC3rYB3K","DwLKuLu","u2TPCcbWyxm","DfrTAw4","BgXIy2O","CM92AwrLigi","C1PSCeO","igfYCMf5yNu","uMHisNy","C0PIq3q","AKHdr3K","AxnAwMy","rNLdDwO","D29kCe8","D1rREuq","EhDxExO","yxrHlcbKyxq","CwXlsey","x3fVC0rc","y29UBMvJDfm","sfvPCLC","Dxrjza","vgDKuwy","ywWGy3vYC28","C2vUza","Eu9wB1q","DMLJzuLeig8","rMTMDLi","vufXzNm","Ae1LC3nHz2u","uhzsvKG","AxnFywnR","B25ozxr3B3i","CwDcvei","CLjKCMC","y09Wzw4","CM92AwrLihC","rezjBeW","ELbNwvm","nxWXFdj8nNW","x2LZtM9Kzq","BLfRsNm","zeD0sw0","B25Uzwn0Aw4","uxvLDwu","BfvQq08","ywrKt25L","z1DQrwO","rw14DM4","rKLgvKW","C1nZwMO","DNLpuNm","t3PVz3K","BezSDxnO","B0XWAMG","r1jyDgi","CgDUswq","AgTAyMm","pxv0zI04","BeHHBMrSzxi","q2TlsLO","vMrMqLe","Ec1TC2CTCw8","ELrvEgC","Aw50zwDLCIa","zKzytwy","uxvQuNe","u1HKDgC","tef0C3C","shbRCKW","CMvJB25Uzwm","DuvRvLO","zLv2yLG","AxnrB1nnzxm","AxHLCxG","r051BNy","zgvIDwC","CuDcBwG","B2f5uwS","txDAy2C","igzHAwWSig0","wevlsNa","BxfUA3C","zwXhAM0","r0TxAKO","tgvfrNG","y3vZDg9Tshq","AfzUChK","Dwj0qwS","ww5YAuq","A1fZBLa","s3PkBwq","B2fK","q0Xpu0LorW","yxrLq291BNq","zMLUza","CNjVCK1LC3m","Ec1TC2CTy3u","zePJC1C","CMvTB3zLrxy","z2j1z2K","zM5YDum","BfncBu0","qxvzrLu","vLHWDKy","wwT5Duq","BM1UCeq","uhntvMe","ywrKq291BNq","CwHtyu4","rvvKA3O","DgXsDwK","zNzHs1a","sLzzzgC","D2Dyy1y","vxzetfO","ywXSB2nvBNm","AwLNwKe","revRvKC","AgPoy1q","x2LZqNjVD3m","zvPytxC","y3vYC29Y","zNjVBujPDhm","ywr2yw5Jzq","BLHQsxu","y29Uy2f0","DfbYEMe","rvzizeK","DMrQuhq","CgfYC2u","vgfN","BLjqDMy","Cw9Zx18","CIb0DhDjra","B25TzxnZywC","mhWXmhW0Fdu","B25tDgfYDfi","C3vIC3rYAw4","ChPKv1m","yLvouge","wfzrBuW","uxrPCve","C25SCuK","sfv1rvG","vvDIzfu","CYbPBNn0yw4","z1rPBwvVDxq","v29Wu0S","rhzKALu","vuHuD08","B2zM","z09Qwe0","s1bjrMm","B1H2z3y","Eu9Mr0y","vMnevhC","B3nLrxzLBNq","rhLfquu","C2vUDa","zMLvCvK","B2jQzwn0u3q","ihrPBwvZ","x29UrxjYB3i","x2DLBMvYyxq","y0LdsvK","Du1jDuG","AuLPseG","x2n1CNnVCK0","EujPsem","EhHgq08","vw9HteK","AxnrB1nby2S","CMvZDwX0","C0rqwhe","thjKtMG","Dw5jENK","zNjVBuj5Dgu","y2HnyxHuCMK","wgnbDMy","EhjIvNy","weHVBwC","rNHOrfi","zgLZywjSzue","yMfSu2nVCgu","q3nvrhG","zNjVBNrPzxi","y2XLyxjtDg8","wufmEue","z2v0q3vYCMu","uuLHrgO","wuXNBhO","A0Lrzha","txzmBxa","q09oveLovuu","wxDLAw8","tez3CMy","zK1YBLy","uKnyse8","Cgu6ia","AM1rCe0","zLbUsgW","DxbKyxrLq3u","rwrXuxC","Cw9Z","ENPhDuO","C2v0zgi","se9iD1u","zw5XDwv1zq","BMv3vMvYC2K","Affju2y","vgPkuMu","x2fKzfDZtgK","zMzmAw5L","zw50tgLZDgu","jMPZy2fSBgi","BLjRsvi","CMvHC29U","EK96rMK","x2LUAxrqCM8","y2XLyxi","rNjVBNrPzxi","BgLUzq","CM9YrxzLBNq","y2jdC0W","wenKsw4","sgHJwLq","q01wr2O","zeTiwxi","zxjFCw9Z","AxnbCNjHEq","BwvKAwf0zwW","y3vYC29Yx24","v3Hxu0i","s21dvNC","C3rHy2y","vuLbwNu","ywnRtxnNswq","Ahr0Ca","C2vYDMLJzq","sgr2quy","zvrtwva","DcbSAw1PDa","seriweW","ugLQuKO","zK5xyNm","q0P2y2i","zfDVCMTLCKC","BwfW","rNzksvq","y3vYCMvUDeK","zxjFCw9Zx2e","zwHerKi","ihzHBgLKigq","mZq1nJaYEKzxBNvH","D2T0sxm","Bg9NsurozxC","z0XHCwy","zNjVBu51Bwi","EhDWAxu","zLfNvhC","nhWWFdv8mxW","D1zlC3q","mxWYFdb8nhW","y3zJCwG","sM1LCxO","B3Dgrhy","wxffrM4","ign1CNnVCIa","y1bWDw8","AevYCM9Yrxy","sKjjyM8","t3H2zKS","DgTKtvK","wvjNz0S","BMCGB3iGyw4","B1fMrxi","v2LUzg93","qu9hCM4","qKT1D3y","z3fOt1e","ChbkuuW","tKrxtwi","D01Vuuu","rurrAe8","sM9qtee","A1jtA1y","B3v0sw50zxi","wenWEuO","uLHTs2u","BgvUz3rO","ywX3yxLZ","zcWGDw5RBM8","BM9Uzv9UB24","C0z6q3a","lcbxzwjtB2m","zv90Aw1LB3u","ywnRpwzYB24","B25szwnLAxy","v01UAeK","B2XRCeC","Ef9MCM9UDgK","uNzSDLC","r25rtwe","CgfNzxnOB3C","tgnVwuO","vMD2wLO","zxjFywnRx20","yvbiuNi","x2nVBM5Ly3q","sLPAChq","rvLvqKK","BKXPBMu","CxvRCwe","CLzHBhvLCW","C0XPC3rLBMu","x2rYB3bhBg8","D3jPDgu","C2v0sxrLBq","Dw50","EgvyC1y","CufYu2e","vNPfD3O","y1rPrMG","zNjUvgO","DuzUz2m","qNzkANO","CvPzt2W","D3LdDNm","yKPqCKm","ueXXrfa","q0zQqw4","yMfSrxzLBNq","ru9REfK","yMzOEum","D1jZAeG","yMHbqMe","uenhzvO","C0nVDw50zxi","BeDKrLe","DuLVteG","Cxviru8","BwLZzq","zMvY","BMnVzgLUzW","ANrYB3q","zKzYwMK","CgvYC2LZDgu","yMLUza","A0jouuW","rKn1teG","BuXIwey","y3jLyxrLtwu","wNnPugO","zMfwqwC","zNjVBunOyxi","DKTcBhq","sNferuG","u3rYyxrLz3K","mJi3ndK3oxzjAM1yyW","C2vUzf9Hy2S","B3jL","DKfuB0K","B1Ljr20","zfL4BLu","Bff0Cvm","AxnmB25N","x29UugfNzu4","y2HLy2Tszwe","B3bLBKrc","t3joANG","EuztyNe","D1zIDLG","tMz6uLy","D24GCMvHC28","CKLMqwi","yxjYyxLIDwy","zwXAvK0","ywrKrxzLBNq","zNvSqNy","AuLzz3i","tKfusvzfx0u","CgP3qMO","DgLLCKPtt04","qw1VDw50","yNvMzMvYzwq","uNnpr28","DgHHBIbSB2m","vMLKyKK","mdaWmdaWmda","wejItg4","ELPHrgm","rxjYB3jdB2q","m3W4FdeW","Cgf5Bg9Hzeu","yxHtqNe","zxf1ywXZ","txjiywK","yvbtvLa","Bg9N","sKPXuwO","DcbVzIbYyw4","s0fyvMK","CMTLCKDSB2i","ExbqA1G","CMvHzfvjBNq","uMvJB25Uzwm","zgvSzxrLrge","CgXYyva","qKnjt1i","DMfSDwu","yMH6Dg4","AM1jBNa","uwvgANu","mJy3ndu3r054Cg1j","t3Lrqwi","y2DXu0K","vhH6zue","tK5wv2S","wM90EKq","yurWseK","y2n3qLO","D3jPDgvvAw4","Aw5Lza","y2HLy2TdDxi","C0PkBwS","x29Uq2XVC2u","Bu5wrxO","ANjwt1e","DNzVuue","igXHCMDLCIa","BgLUzw5V","y2XVC2veqG","z2TmCuW","uKTSrfu","zxjFBxnNAwq","reP3rxK","B25JBg9Zzq","tvnws3q","ELPXDMS","rM1ewhm","tw10tei","ywnR","m3WYFdf8mhW","zgjfC1O","AgvHzgvYCW","wLbqv1u","yuTHtui","vwf0uxu","wfnIvwG","AgDPtNO","yu1PDwK","x3nVy2TLDa","C1HRs0i","Eg9YAMS","Dw1xwxa","x2rItMfTzq","wNfrr2C","DKHsuuu","y29UDgLUDwu","tKzxyvq","v0vMsuG","yunKAxu","r0HwAvy","Cu9qBfy","CMvZzxrdB3u","q2rguxi","Bhm6ia","Du9Nv2y","suX4ENy","vfvhsxy","C3H0vvy","tLf3BuK","zufJAW","vwfLteW","yw1L","u1PtuwS","BvfZuxy","BNvHs0i","ChjVwwW","yvfcBgq","BhL5AKS","nNWWFdn8n3W","zgvSzxrL","D3j2qxi","CMfTzq","uuLlq1i","C3vIyxjYyxK","CezXBei","BuzAvuG","CMvUDevUzha","zsbHihn0CMK","weDAt04","wuf1Ag4","z2fgCLy","s3nWy1a","vvHcwvi","v0Ltrgy","A2zMteu","B25tDg9Wsw0","x3bHDgHlzxK","BuTzrwi","uwrmvxe","s3Lszvm","y3ruAw1LB3u","DLL1Cuy","r2r4Ewe","z2v0s2v5","Bwf4twvZC2e","x2zVCM1HDeu","CuXwywu","uxDvC2u","BuL4tfa","AhHswem","CxDjEw0","u2vYDMLJzvC","AgzJswO","zfPtB2S","uNH0vMK","x3bYB3rVy28","s3HvrMW","C3rVCMu","B0jVuhG","FdL8mxW3Fdy","CNnVCKzPBgu","qNvXDuW","Bwf4uMv0CMK","DLf2Axm","B2zMBgLUzq","q1n2D0q","BfrPBwvVDxq","t3Pcwve","ihrPBwvVDxq","Du5fAem","DhDVCMTdAge","swfbEwC","Cxv2rLe","sLvPC28","zw5HyMXLuw8","rKnHEK0","z2vtEw5J","BKjYA1u","teLlDfK","zxjYtxnN","Dxv6vfe","Ec11C2uT","zfjvzMG","B3vUDa","yNvMzMvY","DhjPzxm","x19LC01Vzhu","zMzLCG","rg5ZDfy","Aw47y2HHCNm","Aw9U","yw51Ce1LC3m","yNL0zuXLBMC","yxbWBhK","CMv0CNLdB3u","yMjVze8","uhfPsey","q0Xpu0ve","yNvlzfK","qK92sNy","AgLNAa","DgLTzw91DcW","rwnxC3m","vKzWDMm","C3bSAwnL","tNHiAeW","Cwj3qK4","ofbXtMznyW","uLjpuG","De92CMy","Dg1IsxC","rxzLBNq","mxWWFdj8nhW","AfjQwvy","Cu1nDei","yNL0zu9MzNm","Aw5JBhvKzxm","tMnYB2y","r2fRuLm","Ahj4BLK","AgfUz2u","CMvKDwnL","x2HHBMrSzvi","tevwtge","u2zuDuK","q3vZDg9Trxi","CMvXDwLYzwq","Cgf5Bg9Hza","tMDzuMe","sND0EK8","B1DgCK0","BLLLwfu","A2LgseK","DeLUDgvYy2u","zNjHBwvuExa","DNbtCxC","yxf6DMO","nhWXFdj8m3W","q3H5CKu","x21PBMLoyxy","sNn6C1C","x2LUDgvYDMe","BMH6z2K","D2TnAu8","mNWWFdn8mxW","shHYwu0","ENjRD2W","sNn5D3G","rufUzwu","vNvMEwO","ywDLu2HVDW","vhDMzMm","ywDL","y29UBMvJDca","wMXnBve","t0PirKG","uuDZwuO","x2TLEvbHDgG","EfzZqLa","BhPkru4","wvjdz1C","ExbL","yxbWzw5Kq2G","ALnMtve","DgfYz2v0","ndi2ndy1mfPKyxzKAa","Dg9cExrLC0i","CMvJzxzPzwq","wMTNtee","D1r5rwC","y29SBM8","EefAsKW","Aw9Ul2PZB24","CMvZB2X2zq","uvbMA0m","z2v0sxrLBq","x2LZtwLUAvC","ugjJAfm","nNWWFdj8nxW","wfHlqMm","vw5Oyw5KBgu","CvnWr1q","r1vszfK","FdeXFdL8n3W","DLDAy2S","z29dy3K","DxbNCMfKzw4","zw5HyMXLvhi","BKrAB3u","uxHHzfm","zen4tMG","rgjHB3O","zg9Uzq","yxnZAwDU","v0Pcqu4","DLHZvLm","tw9KDwXL","DfLmA1C","x2LUAxq","v1netfK","ugfMAg0","zw5fDMvUDa","s2XMwe0","Dg9oDw1Izxi","DwjuDNy","sxD3u08","AxjtwfO","tMzcuLK","t2rnyLa","zfvgD2q","BNrfBMrWB2K","D29nueC","y2fSBa","CNnVCL9Uyw0","AgfZ","id4G","lcbTyxGGCMu","zNvUy3rPB24","z0XrCNK","BMDuAw1LCG","rMP1yw8","rM9XBeW","vKTxt2y","Exb6rMu","tuXPqKO","C3rLBMvYCW","v3znwve","uxHNwNi","x2LZv29YA2u","z0PqBgq","DhjHBNnHy3q","D3HYzxG","rLfYtMi","zNblzvC","senorgK","DwzJEKS","u1fJrgu","q291BNq","yw5ZzM9YBvq","zv9ZDwnJzxm","x3jLBw92zvC","x2HHBMrSzva","CMvWBgfJzq","DgLUzYbZzxi","C3vRvNm","uMLTvxi","zw1PDa","x3DZsw5ZDge","vhrUDwq","wM9wv2W","zxjYtM8","DKjftg4","DM96t2i","sLH4vMm","A3rssKy","x2rLyNvN","vKv4zK4","te5jEhu","zgfUB0S","zLDJEgS","z0znwfe","v2TfAKS","v1vTuhe","zfDkAuy","y29TCgXLDgu","DMvUDa","DfzHtuq","BNz2sNy","sw5iDxq","reTnwMC","vevqy2y","CMPrzxu","D3nZoI8V","vuzLzgi","uNLnAMy","y2HnyxHdB3u","Eg1PwKq","z1fmsMi","ChjVy2vZCW","Dg9cExrLC0W","x2n1CNnVCKy","x3nLCuLK","ruHjufe","t1b4Cwe","vgXzr3K","C3vJy2vZCW","vNfwv2i","y3nJrLu","uhr2Bu0","r0jxqMO","B25fCNjVCG","tKDFrvjst1i","x0rctMfTzq","rLDyvNe","yKLoCNK","t0X1re4","sfvyDgi","z2jiwgO","y1vVrfu","DKf1Cg4","CfLuBui","y291BNq","DhjPzxmGCMu","rxn4CxG","CMvJzwL2zwq","Dhj1y3rVCIa","A3PYzxa","q3vZDg9Tq2W","zxmGCMvHy2G","uhjPBwfYEuS","uMriC0y","AhbPrgK","C0Xf","t1rNDem","uunvBwC","tejiy3K","y29UBMvJDgK","reHRCLa","Aw9Areu","EuDzu2W","ignVzgu6ia","ufn3C1u","u01hyLK","mhWZFdf8mNW","sMrTu1q","uNfAywO","BwfUDwfSihi","AKzwBxu","Dgv4DfbHEwW","zhPAsgG","m3WYFdy","A0PZDhe","BM1Lvhm","AxnszwfKEq","s1LXtfq","B2T3vw0","DMnJC2O","C1Lrr3q","y3vYC29YlNm","yw1jBM0","AxjLza","ruDZyxm","DgDjwKi","z2vjBMzVu3K","swn0ExC","C2v0q3vYC28","Eu5yv1y","ywXPzcb1CMW","sM1qq20","zcWG","qwjVCNrfCNi","BNrLCG","sevNBxG","zw5JB2rPBMC","AMfkEvK","rg9hsg0","y3jLyxrLrwW","swjkENK","CMfUzg9T","ruzIDhu","D2viBwW","vwznDuW","x25HDMLNyxq","x29UvgLTzw8","B3Pfrvi","vhz4C1C","rMHAq0O","reDrtM8","quDyALm","DNvpq1q","q2HNDw8","Ahz1zuy","vK9Ts00","B3jpBMXPBMu","vgHlvM0","zwnVBM5Ly3q","wxPfC0W","zM9Yy2u","DgT5Beq","ChjVDg90Exa","ywnRx2nVzgu","CgLgvhK","z2riBhq","CgLUz09Uy2u","tuDMu0O","CgfNzwHPzgu","Bwvrsxu","rLDt","Dwrfzhu","D3L5Eum","y2XVC2u","vLbouu4","rKf2Buy","x3nLBMrby2S","B25VCgvU","zKHyBhy","ChbL","rfznrNK","AMvJDfn0B3i","yxv0B21HDgK","vuzRCKq","tuTMA3C","twXpt0S","Be9QC2K","uufXDxu","mtvtyNrWzeW","EgjpBgS","Evjtv3u","BxnSsNi","AxnYvgy","y2HHCKnVzgu","Dw5ZAwDUzwq","lcbOB3n0BMe","vvL0uMW","ugL2tMO","wKTks1u","DhbizwfKzxi","uLPntvG","AMXQELa","wu5HwNe","yMrPuw0","BuDTzNu","tuvtu0fhrv8","uNrWu0O","y29UBMvJDa","zvDpvfu","y09ewNq","tg9Nsuq","z2v0qwXS","x2nSzwfYvgK","v0zPyvm","CuvIy0e","DgTpthG","z2v0q3vYC28","AgXJEe4","uNfozKq","AfLxBK4","DLD2yxy","ChjVDg9JB2W","sfzxCfC","rM9ZwNe","C2DPza","l3DZl3yY","C3bSAxq","zgvS","x2n1CNnVCK4","zvLju2m","x3vYBa","ywnOzwq","DNfwuwS","AfrKwgm","DeLK","sLnptLa","ugDmz3O","C2XPy2u","tgLZDgvUzxi","C2v0y3vYC28","D2rkCw8","twLZC2LUzYa","rKrXt0q","DhDyBLG","AxnAzxjV","D2LSBfjLy28","zcbLCNjVCI4","zw50","AgPUwKK","nZCYCNDRBurx","BMCGzMfPBgu","ugjJs0K","qMnet0u","AwXLx25HBwu","rKzNAe4","zfPPz3m","sfr2te4","v1zKrwW","ywnRDxbfBMq","qLHRAKe","rhv1qwi","u1foCLu","BIWGAg9ZDg4","x2jPBMfYEvq","nhWYFdf8nq","ChfLywG","AM9PBG","Bg93","x2rPC2nVBM4","C3nHz2vfDMu","s3bqEgK","y3vYDMfSDwu","DwLLC2W","qw1RCK4","x2nYzwf0zvm","Bg9IywXty28","AuX5twm","r2TOy2m","wxnTu2e","Cg9W","mtb8mhW0Fdm","zM96wuy","A2P3C0q","q29UzMLN","BMrLEa","D2TUD0O","B3nLza","rKLmrv9ot1q","v05tuge","z1HrwvK","rKDhB20","nhWXFdb8m3W","x3bYzwzPEa","rLzREeq","x3bPBMC","uunXAhe","CM92AwrLige","yw1Lu3bHy2u","x2LZtwLUAvq","EurKu2G","zxH0ugf5Bg8","twT2Dvm","B1nPCw8","s3nAt0e","sLflCge","Dg9Y","y2nQCMq","vw5PBxbSzw0","qMzkufa","BK1dEgS","zLHLAuC","tMfTzq","BLjHzLi","uKzywgq","r1LRvNa","B25SAw5L","BergEMS","vMLHtvu","AwDHDg9Yt24","Ae9Wzw5fDMu","svHozvK","BxPez3q","ywzL","txLjrLi","x3jLy29UBMu","zgvMAw5Luhi","x0vysvnu","DxrVuMvJB24","DMvYC2LVBG","Defvs3i","vNHYwxm","BgLZDgvUtMu","zM9YrwfJAa","tMjrDva","BgffCMe","CMLLC0nVDw4","Aw5N","Axnby2TdBgu","qurqrM0","vM9Jr2y","wvfit3i","tMjIswe","C0PrvNm","shPptM0","DfLNrgi","y29Kzq","Dhr3Awq","EM9tELm","x29UtwvZC2e","ywrK","x21LC3nHz2u","x3jLywr5q2W","CgjICdi","u0Tfu3O","sLLzAgG","zKXnAeW","ugLnAMG","z2u6ia","uK1Wruy","shDJwe4","CgLUz1rPBwu","Bg9Nsurhzw4","vgvLBNO","y3jLyxrLrxi","yw5Hz2vY","AMHXqMS"];return Zn=function(){return n},Zn()}function Vu(n){let e=E,s={WopSK:function(c){return c()},UfDRF:function(c){return c()},PiMjh:e(1320)+"or",PqiHF:e(1234),FGGom:e(321),Fjuao:"abort"};if(er.has(n))return;let o=new Promise((c,d)=>{let u=e,l={tlRui:s.PqiHF,bbodO:s[u(1477)],stacf:s.Fjuao},p=()=>{let y=u;n[y(605)+"entListe"+y(396)](l[y(617)],m),n[y(605)+"entListe"+y(396)](l[y(1065)],_),n["removeEventListe"+y(396)](l[y(741)],_)},m=()=>{s[u(654)](c),s.UfDRF(p)},_=()=>{let y=u;d(n[y(321)]||new DOMException("AbortError",s[y(1543)])),p()};n.addEventListener(s[u(1066)],m),n[u(884)+"Listener"](s[u(1477)],_),n[u(884)+"Listener"](s[u(1190)],_)});er[e(1651)](n,o)}function Yu(n){nr={qlKHF:function(o,c){return o(c)}}[E(523)](n,nr)}function Xu(n){let e=E,s={gyOHX:function(o,c){return o(c)},DFIlL:function(o,c){return o(c)},jtkMC:function(o,c){return o+c},nirSY:function(o,c){return o!==c},GURdY:function(o,c){return o&c},YqEFn:function(o,c){return o|c},KpPxi:function(o,c){return o<<c},ezAAV:function(o,c){return o|c},RDdTD:function(o,c){return o&c},yuPOu:function(o,c){return o<<c},KxUFl:function(o,c){return o<c},TydDy:function(o,c){return o>=c},nkdmi:function(o,c){return o<=c},IFfkS:function(o,c){return o(c)},Vufyj:function(o,c){return o(c)},ioZDE:function(o,c){return o(c)},ypPkX:function(o,c){return o===c},XXtyH:function(o,c){return o in c},njHUs:e(667)+e(354),wmCKb:function(o,c){return o===c},QGfqX:e(998),FoqlL:function(o){return o()},UfSzA:function(o,c){return o===c}};if(s[e(910)](n,IDBDatabase.prototype[e(1200)+e(1060)])&&!s[e(1580)](s.njHUs,IDBTransaction[e(1349)+"e"]))if(s.wmCKb(s[e(297)],e(505)))_0x56a659[e(905)](_0x44c05f);else return function(o,...c){let d=e,u=n[d(1182)](on(this),o,...c);return ci[d(1651)](u,o[d(1686)]?o[d(1686)]():[o]),Ue(u)};if(s[e(1191)](Ju)[e(1086)](n)){if(s[e(1589)](e(859),e(859)))return function(...o){let c=e;return n.apply(s[c(1599)](on,this),o),s[c(543)](Ue,xi[c(1657)](this))};_0x52acf1=_0x30981b[_0x2ef7be+_0x39e0ac+1],_0x3b1349=_0x56fbbe[s.jtkMC(_0x280555+_0x11770d,2)],s.nirSY(s[e(1152)](s[e(773)](_0x2fe8ba,s[e(1457)](_0x8c4b74,8)),49344),32896)?_0xd0e4a1+=_0x15fd89:(_0x2f32c6=s[e(1719)](s[e(1457)](s[e(504)](15,_0x4af702),12),s.yuPOu(63&_0x4025e1,6))|s.RDdTD(63,_0x702ac4),s[e(1026)](_0x56218e,2048)||s[e(420)](_0x1bfeb0,55296)&&s.nkdmi(_0x358851,57343)?_0x55524c+=_0x55a89d:(_0x588a02+=s[e(244)](_0x1809e2,_0x2bc3fe),_0x311bfc+=2))}return function(...o){let c=e;return s[c(1119)](Ue,n[c(1063)](s[c(1288)](on,this),o))}}function Qu(n){let e=E,s={qZYOl:function(o,c){return o===c},ysEwa:e(1187),PnOLX:function(o,c){return o instanceof c},JWnzi:function(o,c){return o(c)},fmmTR:function(o,c,d){return o(c,d)},wgXWY:function(o){return o()}};return s[e(833)](typeof n,s[e(293)])?Xu(n):(s[e(336)](n,IDBTransaction)&&s[e(219)](Vu,n),s.fmmTR($o,n,s[e(458)](Wu))?new Proxy(n,nr):n)}function k(n,e){n=n-196;let s=Zn(),o=s[n];if(k.bkGpaF===void 0){var c=function(p){let m="abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789+/=",_="",y="";for(let I=0,L,T,P=0;T=p.charAt(P++);~T&&(L=I%4?L*64+T:T,I++%4)?_+=String.fromCharCode(255&L>>(-2*I&6)):0)T=m.indexOf(T);for(let I=0,L=_.length;I<L;I++)y+="%"+("00"+_.charCodeAt(I).toString(16)).slice(-2);return decodeURIComponent(y)};k.PTJJTN=c,k.IkNHQH={},k.bkGpaF=!0}let d=s[0],u=n+d,l=k.IkNHQH[u];return l?o=l:(o=k.PTJJTN(o),k.IkNHQH[u]=o),o}function Ue(n){let e=E,s={iUERx:function(c,d){return c instanceof d},BNSAJ:function(c,d){return c(d)},icBGr:function(c,d){return c(d)},HDHXL:function(c,d){return c!==d}};if(s.iUERx(n,IDBRequest))return s.BNSAJ($u,n);if(Xn.has(n))return Xn[e(1657)](n);let o=s.icBGr(Qu,n);return s[e(749)](o,n)&&(Xn.set(n,o),tr[e(1651)](o,n)),o}var $o,Ho,jo,xi,er,ci,Xn,tr,nr,on,Ko=Jo({"node_modules/idb/build/wrap-idb-value.js"(){let n=E,e={JdmST:function(s,o){return s instanceof o},AiQho:function(s,o){return s===o},GRXtb:n(667)+n(354),iShhG:n(1027),OxvfK:function(s,o){return s(o)},gXLnT:function(s,o,c){return s(o,c)},MvLmp:"uWFrq",IbJzy:function(s){return s()},NuSOe:n(1234),tgIZB:n(321),gXPRc:"abort",FWXVq:n(569),HwMUU:"zYYXC",sSsZj:function(s,o){return s===o},HmFDQ:n(1162),LanPc:function(s,o){return s===o},PQvzs:function(s,o){return s===o},dKHYr:n(462),JmPCm:n(934),tMBOO:function(s,o){return s in o}};$o=(s,o)=>o[n(486)](c=>s instanceof c),xi=new WeakMap,er=new WeakMap,ci=new WeakMap,Xn=new WeakMap,tr=new WeakMap,nr={get(s,o,c){let d=n;if(e.JdmST(s,IDBTransaction)){if(e.AiQho(o,d(1162)))return er[d(1657)](s);if(o===e[d(561)])return s.objectStoreNames||ci.get(s);if(o===e[d(1775)])return c[d(667)+d(354)][1]?void 0:c[d(667)+d(867)](c[d(667)+"oreNames"][0])}return e[d(778)](Ue,s[o])},set(s,o,c){let d=n;if(e.AiQho(e[d(699)],"uWFrq"))return s[o]=c,!0;{let u=e.gXLnT(_0x18a8a8,_0x4f1f75,_0x3a07d5[d(1572)]),l=_0xc67332[d(1582)],p=_0x272d57[d(1582)];for(let m=0,_=_0x304057[d(1572)];m<_;m++)l[m+u]=p[m]}},has(s,o){let c=n,d={CXDyn:c(1234),LxWQx:e.tgIZB,RnTjU:e.gXPRc,qGBmh:function(u,l){return e[c(778)](u,l)},qhSaN:"AbortError",Oknnz:function(u){return e.IbJzy(u)}};if(e[c(1263)]===e[c(441)])this[c(289)]&&this[c(289)][c(530)](_0x196512),this._debug("send_ack",_0x5e9341);else{if(e[c(1294)](s,IDBTransaction)&&(e[c(556)](o,e.HmFDQ)||e[c(494)](o,c(1027))))if(e[c(247)](e[c(734)],e[c(1318)])){let u={plNxS:function(_){let y=c;return zdBpYN[y(1327)](_)},HUUtz:function(_){return _()}},l=()=>{let _=c;_0x2aadef["removeEv"+_(720)+_(396)](MIlDIU.CXDyn,p),_0x4237a7[_(605)+_(720)+_(396)](MIlDIU[_(198)],m),_0x358a31[_(605)+_(720)+_(396)](MIlDIU.RnTjU,m)},p=()=>{let _=c;u.plNxS(_0x23b668),u[_(466)](l)},m=()=>{let _=c;MIlDIU[_(583)](_0x3aee9e,_0x34e56b.error||new _0x2894de(MIlDIU.qhSaN,MIlDIU[_(615)])),MIlDIU.Oknnz(l)};_0x228537[c(884)+c(1425)](zdBpYN.NuSOe,p),_0x1185af[c(884)+c(1425)](zdBpYN[c(1312)],m),_0x3ce8f1["addEvent"+c(1425)](zdBpYN.gXPRc,m)}else return!0;return e[c(424)](o,s)}}},on=s=>tr[n(1657)](s)}}),Vo={};Gu(Vo,{deleteDB:()=>ef,openDB:()=>Zu,unwrap:()=>on,wrap:()=>Ue});function Zu(n,e,{blocked:s,upgrade:o,blocking:c,terminated:d}={}){let u=E,l={yNHbc:"online",vuOCT:"offline",CtVrc:u(1355),AuYFU:u(810),GKWjJ:function(_,y){return _!==y},ddBlz:"MieLm",sxtUV:u(544),zpWJt:function(_,y){return _(y)},YmkUS:u(1320)+"or",HUXtb:function(_,y){return _===y},hVZfh:u(1501),OJHFH:u(1360),fXFtq:"versionc"+u(1090)},p=indexedDB[u(1655)](n,e),m=Ue(p);return o&&p[u(884)+u(1425)](u(1156)+u(1715),_=>{let y=u;l[y(590)](l[y(501)],l[y(977)])?o(l.zpWJt(Ue,p[y(679)]),_[y(1622)+"on"],_[y(715)+"on"],Ue(p[y(1200)+y(1060)])):(this[y(626)+"er"]&&_0x15335b[y(884)+y(1425)](l[y(392)],this[y(433)+"nLine"]),this._isBrowser&&_0x3f8571["addEvent"+y(1425)](l[y(1339)],this[y(433)+y(719)]),this[y(626)+"er"]&&_0x34cda9[y(884)+y(1425)](l.CtVrc,this[y(1211)+y(1722)]),this._isBrowser&&_0x552bc7[y(884)+y(1425)](l[y(609)],this[y(1211)+"ageShow"]))}),s&&p[u(884)+u(1425)]("blocked",()=>s()),m.then(_=>{let y=u;l[y(1266)]("GYkVp",l.hVZfh)?(d&&_[y(884)+y(1425)](l[y(1125)],()=>d()),c&&_[y(884)+y(1425)](l.fXFtq,()=>c())):(mhfRva[y(1710)](_0x5c60df,_0x2bc0f9[y(321)]||new _0x34ebd0(mhfRva[y(448)],y(1320)+"or")),_0x390b6a())}).catch(()=>{}),m}function ef(n,{blocked:e}={}){let s=E,o={yQbOy:s(1714),JSFEe:function(d,u){return d(u)}},c=indexedDB[s(913)+"tabase"](n);return e&&c[s(884)+s(1425)](o.yQbOy,()=>e()),o[s(331)](Ue,c)[s(317)](()=>{})}function Go(n,e){let s=E,o={hqmLK:function(p,m){return p instanceof m},JszsW:function(p,m){return p in m},tAUKr:function(p,m){return p===m},EVHdI:"string",jFVmu:function(p,m){return p!==m},VRgro:function(p,m){return p in m}};if(!(o.hqmLK(n,IDBDatabase)&&!o[s(1110)](e,n)&&o[s(1516)](typeof e,o[s(634)])))return;if(Qn[s(1657)](e))return Qn.get(e);let c=e.replace(/FromIndex$/,""),d=o[s(1297)](e,c),u=Xo[s(1086)](c);if(!o[s(1606)](c,(d?IDBIndex:IDBObjectStore).prototype)||!(u||Yo[s(1086)](c)))return;let l=async function(p,...m){let _=s,y=this[_(1200)+_(1060)](p,u?"readwrite":"readonly"),I=y.store;return d&&(I=I.index(m.shift())),(await Promise.all([I[c](...m),u&&y.done]))[0]};return Qn[s(1651)](e,l),l}var Yo,Xo,Qn,tf=Jo({"node_modules/idb/build/index.js"(){let n=E,e={sZlpJ:n(1681)+n(1677),aMiui:function(c,d){return c(d)},DvdjU:function(c){return c()},wdJqo:"get",pbbyS:"getAll",Pqeqp:"getAllKeys",AXDdE:n(1271),ubTvv:n(1536),xrbVv:n(989),BgpYU:"clear"},s=e[n(512)][n(1413)]("|"),o=0;for(;;){switch(s[o++]){case"0":e[n(957)](Yu,c=>({...c,get:(d,u,l)=>Go(d,u)||c[n(1657)](d,u,l),has:(d,u)=>!!Go(d,u)||c[n(1184)](d,u)}));continue;case"1":Qn=new Map;continue;case"2":e[n(655)](Ko);continue;case"3":Yo=[e[n(1427)],"getKey",e.pbbyS,e.Pqeqp,e[n(304)]];continue;case"4":Xo=[n(1680),e[n(1174)],e[n(686)],e.BgpYU];continue;case"5":e[n(655)](Ko);continue}break}}}),nf={idb:function(n){let e=E,s={MrHai:function(o,c){return o(c)},PSwsU:function(o,c){return o!==c},BKuwv:e(1496),XYcbd:"TjdzW"};n[e(416)]=Promise[e(1143)]().then(()=>(tf(),Vo))[e(317)](function(o){let c=e,d={mzDgt:function(u,l){return s[k(903)](u,l)}};return s[c(1291)](s[c(785)],s[c(239)])?o:(_0x289c3d[c(1063)](BgStRA[c(1508)](_0x240330,this),_0x5b9d4b),_0x53feda(_0x299971[c(1657)](this)))})}},Wo={};function Fe(n){let e=E,s={EAnee:e(1082)+"3",tjwNK:function(l,p){return l!==p}},o=s[e(1118)][e(1413)]("|"),c=0;for(;;){switch(o[c++]){case"0":if(s.tjwNK(void 0,d))return d[e(416)];continue;case"1":var d=Wo[n];continue;case"2":var u=Wo[n]={exports:{}};continue;case"3":return u[e(416)];case"4":nf[n](u,u[e(416)],Fe);continue}break}}Fe.d=(n,e)=>{let s=k;for(var o in e)Fe.o(e,o)&&!Fe.o(n,o)&&Object[s(1512)+s(1778)](n,o,{enumerable:!0,get:e[o]})},(()=>{let n=E;Fe.o=(e,s)=>Object[n(1349)+"e"].hasOwnProperty[n(1182)](e,s)})(),(()=>{let n=E,e={UFedb:function(s,o){return s!=o},FCuLH:n(1631)+"d",olkpG:n(1166)};Fe.r=s=>{let o=n;e[o(1243)](e[o(856)],typeof Symbol)&&Symbol[o(1605)+"Tag"]&&Object[o(1512)+o(1778)](s,Symbol[o(1605)+o(637)],{value:e[o(806)]}),Object[o(1512)+o(1778)](s,"__esModule",{value:!0})}})();var te={};(()=>{let n=E,e={VFpvc:function(i,t){return i+t},JduWO:function(i,t){return i+t},ymJZn:function(i,t){return i+t},nmnpD:function(i,t){return i*t},rRVsx:function(i,t){return i!==t},rzloJ:"lsobL",ZPPWU:function(i,t){return i+t},hTdXc:function(i,t){return i(t)},rufGw:function(i,t,r){return i(t,r)},OLuDN:function(i,t,r){return i(t,r)},cJSVZ:"complete",VXpvF:n(197),bSNKF:n(264),TEPcf:n(237),YJNZl:n(438),dRUfh:function(i,t){return i|t},dUFwd:function(i,t){return i|t},cODZt:function(i,t){return i<<t},LIKtY:function(i,t){return i<<t},KzJmd:function(i,t){return i<<t},ZXIQJ:function(i,t){return i+t},cWIoB:function(i,t){return i+t},iyfPw:function(i,t){return i|t},sJQVs:function(i,t){return i|t},goCcy:function(i,t){return i+t},UfMuL:function(i,t){return i+t},DHkrP:n(852),cbCsL:n(895)+n(895)+n(895)+"00000000",isZZf:function(i){return i()},JXxVc:function(i,t){return i>t},hYsKK:function(i,t){return i<t},qukqa:n(554),mYJtb:function(i,t){return i!==t},evZjp:function(i,t){return i-t},WxWSB:function(i,t){return i<t},QtbMX:function(i,t){return i-t},uIoLH:function(i,t){return i===t},mFZUH:function(i,t){return i<t},ubtAk:function(i,t,r){return i(t,r)},vvoQA:function(i,t){return i!==t},LLtAc:function(i,t,r){return i(t,r)},pqeah:function(i,t,r){return i(t,r)},HwcXN:function(i,t,r){return i(t,r)},kzrep:function(i,t){return i&t},TgdQf:function(i,t){return i===t},plraP:n(1428)+n(1096)+n(1578)+"value",SrTQD:function(i,t,r){return i(t,r)},TJxHX:function(i,t){return i(t)},FxhDR:n(1502),elGjm:n(1034),nRkIR:n(1355),fulBv:n(810),wVKst:"ping_onc"+n(1209)+"s",dYxnU:n(1255),fNWbs:function(i,t,r,a){return i(t,r,a)},sukVs:n(321),IhUIJ:function(i,t,r){return i(t,r)},yOVoT:function(i,t){return i!==t},aDpHI:function(i,t,r){return i(t,r)},oayQk:function(i,t,r){return i(t,r)},ONXxT:function(i,t){return i!==t},buKdY:n(491),YALyA:function(i,t,r){return i(t,r)},GWfFB:function(i,t){return i!==t},CTYEh:function(i,t,r){return i(t,r)},xpfen:function(i,t){return i!==t},SXhvl:function(i,t,r){return i(t,r)},iigZA:function(i,t){return i===t},iZtQg:n(716),gQLJb:function(i,t,r){return i(t,r)},LhQXo:function(i,t){return i!==t},qqiAR:n(685),gbHXj:function(i,t,r){return i(t,r)},vAupn:function(i,t,r){return i(t,r)},RZMMX:function(i,t){return i!==t},lGdFQ:function(i,t,r){return i(t,r)},gLaqf:function(i,t,r){return i(t,r)},WjLSS:function(i,t,r){return i(t,r)},yFSbq:function(i,t){return i(t)},IQtpa:function(i,t){return i(t)},mxQlT:function(i,t){return i(t)},YtCcr:function(i,t){return i(t)},UoaLI:function(i,t){return i(t)},kODOc:function(i,t){return i(t)},cUoDU:function(i,t,r){return i(t,r)},uiesl:function(i,t){return i===t},JJyen:"Missing "+n(1096)+n(1578)+n(1755),KAXVi:n(1428)+n(1096)+n(1578)+"LogID",QIaDj:n(1428)+n(1096)+n(1578)+"service",UmCHc:n(1428)+n(1096)+n(1578)+n(430),SFFXa:function(i,t){return i(t)},sDPXq:n(519),qwIym:function(i,t,r){return i(t,r)},TElwW:function(i,t){return i+t},LcoYJ:n(1494)+"ented ty"+n(705),cNnPL:function(i,t){return i>=t},nuaKB:n(508)+"t limit",YyxnS:function(i){return i()},kIQdp:function(i){return i()},SfTuI:function(i,t){return i!==t},axSBq:n(1256),yGYSl:function(i,t){return i>=t},WSDLY:n(389),HxrYM:"Read pas"+n(748),mxVDM:function(i,t,r){return i(t,r)},wMoQE:function(i,t){return i||t},Ttnud:function(i,t){return i<t},QyudO:function(i,t){return i+t},QtiqQ:function(i,t){return i===t},lQtqS:function(i,t){return i>=t},lBDHw:function(i,t){return i+t},aqzvj:function(i,t){return i+t},PijRJ:function(i,t){return i!==t},WFiaS:function(i,t){return i(t)},tWTOO:function(i,t){return i==t},WNSPa:function(i,t){return i&t},Zjnes:function(i,t){return i+t},boCKR:function(i,t){return i+t},kkXfR:function(i,t){return i<<t},NXKss:function(i,t){return i<=t},zMxJO:function(i,t){return i(t)},FCazM:function(i,t){return i+t},cPpuo:function(i,t){return i+t},wTyEg:function(i,t){return i!==t},FQrNb:function(i,t){return i&t},kRSkV:function(i,t){return i|t},EOkxY:function(i,t){return i|t},CFjAn:n(1128),yHVrH:function(i,t){return i+t},mQsQv:function(i,t){return i+t},mRHjw:function(i,t){return i<=t},wVbvX:function(i,t){return i+t},gbugi:function(i,t){return i-t},afaVg:function(i,t){return i+t},Ictyw:function(i,t){return i<t},bDTmC:function(i,t,r){return i(t,r)},IGafw:function(i,t){return i<<t},zrZiJ:function(i,t){return i|t},kNHAN:function(i,t){return i>>t},iIYgr:function(i,t){return i|t},FosZq:function(i,t){return i&t},WkEjK:function(i,t){return i>>t},gXQYY:function(i,t){return i&t},dJcsW:function(i,t){return i|t},vIHDf:function(i,t,r){return i(t,r)},UatQu:function(i,t){return i+t},gaFrV:function(i,t,r){return i(t,r)},dZigs:function(i,t){return i<t},PGDSt:function(i,t){return i&t},UVtKw:function(i,t){return i&t},WzgvL:function(i,t){return i>=t},tybAI:function(i,t,r){return i(t,r)},snlqI:function(i,t){return i&t},KOkJH:function(i,t){return i(t)},dZXhc:function(i,t){return i(t)},tQiyO:function(i,t){return i&t},gdHlt:function(i,t){return i&t},piFTy:function(i,t){return i<<t},BbYpg:function(i,t){return i(t)},MwscT:function(i,t){return i<<t},mnrEh:function(i,t){return i&t},DuuAb:function(i,t){return i(t)},HEgmx:function(i,t){return i|t},RXmKe:function(i,t){return i>>>t},mLbXF:function(i,t){return i|t},sJzUD:function(i,t){return i>>>t},aSfpf:function(i,t){return i<<t},ZGymV:function(i,t){return i===t},qiQqS:function(i,t){return i<t},FhZCJ:function(i,t){return i<t},SxKif:function(i,t,r){return i(t,r)},gWjEj:function(i,t){return i!==t},NfzRV:function(i,t){return i!==t},vBELn:function(i,t){return i>>>t},UrDnl:function(i,t){return i&t},kQsnP:function(i,t){return i+t},bINry:function(i,t){return i!==t},qrmhn:function(i,t){return i>>>t},GQXMe:function(i,t){return i&t},mhqCA:function(i,t){return i&t},nstmr:function(i,t){return i>>>t},RhHJv:function(i,t){return i!==t},BXkjA:function(i,t){return i|t},ELJdu:function(i,t){return i+t},UFkrD:function(i,t){return i!==t},NgYRa:function(i,t){return i&t},sJJmk:function(i,t){return i>>>t},FkfvR:function(i,t){return i+t},jSfMQ:function(i,t){return i!==t},zZqvk:function(i,t){return i|t},ntRPE:function(i,t){return i>>>t},MkvuS:function(i,t){return i&t},xxFCO:function(i,t){return i!==t},hrxnY:function(i,t){return i&t},InHut:n(703),wRshH:function(i,t){return i(t)},aIgLb:function(i,t){return i+t},ysgAY:function(i,t){return i!==t},cscFU:n(276),SXdtg:function(i,t){return i===t},nXJsU:n(1075),PYIno:function(i,t){return i|t},vmYvg:function(i,t){return i<<t},bWuPZ:function(i,t){return i<<t},VhytP:function(i,t){return i<<t},ZKJKU:function(i,t){return i|t},acLsI:function(i,t){return i<<t},nBrkU:function(i,t){return i<<t},amInm:function(i,t){return i<<t},pjwBj:function(i,t){return i|t},GHViV:function(i,t){return i<<t},gqfjq:function(i,t){return i<<t},laEra:function(i,t){return i<<t},okwUm:function(i,t){return i===t},kjwsD:function(i,t){return i>>>t},IwwSO:function(i,t){return i|t},gsmKZ:function(i,t){return i<<t},uidRU:function(i,t){return i<<t},vpSqw:function(i,t){return i<<t},eyGwR:function(i,t){return i&t},xKSHS:function(i,t){return i>>>t},cpdLo:function(i,t){return i>>>t},oWFrM:function(i,t){return i(t)},pEEMj:function(i,t){return i===t},FAvmF:function(i,t){return i===t},ZqQGg:n(249),vwQyn:function(i,t){return i!==t},FBpqQ:"mAUnZ",XKQxT:n(1758),cTiFh:"DyEAE",CJvcb:function(i,t){return i<=t},proYl:function(i,t){return i+t},lUjCO:function(i,t){return i%t},VkpSl:function(i,t){return i/t},aPHRr:n(1467)+n(1153)+n(545)+"8",JfOdg:function(i,t){return i|t},sXkKB:function(i,t){return i>t},YNaZq:function(i,t){return i>>>t},WvcbP:function(i,t){return i===t},VPNQN:n(1570),dizax:function(i,t){return i+t},CxyrE:function(i,t){return i*t},DbnXW:function(i,t){return i+t},vROgl:function(i,t){return i===t},UaeLL:n(410),OXsIO:function(i,t){return i(t)},HUirW:function(i,t,r,a){return i(t,r,a)},IeGpt:function(i,t){return i instanceof t},hRjYV:"dsrOa",QujRq:function(i,t){return i>>>t},HhcZT:function(i,t){return i&t},BCIOR:function(i,t){return i>>>t},HdvAF:function(i,t){return i+t},fTQnf:function(i,t){return i===t},VcCdt:function(i,t){return i===t},ZkrRO:function(i,t){return i===t},kffLE:function(i,t){return i+t},KzjVa:function(i,t){return i&t},KVkhV:function(i,t){return i&t},pzdWS:function(i,t){return i>>>t},wyCvs:function(i,t){return i>>>t},dCxNh:function(i,t){return i>>>t},jtrot:function(i,t){return i>>>t},shJKn:function(i,t){return i>>>t},vWZck:function(i,t){return i&t},fFXMf:function(i,t){return i&t},hYWnN:n(887)+n(1078),sFzCp:n(1579)+n(1261),pFqlB:n(399)+"IES_ERROR",kTywa:"MESSAGE_"+n(269),xbOlk:n(414)+"OR",hvueF:n(767)+n(1300),liEwe:function(i,t,r){return i(t,r)},vYuqF:n(1735),hiWNr:n(769)+"3",mVcGD:function(i,t){return i!==t},jDFkw:"SgkCv",arJQq:n(1035),Najbj:function(i,t){return i||t},IRDTh:"undefined",gFMXQ:"awJJa",qMMtB:n(1019),ktGgA:function(i,t){return i instanceof t},fOzds:function(i,t){return i+t},kBNQL:n(766),PbcKI:function(i,t){return i>>>t},bhABa:function(i,t){return i<<t},BTSzz:function(i,t){return i===t},VocGf:function(i,t){return i-t},gzVnK:function(i,t){return i===t},SFxCa:function(i,t){return i>t},Jmeqz:n(904),iLyMc:function(i,t){return i|t},ALehb:function(i,t){return i===t},LEVLa:n(724),QAquu:function(i,t){return i+t},aFLBJ:n(1150)+"d error.",RdHsF:function(i,t){return i+t},HSzrc:function(i,t){return i+t},yDdSh:function(i,t){return i===t},RXaMB:function(i,t){return i===t},OTgtC:n(1058),dZSok:function(i,t){return i===t},vHRQE:function(i,t){return i>>t},FDqOD:n(1611),ehDFB:function(i,t){return i(t)},xwpiu:"unknown reason",MnWSq:function(i,t,r){return i(t,r)},XEKJp:n(1360),cPvxk:function(i,t){return i===t},hpiDi:n(624),NQwmI:n(305),QCUmg:n(1697),wyrig:function(i,t,r){return i(t,r)},ccwBZ:function(i,t){return i!==t},jXYAO:function(i,t){return i-t},RbmSI:function(i,t){return i&t},FnxYW:"OOXzs",JqDEH:n(1655),smSuw:function(i,t){return i===t},nDZou:"jzrAQ",vMCCt:function(i,t){return i+t},HUuEX:n(1293)+"4",WISDf:function(i,t){return i===t},LbRGm:function(i,t){return i+t},ozEER:"NWYPO",MwZcg:function(i,t){return i<t},rSztB:function(i,t){return i&t},vdjPt:function(i,t){return i+t},oSiqo:function(i,t){return i!==t},fosrN:function(i,t){return i===t},GBWBj:function(i,t){return i>>>t},FIFVL:function(i,t){return i<t},uoGSD:function(i,t){return i&t},lOjsi:function(i,t){return i&t},xmiZD:function(i,t){return i>=t},ktRJF:function(i,t){return i<t},zgmGy:function(i,t){return i|t},HouyQ:function(i,t){return i<<t},uEkVZ:function(i,t){return i&t},jjzBa:n(342),HqKEk:n(671),MlOOK:function(i,t){return i|t},woMPG:function(i,t){return i<<t},mqHtZ:function(i,t){return i<<t},JUiso:function(i,t){return i&t},SmfAX:function(i,t){return i+t},MmPvE:function(i,t){return i(t)},ccjrd:function(i,t){return i|t},ppJQL:"YgJGA",fozYF:function(i,t){return i<t},aSRyR:function(i,t){return i|t},zVfQr:function(i,t){return i&t},QxadS:function(i,t){return i===t},IxSuT:function(i,t){return i&t},gxRXI:n(1668)+"4|2",uvHcg:function(i,t){return i|t},oKHTv:function(i,t){return i|t},EYUBI:function(i,t){return i&t},quvFQ:function(i,t){return i+t},fpKeW:function(i,t){return i<<t},RKlDU:function(i,t){return i&t},LcysV:function(i,t){return i|t},ILxzv:function(i,t){return i&t},fPnHl:"PtvmM",CwVGn:function(i,t){return i|t},RMpEF:function(i,t){return i>>t},ycROK:function(i,t){return i&t},GuYBs:function(i,t){return i|t},kJstq:function(i,t){return i==t},vKBlt:function(i,t){return i instanceof t},YzEsL:function(i,t){return i|t},WvMYQ:function(i,t){return i|t},hvOke:function(i,t){return i<<t},tkdMY:function(i,t){return i&t},vPuiZ:function(i,t){return i+t},unIzy:n(1253),MyIFR:function(i,t){return i!=t},UAqfs:function(i,t){return i instanceof t},bJPrC:function(i,t){return i!=t},xQelJ:"applicat"+n(1142),Jtxnb:n(1769),fHmHl:function(i,t){return i!==t},KYqLT:"kaVRC",GWBtw:n(1669),hfcIj:n(1366),qArSa:function(i,t){return i<t},ndHgx:n(451),JGLAF:n(1563),CXqgl:function(i,t){return i+t},HTvLN:n(721)+n(803)+n(889)+"P",RxtVi:n(710),lKgmM:n(1748)+"id",WVdEl:"zRFNQ",JwtzO:"JjAzF",aGYhe:n(323),NbQuP:n(1517),oQfEr:function(i,t){return i!==t},XHomg:n(1033),vccsj:function(i,t){return i>=t},yEtUz:n(1116),LRIoT:function(i,t,r){return i(t,r)},julKZ:n(539),EdqQw:function(i,t){return i===t},Esxqx:n(1691),DKMZg:n(986),pgnId:n(1383),mqnkw:n(1206),LhZbW:function(i,t){return i||t},VExfN:n(738)+n(981),VdfBQ:"Zzqwe",uNhrz:n(1012),lkANU:function(i,t){return i||t},aVflX:function(i,t){return i(t)},CweRD:function(i,t){return i!==t},xiOhL:"AxeRd",mslJr:function(i,t){return i!==t},ThKVm:n(1222),JoPLA:function(i,t){return i||t},TjJRe:function(i,t){return i===t},VKWOf:n(1684),DvQNN:function(i,t){return i||t},nzoRq:function(i,t){return i!==t},aVjuY:"PrGDy",QsKzm:function(i,t){return i||t},QCqhq:function(i,t){return i||t},BUSgz:function(i,t){return i||t},jHCGy:n(284)+n(211)+"d",BZCHG:function(i,t,r){return i(t,r)},ZlMmQ:n(521),JFMfc:"dvGzO",PsSVa:function(i,t){return i(t)},hVnpy:function(i,t){return i-t},wrvAr:"VZHYP",ARTew:n(1129),zzTwP:n(807)+n(735),RWGZu:function(i,t,r){return i(t,r)},AHVMX:n(807)+n(813)+n(1411),SKvHy:n(481),KyReS:n(537),yAtVP:function(i,t){return i&&t},uNEhC:n(1365),uTKdp:n(445),yRSWu:function(i,t){return i||t},JeDpQ:n(1350),HJNrp:n(278),DoGHm:n(1274),fUvbX:function(i,t){return i(t)},llbcj:function(i,t){return i instanceof t},jHrkN:n(341)+n(1059)+"et=utf-8",uADya:"applicat"+n(1142)+n(225)+n(564),KjIlf:"binary",Dbaoz:function(i,t){return i+t},CiPOh:function(i,t){return i(t)},yOfGF:function(i,t){return i+t},XrZuJ:function(i,t){return i|t},laFVw:function(i,t){return i||t},VgvZZ:function(i,t){return i+t},YRggK:function(i,t){return i+t},DJwEy:function(i,t){return i+t},HGhwT:n(1783)+n(907)+n(1544),xeCaJ:" + ",JYnUJ:n(1185),rRdrg:n(570)+"too large",uOgWf:function(i,t){return i&t},kutpz:function(i,t){return i+t},lhpaO:function(i,t){return i===t},nnUuP:"TZusq",fLMhL:function(i,t,r){return i(t,r)},JBIbo:function(i,t){return i<<t},CkKJZ:function(i,t){return i+t},CPCWt:function(i,t){return i+t},gyCuI:function(i,t){return i|t},dNAMH:function(i,t){return i+t},soGkl:function(i,t){return i+t},jGvGb:function(i,t){return i|t},NFWaT:function(i,t){return i|t},vqVQk:function(i,t){return i+t},nYeXU:function(i,t){return i+t},vqmIh:function(i,t){return i+t},eqiZg:function(i,t){return i+t},pYTmB:function(i,t){return i>>>t},SCuwf:function(i,t){return i&t},mGmfu:function(i,t){return i>>>t},Twffc:function(i,t){return i>>>t},zzZim:function(i,t){return i+t},MhLSF:function(i,t){return i instanceof t},elZVM:function(i,t){return i!==t},nabnx:n(280),twXnX:function(i,t){return i&t},TUGIv:function(i,t,r){return i(t,r)},sJbCt:function(i,t){return i!==t},usSIW:n(518),mKvYi:function(i,t){return i+t},bhztn:function(i,t){return i(t)},IoqIN:function(i,t){return i||t},Pafhm:n(947),vHIZZ:function(i,t){return i|t},NNVWk:function(i,t){return i<<t},lYBuP:function(i,t){return i<t},Bpshe:function(i,t){return i>t},phtMy:function(i,t){return i&t},VOmKM:function(i,t){return i|t},oXvgv:function(i,t){return i>>>t},ebYYs:function(i,t){return i<<t},fAMpO:function(i,t){return i===t},nbBKM:n(1008),HzONm:function(i,t){return i(t)},xfrZF:function(i,t){return i(t)},tkOLx:function(i,t){return i&t},fZwjp:function(i,t){return i(t)},tPrza:n(1148)+n(428)+n(899),sYQGt:n(1308)+n(270),dbEsZ:n(745),BOvJv:n(1458),KlfXM:function(i,t){return i|t},Ozogy:function(i,t){return i<<t},vszRt:function(i,t){return i!==t},WJCFT:n(831),KPIFc:"obvcC",rjQeu:function(i,t){return i+t},iLZAR:n(479)+"ile_name",AOGrn:n(1474)+n(1513),Fagwc:n(344)+n(820),CyUED:"ALL",pnBZa:"INSTANT",PbchS:n(700),tkylD:function(i,t,r,a){return i(t,r,a)},aKaMB:function(i){return i()},eZXMw:n(712),mrUyV:function(i,t){return i!==t},tTmin:n(406),WSGEd:function(i,t){return i(t)},enIae:n(1426)+"r",wyyyC:function(i,t){return i+t},nmeTs:function(i,t){return i!==t},LrdNh:function(i,t){return i&t},Zhqss:function(i,t){return i<<t},gDGYq:function(i,t){return i&t},aCdiu:function(i,t){return i<t},dWJiF:function(i,t){return i===t},tLbyN:n(353),gNFtP:n(733),rCVxb:function(i,t){return i!==t},naoGL:n(312),dzZHh:n(1556),QxgZr:"2|1|0|4|3",KFFgt:function(i,t){return i+t},DGQNo:function(i,t){return i+t},cCGbb:n(1528),irSXZ:function(i,t,r){return i(t,r)},UriAW:n(568)+"s",cKiTq:n(603)+n(1183)+"e",QwUse:function(i,t){return i(t)},QIKCR:function(i,t,r){return i(t,r)},QGsYJ:n(603)+"rsor_value",jaJyY:function(i){return i()},aURdb:function(i,t){return i>t},ygBus:function(i,t){return i+t},XhxHE:function(i){return i()},TcifN:function(i,t){return i&&t},nXvwc:function(i){return i()},dGtIm:function(i,t){return i(t)},WUmPq:function(i){return i()},HSddo:function(i){return i()},VzEwz:"always",pVolg:function(i,t){return i===t},DiXaT:n(1685),WJBAN:function(i,t,r){return i(t,r)},wknwJ:function(i,t){return i===t},efitb:function(i,t,r,a){return i(t,r,a)},vyORs:function(i,t,r){return i(t,r)},Yweio:function(i,t){return i===t},RqZaj:function(i,t,r){return i(t,r)},GnQMa:"bye",yFtHE:function(i,t,r){return i(t,r)},DRnPB:n(882)+n(849),QMNlb:n(1539),FVkxD:function(i,t){return i===t},danoK:n(500)+"rovide v"+n(1317),YsmSa:function(i,t){return i!==t},JVYdg:n(251),XBbLn:function(i,t){return i===t},MwUuB:n(199),OyQAb:n(1072),zzGuJ:function(i,t,r){return i(t,r)},HsckE:"stop immediately reconnect",uVcRl:n(949)+"4",isrTf:n(672),LNIxu:"https:",QOilA:n(1242),RyMjf:n(1698),SZSQk:"bd_did",eWOTU:"device_id",cIrPe:n(1187),mWGPS:n(498),UWbdU:n(1764)+"0",TvxsW:n(330)+"3|4",LCVOx:n(1657),zoSzS:n(1013),jmQpM:"count",tYLkW:function(i){return i()},EsKQM:n(496),bdiQm:"oxORc",fXmow:function(i,t){return i===t},khPaB:"VCIwc",HVWpW:function(i,t){return i!==t},FvJIT:n(1581),VcDTw:function(i,t){return i===t},qQyVv:function(i,t,r){return i(t,r)},OdMbP:"reconnect",jpwot:"start",bUxDN:function(i,t){return i>t},NfBRY:function(i,t,r){return i(t,r)},BuquL:function(i,t){return i!==t},RBUXF:n(1041),WMnhI:n(933),jtojW:function(i,t){return i(t)},iIiHH:"FRONTIER>",OhKug:function(i,t){return i>t},cvcqh:function(i,t,r){return i(t,r)},RdwyV:n(1731)+n(478)+n(576)+n(1213)+n(256),BfJPP:n(1541),kiFHI:n(956),SMGbY:function(i,t,r){return i(t,r)},hrlXj:n(1071)+" try rec"+n(549)+"g",fnruC:function(i,t){return i!=t},tYgDb:n(1166),ReBbA:function(i,t){return i(t)},qOPlV:function(i,t){return i===t},CjjOK:n(1194),yVgXe:n(866),woivg:n(1114)+"4",vocNj:function(i,t){return i===t},umWYp:n(1371),dhcCZ:n(580),ocBcr:n(1724),HCNDi:function(i,t,r){return i(t,r)},xYcyS:function(i,t,r){return i(t,r)},zqYOD:n(1731)+n(212)+n(1630)+n(340),pUhme:n(948),XCpyJ:n(988)+n(1451),OfEqP:"close, ws alread"+n(380),yaYQc:n(1662)+n(652)+n(1604)+"nitialized",PHnMf:function(i,t){return i==t},jhqBk:function(i,t){return i==t},fiUqY:n(228),yNXWV:function(i,t){return i instanceof t},nQkJs:function(i,t){return i(t)},KsZOA:function(i,t){return i(t)},gKUCm:function(i,t){return i(t)},DVMFy:n(500)+n(1483)+n(260)+n(270),cXPRr:function(i,t){return i===t},bfhyC:n(665),WxsID:n(1407),fWcxk:n(1107)+"0",xorjk:n(1740),YkyuD:"ping_onc"+n(802)+"t",XXKBc:function(i,t){return i(t)},qbwBN:n(1602),JZZpt:function(i,t){return i*t},CiDYH:function(i,t){return i*t},wxrex:function(i,t){return i!=t},UDqHQ:n(783),ZUwpN:function(i,t){return i===t},picLB:function(i,t){return i!=t},KmCVw:function(i,t){return i!=t},eTSYP:"Object",oAVAm:function(i,t){return i===t},HpkrL:n(258)+n(753)+"lobalScope",gLQry:function(i,t){return i===t},UIAZu:function(i,t){return i!=t},hjnZI:function(i,t){return i!=t},vXsVS:function(i,t){return i===t},OzBYQ:n(1021)+n(427)+n(690),pmcOV:function(i,t){return i!=t},GakRS:n(229)+n(639)};Fe.r(te),Fe.d(te,{FWS:()=>C0,CustomErrorEvent:()=>Xi,createCloseEvent:()=>De,ReconnectEvent:()=>Yi,createErrorEvent:()=>Ie,decodedFrame:()=>wt,createOpenEvent:()=>rs,CustomCloseEvent:()=>Qi,createReconnectEvent:()=>Rr,FrontierMessageEvent:()=>es,encodeFrame:()=>re,createMessageEvent:()=>ns,OpenEvent:()=>ts,ErrorCode:()=>Ze,Event:()=>bt,MessageEvent:()=>Zi});let s="";function o(i=""){let t=n,r="02",a=""+Date[t(1780)](),x=s||(s=p(i)),f=Math[t(1328)]()[t(1605)](16)[t(1424)](-6);return e[t(1073)](e.VFpvc(e.JduWO(r,a),x),f)}function c(){let i=n;return e[i(1696)](1e4*Date[i(1780)](),Math.floor(e.nmnpD(1e4,Math.random())))}function d(i){let t=n;return e.rRVsx(e[t(429)],e.rzloJ)?this[t(524)]?.[t(1657)](_0x5d634f):e[t(952)](e[t(1420)](Array,8).join("0"),e[t(1682)](parseInt,i,10).toString(2))[t(1424)](-8)}function u(i){let t=n;return(e[t(1420)](Array,4)[t(1453)]("0")+e[t(1265)](parseInt,i,2).toString(16))[t(1424)](-4)}function l(i){let t=n,r={tSqkV:e.cJSVZ,IrsYS:"error",MvNgu:e[t(610)]};if(e[t(1658)](e.bSNKF,"bzAHo")){let a=i[t(1413)](/\./)[t(754)](h=>d(h)),x=[];return x[0]=e[t(1420)](u,a[0]+a[1]),x[1]=u(a[2]+a[3]),["0000",e[t(1240)],e.TEPcf,t(237),e[t(1240)],e.YJNZl,x[0],x[1]][t(1453)]("")}else _0x18f454[t(605)+t(720)+t(396)](UYomjE.tSqkV,_0x3ad4ce),_0x3d67e5[t(605)+t(720)+t(396)](UYomjE[t(364)],_0x42b9b9),_0xd37e77[t(605)+"entListe"+t(396)](UYomjE.MvNgu,_0x461473)}function p(i){let t=n;if(e[t(1287)]!==t(1564)){let r=/(25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?)(\.(25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?)){3}/[t(1646)](i),a=/(([0-9a-fA-F]{1,4}:){7,7}[0-9a-fA-F]{1,4}|([0-9a-fA-F]{1,4}:){1,7}:|([0-9a-fA-F]{1,4}:){1,6}:[0-9a-fA-F]{1,4}|([0-9a-fA-F]{1,4}:){1,5}(:[0-9a-fA-F]{1,4}){1,2}|([0-9a-fA-F]{1,4}:){1,4}(:[0-9a-fA-F]{1,4}){1,3}|([0-9a-fA-F]{1,4}:){1,3}(:[0-9a-fA-F]{1,4}){1,4}|([0-9a-fA-F]{1,4}:){1,2}(:[0-9a-fA-F]{1,4}){1,5}|[0-9a-fA-F]{1,4}:((:[0-9a-fA-F]{1,4}){1,6})|:((:[0-9a-fA-F]{1,4}){1,7}|:)|fe80:(:[0-9a-fA-F]{0,4}){0,4}%[0-9a-zA-Z]{1,}|::(ffff(:0{1,4}){0,1}:){0,1}((25[0-5]|(2[0-4]|1{0,1}[0-9]){0,1}[0-9])\.){3,3}(25[0-5]|(2[0-4]|1{0,1}[0-9]){0,1}[0-9])|([0-9a-fA-F]{1,4}:){1,4}:((25[0-5]|(2[0-4]|1{0,1}[0-9]){0,1}[0-9])\.){3,3}(25[0-5]|(2[0-4]|1{0,1}[0-9]){0,1}[0-9]))/.test(i);return r?e[t(1420)](l,i):a?m(i):e[t(730)]}else{let r=new _0x3d89ca(e[t(1052)](e[t(1052)](e.dUFwd(e.cODZt(_0x2f35eb[e[t(1073)](_0x3debb6,4)],24),e[t(1048)](_0x287337[e[t(1073)](_0x313e2a,5)],16)),e[t(597)](_0x27207d[e.ZXIQJ(_0x3125e0,6)],8)),_0x3eeb57[e.cWIoB(_0x5c9782,7)]),e[t(370)](e[t(1529)](_0x38514a[_0x5cd7ab+0]<<24,_0x51f193[e[t(1155)](_0x4a165c,1)]<<16),e[t(597)](_0x52c0b8[e[t(1331)](_0x4c5122,2)],8))|_0x1cc812[_0x5c5ac8+3],!0);return _0x25dcd5+=8,{value:r,offset:_0x3d50f2+8}}}function m(i){let t=n,r={LAtsw:function(b){return e.isZZf(b)}},a="",x=[],f=0,h=0,w=!0,g=e[t(1240)];if(e[t(1223)](i[t(495)]("::"),-1)){let b=i.split("::");for(let C=0;C<b[t(796)];C++){let O=b[C];if(e[t(1223)](O[t(495)](":"),0)){let R=O.split(":");w&&(f=R.length),h+=R[t(796)];for(let F=0;e[t(308)](F,R[t(796)]);F++)if(e[t(1658)](4,R[F].length)){if(t(315)===e[t(819)])return this[t(443)+"hMessage"+t(1081)](_0x7b377a),r[t(574)](_0x394c37);{let ue=g.substring(0,4-R[F][t(796)]),be=ue[t(632)](R[F]);x[t(1774)](be)}}else x[t(1774)](R[F]);w=!1}else{if(e[t(1666)](4,O[t(796)])){let R=g[t(644)+"g"](0,e.evZjp(4,O[t(796)])),F=R[t(632)](O);x[t(1774)](F)}else x[t(1774)](O);w&&(f+=1),h+=1,w=!1}}let v="";for(let C=0;e[t(739)](C,e[t(303)](8,h));C++)v=v[t(632)](g);for(let C=0;e[t(739)](C,x.length);C++)e[t(846)](C,f)?(a=a.concat(v),a=a[t(632)](x[C])):a=a.concat(x[C]);return a}{let b=i[t(1413)](":");for(let v=0;e[t(995)](v,b.length);v++){let C=b[v];if(e.mYJtb(4,b[v][t(796)])){let O=g[t(644)+"g"](0,e[t(303)](4,b[v][t(796)])),R=O[t(632)](C);a=a.concat(R)}else a=a[t(632)](C)}return a}}function _(i,t){let r=n,a=i[r(1642)];e.rRVsx(void 0,a)&&(e.rufGw(V,t,10),e.ubtAk(le,t,a));let x=i.value;e[r(935)](void 0,x)&&(e[r(1265)](V,t,18),e[r(1739)](le,t,x))}function y(i){let t=n,r={};e:for(;!de(i);){let a=X(i);switch(a>>>3){case 0:break e;case 1:r.key=e[t(1452)](Z,i,X(i));break;case 2:r[t(916)]=e.OLuDN(Z,i,e[t(1420)](X,i));break;default:e[t(1546)](Q,i,e[t(1276)](7,a))}}if(e[t(528)](void 0,r[t(1642)]))throw new Error("Missing "+t(1096)+t(1578)+t(1642));if(e.uIoLH(void 0,r[t(916)]))throw new Error(e[t(914)]);return r}function I(i){let t=n,r=e[t(517)](se);return e[t(1594)](L,i,r),e[t(1568)](pe,r)}function L(i,t){let r=n,a=i[r(1755)];e[r(531)](void 0,a)&&(e[r(926)](V,t,8),e[r(584)](W,t,a));let x=i.LogID;e.ONXxT(void 0,x)&&(e.buKdY!==e[r(1068)]?(this._isBrowser&&_0x5a6942[r(605)+r(720)+r(396)](e.FxhDR,this[r(433)+"nLine"]),this[r(626)+"er"]&&_0x48a923[r(605)+r(720)+r(396)](e[r(589)],this[r(433)+"ffLine"]),this._isBrowser&&_0x3a2278[r(605)+r(720)+r(396)](e[r(722)],this[r(1211)+r(1722)]),this._isBrowser&&_0x1f4563[r(605)+r(720)+r(396)](e[r(885)],this[r(1211)+"ageShow"])):(e[r(694)](V,t,16),e[r(1594)](W,t,x)));let f=i[r(745)];e[r(1695)](void 0,f)&&(V(t,24),e[r(1690)](W,t,K(f)));let h=i[r(430)];h!==void 0&&(e[r(584)](V,t,32),e[r(1682)](W,t,e.hTdXc(K,h)));let w=i[r(951)];if(e.xpfen(void 0,w))for(let ue of w){V(t,42);let be=se();_(ue,be),V(t,be[r(1572)]),e.SXhvl(je,t,be),oe(be)}let g=i[r(900)+r(850)];if(g!==void 0)if(e.iigZA(e[r(1773)],e.iZtQg))e[r(1594)](V,t,50),le(t,g);else{let{pingInterval:ue,pingFrequency:be}=this[r(388)];if((_0x383365[r(1661)]==="hi"&&e.uIoLH(r(797),be)||e.uIoLH("auto",be))&&(this[r(375)+"ngTimer"](),this.emit(e.wVKst,e.dYxnU),this._pingPongTimeoutId=e[r(594)](_0x32a821,this._ping[r(854)](this),ue)),e.TgdQf("hi",_0x236811[r(1661)]))return;try{e[r(751)](_0x13e592,this,_0x14241f,[_0x12bf1c,_0x3b48f9,_0x290bf6,_0x1de593,_0x2a4943,_0x5c318f])}catch(Gt){let mn=e[r(1452)](_0x59fc4b,e[r(1214)],{message:Gt[r(1697)],code:_0x26d72b[r(1392)+r(269)],error:Gt});this[r(443)+"hErrorEvent"](mn)}}let b=i[r(384)+"ype"];e[r(1557)](void 0,b)&&(V(t,58),e[r(1247)](le,t,b));let v=i[r(1097)];e[r(432)](void 0,v)&&(e.qqiAR!==e[r(235)]?e[r(262)](_0x22fc90,_0x69e17e,this[r(1706)+r(444)+"e"](_0x2ddd49)):(e[r(1267)](V,t,66),e[r(1739)](V,t,v[r(796)]),e[r(1546)](ye,t,v)));let C=i[r(234)];e[r(1658)](void 0,C)&&(e.SXhvl(V,t,74),e[r(584)](le,t,C));let O=i[r(1727)+r(1699)];e[r(1557)](void 0,O)&&(e[r(1269)](V,t,82),e[r(1247)](le,t,O));let R=i[r(1765)];e[r(1387)](void 0,R)&&(e[r(845)](V,t,90),le(t,R));let F=i[r(1104)+"e"];e[r(1387)](void 0,F)&&(e[r(763)](V,t,96),e.WjLSS(W,t,e[r(1420)](K,F)))}function T(i){let t=n;return e[t(877)](P,e[t(1597)](Te,i))}function P(i){let t=n,r={};e:for(;!de(i);){let a=e[t(1420)](X,i);switch(a>>>3){case 0:break e;case 1:r[t(1755)]=e[t(594)](dt,i,!0);break;case 2:r.LogID=e[t(763)](dt,i,!0);break;case 3:r[t(745)]=e.mxQlT(X,i);break;case 4:r[t(430)]=e.yFSbq(X,i);break;case 5:{let x=e[t(877)](j,i);(r.headers||(r[t(951)]=[]))[t(1774)](e[t(1597)](y,i)),i.limit=x;break}case 6:r[t(900)+"ncoding"]=e[t(1269)](Z,i,e[t(877)](X,i));break;case 7:r.payloadType=Z(i,e.YtCcr(X,i));break;case 8:r[t(1097)]=z(i,e[t(677)](X,i));break;case 9:r[t(234)]=e[t(1267)](Z,i,X(i));break;case 10:r["serverTi"+t(1699)]=e.vAupn(Z,i,e.kODOc(X,i));break;case 11:r[t(1765)]=e[t(1268)](Z,i,e.YtCcr(X,i));break;case 12:r[t(1104)+"e"]=e[t(877)](X,i);break;default:Q(i,e[t(1276)](7,a))}}if(e[t(1459)](void 0,r[t(1755)]))throw new Error(e[t(1772)]);if(e[t(623)](void 0,r[t(1397)]))throw new Error(e[t(908)]);if(e[t(846)](void 0,r[t(745)]))throw new Error(e[t(696)]);if(e[t(528)](void 0,r[t(430)]))throw new Error(e[t(1718)]);return r}function j(i){let t=n,r=e[t(436)](X,i),a=i.limit;return i[t(1572)]=i.offset+r,a}function Q(i,t){let r=n;if(e[r(1557)](e.sDPXq,e[r(680)]))this[r(285)+"ndpointT"+r(1522)+"t"]=0;else switch(t){case 0:for(;128&ne(i););break;case 2:e[r(1020)](xe,i,e.IQtpa(X,i));break;case 5:xe(i,4);break;case 1:xe(i,8);break;default:throw new Error(e[r(1687)](e[r(811)],t))}}function K(i){let t=n;return i|=0,{low:i,high:i>>31,unsigned:e[t(405)](i,0)}}let $=[];function se(){let i=n,t=$[i(1466)]();return t?(t[i(397)]=t[i(1572)]=0,t):{bytes:new Uint8Array(64),offset:0,limit:0}}function oe(i){$.push(i)}function Te(i){return{bytes:i,offset:0,limit:i[n(796)]}}function pe(i){let t=n,r=i[t(1582)],a=i[t(1572)];return r.length===a?r:r[t(993)](0,a)}function xe(i,t){let r=n;if(e[r(361)](i[r(397)],t)>i[r(1572)])throw new Error(e[r(984)]);i[r(397)]+=t}function de(i){let t=n;if(e[t(1094)](e[t(901)],e[t(901)]))Pqqzol[t(1689)](_0x4ae0d5),Pqqzol[t(698)](_0x52811e);else return e[t(1289)](i[t(397)],i.limit)}function A(i,t){let r=n,a=i[r(1582)],x=i[r(397)],f=i[r(1572)],h=x+t;if(e[r(1223)](h,a[r(796)]))if(e[r(1169)]===e[r(1169)]){let w=new Uint8Array(e[r(612)](2,h));w[r(1651)](a),i.bytes=w}else return this._qosDB.clear();return i.offset=h,h>f&&(i.limit=h),x}function N(i,t){let r=n,a=i[r(397)];if(e.ZPPWU(a,t)>i.limit)throw new Error(e[r(1115)]);return i[r(397)]+=t,a}function z(i,t){let r=n,a=N(i,t);return i[r(1582)][r(993)](a,e[r(357)](a,t))}function ye(i,t){let r=n,a=e[r(355)](A,i,t.length);i[r(1582)][r(1651)](t,a)}function Z(i,t){let r=n,a=N(i,t),x=String["fromChar"+r(1700)],f=i[r(1582)],h="\uFFFD",w="";for(let g=0;e[r(1218)](g,t);g++){let b=f[e[r(1553)](g,a)],v,C,O,R;if(e[r(648)](128&b,0))w+=e[r(677)](x,b);else if(e[r(1276)](224,b)===192)e[r(871)](e[r(230)](g,1),t)?w+=h:(v=f[e[r(488)](e[r(1106)](g,a),1)],e[r(750)](192&v,128)?w+=h:(R=e[r(1048)](e[r(1276)](31,b),6)|e[r(1276)](63,v),e[r(739)](R,128)?w+=h:(w+=e.WFiaS(x,R),g++)));else if(e[r(1571)](e[r(1475)](240,b),224))e.lQtqS(g+2,t)?w+=h:(v=f[e[r(1757)](e.boCKR(g,a),1)],C=f[e[r(1106)](g,a)+2],e[r(1276)](e[r(1052)](v,C<<8),49344)!==32896?w+=h:(R=e[r(1529)](e[r(1529)](e[r(1048)](e[r(1475)](15,b),12),e[r(1616)](63&v,6)),e[r(1475)](63,C)),e[r(995)](R,2048)||e[r(1289)](R,55296)&&e[r(337)](R,57343)?w+=h:(w+=e.zMxJO(x,R),g+=2)));else if(e[r(1571)](248&b,240))if(e[r(405)](e[r(1696)](g,3),t))w+=h;else if(r(1441)==="FFghN")if(v=f[e[r(357)](e[r(361)](g,a),1)],C=f[e[r(488)](e[r(1045)](g,a),2)],O=f[e[r(775)](g,a)+3],e[r(1139)](e[r(1202)](e.kRSkV(v,e.cODZt(C,8))|e[r(1396)](O,16),12632256),8421504))w+=h;else if(R=e[r(839)]((7&b)<<18|e[r(1202)](63,v)<<12|e[r(1202)](63,C)<<6,63&O),e.Ttnud(R,65536)||R>1114111)w+=h;else if(e.QtiqQ(e[r(837)],e[r(837)]))R-=65536,w+=e[r(594)](x,e[r(334)](R>>10,55296),e[r(983)](e.FQrNb(1023,R),56320)),g+=3;else{let F=this[r(524)].getItem(this._prefix),ue=_0x5ad08d[r(636)](F||"{}");return ue[_0x14a0fc]=void 0,this[r(524)][r(824)](this[r(1479)],_0x482e2d.stringify(ue))}else{let F=this._qosDB[r(421)+"geInfoSync"](this._prefix),ue=_0x178d98[r(636)](e.wMoQE(F,"{}"));return _0x52e77d[r(1561)](ue)}else w+=h}return w}function le(i,t){let r=n,a=t[r(796)],x=0;for(let w=0;e[r(308)](w,a);w++){let g=t[r(1380)+"At"](w);g>=55296&&e[r(1633)](g,56319)&&e[r(878)](w,1)<a&&(g=e.gbugi(e.afaVg(e.LIKtY(g,10),t[r(1380)+"At"](++w)),56613888)),x+=g<128?1:e.Ictyw(g,2048)?2:g<65536?3:4}V(i,x);let f=e.bDTmC(A,i,x),h=i[r(1582)];for(let w=0;e[r(739)](w,a);w++){let g=t[r(1380)+"At"](w);g>=55296&&g<=56319&&e[r(995)](w+1,a)&&(g=e.IGafw(g,10)+t[r(1380)+"At"](++w)-56613888),g<128?h[f++]=g:(e[r(995)](g,2048)?h[f++]=e[r(335)](e[r(200)](g,6)&31,192):(e[r(308)](g,65536)?h[f++]=e[r(886)](e[r(1410)](e[r(1231)](g,12),15),224):(h[f++]=e[r(1476)](g>>18,7)|240,h[f++]=e[r(1475)](g>>12,63)|128),h[f++]=e[r(604)](e[r(1231)](g,6)&63,128)),h[f++]=e[r(335)](e[r(1410)](63,g),128))}}function je(i,t){let r=n,a=e.vIHDf(A,i,t.limit),x=i[r(1582)],f=t[r(1582)];for(let h=0,w=t[r(1572)];h<w;h++)x[e[r(954)](h,a)]=f[h]}function ne(i){return i[n(1582)][e.gbHXj(N,i,1)]}function Xe(i,t){let r=n,a=e[r(1e3)](A,i,1);i[r(1582)][a]=t}function X(i){let t=n,r=0,a=0,x;do x=e[t(877)](ne,i),e.dZigs(r,32)&&(a|=e[t(1616)](e[t(366)](127,x),r)),r+=7;while(e.UVtKw(128,x));return a}function V(i,t){let r=n;for(t>>>=0;e.WzgvL(t,128);)e[r(474)](Xe,i,e[r(839)](e[r(649)](127,t),128)),t>>>=7;e[r(694)](Xe,i,t)}function dt(i,t){let r=n,a=0,x=0,f=0,h;return h=e.KOkJH(ne,i),a=e[r(1476)](127,h),e[r(1276)](128,h)&&(h=e.dZXhc(ne,i),a|=e[r(1048)](127&h,7),e[r(386)](128,h)&&(h=e[r(465)](ne,i),a|=(127&h)<<14,e[r(1352)](128,h)&&(h=e[r(1568)](ne,i),a|=e[r(1351)](127&h,21),e[r(1410)](128,h)&&(h=ne(i),x=e[r(649)](127,h),128&h&&(h=e[r(1400)](ne,i),x|=e.IGafw(e[r(1352)](127,h),7),e[r(1475)](128,h)&&(h=e.BbYpg(ne,i),x|=e.snlqI(127,h)<<14,e.FosZq(128,h)&&(h=ne(i),x|=e[r(1756)](127&h,21),e.mnrEh(128,h)&&(h=ne(i),f=e[r(649)](127,h),128&h&&(h=e[r(1447)](ne,i),f|=e[r(1351)](127&h,7)))))))))),{low:e[r(1322)](a,e.KzJmd(x,28)),high:e[r(795)](x,4)|e[r(1756)](f,24),unsigned:t}}function W(i,t){let r=n,a=e[r(795)](t[r(1454)],0),x=e[r(857)](e[r(1720)](t[r(1454)],28),e[r(257)](t.high,4))>>>0,f=e[r(1720)](t.high,24),h=e.ZGymV(0,f)?e.ZGymV(0,x)?e[r(1218)](a,16384)?e.qiQqS(a,128)?1:2:a<2097152?3:4:e[r(308)](x,16384)?x<128?5:6:e[r(1336)](x,2097152)?7:8:f<128?9:10,w=e[r(1671)](A,i,h),g=i[r(1582)];switch(h){case 10:g[e[r(230)](w,9)]=e[r(366)](e.sJzUD(f,7),1);case 9:g[e[r(1106)](w,8)]=e[r(553)](9,h)?e[r(792)](128,f):e.PGDSt(127,f);case 8:g[e[r(954)](w,7)]=e[r(879)](8,h)?e[r(1221)](x,21)|128:e.UrDnl(x>>>21,127);case 7:g[e[r(596)](w,6)]=e[r(1264)](7,h)?e.dUFwd(e[r(313)](x,14),128):e[r(1614)](x>>>14,127);case 6:g[w+5]=e[r(432)](6,h)?e[r(1529)](e.RXmKe(x,7),128):e[r(402)](e.nstmr(x,7),127);case 5:g[e.afaVg(w,4)]=e[r(514)](5,h)?e[r(1446)](128,x):e[r(366)](127,x);case 4:g[e[r(1600)](w,3)]=e[r(1370)](4,h)?e.sJQVs(e[r(1720)](a,21),128):e[r(1098)](e[r(1221)](a,21),127);case 3:g[w+2]=e.bINry(3,h)?e.mLbXF(e[r(313)](a,14),128):e[r(386)](e.sJJmk(a,14),127);case 2:g[e[r(533)](w,1)]=e[r(1133)](2,h)?e[r(945)](e[r(475)](a,7),128):e[r(1488)](e[r(475)](a,7),127);case 1:g[w]=e[r(676)](1,h)?128|a:e[r(1089)](127,a)}}function wt(i){return e[n(677)](T,i)}function re(i){let t=n;return e[t(352)](e[t(1238)],t(703))?e[t(841)](I,i):new _0x3ac472(_0x4860a6)}let _t=65536,we=e[n(1076)],yt=e[n(816)](_t,_t),Ji=e.CiDYH(yt,yt),$i=Ji/2,Qe=String[n(1349)+"e"][n(1380)+"At"];class G{constructor(t,r,a){let x=n;this.isLong=!0,this[x(1454)]=e[x(857)](0,t),this[x(1070)]=0|r,this[x(1381)]=!!a}static[n(872)](t){let r=n;return e.ysgAY(e[r(1257)],r(276))?(_0x3b3c93[r(928)+"t8"]?_0x336196.writeUint8(_0x380e05,_0x15e096):_0x141be5[_0x34d144]=e[r(366)](255,_0xad7737),e.aIgLb(_0x1800ce,1)):t&&e[r(573)](!0,t[r(872)])}static fromBits(t,r,a){let x=n;if(e.UFkrD(e.nXJsU,x(647)))return new G(t,r,a);_0x15e9ec[x(1298)+x(598)]="",_0x50ce6f[x(905)](_0x116672)}static[n(683)+"s"](t,r,a){let x=n;return a?G[x(683)+x(1282)](t,r):G[x(683)+x(295)](t,r)}static["fromByte"+n(1282)](t,r){let a=n;return new G(e.PYIno(e[a(945)](t[0],e.vmYvg(t[1],8)),e[a(1751)](t[2],16))|e.VhytP(t[3],24),e[a(857)](e[a(1385)](t[4]|e.acLsI(t[5],8),e.vmYvg(t[6],16)),e[a(1047)](t[7],24)),r)}static[n(683)+n(295)](t,r){let a=n;return new G(e[a(370)](e[a(839)](e[a(945)](t[4]<<24,t[5]<<16),e[a(1309)](t[6],8)),t[7]),e[a(490)](e.pjwBj(e[a(969)](t[0],24),e[a(431)](t[1],16))|e.laEra(t[2],8),t[3]),r)}static[n(254)](t){let r=n;return e[r(1305)](t,we)?Vi:new G(e[r(1469)](e[r(1175)](e[r(335)](Qe.call(t,0)|e.gsmKZ(Qe.call(t,1),8),e[r(507)](Qe.call(t,2),16)),e.amInm(Qe[r(1182)](t,3),24)),0),e[r(335)](e[r(888)](e[r(792)](Qe[r(1182)](t,4),Qe[r(1182)](t,5)<<8),e[r(1105)](Qe.call(t,6),16)),e[r(1047)](Qe[r(1182)](t,7),24))>>>0,!0)}toHash(){let t=n;return String[t(861)+t(1700)](e[t(268)](255,this[t(1454)]),e[t(386)](this[t(1454)]>>>8,255),e[t(1410)](this.low>>>16,255),e.ntRPE(this.low,24),e[t(366)](255,this[t(1070)]),e.RXmKe(this.high,8)&255,e[t(1276)](e.xKSHS(this[t(1070)],16),255),e[t(343)](this.high,24))}static fromNumber(t,r=!0){let a=n,x={QqTJx:function(f,h){return e[k(1609)](f,h)}};if(e[a(1362)](e[a(963)],e.ZqQGg)){if(isNaN(t))return r?Fc:Vi;if(r)if(e[a(1762)](e[a(300)],e[a(403)])){if(t>=Ji)return qc}else this["_miniNavigatorOn"+a(728)]=_0x3e4c80,_0x15a92d?this[a(433)+a(818)]():this["_handleO"+a(719)]();else if(a(664)===e[a(829)]){if(e[a(752)](t,-$i))return Hc;if(e[a(985)](t,1)>=$i)return Uc}else e[a(1100)](_0xb594b3,this[a(377)+a(653)+"Id"]),_0x510da0(this["_reconne"+a(1010)+a(1421)]),this["_pingPon"+a(653)+"Id"]=null,this[a(1511)+a(1010)+a(1421)]=null;return G[a(629)](e[a(1175)](e[a(551)](t,yt),0),e[a(1179)](e.VkpSl(t,yt),0),r)}else return x.QqTJx(0,this[a(1070)])&&x.QqTJx(0,this[a(1454)])}[n(1173)](){let t=n,r={gkLqL:e[t(814)],XJRWm:function(a,x){return e.qiQqS(a,x)},udEdu:function(a,x){return e[t(1052)](a,x)},kUcfp:function(a,x){return e[t(931)](a,x)},TIFfH:function(a,x){return a<<x},Wpnvz:function(a,x){return e.GQXMe(a,x)},uRHSR:function(a,x){return e[t(1674)](a,x)},ZotzD:function(a,x){return a|x},mIxLP:function(a,x){return e.sXkKB(a,x)},PUYHB:function(a,x){return e[t(1352)](a,x)},ugHCi:function(a,x){return e[t(1389)](a,x)}};if(e[t(400)](e[t(1361)],e.VPNQN))return this[t(1381)]?e[t(348)](e[t(1108)](e.ntRPE(this[t(1070)],0),yt),e[t(795)](this[t(1454)],0)):e.DbnXW(e[t(612)](this[t(1070)],yt),e[t(313)](this[t(1454)],0));{let a={xKmmF:r[t(939)],XSbUh:function(f,h){return r.XJRWm(f,h)},fXeiG:function(f,h){return r[t(1358)](f,h)},UpKdM:function(f,h){return r[t(322)](f,h)},TNGMk:function(f,h){return r[t(1752)](f,h)},wTsxy:function(f,h){return r[t(1555)](f,h)},ZKRqe:function(f,h){return r[t(1747)](f,h)},TlYGy:function(f,h){return r[t(1358)](f,h)},wkMiO:function(f,h){return r[t(925)](f,h)},PuHMT:function(f,h){return r[t(1018)](f,h)},JMdDF:function(f,h,w,g){return f(h,w,g)},CdFQr:function(f,h){return f>>>h},GlciK:function(f,h){return f<<h},hjNcT:function(f,h){return r[t(1738)](f,h)},iMzps:function(f,h){return f|h},dypVO:function(f,h){return r[t(1573)](f,h)}},x=4294967295;return function(f,h,w=!0){let g=t,b=a.xKmmF[g(1413)]("|"),v=0;for(;;){switch(b[v++]){case"0":if(a[g(955)](f[h++],128))return{value:w?x:a[g(1497)](0,x),offset:h};continue;case"1":x=a[g(246)](x|a[g(1782)](a[g(1625)](15,f[h]),28),0);continue;case"2":if(a.XSbUh(f[h++],128))return{value:w?x:a[g(206)](0,x),offset:h};continue;case"3":if(f[h++]<128)return{value:w?x:a[g(1254)](0,x),offset:h};continue;case"4":x=a[g(246)](a[g(1497)](x,a[g(1782)](a[g(1625)](127,f[h]),7)),0);continue;case"5":if(a[g(955)](f[h++],128))return{value:w?x:a[g(1113)](0,x),offset:h};continue;case"6":if(a[g(1654)](h+=5,f[g(796)]))throw h=f[g(796)],a[g(493)](_0x40c2a6,h,10,f[g(796)]);continue;case"7":x=a[g(972)](a[g(1497)](x,a[g(296)](a[g(625)](127,f[h]),21)),0);continue;case"8":return{value:w?x:0|x,offset:h};case"9":if(f[h++]<128)return{value:w?x:a.iMzps(0,x),offset:h};continue;case"10":x=a[g(1625)](127,f[h])>>>0;continue;case"11":x=a.dypVO(x|a[g(1782)](127&f[h],14),0);continue}break}}}}[n(1431)](){let t=n;return e.vROgl(0,this.high)&&e[t(352)](0,this[t(1454)])}[n(1536)](t){let r=n;if(r(595)===e[r(1083)]){if(e[r(1571)](e[r(980)],typeof _0x3d2d87)){let a=new _0x19a5e0(e[r(1659)](_0x17e9e5,_0x54db3b));return e[r(526)](_0x16349f,_0x2b4205,a,0),a}return e[r(210)](_0x3f8e0d,_0x7acd5b)?new _0x1dbf12(_0x5a58e7):new _0x11b4db(_0x2d29b5[r(1054)],_0x3bdca0[r(1085)+"et"],_0x24c83d[r(1062)+"th"])}else{G.isLong(t)||(t=G.fromNumber(t));let a=e.ntRPE(this[r(1070)],16),x=65535&this[r(1070)],f=e[r(572)](this.low,16),h=e[r(386)](65535,this[r(1454)]),w=t[r(1070)]>>>16,g=e[r(732)](65535,t.high),b=e[r(931)](t[r(1454)],16),v=e[r(386)](65535,t[r(1454)]),C=0,O=0,R=0,F=0;return F+=e.Zjnes(h,v),R+=e[r(915)](F,16),F&=65535,R+=e[r(746)](f,b),O+=R>>>16,R&=65535,O+=e[r(533)](x,g),C+=O>>>16,O&=65535,C+=e[r(746)](a,w),C&=65535,G[r(629)](e[r(1446)](R<<16,F),e[r(597)](C,16)|O,this[r(1381)])}}[n(902)](t){let r=n;return G[r(872)](t)||(t=G[r(764)+"er"](t)),e[r(1133)](this[r(1381)],t[r(1381)])&&e[r(1596)](e[r(1221)](this.high,31),1)&&e.qrmhn(t[r(1070)],31)===1?!1:this[r(1070)]===t[r(1070)]&&e[r(846)](this[r(1454)],t[r(1454)])}[n(552)](){let t=n;return this[t(1454)]===-1&&e.VcCdt(-1,this[t(1070)])?G[t(629)](0,0,this[t(1381)]):e[t(227)](-1,this[t(1454)])?G[t(629)](0,e[t(985)](this.high,1),this[t(1381)]):G[t(629)](e[t(1004)](this[t(1454)],1),this[t(1070)],this[t(1381)])}[n(1785)](t){let r=n;return t?this[r(1249)+"E"]():this[r(1136)+"E"]()}[n(1249)+"E"](){let t=n,r=this.high,a=this[t(1454)];return[255&a,e[t(263)](e[t(411)](a,8),255),e.KVkhV(e[t(645)](a,16),255),a>>>24,e[t(1352)](255,r),e[t(1221)](r,8)&255,e[t(366)](e[t(834)](r,16),255),e.dCxNh(r,24)]}[n(1136)+"E"](){let t=n,r=this.high,a=this.low;return[e[t(645)](r,24),e[t(1475)](e.jtrot(r,16),255),e[t(1488)](e[t(216)](r,8),255),e[t(366)](255,r),e[t(216)](a,24),e[t(1154)](a>>>16,255),e[t(571)](a>>>8,255),255&a]}}let Vi=new G(0,0,!1),Fc=new G(0,0,!0),Uc=G[n(629)](-1,2147483647,!1),qc=G[n(629)](-1,-1,!0),Hc=G[n(629)](0,-2147483648,!1);var Ze=(function(i){let t=n;return i[i[e[t(1406)]]=5001]=e.hYWnN,i[i[e[t(800)]]=5002]=e[t(800)],i[i[e[t(994)]]=5003]=e.pFqlB,i[i[e[t(473)]]=5004]=e[t(473)],i[i[e[t(1376)]]=5005]=e[t(1376)],i})({});class bt{constructor(t){let r=n;this.type=t,this[r(1134)]=null}}class Yi extends bt{constructor(t,r){let a=n;super(t),this[a(1697)]=r&&r[a(1697)]||null}}class Xi extends bt{constructor(t,r){let a=n,x=e[a(1341)].split("|"),f=0;for(;;){switch(x[f++]){case"0":this[a(321)]=r&&r.error||null;continue;case"1":this.filename=r&&r.filename||"";continue;case"2":this[a(1697)]=r&&r[a(1697)]||"";continue;case"3":this[a(937)]=r&&r.lineno||0;continue;case"4":super(t);continue;case"5":this[a(1140)]=r&&r.colno||0;continue;case"6":this[a(1532)]=r&&r[a(1532)]||5001;continue}break}}}class Qi extends bt{constructor(t,r){let a=n,x={HKlaD:function(f,h,w){return f(h,w)},rVIJE:function(f){return e[k(1689)](f)},AmkrN:function(f,h,w){return e[k(365)](f,h,w)},cSzWs:function(f,h){return e.wRshH(f,h)}};if(e[a(1011)]===e[a(1011)]){let f=e[a(1636)].split("|"),h=0;for(;;){switch(f[h++]){case"0":this.reason=r&&r[a(723)]||"";continue;case"1":super(t);continue;case"2":this.code=r&&r[a(1532)]||0;continue;case"3":this[a(1432)+a(287)]=r&&r[a(1432)+a(287)]||!1;continue;case"4":this[a(1587)]=r&&r.wasClean||!1;continue}break}}else{cwcUjk[a(329)](_0x384fff,_0x4a0f3a,42);let f=cwcUjk[a(281)](_0x4ffe0a);cwcUjk[a(329)](_0x39d82e,_0x13e119,f),cwcUjk[a(1460)](_0x324db3,_0x587a34,f.limit),_0x5246e2(_0x4dbf76,f),cwcUjk.cSzWs(_0x737f68,f)}}}class Zi extends bt{constructor(t,r){let a=n;if(e[a(502)](e[a(499)],e.arJQq))super(t),this[a(1661)]=r&&r[a(1661)]||null;else return new _0x506ca9(_0x562cf7,{data:_0x51a9a0})}}class es extends Zi{constructor(t,r){let a=n;super(t),this[a(1661)]=r&&r[a(1661)]||null,this.message=r&&r[a(1697)]||null}}class ts extends bt{constructor(t,r){let a=n;super(t),this[a(1661)]=r&&r[a(1661)]||null}}function Ie(i,{message:t,code:r,error:a}){return new Xi(i,{message:t,code:r,error:a})}function De(i,{code:t,reason:r,wasClean:a,willReconnect:x}){return new Qi(i,{code:t,reason:r,wasClean:a,willReconnect:x})}function ns(i,{data:t,message:r}){let a=n,x={weHml:function(f,h){return e.Najbj(f,h)},PUDcG:e[a(1712)]};if(e[a(1230)]!==e[a(1084)])return new es(i,{data:t,message:r});if(_0x48e302)return new _0x44e7f3(_0xa590fd[a(1781)],_0x11f697[a(1408)]);if(x[a(1330)](_0x3a37c6,_0x50654f))return new _0x2fcea8(_0x2c1a30[a(1781)],_0x4b71c0[a(1408)],_0xbd76c8[a(951)]);if(x[a(1330)](_0xcb1442,_0x554326)&&x[a(492)]!=typeof _0x14a1ee&&_0x567c99)return new _0xebee8e(_0x125bc5.url,_0x1ea8a8.protocols)}function rs(i,{data:t}){return new ts(i,{data:t})}function Rr(i,{message:t}){return new Yi(i,{message:t})}class is{constructor(t,r){let a=n,x={NSIjW:function(f,h){return e[k(1596)](f,h)},wuOFY:e[a(1214)],UMFmE:function(f,h){return e.ktGgA(f,h)},dtrNr:function(f,h){return f+h},MmWGO:a(1150)+a(1433),FmDXs:function(f,h){return e.fOzds(f,h)},gQmfx:function(f,h){return e.ELJdu(f,h)}};if(e[a(855)]!==e[a(855)]){let f=this[a(1750)+"rs"][_0x207960];if(f)f[a(1424)]()[a(1519)](h=>h.fn[a(1063)](h[a(419)],_0x29e240));else if(x[a(1693)](x.wuOFY,_0x227c35)&&!this.onerror){let h=_0x2343aa.length&&_0x206dd4[0];if(x[a(376)](h,_0x3d744a))throw h;let w=new _0x2e1ef3(x[a(1643)](x[a(1726)],h?x[a(946)](x.gQmfx(" (",h[a(1697)]),")"):""));throw w[a(446)]=h,h}return this}else this[a(464)+"s"]=t,this[a(1032)+"es"]=r,this[a(756)+a(1471)]=0,this[a(285)+a(327)+"riesCount"]=0}[n(226)+n(404)+"fig"](){let t=n,r={vPYIO:function(a,x,f){return a(x,f)},qOUpC:function(a,x){return e[k(1438)](a,x)},oBoPx:function(a,x){return e[k(842)](a,x)}};if(t(482)!==t(482)){let a=0,x=_0x15824d,f=_0x169cda+4;for(;x<f;){let{value:h,offset:w}=r.vPYIO(_0x363b4e,_0x4258ae,x);x=w,a=r[t(394)](r[t(1028)](a,8),0),a+=h}return{value:a,offset:f}}else this[t(756)+t(1471)]=0,this[t(285)+"ndpointT"+t(1522)+"t"]=0}resetTries(){let t=n;this[t(285)+t(327)+t(1522)+"t"]=0}[n(695)+n(1180)+"nt"](){let t=n;return this[t(464)+"s"][this[t(756)+"ndex"]]}[n(695)+n(1180)+"ntTriesC"+n(1053)](){let t=n;return this["currentE"+t(327)+t(1522)+"t"]}[n(874)+"chMaxTries"](){let t=n;return!!(e[t(1289)](this["currentI"+t(1471)],this[t(464)+"s"][t(796)])||e[t(236)](this.currentIndex,e[t(1526)](this[t(464)+"s"][t(796)],1))&&this[t(285)+"ndpointT"+t(1522)+"t"]===this[t(1032)+"es"])}["checkCurrentEndp"+n(345)+n(325)+n(1055)](){let t=n;if(e.gzVnK(t(876),"VsvIk"))this[t(657)](_0x302b7c,_0x59e9c9);else return this[t(756)+t(1471)]==this[t(464)+"s"][t(796)]?!0:e.SFxCa(this["currentE"+t(327)+t(1522)+"t"],this[t(1032)+"es"])}[n(286)+n(1445)+n(1624)+"UpdateCo"+n(825)](){let t=n,r={EGsas:function(a,x){return e[k(1568)](a,x)}};if(e[t(771)]!==e[t(771)])eVpmRq[t(1311)](_0x402e66,eVpmRq.EGsas(_0x60e083,_0x47ae1f[t(679)])),_0x3dcbbe();else return this[t(285)+t(327)+t(1522)+"t"]=1,this.currentIndex++,this[t(464)+"s"][this[t(756)+"ndex"]]}["getCurre"+n(1180)+n(459)+n(600)](){let t=n;return this[t(285)+t(327)+t(1522)+"t"]++,this[t(695)+t(1180)+"nt"]()}}let vt=(e[n(1201)](e[n(1712)],typeof globalThis)&&e[n(456)]===globalThis.constructor.name||e.IRDTh!=typeof window&&e[n(1652)](e[n(456)],window[n(379)+"tor"][n(310)]))&&e.picLB(e[n(1712)],typeof document),ut=e[n(740)](e[n(1712)],typeof globalThis)&&(e[n(747)]===globalThis["construc"+n(1492)][n(310)]||e.oAVAm(e[n(575)],globalThis[n(379)+n(1492)][n(310)]))&&e[n(1201)](e.IRDTh,typeof tt),jt=(e[n(835)](e[n(1712)],typeof globalThis)&&e[n(1188)](e[n(747)],globalThis["construc"+n(1492)][n(310)])||e.tWTOO(e[n(1712)],typeof globalThis)||e[n(1712)]!=typeof globalThis&&!!globalThis[n(1705)+"Bridge"])&&e.UIAZu(e.IRDTh,typeof wx),Kt=e[n(1435)](e[n(1712)],typeof globalThis)&&(e[n(1023)](n(258)+n(753)+n(1462)+"pe",globalThis[n(379)+n(1492)][n(310)])||e.VcDTw(n(1692)+n(909)+n(1653),globalThis[n(379)+n(1492)].name)||e[n(1165)](e[n(1037)],globalThis["construc"+n(1492)][n(310)]))&&e.MyIFR(e.IRDTh,typeof self),jc=e[n(450)](e.IRDTh,typeof globalThis)&&e[n(747)]===globalThis[n(379)+n(1492)][n(310)]&&e[n(742)](e.IRDTh,typeof global)&&e[n(747)]===global[n(379)+"tor"][n(310)]&&e[n(1435)](e[n(1712)],typeof process)&&!!process[n(1515)];class Lr{constructor(){let t=n;e[t(328)](e.LEVLa,e[t(1093)])?this[t(1750)+"rs"]={}:(this[t(872)]=!0,this.low=0|_0x223b4b,this[t(1070)]=e[t(1463)](0,_0x19b3d5),this[t(1381)]=!!_0x138753)}[n(1216)](t,...r){let a=n,x=this._listeners[t];if(x)x[a(1424)]()[a(1519)](f=>f.fn[a(1063)](f.ctx,r));else if(e.okwUm(a(321),t)&&!this[a(440)]){let f=r[a(796)]&&r[0];if(e[a(457)](f,Error))throw f;let h=new Error(e[a(1374)](e[a(215)],f?e[a(1280)](e[a(368)](" (",f[a(1697)]),")"):""));throw h[a(446)]=f,f}return this}[n(657)](t,r){let a=n;if(t===void 0)this[a(1750)+"rs"]={};else if(e[a(1486)](void 0,r))this[a(1750)+"rs"][t]=null;else if(e.RXaMB(e.OTgtC,e[a(1283)])){let x=this._listeners[t];if(x)for(let f=0;e[a(995)](f,x[a(796)]);)e[a(1023)](x[f].fn,r)?x.splice(f,1):++f}else _0xf3c3.resolve()[a(317)](()=>{this[a(718)+"steners"]()});return this}on(t,r,a){let x=n;return(this._listeners[t]||(this[x(1750)+"rs"][t]=[]))[x(1774)]({fn:r,ctx:a||this}),this}}class Kc extends Lr{[n(1015)+n(602)+n(1122)](t){let r=n;return t[r(1049)]||t.errNo?(r(271)+" "+(t[r(1049)]||"")+r(1290)+(t[r(1220)]||""))[r(274)]():JSON[r(1577)+"y"](t)}constructor(t,r,a){let x=n;super(),this[x(958)]=null,jt&&wx[x(525)+x(1592)]&&(this[x(958)]=wx[x(525)+x(1592)]({url:t,protocols:r,header:a,fail:this[x(1461)+"ocketFai"+x(565)][x(854)](this),success:this["_createS"+x(1590)+"cessHand"+x(359)].bind(this)})),ut&&tt[x(525)+x(1592)]&&(this[x(958)]=tt[x(525)+x(1592)]({url:t,protocols:r,header:a,fail:this[x(1461)+x(1711)+x(565)][x(854)](this),success:this[x(1461)+x(1590)+x(255)+x(359)].bind(this)}))}[n(1461)+"ocketSuc"+n(255)+n(359)](){let t=n;Promise[t(1143)]()[t(317)](()=>{let r=t,a={ufczK:function(x,f){return x|f},qTEiY:function(x,f){return x&f},ZoVWl:function(x,f){return e[k(964)](x,f)},xeXsV:function(x,f){return e[k(839)](x,f)},qEbcA:function(x,f){return x>>f},kUdXB:function(x,f){return x|f},IUeln:function(x,f){return x>>f},tsQnp:function(x,f){return x|f},JdczC:function(x,f){return e[k(945)](x,f)}};e[r(1429)]===r(1285)?(_0x3134a5<2048?_0x379969[_0x39894b++]=JqBswd[r(1205)](_0x236734>>6&31,192):(_0x2e17ec<65536?_0x3b2084[_0x5639a4++]=JqBswd[r(484)](JqBswd[r(1219)](_0x5b0c5f,12),15)|224:(_0x20b195[_0x406a5e++]=JqBswd[r(826)](JqBswd[r(484)](JqBswd[r(1401)](_0x5b2c51,18),7),240),_0x1dd279[_0x1733ea++]=JqBswd.kUdXB(JqBswd.IUeln(_0x1bcd3e,12)&63,128)),_0x43cd06[_0x1b1166++]=JqBswd[r(1640)](JqBswd[r(484)](_0x448382>>6,63),128)),_0x5444ba[_0x384e09++]=JqBswd.JdczC(JqBswd[r(484)](63,_0x17b301),128)):this[r(718)+r(1195)]()})}[n(1461)+n(1711)+"lHandler"](t){let r=n,a={EUdkz:function(x,f,h){return e[k(1741)](x,f,h)},Ncrof:e[r(1214)],hxnMz:e[r(587)]};e[r(1627)](e[r(1281)],e[r(978)])?(_0x1ae29d[r(692)+r(1422)]=void 0,e[r(758)](_0x218ae3,e[r(765)])):Promise[r(1143)]()[r(317)](()=>{let x=r,f=a[x(616)](Ie,x(321),{message:this[x(1015)+x(602)+"age"](t)});this[x(1216)](a[x(1087)],f);let h=De(a.hxnMz,{reason:this[x(1015)+x(602)+x(1122)](t)});this[x(1216)]("close",h)})}[n(718)+"steners"](){let t=n,r={PivNj:function(a,x,f){return e[k(1759)](a,x,f)},wWHJL:function(a,x){return e[k(927)](a,x)},iLfQT:function(a,x){return e[k(995)](a,x)},yBiHC:function(a,x){return e[k(307)](a,x)},Dpucr:function(a,x){return a<x},WJpdM:function(a,x){return a<=x},PgLgz:function(a,x){return a>=x},rifex:function(a,x){return a|x},UXBYR:function(a,x){return a<<x},hlcxN:function(a,x){return e[k(205)](a,x)},DaALv:function(a,x){return a<<x},GbUNo:function(a,x){return e[k(1476)](a,x)},NyAoU:function(a,x){return e.WkEjK(a,x)},PLqDP:function(a,x){return a+x},muwYZ:e.FnxYW,nRPvf:e[t(863)],YttNq:function(a,x,f){return e[t(1759)](a,x,f)},Gdyxi:e[t(587)],quHEO:function(a,x,f){return a(x,f)}};if(e[t(332)](t(1623),e[t(1158)])){if(this[t(289)]&&this._ws[t(201)+"te"]===this[t(1579)+"NG"]){this[t(375)+t(1189)](),this[t(377)+"gTimeoutId"]=r[t(1384)](_0x4ff9ab,this[t(1481)].bind(this),this[t(388)][t(318)+t(316)]);return}if(!this[t(289)]||r[t(1620)](this[t(289)].readyState,this[t(1664)]))return void this[t(1092)+t(1345)]();this[t(289)]&&this._ws[t(530)]("hi"),this[t(1511)+"ctTimeou"+t(1421)]=r[t(1384)](_0x19a082,this[t(1092)+t(1345)+t(1763)][t(854)](this),this[t(388)][t(1547)+t(793)+t(476)])}else this[t(958)][t(279)](a=>{let x=t,f={Gkhcc:function(h,w){return r[k(1675)](h,w)},bUNPa:function(h,w){return r[k(675)](h,w)},RFXXd:function(h,w){return r.Dpucr(h,w)},PCGeZ:function(h,w){return r.WJpdM(h,w)},KLRPt:function(h,w){return r[k(1423)](h,w)},gJPld:function(h,w){return r[k(224)](h,w)},ADPFm:function(h,w){return r[k(1002)](h,w)},ZJxsy:function(h,w){return r[k(1404)](h,w)},jmInp:function(h,w){return r.DaALv(h,w)},VidbI:function(h,w){return h|w},SQNrU:function(h,w){return r[k(417)](h,w)},GBEqy:function(h,w){return h<<w},TLxjg:function(h,w){return r.NyAoU(h,w)},KppDU:function(h,w){return r[k(836)](h,w)}};if(r.wWHJL(r[x(222)],x(351)))this[x(1216)](r[x(638)],r[x(314)](rs,r[x(638)],{...a,data:a[x(1049)]||""}));else{if(f[x(1464)](f[x(646)](_0x6d6371,_0x581027),1))return"";let h="";for(let w=_0x54cc0e;f[x(1500)](w,_0x1eb4b0);){let g=_0x3682ef[w++];if(f[x(843)](g,127))h+=_0x12ae46[x(861)+x(1700)](g);else if(f[x(1688)](g,192)&&f.Gkhcc(g,224))h+=_0x306656[x(861)+x(1700)](f[x(1199)](f[x(1525)](31&g,6),f[x(480)](63,_0x2dced2[w++])));else if(f[x(1688)](g,224)&&f[x(1464)](g,240))h+=_0x4b71a8[x(861)+"Code"](f[x(1199)](f[x(1199)](f[x(1525)](15&g,12),f[x(918)](63&_0x2960f2[w++],6)),f[x(480)](63,_0x3ccf84[w++])));else if(f[x(1688)](g,240)){let b=f[x(646)](f[x(894)](f[x(1525)](f[x(1448)](7,g),18),f[x(196)](f[x(1448)](63,_0x3d8ec7[w++]),12))|f[x(1525)](63&_0x35f6d9[w++],6)|f[x(480)](63,_0x20d240[w++]),65536);h+=_0x1d83c4[x(861)+"Code"](55296+f.TLxjg(b,10)),h+=_0x18d7c6[x(861)+"Code"](f[x(503)](56320,f[x(1448)](1023,b)))}}return h}}),this[t(958)].onClose(a=>{let x=t;this[x(1216)](r[x(1709)],r[x(847)](De,r[x(1709)],{...a}))}),this[t(958)].onMessage(a=>{let x=t;this.emit(e[x(1284)],e[x(1732)](ns,e[x(1284)],{...a}))}),this[t(958)][t(1260)](a=>{let x=t;this[x(1216)](x(321),Ie(x(321),{...a,message:a[x(1049)]||""}))})}send(t){let r=n,a={cnSQO:r(321),vAToI:function(x,f,h){return e.IhUIJ(x,f,h)}};if(t instanceof Uint8Array){let x=t[r(1054)][r(1424)](t[r(1085)+"et"],e[r(1558)](t[r(1062)+"th"],t.byteOffset));this[r(958)]&&this._socket[r(530)]({data:x,fail:f=>{let h=r;this[h(1216)](e[h(1214)],Ie(h(321),{message:this[h(1015)+h(602)+h(1122)](f)}))}})}else this[r(958)]&&this[r(958)].send({data:t,fail:x=>{let f=r;this[f(1216)](a[f(1632)],a[f(868)](Ie,a[f(1632)],{message:this[f(1015)+f(602)+f(1122)](x)}))}})}[n(1360)](t,r){this._socket&&this._socket.close({code:t,reason:r})}[n(884)+n(1425)](t,r){this.on(t,r)}[n(605)+"entListe"+n(396)](t,r){this[n(657)](t,r)}get[n(201)+"te"](){let t=n;return this[t(958)][t(201)+"te"]}get[n(1704)+"pe"](){return this[n(958)].binaryType}set[n(1704)+"pe"](t){}get[n(1781)](){return this[n(958)].url}get[n(1408)](){let t=n;return this._socket[t(1408)]}get[n(1617)+"ns"](){let t=n;return this._socket[t(1617)+"ns"]}get[n(891)+"Amount"](){return 0}}function Gc(i,t){let r=n;if(t)return new t(i.url,i[r(1408)]);if(e[r(789)](jt,ut))return new Kc(i.url,i[r(1408)],i.headers);if(e[r(789)](vt,Kt)&&r(1631)+"d"!=typeof WebSocket&&WebSocket)return new WebSocket(i[r(1781)],i.protocols)}function Wc(i){let t=n,r=e[t(650)][t(1413)]("|"),a=0;for(;;){switch(r[a++]){case"0":if(i)return!0;continue;case"1":if(ut&&tt[t(525)+t(1592)])return!0;continue;case"2":if(e[t(789)](vt,Kt)&&e.IRDTh!=typeof WebSocket&&WebSocket)return!0;continue;case"3":if(jt&&wx[t(525)+t(1592)])return!0;continue;case"4":return!1}break}}function ss(i,t,r){let a=n,x={ZkgLA:function(f,h){return e[k(337)](f,h)},JepZI:function(f,h){return f===h},GNunv:function(f,h){return e[k(447)](f,h)}};if(e[a(400)](e[a(1334)],e[a(1334)])){let f=-1;async function h(w){let g=a;return x[g(1138)](w,f)?Promise[g(439)](new Error("next() called mu"+g(1742)+"imes in "+g(1248))):(f=w,x[g(319)](w,r.length)?Promise[g(1143)]():r[w][g(854)](i)(t,h[g(854)](null,x[g(581)](w,1))))}e[a(758)](h,0)}else return _0xc87e73&&e.WISDf(!0,_0x432389.isLong)}function os(i){let t=n,r=0,a=0;for(let x=0;e.WxWSB(x,i[t(796)]);++x)a=i[t(1380)+"At"](x),e[t(585)](a,128)?r+=1:e[t(1442)](a,2048)?r+=2:e[t(1098)](64512,a)===55296&&e.uIoLH(e.rSztB(64512,i[t(1380)+"At"](e.vdjPt(x,1))),56320)?(++x,r+=4):r+=3;return r}function as(i,t,r){let a=n;if(e.FIFVL(e[a(606)](r,t),1))return"";let x="";for(let f=t;e[a(555)](f,r);){let h=i[f++];if(e.NXKss(h,127))x+=String["fromChar"+a(1700)](h);else if(e[a(415)](h,192)&&e.hYsKK(h,224))x+=String[a(861)+a(1700)](e[a(1052)](e[a(1703)](31,h)<<6,e[a(1373)](63,i[f++])));else if(e[a(1246)](h,224)&&e[a(1224)](h,240))x+=String.fromCharCode(e[a(1645)](e.iIYgr((15&h)<<12,e[a(382)](e[a(577)](63,i[f++]),6)),63&i[f++]));else if(h>=240)if(e[a(1094)](e[a(383)],e.HqKEk)){let w=e[a(1372)](e[a(1372)](e[a(1181)](7&h,18),e.mqHtZ(63&i[f++],12))|e[a(253)](e[a(1614)](63,i[f++]),6),e[a(1043)](63,i[f++]))-65536;x+=String[a(861)+a(1700)](55296+e[a(964)](w,10)),x+=String[a(861)+"Code"](e.SmfAX(56320,e.UrDnl(1023,w)))}else return _0x40cfef[a(872)](_0x3544e3)||(_0x2004aa=_0x30f9a7[a(764)+"er"](_0x2a99fe)),e[a(1489)](this[a(1381)],_0x3a38a2[a(1381)])&&e[a(250)](e[a(1259)](this.high,31),1)&&e[a(851)](_0x304f21[a(1070)],31)===1?!1:this[a(1070)]===_0x351219[a(1070)]&&e[a(328)](this[a(1454)],_0x56f35a[a(1454)])}return x}function Or(i,t,r){let a=n,x={yUpPj:function(g,b){return e[k(470)](g,b)},LFwrf:function(g,b){return g>=b},jCPqb:function(g,b){return e[k(635)](g,b)},tVaMD:function(g,b){return e.ccjrd(g,b)},RsOGo:function(g,b){return e.lUjCO(g,b)},xfmQW:function(g,b){return g/b}},f=r,h,w;for(let g=0;e.FIFVL(g,i[a(796)]);++g)if(e[a(787)]===e[a(787)])if(h=i[a(1380)+"At"](g),e[a(1468)](h,128))t[r++]=h;else if(h<2048)t[r++]=e[a(1179)](e[a(1231)](h,6),192),t[r++]=e[a(350)](e.FQrNb(63,h),128);else if(e[a(291)](e[a(1576)](64512,h),55296)&&e[a(1159)](e.IxSuT(64512,w=i[a(1380)+"At"](e[a(775)](g,1))),56320)){let b=e.gxRXI[a(1413)]("|"),v=0;for(;;){switch(b[v++]){case"0":t[r++]=e.uvHcg(h>>18,240);continue;case"1":t[r++]=e[a(350)](e[a(1703)](h>>12,63),128);continue;case"2":t[r++]=e[a(412)](e.EYUBI(63,h),128);continue;case"3":h=e[a(1042)](e[a(533)](65536,e[a(1203)](e[a(940)](1023,h),10)),1023&w);continue;case"4":t[r++]=e.LcysV(e[a(975)](h>>6,63),128);continue;case"5":++g;continue}break}}else if(a(1258)===e[a(707)])t[r++]=e[a(453)](e[a(1545)](h,12),224),t[r++]=e.EOkxY(e[a(1619)](e[a(1231)](h,6),63),128),t[r++]=e.GuYBs(e[a(571)](63,h),128);else{if(QfbbKs[a(1615)](_0x154858,_0x49091c))return _0x5c5dc4?_0x4a7956:_0x2e45bf;if(_0x384a20){if(QfbbKs[a(702)](_0x10af83,_0x43bb77))return _0x48470c}else{if(_0x111a21<=-_0x8463b8)return _0x18b515;if(QfbbKs[a(702)](QfbbKs.jCPqb(_0x2a291b,1),_0x115ad9))return _0x52b121}return _0x1a7aff.fromBits(QfbbKs[a(1236)](QfbbKs[a(892)](_0x208187,_0x136a3b),0),QfbbKs[a(1236)](QfbbKs[a(1784)](_0x1bb35c,_0x31674a),0),_0x118348)}else{let b=this[a(240)+a(302)]?.[a(695)+a(1180)+"nt"]();this._debug(a(1123)+b+a(1038)),this["_disconn"+a(1717)](1001,a(1071)+a(391)+a(549)+"g",!0)}return e.evZjp(r,f)}async function cs(i){let t=n;if(e[t(1301)](e.UaeLL,typeof i)){let r=new Uint8Array(os(i));return e[t(526)](Or,i,r,0),r}return e[t(862)](i,ArrayBuffer)?new Uint8Array(i):new Uint8Array(i[t(1054)],i.byteOffset,i[t(1062)+"th"])}function Jc(i){let t=n,r={wktIs:function(a,x){return e[k(1346)](a,x)},DNyzl:function(a,x){return e[k(1196)](a,x)},oLpjh:function(a,x){return e[k(1760)](a,x)},NYxON:function(a,x){return a<<x},lyyjK:function(a,x){return e[k(779)](a,x)},HzoZi:function(a,x){return e[k(1314)](a,x)},MGvIa:function(a,x){return a>x},ezSfa:function(a,x,f){return e[k(355)](a,x,f)},EDQhO:function(a,x){return e[k(1280)](a,x)},JUckI:function(a,x){return a>>x},MSVKt:function(a,x){return e.vPuiZ(a,x)}};try{return t(1253)===e[t(682)]?e[t(1510)]("string",typeof i)&&(e[t(534)](i,ArrayBuffer)||i[t(1054)]&&i[t(1054)]instanceof ArrayBuffer)||e[t(835)](e[t(980)],typeof i)?"":(JSON.parse(i),e.xQelJ):void 0}catch{if(e.ccwBZ(e.Jtxnb,"tfvTJ"))return t(410)==typeof i?"text/plain;charset=utf-8":"";_0x516a4a=OpbALI[t(761)](OpbALI[t(761)](OpbALI[t(1562)]((7&_0x3b8b52)<<18,OpbALI[t(560)](63&_0x5a8ff3,12)),OpbALI[t(371)](OpbALI.lyyjK(63,_0x5f27fa),6)),OpbALI[t(987)](63,_0x5d31d3)),OpbALI[t(437)](_0x4c4603,65536)||OpbALI[t(1560)](_0x199525,1114111)?_0x57bf65+=_0x477344:(_0x360dbd-=65536,_0xd0efa5+=OpbALI[t(1618)](_0x845a47,OpbALI[t(790)](OpbALI.JUckI(_0x59cb24,10),55296),OpbALI[t(944)](OpbALI.lyyjK(1023,_0x3ab7f9),56320)),_0x40016c+=3)}}let $c=(i,t)=>{let r=n,a={tmbIw:function(x,f){return e.SFFXa(x,f)},HOHwU:e[r(870)],nhzgi:r(1723)+r(1209)+"s"};if(e[r(1567)](r(1237),e[r(1304)]))switch(i){case e.GWBtw:case e[r(1022)]:return{[r(1051)+i]:1,"x-tt-env":t};default:return{}}else a[r(1080)](_0xffd24f,a[r(713)]),Y[r(657)](a[r(1112)],_0x3fb4a9),Y[r(657)](r(1723)+r(802)+"t",_0x2f9ce3)};class Vc{constructor(t){let r=n;this[r(1603)+r(1053)]=t,this.count=0}[n(614)](){this.count++}["checkRea"+n(1245)+"nt"](){let t=n,r={TroCA:function(a,x){return e[k(1023)](a,x)},ICmRn:function(a,x){return e[k(1596)](a,x)},qIvcf:function(a,x){return e[k(827)](a,x)},eAMml:function(a,x){return e[k(332)](a,x)}};if(e[t(1627)](t(451),e.ndHgx))return e.lQtqS(this[t(1271)],this[t(1603)+t(1053)]);if(nEtWUR[t(1608)](void 0,_0x444857))this[t(1750)+"rs"]={};else if(nEtWUR.ICmRn(void 0,_0x170c9b))this[t(1750)+"rs"][_0x3794c2]=null;else{let a=this[t(1750)+"rs"][_0x37511c];if(a)for(let x=0;nEtWUR[t(259)](x,a[t(796)]);)nEtWUR.eAMml(a[x].fn,_0x566f91)?a[t(1074)](x,1):++x}return this}[n(971)+n(1321)](t=0){let r=n;this[r(1603)+r(1053)]=t,this[r(1271)]=0}}async function Yc(i){let t={RvlvW:e.xwpiu};return new Promise(r=>{let a=k;if(!vt)return e[a(1447)](r,"unknown "+a(723));try{let x=document[a(1326)+"ement"](e[a(1694)]);window[a(692)+a(1422)]=f=>{let h=a;document[h(232)][h(435)+h(477)](x),window["frontier"+h(1422)]=void 0,r(f&&f[h(1565)]||t[h(808)])},x[a(1737)]=a(1770)+a(1716),x.src=e[a(1607)](i[a(1212)](/^ws/,a(744)),e[a(1443)]);try{document.body[a(1132)+"ild"](x)}catch{document[a(232)][a(435)+"ild"](x)}}catch{window[a(692)+a(1422)]=void 0,r(e[a(765)])}})}function et(i,t,r){let a=n;return!!i?.find(x=>x[a(1642)]===t&&x[a(916)]===r)}function St(i,t){let r=n;return i?.[r(601)](a=>a[r(1642)]===t)?.[r(916)]}let Nr=null;async function Xc(){let i=n;if(e[i(1444)]!==e[i(1099)])return Nr||(Nr=Promise[i(1143)]()[i(317)](Fe[i(854)](Fe,e.aGYhe))),Nr;this[i(1111)+"lTimeoutId"]=null,this[i(1111)+"l"]=36e5,this._qosDB=e[i(365)](_0x38a16a,e[i(1024)],e[i(1761)])}class Qc extends Lr{constructor(t,r){let a=n;super(),this[a(962)]=t,this[a(1127)]=r,this[a(524)]=void 0,this[a(725)+a(848)]=null}async[n(875)](){let t=n;if(e[t(432)](t(1130),e[t(1520)]))await this._init();else return new _0x3e7963(_0x16521a,{data:_0x28c89c,message:_0x2d0f94})}async[n(1168)](){let t=n,r={qLVae:function(a){return a()}};if(e.oQfEr("vQvis",e[t(687)])){let a=this[t(240)+t(302)]?.[t(695)+t(1180)+"nt"]();this[t(1225)](t(214)+a),r[t(1016)](_0x19c8bd)}else{if(this._qosDB)return;if(this[t(725)+t(848)])return this[t(725)+t(848)];try{let a=this[t(962)],x=this[t(1127)];this[t(725)+t(848)]=(async()=>{let f=t,{openDB:h}=await Xc();this[f(524)]=await h(f(692)+"_"+a,1,{upgrade(w){let g=f;w[g(1644)+g(1368)+"e"](a,{keyPath:x})}})})(),await this[t(725)+t(848)]}catch(a){console[t(905)](a)}finally{this["_initPro"+t(848)]=null}}}async[n(1657)](t){let r=n;try{return await this[r(1168)](),this._qosDB?.get(this[r(962)],t)}catch(a){if(e[r(782)](r(1116),e.yEtUz)){if(e[r(337)](_0x495339,-_0x31d390))return _0x51b577;if(e[r(1306)](_0x12067b+1,_0x4266ce))return _0x5d8e09}else console[r(905)](a)}}async[n(1651)](t,r){let a=n;return await this[a(1168)](),this[a(524)]?.[a(1680)](this[a(962)],t)}async del(t){let r=n;try{return await this._init(),this[r(524)]?.[r(989)](this[r(962)],t)}catch(a){console.log(a)}}async clear(){let t=n;try{return await this[t(1168)](),this._qosDB?.[t(726)](this._dbName)}catch(r){console[t(905)](r)}}async[n(1561)](){let t=n;return await this[t(1168)](),this._qosDB?.[t(311)+"ys"](this[t(962)])}async[n(1398)](){let t=n;if(e[t(1666)](t(539),e[t(1701)])){let r=this[t(240)+t(302)]?.[t(695)+t(1180)+"nt"]();this[t(443)+t(358)+t(1434)](e.LRIoT(_0x50f0ae,"close",{code:1006,reason:t(1123)+r+(t(1038)+t(1186)+t(1272)+t(1418)),wasClean:!0}))}else return await this[t(1168)](),this._qosDB?.getAll(this[t(962)])}async[n(938)](){let t=n;try{if(e[t(709)](e[t(1273)],e[t(1239)]))return this[t(958)][t(1408)];this[t(524)]?.[t(1360)](),this[t(524)]=void 0}catch(r){console[t(905)](r)}}get isReady(){let t=n;if(e[t(935)](e[t(562)],e[t(588)]))try{return!!this[t(524)]}catch(r){return console[t(905)](r),!1}else return _0xcd8789[_0x33c0f5]=_0xbe5ada,!0}}class Zc{constructor(t,r){let a=n;this[a(1262)]=t,this[a(1006)]=r,this._qosDB=localStorage}async openDB(){}get[n(1479)](){let t=n;return t(692)+"_"+this[t(1262)]}async[n(1657)](t){let r=n,a=this[r(524)][r(1145)](this[r(1479)]);return JSON[r(636)](e[r(1744)](a,"{}"))[t]}async[n(1651)](t,r){let a=n,x=this._qosDB[a(1145)](this[a(1479)]),f=JSON[a(636)](e[a(468)](x,"{}"));return f[r||t[this[a(1006)]]]=t,this[a(524)].setItem(this[a(1479)],JSON[a(1577)+"y"](f)),r||t[this[a(1006)]]}async[n(1414)](t){let r=n,a=this[r(524)][r(1145)](this[r(1479)]),x=JSON[r(636)](a||"{}");return x[t]=void 0,this._qosDB.setItem(this[r(1479)],JSON[r(1577)+"y"](x))}async[n(726)](){let t=n;return this[t(524)][t(726)]()}async[n(1561)](){let t=n,r={gqhOQ:function(a,x,f){return e[k(1739)](a,x,f)},PvRVH:e[t(1226)]};if(e[t(567)]!==e.uNhrz){let a=this[t(524)][t(1145)](this[t(1479)]),x=JSON[t(636)](e[t(472)](a,"{}"));return Object.keys(x)}else this[t(1415)+t(1484)]=_0xf97be2,this[t(1250)+t(1777)]=_0x5de017,this[t(1537)+t(864)]=_0x3d62da,this[t(524)]=r[t(786)](_0x47765c,this[t(1415)+t(1484)],r[t(536)])}async[n(1398)](){let t=n;if(e.CweRD(e[t(363)],t(1001))){let r=this._qosDB[t(1145)](this._prefix),a=JSON[t(636)](r||"{}");return Object[t(442)](a)}else _0x28a631(Pqqzol.aVflX(_0x30a226,_0x2c9008[t(679)]),_0x8a2bf6[t(1622)+"on"],_0xc9398c[t(715)+"on"],Pqqzol[t(1400)](_0x5a4b51,_0x3f781c[t(1200)+"ion"]))}[n(938)](){return Promise[n(1143)]()}get isReady(){return!!this[n(524)]}}class e0{constructor(t,r){let a=n;this[a(1262)]=t,this[a(1006)]=r,this._qosDB=ut?tt:jt?wx:null}async[n(875)](){}get[n(1479)](){let t=n;if(e[t(1378)](e[t(1344)],e[t(1344)])){let r={DEUQj:function(a,x){return a(x)}};return function(...a){let x=t;return _0x573e7c[x(1063)](r[x(1593)](_0x431dc0,this),a),r[x(1593)](_0x42a9c2,_0x307d42.get(this))}}else return t(692)+"_"+this[t(1262)]}async[n(1657)](t){let r=n,a=this[r(524)][r(421)+"geSync"](this[r(1479)]);return JSON.parse(a||"{}")[t]}async set(t,r){let a=n,x=this._qosDB["getStora"+a(1046)](this[a(1479)]),f=JSON[a(636)](e[a(791)](x,"{}"));return f[r||t[this[a(1006)]]]=t,this[a(524)][a(407)+a(1046)](this[a(1479)],JSON.stringify(f)),r||t[this._pathKey]}async[n(1414)](t){let r=n,a=this[r(524)]["getStora"+r(1046)](this._prefix),x=JSON[r(636)](e.wMoQE(a,"{}"));return x[t]=void 0,this[r(524)]["setStora"+r(1046)](this[r(1479)],JSON[r(1577)+"y"](x))}async clear(){let t=n;if(e[t(717)](e[t(1192)],t(1151)))_0x57df39[t(853)+"d"]&&(this[t(1332)+t(1343)]()&&(!this[t(289)]||e.rRVsx(this[t(289)][t(201)+"te"],this.OPEN)||this[t(289)][t(201)+"te"]!==this[t(1579)+"NG"])&&this[t(433)+t(818)](),this[t(626)+"er"]&&_0x498ffe[t(884)+t(1425)](e[t(688)],this[t(433)+t(818)]),this._isBrowser&&_0xb7a804["addEvent"+t(1425)](e[t(589)],this[t(433)+"ffLine"]));else return this[t(524)][t(693)+"rageSync"]()}async keys(){let t=n,r=this._qosDB[t(421)+"geInfoSync"](this[t(1479)]),a=JSON.parse(e.DvQNN(r,"{}"));return Object[t(1561)](a)}async getAll(){let t=n,r={cgqSI:function(a,x){return a(x)}};if(e[t(452)](e.aVjuY,e[t(1753)])){let a={wmwET:function(x,f){let h=t;return UNEhxy[h(922)](x,f)}};return function(x,...f){let h=t,w=_0x2343f3[h(1182)](a.wmwET(_0x375c61,this),x,...f);return _0x5542aa.set(w,x[h(1686)]?x[h(1686)]():[x]),a.wmwET(_0x27a079,w)}}else{let a=this[t(524)][t(421)+t(1313)+"nc"](this[t(1479)]),x=JSON[t(636)](e.QsKzm(a,"{}"));return Object[t(442)](x)}}[n(938)](){return Promise[n(1143)]()}get isReady(){return!!this[n(524)]}}function xs(i,t){let r=n;if(e[r(1482)](ut,ut))return new e0(i,t);if((vt||Kt)&&e[r(835)](e[r(1712)],typeof indexedDB))return new Qc(i,t);if(e[r(372)](vt,Kt)&&r(1631)+"d"!=typeof localStorage)return new Zc(i,t);throw new Error(e[r(516)])}class t0{constructor(){let t=n;this[t(1111)+t(1036)+"Id"]=null,this._interval=36e5,this[t(524)]=e[t(218)](xs,e[t(1024)],e.lKgmM)}async[n(1111)+n(559)](){let t=n;e[t(613)](clearInterval,this["_interva"+t(1036)+"Id"]),this[t(1111)+t(1036)+"Id"]=setInterval(()=>{let r=t;e[r(1003)](e[r(1124)],e[r(282)])?_0x37268c[r(1774)](_0x36f63a):this[r(1650)+"ired"]()},this[t(1111)+"l"])}async openDB(){let t=n;await this[t(524)][t(875)]()[t(317)](()=>{let r=t;this[r(1111)+r(559)]()})}async["flushExp"+n(1310)](){let t=n;(await this._qosDB?.[t(1398)]()||[])[t(208)](({timestamp:x})=>x<Date.now())[t(1519)](x=>{let f=t;this[f(524)]?.[f(1414)](x[f(1748)+"id"])})}async[n(1414)](t){let r=n;return this[r(524)]?.[r(1414)](t)}async[n(1651)](t,r){let a=n;return this[a(524)]?.[a(1651)]({message_id:t,timestamp:r})}async get(t){let r=n,a={hHrgG:function(x,f){return x<f},akawt:function(x,f){return e[k(1666)](x,f)},yBPNF:function(x,f){return e[k(593)](x,f)}};if(e[r(413)](e[r(990)],e[r(398)])){let x=_0x2fba9b[r(1413)](":");for(let f=0;XcrsHz[r(275)](f,x[r(796)]);f++){let h=x[f];if(XcrsHz.akawt(4,x[f][r(796)])){let w=_0x39a228[r(644)+"g"](0,XcrsHz[r(266)](4,x[f].length)),g=w[r(632)](h);_0x33c862=_0x309433[r(632)](g)}else _0x544c4f=_0x3c24a1.concat(h)}return _0x1cd123}else return this[r(524)]?.[r(1657)](t)}async closeDB(){let t=n;e.YtCcr(clearInterval,this["_interva"+t(1036)+"Id"]),await this._qosDB?.[t(938)]()}get isReady(){let t=n;return this[t(524)]?.[t(1303)]}}function Mr(i){let t=n,r=!!this[t(388)][t(1044)+"S"];if(!r)return{enabled:r,isQoSMessage:!1,isQoSAck:!1,isAckCleanupMessage:!1,ackMsgIds:[]};let a=et(i[t(1697)][t(951)],e.zzTwP,"2"),x=a&&e.fNWbs(et,i.message[t(951)],"x_fronti"+t(757)+"ck","1"),f=a&&et(i[t(1697)][t(951)],t(807)+t(301)+"k","1"),h=f?e[t(1649)](St,i.message[t(951)],e.AHVMX)?.[t(1413)](",").filter(Boolean)||[]:[];return{enabled:r,isQoSMessage:a,isQoSAck:x,isAckCleanupMessage:f,ackMsgIds:h}}async function ds(){let i=n;return this[i(409)+i(283)]||(this[i(409)+i(283)]=new t0),this[i(409)+i(283)].isReady||await this[i(409)+i(283)].openDB(),this[i(409)+"ger"]}async function n0(i,t){let r=n,a={JpOQL:function(g,b,v){return e.gQLJb(g,b,v)},nXjIu:e[r(587)]},{enableAutoAck:x}=this._options,f=et(i[r(1697)][r(951)],e[r(1766)],"1"),h=e[r(526)](et,i.message.headers,e.KyReS,"1"),w=Mr[r(1182)](this,i);if(e[r(261)](x,f))if(e.fHmHl(e[r(1039)],r(1365))){let g=this[r(240)+"tManager"]?.["getCurre"+r(1180)+"nt"](),b=this[r(388)][r(576)+"tInterce"+r(1768)](_0x259aaf.code,_0x35b365[r(723)]);this[r(443)+r(358)+"ent"](a[r(425)](_0x2520e5,a[r(631)],{code:1006,reason:_0x14ed81[r(723)]||r(1286)+r(1437)+r(798)+r(880)+r(1449)+r(373)+g,willReconnect:b})),b&&this[r(815)]();return}else{let{SeqID:g,LogID:b,service:v,LogIDNew:C,method:O}=i[r(1697)];this[r(1363)]({SeqID:g,LogID:b,LogIDNew:C,service:v,method:O,headers:[{key:e.KyReS,value:"1"},{key:e.uTKdp,value:e[r(1377)](C,"")},{key:e.JeDpQ,value:"0"}]})}h&&!w.isQoSAck&&this[r(443)+"hAckMessageEvent"](i),t()}async function r0(i,t){let r=n,a={AGXjS:function(x,f){return e.vMCCt(x,f)},EFzyF:function(x,f){return e.DuuAb(x,f)},CsUDx:function(x,f,h){return x(f,h)}};if(e[r(1596)](r(1673),e[r(346)]))return FXTQdf[r(1338)](FXTQdf[r(461)](_0x752eea,8)[r(1453)]("0"),FXTQdf[r(691)](_0x566b83,_0x40c066,10)[r(1605)](2))[r(1424)](-8);this._debug(e[r(1325)],i[r(1697)]),t()}async function i0(i,t){let r=n,a=e[r(1597)](wt,await e[r(578)](cs,i.data));try{if(e.IeGpt(a[r(1097)],Uint8Array)){let x=e[r(862)](this[r(388)]["payloadE"+r(850)],Object)?{force:!!this[r(388)][r(900)+"ncoding"][r(1347)],encoding:this[r(388)][r(900)+r(850)][r(1323)]?this[r(388)]["payloadE"+r(850)][r(1323)][r(1212)](/\s/g,"")[r(204)+r(1786)]():""}:{force:!1,encoding:this[r(388)].payloadEncoding?this._options["payloadE"+r(850)][r(1212)](/\s/g,"")["toLowerC"+r(1786)]():""},f=a["payloadE"+r(850)]?a[r(900)+r(850)].replace(/\s/g,"")[r(204)+r(1786)]():"",h=e.llbcj(this._options.payloadType,Object)?{force:!!this[r(388)][r(384)+r(1131)][r(1347)],type:this._options["payloadT"+r(1131)][r(1737)]?this[r(388)][r(384)+r(1131)][r(1737)][r(1212)](/\s/g,"")[r(204)+"ase"]():""}:{force:!1,type:this[r(388)]["payloadT"+r(1131)]?this[r(388)][r(384)+r(1131)].replace(/\s/g,"")[r(204)+"ase"]():""},w=a[r(384)+r(1131)]?a[r(384)+"ype"][r(1212)](/\s/g,"")[r(204)+r(1786)]():"",g=h[r(1347)]?h[r(1737)]:w||h.type,b=x[r(1347)]?x[r(1323)]:f||x[r(1323)],v=[e[r(333)],e[r(242)],e[r(306)],r(410)],C=[r(799)+"e",e[r(298)]];this[r(388)][r(1157)+r(1208)+r(1487)+"ad"]&&v[r(1086)](g)&&(!b||C[r(1086)](b))?a[r(1298)+r(598)]=e[r(751)](as,a.payload,0,a.payload[r(1062)+"th"]):a.textPayload=""}else a[r(1298)+r(598)]=""}catch(x){a["textPayl"+r(598)]="",console[r(905)](x)}i[r(1697)]=a,e[r(517)](t)}function s0(i,t,r){let a=n,x=e[a(1745)](r,8192),f=e[a(216)](x,1),h=null,w=x;return function(g){let b=a;if(g<1||g>f)return e.oWFrM(i,g);e[b(959)](e[b(1161)](w,g),x)&&(h=e.CiPOh(i,x),w=0);let v=t.call(h,w,w+=g);return e.kzrep(7,w)&&(w=e[b(661)](e.XrZuJ(7,w),1)),v}}let o0=4294967295;function a0(i,t,r){let a=n;return e[a(436)](RangeError,e[a(812)](e[a(780)](e[a(942)](e.HGhwT,i)+e.xeCaJ,e[a(468)](t,1)),e.JYnUJ)+r)}function c0(i,t,r){let a=n;if(e[a(959)](r,o0))throw new Error(e[a(540)]);let x=3;for(;x>=0;){let f=e[a(974)](255,r);zr(f,i,t+x),r>>>=8,x--}return e[a(203)](t,4)}function x0(i,t){let r=n,a=0,x=t,f=e[r(596)](t,4);for(;x<f;)if(e.lhpaO("TZusq",e.nnUuP)){let{value:h,offset:w}=e.fLMhL(Br,i,x);x=w,a=e[r(1160)](e[r(777)](a,8),0),a+=h}else _0x4eecd3.log(_0x4c0e3b);return{value:a,offset:f}}function d0(i,t,r){let a=n;return i?e[a(1442)](i[a(796)],40)?Or(i,t,r)+r:t[a(238)+"e"]?e[a(566)](t.utf8Write(i,r),r):t[a(823)]?t[a(823)](i,r)+r:e[a(1665)](Or(i,t,r),r):r}function u0(i,t){let r=n,a=new G(e[r(374)](e.oKHTv(e[r(597)](i[e.dNAMH(t,4)],24)|e.vmYvg(i[e[r(348)](t,5)],16),e[r(257)](i[e.soGkl(t,6)],8)),i[t+7]),e[r(1322)](e[r(434)](e[r(966)](e.mqHtZ(i[e[r(1419)](t,0)],24),i[e[r(812)](t,1)]<<16),i[e[r(1101)](t,2)]<<8),i[e.vqmIh(t,3)]),!0);return t+=8,{value:a,offset:e[r(1601)](t,8)}}function f0(i,t,r){let a=n,x=i[a(1454)],f=i[a(1070)];return t[r]=e.pzdWS(f,24),t[e[a(775)](r,1)]=e[a(1270)](f,16)&255,t[e[a(1687)](r,2)]=e.SCuwf(e[a(1259)](f,8),255),t[r+3]=255&f,t[r+4]=x>>>24,t[r+5]=e[a(1391)](x,16)&255,t[r+6]=e[a(1121)](x,8)&255,t[e[a(1613)](r,7)]=e.uOgWf(255,x),r+=8,r}function Br(i,t){let r=n;if(e[r(883)](e[r(418)],e.nabnx))try{return e.UaeLL!=typeof _0x1da8ff&&(e.MhLSF(_0x457d33,_0x47619e)||_0xe18d23[r(1054)]&&e[r(510)](_0x215ed8[r(1054)],_0x14d7c4))||e[r(1510)](e[r(980)],typeof _0x1cd600)?"":(_0x5bb4b6.parse(_0xdef41c),e[r(242)])}catch{return e[r(1571)](e[r(980)],typeof _0x3cb195)?e[r(333)]:""}else return i.readUInt8?{value:i[r(911)+"8"](t),offset:e[r(1683)](t,1)}:{value:e[r(1430)](255,i[t]),offset:e[r(812)](t,1)}}function zr(i,t,r){let a=n;if(e[a(515)](a(518),e[a(1707)]))try{_0x1bffec(this,_0x236b53,[_0x35966f,_0x5d1f6b,_0x270bfe])}catch(x){let f=e[a(976)](_0x29913f,e[a(1214)],{message:x[a(1697)],code:_0x3639bb.OPEN_ERROR,error:x});this["_dispatc"+a(776)+a(1434)](f)}else return t[a(928)+"t8"]?t[a(928)+"t8"](i,r):t[r]=e.snlqI(255,i),e.mKvYi(r,1)}let l0=function(i){return new Uint8Array(i)},g0=e[n(607)](n(1631)+"d",typeof Buffer)?Buffer[n(622)+n(1509)]:e[n(845)](s0,l0,Uint8Array.prototype[n(993)]);(()=>{let i=n;if(e.fAMpO(i(1008),e.nbBKM)){let t=4294967295;return function(r,a,x=!0){let f=i,h={OqXxX:function(w,g){return e.bhztn(w,g)},owFDv:function(w,g){return e.CPCWt(w,g)},WEfIH:function(w,g){return e.fOzds(w,g)},ntAEw:function(w,g){return e[k(780)](w,g)},dZdNJ:function(w,g){return w+g},qNvNO:e[f(378)],fqEtp:function(w,g){return e[f(252)](w,g)},frnTj:e[f(1708)]};if(e[f(1170)]!==f(1679)){let w=(f(642)+f(1029)+f(209)+"3")[f(1413)]("|"),g=0;for(;;){switch(w[g++]){case"0":t=e.sJJmk(e.gdHlt(127,r[a]),0);continue;case"1":if(e[f(1224)](r[a++],128))return{value:x?t:e.JfOdg(0,t),offset:a};continue;case"2":if(e[f(1442)](r[a++],128))return{value:x?t:e[f(423)](0,t),offset:a};continue;case"3":return{value:x?t:e[f(1493)](0,t),offset:a};case"4":t=e[f(645)](e[f(1493)](t,e[f(924)](127&r[a],7)),0);continue;case"5":if(e[f(243)](r[a++],128))return{value:x?t:e.dRUfh(0,t),offset:a};continue;case"6":if(e[f(1468)](r[a++],128))return{value:x?t:e[f(857)](0,t),offset:a};continue;case"7":t=e[f(1391)](t|e[f(732)](127,r[a])<<21,0);continue;case"8":if(e[f(290)](a+=5,r[f(796)]))throw a=r.length,a0(a,10,r.length);continue;case"9":t=e[f(1645)](t,e.IGafw(e.phtMy(127,r[a]),14))>>>0;continue;case"10":if(e[f(739)](r[a++],128))return{value:x?t:e[f(1342)](0,t),offset:a};continue;case"11":t=e[f(660)](t|e[f(213)](15&r[a],28),0);continue}break}}else return WVMdnt[f(1656)](_0x32e551,WVMdnt[f(772)](WVMdnt[f(967)](WVMdnt.ntAEw(WVMdnt.dZdNJ(f(1783)+f(907)+f(1544),_0x2efeed)+WVMdnt.qNvNO,WVMdnt.fqEtp(_0x28f4c3,1)),WVMdnt[f(830)]),_0x36686d))}}else return Y[i(958)].binaryType})();let h0=16,Fr=32;function p0(i){let t=n,r=0,a={};for(let x=0;x<i[t(796)];x++)a[i[x][t(738)+t(981)]]=e[t(1530)](os,i[x]["cursor_n"+t(981)]),r+=14+a[i[x][t(738)+t(981)]];return[r,a]}function us(i,t,r){let a=n,x={RimUr:function(b,v){return e.xfrZF(b,v)},YAuhn:function(b,v){return e[k(1521)](b,v)},YLglz:function(b,v){return e[k(1402)](b,v)},UHTwO:function(b,v){return e.fZwjp(b,v)},RqNfD:function(b,v){return e.FosZq(b,v)},nRafR:function(b,v){return e.NfzRV(b,v)},wWYMa:a(367),CJGaB:e[a(633)],mKYEb:function(b,v,C,O){return b(v,C,O)},RtpSJ:a(1736)+a(310),XCdIn:"header",eYISc:a(310),wliGh:e[a(1307)],Jsywx:e[a(950)],Dsrni:e[a(1069)]},[f,h]=e[a(294)](p0,i),w=g0(f),g=0;return i[a(1519)](b=>{let v=a,C={SKESz:function(O,R){return x[k(1215)](O,R)},UvDLZ:function(O,R){return x[k(999)](O,R)},IdnTh:function(O,R){return x[k(697)](O,R)},IXNeY:function(O,R){return x[k(697)](O,R)},dpMvS:function(O,R){return x[k(656)](O,R)},zZaDc:function(O,R){return x[k(1405)](O,R)}};if(x[v(1499)]("MrCeR",x.wWYMa))_0x4b08f7=lBLYqp.SKESz(_0x2acc3a,_0x5a2b26),_0x391847|=lBLYqp[v(621)](lBLYqp.IdnTh(127,_0x384c46),21),lBLYqp[v(1507)](128,_0x4ac38d)&&(_0xd3eb45=lBLYqp.dpMvS(_0x4caf8c,_0x567438),_0x56c51d=lBLYqp[v(897)](127,_0x239c64),lBLYqp[v(897)](128,_0x93d009)&&(_0x3dc846=lBLYqp[v(1540)](_0x53fa8d,_0x3a29f2),_0x43d3be|=lBLYqp[v(621)](127&_0x35b502,7)));else{let O=x[v(487)].split("|"),R=0;for(;;){switch(O[R++]){case"0":g=x[v(1007)](zr,0,w,g);continue;case"1":console[v(905)](x[v(1393)],g);continue;case"2":console[v(905)](x[v(731)],g);continue;case"3":console[v(905)](x[v(1416)],g);continue;case"4":g=x.mKYEb(d0,b[v(738)+v(981)],w,g);continue;case"5":g=c0(w,g,b[v(745)]||0);continue;case"6":console[v(905)](x.wliGh,b,b.service);continue;case"7":g=x[v(1007)](zr,h[b[v(738)+v(981)]],w,g);continue;case"8":g=x[v(1007)](f0,G.fromNumber(b[v(628)]||t),w,g);continue;case"9":console[v(905)](x[v(1117)],g);continue;case"10":console[v(905)](x[v(217)],g);continue}break}}}),{frameType:Fr,headers:[{key:a(479)+a(1440),value:r}],payload:w}}function m0(i){let t=n,r={Chguo:function(a,x){return a-x},xIyDF:function(a,x){return e[k(1172)](a,x)},orwek:function(a,x){return e[k(558)](a,x)},BcDOE:function(a,x){return e[k(1475)](a,x)},EFbtu:function(a,x){return a<<x},fvaKP:function(a,x){return e[k(447)](a,x)}};if(e[t(1672)](e.WJCFT,e[t(659)])){let a=0,x=[];for(;e[t(1336)](a,i[t(1062)+"th"]);){let{offset:f}=e[t(763)](Br,i,a);a=f;let h={cursor_name:"",cursor:0,service:0},{value:w,offset:g}=x0(i,a);h[t(745)]=w,a=g;let{value:b,offset:v}=e[t(262)](Br,i,a);a=v,h[t(738)+t(981)]=e[t(526)](as,i,a,e[t(1241)](a,b)),a+=b;let{value:C,offset:O}=e.MnWSq(u0,i,a);h[t(628)]=C.toNumber(),a=O,x[t(1774)](h)}return x}else{let a=uuTSwI[t(1340)](uuTSwI[t(1660)](uuTSwI[t(1660)](uuTSwI[t(231)](uuTSwI[t(1439)](7,_0x41a652),18)|uuTSwI[t(1329)](uuTSwI[t(1439)](63,_0x2135a8[_0x54a835++]),12),uuTSwI[t(1329)](uuTSwI[t(1439)](63,_0xd08c7[_0x481a92++]),6)),uuTSwI[t(1439)](63,_0x10a3bb[_0x18e3c9++])),65536);_0x1e99cf+=_0x2b8993[t(861)+"Code"](55296+(a>>10)),_0xf27b9b+=_0x5adf63.fromCharCode(uuTSwI[t(618)](56320,uuTSwI[t(1439)](1023,a)))}}function w0(){let i=n;return{frameType:Fr,headers:[{key:e[i(426)],value:e[i(784)]}],payload:void 0}}class _0{constructor(t,r,a){let x=n;this[x(1415)+x(1484)]=t,this["_cursorF"+x(1777)]=r,this[x(1537)+x(864)]=a,this[x(524)]=xs(this[x(1415)+x(1484)],e[x(1226)])}async[n(875)](){let t=n;await this[t(524)][t(875)]()}async[n(1403)+"rs"](){let t=n;if(!this._qosDB.isReady)return;let r=this[t(1537)+t(864)],a=await this[t(524)][t(1398)]();switch(console[t(905)](e[t(460)],a),r){case e[t(1667)]:return a&&a[t(796)]?e[t(751)](us,a,0,this[t(1250)+"ileName"]):void 0;case e[t(1767)]:return;case e[t(1147)]:return a&&a[t(796)]?e[t(1348)](us,a,0,this[t(1250)+t(1777)]):e[t(953)](w0)}}async[n(1651)](t,r,a){let x=n;return console[x(905)](e[x(627)],t,r,a),this[x(524)][x(1651)]({cursor_name:t,cursor:r,service:a})}async[n(1315)+"rs"](t){let r=n;if(e.mrUyV(e[r(509)],e[r(509)])){if(!this._connectLock){let a=(r(1478)+"2")[r(1413)]("|"),x=0;for(;;){switch(a[x++]){case"0":this[r(1538)+"osed"]=!1;continue;case"1":this[r(273)+r(844)]?.[r(971)+"nter"]();continue;case"2":this[r(815)]();continue;case"3":this[r(393)]=!0;continue;case"4":this[r(240)+"tManager"]?.[r(226)+r(404)+r(277)]();continue}break}}}else{let a=e.WSGEd(m0,t);for(let x of a)console.log(e[r(349)],a),await this._qosDB[r(1651)](x)}}async get(t){let r=n;return(await this[r(524)][r(1657)](t))?.cursor}async closeDB(){let t=n;e[t(1233)](e[t(1641)],e[t(1779)])?(_0xf2f928=_0x1b1d31[e[t(1359)](e[t(596)](_0x49dfdf,_0x59734e),1)],e[t(1302)](e[t(681)](192,_0x626819),128)?_0x335c5b+=_0x7d035b:(_0x35deee=e[t(1733)](e.gDGYq(31,_0x3aca4b),6)|e[t(817)](63,_0x2d6ba6),e[t(968)](_0x5e901f,128)?_0x12d048+=_0x17722b:(_0x5c83db+=_0x30a0e5(_0x3b3fa6),_0x28bbed++))):await this[t(524)].closeDB()}[n(708)+n(1030)+n(1498)](t){let r=n;this[r(1250)+"ileName"]=t}get[n(1303)](){let t=n;if(e[t(1584)](t(1141),e[t(1635)]))return this._qosDB[t(1303)];this[t(1271)]++}}let y0=e[n(1088)];async function fs(i){let t=n;if(e[t(515)](e[t(1299)],e[t(1299)]))_0x13644f&&_0x5cdfc5.addEventListener(t(1360),()=>_0x4cdb9c()),_0x2d3974&&_0x11d763[t(884)+t(1425)]("versionchange",()=>_0x35fc32());else{if(!this[t(388)][t(1044)+"S"])return null;let{aID:r,fpID:a,messageStrategy:x}=this[t(388)],f=i||y0;try{return this[t(674)+t(1551)]?i&&this._cursorManager[t(708)+t(1030)+t(1498)](i):this[t(674)+t(1551)]=new _0(a+"_"+r+"_"+f,f,x),this[t(674)+t(1551)][t(1303)]||await this[t(674)+"anager"].openDB(),this["_cursorM"+t(1551)]}catch{return null}}}async function b0(i,t){let r=n,a={JJqQj:e[r(1197)],wgXcV:function(x,f){return e[r(455)](x,f)},EHIPQ:function(x,f){return e[r(1337)](x,f)},stnoz:function(x,f){return e[r(497)](x,f)}};if(e[r(1139)](e[r(1628)],r(1528))){let x=a[r(906)][r(1413)]("|"),f=0;for(;;){switch(x[f++]){case"0":if(_0x30ce7d.utf8Write)return xsjpOQ[r(620)](_0x5c3c35[r(238)+"e"](_0x1ee9c0,_0x2afa42),_0x2a25d5);continue;case"1":if(_0x227d3d.length<40)return xsjpOQ[r(1252)](_0x55a210(_0x95bfc9,_0x5e6d82,_0x398916),_0x5c29a1);continue;case"2":if(!_0x37e24c)return _0x215698;continue;case"3":return _0x4768ae(_0x39a1fb,_0x1f4cfa,_0x3c7227)+_0x27376e;case"4":if(_0x39cc29[r(823)])return xsjpOQ.stnoz(_0xa8497d.write(_0xf1586d,_0x100b63),_0x21ac79);continue}break}}else{let x=et(i[r(1697)][r(951)],r(1532),"-1"),f=et(i[r(1697)][r(951)],e[r(1009)],"1"),h=e.irSXZ(St,i.message[r(951)],r(807)+r(941)),w=e[r(1568)](Number,e[r(1020)](St,i.message[r(951)],r(807)+"er_ttl"))||0,g=Mr[r(1182)](this,i),b=e[r(1348)](et,i[r(1697)].headers,e[r(422)],"2"),v=e[r(1452)](St,i[r(1697)][r(951)],e[r(1787)]),C=e[r(1017)](Number,e[r(992)](St,i[r(1697)][r(951)],e[r(1126)]));if(g[r(678)])return e.jaJyY(t);let O=g[r(579)+"sage"]?await ds[r(1182)](this):null;if(e.SFxCa(i.message.service,0)&&f&&!x||e.aURdb(i[r(1697)][r(745)],0)){if(h&&g[r(579)+r(408)]&&O)return!!!await O[r(1657)](h)&&(this["_dispatc"+r(535)+r(1081)](i),await O[r(1651)](h,e.ygBus(Date[r(1780)](),w))),e[r(517)](t);if(b){let R=await fs.call(this);if(!R)return this[r(443)+r(535)+r(1081)](i),e[r(485)](t);let F=await R[r(1657)](v)??-1;if(e[r(243)](F,C))this[r(443)+r(535)+r(1081)](i),R.set(v,C,i[r(1697)][r(745)]);else throw new Error(r(1137)+" message"+r(774)+C+(r(936)+r(893)+r(529)+"r ")+F);return t()}return this[r(443)+r(535)+"Event"](i),e.YyxnS(t)}}}async function v0(i,t){let r=n,a=Mr.call(this,i);if(!a[r(579)+r(408)])return t();let x=await ds.call(this);if(a[r(1524)+r(1061)+r(1122)]&&a.ackMsgIds[r(796)])for(let f of a[r(743)+"s"])await x.del(f);t()}async function S0(i,t){let r=n,a=e[r(1627)](i[r(1697)][r(1104)+"e"],h0),x=e[r(1486)](i.message.frameType,Fr);if(e[r(1639)](!a,!x))return e[r(1324)](t);let f=e[r(1690)](St,i.message[r(951)],e[r(426)]);if(!f)return e[r(1575)](t);let h=await fs.call(this,f);if(!h)return t();if(a){let w=await h[r(1403)+"rs"](),g={frameType:w?.["frameType"],SeqID:G[r(764)+"er"](this[r(1251)]++),LogID:G[r(764)+"er"](this[r(388)][r(1548)+r(1749)]()),service:9e3,method:5,headers:w?.[r(951)],payload:w?.[r(1097)]},b=e[r(548)](I,g);this._ws&&this._ws.readyState&&this[r(289)].send(b)}if(x){let w=i.message[r(1097)];w&&h.setCursors(w)}}let E0=async function(i,t){let r=n;this[r(393)]=!1,e[r(917)](clearTimeout,this[r(815)+r(1647)+r(527)]),e[r(1232)](t)},I0=async function(i,t){let r=n;if(!this[r(289)]||this[r(289)].readyState!==this[r(1664)])return e.HSddo(t);let{pingInterval:a}=this._options;this["_endpoin"+r(302)]?.[r(226)+"pointCon"+r(277)]();for(let f=0;e[r(968)](f,this[r(1537)+r(550)].length);f++){let h=this[r(1537)+r(550)][f];if(this[r(289)].readyState===this[r(1664)]&&e[r(1584)](null,h))this[r(289)]&&this[r(289)].send(h),this[r(1537)+"Queue"][f]=null;else break}this[r(1537)+r(550)]=this[r(1537)+"Queue"][r(208)](f=>!!f),this["_pingPon"+r(653)+"Id"]=e.YALyA(setTimeout,()=>this[r(1481)](),a),this._dispatchOpenEvent(i),this[r(626)+"er"]&&this._ws&&(this[r(289)][r(1704)+"pe"]=this["_binaryT"+r(1131)]);let x=this[r(240)+"tManager"]?.[r(695)+r(1180)+"nt"]();this[r(1225)]("open "+x+" success"),e.kIQdp(t)},A0=async function(i,t){let r=n,a=this[r(240)+r(302)]?.[r(695)+"ntEndpoint"]();this[r(1225)](r(214)+a),e[r(517)](t)};class C0 extends Lr{constructor(t){let r=n,a={lcrZb:function(w,g,b,v){return e[k(751)](w,g,b,v)},BvJjz:e[r(1214)],QeFju:e.XEKJp,MGfSJ:function(w,g,b){return e[r(1295)](w,g,b)},NDWMb:e[r(809)],Teenz:function(w,g){return w!==g},jDGJf:function(w,g){return e.DuuAb(w,g)},uuzTQ:function(w,g){return e[r(432)](w,g)},rGgNZ:function(w,g,b){return e[r(1730)](w,g,b)}};super(),this[r(1109)+r(1505)+r(728)]=!0,this[r(626)+"er"]=vt,this[r(546)]=jc,this[r(1485)+"T"]=ut,this[r(1146)+"X"]=jt,this[r(1198)+"r"]=Kt,this["_message"+r(550)]=[],this["_endpoin"+r(302)]=null,this._readyClosed=!1,this._binaryType=e.DRnPB,this["_connect"+r(202)]=!1,this["_connectionTimeo"+r(527)]=null,this[r(1511)+r(1010)+r(1421)]=null,this[r(377)+"gTimeoutId"]=null,this[r(1251)]=0,this[r(393)]=!1,this[r(1417)]="",this["_QoSMana"+r(283)]=null,this._cursorManager=null,this[r(273)+r(844)]=null,this._protocols=e.QMNlb,this[r(1067)]=3,this[r(1579)+"NG"]=0,this[r(1664)]=1,this[r(599)]=2,this[r(223)]=w=>{let g=r;try{a.lcrZb(ss,this,w,[E0,I0,A0])}catch(b){let v=Ie(a[g(832)],{message:b[g(1697)],code:Ze[g(414)+"OR"],error:b});this[g(443)+g(776)+g(1434)](v)}},this[r(1535)+"ge"]=async w=>{let g=r,{pingInterval:b,pingFrequency:v}=this[g(388)];if((w[g(1661)]==="hi"&&e[g(828)]===v||e.pVolg(e.DiXaT,v))&&(this._clearPingTimer(),this[g(1216)](e[g(768)],e[g(870)]),this[g(377)+"gTimeoutId"]=e[g(1164)](setTimeout,this[g(1481)][g(854)](this),b)),!e[g(1472)]("hi",w[g(1661)]))try{e[g(1728)](ss,this,w,[i0,n0,v0,S0,b0,r0])}catch(C){let O=e[g(557)](Ie,e[g(1214)],{message:C.message,code:Ze["MESSAGE_"+g(269)],error:C});this[g(443)+g(776)+g(1434)](O)}},this[r(669)]=w=>{let g=r,b=this[g(240)+g(302)]?.[g(874)+g(684)+"es"](),v=this[g(240)+"tManager"]?.[g(695)+"ntEndpoint"]();if(b&&!w[g(1697)]){let C=g(1123)+v+(" fail, max retri"+g(1278)+"ed");this[g(443)+"hErrorEv"+g(1434)](e[g(1739)](Ie,e[g(1214)],{message:C,code:Ze[g(399)+"IES_ERROR"],error:w}));return}this[g(289)]&&e[g(701)](this[g(289)][g(201)+"te"],this[g(1664)])&&this[g(1455)+g(1717)](),this[g(443)+g(776)+g(1434)](e[g(1682)](Ie,e[g(1214)],{message:w.message,code:Ze[g(887)+g(1078)],error:w}))},this[r(932)]=async w=>{let g=r;this[g(1399)+"mer"](),this[g(375)+g(1189)](),this["_removeW"+g(821)+"rs"](),this[g(289)]=null,this[g(815)+g(202)]=!1;let b=this[g(240)+"tManager"]?.[g(874)+g(684)+"es"]();if(!b&&this[g(1332)+g(1343)]()&&!this[g(1538)+g(1473)]){let v=this[g(240)+g(302)]?.[g(695)+g(1180)+"nt"](),C=this[g(388)][g(576)+g(1103)+g(1768)](w[g(1532)],w.reason);this[g(443)+g(358)+"ent"](De(a[g(919)],{code:1006,reason:w.reason||g(1286)+"ng faile"+g(798)+g(880)+g(1449)+g(373)+v,willReconnect:C})),C&&this[g(815)]();return}if(w[g(1532)]!==1e3&&this[g(1538)+g(1473)]){this[g(443)+g(358)+g(1434)](a[g(1354)](De,a[g(919)],{code:1e3,reason:a[g(788)]})),this["_endpoin"+g(302)]?.["resetEnd"+g(404)+g(277)](),this[g(273)+g(844)]?.resetCounter();return}if(a[g(1549)](1e3,w[g(1532)])&&b){let v=this[g(240)+"tManager"]?.[g(695)+g(1180)+"nt"](),C=w[g(723)];C||(C=await a.jDGJf(Yc,this._url)),C=g(1286)+g(1437)+g(1319)+C+(g(1382)+"me: ")+v+(g(1186)+g(1272)+g(1418)),this["_dispatc"+g(358)+g(1434)](De(a[g(919)],{code:w.code,reason:C}));let O="connect "+v+(g(586)+"ax retri"+g(1278)+"ed");this[g(443)+g(776)+g(1434)](a[g(1354)](Ie,a.BvJjz,{message:O,code:Ze["MAX_RETR"+g(1569)+"R"]})),this[g(240)+g(302)]?.[g(226)+g(404)+g(277)](),this[g(273)+"sCounter"]?.[g(971)+"nter"]();return}if(a[g(1050)](1e3,w.code)&&!w[g(723)]){let v=this["_endpoin"+g(302)]?.[g(695)+"ntEndpoint"]();this[g(443)+g(358)+g(1434)](a[g(1354)](De,a.QeFju,{code:w[g(1532)],reason:g(1286)+g(1437)+g(798)+"wn reaso"+g(1449)+"ame: "+v})),this._endpointManager?.[g(226)+"pointCon"+g(277)](),this[g(273)+g(844)]?.["resetCou"+g(1321)]();return}this["_dispatchCloseEv"+g(1434)](w),this["_endpoin"+g(302)]?.[g(226)+g(404)+"fig"](),this["_pingLos"+g(844)]?.[g(971)+"nter"]()},this.onclose=null,this[r(440)]=null,this[r(641)+"e"]=null,this[r(1364)]=null,this[r(643)+r(1345)]=null,this["onReceiv"+r(979)]=null,this[r(1005)+r(737)+"yReconnect"]=null,this[r(433)+r(818)]=this[r(433)+r(818)][r(854)](this),this[r(433)+"ffLine"]=this["_handleO"+r(719)].bind(this),this[r(1211)+r(1722)]=this[r(1211)+r(1722)][r(854)](this),this[r(1211)+r(1120)]=this[r(1211)+r(1120)].bind(this),this[r(388)]={url:"",automaticOpen:!0,initReconnectInterval:1e3,maxReconnectInterval:1e4,reconnectIntervalGrowFactor:2,timeoutInterval:5e3,maxRetries:5,debug:!1,maxMessageQueueLength:e[r(288)](1,0),service:0,logIDGenerator:c,headers:void 0,payloadEncoding:"",payloadType:"",fpID:"",deviceID:"",accessKey:"",ttwID:"",bddID:"",aID:"",disableAutoReconnect:!1,customParams:{},pingInterval:15e3,pingTimeoutInterval:4e3,pingFrequency:r(1685),pingLossCount:2,enableTransformTextPayload:!1,logIDNewConfig:{enableAutoGenerateLogIDNew:!1,userIp:""},miniProgramParams:{customHttpHeader:{}},enableAutoAck:!1,reconnectInterceptor:()=>!0,enableQoS:!1,QoSLevel:2,messageStrategy:"CONTINUE",env:{xTTEnv:"",xUseEnv:""},listenNetworkChanged:!0};let{url:x,ws:f}=t,h=Array[r(736)](x)?x:e[r(980)]==typeof x?[x]:[];if(!h||e[r(1480)](0,h[r(796)]))throw new Error(e[r(1228)]);if(!Wc(f))throw new Error(r(500)+r(542)+"s params"+r(801)+r(469)+r(1275)+"is undef"+r(929));if(Object.assign(this._options,t),this[r(240)+r(302)]=new is(h,this[r(388)][r(1032)+"es"]),this[r(273)+r(844)]=new Vc(this[r(388)][r(299)+r(1207)]),this[r(388)][r(1369)+r(541)]&&(this._isInit=!0,this[r(815)]()),this._options[r(1518)+r(1040)+r(1788)])if(e.YsmSa(e[r(619)],r(369)))this[r(1485)+"T"]||this[r(1146)+"X"]?this["_onPageN"+r(1725)+r(1583)]():this[r(626)+"er"]&&this["_initGlo"+r(838)+r(1425)]();else{let w=this._options[r(576)+"tInterce"+r(1768)](_0x999dda,_0xd03bf3);this["_dispatc"+r(358)+r(1434)](a.rGgNZ(_0x583155,a[r(919)],{code:_0x582678,reason:_0x33cbf2,wasClean:!0,willReconnect:w})),w&&this[r(815)]()}}[n(433)+n(818)](){let t=n;this[t(388)][t(689)+t(1514)+t(489)]||this[t(1538)+t(1473)]||this[t(1092)+t(1345)]()}[n(433)+n(719)](){let t=n;if(e[t(896)](e.MwUuB,e[t(921)]))this[t(1603)+"ount"]=_0x2bfe45,this[t(1271)]=0;else{this["_destroy"+t(471)+"t"]();let r=e[t(711)](Rr,t(576)+"t",{message:e[t(1612)]});this[t(1005)+"mediatel"+t(1637)+"ct"]&&this["onStopIm"+t(737)+t(1637)+"ct"](r)}}[n(449)+"balEvent"+n(1425)](){let t=n;this[t(626)+"er"]&&window.addEventListener(e[t(688)],this[t(433)+t(818)]),this[t(626)+"er"]&&window[t(884)+"Listener"](e[t(589)],this["_handleO"+t(719)]),this[t(626)+"er"]&&window["addEvent"+t(1425)](e[t(722)],this[t(1211)+t(1722)]),this._isBrowser&&window[t(884)+t(1425)](e[t(885)],this._handlePageShow)}[n(822)+n(838)+"Listener"](){let t=n,r={GhMEs:e.uVcRl,YRxeM:function(a,x){return a||x},wTkyD:e[t(1712)]};if(e[t(1566)](e[t(1379)],e[t(1379)])){let a=r.GhMEs[t(1413)]("|"),x=0;for(;;){switch(a[x++]){case"0":if(bhXzEr[t(1634)](_0x2400fd,_0x1a4ac7)&&bhXzEr[t(520)]!=typeof _0x793980&&_0x25e483)return!0;continue;case"1":if(_0x741b54&&_0x27d251["connectS"+t(1592)])return!0;continue;case"2":if(_0x3eb92d&&_0x1abd0d.connectSocket)return!0;continue;case"3":if(_0x3c827d)return!0;continue;case"4":return!1}break}}else this[t(626)+"er"]&&window[t(605)+t(720)+t(396)](e[t(688)],this["_handleO"+t(818)]),this._isBrowser&&window[t(605)+t(720)+t(396)](e[t(589)],this["_handleO"+t(719)]),this[t(626)+"er"]&&window["removeEv"+t(720)+t(396)](e[t(722)],this[t(1211)+"ageHide"]),this[t(626)+"er"]&&window[t(605)+t(720)+t(396)](t(810),this[t(1211)+"ageShow"])}[n(1211)+n(1722)](t){let r=n;!t[r(853)+"d"]&&(this[r(626)+"er"]&&window[r(605)+"entListe"+r(396)](e.nRkIR,this[r(1211)+"ageHide"]),this._isBrowser&&window[r(605)+"entListe"+r(396)](e[r(885)],this[r(1211)+r(1120)]),this[r(1360)]()),this[r(626)+"er"]&&window[r(605)+"entListe"+r(396)](e[r(688)],this[r(433)+"nLine"]),this._isBrowser&&window[r(605)+r(720)+r(396)](e[r(589)],this[r(433)+r(719)])}[n(1211)+n(1120)](t){let r=n;t[r(853)+"d"]&&(this[r(1332)+r(1343)]()&&(!this[r(289)]||this[r(289)][r(201)+"te"]!==this.OPEN||e.xpfen(this._ws.readyState,this[r(1579)+"NG"]))&&this["_handleO"+r(818)](),this._isBrowser&&window["addEvent"+r(1425)](e[r(688)],this[r(433)+r(818)]),this[r(626)+"er"]&&window.addEventListener("offline",this[r(433)+r(719)]))}async["_generat"+n(390)](t){let r=n,{fpID:a,deviceID:x,bddID:f,ttwID:h,accessKey:w,aID:g,customParams:b={},enableAutoAck:v,enableQoS:C,QoSLevel:O,env:R}=this[r(388)],F,ue,be;this[r(626)+"er"]||this._isMiniWX||this._isMiniTT?(F=location&&e[r(1227)]==location[r(1408)]?e[r(362)]:e[r(1244)],ue=t[r(1212)](/((^ws)|(^http))((?:[s]*:\/\/))/,""),be=/^wss(.*:\/\/)/[r(1646)](t)?t:""+F+ue):(F=e[r(362)],ue=t[r(1212)](/(^http)((?:[s]*:\/\/))/,""),be=/(^ws)((?:[s]*:\/\/))/[r(1646)](ue)?ue:""+F+ue);let Gt=f?e[r(982)]:h?r(1533):e[r(1395)],mn=f||h||x;if(!mn||!Gt)throw new Error(r(500)+r(511)+"ddID, de"+r(532)+r(640));let P0=e.cIrPe==typeof b?await e.XhxHE(b):b,k0=R?e[r(1176)]($c,R.xUseEnv,R[r(360)]):{},Ur=Object[r(1163)]({device_platform:e[r(320)],version_code:e[r(651)],access_key:w,fpid:a,aid:g,[Gt]:mn,xsack:v?1:0,xaack:v?1:0,xsqos:C?1:0,qos_level:C?O:void 0,qos_sdk_version:2,...k0},P0),T0=Object[r(1561)](Ur)[r(1091)]((qr,Hr)=>Ur[Hr]!==void 0?""+qr+(qr?"&":"?")+Hr+"="+Ur[Hr]:qr,"");return be+r(1412)+T0}async[n(815)](){let t=n,r={NVGnS:t(1697)};if(!(this[t(815)+t(202)]||this[t(1538)+t(1473)])){this[t(815)+t(202)]=!0;try{if(e[t(1598)]===e[t(1598)]){let x=this["_endpoin"+t(302)]?.[t(930)+t(996)+t(345)+t(325)+t(1055)](),{timeoutInterval:f}=this._options;if(x)if(e[t(1390)]!=="oxORc")for(var a in _0x282373)_0x3cebe8.o(_0x561d95,a)&&!_0x2416d5.o(_0x3d0246,a)&&_0x4a6705[t(1512)+t(1778)](_0x374e0d,a,{enumerable:!0,get:_0x5b1bb8[a]});else{let w=this[t(240)+"tManager"]?.[t(695)+"ntEndpoint"](),g=this[t(240)+t(302)]?.[t(286)+t(1445)+t(1624)+t(267)+t(825)](),b=this[t(240)+t(302)]?.[t(695)+t(1180)+t(1721)+t(1053)]();if(g){if(e.fXmow(e[t(207)],t(265)))return{frameType:_0x48d70e,headers:[{key:e.iLZAR,value:e[t(784)]}],payload:void 0};{let v=t(1123)+w+(" timeout"+t(1186)+t(1272)+"ached, will use backup e"+t(221))+g+(t(272)+"y"),C=e[t(365)](Ie,"error",{message:v,code:Ze[t(399)+t(1569)+"R"]});this._debug(v),this[t(443)+t(776)+t(1434)](C),this[t(1417)]=await this[t(670)+t(390)](g),this._debug(t(1123)+g+" "+b+t(668)),this[t(1210)+"sListeners"]()}}else{let v=t(1123)+w+(" timeout, max re"+t(1272)+t(1418));this[t(1225)](v),this["_dispatc"+t(776)+t(1434)](e[t(711)](Ie,e.sukVs,{message:v,code:Ze["MAX_RETR"+t(1569)+"R"]}));return}}else if(e[t(1409)](e[t(755)],t(658))){let w=this[t(240)+t(302)]?.[t(695)+t(1180)+t(459)+t(600)](),g=this[t(240)+t(302)]?.["getCurrentEndpoi"+t(1721)+t(1053)]();this[t(1417)]=await this._generateUrl(w||""),this[t(1225)](t(1123)+w+" "+g+t(668)),this[t(1210)+t(821)+"rs"]()}else{let w=e[t(1335)][t(1413)]("|"),g=0;for(;;){switch(w[g++]){case"0":_0x4d9583=["put","add",t(989),t(726)];continue;case"1":_0x3c49eb=[Pqqzol[t(326)],Pqqzol[t(1534)],t(1398),t(311)+"ys",Pqqzol[t(706)]];continue;case"2":Pqqzol[t(1167)](_0x3bf97d);continue;case"3":_0x1eef0b=new _0x5ef5e2;continue;case"4":Pqqzol[t(465)](_0x3a948a,b=>({...b,get:(v,C,O)=>_0x47e1d0(v,C)||b.get(v,C,O),has:(v,C)=>!!_0xb9f923(v,C)||b[t(1184)](v,C)}));continue;case"5":_0x718e0e();continue}break}}if(this._isInit)this._isInit=!1;else if(e[t(662)]("TxzeA",t(923))){let w=e[t(1663)](Rr,e[t(1178)],{message:e[t(1676)]});this[t(643)+t(1345)]&&this[t(643)+t(1345)](w)}else this[t(1216)](r[t(1621)],_0x49c800),this[t(641)+"e"]&&this[t(641)+"e"](_0x3267b3);let h=this[t(240)+t(302)]?.[t(695)+t(1180)+"ntTriesC"+t(1053)]()||0;e.bUxDN(h,1)&&await this[t(395)](h-1),this[t(1225)](t(1286)+t(1743)+this[t(1417)]+(" protoco"+t(973))+this[t(1025)+"ls"]),this[t(289)]=Gc({url:this[t(1417)],protocols:[this[t(1025)+"ls"]],headers:this[t(388)].miniProgramParams[t(592)+t(1386)]},this._options.ws),(this[t(626)+"er"]||this[t(1198)+"r"])&&this._ws&&(this[t(289)][t(1704)+"pe"]=this[t(1450)+"ype"]),this[t(718)+t(1195)](),this["_connectionTimeo"+t(527)]=e[t(1177)](setTimeout,this[t(1333)+"ut"][t(854)](this),f)}else{let{initReconnectInterval:x,maxReconnectInterval:f,reconnectIntervalGrowFactor:h}=this[t(388)],w=x*_0x8d434d[t(1771)](h,e[t(606)](_0x2a66fd,1));return e[t(290)](w,f)?f:w}}catch(x){throw this[t(815)+"Lock"]=!1,x}}}[n(1399)+n(245)](){let t=n;if(e[t(553)](e[t(1754)],e[t(805)]))e[t(309)](clearTimeout,this[t(815)+"ionTimeoutId"]),this[t(815)+t(1647)+t(527)]=null;else{if(e[t(1031)](4,_0x45985d[t(796)])){let r=_0x34e00b[t(644)+"g"](0,e[t(1526)](4,_0x1f6cad[t(796)])),a=r[t(632)](_0x206d89);_0x592853[t(1774)](a)}else _0x2bbe2d[t(1774)](_0x16a40c);_0x419a53&&(_0xb79832+=1),_0xe2a2f+=1,_0x29d1a7=!1}}[n(375)+n(1189)](){let t=n;clearTimeout(this[t(377)+"gTimeoutId"]),clearTimeout(this[t(1511)+"ctTimeoutId"]),this[t(377)+t(653)+"Id"]=null,this[t(1511)+t(1010)+"tId"]=null}_debug(...t){let r=n;this[r(388)][r(582)]&&console.log[r(1063)](console,[e[r(673)],...t])}[n(1706)+n(444)+"e"](t){let r=n,{initReconnectInterval:a,maxReconnectInterval:x,reconnectIntervalGrowFactor:f}=this._options,h=e.CxyrE(a,Math[r(1771)](f,e[r(606)](t,1)));return e.OhKug(h,x)?x:h}[n(1481)](){let t=n;if(this[t(289)]&&this[t(289)][t(201)+"te"]===this[t(1579)+"NG"]){this[t(375)+t(1189)](),this[t(377)+t(653)+"Id"]=setTimeout(this._ping[t(854)](this),this._options[t(318)+t(316)]);return}if(!this._ws||e[t(1465)](this[t(289)][t(201)+"te"],this[t(1664)]))return void this["_handleR"+t(1345)]();this[t(289)]&&this[t(289)][t(530)]("hi"),this["_reconne"+t(1010)+t(1421)]=e[t(770)](setTimeout,this["_handleR"+t(1345)+t(1763)][t(854)](this),this[t(388)]["pingTime"+t(793)+"val"])}[n(1092)+n(1345)+n(1763)](){let t=n;this._pingLossCounter?.[t(614)](),this[t(1216)](t(1723)+t(802)+"t",t(1740)),this["_pingLos"+t(844)]?.["checkRea"+t(1245)+"nt"]()?this[t(1092)+t(1345)]():this[t(1481)]()}[n(1332)+n(1343)](){let t=n;return this._isMiniTT||this._isMiniWX?this[t(1109)+t(1505)+t(728)]:(this._isBrowser||this._isWorker)&&this[t(388)][t(1518)+"tworkCha"+t(1788)]?navigator.onLine:!0}[n(1092)+n(1345)](){let t=n;!this[t(1332)+t(1343)]()||this[t(1538)+"osed"]||(this[t(240)+t(302)]?.[t(226)+t(404)+"fig"](),this[t(273)+t(844)]?.["resetCou"+t(1321)](),this._ws?this[t(1455)+t(1717)](1001,e.RdwyV,!0):this._connect())}[n(873)+n(1725)+n(1583)](){let t=n;if(e[t(927)](e[t(1495)],e[t(1102)]))this[t(1485)+"T"]?tt["onNetworkStatusC"+t(1090)](({isConnected:r})=>{let a=t;this["_miniNav"+a(1505)+"line"]=r,r?this[a(433)+a(818)]():this["_handleO"+a(719)]()}):this._isMiniWX&&wx[t(538)+"kStatusC"+t(1090)](({isConnected:r})=>{let a=t;this[a(1109)+"igatorOnline"]=r,r?this[a(433)+a(818)]():this[a(433)+"ffLine"]()});else return this[t(289)]?this[t(289)][t(1617)+"ns"]:""}_wait(t){let r={YQHOr:function(a,x,f){return e[k(1292)](a,x,f)}};return new Promise(a=>{let x=k;r[x(1527)](setTimeout,a,this["_getInte"+x(444)+"e"](t))})}[n(1455)+n(1717)](t=1e3,r="",a=!1){let x=n;this[x(289)]&&this[x(506)+"WebSocket"](t,r,a)}[n(1333)+"ut"](){let t=n,r=this[t(240)+t(302)]?.[t(695)+t(1180)+"nt"]();this._debug(t(1123)+r+t(1038)),this[t(1455)+t(1717)](1001,e.hrlXj,!0)}_sendAck(t){let r=n,a={JQKpa:function(f,h){return e[k(607)](f,h)},NCPIt:e.IRDTh,nbfsc:e[r(1531)],lDFzk:"__esModule"},x=e[r(381)](re,t);this[r(289)]&&e[r(970)](this[r(289)].readyState,this[r(1664)])&&(e.mVcGD(e.CjjOK,r(1144))?(this._ws&&this[r(289)].send(x),this[r(1225)](e[r(1626)],t)):_0x19d4af.r=f=>{let h=r;tAoHrX[h(1491)](tAoHrX[h(1559)],typeof _0x378a29)&&_0x7a8818.toStringTag&&_0x560f8b["definePr"+h(1778)](f,_0x5c33f9[h(1605)+h(637)],{value:tAoHrX.nbfsc}),_0x4dbb03[h(1512)+h(1778)](f,tAoHrX[h(1503)],{value:!0})})}["_removeW"+n(821)+"rs"](){let t=n,r=e[t(1734)][t(1413)]("|"),a=0;for(;;){switch(r[a++]){case"0":this[t(289)][t(605)+t(720)+t(396)](e[t(863)],this[t(223)]);continue;case"1":this[t(289)]["removeEv"+t(720)+t(396)](e[t(1284)],this[t(1535)+"ge"]);continue;case"2":if(!this[t(289)])return;continue;case"3":this._ws["removeEv"+t(720)+t(396)]("close",this[t(932)]);continue;case"4":this[t(289)][t(605)+t(720)+t(396)](e[t(1214)],this[t(669)]);continue}break}}[n(718)+n(1195)](){let t=n,r={meQIu:function(a,x,f){return e[k(1542)](a,x,f)}};if(e[t(454)](e[t(961)],e[t(961)])){if(!this._ws)return;this[t(289)][t(884)+t(1425)](e[t(863)],this[t(223)]),this[t(289)][t(884)+"Listener"](t(1360),this[t(932)]),this[t(289)][t(884)+t(1425)](e.QCUmg,this[t(1535)+"ge"]),this[t(289)]["addEvent"+t(1425)](e.sukVs,this._onError)}else{let a=OFSyAS[t(1356)](_0x102534,_0x37141b,_0xf3ee67.length);_0x51292b[t(1582)][t(1651)](_0x35a005,a)}}[n(1217)+n(483)](t=1e3,r=""){let a=n;try{e[a(1629)]!==e[a(401)]?this[a(289)]&&this[a(289)][a(1360)](t,r):_0x21a84a.log(_0x482b1e)}catch{}}[n(506)+n(471)+"t"](t=1e3,r="",a=!1){let x=n;if(this[x(375)+x(1189)](),this[x(1399)+x(245)](),this[x(1210)+x(821)+"rs"](),this[x(1217)+x(483)](1e3,r),this[x(815)+x(202)]=!1,a&&this[x(1332)+x(1343)]()&&!this[x(1538)+x(1473)]){if(this[x(240)+x(302)]?.[x(874)+"chMaxTries"]()){let h=this[x(240)+x(302)]?.[x(695)+x(1180)+"nt"]();this[x(443)+"hCloseEv"+x(1434)](e[x(1204)](De,e[x(587)],{code:1006,reason:"connect "+h+(x(1038)+x(1186)+x(1272)+x(1418)),wasClean:!0}))}else{let h=this[x(388)][x(576)+x(1103)+x(1768)](t,r);this[x(443)+x(358)+x(1434)](e[x(976)](De,e.XEKJp,{code:t,reason:r,wasClean:!0,willReconnect:h})),h&&this[x(815)]()}return}this["_navigat"+x(1343)]()||this[x(1538)+"osed"]?this[x(443)+x(358)+"ent"](e[x(992)](De,x(1360),{code:t,reason:e[x(809)]})):this[x(443)+x(358)+x(1434)](e[x(356)](De,x(1360),{code:1006,reason:e[x(1591)]})),this[x(289)]=null,this[x(240)+x(302)]?.[x(226)+"pointCon"+x(277)](),this[x(273)+x(844)]?.[x(971)+x(1321)]()}[n(443)+n(1506)+"nt"](t){let r=n;this[r(1216)]("open",t),this[r(1364)]&&this[r(1364)](t)}[n(443)+n(535)+n(1081)](t){let r=n;this[r(1216)](e[r(1284)],t),this[r(641)+"e"]&&this.onmessage(t)}[n(443)+n(1648)+n(1713)](t){let r=n;this[r(1216)](e.pUhme,t),this[r(804)+r(979)]&&this[r(804)+"eAck"](t)}[n(443)+"hErrorEvent"](t){let r=n;this[r(1216)](e[r(1214)],t),this[r(440)]&&this[r(440)](t)}[n(443)+n(358)+"ent"](t){let r=n;this[r(1216)](r(1360),t),this[r(943)]&&this[r(943)](t)}get[n(1704)+"pe"](){let t=n;return this[t(289)]?this[t(289)].binaryType:this[t(1450)+t(1131)]}set binaryType(t){let r=n;this[r(1450)+"ype"]=t,this[r(289)]&&(this._ws.binaryType=t)}get[n(1064)+"nt"](){let t=n;if(t(339)===t(1079)){let r=_0x191465[t(1466)]();return r?(r[t(397)]=r[t(1572)]=0,r):{bytes:new _0x32041d(64),offset:0,limit:0}}else return this[t(240)+t(302)]?.["getCurre"+t(1180)+t(1721)+"ount"]()||0}get[n(891)+"Amount"](){let t=n;return this[t(1537)+t(550)][t(1091)]((a,x)=>(a+=x&&x[t(1062)+"th"]||0,a),0)+(this[t(289)]?this[t(289)][t(891)+t(890)]:0)}get extensions(){let t=n;return this[t(289)]?this[t(289)][t(1617)+"ns"]:""}get[n(1408)](){let t=n;return this[t(289)]?this[t(289)][t(1408)]:""}get readyState(){let t=n;return this[t(289)]?this._ws.readyState:this._options[t(1369)+t(541)]?this[t(1579)+"NG"]:this.CLOSED}get[n(1781)](){let t=n;return this[t(289)]?this[t(289)][t(1781)]:this[t(1417)]}close(t=1e3,r){let a=n,x=e[a(794)][a(1413)]("|"),f=0;for(;;){switch(x[f++]){case"0":this["_clearTi"+a(245)]();continue;case"1":if(this[a(289)][a(201)+"te"]===this[a(1067)]||this[a(289)][a(201)+"te"]===this[a(599)])return void this._debug(e.OfEqP);continue;case"2":if(!this._ws)return void this[a(1225)](e.yaYQc);continue;case"3":this[a(375)+a(1189)]();continue;case"4":this[a(409)+a(283)]?.[a(938)]();continue;case"5":this[a(506)+"WebSocket"](t,r);continue;case"6":this["_readyCl"+a(1473)]=!0;continue;case"7":this[a(822)+a(838)+a(1425)]();continue}break}}async[n(530)](t,r){let a=n;if(e.PHnMf(null,t))throw new Error(a(500)+a(1483)+a(759)+a(522)+"a must b"+a(997)+a(781)+a(513)+a(1057));e[a(1552)](e[a(666)],typeof t)&&(t=JSON[a(1577)+"y"](t)),e[a(607)](a(410),typeof t)&&!e.IeGpt(t,ArrayBuffer)&&!(t[a(1054)]&&e[a(1316)](t[a(1054)],ArrayBuffer))&&(t=JSON.stringify(t));let x=await e[a(547)](cs,t),f=e[a(1490)](Jc,t),{method:h=0,service:w=this[a(388)][a(745)],logID:g=this._options[a(1548)+a(1749)](),headers:b=this[a(388)][a(951)],payloadEncoding:v=this._options[a(900)+"ncoding"],payloadType:C=this[a(388)][a(384)+a(1131)],logIDNew:O=this._options[a(762)+a(1470)][a(463)+"toGenerateLogIDNew"]?e[a(1678)](o,this[a(388)][a(762)+"Config"][a(233)]):""}=r||{};if(!w)throw new Error(e[a(1367)]);let R={SeqID:G[a(764)+"er"](this[a(1251)]++),LogID:G[a(764)+"er"](g),service:w,method:h,headers:b,payloadEncoding:v instanceof Object?v[a(1323)]?v[a(1323)]:"":v,payloadType:C instanceof Object?C[a(1737)]?C[a(1737)]:f:C||f,payload:x,LogIDNew:O},F=e.mxQlT(re,R);return this[a(289)]&&e.cXPRr(this[a(289)][a(201)+"te"],this[a(1664)])?(this[a(289)]&&this[a(289)].send(F),this[a(1225)](e[a(840)],R)):this[a(1537)+a(550)].length<this._options[a(1014)+"geQueueL"+a(1574)]?(this[a(1537)+"Queue"][a(1774)](F),this[a(1225)](a(714),R)):(this._messageQueue.shift(),this[a(1537)+"Queue"][a(1774)](F)),{seqID:this[a(1251)],logID:g,logIDNew:O}}async[n(576)+"t"](t){let r=n,{url:a}=e[r(372)](t,{}),x=Array.isArray(a)?a:e.UaeLL==typeof a?[a]:[];t&&Object[r(1163)](this[r(388)],t),x&&x[r(796)]?this[r(240)+r(302)]=new is(x,this[r(388)][r(1032)+"es"]):this[r(240)+r(302)]?.["resetEnd"+r(404)+"fig"](),this[r(273)+r(844)]?.[r(971)+r(1321)](this[r(388)][r(299)+"Count"]),this[r(1538)+"osed"]=!1,this[r(289)]&&this[r(289)].readyState!==this.CLOSED?this[r(1455)+r(1717)](1e3,r(1296)+r(1345)+r(1523),!0):(this[r(393)]=!0,this._connect())}async[n(1394)](){let t=n;if(!this[t(815)+t(202)])if(e[t(896)](e.WxsID,t(220))){let r=e[t(594)](_0xdfd0a2,_0x46584c,1);_0x1560bf[t(1582)][r]=_0x175290}else{let r=e[t(1229)][t(1413)]("|"),a=0;for(;;){switch(r[a++]){case"0":this._connect();continue;case"1":this[t(273)+t(844)]?.[t(971)+t(1321)]();continue;case"2":this[t(1538)+t(1473)]=!1;continue;case"3":this[t(393)]=!0;continue;case"4":this[t(240)+t(302)]?.[t(226)+t(404)+"fig"]();continue}break}}}[n(884)+"Listener"](t,r){this.on(t,r)}[n(1586)+n(1081)](t){let r=n,{type:a}=t;this[r(1216)](a,t)}[n(605)+"entListe"+n(396)](t,r){this.off(t,r)}[n(1353)](){let t=n,r={RCXHO:function(a,x){return e[k(1149)](a,x)},egwBA:e[t(870)],oYIGm:e[t(611)]};return new Promise((a,x)=>{let f=t,h={ypzFe:function(b,v){return b(v)},jljzP:e[f(960)],WjrMQ:e.wVKst,faVAg:e[f(611)]};this["_clearPi"+f(1189)](),this._pingPongTimeoutId=setTimeout(this[f(1481)][f(854)](this),this._options[f(318)+"rval"]);let w=()=>{let b=f;r[b(704)](a,r[b(1746)]),this.off(b(1723)+b(1209)+"s",w),this[b(657)](r[b(869)],g)},g=()=>{let b=f;h[b(1193)](x,h[b(1388)]),this[b(657)](h[b(248)],w),this[b(657)](h[b(860)],g)};this.on(e[f(768)],w),this.on(e[f(611)],g),this[f(1481)]()})}}})(),Y["CustomCl"+E(663)]=te.CustomCloseEvent,Y[E(1095)+E(729)]=te[E(1095)+E(729)],Y[E(898)+"e"]=te[E(898)+"e"],Y[E(1081)]=te[E(1081)],Y[E(1357)]=te[E(1357)],Y["Frontier"+E(1554)+"vent"]=te["Frontier"+E(1554)+E(1235)],Y[E(1554)+E(1235)]=te[E(1554)+E(1235)],Y.OpenEvent=te.OpenEvent,Y[E(912)+E(1588)]=te[E(912)+E(1588)],Y[E(241)+E(663)]=te[E(241)+E(663)],Y.createErrorEvent=te[E(1550)+E(729)],Y[E(858)+E(1456)+"nt"]=te["createMe"+E(1456)+"nt"],Y[E(1670)+E(1171)]=te[E(1670)+E(1171)],Y[E(387)+"connectE"+E(1235)]=te[E(387)+E(292)+E(1235)],Y[E(385)+E(991)]=te[E(385)+E(991)],Y[E(338)+E(981)]=te[E(338)+E(981)];for(Yn in te)[E(1277)+E(663),"CustomEr"+E(729),E(898)+"e",E(1081),E(1357),E(727)+E(1554)+E(1235),E(1554)+E(1235),"OpenEvent",E(912)+E(1588),E(241)+E(663),E(1550)+E(729),E(858)+E(1456)+"nt","createOpenEvent",E(387)+"connectE"+E(1235),E(385)+E(991),E(338)+E(981)].indexOf(Yn)===-1&&(Y[Yn]=te[Yn]);var Yn;Object["definePr"+E(1778)](Y,E(1056)+"le",{value:!0})});var Je=_e((e_,ta)=>{"use strict";var Zo=["nodebuffer","arraybuffer","fragments"],ea=typeof Blob<"u";ea&&Zo.push("blob");ta.exports={BINARY_TYPES:Zo,CLOSE_TIMEOUT:3e4,EMPTY_BUFFER:Buffer.alloc(0),GUID:"258EAFA5-E914-47DA-95CA-C5AB0DC85B11",hasBlob:ea,kForOnEventAttribute:Symbol("kIsForOnEventAttribute"),kListener:Symbol("kListener"),kStatusCode:Symbol("status-code"),kWebSocket:Symbol("websocket"),NOOP:()=>{}}});var an=_e((t_,rr)=>{"use strict";var{EMPTY_BUFFER:rf}=Je(),di=Buffer[Symbol.species];function sf(n,e){if(n.length===0)return rf;if(n.length===1)return n[0];let s=Buffer.allocUnsafe(e),o=0;for(let c=0;c<n.length;c++){let d=n[c];s.set(d,o),o+=d.length}return o<e?new di(s.buffer,s.byteOffset,o):s}function na(n,e,s,o,c){for(let d=0;d<c;d++)s[o+d]=n[d]^e[d&3]}function ra(n,e){for(let s=0;s<n.length;s++)n[s]^=e[s&3]}function of(n){return n.length===n.buffer.byteLength?n.buffer:n.buffer.slice(n.byteOffset,n.byteOffset+n.length)}function ui(n){if(ui.readOnly=!0,Buffer.isBuffer(n))return n;let e;return n instanceof ArrayBuffer?e=new di(n):ArrayBuffer.isView(n)?e=new di(n.buffer,n.byteOffset,n.byteLength):(e=Buffer.from(n),ui.readOnly=!1),e}rr.exports={concat:sf,mask:na,toArrayBuffer:of,toBuffer:ui,unmask:ra};if(!process.env.WS_NO_BUFFER_UTIL)try{let n=ee("bufferutil");rr.exports.mask=function(e,s,o,c,d){d<48?na(e,s,o,c,d):n.mask(e,s,o,c,d)},rr.exports.unmask=function(e,s){e.length<32?ra(e,s):n.unmask(e,s)}}catch{}});var oa=_e((n_,sa)=>{"use strict";var ia=Symbol("kDone"),fi=Symbol("kRun"),li=class{constructor(e){this[ia]=()=>{this.pending--,this[fi]()},this.concurrency=e||1/0,this.jobs=[],this.pending=0}add(e){this.jobs.push(e),this[fi]()}[fi](){if(this.pending!==this.concurrency&&this.jobs.length){let e=this.jobs.shift();this.pending++,e(this[ia])}}};sa.exports=li});var Mt=_e((r_,da)=>{"use strict";var cn=ee("zlib"),aa=an(),af=oa(),{kStatusCode:ca}=Je(),cf=Buffer[Symbol.species],xf=Buffer.from([0,0,255,255]),sr=Symbol("permessage-deflate"),$e=Symbol("total-length"),Ot=Symbol("callback"),ct=Symbol("buffers"),Nt=Symbol("error"),ir,gi=class{constructor(e){if(this._options=e||{},this._threshold=this._options.threshold!==void 0?this._options.threshold:1024,this._maxPayload=this._options.maxPayload|0,this._isServer=!!this._options.isServer,this._deflate=null,this._inflate=null,this.params=null,!ir){let s=this._options.concurrencyLimit!==void 0?this._options.concurrencyLimit:10;ir=new af(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[Ot];this._deflate.close(),this._deflate=null,e&&e(new Error("The deflate stream was closed while data was being processed"))}}acceptAsServer(e){let s=this._options,o=e.find(c=>!(s.serverNoContextTakeover===!1&&c.server_no_context_takeover||c.server_max_window_bits&&(s.serverMaxWindowBits===!1||typeof s.serverMaxWindowBits=="number"&&s.serverMaxWindowBits>c.server_max_window_bits)||typeof s.clientMaxWindowBits=="number"&&!c.client_max_window_bits));if(!o)throw new Error("None of the extension offers can be accepted");return s.serverNoContextTakeover&&(o.server_no_context_takeover=!0),s.clientNoContextTakeover&&(o.client_no_context_takeover=!0),typeof s.serverMaxWindowBits=="number"&&(o.server_max_window_bits=s.serverMaxWindowBits),typeof s.clientMaxWindowBits=="number"?o.client_max_window_bits=s.clientMaxWindowBits:(o.client_max_window_bits===!0||s.clientMaxWindowBits===!1)&&delete o.client_max_window_bits,o}acceptAsClient(e){let s=e[0];if(this._options.clientNoContextTakeover===!1&&s.client_no_context_takeover)throw new Error('Unexpected parameter "client_no_context_takeover"');if(!s.client_max_window_bits)typeof this._options.clientMaxWindowBits=="number"&&(s.client_max_window_bits=this._options.clientMaxWindowBits);else if(this._options.clientMaxWindowBits===!1||typeof this._options.clientMaxWindowBits=="number"&&s.client_max_window_bits>this._options.clientMaxWindowBits)throw new Error('Unexpected or invalid parameter "client_max_window_bits"');return s}normalizeParams(e){return e.forEach(s=>{Object.keys(s).forEach(o=>{let c=s[o];if(c.length>1)throw new Error(`Parameter "${o}" must have only a single value`);if(c=c[0],o==="client_max_window_bits"){if(c!==!0){let d=+c;if(!Number.isInteger(d)||d<8||d>15)throw new TypeError(`Invalid value for parameter "${o}": ${c}`);c=d}else if(!this._isServer)throw new TypeError(`Invalid value for parameter "${o}": ${c}`)}else if(o==="server_max_window_bits"){let d=+c;if(!Number.isInteger(d)||d<8||d>15)throw new TypeError(`Invalid value for parameter "${o}": ${c}`);c=d}else if(o==="client_no_context_takeover"||o==="server_no_context_takeover"){if(c!==!0)throw new TypeError(`Invalid value for parameter "${o}": ${c}`)}else throw new Error(`Unknown parameter "${o}"`);s[o]=c})}),e}decompress(e,s,o){ir.add(c=>{this._decompress(e,s,(d,u)=>{c(),o(d,u)})})}compress(e,s,o){ir.add(c=>{this._compress(e,s,(d,u)=>{c(),o(d,u)})})}_decompress(e,s,o){let c=this._isServer?"client":"server";if(!this._inflate){let d=`${c}_max_window_bits`,u=typeof this.params[d]!="number"?cn.Z_DEFAULT_WINDOWBITS:this.params[d];this._inflate=cn.createInflateRaw({...this._options.zlibInflateOptions,windowBits:u}),this._inflate[sr]=this,this._inflate[$e]=0,this._inflate[ct]=[],this._inflate.on("error",uf),this._inflate.on("data",xa)}this._inflate[Ot]=o,this._inflate.write(e),s&&this._inflate.write(xf),this._inflate.flush(()=>{let d=this._inflate[Nt];if(d){this._inflate.close(),this._inflate=null,o(d);return}let u=aa.concat(this._inflate[ct],this._inflate[$e]);this._inflate._readableState.endEmitted?(this._inflate.close(),this._inflate=null):(this._inflate[$e]=0,this._inflate[ct]=[],s&&this.params[`${c}_no_context_takeover`]&&this._inflate.reset()),o(null,u)})}_compress(e,s,o){let c=this._isServer?"server":"client";if(!this._deflate){let d=`${c}_max_window_bits`,u=typeof this.params[d]!="number"?cn.Z_DEFAULT_WINDOWBITS:this.params[d];this._deflate=cn.createDeflateRaw({...this._options.zlibDeflateOptions,windowBits:u}),this._deflate[$e]=0,this._deflate[ct]=[],this._deflate.on("data",df)}this._deflate[Ot]=o,this._deflate.write(e),this._deflate.flush(cn.Z_SYNC_FLUSH,()=>{if(!this._deflate)return;let d=aa.concat(this._deflate[ct],this._deflate[$e]);s&&(d=new cf(d.buffer,d.byteOffset,d.length-4)),this._deflate[Ot]=null,this._deflate[$e]=0,this._deflate[ct]=[],s&&this.params[`${c}_no_context_takeover`]&&this._deflate.reset(),o(null,d)})}};da.exports=gi;function df(n){this[ct].push(n),this[$e]+=n.length}function xa(n){if(this[$e]+=n.length,this[sr]._maxPayload<1||this[$e]<=this[sr]._maxPayload){this[ct].push(n);return}this[Nt]=new RangeError("Max payload size exceeded"),this[Nt].code="WS_ERR_UNSUPPORTED_MESSAGE_LENGTH",this[Nt][ca]=1009,this.removeListener("data",xa),this.reset()}function uf(n){if(this[sr]._inflate=null,this[Nt]){this[Ot](this[Nt]);return}n[ca]=1007,this[Ot](n)}});var Bt=_e((i_,or)=>{"use strict";var{isUtf8:ua}=ee("buffer"),{hasBlob:ff}=Je(),lf=[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 gf(n){return n>=1e3&&n<=1014&&n!==1004&&n!==1005&&n!==1006||n>=3e3&&n<=4999}function hi(n){let e=n.length,s=0;for(;s<e;)if((n[s]&128)===0)s++;else if((n[s]&224)===192){if(s+1===e||(n[s+1]&192)!==128||(n[s]&254)===192)return!1;s+=2}else if((n[s]&240)===224){if(s+2>=e||(n[s+1]&192)!==128||(n[s+2]&192)!==128||n[s]===224&&(n[s+1]&224)===128||n[s]===237&&(n[s+1]&224)===160)return!1;s+=3}else if((n[s]&248)===240){if(s+3>=e||(n[s+1]&192)!==128||(n[s+2]&192)!==128||(n[s+3]&192)!==128||n[s]===240&&(n[s+1]&240)===128||n[s]===244&&n[s+1]>143||n[s]>244)return!1;s+=4}else return!1;return!0}function hf(n){return ff&&typeof n=="object"&&typeof n.arrayBuffer=="function"&&typeof n.type=="string"&&typeof n.stream=="function"&&(n[Symbol.toStringTag]==="Blob"||n[Symbol.toStringTag]==="File")}or.exports={isBlob:hf,isValidStatusCode:gf,isValidUTF8:hi,tokenChars:lf};if(ua)or.exports.isValidUTF8=function(n){return n.length<24?hi(n):ua(n)};else if(!process.env.WS_NO_UTF_8_VALIDATE)try{let n=ee("utf-8-validate");or.exports.isValidUTF8=function(e){return e.length<32?hi(e):n(e)}}catch{}});var yi=_e((s_,wa)=>{"use strict";var{Writable:pf}=ee("stream"),fa=Mt(),{BINARY_TYPES:mf,EMPTY_BUFFER:la,kStatusCode:wf,kWebSocket:_f}=Je(),{concat:pi,toArrayBuffer:yf,unmask:bf}=an(),{isValidStatusCode:vf,isValidUTF8:ga}=Bt(),ar=Buffer[Symbol.species],Pe=0,ha=1,pa=2,ma=3,mi=4,wi=5,cr=6,_i=class extends pf{constructor(e={}){super(),this._allowSynchronousEvents=e.allowSynchronousEvents!==void 0?e.allowSynchronousEvents:!0,this._binaryType=e.binaryType||mf[0],this._extensions=e.extensions||{},this._isServer=!!e.isServer,this._maxPayload=e.maxPayload|0,this._skipUTF8Validation=!!e.skipUTF8Validation,this[_f]=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=Pe}_write(e,s,o){if(this._opcode===8&&this._state==Pe)return o();this._bufferedBytes+=e.length,this._buffers.push(e),this.startLoop(o)}consume(e){if(this._bufferedBytes-=e,e===this._buffers[0].length)return this._buffers.shift();if(e<this._buffers[0].length){let o=this._buffers[0];return this._buffers[0]=new ar(o.buffer,o.byteOffset+e,o.length-e),new ar(o.buffer,o.byteOffset,e)}let s=Buffer.allocUnsafe(e);do{let o=this._buffers[0],c=s.length-e;e>=o.length?s.set(this._buffers.shift(),c):(s.set(new Uint8Array(o.buffer,o.byteOffset,e),c),this._buffers[0]=new ar(o.buffer,o.byteOffset+e,o.length-e)),e-=o.length}while(e>0);return s}startLoop(e){this._loop=!0;do switch(this._state){case Pe:this.getInfo(e);break;case ha:this.getPayloadLength16(e);break;case pa:this.getPayloadLength64(e);break;case ma:this.getMask();break;case mi:this.getData(e);break;case wi:case cr:this._loop=!1;return}while(this._loop);this._errored||e()}getInfo(e){if(this._bufferedBytes<2){this._loop=!1;return}let s=this.consume(2);if((s[0]&48)!==0){let c=this.createError(RangeError,"RSV2 and RSV3 must be clear",!0,1002,"WS_ERR_UNEXPECTED_RSV_2_3");e(c);return}let o=(s[0]&64)===64;if(o&&!this._extensions[fa.extensionName]){let c=this.createError(RangeError,"RSV1 must be clear",!0,1002,"WS_ERR_UNEXPECTED_RSV_1");e(c);return}if(this._fin=(s[0]&128)===128,this._opcode=s[0]&15,this._payloadLength=s[1]&127,this._opcode===0){if(o){let c=this.createError(RangeError,"RSV1 must be clear",!0,1002,"WS_ERR_UNEXPECTED_RSV_1");e(c);return}if(!this._fragmented){let c=this.createError(RangeError,"invalid opcode 0",!0,1002,"WS_ERR_INVALID_OPCODE");e(c);return}this._opcode=this._fragmented}else if(this._opcode===1||this._opcode===2){if(this._fragmented){let c=this.createError(RangeError,`invalid opcode ${this._opcode}`,!0,1002,"WS_ERR_INVALID_OPCODE");e(c);return}this._compressed=o}else if(this._opcode>7&&this._opcode<11){if(!this._fin){let c=this.createError(RangeError,"FIN must be set",!0,1002,"WS_ERR_EXPECTED_FIN");e(c);return}if(o){let c=this.createError(RangeError,"RSV1 must be clear",!0,1002,"WS_ERR_UNEXPECTED_RSV_1");e(c);return}if(this._payloadLength>125||this._opcode===8&&this._payloadLength===1){let c=this.createError(RangeError,`invalid payload length ${this._payloadLength}`,!0,1002,"WS_ERR_INVALID_CONTROL_PAYLOAD_LENGTH");e(c);return}}else{let c=this.createError(RangeError,`invalid opcode ${this._opcode}`,!0,1002,"WS_ERR_INVALID_OPCODE");e(c);return}if(!this._fin&&!this._fragmented&&(this._fragmented=this._opcode),this._masked=(s[1]&128)===128,this._isServer){if(!this._masked){let c=this.createError(RangeError,"MASK must be set",!0,1002,"WS_ERR_EXPECTED_MASK");e(c);return}}else if(this._masked){let c=this.createError(RangeError,"MASK must be clear",!0,1002,"WS_ERR_UNEXPECTED_MASK");e(c);return}this._payloadLength===126?this._state=ha:this._payloadLength===127?this._state=pa: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 s=this.consume(8),o=s.readUInt32BE(0);if(o>Math.pow(2,21)-1){let c=this.createError(RangeError,"Unsupported WebSocket frame: payload length > 2^53 - 1",!1,1009,"WS_ERR_UNSUPPORTED_DATA_PAYLOAD_LENGTH");e(c);return}this._payloadLength=o*Math.pow(2,32)+s.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 s=this.createError(RangeError,"Max payload size exceeded",!1,1009,"WS_ERR_UNSUPPORTED_MESSAGE_LENGTH");e(s);return}this._masked?this._state=ma:this._state=mi}getMask(){if(this._bufferedBytes<4){this._loop=!1;return}this._mask=this.consume(4),this._state=mi}getData(e){let s=la;if(this._payloadLength){if(this._bufferedBytes<this._payloadLength){this._loop=!1;return}s=this.consume(this._payloadLength),this._masked&&(this._mask[0]|this._mask[1]|this._mask[2]|this._mask[3])!==0&&bf(s,this._mask)}if(this._opcode>7){this.controlMessage(s,e);return}if(this._compressed){this._state=wi,this.decompress(s,e);return}s.length&&(this._messageLength=this._totalPayloadLength,this._fragments.push(s)),this.dataMessage(e)}decompress(e,s){this._extensions[fa.extensionName].decompress(e,this._fin,(c,d)=>{if(c)return s(c);if(d.length){if(this._messageLength+=d.length,this._messageLength>this._maxPayload&&this._maxPayload>0){let u=this.createError(RangeError,"Max payload size exceeded",!1,1009,"WS_ERR_UNSUPPORTED_MESSAGE_LENGTH");s(u);return}this._fragments.push(d)}this.dataMessage(s),this._state===Pe&&this.startLoop(s)})}dataMessage(e){if(!this._fin){this._state=Pe;return}let s=this._messageLength,o=this._fragments;if(this._totalPayloadLength=0,this._messageLength=0,this._fragmented=0,this._fragments=[],this._opcode===2){let c;this._binaryType==="nodebuffer"?c=pi(o,s):this._binaryType==="arraybuffer"?c=yf(pi(o,s)):this._binaryType==="blob"?c=new Blob(o):c=o,this._allowSynchronousEvents?(this.emit("message",c,!0),this._state=Pe):(this._state=cr,setImmediate(()=>{this.emit("message",c,!0),this._state=Pe,this.startLoop(e)}))}else{let c=pi(o,s);if(!this._skipUTF8Validation&&!ga(c)){let d=this.createError(Error,"invalid UTF-8 sequence",!0,1007,"WS_ERR_INVALID_UTF8");e(d);return}this._state===wi||this._allowSynchronousEvents?(this.emit("message",c,!1),this._state=Pe):(this._state=cr,setImmediate(()=>{this.emit("message",c,!1),this._state=Pe,this.startLoop(e)}))}}controlMessage(e,s){if(this._opcode===8){if(e.length===0)this._loop=!1,this.emit("conclude",1005,la),this.end();else{let o=e.readUInt16BE(0);if(!vf(o)){let d=this.createError(RangeError,`invalid status code ${o}`,!0,1002,"WS_ERR_INVALID_CLOSE_CODE");s(d);return}let c=new ar(e.buffer,e.byteOffset+2,e.length-2);if(!this._skipUTF8Validation&&!ga(c)){let d=this.createError(Error,"invalid UTF-8 sequence",!0,1007,"WS_ERR_INVALID_UTF8");s(d);return}this._loop=!1,this.emit("conclude",o,c),this.end()}this._state=Pe;return}this._allowSynchronousEvents?(this.emit(this._opcode===9?"ping":"pong",e),this._state=Pe):(this._state=cr,setImmediate(()=>{this.emit(this._opcode===9?"ping":"pong",e),this._state=Pe,this.startLoop(s)}))}createError(e,s,o,c,d){this._loop=!1,this._errored=!0;let u=new e(o?`Invalid WebSocket frame: ${s}`:s);return Error.captureStackTrace(u,this.createError),u.code=d,u[wf]=c,u}};wa.exports=_i});var Si=_e((a_,ba)=>{"use strict";var{Duplex:o_}=ee("stream"),{randomFillSync:Sf}=ee("crypto"),_a=Mt(),{EMPTY_BUFFER:Ef,kWebSocket:If,NOOP:Af}=Je(),{isBlob:zt,isValidStatusCode:Cf}=Bt(),{mask:ya,toBuffer:lt}=an(),ke=Symbol("kByteLength"),Pf=Buffer.alloc(4),xr=8*1024,gt,Ft=xr,Re=0,kf=1,Tf=2,bi=class n{constructor(e,s,o){this._extensions=s||{},o&&(this._generateMask=o,this._maskBuffer=Buffer.alloc(4)),this._socket=e,this._firstFragment=!0,this._compress=!1,this._bufferedBytes=0,this._queue=[],this._state=Re,this.onerror=Af,this[If]=void 0}static frame(e,s){let o,c=!1,d=2,u=!1;s.mask&&(o=s.maskBuffer||Pf,s.generateMask?s.generateMask(o):(Ft===xr&&(gt===void 0&&(gt=Buffer.alloc(xr)),Sf(gt,0,xr),Ft=0),o[0]=gt[Ft++],o[1]=gt[Ft++],o[2]=gt[Ft++],o[3]=gt[Ft++]),u=(o[0]|o[1]|o[2]|o[3])===0,d=6);let l;typeof e=="string"?(!s.mask||u)&&s[ke]!==void 0?l=s[ke]:(e=Buffer.from(e),l=e.length):(l=e.length,c=s.mask&&s.readOnly&&!u);let p=l;l>=65536?(d+=8,p=127):l>125&&(d+=2,p=126);let m=Buffer.allocUnsafe(c?l+d:d);return m[0]=s.fin?s.opcode|128:s.opcode,s.rsv1&&(m[0]|=64),m[1]=p,p===126?m.writeUInt16BE(l,2):p===127&&(m[2]=m[3]=0,m.writeUIntBE(l,4,6)),s.mask?(m[1]|=128,m[d-4]=o[0],m[d-3]=o[1],m[d-2]=o[2],m[d-1]=o[3],u?[m,e]:c?(ya(e,o,m,d,l),[m]):(ya(e,o,e,0,l),[m,e])):[m,e]}close(e,s,o,c){let d;if(e===void 0)d=Ef;else{if(typeof e!="number"||!Cf(e))throw new TypeError("First argument must be a valid error code number");if(s===void 0||!s.length)d=Buffer.allocUnsafe(2),d.writeUInt16BE(e,0);else{let l=Buffer.byteLength(s);if(l>123)throw new RangeError("The message must not be greater than 123 bytes");d=Buffer.allocUnsafe(2+l),d.writeUInt16BE(e,0),typeof s=="string"?d.write(s,2):d.set(s,2)}}let u={[ke]:d.length,fin:!0,generateMask:this._generateMask,mask:o,maskBuffer:this._maskBuffer,opcode:8,readOnly:!1,rsv1:!1};this._state!==Re?this.enqueue([this.dispatch,d,!1,u,c]):this.sendFrame(n.frame(d,u),c)}ping(e,s,o){let c,d;if(typeof e=="string"?(c=Buffer.byteLength(e),d=!1):zt(e)?(c=e.size,d=!1):(e=lt(e),c=e.length,d=lt.readOnly),c>125)throw new RangeError("The data size must not be greater than 125 bytes");let u={[ke]:c,fin:!0,generateMask:this._generateMask,mask:s,maskBuffer:this._maskBuffer,opcode:9,readOnly:d,rsv1:!1};zt(e)?this._state!==Re?this.enqueue([this.getBlobData,e,!1,u,o]):this.getBlobData(e,!1,u,o):this._state!==Re?this.enqueue([this.dispatch,e,!1,u,o]):this.sendFrame(n.frame(e,u),o)}pong(e,s,o){let c,d;if(typeof e=="string"?(c=Buffer.byteLength(e),d=!1):zt(e)?(c=e.size,d=!1):(e=lt(e),c=e.length,d=lt.readOnly),c>125)throw new RangeError("The data size must not be greater than 125 bytes");let u={[ke]:c,fin:!0,generateMask:this._generateMask,mask:s,maskBuffer:this._maskBuffer,opcode:10,readOnly:d,rsv1:!1};zt(e)?this._state!==Re?this.enqueue([this.getBlobData,e,!1,u,o]):this.getBlobData(e,!1,u,o):this._state!==Re?this.enqueue([this.dispatch,e,!1,u,o]):this.sendFrame(n.frame(e,u),o)}send(e,s,o){let c=this._extensions[_a.extensionName],d=s.binary?2:1,u=s.compress,l,p;typeof e=="string"?(l=Buffer.byteLength(e),p=!1):zt(e)?(l=e.size,p=!1):(e=lt(e),l=e.length,p=lt.readOnly),this._firstFragment?(this._firstFragment=!1,u&&c&&c.params[c._isServer?"server_no_context_takeover":"client_no_context_takeover"]&&(u=l>=c._threshold),this._compress=u):(u=!1,d=0),s.fin&&(this._firstFragment=!0);let m={[ke]:l,fin:s.fin,generateMask:this._generateMask,mask:s.mask,maskBuffer:this._maskBuffer,opcode:d,readOnly:p,rsv1:u};zt(e)?this._state!==Re?this.enqueue([this.getBlobData,e,this._compress,m,o]):this.getBlobData(e,this._compress,m,o):this._state!==Re?this.enqueue([this.dispatch,e,this._compress,m,o]):this.dispatch(e,this._compress,m,o)}getBlobData(e,s,o,c){this._bufferedBytes+=o[ke],this._state=Tf,e.arrayBuffer().then(d=>{if(this._socket.destroyed){let l=new Error("The socket was closed while the blob was being read");process.nextTick(vi,this,l,c);return}this._bufferedBytes-=o[ke];let u=lt(d);s?this.dispatch(u,s,o,c):(this._state=Re,this.sendFrame(n.frame(u,o),c),this.dequeue())}).catch(d=>{process.nextTick(Df,this,d,c)})}dispatch(e,s,o,c){if(!s){this.sendFrame(n.frame(e,o),c);return}let d=this._extensions[_a.extensionName];this._bufferedBytes+=o[ke],this._state=kf,d.compress(e,o.fin,(u,l)=>{if(this._socket.destroyed){let p=new Error("The socket was closed while data was being compressed");vi(this,p,c);return}this._bufferedBytes-=o[ke],this._state=Re,o.readOnly=!1,this.sendFrame(n.frame(l,o),c),this.dequeue()})}dequeue(){for(;this._state===Re&&this._queue.length;){let e=this._queue.shift();this._bufferedBytes-=e[3][ke],Reflect.apply(e[0],this,e.slice(1))}}enqueue(e){this._bufferedBytes+=e[3][ke],this._queue.push(e)}sendFrame(e,s){e.length===2?(this._socket.cork(),this._socket.write(e[0]),this._socket.write(e[1],s),this._socket.uncork()):this._socket.write(e[0],s)}};ba.exports=bi;function vi(n,e,s){typeof s=="function"&&s(e);for(let o=0;o<n._queue.length;o++){let c=n._queue[o],d=c[c.length-1];typeof d=="function"&&d(e)}}function Df(n,e,s){vi(n,e,s),n.onerror(e)}});var Ta=_e((c_,ka)=>{"use strict";var{kForOnEventAttribute:xn,kListener:Ei}=Je(),va=Symbol("kCode"),Sa=Symbol("kData"),Ea=Symbol("kError"),Ia=Symbol("kMessage"),Aa=Symbol("kReason"),Ut=Symbol("kTarget"),Ca=Symbol("kType"),Pa=Symbol("kWasClean"),Ve=class{constructor(e){this[Ut]=null,this[Ca]=e}get target(){return this[Ut]}get type(){return this[Ca]}};Object.defineProperty(Ve.prototype,"target",{enumerable:!0});Object.defineProperty(Ve.prototype,"type",{enumerable:!0});var ht=class extends Ve{constructor(e,s={}){super(e),this[va]=s.code===void 0?0:s.code,this[Aa]=s.reason===void 0?"":s.reason,this[Pa]=s.wasClean===void 0?!1:s.wasClean}get code(){return this[va]}get reason(){return this[Aa]}get wasClean(){return this[Pa]}};Object.defineProperty(ht.prototype,"code",{enumerable:!0});Object.defineProperty(ht.prototype,"reason",{enumerable:!0});Object.defineProperty(ht.prototype,"wasClean",{enumerable:!0});var qt=class extends Ve{constructor(e,s={}){super(e),this[Ea]=s.error===void 0?null:s.error,this[Ia]=s.message===void 0?"":s.message}get error(){return this[Ea]}get message(){return this[Ia]}};Object.defineProperty(qt.prototype,"error",{enumerable:!0});Object.defineProperty(qt.prototype,"message",{enumerable:!0});var dn=class extends Ve{constructor(e,s={}){super(e),this[Sa]=s.data===void 0?null:s.data}get data(){return this[Sa]}};Object.defineProperty(dn.prototype,"data",{enumerable:!0});var Rf={addEventListener(n,e,s={}){for(let c of this.listeners(n))if(!s[xn]&&c[Ei]===e&&!c[xn])return;let o;if(n==="message")o=function(d,u){let l=new dn("message",{data:u?d:d.toString()});l[Ut]=this,dr(e,this,l)};else if(n==="close")o=function(d,u){let l=new ht("close",{code:d,reason:u.toString(),wasClean:this._closeFrameReceived&&this._closeFrameSent});l[Ut]=this,dr(e,this,l)};else if(n==="error")o=function(d){let u=new qt("error",{error:d,message:d.message});u[Ut]=this,dr(e,this,u)};else if(n==="open")o=function(){let d=new Ve("open");d[Ut]=this,dr(e,this,d)};else return;o[xn]=!!s[xn],o[Ei]=e,s.once?this.once(n,o):this.on(n,o)},removeEventListener(n,e){for(let s of this.listeners(n))if(s[Ei]===e&&!s[xn]){this.removeListener(n,s);break}}};ka.exports={CloseEvent:ht,ErrorEvent:qt,Event:Ve,EventTarget:Rf,MessageEvent:dn};function dr(n,e,s){typeof n=="object"&&n.handleEvent?n.handleEvent.call(n,s):n.call(e,s)}});var ur=_e((x_,Da)=>{"use strict";var{tokenChars:un}=Bt();function qe(n,e,s){n[e]===void 0?n[e]=[s]:n[e].push(s)}function Lf(n){let e=Object.create(null),s=Object.create(null),o=!1,c=!1,d=!1,u,l,p=-1,m=-1,_=-1,y=0;for(;y<n.length;y++)if(m=n.charCodeAt(y),u===void 0)if(_===-1&&un[m]===1)p===-1&&(p=y);else if(y!==0&&(m===32||m===9))_===-1&&p!==-1&&(_=y);else if(m===59||m===44){if(p===-1)throw new SyntaxError(`Unexpected character at index ${y}`);_===-1&&(_=y);let L=n.slice(p,_);m===44?(qe(e,L,s),s=Object.create(null)):u=L,p=_=-1}else throw new SyntaxError(`Unexpected character at index ${y}`);else if(l===void 0)if(_===-1&&un[m]===1)p===-1&&(p=y);else if(m===32||m===9)_===-1&&p!==-1&&(_=y);else if(m===59||m===44){if(p===-1)throw new SyntaxError(`Unexpected character at index ${y}`);_===-1&&(_=y),qe(s,n.slice(p,_),!0),m===44&&(qe(e,u,s),s=Object.create(null),u=void 0),p=_=-1}else if(m===61&&p!==-1&&_===-1)l=n.slice(p,y),p=_=-1;else throw new SyntaxError(`Unexpected character at index ${y}`);else if(c){if(un[m]!==1)throw new SyntaxError(`Unexpected character at index ${y}`);p===-1?p=y:o||(o=!0),c=!1}else if(d)if(un[m]===1)p===-1&&(p=y);else if(m===34&&p!==-1)d=!1,_=y;else if(m===92)c=!0;else throw new SyntaxError(`Unexpected character at index ${y}`);else if(m===34&&n.charCodeAt(y-1)===61)d=!0;else if(_===-1&&un[m]===1)p===-1&&(p=y);else if(p!==-1&&(m===32||m===9))_===-1&&(_=y);else if(m===59||m===44){if(p===-1)throw new SyntaxError(`Unexpected character at index ${y}`);_===-1&&(_=y);let L=n.slice(p,_);o&&(L=L.replace(/\\/g,""),o=!1),qe(s,l,L),m===44&&(qe(e,u,s),s=Object.create(null),u=void 0),l=void 0,p=_=-1}else throw new SyntaxError(`Unexpected character at index ${y}`);if(p===-1||d||m===32||m===9)throw new SyntaxError("Unexpected end of input");_===-1&&(_=y);let I=n.slice(p,_);return u===void 0?qe(e,I,s):(l===void 0?qe(s,I,!0):o?qe(s,l,I.replace(/\\/g,"")):qe(s,l,I),qe(e,u,s)),e}function Of(n){return Object.keys(n).map(e=>{let s=n[e];return Array.isArray(s)||(s=[s]),s.map(o=>[e].concat(Object.keys(o).map(c=>{let d=o[c];return Array.isArray(d)||(d=[d]),d.map(u=>u===!0?c:`${c}=${u}`).join("; ")})).join("; ")).join(", ")}).join(", ")}Da.exports={format:Of,parse:Lf}});var hr=_e((f_,ja)=>{"use strict";var Nf=ee("events"),Mf=ee("https"),Bf=ee("http"),Oa=ee("net"),zf=ee("tls"),{randomBytes:Ff,createHash:Uf}=ee("crypto"),{Duplex:d_,Readable:u_}=ee("stream"),{URL:Ii}=ee("url"),xt=Mt(),qf=yi(),Hf=Si(),{isBlob:jf}=Bt(),{BINARY_TYPES:Ra,CLOSE_TIMEOUT:Kf,EMPTY_BUFFER:fr,GUID:Gf,kForOnEventAttribute:Ai,kListener:Wf,kStatusCode:Jf,kWebSocket:ce,NOOP:Na}=Je(),{EventTarget:{addEventListener:$f,removeEventListener:Vf}}=Ta(),{format:Yf,parse:Xf}=ur(),{toBuffer:Qf}=an(),Ma=Symbol("kAborted"),Ci=[8,13],Ye=["CONNECTING","OPEN","CLOSING","CLOSED"],Zf=/^[!#$%&'*+\-.0-9A-Z^_`|a-z~]+$/,J=class n extends Nf{constructor(e,s,o){super(),this._binaryType=Ra[0],this._closeCode=1006,this._closeFrameReceived=!1,this._closeFrameSent=!1,this._closeMessage=fr,this._closeTimer=null,this._errorEmitted=!1,this._extensions={},this._paused=!1,this._protocol="",this._readyState=n.CONNECTING,this._receiver=null,this._sender=null,this._socket=null,e!==null?(this._bufferedAmount=0,this._isServer=!1,this._redirects=0,s===void 0?s=[]:Array.isArray(s)||(typeof s=="object"&&s!==null?(o=s,s=[]):s=[s]),Ba(this,e,s,o)):(this._autoPong=o.autoPong,this._closeTimeout=o.closeTimeout,this._isServer=!0)}get binaryType(){return this._binaryType}set binaryType(e){Ra.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,s,o){let c=new qf({allowSynchronousEvents:o.allowSynchronousEvents,binaryType:this.binaryType,extensions:this._extensions,isServer:this._isServer,maxPayload:o.maxPayload,skipUTF8Validation:o.skipUTF8Validation}),d=new Hf(e,this._extensions,o.generateMask);this._receiver=c,this._sender=d,this._socket=e,c[ce]=this,d[ce]=this,e[ce]=this,c.on("conclude",nl),c.on("drain",rl),c.on("error",il),c.on("message",sl),c.on("ping",ol),c.on("pong",al),d.onerror=cl,e.setTimeout&&e.setTimeout(0),e.setNoDelay&&e.setNoDelay(),s.length>0&&e.unshift(s),e.on("close",Ua),e.on("data",gr),e.on("end",qa),e.on("error",Ha),this._readyState=n.OPEN,this.emit("open")}emitClose(){if(!this._socket){this._readyState=n.CLOSED,this.emit("close",this._closeCode,this._closeMessage);return}this._extensions[xt.extensionName]&&this._extensions[xt.extensionName].cleanup(),this._receiver.removeAllListeners(),this._readyState=n.CLOSED,this.emit("close",this._closeCode,this._closeMessage)}close(e,s){if(this.readyState!==n.CLOSED){if(this.readyState===n.CONNECTING){Ee(this,this._req,"WebSocket was closed before the connection was established");return}if(this.readyState===n.CLOSING){this._closeFrameSent&&(this._closeFrameReceived||this._receiver._writableState.errorEmitted)&&this._socket.end();return}this._readyState=n.CLOSING,this._sender.close(e,s,!this._isServer,o=>{o||(this._closeFrameSent=!0,(this._closeFrameReceived||this._receiver._writableState.errorEmitted)&&this._socket.end())}),Fa(this)}}pause(){this.readyState===n.CONNECTING||this.readyState===n.CLOSED||(this._paused=!0,this._socket.pause())}ping(e,s,o){if(this.readyState===n.CONNECTING)throw new Error("WebSocket is not open: readyState 0 (CONNECTING)");if(typeof e=="function"?(o=e,e=s=void 0):typeof s=="function"&&(o=s,s=void 0),typeof e=="number"&&(e=e.toString()),this.readyState!==n.OPEN){Pi(this,e,o);return}s===void 0&&(s=!this._isServer),this._sender.ping(e||fr,s,o)}pong(e,s,o){if(this.readyState===n.CONNECTING)throw new Error("WebSocket is not open: readyState 0 (CONNECTING)");if(typeof e=="function"?(o=e,e=s=void 0):typeof s=="function"&&(o=s,s=void 0),typeof e=="number"&&(e=e.toString()),this.readyState!==n.OPEN){Pi(this,e,o);return}s===void 0&&(s=!this._isServer),this._sender.pong(e||fr,s,o)}resume(){this.readyState===n.CONNECTING||this.readyState===n.CLOSED||(this._paused=!1,this._receiver._writableState.needDrain||this._socket.resume())}send(e,s,o){if(this.readyState===n.CONNECTING)throw new Error("WebSocket is not open: readyState 0 (CONNECTING)");if(typeof s=="function"&&(o=s,s={}),typeof e=="number"&&(e=e.toString()),this.readyState!==n.OPEN){Pi(this,e,o);return}let c={binary:typeof e!="string",mask:!this._isServer,compress:!0,fin:!0,...s};this._extensions[xt.extensionName]||(c.compress=!1),this._sender.send(e||fr,c,o)}terminate(){if(this.readyState!==n.CLOSED){if(this.readyState===n.CONNECTING){Ee(this,this._req,"WebSocket was closed before the connection was established");return}this._socket&&(this._readyState=n.CLOSING,this._socket.destroy())}}};Object.defineProperty(J,"CONNECTING",{enumerable:!0,value:Ye.indexOf("CONNECTING")});Object.defineProperty(J.prototype,"CONNECTING",{enumerable:!0,value:Ye.indexOf("CONNECTING")});Object.defineProperty(J,"OPEN",{enumerable:!0,value:Ye.indexOf("OPEN")});Object.defineProperty(J.prototype,"OPEN",{enumerable:!0,value:Ye.indexOf("OPEN")});Object.defineProperty(J,"CLOSING",{enumerable:!0,value:Ye.indexOf("CLOSING")});Object.defineProperty(J.prototype,"CLOSING",{enumerable:!0,value:Ye.indexOf("CLOSING")});Object.defineProperty(J,"CLOSED",{enumerable:!0,value:Ye.indexOf("CLOSED")});Object.defineProperty(J.prototype,"CLOSED",{enumerable:!0,value:Ye.indexOf("CLOSED")});["binaryType","bufferedAmount","extensions","isPaused","protocol","readyState","url"].forEach(n=>{Object.defineProperty(J.prototype,n,{enumerable:!0})});["open","error","close","message"].forEach(n=>{Object.defineProperty(J.prototype,`on${n}`,{enumerable:!0,get(){for(let e of this.listeners(n))if(e[Ai])return e[Wf];return null},set(e){for(let s of this.listeners(n))if(s[Ai]){this.removeListener(n,s);break}typeof e=="function"&&this.addEventListener(n,e,{[Ai]:!0})}})});J.prototype.addEventListener=$f;J.prototype.removeEventListener=Vf;ja.exports=J;function Ba(n,e,s,o){let c={allowSynchronousEvents:!0,autoPong:!0,closeTimeout:Kf,protocolVersion:Ci[1],maxPayload:104857600,skipUTF8Validation:!1,perMessageDeflate:!0,followRedirects:!1,maxRedirects:10,...o,socketPath:void 0,hostname:void 0,protocol:void 0,timeout:void 0,method:"GET",host:void 0,path:void 0,port:void 0};if(n._autoPong=c.autoPong,n._closeTimeout=c.closeTimeout,!Ci.includes(c.protocolVersion))throw new RangeError(`Unsupported protocol version: ${c.protocolVersion} (supported versions: ${Ci.join(", ")})`);let d;if(e instanceof Ii)d=e;else try{d=new Ii(e)}catch{throw new SyntaxError(`Invalid URL: ${e}`)}d.protocol==="http:"?d.protocol="ws:":d.protocol==="https:"&&(d.protocol="wss:"),n._url=d.href;let u=d.protocol==="wss:",l=d.protocol==="ws+unix:",p;if(d.protocol!=="ws:"&&!u&&!l?p=`The URL's protocol must be one of "ws:", "wss:", "http:", "https:", or "ws+unix:"`:l&&!d.pathname?p="The URL's pathname is empty":d.hash&&(p="The URL contains a fragment identifier"),p){let P=new SyntaxError(p);if(n._redirects===0)throw P;lr(n,P);return}let m=u?443:80,_=Ff(16).toString("base64"),y=u?Mf.request:Bf.request,I=new Set,L;if(c.createConnection=c.createConnection||(u?tl:el),c.defaultPort=c.defaultPort||m,c.port=d.port||m,c.host=d.hostname.startsWith("[")?d.hostname.slice(1,-1):d.hostname,c.headers={...c.headers,"Sec-WebSocket-Version":c.protocolVersion,"Sec-WebSocket-Key":_,Connection:"Upgrade",Upgrade:"websocket"},c.path=d.pathname+d.search,c.timeout=c.handshakeTimeout,c.perMessageDeflate&&(L=new xt({...c.perMessageDeflate,isServer:!1,maxPayload:c.maxPayload}),c.headers["Sec-WebSocket-Extensions"]=Yf({[xt.extensionName]:L.offer()})),s.length){for(let P of s){if(typeof P!="string"||!Zf.test(P)||I.has(P))throw new SyntaxError("An invalid or duplicated subprotocol was specified");I.add(P)}c.headers["Sec-WebSocket-Protocol"]=s.join(",")}if(c.origin&&(c.protocolVersion<13?c.headers["Sec-WebSocket-Origin"]=c.origin:c.headers.Origin=c.origin),(d.username||d.password)&&(c.auth=`${d.username}:${d.password}`),l){let P=c.path.split(":");c.socketPath=P[0],c.path=P[1]}let T;if(c.followRedirects){if(n._redirects===0){n._originalIpc=l,n._originalSecure=u,n._originalHostOrSocketPath=l?c.socketPath:d.host;let P=o&&o.headers;if(o={...o,headers:{}},P)for(let[j,Q]of Object.entries(P))o.headers[j.toLowerCase()]=Q}else if(n.listenerCount("redirect")===0){let P=l?n._originalIpc?c.socketPath===n._originalHostOrSocketPath:!1:n._originalIpc?!1:d.host===n._originalHostOrSocketPath;(!P||n._originalSecure&&!u)&&(delete c.headers.authorization,delete c.headers.cookie,P||delete c.headers.host,c.auth=void 0)}c.auth&&!o.headers.authorization&&(o.headers.authorization="Basic "+Buffer.from(c.auth).toString("base64")),T=n._req=y(c),n._redirects&&n.emit("redirect",n.url,T)}else T=n._req=y(c);c.timeout&&T.on("timeout",()=>{Ee(n,T,"Opening handshake has timed out")}),T.on("error",P=>{T===null||T[Ma]||(T=n._req=null,lr(n,P))}),T.on("response",P=>{let j=P.headers.location,Q=P.statusCode;if(j&&c.followRedirects&&Q>=300&&Q<400){if(++n._redirects>c.maxRedirects){Ee(n,T,"Maximum redirects exceeded");return}T.abort();let K;try{K=new Ii(j,e)}catch{let se=new SyntaxError(`Invalid URL: ${j}`);lr(n,se);return}Ba(n,K,s,o)}else n.emit("unexpected-response",T,P)||Ee(n,T,`Unexpected server response: ${P.statusCode}`)}),T.on("upgrade",(P,j,Q)=>{if(n.emit("upgrade",P),n.readyState!==J.CONNECTING)return;T=n._req=null;let K=P.headers.upgrade;if(K===void 0||K.toLowerCase()!=="websocket"){Ee(n,j,"Invalid Upgrade header");return}let $=Uf("sha1").update(_+Gf).digest("base64");if(P.headers["sec-websocket-accept"]!==$){Ee(n,j,"Invalid Sec-WebSocket-Accept header");return}let se=P.headers["sec-websocket-protocol"],oe;if(se!==void 0?I.size?I.has(se)||(oe="Server sent an invalid subprotocol"):oe="Server sent a subprotocol but none was requested":I.size&&(oe="Server sent no subprotocol"),oe){Ee(n,j,oe);return}se&&(n._protocol=se);let Te=P.headers["sec-websocket-extensions"];if(Te!==void 0){if(!L){Ee(n,j,"Server sent a Sec-WebSocket-Extensions header but no extension was requested");return}let pe;try{pe=Xf(Te)}catch{Ee(n,j,"Invalid Sec-WebSocket-Extensions header");return}let xe=Object.keys(pe);if(xe.length!==1||xe[0]!==xt.extensionName){Ee(n,j,"Server indicated an extension that was not requested");return}try{L.accept(pe[xt.extensionName])}catch{Ee(n,j,"Invalid Sec-WebSocket-Extensions header");return}n._extensions[xt.extensionName]=L}n.setSocket(j,Q,{allowSynchronousEvents:c.allowSynchronousEvents,generateMask:c.generateMask,maxPayload:c.maxPayload,skipUTF8Validation:c.skipUTF8Validation})}),c.finishRequest?c.finishRequest(T,n):T.end()}function lr(n,e){n._readyState=J.CLOSING,n._errorEmitted=!0,n.emit("error",e),n.emitClose()}function el(n){return n.path=n.socketPath,Oa.connect(n)}function tl(n){return n.path=void 0,!n.servername&&n.servername!==""&&(n.servername=Oa.isIP(n.host)?"":n.host),zf.connect(n)}function Ee(n,e,s){n._readyState=J.CLOSING;let o=new Error(s);Error.captureStackTrace(o,Ee),e.setHeader?(e[Ma]=!0,e.abort(),e.socket&&!e.socket.destroyed&&e.socket.destroy(),process.nextTick(lr,n,o)):(e.destroy(o),e.once("error",n.emit.bind(n,"error")),e.once("close",n.emitClose.bind(n)))}function Pi(n,e,s){if(e){let o=jf(e)?e.size:Qf(e).length;n._socket?n._sender._bufferedBytes+=o:n._bufferedAmount+=o}if(s){let o=new Error(`WebSocket is not open: readyState ${n.readyState} (${Ye[n.readyState]})`);process.nextTick(s,o)}}function nl(n,e){let s=this[ce];s._closeFrameReceived=!0,s._closeMessage=e,s._closeCode=n,s._socket[ce]!==void 0&&(s._socket.removeListener("data",gr),process.nextTick(za,s._socket),n===1005?s.close():s.close(n,e))}function rl(){let n=this[ce];n.isPaused||n._socket.resume()}function il(n){let e=this[ce];e._socket[ce]!==void 0&&(e._socket.removeListener("data",gr),process.nextTick(za,e._socket),e.close(n[Jf])),e._errorEmitted||(e._errorEmitted=!0,e.emit("error",n))}function La(){this[ce].emitClose()}function sl(n,e){this[ce].emit("message",n,e)}function ol(n){let e=this[ce];e._autoPong&&e.pong(n,!this._isServer,Na),e.emit("ping",n)}function al(n){this[ce].emit("pong",n)}function za(n){n.resume()}function cl(n){let e=this[ce];e.readyState!==J.CLOSED&&(e.readyState===J.OPEN&&(e._readyState=J.CLOSING,Fa(e)),this._socket.end(),e._errorEmitted||(e._errorEmitted=!0,e.emit("error",n)))}function Fa(n){n._closeTimer=setTimeout(n._socket.destroy.bind(n._socket),n._closeTimeout)}function Ua(){let n=this[ce];if(this.removeListener("close",Ua),this.removeListener("data",gr),this.removeListener("end",qa),n._readyState=J.CLOSING,!this._readableState.endEmitted&&!n._closeFrameReceived&&!n._receiver._writableState.errorEmitted&&this._readableState.length!==0){let e=this.read(this._readableState.length);n._receiver.write(e)}n._receiver.end(),this[ce]=void 0,clearTimeout(n._closeTimer),n._receiver._writableState.finished||n._receiver._writableState.errorEmitted?n.emitClose():(n._receiver.on("error",La),n._receiver.on("finish",La))}function gr(n){this[ce]._receiver.write(n)||this.pause()}function qa(){let n=this[ce];n._readyState=J.CLOSING,n._receiver.end(),this.end()}function Ha(){let n=this[ce];this.removeListener("error",Ha),this.on("error",Na),n&&(n._readyState=J.CLOSING,this.destroy())}});var Ja=_e((g_,Wa)=>{"use strict";var l_=hr(),{Duplex:xl}=ee("stream");function Ka(n){n.emit("close")}function dl(){!this.destroyed&&this._writableState.finished&&this.destroy()}function Ga(n){this.removeListener("error",Ga),this.destroy(),this.listenerCount("error")===0&&this.emit("error",n)}function ul(n,e){let s=!0,o=new xl({...e,autoDestroy:!1,emitClose:!1,objectMode:!1,writableObjectMode:!1});return n.on("message",function(d,u){let l=!u&&o._readableState.objectMode?d.toString():d;o.push(l)||n.pause()}),n.once("error",function(d){o.destroyed||(s=!1,o.destroy(d))}),n.once("close",function(){o.destroyed||o.push(null)}),o._destroy=function(c,d){if(n.readyState===n.CLOSED){d(c),process.nextTick(Ka,o);return}let u=!1;n.once("error",function(p){u=!0,d(p)}),n.once("close",function(){u||d(c),process.nextTick(Ka,o)}),s&&n.terminate()},o._final=function(c){if(n.readyState===n.CONNECTING){n.once("open",function(){o._final(c)});return}n._socket!==null&&(n._socket._writableState.finished?(c(),o._readableState.endEmitted&&o.destroy()):(n._socket.once("finish",function(){c()}),n.close()))},o._read=function(){n.isPaused&&n.resume()},o._write=function(c,d,u){if(n.readyState===n.CONNECTING){n.once("open",function(){o._write(c,d,u)});return}n.send(c,u)},o.on("end",dl),o.on("error",Ga),o}Wa.exports=ul});var ki=_e((h_,$a)=>{"use strict";var{tokenChars:fl}=Bt();function ll(n){let e=new Set,s=-1,o=-1,c=0;for(c;c<n.length;c++){let u=n.charCodeAt(c);if(o===-1&&fl[u]===1)s===-1&&(s=c);else if(c!==0&&(u===32||u===9))o===-1&&s!==-1&&(o=c);else if(u===44){if(s===-1)throw new SyntaxError(`Unexpected character at index ${c}`);o===-1&&(o=c);let l=n.slice(s,o);if(e.has(l))throw new SyntaxError(`The "${l}" subprotocol is duplicated`);e.add(l),s=o=-1}else throw new SyntaxError(`Unexpected character at index ${c}`)}if(s===-1||o!==-1)throw new SyntaxError("Unexpected end of input");let d=n.slice(s,c);if(e.has(d))throw new SyntaxError(`The "${d}" subprotocol is duplicated`);return e.add(d),e}$a.exports={parse:ll}});var tc=_e((m_,ec)=>{"use strict";var gl=ee("events"),pr=ee("http"),{Duplex:p_}=ee("stream"),{createHash:hl}=ee("crypto"),Va=ur(),pt=Mt(),pl=ki(),ml=hr(),{CLOSE_TIMEOUT:wl,GUID:_l,kWebSocket:yl}=Je(),bl=/^[+/0-9A-Za-z]{22}==$/,Ya=0,Xa=1,Za=2,Ti=class extends gl{constructor(e,s){if(super(),e={allowSynchronousEvents:!0,autoPong:!0,maxPayload:100*1024*1024,skipUTF8Validation:!1,perMessageDeflate:!1,handleProtocols:null,clientTracking:!0,closeTimeout:wl,verifyClient:null,noServer:!1,backlog:null,server:null,host:null,path:null,port:null,WebSocket:ml,...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=pr.createServer((o,c)=>{let d=pr.STATUS_CODES[426];c.writeHead(426,{"Content-Length":d.length,"Content-Type":"text/plain"}),c.end(d)}),this._server.listen(e.port,e.host,e.backlog,s)):e.server&&(this._server=e.server),this._server){let o=this.emit.bind(this,"connection");this._removeListeners=vl(this._server,{listening:this.emit.bind(this,"listening"),error:this.emit.bind(this,"error"),upgrade:(c,d,u)=>{this.handleUpgrade(c,d,u,o)}})}e.perMessageDeflate===!0&&(e.perMessageDeflate={}),e.clientTracking&&(this.clients=new Set,this._shouldEmitClose=!1),this.options=e,this._state=Ya}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===Za){e&&this.once("close",()=>{e(new Error("The server is not running"))}),process.nextTick(fn,this);return}if(e&&this.once("close",e),this._state!==Xa)if(this._state=Xa,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(fn,this):process.nextTick(fn,this);else{let s=this._server;this._removeListeners(),this._removeListeners=this._server=null,s.close(()=>{fn(this)})}}shouldHandle(e){if(this.options.path){let s=e.url.indexOf("?");if((s!==-1?e.url.slice(0,s):e.url)!==this.options.path)return!1}return!0}handleUpgrade(e,s,o,c){s.on("error",Qa);let d=e.headers["sec-websocket-key"],u=e.headers.upgrade,l=+e.headers["sec-websocket-version"];if(e.method!=="GET"){mt(this,e,s,405,"Invalid HTTP method");return}if(u===void 0||u.toLowerCase()!=="websocket"){mt(this,e,s,400,"Invalid Upgrade header");return}if(d===void 0||!bl.test(d)){mt(this,e,s,400,"Missing or invalid Sec-WebSocket-Key header");return}if(l!==13&&l!==8){mt(this,e,s,400,"Missing or invalid Sec-WebSocket-Version header",{"Sec-WebSocket-Version":"13, 8"});return}if(!this.shouldHandle(e)){ln(s,400);return}let p=e.headers["sec-websocket-protocol"],m=new Set;if(p!==void 0)try{m=pl.parse(p)}catch{mt(this,e,s,400,"Invalid Sec-WebSocket-Protocol header");return}let _=e.headers["sec-websocket-extensions"],y={};if(this.options.perMessageDeflate&&_!==void 0){let I=new pt({...this.options.perMessageDeflate,isServer:!0,maxPayload:this.options.maxPayload});try{let L=Va.parse(_);L[pt.extensionName]&&(I.accept(L[pt.extensionName]),y[pt.extensionName]=I)}catch{mt(this,e,s,400,"Invalid or unacceptable Sec-WebSocket-Extensions header");return}}if(this.options.verifyClient){let I={origin:e.headers[`${l===8?"sec-websocket-origin":"origin"}`],secure:!!(e.socket.authorized||e.socket.encrypted),req:e};if(this.options.verifyClient.length===2){this.options.verifyClient(I,(L,T,P,j)=>{if(!L)return ln(s,T||401,P,j);this.completeUpgrade(y,d,m,e,s,o,c)});return}if(!this.options.verifyClient(I))return ln(s,401)}this.completeUpgrade(y,d,m,e,s,o,c)}completeUpgrade(e,s,o,c,d,u,l){if(!d.readable||!d.writable)return d.destroy();if(d[yl])throw new Error("server.handleUpgrade() was called more than once with the same socket, possibly due to a misconfiguration");if(this._state>Ya)return ln(d,503);let m=["HTTP/1.1 101 Switching Protocols","Upgrade: websocket","Connection: Upgrade",`Sec-WebSocket-Accept: ${hl("sha1").update(s+_l).digest("base64")}`],_=new this.options.WebSocket(null,void 0,this.options);if(o.size){let y=this.options.handleProtocols?this.options.handleProtocols(o,c):o.values().next().value;y&&(m.push(`Sec-WebSocket-Protocol: ${y}`),_._protocol=y)}if(e[pt.extensionName]){let y=e[pt.extensionName].params,I=Va.format({[pt.extensionName]:[y]});m.push(`Sec-WebSocket-Extensions: ${I}`),_._extensions=e}this.emit("headers",m,c),d.write(m.concat(`\r
|
|
12
12
|
`).join(`\r
|
|
13
|
-
`)),
|
|
13
|
+
`)),d.removeListener("error",Qa),_.setSocket(d,u,{allowSynchronousEvents:this.options.allowSynchronousEvents,maxPayload:this.options.maxPayload,skipUTF8Validation:this.options.skipUTF8Validation}),this.clients&&(this.clients.add(_),_.on("close",()=>{this.clients.delete(_),this._shouldEmitClose&&!this.clients.size&&process.nextTick(fn,this)})),l(_,c)}};ec.exports=Ti;function vl(n,e){for(let s of Object.keys(e))n.on(s,e[s]);return function(){for(let o of Object.keys(e))n.removeListener(o,e[o])}}function fn(n){n._state=Za,n.emit("close")}function Qa(){this.destroy()}function ln(n,e,s,o){s=s||pr.STATUS_CODES[e],o={Connection:"close","Content-Type":"text/html","Content-Length":Buffer.byteLength(s),...o},n.once("finish",n.destroy),n.end(`HTTP/1.1 ${e} ${pr.STATUS_CODES[e]}\r
|
|
14
14
|
`+Object.keys(o).map(c=>`${c}: ${o[c]}`).join(`\r
|
|
15
15
|
`)+`\r
|
|
16
16
|
\r
|
|
17
|
-
`+s)}function
|
|
17
|
+
`+s)}function mt(n,e,s,o,c,d){if(n.listenerCount("wsClientError")){let u=new Error(c);Error.captureStackTrace(u,mt),n.emit("wsClientError",u,s,e)}else ln(s,o,c,d)}});import{spawn as Yl}from"node:child_process";import{existsSync as Xl,openSync as Ql}from"node:fs";import{mkdir as Zl}from"node:fs/promises";import{dirname as eg}from"node:path";import{fileURLToPath as tg}from"node:url";function Oi(n=q()){return Xl(n.libEntry)?n.libEntry:tg(new URL("../index.ts",import.meta.url))}async function pn(n={}){let e=n.paths??q(),s=n.entryOverride??Oi(e);await Zl(eg(e.logFile),{recursive:!0});let o=Ql(e.logFile,"a"),d=s.endsWith(".ts")?["--import","tsx/esm",s,"--daemon"]:[s,"--daemon"],u=Yl(process.execPath,d,{detached:!0,stdio:["ignore",o,o],env:{...process.env,COZE_BRIDGE_DAEMON:"1"}});if(u.unref(),typeof u.pid!="number")throw new Error("failed to spawn daemon (no pid)");return ng.info("daemon spawned",{pid:u.pid,entry:s}),{pid:u.pid,entry:s}}var ng,vr=Ae(()=>{"use strict";U();ie();ng=D("spawn-daemon")});import{readFile as _c}from"node:fs/promises";async function Sr(n){try{let[e,s]=await Promise.all([_c(n.portFile,"utf8"),_c(n.tokenFile,"utf8")]),o=Number.parseInt(e.trim(),10),c=s.trim();return!Number.isFinite(o)||o<=0||!c?null:{port:o,token:c}}catch(e){if(e.code==="ENOENT")return null;throw e}}function rg(n){if(!n)return null;try{return JSON.parse(n)}catch{return n}}function ig(n){return n instanceof Error?n.message:String(n)}var Le,Er=Ae(()=>{"use strict";ie();Le=class{paths;constructor(e){this.paths=e??q()}async probe(e=1e3){let s=await Sr(this.paths);if(!s)return{kind:"not-running"};try{let o=await this.fetch(s,{method:"GET",path:"/status",timeoutMs:e});return o.status===200?{kind:"connected",...s}:{kind:"stale",reason:`unexpected status ${o.status}`}}catch(o){return{kind:"stale",reason:ig(o)}}}async request(e){let s=await Sr(this.paths);if(!s)throw new Error("coze-bridge daemon not running (no port/token files)");return this.fetch(s,e)}async fetch(e,s){let o=s.body!==void 0,c={Authorization:`Bearer ${e.token}`};o&&(c["content-type"]="application/json");let d=new AbortController,u=setTimeout(()=>d.abort(),s.timeoutMs??5e3);try{let l=await fetch(`http://127.0.0.1:${e.port}${s.path}`,{method:s.method,headers:c,body:o?JSON.stringify(s.body):void 0,signal:d.signal}),p=await l.text();return{status:l.status,body:rg(p)}}finally{clearTimeout(u)}}}});var Cc={};Kr(Cc,{DEFAULT_PROBE_TIMEOUT_MS:()=>Ac,DEFAULT_WAIT_PID_EXIT_MS:()=>Ic,runUpgradeHelper:()=>vg});import{copyFile as mg,rename as zi,unlink as Fi}from"node:fs/promises";async function vg(n){let e=n.paths??q(),s=n.spawnDaemon??pn,o=n.probeDaemon??Ig,c=n.sleep??Ag,d=n.waitPidExitMs??Ic,u=n.probeTimeoutMs??Ac,l=n.killPid??((P,j)=>process.kill(P,j)),{targetVersion:p,oldPid:m}=n;He.info("upgrade-helper start",{targetVersion:p,oldPid:m}),await Sg(m,d,c,l);let _=e.libEntry,y=`${_}.bak`,I=`${_}.next`;try{await mg(_,y)}catch(P){return He.error("backup failed, abort",{err:String(P)}),1}try{await zi(I,_)}catch(P){return He.error("rename .next \u2192 live failed, abort + rollback",{err:String(P)}),await zi(y,_).catch(()=>{}),1}let L,T=!1;try{await s({paths:e}),T=await Eg(()=>o(e),u,c),T||(L="new daemon failed to come up within probeTimeout")}catch(P){L=`spawn new daemon failed: ${String(P)}`,He.warn(L)}return T?(await Sc(e,p,{ok:!0,setLibVersion:!0}),await Fi(y).catch(()=>{}),await Fi(I).catch(()=>{}),He.info("upgrade succeeded",{targetVersion:p}),0):(He.warn("upgrade failed, rolling back",{lastError:L}),await zi(y,_).catch(P=>He.error("rollback rename failed",{err:String(P)})),await s({paths:e}).catch(P=>He.error("spawn old daemon after rollback failed",{err:String(P)})),await Sc(e,p,{ok:!1,lastError:L}),await Fi(I).catch(()=>{}),1)}async function Sc(n,e,s){let o=await at(n.configFile)??{};s.setLibVersion&&(o.libVersion=e),o.upgradeAttempts=o.upgradeAttempts??{},o.upgradeAttempts[e]={count:(o.upgradeAttempts[e]?.count??0)+1,lastAt:Date.now(),ok:s.ok,...s.lastError?{lastError:s.lastError}:{}},await ze(o,n.configFile)}async function Sg(n,e,s,o){let c=Date.now()+e;for(;Date.now()<c;){if(!Ec(n,o))return;await s(yg)}He.warn("oldPid did not exit in time, sending SIGTERM",{pid:n});try{o(n,"SIGTERM")}catch{}if(await s(wg),!!Ec(n,o)){He.warn("SIGTERM ineffective, sending SIGKILL",{pid:n});try{o(n,"SIGKILL")}catch{}await s(_g)}}function Ec(n,e){try{return e(n,0),!0}catch{return!1}}async function Eg(n,e,s){let o=Date.now()+e;for(;Date.now()<o;){if(await n().catch(()=>!1))return!0;await s(bg)}return!1}async function Ig(n){return(await new Le(n).probe(1e3).catch(()=>null))?.kind==="connected"}function Ag(n){return new Promise(e=>setTimeout(e,n))}var He,Ic,Ac,wg,_g,yg,bg,Pc=Ae(()=>{"use strict";Lt();vr();Er();U();ie();He=D("upgrade-helper"),Ic=3e4,Ac=3e4,wg=5e3,_g=2e3,yg=200,bg=500});import{spawn as Cg}from"node:child_process";import{mkdir as Pg,unlink as kg,writeFile as Tg}from"node:fs/promises";import{dirname as Dg,join as Rg}from"node:path";function Cr(n){return n.replace(/&/g,"&").replace(/</g,"<").replace(/>/g,">").replace(/"/g,""")}function kc(n,e){return new Promise((s,o)=>{let c=Cg(n,e,{stdio:["ignore","pipe","pipe"]}),d="";c.stderr?.on("data",u=>{d+=u.toString("utf8")}),c.on("error",o),c.on("close",u=>{u===0?s():o(new Error(`${n} ${e.join(" ")} exited ${u}: ${d.trim()}`))})})}var Ar,Ui,qi,Tc=Ae(()=>{"use strict";U();Ar=D("supervisor.launchd"),Ui="ai.coze.bridge",qi={platform:"darwin",renderConfig(n){return`<?xml version="1.0" encoding="UTF-8"?>
|
|
18
18
|
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
|
|
19
19
|
<plist version="1.0">
|
|
20
20
|
<dict>
|
|
21
21
|
<key>Label</key>
|
|
22
|
-
<string>${
|
|
22
|
+
<string>${Ui}</string>
|
|
23
23
|
<key>ProgramArguments</key>
|
|
24
24
|
<array>
|
|
25
|
-
<string>${
|
|
26
|
-
<string>${
|
|
25
|
+
<string>${Cr(n.nodeBin)}</string>
|
|
26
|
+
<string>${Cr(n.entry)}</string>
|
|
27
27
|
<string>--daemon</string>
|
|
28
28
|
</array>
|
|
29
29
|
<key>RunAtLoad</key>
|
|
@@ -33,12 +33,12 @@ var ac=Object.create;var Or=Object.defineProperty;var cc=Object.getOwnPropertyDe
|
|
|
33
33
|
<key>ThrottleInterval</key>
|
|
34
34
|
<integer>10</integer>
|
|
35
35
|
<key>StandardOutPath</key>
|
|
36
|
-
<string>${
|
|
36
|
+
<string>${Cr(n.logFile)}</string>
|
|
37
37
|
<key>StandardErrorPath</key>
|
|
38
|
-
<string>${
|
|
38
|
+
<string>${Cr(n.logFile)}</string>
|
|
39
39
|
</dict>
|
|
40
40
|
</plist>
|
|
41
|
-
`},configPath(n){return
|
|
41
|
+
`},configPath(n){return Rg(n.homeDir,"Library","LaunchAgents",`${Ui}.plist`)},async install(n){let e=this.configPath(n);await Pg(Dg(e),{recursive:!0}),await Tg(e,this.renderConfig(n),"utf8"),Ar.info("plist written",{plistPath:e}),await kc("launchctl",["load","-w",e]),Ar.info("launchd job loaded",{label:Ui})},async uninstall(n){let e=this.configPath(n);await kc("launchctl",["unload","-w",e]).catch(s=>Ar.warn("launchctl unload failed (ignored)",{err:String(s)})),await kg(e).catch(s=>{if(s.code!=="ENOENT")throw s}),Ar.info("launchd job removed",{plistPath:e})}}});import{spawn as Lg}from"node:child_process";import{mkdir as Og,unlink as Ng,writeFile as Mg}from"node:fs/promises";import{dirname as Bg,join as zg}from"node:path";function Tr(n,e){return new Promise((s,o)=>{let c=Lg(n,e,{stdio:["ignore","pipe","pipe"]}),d="";c.stderr?.on("data",u=>{d+=u.toString("utf8")}),c.on("error",o),c.on("close",u=>{u===0?s():o(new Error(`${n} ${e.join(" ")} exited ${u}: ${d.trim()}`))})})}var Pr,kr,Hi,Dc=Ae(()=>{"use strict";U();Pr=D("supervisor.systemd"),kr="coze-bridge.service",Hi={platform:"linux",renderConfig(n){return`[Unit]
|
|
42
42
|
Description=Coze Bridge daemon
|
|
43
43
|
After=network.target
|
|
44
44
|
|
|
@@ -52,7 +52,7 @@ StandardError=append:${n.logFile}
|
|
|
52
52
|
|
|
53
53
|
[Install]
|
|
54
54
|
WantedBy=default.target
|
|
55
|
-
`},configPath(n){return
|
|
55
|
+
`},configPath(n){return zg(n.homeDir,".config","systemd","user",kr)},async install(n){let e=this.configPath(n);await Og(Bg(e),{recursive:!0}),await Mg(e,this.renderConfig(n),"utf8"),Pr.info("systemd unit written",{unitPath:e}),await Tr("systemctl",["--user","daemon-reload"]),await Tr("systemctl",["--user","enable","--now",kr]),Pr.info("systemd unit enabled",{unitName:kr})},async uninstall(n){let e=this.configPath(n);await Tr("systemctl",["--user","disable","--now",kr]).catch(s=>Pr.warn("systemctl disable failed (ignored)",{err:String(s)})),await Ng(e).catch(s=>{if(s.code!=="ENOENT")throw s}),await Tr("systemctl",["--user","daemon-reload"]).catch(()=>{}),Pr.info("systemd unit removed",{unitPath:e})}}});import{spawn as Fg}from"node:child_process";import{join as Ug}from"node:path";function Rc(n,e){return new Promise((s,o)=>{let c=Fg(n,e,{stdio:["ignore","pipe","pipe"],shell:!1}),d="";c.stderr?.on("data",u=>{d+=u.toString("utf8")}),c.on("error",o),c.on("close",u=>{u===0?s():o(new Error(`${n} ${e.join(" ")} exited ${u}: ${d.trim()}`))})})}var ji,Dr,Ki,Lc=Ae(()=>{"use strict";U();ji=D("supervisor.taskscheduler"),Dr="CozeBridge",Ki={platform:"win32",renderConfig(n){return`<?xml version="1.0" encoding="UTF-16"?>
|
|
56
56
|
<Task version="1.2" xmlns="http://schemas.microsoft.com/windows/2004/02/mit/task">
|
|
57
57
|
<RegistrationInfo>
|
|
58
58
|
<Description>Coze Bridge daemon</Description>
|
|
@@ -76,7 +76,9 @@ WantedBy=default.target
|
|
|
76
76
|
</Exec>
|
|
77
77
|
</Actions>
|
|
78
78
|
</Task>
|
|
79
|
-
`},configPath(n){return
|
|
79
|
+
`},configPath(n){return Ug(n.homeDir,".coze","bridge","task.xml")},async install(n){let e=`"${n.nodeBin}" "${n.entry}" --daemon`;await Rc("schtasks",["/Create","/SC","ONLOGON","/TN",Dr,"/TR",e,"/RU",n.userName,"/F"]),ji.info("task scheduler entry created",{task:Dr})},async uninstall(n){await Rc("schtasks",["/Delete","/TN",Dr,"/F"]).catch(e=>ji.warn("schtasks /Delete failed (ignored)",{err:String(e)})),ji.info("task scheduler entry removed",{task:Dr})}}});var Gi={};Kr(Gi,{buildContext:()=>Kg,getSupervisor:()=>jg,launchdSupervisor:()=>qi,systemdSupervisor:()=>Hi,taskSchedulerSupervisor:()=>Ki});import{homedir as qg,userInfo as Hg}from"node:os";function jg(n=process.platform){switch(n){case"darwin":return qi;case"linux":return Hi;case"win32":return Ki;default:throw new Error(`unsupported platform for OS supervisor: ${n}`)}}function Kg(){let n=q();return{nodeBin:process.execPath,entry:Oi(n),logFile:n.logFile,homeDir:qg(),userName:Hg().username}}var Wi=Ae(()=>{"use strict";ie();vr();Tc();Dc();Lc()});U();U();import{execFile as F0}from"node:child_process";import{promisify as U0}from"node:util";var ms=U0(F0),Wt=D("agents.acp-installer"),q0={"claude-code":{npmPackage:"@agentclientprotocol/claude-agent-acp",binary:"claude-agent-acp"},codex:{npmPackage:"@zed-industries/codex-acp",binary:"codex-acp"}},H0=5e4,j0=5e3,K0=5*6e4,G0=new Set(["ETIMEDOUT","ECONNRESET","ECONNREFUSED","ENETUNREACH","EAI_AGAIN","ERR_SOCKET_TIMEOUT","ENOTFOUND"]),W0=/\b(5\d\d|408|429)\b\s+(Bad Gateway|Service Unavailable|Gateway Timeout|Internal Server Error|Too Many Requests|Request Timeout)/i,J0=/fetch failed|request timed out|socket hang up|network timeout/i;function $0(n){let e=n?.code;if(e&&G0.has(e))return!0;let s=n instanceof Error?`${n.message}
|
|
80
|
+
${n.stack??""}`:String(n);return W0.test(s)||J0.test(s)}var vn=new Map,bn=new Map,Gr=new Map;async function ps(n){let e=process.platform==="win32"?"where":"which";try{let{stdout:s}=await ms(e,[n],{timeout:j0});return s.split(`
|
|
81
|
+
`)[0]?.trim()||void 0}catch{return}}async function V0(n,e){Wt.info("npm install -g start",{npmPackage:n}),await ms("npm",["install","-g",`${n}@latest`],{timeout:H0,maxBuffer:10*1024*1024,...e?{signal:e}:{}}),Wt.info("npm install -g done",{npmPackage:n})}async function Sn(n,e){let s=q0[n];if(!s)return;let o=vn.get(n);if(o)return o;let c=bn.get(n);if(c&&Date.now()-c<K0)return;let d=Gr.get(n);if(d)return d;let u=(async()=>{let l=await ps(s.binary);if(l)return vn.set(n,l),Wt.info("acp wrapper found on PATH",{binary:s.binary,path:l}),l;try{await V0(s.npmPackage,e)}catch(m){let _=$0(m);Wt.warn("acp wrapper install failed (will fallback to npx)",{npmPackage:s.npmPackage,transient:_,err:String(m)}),_||bn.set(n,Date.now());return}let p=await ps(s.binary);if(!p){Wt.warn("acp wrapper installed but binary not found on PATH",{binary:s.binary}),bn.set(n,Date.now());return}return vn.set(n,p),bn.delete(n),p})().finally(()=>{Gr.delete(n)});return Gr.set(n,u),u}function En(n){return vn.get(n)}var ws=D("acp-installer-warmup"),Y0=["claude-code","codex"];async function _s(n={}){let e=n.ensure??Sn,o=(await Promise.allSettled(Y0.map(async c=>{let d=await e(c);ws.info("acp wrapper warmup ok",{framework:c,installed:!!d,path:d??""})}))).filter(c=>c.status==="rejected");o.length>0&&ws.warn("acp wrapper warmup partial failure (acp-installer negative cache 5min \u5185\u4E0D\u91CD\u8BD5)",{failedCount:o.length,reasons:o.map(c=>String(c.reason))})}nt();U();import{readdir as xx}from"node:fs/promises";import{mkdir as As,writeFile as Cs}from"node:fs/promises";import{join as Jr}from"node:path";var ox={"claude-code":"CLAUDE.md",codex:"AGENTS.md",openclaw:"SOUL.md"};async function It(n,e,s,o){await As(n,{recursive:!0});let c=ox[e],d=Jr(n,c),u=ax(e,s,o);return await Cs(d,u,"utf8"),d}async function Ps(n){let e=Jr(n,".claude");await As(e,{recursive:!0});let s=Jr(e,"settings.local.json"),o=JSON.stringify({permissions:{defaultMode:"bypassPermissions"}},null,2);return await Cs(s,o,"utf8"),s}function ax(n,e,s){let o=`# Coze Agent: ${e}
|
|
80
82
|
|
|
81
83
|
> framework: \`${n}\`
|
|
82
84
|
|
|
@@ -86,7 +88,7 @@ WantedBy=default.target
|
|
|
86
88
|
`;return`${o}---
|
|
87
89
|
|
|
88
90
|
${c}
|
|
89
|
-
${
|
|
91
|
+
${cx}`}var cx=`## \u53D1\u9001\u6587\u4EF6 / \u56FE\u7247\u7ED9\u7528\u6237
|
|
90
92
|
|
|
91
93
|
\u6BCF\u6761\u7528\u6237\u6D88\u606F\u5F00\u5934\u4F1A\u6709\u4E91\u7AEF\u6CE8\u5165\u7684 \`<coze-context>\` \u5757, \u5F62\u5982:
|
|
92
94
|
|
|
@@ -110,26 +112,26 @@ ${kc}`}var kc=`## \u53D1\u9001\u6587\u4EF6 / \u56FE\u7247\u7ED9\u7528\u6237
|
|
|
110
112
|
- \`sessionId\` \u5FC5\u987B\u7528\u4E91\u7AEF \`<coze-context>\` \u7ED9\u7684 ID, **\u4E0D\u8981**\u81EA\u5DF1\u7F16\u6216\u8005\u7528\u5176\u5B83\u6765\u6E90
|
|
111
113
|
|
|
112
114
|
\u26A0\uFE0F \u751F\u6210\u6587\u4EF6\u540E\u8BF7**\u7B49\u6587\u4EF6\u5B8C\u6574\u5199\u76D8**\u518D send (\u7528 \`&&\` \u4E32\u884C, \u4E0D\u8981 \`&\` \u540E\u53F0)\u3002
|
|
113
|
-
`;var
|
|
114
|
-
`)}}function Fr(n){return`coze-session-${n.replace(/[^A-Za-z0-9_-]+/g,"-")}`}function Ps(n,e){if(!n.modelToken)return null;let s=n.model||Le,o=zr(e),c={baseUrl:`${Mr}/v1`,api:"openai-completions",apiKey:n.modelToken,models:[{id:s,name:s,reasoning:!1,input:["text"],cost:{input:0,output:0,cacheRead:0,cacheWrite:0},contextWindow:128e3,maxTokens:8192,api:"openai-completions"}]};return Object.keys(o).length>0&&(c.headers=o),c}function ks(n,e){if(!n.modelToken)return[];let s=zr(e),o=[];for(let[c,x]of Object.entries(s))o.push("-c",`model_providers.coze.http_headers.${c}="${x}"`);return o}var ue=R("agent-handlers"),Ds=5*1024*1024,Fc=1,Uc=6,qc=new Set(["node_modules",".git",".coze","dist","build",".next"]),In=class{constructor(e){this.opts=e}opts;async listSkills(e){je(e._meta,"_agent/listSkills");let s=bt(e._meta),o=await this.loadAgentCfg(s),c=o?.workspace??Ke(s).workspace,x=o?.skills??[],u=[];for(let l of x){let m=Oe(c,l.relPath,"SKILL.md");await Bc(m).then(v=>v.isFile()).catch(()=>!1)&&u.push(Wc(l))}return{skills:u}}async addSkills(e){je(e._meta,"_agent/addSkills");let s=bt(e._meta),o=await this.requireAgentCfg(s),c=e.skills??[],x=[...o.skills??[]],u=new Map(x.map((m,w)=>[m.skillId,w])),l=[];for(let m of c){let w=await qr({agentId:s,workspace:o.workspace,framework:o.framework,skill:m});Hr(x,u,w),l.push(m)}return await _n(s,x),await this.reloadAgentSessions(s,"skills-added"),{installedSkills:l}}async removeSkills(e){je(e._meta,"_agent/removeSkills");let s=bt(e._meta),o=await this.requireAgentCfg(s),c=new Set(e.skillIds??[]),x=o.skills??[],u=[];for(let l of x){if(!c.has(l.skillId)){u.push(l);continue}let m=Oe(o.workspace,l.relPath);await Nc(m,{recursive:!0,force:!0}),ue.info("skill removed",{agentId:s,skillId:l.skillId,relPath:l.relPath})}return await _n(s,u),await this.reloadAgentSessions(s,"skills-removed"),{ok:!0}}reloadAgentSessionsPublic(e,s){return this.reloadAgentSessions(e,s)}async reloadAgentSessions(e,s){let o=this.opts.agents.get(e);if(o&&o.framework!=="codex"){for(let[c,x]of o.sessions)if(!(!x.downstream||!x.acpSessionId)){x.loadingSession=!0;try{await x.downstream.sessionLoad({sessionId:x.acpSessionId,cwd:o.workspace}),ue.info("session reloaded",{reason:s,agentId:e,framework:o.framework,cloudId:c,acpId:x.acpSessionId})}catch(u){ue.warn("session reload failed",{reason:s,agentId:e,framework:o.framework,cloudId:c,acpId:x.acpSessionId,err:String(u)})}finally{x.loadingSession=!1}}}}async updateAgent(e){if(!e.cozeIdentity?.trim())return ue.info("_agent/update: empty cozeIdentity, noop",{agentId:e.agentId}),{ok:!0};let s=e.agentId,o=await pe(s);if(!o)throw new S("AGENT_NOT_FOUND",`agent not found: ${s}`);return o.cozeIdentity===e.cozeIdentity?(ue.info("_agent/update: cozeIdentity unchanged, noop",{agentId:s}),{ok:!0}):(o.cozeIdentity=e.cozeIdentity,await Pe(o),await vt(o.workspace,o.framework,s,e.cozeIdentity),ue.info("_agent/update: cozeIdentity rewritten",{agentId:s,framework:o.framework}),await this.reloadAgentSessions(s,"identity-changed"),{ok:!0})}async disconnectAgent(e){let s=e.agentId;if(!s)throw new S("IPC_BAD_REQUEST","_agent/disconnect: missing agentId");let o=await pe(s);return o?(o.disconnectedAt=Date.now(),o.disconnectReason=e.reason??"",await Pe(o),ue.info("agent disconnected",{agentId:s,reason:e.reason??"",force:e.force??!1}),this.opts.disposeAndMarkDisconnected&&await this.opts.disposeAndMarkDisconnected(s,e.reason??"disconnect"),{ok:!0}):(ue.warn("_agent/disconnect: agent not found, ignoring",{agentId:s}),{ok:!0})}async switchModel(e){if(je(e._meta,"_agent/switchModel"),!e.agentId)throw new S("IPC_BAD_REQUEST","_agent/switchModel: missing agentId");let s=e.model?.trim()?e.model:Le,o=await pe(e.agentId);if(!o)throw new S("AGENT_NOT_FOUND",`agent not found: ${e.agentId}`);o.model=s,await Pe(o),ue.info("_agent/switchModel: model persisted",{agentId:e.agentId,model:s,reason:e.reason??""});let c=this.opts.agents.get(e.agentId);if(!c)return ue.info("_agent/switchModel: agent not running, config persisted only",{agentId:e.agentId}),{ok:!0};c.model=s;let x=[];for(let[u,l]of c.allSessionQueues())x.push(l.enqueue(async()=>{let m=c.sessions.get(u);m?.downstream&&(await m.downstream.stop(`switchModel: ${s}`).catch(()=>{}),m.downstream=void 0)}));return await Promise.all(x),ue.info("_agent/switchModel: all session runtimes killed, next prompt will respawn",{agentId:e.agentId,model:s,cloudSessions:x.length}),{ok:!0}}async resetAgent(e){if(je(e._meta,Re.RESET),!e.agentId)throw new S("IPC_BAD_REQUEST",`${Re.RESET}: missing agentId`);return await this.runDetailSync(e.agentId,Re.RESET,e.reason),{ok:!0}}async repairAgent(e){if(je(e._meta,Re.REPAIR),!e.agentId)throw new S("IPC_BAD_REQUEST",`${Re.REPAIR}: missing agentId`);let s=await this.loadAgentCfg(e.agentId);if(s&&s.framework!=="openclaw")throw new S("IPC_BAD_REQUEST",`${Re.REPAIR} only allowed for openclaw, got ${s.framework}`);if(s&&this.opts.openclawRepair)try{await this.opts.openclawRepair(e.agentId,s.workspace)}catch(o){ue.warn("openclaw repair (delete+add) failed (ignored)",{agentId:e.agentId,reason:e.reason,err:String(o)})}return await this.runDetailSync(e.agentId,Re.REPAIR,e.reason),{ok:!0}}async runDetailSync(e,s,o){if(!this.opts.detailSyncer){ue.warn("detailSyncer not wired, skipping sync",{method:s,agentId:e});return}try{await this.opts.detailSyncer(e)}catch(c){ue.warn("detail sync failed (ignored)",{method:s,agentId:e,reason:o,err:String(c)})}}async getFileTree(e){je(e._meta,"_agent/getFileTree");let s=e._meta,o=bt(s),c=await this.resolveWorkspace(o),x=e.filePath??"",u=this.safeJoin(c,x),l=await Ur(u).catch(()=>null);if(!l)throw new S("IPC_BAD_REQUEST",`path not found: ${x}`);if(l.isSymbolicLink())throw new S("IPC_BAD_REQUEST",`symlink not allowed: ${x}`);let m=Qc(e.depth);return l.isDirectory()?{tree:await Bs(c,u,x,m)}:{tree:[{name:Zc(x),path:Ms(x||"."),isDir:!1,size:l.size,modifiedAt:Math.floor(l.mtimeMs)}]}}async getFileContent(e){je(e._meta,"_agent/getFileContent");let s=bt(e._meta),o=await this.resolveWorkspace(s);if(!e.filePath)throw new S("IPC_BAD_REQUEST","filePath required");let c=this.safeJoin(o,e.filePath),x=await Ur(c).catch(()=>null);if(!x||!x.isFile())throw new S("IPC_BAD_REQUEST",`not a file: ${e.filePath}`);if(x.isSymbolicLink())throw new S("IPC_BAD_REQUEST",`symlink not allowed: ${e.filePath}`);if(x.size>Ds)throw new S("IPC_BAD_REQUEST",`file too large: ${x.size} bytes (max ${Ds})`);let u=await Ls(c);return u.includes(0)?{content:u.toString("base64"),encoding:"base64",size:x.size}:{content:u.toString("utf8"),encoding:"utf-8",size:x.size}}async resolveWorkspace(e){let s=this.opts.agents.get(e);return s?s.workspace:(await pe(e).catch(()=>null))?.workspace??Ke(e).workspace}safeJoin(e,s){let o=zc(e,s||"."),c=Os(e,o);if(c.startsWith("..")||c===".."||c.startsWith(`..${Ns}`))throw new S("IPC_BAD_REQUEST",`path escapes workspace: ${s}`);return o}loadAgentCfg(e){return pe(e)}async requireAgentCfg(e){let s=await this.loadAgentCfg(e);if(!s)throw new S("AGENT_NOT_FOUND",`no config for agent: ${e}`);return s}};function Hc(n){let e=n.trim().replace(/[\x00-\x1f<>:"|?*/\\]+/g,"-").replace(/^[\s.-]+|[\s.-]+$/g,"").slice(0,64);if(!e||e==="."||e==="..")throw new S("IPC_BAD_REQUEST",`invalid skill name: ${n}`);if(/^(con|prn|aux|nul|com[1-9]|lpt[1-9])$/i.test(e))throw new S("IPC_BAD_REQUEST",`reserved windows filename: ${n}`);return e}function Kc(n){return n==="claude-code"?Oe(".claude","skills"):Oe(".agents","skills")}var jc=3e4,Gc=50*1024*1024,An=3e4;async function qr(n){let{agentId:e,workspace:s,framework:o,skill:c}=n;if(!c.skillName)throw new S("IPC_BAD_REQUEST","skill missing skillName");let x=typeof c.content=="string"&&c.content.length>0,u=typeof c.downloadUrl=="string"&&c.downloadUrl.length>0;if(!x&&!u)throw new S("IPC_BAD_REQUEST",`skill ${c.skillId} missing both content and downloadUrl`);let l=Hc(c.skillName),m=Kc(o),w=Oe(m,l),v=Oe(s,w);if(await Lc(v,{recursive:!0}),x){let E=Buffer.from(c.content,"utf8");Gt(E.length),await Ts(Oe(v,"SKILL.md"),E,"utf8")}else{let E=await Jc(c.downloadUrl);$c(E)?await Yc(E,v):await Ts(Oe(v,"SKILL.md"),E.toString("utf8"),"utf8")}let y={skillId:c.skillId,skillName:c.skillName,relPath:w,installedAt:Date.now(),...c.description?{description:c.description}:{},...c.icon?{icon:c.icon}:{},...c.version?{version:c.version}:{},...c.downloadUrl?{downloadUrl:c.downloadUrl}:{},...c.config?{config:c.config}:{},...c.builtin?{builtin:c.builtin}:{}};return ue.info("skill installed",{agentId:e,skillId:c.skillId,skillName:c.skillName,relPath:w,source:x?"content":"downloadUrl"}),y}function Hr(n,e,s){let o=e.get(s.skillId);if(o!==void 0){n[o]=s;return}e.set(s.skillId,n.length),n.push(s)}function Wc(n){return{skillId:n.skillId,skillName:n.skillName,...n.description?{description:n.description}:{},...n.icon?{icon:n.icon}:{},...n.version?{version:n.version}:{},...n.config?{config:n.config}:{},...n.builtin?{builtin:n.builtin}:{}}}async function Jc(n){if(!n)throw new S("IPC_BAD_REQUEST","skill missing downloadUrl");if(n.startsWith("data:")){let e=Math.floor(n.length*3/4);Gt(e);let s=Vc(n);return Gt(s.length),s}if(n.startsWith("file:")){let e=new URL(n).pathname,s=await Ls(e);return Gt(s.length),s}if(bn(n)){let e=new AbortController,s=setTimeout(()=>e.abort(),jc);try{let o=await fetch(n,{signal:e.signal});if(!o.ok)throw new S("IPC_BAD_REQUEST",`fetch skill failed HTTP ${o.status} ${n}`);let c=await o.arrayBuffer();return Gt(c.byteLength),Buffer.from(c)}finally{clearTimeout(s)}}throw new S("IPC_BAD_REQUEST",`unsupported downloadUrl scheme (\u8981 https/data/file): ${n.slice(0,80)}`)}function Gt(n){if(n>Gc)throw new S("IPC_BAD_REQUEST",`skill too large: ${n} bytes`)}function Vc(n){let e=/^data:([^,;]*)(;base64)?,(.*)$/s.exec(n);if(!e)throw new S("IPC_BAD_REQUEST","bad data URL");let s=!!e[2],o=e[3]??"";return s?Buffer.from(o,"base64"):Buffer.from(decodeURIComponent(o),"utf8")}function $c(n){return n.length>=2&&n[0]===31&&n[1]===139}async function Yc(n,e){await Xc(n),await new Promise((s,o)=>{let c=Rs("tar",["-xzf","-","-C",e,"--strip-components=1","--no-same-owner"],{stdio:["pipe","pipe","pipe"]}),x="";c.stderr?.on("data",l=>{x+=String(l)});let u=setTimeout(()=>{c.kill("SIGKILL"),o(new S("IPC_BAD_REQUEST",`tar extract timeout (${An}ms)`))},An);c.on("error",l=>{clearTimeout(u),o(new S("IPC_BAD_REQUEST",`tar spawn failed: ${l.message}`,{cause:l}))}),c.on("exit",l=>{clearTimeout(u),l===0?s():o(new S("IPC_BAD_REQUEST",`tar exit ${l}${x?`: ${x.trim().slice(0,200)}`:""}`))}),c.stdin?.end(n)})}async function Xc(n){let e=await new Promise((s,o)=>{let c=Rs("tar",["-tzvf","-"],{stdio:["pipe","pipe","pipe"]}),x="",u="";c.stdout?.on("data",m=>{x+=String(m)}),c.stderr?.on("data",m=>{u+=String(m)});let l=setTimeout(()=>{c.kill("SIGKILL"),o(new S("IPC_BAD_REQUEST",`tar list timeout (${An}ms)`))},An);c.on("error",m=>{clearTimeout(l),o(new S("IPC_BAD_REQUEST",`tar list spawn failed: ${m.message}`))}),c.on("exit",m=>{clearTimeout(l),m===0?s(x):o(new S("IPC_BAD_REQUEST",`tar list exit ${m}${u?`: ${u.trim().slice(0,200)}`:""}`))}),c.stdin?.end(n)});for(let s of e.split(`
|
|
115
|
-
`)){let o=s.trim();if(!o)continue;let c=o.charCodeAt(0);if(c!==45&&c!==100)throw new S("IPC_BAD_REQUEST",`tar entry kind '${o[0]}' not allowed (symlink/hardlink/special): ${o.slice(0,100)}`);let u=(o.match(/\s(\S.*)$/)?.[1]??"").split(" -> ")[0]?.trim()??"";if(!u)continue;if(u.startsWith("/"))throw new S("IPC_BAD_REQUEST",`tar entry absolute path: ${u}`);if(u.split(/[/\\]/).some(
|
|
116
|
-
`
|
|
117
|
-
`}var Nn=class{buffer="";onError;constructor(e={}){this.onError=e.onError}push(e){this.buffer+=typeof e=="string"?e:e.toString("utf8");let s=this.buffer.split(`
|
|
118
|
-
`);this.buffer=s.pop()??"";let o=[];for(let c of s){let x=c.replace(/\r$/,"").trim();if(x)try{o.push(JSON.parse(x))}catch(u){this.onError?.({line:x,error:u})}}return o}flush(){if(!this.buffer)return[];let e=this.buffer.replace(/\r$/,"").trim();if(this.buffer="",!e)return[];try{return[JSON.parse(e)]}catch(s){return this.onError?.({line:e,error:s}),[]}}};var Gs={"session/prompt":"session.prompt","session/cancel":"session.cancel","session/new":"session.new","session/load":"session.load","_agent/create":"agent.create","_agent/health":"agent.health","_agent/pair":"agent.pair","_agent/listSkills":"agent.listSkills","_agent/addSkills":"agent.addSkills","_agent/removeSkills":"agent.removeSkills","_agent/getFileTree":"agent.getFileTree","_agent/getFileContent":"agent.getFileContent","_agent/detail":"agent.detail","_agent/update":"agent.update","_agent/disconnect":"agent.disconnect","_agent/switchModel":"agent.switchModel","_agent/genModelToken":"agent.genModelToken","_agent/reset":"agent.reset","_agent/repair":"agent.repair","session/request_permission":"session.requestPermission",initialize:"initialize"},ng=Object.fromEntries(Object.entries(Gs).map(([n,e])=>[e,n])),ux={"session.prompt":["agentId","triggerMsgId","sessionId"],"session.cancel":["agentId","triggerMsgId","sessionId"],"session.new":["agentId"],"session.load":["agentId"],"agent.create":["agentId"],"agent.health":[],"agent.listSkills":["agentId"],"agent.addSkills":["agentId"],"agent.removeSkills":["agentId"],"agent.getFileTree":["agentId"],"agent.getFileContent":["agentId"],"agent.detail":["agentId"],"agent.update":["agentId"],"agent.disconnect":["agentId"],"agent.switchModel":["agentId"],"agent.genModelToken":["agentId","sessionId"],"agent.reset":["agentId"],"agent.repair":["agentId"],"session.requestPermission":["agentId","sessionId"],"agent.pair":[],initialize:[]},Ct=class{seq=0;next(e,s){this.seq+=1;let o=Gs[e]??fx(e),c=ux[o]??[],x=[o,String(this.seq)];if(c.length>0){let u=c.map(m=>js(s?.[m]??"")),l=lx(u).join(":");l&&x.push(l)}else s&&Object.values(s).some(u=>u)&&x.push(Object.values(s).filter(Boolean).map(u=>js(String(u))).join(":"));return x.join("_")}reset(){this.seq=0}};function fx(n){return n.replace(/[\s/]+/g,".").replace(/_+/g,"-")}function js(n){return n.replace(/[:_\s]+/g,"-")}function lx(n){let e=n.length;for(;e>0&&!n[e-1];)e-=1;return n.slice(0,e)}U();var px=3e4,mx=50,_x=20,Ws=500;function yx(n){try{let e=JSON.stringify(n);return e===void 0||e.length<=Ws?n:`${e.slice(0,Ws)}...<truncated, total ${e.length} chars>`}catch{return"<unserializable>"}}function Js(n,e){if(!(typeof n!="number"||n<=0))try{if(process.platform==="win32"){let s=["/PID",String(n),"/T"];e==="SIGKILL"&&s.push("/F"),gx("taskkill",s,{stdio:"ignore",windowsHide:!0})}else process.kill(-n,e)}catch{}}var et=class{constructor(e){this.opts=e;this.log=R(`downstream.${this.constructor.name}`),this.decoder=new Nn({onError:s=>this.log.warn("decode line failed",{line:s.line})})}opts;child;decoder;pending=new Map;idAllocator=new Ct;updateHandlers=[];agentRequestHandlers=[];exitHandlers=[];log;stopped=!1;stderrRing=[];sanitizeEnv(e){return e}async start(){if(this.child)throw new S("BRIDGE_INTERNAL","Downstream already started");let e=process.platform!=="win32",s=hx(this.opts.command,this.opts.args,{cwd:this.opts.cwd,env:{...this.sanitizeEnv(process.env),...this.opts.env},stdio:["pipe","pipe","pipe"],detached:e});this.child=s,s.stdout?.setEncoding("utf8"),s.stdout?.on("data",o=>{for(let c of this.decoder.push(o))this.dispatch(c)}),s.stderr?.setEncoding("utf8"),s.stderr?.on("data",o=>{let c=o.trimEnd();this.stderrRing.push(c),this.stderrRing.length>mx&&this.stderrRing.shift(),this.log.debug("stderr",{text:c})}),s.on("exit",(o,c)=>{this.stopped=!0,(o!==0||c!==null)&&this.stderrRing.length>0&&this.log.warn("downstream exited abnormally, recent stderr",{code:o,signal:c,recentStderr:this.stderrRing.slice(-_x)}),this.failAllPending(new S("AGENT_PROTOCOL_ERROR",`agent exited (${o}/${c})`));for(let u of this.exitHandlers)u(o,c)}),s.on("error",o=>{this.log.error("child error",{err:String(o)}),this.failAllPending(new S("AGENT_SPAWN_FAILED",String(o),{cause:o}))}),this.log.info("downstream started",{command:this.opts.command,pid:s.pid,cwd:this.opts.cwd})}async stop(e){if(!this.child||this.stopped)return;this.stopped=!0,this.log.info("downstream stopping",{reason:e});let s=this.child,o=new Promise(x=>s.once("exit",()=>x()));Js(s.pid,"SIGTERM");let c=setTimeout(()=>{s.killed||Js(s.pid,"SIGKILL")},5e3);try{await o}finally{clearTimeout(c)}}pid(){return this.child?.pid}isAlive(){return!!this.child&&!this.stopped}initialize(e){return this.call("initialize",e)}sessionNew(e){return this.call("session/new",{mcpServers:[],...e})}sessionLoad(e){return this.call("session/load",{mcpServers:[],...e})}sessionPrompt(e){return this.call("session/prompt",e,0)}async sessionCancel(e){!this.child||this.stopped||this.writeFrame(Yt("session/cancel",e))}onUpdate(e){this.updateHandlers.push(e)}onAgentRequest(e){this.agentRequestHandlers.push(e)}respondAgentRequest(e,s){if(!(!this.child||this.stopped))try{this.writeFrame(Et(e,s))}catch(o){this.log.warn("respondAgentRequest write failed",{id:e,err:String(o)})}}respondAgentRequestError(e,s){if(!(!this.child||this.stopped))try{this.writeFrame(ct(e,s))}catch(o){this.log.warn("respondAgentRequestError write failed",{id:e,err:String(o)})}}onExit(e){this.exitHandlers.push(e)}call(e,s,o=px){if(!this.child||this.stopped)return Promise.reject(new S("AGENT_PROTOCOL_ERROR","downstream not started"));let c=this.idAllocator.next(e),x=$t(c,e,s),u=o>0&&Number.isFinite(o);return new Promise((l,m)=>{let w=u?setTimeout(()=>{this.pending.delete(c),m(new S("AGENT_TIMEOUT",`${e} timed out after ${o}ms`))},o):null;this.pending.set(c,{resolve:l,reject:m,timer:w,method:e});try{this.writeFrame(x)}catch(v){w&&clearTimeout(w),this.pending.delete(c),m(v)}})}writeFrame(e){if(!this.child?.stdin||this.child.stdin.destroyed)throw new S("AGENT_PROTOCOL_ERROR","downstream stdin not writable");this.child.stdin.write(Ks(e))}dispatch(e){if(On(e)){let s=e.id!==null?this.pending.get(e.id):void 0;if(!s){this.log.warn("orphan response",{id:e.id});return}this.pending.delete(e.id),s.timer&&clearTimeout(s.timer),e.error?(this.log.warn("downstream returned error frame",{id:e.id,method:s.method,code:e.error.code,message:e.error.message,data:e.error.data}),s.reject(Hs(e.error))):(this.log.info("downstream returned result",{id:e.id,method:s.method,result:yx(e.result)}),s.resolve(e.result));return}if(qs(e)){if(e.method==="session/update")for(let s of this.updateHandlers)Promise.resolve(s(e.params)).catch(o=>this.log.warn("update handler failed",{err:String(o)}));else this.log.debug("unknown notification",{method:e.method});return}if(Us(e)){let s=e;this.handleAgentRequest(s).catch(o=>this.log.error("agent request handler failed",{method:s.method,err:String(o)}))}}async handleAgentRequest(e){if(this.agentRequestHandlers.length===0){this.writeFrame(ct(e.id,{code:-32601,message:`method not handled by Bridge: ${e.method}`}));return}for(let s of this.agentRequestHandlers)try{await s(e)}catch(o){this.log.error("agentRequestHandler threw",{method:e.method,err:String(o)});try{this.writeFrame(ct(e.id,Xt(o)))}catch{}}}failAllPending(e){for(let s of this.pending.values())s.timer&&clearTimeout(s.timer),s.reject(e);this.pending.clear()}};var vx="@agentclientprotocol/claude-agent-acp@latest";function bx(n){let e={};for(let[s,o]of Object.entries(n))o!==void 0&&(s.startsWith("CLAUDE")||s==="AI_AGENT"||s==="BAGGAGE"||(e[s]=o));return e}var Bn=class extends et{framework="claude-code";constructor(e){let s=Rn("claude-code"),[o,c]=s?[s,[]]:["npx",["-y",vx]],x=e.command??o,u=e.args??c,l={command:x,args:u,cwd:e.cwd,...e.env?{env:e.env}:{}};super(l)}sanitizeEnv(e){return bx(e)}};import{mkdtempSync as Sx,rmSync as Ex}from"node:fs";import{tmpdir as Cx}from"node:os";import{join as Ix}from"node:path";var Ax="@zed-industries/codex-acp@latest",Mn=class extends et{framework="codex";authMethodId;codexHomeDir;constructor(e){let s=Rn("codex"),[o,c]=s?[s,[]]:["npx",["-y",Ax]],x=e.command??o,u=e.args??c,l=e.extraArgs?[...u,...e.extraArgs]:u,m=e.isolateCodexHome?Sx(Ix(Cx(),"coze-bridge-codex-home-")):void 0,w=m?{...e.env??{},CODEX_HOME:m}:e.env,v={command:x,args:l,cwd:e.cwd,...w?{env:w}:{}};super(v),this.authMethodId=e.authMethodId,this.codexHomeDir=m}async initialize(e){let s=await super.initialize(e);return this.authMethodId&&await this.call("authenticate",{methodId:this.authMethodId}),s}async stop(e){if(await super.stop(e),this.codexHomeDir)try{Ex(this.codexHomeDir,{recursive:!0,force:!0})}catch{}}};var It=class extends et{framework="openclaw";agentId;sessionName;slashModelOnStart;constructor(e){let s=e.sessionName??"default",o=["acp","--session",`agent:${e.agentId}:${s}`];e.gatewayToken&&o.push("--token",e.gatewayToken);let c={command:e.command,args:o,cwd:e.cwd,...e.env?{env:e.env}:{}};super(c),this.agentId=e.agentId,this.sessionName=s,this.slashModelOnStart=e.slashModelOnStart}async afterSessionEstablished(e){this.slashModelOnStart&&(this.log.info("switching session to per-session provider via /model",{agentId:this.agentId,sessionName:this.sessionName,slash:this.slashModelOnStart}),await this.sessionPrompt({sessionId:e,prompt:[{type:"text",text:`/model ${this.slashModelOnStart}`}]}))}get acpSessionName(){return this.sessionName}};U();se();function jr(n){return n.replace(/[^A-Za-z0-9._-]+/g,"-")}var At=class{slots=[];running=!1;closed=!1;disposed=!1;enqueue(e){return this.disposed?Promise.reject(new Error("AsyncQueue disposed")):this.closed?Promise.reject(new Error("AsyncQueue closed")):new Promise((s,o)=>{this.slots.push({task:e,resolve:s,reject:o}),this.drain()})}close(){this.closed=!0}dispose(e=new Error("AsyncQueue disposed")){for(this.disposed=!0,this.closed=!0;this.slots.length>0;)this.slots.shift()?.reject(e)}get size(){return this.slots.length}get isRunning(){return this.running}async drain(){if(!this.running){this.running=!0;try{for(;this.slots.length>0&&!this.disposed;){let e=this.slots.shift();if(!e)break;try{let s=await e.task();e.resolve(s)}catch(s){e.reject(s)}}}finally{this.running=!1}}}};var zn=class{agentId;framework;workspace;deployType;accountId;sessions=new Map;sessionQueues=new Map;activeTriggers=new Map;status="ok";model;lastActiveAt=Date.now();constructor(e){this.agentId=e.agentId,this.framework=e.framework,this.workspace=e.workspace,this.model=e.model,this.deployType=e.deployType??"local",e.accountId&&(this.accountId=e.accountId)}getSessionQueue(e){let s=this.sessionQueues.get(e);return s||(s=new At,this.sessionQueues.set(e,s)),s}allSessionQueues(){return this.sessionQueues.entries()}async dispose(e){this.status="stopped";let s=new Error(`AgentSession disposed${e?`: ${e}`:""}`);for(let o of this.sessionQueues.values())o.dispose(s);this.sessionQueues.clear(),await this.killAllRuntimes(e??"dispose")}async killAllRuntimes(e){let s=[];for(let[,o]of this.sessions)Qt(o),o.downstream&&(s.push(o.downstream.stop(e).catch(()=>{})),o.downstream=void 0);await Promise.all(s),this.activeTriggers.clear()}};function Qt(n){n.idleTimer&&(clearTimeout(n.idleTimer),n.idleTimer=void 0)}import{spawn as Px}from"node:child_process";import{homedir as kx}from"node:os";import{join as Tx}from"node:path";hn();U();async function Ys(){let n=Tx(kx(),".openclaw/openclaw.json");return(await yt(n))?.gateway?.auth?.token??""}var Vs=R("openclaw.config"),Dx=[0,5e3,5e3],$s="models.providers.",Fn="agents.defaults.models",Un=class{command;env;retryDelaysMs;queue=new At;constructor(e){this.command=e.command,this.env=e.env??process.env,this.retryDelaysMs=e.retryDelaysMs??Dx}async withRetry(e,s){let o;for(let c=0;c<this.retryDelaysMs.length;c++){let x=this.retryDelaysMs[c]??0;x>0&&await new Promise(u=>setTimeout(u,x));try{return await s()}catch(u){o=u,Vs.warn("openclaw cli failed, will retry",{label:e,attempt:c+1,err:String(u)})}}throw new S("AGENT_SPAWN_FAILED",`openclaw cli ${e} failed after ${this.retryDelaysMs.length} attempts: ${o?.message??"unknown"}`)}runCli(e){return new Promise((s,o)=>{let c=Px(this.command,e,{stdio:["ignore","pipe","pipe"],env:this.env}),x="";c.stderr?.on("data",u=>{x+=u.toString("utf8")}),c.on("error",o),c.on("close",u=>{u===0?s():o(new Error(`exit ${u}: ${x.trim().slice(0,500)}`))})})}async runCliTolerant(e,s){try{await this.runCli(e)}catch(o){let c=String(o);if(s.some(x=>c.includes(x)))return;throw o}}async bestEffortUnset(e,s){try{await this.queue.enqueue(()=>this.withRetry(e,()=>this.runCli(["config","unset",s])))}catch(o){Vs.warn(`${e} failed (best-effort)`,{configPath:s,err:String(o)})}}ensureProvider(e,s){return this.queue.enqueue(()=>this.withRetry(`config set models.providers.${e}`,()=>this.runCli(["config","set",`${$s}${e}`,JSON.stringify(s),"--strict-json","--merge"])))}removeProvider(e){return this.bestEffortUnset(`config unset models.providers.${e}`,`${$s}${e}`)}addModelToAllowlist(e,s){let o={[e]:s?{alias:s}:{}};return this.queue.enqueue(()=>this.withRetry(`config set ${Fn}[${e}]`,()=>this.runCli(["config","set",Fn,JSON.stringify(o),"--strict-json","--merge"])))}removeModelFromAllowlist(e){return this.bestEffortUnset(`config unset ${Fn}[${e}]`,`${Fn}.${e}`)}ensureAgent(e,s,o){let c=["agents","add",e,"--workspace",s,"--non-interactive"];return o&&c.push("--model",o),this.queue.enqueue(()=>this.withRetry(`agents add ${e}`,()=>this.runCliTolerant(c,["already exists","already registered"])))}deleteAgent(e){return this.queue.enqueue(()=>this.withRetry(`agents delete ${e}`,()=>this.runCliTolerant(["agents","delete",e,"--force"],["not found","does not exist"])))}};var Ne=R("agent-manager"),Lx=(n,e,s,o,c,x,u,l)=>{switch(n){case"claude-code":{let m={...c?{...Es(c),...As(c,u)}:{},...l??{}};return new Bn({cwd:s,...Object.keys(m).length>0?{env:m}:{}})}case"codex":{let m=c?[...Cs(c),...ks(c,u)]:[],w={...c?Is(c):{},...l??{}},v=!!c;return new Mn({cwd:s,...m.length>0?{extraArgs:m}:{},...Object.keys(w).length>0?{env:w}:{},...v?{authMethodId:"openai-api-key",isolateCodexHome:!0}:{}})}case"openclaw":return new It({command:e,cwd:s,agentId:o,...x?{sessionName:jr(x)}:{}})}};function Xs(n){return n==="claude-code"||n==="codex"}var Ox={path:"",version:"cloud-deployed"},Nx={protocolVersion:1,clientCapabilities:{fs:{readTextFile:!0,writeTextFile:!0}}},Bx=6e4,qn=class{paths;config;registry;factory;createTimeoutMs;openclawConfigCache;ensuredProviders=new Set;constructor(e){this.paths=e.paths,this.config=e.config,this.registry=e.registry,this.factory=e.downstreamFactory??Lx,this.createTimeoutMs=e.createTimeoutMs??Bx}buildBinShimPathEnv(){let e=process.platform==="win32"?";":":";return{PATH:`${this.paths.binDir}${e}${process.env.PATH??""}`}}getOpenclawConfig(){if(!this.openclawConfigCache){let e=this.config.frameworksCache?.openclaw;if(!e?.path)throw new S("AGENT_SPAWN_FAILED","openclaw binary not detected on this machine");this.openclawConfigCache=new Un({command:e.path})}return this.openclawConfigCache}async createAgent(e){if(!e.agentId)throw new S("IPC_BAD_REQUEST","agentId required");if(!e.framework)throw new S("IPC_BAD_REQUEST","framework required");let s=Kt(e._meta)==="cloud";this.registry.reviveIfDisconnected?.(e.agentId);let o=this.registry.get(e.agentId);if(o){if(o.framework!==e.framework)throw new S("AGENT_BUSY",`agent ${e.agentId} exists with different framework (${o.framework})`);if(o.status==="error")Ne.warn("existing agent in error state, rebuilding",{agentId:e.agentId}),await o.dispose("rebuild after error").catch(P=>Ne.warn("dispose stale agent failed (ignored)",{err:String(P)})),this.registry.unregister(e.agentId);else return Ne.info("agent already exists, return current",{agentId:e.agentId}),{ok:!0,agentId:o.agentId,workspace:o.workspace,framework:o.framework}}if(!s&&!this.config.frameworksCache?.[e.framework])throw new S("AGENT_SPAWN_FAILED",`framework ${e.framework} not detected on this machine; rerun daemon to refresh frameworks_cache`);s&&Xs(e.framework)&&await Dn(e.framework);let x=Ke(e.agentId,this.paths),u=Kt(e._meta),l=e.framework==="openclaw"&&u==="local",m=l?this.config.frameworksCache?.openclaw?.defaultAgent?.workspace:void 0,w=e.workspace??m??x.workspace,v=new AbortController,y=setTimeout(()=>v.abort(new S("AGENT_TIMEOUT",`_agent/create timed out after ${this.createTimeoutMs}ms`)),this.createTimeoutMs),E,k=!1;try{let P=()=>{if(v.signal.aborted)throw v.signal.reason instanceof Error?v.signal.reason:new S("AGENT_TIMEOUT","_agent/create aborted")};await Gr(x.root,{recursive:!0}),await Gr(w,{recursive:!0}),await Gr(x.logs,{recursive:!0}),P(),l||await vt(w,e.framework,e.agentId,e.cozeIdentity),P();let T=await pe(e.agentId,this.paths).catch(()=>null),F=bs({model:e.model??T?.model}),re=hs(e._meta)??T?.accountId;if(E=new zn({agentId:e.agentId,framework:e.framework,workspace:w,model:F.model??Le,deployType:u,...re?{accountId:re}:{}}),E.status="ok",T?.sessions){for(let[oe,ae]of Object.entries(T.sessions))E.sessions.set(oe,{acpSessionId:ae.acpSessionId,modelToken:ae.modelToken,tokenGeneratedAt:ae.tokenGeneratedAt,lastActiveAt:Date.now(),loadingSession:!1,replySeq:0});let ee=Object.keys(T.sessions).length;ee>0&&Ne.info("restored persisted session records (no spawn)",{agentId:e.agentId,count:ee})}this.registry.register(E),k=!0;let J={agentId:e.agentId,framework:e.framework,workspace:w,cozeIdentity:e.cozeIdentity,createdAt:T?.createdAt??Date.now(),sessions:T?.sessions??{},model:F.model};u==="cloud"&&(J.deployType="cloud"),re&&(J.accountId=re),T?.skills&&(J.skills=T.skills),T?.agentName&&(J.agentName=T.agentName),T?.description&&(J.description=T.description),e.framework==="openclaw"&&u==="cloud"&&(this.config.frameworksCache?.openclaw?.path?await this.getOpenclawConfig().ensureAgent(e.agentId,w):Ne.warn("openclaw binary not on this machine, skip agents add (will fail at session/prompt)",{agentId:e.agentId}));let we=e.initialSkills??[];if(we.length>0){let ee=[...J.skills??[]],oe=new Map(ee.map((A,N)=>[A.skillId,N])),ae=0;for(let A of we)try{let N=await qr({agentId:e.agentId,workspace:w,framework:e.framework,skill:A});Hr(ee,oe,N),ae++}catch(N){Ne.warn("initialSkill install failed (skipping)",{agentId:e.agentId,skillId:A.skillId,skillName:A.skillName,err:String(N)})}ae>0&&(J.skills=ee,Ne.info("initialSkills installed",{agentId:e.agentId,installed:ae,requested:we.length}))}return await Pe(J,this.paths),Ne.info("agent created (no spawn, lazy on first prompt)",{agentId:e.agentId,framework:e.framework,deployType:u}),{ok:!0,agentId:e.agentId,workspace:w,framework:e.framework}}catch(P){throw Ne.error("agent create failed, rolling back",{agentId:e.agentId,err:String(P)}),k&&E&&(await E.dispose("rollback").catch(()=>{}),this.registry.unregister(e.agentId)),await Rx(x.root,{recursive:!0,force:!0}).catch(T=>Ne.warn("rm agent dir failed (ignored)",{err:String(T)})),P instanceof S?P:new S("AGENT_SPAWN_FAILED",String(P),{cause:P})}finally{clearTimeout(y)}}async spawnSessionDownstream(e,s,o,c){let u=this.config.frameworksCache?.[e.framework];if(!u)if(e.deployType==="cloud"&&Xs(e.framework))u=Ox;else throw new S("AGENT_SPAWN_FAILED",`framework ${e.framework} not detected on this machine`);let l=e.deployType==="cloud"?{model:e.model,modelToken:s}:void 0,m;e.framework==="openclaw"?m=await this.buildOpenclawDownstream({session:e,modelConfig:l,cloudSessionId:o,cozeEnv:c,command:u.path}):m=this.factory(e.framework,u.path,e.workspace,e.agentId,l,o,c,this.buildBinShimPathEnv());try{return await m.start(),await m.initialize(Nx),m}catch(w){throw await m.stop("spawnSessionDownstream failed").catch(()=>{}),w instanceof S?w:new S("AGENT_SPAWN_FAILED",w instanceof Error?w.message:String(w),{cause:w})}}async buildOpenclawDownstream(e){let{session:s,modelConfig:o,cloudSessionId:c,cozeEnv:x,command:u}=e,l=jr(c);if(s.deployType==="local"){let y=this.config.frameworksCache?.openclaw?.defaultAgent;if(!y?.id||!y.workspace)throw new S("AGENT_SPAWN_FAILED","openclaw default agent \u672A\u63A2\u6D4B\u5230; \u8BF7\u5148\u8DD1 `openclaw setup` \u6216 `openclaw agents add` \u521B\u5EFA\u9ED8\u8BA4 agent");return new It({command:u,cwd:y.workspace,agentId:y.id,sessionName:l})}let m=await Ys(),w=o?Ps(o,x):null,v;if(w){let y=Fr(c),k=w.models[0]?.id??Le,P=`${y}/${k}`;if(!this.ensuredProviders.has(P)){let T=this.getOpenclawConfig();await T.ensureProvider(y,w),await T.addModelToAllowlist(P),this.ensuredProviders.add(P)}v=P}return new It({command:u,cwd:s.workspace,agentId:s.agentId,sessionName:l,...m?{gatewayToken:m}:{},...v?{slashModelOnStart:v}:{}})}async openclawRepair(e,s){let o=this.getOpenclawConfig();await o.deleteAgent(e),await o.ensureAgent(e,s)}async cleanupOpenclawSessionProviders(e){if(e.framework!=="openclaw"||!this.openclawConfigCache)return;let s=this.openclawConfigCache;for(let o of e.sessions.keys()){let c=Fr(o),x=`${c}/${e.model}`;this.ensuredProviders.delete(x),await s.removeProvider(c),await s.removeModelFromAllowlist(x)}}};import{randomUUID as Jx}from"node:crypto";import{promises as Vx}from"node:fs";import{basename as $x}from"node:path";import{promises as zx}from"node:fs";import{basename as Fx}from"node:path";U();var Qs=R("file-upload"),Ux="/api/coze_claw/file/agent_upload",qx=6e4;async function Zs(n,e={}){let o=`${Sn(Cn(e.handshakeBase))}${Ux}`,c=e.timeoutMs??qx,x=await zx.readFile(n.path),u=new FormData;u.append("agent_id",n.agentId),u.append("session_id",n.sessionId),u.append("file_name",n.name),u.append("file_content",new Blob([x],{type:n.mimeType}),n.name);let l={Authorization:`Bearer ${n.patToken}`,Accept:"application/json","x-coze-version":"3.0",...St(e.ppeOverride),...n.accountId?{"x-coze-account":n.accountId}:{}},m=new AbortController,w=setTimeout(()=>m.abort(),c);Qs.info("file upload start",{url:o,agentId:n.agentId,sessionId:n.sessionId,name:n.name,bytes:n.sizeBytes,mime:n.mimeType});try{let v=await fetch(o,{method:"POST",headers:l,body:u,signal:m.signal}),y=v.headers.get("x-tt-logid")??"";if(!v.ok){let P=await v.text().catch(()=>"");throw new S("UPLOAD_FAILED",`upload HTTP ${v.status} logid=${y}: ${P.slice(0,200)}`)}let E=await v.json();if(E.code!==void 0&&E.code!==0)throw new S("UPLOAD_FAILED",`upload code=${E.code} msg=${E.msg??"-"} logid=${y}`);let k=E.data?.file?.file_url;if(!k)throw new S("UPLOAD_FAILED",`upload response missing data.file.file_url logid=${y}: ${JSON.stringify(E).slice(0,200)}`);return Qs.info("file upload ok",{uri:k,logid:y}),{uri:k}}catch(v){throw v instanceof S?v:v.name==="AbortError"?new S("UPLOAD_FAILED",`upload timeout (${c}ms) for ${Fx(n.path)}`):new S("UPLOAD_FAILED",String(v),{cause:v})}finally{clearTimeout(w)}}U();import{promises as Hx}from"node:fs";import{extname as Kx}from"node:path";var jx=[{mime:"image/png",prefix:[137,80,78,71]},{mime:"image/jpeg",prefix:[255,216,255]},{mime:"image/gif",prefix:[71,73,70,56]},{mime:"application/pdf",prefix:[37,80,68,70]}];function Gx(n){return n[0]===82&&n[1]===73&&n[2]===70&&n[3]===70&&n[8]===87&&n[9]===69&&n[10]===66&&n[11]===80}var Wx={".txt":"text/plain",".md":"text/markdown"};async function eo(n){let e=await Hx.open(n,"r");try{let s=Buffer.alloc(16);if(await e.read(s,0,16,0),Gx(s))return"image/webp";for(let o of jx)if(o.prefix.every((c,x)=>s[x]===c))return o.mime}finally{await e.close()}return Wx[Kx(n).toLowerCase()]??"application/octet-stream"}se();var Yx=R("agent-send"),to=50*1024*1024,Xx=new Set(["image/png","image/jpeg","image/webp","image/gif","application/pdf","text/plain","text/markdown"]);async function no(n,e){let s=e.core.get(n.agentId);if(!s)throw new S("AGENT_NOT_FOUND",`agent=${n.agentId}`);if(e.core.disconnectedAgents.has(n.agentId))throw new S("AGENT_DISCONNECTED",`agent=${n.agentId} was disconnected by cloud`);let o=s.sessions.get(n.sessionId);if(!o)throw new S("AGENT_NOT_FOUND",`session=${n.sessionId} not active in agent=${n.agentId}`);if(!await fs(n.path,s.workspace))throw new S("PATH_OUTSIDE_WORKSPACE",`path=${n.path} not under workspace=${s.workspace}`);let c=await Vx.stat(n.path).catch(()=>null);if(!c||!c.isFile())throw new S("IPC_BAD_REQUEST",`path is not a regular file: ${n.path}`);if(c.size>to)throw new S("FILE_TOO_LARGE",`${c.size} bytes > limit ${to}`);let x=await eo(n.path);if(!Xx.has(x))throw new S("UNSUPPORTED_MIME",`mime=${x} not in whitelist`);if(n.kind==="image"&&!x.startsWith("image/"))throw new S("UNSUPPORTED_MIME",`kind=image but mime=${x}`);if(!e.core.upstream.isConnected())throw new S("UPSTREAM_NOT_READY","cloud WS not connected");let u=n.name??$x(n.path),l=await Zs({patToken:e.patToken,agentId:n.agentId,sessionId:n.sessionId,path:n.path,mimeType:x,name:u,sizeBytes:c.size,...s.accountId?{accountId:s.accountId}:{}},{handshakeBase:e.handshakeBase,ppeOverride:e.ppeOverride}),m={sessionUpdate:"agent_file",messageId:Jx(),content:{type:n.kind==="image"?"image":"resource",uri:l.uri,mimeType:x,name:u,sizeBytes:c.size,...l.fileId!==void 0?{fileId:l.fileId}:{},...n.caption!==void 0?{caption:n.caption}:{}}};return await e.core.sendAgentFileUpdate(s,o,n.sessionId,m),Yx.info("agent file sent",{agentId:n.agentId,sessionId:n.sessionId,kind:n.kind,name:u,bytes:c.size,mime:x,uri:l.uri}),{ok:!0,uri:l.uri,bytes:c.size,mimeType:x,...l.fileId!==void 0?{fileId:l.fileId}:{}}}U();var ro=R("acp-installer-warmup"),Qx=["claude-code","codex"];async function io(n={}){let e=n.ensure??Dn,o=(await Promise.allSettled(Qx.map(async c=>{let x=await e(c);ro.info("acp wrapper warmup ok",{framework:c,installed:!!x,path:x??""})}))).filter(c=>c.status==="rejected");o.length>0&&ro.warn("acp wrapper warmup partial failure (acp-installer negative cache 5min \u5185\u4E0D\u91CD\u8BD5)",{failedCount:o.length,reasons:o.map(c=>String(c.reason))})}U();import{execFile as Zx}from"node:child_process";import{promisify as ed}from"node:util";var td=ed(Zx),nt=R("coze-cli-installer"),so="@coze/cli@0.1.3-alpha.89c42a",oo="https://bnpm.byted.org",nd="coze",rd=5e3,id=9e4,ao=1e4,Zt=null,Wr=!1;async function Jr(n,e={}){if(Wr)return;if(Zt)return Zt;let s=e.exec??td;return Zt=(async()=>{try{let o=await sd(nd,s);if(o){nt.info("coze-cli already on PATH, skip install + config + auth",{path:o}),Wr=!0;return}nt.info("coze-cli install start",{package:so,registry:oo});try{await s("npm",["i","-g",so,"--registry",oo],{timeout:id,maxBuffer:10*1024*1024}),nt.info("coze-cli install ok")}catch(c){nt.warn("coze-cli install failed (skip subsequent steps)",{err:String(c)});return}if(n.env)try{await s("coze",["config","set","xTTEnv",n.env],{timeout:ao}),nt.info("coze config set xTTEnv ok",{env:n.env})}catch(c){nt.warn("coze config set failed (continue to auth login)",{err:String(c)})}try{await s("coze",["auth","login","--token",n.patToken],{timeout:ao}),nt.info("coze auth login ok")}catch(c){nt.warn("coze auth login failed",{err:String(c)});return}Wr=!0}finally{Zt=null}})(),Zt}async function sd(n,e){let s=process.platform==="win32"?"where":"which";try{let{stdout:o}=await e(s,[n],{timeout:rd});return o.split(`
|
|
119
|
-
`)
|
|
120
|
-
`),
|
|
121
|
-
`)}return go.info("fs/read_text_file ok",{path:s,size:c.length}),{content:c}}async function wo(n,e){if(typeof n!="string"||n.length===0)throw new S("IPC_BAD_REQUEST","path must be a non-empty string");let[s,o]=await Promise.all([ho(lo(e)),ho(lo(n))]),c=yd(s,o);if(c.startsWith("..")||c===".."||c.startsWith(`..${vd}`))throw new S("IPC_BAD_REQUEST",`path escapes workspace: ${n}`);return o}async function ho(n){let e=[],s=n;for(;s!==Vr(s);)try{let o=await pd(s);return e.length?_d(o,...e.reverse()):o}catch{e.push(wd(s)),s=Vr(s)}return n}U();var _o=R("prompt-multimodal"),yo=10*1024*1024,bd=15e3;async function vo(n){return Promise.all(n.map(Sd))}async function Sd(n){if(n.type!=="image")return n;let e=n;if(e.data||!e.uri||!bn(e.uri))return n;try{let{buf:s,contentType:o}=await Cd(e.uri),c=e.mimeType||Ed(o)||"application/octet-stream";return _o.info("image uri fetched and inlined",{uri:e.uri,bytes:s.length,mimeType:c}),{type:"image",data:s.toString("base64"),mimeType:c}}catch(s){return _o.warn("image fetch failed, degrading to text block",{uri:e.uri,err:String(s)}),{type:"text",text:`[image load failed: ${e.uri}]`}}}function Ed(n){if(!n)return;let e=n.indexOf(";");return(e===-1?n:n.slice(0,e)).trim()||void 0}async function Cd(n){let e=new AbortController,s=setTimeout(()=>e.abort(),bd);try{let o=await fetch(n,{signal:e.signal});if(!o.ok)throw new Error(`HTTP ${o.status} ${o.statusText}`);let c=await o.arrayBuffer();if(c.byteLength>yo)throw new Error(`image too large: ${c.byteLength} bytes (max ${yo})`);return{buf:Buffer.from(c),contentType:o.headers.get("content-type")??void 0}}finally{clearTimeout(s)}}Ze();U();var H=R("core"),Ad=3e4,Pd=3e4,Kn=class{upstream;agents=new Map;disconnectedAgents=new Set;extensions;paths;sessionSpawner;sessionIdleTimeoutMs;upstreamIds=new Ct;pendingUpstream=new Map;pendingBridge=new Map;currentCozeEnv;constructor(e){this.upstream=e.upstream,this.extensions=e.extensions??{},this.paths=e.paths,this.sessionSpawner=e.sessionSpawner,this.sessionIdleTimeoutMs=fo(e.bridgeConfig)}registerExtension(e,s){this.extensions[e]=s}getCozeEnv(){return this.currentCozeEnv}async start(){this.upstream.onFrame(e=>this.handleFrame(e)),await this.upstream.start(),H.info("Core started",{extensions:Object.keys(this.extensions)})}async stop(e){H.info("Core stopping",{reason:e}),await Promise.all([...this.agents.values()].map(s=>s.dispose(e))),this.agents.clear(),await this.upstream.stop(e)}get(e){return this.agents.get(e)}register(e){this.agents.set(e.agentId,e),H.info("agent registered",{agentId:e.agentId,framework:e.framework});for(let s of this.registerHandlers)try{s(e.agentId)}catch(o){H.warn("onAgentRegister handler threw (ignored)",{agentId:e.agentId,err:String(o)})}}onAgentRegister(e){return this.registerHandlers.add(e),()=>this.registerHandlers.delete(e)}registerHandlers=new Set;unregister(e){this.agents.delete(e)}reviveIfDisconnected(e){this.disconnectedAgents.delete(e)&&H.info("agent revived from disconnect",{agentId:e})}attachRuntimeHooks(e,s,o){let c=o.downstream;c&&(c.onUpdate(x=>{o.loadingSession||this.forwardUpdate(e,x)}),c.onAgentRequest(x=>{this.handleAgentRequest(e,c,x)}),c.onExit((x,u)=>{H.info("session runtime exited",{agentId:e.agentId,cloudId:s,code:x,signal:u}),Qt(o),o.downstream=void 0,o.acpSessionId&&e.activeTriggers.delete(o.acpSessionId)}))}async handleFrame(e){if(On(e)){this.handleUpstreamResponse(e);return}if(!("method"in e)||typeof e.method!="string")return;let s="id"in e&&e.id!==void 0?e.id:null,o=e.params?._meta?.cozeEnv;o&&(this.currentCozeEnv=o);try{if(e.method.startsWith("_agent/")){let c=this.extensions[e.method];if(!c){s!==null?await this.sendError(s,j.METHOD_NOT_FOUND,`extension not registered: ${e.method}`):H.warn("drop notification: extension not registered",{method:e.method});return}let x=await c(e,this);s!==null&&await this.upstream.send(Et(s,x));return}if(e.method.startsWith("session/")){let c=await this.routeSessionMethod(e);s!==null&&await this.upstream.send(Et(s,c));return}if(e.method==="initialize"){s!==null&&await this.upstream.send(Et(s,{protocolVersion:1,agentCapabilities:{loadSession:!0}}));return}s!==null?await this.sendError(s,j.METHOD_NOT_FOUND,`method not implemented: ${e.method}`):H.warn("drop unknown notification",{method:e.method})}catch(c){H.error("handleFrame failed",{method:e.method,err:String(c)}),s!==null&&await this.upstream.send(ct(s,Xt(c)))}}async routeSessionMethod(e){if(!e.params||typeof e.params!="object")throw new S("IPC_BAD_REQUEST",`${e.method} requires params`);let s=e.params,o=s._meta?.cozeAgentId;if(!o)throw new S("IPC_BAD_REQUEST",`${e.method}: missing _meta.cozeAgentId`);let c=this.agents.get(o);if(!c)throw this.disconnectedAgents.has(o)?new S("AGENT_DISCONNECTED",`agent ${o} has been disconnected; cloud must _agent/create to revive`):new S("AGENT_NOT_FOUND",`agent not found: ${o}`);let x=typeof s.sessionId=="string"?s.sessionId:void 0;if(e.method==="session/cancel"||e.method==="session/new"||!x)return this.dispatchSessionCall(c,e.method,s);let u=Date.now(),l=!1;try{let m=await c.getSessionQueue(x).enqueue(()=>this.dispatchSessionCall(c,e.method,s));return l=!0,m}finally{H.info("session call done",{agentId:c.agentId,method:e.method,durationMs:Date.now()-u,ok:l})}}async dispatchSessionCall(e,s,o){e.lastActiveAt=Date.now();let{stripped:c}=gs(o);switch(s){case"session/new":{let x=kd();return H.info("session/new ack (lazy spawn)",{agentId:e.agentId,cloudId:x}),{sessionId:x}}case"session/load":{let x=c;return H.info("session/load ack (lazy spawn)",{agentId:e.agentId,cloudId:x.sessionId}),{}}case"session/prompt":{let x=c,u=x.sessionId;if(!u)throw new S("IPC_BAD_REQUEST","session/prompt: missing sessionId");let l=await this.ensureRuntime(e,u);if(l.replySeq=0,await this.ensureDownstream(e,u,l),!l.downstream||!l.acpSessionId)throw new S("BRIDGE_INTERNAL","session runtime not ready after ensureDownstream");let m=o._meta?.cozeTriggerMsgId;m?e.activeTriggers.set(l.acpSessionId,m):e.activeTriggers.delete(l.acpSessionId);let w=await vo(x.prompt);try{let v=await l.downstream.sessionPrompt({...x,sessionId:l.acpSessionId,prompt:w});return l.lastActiveAt=Date.now(),v}finally{e.activeTriggers.delete(l.acpSessionId),l.downstream?.isAlive()&&this.armIdleTimer(e,u,l)}}case"session/cancel":{let u=c.sessionId;if(!u)throw new S("IPC_BAD_REQUEST","session/cancel: missing sessionId");let l=e.sessions.get(u);return l?.downstream?.isAlive()&&l.acpSessionId&&await l.downstream.sessionCancel({sessionId:l.acpSessionId}),{ok:!0}}default:throw new S("IPC_BAD_REQUEST",`session method not supported: ${s}`)}}async ensureRuntime(e,s){let o=e.sessions.get(s);if(o)return o;let x={modelToken:e.deployType==="cloud"?await this.requestSessionToken(e.agentId,s):"",tokenGeneratedAt:Date.now(),lastActiveAt:Date.now(),loadingSession:!1,replySeq:0};return e.sessions.set(s,x),await this.persistSessionMapping(e),x}async requestSessionToken(e,s){let o={sessionId:s,_meta:{cozeAgentId:e}};try{let c=await this.sendRequest(Re.GEN_MODEL_TOKEN,o,Pd);if(!c?.modelToken)throw new S("MODEL_TOKEN_GEN_FAILED",`cloud returned empty modelToken (agentId=${e}, cloudSessionId=${s})`);return c.modelToken}catch(c){throw c instanceof S&&c.code==="MODEL_TOKEN_GEN_FAILED"?c:new S("MODEL_TOKEN_GEN_FAILED",c instanceof Error?c.message:String(c),{cause:c})}}async ensureDownstream(e,s,o){if(Qt(o),o.downstream?.isAlive())return;if(!this.sessionSpawner)throw new S("AGENT_SPAWN_FAILED","sessionSpawner not wired (cannot spawn per-session downstream)");let c=await this.sessionSpawner(e,o.modelToken,s,this.currentCozeEnv);if(o.downstream=c,this.attachRuntimeHooks(e,s,o),o.acpSessionId){o.loadingSession=!0;try{await c.sessionLoad({sessionId:o.acpSessionId,cwd:e.workspace}),H.info("session restored via session/load",{agentId:e.agentId,cloudId:s,acpId:o.acpSessionId})}catch(x){H.warn("session/load failed, fallback to session/new",{agentId:e.agentId,cloudId:s,acpId:o.acpSessionId,err:String(x)}),o.acpSessionId=void 0;let u=await c.sessionNew({cwd:e.workspace});o.acpSessionId=u.sessionId,await this.persistSessionMapping(e)}finally{o.loadingSession=!1}}else{let x=await c.sessionNew({cwd:e.workspace});o.acpSessionId=x.sessionId,await this.persistSessionMapping(e)}c.afterSessionEstablished&&o.acpSessionId&&await c.afterSessionEstablished(o.acpSessionId)}armIdleTimer(e,s,o){if(Qt(o),this.isRuntimeBusy(e,o)){H.debug("skip idle timer: runtime busy (in-flight turn / pending permission)",{agentId:e.agentId,cloudId:s});return}o.idleTimer=setTimeout(()=>{if(o.idleTimer=void 0,this.isRuntimeBusy(e,o)){H.info("idle reaper fired but runtime busy, re-arming",{agentId:e.agentId,cloudId:s}),this.armIdleTimer(e,s,o);return}H.info("session runtime idle timeout, killing downstream",{agentId:e.agentId,cloudId:s});let c=o.downstream;o.downstream=void 0,o.acpSessionId&&e.activeTriggers.delete(o.acpSessionId),c&&c.stop("idle timeout").catch(x=>H.warn("idle stop failed (ignored)",{agentId:e.agentId,cloudId:s,err:String(x)}))},this.sessionIdleTimeoutMs),o.idleTimer.unref?.()}isRuntimeBusy(e,s){if(s.acpSessionId&&e.activeTriggers.has(s.acpSessionId))return!0;let o=s.downstream;if(!o)return!1;for(let c of this.pendingUpstream.values())if(c.downstream===o)return!0;return!1}async sendAgentFileUpdate(e,s,o,c){let x={cozeAgentId:e.agentId,cozeReplySeqID:++s.replySeq};if(s.acpSessionId){let u=e.activeTriggers.get(s.acpSessionId);u&&(x.cozeTriggerMsgId=u)}await this.upstream.send(Yt("session/update",{sessionId:o,update:c,_meta:x}))}forwardUpdate(e,s){let o=s.sessionId,c=this.reverseSessionId(e,o);if(!c){H.debug("drop update for unknown session",{agentId:e.agentId,acpId:o});return}let x=e.sessions.get(c);if(!x){H.debug("drop update: runtime gone",{agentId:e.agentId,cloudId:c});return}if(Td(s)){H.debug("drop codex metadata-warn chunk",{agentId:e.agentId,acpId:o});return}let u={cozeAgentId:e.agentId,cozeReplySeqID:++x.replySeq},l=e.activeTriggers.get(o);l&&(u.cozeTriggerMsgId=l),this.upstream.send(Yt("session/update",{...s,sessionId:c,_meta:u})).catch(m=>H.warn("forward update failed",{agentId:e.agentId,err:String(m)}))}handleAgentRequest(e,s,o){if(o.method==="session/request_permission"){this.forwardPermissionRequest(e,s,o);return}if(o.method==="fs/write_text_file"||o.method==="fs/read_text_file"){this.handleFsRpcRequest(e,s,o);return}H.warn("unhandled agent request,returning method_not_found",{agentId:e.agentId,method:o.method}),s.respondAgentRequestError(o.id,{code:j.METHOD_NOT_FOUND,message:`method not handled by Bridge: ${o.method}`})}async handleFsRpcRequest(e,s,o){try{let c=e.workspace;if(o.method==="fs/write_text_file"){let x=o.params??{},u=await po(x,c);s.respondAgentRequest(o.id,u)}else{let x=o.params??{},u=await mo(x,c);s.respondAgentRequest(o.id,u)}}catch(c){H.warn("fs rpc handler failed",{agentId:e.agentId,method:o.method,err:String(c)}),s.respondAgentRequestError(o.id,Xt(c))}}forwardPermissionRequest(e,s,o){let c=this.upstreamIds.next("session/request_permission"),x=o.params??{},l=x.sessionId,m=l?e.activeTriggers.get(l):void 0,w={cozeAgentId:e.agentId};m&&(w.cozeTriggerMsgId=m);let v=l?this.reverseSessionId(e,l):void 0,y={...x,...v?{sessionId:v}:{},_meta:w};this.pendingUpstream.set(c,{agentRequestId:o.id,agentId:e.agentId,downstream:s,method:o.method}),H.info("forward permission_request \u2192 upstream",{agentId:e.agentId,upstreamId:c,acpSessionId:l,cloudSessionId:v,toolCallId:x.toolCall?.toolCallId,options:x.options?.map(E=>({optionId:E.optionId,kind:E.kind,name:E.name}))}),this.upstream.send($t(c,"session/request_permission",y)).catch(E=>{this.pendingUpstream.delete(c),H.error("forward permission request failed",{agentId:e.agentId,err:String(E)}),s.respondAgentRequestError(o.id,{code:j.INTERNAL_ERROR,message:`upstream send failed: ${String(E)}`})})}handleUpstreamResponse(e){if(e.id===null)return;let s=this.pendingUpstream.get(e.id);if(s){this.pendingUpstream.delete(e.id),e.error?(H.info("upstream \u2192 permission response (error)",{agentId:s.agentId,upstreamId:e.id,method:s.method,error:e.error}),s.downstream.respondAgentRequestError(s.agentRequestId,e.error)):(H.info("upstream \u2192 permission response (result)",{agentId:s.agentId,upstreamId:e.id,method:s.method,result:e.result}),s.downstream.respondAgentRequest(s.agentRequestId,e.result));return}let o=this.pendingBridge.get(e.id);if(o){this.pendingBridge.delete(e.id),clearTimeout(o.timer),e.error?o.reject(new Ln(e.error)):o.resolve(e.result);return}H.debug("orphan upstream response (no pending)",{id:e.id})}sendRequest(e,s,o=Ad){let c=this.upstreamIds.next(e);return new Promise((x,u)=>{let l=setTimeout(()=>{this.pendingBridge.delete(c),u(new S("AGENT_TIMEOUT",`${e} timed out after ${o}ms`))},o);this.pendingBridge.set(c,{method:e,resolve:x,reject:u,timer:l}),this.upstream.send($t(c,e,s)).catch(m=>{let w=this.pendingBridge.get(c);w&&(clearTimeout(w.timer),this.pendingBridge.delete(c)),u(m)})})}async persistSessionMapping(e){if(this.paths)try{let s=new Map;for(let[o,c]of e.sessions){let x={modelToken:c.modelToken,tokenGeneratedAt:c.tokenGeneratedAt};c.acpSessionId&&(x.acpSessionId=c.acpSessionId),s.set(o,x)}await Nr(e.agentId,s,this.paths)}catch(s){H.warn("persist session mapping failed",{agentId:e.agentId,err:String(s)})}}reverseSessionId(e,s){for(let[o,c]of e.sessions.entries())if(c.acpSessionId===s)return o}sendError(e,s,o){return this.upstream.send(ct(e,{code:s,message:o}))}};function kd(){return Id(16).toString("hex")}function Td(n){let e=n.update;if(e?.sessionUpdate!=="agent_message_chunk")return!1;let s=e.content;if(!s||typeof s!="object")return!1;let o=s;return o.type!=="text"||typeof o.text!="string"?!1:o.text.startsWith("Model metadata for `")}U();se();import{randomBytes as Dd}from"node:crypto";import{chmod as Rd,mkdir as Ld,writeFile as bo}from"node:fs/promises";import{createServer as Od}from"node:http";import{dirname as Nd}from"node:path";var Bd=1e6,$r=R("ipc"),jn=class{server=null;port=0;token="";routes;paths;constructor(e){this.routes=new Map(e.routes.map(s=>[`${s.method} ${s.path}`,s])),this.paths=e.paths??q()}async start(){this.token=Dd(32).toString("hex");let e=Od((o,c)=>{this.dispatch(o,c)});this.server=e,await new Promise((o,c)=>{e.once("error",c),e.listen(0,"127.0.0.1",()=>o())});let s=e.address();if(!s||typeof s!="object")throw new Error("failed to obtain IPC port");return this.port=s.port,await this.persistAuthFiles(),$r.info("IPC listening",{port:this.port}),{port:this.port,token:this.token}}async stop(){let e=this.server;e&&(await new Promise((s,o)=>{e.close(c=>c?o(c):s())}),this.server=null)}async persistAuthFiles(){await Ld(Nd(this.paths.portFile),{recursive:!0}),await bo(this.paths.portFile,String(this.port),"utf8"),await bo(this.paths.tokenFile,this.token,{encoding:"utf8",mode:384});try{await Rd(this.paths.tokenFile,384)}catch(e){$r.warn("chmod token file failed (non-POSIX?)",{err:String(e)})}}async dispatch(e,s){if(e.headers.authorization!==`Bearer ${this.token}`){en(s,401,{error:"unauthorized"});return}let c=`${e.method} ${(e.url??"").split("?")[0]}`,x=this.routes.get(c);if(!x){en(s,404,{error:"not found"});return}let u=null;if(e.method==="POST")try{u=await Md(e)}catch(l){en(s,400,{error:"invalid json",detail:String(l)});return}try{let l=await x.handler(u,e);en(s,200,l??{ok:!0})}catch(l){$r.error("IPC handler failed",{key:c,err:String(l)}),en(s,500,{error:l instanceof Error?l.message:String(l)})}}};function en(n,e,s){n.statusCode=e,n.setHeader("content-type","application/json"),n.end(JSON.stringify(s))}async function Md(n){let e=[],s=0;for await(let c of n){let x=c;if(s+=x.length,s>Bd)throw new Error("body too large");e.push(x)}let o=Buffer.concat(e).toString("utf8");return o?JSON.parse(o):null}var ja=He(Lo(),1);var wf=He(Pa(),1),_f=He(or(),1),yf=He(Rt(),1),vf=He(ci(),1),bf=He(ui(),1),Sf=He(mi(),1),Ma=He(dr(),1),Ef=He(Ba(),1);var za=Ma.default;U();var xe=R("upstream.frontier"),Ua="application/json",qa="none",dn=class{constructor(e){this.opts=e}opts;fws=null;handler=null;connectHandler=null;opened=!1;openCount=0;async start(){if(this.fws){xe.warn("start called on already-started FrontierUpstream; noop");return}let e={Authorization:`Bearer ${this.opts.privatecode}`,Origin:ws,...St(this.opts.ppeOverride)};class s extends za{constructor(l){super(l,ms,{headers:e})}send(l,...m){if(xs("debug"))try{let w;typeof l=="string"?w=Buffer.from(l,"utf8"):l instanceof Buffer?w=l:l instanceof ArrayBuffer?w=new Uint8Array(l):ArrayBuffer.isView(l)?w=new Uint8Array(l.buffer,l.byteOffset,l.byteLength):w=new Uint8Array(0);let v=Buffer.from(w.slice(0,128)).toString("hex");xe.debug("WS raw frame out",{bytes:w.byteLength,headHex:v})}catch(w){xe.warn("WS raw frame dump failed",{err:String(w)})}super.send(l,...m)}}let o=ys(this.opts.urlOverride),c={url:o,ws:s,fpID:ps,aID:En,accessKey:this.opts.handshake.accessKey,deviceID:this.opts.handshake.deviceId,payloadType:{type:Ua,force:!0},payloadEncoding:{encoding:qa,force:!0},enableTransformTextPayload:!0,enableQoS:!1,enableAutoAck:!1,automaticOpen:!1,debug:this.opts.debug??!1},x=new ja.FWS(c);x.onopen=()=>{this.opened=!0,this.openCount+=1;let u=this.openCount===1;xe.info("frontier opened",{url:o,remoteDeviceId:this.opts.handshake.deviceId,initial:u,openCount:this.openCount}),this.connectHandler&&Promise.resolve(this.connectHandler({initial:u})).catch(l=>xe.warn("onConnect handler threw (ignored)",{err:String(l)}))},x.onclose=u=>{this.opened=!1,xe.info("frontier closed",{code:u.code,reason:u.reason,willReconnect:u.willReconnect})},x.onerror=u=>{xe.warn("frontier error",{code:u.code,msg:u.message})},x.onmessage=u=>this.handleMessage(u),this.fws=x,await x.connect()}async stop(e){let s=this.fws;if(s){this.fws=null,this.opened=!1;try{s.close(1e3,e??"bridge shutdown")}catch(o){xe.warn("frontier close threw (ignored)",{err:String(o)})}}}async send(e){let s=this.fws;if(!s)throw new S("UPSTREAM_DISCONNECTED","frontier upstream not started");let o=JSON.stringify(e),c=e;Ha(c)||xe.info("frontier frame out",{method:c.method,jsonrpcId:c.id,size:o.length});try{await s.send(o,{service:33555712,method:1,payloadType:Ua,payloadEncoding:qa})}catch(u){throw xe.warn("frontier frame send failed",{method:c.method,jsonrpcId:c.id,err:String(u)}),new S("UPSTREAM_DISCONNECTED",`frontier send failed: ${String(u)}`,{cause:u})}}onFrame(e){this.handler=e}onConnect(e){this.connectHandler=e}isConnected(){return this.opened&&this.fws?.readyState===1}handleMessage(e){let s=e.message?.service;if(s!==33555712){xe.debug("drop non-adapter frontier frame",{service:s});return}let o=Pf(e);if(!o){xe.debug("frontier message without text payload, drop",{payloadType:e.message?.payloadType});return}if(!this.handler){xe.debug("frame received but no onFrame handler",{size:o.length});return}let c;try{c=JSON.parse(o)}catch(u){xe.warn("frontier message JSON parse failed",{err:String(u),head:o.slice(0,80)});return}let x=c;Ha(x)||xe.info("frontier frame in",{logid:Af(e.message?.LogID),logidNew:e.message?.LogIDNew,msgId:e.message?.msgID,jsonrpcId:x.id,method:x.method,body:If(o)}),Promise.resolve(this.handler(c)).catch(u=>xe.warn("frontier frame handler threw",{err:String(u)}))}};function Ha(n){return n.method==="_agent/health"?!0:typeof n.id=="string"&&n.id.startsWith("agent.health_")}var Ka=2e3;function If(n){return n.length<=Ka?n:`${n.slice(0,Ka)}...<truncated, total ${n.length} chars>`}function Af(n){return n?n.high===0?String(n.low>>>0):`${n.high.toString(16)}${(n.low>>>0).toString(16).padStart(8,"0")}`:""}function Pf(n){let e=n.message;if(e?.textPayload)return e.textPayload;let s=e?.payload;if(!s)return null;try{return Buffer.from(s).toString("utf8")}catch{return null}}U();var _i=R("upstream.switchable"),fr=class{inner;handler=null;connectHandler=null;constructor(e){this.inner=e}async swap(e,s){if(this.inner===e)return;_i.info("swap upstream",{reason:s});let o=this.inner;this.inner=e,this.handler&&e.onFrame(this.handler),this.connectHandler&&e.onConnect&&e.onConnect(this.connectHandler);try{await e.start()}catch(c){throw _i.error("swap target start failed, reverting",{err:String(c)}),this.inner=o,c}await o.stop(s??"swapped").catch(c=>_i.warn("previous upstream stop threw (ignored)",{err:String(c)}))}current(){return this.inner}start(){return this.inner.start()}stop(e){return this.inner.stop(e)}send(e){return this.inner.send(e)}onFrame(e){this.handler=e,this.inner.onFrame(e)}onConnect(e){this.connectHandler=e,this.inner.onConnect?.(e)}isConnected(){return this.inner.isConnected()}};U();var yi=R("upstream"),zt=class{handler=null;async start(){yi.info("NoopUpstream started (M1 skeleton; real Frontier wired in M4)")}async stop(e){yi.info("NoopUpstream stopped",{reason:e})}async send(e){yi.debug("NoopUpstream.send (dropped)",{method:"method"in e?e.method:void 0})}onFrame(e){this.handler=e}isConnected(){return!1}async injectFrame(e){this.handler&&await this.handler(e)}};U();U();se();import{promises as vi}from"node:fs";import{dirname as kf}from"node:path";var Tf=R("pat-token-store");async function Ga(n=q()){try{let s=(await vi.readFile(n.patTokenFile,"utf8")).trim();return s.length>0?s:null}catch(e){return e?.code!=="ENOENT"&&Tf.warn("read pat-token failed (treating as missing)",{err:String(e)}),null}}async function un(n,e=q()){if(!n)throw new Error("writePatToken: empty patToken");await vi.mkdir(kf(e.patTokenFile),{recursive:!0}),await vi.writeFile(e.patTokenFile,n,{encoding:"utf8",mode:384})}se();se();import{promises as lr}from"node:fs";import{join as Df}from"node:path";function Rf(n){return`#!/bin/sh
|
|
115
|
+
`;var ve=D("agent-detail-sync"),dx=6e4,ux=5*6e4,Tn=class{constructor(e){this.opts=e}opts;retryQueue=new Map;async syncAll(e){let s=this.opts.paths.agentsRoot,o;try{o=await xx(s)}catch(c){ve.info("agents dir not found, skip detail sync",{root:s,err:String(c)});return}ve.info("starting detail sync",{reason:e,count:o.length}),await Promise.allSettled(o.map(async c=>{let d=await me(c,this.opts.paths).catch(()=>null);if(d){if(d.disconnectedAt){ve.debug("detail sync: skip disconnected agent",{agentId:c});return}try{await this.syncOne(c,d)}catch(u){ve.warn("detail sync failed for agent, skipping",{agentId:c,err:String(u)})}}})),ve.info("detail sync done",{reason:e})}async retryPending(){if(this.retryQueue.size===0)return;let e=Date.now(),s=[];for(let[o,c]of this.retryQueue)e>=c.dueAt&&s.push(o);if(s.length!==0){ve.info("retrying pending detail syncs",{count:s.length});for(let o of s)try{await this.syncOne(o)}catch(c){ve.debug("detail sync retry still failing, will try again",{agentId:o,err:String(c)})}}}async syncOne(e,s){let o=s??await me(e,this.opts.paths);if(!o){ve.info("detail sync: agent config missing, skip",{agentId:e});return}let c;try{c=await this.opts.sendDetail({_meta:{cozeAgentId:e}}),this.retryQueue.delete(e)}catch(l){ve.warn("detail RPC failed, using local data",{agentId:e,err:String(l)});let p=this.retryQueue.get(e),m=p?Math.min(p.currentDelay*2,ux):dx;this.retryQueue.set(e,{dueAt:Date.now()+m,currentDelay:m});return}if(c.agentId&&c.agentId!==e){ve.warn("detail response agentId mismatch, ignoring",{agentId:e,responseAgentId:c.agentId});return}let d=!1,u=!1;if(c.agentName&&c.agentName!==o.agentName&&(o.agentName=c.agentName,d=!0),c.description!==void 0&&c.description!==o.description&&(o.description=c.description,d=!0),c.cozeIdentity&&c.cozeIdentity!==o.cozeIdentity&&(o.cozeIdentity=c.cozeIdentity,d=!0,u=!0),c.deployType&&ve.info("detail.deployType",{agentId:e,deployType:c.deployType}),!d){ve.debug("detail sync: no diff",{agentId:e});return}await Ce(o,this.opts.paths),ve.info("detail sync: config updated",{agentId:e,identityChanged:u,agentName:o.agentName}),u&&(await It(o.workspace,o.framework,e,o.cozeIdentity),this.opts.handlers.reloadAgentSessionsPublic(e,"detail-sync"))}};nt();import{spawn as Js}from"node:child_process";import{lstat as Qr,mkdir as gx,readFile as $s,readdir as hx,rm as px,stat as mx,writeFile as Gs}from"node:fs/promises";import{join as Me,normalize as _x,relative as Vs,resolve as yx,sep as Ys}from"node:path";var Oe={PAIR:"_agent/pair",CREATE:"_agent/create",HEALTH:"_agent/health",LIST_SKILLS:"_agent/listSkills",ADD_SKILLS:"_agent/addSkills",REMOVE_SKILLS:"_agent/removeSkills",GET_FILE_TREE:"_agent/getFileTree",GET_FILE_CONTENT:"_agent/getFileContent",DETAIL:"_agent/detail",UPDATE:"_agent/update",DISCONNECT:"_agent/disconnect",SWITCH_MODEL:"_agent/switchModel",GEN_MODEL_TOKEN:"_agent/genModelToken",RESET:"_agent/reset",REPAIR:"_agent/repair",DELETE:"_agent/delete"};function Jt(n){return n?.cozeDeployType==="cloud"?"cloud":"local"}function ks(n){let e=n?.cozeAccountId?.trim();if(!(!e||e==="0"))return e}function Ts(n){let{_meta:e,...s}=n;return{stripped:s,meta:e}}function At(n){if(!n?.cozeAgentId)throw new Error("missing _meta.cozeAgentId");return n.cozeAgentId}var S=class extends Error{code;retriable;cause;constructor(e,s,o){super(s),this.name="BridgeError",this.code=e,this.retriable=o?.retriable??!1,o?.cause!==void 0&&(this.cause=o.cause)}};U();ie();function We(n,e){if(Jt(n)!=="cloud")throw new S("OPERATION_NOT_ALLOWED_FOR_LOCAL",`${e} is not allowed for local agent`)}function Dn(n){return n.startsWith("http://")||n.startsWith("https://")}function Rn(n){return n.endsWith("/")?n.slice(0,-1):n}U();var Ln="1008033",Ds="1289";var Rs="pbbp2",Ls="https://www.coze.cn",Os="/api/coze_claw/resource/get_frontier_key",fx="https://www.coze.cn",lx="wss://frontier.coze.cn";function On(n){return n??process.env.COZE_BRIDGE_HANDSHAKE_URL??fx}function Ns(n){return n??process.env.COZE_BRIDGE_FRONTIER_URL??lx}function Ct(n){let e={},s=n?.ttEnv??process.env.COZE_BRIDGE_TT_ENV,o=n?.usePpe??process.env.COZE_BRIDGE_USE_PPE;return s&&(e["x-tt-env"]=s),o&&(e["x-use-ppe"]=o),e}function $t(n){return n?n.startsWith("boe_")?{ttEnv:n}:{ttEnv:n,usePpe:"1"}:{}}var Ms=D("handshake");async function $r(n){let e=On(n.endpoint),s=n.timeoutMs??1e4,o=`${Rn(e)}${Os}?aid=${encodeURIComponent(Ln)}`,c={Authorization:`Bearer ${n.privatecode}`,Accept:"application/json",...Ct(n.ppeOverride)},d=new AbortController,u=setTimeout(()=>d.abort(),s);Ms.info("frontier key handshake",{base:e});try{let l=await fetch(o,{method:"GET",headers:c,signal:d.signal}),p=l.headers.get("x-tt-logid")??"",m=l.headers.get("x-tt-trace-id")??"";if(!l.ok){let T=await l.text().catch(()=>"");throw new S("UPSTREAM_HANDSHAKE_FAILED",`handshake HTTP ${l.status} logid=${p}: ${T.slice(0,200)}`)}let _=await l.json();if(_.code!==void 0&&_.code!==0)throw new S("UPSTREAM_HANDSHAKE_FAILED",`handshake code=${_.code} msg=${_.msg??"-"} logid=${p}`);let y=_.data??{},I=typeof y.access_key=="string"&&y.access_key||typeof y.accessKey=="string"&&y.accessKey||void 0,L=typeof y.device_id=="string"&&y.device_id||typeof y.deviceId=="string"&&y.deviceId||void 0;if(!I||!L){let T=JSON.stringify(_).slice(0,500);throw new S("UPSTREAM_HANDSHAKE_FAILED",`handshake response missing access_key/device_id (also tried camelCase) logid=${p}: ${T}`)}return Ms.info("handshake ok",{remoteDeviceId:L,logid:p,traceId:m}),{accessKey:I,deviceId:L}}catch(l){throw l instanceof S?l:l.name==="AbortError"?new S("UPSTREAM_HANDSHAKE_FAILED",`handshake timeout (${s}ms)`):new S("UPSTREAM_HANDSHAKE_FAILED",String(l),{cause:l})}finally{clearTimeout(u)}}var Vr=process.env.COZE_BRIDGE_LLM_GATEWAY_URL?.trim()||"https://llm-gateway.coze.cn",Ne="auto";function Bs(n){return{model:n.model??Ne,...n.modelToken?{modelToken:n.modelToken}:{}}}function zs(n){return!n||n===Ne}function Fs(n){let e={};return n.modelToken?(e.ANTHROPIC_BASE_URL=Vr,e.ANTHROPIC_AUTH_TOKEN=n.modelToken,e.ANTHROPIC_MODEL=n.model||Ne):zs(n.model)||(e.ANTHROPIC_MODEL=n.model),e}function Us(n){let e=[];return n.modelToken?e.push("-c",`model="${n.model||Ne}"`):zs(n.model)||e.push("-c",`model="${n.model}"`),n.modelToken&&(e.push("-c",'model_providers.coze.name="coze"'),e.push("-c",`model_providers.coze.base_url="${Vr}/v1"`),e.push("-c",'model_providers.coze.env_key="OPENAI_API_KEY"'),e.push("-c",'model_providers.coze.wire_api="responses"'),e.push("-c","model_providers.coze.requires_openai_auth=false"),e.push("-c","model_providers.coze.supports_websockets=false"),e.push("-c",'model_provider="coze"')),e}function qs(n){return n.modelToken?{OPENAI_API_KEY:n.modelToken}:{}}function Yr(n){let{ttEnv:e,usePpe:s}=$t(n),o={};return e&&(o["x-tt-env"]=e),s&&(o["x-use-ppe"]=s),o}function Hs(n,e){if(!n.modelToken)return{};let s=Yr(e);return Object.keys(s).length===0?{}:{ANTHROPIC_CUSTOM_HEADERS:Object.entries(s).map(([c,d])=>`${c}:${d}`).join(`
|
|
116
|
+
`)}}function Xr(n){return`coze-session-${n.replace(/[^A-Za-z0-9_-]+/g,"-")}`}function js(n,e){if(!n.modelToken)return null;let s=n.model||Ne,o=Yr(e),c={baseUrl:`${Vr}/v1`,api:"openai-completions",apiKey:n.modelToken,models:[{id:s,name:s,reasoning:!1,input:["text"],cost:{input:0,output:0,cacheRead:0,cacheWrite:0},contextWindow:128e3,maxTokens:8192,api:"openai-completions"}]};return Object.keys(o).length>0&&(c.headers=o),c}function Ks(n,e){if(!n.modelToken)return[];let s=Yr(e),o=[];for(let[c,d]of Object.entries(s))o.push("-c",`model_providers.coze.http_headers.${c}="${d}"`);return o}var ae=D("agent-handlers"),Ws=5*1024*1024,bx=1,vx=6,Sx=new Set(["node_modules",".git",".coze","dist","build",".next"]),Nn=class{constructor(e){this.opts=e}opts;async listSkills(e){We(e._meta,"_agent/listSkills");let s=At(e._meta),o=await this.loadAgentCfg(s),c=o?.workspace??Ge(s).workspace,d=o?.skills??[],u=[];for(let l of d){let p=Me(c,l.relPath,"SKILL.md");await mx(p).then(_=>_.isFile()).catch(()=>!1)&&u.push(Px(l))}return{skills:u}}async addSkills(e){We(e._meta,"_agent/addSkills");let s=At(e._meta),o=await this.requireAgentCfg(s),c=e.skills??[],d=[...o.skills??[]],u=new Map(d.map((p,m)=>[p.skillId,m])),l=[];for(let p of c){let m=await Zr({agentId:s,workspace:o.workspace,framework:o.framework,skill:p});ei(d,u,m),l.push(p)}return await Pn(s,d),this.reloadAgentSessions(s,"skills-added"),{installedSkills:l}}async removeSkills(e){We(e._meta,"_agent/removeSkills");let s=At(e._meta),o=await this.requireAgentCfg(s),c=new Set(e.skillIds??[]),d=o.skills??[],u=[];for(let l of d){if(!c.has(l.skillId)){u.push(l);continue}let p=Me(o.workspace,l.relPath);await px(p,{recursive:!0,force:!0}),ae.info("skill removed",{agentId:s,skillId:l.skillId,relPath:l.relPath})}return await Pn(s,u),this.reloadAgentSessions(s,"skills-removed"),{ok:!0}}reloadAgentSessionsPublic(e,s){this.reloadAgentSessions(e,s)}reloadAgentSessions(e,s){let o=this.opts.agents.get(e);if(o)for(let[c,d]of o.sessions){if(!d.downstream)continue;let u=d.acpSessionId;if(u&&o.activeTriggers.has(u)||this.isRuntimePendingPermission(d)){d.reloadAfterTurn=!0,ae.info("downstream busy, scheduling reload after turn",{reason:s,agentId:e,framework:o.framework,cloudId:c,acpId:u});continue}let p=d.downstream;d.downstream=void 0,ae.info("killing downstream for workspace reload (idle)",{reason:s,agentId:e,framework:o.framework,cloudId:c,acpId:u}),p.stop(s).catch(m=>ae.warn("downstream stop failed during reload (ignored)",{reason:s,agentId:e,cloudId:c,err:String(m)}))}}isRuntimePendingPermission(e){let s=this.opts.isRuntimePendingPermission;return!s||!e.downstream?!1:s(e.downstream)}async updateAgent(e){if(!e.cozeIdentity?.trim())return ae.info("_agent/update: empty cozeIdentity, noop",{agentId:e.agentId}),{ok:!0};let s=e.agentId,o=await me(s);if(!o)throw new S("AGENT_NOT_FOUND",`agent not found: ${s}`);if(o.cozeIdentity===e.cozeIdentity)return ae.info("_agent/update: cozeIdentity unchanged, noop",{agentId:s}),{ok:!0};try{await It(o.workspace,o.framework,s,e.cozeIdentity)}catch(c){throw ae.error("_agent/update: writeInstructionFile failed, aborting update",{agentId:s,framework:o.framework,workspace:o.workspace,err:String(c)}),new S("AGENT_PROTOCOL_ERROR",`failed to write instruction file for agent ${s}: ${String(c)}`,{cause:c})}return o.cozeIdentity=e.cozeIdentity,await Ce(o),ae.info("_agent/update: cozeIdentity rewritten",{agentId:s,framework:o.framework}),this.reloadAgentSessions(s,"identity-changed"),{ok:!0}}async disconnectAgent(e){let s=e.agentId;if(!s)throw new S("IPC_BAD_REQUEST","_agent/disconnect: missing agentId");let o=await me(s);return o?(o.disconnectedAt=Date.now(),o.disconnectReason=e.reason??"",await Ce(o),ae.info("agent disconnected",{agentId:s,reason:e.reason??"",force:e.force??!1}),this.opts.disposeAndMarkDisconnected&&await this.opts.disposeAndMarkDisconnected(s,e.reason??"disconnect"),{ok:!0}):(ae.warn("_agent/disconnect: agent not found, ignoring",{agentId:s}),{ok:!0})}async switchModel(e){if(We(e._meta,"_agent/switchModel"),!e.agentId)throw new S("IPC_BAD_REQUEST","_agent/switchModel: missing agentId");let s=e.model?.trim()?e.model:Ne,o=await me(e.agentId);if(!o)throw new S("AGENT_NOT_FOUND",`agent not found: ${e.agentId}`);o.model=s,await Ce(o),ae.info("_agent/switchModel: model persisted",{agentId:e.agentId,model:s,reason:e.reason??""});let c=this.opts.agents.get(e.agentId);if(!c)return ae.info("_agent/switchModel: agent not running, config persisted only",{agentId:e.agentId}),{ok:!0};c.model=s,this.opts.cleanupOpenclawProviders&&await this.opts.cleanupOpenclawProviders(c).catch(u=>ae.warn("cleanupOpenclawProviders before switchModel failed (ignored)",{agentId:e.agentId,err:String(u)}));let d=[];for(let[u,l]of c.allSessionQueues())d.push(l.enqueue(async()=>{let p=c.sessions.get(u);p?.downstream&&(await p.downstream.stop(`switchModel: ${s}`).catch(()=>{}),p.downstream=void 0)}));return await Promise.all(d),ae.info("_agent/switchModel: all session runtimes killed, next prompt will respawn",{agentId:e.agentId,model:s,cloudSessions:d.length}),{ok:!0}}async resetAgent(e){if(We(e._meta,Oe.RESET),!e.agentId)throw new S("IPC_BAD_REQUEST",`${Oe.RESET}: missing agentId`);return await this.runDetailSync(e.agentId,Oe.RESET,e.reason),{ok:!0}}async repairAgent(e){if(We(e._meta,Oe.REPAIR),!e.agentId)throw new S("IPC_BAD_REQUEST",`${Oe.REPAIR}: missing agentId`);let s=await this.loadAgentCfg(e.agentId);if(s&&s.framework!=="openclaw")throw new S("IPC_BAD_REQUEST",`${Oe.REPAIR} only allowed for openclaw, got ${s.framework}`);if(s&&this.opts.openclawRepair)try{await this.opts.openclawRepair(e.agentId,s.workspace)}catch(o){ae.warn("openclaw repair (delete+add) failed (ignored)",{agentId:e.agentId,reason:e.reason,err:String(o)})}return await this.runDetailSync(e.agentId,Oe.REPAIR,e.reason),{ok:!0}}async runDetailSync(e,s,o){if(!this.opts.detailSyncer){ae.warn("detailSyncer not wired, skipping sync",{method:s,agentId:e});return}try{await this.opts.detailSyncer(e)}catch(c){ae.warn("detail sync failed (ignored)",{method:s,agentId:e,reason:o,err:String(c)})}}async getFileTree(e){We(e._meta,"_agent/getFileTree");let s=e._meta,o=At(s),c=await this.resolveWorkspace(o),d=e.filePath??"",u=this.safeJoin(c,d),l=await Qr(u).catch(()=>null);if(!l)throw new S("IPC_BAD_REQUEST",`path not found: ${d}`);if(l.isSymbolicLink())throw new S("IPC_BAD_REQUEST",`symlink not allowed: ${d}`);let p=Mx(e.depth);return l.isDirectory()?{tree:await Nx(c,u,d,p)}:{tree:[{name:Bx(d),path:Qs(d||"."),isDir:!1,size:l.size,modifiedAt:Math.floor(l.mtimeMs)}]}}async getFileContent(e){We(e._meta,"_agent/getFileContent");let s=At(e._meta),o=await this.resolveWorkspace(s);if(!e.filePath)throw new S("IPC_BAD_REQUEST","filePath required");let c=this.safeJoin(o,e.filePath),d=await Qr(c).catch(()=>null);if(!d||!d.isFile())throw new S("IPC_BAD_REQUEST",`not a file: ${e.filePath}`);if(d.isSymbolicLink())throw new S("IPC_BAD_REQUEST",`symlink not allowed: ${e.filePath}`);if(d.size>Ws)throw new S("IPC_BAD_REQUEST",`file too large: ${d.size} bytes (max ${Ws})`);let u=await $s(c);return u.includes(0)?{content:u.toString("base64"),encoding:"base64",size:d.size}:{content:u.toString("utf8"),encoding:"utf-8",size:d.size}}async resolveWorkspace(e){let s=this.opts.agents.get(e);return s?s.workspace:(await me(e).catch(()=>null))?.workspace??Ge(e).workspace}safeJoin(e,s){let o=yx(e,s||"."),c=Vs(e,o);if(c.startsWith("..")||c===".."||c.startsWith(`..${Ys}`))throw new S("IPC_BAD_REQUEST",`path escapes workspace: ${s}`);return o}loadAgentCfg(e){return me(e)}async requireAgentCfg(e){let s=await this.loadAgentCfg(e);if(!s)throw new S("AGENT_NOT_FOUND",`no config for agent: ${e}`);return s}};function Ex(n){let e=n.trim().replace(/[\x00-\x1f<>:"|?*/\\]+/g,"-").replace(/^[\s.-]+|[\s.-]+$/g,"").slice(0,64);if(!e||e==="."||e==="..")throw new S("IPC_BAD_REQUEST",`invalid skill name: ${n}`);if(/^(con|prn|aux|nul|com[1-9]|lpt[1-9])$/i.test(e))throw new S("IPC_BAD_REQUEST",`reserved windows filename: ${n}`);return e}function Ix(n){return n==="claude-code"?Me(".claude","skills"):Me(".agents","skills")}var Ax=3e4,Cx=50*1024*1024,Mn=3e4;async function Zr(n){let{agentId:e,workspace:s,framework:o,skill:c}=n;if(!c.skillName)throw new S("IPC_BAD_REQUEST","skill missing skillName");let d=typeof c.content=="string"&&c.content.length>0,u=typeof c.downloadUrl=="string"&&c.downloadUrl.length>0;if(!d&&!u)throw new S("IPC_BAD_REQUEST",`skill ${c.skillId} missing both content and downloadUrl`);let l=Ex(c.skillName),p=Ix(o),m=Me(p,l),_=Me(s,m);if(await gx(_,{recursive:!0}),d){let I=Buffer.from(c.content,"utf8");Vt(I.length),await Gs(Me(_,"SKILL.md"),I,"utf8")}else{let I=await kx(c.downloadUrl);Dx(I)?await Rx(I,_):await Gs(Me(_,"SKILL.md"),I.toString("utf8"),"utf8")}let y={skillId:c.skillId,skillName:c.skillName,relPath:m,installedAt:Date.now(),...c.description?{description:c.description}:{},...c.icon?{icon:c.icon}:{},...c.version?{version:c.version}:{},...c.downloadUrl?{downloadUrl:c.downloadUrl}:{},...c.config?{config:c.config}:{},...c.builtin?{builtin:c.builtin}:{}};return ae.info("skill installed",{agentId:e,skillId:c.skillId,skillName:c.skillName,relPath:m,source:d?"content":"downloadUrl"}),y}function ei(n,e,s){let o=e.get(s.skillId);if(o!==void 0){n[o]=s;return}e.set(s.skillId,n.length),n.push(s)}function Px(n){return{skillId:n.skillId,skillName:n.skillName,...n.description?{description:n.description}:{},...n.icon?{icon:n.icon}:{},...n.version?{version:n.version}:{},...n.config?{config:n.config}:{},...n.builtin?{builtin:n.builtin}:{}}}async function kx(n){if(!n)throw new S("IPC_BAD_REQUEST","skill missing downloadUrl");if(n.startsWith("data:")){let e=Math.floor(n.length*3/4);Vt(e);let s=Tx(n);return Vt(s.length),s}if(n.startsWith("file:")){let e=new URL(n).pathname,s=await $s(e);return Vt(s.length),s}if(Dn(n)){let e=new AbortController,s=setTimeout(()=>e.abort(),Ax);try{let o=await fetch(n,{signal:e.signal});if(!o.ok)throw new S("IPC_BAD_REQUEST",`fetch skill failed HTTP ${o.status} ${n}`);let c=await o.arrayBuffer();return Vt(c.byteLength),Buffer.from(c)}finally{clearTimeout(s)}}throw new S("IPC_BAD_REQUEST",`unsupported downloadUrl scheme (\u8981 https/data/file): ${n.slice(0,80)}`)}function Vt(n){if(n>Cx)throw new S("IPC_BAD_REQUEST",`skill too large: ${n} bytes`)}function Tx(n){let e=/^data:([^,;]*)(;base64)?,(.*)$/s.exec(n);if(!e)throw new S("IPC_BAD_REQUEST","bad data URL");let s=!!e[2],o=e[3]??"";return s?Buffer.from(o,"base64"):Buffer.from(decodeURIComponent(o),"utf8")}function Dx(n){return n.length>=2&&n[0]===31&&n[1]===139}async function Rx(n,e){await Lx(n),await new Promise((s,o)=>{let c=Js("tar",["-xzf","-","-C",e,"--strip-components=1","--no-same-owner"],{stdio:["pipe","pipe","pipe"]}),d="";c.stderr?.on("data",l=>{d+=String(l)});let u=setTimeout(()=>{c.kill("SIGKILL"),o(new S("IPC_BAD_REQUEST",`tar extract timeout (${Mn}ms)`))},Mn);c.on("error",l=>{clearTimeout(u),o(new S("IPC_BAD_REQUEST",`tar spawn failed: ${l.message}`,{cause:l}))}),c.on("exit",l=>{clearTimeout(u),l===0?s():o(new S("IPC_BAD_REQUEST",`tar exit ${l}${d?`: ${d.trim().slice(0,200)}`:""}`))}),c.stdin?.end(n)})}async function Lx(n){let e=await new Promise((s,o)=>{let c=Js("tar",["-tzvf","-"],{stdio:["pipe","pipe","pipe"]}),d="",u="";c.stdout?.on("data",p=>{d+=String(p)}),c.stderr?.on("data",p=>{u+=String(p)});let l=setTimeout(()=>{c.kill("SIGKILL"),o(new S("IPC_BAD_REQUEST",`tar list timeout (${Mn}ms)`))},Mn);c.on("error",p=>{clearTimeout(l),o(new S("IPC_BAD_REQUEST",`tar list spawn failed: ${p.message}`))}),c.on("exit",p=>{clearTimeout(l),p===0?s(d):o(new S("IPC_BAD_REQUEST",`tar list exit ${p}${u?`: ${u.trim().slice(0,200)}`:""}`))}),c.stdin?.end(n)});for(let s of e.split(`
|
|
117
|
+
`)){let o=s.trim();if(!o)continue;let c=o.charCodeAt(0);if(c!==45&&c!==100)throw new S("IPC_BAD_REQUEST",`tar entry kind '${o[0]}' not allowed (symlink/hardlink/special): ${o.slice(0,100)}`);let u=(o.match(/\s(\S.*)$/)?.[1]??"").split(" -> ")[0]?.trim()??"";if(!u)continue;if(u.startsWith("/"))throw new S("IPC_BAD_REQUEST",`tar entry absolute path: ${u}`);if(u.split(/[/\\]/).some(p=>p===".."))throw new S("IPC_BAD_REQUEST",`tar entry contains '..': ${u}`)}}var Ox=5e3;async function Nx(n,e,s,o){return Xs(n,e,s,o,{count:0})}async function Xs(n,e,s,o,c){if(o<=0)return[];let d;try{d=await hx(e,{withFileTypes:!0})}catch{return[]}let u=[];for(let l of d){if(Sx.has(l.name)||l.isSymbolicLink())continue;if(c.count>=Ox){u.push({name:"...",path:"...",isDir:!1,size:0,modifiedAt:0,hasMore:!0});break}let p=Me(e,l.name),m=_x(Me(s,l.name)),_=null;try{_=await Qr(p)}catch{continue}if(_.isSymbolicLink())continue;c.count++;let y={name:l.name,path:Qs(Vs(n,p)),isDir:_.isDirectory(),size:_.size,modifiedAt:Math.floor(_.mtimeMs)};_.isDirectory()&&o>1&&(y.children=await Xs(n,p,m,o-1,c)),u.push(y)}return u.sort((l,p)=>l.isDir!==p.isDir?l.isDir?-1:1:l.name.localeCompare(p.name)),u}function Mx(n){return!n||n<=0?bx:Math.min(n,vx)}function Bx(n){if(!n||n==="."||n==="/")return".";let e=n.split(/[/\\]/);return e[e.length-1]||"."}function Qs(n){return n.split(Ys).join("/")}U();import{readFileSync as op}from"node:fs";import{dirname as cp,join as xp}from"node:path";import{fileURLToPath as up}from"node:url";var rt="0.1.48";var Be=D("agent-health-reporter"),zx=1e4,Yt=class{constructor(e){this.opts=e;this.intervalMs=e.intervalMs??zx}opts;timer=null;inFlight=!1;unsubscribeRegister=null;intervalMs;start(){this.timer||(this.timer=setInterval(()=>{this.tick()},this.intervalMs),this.timer.unref?.(),this.unsubscribeRegister=this.opts.core.onAgentRegister(()=>{this.tick()}),Be.info("heartbeat started",{intervalMs:this.intervalMs}),this.tick())}stop(){this.timer&&(clearInterval(this.timer),this.timer=null,this.unsubscribeRegister&&(this.unsubscribeRegister(),this.unsubscribeRegister=null),Be.info("heartbeat stopped"))}async tick(){if(this.inFlight){Be.debug("previous tick still in-flight, skip");return}let e=this.opts.getDeviceId();if(!e){Be.debug("deviceId not available, skip tick (\u5C1A\u672A pair)");return}this.inFlight=!0;try{let s=[];for(let l of this.opts.core.agents.values()){let p=Fx(l);if(!p)continue;let m={agentId:l.agentId,status:p};l.patToken&&(m.patToken=l.patToken),l.accountId&&(m.accountId=l.accountId),s.push(m)}if(s.length===0)return;let o={agents:s,bridgeVersion:rt,_meta:{cozeDeviceId:e}},c;try{c=await this.opts.core.sendRequest("_agent/health",o,5e3)}catch(l){Be.warn("heartbeat batch send failed",{count:s.length,err:String(l)})}let d=c?.authFailures;if(d&&d.length>0&&(Be.warn("heartbeat received authFailures from cloud",{count:d.length,agentIds:d.map(l=>l.agentId)}),this.opts.onAuthFailures))try{await this.opts.onAuthFailures(d)}catch(l){Be.warn("onAuthFailures callback failed (ignored)",{err:String(l)})}let u=c?.minBridgeVersion;if(u&&(Be.info("heartbeat received minBridgeVersion from cloud",{minV:u}),this.opts.onMinBridgeVersion))try{await this.opts.onMinBridgeVersion(u)}catch(l){Be.warn("onMinBridgeVersion callback failed (ignored)",{err:String(l)})}}finally{this.inFlight=!1}if(this.opts.onTickEnd)try{await this.opts.onTickEnd()}catch(s){Be.warn("onTickEnd hook failed",{err:String(s)})}}};function Fx(n){return n.status==="error"?"error":n.activeTriggers.size>0?"busy":n.status==="ok"?"online":null}nt();import{mkdir as ni,rm as ud}from"node:fs/promises";import{spawn as Jx,spawnSync as $x}from"node:child_process";function Xt(n,e,s){return s===void 0?{jsonrpc:"2.0",id:n,method:e}:{jsonrpc:"2.0",id:n,method:e,params:s}}function Qt(n,e){return e===void 0?{jsonrpc:"2.0",method:n}:{jsonrpc:"2.0",method:n,params:e}}function Pt(n,e){return{jsonrpc:"2.0",id:n,result:e}}function it(n,e){return{jsonrpc:"2.0",id:n,error:e}}var Bn=class extends Error{code;data;constructor(e){super(`JSON-RPC error code=${e.code} ${e.message}`),this.name="RemoteRpcError",this.code=e.code,e.data!==void 0&&(this.data=e.data)}},H={PARSE_ERROR:-32700,INVALID_REQUEST:-32600,METHOD_NOT_FOUND:-32601,INVALID_PARAMS:-32602,INTERNAL_ERROR:-32603,AGENT_NOT_FOUND:-32001,AGENT_BUSY:-32002,AGENT_TIMEOUT:-32003,AGENT_SPAWN_FAILED:-32004,OPERATION_NOT_ALLOWED_FOR_LOCAL:-32005,AGENT_DISCONNECTED:-32006,MODEL_TOKEN_GEN_FAILED:-32009,PATH_OUTSIDE_WORKSPACE:-32010,FILE_TOO_LARGE:-32011,UNSUPPORTED_MIME:-32012,UPLOAD_FAILED:-32013,UPSTREAM_NOT_READY:-32014,BRIDGE_UPGRADING:-32015};function Zs(n){return"method"in n&&"id"in n&&n.id!==void 0}function eo(n){return"method"in n&&!("id"in n)}function zn(n){return!("method"in n)&&"id"in n}var Ux={AGENT_NOT_FOUND:H.AGENT_NOT_FOUND,AGENT_BUSY:H.AGENT_BUSY,AGENT_DISCONNECTED:H.AGENT_DISCONNECTED,AGENT_TIMEOUT:H.AGENT_TIMEOUT,AGENT_SPAWN_FAILED:H.AGENT_SPAWN_FAILED,AGENT_PROTOCOL_ERROR:H.INTERNAL_ERROR,BRIDGE_CONFIG_INVALID:H.INTERNAL_ERROR,BRIDGE_INTERNAL:H.INTERNAL_ERROR,IPC_AUTH_FAILED:H.INTERNAL_ERROR,IPC_BAD_REQUEST:H.INVALID_REQUEST,MODEL_TOKEN_GEN_FAILED:H.MODEL_TOKEN_GEN_FAILED,OPERATION_NOT_ALLOWED_FOR_LOCAL:H.OPERATION_NOT_ALLOWED_FOR_LOCAL,UPSTREAM_DISCONNECTED:H.INTERNAL_ERROR,UPSTREAM_HANDSHAKE_FAILED:H.INTERNAL_ERROR,PATH_OUTSIDE_WORKSPACE:H.PATH_OUTSIDE_WORKSPACE,FILE_TOO_LARGE:H.FILE_TOO_LARGE,UNSUPPORTED_MIME:H.UNSUPPORTED_MIME,UPLOAD_FAILED:H.UPLOAD_FAILED,UPSTREAM_NOT_READY:H.UPSTREAM_NOT_READY,BRIDGE_UPGRADING:H.BRIDGE_UPGRADING};function qx(n){if(n!=null)return n instanceof Error?{name:n.name,message:Zt(n.message)}:typeof n=="string"?Zt(n):typeof n=="object"?jx(n):n}var Hx=[[/\/Users\/[^/\s'"`)]+/g,"/Users/<redacted>"],[/\/home\/[^/\s'"`)]+/g,"/home/<redacted>"],[/[A-Za-z]:\\Users\\[^\\\s'"`)]+/g,"C:\\Users\\<redacted>"],[/(Bearer|Token|Authorization:)\s+[\w._-]+/gi,"$1 <redacted>"],[/\b(sk|pat|ak)[-_][A-Za-z0-9_-]{20,}\b/g,"<redacted-key>"]];function Zt(n){let e=n;for(let[s,o]of Hx)e=e.replace(s,o);return e}function jx(n){let e={};for(let[s,o]of Object.entries(n))typeof o=="string"?e[s]=Zt(o):e[s]=o;return e}function en(n){if(n instanceof S){let e=qx(n.cause),s={bridgeCode:n.code,retriable:n.retriable};return e!==void 0&&(s.cause=e),{code:Ux[n.code]??H.INTERNAL_ERROR,message:Zt(n.message),data:s}}return{code:H.INTERNAL_ERROR,message:Zt(n instanceof Error?n.message:String(n))}}function to(n){let e=n.data,s=e?.bridgeCode??"AGENT_PROTOCOL_ERROR",o=!!e&&typeof e.message=="string"&&!!e.message,c=o?e?.message:n.message,d=n.data;if(o&&e){let{message:u,...l}=e;d=l}return new S(s,c,{retriable:e?.retriable??!1,cause:d})}function ro(n){return`${JSON.stringify(n)}
|
|
118
|
+
`}var no=10*1024*1024,Fn=class{buffer="";onError;constructor(e={}){this.onError=e.onError}push(e){if(this.buffer+=typeof e=="string"?e:e.toString("utf8"),this.buffer.length>no){let c=this.buffer.length;return this.buffer="",this.onError?.({line:`<buffer overflow: ${c} bytes, dropped>`,error:new Error(`LdjsonDecoder buffer exceeded ${no} bytes`)}),[]}let s=this.buffer.split(`
|
|
119
|
+
`);this.buffer=s.pop()??"";let o=[];for(let c of s){let d=c.replace(/\r$/,"").trim();if(d)try{o.push(JSON.parse(d))}catch(u){this.onError?.({line:d,error:u})}}return o}flush(){if(!this.buffer)return[];let e=this.buffer.replace(/\r$/,"").trim();if(this.buffer="",!e)return[];try{return[JSON.parse(e)]}catch(s){return this.onError?.({line:e,error:s}),[]}}};var so={"session/prompt":"session.prompt","session/cancel":"session.cancel","session/new":"session.new","session/load":"session.load","_agent/create":"agent.create","_agent/health":"agent.health","_agent/pair":"agent.pair","_agent/listSkills":"agent.listSkills","_agent/addSkills":"agent.addSkills","_agent/removeSkills":"agent.removeSkills","_agent/getFileTree":"agent.getFileTree","_agent/getFileContent":"agent.getFileContent","_agent/detail":"agent.detail","_agent/update":"agent.update","_agent/disconnect":"agent.disconnect","_agent/switchModel":"agent.switchModel","_agent/genModelToken":"agent.genModelToken","_agent/reset":"agent.reset","_agent/repair":"agent.repair","session/request_permission":"session.requestPermission",initialize:"initialize"},vp=Object.fromEntries(Object.entries(so).map(([n,e])=>[e,n])),Kx={"session.prompt":["agentId","triggerMsgId","sessionId"],"session.cancel":["agentId","triggerMsgId","sessionId"],"session.new":["agentId"],"session.load":["agentId"],"agent.create":["agentId"],"agent.health":[],"agent.listSkills":["agentId"],"agent.addSkills":["agentId"],"agent.removeSkills":["agentId"],"agent.getFileTree":["agentId"],"agent.getFileContent":["agentId"],"agent.detail":["agentId"],"agent.update":["agentId"],"agent.disconnect":["agentId"],"agent.switchModel":["agentId"],"agent.genModelToken":["agentId","sessionId"],"agent.reset":["agentId"],"agent.repair":["agentId"],"session.requestPermission":["agentId","sessionId"],"agent.pair":[],initialize:[]},kt=class{seq=0;next(e,s){this.seq+=1;let o=so[e]??Gx(e),c=Kx[o]??[],d=[o,String(this.seq)];if(c.length>0){let u=c.map(p=>io(s?.[p]??"")),l=Wx(u).join(":");l&&d.push(l)}else s&&Object.values(s).some(u=>u)&&d.push(Object.values(s).filter(Boolean).map(u=>io(String(u))).join(":"));return d.join("_")}reset(){this.seq=0}};function Gx(n){return n.replace(/[\s/]+/g,".").replace(/_+/g,"-")}function io(n){return n.replace(/[:_\s]+/g,"-")}function Wx(n){let e=n.length;for(;e>0&&!n[e-1];)e-=1;return n.slice(0,e)}function Un(n,e){let s=process.env[n];if(!s)return e;let o=Number(s);return Number.isFinite(o)&&o>0?o:e}U();var Vx=3e4,Yx=200,Xx=Un("COZE_BRIDGE_SESSION_PROMPT_MAX_MS",3600*1e3),oo=500;function Qx(n){try{let e=JSON.stringify(n);return e===void 0||e.length<=oo?n:`${e.slice(0,oo)}...<truncated, total ${e.length} chars>`}catch{return"<unserializable>"}}function ao(n,e){if(!(typeof n!="number"||n<=0))try{if(process.platform==="win32"){let s=["/PID",String(n),"/T"];e==="SIGKILL"&&s.push("/F"),$x("taskkill",s,{stdio:"ignore",windowsHide:!0})}else process.kill(-n,e)}catch{}}var st=class{constructor(e){this.opts=e;this.log=D(`downstream.${this.constructor.name}`),this.decoder=new Fn({onError:s=>this.log.warn("decode line failed",{line:s.line})})}opts;child;decoder;pending=new Map;idAllocator=new kt;updateHandlers=[];agentRequestHandlers=[];exitHandlers=[];log;stopped=!1;stderrRing=[];sanitizeEnv(e){return e}async start(){if(this.child)throw new S("BRIDGE_INTERNAL","Downstream already started");let e=process.platform!=="win32",s=Jx(this.opts.command,this.opts.args,{cwd:this.opts.cwd,env:{...this.sanitizeEnv(process.env),...this.opts.env},stdio:["pipe","pipe","pipe"],detached:e});this.child=s,s.stdout?.setEncoding("utf8"),s.stdout?.on("data",o=>{try{for(let c of this.decoder.push(o))this.dispatch(c)}catch(c){this.log.warn("stdout dispatch threw, swallowed to keep daemon alive",{err:String(c)})}}),s.stderr?.setEncoding("utf8"),s.stderr?.on("data",o=>{let c=o.trimEnd();this.stderrRing.push(c),this.stderrRing.length>Yx&&this.stderrRing.shift(),this.log.debug("stderr",{text:c})}),s.stdin?.on("error",o=>{this.log.warn("child stdin error",{err:String(o)})}),s.stdout?.on("error",o=>{this.log.warn("child stdout error",{err:String(o)})}),s.stderr?.on("error",o=>{this.log.warn("child stderr error",{err:String(o)})}),s.on("exit",(o,c)=>{this.stopped=!0,(o!==0||c!==null)&&this.stderrRing.length>0&&this.log.warn("downstream exited abnormally, recent stderr",{code:o,signal:c,recentStderr:[...this.stderrRing]});try{for(let u of this.decoder.flush())this.dispatch(u)}catch(u){this.log.debug("decoder.flush on exit threw (ignored)",{err:String(u)})}this.failAllPending(new S("AGENT_PROTOCOL_ERROR",`agent exited (${o}/${c})`));for(let u of this.exitHandlers)u(o,c)}),s.on("error",o=>{this.log.error("child error",{err:String(o)}),this.failAllPending(new S("AGENT_SPAWN_FAILED",String(o),{cause:o}))}),this.log.info("downstream started",{command:this.opts.command,pid:s.pid,cwd:this.opts.cwd})}async stop(e){if(!this.child||this.stopped)return;this.stopped=!0,this.log.info("downstream stopping",{reason:e});let s=this.child,o=new Promise(d=>s.once("exit",()=>d()));ao(s.pid,"SIGTERM");let c=setTimeout(()=>{s.killed||ao(s.pid,"SIGKILL")},5e3);try{await o}finally{clearTimeout(c)}}pid(){return this.child?.pid}isAlive(){return!!this.child&&!this.stopped}initialize(e){return this.call("initialize",e)}sessionNew(e){return this.call("session/new",{mcpServers:[],...e})}sessionLoad(e){return this.call("session/load",{mcpServers:[],...e})}sessionPrompt(e,s=Xx){return this.call("session/prompt",e,s)}async sessionCancel(e){!this.child||this.stopped||this.writeFrame(Qt("session/cancel",e))}onUpdate(e){this.updateHandlers.push(e)}onAgentRequest(e){this.agentRequestHandlers.push(e)}respondAgentRequest(e,s){if(!(!this.child||this.stopped))try{this.writeFrame(Pt(e,s))}catch(o){this.log.warn("respondAgentRequest write failed",{id:e,err:String(o)})}}respondAgentRequestError(e,s){if(!(!this.child||this.stopped))try{this.writeFrame(it(e,s))}catch(o){this.log.warn("respondAgentRequestError write failed",{id:e,err:String(o)})}}onExit(e){this.exitHandlers.push(e)}call(e,s,o=Vx){if(!this.child||this.stopped)return Promise.reject(new S("AGENT_PROTOCOL_ERROR","downstream not started"));let c=this.idAllocator.next(e),d=Xt(c,e,s),u=o>0&&Number.isFinite(o);return new Promise((l,p)=>{let m=u?setTimeout(()=>{this.pending.delete(c),p(new S("AGENT_TIMEOUT",`${e} timed out after ${o}ms`))},o):null;this.pending.set(c,{resolve:l,reject:p,timer:m,method:e});try{this.writeFrame(d)}catch(_){m&&clearTimeout(m),this.pending.delete(c),p(_)}})}writeFrame(e){if(!this.child?.stdin||this.child.stdin.destroyed)throw new S("AGENT_PROTOCOL_ERROR","downstream stdin not writable");this.child.stdin.write(ro(e),s=>{s&&this.log.warn("stdin write callback err",{err:String(s)})})}dispatch(e){if(zn(e)){let s=e.id!==null?this.pending.get(e.id):void 0;if(!s){this.log.warn("orphan response",{id:e.id});return}this.pending.delete(e.id),s.timer&&clearTimeout(s.timer),e.error?(this.log.warn("downstream returned error frame",{id:e.id,method:s.method,code:e.error.code,message:e.error.message,data:e.error.data}),s.reject(to(e.error))):e.result===void 0?(this.log.warn("downstream response missing both result and error",{id:e.id,method:s.method}),s.reject(new S("AGENT_PROTOCOL_ERROR",`${s.method} response missing both result and error`))):(this.log.info("downstream returned result",{id:e.id,method:s.method,result:Qx(e.result)}),s.resolve(e.result));return}if(eo(e)){if(e.method==="session/update")for(let s of this.updateHandlers)try{Promise.resolve(s(e.params)).catch(o=>this.log.warn("update handler failed (async)",{err:String(o)}))}catch(o){this.log.warn("update handler threw sync, swallowed",{err:String(o)})}else this.log.info("unknown notification (drop, not forwarded)",{method:e.method});return}if(Zs(e)){let s=e;try{this.handleAgentRequest(s).catch(o=>this.log.error("agent request handler failed (async)",{method:s.method,err:String(o)}))}catch(o){this.log.warn("handleAgentRequest threw sync, swallowed",{method:s.method,err:String(o)})}}}async handleAgentRequest(e){if(this.agentRequestHandlers.length===0){this.writeFrame(it(e.id,{code:-32601,message:`method not handled by Bridge: ${e.method}`}));return}for(let s of this.agentRequestHandlers)try{await s(e)}catch(o){this.log.error("agentRequestHandler threw",{method:e.method,err:String(o)});try{this.writeFrame(it(e.id,en(o)))}catch{}}}failAllPending(e){for(let s of this.pending.values())s.timer&&clearTimeout(s.timer),s.reject(e);this.pending.clear()}};var Zx="@agentclientprotocol/claude-agent-acp@latest";function ed(n){let e={};for(let[s,o]of Object.entries(n))o!==void 0&&(s.startsWith("CLAUDE")||s==="AI_AGENT"||s==="BAGGAGE"||(e[s]=o));return e}var qn=class extends st{framework="claude-code";constructor(e){let s=En("claude-code"),[o,c]=s?[s,[]]:["npx",["-y",Zx]],d=e.command??o,u=e.args??c,l={command:d,args:u,cwd:e.cwd,...e.env?{env:e.env}:{}};super(l)}sanitizeEnv(e){return ed(e)}};import{mkdtempSync as td,rmSync as nd}from"node:fs";import{tmpdir as rd}from"node:os";import{join as id}from"node:path";var sd="@zed-industries/codex-acp@latest",Hn=class extends st{framework="codex";authMethodId;codexHomeDir;constructor(e){let s=En("codex"),[o,c]=s?[s,[]]:["npx",["-y",sd]],d=e.command??o,u=e.args??c,l=e.extraArgs?[...u,...e.extraArgs]:u,p=e.isolateCodexHome?td(id(rd(),"coze-bridge-codex-home-")):void 0,m=p?{...e.env??{},CODEX_HOME:p}:e.env,_={command:d,args:l,cwd:e.cwd,...m?{env:m}:{}};super(_),this.authMethodId=e.authMethodId,this.codexHomeDir=p}async initialize(e){let s=await super.initialize(e);return this.authMethodId&&await this.call("authenticate",{methodId:this.authMethodId}),s}async stop(e){if(await super.stop(e),this.codexHomeDir)try{nd(this.codexHomeDir,{recursive:!0,force:!0})}catch{}}};var od=3e4,Tt=class extends st{framework="openclaw";agentId;sessionName;slashModelOnStart;constructor(e){let s=e.sessionName??"default",o=["acp","--session",`agent:${e.agentId}:${s}`];e.gatewayToken&&o.push("--token",e.gatewayToken);let c={command:e.command,args:o,cwd:e.cwd,...e.env?{env:e.env}:{}};super(c),this.agentId=e.agentId,this.sessionName=s,this.slashModelOnStart=e.slashModelOnStart}async afterSessionEstablished(e){this.slashModelOnStart&&(this.log.info("switching session to per-session provider via /model",{agentId:this.agentId,sessionName:this.sessionName,slash:this.slashModelOnStart}),await this.sessionPrompt({sessionId:e,prompt:[{type:"text",text:`/model ${this.slashModelOnStart}`}]},od))}get acpSessionName(){return this.sessionName}};U();ie();function ti(n){return n.replace(/[^A-Za-z0-9._-]+/g,"-")}var Dt=class{slots=[];running=!1;closed=!1;disposed=!1;enqueue(e){return this.disposed?Promise.reject(new Error("AsyncQueue disposed")):this.closed?Promise.reject(new Error("AsyncQueue closed")):new Promise((s,o)=>{this.slots.push({task:e,resolve:s,reject:o}),this.drain()})}close(){this.closed=!0}dispose(e=new Error("AsyncQueue disposed")){for(this.disposed=!0,this.closed=!0;this.slots.length>0;)this.slots.shift()?.reject(e)}get size(){return this.slots.length}get isRunning(){return this.running}get isDisposed(){return this.disposed}async drain(){if(!this.running){this.running=!0;try{for(;this.slots.length>0&&!this.disposed;){let e=this.slots.shift();if(!e)break;try{let s=await e.task();e.resolve(s)}catch(s){e.reject(s)}}}finally{this.running=!1}}}};var jn=class{agentId;framework;workspace;deployType;accountId;patToken;sessions=new Map;sessionQueues=new Map;activeTriggers=new Map;status="ok";model;lastActiveAt=Date.now();constructor(e){this.agentId=e.agentId,this.framework=e.framework,this.workspace=e.workspace,this.model=e.model,this.deployType=e.deployType??"local",e.accountId&&(this.accountId=e.accountId),e.patToken&&(this.patToken=e.patToken)}setPatToken(e){this.patToken=e}getSessionQueue(e){let s=this.sessionQueues.get(e);return(!s||s.isDisposed)&&(s=new Dt,this.sessionQueues.set(e,s)),s}allSessionQueues(){return this.sessionQueues.entries()}hasSessionQueue(e){let s=this.sessionQueues.get(e);return!!s&&!s.isDisposed}async dispose(e){this.status="stopped";let s=new Error(`AgentSession disposed${e?`: ${e}`:""}`);for(let o of this.sessionQueues.values())o.dispose(s);this.sessionQueues.clear(),await this.killAllRuntimes(e??"dispose")}async killAllRuntimes(e){let s=[];for(let[,o]of this.sessions)tn(o),o.downstream&&(s.push(o.downstream.stop(e).catch(()=>{})),o.downstream=void 0);await Promise.all(s),this.activeTriggers.clear()}};function tn(n){n.idleTimer&&(clearTimeout(n.idleTimer),n.idleTimer=void 0)}import{spawn as ad}from"node:child_process";import{homedir as cd}from"node:os";import{join as xd}from"node:path";An();U();async function uo(){let n=xd(cd(),".openclaw/openclaw.json");return(await Et(n))?.gateway?.auth?.token??""}var co=D("openclaw.config"),dd=[0,5e3,5e3],xo="models.providers.",Kn="agents.defaults.models",Gn=class{command;env;retryDelaysMs;queue=new Dt;constructor(e){this.command=e.command,this.env=e.env??process.env,this.retryDelaysMs=e.retryDelaysMs??dd}async withRetry(e,s){let o;for(let c=0;c<this.retryDelaysMs.length;c++){let d=this.retryDelaysMs[c]??0;d>0&&await new Promise(u=>setTimeout(u,d));try{return await s()}catch(u){o=u,co.warn("openclaw cli failed, will retry",{label:e,attempt:c+1,err:String(u)})}}throw new S("AGENT_SPAWN_FAILED",`openclaw cli ${e} failed after ${this.retryDelaysMs.length} attempts: ${o?.message??"unknown"}`)}runCli(e){return new Promise((s,o)=>{let c=ad(this.command,e,{stdio:["ignore","pipe","pipe"],env:this.env}),d="";c.stderr?.on("data",u=>{d+=u.toString("utf8")}),c.on("error",o),c.on("close",u=>{u===0?s():o(new Error(`exit ${u}: ${d.trim().slice(0,500)}`))})})}async runCliTolerant(e,s){try{await this.runCli(e)}catch(o){let c=String(o);if(s.some(d=>c.includes(d)))return;throw o}}async bestEffortUnset(e,s){try{await this.queue.enqueue(()=>this.withRetry(e,()=>this.runCli(["config","unset",s])))}catch(o){co.warn(`${e} failed (best-effort)`,{configPath:s,err:String(o)})}}ensureProvider(e,s){return this.queue.enqueue(()=>this.withRetry(`config set models.providers.${e}`,()=>this.runCli(["config","set",`${xo}${e}`,JSON.stringify(s),"--strict-json","--merge"])))}removeProvider(e){return this.bestEffortUnset(`config unset models.providers.${e}`,`${xo}${e}`)}addModelToAllowlist(e,s){let o={[e]:s?{alias:s}:{}};return this.queue.enqueue(()=>this.withRetry(`config set ${Kn}[${e}]`,()=>this.runCli(["config","set",Kn,JSON.stringify(o),"--strict-json","--merge"])))}removeModelFromAllowlist(e){return this.bestEffortUnset(`config unset ${Kn}[${e}]`,`${Kn}.${e}`)}ensureAgent(e,s,o){let c=["agents","add",e,"--workspace",s,"--non-interactive"];return o&&c.push("--model",o),this.queue.enqueue(()=>this.withRetry(`agents add ${e}`,()=>this.runCliTolerant(c,["already exists","already registered"])))}deleteAgent(e){return this.queue.enqueue(()=>this.withRetry(`agents delete ${e}`,()=>this.runCliTolerant(["agents","delete",e,"--force"],["not found","does not exist"])))}};var Se=D("agent-manager"),fd=(n,e,s,o,c,d,u,l)=>{switch(n){case"claude-code":{let p={...c?{...Fs(c),...Hs(c,u)}:{},...l??{}};return new qn({cwd:s,...Object.keys(p).length>0?{env:p}:{}})}case"codex":{let p=c?[...Us(c),...Ks(c,u),"-c",'sandbox_mode="danger-full-access"',"-c",'approval_policy="never"']:[],m={...c?qs(c):{},...l??{}},_=!!c;return new Hn({cwd:s,...p.length>0?{extraArgs:p}:{},...Object.keys(m).length>0?{env:m}:{},..._?{authMethodId:"openai-api-key",isolateCodexHome:!0}:{}})}case"openclaw":return new Tt({command:e,cwd:s,agentId:o,...d?{sessionName:ti(d)}:{}})}};function fo(n){return n==="claude-code"||n==="codex"}var ld={path:"",version:"cloud-deployed"},gd={protocolVersion:1,clientCapabilities:{fs:{readTextFile:!0,writeTextFile:!0}}},hd=6e4,Wn=class{paths;config;registry;factory;createTimeoutMs;openclawConfigCache;ensuredProviders=new Set;constructor(e){this.paths=e.paths,this.config=e.config,this.registry=e.registry,this.factory=e.downstreamFactory??fd,this.createTimeoutMs=e.createTimeoutMs??hd}buildBinShimPathEnv(){let e=process.platform==="win32"?";":":";return{PATH:`${this.paths.binDir}${e}${process.env.PATH??""}`}}getOpenclawConfig(){if(!this.openclawConfigCache){let e=this.config.frameworksCache?.openclaw;if(!e?.path)throw new S("AGENT_SPAWN_FAILED","openclaw binary not detected on this machine");this.openclawConfigCache=new Gn({command:e.path})}return this.openclawConfigCache}async createAgent(e){if(!e.agentId)throw new S("IPC_BAD_REQUEST","agentId required");if(!e.framework)throw new S("IPC_BAD_REQUEST","framework required");let s=Jt(e._meta)==="cloud";this.registry.reviveIfDisconnected?.(e.agentId);let o=this.registry.get(e.agentId);if(o){if(o.framework!==e.framework)throw new S("AGENT_BUSY",`agent ${e.agentId} exists with different framework (${o.framework})`);if(o.status==="error")Se.warn("existing agent in error state, rebuilding",{agentId:e.agentId}),await o.dispose("rebuild after error").catch(T=>Se.warn("dispose stale agent failed (ignored)",{err:String(T)})),this.registry.unregister(e.agentId);else{if(e.patToken&&e.patToken!==o.patToken){Se.info("updating agent patToken on re-create (reconnect with new PAT)",{agentId:e.agentId}),o.setPatToken(e.patToken);let T=await me(e.agentId,this.paths).catch(()=>null);T&&(T.patToken=e.patToken,await Ce(T,this.paths))}return Se.info("agent already exists, return current",{agentId:e.agentId}),{ok:!0,agentId:o.agentId,workspace:o.workspace,framework:o.framework}}}if(!s&&!this.config.frameworksCache?.[e.framework])throw new S("AGENT_SPAWN_FAILED",`framework ${e.framework} not detected on this machine; rerun daemon to refresh frameworks_cache`);let d=Ge(e.agentId,this.paths),u=Jt(e._meta),l=e.framework==="openclaw"&&u==="local",p=l?this.config.frameworksCache?.openclaw?.defaultAgent?.workspace:void 0,m=e.workspace??p??d.workspace,_=new AbortController,y=setTimeout(()=>_.abort(new S("AGENT_TIMEOUT",`_agent/create timed out after ${this.createTimeoutMs}ms`)),this.createTimeoutMs),I,L=!1;try{s&&fo(e.framework)&&await Sn(e.framework,_.signal);let T=()=>{if(_.signal.aborted)throw _.signal.reason instanceof Error?_.signal.reason:new S("AGENT_TIMEOUT","_agent/create aborted")};await ni(d.root,{recursive:!0}),await ni(m,{recursive:!0}),await ni(d.logs,{recursive:!0}),T(),l||await It(m,e.framework,e.agentId,e.cozeIdentity),s&&e.framework==="claude-code"&&await Ps(m),T();let P=await me(e.agentId,this.paths).catch(()=>null),j=Bs({model:e.model??P?.model}),Q=ks(e._meta)??P?.accountId,K=e.patToken??P?.patToken;if(I=new jn({agentId:e.agentId,framework:e.framework,workspace:m,model:j.model??Ne,deployType:u,...Q?{accountId:Q}:{},...K?{patToken:K}:{}}),I.status="ok",P?.sessions){for(let[Te,pe]of Object.entries(P.sessions))I.sessions.set(Te,{acpSessionId:pe.acpSessionId,modelToken:pe.modelToken,tokenGeneratedAt:pe.tokenGeneratedAt,lastActiveAt:Date.now(),loadingSession:!1,replySeq:0});let oe=Object.keys(P.sessions).length;oe>0&&Se.info("restored persisted session records (no spawn)",{agentId:e.agentId,count:oe})}this.registry.register(I),L=!0;let $={agentId:e.agentId,framework:e.framework,workspace:m,cozeIdentity:e.cozeIdentity,createdAt:P?.createdAt??Date.now(),sessions:P?.sessions??{},model:j.model};u==="cloud"&&($.deployType="cloud"),Q&&($.accountId=Q),K&&($.patToken=K),P?.skills&&($.skills=P.skills),P?.agentName&&($.agentName=P.agentName),P?.description&&($.description=P.description),e.framework==="openclaw"&&u==="cloud"&&(this.config.frameworksCache?.openclaw?.path?await this.getOpenclawConfig().ensureAgent(e.agentId,m):Se.warn("openclaw binary not on this machine, skip agents add (will fail at session/prompt)",{agentId:e.agentId}));let se=e.initialSkills??[];if(se.length>0){let oe=[...$.skills??[]],Te=new Map(oe.map((xe,de)=>[xe.skillId,de])),pe=0;for(let xe of se)try{let de=await Zr({agentId:e.agentId,workspace:m,framework:e.framework,skill:xe});ei(oe,Te,de),pe++}catch(de){Se.warn("initialSkill install failed (skipping)",{agentId:e.agentId,skillId:xe.skillId,skillName:xe.skillName,err:String(de)})}pe>0&&($.skills=oe,Se.info("initialSkills installed",{agentId:e.agentId,installed:pe,requested:se.length}))}return await Ce($,this.paths),Se.info("agent created (no spawn, lazy on first prompt)",{agentId:e.agentId,framework:e.framework,deployType:u}),{ok:!0,agentId:e.agentId,workspace:m,framework:e.framework}}catch(T){throw Se.error("agent create failed, rolling back",{agentId:e.agentId,err:String(T)}),L&&I&&(await I.dispose("rollback").catch(()=>{}),this.registry.unregister(e.agentId)),await ud(d.root,{recursive:!0,force:!0}).catch(P=>Se.warn("rm agent dir failed (ignored)",{err:String(P)})),T instanceof S?T:new S("AGENT_SPAWN_FAILED",String(T),{cause:T})}finally{clearTimeout(y)}}async spawnSessionDownstream(e,s,o,c){let u=this.config.frameworksCache?.[e.framework];if(!u)if(e.deployType==="cloud"&&fo(e.framework))u=ld;else throw new S("AGENT_SPAWN_FAILED",`framework ${e.framework} not detected on this machine`);let l=e.deployType==="cloud"?{model:e.model,modelToken:s}:void 0,p;e.framework==="openclaw"?p=await this.buildOpenclawDownstream({session:e,modelConfig:l,cloudSessionId:o,cozeEnv:c,command:u.path}):p=this.factory(e.framework,u.path,e.workspace,e.agentId,l,o,c,this.buildBinShimPathEnv());try{return await p.start(),await p.initialize(gd),p}catch(m){throw await p.stop("spawnSessionDownstream failed").catch(()=>{}),m instanceof S?m:new S("AGENT_SPAWN_FAILED",m instanceof Error?m.message:String(m),{cause:m})}}async buildOpenclawDownstream(e){let{session:s,modelConfig:o,cloudSessionId:c,cozeEnv:d,command:u}=e,l=ti(c);if(s.deployType==="local"){let y=this.config.frameworksCache?.openclaw?.defaultAgent;if(!y?.id||!y.workspace)throw new S("AGENT_SPAWN_FAILED","openclaw default agent \u672A\u63A2\u6D4B\u5230; \u8BF7\u5148\u8DD1 `openclaw setup` \u6216 `openclaw agents add` \u521B\u5EFA\u9ED8\u8BA4 agent");return new Tt({command:u,cwd:y.workspace,agentId:y.id,sessionName:l})}let p=await uo(),m=o?js(o,d):null,_;if(m){let y=Xr(c),L=m.models[0]?.id??Ne,T=`${y}/${L}`;if(!this.ensuredProviders.has(T)){let P=this.getOpenclawConfig();await P.ensureProvider(y,m),await P.addModelToAllowlist(T),this.ensuredProviders.add(T)}_=T}return new Tt({command:u,cwd:s.workspace,agentId:s.agentId,sessionName:l,...p?{gatewayToken:p}:{},..._?{slashModelOnStart:_}:{}})}async openclawRepair(e,s){let o=this.getOpenclawConfig();await o.deleteAgent(e),await o.ensureAgent(e,s)}async cleanupOpenclawSessionProviders(e){if(e.framework!=="openclaw"||!this.openclawConfigCache)return;let s=this.openclawConfigCache;for(let o of e.sessions.keys()){let c=Xr(o),d=`${c}/${e.model}`,u=!0;try{await s.removeProvider(c)}catch(l){u=!1,Se.warn("removeProvider failed, keeping ensuredProviders entry",{providerId:c,err:String(l)})}try{await s.removeModelFromAllowlist(d)}catch(l){u=!1,Se.warn("removeModelFromAllowlist failed, keeping ensuredProviders entry",{fullModelId:d,err:String(l)})}u&&this.ensuredProviders.delete(d)}}};import{randomUUID as Ad}from"node:crypto";import{promises as Cd}from"node:fs";import{basename as Pd}from"node:path";import{promises as md}from"node:fs";import{basename as wd}from"node:path";U();var lo=D("file-upload"),_d="/api/coze_claw/file/agent_upload",yd=6e4;async function go(n,e={}){let o=`${Rn(On(e.handshakeBase))}${_d}`,c=e.timeoutMs??yd,d=await md.readFile(n.path),u=new FormData;u.append("agent_id",n.agentId),u.append("session_id",n.sessionId),u.append("file_name",n.name),u.append("file_content",new Blob([d],{type:n.mimeType}),n.name);let l={Authorization:`Bearer ${n.patToken}`,Accept:"application/json","x-coze-version":"3.0",...Ct(e.ppeOverride),...n.accountId?{"x-coze-account":n.accountId}:{}},p=new AbortController,m=setTimeout(()=>p.abort(),c);lo.info("file upload start",{url:o,agentId:n.agentId,sessionId:n.sessionId,name:n.name,bytes:n.sizeBytes,mime:n.mimeType});try{let _=await fetch(o,{method:"POST",headers:l,body:u,signal:p.signal}),y=_.headers.get("x-tt-logid")??"";if(!_.ok){let T=await _.text().catch(()=>"");throw new S("UPLOAD_FAILED",`upload HTTP ${_.status} logid=${y}: ${T.slice(0,200)}`)}let I=await _.json();if(I.code!==void 0&&I.code!==0)throw new S("UPLOAD_FAILED",`upload code=${I.code} msg=${I.msg??"-"} logid=${y}`);let L=I.data?.file?.file_url;if(!L)throw new S("UPLOAD_FAILED",`upload response missing data.file.file_url logid=${y}: ${JSON.stringify(I).slice(0,200)}`);return lo.info("file upload ok",{uri:L,logid:y}),{uri:L}}catch(_){throw _ instanceof S?_:_.name==="AbortError"?new S("UPLOAD_FAILED",`upload timeout (${c}ms) for ${wd(n.path)}`):new S("UPLOAD_FAILED",String(_),{cause:_})}finally{clearTimeout(m)}}U();import{promises as bd}from"node:fs";import{extname as vd}from"node:path";var Sd=[{mime:"image/png",prefix:[137,80,78,71]},{mime:"image/jpeg",prefix:[255,216,255]},{mime:"image/gif",prefix:[71,73,70,56]},{mime:"application/pdf",prefix:[37,80,68,70]}];function Ed(n){return n[0]===82&&n[1]===73&&n[2]===70&&n[3]===70&&n[8]===87&&n[9]===69&&n[10]===66&&n[11]===80}var Id={".txt":"text/plain",".md":"text/markdown",".svg":"image/svg+xml",".json":"application/json"};async function ho(n){let e=await bd.open(n,"r");try{let s=Buffer.alloc(16);if(await e.read(s,0,16,0),Ed(s))return"image/webp";for(let o of Sd)if(o.prefix.every((c,d)=>s[d]===c))return o.mime}finally{await e.close()}return Id[vd(n).toLowerCase()]??"application/octet-stream"}ie();var po=D("agent-send"),mo=50*1024*1024,kd=new Set(["image/png","image/jpeg","image/webp","image/gif","image/svg+xml","application/pdf","application/json","text/plain","text/markdown"]);async function wo(n,e){let s=e.core.get(n.agentId);if(!s)throw new S("AGENT_NOT_FOUND",`agent=${n.agentId}`);if(e.core.disconnectedAgents.has(n.agentId))throw new S("AGENT_DISCONNECTED",`agent=${n.agentId} was disconnected by cloud`);if(s.deployType!=="cloud")throw new S("IPC_BAD_REQUEST",`agent=${n.agentId} is not a cloud agent (deployType=${s.deployType}); send only available for cloud agents`);let o=s.sessions.get(n.sessionId);if(!o)throw new S("AGENT_NOT_FOUND",`session=${n.sessionId} not active in agent=${n.agentId}`);if(!await Es(n.path,s.workspace))throw new S("PATH_OUTSIDE_WORKSPACE",`path=${n.path} not under workspace=${s.workspace}`);let c=await Cd.stat(n.path).catch(()=>null);if(!c||!c.isFile())throw new S("IPC_BAD_REQUEST",`path is not a regular file: ${n.path}`);if(c.size>mo)throw new S("FILE_TOO_LARGE",`${c.size} bytes > limit ${mo}`);let d=await ho(n.path);if(!kd.has(d))throw new S("UNSUPPORTED_MIME",`mime=${d} not in whitelist`);if(n.kind==="image"&&!d.startsWith("image/"))throw new S("UNSUPPORTED_MIME",`kind=image but mime=${d}`);if(!e.core.upstream.isConnected())throw new S("UPSTREAM_NOT_READY","cloud WS not connected");let u=n.name??Pd(n.path),l=await go({patToken:e.patToken,agentId:n.agentId,sessionId:n.sessionId,path:n.path,mimeType:d,name:u,sizeBytes:c.size,...s.accountId?{accountId:s.accountId}:{}},{handshakeBase:e.handshakeBase,ppeOverride:e.ppeOverride}),p={sessionUpdate:"agent_file",messageId:Ad(),content:{type:n.kind==="image"?"image":"resource",uri:l.uri,mimeType:d,name:u,sizeBytes:c.size,...l.fileId!==void 0?{fileId:l.fileId}:{},...n.caption!==void 0?{caption:n.caption}:{}}},m=2,_;for(let y=0;y<=m;y++)try{await e.core.sendAgentFileUpdate(s,o,n.sessionId,p),_=void 0;break}catch(I){_=I,y<m&&(po.warn("sendAgentFileUpdate failed, retrying",{attempt:y+1,err:String(I)}),await new Promise(L=>setTimeout(L,5e3)))}if(_)throw new S("UPSTREAM_NOT_READY",`agent file uploaded to cloud but sendAgentFileUpdate failed after ${m+1} attempts: ${String(_)}`,{cause:_});return po.info("agent file sent",{agentId:n.agentId,sessionId:n.sessionId,kind:n.kind,name:u,bytes:c.size,mime:d,uri:l.uri}),{ok:!0,uri:l.uri,bytes:c.size,mimeType:d,...l.fileId!==void 0?{fileId:l.fileId}:{}}}U();import{execFile as Td}from"node:child_process";import{promisify as Dd}from"node:util";var Rd=Dd(Td),ot=D("coze-cli-installer"),_o="@coze/cli@0.1.3-alpha.89c42a",yo="https://bnpm.byted.org",Ld="coze",Od=5e3,Nd=9e4,bo=1e4,nn=null,ri=!1;async function ii(n,e={}){if(ri)return;if(nn)return nn;let s=e.exec??Rd;return nn=(async()=>{try{let o=await Md(Ld,s);if(o){ot.info("coze-cli already on PATH, skip install + config + auth",{path:o}),ri=!0;return}ot.info("coze-cli install start",{package:_o,registry:yo});try{await s("npm",["i","-g",_o,"--registry",yo],{timeout:Nd,maxBuffer:10*1024*1024}),ot.info("coze-cli install ok")}catch(c){ot.warn("coze-cli install failed (skip subsequent steps)",{err:String(c)});return}if(n.env)try{await s("coze",["config","set","xTTEnv",n.env],{timeout:bo}),ot.info("coze config set xTTEnv ok",{env:n.env})}catch(c){ot.warn("coze config set failed (continue to auth login)",{err:String(c)})}try{await s("coze",["auth","login","--token",n.patToken],{timeout:bo}),ot.info("coze auth login ok")}catch(c){ot.warn("coze auth login failed",{err:String(c)});return}ri=!0}finally{nn=null}})(),nn}async function Md(n,e){let s=process.platform==="win32"?"where":"which";try{let{stdout:o}=await e(s,[n],{timeout:Od});return o.split(`
|
|
120
|
+
`)[0]?.trim()||void 0}catch{return}}U();import{spawn as Bd}from"node:child_process";import{constants as vo,access as zd}from"node:fs/promises";import{delimiter as Fd,join as Ud}from"node:path";var So=D("framework-detector"),Eo={"claude-code":"claude",codex:"codex",openclaw:"openclaw"},qd=[".exe",".cmd",".bat",".ps1"],Rt=class{env;constructor(e={}){this.env={pathEnv:e.pathEnv??process.env.PATH??"",platform:e.platform??process.platform,spawn:e.spawn??Bd,access:e.access??zd}}async detect(e){let s=Eo[e],o=await this.which(s);if(!o)return So.debug("framework binary not found",{framework:e,bin:s}),null;let c=e==="openclaw"?["--log-level","silent"]:[],[d,u]=await Promise.all([this.probeVersion(o,c),e==="openclaw"?this.probeOpenclawDefaultAgent(o):Promise.resolve(null)]),l={path:o,version:d};return u&&(l.defaultAgent=u),l}async detectAll(){let e=await Promise.all(Object.keys(Eo).map(async o=>[o,await this.detect(o)])),s={};for(let[o,c]of e)c&&(s[o]=c);return s}async which(e){let s=this.env.pathEnv.split(Fd).filter(Boolean),o=this.env.platform==="win32"?["",...qd]:[""];for(let c of s)for(let d of o){let u=Ud(c,e+d);if(await this.isExecutable(u))return u}return null}async isExecutable(e){try{let s=this.env.platform==="win32"?vo.F_OK:vo.X_OK;return await this.env.access(e,s),!0}catch{return!1}}async probeOpenclawDefaultAgent(e){let s=await this.runProbe(e,["--log-level","silent","agents","list","--json"]);if(!s||s.code!==0)return null;try{let o=JSON.parse(s.stdout);if(!Array.isArray(o))return null;let c=o.find(d=>d?.isDefault===!0);return!c?.id||!c.workspace?null:{id:c.id,workspace:c.workspace}}catch(o){return So.warn("openclaw agents list --json parse failed",{err:String(o)}),null}}async probeVersion(e,s=[]){let o=await this.runProbe(e,[...s,"--version"]);return o&&(jd(o.stdout).split(/\r?\n/)[0]??"").trim()||"unknown"}runProbe(e,s){return new Promise(o=>{let c="",d=!1,u,l=p=>{d||(d=!0,u&&clearTimeout(u),o(p))};try{let p=this.env.spawn(e,s,{stdio:["ignore","pipe","pipe"]});u=setTimeout(()=>{p.kill("SIGKILL"),l(null)},5e3),p.stdout?.on("data",m=>{c+=m.toString("utf8")}),p.on("error",()=>l(null)),p.on("close",m=>l({code:m,stdout:c}))}catch{l(null)}})}},Hd=new RegExp("\x1B\\[[0-9;]*[A-Za-z]","g");function jd(n){return n.replace(Hd,"")}Lt();import{randomBytes as cu}from"node:crypto";import{createReadStream as Gd}from"node:fs";import{mkdir as Wd,readFile as Jd,realpath as $d,stat as Vd,writeFile as Yd}from"node:fs/promises";import{basename as Xd,dirname as si,join as Qd,relative as Zd,resolve as Ao,sep as eu}from"node:path";import{createInterface as tu}from"node:readline";U();var Po=D("fs-rpc"),rn=Un("COZE_BRIDGE_FS_RPC_MAX_BYTES",20*1024*1024);async function ko(n,e){let s=Buffer.byteLength(n.content,"utf8");if(s>rn)throw new S("IPC_BAD_REQUEST",`fs/write_text_file content too large: ${s} bytes > limit ${rn} bytes`);let o=await Do(n.path,e);return await Wd(si(o),{recursive:!0}),await Yd(o,n.content,"utf8"),Po.info("fs/write_text_file ok",{path:o,size:n.content.length}),null}async function To(n,e){let s=await Do(n.path,e),o=await Vd(s),c=typeof n.line=="number"||typeof n.limit=="number";if(o.size>rn&&!c)throw new S("IPC_BAD_REQUEST",`fs/read_text_file too large without line/limit slicing: ${o.size} bytes > ${rn} bytes`);let d;if(c&&o.size>rn)d=await nu(s,n.line??1,n.limit);else{let u=await Jd(s,"utf8");if(c){let l=u.split(`
|
|
121
|
+
`),p=Math.max(0,(n.line??1)-1),m=typeof n.limit=="number"?p+n.limit:void 0;d=l.slice(p,m).join(`
|
|
122
|
+
`)}else d=u}return Po.info("fs/read_text_file ok",{path:s,size:d.length}),{content:d}}async function nu(n,e,s){let o=tu({input:Gd(n,{encoding:"utf8"}),crlfDelay:Number.POSITIVE_INFINITY}),c=Math.max(0,e-1),d=typeof s=="number"?c+s:Number.POSITIVE_INFINITY,u=[],l=0;try{for await(let p of o)if(l>=c&&l<d&&u.push(p),l++,l>=d)break}finally{o.close()}return u.join(`
|
|
123
|
+
`)}async function Do(n,e){if(typeof n!="string"||n.length===0)throw new S("IPC_BAD_REQUEST","path must be a non-empty string");let[s,o]=await Promise.all([Co(Ao(e)),Co(Ao(n))]),c=Zd(s,o);if(c.startsWith("..")||c===".."||c.startsWith(`..${eu}`))throw new S("IPC_BAD_REQUEST",`path escapes workspace: ${n}`);return o}async function Co(n){let e=[],s=n;for(;s!==si(s);)try{let o=await $d(s);return e.length?Qd(o,...e.reverse()):o}catch{e.push(Xd(s)),s=si(s)}return n}U();var Ro=D("prompt-multimodal"),Lo=10*1024*1024,ru=15e3,iu=6;async function Oo(n){let e=new Array(n.length),s=0;async function o(){for(;s<n.length;){let d=s++,u=n[d];u!==void 0&&(e[d]=await su(u))}}let c=Array.from({length:Math.min(iu,n.length)},()=>o());return await Promise.all(c),e}async function su(n){if(n.type!=="image")return n;let e=n;if(e.data||!e.uri||!Dn(e.uri))return n;try{let{buf:s,contentType:o}=await au(e.uri),c=e.mimeType||ou(o)||"application/octet-stream";return Ro.info("image uri fetched and inlined",{uri:e.uri,bytes:s.length,mimeType:c}),{type:"image",data:s.toString("base64"),mimeType:c}}catch(s){return Ro.warn("image fetch failed, degrading to text block",{uri:e.uri,err:String(s)}),{type:"text",text:`[image load failed: ${e.uri}]`}}}function ou(n){if(!n)return;let e=n.indexOf(";");return(e===-1?n:n.slice(0,e)).trim()||void 0}async function au(n){let e=new AbortController,s=setTimeout(()=>e.abort(),ru);try{let o=await fetch(n,{signal:e.signal});if(!o.ok)throw new Error(`HTTP ${o.status} ${o.statusText}`);let c=await o.arrayBuffer();if(c.byteLength>Lo)throw new Error(`image too large: ${c.byteLength} bytes (max ${Lo})`);return{buf:Buffer.from(c),contentType:o.headers.get("content-type")??void 0}}finally{clearTimeout(s)}}nt();Lt();U();var B=D("core"),xu=3e4,du=/^(boe|ppe)_[A-Za-z0-9_-]+$/,uu=3e4,fu=new Set(["_agent/create","session/new","session/load","session/prompt"]),Jn=class{upstream;agents=new Map;disconnectedAgents=new Set;extensions;paths;sessionSpawner;sessionIdleTimeoutMs;upgradeGate;upstreamIds=new kt;pendingUpstream=new Map;pendingBridge=new Map;currentCozeEnv;constructor(e){this.upstream=e.upstream,this.extensions=e.extensions??{},this.paths=e.paths,this.sessionSpawner=e.sessionSpawner,this.sessionIdleTimeoutMs=Io(e.bridgeConfig),this.upgradeGate=e.upgradeGate}registerExtension(e,s){this.extensions[e]=s}getCozeEnv(){return this.currentCozeEnv}async start(){this.upstream.onFrame(e=>this.handleFrame(e)),this.upstream.onConnect?.(({initial:e})=>{e||this.rejectAllPendingOnReconnect()}),await this.upstream.start(),B.info("Core started",{extensions:Object.keys(this.extensions)})}async stop(e){B.info("Core stopping",{reason:e}),await Promise.all([...this.agents.values()].map(s=>s.dispose(e))),this.agents.clear(),await this.upstream.stop(e)}get(e){return this.agents.get(e)}register(e){this.agents.set(e.agentId,e),B.info("agent registered",{agentId:e.agentId,framework:e.framework});for(let s of this.registerHandlers)try{s(e.agentId)}catch(o){B.warn("onAgentRegister handler threw (ignored)",{agentId:e.agentId,err:String(o)})}}onAgentRegister(e){return this.registerHandlers.add(e),()=>this.registerHandlers.delete(e)}registerHandlers=new Set;unregister(e){this.agents.delete(e)}reviveIfDisconnected(e){this.disconnectedAgents.delete(e)&&B.info("agent revived from disconnect",{agentId:e})}attachRuntimeHooks(e,s,o){let c=o.downstream;c&&(c.onUpdate(d=>{o.loadingSession||this.forwardUpdate(e,d)}),c.onAgentRequest(d=>{this.handleAgentRequest(e,c,d)}),c.onExit((d,u)=>{B.info("session runtime exited",{agentId:e.agentId,cloudId:s,code:d,signal:u}),tn(o),o.downstream=void 0,o.replySeq=0,o.acpSessionId&&e.activeTriggers.delete(o.acpSessionId),this.rejectPendingForDownstream(c,"downstream exited")}))}hasPendingPermissionFor(e){for(let s of this.pendingUpstream.values())if(s.downstream===e)return!0;return!1}rejectPendingForDownstream(e,s){let o=[];for(let[c,d]of this.pendingUpstream)d.downstream===e&&o.push(c);if(o.length!==0){B.info("reject pendingUpstream entries (downstream gone)",{reason:s,count:o.length});for(let c of o){let d=this.pendingUpstream.get(c);if(d){this.pendingUpstream.delete(c),this.upstream.send(it(c,{code:H.INTERNAL_ERROR,message:`bridge downstream gone: ${s}`})).catch(u=>B.debug("send error response to upstream failed (ignored)",{err:String(u)}));try{d.downstream.respondAgentRequestError(d.agentRequestId,{code:H.INTERNAL_ERROR,message:`bridge: ${s}`})}catch{}}}}}rejectAllPendingOnReconnect(){let e=this.pendingUpstream.size,s=this.pendingBridge.size;if(!(e===0&&s===0)){B.warn("upstream reconnected, rejecting stale pending requests",{pendingUpstream:e,pendingBridge:s});for(let[,o]of this.pendingUpstream)try{o.downstream.respondAgentRequestError(o.agentRequestId,{code:H.INTERNAL_ERROR,message:"upstream reconnected; please retry"})}catch{}this.pendingUpstream.clear();for(let[,o]of this.pendingBridge)clearTimeout(o.timer),o.reject(new S("UPSTREAM_DISCONNECTED",`${o.method} aborted: upstream reconnected`));this.pendingBridge.clear()}}async handleFrame(e){if(zn(e)){this.handleUpstreamResponse(e);return}if(!("method"in e)||typeof e.method!="string")return;let s="id"in e&&e.id!==void 0?e.id:null,o=e.params?._meta?.cozeEnv;o&&du.test(o)?this.currentCozeEnv=o:o&&B.warn("rejecting cozeEnv with invalid shape, keeping previous",{rejected:o});try{if(this.upgradeGate?.isUpgrading()&&fu.has(e.method)){let c=this.upgradeGate.pendingTarget()??"";throw new S("BRIDGE_UPGRADING",`bridge upgrading to ${c}, retry shortly`,{retriable:!0})}if(e.method.startsWith("_agent/")){let c=this.extensions[e.method];if(!c){s!==null?await this.sendError(s,H.METHOD_NOT_FOUND,`extension not registered: ${e.method}`):B.warn("drop notification: extension not registered",{method:e.method});return}let d=await c(e,this);s!==null&&await this.upstream.send(Pt(s,d));return}if(e.method.startsWith("session/")){let c=await this.routeSessionMethod(e);s!==null&&await this.upstream.send(Pt(s,c));return}if(e.method==="initialize"){s!==null&&await this.upstream.send(Pt(s,{protocolVersion:1,agentCapabilities:{loadSession:!0}}));return}s!==null?await this.sendError(s,H.METHOD_NOT_FOUND,`method not implemented: ${e.method}`):B.warn("drop unknown notification",{method:e.method})}catch(c){B.error("handleFrame failed",{method:e.method,err:String(c)}),s!==null&&await this.upstream.send(it(s,en(c)))}}async routeSessionMethod(e){if(!e.params||typeof e.params!="object")throw new S("IPC_BAD_REQUEST",`${e.method} requires params`);let s=e.params,o=s._meta?.cozeAgentId;if(!o)throw new S("IPC_BAD_REQUEST",`${e.method}: missing _meta.cozeAgentId`);let c=this.agents.get(o);if(!c)throw this.disconnectedAgents.has(o)?new S("AGENT_DISCONNECTED",`agent ${o} has been disconnected; cloud must _agent/create to revive`):new S("AGENT_NOT_FOUND",`agent not found: ${o}`);let d=typeof s.sessionId=="string"?s.sessionId:void 0;if(e.method==="session/cancel"||e.method==="session/new"||!d)return this.dispatchSessionCall(c,e.method,s);let u=Date.now(),l=!1,p=e.method==="session/prompt";p&&this.upgradeGate?.incActive();try{let m=await c.getSessionQueue(d).enqueue(()=>this.dispatchSessionCall(c,e.method,s));return l=!0,m}finally{p&&this.upgradeGate?.decActive(),B.info("session call done",{agentId:c.agentId,method:e.method,durationMs:Date.now()-u,ok:l})}}async dispatchSessionCall(e,s,o){e.lastActiveAt=Date.now();let{stripped:c}=Ts(o);switch(s){case"session/new":{let d=lu();return B.info("session/new ack (lazy spawn)",{agentId:e.agentId,cloudId:d}),{sessionId:d}}case"session/load":{let d=c;return B.info("session/load ack (lazy spawn)",{agentId:e.agentId,cloudId:d.sessionId}),{}}case"session/prompt":{let d=c,u=d.sessionId;if(!u)throw new S("IPC_BAD_REQUEST","session/prompt: missing sessionId");let l=await this.ensureRuntime(e,u);if(l.replySeq=0,await this.ensureDownstream(e,u,l),!l.downstream||!l.acpSessionId)throw new S("BRIDGE_INTERNAL","session runtime not ready after ensureDownstream");let p=o._meta?.cozeTriggerMsgId;p?e.activeTriggers.set(l.acpSessionId,p):e.activeTriggers.delete(l.acpSessionId);let m=await Oo(d.prompt);try{let _=await l.downstream.sessionPrompt({...d,sessionId:l.acpSessionId,prompt:m});return l.lastActiveAt=Date.now(),_}finally{if(e.activeTriggers.delete(l.acpSessionId),l.reloadAfterTurn){l.reloadAfterTurn=!1;let _=l.downstream;_&&(l.downstream=void 0,B.info("reloadAfterTurn: stopping downstream",{agentId:e.agentId,cloudId:u,acpId:l.acpSessionId}),_.stop("reload-after-turn").catch(y=>B.warn("reload-after-turn stop failed (ignored)",{agentId:e.agentId,cloudId:u,err:String(y)})))}else l.downstream?.isAlive()&&this.armIdleTimer(e,u,l)}}case"session/cancel":{let u=c.sessionId;if(!u)throw new S("IPC_BAD_REQUEST","session/cancel: missing sessionId");let l=e.sessions.get(u);if(e.hasSessionQueue(u)){let p=e.getSessionQueue(u);p.size>0&&(B.info("session/cancel: draining queued tasks",{agentId:e.agentId,cloudId:u,queuedCount:p.size}),p.dispose(new S("AGENT_PROTOCOL_ERROR",`cancelled by session/cancel on ${u}`)))}return l?.downstream?.isAlive()&&l.acpSessionId&&await l.downstream.sessionCancel({sessionId:l.acpSessionId}),{ok:!0}}default:throw new S("IPC_BAD_REQUEST",`session method not supported: ${s}`)}}async ensureRuntime(e,s){let o=e.sessions.get(s);if(o)return o;let d={modelToken:e.deployType==="cloud"?await this.requestSessionToken(e.agentId,s):"",tokenGeneratedAt:Date.now(),lastActiveAt:Date.now(),loadingSession:!1,replySeq:0};return e.sessions.set(s,d),await this.persistSessionMapping(e),d}async requestSessionToken(e,s){let o={sessionId:s,_meta:{cozeAgentId:e}};try{let c=await this.sendRequest(Oe.GEN_MODEL_TOKEN,o,uu);if(!c?.modelToken)throw new S("MODEL_TOKEN_GEN_FAILED",`cloud returned empty modelToken (agentId=${e}, cloudSessionId=${s})`);return c.modelToken}catch(c){throw c instanceof S&&c.code==="MODEL_TOKEN_GEN_FAILED"?c:new S("MODEL_TOKEN_GEN_FAILED",c instanceof Error?c.message:String(c),{cause:c})}}async ensureDownstream(e,s,o){if(tn(o),o.downstream?.isAlive())return;if(!this.sessionSpawner)throw new S("AGENT_SPAWN_FAILED","sessionSpawner not wired (cannot spawn per-session downstream)");let c=3,d=3e4,u=o.spawnFailCount??0,l=o.spawnFailedAt??0;if(u>=c&&Date.now()-l<d)throw new S("AGENT_SPAWN_FAILED",`agent ${e.agentId} session ${s} spawn failed ${u} times in a row; please check framework binary / network and retry after ${Math.ceil((d-(Date.now()-l))/1e3)}s`);let p;try{p=await this.sessionSpawner(e,o.modelToken,s,this.currentCozeEnv)}catch(m){throw o.spawnFailCount=u+1,o.spawnFailedAt=Date.now(),o.spawnFailCount>=c&&o.acpSessionId&&(B.warn("clearing stale acpSessionId after repeated spawn failures",{agentId:e.agentId,cloudId:s,staleAcpId:o.acpSessionId}),o.acpSessionId=void 0),m}if(o.spawnFailCount=0,o.spawnFailedAt=void 0,o.downstream=p,this.attachRuntimeHooks(e,s,o),o.acpSessionId){o.loadingSession=!0;try{await p.sessionLoad({sessionId:o.acpSessionId,cwd:e.workspace}),B.info("session restored via session/load",{agentId:e.agentId,cloudId:s,acpId:o.acpSessionId})}catch(m){B.warn("session/load failed, fallback to session/new",{agentId:e.agentId,cloudId:s,acpId:o.acpSessionId,err:String(m)}),o.acpSessionId=void 0;let _=await p.sessionNew({cwd:e.workspace});o.acpSessionId=_.sessionId,await this.persistSessionMapping(e)}finally{o.loadingSession=!1}}else{let m=await p.sessionNew({cwd:e.workspace});o.acpSessionId=m.sessionId,await this.persistSessionMapping(e)}p.afterSessionEstablished&&o.acpSessionId&&await p.afterSessionEstablished(o.acpSessionId)}armIdleTimer(e,s,o){if(tn(o),this.isRuntimeBusy(e,o)){B.debug("skip idle timer: runtime busy (in-flight turn / pending permission)",{agentId:e.agentId,cloudId:s});return}o.idleTimer=setTimeout(()=>{if(o.idleTimer=void 0,this.isRuntimeBusy(e,o)){B.info("idle reaper fired but runtime busy, re-arming",{agentId:e.agentId,cloudId:s}),this.armIdleTimer(e,s,o);return}B.info("session runtime idle timeout, killing downstream",{agentId:e.agentId,cloudId:s});let c=o.downstream;o.downstream=void 0,o.acpSessionId&&e.activeTriggers.delete(o.acpSessionId),c&&c.stop("idle timeout").catch(d=>B.warn("idle stop failed (ignored)",{agentId:e.agentId,cloudId:s,err:String(d)}))},this.sessionIdleTimeoutMs),o.idleTimer.unref?.()}isRuntimeBusy(e,s){if(s.acpSessionId&&e.activeTriggers.has(s.acpSessionId))return!0;let o=s.downstream;if(!o)return!1;for(let c of this.pendingUpstream.values())if(c.downstream===o)return!0;return!1}async sendAgentFileUpdate(e,s,o,c){let d={cozeAgentId:e.agentId,cozeReplySeqID:++s.replySeq};if(s.acpSessionId){let u=e.activeTriggers.get(s.acpSessionId);u&&(d.cozeTriggerMsgId=u)}await this.upstream.send(Qt("session/update",{sessionId:o,update:c,_meta:d}))}forwardUpdate(e,s){let o=s.sessionId,c=this.reverseSessionId(e,o);if(!c){B.debug("drop update for unknown session",{agentId:e.agentId,acpId:o});return}let d=e.sessions.get(c);if(!d){B.debug("drop update: runtime gone",{agentId:e.agentId,cloudId:c});return}if(hu(s)){B.debug("drop codex metadata-warn chunk",{agentId:e.agentId,acpId:o});return}let u={cozeAgentId:e.agentId,cozeReplySeqID:++d.replySeq},l=e.activeTriggers.get(o);l&&(u.cozeTriggerMsgId=l),this.upstream.send(Qt("session/update",{...s,sessionId:c,_meta:u})).catch(p=>B.warn("forward update failed",{agentId:e.agentId,err:String(p)}))}handleAgentRequest(e,s,o){if(o.method==="session/request_permission"){this.forwardPermissionRequest(e,s,o);return}if(o.method==="fs/write_text_file"||o.method==="fs/read_text_file"){this.handleFsRpcRequest(e,s,o);return}B.warn("unhandled agent request,returning method_not_found",{agentId:e.agentId,method:o.method}),s.respondAgentRequestError(o.id,{code:H.METHOD_NOT_FOUND,message:`method not handled by Bridge: ${o.method}`})}async handleFsRpcRequest(e,s,o){try{let c=e.workspace;if(o.method==="fs/write_text_file"){let d=o.params??{},u=await ko(d,c);s.respondAgentRequest(o.id,u)}else{let d=o.params??{},u=await To(d,c);s.respondAgentRequest(o.id,u)}}catch(c){B.warn("fs rpc handler failed",{agentId:e.agentId,method:o.method,err:String(c)}),s.respondAgentRequestError(o.id,en(c))}}forwardPermissionRequest(e,s,o){let c=this.upstreamIds.next("session/request_permission"),d=o.params??{},l=d.sessionId,p=l?e.activeTriggers.get(l):void 0,m={cozeAgentId:e.agentId};p&&(m.cozeTriggerMsgId=p);let _=l?this.reverseSessionId(e,l):void 0,y={...d,..._?{sessionId:_}:{},_meta:m};this.pendingUpstream.set(c,{agentRequestId:o.id,agentId:e.agentId,downstream:s,method:o.method}),B.info("forward permission_request \u2192 upstream",{agentId:e.agentId,upstreamId:c,acpSessionId:l,cloudSessionId:_,toolCallId:d.toolCall?.toolCallId,options:d.options?.map(I=>({optionId:I.optionId,kind:I.kind,name:I.name}))}),this.upstream.send(Xt(c,"session/request_permission",y)).catch(I=>{this.pendingUpstream.delete(c),B.error("forward permission request failed",{agentId:e.agentId,err:String(I)}),s.respondAgentRequestError(o.id,{code:H.INTERNAL_ERROR,message:`upstream send failed: ${String(I)}`})})}handleUpstreamResponse(e){if(e.id===null)return;let s=this.lookupPending(this.pendingUpstream,e.id,"upstream");if(s){this.pendingUpstream.delete(s.key);let c=s.value;e.error?(B.info("upstream \u2192 permission response (error)",{agentId:c.agentId,upstreamId:e.id,method:c.method,error:e.error}),c.downstream.respondAgentRequestError(c.agentRequestId,e.error)):(c.method==="session/request_permission"&&gu(e.result,c),B.info("upstream \u2192 permission response (result)",{agentId:c.agentId,upstreamId:e.id,method:c.method,result:e.result}),c.downstream.respondAgentRequest(c.agentRequestId,e.result));return}let o=this.lookupPending(this.pendingBridge,e.id,"bridge");if(o){this.pendingBridge.delete(o.key),clearTimeout(o.value.timer),e.error?o.value.reject(new Bn(e.error)):o.value.resolve(e.result);return}B.debug("orphan upstream response (no pending)",{id:e.id})}lookupPending(e,s,o){let c=e.get(s);if(c)return{value:c,key:s};if(typeof s=="number"){let d=String(s),u=e.get(d);if(u)return B.warn(`${o} id type mismatch: number received but Bridge expected string`,{rawId:s,normalizedId:d}),{value:u,key:d}}}sendRequest(e,s,o=xu){let c=this.upstreamIds.next(e);return new Promise((d,u)=>{let l=setTimeout(()=>{this.pendingBridge.delete(c),u(new S("AGENT_TIMEOUT",`${e} timed out after ${o}ms`))},o);this.pendingBridge.set(c,{method:e,resolve:d,reject:u,timer:l}),this.upstream.send(Xt(c,e,s)).catch(p=>{let m=this.pendingBridge.get(c);m&&(clearTimeout(m.timer),this.pendingBridge.delete(c)),u(p)})})}async persistSessionMapping(e){if(this.paths)try{let s=new Map;for(let[o,c]of e.sessions){let d={modelToken:c.modelToken,tokenGeneratedAt:c.tokenGeneratedAt};c.acpSessionId&&(d.acpSessionId=c.acpSessionId),s.set(o,d)}await Wr(e.agentId,s,this.paths)}catch(s){B.warn("persist session mapping failed",{agentId:e.agentId,err:String(s)})}}reverseSessionId(e,s){for(let[o,c]of e.sessions.entries())if(c.acpSessionId===s)return o}sendError(e,s,o){return this.upstream.send(it(e,{code:s,message:o,data:{bridgeVersion:rt}}))}};function lu(){return cu(16).toString("hex")}function gu(n,e){if(!n||typeof n!="object"){B.warn("permission response: result not an object (suspicious)",{agentId:e.agentId,result:n});return}let s=n;if("kind"in s&&!("outcome"in s)){B.warn('permission response: top-level "kind" field (D66 historical bug shape)',{agentId:e.agentId,result:n});return}let o=s.outcome;if(!o||typeof o!="object"){B.warn("permission response: missing or non-object outcome field",{agentId:e.agentId,result:n});return}let d=o.outcome;(typeof d!="string"||d!=="selected"&&d!=="cancelled")&&B.warn("permission response: unknown outcome discriminant",{agentId:e.agentId,outcomeValue:d,result:n})}function hu(n){let e=n.update;if(e?.sessionUpdate!=="agent_message_chunk")return!1;let s=e.content;if(!s||typeof s!="object")return!1;let o=s;return o.type!=="text"||typeof o.text!="string"?!1:o.text.startsWith("Model metadata for `")}U();ie();import{randomBytes as pu}from"node:crypto";import{chmod as mu,mkdir as wu,writeFile as No}from"node:fs/promises";import{createServer as _u}from"node:http";import{dirname as yu}from"node:path";var bu=1e6,oi=D("ipc"),$n=class{server=null;port=0;token="";routes;paths;constructor(e){this.routes=new Map(e.routes.map(s=>[`${s.method} ${s.path}`,s])),this.paths=e.paths??q()}async start(){this.token=pu(32).toString("hex");let e=_u((o,c)=>{this.dispatch(o,c)});this.server=e,await new Promise((o,c)=>{e.once("error",c),e.listen(0,"127.0.0.1",()=>o())});let s=e.address();if(!s||typeof s!="object")throw new Error("failed to obtain IPC port");return this.port=s.port,await this.persistAuthFiles(),oi.info("IPC listening",{port:this.port}),{port:this.port,token:this.token}}async stop(){let e=this.server;e&&(await new Promise((s,o)=>{e.close(c=>c?o(c):s())}),this.server=null)}async persistAuthFiles(){await wu(yu(this.paths.portFile),{recursive:!0}),await No(this.paths.portFile,String(this.port),"utf8"),await No(this.paths.tokenFile,this.token,{encoding:"utf8",mode:384});try{await mu(this.paths.tokenFile,384)}catch(e){oi.warn("chmod token file failed (non-POSIX?)",{err:String(e)})}}async dispatch(e,s){if(e.headers.authorization!==`Bearer ${this.token}`){sn(s,401,{error:"unauthorized"});return}let c=`${e.method} ${(e.url??"").split("?")[0]}`,d=this.routes.get(c);if(!d){sn(s,404,{error:"not found"});return}let u=null;if(e.method==="POST")try{u=await vu(e)}catch(l){sn(s,400,{error:"invalid json",detail:String(l)});return}try{let l=await d.handler(u,e);sn(s,200,l??{ok:!0})}catch(l){oi.error("IPC handler failed",{key:c,err:String(l)}),sn(s,500,{error:l instanceof Error?l.message:String(l)})}}};function sn(n,e,s){n.statusCode=e,n.setHeader("content-type","application/json"),n.end(JSON.stringify(s))}async function vu(n){let e=[],s=0;for await(let c of n){let d=c;if(s+=d.length,s>bu)throw new Error("body too large");e.push(d)}let o=Buffer.concat(e).toString("utf8");return o?JSON.parse(o):null}import{sep as Mo}from"node:path";import{fileURLToPath as Su}from"node:url";function Bo(){return Eu(Su(import.meta.url))}function Eu(n){let e=`${Mo}src${Mo}`;return n.includes(e)}U();ie();import{spawn as Iu}from"node:child_process";import{existsSync as Au,mkdirSync as Cu,openSync as Pu}from"node:fs";import{dirname as ku}from"node:path";import{fileURLToPath as Tu}from"node:url";var Du=D("spawn-helper");function Ru(n){return Au(n.libEntry)?n.libEntry:Tu(new URL("../index.ts",import.meta.url))}function Lu(n,e,s){let o=n.endsWith(".ts"),c=["--upgrade-helper",`--target-version=${e}`,`--old-pid=${s}`];return o?["--import","tsx/esm",n,...c]:[n,...c]}async function zo(n,e,s={}){let o=s.paths??q(),c=Ru(o);Cu(ku(o.logFile),{recursive:!0});let d=Pu(o.logFile,"a"),u=Lu(c,n,e),l=Iu(process.execPath,u,{detached:!0,stdio:["ignore",d,d],env:{...process.env,COZE_BRIDGE_UPGRADE_HELPER:"1"}});if(l.unref(),typeof l.pid!="number")throw new Error("failed to spawn upgrade helper (no pid)");Du.info("upgrade helper spawned",{pid:l.pid,targetVersion:n,oldPid:e,entry:c})}U();import{mkdir as Ou,writeFile as Nu}from"node:fs/promises";import{dirname as Mu}from"node:path";import{gunzipSync as Bu}from"node:zlib";var ai=D("tarball-downloader"),zu="https://registry.npmjs.org",Fo="package/dist/index.js";async function Uo(n,e,s={}){if(!/^[\w.\-+]+$/.test(n))throw new Error(`invalid version string: ${JSON.stringify(n)}`);let c=`${(s.registry??zu).replace(/\/+$/,"")}/coze-bridge/${n}`;ai.info("fetching tarball metadata",{metaUrl:c});let d=await fetch(c);if(!d.ok)throw new Error(`registry metadata ${c} returned ${d.status}`);let l=(await d.json())?.dist?.tarball;if(!l)throw new Error(`registry metadata missing dist.tarball for ${n}`);ai.info("downloading tarball",{tarballUrl:l});let p=await fetch(l);if(!p.ok)throw new Error(`tarball ${l} returned ${p.status}`);let m=Buffer.from(await p.arrayBuffer()),_=Bu(m),y=Fu(_,Fo);if(!y)throw new Error(`tarball missing entry ${Fo}`);await Ou(Mu(e),{recursive:!0}),await Nu(e,y),ai.info("dist extracted",{destPath:e,bytes:y.length})}function Fu(n,e){let s=0;for(;s+512<=n.length;){let o=n.subarray(s,s+512);if(o.every(_=>_===0))return null;let c=o.subarray(0,100),d=c.indexOf(0),u=c.subarray(0,d===-1?100:d).toString("utf8"),l=o.subarray(124,136).toString("ascii").trim().replace(/\0/g,""),p=Number.parseInt(l,8)||0,m=s+512;if(u===e)return n.subarray(m,m+p);s=m+Math.ceil(p/512)*512}return null}Lt();U();import{resolve as Uu}from"node:path";function qo(n,e){let s=n.split(".").map(Number),o=e.split(".").map(Number),c=Math.max(s.length,o.length);for(let d=0;d<c;d++){let u=s[d]??0,l=o[d]??0;if(u<l)return!0;if(u>l)return!1}return!1}var ft=D("upgrade-manager"),qu=300*1e3,Hu=3,Vn=class{constructor(e){this.opts=e}opts;inFlightTarget=null;async requestUpgrade(e){if(this.inFlightTarget===e){ft.debug("upgrade already in-flight, skip",{targetVersion:e});return}this.inFlightTarget=e;try{let s=await at(this.opts.paths.configFile)??{};if(s.disableAutoUpgrade){ft.info("disableAutoUpgrade=true, skip",{targetVersion:e});return}if(this.opts.isDevMode()){ft.warn("dev mode, skip auto-upgrade",{targetVersion:e});return}if(!qo(this.opts.currentVersion,e)){ft.debug("local version >= target, skip",{local:this.opts.currentVersion,target:e});return}let o=s.upgradeAttempts?.[e];if((o?.count??0)>=Hu){ft.warn("upgrade attempts cap reached, skip",{targetVersion:e,count:o?.count});return}let c=Uu(this.opts.paths.libDir,"index.js.next");try{await this.opts.download(e,c)}catch(u){await this.recordAttempt(s,e,String(u)),ft.warn("download failed, attempt recorded",{targetVersion:e,err:String(u)});return}this.opts.daemon.markUpgradePending(e);let d=await this.opts.daemon.waitIdle(qu);ft.info("waitIdle done",{result:d}),await this.opts.spawnHelper(e,process.pid),this.opts.daemon.exit(0)}finally{this.inFlightTarget=null}}async recordAttempt(e,s,o){e.upgradeAttempts=e.upgradeAttempts??{};let c=e.upgradeAttempts[s];e.upgradeAttempts[s]={count:(c?.count??0)+1,lastAt:Date.now(),...o?{lastError:o}:{}},await ze(e,this.opts.paths.configFile)}};var xc=Ke(Qo(),1);var Sl=Ke(Ja(),1),El=Ke(ur(),1),Il=Ke(Mt(),1),Al=Ke(yi(),1),Cl=Ke(Si(),1),Pl=Ke(ki(),1),nc=Ke(hr(),1),kl=Ke(tc(),1);var rc=nc.default;U();var ge=D("upstream.frontier"),sc="application/json",oc="none",gn=class{constructor(e){this.opts=e}opts;fws=null;handler=null;connectHandlers=[];opened=!1;openCount=0;async start(){if(this.fws){ge.warn("start called on already-started FrontierUpstream; noop");return}let e={Authorization:`Bearer ${this.opts.privatecode}`,Origin:Ls,...Ct(this.opts.ppeOverride)};class s extends rc{constructor(l){super(l,Rs,{headers:e})}send(l,...p){if(hs("debug"))try{let m;typeof l=="string"?m=Buffer.from(l,"utf8"):l instanceof Buffer?m=l:l instanceof ArrayBuffer?m=new Uint8Array(l):ArrayBuffer.isView(l)?m=new Uint8Array(l.buffer,l.byteOffset,l.byteLength):m=new Uint8Array(0);let _=Buffer.from(m.slice(0,128)).toString("hex");ge.debug("WS raw frame out",{bytes:m.byteLength,headHex:_})}catch(m){ge.warn("WS raw frame dump failed",{err:String(m)})}super.send(l,...p)}}let o=Ns(this.opts.urlOverride),c={url:o,ws:s,fpID:Ds,aID:Ln,accessKey:this.opts.handshake.accessKey,deviceID:this.opts.handshake.deviceId,payloadType:{type:sc,force:!0},payloadEncoding:{encoding:oc,force:!0},enableTransformTextPayload:!0,enableQoS:!1,enableAutoAck:!1,automaticOpen:!1,maxRetries:Number.POSITIVE_INFINITY,debug:this.opts.debug??!1},d=new xc.FWS(c);d.onopen=()=>{this.opened=!0,this.openCount+=1;let u=this.openCount===1;ge.info("frontier opened",{url:o,remoteDeviceId:this.opts.handshake.deviceId,initial:u,openCount:this.openCount});for(let l of this.connectHandlers)Promise.resolve(l({initial:u})).catch(p=>ge.warn("onConnect handler threw (ignored)",{err:String(p)}))},d.onclose=u=>{this.opened=!1,ge.info("frontier closed",{code:u.code,reason:u.reason,willReconnect:u.willReconnect})},d.onerror=u=>{ge.warn("frontier error",{code:u.code,msg:u.message})},d.onmessage=u=>this.handleMessage(u),this.fws=d,await d.connect()}async stop(e){let s=this.fws;if(s){this.fws=null,this.opened=!1;try{s.close(1e3,e??"bridge shutdown")}catch(o){ge.warn("frontier close threw (ignored)",{err:String(o)})}}}async send(e){let s=this.fws;if(!s)throw new S("UPSTREAM_DISCONNECTED","frontier upstream not started");if(!this.isConnected())throw new S("UPSTREAM_DISCONNECTED",`frontier ws not open (opened=${this.opened}, readyState=${s.readyState}); refusing to silently buffer`);this.injectAgentPatToken(e);let o=JSON.stringify(e),c=e;ac(c)||ge.info("frontier frame out",{method:c.method,jsonrpcId:c.id,size:o.length});try{await s.send(o,{service:33555712,method:1,payloadType:sc,payloadEncoding:oc})}catch(u){throw ge.warn("frontier frame send failed",{method:c.method,jsonrpcId:c.id,err:String(u)}),new S("UPSTREAM_DISCONNECTED",`frontier send failed: ${String(u)}`,{cause:u})}}onFrame(e){this.handler=e}onConnect(e){this.connectHandlers.push(e)}isConnected(){return this.opened&&this.fws?.readyState===1}injectAgentPatToken(e){let s=this.opts.getPatTokenForAgent;if(!s)return;let o=e.params?._meta;if(!o?.cozeAgentId)return;let c=s(o.cozeAgentId);c&&(o.cozePatToken=c)}handleMessage(e){let s=e.message?.service;if(s!==33555712){ge.debug("drop non-adapter frontier frame",{service:s});return}let o=Ll(e);if(!o){ge.debug("frontier message without text payload, drop",{payloadType:e.message?.payloadType});return}if(!this.handler){ge.debug("frame received but no onFrame handler",{size:o.length});return}let c;try{c=JSON.parse(o)}catch(u){ge.warn("frontier message JSON parse failed",{err:String(u),head:o.slice(0,80)});return}let d=c;ac(d)||ge.info("frontier frame in",{logid:Rl(e.message?.LogID),logidNew:e.message?.LogIDNew,msgId:e.message?.msgID,jsonrpcId:d.id,method:d.method,body:Dl(o)}),Promise.resolve(this.handler(c)).catch(u=>ge.warn("frontier frame handler threw",{err:String(u)}))}};function ac(n){return n.method==="_agent/health"?!0:typeof n.id=="string"&&n.id.startsWith("agent.health_")}var cc=2e3;function Dl(n){return n.length<=cc?n:`${n.slice(0,cc)}...<truncated, total ${n.length} chars>`}function Rl(n){return n?n.high===0?String(n.low>>>0):`${n.high.toString(16)}${(n.low>>>0).toString(16).padStart(8,"0")}`:""}function Ll(n){let e=n.message;if(e?.textPayload)return e.textPayload;let s=e?.payload;if(!s)return null;try{return Buffer.from(s).toString("utf8")}catch{return null}}U();var Di=D("upstream.switchable"),mr=class{inner;handler=null;connectHandlers=[];constructor(e){this.inner=e}async swap(e,s){if(this.inner===e)return;Di.info("swap upstream",{reason:s});let o=this.inner;if(this.inner=e,this.handler&&e.onFrame(this.handler),e.onConnect)for(let c of this.connectHandlers)e.onConnect(c);try{await e.start()}catch(c){throw Di.error("swap target start failed, reverting",{err:String(c)}),this.inner=o,c}await o.stop(s??"swapped").catch(c=>Di.warn("previous upstream stop threw (ignored)",{err:String(c)}))}current(){return this.inner}start(){return this.inner.start()}stop(e){return this.inner.stop(e)}send(e){return this.inner.send(e)}onFrame(e){this.handler=e,this.inner.onFrame(e)}onConnect(e){this.connectHandlers.push(e),this.inner.onConnect?.(e)}isConnected(){return this.inner.isConnected()}};U();var Ri=D("upstream"),Ht=class{handler=null;async start(){Ri.info("NoopUpstream started (M1 skeleton; real Frontier wired in M4)")}async stop(e){Ri.info("NoopUpstream stopped",{reason:e})}async send(e){Ri.debug("NoopUpstream.send (dropped)",{method:"method"in e?e.method:void 0})}onFrame(e){this.handler=e}isConnected(){return!1}async injectFrame(e){this.handler&&await this.handler(e)}};U();U();ie();import{promises as Li}from"node:fs";import{dirname as Ol}from"node:path";var Nl=D("pat-token-store");async function dc(n=q()){try{let s=(await Li.readFile(n.patTokenFile,"utf8")).trim();return s.length>0?s:null}catch(e){return e?.code!=="ENOENT"&&Nl.warn("read pat-token failed (treating as missing)",{err:String(e)}),null}}async function hn(n,e=q()){if(!n)throw new Error("writePatToken: empty patToken");await Li.mkdir(Ol(e.patTokenFile),{recursive:!0}),await Li.writeFile(e.patTokenFile,n,{encoding:"utf8",mode:384})}ie();ie();import{promises as wr}from"node:fs";import{join as Ml}from"node:path";function Bl(n){return`#!/bin/sh
|
|
122
124
|
exec node ${JSON.stringify(n)} "$@"
|
|
123
|
-
`}function
|
|
125
|
+
`}function zl(n){return`@echo off
|
|
124
126
|
node ${JSON.stringify(n)} %*
|
|
125
|
-
`}async function Wa(n,e=q()){let s=e.binDir;await lr.mkdir(s,{recursive:!0});let o=Df(s,process.platform==="win32"?"coze-bridge.cmd":"coze-bridge"),c=process.platform==="win32"?Lf(n):Rf(n);return await lr.readFile(o,"utf8").catch(()=>null)===c||(await lr.writeFile(o,c,"utf8"),process.platform!=="win32"&&await lr.chmod(o,493)),s}U();se();import{execSync as Va}from"node:child_process";import{readFileSync as $a,unlinkSync as Of}from"node:fs";import{mkdir as Nf,readFile as Ya,unlink as Xa,writeFile as Bf}from"node:fs/promises";import{dirname as Mf}from"node:path";function Ja(n){try{return process.kill(n,0),!0}catch(e){return e.code==="EPERM"}}var zf=R("single-instance"),hr=class{pidFile;acquired=!1;constructor(e={}){this.pidFile=e.pidFile??q().pidFile,e.processTitle&&(process.title=e.processTitle)}async acquire(){let e=await this.readExistingPid();return e!==null&&this.isAlive(e)?{kind:"already-running",pid:e}:(e!==null&&(zf.warn("removing stale pid file",{stalePid:e}),await Xa(this.pidFile).catch(()=>{})),await Nf(Mf(this.pidFile),{recursive:!0}),await Bf(this.pidFile,String(process.pid),"utf8"),this.acquired=!0,this.installCleanupHooks(),{kind:"acquired"})}async release(){if(this.acquired){try{(await Ya(this.pidFile,"utf8")).trim()===String(process.pid)&&await Xa(this.pidFile)}catch{}this.acquired=!1}}async readExistingPid(){try{let e=await Ya(this.pidFile,"utf8"),s=Number.parseInt(e.trim(),10);return Number.isFinite(s)&&s>0?s:null}catch(e){if(e.code==="ENOENT")return null;throw e}}isAlive(e){return Ja(e)?this.matchesDaemonTitle(e):!1}matchesDaemonTitle(e){if(process.platform==="win32")return this.matchesDaemonTitleWindows(e);try{let s=$a(`/proc/${e}/cmdline`,"utf8").replace(/\0/g," ");return!!(s.includes("coze-bridge-daemon")||s.includes("lib/index.js"))}catch{}try{let s=Va(`ps -o command= -p ${e}`,{stdio:["ignore","pipe","ignore"],timeout:1e3}).toString();return s.trim()?s.includes("coze-bridge-daemon")||s.includes("lib/index.js"):!1}catch{return!0}}matchesDaemonTitleWindows(e){try{let o=Va(`tasklist /FI "PID eq ${e}" /FO CSV /NH`,{stdio:["ignore","pipe","ignore"],timeout:2e3}).toString().trim();if(!o||o.startsWith("INFO:"))return!1;let c=o.split(",",1)[0]?.replace(/^"|"$/g,"").toLowerCase()??"";return c.includes("node")||c.includes("coze-bridge")}catch{return!0}}installCleanupHooks(){process.once("exit",()=>{if(this.acquired)try{$a(this.pidFile,"utf8").trim()===String(process.pid)&&Of(this.pidFile)}catch{}})}};var M=R("daemon"),Ff="coze-bridge-daemon";async function Za(){let n=new hr({processTitle:Ff}),e=await n.acquire();if(e.kind==="already-running")throw new Error(`coze-bridge daemon already running (pid=${e.pid})`);let s=await Hn(),o=s??{};mn({pid:process.pid}),M.info(s?"loaded bridge config":"initialized bridge config");try{let A=new Pt;o.frameworksCache=await A.detectAll(),M.info("refreshed frameworks_cache",{detected:Object.keys(o.frameworksCache)})}catch(A){M.warn("framework detection failed",{err:String(A)})}await kt(o);let c=new fr(new zt),x=q(),u=null,l=new Kn({upstream:c,paths:x,bridgeConfig:o,sessionSpawner:async(A,N,z,V)=>{if(!u)throw new Error("agentManager not ready");return u.spawnSessionDownstream(A,N,z,V)}});await Uf(x,l);let m=new qn({paths:x,config:o,registry:l});u=m;let w,v,y=null,E={},k,P=null;l.registerExtension("_agent/create",async A=>m.createAgent(A.params)),l.registerExtension("_agent/health",async()=>({ok:!0}));let T={},F=new In({agents:l.agents,disposeAndMarkDisconnected:async(A,N)=>{let z=l.agents.get(A);z&&(await m.cleanupOpenclawSessionProviders(z).catch(V=>M.warn("cleanup openclaw providers failed (ignored)",{agentId:A,err:String(V)})),await z.dispose(`disconnect: ${N}`).catch(V=>M.warn("dispose during disconnect failed (ignored)",{agentId:A,err:String(V)})),z.status="disconnected",l.unregister(A)),l.disconnectedAgents.add(A)},detailSyncer:async A=>{if(!T.ref)throw new Error("agent-detail-sync not initialized yet");await T.ref.syncOne(A)},openclawRepair:async(A,N)=>{await m.openclawRepair(A,N)}});l.registerExtension("_agent/listSkills",A=>F.listSkills(A.params)),l.registerExtension("_agent/addSkills",A=>F.addSkills(A.params)),l.registerExtension("_agent/removeSkills",A=>F.removeSkills(A.params)),l.registerExtension("_agent/getFileTree",A=>F.getFileTree(A.params)),l.registerExtension("_agent/getFileContent",A=>F.getFileContent(A.params)),l.registerExtension("_agent/update",A=>F.updateAgent(A.params)),l.registerExtension("_agent/disconnect",A=>F.disconnectAgent(A.params)),l.registerExtension("_agent/switchModel",A=>F.switchModel(A.params)),l.registerExtension("_agent/reset",A=>F.resetAgent(A.params)),l.registerExtension("_agent/repair",A=>F.repairAgent(A.params));let re=new vn({paths:x,handlers:F,sendDetail:A=>l.sendRequest("_agent/detail",A)});T.ref=re,c.onConnect(({initial:A})=>{M.info("frontier upstream connected, triggering detail sync",{initial:A}),re.syncAll(A?"initial-connect":"reconnect").catch(N=>M.warn("detail sync top-level error (ignored)",{err:String(N)}))});let J=new jn({paths:x,routes:[{method:"GET",path:"/status",handler:async()=>({running:!0,pid:process.pid,agents:[...l.agents.keys()],deviceId:y??"",frameworksCache:o.frameworksCache??{}})},{method:"POST",path:"/pair",handler:async A=>{let N=A,z=N?.privatecode,V=N?.pairing_code;if(!z||!V)throw new S("IPC_BAD_REQUEST","/pair requires privatecode + pairing_code");let _e=jt(N.env),Te=N.handshake_url,Fe=N.frontier_url,fe=Qa(N.env,Te,Fe),ge=!!w&&w!==z,st=v!==void 0&&v!==fe,te=ge||st;if(te){M.warn("pair config switched, resetting agents",{pcChanged:ge,envChanged:st,previousPc:w?gr(w):"",nextPc:gr(z),previousEnvKey:v??"",nextEnvKey:fe});for(let ce of[...l.agents.values()])await ce.dispose("pair config switch").catch(()=>{}),l.agents.delete(ce.agentId);await c.swap(new zt,"pair switch").catch(()=>{})}let ot=await Br({privatecode:z,...Te?{endpoint:Te}:{},ppeOverride:_e});y=ot.deviceId,mn({deviceId:y,pid:process.pid}),Jr({patToken:z,env:N.env}).catch(ce=>M.warn("coze-cli setup error (ignored)",{err:String(ce)}));let G=new dn({handshake:ot,privatecode:z,...Fe?{urlOverride:Fe}:{},ppeOverride:_e});await c.swap(G,"pair");try{let ce=new Pt;o.frameworksCache=await ce.detectAll(),await kt(o),M.info("frameworks_cache refreshed before pair",{detected:Object.keys(o.frameworksCache)})}catch(ce){M.warn("frameworks_cache refresh failed (ignored, using cached)",{err:String(ce)})}let X=Object.keys(o.frameworksCache??{});try{let ce=await l.sendRequest("_agent/pair",{pairCode:V,patToken:z,frameworks:X,_meta:{cozeDeviceId:y}});M.info("_agent/pair ok",{pairResult:ce}),w=z,v=fe,E=_e,k=Te,un(z,x).catch(Ie=>M.warn("writePatToken after /pair failed (ignored)",{err:String(Ie)})),P||(P=new Jt({core:l,getDeviceId:()=>y??""})),P.start(),te&&bi(x,m).catch(Ie=>M.warn("post-pair-switch auto-revive error (ignored)",{err:String(Ie)}));let Ue;return N.agent_id&&(Ue=await qf(N.agent_id,x,m,Ie=>l.sendRequest("_agent/detail",Ie)).catch(Ie=>(M.error("--agent-id ensureAgent failed",{agentId:N.agent_id,err:String(Ie)}),{ok:!1,agentId:N.agent_id??"",note:String(Ie)}))),{ok:!0,note:"paired with cloud",...Ue?{agent:Ue}:{}}}catch(ce){return M.error("_agent/pair failed",{err:String(ce)}),{ok:!1,note:`pair failed: ${String(ce)}`}}}},{method:"POST",path:"/connect",handler:async A=>{let N=A,z=N?.privatecode;if(!z)throw new S("IPC_BAD_REQUEST","/connect requires privatecode");let V=jt(N.env),_e=N.handshake_url,Te=N.frontier_url,Fe=Qa(N.env,_e,Te);if(w===z&&v===Fe)return M.info("/connect: already connected with same PAT + env, noop"),{ok:!0,note:"already connected"};let fe=!!w&&w!==z,ge=v!==void 0&&v!==Fe,st=fe||ge;if(st){M.warn("connect config switched, resetting agents",{pcChanged:fe,envChanged:ge,previousPc:w?gr(w):"",nextPc:gr(z)});for(let G of[...l.agents.values()])await G.dispose("connect config switch").catch(()=>{}),l.agents.delete(G.agentId);await c.swap(new zt,"connect switch").catch(()=>{})}let te=await Br({privatecode:z,..._e?{endpoint:_e}:{},ppeOverride:V});y=te.deviceId,mn({deviceId:y,pid:process.pid}),Jr({patToken:z,env:N.env}).catch(G=>M.warn("coze-cli setup error (ignored)",{err:String(G)}));let ot=new dn({handshake:te,privatecode:z,...Te?{urlOverride:Te}:{},ppeOverride:V});return await c.swap(ot,"connect"),w=z,v=Fe,E=V,k=_e,P||(P=new Jt({core:l,getDeviceId:()=>y??""})),P.start(),st&&bi(x,m).catch(G=>M.warn("post-connect-switch auto-revive error (ignored)",{err:String(G)})),un(z,x).catch(G=>M.warn("writePatToken after /connect failed (ignored)",{err:String(G)})),M.info("/connect: WS established",{deviceId:y}),{ok:!0,note:"connected"}}},{method:"POST",path:"/_agent/create",handler:async A=>{let N=A;return{ok:!0,result:await m.createAgent(N)}}},{method:"POST",path:"/agent/send",handler:async A=>{let N=A;if(!N?.agentId||!N?.sessionId||!N?.kind||!N?.path)throw new S("IPC_BAD_REQUEST","/agent/send requires agentId, sessionId, kind, path");if(!w)throw new S("UPSTREAM_NOT_READY","daemon not yet paired with cloud (run --pair-code first)");try{return await no(N,{core:l,patToken:w,handshakeBase:k,ppeOverride:E})}catch(z){if(z instanceof S)return{ok:!1,code:z.code,message:z.message};throw z}}},{method:"POST",path:"/refresh",handler:async()=>{M.info("IPC /refresh: re-detecting frameworks");let A=new Pt;return o.frameworksCache=await A.detectAll(),await kt(o),{ok:!0,frameworks:o.frameworksCache}}},{method:"POST",path:"/shutdown",handler:async()=>(M.info("IPC /shutdown received"),setImmediate(()=>{ae.shutdown("ipc /shutdown")}),{ok:!0})}]}),{port:we,token:ee}=await J.start();try{await Wa(x.libEntry,x)}catch(A){M.warn("bin shim install failed (D72 send \u547D\u4EE4\u53EF\u80FD\u4E0D\u53EF\u7528)",{err:String(A)})}await l.start(),bi(x,m).catch(A=>M.warn("auto-revive top-level error (ignored)",{err:String(A)})),io().catch(A=>M.warn("acp wrapper warmup top-level error (ignored)",{err:String(A)}));let oe=null,ae={port:we,token:ee,core:l,ipc:J,shutdown(A){return oe||(M.info("daemon shutdown",{reason:A}),oe=(async()=>{P?.stop(),await l.stop(A),await J.stop(),await n.release()})(),oe)}};for(let A of["SIGTERM","SIGINT"])process.on(A,()=>{ae.shutdown(A).then(()=>process.exit(0))});return M.info("daemon ready",{port:we,pid:process.pid,nodeVersion:process.version,platform:process.platform,frameworks:Object.keys(o.frameworksCache??{}),libVersion:o.libVersion??"dev"}),ae}function gr(n){return n.length<=8?"***":`${n.slice(0,4)}***${n.slice(-4)}`}function Qa(n,e,s){return`${n??""}|${e??""}|${s??""}`}async function Uf(n,e){let{readdir:s}=await import("node:fs/promises"),o;try{o=await s(n.agentsRoot)}catch{return}let{loadAgentConfig:c,enforceAgentConfigMode:x}=await Promise.resolve().then(()=>(Ze(),yn));for(let u of o){await x(u,n).catch(l=>M.warn("enforceAgentConfigMode failed (ignored)",{agentId:u,err:String(l)}));try{let l=await c(u,n);l?.disconnectedAt&&(e.disconnectedAgents.add(u),M.info("agent marked disconnected on startup",{agentId:u,disconnectedAt:l.disconnectedAt,reason:l.disconnectReason??""}))}catch(l){M.warn("failed to load agent config on startup, skipping",{agentId:u,err:String(l)})}}}async function qf(n,e,s,o){let{loadAgentConfig:c}=await Promise.resolve().then(()=>(Ze(),yn)),x=await c(n,e);if(x){M.info("--agent-id: local config found, reconnecting",{agentId:n,framework:x.framework,hadDisconnect:!!x.disconnectedAt});let w={agentId:x.agentId,framework:x.framework,...x.cozeIdentity?{cozeIdentity:x.cozeIdentity}:{},...x.model?{model:x.model}:{}};return await s.createAgent(w),{ok:!0,agentId:n,note:x.disconnectedAt?"revived from local config":"connected from local config"}}M.info("--agent-id: local config missing, pulling _agent/detail from cloud",{agentId:n});let u=await o({_meta:{cozeAgentId:n}});if(!u.framework)throw new S("AGENT_NOT_FOUND",`agent ${n} \u4E0D\u5728\u672C\u5730; \u4E91\u7AEF _agent/detail \u54CD\u5E94\u7F3A framework \u5B57\u6BB5 (D36 \u534F\u8BAE\u6269\u5C55\u672A\u751F\u6548), \u65E0\u6CD5\u5728\u672C\u673A\u65B0\u5EFA`);let l={agentId:u.agentId,framework:u.framework,...u.cozeIdentity?{cozeIdentity:u.cozeIdentity}:{},...u.model?{model:u.model}:{},...u.deployType?{_meta:{cozeDeployType:u.deployType}}:{}};await s.createAgent(l);let m=u.deployType==="cloud"&&u.framework==="openclaw";return{ok:!0,agentId:n,note:m?"cloud agent acknowledged":"created from cloud detail"}}async function bi(n,e){let{readdir:s}=await import("node:fs/promises"),o;try{o=await s(n.agentsRoot)}catch{return{revived:0,skipped:0,total:0}}if(o.length===0)return{revived:0,skipped:0,total:0};let{loadAgentConfig:c}=await Promise.resolve().then(()=>(Ze(),yn));M.info("auto-revive: scanning local agents on startup",{count:o.length});let x=0,u=0;for(let l of o){let m;try{m=await c(l,n)}catch(w){M.warn("auto-revive: load config failed (skipping)",{agentId:l,err:String(w)}),u+=1;continue}if(!m){u+=1;continue}if(m.disconnectedAt){M.info("auto-revive: skip disconnected agent",{agentId:l,disconnectedAt:m.disconnectedAt}),u+=1;continue}try{M.info("auto-revive: re-registering agent (D44 no spawn)",{agentId:l,framework:m.framework});let w=Hf(m);await e.createAgent({agentId:m.agentId,framework:m.framework,...m.cozeIdentity?{cozeIdentity:m.cozeIdentity}:{},...m.model?{model:m.model}:{},...w?{_meta:w}:{}}),x+=1}catch(w){M.warn("auto-revive: createAgent failed (skipping)",{agentId:l,framework:m.framework,err:String(w)}),u+=1}}return M.info("auto-revive: done",{revived:x,skipped:u,total:o.length}),{revived:x,skipped:u,total:o.length}}function Hf(n){let e={};return n.deployType&&(e.cozeDeployType=n.deployType),n.accountId&&(e.cozeAccountId=n.accountId),Object.keys(e).length>0?e:void 0}Ci();se();import{readFile as e0}from"node:fs/promises";var $e=class{paths;constructor(e){this.paths=e??q()}async probe(e=1e3){let s=await pr(this.paths);if(!s)return{kind:"not-running"};try{let o=await this.fetch(s,{method:"GET",path:"/status",timeoutMs:e});return o.status===200?{kind:"connected",...s}:{kind:"stale",reason:`unexpected status ${o.status}`}}catch(o){return{kind:"stale",reason:Xf(o)}}}async request(e){let s=await pr(this.paths);if(!s)throw new Error("coze-bridge daemon not running (no port/token files)");return this.fetch(s,e)}async fetch(e,s){let o=s.body!==void 0,c={Authorization:`Bearer ${e.token}`};o&&(c["content-type"]="application/json");let x=new AbortController,u=setTimeout(()=>x.abort(),s.timeoutMs??5e3);try{let l=await fetch(`http://127.0.0.1:${e.port}${s.path}`,{method:s.method,headers:c,body:o?JSON.stringify(s.body):void 0,signal:x.signal}),m=await l.text();return{status:l.status,body:Yf(m)}}finally{clearTimeout(u)}}};async function pr(n){try{let[e,s]=await Promise.all([e0(n.portFile,"utf8"),e0(n.tokenFile,"utf8")]),o=Number.parseInt(e.trim(),10),c=s.trim();return!Number.isFinite(o)||o<=0||!c?null:{port:o,token:c}}catch(e){if(e.code==="ENOENT")return null;throw e}}function Yf(n){if(!n)return null;try{return JSON.parse(n)}catch{return n}}function Xf(n){return n instanceof Error?n.message:String(n)}U();se();import{copyFile as t0,mkdir as Qf,readFile as Ii,writeFile as Zf}from"node:fs/promises";import{dirname as el,resolve as Ai,sep as mr}from"node:path";import{fileURLToPath as tl}from"node:url";U();se();var n0=R("dist-install");function nl(n){let e=tl(n),s=el(e),o=`${mr}src${mr}`;if(s.includes(o)||s.endsWith(`${mr}src${mr}cli`))return null;let c=Ai(s,"index.js"),x=Ai(s,"..","package.json");return{dist:c,pkgJson:x}}async function Pi(n={}){let e=n.paths??q(),s=nl(import.meta.url),o=n.sourceDist??s?.dist,c=n.sourcePackageJson??s?.pkgJson;if(!o||!c)return{kind:"dev-mode-skip",reason:"running from src/(tsx loader);no dist/ to install"};let x;try{x=JSON.parse(await Ii(c,"utf8")).version??"unknown"}catch(y){return n0.warn("cannot read source package.json,skip dist install",{err:String(y)}),{kind:"dev-mode-skip",reason:`package.json read failed: ${String(y)}`}}let u=await Hn(e.configFile)??{},l=u.libVersion;if(l===x)try{return await Ii(e.libEntry),{kind:"already-current",libVersion:x}}catch{}await Qf(e.libDir,{recursive:!0}),await t0(o,e.libEntry),await t0(`${o}.map`,`${e.libEntry}.map`).catch(()=>{});let m=Ai(e.libDir,"package.json"),w=`${JSON.stringify({type:"module"},null,2)}
|
|
126
|
-
`;return await
|
|
127
|
-
`),4;let o=await
|
|
128
|
-
`),4;let c={agentId:n.agentId,sessionId:n.sessionId,kind:n.kind,path:
|
|
129
|
-
`),4}if(!
|
|
130
|
-
`),
|
|
131
|
-
`);else{let u=n.name??
|
|
132
|
-
`)}return 0}async function
|
|
127
|
+
`}async function uc(n,e=q()){let s=e.binDir;await wr.mkdir(s,{recursive:!0});let o=Ml(s,process.platform==="win32"?"coze-bridge.cmd":"coze-bridge"),c=process.platform==="win32"?zl(n):Bl(n);return await wr.readFile(o,"utf8").catch(()=>null)===c||(await wr.writeFile(o,c,"utf8"),process.platform!=="win32"&&await wr.chmod(o,493)),s}U();ie();import{execSync as lc}from"node:child_process";import{readFileSync as gc,unlinkSync as Fl}from"node:fs";import{mkdir as Ul,readFile as hc,unlink as pc,writeFile as ql}from"node:fs/promises";import{dirname as Hl}from"node:path";function fc(n){try{return process.kill(n,0),!0}catch(e){return e.code==="EPERM"}}var jl=D("single-instance"),_r=class{pidFile;acquired=!1;constructor(e={}){this.pidFile=e.pidFile??q().pidFile,e.processTitle&&(process.title=e.processTitle)}async acquire(){let e=await this.readExistingPid();return e!==null&&this.isAlive(e)?{kind:"already-running",pid:e}:(e!==null&&(jl.warn("removing stale pid file",{stalePid:e}),await pc(this.pidFile).catch(()=>{})),await Ul(Hl(this.pidFile),{recursive:!0}),await ql(this.pidFile,String(process.pid),"utf8"),this.acquired=!0,this.installCleanupHooks(),{kind:"acquired"})}async release(){if(this.acquired){try{(await hc(this.pidFile,"utf8")).trim()===String(process.pid)&&await pc(this.pidFile)}catch{}this.acquired=!1}}async readExistingPid(){try{let e=await hc(this.pidFile,"utf8"),s=Number.parseInt(e.trim(),10);return Number.isFinite(s)&&s>0?s:null}catch(e){if(e.code==="ENOENT")return null;throw e}}isAlive(e){return fc(e)?this.matchesDaemonTitle(e):!1}matchesDaemonTitle(e){if(process.platform==="win32")return this.matchesDaemonTitleWindows(e);try{let s=gc(`/proc/${e}/cmdline`,"utf8").replace(/\0/g," ");return!!(s.includes("coze-bridge-daemon")||s.includes("lib/index.js"))}catch{}try{let s=lc(`ps -o command= -p ${e}`,{stdio:["ignore","pipe","ignore"],timeout:1e3}).toString();return s.trim()?s.includes("coze-bridge-daemon")||s.includes("lib/index.js"):!1}catch{return!0}}matchesDaemonTitleWindows(e){try{let o=lc(`tasklist /FI "PID eq ${e}" /FO CSV /NH`,{stdio:["ignore","pipe","ignore"],timeout:2e3}).toString().trim();if(!o||o.startsWith("INFO:"))return!1;let c=o.split(",",1)[0]?.replace(/^"|"$/g,"").toLowerCase()??"";return c.includes("node")||c.includes("coze-bridge")}catch{return!0}}installCleanupHooks(){process.once("exit",()=>{if(this.acquired)try{gc(this.pidFile,"utf8").trim()===String(process.pid)&&Fl(this.pidFile)}catch{}})}};function Kl(){let n=0,e=null;return{incActive(){n++},decActive(){n>0&&n--},activeCount(){return n},markUpgradePending(s){e=s},isUpgrading(){return e!==null},pendingTarget(){return e},async waitIdle(s){let o=Date.now()+s;for(;Date.now()<o;){if(n===0)return"idle";await new Promise(c=>setTimeout(c,200))}return n===0?"idle":"timeout"}}}var M=D("daemon"),Gl="coze-bridge-daemon";async function wc(){let n=new _r({processTitle:Gl}),e=await n.acquire();if(e.kind==="already-running")throw new Error(`coze-bridge daemon already running (pid=${e.pid})`);let s=await at(),o=s??{};yn({pid:process.pid}),M.info(s?"loaded bridge config":"initialized bridge config");try{let A=new Rt;o.frameworksCache=await A.detectAll(),M.info("refreshed frameworks_cache",{detected:Object.keys(o.frameworksCache)})}catch(A){M.warn("framework detection failed",{err:String(A)})}await ze(o);let c=new mr(new Ht),d=q(),u=Kl(),l=null,p=new Jn({upstream:c,paths:d,bridgeConfig:o,upgradeGate:u,sessionSpawner:async(A,N,z,ye)=>{if(!l)throw new Error("agentManager not ready");return l.spawnSessionDownstream(A,N,z,ye)}});await Jl(d,p);let m=new Wn({paths:d,config:o,registry:p});l=m;let _,y,I=null,L={},T,P=null,j=null;p.registerExtension("_agent/create",async A=>m.createAgent(A.params)),p.registerExtension("_agent/health",async()=>({ok:!0}));let Q={},K=new Nn({agents:p.agents,disposeAndMarkDisconnected:async(A,N)=>{let z=p.agents.get(A);if(z){await m.cleanupOpenclawSessionProviders(z).catch(Z=>M.warn("cleanup openclaw providers failed (ignored)",{agentId:A,err:String(Z)}));let ye=!0;try{await z.dispose(`disconnect: ${N}`)}catch(Z){ye=!1,M.error("dispose during disconnect FAILED, leaving agent in error state",{agentId:A,err:String(Z)}),z.status="error"}ye&&(z.status="disconnected",p.unregister(A),p.disconnectedAgents.add(A))}else p.disconnectedAgents.add(A)},detailSyncer:async A=>{if(!Q.ref)throw new Error("agent-detail-sync not initialized yet");await Q.ref.syncOne(A)},cleanupOpenclawProviders:async A=>{await m.cleanupOpenclawSessionProviders(A)},openclawRepair:async(A,N)=>{await m.openclawRepair(A,N)},isRuntimePendingPermission:A=>p.hasPendingPermissionFor(A)});p.registerExtension("_agent/listSkills",A=>K.listSkills(A.params)),p.registerExtension("_agent/addSkills",A=>K.addSkills(A.params)),p.registerExtension("_agent/removeSkills",A=>K.removeSkills(A.params)),p.registerExtension("_agent/getFileTree",A=>K.getFileTree(A.params)),p.registerExtension("_agent/getFileContent",A=>K.getFileContent(A.params)),p.registerExtension("_agent/update",A=>K.updateAgent(A.params)),p.registerExtension("_agent/disconnect",A=>K.disconnectAgent(A.params)),p.registerExtension("_agent/switchModel",A=>K.switchModel(A.params)),p.registerExtension("_agent/reset",A=>K.resetAgent(A.params)),p.registerExtension("_agent/repair",A=>K.repairAgent(A.params));let $=new Tn({paths:d,handlers:K,sendDetail:A=>p.sendRequest("_agent/detail",A)});Q.ref=$;let se=async A=>{await Promise.allSettled(A.map(async N=>{try{await K.disconnectAgent({agentId:N.agentId,reason:`auth_failure: code=${N.code} ${N.message}`}),M.info("agent disconnected due to auth failure from heartbeat response",{agentId:N.agentId,code:N.code,message:N.message})}catch(z){M.warn("disconnect during authFailure handling failed (ignored)",{agentId:N.agentId,err:String(z)})}}))};c.onConnect(({initial:A})=>{M.info("frontier upstream connected, triggering detail sync",{initial:A}),$.syncAll(A?"initial-connect":"reconnect").catch(N=>M.warn("detail sync top-level error (ignored)",{err:String(N)}))});let oe=new $n({paths:d,routes:[{method:"GET",path:"/status",handler:async()=>({running:!0,pid:process.pid,agents:[...p.agents.keys()],deviceId:I??"",frameworksCache:o.frameworksCache??{}})},{method:"POST",path:"/pair",handler:async A=>{let N=A,z=N?.privatecode,ye=N?.pairing_code;if(!z||!ye)throw new S("IPC_BAD_REQUEST","/pair requires privatecode + pairing_code");let Z=$t(N.env),le=N.handshake_url,je=N.frontier_url,ne=mc(N.env,le,je),Xe=!!_&&_!==z,X=y!==void 0&&y!==ne,V=Xe||X,dt=await $r({privatecode:z,...le?{endpoint:le}:{},ppeOverride:Z});if(V){M.warn("pair config switched, resetting agents",{pcChanged:Xe,envChanged:X,previousPc:_?yr(_):"",nextPc:yr(z),previousEnvKey:y??"",nextEnvKey:ne});for(let re of[...p.agents.values()])await re.dispose("pair config switch").catch(()=>{}),p.agents.delete(re.agentId);p.disconnectedAgents.size>0&&(M.info("clearing disconnectedAgents set on pair config switch",{count:p.disconnectedAgents.size}),p.disconnectedAgents.clear()),await c.swap(new Ht,"pair switch").catch(()=>{})}I=dt.deviceId,yn({deviceId:I,pid:process.pid}),ii({patToken:z,env:N.env}).catch(re=>M.warn("coze-cli setup error (ignored)",{err:String(re)}));let W=new gn({handshake:dt,privatecode:z,...je?{urlOverride:je}:{},ppeOverride:Z,getPatTokenForAgent:re=>p.agents.get(re)?.patToken});await c.swap(W,"pair");try{let re=new Rt;o.frameworksCache=await re.detectAll(),await ze(o),M.info("frameworks_cache refreshed before pair",{detected:Object.keys(o.frameworksCache)})}catch(re){M.warn("frameworks_cache refresh failed (ignored, using cached)",{err:String(re)})}let wt=Object.keys(o.frameworksCache??{});try{let re=await p.sendRequest("_agent/pair",{pairCode:ye,patToken:z,frameworks:wt,_meta:{cozeDeviceId:I}});M.info("_agent/pair ok",{pairResult:re}),_=z,y=ne,L=Z,T=le,hn(z,d).catch(we=>M.warn("writePatToken after /pair failed (ignored)",{err:String(we)})),P||(P=new Yt({core:p,getDeviceId:()=>I??"",onTickEnd:()=>$.retryPending().catch(we=>M.warn("detailSync.retryPending failed (ignored)",{err:String(we)})),onAuthFailures:se,onMinBridgeVersion:we=>j?.requestUpgrade(we)})),P.start(),V&&br(d,m).catch(we=>M.warn("post-pair-switch auto-revive error (ignored)",{err:String(we)}));let _t;return N.agent_id&&(_t=await $l(N.agent_id,d,m,we=>p.sendRequest("_agent/detail",we),z).catch(we=>(M.error("--agent-id ensureAgent failed",{agentId:N.agent_id,err:String(we)}),{ok:!1,agentId:N.agent_id??"",note:String(we)}))),{ok:!0,note:"paired with cloud",..._t?{agent:_t}:{}}}catch(re){return M.error("_agent/pair failed",{err:String(re)}),{ok:!1,note:`pair failed: ${String(re)}`}}}},{method:"POST",path:"/connect",handler:async A=>{let N=A,z=N?.privatecode;if(!z)throw new S("IPC_BAD_REQUEST","/connect requires privatecode");let ye=$t(N.env),Z=N.handshake_url,le=N.frontier_url,je=mc(N.env,Z,le);if(_===z&&y===je){let W=await Wl(d);return p.agents.size===0&&W?(M.warn("/connect noop but core.agents empty with configs on disk; re-running auto-revive"),br(d,m).catch(wt=>M.warn("connect-noop auto-revive error (ignored)",{err:String(wt)}))):M.info("/connect: already connected with same PAT + env, noop"),{ok:!0,note:"already connected"}}let ne=!!_&&_!==z,Xe=y!==void 0&&y!==je,X=ne||Xe,V=await $r({privatecode:z,...Z?{endpoint:Z}:{},ppeOverride:ye});if(X){M.warn("connect config switched, resetting agents",{pcChanged:ne,envChanged:Xe,previousPc:_?yr(_):"",nextPc:yr(z)});for(let W of[...p.agents.values()])await W.dispose("connect config switch").catch(()=>{}),p.agents.delete(W.agentId);p.disconnectedAgents.size>0&&(M.info("clearing disconnectedAgents set on connect config switch",{count:p.disconnectedAgents.size}),p.disconnectedAgents.clear()),await c.swap(new Ht,"connect switch").catch(()=>{})}I=V.deviceId,yn({deviceId:I,pid:process.pid}),ii({patToken:z,env:N.env}).catch(W=>M.warn("coze-cli setup error (ignored)",{err:String(W)}));let dt=new gn({handshake:V,privatecode:z,...le?{urlOverride:le}:{},ppeOverride:ye,getPatTokenForAgent:W=>p.agents.get(W)?.patToken});return await c.swap(dt,"connect"),_=z,y=je,L=ye,T=Z,P||(P=new Yt({core:p,getDeviceId:()=>I??"",onTickEnd:()=>$.retryPending().catch(W=>M.warn("detailSync.retryPending failed (ignored)",{err:String(W)})),onAuthFailures:se,onMinBridgeVersion:W=>j?.requestUpgrade(W)})),P.start(),X&&br(d,m).catch(W=>M.warn("post-connect-switch auto-revive error (ignored)",{err:String(W)})),hn(z,d).catch(W=>M.warn("writePatToken after /connect failed (ignored)",{err:String(W)})),M.info("/connect: WS established",{deviceId:I}),{ok:!0,note:"connected"}}},{method:"POST",path:"/_agent/create",handler:async A=>{let N=A;return{ok:!0,result:await m.createAgent(N)}}},{method:"POST",path:"/agent/send",handler:async A=>{let N=A;if(!N?.agentId||!N?.sessionId||!N?.kind||!N?.path)throw new S("IPC_BAD_REQUEST","/agent/send requires agentId, sessionId, kind, path");if(!_)throw new S("UPSTREAM_NOT_READY","daemon not yet paired with cloud (run --pair-code first)");try{return await wo(N,{core:p,patToken:_,handshakeBase:T,ppeOverride:L})}catch(z){if(z instanceof S)return{ok:!1,code:z.code,message:z.message};throw z}}},{method:"POST",path:"/refresh",handler:async()=>{M.info("IPC /refresh: re-detecting frameworks");let A=new Rt;return o.frameworksCache=await A.detectAll(),await ze(o),{ok:!0,frameworks:o.frameworksCache}}},{method:"POST",path:"/shutdown",handler:async()=>(M.info("IPC /shutdown received"),setImmediate(()=>{de.shutdown("ipc /shutdown")}),{ok:!0})}]}),{port:Te,token:pe}=await oe.start();try{await uc(d.libEntry,d)}catch(A){M.warn("bin shim install failed (D72 send \u547D\u4EE4\u53EF\u80FD\u4E0D\u53EF\u7528)",{err:String(A)})}await p.start(),br(d,m).catch(A=>M.warn("auto-revive top-level error (ignored)",{err:String(A)})),_s().catch(A=>M.warn("acp wrapper warmup top-level error (ignored)",{err:String(A)}));let xe=null,de={port:Te,token:pe,core:p,ipc:oe,shutdown(A){return xe||(M.info("daemon shutdown",{reason:A}),xe=(async()=>{P?.stop(),await p.stop(A),await oe.stop(),await n.release()})(),xe)}};j=new Vn({paths:d,currentVersion:rt,isDevMode:Bo,download:(A,N)=>Uo(A,N),spawnHelper:(A,N)=>zo(A,N,{paths:d}),daemon:{markUpgradePending:A=>{M.warn("upgrade pending, ACP gate engaged",{target:A}),u.markUpgradePending(A)},waitIdle:A=>u.waitIdle(A),exit:A=>{de.shutdown("upgrade").then(()=>process.exit(A))}}});for(let A of["SIGTERM","SIGINT"])process.on(A,()=>{de.shutdown(A).then(()=>process.exit(0))});return M.info("daemon ready",{port:Te,pid:process.pid,nodeVersion:process.version,platform:process.platform,frameworks:Object.keys(o.frameworksCache??{}),libVersion:o.libVersion??"dev"}),de}async function Wl(n){let{readdir:e}=await import("node:fs/promises");try{return(await e(n.agentsRoot)).length>0}catch{return!1}}function yr(n){return n.length<=8?"***":`${n.slice(0,4)}***${n.slice(-4)}`}function mc(n,e,s){return`${n??""}|${e??""}|${s??""}`}async function Jl(n,e){let{readdir:s}=await import("node:fs/promises"),o;try{o=await s(n.agentsRoot)}catch{return}let{loadAgentConfig:c,enforceAgentConfigMode:d}=await Promise.resolve().then(()=>(nt(),kn));for(let u of o){await d(u,n).catch(l=>M.warn("enforceAgentConfigMode failed (ignored)",{agentId:u,err:String(l)}));try{let l=await c(u,n);l?.disconnectedAt&&(e.disconnectedAgents.add(u),M.info("agent marked disconnected on startup",{agentId:u,disconnectedAt:l.disconnectedAt,reason:l.disconnectReason??""}))}catch(l){M.warn("failed to load agent config on startup, skipping",{agentId:u,err:String(l)})}}}async function $l(n,e,s,o,c){let{loadAgentConfig:d}=await Promise.resolve().then(()=>(nt(),kn)),u=await d(n,e);if(u){M.info("--agent-id: local config found, reconnecting",{agentId:n,framework:u.framework,hadDisconnect:!!u.disconnectedAt});let _={agentId:u.agentId,framework:u.framework,...u.cozeIdentity?{cozeIdentity:u.cozeIdentity}:{},...u.model?{model:u.model}:{},...c?{patToken:c}:{}};return await s.createAgent(_),{ok:!0,agentId:n,note:u.disconnectedAt?"revived from local config":"connected from local config"}}M.info("--agent-id: local config missing, pulling _agent/detail from cloud",{agentId:n});let l=await o({_meta:{cozeAgentId:n}});if(!l.framework)throw new S("AGENT_NOT_FOUND",`agent ${n} \u4E0D\u5728\u672C\u5730; \u4E91\u7AEF _agent/detail \u54CD\u5E94\u7F3A framework \u5B57\u6BB5 (D36 \u534F\u8BAE\u6269\u5C55\u672A\u751F\u6548), \u65E0\u6CD5\u5728\u672C\u673A\u65B0\u5EFA`);let p={agentId:l.agentId,framework:l.framework,...l.cozeIdentity?{cozeIdentity:l.cozeIdentity}:{},...l.model?{model:l.model}:{},...c?{patToken:c}:{},...l.deployType?{_meta:{cozeDeployType:l.deployType}}:{}};await s.createAgent(p);let m=l.deployType==="cloud"&&l.framework==="openclaw";return{ok:!0,agentId:n,note:m?"cloud agent acknowledged":"created from cloud detail"}}async function br(n,e){let{readdir:s}=await import("node:fs/promises"),o;try{o=await s(n.agentsRoot)}catch{return{revived:0,skipped:0,total:0}}if(o.length===0)return{revived:0,skipped:0,total:0};let{loadAgentConfig:c}=await Promise.resolve().then(()=>(nt(),kn));M.info("auto-revive: scanning local agents on startup",{count:o.length});let d=0,u=0;for(let l of o){let p;try{p=await c(l,n)}catch(m){M.warn("auto-revive: load config failed (skipping)",{agentId:l,err:String(m)}),u+=1;continue}if(!p){u+=1;continue}if(p.disconnectedAt){M.info("auto-revive: skip disconnected agent",{agentId:l,disconnectedAt:p.disconnectedAt}),u+=1;continue}try{M.info("auto-revive: re-registering agent (D44 no spawn)",{agentId:l,framework:p.framework});let m=Vl(p);await e.createAgent({agentId:p.agentId,framework:p.framework,...p.cozeIdentity?{cozeIdentity:p.cozeIdentity}:{},...p.model?{model:p.model}:{},...m?{_meta:m}:{}}),d+=1}catch(m){M.warn("auto-revive: createAgent failed (skipping)",{agentId:l,framework:p.framework,err:String(m)}),u+=1}}return M.info("auto-revive: done",{revived:d,skipped:u,total:o.length}),{revived:d,skipped:u,total:o.length}}function Vl(n){let e={};return n.deployType&&(e.cozeDeployType=n.deployType),n.accountId&&(e.cozeAccountId=n.accountId),Object.keys(e).length>0?e:void 0}vr();Er();U();ie();Lt();U();ie();import{copyFile as yc,mkdir as sg,readFile as Ni,writeFile as og}from"node:fs/promises";import{dirname as ag,resolve as Mi,sep as Ir}from"node:path";import{fileURLToPath as cg}from"node:url";var bc=D("dist-install");function xg(n){let e=cg(n),s=ag(e),o=`${Ir}src${Ir}`;if(s.includes(o)||s.endsWith(`${Ir}src${Ir}cli`))return null;let c=Mi(s,"index.js"),d=Mi(s,"..","package.json");return{dist:c,pkgJson:d}}async function Bi(n={}){let e=n.paths??q(),s=xg(import.meta.url),o=n.sourceDist??s?.dist,c=n.sourcePackageJson??s?.pkgJson;if(!o||!c)return{kind:"dev-mode-skip",reason:"running from src/(tsx loader);no dist/ to install"};let d;try{d=JSON.parse(await Ni(c,"utf8")).version??"unknown"}catch(y){return bc.warn("cannot read source package.json,skip dist install",{err:String(y)}),{kind:"dev-mode-skip",reason:`package.json read failed: ${String(y)}`}}let u=await at(e.configFile)??{},l=u.libVersion;if(l===d)try{return await Ni(e.libEntry),{kind:"already-current",libVersion:d}}catch{}await sg(e.libDir,{recursive:!0}),await yc(o,e.libEntry),await yc(`${o}.map`,`${e.libEntry}.map`).catch(()=>{});let p=Mi(e.libDir,"package.json"),m=`${JSON.stringify({type:"module"},null,2)}
|
|
128
|
+
`;return await Ni(p,"utf8").catch(()=>null)!==m&&await og(p,m),u.libVersion=d,await ze(u,e.configFile),bc.info("dist installed",{libEntry:e.libEntry,fromVersion:l,toVersion:d}),l?{kind:"version-changed",fromVersion:l,toVersion:d,libEntry:e.libEntry}:{kind:"first-install",libVersion:d,libEntry:e.libEntry}}Er();ie();import{basename as dg,resolve as ug}from"node:path";var fg=9e4,lg={PATH_OUTSIDE_WORKSPACE:3,FILE_TOO_LARGE:3,UNSUPPORTED_MIME:3,IPC_BAD_REQUEST:3,AGENT_NOT_FOUND:4,IPC_AUTH_FAILED:4,AGENT_DISCONNECTED:5,UPLOAD_FAILED:5,UPSTREAM_NOT_READY:5,UPSTREAM_DISCONNECTED:5,UPSTREAM_HANDSHAKE_FAILED:5,AGENT_BUSY:1,AGENT_SPAWN_FAILED:1,AGENT_TIMEOUT:1,AGENT_PROTOCOL_ERROR:1,BRIDGE_CONFIG_INVALID:1,BRIDGE_INTERNAL:1,MODEL_TOKEN_GEN_FAILED:1,OPERATION_NOT_ALLOWED_FOR_LOCAL:1,BRIDGE_UPGRADING:5};function gg(n){return lg[n]??1}async function vc(n,e={}){let s=e.paths??q();if(!n.agentId||!n.sessionId)return process.stderr.write(`Error: missing --agent-id and/or --session-id. These IDs come from the <coze-context> block injected at the top of each prompt \u2014 extract agentId and sessionId from there and pass them as flags. Example: coze-bridge send image x.png --agent-id <id> --session-id <id>
|
|
129
|
+
`),4;let o=await Sr(s).catch(()=>null);if(!o)return process.stderr.write(`Error: coze-bridge daemon not running (cannot read ${s.portFile} / ${s.tokenFile}). Make sure you are inside an agent session spawned by the daemon.
|
|
130
|
+
`),4;let c={agentId:n.agentId,sessionId:n.sessionId,kind:n.kind,path:ug(process.cwd(),n.path),...n.caption?{caption:n.caption}:{},...n.name?{name:n.name}:{}},d;try{d=await hg(o,"/agent/send",c,fg)}catch(u){return process.stderr.write(`Error: daemon IPC failed: ${u instanceof Error?u.message:String(u)}
|
|
131
|
+
`),4}if(!d.ok)return process.stderr.write(`Error: ${d.code}: ${d.message}
|
|
132
|
+
`),gg(d.code);if(n.json)process.stdout.write(`${JSON.stringify(d)}
|
|
133
|
+
`);else{let u=n.name??dg(c.path);process.stdout.write(`Sent ${n.kind} ${u} (${pg(d.bytes)})
|
|
134
|
+
`)}return 0}async function hg(n,e,s,o){let c=new AbortController,d=setTimeout(()=>c.abort(),o);try{let u=await fetch(`http://127.0.0.1:${n.port}${e}`,{method:"POST",headers:{Authorization:`Bearer ${n.token}`,"content-type":"application/json"},body:JSON.stringify(s),signal:c.signal}),l=await u.text(),p=l?JSON.parse(l):null;return p&&typeof p=="object"&&"ok"in p?p:{ok:!1,code:"BRIDGE_INTERNAL",message:`unexpected daemon response (status=${u.status}): ${l.slice(0,200)}`}}finally{clearTimeout(d)}}function pg(n){return n<1024?`${n}B`:n<1024*1024?`${(n/1024).toFixed(1)}KB`:`${(n/1024/1024).toFixed(1)}MB`}var Oc=D("cli");function he(n,e){let s=[],o;for(let c=0;c<n.length;c++){let d=n[c];if(d===e){o=n[c+1],c+=1;continue}if(d.startsWith(`${e}=`)){o=d.slice(e.length+1);continue}s.push(d)}return{value:o,rest:s}}function Gg(n){let e=n.slice(2);if(e.includes("--version")||e.includes("-v"))return{mode:"version"};if(e.includes("--daemon"))return{mode:"daemon"};if(e.includes("--status"))return{mode:"status"};if(e.includes("--stop"))return{mode:"stop"};if(e.includes("--refresh"))return{mode:"refresh"};if(e.includes("--uninstall"))return{mode:"uninstall"};if(e.includes("--install-service"))return{mode:"install-service"};if(e.includes("--upgrade-helper")){let P=e.filter(se=>se!=="--upgrade-helper"),{value:j,rest:Q}=he(P,"--target-version"),{value:K}=he(Q,"--old-pid"),$=K?Number.parseInt(K,10):Number.NaN;return!j||!Number.isFinite($)?{mode:"help"}:{mode:"upgrade-helper",targetVersion:j,oldPid:$}}if(e[0]==="send")return Wg(e.slice(1));if(e[0]==="connect")return Jg(e.slice(1));if(e.includes("--help")||e.includes("-h")||e.length===0)return{mode:"help"};let s=e,{value:o,rest:c}=he(s,"--pat-token");s=c;let{value:d,rest:u}=he(s,"--pair-code");s=u;let{value:l,rest:p}=he(s,"--env");s=p;let{value:m,rest:_}=he(s,"--handshake-url");s=_;let{value:y,rest:I}=he(s,"--frontier-url");s=I;let{value:L}=he(s,"--agent-id");if(!o||!d)return{mode:"help"};let T={mode:"pair",privatecode:o,pairingCode:d};return l&&(T.env=l),m&&(T.handshakeUrl=m),y&&(T.frontierUrl=y),L&&(T.agentId=L),T}function Wg(n){let e=n[0],s=n[1];if(e!=="image"&&e!=="file")return{mode:"help"};if(!s||s.startsWith("--"))return{mode:"help"};let o=n.slice(2),{value:c,rest:d}=he(o,"--caption");o=d;let{value:u,rest:l}=he(o,"--name");o=l;let{value:p,rest:m}=he(o,"--agent-id");o=m;let{value:_,rest:y}=he(o,"--session-id");o=y;let I=o.includes("--json"),L={mode:"send",kind:e,path:s,json:I};return c&&(L.caption=c),u&&(L.name=u),p&&(L.agentId=p),_&&(L.sessionId=_),L}function Jg(n){let e=n,{value:s,rest:o}=he(e,"--pat-token");e=o;let{value:c,rest:d}=he(e,"--env");e=d;let{value:u,rest:l}=he(e,"--handshake-url");e=l;let{value:p}=he(e,"--frontier-url"),m={mode:"connect"};return s&&(m.privatecode=s),c&&(m.env=c),u&&(m.handshakeUrl=u),p&&(m.frontierUrl=p),m}var $g=`
|
|
133
135
|
coze-bridge - local bridge daemon for cloud Agent Service
|
|
134
136
|
|
|
135
137
|
Usage:
|
|
@@ -170,43 +172,46 @@ Send file / image (D72; intended to be called by LLM inside agent bash tool):
|
|
|
170
172
|
|
|
171
173
|
Internal:
|
|
172
174
|
<node> <entry> --daemon daemon mode (OS supervisor only)
|
|
173
|
-
|
|
174
|
-
|
|
175
|
-
|
|
175
|
+
<node> <entry> --upgrade-helper --target-version=<v> --old-pid=<pid>
|
|
176
|
+
D82 self-update helper
|
|
177
|
+
(UpgradeManager \u5185\u90E8 fork)
|
|
178
|
+
`.trimStart();async function Nc(n=process.argv,e={}){let s=Gg(n);switch(s.mode){case"help":return process.stdout.write($g),0;case"version":return process.stdout.write(`${rt}
|
|
179
|
+
`),0;case"daemon":{try{await wc()}catch(o){return Oc.error("daemon start failed",{err:String(o)}),1}return new Promise(()=>{})}case"status":return Vg(e);case"stop":return Yg(e);case"refresh":return Xg(e);case"uninstall":return Qg(e);case"install-service":return Zg();case"pair":{let o={};return s.env&&(o.env=s.env),s.handshakeUrl&&(o.handshakeUrl=s.handshakeUrl),s.frontierUrl&&(o.frontierUrl=s.frontierUrl),eh(s.privatecode,s.pairingCode,e,o,s.agentId)}case"connect":{let o={};return s.env&&(o.env=s.env),s.handshakeUrl&&(o.handshakeUrl=s.handshakeUrl),s.frontierUrl&&(o.frontierUrl=s.frontierUrl),th(s.privatecode,e,o)}case"upgrade-helper":{let{runUpgradeHelper:o}=await Promise.resolve().then(()=>(Pc(),Cc));return await o({targetVersion:s.targetVersion,oldPid:s.oldPid,...e.paths?{paths:e.paths}:{}})}case"send":return vc({kind:s.kind,path:s.path,...s.agentId?{agentId:s.agentId}:{},...s.sessionId?{sessionId:s.sessionId}:{},...s.caption?{caption:s.caption}:{},...s.name?{name:s.name}:{},json:s.json},e)}}async function Mc(n){let{unlink:e}=await import("node:fs/promises");await Promise.all([e(n.pidFile).catch(()=>{}),e(n.portFile).catch(()=>{}),e(n.tokenFile).catch(()=>{})])}async function Vg(n){let e=n.paths??q(),s=new Le(e),o=await s.probe();if(o.kind==="not-running")return process.stdout.write(`coze-bridge: not running
|
|
180
|
+
`),1;if(o.kind==="stale")return await Mc(e),process.stdout.write(`coze-bridge: not running (cleaned stale state)
|
|
176
181
|
`),1;let c=await s.request({method:"GET",path:"/status"});return process.stdout.write(`coze-bridge: running
|
|
177
182
|
${JSON.stringify(c.body,null,2)}
|
|
178
|
-
`),0}async function
|
|
179
|
-
`),0;if(o.kind==="stale")return await
|
|
183
|
+
`),0}async function Yg(n){let e=n.paths??q(),s=new Le(e),o=await s.probe();if(o.kind==="not-running")return process.stdout.write(`coze-bridge: not running
|
|
184
|
+
`),0;if(o.kind==="stale")return await Mc(e),process.stdout.write(`coze-bridge: not running (cleaned stale state)
|
|
180
185
|
`),0;try{return await s.request({method:"POST",path:"/shutdown"}),process.stdout.write(`coze-bridge: stopped
|
|
181
186
|
`),0}catch(c){return process.stdout.write(`coze-bridge: stop failed: ${String(c)}
|
|
182
|
-
`),1}}async function
|
|
187
|
+
`),1}}async function Xg(n){let e=new Le(n.paths);if((await e.probe()).kind==="not-running")return process.stdout.write(`coze-bridge: not running (start daemon first)
|
|
183
188
|
`),1;try{let o=await e.request({method:"POST",path:"/refresh"});return o.status===200?(process.stdout.write(`coze-bridge: refreshed
|
|
184
189
|
${JSON.stringify(o.body,null,2)}
|
|
185
190
|
`),0):(process.stderr.write(`coze-bridge: refresh failed: ${JSON.stringify(o.body)}
|
|
186
191
|
`),1)}catch(o){return process.stderr.write(`coze-bridge: refresh failed: ${String(o)}
|
|
187
|
-
`),1}}async function
|
|
188
|
-
`);try{await e.request({method:"POST",path:"/shutdown"})}catch(
|
|
189
|
-
`)}await new Promise(
|
|
190
|
-
`)}catch(
|
|
192
|
+
`),1}}async function Qg(n){let e=new Le(n.paths);if((await e.probe()).kind==="connected"){process.stdout.write(`coze-bridge: stopping daemon...
|
|
193
|
+
`);try{await e.request({method:"POST",path:"/shutdown"})}catch(d){process.stderr.write(`coze-bridge: stop failed (continuing): ${String(d)}
|
|
194
|
+
`)}await new Promise(d=>setTimeout(d,500))}if(!n.skipSupervisor)try{let{getSupervisor:d,buildContext:u}=await Promise.resolve().then(()=>(Wi(),Gi)),l=d();await l.uninstall(u()),process.stdout.write(`coze-bridge: ${l.platform} supervisor unregistered
|
|
195
|
+
`)}catch(d){process.stderr.write(`coze-bridge: supervisor uninstall failed (continuing): ${String(d)}
|
|
191
196
|
`)}let o=n.paths??q(),{rm:c}=await import("node:fs/promises");try{await c(o.cozeRoot,{recursive:!0,force:!0}),process.stdout.write(`coze-bridge: removed ${o.cozeRoot}
|
|
192
|
-
`)}catch(
|
|
197
|
+
`)}catch(d){return process.stderr.write(`coze-bridge: remove failed: ${String(d)}
|
|
193
198
|
`),1}return process.stdout.write(`coze-bridge: uninstalled
|
|
194
|
-
`),0}async function
|
|
199
|
+
`),0}async function Zg(){try{let{getSupervisor:n,buildContext:e}=await Promise.resolve().then(()=>(Wi(),Gi)),s=n(),o=e();return process.stdout.write(`coze-bridge: installing ${s.platform} supervisor...
|
|
195
200
|
`),await s.install(o),process.stdout.write(`coze-bridge: supervisor installed (daemon will auto-start on login)
|
|
196
201
|
`),0}catch(n){return process.stderr.write(`coze-bridge: --install-service failed: ${String(n)}
|
|
197
|
-
`),1}}async function
|
|
198
|
-
`),(await
|
|
199
|
-
`)}let l=await
|
|
200
|
-
`),await u({paths:s.paths}),l=await
|
|
201
|
-
`),1;let
|
|
202
|
-
`),0):(process.stderr.write(`coze-bridge: pair failed: ${JSON.stringify(
|
|
203
|
-
`),1)}catch(
|
|
204
|
-
`),1}}async function
|
|
205
|
-
`),(await
|
|
206
|
-
`)}let l=await
|
|
207
|
-
`),await u({paths:e.paths}),l=await
|
|
208
|
-
`),1;let
|
|
209
|
-
`),await
|
|
210
|
-
`),1)}catch(
|
|
211
|
-
`),1}}async function
|
|
202
|
+
`),1}}async function eh(n,e,s,o={},c){let d=new Le(s.paths),u=s.spawnDaemon??pn;if(!s.skipDistInstall){let m=await Bi({paths:s.paths});m.kind==="version-changed"?(process.stdout.write(`coze-bridge: upgraded ${m.fromVersion} \u2192 ${m.toVersion}
|
|
203
|
+
`),(await d.probe()).kind==="connected"&&(await d.request({method:"POST",path:"/shutdown"}).catch(()=>{}),await new Promise(y=>setTimeout(y,500)))):m.kind==="first-install"&&process.stdout.write(`coze-bridge: installed ${m.libVersion}
|
|
204
|
+
`)}let l=await d.probe();if(l.kind!=="connected"&&(process.stdout.write(`coze-bridge: starting daemon...
|
|
205
|
+
`),await u({paths:s.paths}),l=await Bc(d,s.waitTimeoutMs??1e4,s.sleep??zc),l.kind!=="connected"))return process.stderr.write(`coze-bridge: daemon did not come up: ${l.kind}
|
|
206
|
+
`),1;let p={privatecode:n,pairing_code:e};o.env&&(p.env=o.env),o.handshakeUrl&&(p.handshake_url=o.handshakeUrl),o.frontierUrl&&(p.frontier_url=o.frontierUrl),c&&(p.agent_id=c);try{let m=await d.request({method:"POST",path:"/pair",body:p,timeoutMs:35e3});return m.status===200&&m.body?.ok?(process.stdout.write(`coze-bridge: paired (${m.body.note??"ok"})
|
|
207
|
+
`),0):(process.stderr.write(`coze-bridge: pair failed: ${JSON.stringify(m.body)}
|
|
208
|
+
`),1)}catch(m){return process.stderr.write(`coze-bridge: pair failed: ${String(m)}
|
|
209
|
+
`),1}}async function th(n,e,s={}){let o=e.paths??q(),c=n??await dc(o);if(!c)return process.stderr.write("coze-bridge: \u627E\u4E0D\u5230 patToken \u2014 \u5148\u8DD1\u4E00\u6B21 `coze-bridge --pat-token=<sat_xxx> --pair-code=<xxx>` \u914D\u5BF9, \u6216\u672C\u6B21\u7528 `--pat-token` \u6307\u5B9A\n"),1;let d=new Le(e.paths),u=e.spawnDaemon??pn;if(!e.skipDistInstall){let m=await Bi({paths:e.paths});m.kind==="version-changed"?(process.stdout.write(`coze-bridge: upgraded ${m.fromVersion} \u2192 ${m.toVersion}
|
|
210
|
+
`),(await d.probe()).kind==="connected"&&(await d.request({method:"POST",path:"/shutdown"}).catch(()=>{}),await new Promise(y=>setTimeout(y,500)))):m.kind==="first-install"&&process.stdout.write(`coze-bridge: installed ${m.libVersion}
|
|
211
|
+
`)}let l=await d.probe();if(l.kind!=="connected"&&(process.stdout.write(`coze-bridge: starting daemon...
|
|
212
|
+
`),await u({paths:e.paths}),l=await Bc(d,e.waitTimeoutMs??1e4,e.sleep??zc),l.kind!=="connected"))return process.stderr.write(`coze-bridge: daemon did not come up: ${l.kind}
|
|
213
|
+
`),1;let p={privatecode:c};s.env&&(p.env=s.env),s.handshakeUrl&&(p.handshake_url=s.handshakeUrl),s.frontierUrl&&(p.frontier_url=s.frontierUrl);try{let m=await d.request({method:"POST",path:"/connect",body:p,timeoutMs:35e3});return m.status===200&&m.body?.ok?(process.stdout.write(`coze-bridge: connected (${m.body.note??"ok"})
|
|
214
|
+
`),await hn(c,o).catch(_=>Oc.warn("writePatToken after connect failed (ignored)",{err:String(_)})),0):(process.stderr.write(`coze-bridge: connect failed: ${JSON.stringify(m.body)}
|
|
215
|
+
`),1)}catch(m){return process.stderr.write(`coze-bridge: connect failed: ${String(m)}
|
|
216
|
+
`),1}}async function Bc(n,e,s){let o=Date.now()+e;for(;Date.now()<o;){let c=await n.probe(500);if(c.kind==="connected")return c;await s(200)}return n.probe(500)}function zc(n){return new Promise(e=>setTimeout(e,n))}Nc(process.argv).then(n=>process.exit(n),n=>{process.stderr.write(`fatal: ${n instanceof Error?n.stack??n.message:String(n)}
|
|
212
217
|
`),process.exit(1)});
|