coze-bridge 0.1.61 → 0.1.63
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 +71 -71
- 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 L0=Object.create;var
|
|
9
|
-
`):q0.write(`${
|
|
10
|
-
`)}function
|
|
11
|
-
`,a=`${n}.tmp-${process.pid}-${Math.random().toString(36).slice(2,10)}`;try{i?.mode!==void 0?await Ts(a,o,{encoding:"utf8",mode:i.mode}):await Ts(a,o,"utf8"),await Cs(a,n),i?.mode!==void 0&&await nx(n,i.mode)}catch(x){await Cs(a,a).catch(()=>{});let{rm:u}=await import("node:fs/promises");throw await u(a,{force:!0}).catch(()=>{}),x}}var On=ke(()=>{"use strict"});import{promises as ks}from"node:fs";import{homedir as ox}from"node:os";import{sep as ax,join as le,resolve as Ds}from"node:path";function q(n){let e=n??ox(),i=le(e,".coze"),o=le(i,"bridge"),a=le(o,"lib");return{cozeRoot:i,bridgeRoot:o,libDir:a,libEntry:le(a,"index.js"),binDir:le(o,"bin"),pidFile:le(o,"bridge.pid"),portFile:le(o,"bridge.port"),tokenFile:le(o,"bridge.token"),patTokenFile:le(o,"pat-token"),logFile:le(o,"bridge.log"),installLock:le(o,"install.lock"),configFile:le(o,"config.json"),agentsRoot:le(i,"agents")}}function Xe(n,e=q()){let i=le(e.agentsRoot,n);return{root:i,config:le(i,"config.json"),workspace:le(i,"workspace"),logs:le(i,"logs")}}async function Rs(n,e){let i=await ks.realpath(Ds(n)).catch(()=>null);if(!i)return!1;let o=await ks.realpath(Ds(e)).catch(()=>null);if(!o)return!1;let a=process.platform==="win32"?i.toLowerCase():i,x=process.platform==="win32"?o.toLowerCase():o;return a===x||a.startsWith(x+ax)}var ae=ke(()=>{"use strict"});var Bn={};Xr(Bn,{AGENT_CONFIG_FILE_MODE:()=>Ln,enforceAgentConfigMode:()=>dx,loadAgentConfig:()=>pe,persistAgentSessions:()=>Zr,persistAgentSkills:()=>Mn,saveAgentConfig:()=>Ee});import{chmod as cx,stat as xx}from"node:fs/promises";function pe(n,e){return Lt(Xe(n,e).config)}function Ee(n,e){return Nn(Xe(n.agentId,e).config,n,{mode:Ln})}async function dx(n,e){if(process.platform==="win32")return;let i=Xe(n,e).config;try{let o=await xx(i);if(!o.isFile())return;let a=o.mode&511;a!==Ln&&(await cx(i,Ln),Ns.warn("agent config mode auto-corrected to 0600",{path:i,from:a.toString(8)}))}catch(o){if(o.code==="ENOENT")return;Ns.warn("enforceAgentConfigMode: chmod failed (ignored)",{path:i,err:String(o)})}}async function Zr(n,e,i){let o=await pe(n,i);o&&(o.sessions=Object.fromEntries(e),await Ee(o,i))}async function Mn(n,e,i){let o=await pe(n,i);o&&(o.skills=e,await Ee(o,i))}var Ns,Ln,dt=ke(()=>{"use strict";On();U();ae();Ns=D("agent-config"),Ln=384});function Ro(n){let e=n?.sessionIdleTimeoutMs;return typeof e!="number"||!Number.isFinite(e)||e<=0?eu:e}function gt(n){return Lt(n??q().configFile)}function He(n,e){return Nn(e??q().configFile,n)}var eu,Kt=ke(()=>{"use strict";On();ae();eu=10*6e4});var sa=ve(Q=>{"use strict";var C=R;(function(n,e){let i=R,o=n();for(;;)try{if(-parseInt(i(1023))/1+parseInt(i(1137))/2+parseInt(i(1754))/3*(-parseInt(i(1344))/4)+parseInt(i(1205))/5*(-parseInt(i(1270))/6)+parseInt(i(1014))/7*(-parseInt(i(1616))/8)+-parseInt(i(1186))/9*(parseInt(i(1265))/10)+parseInt(i(749))/11===e)break;o.push(o.shift())}catch{o.push(o.shift())}})(ur,282130);var Qu=Object[C(760)+"operty"],ef=Object["getOwnPr"+C(922)+C(856)],ea=(n,e)=>function(){return n&&(e=(0,n[{MMiTt:function(x,u){return x(u)}}[C(873)](ef,n)[0]])(n=0)),e},tf=(n,e)=>{let i={FhRyz:function(a,x,u,f){return a(x,u,f)}};for(var o in e)i.FhRyz(Qu,n,o,{get:e[o],enumerable:!0})};function nf(){return Vo||(Vo=[IDBDatabase,IDBObjectStore,IDBIndex,IDBCursor,IDBTransaction])}function rf(){let n=C;return Yo||(Yo=[IDBCursor.prototype.advance,IDBCursor[n(1037)+"e"][n(1868)],IDBCursor[n(1037)+"e"][n(1868)+n(1457)+"ey"]])}function sf(n){let e=C,i={CrFWd:function(a,x){return a!==x},Wbdzx:"qJevQ",clzvT:function(a,x){return a(x)},BRkJR:function(a){return a()},KuvVC:e(709),hbhGy:function(a,x){return a!==x},btFAr:e(1275),cgFSQ:function(a,x){return a(x)},yzWao:function(a,x,u){return a(x,u)},oqYbd:e(1609),RRCpT:"close",MLWnH:function(a,x){return a instanceof x}},o=new Promise((a,x)=>{let u=e,f={whfeX:i[u(889)],rqysk:function(_,S){return i[u(683)](_,S)},afDrK:i[u(847)],IadrY:u(1329),plkDy:function(_,S){return i[u(1768)](_,S)},EMtFN:function(_){return _()},TzJKO:function(_,S,E){return i[u(1425)](_,S,E)},RLruN:i[u(972)],yZQmZ:i[u(650)]},g=()=>{let _=u;n["removeEv"+_(1932)+_(903)](f.whfeX,m),n[_(707)+"entListe"+_(903)](_(1609),y)},m=()=>{let _=u;if(f[_(768)](f.afDrK,f[_(773)]))f[_(2009)](a,f[_(2009)](je,n.result)),f[_(1835)](g);else{let S={xwEjp:function(E,A){return E(A)}};return function(...E){let A=_;return _0x56b9cc[A(1389)](S[A(1440)](_0x2fc31a,this),E),S.xwEjp(_0x9774eb,_0x25c8e3[A(2007)](this))}}},y=()=>{let _=u;if(i[_(558)](i.Wbdzx,i[_(1666)])){let S={CNOby:function(E,A,T){return f[_(1450)](E,A,T)},OlWth:f.RLruN,OHkGm:f[_(1594)]};_0xade71c.resolve()[_(1098)](()=>{let E=_,A=S[E(948)](_0x11aa2e,S[E(1846)],{message:this[E(448)+E(549)+E(1880)](_0x1addad)});this.emit(S[E(1846)],A);let T=S[E(948)](_0x5abded,S.OHkGm,{reason:this[E(448)+E(549)+E(1880)](_0x47781e)});this[E(2008)](S[E(482)],T)})}else i[_(1747)](x,n[_(1609)]),i[_(552)](g)};n[u(1424)+u(826)](i.KuvVC,m),n["addEvent"+u(826)](i.oqYbd,y)});return o[e(1098)](a=>{let x=e;i.MLWnH(a,IDBCursor)&&pi[x(833)](a,n)}).catch(()=>{}),xr.set(o,n),o}function of(n){let e=C,i={wtvvB:e(747),oZLaT:e(1609),BOMnZ:e(658),pwlVn:function(a,x){return a===x},wfFWK:e(939),pfaFs:function(a){return a()},VoWkO:function(a,x){return a(x)},oAuTv:e(868)+"or"};if(cr.has(n))return;let o=new Promise((a,x)=>{let u=e,f={ZmJFl:function(_,S){return i[R(1318)](_,S)},twqec:i[u(1708)]},g=()=>{let _=u;n[_(707)+_(1932)+_(903)](i.wtvvB,m),n[_(707)+"entListener"](i.oZLaT,y),n[_(707)+_(1932)+_(903)](i[_(985)],y)},m=()=>{let _=u;i[_(1097)](i.wfFWK,i[_(894)])?(i[_(766)](a),i[_(766)](g)):(this[_(1204)+_(789)][_(720)](),this._messageQueue[_(684)](_0x2b00ae))},y=()=>{let _=u;f[_(1593)](x,n[_(1609)]||new DOMException(f.twqec,f.twqec)),g()};n.addEventListener(i[u(1042)],m),n[u(1424)+"Listener"](i[u(1580)],y),n["addEvent"+u(826)](i.BOMnZ,y)});cr[e(833)](n,o)}function af(n){dr={VBvhf:function(i,o){return i(o)}}.VBvhf(n,dr)}function cf(n){let e=C,i={wkfKz:function(o,a){return o!==a},KfGZq:e(1041),PQqdF:function(o,a){return o(a)},PmsnX:function(o,a){return o>a},PCvuN:e(1456)+e(1738)+"e",AAbvy:function(o,a){return o>=a},pFfse:function(o,a){return o&a},HMbfc:function(o,a){return o===a},EPXBS:e(1899),cSyay:e(445),krqVQ:function(o,a){return o instanceof a},bRSaG:e(1261)+e(1185)+e(1020),wlfpC:"applicat"+e(987),PULmt:e(1206)+"e",aNikv:"binary",eqwvK:function(o,a,x,u){return o(a,x,u)},jBcVT:function(o,a){return o===a},UTjfU:function(o,a){return o in a},hVBLz:"objectStoreNames",oxbPB:"CyIyd"};if(i[e(1059)](n,IDBDatabase[e(1037)+"e"][e(1192)+e(1856)])&&!i[e(1241)](i[e(685)],IDBTransaction.prototype))return function(o,...a){let x=e,u={bxaMX:function(f,g){return f||g}};if(i[x(1411)]("JhwRp",i.KfGZq)){let f=this[x(1945)][x(629)](this._prefix),g=_0x24a9f2[x(1263)](u[x(1016)](f,"{}"));return g[_0x5a9a64]=void 0,this[x(1945)].setItem(this[x(499)],_0x31ee48[x(1990)+"y"](g))}else{let f=n[x(1664)](i[x(531)](pn,this),o,...a);return hi[x(833)](f,o.sort?o[x(1870)]():[o]),i[x(531)](je,f)}};if(rf().includes(n)){if(i.jBcVT(i[e(886)],i[e(886)]))return function(...o){let a=e,x={DLHjQ:function(u,f){return i[R(1120)](u,f)},SSlgs:i.PCvuN,NhehY:function(u,f){return i.AAbvy(u,f)},oDLxy:function(u,f){return i.pFfse(u,f)},yvUzn:function(u,f,g,m){return u(f,g,m)},qgYRW:function(u,f){return u+f}};if(i[a(1996)](i.EPXBS,i.cSyay)){if(x[a(865)](_0x5b75d3,_0x19ab2f))throw new _0x111003(x[a(831)]);let u=3;for(;x[a(1778)](u,0);){let f=x.oDLxy(255,_0x5eb5f0);x[a(475)](_0x38bca8,f,_0x2e38b5,x.qgYRW(_0x12e362,u)),_0x479355>>>=8,u--}return x[a(1556)](_0x19ff14,4)}else return n[a(1389)](pn(this),o),i[a(531)](je,pi.get(this))};if(_0x1d8aff[e(1959)]instanceof _0x991001){let o=i[e(1408)](this[e(1539)]["payloadE"+e(1570)],_0x511b52)?{force:!!this[e(1539)][e(609)+e(1570)][e(1581)],encoding:this[e(1539)]["payloadE"+e(1570)].encoding?this._options[e(609)+e(1570)][e(1739)][e(943)](/\s/g,"")[e(1712)+e(1874)]():""}:{force:!1,encoding:this[e(1539)][e(609)+"ncoding"]?this._options[e(609)+e(1570)].replace(/\s/g,"")[e(1712)+e(1874)]():""},a=_0x22f99d[e(609)+e(1570)]?_0x2d4c44[e(609)+e(1570)][e(943)](/\s/g,"")[e(1712)+e(1874)]():"",x=i[e(1408)](this._options[e(1060)+e(1298)],_0x2c4ed2)?{force:!!this[e(1539)][e(1060)+e(1298)][e(1581)],type:this[e(1539)][e(1060)+e(1298)].type?this._options.payloadType.type[e(943)](/\s/g,"").toLowerCase():""}:{force:!1,type:this[e(1539)][e(1060)+e(1298)]?this[e(1539)][e(1060)+e(1298)][e(943)](/\s/g,"")[e(1712)+e(1874)]():""},u=_0x4b2202["payloadT"+e(1298)]?_0x1ccb83[e(1060)+e(1298)][e(943)](/\s/g,"")[e(1712)+e(1874)]():"",f=x[e(1581)]?x[e(1262)]:u||x.type,g=o[e(1581)]?o[e(1739)]:a||o[e(1739)],m=[i[e(1879)],i.wlfpC,e(672)+"ion/json"+e(1105)+e(1314),e(923)],y=[i[e(1809)],i[e(1840)]];this[e(1539)][e(644)+e(1789)+e(1640)+"ad"]&&m[e(1282)](f)&&(!g||y[e(1282)](g))?_0x19debf[e(1784)+"oad"]=i[e(1055)](_0x36e907,_0x447e63[e(1959)],0,_0x1435cc[e(1959)].byteLength):_0x31a5e1["textPayl"+e(1860)]=""}else _0x4fa708["textPayl"+e(1860)]=""}return function(...o){let a=e;return i[a(531)](je,n[a(1389)](i[a(531)](pn,this),o))}}function xf(n){let e=C,i={mabCq:function(o,a){return o===a},ijNHo:"function",xzBCP:function(o,a){return o(a)},ZqMBd:function(o,a){return o instanceof a},ZzOZu:function(o,a,x){return o(a,x)},KmLlH:function(o){return o()}};return i[e(803)](typeof n,i[e(1234)])?i[e(458)](cf,n):(i[e(756)](n,IDBTransaction)&&i[e(458)](of,n),i[e(528)](ta,n,i[e(805)](nf))?new Proxy(n,dr):n)}function je(n){let e=C,i={Xqyti:function(a,x){return a>x},NXSId:function(a,x){return a instanceof x},nPZxO:function(a,x){return a(x)},YTHBy:function(a,x){return a!==x},hmdSH:function(a,x){return a!==x},mFoxQ:"yznGd",rHKzr:e(1125)};if(i[e(1737)](n,IDBRequest))return i[e(1436)](sf,n);if(or[e(1988)](n))return or[e(2007)](n);let o=xf(n);if(i[e(1679)](o,n))if(i[e(1502)](i[e(1697)],i[e(1439)]))or[e(833)](n,o),xr[e(833)](o,n);else return this["currentI"+e(1504)]==this.endpoints[e(633)]?!0:i.Xqyti(this[e(472)+"ndpointTriesCount"],this.maxRetries);return o}var ta,Vo,Yo,pi,cr,hi,or,xr,dr,pn,Xo=ea({"node_modules/idb/build/wrap-idb-value.js"(){let n=C,e={bibii:function(i,o){return i instanceof o},fOSDJ:function(i,o){return i===o},lBSyh:"done",hDrmY:n(895)+"oreNames",mhBNt:n(519),HbNEA:function(i,o){return i(o)},pLqdM:function(i,o){return i!==o},VsNOY:n(660),UhjAb:function(i,o){return i in o}};ta=(i,o)=>o.some(a=>i instanceof a),pi=new WeakMap,cr=new WeakMap,hi=new WeakMap,or=new WeakMap,xr=new WeakMap,dr={get(i,o,a){let x=n;if(e.bibii(i,IDBTransaction)){if(e[x(1710)](o,e[x(1590)]))return cr[x(2007)](i);if(o===e[x(1320)])return i["objectSt"+x(1670)]||hi[x(2007)](i);if(e[x(1710)](o,e[x(1795)]))return a[x(895)+x(1670)][1]?void 0:a[x(895)+x(1828)](a["objectSt"+x(1670)][0])}return e.HbNEA(je,i[o])},set(i,o,a){let x=n;if(e[x(968)](x(1197),"cmxbr"))_0x171cf5[x(621)+"jectStore"](_0x1bc652,{keyPath:_0x146ff9});else return i[o]=a,!0},has(i,o){let a=n;if(e[a(1710)](e[a(807)],e.VsNOY))return i instanceof IDBTransaction&&(o===e[a(1590)]||e[a(1710)](o,a(519)))?!0:e[a(1346)](o,i);this[a(667)+"rs"]={}}},pn=i=>xr.get(i)}}),na={};tf(na,{deleteDB:()=>uf,openDB:()=>df,unwrap:()=>pn,wrap:()=>je});function ur(){let n=["zxjFCw9Z","DhDQyuG","s3H6q28","C2vYDMLJzq","quXm","s2revLe","Ahr0Ca","u1jhr0m","ueXxDgu","B0f1vhy","AM9mqKy","zK9treO","CvnOu3C","Dg9mB3DLCKm","AwnLsKu","thvLB1G","rfrYAgW","zeDquNC","B2TSuNu","DeLUDgvYy2u","wgT3C2O","y3r4","AMLdy28","CMv0CNLdB3u","vuP5su8","yxGGCMv0CMK","CMvXDwLYzwq","AxnNBvG","ueXLuhm","Ag5UuLe","yw5Nzq","s1zUywm","x2nYzwf0zvm","DhbizwfKzxi","uK1MDxG","D0jou3K","A3D1EMO","BMrWB2LUDca","tLHtswq","Dg9VigXHCMC","zw5JB2rPBMC","zv90Aw1LB3u","AMvJDfn0B3i","yMLUyxj5","BhrPCgXLihq","wKrdtMW","ELfXAwi","x2rPC3bHDgm","y2X6DLq","Cw9Z","CgnkBhy","ywnmwvq","yxbWzw5Kq2G","rND6A1C","q3vZDg9Trxi","mta4mdu5mvz6q3nqyq","t1jHq2y","ihrYEsbYzwm","zgjxzLa","zxf1ywXZ","BML0AwfSAxO","Bg51BvO","BgPKrxe","zfrJq28","twLZC2LUzYa","C2vUza","C2v0zgi","lcbOB3n0BMe","yKjYBfm","y2Dgu1e","DxnLCKLW","A2v5CW","wKHOs1C","ywzL","yxjYyxLIDwy","tfr3q0W","rLDt","ihzHBgLKihm","y2uGBM90igK","tMHLAfK","sLvyEfO","wMThqNG","AxPPrw8","vuLzsMm","x3bYB3rVy28","Dgv4DfbHEwW","y29UBMvJDca","m3W0Fdv8mNW","ruzhEge","Bg9IywXty28","yw5ZzM9YBvq","y1DpAgm","C3bSAxq","zMr4D1K","y0fRCKG","s0TYvMO","BwHctNq","yxnJCMLWDa","B3bLCNr5","rhz6Ag8","BvLPBLG","t0nyDwS","C0nVDw50zxi","r3vPq1K","B2nRzxq","tgjgB00","BeTIEeK","EuLhyw8","B1jjtNe","DNDXzvu","ufvmBxq","ywnRtxnNswq","AK1IyK4","Cgu6ia","t3nTDxG","tfDRDLq","yvjmr2O","Aw5KzxGGB3u","uLDVENK","z2vjBMzVu3K","t2jQzwn0","s2XzAgW","Cg9PBNrdB24","BfLwsu0","BMDLza","y3vYC29YlNm","uMP4weq","n3WZFdf8mG","CgLUz0LUDgu","B3jL","x2HHBMrSzu8","Cg9PBNrbBMq","wgfAsMW","CMvHC29U","y29UBMvJDa","DeLK","ru10rK4","t0XAEu0","uu9fsKW","rhj6EMm","r0Xiwwu","yu5PA3y","wLP4B1G","AgPuBeW","zvvYBa","z2v0u3rVCMe","vxzWDvG","t2XxDgG","Eu5YvwK","vMTkAfi","x3jLywr5q2W","Aef4u2e","Dg9Y","DMfS","r0n0zvu","vKLMrMO","DKvzzeG","Aw9U","uwjhBwG","rLrSvNG","x2rLC3rYB3K","B2fK","BMvJDa","BgvY","BwnhCwC","ywHhC28","EhfuCwu","DuLpAKS","sgXWvLu","y29UDgLUDwu","r0DjtNq","C29YDa","x2DLDeLUDgu","ywDLrxzLBNq","zNjVBu51Bwi","yxnL","wKrKr0i","zM9YrwfJAa","u2PWv1u","rKPeu3u","yLjtyuC","ywDL","AeTqtgC","CKHLz0y","C05ezeq","CMvJu2W","yKPwufe","zNDZxZeUmc4","Dg9tDhjPBMC","BuXnDeq","tg9JAW","z2v0q3vYCMu","zxjFBxnNAwq","zxn6qxq","Ahr0Chm6","yMfJA3vWigu","x2rYB3bhBg8","q0Xpu0ve","BIWGAg9ZDg4","B3v0sw50zxi","AvHlrwK","veDgzfC","Bwf4tg9ZC0m","uur3swu","whrIrum","EMrOq3y","ywnOzwqSihC","Dg9cExrLC0W","D1zQA0S","vNffr0C","ywrK","Bhm6ia","AgLNAa","B3bLBIa","Aw5KzxHpzG","rLjptLrjrvi","AwXSihvZzsa","BMCGB3iGyw4","yuj5rgq","Au9dwue","zgvIDwC","u2Duuui","y09Wzw4","rKngv2u","rfbSshq","teTrsuS","BMfbyMS","AfLZDeG","tKzdDeu","Egntu1q","rhLsyNm","FdH8m3W5","sMzlAhu","zw50tgLZDgu","DgzxruO","B25VCgvU","ruXtANK","y2XLyxi","B2nRzxrtDwm","AenSB3nLrxy","tfDUExK","n3W0Fdv8mta","zvbYv3i","yvPbBwm","zw1Wrxq","z3LMBgy","x3fVC0rc","C2DHy1y","tvvTu08","DhjPzxmGCMu","zw50","BNDhqM8","r1f2uuu","B25LCNjVCG","zejqqM4","DcbSAw1PDa","vhniqMu","zu9LBxK","r0PjuLK","sMTHB2u","Cgf5Bg9Hza","rMP6zNa","y3Ljz0q","A3zfww4","BePdB3G","CMvTB3zLq2G","Dw5RBM93BIa","vvrvwK8","rg5iEwy","DMjAANy","CgLmDxG","vNP0t0q","Cuz2DM0","D2fNr2m","zw5NDgG","Bg9N","CMvZzxruCMK","yvjgwxm","x21PBMLoyxy","x3vYBa","A1zWA0i","BMnLq2XVC2u","yKjMsg8","zvHoq2S","qvnIzui","B0zzCMu","rxjYB3jdB2q","zgrjrcWGzgu","AwrQsNy","AgfZ","AxnszwfKEq","C3rYAw5NAwy","qK1Qr0C","yLzwt3y","z2roy1i","BxHeDgy","AwrNDhy","se1IzMm","yw1L","tvD0D0W","zw5HyMXLqxu","q0PirKK","tw9KDwXL","t3bLBKv2zw4","sgrOANa","ufjhAw4","qNbSwMy","BMfTzq","z2v0","zw1PDa","CgXRrhK","zMLSzw5HBwu","A2rtDue","yxrHlcbKyxq","x2LZv29YA2u","x2zVCM1HDeu","sxfIvNO","ALH0uvO","vw5Oyw5KBgu","AwDHDg9Yt24","Avjjwu8","veXhzvq","rK54vLa","Fdj8oxWZFdG","rgvHDwu","EhPcq1a","we5fsKW","rfzIr2G","s1zyuwK","DML3yLK","r0ztt2S","BgLZDgvUtMu","uxvZDgC","DMrAy0W","y29UBMvJDeu","t2zJDu8","q09otKvdveK","s0nvELy","ruD0A0y","y3vYCMvUDeu","r1fXzeW","x3nLBMrby2S","ExzvEM4","y3jLyxrLq2W","CMvQzwn0","ywXS","tuHqEeq","Eg5sC2m","sMrTsNO","t0HRr20","AwXLx25HBwu","zKHoDuO","t2fuz0O","DvLRDxe","zwfPEhm","y3ruAw1LB3u","Du53Dfy","Cw5KCNG","zNHNzNu","y3vYC29Yx24","ze9vrLm","qwLNrfe","D3m6lY8","CgLUz0XVC3m","zvD0qMS","zeLpv0O","x3bYzwzPEa","wK5WEw0","y3n4CKm","BfDPEMW","u1veAKy","v2nzzNG","yxnZAwDU","y3jLyxrLt3a","De1HBMfNzxi","sLLXAuK","y3fTCLu","x3nLCuLK","x2LZtwLUAvC","x2rItMfTzq","x3bPBMC","A3rKBfG","x2n1CNnVCK0","t2jhvM8","sgvht0G","CMvUDevUzha","C3rVCMu","A1zPuhu","CM92AwrLigi","CMvHzhDYAxq","x2LUAxq","B2nRzxrgywK","x3bHDgHlzxK","yKv6DKK","zwHyB1e","wNPpwNu","q2LlD3e","yMrFzgLK","uffXzey","zxjYtxnN","AM9PBG","zMvY","mhW0Fdz8nxW","sxPSs1G","uNfwBfm","BeXyEwW","zMfrqMm","AMXYDfe","DgfIyxnL","Ec11C2uT","BNrbBMrvCgq","C1nQzNe","s0TSAwi","sKrRC28","B2HkuuK","sennqKW","CNjVCK1LC3m","yMXkA2q","B25dBg9Zzq","qLjRsLi","x25HDMLNyxq","C3rVqw8","vwvJEuO","yM9KEq","yNL0zuXLBMC","q3jgv2q","D1zXyxy","v0Lcu0i","z3Lsr0O","v3nsALK","ref5wKS","zgf0yq","suDHCuC","vK1Orxe","Dxrjza","D2fYAKe","Aw5PDcbrB1m","C2vYDMLJzs0","t0XzuM0","CgfNzxnOB3C","qNjPzgDL","zgPKzfK","D0PxuKu","Ce9Nthq","tg9NsurozxC","ywrKq291BNq","z2vtEw5J","vxbKyxrLq28","tuniwKG","suz4vwW","x2vUzhbVAw4","q0r3ENe","x2LZtwLUAvq","AevYCM9Yrxy","y2DUvKq","DwL2zfm","CMvJzxzPzwq","Du5KChe","B21Iz3u","B3bLBKrc","y29UC3rYDwm","qMz0zgO","BgLUzw5V","B2Horhu","AwHvsue","ve96r0e","qLPmBwC","D3zuvLi","EM51EM4","wxzfBwC","DNnzvgW","uMvHzcbWyxm","yNL0zxm","zcbLCNjVCI4","CvnRrxq","r1j6D0m","Cgf5Bg9Hzeu","zvvUsMy","qK5YC0S","igzHAwWSig0","BKvWrMW","qwTRsgS","vhz2wuO","C1rXt3e","x2HHBMrSzvi","C2vYDMvYvgK","Cw9Zx18","qKDyCw8","y3jLyxrLt2i","CgXLyxnLiha","C2v0q3vYC28","v2zryxO","zNjVBuj5Dgu","uMz3rwy","DeDUvKm","EMHzDLa","z2v0sxrLBq","BxnN","zuzfv0i","veX1CLK","BgvUz3rO","BMrIvhm","zvrxwwi","CxvZzu4","sfD0u2K","we1Izvy","C0XPC3rLBMu","wxjyAfu","z2vY","CMvHzg9UBhK","zNvUy3rPB24","zw5HyMXLvhi","tKLlzvO","zxHWB3j0CW","zMLUza","zcWGDw5RBM8","m3W0Fdj8mhW","uLjdCfq","rufezwK","zxH0zw5ZAw8","EK12r0W","zg5UAfC","ALDVAfi","vw55Bhy","r09ssw0","ywjVCNq","DKv4zM0","zwrdvhO","DwX2A0e","uxreAgO","u29vshi","u3Ptqvy","DgXntKq","AK5swKe","x2XPC3rLBMu","sKTPCxe","AxnNz2K","BMv3vMvYC2K","rhDTzwm","yxbWBgLJyxq","Bg9NsurozxC","CuTLve4","qxjgr1e","txbyzgm","yvfhy0i","tgnqCwe","zK5RB2G","y3vYC29Y","uKXsrgy","Bwf4uMv0CMK","AgjOr3K","ChvZAa","AfzcthO","q0Xpu0LorW","CNnVCL9Uyw0","zw5JB2rLrNi","D3fkzNu","ChLQzhe","CM92AwrLihC","zK5yDuy","z29PBMCGyxC","r3jZExy","DMvY","u1f4ywW","mxW0Fdj8mhW","s1n6CKS","sgfqALu","rezQCKm","uejcB3K","serNDLm","ywnmA2K","DKXuEwG","rNf1AKu","CvP5Bw0","CMvTB3zLrxy","qKf2ENG","C3vJy2vZCW","CuXjEKu","BurOuva","DxbKyxrLq3u","D21kvuW","C3Pdwxi","sKn3Dxa","qu5bDwG","vMHZyLO","yMLUyxj5vhK","Dw5ZAwDUzwq","C2HPzNq","EhzTEw0","y291BNq","ANHvwg0","BNfJuwi","ChrVCG","ALHrrg4","ruH2DNu","CNjjD3C","u2vYDMLJzvC","Bvf0zNK","y29UBMvJDgK","DMfSDwu","ruD3q20","CgfNzwHPzgu","m3WYFdr8mxW","m3WXFdj8nhW","AKD0C3u","EwvQCe8","q05ouwe","mhWXFdn8mNW","BwfW","z05msNe","A2zxBNG","D3jPDgu","z1HYtxm","r3zTz0G","y29TCgXLDgu","zv9ZDwnJzxm","odC2mdGWn3zdBxjIDG","y2nXu3i","yxrLq291BNq","qvzxwuq","CgjICdi","s2XNA3u","rerNBwO","wNfnqMq","CwXpu04","A3r2rK4","qMvbAgW","zgvMAw5Luhi","A3jKugC","zxjYtM8","C2vUDa","Eu5ytuu","x29UugfNzu4","CgzHrNm","rNPjv3O","CNf5C2S","rMHZwge","x2HHBMrSzva","CxDJz2O","ywnR","swfKCLK","q2vXAhG","Ahj2rhq","wwPRBMK","swvMtKC","DvrJyMK","vuvkBvq","yNHztg0","sLnptLa","vxvqtfq","BMjmuKu","AfDPuhi","s25prMe","sevRugi","yLzbufO","tvvZD1G","uxvLDwu","rwjktNG","CuPmEuq","EwHKzuS","vgrovMm","D24GCMvHC28","AgvHzgvYCW","rgXsBKe","Cev2vK4","DwzMyva","Bef5EMK","AhbPqu0","AxmGDw5Kzwy","EuDpD0W","BwfIq3e","q09HANe","s21mBeG","t05qDfy","vNnot1K","x3jLy29UBMu","y29UDgv4Da","v2LUzg93","Aw1LCYbPBIa","x2nSzwfYugK","zuTpCKK","DeLXChi","CYbHBhjLywq","zeztsge","t1bftG","CKHorgm","EM9Ir0i","zxvyrMS","vhnNDwu","zg9Uzq","vxzAr3O","twfUtxa","qwTPrfe","tgLZDgvUzxi","BwvY","txnZs2e","BgLUzq","serev0i","u1nSz3m","r2LgwMy","C2v0","ywDLsgLKzq","tK50ve8","zfDiq1O","swXIB0y","y3jLyxrLtwu","rgTqreC","Cvr1r0S","DgLAsge","BNL3B3u","r3LNs0G","DeP3sxu","uwLqB2u","z3byEMS","yNrgqxi","x3jLBw92zvC","wvv6qxG","ihrPBwvVDxq","x3nVy2TLDa","vwHZB1C","vMztEwW","ywXSzwqGBxu","zhjPzhy","BwvZ","v2r1D24","thjMtxa","B25SAw5L","zxjHDg9Y","CvLOrwG","uK9Lzuy","y3vYCMvUDeK","Dg9oDw1Izxi","reXiALe","t0XRtxy","werPvvG","qwjVCNrfCNi","y3jLyxrLrxi","C01qr3K","zgvSzxrL","Dg9cExrLC0i","tu1Pvhq","DLrztgC","uMvJB25Uzwm","q1bWvNa","CuXHwfm","u3P0tNa","uevsCNq","D0HmEfu","D3P2ywm","y1jlyMu","Aw5KzxG","Cunnq1G","DgvZDa","B3HIuei","CMvKDwnL","B25tDg9Wsw0","s3v2vKm","weH5yvG","thvorgW","yMfSrxzLBNq","x29Ut3bLBG","D2zgv0S","B2jQzwn0u3q","uuvpBvO","BhvmBgS","s01Srui","EeHztva","DxrVuMvJB24","y1vsD0y","u2LHwhq","BMvY","B25mAw5L","D2vI","CM92AwrLige","B3nLrxzLBNq","Dw5KzwzPBMu","C2DPza","tMfTzq","z2v0qwXS","zMLSDgvY","C2v0y3vYC28","x29UtwvZC2e","uuHlEhG","ChbIrLm","AxjLza","B3rWzvO","ugnACvC","q1HmCuu","CMvHzfvjBNq","B3bLCNr5tMe","C3rYAw5N","AhLArhm","C2nYAxb0","u3fYD1G","ywnRDxbfBMq","quLIrxm","B1vguKG","DxbNCMfKzw4","qwvvs0S","t0HwDue","thP5sxy","zw5fDMvUDa","zhPRy3y","Bwu6ia","u3rYyxrLz3K","rxzLBNq","wKXMywO","tK1XtKy","v2PUsvO","zgvSzxrLrge","CMvWBgfJzq","u0TdA0K","y29UBMvJDfm","senwsNy","y2XLyxjtDg8","q05pyNK","qNLithO","wMfutw0","ugPPB0S","D1PHCM8","AgvKtwf4uMu","sK9MDxi","yKD2ELq","CMrqExO","x3DZsw5ZDge","x29Uq2XVC2u","z2v0qwXSs2u","jMPZy2fSBgi","icSG","yLzbug8","x0rctMfTzq","s1Pdz2O","yvPSs1a","ugPAvhK","DxzfwfC","CeXXze0","v2HIsNi","BwvZC2fNzv8","zMX1C2HfEha","B3fzyMq","BNruCMLLC0m","BeHHBMrSzxi","reHRzNK","sg5iELm","DMfSDwvZ","rKfHruK","ANbgufO","suvtx0vsuK8","Ewjnqve","DhjPzxm","y2HLy2Tszwe","ruvsCfu","qK9nBLO","y3vYC29Yx2y","Aw9Ul2PZB24","rvbQAey","Dw1mBNK","zNjVBuHHC2G","x2TLEvbHDgG","sNPjA2S","shzOCNe","Cg93","B25eyNe","sNLAExi","DMvYC2LVBMm","BgjHDuO","twXxtxO","CKPOqLa","uNb2ALq","t0nzvgO","A01YBMW","tK1LBgq","zxrxB3jRq2G","vgfN","A0XeDvi","ihzHBgLKigq","Bg93","B2LUDfjLywm","ywDLu2HVDW","Aw9UvgLTzw8","Dev2zw50","nJnkCvrQu0W","A2HMs0S","yNHHtvG","BMCGDxjSoIa","rfvbvKW","vMPHEK0","zxq9DxrMltG","CLzHBhvLCW","yw1Lu3bHy2u","mtqZodzoEhDYtMi","sxjXDNu","AxbOyLG","u2vXsuq","yxKSihrYEsa","AefmA3G","qunVz0u","CKvewKO","CgvYC2LZDgu","yxPpwxa","DwvID0K","t2vbv2i","Bg9Nsurhzw4","D0nWwxu","ChjVDg90Exa","thHYueq","BLPqsxa","CKPYr3G","sMH3uNa","D3r2DKi","wML6wMy","y3r1tee","x2fKzfDZtgK","mxW0Fdn8mhW","DuLnr3i","quHxC3q","v1vAugK","wM11Cuu","AMDkreu","C0Xf","yKDvD1u","zNjVBujPDhm","zxf3DKS","ysbTDxn0igi","q3nWvxa","uwjbCM0","AKjJvLq","Cgf5Bg9Hzfq","txjhsuy","t1n2DeK","t1bftL9fuLi","v3vts0G","wuXVuwy","D0jpEwy","D1P1DLa","y0vhCgC","EhnAAvu","zxj2AwnL","ref5tw4","rM5qrxq","zgP6B3C","DgvmB2Djre4","rLvYBhq","tufyx1jfvfi","zw5KCg9PBNq","yLvgv1e","y29Kzq","DKHvqwC","sgfjEhu","CYbPBNn0yw4","B2TXzgC","ugvHwLy","zgzrtwq","y2P4EKK","BM5Ly3q","zwn0","DMLJzuLeig8","zMXVB3i","CMzOrMW","x2n1CNnVCK4","x2rPC2nVBM4","t3PxsfK","DK1cBvy","DgfYz2v0","ChDSvM4","DgHLBG","x2jPBMfYEvq","y2HLy2TdDxi","v2vIu29JA2u","BezSDxnO","yM5jBKO","reiGzMfPBgu","o2nOyxjZzxq","zNjVBNrPzxi","Bw5nr0S","AxnFywnR","uxb3DK4","v3fdwxK","rwr1tNy","rg1jBwe","D0rRtMC","BKXPBMu","zNjVBunOyxi","B25pCgvU","B3bLBG","y1zdD3y","r1bcz3G","ug1ZBLG","yxv0BW","DgLTzw91DcW","wNnlwLu","uMn3DxK","uuLXv2S","CMfTzq","C3bSAwnL","AgfUz2u","rK9QB3m","D3nZoI8V","C3zmr2m","Bu5RyKK","nNW1FdD8mxW","suzXswO","B25fCNjVCG","Ae1LC3nHz2u","nJG1mJG2uK1SCMvk","ywnRx2LK","CMTLCKDSB2i","ELnmANK","AhDzCLa","sg5Aruu","BwPQt1m","uhHxvNK","uLjpuG","DwDPrgq","DgPoyMu","whbIr0S","ihjLy29UBMu","vMjyv2G","AffJv24","zMLN","qKL1s0G","zgrZwfe","ww1Ls1m","B25tDgfYDfi","CgLUz1rPBwu","EfvZzuvUDG","v1jqsKK","tuvtu0fhrv8","yxDVB0e","EenhA20","y3jLyxrLrwW","AgfZt3DUuhi","EgDxBKC","tKDFrvjst1i","CgDSDLy","BNvTyMvY","wM14ruy","Axv2wKy","DgjOqKm","rgXYzhe","lcbxzwjtB2m","BwnIwLG","zsbHihn0CMK","Bvzorxi","BMDuAw1LCG","zgvS","A3DIz3y","tKrouuK","BunkzKq","zKHwrMu","ihbYB3rVy28","vezXExG","Aw47y2HHCNm","nJa3nZDAB3bIwgi","z3vxzeq","y2HHCKnVzgu","wMj1sLa","q2fRu2i","thPtEve","DhjHBNnHy3q","tLzetMG","tK1SuK4","B3fjt0W","swDsAeC","y214yNi","B25ozxr3B3i","x2LZsw5PDa","vxrfr3a","CNzHBfzHBhu","DxbUDg8","sg1dDum","x21LC3nHz2u","nvjZs1LcCW","BM9Uzv9UB24","Aw5N","lcbTyxGGCMu","su5vCgC","ufDiDgS","veDcqwy","EsbJBg9Zzwq","Ae9Wzw5fDMu","A2v5","tgPiC2C","t2zfCLO","quvxr3C","AefJA01LC3m","A2XiB3e","sxnQBxm","zMfwtLK","yK9wzxa","ywnRpwzYB24","y2HnyxHuCMK","DvrLC2O","vNPIvM4","Chv0","ywrKt25L","zfDVCMTLCKC","x3bPBMDqB24","AwrI","x2nSzwfYvgK","zxjFCw9Zx2e","AwPosg8","tg9Nsuq","uhD0C1m","tLb5BgS","AxnrB1nby2S","rw5Xr28","zwvKzwq","vvrQzLu","qNPPv2y","B3jpBMXPBMu","x2rLyNvN","zw50zwqGDhK","C3rHCNq","CNbmDK0","vu1QA0q","yLbSv3a","vgLTzw91Da","t2ftrvi","z1rqv3m","DMvYuuW","Fdz8mxWW","BNrLCG","u2f4t08","y0jKBe8","sMLrvgy","z1HVr3e","B2zM","Dgv4Dc9WBge","DhLWzq","CgfYC2u","rxbeuLG","mZCWzg5fsLDw","C0jf","DcbVzIbYyw4","sgDMu1C","zxjFywnRx20","nZGZmZC4vNv6we92","ihrPBwvZ","x194x21Zz18","yxv0B21HDgK","C2XPy2u","vNfYz3e","sgDOCfy","tfDqsxe","BgLTAxq","q291BNq","EefjDhq","zNjHBwvuExa","Aw5JBhvKzxm","DxrMofDYAxq","rgnsDuy","AMLtAvK","DMvUDa","C2fNzq","v1nnvey","B3vUDa","DhDVCMTdAge","A2jVEva","wNvTDNO","qwzosvq","EejNyuy","x2n1CNnVCKy","v2vPEgLUsLm","EvjLy29UBMu","ExbL","CfbAsxC","yMXVy2TLza","vfbjC2W","zgv2AwnLx2K","DNflD3K","v01lv3O","CYbWyxjHBxm","u3bWuue","uMTuqLu","reT4rNm","q1P2v08","BfrPBwvVDxq","ywnRx2nVzgu","y2XVC2uSihC","CMfNzvn5BMm","pxv0zI04","BwvZC2fNzq","qMHbyMK","DuPrD0C","vM9xA08","BMv4DcGPigm","AerYBvK","v1HNrhi","q29Kzq","zMzLCG","mNWZFdr8mxW","D2PlAeW","z1rPuMC","y0fIB0y","C2v0u3rVCMe","uMfltfK","wwTXDMC","wxLqr3m","A0HRELi","uvvWrvm","yMLUza","tKfusvzfx0u","x1fVu01HBMe","CMvZzxrdB3u","D3jPDgvvAw4","yw1LoIa","Exnurgi","Dg9iyxnO","BeDIq3K","DMnJs2m","neT1tfzAEa","yxLXyxq","vwHQqwi","CMvZB2X2zq","BwLUzW","y1n5uMq","DfvWzMy","twnKAMy","A3HZC2G","s1f2yLa","yNL0zu9MzNm","BfDRC2u","uLzTquy","s3LYCeq","Efrurw52","rvjst1i","A25tDNG","q1zzqxG","BxL1r1O","nNWZFdeW","CM9YrxzLBNq","DgLLCKPtt04","BunOBfu","zxPMqvG","rg51tKu","ihn1y2nLC3m","sLPMA1G","tu5vD2m","yM9L","DgLUzYbZzxi","AxnbCNjHEq","ten2sKK","AwXK","AKTQvNC","D2fZq2XLyw4","u1H6zKO","Bwv6rfG","B0zsv0q","CgzIs00","u2TPCcbWyxm","BNvKqMq","AMnQrwi","Dgv4Dc9Qyxy","suvnsxu","CK9KuuO","yxbWBhK","zeXjCNK","tgfeALm","C3nHz2vfDMu","x29UrxjYB3i","zfvJzw4","qw1VDw50","ELPzAum","wMfSAMS","t3vtA1q","yNvMzMvYzwq","svLdu0G","s0jXz2i","sMHkshK","y0nwsNy","CMLLC0nVDw4","y3jLyxrLuMu","z25Rq0u","y0TrwfG","A3jXvLe","D2LSBfjLy28","rMDqqxe","D2TMs3O","yMfSu2nVCgu","Ce1Ur0u","BMrWB2LUDfq","CNzHBa","C2zeAxe","yvH1ywG","B25Uzwn0Aw4","Cg9W","nxWX","sMPrqKq","rKHQD0i","CMvZzxrfBMq","ywrKrxzLBNq","ExPxyw8","ChbyCwe","y0DRruq","zcWG","x2LZtM9Kzq","sKzbswC","DxPOzwS","CeXqCey","BwvKAwf0zwW","wfbxwgm","B3nLza","BLbAEe8","r3P3DLi","sKjMqvO","CKHlENi","EhDfANa","tLjerwe","ywX3yxLZ","DvvpEwC","Aw5Lza","ELrQrKq","zMzmAw5L","zufJAW","tfL3BhG","tKj5Dve","vhPks08","qMHPvM0","Bu5XEhO","rvHPq2m","txfsv0C","BwLZzq","Aw50zwDLCIa","uhjPBwfYEuS","D3zVDhq","zxjFAxnFywm","tfPqC0u","rxf2CLe","BePdvwu","BM93","ywXSq3vYC28","BNv3wu8","DKDesfe","sKfzq1u","uhnLz0q","zffYuKO","CgLUz19VBMm","tgDisNK","De52tu4","wNLYue0","ChzXAMm","BLnbyKe","yw5Hz2vY","EvfnBey","DurTzeO","wKPcCKG","B3jRig9MzMW","rxziu1C","C3PIy3m","BMf6AKO","A3LgrhK","CMvJB25Uzwm","zMzMzG","B2zMBgLUzq","twDgAKu","s2DjDei","A2jkBwm","ywWGy3vYC28","nhWWFdn8mNW","DxjS","DgLTzw91Da","mdaWma","yw1QEeS","vuPVv04","x2DLBMvYyxq","D0josgG","EM1rq2K","x3DZ","Ag1Ku0G","qu9yDKu","BMrLEa","ENjowLq","ChjVDg9JB2W","AgnIs2C","zgLZCgf0y2G","AxnAzxjV","ywnOzwq","tMjWAhK","zvLZwhG","AKPRt28","sgL2wKy","B25TzxnZywC","zxv3r24","B2z4sxC","B1zlz3m","ugv0Dha","ue9OChG","rvHVBha","BxDNCvm","EwPfD0m","rKPkDMG","DezPz0O","wLzmvhO","BNf0twu","C2v0sxrLBq","tKDeCey","ufDmEhy","wvvuCNu","Dhj1y3rVCIa","reHcvxO","Ef9MCM9UDgK","qxzeu3a","B2zMC2v0","z1rPBwvVDxq","y3bcA2q","x29WDgLVBNm","vhn4qxK","sK1fquy","uw9JEha","shfrC2u","wfnOC1q","Dg9hzw5LCMe","DwHhEfG","AuHKwwS","z0jbzwC","y3fnANa","y29Uy2f0","se9zyK4","A0j3swu","zxjFDhrS","Dhr3Awq","zMPrELa","CwDzuLC","y29SBM8","C3rLBMvYCW","yxKSig5LDhC","ChjVy2vZCW","s2DMrhm","y3vYDMfSDwu","wwLWs1e","BenxrfC","yNvMzMvY","BwL6rNO","CNnVCKzPBgu","z1rwtLa","AxnmB25N","BMnVzgLUzW","qLzcuw8","rw5SrNq","ze9Hu2m","A1rurLO","x19LC01Vzhu","CMvHzhLtDge","CIb0DhDjra","D1HqwM0","AwXLtMfTzq","B1Pmyvq","zM9Yy2u","x2LUDgvYDMe","Cezeu0K","nhW1Fdj8m3W","DMH6whO","Exjzvfa","rKLmrv9ot1q","C0vfrw4","mhWYFdL8nxW","BejtEwG","DwTAy2m","uNLABLy","wM1krMW","EvPrBvO","uNLdy3a","EK50AfK","mdaWmdaWmda","y2XVC2veqG","Ec1TC2CTy3u","CfnMrK4","zxr5CKW","CMfTugfYyw0","sMriEgW","u1rqwfy","se55whu","yLDetu8","zgv6tfG","vLfXCMi","zxjYB3i","twvZC2fNzuu","tKPyEeG","x2LUAxrqCM8","BNrfBMrWB2K","x2nVBM5Ly3q","EfnuCKi","ota2mtzxCw5pEgW","B25JBg9Zzq","q1DMwuS","x3bPBMDmB3m","rNjVBNrPzxi","igzPzwXKoIa","z2DqBNK","CMfUzg9T","uKzMse4","zxmGCMvHy2G","y1zisK4","DMvYC2LVBG","z3jLDhG","zMTwDKW","sMD1BwO","B25szwnLAxy","x2LZqNjVD3m","uK56ugi","DM5es0q","vvL4wMm","CK9ZyNe","q29UzMLN","zw5HyMXLuw8","su1xz3G","zxH0ugf5Bg8","t1Lou3e","zgjqwgi","y0rgyLq","x29UvgLTzw8","Dwrtr1G","ugDAALu","AxnrB1nnzxm","rMDHwhe","y3zOzMS","ChbL","mxW0FdD8m3W","vhb4yMG","BMCGzMfPBgu","Ce1fD0m","CM92AwrLihy","z1zvuxG","u3vzDgu","x2LUAxrhBg8","tNbqwgK","x3DHAxq","Ehj4sgm","BxnNsuq","D2zmr2u","y2fSBa","DNrKDfO","v2jKENG","wffTC2q","sgf4AMy","Cff5qMK","B3jLtMfTzxm","DuTYAe8","ig1LC3nHz2u","sun0ueW","svLJu3u","zwnVBM5Ly3q","q3Pnwue","C3vIC3rYAw4","yNLL","wvriqNK","nxWYFdz8ma","y2XVC2u","EhfeyuG","C3vIyxjYyxK","shb4rvG","q3HmEhK","vxbtqLy","q3vZDg9Tq2W","x0vysvnu","r3vYvMO","CNfkDgi","z2v0q3vYC28","BwvZC2fNztO","u1bxy3e","y3vZDg9Tshq","qxbAtvO","B2XKvMvYC2K","BuzVEfe","shj0s0y"];return ur=function(){return n},ur()}function df(n,e,{blocked:i,upgrade:o,blocking:a,terminated:x}={}){let u=C,f={HlpVU:u(859),Haxjf:"offline",kTTFZ:u(734),jiCco:u(572),bKnEk:function(y,_){return y!==_},gdNcR:function(y,_,S,E,A){return y(_,S,E,A)},pSfFN:function(y,_){return y(_)},bGUwU:function(y,_){return y(_)},tUpff:u(1681),HWtSi:u(997)+"hange",NByuQ:u(930)+u(1240)},g=indexedDB[u(1117)](n,e),m=f[u(1600)](je,g);return o&&g[u(1424)+u(826)](f[u(1449)],y=>{let _=u,S={ugiDd:f[_(1867)],bEzvI:f[_(1668)],AIbEs:f[_(1574)],dbeAO:f[_(1721)]};f.bKnEk("SQxal",_(696))?(this._isBrowser&&_0x2496dd[_(707)+"entListe"+_(903)](S[_(1146)],this[_(1829)+"nLine"]),this[_(1632)+"er"]&&_0x56d391[_(707)+_(1932)+_(903)](S[_(526)],this[_(1829)+_(1446)]),this[_(1632)+"er"]&&_0x59d319[_(707)+_(1932)+_(903)](S[_(928)],this["_handleP"+_(834)]),this[_(1632)+"er"]&&_0x2d03e2[_(707)+_(1932)+"ner"](S.dbeAO,this[_(770)+_(1011)])):f[_(1993)](o,f.pSfFN(je,g.result),y[_(1696)+"on"],y[_(670)+"on"],f[_(1053)](je,g[_(1192)+_(1856)]))}),i&&g[u(1424)+u(826)](u(1300),()=>i()),m[u(1098)](y=>{let _=u;x&&y[_(1424)+_(826)](f[_(1350)],()=>x()),a&&y[_(1424)+_(826)](f[_(637)],()=>a())}).catch(()=>{}),m}function uf(n,{blocked:e}={}){let i=C,o={YyPGs:"blocked"},a=indexedDB[i(942)+i(541)](n);return e&&a[i(1424)+i(826)](o[i(1331)],()=>e()),je(a)[i(1098)](()=>{})}function Zo(n,e){let i=C,o={isggi:i(522)+"e",xAItt:i(642),VjazM:function(g,m){return g instanceof m},ECHvc:function(g,m){return g in m},hFQzp:function(g,m){return g!==m},NMeld:function(g,m){return g in m}};if(!(o[i(1019)](n,IDBDatabase)&&!o.ECHvc(e,n)&&typeof e===i(923)))return;if(ar[i(2007)](e))return ar.get(e);let a=e.replace(/FromIndex$/,""),x=o.hFQzp(e,a),u=ia.includes(a);if(!o[i(1004)](a,(x?IDBIndex:IDBObjectStore)[i(1037)+"e"])||!(u||ra[i(1282)](a)))return;let f=async function(g,...m){let y=i,_=this[y(1192)+y(1856)](g,u?o[y(669)]:o[y(1280)]),S=_[y(519)];return x&&(S=S[y(883)](m[y(720)]())),(await Promise[y(478)]([S[a](...m),u&&_[y(822)]]))[0]};return ar[i(833)](e,f),f}var ra,ia,ar,ff=ea({"node_modules/idb/build/index.js"(){let n=C,e={UXHip:n(1786)+"1|0",nywou:function(a,x){return a(x)},VpKjl:n(1227),NMqNF:n(1909),JDkso:n(871),csxrC:function(a){return a()},GQvQE:function(a){return a()},NQxdu:n(911),szCYr:n(959)+"ys",ahGso:n(722)},i=e.UXHip[n(1791)]("|"),o=0;for(;;){switch(i[o++]){case"0":e[n(842)](af,a=>({...a,get:(x,u,f)=>Zo(x,u)||a[n(2007)](x,u,f),has:(x,u)=>!!Zo(x,u)||a[n(1988)](x,u)}));continue;case"1":ar=new Map;continue;case"2":ia=[e.VpKjl,e[n(940)],e[n(546)],n(1936)];continue;case"3":e[n(501)](Xo);continue;case"4":e[n(1951)](Xo);continue;case"5":ra=[n(2007),"getKey",e.NQxdu,e[n(714)],e[n(1864)]];continue}break}}}),lf={idb:function(n){let e=C;n[e(646)]=Promise[e(1347)]()[e(1098)](()=>(ff(),na)).then(function(i){return i})}},Qo={};function Ke(n){let e=C,i={lcLjq:e(735)+"0"},o=i.lcLjq[e(1791)]("|"),a=0;for(;;){switch(o[a++]){case"0":return u[e(646)];case"1":lf[n](u,u[e(646)],Ke);continue;case"2":if(x!==void 0)return x.exports;continue;case"3":var x=Qo[n];continue;case"4":var u=Qo[n]={exports:{}};continue}break}}function R(n,e){n=n-444;let i=ur(),o=i[n];if(R.PUNVKC===void 0){var a=function(g){let m="abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789+/=",y="",_="";for(let S=0,E,A,T=0;A=g.charAt(T++);~A&&(E=S%4?E*64+A:A,S++%4)?y+=String.fromCharCode(255&E>>(-2*S&6)):0)A=m.indexOf(A);for(let S=0,E=y.length;S<E;S++)_+="%"+("00"+y.charCodeAt(S).toString(16)).slice(-2);return decodeURIComponent(_)};R.uSEIJt=a,R.VAgEwZ={},R.PUNVKC=!0}let x=i[0],u=n+x,f=R.VAgEwZ[u];return f?o=f:(o=R.uSEIJt(o),R.VAgEwZ[u]=o),o}(()=>{let n=C,e={zTjFD:function(i,o,a){return i(o,a)},ZdYce:function(i,o){return i!==o},WhbJr:n(662)};Ke.d=(i,o)=>{let a=n,x={xgWnG:function(f,g,m){return e[R(1445)](f,g,m)}};if(e.ZdYce(e[a(969)],a(1103)))for(var u in o)Ke.o(o,u)&&!Ke.o(i,u)&&Object[a(760)+a(1797)](i,u,{enumerable:!0,get:o[u]});else{let f=x[a(1165)](_0x394219,"error",{message:_0xf51aa7.message,code:_0x139e33[a(1063)+"OR"],error:_0x380156});Q[a(1746)+a(586)+a(1949)](f)}}})(),(()=>{let n=C;Ke.o=(e,i)=>Object[n(1037)+"e"][n(1164)+n(1797)][n(1664)](e,i)})(),(()=>{let n=C,e={ohNDu:function(i){return i()},Rdxfm:"wzzyp",eKOrI:n(908)+"d",wHLxU:n(2001),tiZHa:n(1575)+"le"};Ke.r=i=>{let o=n;if(e.Rdxfm===o(634)){let a=Q[o(583)+o(507)]?.[o(1890)+o(1613)+"nt"]();Q[o(1244)]("open "+a),e[o(596)](_0x441e65)}else e[o(813)]!=typeof Symbol&&Symbol["toString"+o(1006)]&&Object[o(760)+"operty"](i,Symbol["toString"+o(1006)],{value:e[o(880)]}),Object[o(760)+o(1797)](i,e[o(841)],{value:!0})}})();var re={};(()=>{let n=C,e={PxWVy:function(s,t){return s(t)},COajq:function(s,t){return s+t},rJrGx:function(s,t){return s+t},aZAmc:function(s,t){return s===t},zQqib:function(s,t){return s!==t},JUXxZ:function(s,t,r){return s(t,r)},fdxwY:function(s,t){return s===t},CxLxy:"qyxqW",iLLLR:function(s,t){return s+t},bBrlS:function(s,t){return s*t},kwuzj:"rZSJE",GQqdL:function(s,t){return s+t},yejpO:function(s,t){return s(t)},hjTlL:function(s,t){return s(t)},QHKxx:function(s,t,r){return s(t,r)},ROeeF:function(s,t){return s(t)},VfSyl:function(s,t){return s(t)},FhsXa:n(1495),cBdlO:n(1486),pdjcP:n(1470)+"e_success",NRDEa:function(s,t,r){return s(t,r)},SPWcq:n(1171),EnlFt:n(1965)+n(1832),TvvYJ:function(s,t){return s&t},OYNSq:function(s,t){return s>>>t},HgfSW:function(s,t){return s&t},cvhfk:function(s,t){return s>t},ZaTMm:function(s,t){return s<t},cyIgD:n(1634),kvSes:function(s,t){return s<t},wagGc:function(s,t){return s-t},RNzPb:function(s,t){return s===t},cRKbe:n(520),aRLGj:function(s,t){return s!==t},ktvFN:function(s,t,r){return s(t,r)},pOgLt:function(s,t,r){return s(t,r)},pcJlv:function(s,t){return s||t},rHNDc:function(s,t){return s!=t},rpLvM:"undefined",XMbeV:function(s,t){return s!=t},VztOD:n(569)+n(1104)+"d",JOfur:function(s,t){return s(t)},OeAWb:function(s,t){return s!==t},CQxnB:n(793),kboyP:n(1417),WuSKH:function(s,t){return s(t)},gNLJq:function(s,t){return s(t)},zPbsz:n(1763)+n(1725)+n(1621)+"key",bGvzT:n(1763)+n(1725)+n(1621)+n(732),KVXQi:function(s){return s()},JMEAF:function(s,t,r){return s(t,r)},DVbGh:n(1315),FNqSZ:n(1312)+n(1082)+n(1777)+n(1759)+"ed",ayqat:function(s,t,r,c){return s(t,r,c)},BeAhl:function(s,t,r,c){return s(t,r,c)},ePrWr:n(1534)+n(1233)+"ck",VqEGG:n(1534)+n(1459)+"k",IefNG:function(s,t,r){return s(t,r)},uTesj:function(s,t){return s!==t},bBfHo:function(s,t){return s!==t},OaTgJ:"YFpxA",PBBoy:function(s,t){return s!==t},xcSST:function(s,t,r){return s(t,r)},iziEo:function(s,t){return s!==t},gXoGq:function(s,t,r){return s(t,r)},VHmMh:function(s,t){return s!==t},PsegD:function(s,t){return s!==t},FgPAq:function(s,t,r){return s(t,r)},onDbq:function(s,t){return s!==t},bVAPZ:function(s,t){return s!==t},JdmJz:n(1388),ZkGBx:function(s,t,r){return s(t,r)},IjUuc:function(s,t){return s!==t},ZJBrH:function(s,t,r){return s(t,r)},AigDQ:function(s,t){return s===t},azOYp:n(465),LkksT:function(s,t,r){return s(t,r)},bOVep:function(s,t){return s(t)},BziWf:function(s,t){return s|t},XShsT:function(s,t){return s<<t},gyflf:function(s,t){return s<<t},ohJQI:function(s,t){return s>>t},bVVOv:n(1571),jXQDn:n(487),QpwvN:function(s,t){return s>>>t},ArFGQ:function(s,t,r){return s(t,r)},recSl:function(s,t){return s(t)},IYCSH:function(s,t){return s(t)},kMrnl:function(s,t){return s(t)},mLMtD:function(s,t){return s(t)},DAyMn:function(s,t,r){return s(t,r)},hWiPr:n(1763)+n(1725)+n(1621)+n(1026),TsHBe:function(s,t){return s===t},xsZiU:n(1763)+n(1725)+n(1621)+n(1235),jGtsu:n(1763)+n(1725)+n(1621)+n(1702),nqcQb:function(s,t){return s===t},HEkPb:n(1763)+n(1725)+n(1621)+"method",Dlrdq:function(s,t){return s(t)},LKQIK:function(s,t){return s&t},jxsgg:function(s,t){return s(t)},wZuvP:function(s,t,r){return s(t,r)},kvEYn:"Unimplem"+n(1245)+n(1812),vHUAg:function(s,t){return s>=t},LCvJI:function(s,t,r){return s(t,r)},Fjzfp:"KKrVj",JAYCU:function(s,t){return s+t},YUTru:n(1383)+n(1954),YmeKS:function(s,t){return s*t},aQGcB:function(s,t){return s>t},dbPXb:function(s,t){return s+t},aByDd:n(604)+n(1954),AkiDQ:n(1575)+"le",vhzXz:n(757),Osmux:function(s,t,r){return s(t,r)},CakSb:function(s,t){return s>>>t},lijBG:function(s,t){return s&t},xBgaF:function(s,t){return s&t},EGtkF:function(s,t){return s<t},dUcen:function(s,t){return s+t},verQL:function(s,t,r,c){return s(t,r,c)},cWOhc:function(s,t,r){return s(t,r)},SgTQB:function(s,t){return s<t},QbArm:function(s,t){return s===t},RjxXD:function(s,t){return s&t},mjoPP:function(s,t){return s===t},dbWfP:function(s,t){return s>=t},mnMGK:function(s,t){return s<t},POhpx:n(1771),eYsXx:"hoquK",tIqpr:function(s,t){return s&t},KKlib:function(s,t){return s+t},pMnGE:function(s,t){return s+t},eTWYb:function(s,t){return s&t},pXvYY:n(611),WqCYy:function(s,t){return s|t},SKCkI:function(s,t){return s|t},CDwzq:function(s,t){return s<<t},unZmW:function(s,t){return s<<t},SqrwX:function(s,t){return s&t},sMPGy:function(s,t){return s<=t},gnkCE:function(s,t){return s==t},CJHFI:function(s,t){return s&t},SiaXt:function(s,t){return s|t},GPBgx:function(s,t){return s<<t},vccKc:function(s,t){return s|t},ctuLA:function(s,t){return s<<t},KMlEB:function(s,t){return s&t},vGDHQ:function(s,t){return s&t},ASbeB:function(s,t){return s&t},LzSyQ:function(s,t){return s>t},HivZF:function(s,t){return s+t},bJVPQ:function(s,t){return s+t},fxgfu:function(s,t){return s&t},ACogE:function(s,t){return s===t},JYqiI:"IRbiN",Hvhrq:function(s,t){return s===t},WIBSB:n(1714),ulvkA:function(s,t){return s<=t},FJJvh:function(s,t){return s+t},cpBkd:function(s,t){return s<t},uIMGr:function(s,t){return s<t},UhsoW:function(s,t){return s<t},ddsXQ:function(s,t,r){return s(t,r)},LYwlx:function(s,t){return s<t},JCwup:function(s,t){return s!==t},zZYiC:"pJkIn",zobGB:function(s,t){return s<t},PRGin:function(s,t){return s&t},OCXuk:function(s,t){return s>>t},bUFWQ:n(517),fNkoh:function(s,t){return s&t},SRGGC:function(s,t){return s>>t},myuGZ:function(s,t){return s&t},mizFz:function(s,t){return s&t},jKjVw:function(s,t){return s>>t},UecyJ:function(s,t){return s===t},NDNQI:n(745),CXLqE:function(s,t){return s>=t},VaLVW:function(s,t,r){return s(t,r)},UIYJc:function(s,t,r){return s(t,r)},HqQse:n(1609),bVAPo:function(s,t,r){return s(t,r)},RWozy:n(574),fNXuF:function(s,t){return s&t},fkVvL:function(s,t){return s(t)},mxDtf:function(s,t){return s&t},IFqIj:function(s,t){return s&t},jcjEb:function(s,t){return s&t},vMBmV:function(s,t){return s&t},CZvWO:function(s,t){return s(t)},IlUBh:function(s,t){return s&t},kbJmc:function(s,t){return s<<t},wDkNg:function(s,t){return s&t},uivdS:function(s,t){return s&t},vExfm:function(s,t){return s&t},pkQHT:function(s,t){return s<<t},pfbKM:function(s,t){return s&t},EnqGo:function(s,t){return s===t},EpDRX:n(1841),ZVLTz:function(s,t){return s(t)},fHAps:function(s,t){return s<<t},KlYhl:function(s,t){return s&t},NVDNh:function(s,t){return s|t},hnnRQ:function(s,t){return s<<t},Grsyv:function(s,t){return s|t},nbLRE:function(s,t){return s>>>t},uzhek:function(s,t){return s>>>t},RsyLB:function(s,t){return s<<t},ZyrPM:function(s,t){return s>>>t},GkmEt:function(s,t){return s===t},CPpVp:function(s,t){return s<t},FJDSu:function(s,t,r){return s(t,r)},IGaqG:function(s,t){return s+t},GRzwC:function(s,t){return s!==t},pLPpF:function(s,t){return s!==t},udSGX:function(s,t){return s>>>t},GLHYe:function(s,t){return s&t},jlrtQ:function(s,t){return s+t},RFfHN:function(s,t){return s|t},naAbk:function(s,t){return s>>>t},Iutrn:function(s,t){return s+t},ftxcV:function(s,t){return s+t},QppYP:function(s,t){return s!==t},uNwtV:function(s,t){return s>>>t},RxxrZ:function(s,t){return s!==t},EbJNx:function(s,t){return s&t},oklRu:function(s,t){return s!==t},djzow:function(s,t){return s(t)},HOYbN:function(s,t){return s(t)},xvmym:function(s,t){return s|t},mwgqS:n(1695),qLIzE:function(s,t){return s<<t},szbcs:function(s,t){return s|t},mCJfD:function(s,t){return s|t},cgnVD:function(s,t){return s|t},HDDWB:function(s,t){return s<<t},piqTx:function(s,t){return s|t},FzIWz:function(s,t){return s<<t},EjwEV:function(s,t){return s===t},rrIww:function(s,t){return s>>>t},XtbEC:function(s,t){return s|t},GORIm:function(s,t){return s<<t},HrtKF:function(s,t){return s|t},faQBc:function(s,t){return s|t},ICtPL:function(s,t){return s<<t},WUZPi:function(s,t){return s<<t},JiQTf:function(s,t){return s&t},CspUp:function(s,t){return s&t},idjJv:function(s,t){return s&t},LHcXH:function(s,t){return s&t},empEt:function(s,t){return s>>>t},KdDVQ:function(s,t){return s(t)},BQVYy:function(s,t){return s>=t},UTUZO:function(s,t){return s|t},CzMYA:function(s,t){return s+t},uvEXW:function(s,t){return s>>>t},xnRsc:function(s,t){return s+t},WRPJI:function(s,t){return s*t},RLRDf:function(s,t){return s>>>t},YUzAx:function(s,t){return s===t},OCYTj:function(s,t){return s!==t},RZEpi:function(s,t){return s&t},ombgu:function(s,t){return s>>>t},SpQnv:function(s,t){return s&t},uKrhO:function(s,t){return s&t},Zjclv:function(s,t){return s+t},iOCYA:function(s,t){return s>>>t},wJWRE:function(s,t){return s+t},FCFWe:function(s,t){return s>>>t},vqKwy:n(626),DTrhl:function(s,t){return s===t},lCWDW:function(s,t){return s===t},mjjOS:function(s,t){return s===t},OLkMv:function(s,t){return s+t},WuRap:function(s,t){return s&t},euXFk:function(s,t){return s>>>t},BAvzx:function(s,t){return s>>>t},XpbGK:function(s,t){return s&t},ORaCf:function(s,t){return s>>>t},joLBF:function(s,t){return s&t},ddEgM:function(s,t){return s>>>t},MUmSO:function(s,t){return s&t},EGwCm:n(1335)+n(1145),lJCox:n(469)+"NG_ERROR",NIKeZ:n(1076)+n(980)+"R",ZbuJP:n(1160)+n(1359),AkkHk:n(1063)+"OR",WfQaz:n(1584)+"6|0|1",mNkbI:n(736)+"0",vLTyh:n(1469),HDgvS:n(988),bPlWp:function(s,t){return s>=t},mcGqg:function(s,t){return s-t},jNRZA:function(s,t){return s>>>t},DJYWG:function(s,t){return s<<t},RpvjT:n(791),hAxSa:function(s,t){return s==t},vbZjv:n(1422),DnuNE:function(s,t){return s instanceof t},WkNfr:n(451)+n(606),bwlZt:function(s,t){return s+t},MrGIF:function(s,t){return s===t},cGkED:n(1332),vMLKN:n(1203),wvTVR:"close",PLWte:"open",uebwI:n(1518),IYcSu:function(s,t,r){return s(t,r)},dLIry:function(s,t){return s!==t},EERpU:"AjRJe",JQfya:"DDgmj",GiFZf:function(s,t){return s||t},WcYfx:function(s,t){return s===t},kLDuR:n(1319)+n(854)+n(1743)+n(811)+n(1560),UvZGz:function(s,t){return s<t},hpiAM:function(s,t){return s<t},kfWnx:function(s,t){return s&t},BIuKH:function(s,t){return s===t},PrJCC:function(s,t){return s&t},PjZTy:function(s,t){return s<=t},sEEEn:function(s,t){return s>=t},MpXdc:function(s,t){return s&t},NNtTO:function(s,t){return s>=t},bxYLm:function(s,t){return s<t},LWnyy:function(s,t){return s|t},hQcWn:function(s,t){return s-t},eWtBk:function(s,t){return s|t},BYnPy:function(s,t){return s|t},knSvx:function(s,t){return s<<t},zhYvP:function(s,t){return s&t},NkTlL:function(s,t){return s&t},oFYre:function(s,t){return s+t},Zumvz:n(734),zmQCi:n(572),XNEJL:"online",FwzkW:function(s,t){return s<t},nEpFl:n(1667),XPWXc:function(s,t){return s|t},mQtfy:function(s,t){return s&t},qFvvm:function(s,t){return s===t},wBNSy:function(s,t){return s===t},xzGmH:function(s,t){return s+t},EADei:function(s,t){return s+t},NFCtE:function(s,t){return s|t},oXTlr:function(s,t){return s&t},PWHtk:"Djiat",lLXyl:function(s,t){return s|t},CVYAx:function(s,t){return s|t},acLYT:function(s,t){return s(t)},zSLjy:function(s,t){return s>t},yGOwL:n(923),NMlRN:function(s,t){return s!=t},hwYrP:function(s,t){return s==t},GurVj:n(1261)+n(1185)+n(1020),rdPyz:n(1372),AvDSp:n(1650),BhAbi:function(s,t,r){return s(t,r)},Jkaoe:function(s,t,r,c){return s(t,r,c)},otpeZ:function(s,t){return s+t},aOHmi:function(s,t){return s!==t},pBdTE:"pQyBi",svLGc:function(s,t){return s||t},YrXhU:n(925),PgZjU:n(960)+n(1223)+n(1365)+"P",fHVFe:function(s,t){return s-t},zuHZo:function(s,t){return s===t},LrfMp:n(1657),eOemy:function(s,t){return s===t},GygKH:n(603),MCHZH:function(s,t){return s===t},MNUwc:n(703),UJoWN:function(s){return s()},RVmAF:function(s,t,r,c){return s(t,r,c)},EXiCc:function(s,t){return s===t},hYstH:function(s,t){return s>>t},kxssh:function(s,t){return s|t},NvNVg:function(s,t){return s&t},wjKhL:function(s,t){return s>>t},uYkuq:function(s,t){return s===t},NpPXi:n(631),BGXqo:"dXTxQ",ANAuh:n(2001),lWizl:function(s,t){return s!==t},wqJfu:n(563),dRFGO:"CayQL",ktdlX:function(s,t){return s||t},vTYLg:function(s,t){return s||t},LZPsE:function(s,t){return s||t},dIOWJ:n(1748),MWtwL:n(970)+"id",SaxOO:n(778),LWkvT:n(981),rfhFl:function(s,t){return s(t)},TsxAy:function(s,t){return s<t},gTVNP:function(s,t){return s(t)},ysTDb:function(s,t){return s+t},cAboF:function(s,t){return s&t},pEvVN:function(s,t){return s===t},khfKK:n(1701),tFigJ:function(s,t){return s&t},KeXez:function(s,t){return s!==t},cKQXX:n(1397),blJkd:function(s,t){return s(t)},TTdhi:n(1534)+n(1699),LzyIv:function(s,t,r,c){return s(t,r,c)},DmIma:n(1534)+n(1269)+n(909),BhiVm:"need_ack",JFAIg:function(s,t,r,c){return s(t,r,c)},dOUFS:function(s,t){return s&&t},nZPIp:n(1108),tjNbe:n(1138),vdZcL:n(1311),KVnac:"received",LaDjS:function(s){return s()},zJxNF:function(s,t){return s(t)},KnOFa:n(672)+n(987)+n(1105)+n(1314),VfETj:n(1206)+"e",ezfAX:n(1742),qYhEh:function(s,t){return s!==t},stoAo:"KoEXn",zMvGL:n(1167),UEJmT:function(s,t){return s(t)},sNDdD:function(s,t){return s+t},DFjrC:function(s,t){return s|t},yNXME:function(s,t){return s||t},feDPf:function(s,t){return s instanceof t},WJRKn:function(s,t){return s!==t},JKiqq:n(503),WSMTF:function(s,t){return s(t)},fBFfP:function(s,t){return s+t},HCMBL:function(s,t){return s+t},kVpkB:n(1816)+n(1267)+"ge: ",ZmxEF:n(961),qTuGK:function(s,t){return s||t},CWfYK:function(s,t){return s>t},faVNY:"integer too large",jJkOo:function(s,t){return s+t},TGBAf:function(s,t){return s===t},klHoq:function(s,t){return s===t},EFGxa:function(s,t){return s>>>t},Dvzho:n(529),qYuYq:function(s,t){return s>>>t},pMEwC:function(s,t){return s<<t},Rcwuy:n(697)+"3",PjioK:function(s,t){return s+t},uinPW:function(s,t){return s|t},AEWGw:function(s,t){return s+t},KCUzV:function(s,t){return s+t},KQvbP:function(s,t){return s|t},FnPEt:function(s,t){return s+t},hcbKg:function(s,t){return s<<t},MlWMz:function(s,t){return s+t},waKMM:function(s,t){return s>>>t},DKxFs:function(s,t){return s&t},HghpV:function(s,t){return s>>>t},dBPBn:function(s,t){return s&t},umLny:function(s,t){return s&t},gTPWs:function(s,t){return s>>>t},DlRnA:function(s,t){return s&t},RtAtp:function(s,t){return s+t},quseN:function(s,t){return s>>>t},JyZyr:function(s,t){return s&t},gBAeg:function(s,t){return s+t},gTiRg:function(s,t){return s>>>t},amjxK:function(s,t){return s<<t},FqujE:function(s,t){return s<t},wZaro:n(1799),cqMjp:function(s,t){return s(t)},GRAsu:function(s,t){return s+t},HNyXu:n(1133)+"4|2|0|10"+n(1930),MssKa:n(570)+n(2006),vJfRj:function(s,t,r,c){return s(t,r,c)},AVWYD:n(1702),tfWEJ:n(1824)+n(1070),DkPDG:"header",wzvac:n(1562),KyeLy:function(s,t){return s(t)},IzlKX:n(986)+n(483),Xkwsj:function(s,t,r){return s(t,r)},tNvMN:function(s,t,r){return s(t,r)},hALkx:n(1587)+n(1688),xqTqe:n(492)+"ame",Bftdj:n(1464)+n(1021),ONPtV:n(1703),OSvtI:function(s,t,r,c){return s(t,r,c)},dfQMd:"CONTINUE",HnHzS:function(s){return s()},uNdpq:n(1765),STPXV:n(913)+"r",nuwYO:n(698),RyCcp:n(1635),wBOyf:n(1355),ThKZS:n(788),nazjJ:n(1881),yIGao:function(s,t,r,c){return s(t,r,c)},nSAbA:function(s,t,r,c){return s(t,r,c)},ofxIw:n(1079),krdPg:function(s,t,r,c){return s(t,r,c)},hPEqY:function(s,t,r){return s(t,r)},yQMlF:n(1534)+n(1891),Hdhjp:function(s,t,r){return s(t,r)},IGngG:n(1534)+n(1553),DnHyf:function(s,t,r,c){return s(t,r,c)},wmJUL:n(1599)+n(687)+"e",CdlRL:n(1723),SXzfJ:n(1907),uIOjK:function(s){return s()},qSkEt:function(s){return s()},ppXqa:function(s){return s()},LjHsg:function(s){return s()},BplZf:function(s,t){return s(t)},nqtMe:function(s,t){return s<t},QDwIe:function(s,t,r){return s(t,r)},jpFPZ:function(s,t){return s===t},wVqav:n(1442),IMWgx:n(1452),KyrpD:"success",Mcdjf:n(1716),gpXzk:function(s,t,r){return s(t,r)},wBNHh:function(s,t){return s!==t},TFqyx:function(s,t,r){return s(t,r)},oRINq:n(1678),NJXxH:function(s,t){return s(t)},iHdYk:n(753),RMfux:function(s,t){return s/t},dFSHa:"auto",OHVuA:function(s,t){return s==t},pyjdq:n(622)+n(1655)+"alid url",NGDpF:n(622)+n(691)+n(1305)+n(1173)+"ket cons"+n(1532)+n(801)+n(1444),OLZyM:"EduNv",hyZDs:function(s,t){return s(t)},ULIpr:n(1589)+"8|7|4|1|"+n(1363),lbauJ:function(s,t,r,c){return s(t,r,c)},VIfFj:function(s,t){return s===t},xrxHc:"AHWst",AOXvE:function(s,t,r){return s(t,r)},XHyaX:n(1485)+"t",mezDX:"stop immediately"+n(1149)+"ct",VDoLF:function(s,t){return s&t},rzqrO:function(s,t){return s!==t},gVUQx:n(1317),jnqKF:n(1950),oUFRH:n(1487),eszAt:n(1129),LgHJy:n(566),GuiCY:function(s,t){return s!==t},hdpGJ:function(s,t){return s===t},mDhQP:n(1086),rqJtb:n(1893),LTwCL:n(1130),ehXoQ:n(530),xHYMP:n(1554),RSstO:n(622)+n(521)+n(1986)+n(1089)+n(1577),sSjfq:n(643),Ceqhx:function(s,t,r){return s(t,r)},Yjkni:n(1886)+"0",VzbVn:function(s,t){return s>t},SppQA:function(s,t,r){return s(t,r)},mVNEr:function(s,t,r){return s(t,r)},QiPoe:function(s,t){return s(t)},kyFDy:function(s,t){return s(t)},IqbVz:function(s,t){return s(t)},OaSER:n(1914)+">",UpSBV:function(s,t){return s-t},EHvvu:function(s,t){return s>t},LnLgu:function(s,t){return s===t},UvpuX:function(s,t,r){return s(t,r)},GqQDi:function(s,t){return s!==t},zNthY:function(s,t,r){return s(t,r)},UtEGp:"ping_onc"+n(1740)+"t",ihUIA:n(1494),RqVlS:function(s,t){return s!==t},QUpES:n(1855),MgFjE:function(s,t,r){return s(t,r)},NPylk:n(1615),NEPaU:"YpGIc",FUrlt:n(1122)+n(1756)+n(1418)+"g",Irqvu:"send_ack",hrvDt:n(1324)+"0",wfLGe:function(s,t,r){return s(t,r)},JhJHy:function(s,t,r){return s(t,r)},QbGmh:n(693)+n(1559)+n(1480)+"ine",TwqaX:n(792),BMjGG:n(1195),nudBd:function(s,t){return s||t},ZDCNl:function(s,t){return s===t},lJCUe:"abHGC",gretx:n(1179),wCpYu:function(s,t){return s===t},YipKQ:n(1603),qwcgj:function(s,t){return s(t)},HMTSF:function(s,t){return s(t)},ULSfP:function(s,t){return s!==t},KgItB:n(975),RkTBU:"qyMQx",KBqgb:n(1312)+n(815)+n(1212),YvEmg:function(s,t){return s|t},NoUaN:function(s,t){return s==t},LxrPD:n(622)+n(906)+n(1008)+n(446)+n(1056)+n(1175)+n(1916)+" arraybu"+n(1323),LcPqa:n(1168),DUAVL:function(s,t){return s instanceof t},mGKQz:function(s,t){return s(t)},ETqfE:n(622)+n(906)+n(1776)+n(1070),DHBUz:function(s,t){return s===t},jMbbN:n(763),warjA:function(s,t){return s===t},fVFgr:n(500),CNNQa:"enqueue",Jgumj:function(s,t){return s!==t},WjnIZ:n(462),dWHCZ:n(1381),yNrUi:"manual r"+n(1675)+n(1207),ccqSr:"kHccr",INUpg:n(1492)+"1",RyZnV:"MZJeG",qgiyq:n(916),ZsKZU:n(674),KZCgj:function(s,t){return s!=t},SztNp:function(s,t){return s===t},SoUHr:n(810),dezLX:function(s,t){return s===t},XDiUX:function(s,t){return s!=t},WsRjY:function(s,t){return s===t},eXNCk:n(1819),FAaEI:"Dedicate"+n(1229)+n(1788)+"pe",lYVIM:function(s,t){return s!=t},cURwF:function(s,t){return s===t},qLaXS:function(s,t){return s!=t},qShSw:function(s,t){return s===t},rHegF:function(s,t){return s===t},Nbphy:"SharedWo"+n(1139)+"alScope",ZDdGB:function(s,t){return s===t},FgaXq:n(729)+"orkerGlo"+n(1412),cCVJv:function(s,t){return s!=t},jiSiY:function(s,t){return s!=t},JfKhu:n(1272)+n(619)};Ke.r(re),Ke.d(re,{FWS:()=>O0,CustomErrorEvent:()=>is,createCloseEvent:()=>Oe,ReconnectEvent:()=>rs,createErrorEvent:()=>Pe,decodedFrame:()=>At,createOpenEvent:()=>ds,CustomCloseEvent:()=>ss,createReconnectEvent:()=>qr,FrontierMessageEvent:()=>as,encodeFrame:()=>oe,createMessageEvent:()=>xs,OpenEvent:()=>cs,ErrorCode:()=>ot,Event:()=>Tt,MessageEvent:()=>os});let i="";function o(s=""){let t=n,r="02",c=""+Date[t(1463)](),d=i||(i=e[t(1144)](g,s)),h=Math.random().toString(16)[t(1274)](-6);return e[t(804)](e.COajq(e[t(1040)](r,c),d),h)}function a(){let s=n,t={EqvrQ:function(r,c){return e[R(1942)](r,c)},rVMky:function(r,c){return e[R(1745)](r,c)},bWDMO:function(r,c,d){return e[R(1779)](r,c,d)}};if(e[s(1792)](s(599),e[s(1685)])){if(this._ws&&t[s(1461)](this[s(1501)][s(1576)+"te"],this.CONNECTING)){this[s(812)+"ngTimer"](),this[s(1230)+"gTimeoutId"]=_0x3b9671(this[s(513)].bind(this),this._options[s(1827)+s(1415)]);return}if(!this[s(1501)]||t.rVMky(this[s(1501)][s(1576)+"te"],this.OPEN))return void this[s(617)+s(1675)]();this[s(1501)]&&this._ws[s(1764)]("hi"),this["_reconne"+s(488)+s(1834)]=t[s(1606)](_0x406362,this[s(617)+s(1675)+"Timeout"].bind(this),this._options["pingTime"+s(1898)+s(1852)])}else return e.iLLLR(1e4*Date[s(1463)](),Math[s(1090)](e[s(1767)](1e4,Math[s(1623)]())))}function x(s){let t=n;if(e[t(1735)]===e[t(1735)])return e[t(473)](e[t(738)](Array,8)[t(533)]("0"),e[t(1779)](parseInt,s,10)[t(1887)](2)).slice(-8);this.on(_0x121eb5,_0x33a8ed)}function u(s){let t=n;return e.iLLLR(e[t(1842)](Array,4).join("0"),e[t(915)](parseInt,s,2).toString(16))[t(1274)](-4)}function f(s){let t=n,r=s[t(1791)](/\./)[t(741)](h=>x(h)),c=[];return c[0]=e.ROeeF(u,e[t(473)](r[0],r[1])),c[1]=e[t(853)](u,e[t(1040)](r[2],r[3])),[e[t(769)],t(1495),t(1495),e[t(769)],t(1495),e[t(1257)],c[0],c[1]][t(533)]("")}function g(s){let t=n,r={ruDDa:e.pdjcP,kBwIe:t(709),aZlKP:function(c,d,h){return e[t(1441)](c,d,h)}};if(e[t(1745)](t(1946),e[t(1693)])){let c=/(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(885)](s),d=/(([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(885)](s);return c?f(s):d?e.hjTlL(m,s):t(1597)+t(1597)+t(1597)+t(1597)}else this[t(812)+"ngTimer"](),this[t(2008)](r.ruDDa,r[t(1552)]),this["_pingPon"+t(1537)+"Id"]=r[t(965)](_0x152a9b,this[t(513)][t(1334)](this),_0x26cc11)}function m(s){let t=n,r="",c=[],d=0,h=0,p=!0,w=e.FhsXa;if(e[t(1649)](s.indexOf("::"),-1)){let l=s.split("::");for(let I=0;e[t(950)](I,l[t(633)]);I++){let k=l[I];if(k[t(1913)](":")>0)if(e[t(1745)](e[t(1961)],e[t(1961)]))_0x509bce["frontier"+t(781)]=void 0,e[t(862)](_0x297c34,e[t(1572)]);else{let M=k[t(1791)](":");p&&(d=M.length),h+=M[t(633)];for(let N=0;e.kvSes(N,M[t(633)]);N++)if(M[N][t(633)]!==4){let H=w[t(1677)+"g"](0,e[t(1972)](4,M[N][t(633)])),fe=H[t(1550)](M[N]);c.push(fe)}else c[t(684)](M[N]);p=!1}else{if(k[t(633)]!==4){let M=w.substring(0,e.wagGc(4,k[t(633)])),N=M[t(1550)](k);c.push(N)}else c[t(684)](k);p&&(d+=1),h+=1,p=!1}}let b="";for(let I=0;I<e.wagGc(8,h);I++)b=b[t(1550)](w);for(let I=0;I<c[t(633)];I++)e[t(1633)](I,d)?(r=r.concat(b),r=r[t(1550)](c[I])):r=r.concat(c[I]);return r}{let l=s[t(1791)](":");for(let b=0;b<l[t(633)];b++){let I=l[b];if(e[t(1745)](4,l[b][t(633)]))if(e.RNzPb(e[t(882)],e[t(882)])){let k=w[t(1677)+"g"](0,e[t(1972)](4,l[b][t(633)])),M=k.concat(I);r=r.concat(M)}else return _0x71ac6c[t(1115)+t(1322)](e[t(615)](255,this[t(1009)]),this[t(1009)]>>>8&255,this[t(1009)]>>>16&255,e[t(1641)](this[t(1009)],24),e[t(1268)](255,this.high),e[t(1641)](this.high,8)&255,e[t(1641)](this.high,16)&255,this.high>>>24);else r=r[t(1550)](I)}return r}}function y(s,t){let r=n,c=s.key;e[r(1815)](void 0,c)&&(X(t,10),e[r(758)](he,t,c));let d=s.value;e.aRLGj(void 0,d)&&(e.QHKxx(X,t,18),e.pOgLt(he,t,d))}function _(s){let t=n,r={};e:for(;!e[t(954)](ue,s);)if(e[t(1034)](e.CQxnB,e[t(1291)])){let c=e.WuSKH(ee,s);switch(c>>>3){case 0:break e;case 1:r.key=e[t(1779)](te,s,e[t(742)](ee,s));break;case 2:r.value=e.JUXxZ(te,s,e[t(742)](ee,s));break;default:Z(s,e[t(615)](7,c))}}else{if(_0x340187||_0x448416)return new _0x1e98e9(_0x3af944,_0x125314);if(e[t(1749)](_0x55c545,_0x545a03)&&e.rHNDc(e[t(1247)],typeof _0x557663))return new _0x3a75db(_0x294b90,_0x20b953);if(e[t(1749)](_0x1e1872,_0x3e4b58)&&e.XMbeV(t(908)+"d",typeof _0x5a6bbf))return new _0x250ee0(_0x326c2a,_0x1a7c8b);throw new _0x20c05e(e[t(1970)])}if(e[t(1942)](void 0,r.key))throw new Error(e.zPbsz);if(e.fdxwY(void 0,r[t(732)]))throw new Error(e[t(955)]);return r}function S(s){let t=n,r=e[t(461)](J);return e[t(1541)](E,s,r),e[t(862)](Ne,r)}function E(s,t){let r=n,c={HnZEE:e.FNqSZ,uUOyg:function(j,$){return j===$},IlboF:r(1312)+r(815)+r(1212),ZmuqE:function(j,$,Ce,Te){return e[r(1345)](j,$,Ce,Te)},yNkci:function(j,$,Ce,Te){return e.BeAhl(j,$,Ce,Te)},GFSOk:e[r(1941)],OrwbW:e.VqEGG,uyLwf:function(j,$,Ce){return e[r(1441)](j,$,Ce)}},d=s[r(1026)];e[r(1815)](void 0,d)&&(e[r(777)](X,t,8),e[r(915)](V,t,d));let h=s[r(1235)];e[r(1225)](void 0,h)&&(X(t,16),e[r(758)](V,t,h));let p=s[r(1702)];e[r(1981)](void 0,p)&&(e[r(485)]===e.OaTgJ?(e.ktvFN(X,t,24),e[r(1441)](V,t,e[r(738)](K,p))):this.emit(e[r(460)],e[r(576)](_0x3f8146,e.DVbGh,{..._0x31d17a})));let w=s.method;e[r(701)](void 0,w)&&(e.xcSST(X,t,32),e.pOgLt(V,t,e.hjTlL(K,w)));let l=s[r(795)];if(l!==void 0)for(let j of l){X(t,42);let $=e.KVXQi(J);y(j,$),X(t,$[r(1278)]),e.pOgLt(Je,t,$),e[r(1842)](_e,$)}let b=s["payloadE"+r(1570)];e[r(1781)](void 0,b)&&(X(t,50),e[r(1259)](he,t,b));let I=s["payloadT"+r(1298)];e.VHmMh(void 0,I)&&(e[r(1441)](X,t,58),he(t,I));let k=s[r(1959)];e.PsegD(void 0,k)&&(e[r(1410)](X,t,66),e[r(1928)](X,t,k[r(633)]),e[r(758)](Se,t,k));let M=s[r(577)];e.onDbq(void 0,M)&&(e[r(1779)](X,t,74),e.JUXxZ(he,t,M));let N=s[r(618)+"ming"];if(e[r(787)](void 0,N))if(e[r(1792)](r(1388),e[r(481)]))X(t,82),e[r(1780)](he,t,N);else{let j=(r(1651)+r(1680))[r(1791)]("|"),$=0;for(;;){switch(j[$++]){case"0":this["_destroy"+r(1101)+"t"](_0x428a78,_0x89d2d2);continue;case"1":this["_readyCl"+r(1435)]=!0;continue;case"2":if(!this[r(1501)])return void this[r(1244)](c[r(1142)]);continue;case"3":this[r(1895)+r(892)+r(826)]();continue;case"4":this[r(1232)+r(827)]();continue;case"5":this["_QoSMana"+r(641)]?.[r(1598)]();continue;case"6":if(this[r(1501)].readyState===this[r(1896)]||c[r(1443)](this._ws[r(1576)+"te"],this.CLOSING))return void this[r(1244)](c[r(837)]);continue;case"7":this[r(812)+r(1177)]();continue}break}}let H=s[r(1662)];e.IjUuc(void 0,H)&&(X(t,90),e[r(1479)](he,t,H));let fe=s.frameType;if(fe!==void 0)if(e.AigDQ(e[r(1032)],r(1608))){let j=!!this[r(1539)].enableQoS;if(!j)return{enabled:j,isQoSMessage:!1,isQoSAck:!1,isAckCleanupMessage:!1,ackMsgIds:[]};let $=c[r(1050)](_0xffce36,_0x4f471f.message[r(795)],r(1534)+r(1699),"2"),Ce=$&&c.yNkci(_0xfcd997,_0x3dc5e9.message[r(795)],c[r(463)],"1"),Te=$&&_0x55d092(_0x5e8dc1.message[r(795)],c.OrwbW,"1"),Rt=Te?c.uyLwf(_0x31e755,_0x517ab4[r(1315)][r(795)],r(1534)+"er_ack_m"+r(909))?.split(",")[r(912)](_0x2a0d44)||[]:[];return{enabled:j,isQoSMessage:$,isQoSAck:Ce,isAckCleanupMessage:Te,ackMsgIds:Rt}}else e[r(1410)](X,t,96),e.LkksT(V,t,e[r(1222)](K,fe))}function A(s){let t=n,r={wvott:function(c,d){return e[R(1242)](c,d)},yjEwC:function(c,d){return c|d},HCVJv:function(c,d){return e[R(1544)](c,d)},aRFYs:function(c,d){return e.HgfSW(c,d)},qZymm:function(c,d){return e[R(1544)](c,d)},wXPZm:function(c,d){return e[R(1944)](c,d)},AeUKK:function(c,d){return e.COajq(c,d)},rOsbq:function(c,d){return e[R(547)](c,d)},lGbCy:function(c,d){return c+d}};if(e.aZAmc(e[t(1992)],e[t(726)])){let c=r[t(1458)](r[t(1523)](r[t(1523)](r[t(946)](r[t(1976)](7,_0x5425e2),18),r[t(706)](r[t(1976)](63,_0x78a563[_0x5261bc++]),12)),r[t(1578)](r[t(1976)](63,_0x580dab[_0x28e7d0++]),6)),r[t(1976)](63,_0xe86484[_0x288cc7++]))-65536;_0x5ac012+=_0x28dae4[t(1115)+t(1322)](r[t(931)](55296,r[t(1636)](c,10))),_0x49ab11+=_0xe06d2e[t(1115)+t(1322)](r[t(1342)](56320,1023&c))}else return e.yejpO(T,e[t(853)](ye,s))}function T(s){let t=n,r={};e:for(;!ue(s);){let c=e[t(954)](ee,s);switch(e.QpwvN(c,3)){case 0:break e;case 1:r[t(1026)]=mt(s,!0);break;case 2:r[t(1235)]=e[t(675)](mt,s,!0);break;case 3:r.service=e[t(1884)](ee,s);break;case 4:r.method=e[t(1064)](ee,s);break;case 5:{let d=e.recSl(z,s);(r[t(795)]||(r[t(795)]=[]))[t(684)](e[t(738)](_,s)),s[t(1278)]=d;break}case 6:r[t(609)+t(1570)]=e[t(1541)](te,s,e.WuSKH(ee,s));break;case 7:r[t(1060)+"ype"]=e.pOgLt(te,s,e[t(1400)](ee,s));break;case 8:r[t(1959)]=e[t(576)](F,s,ee(s));break;case 9:r[t(577)]=te(s,e.recSl(ee,s));break;case 10:r[t(618)+t(1348)]=e[t(1259)](te,s,e[t(1003)](ee,s));break;case 11:r[t(1662)]=e[t(576)](te,s,e[t(1003)](ee,s));break;case 12:r[t(1281)+"e"]=e[t(1888)](ee,s);break;default:e[t(1071)](Z,s,e[t(1268)](7,c))}}if(r.SeqID===void 0)throw new Error(e[t(784)]);if(e[t(1955)](void 0,r.LogID))throw new Error(e[t(1069)]);if(r[t(1702)]===void 0)throw new Error(e[t(737)]);if(e[t(724)](void 0,r.method))throw new Error(e[t(786)]);return r}function z(s){let t=n,r=e[t(1172)](ee,s),c=s[t(1278)];return s[t(1278)]=e[t(1040)](s[t(1536)],r),c}function Z(s,t){let r=n;switch(t){case 0:for(;e[r(1924)](128,e[r(1842)](se,s)););break;case 2:ie(s,e.jxsgg(ee,s));break;case 5:e.wZuvP(ie,s,4);break;case 1:ie(s,8);break;default:throw new Error(e[r(1962)]+t)}}function K(s){let t=n;return s|=0,{low:s,high:e.ohJQI(s,31),unsigned:e[t(1080)](s,0)}}let ce=[];function J(){let s=n,t={HpxEX:function(r,c,d){return e[R(1375)](r,c,d)},QOEJL:function(r,c,d){return e[R(576)](r,c,d)}};if(e[s(1815)](s(1794),e[s(1960)]))atXZQR[s(1684)](_0xbffdc2,_0x16703f,90),atXZQR[s(1837)](_0x43fbac,_0x39d6de,_0x25674b);else{let r=ce[s(1419)]();return r?(r[s(1536)]=r[s(1278)]=0,r):{bytes:new Uint8Array(64),offset:0,limit:0}}}function _e(s){ce.push(s)}function ye(s){return{bytes:s,offset:0,limit:s[n(633)]}}function Ne(s){let t=n,r=s.bytes,c=s[t(1278)];return e[t(494)](r[t(633)],c)?r:r[t(1683)](0,c)}function ie(s,t){let r=n;if(e[r(1649)](e.JAYCU(s[r(1536)],t),s[r(1278)]))throw new Error(e[r(1531)]);s[r(1536)]+=t}function ue(s){let t=n;return e[t(1942)](t(1e3),t(1e3))?e[t(1080)](s[t(1536)],s[t(1278)]):_0x29827b[t(1347)]()}function P(s,t){let r=n,c=s.bytes,d=s[r(1536)],h=s.limit,p=d+t;if(e[r(1649)](p,c[r(633)])){let w=new Uint8Array(e[r(1155)](2,p));w[r(833)](c),s[r(605)]=w}return s[r(1536)]=p,e[r(677)](p,h)&&(s[r(1278)]=p),d}function O(s,t){let r=n,c=s[r(1536)];if(e[r(677)](e.dbPXb(c,t),s[r(1278)]))throw new Error(e[r(1917)]);return s[r(1536)]+=t,c}function F(s,t){let r=n,c={wgGLq:function(d,h){return e.XMbeV(d,h)},GCteU:e[r(1247)],okqdg:r(2001),VbXWh:e.AkiDQ};if(e[r(1942)](e[r(1585)],e[r(1585)])){let d=O(s,t);return s.bytes[r(1683)](d,e.COajq(d,t))}else _0x4f73b3.r=d=>{let h=r;HhoZee.wgGLq(HhoZee[h(1853)],typeof _0x103bc5)&&_0x3b25e6[h(1887)+h(1006)]&&_0x4c61c5["definePr"+h(1797)](d,_0x2b5e71[h(1887)+h(1006)],{value:HhoZee[h(1083)]}),_0x1a4c0f[h(760)+h(1797)](d,HhoZee[h(1150)],{value:!0})}}function Se(s,t){let r=n,c=e.Osmux(P,s,t[r(633)]);s[r(605)][r(833)](t,c)}function te(s,t){let r=n,c=e[r(1790)](O,s,t),d=String["fromChar"+r(1322)],h=s.bytes,p="\uFFFD",w="";for(let l=0;e[r(1920)](l,t);l++){let b=h[e[r(473)](l,c)],I,k,M,N;if(e[r(1058)](e[r(1825)](128,b),0))w+=e[r(954)](d,b);else if(e.mjoPP(224&b,192))if(e[r(1757)](l+1,t))w+=p;else if(I=h[e[r(1040)](l,c)+1],e.lijBG(192,I)!==128)w+=p;else if(N=e[r(1242)](e[r(615)](31,b)<<6,63&I),e[r(1107)](N,128))w+=p;else if(e[r(494)](e[r(1520)],e[r(1512)])){_0x11e908[r(1569)](_0x28f3fd)||(_0x4afc7d=_0x594f09[r(1873)+"er"](_0x19f642));let H=e.QpwvN(this.high,16),fe=65535&this[r(1911)],j=e[r(1190)](this[r(1009)],16),$=e.lijBG(65535,this[r(1009)]),Ce=e[r(1109)](_0x44ed9b.high,16),Te=65535&_0x5b5843[r(1911)],Rt=_0x2594c8[r(1009)]>>>16,Vr=e[r(1294)](65535,_0x5b8e73[r(1009)]),ct=0,_t=0,Ve=0,xt=0;return xt+=$+Vr,Ve+=e[r(1190)](xt,16),xt&=65535,Ve+=j+Rt,_t+=e[r(1190)](Ve,16),Ve&=65535,_t+=fe+Te,ct+=e[r(1190)](_t,16),_t&=65535,ct+=e[r(473)](H,Ce),ct&=65535,_0x516dda[r(1054)](e[r(1242)](e.XShsT(Ve,16),xt),e[r(1242)](e[r(1944)](ct,16),_t),this[r(719)])}else w+=e[r(862)](d,N),l++;else if(e[r(814)](240,b)==224)if(e[r(1080)](l+2,t))w+=p;else if(I=h[e[r(545)](e.rJrGx(l,c),1)],k=h[e[r(545)](e[r(1413)](l,c),2)],e[r(787)](e[r(635)](e[r(1242)](I,e[r(1944)](k,8)),49344),32896))w+=p;else if(e[r(995)](e.pXvYY,"xPgBY"))N=e.WqCYy(e[r(944)](e[r(584)](15&b,12),e.unZmW(e[r(926)](63,I),6)),63&k),e[r(1107)](N,2048)||e[r(1080)](N,55296)&&e[r(870)](N,57343)?w+=p:(w+=e[r(742)](d,N),l+=2);else{let H="2|1|0|3|4"[r(1791)]("|"),fe=0;for(;;){switch(H[fe++]){case"0":if(_0x59147f[r(1283)+"e"])return _0x17df1d[r(1283)+"e"](_0x2bb07,_0x2237ef)+_0x533da3;continue;case"1":if(e[r(471)](_0x39dc43.length,40))return e.dUcen(_0x243352(_0x567471,_0x1684b9,_0x2aef18),_0x5a1999);continue;case"2":if(!_0x7277c1)return _0x3c1400;continue;case"3":if(_0x406cf7[r(744)])return _0x5a83d7[r(744)](_0x1a906c,_0x32ced9)+_0x42bb3b;continue;case"4":return e[r(804)](e.verQL(_0x42b044,_0x308f2b,_0x37a109,_0x2d4206),_0x400788)}break}}else e[r(1406)](248&b,240)?e[r(1080)](e[r(1040)](l,3),t)?w+=p:(I=h[e[r(1642)](l+c,1)],k=h[e.dbPXb(e[r(804)](l,c),2)],M=h[e[r(1040)](e.JAYCU(l,c),3)],e[r(2e3)](e[r(902)](e[r(944)](I,e.GPBgx(k,8)),e.GPBgx(M,16)),12632256)!==8421504?w+=p:(N=e[r(1343)](e[r(1044)](7&b,18),e[r(1119)](e[r(898)](63,I),12))|e[r(584)](e.vGDHQ(63,k),6)|e[r(1983)](63,M),e[r(1107)](N,65536)||e[r(1191)](N,1114111)?w+=p:(N-=65536,w+=d(e[r(1514)](e.ohJQI(N,10),55296),e[r(1885)](e[r(491)](1023,N),56320)),l+=3))):w+=p}return w}function he(s,t){let r=n;if(e[r(1029)](e[r(508)],e[r(508)])){let c=t.length,d=0;for(let w=0;e[r(1107)](w,c);w++)if(e.Hvhrq(e[r(560)],e[r(560)])){let l=t[r(1188)+"At"](w);e[r(1757)](l,55296)&&e[r(661)](l,56319)&&e[r(1524)](w,1)<c&&(l=e.wagGc(e[r(1044)](l,10)+t.charCodeAt(++w),56613888)),d+=e[r(1538)](l,128)?1:e.uIMGr(l,2048)?2:e[r(852)](l,65536)?3:4}else this[r(963)]=_0x6292b5,this[r(525)]=_0x4fc1a9,this._qosDB=_0xbeffb2?_0x176996:_0x237d09?_0x5b9c07:null;e.ddsXQ(X,s,d);let h=e[r(1813)](P,s,d),p=s[r(605)];for(let w=0;e[r(1448)](w,c);w++){let l=t[r(1188)+"At"](w);if(l>=55296&&e.ulvkA(l,56319)&&e[r(471)](w+1,c)&&(l=e[r(1972)](e[r(1467)](l<<10,t.charCodeAt(++w)),56613888)),l<128)p[h++]=l;else if(e[r(715)](e[r(1396)],e[r(1396)]))this[r(1901)+r(1289)]=_0x2477e2,this[r(722)]=0;else{if(e[r(819)](l,2048))p[h++]=e[r(1343)](e.PRGin(e[r(1800)](l,6),31),192);else if(e[r(1078)]!==e.bUFWQ){let b={aXnGY:function(I,k,M){return I(k,M)}};return new _0x4a9bda(I=>{let k=r;b.aXnGY(_0x50020e,I,this[k(1871)+k(1201)+"e"](_0x1cc486))})}else l<65536?p[h++]=e[r(679)](e[r(1706)](l,12),15)|224:(p[h++]=e[r(1362)](l>>18,7)|240,p[h++]=e.BziWf(e[r(1566)](l>>12,63),128)),p[h++]=e[r(1110)](e.fxgfu(e[r(1377)](l,6),63),128);p[h++]=e[r(926)](63,l)|128}}}else return this[r(1501)]?this._ws[r(1506)]:""}function Je(s,t){let r=n,c=P(s,t[r(1278)]),d=s[r(605)],h=t[r(605)];for(let p=0,w=t[r(1278)];p<w;p++)d[e.KKlib(p,c)]=h[p]}function se(s){let t=n;return s[t(605)][e[t(1259)](O,s,1)]}function it(s,t){let r=n,c=e[r(1790)](P,s,1);s[r(605)][c]=t}function ee(s){let t=n;if(e[t(555)](t(745),e[t(1180)])){let r=0,c=0,d;do d=se(s),e.LYwlx(r,32)&&(c|=e.unZmW(127&d,r)),r+=7;while(128&d);return c}else _0x20938c[t(1974)](_0x52f0ab)}function X(s,t){let r=n;for(t>>>=0;e[r(920)](t,128);)e.VaLVW(it,s,e.mizFz(127,t)|128),t>>>=7;e[r(1782)](it,s,t)}function mt(s,t){let r=n,c={Tsgue:e[r(1543)],FjcUR:function(d,h,p){return e[r(962)](d,h,p)}};if(e[r(1817)]===e[r(1817)]){let d=0,h=0,p=0,w;return w=se(s),d=127&w,e[r(692)](128,w)&&(w=e[r(1629)](se,s),d|=e[r(1119)](e[r(1994)](127,w),7),e[r(1134)](128,w)&&(w=e[r(742)](se,s),d|=(127&w)<<14,128&w&&(w=se(s),d|=e[r(1119)](e[r(1385)](127,w),21),e[r(1095)](128,w)&&(w=e[r(1309)](se,s),h=e.IlUBh(127,w),128&w&&(w=se(s),h|=e.kbJmc(e[r(1113)](127,w),7),e[r(588)](128,w)&&(w=se(s),h|=e[r(1490)](e[r(659)](127,w),14),e[r(814)](128,w)&&(w=se(s),h|=e.pkQHT(e.pfbKM(127,w),21),128&w&&(e[r(1239)](e[r(1264)],e[r(1264)])?(w=e[r(1888)](se,s),p=e[r(635)](127,w),128&w&&(w=e[r(1526)](se,s),p|=e.fHAps(e[r(1820)](127,w),7))):this.emit(c[r(821)],c.FjcUR(_0x49c176,c.Tsgue,{message:this["_formatE"+r(549)+r(1880)](_0x4406e1)})))))))))),{low:e[r(1193)](d,e[r(1728)](h,28)),high:e[r(694)](e[r(1109)](h,4),p<<24),unsigned:t}}else return this[r(585)+"T"]||this._isMiniWX?this[r(1977)+r(452)+"line"]:(this._isBrowser||this._isWorker)&&this[r(1539)][r(464)+"tworkCha"+r(1823)]?_0x368cc4[r(904)]:!0}function V(s,t){let r=n,c=e[r(783)](t[r(1009)],0),d=e[r(944)](e[r(1431)](t[r(1009)],28),e.RsyLB(t.high,4))>>>0,h=e.ZyrPM(t[r(1911)],24),p=e.GkmEt(0,h)?e[r(1942)](0,d)?e[r(876)](c,16384)?e[r(819)](c,128)?1:2:e[r(1047)](c,2097152)?3:4:d<16384?e.CPpVp(d,128)?5:6:e[r(1047)](d,2097152)?7:8:h<128?9:10,w=e.FJDSu(P,s,p),l=s[r(605)];switch(p){case 10:l[e.IGaqG(w,9)]=e[r(1473)](h,7)&1;case 9:l[e[r(1467)](w,8)]=e[r(608)](9,p)?128|h:127&h;case 8:l[e[r(473)](w,7)]=p!==8?d>>>21|128:e[r(2004)](d>>>21,127);case 7:l[w+6]=e[r(1432)](7,p)?e[r(1343)](e.udSGX(d,14),128):e[r(1839)](e[r(1109)](d,14),127);case 6:l[e.jlrtQ(w,5)]=p!==6?e[r(1624)](e[r(1925)](d,7),128):e.lijBG(e[r(1431)](d,7),127);case 5:l[e[r(1394)](w,4)]=e[r(1034)](5,p)?128|d:e[r(1566)](127,d);case 4:l[e.Iutrn(w,3)]=e[r(1432)](4,p)?e.ZyrPM(c,21)|128:e.fNXuF(e.OYNSq(c,21),127);case 3:l[e.ftxcV(w,2)]=e.QppYP(3,p)?e[r(1624)](e.uNwtV(c,14),128):e[r(588)](c>>>14,127);case 2:l[e[r(565)](w,1)]=e.RxxrZ(2,p)?e[r(1242)](e[r(1431)](c,7),128):e[r(790)](e.ZyrPM(c,7),127);case 1:l[w]=e[r(1717)](1,p)?128|c:127&c}}function At(s){return e[n(1073)](A,s)}function oe(s){return e.HOYbN(S,s)}let Pt=65536,be="\0\0\0\0\0\0\0\0",Ct=Pt*Pt,es=e[n(1159)](Ct,Ct),ts=es/2,st=String[n(1037)+"e"][n(1188)+"At"];class W{constructor(t,r,c){let d=n;this.isLong=!0,this[d(1009)]=0|t,this[d(1911)]=e[d(721)](0,r),this[d(719)]=!!c}static[n(1569)](t){return t&&e[n(1633)](!0,t.isLong)}static[n(1054)](t,r,c){return new W(t,r,c)}static fromBytes(t,r,c){let d=n,h={ELSjy:function(p,w){return p||w}};if(e[d(1522)]===d(1051)){let p=this[d(1945)][d(629)](this[d(499)]);return _0x302d67[d(1263)](h[d(1935)](p,"{}"))[_0x454e4d]}else return c?W[d(625)+d(1052)](t,r):W["fromByte"+d(1266)](t,r)}static["fromByte"+n(1052)](t,r){let c=n;return new W(e.WqCYy(e.vccKc(t[0],e[c(1490)](t[1],8))|t[2]<<16,e[c(710)](t[3],24)),e[c(1193)](e.szbcs(t[4]|e.fHAps(t[5],8),e[c(710)](t[6],16)),e.qLIzE(t[7],24)),r)}static[n(625)+n(1266)](t,r){let c=n;return new W(e[c(1181)](e[c(587)](e[c(1490)](t[4],24)|e.HDDWB(t[5],16),t[6]<<8),t[7]),e.NVDNh(e.piqTx(t[0]<<24,e[c(767)](t[1],16)),t[2]<<8)|t[3],r)}static[n(990)](t){let r=n;return e.EjwEV(t,be)?ns:new W(e[r(728)](e[r(1903)](e.NVDNh(st[r(1664)](t,0),e[r(657)](st[r(1664)](t,1),8)),e[r(830)](st[r(1664)](t,2),16))|e[r(1044)](st.call(t,3),24),0),e[r(1925)](e[r(1698)](e[r(539)](e.HrtKF(st[r(1664)](t,4),e[r(1673)](st.call(t,5),8)),e[r(1049)](st[r(1664)](t,6),16)),e[r(1728)](st[r(1664)](t,7),24)),0),!0)}[n(1341)](){let t=n;return String["fromChar"+t(1322)](e[t(1258)](255,this.low),e[t(1057)](e[t(489)](this[t(1009)],8),255),e[t(1987)](e[t(1431)](this[t(1009)],16),255),e[t(1645)](this[t(1009)],24),e[t(926)](255,this[t(1911)]),e[t(692)](this.high>>>8,255),e.LHcXH(e[t(783)](this[t(1911)],16),255),e[t(1943)](this[t(1911)],24))}static[n(1873)+"er"](t,r=!0){let c=n;if(e[c(1704)](isNaN,t))return r?Wc:ns;if(r){if(e.BQVYy(t,es))return Jc}else{if(t<=-ts)return Vc;if(e[c(920)](e[c(565)](t,1),ts))return $c}return W[c(1054)](e.BziWf(t%Ct,0),e[c(1966)](t/Ct,0),r)}toNumber(){let t=n;return this[t(719)]?e[t(1676)](e[t(1767)](e[t(967)](this.high,0),Ct),e[t(1943)](this[t(1009)],0)):e[t(480)](e[t(1159)](this[t(1911)],Ct),e[t(681)](this[t(1009)],0))}[n(1509)](){let t=n;return e[t(849)](0,this[t(1911)])&&this[t(1009)]===0}add(t){let r=n;if(e[r(1002)]("OLYRm",r(571)))_0x5ab164=e.hjTlL(_0x172c82,_0x36debd),e[r(471)](_0x8a80a,32)&&(_0x58d57|=e[r(1728)](e.EbJNx(127,_0x112ec5),_0x551faf)),_0x968e8d+=7;else{W.isLong(t)||(t=W[r(1873)+"er"](t));let c=this.high>>>16,d=e[r(1382)](65535,this.high),h=this[r(1009)]>>>16,p=e.RZEpi(65535,this[r(1009)]),w=e[r(591)](t.high,16),l=e.SpQnv(65535,t.high),b=e[r(1645)](t[r(1009)],16),I=e[r(1671)](65535,t.low),k=0,M=0,N=0,H=0;return H+=e[r(1885)](p,I),N+=e.uvEXW(H,16),H&=65535,N+=e.Zjclv(h,b),M+=e[r(1918)](N,16),N&=65535,M+=e[r(575)](d,l),k+=e[r(1922)](M,16),M&=65535,k+=e[r(473)](c,w),k&=65535,W[r(1054)](e[r(1193)](e[r(1044)](N,16),H),e[r(1728)](k,16)|M,this[r(719)])}}[n(1758)](t){let r=n,c={FTlVx:function(h,p,w,l){return e.verQL(h,p,w,l)}};if(e[r(1792)](e.vqKwy,e[r(1303)]))return W.isLong(t)||(t=W[r(1873)+"er"](t)),e[r(1781)](this[r(719)],t.unsigned)&&e[r(993)](e[r(1922)](this[r(1911)],31),1)&&e[r(783)](t[r(1911)],31)===1?!1:e[r(1058)](this[r(1911)],t[r(1911)])&&e[r(1715)](this[r(1009)],t[r(1009)]);for(var d in _0x3962b4)IgIxYo[r(1858)](_0x3242d5,_0x3b6721,d,{get:_0x144965[d],enumerable:!0})}[n(1228)](){let t=n;return e[t(1564)](-1,this[t(1009)])&&e[t(1143)](-1,this.high)?W[t(1054)](0,0,this.unsigned):e[t(1955)](-1,this[t(1009)])?W[t(1054)](0,e[t(866)](this.high,1),this[t(719)]):W[t(1054)](e.wJWRE(this[t(1009)],1),this.high,this.unsigned)}toBytes(t){let r=n;return t?this[r(1906)+"E"]():this[r(872)+"E"]()}toBytesLE(){let t=n,r=this[t(1911)],c=this[t(1009)];return[e.WuRap(255,c),e[t(591)](c,8)&255,c>>>16&255,c>>>24,255&r,e[t(1466)](r>>>8,255),e[t(491)](e[t(967)](r,16),255),e[t(820)](r,24)]}[n(872)+"E"](){let t=n,r=this[t(1911)],c=this[t(1009)];return[e[t(708)](r,24),e.XpbGK(e[t(1755)](r,16),255),r>>>8&255,255&r,e[t(489)](c,24),e[t(1709)](e.ddEgM(c,16),255),e[t(491)](e[t(1645)](c,8),255),e[t(1947)](255,c)]}}let ns=new W(0,0,!1),Wc=new W(0,0,!0),$c=W[n(1054)](-1,2147483647,!1),Jc=W[n(1054)](-1,-1,!0),Vc=W[n(1054)](0,-2147483648,!1);var ot=(function(s){let t=n;return s[s[e[t(733)]]=5001]=e[t(733)],s[s[t(469)+t(1166)]=5002]=e[t(1963)],s[s[e.NIKeZ]=5003]=e[t(645)],s[s[e[t(1189)]]=5004]="MESSAGE_"+t(1359),s[s[e[t(614)]]=5005]=t(1063)+"OR",s})({});class Tt{constructor(t){let r=n;this[r(1262)]=t,this[r(1096)]=null}}class rs extends Tt{constructor(t,r){let c=n;super(t),this.message=r&&r[c(1315)]||null}}class is extends Tt{constructor(t,r){let c=n,d=e[c(624)].split("|"),h=0;for(;;){switch(d[h++]){case"0":this[c(1315)]=r&&r.message||"";continue;case"1":this[c(1079)]=r&&r[c(1079)]||5001;continue;case"2":this[c(1557)]=r&&r.colno||0;continue;case"3":this.filename=r&&r[c(444)]||"";continue;case"4":super(t);continue;case"5":this[c(1609)]=r&&r[c(1609)]||null;continue;case"6":this.lineno=r&&r[c(595)]||0;continue}break}}}class ss extends Tt{constructor(t,r){let c=n,d=e[c(1132)][c(1791)]("|"),h=0;for(;;){switch(d[h++]){case"0":this[c(1409)+"nnect"]=r&&r[c(1409)+c(1087)]||!1;continue;case"1":this[c(1079)]=r&&r[c(1079)]||0;continue;case"2":this[c(1832)]=r&&r.reason||"";continue;case"3":super(t);continue;case"4":this[c(1378)]=r&&r.wasClean||!1;continue}break}}}class os extends Tt{constructor(t,r){let c=n;super(t),this[c(564)]=r&&r.data||null}}class as extends os{constructor(t,r){let c=n;super(t),this[c(564)]=r&&r[c(564)]||null,this[c(1315)]=r&&r[c(1315)]||null}}class cs extends Tt{constructor(t,r){super(t),this.data=r&&r.data||null}}function Pe(s,{message:t,code:r,error:c}){return new is(s,{message:t,code:r,error:c})}function Oe(s,{code:t,reason:r,wasClean:c,willReconnect:d}){return new ss(s,{code:t,reason:r,wasClean:c,willReconnect:d})}function xs(s,{data:t,message:r}){return new as(s,{data:t,message:r})}function ds(s,{data:t}){return new cs(s,{data:t})}function qr(s,{message:t}){return new rs(s,{message:t})}class us{constructor(t,r){let c=n;this[c(1077)+"s"]=t,this[c(682)+"es"]=r,this[c(863)+c(1504)]=0,this[c(472)+c(1414)+c(1404)+"t"]=0}[n(1423)+n(1821)+n(1152)](){let t=n;this[t(863)+t(1504)]=0,this[t(472)+t(1414)+"riesCount"]=0}[n(1975)+"es"](){let t=n,r={jxUXm:function(c,d,h){return e[R(758)](c,d,h)}};if(e[t(1239)](e[t(704)],e[t(702)]))return _0x9c9e6a[t(605)][UPmaPF[t(723)](_0x328821,_0x300b54,1)];this["currentEndpointT"+t(1404)+"t"]=0}[n(1890)+n(1613)+"nt"](){let t=n;return this[t(1077)+"s"][this[t(863)+t(1504)]]}["getCurrentEndpoi"+n(973)+n(1289)](){let t=n;return this[t(472)+t(1414)+t(1404)+"t"]}checkReachMaxTries(){let t=n;return!!(e[t(1249)](this[t(863)+t(1504)],this[t(1077)+"s"].length)||this[t(863)+t(1504)]===e.mcGqg(this[t(1077)+"s"][t(633)],1)&&e.ACogE(this[t(472)+t(1414)+t(1404)+"t"],this[t(682)+"es"]))}[n(1100)+n(518)+"ointReac"+n(953)+"tries"](){let t=n,r={uffaP:function(c,d){return e.jNRZA(c,d)},uHmEJ:function(c,d){return e.DJYWG(c,d)}};if(e[t(1001)]!=="AQJId")return e[t(1850)](this[t(863)+t(1504)],this[t(1077)+"s"][t(633)])?!0:e[t(1649)](this[t(472)+t(1414)+"riesCount"],this.maxRetries);{let{value:c,offset:d}=_0x24bda9(_0x5b3278,_0x28e32a);_0xfe0e85=d,_0x459b14=r[t(798)](r.uHmEJ(_0x5024a3,8),0),_0x3dbad6+=c}}["replaceB"+n(927)+n(1830)+"UpdateCount"](){let t=n;if(e[t(1968)]===e[t(1968)])return this[t(472)+"ndpointTriesCount"]=1,this["currentI"+t(1504)]++,this.endpoints[this[t(863)+t(1504)]];++_0x535267,_0x5b6d86+=4}[n(1890)+"ntEndpoi"+n(543)+n(751)](){let t=n;return this[t(472)+t(1414)+t(1404)+"t"]++,this[t(1890)+t(1613)+"nt"]()}}let kt=(e[n(964)](n(908)+"d",typeof globalThis)&&e[n(878)](e[n(663)],globalThis[n(593)+"tor"][n(2006)])||e[n(964)](e.rpLvM,typeof window)&&e[n(1607)](e.SoUHr,window["construc"+n(1851)][n(2006)]))&&e[n(867)](n(908)+"d",typeof document),wt=e[n(818)](e[n(1247)],typeof globalThis)&&(e[n(562)](e[n(1982)],globalThis.constructor[n(2006)])||e[n(1734)](e[n(978)],globalThis[n(593)+"tor"].name))&&e[n(1822)](e[n(1247)],typeof tt),en=(e[n(1194)](e[n(1247)],typeof globalThis)&&e[n(901)](e.eXNCk,globalThis[n(593)+"tor"][n(2006)])||e[n(1406)](n(908)+"d",typeof globalThis)||e[n(964)](e[n(1247)],typeof globalThis)&&!!globalThis[n(1296)+n(573)])&&e.XDiUX(e[n(1247)],typeof wx),tn=e[n(877)](e[n(1247)],typeof globalThis)&&(e.qShSw(e.FAaEI,globalThis[n(593)+n(1851)][n(2006)])||e[n(1882)](e[n(1511)],globalThis[n(593)+n(1851)].name)||e[n(1875)](e[n(1648)],globalThis[n(593)+"tor"][n(2006)]))&&e[n(1403)](n(908)+"d",typeof self),Yc=e[n(1285)](e[n(1247)],typeof globalThis)&&e[n(1711)](e[n(1982)],globalThis[n(593)+n(1851)][n(2006)])&&e[n(1194)]("undefined",typeof global)&&e[n(1982)]===global[n(593)+n(1851)].name&&e[n(1247)]!=typeof process&&!!process[n(1627)];class Gr{constructor(){let t=n;this[t(667)+"rs"]={}}emit(t,...r){let c=n,d=this._listeners[t];if(d)d[c(1274)]()[c(1876)](h=>h.fn[c(1389)](h[c(1720)],r));else if(e[c(1543)]===t&&!this[c(1952)]){let h=r.length&&r[0];if(e[c(1368)](h,Error))throw h;let p=new Error(e[c(1040)](e.WkNfr,h?e.bwlZt(" ("+h.message,")"):""));throw p[c(809)]=h,h}return this}[n(1260)](t,r){let c=n;if(t===void 0)this[c(667)+"rs"]={};else if(e[c(1061)](void 0,r))this[c(667)+"rs"][t]=null;else{let d=this._listeners[t];if(d)for(let h=0;h<d.length;)d[h].fn===r?d[c(1127)](h,1):++h}return this}on(t,r,c){let d=n;return(this[d(667)+"rs"][t]||(this[d(667)+"rs"][t]=[]))[d(684)]({fn:r,ctx:c||this}),this}}class Xc extends Gr{[n(448)+"rrorMess"+n(1880)](t){let r=n;return t[r(532)]||t[r(762)]?(r(1692)+" "+(t[r(532)]||"")+" code: "+(t.errNo||"")).trim():JSON[r(1990)+"y"](t)}constructor(t,r,c){let d=n;super(),this[d(851)]=null,en&&wx[d(945)+d(1803)]&&(this[d(851)]=wx[d(945)+d(1803)]({url:t,protocols:r,header:c,fail:this[d(1731)+d(524)+d(974)][d(1334)](this),success:this["_createS"+d(1937)+"cessHandler"].bind(this)})),wt&&tt[d(945)+d(1803)]&&(this._socket=tt[d(945)+d(1803)]({url:t,protocols:r,header:c,fail:this["_createS"+d(524)+d(974)].bind(this),success:this[d(1731)+d(1937)+"cessHand"+d(1862)][d(1334)](this)}))}[n(1731)+n(1937)+"cessHand"+n(1862)](){let t=n,r={FMgow:function(c){return c()},GzwvR:function(c){return e[R(461)](c)}};e.uTesj(e[t(1427)],e.vMLKN)?Promise.resolve().then(()=>{this[t(1045)+"steners"]()}):(MXWttz.FMgow(_0x423ff1),MXWttz[t(1437)](_0x416bec))}["_createS"+n(524)+"lHandler"](t){let r=n,c={OzWHY:function(d,h,p){return e[R(1928)](d,h,p)},isgmX:e[r(1543)],cEGpg:e[r(600)]};Promise.resolve()[r(1098)](()=>{let d=r,h=c.OzWHY(Pe,c.isgmX,{message:this[d(448)+d(549)+"age"](t)});this.emit(c[d(1726)],h);let p=c[d(1094)](Oe,c[d(1068)],{reason:this[d(448)+d(549)+"age"](t)});this[d(2008)](c[d(1068)],p)})}[n(1045)+n(1558)](){let t=n,r={ljdEq:e[t(1707)],PeaZV:function(c,d,h){return e.JMEAF(c,d,h)},GJIRY:e.wvTVR,dridv:e.DVbGh,QEOmZ:e[t(1543)]};this[t(851)][t(1116)](c=>{let d=t;this[d(2008)](r.ljdEq,r[d(1084)](ds,r[d(1761)],{...c,data:c[d(532)]||""}))}),this[t(851)][t(551)](c=>{let d=t;this[d(2008)](r[d(1957)],r.PeaZV(Oe,d(1681),{...c}))}),this._socket.onMessage(c=>{let d=t;this[d(2008)](r[d(855)],xs(r[d(855)],{...c}))}),this[t(851)][t(1135)](c=>{let d=t;this[d(2008)](r[d(896)],Pe(r[d(896)],{...c,message:c[d(532)]||""}))})}[n(1764)](t){let r=n,c={Unylv:function(d,h){return d===h},Qocxp:e[r(1033)],tlMND:r(879),OfcuO:function(d,h,p){return e[r(1782)](d,h,p)},vtdtZ:r(1609)};if(e[r(1368)](t,Uint8Array)){let d=t[r(1565)][r(1274)](t[r(1354)+"et"],t[r(557)+"th"]+t[r(1354)+"et"]);this[r(851)]&&this._socket.send({data:d,fail:h=>{let p=r;this.emit(e.HqQse,e[p(1541)](Pe,p(1609),{message:this[p(448)+p(549)+p(1880)](h)}))}})}else this._socket&&this._socket[r(1764)]({data:t,fail:d=>{let h=r;c[h(656)](c[h(1542)],c[h(665)])?(_0x252b35=_0x16b0b7(_0x1eb975),_0x5e0c7d=0):this[h(2008)](h(1609),c[h(468)](Pe,c[h(1665)],{message:this[h(448)+"rrorMessage"](d)}))}})}[n(1681)](t,r){let c=n,d={PLePs:c(1117),sTqOq:function(h,p,w){return e.IYcSu(h,p,w)}};e[c(1390)](e.EERpU,e[c(984)])?this[c(2008)](IqEPKN.PLePs,IqEPKN[c(616)](_0x2531c4,IqEPKN[c(1727)],{..._0xb8eddf,data:_0x3cba90[c(532)]||""})):this[c(851)]&&this[c(851)][c(1681)]({code:t,reason:r})}[n(1424)+"Listener"](t,r){this.on(t,r)}["removeEv"+n(1932)+"ner"](t,r){this[n(1260)](t,r)}get[n(1576)+"te"](){let t=n;return t(755)===e.JQfya?this[t(851)][t(1576)+"te"]:this._ws?this[t(1501)].url:this._url}get[n(718)+"pe"](){let t=n;return this._socket[t(718)+"pe"]}set[n(718)+"pe"](t){}get[n(1493)](){return this[n(851)].url}get[n(1506)](){let t=n;return this[t(851)][t(1506)]}get[n(652)+"ns"](){let t=n;return this[t(851)][t(652)+"ns"]}get[n(1399)+n(1395)](){return 0}}function Zc(s,t){let r=n;if(t)return new t(s[r(1493)],s[r(1506)]);if(en||wt)return new Xc(s.url,s.protocol,s[r(795)]);if((kt||tn)&&e[r(818)](e[r(1247)],typeof WebSocket)&&WebSocket)return new WebSocket(s[r(1493)],s.protocols)}function Qc(s){let t=n;return!!(s||en&&wx[t(945)+t(1803)]||wt&&tt[t(945)+t(1803)]||e[t(832)](kt,tn)&&e[t(638)](t(908)+"d",typeof WebSocket)&&WebSocket)}function fs(s,t,r){let c=n,d={cSyRd:function(w,l){return e[R(504)](w,l)},VkJhR:"AnkSn",XaZJl:function(w,l){return e[R(661)](w,l)},ZizZf:e[c(1007)]},h=-1;async function p(w){let l=c,b={Wduwn:function(I,k){return I(k)}};if(d[l(1349)](d[l(1848)],d.VkJhR))return d[l(1831)](w,h)?Promise[l(477)](new Error(d[l(1043)])):(h=w,d[l(1349)](w,r[l(633)])?Promise.resolve():r[w][l(1334)](s)(t,p.bind(null,w+1)));{let I=_0x8ec384[l(942)+l(541)](_0x481613);return _0x30e0b3&&I["addEvent"+l(826)](l(1300),()=>_0xa485dd()),IYbomy[l(857)](_0x108c2e,I)[l(1098)](()=>{})}}e[c(862)](p,0)}function ls(s){let t=n,r=0,c=0;for(let d=0;e.kvSes(d,s[t(633)]);++d)c=s[t(1188)+"At"](d),e[t(823)](c,128)?r+=1:e[t(800)](c,2048)?r+=2:e[t(743)](64512,c)===55296&&e[t(1153)](e.PrJCC(64512,s.charCodeAt(e.JAYCU(d,1))),56320)?(++d,r+=4):r+=3;return r}function gs(s,t,r){let c=n;if(e[c(876)](e[c(1863)](r,t),1))return"";let d="";for(let h=t;h<r;){let p=s[h++];if(e[c(966)](p,127))d+=String[c(1115)+c(1322)](p);else if(e[c(1588)](p,192)&&e.SgTQB(p,224))d+=String[c(1115)+c(1322)](e[c(584)](e[c(1994)](31,p),6)|e[c(676)](63,s[h++]));else if(e[c(835)](p,224)&&e[c(780)](p,240))d+=String.fromCharCode(e[c(1698)](e[c(1939)]((15&p)<<12,e[c(1119)](63&s[h++],6)),63&s[h++]));else if(e[c(1249)](p,240)){let w=e[c(1151)](e[c(497)](e.BYnPy(e[c(1360)](e[c(628)](7,p),18),e[c(1490)](e[c(1839)](63,s[h++]),12))|e.KlYhl(63,s[h++])<<6,e.NkTlL(63,s[h++])),65536);d+=String["fromChar"+c(1322)](55296+e.jKjVw(w,10)),d+=String["fromChar"+c(1322)](e[c(1984)](56320,e[c(635)](1023,w)))}}return d}function Hr(s,t,r){let c=n,d={cDFbT:function(l,b,I){return e.LCvJI(l,b,I)},EvHSW:function(l,b,I){return l(b,I)}},h=r,p,w;for(let l=0;e[c(1107)](l,s[c(633)]);++l)if(p=s[c(1188)+"At"](l),e.FwzkW(p,128))t[r++]=p;else if(p<2048)e[c(613)]===e[c(613)]?(t[r++]=e.vccKc(e[c(547)](p,6),192),t[r++]=e[c(1434)](e[c(730)](63,p),128)):(!_0x2e2d26[c(1031)+"d"]&&(this[c(1632)+"er"]&&_0x200c67["removeEventListe"+c(903)](e[c(1292)],this[c(770)+"ageHide"]),this[c(1632)+"er"]&&_0x5d7c36[c(707)+c(1932)+c(903)](e[c(1500)],this[c(770)+"ageShow"]),this.close()),this[c(1632)+"er"]&&_0x2b19c3[c(707)+"entListener"](e[c(459)],this["_handleO"+c(1114)]),this[c(1632)+"er"]&&_0x29f6b0[c(707)+"entListe"+c(903)](c(1487),this["_handleO"+c(1446)]));else if(e[c(1971)](e[c(692)](64512,p),55296)&&e.wBNSy(e[c(1983)](64512,w=s[c(1188)+"At"](e.xzGmH(l,1))),56320)){let b=(c(649)+c(1420))[c(1791)]("|"),I=0;for(;;){switch(b[I++]){case"0":t[r++]=e[c(790)](e.OCXuk(p,12),63)|128;continue;case"1":t[r++]=e[c(1110)](63&p,128);continue;case"2":t[r++]=p>>18|240;continue;case"3":p=e[c(651)](65536+e.kbJmc(e[c(1258)](1023,p),10),1023&w);continue;case"4":++l;continue;case"5":t[r++]=e[c(1927)](e.oXTlr(p>>6,63),128);continue}break}}else e[c(1792)](e.PWHtk,e[c(1210)])?(t[r++]=e[c(1343)](p>>12,224),t[r++]=e[c(538)](e[c(1377)](p,6)&63,128),t[r++]=e[c(1361)](e[c(1924)](63,p),128)):(jGGeNP[c(1643)](_0x1cd3ef,_0x24a1b9,66),jGGeNP.EvHSW(_0x3f8c86,_0x47f772,_0xbcf165[c(633)]),jGGeNP[c(1481)](_0x97eef0,_0x473962,_0x4aa7ab));return r-h}async function hs(s){let t=n;if(e.gnkCE(t(923),typeof s)){let r=new Uint8Array(e[t(1750)](ls,s));return e[t(1253)](Hr,s,r,0),r}return e[t(1368)](s,ArrayBuffer)?new Uint8Array(s):new Uint8Array(s.buffer,s[t(1354)+"et"],s[t(557)+"th"])}function e0(s){let t=n,r={lyYtA:function(c,d){return e[R(1140)](c,d)},PcZqW:function(c,d){return e[R(480)](c,d)},qqXRR:e[t(1531)]};try{if(e[t(1781)]("Isjms",t(1220))){if(GkWKLm.lyYtA(GkWKLm[t(919)](_0x4d6adb[t(1536)],_0xb81f11),_0x5e5e06.limit))throw new _0x3082d0(GkWKLm.qqXRR);_0x2de908.offset+=_0x5d3a56}else return e.rHNDc(e[t(802)],typeof s)&&(e[t(1368)](s,ArrayBuffer)||s[t(1565)]&&e.DnuNE(s[t(1565)],ArrayBuffer))||e[t(1194)](e[t(802)],typeof s)?"":(JSON.parse(s),t(672)+t(987))}catch{return e[t(1141)](t(923),typeof s)?e[t(1689)]:""}}let t0=(s,t)=>{let r=n;switch(s){case e[r(956)]:case e[r(1535)]:return{[r(542)+s]:1,"x-tt-env":t};default:return{}}};class n0{constructor(t){let r=n;this[r(1901)+r(1289)]=t,this[r(722)]=0}[n(578)](){let t=n;t(1304)===t(1652)?(_0x2f92aa="wss://",_0xa43f27=_0xb5a17e.replace(/(^http)((?:[s]*:\/\/))/,""),_0x114e43=/(^ws)((?:[s]*:\/\/))/[t(885)](_0x3857e4)?_0x1d3fbb:""+_0x4eb2fd+_0x2416c9):this[t(722)]++}[n(983)+"chMaxCount"](){let t=n;if(e.aOHmi(e.pBdTE,t(1669))){let{offset:r}=e[t(1259)](_0x7d5482,_0x396559,_0x2544cb);_0x55e801=r;let c={cursor_name:"",cursor:0,service:0},{value:d,offset:h}=_0x39ff5d(_0x36bcc9,_0x5ac1d6);c[t(1702)]=d,_0x38f9de=h;let{value:p,offset:w}=e[t(1316)](_0x1e813f,_0x206074,_0x4baea4);_0x521141=w,c["cursor_n"+t(1997)]=e[t(1958)](_0x310600,_0x239860,_0x529038,e[t(918)](_0x37ed47,p)),_0x1d57d1+=p;let{value:l,offset:b}=e.cWOhc(_0x5741e7,_0x4d8624,_0x3f497c);c[t(680)]=l.toNumber(),_0x3f8ce7=b,_0x1975c9[t(684)](c)}else return this[t(722)]>=this[t(1901)+t(1289)]}[n(1337)+n(1255)](t=0){let r=n;this.maxLossCount=t,this[r(722)]=0}}async function r0(s){let t=n,r={pvqjc:function(c,d){return c(d)},UuPLT:e[t(1572)],AfNIT:function(c,d){return e[t(1131)](c,d)},iRIYO:function(c,d){return e[t(638)](c,d)},luLlk:e[t(1247)],DPlHt:e[t(640)],dOaSc:t(1386)+t(1796),PuCJD:e[t(1646)],guWdD:function(c,d){return e[t(1143)](c,d)},LbFoM:t(1421),ManMp:function(c,d){return e[t(1172)](c,d)},vDPDE:function(c,d){return e.CXLqE(c,d)},Klgku:function(c,d){return e[t(1182)](c,d)}};return e.zuHZo(t(1657),e[t(858)])?new Promise(c=>{let d=t,h={GGINt:function(p,w){return r[R(1293)](p,w)},PWLxv:function(p,w){return r[R(453)](p,w)},dXFRY:r[d(897)]};if(!kt)return c(r[d(782)]);try{let p=document[d(1163)+"ement"](r[d(1923)]);window[d(1106)+d(781)]=w=>{let l=d;document[l(556)][l(1964)+l(1376)](p),window[l(1106)+l(781)]=void 0,r[l(1474)](c,w&&w[l(630)]||r[l(782)])},p.type=r[d(1573)],p.src=s.replace(/^ws/,d(1705))+r.PuCJD;try{if(r[d(1187)](r[d(1804)],"GFbZE")){if(_0x34f801)return new _0x4a2964(_0x4bac25[d(1493)],_0x19f89e[d(1506)]);if(KJaqoP[d(1869)](_0x2eb0c9,_0x1ba526))return new _0x428498(_0x2430ed[d(1493)],_0x37a03c[d(1506)],_0x4af479[d(795)]);if(KJaqoP.GGINt(_0x295b97,_0x500b0f)&&KJaqoP[d(1530)](KJaqoP.dXFRY,typeof _0xda5785)&&_0x3c6409)return new _0x5e5868(_0x2ca19b[d(1493)],_0x6d9757[d(1506)+"s"])}else document[d(556)][d(1751)+d(1376)](p)}catch{document[d(556)][d(1964)+"ild"](p)}}catch{window["frontier"+d(781)]=void 0,r[d(824)](c,r[d(782)])}}):!!(ejmDHj.vDPDE(this["currentI"+t(1504)],this[t(1077)+"s"][t(633)])||this[t(863)+t(1504)]===ejmDHj[t(754)](this[t(1077)+"s"][t(633)],1)&&this[t(472)+"ndpointT"+t(1404)+"t"]===this[t(682)+"es"])}function at(s,t,r){return!!s?.[n(647)](d=>d.key===t&&d.value===r)}function Dt(s,t){let r=n;return s?.[r(647)](c=>c.key===t)?.[r(732)]}let Kr=null;async function i0(){let s=n;return Kr||(Kr=Promise.resolve()[s(1098)](Ke[s(1334)](Ke,s(1231)))),Kr}class s0 extends Gr{constructor(t,r){let c=n,d={EXolp:function(h,p){return h<p},awooA:function(h,p){return e[R(1633)](h,p)},wFGeT:function(h,p){return e[R(1466)](h,p)},SzSAV:function(h,p){return h&p},SuFXL:function(h,p){return e[R(1642)](h,p)}};e[c(1956)](e[c(843)],"UgsHE")?(_0x57a430=_0x5b3a1c[c(1188)+"At"](_0x484a59),TNoCKb[c(1521)](_0x376b8b,128)?_0xc5c767+=1:TNoCKb[c(1521)](_0x4453f0,2048)?_0x5a056c+=2:TNoCKb[c(1161)](TNoCKb.wFGeT(64512,_0x53d7d2),55296)&&TNoCKb[c(1161)](TNoCKb[c(664)](64512,_0x175a28.charCodeAt(TNoCKb.SuFXL(_0x3ba885,1))),56320)?(++_0x1470ae,_0x121a4a+=4):_0x46a9ce+=3):(super(),this[c(512)]=t,this._keyPath=r,this[c(1945)]=void 0,this[c(1612)+c(1455)]=null)}async openDB(){await this[n(523)]()}async _init(){let t=n,r={yrYTP:function(c,d){return e[R(581)](c,d)},rEDZJ:e[t(1371)],gxhJh:function(c){return e[t(1497)](c)},lKbxI:function(c,d,h,p){return e[t(1356)](c,d,h,p)}};if(!this[t(1945)]){if(this[t(1612)+"mise"])return this[t(1612)+t(1455)];try{let c=this[t(512)],d=this[t(991)];this[t(1612)+t(1455)]=(async()=>{let h=t;if(r[h(1586)](r[h(1030)],h(703))){let{openDB:w}=await r.gxhJh(i0);this[h(1945)]=await r[h(1805)](w,h(1106)+"_"+c,1,{upgrade(l){let b=h;l[b(621)+b(1741)+"e"](c,{keyPath:d})}})}else for(var p in _0x1d03a4)_0x4e4dc0.o(_0x580986,p)&&!_0x2623c3.o(_0x57a524,p)&&_0x1f9771[h(760)+"operty"](_0x1d6aff,p,{enumerable:!0,get:_0x4eae64[p]})})(),await this[t(1612)+t(1455)]}catch(c){console.log(c)}finally{this[t(1612)+t(1455)]=null}}}async[n(2007)](t){let r=n;try{return await this[r(523)](),this._qosDB?.[r(2007)](this[r(512)],t)}catch(c){console[r(1974)](c)}}async[n(833)](t,r){let c=n;return await this._init(),this[c(1945)]?.[c(1227)](this[c(512)],t)}async[n(1178)](t){let r=n;if(!e[r(1453)](r(1561),r(1713)))try{return await this[r(523)](),this[r(1945)]?.[r(871)](this[r(512)],t)}catch(c){console[r(1974)](c)}}async[n(1936)](){let t=n;try{return await this[t(523)](),this[t(1945)]?.[t(1936)](this[t(512)])}catch(r){console[t(1974)](r)}}async keys(){let t=n;return await this[t(523)](),this[t(1945)]?.[t(959)+"ys"](this[t(512)])}async[n(911)](){let t=n;return await this[t(523)](),this[t(1945)]?.[t(911)](this[t(512)])}async[n(1598)](){let t=n;try{e[t(486)](e[t(1659)],e[t(620)])?(_0x4f58d9[_0xc9c2eb++]=e.mizFz(e[t(1926)](_0x53c419,18),7)|240,_0x17948d[_0x1f5856++]=e[t(1352)](e.NvNVg(e[t(1325)](_0x390c93,12),63),128)):(this[t(1945)]?.[t(1681)](),this._qosDB=void 0)}catch(r){console[t(1974)](r)}}get[n(1989)](){let t=n;try{return!!this[t(1945)]}catch(r){return console.log(r),!1}}}class o0{constructor(t,r){let c=n,d={LpTwd:e[c(1247)],vwqeU:e[c(716)],MHPxD:e[c(825)]};e[c(502)](e[c(689)],e.dRFGO)?(this._DBName=t,this[c(525)]=r,this[c(1945)]=localStorage):(ifJOhn.LpTwd!=typeof _0xb1b6ca&&_0xdb6c92[c(1887)+c(1006)]&&_0x2755c4[c(760)+c(1797)](_0x4562d5,_0x13bf35["toString"+c(1006)],{value:ifJOhn[c(1808)]}),_0x119e36[c(760)+"operty"](_0x343605,ifJOhn[c(479)],{value:!0}))}async[n(592)](){}get _prefix(){return"frontier_"+this[n(963)]}async[n(2007)](t){let r=n,c=this._qosDB[r(629)](this[r(499)]);return JSON[r(1263)](e[r(1749)](c,"{}"))[t]}async[n(833)](t,r){let c=n,d=this._qosDB[c(629)](this[c(499)]),h=JSON[c(1263)](e[c(514)](d,"{}"));return h[r||t[this[c(525)]]]=t,this[c(1945)][c(1528)](this._prefix,JSON[c(1990)+"y"](h)),r||t[this[c(525)]]}async[n(1178)](t){let r=n,c=this[r(1945)].getItem(this[r(499)]),d=JSON[r(1263)](c||"{}");return d[t]=void 0,this._qosDB[r(1528)](this[r(499)],JSON.stringify(d))}async[n(1936)](){let t=n;return this._qosDB[t(1936)]()}async keys(){let t=n,r=this._qosDB.getItem(this[t(499)]),c=JSON[t(1263)](r||"{}");return Object[t(1770)](c)}async[n(911)](){let t=n,r=this[t(1945)][t(629)](this[t(499)]),c=JSON.parse(e[t(1131)](r,"{}"));return Object[t(977)](c)}[n(1598)](){return Promise.resolve()}get[n(1989)](){return!!this[n(1945)]}}class a0{constructor(t,r){let c=n;this[c(963)]=t,this[c(525)]=r,this[c(1945)]=wt?tt:en?wx:null}async[n(592)](){}get[n(499)](){let t=n;return t(1106)+"_"+this[t(963)]}async get(t){let r=n,c=this[r(1945)][r(1844)+"geSync"](this[r(499)]);return JSON[r(1263)](e[r(514)](c,"{}"))[t]}async[n(833)](t,r){let c=n,d=this[c(1945)][c(1844)+"geSync"](this[c(499)]),h=JSON.parse(e[c(874)](d,"{}"));return h[r||t[this._pathKey]]=t,this[c(1945)][c(1328)+c(579)](this[c(499)],JSON[c(1990)+"y"](h)),r||t[this._pathKey]}async[n(1178)](t){let r=n,c=this[r(1945)][r(1844)+r(579)](this[r(499)]),d=JSON[r(1263)](c||"{}");return d[t]=void 0,this._qosDB["setStora"+r(579)](this._prefix,JSON[r(1990)+"y"](d))}async[n(1936)](){let t=n;return this[t(1945)][t(947)+t(1313)]()}async[n(1770)](){let t=n,r=this[t(1945)].getStorageInfoSync(this[t(499)]),c=JSON[t(1263)](e[t(1460)](r,"{}"));return Object.keys(c)}async[n(911)](){let t=n,r=this._qosDB[t(1844)+t(1818)+"nc"](this[t(499)]),c=JSON[t(1263)](e[t(1749)](r,"{}"));return Object[t(977)](c)}closeDB(){return Promise.resolve()}get[n(1989)](){return!!this._qosDB}}function ps(s,t){let r=n;if(wt||wt)return new a0(s,t);if((kt||tn)&&r(908)+"d"!=typeof indexedDB)return new s0(s,t);if(e.LZPsE(kt,tn)&&e[r(1194)](e.rpLvM,typeof localStorage))return new o0(s,t);throw new Error(e[r(1970)])}class c0{constructor(){let t=n;this[t(1582)+t(1310)+"Id"]=null,this._interval=36e5,this[t(1945)]=ps(e[t(498)],e.MWtwL)}async[n(1582)+n(1102)](){let t=n,r={TPIsl:e[t(1543)]};if(e[t(1390)](t(1622),t(746)))e[t(1091)](clearInterval,this["_interva"+t(1310)+"Id"]),this[t(1582)+"lTimeoutId"]=e[t(1878)](setInterval,()=>{let c=t;if(e[c(1745)](e[c(1256)],e[c(1814)]))this[c(971)+c(917)]();else if(!this[c(1614)+"Lock"]){let d=(c(740)+"4")[c(1791)]("|"),h=0;for(;;){switch(d[h++]){case"0":this[c(583)+"tManager"]?.[c(1423)+c(1821)+c(1152)]();continue;case"1":this[c(1619)+c(1801)]?.["resetCou"+c(1255)]();continue;case"2":this._isInit=!0;continue;case"3":this[c(1849)+"osed"]=!1;continue;case"4":this[c(1614)]();continue}break}}},this._interval);else{let c=t(1785)+_0x5829aa+(t(850)+t(1208)+t(1948)+t(1510));this[t(1244)](c),this["_dispatc"+t(586)+t(1949)](_0x13a22b(r[t(1301)],{message:c,code:_0x1dbc37[t(1076)+t(980)+"R"]}));return}}async openDB(){let t=n;await this[t(1945)].openDB()[t(1098)](()=>{let r=t,c={Dwmec:function(d,h){return e[R(1540)](d,h)},jWohR:function(d,h){return d>h},iphbX:function(d,h){return e[R(1568)](d,h)},mcbZX:function(d,h){return e[R(1340)](d,h)},cVCwv:function(d,h){return e.rfhFl(d,h)},pPZIw:function(d,h){return e[R(1327)](d,h)},DcRuF:function(d,h){return d|h}};if(e[r(797)](e[r(1015)],r(1929))){if(c[r(671)](_0xbf1654,1)||c[r(655)](_0x2980e7,_0x89122a))return c[r(1025)](_0x2f2e81,_0x231980);c[r(1174)](_0x5e4bab,_0x1e241a)>_0x41cd71&&(_0x37f858=c[r(1118)](_0x124636,_0x49e252),_0x1e808d=0);let d=_0x2c64e8[r(1664)](_0x11c804,_0xeffa33,_0x1fb4c3+=_0x1885df);return c[r(1299)](7,_0x27a813)&&(_0x46b9d0=c[r(1174)](c[r(1284)](7,_0x46eac1),1)),d}else this[r(1582)+r(1102)]()})}async[n(971)+n(917)](){let t=n;(await this._qosDB?.[t(911)]()||[])[t(912)](({timestamp:d})=>d<Date[t(1463)]())[t(1876)](d=>{let h=t;this._qosDB?.del(d[h(970)+"id"])})}async del(t){let r=n;return this[r(1945)]?.[r(1178)](t)}async[n(833)](t,r){return this[n(1945)]?.set({message_id:t,timestamp:r})}async[n(2007)](t){let r=n;return this[r(1945)]?.[r(2007)](t)}async closeDB(){let t=n;if(e.KeXez(e[t(1407)],t(1762)))e[t(550)](clearInterval,this[t(1582)+t(1310)+"Id"]),await this[t(1945)]?.[t(1598)]();else return _0x234303[t(1338)+"t8"]?_0x4d99f4[t(1338)+"t8"](_0x29e7a6,_0x1261cb):_0x517bdc[_0x192f72]=e[t(1525)](255,_0x47df8c),_0x5d8c83+1}get[n(1989)](){let t=n;return this[t(1945)]?.[t(1989)]}}function jr(s){let t=n,r=!!this[t(1539)][t(1638)+"S"];if(!r)return{enabled:r,isQoSMessage:!1,isQoSAck:!1,isAckCleanupMessage:!1,ackMsgIds:[]};let c=at(s[t(1315)][t(795)],e.TTdhi,"2"),d=c&&at(s[t(1315)][t(795)],t(1534)+t(1233)+"ck","1"),h=c&&e.LzyIv(at,s[t(1315)][t(795)],e[t(1908)],"1"),p=h?Dt(s.message.headers,e[t(1112)])?.[t(1791)](",")[t(912)](Boolean)||[]:[];return{enabled:r,isQoSMessage:c,isQoSAck:d,isAckCleanupMessage:h,ackMsgIds:p}}async function ms(){let s=n;return this[s(1336)+"ger"]||(this[s(1336)+s(641)]=new c0),this[s(1336)+s(641)][s(1989)]||await this[s(1336)+"ger"][s(592)](),this["_QoSMana"+s(641)]}async function x0(s,t){let r=n,{enableAutoAck:c}=this[r(1539)],d=at(s[r(1315)][r(795)],e[r(1451)],"1"),h=e[r(1430)](at,s.message.headers,r(1108),"1"),p=jr[r(1664)](this,s);if(e[r(493)](c,d)){let{SeqID:w,LogID:l,service:b,LogIDNew:I,method:k}=s[r(1315)];this[r(474)]({SeqID:w,LogID:l,LogIDNew:I,service:b,method:k,headers:[{key:e[r(1039)],value:"1"},{key:e[r(1147)],value:e[r(874)](I,"")},{key:e[r(466)],value:"0"}]})}h&&!p[r(1238)]&&this[r(1746)+r(1218)+r(1872)](s),e[r(461)](t)}async function d0(s,t){let r=n;this[r(1244)](e[r(1730)],s[r(1315)]),e[r(1391)](t)}async function u0(s,t){let r=n,c=At(await e.zJxNF(hs,s[r(564)]));try{if(c.payload instanceof Uint8Array){let d=e.DnuNE(this[r(1539)]["payloadE"+r(1570)],Object)?{force:!!this[r(1539)][r(609)+r(1570)][r(1581)],encoding:this[r(1539)][r(609)+r(1570)][r(1739)]?this[r(1539)][r(609)+r(1570)][r(1739)].replace(/\s/g,"")["toLowerC"+r(1874)]():""}:{force:!1,encoding:this._options[r(609)+"ncoding"]?this._options[r(609)+r(1570)][r(943)](/\s/g,"")[r(1712)+"ase"]():""},h=c[r(609)+r(1570)]?c["payloadE"+r(1570)][r(943)](/\s/g,"")[r(1712)+r(1874)]():"",p=e.DnuNE(this[r(1539)][r(1060)+r(1298)],Object)?{force:!!this[r(1539)]["payloadT"+r(1298)].force,type:this._options["payloadT"+r(1298)][r(1262)]?this[r(1539)][r(1060)+r(1298)].type[r(943)](/\s/g,"")[r(1712)+r(1874)]():""}:{force:!1,type:this[r(1539)][r(1060)+r(1298)]?this[r(1539)][r(1060)+r(1298)][r(943)](/\s/g,"")[r(1712)+"ase"]():""},w=c[r(1060)+"ype"]?c[r(1060)+r(1298)].replace(/\s/g,"")[r(1712)+r(1874)]():"",l=p.force?p[r(1262)]:w||p[r(1262)],b=d[r(1581)]?d[r(1739)]:h||d[r(1739)],I=[e.GurVj,r(672)+r(987),e[r(785)],e.yGOwL],k=[e.VfETj,e[r(1367)]];this._options[r(644)+r(1789)+"extPayload"]&&I.includes(l)&&(!b||k[r(1282)](b))?c[r(1784)+r(1860)]=e[r(933)](gs,c.payload,0,c[r(1959)][r(557)+"th"]):c[r(1784)+r(1860)]=""}else c[r(1784)+r(1860)]=""}catch(d){if(e[r(861)](e[r(554)],e[r(653)]))c[r(1784)+r(1860)]="",console[r(1974)](d);else return e.PxWVy(_0x193f5f,_0x571e4e)}s[r(1315)]=c,e[r(1391)](t)}function f0(s,t,r){let c=n,d={HaIxu:function(b,I){return b>I},lEkqu:function(b,I){return e[R(779)](b,I)},yCceq:function(b,I){return e.LzSyQ(b,I)},xIjBX:function(b,I){return e[R(1064)](b,I)},euwGn:function(b,I){return b&I},IgRhG:function(b,I){return e[R(1883)](b,I)},SjpWU:function(b,I){return e[R(700)](b,I)}},h=e[c(764)](r,8192),p=e[c(666)](h,1),w=null,l=h;return function(b){let I=c;if(b<1||d[I(1081)](b,p))return d.lEkqu(s,b);d.yCceq(l+b,h)&&(w=d.xIjBX(s,h),l=0);let k=t[I(1664)](w,l,l+=b);return d[I(1516)](7,l)&&(l=d[I(1196)](d[I(1877)](7,l),1)),k}}let l0=4294967295;function g0(s,t,r){let c=n,d={qCMCX:function(h,p){return e.feDPf(h,p)}};if(e.WJRKn(e[c(668)],e[c(668)]))fKcANQ[c(884)](_0x584fb1,_0x35ecd8)&&_0x2375c9[c(833)](_0x33c49e,_0x4eca25);else return e[c(1288)](RangeError,e[c(1514)](e.fBFfP(e[c(1514)](e[c(548)](e[c(1979)],s),e[c(1169)]),e[c(840)](t,1))," > ")+r)}function h0(s,t,r){let c=n;if(e[c(1618)](r,l0))throw new Error(e[c(1221)]);let d=3;for(;d>=0;){let h=255&r;e[c(1356)]($r,h,s,e[c(1513)](t,d)),r>>>=8,d--}return t+4}function p0(s,t){let r=n;if(e[r(1432)](r(529),e[r(1798)]))return _0x5a50b3[r(1569)](_0x329e49)||(_0x4b43a6=_0x3a8152[r(1873)+"er"](_0xf9e1)),this[r(719)]!==_0x955653[r(719)]&&e.TGBAf(this.high>>>31,1)&&e[r(1219)](e[r(1787)](_0x53c17d[r(1911)],31),1)?!1:e.QbArm(this.high,_0x202cb1[r(1911)])&&e[r(494)](this[r(1009)],_0x220103[r(1009)]);{let c=0,d=t,h=t+4;for(;d<h;){let{value:p,offset:w}=e.ZkGBx(Wr,s,d);d=w,c=e.qYuYq(e[r(1654)](c,8),0),c+=p}return{value:c,offset:h}}}function m0(s,t,r){let c=n,d=e[c(1124)][c(1791)]("|"),h=0;for(;;){switch(d[h++]){case"0":if(t[c(744)])return e[c(951)](t[c(744)](s,r),r);continue;case"1":if(!s)return r;continue;case"2":if(t[c(1283)+"e"])return e[c(540)](t.utf8Write(s,r),r);continue;case"3":return e[c(918)](e[c(1345)](Hr,s,t,r),r);case"4":if(s[c(633)]<40)return e[c(759)](Hr,s,t,r)+r;continue}break}}function w0(s,t){let r=n,c=new W(e.uinPW(e[r(497)](e[r(1482)](s[e[r(1217)](t,4)]<<24,s[e[r(470)](t,5)]<<16),s[t+6]<<8),s[t+7]),e[r(1353)](e[r(1903)](e[r(1673)](s[e[r(1072)](t,0)],24),e[r(830)](s[e[r(1217)](t,1)],16))|e[r(1507)](s[t+2],8),s[e[r(999)](t,3)]),!0);return t+=8,{value:c,offset:e[r(1040)](t,8)}}function _0(s,t,r){let c=n,d=s[c(1009)],h=s[c(1911)];return t[r]=e.waKMM(h,24),t[e[c(1885)](r,1)]=e[c(1308)](e[c(1276)](h,16),255),t[e[c(1413)](r,2)]=e[c(1953)](e[c(1641)](h,8),255),t[e[c(1883)](r,3)]=e[c(989)](255,h),t[e[c(1984)](r,4)]=e[c(1252)](d,24),t[r+5]=e[c(796)](d>>>16,255),t[e.RtAtp(r,6)]=e.IFqIj(e[c(636)](d,8),255),t[r+7]=e[c(996)](255,d),r+=8,r}function Wr(s,t){let r=n;return s.readUInt8?{value:s[r(921)+"8"](t),offset:e[r(1524)](t,1)}:{value:e[r(1148)](255,s[t]),offset:e[r(1548)](t,1)}}function $r(s,t,r){let c=n;return t[c(1338)+"t8"]?t.writeUint8(s,r):t[r]=e[c(1994)](255,s),r+1}let y0=function(s){return new Uint8Array(s)},b0=e.XMbeV(e.rpLvM,typeof Buffer)?Buffer["allocUns"+n(1772)]:e[n(1316)](f0,y0,Uint8Array[n(1037)+"e"][n(1683)]);(()=>{let s=n,t={etyrL:function(r,c){return e[R(1326)](r,c)},PwtsS:function(r,c){return e[R(628)](r,c)},upnto:function(r,c){return r<c},Drzzc:function(r,c){return r|c},OjaDB:function(r,c){return e.XpbGK(r,c)},cVHJN:function(r,c){return e.SgTQB(r,c)},jXtQZ:function(r,c){return e[R(1496)](r,c)},JzIkk:function(r,c){return e.EGtkF(r,c)},TLurY:function(r,c){return e[R(1496)](r,c)},TGFdW:function(r,c){return e[R(705)](r,c)},TLGeT:function(r,c){return e.NVDNh(r,c)},FPYQZ:function(r,c,d,h){return e[R(933)](r,c,d,h)}};if(e.AigDQ(s(1799),e[s(952)])){let r=4294967295;return function(c,d,h=!0){let p=s;if(r=t.etyrL(t.PwtsS(127,c[d]),0),t[p(1202)](c[d++],128))return{value:h?r:t[p(1838)](0,r),offset:d};if(r=t[p(1601)](r|t.OjaDB(127,c[d])<<7,0),t[p(1626)](c[d++],128))return{value:h?r:t[p(1838)](0,r),offset:d};if(r=t[p(1601)](t[p(1838)](r,t[p(450)](t[p(1236)](127,c[d]),14)),0),t[p(992)](c[d++],128))return{value:h?r:t[p(1838)](0,r),offset:d};if(r=(r|t[p(632)](t[p(1236)](127,c[d]),21))>>>0,t[p(1900)](c[d++],128))return{value:h?r:t.Drzzc(0,r),offset:d};if(r=t[p(1601)](t[p(454)](r,(15&c[d])<<28),0),t[p(1900)](c[d++],128))return{value:h?r:t[p(1838)](0,r),offset:d};if((d+=5)>c.length)throw d=c[p(633)],t.FPYQZ(g0,d,10,c[p(633)]);return{value:h?r:t[p(454)](0,r),offset:d}}}else _0x64c044[s(1974)](_0x5a49b7)})();let v0=16,Jr=32;function S0(s){let t=n,r=0,c={};for(let d=0;e[t(823)](d,s[t(633)]);d++)c[s[d][t(492)+t(1997)]]=e[t(1549)](ls,s[d][t(492)+t(1997)]),r+=e.GRAsu(14,c[s[d][t(492)+"ame"]]);return[r,c]}function ws(s,t,r){let c=n,[d,h]=e.KyeLy(S0,s),p=e[c(1144)](b0,d),w=0;return s.forEach(l=>{let b=c,I=e[b(1605)][b(1791)]("|"),k=0;for(;;){switch(I[k++]){case"0":console[b(1974)](e[b(828)],w);continue;case"1":w=h0(p,w,l[b(1702)]||0);continue;case"2":w=e.vJfRj($r,h[l[b(492)+b(1997)]],p,w);continue;case"3":w=e[b(1345)](_0,W[b(1873)+"er"](l[b(680)]||t),p,w);continue;case"4":console.log(e[b(752)],w);continue;case"5":w=$r(0,p,w);continue;case"6":console[b(1974)](e.tfWEJ,l,l.service);continue;case"7":console[b(1974)](e[b(839)],w);continue;case"8":console[b(1974)](b(2006),w);continue;case"9":console[b(1974)](e[b(881)],w);continue;case"10":w=e[b(1356)](m0,l[b(492)+b(1997)],p,w);continue}break}}),{frameType:Jr,headers:[{key:e.IzlKX,value:r}],payload:p}}function E0(s){let t=n,r=0,c=[];for(;e[t(1752)](r,s[t(557)+"th"]);){let{offset:d}=e[t(1779)](Wr,s,r);r=d;let h={cursor_name:"",cursor:0,service:0},{value:p,offset:w}=e[t(1316)](p0,s,r);h[t(1702)]=p,r=w;let{value:l,offset:b}=e[t(1719)](Wr,s,r);r=b,h[t(492)+"ame"]=gs(s,r,r+l),r+=l;let{value:I,offset:k}=e[t(1472)](w0,s,r);h[t(680)]=I[t(864)](),r=k,c[t(684)](h)}return c}function I0(){let s=n;return{frameType:Jr,headers:[{key:e[s(536)],value:e[s(1028)]}],payload:void 0}}class A0{constructor(t,r,c){let d=n;this[d(1092)+d(1022)]=t,this["_cursorF"+d(1579)]=r,this._messageStrategy=c,this[d(1945)]=ps(this[d(1092)+"ameSpace"],e[d(1865)])}async openDB(){let t=n;await this[t(1945)][t(592)]()}async[n(1691)+"rs"](){let t=n;if(!this[t(1945)][t(1989)])return;let r=this[t(1204)+t(937)],c=await this[t(1945)][t(911)]();switch(console[t(1974)](e[t(594)],c),r){case e[t(806)]:return c&&c.length?e[t(1062)](ws,c,0,this._cursorFileName):void 0;case"INSTANT":return;case e[t(1085)]:return c&&c.length?e[t(1345)](ws,c,0,this[t(1295)+"ileName"]):e[t(976)](I0)}}async set(t,r,c){let d=n;return console[d(1974)](e[d(590)],t,r,c),this[d(1945)][d(833)]({cursor_name:t,cursor:r,service:c})}async[n(623)+"rs"](t){let r=n,c=e.UEJmT(E0,t);for(let d of c)console[r(1974)](e[r(1604)],c),await this[r(1945)][r(833)](d)}async[n(2007)](t){let r=n;return(await this[r(1945)][r(2007)](t))?.[r(680)]}async[n(1598)](){let t=n;await this[t(1945)][t(1598)]()}["updateCu"+n(1567)+n(910)](t){let r=n;this["_cursorF"+r(1579)]=t}get isReady(){let t=n;return this[t(1945)][t(1989)]}}let P0=e[n(1931)];async function _s(s){let t=n,r={JBfAZ:function(c,d){return e.Dlrdq(c,d)},iuvZF:function(c,d,h){return e.LkksT(c,d,h)},tJwIu:t(1748),pFDSI:e[t(1998)]};if(e[t(1465)]!==e[t(1595)]){if(!this[t(1539)][t(1638)+"S"])return null;let{aID:c,fpID:d,messageStrategy:h}=this[t(1539)],p=e[t(514)](s,P0);try{if(e[t(1066)]===e.ThKZS)_0x5bd4c0+=lZcWLT[t(1438)](_0x349c22,_0xae98e5),_0x303250+=2;else return this[t(515)+t(1476)]?s&&this[t(515)+"anager"][t(712)+t(1567)+t(910)](s):this[t(515)+t(1476)]=new A0(d+"_"+c+"_"+p,p,h),this[t(515)+t(1476)][t(1989)]||await this[t(515)+t(1476)][t(592)](),this["_cursorM"+t(1476)]}catch{if(e[t(1211)](e[t(1483)],e[t(1483)]))return null;this[t(1945)]?.[t(1681)](),this[t(1945)]=void 0}}else this[t(1582)+"lTimeoutId"]=null,this[t(1582)+"l"]=36e5,this[t(1945)]=lZcWLT[t(1170)](_0x3ab80e,lZcWLT[t(844)],lZcWLT[t(1583)])}async function C0(s,t){let r=n,c={hhJXF:r(1940)+r(456)+r(1254),fwHTh:r(1562),eUnJf:function(N,H,fe,j){return e[r(1806)](N,H,fe,j)},KcKtX:e[r(752)],FNxVP:"header",VhsbZ:e[r(1933)],TOzGA:function(N,H,fe,j){return e[r(1475)](N,H,fe,j)}},d=at(s[r(1315)].headers,e[r(1517)],"-1"),h=e[r(761)](at,s[r(1315)][r(795)],e.nZPIp,"1"),p=e.hPEqY(Dt,s[r(1315)].headers,e[r(1477)]),w=e[r(742)](Number,e[r(2003)](Dt,s.message[r(795)],e.IGngG))||0,l=jr.call(this,s),b=e[r(1967)](at,s[r(1315)][r(795)],"x-msg-qos","2"),I=e.gXoGq(Dt,s[r(1315)][r(795)],e[r(713)]),k=e[r(1551)](Number,e[r(675)](Dt,s[r(1315)].headers,"x-msg-cursor_value"));if(l[r(1238)])return e[r(1391)](t);let M=l[r(1647)+r(1287)]?await ms.call(this):null;if(e[r(1140)](s[r(1315)][r(1702)],0)&&h&&!d||s[r(1315)][r(1702)]>0){if(p&&l["isQoSMes"+r(1287)]&&M){if(e[r(1815)](e.CdlRL,e[r(1379)]))return!!!await M[r(2007)](p)&&(this["_dispatc"+r(1136)+r(938)](s),await M[r(833)](p,e[r(951)](Date[r(1463)](),w))),t();{let N=c.hhJXF[r(1791)]("|"),H=0;for(;;){switch(N[H++]){case"0":_0xc7642e[r(1974)](JYItsS.fwHTh,_0x102ecb);continue;case"1":_0x466a2f=JYItsS[r(610)](_0x42bb26,_0x3f0af1[r(1873)+"er"](_0x2cb2bd[r(680)]||_0x914b39),_0x3e7245,_0x4930f4);continue;case"2":_0x2d535a.log(JYItsS.KcKtX,_0x5bc55f);continue;case"3":_0x146b81.log(r(570)+"name",_0x5f6138);continue;case"4":_0x1b3e5f=JYItsS[r(610)](_0x79bcc9,0,_0x4b29cb,_0x147203);continue;case"5":_0x52effc[r(1974)](JYItsS[r(455)],_0x18fb06);continue;case"6":_0x15ce40[r(1974)](r(2006),_0x80c5df);continue;case"7":_0x28c966[r(1974)](JYItsS[r(717)],_0x4b2b0c,_0x2c29b7[r(1702)]);continue;case"8":_0x491024=JYItsS[r(610)](_0x4169bb,_0x319a03[r(492)+r(1997)],_0x1132e9,_0x36d3d1);continue;case"9":_0x42192a=JYItsS[r(598)](_0x137c7e,_0x40a4dc[_0x48ba03[r(492)+r(1997)]],_0xd0f625,_0x37085b);continue;case"10":_0x491213=_0xd8e6dc(_0x149dc2,_0x40e8b5,_0x338125[r(1702)]||0);continue}break}}}if(b){let N=await _s.call(this);if(!N)return this[r(1746)+r(1136)+"Event"](s),e[r(1866)](t);let H=await N[r(2007)](I)??-1;if(H<k)this["_dispatc"+r(1136)+r(938)](s),N.set(I,k,s.message[r(1702)]);else throw new Error(r(589)+r(1672)+" cursor "+k+(" larger than loc"+r(1491)+"r ")+H);return e[r(976)](t)}return this[r(1746)+r(1136)+"Event"](s),e[r(607)](t)}}async function T0(s,t){let r=n,c=jr[r(1664)](this,s);if(!c[r(1647)+r(1287)])return e[r(607)](t);let d=await ms[r(1664)](this);if(c["isAckCleanupMess"+r(1880)]&&c[r(1810)+"s"][r(633)])for(let h of c[r(1810)+"s"])await d[r(1178)](h);e[r(461)](t)}async function k0(s,t){let r=n,c=e[r(1058)](s[r(1315)][r(1281)+"e"],v0),d=e[r(1143)](s.message[r(1281)+"e"],Jr);if(e[r(493)](!c,!d))return e[r(1426)](t);let h=e[r(1674)](Dt,s.message.headers,e.IzlKX);if(!h)return t();let p=await _s[r(1664)](this,h);if(!p)return e[r(1215)](t);if(c){let w=await p.getCursors(),l={frameType:w?.[r(1281)+"e"],SeqID:W.fromNumber(this._seqId++),LogID:W[r(1873)+"er"](this[r(1539)][r(1035)+"erator"]()),service:9e3,method:5,headers:w?.headers,payload:w?.payload},b=S(l);this[r(1501)]&&this[r(1501)].readyState&&this[r(1501)][r(1764)](b)}if(d){let w=s[r(1315)][r(1959)];w&&p[r(623)+"rs"](w)}}let D0=async function(s,t){let r=n;this[r(1199)]=!1,e[r(2005)](clearTimeout,this[r(1614)+r(1012)+r(567)]),e[r(607)](t)},R0=async function(s,t){let r=n;if(!this._ws||this[r(1501)][r(1576)+"te"]!==this[r(817)])return e.KVXQi(t);let{pingInterval:c}=this._options;this["_endpoin"+r(507)]?.[r(1423)+r(1821)+r(1152)]();for(let h=0;e[r(1527)](h,this[r(1204)+r(789)][r(633)]);h++){let p=this[r(1204)+r(789)][h];if(this[r(1501)].readyState===this[r(817)]&&e[r(1815)](null,p))this[r(1501)]&&this[r(1501)][r(1764)](p),this[r(1204)+"Queue"][h]=null;else break}this["_message"+r(789)]=this[r(1204)+r(789)][r(912)](h=>!!h),this._pingPongTimeoutId=e[r(1902)](setTimeout,()=>this[r(513)](),c),this[r(1746)+r(1213)+"nt"](s),this[r(1632)+"er"]&&this._ws&&(this._ws[r(718)+"pe"]=this[r(1099)+r(1298)]);let d=this[r(583)+"tManager"]?.["getCurre"+r(1613)+"nt"]();this._debug(r(1912)+d+r(1369)),e[r(1426)](t)},N0=async function(s,t){let r=n,c=this[r(583)+r(507)]?.[r(1890)+r(1613)+"nt"]();this[r(1244)](r(1912)+c),t()};class O0 extends Gr{constructor(t){let r=n,c={xCGkm:function(w,l,b,I){return e[R(1958)](w,l,b,I)},OfErZ:function(w,l,b){return w(l,b)},Pettp:e.HqQse,cqmrU:function(w,l){return w===l},hvYcr:e[r(559)],gyRGJ:r(1121),HaPjU:function(w,l){return e.VHmMh(w,l)},sfDiq:e[r(1639)],LuNDl:e[r(1357)],idgtv:function(w,l,b){return w(l,b)},dzkcv:function(w,l){return w===l},LWPIq:function(w,l,b,I){return w(l,b,I)},Ykqvg:function(w,l,b){return e[r(1067)](w,l,b)},lAyzi:function(w,l){return e.GiFZf(w,l)},cAkrH:e[r(1351)],lnumZ:function(w,l,b){return e[r(846)](w,l,b)},fHNuJ:e[r(600)],piLux:function(w,l){return e[r(1499)](w,l)},OuSkT:function(w,l,b){return e.TFqyx(w,l,b)},IsgQt:e[r(1807)],cSFFw:function(w,l){return e.NJXxH(w,l)},NJrRo:function(w,l,b){return e.NRDEa(w,l,b)},RpntO:function(w,l,b){return w(l,b)},YYJnF:function(w,l){return w!==l}};super(),this[r(1977)+r(452)+"line"]=!0,this._isBrowser=kt,this[r(1429)]=Yc,this[r(585)+"T"]=wt,this[r(511)+"X"]=en,this[r(447)+"r"]=tn,this[r(1204)+r(789)]=[],this["_endpoin"+r(507)]=null,this[r(1849)+r(1435)]=!1,this._binaryType=r(1773)+r(534),this._connectLock=!1,this[r(1614)+r(1012)+"utId"]=null,this[r(808)+r(488)+r(1834)]=null,this[r(1230)+r(1537)+"Id"]=null,this[r(510)]=0,this[r(1199)]=!1,this[r(1978)]="",this["_QoSMana"+r(641)]=null,this[r(515)+r(1476)]=null,this[r(1619)+r(1801)]=null,this[r(1783)+"ls"]=e[r(1547)],this.CLOSED=3,this[r(469)+"NG"]=0,this[r(817)]=1,this[r(686)]=2,this[r(893)]=w=>{let l=r;try{c[l(1162)](fs,this,w,[D0,R0,N0])}catch(b){let I=c[l(1216)](Pe,c.Pettp,{message:b.message,code:ot.OPEN_ERROR,error:b});this[l(1746)+l(586)+l(1949)](I)}},this[r(914)+"ge"]=async w=>{let l=r,{pingInterval:b,pingFrequency:I}=this[l(1539)];if((c.cqmrU("hi",w[l(564)])&&c[l(509)](c.hvYcr,I)||c[l(561)]===I)&&(c.HaPjU(c[l(1416)],c.sfDiq)?_0x12ab10[l(1347)]()[l(1098)](()=>{this[l(1045)+"steners"]()}):(this[l(812)+l(1177)](),this[l(2008)](l(1470)+"e_success",c[l(891)]),this[l(1230)+l(1537)+"Id"]=c[l(1995)](setTimeout,this[l(513)][l(1334)](this),b))),!c[l(935)]("hi",w[l(564)]))try{c[l(1277)](fs,this,w,[u0,x0,T0,k0,C0,d0])}catch(k){let M=c[l(1330)](Pe,c[l(1519)],{message:k.message,code:ot["MESSAGE_"+l(1359)],error:k});this[l(1746)+l(586)+l(1949)](M)}},this[r(1393)]=w=>{let l=r,b={shZbV:function(M,N){return c[R(799)](M,N)}},I=this["_endpoin"+l(507)]?.[l(983)+"chMaxTries"](),k=this[l(583)+l(507)]?.[l(1890)+"ntEndpoint"]();if(I&&!w.message)if(c.dzkcv(c[l(1793)],c[l(1793)])){let M=l(1785)+k+(l(612)+l(1724)+"es reached");this[l(1746)+l(586)+l(1949)](c[l(1330)](Pe,c.Pettp,{message:M,code:ot["MAX_RETR"+l(980)+"R"],error:w}));return}else{let M=this[l(1945)][l(1844)+l(1818)+"nc"](this[l(499)]),N=_0x532298[l(1263)](vvvsVD.shZbV(M,"{}"));return _0x158eaa[l(977)](N)}this[l(1501)]&&c[l(935)](this[l(1501)][l(1576)+"te"],this[l(817)])&&this._disconnect(),this[l(1746)+"hErrorEv"+l(1949)](Pe(c.Pettp,{message:w[l(1315)],code:ot[l(1335)+l(1145)],error:w}))},this[r(958)]=async w=>{let l=r;this[l(1232)+"mer"](),this._clearPingTimer(),this[l(848)+"sListeners"](),this._ws=null,this._connectLock=!1;let b=this[l(583)+l(507)]?.["checkRea"+l(1224)+"es"]();if(!b&&this[l(553)+l(1243)]()&&!this[l(1849)+l(1435)]){let I=this["_endpoin"+l(507)]?.[l(1890)+"ntEndpoint"](),k=this[l(1539)][l(1485)+l(1718)+l(725)](w.code,w.reason);this[l(1746)+l(1938)+"ent"](c[l(1760)](Oe,c[l(484)],{code:1006,reason:w[l(1832)]||l(731)+l(1653)+l(648)+l(794)+l(1897)+l(1339)+I,willReconnect:k})),k&&this._connect();return}if(c[l(1969)](1e3,w[l(1079)])&&this["_readyCl"+l(1435)]){this["_dispatc"+l(1938)+l(1949)](c[l(1398)](Oe,c[l(484)],{code:1e3,reason:c.IsgQt})),this._endpointManager?.[l(1423)+l(1821)+l(1152)](),this[l(1619)+"sCounter"]?.[l(1337)+l(1255)]();return}if(c[l(699)](1e3,w[l(1079)])&&b){let I=this[l(583)+"tManager"]?.[l(1890)+l(1613)+"nt"](),k=w[l(1832)];k||(k=await c.cSFFw(r0,this._url)),k=l(731)+l(1653)+l(1428)+k+(l(1766)+l(936))+I+(l(1208)+l(1948)+l(1510)),this["_dispatchCloseEv"+l(1949)](c.NJrRo(Oe,"close",{code:w[l(1079)],reason:k}));let M="connect "+I+(l(612)+l(1724)+l(1625)+"ed");this[l(1746)+l(586)+l(1949)](c.RpntO(Pe,l(1609),{message:M,code:ot["MAX_RETR"+l(980)+"R"]})),this[l(583)+l(507)]?.[l(1423)+l(1821)+l(1152)](),this[l(1619)+l(1801)]?.resetCounter();return}if(c.YYJnF(1e3,w[l(1079)])&&!w[l(1832)]){let I=this["_endpoin"+l(507)]?.getCurrentEndpoint();this[l(1746)+l(1938)+"ent"](Oe(c[l(484)],{code:w[l(1079)],reason:l(731)+l(1653)+l(648)+"wn reaso"+l(1897)+"ame: "+I})),this[l(583)+"tManager"]?.["resetEnd"+l(1821)+"fig"](),this[l(1619)+l(1801)]?.[l(1337)+l(1255)]();return}this[l(1746)+"hCloseEv"+l(1949)](w),this[l(583)+l(507)]?.[l(1423)+l(1821)+l(1152)](),this[l(1619)+l(1801)]?.[l(1337)+l(1255)]()},this.onclose=null,this[r(1952)]=null,this[r(1515)+"e"]=null,this[r(1934)]=null,this[r(1156)+r(1675)]=null,this.onReceiveAck=null,this[r(888)+r(1433)+r(1297)+"ct"]=null,this["_handleO"+r(1114)]=this["_handleO"+r(1114)].bind(this),this["_handleO"+r(1446)]=this[r(1829)+"ffLine"][r(1334)](this),this[r(770)+"ageHide"]=this[r(770)+r(834)].bind(this),this["_handleP"+r(1011)]=this[r(770)+r(1011)][r(1334)](this),this._options={url:"",automaticOpen:!0,initReconnectInterval:1e3,maxReconnectInterval:1e4,reconnectIntervalGrowFactor:2,timeoutInterval:5e3,maxRetries:5,debug:!1,maxMessageQueueLength:e[r(1733)](1,0),service:0,logIDGenerator:a,headers:void 0,payloadEncoding:"",payloadType:"",fpID:"",deviceID:"",accessKey:"",ttwID:"",bddID:"",aID:"",disableAutoReconnect:!1,customParams:{},pingInterval:15e3,pingTimeoutInterval:4e3,pingFrequency:e[r(816)],pingLossCount:2,enableTransformTextPayload:!1,logIDNewConfig:{enableAutoGenerateLogIDNew:!1,userIp:""},miniProgramParams:{customHttpHeader:{}},enableAutoAck:!1,reconnectInterceptor:()=>!0,enableQoS:!1,QoSLevel:2,messageStrategy:e[r(1085)],env:{xTTEnv:"",xUseEnv:""},listenNetworkChanged:!0};let{url:d,ws:h}=t,p=Array[r(1374)](d)?d:e[r(932)](e.yGOwL,typeof d)?[d]:[];if(!p||e[r(494)](0,p[r(633)]))throw new Error(e[r(690)]);if(!e[r(1884)](Qc,h))throw new Error(e[r(1529)]);if(Object[r(505)](this[r(1539)],t),this["_endpoin"+r(507)]=new us(p,this[r(1539)][r(682)+"es"]),this[r(1619)+"sCounter"]=new n0(this[r(1539)][r(496)+r(1279)]),this[r(1539)][r(1273)+"cOpen"]&&(this._isInit=!0,this[r(1614)]()),this[r(1539)]["listenNe"+r(1290)+r(1823)])if(r(1111)!==e[r(1836)]){let w=_0x3a32df[r(605)],l=_0x28d86f.limit;return e[r(979)](w[r(633)],l)?w:w[r(1683)](0,l)}else this[r(585)+"T"]||this[r(511)+"X"]?this["_onPageN"+r(1005)+"ange"]():this[r(1632)+"er"]&&this[r(1658)+r(892)+r(826)]()}[n(1829)+n(1114)](){let t=n;this[t(1539)]["disableA"+t(900)+t(1861)]||this[t(1849)+t(1435)]||this["_handleR"+t(1675)]()}["_handleO"+n(1446)](){let t=n,r={uhGxX:e.ULIpr,UMjkD:e.tfWEJ,qndrx:function(c,d,h,p){return e[R(1062)](c,d,h,p)},qUHgK:e[t(828)],dnnhW:function(c,d,h,p){return e[t(998)](c,d,h,p)},fjQzP:t(2006),ukZcc:e[t(752)],XnLzD:e.DkPDG,tGnVC:"curvalue"};if(e[t(1854)](e[t(1661)],t(1048))){this[t(1859)+t(1101)+"t"]();let c=e[t(1503)](qr,e[t(890)],{message:e[t(1380)]});this[t(888)+"mediatel"+t(1297)+"ct"]&&this[t(888)+"mediatel"+t(1297)+"ct"](c)}else{let[c,d]=e[t(924)](_0x21ea7e,_0x7d42a6),h=e.fkVvL(_0x1e1bcc,c),p=0;return _0x97698.forEach(w=>{let l=t,b=yEjbts[l(1546)][l(1791)]("|"),I=0;for(;;){switch(b[I++]){case"0":_0x355497[l(1974)](yEjbts[l(1248)],w,w[l(1702)]);continue;case"1":p=yEjbts.qndrx(_0x68dc76,w[l(492)+"ame"],h,p);continue;case"2":p=yEjbts[l(490)](_0x41acb8,0,h,p);continue;case"3":p=_0xe62e5(_0x57fbdc[l(1873)+"er"](w[l(680)]||_0x622f14),h,p);continue;case"4":_0x5eeca7.log(yEjbts.qUHgK,p);continue;case"5":p=yEjbts[l(654)](_0x5de671,h,p,w.service||0);continue;case"6":_0xfd1768[l(1974)](yEjbts[l(1555)],p);continue;case"7":p=yEjbts[l(490)](_0x533cb7,d[w[l(492)+l(1997)]],h,p);continue;case"8":_0x552a9d[l(1974)](yEjbts[l(1591)],p);continue;case"9":_0x3dff22[l(1974)](yEjbts.XnLzD,p);continue;case"10":_0x4b4e80.log(yEjbts[l(627)],p);continue}break}}),{frameType:_0x92ce6b,headers:[{key:t(986)+t(483),value:_0x26a5c2}],payload:h}}}[n(1658)+n(892)+n(826)](){let t=n,r={JZfkX:function(c,d){return e[R(651)](c,d)},uDmdJ:function(c,d){return e.VDoLF(c,d)},IFxUl:function(c,d){return e[R(1676)](c,d)}};if(e.rzqrO(e[t(1656)],e.jnqKF))this[t(1632)+"er"]&&window["addEvent"+t(826)](e[t(459)],this[t(1829)+"nLine"]),this._isBrowser&&window[t(1424)+t(826)](e[t(929)],this["_handleO"+t(1446)]),this[t(1632)+"er"]&&window[t(1424)+t(826)]("pagehide",this["_handleP"+t(834)]),this[t(1632)+"er"]&&window[t(1424)+t(826)](t(572),this[t(770)+t(1011)]);else return _0x314ac9.readUInt8?{value:_0x140e60[t(921)+"8"](_0x153324),offset:RGKasA[t(1370)](_0x9326a7,1)}:{value:RGKasA[t(1478)](255,_0x3cba64[_0x47c40b]),offset:RGKasA[t(582)](_0x110062,1)}}[n(1895)+"balEvent"+n(826)](){let t=n;this[t(1632)+"er"]&&window[t(707)+t(1932)+t(903)](e[t(459)],this["_handleO"+t(1114)]),this[t(1632)+"er"]&&window[t(707)+t(1932)+t(903)](e[t(929)],this[t(1829)+t(1446)]),this[t(1632)+"er"]&&window[t(707)+t(1932)+t(903)](e[t(1292)],this[t(770)+t(834)]),this._isBrowser&&window[t(707)+t(1932)+t(903)](e[t(1500)],this[t(770)+t(1011)])}[n(770)+n(834)](t){let r=n;e[r(486)](e[r(1892)],e[r(1471)])?this[r(1945)]?.[r(1178)](_0x4a75ee[r(970)+"id"]):(!t[r(1031)+"d"]&&(this[r(1632)+"er"]&&window[r(707)+r(1932)+r(903)](e[r(1292)],this[r(770)+r(834)]),this[r(1632)+"er"]&&window[r(707)+r(1932)+r(903)](e[r(1500)],this["_handleP"+r(1011)]),this[r(1681)]()),this._isBrowser&&window["removeEventListe"+r(903)](e[r(459)],this[r(1829)+r(1114)]),this[r(1632)+"er"]&&window[r(707)+r(1932)+r(903)](r(1487),this["_handleO"+r(1446)]))}[n(770)+n(1011)](t){let r=n;t[r(1031)+"d"]&&(this[r(553)+r(1243)]()&&(!this[r(1501)]||this[r(1501)][r(1576)+"te"]!==this.OPEN||e[r(1802)](this[r(1501)][r(1576)+"te"],this[r(469)+"NG"]))&&this[r(1829)+"nLine"](),this[r(1632)+"er"]&&window[r(1424)+r(826)](e[r(459)],this[r(1829)+r(1114)]),this._isBrowser&&window[r(1424)+r(826)](e[r(929)],this[r(1829)+r(1446)]))}async[n(1498)+n(1843)](t){let r=n,c={MqRWG:e.wvTVR};if(e.hdpGJ("cjxzI",e[r(711)])){let{fpID:d,deviceID:h,bddID:p,ttwID:w,accessKey:l,aID:b,customParams:I={},enableAutoAck:k,enableQoS:M,QoSLevel:N,env:H}=this[r(1539)],fe,j,$;this[r(1632)+"er"]||this[r(511)+"X"]||this[r(585)+"T"]?(fe=location&&e[r(1690)]==location[r(1506)]?e.LTwCL:r(495),j=t[r(943)](/((^ws)|(^http))((?:[s]*:\/\/))/,""),$=/^wss(.*:\/\/)/[r(885)](t)?t:""+fe+j):(fe=e[r(1774)],j=t[r(943)](/(^http)((?:[s]*:\/\/))/,""),$=/(^ws)((?:[s]*:\/\/))/.test(j)?j:""+fe+j);let Ce=p?e[r(527)]:w?e[r(899)]:r(1302)+"d",Te=p||w||h;if(e[r(1131)](!Te,!Ce))throw new Error(e.RSstO);let Rt=e[r(544)]==typeof I?await I():I,Vr=H?e[r(774)](t0,H[r(1158)],H[r(1358)]):{},ct=Object[r(505)]({device_platform:r(905),version_code:e[r(776)],access_key:l,fpid:d,aid:b,[Ce]:Te,xsack:k?1:0,xaack:k?1:0,xsqos:M?1:0,qos_level:M?N:void 0,qos_sdk_version:2,...Vr},Rt),_t=Object.keys(ct).reduce((Ve,xt)=>ct[xt]!==void 0?""+Ve+(Ve?"&":"?")+xt+"="+ct[xt]:Ve,"");return $+"/ws/v2"+_t}else{let d=this[r(583)+r(507)]?.[r(1890)+"ntEndpoint"]();this[r(1746)+"hCloseEv"+r(1949)](_0x64b195(c[r(1454)],{code:1006,reason:r(1785)+d+(" timeout"+r(1208)+r(1948)+r(1510)),wasClean:!0}))}}async _connect(){let t=n;if(!(this[t(1614)+"Lock"]||this[t(1849)+t(1435)])){this[t(1614)+t(1889)]=!0;try{let r=this[t(583)+t(507)]?.[t(1100)+t(518)+t(1010)+t(953)+t(982)](),{timeoutInterval:c}=this[t(1539)];if(r){let h=this[t(583)+"tManager"]?.[t(1890)+t(1613)+"nt"](),p=this[t(583)+t(507)]?.["replaceBackupEnd"+t(1830)+t(580)+"unt"](),w=this[t(583)+t(507)]?.[t(1890)+"ntEndpoi"+t(973)+"ount"]();if(p){let l=t(1785)+h+(t(850)+t(1208)+"tries re"+t(1905)+t(1915)+t(1894)+t(1736))+p+" to retry",b=e[t(1184)](Pe,e.HqQse,{message:l,code:ot[t(1076)+t(980)+"R"]});this[t(1244)](l),this[t(1746)+t(586)+t(1949)](b),this[t(1978)]=await this["_generat"+t(1843)](p),this._debug(t(1785)+p+" "+w+t(1271)),this[t(848)+t(639)+"rs"]()}else{let l="connect "+h+(t(850)+t(1208)+t(1948)+t(1510));this[t(1244)](l),this[t(1746)+"hErrorEv"+t(1949)](e[t(1154)](Pe,t(1609),{message:l,code:ot[t(1076)+t(980)+"R"]}));return}}else{let h=this[t(583)+t(507)]?.["getCurre"+t(1613)+t(543)+t(751)](),p=this[t(583)+t(507)]?.[t(1890)+t(1613)+t(973)+t(1289)]();this[t(1978)]=await this["_generat"+t(1843)](e.yNXME(h,"")),this._debug(t(1785)+h+" "+p+t(1271)),this[t(848)+t(639)+"rs"]()}if(this[t(1199)])this[t(1199)]=!1;else{let h=e[t(1541)](qr,e[t(890)],{message:t(1246)});this[t(1156)+"econnect"]&&this[t(1156)+"econnect"](h)}let d=this[t(583)+"tManager"]?.[t(1890)+"ntEndpointTriesC"+t(1289)]()||0;e[t(1226)](d,1)&&await this[t(1660)](e[t(1972)](d,1)),this[t(1244)](t(731)+t(1017)+this[t(1978)]+(t(1183)+t(1910))+this[t(1783)+"ls"]),this._ws=e[t(1306)](Zc,{url:this._url,protocols:[this._protocols],headers:this._options["miniProg"+t(1602)+"s"][t(1694)+t(1732)]},this._options.ws),(this[t(1632)+"er"]||this[t(447)+"r"])&&this[t(1501)]&&(this[t(1501)][t(718)+"pe"]=this[t(1099)+t(1298)]),this[t(1045)+"steners"](),this[t(1614)+t(1012)+t(567)]=e[t(1176)](setTimeout,this[t(1644)+"ut"][t(1334)](this),c)}catch(r){throw this[t(1614)+t(1889)]=!1,r}}}[n(1232)+n(827)](){let t=n;e[t(845)](clearTimeout,this["_connectionTimeo"+t(567)]),this[t(1614)+"ionTimeo"+t(567)]=null}[n(812)+n(1177)](){let t=n;e[t(1484)](clearTimeout,this._pingPongTimeoutId),e[t(449)](clearTimeout,this[t(808)+"ctTimeou"+t(1834)]),this._pingPongTimeoutId=null,this[t(808)+t(488)+t(1834)]=null}[n(1244)](...t){let r=n;this[r(1539)][r(1919)]&&console[r(1974)][r(1389)](console,[e[r(1251)],...t])}[n(1871)+n(1201)+"e"](t){let r=n,{initReconnectInterval:c,maxReconnectInterval:d,reconnectIntervalGrowFactor:h}=this[r(1539)],p=e[r(1767)](c,Math[r(994)](h,e[r(1686)](t,1)));return e[r(727)](p,d)?d:p}[n(513)](){let t=n;if(e[t(701)](t(1387),t(1387)))this["_addWsLi"+t(1558)]();else{if(this[t(1501)]&&e.LnLgu(this[t(1501)][t(1576)+"te"],this[t(469)+"NG"])){this[t(812)+t(1177)](),this[t(1230)+t(1537)+"Id"]=e[t(1845)](setTimeout,this._ping[t(1334)](this),this[t(1539)][t(1827)+t(1415)]);return}if(!this[t(1501)]||e.GqQDi(this[t(1501)][t(1576)+"te"],this[t(817)]))return void this[t(617)+t(1675)]();this._ws&&this[t(1501)][t(1764)]("hi"),this[t(808)+t(488)+t(1834)]=e[t(1596)](setTimeout,this[t(617)+t(1675)+t(1250)][t(1334)](this),this._options[t(1157)+t(1898)+t(1852)])}}[n(617)+n(1675)+n(1250)](){let t=n;this[t(1619)+t(1801)]?.[t(578)](),this[t(2008)](e.UtEGp,e[t(597)]),this[t(1619)+"sCounter"]?.checkReachMaxCount()?this[t(617)+t(1675)]():this[t(513)]()}[n(553)+n(1243)](){let t=n;return this[t(585)+"T"]||this[t(511)+"X"]?this[t(1977)+"igatorOnline"]:(this._isBrowser||this[t(447)+"r"])&&this[t(1539)]["listenNe"+t(1290)+"nged"]?navigator[t(904)]:!0}[n(617)+n(1675)](){let t=n;!this["_navigat"+t(1243)]()||this[t(1849)+t(1435)]||(this[t(583)+t(507)]?.[t(1423)+"pointCon"+t(1152)](),this[t(1619)+t(1801)]?.[t(1337)+t(1255)](),this[t(1501)]?this["_disconn"+t(1088)](1001,t(693)+t(1027)+"reconnec"+t(1373)+t(695),!0):this[t(1614)]())}[n(765)+"etWorkCh"+n(1729)](){let t=n;if(e[t(537)](e[t(1333)],t(1855)))return _0x1617eb?.[t(647)](r=>r[t(1214)]===_0x56d616)?.[t(732)];this[t(585)+"T"]?tt[t(1198)+"kStatusC"+t(1128)](({isConnected:r})=>{let c=t;this[c(1977)+c(452)+"line"]=r,r?this[c(1829)+c(1114)]():this[c(1829)+c(1446)]()}):this[t(511)+"X"]&&wx.onNetworkStatusChange(({isConnected:r})=>{let c=t;this[c(1977)+c(452)+c(829)]=r,r?this[c(1829)+c(1114)]():this[c(1829)+c(1446)]()})}_wait(t){let r=n,c={YLoQf:function(d,h,p){return e[R(1488)](d,h,p)}};return e[r(1237)]!==e.NEPaU?new Promise(d=>{let h=r;c[h(1065)](setTimeout,d,this[h(1871)+"rvalValue"](t))}):(this["currentE"+r(1414)+r(1404)+"t"]=1,this[r(863)+r(1504)]++,this.endpoints[this[r(863)+r(1504)]])}["_disconn"+n(1088)](t=1e3,r="",c=!1){let d=n;this[d(1501)]&&this[d(1859)+"WebSocket"](t,r,c)}[n(1644)+"ut"](){let t=n,r=this["_endpoin"+t(507)]?.[t(1890)+t(1613)+"nt"]();this[t(1244)](t(1785)+r+t(850)),this[t(1093)+t(1088)](1001,e[t(1075)],!0)}[n(474)](t){let r=n,c=oe(t);this[r(1501)]&&this[r(1501)][r(1576)+"te"]===this[r(817)]&&(this[r(1501)]&&this._ws.send(c),this._debug(e[r(1024)],t))}[n(848)+n(639)+"rs"](){let t=n,r=e[t(775)][t(1791)]("|"),c=0;for(;;){switch(r[c++]){case"0":this._ws["removeEv"+t(1932)+"ner"](t(1609),this._onError);continue;case"1":this[t(1501)][t(707)+t(1932)+t(903)](e[t(460)],this[t(914)+"ge"]);continue;case"2":if(!this[t(1501)])return;continue;case"3":this[t(1501)][t(707)+t(1932)+t(903)](e[t(1707)],this[t(893)]);continue;case"4":this[t(1501)][t(707)+t(1932)+t(903)](e[t(600)],this[t(958)]);continue}break}}[n(1045)+"steners"](){let t=n,r=(t(1046)+"2")[t(1791)]("|"),c=0;for(;;){switch(r[c++]){case"0":this._ws[t(1424)+t(826)](e[t(460)],this[t(914)+"ge"]);continue;case"1":if(!this[t(1501)])return;continue;case"2":this._ws["addEvent"+t(826)](e[t(1543)],this[t(1393)]);continue;case"3":this[t(1501)]["addEvent"+t(826)](t(1681),this[t(958)]);continue;case"4":this[t(1501)][t(1424)+t(826)](t(1117),this[t(893)]);continue}break}}[n(957)+n(1980)](t=1e3,r=""){let c=n;try{this._ws&&this[c(1501)][c(1681)](t,r)}catch{}}_destroyWebSocket(t=1e3,r="",c=!1){let d=n;if(this[d(812)+d(1177)](),this[d(1232)+d(827)](),this[d(848)+d(639)+"rs"](),this[d(957)+"nceClose"](1e3,r),this["_connect"+d(1889)]=!1,c&&this[d(553)+d(1243)]()&&!this[d(1849)+d(1435)]){if(this["_endpoin"+d(507)]?.[d(983)+"chMaxTries"]()){let p=this[d(583)+d(507)]?.[d(1890)+d(1613)+"nt"]();this[d(1746)+d(1938)+d(1949)](e[d(1663)](Oe,d(1681),{code:1006,reason:"connect "+p+(d(850)+d(1208)+"tries reached"),wasClean:!0}))}else{let p=this[d(1539)]["reconnec"+d(1718)+d(725)](t,r);this["_dispatc"+d(1938)+d(1949)](e[d(1402)](Oe,e[d(600)],{code:t,reason:r,wasClean:!0,willReconnect:p})),p&&this[d(1614)]()}return}this[d(553)+"orOnline"]()||this[d(1849)+"osed"]?this["_dispatc"+d(1938)+d(1949)](e[d(774)](Oe,"close",{code:t,reason:e[d(1807)]})):this["_dispatc"+d(1938)+d(1949)](e[d(1813)](Oe,e.wvTVR,{code:1006,reason:e[d(1857)]})),this._ws=null,this[d(583)+d(507)]?.["resetEndpointCon"+d(1152)](),this[d(1619)+d(1801)]?.[d(1337)+d(1255)]()}[n(1746)+n(1213)+"nt"](t){let r=n;this.emit(r(1117),t),this[r(1934)]&&this[r(1934)](t)}[n(1746)+n(1136)+n(938)](t){let r=n;this.emit(e[r(460)],t),this[r(1515)+"e"]&&this[r(1515)+"e"](t)}[n(1746)+"hAckMess"+n(1872)](t){let r=n;this[r(2008)](r(772),t),this[r(1631)+"eAck"]&&this[r(1631)+r(1447)](t)}[n(1746)+n(586)+n(1949)](t){let r=n;this.emit(e[r(1543)],t),this[r(1952)]&&this[r(1952)](t)}[n(1746)+n(1938)+n(1949)](t){let r=n;if(e.fdxwY(e.TwqaX,e[r(1991)]))try{this[r(1945)]?.close(),this._qosDB=void 0}catch(c){_0x4b7864.log(c)}else this.emit(e[r(600)],t),this[r(1617)]&&this[r(1617)](t)}get[n(718)+"pe"](){let t=n;return this[t(1501)]?this._ws[t(718)+"pe"]:this[t(1099)+t(1298)]}set[n(718)+"pe"](t){let r=n;this[r(1099)+r(1298)]=t,this[r(1501)]&&(this[r(1501)][r(718)+"pe"]=t)}get[n(1722)+"nt"](){let t=n;if(e[t(1744)](e[t(1462)],e[t(1628)])){let r=this[t(1945)][t(629)](this._prefix),c=_0xa51949.parse(e[t(1384)](r,"{}"));return _0x2423ad[t(1770)](c)}else return this["_endpoin"+t(507)]?.["getCurre"+t(1613)+t(973)+t(1289)]()||0}get[n(1399)+n(1395)](){let t=n,r=this[t(1204)+t(789)][t(887)]((c,d)=>(c+=d&&d[t(557)+"th"]||0,c),0);return e[t(1524)](r,this[t(1501)]?this[t(1501)][t(1399)+t(1395)]:0)}get[n(652)+"ns"](){let t=n;return this[t(1501)]?this[t(1501)][t(652)+"ns"]:""}get protocol(){let t=n;return e[t(1036)](e[t(1563)],e.YipKQ)?this[t(1501)]?this[t(1501)][t(1506)]:"":{frameType:_0x57088e,headers:[{key:t(986)+t(483),value:e[t(1028)]}],payload:void 0}}get[n(1576)+"te"](){let t=n;if(e.ULSfP(e[t(1489)],e[t(1307)]))return this._ws?this[t(1501)].readyState:this[t(1539)][t(1273)+t(1921)]?this[t(469)+"NG"]:this[t(1896)];{let r=_0x1be9cc[t(1664)](TDlAQG[t(771)](_0x219158,this),_0x3b6d42,..._0xdefe6b);return _0x207df6[t(833)](r,_0x370f4a[t(1870)]?_0xfa68fb[t(1870)]():[_0x13969f]),TDlAQG.HMTSF(_0x737a16,r)}}get url(){let t=n;return this[t(1501)]?this[t(1501)][t(1493)]:this._url}[n(1681)](t=1e3,r){let c=n,d=(c(535)+c(1826))[c(1791)]("|"),h=0;for(;;){switch(d[h++]){case"0":this["_readyCl"+c(1435)]=!0;continue;case"1":if(this._ws[c(1576)+"te"]===this[c(1896)]||this[c(1501)].readyState===this[c(686)])return void this[c(1244)](e[c(1401)]);continue;case"2":this[c(1859)+c(1101)+"t"](t,r);continue;case"3":if(!this._ws)return void this[c(1244)](e.FNqSZ);continue;case"4":this["_clearTi"+c(827)]();continue;case"5":this[c(1895)+c(892)+"Listener"]();continue;case"6":this[c(812)+c(1177)]();continue;case"7":this[c(1336)+c(641)]?.[c(1598)]();continue}break}}async[n(1764)](t,r){let c=n;if(e.NoUaN(null,t))throw new Error(e[c(1038)]);e.gnkCE(e[c(678)],typeof t)&&(t=JSON.stringify(t)),e[c(802)]!=typeof t&&!e.DnuNE(t,ArrayBuffer)&&!(t[c(1565)]&&e[c(1018)](t.buffer,ArrayBuffer))&&(t=JSON.stringify(t));let d=await e.mGKQz(hs,t),h=e[c(1842)](e0,t),{method:p=0,service:w=this[c(1539)][c(1702)],logID:l=this[c(1539)][c(1035)+c(860)](),headers:b=this[c(1539)][c(795)],payloadEncoding:I=this[c(1539)][c(609)+"ncoding"],payloadType:k=this[c(1539)]["payloadT"+c(1298)],logIDNew:M=this[c(1539)]["logIDNew"+c(1637)][c(1999)+c(1545)+c(1074)+"ew"]?e[c(1611)](o,this._options[c(673)+c(1637)][c(1769)]):""}=r||{};if(!w)throw new Error(e.ETqfE);let N={SeqID:W[c(1873)+"er"](this[c(510)]++),LogID:W[c(1873)+"er"](l),service:w,method:p,headers:b,payloadEncoding:e[c(1018)](I,Object)?I[c(1739)]?I[c(1739)]:"":I,payloadType:k instanceof Object?k.type?k[c(1262)]:h:k||h,payload:d,LogIDNew:M},H=e[c(779)](oe,N);if(this[c(1501)]&&e[c(1533)](this[c(1501)].readyState,this[c(817)]))this[c(1501)]&&this._ws[c(1764)](H),this[c(1244)](e[c(1811)],N);else if(e[c(800)](this["_message"+c(789)][c(633)],this[c(1539)]["maxMessageQueueL"+c(1973)])){if(e[c(568)](e.fVFgr,c(1904)))return _0x43091b;this["_message"+c(789)][c(684)](H),this._debug(e[c(739)],N)}else e[c(1630)](e[c(941)],e[c(836)])?(this[c(1204)+c(789)][c(720)](),this[c(1204)+c(789)].push(H)):(_0x4947bf[_0xc80b88++]=e[c(602)](_0x54c2f9>>6,192),_0x55bad2[_0xdef9fa++]=e[c(1947)](63,_0x516bf8)|128);return{seqID:this[c(510)],logID:l,logIDNew:M}}async[n(1485)+"t"](t){let r=n,c={mChlU:function(p,w){return e[R(1749)](p,w)}},{url:d}=e.vTYLg(t,{}),h=Array[r(1374)](d)?d:e[r(1141)](e.yGOwL,typeof d)?[d]:[];if(t&&Object.assign(this[r(1539)],t),h&&h[r(633)]?this[r(583)+r(507)]=new us(h,this._options[r(682)+"es"]):this[r(583)+r(507)]?.["resetEnd"+r(1821)+"fig"](),this[r(1619)+r(1801)]?.[r(1337)+r(1255)](this[r(1539)][r(496)+r(1279)]),this[r(1849)+"osed"]=!1,this[r(1501)]&&e.OCYTj(this[r(1501)][r(1576)+"te"],this[r(1896)]))this[r(1093)+"ect"](1e3,e[r(1847)],!0);else if(e[r(724)]("kHccr",e[r(750)]))this[r(1199)]=!0,this._connect();else{let p=this[r(1945)]["getStora"+r(1818)+"nc"](this[r(499)]),w=_0x3f3009[r(1263)](YGhdis[r(1366)](p,"{}"));return _0x788047[r(1770)](w)}}async[n(1833)](){let t=n;if(!this[t(1614)+"Lock"]){let r=e[t(1209)][t(1791)]("|"),c=0;for(;;){switch(r[c++]){case"0":this[t(1619)+t(1801)]?.[t(1337)+t(1255)]();continue;case"1":this[t(1614)]();continue;case"2":this[t(1199)]=!0;continue;case"3":this[t(1849)+t(1435)]=!1;continue;case"4":this[t(583)+t(507)]?.[t(1423)+t(1821)+"fig"]();continue}break}}}["addEvent"+n(826)](t,r){let c=n;if(e[c(1468)](e[c(1592)],e.qgiyq))this.on(t,r);else{let d=this[c(1539)][c(1485)+c(1718)+"ptor"](_0x2159cf,_0x34ec27);this["_dispatc"+c(1938)+c(1949)](e[c(1472)](_0x3af719,e[c(600)],{code:_0x51f79d,reason:_0x48b40b,wasClean:!0,willReconnect:d})),d&&this[c(1614)]()}}[n(1508)+"Event"](t){let r=n;if(e[r(1715)](e[r(1123)],e[r(1123)])){let{type:c}=t;this[r(2008)](c,t)}else return this._ws?this[r(1501)].binaryType:this[r(1099)+"ype"]}[n(707)+"entListener"](t,r){this[n(1260)](t,r)}pingOnce(){let t=n,r={zrNZT:e.KyrpD,xqDaH:t(1470)+t(748)+"s",Deaue:e[t(1200)],xwTjV:e.ihUIA,twjaH:function(c,d,h){return e[t(1472)](c,d,h)}};return new Promise((c,d)=>{let h=t,p={ObGVo:r[h(1505)],WXgDr:r[h(1682)],znuzn:r[h(457)],ByHLz:r.xwTjV};this["_clearPi"+h(1177)](),this[h(1230)+h(1537)+"Id"]=r[h(1700)](setTimeout,this[h(513)][h(1334)](this),this._options[h(1827)+"rval"]);let w=()=>{let b=h;c(p[b(516)]),this.off(p.WXgDr,w),this[b(1260)](p[b(601)],l)},l=()=>{let b=h;d(p[b(949)]),this[b(1260)](p[b(1321)],w),this[b(1260)](b(1470)+b(1740)+"t",l)};this.on(h(1470)+h(748)+"s",w),this.on("ping_onc"+h(1740)+"t",l),this[h(513)]()})}}})(),Q[C(1687)+C(907)]=re[C(1687)+C(907)],Q[C(1753)+C(1364)]=re[C(1753)+"rorEvent"],Q[C(1985)+"e"]=re[C(1985)+"e"],Q[C(938)]=re[C(938)],Q[C(1775)]=re.FWS,Q["Frontier"+C(1610)+"vent"]=re[C(1620)+"MessageE"+C(1286)],Q[C(1610)+C(1286)]=re["MessageE"+C(1286)],Q[C(2002)+"t"]=re[C(2002)+"t"],Q[C(875)+C(1013)]=re[C(875)+C(1013)],Q[C(476)+C(907)]=re[C(476)+C(907)],Q[C(869)+"rorEvent"]=re.createErrorEvent,Q[C(838)+C(1392)+"nt"]=re[C(838)+"ssageEvent"],Q["createOp"+C(934)]=re["createOp"+C(934)],Q[C(1405)+C(467)+C(1286)]=re[C(1405)+"connectE"+C(1286)],Q.decodedFrame=re["decodedF"+C(1126)],Q[C(688)+C(1997)]=re[C(688)+"ame"];for(sr in re)[C(1687)+C(907),C(1753)+C(1364),C(1985)+"e",C(938),C(1775),C(1620)+C(1610)+C(1286),C(1610)+C(1286),"OpenEvent",C(875)+C(1013),C(476)+C(907),C(869)+"rorEvent",C(838)+C(1392)+"nt",C(506)+C(934),C(1405)+"connectE"+C(1286),"decodedF"+C(1126),C(688)+C(1997)].indexOf(sr)===-1&&(Q[sr]=re[sr]);var sr;Object[C(760)+C(1797)](Q,"__esModule",{value:!0})});var Qe=ve((h_,ca)=>{"use strict";var oa=["nodebuffer","arraybuffer","fragments"],aa=typeof Blob<"u";aa&&oa.push("blob");ca.exports={BINARY_TYPES:oa,CLOSE_TIMEOUT:3e4,EMPTY_BUFFER:Buffer.alloc(0),GUID:"258EAFA5-E914-47DA-95CA-C5AB0DC85B11",hasBlob:aa,kForOnEventAttribute:Symbol("kIsForOnEventAttribute"),kListener:Symbol("kListener"),kStatusCode:Symbol("status-code"),kWebSocket:Symbol("websocket"),NOOP:()=>{}}});var mn=ve((p_,fr)=>{"use strict";var{EMPTY_BUFFER:gf}=Qe(),mi=Buffer[Symbol.species];function hf(n,e){if(n.length===0)return gf;if(n.length===1)return n[0];let i=Buffer.allocUnsafe(e),o=0;for(let a=0;a<n.length;a++){let x=n[a];i.set(x,o),o+=x.length}return o<e?new mi(i.buffer,i.byteOffset,o):i}function xa(n,e,i,o,a){for(let x=0;x<a;x++)i[o+x]=n[x]^e[x&3]}function da(n,e){for(let i=0;i<n.length;i++)n[i]^=e[i&3]}function pf(n){return n.length===n.buffer.byteLength?n.buffer:n.buffer.slice(n.byteOffset,n.byteOffset+n.length)}function wi(n){if(wi.readOnly=!0,Buffer.isBuffer(n))return n;let e;return n instanceof ArrayBuffer?e=new mi(n):ArrayBuffer.isView(n)?e=new mi(n.buffer,n.byteOffset,n.byteLength):(e=Buffer.from(n),wi.readOnly=!1),e}fr.exports={concat:hf,mask:xa,toArrayBuffer:pf,toBuffer:wi,unmask:da};if(!process.env.WS_NO_BUFFER_UTIL)try{let n=ne("bufferutil");fr.exports.mask=function(e,i,o,a,x){x<48?xa(e,i,o,a,x):n.mask(e,i,o,a,x)},fr.exports.unmask=function(e,i){e.length<32?da(e,i):n.unmask(e,i)}}catch{}});var la=ve((m_,fa)=>{"use strict";var ua=Symbol("kDone"),_i=Symbol("kRun"),yi=class{constructor(e){this[ua]=()=>{this.pending--,this[_i]()},this.concurrency=e||1/0,this.jobs=[],this.pending=0}add(e){this.jobs.push(e),this[_i]()}[_i](){if(this.pending!==this.concurrency&&this.jobs.length){let e=this.jobs.shift();this.pending++,e(this[ua])}}};fa.exports=yi});var $t=ve((w_,ma)=>{"use strict";var wn=ne("zlib"),ga=mn(),mf=la(),{kStatusCode:ha}=Qe(),wf=Buffer[Symbol.species],_f=Buffer.from([0,0,255,255]),gr=Symbol("permessage-deflate"),et=Symbol("total-length"),jt=Symbol("callback"),ht=Symbol("buffers"),Wt=Symbol("error"),lr,bi=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,!lr){let i=this._options.concurrencyLimit!==void 0?this._options.concurrencyLimit:10;lr=new mf(i)}}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[jt];this._deflate.close(),this._deflate=null,e&&e(new Error("The deflate stream was closed while data was being processed"))}}acceptAsServer(e){let i=this._options,o=e.find(a=>!(i.serverNoContextTakeover===!1&&a.server_no_context_takeover||a.server_max_window_bits&&(i.serverMaxWindowBits===!1||typeof i.serverMaxWindowBits=="number"&&i.serverMaxWindowBits>a.server_max_window_bits)||typeof i.clientMaxWindowBits=="number"&&!a.client_max_window_bits));if(!o)throw new Error("None of the extension offers can be accepted");return i.serverNoContextTakeover&&(o.server_no_context_takeover=!0),i.clientNoContextTakeover&&(o.client_no_context_takeover=!0),typeof i.serverMaxWindowBits=="number"&&(o.server_max_window_bits=i.serverMaxWindowBits),typeof i.clientMaxWindowBits=="number"?o.client_max_window_bits=i.clientMaxWindowBits:(o.client_max_window_bits===!0||i.clientMaxWindowBits===!1)&&delete o.client_max_window_bits,o}acceptAsClient(e){let i=e[0];if(this._options.clientNoContextTakeover===!1&&i.client_no_context_takeover)throw new Error('Unexpected parameter "client_no_context_takeover"');if(!i.client_max_window_bits)typeof this._options.clientMaxWindowBits=="number"&&(i.client_max_window_bits=this._options.clientMaxWindowBits);else if(this._options.clientMaxWindowBits===!1||typeof this._options.clientMaxWindowBits=="number"&&i.client_max_window_bits>this._options.clientMaxWindowBits)throw new Error('Unexpected or invalid parameter "client_max_window_bits"');return i}normalizeParams(e){return e.forEach(i=>{Object.keys(i).forEach(o=>{let a=i[o];if(a.length>1)throw new Error(`Parameter "${o}" must have only a single value`);if(a=a[0],o==="client_max_window_bits"){if(a!==!0){let x=+a;if(!Number.isInteger(x)||x<8||x>15)throw new TypeError(`Invalid value for parameter "${o}": ${a}`);a=x}else if(!this._isServer)throw new TypeError(`Invalid value for parameter "${o}": ${a}`)}else if(o==="server_max_window_bits"){let x=+a;if(!Number.isInteger(x)||x<8||x>15)throw new TypeError(`Invalid value for parameter "${o}": ${a}`);a=x}else if(o==="client_no_context_takeover"||o==="server_no_context_takeover"){if(a!==!0)throw new TypeError(`Invalid value for parameter "${o}": ${a}`)}else throw new Error(`Unknown parameter "${o}"`);i[o]=a})}),e}decompress(e,i,o){lr.add(a=>{this._decompress(e,i,(x,u)=>{a(),o(x,u)})})}compress(e,i,o){lr.add(a=>{this._compress(e,i,(x,u)=>{a(),o(x,u)})})}_decompress(e,i,o){let a=this._isServer?"client":"server";if(!this._inflate){let x=`${a}_max_window_bits`,u=typeof this.params[x]!="number"?wn.Z_DEFAULT_WINDOWBITS:this.params[x];this._inflate=wn.createInflateRaw({...this._options.zlibInflateOptions,windowBits:u}),this._inflate[gr]=this,this._inflate[et]=0,this._inflate[ht]=[],this._inflate.on("error",bf),this._inflate.on("data",pa)}this._inflate[jt]=o,this._inflate.write(e),i&&this._inflate.write(_f),this._inflate.flush(()=>{let x=this._inflate[Wt];if(x){this._inflate.close(),this._inflate=null,o(x);return}let u=ga.concat(this._inflate[ht],this._inflate[et]);this._inflate._readableState.endEmitted?(this._inflate.close(),this._inflate=null):(this._inflate[et]=0,this._inflate[ht]=[],i&&this.params[`${a}_no_context_takeover`]&&this._inflate.reset()),o(null,u)})}_compress(e,i,o){let a=this._isServer?"server":"client";if(!this._deflate){let x=`${a}_max_window_bits`,u=typeof this.params[x]!="number"?wn.Z_DEFAULT_WINDOWBITS:this.params[x];this._deflate=wn.createDeflateRaw({...this._options.zlibDeflateOptions,windowBits:u}),this._deflate[et]=0,this._deflate[ht]=[],this._deflate.on("data",yf)}this._deflate[jt]=o,this._deflate.write(e),this._deflate.flush(wn.Z_SYNC_FLUSH,()=>{if(!this._deflate)return;let x=ga.concat(this._deflate[ht],this._deflate[et]);i&&(x=new wf(x.buffer,x.byteOffset,x.length-4)),this._deflate[jt]=null,this._deflate[et]=0,this._deflate[ht]=[],i&&this.params[`${a}_no_context_takeover`]&&this._deflate.reset(),o(null,x)})}};ma.exports=bi;function yf(n){this[ht].push(n),this[et]+=n.length}function pa(n){if(this[et]+=n.length,this[gr]._maxPayload<1||this[et]<=this[gr]._maxPayload){this[ht].push(n);return}this[Wt]=new RangeError("Max payload size exceeded"),this[Wt].code="WS_ERR_UNSUPPORTED_MESSAGE_LENGTH",this[Wt][ha]=1009,this.removeListener("data",pa),this.reset()}function bf(n){if(this[gr]._inflate=null,this[Wt]){this[jt](this[Wt]);return}n[ha]=1007,this[jt](n)}});var Jt=ve((__,hr)=>{"use strict";var{isUtf8:wa}=ne("buffer"),{hasBlob:vf}=Qe(),Sf=[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 Ef(n){return n>=1e3&&n<=1014&&n!==1004&&n!==1005&&n!==1006||n>=3e3&&n<=4999}function vi(n){let e=n.length,i=0;for(;i<e;)if((n[i]&128)===0)i++;else if((n[i]&224)===192){if(i+1===e||(n[i+1]&192)!==128||(n[i]&254)===192)return!1;i+=2}else if((n[i]&240)===224){if(i+2>=e||(n[i+1]&192)!==128||(n[i+2]&192)!==128||n[i]===224&&(n[i+1]&224)===128||n[i]===237&&(n[i+1]&224)===160)return!1;i+=3}else if((n[i]&248)===240){if(i+3>=e||(n[i+1]&192)!==128||(n[i+2]&192)!==128||(n[i+3]&192)!==128||n[i]===240&&(n[i+1]&240)===128||n[i]===244&&n[i+1]>143||n[i]>244)return!1;i+=4}else return!1;return!0}function If(n){return vf&&typeof n=="object"&&typeof n.arrayBuffer=="function"&&typeof n.type=="string"&&typeof n.stream=="function"&&(n[Symbol.toStringTag]==="Blob"||n[Symbol.toStringTag]==="File")}hr.exports={isBlob:If,isValidStatusCode:Ef,isValidUTF8:vi,tokenChars:Sf};if(wa)hr.exports.isValidUTF8=function(n){return n.length<24?vi(n):wa(n)};else if(!process.env.WS_NO_UTF_8_VALIDATE)try{let n=ne("utf-8-validate");hr.exports.isValidUTF8=function(e){return e.length<32?vi(e):n(e)}}catch{}});var Pi=ve((y_,Ia)=>{"use strict";var{Writable:Af}=ne("stream"),_a=$t(),{BINARY_TYPES:Pf,EMPTY_BUFFER:ya,kStatusCode:Cf,kWebSocket:Tf}=Qe(),{concat:Si,toArrayBuffer:kf,unmask:Df}=mn(),{isValidStatusCode:Rf,isValidUTF8:ba}=Jt(),pr=Buffer[Symbol.species],De=0,va=1,Sa=2,Ea=3,Ei=4,Ii=5,mr=6,Ai=class extends Af{constructor(e={}){super(),this._allowSynchronousEvents=e.allowSynchronousEvents!==void 0?e.allowSynchronousEvents:!0,this._binaryType=e.binaryType||Pf[0],this._extensions=e.extensions||{},this._isServer=!!e.isServer,this._maxPayload=e.maxPayload|0,this._skipUTF8Validation=!!e.skipUTF8Validation,this[Tf]=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=De}_write(e,i,o){if(this._opcode===8&&this._state==De)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 pr(o.buffer,o.byteOffset+e,o.length-e),new pr(o.buffer,o.byteOffset,e)}let i=Buffer.allocUnsafe(e);do{let o=this._buffers[0],a=i.length-e;e>=o.length?i.set(this._buffers.shift(),a):(i.set(new Uint8Array(o.buffer,o.byteOffset,e),a),this._buffers[0]=new pr(o.buffer,o.byteOffset+e,o.length-e)),e-=o.length}while(e>0);return i}startLoop(e){this._loop=!0;do switch(this._state){case De:this.getInfo(e);break;case va:this.getPayloadLength16(e);break;case Sa:this.getPayloadLength64(e);break;case Ea:this.getMask();break;case Ei:this.getData(e);break;case Ii:case mr:this._loop=!1;return}while(this._loop);this._errored||e()}getInfo(e){if(this._bufferedBytes<2){this._loop=!1;return}let i=this.consume(2);if((i[0]&48)!==0){let a=this.createError(RangeError,"RSV2 and RSV3 must be clear",!0,1002,"WS_ERR_UNEXPECTED_RSV_2_3");e(a);return}let o=(i[0]&64)===64;if(o&&!this._extensions[_a.extensionName]){let a=this.createError(RangeError,"RSV1 must be clear",!0,1002,"WS_ERR_UNEXPECTED_RSV_1");e(a);return}if(this._fin=(i[0]&128)===128,this._opcode=i[0]&15,this._payloadLength=i[1]&127,this._opcode===0){if(o){let a=this.createError(RangeError,"RSV1 must be clear",!0,1002,"WS_ERR_UNEXPECTED_RSV_1");e(a);return}if(!this._fragmented){let a=this.createError(RangeError,"invalid opcode 0",!0,1002,"WS_ERR_INVALID_OPCODE");e(a);return}this._opcode=this._fragmented}else if(this._opcode===1||this._opcode===2){if(this._fragmented){let a=this.createError(RangeError,`invalid opcode ${this._opcode}`,!0,1002,"WS_ERR_INVALID_OPCODE");e(a);return}this._compressed=o}else if(this._opcode>7&&this._opcode<11){if(!this._fin){let a=this.createError(RangeError,"FIN must be set",!0,1002,"WS_ERR_EXPECTED_FIN");e(a);return}if(o){let a=this.createError(RangeError,"RSV1 must be clear",!0,1002,"WS_ERR_UNEXPECTED_RSV_1");e(a);return}if(this._payloadLength>125||this._opcode===8&&this._payloadLength===1){let a=this.createError(RangeError,`invalid payload length ${this._payloadLength}`,!0,1002,"WS_ERR_INVALID_CONTROL_PAYLOAD_LENGTH");e(a);return}}else{let a=this.createError(RangeError,`invalid opcode ${this._opcode}`,!0,1002,"WS_ERR_INVALID_OPCODE");e(a);return}if(!this._fin&&!this._fragmented&&(this._fragmented=this._opcode),this._masked=(i[1]&128)===128,this._isServer){if(!this._masked){let a=this.createError(RangeError,"MASK must be set",!0,1002,"WS_ERR_EXPECTED_MASK");e(a);return}}else if(this._masked){let a=this.createError(RangeError,"MASK must be clear",!0,1002,"WS_ERR_UNEXPECTED_MASK");e(a);return}this._payloadLength===126?this._state=va:this._payloadLength===127?this._state=Sa: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 i=this.consume(8),o=i.readUInt32BE(0);if(o>Math.pow(2,21)-1){let a=this.createError(RangeError,"Unsupported WebSocket frame: payload length > 2^53 - 1",!1,1009,"WS_ERR_UNSUPPORTED_DATA_PAYLOAD_LENGTH");e(a);return}this._payloadLength=o*Math.pow(2,32)+i.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 i=this.createError(RangeError,"Max payload size exceeded",!1,1009,"WS_ERR_UNSUPPORTED_MESSAGE_LENGTH");e(i);return}this._masked?this._state=Ea:this._state=Ei}getMask(){if(this._bufferedBytes<4){this._loop=!1;return}this._mask=this.consume(4),this._state=Ei}getData(e){let i=ya;if(this._payloadLength){if(this._bufferedBytes<this._payloadLength){this._loop=!1;return}i=this.consume(this._payloadLength),this._masked&&(this._mask[0]|this._mask[1]|this._mask[2]|this._mask[3])!==0&&Df(i,this._mask)}if(this._opcode>7){this.controlMessage(i,e);return}if(this._compressed){this._state=Ii,this.decompress(i,e);return}i.length&&(this._messageLength=this._totalPayloadLength,this._fragments.push(i)),this.dataMessage(e)}decompress(e,i){this._extensions[_a.extensionName].decompress(e,this._fin,(a,x)=>{if(a)return i(a);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");i(u);return}this._fragments.push(x)}this.dataMessage(i),this._state===De&&this.startLoop(i)})}dataMessage(e){if(!this._fin){this._state=De;return}let i=this._messageLength,o=this._fragments;if(this._totalPayloadLength=0,this._messageLength=0,this._fragmented=0,this._fragments=[],this._opcode===2){let a;this._binaryType==="nodebuffer"?a=Si(o,i):this._binaryType==="arraybuffer"?a=kf(Si(o,i)):this._binaryType==="blob"?a=new Blob(o):a=o,this._allowSynchronousEvents?(this.emit("message",a,!0),this._state=De):(this._state=mr,setImmediate(()=>{this.emit("message",a,!0),this._state=De,this.startLoop(e)}))}else{let a=Si(o,i);if(!this._skipUTF8Validation&&!ba(a)){let x=this.createError(Error,"invalid UTF-8 sequence",!0,1007,"WS_ERR_INVALID_UTF8");e(x);return}this._state===Ii||this._allowSynchronousEvents?(this.emit("message",a,!1),this._state=De):(this._state=mr,setImmediate(()=>{this.emit("message",a,!1),this._state=De,this.startLoop(e)}))}}controlMessage(e,i){if(this._opcode===8){if(e.length===0)this._loop=!1,this.emit("conclude",1005,ya),this.end();else{let o=e.readUInt16BE(0);if(!Rf(o)){let x=this.createError(RangeError,`invalid status code ${o}`,!0,1002,"WS_ERR_INVALID_CLOSE_CODE");i(x);return}let a=new pr(e.buffer,e.byteOffset+2,e.length-2);if(!this._skipUTF8Validation&&!ba(a)){let x=this.createError(Error,"invalid UTF-8 sequence",!0,1007,"WS_ERR_INVALID_UTF8");i(x);return}this._loop=!1,this.emit("conclude",o,a),this.end()}this._state=De;return}this._allowSynchronousEvents?(this.emit(this._opcode===9?"ping":"pong",e),this._state=De):(this._state=mr,setImmediate(()=>{this.emit(this._opcode===9?"ping":"pong",e),this._state=De,this.startLoop(i)}))}createError(e,i,o,a,x){this._loop=!1,this._errored=!0;let u=new e(o?`Invalid WebSocket frame: ${i}`:i);return Error.captureStackTrace(u,this.createError),u.code=x,u[Cf]=a,u}};Ia.exports=Ai});var ki=ve((v_,Ca)=>{"use strict";var{Duplex:b_}=ne("stream"),{randomFillSync:Nf}=ne("crypto"),Aa=$t(),{EMPTY_BUFFER:Of,kWebSocket:Lf,NOOP:Mf}=Qe(),{isBlob:Vt,isValidStatusCode:Bf}=Jt(),{mask:Pa,toBuffer:bt}=mn(),Re=Symbol("kByteLength"),zf=Buffer.alloc(4),wr=8*1024,vt,Yt=wr,Le=0,Ff=1,Uf=2,Ci=class n{constructor(e,i,o){this._extensions=i||{},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=Le,this.onerror=Mf,this[Lf]=void 0}static frame(e,i){let o,a=!1,x=2,u=!1;i.mask&&(o=i.maskBuffer||zf,i.generateMask?i.generateMask(o):(Yt===wr&&(vt===void 0&&(vt=Buffer.alloc(wr)),Nf(vt,0,wr),Yt=0),o[0]=vt[Yt++],o[1]=vt[Yt++],o[2]=vt[Yt++],o[3]=vt[Yt++]),u=(o[0]|o[1]|o[2]|o[3])===0,x=6);let f;typeof e=="string"?(!i.mask||u)&&i[Re]!==void 0?f=i[Re]:(e=Buffer.from(e),f=e.length):(f=e.length,a=i.mask&&i.readOnly&&!u);let g=f;f>=65536?(x+=8,g=127):f>125&&(x+=2,g=126);let m=Buffer.allocUnsafe(a?f+x:x);return m[0]=i.fin?i.opcode|128:i.opcode,i.rsv1&&(m[0]|=64),m[1]=g,g===126?m.writeUInt16BE(f,2):g===127&&(m[2]=m[3]=0,m.writeUIntBE(f,4,6)),i.mask?(m[1]|=128,m[x-4]=o[0],m[x-3]=o[1],m[x-2]=o[2],m[x-1]=o[3],u?[m,e]:a?(Pa(e,o,m,x,f),[m]):(Pa(e,o,e,0,f),[m,e])):[m,e]}close(e,i,o,a){let x;if(e===void 0)x=Of;else{if(typeof e!="number"||!Bf(e))throw new TypeError("First argument must be a valid error code number");if(i===void 0||!i.length)x=Buffer.allocUnsafe(2),x.writeUInt16BE(e,0);else{let f=Buffer.byteLength(i);if(f>123)throw new RangeError("The message must not be greater than 123 bytes");x=Buffer.allocUnsafe(2+f),x.writeUInt16BE(e,0),typeof i=="string"?x.write(i,2):x.set(i,2)}}let u={[Re]:x.length,fin:!0,generateMask:this._generateMask,mask:o,maskBuffer:this._maskBuffer,opcode:8,readOnly:!1,rsv1:!1};this._state!==Le?this.enqueue([this.dispatch,x,!1,u,a]):this.sendFrame(n.frame(x,u),a)}ping(e,i,o){let a,x;if(typeof e=="string"?(a=Buffer.byteLength(e),x=!1):Vt(e)?(a=e.size,x=!1):(e=bt(e),a=e.length,x=bt.readOnly),a>125)throw new RangeError("The data size must not be greater than 125 bytes");let u={[Re]:a,fin:!0,generateMask:this._generateMask,mask:i,maskBuffer:this._maskBuffer,opcode:9,readOnly:x,rsv1:!1};Vt(e)?this._state!==Le?this.enqueue([this.getBlobData,e,!1,u,o]):this.getBlobData(e,!1,u,o):this._state!==Le?this.enqueue([this.dispatch,e,!1,u,o]):this.sendFrame(n.frame(e,u),o)}pong(e,i,o){let a,x;if(typeof e=="string"?(a=Buffer.byteLength(e),x=!1):Vt(e)?(a=e.size,x=!1):(e=bt(e),a=e.length,x=bt.readOnly),a>125)throw new RangeError("The data size must not be greater than 125 bytes");let u={[Re]:a,fin:!0,generateMask:this._generateMask,mask:i,maskBuffer:this._maskBuffer,opcode:10,readOnly:x,rsv1:!1};Vt(e)?this._state!==Le?this.enqueue([this.getBlobData,e,!1,u,o]):this.getBlobData(e,!1,u,o):this._state!==Le?this.enqueue([this.dispatch,e,!1,u,o]):this.sendFrame(n.frame(e,u),o)}send(e,i,o){let a=this._extensions[Aa.extensionName],x=i.binary?2:1,u=i.compress,f,g;typeof e=="string"?(f=Buffer.byteLength(e),g=!1):Vt(e)?(f=e.size,g=!1):(e=bt(e),f=e.length,g=bt.readOnly),this._firstFragment?(this._firstFragment=!1,u&&a&&a.params[a._isServer?"server_no_context_takeover":"client_no_context_takeover"]&&(u=f>=a._threshold),this._compress=u):(u=!1,x=0),i.fin&&(this._firstFragment=!0);let m={[Re]:f,fin:i.fin,generateMask:this._generateMask,mask:i.mask,maskBuffer:this._maskBuffer,opcode:x,readOnly:g,rsv1:u};Vt(e)?this._state!==Le?this.enqueue([this.getBlobData,e,this._compress,m,o]):this.getBlobData(e,this._compress,m,o):this._state!==Le?this.enqueue([this.dispatch,e,this._compress,m,o]):this.dispatch(e,this._compress,m,o)}getBlobData(e,i,o,a){this._bufferedBytes+=o[Re],this._state=Uf,e.arrayBuffer().then(x=>{if(this._socket.destroyed){let f=new Error("The socket was closed while the blob was being read");process.nextTick(Ti,this,f,a);return}this._bufferedBytes-=o[Re];let u=bt(x);i?this.dispatch(u,i,o,a):(this._state=Le,this.sendFrame(n.frame(u,o),a),this.dequeue())}).catch(x=>{process.nextTick(qf,this,x,a)})}dispatch(e,i,o,a){if(!i){this.sendFrame(n.frame(e,o),a);return}let x=this._extensions[Aa.extensionName];this._bufferedBytes+=o[Re],this._state=Ff,x.compress(e,o.fin,(u,f)=>{if(this._socket.destroyed){let g=new Error("The socket was closed while data was being compressed");Ti(this,g,a);return}this._bufferedBytes-=o[Re],this._state=Le,o.readOnly=!1,this.sendFrame(n.frame(f,o),a),this.dequeue()})}dequeue(){for(;this._state===Le&&this._queue.length;){let e=this._queue.shift();this._bufferedBytes-=e[3][Re],Reflect.apply(e[0],this,e.slice(1))}}enqueue(e){this._bufferedBytes+=e[3][Re],this._queue.push(e)}sendFrame(e,i){e.length===2?(this._socket.cork(),this._socket.write(e[0]),this._socket.write(e[1],i),this._socket.uncork()):this._socket.write(e[0],i)}};Ca.exports=Ci;function Ti(n,e,i){typeof i=="function"&&i(e);for(let o=0;o<n._queue.length;o++){let a=n._queue[o],x=a[a.length-1];typeof x=="function"&&x(e)}}function qf(n,e,i){Ti(n,e,i),n.onerror(e)}});var Ba=ve((S_,Ma)=>{"use strict";var{kForOnEventAttribute:_n,kListener:Di}=Qe(),Ta=Symbol("kCode"),ka=Symbol("kData"),Da=Symbol("kError"),Ra=Symbol("kMessage"),Na=Symbol("kReason"),Xt=Symbol("kTarget"),Oa=Symbol("kType"),La=Symbol("kWasClean"),nt=class{constructor(e){this[Xt]=null,this[Oa]=e}get target(){return this[Xt]}get type(){return this[Oa]}};Object.defineProperty(nt.prototype,"target",{enumerable:!0});Object.defineProperty(nt.prototype,"type",{enumerable:!0});var St=class extends nt{constructor(e,i={}){super(e),this[Ta]=i.code===void 0?0:i.code,this[Na]=i.reason===void 0?"":i.reason,this[La]=i.wasClean===void 0?!1:i.wasClean}get code(){return this[Ta]}get reason(){return this[Na]}get wasClean(){return this[La]}};Object.defineProperty(St.prototype,"code",{enumerable:!0});Object.defineProperty(St.prototype,"reason",{enumerable:!0});Object.defineProperty(St.prototype,"wasClean",{enumerable:!0});var Zt=class extends nt{constructor(e,i={}){super(e),this[Da]=i.error===void 0?null:i.error,this[Ra]=i.message===void 0?"":i.message}get error(){return this[Da]}get message(){return this[Ra]}};Object.defineProperty(Zt.prototype,"error",{enumerable:!0});Object.defineProperty(Zt.prototype,"message",{enumerable:!0});var yn=class extends nt{constructor(e,i={}){super(e),this[ka]=i.data===void 0?null:i.data}get data(){return this[ka]}};Object.defineProperty(yn.prototype,"data",{enumerable:!0});var Gf={addEventListener(n,e,i={}){for(let a of this.listeners(n))if(!i[_n]&&a[Di]===e&&!a[_n])return;let o;if(n==="message")o=function(x,u){let f=new yn("message",{data:u?x:x.toString()});f[Xt]=this,_r(e,this,f)};else if(n==="close")o=function(x,u){let f=new St("close",{code:x,reason:u.toString(),wasClean:this._closeFrameReceived&&this._closeFrameSent});f[Xt]=this,_r(e,this,f)};else if(n==="error")o=function(x){let u=new Zt("error",{error:x,message:x.message});u[Xt]=this,_r(e,this,u)};else if(n==="open")o=function(){let x=new nt("open");x[Xt]=this,_r(e,this,x)};else return;o[_n]=!!i[_n],o[Di]=e,i.once?this.once(n,o):this.on(n,o)},removeEventListener(n,e){for(let i of this.listeners(n))if(i[Di]===e&&!i[_n]){this.removeListener(n,i);break}}};Ma.exports={CloseEvent:St,ErrorEvent:Zt,Event:nt,EventTarget:Gf,MessageEvent:yn};function _r(n,e,i){typeof n=="object"&&n.handleEvent?n.handleEvent.call(n,i):n.call(e,i)}});var yr=ve((E_,za)=>{"use strict";var{tokenChars:bn}=Jt();function We(n,e,i){n[e]===void 0?n[e]=[i]:n[e].push(i)}function Hf(n){let e=Object.create(null),i=Object.create(null),o=!1,a=!1,x=!1,u,f,g=-1,m=-1,y=-1,_=0;for(;_<n.length;_++)if(m=n.charCodeAt(_),u===void 0)if(y===-1&&bn[m]===1)g===-1&&(g=_);else if(_!==0&&(m===32||m===9))y===-1&&g!==-1&&(y=_);else if(m===59||m===44){if(g===-1)throw new SyntaxError(`Unexpected character at index ${_}`);y===-1&&(y=_);let E=n.slice(g,y);m===44?(We(e,E,i),i=Object.create(null)):u=E,g=y=-1}else throw new SyntaxError(`Unexpected character at index ${_}`);else if(f===void 0)if(y===-1&&bn[m]===1)g===-1&&(g=_);else if(m===32||m===9)y===-1&&g!==-1&&(y=_);else if(m===59||m===44){if(g===-1)throw new SyntaxError(`Unexpected character at index ${_}`);y===-1&&(y=_),We(i,n.slice(g,y),!0),m===44&&(We(e,u,i),i=Object.create(null),u=void 0),g=y=-1}else if(m===61&&g!==-1&&y===-1)f=n.slice(g,_),g=y=-1;else throw new SyntaxError(`Unexpected character at index ${_}`);else if(a){if(bn[m]!==1)throw new SyntaxError(`Unexpected character at index ${_}`);g===-1?g=_:o||(o=!0),a=!1}else if(x)if(bn[m]===1)g===-1&&(g=_);else if(m===34&&g!==-1)x=!1,y=_;else if(m===92)a=!0;else throw new SyntaxError(`Unexpected character at index ${_}`);else if(m===34&&n.charCodeAt(_-1)===61)x=!0;else if(y===-1&&bn[m]===1)g===-1&&(g=_);else if(g!==-1&&(m===32||m===9))y===-1&&(y=_);else if(m===59||m===44){if(g===-1)throw new SyntaxError(`Unexpected character at index ${_}`);y===-1&&(y=_);let E=n.slice(g,y);o&&(E=E.replace(/\\/g,""),o=!1),We(i,f,E),m===44&&(We(e,u,i),i=Object.create(null),u=void 0),f=void 0,g=y=-1}else throw new SyntaxError(`Unexpected character at index ${_}`);if(g===-1||x||m===32||m===9)throw new SyntaxError("Unexpected end of input");y===-1&&(y=_);let S=n.slice(g,y);return u===void 0?We(e,S,i):(f===void 0?We(i,S,!0):o?We(i,f,S.replace(/\\/g,"")):We(i,f,S),We(e,u,i)),e}function Kf(n){return Object.keys(n).map(e=>{let i=n[e];return Array.isArray(i)||(i=[i]),i.map(o=>[e].concat(Object.keys(o).map(a=>{let x=o[a];return Array.isArray(x)||(x=[x]),x.map(u=>u===!0?a:`${a}=${u}`).join("; ")})).join("; ")).join(", ")}).join(", ")}za.exports={format:Kf,parse:Hf}});var Er=ve((P_,Ya)=>{"use strict";var jf=ne("events"),Wf=ne("https"),$f=ne("http"),qa=ne("net"),Jf=ne("tls"),{randomBytes:Vf,createHash:Yf}=ne("crypto"),{Duplex:I_,Readable:A_}=ne("stream"),{URL:Ri}=ne("url"),pt=$t(),Xf=Pi(),Zf=ki(),{isBlob:Qf}=Jt(),{BINARY_TYPES:Fa,CLOSE_TIMEOUT:el,EMPTY_BUFFER:br,GUID:tl,kForOnEventAttribute:Ni,kListener:nl,kStatusCode:rl,kWebSocket:de,NOOP:Ga}=Qe(),{EventTarget:{addEventListener:il,removeEventListener:sl}}=Ba(),{format:ol,parse:al}=yr(),{toBuffer:cl}=mn(),Ha=Symbol("kAborted"),Oi=[8,13],rt=["CONNECTING","OPEN","CLOSING","CLOSED"],xl=/^[!#$%&'*+\-.0-9A-Z^_`|a-z~]+$/,Y=class n extends jf{constructor(e,i,o){super(),this._binaryType=Fa[0],this._closeCode=1006,this._closeFrameReceived=!1,this._closeFrameSent=!1,this._closeMessage=br,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,i===void 0?i=[]:Array.isArray(i)||(typeof i=="object"&&i!==null?(o=i,i=[]):i=[i]),Ka(this,e,i,o)):(this._autoPong=o.autoPong,this._closeTimeout=o.closeTimeout,this._isServer=!0)}get binaryType(){return this._binaryType}set binaryType(e){Fa.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,i,o){let a=new Xf({allowSynchronousEvents:o.allowSynchronousEvents,binaryType:this.binaryType,extensions:this._extensions,isServer:this._isServer,maxPayload:o.maxPayload,skipUTF8Validation:o.skipUTF8Validation}),x=new Zf(e,this._extensions,o.generateMask);this._receiver=a,this._sender=x,this._socket=e,a[de]=this,x[de]=this,e[de]=this,a.on("conclude",fl),a.on("drain",ll),a.on("error",gl),a.on("message",hl),a.on("ping",pl),a.on("pong",ml),x.onerror=wl,e.setTimeout&&e.setTimeout(0),e.setNoDelay&&e.setNoDelay(),i.length>0&&e.unshift(i),e.on("close",$a),e.on("data",Sr),e.on("end",Ja),e.on("error",Va),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[pt.extensionName]&&this._extensions[pt.extensionName].cleanup(),this._receiver.removeAllListeners(),this._readyState=n.CLOSED,this.emit("close",this._closeCode,this._closeMessage)}close(e,i){if(this.readyState!==n.CLOSED){if(this.readyState===n.CONNECTING){Ae(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,i,!this._isServer,o=>{o||(this._closeFrameSent=!0,(this._closeFrameReceived||this._receiver._writableState.errorEmitted)&&this._socket.end())}),Wa(this)}}pause(){this.readyState===n.CONNECTING||this.readyState===n.CLOSED||(this._paused=!0,this._socket.pause())}ping(e,i,o){if(this.readyState===n.CONNECTING)throw new Error("WebSocket is not open: readyState 0 (CONNECTING)");if(typeof e=="function"?(o=e,e=i=void 0):typeof i=="function"&&(o=i,i=void 0),typeof e=="number"&&(e=e.toString()),this.readyState!==n.OPEN){Li(this,e,o);return}i===void 0&&(i=!this._isServer),this._sender.ping(e||br,i,o)}pong(e,i,o){if(this.readyState===n.CONNECTING)throw new Error("WebSocket is not open: readyState 0 (CONNECTING)");if(typeof e=="function"?(o=e,e=i=void 0):typeof i=="function"&&(o=i,i=void 0),typeof e=="number"&&(e=e.toString()),this.readyState!==n.OPEN){Li(this,e,o);return}i===void 0&&(i=!this._isServer),this._sender.pong(e||br,i,o)}resume(){this.readyState===n.CONNECTING||this.readyState===n.CLOSED||(this._paused=!1,this._receiver._writableState.needDrain||this._socket.resume())}send(e,i,o){if(this.readyState===n.CONNECTING)throw new Error("WebSocket is not open: readyState 0 (CONNECTING)");if(typeof i=="function"&&(o=i,i={}),typeof e=="number"&&(e=e.toString()),this.readyState!==n.OPEN){Li(this,e,o);return}let a={binary:typeof e!="string",mask:!this._isServer,compress:!0,fin:!0,...i};this._extensions[pt.extensionName]||(a.compress=!1),this._sender.send(e||br,a,o)}terminate(){if(this.readyState!==n.CLOSED){if(this.readyState===n.CONNECTING){Ae(this,this._req,"WebSocket was closed before the connection was established");return}this._socket&&(this._readyState=n.CLOSING,this._socket.destroy())}}};Object.defineProperty(Y,"CONNECTING",{enumerable:!0,value:rt.indexOf("CONNECTING")});Object.defineProperty(Y.prototype,"CONNECTING",{enumerable:!0,value:rt.indexOf("CONNECTING")});Object.defineProperty(Y,"OPEN",{enumerable:!0,value:rt.indexOf("OPEN")});Object.defineProperty(Y.prototype,"OPEN",{enumerable:!0,value:rt.indexOf("OPEN")});Object.defineProperty(Y,"CLOSING",{enumerable:!0,value:rt.indexOf("CLOSING")});Object.defineProperty(Y.prototype,"CLOSING",{enumerable:!0,value:rt.indexOf("CLOSING")});Object.defineProperty(Y,"CLOSED",{enumerable:!0,value:rt.indexOf("CLOSED")});Object.defineProperty(Y.prototype,"CLOSED",{enumerable:!0,value:rt.indexOf("CLOSED")});["binaryType","bufferedAmount","extensions","isPaused","protocol","readyState","url"].forEach(n=>{Object.defineProperty(Y.prototype,n,{enumerable:!0})});["open","error","close","message"].forEach(n=>{Object.defineProperty(Y.prototype,`on${n}`,{enumerable:!0,get(){for(let e of this.listeners(n))if(e[Ni])return e[nl];return null},set(e){for(let i of this.listeners(n))if(i[Ni]){this.removeListener(n,i);break}typeof e=="function"&&this.addEventListener(n,e,{[Ni]:!0})}})});Y.prototype.addEventListener=il;Y.prototype.removeEventListener=sl;Ya.exports=Y;function Ka(n,e,i,o){let a={allowSynchronousEvents:!0,autoPong:!0,closeTimeout:el,protocolVersion:Oi[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=a.autoPong,n._closeTimeout=a.closeTimeout,!Oi.includes(a.protocolVersion))throw new RangeError(`Unsupported protocol version: ${a.protocolVersion} (supported versions: ${Oi.join(", ")})`);let x;if(e instanceof Ri)x=e;else try{x=new Ri(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:",f=x.protocol==="ws+unix:",g;if(x.protocol!=="ws:"&&!u&&!f?g=`The URL's protocol must be one of "ws:", "wss:", "http:", "https:", or "ws+unix:"`:f&&!x.pathname?g="The URL's pathname is empty":x.hash&&(g="The URL contains a fragment identifier"),g){let T=new SyntaxError(g);if(n._redirects===0)throw T;vr(n,T);return}let m=u?443:80,y=Vf(16).toString("base64"),_=u?Wf.request:$f.request,S=new Set,E;if(a.createConnection=a.createConnection||(u?ul:dl),a.defaultPort=a.defaultPort||m,a.port=x.port||m,a.host=x.hostname.startsWith("[")?x.hostname.slice(1,-1):x.hostname,a.headers={...a.headers,"Sec-WebSocket-Version":a.protocolVersion,"Sec-WebSocket-Key":y,Connection:"Upgrade",Upgrade:"websocket"},a.path=x.pathname+x.search,a.timeout=a.handshakeTimeout,a.perMessageDeflate&&(E=new pt({...a.perMessageDeflate,isServer:!1,maxPayload:a.maxPayload}),a.headers["Sec-WebSocket-Extensions"]=ol({[pt.extensionName]:E.offer()})),i.length){for(let T of i){if(typeof T!="string"||!xl.test(T)||S.has(T))throw new SyntaxError("An invalid or duplicated subprotocol was specified");S.add(T)}a.headers["Sec-WebSocket-Protocol"]=i.join(",")}if(a.origin&&(a.protocolVersion<13?a.headers["Sec-WebSocket-Origin"]=a.origin:a.headers.Origin=a.origin),(x.username||x.password)&&(a.auth=`${x.username}:${x.password}`),f){let T=a.path.split(":");a.socketPath=T[0],a.path=T[1]}let A;if(a.followRedirects){if(n._redirects===0){n._originalIpc=f,n._originalSecure=u,n._originalHostOrSocketPath=f?a.socketPath:x.host;let T=o&&o.headers;if(o={...o,headers:{}},T)for(let[z,Z]of Object.entries(T))o.headers[z.toLowerCase()]=Z}else if(n.listenerCount("redirect")===0){let T=f?n._originalIpc?a.socketPath===n._originalHostOrSocketPath:!1:n._originalIpc?!1:x.host===n._originalHostOrSocketPath;(!T||n._originalSecure&&!u)&&(delete a.headers.authorization,delete a.headers.cookie,T||delete a.headers.host,a.auth=void 0)}a.auth&&!o.headers.authorization&&(o.headers.authorization="Basic "+Buffer.from(a.auth).toString("base64")),A=n._req=_(a),n._redirects&&n.emit("redirect",n.url,A)}else A=n._req=_(a);a.timeout&&A.on("timeout",()=>{Ae(n,A,"Opening handshake has timed out")}),A.on("error",T=>{A===null||A[Ha]||(A=n._req=null,vr(n,T))}),A.on("response",T=>{let z=T.headers.location,Z=T.statusCode;if(z&&a.followRedirects&&Z>=300&&Z<400){if(++n._redirects>a.maxRedirects){Ae(n,A,"Maximum redirects exceeded");return}A.abort();let K;try{K=new Ri(z,e)}catch{let J=new SyntaxError(`Invalid URL: ${z}`);vr(n,J);return}Ka(n,K,i,o)}else n.emit("unexpected-response",A,T)||Ae(n,A,`Unexpected server response: ${T.statusCode}`)}),A.on("upgrade",(T,z,Z)=>{if(n.emit("upgrade",T),n.readyState!==Y.CONNECTING)return;A=n._req=null;let K=T.headers.upgrade;if(K===void 0||K.toLowerCase()!=="websocket"){Ae(n,z,"Invalid Upgrade header");return}let ce=Yf("sha1").update(y+tl).digest("base64");if(T.headers["sec-websocket-accept"]!==ce){Ae(n,z,"Invalid Sec-WebSocket-Accept header");return}let J=T.headers["sec-websocket-protocol"],_e;if(J!==void 0?S.size?S.has(J)||(_e="Server sent an invalid subprotocol"):_e="Server sent a subprotocol but none was requested":S.size&&(_e="Server sent no subprotocol"),_e){Ae(n,z,_e);return}J&&(n._protocol=J);let ye=T.headers["sec-websocket-extensions"];if(ye!==void 0){if(!E){Ae(n,z,"Server sent a Sec-WebSocket-Extensions header but no extension was requested");return}let Ne;try{Ne=al(ye)}catch{Ae(n,z,"Invalid Sec-WebSocket-Extensions header");return}let ie=Object.keys(Ne);if(ie.length!==1||ie[0]!==pt.extensionName){Ae(n,z,"Server indicated an extension that was not requested");return}try{E.accept(Ne[pt.extensionName])}catch{Ae(n,z,"Invalid Sec-WebSocket-Extensions header");return}n._extensions[pt.extensionName]=E}n.setSocket(z,Z,{allowSynchronousEvents:a.allowSynchronousEvents,generateMask:a.generateMask,maxPayload:a.maxPayload,skipUTF8Validation:a.skipUTF8Validation})}),a.finishRequest?a.finishRequest(A,n):A.end()}function vr(n,e){n._readyState=Y.CLOSING,n._errorEmitted=!0,n.emit("error",e),n.emitClose()}function dl(n){return n.path=n.socketPath,qa.connect(n)}function ul(n){return n.path=void 0,!n.servername&&n.servername!==""&&(n.servername=qa.isIP(n.host)?"":n.host),Jf.connect(n)}function Ae(n,e,i){n._readyState=Y.CLOSING;let o=new Error(i);Error.captureStackTrace(o,Ae),e.setHeader?(e[Ha]=!0,e.abort(),e.socket&&!e.socket.destroyed&&e.socket.destroy(),process.nextTick(vr,n,o)):(e.destroy(o),e.once("error",n.emit.bind(n,"error")),e.once("close",n.emitClose.bind(n)))}function Li(n,e,i){if(e){let o=Qf(e)?e.size:cl(e).length;n._socket?n._sender._bufferedBytes+=o:n._bufferedAmount+=o}if(i){let o=new Error(`WebSocket is not open: readyState ${n.readyState} (${rt[n.readyState]})`);process.nextTick(i,o)}}function fl(n,e){let i=this[de];i._closeFrameReceived=!0,i._closeMessage=e,i._closeCode=n,i._socket[de]!==void 0&&(i._socket.removeListener("data",Sr),process.nextTick(ja,i._socket),n===1005?i.close():i.close(n,e))}function ll(){let n=this[de];n.isPaused||n._socket.resume()}function gl(n){let e=this[de];e._socket[de]!==void 0&&(e._socket.removeListener("data",Sr),process.nextTick(ja,e._socket),e.close(n[rl])),e._errorEmitted||(e._errorEmitted=!0,e.emit("error",n))}function Ua(){this[de].emitClose()}function hl(n,e){this[de].emit("message",n,e)}function pl(n){let e=this[de];e._autoPong&&e.pong(n,!this._isServer,Ga),e.emit("ping",n)}function ml(n){this[de].emit("pong",n)}function ja(n){n.resume()}function wl(n){let e=this[de];e.readyState!==Y.CLOSED&&(e.readyState===Y.OPEN&&(e._readyState=Y.CLOSING,Wa(e)),this._socket.end(),e._errorEmitted||(e._errorEmitted=!0,e.emit("error",n)))}function Wa(n){n._closeTimer=setTimeout(n._socket.destroy.bind(n._socket),n._closeTimeout)}function $a(){let n=this[de];if(this.removeListener("close",$a),this.removeListener("data",Sr),this.removeListener("end",Ja),n._readyState=Y.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[de]=void 0,clearTimeout(n._closeTimer),n._receiver._writableState.finished||n._receiver._writableState.errorEmitted?n.emitClose():(n._receiver.on("error",Ua),n._receiver.on("finish",Ua))}function Sr(n){this[de]._receiver.write(n)||this.pause()}function Ja(){let n=this[de];n._readyState=Y.CLOSING,n._receiver.end(),this.end()}function Va(){let n=this[de];this.removeListener("error",Va),this.on("error",Ga),n&&(n._readyState=Y.CLOSING,this.destroy())}});var ec=ve((T_,Qa)=>{"use strict";var C_=Er(),{Duplex:_l}=ne("stream");function Xa(n){n.emit("close")}function yl(){!this.destroyed&&this._writableState.finished&&this.destroy()}function Za(n){this.removeListener("error",Za),this.destroy(),this.listenerCount("error")===0&&this.emit("error",n)}function bl(n,e){let i=!0,o=new _l({...e,autoDestroy:!1,emitClose:!1,objectMode:!1,writableObjectMode:!1});return n.on("message",function(x,u){let f=!u&&o._readableState.objectMode?x.toString():x;o.push(f)||n.pause()}),n.once("error",function(x){o.destroyed||(i=!1,o.destroy(x))}),n.once("close",function(){o.destroyed||o.push(null)}),o._destroy=function(a,x){if(n.readyState===n.CLOSED){x(a),process.nextTick(Xa,o);return}let u=!1;n.once("error",function(g){u=!0,x(g)}),n.once("close",function(){u||x(a),process.nextTick(Xa,o)}),i&&n.terminate()},o._final=function(a){if(n.readyState===n.CONNECTING){n.once("open",function(){o._final(a)});return}n._socket!==null&&(n._socket._writableState.finished?(a(),o._readableState.endEmitted&&o.destroy()):(n._socket.once("finish",function(){a()}),n.close()))},o._read=function(){n.isPaused&&n.resume()},o._write=function(a,x,u){if(n.readyState===n.CONNECTING){n.once("open",function(){o._write(a,x,u)});return}n.send(a,u)},o.on("end",yl),o.on("error",Za),o}Qa.exports=bl});var Mi=ve((k_,tc)=>{"use strict";var{tokenChars:vl}=Jt();function Sl(n){let e=new Set,i=-1,o=-1,a=0;for(a;a<n.length;a++){let u=n.charCodeAt(a);if(o===-1&&vl[u]===1)i===-1&&(i=a);else if(a!==0&&(u===32||u===9))o===-1&&i!==-1&&(o=a);else if(u===44){if(i===-1)throw new SyntaxError(`Unexpected character at index ${a}`);o===-1&&(o=a);let f=n.slice(i,o);if(e.has(f))throw new SyntaxError(`The "${f}" subprotocol is duplicated`);e.add(f),i=o=-1}else throw new SyntaxError(`Unexpected character at index ${a}`)}if(i===-1||o!==-1)throw new SyntaxError("Unexpected end of input");let x=n.slice(i,a);if(e.has(x))throw new SyntaxError(`The "${x}" subprotocol is duplicated`);return e.add(x),e}tc.exports={parse:Sl}});var cc=ve((R_,ac)=>{"use strict";var El=ne("events"),Ir=ne("http"),{Duplex:D_}=ne("stream"),{createHash:Il}=ne("crypto"),nc=yr(),Et=$t(),Al=Mi(),Pl=Er(),{CLOSE_TIMEOUT:Cl,GUID:Tl,kWebSocket:kl}=Qe(),Dl=/^[+/0-9A-Za-z]{22}==$/,rc=0,ic=1,oc=2,Bi=class extends El{constructor(e,i){if(super(),e={allowSynchronousEvents:!0,autoPong:!0,maxPayload:100*1024*1024,skipUTF8Validation:!1,perMessageDeflate:!1,handleProtocols:null,clientTracking:!0,closeTimeout:Cl,verifyClient:null,noServer:!1,backlog:null,server:null,host:null,path:null,port:null,WebSocket:Pl,...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=Ir.createServer((o,a)=>{let x=Ir.STATUS_CODES[426];a.writeHead(426,{"Content-Length":x.length,"Content-Type":"text/plain"}),a.end(x)}),this._server.listen(e.port,e.host,e.backlog,i)):e.server&&(this._server=e.server),this._server){let o=this.emit.bind(this,"connection");this._removeListeners=Rl(this._server,{listening:this.emit.bind(this,"listening"),error:this.emit.bind(this,"error"),upgrade:(a,x,u)=>{this.handleUpgrade(a,x,u,o)}})}e.perMessageDeflate===!0&&(e.perMessageDeflate={}),e.clientTracking&&(this.clients=new Set,this._shouldEmitClose=!1),this.options=e,this._state=rc}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===oc){e&&this.once("close",()=>{e(new Error("The server is not running"))}),process.nextTick(vn,this);return}if(e&&this.once("close",e),this._state!==ic)if(this._state=ic,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(vn,this):process.nextTick(vn,this);else{let i=this._server;this._removeListeners(),this._removeListeners=this._server=null,i.close(()=>{vn(this)})}}shouldHandle(e){if(this.options.path){let i=e.url.indexOf("?");if((i!==-1?e.url.slice(0,i):e.url)!==this.options.path)return!1}return!0}handleUpgrade(e,i,o,a){i.on("error",sc);let x=e.headers["sec-websocket-key"],u=e.headers.upgrade,f=+e.headers["sec-websocket-version"];if(e.method!=="GET"){It(this,e,i,405,"Invalid HTTP method");return}if(u===void 0||u.toLowerCase()!=="websocket"){It(this,e,i,400,"Invalid Upgrade header");return}if(x===void 0||!Dl.test(x)){It(this,e,i,400,"Missing or invalid Sec-WebSocket-Key header");return}if(f!==13&&f!==8){It(this,e,i,400,"Missing or invalid Sec-WebSocket-Version header",{"Sec-WebSocket-Version":"13, 8"});return}if(!this.shouldHandle(e)){Sn(i,400);return}let g=e.headers["sec-websocket-protocol"],m=new Set;if(g!==void 0)try{m=Al.parse(g)}catch{It(this,e,i,400,"Invalid Sec-WebSocket-Protocol header");return}let y=e.headers["sec-websocket-extensions"],_={};if(this.options.perMessageDeflate&&y!==void 0){let S=new Et({...this.options.perMessageDeflate,isServer:!0,maxPayload:this.options.maxPayload});try{let E=nc.parse(y);E[Et.extensionName]&&(S.accept(E[Et.extensionName]),_[Et.extensionName]=S)}catch{It(this,e,i,400,"Invalid or unacceptable Sec-WebSocket-Extensions header");return}}if(this.options.verifyClient){let S={origin:e.headers[`${f===8?"sec-websocket-origin":"origin"}`],secure:!!(e.socket.authorized||e.socket.encrypted),req:e};if(this.options.verifyClient.length===2){this.options.verifyClient(S,(E,A,T,z)=>{if(!E)return Sn(i,A||401,T,z);this.completeUpgrade(_,x,m,e,i,o,a)});return}if(!this.options.verifyClient(S))return Sn(i,401)}this.completeUpgrade(_,x,m,e,i,o,a)}completeUpgrade(e,i,o,a,x,u,f){if(!x.readable||!x.writable)return x.destroy();if(x[kl])throw new Error("server.handleUpgrade() was called more than once with the same socket, possibly due to a misconfiguration");if(this._state>rc)return Sn(x,503);let m=["HTTP/1.1 101 Switching Protocols","Upgrade: websocket","Connection: Upgrade",`Sec-WebSocket-Accept: ${Il("sha1").update(i+Tl).digest("base64")}`],y=new this.options.WebSocket(null,void 0,this.options);if(o.size){let _=this.options.handleProtocols?this.options.handleProtocols(o,a):o.values().next().value;_&&(m.push(`Sec-WebSocket-Protocol: ${_}`),y._protocol=_)}if(e[Et.extensionName]){let _=e[Et.extensionName].params,S=nc.format({[Et.extensionName]:[_]});m.push(`Sec-WebSocket-Extensions: ${S}`),y._extensions=e}this.emit("headers",m,a),x.write(m.concat(`\r
|
|
8
|
+
var L0=Object.create;var Wr=Object.defineProperty;var M0=Object.getOwnPropertyDescriptor;var B0=Object.getOwnPropertyNames;var z0=Object.getPrototypeOf,F0=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 Te=(n,e)=>()=>(n&&(e=n(n=0)),e);var be=(n,e)=>()=>(e||n((e={exports:{}}).exports,e),e.exports),Jr=(n,e)=>{for(var s in e)Wr(n,s,{get:e[s],enumerable:!0})},U0=(n,e,s,o)=>{if(e&&typeof e=="object"||typeof e=="function")for(let c of B0(e))!F0.call(n,c)&&c!==s&&Wr(n,c,{get:()=>e[c],enumerable:!(o=M0(e,c))||o.enumerable});return n};var We=(n,e,s)=>(s=n!=null?L0(z0(n)):{},U0(e||!n||!n.__esModule?Wr(s,"default",{value:n,enumerable:!0}):s,n));function _s(n){return vn[ms]<=vn[n]}function Sn(n){ws={...n}}function bn(n,e,s,o){if(vn[n]<vn[ms])return;let c=JSON.stringify({ts:new Date().toISOString(),level:n,module:e,msg:s,...ws,...o});n==="error"||n==="warn"?G0.write(`${c}
|
|
9
|
+
`):q0.write(`${c}
|
|
10
|
+
`)}function N(n){return{debug:(e,s)=>bn("debug",n,e,s),info:(e,s)=>bn("info",n,e,s),warn:(e,s)=>bn("warn",n,e,s),error:(e,s)=>bn("error",n,e,s),child:e=>N(`${n}.${e}`)}}var vn,ms,q0,G0,ws,q=Te(()=>{"use strict";vn={debug:10,info:20,warn:30,error:40},ms=(()=>{let n=process.env.COZE_BRIDGE_LOG_LEVEL;return n==="debug"||n==="info"||n==="warn"||n==="error"?n:"info"})(),q0=process.stdout,G0=process.stderr,ws={}});import{chmod as nd,mkdir as rd,readFile as id,rename as Is,writeFile as As}from"node:fs/promises";import{dirname as sd}from"node:path";async function Tt(n){try{let e=await id(n,"utf8");return JSON.parse(e)}catch(e){if(e.code==="ENOENT")return null;throw e}}async function Tn(n,e,s){await rd(sd(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 As(c,o,{encoding:"utf8",mode:s.mode}):await As(c,o,"utf8"),await Is(c,n),s?.mode!==void 0&&await nd(n,s.mode)}catch(d){await Is(c,c).catch(()=>{});let{rm:u}=await import("node:fs/promises");throw await u(c,{force:!0}).catch(()=>{}),d}}var Pn=Te(()=>{"use strict"});import{promises as Ts}from"node:fs";import{homedir as od}from"node:os";import{sep as ad,join as ue,resolve as Ps}from"node:path";function G(n){let e=n??od(),s=ue(e,".coze"),o=ue(s,"bridge"),c=ue(o,"lib");return{cozeRoot:s,bridgeRoot:o,libDir:c,libEntry:ue(c,"index.js"),binDir:ue(o,"bin"),pidFile:ue(o,"bridge.pid"),portFile:ue(o,"bridge.port"),tokenFile:ue(o,"bridge.token"),patTokenFile:ue(o,"pat-token"),logFile:ue(o,"bridge.log"),installLock:ue(o,"install.lock"),configFile:ue(o,"config.json"),agentsRoot:ue(s,"agents")}}function Je(n,e=G()){let s=ue(e.agentsRoot,n);return{root:s,config:ue(s,"config.json"),workspace:ue(s,"workspace"),logs:ue(s,"logs")}}async function Cs(n,e){let s=await Ts.realpath(Ps(n)).catch(()=>null);if(!s)return!1;let o=await Ts.realpath(Ps(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+ad)}var ie=Te(()=>{"use strict"});var Dn={};Jr(Dn,{AGENT_CONFIG_FILE_MODE:()=>Cn,enforceAgentConfigMode:()=>xd,loadAgentConfig:()=>he,persistAgentSessions:()=>$r,persistAgentSkills:()=>kn,saveAgentConfig:()=>Se});import{chmod as cd,stat as dd}from"node:fs/promises";function he(n,e){return Tt(Je(n,e).config)}function Se(n,e){return Tn(Je(n.agentId,e).config,n,{mode:Cn})}async function xd(n,e){if(process.platform==="win32")return;let s=Je(n,e).config;try{let o=await dd(s);if(!o.isFile())return;let c=o.mode&511;c!==Cn&&(await cd(s,Cn),ks.warn("agent config mode auto-corrected to 0600",{path:s,from:c.toString(8)}))}catch(o){if(o.code==="ENOENT")return;ks.warn("enforceAgentConfigMode: chmod failed (ignored)",{path:s,err:String(o)})}}async function $r(n,e,s){let o=await he(n,s);o&&(o.sessions=Object.fromEntries(e),await Se(o,s))}async function kn(n,e,s){let o=await he(n,s);o&&(o.skills=e,await Se(o,s))}var ks,Cn,it=Te(()=>{"use strict";Pn();q();ie();ks=N("agent-config"),Cn=384});function Co(n){let e=n?.sessionIdleTimeoutMs;return typeof e!="number"||!Number.isFinite(e)||e<=0?eu:e}function ct(n){return Tt(n??G().configFile)}function Ue(n,e){return Tn(e??G().configFile,n)}var eu,Mt=Te(()=>{"use strict";Pn();ie();eu=10*6e4});var na=be(se=>{"use strict";var P=R;function nr(){let n=["CMvHC29U","wg9Nsuu","qw16vK0","yxbWBhK","Eg9rAM0","C3vIC3rYAw4","uwDLrKi","twvZC2fNzuu","s2ncAxe","yM9KEq","mhWXFdj8nhW","D3jiEhK","C2vUDa","Bg9Nsurhzw4","BIWGAg9ZDg4","Ag5zrLO","DhLnyvG","yw51Ce1LC3m","x2DLDeLUDgu","DgLTzw91DcW","DhjPzxmGCMu","EKvHDey","tg9Nsuq","CMvKDwnL","mtGXmLvQBhjqAG","rgXuCvm","zhLksxG","Eg9ZAe0","DcbSAw1PDa","AuzozNa","Aw47y2HHCNm","x25HDMLNyxq","wvHdze0","zMLN","yw1LoIa","y2fSBa","BwfUDwfSihi","rLDt","BM5Ly3q","r2Pfu1O","y2HnyxHdB3u","vhv6s0O","vhzoz1K","u0XpC1q","ruXnwvO","sNnVBNi","D3PhsKq","AenSB3nLrxy","u2vXsuq","B2zQq0q","CLbrqKO","yMLUyxj5","BNvTyMvY","AxmGDw5Kzwy","x3bPBMDqB24","vM9IAeW","wgPnELu","shn1qxu","s0Tsr0W","ExbL","s0vVswG","Be1yvhu","zxH0ugf5Bg8","B2nRzxq","qwnMy0m","yw5Nzq","q0PNCM4","BgjzC1e","zxjFCw9Z","rg9JDxe","B25JBg9Zzq","A2zqrLu","BKv4t24","q3DSzgi","B2XKvMvYC2K","yM9L","B0z0wfq","tg9NsurozxC","BfDyDuu","zNjVBunOyxi","A01Yr2C","CMvTB3zLq2G","DLvWwMy","z2v0u3rVCMe","q2vfzK8","DvnRChe","A0LLBK4","x29WDgLVBNm","vLHttLe","yMTdwhO","B3bLBKrc","AevYCM9Yrxy","qvznENi","ALf2uMO","sgPKtwm","zxHWB3j0CW","CKXuuw0","zNDZxZeUmc4","tLfxtKS","uM5Pzxe","y29UC3rYDwm","DM9Vt2K","C1zTAxm","BNrfBMrWB2K","v0fhwKe","wNvhCe8","tgvxwgK","A2v5CW","zxjFCw9Zx2e","vgfwBgW","suPZweq","yuv4qxy","A0fjAxO","sLjWC1a","CMv0CNLdB3u","Evfhte8","ywDL","q0TTwfG","DhDVCMTdAge","we5dqw0","BenTuhm","q1rQCuO","t1bftG","BgvUz3rO","whrSuNC","y29Uy2f0","vuTuEuS","rxjYB3jdB2q","qw1VDw50","B1zIvKS","BMDLza","yw1L","s2LIzxu","ywrKq291BNq","r1z0Exy","rMvbuMS","rxjSr2G","y3vYC29Yx2y","z2v0sxrLBq","D0P6A3C","v1DUq04","BgLZDgvUtMu","tffuy1a","zNjVBNrPzxi","Cgf5Bg9Hza","txncsgS","qNDuBgW","ExDNr0q","ywDLu2HVDW","yMXVy2TLza","vfLgChq","y3vYDMfSDwu","x2nSzwfYvgK","u3bjru8","AwXK","Dw5RBM93BIa","t3bLBKv2zw4","De1HBMfNzxi","ExHsyxq","zNjHBwvuExa","y2LurLm","u3ndDei","vgHUrwe","v0H2uvC","zxjYtxnN","y3r4","AMPpyM4","B3jRzxjhBg8","DhjPBq","zNjVBuHHC2G","qNfXwKm","zxj2AwnL","EhbTwe0","tgLZDgvUzxi","yM5qq20","Dg9tDhjPBMC","B2fK","B25nzxnZywC","q1fQteq","B25pCgvU","sgvKBuq","svfXAgq","Ec1TC2CTy3u","C3nHz2vfDMu","s2HzwgK","rNPUC1O","zgLKvhK","B3jpBMXPBMu","BLrADeG","tLf4twS","BMrLEa","y29SBM8","CKvIvge","vKzrEwG","sxrmEuy","B2rJC0G","lcbOB3n0BMe","zuPRqxq","qu5nEK8","Eu1ACMu","r2LIsfm","zhLlELi","yu5uruO","B3LMtLe","C2XKsKq","EM1evee","uLDTBKu","CMvHzhLtDge","u01XCNe","zfDVCMTLCKC","B2nRzxrgywK","CMvHzfvjBNq","x2LZqNjVD3m","Bhm6ia","uxzAv1i","u1fssvq","z1zcDgG","y2XLyxi","EwP3sxa","ywrTCg4","vfHOwwW","EuPKAfi","BuPet1C","vwf2AMy","zNbMr0K","igfYCMf5yNu","D0TKDKC","nJuWmwL3EhnMvG","CeDMs3y","z2v0q3vYCMu","tNDtqw0","B3jL","Ae1RrK8","vvv4Bfa","Cxf4teG","sLDgrLi","Bxjpuu4","yNvOCwW","zvP3B0C","Ewjfv0m","mxW0Fdb8m3W","C2v0","BgvY","AMTQAe0","u1HhrNe","teXtwue","EMDHruK","BwvY","CLvUq2K","twLZC2LUzYa","rwT4rwS","C2v0q3vYC28","qKLpt0W","BMv4DcGPigm","zwHHu1i","pxv0zI04","DMvY","BurfuLe","B25SAw5L","qMvkvuW","z3zzAeK","DLnVzM4","vw5PBxbSzw0","mNWXFdn8mhW","CxPSENO","u3PhCgm","BfrPBwvVDxq","mtjku2zcv1a","qLzeDLe","DuP5v2W","B3jLtMfTzxm","qwPJBfm","Bhb3swq","y2XVC2u","x2LZv29YA2u","ELjTDuG","y29UBMvJDgK","x2nVBM5Ly3q","Aw50zwDLCIa","s0f6tMW","Ee1Tu3q","B3bLCNr5tMe","yNL0zu9MzNm","whrSzwi","r0zyBeq","Dhfstgu","CNnVCL9Uyw0","AxnFywnR","x2rLC3rYB3K","y29UBMvJDa","zxrMB28","ywjVCNq","z2vjBMzVu3K","sLfYDwO","ENPgvfK","rMPquM0","v1zywuW","uK5Hvxu","zg9Uzq","tKLzswy","z2Dpzfy","EKfoB3i","B3bLCNr5","AKfyDxy","senzugu","rwHyrK4","t05OEuq","AwXSihvZzsa","A2rnwNe","Cgf5Bg9Hzfq","B2zM","uhDWDu0","zxf1ywXZ","sKXMA1C","B3bLBG","x2fKzfDZtgK","Dgv4Dc9Qyxy","rLb3D2u","C2zKq3u","A2v5","BMvJDa","BeLwwuO","wwfou2O","wwHjqLy","ywnRtxnNswq","qLHLsLG","x3nLCuLK","r0vrBwS","zMX1C2HfEha","DNLgwee","AgvHzgvY","tKDFrvjst1i","yKXjru4","ywXSq3vYC28","x1fVu01HBMe","AgXLDgy","C2DPza","rvboCxu","swnmsw8","rMD0BuK","BNPYtvm","tKXpBwO","uMf5wLi","sMXvwfy","vxDNA3C","yuTgqK4","u2XLAKy","x3DZsw5ZDge","zhjhuKi","m3W1","BwLZzq","EurbDNu","A1vsrMK","Aw5N","wNvAwuK","Dunryuq","sKL5uKe","qwDOzNu","x194x21Zz18","qLrwBfe","sezvtKK","rwHiD0i","C0Xf","zxjFywnRx20","C3rYAw5N","wLLXAha","u2LdyLi","ufzXzxe","CKXYy1K","zNrUz0u","vgX6Cu0","swn3rLC","Dhr3Awq","Cg5tEhC","vvPiBvm","vvj6s0G","runfA1K","x2DLBMvYyxq","s1HYtKW","rhzQuKi","C0TiyKe","ug5ozvK","Bg9N","B25fCNjVCG","yw1Lu3bHy2u","mNW0Fdb8nxW","Cvbnwvy","x3jLy29UBMu","yMLUza","z2v0q3vYC28","Bgzsy1G","y3vYCMvUDeK","BMrWB2LUDca","uvbRugG","rNnVAwS","C3rLBMvYCW","D1LVvK8","vwzszg8","CfrVDeS","zM9Yy2u","tNnLrvC","y2XVC2uSihC","teLiEgu","zNrWExy","C3vIyxjYyxK","ExvusgG","y2XVC2veqG","tg5hvwm","Dg9cExrLC0W","ChzYqKu","BuPdEM0","tKT3wxi","vur5thy","t2PtvvG","wKjSEuq","x3bYB3rVy28","sMzwrNu","x3jLBw92zvC","BezSDxnO","tNrjqNK","y09Wzw4","y29UBMvJDeu","q3vZDg9Trxi","rvz0z0y","z2DAEu4","Ew1ttxa","BMCGzMfPBgu","DxvgsNC","zMLSzw5HBwu","C2vYDMLJzq","y2HHCKnVzgu","rfrnzuW","tKfusvzfx0u","zMzMzG","zcbLCNjVCI4","vK5AB2u","s1L1vwq","qMXfAhu","sufkBgu","uwzfzLu","D24GCMvHC28","x2HHBMrSzvi","rfvlA2e","z2v0","CKzQuNK","r0rqzvK","DLv4Bvm","DxfXDwW","nhWWFdu","DMvUDa","wffbC0S","DMfSDwu","v3jqChK","uNjAt3K","zMvY","BuzQtfy","zNjVBujPDhm","Bwf4uMv0CMK","zMPewui","z0zIBhG","y3vYC29Yx24","AxvUv0G","vgTTz3m","wwDVzvi","Dxrjza","Eenwrwe","CMfNzvn5BMm","su1pD1y","Ew1VDu0","zvzmAhq","Dhvdqve","zgvSzxrLrge","veXfseG","t0Xwtwy","u0XQwwW","B1Lxwge","Eun2uM4","zcWG","C3HcCw0","EeXXwxu","Aw9UvgLTzw8","BNvAtee","vev4r3O","zKzrqKK","rfnWAgG","uKz2zvy","C29YDa","ugnuuNi","q3zqBe4","zgvS","AhDuuvG","ihrPBwvZ","sNDUzuK","rxPys2S","ufHkAwe","zuLzvwG","y2HLy2TdDxi","BuLvEKC","CMvJzxzPzwq","BuDiwMy","AwXLx25HBwu","v1DUD2C","EMf1whK","sNzVuuS","uvDHsxG","rxPHz3e","AgfZ","ywnR","CgLUz1rPBwu","AgLNAa","x21PBMLoyxy","v0jtsLe","zw5HyMXLqxu","v1fWv2q","yKT3wxy","x2LZtwLUAvq","Aw5KzxHpzG","sxjTCMm","zxjFBxnNAwq","zgvMAw5Luhi","y3HHtg4","y29TCgXLDgu","wvPLvw8","qvvpy3u","yvnnzLG","zw1LBNq","uuTdzxq","vvDwzNe","vNPeDeK","x2LZsw5PDa","v0nJDKC","tMfTzq","x2LUAxrqCM8","yxKSig5LDhC","qKvztwu","zv9ZDwnJzxm","svLyz1m","yKDssfy","Ee9JwuC","uMvJB25Uzwm","B2zMBgLUzq","vxnuufy","uhbPq0S","qxLXz0S","sLjQBMO","rw1Jsee","zwnVBM5Ly3q","ywDLsgLKzq","D05iuuq","z0zLs3K","yLD1yum","rwz3s0C","B256zfe","yxHRs3y","CM92AwrLige","zeTXBeu","u2HHCMvKv28","u0fms3y","y3jLyxrLq2W","zvLeC20","x0rctMfTzq","zwHprge","BgLUzq","vKTSr0u","CMvUDevUzha","DKPQCNC","tvnpB3C","sxz2zM8","vNngueC","AxnmB25N","t2jMzLK","z29dqKq","r1ncCwC","x2HHBMrSzu8","zMLSDgvY","D3jPDgu","mhWZFdf8nhW","C3rYAw5NAwy","wezysgG","u2TPCcbWyxm","DeLUDgvYy2u","wgnmtuK","C3vJy2vZCW","CeHKBNq","qKnvs1y","CKX0quu","tePZt1e","AxnrB1nnzxm","r1rXsxK","C2DIzfm","zcWGDw5RBM8","BMCGB3iGyw4","yxrHlcbKyxq","rvL0v2W","rwPtAM8","AxnbCNjHEq","rvDprNe","qw9vy1K","ywrKrxzLBNq","CNPWrey","zw50tgLZDgu","ywPLAMC","De5pr1a","DMHUAxu","CgXLyxnLiha","vLfLww4","qvDxBe0","BMvY","nde3ntj1y3jJqxO","yxrLq291BNq","u0DAEwC","wxbxruK","v052uwW","zgTzrgO","x2rYB3bhBg8","DhDQC0O","zunyt2u","x3bYzwzPEa","rgjsrve","Ae1LC3nHz2u","ywXSB2nvBNm","uhz0u3u","wu16CMi","y3zmBMy","zMDAEKi","C2v0zgi","D0DVwee","u3bgEei","yxbWzw5Kq2G","y2XLyxjtDg8","uMfcrhG","uLPMwLK","DvfiBxi","q0zuBxO","qLjcq24","t095CvG","vhDewui","quXhtKq","BMjQyLK","y0zUyMm","qMD2CNK","y2f0y2G","AfHJueG","rxPQwva","x3nVy2TLDa","qK9ry0K","zw5JB2rLrNi","yxjuD3a","rKLmrv9ot1q","B3bLBIa","zMPbuhO","sLzHvum","yLjoDMC","suvtx0vsuK8","DeH4vwK","rxLcve0","x2n1CNnVCKy","zgf0yq","EeHICNq","zNjVBuj5Dgu","yNL0zuXLBMC","svPbCfK","qKHOzfG","CM92AwrLigi","BM55sKu","CNj1sMm","qxPpvgG","y2vZC0HHBMq","C0XPC3rLBMu","y29Kzq","AefJA01LC3m","tvvWtfy","sg5ru0i","ru90B2m","t3r2CK8","Cg93","ywnRpwzYB24","Bg93","DMvYrgO","ywDLrxzLBNq","zxH0zw5ZAw8","zen0wM0","DgvZDa","CK5oqwm","u213rfC","zK1Yzu4","zvnLyKO","z05VD2K","B2LUDfjLywm","uhPmv1e","z3vOD2m","Dgv4DfbHEwW","yMLUyxj5vhK","tNbAzuK","B3nLrxzLBNq","u25ZBxq","BwvZC2fNzv8","yKfIEeW","tw5nwLe","txn2v3i","EvjLy29UBMu","zMDpyNu","z2vY","zNzTBMG","DMfSDwvZ","v21lChO","B3vUDa","sfnVAu8","zv90Aw1LB3u","A3fVDva","verKEwK","rvjst1i","ihzHBgLKigq","B25TzxnZywC","zvniANm","DMvYC2LVBMm","v1LJDgG","vhPotgi","l3DZl3yY","sMrNqwy","y3ruAw1LB3u","Cu5uqLG","qxziDMC","Ef9MCM9UDgK","DxjS","v0PJAMu","EuHHq0i","CunKu3e","r3PbELy","vhPVCwC","BwfW","BKXPBMu","CM92AwrLihC","CxjcuKO","rgHdrhq","sgfRvNK","C3jJ","BLHKAeW","uuDgq00","x19LC01Vzhu","BeHHBMrSzxi","Euvrsge","q2jkq3m","EMz0B2O","uKTkrgC","zwXsy1O","BxHcruG","we5Ks1e","DxrVuMvJB24","x2rItMfTzq","CMvXDwLYzwq","uLjpuG","DeLyy0m","yxKSihrYEsa","CNnVCKzPBgu","yKLkENe","yKvZq3u","q25ms3y","q0Xpu0ve","C2jevwq","otG0mZHtB0zVu1a","qwjVCNrfCNi","DMvYC2LVBG","qNf3vwi","BwvKAwf0zwW","AgfZt3DUuhi","DffeDuK","D2LSBfjLy28","thbVveC","CM9YrxzLBNq","CMvJB25Uzwm","tNfXsMq","BNrLCG","rxPOyKe","s0Xyu1O","yNvMzMvY","Cw9Zx18","BhrPCgXLihq","Cgu6ia","B25VCgvU","r1nJBK4","Cg9PBNrdB24","DxPMyNm","re5zB1G","z0TYuKW","BMjHqKC","CgLUz0LUDgu","A1fJseW","q1Pvy0W","CgfNzwHPzgu","mta4mdH5wxjStha","s2vkz2W","z2v0qwXS","DfnxEuC","AxfvsMC","DhHNEMS","DeLK","ChjVDg9JB2W","CePdtMq","tw9KDwXL","DhjPzxm","ve5Auxm","CgLUz0XVC3m","yuDRz0m","zMzLCG","AM9PBG","DNLmCgm","y2HnyxHuCMK","Cfj2BhG","ywnRx2LK","BMCGDxjSoIa","Dw92s08","u0TJB20","r05etvK","Dvfjs00","D1bVueq","D1bNqu0","Ae9XwMm","Dev2zw50","CMvQzwn0","x3fVC0rc","uLjgy0O","B25dBg9Zzq","C1r6tuO","zgLZywjSzue","DxrMofDYAxq","CMnID0W","C3bSAwnL","DgHLBG","rvbICLO","CLDzAMu","tuvtu0fhrv8","vw1Ys1y","A1fvAKq","wg5dz0y","rg9qAwi","DgfIyxnL","y3jLyxrLtwu","zgfZD0C","t0nwsfm","ugPIvxO","rhbxD28","Cevhruy","Ec11C2uT","sezgyKW","CMzovfu","B3nLza","t2ngt0O","Ehrwzw0","DwHOweO","zgvJB2rLzey","ywzL","B3DlC2K","ywrKt25L","Aw1LCYbPBIa","yxGGCMv0CMK","v3HoD3e","y29UBMvJDfm","y1PHu1K","BMnVzgLUzW","rNbSquq","zw5XDwv1zq","Cg9PBNrbBMq","z3LvAxC","BKHzDvm","B0DXCue","sgPnrvq","AhH2yxi","tufyx1jfvfi","s2Lmv2G","Be5xz3y","DhzoCNi","ChrVCG","x29UrxjYB3i","yxnL","CMvWBgfJzq","nhWYFdD8nq","vNrRCwm","BMvLzf9Hy2S","yxjYyxLIDwy","x2jPBMfYEvq","zwrPyxrLBhK","ywnRx2nVzgu","z213EgK","lcbTyxGGCMu","rLvqD2u","z2v0s2v5","BMHrDuW","DxbNCMfKzw4","Bwv0Ag9K","zM9YrwfJAa","CNjVCK1LC3m","t3zHvve","te5KAwm","q09otKvdveK","DKTzrem","Ahf5uMS","ELDbAei","ExHLzLK","ywnOzwqSihC","CLHjDMC","quDss0e","CMTmDwu","sMPOAKG","vwz4Ahe","wwz2qvq","z2v0qwXSs2u","DgHHBIbSB2m","DxbKyxrLq3u","y3vYC29YlNm","s1zxBhq","CLb0zwO","x3jLywr5q2W","CMvHzhDYAxq","AMXcAxm","C2v0sxrLBq","q3vZDg9Tq2W","zw5JB2rPBMC","zgnls3C","ALftzMm","B3PHBLC","Cw5dz1e","tfnTwgy","yNLL","CIb0DhDjra","vNPqD1i","DLziqxa","EfzgsMW","D3m6lY8","zxbnuLG","rgLXuLa","A0LZuuu","x2XPC3rLBMu","rNjVBNrPzxi","x2vUzhbVAw4","CMvWBgfJzui","B2jQzwn0u3q","x29Uq2XVC2u","D0zoue8","tuvurLO","AffPvg0","tvzUC3C","EvP2vLu","CNnVCL92ywW","suXhCM4","Dg9cExrLC0i","EM5QCNO","r2XWsg8","CgfNzxnOB3C","y29UBMvJDca","wuTrwNm","sK94r2m","vNP0tum","wKTyAuy","DeDTsLi","DhP0y3C","Aw5JBhvKzxm","Dw5KzwzPBMu","zw50","q291BNq","nNWXFdj8m3W","suLkzuG","y1zeChC","Ahr0Ca","q25dquy","z3v3qKm","vwLuu3G","uxvLDwu","qLP3CKG","y2nQEwu","mdaWmdaWmda","tNPXswG","uwvYAfm","sM5ICfC","ELPktLm","CMvZB2X2zq","zw1PDa","sLvVAuK","D3jPDgvvAw4","DK53qvy","y3vYCMvUDeu","ve9vEMi","Bg9NsurozxC","qufIzwi","C2v0u3rVCMe","uwHoqM8","whbHC1y","z09Xu3O","x3DZ","r3PYwNu","zxq9DxrMltG","ufnLvNO","x2HHBMrSzva","jMPZy2fSBgi","ten0v0G","CMvZzxrfBMq","BvPSvvC","zgjXA2S","CYbHBhjLywq","ywXty29Wzq","x2nSzwfYugK","r29pvNO","CMHgv3q","CMfTugfYyw0","zwn0","AwDHDg9Yt24","yNL0zxm","y3DmAvi","tMTosgK","D0TNB2S","EuvQtgq","ChvZAa","CgLqvfa","y3zRB0m","wwjms3O","DhfeuwK","x29UtwvZC2e","yMfSu2nVCgu","B25ozxr3B3i","AuruuKO","x2n1CNnVCK0","vgLTr1y","ywnRDxbfBMq","Dw5ZAwDUzwq","ALD3y1y","rxnMwva","AejxveW","BgLTAxq","yvvtvwG","q29UzMLN","x2nYzwf0zvm","y3ffAfq","CMPztfC","x21LC3nHz2u","zw50zwqGDhK","yNbRy2e","vurHquK","v3zIwg4","DhLWzq","wLvkufK","CgLUz09Uy2u","x2LZtM9Kzq","thbTEM8","Aw9U","rxDJCvG","seHXzNq","u29pvNq","yuDNvgW","Bwf4tg9ZC0m","uenhAgi","mZmXmta4mhzXCND1vq","DNDeAwm","CMfTzq","DgLUzYbZzxi","swroB1y","mxWZ","D2fZq2XLyw4","u0jYuuW","x29UugfNzu4","CKLesxC","Dxv1uKm","uhjPBwfYEuS","A1bbv1m","EvjVzxa","tg9JAW","BgDuDMy","yxv0B21HDgK","EMfmDhe","A0zXrwu","vMn1Dgm","v2vPEgLUsLm","A0TPDgi","Bvberei","yxnZAwDU","vw5Oyw5KBgu","Ae9Wzw5fDMu","ywX3yxLZ","AfD4q1e","Aw9Ul2PZB24","C3rVCMu","ENfPr08","u3vkELu","yNfQq2O","v0nmrge","Aw5Lza","BwH0vfO","uMnys0y","zM1hv3u","DMLJzuLeig8","x2LZtwLUAvC","C2v0y3vYC28","sfLcrKe","EfD4BNC","A1n0yxr1C0m","CNzHBa","x2rPC2nVBM4","zvvYBa","EfDUDwi","BfbcD0G","mZa4nZiXmfjOChrtCq","sLnptLa","BMrJuva","Aw5PDcbrB1m","C3rVCcbPBw0","qKPxCuK","q1DmyKy","z1rPBwvVDxq","vgPJywi","veH0rhu","r0jWsNe","Ee5xBM8","uef1vwq","y3jLyxrLt3a","C3rHCNq","x2n1CNnVCK4","x3bHDgHlzxK","BwLUzW","AxnszwfKEq","u0nutKC","EuL1zeC","t1DUANC","Eejku0m","z3PgBNu","Efrurw52","q09oveLovuu","zLHKuhy","B2zMC2v0","Dg9mB3DLCKm","t0f3r3i","rujPELG","y1jdA08","u1Pfreu","wwLMD3i","zw5fDMvUDa","BMDuAw1LCG","mZu1oermBvfVBG","ywnOzwq","tKr1zvK","y2uGBM90igK","Ce9oy0y","x3nLBMrby2S","mdaWma","ihrPBwvVDxq","veXbsuy","yvDJAue","qxfZCfi","t2jQzwn0","su5tvefova","B2jztKi","AwXLtMfTzq","zfnLwgu","CYbPBNn0yw4","DfDTDwm","vfzyB2W","yw5ZzM9YBvq","ywrK","BwvZC2fNztO","x3vYBa","zxjYB3i","quPXBhG","suHMCKC","DgLTzw91Da","swXjuuy","BMfTzq","yuDHvuK","runkBum","zxjHDg9Y","EM1pthC","Bwzxt0G","y291BNq","zMzmAw5L","yxnJCMLWDa","Cu9tBLC","uLbKzuq","BMnLq2XVC2u","tNfhCvi","shHkB2e","vLLSzKS","v05AEMC","uhvnyw0","uuvfwKu","yvrqr3y","r1bRAM8","CNDKrfu","zxrxB3jRq2G","tgjgu1i","AxnAzxjV","u2HdB2C","vNn1zNu","ru15Be4","z2v0t3DUuhi","y3jLyxrLrxi","zMLUza","ALrjBfm","AxnrB1nby2S","zufJAW","t01rr3O","DffksMq","EhDqB1a","Aw5KzxGGB3u","ExfmDNC","zMLHEeK","yMDXzNe","Egf4BvK","B25LCNjVCG","BLvSC3O","zw5NDgG","CMfUzg9T","s1vqDMO","B0HbCwG","EhbbDMe","u3rYyxrLz3K","r3ztwfK","BwvZ","tvnMvxC","igzHAwWSig0","yMrFzgLK","B3jRig9MzMW","BNLsB1C","BKDTt2G","yMfSrxzLBNq","ysbTDxn0igi","zxjFAxnFywm","s3jPy3G","CLbzAeO","sNbVB1C","CMvHzg9UBhK","tLrHrwK","C2fNzq","uKLuB2u","DvvKAgy","zujyvMK","ywr2yw5Jzq","wxzytwO","yMfJA3vWigu","wNzwDeO","x2zVCM1HDeu","AgvHzgvYCW","zM5yuM0","CMLLC0nVDw4","Bxv4rwW","y3jLyxrLuMu","BMXHAw8","Ahbwwui","x3DHAxq","C0nsq0u","C0jf","rKTnDLi","CMvZDwX0","Eg1AsuG","DMfS","svnYtvO","vgfN","x2LUDgvYDMe","CgjICdi","sNvJCxm","zMXYzwS","ufnABKu","zxjYtM8","ChPqsNy","sfz0AgO","y29RAeC","y3vYC29Y","vvbNtg8","y3vZDg9Tshq","rgvKAwnHDgu","yw5WvgO","CLzHBhvLCW","CMvZzxrdB3u","zgvSzxrL","Dw50","ze5nDvy","u3bSr08","uhb2suy","Dur4Cxm","C2vYDMLJzs0","rK9gD2i","ANrgwgW","CNzHBfzHBhu","C1nzuhu","Au5LBeu","qw9hwMS","v0nmy3y","y1flsKy","AMvJDfn0B3i","AMTqDe0","Cgf5Bg9Hzeu","BMrWB2LUDfq","yNvMzMvYzwq","ywXYrvq","DxnLCKLW","qwDlz1u","t0P3zgG","igzPzwXKoIa","ihn1y2nLC3m","Axnby2TdBgu","zwn0v2K","y2HLy2Tszwe","swD3A2e","z29PBMCGyxC","z2vrDwv1zuW","A2v0ignVBNm","BxHKveS","v2TVAxm","igXHCMDLCIa","Ahr0Chm6","D3vfugu","C2vYDMvYvgK","EgT4DNm","DhjWwgS","icSG","Aw5L","DgLLCKPtt04","A3rhugS","B25szwnLAxy","AgfUz2u","ihzHBgLKihm","sxH5rKq","BLPtqLi","z0PkrK8","r1DkBMS","zNvUy3rPB24","Avz1zNm","yLrVAu8","ihjLy29UBMu","id4G","yK5ZCfG","D2vI","r1rmAui","EMXUr3y","A3nICNC","C3bSAxq","odq4BLfkz1bI","zNjVBu51Bwi","Dwzrrvy","AerIrKK","vxbKyxrLq28","AxjLza","EfnZsva","BgLUzw5V","x2rPC3bHDgm","x2LUAxq","y0XsuNy","rvPHCuW","Ew1HAum","zu1fCxK","BNrbBMrvCgq","rKjQu28","DNvKD08","BNruCMLLC0m","x3bPBMC","vvfoseO","C2XPy2u","BM93","DLLky0m","C0nVDw50zxi","C29Tzq","txbAwei","tevjAKi","t1bftL9fuLi","CfDUAvO","D2PQtKq","BxnN","rxzLBNq","runhEKG","z2vtEw5J","uwn1q2G","B21yCwG","zxjFDhrS","B3v0sw50zxi","v2zVqMu","s05oDgm","zw5KCg9PBNq","qLrvthy","Bu9qC0q","C1PcDva","vgLTzw91Da","BLfHrK4","B2nRzxrtDwm","BwrIvLK","yw5Hz2vY","CxLfqvG","yvbryuW","mZy3mZjRtwXdvLe","yxv0BW","thfmtfK","rMLYD1q","DcbVzIbYyw4","u2zptKi","s2fSANG","vKDtr3a","BhbKsLy","x3bPBMDmB3m","Dg9oDw1Izxi","BwPrEey","mti1mwrUvfj0ua","zu5gt1m","x2rLyNvN","Dg9Y","BwvZC2fNzq","Au5MB0m","Dgv4Dc9WBge","B25tDgfYDfi","Bg9IywXty28","y3bqqLm","x29UvgLTzw8","DhjHBNnHy3q","zgDyEMW","wKHmELe","s2Pxwha","zxmGCMvHy2G","A09ms2u","BvLcuMi","AeLdBgy","ywWGy3vYC28","CgLUz19VBMm","sMDzr3u","Dg9cExrLCW","CMvTB3zLrxy","uMXeugC","yLvMuMS","ChjVDg90Exa","BMnlqNi","q2Ddz1K","zgrjrcWGzgu","tNzSruy","wNr4u1e","DxrXCfG","yxbWBgLJyxq","uxn5yNa","x29Ut3bLBG","CgfYC2u","quXm","z2u6ia","Dg9iyxnO","BerfCMm","BuvbqvO","ENnTsuK","Chv0","B25tDg9Wsw0","rLfIswW","AgvKtwf4uMu","tvnzyLe","vg1lzLi","wu1WqLa","y29UDgLUDwu","EurHqMO","C2vUza","x2LUAxrhBg8","u09IuuW","uejcwLi","q0Xpu0LorW","Egzbrwi","zwvKzwq","v2vIu29JA2u","vKPOthC","A3POshy","r0TZq2C","q29Kzq","uMvHzcbWyxm"];return nr=function(){return n},nr()}(function(n,e){let s=R,o=n();for(;;)try{if(-parseInt(s(783))/1*(parseInt(s(290))/2)+parseInt(s(1158))/3*(-parseInt(s(1355))/4)+-parseInt(s(1122))/5+parseInt(s(1507))/6*(parseInt(s(813))/7)+-parseInt(s(631))/8*(parseInt(s(1418))/9)+parseInt(s(1073))/10+-parseInt(s(250))/11*(-parseInt(s(1406))/12)===e)break;o.push(o.shift())}catch{o.push(o.shift())}})(nr,421504);var Zu=Object[P(542)+P(325)],ef=Object[P(1213)+P(304)+P(1236)],Xo=(n,e)=>function(){return n&&(e=(0,n[ef(n)[0]])(n=0)),e},tf=(n,e)=>{let s=P,o={AUOcu:function(d,u,f,h){return d(u,f,h)}};for(var c in e)o[s(546)](Zu,n,c,{get:e[c],enumerable:!0})};function nf(){return Wo||(Wo=[IDBDatabase,IDBObjectStore,IDBIndex,IDBCursor,IDBTransaction])}function rf(){let n=P;return Jo||(Jo=[IDBCursor[n(1444)+"e"][n(1255)],IDBCursor[n(1444)+"e"][n(1468)],IDBCursor[n(1444)+"e"]["continue"+n(1084)+"ey"]])}function sf(n){let e=P,s={BEYMe:"success",XFXHh:e(1181),AoGZk:function(c,d){return c(d)},Tjcab:function(c){return c()},lIVYJ:function(c,d){return c(d)}},o=new Promise((c,d)=>{let u=e,f={wJzkw:function(b,E){return s[R(344)](b,E)},RIToe:function(b){return s[R(1130)](b)}},h=()=>{let b=R;n[b(1441)+b(623)+b(630)](s[b(557)],p),n[b(1441)+b(623)+b(630)](s.XFXHh,w)},p=()=>{let b=R;f[b(1622)](c,f[b(1622)](Ge,n[b(1271)])),f[b(1252)](h)},w=()=>{let b=R;s[b(1304)](d,n[b(1181)]),s[b(1130)](h)};n[u(621)+u(196)](s[u(557)],p),n[u(621)+u(196)](s[u(601)],w)});return o[e(851)](c=>{let d=e;c instanceof IDBCursor&&fi[d(264)](c,n)})[e(664)](()=>{}),ir[e(264)](o,n),o}function of(n){let e=P,s={pWniZ:"complete",kzhHv:e(314),ObffY:function(c){return c()},aqRSQ:e(1607),IlIQF:e(611),EkxEk:function(c,d){return c(d)},zgaEI:e(784)+"or",LbFSR:"error"};if(rr[e(529)](n))return;let o=new Promise((c,d)=>{let u=e,f=()=>{let w=R;n["removeEv"+w(623)+w(630)](s[w(1383)],h),n["removeEv"+w(623)+"ner"]("error",p),n[w(1441)+w(623)+w(630)](s[w(1479)],p)},h=()=>{let w=R;s[w(593)](c),s[w(593)](f)},p=()=>{let w=R;if(s.aqRSQ===s[w(1185)])return new _0x112018(b=>{let E=w;_0x317e41(b,this[E(1501)+E(1301)+"e"](_0x1db121))});s[w(273)](d,n.error||new DOMException(s[w(269)],s[w(269)])),f()};n[u(621)+"Listener"](u(544),h),n[u(621)+u(196)](s[u(1208)],p),n["addEvent"+u(196)](s.kzhHv,p)});rr.set(n,o)}function af(n){sr={PcTRr:function(o,c){return o(c)}}[P(510)](n,sr)}function cf(n){let e=P,s={yQGLO:function(o,c){return o(c)},pnSxw:function(o,c){return o===c},xxbDY:function(o,c){return o in c},CnZOH:"objectStoreNames"};return s[e(396)](n,IDBDatabase[e(1444)+"e"]["transact"+e(1066)])&&!s.xxbDY(s.CnZOH,IDBTransaction.prototype)?function(o,...c){let d=e,u=n[d(1518)](s[d(1598)](dn,this),o,...c);return ui[d(264)](u,o[d(509)]?o.sort():[o]),Ge(u)}:rf().includes(n)?function(...o){let c=e;return n.apply(dn(this),o),Ge(fi[c(466)](this))}:function(...o){let c=e;return Ge(n.apply(s[c(1598)](dn,this),o))}}function R(n,e){n=n-187;let s=nr(),o=s[n];if(R.qVuSHx===void 0){var c=function(h){let p="abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789+/=",w="",b="";for(let E=0,I,A,k=0;A=h.charAt(k++);~A&&(I=E%4?I*64+A:A,E++%4)?w+=String.fromCharCode(255&I>>(-2*E&6)):0)A=p.indexOf(A);for(let E=0,I=w.length;E<I;E++)b+="%"+("00"+w.charCodeAt(E).toString(16)).slice(-2);return decodeURIComponent(b)};R.hVORPS=c,R.EICPpe={},R.qVuSHx=!0}let d=s[0],u=n+d,f=R.EICPpe[u];return f?o=f:(o=R.hVORPS(o),R.EICPpe[u]=o),o}function df(n){let e=P,s={DTMeL:function(o,c){return o===c},fiaxI:"function",Bgvry:function(o,c){return o(c)},CnLKv:function(o,c,d){return o(c,d)},DhCDt:function(o){return o()}};return s[e(454)](typeof n,s[e(1224)])?cf(n):(n instanceof IDBTransaction&&s[e(663)](of,n),s[e(780)](Qo,n,s[e(757)](nf))?new Proxy(n,sr):n)}function Ge(n){let e=P,s={vudwO:function(c,d){return c!==d}};if(n instanceof IDBRequest)return sf(n);if(er[e(529)](n))return er[e(466)](n);let o=df(n);return s[e(1371)](o,n)&&(er.set(n,o),ir.set(o,n)),o}var Qo,Wo,Jo,fi,rr,ui,er,ir,sr,dn,$o=Xo({"node_modules/idb/build/wrap-idb-value.js"(){let n=P,e={KdJlW:"close",AqspR:n(738)+n(1338),jAXuv:function(s,o){return s===o},IdNoV:n(959)+"oreNames",AzOTh:n(1102),sSYPu:n(915),iunWH:n(321),oRRIn:function(s,o){return s===o},nuZLA:function(s,o){return s in o}};Qo=(s,o)=>o[n(1379)](c=>s instanceof c),fi=new WeakMap,rr=new WeakMap,ui=new WeakMap,er=new WeakMap,ir=new WeakMap,sr={get(s,o,c){let d=n;if(s instanceof IDBTransaction){if(o==="done")return rr[d(466)](s);if(e[d(326)](o,e[d(1077)]))return s[d(959)+d(293)]||ui[d(466)](s);if(e[d(326)](o,e[d(689)])){if(e.jAXuv(e[d(1302)],e[d(1302)]))return c[d(959)+d(293)][1]?void 0:c[d(959)+d(254)](c[d(959)+d(293)][0]);_0x1c19f6&&_0x2d2445[d(621)+"Listener"](e.KdJlW,()=>_0x41d41c()),_0x4168ef&&_0x433d58[d(621)+d(196)](e[d(1168)],()=>_0x2fe36a())}}return Ge(s[o])},set(s,o,c){return s[o]=c,!0},has(s,o){let c=n;return s instanceof IDBTransaction&&(e[c(326)](o,e[c(484)])||e.oRRIn(o,e[c(689)]))?!0:e[c(504)](o,s)}},dn=s=>ir.get(s)}}),Zo={};tf(Zo,{deleteDB:()=>uf,openDB:()=>xf,unwrap:()=>dn,wrap:()=>Ge});function xf(n,e,{blocked:s,upgrade:o,blocking:c,terminated:d}={}){let u=P,f={rPYhJ:function(w,b,E,I,A){return w(b,E,I,A)},bIJzq:function(w,b){return w(b)},kIenN:function(w,b){return w(b)},HHqft:u(296),xEkAY:u(738)+u(1338),lMXTu:u(911)+u(1476),wPoPD:"blocked"},h=indexedDB[u(337)](n,e),p=f[u(1569)](Ge,h);return o&&h[u(621)+u(196)](f[u(1544)],w=>{let b=u;f[b(1247)](o,f[b(778)](Ge,h[b(1271)]),w[b(1557)+"on"],w.newVersion,f[b(1569)](Ge,h[b(1429)+b(1066)]))}),s&&h[u(621)+u(196)](f[u(838)],()=>s()),p[u(851)](w=>{let b=u;d&&w[b(621)+b(196)](f[b(1068)],()=>d()),c&&w[b(621)+"Listener"](f.xEkAY,()=>c())})[u(664)](()=>{}),p}function uf(n,{blocked:e}={}){let s=P,o={fpfGI:s(1632)},c=indexedDB[s(494)+"tabase"](n);return e&&c[s(621)+s(196)](o[s(247)],()=>e()),Ge(c)[s(851)](()=>{})}function Vo(n,e){let s=P,o={gJJFO:function(h,p){return h!==p},cvLnf:s(726),hDbFI:"qyuNC",SuJzU:function(h,p){return h instanceof p},vYJcC:function(h,p){return h in p},eYDsm:function(h,p){return h===p},YpWEI:s(387),oFtXT:function(h,p){return h!==p}};if(!(o[s(1104)](n,IDBDatabase)&&!o[s(1377)](e,n)&&o[s(582)](typeof e,o[s(634)])))return;if(tr[s(466)](e))return tr[s(466)](e);let c=e[s(898)](/FromIndex$/,""),d=o[s(1559)](e,c),u=ta[s(979)](c);if(!o.vYJcC(c,(d?IDBIndex:IDBObjectStore)[s(1444)+"e"])||!(u||ea.includes(c)))return;let f=async function(h,...p){let w=s,b={cVDpw:function(E,I){return E||I}};if(o[w(1342)](o[w(646)],o[w(1358)])){let E=this[w(1429)+w(1066)](h,u?w(936)+"e":w(1249)),I=E[w(1102)];return d&&(I=I.index(p.shift())),(await Promise.all([I[c](...p),u&&E.done]))[0]}else{let E=this[w(843)][w(1621)](this[w(640)]),I=_0x11c2b8[w(1454)](b[w(985)](E,"{}"));return I[_0x3eda68]=void 0,this[w(843)][w(938)](this._prefix,_0xa6b953[w(600)+"y"](I))}};return tr.set(e,f),f}var ea,ta,tr,ff=Xo({"node_modules/idb/build/index.js"(){let n=P,e={VsFPG:n(408)+n(1078),XQAsK:n(466),GzAzV:n(909),uDjIh:"getAllKeys",pfOJG:n(1192),Vcutc:function(c){return c()},IBemI:function(c,d){return c(d)},Yifwr:function(c){return c()},nbjbY:n(1461),WvbXn:n(1178),Uavjf:n(1292),mPDDB:n(240)},s=e[n(591)][n(1354)]("|"),o=0;for(;;){switch(s[o++]){case"0":ea=[e[n(473)],e[n(751)],n(815),e.uDjIh,e.pfOJG];continue;case"1":tr=new Map;continue;case"2":e[n(1092)]($o);continue;case"3":e.IBemI(af,c=>({...c,get:(d,u,f)=>Vo(d,u)||c.get(d,u,f),has:(d,u)=>!!Vo(d,u)||c.has(d,u)}));continue;case"4":e[n(1155)]($o);continue;case"5":ta=[e[n(661)],e[n(1060)],e[n(246)],e[n(1095)]];continue}break}}}),lf={idb:function(n){let e=P;n.exports=Promise[e(998)]()[e(851)](()=>(ff(),Zo)).then(function(s){return s})}},Yo={};function qe(n){let e=P,s={lCmPs:function(d,u){return d!==u}};var o=Yo[n];if(s[e(1603)](void 0,o))return o[e(1578)];var c=Yo[n]={exports:{}};return lf[n](c,c[e(1578)],qe),c[e(1578)]}qe.d=(n,e)=>{let s=R;for(var o in e)qe.o(e,o)&&!qe.o(n,o)&&Object["definePr"+s(325)](n,o,{enumerable:!0,get:e[o]})},(()=>{let n=P;qe.o=(e,s)=>Object[n(1444)+"e"][n(788)+n(325)][n(1518)](e,s)})(),(()=>{let n=P,e={DNYoX:function(s,o){return s!=o},doXZH:n(980)+"d",hpVYB:n(822),UoRqD:n(762)+"le"};qe.r=s=>{let o=n;e[o(806)](e.doXZH,typeof Symbol)&&Symbol["toString"+o(1275)]&&Object[o(542)+o(325)](s,Symbol[o(198)+o(1275)],{value:e[o(1266)]}),Object[o(542)+o(325)](s,e.UoRqD,{value:!0})}})();var te={};(()=>{let n=P,e={AJqlx:function(i,t){return i+t},wFNPO:function(i,t){return i+t},HYBFA:function(i,t){return i+t},eJkAt:function(i,t){return i*t},TXhYl:function(i,t){return i*t},KYuUd:n(762)+"le",verDj:function(i,t){return i===t},uovKO:"NWnjy",WJcje:function(i,t){return i(t)},QEEZE:function(i,t,r){return i(t,r)},URzKH:function(i,t){return i+t},bKwYv:function(i,t){return i(t)},ymaiC:function(i,t,r){return i(t,r)},fgObu:function(i,t){return i(t)},QKCet:n(1164),aUSUh:function(i,t){return i(t)},KNNtc:n(993)+n(993)+n(993)+n(993),WNvQl:function(i,t){return i>t},IQqhd:function(i,t){return i>t},HnQSB:function(i,t){return i!==t},SpIEO:function(i,t){return i-t},SALKv:function(i,t){return i<t},HSoiO:function(i,t){return i<t},tvNrr:"fPfmb",jQvRj:function(i,t){return i<t},ZKXiF:function(i,t){return i-t},BlEhu:function(i,t){return i!==t},nQaFN:function(i,t,r){return i(t,r)},uqqul:function(i,t){return i||t},DbREQ:n(836),rIDIw:function(i,t){return i(t)},wKgok:function(i,t,r){return i(t,r)},hletf:function(i,t){return i(t)},NQxMk:function(i,t){return i&t},nUlsz:function(i,t){return i===t},RBaGJ:n(272)+"required"+n(1316)+n(342),cQEYZ:"Missing "+n(773)+n(1316)+n(474),sgbdS:function(i){return i()},bqjCj:function(i,t){return i(t)},Vsufu:function(i){return i()},nzrMS:function(i,t){return i>=t},QfEfU:function(i,t){return i===t},XpasV:function(i,t){return i!==t},Vtkqc:function(i,t){return i!==t},VNZoe:function(i,t){return i!==t},wjIuq:n(1329),DpWwo:function(i){return i()},rXIvg:function(i,t,r){return i(t,r)},xaxmY:function(i,t,r){return i(t,r)},uSkpq:function(i,t){return i!==t},VjqwZ:n(872),oYSXz:"WEApq",BTULv:function(i,t,r){return i(t,r)},QcuCh:function(i,t,r){return i(t,r)},GMmCB:function(i,t,r){return i(t,r)},ZBlyD:function(i,t){return i!==t},nhQuL:function(i,t,r){return i(t,r)},gvYhI:function(i,t){return i(t)},hWxCQ:function(i,t){return i!==t},RaBDx:n(1258),ggZyN:n(1254),rkLue:n(639),dyKzR:function(i,t){return i(t)},LIHxe:function(i,t){return i>>>t},uUdhf:function(i,t,r){return i(t,r)},nZSBR:function(i,t){return i(t)},PTKHW:function(i,t){return i(t)},EBizX:function(i,t){return i(t)},EzjYP:function(i,t,r){return i(t,r)},GVtyv:function(i,t){return i(t)},BqwUb:function(i,t){return i(t)},YZeUo:function(i,t,r){return i(t,r)},eSebJ:function(i,t,r){return i(t,r)},GjESZ:function(i,t,r){return i(t,r)},RYBoA:function(i,t){return i(t)},QgeFB:function(i,t){return i===t},gkyrt:n(272)+n(773)+n(1316)+"SeqID",BTVlQ:function(i,t){return i===t},LeWXi:n(272)+"required field: LogID",nZMTa:n(272)+n(773)+n(1316)+n(452),qrJlq:n(272)+"required"+n(1316)+n(912),tuCAQ:function(i,t){return i+t},vUxmS:function(i,t,r){return i(t,r)},GFXlD:function(i,t){return i(t)},MsBHk:function(i,t){return i+t},gMKwb:n(285)+n(1057)+n(801),YgoeR:function(i,t){return i>>t},tyMaX:function(i,t){return i>=t},RayZR:n(602)+n(1511),NvlEF:function(i,t,r){return i(t,r)},SBrQL:function(i,t,r){return i(t,r)},mGHZf:function(i,t){return i!==t},ZYqhp:function(i,t){return i<t},oeLup:function(i,t){return i(t)},KiLWh:function(i,t){return i&t},omXqh:function(i,t){return i+t},BVDvQ:n(527),ybEWC:function(i,t){return i|t},rwdDU:function(i,t){return i&t},tQJJd:function(i,t){return i==t},yqLvw:function(i,t){return i&t},NQWNK:function(i,t){return i>=t},AyqgK:function(i,t){return i+t},dyJIx:n(568),GlpHo:n(745),ErlGh:function(i,t){return i+t},yrwMJ:function(i,t){return i!==t},piPTP:function(i,t){return i|t},drGRB:function(i,t){return i<<t},XcLMI:function(i,t){return i&t},ZUJPY:function(i,t){return i<=t},vVHAp:function(i,t){return i(t)},wGoXA:function(i,t){return i&t},gFeKy:function(i,t){return i+t},uuuRC:function(i,t){return i+t},IcwFW:function(i,t){return i+t},uJyWl:function(i,t){return i+t},JwneI:function(i,t){return i|t},RcXKF:function(i,t){return i<<t},iVufs:function(i,t){return i<<t},Ezagq:function(i,t){return i===t},yMZre:n(361),ALGND:n(1526),BlPdT:function(i,t){return i|t},sKHbA:function(i,t){return i<<t},EVtgF:function(i,t){return i&t},TmKfR:function(i,t){return i<t},huqXV:function(i,t){return i>t},zaLtq:function(i,t,r){return i(t,r)},KAzNl:function(i,t){return i>t},FLTsO:n(1482)+"t limit",GSBqg:n(883),tSWyG:function(i,t){return i>=t},rWYje:function(i,t){return i+t},YXCdM:function(i,t){return i<<t},jTIlS:function(i,t){return i<t},YhIBV:function(i,t,r){return i(t,r)},FOFwb:function(i,t){return i>=t},CJgrn:function(i,t){return i<=t},BvQZl:function(i,t){return i+t},LCtWH:function(i,t){return i<<t},uaiyP:n(888),Ivvfo:function(i,t){return i<t},AmzVM:function(i,t){return i|t},dSeXe:function(i,t){return i|t},TwDYB:function(i,t){return i&t},hQiTm:function(i,t){return i>>t},Igwka:function(i,t){return i>>t},nGmOh:function(i,t){return i|t},xtVem:function(i,t){return i&t},fnXRm:function(i,t){return i|t},admpn:function(i,t){return i&t},IxyFD:function(i,t){return i!==t},lIvbx:"yVuan",rLrcY:n(1543),sZBuP:function(i,t){return i<t},Qsybp:function(i,t){return i&t},VztMC:function(i,t){return i&t},dNMuV:function(i,t,r){return i(t,r)},zzFTY:function(i,t){return i<<t},zqiGO:function(i,t){return i<<t},JLfkW:n(518),RkHTX:n(201),rfNTU:function(i,t){return i(t)},dCtZm:function(i,t){return i(t)},IMOwV:function(i,t){return i&t},IVwxi:function(i,t){return i<<t},cZaSY:function(i,t){return i&t},nExOn:function(i,t){return i&t},nXdhL:function(i,t){return i(t)},mZlUW:function(i,t){return i(t)},VzPwR:function(i,t){return i&t},yIudG:function(i,t){return i&t},HjdMc:function(i,t){return i(t)},nyRoW:function(i,t){return i<<t},BwTll:function(i,t){return i&t},zauXy:function(i,t){return i(t)},hxvar:function(i,t){return i&t},QerhS:n(1284),RlDPg:function(i,t){return i(t)},Dytda:function(i,t){return i&t},didTy:function(i,t){return i<<t},fmGWu:function(i,t){return i>>>t},cwLiR:function(i,t){return i>>>t},UQNHJ:function(i,t){return i<<t},EfwKG:function(i,t){return i>>>t},xLqYu:function(i,t){return i<t},qnCgQ:function(i,t,r){return i(t,r)},qzlzz:function(i,t){return i&t},sfdCu:function(i,t){return i>>>t},WQpWd:function(i,t){return i+t},aGaUI:function(i,t){return i+t},RFveV:function(i,t){return i+t},bAbxL:function(i,t){return i!==t},gOqSz:function(i,t){return i&t},Tzoqg:function(i,t){return i+t},QEIMI:function(i,t){return i&t},Lpmzo:function(i,t){return i|t},fFQBI:function(i,t){return i!==t},mhtTZ:function(i,t){return i|t},cxaLn:function(i,t){return i>>>t},VJhLw:function(i,t){return i|t},lwQZk:function(i,t){return i&t},TtgyM:function(i,t){return i!==t},OOyqX:function(i,t){return i&t},SmwDW:function(i,t,r){return i(t,r)},kAIiz:function(i,t){return i(t)},CKmXX:function(i,t){return i|t},DUKka:"undefined",tWmuc:n(1594),yZrbe:n(275),hqyRk:function(i,t){return i===t},pJCNd:n(1632),vJjrw:n(374),HzSJV:function(i,t){return i|t},rzpDF:function(i,t){return i|t},PSZnE:function(i,t){return i<<t},yUWzv:function(i,t){return i<<t},CvPlN:function(i,t){return i|t},Ufxhq:function(i,t){return i|t},IAJle:function(i,t){return i<<t},KUPvj:function(i,t){return i|t},jtFXl:function(i,t){return i|t},obYmM:function(i,t){return i<<t},uCQaD:function(i,t){return i|t},HdShR:function(i,t){return i<<t},BCUKV:function(i,t){return i===t},xSjgM:function(i,t){return i<<t},JihaT:function(i,t){return i<<t},iPsZQ:function(i,t){return i&t},xpAva:function(i,t){return i>>>t},obYNB:function(i,t){return i>>>t},VYlfK:function(i,t){return i&t},yDaBj:function(i,t){return i<=t},cQKJF:function(i,t){return i%t},YfvAT:function(i,t){return i/t},wPgAM:function(i,t){return i>>>t},Kaljx:function(i,t){return i>>>t},VFQyh:function(i,t){return i+t},yjwIp:function(i,t){return i===t},kdMZq:function(i,t){return i>>>t},iDTRJ:function(i,t){return i&t},ECEkY:function(i,t){return i>>>t},KcDVz:function(i,t){return i&t},uQHmr:function(i,t){return i+t},Snsmt:function(i,t){return i>>>t},LAOPV:function(i,t){return i+t},TExGz:function(i,t){return i+t},gKrRL:function(i,t){return i!==t},bEsCu:function(i,t){return i===t},AWWlM:function(i,t){return i===t},pvrBE:n(1183),xWnub:function(i,t){return i>>>t},zRmuH:function(i,t){return i&t},mDBKM:function(i,t){return i>>>t},EWOFq:function(i,t){return i&t},FjbQm:function(i,t){return i>>>t},ECGzH:function(i,t){return i>>>t},iFNfp:function(i,t){return i&t},gNowi:function(i,t){return i&t},OVmJN:function(i,t){return i&t},ndcQP:function(i,t){return i>>>t},JUoiI:function(i,t){return i>>>t},cRCkO:n(455)+n(774),zWAhB:n(917)+n(354),VGSGp:n(891)+n(676)+"R",LJsOQ:"OPEN_ERROR",anpTj:n(983)+n(471),oVbVK:n(1463),SfONB:function(i,t){return i(t)},jyZVI:function(i,t){return i&t},aWciA:function(i,t){return i(t)},aSMfX:n(840),ELMYZ:function(i,t){return i>=t},Wvrfy:function(i,t){return i===t},wOTLn:function(i,t){return i==t},jkjhM:function(i,t){return i>t},EhXFN:function(i,t){return i!==t},TvNgY:n(650),LLSYA:n(1181),vUpZf:function(i,t){return i instanceof t},TaVll:function(i,t){return i+t},CZUcL:n(1097)+n(457),NLOmj:function(i,t){return i+t},kURFi:function(i,t){return i===t},gzFnu:function(i,t){return i<t},pEGEF:function(i,t,r){return i(t,r)},vyLpc:"close",qNTBX:function(i,t){return i==t},rUnCi:n(1048),dQmXc:n(996),jZNPp:function(i,t,r){return i(t,r)},hXcPH:n(337),GzrZu:n(1422),cLRRv:function(i,t,r){return i(t,r)},hJKFZ:function(i,t,r){return i(t,r)},muxEl:function(i,t){return i!==t},FUPwe:"AntGn",lpdJV:function(i,t){return i+t},rjYLW:"VlBnw",JVaUC:function(i,t,r){return i(t,r)},WNZzg:n(766),axkKv:function(i,t){return i!=t},NqqJd:"egXcp",JRpsP:function(i,t){return i||t},sVmis:function(i,t){return i!=t},dkYDj:"ZXvHG",iqUJg:n(276)+"alled mu"+n(800)+n(877)+"process",ymSMp:function(i,t){return i+t},uzUaB:function(i,t){return i<t},kOLKe:function(i,t){return i&t},MUpLV:function(i,t){return i===t},bPQGR:n(501),WAGZA:"STRWt",YMzrb:function(i,t){return i<t},JdgAf:function(i,t){return i|t},mEAAZ:function(i,t){return i<<t},tIXcC:function(i,t){return i&t},uQIKM:function(i,t){return i&t},lLKrY:function(i,t){return i-t},NwNrR:function(i,t){return i&t},fjAPz:function(i,t){return i&t},AVuiq:function(i,t){return i+t},NpZeI:function(i,t){return i>>t},TimGV:function(i,t){return i+t},KhYXi:function(i,t){return i&t},QPkPh:"ping_onc"+n(731)+"t",lfRcX:function(i,t){return i<t},WCLDa:function(i,t){return i<t},PVqeq:function(i,t){return i&t},Cwldb:function(i,t){return i&t},xoQjm:function(i,t){return i+t},GoOVz:n(1493)+n(372),EMylN:function(i,t){return i+t},eMEqy:function(i,t){return i|t},UPgLo:function(i,t){return i|t},kDTHi:function(i,t){return i&t},AgKgU:function(i,t){return i&t},xBJSC:function(i,t){return i>>t},vNwAV:function(i,t){return i&t},BqqZC:n(1510),aKFBN:function(i,t){return i|t},LNdic:function(i,t){return i>>t},OjSUX:function(i,t,r){return i(t,r)},nnyJE:function(i,t){return i!==t},okkTa:"ouYRo",vhniu:n(387),JfVFu:n(1451)+n(1101),EhHwB:n(1332),ggOdV:function(i,t){return i==t},PuMam:n(1424)+"in;chars"+n(1013),uhrJU:"ppe",ccjye:n(339)+n(1194),HxJoa:function(i,t){return i+t},mOPsD:n(986),dbqkk:n(1016)+n(699)+n(1335)+"P",ywgGD:function(i,t){return i===t},WWnwg:n(409),xwPoP:function(i,t){return i(t)},YvXMj:n(671)+"_EXIST",zEatF:function(i,t){return i!==t},aNTEJ:"YNJfB",CTjqJ:n(1602),PnNeY:"idb",ShCog:function(i,t){return i(t)},BHhdX:n(231),BOQcI:n(1445),mdbVY:function(i,t){return i!==t},wKdvG:"kQTGp",kqouP:n(962),yEjLd:"SsCtB",yCvRn:function(i,t){return i<t},mJDOW:function(i,t,r,a){return i(t,r,a)},Docuq:n(1225),lDErc:function(i,t){return i||t},jlBis:function(i,t){return i||t},QGFCM:n(1102),ectWi:function(i,t){return i(t)},Xtleb:n(402),iNfoC:n(1325),VzDtI:n(256),pmsJU:n(277),TDdyi:function(i,t){return i||t},PtkWq:function(i,t){return i!=t},dvTvH:n(1125)+"DB failed",CnCAF:function(i,t,r){return i(t,r)},FKMvR:function(i,t){return i!==t},xSsIP:n(482),aCwsr:"qos",ohmdq:"message_id",JCEPz:function(i,t){return i(t)},rFjRy:function(i,t){return i!==t},JIyRA:"jkNSl",nTZtH:function(i,t){return i!==t},aPQaL:"tqDQi",UiTSx:function(i,t){return i&t},onzdQ:n(1352),zbbdf:n(746)+n(1591)+"ck",JgYGu:n(746)+n(1245)+"k",yRoep:function(i,t,r){return i(t,r)},Kricx:n(901),bGRHV:n(310),cQZJU:n(905),SiCbR:"hQaoG",guhwc:"kUgOs",PBBZR:"received",NTaEi:function(i){return i()},RrZOy:function(i,t){return i instanceof t},QvZWR:n(1451)+n(1101)+";charset"+n(278),ZHLzQ:"none_none",VXSNQ:n(1534),ajejg:function(i,t,r,a){return i(t,r,a)},nHYuS:function(i){return i()},kgipt:function(i,t){return i(t)},Jtnxt:function(i,t){return i&t},lPBwH:function(i,t){return i|t},CYQIz:function(i,t){return i||t},EPbrZ:function(i,t){return i>>>t},vwDic:function(i,t){return i(t)},kQUjD:function(i,t){return i+t},odcsH:function(i,t){return i+t},qOSnW:n(1222)+n(1410)+n(1456),ymouM:n(1322)+n(776)+n(793)+n(1076)+n(279),SGZyg:function(i,t){return i===t},SZEDE:n(1582),XNdKQ:n(301)+"too large",SpYEE:function(i,t){return i>=t},NKwYr:function(i,t,r,a){return i(t,r,a)},tNOGP:function(i,t){return i<t},RRFcJ:n(889),Uwgkw:function(i,t,r){return i(t,r)},SXGFq:"3|0|4|1|2",AAbeb:function(i,t){return i+t},VobhL:function(i,t){return i|t},eZwoG:function(i,t){return i<<t},jkPtM:function(i,t){return i+t},ksbrw:function(i,t){return i|t},PgJuQ:function(i,t){return i+t},sbDUd:function(i,t){return i<<t},FvPld:function(i,t){return i+t},utqpX:function(i,t,r){return i(t,r)},lpwId:function(i,t){return i!==t},kzjah:n(397),QhNBo:function(i,t){return i+t},kQcHL:function(i,t){return i&t},XjMzU:function(i,t){return i&t},KKRGL:function(i,t){return i>>>t},uuFJw:function(i,t){return i!==t},FznsZ:n(756),Gneut:function(i,t,r,a){return i(t,r,a)},GScnN:n(1037),zQoqE:function(i,t){return i<t},SCTNG:function(i,t){return i|t},sldJD:function(i,t){return i<<t},WLewH:function(i,t){return i&t},EwcqX:function(i,t){return i>>>t},daswG:function(i,t){return i|t},wAKOj:function(i,t){return i>t},tztcw:function(i,t,r,a){return i(t,r,a)},PjbUz:function(i,t){return i<t},guwBC:n(353),yZvVU:n(452),UfRdo:n(1298)+n(1186),idOGt:n(1186),PSeVz:n(1634),ItLyF:n(1620)+n(523),NkNHi:n(1638)+n(1483),vyFXA:n(678),TNZQs:n(1162),HFFbL:function(i,t,r){return i(t,r)},AGRKA:n(356)+n(1290),lgTvf:n(1455),zmDTA:n(1170),ISrMZ:n(1147),EZaqL:function(i,t,r,a){return i(t,r,a)},Aghfu:function(i,t){return i===t},OqjDe:"xNWno",kIsQE:n(648),LnGUc:function(i,t){return i===t},dcKKw:"SQMJd",eVLht:n(835),gmwxi:"jznEO",RNaUu:function(i,t,r,a){return i(t,r,a)},EPNqu:n(205)+n(309)+"e",IIJeH:function(i,t){return i(t)},PXJia:function(i,t,r){return i(t,r)},QDvEN:"x-msg-cu"+n(966)+"ue",EzXKk:function(i,t){return i+t},tHxUi:function(i){return i()},aTPGv:function(i,t){return i<t},EOtoc:function(i){return i()},EjSjo:function(i,t){return i===t},TuzKJ:function(i){return i()},EYtWl:function(i,t,r){return i(t,r)},WBSJQ:n(737),laKvD:n(1572),UduLe:function(i,t){return i(t)},HVthj:function(i){return i()},TLEHH:function(i,t){return i===t},rNNAc:function(i,t,r){return i(t,r)},DlTqS:function(i){return i()},gOIbj:function(i,t){return i-t},XWjnD:function(i,t){return i>t},jjObn:n(750),OtvrO:n(926),zZJNS:function(i){return i()},zANor:n(1099),pHdnt:n(1407),WCcvG:n(1438)+n(558)+"s",xfAEb:n(605),Jucqs:function(i,t,r){return i(t,r)},GWJnk:function(i,t,r,a){return i(t,r,a)},hwTQX:function(i,t,r){return i(t,r)},stjhA:function(i,t,r){return i(t,r)},uzfbs:function(i,t){return i!==t},TucFT:function(i,t,r){return i(t,r)},BFisd:n(946),FPwNp:function(i,t){return i!==t},WiRTK:function(i,t){return i(t)},oHAqh:n(1036),HqLdF:function(i,t,r){return i(t,r)},vOYQm:function(i,t){return i(t)},tGmJR:function(i,t){return i instanceof t},MSOow:function(i,t){return i(t)},TrRgv:function(i,t,r){return i(t,r)},yuTHh:n(902)+n(477),lNWgv:n(627)+"rovide valid url",SLjYl:n(627)+n(755)+"s params, WebSoc"+n(1324)+"tructor "+n(1536)+n(1107),kKitb:function(i,t){return i===t},NIYIf:n(953),NqGqR:function(i,t){return i!==t},ECJmC:n(1593),Mrhqx:function(i,t,r){return i(t,r)},SoOVt:n(1126)+n(904)+n(1347)+"ct",ANMzO:n(563),MsvWr:n(812),ZuGpO:n(971),qdLeG:n(321),OcFOJ:function(i,t){return i in t},AqTKl:n(1326),hBWTL:"NgtvQ",UWVfq:n(281),vooOi:n(251),rLtAE:function(i,t){return i==t},LSmXf:n(1328),yHaCB:"wss://",OCVHS:n(951),cqEhT:n(1239),PCGhb:n(395),mIUzG:"device_id",JpooW:function(i,t){return i||t},rPtej:n(627)+n(686)+n(1447)+n(1111)+n(947),AcfcC:"function",gyUiw:n(1580)+"0",dPOgd:n(1322)+n(556)+n(1240)+n(1334),yxRat:"ljaYF",pTotK:function(i,t,r){return i(t,r)},pzPJv:function(i,t){return i===t},MSfUw:n(638),IZApY:function(i,t,r){return i(t,r)},NWQdr:"reconnect",JOxGc:n(1136),BeJUL:function(i,t,r){return i(t,r)},AUkTa:function(i,t){return i===t},wzGJD:n(1625),BJWqI:function(i,t){return i(t)},THtDu:function(i,t){return i===t},HFUNI:n(340),kFqEe:n(740),rPQBJ:function(i,t){return i(t)},tveyy:function(i,t){return i(t)},BXeJX:"FRONTIER>",avvMW:function(i,t,r){return i(t,r)},TzQCO:function(i,t,r){return i(t,r)},ZuZYI:"hKlBY",ftngE:function(i,t){return i===t},RZfZY:function(i,t){return i!==t},TlzqM:n(1184),vKYDC:"VhYUc",fXdPv:n(1419),bUfRk:function(i,t,r){return i(t,r)},wjjND:n(789),WWnCN:n(238),znjrz:"OWTSB",txgzk:n(1502)+" try reconnecting",ftpyv:function(i,t){return i(t)},dKqlE:"4|0|1|3|2",qSLmM:function(i,t){return i(t)},BtSUT:function(i,t,r){return i(t,r)},JQruj:"tZbuF",akqAY:function(i,t){return i===t},CWLbF:n(284),rhFWt:function(i,t,r){return i(t,r)},zdKnc:function(i,t,r){return i(t,r)},fgZzB:function(i,t){return i(t)},buhql:"AbortError",GDPeY:"KFEJO",BWdVF:function(i,t){return i!==t},UmrKV:n(1633),yEQHa:function(i,t,r,a){return i(t,r,a)},PzLWQ:n(831),xkxvs:"boe",uDxqs:function(i,t){return i===t},LocYf:n(1567),WxNwq:"hoVVw",TLAIF:function(i,t){return i+t},KeJgl:n(226),CgCgY:"6|1|0|3|"+n(899),ehODa:n(424)+n(1174)+n(1161)+"nitialized",rruJc:function(i,t){return i===t},MpZXB:n(424)+n(1021)+"y closed",DoPib:n(627)+n(577)+n(735)+n(615)+n(1244)+"e a stri"+n(614)+n(248)+n(827),nbaBG:n(1535),gHxBB:function(i,t){return i||t},gbour:n(627)+n(577)+n(1339)+n(194),AoUcY:function(i,t){return i instanceof t},hgLkw:function(i,t){return i===t},bWuaC:n(1495),ATqvG:function(i,t){return i<t},ONhyD:n(884),BZwrH:function(i,t){return i!==t},arTwp:function(i,t,r){return i(t,r)},HedmD:function(i,t){return i!==t},EGQJG:function(i,t){return i!==t},xVFJl:n(280),WmKpz:"vsmKl",PpvIF:n(1472),bYPGD:n(1303),JvoQK:function(i,t){return i!==t},GPkjo:"PkGNb",owKsi:"\0\0\0\0\0\0\0\0",VeXuB:"Window",bRNvg:function(i,t){return i===t},lWXuE:n(1169),kPAWS:function(i,t){return i!=t},bToiO:function(i,t){return i===t},ATnmP:function(i,t){return i===t},qonAl:n(579)+"rkerGlob"+n(1022),AVMzr:function(i,t){return i!=t},olEiG:function(i,t){return i!=t},DpuLs:function(i,t){return i===t},KVWlt:function(i,t){return i===t},xtQaT:function(i,t){return i!=t},TjZev:function(i,t){return i!=t}};qe.r(te),qe.d(te,{FWS:()=>D0,CustomErrorEvent:()=>es,createCloseEvent:()=>De,ReconnectEvent:()=>Zi,createErrorEvent:()=>Ae,decodedFrame:()=>_t,createOpenEvent:()=>os,CustomCloseEvent:()=>ts,createReconnectEvent:()=>Lr,FrontierMessageEvent:()=>rs,encodeFrame:()=>re,createMessageEvent:()=>ss,OpenEvent:()=>is,ErrorCode:()=>nt,Event:()=>vt,MessageEvent:()=>ns});let s="";function o(i=""){let t=n,r="02",a=""+Date[t(1376)](),x=s||(s=h(i)),g=Math.random().toString(16)[t(1375)](-6);return e[t(1182)](e[t(1182)](e[t(961)](r,a),x),g)}function c(){let i=n;return e[i(1114)](e.eJkAt(1e4,Date[i(1376)]()),Math.floor(e[i(243)](1e4,Math[i(1230)]())))}function d(i){let t=n,r={qqxLH:function(a,x){return a!=x},Tkmgs:t(980)+"d",ThnEa:t(822),ufQEV:e[t(459)]};if(e.verDj(e[t(834)],e[t(834)]))return e[t(1114)](e.WJcje(Array,8)[t(828)]("0"),e[t(1203)](parseInt,i,10)[t(198)](2))[t(1375)](-8);zxQsjZ[t(257)](zxQsjZ[t(485)],typeof _0x2b13e4)&&_0xf889[t(198)+"Tag"]&&_0x1abbe9[t(542)+"operty"](_0xec1b3b,_0x302231[t(198)+"Tag"],{value:zxQsjZ[t(1645)]}),_0x2999c1[t(542)+t(325)](_0x3a9ed2,zxQsjZ[t(1357)],{value:!0})}function u(i){let t=n;return e[t(398)](e[t(537)](Array,4)[t(828)]("0"),e[t(1367)](parseInt,i,2)[t(198)](16))[t(1375)](-4)}function f(i){let t=n,r=i[t(1354)](/\./)[t(753)](g=>d(g)),a=[];return a[0]=e[t(748)](u,e.wFNPO(r[0],r[1])),a[1]=e[t(724)](u,r[2]+r[3]),[e[t(549)],t(1164),e[t(549)],t(1164),t(1164),t(456),a[0],a[1]][t(828)]("")}function h(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}/.test(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(705)](i);return r?e[t(1051)](f,i):a?p(i):e[t(1394)]}function p(i){let t=n,r="",a=[],x=0,g=0,m=!0,y=e[t(549)];if(e.WNvQl(i.indexOf("::"),-1)){let _=i.split("::");for(let v=0;v<_[t(1606)];v++){let C=_[v];if(e[t(204)](C[t(539)](":"),0)){let D=C[t(1354)](":");m&&(x=D[t(1606)]),g+=D[t(1606)];for(let F=0;F<D[t(1606)];F++)if(D[F][t(1606)]!==4){let U=y[t(1488)+"g"](0,4-D[F][t(1606)]),Z=U[t(1608)](D[F]);a[t(1034)](Z)}else a[t(1034)](D[F]);m=!1}else{if(e.HnQSB(4,C[t(1606)])){let D=y[t(1488)+"g"](0,e[t(1636)](4,C[t(1606)])),F=D[t(1608)](C);a[t(1034)](F)}else a[t(1034)](C);m&&(x+=1),g+=1,m=!1}}let l="";for(let v=0;e[t(580)](v,e[t(1636)](8,g));v++)l=l[t(1608)](y);for(let v=0;e[t(730)](v,a[t(1606)]);v++)if(v===x)if(e[t(894)]==="fPfmb")r=r[t(1608)](l),r=r.concat(a[v]);else return this[t(957)+t(1640)]?.[t(252)+t(1586)+t(1372)+t(729)]()||0;else r=r[t(1608)](a[v]);return r}{let _=i.split(":");for(let l=0;e.jQvRj(l,_[t(1606)]);l++){let v=_[l];if(_[l].length!==4){let C=y.substring(0,e[t(976)](4,_[l][t(1606)])),D=C.concat(v);r=r.concat(D)}else r=r[t(1608)](v)}return r}}function w(i,t){let r=n,a=i[r(342)];e[r(695)](void 0,a)&&(e.ymaiC(V,t,10),ge(t,a));let x=i[r(474)];e[r(460)](void 0,x)&&(e[r(1400)](V,t,18),e[r(1203)](ge,t,x))}function b(i){let t=n,r={rHINc:function(a,x){return e[R(470)](a,x)}};if(e[t(460)](e[t(641)],t(308))){let a={};e:for(;!e[t(1082)](we,i);){let x=e[t(724)](X,i);switch(x>>>3){case 0:break e;case 1:a[t(342)]=Q(i,X(i));break;case 2:a[t(474)]=e[t(1032)](Q,i,e.hletf(X,i));break;default:e[t(1203)](Y,i,e[t(212)](7,x))}}if(e[t(1228)](void 0,a[t(342)]))throw new Error(e.RBaGJ);if(a[t(474)]===void 0)throw new Error(e.cQEYZ);return a}else{let a=this[t(843)][t(1566)+t(1388)](this[t(640)]),x=_0x536c61.parse(r.rHINc(a,"{}"));return x[_0x442fdb]=void 0,this._qosDB[t(1007)+t(1388)](this[t(640)],_0x39a928.stringify(x))}}function E(i){let t=n,r=e[t(612)](W);return I(i,r),e[t(1105)](ke,r)}function I(i,t){let r=n,a=i.SeqID;e[r(460)](void 0,a)&&(e[r(1203)](V,t,8),e[r(1203)](J,t,a));let x=i[r(1505)];e[r(1009)](void 0,x)&&(V(t,16),J(t,x));let g=i[r(452)];e[r(900)](void 0,g)&&(e[r(1032)](V,t,24),J(t,e[r(358)](j,g)));let m=i[r(912)];if(e.VNZoe(void 0,m))if(e.wjIuq!==r(1329)){let Z=this["_endpoin"+r(1640)]?.[r(252)+r(1586)+"nt"]();this[r(1420)](r(672)+Z),e[r(1211)](_0x154b84)}else e[r(1367)](V,t,32),e[r(1367)](J,t,j(m));let y=i[r(1260)];if(e.XpasV(void 0,y))for(let Z of y){e[r(1203)](V,t,42);let ae=e[r(864)](W);e[r(923)](w,Z,ae),e.QEEZE(V,t,ae[r(1050)]),e[r(1226)](Ke,t,ae),e.bKwYv(le,ae)}let _=i[r(1309)+r(882)];if(e[r(1568)](void 0,_))if(e.VjqwZ!==e.oYSXz)e[r(1396)](V,t,50),e[r(1400)](ge,t,_);else return!!(e[r(363)](this.currentIndex,this[r(1395)+"s"][r(1606)])||e[r(1228)](this[r(414)+"ndex"],this[r(1395)+"s"][r(1606)]-1)&&e[r(462)](this[r(1003)+"ndpointT"+r(1262)+"t"],this.maxRetries));let l=i[r(332)+r(1542)];e[r(1568)](void 0,l)&&(V(t,58),e[r(923)](ge,t,l));let v=i[r(1627)];v!==void 0&&(e[r(1032)](V,t,66),e[r(1032)](V,t,v[r(1606)]),e[r(1226)](ve,t,v));let C=i[r(1560)];e[r(458)](void 0,C)&&(e[r(1389)](V,t,74),e[r(923)](ge,t,C));let D=i[r(1330)+r(1139)];e[r(460)](void 0,D)&&(e.GMmCB(V,t,82),ge(t,D));let F=i.msgID;e.ZBlyD(void 0,F)&&(V(t,90),ge(t,F));let U=i.frameType;e[r(1568)](void 0,U)&&(e[r(910)](V,t,96),e.nQaFN(J,t,e[r(283)](j,U)))}function A(i){let t=n;return e[t(537)](k,e[t(1105)](_e,i))}function k(i){let t=n;if(e[t(1100)](e[t(653)],e[t(447)])){let r={};e:for(;!e.bKwYv(we,i);)if(e[t(1009)](t(1430),e[t(925)])){let a=e[t(224)](X,i);switch(e[t(425)](a,3)){case 0:break e;case 1:r[t(1531)]=e[t(1396)](ut,i,!0);break;case 2:r[t(1505)]=e.uUdhf(ut,i,!0);break;case 3:r[t(452)]=e[t(1051)](X,i);break;case 4:r.method=e[t(1341)](X,i);break;case 5:{let x=e.PTKHW(z,i);(r[t(1260)]||(r[t(1260)]=[]))[t(1034)](e[t(1152)](b,i)),i[t(1050)]=x;break}case 6:r[t(1309)+t(882)]=e.nhQuL(Q,i,e[t(283)](X,i));break;case 7:r[t(332)+t(1542)]=e[t(666)](Q,i,e[t(1617)](X,i));break;case 8:r[t(1627)]=B(i,e[t(786)](X,i));break;case 9:r[t(1560)]=e.YZeUo(Q,i,e[t(724)](X,i));break;case 10:r[t(1330)+t(1139)]=e[t(709)](Q,i,e[t(224)](X,i));break;case 11:r.msgID=e[t(1522)](Q,i,e.RYBoA(X,i));break;case 12:r[t(1642)+"e"]=X(i);break;default:e.QcuCh(Y,i,e[t(212)](7,a))}}else{let a=this[t(843)][t(1621)](this[t(640)]),x=_0x5e3ab6[t(1454)](e.uqqul(a,"{}"));return _0x788462[t(727)](x)}if(e[t(1489)](void 0,r[t(1531)]))throw new Error(e.gkyrt);if(e.BTVlQ(void 0,r[t(1505)]))throw new Error(e[t(1589)]);if(e.verDj(void 0,r[t(452)]))throw new Error(e.nZMTa);if(e[t(701)](void 0,r[t(912)]))throw new Error(e.qrJlq);return r}else++_0x336977,_0x5dc102+=4}function z(i){let t=n,r=e.RYBoA(X,i),a=i[t(1050)];return i[t(1050)]=e[t(493)](i[t(1149)],r),a}function Y(i,t){let r=n;switch(t){case 0:for(;128&e[r(724)](ne,i););break;case 2:e.vUxmS(xe,i,e[r(307)](X,i));break;case 5:e.wKgok(xe,i,4);break;case 1:xe(i,8);break;default:throw new Error(e[r(1628)](e.gMKwb,t))}}function j(i){let t=n;return i|=0,{low:i,high:e[t(486)](i,31),unsigned:e[t(1499)](i,0)}}let oe=[];function W(){let i=n,t=oe.pop();return t?(t[i(1149)]=t[i(1050)]=0,t):{bytes:new Uint8Array(64),offset:0,limit:0}}function le(i){oe.push(i)}function _e(i){return{bytes:i,offset:0,limit:i.length}}function ke(i){let t=n,r=i.bytes,a=i.limit;return r[t(1606)]===a?r:r[t(427)](0,a)}function xe(i,t){let r=n;if(e.IQqhd(i[r(1149)]+t,i.limit))throw new Error(e[r(365)]);i[r(1149)]+=t}function we(i){let t=n;return e.nzrMS(i.offset,i[t(1050)])}function T(i,t){let r=n,a=i[r(1029)],x=i[r(1149)],g=i[r(1050)],m=e[r(1182)](x,t);if(m>a[r(1606)]){let y=new Uint8Array(e[r(220)](2,m));y[r(264)](a),i[r(1029)]=y}return i[r(1149)]=m,e[r(204)](m,g)&&(i[r(1050)]=m),x}function O(i,t){let r=n,a=i[r(1149)];if(e[r(961)](a,t)>i[r(1050)])throw new Error(r(1482)+"t limit");return i[r(1149)]+=t,a}function B(i,t){let r=n,a=e[r(1448)](O,i,t);return i[r(1029)].subarray(a,e[r(398)](a,t))}function ve(i,t){let r=n,a=e.SBrQL(T,i,t[r(1606)]);i[r(1029)][r(264)](t,a)}function Q(i,t){let r=n,a={YMpBP:function(l,v){return e[R(1576)](l,v)},lKyDT:function(l,v){return e[R(522)](l,v)},YaNSj:function(l,v){return e.SpIEO(l,v)}},x=e[r(1080)](O,i,t),g=String["fromChar"+r(1481)],m=i[r(1029)],y="\uFFFD",_="";for(let l=0;e[r(388)](l,t);l++){let v=m[l+x],C,D,F,U;if(e[r(212)](128,v)===0)_+=e.oeLup(g,v);else if(e[r(701)](e.KiLWh(224,v),192))if(l+1>=t)_+=y;else if(e[r(1228)](r(846),"XVubc"))_0x11f7c7[r(405)](_0x5a5dec);else if(C=m[e.omXqh(l+x,1)],e[r(437)](e[r(892)](192,C),128))_+=y;else{if(e[r(291)]!==e[r(291)])return _0x5b6b30?.[r(1215)](Z=>Z.key===_0x51f64c)?.value;U=e[r(262)](e[r(892)](31,v)<<6,e[r(1206)](63,C)),e[r(1576)](U,128)?_+=y:(_+=e[r(537)](g,U),l++)}else if(e[r(1220)](e[r(1223)](240,v),224))e[r(1581)](e.AyqgK(l,2),t)?_+=y:e[r(382)](e[r(1509)],e[r(970)])?this[r(679)+r(1172)]=_0x11d74c:(C=m[e.omXqh(e[r(1619)](l,x),1)],D=m[e[r(1182)](e[r(1182)](l,x),2)],e.yrwMJ(e[r(1223)](e[r(262)](C,D<<8),49344),32896)?_+=y:(U=e[r(1035)](e.ybEWC(e.drGRB(e[r(1206)](15,v),12),e[r(371)](63&C,6)),e.XcLMI(63,D)),e[r(388)](U,2048)||e[r(1581)](U,55296)&&e[r(1062)](U,57343)?_+=y:(_+=e[r(949)](g,U),l+=2)));else if(e[r(649)](248,v)==240)if(e[r(363)](e[r(572)](l,3),t))_+=y;else if(C=m[e[r(1083)](l+x,1)],D=m[e[r(566)](e[r(394)](l,x),2)],F=m[e[r(1390)](e[r(292)](l,x),3)],e[r(900)](e[r(515)](e[r(262)](C,e[r(1109)](D,8)),e[r(1345)](F,16))&12632256,8421504))_+=y;else if(e.Ezagq(e[r(222)],e[r(660)])){let Z=_0x32384f[r(1354)](":");_0x2e562a&&(_0x429186=Z[r(1606)]),_0x1cdd3d+=Z[r(1606)];for(let ae=0;yPLWvC[r(1467)](ae,Z[r(1606)]);ae++)if(yPLWvC.lKyDT(4,Z[ae][r(1606)])){let $t=_0x2f042b[r(1488)+"g"](0,yPLWvC[r(345)](4,Z[ae].length)),yn=$t[r(1608)](Z[ae]);_0xbb5167[r(1034)](yn)}else _0x2fe4a1[r(1034)](Z[ae]);_0x337d7c=!1}else U=e[r(1035)](e.BlPdT(e[r(1109)](7&v,18),e.sKHbA(e[r(446)](63,C),12)),e[r(371)](e.EVtgF(63,D),6))|63&F,e[r(1466)](U,65536)||e.huqXV(U,1114111)?_+=y:(U-=65536,_+=e.zaLtq(g,e[r(1628)](e[r(486)](U,10),55296),e[r(394)](e[r(604)](1023,U),56320)),l+=3);else _+=y}return _}function ge(i,t){let r=n;if(e.GSBqg===e[r(595)]){let a=t[r(1606)],x=0;for(let y=0;e.TmKfR(y,a);y++){let _=t[r(453)+"At"](y);e[r(816)](_,55296)&&_<=56319&&e.SALKv(e[r(853)](y,1),a)&&(_=e[r(976)](e[r(572)](e[r(1515)](_,10),t[r(453)+"At"](++y)),56613888)),x+=e.jTIlS(_,128)?1:e[r(388)](_,2048)?2:e[r(388)](_,65536)?3:4}e[r(346)](V,i,x);let g=T(i,x),m=i[r(1029)];for(let y=0;y<a;y++){let _=t[r(453)+"At"](y);if(e.FOFwb(_,55296)&&e[r(1549)](_,56319)&&e[r(388)](y+1,a)&&(_=e.BvQZl(e.LCtWH(_,10),t[r(453)+"At"](++y))-56613888),e[r(730)](_,128))m[g++]=_;else if(e[r(1100)](e.uaiyP,r(888))){let l=_0x58d90c[r(1488)+"g"](0,4-_0x5d0467[_0x1bce3d][r(1606)]),v=l[r(1608)](_0x32e763[_0x13378f]);_0x5a1932[r(1034)](v)}else e[r(590)](_,2048)?m[g++]=e[r(1485)](e[r(604)](e[r(486)](_,6),31),192):(_<65536?m[g++]=e[r(1173)](e[r(659)](e[r(963)](_,12),15),224):(m[g++]=e.JwneI(e[r(1321)](_,18)&7,240),m[g++]=e[r(1242)](e.xtVem(e.YgoeR(_,12),63),128)),m[g++]=e[r(1261)](e[r(242)](e[r(486)](_,6),63),128)),m[g++]=e.dSeXe(e[r(446)](63,_),128)}}else{let a=_0x38268e[r(1149)];if(e[r(302)](e[r(566)](a,_0x5ad931),_0x2145e5[r(1050)]))throw new _0x457555(e.FLTsO);return _0x522b89.offset+=_0x49321c,a}}function Ke(i,t){let r=n,a=e[r(923)](T,i,t[r(1050)]),x=i[r(1029)],g=t[r(1029)];for(let m=0,y=t[r(1050)];e[r(1216)](m,y);m++)x[m+a]=g[m]}function ne(i){let t=n;return i.bytes[e[t(1090)](O,i,1)]}function Ze(i,t){let r=n;if(e[r(1340)](e.lIvbx,e[r(391)])){let a=e.QcuCh(T,i,1);i[r(1029)][a]=t}else _0x5d45d4[r(1492)][r(651)+r(1637)](_0x1003b5)}function X(i){let t=n,r=0,a=0,x;do x=e.fgObu(ne,i),e[t(1398)](r,32)&&(a|=e[t(1452)](127,x)<<r),r+=7;while(e[t(975)](128,x));return a}function V(i,t){let r=n;for(t>>>=0;e[r(816)](t,128);)e[r(1294)](Ze,i,e.admpn(127,t)|128),t>>>=7;e[r(469)](Ze,i,t)}function ut(i,t){let r=n,a={nCtSh:function(x,g){return x|g},RKJDg:function(x,g){return e[R(1261)](x,g)},SplGO:function(x,g){return e[R(317)](x,g)},WfoBe:function(x,g){return e[R(1103)](x,g)},mfWOH:function(x,g){return x|g}};if(e[r(528)](e[r(336)],e.RkHTX))return _0x28d12c[r(405)](_0x198b1d),!1;{let x=0,g=0,m=0,y;if(y=e[r(868)](ne,i),x=e[r(1452)](127,y),e[r(892)](128,y)&&(y=e[r(704)](ne,i),x|=e[r(212)](127,y)<<7,e.IMOwV(128,y)&&(y=e.bqjCj(ne,i),x|=e.IVwxi(e[r(881)](127,y),14),e[r(1555)](128,y)&&(y=e[r(760)](ne,i),x|=e[r(1103)](e[r(881)](127,y),21),128&y&&(y=e[r(1019)](ne,i),g=e[r(871)](127,y),128&y))))){if(e.BTVlQ(r(244),r(769)))this[r(1011)]&&this._ws.close(_0xfe71ba,_0x36171c);else if(y=e.gvYhI(ne,i),g|=e.VzPwR(127,y)<<7,e[r(1142)](128,y)&&(y=e[r(1577)](ne,i),g|=e.nyRoW(e[r(1629)](127,y),14),e[r(659)](128,y)&&(y=e[r(525)](ne,i),g|=e[r(490)](127,y)<<21,e[r(890)](128,y)))){if(e[r(437)](e[r(995)],r(1284)))return new _0x314b12(a.nCtSh(a[r(767)](a[r(767)](_0x31713e[0],a[r(1295)](_0x59d9fe[1],8)),a[r(1393)](_0x3cb1a4[2],16)),a[r(1393)](_0x2dd1e9[3],24)),a[r(1191)](_0x1d73f3[4]|a[r(1393)](_0x3d3e46[5],8),a[r(1393)](_0xd13b67[6],16))|a[r(1295)](_0x53cc24[7],24),_0x2c1bfb);y=e.RlDPg(ne,i),m=e.Dytda(127,y),e[r(975)](128,y)&&(y=e[r(358)](ne,i),m|=e[r(1241)](127&y,7))}}return{low:e[r(1242)](x,e[r(209)](g,28)),high:e[r(1035)](e[r(1110)](g,4),e[r(371)](m,24)),unsigned:t}}}function J(i,t){let r=n,a=e[r(1030)](t[r(700)],0),x=e.AmzVM(e.LIHxe(t.low,28),e[r(1374)](t[r(532)],4))>>>0,g=e[r(574)](t[r(532)],24),m=g===0?e.BTVlQ(0,x)?e[r(730)](a,16384)?e[r(1576)](a,128)?1:2:a<2097152?3:4:e[r(388)](x,16384)?x<128?5:6:e[r(502)](x,2097152)?7:8:e[r(1466)](g,128)?9:10,y=e[r(944)](T,i,m),_=i[r(1029)];switch(m){case 10:_[e.wFNPO(y,9)]=e[r(287)](e[r(341)](g,7),1);case 9:_[e[r(536)](y,8)]=m!==9?e.JwneI(128,g):127&g;case 8:_[e[r(1187)](y,7)]=m!==8?e[r(1242)](x>>>21,128):x>>>21&127;case 7:_[e[r(508)](y,6)]=e[r(720)](7,m)?e.BlPdT(x>>>14,128):e[r(1010)](e[r(1030)](x,14),127);case 6:_[e[r(752)](y,5)]=m!==6?e[r(515)](e[r(1110)](x,7),128):e.QEIMI(e[r(341)](x,7),127);case 5:_[y+4]=m!==5?e.Lpmzo(128,x):127&x;case 4:_[e[r(1628)](y,3)]=e[r(506)](4,m)?e[r(1065)](e[r(425)](a,21),128):e.Dytda(a>>>21,127);case 3:_[e[r(1187)](y,2)]=e.bAbxL(3,m)?e[r(1108)](e[r(1110)](a,14),128):e[r(543)](a,14)&127;case 2:_[e.omXqh(y,1)]=e.ZBlyD(2,m)?e[r(1478)](e[r(341)](a,7),128):e.lwQZk(a>>>7,127);case 1:_[y]=e.TtgyM(1,m)?e[r(1065)](128,a):e[r(658)](127,a)}}function _t(i){return e[n(868)](A,i)}function re(i){let t=n;if(e[t(458)]("WHvQW",t(1646)))e.SmwDW(_0x3140fd,_0x4da438,32),e[t(1032)](_0x23ca6a,_0x23f6be,e[t(1595)](_0x3fa8e7,_0x5de8f3));else return e[t(537)](E,i)}let yt=65536,ye=e[n(875)],bt=yt*yt,Yi=bt*bt,Xi=Yi/2,et=String[n(1444)+"e"].charCodeAt;class K{constructor(t,r,a){let x=n;this[x(592)]=!0,this[x(700)]=0|t,this.high=e[x(1600)](0,r),this[x(1046)]=!!a}static[n(592)](t){let r=n,a={QADMu:function(x,g){return x!=g},GibHS:e[r(465)]};if(e[r(1175)]!==e.yZrbe)return t&&e[r(919)](!0,t.isLong);{let x={cpPBS:function(g,m){return EbMkGq.QADMu(g,m)},hMkFO:EbMkGq[r(223)],MVnsw:r(822),CFTmz:r(762)+"le"};_0x102fe6.r=g=>{let m=r;x[m(1427)](x[m(255)],typeof _0x36cddf)&&_0x3328f5[m(198)+m(1275)]&&_0x589d8e[m(542)+"operty"](g,_0x47ce66["toString"+m(1275)],{value:x[m(964)]}),_0x17a84b[m(542)+m(325)](g,x[m(656)],{value:!0})}}}static[n(479)](t,r,a){return new K(t,r,a)}static fromBytes(t,r,a){let x=n;return a?K[x(682)+x(385)](t,r):K["fromByte"+x(1269)](t,r)}static[n(682)+n(385)](t,r){let a=n,x={eLpIL:e[a(821)],rcbwL:function(g,m){return g(m)}};if(e[a(1489)](e[a(588)],"xcYDD")){let g=_0x37fa87[a(494)+a(859)](_0x589552);return _0x1bd3f1&&g[a(621)+a(196)](EFTlby.eLpIL,()=>_0x15cfe1()),EFTlby[a(849)](_0x5d616e,g).then(()=>{})}else return new K(e.HzSJV(e[a(622)](t[0]|e.drGRB(t[1],8),e[a(1280)](t[2],16)),e.yUWzv(t[3],24)),e[a(1108)](e[a(511)](e[a(927)](t[4],e[a(461)](t[5],8)),e[a(317)](t[6],16)),e[a(317)](t[7],24)),r)}static[n(682)+n(1269)](t,r){let a=n;return new K(e.Lpmzo(e[a(1231)](e[a(1300)](e[a(209)](t[4],24),e[a(1374)](t[5],16)),e.obYmM(t[6],8)),t[7]),e.jtFXl(e[a(378)](e.HdShR(t[0],24),e[a(317)](t[1],16)),t[2]<<8)|t[3],r)}static[n(192)](t){let r=n;return e.BCUKV(t,ye)?Qi:new K(e[r(425)](e[r(1485)](et[r(1518)](t,0)|e[r(371)](et[r(1518)](t,1),8),e.PSZnE(et[r(1518)](t,2),16))|e.xSjgM(et[r(1518)](t,3),24),0),e[r(378)](e.JwneI(e[r(262)](et[r(1518)](t,4),e.JihaT(et[r(1518)](t,5),8)),e[r(1241)](et[r(1518)](t,6),16)),et.call(t,7)<<24)>>>0,!0)}[n(1457)](){let t=n;return String[t(1562)+t(1481)](255&this.low,e.iPsZQ(e[t(341)](this[t(700)],8),255),e[t(1233)](this.low,16)&255,e[t(543)](this[t(700)],24),e[t(1010)](255,this[t(532)]),e[t(871)](e[t(1171)](this[t(532)],8),255),e[t(1200)](this.high>>>16,255),e[t(1110)](this.high,24))}static[n(1356)+"er"](t,r=!0){let a=n;if(e[a(949)](isNaN,t))return r?Hc:Qi;if(r){if(e[a(363)](t,Yi))return Kc}else{if(e[a(1469)](t,-Xi))return Wc;if(e[a(363)](e[a(1628)](t,1),Xi))return jc}return K[a(479)](e.rzpDF(e[a(1306)](t,bt),0),e[a(1478)](e[a(928)](t,bt),0),r)}[n(1416)](){let t=n;return this[t(1046)]?e[t(839)](this[t(532)],0)*bt+e[t(1412)](this[t(700)],0):e[t(216)](e[t(243)](this.high,bt),this[t(700)]>>>0)}[n(1209)](){let t=n;return e[t(241)](0,this.high)&&this[t(700)]===0}[n(1178)](t){let r=n;K[r(592)](t)||(t=K.fromNumber(t));let a=e[r(331)](this[r(532)],16),x=e[r(1042)](65535,this[r(532)]),g=e[r(399)](this[r(700)],16),m=e[r(892)](65535,this[r(700)]),y=e[r(574)](t.high,16),_=65535&t.high,l=t[r(700)]>>>16,v=e.KcDVz(65535,t[r(700)]),C=0,D=0,F=0,U=0;return U+=m+v,F+=e[r(331)](U,16),U&=65535,F+=e[r(655)](g,l),D+=e[r(718)](F,16),F&=65535,D+=e.LAOPV(x,_),C+=e[r(839)](D,16),D&=65535,C+=e.TExGz(a,y),C&=65535,K[r(479)](e[r(511)](e[r(403)](F,16),U),e[r(1065)](e[r(403)](C,16),D),this[r(1046)])}[n(335)](t){let r=n;return K[r(592)](t)||(t=K[r(1356)+"er"](t)),e[r(807)](this[r(1046)],t[r(1046)])&&e[r(1110)](this[r(532)],31)===1&&e[r(701)](e.sfdCu(t[r(532)],31),1)?!1:e[r(779)](this.high,t[r(532)])&&e[r(629)](this.low,t.low)}[n(876)](){let t=n;if(e[t(1228)](e[t(432)],e.pvrBE))return this[t(700)]===-1&&e.QgeFB(-1,this[t(532)])?K[t(479)](0,0,this[t(1046)]):e[t(241)](-1,this[t(700)])?K[t(479)](0,e.tuCAQ(this[t(532)],1),this.unsigned):K.fromBits(e.omXqh(this.low,1),this[t(532)],this[t(1046)]);_0x57ad34[t(1034)](_0x138d63)}[n(1440)](t){let r=n;return t?this[r(431)+"E"]():this[r(968)+"E"]()}toBytesLE(){let t=n,r=this.high,a=this[t(700)];return[255&a,e[t(718)](a,8)&255,e.qzlzz(e[t(1171)](a,16),255),e[t(1120)](a,24),255&r,e[t(298)](e.mDBKM(r,8),255),e[t(619)](e.FjbQm(r,16),255),e[t(1387)](r,24)]}[n(968)+"E"](){let t=n,r=this[t(532)],a=this[t(700)];return[r>>>24,e.iFNfp(r>>>16,255),e[t(710)](e[t(839)](r,8),255),e.OVmJN(255,r),e[t(1124)](a,24),e[t(1e3)](a,16)&255,e[t(604)](a>>>8,255),e[t(1010)](255,a)]}}let Qi=new K(0,0,!1),Hc=new K(0,0,!0),jc=K[n(479)](-1,2147483647,!1),Kc=K[n(479)](-1,-1,!0),Wc=K[n(479)](0,-2147483648,!1);var nt=(function(i){let t=n;return i[i[e[t(1153)]]=5001]=e[t(1153)],i[i[e[t(920)]]=5002]=e[t(920)],i[i[e[t(1413)]]=5003]="MAX_RETR"+t(676)+"R",i[i[t(854)+t(734)]=5004]="MESSAGE_"+t(734),i[i[e[t(609)]]=5005]=e[t(609)],i})({});class vt{constructor(t){let r=n;this[r(1061)]=t,this.target=null}}class Zi extends vt{constructor(t,r){let a=n;super(t),this[a(1422)]=r&&r[a(1422)]||null}}class es extends vt{constructor(t,r){let a=n,x=e[a(1289)].split("|"),g=0;for(;;){switch(x[g++]){case"0":this[a(1422)]=r&&r[a(1422)]||"";continue;case"1":this[a(1181)]=r&&r[a(1181)]||null;continue;case"2":this[a(214)]=r&&r.colno||0;continue;case"3":this[a(451)]=r&&r[a(451)]||"";continue;case"4":this[a(1362)]=r&&r[a(1362)]||0;continue;case"5":this[a(692)]=r&&r[a(692)]||5001;continue;case"6":super(t);continue}break}}}class ts extends vt{constructor(t,r){let a=n;super(t),this[a(692)]=r&&r.code||0,this[a(1483)]=r&&r[a(1483)]||"",this.wasClean=r&&r[a(1079)]||!1,this[a(790)+a(1521)]=r&&r["willReco"+a(1521)]||!1}}class ns extends vt{constructor(t,r){let a=n;super(t),this.data=r&&r[a(680)]||null}}class rs extends ns{constructor(t,r){let a=n;super(t),this[a(680)]=r&&r[a(680)]||null,this[a(1422)]=r&&r[a(1422)]||null}}class is extends vt{constructor(t,r){let a=n;super(t),this[a(680)]=r&&r.data||null}}function Ae(i,{message:t,code:r,error:a}){return new es(i,{message:t,code:r,error:a})}function De(i,{code:t,reason:r,wasClean:a,willReconnect:x}){return new ts(i,{code:t,reason:r,wasClean:a,willReconnect:x})}function ss(i,{data:t,message:r}){return new rs(i,{data:t,message:r})}function os(i,{data:t}){return new is(i,{data:t})}function Lr(i,{message:t}){return new Zi(i,{message:t})}class as{constructor(t,r){let a=n;this[a(1395)+"s"]=t,this.maxRetries=r,this[a(414)+a(213)]=0,this[a(1003)+a(1310)+"riesCount"]=0}[n(1018)+"pointConfig"](){let t=n;this[t(414)+"ndex"]=0,this[t(1003)+t(1310)+t(1262)+"t"]=0}resetTries(){let t=n;if(e[t(1612)]!==e[t(1612)]){let r=e[t(1389)](_0x16a5a8,_0x2f2484,1);_0x375427[t(1029)][r]=_0xbffdca}else this[t(1003)+t(1310)+"riesCount"]=0}["getCurre"+n(1586)+"nt"](){let t=n;return this.endpoints[this[t(414)+t(213)]]}[n(252)+n(1586)+n(1372)+n(729)](){let t=n;return this[t(1003)+"ndpointT"+t(1262)+"t"]}[n(1320)+"chMaxTries"](){let t=n,r={Kibeu:function(a,x){return e[R(1411)](a,x)},bLIEN:function(a,x){return a<<x},ciTFS:function(a,x){return e[R(1555)](a,x)},WrPpy:function(a,x){return e.jyZVI(a,x)},XnCgF:function(a,x){return e[R(1167)](a,x)},OJwdh:function(a,x){return e[R(1512)](a,x)}};if(e[t(460)]("hOqZc",e[t(547)]))_0x2ca34d=uKzRMY[t(1615)](_0x7bc71f,_0x3e90c1),_0x48901f|=uKzRMY[t(355)](uKzRMY[t(1643)](127,_0x47b1aa),21),uKzRMY[t(1643)](128,_0x19507a)&&(_0x312364=uKzRMY[t(1615)](_0x467ff0,_0x350fb4),_0x15b268=uKzRMY[t(475)](127,_0x71bd49),128&_0x1499e1&&(_0x3a2f89=uKzRMY[t(857)](_0x3ef5f7,_0x1d1d6e),_0x3cb0d2|=uKzRMY[t(1315)](127,_0x14bdad)<<7));else return!!(e.ELMYZ(this[t(414)+t(213)],this[t(1395)+"s"].length)||e.Wvrfy(this[t(414)+"ndex"],this[t(1395)+"s"][t(1606)]-1)&&this[t(1003)+t(1310)+"riesCount"]===this[t(480)+"es"])}[n(519)+n(587)+n(711)+n(1464)+n(823)](){let t=n;return e.wOTLn(this[t(414)+t(213)],this[t(1395)+"s"][t(1606)])?!0:e[t(266)](this[t(1003)+t(1310)+t(1262)+"t"],this[t(480)+"es"])}["replaceBackupEndpointAndUpdateCo"+n(1293)](){let t=n;return this[t(1003)+"ndpointT"+t(1262)+"t"]=1,this[t(414)+"ndex"]++,this[t(1395)+"s"][this[t(414)+t(213)]]}[n(252)+"ntEndpoi"+n(1369)+n(632)](){let t=n;return this[t(1003)+t(1310)+"riesCount"]++,this[t(252)+"ntEndpoint"]()}}let St=(e.sVmis(n(980)+"d",typeof globalThis)&&e.VeXuB===globalThis[n(1583)+n(1421)].name||e[n(1585)](n(980)+"d",typeof window)&&e[n(675)](e.VeXuB,window[n(1583)+n(1421)][n(1186)]))&&e[n(576)](e[n(465)],typeof document),ft=e[n(576)](e[n(465)],typeof globalThis)&&(e.lWXuE===globalThis[n(1583)+n(1421)].name||"Dedicate"+n(232)+n(1426)+"pe"===globalThis[n(1583)+n(1421)][n(1186)])&&e[n(576)](e[n(465)],typeof tt),Wt=(n(980)+"d"!=typeof globalThis&&e[n(779)](e[n(1561)],globalThis[n(1583)+n(1421)].name)||e.DUKka==typeof globalThis||e[n(576)](e.DUKka,typeof globalThis)&&!!globalThis[n(1093)+"Bridge"])&&e[n(1085)](e.DUKka,typeof wx),Jt=e[n(465)]!=typeof globalThis&&(e[n(1346)](n(1288)+n(232)+n(1426)+"pe",globalThis[n(1583)+n(1421)][n(1186)])||e.ATnmP(e.qonAl,globalThis["construc"+n(1421)][n(1186)])||e[n(1228)]("ServiceW"+n(190)+n(1040),globalThis[n(1583)+n(1421)][n(1186)]))&&e.AVMzr(n(980)+"d",typeof self),Jc=e.olEiG(e[n(465)],typeof globalThis)&&e.DpuLs(e[n(1561)],globalThis["construc"+n(1421)].name)&&e[n(1575)](e[n(465)],typeof global)&&e[n(933)](e.lWXuE,global[n(1583)+n(1421)][n(1186)])&&e.xtQaT(e[n(465)],typeof process)&&!!process[n(785)];class Mr{constructor(){let t=n;if(e[t(328)](e[t(1525)],e[t(1525)]))return this[t(1192)]>=this[t(1071)+t(729)];this[t(955)+"rs"]={}}emit(t,...r){let a=n,x=this[a(955)+"rs"][t];if(x)x.slice().forEach(g=>g.fn.apply(g[a(188)],r));else if(e[a(268)]===t&&!this.onerror){let g=r[a(1606)]&&r[0];if(e[a(1565)](g,Error))throw g;let m=new Error(e[a(1592)](e[a(811)],g?e[a(364)](" (",g[a(1422)])+")":""));throw m.context=g,g}return this}off(t,r){let a=n;if(e[a(241)](void 0,t))this._listeners={};else if(e[a(375)](void 0,r))this[a(955)+"rs"][t]=null;else{let x=this._listeners[t];if(x)for(let g=0;e[a(1145)](g,x[a(1606)]);)e.Wvrfy(x[g].fn,r)?x[a(850)](g,1):++g}return this}on(t,r,a){let x=n;return(this[x(955)+"rs"][t]||(this[x(955)+"rs"][t]=[]))[x(1034)]({fn:r,ctx:a||this}),this}}class $c extends Mr{["_formatE"+n(914)+n(1599)](t){let r=n;return t[r(187)]||t[r(1281)]?(r(1179)+" "+(t[r(187)]||"")+" code: "+(t.errNo||""))[r(191)]():JSON[r(600)+"y"](t)}constructor(t,r,a){let x=n;super(),this[x(667)]=null,Wt&&wx[x(880)+x(1546)]&&(this[x(667)]=wx[x(880)+x(1546)]({url:t,protocols:r,header:a,fail:this[x(1053)+x(233)+x(763)][x(411)](this),success:this[x(1053)+"ocketSuc"+x(690)+x(265)].bind(this)})),ft&&tt[x(880)+x(1546)]&&(this._socket=tt[x(880)+x(1546)]({url:t,protocols:r,header:a,fail:this[x(1053)+x(233)+x(763)][x(411)](this),success:this[x(1053)+x(1401)+x(690)+"ler"][x(411)](this)}))}["_createS"+n(1401)+n(690)+n(265)](){let t=n;Promise[t(998)]()[t(851)](()=>{this._addWsListeners()})}[n(1053)+n(233)+n(763)](t){let r=n,a={kMrGg:function(x,g,m){return e[R(545)](x,g,m)},dftPN:function(x,g,m){return e[R(865)](x,g,m)},NwSAm:e[r(829)]};Promise[r(998)]().then(()=>{let x=r,g=a[x(1563)](Ae,x(1181),{message:this[x(1259)+x(914)+x(1599)](t)});this[x(999)]("error",g);let m=a.dftPN(De,a[x(253)],{reason:this[x(1259)+x(914)+x(1599)](t)});this[x(999)](a.NwSAm,m)})}_addWsListeners(){let t=n,r={SXQby:"close",fMreN:function(a,x,g){return e.hJKFZ(a,x,g)}};this._socket[t(202)](a=>{let x=t,g={EjYEA:function(m,y){return e[R(744)](m,y)}};if(e[x(271)]===e.dQmXc)return YSahNI.EjYEA(this[x(414)+"ndex"],this[x(1395)+"s"][x(1606)])?!0:this[x(1003)+x(1310)+x(1262)+"t"]>this[x(480)+"es"];this[x(999)](x(337),e.jZNPp(os,e.hXcPH,{...a,data:a[x(187)]||""}))}),this[t(667)][t(845)](a=>{let x=t;this[x(999)](r.SXQby,r[x(708)](De,x(296),{...a}))}),this[t(667)][t(200)+"e"](a=>{let x=t;this[x(999)](e[x(1012)],ss(e[x(1012)],{...a}))}),this._socket[t(406)](a=>{let x=t;this[x(999)](e[x(268)],e[x(1365)](Ae,e.LLSYA,{...a,message:a[x(187)]||""}))})}[n(1470)](t){let r=n;if(e[r(1263)]("AntGn",e[r(908)])){if(this[r(1570)][r(847)+r(771)+"nect"]||this[r(935)+r(869)])return;this._handleReconnect()}else if(e[r(1565)](t,Uint8Array)){let a=t[r(798)].slice(t.byteOffset,e[r(1414)](t[r(683)+"th"],t[r(305)+"et"]));this._socket&&this[r(667)][r(1470)]({data:a,fail:x=>{let g=r;this[g(999)](e.LLSYA,Ae(g(1181),{message:this[g(1259)+g(914)+"age"](x)}))}})}else this._socket&&this[r(667)][r(1470)]({data:t,fail:a=>{let x=r;this.emit(e[x(268)],e[x(1448)](Ae,e[x(268)],{message:this[x(1259)+x(914)+x(1599)](a)}))}})}[n(296)](t,r){let a=n;this._socket&&this[a(667)][a(296)]({code:t,reason:r})}[n(621)+n(196)](t,r){this.on(t,r)}["removeEv"+n(623)+n(630)](t,r){this[n(333)](t,r)}get readyState(){let t=n;if(e[t(1055)]!==e[t(1055)]){let r=this[t(843)][t(1566)+t(315)+"nc"](this[t(640)]),a=_0x582bb2[t(1454)](r||"{}");return _0xb5da5e[t(727)](a)}else return this[t(667)][t(230)+"te"]}get binaryType(){let t=n,r={mjQxF:function(a,x,g){return e[R(674)](a,x,g)}};if(e[t(375)](e[t(1201)],t(433)))WTdppb.mjQxF(_0x19ac8d,_0x413a38,66),WTdppb[t(1417)](_0x5dea92,_0x1da896,_0x3af955[t(1606)]),WTdppb.mjQxF(_0x3e73e2,_0x246d64,_0x61d690);else return this[t(667)][t(715)+"pe"]}set[n(715)+"pe"](t){}get[n(747)](){let t=n;return this[t(667)][t(747)]}get[n(820)](){let t=n;return this._socket[t(820)]}get[n(703)+"ns"](){return this[n(667)].extensions}get[n(1311)+n(1611)](){let t=n;if(e[t(807)](t(586),t(586)))this[t(552)]=!0,this[t(300)]();else return 0}}function Vc(i,t){let r=n;if(t)return new t(i[r(747)],i[r(820)]);if(e[r(470)](Wt,ft))return new $c(i.url,i[r(820)],i[r(1260)]);if(e[r(470)](St,Jt)&&e[r(576)](e[r(465)],typeof WebSocket)&&WebSocket)return new WebSocket(i[r(747)],i[r(820)+"s"])}function Yc(i){let t=n;if(e[t(794)]===e[t(794)]){let r=(t(599)+"2").split("|"),a=0;for(;;){switch(r[a++]){case"0":if(i)return!0;continue;case"1":if(ft&&tt[t(880)+"ocket"])return!0;continue;case"2":return!1;case"3":if(Wt&&wx[t(880)+t(1546)])return!0;continue;case"4":if(e.JRpsP(St,Jt)&&e[t(1585)](t(980)+"d",typeof WebSocket)&&WebSocket)return!0;continue}break}}else{let r=_0x2c9db3(_0x56fa49),a=_0x5f078c[t(1050)];return _0x54b6c1[t(1050)]=e[t(752)](_0x5bfb9e[t(1149)],r),a}}function cs(i,t,r){let a=n,x={RWmnE:function(y,_){return e[R(458)](y,_)},ktGPk:e[a(636)],aIdej:function(y,_){return e.ZUJPY(y,_)},kfPFU:e[a(817)],xOcYG:function(y,_){return e[a(448)](y,_)}},g=-1;async function m(y){let _=a;if(x[_(229)]("vFSIo",x[_(1336)]))return x.aIdej(y,g)?Promise[_(842)](new Error(x[_(1554)])):(g=y,y===r[_(1606)]?Promise[_(998)]():r[y][_(411)](i)(t,m.bind(null,x[_(561)](y,1))));this[_(999)](_(1181),_0x4c3712),this[_(1227)]&&this[_(1227)](_0x12be6a)}m(0)}function ds(i){let t=n,r={tEOIF:function(g,m,y){return e[R(1226)](g,m,y)}},a=0,x=0;for(let g=0;g<i[t(1606)];++g)if(x=i[t(453)+"At"](g),x<128)a+=1;else if(e.uzUaB(x,2048))a+=2;else if(e[t(462)](e[t(1434)](64512,x),55296)&&e[t(1228)](e[t(948)](64512,i.charCodeAt(g+1)),56320)){if(e[t(694)](e.bPQGR,e[t(1587)]))return _0x501308[t(1029)][SgGYrn.tEOIF(_0x238b61,_0x497252,1)];++g,a+=4}else a+=3;return a}function xs(i,t,r){let a=n;if(r-t<1)return"";let x="";for(let g=t;e[a(645)](g,r);){let m=i[g++];if(m<=127)x+=String["fromChar"+a(1481)](m);else if(e[a(1299)](m,192)&&m<224)x+=String[a(1562)+a(1481)](e[a(742)](e[a(1459)](31&m,6),e[a(1200)](63,i[g++])));else if(m>=224&&m<240)x+=String[a(1562)+a(1481)](e[a(461)](e[a(775)](15,m),12)|e[a(317)](e[a(837)](63,i[g++]),6)|63&i[g++]);else if(e[a(1527)](m,240)){let y=e.lLKrY(e[a(1485)](e[a(1600)](e.NwNrR(7,m)<<18,e[a(1103)](e[a(1142)](63,i[g++]),12)),e[a(673)](63,i[g++])<<6)|e[a(890)](63,i[g++]),65536);x+=String[a(1562)+a(1481)](e.AVuiq(55296,e[a(716)](y,10))),x+=String[a(1562)+a(1481)](e[a(1044)](56320,e[a(207)](1023,y)))}}return x}function Br(i,t,r){let a=n,x={XogIE:e[a(829)],OAwGr:e[a(268)]};if(e[a(382)]("TJVSb",a(796)))this[a(1415)+a(1378)]?.[a(1616)](),this[a(999)](e.QPkPh,a(1184)),this[a(1415)+a(1378)]?.[a(1320)+a(1523)+"nt"]()?this._handleReconnect():this[a(1373)]();else{let g=r,m,y;for(let _=0;e[a(413)](_,i[a(1606)]);++_)if(m=i[a(453)+"At"](_),e[a(1106)](m,128))t[r++]=m;else if(m<2048)t[r++]=e[a(963)](m,6)|192,t[r++]=e[a(1600)](e[a(390)](63,m),128);else if((64512&m)===55296&&e.Ezagq(e[a(1556)](64512,y=i.charCodeAt(e.xoQjm(_,1))),56320)){let l=e[a(1024)][a(1354)]("|"),v=0;for(;;){switch(l[v++]){case"0":m=e[a(1212)](65536,e[a(1280)](e[a(892)](1023,m),10))+(1023&y);continue;case"1":++_;continue;case"2":t[r++]=e[a(1368)](e[a(963)](m,18),240);continue;case"3":t[r++]=e[a(1286)](e.kDTHi(e[a(716)](m,6),63),128);continue;case"4":t[r++]=e[a(1314)](e[a(1144)](m,12),63)|128;continue;case"5":t[r++]=e[a(1600)](e[a(1002)](63,m),128);continue}break}}else if(e[a(193)]!=="xoshM"){let l=(a(286)+"4")[a(1354)]("|"),v=0;for(;;){switch(l[v++]){case"0":this[a(1011)][a(1441)+a(623)+a(630)]("message",this[a(1039)+"ge"]);continue;case"1":this._ws[a(1441)+"entListe"+a(630)](a(337),this[a(1453)]);continue;case"2":if(!this[a(1011)])return;continue;case"3":this[a(1011)][a(1441)+a(623)+a(630)](x[a(1484)],this._onClose);continue;case"4":this[a(1011)]["removeEv"+a(623)+a(630)](x[a(1151)],this._onError);continue}break}}else t[r++]=e[a(368)](m>>12,224),t[r++]=e[a(871)](e[a(916)](m,6),63)|128,t[r++]=63&m|128;return r-g}}async function us(i){let t=n;if(t(387)==typeof i){let r=new Uint8Array(e[t(1411)](ds,i));return Br(i,r,0),r}return e.vUpZf(i,ArrayBuffer)?new Uint8Array(i):new Uint8Array(i[t(798)],i.byteOffset,i[t(683)+"th"])}function Xc(i){let t=n,r={ETlWw:function(a,x){return e[R(1499)](a,x)}};try{if(e[t(687)](e.okkTa,t(435)))return e[t(576)](e[t(626)],typeof i)&&(i instanceof ArrayBuffer||i[t(798)]&&e.vUpZf(i.buffer,ArrayBuffer))||t(387)!=typeof i?"":(JSON[t(1454)](i),e[t(439)]);{let a=t(972)+_0x4670b5+(" timeout"+t(907)+t(1503)+"ached");this[t(1420)](a),this[t(1363)+t(1574)+t(981)](e.OjSUX(_0x219ca5,e[t(268)],{message:a,code:_0x49e3eb[t(891)+t(676)+"R"]}));return}}catch{return e[t(384)]===e.EhHwB?e[t(323)](e[t(626)],typeof i)?e[t(1202)]:"":JxaFtW.ETlWw(_0x158022.offset,_0x2cbb86[t(1050)])}}let Qc=(i,t)=>{let r=n;switch(i){case r(1558):case e.uhrJU:return{[r(866)+i]:1,"x-tt-env":t};default:return{}}};class Zc{constructor(t){let r=n;this[r(1071)+"ount"]=t,this[r(1192)]=0}addCount(){let t=n;this[t(1192)]++}["checkRea"+n(1523)+"nt"](){let t=n;return this.count>=this[t(1071)+t(729)]}[n(1291)+n(795)](t=0){let r=n;this[r(1071)+r(729)]=t,this[r(1192)]=0}}async function e0(i){let t={WVXYL:e.YvXMj};return new Promise(r=>{let a=R,x={DSphh:function(g,m){return g(m)},stYjC:"unknown reason"};if(!St)return e[a(724)](r,a(1638)+a(1483));try{let g=document["createEl"+a(548)]("script");window[a(1626)+a(1123)]=m=>{let y=a;document[y(1492)][y(1564)+"ild"](g),window[y(1626)+y(1123)]=void 0,x[y(507)](r,m&&m[y(1385)]||x.stYjC)},g[a(1061)]=e[a(992)],g[a(759)]=e[a(1199)](i[a(898)](/^ws/,e[a(1397)]),e[a(1020)]);try{document.body[a(651)+a(1637)](g)}catch{if(e[a(1630)](e[a(524)],"qPMYV"))document[a(1492)][a(1564)+"ild"](g);else return{frameType:_0x3449cf,headers:[{key:a(1620)+a(523),value:t[a(319)]}],payload:void 0}}}catch{window[a(1626)+"JSONP"]=void 0,e.xwPoP(r,"unknown "+a(1483))}})}function rt(i,t,r){let a=n;return!!i?.find(x=>x[a(342)]===t&&x[a(474)]===r)}function Et(i,t){let r=n;return e[r(1504)](e[r(225)],e[r(1604)])?i?.find(a=>a[r(342)]===t)?.[r(474)]:this._socket[r(703)+"ns"]}let zr=null;async function t0(){let i=n;return zr||(zr=Promise[i(998)]()[i(851)](qe.bind(qe,e[i(404)]))),zr}class n0 extends Mr{constructor(t,r){let a=n;super(),this._dbName=t,this._keyPath=r,this[a(843)]=void 0,this[a(555)+a(373)]=null}async[n(1573)](){await this[n(1364)]()}async[n(1364)](){let t=n;if(!this[t(843)]){if(this[t(555)+t(373)])return this[t(555)+t(373)];try{let r=this._dbName,a=this._keyPath;this[t(555)+t(373)]=(async()=>{let x=t,{openDB:g}=await t0();this[x(843)]=await g(x(1626)+"_"+r,1,{upgrade(m){let y=x;if(y(797)==="cYStA"){let _=_0x50569f[y(1029)],l=_0x581626[y(1050)];return _[y(1606)]===l?_:_.subarray(0,l)}else m["createOb"+y(1307)+"e"](r,{keyPath:a})}})})(),await this[t(555)+t(373)]}catch(r){console[t(405)](r)}finally{this[t(555)+t(373)]=null}}}async[n(466)](t){let r=n,a={KcBiq:function(x,g){return e[R(1341)](x,g)},aGkgC:function(x,g){return e[R(1210)](x,g)}};try{return await this[r(1364)](),this[r(843)]?.[r(466)](this._dbName,t)}catch(x){if(e.IxyFD(e[r(685)],e[r(668)]))console[r(405)](x);else return function(...g){let m=r;return _0x1eee2a[m(1486)](GwXKnU[m(1491)](_0x1367ac,this),g),GwXKnU[m(826)](_0x4a28a3,_0x54a460[m(466)](this))}}}async[n(264)](t,r){let a=n;return await this[a(1364)](),this[a(843)]?.put(this[a(772)],t)}async[n(512)](t){let r=n;if(e[r(1402)](e[r(249)],r(1540)))try{return await this[r(1364)](),this[r(843)]?.delete(this[r(772)],t)}catch(a){console[r(405)](a)}else{if(!this[r(1011)])return;this[r(311)+r(1477)+"t"](_0x494f9d,_0x118933,_0x1fbe5d)}}async[n(240)](){let t=n;try{return await this._init(),this[t(843)]?.[t(240)](this[t(772)])}catch(r){console[t(405)](r)}}async[n(1590)](){let t=n;if(e[t(732)]!=="UfByt")return await this._init(),this[t(843)]?.[t(929)+"ys"](this._dbName);try{return!!this[t(843)]}catch(r){return _0x49bfa8.log(r),!1}}async[n(815)](){let t=n;return t(1644)!==e[t(1033)]?(_0x15453c[t(405)](t(648),_0x5dba13,_0x43318b,_0x4d65aa),this[t(843)][t(264)]({cursor_name:_0x103709,cursor:_0x6318d,service:_0x36e411})):(await this[t(1364)](),this[t(843)]?.[t(815)](this._dbName))}async[n(429)](){let t=n;try{this[t(843)]?.[t(296)](),this[t(843)]=void 0}catch(r){console[t(405)](r)}}get[n(1140)](){let t=n,r={nlaio:function(a,x){return e[R(499)](a,x)},hnYFZ:function(a,x,g){return a(x,g)},JRjnj:function(a,x,g,m){return e[R(245)](a,x,g,m)},hIClf:function(a,x){return e[R(1083)](a,x)},GBpJq:function(a,x,g){return e[R(707)](a,x,g)}};try{if(e.HnQSB(e[t(1552)],e[t(1552)])){let a=0,x=[];for(;r[t(1265)](a,_0x417cc4[t(683)+"th"]);){let{offset:g}=_0x40bf7e(_0x49b73d,a);a=g;let m={cursor_name:"",cursor:0,service:0},{value:y,offset:_}=_0x3fb0ce(_0x491fc5,a);m.service=y,a=_;let{value:l,offset:v}=r[t(1498)](_0xabc45e,_0x307d93,a);a=v,m["cursor_n"+t(1614)]=r[t(567)](_0x1678b8,_0x2dae36,a,r[t(1436)](a,l)),a+=l;let{value:C,offset:D}=r[t(1132)](_0x325f92,_0x2f0d03,a);m.cursor=C.toNumber(),a=D,x[t(1034)](m)}return x}else return!!this._qosDB}catch(a){return console[t(405)](a),!1}}}class r0{constructor(t,r){let a=n;this[a(583)]=t,this[a(1138)]=r,this[a(843)]=localStorage}async openDB(){}get _prefix(){let t=n;return t(1626)+"_"+this[t(583)]}async[n(466)](t){let r=n,a=this[r(843)][r(1621)](this[r(640)]);return JSON.parse(e[r(470)](a,"{}"))[t]}async[n(264)](t,r){let a=n,x=this[a(843)].getItem(this[a(640)]),g=JSON[a(1454)](e[a(1458)](x,"{}"));return g[r||t[this[a(1138)]]]=t,this[a(843)][a(938)](this._prefix,JSON[a(600)+"y"](g)),r||t[this[a(1138)]]}async del(t){let r=n,a=this[r(843)][r(1621)](this._prefix),x=JSON.parse(e[r(937)](a,"{}"));return x[t]=void 0,this[r(843)][r(938)](this[r(640)],JSON[r(600)+"y"](x))}async[n(240)](){let t=n,r={ksTaI:function(a,x){return e[R(1565)](a,x)},xMmSt:function(a,x){return e[R(607)](a,x)},ofjCD:e[t(761)],PpiCK:function(a,x){return e[t(1319)](a,x)}};if(e[t(306)]==="cdeja"){if(PQFuDG.ksTaI(_0x2381bf,_0xc3c878)){if(_0x51b3db===t(321))return _0x244d23[t(466)](_0x54928f);if(PQFuDG[t(303)](_0x1e01ba,t(959)+t(293)))return _0x282836[t(959)+t(293)]||_0x2bcc12[t(466)](_0x4849fc);if(_0x4b220d===PQFuDG[t(1532)])return _0x52ec5d[t(959)+t(293)][1]?void 0:_0x41e995["objectSt"+t(254)](_0x127cc8[t(959)+t(293)][0])}return PQFuDG[t(565)](_0x14e53a,_0x1371e1[_0x136058])}else return this[t(843)][t(240)]()}async[n(1590)](){let t=n;if(e[t(1423)]!==e[t(551)]){let r=this[t(843)][t(1621)](this[t(640)]),a=JSON[t(1454)](e[t(937)](r,"{}"));return Object[t(1590)](a)}else return _0x2aa86e.resolve()}async[n(815)](){let t=n,r=this[t(843)][t(1621)](this[t(640)]),a=JSON[t(1454)](e.jlBis(r,"{}"));return Object.values(a)}[n(429)](){let t=n,r={MYMvU:function(a,x){return e[R(1489)](a,x)},Fsoik:function(a,x){return e[R(399)](a,x)},etfoo:function(a,x){return e[R(511)](a,x)},CbJCs:function(a,x){return e[R(461)](a,x)},elRcZ:function(a,x){return a>>>x},flrek:function(a,x){return a|x},bpkca:function(a,x){return a|x}};return e[t(1504)](e.pmsJU,"QTViI")?Promise[t(998)]():AELyvk.MYMvU(_0x2a63f6,_0x51f170)?_0x114e77:new _0x4e0170(AELyvk[t(417)](AELyvk[t(313)](_0x3c2a5c.call(_0x547707,0),_0x14bee6[t(1518)](_0x23d6aa,1)<<8)|AELyvk[t(765)](_0x6172b5[t(1518)](_0x9d2fa2,2),16)|AELyvk[t(765)](_0x553187[t(1518)](_0x506f52,3),24),0),AELyvk[t(768)](AELyvk[t(1279)](AELyvk[t(1058)](_0x367dcf.call(_0x398ec5,4),AELyvk[t(765)](_0x496b23[t(1518)](_0x1ed0ca,5),8))|AELyvk[t(765)](_0x401296[t(1518)](_0x1b4b90,6),16),_0x2222b8.call(_0x290743,7)<<24),0),!0)}get isReady(){return!!this[n(843)]}}class i0{constructor(t,r){let a=n;this[a(583)]=t,this[a(1138)]=r,this[a(843)]=ft?tt:Wt?wx:null}async openDB(){}get[n(640)](){return n(1626)+"_"+this._DBName}async[n(466)](t){let r=n,a=this[r(843)][r(1566)+r(1388)](this[r(640)]);return JSON[r(1454)](e[r(1458)](a,"{}"))[t]}async[n(264)](t,r){let a=n,x=this[a(843)]["getStora"+a(1388)](this._prefix),g=JSON[a(1454)](e[a(470)](x,"{}"));return g[r||t[this[a(1138)]]]=t,this[a(843)]["setStora"+a(1388)](this[a(640)],JSON[a(600)+"y"](g)),r||t[this[a(1138)]]}async[n(512)](t){let r=n,a=this[r(843)]["getStora"+r(1388)](this[r(640)]),x=JSON[r(1454)](e[r(937)](a,"{}"));return x[t]=void 0,this[r(843)][r(1007)+"geSync"](this[r(640)],JSON[r(600)+"y"](x))}async clear(){let t=n;return this[t(843)][t(652)+t(489)]()}async[n(1590)](){let t=n,r=this[t(843)][t(1566)+t(315)+"nc"](this[t(640)]),a=JSON[t(1454)](e[t(1458)](r,"{}"));return Object.keys(a)}async getAll(){let t=n,r=this[t(843)][t(1566)+t(315)+"nc"](this[t(640)]),a=JSON[t(1454)](e[t(733)](r,"{}"));return Object.values(a)}[n(429)](){return Promise.resolve()}get[n(1140)](){return!!this[n(843)]}}function fs(i,t){let r=n;if(e.jlBis(ft,ft))return new i0(i,t);if(e[r(733)](St,Jt)&&e[r(576)](r(980)+"d",typeof indexedDB))return new n0(i,t);if(e[r(470)](St,Jt)&&e.PtkWq(e[r(465)],typeof localStorage))return new r0(i,t);throw new Error(e.dvTvH)}class s0{constructor(){let t=n,r={OMQGz:function(a,x,g){return e[R(987)](a,x,g)}};e[t(1270)](e[t(1361)],e[t(1361)])?(_0x86c6e8(_0x18486b,90),OJlZhX[t(1219)](_0x474367,_0x58aec3,_0x9761ac)):(this._intervalTimeoutId=null,this[t(1276)+"l"]=36e5,this[t(843)]=e[t(865)](fs,e.aCwsr,e.ohmdq))}async[n(1276)+n(441)](){let t=n;e.JCEPz(clearInterval,this[t(1276)+t(289)+"Id"]),this["_interva"+t(289)+"Id"]=setInterval(()=>{let r=t;this[r(351)+r(1360)]()},this[t(1276)+"l"])}async[n(1573)](){let t=n;await this._qosDB.openDB()[t(851)](()=>{this["_interva"+t(441)]()})}async[n(351)+n(1360)](){let t=n,r={NseEW:function(a,x){return e[R(467)](a,x)},Irmrc:e[t(379)]};if(e.nTZtH(t(1038),e[t(1405)]))return this[t(1395)+"s"][this["currentI"+t(213)]];(await this[t(843)]?.[t(815)]()||[])[t(597)](({timestamp:g})=>g<Date.now())[t(913)](g=>{let m=t;if(r[m(423)](r[m(540)],r.Irmrc))return _0x149324(_0x4020f6);this[m(843)]?.del(g[m(719)+"id"])})}async[n(512)](t){let r=n;return this[r(843)]?.[r(512)](t)}async set(t,r){return this[n(843)]?.set({message_id:t,timestamp:r})}async[n(466)](t){let r=n;return this._qosDB?.[r(466)](t)}async[n(429)](){let t=n;if(e[t(211)](e[t(575)],e.onzdQ))return _0x4108da[t(234)+"8"]?{value:_0x51ed78[t(234)+"8"](_0x5cb646),offset:_0x35aefe+1}:{value:e[t(989)](255,_0x3cc4e4[_0x3be187]),offset:e.tuCAQ(_0x26ed73,1)};e[t(1442)](clearInterval,this[t(1276)+"lTimeoutId"]),await this[t(843)]?.[t(429)]()}get[n(1140)](){let t=n;return this[t(843)]?.[t(1140)]}}function Fr(i){let t=n,r=!!this[t(1570)].enableQoS;if(!r)return{enabled:r,isQoSMessage:!1,isQoSAck:!1,isAckCleanupMessage:!1,ackMsgIds:[]};let a=e[t(245)](rt,i[t(1422)].headers,t(746)+t(1551),"2"),x=a&&rt(i[t(1422)][t(1260)],e.zbbdf,"1"),g=a&&rt(i[t(1422)][t(1260)],e[t(1439)],"1"),m=g?e[t(1086)](Et,i[t(1422)][t(1260)],t(746)+t(386)+t(359))?.[t(1354)](",")[t(597)](Boolean)||[]:[];return{enabled:r,isQoSMessage:a,isQoSAck:x,isAckCleanupMessage:g,ackMsgIds:m}}async function ls(){let i=n;return this[i(357)+i(725)]||(this[i(357)+i(725)]=new s0),this[i(357)+i(725)].isReady||await this[i(357)+i(725)].openDB(),this[i(357)+i(725)]}async function o0(i,t){let r=n,{enableAutoAck:a}=this._options,x=e[r(245)](rt,i[r(1422)][r(1260)],e[r(1246)],"1"),g=e.mJDOW(rt,i[r(1422)][r(1260)],e[r(560)],"1"),m=Fr.call(this,i);if(a&&x){let{SeqID:y,LogID:_,service:l,LogIDNew:v,method:C}=i[r(1422)];this[r(1163)]({SeqID:y,LogID:_,LogIDNew:v,service:l,method:C,headers:[{key:e[r(560)],value:"1"},{key:r(832),value:v||""},{key:e.cQZJU,value:"0"}]})}g&&!m[r(1217)]&&this[r(1363)+r(693)+r(702)](i),e[r(864)](t)}async function a0(i,t){let r=n;e[r(389)]===e[r(713)]?this._listeners={}:(this[r(1420)](e[r(1473)],i[r(1422)]),e.NTaEi(t))}async function c0(i,t){let r=n,a=_t(await e[r(1595)](us,i[r(680)]));try{if(e[r(1565)](a.payload,Uint8Array)){let x=e.RrZOy(this._options[r(1309)+r(882)],Object)?{force:!!this[r(1570)][r(1309)+"ncoding"][r(422)],encoding:this[r(1570)][r(1309)+r(882)][r(940)]?this[r(1570)][r(1309)+r(882)][r(940)].replace(/\s/g,"")[r(1150)+"ase"]():""}:{force:!1,encoding:this[r(1570)]["payloadE"+r(882)]?this[r(1570)]["payloadE"+r(882)][r(898)](/\s/g,"")[r(1150)+"ase"]():""},g=a[r(1309)+r(882)]?a.payloadEncoding[r(898)](/\s/g,"")[r(1150)+r(897)]():"",m=e[r(1565)](this[r(1570)][r(332)+"ype"],Object)?{force:!!this[r(1570)][r(332)+r(1542)][r(422)],type:this._options[r(332)+r(1542)][r(1061)]?this[r(1570)].payloadType[r(1061)][r(898)](/\s/g,"")[r(1150)+r(897)]():""}:{force:!1,type:this[r(1570)][r(332)+r(1542)]?this._options[r(332)+"ype"].replace(/\s/g,"")[r(1150)+r(897)]():""},y=a[r(332)+r(1542)]?a[r(332)+r(1542)][r(898)](/\s/g,"")[r(1150)+r(897)]():"",_=m.force?m[r(1061)]:y||m[r(1061)],l=x.force?x[r(940)]:g||x[r(940)],v=[e[r(1202)],r(1451)+r(1101),e.QvZWR,e.vhniu],C=[e[r(1431)],e[r(1571)]];this._options["enableTr"+r(1177)+r(1545)+"ad"]&&v.includes(_)&&(!l||C[r(979)](l))?a[r(714)+r(199)]=e[r(624)](xs,a[r(1627)],0,a[r(1627)][r(683)+"th"]):a[r(714)+r(199)]=""}else a[r(714)+r(199)]=""}catch(x){a[r(714)+r(199)]="",console[r(405)](x)}i[r(1422)]=a,e[r(887)](t)}function d0(i,t,r){let a=n,x={Jsonr:function(l,v){return e[R(635)](l,v)},FgtmI:function(l,v){return l>v},fjDYB:function(l,v){return e[R(505)](l,v)},qyEAX:function(l,v){return e.kgipt(l,v)},KjWXp:function(l,v){return e.Jtnxt(l,v)},rLTQm:function(l,v){return e[R(1121)](l,v)}},g=e.CYQIz(r,8192),m=e[a(852)](g,1),y=null,_=g;return function(l){let v=a;if(l<1||x[v(1528)](l,m))return i(l);x[v(362)](x[v(481)](_,l),g)&&(y=x[v(1404)](i,g),_=0);let C=t[v(1518)](y,_,_+=l);return x[v(1432)](7,_)&&(_=x[v(481)](x[v(1579)](7,_),1)),C}}let x0=4294967295;function u0(i,t,r){let a=n;return e[a(1074)](RangeError,e.URzKH(e[a(572)](e[a(856)](e[a(218)](e[a(1195)],i),a(1333)),t||1)+a(1348),r))}function f0(i,t,r){let a=n,x={IGVCr:e[a(491)]};if(e[a(633)](e[a(1154)],e[a(1154)])){if(e.KAzNl(r,x0))throw new Error(e[a(770)]);let g=3;for(;e.SpYEE(g,0);){let m=e[a(1142)](255,r);e[a(434)](qr,m,i,e[a(505)](t,g)),r>>>=8,g--}return e[a(292)](t,4)}else{if(!this[a(1514)+a(210)]()||this[a(935)+"osed"])return;this[a(957)+a(1640)]?.["resetEnd"+a(804)+a(1516)](),this[a(1415)+a(1378)]?.["resetCou"+a(795)](),this[a(1011)]?this[a(1118)+a(1027)](1001,x.IGVCr,!0):this[a(300)]()}}function l0(i,t){let r=n,a=0,x=t,g=e[r(1487)](t,4);for(;e[r(625)](x,g);)if(e.RRFcJ!==e[r(844)])e[r(245)](_0xb49ef0,this,_0x5dbd56,[_0x1164e5,_0x5d31b5,_0x5b8b3d]);else{let{value:m,offset:y}=e.Uwgkw(Ur,i,x);x=y,a=e.mEAAZ(a,8)>>>0,a+=m}return{value:a,offset:g}}function g0(i,t,r){let a=n,x=e[a(267)][a(1354)]("|"),g=0;for(;;){switch(x[g++]){case"0":if(i.length<40)return e[a(1006)](Br(i,t,r),r);continue;case"1":if(t[a(598)])return t[a(598)](i,r)+r;continue;case"2":return e[a(1212)](e.NKwYr(Br,i,t,r),r);case"3":if(!i)return r;continue;case"4":if(t[a(848)+"e"])return t[a(848)+"e"](i,r)+r;continue}break}}function h0(i,t){let r=n,a=new K(e[r(1538)](i[e[r(752)](t,4)]<<24,e[r(261)](i[e[r(292)](t,5)],16))|i[e[r(1308)](t,6)]<<8|i[t+7],e[r(1353)](e.fnXRm(e[r(1017)](i[e.PgJuQ(t,0)],24),e[r(1017)](i[t+1],16))|e[r(782)](i[e.FvPld(t,2)],8),i[t+3]),!0);return t+=8,{value:a,offset:e[r(536)](t,8)}}function p0(i,t,r){let a=n;if(e[a(295)](a(594),e.kzjah)){let x=i.low,g=i[a(532)];return t[r]=e[a(1030)](g,24),t[e.EMylN(r,1)]=e[a(574)](g,16)&255,t[e[a(1008)](r,2)]=e.yqLvw(e.wPgAM(g,8),255),t[r+3]=e[a(810)](255,g),t[e[a(1006)](r,4)]=e[a(1171)](x,24),t[r+5]=e[a(1539)](x>>>16,255),t[r+6]=e[a(1541)](x,8)&255,t[e[a(856)](r,7)]=e[a(1555)](255,x),r+=8,r}else this.emit(e[a(268)],e[a(1450)](_0x417fe8,e.LLSYA,{message:this["_formatE"+a(914)+a(1599)](_0xfde039)}))}function Ur(i,t){let r=n;return e.uuFJw(e[r(208)],e[r(208)])?(this[r(1003)+r(1310)+r(1262)+"t"]++,this[r(252)+r(1586)+"nt"]()):i[r(234)+"8"]?{value:i[r(234)+"8"](t),offset:t+1}:{value:e.EWOFq(255,i[t]),offset:t+1}}function qr(i,t,r){let a=n;return t[a(1001)+"t8"]?t[a(1001)+"t8"](i,r):t[r]=e[a(1512)](255,i),e.VFQyh(r,1)}let m0=function(i){let t=n,r={PAuUd:function(a,x,g,m){return e.Gneut(a,x,g,m)}};if(e[t(1504)](e[t(803)],t(1190)))return new Uint8Array(i);{let a=new _0x1a5215(_0x2e2c2a(_0x3dd3ac));return XMnboJ[t(1134)](_0x33eaa6,_0x42207d,a,0),a}},w0=e.TjZev(n(980)+"d",typeof Buffer)?Buffer[n(643)+n(874)]:e[n(1389)](d0,m0,Uint8Array[n(1444)+"e"][n(427)]),_0=16,Gr=32;function y0(i){let t=n,r=0,a={};for(let x=0;e.PjbUz(x,i[t(1606)]);x++)a[i[x]["cursor_n"+t(1614)]]=e[t(724)](ds,i[x]["cursor_n"+t(1614)]),r+=14+a[i[x][t(483)+t(1614)]];return[r,a]}function gs(i,t,r){let a=n,x={FBjSo:a(932)+a(194),FeARk:function(l,v,C,D){return e.NKwYr(l,v,C,D)},wrHxy:e[a(988)],xWxnw:function(l,v,C,D){return e[a(624)](l,v,C,D)},wNHQD:e[a(965)],VQeYn:function(l,v,C,D){return l(v,C,D)},JWFFR:e[a(420)],jQSfc:e.idOGt,LEIjB:e[a(1014)]},[g,m]=y0(i),y=e[a(307)](w0,g),_=0;return i[a(913)](l=>{let v=a;console[v(405)](x[v(1370)],l,l[v(452)]),_=x[v(1618)](qr,0,y,_),console[v(405)](x[v(1494)],_),_=x[v(1115)](f0,y,_,l[v(452)]||0),console.log(x[v(571)],_),_=x.VQeYn(qr,m[l.cursor_name],y,_),console[v(405)](x[v(258)],_),_=x[v(1618)](g0,l[v(483)+v(1614)],y,_),console[v(405)](x[v(942)],_),_=x[v(628)](p0,K[v(1356)+"er"](l[v(1285)]||t),y,_),console[v(405)](x[v(1381)],_)}),{frameType:Gr,headers:[{key:e[a(217)],value:r}],payload:y}}function b0(i){let t=n;if(e[t(241)](e[t(352)],e[t(824)]))_0x2481d9[t(1626)+t(1123)]=void 0,_0x2c87cd(e[t(1031)]);else{let r=0,a=[];for(;r<i.byteLength;){let{offset:x}=Ur(i,r);r=x;let g={cursor_name:"",cursor:0,service:0},{value:m,offset:y}=l0(i,r);g[t(452)]=m,r=y;let{value:_,offset:l}=e[t(867)](Ur,i,r);r=l,g[t(483)+t(1614)]=xs(i,r,e[t(1619)](r,_)),r+=_;let{value:v,offset:C}=h0(i,r);g[t(1285)]=v[t(1416)](),r=C,a[t(1034)](g)}return a}}function v0(){let i=n;return{frameType:Gr,headers:[{key:e[i(217)],value:e[i(1256)]}],payload:void 0}}class S0{constructor(t,r,a){let x=n;this._cursorNameSpace=t,this[x(679)+x(1172)]=r,this["_message"+x(1234)]=a,this._qosDB=e[x(367)](fs,this[x(1137)+x(407)],x(483)+x(1614))}async[n(1573)](){await this[n(843)].openDB()}async[n(412)+"rs"](){let t=n;if(!this[t(843)][t(1140)])return;let r=this[t(1056)+t(1234)],a=await this._qosDB[t(815)]();switch(console[t(405)](e[t(924)],a),r){case e[t(1088)]:return a&&a[t(1606)]?gs(a,0,this[t(679)+t(1172)]):void 0;case e[t(228)]:return;case e[t(1274)]:return a&&a[t(1606)]?e[t(1366)](gs,a,0,this[t(679)+"ileName"]):e[t(1250)](v0)}}async[n(264)](t,r,a){let x=n;if(e[x(380)](e.OqjDe,x(1133)))return console[x(405)](e[x(954)],t,r,a),this[x(843)][x(264)]({cursor_name:t,cursor:r,service:a});this[x(552)]=!0,this[x(300)]()}async[n(274)+"rs"](t){let r=n,a=e[r(1595)](b0,t);for(let x of a)console[r(405)](r(1113)+"r",a),await this._qosDB[r(264)](x)}async[n(466)](t){let r=n;return(await this[r(843)][r(466)](t))?.[r(1285)]}async[n(429)](){let t=n;await this[t(843)][t(429)]()}[n(931)+n(777)+n(554)](t){let r=n;this[r(679)+r(1172)]=t}get[n(1140)](){let t=n;return this[t(843)][t(1140)]}}let E0=n(381)+n(799);async function hs(i){let t=n,r={xCVEa:function(a,x){return a(x)},UKTyK:function(a,x){return a+x},HakVy:e.QKCet,UDaAI:t(456)};if(e[t(430)](e[t(941)],"SQMJd")){if(!this[t(1570)].enableQoS)return null;let{aID:a,fpID:x,messageStrategy:g}=this._options,m=i||E0;try{if(this[t(1043)+t(1403)])if(e[t(492)]===e[t(906)]){let y=_0x38a7bc[t(1354)](/\./)[t(753)](v=>_0x289202(v)),_=[];return _[0]=dSXVUL[t(488)](_0x31c076,dSXVUL[t(1609)](y[0],y[1])),_[1]=dSXVUL[t(488)](_0x33b323,dSXVUL[t(1609)](y[2],y[3])),[dSXVUL[t(758)],"0000",t(1164),dSXVUL.HakVy,t(1164),dSXVUL[t(1059)],_[0],_[1]][t(828)]("")}else i&&this["_cursorM"+t(1403)][t(931)+"rsorFile"+t(554)](i);else this["_cursorM"+t(1403)]=new S0(x+"_"+a+"_"+m,m,g);return this["_cursorM"+t(1403)][t(1140)]||await this[t(1043)+t(1403)][t(1573)](),this["_cursorM"+t(1403)]}catch{return null}}else try{this._qosDB?.[t(296)](),this._qosDB=void 0}catch(a){_0x4a1c41[t(405)](a)}}async function I0(i,t){let r=n,a=e[r(245)](rt,i.message[r(1260)],r(692),"-1"),x=e.RNaUu(rt,i[r(1422)][r(1260)],e[r(560)],"1"),g=Et(i[r(1422)][r(1260)],"x_fronti"+r(541)),m=e[r(1221)](Number,e[r(1080)](Et,i.message[r(1260)],r(746)+r(1391)))||0,y=Fr.call(this,i),_=e.Gneut(rt,i[r(1422)][r(1260)],"x-msg-qos","2"),l=e[r(707)](Et,i[r(1422)].headers,e[r(360)]),v=e[r(984)](Number,e[r(517)](Et,i[r(1422)].headers,e.QDvEN));if(y.isQoSAck)return t();let C=y[r(610)+r(1251)]?await ls[r(1518)](this):null;if(i.message[r(452)]>0&&x&&!a||i[r(1422)].service>0){if(g&&y[r(610)+r(1251)]&&C){if(!!!await C[r(466)](g)){if(e.yjwIp("yKIcX",r(791)))return!!this[r(843)];this[r(1363)+"hMessage"+r(1386)](i),await C[r(264)](g,e[r(516)](Date.now(),m))}return e[r(677)](t)}if(_){let D=await hs[r(1518)](this);if(!D)return this[r(1363)+"hMessage"+r(1386)](i),e.DpWwo(t);let F=await D[r(466)](l)??-1;if(e[r(1204)](F,v))this["_dispatc"+r(642)+r(1386)](i),D[r(264)](l,v,i.message[r(452)]);else throw new Error(r(521)+" message cursor "+v+(r(1327)+r(930)+r(1437)+"r ")+F);return e.Vsufu(t)}return this._dispatchMessageEvent(i),t()}}async function A0(i,t){let r=n,a=Fr[r(1518)](this,i);if(!a[r(610)+"sage"])return e[r(1250)](t);let x=await ls[r(1518)](this);if(a[r(1318)+r(1500)+"age"]&&a.ackMsgIds.length)for(let g of a[r(347)+"s"])await x[r(512)](g);e[r(696)](t)}async function T0(i,t){let r=n,a=e[r(617)](i[r(1422)][r(1642)+"e"],_0),x=i[r(1422)][r(1642)+"e"]===Gr;if(!a&&!x)return e[r(1524)](t);let g=e[r(616)](Et,i.message[r(1260)],r(1620)+r(523));if(!g)return e[r(1211)](t);let m=await hs.call(this,g);if(!m)return e.TuzKJ(t);if(a){let y=await m[r(412)+"rs"](),_={frameType:y?.["frameType"],SeqID:K[r(1356)+"er"](this._seqId++),LogID:K[r(1356)+"er"](this[r(1570)][r(1496)+r(1189)]()),service:9e3,method:5,headers:y?.headers,payload:y?.[r(1627)]},l=e.GVtyv(E,_);this[r(1011)]&&this[r(1011)][r(230)+"te"]&&this[r(1011)].send(l)}if(x)if(e[r(1009)](e[r(534)],e.laKvD)){let y=i[r(1422)][r(1627)];y&&m.setCursors(y)}else{let y=this[r(1570)][r(1309)+"ncoding"]instanceof _0x32ae75?{force:!!this._options[r(1309)+r(882)].force,encoding:this[r(1570)][r(1309)+r(882)][r(940)]?this[r(1570)]["payloadE"+r(882)][r(940)][r(898)](/\s/g,"")[r(1150)+r(897)]():""}:{force:!1,encoding:this[r(1570)].payloadEncoding?this[r(1570)][r(1309)+"ncoding"].replace(/\s/g,"")[r(1150)+"ase"]():""},_=_0x7326d9[r(1309)+r(882)]?_0x3e18ba[r(1309)+r(882)].replace(/\s/g,"")[r(1150)+"ase"]():"",l=e.vUpZf(this[r(1570)][r(332)+r(1542)],_0x21c926)?{force:!!this._options[r(332)+r(1542)][r(422)],type:this[r(1570)][r(332)+r(1542)][r(1061)]?this[r(1570)][r(332)+r(1542)][r(1061)][r(898)](/\s/g,"")[r(1150)+r(897)]():""}:{force:!1,type:this[r(1570)][r(332)+r(1542)]?this[r(1570)][r(332)+r(1542)][r(898)](/\s/g,"")[r(1150)+r(897)]():""},v=_0x328d33[r(332)+r(1542)]?_0x4b240a[r(332)+r(1542)][r(898)](/\s/g,"")[r(1150)+r(897)]():"",C=l.force?l.type:v||l.type,D=y.force?y[r(940)]:_||y.encoding,F=["text/pla"+r(1513)+"et=utf-8",r(1451)+r(1101),e[r(237)],e.vhniu],U=[e[r(1431)],e[r(1571)]];this[r(1570)]["enableTr"+r(1177)+r(1545)+"ad"]&&F[r(979)](C)&&(!D||U[r(979)](D))?_0x5a824a.textPayload=_0x7a65ff(_0x4a0336[r(1627)],0,_0x4fecdc.payload.byteLength):_0x1742e0["textPayl"+r(199)]=""}}let P0=async function(i,t){let r=n;this[r(552)]=!1,e.UduLe(clearTimeout,this[r(300)+r(503)+r(487)]),e[r(1283)](t)},C0=async function(i,t){let r=n,a={FirwT:e[r(1394)]};if(!this[r(1011)]||this[r(1011)][r(230)+"te"]!==this[r(1605)])return e[r(612)](t);let{pingInterval:x}=this[r(1570)];this[r(957)+r(1640)]?.[r(1018)+r(804)+r(1516)]();for(let m=0;e[r(863)](m,this[r(1056)+r(990)][r(1606)]);m++)if(e.hWxCQ("vuaJD","Tpfld")){let y=this[r(1056)+r(990)][m];if(e[r(495)](this[r(1011)][r(230)+"te"],this.OPEN)&&y!==null)this._ws&&this[r(1011)][r(1470)](y),this[r(1056)+r(990)][m]=null;else break}else{let y=/(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}/[r(705)](_0xbe8078),_=/(([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(_0x54d01f);return y?_0x3a8733(_0x389ab2):_?_0x3f4770(_0x3ce4bb):SGQfSw[r(1409)]}this["_message"+r(990)]=this[r(1056)+"Queue"][r(597)](m=>!!m),this[r(1537)+r(1129)+"Id"]=e[r(706)](setTimeout,()=>this[r(1373)](),x),this[r(1363)+r(1098)+"nt"](i),this[r(235)+"er"]&&this[r(1011)]&&(this._ws[r(715)+"pe"]=this[r(903)+r(1542)]);let g=this[r(957)+r(1640)]?.["getCurre"+r(1586)+"nt"]();this[r(1420)](r(672)+g+r(1317)),e[r(1508)](t)},k0=async function(i,t){let r=n,a={SlejF:function(x,g){return e.gOIbj(x,g)},epMRX:function(x,g){return e.XWjnD(x,g)}};if(e[r(189)]===e[r(697)]){let{initReconnectInterval:x,maxReconnectInterval:g,reconnectIntervalGrowFactor:m}=this[r(1570)],y=x*_0x588caf[r(698)](m,a[r(369)](_0x2b3db7,1));return a[r(952)](y,g)?g:y}else{let x=this[r(957)+"tManager"]?.[r(252)+r(1586)+"nt"]();this[r(1420)]("open "+x),e.zZJNS(t)}};class D0 extends Mr{constructor(t){let r=n,a={OBUTg:function(_,l,v,C){return e[R(624)](_,l,v,C)},WYcth:function(_,l,v){return e.HqLdF(_,l,v)},AjclS:r(1181),BRBCn:function(_,l){return e[r(1228)](_,l)},GKsCg:r(1344),ILGrn:function(_,l){return e.vOYQm(_,l)},xmZIH:function(_,l){return e[r(977)](_,l)},khVWH:function(_,l){return e[r(589)](_,l)},HCYPe:function(_,l,v){return e.TrRgv(_,l,v)},KXrNL:function(_){return _()},rEbTa:function(_,l,v,C){return _(l,v,C)}};super(),this[r(533)+r(1028)+"line"]=!0,this[r(235)+"er"]=St,this[r(1064)]=Jc,this[r(538)+"T"]=ft,this[r(1112)+"X"]=Wt,this[r(297)+"r"]=Jt,this._messageQueue=[],this[r(957)+r(1640)]=null,this[r(935)+r(869)]=!1,this["_binaryT"+r(1542)]=e[r(428)],this[r(300)+r(1087)]=!1,this[r(300)+r(503)+r(487)]=null,this[r(410)+r(743)+r(819)]=null,this[r(1537)+r(1129)+"Id"]=null,this[r(349)]=0,this._isInit=!1,this[r(1180)]="",this["_QoSMana"+r(725)]=null,this[r(1043)+r(1403)]=null,this[r(1415)+r(1378)]=null,this[r(438)+"ls"]=r(1277),this[r(781)]=3,this.CONNECTING=0,this[r(1605)]=1,this[r(1474)]=2,this[r(1453)]=_=>{let l=r;try{a.OBUTg(cs,this,_,[P0,C0,k0])}catch(v){let C=a[l(739)](Ae,a[l(294)],{message:v[l(1422)],code:nt[l(1382)+"OR"],error:v});this[l(1363)+l(1574)+l(981)](C)}},this[r(1039)+"ge"]=async _=>{let l=r,{pingInterval:v,pingFrequency:C}=this[l(1570)];if((e[l(919)]("hi",_[l(680)])&&e[l(324)]===C||e[l(629)](e[l(606)],C))&&(this[l(1023)+"ngTimer"](),this[l(999)](e[l(553)],e[l(1475)]),this[l(1537)+l(1129)+"Id"]=e[l(1278)](setTimeout,this[l(1373)].bind(this),v)),!e[l(528)]("hi",_[l(680)]))try{e[l(1343)](cs,this,_,[c0,o0,A0,T0,I0,a0])}catch(D){let F=e[l(513)](Ae,e.LLSYA,{message:D[l(1422)],code:nt[l(854)+l(734)],error:D});this[l(1363)+l(1574)+l(981)](F)}},this._onError=_=>{let l=r,v=this["_endpoin"+l(1640)]?.[l(1320)+l(830)+"es"](),C=this[l(957)+l(1640)]?.[l(252)+l(1586)+"nt"]();if(v&&!_[l(1422)]){let D=l(972)+C+(l(1238)+l(878)+l(1433)+"ed");this[l(1363)+"hErrorEv"+l(981)](e[l(545)](Ae,e[l(268)],{message:D,code:nt["MAX_RETR"+l(676)+"R"],error:_}));return}this[l(1011)]&&this[l(1011)][l(230)+"te"]===this[l(1605)]&&this[l(1118)+l(1027)](),this[l(1363)+l(1574)+l(981)](e.stjhA(Ae,e.LLSYA,{message:_[l(1422)],code:nt[l(455)+"RROR"],error:_}))},this[r(960)]=async _=>{let l=r;this[l(1635)+l(270)](),this[l(1023)+l(1157)](),this[l(440)+l(691)+"rs"](),this[l(1011)]=null,this._connectLock=!1;let v=this[l(957)+"tManager"]?.checkReachMaxTries();if(!v&&this[l(1514)+l(210)]()&&!this[l(935)+l(869)]){let C=this[l(957)+l(1640)]?.[l(252)+l(1586)+"nt"](),D=this._options["reconnec"+l(603)+l(895)](_.code,_[l(1483)]);this["_dispatc"+l(1530)+l(981)](De(l(296),{code:1006,reason:_.reason||l(299)+l(449)+"d, unkno"+l(463)+l(1497)+l(1517)+C,willReconnect:D})),D&&this[l(300)]();return}if(e[l(805)](1e3,_[l(692)])&&this["_readyCl"+l(869)]){this[l(1363)+l(1530)+"ent"](e.TucFT(De,e[l(829)],{code:1e3,reason:e.BFisd})),this[l(957)+l(1640)]?.[l(1018)+l(804)+l(1516)](),this[l(1415)+l(1378)]?.[l(1291)+l(795)]();return}if(e.FPwNp(1e3,_[l(692)])&&v){let C=this[l(957)+l(1640)]?.["getCurre"+l(1586)+"nt"](),D=_[l(1483)];D||(D=await e.WiRTK(e0,this._url)),D=l(299)+"ng faile"+l(500)+D+(l(219)+"me: ")+C+(l(907)+l(1503)+l(1159)),this["_dispatc"+l(1530)+"ent"](De(e[l(829)],{code:_[l(692)],reason:D}));let F=l(972)+C+(l(1238)+l(878)+l(1433)+"ed");this["_dispatc"+l(1574)+l(981)](Ae(e[l(268)],{message:F,code:nt["MAX_RETR"+l(676)+"R"]})),this._endpointManager?.[l(1018)+l(804)+"fig"](),this[l(1415)+l(1378)]?.[l(1291)+l(795)]();return}if(_[l(692)]!==1e3&&!_.reason){if(e.oHAqh!==e[l(1232)])return OdBwYH[l(657)](typeof _0x2dadd6,OdBwYH[l(1480)])?OdBwYH[l(967)](_0x206fad,_0x114919):(OdBwYH[l(1272)](_0x3ae48f,_0x50c7a6)&&OdBwYH.khVWH(_0x1147fb,_0x1ee078),OdBwYH[l(327)](_0x31e2b0,_0x1319f6,OdBwYH[l(401)](_0x49aff5))?new _0x1f25c6(_0x128df6,_0x27fafa):_0x3bf1b5);{let C=this[l(957)+l(1640)]?.[l(252)+l(1586)+"nt"]();this[l(1363)+l(1530)+"ent"](e[l(436)](De,e[l(829)],{code:_.code,reason:l(299)+l(449)+l(613)+l(463)+l(1497)+l(1517)+C})),this[l(957)+l(1640)]?.[l(1018)+l(804)+"fig"](),this[l(1415)+l(1378)]?.[l(1291)+l(795)]();return}}this._dispatchCloseEvent(_),this[l(957)+l(1640)]?.[l(1018)+"pointConfig"](),this[l(1415)+"sCounter"]?.[l(1291)+"nter"]()},this[r(1553)]=null,this.onerror=null,this[r(736)+"e"]=null,this[r(802)]=null,this[r(1425)+r(569)]=null,this[r(1337)+"eAck"]=null,this[r(1462)+r(787)+r(723)+"ct"]=null,this["_handleO"+r(754)]=this["_handleO"+r(754)][r(411)](this),this[r(596)+r(1193)]=this[r(596)+r(1193)][r(411)](this),this["_handleP"+r(570)]=this._handlePageHide[r(411)](this),this[r(1015)+r(1631)]=this[r(1015)+"ageShow"][r(411)](this),this._options={url:"",automaticOpen:!0,initReconnectInterval:1e3,maxReconnectInterval:1e4,reconnectIntervalGrowFactor:2,timeoutInterval:5e3,maxRetries:5,debug:!1,maxMessageQueueLength:e.YfvAT(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.pHdnt,pingLossCount:2,enableTransformTextPayload:!1,logIDNewConfig:{enableAutoGenerateLogIDNew:!1,userIp:""},miniProgramParams:{customHttpHeader:{}},enableAutoAck:!1,reconnectInterceptor:()=>!0,enableQoS:!1,QoSLevel:2,messageStrategy:e[r(1274)],env:{xTTEnv:"",xUseEnv:""},listenNetworkChanged:!0};let{url:x,ws:g}=t,m=Array[r(618)](x)?x:e[r(323)](e[r(626)],typeof x)?[x]:[];if(!m||m[r(1606)]===0)throw new Error(e[r(893)]);if(!Yc(g))throw new Error(e[r(497)]);if(Object[r(1096)](this[r(1570)],t),this[r(957)+r(1640)]=new as(m,this[r(1570)][r(480)+"es"]),this[r(1415)+r(1378)]=new Zc(this._options[r(825)+r(982)]),this[r(1570)][r(1089)+r(443)])if(e[r(1094)](e[r(322)],e[r(322)]))this[r(552)]=!0,this[r(300)]();else for(var y in _0x4ed723)OdBwYH[r(215)](_0x22d4fd,_0x24770c,y,{get:_0x436d3b[y],enumerable:!0});this._options[r(1624)+r(1601)+"nged"]&&(this[r(538)+"T"]||this[r(1112)+"X"]?this[r(1081)+r(1207)+"ange"]():this[r(235)+"er"]&&this["_initGlo"+r(1243)+r(196)]())}[n(596)+n(754)](){let t=n;this[t(1570)][t(847)+t(771)+t(343)]||this[t(935)+"osed"]||this[t(464)+"econnect"]()}[n(596)+"ffLine"](){let t=n;if(e[t(1198)](e[t(1188)],"IJsXD")){let r=t(972)+_0x50f1d7+(t(1238)+t(878)+"es reached");this["_dispatc"+t(1574)+"ent"](e.eSebJ(_0x17e302,e.LLSYA,{message:r,code:_0x452e33[t(891)+t(676)+"R"],error:_0x228c06}));return}else{this[t(311)+t(1477)+"t"]();let r=e.Mrhqx(Lr,t(793)+"t",{message:e[t(1069)]});this["onStopIm"+t(787)+t(723)+"ct"]&&this[t(1462)+"mediatel"+t(723)+"ct"](r)}}[n(1471)+n(1243)+n(196)](){let t=n;this[t(235)+"er"]&&window[t(621)+t(196)](t(281),this[t(596)+t(754)]),this[t(235)+"er"]&&window[t(621)+t(196)](e[t(221)],this[t(596)+t(1193)]),this[t(235)+"er"]&&window[t(621)+t(196)](e[t(722)],this[t(1015)+t(570)]),this[t(235)+"er"]&&window[t(621)+t(196)](e[t(1588)],this[t(1015)+"ageShow"])}["_dropGlo"+n(1243)+n(196)](){let t=n;if(e.AqTKl===e[t(1049)])return _0x4eb71c instanceof _0x24f49b&&(pVJgTo[t(1228)](_0x1b81de,pVJgTo.qdLeG)||_0x1c6159===pVJgTo[t(761)])?!0:pVJgTo[t(870)](_0x571e7b,_0x25ff7d);this._isBrowser&&window[t(1441)+t(623)+t(630)](e[t(550)],this[t(596)+t(754)]),this._isBrowser&&window["removeEv"+t(623)+t(630)](e[t(221)],this[t(596)+t(1193)]),this[t(235)+"er"]&&window["removeEv"+t(623)+t(630)](e[t(722)],this[t(1015)+t(570)]),this[t(235)+"er"]&&window["removeEv"+t(623)+t(630)](e[t(1588)],this[t(1015)+t(1631)])}[n(1015)+"ageHide"](t){let r=n;!t.persisted&&(this[r(235)+"er"]&&window[r(1441)+r(623)+r(630)](e[r(722)],this[r(1015)+"ageHide"]),this[r(235)+"er"]&&window[r(1441)+r(623)+r(630)](e[r(1588)],this["_handleP"+r(1631)]),this[r(296)]()),this[r(235)+"er"]&&window[r(1441)+"entListe"+r(630)](e[r(550)],this["_handleO"+r(754)]),this._isBrowser&&window[r(1441)+r(623)+r(630)](e[r(221)],this[r(596)+r(1193)])}[n(1015)+"ageShow"](t){let r=n;t.persisted&&(this[r(1514)+"orOnline"]()&&(!this[r(1011)]||this[r(1011)][r(230)+"te"]!==this.OPEN||e[r(450)](this[r(1011)].readyState,this.CONNECTING))&&this[r(596)+r(754)](),this[r(235)+"er"]&&window[r(621)+r(196)](r(281),this._handleOnLine),this._isBrowser&&window["addEvent"+r(196)](e[r(221)],this[r(596)+r(1193)]))}async[n(400)+n(1119)](t){let r=n,a={mrOQN:function(x,g){return x||g}};if(e[r(1198)](e[r(1584)],e[r(1584)])){let x=this._qosDB[r(1621)](this[r(640)]),g=_0x1969a7[r(1454)](UdrloM[r(259)](x,"{}"));return _0x8fbab2[r(1590)](g)}else{let{fpID:x,deviceID:g,bddID:m,ttwID:y,accessKey:_,aID:l,customParams:v={},enableAutoAck:C,enableQoS:D,QoSLevel:F,env:U}=this[r(1570)],Z,ae,$t;this[r(235)+"er"]||this[r(1112)+"X"]||this[r(538)+"T"]?(Z=location&&e[r(608)](e[r(945)],location[r(820)])?e[r(749)]:e[r(862)],ae=t[r(898)](/((^ws)|(^http))((?:[s]*:\/\/))/,""),$t=/^wss(.*:\/\/)/[r(705)](t)?t:""+Z+ae):(Z=e[r(749)],ae=t.replace(/(^http)((?:[s]*:\/\/))/,""),$t=/(^ws)((?:[s]*:\/\/))/.test(ae)?ae:""+Z+ae);let yn=m?e[r(1054)]:y?e[r(1072)]:e[r(520)],ps=m||y||g;if(e[r(1248)](!ps,!yn))throw new Error(e[r(934)]);let R0=e[r(608)](e[r(1547)],typeof v)?await v():v,N0=U?e[r(865)](Qc,U.xUseEnv,U[r(1146)]):{},Hr=Object[r(1096)]({device_platform:r(1350),version_code:e[r(886)],access_key:_,fpid:x,aid:l,[yn]:ps,xsack:C?1:0,xaack:C?1:0,xsqos:D?1:0,qos_level:D?F:void 0,qos_sdk_version:2,...N0},R0),O0=Object[r(1590)](Hr)[r(1506)]((jr,Kr)=>Hr[Kr]!==void 0?""+jr+(jr?"&":"?")+Kr+"="+Hr[Kr]:jr,"");return $t+r(741)+O0}}async[n(300)](){let t=n,r={JlUXV:function(a,x,g){return e[R(545)](a,x,g)}};if(!(this["_connect"+t(1087)]||this[t(935)+"osed"])){this[t(300)+t(1087)]=!0;try{if(e.uSkpq(e[t(1641)],"FdCVO")){let a=this[t(957)+"tManager"]?.[t(519)+t(587)+t(711)+t(1464)+t(823)](),{timeoutInterval:x}=this._options;if(a){let m=this[t(957)+t(1640)]?.[t(252)+"ntEndpoint"](),y=this["_endpoin"+t(1640)]?.[t(958)+t(1045)+t(885)+t(1359)+t(1293)](),_=this[t(957)+t(1640)]?.[t(252)+t(1586)+"ntTriesCount"]();if(y){let l=t(972)+m+(t(1165)+", max re"+t(1503)+t(922)+t(330)+t(1257)+t(415))+y+" to retry",v=e[t(421)](Ae,e[t(268)],{message:l,code:nt[t(891)+t(676)+"R"]});this[t(1420)](l),this[t(1363)+"hErrorEvent"](v),this[t(1180)]=await this[t(400)+t(1119)](y),this[t(1420)](t(972)+y+" "+_+t(514)),this[t(440)+"sListeners"]()}else{let l=t(972)+m+(t(1165)+", max retries re"+t(1159));this[t(1420)](l),this[t(1363)+t(1574)+"ent"](e.BTULv(Ae,t(1181),{message:l,code:nt.MAX_RETRIES_ERROR}));return}}else if(e[t(1282)](e[t(1237)],t(1004)))ibVPoB[t(366)](_0x5237e7,_0x212025,18),_0x1874df(_0xaaa072,_0x4b1bc4);else{let m=this[t(957)+"tManager"]?.[t(252)+t(1586)+t(1369)+t(632)](),y=this[t(957)+t(1640)]?.["getCurre"+t(1586)+t(1372)+t(729)]();this[t(1180)]=await this[t(400)+"eUrl"](e[t(1596)](m,"")),this[t(1420)](t(972)+m+" "+y+" times"),this[t(440)+"sListeners"]()}if(this[t(552)])this[t(552)]=!1;else{let m=e[t(684)](Lr,e.NWQdr,{message:e[t(974)]});this[t(1425)+t(569)]&&this[t(1425)+t(569)](m)}let g=this[t(957)+"tManager"]?.[t(252)+"ntEndpointTriesC"+t(729)]()||0;g>1&&await this[t(1267)](e.gOIbj(g,1)),this[t(1420)](t(299)+t(833)+this._url+(" protoco"+t(236))+this[t(438)+"ls"]),this[t(1011)]=e.rXIvg(Vc,{url:this[t(1180)],protocols:[this[t(438)+"ls"]],headers:this[t(1570)]["miniProg"+t(1026)+"s"][t(1287)+"tpHeader"]},this[t(1570)].ws),(this[t(235)+"er"]||this._isWorker)&&this[t(1011)]&&(this[t(1011)][t(715)+"pe"]=this[t(903)+"ype"]),this[t(338)+t(418)](),this["_connect"+t(503)+"utId"]=e[t(282)](setTimeout,this._onTimeout[t(411)](this),x)}else{if(this[t(1023)+t(1157)](),this[t(1635)+t(270)](),this["_removeW"+t(691)+"rs"](),this[t(370)+t(1197)](1e3,_0x375683),this[t(300)+"Lock"]=!1,_0x9290b8&&this[t(1514)+t(210)]()&&!this[t(935)+t(869)]){if(this[t(957)+t(1640)]?.["checkRea"+t(830)+"es"]()){let x=this[t(957)+"tManager"]?.[t(252)+"ntEndpoint"]();this[t(1363)+t(1530)+t(981)](e[t(666)](_0x4e6f40,e.vyLpc,{code:1006,reason:t(972)+x+(t(1165)+", max re"+t(1503)+t(1159)),wasClean:!0}))}else{let x=this[t(1570)]["reconnectInterce"+t(895)](_0x53826a,_0x16d87a);this[t(1363)+"hCloseEvent"](e.cLRRv(_0x379f30,e.vyLpc,{code:_0x9c3edf,reason:_0x4c68ff,wasClean:!0,willReconnect:x})),x&&this[t(300)]()}return}this[t(1514)+t(210)]()||this[t(935)+t(869)]?this[t(1363)+t(1530)+t(981)](_0x2f1296(e[t(829)],{code:_0x4fb86b,reason:t(946)})):this["_dispatchCloseEv"+t(981)](e[t(1389)](_0x21e78a,t(296),{code:1006,reason:e.dPOgd})),this[t(1011)]=null,this[t(957)+"tManager"]?.[t(1018)+t(804)+t(1516)](),this["_pingLos"+t(1378)]?.[t(1291)+t(795)]()}}catch(a){throw this["_connect"+t(1087)]=!1,a}}}[n(1635)+"mer"](){let t=n;e.AUkTa(e[t(1529)],e[t(1529)])?(e[t(1127)](clearTimeout,this["_connect"+t(503)+t(487)]),this[t(300)+t(503)+t(487)]=null):_0x2c0a26[t(264)](_0x5efb41,_0x3b7560)}[n(1023)+"ngTimer"](){let t=n,r={dxgro:function(a,x){return e[R(307)](a,x)},aDjdd:function(a){return e[R(997)](a)}};e[t(1131)](e[t(383)],e[t(1091)])?(BkRxaH.dxgro(_0x2559c0,_0xe5e9a7.error),BkRxaH.aDjdd(_0x1b4fd8)):(e[t(1533)](clearTimeout,this[t(1537)+t(1129)+"Id"]),e.tveyy(clearTimeout,this[t(410)+t(743)+t(819)]),this[t(1537)+"gTimeoutId"]=null,this[t(410)+t(743)+t(819)]=null)}_debug(...t){let r=n;this._options.debug&&console[r(405)][r(1486)](console,[e[r(348)],...t])}[n(1501)+"rvalValue"](t){let r=n;if(e[r(295)](e[r(377)],"RXDXR")){let{initReconnectInterval:a,maxReconnectInterval:x,reconnectIntervalGrowFactor:g}=this[r(1570)],m=e.TXhYl(a,Math.pow(g,t-1));return e[r(635)](m,x)?x:m}else{let a=e.avvMW(_0x2307e0,e[r(268)],{message:this[r(1259)+r(914)+r(1599)](_0x4ff8a9)});this[r(999)](r(1181),a);let x=e.TzQCO(_0x209e96,r(296),{reason:this[r(1259)+r(914)+r(1599)](_0x1d118f)});this[r(999)](e[r(829)],x)}}[n(1373)](){let t=n;if(this._ws&&e[t(392)](this[t(1011)][t(230)+"te"],this[t(917)+"NG"])){this._clearPingTimer(),this["_pingPon"+t(1129)+"Id"]=e[t(1450)](setTimeout,this[t(1373)][t(411)](this),this._options[t(809)+t(1117)]);return}if(!this[t(1011)]||e[t(654)](this._ws[t(230)+"te"],this[t(1605)]))return void this[t(464)+t(569)]();this[t(1011)]&&this._ws[t(1470)]("hi"),this[t(410)+t(743)+t(819)]=e[t(1253)](setTimeout,this[t(464)+"econnect"+t(1399)][t(411)](this),this._options[t(531)+t(1392)+t(1273)])}["_handleR"+n(569)+n(1399)](){let t=n;this[t(1415)+t(1378)]?.[t(1616)](),this[t(999)](e[t(416)],e.TlzqM),this[t(1415)+t(1378)]?.[t(1320)+t(1523)+"nt"]()?this["_handleR"+t(569)]():this[t(1373)]()}[n(1514)+n(210)](){let t=n;if(e[t(918)]===t(644))throw _0x1bb906=_0x3bc290[t(1606)],e[t(320)](_0x30e25c,_0x5ad18c,10,_0x5dac76.length);return this[t(538)+"T"]||this._isMiniWX?this["_miniNav"+t(1028)+t(585)]:(this[t(235)+"er"]||this[t(297)+"r"])&&this[t(1570)][t(1624)+"tworkCha"+t(1613)]?navigator.onLine:!0}[n(464)+n(569)](){let t=n;!this[t(1514)+t(210)]()||this[t(935)+t(869)]||(this[t(957)+t(1640)]?.["resetEnd"+t(804)+"fig"](),this[t(1415)+t(1378)]?.[t(1291)+t(795)](),this[t(1011)]?this["_disconn"+t(1027)](1001,e.ymouM,!0):this._connect())}[n(1081)+n(1207)+n(1548)](){let t=n,r={yxefY:"PIYZa",CIeYj:e[t(1148)]};this[t(538)+"T"]?tt[t(1041)+t(1116)+"hange"](({isConnected:a})=>{let x=t;this["_miniNav"+x(1028)+x(585)]=a,a?this[x(596)+x(754)]():this[x(596)+x(1193)]()}):this[t(1112)+"X"]&&wx[t(1041)+t(1116)+t(1338)](({isConnected:a})=>{let x=t;r[x(921)]===r.CIeYj?_0x1cba54[x(1578)]=_0x42fcca[x(998)]()[x(851)](()=>(_0x1b35a6(),_0xae47da))[x(851)](function(g){return g}):(this[x(533)+x(1028)+x(585)]=a,a?this["_handleO"+x(754)]():this[x(596)+x(1193)]())})}[n(1267)](t){let r={LqLLY:function(a,x,g){return e[R(1443)](a,x,g)}};return new Promise(a=>{let x=R;r[x(1408)](setTimeout,a,this[x(1501)+x(1301)+"e"](t))})}[n(1118)+"ect"](t=1e3,r="",a=!1){let x=n;if(e.TtgyM(e.wjjND,e[x(1384)]))this[x(1276)+x(289)+"Id"]=null,this[x(1276)+"l"]=36e5,this[x(843)]=_0x4139d8(e.aCwsr,e.ohmdq);else{if(!this._ws)return;this[x(311)+x(1477)+"t"](t,r,a)}}[n(1428)+"ut"](){let t=n;if(e[t(1623)]!==e[t(969)]){let r=this[t(957)+t(1640)]?.getCurrentEndpoint();this._debug(t(972)+r+" timeout"),this[t(1118)+t(1027)](1001,e[t(818)],!0)}else this[t(555)+t(373)]=null}[n(1163)](t){let r=n,a=e[r(426)](re,t);this._ws&&e[r(1094)](this[r(1011)][r(230)+"te"],this[r(1605)])&&(this[r(1011)]&&this._ws[r(1470)](a),this[r(1420)]("send_ack",t))}["_removeW"+n(691)+"rs"](){let t=n,r=e[t(578)][t(1354)]("|"),a=0;for(;;){switch(r[a++]){case"0":this[t(1011)][t(1441)+t(623)+t(630)](e[t(665)],this[t(1453)]);continue;case"1":this._ws[t(1441)+t(623)+t(630)](e[t(829)],this._onClose);continue;case"2":this._ws[t(1441)+"entListe"+t(630)](e[t(268)],this[t(896)]);continue;case"3":this[t(1011)][t(1441)+t(623)+t(630)](e[t(1012)],this[t(1039)+"ge"]);continue;case"4":if(!this._ws)return;continue}break}}[n(338)+n(418)](){let t=n;this[t(1011)]&&(this[t(1011)]["addEvent"+t(196)](e[t(665)],this[t(1453)]),this[t(1011)]["addEvent"+t(196)]("close",this[t(960)]),this[t(1011)]["addEvent"+t(196)](e[t(1012)],this[t(1039)+"ge"]),this[t(1011)][t(621)+t(196)](e[t(268)],this._onError))}[n(370)+n(1197)](t=1e3,r=""){let a=n;try{this[a(1011)]&&this._ws[a(296)](t,r)}catch{}}["_destroy"+n(1477)+"t"](t=1e3,r="",a=!1){let x=n;if(e[x(807)](e[x(316)],e[x(316)])){let g={NtIBy:function(m,y){return e[x(984)](m,y)},GEQmk:e.xfAEb,OLVMf:x(1438)+"e_success",RPdeD:"ping_onc"+x(731)+"t",xpmXM:function(m,y){return e.qSLmM(m,y)},lbYsQ:e[x(393)],kOHxq:function(m,y,_){return e.BtSUT(m,y,_)}};return new _0x4c66ed((m,y)=>{let _=x,l={GTLiB:function(D,F){return g[R(195)](D,F)},FjPRm:g[_(1550)],zsmII:g[_(496)]};this[_(1023)+_(1157)](),this["_pingPon"+_(1129)+"Id"]=g.kOHxq(_0x33f5a7,this._ping.bind(this),this[_(1570)][_(809)+_(1117)]);let v=()=>{let D=_;g[D(442)](m,g[D(350)]),this[D(333)](g[D(496)],v),this.off(g[D(1196)],C)},C=()=>{let D=_;l[D(1351)](y,l[D(318)]),this.off(l[D(1460)],v),this[D(333)](D(1438)+D(731)+"t",C)};this.on(g[_(496)],v),this.on(g.RPdeD,C),this._ping()})}else{if(this._clearPingTimer(),this[x(1635)+x(270)](),this[x(440)+x(691)+"rs"](),this[x(370)+x(1197)](1e3,r),this["_connect"+x(1087)]=!1,a&&this[x(1514)+x(210)]()&&!this[x(935)+x(869)]){if(this[x(957)+x(1640)]?.checkReachMaxTries())if(e.akqAY(e.CWLbF,e[x(1128)])){let m=this._endpointManager?.[x(252)+x(1586)+"nt"]();this[x(1363)+x(1530)+x(981)](e[x(1025)](De,e[x(829)],{code:1006,reason:x(972)+m+(" timeout, max re"+x(1503)+"ached"),wasClean:!0}))}else return 0;else{let m=this._options["reconnec"+x(603)+x(895)](t,r);this[x(1363)+x(1530)+x(981)](e.zdKnc(De,x(296),{code:t,reason:r,wasClean:!0,willReconnect:m})),m&&this[x(300)]()}return}this[x(1514)+x(210)]()||this["_readyCl"+x(869)]?this[x(1363)+"hCloseEvent"](e.YZeUo(De,x(296),{code:t,reason:x(946)})):this[x(1363)+x(1530)+"ent"](De(e[x(829)],{code:1006,reason:e.dPOgd})),this[x(1011)]=null,this._endpointManager?.["resetEnd"+x(804)+x(1516)](),this[x(1415)+x(1378)]?.[x(1291)+x(795)]()}}[n(1363)+n(1098)+"nt"](t){let r=n;e[r(468)]===r(943)?(pVJgTo[r(647)](_0x857d14,_0x3d493d[r(1181)]||new _0x588bdc(pVJgTo.buhql,pVJgTo[r(260)])),pVJgTo.Vsufu(_0x8dd48f)):(this.emit(e.hXcPH,t),this.onopen&&this[r(802)](t))}[n(1363)+n(642)+n(1386)](t){let r=n;if(e.BWdVF(e[r(855)],"TYFpt"))return _0xcf32fc[r(998)]();this[r(999)]("message",t),this[r(736)+"e"]&&this.onmessage(t)}[n(1363)+"hAckMess"+n(702)](t){let r=n;this[r(999)](r(530),t),this[r(1337)+r(1218)]&&this["onReceiv"+r(1218)](t)}[n(1363)+n(1574)+"ent"](t){let r=n,a={jWwcV:function(x,g,m,y){return e[R(764)](x,g,m,y)}};e[r(375)](e[r(712)],e[r(712)])?(this[r(999)](e[r(268)],t),this[r(1227)]&&this.onerror(t)):nmSAaB[r(1047)](_0x362403,this,_0xd51eb5,[_0x262edb,_0x343269,_0x5e231e,_0x3faec2,_0x57b1f1,_0x8195ed])}[n(1363)+"hCloseEvent"](t){let r=n;this[r(999)](e[r(829)],t),this[r(1553)]&&this[r(1553)](t)}get[n(715)+"pe"](){let t=n,r={loCgs:e[t(1331)],NDueY:e.uhrJU};if(e[t(1297)](e.LocYf,e[t(879)]))switch(_0x1761f2){case UJUlrj.loCgs:case UJUlrj[t(1160)]:return{[t(866)+_0x111dea]:1,"x-tt-env":_0x2ee923};default:return{}}else return this[t(1011)]?this[t(1011)][t(715)+"pe"]:this[t(903)+t(1542)]}set binaryType(t){let r=n;this[r(903)+"ype"]=t,this[r(1011)]&&(this[r(1011)][r(715)+"pe"]=t)}get[n(1597)+"nt"](){let t=n;return this["_endpoin"+t(1640)]?.["getCurrentEndpoi"+t(1372)+t(729)]()||0}get["buffered"+n(1611)](){let t=n,r=this[t(1056)+t(990)][t(1506)]((a,x)=>(a+=x&&x.byteLength||0,a),0);return e[t(1166)](r,this._ws?this[t(1011)][t(1311)+t(1611)]:0)}get extensions(){let t=n;return this[t(1011)]?this[t(1011)].extensions:""}get[n(820)](){let t=n,r={alrET:function(a,x){return e[R(976)](a,x)}};if(t(498)===e[t(814)]){let a=_0x49d5c3[t(1488)+"g"](0,jJdEhK[t(1312)](4,_0x4ded2a[t(1606)])),x=a.concat(_0x1bcebf);_0x1e3850.push(x)}else return this._ws?this[t(1011)][t(820)]:""}get[n(230)+"te"](){let t=n;return this[t(1011)]?this[t(1011)][t(230)+"te"]:this[t(1570)]["automati"+t(443)]?this[t(917)+"NG"]:this[t(781)]}get[n(747)](){let t=n;return this._ws?this._ws[t(747)]:this._url}close(t=1e3,r){let a=n,x=e[a(1446)].split("|"),g=0;for(;;){switch(x[g++]){case"0":this[a(1023)+"ngTimer"]();continue;case"1":this._clearTimer();continue;case"2":if(!this[a(1011)])return void this[a(1420)](e[a(584)]);continue;case"3":this[a(637)+a(1243)+a(196)]();continue;case"4":this[a(357)+a(725)]?.[a(429)]();continue;case"5":this[a(311)+a(1477)+"t"](t,r);continue;case"6":this[a(935)+a(869)]=!0;continue;case"7":if(e[a(688)](this._ws[a(230)+"te"],this.CLOSED)||e[a(375)](this._ws.readyState,this[a(1474)]))return void this[a(1420)](e[a(1380)]);continue}break}}async send(t,r){let a=n;if(t==null)throw new Error(e[a(858)]);e.rLtAE(e[a(808)],typeof t)&&(t=JSON[a(600)+"y"](t)),e.vhniu!=typeof t&&!e[a(977)](t,ArrayBuffer)&&!(t[a(798)]&&e[a(476)](t[a(798)],ArrayBuffer))&&(t=JSON[a(600)+"y"](t));let x=await e[a(786)](us,t),g=e.rIDIw(Xc,t),{method:m=0,service:y=this[a(1570)][a(452)],logID:_=this._options[a(1496)+"erator"](),headers:l=this[a(1570)][a(1260)],payloadEncoding:v=this[a(1570)][a(1309)+"ncoding"],payloadType:C=this[a(1570)][a(332)+"ype"],logIDNew:D=this._options[a(1005)+"Config"][a(535)+"toGenerateLogIDNew"]?e.ftpyv(o,this[a(1570)][a(1005)+a(1052)][a(1313)]):""}=e.gHxBB(r,{});if(!y)throw new Error(e.gbour);let F={SeqID:K[a(1356)+"er"](this._seqId++),LogID:K[a(1356)+"er"](_),service:y,method:m,headers:l,payloadEncoding:e[a(620)](v,Object)?v.encoding?v[a(940)]:"":v,payloadType:C instanceof Object?C.type?C[a(1061)]:g:C||g,payload:x,LogIDNew:D},U=re(F);return this[a(1011)]&&e.hgLkw(this[a(1011)][a(230)+"te"],this[a(1605)])?(this[a(1011)]&&this[a(1011)][a(1470)](U),this[a(1420)](e[a(573)],F)):e.ATqvG(this[a(1056)+a(990)][a(1606)],this._options["maxMessa"+a(1323)+a(1229)])?(this[a(1056)+a(990)][a(1034)](U),this[a(1420)](e[a(329)],F)):(this[a(1056)+a(990)].shift(),this._messageQueue[a(1034)](U)),{seqID:this._seqId,logID:_,logIDNew:D}}async[n(793)+"t"](t){let r=n,{url:a}=e[r(1458)](t,{}),x=Array[r(618)](a)?a:typeof a=="string"?[a]:[];t&&Object[r(1096)](this[r(1570)],t),x&&x[r(1606)]?this[r(957)+"tManager"]=new as(x,this[r(1570)][r(480)+"es"]):this[r(957)+r(1640)]?.["resetEnd"+r(804)+r(1516)](),this[r(1415)+r(1378)]?.[r(1291)+r(795)](this[r(1570)]["pingLoss"+r(982)]),this[r(935)+r(869)]=!1,this[r(1011)]&&e[r(991)](this[r(1011)][r(230)+"te"],this[r(781)])?this[r(1118)+r(1027)](1e3,r(1519)+r(569)+r(376),!0):(this[r(552)]=!0,this[r(300)]())}async[n(312)](){let t=n,r={dYJsT:function(a,x,g){return e[R(670)](a,x,g)},xHbrt:function(a,x){return e[R(203)](a,x)},sCRCE:function(a,x,g){return e.IZApY(a,x,g)}};if(e.EGQJG(e[t(950)],e[t(728)])){if(!this["_connect"+t(1087)]){let a=(t(263)+"2").split("|"),x=0;for(;;){switch(a[x++]){case"0":this[t(935)+t(869)]=!1;continue;case"1":this[t(957)+t(1640)]?.[t(1018)+t(804)+t(1516)]();continue;case"2":this[t(300)]();continue;case"3":this[t(552)]=!0;continue;case"4":this["_pingLos"+t(1378)]?.["resetCou"+t(795)]();continue}break}}}else{if(this[t(1011)]&&this[t(1011)].readyState===this[t(917)+"NG"]){this[t(1023)+t(1157)](),this["_pingPon"+t(1129)+"Id"]=smSykJ.dYJsT(_0x1a3250,this[t(1373)][t(411)](this),this[t(1570)][t(809)+t(1117)]);return}if(!this[t(1011)]||smSykJ[t(681)](this[t(1011)][t(230)+"te"],this[t(1605)]))return void this[t(464)+t(569)]();this[t(1011)]&&this[t(1011)][t(1470)]("hi"),this["_reconnectTimeou"+t(819)]=smSykJ[t(1268)](_0x240960,this["_handleR"+t(569)+t(1399)].bind(this),this[t(1570)][t(531)+"outInterval"])}}["addEvent"+n(196)](t,r){this.on(t,r)}["dispatch"+n(1386)](t){let r=n;if(e[r(1296)]!==e.bYPGD){let{type:a}=t;this[r(999)](a,t)}else return!!this._qosDB}["removeEv"+n(623)+"ner"](t,r){this.off(t,r)}[n(1063)](){let t=n,r={SzGpc:t(605),GvSXY:e.QPkPh,bNspX:function(a,x){return e[t(526)](a,x)},bnPCm:e[t(1205)],WCLcv:t(1184),wYoVO:e[t(553)],ZtxSQ:function(a,x,g){return e[t(1203)](a,x,g)}};return new Promise((a,x)=>{let g=t,m={gVBth:function(l,v){return r[R(1349)](l,v)},PwpuM:r[g(197)],nXWSQ:r[g(1305)],AgHNm:r[g(419)]};this[g(1023)+g(1157)](),this[g(1537)+g(1129)+"Id"]=r[g(1449)](setTimeout,this._ping.bind(this),this._options[g(809)+g(1117)]);let y=()=>{let l=g;a(r[l(288)]),this[l(333)](l(1438)+l(558)+"s",y),this[l(333)](r[l(1235)],_)},_=()=>{let l=g;m[l(239)]("PkGNb",m[l(334)])?(this[l(903)+l(1542)]=_0x24f721,this._ws&&(this[l(1011)][l(715)+"pe"]=_0x343f3a)):(x(m.nXWSQ),this[l(333)](m.AgHNm,y),this[l(333)](l(1438)+l(731)+"t",_))};this.on(r[g(419)],y),this.on(r.GvSXY,_),this._ping()})}}})(),se[P(939)+P(717)]=te["CustomCl"+P(717)],se["CustomEr"+P(792)]=te.CustomErrorEvent,se.ErrorCode=te[P(1610)+"e"],se[P(1386)]=te.Event,se[P(1520)]=te[P(1520)],se[P(956)+"MessageE"+P(472)]=te[P(956)+P(1490)+"vent"],se[P(1490)+P(472)]=te[P(1490)+P(472)],se[P(1639)+"t"]=te[P(1639)+"t"],se[P(562)+P(841)]=te[P(562)+P(841)],se[P(581)+P(717)]=te[P(581)+"oseEvent"],se.createErrorEvent=te["createEr"+P(792)],se[P(860)+P(206)+"nt"]=te["createMe"+P(206)+"nt"],se["createOp"+P(1156)]=te[P(1135)+P(1156)],se[P(1264)+"connectE"+P(472)]=te[P(1264)+P(444)+P(472)],se[P(873)+P(1075)]=te[P(873)+P(1075)],se[P(669)+P(1614)]=te[P(669)+P(1614)];for(Zn in te)["CustomCl"+P(717),P(445)+P(792),P(1610)+"e","Event",P(1520),P(956)+"MessageEvent",P(1490)+"vent","OpenEvent",P(562)+P(841),"createCl"+P(717),P(1214)+P(792),"createMe"+P(206)+"nt",P(1135)+P(1156),"createRe"+P(444)+P(472),P(873)+P(1075),P(669)+P(1614)][P(539)](Zn)===-1&&(se[Zn]=te[Zn]);var Zn;Object[P(542)+P(325)](se,P(762)+"le",{value:!0})});var Ve=be((h_,sa)=>{"use strict";var ra=["nodebuffer","arraybuffer","fragments"],ia=typeof Blob<"u";ia&&ra.push("blob");sa.exports={BINARY_TYPES:ra,CLOSE_TIMEOUT:3e4,EMPTY_BUFFER:Buffer.alloc(0),GUID:"258EAFA5-E914-47DA-95CA-C5AB0DC85B11",hasBlob:ia,kForOnEventAttribute:Symbol("kIsForOnEventAttribute"),kListener:Symbol("kListener"),kStatusCode:Symbol("status-code"),kWebSocket:Symbol("websocket"),NOOP:()=>{}}});var xn=be((p_,or)=>{"use strict";var{EMPTY_BUFFER:gf}=Ve(),li=Buffer[Symbol.species];function hf(n,e){if(n.length===0)return gf;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 li(s.buffer,s.byteOffset,o):s}function oa(n,e,s,o,c){for(let d=0;d<c;d++)s[o+d]=n[d]^e[d&3]}function aa(n,e){for(let s=0;s<n.length;s++)n[s]^=e[s&3]}function pf(n){return n.length===n.buffer.byteLength?n.buffer:n.buffer.slice(n.byteOffset,n.byteOffset+n.length)}function gi(n){if(gi.readOnly=!0,Buffer.isBuffer(n))return n;let e;return n instanceof ArrayBuffer?e=new li(n):ArrayBuffer.isView(n)?e=new li(n.buffer,n.byteOffset,n.byteLength):(e=Buffer.from(n),gi.readOnly=!1),e}or.exports={concat:hf,mask:oa,toArrayBuffer:pf,toBuffer:gi,unmask:aa};if(!process.env.WS_NO_BUFFER_UTIL)try{let n=ee("bufferutil");or.exports.mask=function(e,s,o,c,d){d<48?oa(e,s,o,c,d):n.mask(e,s,o,c,d)},or.exports.unmask=function(e,s){e.length<32?aa(e,s):n.unmask(e,s)}}catch{}});var xa=be((m_,da)=>{"use strict";var ca=Symbol("kDone"),hi=Symbol("kRun"),pi=class{constructor(e){this[ca]=()=>{this.pending--,this[hi]()},this.concurrency=e||1/0,this.jobs=[],this.pending=0}add(e){this.jobs.push(e),this[hi]()}[hi](){if(this.pending!==this.concurrency&&this.jobs.length){let e=this.jobs.shift();this.pending++,e(this[ca])}}};da.exports=pi});var Ft=be((w_,ga)=>{"use strict";var un=ee("zlib"),ua=xn(),mf=xa(),{kStatusCode:fa}=Ve(),wf=Buffer[Symbol.species],_f=Buffer.from([0,0,255,255]),cr=Symbol("permessage-deflate"),Ye=Symbol("total-length"),Bt=Symbol("callback"),dt=Symbol("buffers"),zt=Symbol("error"),ar,mi=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,!ar){let s=this._options.concurrencyLimit!==void 0?this._options.concurrencyLimit:10;ar=new mf(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[Bt];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){ar.add(c=>{this._decompress(e,s,(d,u)=>{c(),o(d,u)})})}compress(e,s,o){ar.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"?un.Z_DEFAULT_WINDOWBITS:this.params[d];this._inflate=un.createInflateRaw({...this._options.zlibInflateOptions,windowBits:u}),this._inflate[cr]=this,this._inflate[Ye]=0,this._inflate[dt]=[],this._inflate.on("error",bf),this._inflate.on("data",la)}this._inflate[Bt]=o,this._inflate.write(e),s&&this._inflate.write(_f),this._inflate.flush(()=>{let d=this._inflate[zt];if(d){this._inflate.close(),this._inflate=null,o(d);return}let u=ua.concat(this._inflate[dt],this._inflate[Ye]);this._inflate._readableState.endEmitted?(this._inflate.close(),this._inflate=null):(this._inflate[Ye]=0,this._inflate[dt]=[],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"?un.Z_DEFAULT_WINDOWBITS:this.params[d];this._deflate=un.createDeflateRaw({...this._options.zlibDeflateOptions,windowBits:u}),this._deflate[Ye]=0,this._deflate[dt]=[],this._deflate.on("data",yf)}this._deflate[Bt]=o,this._deflate.write(e),this._deflate.flush(un.Z_SYNC_FLUSH,()=>{if(!this._deflate)return;let d=ua.concat(this._deflate[dt],this._deflate[Ye]);s&&(d=new wf(d.buffer,d.byteOffset,d.length-4)),this._deflate[Bt]=null,this._deflate[Ye]=0,this._deflate[dt]=[],s&&this.params[`${c}_no_context_takeover`]&&this._deflate.reset(),o(null,d)})}};ga.exports=mi;function yf(n){this[dt].push(n),this[Ye]+=n.length}function la(n){if(this[Ye]+=n.length,this[cr]._maxPayload<1||this[Ye]<=this[cr]._maxPayload){this[dt].push(n);return}this[zt]=new RangeError("Max payload size exceeded"),this[zt].code="WS_ERR_UNSUPPORTED_MESSAGE_LENGTH",this[zt][fa]=1009,this.removeListener("data",la),this.reset()}function bf(n){if(this[cr]._inflate=null,this[zt]){this[Bt](this[zt]);return}n[fa]=1007,this[Bt](n)}});var Ut=be((__,dr)=>{"use strict";var{isUtf8:ha}=ee("buffer"),{hasBlob:vf}=Ve(),Sf=[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 Ef(n){return n>=1e3&&n<=1014&&n!==1004&&n!==1005&&n!==1006||n>=3e3&&n<=4999}function wi(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 If(n){return vf&&typeof n=="object"&&typeof n.arrayBuffer=="function"&&typeof n.type=="string"&&typeof n.stream=="function"&&(n[Symbol.toStringTag]==="Blob"||n[Symbol.toStringTag]==="File")}dr.exports={isBlob:If,isValidStatusCode:Ef,isValidUTF8:wi,tokenChars:Sf};if(ha)dr.exports.isValidUTF8=function(n){return n.length<24?wi(n):ha(n)};else if(!process.env.WS_NO_UTF_8_VALIDATE)try{let n=ee("utf-8-validate");dr.exports.isValidUTF8=function(e){return e.length<32?wi(e):n(e)}}catch{}});var Si=be((y_,va)=>{"use strict";var{Writable:Af}=ee("stream"),pa=Ft(),{BINARY_TYPES:Tf,EMPTY_BUFFER:ma,kStatusCode:Pf,kWebSocket:Cf}=Ve(),{concat:_i,toArrayBuffer:kf,unmask:Df}=xn(),{isValidStatusCode:Rf,isValidUTF8:wa}=Ut(),xr=Buffer[Symbol.species],Pe=0,_a=1,ya=2,ba=3,yi=4,bi=5,ur=6,vi=class extends Af{constructor(e={}){super(),this._allowSynchronousEvents=e.allowSynchronousEvents!==void 0?e.allowSynchronousEvents:!0,this._binaryType=e.binaryType||Tf[0],this._extensions=e.extensions||{},this._isServer=!!e.isServer,this._maxPayload=e.maxPayload|0,this._skipUTF8Validation=!!e.skipUTF8Validation,this[Cf]=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 xr(o.buffer,o.byteOffset+e,o.length-e),new xr(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 xr(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 _a:this.getPayloadLength16(e);break;case ya:this.getPayloadLength64(e);break;case ba:this.getMask();break;case yi:this.getData(e);break;case bi:case ur: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[pa.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=_a:this._payloadLength===127?this._state=ya: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=ba:this._state=yi}getMask(){if(this._bufferedBytes<4){this._loop=!1;return}this._mask=this.consume(4),this._state=yi}getData(e){let s=ma;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&&Df(s,this._mask)}if(this._opcode>7){this.controlMessage(s,e);return}if(this._compressed){this._state=bi,this.decompress(s,e);return}s.length&&(this._messageLength=this._totalPayloadLength,this._fragments.push(s)),this.dataMessage(e)}decompress(e,s){this._extensions[pa.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=_i(o,s):this._binaryType==="arraybuffer"?c=kf(_i(o,s)):this._binaryType==="blob"?c=new Blob(o):c=o,this._allowSynchronousEvents?(this.emit("message",c,!0),this._state=Pe):(this._state=ur,setImmediate(()=>{this.emit("message",c,!0),this._state=Pe,this.startLoop(e)}))}else{let c=_i(o,s);if(!this._skipUTF8Validation&&!wa(c)){let d=this.createError(Error,"invalid UTF-8 sequence",!0,1007,"WS_ERR_INVALID_UTF8");e(d);return}this._state===bi||this._allowSynchronousEvents?(this.emit("message",c,!1),this._state=Pe):(this._state=ur,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,ma),this.end();else{let o=e.readUInt16BE(0);if(!Rf(o)){let d=this.createError(RangeError,`invalid status code ${o}`,!0,1002,"WS_ERR_INVALID_CLOSE_CODE");s(d);return}let c=new xr(e.buffer,e.byteOffset+2,e.length-2);if(!this._skipUTF8Validation&&!wa(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=ur,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[Pf]=c,u}};va.exports=vi});var Ai=be((v_,Ia)=>{"use strict";var{Duplex:b_}=ee("stream"),{randomFillSync:Nf}=ee("crypto"),Sa=Ft(),{EMPTY_BUFFER:Of,kWebSocket:Lf,NOOP:Mf}=Ve(),{isBlob:qt,isValidStatusCode:Bf}=Ut(),{mask:Ea,toBuffer:gt}=xn(),Ce=Symbol("kByteLength"),zf=Buffer.alloc(4),fr=8*1024,ht,Gt=fr,Re=0,Ff=1,Uf=2,Ei=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=Mf,this[Lf]=void 0}static frame(e,s){let o,c=!1,d=2,u=!1;s.mask&&(o=s.maskBuffer||zf,s.generateMask?s.generateMask(o):(Gt===fr&&(ht===void 0&&(ht=Buffer.alloc(fr)),Nf(ht,0,fr),Gt=0),o[0]=ht[Gt++],o[1]=ht[Gt++],o[2]=ht[Gt++],o[3]=ht[Gt++]),u=(o[0]|o[1]|o[2]|o[3])===0,d=6);let f;typeof e=="string"?(!s.mask||u)&&s[Ce]!==void 0?f=s[Ce]:(e=Buffer.from(e),f=e.length):(f=e.length,c=s.mask&&s.readOnly&&!u);let h=f;f>=65536?(d+=8,h=127):f>125&&(d+=2,h=126);let p=Buffer.allocUnsafe(c?f+d:d);return p[0]=s.fin?s.opcode|128:s.opcode,s.rsv1&&(p[0]|=64),p[1]=h,h===126?p.writeUInt16BE(f,2):h===127&&(p[2]=p[3]=0,p.writeUIntBE(f,4,6)),s.mask?(p[1]|=128,p[d-4]=o[0],p[d-3]=o[1],p[d-2]=o[2],p[d-1]=o[3],u?[p,e]:c?(Ea(e,o,p,d,f),[p]):(Ea(e,o,e,0,f),[p,e])):[p,e]}close(e,s,o,c){let d;if(e===void 0)d=Of;else{if(typeof e!="number"||!Bf(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 f=Buffer.byteLength(s);if(f>123)throw new RangeError("The message must not be greater than 123 bytes");d=Buffer.allocUnsafe(2+f),d.writeUInt16BE(e,0),typeof s=="string"?d.write(s,2):d.set(s,2)}}let u={[Ce]: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):qt(e)?(c=e.size,d=!1):(e=gt(e),c=e.length,d=gt.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:d,rsv1:!1};qt(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):qt(e)?(c=e.size,d=!1):(e=gt(e),c=e.length,d=gt.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:d,rsv1:!1};qt(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[Sa.extensionName],d=s.binary?2:1,u=s.compress,f,h;typeof e=="string"?(f=Buffer.byteLength(e),h=!1):qt(e)?(f=e.size,h=!1):(e=gt(e),f=e.length,h=gt.readOnly),this._firstFragment?(this._firstFragment=!1,u&&c&&c.params[c._isServer?"server_no_context_takeover":"client_no_context_takeover"]&&(u=f>=c._threshold),this._compress=u):(u=!1,d=0),s.fin&&(this._firstFragment=!0);let p={[Ce]:f,fin:s.fin,generateMask:this._generateMask,mask:s.mask,maskBuffer:this._maskBuffer,opcode:d,readOnly:h,rsv1:u};qt(e)?this._state!==Re?this.enqueue([this.getBlobData,e,this._compress,p,o]):this.getBlobData(e,this._compress,p,o):this._state!==Re?this.enqueue([this.dispatch,e,this._compress,p,o]):this.dispatch(e,this._compress,p,o)}getBlobData(e,s,o,c){this._bufferedBytes+=o[Ce],this._state=Uf,e.arrayBuffer().then(d=>{if(this._socket.destroyed){let f=new Error("The socket was closed while the blob was being read");process.nextTick(Ii,this,f,c);return}this._bufferedBytes-=o[Ce];let u=gt(d);s?this.dispatch(u,s,o,c):(this._state=Re,this.sendFrame(n.frame(u,o),c),this.dequeue())}).catch(d=>{process.nextTick(qf,this,d,c)})}dispatch(e,s,o,c){if(!s){this.sendFrame(n.frame(e,o),c);return}let d=this._extensions[Sa.extensionName];this._bufferedBytes+=o[Ce],this._state=Ff,d.compress(e,o.fin,(u,f)=>{if(this._socket.destroyed){let h=new Error("The socket was closed while data was being compressed");Ii(this,h,c);return}this._bufferedBytes-=o[Ce],this._state=Re,o.readOnly=!1,this.sendFrame(n.frame(f,o),c),this.dequeue()})}dequeue(){for(;this._state===Re&&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)}};Ia.exports=Ei;function Ii(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 qf(n,e,s){Ii(n,e,s),n.onerror(e)}});var Oa=be((S_,Na)=>{"use strict";var{kForOnEventAttribute:fn,kListener:Ti}=Ve(),Aa=Symbol("kCode"),Ta=Symbol("kData"),Pa=Symbol("kError"),Ca=Symbol("kMessage"),ka=Symbol("kReason"),Ht=Symbol("kTarget"),Da=Symbol("kType"),Ra=Symbol("kWasClean"),Xe=class{constructor(e){this[Ht]=null,this[Da]=e}get target(){return this[Ht]}get type(){return this[Da]}};Object.defineProperty(Xe.prototype,"target",{enumerable:!0});Object.defineProperty(Xe.prototype,"type",{enumerable:!0});var pt=class extends Xe{constructor(e,s={}){super(e),this[Aa]=s.code===void 0?0:s.code,this[ka]=s.reason===void 0?"":s.reason,this[Ra]=s.wasClean===void 0?!1:s.wasClean}get code(){return this[Aa]}get reason(){return this[ka]}get wasClean(){return this[Ra]}};Object.defineProperty(pt.prototype,"code",{enumerable:!0});Object.defineProperty(pt.prototype,"reason",{enumerable:!0});Object.defineProperty(pt.prototype,"wasClean",{enumerable:!0});var jt=class extends Xe{constructor(e,s={}){super(e),this[Pa]=s.error===void 0?null:s.error,this[Ca]=s.message===void 0?"":s.message}get error(){return this[Pa]}get message(){return this[Ca]}};Object.defineProperty(jt.prototype,"error",{enumerable:!0});Object.defineProperty(jt.prototype,"message",{enumerable:!0});var ln=class extends Xe{constructor(e,s={}){super(e),this[Ta]=s.data===void 0?null:s.data}get data(){return this[Ta]}};Object.defineProperty(ln.prototype,"data",{enumerable:!0});var Gf={addEventListener(n,e,s={}){for(let c of this.listeners(n))if(!s[fn]&&c[Ti]===e&&!c[fn])return;let o;if(n==="message")o=function(d,u){let f=new ln("message",{data:u?d:d.toString()});f[Ht]=this,lr(e,this,f)};else if(n==="close")o=function(d,u){let f=new pt("close",{code:d,reason:u.toString(),wasClean:this._closeFrameReceived&&this._closeFrameSent});f[Ht]=this,lr(e,this,f)};else if(n==="error")o=function(d){let u=new jt("error",{error:d,message:d.message});u[Ht]=this,lr(e,this,u)};else if(n==="open")o=function(){let d=new Xe("open");d[Ht]=this,lr(e,this,d)};else return;o[fn]=!!s[fn],o[Ti]=e,s.once?this.once(n,o):this.on(n,o)},removeEventListener(n,e){for(let s of this.listeners(n))if(s[Ti]===e&&!s[fn]){this.removeListener(n,s);break}}};Na.exports={CloseEvent:pt,ErrorEvent:jt,Event:Xe,EventTarget:Gf,MessageEvent:ln};function lr(n,e,s){typeof n=="object"&&n.handleEvent?n.handleEvent.call(n,s):n.call(e,s)}});var gr=be((E_,La)=>{"use strict";var{tokenChars:gn}=Ut();function He(n,e,s){n[e]===void 0?n[e]=[s]:n[e].push(s)}function Hf(n){let e=Object.create(null),s=Object.create(null),o=!1,c=!1,d=!1,u,f,h=-1,p=-1,w=-1,b=0;for(;b<n.length;b++)if(p=n.charCodeAt(b),u===void 0)if(w===-1&&gn[p]===1)h===-1&&(h=b);else if(b!==0&&(p===32||p===9))w===-1&&h!==-1&&(w=b);else if(p===59||p===44){if(h===-1)throw new SyntaxError(`Unexpected character at index ${b}`);w===-1&&(w=b);let I=n.slice(h,w);p===44?(He(e,I,s),s=Object.create(null)):u=I,h=w=-1}else throw new SyntaxError(`Unexpected character at index ${b}`);else if(f===void 0)if(w===-1&&gn[p]===1)h===-1&&(h=b);else if(p===32||p===9)w===-1&&h!==-1&&(w=b);else if(p===59||p===44){if(h===-1)throw new SyntaxError(`Unexpected character at index ${b}`);w===-1&&(w=b),He(s,n.slice(h,w),!0),p===44&&(He(e,u,s),s=Object.create(null),u=void 0),h=w=-1}else if(p===61&&h!==-1&&w===-1)f=n.slice(h,b),h=w=-1;else throw new SyntaxError(`Unexpected character at index ${b}`);else if(c){if(gn[p]!==1)throw new SyntaxError(`Unexpected character at index ${b}`);h===-1?h=b:o||(o=!0),c=!1}else if(d)if(gn[p]===1)h===-1&&(h=b);else if(p===34&&h!==-1)d=!1,w=b;else if(p===92)c=!0;else throw new SyntaxError(`Unexpected character at index ${b}`);else if(p===34&&n.charCodeAt(b-1)===61)d=!0;else if(w===-1&&gn[p]===1)h===-1&&(h=b);else if(h!==-1&&(p===32||p===9))w===-1&&(w=b);else if(p===59||p===44){if(h===-1)throw new SyntaxError(`Unexpected character at index ${b}`);w===-1&&(w=b);let I=n.slice(h,w);o&&(I=I.replace(/\\/g,""),o=!1),He(s,f,I),p===44&&(He(e,u,s),s=Object.create(null),u=void 0),f=void 0,h=w=-1}else throw new SyntaxError(`Unexpected character at index ${b}`);if(h===-1||d||p===32||p===9)throw new SyntaxError("Unexpected end of input");w===-1&&(w=b);let E=n.slice(h,w);return u===void 0?He(e,E,s):(f===void 0?He(s,E,!0):o?He(s,f,E.replace(/\\/g,"")):He(s,f,E),He(e,u,s)),e}function jf(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(", ")}La.exports={format:jf,parse:Hf}});var wr=be((T_,Ja)=>{"use strict";var Kf=ee("events"),Wf=ee("https"),Jf=ee("http"),za=ee("net"),$f=ee("tls"),{randomBytes:Vf,createHash:Yf}=ee("crypto"),{Duplex:I_,Readable:A_}=ee("stream"),{URL:Pi}=ee("url"),xt=Ft(),Xf=Si(),Qf=Ai(),{isBlob:Zf}=Ut(),{BINARY_TYPES:Ma,CLOSE_TIMEOUT:el,EMPTY_BUFFER:hr,GUID:tl,kForOnEventAttribute:Ci,kListener:nl,kStatusCode:rl,kWebSocket:de,NOOP:Fa}=Ve(),{EventTarget:{addEventListener:il,removeEventListener:sl}}=Oa(),{format:ol,parse:al}=gr(),{toBuffer:cl}=xn(),Ua=Symbol("kAborted"),ki=[8,13],Qe=["CONNECTING","OPEN","CLOSING","CLOSED"],dl=/^[!#$%&'*+\-.0-9A-Z^_`|a-z~]+$/,$=class n extends Kf{constructor(e,s,o){super(),this._binaryType=Ma[0],this._closeCode=1006,this._closeFrameReceived=!1,this._closeFrameSent=!1,this._closeMessage=hr,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]),qa(this,e,s,o)):(this._autoPong=o.autoPong,this._closeTimeout=o.closeTimeout,this._isServer=!0)}get binaryType(){return this._binaryType}set binaryType(e){Ma.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 Xf({allowSynchronousEvents:o.allowSynchronousEvents,binaryType:this.binaryType,extensions:this._extensions,isServer:this._isServer,maxPayload:o.maxPayload,skipUTF8Validation:o.skipUTF8Validation}),d=new Qf(e,this._extensions,o.generateMask);this._receiver=c,this._sender=d,this._socket=e,c[de]=this,d[de]=this,e[de]=this,c.on("conclude",fl),c.on("drain",ll),c.on("error",gl),c.on("message",hl),c.on("ping",pl),c.on("pong",ml),d.onerror=wl,e.setTimeout&&e.setTimeout(0),e.setNoDelay&&e.setNoDelay(),s.length>0&&e.unshift(s),e.on("close",ja),e.on("data",mr),e.on("end",Ka),e.on("error",Wa),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){Ie(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())}),Ha(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){Di(this,e,o);return}s===void 0&&(s=!this._isServer),this._sender.ping(e||hr,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){Di(this,e,o);return}s===void 0&&(s=!this._isServer),this._sender.pong(e||hr,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){Di(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||hr,c,o)}terminate(){if(this.readyState!==n.CLOSED){if(this.readyState===n.CONNECTING){Ie(this,this._req,"WebSocket was closed before the connection was established");return}this._socket&&(this._readyState=n.CLOSING,this._socket.destroy())}}};Object.defineProperty($,"CONNECTING",{enumerable:!0,value:Qe.indexOf("CONNECTING")});Object.defineProperty($.prototype,"CONNECTING",{enumerable:!0,value:Qe.indexOf("CONNECTING")});Object.defineProperty($,"OPEN",{enumerable:!0,value:Qe.indexOf("OPEN")});Object.defineProperty($.prototype,"OPEN",{enumerable:!0,value:Qe.indexOf("OPEN")});Object.defineProperty($,"CLOSING",{enumerable:!0,value:Qe.indexOf("CLOSING")});Object.defineProperty($.prototype,"CLOSING",{enumerable:!0,value:Qe.indexOf("CLOSING")});Object.defineProperty($,"CLOSED",{enumerable:!0,value:Qe.indexOf("CLOSED")});Object.defineProperty($.prototype,"CLOSED",{enumerable:!0,value:Qe.indexOf("CLOSED")});["binaryType","bufferedAmount","extensions","isPaused","protocol","readyState","url"].forEach(n=>{Object.defineProperty($.prototype,n,{enumerable:!0})});["open","error","close","message"].forEach(n=>{Object.defineProperty($.prototype,`on${n}`,{enumerable:!0,get(){for(let e of this.listeners(n))if(e[Ci])return e[nl];return null},set(e){for(let s of this.listeners(n))if(s[Ci]){this.removeListener(n,s);break}typeof e=="function"&&this.addEventListener(n,e,{[Ci]:!0})}})});$.prototype.addEventListener=il;$.prototype.removeEventListener=sl;Ja.exports=$;function qa(n,e,s,o){let c={allowSynchronousEvents:!0,autoPong:!0,closeTimeout:el,protocolVersion:ki[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,!ki.includes(c.protocolVersion))throw new RangeError(`Unsupported protocol version: ${c.protocolVersion} (supported versions: ${ki.join(", ")})`);let d;if(e instanceof Pi)d=e;else try{d=new Pi(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:",f=d.protocol==="ws+unix:",h;if(d.protocol!=="ws:"&&!u&&!f?h=`The URL's protocol must be one of "ws:", "wss:", "http:", "https:", or "ws+unix:"`:f&&!d.pathname?h="The URL's pathname is empty":d.hash&&(h="The URL contains a fragment identifier"),h){let k=new SyntaxError(h);if(n._redirects===0)throw k;pr(n,k);return}let p=u?443:80,w=Vf(16).toString("base64"),b=u?Wf.request:Jf.request,E=new Set,I;if(c.createConnection=c.createConnection||(u?ul:xl),c.defaultPort=c.defaultPort||p,c.port=d.port||p,c.host=d.hostname.startsWith("[")?d.hostname.slice(1,-1):d.hostname,c.headers={...c.headers,"Sec-WebSocket-Version":c.protocolVersion,"Sec-WebSocket-Key":w,Connection:"Upgrade",Upgrade:"websocket"},c.path=d.pathname+d.search,c.timeout=c.handshakeTimeout,c.perMessageDeflate&&(I=new xt({...c.perMessageDeflate,isServer:!1,maxPayload:c.maxPayload}),c.headers["Sec-WebSocket-Extensions"]=ol({[xt.extensionName]:I.offer()})),s.length){for(let k of s){if(typeof k!="string"||!dl.test(k)||E.has(k))throw new SyntaxError("An invalid or duplicated subprotocol was specified");E.add(k)}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}`),f){let k=c.path.split(":");c.socketPath=k[0],c.path=k[1]}let A;if(c.followRedirects){if(n._redirects===0){n._originalIpc=f,n._originalSecure=u,n._originalHostOrSocketPath=f?c.socketPath:d.host;let k=o&&o.headers;if(o={...o,headers:{}},k)for(let[z,Y]of Object.entries(k))o.headers[z.toLowerCase()]=Y}else if(n.listenerCount("redirect")===0){let k=f?n._originalIpc?c.socketPath===n._originalHostOrSocketPath:!1:n._originalIpc?!1:d.host===n._originalHostOrSocketPath;(!k||n._originalSecure&&!u)&&(delete c.headers.authorization,delete c.headers.cookie,k||delete c.headers.host,c.auth=void 0)}c.auth&&!o.headers.authorization&&(o.headers.authorization="Basic "+Buffer.from(c.auth).toString("base64")),A=n._req=b(c),n._redirects&&n.emit("redirect",n.url,A)}else A=n._req=b(c);c.timeout&&A.on("timeout",()=>{Ie(n,A,"Opening handshake has timed out")}),A.on("error",k=>{A===null||A[Ua]||(A=n._req=null,pr(n,k))}),A.on("response",k=>{let z=k.headers.location,Y=k.statusCode;if(z&&c.followRedirects&&Y>=300&&Y<400){if(++n._redirects>c.maxRedirects){Ie(n,A,"Maximum redirects exceeded");return}A.abort();let j;try{j=new Pi(z,e)}catch{let W=new SyntaxError(`Invalid URL: ${z}`);pr(n,W);return}qa(n,j,s,o)}else n.emit("unexpected-response",A,k)||Ie(n,A,`Unexpected server response: ${k.statusCode}`)}),A.on("upgrade",(k,z,Y)=>{if(n.emit("upgrade",k),n.readyState!==$.CONNECTING)return;A=n._req=null;let j=k.headers.upgrade;if(j===void 0||j.toLowerCase()!=="websocket"){Ie(n,z,"Invalid Upgrade header");return}let oe=Yf("sha1").update(w+tl).digest("base64");if(k.headers["sec-websocket-accept"]!==oe){Ie(n,z,"Invalid Sec-WebSocket-Accept header");return}let W=k.headers["sec-websocket-protocol"],le;if(W!==void 0?E.size?E.has(W)||(le="Server sent an invalid subprotocol"):le="Server sent a subprotocol but none was requested":E.size&&(le="Server sent no subprotocol"),le){Ie(n,z,le);return}W&&(n._protocol=W);let _e=k.headers["sec-websocket-extensions"];if(_e!==void 0){if(!I){Ie(n,z,"Server sent a Sec-WebSocket-Extensions header but no extension was requested");return}let ke;try{ke=al(_e)}catch{Ie(n,z,"Invalid Sec-WebSocket-Extensions header");return}let xe=Object.keys(ke);if(xe.length!==1||xe[0]!==xt.extensionName){Ie(n,z,"Server indicated an extension that was not requested");return}try{I.accept(ke[xt.extensionName])}catch{Ie(n,z,"Invalid Sec-WebSocket-Extensions header");return}n._extensions[xt.extensionName]=I}n.setSocket(z,Y,{allowSynchronousEvents:c.allowSynchronousEvents,generateMask:c.generateMask,maxPayload:c.maxPayload,skipUTF8Validation:c.skipUTF8Validation})}),c.finishRequest?c.finishRequest(A,n):A.end()}function pr(n,e){n._readyState=$.CLOSING,n._errorEmitted=!0,n.emit("error",e),n.emitClose()}function xl(n){return n.path=n.socketPath,za.connect(n)}function ul(n){return n.path=void 0,!n.servername&&n.servername!==""&&(n.servername=za.isIP(n.host)?"":n.host),$f.connect(n)}function Ie(n,e,s){n._readyState=$.CLOSING;let o=new Error(s);Error.captureStackTrace(o,Ie),e.setHeader?(e[Ua]=!0,e.abort(),e.socket&&!e.socket.destroyed&&e.socket.destroy(),process.nextTick(pr,n,o)):(e.destroy(o),e.once("error",n.emit.bind(n,"error")),e.once("close",n.emitClose.bind(n)))}function Di(n,e,s){if(e){let o=Zf(e)?e.size:cl(e).length;n._socket?n._sender._bufferedBytes+=o:n._bufferedAmount+=o}if(s){let o=new Error(`WebSocket is not open: readyState ${n.readyState} (${Qe[n.readyState]})`);process.nextTick(s,o)}}function fl(n,e){let s=this[de];s._closeFrameReceived=!0,s._closeMessage=e,s._closeCode=n,s._socket[de]!==void 0&&(s._socket.removeListener("data",mr),process.nextTick(Ga,s._socket),n===1005?s.close():s.close(n,e))}function ll(){let n=this[de];n.isPaused||n._socket.resume()}function gl(n){let e=this[de];e._socket[de]!==void 0&&(e._socket.removeListener("data",mr),process.nextTick(Ga,e._socket),e.close(n[rl])),e._errorEmitted||(e._errorEmitted=!0,e.emit("error",n))}function Ba(){this[de].emitClose()}function hl(n,e){this[de].emit("message",n,e)}function pl(n){let e=this[de];e._autoPong&&e.pong(n,!this._isServer,Fa),e.emit("ping",n)}function ml(n){this[de].emit("pong",n)}function Ga(n){n.resume()}function wl(n){let e=this[de];e.readyState!==$.CLOSED&&(e.readyState===$.OPEN&&(e._readyState=$.CLOSING,Ha(e)),this._socket.end(),e._errorEmitted||(e._errorEmitted=!0,e.emit("error",n)))}function Ha(n){n._closeTimer=setTimeout(n._socket.destroy.bind(n._socket),n._closeTimeout)}function ja(){let n=this[de];if(this.removeListener("close",ja),this.removeListener("data",mr),this.removeListener("end",Ka),n._readyState=$.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[de]=void 0,clearTimeout(n._closeTimer),n._receiver._writableState.finished||n._receiver._writableState.errorEmitted?n.emitClose():(n._receiver.on("error",Ba),n._receiver.on("finish",Ba))}function mr(n){this[de]._receiver.write(n)||this.pause()}function Ka(){let n=this[de];n._readyState=$.CLOSING,n._receiver.end(),this.end()}function Wa(){let n=this[de];this.removeListener("error",Wa),this.on("error",Fa),n&&(n._readyState=$.CLOSING,this.destroy())}});var Xa=be((C_,Ya)=>{"use strict";var P_=wr(),{Duplex:_l}=ee("stream");function $a(n){n.emit("close")}function yl(){!this.destroyed&&this._writableState.finished&&this.destroy()}function Va(n){this.removeListener("error",Va),this.destroy(),this.listenerCount("error")===0&&this.emit("error",n)}function bl(n,e){let s=!0,o=new _l({...e,autoDestroy:!1,emitClose:!1,objectMode:!1,writableObjectMode:!1});return n.on("message",function(d,u){let f=!u&&o._readableState.objectMode?d.toString():d;o.push(f)||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($a,o);return}let u=!1;n.once("error",function(h){u=!0,d(h)}),n.once("close",function(){u||d(c),process.nextTick($a,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",yl),o.on("error",Va),o}Ya.exports=bl});var Ri=be((k_,Qa)=>{"use strict";var{tokenChars:vl}=Ut();function Sl(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&&vl[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 f=n.slice(s,o);if(e.has(f))throw new SyntaxError(`The "${f}" subprotocol is duplicated`);e.add(f),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}Qa.exports={parse:Sl}});var sc=be((R_,ic)=>{"use strict";var El=ee("events"),_r=ee("http"),{Duplex:D_}=ee("stream"),{createHash:Il}=ee("crypto"),Za=gr(),mt=Ft(),Al=Ri(),Tl=wr(),{CLOSE_TIMEOUT:Pl,GUID:Cl,kWebSocket:kl}=Ve(),Dl=/^[+/0-9A-Za-z]{22}==$/,ec=0,tc=1,rc=2,Ni=class extends El{constructor(e,s){if(super(),e={allowSynchronousEvents:!0,autoPong:!0,maxPayload:100*1024*1024,skipUTF8Validation:!1,perMessageDeflate:!1,handleProtocols:null,clientTracking:!0,closeTimeout:Pl,verifyClient:null,noServer:!1,backlog:null,server:null,host:null,path:null,port:null,WebSocket:Tl,...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=_r.createServer((o,c)=>{let d=_r.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=Rl(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=ec}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===rc){e&&this.once("close",()=>{e(new Error("The server is not running"))}),process.nextTick(hn,this);return}if(e&&this.once("close",e),this._state!==tc)if(this._state=tc,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(hn,this):process.nextTick(hn,this);else{let s=this._server;this._removeListeners(),this._removeListeners=this._server=null,s.close(()=>{hn(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",nc);let d=e.headers["sec-websocket-key"],u=e.headers.upgrade,f=+e.headers["sec-websocket-version"];if(e.method!=="GET"){wt(this,e,s,405,"Invalid HTTP method");return}if(u===void 0||u.toLowerCase()!=="websocket"){wt(this,e,s,400,"Invalid Upgrade header");return}if(d===void 0||!Dl.test(d)){wt(this,e,s,400,"Missing or invalid Sec-WebSocket-Key header");return}if(f!==13&&f!==8){wt(this,e,s,400,"Missing or invalid Sec-WebSocket-Version header",{"Sec-WebSocket-Version":"13, 8"});return}if(!this.shouldHandle(e)){pn(s,400);return}let h=e.headers["sec-websocket-protocol"],p=new Set;if(h!==void 0)try{p=Al.parse(h)}catch{wt(this,e,s,400,"Invalid Sec-WebSocket-Protocol header");return}let w=e.headers["sec-websocket-extensions"],b={};if(this.options.perMessageDeflate&&w!==void 0){let E=new mt({...this.options.perMessageDeflate,isServer:!0,maxPayload:this.options.maxPayload});try{let I=Za.parse(w);I[mt.extensionName]&&(E.accept(I[mt.extensionName]),b[mt.extensionName]=E)}catch{wt(this,e,s,400,"Invalid or unacceptable Sec-WebSocket-Extensions header");return}}if(this.options.verifyClient){let E={origin:e.headers[`${f===8?"sec-websocket-origin":"origin"}`],secure:!!(e.socket.authorized||e.socket.encrypted),req:e};if(this.options.verifyClient.length===2){this.options.verifyClient(E,(I,A,k,z)=>{if(!I)return pn(s,A||401,k,z);this.completeUpgrade(b,d,p,e,s,o,c)});return}if(!this.options.verifyClient(E))return pn(s,401)}this.completeUpgrade(b,d,p,e,s,o,c)}completeUpgrade(e,s,o,c,d,u,f){if(!d.readable||!d.writable)return d.destroy();if(d[kl])throw new Error("server.handleUpgrade() was called more than once with the same socket, possibly due to a misconfiguration");if(this._state>ec)return pn(d,503);let p=["HTTP/1.1 101 Switching Protocols","Upgrade: websocket","Connection: Upgrade",`Sec-WebSocket-Accept: ${Il("sha1").update(s+Cl).digest("base64")}`],w=new this.options.WebSocket(null,void 0,this.options);if(o.size){let b=this.options.handleProtocols?this.options.handleProtocols(o,c):o.values().next().value;b&&(p.push(`Sec-WebSocket-Protocol: ${b}`),w._protocol=b)}if(e[mt.extensionName]){let b=e[mt.extensionName].params,E=Za.format({[mt.extensionName]:[b]});p.push(`Sec-WebSocket-Extensions: ${E}`),w._extensions=e}this.emit("headers",p,c),d.write(p.concat(`\r
|
|
12
12
|
`).join(`\r
|
|
13
|
-
`)),
|
|
14
|
-
`+Object.keys(o).map(
|
|
13
|
+
`)),d.removeListener("error",nc),w.setSocket(d,u,{allowSynchronousEvents:this.options.allowSynchronousEvents,maxPayload:this.options.maxPayload,skipUTF8Validation:this.options.skipUTF8Validation}),this.clients&&(this.clients.add(w),w.on("close",()=>{this.clients.delete(w),this._shouldEmitClose&&!this.clients.size&&process.nextTick(hn,this)})),f(w,c)}};ic.exports=Ni;function Rl(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 hn(n){n._state=rc,n.emit("close")}function nc(){this.destroy()}function pn(n,e,s,o){s=s||_r.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} ${_r.STATUS_CODES[e]}\r
|
|
14
|
+
`+Object.keys(o).map(c=>`${c}: ${o[c]}`).join(`\r
|
|
15
15
|
`)+`\r
|
|
16
16
|
\r
|
|
17
|
-
`+
|
|
17
|
+
`+s)}function wt(n,e,s,o,c,d){if(n.listenerCount("wsClientError")){let u=new Error(c);Error.captureStackTrace(u,wt),n.emit("wsClientError",u,s,e)}else pn(s,o,c,d)}});import{spawn as ag}from"node:child_process";import{existsSync as cg,openSync as dg}from"node:fs";import{mkdir as xg}from"node:fs/promises";import{dirname as ug}from"node:path";import{fileURLToPath as fg}from"node:url";function Bi(n=G()){return cg(n.libEntry)?n.libEntry:fg(new URL("../index.ts",import.meta.url))}async function _n(n={}){let e=n.paths??G(),s=n.entryOverride??Bi(e);await xg(ug(e.logFile),{recursive:!0});let o=dg(e.logFile,"a"),d=s.endsWith(".ts")?["--import","tsx/esm",s,"--daemon"]:[s,"--daemon"],u=ag(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 lg.info("daemon spawned",{pid:u.pid,entry:s}),{pid:u.pid,entry:s}}var lg,Ir=Te(()=>{"use strict";q();ie();lg=N("spawn-daemon")});import{readFile as Sc}from"node:fs/promises";async function Ar(n){try{let[e,s]=await Promise.all([Sc(n.portFile,"utf8"),Sc(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 gg(n){if(!n)return null;try{return JSON.parse(n)}catch{return n}}function hg(n){return n instanceof Error?n.message:String(n)}var Ne,Tr=Te(()=>{"use strict";ie();Ne=class{paths;constructor(e){this.paths=e??G()}async probe(e=1e3){let s=await Ar(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:hg(o)}}}async request(e){let s=await Ar(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 f=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}),h=await f.text();return{status:f.status,body:gg(h)}}finally{clearTimeout(u)}}}});var Dc={};Jr(Dc,{DEFAULT_PROBE_TIMEOUT_MS:()=>kc,DEFAULT_WAIT_PID_EXIT_MS:()=>Cc,runUpgradeHelper:()=>Ng});import{copyFile as Pg,rename as qi,unlink as Gi}from"node:fs/promises";async function Ng(n){let e=n.paths??G(),s=n.spawnDaemon??_n,o=n.probeDaemon??Mg,c=n.sleep??Bg,d=n.waitPidExitMs??Cc,u=n.probeTimeoutMs??kc,f=n.killPid??((k,z)=>process.kill(k,z)),{targetVersion:h,oldPid:p}=n;je.info("upgrade-helper start",{targetVersion:h,oldPid:p}),await Og(p,d,c,f);let w=e.libEntry,b=`${w}.bak`,E=`${w}.next`;try{await Pg(w,b)}catch(k){return je.error("backup failed, abort",{err:String(k)}),1}try{await qi(E,w)}catch(k){return je.error("rename .next \u2192 live failed, abort + rollback",{err:String(k)}),await qi(b,w).catch(()=>{}),1}let I,A=!1;try{await s({paths:e}),A=await Lg(()=>o(e),u,c),A||(I="new daemon failed to come up within probeTimeout")}catch(k){I=`spawn new daemon failed: ${String(k)}`,je.warn(I)}return A?(await Tc(e,h,{ok:!0,setLibVersion:!0}),await Gi(b).catch(()=>{}),await Gi(E).catch(()=>{}),je.info("upgrade succeeded",{targetVersion:h}),0):(je.warn("upgrade failed, rolling back",{lastError:I}),await qi(b,w).catch(k=>je.error("rollback rename failed",{err:String(k)})),await s({paths:e}).catch(k=>je.error("spawn old daemon after rollback failed",{err:String(k)})),await Tc(e,h,{ok:!1,lastError:I}),await Gi(E).catch(()=>{}),1)}async function Tc(n,e,s){let o=await ct(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 Ue(o,n.configFile)}async function Og(n,e,s,o){let c=Date.now()+e;for(;Date.now()<c;){if(!Pc(n,o))return;await s(Dg)}je.warn("oldPid did not exit in time, sending SIGTERM",{pid:n});try{o(n,"SIGTERM")}catch{}if(await s(Cg),!!Pc(n,o)){je.warn("SIGTERM ineffective, sending SIGKILL",{pid:n});try{o(n,"SIGKILL")}catch{}await s(kg)}}function Pc(n,e){try{return e(n,0),!0}catch{return!1}}async function Lg(n,e,s){let o=Date.now()+e;for(;Date.now()<o;){if(await n().catch(()=>!1))return!0;await s(Rg)}return!1}async function Mg(n){return(await new Ne(n).probe(1e3).catch(()=>null))?.kind==="connected"}function Bg(n){return new Promise(e=>setTimeout(e,n))}var je,Cc,kc,Cg,kg,Dg,Rg,Rc=Te(()=>{"use strict";Mt();Ir();Tr();q();ie();je=N("upgrade-helper"),Cc=3e4,kc=3e4,Cg=5e3,kg=2e3,Dg=200,Rg=500});import{spawn as zg}from"node:child_process";import{mkdir as Fg,unlink as Ug,writeFile as qg}from"node:fs/promises";import{dirname as Gg,join as Hg}from"node:path";function kr(n){return n.replace(/&/g,"&").replace(/</g,"<").replace(/>/g,">").replace(/"/g,""")}function Nc(n,e){return new Promise((s,o)=>{let c=zg(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 Cr,Hi,ji,Oc=Te(()=>{"use strict";q();Cr=N("supervisor.launchd"),Hi="ai.coze.bridge",ji={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>${Hi}</string>
|
|
23
23
|
<key>ProgramArguments</key>
|
|
24
24
|
<array>
|
|
25
|
-
<string>${
|
|
26
|
-
<string>${
|
|
25
|
+
<string>${kr(n.nodeBin)}</string>
|
|
26
|
+
<string>${kr(n.entry)}</string>
|
|
27
27
|
<string>--daemon</string>
|
|
28
28
|
</array>
|
|
29
29
|
<key>RunAtLoad</key>
|
|
@@ -33,12 +33,12 @@ var L0=Object.create;var Yr=Object.defineProperty;var M0=Object.getOwnPropertyDe
|
|
|
33
33
|
<key>ThrottleInterval</key>
|
|
34
34
|
<integer>10</integer>
|
|
35
35
|
<key>StandardOutPath</key>
|
|
36
|
-
<string>${
|
|
36
|
+
<string>${kr(n.logFile)}</string>
|
|
37
37
|
<key>StandardErrorPath</key>
|
|
38
|
-
<string>${
|
|
38
|
+
<string>${kr(n.logFile)}</string>
|
|
39
39
|
</dict>
|
|
40
40
|
</plist>
|
|
41
|
-
`},configPath(n){return Hg(n.homeDir,"Library","LaunchAgents",`${
|
|
41
|
+
`},configPath(n){return Hg(n.homeDir,"Library","LaunchAgents",`${Hi}.plist`)},async install(n){let e=this.configPath(n);await Fg(Gg(e),{recursive:!0}),await qg(e,this.renderConfig(n),"utf8"),Cr.info("plist written",{plistPath:e}),await Nc("launchctl",["load","-w",e]),Cr.info("launchd job loaded",{label:Hi})},async uninstall(n){let e=this.configPath(n);await Nc("launchctl",["unload","-w",e]).catch(s=>Cr.warn("launchctl unload failed (ignored)",{err:String(s)})),await Ug(e).catch(s=>{if(s.code!=="ENOENT")throw s}),Cr.info("launchd job removed",{plistPath:e})}}});import{spawn as jg}from"node:child_process";import{mkdir as Kg,unlink as Wg,writeFile as Jg}from"node:fs/promises";import{dirname as $g,join as Vg}from"node:path";function Nr(n,e){return new Promise((s,o)=>{let c=jg(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 Dr,Rr,Ki,Lc=Te(()=>{"use strict";q();Dr=N("supervisor.systemd"),Rr="coze-bridge.service",Ki={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 Vg(n.homeDir,".config","systemd","user",
|
|
55
|
+
`},configPath(n){return Vg(n.homeDir,".config","systemd","user",Rr)},async install(n){let e=this.configPath(n);await Kg($g(e),{recursive:!0}),await Jg(e,this.renderConfig(n),"utf8"),Dr.info("systemd unit written",{unitPath:e}),await Nr("systemctl",["--user","daemon-reload"]),await Nr("systemctl",["--user","enable","--now",Rr]),Dr.info("systemd unit enabled",{unitName:Rr})},async uninstall(n){let e=this.configPath(n);await Nr("systemctl",["--user","disable","--now",Rr]).catch(s=>Dr.warn("systemctl disable failed (ignored)",{err:String(s)})),await Wg(e).catch(s=>{if(s.code!=="ENOENT")throw s}),await Nr("systemctl",["--user","daemon-reload"]).catch(()=>{}),Dr.info("systemd unit removed",{unitPath:e})}}});import{spawn as Yg}from"node:child_process";import{join as Xg}from"node:path";function Mc(n,e){return new Promise((s,o)=>{let c=Yg(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 Wi,Or,Ji,Bc=Te(()=>{"use strict";q();Wi=N("supervisor.taskscheduler"),Or="CozeBridge",Ji={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,19 +76,19 @@ WantedBy=default.target
|
|
|
76
76
|
</Exec>
|
|
77
77
|
</Actions>
|
|
78
78
|
</Task>
|
|
79
|
-
`},configPath(n){return Xg(n.homeDir,".coze","bridge","task.xml")},async install(n){let e=`"${n.nodeBin}" "${n.entry}" --daemon`;await
|
|
80
|
-
${n.stack??""}`:String(n);return Y0.test(
|
|
81
|
-
`)[0]?.trim()||void 0}catch{return}}async function
|
|
79
|
+
`},configPath(n){return Xg(n.homeDir,".coze","bridge","task.xml")},async install(n){let e=`"${n.nodeBin}" "${n.entry}" --daemon`;await Mc("schtasks",["/Create","/SC","ONLOGON","/TN",Or,"/TR",e,"/RU",n.userName,"/F"]),Wi.info("task scheduler entry created",{task:Or})},async uninstall(n){await Mc("schtasks",["/Delete","/TN",Or,"/F"]).catch(e=>Wi.warn("schtasks /Delete failed (ignored)",{err:String(e)})),Wi.info("task scheduler entry removed",{task:Or})}}});var $i={};Jr($i,{buildContext:()=>th,getSupervisor:()=>eh,launchdSupervisor:()=>ji,systemdSupervisor:()=>Ki,taskSchedulerSupervisor:()=>Ji});import{homedir as Qg,userInfo as Zg}from"node:os";function eh(n=process.platform){switch(n){case"darwin":return ji;case"linux":return Ki;case"win32":return Ji;default:throw new Error(`unsupported platform for OS supervisor: ${n}`)}}function th(){let n=G();return{nodeBin:process.execPath,entry:Bi(n),logFile:n.logFile,homeDir:Qg(),userName:Zg().username}}var Vi=Te(()=>{"use strict";ie();Ir();Oc();Lc();Bc()});q();q();import{execFile as H0}from"node:child_process";import{promisify as j0}from"node:util";var bs=j0(H0),Vt=N("agents.acp-installer"),K0={"claude-code":{npmPackage:"@agentclientprotocol/claude-agent-acp",binary:"claude-agent-acp"},codex:{npmPackage:"@zed-industries/codex-acp",binary:"codex-acp"}},W0=5e4,J0=5e3,$0=5*6e4,V0=new Set(["ETIMEDOUT","ECONNRESET","ECONNREFUSED","ENETUNREACH","EAI_AGAIN","ERR_SOCKET_TIMEOUT","ENOTFOUND"]),Y0=/\b(5\d\d|408|429)\b\s+(Bad Gateway|Service Unavailable|Gateway Timeout|Internal Server Error|Too Many Requests|Request Timeout)/i,X0=/fetch failed|request timed out|socket hang up|network timeout/i;function Q0(n){let e=n?.code;if(e&&V0.has(e))return!0;let s=n instanceof Error?`${n.message}
|
|
80
|
+
${n.stack??""}`:String(n);return Y0.test(s)||X0.test(s)}function Z0(n){if(n==null||typeof n!="object")return String(n);let e=n,s=[];e.message&&s.push(e.message),e.code!==void 0&&e.code!==null&&s.push(`code=${e.code}`),e.signal&&s.push(`signal=${e.signal}`);let o=e.stderr?.toString().trim();o&&s.push(`stderr=${o.slice(0,2e3)}`);let c=e.stdout?.toString().trim();return c&&s.push(`stdout=${c.slice(0,2e3)}`),s.length>0?s.join(" | "):String(n)}var In=new Map,En=new Map,An=new Map;async function ys(n){let e=process.platform==="win32"?"where":"which";try{let{stdout:s}=await bs(e,[n],{timeout:J0});return s.split(`
|
|
81
|
+
`)[0]?.trim()||void 0}catch{return}}async function ed(n,e){Vt.info("npm install -g start",{npmPackage:n}),await bs("npm",["install","-g",`${n}@latest`],{timeout:W0,maxBuffer:10*1024*1024,...e?{signal:e}:{}}),Vt.info("npm install -g done",{npmPackage:n})}async function It(n,e){let s=K0[n];if(!s)return;let o=In.get(n);if(o)return o;let c=En.get(n);if(c&&Date.now()-c<$0)return;let d=An.get(n);if(d)return d;let u=(async()=>{let f=await ys(s.binary);if(f)return In.set(n,f),Vt.info("acp wrapper found on PATH",{binary:s.binary,path:f}),f;try{await ed(s.npmPackage,e)}catch(p){let w=Q0(p);Vt.warn("acp wrapper install failed (will fallback to npx)",{npmPackage:s.npmPackage,transient:w,err:Z0(p)}),w||En.set(n,Date.now());return}let h=await ys(s.binary);if(!h){Vt.warn("acp wrapper installed but binary not found on PATH",{binary:s.binary}),En.set(n,Date.now());return}return In.set(n,h),En.delete(n),h})().finally(()=>{An.delete(n)});return An.set(n,u),u}function At(n){return In.get(n)}function vs(n){return An.get(n)}var Ss=N("acp-installer-warmup"),td=["claude-code","codex"];async function Es(n={}){let e=n.ensure??It,o=(await Promise.allSettled(td.map(async c=>{let d=await e(c);Ss.info("acp wrapper warmup ok",{framework:c,installed:!!d,path:d??""})}))).filter(c=>c.status==="rejected");o.length>0&&Ss.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))})}it();q();import{readdir as gd}from"node:fs/promises";import{mkdir as Ds,writeFile as Rs}from"node:fs/promises";import{join as Vr}from"node:path";var ud={"claude-code":"CLAUDE.md",codex:"AGENTS.md",openclaw:"SOUL.md"};async function Pt(n,e,s,o){await Ds(n,{recursive:!0});let c=ud[e],d=Vr(n,c),u=fd(e,s,o);return await Rs(d,u,"utf8"),d}async function Ns(n){let e=Vr(n,".claude");await Ds(e,{recursive:!0});let s=Vr(e,"settings.local.json"),o=JSON.stringify({permissions:{defaultMode:"bypassPermissions"}},null,2);return await Rs(s,o,"utf8"),s}function fd(n,e,s){let o=`# Coze Agent: ${e}
|
|
82
82
|
|
|
83
83
|
> framework: \`${n}\`
|
|
84
84
|
|
|
85
|
-
`,
|
|
86
|
-
`)?
|
|
85
|
+
`,c=s?.trim()?s.endsWith(`
|
|
86
|
+
`)?s:`${s}
|
|
87
87
|
`:`_No instructions provided._
|
|
88
88
|
`;return`${o}---
|
|
89
89
|
|
|
90
|
-
${
|
|
91
|
-
${
|
|
90
|
+
${c}
|
|
91
|
+
${ld}`}var ld=`## \u53D1\u9001\u6587\u4EF6 / \u56FE\u7247\u7ED9\u7528\u6237
|
|
92
92
|
|
|
93
93
|
\u6BCF\u6761\u7528\u6237\u6D88\u606F\u5F00\u5934\u4F1A\u6709\u4E91\u7AEF\u6CE8\u5165\u7684 \`<coze-context>\` \u5757, \u5F62\u5982:
|
|
94
94
|
|
|
@@ -112,26 +112,26 @@ ${lx}`}var lx=`## \u53D1\u9001\u6587\u4EF6 / \u56FE\u7247\u7ED9\u7528\u6237
|
|
|
112
112
|
- \`sessionId\` \u5FC5\u987B\u7528\u4E91\u7AEF \`<coze-context>\` \u7ED9\u7684 ID, **\u4E0D\u8981**\u81EA\u5DF1\u7F16\u6216\u8005\u7528\u5176\u5B83\u6765\u6E90
|
|
113
113
|
|
|
114
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
|
|
115
|
-
`;var
|
|
116
|
-
`)}}function ri(n){return`coze-session-${n.replace(/[^A-Za-z0-9_-]+/g,"-")}`}function Xs(n,e){if(!n.modelToken)return null;let i=n.model||ze,o=ni(e),a=["text"];n.modelInfo?.capabilities?.image===!0&&a.push("image");let x={baseUrl:`${ti}/v1`,api:"openai-completions",apiKey:n.modelToken,models:[{id:i,name:i,reasoning:!1,input:a,cost:{input:0,output:0,cacheRead:0,cacheWrite:0},contextWindow:n.modelInfo?.contextWindow??128e3,maxTokens:8192,api:"openai-completions"}]};return Object.keys(o).length>0&&(x.headers=o),x}function Zs(n,e){if(!n.modelToken)return[];let i=ni(e),o=[];for(let[a,x]of Object.entries(i))o.push("-c",`model_providers.coze.http_headers.${a}="${x}"`);return o}var xe=D("agent-handlers"),eo=5*1024*1024,Ax=1,Px=6,Cx=new Set(["node_modules",".git",".coze","dist","build",".next"]),Hn=class{constructor(e){this.opts=e}opts;async listSkills(e){Ze(e._meta,"_agent/listSkills");let i=Bt(e._meta),o=await this.loadAgentCfg(i),a=o?.workspace??Xe(i).workspace,x=o?.skills??[],u=[];for(let f of x){let g=Fe(a,f.relPath,"SKILL.md");await Sx(g).then(y=>y.isFile()).catch(()=>!1)&&u.push(Nx(f))}return{skills:u}}async addSkills(e){Ze(e._meta,"_agent/addSkills");let i=Bt(e._meta),o=await this.requireAgentCfg(i),a=e.skills??[],x=[...o.skills??[]],u=new Map(x.map((g,m)=>[g.skillId,m])),f=[];for(let g of a){let m=await si({agentId:i,workspace:o.workspace,framework:o.framework,skill:g});oi(x,u,m),f.push(g)}return await Mn(i,x),this.reloadAgentSessions(i,"skills-added"),{installedSkills:f}}async removeSkills(e){Ze(e._meta,"_agent/removeSkills");let i=Bt(e._meta),o=await this.requireAgentCfg(i),a=new Set(e.skillIds??[]),x=o.skills??[],u=[];for(let f of x){if(!a.has(f.skillId)){u.push(f);continue}let g=Fe(o.workspace,f.relPath);await vx(g,{recursive:!0,force:!0}),xe.info("skill removed",{agentId:i,skillId:f.skillId,relPath:f.relPath})}return await Mn(i,u),this.reloadAgentSessions(i,"skills-removed"),{ok:!0}}reloadAgentSessionsPublic(e,i){this.reloadAgentSessions(e,i)}reloadAgentSessions(e,i){let o=this.opts.agents.get(e);if(o)for(let[a,x]of o.sessions){if(!x.downstream)continue;let u=x.acpSessionId;if(u&&o.activeTriggers.has(u)||this.isRuntimePendingPermission(x)){x.reloadAfterTurn=!0,xe.info("downstream busy, scheduling reload after turn",{reason:i,agentId:e,framework:o.framework,cloudId:a,acpId:u});continue}let g=x.downstream;x.downstream=void 0,xe.info("killing downstream for workspace reload (idle)",{reason:i,agentId:e,framework:o.framework,cloudId:a,acpId:u}),g.stop(i).catch(m=>xe.warn("downstream stop failed during reload (ignored)",{reason:i,agentId:e,cloudId:a,err:String(m)}))}}isRuntimePendingPermission(e){let i=this.opts.isRuntimePendingPermission;return!i||!e.downstream?!1:i(e.downstream)}async updateAgent(e){if(!e.cozeIdentity?.trim())return xe.info("_agent/update: empty cozeIdentity, noop",{agentId:e.agentId}),{ok:!0};let i=e.agentId,o=await pe(i);if(!o)throw new v("AGENT_NOT_FOUND",`agent not found: ${i}`);if(o.cozeIdentity===e.cozeIdentity)return xe.info("_agent/update: cozeIdentity unchanged, noop",{agentId:i}),{ok:!0};try{await Mt(o.workspace,o.framework,i,e.cozeIdentity)}catch(a){throw xe.error("_agent/update: writeInstructionFile failed, aborting update",{agentId:i,framework:o.framework,workspace:o.workspace,err:String(a)}),new v("AGENT_PROTOCOL_ERROR",`failed to write instruction file for agent ${i}: ${String(a)}`,{cause:a})}return o.cozeIdentity=e.cozeIdentity,await Ee(o),xe.info("_agent/update: cozeIdentity rewritten",{agentId:i,framework:o.framework}),this.reloadAgentSessions(i,"identity-changed"),{ok:!0}}async disconnectAgent(e){let i=e.agentId;if(!i)throw new v("IPC_BAD_REQUEST","_agent/disconnect: missing agentId");let o=await pe(i);return o?(o.disconnectedAt=Date.now(),o.disconnectReason=e.reason??"",await Ee(o),xe.info("agent disconnected",{agentId:i,reason:e.reason??"",force:e.force??!1}),this.opts.disposeAndMarkDisconnected&&await this.opts.disposeAndMarkDisconnected(i,e.reason??"disconnect"),{ok:!0}):(xe.warn("_agent/disconnect: agent not found, ignoring",{agentId:i}),{ok:!0})}async switchModel(e){if(Ze(e._meta,"_agent/switchModel"),!e.agentId)throw new v("IPC_BAD_REQUEST","_agent/switchModel: missing agentId");let i=e.model?.trim()?e.model:ze,o=await pe(e.agentId);if(!o)throw new v("AGENT_NOT_FOUND",`agent not found: ${e.agentId}`);o.model=i,e.modelInfo&&(o.modelInfo=e.modelInfo),await Ee(o),xe.info("_agent/switchModel: model persisted",{agentId:e.agentId,model:i,reason:e.reason??""});let a=this.opts.agents.get(e.agentId);if(!a)return xe.info("_agent/switchModel: agent not running, config persisted only",{agentId:e.agentId}),{ok:!0};a.model=i,e.modelInfo&&a.setModelInfo(e.modelInfo),this.opts.cleanupOpenclawProviders&&await this.opts.cleanupOpenclawProviders(a).catch(u=>xe.warn("cleanupOpenclawProviders before switchModel failed (ignored)",{agentId:e.agentId,err:String(u)}));let x=[];for(let[u,f]of a.allSessionQueues())x.push(f.enqueue(async()=>{let g=a.sessions.get(u);g?.downstream&&(await g.downstream.stop(`switchModel: ${i}`).catch(()=>{}),g.downstream=void 0)}));return await Promise.all(x),xe.info("_agent/switchModel: all session runtimes killed, next prompt will respawn",{agentId:e.agentId,model:i,cloudSessions:x.length}),{ok:!0}}async resetAgent(e){if(Ze(e._meta,Be.RESET),!e.agentId)throw new v("IPC_BAD_REQUEST",`${Be.RESET}: missing agentId`);return await this.runDetailSync(e.agentId,Be.RESET,e.reason),{ok:!0}}async repairAgent(e){if(Ze(e._meta,Be.REPAIR),!e.agentId)throw new v("IPC_BAD_REQUEST",`${Be.REPAIR}: missing agentId`);let i=await this.loadAgentCfg(e.agentId);if(i&&i.framework!=="openclaw")throw new v("IPC_BAD_REQUEST",`${Be.REPAIR} only allowed for openclaw, got ${i.framework}`);if(i&&this.opts.openclawRepair)try{await this.opts.openclawRepair(e.agentId,i.workspace)}catch(o){xe.warn("openclaw repair (delete+add) failed (ignored)",{agentId:e.agentId,reason:e.reason,err:String(o)})}return await this.runDetailSync(e.agentId,Be.REPAIR,e.reason),{ok:!0}}async runDetailSync(e,i,o){if(!this.opts.detailSyncer){xe.warn("detailSyncer not wired, skipping sync",{method:i,agentId:e});return}try{await this.opts.detailSyncer(e)}catch(a){xe.warn("detail sync failed (ignored)",{method:i,agentId:e,reason:o,err:String(a)})}}async getFileTree(e){Ze(e._meta,"_agent/getFileTree");let i=e._meta,o=Bt(i),a=await this.resolveWorkspace(o),x=e.filePath??"",u=this.safeJoin(a,x),f=await ii(u).catch(()=>null);if(!f)throw new v("IPC_BAD_REQUEST",`path not found: ${x}`);if(f.isSymbolicLink())throw new v("IPC_BAD_REQUEST",`symlink not allowed: ${x}`);let g=qx(e.depth);return f.isDirectory()?{tree:await Ux(a,u,x,g)}:{tree:[{name:Gx(x),path:oo(x||"."),isDir:!1,size:f.size,modifiedAt:Math.floor(f.mtimeMs)}]}}async getFileContent(e){Ze(e._meta,"_agent/getFileContent");let i=Bt(e._meta),o=await this.resolveWorkspace(i);if(!e.filePath)throw new v("IPC_BAD_REQUEST","filePath required");let a=this.safeJoin(o,e.filePath),x=await ii(a).catch(()=>null);if(!x||!x.isFile())throw new v("IPC_BAD_REQUEST",`not a file: ${e.filePath}`);if(x.isSymbolicLink())throw new v("IPC_BAD_REQUEST",`symlink not allowed: ${e.filePath}`);if(x.size>eo)throw new v("IPC_BAD_REQUEST",`file too large: ${x.size} bytes (max ${eo})`);let u=await no(a);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 i=this.opts.agents.get(e);return i?i.workspace:(await pe(e).catch(()=>null))?.workspace??Xe(e).workspace}safeJoin(e,i){let o=Ix(e,i||"."),a=ro(e,o);if(a.startsWith("..")||a===".."||a.startsWith(`..${io}`))throw new v("IPC_BAD_REQUEST",`path escapes workspace: ${i}`);return o}loadAgentCfg(e){return pe(e)}async requireAgentCfg(e){let i=await this.loadAgentCfg(e);if(!i)throw new v("AGENT_NOT_FOUND",`no config for agent: ${e}`);return i}};function Tx(n){let e=n.trim().replace(/[\x00-\x1f<>:"|?*/\\]+/g,"-").replace(/^[\s.-]+|[\s.-]+$/g,"").slice(0,64);if(!e||e==="."||e==="..")throw new v("IPC_BAD_REQUEST",`invalid skill name: ${n}`);if(/^(con|prn|aux|nul|com[1-9]|lpt[1-9])$/i.test(e))throw new v("IPC_BAD_REQUEST",`reserved windows filename: ${n}`);return e}function kx(n){return n==="claude-code"?Fe(".claude","skills"):Fe(".agents","skills")}var Dx=3e4,Rx=50*1024*1024,Kn=3e4;async function si(n){let{agentId:e,workspace:i,framework:o,skill:a}=n;if(!a.skillName)throw new v("IPC_BAD_REQUEST","skill missing skillName");let x=typeof a.content=="string"&&a.content.length>0,u=typeof a.downloadUrl=="string"&&a.downloadUrl.length>0;if(!x&&!u)throw new v("IPC_BAD_REQUEST",`skill ${a.skillId} missing both content and downloadUrl`);let f=Tx(a.skillName),g=kx(o),m=Fe(g,f),y=Fe(i,m);if(await yx(y,{recursive:!0}),x){let S=Buffer.from(a.content,"utf8");on(S.length),await Qs(Fe(y,"SKILL.md"),S,"utf8")}else{let S=await Ox(a.downloadUrl);Mx(S)?await Bx(S,y):await Qs(Fe(y,"SKILL.md"),S.toString("utf8"),"utf8")}let _={skillId:a.skillId,skillName:a.skillName,relPath:m,installedAt:Date.now(),...a.description?{description:a.description}:{},...a.icon?{icon:a.icon}:{},...a.version?{version:a.version}:{},...a.downloadUrl?{downloadUrl:a.downloadUrl}:{},...a.config?{config:a.config}:{},...a.builtin?{builtin:a.builtin}:{}};return xe.info("skill installed",{agentId:e,skillId:a.skillId,skillName:a.skillName,relPath:m,source:x?"content":"downloadUrl"}),_}function oi(n,e,i){let o=e.get(i.skillId);if(o!==void 0){n[o]=i;return}e.set(i.skillId,n.length),n.push(i)}function Nx(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 Ox(n){if(!n)throw new v("IPC_BAD_REQUEST","skill missing downloadUrl");if(n.startsWith("data:")){let e=Math.floor(n.length*3/4);on(e);let i=Lx(n);return on(i.length),i}if(n.startsWith("file:")){let e=new URL(n).pathname,i=await no(e);return on(i.length),i}if(Fn(n)){let e=new AbortController,i=setTimeout(()=>e.abort(),Dx);try{let o=await fetch(n,{signal:e.signal});if(!o.ok)throw new v("IPC_BAD_REQUEST",`fetch skill failed HTTP ${o.status} ${n}`);let a=await o.arrayBuffer();return on(a.byteLength),Buffer.from(a)}finally{clearTimeout(i)}}throw new v("IPC_BAD_REQUEST",`unsupported downloadUrl scheme (\u8981 https/data/file): ${n.slice(0,80)}`)}function on(n){if(n>Rx)throw new v("IPC_BAD_REQUEST",`skill too large: ${n} bytes`)}function Lx(n){let e=/^data:([^,;]*)(;base64)?,(.*)$/s.exec(n);if(!e)throw new v("IPC_BAD_REQUEST","bad data URL");let i=!!e[2],o=e[3]??"";return i?Buffer.from(o,"base64"):Buffer.from(decodeURIComponent(o),"utf8")}function Mx(n){return n.length>=2&&n[0]===31&&n[1]===139}async function Bx(n,e){await zx(n),await new Promise((i,o)=>{let a=to("tar",["-xzf","-","-C",e,"--strip-components=1","--no-same-owner"],{stdio:["pipe","pipe","pipe"]}),x="";a.stderr?.on("data",f=>{x+=String(f)});let u=setTimeout(()=>{a.kill("SIGKILL"),o(new v("IPC_BAD_REQUEST",`tar extract timeout (${Kn}ms)`))},Kn);a.on("error",f=>{clearTimeout(u),o(new v("IPC_BAD_REQUEST",`tar spawn failed: ${f.message}`,{cause:f}))}),a.on("exit",f=>{clearTimeout(u),f===0?i():o(new v("IPC_BAD_REQUEST",`tar exit ${f}${x?`: ${x.trim().slice(0,200)}`:""}`))}),a.stdin?.end(n)})}async function zx(n){let e=await new Promise((i,o)=>{let a=to("tar",["-tzvf","-"],{stdio:["pipe","pipe","pipe"]}),x="",u="";a.stdout?.on("data",g=>{x+=String(g)}),a.stderr?.on("data",g=>{u+=String(g)});let f=setTimeout(()=>{a.kill("SIGKILL"),o(new v("IPC_BAD_REQUEST",`tar list timeout (${Kn}ms)`))},Kn);a.on("error",g=>{clearTimeout(f),o(new v("IPC_BAD_REQUEST",`tar list spawn failed: ${g.message}`))}),a.on("exit",g=>{clearTimeout(f),g===0?i(x):o(new v("IPC_BAD_REQUEST",`tar list exit ${g}${u?`: ${u.trim().slice(0,200)}`:""}`))}),a.stdin?.end(n)});for(let i of e.split(`
|
|
117
|
-
`)){let o=
|
|
118
|
-
`}var
|
|
119
|
-
`);this.buffer=i.pop()??"";let o=[];for(let a of i){let x=a.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(i){return this.onError?.({line:e,error:i}),[]}}};var go={"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"},Np=Object.fromEntries(Object.entries(go).map(([n,e])=>[e,n])),Vx={"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:[]},Ut=class{seq=0;next(e,i){this.seq+=1;let o=go[e]??Yx(e),a=Vx[o]??[],x=[o,String(this.seq)];if(a.length>0){let u=a.map(g=>lo(i?.[g]??"")),f=Xx(u).join(":");f&&x.push(f)}else i&&Object.values(i).some(u=>u)&&x.push(Object.values(i).filter(Boolean).map(u=>lo(String(u))).join(":"));return x.join("_")}reset(){this.seq=0}};function Yx(n){return n.replace(/[\s/]+/g,".").replace(/_+/g,"-")}function lo(n){return n.replace(/[:_\s]+/g,"-")}function Xx(n){let e=n.length;for(;e>0&&!n[e-1];)e-=1;return n.slice(0,e)}function lt(n,e){let i=process.env[n];if(!i)return e;let o=Number(i);return Number.isFinite(o)&&o>0?o:e}U();var ed=lt("COZE_BRIDGE_INITIALIZE_TIMEOUT_MS",3e4),td=200,nd=/(ENOTEMPTY|EEXIST).*_npx[/\\]/;function ai(n){return n.some(e=>nd.test(e))}var rd=lt("COZE_BRIDGE_SESSION_PROMPT_MAX_MS",3600*1e3),id=lt("COZE_BRIDGE_SESSION_PROMPT_FRAME_IDLE_MS",600*1e3),ho=500;function sd(n){try{let e=JSON.stringify(n);return e===void 0||e.length<=ho?n:`${e.slice(0,ho)}...<truncated, total ${e.length} chars>`}catch{return"<unserializable>"}}function po(n,e){if(!(typeof n!="number"||n<=0))try{if(process.platform==="win32"){let i=["/PID",String(n),"/T"];e==="SIGKILL"&&i.push("/F"),Qx("taskkill",i,{stdio:"ignore",windowsHide:!0})}else process.kill(-n,e)}catch{}}var qe=class{constructor(e){this.opts=e;this.log=D(`downstream.${this.constructor.name}`),this.decoder=new $n({onError:i=>this.log.warn("decode line failed",{line:i.line})})}opts;child;decoder;pending=new Map;inflightAgentRequests=new Map;idAllocator=new Ut;updateHandlers=[];agentRequestHandlers=[];exitHandlers=[];log;stopped=!1;stderrRing=[];sanitizeEnv(e){return e}async start(){if(this.child)throw new v("BRIDGE_INTERNAL","Downstream already started");let e=process.platform!=="win32",i=Zx(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=i,i.stdout?.setEncoding("utf8"),i.stdout?.on("data",o=>{try{for(let a of this.decoder.push(o))this.dispatch(a)}catch(a){this.log.warn("stdout dispatch threw, swallowed to keep daemon alive",{err:String(a)})}}),i.stderr?.setEncoding("utf8"),i.stderr?.on("data",o=>{let a=o.trimEnd();this.stderrRing.push(a),this.stderrRing.length>td&&this.stderrRing.shift(),this.log.debug("stderr",{text:a})}),i.stdin?.on("error",o=>{this.log.warn("child stdin error",{err:String(o)})}),i.stdout?.on("error",o=>{this.log.warn("child stdout error",{err:String(o)})}),i.stderr?.on("error",o=>{this.log.warn("child stderr error",{err:String(o)})}),i.on("exit",(o,a)=>{this.stopped=!0,(o!==0||a!==null)&&this.stderrRing.length>0&&(this.log.warn("downstream exited abnormally, recent stderr",{code:o,signal:a,recentStderr:[...this.stderrRing]}),(this.framework==="claude-code"||this.framework==="codex")&&ai(this.stderrRing)&&(this.log.warn("npx cache corruption detected, triggering global install fallback (D93)",{framework:this.framework}),Nt(this.framework).catch(f=>{this.log.warn("D93 fallback install failed (will retry next spawn cycle)",{framework:this.framework,err:String(f)})})));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 v("AGENT_PROTOCOL_ERROR",`agent exited (${o}/${a})`));for(let u of this.exitHandlers)u(o,a)}),i.on("error",o=>{this.log.error("child error",{err:String(o)}),this.failAllPending(new v("AGENT_SPAWN_FAILED",String(o),{cause:o}))}),this.log.info("downstream started",{command:this.opts.command,pid:i.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 i=this.child,o=new Promise(x=>i.once("exit",()=>x()));po(i.pid,"SIGTERM");let a=setTimeout(()=>{i.killed||po(i.pid,"SIGKILL")},5e3);try{await o}finally{clearTimeout(a)}}pid(){return this.child?.pid}isAlive(){return!!this.child&&!this.stopped}getStderrTail(){return[...this.stderrRing]}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,i=rd,o=id){return this.call("session/prompt",e,i,o)}async sessionCancel(e){!this.child||this.stopped||this.writeFrame(xn("session/cancel",e))}onUpdate(e){this.updateHandlers.push(e)}onAgentRequest(e){this.agentRequestHandlers.push(e)}respondAgentRequest(e,i){if(this.inflightAgentRequests.delete(e),!(!this.child||this.stopped))try{this.writeFrame(Ft(e,i))}catch(o){this.log.warn("respondAgentRequest write failed",{id:e,err:String(o)})}}respondAgentRequestError(e,i){if(this.inflightAgentRequests.delete(e),!(!this.child||this.stopped))try{this.writeFrame(ft(e,i))}catch(o){this.log.warn("respondAgentRequestError write failed",{id:e,err:String(o)})}}onExit(e){this.exitHandlers.push(e)}call(e,i,o=ed,a=0){if(!this.child||this.stopped)return Promise.reject(new v("AGENT_PROTOCOL_ERROR","downstream not started"));let x=this.idAllocator.next(e),u=cn(x,e,i),f=o>0&&Number.isFinite(o),g=a>0&&Number.isFinite(a);return new Promise((m,y)=>{let _={resolve:m,reject:y,timer:null,frameIdleTimer:null,armFrameIdle:null,method:e};f&&(_.timer=setTimeout(()=>{this.pending.delete(x),_.frameIdleTimer&&clearTimeout(_.frameIdleTimer),y(new v("AGENT_TIMEOUT",`${e} timed out after ${o}ms`))},o));let S=g?()=>{_.frameIdleTimer&&clearTimeout(_.frameIdleTimer),_.frameIdleTimer=setTimeout(()=>{if(this.inflightAgentRequests.size>0){this.log.debug("frame-idle fired but agent request inflight, re-arming",{id:x,method:e,inflight:this.inflightAgentRequests.size}),S?.();return}_.timer&&clearTimeout(_.timer),this.pending.delete(x),this.log.warn("frame-idle timeout, rejecting pending call",{id:x,method:e,frameIdleMs:a}),y(new v("AGENT_FRAME_IDLE_TIMEOUT",`${e} no session/update for ${a}ms (no inflight agent request)`))},a)}:null;_.armFrameIdle=S,this.pending.set(x,_),S?.();try{this.writeFrame(u)}catch(E){_.timer&&clearTimeout(_.timer),_.frameIdleTimer&&clearTimeout(_.frameIdleTimer),this.pending.delete(x),y(E)}})}writeFrame(e){if(!this.child?.stdin||this.child.stdin.destroyed)throw new v("AGENT_PROTOCOL_ERROR","downstream stdin not writable");this.child.stdin.write(fo(e),i=>{i&&this.log.warn("stdin write callback err",{err:String(i)})})}dispatch(e){if(Wn(e)){let i=e.id!==null?this.pending.get(e.id):void 0;if(!i){this.log.warn("orphan response",{id:e.id});return}this.pending.delete(e.id),i.timer&&clearTimeout(i.timer),i.frameIdleTimer&&clearTimeout(i.frameIdleTimer),e.error?(this.log.warn("downstream returned error frame",{id:e.id,method:i.method,code:e.error.code,message:e.error.message,data:e.error.data}),i.reject(xo(e.error))):e.result===void 0?(this.log.warn("downstream response missing both result and error",{id:e.id,method:i.method}),i.reject(new v("AGENT_PROTOCOL_ERROR",`${i.method} response missing both result and error`))):(this.log.info("downstream returned result",{id:e.id,method:i.method,result:sd(e.result)}),i.resolve(e.result));return}if(co(e)){if(e.method==="session/update"){for(let i of this.pending.values())i.armFrameIdle?.();for(let i of this.updateHandlers)try{Promise.resolve(i(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(ao(e)){let i=e;try{this.handleAgentRequest(i).catch(o=>this.log.error("agent request handler failed (async)",{method:i.method,err:String(o)}))}catch(o){this.log.warn("handleAgentRequest threw sync, swallowed",{method:i.method,err:String(o)})}}}async handleAgentRequest(e){if(this.agentRequestHandlers.length===0){this.writeFrame(ft(e.id,{code:-32601,message:`method not handled by Bridge: ${e.method}`}));return}this.inflightAgentRequests.set(e.id,e.method);for(let i of this.agentRequestHandlers)try{await i(e)}catch(o){this.log.error("agentRequestHandler threw",{method:e.method,err:String(o)});try{this.writeFrame(ft(e.id,un(o)))}catch{}this.inflightAgentRequests.delete(e.id)}}failAllPending(e){for(let i of this.pending.values())i.timer&&clearTimeout(i.timer),i.frameIdleTimer&&clearTimeout(i.frameIdleTimer),i.reject(e);this.pending.clear(),this.inflightAgentRequests.clear()}};var od="@agentclientprotocol/claude-agent-acp@latest";function ad(n){let e={};for(let[i,o]of Object.entries(n))o!==void 0&&(i.startsWith("CLAUDE")||i==="AI_AGENT"||i==="BAGGAGE"||(e[i]=o));return e}var Jn=class extends qe{framework="claude-code";constructor(e){let i=Ot("claude-code"),[o,a]=i?[i,[]]:["npx",["-y",od]],x=e.command??o,u=e.args??a,f={command:x,args:u,cwd:e.cwd,...e.env?{env:e.env}:{}};super(f)}sanitizeEnv(e){return ad(e)}};import{mkdtempSync as cd,rmSync as xd}from"node:fs";import{tmpdir as dd}from"node:os";import{join as ud}from"node:path";var fd="@zed-industries/codex-acp@latest",Vn=class extends qe{framework="codex";authMethodId;codexHomeDir;constructor(e){let i=Ot("codex"),[o,a]=i?[i,[]]:["npx",["-y",fd]],x=e.command??o,u=e.args??a,f=e.extraArgs?[...u,...e.extraArgs]:u,g=e.isolateCodexHome?cd(ud(dd(),"coze-bridge-codex-home-")):void 0,m=g?{...e.env??{},CODEX_HOME:g}:e.env,y={command:x,args:f,cwd:e.cwd,...m?{env:m}:{}};super(y),this.authMethodId=e.authMethodId,this.codexHomeDir=g}async initialize(e){let i=await super.initialize(e);return this.authMethodId&&await this.call("authenticate",{methodId:this.authMethodId}),i}async stop(e){if(await super.stop(e),this.codexHomeDir)try{xd(this.codexHomeDir,{recursive:!0,force:!0})}catch{}}};var ld=3e4,qt=class extends qe{framework="openclaw";agentId;sessionName;slashModelOnStart;constructor(e){let i=e.sessionName??"default",o=["acp","--session",`agent:${e.agentId}:${i}`];e.gatewayToken&&o.push("--token",e.gatewayToken);let a={command:e.command,args:o,cwd:e.cwd,...e.env?{env:e.env}:{}};super(a),this.agentId=e.agentId,this.sessionName=i,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}`}]},ld))}get acpSessionName(){return this.sessionName}};U();ae();function ci(n){return n.replace(/[^A-Za-z0-9._-]+/g,"-")}var Gt=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((i,o)=>{this.slots.push({task:e,resolve:i,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 i=await e.task();e.resolve(i)}catch(i){e.reject(i)}}}finally{this.running=!1}}}};var Yn=class{agentId;framework;workspace;deployType;accountId;patToken;modelInfo;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),e.modelInfo&&(this.modelInfo=e.modelInfo)}setPatToken(e){this.patToken=e}setModelInfo(e){this.modelInfo=e}getSessionQueue(e){let i=this.sessionQueues.get(e);return(!i||i.isDisposed)&&(i=new Gt,this.sessionQueues.set(e,i)),i}allSessionQueues(){return this.sessionQueues.entries()}hasSessionQueue(e){let i=this.sessionQueues.get(e);return!!i&&!i.isDisposed}async dispose(e){this.status="stopped";let i=new Error(`AgentSession disposed${e?`: ${e}`:""}`);for(let o of this.sessionQueues.values())o.dispose(i);this.sessionQueues.clear(),await this.killAllRuntimes(e??"dispose")}async killAllRuntimes(e){let i=[];for(let[,o]of this.sessions)fn(o),o.downstream&&(i.push(o.downstream.stop(e).catch(()=>{})),o.downstream=void 0);await Promise.all(i),this.activeTriggers.clear()}};function fn(n){n.idleTimer&&(clearTimeout(n.idleTimer),n.idleTimer=void 0)}import{spawn as gd}from"node:child_process";import{homedir as hd}from"node:os";import{join as pd}from"node:path";On();U();async function _o(){let n=pd(hd(),".openclaw/openclaw.json");return(await Lt(n))?.gateway?.auth?.token??""}var mo=D("openclaw.config"),md=[0,5e3,5e3],wo="models.providers.",Xn="agents.defaults.models",Zn=class{command;env;retryDelaysMs;queue=new Gt;constructor(e){this.command=e.command,this.env=e.env??process.env,this.retryDelaysMs=e.retryDelaysMs??md}async withRetry(e,i){let o;for(let a=0;a<this.retryDelaysMs.length;a++){let x=this.retryDelaysMs[a]??0;x>0&&await new Promise(u=>setTimeout(u,x));try{return await i()}catch(u){o=u,mo.warn("openclaw cli failed, will retry",{label:e,attempt:a+1,err:String(u)})}}throw new v("AGENT_SPAWN_FAILED",`openclaw cli ${e} failed after ${this.retryDelaysMs.length} attempts: ${o?.message??"unknown"}`)}runCli(e){return new Promise((i,o)=>{let a=gd(this.command,e,{stdio:["ignore","pipe","pipe"],env:this.env}),x="";a.stderr?.on("data",u=>{x+=u.toString("utf8")}),a.on("error",o),a.on("close",u=>{u===0?i():o(new Error(`exit ${u}: ${x.trim().slice(0,500)}`))})})}async runCliTolerant(e,i){try{await this.runCli(e)}catch(o){let a=String(o);if(i.some(x=>a.includes(x)))return;throw o}}async bestEffortUnset(e,i){try{await this.queue.enqueue(()=>this.withRetry(e,()=>this.runCli(["config","unset",i])))}catch(o){mo.warn(`${e} failed (best-effort)`,{configPath:i,err:String(o)})}}ensureProvider(e,i){return this.queue.enqueue(()=>this.withRetry(`config set models.providers.${e}`,()=>this.runCli(["config","set",`${wo}${e}`,JSON.stringify(i),"--strict-json","--merge"])))}removeProvider(e){return this.bestEffortUnset(`config unset models.providers.${e}`,`${wo}${e}`)}addModelToAllowlist(e,i){let o={[e]:i?{alias:i}:{}};return this.queue.enqueue(()=>this.withRetry(`config set ${Xn}[${e}]`,()=>this.runCli(["config","set",Xn,JSON.stringify(o),"--strict-json","--merge"])))}removeModelFromAllowlist(e){return this.bestEffortUnset(`config unset ${Xn}[${e}]`,`${Xn}.${e}`)}ensureAgent(e,i,o){let a=["agents","add",e,"--workspace",i,"--non-interactive"];return o&&a.push("--model",o),this.queue.enqueue(()=>this.withRetry(`agents add ${e}`,()=>this.runCliTolerant(a,["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 me=D("agent-manager"),_d=(n,e,i,o,a,x,u,f)=>{switch(n){case"claude-code":{let g={...a?{...$s(a),...Ys(a,u)}:{},...f??{},IS_SANDBOX:"1"};return new Jn({cwd:i,env:g})}case"codex":{let m=[...a?[...Js(a),...Zs(a,u)]:[],"-c",'sandbox_mode="danger-full-access"',"-c",'approval_policy="never"'],y={...a?Vs(a):{},...f??{}},_=!!a;return new Vn({cwd:i,...m.length>0?{extraArgs:m}:{},...Object.keys(y).length>0?{env:y}:{},..._?{authMethodId:"openai-api-key",isolateCodexHome:!0}:{}})}case"openclaw":return new qt({command:e,cwd:i,agentId:o,...x?{sessionName:ci(x)}:{}})}};function di(n){return n==="claude-code"||n==="codex"}var yd={path:"",version:"cloud-deployed"},bd={protocolVersion:1,clientCapabilities:{fs:{readTextFile:!0,writeTextFile:!0}}},vd=6e4,Sd=lt("COZE_BRIDGE_SPAWN_AWAIT_INSTALL_MS",25e3),Qn=class{paths;config;registry;factory;createTimeoutMs;spawnAwaitInstallMs;openclawConfigCache;ensuredProviders=new Set;constructor(e){this.paths=e.paths,this.config=e.config,this.registry=e.registry,this.factory=e.downstreamFactory??_d,this.createTimeoutMs=e.createTimeoutMs??vd,this.spawnAwaitInstallMs=e.spawnAwaitInstallMs??Sd}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 v("AGENT_SPAWN_FAILED","openclaw binary not detected on this machine");this.openclawConfigCache=new Zn({command:e.path})}return this.openclawConfigCache}async createAgent(e){if(!e.agentId)throw new v("IPC_BAD_REQUEST","agentId required");if(!e.framework)throw new v("IPC_BAD_REQUEST","framework required");let i=rn(e._meta)==="cloud";this.registry.reviveIfDisconnected?.(e.agentId);let o=this.registry.get(e.agentId);if(o){if(o.framework!==e.framework)throw new v("AGENT_BUSY",`agent ${e.agentId} exists with different framework (${o.framework})`);if(o.status==="error")me.warn("existing agent in error state, rebuilding",{agentId:e.agentId}),await o.dispose("rebuild after error").catch(A=>me.warn("dispose stale agent failed (ignored)",{err:String(A)})),this.registry.unregister(e.agentId);else{if(e.patToken&&e.patToken!==o.patToken){me.info("updating agent patToken on re-create (reconnect with new PAT)",{agentId:e.agentId}),o.setPatToken(e.patToken);let A=await pe(e.agentId,this.paths).catch(()=>null);A&&(A.patToken=e.patToken,await Ee(A,this.paths))}if(o.deployType==="cloud"&&e.modelInfo){me.info("updating agent modelInfo on re-create",{agentId:e.agentId}),o.setModelInfo(e.modelInfo);let A=await pe(e.agentId,this.paths).catch(()=>null);A&&(A.modelInfo=e.modelInfo,await Ee(A,this.paths))}return me.info("agent already exists, return current",{agentId:e.agentId}),{ok:!0,agentId:o.agentId,workspace:o.workspace,framework:o.framework}}}if(!i&&!this.config.frameworksCache?.[e.framework])throw new v("AGENT_SPAWN_FAILED",`framework ${e.framework} not detected on this machine; rerun daemon to refresh frameworks_cache`);let x=Xe(e.agentId,this.paths),u=rn(e._meta),f=e.framework==="openclaw"&&u==="local",g=f?this.config.frameworksCache?.openclaw?.defaultAgent?.workspace:void 0,m=e.workspace??g??x.workspace,y=new AbortController,_=setTimeout(()=>y.abort(new v("AGENT_TIMEOUT",`_agent/create timed out after ${this.createTimeoutMs}ms`)),this.createTimeoutMs),S,E=!1;try{i&&di(e.framework)&&await Nt(e.framework,y.signal);let A=()=>{if(y.signal.aborted)throw y.signal.reason instanceof Error?y.signal.reason:new v("AGENT_TIMEOUT","_agent/create aborted")};await xi(x.root,{recursive:!0}),await xi(m,{recursive:!0}),await xi(x.logs,{recursive:!0}),A(),f||await Mt(m,e.framework,e.agentId,e.cozeIdentity),e.framework==="claude-code"&&await Ms(m),A();let T=await pe(e.agentId,this.paths).catch(()=>null),z=js({model:e.model??T?.model}),Z=Bs(e._meta)??T?.accountId,K=e.patToken??T?.patToken,ce=u==="cloud"?e.modelInfo??T?.modelInfo:void 0;if(S=new Yn({agentId:e.agentId,framework:e.framework,workspace:m,model:z.model??ze,deployType:u,...Z?{accountId:Z}:{},...K?{patToken:K}:{},...ce?{modelInfo:ce}:{}}),S.status="ok",T?.sessions){for(let[Ne,ie]of Object.entries(T.sessions))S.sessions.set(Ne,{acpSessionId:ie.acpSessionId,modelToken:ie.modelToken,tokenGeneratedAt:ie.tokenGeneratedAt,lastActiveAt:Date.now(),loadingSession:!1,replySeq:0});let ye=Object.keys(T.sessions).length;ye>0&&me.info("restored persisted session records (no spawn)",{agentId:e.agentId,count:ye})}this.registry.register(S),E=!0;let J={agentId:e.agentId,framework:e.framework,workspace:m,cozeIdentity:e.cozeIdentity,createdAt:T?.createdAt??Date.now(),sessions:T?.sessions??{},model:z.model};u==="cloud"&&(J.deployType="cloud"),Z&&(J.accountId=Z),K&&(J.patToken=K),ce&&(J.modelInfo=ce),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,m):me.warn("openclaw binary not on this machine, skip agents add (will fail at session/prompt)",{agentId:e.agentId}));let _e=e.initialSkills??[];if(_e.length>0){let ye=[...J.skills??[]],Ne=new Map(ye.map((ue,P)=>[ue.skillId,P])),ie=0;for(let ue of _e)try{let P=await si({agentId:e.agentId,workspace:m,framework:e.framework,skill:ue});oi(ye,Ne,P),ie++}catch(P){me.warn("initialSkill install failed (skipping)",{agentId:e.agentId,skillId:ue.skillId,skillName:ue.skillName,err:String(P)})}ie>0&&(J.skills=ye,me.info("initialSkills installed",{agentId:e.agentId,installed:ie,requested:_e.length}))}return await Ee(J,this.paths),me.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(A){throw me.error("agent create failed, rolling back",{agentId:e.agentId,err:String(A)}),E&&S&&(await S.dispose("rollback").catch(()=>{}),this.registry.unregister(e.agentId)),await wd(x.root,{recursive:!0,force:!0}).catch(T=>me.warn("rm agent dir failed (ignored)",{err:String(T)})),A instanceof v?A:new v("AGENT_SPAWN_FAILED",String(A),{cause:A})}finally{clearTimeout(_)}}async spawnSessionDownstream(e,i,o,a){let u=this.config.frameworksCache?.[e.framework];if(!u)if(e.deployType==="cloud"&&di(e.framework))u=yd;else throw new v("AGENT_SPAWN_FAILED",`framework ${e.framework} not detected on this machine`);if(di(e.framework)&&!Ot(e.framework)){let m=Is(e.framework);m&&(me.info("spawn: awaiting in-flight acp install (D92)",{agentId:e.agentId,framework:e.framework}),await Promise.race([m.catch(()=>{}),new Promise(y=>setTimeout(y,this.spawnAwaitInstallMs))]))}let f=e.deployType==="cloud"?{model:e.model,modelToken:i,...e.modelInfo?{modelInfo:e.modelInfo}:{}}:void 0,g;e.framework==="openclaw"?g=await this.buildOpenclawDownstream({session:e,modelConfig:f,cloudSessionId:o,cozeEnv:a,command:u.path}):g=this.factory(e.framework,u.path,e.workspace,e.agentId,f,o,a,this.buildBinShimPathEnv());try{return await g.start(),await g.initialize(bd),g}catch(m){let y=g instanceof qe?g.getStderrTail():[];y.length>0&&me.warn("spawnSessionDownstream failed, recent stderr (D94)",{agentId:e.agentId,framework:e.framework,method:m instanceof v?m.code:"unknown",recentStderr:y});let _=ai(y);await g.stop("spawnSessionDownstream failed").catch(()=>{});let S=_?new v("NPX_CACHE_CORRUPT","~/.npm/_npx \u76EE\u5F55\u635F\u574F (ENOTEMPTY)\u3002\u5EFA\u8BAE: rm -rf ~/.npm/_npx && npm i -g @zed-industries/codex-acp (\u6216\u5BF9\u5E94 @agentclientprotocol/claude-agent-acp)",{cause:m}):m;throw m instanceof v?new v(m.code,m.message,{retriable:m.retriable,cause:S}):new v("AGENT_SPAWN_FAILED",m instanceof Error?m.message:String(m),{cause:S})}}async buildOpenclawDownstream(e){let{session:i,modelConfig:o,cloudSessionId:a,cozeEnv:x,command:u}=e,f=ci(a);if(i.deployType==="local"){let _=this.config.frameworksCache?.openclaw?.defaultAgent;if(!_?.id||!_.workspace)throw new v("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 qt({command:u,cwd:_.workspace,agentId:_.id,sessionName:f})}let g=await _o(),m=o?Xs(o,x):null,y;if(m){let _=ri(a),E=m.models[0]?.id??ze,A=`${_}/${E}`;if(!this.ensuredProviders.has(A)){let T=this.getOpenclawConfig();await T.ensureProvider(_,m),await T.addModelToAllowlist(A),this.ensuredProviders.add(A)}y=A}return new qt({command:u,cwd:i.workspace,agentId:i.agentId,sessionName:f,...g?{gatewayToken:g}:{},...y?{slashModelOnStart:y}:{}})}async openclawRepair(e,i){let o=this.getOpenclawConfig();await o.deleteAgent(e),await o.ensureAgent(e,i)}async cleanupOpenclawSessionProviders(e){if(e.framework!=="openclaw"||!this.openclawConfigCache)return;let i=this.openclawConfigCache;for(let o of e.sessions.keys()){let a=ri(o),x=`${a}/${e.model}`,u=!0;try{await i.removeProvider(a)}catch(f){u=!1,me.warn("removeProvider failed, keeping ensuredProviders entry",{providerId:a,err:String(f)})}try{await i.removeModelFromAllowlist(x)}catch(f){u=!1,me.warn("removeModelFromAllowlist failed, keeping ensuredProviders entry",{fullModelId:x,err:String(f)})}u&&this.ensuredProviders.delete(x)}}};import{randomUUID as Od}from"node:crypto";import{promises as Ld}from"node:fs";import{basename as Md}from"node:path";import{promises as Id}from"node:fs";import{basename as Ad}from"node:path";U();var yo=D("file-upload"),Pd="/api/coze_claw/file/agent_upload",Cd=6e4;async function bo(n,e={}){let o=`${Un(Gn(e.handshakeBase))}${Pd}`,a=e.timeoutMs??Cd,x=await Id.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 f={Authorization:`Bearer ${n.patToken}`,Accept:"application/json","x-coze-version":"3.0",...zt(e.ppeOverride),...n.accountId?{"x-coze-account":n.accountId}:{}},g=new AbortController,m=setTimeout(()=>g.abort(),a);yo.info("file upload start",{url:o,agentId:n.agentId,sessionId:n.sessionId,name:n.name,bytes:n.sizeBytes,mime:n.mimeType});try{let y=await fetch(o,{method:"POST",headers:f,body:u,signal:g.signal}),_=y.headers.get("x-tt-logid")??"";if(!y.ok){let A=await y.text().catch(()=>"");throw new v("UPLOAD_FAILED",`upload HTTP ${y.status} logid=${_}: ${A.slice(0,200)}`)}let S=await y.json();if(S.code!==void 0&&S.code!==0)throw new v("UPLOAD_FAILED",`upload code=${S.code} msg=${S.msg??"-"} logid=${_}`);let E=S.data?.file?.file_url;if(!E)throw new v("UPLOAD_FAILED",`upload response missing data.file.file_url logid=${_}: ${JSON.stringify(S).slice(0,200)}`);return yo.info("file upload ok",{uri:E,logid:_}),{uri:E}}catch(y){throw y instanceof v?y:y.name==="AbortError"?new v("UPLOAD_FAILED",`upload timeout (${a}ms) for ${Ad(n.path)}`):new v("UPLOAD_FAILED",String(y),{cause:y})}finally{clearTimeout(m)}}U();import{promises as Td}from"node:fs";import{extname as kd}from"node:path";var Dd=[{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 Rd(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 Nd={".txt":"text/plain",".md":"text/markdown",".svg":"image/svg+xml",".json":"application/json"};async function vo(n){let e=await Td.open(n,"r");try{let i=Buffer.alloc(16);if(await e.read(i,0,16,0),Rd(i))return"image/webp";for(let o of Dd)if(o.prefix.every((a,x)=>i[x]===a))return o.mime}finally{await e.close()}return Nd[kd(n).toLowerCase()]??"application/octet-stream"}ae();var So=D("agent-send"),Eo=50*1024*1024,Bd=new Set(["image/png","image/jpeg","image/webp","image/gif","image/svg+xml","application/pdf","application/json","text/plain","text/markdown"]);async function Io(n,e){let i=e.core.get(n.agentId);if(!i)throw new v("AGENT_NOT_FOUND",`agent=${n.agentId}`);if(e.core.disconnectedAgents.has(n.agentId))throw new v("AGENT_DISCONNECTED",`agent=${n.agentId} was disconnected by cloud`);let o=i.sessions.get(n.sessionId);if(!o)throw new v("AGENT_NOT_FOUND",`session=${n.sessionId} not active in agent=${n.agentId}`);if(!await Rs(n.path,i.workspace))throw new v("PATH_OUTSIDE_WORKSPACE",`path=${n.path} not under workspace=${i.workspace}`);let a=await Ld.stat(n.path).catch(()=>null);if(!a||!a.isFile())throw new v("IPC_BAD_REQUEST",`path is not a regular file: ${n.path}`);if(a.size>Eo)throw new v("FILE_TOO_LARGE",`${a.size} bytes > limit ${Eo}`);let x=await vo(n.path);if(!Bd.has(x))throw new v("UNSUPPORTED_MIME",`mime=${x} not in whitelist`);if(n.kind==="image"&&!x.startsWith("image/"))throw new v("UNSUPPORTED_MIME",`kind=image but mime=${x}`);if(!e.core.upstream.isConnected())throw new v("UPSTREAM_NOT_READY","cloud WS not connected");let u=n.name??Md(n.path),f=await bo({patToken:i.patToken??e.patToken,agentId:n.agentId,sessionId:n.sessionId,path:n.path,mimeType:x,name:u,sizeBytes:a.size,...i.accountId?{accountId:i.accountId}:{}},{handshakeBase:e.handshakeBase,ppeOverride:e.ppeOverride}),g={sessionUpdate:"agent_file",messageId:Od(),content:{type:n.kind==="image"?"image":"resource",uri:f.uri,mimeType:x,name:u,sizeBytes:a.size,...f.fileId!==void 0?{fileId:f.fileId}:{},...n.caption!==void 0?{caption:n.caption}:{}}},m=2,y;for(let _=0;_<=m;_++)try{await e.core.sendAgentFileUpdate(i,o,n.sessionId,g),y=void 0;break}catch(S){y=S,_<m&&(So.warn("sendAgentFileUpdate failed, retrying",{attempt:_+1,err:String(S)}),await new Promise(E=>setTimeout(E,5e3)))}if(y)throw new v("UPSTREAM_NOT_READY",`agent file uploaded to cloud but sendAgentFileUpdate failed after ${m+1} attempts: ${String(y)}`,{cause:y});return So.info("agent file sent",{agentId:n.agentId,sessionId:n.sessionId,kind:n.kind,name:u,bytes:a.size,mime:x,uri:f.uri}),{ok:!0,uri:f.uri,bytes:a.size,mimeType:x,...f.fileId!==void 0?{fileId:f.fileId}:{}}}import{execFile as zd}from"node:child_process";import{promisify as Fd}from"node:util";function er(n,e){let i=n.split(".").map(Number),o=e.split(".").map(Number),a=Math.max(i.length,o.length);for(let x=0;x<a;x++){let u=i[x]??0,f=o[x]??0;if(u<f)return!0;if(u>f)return!1}return!1}U();var Ud=Fd(zd),Ge=D("coze-cli-installer"),Ao="@coze/cli@latest",qd="coze",Po="0.1.7",Gd=5e3,Hd=5e3,Kd=9e4,Co=1e4,ln=null,tr=!1;async function ui(n,e={}){if(tr)return;if(ln)return ln;let i=e.exec??Ud;return ln=(async()=>{try{let o=await jd(qd,i),a=!1;if(o){let u=await Wd(i);if(u===void 0)Ge.warn("coze-cli found but version unparseable, fall through to full install",{path:o});else if(er(u,Po))Ge.info("coze-cli version too old, upgrade-only (preserve user config + auth)",{path:o,version:u,min:Po}),a=!0;else{Ge.info("coze-cli already on PATH with sufficient version, skip",{path:o,version:u}),tr=!0;return}}let x=a?"upgrade-only":"full";Ge.info("coze-cli install start",{package:Ao,mode:x});try{await i("npm",["i","-g","--prefer-online",Ao],{timeout:Kd,maxBuffer:10*1024*1024}),Ge.info("coze-cli install ok")}catch(u){Ge.warn("coze-cli install failed (skip subsequent steps)",{err:String(u)});return}if(a){tr=!0;return}if(n.env)try{await i("coze",["config","set","xTTEnv",n.env],{timeout:Co}),Ge.info("coze config set xTTEnv ok",{env:n.env})}catch(u){Ge.warn("coze config set failed (continue to auth login)",{err:String(u)})}try{await i("coze",["auth","login","--token",n.patToken],{timeout:Co}),Ge.info("coze auth login ok")}catch(u){Ge.warn("coze auth login failed",{err:String(u)});return}tr=!0}finally{ln=null}})(),ln}async function jd(n,e){let i=process.platform==="win32"?"where":"which";try{let{stdout:o}=await e(i,[n],{timeout:Gd});return o.split(`
|
|
120
|
-
`)[0]?.trim()||void 0}catch{return}}async function
|
|
121
|
-
`),
|
|
122
|
-
`)}else
|
|
123
|
-
`)}async function zo(n,e){if(typeof n!="string"||n.length===0)throw new v("IPC_BAD_REQUEST","path must be a non-empty string");let[i,o]=await Promise.all([Oo(No(e)),Oo(No(n))]),a=xu(i,o);if(a.startsWith("..")||a===".."||a.startsWith(`..${du}`))throw new v("IPC_BAD_REQUEST",`path escapes workspace: ${n}`);return o}async function Oo(n){let e=[],i=n;for(;i!==fi(i);)try{let o=await iu(i);return e.length?cu(o,...e.reverse()):o}catch{e.push(au(i)),i=fi(i)}return n}U();var Fo=D("prompt-multimodal"),Uo=10*1024*1024,lu=15e3,gu=6;async function qo(n){let e=new Array(n.length),i=0;async function o(){for(;i<n.length;){let x=i++,u=n[x];u!==void 0&&(e[x]=await hu(u))}}let a=Array.from({length:Math.min(gu,n.length)},()=>o());return await Promise.all(a),e}function Go(n){return n.some(e=>e.type==="image")}async function hu(n){if(n.type!=="image")return n;let e=n;if(e.data||!e.uri||!Fn(e.uri))return n;try{let{buf:i,contentType:o}=await mu(e.uri),a=e.mimeType||pu(o)||"application/octet-stream";return Fo.info("image uri fetched and inlined",{uri:e.uri,bytes:i.length,mimeType:a}),{type:"image",data:i.toString("base64"),mimeType:a}}catch(i){return Fo.warn("image fetch failed, degrading to text block",{uri:e.uri,err:String(i)}),{type:"text",text:`[image load failed: ${e.uri}]`}}}function pu(n){if(!n)return;let e=n.indexOf(";");return(e===-1?n:n.slice(0,e)).trim()||void 0}async function mu(n){let e=new AbortController,i=setTimeout(()=>e.abort(),lu);try{let o=await fetch(n,{signal:e.signal});if(!o.ok)throw new Error(`HTTP ${o.status} ${o.statusText}`);let a=await o.arrayBuffer();if(a.byteLength>Uo)throw new Error(`image too large: ${a.byteLength} bytes (max ${Uo})`);return{buf:Buffer.from(a),contentType:o.headers.get("content-type")??void 0}}finally{clearTimeout(i)}}dt();Kt();U();var B=D("core"),_u=3e4,yu=/^(boe|ppe)_[A-Za-z0-9_-]+$/,bu=3e4,vu=new Set(["_agent/create","session/new","session/load","session/prompt"]),nr=class{upstream;agents=new Map;disconnectedAgents=new Set;extensions;paths;sessionSpawner;sessionIdleTimeoutMs;upgradeGate;upstreamIds=new Ut;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=Ro(e.bridgeConfig),this.upgradeGate=e.upgradeGate}registerExtension(e,i){this.extensions[e]=i}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(i=>i.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 i of this.registerHandlers)try{i(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,i,o){let a=o.downstream;a&&(a.onUpdate(x=>{o.loadingSession||this.forwardUpdate(e,x)}),a.onAgentRequest(x=>{this.handleAgentRequest(e,a,x)}),a.onExit((x,u)=>{B.info("session runtime exited",{agentId:e.agentId,cloudId:i,code:x,signal:u}),fn(o),o.downstream=void 0,o.replySeq=0,o.acpSessionId&&e.activeTriggers.delete(o.acpSessionId),this.rejectPendingForDownstream(a,"downstream exited")}))}hasPendingPermissionFor(e){for(let i of this.pendingUpstream.values())if(i.downstream===e)return!0;return!1}rejectPendingForDownstream(e,i){let o=[];for(let[a,x]of this.pendingUpstream)x.downstream===e&&o.push(a);if(o.length!==0){B.info("reject pendingUpstream entries (downstream gone)",{reason:i,count:o.length});for(let a of o){let x=this.pendingUpstream.get(a);if(x){this.pendingUpstream.delete(a),this.upstream.send(ft(a,{code:G.INTERNAL_ERROR,message:`bridge downstream gone: ${i}`})).catch(u=>B.debug("send error response to upstream failed (ignored)",{err:String(u)}));try{x.downstream.respondAgentRequestError(x.agentRequestId,{code:G.INTERNAL_ERROR,message:`bridge: ${i}`})}catch{}}}}}rejectAllPendingOnReconnect(){let e=this.pendingUpstream.size,i=this.pendingBridge.size;if(!(e===0&&i===0)){B.warn("upstream reconnected, rejecting stale pending requests",{pendingUpstream:e,pendingBridge:i});for(let[,o]of this.pendingUpstream)try{o.downstream.respondAgentRequestError(o.agentRequestId,{code:G.INTERNAL_ERROR,message:"upstream reconnected; please retry"})}catch{}this.pendingUpstream.clear();for(let[,o]of this.pendingBridge)clearTimeout(o.timer),o.reject(new v("UPSTREAM_DISCONNECTED",`${o.method} aborted: upstream reconnected`));this.pendingBridge.clear()}}async handleFrame(e){if(Wn(e)){this.handleUpstreamResponse(e);return}if(!("method"in e)||typeof e.method!="string")return;let i="id"in e&&e.id!==void 0?e.id:null,o=e.params?._meta?.cozeEnv;o&&yu.test(o)?this.currentCozeEnv=o:o&&B.warn("rejecting cozeEnv with invalid shape, keeping previous",{rejected:o});try{if(this.upgradeGate?.isUpgrading()&&vu.has(e.method)){let a=this.upgradeGate.pendingTarget()??"";throw new v("BRIDGE_UPGRADING",`bridge upgrading to ${a}, retry shortly`,{retriable:!0})}if(e.method.startsWith("_agent/")){let a=this.extensions[e.method];if(!a){i!==null?await this.sendError(i,G.METHOD_NOT_FOUND,`extension not registered: ${e.method}`):B.warn("drop notification: extension not registered",{method:e.method});return}let x=await a(e,this);i!==null&&await this.upstream.send(Ft(i,x));return}if(e.method.startsWith("session/")){let a=await this.routeSessionMethod(e);i!==null&&await this.upstream.send(Ft(i,a));return}if(e.method==="initialize"){i!==null&&await this.upstream.send(Ft(i,{protocolVersion:1,agentCapabilities:{loadSession:!0}}));return}i!==null?await this.sendError(i,G.METHOD_NOT_FOUND,`method not implemented: ${e.method}`):B.warn("drop unknown notification",{method:e.method})}catch(a){B.error("handleFrame failed",{method:e.method,err:String(a)}),i!==null&&await this.upstream.send(ft(i,un(a)))}}async routeSessionMethod(e){if(!e.params||typeof e.params!="object")throw new v("IPC_BAD_REQUEST",`${e.method} requires params`);let i=e.params,o=i._meta?.cozeAgentId;if(!o)throw new v("IPC_BAD_REQUEST",`${e.method}: missing _meta.cozeAgentId`);let a=this.agents.get(o);if(!a)throw this.disconnectedAgents.has(o)?new v("AGENT_DISCONNECTED",`agent ${o} has been disconnected; cloud must _agent/create to revive`):new v("AGENT_NOT_FOUND",`agent not found: ${o}`);let x=typeof i.sessionId=="string"?i.sessionId:void 0;if(e.method==="session/cancel"||e.method==="session/new"||!x)return this.dispatchSessionCall(a,e.method,i);let u=Date.now(),f=!1,g=e.method==="session/prompt";g&&this.upgradeGate?.incActive();try{let m=await a.getSessionQueue(x).enqueue(()=>this.dispatchSessionCall(a,e.method,i));return f=!0,m}finally{g&&this.upgradeGate?.decActive(),B.info("session call done",{agentId:a.agentId,method:e.method,durationMs:Date.now()-u,ok:f})}}async dispatchSessionCall(e,i,o){e.lastActiveAt=Date.now();let{stripped:a}=zs(o);switch(i){case"session/new":{let x=Su();return B.info("session/new ack (lazy spawn)",{agentId:e.agentId,cloudId:x}),{sessionId:x}}case"session/load":{let x=a;return B.info("session/load ack (lazy spawn)",{agentId:e.agentId,cloudId:x.sessionId}),{}}case"session/prompt":{let x=a,u=x.sessionId;if(!u)throw new v("IPC_BAD_REQUEST","session/prompt: missing sessionId");let f=await this.ensureRuntime(e,u);if(f.replySeq=0,await this.ensureDownstream(e,u,f),!f.downstream||!f.acpSessionId)throw new v("BRIDGE_INTERNAL","session runtime not ready after ensureDownstream");let g=o._meta?.cozeTriggerMsgId;if(g?e.activeTriggers.set(f.acpSessionId,g):e.activeTriggers.delete(f.acpSessionId),e.deployType==="cloud"&&e.modelInfo?.capabilities?.image===!1&&Go(x.prompt))throw new v("MODEL_MODALITY_UNSUPPORTED",`model=${e.modelInfo.id??e.model} does not support image input`);let m=await qo(x.prompt);try{let y=await f.downstream.sessionPrompt({...x,sessionId:f.acpSessionId,prompt:m});return f.lastActiveAt=Date.now(),y}finally{if(e.activeTriggers.delete(f.acpSessionId),f.reloadAfterTurn){f.reloadAfterTurn=!1;let y=f.downstream;y&&(f.downstream=void 0,B.info("reloadAfterTurn: stopping downstream",{agentId:e.agentId,cloudId:u,acpId:f.acpSessionId}),y.stop("reload-after-turn").catch(_=>B.warn("reload-after-turn stop failed (ignored)",{agentId:e.agentId,cloudId:u,err:String(_)})))}else f.downstream?.isAlive()&&this.armIdleTimer(e,u,f)}}case"session/cancel":{let u=a.sessionId;if(!u)throw new v("IPC_BAD_REQUEST","session/cancel: missing sessionId");let f=e.sessions.get(u);if(e.hasSessionQueue(u)){let g=e.getSessionQueue(u);g.size>0&&(B.info("session/cancel: draining queued tasks",{agentId:e.agentId,cloudId:u,queuedCount:g.size}),g.dispose(new v("AGENT_PROTOCOL_ERROR",`cancelled by session/cancel on ${u}`)))}return f?.downstream?.isAlive()&&f.acpSessionId&&await f.downstream.sessionCancel({sessionId:f.acpSessionId}),{ok:!0}}default:throw new v("IPC_BAD_REQUEST",`session method not supported: ${i}`)}}async ensureRuntime(e,i){let o=e.sessions.get(i);if(o)return o;let x={modelToken:e.deployType==="cloud"?await this.requestSessionToken(e.agentId,i):"",tokenGeneratedAt:Date.now(),lastActiveAt:Date.now(),loadingSession:!1,replySeq:0};return e.sessions.set(i,x),await this.persistSessionMapping(e),x}async requestSessionToken(e,i){let o={sessionId:i,_meta:{cozeAgentId:e}};try{let a=await this.sendRequest(Be.GEN_MODEL_TOKEN,o,bu);if(!a?.modelToken)throw new v("MODEL_TOKEN_GEN_FAILED",`cloud returned empty modelToken (agentId=${e}, cloudSessionId=${i})`);return a.modelToken}catch(a){throw a instanceof v&&a.code==="MODEL_TOKEN_GEN_FAILED"?a:new v("MODEL_TOKEN_GEN_FAILED",a instanceof Error?a.message:String(a),{cause:a})}}async ensureDownstream(e,i,o){if(fn(o),o.downstream?.isAlive())return;if(!this.sessionSpawner)throw new v("AGENT_SPAWN_FAILED","sessionSpawner not wired (cannot spawn per-session downstream)");let a=3,x=3e4,u=o.spawnFailCount??0,f=o.spawnFailedAt??0;if(u>=a&&Date.now()-f<x)throw new v("AGENT_SPAWN_FAILED",`agent ${e.agentId} session ${i} spawn failed ${u} times in a row; please check framework binary / network and retry after ${Math.ceil((x-(Date.now()-f))/1e3)}s`);let g;try{g=await this.sessionSpawner(e,o.modelToken,i,this.currentCozeEnv)}catch(m){throw o.spawnFailCount=u+1,o.spawnFailedAt=Date.now(),o.spawnFailCount>=a&&o.acpSessionId&&(B.warn("clearing stale acpSessionId after repeated spawn failures",{agentId:e.agentId,cloudId:i,staleAcpId:o.acpSessionId}),o.acpSessionId=void 0),m}if(o.spawnFailCount=0,o.spawnFailedAt=void 0,o.downstream=g,this.attachRuntimeHooks(e,i,o),o.acpSessionId){o.loadingSession=!0;try{await g.sessionLoad({sessionId:o.acpSessionId,cwd:e.workspace}),B.info("session restored via session/load",{agentId:e.agentId,cloudId:i,acpId:o.acpSessionId})}catch(m){B.warn("session/load failed, fallback to session/new",{agentId:e.agentId,cloudId:i,acpId:o.acpSessionId,err:String(m)}),o.acpSessionId=void 0;let y=await g.sessionNew({cwd:e.workspace});o.acpSessionId=y.sessionId,await this.persistSessionMapping(e)}finally{o.loadingSession=!1}}else{let m=await g.sessionNew({cwd:e.workspace});o.acpSessionId=m.sessionId,await this.persistSessionMapping(e)}g.afterSessionEstablished&&o.acpSessionId&&await g.afterSessionEstablished(o.acpSessionId)}armIdleTimer(e,i,o){if(fn(o),this.isRuntimeBusy(e,o)){B.debug("skip idle timer: runtime busy (in-flight turn / pending permission)",{agentId:e.agentId,cloudId:i});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:i}),this.armIdleTimer(e,i,o);return}B.info("session runtime idle timeout, killing downstream",{agentId:e.agentId,cloudId:i});let a=o.downstream;o.downstream=void 0,o.acpSessionId&&e.activeTriggers.delete(o.acpSessionId),a&&a.stop("idle timeout").catch(x=>B.warn("idle stop failed (ignored)",{agentId:e.agentId,cloudId:i,err:String(x)}))},this.sessionIdleTimeoutMs),o.idleTimer.unref?.()}isRuntimeBusy(e,i){if(i.acpSessionId&&e.activeTriggers.has(i.acpSessionId))return!0;let o=i.downstream;if(!o)return!1;for(let a of this.pendingUpstream.values())if(a.downstream===o)return!0;return!1}async sendAgentFileUpdate(e,i,o,a){let x={cozeAgentId:e.agentId,cozeReplySeqID:++i.replySeq};if(i.acpSessionId){let u=e.activeTriggers.get(i.acpSessionId);u&&(x.cozeTriggerMsgId=u)}await this.upstream.send(xn("session/update",{sessionId:o,update:a,_meta:x}))}forwardUpdate(e,i){let o=i.sessionId,a=this.reverseSessionId(e,o);if(!a){B.debug("drop update for unknown session",{agentId:e.agentId,acpId:o});return}let x=e.sessions.get(a);if(!x){B.debug("drop update: runtime gone",{agentId:e.agentId,cloudId:a});return}if(Iu(i)){B.debug("drop codex metadata-warn chunk",{agentId:e.agentId,acpId:o});return}let u={cozeAgentId:e.agentId,cozeReplySeqID:++x.replySeq},f=e.activeTriggers.get(o);f&&(u.cozeTriggerMsgId=f),this.upstream.send(xn("session/update",{...i,sessionId:a,_meta:u})).catch(g=>B.warn("forward update failed",{agentId:e.agentId,err:String(g)}))}handleAgentRequest(e,i,o){if(o.method==="session/request_permission"){this.forwardPermissionRequest(e,i,o);return}if(o.method==="fs/write_text_file"||o.method==="fs/read_text_file"){this.handleFsRpcRequest(e,i,o);return}B.warn("unhandled agent request,returning method_not_found",{agentId:e.agentId,method:o.method}),i.respondAgentRequestError(o.id,{code:G.METHOD_NOT_FOUND,message:`method not handled by Bridge: ${o.method}`})}async handleFsRpcRequest(e,i,o){try{let a=e.workspace;if(o.method==="fs/write_text_file"){let x=o.params??{},u=await Mo(x,a);i.respondAgentRequest(o.id,u)}else{let x=o.params??{},u=await Bo(x,a);i.respondAgentRequest(o.id,u)}}catch(a){B.warn("fs rpc handler failed",{agentId:e.agentId,method:o.method,err:String(a)}),i.respondAgentRequestError(o.id,un(a))}}forwardPermissionRequest(e,i,o){let a=this.upstreamIds.next("session/request_permission"),x=o.params??{},f=x.sessionId,g=f?e.activeTriggers.get(f):void 0,m={cozeAgentId:e.agentId};g&&(m.cozeTriggerMsgId=g);let y=f?this.reverseSessionId(e,f):void 0,_={...x,...y?{sessionId:y}:{},_meta:m};this.pendingUpstream.set(a,{agentRequestId:o.id,agentId:e.agentId,downstream:i,method:o.method}),B.info("forward permission_request \u2192 upstream",{agentId:e.agentId,upstreamId:a,acpSessionId:f,cloudSessionId:y,toolCallId:x.toolCall?.toolCallId,options:x.options?.map(S=>({optionId:S.optionId,kind:S.kind,name:S.name}))}),this.upstream.send(cn(a,"session/request_permission",_)).catch(S=>{this.pendingUpstream.delete(a),B.error("forward permission request failed",{agentId:e.agentId,err:String(S)}),i.respondAgentRequestError(o.id,{code:G.INTERNAL_ERROR,message:`upstream send failed: ${String(S)}`})})}handleUpstreamResponse(e){if(e.id===null)return;let i=this.lookupPending(this.pendingUpstream,e.id,"upstream");if(i){this.pendingUpstream.delete(i.key);let a=i.value;e.error?(B.info("upstream \u2192 permission response (error)",{agentId:a.agentId,upstreamId:e.id,method:a.method,error:e.error}),a.downstream.respondAgentRequestError(a.agentRequestId,e.error)):(a.method==="session/request_permission"&&Eu(e.result,a),B.info("upstream \u2192 permission response (result)",{agentId:a.agentId,upstreamId:e.id,method:a.method,result:e.result}),a.downstream.respondAgentRequest(a.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 jn(e.error)):o.value.resolve(e.result);return}B.debug("orphan upstream response (no pending)",{id:e.id})}lookupPending(e,i,o){let a=e.get(i);if(a)return{value:a,key:i};if(typeof i=="number"){let x=String(i),u=e.get(x);if(u)return B.warn(`${o} id type mismatch: number received but Bridge expected string`,{rawId:i,normalizedId:x}),{value:u,key:x}}}sendRequest(e,i,o=_u){let a=this.upstreamIds.next(e);return new Promise((x,u)=>{let f=setTimeout(()=>{this.pendingBridge.delete(a),u(new v("AGENT_TIMEOUT",`${e} timed out after ${o}ms`))},o);this.pendingBridge.set(a,{method:e,resolve:x,reject:u,timer:f}),this.upstream.send(cn(a,e,i)).catch(g=>{let m=this.pendingBridge.get(a);m&&(clearTimeout(m.timer),this.pendingBridge.delete(a)),u(g)})})}async persistSessionMapping(e){if(this.paths)try{let i=new Map;for(let[o,a]of e.sessions){let x={modelToken:a.modelToken,tokenGeneratedAt:a.tokenGeneratedAt};a.acpSessionId&&(x.acpSessionId=a.acpSessionId),i.set(o,x)}await Zr(e.agentId,i,this.paths)}catch(i){B.warn("persist session mapping failed",{agentId:e.agentId,err:String(i)})}}reverseSessionId(e,i){for(let[o,a]of e.sessions.entries())if(a.acpSessionId===i)return o}sendError(e,i,o){return this.upstream.send(ft(e,{code:i,message:o,data:{bridgeVersion:ut}}))}};function Su(){return wu(16).toString("hex")}function Eu(n,e){if(!n||typeof n!="object"){B.warn("permission response: result not an object (suspicious)",{agentId:e.agentId,result:n});return}let i=n;if("kind"in i&&!("outcome"in i)){B.warn('permission response: top-level "kind" field (D66 historical bug shape)',{agentId:e.agentId,result:n});return}let o=i.outcome;if(!o||typeof o!="object"){B.warn("permission response: missing or non-object outcome field",{agentId:e.agentId,result:n});return}let x=o.outcome;(typeof x!="string"||x!=="selected"&&x!=="cancelled")&&B.warn("permission response: unknown outcome discriminant",{agentId:e.agentId,outcomeValue:x,result:n})}function Iu(n){let e=n.update;if(e?.sessionUpdate!=="agent_message_chunk")return!1;let i=e.content;if(!i||typeof i!="object")return!1;let o=i;return o.type!=="text"||typeof o.text!="string"?!1:o.text.startsWith("Model metadata for `")}U();ae();import{randomBytes as Au}from"node:crypto";import{chmod as Pu,mkdir as Cu,writeFile as Ho}from"node:fs/promises";import{createServer as Tu}from"node:http";import{dirname as ku}from"node:path";var Du=1e6,li=D("ipc"),rr=class{server=null;port=0;token="";routes;paths;constructor(e){this.routes=new Map(e.routes.map(i=>[`${i.method} ${i.path}`,i])),this.paths=e.paths??q()}async start(){this.token=Au(32).toString("hex");let e=Tu((o,a)=>{this.dispatch(o,a)});this.server=e,await new Promise((o,a)=>{e.once("error",a),e.listen(0,"127.0.0.1",()=>o())});let i=e.address();if(!i||typeof i!="object")throw new Error("failed to obtain IPC port");return this.port=i.port,await this.persistAuthFiles(),li.info("IPC listening",{port:this.port}),{port:this.port,token:this.token}}async stop(){let e=this.server;e&&(await new Promise((i,o)=>{e.close(a=>a?o(a):i())}),this.server=null)}async persistAuthFiles(){await Cu(ku(this.paths.portFile),{recursive:!0}),await Ho(this.paths.portFile,String(this.port),"utf8"),await Ho(this.paths.tokenFile,this.token,{encoding:"utf8",mode:384});try{await Pu(this.paths.tokenFile,384)}catch(e){li.warn("chmod token file failed (non-POSIX?)",{err:String(e)})}}async dispatch(e,i){if(e.headers.authorization!==`Bearer ${this.token}`){hn(i,401,{error:"unauthorized"});return}let a=`${e.method} ${(e.url??"").split("?")[0]}`,x=this.routes.get(a);if(!x){hn(i,404,{error:"not found"});return}let u=null;if(e.method==="POST")try{u=await Ru(e)}catch(f){hn(i,400,{error:"invalid json",detail:String(f)});return}try{let f=await x.handler(u,e);hn(i,200,f??{ok:!0})}catch(f){li.error("IPC handler failed",{key:a,err:String(f)}),hn(i,500,{error:f instanceof Error?f.message:String(f)})}}};function hn(n,e,i){n.statusCode=e,n.setHeader("content-type","application/json"),n.end(JSON.stringify(i))}async function Ru(n){let e=[],i=0;for await(let a of n){let x=a;if(i+=x.length,i>Du)throw new Error("body too large");e.push(x)}let o=Buffer.concat(e).toString("utf8");return o?JSON.parse(o):null}import{sep as Ko}from"node:path";import{fileURLToPath as Nu}from"node:url";function jo(){return Ou(Nu(import.meta.url))}function Ou(n){let e=`${Ko}src${Ko}`;return n.includes(e)}U();ae();import{spawn as Lu}from"node:child_process";import{existsSync as Mu,mkdirSync as Bu,openSync as zu}from"node:fs";import{dirname as Fu}from"node:path";import{fileURLToPath as Uu}from"node:url";var qu=D("spawn-helper");function Gu(n){return Mu(n.libEntry)?n.libEntry:Uu(new URL("../index.ts",import.meta.url))}function Hu(n,e,i){let o=n.endsWith(".ts"),a=["--upgrade-helper",`--target-version=${e}`,`--old-pid=${i}`];return o?["--import","tsx/esm",n,...a]:[n,...a]}async function Wo(n,e,i={}){let o=i.paths??q(),a=Gu(o);Bu(Fu(o.logFile),{recursive:!0});let x=zu(o.logFile,"a"),u=Hu(a,n,e),f=Lu(process.execPath,u,{detached:!0,stdio:["ignore",x,x],env:{...process.env,COZE_BRIDGE_UPGRADE_HELPER:"1"}});if(f.unref(),typeof f.pid!="number")throw new Error("failed to spawn upgrade helper (no pid)");qu.info("upgrade helper spawned",{pid:f.pid,targetVersion:n,oldPid:e,entry:a})}U();import{mkdir as Ku,writeFile as ju}from"node:fs/promises";import{dirname as Wu}from"node:path";import{gunzipSync as $u}from"node:zlib";var gi=D("tarball-downloader"),Ju="https://registry.npmjs.org",$o="package/dist/index.js";async function Jo(n,e,i={}){if(!/^[\w.\-+]+$/.test(n))throw new Error(`invalid version string: ${JSON.stringify(n)}`);let a=`${(i.registry??Ju).replace(/\/+$/,"")}/coze-bridge/${n}`;gi.info("fetching tarball metadata",{metaUrl:a});let x=await fetch(a);if(!x.ok)throw new Error(`registry metadata ${a} returned ${x.status}`);let f=(await x.json())?.dist?.tarball;if(!f)throw new Error(`registry metadata missing dist.tarball for ${n}`);gi.info("downloading tarball",{tarballUrl:f});let g=await fetch(f);if(!g.ok)throw new Error(`tarball ${f} returned ${g.status}`);let m=Buffer.from(await g.arrayBuffer()),y=$u(m),_=Vu(y,$o);if(!_)throw new Error(`tarball missing entry ${$o}`);await Ku(Wu(e),{recursive:!0}),await ju(e,_),gi.info("dist extracted",{destPath:e,bytes:_.length})}function Vu(n,e){let i=0;for(;i+512<=n.length;){let o=n.subarray(i,i+512);if(o.every(y=>y===0))return null;let a=o.subarray(0,100),x=a.indexOf(0),u=a.subarray(0,x===-1?100:x).toString("utf8"),f=o.subarray(124,136).toString("ascii").trim().replace(/\0/g,""),g=Number.parseInt(f,8)||0,m=i+512;if(u===e)return n.subarray(m,m+g);i=m+Math.ceil(g/512)*512}return null}Kt();U();import{resolve as Yu}from"node:path";var yt=D("upgrade-manager"),Xu=300*1e3,Zu=3,ir=class{constructor(e){this.opts=e}opts;inFlightTarget=null;async requestUpgrade(e){if(this.inFlightTarget===e){yt.debug("upgrade already in-flight, skip",{targetVersion:e});return}this.inFlightTarget=e;try{let i=await gt(this.opts.paths.configFile)??{};if(i.disableAutoUpgrade){yt.info("disableAutoUpgrade=true, skip",{targetVersion:e});return}if(this.opts.isDevMode()){yt.warn("dev mode, skip auto-upgrade",{targetVersion:e});return}if(!er(this.opts.currentVersion,e)){yt.debug("local version >= target, skip",{local:this.opts.currentVersion,target:e});return}let o=i.upgradeAttempts?.[e];if((o?.count??0)>=Zu){yt.warn("upgrade attempts cap reached, skip",{targetVersion:e,count:o?.count});return}let a=Yu(this.opts.paths.libDir,"index.js.next");try{await this.opts.download(e,a)}catch(u){await this.recordAttempt(i,e,String(u)),yt.warn("download failed, attempt recorded",{targetVersion:e,err:String(u)});return}this.opts.daemon.markUpgradePending(e);let x=await this.opts.daemon.waitIdle(Xu);yt.info("waitIdle done",{result:x}),await this.opts.spawnHelper(e,process.pid),this.opts.daemon.exit(0)}finally{this.inFlightTarget=null}}async recordAttempt(e,i,o){e.upgradeAttempts=e.upgradeAttempts??{};let a=e.upgradeAttempts[i];e.upgradeAttempts[i]={count:(a?.count??0)+1,lastAt:Date.now(),...o?{lastError:o}:{}},await He(e,this.opts.paths.configFile)}};var pc=Ye(sa(),1);var Nl=Ye(ec(),1),Ol=Ye(yr(),1),Ll=Ye($t(),1),Ml=Ye(Pi(),1),Bl=Ye(ki(),1),zl=Ye(Mi(),1),xc=Ye(Er(),1),Fl=Ye(cc(),1);var dc=xc.default;U();var ge=D("upstream.frontier"),fc="application/json",lc="none",ql=15e3,En=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:qs,...zt(this.opts.ppeOverride)};class i extends dc{constructor(A){super(A,Us,{headers:e})}send(A,...T){if(vs("debug"))try{let z;typeof A=="string"?z=Buffer.from(A,"utf8"):A instanceof Buffer?z=A:A instanceof ArrayBuffer?z=new Uint8Array(A):ArrayBuffer.isView(A)?z=new Uint8Array(A.buffer,A.byteOffset,A.byteLength):z=new Uint8Array(0);let Z=Buffer.from(z.slice(0,128)).toString("hex");ge.debug("WS raw frame out",{bytes:z.byteLength,headHex:Z})}catch(z){ge.warn("WS raw frame dump failed",{err:String(z)})}super.send(A,...T)}}let o=Hs(this.opts.urlOverride),a={url:o,ws:i,fpID:Fs,aID:qn,accessKey:this.opts.handshake.accessKey,deviceID:this.opts.handshake.deviceId,payloadType:{type:fc,force:!0},payloadEncoding:{encoding:lc,force:!0},enableTransformTextPayload:!0,enableQoS:!1,enableAutoAck:!1,automaticOpen:!1,maxRetries:Number.POSITIVE_INFINITY,debug:this.opts.debug??!1},x=new pc.FWS(a),u=!1,f=null,g,m,y=new Promise((E,A)=>{g=E,m=A}),_=E=>{u||(u=!0,f&&(clearTimeout(f),f=null),E?m(E):g())};x.onopen=()=>{this.opened=!0,this.openCount+=1;let E=this.openCount===1;ge.info("frontier opened",{url:o,remoteDeviceId:this.opts.handshake.deviceId,initial:E,openCount:this.openCount}),E&&_();for(let A of this.connectHandlers)Promise.resolve(A({initial:E})).catch(T=>ge.warn("onConnect handler threw (ignored)",{err:String(T)}))},x.onclose=E=>{this.opened=!1,ge.info("frontier closed",{code:E.code,reason:E.reason,willReconnect:E.willReconnect})},x.onerror=E=>{ge.warn("frontier error",{code:E.code,msg:E.message}),_(new v("UPSTREAM_DISCONNECTED",`frontier connect error before open: code=${E.code} msg=${E.message??""}`))},x.onmessage=E=>this.handleMessage(E),this.fws=x;let S=this.opts.openTimeoutMs??ql;f=setTimeout(()=>{_(new v("UPSTREAM_DISCONNECTED",`frontier ws open timeout after ${S}ms (handshake or upgrade slow)`))},S),await x.connect();try{await y}catch(E){try{x.close(1e3,"open failed")}catch(A){ge.warn("fws close during start failure threw (ignored)",{err:String(A)})}throw this.fws=null,this.opened=!1,E}}async stop(e){let i=this.fws;if(i){this.fws=null,this.opened=!1;try{i.close(1e3,e??"bridge shutdown")}catch(o){ge.warn("frontier close threw (ignored)",{err:String(o)})}}}async send(e){let i=this.fws;if(!i)throw new v("UPSTREAM_DISCONNECTED","frontier upstream not started");if(!this.isConnected())throw new v("UPSTREAM_DISCONNECTED",`frontier ws not open (opened=${this.opened}, readyState=${i.readyState}); refusing to silently buffer`);this.injectAgentPatToken(e);let o=JSON.stringify(e),a=e;gc(a)||ge.info("frontier frame out",{method:a.method,jsonrpcId:a.id,size:o.length});try{await i.send(o,{service:33555712,method:1,payloadType:fc,payloadEncoding:lc})}catch(u){throw ge.warn("frontier frame send failed",{method:a.method,jsonrpcId:a.id,err:String(u)}),new v("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 i=this.opts.getPatTokenForAgent;if(!i)return;let o=e.params?._meta;if(!o?.cozeAgentId)return;let a=i(o.cozeAgentId);a&&(o.cozePatToken=a)}handleMessage(e){let i=e.message?.service;if(i!==33555712){ge.debug("drop non-adapter frontier frame",{service:i});return}let o=Kl(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 a;try{a=JSON.parse(o)}catch(u){ge.warn("frontier message JSON parse failed",{err:String(u),head:o.slice(0,80)});return}let x=a;gc(x)||ge.info("frontier frame in",{logid:Hl(e.message?.LogID),logidNew:e.message?.LogIDNew,msgId:e.message?.msgID,jsonrpcId:x.id,method:x.method,body:Gl(o)}),Promise.resolve(this.handler(a)).catch(u=>ge.warn("frontier frame handler threw",{err:String(u)}))}};function gc(n){return n.method==="_agent/health"?!0:typeof n.id=="string"&&n.id.startsWith("agent.health_")}var hc=2e3;function Gl(n){return n.length<=hc?n:`${n.slice(0,hc)}...<truncated, total ${n.length} chars>`}function Hl(n){return n?n.high===0?String(n.low>>>0):`${n.high.toString(16)}${(n.low>>>0).toString(16).padStart(8,"0")}`:""}function Kl(n){let e=n.message;if(e?.textPayload)return e.textPayload;let i=e?.payload;if(!i)return null;try{return Buffer.from(i).toString("utf8")}catch{return null}}U();var zi=D("upstream.switchable"),Ar=class{inner;handler=null;connectHandlers=[];constructor(e){this.inner=e}async swap(e,i){if(this.inner===e)return;zi.info("swap upstream",{reason:i});let o=this.inner;if(this.inner=e,this.handler&&e.onFrame(this.handler),e.onConnect)for(let a of this.connectHandlers)e.onConnect(a);try{await e.start()}catch(a){throw zi.error("swap target start failed, reverting",{err:String(a)}),this.inner=o,a}await o.stop(i??"swapped").catch(a=>zi.warn("previous upstream stop threw (ignored)",{err:String(a)}))}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 Fi=D("upstream"),Qt=class{handler=null;async start(){Fi.info("NoopUpstream started (M1 skeleton; real Frontier wired in M4)")}async stop(e){Fi.info("NoopUpstream stopped",{reason:e})}async send(e){Fi.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();ae();import{promises as Ui}from"node:fs";import{dirname as jl}from"node:path";var Wl=D("pat-token-store");async function mc(n=q()){try{let i=(await Ui.readFile(n.patTokenFile,"utf8")).trim();return i.length>0?i:null}catch(e){return e?.code!=="ENOENT"&&Wl.warn("read pat-token failed (treating as missing)",{err:String(e)}),null}}async function In(n,e=q()){if(!n)throw new Error("writePatToken: empty patToken");await Ui.mkdir(jl(e.patTokenFile),{recursive:!0}),await Ui.writeFile(e.patTokenFile,n,{encoding:"utf8",mode:384})}ae();ae();import{promises as Pr}from"node:fs";import{join as $l}from"node:path";function Jl(n){return`#!/bin/sh
|
|
115
|
+
`;var Ee=N("agent-detail-sync"),hd=6e4,pd=5*6e4,Rn=class{constructor(e){this.opts=e}opts;retryQueue=new Map;async syncAll(e){let s=this.opts.paths.agentsRoot,o;try{o=await gd(s)}catch(c){Ee.info("agents dir not found, skip detail sync",{root:s,err:String(c)});return}Ee.info("starting detail sync",{reason:e,count:o.length}),await Promise.allSettled(o.map(async c=>{let d=await he(c,this.opts.paths).catch(()=>null);if(d){if(d.disconnectedAt){Ee.debug("detail sync: skip disconnected agent",{agentId:c});return}try{await this.syncOne(c,d)}catch(u){Ee.warn("detail sync failed for agent, skipping",{agentId:c,err:String(u)})}}})),Ee.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){Ee.info("retrying pending detail syncs",{count:s.length});for(let o of s)try{await this.syncOne(o)}catch(c){Ee.debug("detail sync retry still failing, will try again",{agentId:o,err:String(c)})}}}async syncOne(e,s){let o=s??await he(e,this.opts.paths);if(!o){Ee.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(f){Ee.warn("detail RPC failed, using local data",{agentId:e,err:String(f)});let h=this.retryQueue.get(e),p=h?Math.min(h.currentDelay*2,pd):hd;this.retryQueue.set(e,{dueAt:Date.now()+p,currentDelay:p});return}if(c.agentId&&c.agentId!==e){Ee.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&&Ee.info("detail.deployType",{agentId:e,deployType:c.deployType}),!d){Ee.debug("detail sync: no diff",{agentId:e});return}await Se(o,this.opts.paths),Ee.info("detail sync: config updated",{agentId:e,identityChanged:u,agentName:o.agentName}),u&&(await Pt(o.workspace,o.framework,e,o.cozeIdentity),this.opts.handlers.reloadAgentSessionsPublic(e,"detail-sync"))}};it();import{spawn as Qs}from"node:child_process";import{lstat as ei,mkdir as _d,readFile as Zs,readdir as yd,rm as bd,stat as vd,writeFile as Ys}from"node:fs/promises";import{join as Me,normalize as Sd,relative as eo,resolve as Ed,sep as to}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 Yt(n){return n?.cozeDeployType==="cloud"?"cloud":"local"}function Os(n){let e=n?.cozeAccountId?.trim();if(!(!e||e==="0"))return e}function Ls(n){let{_meta:e,...s}=n;return{stripped:s,meta:e}}function Ct(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)}};q();ie();function $e(n,e){if(Yt(n)!=="cloud")throw new S("OPERATION_NOT_ALLOWED_FOR_LOCAL",`${e} is not allowed for local agent`)}function Nn(n){return n.startsWith("http://")||n.startsWith("https://")}function On(n){return n.endsWith("/")?n.slice(0,-1):n}q();var Ln="1008033",Ms="1289";var Bs="pbbp2",zs="https://www.coze.cn",Fs="/api/coze_claw/resource/get_frontier_key",md="https://www.coze.cn",wd="wss://frontier.coze.cn";function Mn(n){return n??process.env.COZE_BRIDGE_HANDSHAKE_URL??md}function Us(n){return n??process.env.COZE_BRIDGE_FRONTIER_URL??wd}function kt(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 Xt(n){return n?n.startsWith("boe_")?{ttEnv:n}:{ttEnv:n,usePpe:"1"}:{}}var qs=N("handshake");async function Yr(n){let e=Mn(n.endpoint),s=n.timeoutMs??1e4,o=`${On(e)}${Fs}?aid=${encodeURIComponent(Ln)}`,c={Authorization:`Bearer ${n.privatecode}`,Accept:"application/json",...kt(n.ppeOverride)},d=new AbortController,u=setTimeout(()=>d.abort(),s);qs.info("frontier key handshake",{base:e});try{let f=await fetch(o,{method:"GET",headers:c,signal:d.signal}),h=f.headers.get("x-tt-logid")??"",p=f.headers.get("x-tt-trace-id")??"";if(!f.ok){let A=await f.text().catch(()=>"");throw new S("UPSTREAM_HANDSHAKE_FAILED",`handshake HTTP ${f.status} logid=${h}: ${A.slice(0,200)}`)}let w=await f.json();if(w.code!==void 0&&w.code!==0)throw new S("UPSTREAM_HANDSHAKE_FAILED",`handshake code=${w.code} msg=${w.msg??"-"} logid=${h}`);let b=w.data??{},E=typeof b.access_key=="string"&&b.access_key||typeof b.accessKey=="string"&&b.accessKey||void 0,I=typeof b.device_id=="string"&&b.device_id||typeof b.deviceId=="string"&&b.deviceId||void 0;if(!E||!I){let A=JSON.stringify(w).slice(0,500);throw new S("UPSTREAM_HANDSHAKE_FAILED",`handshake response missing access_key/device_id (also tried camelCase) logid=${h}: ${A}`)}return qs.info("handshake ok",{remoteDeviceId:I,logid:h,traceId:p}),{accessKey:E,deviceId:I}}catch(f){throw f instanceof S?f:f.name==="AbortError"?new S("UPSTREAM_HANDSHAKE_FAILED",`handshake timeout (${s}ms)`):new S("UPSTREAM_HANDSHAKE_FAILED",String(f),{cause:f})}finally{clearTimeout(u)}}var Xr=process.env.COZE_BRIDGE_LLM_GATEWAY_URL?.trim()||"https://llm-gateway.coze.cn",Le="auto";function Gs(n){return{model:n.model??Le,...n.modelToken?{modelToken:n.modelToken}:{}}}function Hs(n){return!n||n===Le}function js(n){let e={};return n.modelToken?(e.ANTHROPIC_BASE_URL=Xr,e.ANTHROPIC_AUTH_TOKEN=n.modelToken,e.ANTHROPIC_MODEL=n.model||Le,n.modelInfo?.contextWindow&&(e.CLAUDE_CODE_MAX_CONTEXT_TOKENS=String(n.modelInfo.contextWindow))):Hs(n.model)||(e.ANTHROPIC_MODEL=n.model),e}function Ks(n){let e=[];return n.modelToken?e.push("-c",`model="${n.model||Le}"`):Hs(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="${Xr}/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"'),n.modelInfo?.contextWindow&&e.push("-c",`model_context_window=${n.modelInfo.contextWindow}`)),e}function Ws(n){return n.modelToken?{OPENAI_API_KEY:n.modelToken}:{}}function Qr(n){let{ttEnv:e,usePpe:s}=Xt(n),o={};return e&&(o["x-tt-env"]=e),s&&(o["x-use-ppe"]=s),o}function Js(n,e){if(!n.modelToken)return{};let s=Qr(e);return Object.keys(s).length===0?{}:{ANTHROPIC_CUSTOM_HEADERS:Object.entries(s).map(([c,d])=>`${c}:${d}`).join(`
|
|
116
|
+
`)}}function Zr(n){return`coze-session-${n.replace(/[^A-Za-z0-9_-]+/g,"-")}`}function $s(n,e){if(!n.modelToken)return null;let s=n.model||Le,o=Qr(e),c=["text"];n.modelInfo?.capabilities?.image===!0&&c.push("image");let d={baseUrl:`${Xr}/v1`,api:"openai-completions",apiKey:n.modelToken,models:[{id:s,name:s,reasoning:!1,input:c,cost:{input:0,output:0,cacheRead:0,cacheWrite:0},contextWindow:n.modelInfo?.contextWindow??128e3,maxTokens:8192,api:"openai-completions"}]};return Object.keys(o).length>0&&(d.headers=o),d}function Vs(n,e){if(!n.modelToken)return[];let s=Qr(e),o=[];for(let[c,d]of Object.entries(s))o.push("-c",`model_providers.coze.http_headers.${c}="${d}"`);return o}var ce=N("agent-handlers"),Xs=5*1024*1024,Id=1,Ad=6,Td=new Set(["node_modules",".git",".coze","dist","build",".next"]),Bn=class{constructor(e){this.opts=e}opts;async listSkills(e){$e(e._meta,"_agent/listSkills");let s=Ct(e._meta),o=await this.loadAgentCfg(s),c=o?.workspace??Je(s).workspace,d=o?.skills??[],u=[];for(let f of d){let h=Me(c,f.relPath,"SKILL.md");await vd(h).then(w=>w.isFile()).catch(()=>!1)&&u.push(Rd(f))}return{skills:u}}async addSkills(e){$e(e._meta,"_agent/addSkills");let s=Ct(e._meta),o=await this.requireAgentCfg(s),c=e.skills??[],d=[...o.skills??[]],u=new Map(d.map((h,p)=>[h.skillId,p])),f=[];for(let h of c){let p=await ti({agentId:s,workspace:o.workspace,framework:o.framework,skill:h});ni(d,u,p),f.push(h)}return await kn(s,d),this.reloadAgentSessions(s,"skills-added"),{installedSkills:f}}async removeSkills(e){$e(e._meta,"_agent/removeSkills");let s=Ct(e._meta),o=await this.requireAgentCfg(s),c=new Set(e.skillIds??[]),d=o.skills??[],u=[];for(let f of d){if(!c.has(f.skillId)){u.push(f);continue}let h=Me(o.workspace,f.relPath);await bd(h,{recursive:!0,force:!0}),ce.info("skill removed",{agentId:s,skillId:f.skillId,relPath:f.relPath})}return await kn(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,ce.info("downstream busy, scheduling reload after turn",{reason:s,agentId:e,framework:o.framework,cloudId:c,acpId:u});continue}let h=d.downstream;d.downstream=void 0,ce.info("killing downstream for workspace reload (idle)",{reason:s,agentId:e,framework:o.framework,cloudId:c,acpId:u}),h.stop(s).catch(p=>ce.warn("downstream stop failed during reload (ignored)",{reason:s,agentId:e,cloudId:c,err:String(p)}))}}isRuntimePendingPermission(e){let s=this.opts.isRuntimePendingPermission;return!s||!e.downstream?!1:s(e.downstream)}async updateAgent(e){if(!e.cozeIdentity?.trim())return ce.info("_agent/update: empty cozeIdentity, noop",{agentId:e.agentId}),{ok:!0};let s=e.agentId,o=await he(s);if(!o)throw new S("AGENT_NOT_FOUND",`agent not found: ${s}`);if(o.cozeIdentity===e.cozeIdentity)return ce.info("_agent/update: cozeIdentity unchanged, noop",{agentId:s}),{ok:!0};try{await Pt(o.workspace,o.framework,s,e.cozeIdentity)}catch(c){throw ce.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 Se(o),ce.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 he(s);return o?(o.disconnectedAt=Date.now(),o.disconnectReason=e.reason??"",await Se(o),ce.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}):(ce.warn("_agent/disconnect: agent not found, ignoring",{agentId:s}),{ok:!0})}async switchModel(e){if($e(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 he(e.agentId);if(!o)throw new S("AGENT_NOT_FOUND",`agent not found: ${e.agentId}`);o.model=s,e.modelInfo&&(o.modelInfo=e.modelInfo),await Se(o),ce.info("_agent/switchModel: model persisted",{agentId:e.agentId,model:s,reason:e.reason??""});let c=this.opts.agents.get(e.agentId);if(!c)return ce.info("_agent/switchModel: agent not running, config persisted only",{agentId:e.agentId}),{ok:!0};c.model=s,e.modelInfo&&c.setModelInfo(e.modelInfo),this.opts.cleanupOpenclawProviders&&await this.opts.cleanupOpenclawProviders(c).catch(u=>ce.warn("cleanupOpenclawProviders before switchModel failed (ignored)",{agentId:e.agentId,err:String(u)}));let d=[];for(let[u,f]of c.allSessionQueues())d.push(f.enqueue(async()=>{let h=c.sessions.get(u);h?.downstream&&(await h.downstream.stop(`switchModel: ${s}`).catch(()=>{}),h.downstream=void 0)}));return await Promise.all(d),ce.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($e(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($e(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){ce.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){ce.warn("detailSyncer not wired, skipping sync",{method:s,agentId:e});return}try{await this.opts.detailSyncer(e)}catch(c){ce.warn("detail sync failed (ignored)",{method:s,agentId:e,reason:o,err:String(c)})}}async getFileTree(e){$e(e._meta,"_agent/getFileTree");let s=e._meta,o=Ct(s),c=await this.resolveWorkspace(o),d=e.filePath??"",u=this.safeJoin(c,d),f=await ei(u).catch(()=>null);if(!f)throw new S("IPC_BAD_REQUEST",`path not found: ${d}`);if(f.isSymbolicLink())throw new S("IPC_BAD_REQUEST",`symlink not allowed: ${d}`);let h=Ud(e.depth);return f.isDirectory()?{tree:await Fd(c,u,d,h)}:{tree:[{name:qd(d),path:ro(d||"."),isDir:!1,size:f.size,modifiedAt:Math.floor(f.mtimeMs)}]}}async getFileContent(e){$e(e._meta,"_agent/getFileContent");let s=Ct(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 ei(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>Xs)throw new S("IPC_BAD_REQUEST",`file too large: ${d.size} bytes (max ${Xs})`);let u=await Zs(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 he(e).catch(()=>null))?.workspace??Je(e).workspace}safeJoin(e,s){let o=Ed(e,s||"."),c=eo(e,o);if(c.startsWith("..")||c===".."||c.startsWith(`..${to}`))throw new S("IPC_BAD_REQUEST",`path escapes workspace: ${s}`);return o}loadAgentCfg(e){return he(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 Pd(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 Cd(n){return n==="claude-code"?Me(".claude","skills"):Me(".agents","skills")}var kd=3e4,Dd=50*1024*1024,zn=3e4;async function ti(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 f=Pd(c.skillName),h=Cd(o),p=Me(h,f),w=Me(s,p);if(await _d(w,{recursive:!0}),d){let E=Buffer.from(c.content,"utf8");Qt(E.length),await Ys(Me(w,"SKILL.md"),E,"utf8")}else{let E=await Nd(c.downloadUrl);Ld(E)?await Md(E,w):await Ys(Me(w,"SKILL.md"),E.toString("utf8"),"utf8")}let b={skillId:c.skillId,skillName:c.skillName,relPath:p,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 ce.info("skill installed",{agentId:e,skillId:c.skillId,skillName:c.skillName,relPath:p,source:d?"content":"downloadUrl"}),b}function ni(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 Rd(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 Nd(n){if(!n)throw new S("IPC_BAD_REQUEST","skill missing downloadUrl");if(n.startsWith("data:")){let e=Math.floor(n.length*3/4);Qt(e);let s=Od(n);return Qt(s.length),s}if(n.startsWith("file:")){let e=new URL(n).pathname,s=await Zs(e);return Qt(s.length),s}if(Nn(n)){let e=new AbortController,s=setTimeout(()=>e.abort(),kd);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 Qt(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 Qt(n){if(n>Dd)throw new S("IPC_BAD_REQUEST",`skill too large: ${n} bytes`)}function Od(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 Ld(n){return n.length>=2&&n[0]===31&&n[1]===139}async function Md(n,e){await Bd(n),await new Promise((s,o)=>{let c=Qs("tar",["-xzf","-","-C",e,"--strip-components=1","--no-same-owner"],{stdio:["pipe","pipe","pipe"]}),d="";c.stderr?.on("data",f=>{d+=String(f)});let u=setTimeout(()=>{c.kill("SIGKILL"),o(new S("IPC_BAD_REQUEST",`tar extract timeout (${zn}ms)`))},zn);c.on("error",f=>{clearTimeout(u),o(new S("IPC_BAD_REQUEST",`tar spawn failed: ${f.message}`,{cause:f}))}),c.on("exit",f=>{clearTimeout(u),f===0?s():o(new S("IPC_BAD_REQUEST",`tar exit ${f}${d?`: ${d.trim().slice(0,200)}`:""}`))}),c.stdin?.end(n)})}async function Bd(n){let e=await new Promise((s,o)=>{let c=Qs("tar",["-tzvf","-"],{stdio:["pipe","pipe","pipe"]}),d="",u="";c.stdout?.on("data",h=>{d+=String(h)}),c.stderr?.on("data",h=>{u+=String(h)});let f=setTimeout(()=>{c.kill("SIGKILL"),o(new S("IPC_BAD_REQUEST",`tar list timeout (${zn}ms)`))},zn);c.on("error",h=>{clearTimeout(f),o(new S("IPC_BAD_REQUEST",`tar list spawn failed: ${h.message}`))}),c.on("exit",h=>{clearTimeout(f),h===0?s(d):o(new S("IPC_BAD_REQUEST",`tar list exit ${h}${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(h=>h===".."))throw new S("IPC_BAD_REQUEST",`tar entry contains '..': ${u}`)}}var zd=5e3;async function Fd(n,e,s,o){return no(n,e,s,o,{count:0})}async function no(n,e,s,o,c){if(o<=0)return[];let d;try{d=await yd(e,{withFileTypes:!0})}catch{return[]}let u=[];for(let f of d){if(Td.has(f.name)||f.isSymbolicLink())continue;if(c.count>=zd){u.push({name:"...",path:"...",isDir:!1,size:0,modifiedAt:0,hasMore:!0});break}let h=Me(e,f.name),p=Sd(Me(s,f.name)),w=null;try{w=await ei(h)}catch{continue}if(w.isSymbolicLink())continue;c.count++;let b={name:f.name,path:ro(eo(n,h)),isDir:w.isDirectory(),size:w.size,modifiedAt:Math.floor(w.mtimeMs)};w.isDirectory()&&o>1&&(b.children=await no(n,h,p,o-1,c)),u.push(b)}return u.sort((f,h)=>f.isDir!==h.isDir?f.isDir?-1:1:f.name.localeCompare(h.name)),u}function Ud(n){return!n||n<=0?Id:Math.min(n,Ad)}function qd(n){if(!n||n==="."||n==="/")return".";let e=n.split(/[/\\]/);return e[e.length-1]||"."}function ro(n){return n.split(to).join("/")}q();import{readFileSync as mp}from"node:fs";import{dirname as _p,join as yp}from"node:path";import{fileURLToPath as vp}from"node:url";var st="0.1.63";var Be=N("agent-health-reporter"),Gd=1e4,Zt=class{constructor(e){this.opts=e;this.intervalMs=e.intervalMs??Gd}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 f of this.opts.core.agents.values()){let h=Hd(f);if(!h)continue;let p={agentId:f.agentId,status:h};f.patToken&&(p.patToken=f.patToken),f.accountId&&(p.accountId=f.accountId),s.push(p)}if(s.length===0)return;let o={agents:s,bridgeVersion:st,_meta:{cozeDeviceId:e}},c;try{c=await this.opts.core.sendRequest("_agent/health",o,5e3)}catch(f){Be.warn("heartbeat batch send failed",{count:s.length,err:String(f)})}let d=c?.authFailures;if(d&&d.length>0&&(Be.warn("heartbeat received authFailures from cloud",{count:d.length,agentIds:d.map(f=>f.agentId)}),this.opts.onAuthFailures))try{await this.opts.onAuthFailures(d)}catch(f){Be.warn("onAuthFailures callback failed (ignored)",{err:String(f)})}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(f){Be.warn("onMinBridgeVersion callback failed (ignored)",{err:String(f)})}}finally{this.inFlight=!1}if(this.opts.onTickEnd)try{await this.opts.onTickEnd()}catch(s){Be.warn("onTickEnd hook failed",{err:String(s)})}}};function Hd(n){return n.status==="error"?"error":n.activeTriggers.size>0?"busy":n.status==="ok"?"online":null}it();import{mkdir as si,rm as mx}from"node:fs/promises";import{spawn as Xd,spawnSync as Qd}from"node:child_process";function en(n,e,s){return s===void 0?{jsonrpc:"2.0",id:n,method:e}:{jsonrpc:"2.0",id:n,method:e,params:s}}function tn(n,e){return e===void 0?{jsonrpc:"2.0",method:n}:{jsonrpc:"2.0",method:n,params:e}}function Dt(n,e){return{jsonrpc:"2.0",id:n,result:e}}function ot(n,e){return{jsonrpc:"2.0",id:n,error:e}}var Fn=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,AGENT_FRAME_IDLE_TIMEOUT:-32016,MODEL_MODALITY_UNSUPPORTED:-32017};function io(n){return"method"in n&&"id"in n&&n.id!==void 0}function so(n){return"method"in n&&!("id"in n)}function Un(n){return!("method"in n)&&"id"in n}var jd={AGENT_NOT_FOUND:H.AGENT_NOT_FOUND,AGENT_BUSY:H.AGENT_BUSY,AGENT_DISCONNECTED:H.AGENT_DISCONNECTED,AGENT_TIMEOUT:H.AGENT_TIMEOUT,AGENT_FRAME_IDLE_TIMEOUT:H.AGENT_FRAME_IDLE_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,MODEL_MODALITY_UNSUPPORTED:H.MODEL_MODALITY_UNSUPPORTED,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,NPX_CACHE_CORRUPT:H.INTERNAL_ERROR};function Kd(n){if(n!=null)return n instanceof Error?{name:n.name,message:nn(n.message)}:typeof n=="string"?nn(n):typeof n=="object"?Jd(n):n}var Wd=[[/\/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 nn(n){let e=n;for(let[s,o]of Wd)e=e.replace(s,o);return e}function Jd(n){let e={};for(let[s,o]of Object.entries(n))typeof o=="string"?e[s]=nn(o):e[s]=o;return e}function rn(n){if(n instanceof S){let e=Kd(n.cause),s={bridgeCode:n.code,retriable:n.retriable};return e!==void 0&&(s.cause=e),{code:jd[n.code]??H.INTERNAL_ERROR,message:nn(n.message),data:s}}return{code:H.INTERNAL_ERROR,message:nn(n instanceof Error?n.message:String(n))}}function oo(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,...f}=e;d=f}return new S(s,c,{retriable:e?.retriable??!1,cause:d})}function co(n){return`${JSON.stringify(n)}
|
|
118
|
+
`}var ao=10*1024*1024,qn=class{buffer="";onError;constructor(e={}){this.onError=e.onError}push(e){if(this.buffer+=typeof e=="string"?e:e.toString("utf8"),this.buffer.length>ao){let c=this.buffer.length;return this.buffer="",this.onError?.({line:`<buffer overflow: ${c} bytes, dropped>`,error:new Error(`LdjsonDecoder buffer exceeded ${ao} 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 uo={"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"},Np=Object.fromEntries(Object.entries(uo).map(([n,e])=>[e,n])),$d={"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:[]},Rt=class{seq=0;next(e,s){this.seq+=1;let o=uo[e]??Vd(e),c=$d[o]??[],d=[o,String(this.seq)];if(c.length>0){let u=c.map(h=>xo(s?.[h]??"")),f=Yd(u).join(":");f&&d.push(f)}else s&&Object.values(s).some(u=>u)&&d.push(Object.values(s).filter(Boolean).map(u=>xo(String(u))).join(":"));return d.join("_")}reset(){this.seq=0}};function Vd(n){return n.replace(/[\s/]+/g,".").replace(/_+/g,"-")}function xo(n){return n.replace(/[:_\s]+/g,"-")}function Yd(n){let e=n.length;for(;e>0&&!n[e-1];)e-=1;return n.slice(0,e)}function at(n,e){let s=process.env[n];if(!s)return e;let o=Number(s);return Number.isFinite(o)&&o>0?o:e}q();var Zd=at("COZE_BRIDGE_INITIALIZE_TIMEOUT_MS",3e4),ex=200,tx=/(ENOTEMPTY|EEXIST).*_npx[/\\]/;function ri(n){return n.some(e=>tx.test(e))}var nx=at("COZE_BRIDGE_SESSION_PROMPT_MAX_MS",3600*1e3),rx=at("COZE_BRIDGE_SESSION_PROMPT_FRAME_IDLE_MS",600*1e3),fo=500;function ix(n){try{let e=JSON.stringify(n);return e===void 0||e.length<=fo?n:`${e.slice(0,fo)}...<truncated, total ${e.length} chars>`}catch{return"<unserializable>"}}function lo(n,e){if(!(typeof n!="number"||n<=0))try{if(process.platform==="win32"){let s=["/PID",String(n),"/T"];e==="SIGKILL"&&s.push("/F"),Qd("taskkill",s,{stdio:"ignore",windowsHide:!0})}else process.kill(-n,e)}catch{}}var ze=class{constructor(e){this.opts=e;this.log=N(`downstream.${this.constructor.name}`),this.decoder=new qn({onError:s=>this.log.warn("decode line failed",{line:s.line})})}opts;child;decoder;pending=new Map;inflightAgentRequests=new Map;idAllocator=new Rt;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=Xd(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>ex&&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]}),(this.framework==="claude-code"||this.framework==="codex")&&ri(this.stderrRing)&&(this.log.warn("npx cache corruption detected, triggering global install fallback (D93)",{framework:this.framework}),It(this.framework).catch(f=>{this.log.warn("D93 fallback install failed (will retry next spawn cycle)",{framework:this.framework,err:String(f)})})));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()));lo(s.pid,"SIGTERM");let c=setTimeout(()=>{s.killed||lo(s.pid,"SIGKILL")},5e3);try{await o}finally{clearTimeout(c)}}pid(){return this.child?.pid}isAlive(){return!!this.child&&!this.stopped}getStderrTail(){return[...this.stderrRing]}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=nx,o=rx){return this.call("session/prompt",e,s,o)}async sessionCancel(e){!this.child||this.stopped||this.writeFrame(tn("session/cancel",e))}onUpdate(e){this.updateHandlers.push(e)}onAgentRequest(e){this.agentRequestHandlers.push(e)}respondAgentRequest(e,s){if(this.inflightAgentRequests.delete(e),!(!this.child||this.stopped))try{this.writeFrame(Dt(e,s))}catch(o){this.log.warn("respondAgentRequest write failed",{id:e,err:String(o)})}}respondAgentRequestError(e,s){if(this.inflightAgentRequests.delete(e),!(!this.child||this.stopped))try{this.writeFrame(ot(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=Zd,c=0){if(!this.child||this.stopped)return Promise.reject(new S("AGENT_PROTOCOL_ERROR","downstream not started"));let d=this.idAllocator.next(e),u=en(d,e,s),f=o>0&&Number.isFinite(o),h=c>0&&Number.isFinite(c);return new Promise((p,w)=>{let b={resolve:p,reject:w,timer:null,frameIdleTimer:null,armFrameIdle:null,method:e};f&&(b.timer=setTimeout(()=>{this.pending.delete(d),b.frameIdleTimer&&clearTimeout(b.frameIdleTimer),w(new S("AGENT_TIMEOUT",`${e} timed out after ${o}ms`))},o));let E=h?()=>{b.frameIdleTimer&&clearTimeout(b.frameIdleTimer),b.frameIdleTimer=setTimeout(()=>{if(this.inflightAgentRequests.size>0){this.log.debug("frame-idle fired but agent request inflight, re-arming",{id:d,method:e,inflight:this.inflightAgentRequests.size}),E?.();return}b.timer&&clearTimeout(b.timer),this.pending.delete(d),this.log.warn("frame-idle timeout, rejecting pending call",{id:d,method:e,frameIdleMs:c}),w(new S("AGENT_FRAME_IDLE_TIMEOUT",`${e} no session/update for ${c}ms (no inflight agent request)`))},c)}:null;b.armFrameIdle=E,this.pending.set(d,b),E?.();try{this.writeFrame(u)}catch(I){b.timer&&clearTimeout(b.timer),b.frameIdleTimer&&clearTimeout(b.frameIdleTimer),this.pending.delete(d),w(I)}})}writeFrame(e){if(!this.child?.stdin||this.child.stdin.destroyed)throw new S("AGENT_PROTOCOL_ERROR","downstream stdin not writable");this.child.stdin.write(co(e),s=>{s&&this.log.warn("stdin write callback err",{err:String(s)})})}dispatch(e){if(Un(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),s.frameIdleTimer&&clearTimeout(s.frameIdleTimer),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(oo(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:ix(e.result)}),s.resolve(e.result));return}if(so(e)){if(e.method==="session/update"){for(let s of this.pending.values())s.armFrameIdle?.();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(io(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(ot(e.id,{code:-32601,message:`method not handled by Bridge: ${e.method}`}));return}this.inflightAgentRequests.set(e.id,e.method);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(ot(e.id,rn(o)))}catch{}this.inflightAgentRequests.delete(e.id)}}failAllPending(e){for(let s of this.pending.values())s.timer&&clearTimeout(s.timer),s.frameIdleTimer&&clearTimeout(s.frameIdleTimer),s.reject(e);this.pending.clear(),this.inflightAgentRequests.clear()}};var sx="@agentclientprotocol/claude-agent-acp@latest";function ox(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 Gn=class extends ze{framework="claude-code";constructor(e){let s=At("claude-code"),[o,c]=s?[s,[]]:["npx",["-y",sx]],d=e.command??o,u=e.args??c,f={command:d,args:u,cwd:e.cwd,...e.env?{env:e.env}:{}};super(f)}sanitizeEnv(e){return ox(e)}};import{mkdtempSync as ax,rmSync as cx}from"node:fs";import{tmpdir as dx}from"node:os";import{join as xx}from"node:path";var ux="@zed-industries/codex-acp@latest",Hn=class extends ze{framework="codex";authMethodId;codexHomeDir;constructor(e){let s=At("codex"),[o,c]=s?[s,[]]:["npx",["-y",ux]],d=e.command??o,u=e.args??c,f=e.extraArgs?[...u,...e.extraArgs]:u,h=e.isolateCodexHome?ax(xx(dx(),"coze-bridge-codex-home-")):void 0,p=h?{...e.env??{},CODEX_HOME:h}:e.env,w={command:d,args:f,cwd:e.cwd,...p?{env:p}:{}};super(w),this.authMethodId=e.authMethodId,this.codexHomeDir=h}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{cx(this.codexHomeDir,{recursive:!0,force:!0})}catch{}}};var fx=3e4,Nt=class extends ze{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}`}]},fx))}get acpSessionName(){return this.sessionName}};q();ie();function ii(n){return n.replace(/[^A-Za-z0-9._-]+/g,"-")}var Ot=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;modelInfo;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),e.modelInfo&&(this.modelInfo=e.modelInfo)}setPatToken(e){this.patToken=e}setModelInfo(e){this.modelInfo=e}getSessionQueue(e){let s=this.sessionQueues.get(e);return(!s||s.isDisposed)&&(s=new Ot,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)sn(o),o.downstream&&(s.push(o.downstream.stop(e).catch(()=>{})),o.downstream=void 0);await Promise.all(s),this.activeTriggers.clear()}};function sn(n){n.idleTimer&&(clearTimeout(n.idleTimer),n.idleTimer=void 0)}import{spawn as lx}from"node:child_process";import{homedir as gx}from"node:os";import{join as hx}from"node:path";Pn();q();async function po(){let n=hx(gx(),".openclaw/openclaw.json");return(await Tt(n))?.gateway?.auth?.token??""}var go=N("openclaw.config"),px=[0,5e3,5e3],ho="models.providers.",Kn="agents.defaults.models",Wn=class{command;env;retryDelaysMs;queue=new Ot;constructor(e){this.command=e.command,this.env=e.env??process.env,this.retryDelaysMs=e.retryDelaysMs??px}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,go.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=lx(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){go.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",`${ho}${e}`,JSON.stringify(s),"--strict-json","--merge"])))}removeProvider(e){return this.bestEffortUnset(`config unset models.providers.${e}`,`${ho}${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 pe=N("agent-manager"),_x=(n,e,s,o,c,d,u,f)=>{switch(n){case"claude-code":{let h={...c?{...js(c),...Js(c,u)}:{},...f??{},IS_SANDBOX:"1"};return new Gn({cwd:s,env:h})}case"codex":{let p=[...c?[...Ks(c),...Vs(c,u)]:[],"-c",'sandbox_mode="danger-full-access"',"-c",'approval_policy="never"'],w={...c?Ws(c):{},...f??{}},b=!!c;return new Hn({cwd:s,...p.length>0?{extraArgs:p}:{},...Object.keys(w).length>0?{env:w}:{},...b?{authMethodId:"openai-api-key",isolateCodexHome:!0}:{}})}case"openclaw":return new Nt({command:e,cwd:s,agentId:o,...d?{sessionName:ii(d)}:{}})}};function oi(n){return n==="claude-code"||n==="codex"}var yx={path:"",version:"cloud-deployed"},bx={protocolVersion:1,clientCapabilities:{fs:{readTextFile:!0,writeTextFile:!0}}},vx=6e4,Sx=at("COZE_BRIDGE_SPAWN_AWAIT_INSTALL_MS",25e3),Jn=class{paths;config;registry;factory;createTimeoutMs;spawnAwaitInstallMs;openclawConfigCache;ensuredProviders=new Set;constructor(e){this.paths=e.paths,this.config=e.config,this.registry=e.registry,this.factory=e.downstreamFactory??_x,this.createTimeoutMs=e.createTimeoutMs??vx,this.spawnAwaitInstallMs=e.spawnAwaitInstallMs??Sx}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 Wn({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=Yt(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")pe.warn("existing agent in error state, rebuilding",{agentId:e.agentId}),await o.dispose("rebuild after error").catch(A=>pe.warn("dispose stale agent failed (ignored)",{err:String(A)})),this.registry.unregister(e.agentId);else{if(e.patToken&&e.patToken!==o.patToken){pe.info("updating agent patToken on re-create (reconnect with new PAT)",{agentId:e.agentId}),o.setPatToken(e.patToken);let A=await he(e.agentId,this.paths).catch(()=>null);A&&(A.patToken=e.patToken,await Se(A,this.paths))}if(o.deployType==="cloud"&&e.modelInfo){pe.info("updating agent modelInfo on re-create",{agentId:e.agentId}),o.setModelInfo(e.modelInfo);let A=await he(e.agentId,this.paths).catch(()=>null);A&&(A.modelInfo=e.modelInfo,await Se(A,this.paths))}return pe.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=Je(e.agentId,this.paths),u=Yt(e._meta),f=e.framework==="openclaw"&&u==="local",h=f?this.config.frameworksCache?.openclaw?.defaultAgent?.workspace:void 0,p=e.workspace??h??d.workspace,w=new AbortController,b=setTimeout(()=>w.abort(new S("AGENT_TIMEOUT",`_agent/create timed out after ${this.createTimeoutMs}ms`)),this.createTimeoutMs),E,I=!1;try{s&&oi(e.framework)&&await It(e.framework,w.signal);let A=()=>{if(w.signal.aborted)throw w.signal.reason instanceof Error?w.signal.reason:new S("AGENT_TIMEOUT","_agent/create aborted")};await si(d.root,{recursive:!0}),await si(p,{recursive:!0}),await si(d.logs,{recursive:!0}),A(),f||await Pt(p,e.framework,e.agentId,e.cozeIdentity),e.framework==="claude-code"&&await Ns(p),A();let k=await he(e.agentId,this.paths).catch(()=>null),z=Gs({model:e.model??k?.model}),Y=Os(e._meta)??k?.accountId,j=e.patToken??k?.patToken,oe=u==="cloud"?e.modelInfo??k?.modelInfo:void 0;if(E=new jn({agentId:e.agentId,framework:e.framework,workspace:p,model:z.model??Le,deployType:u,...Y?{accountId:Y}:{},...j?{patToken:j}:{},...oe?{modelInfo:oe}:{}}),E.status="ok",k?.sessions){for(let[ke,xe]of Object.entries(k.sessions))E.sessions.set(ke,{acpSessionId:xe.acpSessionId,modelToken:xe.modelToken,tokenGeneratedAt:xe.tokenGeneratedAt,lastActiveAt:Date.now(),loadingSession:!1,replySeq:0});let _e=Object.keys(k.sessions).length;_e>0&&pe.info("restored persisted session records (no spawn)",{agentId:e.agentId,count:_e})}this.registry.register(E),I=!0;let W={agentId:e.agentId,framework:e.framework,workspace:p,cozeIdentity:e.cozeIdentity,createdAt:k?.createdAt??Date.now(),sessions:k?.sessions??{},model:z.model};u==="cloud"&&(W.deployType="cloud"),Y&&(W.accountId=Y),j&&(W.patToken=j),oe&&(W.modelInfo=oe),k?.skills&&(W.skills=k.skills),k?.agentName&&(W.agentName=k.agentName),k?.description&&(W.description=k.description),e.framework==="openclaw"&&u==="cloud"&&(this.config.frameworksCache?.openclaw?.path?await this.getOpenclawConfig().ensureAgent(e.agentId,p):pe.warn("openclaw binary not on this machine, skip agents add (will fail at session/prompt)",{agentId:e.agentId}));let le=e.initialSkills??[];if(le.length>0){let _e=[...W.skills??[]],ke=new Map(_e.map((T,O)=>[T.skillId,O])),xe=await Promise.allSettled(le.map(T=>ti({agentId:e.agentId,workspace:p,framework:e.framework,skill:T}))),we=0;for(let[T,O]of xe.entries()){let B=le[T];B&&(O.status==="fulfilled"?(ni(_e,ke,O.value),we++):pe.warn("initialSkill install failed (skipping)",{agentId:e.agentId,skillId:B.skillId,skillName:B.skillName,err:String(O.reason)}))}we>0&&(W.skills=_e,pe.info("initialSkills installed",{agentId:e.agentId,installed:we,requested:le.length}))}return await Se(W,this.paths),pe.info("agent created (no spawn, lazy on first prompt)",{agentId:e.agentId,framework:e.framework,deployType:u}),{ok:!0,agentId:e.agentId,workspace:p,framework:e.framework}}catch(A){throw pe.error("agent create failed, rolling back",{agentId:e.agentId,err:String(A)}),I&&E&&(await E.dispose("rollback").catch(()=>{}),this.registry.unregister(e.agentId)),await mx(d.root,{recursive:!0,force:!0}).catch(k=>pe.warn("rm agent dir failed (ignored)",{err:String(k)})),A instanceof S?A:new S("AGENT_SPAWN_FAILED",String(A),{cause:A})}finally{clearTimeout(b)}}async spawnSessionDownstream(e,s,o,c){let u=this.config.frameworksCache?.[e.framework];if(!u)if(e.deployType==="cloud"&&oi(e.framework))u=yx;else throw new S("AGENT_SPAWN_FAILED",`framework ${e.framework} not detected on this machine`);if(oi(e.framework)&&!At(e.framework)){let p=vs(e.framework);p&&(pe.info("spawn: awaiting in-flight acp install (D92)",{agentId:e.agentId,framework:e.framework}),await Promise.race([p.catch(()=>{}),new Promise(w=>setTimeout(w,this.spawnAwaitInstallMs))]))}let f=e.deployType==="cloud"?{model:e.model,modelToken:s,...e.modelInfo?{modelInfo:e.modelInfo}:{}}:void 0,h;e.framework==="openclaw"?h=await this.buildOpenclawDownstream({session:e,modelConfig:f,cloudSessionId:o,cozeEnv:c,command:u.path}):h=this.factory(e.framework,u.path,e.workspace,e.agentId,f,o,c,this.buildBinShimPathEnv());try{return await h.start(),await h.initialize(bx),h}catch(p){let w=h instanceof ze?h.getStderrTail():[];w.length>0&&pe.warn("spawnSessionDownstream failed, recent stderr (D94)",{agentId:e.agentId,framework:e.framework,method:p instanceof S?p.code:"unknown",recentStderr:w});let b=ri(w);await h.stop("spawnSessionDownstream failed").catch(()=>{});let E=b?new S("NPX_CACHE_CORRUPT","~/.npm/_npx \u76EE\u5F55\u635F\u574F (ENOTEMPTY)\u3002\u5EFA\u8BAE: rm -rf ~/.npm/_npx && npm i -g @zed-industries/codex-acp (\u6216\u5BF9\u5E94 @agentclientprotocol/claude-agent-acp)",{cause:p}):p;throw p instanceof S?new S(p.code,p.message,{retriable:p.retriable,cause:E}):new S("AGENT_SPAWN_FAILED",p instanceof Error?p.message:String(p),{cause:E})}}async buildOpenclawDownstream(e){let{session:s,modelConfig:o,cloudSessionId:c,cozeEnv:d,command:u}=e,f=ii(c);if(s.deployType==="local"){let b=this.config.frameworksCache?.openclaw?.defaultAgent;if(!b?.id||!b.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 Nt({command:u,cwd:b.workspace,agentId:b.id,sessionName:f})}let h=await po(),p=o?$s(o,d):null,w;if(p){let b=Zr(c),I=p.models[0]?.id??Le,A=`${b}/${I}`;if(!this.ensuredProviders.has(A)){let k=this.getOpenclawConfig();await k.ensureProvider(b,p),await k.addModelToAllowlist(A),this.ensuredProviders.add(A)}w=A}return new Nt({command:u,cwd:s.workspace,agentId:s.agentId,sessionName:f,...h?{gatewayToken:h}:{},...w?{slashModelOnStart:w}:{}})}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=Zr(o),d=`${c}/${e.model}`,u=!0;try{await s.removeProvider(c)}catch(f){u=!1,pe.warn("removeProvider failed, keeping ensuredProviders entry",{providerId:c,err:String(f)})}try{await s.removeModelFromAllowlist(d)}catch(f){u=!1,pe.warn("removeModelFromAllowlist failed, keeping ensuredProviders entry",{fullModelId:d,err:String(f)})}u&&this.ensuredProviders.delete(d)}}};import{randomUUID as Ox}from"node:crypto";import{promises as Lx}from"node:fs";import{basename as Mx}from"node:path";import{promises as Ix}from"node:fs";import{basename as Ax}from"node:path";q();var mo=N("file-upload"),Tx="/api/coze_claw/file/agent_upload",Px=6e4;async function wo(n,e={}){let o=`${On(Mn(e.handshakeBase))}${Tx}`,c=e.timeoutMs??Px,d=await Ix.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 f={Authorization:`Bearer ${n.patToken}`,Accept:"application/json","x-coze-version":"3.0",...kt(e.ppeOverride),...n.accountId?{"x-coze-account":n.accountId}:{}},h=new AbortController,p=setTimeout(()=>h.abort(),c);mo.info("file upload start",{url:o,agentId:n.agentId,sessionId:n.sessionId,name:n.name,bytes:n.sizeBytes,mime:n.mimeType});try{let w=await fetch(o,{method:"POST",headers:f,body:u,signal:h.signal}),b=w.headers.get("x-tt-logid")??"";if(!w.ok){let A=await w.text().catch(()=>"");throw new S("UPLOAD_FAILED",`upload HTTP ${w.status} logid=${b}: ${A.slice(0,200)}`)}let E=await w.json();if(E.code!==void 0&&E.code!==0)throw new S("UPLOAD_FAILED",`upload code=${E.code} msg=${E.msg??"-"} logid=${b}`);let I=E.data?.file?.file_url;if(!I)throw new S("UPLOAD_FAILED",`upload response missing data.file.file_url logid=${b}: ${JSON.stringify(E).slice(0,200)}`);return mo.info("file upload ok",{uri:I,logid:b}),{uri:I}}catch(w){throw w instanceof S?w:w.name==="AbortError"?new S("UPLOAD_FAILED",`upload timeout (${c}ms) for ${Ax(n.path)}`):new S("UPLOAD_FAILED",String(w),{cause:w})}finally{clearTimeout(p)}}q();import{promises as Cx}from"node:fs";import{extname as kx}from"node:path";var Dx=[{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 Rx(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 Nx={".txt":"text/plain",".md":"text/markdown",".svg":"image/svg+xml",".json":"application/json"};async function _o(n){let e=await Cx.open(n,"r");try{let s=Buffer.alloc(16);if(await e.read(s,0,16,0),Rx(s))return"image/webp";for(let o of Dx)if(o.prefix.every((c,d)=>s[d]===c))return o.mime}finally{await e.close()}return Nx[kx(n).toLowerCase()]??"application/octet-stream"}ie();var yo=N("agent-send"),bo=50*1024*1024,Bx=new Set(["image/png","image/jpeg","image/webp","image/gif","image/svg+xml","application/pdf","application/json","text/plain","text/markdown"]);async function vo(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 Cs(n.path,s.workspace))throw new S("PATH_OUTSIDE_WORKSPACE",`path=${n.path} not under workspace=${s.workspace}`);let c=await Lx.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>bo)throw new S("FILE_TOO_LARGE",`${c.size} bytes > limit ${bo}`);let d=await _o(n.path);if(!Bx.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??Mx(n.path),f=await wo({patToken:s.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}),h={sessionUpdate:"agent_file",messageId:Ox(),content:{type:n.kind==="image"?"image":"resource",uri:f.uri,mimeType:d,name:u,sizeBytes:c.size,...f.fileId!==void 0?{fileId:f.fileId}:{},...n.caption!==void 0?{caption:n.caption}:{}}},p=2,w;for(let b=0;b<=p;b++)try{await e.core.sendAgentFileUpdate(s,o,n.sessionId,h),w=void 0;break}catch(E){w=E,b<p&&(yo.warn("sendAgentFileUpdate failed, retrying",{attempt:b+1,err:String(E)}),await new Promise(I=>setTimeout(I,5e3)))}if(w)throw new S("UPSTREAM_NOT_READY",`agent file uploaded to cloud but sendAgentFileUpdate failed after ${p+1} attempts: ${String(w)}`,{cause:w});return yo.info("agent file sent",{agentId:n.agentId,sessionId:n.sessionId,kind:n.kind,name:u,bytes:c.size,mime:d,uri:f.uri}),{ok:!0,uri:f.uri,bytes:c.size,mimeType:d,...f.fileId!==void 0?{fileId:f.fileId}:{}}}import{execFile as zx}from"node:child_process";import{promisify as Fx}from"node:util";function $n(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,f=o[d]??0;if(u<f)return!0;if(u>f)return!1}return!1}q();var Ux=Fx(zx),Fe=N("coze-cli-installer"),So="@coze/cli@latest",qx="coze",Eo="0.1.7",Gx=5e3,Hx=5e3,jx=9e4,Io=1e4,on=null,Vn=!1;async function ai(n,e={}){if(Vn)return;if(on)return on;let s=e.exec??Ux;return on=(async()=>{try{let o=await Kx(qx,s),c=!1;if(o){let u=await Wx(s);if(u===void 0)Fe.warn("coze-cli found but version unparseable, fall through to full install",{path:o});else if($n(u,Eo))Fe.info("coze-cli version too old, upgrade-only (preserve user config + auth)",{path:o,version:u,min:Eo}),c=!0;else{Fe.info("coze-cli already on PATH with sufficient version, skip",{path:o,version:u}),Vn=!0;return}}let d=c?"upgrade-only":"full";Fe.info("coze-cli install start",{package:So,mode:d});try{await s("npm",["i","-g","--prefer-online",So],{timeout:jx,maxBuffer:10*1024*1024}),Fe.info("coze-cli install ok")}catch(u){Fe.warn("coze-cli install failed (skip subsequent steps)",{err:String(u)});return}if(c){Vn=!0;return}if(n.env)try{await s("coze",["config","set","xTTEnv",n.env],{timeout:Io}),Fe.info("coze config set xTTEnv ok",{env:n.env})}catch(u){Fe.warn("coze config set failed (continue to auth login)",{err:String(u)})}try{await s("coze",["auth","login","--token",n.patToken],{timeout:Io}),Fe.info("coze auth login ok")}catch(u){Fe.warn("coze auth login failed",{err:String(u)});return}Vn=!0}finally{on=null}})(),on}async function Kx(n,e){let s=process.platform==="win32"?"where":"which";try{let{stdout:o}=await e(s,[n],{timeout:Gx});return o.split(`
|
|
120
|
+
`)[0]?.trim()||void 0}catch{return}}async function Wx(n){try{let{stdout:e,stderr:s}=await n("coze",["--version"],{timeout:Hx});return(e||s).match(/(\d+\.\d+\.\d+)/)?.[1]}catch{return}}q();import{spawn as Jx}from"node:child_process";import{constants as Ao,access as $x}from"node:fs/promises";import{delimiter as Vx,join as Yx}from"node:path";var To=N("framework-detector"),Po={"claude-code":"claude",codex:"codex",openclaw:"openclaw"},Xx=[".exe",".cmd",".bat",".ps1"],Lt=class{env;constructor(e={}){this.env={pathEnv:e.pathEnv??process.env.PATH??"",platform:e.platform??process.platform,spawn:e.spawn??Jx,access:e.access??$x}}async detect(e){let s=Po[e],o=await this.which(s);if(!o)return To.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)]),f={path:o,version:d};return u&&(f.defaultAgent=u),f}async detectAll(){let e=await Promise.all(Object.keys(Po).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(Vx).filter(Boolean),o=this.env.platform==="win32"?["",...Xx]:[""];for(let c of s)for(let d of o){let u=Yx(c,e+d);if(await this.isExecutable(u))return u}return null}async isExecutable(e){try{let s=this.env.platform==="win32"?Ao.F_OK:Ao.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;let o=s.stdout.match(/\[\s*\{[\s\S]*\}\s*\]/);if(!o)return null;try{let c=JSON.parse(o[0]);if(!Array.isArray(c))return null;let d=c.find(u=>u?.isDefault===!0);return!d?.id||!d.workspace?null:{id:d.id,workspace:d.workspace}}catch(c){return To.warn("openclaw agents list --json parse failed",{err:String(c)}),null}}async probeVersion(e,s=[]){let o=await this.runProbe(e,[...s,"--version"]);return o&&(Zx(o.stdout).split(/\r?\n/)[0]??"").trim()||"unknown"}runProbe(e,s){return new Promise(o=>{let c="",d=!1,u,f=h=>{d||(d=!0,u&&clearTimeout(u),o(h))};try{let h=this.env.spawn(e,s,{stdio:["ignore","pipe","pipe"]});u=setTimeout(()=>{h.kill("SIGKILL"),f(null)},5e3),h.stdout?.on("data",p=>{c+=p.toString("utf8")}),h.on("error",()=>f(null)),h.on("close",p=>f({code:p,stdout:c}))}catch{f(null)}})}},Qx=new RegExp("\x1B\\[[0-9;]*[A-Za-z]","g");function Zx(n){return n.replace(Qx,"")}Mt();import{randomBytes as wu}from"node:crypto";import{createReadStream as tu}from"node:fs";import{mkdir as nu,readFile as ru,realpath as iu,stat as su,writeFile as ou}from"node:fs/promises";import{basename as au,dirname as ci,join as cu,relative as du,resolve as ko,sep as xu}from"node:path";import{createInterface as uu}from"node:readline";q();var Ro=N("fs-rpc"),an=at("COZE_BRIDGE_FS_RPC_MAX_BYTES",20*1024*1024);async function No(n,e){let s=Buffer.byteLength(n.content,"utf8");if(s>an)throw new S("IPC_BAD_REQUEST",`fs/write_text_file content too large: ${s} bytes > limit ${an} bytes`);let o=await Lo(n.path,e);return await nu(ci(o),{recursive:!0}),await ou(o,n.content,"utf8"),Ro.info("fs/write_text_file ok",{path:o,size:n.content.length}),null}async function Oo(n,e){let s=await Lo(n.path,e),o=await su(s),c=typeof n.line=="number"||typeof n.limit=="number";if(o.size>an&&!c)throw new S("IPC_BAD_REQUEST",`fs/read_text_file too large without line/limit slicing: ${o.size} bytes > ${an} bytes`);let d;if(c&&o.size>an)d=await fu(s,n.line??1,n.limit);else{let u=await ru(s,"utf8");if(c){let f=u.split(`
|
|
121
|
+
`),h=Math.max(0,(n.line??1)-1),p=typeof n.limit=="number"?h+n.limit:void 0;d=f.slice(h,p).join(`
|
|
122
|
+
`)}else d=u}return Ro.info("fs/read_text_file ok",{path:s,size:d.length}),{content:d}}async function fu(n,e,s){let o=uu({input:tu(n,{encoding:"utf8"}),crlfDelay:Number.POSITIVE_INFINITY}),c=Math.max(0,e-1),d=typeof s=="number"?c+s:Number.POSITIVE_INFINITY,u=[],f=0;try{for await(let h of o)if(f>=c&&f<d&&u.push(h),f++,f>=d)break}finally{o.close()}return u.join(`
|
|
123
|
+
`)}async function Lo(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([Do(ko(e)),Do(ko(n))]),c=du(s,o);if(c.startsWith("..")||c===".."||c.startsWith(`..${xu}`))throw new S("IPC_BAD_REQUEST",`path escapes workspace: ${n}`);return o}async function Do(n){let e=[],s=n;for(;s!==ci(s);)try{let o=await iu(s);return e.length?cu(o,...e.reverse()):o}catch{e.push(au(s)),s=ci(s)}return n}q();var Mo=N("prompt-multimodal"),Bo=10*1024*1024,lu=15e3,gu=6;async function zo(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 hu(u))}}let c=Array.from({length:Math.min(gu,n.length)},()=>o());return await Promise.all(c),e}function Fo(n){return n.some(e=>e.type==="image")}async function hu(n){if(n.type!=="image")return n;let e=n;if(e.data||!e.uri||!Nn(e.uri))return n;try{let{buf:s,contentType:o}=await mu(e.uri),c=e.mimeType||pu(o)||"application/octet-stream";return Mo.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 Mo.warn("image fetch failed, degrading to text block",{uri:e.uri,err:String(s)}),{type:"text",text:`[image load failed: ${e.uri}]`}}}function pu(n){if(!n)return;let e=n.indexOf(";");return(e===-1?n:n.slice(0,e)).trim()||void 0}async function mu(n){let e=new AbortController,s=setTimeout(()=>e.abort(),lu);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>Bo)throw new Error(`image too large: ${c.byteLength} bytes (max ${Bo})`);return{buf:Buffer.from(c),contentType:o.headers.get("content-type")??void 0}}finally{clearTimeout(s)}}it();Mt();q();var M=N("core"),_u=3e4,yu=/^(boe|ppe)_[A-Za-z0-9_-]+$/,bu=3e4,vu=new Set(["_agent/create","session/new","session/load","session/prompt"]),Yn=class{upstream;agents=new Map;disconnectedAgents=new Set;extensions;paths;sessionSpawner;sessionIdleTimeoutMs;upgradeGate;upstreamIds=new Rt;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=Co(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(),M.info("Core started",{extensions:Object.keys(this.extensions)})}async stop(e){M.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),M.info("agent registered",{agentId:e.agentId,framework:e.framework});for(let s of this.registerHandlers)try{s(e.agentId)}catch(o){M.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)&&M.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)=>{M.info("session runtime exited",{agentId:e.agentId,cloudId:s,code:d,signal:u}),sn(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){M.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(ot(c,{code:H.INTERNAL_ERROR,message:`bridge downstream gone: ${s}`})).catch(u=>M.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)){M.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(Un(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&&yu.test(o)?this.currentCozeEnv=o:o&&M.warn("rejecting cozeEnv with invalid shape, keeping previous",{rejected:o});try{if(this.upgradeGate?.isUpgrading()&&vu.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}`):M.warn("drop notification: extension not registered",{method:e.method});return}let d=await c(e,this);s!==null&&await this.upstream.send(Dt(s,d));return}if(e.method.startsWith("session/")){let c=await this.routeSessionMethod(e);s!==null&&await this.upstream.send(Dt(s,c));return}if(e.method==="initialize"){s!==null&&await this.upstream.send(Dt(s,{protocolVersion:1,agentCapabilities:{loadSession:!0}}));return}s!==null?await this.sendError(s,H.METHOD_NOT_FOUND,`method not implemented: ${e.method}`):M.warn("drop unknown notification",{method:e.method})}catch(c){M.error("handleFrame failed",{method:e.method,err:String(c)}),s!==null&&await this.upstream.send(ot(s,rn(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(),f=!1,h=e.method==="session/prompt";h&&this.upgradeGate?.incActive();try{let p=await c.getSessionQueue(d).enqueue(()=>this.dispatchSessionCall(c,e.method,s));return f=!0,p}finally{h&&this.upgradeGate?.decActive(),M.info("session call done",{agentId:c.agentId,method:e.method,durationMs:Date.now()-u,ok:f})}}async dispatchSessionCall(e,s,o){e.lastActiveAt=Date.now();let{stripped:c}=Ls(o);switch(s){case"session/new":{let d=Su();return M.info("session/new ack (lazy spawn)",{agentId:e.agentId,cloudId:d}),{sessionId:d}}case"session/load":{let d=c;return M.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 f=await this.ensureRuntime(e,u);if(f.replySeq=0,await this.ensureDownstream(e,u,f),!f.downstream||!f.acpSessionId)throw new S("BRIDGE_INTERNAL","session runtime not ready after ensureDownstream");let h=o._meta?.cozeTriggerMsgId;if(h?e.activeTriggers.set(f.acpSessionId,h):e.activeTriggers.delete(f.acpSessionId),e.deployType==="cloud"&&e.modelInfo?.capabilities?.image===!1&&Fo(d.prompt))throw new S("MODEL_MODALITY_UNSUPPORTED",`model=${e.modelInfo.id??e.model} does not support image input`);let p=await zo(d.prompt);try{let w=await f.downstream.sessionPrompt({...d,sessionId:f.acpSessionId,prompt:p});return f.lastActiveAt=Date.now(),w}finally{if(e.activeTriggers.delete(f.acpSessionId),f.reloadAfterTurn){f.reloadAfterTurn=!1;let w=f.downstream;w&&(f.downstream=void 0,M.info("reloadAfterTurn: stopping downstream",{agentId:e.agentId,cloudId:u,acpId:f.acpSessionId}),w.stop("reload-after-turn").catch(b=>M.warn("reload-after-turn stop failed (ignored)",{agentId:e.agentId,cloudId:u,err:String(b)})))}else f.downstream?.isAlive()&&this.armIdleTimer(e,u,f)}}case"session/cancel":{let u=c.sessionId;if(!u)throw new S("IPC_BAD_REQUEST","session/cancel: missing sessionId");let f=e.sessions.get(u);if(e.hasSessionQueue(u)){let h=e.getSessionQueue(u);h.size>0&&(M.info("session/cancel: draining queued tasks",{agentId:e.agentId,cloudId:u,queuedCount:h.size}),h.dispose(new S("AGENT_PROTOCOL_ERROR",`cancelled by session/cancel on ${u}`)))}return f?.downstream?.isAlive()&&f.acpSessionId&&await f.downstream.sessionCancel({sessionId:f.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,bu);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(sn(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,f=o.spawnFailedAt??0;if(u>=c&&Date.now()-f<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()-f))/1e3)}s`);let h;try{h=await this.sessionSpawner(e,o.modelToken,s,this.currentCozeEnv)}catch(p){throw o.spawnFailCount=u+1,o.spawnFailedAt=Date.now(),o.spawnFailCount>=c&&o.acpSessionId&&(M.warn("clearing stale acpSessionId after repeated spawn failures",{agentId:e.agentId,cloudId:s,staleAcpId:o.acpSessionId}),o.acpSessionId=void 0),p}if(o.spawnFailCount=0,o.spawnFailedAt=void 0,o.downstream=h,this.attachRuntimeHooks(e,s,o),o.acpSessionId){o.loadingSession=!0;try{await h.sessionLoad({sessionId:o.acpSessionId,cwd:e.workspace}),M.info("session restored via session/load",{agentId:e.agentId,cloudId:s,acpId:o.acpSessionId})}catch(p){M.warn("session/load failed, fallback to session/new",{agentId:e.agentId,cloudId:s,acpId:o.acpSessionId,err:String(p)}),o.acpSessionId=void 0;let w=await h.sessionNew({cwd:e.workspace});o.acpSessionId=w.sessionId,await this.persistSessionMapping(e)}finally{o.loadingSession=!1}}else{let p=await h.sessionNew({cwd:e.workspace});o.acpSessionId=p.sessionId,await this.persistSessionMapping(e)}h.afterSessionEstablished&&o.acpSessionId&&await h.afterSessionEstablished(o.acpSessionId)}armIdleTimer(e,s,o){if(sn(o),this.isRuntimeBusy(e,o)){M.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)){M.info("idle reaper fired but runtime busy, re-arming",{agentId:e.agentId,cloudId:s}),this.armIdleTimer(e,s,o);return}M.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=>M.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(tn("session/update",{sessionId:o,update:c,_meta:d}))}forwardUpdate(e,s){let o=s.sessionId,c=this.reverseSessionId(e,o);if(!c){M.debug("drop update for unknown session",{agentId:e.agentId,acpId:o});return}let d=e.sessions.get(c);if(!d){M.debug("drop update: runtime gone",{agentId:e.agentId,cloudId:c});return}if(Iu(s)){M.debug("drop codex metadata-warn chunk",{agentId:e.agentId,acpId:o});return}let u={cozeAgentId:e.agentId,cozeReplySeqID:++d.replySeq},f=e.activeTriggers.get(o);f&&(u.cozeTriggerMsgId=f),this.upstream.send(tn("session/update",{...s,sessionId:c,_meta:u})).catch(h=>M.warn("forward update failed",{agentId:e.agentId,err:String(h)}))}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}M.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 No(d,c);s.respondAgentRequest(o.id,u)}else{let d=o.params??{},u=await Oo(d,c);s.respondAgentRequest(o.id,u)}}catch(c){M.warn("fs rpc handler failed",{agentId:e.agentId,method:o.method,err:String(c)}),s.respondAgentRequestError(o.id,rn(c))}}forwardPermissionRequest(e,s,o){let c=this.upstreamIds.next("session/request_permission"),d=o.params??{},f=d.sessionId,h=f?e.activeTriggers.get(f):void 0,p={cozeAgentId:e.agentId};h&&(p.cozeTriggerMsgId=h);let w=f?this.reverseSessionId(e,f):void 0,b={...d,...w?{sessionId:w}:{},_meta:p};this.pendingUpstream.set(c,{agentRequestId:o.id,agentId:e.agentId,downstream:s,method:o.method}),M.info("forward permission_request \u2192 upstream",{agentId:e.agentId,upstreamId:c,acpSessionId:f,cloudSessionId:w,toolCallId:d.toolCall?.toolCallId,options:d.options?.map(E=>({optionId:E.optionId,kind:E.kind,name:E.name}))}),this.upstream.send(en(c,"session/request_permission",b)).catch(E=>{this.pendingUpstream.delete(c),M.error("forward permission request failed",{agentId:e.agentId,err:String(E)}),s.respondAgentRequestError(o.id,{code:H.INTERNAL_ERROR,message:`upstream send failed: ${String(E)}`})})}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?(M.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"&&Eu(e.result,c),M.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 Fn(e.error)):o.value.resolve(e.result);return}M.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 M.warn(`${o} id type mismatch: number received but Bridge expected string`,{rawId:s,normalizedId:d}),{value:u,key:d}}}sendRequest(e,s,o=_u){let c=this.upstreamIds.next(e);return new Promise((d,u)=>{let f=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:f}),this.upstream.send(en(c,e,s)).catch(h=>{let p=this.pendingBridge.get(c);p&&(clearTimeout(p.timer),this.pendingBridge.delete(c)),u(h)})})}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 $r(e.agentId,s,this.paths)}catch(s){M.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(ot(e,{code:s,message:o,data:{bridgeVersion:st}}))}};function Su(){return wu(16).toString("hex")}function Eu(n,e){if(!n||typeof n!="object"){M.warn("permission response: result not an object (suspicious)",{agentId:e.agentId,result:n});return}let s=n;if("kind"in s&&!("outcome"in s)){M.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"){M.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")&&M.warn("permission response: unknown outcome discriminant",{agentId:e.agentId,outcomeValue:d,result:n})}function Iu(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 `")}q();ie();import{randomBytes as Au}from"node:crypto";import{chmod as Tu,mkdir as Pu,writeFile as Uo}from"node:fs/promises";import{createServer as Cu}from"node:http";import{dirname as ku}from"node:path";var Du=1e6,di=N("ipc"),Xn=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??G()}async start(){this.token=Au(32).toString("hex");let e=Cu((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(),di.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 Pu(ku(this.paths.portFile),{recursive:!0}),await Uo(this.paths.portFile,String(this.port),"utf8"),await Uo(this.paths.tokenFile,this.token,{encoding:"utf8",mode:384});try{await Tu(this.paths.tokenFile,384)}catch(e){di.warn("chmod token file failed (non-POSIX?)",{err:String(e)})}}async dispatch(e,s){if(e.headers.authorization!==`Bearer ${this.token}`){cn(s,401,{error:"unauthorized"});return}let c=`${e.method} ${(e.url??"").split("?")[0]}`,d=this.routes.get(c);if(!d){cn(s,404,{error:"not found"});return}let u=null;if(e.method==="POST")try{u=await Ru(e)}catch(f){cn(s,400,{error:"invalid json",detail:String(f)});return}try{let f=await d.handler(u,e);cn(s,200,f??{ok:!0})}catch(f){di.error("IPC handler failed",{key:c,err:String(f)}),cn(s,500,{error:f instanceof Error?f.message:String(f)})}}};function cn(n,e,s){n.statusCode=e,n.setHeader("content-type","application/json"),n.end(JSON.stringify(s))}async function Ru(n){let e=[],s=0;for await(let c of n){let d=c;if(s+=d.length,s>Du)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 qo}from"node:path";import{fileURLToPath as Nu}from"node:url";function Go(){return Ou(Nu(import.meta.url))}function Ou(n){let e=`${qo}src${qo}`;return n.includes(e)}q();ie();import{spawn as Lu}from"node:child_process";import{existsSync as Mu,mkdirSync as Bu,openSync as zu}from"node:fs";import{dirname as Fu}from"node:path";import{fileURLToPath as Uu}from"node:url";var qu=N("spawn-helper");function Gu(n){return Mu(n.libEntry)?n.libEntry:Uu(new URL("../index.ts",import.meta.url))}function Hu(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 Ho(n,e,s={}){let o=s.paths??G(),c=Gu(o);Bu(Fu(o.logFile),{recursive:!0});let d=zu(o.logFile,"a"),u=Hu(c,n,e),f=Lu(process.execPath,u,{detached:!0,stdio:["ignore",d,d],env:{...process.env,COZE_BRIDGE_UPGRADE_HELPER:"1"}});if(f.unref(),typeof f.pid!="number")throw new Error("failed to spawn upgrade helper (no pid)");qu.info("upgrade helper spawned",{pid:f.pid,targetVersion:n,oldPid:e,entry:c})}q();import{mkdir as ju,writeFile as Ku}from"node:fs/promises";import{dirname as Wu}from"node:path";import{gunzipSync as Ju}from"node:zlib";var xi=N("tarball-downloader"),$u="https://registry.npmjs.org",jo="package/dist/index.js";async function Ko(n,e,s={}){if(!/^[\w.\-+]+$/.test(n))throw new Error(`invalid version string: ${JSON.stringify(n)}`);let c=`${(s.registry??$u).replace(/\/+$/,"")}/coze-bridge/${n}`;xi.info("fetching tarball metadata",{metaUrl:c});let d=await fetch(c);if(!d.ok)throw new Error(`registry metadata ${c} returned ${d.status}`);let f=(await d.json())?.dist?.tarball;if(!f)throw new Error(`registry metadata missing dist.tarball for ${n}`);xi.info("downloading tarball",{tarballUrl:f});let h=await fetch(f);if(!h.ok)throw new Error(`tarball ${f} returned ${h.status}`);let p=Buffer.from(await h.arrayBuffer()),w=Ju(p),b=Vu(w,jo);if(!b)throw new Error(`tarball missing entry ${jo}`);await ju(Wu(e),{recursive:!0}),await Ku(e,b),xi.info("dist extracted",{destPath:e,bytes:b.length})}function Vu(n,e){let s=0;for(;s+512<=n.length;){let o=n.subarray(s,s+512);if(o.every(w=>w===0))return null;let c=o.subarray(0,100),d=c.indexOf(0),u=c.subarray(0,d===-1?100:d).toString("utf8"),f=o.subarray(124,136).toString("ascii").trim().replace(/\0/g,""),h=Number.parseInt(f,8)||0,p=s+512;if(u===e)return n.subarray(p,p+h);s=p+Math.ceil(h/512)*512}return null}Mt();q();import{resolve as Yu}from"node:path";var lt=N("upgrade-manager"),Xu=300*1e3,Qu=3,Qn=class{constructor(e){this.opts=e}opts;inFlightTarget=null;async requestUpgrade(e){if(this.inFlightTarget===e){lt.debug("upgrade already in-flight, skip",{targetVersion:e});return}this.inFlightTarget=e;try{let s=await ct(this.opts.paths.configFile)??{};if(s.disableAutoUpgrade){lt.info("disableAutoUpgrade=true, skip",{targetVersion:e});return}if(this.opts.isDevMode()){lt.warn("dev mode, skip auto-upgrade",{targetVersion:e});return}if(!$n(this.opts.currentVersion,e)){lt.debug("local version >= target, skip",{local:this.opts.currentVersion,target:e});return}let o=s.upgradeAttempts?.[e];if((o?.count??0)>=Qu){lt.warn("upgrade attempts cap reached, skip",{targetVersion:e,count:o?.count});return}let c=Yu(this.opts.paths.libDir,"index.js.next");try{await this.opts.download(e,c)}catch(u){await this.recordAttempt(s,e,String(u)),lt.warn("download failed, attempt recorded",{targetVersion:e,err:String(u)});return}this.opts.daemon.markUpgradePending(e);let d=await this.opts.daemon.waitIdle(Xu);lt.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 Ue(e,this.opts.paths.configFile)}};var lc=We(na(),1);var Nl=We(Xa(),1),Ol=We(gr(),1),Ll=We(Ft(),1),Ml=We(Si(),1),Bl=We(Ai(),1),zl=We(Ri(),1),oc=We(wr(),1),Fl=We(sc(),1);var ac=oc.default;q();var fe=N("upstream.frontier"),dc="application/json",xc="none",ql=15e3,mn=class{constructor(e){this.opts=e}opts;fws=null;handler=null;connectHandlers=[];opened=!1;openCount=0;async start(){if(this.fws){fe.warn("start called on already-started FrontierUpstream; noop");return}let e={Authorization:`Bearer ${this.opts.privatecode}`,Origin:zs,...kt(this.opts.ppeOverride)};class s extends ac{constructor(A){super(A,Bs,{headers:e})}send(A,...k){if(_s("debug"))try{let z;typeof A=="string"?z=Buffer.from(A,"utf8"):A instanceof Buffer?z=A:A instanceof ArrayBuffer?z=new Uint8Array(A):ArrayBuffer.isView(A)?z=new Uint8Array(A.buffer,A.byteOffset,A.byteLength):z=new Uint8Array(0);let Y=Buffer.from(z.slice(0,128)).toString("hex");fe.debug("WS raw frame out",{bytes:z.byteLength,headHex:Y})}catch(z){fe.warn("WS raw frame dump failed",{err:String(z)})}super.send(A,...k)}}let o=Us(this.opts.urlOverride),c={url:o,ws:s,fpID:Ms,aID:Ln,accessKey:this.opts.handshake.accessKey,deviceID:this.opts.handshake.deviceId,payloadType:{type:dc,force:!0},payloadEncoding:{encoding:xc,force:!0},enableTransformTextPayload:!0,enableQoS:!1,enableAutoAck:!1,automaticOpen:!1,maxRetries:Number.POSITIVE_INFINITY,debug:this.opts.debug??!1},d=new lc.FWS(c),u=!1,f=null,h,p,w=new Promise((I,A)=>{h=I,p=A}),b=I=>{u||(u=!0,f&&(clearTimeout(f),f=null),I?p(I):h())};d.onopen=()=>{this.opened=!0,this.openCount+=1;let I=this.openCount===1;fe.info("frontier opened",{url:o,remoteDeviceId:this.opts.handshake.deviceId,initial:I,openCount:this.openCount}),I&&b();for(let A of this.connectHandlers)Promise.resolve(A({initial:I})).catch(k=>fe.warn("onConnect handler threw (ignored)",{err:String(k)}))},d.onclose=I=>{this.opened=!1,fe.info("frontier closed",{code:I.code,reason:I.reason,willReconnect:I.willReconnect})},d.onerror=I=>{fe.warn("frontier error",{code:I.code,msg:I.message}),b(new S("UPSTREAM_DISCONNECTED",`frontier connect error before open: code=${I.code} msg=${I.message??""}`))},d.onmessage=I=>this.handleMessage(I),this.fws=d;let E=this.opts.openTimeoutMs??ql;f=setTimeout(()=>{b(new S("UPSTREAM_DISCONNECTED",`frontier ws open timeout after ${E}ms (handshake or upgrade slow)`))},E),await d.connect();try{await w}catch(I){try{d.close(1e3,"open failed")}catch(A){fe.warn("fws close during start failure threw (ignored)",{err:String(A)})}throw this.fws=null,this.opened=!1,I}}async stop(e){let s=this.fws;if(s){this.fws=null,this.opened=!1;try{s.close(1e3,e??"bridge shutdown")}catch(o){fe.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;uc(c)||fe.info("frontier frame out",{method:c.method,jsonrpcId:c.id,size:o.length});try{await s.send(o,{service:33555712,method:1,payloadType:dc,payloadEncoding:xc})}catch(u){throw fe.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){fe.debug("drop non-adapter frontier frame",{service:s});return}let o=jl(e);if(!o){fe.debug("frontier message without text payload, drop",{payloadType:e.message?.payloadType});return}if(!this.handler){fe.debug("frame received but no onFrame handler",{size:o.length});return}let c;try{c=JSON.parse(o)}catch(u){fe.warn("frontier message JSON parse failed",{err:String(u),head:o.slice(0,80)});return}let d=c;uc(d)||fe.info("frontier frame in",{logid:Hl(e.message?.LogID),logidNew:e.message?.LogIDNew,msgId:e.message?.msgID,jsonrpcId:d.id,method:d.method,body:Gl(o)}),Promise.resolve(this.handler(c)).catch(u=>fe.warn("frontier frame handler threw",{err:String(u)}))}};function uc(n){return n.method==="_agent/health"?!0:typeof n.id=="string"&&n.id.startsWith("agent.health_")}var fc=2e3;function Gl(n){return n.length<=fc?n:`${n.slice(0,fc)}...<truncated, total ${n.length} chars>`}function Hl(n){return n?n.high===0?String(n.low>>>0):`${n.high.toString(16)}${(n.low>>>0).toString(16).padStart(8,"0")}`:""}function jl(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}}q();var Oi=N("upstream.switchable"),yr=class{inner;handler=null;connectHandlers=[];constructor(e){this.inner=e}async swap(e,s){if(this.inner===e)return;Oi.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 Oi.error("swap target start failed, reverting",{err:String(c)}),this.inner=o,c}await o.stop(s??"swapped").catch(c=>Oi.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()}};q();var Li=N("upstream"),Kt=class{handler=null;async start(){Li.info("NoopUpstream started (M1 skeleton; real Frontier wired in M4)")}async stop(e){Li.info("NoopUpstream stopped",{reason:e})}async send(e){Li.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)}};q();q();ie();import{promises as Mi}from"node:fs";import{dirname as Kl}from"node:path";var Wl=N("pat-token-store");async function gc(n=G()){try{let s=(await Mi.readFile(n.patTokenFile,"utf8")).trim();return s.length>0?s:null}catch(e){return e?.code!=="ENOENT"&&Wl.warn("read pat-token failed (treating as missing)",{err:String(e)}),null}}async function wn(n,e=G()){if(!n)throw new Error("writePatToken: empty patToken");await Mi.mkdir(Kl(e.patTokenFile),{recursive:!0}),await Mi.writeFile(e.patTokenFile,n,{encoding:"utf8",mode:384})}ie();ie();import{promises as br}from"node:fs";import{join as Jl}from"node:path";function $l(n){return`#!/bin/sh
|
|
124
124
|
exec node ${JSON.stringify(n)} "$@"
|
|
125
125
|
`}function Vl(n){return`@echo off
|
|
126
126
|
node ${JSON.stringify(n)} %*
|
|
127
|
-
`}async function wc(n,e=q()){let i=e.binDir;await Pr.mkdir(i,{recursive:!0});let o=$l(i,process.platform==="win32"?"coze-bridge.cmd":"coze-bridge"),a=process.platform==="win32"?Vl(n):Jl(n);return await Pr.readFile(o,"utf8").catch(()=>null)===a||(await Pr.writeFile(o,a,"utf8"),process.platform!=="win32"&&await Pr.chmod(o,493)),i}U();ae();import{execSync as yc}from"node:child_process";import{readFileSync as bc,unlinkSync as Yl}from"node:fs";import{mkdir as Xl,readFile as vc,unlink as Sc,writeFile as Zl}from"node:fs/promises";import{dirname as Ql}from"node:path";function _c(n){try{return process.kill(n,0),!0}catch(e){return e.code==="EPERM"}}var eg=D("single-instance"),Cr=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&&(eg.warn("removing stale pid file",{stalePid:e}),await Sc(this.pidFile).catch(()=>{})),await Xl(Ql(this.pidFile),{recursive:!0}),await Zl(this.pidFile,String(process.pid),"utf8"),this.acquired=!0,this.installCleanupHooks(),{kind:"acquired"})}async release(){if(this.acquired){try{(await vc(this.pidFile,"utf8")).trim()===String(process.pid)&&await Sc(this.pidFile)}catch{}this.acquired=!1}}async readExistingPid(){try{let e=await vc(this.pidFile,"utf8"),i=Number.parseInt(e.trim(),10);return Number.isFinite(i)&&i>0?i:null}catch(e){if(e.code==="ENOENT")return null;throw e}}isAlive(e){return _c(e)?this.matchesDaemonTitle(e):!1}matchesDaemonTitle(e){if(process.platform==="win32")return this.matchesDaemonTitleWindows(e);try{let i=bc(`/proc/${e}/cmdline`,"utf8").replace(/\0/g," ");return!!(i.includes("coze-bridge-daemon")||i.includes("lib/index.js"))}catch{}try{let i=yc(`ps -o command= -p ${e}`,{stdio:["ignore","pipe","ignore"],timeout:1e3}).toString();return i.trim()?i.includes("coze-bridge-daemon")||i.includes("lib/index.js"):!1}catch{return!0}}matchesDaemonTitleWindows(e){try{let o=yc(`tasklist /FI "PID eq ${e}" /FO CSV /NH`,{stdio:["ignore","pipe","ignore"],timeout:2e3}).toString().trim();if(!o||o.startsWith("INFO:"))return!1;let a=o.split(",",1)[0]?.replace(/^"|"$/g,"").toLowerCase()??"";return a.includes("node")||a.includes("coze-bridge")}catch{return!0}}installCleanupHooks(){process.once("exit",()=>{if(this.acquired)try{bc(this.pidFile,"utf8").trim()===String(process.pid)&&Yl(this.pidFile)}catch{}})}};function tg(){let n=0,e=null;return{incActive(){n++},decActive(){n>0&&n--},activeCount(){return n},markUpgradePending(i){e=i},isUpgrading(){return e!==null},pendingTarget(){return e},async waitIdle(i){let o=Date.now()+i;for(;Date.now()<o;){if(n===0)return"idle";await new Promise(a=>setTimeout(a,200))}return n===0?"idle":"timeout"}}}var L=D("daemon"),ng="coze-bridge-daemon";async function Ic(){let n=new Cr({processTitle:ng}),e=await n.acquire();if(e.kind==="already-running")throw new Error(`coze-bridge daemon already running (pid=${e.pid})`);let i=await gt(),o=i??{};Tn({pid:process.pid}),L.info(i?"loaded bridge config":"initialized bridge config");try{let P=new Ht;o.frameworksCache=await P.detectAll(),L.info("refreshed frameworks_cache",{detected:Object.keys(o.frameworksCache)})}catch(P){L.warn("framework detection failed",{err:String(P)})}await He(o);let a=new Ar(new Qt),x=q(),u=tg(),f=null,g=new nr({upstream:a,paths:x,bridgeConfig:o,upgradeGate:u,sessionSpawner:async(P,O,F,Se)=>{if(!f)throw new Error("agentManager not ready");return f.spawnSessionDownstream(P,O,F,Se)}});await ig(x,g);let m=new Qn({paths:x,config:o,registry:g});f=m;let y,_,S=null,E={},A,T=null,z=null;g.registerExtension("_agent/create",async P=>m.createAgent(P.params)),g.registerExtension("_agent/health",async()=>({ok:!0}));let Z={},K=new Hn({agents:g.agents,disposeAndMarkDisconnected:async(P,O)=>{let F=g.agents.get(P);if(F){await m.cleanupOpenclawSessionProviders(F).catch(te=>L.warn("cleanup openclaw providers failed (ignored)",{agentId:P,err:String(te)}));let Se=!0;try{await F.dispose(`disconnect: ${O}`)}catch(te){Se=!1,L.error("dispose during disconnect FAILED, leaving agent in error state",{agentId:P,err:String(te)}),F.status="error"}Se&&(F.status="disconnected",g.unregister(P),g.disconnectedAgents.add(P))}else g.disconnectedAgents.add(P)},detailSyncer:async P=>{if(!Z.ref)throw new Error("agent-detail-sync not initialized yet");await Z.ref.syncOne(P)},cleanupOpenclawProviders:async P=>{await m.cleanupOpenclawSessionProviders(P)},openclawRepair:async(P,O)=>{await m.openclawRepair(P,O)},isRuntimePendingPermission:P=>g.hasPendingPermissionFor(P)});g.registerExtension("_agent/listSkills",P=>K.listSkills(P.params)),g.registerExtension("_agent/addSkills",P=>K.addSkills(P.params)),g.registerExtension("_agent/removeSkills",P=>K.removeSkills(P.params)),g.registerExtension("_agent/getFileTree",P=>K.getFileTree(P.params)),g.registerExtension("_agent/getFileContent",P=>K.getFileContent(P.params)),g.registerExtension("_agent/update",P=>K.updateAgent(P.params)),g.registerExtension("_agent/disconnect",P=>K.disconnectAgent(P.params)),g.registerExtension("_agent/switchModel",P=>K.switchModel(P.params)),g.registerExtension("_agent/reset",P=>K.resetAgent(P.params)),g.registerExtension("_agent/repair",P=>K.repairAgent(P.params));let ce=new zn({paths:x,handlers:K,sendDetail:P=>g.sendRequest("_agent/detail",P)});Z.ref=ce;let J=async P=>{await Promise.allSettled(P.map(async O=>{try{await K.disconnectAgent({agentId:O.agentId,reason:`auth_failure: code=${O.code} ${O.message}`}),L.info("agent disconnected due to auth failure from heartbeat response",{agentId:O.agentId,code:O.code,message:O.message})}catch(F){L.warn("disconnect during authFailure handling failed (ignored)",{agentId:O.agentId,err:String(F)})}}))};a.onConnect(({initial:P})=>{L.info("frontier upstream connected, triggering detail sync",{initial:P}),ce.syncAll(P?"initial-connect":"reconnect").catch(O=>L.warn("detail sync top-level error (ignored)",{err:String(O)}))});let _e=new rr({paths:x,routes:[{method:"GET",path:"/status",handler:async()=>({running:!0,pid:process.pid,agents:[...g.agents.keys()],deviceId:S??"",frameworksCache:o.frameworksCache??{}})},{method:"POST",path:"/pair",handler:async P=>{let O=P,F=O?.privatecode,Se=O?.pairing_code;if(!F||!Se)throw new v("IPC_BAD_REQUEST","/pair requires privatecode + pairing_code");let te=sn(O.env),he=O.handshake_url,Je=O.frontier_url,se=Ec(O.env,he,Je),it=!!y&&y!==F,ee=_!==void 0&&_!==se,X=it||ee,mt=await ei({privatecode:F,...he?{endpoint:he}:{},ppeOverride:te});if(X){L.warn("pair config switched, resetting agents",{pcChanged:it,envChanged:ee,previousPc:y?Tr(y):"",nextPc:Tr(F),previousEnvKey:_??"",nextEnvKey:se});for(let oe of[...g.agents.values()])await oe.dispose("pair config switch").catch(()=>{}),g.agents.delete(oe.agentId);g.disconnectedAgents.size>0&&(L.info("clearing disconnectedAgents set on pair config switch",{count:g.disconnectedAgents.size}),g.disconnectedAgents.clear()),await a.swap(new Qt,"pair switch").catch(()=>{})}S=mt.deviceId,Tn({deviceId:S,pid:process.pid}),ui({patToken:F,env:O.env}).catch(oe=>L.warn("coze-cli setup error (ignored)",{err:String(oe)}));let V=new En({handshake:mt,privatecode:F,...Je?{urlOverride:Je}:{},ppeOverride:te,getPatTokenForAgent:oe=>g.agents.get(oe)?.patToken});await a.swap(V,"pair");try{let oe=new Ht;o.frameworksCache=await oe.detectAll(),await He(o),L.info("frameworks_cache refreshed before pair",{detected:Object.keys(o.frameworksCache)})}catch(oe){L.warn("frameworks_cache refresh failed (ignored, using cached)",{err:String(oe)})}let At=Object.keys(o.frameworksCache??{});try{let oe=await g.sendRequest("_agent/pair",{pairCode:Se,patToken:F,frameworks:At,_meta:{cozeDeviceId:S}});L.info("_agent/pair ok",{pairResult:oe}),y=F,_=se,E=te,A=he,In(F,x).catch(be=>L.warn("writePatToken after /pair failed (ignored)",{err:String(be)})),T||(T=new an({core:g,getDeviceId:()=>S??"",onTickEnd:()=>ce.retryPending().catch(be=>L.warn("detailSync.retryPending failed (ignored)",{err:String(be)})),onAuthFailures:J,onMinBridgeVersion:be=>z?.requestUpgrade(be)})),T.start(),X&&kr(x,m).catch(be=>L.warn("post-pair-switch auto-revive error (ignored)",{err:String(be)}));let Pt;return O.agent_id&&(Pt=await sg(O.agent_id,x,m,be=>g.sendRequest("_agent/detail",be),F).catch(be=>(L.error("--agent-id ensureAgent failed",{agentId:O.agent_id,err:String(be)}),{ok:!1,agentId:O.agent_id??"",note:String(be)}))),{ok:!0,note:"paired with cloud",...Pt?{agent:Pt}:{}}}catch(oe){return L.error("_agent/pair failed",{err:String(oe)}),{ok:!1,note:`pair failed: ${String(oe)}`}}}},{method:"POST",path:"/connect",handler:async P=>{let O=P,F=O?.privatecode;if(!F)throw new v("IPC_BAD_REQUEST","/connect requires privatecode");let Se=sn(O.env),te=O.handshake_url,he=O.frontier_url,Je=Ec(O.env,te,he);if(y===F&&_===Je){let V=await rg(x);return g.agents.size===0&&V?(L.warn("/connect noop but core.agents empty with configs on disk; re-running auto-revive"),kr(x,m).catch(At=>L.warn("connect-noop auto-revive error (ignored)",{err:String(At)}))):L.info("/connect: already connected with same PAT + env, noop"),{ok:!0,note:"already connected"}}let se=!!y&&y!==F,it=_!==void 0&&_!==Je,ee=se||it,X=await ei({privatecode:F,...te?{endpoint:te}:{},ppeOverride:Se});if(ee){L.warn("connect config switched, resetting agents",{pcChanged:se,envChanged:it,previousPc:y?Tr(y):"",nextPc:Tr(F)});for(let V of[...g.agents.values()])await V.dispose("connect config switch").catch(()=>{}),g.agents.delete(V.agentId);g.disconnectedAgents.size>0&&(L.info("clearing disconnectedAgents set on connect config switch",{count:g.disconnectedAgents.size}),g.disconnectedAgents.clear()),await a.swap(new Qt,"connect switch").catch(()=>{})}S=X.deviceId,Tn({deviceId:S,pid:process.pid}),ui({patToken:F,env:O.env}).catch(V=>L.warn("coze-cli setup error (ignored)",{err:String(V)}));let mt=new En({handshake:X,privatecode:F,...he?{urlOverride:he}:{},ppeOverride:Se,getPatTokenForAgent:V=>g.agents.get(V)?.patToken});return await a.swap(mt,"connect"),y=F,_=Je,E=Se,A=te,T||(T=new an({core:g,getDeviceId:()=>S??"",onTickEnd:()=>ce.retryPending().catch(V=>L.warn("detailSync.retryPending failed (ignored)",{err:String(V)})),onAuthFailures:J,onMinBridgeVersion:V=>z?.requestUpgrade(V)})),T.start(),ee&&kr(x,m).catch(V=>L.warn("post-connect-switch auto-revive error (ignored)",{err:String(V)})),In(F,x).catch(V=>L.warn("writePatToken after /connect failed (ignored)",{err:String(V)})),L.info("/connect: WS established",{deviceId:S}),{ok:!0,note:"connected"}}},{method:"POST",path:"/_agent/create",handler:async P=>{let O=P;return{ok:!0,result:await m.createAgent(O)}}},{method:"POST",path:"/agent/send",handler:async P=>{let O=P;if(!O?.agentId||!O?.sessionId||!O?.kind||!O?.path)throw new v("IPC_BAD_REQUEST","/agent/send requires agentId, sessionId, kind, path");if(!y)throw new v("UPSTREAM_NOT_READY","daemon not yet paired with cloud (run --pair-code first)");try{return await Io(O,{core:g,patToken:y,handshakeBase:A,ppeOverride:E})}catch(F){if(F instanceof v)return{ok:!1,code:F.code,message:F.message};throw F}}},{method:"POST",path:"/refresh",handler:async()=>{L.info("IPC /refresh: re-detecting frameworks");let P=new Ht;return o.frameworksCache=await P.detectAll(),await He(o),{ok:!0,frameworks:o.frameworksCache}}},{method:"POST",path:"/shutdown",handler:async()=>(L.info("IPC /shutdown received"),setImmediate(()=>{ue.shutdown("ipc /shutdown")}),{ok:!0})}]}),{port:ye,token:Ne}=await _e.start();try{await wc(x.libEntry,x)}catch(P){L.warn("bin shim install failed (D72 send \u547D\u4EE4\u53EF\u80FD\u4E0D\u53EF\u7528)",{err:String(P)})}await g.start(),kr(x,m).catch(P=>L.warn("auto-revive top-level error (ignored)",{err:String(P)})),Ps().catch(P=>L.warn("acp wrapper warmup top-level error (ignored)",{err:String(P)}));let ie=null,ue={port:ye,token:Ne,core:g,ipc:_e,shutdown(P){return ie||(L.info("daemon shutdown",{reason:P}),ie=(async()=>{T?.stop(),await g.stop(P),await _e.stop(),await n.release()})(),ie)}};z=new ir({paths:x,currentVersion:ut,isDevMode:jo,download:(P,O)=>Jo(P,O),spawnHelper:(P,O)=>Wo(P,O,{paths:x}),daemon:{markUpgradePending:P=>{L.warn("upgrade pending, ACP gate engaged",{target:P}),u.markUpgradePending(P)},waitIdle:P=>u.waitIdle(P),exit:P=>{ue.shutdown("upgrade").then(()=>process.exit(P))}}});for(let P of["SIGTERM","SIGINT"])process.on(P,()=>{ue.shutdown(P).then(()=>process.exit(0))});return L.info("daemon ready",{port:ye,pid:process.pid,nodeVersion:process.version,platform:process.platform,frameworks:Object.keys(o.frameworksCache??{}),libVersion:o.libVersion??"dev"}),ue}async function rg(n){let{readdir:e}=await import("node:fs/promises");try{return(await e(n.agentsRoot)).length>0}catch{return!1}}function Tr(n){return n.length<=8?"***":`${n.slice(0,4)}***${n.slice(-4)}`}function Ec(n,e,i){return`${n??""}|${e??""}|${i??""}`}async function ig(n,e){let{readdir:i}=await import("node:fs/promises"),o;try{o=await i(n.agentsRoot)}catch{return}let{loadAgentConfig:a,enforceAgentConfigMode:x}=await Promise.resolve().then(()=>(dt(),Bn));for(let u of o){await x(u,n).catch(f=>L.warn("enforceAgentConfigMode failed (ignored)",{agentId:u,err:String(f)}));try{let f=await a(u,n);f?.disconnectedAt&&(e.disconnectedAgents.add(u),L.info("agent marked disconnected on startup",{agentId:u,disconnectedAt:f.disconnectedAt,reason:f.disconnectReason??""}))}catch(f){L.warn("failed to load agent config on startup, skipping",{agentId:u,err:String(f)})}}}async function sg(n,e,i,o,a){let{loadAgentConfig:x}=await Promise.resolve().then(()=>(dt(),Bn)),u=await x(n,e);if(u){L.info("--agent-id: local config found, reconnecting",{agentId:n,framework:u.framework,hadDisconnect:!!u.disconnectedAt});let y={agentId:u.agentId,framework:u.framework,...u.cozeIdentity?{cozeIdentity:u.cozeIdentity}:{},...u.model?{model:u.model}:{},...a?{patToken:a}:{}};return await i.createAgent(y),{ok:!0,agentId:n,note:u.disconnectedAt?"revived from local config":"connected from local config"}}L.info("--agent-id: local config missing, pulling _agent/detail from cloud",{agentId:n});let f=await o({_meta:{cozeAgentId:n}});if(!f.framework)throw new v("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 g={agentId:f.agentId,framework:f.framework,...f.cozeIdentity?{cozeIdentity:f.cozeIdentity}:{},...f.model?{model:f.model}:{},...a?{patToken:a}:{},...f.deployType?{_meta:{cozeDeployType:f.deployType}}:{}};await i.createAgent(g);let m=f.deployType==="cloud"&&f.framework==="openclaw";return{ok:!0,agentId:n,note:m?"cloud agent acknowledged":"created from cloud detail"}}async function kr(n,e){let{readdir:i}=await import("node:fs/promises"),o;try{o=await i(n.agentsRoot)}catch{return{revived:0,skipped:0,total:0}}if(o.length===0)return{revived:0,skipped:0,total:0};let{loadAgentConfig:a}=await Promise.resolve().then(()=>(dt(),Bn));L.info("auto-revive: scanning local agents on startup",{count:o.length});let x=0,u=0;for(let f of o){let g;try{g=await a(f,n)}catch(m){L.warn("auto-revive: load config failed (skipping)",{agentId:f,err:String(m)}),u+=1;continue}if(!g){u+=1;continue}if(g.disconnectedAt){L.info("auto-revive: skip disconnected agent",{agentId:f,disconnectedAt:g.disconnectedAt}),u+=1;continue}try{L.info("auto-revive: re-registering agent (D44 no spawn)",{agentId:f,framework:g.framework});let m=og(g);await e.createAgent({agentId:g.agentId,framework:g.framework,...g.cozeIdentity?{cozeIdentity:g.cozeIdentity}:{},...g.model?{model:g.model}:{},...m?{_meta:m}:{}}),x+=1}catch(m){L.warn("auto-revive: createAgent failed (skipping)",{agentId:f,framework:g.framework,err:String(m)}),u+=1}}return L.info("auto-revive: done",{revived:x,skipped:u,total:o.length}),{revived:x,skipped:u,total:o.length}}function og(n){let e={};return n.deployType&&(e.cozeDeployType=n.deployType),n.accountId&&(e.cozeAccountId=n.accountId),Object.keys(e).length>0?e:void 0}Dr();Nr();U();ae();Kt();U();ae();import{copyFile as Pc,mkdir as pg,readFile as Gi,writeFile as mg}from"node:fs/promises";import{dirname as wg,resolve as Hi,sep as Or}from"node:path";import{fileURLToPath as _g}from"node:url";var Cc=D("dist-install");function yg(n){let e=_g(n),i=wg(e),o=`${Or}src${Or}`;if(i.includes(o)||i.endsWith(`${Or}src${Or}cli`))return null;let a=Hi(i,"index.js"),x=Hi(i,"..","package.json");return{dist:a,pkgJson:x}}async function Ki(n={}){let e=n.paths??q(),i=yg(import.meta.url),o=n.sourceDist??i?.dist,a=n.sourcePackageJson??i?.pkgJson;if(!o||!a)return{kind:"dev-mode-skip",reason:"running from src/(tsx loader);no dist/ to install"};let x;try{x=JSON.parse(await Gi(a,"utf8")).version??"unknown"}catch(_){return Cc.warn("cannot read source package.json,skip dist install",{err:String(_)}),{kind:"dev-mode-skip",reason:`package.json read failed: ${String(_)}`}}let u=await gt(e.configFile)??{},f=u.libVersion;if(f===x)try{return await Gi(e.libEntry),{kind:"already-current",libVersion:x}}catch{}await pg(e.libDir,{recursive:!0}),await Pc(o,e.libEntry),await Pc(`${o}.map`,`${e.libEntry}.map`).catch(()=>{});let g=Hi(e.libDir,"package.json"),m=`${JSON.stringify({type:"module"},null,2)}
|
|
128
|
-
`;return await
|
|
129
|
-
`),4;let o=await
|
|
130
|
-
`),4;let
|
|
131
|
-
`),4}if(!
|
|
132
|
-
`),Ig(
|
|
133
|
-
`);else{let u=n.name??bg(
|
|
134
|
-
`)}return 0}async function Ag(n,e,
|
|
127
|
+
`}async function hc(n,e=G()){let s=e.binDir;await br.mkdir(s,{recursive:!0});let o=Jl(s,process.platform==="win32"?"coze-bridge.cmd":"coze-bridge"),c=process.platform==="win32"?Vl(n):$l(n);return await br.readFile(o,"utf8").catch(()=>null)===c||(await br.writeFile(o,c,"utf8"),process.platform!=="win32"&&await br.chmod(o,493)),s}q();ie();import{execSync as mc}from"node:child_process";import{readFileSync as wc,unlinkSync as Yl}from"node:fs";import{mkdir as Xl,readFile as _c,unlink as yc,writeFile as Ql}from"node:fs/promises";import{dirname as Zl}from"node:path";function pc(n){try{return process.kill(n,0),!0}catch(e){return e.code==="EPERM"}}var eg=N("single-instance"),vr=class{pidFile;acquired=!1;constructor(e={}){this.pidFile=e.pidFile??G().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&&(eg.warn("removing stale pid file",{stalePid:e}),await yc(this.pidFile).catch(()=>{})),await Xl(Zl(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 _c(this.pidFile,"utf8")).trim()===String(process.pid)&&await yc(this.pidFile)}catch{}this.acquired=!1}}async readExistingPid(){try{let e=await _c(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 pc(e)?this.matchesDaemonTitle(e):!1}matchesDaemonTitle(e){if(process.platform==="win32")return this.matchesDaemonTitleWindows(e);try{let s=wc(`/proc/${e}/cmdline`,"utf8").replace(/\0/g," ");return!!(s.includes("coze-bridge-daemon")||s.includes("lib/index.js"))}catch{}try{let s=mc(`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=mc(`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{wc(this.pidFile,"utf8").trim()===String(process.pid)&&Yl(this.pidFile)}catch{}})}};function tg(){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 L=N("daemon"),ng="coze-bridge-daemon";async function vc(){let n=new vr({processTitle:ng}),e=await n.acquire();if(e.kind==="already-running")throw new Error(`coze-bridge daemon already running (pid=${e.pid})`);let s=await ct(),o=s??{};Sn({pid:process.pid}),L.info(s?"loaded bridge config":"initialized bridge config");try{let T=new Lt;o.frameworksCache=await T.detectAll(),L.info("refreshed frameworks_cache",{detected:Object.keys(o.frameworksCache)})}catch(T){L.warn("framework detection failed",{err:String(T)})}await Ue(o);let c=new yr(new Kt),d=G(),u=tg(),f=null,h=new Yn({upstream:c,paths:d,bridgeConfig:o,upgradeGate:u,sessionSpawner:async(T,O,B,ve)=>{if(!f)throw new Error("agentManager not ready");return f.spawnSessionDownstream(T,O,B,ve)}});await ig(d,h);let p=new Jn({paths:d,config:o,registry:h});f=p;let w,b,E=null,I={},A,k=null,z=null;h.registerExtension("_agent/create",async T=>p.createAgent(T.params)),h.registerExtension("_agent/health",async()=>({ok:!0}));let Y={},j=new Bn({agents:h.agents,disposeAndMarkDisconnected:async(T,O)=>{let B=h.agents.get(T);if(B){await p.cleanupOpenclawSessionProviders(B).catch(Q=>L.warn("cleanup openclaw providers failed (ignored)",{agentId:T,err:String(Q)}));let ve=!0;try{await B.dispose(`disconnect: ${O}`)}catch(Q){ve=!1,L.error("dispose during disconnect FAILED, leaving agent in error state",{agentId:T,err:String(Q)}),B.status="error"}ve&&(B.status="disconnected",h.unregister(T),h.disconnectedAgents.add(T))}else h.disconnectedAgents.add(T)},detailSyncer:async T=>{if(!Y.ref)throw new Error("agent-detail-sync not initialized yet");await Y.ref.syncOne(T)},cleanupOpenclawProviders:async T=>{await p.cleanupOpenclawSessionProviders(T)},openclawRepair:async(T,O)=>{await p.openclawRepair(T,O)},isRuntimePendingPermission:T=>h.hasPendingPermissionFor(T)});h.registerExtension("_agent/listSkills",T=>j.listSkills(T.params)),h.registerExtension("_agent/addSkills",T=>j.addSkills(T.params)),h.registerExtension("_agent/removeSkills",T=>j.removeSkills(T.params)),h.registerExtension("_agent/getFileTree",T=>j.getFileTree(T.params)),h.registerExtension("_agent/getFileContent",T=>j.getFileContent(T.params)),h.registerExtension("_agent/update",T=>j.updateAgent(T.params)),h.registerExtension("_agent/disconnect",T=>j.disconnectAgent(T.params)),h.registerExtension("_agent/switchModel",T=>j.switchModel(T.params)),h.registerExtension("_agent/reset",T=>j.resetAgent(T.params)),h.registerExtension("_agent/repair",T=>j.repairAgent(T.params));let oe=new Rn({paths:d,handlers:j,sendDetail:T=>h.sendRequest("_agent/detail",T)});Y.ref=oe;let W=async T=>{await Promise.allSettled(T.map(async O=>{try{await j.disconnectAgent({agentId:O.agentId,reason:`auth_failure: code=${O.code} ${O.message}`}),L.info("agent disconnected due to auth failure from heartbeat response",{agentId:O.agentId,code:O.code,message:O.message})}catch(B){L.warn("disconnect during authFailure handling failed (ignored)",{agentId:O.agentId,err:String(B)})}}))};c.onConnect(({initial:T})=>{L.info("frontier upstream connected, triggering detail sync",{initial:T}),oe.syncAll(T?"initial-connect":"reconnect").catch(O=>L.warn("detail sync top-level error (ignored)",{err:String(O)}))});let le=new Xn({paths:d,routes:[{method:"GET",path:"/status",handler:async()=>({running:!0,pid:process.pid,agents:[...h.agents.keys()],deviceId:E??"",frameworksCache:o.frameworksCache??{}})},{method:"POST",path:"/pair",handler:async T=>{let O=T,B=O?.privatecode,ve=O?.pairing_code;if(!B||!ve)throw new S("IPC_BAD_REQUEST","/pair requires privatecode + pairing_code");let Q=Xt(O.env),ge=O.handshake_url,Ke=O.frontier_url,ne=bc(O.env,ge,Ke),Ze=!!w&&w!==B,X=b!==void 0&&b!==ne,V=Ze||X,ut=await Yr({privatecode:B,...ge?{endpoint:ge}:{},ppeOverride:Q});if(V){L.warn("pair config switched, resetting agents",{pcChanged:Ze,envChanged:X,previousPc:w?Sr(w):"",nextPc:Sr(B),previousEnvKey:b??"",nextEnvKey:ne});for(let re of[...h.agents.values()])await re.dispose("pair config switch").catch(()=>{}),h.agents.delete(re.agentId);h.disconnectedAgents.size>0&&(L.info("clearing disconnectedAgents set on pair config switch",{count:h.disconnectedAgents.size}),h.disconnectedAgents.clear()),await c.swap(new Kt,"pair switch").catch(()=>{})}E=ut.deviceId,Sn({deviceId:E,pid:process.pid}),ai({patToken:B,env:O.env}).catch(re=>L.warn("coze-cli setup error (ignored)",{err:String(re)}));let J=new mn({handshake:ut,privatecode:B,...Ke?{urlOverride:Ke}:{},ppeOverride:Q,getPatTokenForAgent:re=>h.agents.get(re)?.patToken});await c.swap(J,"pair");try{let re=new Lt;o.frameworksCache=await re.detectAll(),await Ue(o),L.info("frameworks_cache refreshed before pair",{detected:Object.keys(o.frameworksCache)})}catch(re){L.warn("frameworks_cache refresh failed (ignored, using cached)",{err:String(re)})}let _t=Object.keys(o.frameworksCache??{});try{let re=await h.sendRequest("_agent/pair",{pairCode:ve,patToken:B,frameworks:_t,_meta:{cozeDeviceId:E}});L.info("_agent/pair ok",{pairResult:re}),w=B,b=ne,I=Q,A=ge,wn(B,d).catch(ye=>L.warn("writePatToken after /pair failed (ignored)",{err:String(ye)})),k||(k=new Zt({core:h,getDeviceId:()=>E??"",onTickEnd:()=>oe.retryPending().catch(ye=>L.warn("detailSync.retryPending failed (ignored)",{err:String(ye)})),onAuthFailures:W,onMinBridgeVersion:ye=>z?.requestUpgrade(ye)})),k.start(),V&&Er(d,p).catch(ye=>L.warn("post-pair-switch auto-revive error (ignored)",{err:String(ye)}));let yt;return O.agent_id&&(yt=await sg(O.agent_id,d,p,ye=>h.sendRequest("_agent/detail",ye),B).catch(ye=>(L.error("--agent-id ensureAgent failed",{agentId:O.agent_id,err:String(ye)}),{ok:!1,agentId:O.agent_id??"",note:String(ye)}))),{ok:!0,note:"paired with cloud",...yt?{agent:yt}:{}}}catch(re){return L.error("_agent/pair failed",{err:String(re)}),{ok:!1,note:`pair failed: ${String(re)}`}}}},{method:"POST",path:"/connect",handler:async T=>{let O=T,B=O?.privatecode;if(!B)throw new S("IPC_BAD_REQUEST","/connect requires privatecode");let ve=Xt(O.env),Q=O.handshake_url,ge=O.frontier_url,Ke=bc(O.env,Q,ge);if(w===B&&b===Ke){let J=await rg(d);return h.agents.size===0&&J?(L.warn("/connect noop but core.agents empty with configs on disk; re-running auto-revive"),Er(d,p).catch(_t=>L.warn("connect-noop auto-revive error (ignored)",{err:String(_t)}))):L.info("/connect: already connected with same PAT + env, noop"),{ok:!0,note:"already connected"}}let ne=!!w&&w!==B,Ze=b!==void 0&&b!==Ke,X=ne||Ze,V=await Yr({privatecode:B,...Q?{endpoint:Q}:{},ppeOverride:ve});if(X){L.warn("connect config switched, resetting agents",{pcChanged:ne,envChanged:Ze,previousPc:w?Sr(w):"",nextPc:Sr(B)});for(let J of[...h.agents.values()])await J.dispose("connect config switch").catch(()=>{}),h.agents.delete(J.agentId);h.disconnectedAgents.size>0&&(L.info("clearing disconnectedAgents set on connect config switch",{count:h.disconnectedAgents.size}),h.disconnectedAgents.clear()),await c.swap(new Kt,"connect switch").catch(()=>{})}E=V.deviceId,Sn({deviceId:E,pid:process.pid}),ai({patToken:B,env:O.env}).catch(J=>L.warn("coze-cli setup error (ignored)",{err:String(J)}));let ut=new mn({handshake:V,privatecode:B,...ge?{urlOverride:ge}:{},ppeOverride:ve,getPatTokenForAgent:J=>h.agents.get(J)?.patToken});return await c.swap(ut,"connect"),w=B,b=Ke,I=ve,A=Q,k||(k=new Zt({core:h,getDeviceId:()=>E??"",onTickEnd:()=>oe.retryPending().catch(J=>L.warn("detailSync.retryPending failed (ignored)",{err:String(J)})),onAuthFailures:W,onMinBridgeVersion:J=>z?.requestUpgrade(J)})),k.start(),X&&Er(d,p).catch(J=>L.warn("post-connect-switch auto-revive error (ignored)",{err:String(J)})),wn(B,d).catch(J=>L.warn("writePatToken after /connect failed (ignored)",{err:String(J)})),L.info("/connect: WS established",{deviceId:E}),{ok:!0,note:"connected"}}},{method:"POST",path:"/_agent/create",handler:async T=>{let O=T;return{ok:!0,result:await p.createAgent(O)}}},{method:"POST",path:"/agent/send",handler:async T=>{let O=T;if(!O?.agentId||!O?.sessionId||!O?.kind||!O?.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 vo(O,{core:h,patToken:w,handshakeBase:A,ppeOverride:I})}catch(B){if(B instanceof S)return{ok:!1,code:B.code,message:B.message};throw B}}},{method:"POST",path:"/refresh",handler:async()=>{L.info("IPC /refresh: re-detecting frameworks");let T=new Lt;return o.frameworksCache=await T.detectAll(),await Ue(o),{ok:!0,frameworks:o.frameworksCache}}},{method:"POST",path:"/shutdown",handler:async()=>(L.info("IPC /shutdown received"),setImmediate(()=>{we.shutdown("ipc /shutdown")}),{ok:!0})}]}),{port:_e,token:ke}=await le.start();try{await hc(d.libEntry,d)}catch(T){L.warn("bin shim install failed (D72 send \u547D\u4EE4\u53EF\u80FD\u4E0D\u53EF\u7528)",{err:String(T)})}await h.start(),Er(d,p).catch(T=>L.warn("auto-revive top-level error (ignored)",{err:String(T)})),Es().catch(T=>L.warn("acp wrapper warmup top-level error (ignored)",{err:String(T)}));let xe=null,we={port:_e,token:ke,core:h,ipc:le,shutdown(T){return xe||(L.info("daemon shutdown",{reason:T}),xe=(async()=>{k?.stop(),await h.stop(T),await le.stop(),await n.release()})(),xe)}};z=new Qn({paths:d,currentVersion:st,isDevMode:Go,download:(T,O)=>Ko(T,O),spawnHelper:(T,O)=>Ho(T,O,{paths:d}),daemon:{markUpgradePending:T=>{L.warn("upgrade pending, ACP gate engaged",{target:T}),u.markUpgradePending(T)},waitIdle:T=>u.waitIdle(T),exit:T=>{we.shutdown("upgrade").then(()=>process.exit(T))}}});for(let T of["SIGTERM","SIGINT"])process.on(T,()=>{we.shutdown(T).then(()=>process.exit(0))});return L.info("daemon ready",{port:_e,pid:process.pid,nodeVersion:process.version,platform:process.platform,frameworks:Object.keys(o.frameworksCache??{}),libVersion:o.libVersion??"dev"}),we}async function rg(n){let{readdir:e}=await import("node:fs/promises");try{return(await e(n.agentsRoot)).length>0}catch{return!1}}function Sr(n){return n.length<=8?"***":`${n.slice(0,4)}***${n.slice(-4)}`}function bc(n,e,s){return`${n??""}|${e??""}|${s??""}`}async function ig(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(()=>(it(),Dn));for(let u of o){await d(u,n).catch(f=>L.warn("enforceAgentConfigMode failed (ignored)",{agentId:u,err:String(f)}));try{let f=await c(u,n);f?.disconnectedAt&&(e.disconnectedAgents.add(u),L.info("agent marked disconnected on startup",{agentId:u,disconnectedAt:f.disconnectedAt,reason:f.disconnectReason??""}))}catch(f){L.warn("failed to load agent config on startup, skipping",{agentId:u,err:String(f)})}}}async function sg(n,e,s,o,c){let{loadAgentConfig:d}=await Promise.resolve().then(()=>(it(),Dn)),u=await d(n,e);if(u){L.info("--agent-id: local config found, reconnecting",{agentId:n,framework:u.framework,hadDisconnect:!!u.disconnectedAt});let w={agentId:u.agentId,framework:u.framework,...u.cozeIdentity?{cozeIdentity:u.cozeIdentity}:{},...u.model?{model:u.model}:{},...c?{patToken:c}:{}};return await s.createAgent(w),{ok:!0,agentId:n,note:u.disconnectedAt?"revived from local config":"connected from local config"}}L.info("--agent-id: local config missing, pulling _agent/detail from cloud",{agentId:n});let f=await o({_meta:{cozeAgentId:n}});if(!f.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 h={agentId:f.agentId,framework:f.framework,...f.cozeIdentity?{cozeIdentity:f.cozeIdentity}:{},...f.model?{model:f.model}:{},...c?{patToken:c}:{},...f.deployType?{_meta:{cozeDeployType:f.deployType}}:{}};await s.createAgent(h);let p=f.deployType==="cloud"&&f.framework==="openclaw";return{ok:!0,agentId:n,note:p?"cloud agent acknowledged":"created from cloud detail"}}async function Er(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(()=>(it(),Dn));L.info("auto-revive: scanning local agents on startup",{count:o.length});let d=0,u=0;for(let f of o){let h;try{h=await c(f,n)}catch(p){L.warn("auto-revive: load config failed (skipping)",{agentId:f,err:String(p)}),u+=1;continue}if(!h){u+=1;continue}if(h.disconnectedAt){L.info("auto-revive: skip disconnected agent",{agentId:f,disconnectedAt:h.disconnectedAt}),u+=1;continue}try{L.info("auto-revive: re-registering agent (D44 no spawn)",{agentId:f,framework:h.framework});let p=og(h);await e.createAgent({agentId:h.agentId,framework:h.framework,...h.cozeIdentity?{cozeIdentity:h.cozeIdentity}:{},...h.model?{model:h.model}:{},...p?{_meta:p}:{}}),d+=1}catch(p){L.warn("auto-revive: createAgent failed (skipping)",{agentId:f,framework:h.framework,err:String(p)}),u+=1}}return L.info("auto-revive: done",{revived:d,skipped:u,total:o.length}),{revived:d,skipped:u,total:o.length}}function og(n){let e={};return n.deployType&&(e.cozeDeployType=n.deployType),n.accountId&&(e.cozeAccountId=n.accountId),Object.keys(e).length>0?e:void 0}Ir();Tr();q();ie();Mt();q();ie();import{copyFile as Ec,mkdir as pg,readFile as zi,writeFile as mg}from"node:fs/promises";import{dirname as wg,resolve as Fi,sep as Pr}from"node:path";import{fileURLToPath as _g}from"node:url";var Ic=N("dist-install");function yg(n){let e=_g(n),s=wg(e),o=`${Pr}src${Pr}`;if(s.includes(o)||s.endsWith(`${Pr}src${Pr}cli`))return null;let c=Fi(s,"index.js"),d=Fi(s,"..","package.json");return{dist:c,pkgJson:d}}async function Ui(n={}){let e=n.paths??G(),s=yg(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 zi(c,"utf8")).version??"unknown"}catch(b){return Ic.warn("cannot read source package.json,skip dist install",{err:String(b)}),{kind:"dev-mode-skip",reason:`package.json read failed: ${String(b)}`}}let u=await ct(e.configFile)??{},f=u.libVersion;if(f===d)try{return await zi(e.libEntry),{kind:"already-current",libVersion:d}}catch{}await pg(e.libDir,{recursive:!0}),await Ec(o,e.libEntry),await Ec(`${o}.map`,`${e.libEntry}.map`).catch(()=>{});let h=Fi(e.libDir,"package.json"),p=`${JSON.stringify({type:"module"},null,2)}
|
|
128
|
+
`;return await zi(h,"utf8").catch(()=>null)!==p&&await mg(h,p),u.libVersion=d,await Ue(u,e.configFile),Ic.info("dist installed",{libEntry:e.libEntry,fromVersion:f,toVersion:d}),f?{kind:"version-changed",fromVersion:f,toVersion:d,libEntry:e.libEntry}:{kind:"first-install",libVersion:d,libEntry:e.libEntry}}Tr();ie();import{basename as bg,resolve as vg}from"node:path";var Sg=9e4,Eg={PATH_OUTSIDE_WORKSPACE:3,FILE_TOO_LARGE:3,UNSUPPORTED_MIME:3,MODEL_MODALITY_UNSUPPORTED: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_FRAME_IDLE_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,NPX_CACHE_CORRUPT:1};function Ig(n){return Eg[n]??1}async function Ac(n,e={}){let s=e.paths??G();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 Ar(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:vg(process.cwd(),n.path),...n.caption?{caption:n.caption}:{},...n.name?{name:n.name}:{}},d;try{d=await Ag(o,"/agent/send",c,Sg)}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
|
+
`),Ig(d.code);if(n.json)process.stdout.write(`${JSON.stringify(d)}
|
|
133
|
+
`);else{let u=n.name??bg(c.path);process.stdout.write(`Sent ${n.kind} ${u} (${Tg(d.bytes)})
|
|
134
|
+
`)}return 0}async function Ag(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}),f=await u.text(),h=f?JSON.parse(f):null;return h&&typeof h=="object"&&"ok"in h?h:{ok:!1,code:"BRIDGE_INTERNAL",message:`unexpected daemon response (status=${u.status}): ${f.slice(0,200)}`}}finally{clearTimeout(d)}}function Tg(n){return n<1024?`${n}B`:n<1024*1024?`${(n/1024).toFixed(1)}KB`:`${(n/1024/1024).toFixed(1)}MB`}var zc=N("cli");function me(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 nh(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 k=e.filter(W=>W!=="--upgrade-helper"),{value:z,rest:Y}=me(k,"--target-version"),{value:j}=me(Y,"--old-pid"),oe=j?Number.parseInt(j,10):Number.NaN;return!z||!Number.isFinite(oe)?{mode:"help"}:{mode:"upgrade-helper",targetVersion:z,oldPid:oe}}if(e[0]==="send")return rh(e.slice(1));if(e[0]==="connect")return ih(e.slice(1));if(e.includes("--help")||e.includes("-h")||e.length===0)return{mode:"help"};let s=e,{value:o,rest:c}=me(s,"--pat-token");s=c;let{value:d,rest:u}=me(s,"--pair-code");s=u;let{value:f,rest:h}=me(s,"--env");s=h;let{value:p,rest:w}=me(s,"--handshake-url");s=w;let{value:b,rest:E}=me(s,"--frontier-url");s=E;let{value:I}=me(s,"--agent-id");if(!o||!d)return{mode:"help"};let A={mode:"pair",privatecode:o,pairingCode:d};return f&&(A.env=f),p&&(A.handshakeUrl=p),b&&(A.frontierUrl=b),I&&(A.agentId=I),A}function rh(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}=me(o,"--caption");o=d;let{value:u,rest:f}=me(o,"--name");o=f;let{value:h,rest:p}=me(o,"--agent-id");o=p;let{value:w,rest:b}=me(o,"--session-id");o=b;let E=o.includes("--json"),I={mode:"send",kind:e,path:s,json:E};return c&&(I.caption=c),u&&(I.name=u),h&&(I.agentId=h),w&&(I.sessionId=w),I}function ih(n){let e=n,{value:s,rest:o}=me(e,"--pat-token");e=o;let{value:c,rest:d}=me(e,"--env");e=d;let{value:u,rest:f}=me(e,"--handshake-url");e=f;let{value:h}=me(e,"--frontier-url"),p={mode:"connect"};return s&&(p.privatecode=s),c&&(p.env=c),u&&(p.handshakeUrl=u),h&&(p.frontierUrl=h),p}var sh=`
|
|
135
135
|
coze-bridge - local bridge daemon for cloud Agent Service
|
|
136
136
|
|
|
137
137
|
Usage:
|
|
@@ -175,43 +175,43 @@ Internal:
|
|
|
175
175
|
<node> <entry> --upgrade-helper --target-version=<v> --old-pid=<pid>
|
|
176
176
|
D82 self-update helper
|
|
177
177
|
(UpgradeManager \u5185\u90E8 fork)
|
|
178
|
-
`.trimStart();async function
|
|
179
|
-
`),0;case"daemon":{try{await
|
|
180
|
-
`),1;if(o.kind==="stale")return await
|
|
181
|
-
`),1;let
|
|
182
|
-
${JSON.stringify(
|
|
183
|
-
`),0}async function ah(n){let e=n.paths??
|
|
184
|
-
`),0;if(o.kind==="stale")return await
|
|
185
|
-
`),0;try{return await
|
|
186
|
-
`),0}catch(
|
|
187
|
-
`),1}}async function ch(n){let e=new
|
|
178
|
+
`.trimStart();async function Fc(n=process.argv,e={}){let s=nh(n);switch(s.mode){case"help":return process.stdout.write(sh),0;case"version":return process.stdout.write(`${st}
|
|
179
|
+
`),0;case"daemon":{try{await vc()}catch(o){return zc.error("daemon start failed",{err:String(o)}),1}return new Promise(()=>{})}case"status":return oh(e);case"stop":return ah(e);case"refresh":return ch(e);case"uninstall":return dh(e);case"install-service":return xh();case"pair":{let o={};return s.env&&(o.env=s.env),s.handshakeUrl&&(o.handshakeUrl=s.handshakeUrl),s.frontierUrl&&(o.frontierUrl=s.frontierUrl),uh(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),fh(s.privatecode,e,o)}case"upgrade-helper":{let{runUpgradeHelper:o}=await Promise.resolve().then(()=>(Rc(),Dc));return await o({targetVersion:s.targetVersion,oldPid:s.oldPid,...e.paths?{paths:e.paths}:{}})}case"send":return Ac({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 Uc(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 oh(n){let e=n.paths??G(),s=new Ne(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 Uc(e),process.stdout.write(`coze-bridge: not running (cleaned stale state)
|
|
181
|
+
`),1;let c=await s.request({method:"GET",path:"/status"});return process.stdout.write(`coze-bridge: running
|
|
182
|
+
${JSON.stringify(c.body,null,2)}
|
|
183
|
+
`),0}async function ah(n){let e=n.paths??G(),s=new Ne(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 Uc(e),process.stdout.write(`coze-bridge: not running (cleaned stale state)
|
|
185
|
+
`),0;try{return await s.request({method:"POST",path:"/shutdown"}),process.stdout.write(`coze-bridge: stopped
|
|
186
|
+
`),0}catch(c){return process.stdout.write(`coze-bridge: stop failed: ${String(c)}
|
|
187
|
+
`),1}}async function ch(n){let e=new Ne(n.paths);if((await e.probe()).kind==="not-running")return process.stdout.write(`coze-bridge: not running (start daemon first)
|
|
188
188
|
`),1;try{let o=await e.request({method:"POST",path:"/refresh"});return o.status===200?(process.stdout.write(`coze-bridge: refreshed
|
|
189
189
|
${JSON.stringify(o.body,null,2)}
|
|
190
190
|
`),0):(process.stderr.write(`coze-bridge: refresh failed: ${JSON.stringify(o.body)}
|
|
191
191
|
`),1)}catch(o){return process.stderr.write(`coze-bridge: refresh failed: ${String(o)}
|
|
192
|
-
`),1}}async function
|
|
193
|
-
`);try{await e.request({method:"POST",path:"/shutdown"})}catch(
|
|
194
|
-
`)}await new Promise(
|
|
195
|
-
`)}catch(
|
|
196
|
-
`)}let o=n.paths??
|
|
197
|
-
`)}catch(
|
|
192
|
+
`),1}}async function dh(n){let e=new Ne(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(()=>(Vi(),$i)),f=d();await f.uninstall(u()),process.stdout.write(`coze-bridge: ${f.platform} supervisor unregistered
|
|
195
|
+
`)}catch(d){process.stderr.write(`coze-bridge: supervisor uninstall failed (continuing): ${String(d)}
|
|
196
|
+
`)}let o=n.paths??G(),{rm:c}=await import("node:fs/promises");try{await c(o.cozeRoot,{recursive:!0,force:!0}),process.stdout.write(`coze-bridge: removed ${o.cozeRoot}
|
|
197
|
+
`)}catch(d){return process.stderr.write(`coze-bridge: remove failed: ${String(d)}
|
|
198
198
|
`),1}return process.stdout.write(`coze-bridge: uninstalled
|
|
199
|
-
`),0}async function
|
|
200
|
-
`),await
|
|
199
|
+
`),0}async function xh(){try{let{getSupervisor:n,buildContext:e}=await Promise.resolve().then(()=>(Vi(),$i)),s=n(),o=e();return process.stdout.write(`coze-bridge: installing ${s.platform} supervisor...
|
|
200
|
+
`),await s.install(o),process.stdout.write(`coze-bridge: supervisor installed (daemon will auto-start on login)
|
|
201
201
|
`),0}catch(n){return process.stderr.write(`coze-bridge: --install-service failed: ${String(n)}
|
|
202
|
-
`),1}}async function uh(n,e,
|
|
203
|
-
`),(await
|
|
204
|
-
`)}let f=await
|
|
205
|
-
`),await u({paths:
|
|
206
|
-
`),1;let
|
|
207
|
-
`),0):(process.stderr.write(`coze-bridge: pair failed: ${JSON.stringify(
|
|
208
|
-
`),1)}catch(
|
|
209
|
-
`),1}}async function fh(n,e,
|
|
210
|
-
`),(await
|
|
211
|
-
`)}let f=await
|
|
212
|
-
`),await u({paths:e.paths}),f=await
|
|
213
|
-
`),1;let
|
|
214
|
-
`),await
|
|
215
|
-
`),1)}catch(
|
|
216
|
-
`),1}}async function
|
|
202
|
+
`),1}}async function uh(n,e,s,o={},c){let d=new Ne(s.paths),u=s.spawnDaemon??_n;if(!s.skipDistInstall){let p=await Ui({paths:s.paths});p.kind==="version-changed"?(process.stdout.write(`coze-bridge: upgraded ${p.fromVersion} \u2192 ${p.toVersion}
|
|
203
|
+
`),(await d.probe()).kind==="connected"&&(await d.request({method:"POST",path:"/shutdown"}).catch(()=>{}),await new Promise(b=>setTimeout(b,500)))):p.kind==="first-install"&&process.stdout.write(`coze-bridge: installed ${p.libVersion}
|
|
204
|
+
`)}let f=await d.probe();if(f.kind!=="connected"&&(process.stdout.write(`coze-bridge: starting daemon...
|
|
205
|
+
`),await u({paths:s.paths}),f=await qc(d,s.waitTimeoutMs??1e4,s.sleep??Gc),f.kind!=="connected"))return process.stderr.write(`coze-bridge: daemon did not come up: ${f.kind}
|
|
206
|
+
`),1;let h={privatecode:n,pairing_code:e};o.env&&(h.env=o.env),o.handshakeUrl&&(h.handshake_url=o.handshakeUrl),o.frontierUrl&&(h.frontier_url=o.frontierUrl),c&&(h.agent_id=c);try{let p=await d.request({method:"POST",path:"/pair",body:h,timeoutMs:35e3});return p.status===200&&p.body?.ok?(process.stdout.write(`coze-bridge: paired (${p.body.note??"ok"})
|
|
207
|
+
`),0):(process.stderr.write(`coze-bridge: pair failed: ${JSON.stringify(p.body)}
|
|
208
|
+
`),1)}catch(p){return process.stderr.write(`coze-bridge: pair failed: ${String(p)}
|
|
209
|
+
`),1}}async function fh(n,e,s={}){let o=e.paths??G(),c=n??await gc(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 Ne(e.paths),u=e.spawnDaemon??_n;if(!e.skipDistInstall){let p=await Ui({paths:e.paths});p.kind==="version-changed"?(process.stdout.write(`coze-bridge: upgraded ${p.fromVersion} \u2192 ${p.toVersion}
|
|
210
|
+
`),(await d.probe()).kind==="connected"&&(await d.request({method:"POST",path:"/shutdown"}).catch(()=>{}),await new Promise(b=>setTimeout(b,500)))):p.kind==="first-install"&&process.stdout.write(`coze-bridge: installed ${p.libVersion}
|
|
211
|
+
`)}let f=await d.probe();if(f.kind!=="connected"&&(process.stdout.write(`coze-bridge: starting daemon...
|
|
212
|
+
`),await u({paths:e.paths}),f=await qc(d,e.waitTimeoutMs??1e4,e.sleep??Gc),f.kind!=="connected"))return process.stderr.write(`coze-bridge: daemon did not come up: ${f.kind}
|
|
213
|
+
`),1;let h={privatecode:c};s.env&&(h.env=s.env),s.handshakeUrl&&(h.handshake_url=s.handshakeUrl),s.frontierUrl&&(h.frontier_url=s.frontierUrl);try{let p=await d.request({method:"POST",path:"/connect",body:h,timeoutMs:35e3});return p.status===200&&p.body?.ok?(process.stdout.write(`coze-bridge: connected (${p.body.note??"ok"})
|
|
214
|
+
`),await wn(c,o).catch(w=>zc.warn("writePatToken after connect failed (ignored)",{err:String(w)})),0):(process.stderr.write(`coze-bridge: connect failed: ${JSON.stringify(p.body)}
|
|
215
|
+
`),1)}catch(p){return process.stderr.write(`coze-bridge: connect failed: ${String(p)}
|
|
216
|
+
`),1}}async function qc(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 Gc(n){return new Promise(e=>setTimeout(e,n))}Fc(process.argv).then(n=>process.exit(n),n=>{process.stderr.write(`fatal: ${n instanceof Error?n.stack??n.message:String(n)}
|
|
217
217
|
`),process.exit(1)});
|