coze-bridge 0.1.48 → 0.1.51
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 +50 -50
- 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 D0=Object.create;var
|
|
9
|
-
`):
|
|
10
|
-
`)}function
|
|
11
|
-
`,c=`${n}.tmp-${process.pid}-${Math.random().toString(36).slice(2,10)}`;try{s?.mode!==void 0?await bs(c,o,{encoding:"utf8",mode:s.mode}):await bs(c,o,"utf8"),await ys(c,n),s?.mode!==void 0&&await X0(n,s.mode)}catch(d){await ys(c,c).catch(()=>{});let{rm:u}=await import("node:fs/promises");throw await u(c,{force:!0}).catch(()=>{}),d}}var An=Ae(()=>{"use strict"});import{promises as vs}from"node:fs";import{homedir as tx}from"node:os";import{sep as nx,join as fe,resolve as Ss}from"node:path";function q(n){let e=n??tx(),s=fe(e,".coze"),o=fe(s,"bridge"),c=fe(o,"lib");return{cozeRoot:s,bridgeRoot:o,libDir:c,libEntry:fe(c,"index.js"),binDir:fe(o,"bin"),pidFile:fe(o,"bridge.pid"),portFile:fe(o,"bridge.port"),tokenFile:fe(o,"bridge.token"),patTokenFile:fe(o,"pat-token"),logFile:fe(o,"bridge.log"),installLock:fe(o,"install.lock"),configFile:fe(o,"config.json"),agentsRoot:fe(s,"agents")}}function Ge(n,e=q()){let s=fe(e.agentsRoot,n);return{root:s,config:fe(s,"config.json"),workspace:fe(s,"workspace"),logs:fe(s,"logs")}}async function Es(n,e){let s=await vs.realpath(Ss(n)).catch(()=>null);if(!s)return!1;let o=await vs.realpath(Ss(e)).catch(()=>null);if(!o)return!1;let c=process.platform==="win32"?s.toLowerCase():s,d=process.platform==="win32"?o.toLowerCase():o;return c===d||c.startsWith(d+nx)}var ie=Ae(()=>{"use strict"});var kn={};Kr(kn,{AGENT_CONFIG_FILE_MODE:()=>Cn,enforceAgentConfigMode:()=>sx,loadAgentConfig:()=>me,persistAgentSessions:()=>Wr,persistAgentSkills:()=>Pn,saveAgentConfig:()=>Ce});import{chmod as rx,stat as ix}from"node:fs/promises";function me(n,e){return Et(Ge(n,e).config)}function Ce(n,e){return In(Ge(n.agentId,e).config,n,{mode:Cn})}async function sx(n,e){if(process.platform==="win32")return;let s=Ge(n,e).config;try{let o=await ix(s);if(!o.isFile())return;let c=o.mode&511;c!==Cn&&(await rx(s,Cn),Is.warn("agent config mode auto-corrected to 0600",{path:s,from:c.toString(8)}))}catch(o){if(o.code==="ENOENT")return;Is.warn("enforceAgentConfigMode: chmod failed (ignored)",{path:s,err:String(o)})}}async function Wr(n,e,s){let o=await me(n,s);o&&(o.sessions=Object.fromEntries(e),await Ce(o,s))}async function Pn(n,e,s){let o=await me(n,s);o&&(o.skills=e,await Ce(o,s))}var Is,Cn,nt=Ae(()=>{"use strict";An();U();ie();Is=D("agent-config"),Cn=384});function Io(n){let e=n?.sessionIdleTimeoutMs;return typeof e!="number"||!Number.isFinite(e)||e<=0?Kd:e}function at(n){return Et(n??q().configFile)}function ze(n,e){return In(e??q().configFile,n)}var Kd,Lt=Ae(()=>{"use strict";An();ie();Kd=10*6e4});var Qo=_e(Y=>{"use strict";var E=k;(function(n,e){let s=k,o=n();for(;;)try{if(-parseInt(s(920))/1+parseInt(s(760))/2*(-parseInt(s(1375))/3)+-parseInt(s(1436))/4*(-parseInt(s(1702))/5)+parseInt(s(1610))/6+parseInt(s(865))/7*(parseInt(s(1077))/8)+-parseInt(s(1595))/9+parseInt(s(1135))/10===e)break;o.push(o.shift())}catch{o.push(o.shift())}})(Zn,501112);var ju=Object[E(1512)+E(1778)],Ku=Object[E(324)+"opertyNa"+E(1776)],Jo=(n,e)=>function(){return n&&(e=(0,n[{hkZbc:function(d,u){return d(u)}}[E(563)](Ku,n)[0]])(n=0)),e},Gu=(n,e)=>{let s=E,o={lSBmM:function(d,u,l,p){return d(u,l,p)}};for(var c in e)o[s(608)](ju,n,c,{get:e[c],enumerable:!0})};function Wu(){return Ho||(Ho=[IDBDatabase,IDBObjectStore,IDBIndex,IDBCursor,IDBTransaction])}function Ju(){let n=E;return jo||(jo=[IDBCursor[n(1349)+"e"][n(630)],IDBCursor[n(1349)+"e"][n(965)],IDBCursor[n(1349)+"e"][n(965)+n(1279)+"ey"]])}function $u(n){let e=E,s={rIfAb:e(321),kvZcc:function(c,d){return c===d},jChUo:e(1504),cyIpI:function(c,d){return c(d)},LeEFx:function(c){return c()},mJDme:e(1255),eeoHQ:function(c,d){return c instanceof d}},o=new Promise((c,d)=>{let u=e,l={aAxbJ:function(y,I){return y|I}},p=()=>{let y=k;n[y(605)+y(720)+y(396)](y(1255),m),n[y(605)+y(720)+"ner"](s[y(881)],_)},m=()=>{let y=k;s[y(1585)](s[y(347)],s[y(347)])?(c(s[y(467)](Ue,n[y(679)])),s[y(591)](p)):(_0x108c45[_0x45056c++]=l[y(1638)](_0x3364e2>>6,192),_0x45ad11[_0x5a78b6++]=l[y(1638)](63&_0x259db0,128))},_=()=>{let y=k;s[y(467)](d,n.error),s[y(591)](p)};n[u(884)+"Listener"](s.mJDme,m),n[u(884)+"Listener"](s[u(881)],_)});return o[e(317)](c=>{let d=e;s[d(1729)](c,IDBCursor)&&xi[d(1651)](c,n)}).catch(()=>{}),tr[e(1651)](o,n),o}function Zn(){let n=["uxL1ze8","twvZC2fNzuu","v3bUDNO","A1L5zMu","t05yEfq","DK1dq3q","tKnqsxq","tuD2swe","A2v5CW","re55EMW","C2nYAxb0","A1L3u2C","BxnN","BxjvEvy","zKHTsgW","veP4sfG","suvtx0vsuK8","z29sD0C","DfDut08","BgLTAxq","DwDiq2K","zw5NDgG","BLH2D2m","ELzMuxi","C3rYAw5NAwy","igzPzwXKoIa","q09otKvdveK","wfH0EuG","t3HbCwq","yNL0zxm","yw5Nzq","CKnwEgi","A3zAy2m","zgLZCgf0y2G","D2fZq2XLyw4","Dev2zw50","vwztEKe","B2nRzxrtDwm","ENfzt0q","B2nRzxq","revvuwO","u3juuuq","mtiYotCWnNncBgnwDa","zLrrBMy","svf0Cge","rxnluu0","z3LpsfG","ruXkzhu","zxfPwMC","aaaaaaaaaaa","Bwf4tg9ZC0m","y2uGBM90igK","Dg9tDhjPBMC","vLjNCM8","q1HXz2W","vhjVq0e","CevftwO","mtyXmJi3oe9rrxbSDW","DvLyqwO","shnJA0u","ENPAAw0","r1fytwu","EvvWugO","A2TyzLi","zxH0zw5ZAw8","zxPtzMe","Ewnst0S","D1DisKW","tLzhBLm","B2XKvMvYC2K","AKzMDwS","Cg9PBNrbBMq","D1rZEhK","EvzNwgu","y1b2EgS","y0nhyMi","zgHJq1O","B3jRig9MzMW","Dw5KzwzPBMu","y25tuu8","BvjiANC","wvj4zu0","BMfVr0W","AgLxtNi","EvjLy29UBMu","yuf4yKO","vgnPzK4","DhnrBNa","DeXIEu4","A2v5","zhrYtNi","y3jLyxrLt2i","EMDTr3K","DgvZDa","Aw9UvgLTzw8","AefJA01LC3m","uLDhwNu","zMX1C2HfEha","C2v0","wLv3Ce4","ywXty29Wzq","uhvitvq","B3bLBG","t3fyEfG","z2v0","CLjwC3G","t1HZsu8","EeL5rey","zgf0yq","y2XVC2uSihC","Cvf5vNy","t1bftG","q1bdv3q","BvLkDgi","q3Lvruq","m3W1Fdb8mxW","yM9L","y3jLyxrLt3a","u3HlAwy","DNn6uNq","Eu9cv2i","sMzpzgC","AuXMuvq","ANb3B3q","mxWW","z0Tvq20","uvnVque","Chv0","nxWYFdn8nhW","CNvMr3C","DLb1AvO","tKrXuKO","yxv0BW","C29YDa","vevSD1C","s0Xsuhq","wxL4BLm","q1rzrwG","C0LmvwO","u2HHCMvKv28","tLnjALC","sKDmquy","r1DMrKi","Ew1kwM4","BwvZC2fNzq","D3m6lY8","BwLUzW","q29Kzq","ANvSs1O","mtK0mdvczerLrgW","Dw9hu0q","yMLUyxj5vhK","v2vPEgLUsLm","x2DLDeLUDgu","DxntsvC","sLLUvuO","r2r5EgK","ENbxsNq","B2nRzxrgywK","svjevgG","ywDLrxzLBNq","yMXVy2TLza","zwvKzwq","yxnJCMLWDa","zwn0","vw1dsgm","zxPbqvy","C0P6vuq","BNruCMLLC0m","ywDLsgLKzq","CgLUz19VBMm","u2HLqLq","zxrxB3jRq2G","tw1xr08","C2vYDMvYvgK","zwzPDgi","zwvVsfe","Euz0seu","z29PBMCGyxC","D3LYAwC","wMHXC3m","D29PDMC","tKvruuC","C2vYDMLJzs0","DhLWzq","ufvzsei","teX0qwm","DgLTzw91Da","tw5xu3e","BhrPCgXLihq","BMCGDxjSoIa","tMfQyMO","BgfgvNC","zwD3qKe","Dvjiu1i","BwvZC2fNzv8","zxjHDg9Y","x2XPC3rLBMu","yLD1ufO","veLgzKG","yvzQDvK","uKjvwey","u2vXsuq","txDZy1q","wMPUzxm","s3jkCg0","u1HODMW","AhzpA2u","BeTNBu0","DNDrEw4","vgLTzw91Da","zNDZxZeUmc4","BxnNsuq","u0T2shK","Cg5cwMe","ChrVCG","ruHXCNy","Dgv4Dc9Qyxy","Cg93","sKP5zw4","AvP0uwC","ChvZAa","AvnOAeC","BwvZ","AwXLtMfTzq","B3bLCNr5","z05gDfa","BM93","DxjS","ve5htwS","Aw5KzxGGB3u","EgzTuvC","Dg9cExrLCW","yxnL","y0TPvhe","BMDLza","r0jfCxK","ywjVCNq","thHxuxG","EK9zChq","A05iqu4","CMvHzhLtDge","tg9JAW","A3v0ChO","Dg9mB3DLCKm","uMjTu0K","wKTsCwu","A2Hqyui","zMLSDgvY","FdeXFdj8ohW","swvhChq","reiGzMfPBgu","yxKSig5LDhC","zwjzwxm","B3bLBIa","yuzmqKO","C2Hks24","rhnYBMK","qLPdseC","sLDUEMK","ve52Bgm","BMrWB2LUDca","Bxv3wvO","x29Ut3bLBG","CMLMzxG","o2nOyxjZzxq","CMvZzxrfBMq","wMTYuK8","BNvTyMvY","x194x21Zz18","BejeshC","B3j3zwS","yM9KEq","DxnLCKLW","tg9NsurozxC","CxfPqvi","qLrtENO","mdaWma","DxrMofDYAxq","wfLJyMq","x2vUzhbVAw4","y3jLyxrLq2W","EffLBeO","BfLcDva","suzMA1m","BwvY","vxblze0","uff2ENm","v2PYtve","AgHmBui","zM9ZCK4","uLPWteO","sw9Xsu4","DM1zDMC","zNjVBuHHC2G","y2vZC0HHBMq","DMvY","yvnMCgy","rgvKAwnHDgu","CuL2y2y","ihzHBgLKihm","Euf0vLa","swHvsuO","s3PQvMe","BxrKtge","sLnhEe4","EujqtKy","vxbKyxrLq28","zxLhD1i","rvjst1i","zxj2AwnL","BwvZC2fNztO","ihrVihjLDhi","x3bPBMDmB3m","DhjPBq","AeHYz0C","sfzXy2G","zMLN","zev5u1G","B25pCgvU","AenQCg8","CLzjsKu","sKznzMm","z2vY","Aw5PDcbrB1m","y3vYCMvUDeu","CMvWBgfJzui","BM5Ly3q","vMTWu2W","x3DZ","qNbZAgu","DLjpz2W","y29UBMvJDeu","ExnfD2e","s09RsKG","C0jf","r2XJAuS","uuDMCvG","s2PjBgy","CgLUz0XVC3m","rKjWCve","zxjFAxnFywm","De1HBMfNzxi","uxrItvG","qvHezeu","yNbHwM4","DufeEwe","ALHzqu8","AfLZs0S","ANrVALC","BMfTzq","z2v0qwXSs2u","DvzZChu","CxjTAg4","wxr0tNe","r3vSvxG","CNzHBa","DgHLBG","CgLUz0LUDgu","sMvWwKK","BvDhufm","zxjYB3i","A1vJzNa","AwrI","z2v0t3DUuhi","AgvKtwf4uMu","tenwt3G","BMrWB2LUDfq","quXLAgi","seTSyuq","mNW1Fdf8mhW","sLngrwu","C21tDxC","AKHYA04","EuHwCKG","ENjAAuO","ug5ptfG","tLHlC3m","zw5JB2rLrNi","qxfJq24","Aw5L","Dgv4Dc9WBge","vgT5vxC","y3bKtg8","ywXSq3vYC28","B2LUDfjLywm","sePoCNa","AKnOvw8","zgL6yxG","zw5jywu","yvnsEvi","y3Hzzw4","wKD5Bvy","ChvsAgO","B3jLtMfTzxm","BxHwre0","EfLJEvm","sMr1v08","AenSB3nLrxy","BgvY","Efrurw52","y1DjB0i","uu9PBee","EgLpAeW","sxjZwvm","BgLfD2u","ueDeu3q","txjdzvi","sfn6CMm","BwzyDwu","AxLMuhC","tLL4t04","qLvtz3O","yw1LoIa","z3LdDuK","x2nSzwfYugK","vu1gBuu","x3bPBMDqB24","EgvdyuO","y29UC3rYDwm","EsbJBg9Zzwq","uMvcyKe","sg91Eve","AMP6qMe","Cgf5Bg9Hzfq","zgvJB2rLzey","DffPEu8","y3jLyxrLuMu","x29WDgLVBNm","rvPprgG","zvvYBa","ihrYEsbYzwm","Eu5iyMm","x2LZsw5PDa","Cu9vCem","x3DHAxq","BMvY","B2zMC2v0","qvjuzxC","tufyx1jfvfi","v3zJyLa","B2ncy3i","BwHXq0e","weTrEfq","Cg9PBNrdB24","y05UueW","D25PuK8","C2v0u3rVCMe","C2fNzq","x1fVu01HBMe","C3rYAw5N","EeTtsfm","B0Tivhy","vMndzhq","t1bftL9fuLi","v3PNDKW","zxHWB3j0CW","r2jvtM8","BMfIBNG","y3r4","vhLKrhK","z2v0u3rVCMe","vxjPqvC","DKHjwLO","De1ct08","sNbpuuW","AuXAqvi","B3jRzxjhBg8","oxW3Fdf8nhW","CNPSB0O","Bwv0Ag9K","z3fMANe","tgHrwg8","x2HHBMrSzu8","AKD2r2i","CMvTB3zLq2G","u0zgwge","shPVwMK","zMzMzG","CMvQzwn0","B25LCNjVCG","shDnvvu","DMfSDwvZ","x2rPC3bHDgm","CNzHBfzHBhu","ywnRx2LK","y29UDgv4Da","tgjsr20","ww1Rvvm","x2LUAxrhBg8","Cg1Jt1y","r0D6sxO","BNPVuNe","q3Dwr24","DM9JtMO","s0zgz3q","vurXsfe","A3rhz0e","D2Dyv1K","BNrbBMrvCgq","rMfND2m","ruz6Euy","BNjjzgK","zw5HyMXLqxu","zw5KCg9PBNq","A09et2m","sfvvDhO","y3LjCeK","tgHAyLC","A2v0ignVBNm","tw1qDKu","v2vIu29JA2u","BgTbtLu","A1r5D2e","DhLIquK","BNrsueu","DMfS","AwXK","yxKSihrYEsa","y3vYC29Yx2y","wKP4C3K","BMvLzf9Hy2S","D25lswS","BMnLq2XVC2u","CvrfAvK","wgH4seu","C29Tzq","q0Phyui","wLHjuuO","BMvJDa","ufLjBM8","verrDLa","ufvey0C","sK1Krey","tgfUugm","Aw5KzxHpzG","AK1sELi","yuLNtgi","D2vI","AKrgA3C","CgXLyxnLiha","zgrcBhO","BvzJr0q","s3bWrfu","uKrKveq","DKrtDNy","x2rLC3rYB3K","DwLKuLu","u2TPCcbWyxm","DfrTAw4","BgXIy2O","CM92AwrLigi","C1PSCeO","igfYCMf5yNu","uMHisNy","C0PIq3q","AKHdr3K","AxnAwMy","rNLdDwO","D29kCe8","D1rREuq","EhDxExO","yxrHlcbKyxq","CwXlsey","x3fVC0rc","y29UBMvJDfm","sfvPCLC","Dxrjza","vgDKuwy","ywWGy3vYC28","C2vUza","Eu9wB1q","DMLJzuLeig8","rMTMDLi","vufXzNm","Ae1LC3nHz2u","uhzsvKG","AxnFywnR","B25ozxr3B3i","CwDcvei","CLjKCMC","y09Wzw4","CM92AwrLihC","rezjBeW","ELbNwvm","nxWXFdj8nNW","x2LZtM9Kzq","BLfRsNm","zeD0sw0","B25Uzwn0Aw4","uxvLDwu","BfvQq08","ywrKt25L","z1DQrwO","rw14DM4","rKLgvKW","C1nZwMO","DNLpuNm","t3PVz3K","BezSDxnO","B0XWAMG","r1jyDgi","CgDUswq","AgTAyMm","pxv0zI04","BeHHBMrSzxi","q2TlsLO","vMrMqLe","Ec1TC2CTCw8","ELrvEgC","Aw50zwDLCIa","zKzytwy","uxvQuNe","u1HKDgC","tef0C3C","shbRCKW","CMvJB25Uzwm","DuvRvLO","zLv2yLG","AxnrB1nnzxm","AxHLCxG","r051BNy","zgvIDwC","CuDcBwG","B2f5uwS","txDAy2C","igzHAwWSig0","wevlsNa","BxfUA3C","zwXhAM0","r0TxAKO","tgvfrNG","y3vZDg9Tshq","AfzUChK","Dwj0qwS","ww5YAuq","A1fZBLa","s3PkBwq","B2fK","q0Xpu0LorW","yxrLq291BNq","zMLUza","CNjVCK1LC3m","Ec1TC2CTy3u","zePJC1C","CMvTB3zLrxy","z2j1z2K","zM5YDum","BfncBu0","qxvzrLu","vLHWDKy","wwT5Duq","BM1UCeq","uhntvMe","ywrKq291BNq","CwHtyu4","rvvKA3O","DgXsDwK","zNzHs1a","sLzzzgC","D2Dyy1y","vxzetfO","ywXSB2nvBNm","AwLNwKe","revRvKC","AgPoy1q","x2LZqNjVD3m","zvPytxC","y3vYC29Y","zNjVBujPDhm","ywr2yw5Jzq","BLHQsxu","y29Uy2f0","DfbYEMe","rvzizeK","DMrQuhq","CgfYC2u","vgfN","BLjqDMy","Cw9Zx18","CIb0DhDjra","B25TzxnZywC","mhWXmhW0Fdu","B25tDgfYDfi","C3vIC3rYAw4","ChPKv1m","yLvouge","wfzrBuW","uxrPCve","C25SCuK","sfv1rvG","vvDIzfu","CYbPBNn0yw4","z1rPBwvVDxq","v29Wu0S","rhzKALu","vuHuD08","B2zM","z09Qwe0","s1bjrMm","B1H2z3y","Eu9Mr0y","vMnevhC","B3nLrxzLBNq","rhLfquu","C2vUDa","zMLvCvK","B2jQzwn0u3q","ihrPBwvZ","x29UrxjYB3i","x2DLBMvYyxq","y0LdsvK","Du1jDuG","AuLPseG","x2n1CNnVCK0","EujPsem","EhHgq08","vw9HteK","AxnrB1nby2S","CMvZDwX0","C0rqwhe","thjKtMG","Dw5jENK","zNjVBuj5Dgu","y2HnyxHuCMK","wgnbDMy","EhjIvNy","weHVBwC","rNHOrfi","zgLZywjSzue","yMfSu2nVCgu","q3nvrhG","zNjVBNrPzxi","y2XLyxjtDg8","wufmEue","z2v0q3vYCMu","uuLHrgO","wuXNBhO","A0Lrzha","txzmBxa","q09oveLovuu","wxDLAw8","tez3CMy","zK1YBLy","uKnyse8","Cgu6ia","AM1rCe0","zLbUsgW","DxbKyxrLq3u","rwrXuxC","Cw9Z","ENPhDuO","C2v0zgi","se9iD1u","zw5XDwv1zq","BMv3vMvYC2K","Affju2y","vgPkuMu","x2fKzfDZtgK","zMzmAw5L","zw50tgLZDgu","jMPZy2fSBgi","BLjRsvi","CMvHC29U","EK96rMK","x2LUAxrqCM8","y2XLyxi","rNjVBNrPzxi","BgLUzq","CM9YrxzLBNq","y2jdC0W","wenKsw4","sgHJwLq","q01wr2O","zeTiwxi","zxjFCw9Z","AxnbCNjHEq","BwvKAwf0zwW","y3vYC29Yx24","v3Hxu0i","s21dvNC","C3rHy2y","vuLbwNu","ywnRtxnNswq","Ahr0Ca","C2vYDMLJzq","sgr2quy","zvrtwva","DcbSAw1PDa","seriweW","ugLQuKO","zK5xyNm","q0P2y2i","zfDVCMTLCKC","BwfW","rNzksvq","y3vYCMvUDeK","zxjFCw9Zx2e","zwHerKi","ihzHBgLKigq","mZq1nJaYEKzxBNvH","D2T0sxm","Bg9NsurozxC","z0XHCwy","zNjVBu51Bwi","EhDWAxu","zLfNvhC","nhWWFdv8mxW","D1zlC3q","mxWYFdb8nhW","y3zJCwG","sM1LCxO","B3Dgrhy","wxffrM4","ign1CNnVCIa","y1bWDw8","AevYCM9Yrxy","sKjjyM8","t3H2zKS","DgTKtvK","wvjNz0S","BMCGB3iGyw4","B1fMrxi","v2LUzg93","qu9hCM4","qKT1D3y","z3fOt1e","ChbkuuW","tKrxtwi","D01Vuuu","rurrAe8","sM9qtee","A1jtA1y","B3v0sw50zxi","wenWEuO","uLHTs2u","BgvUz3rO","ywX3yxLZ","zcWGDw5RBM8","BM9Uzv9UB24","C0z6q3a","lcbxzwjtB2m","zv90Aw1LB3u","ywnRpwzYB24","B25szwnLAxy","v01UAeK","B2XRCeC","Ef9MCM9UDgK","uNzSDLC","r25rtwe","CgfNzxnOB3C","tgnVwuO","vMD2wLO","zxjFywnRx20","yvbiuNi","x2nVBM5Ly3q","sLPAChq","rvLvqKK","BKXPBMu","CxvRCwe","CLzHBhvLCW","C0XPC3rLBMu","x2rYB3bhBg8","D3jPDgu","C2v0sxrLBq","Dw50","EgvyC1y","CufYu2e","vNPfD3O","y1rPrMG","zNjUvgO","DuzUz2m","qNzkANO","CvPzt2W","D3LdDNm","yKPqCKm","ueXXrfa","q0zQqw4","yMfSrxzLBNq","ru9REfK","yMzOEum","D1jZAeG","yMHbqMe","uenhzvO","C0nVDw50zxi","BeDKrLe","DuLVteG","Cxviru8","BwLZzq","zMvY","BMnVzgLUzW","ANrYB3q","zKzYwMK","CgvYC2LZDgu","yMLUza","A0jouuW","rKn1teG","BuXIwey","y3jLyxrLtwu","wNnPugO","zMfwqwC","zNjVBunOyxi","DKTcBhq","sNferuG","u3rYyxrLz3K","mJi3ndK3oxzjAM1yyW","C2vUzf9Hy2S","B3jL","DKfuB0K","B1Ljr20","zfL4BLu","Bff0Cvm","AxnmB25N","x29UugfNzu4","y2HLy2Tszwe","B3bLBKrc","t3joANG","EuztyNe","D1zIDLG","tMz6uLy","D24GCMvHC28","CKLMqwi","yxjYyxLIDwy","zwXAvK0","ywrKrxzLBNq","zNvSqNy","AuLzz3i","tKfusvzfx0u","CgP3qMO","DgLLCKPtt04","qw1VDw50","yNvMzMvYzwq","uNnpr28","DgHHBIbSB2m","vMLKyKK","mdaWmdaWmda","wejItg4","ELPHrgm","rxjYB3jdB2q","m3W4FdeW","Cgf5Bg9Hzeu","yxHtqNe","zxf1ywXZ","txjiywK","yvbtvLa","Bg9N","sKPXuwO","DcbVzIbYyw4","s0fyvMK","CMTLCKDSB2i","ExbqA1G","CMvHzfvjBNq","uMvJB25Uzwm","zgvSzxrLrge","CgXYyva","qKnjt1i","DMfSDwu","yMH6Dg4","AM1jBNa","uwvgANu","mJy3ndu3r054Cg1j","t3Lrqwi","y2DXu0K","vhH6zue","tK5wv2S","wM90EKq","yurWseK","y2n3qLO","D3jPDgvvAw4","Aw5Lza","y2HLy2TdDxi","C0PkBwS","x29Uq2XVC2u","Bu5wrxO","ANjwt1e","DNzVuue","igXHCMDLCIa","BgLUzw5V","y2XVC2veqG","z2TmCuW","uKTSrfu","zxjFBxnNAwq","reP3rxK","B25JBg9Zzq","tvnws3q","ELPXDMS","rM1ewhm","tw10tei","ywnR","m3WYFdf8mhW","zgjfC1O","AgvHzgvYCW","wLbqv1u","yuTHtui","vwf0uxu","wfnIvwG","AgDPtNO","yu1PDwK","x3nVy2TLDa","C1HRs0i","Eg9YAMS","Dw1xwxa","x2rItMfTzq","wNfrr2C","DKHsuuu","y29UDgLUDwu","tKzxyvq","v0vMsuG","yunKAxu","r0HwAvy","Cu9qBfy","CMvZzxrdB3u","q2rguxi","Bhm6ia","Du9Nv2y","suX4ENy","vfvhsxy","C3H0vvy","tLf3BuK","zufJAW","vwfLteW","yw1L","u1PtuwS","BvfZuxy","BNvHs0i","ChjVwwW","yvfcBgq","BhL5AKS","nNWWFdn8n3W","zgvSzxrL","D3j2qxi","CMfTzq","uuLlq1i","C3vIyxjYyxK","CezXBei","BuzAvuG","CMvUDevUzha","zsbHihn0CMK","weDAt04","wuf1Ag4","z2fgCLy","s3nWy1a","vvHcwvi","v0Ltrgy","A2zMteu","B25tDg9Wsw0","x3bHDgHlzxK","BuTzrwi","uwrmvxe","s3Lszvm","y3ruAw1LB3u","DLL1Cuy","r2r4Ewe","z2v0s2v5","Bwf4twvZC2e","x2zVCM1HDeu","CuXwywu","uxDvC2u","BuL4tfa","AhHswem","CxDjEw0","u2vYDMLJzvC","AgzJswO","zfPtB2S","uNH0vMK","x3bYB3rVy28","s3HvrMW","C3rVCMu","B0jVuhG","FdL8mxW3Fdy","CNnVCKzPBgu","qNvXDuW","Bwf4uMv0CMK","DLf2Axm","B2zMBgLUzq","q1n2D0q","BfrPBwvVDxq","t3Pcwve","ihrPBwvVDxq","Du5fAem","DhDVCMTdAge","swfbEwC","Cxv2rLe","sLvPC28","zw5HyMXLuw8","rKnHEK0","z2vtEw5J","BKjYA1u","teLlDfK","zxjYtxnN","Dxv6vfe","Ec11C2uT","zfjvzMG","B3vUDa","yNvMzMvY","DhjPzxm","x19LC01Vzhu","zMzLCG","rg5ZDfy","Aw47y2HHCNm","Aw9U","yw51Ce1LC3m","yNL0zuXLBMC","yxbWBhK","CMv0CNLdB3u","yMjVze8","uhfPsey","q0Xpu0ve","yNvlzfK","qK92sNy","AgLNAa","DgLTzw91DcW","rwnxC3m","vKzWDMm","C3bSAwnL","tNHiAeW","Cwj3qK4","ofbXtMznyW","uLjpuG","De92CMy","Dg1IsxC","rxzLBNq","mxWWFdj8nhW","AfjQwvy","Cu1nDei","yNL0zu9MzNm","Aw5JBhvKzxm","tMnYB2y","r2fRuLm","Ahj4BLK","AgfUz2u","CMvKDwnL","x2HHBMrSzvi","tevwtge","u2zuDuK","q3vZDg9Trxi","CMvXDwLYzwq","Cgf5Bg9Hza","tMDzuMe","sND0EK8","B1DgCK0","BLLLwfu","A2LgseK","DeLUDgvYy2u","zNjHBwvuExa","DNbtCxC","yxf6DMO","nhWXFdj8m3W","q3H5CKu","x21PBMLoyxy","sNn6C1C","x2LUDgvYDMe","BMH6z2K","D2TnAu8","mNWWFdn8mxW","shHYwu0","ENjRD2W","sNn5D3G","rufUzwu","vNvMEwO","ywDLu2HVDW","vhDMzMm","ywDL","y29UBMvJDca","wMXnBve","t0PirKG","uuDZwuO","x2TLEvbHDgG","EfzZqLa","BhPkru4","wvjdz1C","ExbL","yxbWzw5Kq2G","ALnMtve","DgfYz2v0","ndi2ndy1mfPKyxzKAa","Dg9cExrLC0i","CMvJzxzPzwq","wMTNtee","D1r5rwC","y29SBM8","EefAsKW","Aw9Ul2PZB24","CMvZB2X2zq","uvbMA0m","z2v0sxrLBq","x2LZtwLUAvC","ugjJAfm","nNWWFdj8nxW","wfHlqMm","vw5Oyw5KBgu","CvnWr1q","r1vszfK","FdeXFdL8n3W","DLDAy2S","z29dy3K","DxbNCMfKzw4","zw5HyMXLvhi","BKrAB3u","uxHHzfm","zen4tMG","rgjHB3O","zg9Uzq","yxnZAwDU","v0Pcqu4","DLHZvLm","tw9KDwXL","DfLmA1C","x2LUAxq","v1netfK","ugfMAg0","zw5fDMvUDa","s2XMwe0","Dg9oDw1Izxi","DwjuDNy","sxD3u08","AxjtwfO","tMzcuLK","t2rnyLa","zfvgD2q","BNrfBMrWB2K","D29nueC","y2fSBa","CNnVCL9Uyw0","AgfZ","id4G","lcbTyxGGCMu","zNvUy3rPB24","z0XrCNK","BMDuAw1LCG","rMP1yw8","rM9XBeW","vKTxt2y","Exb6rMu","tuXPqKO","C3rLBMvYCW","v3znwve","uxHNwNi","x2LZv29YA2u","z0PqBgq","DhjHBNnHy3q","D3HYzxG","rLfYtMi","zNblzvC","senorgK","DwzJEKS","u1fJrgu","q291BNq","yw5ZzM9YBvq","zv9ZDwnJzxm","x3jLBw92zvC","x2HHBMrSzva","CMvWBgfJzq","DgLUzYbZzxi","C3vRvNm","uMLTvxi","zw1PDa","x3DZsw5ZDge","vhrUDwq","wM9wv2W","zxjYtM8","DKjftg4","DM96t2i","sLH4vMm","A3rssKy","x2rLyNvN","vKv4zK4","te5jEhu","zgfUB0S","zLDJEgS","z0znwfe","v2TfAKS","v1vTuhe","zfDkAuy","y29TCgXLDgu","DMvUDa","DfzHtuq","BNz2sNy","sw5iDxq","reTnwMC","vevqy2y","CMPrzxu","D3nZoI8V","vuzLzgi","uNLnAMy","y2HnyxHdB3u","Eg1PwKq","z1fmsMi","ChjVy2vZCW","Dg9cExrLC0W","x2n1CNnVCKy","x3nLCuLK","ruHjufe","t1b4Cwe","vgXzr3K","C3vJy2vZCW","vNfwv2i","y3nJrLu","uhr2Bu0","r0jxqMO","B25fCNjVCG","tKDFrvjst1i","x0rctMfTzq","rLDyvNe","yKLoCNK","t0X1re4","sfvyDgi","z2jiwgO","y1vVrfu","DKf1Cg4","CfLuBui","y291BNq","DhjPzxmGCMu","rxn4CxG","CMvJzwL2zwq","Dhj1y3rVCIa","A3PYzxa","q3vZDg9Tq2W","zxmGCMvHy2G","uhjPBwfYEuS","uMriC0y","AhbPrgK","C0Xf","t1rNDem","uunvBwC","tejiy3K","y29UBMvJDgK","reHRCLa","Aw9Areu","EuDzu2W","ignVzgu6ia","ufn3C1u","u01hyLK","mhWZFdf8mNW","sMrTu1q","uNfAywO","BwfUDwfSihi","AKzwBxu","Dgv4DfbHEwW","zhPAsgG","m3WYFdy","A0PZDhe","BM1Lvhm","AxnszwfKEq","s1LXtfq","B2T3vw0","DMnJC2O","C1Lrr3q","y3vYC29YlNm","yw1jBM0","AxjLza","ruDZyxm","DgDjwKi","z2vjBMzVu3K","swn0ExC","C2v0q3vYC28","Eu5yv1y","ywXPzcb1CMW","sM1qq20","zcWG","qwjVCNrfCNi","BNrLCG","sevNBxG","zw5JB2rPBMC","AMfkEvK","rg9hsg0","y3jLyxrLrwW","swjkENK","CMfUzg9T","ruzIDhu","D2viBwW","vwznDuW","x25HDMLNyxq","x29UvgLTzw8","B3Pfrvi","vhz4C1C","rMHAq0O","reDrtM8","quDyALm","DNvpq1q","q2HNDw8","Ahz1zuy","vK9Ts00","B3jpBMXPBMu","vgHlvM0","zwnVBM5Ly3q","wxPfC0W","zM9Yy2u","DgT5Beq","ChjVDg90Exa","ywnRx2nVzgu","CgLgvhK","z2riBhq","CgLUz09Uy2u","tuDMu0O","CgfNzwHPzgu","Bwvrsxu","rLDt","Dwrfzhu","D3L5Eum","y2XVC2u","vLbouu4","rKf2Buy","x3nLBMrby2S","B25VCgvU","zKHyBhy","ChbL","rfznrNK","AMvJDfn0B3i","yxv0B21HDgK","vuzRCKq","tuTMA3C","twXpt0S","Be9QC2K","uufXDxu","mtvtyNrWzeW","EgjpBgS","Evjtv3u","BxnSsNi","AxnYvgy","y2HHCKnVzgu","Dw5ZAwDUzwq","lcbOB3n0BMe","vvL0uMW","ugL2tMO","wKTks1u","DhbizwfKzxi","uLPntvG","AMXQELa","wu5HwNe","yMrPuw0","BuDTzNu","tuvtu0fhrv8","uNrWu0O","y29UBMvJDa","zvDpvfu","y09ewNq","tg9Nsuq","z2v0qwXS","x2nSzwfYvgK","v0zPyvm","CuvIy0e","DgTpthG","z2v0q3vYC28","AgXJEe4","uNfozKq","AfLxBK4","DLD2yxy","ChjVDg9JB2W","sfzxCfC","rM9ZwNe","C2DPza","l3DZl3yY","C3bSAxq","zgvS","x2n1CNnVCK4","zvLju2m","x3vYBa","ywnOzwq","DNfwuwS","AfrKwgm","DeLK","sLnptLa","ugDmz3O","C2XPy2u","tgLZDgvUzxi","C2v0y3vYC28","D2rkCw8","twLZC2LUzYa","rKrXt0q","DhDyBLG","AxnAzxjV","D2LSBfjLy28","zcbLCNjVCI4","zw50","AgPUwKK","nZCYCNDRBurx","BMCGzMfPBgu","ugjJs0K","qMnet0u","AwXLx25HBwu","rKzNAe4","zfPPz3m","sfr2te4","v1zKrwW","ywnRDxbfBMq","qLHRAKe","rhv1qwi","u1foCLu","BIWGAg9ZDg4","x2jPBMfYEvq","nhWYFdf8nq","ChfLywG","AM9PBG","Bg93","x2rPC2nVBM4","C3nHz2vfDMu","s3bqEgK","y3vYDMfSDwu","DwLLC2W","qw1RCK4","x2nYzwf0zvm","Bg9IywXty28","AuX5twm","r2TOy2m","wxnTu2e","Cg9W","mtb8mhW0Fdm","zM96wuy","A2P3C0q","q29UzMLN","BMrLEa","D2TUD0O","B3nLza","rKLmrv9ot1q","v05tuge","z1HrwvK","rKDhB20","nhWXFdb8m3W","x3bYzwzPEa","rLzREeq","x3bPBMC","uunXAhe","CM92AwrLige","yw1Lu3bHy2u","x2LZtwLUAvq","EurKu2G","zxH0ugf5Bg8","twT2Dvm","B1nPCw8","s3nAt0e","sLflCge","Dg9Y","y2nQCMq","vw5PBxbSzw0","qMzkufa","BK1dEgS","zLHLAuC","tMfTzq","BLjHzLi","uKzywgq","r1LRvNa","B25SAw5L","BergEMS","vMLHtvu","AwDHDg9Yt24","Ae9Wzw5fDMu","svHozvK","BxPez3q","ywzL","txLjrLi","x3jLy29UBMu","zgvMAw5Luhi","x0vysvnu","DxrVuMvJB24","DMvYC2LVBG","Defvs3i","vNHYwxm","BgLZDgvUtMu","zM9YrwfJAa","tMjrDva","BgffCMe","CMLLC0nVDw4","Aw5N","Axnby2TdBgu","qurqrM0","vM9Jr2y","wvfit3i","tMjIswe","C0PrvNm","shPptM0","DfLNrgi","y29Kzq","Dhr3Awq","EM9tELm","x29UtwvZC2e","ywrK","x21LC3nHz2u","x3jLywr5q2W","CgjICdi","u0Tfu3O","sLLzAgG","zKXnAeW","ugLnAMG","z2u6ia","uK1Wruy","shDJwe4","CgLUz1rPBwu","Bg9Nsurhzw4","vgvLBNO","y3jLyxrLrxi","yw5Hz2vY","AMHXqMS"];return Zn=function(){return n},Zn()}function Vu(n){let e=E,s={WopSK:function(c){return c()},UfDRF:function(c){return c()},PiMjh:e(1320)+"or",PqiHF:e(1234),FGGom:e(321),Fjuao:"abort"};if(er.has(n))return;let o=new Promise((c,d)=>{let u=e,l={tlRui:s.PqiHF,bbodO:s[u(1477)],stacf:s.Fjuao},p=()=>{let y=u;n[y(605)+"entListe"+y(396)](l[y(617)],m),n[y(605)+"entListe"+y(396)](l[y(1065)],_),n["removeEventListe"+y(396)](l[y(741)],_)},m=()=>{s[u(654)](c),s.UfDRF(p)},_=()=>{let y=u;d(n[y(321)]||new DOMException("AbortError",s[y(1543)])),p()};n.addEventListener(s[u(1066)],m),n[u(884)+"Listener"](s[u(1477)],_),n[u(884)+"Listener"](s[u(1190)],_)});er[e(1651)](n,o)}function Yu(n){nr={qlKHF:function(o,c){return o(c)}}[E(523)](n,nr)}function Xu(n){let e=E,s={gyOHX:function(o,c){return o(c)},DFIlL:function(o,c){return o(c)},jtkMC:function(o,c){return o+c},nirSY:function(o,c){return o!==c},GURdY:function(o,c){return o&c},YqEFn:function(o,c){return o|c},KpPxi:function(o,c){return o<<c},ezAAV:function(o,c){return o|c},RDdTD:function(o,c){return o&c},yuPOu:function(o,c){return o<<c},KxUFl:function(o,c){return o<c},TydDy:function(o,c){return o>=c},nkdmi:function(o,c){return o<=c},IFfkS:function(o,c){return o(c)},Vufyj:function(o,c){return o(c)},ioZDE:function(o,c){return o(c)},ypPkX:function(o,c){return o===c},XXtyH:function(o,c){return o in c},njHUs:e(667)+e(354),wmCKb:function(o,c){return o===c},QGfqX:e(998),FoqlL:function(o){return o()},UfSzA:function(o,c){return o===c}};if(s[e(910)](n,IDBDatabase.prototype[e(1200)+e(1060)])&&!s[e(1580)](s.njHUs,IDBTransaction[e(1349)+"e"]))if(s.wmCKb(s[e(297)],e(505)))_0x56a659[e(905)](_0x44c05f);else return function(o,...c){let d=e,u=n[d(1182)](on(this),o,...c);return ci[d(1651)](u,o[d(1686)]?o[d(1686)]():[o]),Ue(u)};if(s[e(1191)](Ju)[e(1086)](n)){if(s[e(1589)](e(859),e(859)))return function(...o){let c=e;return n.apply(s[c(1599)](on,this),o),s[c(543)](Ue,xi[c(1657)](this))};_0x52acf1=_0x30981b[_0x2ef7be+_0x39e0ac+1],_0x3b1349=_0x56fbbe[s.jtkMC(_0x280555+_0x11770d,2)],s.nirSY(s[e(1152)](s[e(773)](_0x2fe8ba,s[e(1457)](_0x8c4b74,8)),49344),32896)?_0xd0e4a1+=_0x15fd89:(_0x2f32c6=s[e(1719)](s[e(1457)](s[e(504)](15,_0x4af702),12),s.yuPOu(63&_0x4025e1,6))|s.RDdTD(63,_0x702ac4),s[e(1026)](_0x56218e,2048)||s[e(420)](_0x1bfeb0,55296)&&s.nkdmi(_0x358851,57343)?_0x55524c+=_0x55a89d:(_0x588a02+=s[e(244)](_0x1809e2,_0x2bc3fe),_0x311bfc+=2))}return function(...o){let c=e;return s[c(1119)](Ue,n[c(1063)](s[c(1288)](on,this),o))}}function Qu(n){let e=E,s={qZYOl:function(o,c){return o===c},ysEwa:e(1187),PnOLX:function(o,c){return o instanceof c},JWnzi:function(o,c){return o(c)},fmmTR:function(o,c,d){return o(c,d)},wgXWY:function(o){return o()}};return s[e(833)](typeof n,s[e(293)])?Xu(n):(s[e(336)](n,IDBTransaction)&&s[e(219)](Vu,n),s.fmmTR($o,n,s[e(458)](Wu))?new Proxy(n,nr):n)}function k(n,e){n=n-196;let s=Zn(),o=s[n];if(k.bkGpaF===void 0){var c=function(p){let m="abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789+/=",_="",y="";for(let I=0,L,T,P=0;T=p.charAt(P++);~T&&(L=I%4?L*64+T:T,I++%4)?_+=String.fromCharCode(255&L>>(-2*I&6)):0)T=m.indexOf(T);for(let I=0,L=_.length;I<L;I++)y+="%"+("00"+_.charCodeAt(I).toString(16)).slice(-2);return decodeURIComponent(y)};k.PTJJTN=c,k.IkNHQH={},k.bkGpaF=!0}let d=s[0],u=n+d,l=k.IkNHQH[u];return l?o=l:(o=k.PTJJTN(o),k.IkNHQH[u]=o),o}function Ue(n){let e=E,s={iUERx:function(c,d){return c instanceof d},BNSAJ:function(c,d){return c(d)},icBGr:function(c,d){return c(d)},HDHXL:function(c,d){return c!==d}};if(s.iUERx(n,IDBRequest))return s.BNSAJ($u,n);if(Xn.has(n))return Xn[e(1657)](n);let o=s.icBGr(Qu,n);return s[e(749)](o,n)&&(Xn.set(n,o),tr[e(1651)](o,n)),o}var $o,Ho,jo,xi,er,ci,Xn,tr,nr,on,Ko=Jo({"node_modules/idb/build/wrap-idb-value.js"(){let n=E,e={JdmST:function(s,o){return s instanceof o},AiQho:function(s,o){return s===o},GRXtb:n(667)+n(354),iShhG:n(1027),OxvfK:function(s,o){return s(o)},gXLnT:function(s,o,c){return s(o,c)},MvLmp:"uWFrq",IbJzy:function(s){return s()},NuSOe:n(1234),tgIZB:n(321),gXPRc:"abort",FWXVq:n(569),HwMUU:"zYYXC",sSsZj:function(s,o){return s===o},HmFDQ:n(1162),LanPc:function(s,o){return s===o},PQvzs:function(s,o){return s===o},dKHYr:n(462),JmPCm:n(934),tMBOO:function(s,o){return s in o}};$o=(s,o)=>o[n(486)](c=>s instanceof c),xi=new WeakMap,er=new WeakMap,ci=new WeakMap,Xn=new WeakMap,tr=new WeakMap,nr={get(s,o,c){let d=n;if(e.JdmST(s,IDBTransaction)){if(e.AiQho(o,d(1162)))return er[d(1657)](s);if(o===e[d(561)])return s.objectStoreNames||ci.get(s);if(o===e[d(1775)])return c[d(667)+d(354)][1]?void 0:c[d(667)+d(867)](c[d(667)+"oreNames"][0])}return e[d(778)](Ue,s[o])},set(s,o,c){let d=n;if(e.AiQho(e[d(699)],"uWFrq"))return s[o]=c,!0;{let u=e.gXLnT(_0x18a8a8,_0x4f1f75,_0x3a07d5[d(1572)]),l=_0xc67332[d(1582)],p=_0x272d57[d(1582)];for(let m=0,_=_0x304057[d(1572)];m<_;m++)l[m+u]=p[m]}},has(s,o){let c=n,d={CXDyn:c(1234),LxWQx:e.tgIZB,RnTjU:e.gXPRc,qGBmh:function(u,l){return e[c(778)](u,l)},qhSaN:"AbortError",Oknnz:function(u){return e.IbJzy(u)}};if(e[c(1263)]===e[c(441)])this[c(289)]&&this[c(289)][c(530)](_0x196512),this._debug("send_ack",_0x5e9341);else{if(e[c(1294)](s,IDBTransaction)&&(e[c(556)](o,e.HmFDQ)||e[c(494)](o,c(1027))))if(e[c(247)](e[c(734)],e[c(1318)])){let u={plNxS:function(_){let y=c;return zdBpYN[y(1327)](_)},HUUtz:function(_){return _()}},l=()=>{let _=c;_0x2aadef["removeEv"+_(720)+_(396)](MIlDIU.CXDyn,p),_0x4237a7[_(605)+_(720)+_(396)](MIlDIU[_(198)],m),_0x358a31[_(605)+_(720)+_(396)](MIlDIU.RnTjU,m)},p=()=>{let _=c;u.plNxS(_0x23b668),u[_(466)](l)},m=()=>{let _=c;MIlDIU[_(583)](_0x3aee9e,_0x34e56b.error||new _0x2894de(MIlDIU.qhSaN,MIlDIU[_(615)])),MIlDIU.Oknnz(l)};_0x228537[c(884)+c(1425)](zdBpYN.NuSOe,p),_0x1185af[c(884)+c(1425)](zdBpYN[c(1312)],m),_0x3ce8f1["addEvent"+c(1425)](zdBpYN.gXPRc,m)}else return!0;return e[c(424)](o,s)}}},on=s=>tr[n(1657)](s)}}),Vo={};Gu(Vo,{deleteDB:()=>ef,openDB:()=>Zu,unwrap:()=>on,wrap:()=>Ue});function Zu(n,e,{blocked:s,upgrade:o,blocking:c,terminated:d}={}){let u=E,l={yNHbc:"online",vuOCT:"offline",CtVrc:u(1355),AuYFU:u(810),GKWjJ:function(_,y){return _!==y},ddBlz:"MieLm",sxtUV:u(544),zpWJt:function(_,y){return _(y)},YmkUS:u(1320)+"or",HUXtb:function(_,y){return _===y},hVZfh:u(1501),OJHFH:u(1360),fXFtq:"versionc"+u(1090)},p=indexedDB[u(1655)](n,e),m=Ue(p);return o&&p[u(884)+u(1425)](u(1156)+u(1715),_=>{let y=u;l[y(590)](l[y(501)],l[y(977)])?o(l.zpWJt(Ue,p[y(679)]),_[y(1622)+"on"],_[y(715)+"on"],Ue(p[y(1200)+y(1060)])):(this[y(626)+"er"]&&_0x15335b[y(884)+y(1425)](l[y(392)],this[y(433)+"nLine"]),this._isBrowser&&_0x3f8571["addEvent"+y(1425)](l[y(1339)],this[y(433)+y(719)]),this[y(626)+"er"]&&_0x34cda9[y(884)+y(1425)](l.CtVrc,this[y(1211)+y(1722)]),this._isBrowser&&_0x552bc7[y(884)+y(1425)](l[y(609)],this[y(1211)+"ageShow"]))}),s&&p[u(884)+u(1425)]("blocked",()=>s()),m.then(_=>{let y=u;l[y(1266)]("GYkVp",l.hVZfh)?(d&&_[y(884)+y(1425)](l[y(1125)],()=>d()),c&&_[y(884)+y(1425)](l.fXFtq,()=>c())):(mhfRva[y(1710)](_0x5c60df,_0x2bc0f9[y(321)]||new _0x34ebd0(mhfRva[y(448)],y(1320)+"or")),_0x390b6a())}).catch(()=>{}),m}function ef(n,{blocked:e}={}){let s=E,o={yQbOy:s(1714),JSFEe:function(d,u){return d(u)}},c=indexedDB[s(913)+"tabase"](n);return e&&c[s(884)+s(1425)](o.yQbOy,()=>e()),o[s(331)](Ue,c)[s(317)](()=>{})}function Go(n,e){let s=E,o={hqmLK:function(p,m){return p instanceof m},JszsW:function(p,m){return p in m},tAUKr:function(p,m){return p===m},EVHdI:"string",jFVmu:function(p,m){return p!==m},VRgro:function(p,m){return p in m}};if(!(o.hqmLK(n,IDBDatabase)&&!o[s(1110)](e,n)&&o[s(1516)](typeof e,o[s(634)])))return;if(Qn[s(1657)](e))return Qn.get(e);let c=e.replace(/FromIndex$/,""),d=o[s(1297)](e,c),u=Xo[s(1086)](c);if(!o[s(1606)](c,(d?IDBIndex:IDBObjectStore).prototype)||!(u||Yo[s(1086)](c)))return;let l=async function(p,...m){let _=s,y=this[_(1200)+_(1060)](p,u?"readwrite":"readonly"),I=y.store;return d&&(I=I.index(m.shift())),(await Promise.all([I[c](...m),u&&y.done]))[0]};return Qn[s(1651)](e,l),l}var Yo,Xo,Qn,tf=Jo({"node_modules/idb/build/index.js"(){let n=E,e={sZlpJ:n(1681)+n(1677),aMiui:function(c,d){return c(d)},DvdjU:function(c){return c()},wdJqo:"get",pbbyS:"getAll",Pqeqp:"getAllKeys",AXDdE:n(1271),ubTvv:n(1536),xrbVv:n(989),BgpYU:"clear"},s=e[n(512)][n(1413)]("|"),o=0;for(;;){switch(s[o++]){case"0":e[n(957)](Yu,c=>({...c,get:(d,u,l)=>Go(d,u)||c[n(1657)](d,u,l),has:(d,u)=>!!Go(d,u)||c[n(1184)](d,u)}));continue;case"1":Qn=new Map;continue;case"2":e[n(655)](Ko);continue;case"3":Yo=[e[n(1427)],"getKey",e.pbbyS,e.Pqeqp,e[n(304)]];continue;case"4":Xo=[n(1680),e[n(1174)],e[n(686)],e.BgpYU];continue;case"5":e[n(655)](Ko);continue}break}}}),nf={idb:function(n){let e=E,s={MrHai:function(o,c){return o(c)},PSwsU:function(o,c){return o!==c},BKuwv:e(1496),XYcbd:"TjdzW"};n[e(416)]=Promise[e(1143)]().then(()=>(tf(),Vo))[e(317)](function(o){let c=e,d={mzDgt:function(u,l){return s[k(903)](u,l)}};return s[c(1291)](s[c(785)],s[c(239)])?o:(_0x289c3d[c(1063)](BgStRA[c(1508)](_0x240330,this),_0x5b9d4b),_0x53feda(_0x299971[c(1657)](this)))})}},Wo={};function Fe(n){let e=E,s={EAnee:e(1082)+"3",tjwNK:function(l,p){return l!==p}},o=s[e(1118)][e(1413)]("|"),c=0;for(;;){switch(o[c++]){case"0":if(s.tjwNK(void 0,d))return d[e(416)];continue;case"1":var d=Wo[n];continue;case"2":var u=Wo[n]={exports:{}};continue;case"3":return u[e(416)];case"4":nf[n](u,u[e(416)],Fe);continue}break}}Fe.d=(n,e)=>{let s=k;for(var o in e)Fe.o(e,o)&&!Fe.o(n,o)&&Object[s(1512)+s(1778)](n,o,{enumerable:!0,get:e[o]})},(()=>{let n=E;Fe.o=(e,s)=>Object[n(1349)+"e"].hasOwnProperty[n(1182)](e,s)})(),(()=>{let n=E,e={UFedb:function(s,o){return s!=o},FCuLH:n(1631)+"d",olkpG:n(1166)};Fe.r=s=>{let o=n;e[o(1243)](e[o(856)],typeof Symbol)&&Symbol[o(1605)+"Tag"]&&Object[o(1512)+o(1778)](s,Symbol[o(1605)+o(637)],{value:e[o(806)]}),Object[o(1512)+o(1778)](s,"__esModule",{value:!0})}})();var te={};(()=>{let n=E,e={VFpvc:function(i,t){return i+t},JduWO:function(i,t){return i+t},ymJZn:function(i,t){return i+t},nmnpD:function(i,t){return i*t},rRVsx:function(i,t){return i!==t},rzloJ:"lsobL",ZPPWU:function(i,t){return i+t},hTdXc:function(i,t){return i(t)},rufGw:function(i,t,r){return i(t,r)},OLuDN:function(i,t,r){return i(t,r)},cJSVZ:"complete",VXpvF:n(197),bSNKF:n(264),TEPcf:n(237),YJNZl:n(438),dRUfh:function(i,t){return i|t},dUFwd:function(i,t){return i|t},cODZt:function(i,t){return i<<t},LIKtY:function(i,t){return i<<t},KzJmd:function(i,t){return i<<t},ZXIQJ:function(i,t){return i+t},cWIoB:function(i,t){return i+t},iyfPw:function(i,t){return i|t},sJQVs:function(i,t){return i|t},goCcy:function(i,t){return i+t},UfMuL:function(i,t){return i+t},DHkrP:n(852),cbCsL:n(895)+n(895)+n(895)+"00000000",isZZf:function(i){return i()},JXxVc:function(i,t){return i>t},hYsKK:function(i,t){return i<t},qukqa:n(554),mYJtb:function(i,t){return i!==t},evZjp:function(i,t){return i-t},WxWSB:function(i,t){return i<t},QtbMX:function(i,t){return i-t},uIoLH:function(i,t){return i===t},mFZUH:function(i,t){return i<t},ubtAk:function(i,t,r){return i(t,r)},vvoQA:function(i,t){return i!==t},LLtAc:function(i,t,r){return i(t,r)},pqeah:function(i,t,r){return i(t,r)},HwcXN:function(i,t,r){return i(t,r)},kzrep:function(i,t){return i&t},TgdQf:function(i,t){return i===t},plraP:n(1428)+n(1096)+n(1578)+"value",SrTQD:function(i,t,r){return i(t,r)},TJxHX:function(i,t){return i(t)},FxhDR:n(1502),elGjm:n(1034),nRkIR:n(1355),fulBv:n(810),wVKst:"ping_onc"+n(1209)+"s",dYxnU:n(1255),fNWbs:function(i,t,r,a){return i(t,r,a)},sukVs:n(321),IhUIJ:function(i,t,r){return i(t,r)},yOVoT:function(i,t){return i!==t},aDpHI:function(i,t,r){return i(t,r)},oayQk:function(i,t,r){return i(t,r)},ONXxT:function(i,t){return i!==t},buKdY:n(491),YALyA:function(i,t,r){return i(t,r)},GWfFB:function(i,t){return i!==t},CTYEh:function(i,t,r){return i(t,r)},xpfen:function(i,t){return i!==t},SXhvl:function(i,t,r){return i(t,r)},iigZA:function(i,t){return i===t},iZtQg:n(716),gQLJb:function(i,t,r){return i(t,r)},LhQXo:function(i,t){return i!==t},qqiAR:n(685),gbHXj:function(i,t,r){return i(t,r)},vAupn:function(i,t,r){return i(t,r)},RZMMX:function(i,t){return i!==t},lGdFQ:function(i,t,r){return i(t,r)},gLaqf:function(i,t,r){return i(t,r)},WjLSS:function(i,t,r){return i(t,r)},yFSbq:function(i,t){return i(t)},IQtpa:function(i,t){return i(t)},mxQlT:function(i,t){return i(t)},YtCcr:function(i,t){return i(t)},UoaLI:function(i,t){return i(t)},kODOc:function(i,t){return i(t)},cUoDU:function(i,t,r){return i(t,r)},uiesl:function(i,t){return i===t},JJyen:"Missing "+n(1096)+n(1578)+n(1755),KAXVi:n(1428)+n(1096)+n(1578)+"LogID",QIaDj:n(1428)+n(1096)+n(1578)+"service",UmCHc:n(1428)+n(1096)+n(1578)+n(430),SFFXa:function(i,t){return i(t)},sDPXq:n(519),qwIym:function(i,t,r){return i(t,r)},TElwW:function(i,t){return i+t},LcoYJ:n(1494)+"ented ty"+n(705),cNnPL:function(i,t){return i>=t},nuaKB:n(508)+"t limit",YyxnS:function(i){return i()},kIQdp:function(i){return i()},SfTuI:function(i,t){return i!==t},axSBq:n(1256),yGYSl:function(i,t){return i>=t},WSDLY:n(389),HxrYM:"Read pas"+n(748),mxVDM:function(i,t,r){return i(t,r)},wMoQE:function(i,t){return i||t},Ttnud:function(i,t){return i<t},QyudO:function(i,t){return i+t},QtiqQ:function(i,t){return i===t},lQtqS:function(i,t){return i>=t},lBDHw:function(i,t){return i+t},aqzvj:function(i,t){return i+t},PijRJ:function(i,t){return i!==t},WFiaS:function(i,t){return i(t)},tWTOO:function(i,t){return i==t},WNSPa:function(i,t){return i&t},Zjnes:function(i,t){return i+t},boCKR:function(i,t){return i+t},kkXfR:function(i,t){return i<<t},NXKss:function(i,t){return i<=t},zMxJO:function(i,t){return i(t)},FCazM:function(i,t){return i+t},cPpuo:function(i,t){return i+t},wTyEg:function(i,t){return i!==t},FQrNb:function(i,t){return i&t},kRSkV:function(i,t){return i|t},EOkxY:function(i,t){return i|t},CFjAn:n(1128),yHVrH:function(i,t){return i+t},mQsQv:function(i,t){return i+t},mRHjw:function(i,t){return i<=t},wVbvX:function(i,t){return i+t},gbugi:function(i,t){return i-t},afaVg:function(i,t){return i+t},Ictyw:function(i,t){return i<t},bDTmC:function(i,t,r){return i(t,r)},IGafw:function(i,t){return i<<t},zrZiJ:function(i,t){return i|t},kNHAN:function(i,t){return i>>t},iIYgr:function(i,t){return i|t},FosZq:function(i,t){return i&t},WkEjK:function(i,t){return i>>t},gXQYY:function(i,t){return i&t},dJcsW:function(i,t){return i|t},vIHDf:function(i,t,r){return i(t,r)},UatQu:function(i,t){return i+t},gaFrV:function(i,t,r){return i(t,r)},dZigs:function(i,t){return i<t},PGDSt:function(i,t){return i&t},UVtKw:function(i,t){return i&t},WzgvL:function(i,t){return i>=t},tybAI:function(i,t,r){return i(t,r)},snlqI:function(i,t){return i&t},KOkJH:function(i,t){return i(t)},dZXhc:function(i,t){return i(t)},tQiyO:function(i,t){return i&t},gdHlt:function(i,t){return i&t},piFTy:function(i,t){return i<<t},BbYpg:function(i,t){return i(t)},MwscT:function(i,t){return i<<t},mnrEh:function(i,t){return i&t},DuuAb:function(i,t){return i(t)},HEgmx:function(i,t){return i|t},RXmKe:function(i,t){return i>>>t},mLbXF:function(i,t){return i|t},sJzUD:function(i,t){return i>>>t},aSfpf:function(i,t){return i<<t},ZGymV:function(i,t){return i===t},qiQqS:function(i,t){return i<t},FhZCJ:function(i,t){return i<t},SxKif:function(i,t,r){return i(t,r)},gWjEj:function(i,t){return i!==t},NfzRV:function(i,t){return i!==t},vBELn:function(i,t){return i>>>t},UrDnl:function(i,t){return i&t},kQsnP:function(i,t){return i+t},bINry:function(i,t){return i!==t},qrmhn:function(i,t){return i>>>t},GQXMe:function(i,t){return i&t},mhqCA:function(i,t){return i&t},nstmr:function(i,t){return i>>>t},RhHJv:function(i,t){return i!==t},BXkjA:function(i,t){return i|t},ELJdu:function(i,t){return i+t},UFkrD:function(i,t){return i!==t},NgYRa:function(i,t){return i&t},sJJmk:function(i,t){return i>>>t},FkfvR:function(i,t){return i+t},jSfMQ:function(i,t){return i!==t},zZqvk:function(i,t){return i|t},ntRPE:function(i,t){return i>>>t},MkvuS:function(i,t){return i&t},xxFCO:function(i,t){return i!==t},hrxnY:function(i,t){return i&t},InHut:n(703),wRshH:function(i,t){return i(t)},aIgLb:function(i,t){return i+t},ysgAY:function(i,t){return i!==t},cscFU:n(276),SXdtg:function(i,t){return i===t},nXJsU:n(1075),PYIno:function(i,t){return i|t},vmYvg:function(i,t){return i<<t},bWuPZ:function(i,t){return i<<t},VhytP:function(i,t){return i<<t},ZKJKU:function(i,t){return i|t},acLsI:function(i,t){return i<<t},nBrkU:function(i,t){return i<<t},amInm:function(i,t){return i<<t},pjwBj:function(i,t){return i|t},GHViV:function(i,t){return i<<t},gqfjq:function(i,t){return i<<t},laEra:function(i,t){return i<<t},okwUm:function(i,t){return i===t},kjwsD:function(i,t){return i>>>t},IwwSO:function(i,t){return i|t},gsmKZ:function(i,t){return i<<t},uidRU:function(i,t){return i<<t},vpSqw:function(i,t){return i<<t},eyGwR:function(i,t){return i&t},xKSHS:function(i,t){return i>>>t},cpdLo:function(i,t){return i>>>t},oWFrM:function(i,t){return i(t)},pEEMj:function(i,t){return i===t},FAvmF:function(i,t){return i===t},ZqQGg:n(249),vwQyn:function(i,t){return i!==t},FBpqQ:"mAUnZ",XKQxT:n(1758),cTiFh:"DyEAE",CJvcb:function(i,t){return i<=t},proYl:function(i,t){return i+t},lUjCO:function(i,t){return i%t},VkpSl:function(i,t){return i/t},aPHRr:n(1467)+n(1153)+n(545)+"8",JfOdg:function(i,t){return i|t},sXkKB:function(i,t){return i>t},YNaZq:function(i,t){return i>>>t},WvcbP:function(i,t){return i===t},VPNQN:n(1570),dizax:function(i,t){return i+t},CxyrE:function(i,t){return i*t},DbnXW:function(i,t){return i+t},vROgl:function(i,t){return i===t},UaeLL:n(410),OXsIO:function(i,t){return i(t)},HUirW:function(i,t,r,a){return i(t,r,a)},IeGpt:function(i,t){return i instanceof t},hRjYV:"dsrOa",QujRq:function(i,t){return i>>>t},HhcZT:function(i,t){return i&t},BCIOR:function(i,t){return i>>>t},HdvAF:function(i,t){return i+t},fTQnf:function(i,t){return i===t},VcCdt:function(i,t){return i===t},ZkrRO:function(i,t){return i===t},kffLE:function(i,t){return i+t},KzjVa:function(i,t){return i&t},KVkhV:function(i,t){return i&t},pzdWS:function(i,t){return i>>>t},wyCvs:function(i,t){return i>>>t},dCxNh:function(i,t){return i>>>t},jtrot:function(i,t){return i>>>t},shJKn:function(i,t){return i>>>t},vWZck:function(i,t){return i&t},fFXMf:function(i,t){return i&t},hYWnN:n(887)+n(1078),sFzCp:n(1579)+n(1261),pFqlB:n(399)+"IES_ERROR",kTywa:"MESSAGE_"+n(269),xbOlk:n(414)+"OR",hvueF:n(767)+n(1300),liEwe:function(i,t,r){return i(t,r)},vYuqF:n(1735),hiWNr:n(769)+"3",mVcGD:function(i,t){return i!==t},jDFkw:"SgkCv",arJQq:n(1035),Najbj:function(i,t){return i||t},IRDTh:"undefined",gFMXQ:"awJJa",qMMtB:n(1019),ktGgA:function(i,t){return i instanceof t},fOzds:function(i,t){return i+t},kBNQL:n(766),PbcKI:function(i,t){return i>>>t},bhABa:function(i,t){return i<<t},BTSzz:function(i,t){return i===t},VocGf:function(i,t){return i-t},gzVnK:function(i,t){return i===t},SFxCa:function(i,t){return i>t},Jmeqz:n(904),iLyMc:function(i,t){return i|t},ALehb:function(i,t){return i===t},LEVLa:n(724),QAquu:function(i,t){return i+t},aFLBJ:n(1150)+"d error.",RdHsF:function(i,t){return i+t},HSzrc:function(i,t){return i+t},yDdSh:function(i,t){return i===t},RXaMB:function(i,t){return i===t},OTgtC:n(1058),dZSok:function(i,t){return i===t},vHRQE:function(i,t){return i>>t},FDqOD:n(1611),ehDFB:function(i,t){return i(t)},xwpiu:"unknown reason",MnWSq:function(i,t,r){return i(t,r)},XEKJp:n(1360),cPvxk:function(i,t){return i===t},hpiDi:n(624),NQwmI:n(305),QCUmg:n(1697),wyrig:function(i,t,r){return i(t,r)},ccwBZ:function(i,t){return i!==t},jXYAO:function(i,t){return i-t},RbmSI:function(i,t){return i&t},FnxYW:"OOXzs",JqDEH:n(1655),smSuw:function(i,t){return i===t},nDZou:"jzrAQ",vMCCt:function(i,t){return i+t},HUuEX:n(1293)+"4",WISDf:function(i,t){return i===t},LbRGm:function(i,t){return i+t},ozEER:"NWYPO",MwZcg:function(i,t){return i<t},rSztB:function(i,t){return i&t},vdjPt:function(i,t){return i+t},oSiqo:function(i,t){return i!==t},fosrN:function(i,t){return i===t},GBWBj:function(i,t){return i>>>t},FIFVL:function(i,t){return i<t},uoGSD:function(i,t){return i&t},lOjsi:function(i,t){return i&t},xmiZD:function(i,t){return i>=t},ktRJF:function(i,t){return i<t},zgmGy:function(i,t){return i|t},HouyQ:function(i,t){return i<<t},uEkVZ:function(i,t){return i&t},jjzBa:n(342),HqKEk:n(671),MlOOK:function(i,t){return i|t},woMPG:function(i,t){return i<<t},mqHtZ:function(i,t){return i<<t},JUiso:function(i,t){return i&t},SmfAX:function(i,t){return i+t},MmPvE:function(i,t){return i(t)},ccjrd:function(i,t){return i|t},ppJQL:"YgJGA",fozYF:function(i,t){return i<t},aSRyR:function(i,t){return i|t},zVfQr:function(i,t){return i&t},QxadS:function(i,t){return i===t},IxSuT:function(i,t){return i&t},gxRXI:n(1668)+"4|2",uvHcg:function(i,t){return i|t},oKHTv:function(i,t){return i|t},EYUBI:function(i,t){return i&t},quvFQ:function(i,t){return i+t},fpKeW:function(i,t){return i<<t},RKlDU:function(i,t){return i&t},LcysV:function(i,t){return i|t},ILxzv:function(i,t){return i&t},fPnHl:"PtvmM",CwVGn:function(i,t){return i|t},RMpEF:function(i,t){return i>>t},ycROK:function(i,t){return i&t},GuYBs:function(i,t){return i|t},kJstq:function(i,t){return i==t},vKBlt:function(i,t){return i instanceof t},YzEsL:function(i,t){return i|t},WvMYQ:function(i,t){return i|t},hvOke:function(i,t){return i<<t},tkdMY:function(i,t){return i&t},vPuiZ:function(i,t){return i+t},unIzy:n(1253),MyIFR:function(i,t){return i!=t},UAqfs:function(i,t){return i instanceof t},bJPrC:function(i,t){return i!=t},xQelJ:"applicat"+n(1142),Jtxnb:n(1769),fHmHl:function(i,t){return i!==t},KYqLT:"kaVRC",GWBtw:n(1669),hfcIj:n(1366),qArSa:function(i,t){return i<t},ndHgx:n(451),JGLAF:n(1563),CXqgl:function(i,t){return i+t},HTvLN:n(721)+n(803)+n(889)+"P",RxtVi:n(710),lKgmM:n(1748)+"id",WVdEl:"zRFNQ",JwtzO:"JjAzF",aGYhe:n(323),NbQuP:n(1517),oQfEr:function(i,t){return i!==t},XHomg:n(1033),vccsj:function(i,t){return i>=t},yEtUz:n(1116),LRIoT:function(i,t,r){return i(t,r)},julKZ:n(539),EdqQw:function(i,t){return i===t},Esxqx:n(1691),DKMZg:n(986),pgnId:n(1383),mqnkw:n(1206),LhZbW:function(i,t){return i||t},VExfN:n(738)+n(981),VdfBQ:"Zzqwe",uNhrz:n(1012),lkANU:function(i,t){return i||t},aVflX:function(i,t){return i(t)},CweRD:function(i,t){return i!==t},xiOhL:"AxeRd",mslJr:function(i,t){return i!==t},ThKVm:n(1222),JoPLA:function(i,t){return i||t},TjJRe:function(i,t){return i===t},VKWOf:n(1684),DvQNN:function(i,t){return i||t},nzoRq:function(i,t){return i!==t},aVjuY:"PrGDy",QsKzm:function(i,t){return i||t},QCqhq:function(i,t){return i||t},BUSgz:function(i,t){return i||t},jHCGy:n(284)+n(211)+"d",BZCHG:function(i,t,r){return i(t,r)},ZlMmQ:n(521),JFMfc:"dvGzO",PsSVa:function(i,t){return i(t)},hVnpy:function(i,t){return i-t},wrvAr:"VZHYP",ARTew:n(1129),zzTwP:n(807)+n(735),RWGZu:function(i,t,r){return i(t,r)},AHVMX:n(807)+n(813)+n(1411),SKvHy:n(481),KyReS:n(537),yAtVP:function(i,t){return i&&t},uNEhC:n(1365),uTKdp:n(445),yRSWu:function(i,t){return i||t},JeDpQ:n(1350),HJNrp:n(278),DoGHm:n(1274),fUvbX:function(i,t){return i(t)},llbcj:function(i,t){return i instanceof t},jHrkN:n(341)+n(1059)+"et=utf-8",uADya:"applicat"+n(1142)+n(225)+n(564),KjIlf:"binary",Dbaoz:function(i,t){return i+t},CiPOh:function(i,t){return i(t)},yOfGF:function(i,t){return i+t},XrZuJ:function(i,t){return i|t},laFVw:function(i,t){return i||t},VgvZZ:function(i,t){return i+t},YRggK:function(i,t){return i+t},DJwEy:function(i,t){return i+t},HGhwT:n(1783)+n(907)+n(1544),xeCaJ:" + ",JYnUJ:n(1185),rRdrg:n(570)+"too large",uOgWf:function(i,t){return i&t},kutpz:function(i,t){return i+t},lhpaO:function(i,t){return i===t},nnUuP:"TZusq",fLMhL:function(i,t,r){return i(t,r)},JBIbo:function(i,t){return i<<t},CkKJZ:function(i,t){return i+t},CPCWt:function(i,t){return i+t},gyCuI:function(i,t){return i|t},dNAMH:function(i,t){return i+t},soGkl:function(i,t){return i+t},jGvGb:function(i,t){return i|t},NFWaT:function(i,t){return i|t},vqVQk:function(i,t){return i+t},nYeXU:function(i,t){return i+t},vqmIh:function(i,t){return i+t},eqiZg:function(i,t){return i+t},pYTmB:function(i,t){return i>>>t},SCuwf:function(i,t){return i&t},mGmfu:function(i,t){return i>>>t},Twffc:function(i,t){return i>>>t},zzZim:function(i,t){return i+t},MhLSF:function(i,t){return i instanceof t},elZVM:function(i,t){return i!==t},nabnx:n(280),twXnX:function(i,t){return i&t},TUGIv:function(i,t,r){return i(t,r)},sJbCt:function(i,t){return i!==t},usSIW:n(518),mKvYi:function(i,t){return i+t},bhztn:function(i,t){return i(t)},IoqIN:function(i,t){return i||t},Pafhm:n(947),vHIZZ:function(i,t){return i|t},NNVWk:function(i,t){return i<<t},lYBuP:function(i,t){return i<t},Bpshe:function(i,t){return i>t},phtMy:function(i,t){return i&t},VOmKM:function(i,t){return i|t},oXvgv:function(i,t){return i>>>t},ebYYs:function(i,t){return i<<t},fAMpO:function(i,t){return i===t},nbBKM:n(1008),HzONm:function(i,t){return i(t)},xfrZF:function(i,t){return i(t)},tkOLx:function(i,t){return i&t},fZwjp:function(i,t){return i(t)},tPrza:n(1148)+n(428)+n(899),sYQGt:n(1308)+n(270),dbEsZ:n(745),BOvJv:n(1458),KlfXM:function(i,t){return i|t},Ozogy:function(i,t){return i<<t},vszRt:function(i,t){return i!==t},WJCFT:n(831),KPIFc:"obvcC",rjQeu:function(i,t){return i+t},iLZAR:n(479)+"ile_name",AOGrn:n(1474)+n(1513),Fagwc:n(344)+n(820),CyUED:"ALL",pnBZa:"INSTANT",PbchS:n(700),tkylD:function(i,t,r,a){return i(t,r,a)},aKaMB:function(i){return i()},eZXMw:n(712),mrUyV:function(i,t){return i!==t},tTmin:n(406),WSGEd:function(i,t){return i(t)},enIae:n(1426)+"r",wyyyC:function(i,t){return i+t},nmeTs:function(i,t){return i!==t},LrdNh:function(i,t){return i&t},Zhqss:function(i,t){return i<<t},gDGYq:function(i,t){return i&t},aCdiu:function(i,t){return i<t},dWJiF:function(i,t){return i===t},tLbyN:n(353),gNFtP:n(733),rCVxb:function(i,t){return i!==t},naoGL:n(312),dzZHh:n(1556),QxgZr:"2|1|0|4|3",KFFgt:function(i,t){return i+t},DGQNo:function(i,t){return i+t},cCGbb:n(1528),irSXZ:function(i,t,r){return i(t,r)},UriAW:n(568)+"s",cKiTq:n(603)+n(1183)+"e",QwUse:function(i,t){return i(t)},QIKCR:function(i,t,r){return i(t,r)},QGsYJ:n(603)+"rsor_value",jaJyY:function(i){return i()},aURdb:function(i,t){return i>t},ygBus:function(i,t){return i+t},XhxHE:function(i){return i()},TcifN:function(i,t){return i&&t},nXvwc:function(i){return i()},dGtIm:function(i,t){return i(t)},WUmPq:function(i){return i()},HSddo:function(i){return i()},VzEwz:"always",pVolg:function(i,t){return i===t},DiXaT:n(1685),WJBAN:function(i,t,r){return i(t,r)},wknwJ:function(i,t){return i===t},efitb:function(i,t,r,a){return i(t,r,a)},vyORs:function(i,t,r){return i(t,r)},Yweio:function(i,t){return i===t},RqZaj:function(i,t,r){return i(t,r)},GnQMa:"bye",yFtHE:function(i,t,r){return i(t,r)},DRnPB:n(882)+n(849),QMNlb:n(1539),FVkxD:function(i,t){return i===t},danoK:n(500)+"rovide v"+n(1317),YsmSa:function(i,t){return i!==t},JVYdg:n(251),XBbLn:function(i,t){return i===t},MwUuB:n(199),OyQAb:n(1072),zzGuJ:function(i,t,r){return i(t,r)},HsckE:"stop immediately reconnect",uVcRl:n(949)+"4",isrTf:n(672),LNIxu:"https:",QOilA:n(1242),RyMjf:n(1698),SZSQk:"bd_did",eWOTU:"device_id",cIrPe:n(1187),mWGPS:n(498),UWbdU:n(1764)+"0",TvxsW:n(330)+"3|4",LCVOx:n(1657),zoSzS:n(1013),jmQpM:"count",tYLkW:function(i){return i()},EsKQM:n(496),bdiQm:"oxORc",fXmow:function(i,t){return i===t},khPaB:"VCIwc",HVWpW:function(i,t){return i!==t},FvJIT:n(1581),VcDTw:function(i,t){return i===t},qQyVv:function(i,t,r){return i(t,r)},OdMbP:"reconnect",jpwot:"start",bUxDN:function(i,t){return i>t},NfBRY:function(i,t,r){return i(t,r)},BuquL:function(i,t){return i!==t},RBUXF:n(1041),WMnhI:n(933),jtojW:function(i,t){return i(t)},iIiHH:"FRONTIER>",OhKug:function(i,t){return i>t},cvcqh:function(i,t,r){return i(t,r)},RdwyV:n(1731)+n(478)+n(576)+n(1213)+n(256),BfJPP:n(1541),kiFHI:n(956),SMGbY:function(i,t,r){return i(t,r)},hrlXj:n(1071)+" try rec"+n(549)+"g",fnruC:function(i,t){return i!=t},tYgDb:n(1166),ReBbA:function(i,t){return i(t)},qOPlV:function(i,t){return i===t},CjjOK:n(1194),yVgXe:n(866),woivg:n(1114)+"4",vocNj:function(i,t){return i===t},umWYp:n(1371),dhcCZ:n(580),ocBcr:n(1724),HCNDi:function(i,t,r){return i(t,r)},xYcyS:function(i,t,r){return i(t,r)},zqYOD:n(1731)+n(212)+n(1630)+n(340),pUhme:n(948),XCpyJ:n(988)+n(1451),OfEqP:"close, ws alread"+n(380),yaYQc:n(1662)+n(652)+n(1604)+"nitialized",PHnMf:function(i,t){return i==t},jhqBk:function(i,t){return i==t},fiUqY:n(228),yNXWV:function(i,t){return i instanceof t},nQkJs:function(i,t){return i(t)},KsZOA:function(i,t){return i(t)},gKUCm:function(i,t){return i(t)},DVMFy:n(500)+n(1483)+n(260)+n(270),cXPRr:function(i,t){return i===t},bfhyC:n(665),WxsID:n(1407),fWcxk:n(1107)+"0",xorjk:n(1740),YkyuD:"ping_onc"+n(802)+"t",XXKBc:function(i,t){return i(t)},qbwBN:n(1602),JZZpt:function(i,t){return i*t},CiDYH:function(i,t){return i*t},wxrex:function(i,t){return i!=t},UDqHQ:n(783),ZUwpN:function(i,t){return i===t},picLB:function(i,t){return i!=t},KmCVw:function(i,t){return i!=t},eTSYP:"Object",oAVAm:function(i,t){return i===t},HpkrL:n(258)+n(753)+"lobalScope",gLQry:function(i,t){return i===t},UIAZu:function(i,t){return i!=t},hjnZI:function(i,t){return i!=t},vXsVS:function(i,t){return i===t},OzBYQ:n(1021)+n(427)+n(690),pmcOV:function(i,t){return i!=t},GakRS:n(229)+n(639)};Fe.r(te),Fe.d(te,{FWS:()=>C0,CustomErrorEvent:()=>Xi,createCloseEvent:()=>De,ReconnectEvent:()=>Yi,createErrorEvent:()=>Ie,decodedFrame:()=>wt,createOpenEvent:()=>rs,CustomCloseEvent:()=>Qi,createReconnectEvent:()=>Rr,FrontierMessageEvent:()=>es,encodeFrame:()=>re,createMessageEvent:()=>ns,OpenEvent:()=>ts,ErrorCode:()=>Ze,Event:()=>bt,MessageEvent:()=>Zi});let s="";function o(i=""){let t=n,r="02",a=""+Date[t(1780)](),x=s||(s=p(i)),f=Math[t(1328)]()[t(1605)](16)[t(1424)](-6);return e[t(1073)](e.VFpvc(e.JduWO(r,a),x),f)}function c(){let i=n;return e[i(1696)](1e4*Date[i(1780)](),Math.floor(e.nmnpD(1e4,Math.random())))}function d(i){let t=n;return e.rRVsx(e[t(429)],e.rzloJ)?this[t(524)]?.[t(1657)](_0x5d634f):e[t(952)](e[t(1420)](Array,8).join("0"),e[t(1682)](parseInt,i,10).toString(2))[t(1424)](-8)}function u(i){let t=n;return(e[t(1420)](Array,4)[t(1453)]("0")+e[t(1265)](parseInt,i,2).toString(16))[t(1424)](-4)}function l(i){let t=n,r={tSqkV:e.cJSVZ,IrsYS:"error",MvNgu:e[t(610)]};if(e[t(1658)](e.bSNKF,"bzAHo")){let a=i[t(1413)](/\./)[t(754)](h=>d(h)),x=[];return x[0]=e[t(1420)](u,a[0]+a[1]),x[1]=u(a[2]+a[3]),["0000",e[t(1240)],e.TEPcf,t(237),e[t(1240)],e.YJNZl,x[0],x[1]][t(1453)]("")}else _0x18f454[t(605)+t(720)+t(396)](UYomjE.tSqkV,_0x3ad4ce),_0x3d67e5[t(605)+t(720)+t(396)](UYomjE[t(364)],_0x42b9b9),_0xd37e77[t(605)+"entListe"+t(396)](UYomjE.MvNgu,_0x461473)}function p(i){let t=n;if(e[t(1287)]!==t(1564)){let r=/(25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?)(\.(25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?)){3}/[t(1646)](i),a=/(([0-9a-fA-F]{1,4}:){7,7}[0-9a-fA-F]{1,4}|([0-9a-fA-F]{1,4}:){1,7}:|([0-9a-fA-F]{1,4}:){1,6}:[0-9a-fA-F]{1,4}|([0-9a-fA-F]{1,4}:){1,5}(:[0-9a-fA-F]{1,4}){1,2}|([0-9a-fA-F]{1,4}:){1,4}(:[0-9a-fA-F]{1,4}){1,3}|([0-9a-fA-F]{1,4}:){1,3}(:[0-9a-fA-F]{1,4}){1,4}|([0-9a-fA-F]{1,4}:){1,2}(:[0-9a-fA-F]{1,4}){1,5}|[0-9a-fA-F]{1,4}:((:[0-9a-fA-F]{1,4}){1,6})|:((:[0-9a-fA-F]{1,4}){1,7}|:)|fe80:(:[0-9a-fA-F]{0,4}){0,4}%[0-9a-zA-Z]{1,}|::(ffff(:0{1,4}){0,1}:){0,1}((25[0-5]|(2[0-4]|1{0,1}[0-9]){0,1}[0-9])\.){3,3}(25[0-5]|(2[0-4]|1{0,1}[0-9]){0,1}[0-9])|([0-9a-fA-F]{1,4}:){1,4}:((25[0-5]|(2[0-4]|1{0,1}[0-9]){0,1}[0-9])\.){3,3}(25[0-5]|(2[0-4]|1{0,1}[0-9]){0,1}[0-9]))/.test(i);return r?e[t(1420)](l,i):a?m(i):e[t(730)]}else{let r=new _0x3d89ca(e[t(1052)](e[t(1052)](e.dUFwd(e.cODZt(_0x2f35eb[e[t(1073)](_0x3debb6,4)],24),e[t(1048)](_0x287337[e[t(1073)](_0x313e2a,5)],16)),e[t(597)](_0x27207d[e.ZXIQJ(_0x3125e0,6)],8)),_0x3eeb57[e.cWIoB(_0x5c9782,7)]),e[t(370)](e[t(1529)](_0x38514a[_0x5cd7ab+0]<<24,_0x51f193[e[t(1155)](_0x4a165c,1)]<<16),e[t(597)](_0x52c0b8[e[t(1331)](_0x4c5122,2)],8))|_0x1cc812[_0x5c5ac8+3],!0);return _0x25dcd5+=8,{value:r,offset:_0x3d50f2+8}}}function m(i){let t=n,r={LAtsw:function(b){return e.isZZf(b)}},a="",x=[],f=0,h=0,w=!0,g=e[t(1240)];if(e[t(1223)](i[t(495)]("::"),-1)){let b=i.split("::");for(let C=0;C<b[t(796)];C++){let O=b[C];if(e[t(1223)](O[t(495)](":"),0)){let R=O.split(":");w&&(f=R.length),h+=R[t(796)];for(let F=0;e[t(308)](F,R[t(796)]);F++)if(e[t(1658)](4,R[F].length)){if(t(315)===e[t(819)])return this[t(443)+"hMessage"+t(1081)](_0x7b377a),r[t(574)](_0x394c37);{let ue=g.substring(0,4-R[F][t(796)]),be=ue[t(632)](R[F]);x[t(1774)](be)}}else x[t(1774)](R[F]);w=!1}else{if(e[t(1666)](4,O[t(796)])){let R=g[t(644)+"g"](0,e.evZjp(4,O[t(796)])),F=R[t(632)](O);x[t(1774)](F)}else x[t(1774)](O);w&&(f+=1),h+=1,w=!1}}let v="";for(let C=0;e[t(739)](C,e[t(303)](8,h));C++)v=v[t(632)](g);for(let C=0;e[t(739)](C,x.length);C++)e[t(846)](C,f)?(a=a.concat(v),a=a[t(632)](x[C])):a=a.concat(x[C]);return a}{let b=i[t(1413)](":");for(let v=0;e[t(995)](v,b.length);v++){let C=b[v];if(e.mYJtb(4,b[v][t(796)])){let O=g[t(644)+"g"](0,e[t(303)](4,b[v][t(796)])),R=O[t(632)](C);a=a.concat(R)}else a=a[t(632)](C)}return a}}function _(i,t){let r=n,a=i[r(1642)];e.rRVsx(void 0,a)&&(e.rufGw(V,t,10),e.ubtAk(le,t,a));let x=i.value;e[r(935)](void 0,x)&&(e[r(1265)](V,t,18),e[r(1739)](le,t,x))}function y(i){let t=n,r={};e:for(;!de(i);){let a=X(i);switch(a>>>3){case 0:break e;case 1:r.key=e[t(1452)](Z,i,X(i));break;case 2:r[t(916)]=e.OLuDN(Z,i,e[t(1420)](X,i));break;default:e[t(1546)](Q,i,e[t(1276)](7,a))}}if(e[t(528)](void 0,r[t(1642)]))throw new Error("Missing "+t(1096)+t(1578)+t(1642));if(e.uIoLH(void 0,r[t(916)]))throw new Error(e[t(914)]);return r}function I(i){let t=n,r=e[t(517)](se);return e[t(1594)](L,i,r),e[t(1568)](pe,r)}function L(i,t){let r=n,a=i[r(1755)];e[r(531)](void 0,a)&&(e[r(926)](V,t,8),e[r(584)](W,t,a));let x=i.LogID;e.ONXxT(void 0,x)&&(e.buKdY!==e[r(1068)]?(this._isBrowser&&_0x5a6942[r(605)+r(720)+r(396)](e.FxhDR,this[r(433)+"nLine"]),this[r(626)+"er"]&&_0x48a923[r(605)+r(720)+r(396)](e[r(589)],this[r(433)+"ffLine"]),this._isBrowser&&_0x3a2278[r(605)+r(720)+r(396)](e[r(722)],this[r(1211)+r(1722)]),this._isBrowser&&_0x1f4563[r(605)+r(720)+r(396)](e[r(885)],this[r(1211)+"ageShow"])):(e[r(694)](V,t,16),e[r(1594)](W,t,x)));let f=i[r(745)];e[r(1695)](void 0,f)&&(V(t,24),e[r(1690)](W,t,K(f)));let h=i[r(430)];h!==void 0&&(e[r(584)](V,t,32),e[r(1682)](W,t,e.hTdXc(K,h)));let w=i[r(951)];if(e.xpfen(void 0,w))for(let ue of w){V(t,42);let be=se();_(ue,be),V(t,be[r(1572)]),e.SXhvl(je,t,be),oe(be)}let g=i[r(900)+r(850)];if(g!==void 0)if(e.iigZA(e[r(1773)],e.iZtQg))e[r(1594)](V,t,50),le(t,g);else{let{pingInterval:ue,pingFrequency:be}=this[r(388)];if((_0x383365[r(1661)]==="hi"&&e.uIoLH(r(797),be)||e.uIoLH("auto",be))&&(this[r(375)+"ngTimer"](),this.emit(e.wVKst,e.dYxnU),this._pingPongTimeoutId=e[r(594)](_0x32a821,this._ping[r(854)](this),ue)),e.TgdQf("hi",_0x236811[r(1661)]))return;try{e[r(751)](_0x13e592,this,_0x14241f,[_0x12bf1c,_0x3b48f9,_0x290bf6,_0x1de593,_0x2a4943,_0x5c318f])}catch(Gt){let mn=e[r(1452)](_0x59fc4b,e[r(1214)],{message:Gt[r(1697)],code:_0x26d72b[r(1392)+r(269)],error:Gt});this[r(443)+"hErrorEvent"](mn)}}let b=i[r(384)+"ype"];e[r(1557)](void 0,b)&&(V(t,58),e[r(1247)](le,t,b));let v=i[r(1097)];e[r(432)](void 0,v)&&(e.qqiAR!==e[r(235)]?e[r(262)](_0x22fc90,_0x69e17e,this[r(1706)+r(444)+"e"](_0x2ddd49)):(e[r(1267)](V,t,66),e[r(1739)](V,t,v[r(796)]),e[r(1546)](ye,t,v)));let C=i[r(234)];e[r(1658)](void 0,C)&&(e.SXhvl(V,t,74),e[r(584)](le,t,C));let O=i[r(1727)+r(1699)];e[r(1557)](void 0,O)&&(e[r(1269)](V,t,82),e[r(1247)](le,t,O));let R=i[r(1765)];e[r(1387)](void 0,R)&&(e[r(845)](V,t,90),le(t,R));let F=i[r(1104)+"e"];e[r(1387)](void 0,F)&&(e[r(763)](V,t,96),e.WjLSS(W,t,e[r(1420)](K,F)))}function T(i){let t=n;return e[t(877)](P,e[t(1597)](Te,i))}function P(i){let t=n,r={};e:for(;!de(i);){let a=e[t(1420)](X,i);switch(a>>>3){case 0:break e;case 1:r[t(1755)]=e[t(594)](dt,i,!0);break;case 2:r.LogID=e[t(763)](dt,i,!0);break;case 3:r[t(745)]=e.mxQlT(X,i);break;case 4:r[t(430)]=e.yFSbq(X,i);break;case 5:{let x=e[t(877)](j,i);(r.headers||(r[t(951)]=[]))[t(1774)](e[t(1597)](y,i)),i.limit=x;break}case 6:r[t(900)+"ncoding"]=e[t(1269)](Z,i,e[t(877)](X,i));break;case 7:r.payloadType=Z(i,e.YtCcr(X,i));break;case 8:r[t(1097)]=z(i,e[t(677)](X,i));break;case 9:r[t(234)]=e[t(1267)](Z,i,X(i));break;case 10:r["serverTi"+t(1699)]=e.vAupn(Z,i,e.kODOc(X,i));break;case 11:r[t(1765)]=e[t(1268)](Z,i,e.YtCcr(X,i));break;case 12:r[t(1104)+"e"]=e[t(877)](X,i);break;default:Q(i,e[t(1276)](7,a))}}if(e[t(1459)](void 0,r[t(1755)]))throw new Error(e[t(1772)]);if(e[t(623)](void 0,r[t(1397)]))throw new Error(e[t(908)]);if(e[t(846)](void 0,r[t(745)]))throw new Error(e[t(696)]);if(e[t(528)](void 0,r[t(430)]))throw new Error(e[t(1718)]);return r}function j(i){let t=n,r=e[t(436)](X,i),a=i.limit;return i[t(1572)]=i.offset+r,a}function Q(i,t){let r=n;if(e[r(1557)](e.sDPXq,e[r(680)]))this[r(285)+"ndpointT"+r(1522)+"t"]=0;else switch(t){case 0:for(;128&ne(i););break;case 2:e[r(1020)](xe,i,e.IQtpa(X,i));break;case 5:xe(i,4);break;case 1:xe(i,8);break;default:throw new Error(e[r(1687)](e[r(811)],t))}}function K(i){let t=n;return i|=0,{low:i,high:i>>31,unsigned:e[t(405)](i,0)}}let $=[];function se(){let i=n,t=$[i(1466)]();return t?(t[i(397)]=t[i(1572)]=0,t):{bytes:new Uint8Array(64),offset:0,limit:0}}function oe(i){$.push(i)}function Te(i){return{bytes:i,offset:0,limit:i[n(796)]}}function pe(i){let t=n,r=i[t(1582)],a=i[t(1572)];return r.length===a?r:r[t(993)](0,a)}function xe(i,t){let r=n;if(e[r(361)](i[r(397)],t)>i[r(1572)])throw new Error(e[r(984)]);i[r(397)]+=t}function de(i){let t=n;if(e[t(1094)](e[t(901)],e[t(901)]))Pqqzol[t(1689)](_0x4ae0d5),Pqqzol[t(698)](_0x52811e);else return e[t(1289)](i[t(397)],i.limit)}function A(i,t){let r=n,a=i[r(1582)],x=i[r(397)],f=i[r(1572)],h=x+t;if(e[r(1223)](h,a[r(796)]))if(e[r(1169)]===e[r(1169)]){let w=new Uint8Array(e[r(612)](2,h));w[r(1651)](a),i.bytes=w}else return this._qosDB.clear();return i.offset=h,h>f&&(i.limit=h),x}function N(i,t){let r=n,a=i[r(397)];if(e.ZPPWU(a,t)>i.limit)throw new Error(e[r(1115)]);return i[r(397)]+=t,a}function z(i,t){let r=n,a=N(i,t);return i[r(1582)][r(993)](a,e[r(357)](a,t))}function ye(i,t){let r=n,a=e[r(355)](A,i,t.length);i[r(1582)][r(1651)](t,a)}function Z(i,t){let r=n,a=N(i,t),x=String["fromChar"+r(1700)],f=i[r(1582)],h="\uFFFD",w="";for(let g=0;e[r(1218)](g,t);g++){let b=f[e[r(1553)](g,a)],v,C,O,R;if(e[r(648)](128&b,0))w+=e[r(677)](x,b);else if(e[r(1276)](224,b)===192)e[r(871)](e[r(230)](g,1),t)?w+=h:(v=f[e[r(488)](e[r(1106)](g,a),1)],e[r(750)](192&v,128)?w+=h:(R=e[r(1048)](e[r(1276)](31,b),6)|e[r(1276)](63,v),e[r(739)](R,128)?w+=h:(w+=e.WFiaS(x,R),g++)));else if(e[r(1571)](e[r(1475)](240,b),224))e.lQtqS(g+2,t)?w+=h:(v=f[e[r(1757)](e.boCKR(g,a),1)],C=f[e[r(1106)](g,a)+2],e[r(1276)](e[r(1052)](v,C<<8),49344)!==32896?w+=h:(R=e[r(1529)](e[r(1529)](e[r(1048)](e[r(1475)](15,b),12),e[r(1616)](63&v,6)),e[r(1475)](63,C)),e[r(995)](R,2048)||e[r(1289)](R,55296)&&e[r(337)](R,57343)?w+=h:(w+=e.zMxJO(x,R),g+=2)));else if(e[r(1571)](248&b,240))if(e[r(405)](e[r(1696)](g,3),t))w+=h;else if(r(1441)==="FFghN")if(v=f[e[r(357)](e[r(361)](g,a),1)],C=f[e[r(488)](e[r(1045)](g,a),2)],O=f[e[r(775)](g,a)+3],e[r(1139)](e[r(1202)](e.kRSkV(v,e.cODZt(C,8))|e[r(1396)](O,16),12632256),8421504))w+=h;else if(R=e[r(839)]((7&b)<<18|e[r(1202)](63,v)<<12|e[r(1202)](63,C)<<6,63&O),e.Ttnud(R,65536)||R>1114111)w+=h;else if(e.QtiqQ(e[r(837)],e[r(837)]))R-=65536,w+=e[r(594)](x,e[r(334)](R>>10,55296),e[r(983)](e.FQrNb(1023,R),56320)),g+=3;else{let F=this[r(524)].getItem(this._prefix),ue=_0x5ad08d[r(636)](F||"{}");return ue[_0x14a0fc]=void 0,this[r(524)][r(824)](this[r(1479)],_0x482e2d.stringify(ue))}else{let F=this._qosDB[r(421)+"geInfoSync"](this._prefix),ue=_0x178d98[r(636)](e.wMoQE(F,"{}"));return _0x52e77d[r(1561)](ue)}else w+=h}return w}function le(i,t){let r=n,a=t[r(796)],x=0;for(let w=0;e[r(308)](w,a);w++){let g=t[r(1380)+"At"](w);g>=55296&&e[r(1633)](g,56319)&&e[r(878)](w,1)<a&&(g=e.gbugi(e.afaVg(e.LIKtY(g,10),t[r(1380)+"At"](++w)),56613888)),x+=g<128?1:e.Ictyw(g,2048)?2:g<65536?3:4}V(i,x);let f=e.bDTmC(A,i,x),h=i[r(1582)];for(let w=0;e[r(739)](w,a);w++){let g=t[r(1380)+"At"](w);g>=55296&&g<=56319&&e[r(995)](w+1,a)&&(g=e.IGafw(g,10)+t[r(1380)+"At"](++w)-56613888),g<128?h[f++]=g:(e[r(995)](g,2048)?h[f++]=e[r(335)](e[r(200)](g,6)&31,192):(e[r(308)](g,65536)?h[f++]=e[r(886)](e[r(1410)](e[r(1231)](g,12),15),224):(h[f++]=e[r(1476)](g>>18,7)|240,h[f++]=e[r(1475)](g>>12,63)|128),h[f++]=e[r(604)](e[r(1231)](g,6)&63,128)),h[f++]=e[r(335)](e[r(1410)](63,g),128))}}function je(i,t){let r=n,a=e.vIHDf(A,i,t.limit),x=i[r(1582)],f=t[r(1582)];for(let h=0,w=t[r(1572)];h<w;h++)x[e[r(954)](h,a)]=f[h]}function ne(i){return i[n(1582)][e.gbHXj(N,i,1)]}function Xe(i,t){let r=n,a=e[r(1e3)](A,i,1);i[r(1582)][a]=t}function X(i){let t=n,r=0,a=0,x;do x=e[t(877)](ne,i),e.dZigs(r,32)&&(a|=e[t(1616)](e[t(366)](127,x),r)),r+=7;while(e.UVtKw(128,x));return a}function V(i,t){let r=n;for(t>>>=0;e.WzgvL(t,128);)e[r(474)](Xe,i,e[r(839)](e[r(649)](127,t),128)),t>>>=7;e[r(694)](Xe,i,t)}function dt(i,t){let r=n,a=0,x=0,f=0,h;return h=e.KOkJH(ne,i),a=e[r(1476)](127,h),e[r(1276)](128,h)&&(h=e.dZXhc(ne,i),a|=e[r(1048)](127&h,7),e[r(386)](128,h)&&(h=e[r(465)](ne,i),a|=(127&h)<<14,e[r(1352)](128,h)&&(h=e[r(1568)](ne,i),a|=e[r(1351)](127&h,21),e[r(1410)](128,h)&&(h=ne(i),x=e[r(649)](127,h),128&h&&(h=e[r(1400)](ne,i),x|=e.IGafw(e[r(1352)](127,h),7),e[r(1475)](128,h)&&(h=e.BbYpg(ne,i),x|=e.snlqI(127,h)<<14,e.FosZq(128,h)&&(h=ne(i),x|=e[r(1756)](127&h,21),e.mnrEh(128,h)&&(h=ne(i),f=e[r(649)](127,h),128&h&&(h=e[r(1447)](ne,i),f|=e[r(1351)](127&h,7)))))))))),{low:e[r(1322)](a,e.KzJmd(x,28)),high:e[r(795)](x,4)|e[r(1756)](f,24),unsigned:t}}function W(i,t){let r=n,a=e[r(795)](t[r(1454)],0),x=e[r(857)](e[r(1720)](t[r(1454)],28),e[r(257)](t.high,4))>>>0,f=e[r(1720)](t.high,24),h=e.ZGymV(0,f)?e.ZGymV(0,x)?e[r(1218)](a,16384)?e.qiQqS(a,128)?1:2:a<2097152?3:4:e[r(308)](x,16384)?x<128?5:6:e[r(1336)](x,2097152)?7:8:f<128?9:10,w=e[r(1671)](A,i,h),g=i[r(1582)];switch(h){case 10:g[e[r(230)](w,9)]=e[r(366)](e.sJzUD(f,7),1);case 9:g[e[r(1106)](w,8)]=e[r(553)](9,h)?e[r(792)](128,f):e.PGDSt(127,f);case 8:g[e[r(954)](w,7)]=e[r(879)](8,h)?e[r(1221)](x,21)|128:e.UrDnl(x>>>21,127);case 7:g[e[r(596)](w,6)]=e[r(1264)](7,h)?e.dUFwd(e[r(313)](x,14),128):e[r(1614)](x>>>14,127);case 6:g[w+5]=e[r(432)](6,h)?e[r(1529)](e.RXmKe(x,7),128):e[r(402)](e.nstmr(x,7),127);case 5:g[e.afaVg(w,4)]=e[r(514)](5,h)?e[r(1446)](128,x):e[r(366)](127,x);case 4:g[e[r(1600)](w,3)]=e[r(1370)](4,h)?e.sJQVs(e[r(1720)](a,21),128):e[r(1098)](e[r(1221)](a,21),127);case 3:g[w+2]=e.bINry(3,h)?e.mLbXF(e[r(313)](a,14),128):e[r(386)](e.sJJmk(a,14),127);case 2:g[e[r(533)](w,1)]=e[r(1133)](2,h)?e[r(945)](e[r(475)](a,7),128):e[r(1488)](e[r(475)](a,7),127);case 1:g[w]=e[r(676)](1,h)?128|a:e[r(1089)](127,a)}}function wt(i){return e[n(677)](T,i)}function re(i){let t=n;return e[t(352)](e[t(1238)],t(703))?e[t(841)](I,i):new _0x3ac472(_0x4860a6)}let _t=65536,we=e[n(1076)],yt=e[n(816)](_t,_t),Ji=e.CiDYH(yt,yt),$i=Ji/2,Qe=String[n(1349)+"e"][n(1380)+"At"];class G{constructor(t,r,a){let x=n;this.isLong=!0,this[x(1454)]=e[x(857)](0,t),this[x(1070)]=0|r,this[x(1381)]=!!a}static[n(872)](t){let r=n;return e.ysgAY(e[r(1257)],r(276))?(_0x3b3c93[r(928)+"t8"]?_0x336196.writeUint8(_0x380e05,_0x15e096):_0x141be5[_0x34d144]=e[r(366)](255,_0xad7737),e.aIgLb(_0x1800ce,1)):t&&e[r(573)](!0,t[r(872)])}static fromBits(t,r,a){let x=n;if(e.UFkrD(e.nXJsU,x(647)))return new G(t,r,a);_0x15e9ec[x(1298)+x(598)]="",_0x50ce6f[x(905)](_0x116672)}static[n(683)+"s"](t,r,a){let x=n;return a?G[x(683)+x(1282)](t,r):G[x(683)+x(295)](t,r)}static["fromByte"+n(1282)](t,r){let a=n;return new G(e.PYIno(e[a(945)](t[0],e.vmYvg(t[1],8)),e[a(1751)](t[2],16))|e.VhytP(t[3],24),e[a(857)](e[a(1385)](t[4]|e.acLsI(t[5],8),e.vmYvg(t[6],16)),e[a(1047)](t[7],24)),r)}static[n(683)+n(295)](t,r){let a=n;return new G(e[a(370)](e[a(839)](e[a(945)](t[4]<<24,t[5]<<16),e[a(1309)](t[6],8)),t[7]),e[a(490)](e.pjwBj(e[a(969)](t[0],24),e[a(431)](t[1],16))|e.laEra(t[2],8),t[3]),r)}static[n(254)](t){let r=n;return e[r(1305)](t,we)?Vi:new G(e[r(1469)](e[r(1175)](e[r(335)](Qe.call(t,0)|e.gsmKZ(Qe.call(t,1),8),e[r(507)](Qe.call(t,2),16)),e.amInm(Qe[r(1182)](t,3),24)),0),e[r(335)](e[r(888)](e[r(792)](Qe[r(1182)](t,4),Qe[r(1182)](t,5)<<8),e[r(1105)](Qe.call(t,6),16)),e[r(1047)](Qe[r(1182)](t,7),24))>>>0,!0)}toHash(){let t=n;return String[t(861)+t(1700)](e[t(268)](255,this[t(1454)]),e[t(386)](this[t(1454)]>>>8,255),e[t(1410)](this.low>>>16,255),e.ntRPE(this.low,24),e[t(366)](255,this[t(1070)]),e.RXmKe(this.high,8)&255,e[t(1276)](e.xKSHS(this[t(1070)],16),255),e[t(343)](this.high,24))}static fromNumber(t,r=!0){let a=n,x={QqTJx:function(f,h){return e[k(1609)](f,h)}};if(e[a(1362)](e[a(963)],e.ZqQGg)){if(isNaN(t))return r?Fc:Vi;if(r)if(e[a(1762)](e[a(300)],e[a(403)])){if(t>=Ji)return qc}else this["_miniNavigatorOn"+a(728)]=_0x3e4c80,_0x15a92d?this[a(433)+a(818)]():this["_handleO"+a(719)]();else if(a(664)===e[a(829)]){if(e[a(752)](t,-$i))return Hc;if(e[a(985)](t,1)>=$i)return Uc}else e[a(1100)](_0xb594b3,this[a(377)+a(653)+"Id"]),_0x510da0(this["_reconne"+a(1010)+a(1421)]),this["_pingPon"+a(653)+"Id"]=null,this[a(1511)+a(1010)+a(1421)]=null;return G[a(629)](e[a(1175)](e[a(551)](t,yt),0),e[a(1179)](e.VkpSl(t,yt),0),r)}else return x.QqTJx(0,this[a(1070)])&&x.QqTJx(0,this[a(1454)])}[n(1173)](){let t=n,r={gkLqL:e[t(814)],XJRWm:function(a,x){return e.qiQqS(a,x)},udEdu:function(a,x){return e[t(1052)](a,x)},kUcfp:function(a,x){return e[t(931)](a,x)},TIFfH:function(a,x){return a<<x},Wpnvz:function(a,x){return e.GQXMe(a,x)},uRHSR:function(a,x){return e[t(1674)](a,x)},ZotzD:function(a,x){return a|x},mIxLP:function(a,x){return e.sXkKB(a,x)},PUYHB:function(a,x){return e[t(1352)](a,x)},ugHCi:function(a,x){return e[t(1389)](a,x)}};if(e[t(400)](e[t(1361)],e.VPNQN))return this[t(1381)]?e[t(348)](e[t(1108)](e.ntRPE(this[t(1070)],0),yt),e[t(795)](this[t(1454)],0)):e.DbnXW(e[t(612)](this[t(1070)],yt),e[t(313)](this[t(1454)],0));{let a={xKmmF:r[t(939)],XSbUh:function(f,h){return r.XJRWm(f,h)},fXeiG:function(f,h){return r[t(1358)](f,h)},UpKdM:function(f,h){return r[t(322)](f,h)},TNGMk:function(f,h){return r[t(1752)](f,h)},wTsxy:function(f,h){return r[t(1555)](f,h)},ZKRqe:function(f,h){return r[t(1747)](f,h)},TlYGy:function(f,h){return r[t(1358)](f,h)},wkMiO:function(f,h){return r[t(925)](f,h)},PuHMT:function(f,h){return r[t(1018)](f,h)},JMdDF:function(f,h,w,g){return f(h,w,g)},CdFQr:function(f,h){return f>>>h},GlciK:function(f,h){return f<<h},hjNcT:function(f,h){return r[t(1738)](f,h)},iMzps:function(f,h){return f|h},dypVO:function(f,h){return r[t(1573)](f,h)}},x=4294967295;return function(f,h,w=!0){let g=t,b=a.xKmmF[g(1413)]("|"),v=0;for(;;){switch(b[v++]){case"0":if(a[g(955)](f[h++],128))return{value:w?x:a[g(1497)](0,x),offset:h};continue;case"1":x=a[g(246)](x|a[g(1782)](a[g(1625)](15,f[h]),28),0);continue;case"2":if(a.XSbUh(f[h++],128))return{value:w?x:a[g(206)](0,x),offset:h};continue;case"3":if(f[h++]<128)return{value:w?x:a[g(1254)](0,x),offset:h};continue;case"4":x=a[g(246)](a[g(1497)](x,a[g(1782)](a[g(1625)](127,f[h]),7)),0);continue;case"5":if(a[g(955)](f[h++],128))return{value:w?x:a[g(1113)](0,x),offset:h};continue;case"6":if(a[g(1654)](h+=5,f[g(796)]))throw h=f[g(796)],a[g(493)](_0x40c2a6,h,10,f[g(796)]);continue;case"7":x=a[g(972)](a[g(1497)](x,a[g(296)](a[g(625)](127,f[h]),21)),0);continue;case"8":return{value:w?x:0|x,offset:h};case"9":if(f[h++]<128)return{value:w?x:a.iMzps(0,x),offset:h};continue;case"10":x=a[g(1625)](127,f[h])>>>0;continue;case"11":x=a.dypVO(x|a[g(1782)](127&f[h],14),0);continue}break}}}}[n(1431)](){let t=n;return e.vROgl(0,this.high)&&e[t(352)](0,this[t(1454)])}[n(1536)](t){let r=n;if(r(595)===e[r(1083)]){if(e[r(1571)](e[r(980)],typeof _0x3d2d87)){let a=new _0x19a5e0(e[r(1659)](_0x17e9e5,_0x54db3b));return e[r(526)](_0x16349f,_0x2b4205,a,0),a}return e[r(210)](_0x3f8e0d,_0x7acd5b)?new _0x1dbf12(_0x5a58e7):new _0x11b4db(_0x2d29b5[r(1054)],_0x3bdca0[r(1085)+"et"],_0x24c83d[r(1062)+"th"])}else{G.isLong(t)||(t=G.fromNumber(t));let a=e.ntRPE(this[r(1070)],16),x=65535&this[r(1070)],f=e[r(572)](this.low,16),h=e[r(386)](65535,this[r(1454)]),w=t[r(1070)]>>>16,g=e[r(732)](65535,t.high),b=e[r(931)](t[r(1454)],16),v=e[r(386)](65535,t[r(1454)]),C=0,O=0,R=0,F=0;return F+=e.Zjnes(h,v),R+=e[r(915)](F,16),F&=65535,R+=e[r(746)](f,b),O+=R>>>16,R&=65535,O+=e[r(533)](x,g),C+=O>>>16,O&=65535,C+=e[r(746)](a,w),C&=65535,G[r(629)](e[r(1446)](R<<16,F),e[r(597)](C,16)|O,this[r(1381)])}}[n(902)](t){let r=n;return G[r(872)](t)||(t=G[r(764)+"er"](t)),e[r(1133)](this[r(1381)],t[r(1381)])&&e[r(1596)](e[r(1221)](this.high,31),1)&&e.qrmhn(t[r(1070)],31)===1?!1:this[r(1070)]===t[r(1070)]&&e[r(846)](this[r(1454)],t[r(1454)])}[n(552)](){let t=n;return this[t(1454)]===-1&&e.VcCdt(-1,this[t(1070)])?G[t(629)](0,0,this[t(1381)]):e[t(227)](-1,this[t(1454)])?G[t(629)](0,e[t(985)](this.high,1),this[t(1381)]):G[t(629)](e[t(1004)](this[t(1454)],1),this[t(1070)],this[t(1381)])}[n(1785)](t){let r=n;return t?this[r(1249)+"E"]():this[r(1136)+"E"]()}[n(1249)+"E"](){let t=n,r=this.high,a=this[t(1454)];return[255&a,e[t(263)](e[t(411)](a,8),255),e.KVkhV(e[t(645)](a,16),255),a>>>24,e[t(1352)](255,r),e[t(1221)](r,8)&255,e[t(366)](e[t(834)](r,16),255),e.dCxNh(r,24)]}[n(1136)+"E"](){let t=n,r=this.high,a=this.low;return[e[t(645)](r,24),e[t(1475)](e.jtrot(r,16),255),e[t(1488)](e[t(216)](r,8),255),e[t(366)](255,r),e[t(216)](a,24),e[t(1154)](a>>>16,255),e[t(571)](a>>>8,255),255&a]}}let Vi=new G(0,0,!1),Fc=new G(0,0,!0),Uc=G[n(629)](-1,2147483647,!1),qc=G[n(629)](-1,-1,!0),Hc=G[n(629)](0,-2147483648,!1);var Ze=(function(i){let t=n;return i[i[e[t(1406)]]=5001]=e.hYWnN,i[i[e[t(800)]]=5002]=e[t(800)],i[i[e[t(994)]]=5003]=e.pFqlB,i[i[e[t(473)]]=5004]=e[t(473)],i[i[e[t(1376)]]=5005]=e[t(1376)],i})({});class bt{constructor(t){let r=n;this.type=t,this[r(1134)]=null}}class Yi extends bt{constructor(t,r){let a=n;super(t),this[a(1697)]=r&&r[a(1697)]||null}}class Xi extends bt{constructor(t,r){let a=n,x=e[a(1341)].split("|"),f=0;for(;;){switch(x[f++]){case"0":this[a(321)]=r&&r.error||null;continue;case"1":this.filename=r&&r.filename||"";continue;case"2":this[a(1697)]=r&&r[a(1697)]||"";continue;case"3":this[a(937)]=r&&r.lineno||0;continue;case"4":super(t);continue;case"5":this[a(1140)]=r&&r.colno||0;continue;case"6":this[a(1532)]=r&&r[a(1532)]||5001;continue}break}}}class Qi extends bt{constructor(t,r){let a=n,x={HKlaD:function(f,h,w){return f(h,w)},rVIJE:function(f){return e[k(1689)](f)},AmkrN:function(f,h,w){return e[k(365)](f,h,w)},cSzWs:function(f,h){return e.wRshH(f,h)}};if(e[a(1011)]===e[a(1011)]){let f=e[a(1636)].split("|"),h=0;for(;;){switch(f[h++]){case"0":this.reason=r&&r[a(723)]||"";continue;case"1":super(t);continue;case"2":this.code=r&&r[a(1532)]||0;continue;case"3":this[a(1432)+a(287)]=r&&r[a(1432)+a(287)]||!1;continue;case"4":this[a(1587)]=r&&r.wasClean||!1;continue}break}}else{cwcUjk[a(329)](_0x384fff,_0x4a0f3a,42);let f=cwcUjk[a(281)](_0x4ffe0a);cwcUjk[a(329)](_0x39d82e,_0x13e119,f),cwcUjk[a(1460)](_0x324db3,_0x587a34,f.limit),_0x5246e2(_0x4dbf76,f),cwcUjk.cSzWs(_0x737f68,f)}}}class Zi extends bt{constructor(t,r){let a=n;if(e[a(502)](e[a(499)],e.arJQq))super(t),this[a(1661)]=r&&r[a(1661)]||null;else return new _0x506ca9(_0x562cf7,{data:_0x51a9a0})}}class es extends Zi{constructor(t,r){let a=n;super(t),this[a(1661)]=r&&r[a(1661)]||null,this.message=r&&r[a(1697)]||null}}class ts extends bt{constructor(t,r){let a=n;super(t),this[a(1661)]=r&&r[a(1661)]||null}}function Ie(i,{message:t,code:r,error:a}){return new Xi(i,{message:t,code:r,error:a})}function De(i,{code:t,reason:r,wasClean:a,willReconnect:x}){return new Qi(i,{code:t,reason:r,wasClean:a,willReconnect:x})}function ns(i,{data:t,message:r}){let a=n,x={weHml:function(f,h){return e.Najbj(f,h)},PUDcG:e[a(1712)]};if(e[a(1230)]!==e[a(1084)])return new es(i,{data:t,message:r});if(_0x48e302)return new _0x44e7f3(_0xa590fd[a(1781)],_0x11f697[a(1408)]);if(x[a(1330)](_0x3a37c6,_0x50654f))return new _0x2fcea8(_0x2c1a30[a(1781)],_0x4b71c0[a(1408)],_0xbd76c8[a(951)]);if(x[a(1330)](_0xcb1442,_0x554326)&&x[a(492)]!=typeof _0x14a1ee&&_0x567c99)return new _0xebee8e(_0x125bc5.url,_0x1ea8a8.protocols)}function rs(i,{data:t}){return new ts(i,{data:t})}function Rr(i,{message:t}){return new Yi(i,{message:t})}class is{constructor(t,r){let a=n,x={NSIjW:function(f,h){return e[k(1596)](f,h)},wuOFY:e[a(1214)],UMFmE:function(f,h){return e.ktGgA(f,h)},dtrNr:function(f,h){return f+h},MmWGO:a(1150)+a(1433),FmDXs:function(f,h){return e.fOzds(f,h)},gQmfx:function(f,h){return e.ELJdu(f,h)}};if(e[a(855)]!==e[a(855)]){let f=this[a(1750)+"rs"][_0x207960];if(f)f[a(1424)]()[a(1519)](h=>h.fn[a(1063)](h[a(419)],_0x29e240));else if(x[a(1693)](x.wuOFY,_0x227c35)&&!this.onerror){let h=_0x2343aa.length&&_0x206dd4[0];if(x[a(376)](h,_0x3d744a))throw h;let w=new _0x2e1ef3(x[a(1643)](x[a(1726)],h?x[a(946)](x.gQmfx(" (",h[a(1697)]),")"):""));throw w[a(446)]=h,h}return this}else this[a(464)+"s"]=t,this[a(1032)+"es"]=r,this[a(756)+a(1471)]=0,this[a(285)+a(327)+"riesCount"]=0}[n(226)+n(404)+"fig"](){let t=n,r={vPYIO:function(a,x,f){return a(x,f)},qOUpC:function(a,x){return e[k(1438)](a,x)},oBoPx:function(a,x){return e[k(842)](a,x)}};if(t(482)!==t(482)){let a=0,x=_0x15824d,f=_0x169cda+4;for(;x<f;){let{value:h,offset:w}=r.vPYIO(_0x363b4e,_0x4258ae,x);x=w,a=r[t(394)](r[t(1028)](a,8),0),a+=h}return{value:a,offset:f}}else this[t(756)+t(1471)]=0,this[t(285)+"ndpointT"+t(1522)+"t"]=0}resetTries(){let t=n;this[t(285)+t(327)+t(1522)+"t"]=0}[n(695)+n(1180)+"nt"](){let t=n;return this[t(464)+"s"][this[t(756)+"ndex"]]}[n(695)+n(1180)+"ntTriesC"+n(1053)](){let t=n;return this["currentE"+t(327)+t(1522)+"t"]}[n(874)+"chMaxTries"](){let t=n;return!!(e[t(1289)](this["currentI"+t(1471)],this[t(464)+"s"][t(796)])||e[t(236)](this.currentIndex,e[t(1526)](this[t(464)+"s"][t(796)],1))&&this[t(285)+"ndpointT"+t(1522)+"t"]===this[t(1032)+"es"])}["checkCurrentEndp"+n(345)+n(325)+n(1055)](){let t=n;if(e.gzVnK(t(876),"VsvIk"))this[t(657)](_0x302b7c,_0x59e9c9);else return this[t(756)+t(1471)]==this[t(464)+"s"][t(796)]?!0:e.SFxCa(this["currentE"+t(327)+t(1522)+"t"],this[t(1032)+"es"])}[n(286)+n(1445)+n(1624)+"UpdateCo"+n(825)](){let t=n,r={EGsas:function(a,x){return e[k(1568)](a,x)}};if(e[t(771)]!==e[t(771)])eVpmRq[t(1311)](_0x402e66,eVpmRq.EGsas(_0x60e083,_0x47ae1f[t(679)])),_0x3dcbbe();else return this[t(285)+t(327)+t(1522)+"t"]=1,this.currentIndex++,this[t(464)+"s"][this[t(756)+"ndex"]]}["getCurre"+n(1180)+n(459)+n(600)](){let t=n;return this[t(285)+t(327)+t(1522)+"t"]++,this[t(695)+t(1180)+"nt"]()}}let vt=(e[n(1201)](e[n(1712)],typeof globalThis)&&e[n(456)]===globalThis.constructor.name||e.IRDTh!=typeof window&&e[n(1652)](e[n(456)],window[n(379)+"tor"][n(310)]))&&e.picLB(e[n(1712)],typeof document),ut=e[n(740)](e[n(1712)],typeof globalThis)&&(e[n(747)]===globalThis["construc"+n(1492)][n(310)]||e.oAVAm(e[n(575)],globalThis[n(379)+n(1492)][n(310)]))&&e[n(1201)](e.IRDTh,typeof tt),jt=(e[n(835)](e[n(1712)],typeof globalThis)&&e[n(1188)](e[n(747)],globalThis["construc"+n(1492)][n(310)])||e.tWTOO(e[n(1712)],typeof globalThis)||e[n(1712)]!=typeof globalThis&&!!globalThis[n(1705)+"Bridge"])&&e.UIAZu(e.IRDTh,typeof wx),Kt=e[n(1435)](e[n(1712)],typeof globalThis)&&(e[n(1023)](n(258)+n(753)+n(1462)+"pe",globalThis[n(379)+n(1492)][n(310)])||e.VcDTw(n(1692)+n(909)+n(1653),globalThis[n(379)+n(1492)].name)||e[n(1165)](e[n(1037)],globalThis["construc"+n(1492)][n(310)]))&&e.MyIFR(e.IRDTh,typeof self),jc=e[n(450)](e.IRDTh,typeof globalThis)&&e[n(747)]===globalThis[n(379)+n(1492)][n(310)]&&e[n(742)](e.IRDTh,typeof global)&&e[n(747)]===global[n(379)+"tor"][n(310)]&&e[n(1435)](e[n(1712)],typeof process)&&!!process[n(1515)];class Lr{constructor(){let t=n;e[t(328)](e.LEVLa,e[t(1093)])?this[t(1750)+"rs"]={}:(this[t(872)]=!0,this.low=0|_0x223b4b,this[t(1070)]=e[t(1463)](0,_0x19b3d5),this[t(1381)]=!!_0x138753)}[n(1216)](t,...r){let a=n,x=this._listeners[t];if(x)x[a(1424)]()[a(1519)](f=>f.fn[a(1063)](f.ctx,r));else if(e.okwUm(a(321),t)&&!this[a(440)]){let f=r[a(796)]&&r[0];if(e[a(457)](f,Error))throw f;let h=new Error(e[a(1374)](e[a(215)],f?e[a(1280)](e[a(368)](" (",f[a(1697)]),")"):""));throw h[a(446)]=f,f}return this}[n(657)](t,r){let a=n;if(t===void 0)this[a(1750)+"rs"]={};else if(e[a(1486)](void 0,r))this[a(1750)+"rs"][t]=null;else if(e.RXaMB(e.OTgtC,e[a(1283)])){let x=this._listeners[t];if(x)for(let f=0;e[a(995)](f,x[a(796)]);)e[a(1023)](x[f].fn,r)?x.splice(f,1):++f}else _0xf3c3.resolve()[a(317)](()=>{this[a(718)+"steners"]()});return this}on(t,r,a){let x=n;return(this._listeners[t]||(this[x(1750)+"rs"][t]=[]))[x(1774)]({fn:r,ctx:a||this}),this}}class Kc extends Lr{[n(1015)+n(602)+n(1122)](t){let r=n;return t[r(1049)]||t.errNo?(r(271)+" "+(t[r(1049)]||"")+r(1290)+(t[r(1220)]||""))[r(274)]():JSON[r(1577)+"y"](t)}constructor(t,r,a){let x=n;super(),this[x(958)]=null,jt&&wx[x(525)+x(1592)]&&(this[x(958)]=wx[x(525)+x(1592)]({url:t,protocols:r,header:a,fail:this[x(1461)+"ocketFai"+x(565)][x(854)](this),success:this["_createS"+x(1590)+"cessHand"+x(359)].bind(this)})),ut&&tt[x(525)+x(1592)]&&(this[x(958)]=tt[x(525)+x(1592)]({url:t,protocols:r,header:a,fail:this[x(1461)+x(1711)+x(565)][x(854)](this),success:this[x(1461)+x(1590)+x(255)+x(359)].bind(this)}))}[n(1461)+"ocketSuc"+n(255)+n(359)](){let t=n;Promise[t(1143)]()[t(317)](()=>{let r=t,a={ufczK:function(x,f){return x|f},qTEiY:function(x,f){return x&f},ZoVWl:function(x,f){return e[k(964)](x,f)},xeXsV:function(x,f){return e[k(839)](x,f)},qEbcA:function(x,f){return x>>f},kUdXB:function(x,f){return x|f},IUeln:function(x,f){return x>>f},tsQnp:function(x,f){return x|f},JdczC:function(x,f){return e[k(945)](x,f)}};e[r(1429)]===r(1285)?(_0x3134a5<2048?_0x379969[_0x39894b++]=JqBswd[r(1205)](_0x236734>>6&31,192):(_0x2e17ec<65536?_0x3b2084[_0x5639a4++]=JqBswd[r(484)](JqBswd[r(1219)](_0x5b0c5f,12),15)|224:(_0x20b195[_0x406a5e++]=JqBswd[r(826)](JqBswd[r(484)](JqBswd[r(1401)](_0x5b2c51,18),7),240),_0x1dd279[_0x1733ea++]=JqBswd.kUdXB(JqBswd.IUeln(_0x1bcd3e,12)&63,128)),_0x43cd06[_0x1b1166++]=JqBswd[r(1640)](JqBswd[r(484)](_0x448382>>6,63),128)),_0x5444ba[_0x384e09++]=JqBswd.JdczC(JqBswd[r(484)](63,_0x17b301),128)):this[r(718)+r(1195)]()})}[n(1461)+n(1711)+"lHandler"](t){let r=n,a={EUdkz:function(x,f,h){return e[k(1741)](x,f,h)},Ncrof:e[r(1214)],hxnMz:e[r(587)]};e[r(1627)](e[r(1281)],e[r(978)])?(_0x1ae29d[r(692)+r(1422)]=void 0,e[r(758)](_0x218ae3,e[r(765)])):Promise[r(1143)]()[r(317)](()=>{let x=r,f=a[x(616)](Ie,x(321),{message:this[x(1015)+x(602)+"age"](t)});this[x(1216)](a[x(1087)],f);let h=De(a.hxnMz,{reason:this[x(1015)+x(602)+x(1122)](t)});this[x(1216)]("close",h)})}[n(718)+"steners"](){let t=n,r={PivNj:function(a,x,f){return e[k(1759)](a,x,f)},wWHJL:function(a,x){return e[k(927)](a,x)},iLfQT:function(a,x){return e[k(995)](a,x)},yBiHC:function(a,x){return e[k(307)](a,x)},Dpucr:function(a,x){return a<x},WJpdM:function(a,x){return a<=x},PgLgz:function(a,x){return a>=x},rifex:function(a,x){return a|x},UXBYR:function(a,x){return a<<x},hlcxN:function(a,x){return e[k(205)](a,x)},DaALv:function(a,x){return a<<x},GbUNo:function(a,x){return e[k(1476)](a,x)},NyAoU:function(a,x){return e.WkEjK(a,x)},PLqDP:function(a,x){return a+x},muwYZ:e.FnxYW,nRPvf:e[t(863)],YttNq:function(a,x,f){return e[t(1759)](a,x,f)},Gdyxi:e[t(587)],quHEO:function(a,x,f){return a(x,f)}};if(e[t(332)](t(1623),e[t(1158)])){if(this[t(289)]&&this._ws[t(201)+"te"]===this[t(1579)+"NG"]){this[t(375)+t(1189)](),this[t(377)+"gTimeoutId"]=r[t(1384)](_0x4ff9ab,this[t(1481)].bind(this),this[t(388)][t(318)+t(316)]);return}if(!this[t(289)]||r[t(1620)](this[t(289)].readyState,this[t(1664)]))return void this[t(1092)+t(1345)]();this[t(289)]&&this._ws[t(530)]("hi"),this[t(1511)+"ctTimeou"+t(1421)]=r[t(1384)](_0x19a082,this[t(1092)+t(1345)+t(1763)][t(854)](this),this[t(388)][t(1547)+t(793)+t(476)])}else this[t(958)][t(279)](a=>{let x=t,f={Gkhcc:function(h,w){return r[k(1675)](h,w)},bUNPa:function(h,w){return r[k(675)](h,w)},RFXXd:function(h,w){return r.Dpucr(h,w)},PCGeZ:function(h,w){return r.WJpdM(h,w)},KLRPt:function(h,w){return r[k(1423)](h,w)},gJPld:function(h,w){return r[k(224)](h,w)},ADPFm:function(h,w){return r[k(1002)](h,w)},ZJxsy:function(h,w){return r[k(1404)](h,w)},jmInp:function(h,w){return r.DaALv(h,w)},VidbI:function(h,w){return h|w},SQNrU:function(h,w){return r[k(417)](h,w)},GBEqy:function(h,w){return h<<w},TLxjg:function(h,w){return r.NyAoU(h,w)},KppDU:function(h,w){return r[k(836)](h,w)}};if(r.wWHJL(r[x(222)],x(351)))this[x(1216)](r[x(638)],r[x(314)](rs,r[x(638)],{...a,data:a[x(1049)]||""}));else{if(f[x(1464)](f[x(646)](_0x6d6371,_0x581027),1))return"";let h="";for(let w=_0x54cc0e;f[x(1500)](w,_0x1eb4b0);){let g=_0x3682ef[w++];if(f[x(843)](g,127))h+=_0x12ae46[x(861)+x(1700)](g);else if(f[x(1688)](g,192)&&f.Gkhcc(g,224))h+=_0x306656[x(861)+x(1700)](f[x(1199)](f[x(1525)](31&g,6),f[x(480)](63,_0x2dced2[w++])));else if(f[x(1688)](g,224)&&f[x(1464)](g,240))h+=_0x4b71a8[x(861)+"Code"](f[x(1199)](f[x(1199)](f[x(1525)](15&g,12),f[x(918)](63&_0x2960f2[w++],6)),f[x(480)](63,_0x3ccf84[w++])));else if(f[x(1688)](g,240)){let b=f[x(646)](f[x(894)](f[x(1525)](f[x(1448)](7,g),18),f[x(196)](f[x(1448)](63,_0x3d8ec7[w++]),12))|f[x(1525)](63&_0x35f6d9[w++],6)|f[x(480)](63,_0x20d240[w++]),65536);h+=_0x1d83c4[x(861)+"Code"](55296+f.TLxjg(b,10)),h+=_0x18d7c6[x(861)+"Code"](f[x(503)](56320,f[x(1448)](1023,b)))}}return h}}),this[t(958)].onClose(a=>{let x=t;this[x(1216)](r[x(1709)],r[x(847)](De,r[x(1709)],{...a}))}),this[t(958)].onMessage(a=>{let x=t;this.emit(e[x(1284)],e[x(1732)](ns,e[x(1284)],{...a}))}),this[t(958)][t(1260)](a=>{let x=t;this[x(1216)](x(321),Ie(x(321),{...a,message:a[x(1049)]||""}))})}send(t){let r=n,a={cnSQO:r(321),vAToI:function(x,f,h){return e.IhUIJ(x,f,h)}};if(t instanceof Uint8Array){let x=t[r(1054)][r(1424)](t[r(1085)+"et"],e[r(1558)](t[r(1062)+"th"],t.byteOffset));this[r(958)]&&this._socket[r(530)]({data:x,fail:f=>{let h=r;this[h(1216)](e[h(1214)],Ie(h(321),{message:this[h(1015)+h(602)+h(1122)](f)}))}})}else this[r(958)]&&this[r(958)].send({data:t,fail:x=>{let f=r;this[f(1216)](a[f(1632)],a[f(868)](Ie,a[f(1632)],{message:this[f(1015)+f(602)+f(1122)](x)}))}})}[n(1360)](t,r){this._socket&&this._socket.close({code:t,reason:r})}[n(884)+n(1425)](t,r){this.on(t,r)}[n(605)+"entListe"+n(396)](t,r){this[n(657)](t,r)}get[n(201)+"te"](){let t=n;return this[t(958)][t(201)+"te"]}get[n(1704)+"pe"](){return this[n(958)].binaryType}set[n(1704)+"pe"](t){}get[n(1781)](){return this[n(958)].url}get[n(1408)](){let t=n;return this._socket[t(1408)]}get[n(1617)+"ns"](){let t=n;return this._socket[t(1617)+"ns"]}get[n(891)+"Amount"](){return 0}}function Gc(i,t){let r=n;if(t)return new t(i.url,i[r(1408)]);if(e[r(789)](jt,ut))return new Kc(i.url,i[r(1408)],i.headers);if(e[r(789)](vt,Kt)&&r(1631)+"d"!=typeof WebSocket&&WebSocket)return new WebSocket(i[r(1781)],i.protocols)}function Wc(i){let t=n,r=e[t(650)][t(1413)]("|"),a=0;for(;;){switch(r[a++]){case"0":if(i)return!0;continue;case"1":if(ut&&tt[t(525)+t(1592)])return!0;continue;case"2":if(e[t(789)](vt,Kt)&&e.IRDTh!=typeof WebSocket&&WebSocket)return!0;continue;case"3":if(jt&&wx[t(525)+t(1592)])return!0;continue;case"4":return!1}break}}function ss(i,t,r){let a=n,x={ZkgLA:function(f,h){return e[k(337)](f,h)},JepZI:function(f,h){return f===h},GNunv:function(f,h){return e[k(447)](f,h)}};if(e[a(400)](e[a(1334)],e[a(1334)])){let f=-1;async function h(w){let g=a;return x[g(1138)](w,f)?Promise[g(439)](new Error("next() called mu"+g(1742)+"imes in "+g(1248))):(f=w,x[g(319)](w,r.length)?Promise[g(1143)]():r[w][g(854)](i)(t,h[g(854)](null,x[g(581)](w,1))))}e[a(758)](h,0)}else return _0xc87e73&&e.WISDf(!0,_0x432389.isLong)}function os(i){let t=n,r=0,a=0;for(let x=0;e.WxWSB(x,i[t(796)]);++x)a=i[t(1380)+"At"](x),e[t(585)](a,128)?r+=1:e[t(1442)](a,2048)?r+=2:e[t(1098)](64512,a)===55296&&e.uIoLH(e.rSztB(64512,i[t(1380)+"At"](e.vdjPt(x,1))),56320)?(++x,r+=4):r+=3;return r}function as(i,t,r){let a=n;if(e.FIFVL(e[a(606)](r,t),1))return"";let x="";for(let f=t;e[a(555)](f,r);){let h=i[f++];if(e.NXKss(h,127))x+=String["fromChar"+a(1700)](h);else if(e[a(415)](h,192)&&e.hYsKK(h,224))x+=String[a(861)+a(1700)](e[a(1052)](e[a(1703)](31,h)<<6,e[a(1373)](63,i[f++])));else if(e[a(1246)](h,224)&&e[a(1224)](h,240))x+=String.fromCharCode(e[a(1645)](e.iIYgr((15&h)<<12,e[a(382)](e[a(577)](63,i[f++]),6)),63&i[f++]));else if(h>=240)if(e[a(1094)](e[a(383)],e.HqKEk)){let w=e[a(1372)](e[a(1372)](e[a(1181)](7&h,18),e.mqHtZ(63&i[f++],12))|e[a(253)](e[a(1614)](63,i[f++]),6),e[a(1043)](63,i[f++]))-65536;x+=String[a(861)+a(1700)](55296+e[a(964)](w,10)),x+=String[a(861)+"Code"](e.SmfAX(56320,e.UrDnl(1023,w)))}else return _0x40cfef[a(872)](_0x3544e3)||(_0x2004aa=_0x30f9a7[a(764)+"er"](_0x2a99fe)),e[a(1489)](this[a(1381)],_0x3a38a2[a(1381)])&&e[a(250)](e[a(1259)](this.high,31),1)&&e[a(851)](_0x304f21[a(1070)],31)===1?!1:this[a(1070)]===_0x351219[a(1070)]&&e[a(328)](this[a(1454)],_0x56f35a[a(1454)])}return x}function Or(i,t,r){let a=n,x={yUpPj:function(g,b){return e[k(470)](g,b)},LFwrf:function(g,b){return g>=b},jCPqb:function(g,b){return e[k(635)](g,b)},tVaMD:function(g,b){return e.ccjrd(g,b)},RsOGo:function(g,b){return e.lUjCO(g,b)},xfmQW:function(g,b){return g/b}},f=r,h,w;for(let g=0;e.FIFVL(g,i[a(796)]);++g)if(e[a(787)]===e[a(787)])if(h=i[a(1380)+"At"](g),e[a(1468)](h,128))t[r++]=h;else if(h<2048)t[r++]=e[a(1179)](e[a(1231)](h,6),192),t[r++]=e[a(350)](e.FQrNb(63,h),128);else if(e[a(291)](e[a(1576)](64512,h),55296)&&e[a(1159)](e.IxSuT(64512,w=i[a(1380)+"At"](e[a(775)](g,1))),56320)){let b=e.gxRXI[a(1413)]("|"),v=0;for(;;){switch(b[v++]){case"0":t[r++]=e.uvHcg(h>>18,240);continue;case"1":t[r++]=e[a(350)](e[a(1703)](h>>12,63),128);continue;case"2":t[r++]=e[a(412)](e.EYUBI(63,h),128);continue;case"3":h=e[a(1042)](e[a(533)](65536,e[a(1203)](e[a(940)](1023,h),10)),1023&w);continue;case"4":t[r++]=e.LcysV(e[a(975)](h>>6,63),128);continue;case"5":++g;continue}break}}else if(a(1258)===e[a(707)])t[r++]=e[a(453)](e[a(1545)](h,12),224),t[r++]=e.EOkxY(e[a(1619)](e[a(1231)](h,6),63),128),t[r++]=e.GuYBs(e[a(571)](63,h),128);else{if(QfbbKs[a(1615)](_0x154858,_0x49091c))return _0x5c5dc4?_0x4a7956:_0x2e45bf;if(_0x384a20){if(QfbbKs[a(702)](_0x10af83,_0x43bb77))return _0x48470c}else{if(_0x111a21<=-_0x8463b8)return _0x18b515;if(QfbbKs[a(702)](QfbbKs.jCPqb(_0x2a291b,1),_0x115ad9))return _0x52b121}return _0x1a7aff.fromBits(QfbbKs[a(1236)](QfbbKs[a(892)](_0x208187,_0x136a3b),0),QfbbKs[a(1236)](QfbbKs[a(1784)](_0x1bb35c,_0x31674a),0),_0x118348)}else{let b=this[a(240)+a(302)]?.[a(695)+a(1180)+"nt"]();this._debug(a(1123)+b+a(1038)),this["_disconn"+a(1717)](1001,a(1071)+a(391)+a(549)+"g",!0)}return e.evZjp(r,f)}async function cs(i){let t=n;if(e[t(1301)](e.UaeLL,typeof i)){let r=new Uint8Array(os(i));return e[t(526)](Or,i,r,0),r}return e[t(862)](i,ArrayBuffer)?new Uint8Array(i):new Uint8Array(i[t(1054)],i.byteOffset,i[t(1062)+"th"])}function Jc(i){let t=n,r={wktIs:function(a,x){return e[k(1346)](a,x)},DNyzl:function(a,x){return e[k(1196)](a,x)},oLpjh:function(a,x){return e[k(1760)](a,x)},NYxON:function(a,x){return a<<x},lyyjK:function(a,x){return e[k(779)](a,x)},HzoZi:function(a,x){return e[k(1314)](a,x)},MGvIa:function(a,x){return a>x},ezSfa:function(a,x,f){return e[k(355)](a,x,f)},EDQhO:function(a,x){return e[k(1280)](a,x)},JUckI:function(a,x){return a>>x},MSVKt:function(a,x){return e.vPuiZ(a,x)}};try{return t(1253)===e[t(682)]?e[t(1510)]("string",typeof i)&&(e[t(534)](i,ArrayBuffer)||i[t(1054)]&&i[t(1054)]instanceof ArrayBuffer)||e[t(835)](e[t(980)],typeof i)?"":(JSON.parse(i),e.xQelJ):void 0}catch{if(e.ccwBZ(e.Jtxnb,"tfvTJ"))return t(410)==typeof i?"text/plain;charset=utf-8":"";_0x516a4a=OpbALI[t(761)](OpbALI[t(761)](OpbALI[t(1562)]((7&_0x3b8b52)<<18,OpbALI[t(560)](63&_0x5a8ff3,12)),OpbALI[t(371)](OpbALI.lyyjK(63,_0x5f27fa),6)),OpbALI[t(987)](63,_0x5d31d3)),OpbALI[t(437)](_0x4c4603,65536)||OpbALI[t(1560)](_0x199525,1114111)?_0x57bf65+=_0x477344:(_0x360dbd-=65536,_0xd0efa5+=OpbALI[t(1618)](_0x845a47,OpbALI[t(790)](OpbALI.JUckI(_0x59cb24,10),55296),OpbALI[t(944)](OpbALI.lyyjK(1023,_0x3ab7f9),56320)),_0x40016c+=3)}}let $c=(i,t)=>{let r=n,a={tmbIw:function(x,f){return e.SFFXa(x,f)},HOHwU:e[r(870)],nhzgi:r(1723)+r(1209)+"s"};if(e[r(1567)](r(1237),e[r(1304)]))switch(i){case e.GWBtw:case e[r(1022)]:return{[r(1051)+i]:1,"x-tt-env":t};default:return{}}else a[r(1080)](_0xffd24f,a[r(713)]),Y[r(657)](a[r(1112)],_0x3fb4a9),Y[r(657)](r(1723)+r(802)+"t",_0x2f9ce3)};class Vc{constructor(t){let r=n;this[r(1603)+r(1053)]=t,this.count=0}[n(614)](){this.count++}["checkRea"+n(1245)+"nt"](){let t=n,r={TroCA:function(a,x){return e[k(1023)](a,x)},ICmRn:function(a,x){return e[k(1596)](a,x)},qIvcf:function(a,x){return e[k(827)](a,x)},eAMml:function(a,x){return e[k(332)](a,x)}};if(e[t(1627)](t(451),e.ndHgx))return e.lQtqS(this[t(1271)],this[t(1603)+t(1053)]);if(nEtWUR[t(1608)](void 0,_0x444857))this[t(1750)+"rs"]={};else if(nEtWUR.ICmRn(void 0,_0x170c9b))this[t(1750)+"rs"][_0x3794c2]=null;else{let a=this[t(1750)+"rs"][_0x37511c];if(a)for(let x=0;nEtWUR[t(259)](x,a[t(796)]);)nEtWUR.eAMml(a[x].fn,_0x566f91)?a[t(1074)](x,1):++x}return this}[n(971)+n(1321)](t=0){let r=n;this[r(1603)+r(1053)]=t,this[r(1271)]=0}}async function Yc(i){let t={RvlvW:e.xwpiu};return new Promise(r=>{let a=k;if(!vt)return e[a(1447)](r,"unknown "+a(723));try{let x=document[a(1326)+"ement"](e[a(1694)]);window[a(692)+a(1422)]=f=>{let h=a;document[h(232)][h(435)+h(477)](x),window["frontier"+h(1422)]=void 0,r(f&&f[h(1565)]||t[h(808)])},x[a(1737)]=a(1770)+a(1716),x.src=e[a(1607)](i[a(1212)](/^ws/,a(744)),e[a(1443)]);try{document.body[a(1132)+"ild"](x)}catch{document[a(232)][a(435)+"ild"](x)}}catch{window[a(692)+a(1422)]=void 0,r(e[a(765)])}})}function et(i,t,r){let a=n;return!!i?.find(x=>x[a(1642)]===t&&x[a(916)]===r)}function St(i,t){let r=n;return i?.[r(601)](a=>a[r(1642)]===t)?.[r(916)]}let Nr=null;async function Xc(){let i=n;if(e[i(1444)]!==e[i(1099)])return Nr||(Nr=Promise[i(1143)]()[i(317)](Fe[i(854)](Fe,e.aGYhe))),Nr;this[i(1111)+"lTimeoutId"]=null,this[i(1111)+"l"]=36e5,this._qosDB=e[i(365)](_0x38a16a,e[i(1024)],e[i(1761)])}class Qc extends Lr{constructor(t,r){let a=n;super(),this[a(962)]=t,this[a(1127)]=r,this[a(524)]=void 0,this[a(725)+a(848)]=null}async[n(875)](){let t=n;if(e[t(432)](t(1130),e[t(1520)]))await this._init();else return new _0x3e7963(_0x16521a,{data:_0x28c89c,message:_0x2d0f94})}async[n(1168)](){let t=n,r={qLVae:function(a){return a()}};if(e.oQfEr("vQvis",e[t(687)])){let a=this[t(240)+t(302)]?.[t(695)+t(1180)+"nt"]();this[t(1225)](t(214)+a),r[t(1016)](_0x19c8bd)}else{if(this._qosDB)return;if(this[t(725)+t(848)])return this[t(725)+t(848)];try{let a=this[t(962)],x=this[t(1127)];this[t(725)+t(848)]=(async()=>{let f=t,{openDB:h}=await Xc();this[f(524)]=await h(f(692)+"_"+a,1,{upgrade(w){let g=f;w[g(1644)+g(1368)+"e"](a,{keyPath:x})}})})(),await this[t(725)+t(848)]}catch(a){console[t(905)](a)}finally{this["_initPro"+t(848)]=null}}}async[n(1657)](t){let r=n;try{return await this[r(1168)](),this._qosDB?.get(this[r(962)],t)}catch(a){if(e[r(782)](r(1116),e.yEtUz)){if(e[r(337)](_0x495339,-_0x31d390))return _0x51b577;if(e[r(1306)](_0x12067b+1,_0x4266ce))return _0x5d8e09}else console[r(905)](a)}}async[n(1651)](t,r){let a=n;return await this[a(1168)](),this[a(524)]?.[a(1680)](this[a(962)],t)}async del(t){let r=n;try{return await this._init(),this[r(524)]?.[r(989)](this[r(962)],t)}catch(a){console.log(a)}}async clear(){let t=n;try{return await this[t(1168)](),this._qosDB?.[t(726)](this._dbName)}catch(r){console[t(905)](r)}}async[n(1561)](){let t=n;return await this[t(1168)](),this._qosDB?.[t(311)+"ys"](this[t(962)])}async[n(1398)](){let t=n;if(e[t(1666)](t(539),e[t(1701)])){let r=this[t(240)+t(302)]?.[t(695)+t(1180)+"nt"]();this[t(443)+t(358)+t(1434)](e.LRIoT(_0x50f0ae,"close",{code:1006,reason:t(1123)+r+(t(1038)+t(1186)+t(1272)+t(1418)),wasClean:!0}))}else return await this[t(1168)](),this._qosDB?.getAll(this[t(962)])}async[n(938)](){let t=n;try{if(e[t(709)](e[t(1273)],e[t(1239)]))return this[t(958)][t(1408)];this[t(524)]?.[t(1360)](),this[t(524)]=void 0}catch(r){console[t(905)](r)}}get isReady(){let t=n;if(e[t(935)](e[t(562)],e[t(588)]))try{return!!this[t(524)]}catch(r){return console[t(905)](r),!1}else return _0xcd8789[_0x33c0f5]=_0xbe5ada,!0}}class Zc{constructor(t,r){let a=n;this[a(1262)]=t,this[a(1006)]=r,this._qosDB=localStorage}async openDB(){}get[n(1479)](){let t=n;return t(692)+"_"+this[t(1262)]}async[n(1657)](t){let r=n,a=this[r(524)][r(1145)](this[r(1479)]);return JSON[r(636)](e[r(1744)](a,"{}"))[t]}async[n(1651)](t,r){let a=n,x=this._qosDB[a(1145)](this[a(1479)]),f=JSON[a(636)](e[a(468)](x,"{}"));return f[r||t[this[a(1006)]]]=t,this[a(524)].setItem(this[a(1479)],JSON[a(1577)+"y"](f)),r||t[this[a(1006)]]}async[n(1414)](t){let r=n,a=this[r(524)][r(1145)](this[r(1479)]),x=JSON[r(636)](a||"{}");return x[t]=void 0,this._qosDB.setItem(this[r(1479)],JSON[r(1577)+"y"](x))}async[n(726)](){let t=n;return this[t(524)][t(726)]()}async[n(1561)](){let t=n,r={gqhOQ:function(a,x,f){return e[k(1739)](a,x,f)},PvRVH:e[t(1226)]};if(e[t(567)]!==e.uNhrz){let a=this[t(524)][t(1145)](this[t(1479)]),x=JSON[t(636)](e[t(472)](a,"{}"));return Object.keys(x)}else this[t(1415)+t(1484)]=_0xf97be2,this[t(1250)+t(1777)]=_0x5de017,this[t(1537)+t(864)]=_0x3d62da,this[t(524)]=r[t(786)](_0x47765c,this[t(1415)+t(1484)],r[t(536)])}async[n(1398)](){let t=n;if(e.CweRD(e[t(363)],t(1001))){let r=this._qosDB[t(1145)](this._prefix),a=JSON[t(636)](r||"{}");return Object[t(442)](a)}else _0x28a631(Pqqzol.aVflX(_0x30a226,_0x2c9008[t(679)]),_0x8a2bf6[t(1622)+"on"],_0xc9398c[t(715)+"on"],Pqqzol[t(1400)](_0x5a4b51,_0x3f781c[t(1200)+"ion"]))}[n(938)](){return Promise[n(1143)]()}get isReady(){return!!this[n(524)]}}class e0{constructor(t,r){let a=n;this[a(1262)]=t,this[a(1006)]=r,this._qosDB=ut?tt:jt?wx:null}async[n(875)](){}get[n(1479)](){let t=n;if(e[t(1378)](e[t(1344)],e[t(1344)])){let r={DEUQj:function(a,x){return a(x)}};return function(...a){let x=t;return _0x573e7c[x(1063)](r[x(1593)](_0x431dc0,this),a),r[x(1593)](_0x42a9c2,_0x307d42.get(this))}}else return t(692)+"_"+this[t(1262)]}async[n(1657)](t){let r=n,a=this[r(524)][r(421)+"geSync"](this[r(1479)]);return JSON.parse(a||"{}")[t]}async set(t,r){let a=n,x=this._qosDB["getStora"+a(1046)](this[a(1479)]),f=JSON[a(636)](e[a(791)](x,"{}"));return f[r||t[this[a(1006)]]]=t,this[a(524)][a(407)+a(1046)](this[a(1479)],JSON.stringify(f)),r||t[this._pathKey]}async[n(1414)](t){let r=n,a=this[r(524)]["getStora"+r(1046)](this._prefix),x=JSON[r(636)](e.wMoQE(a,"{}"));return x[t]=void 0,this[r(524)]["setStora"+r(1046)](this[r(1479)],JSON[r(1577)+"y"](x))}async clear(){let t=n;if(e[t(717)](e[t(1192)],t(1151)))_0x57df39[t(853)+"d"]&&(this[t(1332)+t(1343)]()&&(!this[t(289)]||e.rRVsx(this[t(289)][t(201)+"te"],this.OPEN)||this[t(289)][t(201)+"te"]!==this[t(1579)+"NG"])&&this[t(433)+t(818)](),this[t(626)+"er"]&&_0x498ffe[t(884)+t(1425)](e[t(688)],this[t(433)+t(818)]),this._isBrowser&&_0xb7a804["addEvent"+t(1425)](e[t(589)],this[t(433)+"ffLine"]));else return this[t(524)][t(693)+"rageSync"]()}async keys(){let t=n,r=this._qosDB[t(421)+"geInfoSync"](this[t(1479)]),a=JSON.parse(e.DvQNN(r,"{}"));return Object[t(1561)](a)}async getAll(){let t=n,r={cgqSI:function(a,x){return a(x)}};if(e[t(452)](e.aVjuY,e[t(1753)])){let a={wmwET:function(x,f){let h=t;return UNEhxy[h(922)](x,f)}};return function(x,...f){let h=t,w=_0x2343f3[h(1182)](a.wmwET(_0x375c61,this),x,...f);return _0x5542aa.set(w,x[h(1686)]?x[h(1686)]():[x]),a.wmwET(_0x27a079,w)}}else{let a=this[t(524)][t(421)+t(1313)+"nc"](this[t(1479)]),x=JSON[t(636)](e.QsKzm(a,"{}"));return Object[t(442)](x)}}[n(938)](){return Promise[n(1143)]()}get isReady(){return!!this[n(524)]}}function xs(i,t){let r=n;if(e[r(1482)](ut,ut))return new e0(i,t);if((vt||Kt)&&e[r(835)](e[r(1712)],typeof indexedDB))return new Qc(i,t);if(e[r(372)](vt,Kt)&&r(1631)+"d"!=typeof localStorage)return new Zc(i,t);throw new Error(e[r(516)])}class t0{constructor(){let t=n;this[t(1111)+t(1036)+"Id"]=null,this._interval=36e5,this[t(524)]=e[t(218)](xs,e[t(1024)],e.lKgmM)}async[n(1111)+n(559)](){let t=n;e[t(613)](clearInterval,this["_interva"+t(1036)+"Id"]),this[t(1111)+t(1036)+"Id"]=setInterval(()=>{let r=t;e[r(1003)](e[r(1124)],e[r(282)])?_0x37268c[r(1774)](_0x36f63a):this[r(1650)+"ired"]()},this[t(1111)+"l"])}async openDB(){let t=n;await this[t(524)][t(875)]()[t(317)](()=>{let r=t;this[r(1111)+r(559)]()})}async["flushExp"+n(1310)](){let t=n;(await this._qosDB?.[t(1398)]()||[])[t(208)](({timestamp:x})=>x<Date.now())[t(1519)](x=>{let f=t;this[f(524)]?.[f(1414)](x[f(1748)+"id"])})}async[n(1414)](t){let r=n;return this[r(524)]?.[r(1414)](t)}async[n(1651)](t,r){let a=n;return this[a(524)]?.[a(1651)]({message_id:t,timestamp:r})}async get(t){let r=n,a={hHrgG:function(x,f){return x<f},akawt:function(x,f){return e[k(1666)](x,f)},yBPNF:function(x,f){return e[k(593)](x,f)}};if(e[r(413)](e[r(990)],e[r(398)])){let x=_0x2fba9b[r(1413)](":");for(let f=0;XcrsHz[r(275)](f,x[r(796)]);f++){let h=x[f];if(XcrsHz.akawt(4,x[f][r(796)])){let w=_0x39a228[r(644)+"g"](0,XcrsHz[r(266)](4,x[f].length)),g=w[r(632)](h);_0x33c862=_0x309433[r(632)](g)}else _0x544c4f=_0x3c24a1.concat(h)}return _0x1cd123}else return this[r(524)]?.[r(1657)](t)}async closeDB(){let t=n;e.YtCcr(clearInterval,this["_interva"+t(1036)+"Id"]),await this._qosDB?.[t(938)]()}get isReady(){let t=n;return this[t(524)]?.[t(1303)]}}function Mr(i){let t=n,r=!!this[t(388)][t(1044)+"S"];if(!r)return{enabled:r,isQoSMessage:!1,isQoSAck:!1,isAckCleanupMessage:!1,ackMsgIds:[]};let a=et(i[t(1697)][t(951)],e.zzTwP,"2"),x=a&&e.fNWbs(et,i.message[t(951)],"x_fronti"+t(757)+"ck","1"),f=a&&et(i[t(1697)][t(951)],t(807)+t(301)+"k","1"),h=f?e[t(1649)](St,i.message[t(951)],e.AHVMX)?.[t(1413)](",").filter(Boolean)||[]:[];return{enabled:r,isQoSMessage:a,isQoSAck:x,isAckCleanupMessage:f,ackMsgIds:h}}async function ds(){let i=n;return this[i(409)+i(283)]||(this[i(409)+i(283)]=new t0),this[i(409)+i(283)].isReady||await this[i(409)+i(283)].openDB(),this[i(409)+"ger"]}async function n0(i,t){let r=n,a={JpOQL:function(g,b,v){return e.gQLJb(g,b,v)},nXjIu:e[r(587)]},{enableAutoAck:x}=this._options,f=et(i[r(1697)][r(951)],e[r(1766)],"1"),h=e[r(526)](et,i.message.headers,e.KyReS,"1"),w=Mr[r(1182)](this,i);if(e[r(261)](x,f))if(e.fHmHl(e[r(1039)],r(1365))){let g=this[r(240)+"tManager"]?.["getCurre"+r(1180)+"nt"](),b=this[r(388)][r(576)+"tInterce"+r(1768)](_0x259aaf.code,_0x35b365[r(723)]);this[r(443)+r(358)+"ent"](a[r(425)](_0x2520e5,a[r(631)],{code:1006,reason:_0x14ed81[r(723)]||r(1286)+r(1437)+r(798)+r(880)+r(1449)+r(373)+g,willReconnect:b})),b&&this[r(815)]();return}else{let{SeqID:g,LogID:b,service:v,LogIDNew:C,method:O}=i[r(1697)];this[r(1363)]({SeqID:g,LogID:b,LogIDNew:C,service:v,method:O,headers:[{key:e.KyReS,value:"1"},{key:e.uTKdp,value:e[r(1377)](C,"")},{key:e.JeDpQ,value:"0"}]})}h&&!w.isQoSAck&&this[r(443)+"hAckMessageEvent"](i),t()}async function r0(i,t){let r=n,a={AGXjS:function(x,f){return e.vMCCt(x,f)},EFzyF:function(x,f){return e.DuuAb(x,f)},CsUDx:function(x,f,h){return x(f,h)}};if(e[r(1596)](r(1673),e[r(346)]))return FXTQdf[r(1338)](FXTQdf[r(461)](_0x752eea,8)[r(1453)]("0"),FXTQdf[r(691)](_0x566b83,_0x40c066,10)[r(1605)](2))[r(1424)](-8);this._debug(e[r(1325)],i[r(1697)]),t()}async function i0(i,t){let r=n,a=e[r(1597)](wt,await e[r(578)](cs,i.data));try{if(e.IeGpt(a[r(1097)],Uint8Array)){let x=e[r(862)](this[r(388)]["payloadE"+r(850)],Object)?{force:!!this[r(388)][r(900)+"ncoding"][r(1347)],encoding:this[r(388)][r(900)+r(850)][r(1323)]?this[r(388)]["payloadE"+r(850)][r(1323)][r(1212)](/\s/g,"")[r(204)+r(1786)]():""}:{force:!1,encoding:this[r(388)].payloadEncoding?this._options["payloadE"+r(850)][r(1212)](/\s/g,"")["toLowerC"+r(1786)]():""},f=a["payloadE"+r(850)]?a[r(900)+r(850)].replace(/\s/g,"")[r(204)+r(1786)]():"",h=e.llbcj(this._options.payloadType,Object)?{force:!!this[r(388)][r(384)+r(1131)][r(1347)],type:this._options["payloadT"+r(1131)][r(1737)]?this[r(388)][r(384)+r(1131)][r(1737)][r(1212)](/\s/g,"")[r(204)+"ase"]():""}:{force:!1,type:this[r(388)]["payloadT"+r(1131)]?this[r(388)][r(384)+r(1131)].replace(/\s/g,"")[r(204)+"ase"]():""},w=a[r(384)+r(1131)]?a[r(384)+"ype"][r(1212)](/\s/g,"")[r(204)+r(1786)]():"",g=h[r(1347)]?h[r(1737)]:w||h.type,b=x[r(1347)]?x[r(1323)]:f||x[r(1323)],v=[e[r(333)],e[r(242)],e[r(306)],r(410)],C=[r(799)+"e",e[r(298)]];this[r(388)][r(1157)+r(1208)+r(1487)+"ad"]&&v[r(1086)](g)&&(!b||C[r(1086)](b))?a[r(1298)+r(598)]=e[r(751)](as,a.payload,0,a.payload[r(1062)+"th"]):a.textPayload=""}else a[r(1298)+r(598)]=""}catch(x){a["textPayl"+r(598)]="",console[r(905)](x)}i[r(1697)]=a,e[r(517)](t)}function s0(i,t,r){let a=n,x=e[a(1745)](r,8192),f=e[a(216)](x,1),h=null,w=x;return function(g){let b=a;if(g<1||g>f)return e.oWFrM(i,g);e[b(959)](e[b(1161)](w,g),x)&&(h=e.CiPOh(i,x),w=0);let v=t.call(h,w,w+=g);return e.kzrep(7,w)&&(w=e[b(661)](e.XrZuJ(7,w),1)),v}}let o0=4294967295;function a0(i,t,r){let a=n;return e[a(436)](RangeError,e[a(812)](e[a(780)](e[a(942)](e.HGhwT,i)+e.xeCaJ,e[a(468)](t,1)),e.JYnUJ)+r)}function c0(i,t,r){let a=n;if(e[a(959)](r,o0))throw new Error(e[a(540)]);let x=3;for(;x>=0;){let f=e[a(974)](255,r);zr(f,i,t+x),r>>>=8,x--}return e[a(203)](t,4)}function x0(i,t){let r=n,a=0,x=t,f=e[r(596)](t,4);for(;x<f;)if(e.lhpaO("TZusq",e.nnUuP)){let{value:h,offset:w}=e.fLMhL(Br,i,x);x=w,a=e[r(1160)](e[r(777)](a,8),0),a+=h}else _0x4eecd3.log(_0x4c0e3b);return{value:a,offset:f}}function d0(i,t,r){let a=n;return i?e[a(1442)](i[a(796)],40)?Or(i,t,r)+r:t[a(238)+"e"]?e[a(566)](t.utf8Write(i,r),r):t[a(823)]?t[a(823)](i,r)+r:e[a(1665)](Or(i,t,r),r):r}function u0(i,t){let r=n,a=new G(e[r(374)](e.oKHTv(e[r(597)](i[e.dNAMH(t,4)],24)|e.vmYvg(i[e[r(348)](t,5)],16),e[r(257)](i[e.soGkl(t,6)],8)),i[t+7]),e[r(1322)](e[r(434)](e[r(966)](e.mqHtZ(i[e[r(1419)](t,0)],24),i[e[r(812)](t,1)]<<16),i[e[r(1101)](t,2)]<<8),i[e.vqmIh(t,3)]),!0);return t+=8,{value:a,offset:e[r(1601)](t,8)}}function f0(i,t,r){let a=n,x=i[a(1454)],f=i[a(1070)];return t[r]=e.pzdWS(f,24),t[e[a(775)](r,1)]=e[a(1270)](f,16)&255,t[e[a(1687)](r,2)]=e.SCuwf(e[a(1259)](f,8),255),t[r+3]=255&f,t[r+4]=x>>>24,t[r+5]=e[a(1391)](x,16)&255,t[r+6]=e[a(1121)](x,8)&255,t[e[a(1613)](r,7)]=e.uOgWf(255,x),r+=8,r}function Br(i,t){let r=n;if(e[r(883)](e[r(418)],e.nabnx))try{return e.UaeLL!=typeof _0x1da8ff&&(e.MhLSF(_0x457d33,_0x47619e)||_0xe18d23[r(1054)]&&e[r(510)](_0x215ed8[r(1054)],_0x14d7c4))||e[r(1510)](e[r(980)],typeof _0x1cd600)?"":(_0x5bb4b6.parse(_0xdef41c),e[r(242)])}catch{return e[r(1571)](e[r(980)],typeof _0x3cb195)?e[r(333)]:""}else return i.readUInt8?{value:i[r(911)+"8"](t),offset:e[r(1683)](t,1)}:{value:e[r(1430)](255,i[t]),offset:e[r(812)](t,1)}}function zr(i,t,r){let a=n;if(e[a(515)](a(518),e[a(1707)]))try{_0x1bffec(this,_0x236b53,[_0x35966f,_0x5d1f6b,_0x270bfe])}catch(x){let f=e[a(976)](_0x29913f,e[a(1214)],{message:x[a(1697)],code:_0x3639bb.OPEN_ERROR,error:x});this["_dispatc"+a(776)+a(1434)](f)}else return t[a(928)+"t8"]?t[a(928)+"t8"](i,r):t[r]=e.snlqI(255,i),e.mKvYi(r,1)}let l0=function(i){return new Uint8Array(i)},g0=e[n(607)](n(1631)+"d",typeof Buffer)?Buffer[n(622)+n(1509)]:e[n(845)](s0,l0,Uint8Array.prototype[n(993)]);(()=>{let i=n;if(e.fAMpO(i(1008),e.nbBKM)){let t=4294967295;return function(r,a,x=!0){let f=i,h={OqXxX:function(w,g){return e.bhztn(w,g)},owFDv:function(w,g){return e.CPCWt(w,g)},WEfIH:function(w,g){return e.fOzds(w,g)},ntAEw:function(w,g){return e[k(780)](w,g)},dZdNJ:function(w,g){return w+g},qNvNO:e[f(378)],fqEtp:function(w,g){return e[f(252)](w,g)},frnTj:e[f(1708)]};if(e[f(1170)]!==f(1679)){let w=(f(642)+f(1029)+f(209)+"3")[f(1413)]("|"),g=0;for(;;){switch(w[g++]){case"0":t=e.sJJmk(e.gdHlt(127,r[a]),0);continue;case"1":if(e[f(1224)](r[a++],128))return{value:x?t:e.JfOdg(0,t),offset:a};continue;case"2":if(e[f(1442)](r[a++],128))return{value:x?t:e[f(423)](0,t),offset:a};continue;case"3":return{value:x?t:e[f(1493)](0,t),offset:a};case"4":t=e[f(645)](e[f(1493)](t,e[f(924)](127&r[a],7)),0);continue;case"5":if(e[f(243)](r[a++],128))return{value:x?t:e.dRUfh(0,t),offset:a};continue;case"6":if(e[f(1468)](r[a++],128))return{value:x?t:e[f(857)](0,t),offset:a};continue;case"7":t=e[f(1391)](t|e[f(732)](127,r[a])<<21,0);continue;case"8":if(e[f(290)](a+=5,r[f(796)]))throw a=r.length,a0(a,10,r.length);continue;case"9":t=e[f(1645)](t,e.IGafw(e.phtMy(127,r[a]),14))>>>0;continue;case"10":if(e[f(739)](r[a++],128))return{value:x?t:e[f(1342)](0,t),offset:a};continue;case"11":t=e[f(660)](t|e[f(213)](15&r[a],28),0);continue}break}}else return WVMdnt[f(1656)](_0x32e551,WVMdnt[f(772)](WVMdnt[f(967)](WVMdnt.ntAEw(WVMdnt.dZdNJ(f(1783)+f(907)+f(1544),_0x2efeed)+WVMdnt.qNvNO,WVMdnt.fqEtp(_0x28f4c3,1)),WVMdnt[f(830)]),_0x36686d))}}else return Y[i(958)].binaryType})();let h0=16,Fr=32;function p0(i){let t=n,r=0,a={};for(let x=0;x<i[t(796)];x++)a[i[x][t(738)+t(981)]]=e[t(1530)](os,i[x]["cursor_n"+t(981)]),r+=14+a[i[x][t(738)+t(981)]];return[r,a]}function us(i,t,r){let a=n,x={RimUr:function(b,v){return e.xfrZF(b,v)},YAuhn:function(b,v){return e[k(1521)](b,v)},YLglz:function(b,v){return e[k(1402)](b,v)},UHTwO:function(b,v){return e.fZwjp(b,v)},RqNfD:function(b,v){return e.FosZq(b,v)},nRafR:function(b,v){return e.NfzRV(b,v)},wWYMa:a(367),CJGaB:e[a(633)],mKYEb:function(b,v,C,O){return b(v,C,O)},RtpSJ:a(1736)+a(310),XCdIn:"header",eYISc:a(310),wliGh:e[a(1307)],Jsywx:e[a(950)],Dsrni:e[a(1069)]},[f,h]=e[a(294)](p0,i),w=g0(f),g=0;return i[a(1519)](b=>{let v=a,C={SKESz:function(O,R){return x[k(1215)](O,R)},UvDLZ:function(O,R){return x[k(999)](O,R)},IdnTh:function(O,R){return x[k(697)](O,R)},IXNeY:function(O,R){return x[k(697)](O,R)},dpMvS:function(O,R){return x[k(656)](O,R)},zZaDc:function(O,R){return x[k(1405)](O,R)}};if(x[v(1499)]("MrCeR",x.wWYMa))_0x4b08f7=lBLYqp.SKESz(_0x2acc3a,_0x5a2b26),_0x391847|=lBLYqp[v(621)](lBLYqp.IdnTh(127,_0x384c46),21),lBLYqp[v(1507)](128,_0x4ac38d)&&(_0xd3eb45=lBLYqp.dpMvS(_0x4caf8c,_0x567438),_0x56c51d=lBLYqp[v(897)](127,_0x239c64),lBLYqp[v(897)](128,_0x93d009)&&(_0x3dc846=lBLYqp[v(1540)](_0x53fa8d,_0x3a29f2),_0x43d3be|=lBLYqp[v(621)](127&_0x35b502,7)));else{let O=x[v(487)].split("|"),R=0;for(;;){switch(O[R++]){case"0":g=x[v(1007)](zr,0,w,g);continue;case"1":console[v(905)](x[v(1393)],g);continue;case"2":console[v(905)](x[v(731)],g);continue;case"3":console[v(905)](x[v(1416)],g);continue;case"4":g=x.mKYEb(d0,b[v(738)+v(981)],w,g);continue;case"5":g=c0(w,g,b[v(745)]||0);continue;case"6":console[v(905)](x.wliGh,b,b.service);continue;case"7":g=x[v(1007)](zr,h[b[v(738)+v(981)]],w,g);continue;case"8":g=x[v(1007)](f0,G.fromNumber(b[v(628)]||t),w,g);continue;case"9":console[v(905)](x[v(1117)],g);continue;case"10":console[v(905)](x[v(217)],g);continue}break}}}),{frameType:Fr,headers:[{key:a(479)+a(1440),value:r}],payload:w}}function m0(i){let t=n,r={Chguo:function(a,x){return a-x},xIyDF:function(a,x){return e[k(1172)](a,x)},orwek:function(a,x){return e[k(558)](a,x)},BcDOE:function(a,x){return e[k(1475)](a,x)},EFbtu:function(a,x){return a<<x},fvaKP:function(a,x){return e[k(447)](a,x)}};if(e[t(1672)](e.WJCFT,e[t(659)])){let a=0,x=[];for(;e[t(1336)](a,i[t(1062)+"th"]);){let{offset:f}=e[t(763)](Br,i,a);a=f;let h={cursor_name:"",cursor:0,service:0},{value:w,offset:g}=x0(i,a);h[t(745)]=w,a=g;let{value:b,offset:v}=e[t(262)](Br,i,a);a=v,h[t(738)+t(981)]=e[t(526)](as,i,a,e[t(1241)](a,b)),a+=b;let{value:C,offset:O}=e.MnWSq(u0,i,a);h[t(628)]=C.toNumber(),a=O,x[t(1774)](h)}return x}else{let a=uuTSwI[t(1340)](uuTSwI[t(1660)](uuTSwI[t(1660)](uuTSwI[t(231)](uuTSwI[t(1439)](7,_0x41a652),18)|uuTSwI[t(1329)](uuTSwI[t(1439)](63,_0x2135a8[_0x54a835++]),12),uuTSwI[t(1329)](uuTSwI[t(1439)](63,_0xd08c7[_0x481a92++]),6)),uuTSwI[t(1439)](63,_0x10a3bb[_0x18e3c9++])),65536);_0x1e99cf+=_0x2b8993[t(861)+"Code"](55296+(a>>10)),_0xf27b9b+=_0x5adf63.fromCharCode(uuTSwI[t(618)](56320,uuTSwI[t(1439)](1023,a)))}}function w0(){let i=n;return{frameType:Fr,headers:[{key:e[i(426)],value:e[i(784)]}],payload:void 0}}class _0{constructor(t,r,a){let x=n;this[x(1415)+x(1484)]=t,this["_cursorF"+x(1777)]=r,this[x(1537)+x(864)]=a,this[x(524)]=xs(this[x(1415)+x(1484)],e[x(1226)])}async[n(875)](){let t=n;await this[t(524)][t(875)]()}async[n(1403)+"rs"](){let t=n;if(!this._qosDB.isReady)return;let r=this[t(1537)+t(864)],a=await this[t(524)][t(1398)]();switch(console[t(905)](e[t(460)],a),r){case e[t(1667)]:return a&&a[t(796)]?e[t(751)](us,a,0,this[t(1250)+"ileName"]):void 0;case e[t(1767)]:return;case e[t(1147)]:return a&&a[t(796)]?e[t(1348)](us,a,0,this[t(1250)+t(1777)]):e[t(953)](w0)}}async[n(1651)](t,r,a){let x=n;return console[x(905)](e[x(627)],t,r,a),this[x(524)][x(1651)]({cursor_name:t,cursor:r,service:a})}async[n(1315)+"rs"](t){let r=n;if(e.mrUyV(e[r(509)],e[r(509)])){if(!this._connectLock){let a=(r(1478)+"2")[r(1413)]("|"),x=0;for(;;){switch(a[x++]){case"0":this[r(1538)+"osed"]=!1;continue;case"1":this[r(273)+r(844)]?.[r(971)+"nter"]();continue;case"2":this[r(815)]();continue;case"3":this[r(393)]=!0;continue;case"4":this[r(240)+"tManager"]?.[r(226)+r(404)+r(277)]();continue}break}}}else{let a=e.WSGEd(m0,t);for(let x of a)console.log(e[r(349)],a),await this._qosDB[r(1651)](x)}}async get(t){let r=n;return(await this[r(524)][r(1657)](t))?.cursor}async closeDB(){let t=n;e[t(1233)](e[t(1641)],e[t(1779)])?(_0xf2f928=_0x1b1d31[e[t(1359)](e[t(596)](_0x49dfdf,_0x59734e),1)],e[t(1302)](e[t(681)](192,_0x626819),128)?_0x335c5b+=_0x7d035b:(_0x35deee=e[t(1733)](e.gDGYq(31,_0x3aca4b),6)|e[t(817)](63,_0x2d6ba6),e[t(968)](_0x5e901f,128)?_0x12d048+=_0x17722b:(_0x5c83db+=_0x30a0e5(_0x3b3fa6),_0x28bbed++))):await this[t(524)].closeDB()}[n(708)+n(1030)+n(1498)](t){let r=n;this[r(1250)+"ileName"]=t}get[n(1303)](){let t=n;if(e[t(1584)](t(1141),e[t(1635)]))return this._qosDB[t(1303)];this[t(1271)]++}}let y0=e[n(1088)];async function fs(i){let t=n;if(e[t(515)](e[t(1299)],e[t(1299)]))_0x13644f&&_0x5cdfc5.addEventListener(t(1360),()=>_0x4cdb9c()),_0x2d3974&&_0x11d763[t(884)+t(1425)]("versionchange",()=>_0x35fc32());else{if(!this[t(388)][t(1044)+"S"])return null;let{aID:r,fpID:a,messageStrategy:x}=this[t(388)],f=i||y0;try{return this[t(674)+t(1551)]?i&&this._cursorManager[t(708)+t(1030)+t(1498)](i):this[t(674)+t(1551)]=new _0(a+"_"+r+"_"+f,f,x),this[t(674)+t(1551)][t(1303)]||await this[t(674)+"anager"].openDB(),this["_cursorM"+t(1551)]}catch{return null}}}async function b0(i,t){let r=n,a={JJqQj:e[r(1197)],wgXcV:function(x,f){return e[r(455)](x,f)},EHIPQ:function(x,f){return e[r(1337)](x,f)},stnoz:function(x,f){return e[r(497)](x,f)}};if(e[r(1139)](e[r(1628)],r(1528))){let x=a[r(906)][r(1413)]("|"),f=0;for(;;){switch(x[f++]){case"0":if(_0x30ce7d.utf8Write)return xsjpOQ[r(620)](_0x5c3c35[r(238)+"e"](_0x1ee9c0,_0x2afa42),_0x2a25d5);continue;case"1":if(_0x227d3d.length<40)return xsjpOQ[r(1252)](_0x55a210(_0x95bfc9,_0x5e6d82,_0x398916),_0x5c29a1);continue;case"2":if(!_0x37e24c)return _0x215698;continue;case"3":return _0x4768ae(_0x39a1fb,_0x1f4cfa,_0x3c7227)+_0x27376e;case"4":if(_0x39cc29[r(823)])return xsjpOQ.stnoz(_0xa8497d.write(_0xf1586d,_0x100b63),_0x21ac79);continue}break}}else{let x=et(i[r(1697)][r(951)],r(1532),"-1"),f=et(i[r(1697)][r(951)],e[r(1009)],"1"),h=e.irSXZ(St,i.message[r(951)],r(807)+r(941)),w=e[r(1568)](Number,e[r(1020)](St,i.message[r(951)],r(807)+"er_ttl"))||0,g=Mr[r(1182)](this,i),b=e[r(1348)](et,i[r(1697)].headers,e[r(422)],"2"),v=e[r(1452)](St,i[r(1697)][r(951)],e[r(1787)]),C=e[r(1017)](Number,e[r(992)](St,i[r(1697)][r(951)],e[r(1126)]));if(g[r(678)])return e.jaJyY(t);let O=g[r(579)+"sage"]?await ds[r(1182)](this):null;if(e.SFxCa(i.message.service,0)&&f&&!x||e.aURdb(i[r(1697)][r(745)],0)){if(h&&g[r(579)+r(408)]&&O)return!!!await O[r(1657)](h)&&(this["_dispatc"+r(535)+r(1081)](i),await O[r(1651)](h,e.ygBus(Date[r(1780)](),w))),e[r(517)](t);if(b){let R=await fs.call(this);if(!R)return this[r(443)+r(535)+r(1081)](i),e[r(485)](t);let F=await R[r(1657)](v)??-1;if(e[r(243)](F,C))this[r(443)+r(535)+r(1081)](i),R.set(v,C,i[r(1697)][r(745)]);else throw new Error(r(1137)+" message"+r(774)+C+(r(936)+r(893)+r(529)+"r ")+F);return t()}return this[r(443)+r(535)+"Event"](i),e.YyxnS(t)}}}async function v0(i,t){let r=n,a=Mr.call(this,i);if(!a[r(579)+r(408)])return t();let x=await ds.call(this);if(a[r(1524)+r(1061)+r(1122)]&&a.ackMsgIds[r(796)])for(let f of a[r(743)+"s"])await x.del(f);t()}async function S0(i,t){let r=n,a=e[r(1627)](i[r(1697)][r(1104)+"e"],h0),x=e[r(1486)](i.message.frameType,Fr);if(e[r(1639)](!a,!x))return e[r(1324)](t);let f=e[r(1690)](St,i.message[r(951)],e[r(426)]);if(!f)return e[r(1575)](t);let h=await fs.call(this,f);if(!h)return t();if(a){let w=await h[r(1403)+"rs"](),g={frameType:w?.["frameType"],SeqID:G[r(764)+"er"](this[r(1251)]++),LogID:G[r(764)+"er"](this[r(388)][r(1548)+r(1749)]()),service:9e3,method:5,headers:w?.[r(951)],payload:w?.[r(1097)]},b=e[r(548)](I,g);this._ws&&this._ws.readyState&&this[r(289)].send(b)}if(x){let w=i.message[r(1097)];w&&h.setCursors(w)}}let E0=async function(i,t){let r=n;this[r(393)]=!1,e[r(917)](clearTimeout,this[r(815)+r(1647)+r(527)]),e[r(1232)](t)},I0=async function(i,t){let r=n;if(!this[r(289)]||this[r(289)].readyState!==this[r(1664)])return e.HSddo(t);let{pingInterval:a}=this._options;this["_endpoin"+r(302)]?.[r(226)+"pointCon"+r(277)]();for(let f=0;e[r(968)](f,this[r(1537)+r(550)].length);f++){let h=this[r(1537)+r(550)][f];if(this[r(289)].readyState===this[r(1664)]&&e[r(1584)](null,h))this[r(289)]&&this[r(289)].send(h),this[r(1537)+"Queue"][f]=null;else break}this[r(1537)+r(550)]=this[r(1537)+"Queue"][r(208)](f=>!!f),this["_pingPon"+r(653)+"Id"]=e.YALyA(setTimeout,()=>this[r(1481)](),a),this._dispatchOpenEvent(i),this[r(626)+"er"]&&this._ws&&(this[r(289)][r(1704)+"pe"]=this["_binaryT"+r(1131)]);let x=this[r(240)+"tManager"]?.[r(695)+r(1180)+"nt"]();this[r(1225)]("open "+x+" success"),e.kIQdp(t)},A0=async function(i,t){let r=n,a=this[r(240)+r(302)]?.[r(695)+"ntEndpoint"]();this[r(1225)](r(214)+a),e[r(517)](t)};class C0 extends Lr{constructor(t){let r=n,a={lcrZb:function(w,g,b,v){return e[k(751)](w,g,b,v)},BvJjz:e[r(1214)],QeFju:e.XEKJp,MGfSJ:function(w,g,b){return e[r(1295)](w,g,b)},NDWMb:e[r(809)],Teenz:function(w,g){return w!==g},jDGJf:function(w,g){return e.DuuAb(w,g)},uuzTQ:function(w,g){return e[r(432)](w,g)},rGgNZ:function(w,g,b){return e[r(1730)](w,g,b)}};super(),this[r(1109)+r(1505)+r(728)]=!0,this[r(626)+"er"]=vt,this[r(546)]=jc,this[r(1485)+"T"]=ut,this[r(1146)+"X"]=jt,this[r(1198)+"r"]=Kt,this["_message"+r(550)]=[],this["_endpoin"+r(302)]=null,this._readyClosed=!1,this._binaryType=e.DRnPB,this["_connect"+r(202)]=!1,this["_connectionTimeo"+r(527)]=null,this[r(1511)+r(1010)+r(1421)]=null,this[r(377)+"gTimeoutId"]=null,this[r(1251)]=0,this[r(393)]=!1,this[r(1417)]="",this["_QoSMana"+r(283)]=null,this._cursorManager=null,this[r(273)+r(844)]=null,this._protocols=e.QMNlb,this[r(1067)]=3,this[r(1579)+"NG"]=0,this[r(1664)]=1,this[r(599)]=2,this[r(223)]=w=>{let g=r;try{a.lcrZb(ss,this,w,[E0,I0,A0])}catch(b){let v=Ie(a[g(832)],{message:b[g(1697)],code:Ze[g(414)+"OR"],error:b});this[g(443)+g(776)+g(1434)](v)}},this[r(1535)+"ge"]=async w=>{let g=r,{pingInterval:b,pingFrequency:v}=this[g(388)];if((w[g(1661)]==="hi"&&e[g(828)]===v||e.pVolg(e.DiXaT,v))&&(this._clearPingTimer(),this[g(1216)](e[g(768)],e[g(870)]),this[g(377)+"gTimeoutId"]=e[g(1164)](setTimeout,this[g(1481)][g(854)](this),b)),!e[g(1472)]("hi",w[g(1661)]))try{e[g(1728)](ss,this,w,[i0,n0,v0,S0,b0,r0])}catch(C){let O=e[g(557)](Ie,e[g(1214)],{message:C.message,code:Ze["MESSAGE_"+g(269)],error:C});this[g(443)+g(776)+g(1434)](O)}},this[r(669)]=w=>{let g=r,b=this[g(240)+g(302)]?.[g(874)+g(684)+"es"](),v=this[g(240)+"tManager"]?.[g(695)+"ntEndpoint"]();if(b&&!w[g(1697)]){let C=g(1123)+v+(" fail, max retri"+g(1278)+"ed");this[g(443)+"hErrorEv"+g(1434)](e[g(1739)](Ie,e[g(1214)],{message:C,code:Ze[g(399)+"IES_ERROR"],error:w}));return}this[g(289)]&&e[g(701)](this[g(289)][g(201)+"te"],this[g(1664)])&&this[g(1455)+g(1717)](),this[g(443)+g(776)+g(1434)](e[g(1682)](Ie,e[g(1214)],{message:w.message,code:Ze[g(887)+g(1078)],error:w}))},this[r(932)]=async w=>{let g=r;this[g(1399)+"mer"](),this[g(375)+g(1189)](),this["_removeW"+g(821)+"rs"](),this[g(289)]=null,this[g(815)+g(202)]=!1;let b=this[g(240)+"tManager"]?.[g(874)+g(684)+"es"]();if(!b&&this[g(1332)+g(1343)]()&&!this[g(1538)+g(1473)]){let v=this[g(240)+g(302)]?.[g(695)+g(1180)+"nt"](),C=this[g(388)][g(576)+g(1103)+g(1768)](w[g(1532)],w.reason);this[g(443)+g(358)+"ent"](De(a[g(919)],{code:1006,reason:w.reason||g(1286)+"ng faile"+g(798)+g(880)+g(1449)+g(373)+v,willReconnect:C})),C&&this[g(815)]();return}if(w[g(1532)]!==1e3&&this[g(1538)+g(1473)]){this[g(443)+g(358)+g(1434)](a[g(1354)](De,a[g(919)],{code:1e3,reason:a[g(788)]})),this["_endpoin"+g(302)]?.["resetEnd"+g(404)+g(277)](),this[g(273)+g(844)]?.resetCounter();return}if(a[g(1549)](1e3,w[g(1532)])&&b){let v=this[g(240)+"tManager"]?.[g(695)+g(1180)+"nt"](),C=w[g(723)];C||(C=await a.jDGJf(Yc,this._url)),C=g(1286)+g(1437)+g(1319)+C+(g(1382)+"me: ")+v+(g(1186)+g(1272)+g(1418)),this["_dispatc"+g(358)+g(1434)](De(a[g(919)],{code:w.code,reason:C}));let O="connect "+v+(g(586)+"ax retri"+g(1278)+"ed");this[g(443)+g(776)+g(1434)](a[g(1354)](Ie,a.BvJjz,{message:O,code:Ze["MAX_RETR"+g(1569)+"R"]})),this[g(240)+g(302)]?.[g(226)+g(404)+g(277)](),this[g(273)+"sCounter"]?.[g(971)+"nter"]();return}if(a[g(1050)](1e3,w.code)&&!w[g(723)]){let v=this["_endpoin"+g(302)]?.[g(695)+"ntEndpoint"]();this[g(443)+g(358)+g(1434)](a[g(1354)](De,a.QeFju,{code:w[g(1532)],reason:g(1286)+g(1437)+g(798)+"wn reaso"+g(1449)+"ame: "+v})),this._endpointManager?.[g(226)+"pointCon"+g(277)](),this[g(273)+g(844)]?.["resetCou"+g(1321)]();return}this["_dispatchCloseEv"+g(1434)](w),this["_endpoin"+g(302)]?.[g(226)+g(404)+"fig"](),this["_pingLos"+g(844)]?.[g(971)+"nter"]()},this.onclose=null,this[r(440)]=null,this[r(641)+"e"]=null,this[r(1364)]=null,this[r(643)+r(1345)]=null,this["onReceiv"+r(979)]=null,this[r(1005)+r(737)+"yReconnect"]=null,this[r(433)+r(818)]=this[r(433)+r(818)][r(854)](this),this[r(433)+"ffLine"]=this["_handleO"+r(719)].bind(this),this[r(1211)+r(1722)]=this[r(1211)+r(1722)][r(854)](this),this[r(1211)+r(1120)]=this[r(1211)+r(1120)].bind(this),this[r(388)]={url:"",automaticOpen:!0,initReconnectInterval:1e3,maxReconnectInterval:1e4,reconnectIntervalGrowFactor:2,timeoutInterval:5e3,maxRetries:5,debug:!1,maxMessageQueueLength:e[r(288)](1,0),service:0,logIDGenerator:c,headers:void 0,payloadEncoding:"",payloadType:"",fpID:"",deviceID:"",accessKey:"",ttwID:"",bddID:"",aID:"",disableAutoReconnect:!1,customParams:{},pingInterval:15e3,pingTimeoutInterval:4e3,pingFrequency:r(1685),pingLossCount:2,enableTransformTextPayload:!1,logIDNewConfig:{enableAutoGenerateLogIDNew:!1,userIp:""},miniProgramParams:{customHttpHeader:{}},enableAutoAck:!1,reconnectInterceptor:()=>!0,enableQoS:!1,QoSLevel:2,messageStrategy:"CONTINUE",env:{xTTEnv:"",xUseEnv:""},listenNetworkChanged:!0};let{url:x,ws:f}=t,h=Array[r(736)](x)?x:e[r(980)]==typeof x?[x]:[];if(!h||e[r(1480)](0,h[r(796)]))throw new Error(e[r(1228)]);if(!Wc(f))throw new Error(r(500)+r(542)+"s params"+r(801)+r(469)+r(1275)+"is undef"+r(929));if(Object.assign(this._options,t),this[r(240)+r(302)]=new is(h,this[r(388)][r(1032)+"es"]),this[r(273)+r(844)]=new Vc(this[r(388)][r(299)+r(1207)]),this[r(388)][r(1369)+r(541)]&&(this._isInit=!0,this[r(815)]()),this._options[r(1518)+r(1040)+r(1788)])if(e.YsmSa(e[r(619)],r(369)))this[r(1485)+"T"]||this[r(1146)+"X"]?this["_onPageN"+r(1725)+r(1583)]():this[r(626)+"er"]&&this["_initGlo"+r(838)+r(1425)]();else{let w=this._options[r(576)+"tInterce"+r(1768)](_0x999dda,_0xd03bf3);this["_dispatc"+r(358)+r(1434)](a.rGgNZ(_0x583155,a[r(919)],{code:_0x582678,reason:_0x33cbf2,wasClean:!0,willReconnect:w})),w&&this[r(815)]()}}[n(433)+n(818)](){let t=n;this[t(388)][t(689)+t(1514)+t(489)]||this[t(1538)+t(1473)]||this[t(1092)+t(1345)]()}[n(433)+n(719)](){let t=n;if(e[t(896)](e.MwUuB,e[t(921)]))this[t(1603)+"ount"]=_0x2bfe45,this[t(1271)]=0;else{this["_destroy"+t(471)+"t"]();let r=e[t(711)](Rr,t(576)+"t",{message:e[t(1612)]});this[t(1005)+"mediatel"+t(1637)+"ct"]&&this["onStopIm"+t(737)+t(1637)+"ct"](r)}}[n(449)+"balEvent"+n(1425)](){let t=n;this[t(626)+"er"]&&window.addEventListener(e[t(688)],this[t(433)+t(818)]),this[t(626)+"er"]&&window[t(884)+"Listener"](e[t(589)],this["_handleO"+t(719)]),this[t(626)+"er"]&&window["addEvent"+t(1425)](e[t(722)],this[t(1211)+t(1722)]),this._isBrowser&&window[t(884)+t(1425)](e[t(885)],this._handlePageShow)}[n(822)+n(838)+"Listener"](){let t=n,r={GhMEs:e.uVcRl,YRxeM:function(a,x){return a||x},wTkyD:e[t(1712)]};if(e[t(1566)](e[t(1379)],e[t(1379)])){let a=r.GhMEs[t(1413)]("|"),x=0;for(;;){switch(a[x++]){case"0":if(bhXzEr[t(1634)](_0x2400fd,_0x1a4ac7)&&bhXzEr[t(520)]!=typeof _0x793980&&_0x25e483)return!0;continue;case"1":if(_0x741b54&&_0x27d251["connectS"+t(1592)])return!0;continue;case"2":if(_0x3eb92d&&_0x1abd0d.connectSocket)return!0;continue;case"3":if(_0x3c827d)return!0;continue;case"4":return!1}break}}else this[t(626)+"er"]&&window[t(605)+t(720)+t(396)](e[t(688)],this["_handleO"+t(818)]),this._isBrowser&&window[t(605)+t(720)+t(396)](e[t(589)],this["_handleO"+t(719)]),this[t(626)+"er"]&&window["removeEv"+t(720)+t(396)](e[t(722)],this[t(1211)+"ageHide"]),this[t(626)+"er"]&&window[t(605)+t(720)+t(396)](t(810),this[t(1211)+"ageShow"])}[n(1211)+n(1722)](t){let r=n;!t[r(853)+"d"]&&(this[r(626)+"er"]&&window[r(605)+"entListe"+r(396)](e.nRkIR,this[r(1211)+"ageHide"]),this._isBrowser&&window[r(605)+"entListe"+r(396)](e[r(885)],this[r(1211)+r(1120)]),this[r(1360)]()),this[r(626)+"er"]&&window[r(605)+"entListe"+r(396)](e[r(688)],this[r(433)+"nLine"]),this._isBrowser&&window[r(605)+r(720)+r(396)](e[r(589)],this[r(433)+r(719)])}[n(1211)+n(1120)](t){let r=n;t[r(853)+"d"]&&(this[r(1332)+r(1343)]()&&(!this[r(289)]||this[r(289)][r(201)+"te"]!==this.OPEN||e.xpfen(this._ws.readyState,this[r(1579)+"NG"]))&&this["_handleO"+r(818)](),this._isBrowser&&window["addEvent"+r(1425)](e[r(688)],this[r(433)+r(818)]),this[r(626)+"er"]&&window.addEventListener("offline",this[r(433)+r(719)]))}async["_generat"+n(390)](t){let r=n,{fpID:a,deviceID:x,bddID:f,ttwID:h,accessKey:w,aID:g,customParams:b={},enableAutoAck:v,enableQoS:C,QoSLevel:O,env:R}=this[r(388)],F,ue,be;this[r(626)+"er"]||this._isMiniWX||this._isMiniTT?(F=location&&e[r(1227)]==location[r(1408)]?e[r(362)]:e[r(1244)],ue=t[r(1212)](/((^ws)|(^http))((?:[s]*:\/\/))/,""),be=/^wss(.*:\/\/)/[r(1646)](t)?t:""+F+ue):(F=e[r(362)],ue=t[r(1212)](/(^http)((?:[s]*:\/\/))/,""),be=/(^ws)((?:[s]*:\/\/))/[r(1646)](ue)?ue:""+F+ue);let Gt=f?e[r(982)]:h?r(1533):e[r(1395)],mn=f||h||x;if(!mn||!Gt)throw new Error(r(500)+r(511)+"ddID, de"+r(532)+r(640));let P0=e.cIrPe==typeof b?await e.XhxHE(b):b,k0=R?e[r(1176)]($c,R.xUseEnv,R[r(360)]):{},Ur=Object[r(1163)]({device_platform:e[r(320)],version_code:e[r(651)],access_key:w,fpid:a,aid:g,[Gt]:mn,xsack:v?1:0,xaack:v?1:0,xsqos:C?1:0,qos_level:C?O:void 0,qos_sdk_version:2,...k0},P0),T0=Object[r(1561)](Ur)[r(1091)]((qr,Hr)=>Ur[Hr]!==void 0?""+qr+(qr?"&":"?")+Hr+"="+Ur[Hr]:qr,"");return be+r(1412)+T0}async[n(815)](){let t=n,r={NVGnS:t(1697)};if(!(this[t(815)+t(202)]||this[t(1538)+t(1473)])){this[t(815)+t(202)]=!0;try{if(e[t(1598)]===e[t(1598)]){let x=this["_endpoin"+t(302)]?.[t(930)+t(996)+t(345)+t(325)+t(1055)](),{timeoutInterval:f}=this._options;if(x)if(e[t(1390)]!=="oxORc")for(var a in _0x282373)_0x3cebe8.o(_0x561d95,a)&&!_0x2416d5.o(_0x3d0246,a)&&_0x4a6705[t(1512)+t(1778)](_0x374e0d,a,{enumerable:!0,get:_0x5b1bb8[a]});else{let w=this[t(240)+"tManager"]?.[t(695)+"ntEndpoint"](),g=this[t(240)+t(302)]?.[t(286)+t(1445)+t(1624)+t(267)+t(825)](),b=this[t(240)+t(302)]?.[t(695)+t(1180)+t(1721)+t(1053)]();if(g){if(e.fXmow(e[t(207)],t(265)))return{frameType:_0x48d70e,headers:[{key:e.iLZAR,value:e[t(784)]}],payload:void 0};{let v=t(1123)+w+(" timeout"+t(1186)+t(1272)+"ached, will use backup e"+t(221))+g+(t(272)+"y"),C=e[t(365)](Ie,"error",{message:v,code:Ze[t(399)+t(1569)+"R"]});this._debug(v),this[t(443)+t(776)+t(1434)](C),this[t(1417)]=await this[t(670)+t(390)](g),this._debug(t(1123)+g+" "+b+t(668)),this[t(1210)+"sListeners"]()}}else{let v=t(1123)+w+(" timeout, max re"+t(1272)+t(1418));this[t(1225)](v),this["_dispatc"+t(776)+t(1434)](e[t(711)](Ie,e.sukVs,{message:v,code:Ze["MAX_RETR"+t(1569)+"R"]}));return}}else if(e[t(1409)](e[t(755)],t(658))){let w=this[t(240)+t(302)]?.[t(695)+t(1180)+t(459)+t(600)](),g=this[t(240)+t(302)]?.["getCurrentEndpoi"+t(1721)+t(1053)]();this[t(1417)]=await this._generateUrl(w||""),this[t(1225)](t(1123)+w+" "+g+t(668)),this[t(1210)+t(821)+"rs"]()}else{let w=e[t(1335)][t(1413)]("|"),g=0;for(;;){switch(w[g++]){case"0":_0x4d9583=["put","add",t(989),t(726)];continue;case"1":_0x3c49eb=[Pqqzol[t(326)],Pqqzol[t(1534)],t(1398),t(311)+"ys",Pqqzol[t(706)]];continue;case"2":Pqqzol[t(1167)](_0x3bf97d);continue;case"3":_0x1eef0b=new _0x5ef5e2;continue;case"4":Pqqzol[t(465)](_0x3a948a,b=>({...b,get:(v,C,O)=>_0x47e1d0(v,C)||b.get(v,C,O),has:(v,C)=>!!_0xb9f923(v,C)||b[t(1184)](v,C)}));continue;case"5":_0x718e0e();continue}break}}if(this._isInit)this._isInit=!1;else if(e[t(662)]("TxzeA",t(923))){let w=e[t(1663)](Rr,e[t(1178)],{message:e[t(1676)]});this[t(643)+t(1345)]&&this[t(643)+t(1345)](w)}else this[t(1216)](r[t(1621)],_0x49c800),this[t(641)+"e"]&&this[t(641)+"e"](_0x3267b3);let h=this[t(240)+t(302)]?.[t(695)+t(1180)+"ntTriesC"+t(1053)]()||0;e.bUxDN(h,1)&&await this[t(395)](h-1),this[t(1225)](t(1286)+t(1743)+this[t(1417)]+(" protoco"+t(973))+this[t(1025)+"ls"]),this[t(289)]=Gc({url:this[t(1417)],protocols:[this[t(1025)+"ls"]],headers:this[t(388)].miniProgramParams[t(592)+t(1386)]},this._options.ws),(this[t(626)+"er"]||this[t(1198)+"r"])&&this._ws&&(this[t(289)][t(1704)+"pe"]=this[t(1450)+"ype"]),this[t(718)+t(1195)](),this["_connectionTimeo"+t(527)]=e[t(1177)](setTimeout,this[t(1333)+"ut"][t(854)](this),f)}else{let{initReconnectInterval:x,maxReconnectInterval:f,reconnectIntervalGrowFactor:h}=this[t(388)],w=x*_0x8d434d[t(1771)](h,e[t(606)](_0x2a66fd,1));return e[t(290)](w,f)?f:w}}catch(x){throw this[t(815)+"Lock"]=!1,x}}}[n(1399)+n(245)](){let t=n;if(e[t(553)](e[t(1754)],e[t(805)]))e[t(309)](clearTimeout,this[t(815)+"ionTimeoutId"]),this[t(815)+t(1647)+t(527)]=null;else{if(e[t(1031)](4,_0x45985d[t(796)])){let r=_0x34e00b[t(644)+"g"](0,e[t(1526)](4,_0x1f6cad[t(796)])),a=r[t(632)](_0x206d89);_0x592853[t(1774)](a)}else _0x2bbe2d[t(1774)](_0x16a40c);_0x419a53&&(_0xb79832+=1),_0xe2a2f+=1,_0x29d1a7=!1}}[n(375)+n(1189)](){let t=n;clearTimeout(this[t(377)+"gTimeoutId"]),clearTimeout(this[t(1511)+"ctTimeoutId"]),this[t(377)+t(653)+"Id"]=null,this[t(1511)+t(1010)+"tId"]=null}_debug(...t){let r=n;this[r(388)][r(582)]&&console.log[r(1063)](console,[e[r(673)],...t])}[n(1706)+n(444)+"e"](t){let r=n,{initReconnectInterval:a,maxReconnectInterval:x,reconnectIntervalGrowFactor:f}=this._options,h=e.CxyrE(a,Math[r(1771)](f,e[r(606)](t,1)));return e.OhKug(h,x)?x:h}[n(1481)](){let t=n;if(this[t(289)]&&this[t(289)][t(201)+"te"]===this[t(1579)+"NG"]){this[t(375)+t(1189)](),this[t(377)+t(653)+"Id"]=setTimeout(this._ping[t(854)](this),this._options[t(318)+t(316)]);return}if(!this._ws||e[t(1465)](this[t(289)][t(201)+"te"],this[t(1664)]))return void this["_handleR"+t(1345)]();this[t(289)]&&this[t(289)][t(530)]("hi"),this["_reconne"+t(1010)+t(1421)]=e[t(770)](setTimeout,this["_handleR"+t(1345)+t(1763)][t(854)](this),this[t(388)]["pingTime"+t(793)+"val"])}[n(1092)+n(1345)+n(1763)](){let t=n;this._pingLossCounter?.[t(614)](),this[t(1216)](t(1723)+t(802)+"t",t(1740)),this["_pingLos"+t(844)]?.["checkRea"+t(1245)+"nt"]()?this[t(1092)+t(1345)]():this[t(1481)]()}[n(1332)+n(1343)](){let t=n;return this._isMiniTT||this._isMiniWX?this[t(1109)+t(1505)+t(728)]:(this._isBrowser||this._isWorker)&&this[t(388)][t(1518)+"tworkCha"+t(1788)]?navigator.onLine:!0}[n(1092)+n(1345)](){let t=n;!this[t(1332)+t(1343)]()||this[t(1538)+"osed"]||(this[t(240)+t(302)]?.[t(226)+t(404)+"fig"](),this[t(273)+t(844)]?.["resetCou"+t(1321)](),this._ws?this[t(1455)+t(1717)](1001,e.RdwyV,!0):this._connect())}[n(873)+n(1725)+n(1583)](){let t=n;if(e[t(927)](e[t(1495)],e[t(1102)]))this[t(1485)+"T"]?tt["onNetworkStatusC"+t(1090)](({isConnected:r})=>{let a=t;this["_miniNav"+a(1505)+"line"]=r,r?this[a(433)+a(818)]():this["_handleO"+a(719)]()}):this._isMiniWX&&wx[t(538)+"kStatusC"+t(1090)](({isConnected:r})=>{let a=t;this[a(1109)+"igatorOnline"]=r,r?this[a(433)+a(818)]():this[a(433)+"ffLine"]()});else return this[t(289)]?this[t(289)][t(1617)+"ns"]:""}_wait(t){let r={YQHOr:function(a,x,f){return e[k(1292)](a,x,f)}};return new Promise(a=>{let x=k;r[x(1527)](setTimeout,a,this["_getInte"+x(444)+"e"](t))})}[n(1455)+n(1717)](t=1e3,r="",a=!1){let x=n;this[x(289)]&&this[x(506)+"WebSocket"](t,r,a)}[n(1333)+"ut"](){let t=n,r=this[t(240)+t(302)]?.[t(695)+t(1180)+"nt"]();this._debug(t(1123)+r+t(1038)),this[t(1455)+t(1717)](1001,e.hrlXj,!0)}_sendAck(t){let r=n,a={JQKpa:function(f,h){return e[k(607)](f,h)},NCPIt:e.IRDTh,nbfsc:e[r(1531)],lDFzk:"__esModule"},x=e[r(381)](re,t);this[r(289)]&&e[r(970)](this[r(289)].readyState,this[r(1664)])&&(e.mVcGD(e.CjjOK,r(1144))?(this._ws&&this[r(289)].send(x),this[r(1225)](e[r(1626)],t)):_0x19d4af.r=f=>{let h=r;tAoHrX[h(1491)](tAoHrX[h(1559)],typeof _0x378a29)&&_0x7a8818.toStringTag&&_0x560f8b["definePr"+h(1778)](f,_0x5c33f9[h(1605)+h(637)],{value:tAoHrX.nbfsc}),_0x4dbb03[h(1512)+h(1778)](f,tAoHrX[h(1503)],{value:!0})})}["_removeW"+n(821)+"rs"](){let t=n,r=e[t(1734)][t(1413)]("|"),a=0;for(;;){switch(r[a++]){case"0":this[t(289)][t(605)+t(720)+t(396)](e[t(863)],this[t(223)]);continue;case"1":this[t(289)]["removeEv"+t(720)+t(396)](e[t(1284)],this[t(1535)+"ge"]);continue;case"2":if(!this[t(289)])return;continue;case"3":this._ws["removeEv"+t(720)+t(396)]("close",this[t(932)]);continue;case"4":this[t(289)][t(605)+t(720)+t(396)](e[t(1214)],this[t(669)]);continue}break}}[n(718)+n(1195)](){let t=n,r={meQIu:function(a,x,f){return e[k(1542)](a,x,f)}};if(e[t(454)](e[t(961)],e[t(961)])){if(!this._ws)return;this[t(289)][t(884)+t(1425)](e[t(863)],this[t(223)]),this[t(289)][t(884)+"Listener"](t(1360),this[t(932)]),this[t(289)][t(884)+t(1425)](e.QCUmg,this[t(1535)+"ge"]),this[t(289)]["addEvent"+t(1425)](e.sukVs,this._onError)}else{let a=OFSyAS[t(1356)](_0x102534,_0x37141b,_0xf3ee67.length);_0x51292b[t(1582)][t(1651)](_0x35a005,a)}}[n(1217)+n(483)](t=1e3,r=""){let a=n;try{e[a(1629)]!==e[a(401)]?this[a(289)]&&this[a(289)][a(1360)](t,r):_0x21a84a.log(_0x482b1e)}catch{}}[n(506)+n(471)+"t"](t=1e3,r="",a=!1){let x=n;if(this[x(375)+x(1189)](),this[x(1399)+x(245)](),this[x(1210)+x(821)+"rs"](),this[x(1217)+x(483)](1e3,r),this[x(815)+x(202)]=!1,a&&this[x(1332)+x(1343)]()&&!this[x(1538)+x(1473)]){if(this[x(240)+x(302)]?.[x(874)+"chMaxTries"]()){let h=this[x(240)+x(302)]?.[x(695)+x(1180)+"nt"]();this[x(443)+"hCloseEv"+x(1434)](e[x(1204)](De,e[x(587)],{code:1006,reason:"connect "+h+(x(1038)+x(1186)+x(1272)+x(1418)),wasClean:!0}))}else{let h=this[x(388)][x(576)+x(1103)+x(1768)](t,r);this[x(443)+x(358)+x(1434)](e[x(976)](De,e.XEKJp,{code:t,reason:r,wasClean:!0,willReconnect:h})),h&&this[x(815)]()}return}this["_navigat"+x(1343)]()||this[x(1538)+"osed"]?this[x(443)+x(358)+"ent"](e[x(992)](De,x(1360),{code:t,reason:e[x(809)]})):this[x(443)+x(358)+x(1434)](e[x(356)](De,x(1360),{code:1006,reason:e[x(1591)]})),this[x(289)]=null,this[x(240)+x(302)]?.[x(226)+"pointCon"+x(277)](),this[x(273)+x(844)]?.[x(971)+x(1321)]()}[n(443)+n(1506)+"nt"](t){let r=n;this[r(1216)]("open",t),this[r(1364)]&&this[r(1364)](t)}[n(443)+n(535)+n(1081)](t){let r=n;this[r(1216)](e[r(1284)],t),this[r(641)+"e"]&&this.onmessage(t)}[n(443)+n(1648)+n(1713)](t){let r=n;this[r(1216)](e.pUhme,t),this[r(804)+r(979)]&&this[r(804)+"eAck"](t)}[n(443)+"hErrorEvent"](t){let r=n;this[r(1216)](e[r(1214)],t),this[r(440)]&&this[r(440)](t)}[n(443)+n(358)+"ent"](t){let r=n;this[r(1216)](r(1360),t),this[r(943)]&&this[r(943)](t)}get[n(1704)+"pe"](){let t=n;return this[t(289)]?this[t(289)].binaryType:this[t(1450)+t(1131)]}set binaryType(t){let r=n;this[r(1450)+"ype"]=t,this[r(289)]&&(this._ws.binaryType=t)}get[n(1064)+"nt"](){let t=n;if(t(339)===t(1079)){let r=_0x191465[t(1466)]();return r?(r[t(397)]=r[t(1572)]=0,r):{bytes:new _0x32041d(64),offset:0,limit:0}}else return this[t(240)+t(302)]?.["getCurre"+t(1180)+t(1721)+"ount"]()||0}get[n(891)+"Amount"](){let t=n;return this[t(1537)+t(550)][t(1091)]((a,x)=>(a+=x&&x[t(1062)+"th"]||0,a),0)+(this[t(289)]?this[t(289)][t(891)+t(890)]:0)}get extensions(){let t=n;return this[t(289)]?this[t(289)][t(1617)+"ns"]:""}get[n(1408)](){let t=n;return this[t(289)]?this[t(289)][t(1408)]:""}get readyState(){let t=n;return this[t(289)]?this._ws.readyState:this._options[t(1369)+t(541)]?this[t(1579)+"NG"]:this.CLOSED}get[n(1781)](){let t=n;return this[t(289)]?this[t(289)][t(1781)]:this[t(1417)]}close(t=1e3,r){let a=n,x=e[a(794)][a(1413)]("|"),f=0;for(;;){switch(x[f++]){case"0":this["_clearTi"+a(245)]();continue;case"1":if(this[a(289)][a(201)+"te"]===this[a(1067)]||this[a(289)][a(201)+"te"]===this[a(599)])return void this._debug(e.OfEqP);continue;case"2":if(!this._ws)return void this[a(1225)](e.yaYQc);continue;case"3":this[a(375)+a(1189)]();continue;case"4":this[a(409)+a(283)]?.[a(938)]();continue;case"5":this[a(506)+"WebSocket"](t,r);continue;case"6":this["_readyCl"+a(1473)]=!0;continue;case"7":this[a(822)+a(838)+a(1425)]();continue}break}}async[n(530)](t,r){let a=n;if(e.PHnMf(null,t))throw new Error(a(500)+a(1483)+a(759)+a(522)+"a must b"+a(997)+a(781)+a(513)+a(1057));e[a(1552)](e[a(666)],typeof t)&&(t=JSON[a(1577)+"y"](t)),e[a(607)](a(410),typeof t)&&!e.IeGpt(t,ArrayBuffer)&&!(t[a(1054)]&&e[a(1316)](t[a(1054)],ArrayBuffer))&&(t=JSON.stringify(t));let x=await e[a(547)](cs,t),f=e[a(1490)](Jc,t),{method:h=0,service:w=this[a(388)][a(745)],logID:g=this._options[a(1548)+a(1749)](),headers:b=this[a(388)][a(951)],payloadEncoding:v=this._options[a(900)+"ncoding"],payloadType:C=this[a(388)][a(384)+a(1131)],logIDNew:O=this._options[a(762)+a(1470)][a(463)+"toGenerateLogIDNew"]?e[a(1678)](o,this[a(388)][a(762)+"Config"][a(233)]):""}=r||{};if(!w)throw new Error(e[a(1367)]);let R={SeqID:G[a(764)+"er"](this[a(1251)]++),LogID:G[a(764)+"er"](g),service:w,method:h,headers:b,payloadEncoding:v instanceof Object?v[a(1323)]?v[a(1323)]:"":v,payloadType:C instanceof Object?C[a(1737)]?C[a(1737)]:f:C||f,payload:x,LogIDNew:O},F=e.mxQlT(re,R);return this[a(289)]&&e.cXPRr(this[a(289)][a(201)+"te"],this[a(1664)])?(this[a(289)]&&this[a(289)].send(F),this[a(1225)](e[a(840)],R)):this[a(1537)+a(550)].length<this._options[a(1014)+"geQueueL"+a(1574)]?(this[a(1537)+"Queue"][a(1774)](F),this[a(1225)](a(714),R)):(this._messageQueue.shift(),this[a(1537)+"Queue"][a(1774)](F)),{seqID:this[a(1251)],logID:g,logIDNew:O}}async[n(576)+"t"](t){let r=n,{url:a}=e[r(372)](t,{}),x=Array.isArray(a)?a:e.UaeLL==typeof a?[a]:[];t&&Object[r(1163)](this[r(388)],t),x&&x[r(796)]?this[r(240)+r(302)]=new is(x,this[r(388)][r(1032)+"es"]):this[r(240)+r(302)]?.["resetEnd"+r(404)+"fig"](),this[r(273)+r(844)]?.[r(971)+r(1321)](this[r(388)][r(299)+"Count"]),this[r(1538)+"osed"]=!1,this[r(289)]&&this[r(289)].readyState!==this.CLOSED?this[r(1455)+r(1717)](1e3,r(1296)+r(1345)+r(1523),!0):(this[r(393)]=!0,this._connect())}async[n(1394)](){let t=n;if(!this[t(815)+t(202)])if(e[t(896)](e.WxsID,t(220))){let r=e[t(594)](_0xdfd0a2,_0x46584c,1);_0x1560bf[t(1582)][r]=_0x175290}else{let r=e[t(1229)][t(1413)]("|"),a=0;for(;;){switch(r[a++]){case"0":this._connect();continue;case"1":this[t(273)+t(844)]?.[t(971)+t(1321)]();continue;case"2":this[t(1538)+t(1473)]=!1;continue;case"3":this[t(393)]=!0;continue;case"4":this[t(240)+t(302)]?.[t(226)+t(404)+"fig"]();continue}break}}}[n(884)+"Listener"](t,r){this.on(t,r)}[n(1586)+n(1081)](t){let r=n,{type:a}=t;this[r(1216)](a,t)}[n(605)+"entListe"+n(396)](t,r){this.off(t,r)}[n(1353)](){let t=n,r={RCXHO:function(a,x){return e[k(1149)](a,x)},egwBA:e[t(870)],oYIGm:e[t(611)]};return new Promise((a,x)=>{let f=t,h={ypzFe:function(b,v){return b(v)},jljzP:e[f(960)],WjrMQ:e.wVKst,faVAg:e[f(611)]};this["_clearPi"+f(1189)](),this._pingPongTimeoutId=setTimeout(this[f(1481)][f(854)](this),this._options[f(318)+"rval"]);let w=()=>{let b=f;r[b(704)](a,r[b(1746)]),this.off(b(1723)+b(1209)+"s",w),this[b(657)](r[b(869)],g)},g=()=>{let b=f;h[b(1193)](x,h[b(1388)]),this[b(657)](h[b(248)],w),this[b(657)](h[b(860)],g)};this.on(e[f(768)],w),this.on(e[f(611)],g),this[f(1481)]()})}}})(),Y["CustomCl"+E(663)]=te.CustomCloseEvent,Y[E(1095)+E(729)]=te[E(1095)+E(729)],Y[E(898)+"e"]=te[E(898)+"e"],Y[E(1081)]=te[E(1081)],Y[E(1357)]=te[E(1357)],Y["Frontier"+E(1554)+"vent"]=te["Frontier"+E(1554)+E(1235)],Y[E(1554)+E(1235)]=te[E(1554)+E(1235)],Y.OpenEvent=te.OpenEvent,Y[E(912)+E(1588)]=te[E(912)+E(1588)],Y[E(241)+E(663)]=te[E(241)+E(663)],Y.createErrorEvent=te[E(1550)+E(729)],Y[E(858)+E(1456)+"nt"]=te["createMe"+E(1456)+"nt"],Y[E(1670)+E(1171)]=te[E(1670)+E(1171)],Y[E(387)+"connectE"+E(1235)]=te[E(387)+E(292)+E(1235)],Y[E(385)+E(991)]=te[E(385)+E(991)],Y[E(338)+E(981)]=te[E(338)+E(981)];for(Yn in te)[E(1277)+E(663),"CustomEr"+E(729),E(898)+"e",E(1081),E(1357),E(727)+E(1554)+E(1235),E(1554)+E(1235),"OpenEvent",E(912)+E(1588),E(241)+E(663),E(1550)+E(729),E(858)+E(1456)+"nt","createOpenEvent",E(387)+"connectE"+E(1235),E(385)+E(991),E(338)+E(981)].indexOf(Yn)===-1&&(Y[Yn]=te[Yn]);var Yn;Object["definePr"+E(1778)](Y,E(1056)+"le",{value:!0})});var Je=_e((e_,ta)=>{"use strict";var Zo=["nodebuffer","arraybuffer","fragments"],ea=typeof Blob<"u";ea&&Zo.push("blob");ta.exports={BINARY_TYPES:Zo,CLOSE_TIMEOUT:3e4,EMPTY_BUFFER:Buffer.alloc(0),GUID:"258EAFA5-E914-47DA-95CA-C5AB0DC85B11",hasBlob:ea,kForOnEventAttribute:Symbol("kIsForOnEventAttribute"),kListener:Symbol("kListener"),kStatusCode:Symbol("status-code"),kWebSocket:Symbol("websocket"),NOOP:()=>{}}});var an=_e((t_,rr)=>{"use strict";var{EMPTY_BUFFER:rf}=Je(),di=Buffer[Symbol.species];function sf(n,e){if(n.length===0)return rf;if(n.length===1)return n[0];let s=Buffer.allocUnsafe(e),o=0;for(let c=0;c<n.length;c++){let d=n[c];s.set(d,o),o+=d.length}return o<e?new di(s.buffer,s.byteOffset,o):s}function na(n,e,s,o,c){for(let d=0;d<c;d++)s[o+d]=n[d]^e[d&3]}function ra(n,e){for(let s=0;s<n.length;s++)n[s]^=e[s&3]}function of(n){return n.length===n.buffer.byteLength?n.buffer:n.buffer.slice(n.byteOffset,n.byteOffset+n.length)}function ui(n){if(ui.readOnly=!0,Buffer.isBuffer(n))return n;let e;return n instanceof ArrayBuffer?e=new di(n):ArrayBuffer.isView(n)?e=new di(n.buffer,n.byteOffset,n.byteLength):(e=Buffer.from(n),ui.readOnly=!1),e}rr.exports={concat:sf,mask:na,toArrayBuffer:of,toBuffer:ui,unmask:ra};if(!process.env.WS_NO_BUFFER_UTIL)try{let n=ee("bufferutil");rr.exports.mask=function(e,s,o,c,d){d<48?na(e,s,o,c,d):n.mask(e,s,o,c,d)},rr.exports.unmask=function(e,s){e.length<32?ra(e,s):n.unmask(e,s)}}catch{}});var oa=_e((n_,sa)=>{"use strict";var ia=Symbol("kDone"),fi=Symbol("kRun"),li=class{constructor(e){this[ia]=()=>{this.pending--,this[fi]()},this.concurrency=e||1/0,this.jobs=[],this.pending=0}add(e){this.jobs.push(e),this[fi]()}[fi](){if(this.pending!==this.concurrency&&this.jobs.length){let e=this.jobs.shift();this.pending++,e(this[ia])}}};sa.exports=li});var Mt=_e((r_,da)=>{"use strict";var cn=ee("zlib"),aa=an(),af=oa(),{kStatusCode:ca}=Je(),cf=Buffer[Symbol.species],xf=Buffer.from([0,0,255,255]),sr=Symbol("permessage-deflate"),$e=Symbol("total-length"),Ot=Symbol("callback"),ct=Symbol("buffers"),Nt=Symbol("error"),ir,gi=class{constructor(e){if(this._options=e||{},this._threshold=this._options.threshold!==void 0?this._options.threshold:1024,this._maxPayload=this._options.maxPayload|0,this._isServer=!!this._options.isServer,this._deflate=null,this._inflate=null,this.params=null,!ir){let s=this._options.concurrencyLimit!==void 0?this._options.concurrencyLimit:10;ir=new af(s)}}static get extensionName(){return"permessage-deflate"}offer(){let e={};return this._options.serverNoContextTakeover&&(e.server_no_context_takeover=!0),this._options.clientNoContextTakeover&&(e.client_no_context_takeover=!0),this._options.serverMaxWindowBits&&(e.server_max_window_bits=this._options.serverMaxWindowBits),this._options.clientMaxWindowBits?e.client_max_window_bits=this._options.clientMaxWindowBits:this._options.clientMaxWindowBits==null&&(e.client_max_window_bits=!0),e}accept(e){return e=this.normalizeParams(e),this.params=this._isServer?this.acceptAsServer(e):this.acceptAsClient(e),this.params}cleanup(){if(this._inflate&&(this._inflate.close(),this._inflate=null),this._deflate){let e=this._deflate[Ot];this._deflate.close(),this._deflate=null,e&&e(new Error("The deflate stream was closed while data was being processed"))}}acceptAsServer(e){let s=this._options,o=e.find(c=>!(s.serverNoContextTakeover===!1&&c.server_no_context_takeover||c.server_max_window_bits&&(s.serverMaxWindowBits===!1||typeof s.serverMaxWindowBits=="number"&&s.serverMaxWindowBits>c.server_max_window_bits)||typeof s.clientMaxWindowBits=="number"&&!c.client_max_window_bits));if(!o)throw new Error("None of the extension offers can be accepted");return s.serverNoContextTakeover&&(o.server_no_context_takeover=!0),s.clientNoContextTakeover&&(o.client_no_context_takeover=!0),typeof s.serverMaxWindowBits=="number"&&(o.server_max_window_bits=s.serverMaxWindowBits),typeof s.clientMaxWindowBits=="number"?o.client_max_window_bits=s.clientMaxWindowBits:(o.client_max_window_bits===!0||s.clientMaxWindowBits===!1)&&delete o.client_max_window_bits,o}acceptAsClient(e){let s=e[0];if(this._options.clientNoContextTakeover===!1&&s.client_no_context_takeover)throw new Error('Unexpected parameter "client_no_context_takeover"');if(!s.client_max_window_bits)typeof this._options.clientMaxWindowBits=="number"&&(s.client_max_window_bits=this._options.clientMaxWindowBits);else if(this._options.clientMaxWindowBits===!1||typeof this._options.clientMaxWindowBits=="number"&&s.client_max_window_bits>this._options.clientMaxWindowBits)throw new Error('Unexpected or invalid parameter "client_max_window_bits"');return s}normalizeParams(e){return e.forEach(s=>{Object.keys(s).forEach(o=>{let c=s[o];if(c.length>1)throw new Error(`Parameter "${o}" must have only a single value`);if(c=c[0],o==="client_max_window_bits"){if(c!==!0){let d=+c;if(!Number.isInteger(d)||d<8||d>15)throw new TypeError(`Invalid value for parameter "${o}": ${c}`);c=d}else if(!this._isServer)throw new TypeError(`Invalid value for parameter "${o}": ${c}`)}else if(o==="server_max_window_bits"){let d=+c;if(!Number.isInteger(d)||d<8||d>15)throw new TypeError(`Invalid value for parameter "${o}": ${c}`);c=d}else if(o==="client_no_context_takeover"||o==="server_no_context_takeover"){if(c!==!0)throw new TypeError(`Invalid value for parameter "${o}": ${c}`)}else throw new Error(`Unknown parameter "${o}"`);s[o]=c})}),e}decompress(e,s,o){ir.add(c=>{this._decompress(e,s,(d,u)=>{c(),o(d,u)})})}compress(e,s,o){ir.add(c=>{this._compress(e,s,(d,u)=>{c(),o(d,u)})})}_decompress(e,s,o){let c=this._isServer?"client":"server";if(!this._inflate){let d=`${c}_max_window_bits`,u=typeof this.params[d]!="number"?cn.Z_DEFAULT_WINDOWBITS:this.params[d];this._inflate=cn.createInflateRaw({...this._options.zlibInflateOptions,windowBits:u}),this._inflate[sr]=this,this._inflate[$e]=0,this._inflate[ct]=[],this._inflate.on("error",uf),this._inflate.on("data",xa)}this._inflate[Ot]=o,this._inflate.write(e),s&&this._inflate.write(xf),this._inflate.flush(()=>{let d=this._inflate[Nt];if(d){this._inflate.close(),this._inflate=null,o(d);return}let u=aa.concat(this._inflate[ct],this._inflate[$e]);this._inflate._readableState.endEmitted?(this._inflate.close(),this._inflate=null):(this._inflate[$e]=0,this._inflate[ct]=[],s&&this.params[`${c}_no_context_takeover`]&&this._inflate.reset()),o(null,u)})}_compress(e,s,o){let c=this._isServer?"server":"client";if(!this._deflate){let d=`${c}_max_window_bits`,u=typeof this.params[d]!="number"?cn.Z_DEFAULT_WINDOWBITS:this.params[d];this._deflate=cn.createDeflateRaw({...this._options.zlibDeflateOptions,windowBits:u}),this._deflate[$e]=0,this._deflate[ct]=[],this._deflate.on("data",df)}this._deflate[Ot]=o,this._deflate.write(e),this._deflate.flush(cn.Z_SYNC_FLUSH,()=>{if(!this._deflate)return;let d=aa.concat(this._deflate[ct],this._deflate[$e]);s&&(d=new cf(d.buffer,d.byteOffset,d.length-4)),this._deflate[Ot]=null,this._deflate[$e]=0,this._deflate[ct]=[],s&&this.params[`${c}_no_context_takeover`]&&this._deflate.reset(),o(null,d)})}};da.exports=gi;function df(n){this[ct].push(n),this[$e]+=n.length}function xa(n){if(this[$e]+=n.length,this[sr]._maxPayload<1||this[$e]<=this[sr]._maxPayload){this[ct].push(n);return}this[Nt]=new RangeError("Max payload size exceeded"),this[Nt].code="WS_ERR_UNSUPPORTED_MESSAGE_LENGTH",this[Nt][ca]=1009,this.removeListener("data",xa),this.reset()}function uf(n){if(this[sr]._inflate=null,this[Nt]){this[Ot](this[Nt]);return}n[ca]=1007,this[Ot](n)}});var Bt=_e((i_,or)=>{"use strict";var{isUtf8:ua}=ee("buffer"),{hasBlob:ff}=Je(),lf=[0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,1,0,1,1,1,1,1,0,0,1,1,0,1,1,0,1,1,1,1,1,1,1,1,1,1,0,0,0,0,0,0,0,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,0,0,0,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,0,1,0,1,0];function gf(n){return n>=1e3&&n<=1014&&n!==1004&&n!==1005&&n!==1006||n>=3e3&&n<=4999}function hi(n){let e=n.length,s=0;for(;s<e;)if((n[s]&128)===0)s++;else if((n[s]&224)===192){if(s+1===e||(n[s+1]&192)!==128||(n[s]&254)===192)return!1;s+=2}else if((n[s]&240)===224){if(s+2>=e||(n[s+1]&192)!==128||(n[s+2]&192)!==128||n[s]===224&&(n[s+1]&224)===128||n[s]===237&&(n[s+1]&224)===160)return!1;s+=3}else if((n[s]&248)===240){if(s+3>=e||(n[s+1]&192)!==128||(n[s+2]&192)!==128||(n[s+3]&192)!==128||n[s]===240&&(n[s+1]&240)===128||n[s]===244&&n[s+1]>143||n[s]>244)return!1;s+=4}else return!1;return!0}function hf(n){return ff&&typeof n=="object"&&typeof n.arrayBuffer=="function"&&typeof n.type=="string"&&typeof n.stream=="function"&&(n[Symbol.toStringTag]==="Blob"||n[Symbol.toStringTag]==="File")}or.exports={isBlob:hf,isValidStatusCode:gf,isValidUTF8:hi,tokenChars:lf};if(ua)or.exports.isValidUTF8=function(n){return n.length<24?hi(n):ua(n)};else if(!process.env.WS_NO_UTF_8_VALIDATE)try{let n=ee("utf-8-validate");or.exports.isValidUTF8=function(e){return e.length<32?hi(e):n(e)}}catch{}});var yi=_e((s_,wa)=>{"use strict";var{Writable:pf}=ee("stream"),fa=Mt(),{BINARY_TYPES:mf,EMPTY_BUFFER:la,kStatusCode:wf,kWebSocket:_f}=Je(),{concat:pi,toArrayBuffer:yf,unmask:bf}=an(),{isValidStatusCode:vf,isValidUTF8:ga}=Bt(),ar=Buffer[Symbol.species],Pe=0,ha=1,pa=2,ma=3,mi=4,wi=5,cr=6,_i=class extends pf{constructor(e={}){super(),this._allowSynchronousEvents=e.allowSynchronousEvents!==void 0?e.allowSynchronousEvents:!0,this._binaryType=e.binaryType||mf[0],this._extensions=e.extensions||{},this._isServer=!!e.isServer,this._maxPayload=e.maxPayload|0,this._skipUTF8Validation=!!e.skipUTF8Validation,this[_f]=void 0,this._bufferedBytes=0,this._buffers=[],this._compressed=!1,this._payloadLength=0,this._mask=void 0,this._fragmented=0,this._masked=!1,this._fin=!1,this._opcode=0,this._totalPayloadLength=0,this._messageLength=0,this._fragments=[],this._errored=!1,this._loop=!1,this._state=Pe}_write(e,s,o){if(this._opcode===8&&this._state==Pe)return o();this._bufferedBytes+=e.length,this._buffers.push(e),this.startLoop(o)}consume(e){if(this._bufferedBytes-=e,e===this._buffers[0].length)return this._buffers.shift();if(e<this._buffers[0].length){let o=this._buffers[0];return this._buffers[0]=new ar(o.buffer,o.byteOffset+e,o.length-e),new ar(o.buffer,o.byteOffset,e)}let s=Buffer.allocUnsafe(e);do{let o=this._buffers[0],c=s.length-e;e>=o.length?s.set(this._buffers.shift(),c):(s.set(new Uint8Array(o.buffer,o.byteOffset,e),c),this._buffers[0]=new ar(o.buffer,o.byteOffset+e,o.length-e)),e-=o.length}while(e>0);return s}startLoop(e){this._loop=!0;do switch(this._state){case Pe:this.getInfo(e);break;case ha:this.getPayloadLength16(e);break;case pa:this.getPayloadLength64(e);break;case ma:this.getMask();break;case mi:this.getData(e);break;case wi:case cr:this._loop=!1;return}while(this._loop);this._errored||e()}getInfo(e){if(this._bufferedBytes<2){this._loop=!1;return}let s=this.consume(2);if((s[0]&48)!==0){let c=this.createError(RangeError,"RSV2 and RSV3 must be clear",!0,1002,"WS_ERR_UNEXPECTED_RSV_2_3");e(c);return}let o=(s[0]&64)===64;if(o&&!this._extensions[fa.extensionName]){let c=this.createError(RangeError,"RSV1 must be clear",!0,1002,"WS_ERR_UNEXPECTED_RSV_1");e(c);return}if(this._fin=(s[0]&128)===128,this._opcode=s[0]&15,this._payloadLength=s[1]&127,this._opcode===0){if(o){let c=this.createError(RangeError,"RSV1 must be clear",!0,1002,"WS_ERR_UNEXPECTED_RSV_1");e(c);return}if(!this._fragmented){let c=this.createError(RangeError,"invalid opcode 0",!0,1002,"WS_ERR_INVALID_OPCODE");e(c);return}this._opcode=this._fragmented}else if(this._opcode===1||this._opcode===2){if(this._fragmented){let c=this.createError(RangeError,`invalid opcode ${this._opcode}`,!0,1002,"WS_ERR_INVALID_OPCODE");e(c);return}this._compressed=o}else if(this._opcode>7&&this._opcode<11){if(!this._fin){let c=this.createError(RangeError,"FIN must be set",!0,1002,"WS_ERR_EXPECTED_FIN");e(c);return}if(o){let c=this.createError(RangeError,"RSV1 must be clear",!0,1002,"WS_ERR_UNEXPECTED_RSV_1");e(c);return}if(this._payloadLength>125||this._opcode===8&&this._payloadLength===1){let c=this.createError(RangeError,`invalid payload length ${this._payloadLength}`,!0,1002,"WS_ERR_INVALID_CONTROL_PAYLOAD_LENGTH");e(c);return}}else{let c=this.createError(RangeError,`invalid opcode ${this._opcode}`,!0,1002,"WS_ERR_INVALID_OPCODE");e(c);return}if(!this._fin&&!this._fragmented&&(this._fragmented=this._opcode),this._masked=(s[1]&128)===128,this._isServer){if(!this._masked){let c=this.createError(RangeError,"MASK must be set",!0,1002,"WS_ERR_EXPECTED_MASK");e(c);return}}else if(this._masked){let c=this.createError(RangeError,"MASK must be clear",!0,1002,"WS_ERR_UNEXPECTED_MASK");e(c);return}this._payloadLength===126?this._state=ha:this._payloadLength===127?this._state=pa:this.haveLength(e)}getPayloadLength16(e){if(this._bufferedBytes<2){this._loop=!1;return}this._payloadLength=this.consume(2).readUInt16BE(0),this.haveLength(e)}getPayloadLength64(e){if(this._bufferedBytes<8){this._loop=!1;return}let s=this.consume(8),o=s.readUInt32BE(0);if(o>Math.pow(2,21)-1){let c=this.createError(RangeError,"Unsupported WebSocket frame: payload length > 2^53 - 1",!1,1009,"WS_ERR_UNSUPPORTED_DATA_PAYLOAD_LENGTH");e(c);return}this._payloadLength=o*Math.pow(2,32)+s.readUInt32BE(4),this.haveLength(e)}haveLength(e){if(this._payloadLength&&this._opcode<8&&(this._totalPayloadLength+=this._payloadLength,this._totalPayloadLength>this._maxPayload&&this._maxPayload>0)){let s=this.createError(RangeError,"Max payload size exceeded",!1,1009,"WS_ERR_UNSUPPORTED_MESSAGE_LENGTH");e(s);return}this._masked?this._state=ma:this._state=mi}getMask(){if(this._bufferedBytes<4){this._loop=!1;return}this._mask=this.consume(4),this._state=mi}getData(e){let s=la;if(this._payloadLength){if(this._bufferedBytes<this._payloadLength){this._loop=!1;return}s=this.consume(this._payloadLength),this._masked&&(this._mask[0]|this._mask[1]|this._mask[2]|this._mask[3])!==0&&bf(s,this._mask)}if(this._opcode>7){this.controlMessage(s,e);return}if(this._compressed){this._state=wi,this.decompress(s,e);return}s.length&&(this._messageLength=this._totalPayloadLength,this._fragments.push(s)),this.dataMessage(e)}decompress(e,s){this._extensions[fa.extensionName].decompress(e,this._fin,(c,d)=>{if(c)return s(c);if(d.length){if(this._messageLength+=d.length,this._messageLength>this._maxPayload&&this._maxPayload>0){let u=this.createError(RangeError,"Max payload size exceeded",!1,1009,"WS_ERR_UNSUPPORTED_MESSAGE_LENGTH");s(u);return}this._fragments.push(d)}this.dataMessage(s),this._state===Pe&&this.startLoop(s)})}dataMessage(e){if(!this._fin){this._state=Pe;return}let s=this._messageLength,o=this._fragments;if(this._totalPayloadLength=0,this._messageLength=0,this._fragmented=0,this._fragments=[],this._opcode===2){let c;this._binaryType==="nodebuffer"?c=pi(o,s):this._binaryType==="arraybuffer"?c=yf(pi(o,s)):this._binaryType==="blob"?c=new Blob(o):c=o,this._allowSynchronousEvents?(this.emit("message",c,!0),this._state=Pe):(this._state=cr,setImmediate(()=>{this.emit("message",c,!0),this._state=Pe,this.startLoop(e)}))}else{let c=pi(o,s);if(!this._skipUTF8Validation&&!ga(c)){let d=this.createError(Error,"invalid UTF-8 sequence",!0,1007,"WS_ERR_INVALID_UTF8");e(d);return}this._state===wi||this._allowSynchronousEvents?(this.emit("message",c,!1),this._state=Pe):(this._state=cr,setImmediate(()=>{this.emit("message",c,!1),this._state=Pe,this.startLoop(e)}))}}controlMessage(e,s){if(this._opcode===8){if(e.length===0)this._loop=!1,this.emit("conclude",1005,la),this.end();else{let o=e.readUInt16BE(0);if(!vf(o)){let d=this.createError(RangeError,`invalid status code ${o}`,!0,1002,"WS_ERR_INVALID_CLOSE_CODE");s(d);return}let c=new ar(e.buffer,e.byteOffset+2,e.length-2);if(!this._skipUTF8Validation&&!ga(c)){let d=this.createError(Error,"invalid UTF-8 sequence",!0,1007,"WS_ERR_INVALID_UTF8");s(d);return}this._loop=!1,this.emit("conclude",o,c),this.end()}this._state=Pe;return}this._allowSynchronousEvents?(this.emit(this._opcode===9?"ping":"pong",e),this._state=Pe):(this._state=cr,setImmediate(()=>{this.emit(this._opcode===9?"ping":"pong",e),this._state=Pe,this.startLoop(s)}))}createError(e,s,o,c,d){this._loop=!1,this._errored=!0;let u=new e(o?`Invalid WebSocket frame: ${s}`:s);return Error.captureStackTrace(u,this.createError),u.code=d,u[wf]=c,u}};wa.exports=_i});var Si=_e((a_,ba)=>{"use strict";var{Duplex:o_}=ee("stream"),{randomFillSync:Sf}=ee("crypto"),_a=Mt(),{EMPTY_BUFFER:Ef,kWebSocket:If,NOOP:Af}=Je(),{isBlob:zt,isValidStatusCode:Cf}=Bt(),{mask:ya,toBuffer:lt}=an(),ke=Symbol("kByteLength"),Pf=Buffer.alloc(4),xr=8*1024,gt,Ft=xr,Re=0,kf=1,Tf=2,bi=class n{constructor(e,s,o){this._extensions=s||{},o&&(this._generateMask=o,this._maskBuffer=Buffer.alloc(4)),this._socket=e,this._firstFragment=!0,this._compress=!1,this._bufferedBytes=0,this._queue=[],this._state=Re,this.onerror=Af,this[If]=void 0}static frame(e,s){let o,c=!1,d=2,u=!1;s.mask&&(o=s.maskBuffer||Pf,s.generateMask?s.generateMask(o):(Ft===xr&&(gt===void 0&&(gt=Buffer.alloc(xr)),Sf(gt,0,xr),Ft=0),o[0]=gt[Ft++],o[1]=gt[Ft++],o[2]=gt[Ft++],o[3]=gt[Ft++]),u=(o[0]|o[1]|o[2]|o[3])===0,d=6);let l;typeof e=="string"?(!s.mask||u)&&s[ke]!==void 0?l=s[ke]:(e=Buffer.from(e),l=e.length):(l=e.length,c=s.mask&&s.readOnly&&!u);let p=l;l>=65536?(d+=8,p=127):l>125&&(d+=2,p=126);let m=Buffer.allocUnsafe(c?l+d:d);return m[0]=s.fin?s.opcode|128:s.opcode,s.rsv1&&(m[0]|=64),m[1]=p,p===126?m.writeUInt16BE(l,2):p===127&&(m[2]=m[3]=0,m.writeUIntBE(l,4,6)),s.mask?(m[1]|=128,m[d-4]=o[0],m[d-3]=o[1],m[d-2]=o[2],m[d-1]=o[3],u?[m,e]:c?(ya(e,o,m,d,l),[m]):(ya(e,o,e,0,l),[m,e])):[m,e]}close(e,s,o,c){let d;if(e===void 0)d=Ef;else{if(typeof e!="number"||!Cf(e))throw new TypeError("First argument must be a valid error code number");if(s===void 0||!s.length)d=Buffer.allocUnsafe(2),d.writeUInt16BE(e,0);else{let l=Buffer.byteLength(s);if(l>123)throw new RangeError("The message must not be greater than 123 bytes");d=Buffer.allocUnsafe(2+l),d.writeUInt16BE(e,0),typeof s=="string"?d.write(s,2):d.set(s,2)}}let u={[ke]:d.length,fin:!0,generateMask:this._generateMask,mask:o,maskBuffer:this._maskBuffer,opcode:8,readOnly:!1,rsv1:!1};this._state!==Re?this.enqueue([this.dispatch,d,!1,u,c]):this.sendFrame(n.frame(d,u),c)}ping(e,s,o){let c,d;if(typeof e=="string"?(c=Buffer.byteLength(e),d=!1):zt(e)?(c=e.size,d=!1):(e=lt(e),c=e.length,d=lt.readOnly),c>125)throw new RangeError("The data size must not be greater than 125 bytes");let u={[ke]:c,fin:!0,generateMask:this._generateMask,mask:s,maskBuffer:this._maskBuffer,opcode:9,readOnly:d,rsv1:!1};zt(e)?this._state!==Re?this.enqueue([this.getBlobData,e,!1,u,o]):this.getBlobData(e,!1,u,o):this._state!==Re?this.enqueue([this.dispatch,e,!1,u,o]):this.sendFrame(n.frame(e,u),o)}pong(e,s,o){let c,d;if(typeof e=="string"?(c=Buffer.byteLength(e),d=!1):zt(e)?(c=e.size,d=!1):(e=lt(e),c=e.length,d=lt.readOnly),c>125)throw new RangeError("The data size must not be greater than 125 bytes");let u={[ke]:c,fin:!0,generateMask:this._generateMask,mask:s,maskBuffer:this._maskBuffer,opcode:10,readOnly:d,rsv1:!1};zt(e)?this._state!==Re?this.enqueue([this.getBlobData,e,!1,u,o]):this.getBlobData(e,!1,u,o):this._state!==Re?this.enqueue([this.dispatch,e,!1,u,o]):this.sendFrame(n.frame(e,u),o)}send(e,s,o){let c=this._extensions[_a.extensionName],d=s.binary?2:1,u=s.compress,l,p;typeof e=="string"?(l=Buffer.byteLength(e),p=!1):zt(e)?(l=e.size,p=!1):(e=lt(e),l=e.length,p=lt.readOnly),this._firstFragment?(this._firstFragment=!1,u&&c&&c.params[c._isServer?"server_no_context_takeover":"client_no_context_takeover"]&&(u=l>=c._threshold),this._compress=u):(u=!1,d=0),s.fin&&(this._firstFragment=!0);let m={[ke]:l,fin:s.fin,generateMask:this._generateMask,mask:s.mask,maskBuffer:this._maskBuffer,opcode:d,readOnly:p,rsv1:u};zt(e)?this._state!==Re?this.enqueue([this.getBlobData,e,this._compress,m,o]):this.getBlobData(e,this._compress,m,o):this._state!==Re?this.enqueue([this.dispatch,e,this._compress,m,o]):this.dispatch(e,this._compress,m,o)}getBlobData(e,s,o,c){this._bufferedBytes+=o[ke],this._state=Tf,e.arrayBuffer().then(d=>{if(this._socket.destroyed){let l=new Error("The socket was closed while the blob was being read");process.nextTick(vi,this,l,c);return}this._bufferedBytes-=o[ke];let u=lt(d);s?this.dispatch(u,s,o,c):(this._state=Re,this.sendFrame(n.frame(u,o),c),this.dequeue())}).catch(d=>{process.nextTick(Df,this,d,c)})}dispatch(e,s,o,c){if(!s){this.sendFrame(n.frame(e,o),c);return}let d=this._extensions[_a.extensionName];this._bufferedBytes+=o[ke],this._state=kf,d.compress(e,o.fin,(u,l)=>{if(this._socket.destroyed){let p=new Error("The socket was closed while data was being compressed");vi(this,p,c);return}this._bufferedBytes-=o[ke],this._state=Re,o.readOnly=!1,this.sendFrame(n.frame(l,o),c),this.dequeue()})}dequeue(){for(;this._state===Re&&this._queue.length;){let e=this._queue.shift();this._bufferedBytes-=e[3][ke],Reflect.apply(e[0],this,e.slice(1))}}enqueue(e){this._bufferedBytes+=e[3][ke],this._queue.push(e)}sendFrame(e,s){e.length===2?(this._socket.cork(),this._socket.write(e[0]),this._socket.write(e[1],s),this._socket.uncork()):this._socket.write(e[0],s)}};ba.exports=bi;function vi(n,e,s){typeof s=="function"&&s(e);for(let o=0;o<n._queue.length;o++){let c=n._queue[o],d=c[c.length-1];typeof d=="function"&&d(e)}}function Df(n,e,s){vi(n,e,s),n.onerror(e)}});var Ta=_e((c_,ka)=>{"use strict";var{kForOnEventAttribute:xn,kListener:Ei}=Je(),va=Symbol("kCode"),Sa=Symbol("kData"),Ea=Symbol("kError"),Ia=Symbol("kMessage"),Aa=Symbol("kReason"),Ut=Symbol("kTarget"),Ca=Symbol("kType"),Pa=Symbol("kWasClean"),Ve=class{constructor(e){this[Ut]=null,this[Ca]=e}get target(){return this[Ut]}get type(){return this[Ca]}};Object.defineProperty(Ve.prototype,"target",{enumerable:!0});Object.defineProperty(Ve.prototype,"type",{enumerable:!0});var ht=class extends Ve{constructor(e,s={}){super(e),this[va]=s.code===void 0?0:s.code,this[Aa]=s.reason===void 0?"":s.reason,this[Pa]=s.wasClean===void 0?!1:s.wasClean}get code(){return this[va]}get reason(){return this[Aa]}get wasClean(){return this[Pa]}};Object.defineProperty(ht.prototype,"code",{enumerable:!0});Object.defineProperty(ht.prototype,"reason",{enumerable:!0});Object.defineProperty(ht.prototype,"wasClean",{enumerable:!0});var qt=class extends Ve{constructor(e,s={}){super(e),this[Ea]=s.error===void 0?null:s.error,this[Ia]=s.message===void 0?"":s.message}get error(){return this[Ea]}get message(){return this[Ia]}};Object.defineProperty(qt.prototype,"error",{enumerable:!0});Object.defineProperty(qt.prototype,"message",{enumerable:!0});var dn=class extends Ve{constructor(e,s={}){super(e),this[Sa]=s.data===void 0?null:s.data}get data(){return this[Sa]}};Object.defineProperty(dn.prototype,"data",{enumerable:!0});var Rf={addEventListener(n,e,s={}){for(let c of this.listeners(n))if(!s[xn]&&c[Ei]===e&&!c[xn])return;let o;if(n==="message")o=function(d,u){let l=new dn("message",{data:u?d:d.toString()});l[Ut]=this,dr(e,this,l)};else if(n==="close")o=function(d,u){let l=new ht("close",{code:d,reason:u.toString(),wasClean:this._closeFrameReceived&&this._closeFrameSent});l[Ut]=this,dr(e,this,l)};else if(n==="error")o=function(d){let u=new qt("error",{error:d,message:d.message});u[Ut]=this,dr(e,this,u)};else if(n==="open")o=function(){let d=new Ve("open");d[Ut]=this,dr(e,this,d)};else return;o[xn]=!!s[xn],o[Ei]=e,s.once?this.once(n,o):this.on(n,o)},removeEventListener(n,e){for(let s of this.listeners(n))if(s[Ei]===e&&!s[xn]){this.removeListener(n,s);break}}};ka.exports={CloseEvent:ht,ErrorEvent:qt,Event:Ve,EventTarget:Rf,MessageEvent:dn};function dr(n,e,s){typeof n=="object"&&n.handleEvent?n.handleEvent.call(n,s):n.call(e,s)}});var ur=_e((x_,Da)=>{"use strict";var{tokenChars:un}=Bt();function qe(n,e,s){n[e]===void 0?n[e]=[s]:n[e].push(s)}function Lf(n){let e=Object.create(null),s=Object.create(null),o=!1,c=!1,d=!1,u,l,p=-1,m=-1,_=-1,y=0;for(;y<n.length;y++)if(m=n.charCodeAt(y),u===void 0)if(_===-1&&un[m]===1)p===-1&&(p=y);else if(y!==0&&(m===32||m===9))_===-1&&p!==-1&&(_=y);else if(m===59||m===44){if(p===-1)throw new SyntaxError(`Unexpected character at index ${y}`);_===-1&&(_=y);let L=n.slice(p,_);m===44?(qe(e,L,s),s=Object.create(null)):u=L,p=_=-1}else throw new SyntaxError(`Unexpected character at index ${y}`);else if(l===void 0)if(_===-1&&un[m]===1)p===-1&&(p=y);else if(m===32||m===9)_===-1&&p!==-1&&(_=y);else if(m===59||m===44){if(p===-1)throw new SyntaxError(`Unexpected character at index ${y}`);_===-1&&(_=y),qe(s,n.slice(p,_),!0),m===44&&(qe(e,u,s),s=Object.create(null),u=void 0),p=_=-1}else if(m===61&&p!==-1&&_===-1)l=n.slice(p,y),p=_=-1;else throw new SyntaxError(`Unexpected character at index ${y}`);else if(c){if(un[m]!==1)throw new SyntaxError(`Unexpected character at index ${y}`);p===-1?p=y:o||(o=!0),c=!1}else if(d)if(un[m]===1)p===-1&&(p=y);else if(m===34&&p!==-1)d=!1,_=y;else if(m===92)c=!0;else throw new SyntaxError(`Unexpected character at index ${y}`);else if(m===34&&n.charCodeAt(y-1)===61)d=!0;else if(_===-1&&un[m]===1)p===-1&&(p=y);else if(p!==-1&&(m===32||m===9))_===-1&&(_=y);else if(m===59||m===44){if(p===-1)throw new SyntaxError(`Unexpected character at index ${y}`);_===-1&&(_=y);let L=n.slice(p,_);o&&(L=L.replace(/\\/g,""),o=!1),qe(s,l,L),m===44&&(qe(e,u,s),s=Object.create(null),u=void 0),l=void 0,p=_=-1}else throw new SyntaxError(`Unexpected character at index ${y}`);if(p===-1||d||m===32||m===9)throw new SyntaxError("Unexpected end of input");_===-1&&(_=y);let I=n.slice(p,_);return u===void 0?qe(e,I,s):(l===void 0?qe(s,I,!0):o?qe(s,l,I.replace(/\\/g,"")):qe(s,l,I),qe(e,u,s)),e}function Of(n){return Object.keys(n).map(e=>{let s=n[e];return Array.isArray(s)||(s=[s]),s.map(o=>[e].concat(Object.keys(o).map(c=>{let d=o[c];return Array.isArray(d)||(d=[d]),d.map(u=>u===!0?c:`${c}=${u}`).join("; ")})).join("; ")).join(", ")}).join(", ")}Da.exports={format:Of,parse:Lf}});var hr=_e((f_,ja)=>{"use strict";var Nf=ee("events"),Mf=ee("https"),Bf=ee("http"),Oa=ee("net"),zf=ee("tls"),{randomBytes:Ff,createHash:Uf}=ee("crypto"),{Duplex:d_,Readable:u_}=ee("stream"),{URL:Ii}=ee("url"),xt=Mt(),qf=yi(),Hf=Si(),{isBlob:jf}=Bt(),{BINARY_TYPES:Ra,CLOSE_TIMEOUT:Kf,EMPTY_BUFFER:fr,GUID:Gf,kForOnEventAttribute:Ai,kListener:Wf,kStatusCode:Jf,kWebSocket:ce,NOOP:Na}=Je(),{EventTarget:{addEventListener:$f,removeEventListener:Vf}}=Ta(),{format:Yf,parse:Xf}=ur(),{toBuffer:Qf}=an(),Ma=Symbol("kAborted"),Ci=[8,13],Ye=["CONNECTING","OPEN","CLOSING","CLOSED"],Zf=/^[!#$%&'*+\-.0-9A-Z^_`|a-z~]+$/,J=class n extends Nf{constructor(e,s,o){super(),this._binaryType=Ra[0],this._closeCode=1006,this._closeFrameReceived=!1,this._closeFrameSent=!1,this._closeMessage=fr,this._closeTimer=null,this._errorEmitted=!1,this._extensions={},this._paused=!1,this._protocol="",this._readyState=n.CONNECTING,this._receiver=null,this._sender=null,this._socket=null,e!==null?(this._bufferedAmount=0,this._isServer=!1,this._redirects=0,s===void 0?s=[]:Array.isArray(s)||(typeof s=="object"&&s!==null?(o=s,s=[]):s=[s]),Ba(this,e,s,o)):(this._autoPong=o.autoPong,this._closeTimeout=o.closeTimeout,this._isServer=!0)}get binaryType(){return this._binaryType}set binaryType(e){Ra.includes(e)&&(this._binaryType=e,this._receiver&&(this._receiver._binaryType=e))}get bufferedAmount(){return this._socket?this._socket._writableState.length+this._sender._bufferedBytes:this._bufferedAmount}get extensions(){return Object.keys(this._extensions).join()}get isPaused(){return this._paused}get onclose(){return null}get onerror(){return null}get onopen(){return null}get onmessage(){return null}get protocol(){return this._protocol}get readyState(){return this._readyState}get url(){return this._url}setSocket(e,s,o){let c=new qf({allowSynchronousEvents:o.allowSynchronousEvents,binaryType:this.binaryType,extensions:this._extensions,isServer:this._isServer,maxPayload:o.maxPayload,skipUTF8Validation:o.skipUTF8Validation}),d=new Hf(e,this._extensions,o.generateMask);this._receiver=c,this._sender=d,this._socket=e,c[ce]=this,d[ce]=this,e[ce]=this,c.on("conclude",nl),c.on("drain",rl),c.on("error",il),c.on("message",sl),c.on("ping",ol),c.on("pong",al),d.onerror=cl,e.setTimeout&&e.setTimeout(0),e.setNoDelay&&e.setNoDelay(),s.length>0&&e.unshift(s),e.on("close",Ua),e.on("data",gr),e.on("end",qa),e.on("error",Ha),this._readyState=n.OPEN,this.emit("open")}emitClose(){if(!this._socket){this._readyState=n.CLOSED,this.emit("close",this._closeCode,this._closeMessage);return}this._extensions[xt.extensionName]&&this._extensions[xt.extensionName].cleanup(),this._receiver.removeAllListeners(),this._readyState=n.CLOSED,this.emit("close",this._closeCode,this._closeMessage)}close(e,s){if(this.readyState!==n.CLOSED){if(this.readyState===n.CONNECTING){Ee(this,this._req,"WebSocket was closed before the connection was established");return}if(this.readyState===n.CLOSING){this._closeFrameSent&&(this._closeFrameReceived||this._receiver._writableState.errorEmitted)&&this._socket.end();return}this._readyState=n.CLOSING,this._sender.close(e,s,!this._isServer,o=>{o||(this._closeFrameSent=!0,(this._closeFrameReceived||this._receiver._writableState.errorEmitted)&&this._socket.end())}),Fa(this)}}pause(){this.readyState===n.CONNECTING||this.readyState===n.CLOSED||(this._paused=!0,this._socket.pause())}ping(e,s,o){if(this.readyState===n.CONNECTING)throw new Error("WebSocket is not open: readyState 0 (CONNECTING)");if(typeof e=="function"?(o=e,e=s=void 0):typeof s=="function"&&(o=s,s=void 0),typeof e=="number"&&(e=e.toString()),this.readyState!==n.OPEN){Pi(this,e,o);return}s===void 0&&(s=!this._isServer),this._sender.ping(e||fr,s,o)}pong(e,s,o){if(this.readyState===n.CONNECTING)throw new Error("WebSocket is not open: readyState 0 (CONNECTING)");if(typeof e=="function"?(o=e,e=s=void 0):typeof s=="function"&&(o=s,s=void 0),typeof e=="number"&&(e=e.toString()),this.readyState!==n.OPEN){Pi(this,e,o);return}s===void 0&&(s=!this._isServer),this._sender.pong(e||fr,s,o)}resume(){this.readyState===n.CONNECTING||this.readyState===n.CLOSED||(this._paused=!1,this._receiver._writableState.needDrain||this._socket.resume())}send(e,s,o){if(this.readyState===n.CONNECTING)throw new Error("WebSocket is not open: readyState 0 (CONNECTING)");if(typeof s=="function"&&(o=s,s={}),typeof e=="number"&&(e=e.toString()),this.readyState!==n.OPEN){Pi(this,e,o);return}let c={binary:typeof e!="string",mask:!this._isServer,compress:!0,fin:!0,...s};this._extensions[xt.extensionName]||(c.compress=!1),this._sender.send(e||fr,c,o)}terminate(){if(this.readyState!==n.CLOSED){if(this.readyState===n.CONNECTING){Ee(this,this._req,"WebSocket was closed before the connection was established");return}this._socket&&(this._readyState=n.CLOSING,this._socket.destroy())}}};Object.defineProperty(J,"CONNECTING",{enumerable:!0,value:Ye.indexOf("CONNECTING")});Object.defineProperty(J.prototype,"CONNECTING",{enumerable:!0,value:Ye.indexOf("CONNECTING")});Object.defineProperty(J,"OPEN",{enumerable:!0,value:Ye.indexOf("OPEN")});Object.defineProperty(J.prototype,"OPEN",{enumerable:!0,value:Ye.indexOf("OPEN")});Object.defineProperty(J,"CLOSING",{enumerable:!0,value:Ye.indexOf("CLOSING")});Object.defineProperty(J.prototype,"CLOSING",{enumerable:!0,value:Ye.indexOf("CLOSING")});Object.defineProperty(J,"CLOSED",{enumerable:!0,value:Ye.indexOf("CLOSED")});Object.defineProperty(J.prototype,"CLOSED",{enumerable:!0,value:Ye.indexOf("CLOSED")});["binaryType","bufferedAmount","extensions","isPaused","protocol","readyState","url"].forEach(n=>{Object.defineProperty(J.prototype,n,{enumerable:!0})});["open","error","close","message"].forEach(n=>{Object.defineProperty(J.prototype,`on${n}`,{enumerable:!0,get(){for(let e of this.listeners(n))if(e[Ai])return e[Wf];return null},set(e){for(let s of this.listeners(n))if(s[Ai]){this.removeListener(n,s);break}typeof e=="function"&&this.addEventListener(n,e,{[Ai]:!0})}})});J.prototype.addEventListener=$f;J.prototype.removeEventListener=Vf;ja.exports=J;function Ba(n,e,s,o){let c={allowSynchronousEvents:!0,autoPong:!0,closeTimeout:Kf,protocolVersion:Ci[1],maxPayload:104857600,skipUTF8Validation:!1,perMessageDeflate:!0,followRedirects:!1,maxRedirects:10,...o,socketPath:void 0,hostname:void 0,protocol:void 0,timeout:void 0,method:"GET",host:void 0,path:void 0,port:void 0};if(n._autoPong=c.autoPong,n._closeTimeout=c.closeTimeout,!Ci.includes(c.protocolVersion))throw new RangeError(`Unsupported protocol version: ${c.protocolVersion} (supported versions: ${Ci.join(", ")})`);let d;if(e instanceof Ii)d=e;else try{d=new Ii(e)}catch{throw new SyntaxError(`Invalid URL: ${e}`)}d.protocol==="http:"?d.protocol="ws:":d.protocol==="https:"&&(d.protocol="wss:"),n._url=d.href;let u=d.protocol==="wss:",l=d.protocol==="ws+unix:",p;if(d.protocol!=="ws:"&&!u&&!l?p=`The URL's protocol must be one of "ws:", "wss:", "http:", "https:", or "ws+unix:"`:l&&!d.pathname?p="The URL's pathname is empty":d.hash&&(p="The URL contains a fragment identifier"),p){let P=new SyntaxError(p);if(n._redirects===0)throw P;lr(n,P);return}let m=u?443:80,_=Ff(16).toString("base64"),y=u?Mf.request:Bf.request,I=new Set,L;if(c.createConnection=c.createConnection||(u?tl:el),c.defaultPort=c.defaultPort||m,c.port=d.port||m,c.host=d.hostname.startsWith("[")?d.hostname.slice(1,-1):d.hostname,c.headers={...c.headers,"Sec-WebSocket-Version":c.protocolVersion,"Sec-WebSocket-Key":_,Connection:"Upgrade",Upgrade:"websocket"},c.path=d.pathname+d.search,c.timeout=c.handshakeTimeout,c.perMessageDeflate&&(L=new xt({...c.perMessageDeflate,isServer:!1,maxPayload:c.maxPayload}),c.headers["Sec-WebSocket-Extensions"]=Yf({[xt.extensionName]:L.offer()})),s.length){for(let P of s){if(typeof P!="string"||!Zf.test(P)||I.has(P))throw new SyntaxError("An invalid or duplicated subprotocol was specified");I.add(P)}c.headers["Sec-WebSocket-Protocol"]=s.join(",")}if(c.origin&&(c.protocolVersion<13?c.headers["Sec-WebSocket-Origin"]=c.origin:c.headers.Origin=c.origin),(d.username||d.password)&&(c.auth=`${d.username}:${d.password}`),l){let P=c.path.split(":");c.socketPath=P[0],c.path=P[1]}let T;if(c.followRedirects){if(n._redirects===0){n._originalIpc=l,n._originalSecure=u,n._originalHostOrSocketPath=l?c.socketPath:d.host;let P=o&&o.headers;if(o={...o,headers:{}},P)for(let[j,Q]of Object.entries(P))o.headers[j.toLowerCase()]=Q}else if(n.listenerCount("redirect")===0){let P=l?n._originalIpc?c.socketPath===n._originalHostOrSocketPath:!1:n._originalIpc?!1:d.host===n._originalHostOrSocketPath;(!P||n._originalSecure&&!u)&&(delete c.headers.authorization,delete c.headers.cookie,P||delete c.headers.host,c.auth=void 0)}c.auth&&!o.headers.authorization&&(o.headers.authorization="Basic "+Buffer.from(c.auth).toString("base64")),T=n._req=y(c),n._redirects&&n.emit("redirect",n.url,T)}else T=n._req=y(c);c.timeout&&T.on("timeout",()=>{Ee(n,T,"Opening handshake has timed out")}),T.on("error",P=>{T===null||T[Ma]||(T=n._req=null,lr(n,P))}),T.on("response",P=>{let j=P.headers.location,Q=P.statusCode;if(j&&c.followRedirects&&Q>=300&&Q<400){if(++n._redirects>c.maxRedirects){Ee(n,T,"Maximum redirects exceeded");return}T.abort();let K;try{K=new Ii(j,e)}catch{let se=new SyntaxError(`Invalid URL: ${j}`);lr(n,se);return}Ba(n,K,s,o)}else n.emit("unexpected-response",T,P)||Ee(n,T,`Unexpected server response: ${P.statusCode}`)}),T.on("upgrade",(P,j,Q)=>{if(n.emit("upgrade",P),n.readyState!==J.CONNECTING)return;T=n._req=null;let K=P.headers.upgrade;if(K===void 0||K.toLowerCase()!=="websocket"){Ee(n,j,"Invalid Upgrade header");return}let $=Uf("sha1").update(_+Gf).digest("base64");if(P.headers["sec-websocket-accept"]!==$){Ee(n,j,"Invalid Sec-WebSocket-Accept header");return}let se=P.headers["sec-websocket-protocol"],oe;if(se!==void 0?I.size?I.has(se)||(oe="Server sent an invalid subprotocol"):oe="Server sent a subprotocol but none was requested":I.size&&(oe="Server sent no subprotocol"),oe){Ee(n,j,oe);return}se&&(n._protocol=se);let Te=P.headers["sec-websocket-extensions"];if(Te!==void 0){if(!L){Ee(n,j,"Server sent a Sec-WebSocket-Extensions header but no extension was requested");return}let pe;try{pe=Xf(Te)}catch{Ee(n,j,"Invalid Sec-WebSocket-Extensions header");return}let xe=Object.keys(pe);if(xe.length!==1||xe[0]!==xt.extensionName){Ee(n,j,"Server indicated an extension that was not requested");return}try{L.accept(pe[xt.extensionName])}catch{Ee(n,j,"Invalid Sec-WebSocket-Extensions header");return}n._extensions[xt.extensionName]=L}n.setSocket(j,Q,{allowSynchronousEvents:c.allowSynchronousEvents,generateMask:c.generateMask,maxPayload:c.maxPayload,skipUTF8Validation:c.skipUTF8Validation})}),c.finishRequest?c.finishRequest(T,n):T.end()}function lr(n,e){n._readyState=J.CLOSING,n._errorEmitted=!0,n.emit("error",e),n.emitClose()}function el(n){return n.path=n.socketPath,Oa.connect(n)}function tl(n){return n.path=void 0,!n.servername&&n.servername!==""&&(n.servername=Oa.isIP(n.host)?"":n.host),zf.connect(n)}function Ee(n,e,s){n._readyState=J.CLOSING;let o=new Error(s);Error.captureStackTrace(o,Ee),e.setHeader?(e[Ma]=!0,e.abort(),e.socket&&!e.socket.destroyed&&e.socket.destroy(),process.nextTick(lr,n,o)):(e.destroy(o),e.once("error",n.emit.bind(n,"error")),e.once("close",n.emitClose.bind(n)))}function Pi(n,e,s){if(e){let o=jf(e)?e.size:Qf(e).length;n._socket?n._sender._bufferedBytes+=o:n._bufferedAmount+=o}if(s){let o=new Error(`WebSocket is not open: readyState ${n.readyState} (${Ye[n.readyState]})`);process.nextTick(s,o)}}function nl(n,e){let s=this[ce];s._closeFrameReceived=!0,s._closeMessage=e,s._closeCode=n,s._socket[ce]!==void 0&&(s._socket.removeListener("data",gr),process.nextTick(za,s._socket),n===1005?s.close():s.close(n,e))}function rl(){let n=this[ce];n.isPaused||n._socket.resume()}function il(n){let e=this[ce];e._socket[ce]!==void 0&&(e._socket.removeListener("data",gr),process.nextTick(za,e._socket),e.close(n[Jf])),e._errorEmitted||(e._errorEmitted=!0,e.emit("error",n))}function La(){this[ce].emitClose()}function sl(n,e){this[ce].emit("message",n,e)}function ol(n){let e=this[ce];e._autoPong&&e.pong(n,!this._isServer,Na),e.emit("ping",n)}function al(n){this[ce].emit("pong",n)}function za(n){n.resume()}function cl(n){let e=this[ce];e.readyState!==J.CLOSED&&(e.readyState===J.OPEN&&(e._readyState=J.CLOSING,Fa(e)),this._socket.end(),e._errorEmitted||(e._errorEmitted=!0,e.emit("error",n)))}function Fa(n){n._closeTimer=setTimeout(n._socket.destroy.bind(n._socket),n._closeTimeout)}function Ua(){let n=this[ce];if(this.removeListener("close",Ua),this.removeListener("data",gr),this.removeListener("end",qa),n._readyState=J.CLOSING,!this._readableState.endEmitted&&!n._closeFrameReceived&&!n._receiver._writableState.errorEmitted&&this._readableState.length!==0){let e=this.read(this._readableState.length);n._receiver.write(e)}n._receiver.end(),this[ce]=void 0,clearTimeout(n._closeTimer),n._receiver._writableState.finished||n._receiver._writableState.errorEmitted?n.emitClose():(n._receiver.on("error",La),n._receiver.on("finish",La))}function gr(n){this[ce]._receiver.write(n)||this.pause()}function qa(){let n=this[ce];n._readyState=J.CLOSING,n._receiver.end(),this.end()}function Ha(){let n=this[ce];this.removeListener("error",Ha),this.on("error",Na),n&&(n._readyState=J.CLOSING,this.destroy())}});var Ja=_e((g_,Wa)=>{"use strict";var l_=hr(),{Duplex:xl}=ee("stream");function Ka(n){n.emit("close")}function dl(){!this.destroyed&&this._writableState.finished&&this.destroy()}function Ga(n){this.removeListener("error",Ga),this.destroy(),this.listenerCount("error")===0&&this.emit("error",n)}function ul(n,e){let s=!0,o=new xl({...e,autoDestroy:!1,emitClose:!1,objectMode:!1,writableObjectMode:!1});return n.on("message",function(d,u){let l=!u&&o._readableState.objectMode?d.toString():d;o.push(l)||n.pause()}),n.once("error",function(d){o.destroyed||(s=!1,o.destroy(d))}),n.once("close",function(){o.destroyed||o.push(null)}),o._destroy=function(c,d){if(n.readyState===n.CLOSED){d(c),process.nextTick(Ka,o);return}let u=!1;n.once("error",function(p){u=!0,d(p)}),n.once("close",function(){u||d(c),process.nextTick(Ka,o)}),s&&n.terminate()},o._final=function(c){if(n.readyState===n.CONNECTING){n.once("open",function(){o._final(c)});return}n._socket!==null&&(n._socket._writableState.finished?(c(),o._readableState.endEmitted&&o.destroy()):(n._socket.once("finish",function(){c()}),n.close()))},o._read=function(){n.isPaused&&n.resume()},o._write=function(c,d,u){if(n.readyState===n.CONNECTING){n.once("open",function(){o._write(c,d,u)});return}n.send(c,u)},o.on("end",dl),o.on("error",Ga),o}Wa.exports=ul});var ki=_e((h_,$a)=>{"use strict";var{tokenChars:fl}=Bt();function ll(n){let e=new Set,s=-1,o=-1,c=0;for(c;c<n.length;c++){let u=n.charCodeAt(c);if(o===-1&&fl[u]===1)s===-1&&(s=c);else if(c!==0&&(u===32||u===9))o===-1&&s!==-1&&(o=c);else if(u===44){if(s===-1)throw new SyntaxError(`Unexpected character at index ${c}`);o===-1&&(o=c);let l=n.slice(s,o);if(e.has(l))throw new SyntaxError(`The "${l}" subprotocol is duplicated`);e.add(l),s=o=-1}else throw new SyntaxError(`Unexpected character at index ${c}`)}if(s===-1||o!==-1)throw new SyntaxError("Unexpected end of input");let d=n.slice(s,c);if(e.has(d))throw new SyntaxError(`The "${d}" subprotocol is duplicated`);return e.add(d),e}$a.exports={parse:ll}});var tc=_e((m_,ec)=>{"use strict";var gl=ee("events"),pr=ee("http"),{Duplex:p_}=ee("stream"),{createHash:hl}=ee("crypto"),Va=ur(),pt=Mt(),pl=ki(),ml=hr(),{CLOSE_TIMEOUT:wl,GUID:_l,kWebSocket:yl}=Je(),bl=/^[+/0-9A-Za-z]{22}==$/,Ya=0,Xa=1,Za=2,Ti=class extends gl{constructor(e,s){if(super(),e={allowSynchronousEvents:!0,autoPong:!0,maxPayload:100*1024*1024,skipUTF8Validation:!1,perMessageDeflate:!1,handleProtocols:null,clientTracking:!0,closeTimeout:wl,verifyClient:null,noServer:!1,backlog:null,server:null,host:null,path:null,port:null,WebSocket:ml,...e},e.port==null&&!e.server&&!e.noServer||e.port!=null&&(e.server||e.noServer)||e.server&&e.noServer)throw new TypeError('One and only one of the "port", "server", or "noServer" options must be specified');if(e.port!=null?(this._server=pr.createServer((o,c)=>{let d=pr.STATUS_CODES[426];c.writeHead(426,{"Content-Length":d.length,"Content-Type":"text/plain"}),c.end(d)}),this._server.listen(e.port,e.host,e.backlog,s)):e.server&&(this._server=e.server),this._server){let o=this.emit.bind(this,"connection");this._removeListeners=vl(this._server,{listening:this.emit.bind(this,"listening"),error:this.emit.bind(this,"error"),upgrade:(c,d,u)=>{this.handleUpgrade(c,d,u,o)}})}e.perMessageDeflate===!0&&(e.perMessageDeflate={}),e.clientTracking&&(this.clients=new Set,this._shouldEmitClose=!1),this.options=e,this._state=Ya}address(){if(this.options.noServer)throw new Error('The server is operating in "noServer" mode');return this._server?this._server.address():null}close(e){if(this._state===Za){e&&this.once("close",()=>{e(new Error("The server is not running"))}),process.nextTick(fn,this);return}if(e&&this.once("close",e),this._state!==Xa)if(this._state=Xa,this.options.noServer||this.options.server)this._server&&(this._removeListeners(),this._removeListeners=this._server=null),this.clients?this.clients.size?this._shouldEmitClose=!0:process.nextTick(fn,this):process.nextTick(fn,this);else{let s=this._server;this._removeListeners(),this._removeListeners=this._server=null,s.close(()=>{fn(this)})}}shouldHandle(e){if(this.options.path){let s=e.url.indexOf("?");if((s!==-1?e.url.slice(0,s):e.url)!==this.options.path)return!1}return!0}handleUpgrade(e,s,o,c){s.on("error",Qa);let d=e.headers["sec-websocket-key"],u=e.headers.upgrade,l=+e.headers["sec-websocket-version"];if(e.method!=="GET"){mt(this,e,s,405,"Invalid HTTP method");return}if(u===void 0||u.toLowerCase()!=="websocket"){mt(this,e,s,400,"Invalid Upgrade header");return}if(d===void 0||!bl.test(d)){mt(this,e,s,400,"Missing or invalid Sec-WebSocket-Key header");return}if(l!==13&&l!==8){mt(this,e,s,400,"Missing or invalid Sec-WebSocket-Version header",{"Sec-WebSocket-Version":"13, 8"});return}if(!this.shouldHandle(e)){ln(s,400);return}let p=e.headers["sec-websocket-protocol"],m=new Set;if(p!==void 0)try{m=pl.parse(p)}catch{mt(this,e,s,400,"Invalid Sec-WebSocket-Protocol header");return}let _=e.headers["sec-websocket-extensions"],y={};if(this.options.perMessageDeflate&&_!==void 0){let I=new pt({...this.options.perMessageDeflate,isServer:!0,maxPayload:this.options.maxPayload});try{let L=Va.parse(_);L[pt.extensionName]&&(I.accept(L[pt.extensionName]),y[pt.extensionName]=I)}catch{mt(this,e,s,400,"Invalid or unacceptable Sec-WebSocket-Extensions header");return}}if(this.options.verifyClient){let I={origin:e.headers[`${l===8?"sec-websocket-origin":"origin"}`],secure:!!(e.socket.authorized||e.socket.encrypted),req:e};if(this.options.verifyClient.length===2){this.options.verifyClient(I,(L,T,P,j)=>{if(!L)return ln(s,T||401,P,j);this.completeUpgrade(y,d,m,e,s,o,c)});return}if(!this.options.verifyClient(I))return ln(s,401)}this.completeUpgrade(y,d,m,e,s,o,c)}completeUpgrade(e,s,o,c,d,u,l){if(!d.readable||!d.writable)return d.destroy();if(d[yl])throw new Error("server.handleUpgrade() was called more than once with the same socket, possibly due to a misconfiguration");if(this._state>Ya)return ln(d,503);let m=["HTTP/1.1 101 Switching Protocols","Upgrade: websocket","Connection: Upgrade",`Sec-WebSocket-Accept: ${hl("sha1").update(s+_l).digest("base64")}`],_=new this.options.WebSocket(null,void 0,this.options);if(o.size){let y=this.options.handleProtocols?this.options.handleProtocols(o,c):o.values().next().value;y&&(m.push(`Sec-WebSocket-Protocol: ${y}`),_._protocol=y)}if(e[pt.extensionName]){let y=e[pt.extensionName].params,I=Va.format({[pt.extensionName]:[y]});m.push(`Sec-WebSocket-Extensions: ${I}`),_._extensions=e}this.emit("headers",m,c),d.write(m.concat(`\r
|
|
8
|
+
var D0=Object.create;var Gr=Object.defineProperty;var R0=Object.getOwnPropertyDescriptor;var L0=Object.getOwnPropertyNames;var O0=Object.getPrototypeOf,N0=Object.prototype.hasOwnProperty;var te=(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 Ce=(n,e)=>()=>(n&&(e=n(n=0)),e);var ye=(n,e)=>()=>(e||n((e={exports:{}}).exports,e),e.exports),jr=(n,e)=>{for(var s in e)Gr(n,s,{get:e[s],enumerable:!0})},B0=(n,e,s,o)=>{if(e&&typeof e=="object"||typeof e=="function")for(let c of L0(e))!N0.call(n,c)&&c!==s&&Gr(n,c,{get:()=>e[c],enumerable:!(o=R0(e,c))||o.enumerable});return n};var je=(n,e,s)=>(s=n!=null?D0(O0(n)):{},B0(e||!n||!n.__esModule?Gr(s,"default",{value:n,enumerable:!0}):s,n));function ps(n){return yn[gs]<=yn[n]}function bn(n){hs={...n}}function _n(n,e,s,o){if(yn[n]<yn[gs])return;let c=JSON.stringify({ts:new Date().toISOString(),level:n,module:e,msg:s,...hs,...o});n==="error"||n==="warn"?z0.write(`${c}
|
|
9
|
+
`):M0.write(`${c}
|
|
10
|
+
`)}function L(n){return{debug:(e,s)=>_n("debug",n,e,s),info:(e,s)=>_n("info",n,e,s),warn:(e,s)=>_n("warn",n,e,s),error:(e,s)=>_n("error",n,e,s),child:e=>L(`${n}.${e}`)}}var yn,gs,M0,z0,hs,q=Ce(()=>{"use strict";yn={debug:10,info:20,warn:30,error:40},gs=(()=>{let n=process.env.COZE_BRIDGE_LOG_LEVEL;return n==="debug"||n==="info"||n==="warn"||n==="error"?n:"info"})(),M0=process.stdout,z0=process.stderr,hs={}});import{chmod as Z0,mkdir as Q0,readFile as ex,rename as bs,writeFile as vs}from"node:fs/promises";import{dirname as tx}from"node:path";async function It(n){try{let e=await ex(n,"utf8");return JSON.parse(e)}catch(e){if(e.code==="ENOENT")return null;throw e}}async function In(n,e,s){await Q0(tx(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 vs(c,o,{encoding:"utf8",mode:s.mode}):await vs(c,o,"utf8"),await bs(c,n),s?.mode!==void 0&&await Z0(n,s.mode)}catch(d){await bs(c,c).catch(()=>{});let{rm:u}=await import("node:fs/promises");throw await u(c,{force:!0}).catch(()=>{}),d}}var Cn=Ce(()=>{"use strict"});import{promises as Ss}from"node:fs";import{homedir as nx}from"node:os";import{sep as rx,join as le,resolve as Es}from"node:path";function K(n){let e=n??nx(),s=le(e,".coze"),o=le(s,"bridge"),c=le(o,"lib");return{cozeRoot:s,bridgeRoot:o,libDir:c,libEntry:le(c,"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(s,"agents")}}function We(n,e=K()){let s=le(e.agentsRoot,n);return{root:s,config:le(s,"config.json"),workspace:le(s,"workspace"),logs:le(s,"logs")}}async function As(n,e){let s=await Ss.realpath(Es(n)).catch(()=>null);if(!s)return!1;let o=await Ss.realpath(Es(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+rx)}var se=Ce(()=>{"use strict"});var Tn={};jr(Tn,{AGENT_CONFIG_FILE_MODE:()=>Pn,enforceAgentConfigMode:()=>ox,loadAgentConfig:()=>we,persistAgentSessions:()=>Jr,persistAgentSkills:()=>kn,saveAgentConfig:()=>Pe});import{chmod as ix,stat as sx}from"node:fs/promises";function we(n,e){return It(We(n,e).config)}function Pe(n,e){return In(We(n.agentId,e).config,n,{mode:Pn})}async function ox(n,e){if(process.platform==="win32")return;let s=We(n,e).config;try{let o=await sx(s);if(!o.isFile())return;let c=o.mode&511;c!==Pn&&(await ix(s,Pn),Is.warn("agent config mode auto-corrected to 0600",{path:s,from:c.toString(8)}))}catch(o){if(o.code==="ENOENT")return;Is.warn("enforceAgentConfigMode: chmod failed (ignored)",{path:s,err:String(o)})}}async function Jr(n,e,s){let o=await we(n,s);o&&(o.sessions=Object.fromEntries(e),await Pe(o,s))}async function kn(n,e,s){let o=await we(n,s);o&&(o.skills=e,await Pe(o,s))}var Is,Pn,rt=Ce(()=>{"use strict";Cn();q();se();Is=L("agent-config"),Pn=384});function Io(n){let e=n?.sessionIdleTimeoutMs;return typeof e!="number"||!Number.isFinite(e)||e<=0?jd:e}function ct(n){return It(n??K().configFile)}function Fe(n,e){return In(e??K().configFile,n)}var jd,Nt=Ce(()=>{"use strict";Cn();se();jd=10*6e4});var Qo=ye(oe=>{"use strict";var I=D;(function(n,e){let s=D,o=n();for(;;)try{if(parseInt(s(1876))/1*(parseInt(s(482))/2)+-parseInt(s(1909))/3+-parseInt(s(1258))/4*(-parseInt(s(663))/5)+parseInt(s(1493))/6*(-parseInt(s(1096))/7)+parseInt(s(892))/8+-parseInt(s(1749))/9+-parseInt(s(711))/10===e)break;o.push(o.shift())}catch{o.push(o.shift())}})(rr,391329);var Gu=Object.defineProperty,ju=Object["getOwnPr"+I(1895)+I(555)],$o=(n,e)=>function(){return n&&(e=(0,n[{ILbfM:function(d,u){return d(u)}}[I(933)](ju,n)[0]])(n=0)),e},Wu=(n,e)=>{for(var s in e)Gu(n,s,{get:e[s],enumerable:!0})};function Ju(){return Ho||(Ho=[IDBDatabase,IDBObjectStore,IDBIndex,IDBCursor,IDBTransaction])}function $u(){let n=I;return Go||(Go=[IDBCursor[n(938)+"e"][n(452)],IDBCursor[n(938)+"e"][n(1903)],IDBCursor[n(938)+"e"][n(1903)+"PrimaryKey"]])}function Vu(n){let e=I,s={urelI:function(c,d){return c|d},CiBHD:function(c,d){return c&d},DgAXc:function(c,d){return c<d},fHLEb:function(c,d){return c===d},QTfST:e(599),VBjNJ:e(1706),vmHkx:e(1648),ZvPGW:e(1948),dnvCM:function(c,d){return c(d)},qjpPS:function(c,d){return c(d)},XKVzt:function(c){return c()},eVPGF:function(c,d){return c!==d},wukud:e(1222),GpNSu:function(c,d){return c instanceof d}},o=new Promise((c,d)=>{let u=e,g={yvdqu:function(y){return y()},UTKrf:function(y,S){return s[D(1359)](y,S)},CPEoM:s[u(546)],fMvUs:function(y,S){return s[u(1033)](y,S)}},p=()=>{let y=u,S={NCVdV:function(T,C){return s[D(912)](T,C)},yFujU:function(T,C){return T<<C},XIfZE:function(T,C){return s[D(552)](T,C)},XxcrI:function(T,C){return s[D(1265)](T,C)}};s[y(1727)](s[y(1471)],s[y(1647)])?(_0x19d03f=S.NCVdV(S[y(1943)](S[y(1227)](31,_0x1ad035),6),63&_0x2bb9cc),S[y(1693)](_0x26e0bd,128)?_0x4cb8f4+=_0x2fed0e:(_0x23b15e+=_0x33afa3(_0x5c1eb4),_0x3e96f4++)):(n[y(1531)+y(623)+y(1315)](s[y(863)],m),n["removeEv"+y(623)+y(1315)](s[y(1442)],_))},m=()=>{let y=u;s.dnvCM(c,s.qjpPS(qe,n[y(720)])),s[y(479)](p)},_=()=>{let y=u,S={WPPxO:function(T,C){return T(C)},ZLJXX:function(T){return g[D(1480)](T)}};g.UTKrf(y(1222),g[y(363)])?(S[y(1813)](_0x15c3d5,_0x50a1ea.error),S.ZLJXX(_0x6e3101)):(g.fMvUs(d,n[y(1948)]),p())};n[u(597)+u(667)](s[u(863)],m),n["addEvent"+u(667)](s.ZvPGW,_)});return o[e(1487)](c=>{let d=e;s.GpNSu(c,IDBCursor)&&di[d(590)](c,n)}).catch(()=>{}),tr.set(o,n),o}function Yu(n){let e=I,s={LqNLe:"error",rSnFQ:e(1945),dzxxK:function(c,d){return c!==d},ZiFOY:e(484),qYiGt:function(c,d){return c(d)},ebdOC:e(390)+"or",SROEQ:function(c,d){return c!==d},XyhJo:e(1720),nRjCl:"complete"};if(er[e(879)](n))return;let o=new Promise((c,d)=>{let u=e;if(s[u(1148)](u(1720),s[u(1352)]))this[u(1599)]=_0x1126bb,this[u(1263)]=_0x4a0ece,this[u(1440)]=_0x182b0f?_0x439ffe:_0x48a8a3?_0x4708de:null;else{let g=()=>{let _=u;n["removeEv"+_(623)+_(1315)]("complete",p),n[_(1531)+_(623)+"ner"](s.LqNLe,m),n["removeEv"+_(623)+_(1315)](s[_(382)],m)},p=()=>{c(),g()},m=()=>{let _=u;if(s[_(1049)](s[_(753)],"nMamL"))s.qYiGt(d,n[_(1948)]||new DOMException(s[_(1133)],s.ebdOC)),g();else return new _0x145e06(_0x4184ba,{code:_0x704e2a,reason:_0x571a10,wasClean:_0x5369dc,willReconnect:_0x2a1be6})};n["addEvent"+u(667)](s[u(1780)],p),n[u(597)+u(667)](s[u(1022)],m),n[u(597)+u(667)]("abort",m)}});er.set(n,o)}function Xu(n){nr={lOxHU:function(o,c){return o(c)}}[I(1509)](n,nr)}function Zu(n){let e=I,s={YcSdI:function(o,c){return o(c)},HFIWI:function(o,c){return o(c)},pXgMk:function(o,c){return o(c)},AoRBJ:function(o,c){return o(c)},MAlyK:function(o,c){return o===c},YVcIS:function(o,c){return o in c},tDsau:function(o){return o()}};return s[e(1621)](n,IDBDatabase[e(938)+"e"].transaction)&&!s[e(719)]("objectStoreNames",IDBTransaction.prototype)?function(o,...c){let d=e,u=n[d(1045)](s.YcSdI(an,this),o,...c);return xi[d(590)](u,o.sort?o[d(904)]():[o]),s[d(1520)](qe,u)}:s[e(1768)]($u)[e(1738)](n)?function(...o){let c=e;return n[c(1800)](s[c(491)](an,this),o),s.HFIWI(qe,di[c(346)](this))}:function(...o){let c=e;return s[c(1520)](qe,n[c(1800)](s[c(1769)](an,this),o))}}function Qu(n){let e=I,s={wwhZD:function(o,c){return o===c},SkcAK:e(704),ZeeMN:function(o,c){return o(c)},CXJBC:function(o,c,d){return o(c,d)}};return s[e(1028)](typeof n,s[e(689)])?s[e(1031)](Zu,n):(n instanceof IDBTransaction&&s[e(1031)](Yu,n),s[e(962)](Vo,n,Ju())?new Proxy(n,nr):n)}function qe(n){let e=I,s={ElmLr:function(c,d){return c(d)},vdJvP:function(c,d){return c!==d}};if(n instanceof IDBRequest)return s[e(1901)](Vu,n);if(Zn[e(879)](n))return Zn.get(n);let o=s.ElmLr(Qu,n);return s[e(1330)](o,n)&&(Zn[e(590)](n,o),tr[e(590)](o,n)),o}var Vo,Ho,Go,di,er,xi,Zn,tr,nr,an,jo=$o({"node_modules/idb/build/wrap-idb-value.js"(){let n=I,e={ucrjk:function(s,o){return s instanceof o},kGZDK:function(s,o){return s===o},gzpvB:n(950)+"oreNames",tYGnr:n(1814),LVvuy:function(s,o){return s(o)},PsNBO:"skzMi",mwRcE:function(s,o){return s instanceof o},NMoOA:n(1230),kczmZ:function(s,o){return s in o}};Vo=(s,o)=>o[n(1951)](c=>s instanceof c),di=new WeakMap,er=new WeakMap,xi=new WeakMap,Zn=new WeakMap,tr=new WeakMap,nr={get(s,o,c){let d=n;if(e[d(341)](s,IDBTransaction)){if(e[d(1802)](o,d(1230)))return er[d(346)](s);if(e[d(1802)](o,e[d(827)]))return s.objectStoreNames||xi.get(s);if(o===e[d(919)])return c[d(950)+d(1779)][1]?void 0:c[d(950)+"ore"](c[d(950)+"oreNames"][0])}return e[d(1507)](qe,s[o])},set(s,o,c){let d=n;if(e.kGZDK(e.PsNBO,e.PsNBO))return s[o]=c,!0;{let u=_0x2657d8[d(1372)][d(549)];u&&_0x5f3311.setCursors(u)}},has(s,o){let c=n;return e[c(679)](s,IDBTransaction)&&(e[c(1802)](o,e[c(931)])||o===c(1814))?!0:e[c(654)](o,s)}},an=s=>tr[n(346)](s)}}),Yo={};Wu(Yo,{deleteDB:()=>tf,openDB:()=>ef,unwrap:()=>an,wrap:()=>qe});function rr(){let n=["y29UBMvJDca","B3jpBMXPBMu","yvfjt1K","ig1LC3nHz2u","vKj5ALO","r1ffq04","C3zKzgO","ALLeu2e","qu50q0G","s2n5wwq","vxbKyxrLq28","x2XPC3rLBMu","B3bLBKrc","BwT2rKK","yNnPAfu","zMzmAw5L","igzHAwWSig0","x0rctMfTzq","x2LUAxq","yMfSu2nVCgu","rKvOqLu","B0XkDMG","uLvNwNi","AufUD2W","BMfTzq","seTXwhG","igzPzwXKoIa","yNL0zu9MzNm","Dg1RvwO","r1bgqMy","yNLL","Aw5N","CNnVCL9Uyw0","zgv2AwnLx2K","z2vtEw5J","tLPPzNO","Be9zseS","veL4yvC","DcbVzIbYyw4","tufSEuS","Dg9iyxnO","B25mAw5L","uxLwrvi","z2v0sxrLBq","AhfguwC","EwrbDvm","uLjpuG","mxW0Fdb8m3W","qvPetK8","y2HnyxHuCMK","shrXt2C","CMvHzhLtDge","B25LCNjVCG","zvL4r1i","vufxChm","EvzoB3a","AK9bsLC","v2vIu29JA2u","wffwqKK","DgLLCKPtt04","AgLNAa","s2PNue8","CvjjDeW","sLzys2e","t0f0zLC","vKjQtKO","C3vJy2vZCW","s0juAwe","CePss0i","BIWGAg9ZDg4","whfQEwi","zejbvui","DwzuCLa","zw50zwqGDhK","ANbxrhG","C3rVCcbPBw0","y3jLyxrLt2i","zvLTvum","sNHgsgW","ywXSq3vYC28","zxjYtM8","ANr4uMG","zMLSzw5HBwu","Dw9oEwW","tNnnqLC","z2DUAKS","Cu9QCeK","zw5HyMXLqxu","AMvJDfn0B3i","ChjUtgq","yLLWueu","rvjKALC","ENHWsMW","DgfYz2v0","zMLUza","CuXHz3a","r3ftvfO","qNrKr1O","vfreDwi","Dxrjza","qxHbwey","C013ve0","B3zwBwC","t1LHrve","BM1jB1C","rNvnsKK","twXwEfa","sNrUvNG","yxvnBwW","ELnHzhu","y3ruAw1LB3u","whHJCKK","Cvjzq3u","zw5XDwv1zq","Dhr3Awq","AuLxrwu","B3bLCNr5","CMvXDwLYzwq","CfjsA3a","DxbNCMfKzw4","AM9PBG","y21swMe","zgvSzxrL","ywnRx2LK","zuHzy0q","zfv3twK","EgD5zKG","x2nYzwf0zvm","su5nCKG","yuLOue4","v2LUzg93","C3vIyxjYyxK","zNjVBujPDhm","y0vhqwC","rKLmrv9ot1q","Cvjbrg0","s1f6D0q","EhDnC2O","vezfs3K","ywnOzwqSihC","zw5At00","zw50","tg9JAW","Egz0r3O","x2LZtwLUAvC","zKHmrwi","AxnrB1nby2S","C0Xf","zuvKCMi","CM92AwrLihy","Bvbkrfq","D2LSBfjLy28","AwnpzeW","sgnHuhO","DgrvAem","Ehj0wgi","Aw5JBhvKzxm","x2HHBMrSzu8","B1LTAu8","wKzmv1m","rhjfsfO","tMDRAMK","x2n1CNnVCKy","B25tDg9Wsw0","CNnVCL92ywW","EgHkv0q","wKH3ExG","nJK0oda5A2fuA0TQ","y29UBMvJDgK","DNDmv3i","Dg9cExrLC0W","ww9ey3q","ignVzgu6ia","tg5lz2O","AxmGDw5Kzwy","DLbTuMW","Bwf4tg9ZC0m","Aw5KzxGGB3u","q29Js2W","CMfTzq","DuryB2C","id4G","BeTfELi","ywX3yxLZ","zK9Tq2W","DhjPzxmGCMu","DerZyxu","qw9sqKO","t1bftG","AwXLtMfTzq","q01vEwe","vKzxy1y","AuzvseW","D3nZoI8V","s3n3C0O","Bg9IywXty28","y3boz1K","B3jLtMfTzxm","BLjQq2W","r3neu0W","D1b5twe","uvD4rw8","B21Ouuq","Dez1AMe","AxvuzwK","tvvfwvG","u0rlzfi","EMH0rvi","D0vKDLa","s0vhANq","C2jtvMW","vMnws3y","q3vZDg9Tq2W","CMvUDevUzha","zNjVBuHHC2G","tgnQCw0","q3Hytva","B25nzxnZywC","yxbWBhK","AefzB08","A0DAreS","BhbLtg4","BgvUz3rO","C3r0BKi","BKHqsfy","A3rly3a","B3jRig9MzMW","uNDjqMW","yNj3ugy","r3PMwui","reXMsuq","v1bqEe8","C3rVCMu","EwPfrNy","yNvMzMvY","Bu15yNm","B1PuvMy","B0PuywG","rKfbuuq","zv9ZDwnJzxm","EvfhEgq","rhfZCei","DMf0z3q","BM9Uzv9UB24","EhHfAMu","DM5qseK","CMvWBgfJzq","x3bPBMDmB3m","vxHxs08","EvjLy29UBMu","vhHYDMW","vwzJENu","weHWsxm","ihzHBgLKigq","zw5HyMXLuw8","sgfKCK8","zgnfAKS","tfjev2q","vLjrsw0","DvrhrM8","ywnRpwzYB24","uhjpD3u","rgTOAem","Aw1LCYbPBIa","sfHty3a","ihrPBwvZ","BKXhB0m","wNz4q3K","EgHIvLu","zcWGDw5RBM8","tMT2q0K","lcbTyxGGCMu","BefetKq","D24GCMvHC28","BgLTAxq","q09oveLovuu","yKXTv1G","AvPbvM0","zLzXBgy","zgPAzuW","EhPNwge","Aw47y2HHCNm","r2HivwG","x2HHBMrSzva","DMfS","zfrqzNi","wwX3wM8","DLvsAg4","qLHoBuO","zxmGCMvHy2G","wur2EgS","wLnWr3m","qMnus1C","B29OEuO","nda5Be1Tz2vS","Cej6tMu","zxjFBxnNAwq","BgXADwe","AxjLza","BNrLCG","x2rLC3rYB3K","wxPABuS","uKHHCeW","CM5hsuq","ywDLu2HVDW","qKjiAfq","DgfIyxnL","CM92AwrLigi","vw5PBxbSzw0","y0Ldyxy","Ahr0Ca","BMrLEa","u2zRA3i","B3bLCNr5tMe","DvvwA20","yxKSihrYEsa","twHnEM0","ugHOuLi","DwLHANG","rwXTthi","DKLHD0q","y29UDgLUDwu","CMvHzhDYAxq","C0HLAwG","z2vjBMzVu3K","s21Wuhu","BM5Ly3q","mtmYmdi0CNPcEw5T","C2vYDMLJzs0","zxjFDhrS","B2zM","ExbL","quvTrhK","ruT1svu","Cw13CMq","y1fKsKG","uNfSDM0","zLbYEvG","tuDxD0C","Bejcq2K","sKTyB08","qNL4ELK","A0nWr0y","tgzhtvK","C3rYAw5NAwy","wNzLr04","AwXK","zNjVBNrPzxi","DeXhExO","Aw9U","tuvtu0fhrv8","v29ftLq","zxjFywnRx20","x29UugfNzu4","BKrYr0y","wK5iB3K","BMv4DcGPigm","zgvJB2rLzey","x3jLy29UBMu","CvD2vLu","CMvZB2X2zq","Euz1ALu","CgLUz0LUDgu","ywjVCNq","ywnRx2nVzgu","AKf2qLu","zxjYB3i","Aw5Lza","mxW1Fdr8mhW","C29Tzq","zMPprgK","AK1cweC","B1LuDeK","yxnL","ihn1y2nLC3m","DfH4y2K","DMLJzuLeig8","y2XLyxjtDg8","uMvJB25Uzwm","Bw9hrg0","rMnzzMG","x2nVBM5Ly3q","z2TdEge","qLzNu20","ww5btMi","Ehr2BgK","DMfSDwu","u3DLshq","EwrUuNm","CLr6s00","DwnYAMS","zufJAW","DMfSDwvZ","DeLft0q","yvzrz24","z2v0","AxnpCxO","Au5ZBwq","rfL6sw0","q3nWrMy","B3rlCeO","CMf5rg8","Axnby2TdBgu","ywrK","BgLUzq","zNjVBunOyxi","sfPUEve","Aundzuu","zMzLCG","BxfOruG","y29UBMvJDa","mdaWma","q1bfB00","tg9Nsuq","Cw9Zx18","q0Xpu0ve","DxPXzfi","vvbjDfa","CNbjtNG","qLfus2W","q1jeC0i","z1vwBei","DgvZDa","EfvZzuvUDG","CgLUz1rPBwu","B3v0sw50zxi","uu1NCeu","zxjFCw9Z","CNnVCKzPBgu","y2XVC2u","runZvxG","CLnUrLe","zwzYC0O","Cg9W","y1vVDKu","BKXPBMu","BKzuq04","B1LhsLK","x29Uq2XVC2u","qwjVCNrfCNi","yw9NuvC","tNfouMm","ExrKDvC","Fdn8oxW4Fde","B3nLrxzLBNq","s1zOEe0","yw1LoIa","Chv0","Ae15BMq","t0Hwug8","rLLPvvq","rvjst1i","B0Dnvee","s1zSBvu","rhzczvm","vvHYsfm","A05wrxy","BNznr1a","v25JtLO","tKnMwhC","B25ozxr3B3i","EKjtyNu","BgjJDeW","s1fpyKO","s1HQzhm","zNDZxZeUmc4","EKrrte4","quThv2W","BezhvK4","Dg9tDhjPBMC","Aw9Ul2PZB24","D2zRvue","A0Heq3u","EhnQDM0","CgfNzwHPzgu","ywXS","ELjezhy","vgfN","nhWWFdf8mNW","DxjS","rvrSq0W","swPfuK4","wMT4DLO","yMPruhq","yMLUyxj5vhK","yw1Lu3bHy2u","DMvY","yLfvsNa","Eg1IBg8","se1msui","z2v0s2v5","AwDHDg9Yt24","DMvUDa","ChbL","q291BNq","vKPsz1u","ihrPBwvVDxq","C2v0y3vYC28","CM9Xvue","yxjiq0O","x3bYB3rVy28","ywr2yw5Jzq","v2LwD2C","sNj5Ewu","v3bKq00","sMnAB0u","tKf6DfC","vgfhrK0","svjrs2u","sg5UsvO","DgvmB2Djre4","B25Uzwn0Aw4","EwTWsLy","DeLK","CfrishO","C2v0u3rVCMe","ign1CNnVCIa","tNrvyMy","ywXSzwqGBxu","Bwu6ia","A0vnzeu","Ef9MCM9UDgK","zMLN","sMnjzMS","t2jQzwn0","B3jRzxjhBg8","z1fKEwG","qLD1zwG","weTwENq","AgfZt3DUuhi","B2nRzxrtDwm","mJyZnKDOy0zOqW","r1nYwfq","revsuee","rfDWA2m","qKnNrhe","CwTJuM0","v3Pjtgy","x2LZtwLUAvq","CLPbzwy","CfHNtwS","z3PWqwm","wvfRzgy","z1bgDhi","zxf1ywXZ","y29Uy2f0","sKr6vhu","rwrqr2m","qxjzBKS","wMnprKO","tKDFrvjst1i","AMf4Eui","Evr1uKG","AuH6BwS","vxrRAuK","B25dBg9Zzq","AhjnrKu","thDsrLi","zsbHihn0CMK","EMPVtgS","yNDRAuu","Dgv4Dc9Qyxy","ELzLwKy","rfH2DuS","AgvKtwf4uMu","B3bLBG","x3vYBa","zNzXwMC","x3nVy2TLDa","suTiC2S","B3vUDa","zwrPyxrLBhK","ihzHBgLKihm","AejiBg8","r2TVtfK","s1rgCMW","DgHHBIbSB2m","zNjHswG","q1b1Bhq","vwPXCgi","y1vZDuq","vK1Zu0q","C2XPy2u","DcbSAw1PDa","ufDQzwy","sMPLwgG","CYbHBhjLywq","DejLsKm","C3vIC3rYAw4","x2HHBMrSzvi","y2HLy2Tszwe","whPYEwe","A0fkvKK","zwfPu0G","z2v0q3vYCMu","D3vRDwq","BMCGDxjSoIa","x2TLEvbHDgG","Cgf5Bg9Hza","CMvKDwnL","vNHwz0C","q2Lcseq","y3vYC29Y","twvZC2fNzuu","BwvZ","Cgrms3u","yKHUreS","DurQww0","qurzv1q","zKrLvhy","A1n0yxr1C0m","rNjVBNrPzxi","u3fHuhK","rwnRsNG","zhncAKi","DgLTzw91Da","CM92AwrLige","B2fK","yM9KEq","tuzuDeG","qw1VDw50","B3nLza","DxrVuMvJB24","r25Pr2S","y3vYC29YlNm","rxb2tge","DNbWEKO","BvDUsge","B2j1t2G","B0XYBNG","CMXovei","se5HEwy","BgvY","vwHlD2u","s1P4AuS","ALP6q2K","q3HosgC","AxnyrM8","yLvbEMm","C2v0","u0nqBha","DMvKy1m","u3buBw8","rfj3yLe","qLDeqwq","CgLUz19VBMm","ywrKrxzLBNq","swn3rxe","C1jMA2K","v29qzhq","C3nHz2vfDMu","u1vWwLm","x3bPBMC","wu5eqMW","wgDIuhO","u2vXsuq","qLfUu0K","B25pCgvU","t1jnsg8","ywzL","re9QywG","AxnFywnR","yxv0B21HDgK","DeDlzvi","zw5JB2rLrNi","z29PBMCGyxC","B25tDgfYDfi","y2Dky2u","qK1NtxO","DNjOAva","t3rJz3e","D0jKCum","zw50tgLZDgu","zw5HyMXLvhi","wK1wvgS","t1nPvvu","ww1Xtuu","rxzyEe4","z0Teshq","DhjPBq","CNzHBa","uuTsCei","DeP1Afe","zxHWB3j0CW","u0vLq1C","tgvesLu","AwrI","z1rPBwvVDxq","svD4qu0","y2f0y2G","tMzrB2i","C2v0sxrLBq","Ae9Wzw5fDMu","CMvJzxzPzwq","ALv4EK8","Evfutw0","A21qqLO","z3PfsMK","sgnJsxy","z1Ddvhy","vu5eDNq","y3vYCMvUDeu","u0jSEK4","A2n6BvO","x2LUAxrhBg8","y0nesLG","CMvTB3zLq2G","D1znseC","rgr0C1O","C3jJ","igXHCMDLCIa","z1v3whK","mJvUEfP2vKW","AKjPruW","q3vZDg9Trxi","qNjxEuO","tgLZDgvUzxi","Cg93","yxrHlcbKyxq","C0X3vuW","r0PyCKy","CgLUz0XVC3m","Aw5PDcbrB1m","u3rYyxrLz3K","C3bSAxq","y3jLyxrLuMu","ugjUv00","y0nZBwK","BxDsy0u","icSG","z2vczum","BwvKAwf0zwW","t09lEhm","wgHlB0G","AxHqr24","DwL3rfO","AxnAzxjV","BfvLB1C","u2TJquS","txnUsLe","DuLivwq","aaaaaaaaaaa","y2XLyxi","q29Kzq","x2vUzhbVAw4","u0PwALC","u090v0S","EKnKCfO","yu1PzuG","u1HYvxC","zeXtvem","u1vUuge","q3HSwgG","zNvUy3rPB24","s0frEK8","A0XUBxC","yxbWBgLJyxq","uvLpzMO","CMvZzxrdB3u","tg9NsurozxC","ndi2mdC4mhrqC2Dbsq","wMTiD0q","B2zMBgLUzq","zMf0zwG","Aevdz1q","quXm","zu5AD0K","EMzMr1G","wvzJsvm","CMvZDwX0","q29UzMLN","zMzMzG","vgHczLu","rw1Rz28","ze93Dwu","x2DLDeLUDgu","zuj3qum","Bfvdrwe","sLPqywC","DKP6D2O","zxjHDg9Y","rK5xqLe","lcbxzwjtB2m","DLHZzvm","svj6Efa","s0HUu0i","zMLSDgvY","yNnZyMi","ww1ZA2O","A21UBM8","ruXjA3K","sezhy2C","qwvAEgW","zwn0","r3jbvhe","A2v5","CNfUyuC","Dg5KwKm","AMPUv3G","sKDLsuW","uvHKzxe","t3nrq1q","wMLgt1K","BuzNEMW","z3L2EKO","yuvnwK8","uw1XrKe","Bw9JEuS","DNbrt3y","BxnNsuq","Ehz5u2C","BevAsg0","zxH0zw5ZAw8","B3bLBIa","zxjFAxnFywm","zM9Yy2u","DeLUDgvYy2u","AgvHzgvY","CufiDhe","x3bYzwzPEa","BhHRAuG","A0jZALm","DhjPzxm","AvzjChO","uM92ugG","x2zVCM1HDeu","DuLABuO","v3H1BuG","swfZBeq","B2zVvey","thfyyKS","uNzJBxG","BgLUzw5V","qwf6v2G","EM1VBxe","DxrMofDYAxq","shrwy3a","CKDjvMO","D3vnzNK","q2PUyui","yMfSrxzLBNq","ruPxrLO","qKzsANi","vw5Oyw5KBgu","y3vYC29Yx2y","Dw50","vgLTzw91Da","x21LC3nHz2u","ueLJsfq","uuXND0W","qxHIBuW","y3HdshK","yMXVy2TLza","CMLLC0nVDw4","ugLhqNq","y3jLyxrLrwW","rLbpshu","v1bsuLy","ENPzCMu","zv90Aw1LB3u","CvzoB2K","z21oBhi","q1fmrvi","BvnMq2K","EwfbB3e","B2zfsgC","yMDOzKW","v0jdwuC","Cg9PBNrdB24","CgLUz09Uy2u","uxPgAhq","CNjVCK1LC3m","tuLMDvC","CeTNCLq","zuPurw0","x29UtwvZC2e","z3PWDKi","BwLUAvbYB2C","rNbHCu0","B2nRzxrgywK","DNnnseO","Dw5RBM93BIa","s0TRyvm","z0rQEMu","q3bsuLC","q09otKvdveK","ser6zwy","DxfgCgG","B1LitM4","sunMBeG","C2Lisfu","swXut0W","D2vI","x3nLCuLK","ywzuuKG","vhnJB3a","m3W0Fdf8mhW","r21qzuK","B0HYCMy","runvzLu","l3DZl3yY","uvzituG","D2r1Bee","zw1PDa","revuwNG","yxnZAwDU","BMrWB2LUDfq","uurfEfm","zgXiugC","B25TzxnZywC","B0jQDg0","zxj2AwnL","DM1iA3G","s1verxa","q3nMBLO","CvfVvLa","vxbezg0","Bwf4twvZC2e","y3jLyxrLtwu","y2XVC2uSihC","rKLYuKi","u2zpyvK","r1rdAxe","x3nLBMrby2S","ywXty29Wzq","uLzxDu0","x29Ut3bLBG","DfjLz3y","AgfZ","Aw5L","D2fNufC","A2vNsw0","wvbWANq","zgDTr0C","CM9YrxzLBNq","z3niDfq","v05gtvu","zMLvC0m","se5rB2y","rvf4u2m","ihrVihjLDhi","mJKXotG3mNvMD2TvyG","y3vYCMvUDeK","mhWX","yxv0BW","uLPNy3G","x3DZsw5ZDge","wu1kzLa","yM9L","DMvYC2LVBG","z2HpyuS","ENLqs20","v2vPEgLUsLm","C29YDa","x2rPC3bHDgm","z2u6ia","A3vgzey","y29Kzq","thnmzMK","zKvwrNi","AKzLzwK","DxjLBeK","rgvKAwnHDgu","r0nbwMK","CvjgDey","ruPVrxe","t1bftL9fuLi","ywnRDxbfBMq","DfLhBNi","z1vZu24","vvjys3K","shLdsha","reXxzuC","Bwf4uMv0CMK","yNbQzem","u2LUAve","D2n6AMG","pxv0zI04","Cw9ouuu","C0nVDw50zxi","tK1Vt0e","wfPMCMW","suXIzK0","y3jLyxrLq2W","y29TCgXLDgu","C3bSAwnL","weHtuuC","ChjVDg90Exa","rgDQwuu","CgfYC2u","A2XOA1y","CMvJzwL2zwq","rvLeDvy","CfjZDgK","ufnrDMe","y2uGBM90igK","t3bLBKv2zw4","Ce9kvvy","A05gEgC","B2jQzwn0u3q","B0LLBwC","C1bOrNi","B2j1qK4","Bu1xCgu","x194x21Zz18","txDUyNe","sMHHAxG","wuD3s3y","tw9KDwXL","vMLoAxG","swjbqLm","q1HkqKm","y29UBMvJDfm","x19LC01Vzhu","B2zMC2v0","sLnptLa","x2jPBMfYEvq","vKvMwLy","BwvY","CMfUzg9T","x3jLywr5q2W","Dev2zw50","CKLNC2S","x3jLBw92zvC","vKPAsgW","u2feB1C","DMvYC2LVBMm","Cvzyqxu","zgf0yq","q1n6AfO","nhWZFdj8mxW","wvbKvMG","CMziAuu","wxDnqKC","zhrQy0G","zNjHBwvuExa","r09zALC","y09Wzw4","twLZC2LUzYa","vu9AwgC","Aw5KzxHpzG","B25SAw5L","sgzLsee","zgvjsxe","o2nOyxjZzxq","Bhm6ia","ELPdquS","DwLctxy","Be9MDwC","A1jACxq","ywXSB2nvBNm","rgTutfO","BKTiDKe","shHMzM0","CMvWBgfJzui","BuHryvK","shvoD0u","B1D4wNK","BvD3vNG","suvtx0vsuK8","BMCGB3iGyw4","Aw9UvgLTzw8","zgXnBMS","yxv3yNu","yxKSig5LDhC","yK5lCNC","y3vYC29Yx24","rLjHs0y","zMXVB3i","DurWD3C","uhrSEvK","thfotgu","CKjMANi","Bg9N","A2HlzLu","x29UrxjYB3i","uxvLDwu","D3DOwKq","twPUDuS","quDPtui","wMvLtu4","BgfzzeK","CwPWufm","C0jf","EvvoC3a","qKrYvLa","vK1ruLO","DLbyv0q","wwHjreW","zxH0ugf5Bg8","uwvZruG","Bwv0Ag9K","D2fZq2XLyw4","rxf2vfe","y2fSBa","BNPrCLK","swnnzMy","q0Xpu0LorW","zhP4EeS","vKPYzfu","EefQENa","vhvOwee","r1fWEgK","vuLoD1C","EsbJBg9Zzwq","Dw5KzwzPBMu","x3bPBMDqB24","rxjYB3jdB2q","sg11C0u","z2v0qwXS","rwnAthe","y3vZDg9Tshq","q0jcrgG","x2DLBMvYyxq","yNL0zxm","B1zJrgi","s2XSDNq","yMLUza","q2Phzfi","AMTrthm","x2LZqNjVD3m","Cgv3vwe","vezws2S","B2rbEvG","EuvYt0u","AvLzs0q","ALzjDuK","wMPutMO","BLLrAMW","y0zAD24","BMfwEwy","CgjICdi","Dg9cExrLC0i","x2n1CNnVCK0","y3jLyxrLt3a","C2fNzq","AxDRBeK","x2LZsw5PDa","suvZsLG","y0vez2O","yLLrDui","Cgf5Bg9Hzfq","ze5LqwC","zwvKzwq","De1HBMfNzxi","n1fhEeP1vq","s0rcquO","DKLHv2G","yNbIEeG","ywDLsgLKzq","tKTju2u","t2LgB3G","rKz5zxi","zNzWyKm","zg1Jy28","Cgn0uMG","DhDVCMTdAge","B2vKAeW","Be5xEwK","CM92AwrLihC","sMLewhO","svjTzMi","mtf8nhW2Fda","wNvqBLe","Bff4AKO","reP2rKC","uufntK8","wuTpquS","ug5Wsw0","AxnrB1nnzxm","AgfUz2u","v3jTr2u","x2fKzfDZtgK","DhLWzq","A2v0ignVBNm","CMvJB25Uzwm","yLv2z0m","vfDREuq","x21PBMLoyxy","tvbAs2C","r3b3Awu","wLPetg8","zwjKt0m","zKXQEha","CwXbAMi","r3zpyMm","y3r4","rvfyEw0","BuPgB00","wvnZthq","qNbHCgy","AuL1CLC","zwnVBM5Ly3q","BKD5DfK","CvDjr08","C1vtz00","BMnLq2XVC2u","u1jprve","zw5fDMvUDa","tKHxugO","qxfmDee","EhPMuNK","r05tzfO","uhbOzKG","z2v0u3rVCMe","q3D5whK","mhW0Fdf8mNW","zg56C3C","tvrRD0G","sK9xB0S","zgjrEg0","CMnRtg8","zgvIDwC","zNjVBuj5Dgu","BfrPBwvVDxq","BM1PB2G","CgXLyxnLiha","ExHny2i","z1DfseS","CgHjruG","Dw5ZAwDUzwq","ANDPD1m","CNzHBfzHBhu","twveyKK","lcbOB3n0BMe","B25VCgvU","v1Pnwfy","C0XPC3rLBMu","yLbcrKu","BKnmDgW","uMrStNC","vw1Rq20","DgTfD3a","wxPkz2u","zfnsyvq","DgzWqvu","BLfnve0","zw5KCg9PBNq","Dg9Y","uhD6A2q","weLcueO","qxv5seu","t0nHEfm","x3DZ","y29UBMvJDeu","z2v0q3vYC28","zfz0teu","whPNsxe","sePIBwy","BMz2z24","DwHgvvG","CgnXELe","D0ztDM8","A3nbteC","BNbltve","r1bNv2K","CMvHzg9UBhK","C2vYDMLJzq","wwTNEwW","Dhn5wM8","BfbTuui","z2vY","zNbvCvK","ChrVCG","D21LCe8","BgL2vNq","rLnlz08","Fdf8n3W1Fdi","wfHRuLO","rxzLBNq","wK90zNK","BxnUB1G","shb1DKy","C2v0q3vYC28","BMCGzMfPBgu","y0H1vMO","weLMwKu","z0DovKC","Bg1cueq","zg9Uzq","AxnmB25N","EKvZAhm","x25HDMLNyxq","AefJA01LC3m","s0PivMi","ywzNvKe","z3fAzuC","ywDL","D1PXueS","A2HdsxO","yNL0zuXLBMC","yKLot2e","DNLWA2O","ihjLy29UBMu","rMv2zLy","AwXLx25HBwu","BNruCMLLC0m","DfjYuNu","BMDLza","zer5uuC","x2rItMfTzq","tefxuxO","C2nYAxb0","yxD3zhu","y29UC3rYDwm","x2LUDgvYDMe","BhnxENq","mZaXmtqWBgrmAgLr","z2v0qwXSs2u","reiGzMfPBgu","BwLUzW","sxrNDwS","x3bHDgHlzxK","x1fVu01HBMe","rgDbwgm","BhrPCgXLihq","uurgrvq","wLDoqLa","yxnJCMLWDa","uhjcBhe","AuvbwwG","tvLuBxO","rLLuA00","ChvZAa","vfreze0","rLPXuLm","x2rLyNvN","wejbz08","wgDIEgO","yw1L","tufyx1jfvfi","zuzxq1i","wM5kD2i","Ag5Hwxe","BwvZC2fNzv8","B25szwnLAxy","y1j6s1y","qxr5uvu","ywDLrxzLBNq","ChD5zwy","zwftDwS","CwTqwxG","svrntge","ugTHvxy","CMfTugfYyw0","y0HbD1y","B0PsugC","uuD2quO","y2HnyxHdB3u","r1DPrgu","Dg9hzw5LCMe","zNjVBu51Bwi","CezzuMC","EwHAs2q","y291BNq","wgHmsMK","EMrxCgK","Auj5rMi","rvLQq1y","y2vZC0HHBMq","y2HHCKnVzgu","ALf5BgO","tgHeAMu","CYbPBNn0yw4","BMvY","C2vUza","wwHPD2q","qwDktLa","BM93","yw5Hz2vY","EMj4see","zxzNAgu","tuz2sK0","CKnoCK8","sfvHtfG","yw51Ce1LC3m","Ehr4zNK","C2vYDMvYvgK","zxjzquW","DMrkDLa","zMfgwe4","AeT6Bhm","BLLxrfe","Bw9iBvu","u2zlv2K","t2j1thK","CgfNzxnOB3C","sKLSyum","te9uCxK","BeTxDhq","vfr0Aue","q21IzeS","C3rLBMvYCW","EgDAAgi","tgTSvNq","t21tuxq","uK96svK","DvzYvNK","yMzvEKS","tvPXwfC","vuLuC0i","whLOsM8","AevYCM9Yrxy","Ec11C2uT","vM5mq2O","AxnbCNjHEq","D3jPDgvvAw4","D3m6lY8","zvzqr0y","rxLUDw8","ENvcr1K","zu5ry24","ysbTDxn0igi","svfNrvO","CMTLCKDSB2i","q2jUsu8","zxrxB3jRq2G","vhnAzvu","C2v0zgi","rxvbt0G","qvrvzLC","BwvZC2fNzq","CNfJDeS","m3WXFdj8nhW","yLPZuhG","mxW1Fdj8nG","zuL3shK","DuXdt1e","D2PZuhu","Dw5dyxa","ywzWzvG","AwXSihvZzsa","DgLUzYbZzxi","u3vSshO","whvJrNy","ywnOzwq","DxnLCKLW","D3jPDgu","CMvHzfvjBNq","Cgu6ia","s1Hyuw4","zw5NDgG","D0j0y0q","q2v5Ag0","AMrIEvO","veTmsuK","BLL5yui","DxbKyxrLq3u","sM9zsvC","EuzrseG","AgvHzgvYCW","DK1st00","m3WY","D1foENC","BKrlA2S","A2v5CW","rLDt","v3fxvhm","tKvstNu","vefpDwS","quT3C2u","BxnN","ELfgDKu","y2HLy2TdDxi","BMnfzuG","Dg9oDw1Izxi","uhfAq2u","y29UDgv4Da","x2LZv29YA2u","y2XVC2veqG","qvfgthe","x2rPC2nVBM4","r2D2z0O","tK9AwLm","Bg93","zKPju0S","uxDLzLi","BMnVzgLUzW","Bg9NsurozxC","rfLyCuK","tNPbtKW","zwDvBvi","z1fAyvu","s0vSqM0","Ec1TC2CTy3u","zMX1C2HfEha","z09otem","B1vLB20","zgvMAw5Luhi","x3fVC0rc","Ae1LC3nHz2u","wNzqr1C","se5oCwO","DxjSqu4","BwfUDwfSihi","vhbksKW","m3W0Fdj8mxW","D09PtNO","C2HPzNq","tM5yrNi","yNvMzMvYzwq","x2rYB3bhBg8","zfDVCMTLCKC","zgLZCgf0y2G","Cwf0ufm","zM9YrwfJAa","sfHYCLm","tuLLCg4","B2LUDfjLywm","ChjVwwK","rgrhrwC","B2nRzxq","u3rbCuW","uhn6sfu","CMvHC29U","yxHbsem","CMvZzxrfBMq","x2nSzwfYugK","BezSDxnO","AenSB3nLrxy","uvrMu1q","uhjmt3G","Dgv4DfbHEwW","tePdBe8","y05ivKq","v3rlBfG","zw5JB2rPBMC","uM5Jvwu","B25JBg9Zzq","ExzKCxu","yLDNDfi","Cwfly3u","zxjYtxnN","DhjHBNnHy3q","zgvS","x2LUAxrqCM8","DgHLBG","Bg9Nsurhzw4","CgvYC2LZDgu","DM9LwfC","BMv3vMvYC2K","x29WDgLVBNm","mJa1mteZmevcsffZta","v1DjEue","ANvls1e","Cvz3Eu8","C2vUzf9Hy2S","rLfUsKm","u2vYDMLJzvC","vhzUCLa","AfjICu8","thPQDu8","wwjTCva","Aw5KzxG","Dg9cExrLCW","uxDzqNC","tfz2DxK","BNrbBMrvCgq","Be94sfu","uurewhK","BxfHuui","DeXwrLy","D3HJsLq","Dg9VigXHCMC","sfbryuW","D1PoBM0","x2nSzwfYvgK","Du1YB2e","CujAuhi","sezjv0K","mdaWmdaWmda","tMfTzq","BwLZzq","vLDzvwS","C3rYAw5N","ChjVDg9JB2W","zgvSzxrLrge","zenLueO","yuPVt3i","qvvxBLu","CMvTB3zLrxy","Efrurw52","D2D6wNe","yMfJA3vWigu","z2vrDwv1zuW","u1viEMG","zwPrtLu","z2HfDLO","DhbizwfKzxi","Dg9mB3DLCKm","vvzor3m","AxnszwfKEq","vg5KBNC","zvvYBa","u1jfvuW","uMnJvKy","ywnRtxnNswq","qNjPzgDL","qvjSyKq","s0f1wMm","BhHhweG","AKDREg4","wgzcD1C","yu1cr1O","sK9nBeO","Ewvbuwe","wLHwChm","wNHpt3a","zvPhDeq","BwfW","Eu1HBvm","ywrKq291BNq","r1D2tK0","BKr6y0i","v2nwAey","Cgf5Bg9Hzeu","yxbWzw5Kq2G","BNrfBMrWB2K","BeHHBMrSzxi","zfncwMm","BgLZDgvUtMu","DK1sDM8","x0vysvnu","yuP1Cge","y3jLyxrLrxi","BMDuAw1LCG","EKn4BNu","AeHjvMy","uKn2A2m","CLzHBhvLCW","CYbWyxjHBxm"];return rr=function(){return n},rr()}function ef(n,e,{blocked:s,upgrade:o,blocking:c,terminated:d}={}){let u=I,g={SBlzN:function(_,y){return _-y},tJlGM:function(_,y,S,T,C){return _(y,S,T,C)},DrEHZ:function(_,y){return _(y)},PWjef:function(_,y){return _(y)},DqspB:u(380),GPgWi:function(_,y){return _!==y},YGwKv:"oHAhC",GWiDe:u(1701)+u(1094),FZqRS:u(803)},p=indexedDB[u(516)](n,e),m=qe(p);if(o)if(g[u(1206)](g[u(958)],g[u(958)])){let _=_0x329489.substring(0,g[u(653)](4,_0x3a1147[u(1804)])),y=_[u(496)](_0x19d021);_0x2dbd38[u(1274)](y)}else p["addEvent"+u(667)](g[u(1300)],_=>{let y=u;g.tJlGM(o,g[y(1742)](qe,p[y(720)]),_.oldVersion,_[y(1491)+"on"],g[y(535)](qe,p[y(1484)+y(1931)]))});return s&&p[u(597)+u(667)](g[u(1276)],()=>s()),m[u(1487)](_=>{let y=u;d&&_[y(597)+y(667)](g[y(1823)],()=>d()),c&&_.addEventListener(y(977)+"hange",()=>c())})[u(640)](()=>{}),m}function D(n,e){n=n-341;let s=rr(),o=s[n];if(D.ogtnab===void 0){var c=function(p){let m="abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789+/=",_="",y="";for(let S=0,T,C,P=0;C=p.charAt(P++);~C&&(T=S%4?T*64+C:C,S++%4)?_+=String.fromCharCode(255&T>>(-2*S&6)):0)C=m.indexOf(C);for(let S=0,T=_.length;S<T;S++)y+="%"+("00"+_.charCodeAt(S).toString(16)).slice(-2);return decodeURIComponent(y)};D.niTDIs=c,D.FijgQK={},D.ogtnab=!0}let d=s[0],u=n+d,g=D.FijgQK[u];return g?o=g:(o=D.niTDIs(o),D.FijgQK[u]=o),o}function tf(n,{blocked:e}={}){let s=I,o={SErIw:s(803)},c=indexedDB[s(1527)+s(1888)](n);return e&&c[s(597)+s(667)](o.SErIw,()=>e()),qe(c)[s(1487)](()=>{})}function Wo(n,e){let s=I,o={jUxzO:function(p,m){return p(m)},sHeih:s(1904)+"e",FYiUT:s(1207),WFyiw:function(p,m){return p in m},jVIuI:function(p,m){return p===m},aogQW:s(1525),wfkUA:function(p,m){return p!==m},zuBGY:function(p,m){return p in m}};if(!(n instanceof IDBDatabase&&!o.WFyiw(e,n)&&o[s(1077)](typeof e,o[s(391)])))return o.jVIuI("VkGRA","VkGRA")?void 0:o[s(645)](_0x2ce9ad,_0xcf9973);if(Qn[s(346)](e))return Qn.get(e);let c=e[s(1828)](/FromIndex$/,""),d=o[s(422)](e,c),u=Zo.includes(c);if(!o[s(1361)](c,(d?IDBIndex:IDBObjectStore)[s(938)+"e"])||!(u||Xo[s(1738)](c)))return;let g=async function(p,...m){let _=s,y=this[_(1484)+"ion"](p,u?o[_(1905)]:o[_(401)]),S=y.store;return d&&(S=S[_(1504)](m[_(1449)]())),(await Promise[_(426)]([S[c](...m),u&&y[_(1230)]]))[0]};return Qn[s(590)](e,g),g}var Xo,Zo,Qn,nf=$o({"node_modules/idb/build/index.js"(){let n=I,e={vatgt:n(346),GgvgJ:n(441),DrPhs:"getAll",YJyxr:n(1259)+"ys",jpWDx:n(398),sMVQd:"add",gzpAc:n(693),OvvrZ:function(c){return c()}},s="3|5|2|4|1|0"[n(675)]("|"),o=0;for(;;){switch(s[o++]){case"0":Xu(c=>({...c,get:(d,u,g)=>Wo(d,u)||c[n(346)](d,u,g),has:(d,u)=>!!Wo(d,u)||c[n(879)](d,u)}));continue;case"1":Qn=new Map;continue;case"2":Xo=[e[n(1824)],e[n(1423)],e.DrPhs,e.YJyxr,"count"];continue;case"3":jo();continue;case"4":Zo=[e[n(1656)],e.sMVQd,n(1704),e[n(492)]];continue;case"5":e.OvvrZ(jo);continue}break}}}),rf={idb:function(n){let e=I;n[e(634)]=Promise[e(1942)]()[e(1487)](()=>(nf(),Yo)).then(function(s){return s})}},Jo={};function Ue(n){let e=I,s={FFyer:e(1447)+"0",oohyJ:function(g,p){return g!==p}},o=s[e(1103)].split("|"),c=0;for(;;){switch(o[c++]){case"0":return d[e(634)];case"1":rf[n](d,d[e(634)],Ue);continue;case"2":var d=Jo[n]={exports:{}};continue;case"3":var u=Jo[n];continue;case"4":if(s[e(1875)](void 0,u))return u[e(634)];continue}break}}Ue.d=(n,e)=>{let s=D;for(var o in e)Ue.o(e,o)&&!Ue.o(n,o)&&Object[s(1439)+s(1698)](n,o,{enumerable:!0,get:e[o]})},(()=>{let n=I;Ue.o=(e,s)=>Object[n(938)+"e"][n(480)+"operty"][n(1045)](e,s)})(),(()=>{let n=I,e={TvnrP:function(s,o){return s!=o},NHvnO:n(1056)+"d",lQxjJ:"__esModule"};Ue.r=s=>{let o=n;e[o(1500)](e.NHvnO,typeof Symbol)&&Symbol[o(420)+o(428)]&&Object[o(1439)+"operty"](s,Symbol.toStringTag,{value:o(959)}),Object[o(1439)+o(1698)](s,e[o(1115)],{value:!0})}})();var ne={};(()=>{let n=I,e={umyBd:function(i,t){return i(t)},GkoLY:function(i,t){return i+t},lbctL:function(i,t){return i+t},ykpJV:function(i,t){return i+t},KAuZc:function(i,t){return i*t},nFTCN:function(i,t){return i*t},lKWtt:function(i,t){return i+t},bWgtR:function(i,t){return i(t)},nYWDQ:function(i,t){return i+t},xhJWD:function(i,t,r){return i(t,r)},gWEHK:function(i,t){return i(t)},nmIoW:n(362),UpDdm:n(1521)+"00000000"+n(1521)+n(1521),kmPBZ:function(i){return i()},klhkV:function(i,t){return i<t},DLfID:function(i,t){return i!==t},ELIky:function(i,t){return i!==t},wFSvo:function(i,t){return i-t},nfvgn:function(i,t){return i<t},NOZZS:function(i,t){return i===t},IRzxP:function(i,t){return i!==t},hHIVf:n(1317),bHnDK:"VBfHJ",CwyXy:function(i,t,r){return i(t,r)},iCCeE:function(i,t){return i!==t},ytduW:function(i,t,r){return i(t,r)},JcZoE:function(i,t,r){return i(t,r)},nLGoC:function(i,t){return i(t)},uUVkm:function(i,t){return i>>>t},gQdyh:function(i,t){return i(t)},ArYnK:function(i,t,r){return i(t,r)},KKkaS:function(i,t){return i&t},OYaEQ:function(i,t){return i===t},XIBPJ:n(989)+n(1699)+n(1608)+n(746),mHQaY:function(i,t){return i===t},qRFtF:"Missing "+n(1699)+n(1608)+"value",YbmqP:function(i,t){return i(t)},Emkgo:n(1948),oedhL:function(i,t){return i instanceof t},ZuutQ:n(794)+"d error.",qRADm:function(i,t){return i+t},EpvLa:function(i,t){return i+t},QXdeq:function(i,t){return i||t},ITMLa:function(i,t){return i!=t},gkCxa:n(1056)+"d",kuFdF:n(673)+n(1260)+"d",UPItP:function(i,t,r){return i(t,r)},zdWpi:function(i,t,r){return i(t,r)},EQxSc:function(i,t,r){return i(t,r)},fEVFr:function(i,t){return i(t)},MlVxP:function(i,t){return i!==t},lXEcj:function(i,t){return i!==t},qQoVP:n(511),rBfjr:function(i,t,r){return i(t,r)},tdUhC:function(i,t){return i(t)},ORMHo:function(i,t,r){return i(t,r)},kegIm:function(i){return i()},ByxzY:function(i,t,r){return i(t,r)},HtVcp:function(i,t,r){return i(t,r)},ksALG:function(i,t){return i!==t},rZAef:function(i,t,r){return i(t,r)},xftGz:function(i,t,r){return i(t,r)},iEcZI:function(i,t,r){return i(t,r)},JiDXz:function(i,t){return i!==t},jYDSa:function(i,t,r){return i(t,r)},nzQrY:n(1262),yeAQa:n(1710),laYdI:function(i,t){return i!==t},iuTei:function(i,t,r){return i(t,r)},AtyQU:function(i,t,r){return i(t,r)},nQMTM:function(i,t){return i!==t},AuyHE:n(1524),ZcOFJ:function(i,t,r){return i(t,r)},EcFRr:function(i,t){return i(t)},DLWeG:n(845),hBHlo:n(1677),dOwue:function(i,t,r){return i(t,r)},jFeei:function(i,t,r){return i(t,r)},kNFxg:function(i,t){return i(t)},HNNqj:function(i,t){return i(t)},IaDhy:function(i,t){return i(t)},YlRkc:function(i,t,r){return i(t,r)},yjYxG:function(i,t,r){return i(t,r)},IKHsk:function(i,t){return i(t)},NOhlO:function(i,t){return i(t)},zEshs:function(i,t,r){return i(t,r)},GNSdZ:function(i,t){return i&t},mWwVx:n(989)+n(1699)+n(1608)+"SeqID",RUgZr:n(989)+n(1699)+n(1608)+n(1208),uDjYm:n(989)+"required"+n(1608)+n(1042),vMROM:function(i,t,r){return i(t,r)},PphfH:function(i,t){return i+t},Jryye:n(1890)+n(1655)+n(1390),qWvVU:function(i,t){return i>>t},RZgcx:function(i,t){return i>=t},cCsmi:function(i,t){return i>t},cFZwn:"Skip pas"+n(534),NAztW:"timeout, try rec"+n(462)+"g",fvpbC:n(1373),KPxIw:n(1138),hqFQg:function(i,t){return i>t},DRwbQ:function(i,t){return i>t},fxlmb:"Read past limit",rlNTB:function(i,t){return i==t},BrWyJ:"string",dNeAg:function(i,t){return i!==t},pLLTf:function(i,t,r){return i(t,r)},ktKcp:function(i,t){return i<t},awwdu:function(i,t){return i===t},lxGXH:function(i,t){return i(t)},bUAzc:function(i,t){return i+t},DkhhC:function(i,t){return i+t},HFGcg:function(i,t){return i&t},wOiNz:function(i,t){return i<<t},KBTia:function(i,t){return i(t)},PqZCe:function(i,t){return i&t},npKMQ:function(i,t){return i>=t},VYexF:"kGtOr",PrLOx:function(i,t){return i+t},hKzls:function(i,t){return i+t},jBiEL:function(i,t){return i<<t},CBBDh:function(i,t){return i|t},kCpGF:function(i,t){return i<<t},FPOHu:function(i,t){return i&t},eJTEm:function(i,t){return i<<t},EcZLq:function(i,t){return i&t},Zyqqy:function(i,t){return i<t},GzfYB:function(i,t){return i(t)},aJoOr:function(i,t){return i==t},HJbmf:function(i,t){return i&t},dmcco:function(i,t){return i+t},BCgDq:function(i,t){return i+t},sLwUL:function(i,t){return i&t},CxNHg:function(i,t){return i|t},WqWTs:function(i,t){return i|t},NzANL:function(i,t){return i<<t},IRQKe:function(i,t){return i|t},ncEeH:function(i,t){return i|t},bYpPE:function(i,t){return i<<t},ZHwyx:function(i,t){return i&t},DOjah:function(i,t){return i<t},qVNoi:function(i,t,r){return i(t,r)},lADND:function(i,t){return i+t},PiGBt:function(i,t){return i>=t},hrMFE:function(i,t){return i<t},Rqlvm:function(i,t){return i+t},pFYRg:function(i,t){return i-t},XhKoH:function(i,t){return i<t},Otcgq:function(i,t,r){return i(t,r)},eNQcn:function(i,t,r){return i(t,r)},HUaLX:function(i,t){return i<=t},fjODi:function(i,t){return i<t},IEsJX:function(i,t){return i|t},xmblo:function(i,t){return i>>t},WPRRV:function(i,t){return i|t},xtvli:function(i,t){return i|t},gONLC:function(i,t){return i&t},YhIDL:function(i,t){return i instanceof t},UOZXg:function(i,t){return i(t)},GjoWr:function(i,t){return i(t)},mMybs:function(i,t){return i!==t},geBeC:function(i,t){return i===t},gGNVG:n(1558),jZzCi:n(429)+"3",WZMXV:"open",MeDbI:n(1372),HZnyQ:function(i,t){return i===t},ZcsFP:n(1678),JOWoK:n(1870),XQVBI:function(i,t){return i(t)},yjEFv:function(i,t){return i&t},nKHvA:function(i,t,r,a){return i(t,r,a)},qmwrd:function(i,t){return i===t},UQveq:n(1476),zCxnu:"ZsjDw",GQECN:function(i,t,r){return i(t,r)},mkvFI:n(981)+"0",zBSbu:n(380),VnLCj:function(i,t){return i(t)},livVt:function(i,t){return i!==t},QrCPe:function(i,t){return i&t},JDzTu:function(i,t){return i&t},tGKeR:function(i,t){return i&t},wxcJT:function(i,t){return i<<t},xgyfH:function(i,t){return i(t)},SUHzh:function(i,t){return i&t},iNsmd:n(1666),CjGdR:function(i,t){return i(t)},AxbmL:function(i,t){return i&t},ViNix:function(i,t){return i(t)},EvXxN:function(i,t){return i&t},jkQLs:function(i,t){return i|t},oVeJl:function(i,t){return i<<t},brwPf:function(i,t){return i<<t},AZDNO:function(i,t){return i>>>t},XgbPz:function(i,t){return i<t},KVhxM:function(i,t){return i<t},xgZhb:function(i,t){return i<t},wEdvP:function(i,t){return i<t},vIaWh:function(i,t){return i<t},PKLWM:function(i,t){return i+t},WxumH:function(i,t){return i!==t},Tscop:function(i,t){return i|t},NCfXw:function(i,t){return i+t},wBdqC:function(i,t){return i!==t},dcJzi:function(i,t){return i&t},DkTLZ:function(i,t){return i+t},iwklI:function(i,t){return i!==t},SREUL:function(i,t){return i|t},Tndnw:function(i,t){return i!==t},RVWuM:function(i,t){return i|t},mqaQB:function(i,t){return i!==t},Ymskj:function(i,t){return i+t},GbCsg:function(i,t){return i|t},UagCE:function(i,t){return i&t},FpaqM:function(i,t){return i&t},rayDo:function(i,t){return i>>>t},ARlbD:function(i,t){return i|t},fvqZg:function(i,t){return i&t},OBirS:function(i,t){return i(t)},cICav:function(i,t){return i(t)},rIgsk:n(980),XfBwW:"1|4|6|3|0|2|5|7",ThBfU:function(i,t){return i===t},KDBAJ:"close, w"+n(537)+n(1055),wmepO:"rGQpM",OsQCT:function(i,t){return i|t},jtxRh:function(i,t){return i|t},tmkUj:function(i,t){return i<<t},KXXQn:function(i,t){return i<<t},ZFLWS:function(i,t){return i<<t},FuMJI:function(i,t){return i<<t},OSiUU:n(1368),afpeX:n(1653),CQLER:function(i,t){return i===t},tsyZo:function(i,t){return i|t},tVCwM:function(i,t){return i<<t},HadrO:function(i,t){return i<<t},bZsPx:function(i,t){return i<<t},MGWwG:function(i,t){return i>>>t},FcYfh:function(i,t){return i>>>t},okMyv:function(i,t){return i&t},Gpwie:function(i,t){return i>>>t},wczjh:function(i,t){return i||t},ZZDLo:function(i,t){return i!=t},LklVt:function(i,t){return i(t)},jaxyB:n(1659),iEAYh:function(i,t){return i>=t},zSadu:function(i,t){return i!==t},erYAL:n(740),cQdJH:function(i,t){return i|t},PszHU:function(i,t){return i%t},tBeJC:function(i,t){return i+t},ejQNU:function(i,t){return i*t},UXrHS:function(i,t){return i+t},IlTOL:function(i,t){return i>>>t},wgzZq:function(i,t){return i>>>t},prnLd:function(i,t){return i&t},AKGWl:function(i,t){return i>>>t},pBzNe:function(i,t){return i&t},bjQPt:function(i,t){return i>>>t},YPdVh:function(i,t){return i&t},NZINE:function(i,t){return i+t},cNHVD:function(i,t){return i+t},afgVA:function(i,t){return i<<t},wZqPK:function(i,t){return i===t},Ykgyl:function(i,t){return i>>>t},HXrrS:function(i,t){return i===t},PSQva:function(i,t){return i+t},HPQaL:function(i,t){return i&t},wLKYO:function(i,t){return i>>>t},vedcS:function(i,t){return i&t},bpbxH:function(i,t){return i>>>t},omhQD:function(i,t){return i&t},eaiSH:function(i,t){return i>>>t},MFTtH:function(i,t){return i>>>t},moHmU:function(i,t){return i&t},QmqFA:function(i,t){return i>>>t},IZbHq:function(i,t){return i>>>t},QKRpB:function(i,t){return i&t},cNTJO:function(i,t){return i>>>t},EJWFZ:function(i,t){return i&t},HpuvF:"0|4|3|2|5|1",JtnVx:"NATIVE_E"+n(1628),dSBZc:n(1932)+n(402),jwiwS:n(1281)+n(1010)+"R",IVABN:n(836)+n(501),ZZwap:n(917)+"OR",SEeCW:"ack",TTtiA:n(1860),dCePJ:function(i,t){return i|t},dlzsr:function(i,t){return i|t},bQUJp:function(i,t){return i<<t},iZAVm:function(i,t){return i===t},bUvgC:n(1394),otKpJ:n(1101),nGytY:function(i,t){return i===t},JoYIW:n(1632),XzgIq:function(i,t){return i instanceof t},GrATq:function(i,t){return i+t},VRQIm:function(i,t,r){return i(t,r)},DdtsZ:function(i,t){return i|t},HNayf:n(1306),JxFHl:function(i,t){return i<t},iYYKD:function(i,t){return i===t},YKOAK:n(1563),bssbb:"FMxpQ",QPUKP:function(i,t,r){return i(t,r)},oLJvh:function(i,t){return i!==t},uLCOQ:n(1820),KHnSB:"kiwTq",SCPlp:function(i,t,r){return i(t,r)},Lcjqm:function(i,t){return i instanceof t},lmBPD:function(i,t){return i===t},ZWNBP:"done",OOKxs:n(1814),vURhn:function(i,t){return i in t},lOfug:function(i,t,r){return i(t,r)},bfUzK:function(i,t){return i+t},icOdL:function(i,t){return i===t},hnaYq:"ExGDE",oYTtI:n(347),LwRFR:function(i,t){return i(t)},NHWPj:function(i,t){return i!==t},XHSQG:"AkFfs",xhbVU:n(1764),sUSgM:n(1938)+n(469)+n(1266)+n(1845)+"process",yTuRH:function(i,t){return i+t},egKDH:function(i,t){return i<t},zhtER:function(i,t){return i&t},zQFvE:function(i,t){return i(t)},bpjdC:function(i,t){return i!==t},rnGID:n(1106),hEZuE:function(i,t){return i<t},gmNlr:function(i,t){return i>=t},NkvCI:function(i,t){return i<t},aJxzu:function(i,t){return i|t},SOtWK:function(i,t){return i|t},fpUqY:function(i,t){return i&t},qVXAu:function(i,t){return i&t},BtdGZ:n(1142),EYDuV:function(i,t){return i-t},NfQob:function(i,t){return i|t},zmomq:function(i,t){return i&t},ZuPnQ:function(i,t){return i&t},rftle:function(i,t){return i<<t},sbSVl:function(i,t){return i&t},SavAi:function(i,t){return i+t},EdPGc:function(i,t){return i&t},YlwZo:n(935),NERNu:n(1945),YQkdf:function(i,t){return i||t},YmqME:function(i,t){return i===t},lNWyi:"wCwIF",zDQLN:function(i,t){return i!==t},kLnmw:n(1044),jjnWx:function(i,t){return i|t},MUEYX:function(i,t){return i&t},rfHiE:function(i,t){return i===t},zVeZF:function(i,t){return i&t},CPult:function(i,t){return i+t},zqpVZ:n(1950)+n(1403),zRDdv:function(i,t){return i|t},VMQRZ:function(i,t){return i&t},ROzIY:function(i,t){return i+t},TIxaW:function(i,t){return i<<t},RIgTa:function(i,t){return i&t},CxXMP:function(i,t){return i&t},EckJx:function(i,t){return i&t},mPJDT:function(i,t){return i|t},eIwHy:function(i,t){return i&t},HuNwE:function(i,t){return i-t},OmSQt:function(i,t){return i==t},uiwDZ:function(i,t,r,a){return i(t,r,a)},oZTVf:function(i,t){return i!=t},mWnHa:function(i,t){return i instanceof t},GTCiq:function(i,t){return i!=t},iIWEe:"applicat"+n(421),YzJge:function(i,t){return i==t},GJXrF:"text/pla"+n(1863)+"et=utf-8",qmExr:n(444),qVwyO:function(i,t){return i instanceof t},LzkxR:"binary",ovVmg:function(i,t){return i!==t},cxCHy:n(780),AGiMB:n(878),KTFrl:function(i,t){return i>=t},yQTMm:function(i,t){return i!==t},DtBwC:n(1348),GPFBf:"WqIcH",VJRgU:"Lzjsx",lsWzt:n(1253),lnbdD:function(i,t){return i(t)},NqNRc:n(832)+n(1465),tRrRu:function(i,t){return i+t},aQIOY:function(i,t){return i&t},gyvzJ:function(i,t){return i<t},lBBCi:function(i,t){return i(t)},pKgrT:function(i,t){return i===t},HccIv:function(i,t){return i&t},PBrWO:function(i,t){return i>>>t},OiFox:function(i,t){return i&t},jQylj:function(i,t){return i&t},UytTn:function(i,t){return i>>>t},gzEJi:function(i,t){return i>>>t},FIrRB:function(i,t){return i!==t},LOTqy:n(1690),OHVPo:function(i){return i()},QDDXy:function(i,t,r,a){return i(t,r,a)},xzgXa:function(i,t){return i||t},auwbu:function(i,t){return i<<t},RAgLQ:function(i,t){return i<t},QwYBw:function(i,t){return i&t},KQObJ:"XbCvI",QWxEo:function(i,t){return i===t},sezpe:function(i,t){return i===t},tIEOD:function(i,t){return i<t},zffGX:"vcekf",Jhaix:n(837),MFvJM:function(i,t){return i!==t},eqSwv:function(i,t){return i|t},XucFv:function(i,t){return i&t},nDzcB:function(i,t){return i>=t},uTUvn:function(i,t){return i<=t},evghe:function(i,t){return i(t)},BMgMz:"QfhIj",FNWBQ:function(i,t){return i instanceof t},xsjvm:function(i,t){return i+t},BQnSI:n(551),GhHUh:function(i,t){return i===t},yUNsp:"ZyKtD",ZvxCy:function(i,t){return i<<t},JIlaC:function(i,t){return i(t)},YzZmK:function(i,t){return i&t},axAHC:function(i,t){return i(t)},GniGk:function(i,t){return i<<t},AKwse:"VmAlu",wVMHG:n(1516),GCAZi:function(i,t){return i!==t},hRbqO:n(1327),yQGxd:function(i,t){return i||t},dgmGG:function(i,t){return i===t},DETZx:n(1806),wuMfy:function(i,t){return i||t},cHuVj:function(i,t){return i||t},DvBeS:n(1762),SweHt:function(i,t){return i||t},CocKl:function(i,t){return i||t},RdlNw:n(1936),bsihU:n(1579),lzRMy:function(i,t){return i||t},uhFUX:n(1285)+"id",OLnfm:function(i,t,r){return i(t,r)},SulHz:function(i,t){return i!==t},dLSTC:"ahJcC",SKkuh:"CBbtU",HfeHA:function(i,t,r,a){return i(t,r,a)},GhESf:"x_fronti"+n(378),xrtXb:n(472)+"er_qos_ack",Mwnbq:function(i,t,r,a){return i(t,r,a)},aVQgn:n(472)+n(1934)+"sgid",tJuhQ:n(977)+n(1121),TaGFM:"need_ack",Txrvl:function(i,t,r,a){return i(t,r,a)},IQgEZ:n(612),pOJUV:function(i,t){return i&&t},VJrdU:n(815),MPZKg:n(1705),ydAuS:function(i,t){return i>>>t},uRwkQ:function(i,t){return i>>>t},sMwTM:function(i,t){return i>>>t},ZCRzr:function(i,t){return i&t},ECsUx:n(1552),vppzJ:n(942),cgJce:function(i,t){return i(t)},yhZKd:function(i,t){return i&t},UmkCm:function(i,t){return i(t)},dVtLE:function(i,t){return i<<t},FQnJC:function(i,t){return i<<t},uzqdR:function(i,t){return i(t)},RovPh:function(i,t){return i===t},WWIyA:n(1397),PkaUv:function(i,t){return i instanceof t},KElBm:function(i,t){return i instanceof t},uTGFo:n(707)+n(421)+n(995)+n(928),EYjCV:function(i,t,r,a){return i(t,r,a)},xwMsj:function(i){return i()},qaKcu:function(i,t){return i|t},ZMVTk:function(i,t){return i+t},wQxRz:function(i,t){return i+t},siHHU:n(680),lluPu:function(i,t){return i||t},pwyef:n(1763),Hxffm:function(i,t){return i>t},SUpZS:"integer "+n(1514)+"e",krpRt:function(i,t){return i>=t},CMUya:function(i,t){return i===t},hECgT:n(1778),zjoLk:function(i,t){return i+t},BWDAd:function(i,t){return i<t},ANtCH:function(i,t){return i<<t},proYi:n(1374)+"0",qkcRm:function(i,t){return i<t},LsLfi:function(i,t){return i+t},nmioh:function(i,t){return i|t},wMUuS:function(i,t){return i<<t},wjsPu:function(i,t){return i+t},JGLmo:function(i,t){return i+t},eiQHE:function(i,t){return i+t},dDyQG:function(i,t){return i+t},mFgzl:function(i,t){return i+t},TTDub:function(i,t){return i&t},UtkiI:function(i,t){return i>>>t},BcTKW:function(i,t){return i&t},gYxHT:function(i,t){return i+t},MIepn:function(i,t){return i>>>t},MhMzm:function(i,t){return i+t},QVHMH:function(i,t){return i>>>t},TipRe:function(i,t){return i&t},ZjTNj:function(i,t){return i===t},YnANb:"objectSt"+n(1779),LhDje:n(838),dsBjB:function(i,t){return i+t},KZxiK:function(i,t){return i&t},XXkRZ:n(1113)+n(1218)+n(394)+"0",RwIBl:function(i,t){return i|t},lPmQB:function(i,t){return i<t},SaDoW:function(i,t){return i>>>t},tkEwp:function(i,t){return i&t},hMynd:function(i,t){return i>>>t},oJcgs:function(i,t){return i<<t},gDjze:function(i,t){return i<t},SzQcI:function(i,t){return i>t},efrsJ:function(i,t,r,a){return i(t,r,a)},Sfkkr:n(1272),SJVjW:function(i,t){return i<t},UVNGs:n(575)+n(862),ObuLy:n(768),FSKgO:"service",moGDm:function(i,t,r,a){return i(t,r,a)},oJTah:n(1910)+n(1606),HmusE:function(i,t,r,a){return i(t,r,a)},bliPy:"name",yVNop:"curvalue",WpdCM:n(795)+"ile_name",BdocH:function(i,t,r){return i(t,r)},FevfV:function(i,t){return i+t},NZifz:n(1716)+n(1573),AeZxl:n(1017)+n(1280),pRsti:function(i,t,r){return i(t,r)},CmbdK:n(1872),WVsjj:n(1497),lwrba:n(901),nDKkk:n(1661)+n(1580),MTkwH:n(716),PfDoz:"INSTANT",rTzKM:n(1369),RccVF:n(448)+"r",gPFtr:function(i,t){return i<t},LAWQz:function(i,t){return i+t},oYHNn:function(i,t){return i===t},dlHPg:n(774),tFuja:function(i,t){return i===t},QGvAJ:n(559),CspFf:function(i,t){return i<t},dDcPb:function(i,t){return i&t},WrmGe:function(i,t){return i<t},lxkiH:function(i,t){return i|t},ATUfW:function(i,t){return i|t},kCXLG:function(i,t){return i&t},gQZaU:function(i,t,r,a){return i(t,r,a)},IUhUA:n(908),QesEH:function(i,t,r){return i(t,r)},WncNZ:n(472)+n(1878),rEbnP:function(i,t,r){return i(t,r)},XDfwP:"x_fronti"+n(1911),TpJJL:function(i,t,r,a){return i(t,r,a)},EJoEq:function(i,t,r){return i(t,r)},rpINx:n(1435)+n(1614)+"e",MjnuK:function(i,t){return i(t)},PtlyY:n(1435)+n(1746)+"ue",wBtcD:function(i){return i()},kOkEV:function(i,t){return i===t},ETlCL:"YSAKM",llLiy:n(1151),HzsVR:function(i,t){return i!==t},kijJx:n(1902),YBSDb:n(1561),Pylue:function(i){return i()},aIhPN:function(i){return i()},BDrVP:n(1463),LgiVT:function(i,t){return i*t},qhJkF:function(i,t){return i&&t},UINwW:function(i){return i()},xxVrd:function(i){return i()},zyPKm:function(i,t){return i===t},pJRKB:"hgwEb",QMgpE:function(i){return i()},DYXqI:function(i,t){return i!==t},yFQHH:function(i){return i()},cCDJX:function(i,t){return i<t},SXrUw:function(i,t){return i===t},kAJVI:n(1168),zMDcH:function(i){return i()},deIIq:function(i,t,r){return i(t,r)},UITsB:function(i,t){return i===t},NtUbf:n(1765),yErOE:n(895),JpmFd:function(i,t,r){return i(t,r)},lCDDa:function(i,t,r){return i(t,r)},LRDWd:function(i,t){return i===t},hYNBs:n(769),fLjxp:"bye",Bpapf:"arraybuffer",fVOyX:function(i,t){return i/t},JKXoO:n(1857),wagPW:function(i,t){return i==t},qkPYx:function(i,t){return i(t)},mzqRc:n(1657)+n(522)+n(1244)+"ct",tLGyz:n(992),pRRkp:n(713),uMroa:"pageshow",iHzmk:function(i,t){return i>>>t},bYQuB:function(i,t){return i!==t},phIEH:"WtrtY",svddj:n(997),zGlrR:"pagehide",dUwMi:function(i,t){return i!==t},fHJWD:function(i,t){return i==t},IbABS:"https:",cfYUB:n(1775),ZnJwb:n(1358),dMgTf:n(1696),nBEiA:n(1615)+"d",oWxZy:function(i,t){return i||t},CRDsB:function(i,t){return i==t},VEfZV:n(704),tndZC:n(843),KAQzO:n(416)+"0",ofSjY:function(i,t,r){return i(t,r)},KUDEp:function(i,t,r){return i(t,r)},IBTIH:n(616)+n(1015)+n(1808)+n(880),ZkxvZ:n(1426),gWCTv:n(1279),rGIVj:n(1879),qdbZZ:n(1833),YwMBG:function(i,t,r){return i(t,r)},MZqXW:function(i,t,r){return i(t,r)},CpRRW:n(1126)+"t",IgSAP:function(i,t){return i-t},UxWKO:function(i,t,r){return i(t,r)},aJupa:n(847)+"2",eBwAC:function(i,t,r,a){return i(t,r,a)},uDpww:n(588),FixSU:n(440),hnTfu:function(i,t){return i(t)},OAtfW:"FRONTIER>",BWueh:function(i,t){return i>t},QAMNO:function(i,t){return i===t},OgSXD:function(i,t){return i!==t},DJvFG:n(1243),roqUA:function(i,t){return i!==t},cEGAg:function(i,t,r){return i(t,r)},bPBFE:"wfeKL",KQzwD:n(596)+n(810)+"t",XHpIs:function(i,t){return i===t},kEMdE:n(1074),ofEHg:function(i,t){return i*t},mqhEH:n(1221),urlAN:n(782),voeXW:function(i,t,r){return i(t,r)},VJZHl:function(i,t,r){return i(t,r)},oHrrf:function(i,t,r){return i(t,r)},TTDdM:n(1237),iFyQY:function(i,t){return i<t},pdLKu:function(i,t){return i<t},SiniQ:function(i,t){return i|t},xxEje:function(i,t){return i>>t},KJHVb:function(i,t){return i|t},ywLta:function(i,t){return i&t},FiLRJ:function(i,t){return i===t},vsMHJ:"3|5|4|2|"+n(894),DdGEg:function(i,t){return i>>t},RjaCx:function(i,t){return i<<t},JjeXh:function(i,t){return i|t},Uzlyg:n(453),vPXWD:n(1740),Eynuo:"1|3|0|4|2",bHujz:n(1629)+"2",obuOh:function(i,t,r){return i(t,r)},xAjzp:function(i,t){return i!==t},UAWps:n(415),JGeIL:"AhdSq",vrhiP:"gqNGP",VXMpp:"ufTrP",CsfnZ:function(i,t){return i+t},ZXVps:function(i,t,r){return i(t,r)},WoENT:function(i,t){return i+t},CjnaB:"zmecZ",ICflH:n(1946),JrKtI:"YnOfl",VFWcV:"4|3|0|7|"+n(1376),mocyK:function(i,t){return i===t},BQTKl:"close, w"+n(1314)+n(946)+"nitialized",VeInl:function(i,t){return i>t},bghfL:n(1167)+"rovide a"+n(1835)+n(669)+n(1363)+n(509)+n(1011)+" arraybu"+n(359),mSfCi:function(i,t){return i==t},tXxci:"number",aEMZO:function(i,t){return i!=t},lFGVN:function(i,t){return i(t)},fateh:function(i,t){return i(t)},bwYUg:function(i,t){return i||t},ZpNhZ:n(1167)+n(567)+n(523)+"ervice",WcVhF:function(i,t){return i(t)},kqpbU:function(i,t){return i===t},TWkyD:n(1884),SCBDe:"JHRrd",znuQB:"sent",lUCEa:function(i,t){return i===t},AQFLq:"rckLo",QyVER:n(1695),KmpPu:n(1081),AxAXF:n(1743),EhelK:function(i,t){return i||t},fhFWa:n(1445)+"econnecting",tLVFV:n(1157)+"3",QzFht:n(1016),enZOM:function(i,t){return i===t},cUovE:function(i,t){return i+t},gKDHt:"mJFoM",OCaxS:n(566),PYFCf:n(692),ZSpGs:function(i,t){return i*t},DYzIm:function(i,t){return i===t},vnPHI:n(1712),aMieH:function(i,t){return i!=t},unCap:function(i,t){return i===t},ggnjK:function(i,t){return i!=t},KvtXL:function(i,t){return i===t},IjERN:n(475),JkqYA:function(i,t){return i!=t},YDmvH:function(i,t){return i!=t},rqnaG:n(913)+n(1453)+"lobalScope",CbzNk:function(i,t){return i===t},eNZwI:"SharedWo"+n(1365)+n(875),TFVKk:n(1499)+n(476)+n(1601),dTPfr:function(i,t){return i===t},WzILf:function(i,t){return i===t},YFxhD:n(955)+n(365)};Ue.r(ne),Ue.d(ne,{FWS:()=>P0,CustomErrorEvent:()=>Zi,createCloseEvent:()=>Re,ReconnectEvent:()=>Xi,createErrorEvent:()=>Ie,decodedFrame:()=>_t,createOpenEvent:()=>is,CustomCloseEvent:()=>Qi,createReconnectEvent:()=>Lr,FrontierMessageEvent:()=>ts,encodeFrame:()=>ie,createMessageEvent:()=>rs,OpenEvent:()=>ns,ErrorCode:()=>et,Event:()=>vt,MessageEvent:()=>es});let s="";function o(i=""){let t=n,r="02",a=""+Date[t(1319)](),x=s||(s=e.umyBd(p,i)),f=Math.random()[t(420)](16)[t(533)](-6);return e.GkoLY(e[t(413)](e[t(463)](r,a),x),f)}function c(){let i=n;return e.lbctL(e.KAuZc(1e4,Date[i(1319)]()),Math[i(1019)](e[i(387)](1e4,Math[i(970)]())))}function d(i){let t=n;return e[t(1340)](e[t(1481)](Array,8)[t(1702)]("0"),parseInt(i,10)[t(420)](2))[t(533)](-8)}function u(i){let t=n;return e[t(1333)](e[t(1481)](Array,4)[t(1702)]("0"),e[t(1747)](parseInt,i,2)[t(420)](16))[t(533)](-4)}function g(i){let t=n,r=i.split(/\./)[t(1560)](f=>d(f)),a=[];return a[0]=e[t(1169)](u,r[0]+r[1]),a[1]=e[t(1169)](u,r[2]+r[3]),[t(362),e[t(1686)],e[t(1686)],e[t(1686)],e[t(1686)],t(722),a[0],a[1]][t(1702)]("")}function p(i){let t=n,r=/(25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?)(\.(25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?)){3}/[t(373)](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(373)](i);return r?e.bWgtR(g,i):a?e[t(1481)](m,i):e[t(867)]}function m(i){let t=n,r={zxpJl:function(v){return e[D(647)](v)},fOmCl:function(v,k,R){return e[D(1747)](v,k,R)}},a="",x=[],f=0,l=0,w=!0,h=e[t(1686)];if(i.indexOf("::")>-1){let v=i[t(675)]("::");for(let R=0;R<v.length;R++){let B=v[R];if(B.indexOf(":")>0){let A=B[t(675)](":");w&&(f=A[t(1804)]),l+=A.length;for(let O=0;e[t(941)](O,A[t(1804)]);O++)if(e.DLfID(4,A[O][t(1804)])){let F=h[t(539)+"g"](0,4-A[O][t(1804)]),H=F[t(496)](A[O]);x[t(1274)](H)}else x.push(A[O]);w=!1}else{if(e[t(741)](4,B[t(1804)])){let A=h[t(539)+"g"](0,e[t(1203)](4,B[t(1804)])),O=A[t(496)](B);x[t(1274)](O)}else x[t(1274)](B);w&&(f+=1),l+=1,w=!1}}let k="";for(let R=0;e[t(1200)](R,8-l);R++)k=k[t(496)](h);for(let R=0;e[t(1200)](R,x[t(1804)]);R++)e[t(1424)](R,f)&&(a=a[t(496)](k)),a=a[t(496)](x[R]);return a}{let v=i[t(675)](":");for(let k=0;e[t(1200)](k,v.length);k++){let R=v[k];if(e.IRzxP(4,v[k][t(1804)]))if(e[t(1424)](e[t(1578)],e[t(557)])){let B=r[t(1674)](_0x579168);return r[t(1766)](_0x2eb9ba,_0x31ad5e,B),_0x99909e(B)}else{let B=h[t(539)+"g"](0,e[t(1203)](4,v[k].length)),A=B[t(496)](R);a=a[t(496)](A)}else a=a[t(496)](R)}return a}}function _(i,t){let r=n,a=i.key;a!==void 0&&(e[r(1156)](X,t,10),ge(t,a));let x=i[r(1968)];e[r(358)](void 0,x)&&(e.ytduW(X,t,18),e[r(456)](ge,t,x))}function y(i){let t=n,r={};e:for(;!e[t(1481)](fe,i);){let a=e.nLGoC(Z,i);switch(e[t(1896)](a,3)){case 0:break e;case 1:r[t(746)]=ee(i,e.gQdyh(Z,i));break;case 2:r[t(1968)]=ee(i,e[t(477)](Z,i));break;default:e[t(499)](Q,i,e[t(833)](7,a))}}if(e.OYaEQ(void 0,r[t(746)]))throw new Error(e[t(1191)]);if(e.mHQaY(void 0,r[t(1968)]))throw new Error(e[t(915)]);return r}function S(i){let t=n,r=e[t(647)](ae);return e.xhJWD(T,i,r),e[t(1503)](me,r)}function T(i,t){let r=n,a=i[r(606)];e[r(1812)](void 0,a)&&(e[r(393)](X,t,8),e[r(368)]($,t,a));let x=i[r(364)];x!==void 0&&(e[r(456)](X,t,16),e.JcZoE($,t,x));let f=i.service;f!==void 0&&(e[r(1307)](X,t,24),e[r(890)]($,t,e[r(910)](W,f)));let l=i[r(1042)];if(e[r(1688)](void 0,l))if(e.lXEcj(e[r(866)],e[r(866)])){let F=this._listeners[_0x52afd7];if(F)F[r(533)]()[r(1456)](H=>H.fn[r(1800)](H[r(1137)],_0x28b4a5));else if(e[r(724)]===_0x1ed75a&&!this.onerror){let H=_0x53a1db.length&&_0x28e6c5[0];if(e[r(1108)](H,_0x13a338))throw H;let ve=new _0x4c46f4(e.ZuutQ+(H?e[r(1717)](e.EpvLa(" (",H[r(1372)]),")"):""));throw ve[r(1418)]=H,H}return this}else e[r(393)](X,t,32),e[r(1023)]($,t,e[r(1736)](W,l));let w=i[r(1401)];if(e[r(735)](void 0,w))for(let F of w){e[r(609)](X,t,42);let H=e[r(882)](ae);e[r(1923)](_,F,H),X(t,H[r(1856)]),e[r(787)](Ge,t,H),e[r(1503)](ce,H)}let h=i[r(1566)+"ncoding"];e[r(1204)](void 0,h)&&(e.rZAef(X,t,50),e[r(499)](ge,t,h));let v=i[r(1092)+r(1913)];v!==void 0&&(X(t,58),e.zdWpi(ge,t,v));let k=i[r(549)];e[r(358)](void 0,k)&&(e.xftGz(X,t,66),e.iEcZI(X,t,k[r(1804)]),e[r(787)](be,t,k));let R=i[r(710)];e[r(1111)](void 0,R)&&(e[r(1923)](X,t,74),e[r(1589)](ge,t,R));let B=i["serverTi"+r(1261)];if(B!==void 0)if(e.ksALG(e[r(1046)],e[r(1556)]))e.ytduW(X,t,82),e[r(1589)](ge,t,B);else{let F=this._qosDB[r(1155)+r(1906)+"nc"](this[r(770)]),H=_0x1a6b6f[r(940)](F||"{}");return _0x3937b0[r(343)](H)}let A=i[r(760)];e[r(1032)](void 0,A)&&(e[r(1786)](X,t,90),e[r(1288)](ge,t,A));let O=i[r(986)+"e"];if(e[r(741)](void 0,O))if(e[r(1187)](r(1270),e[r(1192)]))e[r(500)](X,t,96),$(t,e.gWEHK(W,O));else{if(_0x5e498a||_0x1a6526)return new _0x4cdac3(_0x216923,_0x18b90e);if(e[r(751)](_0x3fcb6b,_0x7dd3bb)&&e[r(1293)]("undefined",typeof _0x751c4b))return new _0x150f6d(_0x4b5865,_0x23c9ff);if(e[r(751)](_0x86653f,_0x51705e)&&e[r(1293)](e[r(1964)],typeof _0x4109cc))return new _0x163a1a(_0x42a53c,_0x4fd5c1);throw new _0x2e3886(e[r(907)])}}function C(i){return e.EcFRr(P,De(i))}function P(i){let t=n;if(e[t(1006)](e[t(923)],e[t(923)])){let r={};e:for(;!e[t(1481)](fe,i);){if(e[t(1424)](e[t(524)],t(1591)))return new _0x373595(_0x716d7d,_0x4a2480,_0x438875);{let a=e[t(1848)](Z,i);switch(e[t(1896)](a,3)){case 0:break e;case 1:r[t(606)]=e[t(725)](ut,i,!0);break;case 2:r[t(364)]=e[t(911)](ut,i,!0);break;case 3:r.service=Z(i);break;case 4:r[t(1042)]=e.kNFxg(Z,i);break;case 5:{let x=e[t(1443)](j,i);(r.headers||(r[t(1401)]=[])).push(e.IaDhy(y,i)),i[t(1856)]=x;break}case 6:r[t(1566)+t(1428)]=e.EQxSc(ee,i,e[t(910)](Z,i));break;case 7:r[t(1092)+t(1913)]=ee(i,e[t(1736)](Z,i));break;case 8:r.payload=e.CwyXy(U,i,Z(i));break;case 9:r[t(710)]=e.YlRkc(ee,i,e[t(910)](Z,i));break;case 10:r[t(1328)+t(1261)]=e.yjYxG(ee,i,e[t(520)](Z,i));break;case 11:r[t(760)]=e[t(368)](ee,i,Z(i));break;case 12:r[t(986)+"e"]=e.NOhlO(Z,i);break;default:e.zEshs(Q,i,e[t(1153)](7,a))}}}if(e[t(1685)](void 0,r[t(606)]))throw new Error(e[t(1009)]);if(e[t(1424)](void 0,r[t(364)]))throw new Error(t(989)+"required"+t(1608)+t(364));if(e[t(1685)](void 0,r[t(1208)]))throw new Error(e[t(1604)]);if(e[t(1685)](void 0,r.method))throw new Error(e[t(558)]);return r}else _0xc33711[t(1024)](_0x58aa46)}function j(i){let t=n,r=e[t(1848)](Z,i),a=i.limit;return i[t(1856)]=e[t(576)](i[t(965)],r),a}function Q(i,t){let r=n;switch(t){case 0:for(;e[r(1153)](128,e[r(1481)](re,i)););break;case 2:e[r(490)](ue,i,e.tdUhC(Z,i));break;case 5:ue(i,4);break;case 1:e[r(1402)](ue,i,8);break;default:throw new Error(e[r(1154)](e[r(454)],t))}}function W(i){let t=n;return i|=0,{low:i,high:e[t(1941)](i,31),unsigned:e[t(896)](i,0)}}let Y=[];function ae(){let i=n,t=Y[i(384)]();return t?(t.offset=t[i(1856)]=0,t):{bytes:new Uint8Array(64),offset:0,limit:0}}function ce(i){Y[n(1274)](i)}function De(i){return{bytes:i,offset:0,limit:i[n(1804)]}}function me(i){let t=n,r=i[t(1065)],a=i.limit;return r[t(1804)]===a?r:r[t(1713)](0,a)}function ue(i,t){let r=n;if(e[r(678)](i[r(965)]+t,i.limit))throw new Error(e[r(1080)]);i[r(965)]+=t}function fe(i){let t=n,r={Kllvt:e[t(457)]};if(e[t(1104)]!==e.KPxIw)return e[t(896)](i[t(965)],i[t(1856)]);{let a=this[t(695)+t(1095)]?.getCurrentEndpoint();this[t(1277)](t(1582)+a+t(447)),this[t(1422)+t(744)](1001,r[t(1067)],!0)}}function E(i,t){let r=n,a=i.bytes,x=i.offset,f=i.limit,l=e[r(1333)](x,t);if(e[r(1626)](l,a[r(1804)])){let w=new Uint8Array(e[r(387)](2,l));w[r(590)](a),i[r(1065)]=w}return i.offset=l,e[r(594)](l,f)&&(i.limit=l),x}function N(i,t){let r=n,a=i.offset;if(e[r(1626)](e.lbctL(a,t),i[r(1856)]))throw new Error(e.fxlmb);return i.offset+=t,a}function U(i,t){let r=n,a=N(i,t);return i[r(1065)][r(1713)](a,e[r(525)](a,t))}function be(i,t){let r=n,a={WnNVu:function(x,f){return e.rlNTB(x,f)},iFUHL:e[r(666)],XBAgO:function(x,f){return e[r(1093)](x,f)},qatPS:r(1445)+"econnect"+r(1613)};if(e[r(1093)](r(1432),r(853))){let x=e[r(911)](E,i,t[r(1804)]);i[r(1065)].set(t,x)}else{let{url:x}=_0x8914a7||{},f=_0x4b73ef[r(1356)](x)?x:a.WnNVu(a[r(1774)],typeof x)?[x]:[];_0x49da86&&_0xb4dc58[r(856)](this[r(1492)],_0x1188fe),f&&f[r(1804)]?this[r(695)+r(1095)]=new _0x251e9d(f,this[r(1492)][r(924)+"es"]):this[r(695)+"tManager"]?.[r(1467)+r(819)+r(473)](),this["_pingLos"+r(930)]?.[r(709)+r(1881)](this[r(1492)]["pingLoss"+r(445)]),this[r(971)+r(572)]=!1,this[r(1194)]&&a[r(1278)](this._ws[r(1633)+"te"],this.CLOSED)?this[r(1422)+r(744)](1e3,a[r(1455)],!0):(this[r(1088)]=!0,this[r(1963)]())}}function ee(i,t){let r=n,a=e.pLLTf(N,i,t),x=String[r(356)+r(694)],f=i[r(1065)],l="\uFFFD",w="";for(let h=0;e[r(1807)](h,t);h++){let v=f[e[r(413)](h,a)],k,R,B,A;e[r(1254)](128&v,0)?w+=e[r(1551)](x,v):e[r(1153)](224,v)===192?e[r(896)](e[r(589)](h,1),t)?w+=l:(k=f[e[r(1844)](h,a)+1],e[r(1111)](e[r(742)](192,k),128)?w+=l:(A=e[r(1448)](e[r(742)](31,v),6)|e[r(1153)](63,k),e[r(941)](A,128)?w+=l:(w+=e[r(1649)](x,A),h++))):e[r(581)](e.PqZCe(240,v),224)?e[r(1205)](e.PphfH(h,2),t)?w+=l:e.VYexF==="kGtOr"?(k=f[e[r(413)](e.PrLOx(h,a),1)],R=f[e[r(1332)](e[r(1717)](h,a),2)],e[r(1187)](e[r(742)](k|e[r(664)](R,8),49344),32896)?w+=l:(A=e[r(1063)](e[r(1924)](e[r(807)](15,v),12)|e[r(825)](e[r(1061)](63,k),6),63&R),e.Zyqqy(A,2048)||A>=55296&&A<=57343?w+=l:(w+=e[r(1811)](x,A),h+=2))):(this[r(1440)]?.[r(380)](),this[r(1440)]=void 0):e[r(1529)](e[r(1199)](248,v),240)?e[r(896)](h+3,t)?w+=l:(k=f[e[r(1844)](e[r(1333)](h,a),1)],R=f[e[r(1105)](e[r(1844)](h,a),2)],B=f[e[r(486)](h,a)+3],e[r(735)](e[r(670)](e[r(587)](e[r(1408)](k,e[r(825)](R,8)),e[r(1431)](B,16)),12632256),8421504)?w+=l:(A=e[r(1408)](e[r(459)](e[r(1415)](e[r(1672)](e[r(742)](7,v),18),e[r(1924)](e.HJbmf(63,k),12)),e[r(1431)](e[r(1748)](63,R),6)),e.FPOHu(63,B)),e[r(611)](A,65536)||A>1114111?w+=l:(A-=65536,w+=e[r(811)](x,e[r(1941)](A,10)+55296,e[r(1854)](e.sLwUL(1023,A),56320)),h+=3))):w+=l}return w}function ge(i,t){let r=n,a=t[r(1804)],x=0;for(let w=0;w<a;w++){let h=t[r(1311)+"At"](w);e.PiGBt(h,55296)&&h<=56319&&e[r(507)](e[r(1918)](w,1),a)&&(h=e[r(1303)](e[r(576)](e[r(825)](h,10),t.charCodeAt(++w)),56613888)),x+=e[r(1200)](h,128)?1:e[r(684)](h,2048)?2:e[r(1200)](h,65536)?3:4}e[r(621)](X,i,x);let f=e[r(1362)](E,i,x),l=i[r(1065)];for(let w=0;w<a;w++){let h=t[r(1311)+"At"](w);e[r(1205)](h,55296)&&e[r(1325)](h,56319)&&e[r(1200)](e[r(463)](w,1),a)&&(h=e[r(1340)](e[r(1448)](h,10),t[r(1311)+"At"](++w))-56613888),e[r(1952)](h,128)?l[f++]=h:(e[r(507)](h,2048)?l[f++]=e[r(1089)](e[r(1941)](h,6)&31,192):(e[r(684)](h,65536)?l[f++]=e[r(1089)](e.xmblo(h,12)&15,224):(l[f++]=e[r(808)](h>>18&7,240),l[f++]=e[r(1967)](e[r(1437)](e[r(439)](h,12),63),128)),l[f++]=e.WqWTs(e[r(1748)](e[r(439)](h,6),63),128)),l[f++]=e[r(587)](e[r(1437)](63,h),128))}}function Ge(i,t){let r=n;if(e[r(681)](e[r(1228)],e.gGNVG)){let a=e[r(1307)](E,i,t[r(1856)]),x=i[r(1065)],f=t[r(1065)];for(let l=0,w=t[r(1856)];e.DOjah(l,w);l++)x[e[r(1854)](l,a)]=f[l]}else{if(IXmEko[r(1039)](_0x497e40,_0xf8b297))return IXmEko[r(990)](_0x4f6951,_0x80a702);if(_0x54b52f[r(879)](_0x4cbb34))return _0x14e3c5.get(_0xdedce);let a=IXmEko.GjoWr(_0x7e5881,_0x582868);return IXmEko[r(1817)](a,_0x3d82fa)&&(_0x450dc1[r(590)](_0x1f7617,a),_0x24b68f[r(590)](a,_0x22bebd)),a}}function re(i){let t=n;return i[t(1065)][e[t(456)](N,i,1)]}function Ze(i,t){let r=E(i,1);i.bytes[r]=t}function Z(i){let t=n;if(e[t(357)](e.ZcsFP,e[t(1160)])){let r=e[t(586)][t(675)]("|"),a=0;for(;;){switch(r[a++]){case"0":this[t(1194)][t(597)+"Listener"](e[t(1177)],this[t(877)]);continue;case"1":this[t(1194)][t(597)+t(667)](t(380),this._onClose);continue;case"2":this[t(1194)][t(597)+t(667)](e.MeDbI,this._onMessage);continue;case"3":this[t(1194)][t(597)+t(667)](e[t(724)],this[t(1026)]);continue;case"4":if(!this[t(1194)])return;continue}break}}else{let r=0,a=0,x;do x=e[t(1640)](re,i),r<32&&(a|=e[t(1924)](e[t(1815)](127,x),r)),r+=7;while(128&x);return a}}function X(i,t){let r=n,a={zbxHA:function(x,f,l,w){return e.nKHvA(x,f,l,w)}};for(t>>>=0;t>=128;)e.qmwrd(e.UQveq,e[r(1577)])?a[r(1321)](_0x5eb0bc,this,_0x29b5d5,[_0x3a6b06,_0x19bb15,_0x401ff5]):(Ze(i,e.xtvli(e[r(1815)](127,t),128)),t>>>=7);e[r(1587)](Ze,i,t)}function ut(i,t){let r=n,a={ghEvZ:e[r(1595)],eZGtD:e[r(412)],zCdpZ:r(516),SmROi:function(h,v,k){return e[r(725)](h,v,k)},ERdjW:e[r(724)],UthjP:function(h,v,k){return h(v,k)}},x=0,f=0,l=0,w;if(w=e[r(1355)](re,i),x=e[r(1061)](127,w),e[r(1748)](128,w))if(e.livVt("aJriO",r(1079))){if(w=re(i),x|=e.eJTEm(e.HFGcg(127,w),7),128&w&&(w=e.HNNqj(re,i),x|=e[r(825)](127&w,14),e.QrCPe(128,w)&&(w=e.tdUhC(re,i),x|=e[r(1417)](127,w)<<21,e[r(807)](128,w)&&(w=re(i),f=e[r(497)](127,w),128&w&&(w=e.YbmqP(re,i),f|=e[r(1924)](127&w,7),e[r(614)](128,w)&&(w=e[r(1811)](re,i),f|=e[r(1513)](e[r(614)](127,w),14),128&w&&(w=e[r(1708)](re,i),f|=(127&w)<<21,e[r(1536)](128,w))))))))if(e[r(1688)](e[r(348)],e.iNsmd)){let h=a[r(1538)].split("|"),v=0;for(;;){switch(h[v++]){case"0":this[r(1194)]["removeEventListe"+r(1315)](r(1948),this._onError);continue;case"1":this._ws[r(1531)+r(623)+"ner"](r(1372),this[r(826)+"ge"]);continue;case"2":this[r(1194)][r(1531)+r(623)+r(1315)](a[r(1559)],this[r(389)]);continue;case"3":this[r(1194)].removeEventListener(a[r(698)],this[r(877)]);continue;case"4":if(!this[r(1194)])return;continue}break}}else w=e[r(1069)](re,i),l=e[r(801)](127,w),128&w&&(w=e.ViNix(re,i),l|=e[r(1672)](e[r(628)](127,w),7))}else _0x3da307[r(1942)]()[r(1487)](()=>{let h=r,v=a.SmROi(_0x14cc99,a.ERdjW,{message:this[h(776)+h(822)+h(1238)](_0x32ebcd)});this[h(854)](a[h(1673)],v);let k=a.UthjP(_0x4a2a02,a[h(1559)],{reason:this[h(776)+h(822)+"age"](_0x3e1524)});this[h(854)](a[h(1559)],k)});return{low:e[r(1070)](x,e.oVeJl(f,28)),high:e[r(1896)](f,4)|e[r(1810)](l,24),unsigned:t}}function $(i,t){let r=n,a=e[r(1896)](t[r(1425)],0),x=e.AZDNO(e[r(1896)](t[r(1425)],28)|t[r(1642)]<<4,0),f=t[r(1642)]>>>24,l=e[r(681)](0,f)?e[r(1916)](0,x)?e[r(605)](a,16384)?e[r(396)](a,128)?1:2:a<2097152?3:4:e[r(1344)](x,16384)?e[r(1790)](x,128)?5:6:e.ktKcp(x,2097152)?7:8:e[r(1098)](f,128)?9:10,w=E(i,l),h=i.bytes;switch(l){case 10:h[e.PKLWM(w,9)]=e[r(807)](e[r(1630)](f,7),1);case 9:h[e[r(486)](w,8)]=e[r(778)](9,l)?e[r(846)](128,f):e[r(1437)](127,f);case 8:h[w+7]=e[r(1216)](8,l)?e[r(808)](x>>>21,128):e[r(1536)](e.uUVkm(x,21),127);case 7:h[e[r(410)](w,6)]=e[r(622)](7,l)?e[r(1630)](x,14)|128:e.dcJzi(e.uUVkm(x,14),127);case 6:h[e[r(1002)](w,5)]=e[r(1087)](6,l)?e.SREUL(x>>>7,128):e.dcJzi(e[r(1630)](x,7),127);case 5:h[e.lKWtt(w,4)]=e[r(1543)](5,l)?e[r(876)](128,x):e.EvXxN(127,x);case 4:h[w+3]=e[r(1511)](4,l)?e.IRQKe(a>>>21,128):e.tGKeR(a>>>21,127);case 3:h[e[r(739)](w,2)]=e[r(1688)](3,l)?e.GbCsg(e[r(1630)](a,14),128):e.UagCE(a>>>14,127);case 2:h[e[r(1105)](w,1)]=l!==2?e[r(1545)](a>>>7,128):e[r(829)](e[r(352)](a,7),127);case 1:h[w]=e[r(1093)](1,l)?e[r(1549)](128,a):e[r(518)](127,a)}}function _t(i){return e.OBirS(C,i)}function ie(i){return e[n(1891)](S,i)}let yt=65536,_e=e.PYFCf,bt=e[n(816)](yt,yt),$i=e[n(1873)](bt,bt),Vi=$i/2,Qe=String[n(938)+"e"].charCodeAt;class J{constructor(t,r,a){let x=n;this[x(1231)]=!0,this[x(1425)]=e[x(1070)](0,t),this[x(1642)]=e.GbCsg(0,r),this[x(1171)]=!!a}static[n(1231)](t){let r=n,a={FYTkM:e[r(724)]};if(e[r(973)]!==r(980))_0x560cea[r(1531)+r(623)+r(1315)]("success",_0x20749e),_0x409cf2[r(1531)+"entListe"+r(1315)](rDIFpv[r(1273)],_0x30c56c);else return t&&t[r(1231)]===!0}static[n(1714)](t,r,a){return new J(t,r,a)}static[n(1164)+"s"](t,r,a){let x=n;if(e[x(1215)]!=="rGQpM"){let f=e[x(1553)].split("|"),l=0;for(;;){switch(f[l++]){case"0":this._QoSManager?.closeDB();continue;case"1":this[x(971)+x(572)]=!0;continue;case"2":if(!this[x(1194)])return void this[x(1277)]("close, w"+x(1314)+x(946)+"nitialized");continue;case"3":this[x(1452)+x(791)+x(667)]();continue;case"4":this[x(1517)+"mer"]();continue;case"5":if(e[x(723)](this[x(1194)][x(1633)+"te"],this[x(366)])||this[x(1194)][x(1633)+"te"]===this[x(1048)])return void this._debug(e[x(1097)]);continue;case"6":this[x(1468)+x(1576)]();continue;case"7":this[x(1882)+x(1639)+"t"](_0x28e6e1,_0x3d561c);continue}break}}else return a?J["fromByte"+x(1729)](t,r):J[x(1164)+x(1034)](t,r)}static[n(1164)+n(1729)](t,r){let a=n;return new J(e[a(808)](e[a(1415)](t[0],t[1]<<8),t[2]<<16)|t[3]<<24,e[a(752)](e[a(1967)](t[4]|t[5]<<8,e[a(1431)](t[6],16)),e[a(825)](t[7],24)),r)}static[n(1164)+n(1034)](t,r){let a=n;return new J(e[a(1663)](e[a(808)](t[4]<<24|e[a(1610)](t[5],16),e.KXXQn(t[6],8)),t[7]),e[a(1063)](t[0]<<24|e.ZFLWS(t[1],16)|e.FuMJI(t[2],8),t[3]),r)}static[n(1796)](t){let r=n;if(e[r(1685)](e[r(626)],e[r(1381)])){if(!this._ws)return;this[r(1882)+r(1639)+"t"](_0x2d57d7,_0x5e5e7f,_0x3c7aae)}else return e.CQLER(t,_e)?Yi:new J(e[r(1630)](e[r(1070)](e[r(587)](Qe.call(t,0),e.kCpGF(Qe[r(1045)](t,1),8)),Qe[r(1045)](t,2)<<16)|Qe[r(1045)](t,3)<<24,0),e[r(587)](e[r(1210)](Qe[r(1045)](t,4),e.tVCwM(Qe[r(1045)](t,5),8))|e[r(1837)](Qe[r(1045)](t,6),16),e.bZsPx(Qe[r(1045)](t,7),24))>>>0,!0)}[n(1622)](){let t=n;return String["fromChar"+t(694)](e[t(1199)](255,this.low),e.yjEFv(e[t(1920)](this.low,8),255),e[t(1630)](this[t(1425)],16)&255,e[t(1962)](this[t(1425)],24),e[t(1199)](255,this[t(1642)]),e.okMyv(e[t(352)](this[t(1642)],8),255),e[t(801)](e[t(1131)](this[t(1642)],16),255),e[t(1920)](this.high,24))}static fromNumber(t,r=!0){let a=n,x={pcqzQ:function(f,l){return e[D(927)](f,l)},TKLII:function(f,l){return e.ZZDLo(f,l)},Tkljw:e[a(1964)]};if(e[a(1345)](isNaN,t))return r?Uc:Yi;if(r){if(e[a(502)]!=="eYmUC"){let f=this[a(1440)][a(1155)+a(1906)+"nc"](this[a(770)]),l=_0x4f4416[a(940)](x[a(1202)](f,"{}"));return _0x242f44[a(1406)](l)}else if(e[a(1271)](t,$i))return Kc}else if(e.zSadu(e[a(1329)],a(1776))){if(e[a(1325)](t,-Vi))return Hc;if(t+1>=Vi)return qc}else return!!(_0x5642d2||_0x3135fc&&_0x5f5b50[a(963)+a(1462)]||_0x1b47ab&&_0x2c9acd["connectS"+a(1462)]||x[a(1202)](_0x4e807e,_0x198108)&&x[a(1396)](x.Tkljw,typeof _0x365e25)&&_0x56eb5b);return J.fromBits(e[a(1917)](e[a(1464)](t,bt),0),t/bt|0,r)}toNumber(){let t=n;return this[t(1171)]?e.tBeJC(e.ejQNU(this[t(1642)]>>>0,bt),e[t(1630)](this[t(1425)],0)):e[t(406)](e[t(1550)](this[t(1642)],bt),e.IlTOL(this[t(1425)],0))}[n(687)](){let t=n;return this[t(1642)]===0&&e[t(1424)](0,this[t(1425)])}[n(354)](t){let r=n;J[r(1231)](t)||(t=J.fromNumber(t));let a=e[r(1533)](this[r(1642)],16),x=e[r(1671)](65535,this.high),f=e[r(418)](this.low,16),l=e[r(1877)](65535,this[r(1425)]),w=e[r(434)](t[r(1642)],16),h=65535&t[r(1642)],v=e[r(434)](t[r(1425)],16),k=e[r(982)](65535,t[r(1425)]),R=0,B=0,A=0,O=0;return O+=e.NZINE(l,k),A+=O>>>16,O&=65535,A+=e[r(1475)](f,v),B+=A>>>16,A&=65535,B+=e.lADND(x,h),R+=B>>>16,B&=65535,R+=e[r(1717)](a,w),R&=65535,J[r(1714)](e[r(1391)](A,16)|O,e.RVWuM(e[r(1236)](R,16),B),this[r(1171)])}[n(495)](t){let r=n;return J[r(1231)](t)||(t=J[r(1302)+"er"](t)),e[r(1087)](this[r(1171)],t.unsigned)&&e[r(1239)](e[r(1209)](this[r(1642)],31),1)&&e[r(1006)](e[r(352)](t.high,31),1)?!1:this[r(1642)]===t[r(1642)]&&e[r(723)](this.low,t[r(1425)])}addOne(){let t=n;return e[t(1916)](-1,this.low)&&e[t(1457)](-1,this[t(1642)])?J[t(1714)](0,0,this[t(1171)]):e[t(681)](-1,this[t(1425)])?J[t(1714)](0,e[t(945)](this.high,1),this.unsigned):J[t(1714)](this.low+1,this.high,this[t(1171)])}[n(1505)](t){return t?this[n(1752)+"E"]():this.toBytesBE()}[n(1752)+"E"](){let t=n,r=this.high,a=this.low;return[e[t(1515)](255,a),e.dcJzi(a>>>8,255),e[t(1417)](e.wLKYO(a,16),255),e[t(1131)](a,24),e[t(592)](255,r),e.bpbxH(r,8)&255,e[t(1784)](e[t(544)](r,16),255),e[t(570)](r,24)]}[n(1083)+"E"](){let t=n,r=this.high,a=this.low;return[e[t(842)](r,24),e[t(1334)](e[t(757)](r,16),255),e.pBzNe(e.IlTOL(r,8),255),255&r,e.IZbHq(a,24),e[t(632)](e.cNTJO(a,16),255),e[t(1536)](a>>>8,255),e[t(792)](255,a)]}}let Yi=new J(0,0,!1),Uc=new J(0,0,!0),qc=J.fromBits(-1,2147483647,!1),Kc=J[n(1714)](-1,-1,!0),Hc=J.fromBits(0,-2147483648,!1);var et=(function(i){let t=n,r=e[t(1223)][t(675)]("|"),a=0;for(;;){switch(r[a++]){case"0":i[i[e[t(1689)]]=5001]=e[t(1689)];continue;case"1":return i;case"2":i[i[e[t(1570)]]=5004]=e.dSBZc;continue;case"3":i[i[e[t(1172)]]=5003]=e.jwiwS;continue;case"4":i[i[e.IVABN]=5002]="CONNECTI"+t(501);continue;case"5":i[i[t(917)+"OR"]=5005]=e.ZZwap;continue}break}})({});class vt{constructor(t){let r=n;r(1860)===e[r(1341)]?(this[r(1124)]=t,this[r(1675)]=null):(this.emit(e[r(635)],_0x2b29a9),this[r(1286)+"eAck"]&&this[r(1286)+"eAck"](_0x58804b))}}class Xi extends vt{constructor(t,r){let a=n;super(t),this.message=r&&r[a(1372)]||null}}class Zi extends vt{constructor(t,r){let a=n;super(t),this.error=r&&r[a(1948)]||null,this.colno=r&&r.colno||0,this[a(1664)]=r&&r[a(1664)]||"",this.lineno=r&&r[a(783)]||0,this.message=r&&r.message||"",this.code=r&&r.code||5001}}class Qi extends vt{constructor(t,r){let a=n;super(t),this[a(908)]=r&&r[a(908)]||0,this.reason=r&&r[a(1465)]||"",this[a(1043)]=r&&r.wasClean||!1,this[a(1733)+a(1908)]=r&&r[a(1733)+a(1908)]||!1}}class es extends vt{constructor(t,r){let a=n;super(t),this[a(979)]=r&&r[a(979)]||null}}class ts extends es{constructor(t,r){let a=n;super(t),this[a(979)]=r&&r[a(979)]||null,this.message=r&&r[a(1372)]||null}}class ns extends vt{constructor(t,r){let a=n,x={AgJNP:function(f,l){return e[D(1528)](f,l)},uiBMv:function(f,l){return e.dlzsr(f,l)},ZlVWh:function(f,l){return e[D(438)](f,l)},pTHHz:function(f,l){return f<<l},CbnIO:function(f,l){return f&l},CNYhM:function(f,l){return f<l},vJzwj:function(f,l){return f+l},TAOuk:function(f,l){return f>>l}};e[a(1859)](e[a(1127)],e[a(351)])?(_0x545b06=fULfwA[a(1318)](fULfwA[a(998)]((7&_0x812343)<<18|fULfwA.ZlVWh(63&_0x44e532,12),fULfwA[a(465)](fULfwA[a(1366)](63,_0x71a2f4),6)),63&_0x14e897),fULfwA.CNYhM(_0x272051,65536)||_0x5a9449>1114111?_0x16e57e+=_0x85a488:(_0x44c97d-=65536,_0x1671f6+=_0x5a9762(fULfwA[a(730)](fULfwA[a(1410)](_0xe73ead,10),55296),fULfwA[a(1366)](1023,_0x4e24a7)+56320),_0x1f3832+=3)):(super(t),this[a(979)]=r&&r.data||null)}}function Ie(i,{message:t,code:r,error:a}){return new Zi(i,{message:t,code:r,error:a})}function Re(i,{code:t,reason:r,wasClean:a,willReconnect:x}){return new Qi(i,{code:t,reason:r,wasClean:a,willReconnect:x})}function rs(i,{data:t,message:r}){return new ts(i,{data:t,message:r})}function is(i,{data:t}){return new ns(i,{data:t})}function Lr(i,{message:t}){return new Xi(i,{message:t})}class ss{constructor(t,r){let a=n;this[a(1188)+"s"]=t,this[a(924)+"es"]=r,this[a(893)+"ndex"]=0,this[a(652)+"ndpointT"+a(804)+"t"]=0}[n(1467)+n(819)+n(473)](){let t=n;this[t(893)+t(1893)]=0,this[t(652)+t(857)+t(804)+"t"]=0}resetTries(){let t=n;this[t(652)+t(857)+t(804)+"t"]=0}[n(545)+n(1568)+"nt"](){let t=n;return this.endpoints[this["currentI"+t(1893)]]}[n(545)+n(1568)+n(1247)+n(521)](){return this[n(652)+"ndpointTriesCount"]}[n(541)+"chMaxTries"](){let t=n;return!!(this[t(893)+t(1893)]>=this[t(1188)+"s"][t(1804)]||e.nGytY(this["currentI"+t(1893)],e.pFYRg(this.endpoints[t(1804)],1))&&e[t(1254)](this[t(652)+t(857)+"riesCount"],this[t(924)+"es"]))}[n(1414)+n(1795)+n(1459)+n(515)+n(773)](){let t=n;return e[t(1006)](e[t(1399)],t(1632))?e[t(581)](this[t(893)+"ndex"],this[t(1188)+"s"][t(1804)])?!0:e.hqFQg(this[t(652)+t(857)+t(804)+"t"],this[t(924)+"es"]):!!this._qosDB}["replaceB"+n(918)+"pointAnd"+n(1592)+n(796)](){let t=n;return this[t(652)+t(857)+t(804)+"t"]=1,this["currentI"+t(1893)]++,this[t(1188)+"s"][this["currentI"+t(1893)]]}["getCurrentEndpoi"+n(1508)+"ateCount"](){let t=n;return this[t(652)+t(857)+t(804)+"t"]++,this[t(545)+t(1568)+"nt"]()}}let St=(e[n(1132)](e[n(1964)],typeof globalThis)&&e[n(349)](e[n(1827)],globalThis[n(1255)+n(1189)][n(1606)])||e[n(699)](e[n(1964)],typeof window)&&e[n(1380)](e[n(1827)],window[n(1255)+n(1189)][n(1606)]))&&e[n(1667)](e[n(1964)],typeof document),ft=typeof globalThis<"u"&&(e.KvtXL(e[n(432)],globalThis[n(1255)+n(1189)][n(1606)])||e[n(1783)](n(913)+n(1453)+n(1777)+"pe",globalThis["construc"+n(1189)][n(1606)]))&&e[n(1964)]!=typeof tt,jt=(n(1056)+"d"!=typeof globalThis&&e[n(432)]===globalThis[n(1255)+n(1189)].name||typeof globalThis>"u"||e.JkqYA(e[n(1964)],typeof globalThis)&&!!globalThis[n(903)+n(1548)])&&e.YDmvH(e[n(1964)],typeof wx),Wt=e[n(1964)]!=typeof globalThis&&(e[n(747)]===globalThis[n(1255)+n(1189)][n(1606)]||e.CbzNk(e[n(717)],globalThis[n(1255)+n(1189)][n(1606)])||e[n(1073)]===globalThis["construc"+n(1189)][n(1606)])&&e[n(756)](n(1056)+"d",typeof self),Gc=e[n(1964)]!=typeof globalThis&&e[n(1867)](n(475),globalThis[n(1255)+n(1189)][n(1606)])&&e[n(1818)](n(1056)+"d",typeof global)&&e[n(488)](e[n(432)],global[n(1255)+n(1189)][n(1606)])&&e[n(1964)]!=typeof process&&!!process[n(900)];class Or{constructor(){let t=n;this[t(1593)+"rs"]={}}[n(854)](t,...r){let a=n,x=this[a(1593)+"rs"][t];if(x)x[a(533)]()[a(1456)](f=>f.fn[a(1800)](f.ctx,r));else if(e[a(724)]===t&&!this[a(1634)]){let f=r.length&&r[0];if(e[a(1198)](f,Error))throw f;let l=new Error(e[a(745)](e.ZuutQ,f?e[a(1844)](" ("+f.message,")"):""));throw l[a(1418)]=f,f}return this}[n(1912)](t,r){let a=n;if(e[a(1817)](e[a(582)],a(1306))){for(_0x2e057e>>>=0;e[a(1205)](_0x359d33,128);)e[a(1840)](_0x22c347,_0x811c0f,e[a(659)](127&_0x3227c7,128)),_0x533f7a>>>=7;e[a(500)](_0x5a7dc0,_0x5355d0,_0xf224e0)}else{if(t===void 0)this[a(1593)+"rs"]={};else if(e[a(1457)](void 0,r))this[a(1593)+"rs"][t]=null;else{let x=this[a(1593)+"rs"][t];if(x)for(let f=0;e[a(1660)](f,x[a(1804)]);)e[a(1076)](x[f].fn,r)?x[a(936)](f,1):++f}return this}}on(t,r,a){let x=n,f={jAvBU:x(380),dcEjK:function(l,w,h){return e[x(499)](l,w,h)}};if(e[x(1144)](e[x(1118)],x(1563)))return(this[x(1593)+"rs"][t]||(this[x(1593)+"rs"][t]=[]))[x(1274)]({fn:r,ctx:a||this}),this;this[x(854)](f[x(1947)],f[x(1838)](_0x33f7f9,f[x(1947)],{..._0x1cd4db}))}}class jc extends Or{[n(776)+n(822)+n(1238)](t){let r=n;return t[r(1483)]||t[r(1662)]?("message: "+(t[r(1483)]||"")+r(1754)+(t[r(1662)]||""))[r(630)]():JSON[r(1926)+"y"](t)}constructor(t,r,a){let x=n;if(e[x(738)]===e[x(738)])super(),this._socket=null,jt&&wx[x(963)+"ocket"]&&(this._socket=wx["connectS"+x(1462)]({url:t,protocols:r,header:a,fail:this[x(1709)+x(830)+x(1569)][x(1068)](this),success:this[x(1709)+"ocketSuccessHandler"][x(1068)](this)})),ft&&tt[x(963)+x(1462)]&&(this[x(519)]=tt[x(963)+x(1462)]({url:t,protocols:r,header:a,fail:this["_createS"+x(830)+x(1569)][x(1068)](this),success:this[x(1709)+x(481)+x(1310)+x(583)][x(1068)](this)}));else return this[x(1188)+"s"][this[x(893)+x(1893)]]}[n(1709)+"ocketSuc"+n(1310)+n(583)](){let t=n,r={ydnRs:function(a,x,f){return e[D(1587)](a,x,f)},URXKy:function(a,x,f){return e.QPUKP(a,x,f)},CbzoL:function(a,x){return e[D(1603)](a,x)},Ujqpb:t(460),Pwzkd:e[t(1378)]};Promise[t(1942)]()[t(1487)](()=>{let a=t;r.CbzoL(r[a(530)],r[a(1190)])?this._addWsListeners():(nEoQPK[a(1970)](_0x1d3644,_0x42aac3,10),nEoQPK[a(921)](_0x131bfb,_0x5ccb82,_0x24bd8a))})}[n(1709)+"ocketFai"+n(1569)](t){let r=n,a={oYGJY:function(x,f,l){return x(f,l)},FEhBU:function(x,f){return e[D(1111)](x,f)},cHAwV:function(x,f,l){return e[D(499)](x,f,l)},mMWpe:e[r(724)],cUsuD:e[r(412)]};Promise[r(1942)]().then(()=>{let x=r,f={sPhFr:function(l,w,h){return a.oYGJY(l,w,h)}};if(a[x(1602)]("HANnZ","JpCli")){let l=a[x(1296)](Ie,a[x(954)],{message:this[x(776)+"rrorMessage"](t)});this[x(854)](a.mMWpe,l);let w=a[x(388)](Re,x(380),{reason:this[x(776)+x(822)+"age"](t)});this[x(854)](a[x(531)],w)}else hhxcNs[x(952)](_0x37b2b1,_0x246024,74),hhxcNs[x(952)](_0x566089,_0xb8cdf6,_0x504c14)})}[n(1123)+n(1343)](){let t=n,r={BBHhT:function(a,x){return e[D(1797)](a,x)},jMBXG:function(a,x){return e[D(1229)](a,x)},etcwC:e[t(1268)],khKfU:e[t(683)],dnzsw:function(a,x){return e[t(1869)](a,x)},qRItL:"message",YNDBl:function(a,x,f){return e[t(1725)](a,x,f)},qOjpI:t(1948)};this[t(519)][t(608)](a=>{let x=t;if(e[x(778)](e[x(736)],e.KHnSB))return iqXbql[x(1887)](_0x566fcc,_0x322d6d)&&(iqXbql.jMBXG(_0x4d321c,iqXbql.etcwC)||iqXbql[x(1953)](_0x4b881a,iqXbql[x(1025)]))?!0:iqXbql[x(1158)](_0x50ed8d,_0x4f7cbb);this[x(854)](x(516),e[x(591)](is,e[x(1177)],{...a,data:a.errMsg||""}))}),this._socket[t(506)](a=>{let x=t;this[x(854)](e[x(412)],e.VRQIm(Re,e[x(412)],{...a}))}),this._socket[t(1799)+"e"](a=>{let x=t;this.emit(r[x(1644)],r[x(604)](rs,x(1372),{...a}))}),this[t(519)].onError(a=>{let x=t;this[x(854)](r[x(1668)],Ie(r[x(1668)],{...a,message:a[x(1483)]||""}))})}[n(1316)](t){let r=n;if(e[r(1797)](t,Uint8Array)){let a=t[r(1816)][r(533)](t[r(1609)+"et"],e[r(1349)](t[r(1241)+"th"],t[r(1609)+"et"]));this._socket&&this[r(519)][r(1316)]({data:a,fail:x=>{let f=r;this[f(854)](e[f(724)],e[f(999)](Ie,e.Emkgo,{message:this[f(776)+f(822)+f(1238)](x)}))}})}else this._socket&&this[r(519)][r(1316)]({data:t,fail:a=>{let x=r;this.emit(e[x(724)],e[x(490)](Ie,e[x(724)],{message:this["_formatErrorMess"+x(1238)](a)}))}})}[n(380)](t,r){let a=n;e.icOdL(e[a(1284)],e[a(1954)])?this[a(489)+"T"]?_0x2a7a4a[a(411)+a(561)+a(1121)](({isConnected:x})=>{let f=a;this["_miniNav"+f(442)+f(355)]=x,x?this[f(1739)+f(386)]():this[f(1739)+f(1597)]()}):this[a(1726)+"X"]&&_0x548c70["onNetwor"+a(561)+"hange"](({isConnected:x})=>{let f=a;this[f(1129)+f(442)+f(355)]=x,x?this["_handleO"+f(386)]():this[f(1739)+f(1597)]()}):this._socket&&this[a(519)][a(380)]({code:t,reason:r})}[n(597)+"Listener"](t,r){let a=n,x={SpTmo:function(f,l){return e[D(508)](f,l)},DWpkc:e[a(867)]};if(e[a(1150)](e[a(937)],e[a(1850)]))this.on(t,r);else{let f=/(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}/[a(373)](_0x30abad),l=/(([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]))/[a(373)](_0x30a7e7);return f?_0x34f862(_0x19ac14):l?FkrRsu[a(593)](_0x2737c5,_0x57aa97):FkrRsu[a(485)]}}[n(1531)+"entListe"+n(1315)](t,r){this[n(1912)](t,r)}get[n(1633)+"te"](){let t=n;return this[t(519)][t(1633)+"te"]}get[n(435)+"pe"](){let t=n;return this._socket[t(435)+"pe"]}set binaryType(t){}get[n(430)](){let t=n;return this[t(519)][t(430)]}get[n(1526)](){return this[n(519)].protocol}get extensions(){return this[n(519)].extensions}get[n(1451)+n(571)](){return 0}}function Wc(i,t){let r=n;if(t)return new t(i.url,i[r(1526)]);if(jt||ft)return new jc(i[r(430)],i[r(1526)],i[r(1401)]);if(e.QXdeq(St,Wt)&&e[r(1293)](e[r(1964)],typeof WebSocket)&&WebSocket)return new WebSocket(i[r(430)],i.protocols)}function Jc(i){let t=n;return!!(i||jt&&wx[t(963)+"ocket"]||ft&&tt[t(963)+t(1462)]||e[t(927)](St,Wt)&&e[t(1132)](e[t(1964)],typeof WebSocket)&&WebSocket)}function os(i,t,r){let a=-1;async function x(f){let l=D;return e[l(1325)](f,a)?Promise.reject(new Error(e[l(1146)])):(a=f,e[l(681)](f,r[l(1804)])?Promise[l(1942)]():r[f][l(1068)](i)(t,x[l(1068)](null,e[l(503)](f,1))))}e.tdUhC(x,0)}function as(i){let t=n,r=0,a=0;for(let x=0;e[t(1807)](x,i[t(1804)]);++x)a=i[t(1311)+"At"](x),e.egKDH(a,128)?r+=1:e[t(396)](a,2048)?r+=2:e[t(1734)](e[t(1815)](64512,a),55296)&&e[t(1789)](64512,i[t(1311)+"At"](x+1))===56320?(++x,r+=4):r+=3;return r}function cs(i,t,r){let a=n;if(e[a(925)](e[a(1885)],e.rnGID))this.count++;else{if(e.hEZuE(r-t,1))return"";let x="";for(let f=t;e[a(1790)](f,r);){let l=i[f++];if(e.HUaLX(l,127))x+=String[a(356)+a(694)](l);else if(e[a(812)](l,192)&&e.NkvCI(l,224))x+=String[a(356)+a(694)](e[a(1917)](e.jBiEL(e[a(670)](31,l),6),63&i[f++]));else if(e.npKMQ(l,224)&&l<240)x+=String[a(356)+a(694)](e.aJxzu(e[a(697)](e.bYpPE(e[a(1213)](15,l),12),e[a(1448)](e[a(978)](63,i[f++]),6)),63&i[f++]));else if(e[a(1271)](l,240))if(e[a(622)](e[a(1679)],a(793))){let w=e[a(943)](e.NfQob(e.afgVA(e[a(785)](7,l),18)|e[a(1448)](e[a(1114)](63,i[f++]),12),e.rftle(e[a(1334)](63,i[f++]),6))|e[a(1792)](63,i[f++]),65536);x+=String[a(356)+a(694)](e[a(1854)](55296,w>>10)),x+=String["fromChar"+a(694)](e.SavAi(56320,e[a(498)](1023,w)))}else e[a(911)](_0x584321,_0x3dcdf9,32),e[a(609)](_0x4b58d9,_0x12c023,e[a(1413)](_0x141488,_0x32c2b4))}return x}}function Nr(i,t,r){let a=n,x={VMsSD:function(f,l){return e[D(493)](f,l)}};if(e[a(627)](e.lNWyi,e[a(1109)])){let f=r,l,w;for(let h=0;h<i.length;++h)if(e[a(417)](e[a(706)],e[a(706)]))_0x4d050c&&this["_cursorM"+a(1320)][a(1398)+a(379)+a(1522)](_0x2c7556);else if(l=i.charCodeAt(h),e[a(684)](l,128))t[r++]=l;else if(l<2048)e[a(1239)](a(848),a(1919))?(e[a(1232)](_0x17f911,_0x1e7b95,90),e[a(499)](_0x501994,_0x3ecd1c,_0x200890)):(t[r++]=e[a(749)](l>>6,192),t[r++]=e[a(697)](e[a(1787)](63,l),128));else if(e[a(983)](e[a(982)](64512,l),55296)&&e[a(1006)](e[a(513)](64512,w=i[a(1311)+"At"](e[a(529)](h,1))),56320))if(e[a(1543)](a(1370),a(823))){let v=e.zqpVZ[a(675)]("|"),k=0;for(;;){switch(v[k++]){case"0":t[r++]=e[a(427)](e[a(1037)](l>>12,63),128);continue;case"1":l=e[a(538)](e[a(1347)](65536,e[a(1619)](e.RIgTa(1023,l),10)),e[a(1798)](1023,w));continue;case"2":t[r++]=e[a(427)](e[a(564)](63,l),128);continue;case"3":t[r++]=e.mPJDT(e[a(1377)](l>>6,63),128);continue;case"4":t[r++]=e[a(1549)](l>>18,240);continue;case"5":++h;continue}break}}else _0x43ca58[a(1531)+a(623)+a(1315)](IXmEko[a(1868)],_0x1bef83),_0x1323b4[a(1531)+"entListe"+a(1315)](a(1948),_0x498c5f),_0x57058d["removeEv"+a(623)+a(1315)](IXmEko[a(1409)],_0x32de99);else t[r++]=e[a(1941)](l,12)|224,t[r++]=e.OsQCT(e.xmblo(l,6)&63,128),t[r++]=63&l|128;return e.HuNwE(r,f)}else{let f=this[a(1440)][a(1155)+a(1616)](this[a(770)]);return _0x273e6d[a(940)](x[a(532)](f,"{}"))[_0x2171d8]}}async function xs(i){let t=n;if(e[t(1346)](e[t(666)],typeof i)){let r=new Uint8Array(e[t(949)](as,i));return e[t(686)](Nr,i,r,0),r}return e[t(1108)](i,ArrayBuffer)?new Uint8Array(i):new Uint8Array(i[t(1816)],i[t(1609)+"et"],i[t(1241)+"th"])}function $c(i){let t=n;try{return e[t(1818)](e.BrWyJ,typeof i)&&(e[t(578)](i,ArrayBuffer)||i[t(1816)]&&e[t(578)](i[t(1816)],ArrayBuffer))||e[t(873)](e[t(666)],typeof i)?"":(JSON.parse(i),e[t(1697)])}catch{return e[t(1184)](e[t(666)],typeof i)?e[t(671)]:""}}let Vc=(i,t)=>{let r=n;switch(i){case r(899):case e.qmExr:return{[r(1354)+i]:1,"x-tt-env":t};default:return{}}};class Yc{constructor(t){let r=n;this.maxLossCount=t,this[r(1305)]=0}[n(1562)](){let t=n;if(e[t(1684)](e[t(802)],e[t(802)]))if(e[t(1039)](_0x5e0f83[t(549)],_0x2cbdb7)){let r=e[t(1108)](this[t(1492)][t(1566)+t(1428)],_0x5841cc)?{force:!!this._options[t(1566)+"ncoding"].force,encoding:this[t(1492)][t(1566)+t(1428)][t(1477)]?this[t(1492)][t(1566)+t(1428)][t(1477)].replace(/\s/g,"")[t(1540)+"ase"]():""}:{force:!1,encoding:this._options[t(1566)+t(1428)]?this[t(1492)][t(1566)+t(1428)][t(1828)](/\s/g,"")[t(1540)+t(1955)]():""},a=_0x216eb2[t(1566)+t(1428)]?_0x2a7f96[t(1566)+"ncoding"][t(1828)](/\s/g,"")[t(1540)+t(1955)]():"",x=e[t(1496)](this[t(1492)][t(1092)+t(1913)],_0x36b15d)?{force:!!this[t(1492)]["payloadT"+t(1913)][t(766)],type:this[t(1492)][t(1092)+"ype"].type?this[t(1492)][t(1092)+t(1913)][t(1124)][t(1828)](/\s/g,"")["toLowerC"+t(1955)]():""}:{force:!1,type:this[t(1492)][t(1092)+t(1913)]?this[t(1492)].payloadType.replace(/\s/g,"")[t(1540)+"ase"]():""},f=_0x20747e[t(1092)+"ype"]?_0x2e4c02[t(1092)+"ype"][t(1828)](/\s/g,"")[t(1540)+t(1955)]():"",l=x[t(766)]?x.type:f||x.type,w=r[t(766)]?r[t(1477)]:a||r.encoding,h=[e[t(671)],e.iIWEe,t(707)+t(421)+";charset"+t(928),e.BrWyJ],v=[t(1825)+"e",e.LzkxR];this[t(1492)][t(624)+"ansformTextPayload"]&&h[t(1738)](l)&&(!w||v.includes(w))?_0x179c54["textPayl"+t(568)]=e[t(1003)](_0x2a6983,_0x3cf02c[t(549)],0,_0x5b6221[t(549)][t(1241)+"th"]):_0x5b1e6e[t(1473)+t(568)]=""}else _0x4a15a7.textPayload="";else this.count++}["checkRea"+n(1299)+"nt"](){let t=n;if(e.AGiMB!==e[t(1030)])this[t(1188)+"s"]=_0x5ce4f7,this[t(924)+"es"]=_0x573f22,this[t(893)+t(1893)]=0,this["currentE"+t(857)+t(804)+"t"]=0;else return e[t(526)](this.count,this[t(1758)+t(521)])}[n(709)+n(1881)](t=0){let r=n;if(e.yQTMm(r(1335),e.DtBwC))this["maxLossC"+r(521)]=t,this[r(1305)]=0;else return _0x577163||(_0x1de132=_0x28edcb[r(1942)]()[r(1487)](_0x85c7d4[r(1068)](_0x3e7a64,r(637)))),_0x484150}}async function Xc(i){let t=n,r={uiajx:function(a,x){return e[D(1503)](a,x)},vZifc:t(832)+t(1465),JZPag:function(a,x){return e.rftle(a,x)},faFXN:function(a,x){return a&x},JVXKa:function(a,x){return e[t(1248)](a,x)},EKuIU:function(a,x){return e[t(1584)](a,x)},VByjZ:function(a,x){return e[t(1515)](a,x)},eFWCR:function(a,x){return e[t(755)](a,x)},aMBGZ:function(a,x){return e[t(1921)](a,x)}};if(e[t(824)](t(1090),t(1090)))return new Promise(a=>{let x=t;if(e[x(1216)](e[x(1611)],e[x(446)])){if(!St)return e.LklVt(a,"unknown "+x(1465));try{let f=document[x(806)+"ement"](e[x(1257)]);window[x(1929)+x(966)]=l=>{let w=x;document[w(569)][w(657)+w(1928)](f),window[w(1929)+w(966)]=void 0,r[w(1900)](a,l&&l[w(1412)]||r.vZifc)},f[x(1124)]=x(512)+x(1269),f[x(660)]=e[x(486)](i[x(1828)](/^ws/,x(1892)),"&jscallb"+x(1842)+x(1641)+"P");try{document.body[x(1567)+x(1928)](f)}catch{document[x(569)]["removeCh"+x(1928)](f)}}catch{window.frontierJSONP=void 0,e.lnbdD(a,e[x(392)])}}else _0x31314b=gSBSCv.uiajx(_0x11e228,_0x5886f0),_0x552261<32&&(_0x2188d1|=gSBSCv.JZPag(gSBSCv[x(1331)](127,_0x2b9e84),_0x5becf7)),_0x47d964+=7});_0x172444=_0xd599d3[gSBSCv[t(1645)](_0x287e14+_0x67afd9,1)],gSBSCv[t(1915)](192,_0x133d51)!==128?_0x31dac5+=_0x28934a:(_0xda30c1=gSBSCv[t(729)](31&_0x553e63,6)|gSBSCv[t(1586)](63,_0x50b8c1),gSBSCv[t(1282)](_0x1db542,128)?_0x46949d+=_0x2cbb5e:(_0x3cc072+=gSBSCv[t(1554)](_0xd3799d,_0x5cc5fc),_0x3bdc01++))}function nt(i,t,r){let a=n;return!!i?.find(x=>x[a(746)]===t&&x[a(1968)]===r)}function Et(i,t){let r=n;return i?.[r(1676)](a=>a[r(746)]===t)?.[r(1968)]}let Br=null;async function Zc(){let i=n;return Br||(Br=Promise[i(1942)]().then(Ue[i(1068)](Ue,i(637)))),Br}class Qc extends Or{constructor(t,r){let a=n;super(),this[a(1251)]=t,this[a(548)]=r,this[a(1440)]=void 0,this[a(1486)+a(1523)]=null}async openDB(){let t=n;if(e[t(871)](e[t(1339)],t(1135)))await this[t(1600)]();else{_0x21e4db.isLong(_0x6d82b8)||(_0x17c715=_0x202f10[t(1302)+"er"](_0x2cdcae));let r=this[t(1642)]>>>16,a=e[t(649)](65535,this[t(1642)]),x=e[t(1099)](this[t(1425)],16),f=e.CxXMP(65535,this.low),l=e.PBrWO(_0x22df25[t(1642)],16),w=e[t(1102)](65535,_0x23f6de.high),h=_0x487497[t(1425)]>>>16,v=e[t(1312)](65535,_0x522638[t(1425)]),k=0,R=0,B=0,A=0;return A+=f+v,B+=e.UytTn(A,16),A&=65535,B+=x+h,R+=e[t(1533)](B,16),B&=65535,R+=a+w,k+=e[t(648)](R,16),R&=65535,k+=e[t(413)](r,l),k&=65535,_0x4566bb[t(1714)](e[t(808)](e[t(1610)](B,16),A),e[t(641)](e[t(1741)](k,16),R),this.unsigned)}}async _init(){let t=n,r={qRYCu:function(a,x){return a|x},vPmRl:function(a,x){return a>>>x},SfOaY:function(a,x){return a&x},DgjYE:function(a,x){return e[D(1014)](a,x)},IaslD:function(a,x){return a&x},gkrAi:function(a,x){return a<x},wQNzw:function(a,x){return e.RAgLQ(a,x)},gUVlB:function(a,x){return e[D(1506)](a,x)},MsnJQ:function(a,x){return a|x},zzYre:function(a,x,f,l){return e[D(1003)](a,x,f,l)}};if(!this[t(1440)]){if(this._initPromise)return this["_initPro"+t(1523)];try{if(e[t(414)]!==e[t(414)]){let a={gUsSn:function(f,l){return f>>>l},UhKwe:function(f,l){return f&l},fiUsC:function(f,l){return f<l},DXvuK:function(f,l){return r.qRYCu(f,l)},HcaPz:function(f,l){return r[t(1757)](f,l)},HKqXx:function(f,l){return f|l},ixPGn:function(f,l){return f<<l},AcrhL:function(f,l){return r[t(872)](f,l)},qoNQE:function(f,l){return f<l},LJClO:function(f,l){return r[t(1757)](f,l)},lHwnt:function(f,l){return r[t(1694)](f,l)},iAnwl:function(f,l){return r[t(939)](f,l)},eYxGR:function(f,l){return r[t(779)](f,l)},KEGjt:function(f,l){return r.gkrAi(f,l)},kRZqt:function(f,l){return f|l},IlRTD:function(f,l){return f&l},qWIGO:function(f,l){return r[t(1404)](f,l)},LqXbK:function(f,l){return r[t(1694)](f,l)},YcgOu:function(f,l){return r[t(372)](f,l)},GsDSL:function(f,l){return r[t(690)](f,l)},tYaGq:function(f,l,w,h){return r[t(809)](f,l,w,h)}},x=4294967295;return function(f,l,w=!0){let h=t;if(x=a.gUsSn(a[h(584)](127,f[l]),0),a[h(888)](f[l++],128))return{value:w?x:a[h(514)](0,x),offset:l};if(x=a[h(1735)](a[h(1607)](x,a[h(685)](a.AcrhL(127,f[l]),7)),0),a[h(929)](f[l++],128))return{value:w?x:a.HKqXx(0,x),offset:l};if(x=a[h(1474)](a.lHwnt(x,a[h(1605)](a[h(1635)](127,f[l]),14)),0),a[h(1791)](f[l++],128))return{value:w?x:a.kRZqt(0,x),offset:l};if(x=a[h(920)](x|a[h(1605)](a.IlRTD(127,f[l]),21),0),a[h(1145)](f[l++],128))return{value:w?x:a[h(781)](0,x),offset:l};if(x=a[h(1735)](x|a[h(1605)](a.YcgOu(15,f[l]),28),0),a[h(888)](f[l++],128))return{value:w?x:a[h(1781)](0,x),offset:l};if((l+=5)>f.length)throw l=f[h(1804)],a.tYaGq(_0x58f463,l,10,f[h(1804)]);return{value:w?x:a[h(1e3)](0,x),offset:l}}}else{let a=this[t(1251)],x=this._keyPath;this[t(1486)+t(1523)]=(async()=>{let f=t,{openDB:l}=await e[f(400)](Zc);this._qosDB=await e[f(1510)](l,f(1929)+"_"+a,1,{upgrade(w){let h=f;w[h(1658)+h(1670)+"e"](a,{keyPath:x})}})})(),await this[t(1486)+t(1523)]}}catch(a){if(e.QWxEo("ydzai",t(1072))){let x=this[t(1440)].getItem(this[t(770)]),f=_0x3a6eae[t(940)](e.xzgXa(x,"{}"));return _0x1163ce.keys(f)}else console[t(1024)](a)}finally{this[t(1486)+"mise"]=null}}}async[n(346)](t){let r=n;try{return await this[r(1600)](),this[r(1440)]?.[r(346)](this._dbName,t)}catch(a){console[r(1024)](a)}}async[n(590)](t,r){let a=n;return await this._init(),this[a(1440)]?.[a(398)](this[a(1251)],t)}async[n(1485)](t){let r=n,a={pqqrX:function(x,f){return e[D(1229)](x,f)},UNDvt:function(x,f){return e.sezpe(x,f)},ZkHwD:function(x,f){return e[D(344)](x,f)}};try{if(e[r(718)]!==r(1495))return await this._init(),this[r(1440)]?.[r(1704)](this[r(1251)],t);_0x5bbe91[r(590)](_0x373bd4,_0x31a18a)}catch(x){if(e[r(957)]!==r(688))console[r(1024)](x);else{if(dgqyKW.pqqrX(void 0,_0x26d323))this._listeners={};else if(dgqyKW.UNDvt(void 0,_0x246b57))this._listeners[_0x171a17]=null;else{let f=this[r(1593)+"rs"][_0x29e5e7];if(f)for(let l=0;dgqyKW[r(712)](l,f[r(1804)]);)dgqyKW[r(651)](f[l].fn,_0x470063)?f.splice(l,1):++l}return this}}}async clear(){let t=n;try{return await this[t(1600)](),this[t(1440)]?.[t(693)](this[t(1251)])}catch(r){console.log(r)}}async[n(1406)](){let t=n;return await this[t(1600)](),this[t(1440)]?.getAllKeys(this[t(1251)])}async[n(1060)](){let t=n;return await this[t(1600)](),this._qosDB?.getAll(this[t(1251)])}async[n(1420)](){let t=n;if(e[t(813)](t(404),t(1013)))throw _0x2af962=_0x283d59.length,_0x902151(_0x1b4430,10,_0x3abecb[t(1804)]);try{this[t(1440)]?.[t(380)](),this[t(1440)]=void 0}catch(r){console[t(1024)](r)}}get[n(1542)](){let t=n;try{return!!this[t(1440)]}catch(r){return console[t(1024)](r),!1}}}class e0{constructor(t,r){let a=n;this[a(1599)]=t,this[a(1263)]=r,this[a(1440)]=localStorage}async openDB(){}get[n(770)](){let t=n;return t(1929)+"_"+this[t(1599)]}async get(t){let r=n,a=this[r(1440)].getItem(this[r(770)]);return JSON.parse(e[r(1862)](a,"{}"))[t]}async[n(590)](t,r){let a=n,x={vXseS:function(f,l){return f+l},oGMTA:function(f,l){return e[D(1323)](f,l)},khCIz:function(f,l){return f&l},NnXFr:function(f,l){return e.eqSwv(f,l)},hAYoO:function(f,l){return e.wOiNz(f,l)},BVgSm:function(f,l){return f<<l},ECUfU:function(f,l){return e[D(1385)](f,l)},YMJfP:function(f,l){return f&l},fMSBz:function(f,l){return f<l},ujUXa:function(f,l){return e[D(1564)](f,l)},YPpjt:function(f,l){return e.uTUvn(f,l)},SqaPy:function(f,l){return e[D(1322)](f,l)}};if(e[a(1603)](e[a(619)],e.BMgMz))_0xee6f7f=_0x48feaf[vplaYu[a(734)](_0x57cfb6+_0x2907f3,1)],_0x5e9864=_0xa57ad6[_0x47a33d+_0x23ff4a+2],vplaYu[a(403)](vplaYu[a(1240)](vplaYu[a(1450)](_0x54fbdb,vplaYu[a(1801)](_0x542ca5,8)),49344),32896)?_0x15647e+=_0x1bf67c:(_0x413f00=vplaYu.hAYoO(vplaYu.khCIz(15,_0x342680),12)|vplaYu[a(1965)](vplaYu[a(850)](63,_0x48a9ab),6)|vplaYu[a(898)](63,_0x358fc8),vplaYu.fMSBz(_0x3e0e36,2048)||vplaYu.ujUXa(_0x43a26c,55296)&&vplaYu[a(883)](_0x50cb1a,57343)?_0x2346ca+=_0x3e61b9:(_0x195b38+=vplaYu[a(563)](_0x4f7001,_0x685d25),_0x1562b2+=2));else{let f=this[a(1440)].getItem(this[a(770)]),l=JSON.parse(e.YQkdf(f,"{}"));return l[r||t[this._pathKey]]=t,this[a(1440)].setItem(this[a(770)],JSON[a(1926)+"y"](l)),r||t[this[a(1263)]]}}async del(t){let r=n,a=this[r(1440)][r(1625)](this._prefix),x=JSON.parse(a||"{}");return x[t]=void 0,this._qosDB[r(642)](this[r(770)],JSON[r(1926)+"y"](x))}async clear(){let t=n,r={ZNHoy:e.Emkgo,uIZmJ:function(a,x,f){return a(x,f)},fDtcE:function(a,x){return e[D(732)](a,x)},LfGMY:function(a,x){return e[D(424)](a,x)}};if(e[t(607)]!==e[t(607)]){let a={PnpIm:"error"};if(ymziMM.fDtcE(_0x362c02,_0x601938)){let x=_0x142b82[t(1816)].slice(_0x3e4ed7[t(1609)+"et"],ymziMM[t(1925)](_0x419783[t(1241)+"th"],_0x4c4938[t(1609)+"et"]));this[t(519)]&&this[t(519)].send({data:x,fail:f=>{let l=t;this[l(854)](ymziMM[l(1937)],ymziMM[l(777)](_0x26df58,ymziMM[l(1937)],{message:this[l(776)+l(822)+l(1238)](f)}))}})}else this[t(519)]&&this[t(519)].send({data:_0x31dc68,fail:x=>{let f=t;this[f(854)](a[f(1119)],_0x2a54d8(a[f(1119)],{message:this["_formatE"+f(822)+"age"](x)}))}})}else return this._qosDB.clear()}async[n(1406)](){let t=n;if(e[t(1864)](e.yUNsp,e[t(1035)])){let r=this._qosDB[t(1625)](this[t(770)]),a=JSON[t(940)](e[t(751)](r,"{}"));return Object[t(1406)](a)}else return!!_0x5cb416?.[t(1676)](r=>r.key===_0x71b565&&r[t(1968)]===_0x5f1499)}async getAll(){let t=n,r=this[t(1440)][t(1625)](this[t(770)]),a=JSON[t(940)](e.wczjh(r,"{}"));return Object.values(a)}[n(1420)](){let t=n;if(e[t(1229)](e[t(1411)],e[t(658)]))_0x163198=e[t(1503)](_0x2ed64f,_0x5e4f12),_0x1de40a|=e[t(1849)](e.qVXAu(127,_0xd03143),21),e[t(592)](128,_0x53dc33)&&(_0x25d24d=e[t(1338)](_0x3fb7e9,_0x3b2e38),_0x1e6845=e[t(1883)](127,_0x3364c1),128&_0x51ffbf&&(_0x16b8a0=e[t(1466)](_0x55542c,_0x450f2b),_0x2d3281|=e[t(574)](127&_0x33e493,7)));else return Promise[t(1942)]()}get[n(1542)](){return!!this[n(1440)]}}class t0{constructor(t,r){let a=n;this[a(1599)]=t,this[a(1263)]=r,this[a(1440)]=ft?tt:jt?wx:null}async openDB(){}get _prefix(){let t=n;return e[t(914)](e[t(1501)],"xtxfy")?(_0x328af2[t(1024)](_0x45a8ed),!1):"frontier_"+this[t(1599)]}async get(t){let r=n,a=this[r(1440)][r(1155)+r(1616)](this._prefix);return JSON[r(940)](e[r(1822)](a,"{}"))[t]}async[n(590)](t,r){let a=n;if(e[a(884)](e[a(855)],a(1806))){let x=this[a(1440)][a(1155)+"geSync"](this._prefix),f=JSON[a(940)](e[a(789)](x,"{}"));return f[r||t[this[a(1263)]]]=t,this[a(1440)][a(466)+a(1616)](this[a(770)],JSON.stringify(f)),r||t[this[a(1263)]]}else _0x1d7ca9[a(1942)]().then(()=>{this["_addWsLi"+a(1343)]()})}async[n(1485)](t){let r=n,a=this[r(1440)][r(1155)+r(1616)](this[r(770)]),x=JSON[r(940)](e.cHuVj(a,"{}"));return x[t]=void 0,this[r(1440)][r(466)+r(1616)](this[r(770)],JSON[r(1926)+"y"](x))}async[n(693)](){let t=n;if(e.FIrRB(e[t(405)],e[t(405)]))++_0x3fab3b,_0x10d57c+=4;else return this[t(1440)][t(1959)+"rageSync"]()}async[n(1406)](){let t=n,r=this[t(1440)][t(1155)+"geInfoSync"](this[t(770)]),a=JSON[t(940)](e[t(1969)](r,"{}"));return Object.keys(a)}async[n(1060)](){let t=n,r=this[t(1440)][t(1155)+t(1906)+"nc"](this[t(770)]),a=JSON[t(940)](e[t(1760)](r,"{}"));return Object[t(343)](a)}[n(1420)](){return Promise.resolve()}get[n(1542)](){return!!this[n(1440)]}}function ds(i,t){let r=n;if(e[r(1181)]===e[r(1596)])_0x51ee05[r(1024)](_0x447c02);else{if(e[r(1226)](ft,ft))return new t0(i,t);if(e.lzRMy(St,Wt)&&e.gkCxa!=typeof indexedDB)return new Qc(i,t);if(e[r(1760)](St,Wt)&&e[r(1818)](r(1056)+"d",typeof localStorage))return new e0(i,t);throw new Error(r(673)+"DB failed")}}class n0{constructor(){let t=n;this[t(1256)+t(1165)+"Id"]=null,this[t(1256)+"l"]=36e5,this[t(1440)]=e[t(911)](ds,"qos",e[t(1201)])}async["_interva"+n(1469)](){let t=n;clearInterval(this[t(1256)+t(1165)+"Id"]),this["_interva"+t(1165)+"Id"]=e.OLnfm(setInterval,()=>{let r=t;this[r(1436)+r(1880)]()},this[t(1256)+"l"])}async[n(1594)](){let t=n;await this[t(1440)].openDB()[t(1487)](()=>{let r=t;this[r(1256)+r(1469)]()})}async[n(1436)+"ired"](){let t=n;(await this[t(1440)]?.[t(1060)]()||[])[t(737)](({timestamp:x})=>x<Date.now())[t(1456)](x=>{let f=t;this[f(1440)]?.[f(1485)](x[f(1285)+"id"])})}async[n(1485)](t){let r=n;if(e[r(1384)](e[r(701)],e.SKkuh))return this._qosDB?.[r(1485)](t);_0x19fabf(_0x7b15f7,58),_0x5f09e8(_0x224d37,_0x355be1)}async[n(590)](t,r){let a=n;return this._qosDB?.[a(590)]({message_id:t,timestamp:r})}async get(t){let r=n;return this[r(1440)]?.[r(346)](t)}async[n(1420)](){let t=n;clearInterval(this["_interva"+t(1165)+"Id"]),await this[t(1440)]?.[t(1420)]()}get[n(1542)](){return this[n(1440)]?.isReady}}function Mr(i){let t=n,r=!!this._options.enableQoS;if(!r)return{enabled:r,isQoSMessage:!1,isQoSAck:!1,isAckCleanupMessage:!1,ackMsgIds:[]};let a=e[t(993)](nt,i[t(1372)][t(1401)],e.GhESf,"2"),x=a&&nt(i[t(1372)][t(1401)],e[t(1737)],"1"),f=a&&e[t(956)](nt,i.message[t(1401)],t(472)+t(765)+"k","1"),l=f?e[t(1587)](Et,i.message[t(1401)],e[t(345)])?.[t(675)](",")[t(737)](Boolean)||[]:[];return{enabled:r,isQoSMessage:a,isQoSAck:x,isAckCleanupMessage:f,ackMsgIds:l}}async function us(){let i=n;return this._QoSManager||(this[i(1264)+i(1212)]=new n0),this["_QoSMana"+i(1212)][i(1542)]||await this[i(1264)+i(1212)][i(1594)](),this[i(1264)+"ger"]}async function r0(i,t){let r=n,{enableAutoAck:a}=this[r(1492)],x=nt(i[r(1372)][r(1401)],e[r(458)],"1"),f=e[r(1832)](nt,i[r(1372)].headers,e[r(1364)],"1"),l=Mr[r(1045)](this,i);if(e[r(948)](a,x))if(e.nQMTM(r(1530),e[r(1050)])){let{SeqID:w,LogID:h,service:v,LogIDNew:k,method:R}=i[r(1372)];this[r(874)]({SeqID:w,LogID:h,LogIDNew:k,service:v,method:R,headers:[{key:e[r(1364)],value:"1"},{key:e[r(1130)],value:e[r(1862)](k,"")},{key:"ack_code",value:"0"}]})}else _0xb25f46&&_0x19fb85[r(597)+"Listener"](IXmEko.zBSbu,()=>_0x14ad33()),_0x499609&&_0x1e2904[r(597)+r(667)](IXmEko[r(633)],()=>_0x474671());f&&!l[r(1728)]&&this["_dispatc"+r(1234)+r(1289)](i),t()}async function i0(i,t){let r=n,a={JcIfk:function(x,f){return e[D(1627)](x,f)},djZeL:function(x,f){return e.uRwkQ(x,f)},SUnPa:function(x,f){return e.bfUzK(x,f)},GvObc:function(x,f){return e[D(518)](x,f)},gsHtT:function(x,f){return e[D(1683)](x,f)},cmRZa:function(x,f){return e.NCfXw(x,f)},SDKdR:function(x,f){return e.ZCRzr(x,f)},JOMlJ:function(x,f){return x>>>f}};if(e[r(1817)](r(542),e[r(381)]))this[r(1277)](e[r(577)],i.message),e[r(882)](t);else{let x=_0x24f993[r(1425)],f=_0x55e03a.high;return _0x25fa48[_0x536eba]=a[r(474)](f,24),_0x436916[_0x2b2843+1]=a.djZeL(f,16)&255,_0x4cfc1f[a[r(702)](_0x1d2e2a,2)]=a[r(1861)](f,8)&255,_0x2ddbfb[_0x79dd01+3]=a[r(1136)](255,f),_0x3471b1[_0x37a724+4]=a[r(886)](x,24),_0x3c395f[a[r(1703)](_0x337262,5)]=a[r(1788)](a[r(1555)](x,16),255),_0x10aa67[_0x54ca7e+6]=a[r(886)](x,8)&255,_0x4c51fd[a[r(1703)](_0x618004,7)]=a[r(1136)](255,x),_0xf3ef77+=8,_0x2b0d9d}}async function s0(i,t){let r=n,a=e[r(367)](_t,await xs(i[r(979)]));try{if(e[r(775)](e[r(1494)],e[r(1494)]))if(e[r(1039)](a.payload,Uint8Array)){let x=e.PkaUv(this._options[r(1566)+r(1428)],Object)?{force:!!this[r(1492)][r(1566)+"ncoding"][r(766)],encoding:this[r(1492)][r(1566)+"ncoding"][r(1477)]?this[r(1492)].payloadEncoding.encoding[r(1828)](/\s/g,"")[r(1540)+r(1955)]():""}:{force:!1,encoding:this._options[r(1566)+r(1428)]?this._options[r(1566)+"ncoding"][r(1828)](/\s/g,"")["toLowerC"+r(1955)]():""},f=a["payloadE"+r(1428)]?a[r(1566)+r(1428)].replace(/\s/g,"")[r(1540)+"ase"]():"",l=e[r(1434)](this._options[r(1092)+"ype"],Object)?{force:!!this[r(1492)]["payloadT"+r(1913)][r(766)],type:this[r(1492)]["payloadT"+r(1913)][r(1124)]?this[r(1492)]["payloadT"+r(1913)][r(1124)].replace(/\s/g,"")[r(1540)+r(1955)]():""}:{force:!1,type:this._options[r(1092)+r(1913)]?this[r(1492)]["payloadT"+r(1913)][r(1828)](/\s/g,"")[r(1540)+"ase"]():""},w=a[r(1092)+"ype"]?a["payloadT"+r(1913)][r(1828)](/\s/g,"")[r(1540)+r(1955)]():"",h=l[r(766)]?l[r(1124)]:w||l[r(1124)],v=x[r(766)]?x[r(1477)]:f||x.encoding,k=[e[r(671)],e[r(1697)],e[r(1841)],e.BrWyJ],R=[r(1825)+"e",e.LzkxR];this._options["enableTransformT"+r(1040)+"ad"]&&k[r(1738)](h)&&(!v||R[r(1738)](v))?a["textPayl"+r(568)]=e[r(1309)](cs,a[r(549)],0,a[r(549)][r(1241)+"th"]):a[r(1473)+r(568)]=""}else a["textPayl"+r(568)]="";else _0x645bf=e[r(618)](_0x3a9aa8,_0x515fe8),_0x3d85cc|=e[r(1448)](127&_0x27e0bc,14),e[r(1304)](128,_0x2c2f9d)&&(_0x4011ab=e[r(1182)](_0x2f1958,_0x270492),_0x1592a4|=e[r(1197)](127&_0x55cd8b,21),e.fvqZg(128,_0x5c2579)&&(_0x5a70cd=_0x2a01d2(_0x4de35a),_0x201d09=127&_0x1824cc,e[r(1798)](128,_0x28a9cc)&&(_0x23b8d4=e.cgJce(_0x82aad7,_0x14f315),_0x24b65d|=e[r(1498)](127&_0x32a214,7))))}catch(x){a[r(1473)+r(568)]="",console[r(1024)](x)}i[r(1372)]=a,e[r(1719)](t)}function o0(i,t,r){let a=n,x=e[a(1862)](r,8192),f=x>>>1,l=null,w=x;return function(h){let v=a;if(e[v(605)](h,1)||h>f)return i(h);e[v(1626)](e[v(945)](w,h),x)&&(l=e.cgJce(i,x),w=0);let k=t[v(1045)](l,w,w+=h);return e[v(1199)](7,w)&&(w=e[v(1475)](e[v(1482)](7,w),1)),k}}let a0=4294967295;function c0(i,t,r){let a=n;return RangeError(e[a(625)](e.wQxRz(e.hKzls(a(1759)+a(1620)+a(906)+i+e[a(841)],e.lluPu(t,1)),e[a(1290)]),r))}function x0(i,t,r){let a=n;if(e[a(1004)](r,a0))throw new Error(e[a(602)]);let x=3;for(;e.krpRt(x,0);){if(e[a(1772)]("zouIA",e[a(715)]))return _0x4a5dee&&_0x84959e[a(1231)]===!0;{let f=255&r;e[a(1832)](Fr,f,i,e.zjoLk(t,x)),r>>>=8,x--}}return t+4}function d0(i,t){let r=n,a=0,x=t,f=e[r(1349)](t,4);for(;e[r(595)](x,f);){let{value:l,offset:w}=zr(i,x);x=w,a=e.MFTtH(e[r(1590)](a,8),0),a+=l}return{value:a,offset:f}}function u0(i,t,r){let a=n,x=e[a(1460)][a(675)]("|"),f=0;for(;;){switch(x[f++]){case"0":return e[a(1309)](Nr,i,t,r)+r;case"1":if(e[a(487)](i[a(1804)],40))return e.Mwnbq(Nr,i,t,r)+r;continue;case"2":if(t[a(786)+"e"])return e[a(909)](t[a(786)+"e"](i,r),r);continue;case"3":if(!i)return r;continue;case"4":if(t[a(1388)])return e[a(576)](t.write(i,r),r);continue}break}}function f0(i,t){let r=n,a=new J(e[r(1166)](i[t+4]<<24,e[r(1375)](i[t+5],16))|e.wMUuS(i[t+6],8)|i[e[r(1379)](t,7)],e[r(459)](e[r(808)](e[r(1837)](i[e[r(1347)](t,0)],24),e[r(1687)](i[e[r(525)](t,1)],16))|e.ZvxCy(i[e.JGLmo(t,2)],8),i[e.eiQHE(t,3)]),!0);return t+=8,{value:a,offset:e[r(1250)](t,8)}}function l0(i,t,r){let a=n,x=i.low,f=i.high;return t[r]=e[a(1962)](f,24),t[r+1]=e.MFTtH(f,16)&255,t[e[a(754)](r,2)]=e[a(1680)](e[a(505)](f,8),255),t[e.wQxRz(r,3)]=e[a(1874)](255,f),t[e.gYxHT(r,4)]=e[a(1458)](x,24),t[e[a(1898)](r,5)]=e[a(852)](x,16)&255,t[r+6]=e.TipRe(x>>>8,255),t[e[a(1154)](r,7)]=255&x,r+=8,r}function zr(i,t){let r=n,a={CxlXh:function(x,f){return e[D(1078)](x,f)},cRzKV:e[r(1966)],TZxGq:function(x,f){return e[r(1076)](x,f)},kHDCu:e[r(683)]};if(e.mHQaY(e[r(1313)],e[r(1313)]))return i[r(1389)+"8"]?{value:i[r(1389)+"8"](t),offset:e[r(565)](t,1)}:{value:e[r(585)](255,i[t]),offset:e[r(510)](t,1)};if(bwCjxU[r(703)](_0xf31d91,r(1230)))return _0x4fc4f3.get(_0x5d4819);if(_0x436a11===bwCjxU[r(1287)])return _0x4272b4[r(950)+r(1779)]||_0x4814f6[r(346)](_0x5544f9);if(bwCjxU.TZxGq(_0x2ad92e,bwCjxU[r(423)]))return _0x4aeed7[r(950)+"oreNames"][1]?void 0:_0xfa5bc8.objectStore(_0x3e54e1[r(950)+r(1779)][0])}function Fr(i,t,r){let a=n;return t[a(1357)+"t8"]?t.writeUint8(i,r):t[r]=e[a(1536)](255,i),e[a(510)](r,1)}let g0=function(i){return new Uint8Array(i)},h0=e.gkCxa!=typeof Buffer?Buffer[n(1001)+n(610)]:o0(g0,Uint8Array[n(938)+"e"][n(1713)]);(()=>{let i=n,t={IcwEq:function(r,a){return e[D(611)](r,a)},xMykD:function(r,a){return r&a}};if(i(1272)===e[i(1894)]){let r=4294967295;return function(a,x,f=!0){let l=i,w=e[l(1219)][l(675)]("|"),h=0;for(;;){switch(w[h++]){case"0":if(e[l(941)](a[x++],128))return{value:f?r:e[l(1809)](0,r),offset:x};continue;case"1":r=(r|e[l(498)](127,a[x])<<14)>>>0;continue;case"2":if(e[l(1211)](a[x++],128))return{value:f?r:e[l(1732)](0,r),offset:x};continue;case"3":r=e[l(976)](e.NfQob(r,e[l(1619)](e[l(1183)](15,a[x]),28)),0);continue;case"4":if(e[l(1852)](a[x++],128))return{value:f?r:e[l(1967)](0,r),offset:x};continue;case"5":r=e[l(399)](e.WPRRV(r,e.zmomq(127,a[x])<<21),0);continue;case"6":r=e[l(1131)](e[l(1967)](r,e.oJcgs(127&a[x],7)),0);continue;case"7":if(e[l(834)](a[x++],128))return{value:f?r:e.NfQob(0,r),offset:x};continue;case"8":if(e.SzQcI(x+=5,a[l(1804)]))throw x=a[l(1804)],e[l(383)](c0,x,10,a[l(1804)]);continue;case"9":if(e.gDjze(a[x++],128))return{value:f?r:0|r,offset:x};continue;case"10":return{value:f?r:0|r,offset:x};case"11":r=e[l(399)](e[l(1877)](127,a[x]),0);continue}break}}}else{let r=0,a=0,x;do x=_0x1979b1(_0x3bdcb2),USaQoO[i(598)](r,32)&&(a|=(127&x)<<r),r+=7;while(USaQoO.xMykD(128,x));return a}})();let p0=16,Ur=32;function m0(i){let t=n,r=0,a={};for(let x=0;e[t(696)](x,i[t(1804)]);x++)a[i[x]["cursor_n"+t(1280)]]=as(i[x].cursor_name),r+=e[t(1250)](14,a[i[x][t(1017)+t(1280)]]);return[r,a]}function fs(i,t,r){let a=n,[x,f]=m0(i),l=h0(x),w=0;return i.forEach(h=>{let v=D;console[v(1024)](e[v(1541)],h,h.service),w=e[v(686)](Fr,0,l,w),console[v(1024)](e[v(1336)],w),w=e[v(1510)](x0,l,w,h.service||0),console[v(1024)](e[v(1217)],w),w=e[v(1961)](Fr,f[h[v(1017)+v(1280)]],l,w),console[v(1024)](e[v(1819)],w),w=e[v(1059)](u0,h[v(1017)+"ame"],l,w),console.log(e.bliPy,w),w=e[v(686)](l0,J[v(1302)+"er"](h[v(553)]||t),l,w),console[v(1024)](e[v(1637)],w)}),{frameType:Ur,headers:[{key:e[a(455)],value:r}],payload:l}}function w0(i){let t=n,r=0,a=[];for(;r<i.byteLength;){let{offset:x}=e.BdocH(zr,i,r);r=x;let f={cursor_name:"",cursor:0,service:0},{value:l,offset:w}=e.lOfug(d0,i,r);f[t(1208)]=l,r=w;let{value:h,offset:v}=e[t(1589)](zr,i,r);r=v,f[t(1017)+t(1280)]=e[t(1832)](cs,i,r,e[t(1245)](r,h)),r+=h;let{value:k,offset:R}=e[t(1023)](f0,i,r);f[t(553)]=k[t(1416)](),r=R,a[t(1274)](f)}return a}function _0(){let i=n;return{frameType:Ur,headers:[{key:i(795)+i(1246),value:e[i(1617)]}],payload:void 0}}class y0{constructor(t,r,a){let x=n;this["_cursorN"+x(436)]=t,this[x(1744)+"ileName"]=r,this[x(798)+x(674)]=a,this[x(1440)]=ds(this["_cursorN"+x(436)],e[x(743)])}async[n(1594)](){let t=n,r={QYOfj:function(a,x,f){return e[D(944)](a,x,f)},uIHUd:e[t(412)]};if(e[t(1342)]===e[t(1342)])await this[t(1440)][t(1594)]();else{let a=this[t(1492)][t(1126)+"tInterce"+t(1214)](_0x2ad391,_0x22406b);this[t(905)+t(1470)+t(1723)](r[t(708)](_0x56e231,r[t(691)],{code:_0x37c11a,reason:_0xf333d,wasClean:!0,willReconnect:a})),a&&this[t(1963)]()}}async getCursors(){let t=n,r={PbnWM:e.WVsjj};if(e[t(983)]("sFEun",e.lwrba)){let a=_0x443240(_0x5d0292);this._ws&&this[t(1194)][t(1633)+"te"]===this[t(1770)]&&(this[t(1194)]&&this._ws[t(1316)](a),this[t(1277)](r[t(677)],_0x4aff17))}else{if(!this[t(1440)][t(1542)])return;let a=this[t(798)+t(674)],x=await this._qosDB.getAll();switch(console.log(e[t(1405)],x),a){case e[t(1159)]:return x&&x[t(1804)]?e.moGDm(fs,x,0,this[t(1744)+t(1771)]):void 0;case e.PfDoz:return;case"CONTINUE":return x&&x.length?e.Txrvl(fs,x,0,this["_cursorF"+t(1771)]):e.kmPBZ(_0)}}}async set(t,r,a){let x=n;return console[x(1024)](e[x(1971)],t,r,a),this[x(1440)][x(590)]({cursor_name:t,cursor:r,service:a})}async[n(1224)+"rs"](t){let r=n,a=w0(t);for(let x of a)console.log(e[r(1546)],a),await this[r(1440)][r(590)](x)}async[n(346)](t){let r=n;return(await this[r(1440)].get(t))?.[r(553)]}async[n(1420)](){let t=n;await this[t(1440)][t(1420)]()}[n(1398)+n(379)+n(1522)](t){let r=n;if(e[r(839)]("iVIpz",e[r(859)]))this[r(1744)+r(1771)]=t;else{let a=0,x={};for(let f=0;e[r(494)](f,_0x360386[r(1804)]);f++)x[_0x4a8dd7[f][r(1017)+r(1280)]]=_0xa2812d(_0xaeb4e7[f][r(1017)+r(1280)]),a+=e[r(1252)](14,x[_0x35053a[f][r(1017)+r(1280)]]);return[a,x]}}get isReady(){return this[n(1440)].isReady}}let b0=e.YFxhD;async function ls(i){let t=n;if(!this._options[t(1836)+"S"])return null;let{aID:r,fpID:a,messageStrategy:x}=this[t(1492)],f=e[t(1822)](i,b0);try{return e[t(1785)](e[t(1298)],e[t(1298)])?(this["_cursorM"+t(1320)]?i&&this[t(1084)+t(1320)]["updateCursorFile"+t(1522)](i):this[t(1084)+"anager"]=new y0(a+"_"+r+"_"+f,f,x),this[t(1084)+t(1320)][t(1542)]||await this[t(1084)+t(1320)][t(1594)](),this[t(1084)+t(1320)]):_0xa3dd9c?_0x5df608[t(1164)+t(1729)](_0x2d1df9,_0x5aa63c):_0x127ffa[t(1164)+t(1034)](_0xf4b0f5,_0x29dd08)}catch{return null}}async function v0(i,t){let r=n,a={wPyMa:function(A,O){return e[D(1205)](A,O)},obuBN:function(A,O){return e[D(350)](A,O)},YSsLt:function(A,O){return e.xtvli(A,O)},PhhRR:function(A,O){return e.dDcPb(A,O)},qBZPr:function(A,O){return e[D(1515)](A,O)},GSrXT:function(A,O){return A>=O},AEmDy:function(A,O){return e[D(1122)](A,O)},oXTGj:function(A,O){return e[D(1663)](A,O)},RncUe:function(A,O){return A&O},KjgPO:function(A,O){return e[D(1007)](A,O)},TuhXA:function(A,O){return e[D(771)](A,O)},Xqjyb:function(A,O){return e[D(1371)](A,O)},fraIh:function(A,O){return e[D(1197)](A,O)},JgJdb:function(A,O){return e[D(1061)](A,O)},HyCHp:function(A,O){return e.TIxaW(A,O)},xzfRy:function(A,O){return e.kCXLG(A,O)},iByFb:function(A,O){return A+O},gUwXy:function(A,O){return e[D(742)](A,O)}},x=e[r(1433)](nt,i[r(1372)][r(1401)],e.IUhUA,"-1"),f=e[r(383)](nt,i[r(1372)][r(1401)],r(612),"1"),l=e[r(1041)](Et,i.message.headers,e[r(409)]),w=e.EcFRr(Number,e.rEbnP(Et,i[r(1372)][r(1401)],e.XDfwP))||0,h=Mr[r(1045)](this,i),v=e[r(1446)](nt,i[r(1372)][r(1401)],"x-msg-qos","2"),k=e[r(916)](Et,i[r(1372)].headers,e[r(369)]),R=e[r(1029)](Number,Et(i[r(1372)][r(1401)],e[r(1021)]));if(h[r(1728)])return e[r(1393)](t);let B=h[r(1120)+"sage"]?await us[r(1045)](this):null;if(e[r(1004)](i[r(1372)][r(1208)],0)&&f&&!x||i[r(1372)][r(1208)]>0){if(l&&h["isQoSMes"+r(1086)]&&B)return!!!await B[r(346)](l)&&(this["_dispatc"+r(1441)+r(1220)](i),await B.set(l,e[r(1340)](Date.now(),w))),e[r(1393)](t);if(v){if(e.kOkEV(e[r(431)],e.llLiy))return this[r(489)+"T"]||this[r(1726)+"X"]?this["_miniNav"+r(442)+r(355)]:(this._isBrowser||this[r(1419)+"r"])&&this[r(1492)][r(1571)+r(1107)+"nged"]?_0x2e6fe5[r(1623)]:!0;{let A=await ls[r(1045)](this);if(!A){if(e.HzsVR(e.kijJx,e.YBSDb))return this[r(905)+r(1441)+r(1220)](i),e.Pylue(t);{let F=_0x36a0bf[_0x97e1f9++];if(F<=127)_0x2aaa06+=_0x55e786[r(356)+r(694)](F);else if(ugyFdn[r(1782)](F,192)&&ugyFdn[r(953)](F,224))_0x3f155b+=_0x23e905[r(356)+r(694)](ugyFdn[r(1140)](ugyFdn[r(1899)](31,F)<<6,ugyFdn[r(1519)](63,_0x4c2c69[_0x24dce4++])));else if(ugyFdn[r(483)](F,224)&&ugyFdn[r(1914)](F,240))_0x580120+=_0x58a928[r(356)+r(694)](ugyFdn[r(1140)](ugyFdn.oXTGj(ugyFdn[r(1519)](15,F)<<12,ugyFdn[r(1519)](63,_0x4d3927[_0x42d140++])<<6),ugyFdn[r(1478)](63,_0x4b92fa[_0x1157b3++])));else if(F>=240){let H=ugyFdn[r(1643)](ugyFdn[r(1052)](ugyFdn[r(1652)](ugyFdn[r(528)](ugyFdn.JgJdb(7,F),18),ugyFdn[r(528)](63&_0x1f2a9d[_0x1263f7++],12)),ugyFdn[r(922)](ugyFdn[r(1899)](63,_0xe55201[_0xfc0c29++]),6))|ugyFdn[r(1152)](63,_0xe817c[_0x24216f++]),65536);_0x71b1c3+=_0x49074f["fromChar"+r(694)](ugyFdn.iByFb(55296,H>>10)),_0x1d728f+=_0x246d0e[r(356)+r(694)](ugyFdn[r(1308)](56320,ugyFdn[r(662)](1023,H)))}}}let O=await A[r(346)](k)??-1;if(O<R)this[r(905)+"hMessage"+r(1220)](i),A[r(590)](k,R,i[r(1372)].service);else throw new Error(r(644)+r(1585)+r(467)+R+(r(661)+r(527)+"al cursor ")+O);return t()}}return this["_dispatc"+r(1441)+r(1220)](i),e.aIhPN(t)}}async function S0(i,t){let r=n;if(e[r(646)](e[r(1036)],r(1463)))return this[r(652)+r(857)+r(804)+"t"]=1,this[r(893)+r(1893)]++,this[r(1188)+"s"][this[r(893)+r(1893)]];{let a=Mr[r(1045)](this,i);if(!a[r(1120)+"sage"])return e[r(1393)](t);let x=await us[r(1045)](this);if(a[r(353)+r(1326)+r(1238)]&&a.ackMsgIds.length)for(let f of a[r(1547)+"s"])await x.del(f);t()}}async function E0(i,t){let r=n,a={oVcDb:function(h,v){return e.LgiVT(h,v)}},x=i[r(1372)][r(986)+"e"]===p0,f=e[r(884)](i.message[r(986)+"e"],Ur);if(e.qhJkF(!x,!f))return e[r(647)](t);let l=Et(i.message[r(1401)],e.WpdCM);if(!l)return e[r(1054)](t);let w=await ls.call(this,l);if(!w)return e.xxVrd(t);if(x){let h=await w[r(1196)+"rs"](),v={frameType:h?.[r(986)+"e"],SeqID:J.fromNumber(this._seqId++),LogID:J[r(1302)+"er"](this[r(1492)][r(1488)+r(731)]()),service:9e3,method:5,headers:h?.[r(1401)],payload:h?.[r(549)]},k=e[r(1443)](S,v);this[r(1194)]&&this._ws.readyState&&this[r(1194)][r(1316)](k)}if(f)if(e[r(902)]("hgwEb",e[r(1650)])){let h=i[r(1372)][r(549)];h&&w[r(1224)+"rs"](h)}else{let h=new _0x513cfa(jxgMLZ[r(1066)](2,_0x134a2a));h[r(590)](_0x5b6339),_0x487aed.bytes=h}}let A0=async function(i,t){let r=n;this[r(1088)]=!1,e[r(1891)](clearTimeout,this[r(1963)+r(1012)+"utId"]),e[r(377)](t)},I0=async function(i,t){let r=n;if(!this._ws||e[r(1430)](this[r(1194)].readyState,this[r(1770)]))return e[r(1400)](t);let{pingInterval:a}=this[r(1492)];this[r(695)+r(1095)]?.[r(1467)+r(819)+r(473)]();for(let f=0;e[r(656)](f,this["_message"+r(1027)][r(1804)]);f++){let l=this[r(798)+r(1027)][f];if(e[r(1685)](this[r(1194)][r(1633)+"te"],this.OPEN)&&l!==null)e[r(700)](e[r(543)],e[r(543)])?(this[r(1194)]&&this[r(1194)].send(l),this[r(798)+r(1027)][f]=null):IXmEko.YhIDL(_0x45c570,_0x40df33)&&_0x4fb70d[r(590)](_0x1895d8,_0x355f93);else break}this["_message"+r(1027)]=this[r(798)+r(1027)][r(737)](f=>!!f),this["_pingPon"+r(638)+"Id"]=e[r(500)](setTimeout,()=>this[r(603)](),a),this["_dispatc"+r(643)+"nt"](i),this[r(1071)+"er"]&&this[r(1194)]&&(this[r(1194)][r(435)+"pe"]=this[r(967)+r(1913)]);let x=this._endpointManager?.getCurrentEndpoint();this[r(1277)]("open "+x+r(1956)),e[r(1711)](t)},C0=async function(i,t){let r=n,a=this[r(695)+r(1095)]?.getCurrentEndpoint();this._debug(r(764)+a),e.zMDcH(t)};class P0 extends Or{constructor(t){let r=n,a={bINOa:function(w,h,v){return w(h,v)},LeDJU:e[r(724)],oBjtm:function(w,h){return e.zyPKm(w,h)},xvySg:function(w,h,v){return e.lCDDa(w,h,v)},lpeLn:function(w,h){return e[r(805)](w,h)},vwLWr:function(w,h){return e[r(1543)](w,h)},oJRPg:function(w,h){return e.LRDWd(w,h)},MVOYb:e.hYNBs,eEdrb:r(380),fDeTv:e[r(1134)],lEZHm:function(w,h){return e[r(990)](w,h)},LnKgj:function(w,h,v){return w(h,v)}};super(),this["_miniNav"+r(442)+r(355)]=!0,this._isBrowser=St,this._isNode=Gc,this[r(489)+"T"]=ft,this[r(1726)+"X"]=jt,this[r(1419)+"r"]=Wt,this[r(798)+r(1027)]=[],this["_endpoin"+r(1095)]=null,this[r(971)+"osed"]=!1,this["_binaryT"+r(1913)]=e[r(1141)],this[r(1963)+r(1724)]=!1,this[r(1963)+r(1012)+"utId"]=null,this["_reconnectTimeou"+r(464)]=null,this[r(1057)+"gTimeoutId"]=null,this[r(844)]=0,this[r(1088)]=!1,this[r(517)]="",this["_QoSMana"+r(1212)]=null,this[r(1084)+r(1320)]=null,this[r(1829)+r(930)]=null,this[r(451)+"ls"]=r(1082),this[r(366)]=3,this[r(836)+"NG"]=0,this[r(1770)]=1,this.CLOSING=2,this._onOpen=w=>{let h=r;try{e[h(993)](os,this,w,[A0,I0,C0])}catch(v){let k=e[h(994)](Ie,e[h(724)],{message:v.message,code:et[h(917)+"OR"],error:v});this[h(905)+h(1353)+"ent"](k)}},this[r(826)+"ge"]=async w=>{let h=r,{pingInterval:v,pingFrequency:k}=this[h(1492)];if((e[h(1229)]("hi",w[h(979)])&&e.UITsB(e[h(468)],k)||e[h(1859)](e[h(1075)],k))&&(this[h(1468)+h(1576)](),this[h(854)](h(596)+h(1821)+"s",h(1648)),this[h(1057)+h(638)+"Id"]=e.JpmFd(setTimeout,this._ping[h(1068)](this),v)),w.data!=="hi")try{e[h(1309)](os,this,w,[s0,r0,S0,E0,v0,i0])}catch(R){let B=e.ByxzY(Ie,e[h(724)],{message:R[h(1372)],code:et[h(1932)+h(402)],error:R});this["_dispatchErrorEv"+h(1723)](B)}},this[r(1026)]=w=>{let h=r,v=this[h(695)+h(1095)]?.[h(541)+"chMaxTries"](),k=this._endpointManager?.[h(545)+h(1568)+"nt"]();if(v&&!w[h(1372)]){let R=h(1582)+k+(h(1598)+"ax retri"+h(1871)+"ed");this[h(905)+"hErrorEvent"](a[h(1242)](Ie,a[h(636)],{message:R,code:et[h(1281)+h(1010)+"R"],error:w}));return}this[h(1194)]&&a[h(861)](this[h(1194)][h(1633)+"te"],this[h(1770)])&&this[h(1422)+"ect"](),this[h(905)+"hErrorEv"+h(1723)](a[h(761)](Ie,a.LeDJU,{message:w[h(1372)],code:et["NATIVE_E"+h(1628)],error:w}))},this[r(389)]=async w=>{let h=r;this[h(1517)+h(969)](),this._clearPingTimer(),this["_removeW"+h(1178)+"rs"](),this[h(1194)]=null,this[h(1963)+h(1724)]=!1;let v=this[h(695)+h(1095)]?.["checkRea"+h(1631)+"es"]();if(!v&&this[h(1233)+h(1583)]()&&!this[h(971)+h(572)]){let k=this[h(695)+h(1095)]?.[h(545)+h(1568)+"nt"](),R=this[h(1492)][h(1126)+"tInterce"+h(1214)](w[h(908)],w[h(1465)]);this[h(905)+"hCloseEvent"](a[h(761)](Re,h(380),{code:1006,reason:w[h(1465)]||h(1750)+h(1225)+"d, unkno"+h(1855)+h(1651)+h(397)+k,willReconnect:R})),R&&this._connect();return}if(a.vwLWr(1e3,w[h(908)])&&this["_readyCl"+h(572)]){if(a[h(1297)](h(784),a.MVOYb))return jCJGba[h(1803)](_0x3c93cc[h(965)],_0x16177a[h(1856)]);this[h(905)+h(1470)+h(1723)](a[h(761)](Re,a[h(1730)],{code:1e3,reason:a[h(560)]})),this[h(695)+h(1095)]?.[h(1467)+h(819)+h(473)](),this._pingLossCounter?.[h(709)+h(1881)]();return}if(w.code!==1e3&&v){let k=this._endpointManager?.[h(545)+h(1568)+"nt"](),R=w[h(1465)];R||(R=await a[h(762)](Xc,this[h(517)])),R=h(1750)+h(1225)+"d, "+R+(h(1175)+h(470))+k+(h(1853)+h(1767)+"ached"),this[h(905)+h(1470)+h(1723)](Re(a[h(1730)],{code:w[h(908)],reason:R}));let B="connect "+k+(h(1598)+"ax retri"+h(1871)+"ed");this[h(905)+h(1353)+"ent"](a[h(761)](Ie,a.LeDJU,{message:B,code:et[h(1281)+h(1010)+"R"]})),this[h(695)+"tManager"]?.["resetEnd"+h(819)+h(473)](),this._pingLossCounter?.[h(709)+h(1881)]();return}if(a[h(1751)](1e3,w[h(908)])&&!w.reason){let k=this[h(695)+"tManager"]?.["getCurre"+h(1568)+"nt"]();this[h(905)+h(1470)+h(1723)](a[h(1755)](Re,a[h(1730)],{code:w[h(908)],reason:h(1750)+"ng faile"+h(1851)+"wn reason, hostn"+h(397)+k})),this[h(695)+h(1095)]?.[h(1467)+h(819)+"fig"](),this[h(1829)+h(930)]?.[h(709)+h(1881)]();return}this[h(905)+"hCloseEv"+h(1723)](w),this[h(695)+h(1095)]?.[h(1467)+h(819)+h(473)](),this[h(1829)+h(930)]?.[h(709)+h(1881)]()},this[r(1479)]=null,this[r(1634)]=null,this[r(860)+"e"]=null,this[r(1176)]=null,this["onStartR"+r(1143)]=null,this[r(1286)+"eAck"]=null,this[r(1745)+r(682)+r(1831)+"ct"]=null,this._handleOnLine=this[r(1739)+"nLine"][r(1068)](this),this[r(1739)+"ffLine"]=this["_handleO"+r(1597)].bind(this),this[r(1865)+r(1100)]=this["_handleP"+r(1100)][r(1068)](this),this["_handleP"+r(1886)]=this[r(1865)+r(1886)][r(1068)](this),this[r(1492)]={url:"",automaticOpen:!0,initReconnectInterval:1e3,maxReconnectInterval:1e4,reconnectIntervalGrowFactor:2,timeoutInterval:5e3,maxRetries:5,debug:!1,maxMessageQueueLength:e.fVOyX(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.yErOE,pingLossCount:2,enableTransformTextPayload:!1,logIDNewConfig:{enableAutoGenerateLogIDNew:!1,userIp:""},miniProgramParams:{customHttpHeader:{}},enableAutoAck:!1,reconnectInterceptor:()=>!0,enableQoS:!1,QoSLevel:2,messageStrategy:e[r(1922)],env:{xTTEnv:"",xUseEnv:""},listenNetworkChanged:!0};let{url:x,ws:f}=t,l=Array.isArray(x)?x:e[r(881)](e[r(666)],typeof x)?[x]:[];if(!l||e[r(1785)](0,l[r(1804)]))throw new Error(r(1167)+r(1731)+"alid url");if(!e[r(1292)](Jc,f))throw new Error("please p"+r(1110)+r(1581)+r(733)+r(1125)+"tructor "+r(1756)+r(1949));Object[r(856)](this[r(1492)],t),this["_endpoin"+r(1095)]=new ss(l,this[r(1492)][r(924)+"es"]),this[r(1829)+r(930)]=new Yc(this[r(1492)][r(672)+r(445)]),this[r(1492)][r(613)+r(988)]&&(this[r(1088)]=!0,this[r(1963)]()),this[r(1492)][r(1571)+r(1107)+r(1249)]&&(this[r(489)+"T"]||this[r(1726)+"X"]?this[r(1935)+r(1367)+"ange"]():this[r(1071)+"er"]&&this[r(655)+r(791)+"Listener"]())}[n(1739)+"nLine"](){let t=n;this[t(1492)]["disableA"+t(573)+"nect"]||this["_readyCl"+t(572)]||this[t(540)+t(1143)]()}[n(1739)+n(1597)](){let t=n;this[t(1882)+t(1639)+"t"]();let r=e[t(1023)](Lr,"reconnect",{message:e.mzqRc});this[t(1745)+t(682)+t(1831)+"ct"]&&this["onStopIm"+t(682)+t(1831)+"ct"](r)}["_initGlo"+n(791)+"Listener"](){let t=n;this[t(1071)+"er"]&&window[t(597)+"Listener"](e[t(1930)],this["_handleO"+t(386)]),this._isBrowser&&window[t(597)+t(667)](e[t(1700)],this[t(1739)+t(1597)]),this[t(1071)+"er"]&&window[t(597)+t(667)]("pagehide",this[t(1865)+t(1100)]),this._isBrowser&&window[t(597)+"Listener"](e[t(1518)],this[t(1865)+t(1886)])}["_dropGlobalEvent"+n(667)](){let t=n;this[t(1071)+"er"]&&window["removeEv"+t(623)+t(1315)](e[t(1930)],this["_handleO"+t(386)]),this._isBrowser&&window[t(1531)+t(623)+t(1315)](e[t(1700)],this[t(1739)+t(1597)]),this[t(1071)+"er"]&&window[t(1531)+t(623)+t(1315)](t(425),this["_handleP"+t(1100)]),this._isBrowser&&window[t(1531)+t(623)+"ner"](e[t(1518)],this[t(1865)+t(1886)])}[n(1865)+n(1100)](t){let r=n;if(!t.persisted)if(e[r(1091)](e[r(1170)],e[r(1588)]))this._isBrowser&&window["removeEv"+r(623)+"ner"](e.zGlrR,this[r(1865)+r(1100)]),this[r(1071)+"er"]&&window[r(1531)+r(623)+r(1315)](r(1337),this["_handleP"+r(1886)]),this.close();else return this[r(1171)]?e[r(410)](e[r(1550)](e[r(504)](this[r(1642)],0),_0x2c4e38),this[r(1425)]>>>0):e.MhMzm(e[r(1550)](this[r(1642)],_0x17db78),e.bpbxH(this.low,0));this[r(1071)+"er"]&&window[r(1531)+r(623)+r(1315)](e.tLGyz,this[r(1739)+"nLine"]),this[r(1071)+"er"]&&window[r(1531)+"entListener"](e.pRRkp,this[r(1739)+r(1597)])}[n(1865)+n(1886)](t){let r=n;t[r(1489)+"d"]&&(this["_navigat"+r(1583)]()&&(!this[r(1194)]||e.dUwMi(this[r(1194)][r(1633)+"te"],this[r(1770)])||this[r(1194)][r(1633)+"te"]!==this[r(836)+"NG"])&&this["_handleO"+r(386)](),this[r(1071)+"er"]&&window["addEvent"+r(667)](e[r(1930)],this[r(1739)+"nLine"]),this._isBrowser&&window["addEvent"+r(667)](e[r(1700)],this["_handleO"+r(1597)]))}async[n(1064)+n(1544)](t){let r=n,{fpID:a,deviceID:x,bddID:f,ttwID:l,accessKey:w,aID:h,customParams:v={},enableAutoAck:k,enableQoS:R,QoSLevel:B,env:A}=this[r(1492)],O,F,H;this._isBrowser||this._isMiniWX||this[r(489)+"T"]?(O=location&&e.fHJWD(e[r(961)],location.protocol)?e.cfYUB:e[r(1283)],F=t[r(1828)](/((^ws)|(^http))((?:[s]*:\/\/))/,""),H=/^wss(.*:\/\/)/[r(373)](t)?t:""+O+F):(O="wss://",F=t.replace(/(^http)((?:[s]*:\/\/))/,""),H=/(^ws)((?:[s]*:\/\/))/[r(373)](F)?F:""+O+F);let ve=f?"bd_did":l?e.dMgTf:e.nBEiA,At=f||l||x;if(e[r(1008)](!At,!ve))throw new Error(r(1167)+r(1889)+"ddID, de"+r(1958)+"r ttwID");let wn=e[r(371)](e[r(968)],typeof v)?await e[r(1400)](v):v,k0=A?e.AtyQU(Vc,A[r(374)],A[r(1532)]):{},qr=Object[r(856)]({device_platform:e[r(748)],version_code:e[r(705)],access_key:w,fpid:a,aid:h,[ve]:At,xsack:k?1:0,xaack:k?1:0,xsqos:R?1:0,qos_level:R?B:void 0,qos_sdk_version:2,...k0},wn),T0=Object[r(1406)](qr)[r(550)]((Kr,Hr)=>qr[Hr]!==void 0?""+Kr+(Kr?"&":"?")+Hr+"="+qr[Hr]:Kr,"");return H+r(851)+T0}async _connect(){let t=n,r={kBsjS:function(a,x,f){return e.ofSjY(a,x,f)},lOYHK:e.zBSbu,IWxAM:function(a,x,f){return e[D(864)](a,x,f)},HXScp:function(a,x,f){return e[D(1840)](a,x,f)},tfpAU:e.IBTIH};if(e[t(1864)](e[t(433)],e[t(650)]))return _0x42c1dd[t(1800)](IXmEko[t(960)](_0x45fe23,this),_0x1af7ab),IXmEko.UOZXg(_0x1bff8c,_0xb817aa.get(this));if(this[t(1963)+t(1724)]||this[t(971)+"osed"])return;this[t(1963)+t(1724)]=!0;try{if(e[t(884)](e[t(788)],e.qdbZZ)){if(this["_clearPi"+t(1576)](),this[t(1517)+"mer"](),this[t(974)+"sListeners"](),this[t(897)+"nceClose"](1e3,_0x127593),this["_connect"+t(1724)]=!1,_0x3fdb06&&this._navigatorOnline()&&!this[t(971)+t(572)]){if(this[t(695)+"tManager"]?.["checkRea"+t(1631)+"es"]()){let x=this[t(695)+t(1095)]?.[t(545)+t(1568)+"nt"]();this["_dispatc"+t(1470)+"ent"](r[t(772)](_0x174660,r.lOYHK,{code:1006,reason:t(1582)+x+(t(447)+t(1853)+t(1767)+t(1386)),wasClean:!0}))}else{let x=this._options[t(1126)+"tInterceptor"](_0x5b6737,_0x409e8a);this[t(905)+"hCloseEvent"](r[t(639)](_0x1da90c,t(380),{code:_0x21dfd6,reason:_0x96e899,wasClean:!0,willReconnect:x})),x&&this[t(1963)]()}return}this[t(1233)+"orOnline"]()||this[t(971)+t(572)]?this[t(905)+t(1470)+t(1723)](_0x480cbc(r[t(1618)],{code:_0x142244,reason:t(1612)})):this[t(905)+t(1470)+"ent"](r[t(1846)](_0x82bdbf,r.lOYHK,{code:1006,reason:r[t(1186)]})),this[t(1194)]=null,this[t(695)+t(1095)]?.["resetEnd"+t(819)+t(473)](),this[t(1829)+t(930)]?.[t(709)+t(1881)]()}else{let a=this[t(695)+t(1095)]?.[t(1414)+t(1795)+t(1459)+t(515)+"tries"](),{timeoutInterval:x}=this[t(1492)];if(a){let l=this[t(695)+t(1095)]?.[t(545)+t(1568)+"nt"](),w=this[t(695)+t(1095)]?.[t(1005)+t(918)+"pointAnd"+t(1592)+t(796)](),h=this[t(695)+"tManager"]?.[t(545)+t(1568)+t(1247)+"ount"]();if(w){let v=t(1582)+l+(t(447)+t(1853)+t(1767)+t(1721)+t(1382)+t(1534)+"ndpoint ")+w+(t(891)+"y"),k=e[t(984)](Ie,e.Emkgo,{message:v,code:et[t(1281)+t(1010)+"R"]});this[t(1277)](v),this["_dispatchErrorEv"+t(1723)](k),this[t(517)]=await this["_generat"+t(1544)](w),this[t(1277)]("connect "+w+" "+h+t(1847)),this[t(974)+t(1178)+"rs"]()}else{let v=t(1582)+l+(t(447)+t(1853)+"tries re"+t(1386));this._debug(v),this["_dispatc"+t(1353)+t(1723)](e[t(1350)](Ie,e[t(724)],{message:v,code:et["MAX_RETR"+t(1010)+"R"]}));return}}else{let l=this[t(695)+t(1095)]?.["getCurre"+t(1568)+t(1508)+"ateCount"](),w=this[t(695)+t(1095)]?.[t(545)+t(1568)+t(1247)+t(521)]();this._url=await this[t(1064)+t(1544)](e[t(789)](l,"")),this[t(1277)](t(1582)+l+" "+w+" times"),this[t(974)+t(1178)+"rs"]()}if(this[t(1088)])this._isInit=!1;else{let l=Lr(e[t(835)],{message:"start"});this[t(617)+t(1143)]&&this[t(617)+t(1143)](l)}let f=this[t(695)+"tManager"]?.[t(545)+t(1568)+t(1247)+t(521)]()||0;e.hqFQg(f,1)&&await this._wait(e.IgSAP(f,1)),this._debug("connecti"+t(547)+this[t(517)]+(" protoco"+t(996))+this[t(451)+"ls"]),this[t(1194)]=e[t(1350)](Wc,{url:this[t(517)],protocols:[this[t(451)+"ls"]],headers:this._options[t(828)+t(1295)+"s"][t(1062)+t(1539)]},this[t(1492)].ws),(this[t(1071)+"er"]||this._isWorker)&&this._ws&&(this[t(1194)].binaryType=this[t(967)+t(1913)]),this[t(1123)+t(1343)](),this[t(1963)+"ionTimeo"+t(1681)]=e[t(1830)](setTimeout,this._onTimeout[t(1068)](this),x)}}catch(a){throw this[t(1963)+t(1724)]=!1,a}}[n(1517)+n(969)](){let t=n,r={QDFET:e[t(1574)],WBCYG:function(a,x){return e[t(1248)](a,x)},IRmfb:function(a,x){return e[t(1472)](a,x)},VcVKv:function(a,x){return e[t(1349)](a,x)},CwluZ:function(a,x,f,l){return e[t(727)](a,x,f,l)},TjWTW:function(a,x){return e.xgZhb(a,x)},EPlXv:function(a,x){return a+x},GhIRB:function(a,x,f,l){return e[t(1446)](a,x,f,l)}};if(e[t(1020)]===e.FixSU){let a=r[t(1267)].split("|"),x=0;for(;;){switch(a[x++]){case"0":if(_0x5c7e83[t(1388)])return mUcLQO[t(818)](_0x242d08[t(1388)](_0x395535,_0x200a58),_0x39837b);continue;case"1":if(_0x2f7f49[t(786)+"e"])return mUcLQO[t(1112)](_0x2ae554[t(786)+"e"](_0x1798e9,_0x309264),_0x2784a6);continue;case"2":return mUcLQO[t(1793)](mUcLQO.CwluZ(_0x2f342d,_0x4f0992,_0x238a8b,_0x3c9f77),_0x18c06d);case"3":if(!_0x43cced)return _0x567542;continue;case"4":if(mUcLQO.TjWTW(_0x3e2a49[t(1804)],40))return mUcLQO.EPlXv(mUcLQO.GhIRB(_0x39e579,_0x469c60,_0x3eb338,_0x3319c1),_0xfb1e03);continue}break}}else e.lBBCi(clearTimeout,this["_connect"+t(1012)+t(1681)]),this[t(1963)+"ionTimeo"+t(1681)]=null}["_clearPi"+n(1576)](){let t=n;e[t(990)](clearTimeout,this[t(1057)+"gTimeoutId"]),e.hnTfu(clearTimeout,this[t(1940)+"ctTimeou"+t(464)]),this[t(1057)+t(638)+"Id"]=null,this[t(1940)+"ctTimeou"+t(464)]=null}_debug(...t){let r=n;this._options[r(1163)]&&console[r(1024)][r(1800)](console,[e[r(1646)],...t])}[n(726)+n(1173)+"e"](t){let r=n,{initReconnectInterval:a,maxReconnectInterval:x,reconnectIntervalGrowFactor:f}=this[r(1492)],l=e[r(387)](a,Math[r(668)](f,e[r(943)](t,1)));return e[r(478)](l,x)?x:l}[n(603)](){let t=n;if(this[t(1194)]&&e[t(1117)](this[t(1194)].readyState,this[t(836)+"NG"])){if(e.OgSXD(e[t(1116)],t(1243)))return!0;this[t(1468)+"ngTimer"](),this._pingPongTimeoutId=setTimeout(this[t(603)].bind(this),this._options[t(1944)+t(631)]);return}if(!this[t(1194)]||e[t(449)](this[t(1194)][t(1633)+"te"],this[t(1770)]))return void this[t(540)+t(1143)]();this[t(1194)]&&this[t(1194)][t(1316)]("hi"),this[t(1940)+t(1692)+t(464)]=e[t(1715)](setTimeout,this[t(540)+t(1143)+t(797)].bind(this),this[t(1492)][t(375)+t(376)+t(1866)])}["_handleR"+n(1143)+n(797)](){let t=n;e[t(1179)]!=="wfeKL"?(this[t(1088)]=!0,this[t(1963)]()):(this[t(1829)+t(930)]?.addCount(),this[t(854)](e[t(1718)],t(566)),this[t(1829)+t(930)]?.[t(541)+t(1299)+"nt"]()?this[t(540)+t(1143)]():this[t(603)]())}[n(1233)+n(1583)](){let t=n;if(e[t(1834)](t(1074),e[t(471)]))return this._isMiniTT||this[t(1726)+"X"]?this[t(1129)+t(442)+"line"]:(this[t(1071)+"er"]||this[t(1419)+"r"])&&this._options["listenNe"+t(1107)+t(1249)]?navigator.onLine:!0;this[t(1124)]=_0x58fad1,this.target=null}_handleReconnect(){let t=n;!this[t(1233)+"orOnline"]()||this[t(971)+t(572)]||(this[t(695)+t(1095)]?.["resetEnd"+t(819)+t(473)](),this["_pingLos"+t(930)]?.[t(709)+"nter"](),this[t(1194)]?this._disconnect(1001,t(616)+t(1897)+t(1126)+t(1383)+t(437),!0):this[t(1963)]())}["_onPageN"+n(1367)+"ange"](){let t=n;this._isMiniTT?tt[t(411)+t(561)+t(1121)](({isConnected:r})=>{let a=t;this[a(1129)+a(442)+a(355)]=r,r?this[a(1739)+"nLine"]():this[a(1739)+a(1597)]()}):this[t(1726)+"X"]&&wx["onNetwor"+t(561)+t(1121)](({isConnected:r})=>{let a=t;this[a(1129)+a(442)+a(355)]=r,r?this[a(1739)+a(386)]():this["_handleO"+a(1597)]()})}_wait(t){return new Promise(r=>{let a=D,x={dbQxm:function(f,l){return e[D(754)](f,l)},IcMff:function(f,l){return e[D(1004)](f,l)},RWWAq:function(f,l){return e[D(816)](f,l)}};if(e[a(360)]!==e[a(1444)])e[a(1490)](setTimeout,r,this[a(726)+a(1173)+"e"](t));else{let f=_0x9153ce[a(1065)],l=_0x5a7073[a(965)],w=_0x4ac44f[a(1856)],h=GQogxh[a(1161)](l,_0x5bd647);if(GQogxh[a(1047)](h,f[a(1804)])){let v=new _0x34bc31(GQogxh.RWWAq(2,h));v[a(590)](f),_0x111260[a(1065)]=v}return _0x3009d2[a(965)]=h,h>w&&(_0x32d3b8.limit=h),l}})}_disconnect(t=1e3,r="",a=!1){let x=n;this[x(1194)]&&this[x(1882)+x(1639)+"t"](t,r,a)}_onTimeout(){let t=n,r={OaspT:function(a,x,f){return e[D(975)](a,x,f)},QwefR:function(a,x,f){return e[D(849)](a,x,f)}};if(e[t(1275)]!==e[t(1275)])aBZbSq.OaspT(_0x323864,_0x547467,16),aBZbSq[t(1427)](_0x3ee7ae,_0x4ef681,_0x254cca);else{let a=this[t(695)+t(1095)]?.["getCurre"+t(1568)+"nt"]();this[t(1277)](t(1582)+a+t(447)),this[t(1422)+t(744)](1001,e[t(457)],!0)}}[n(874)](t){let r=n,a=e.fEVFr(ie,t);this[r(1194)]&&e[r(1839)](this[r(1194)][r(1633)+"te"],this[r(1770)])&&(this._ws&&this[r(1194)].send(a),this._debug(r(1497),t))}[n(974)+n(1178)+"rs"](){let t=n,r={dtjcH:function(a,x){return e.iFyQY(a,x)},PrOwu:function(a,x){return e[D(556)](a,x)},vMRvo:function(a,x){return e[D(926)](a,x)},nCLtl:function(a,x){return e[D(1826)](a,x)},arHCJ:function(a,x){return e[D(1235)](a,x)},jdbyZ:function(a,x){return e.ywLta(a,x)},xMEWX:function(a,x){return e.FiLRJ(a,x)},uoNyl:function(a,x){return a&x},dSRaT:function(a,x){return a+x},WNFMU:e[t(831)],jOAJW:function(a,x){return e.ZCRzr(a,x)},WoPdt:function(a,x){return e[t(1545)](a,x)},sttnB:function(a,x){return e[t(1461)](a,x)},oIemg:function(a,x){return e.RjaCx(a,x)},PIcHT:function(a,x){return e[t(1213)](a,x)},QDExS:function(a,x){return e[t(536)](a,x)}};if(e[t(1351)](e.Uzlyg,e[t(1038)]))if(_0x3336c5=_0x4cba20[t(1311)+"At"](_0x3129e8),KXYhhK[t(985)](_0x13ff7c,128))_0x2778dc[_0x3e8995++]=_0x582592;else if(KXYhhK[t(1843)](_0xf772cb,2048))_0x5cfe35[_0x34d178++]=KXYhhK[t(1572)](KXYhhK[t(1180)](_0x4eedfc,6),192),_0x3913fc[_0x4d5a9a++]=KXYhhK[t(450)](KXYhhK[t(1395)](63,_0x430e42),128);else if((64512&_0x1218b4)===55296&&KXYhhK.xMEWX(KXYhhK[t(1665)](64512,_0x1b6474=_0x360776[t(1311)+"At"](KXYhhK[t(1185)](_0x3e4f96,1))),56320)){let a=KXYhhK[t(887)][t(675)]("|"),x=0;for(;;){switch(a[x++]){case"0":_0x52ab81[_0x3c063a++]=KXYhhK[t(450)](KXYhhK.jOAJW(_0x1c6b8c>>6,63),128);continue;case"1":_0x4983d1[_0x17f8da++]=KXYhhK.WoPdt(KXYhhK[t(1638)](63,_0x5bb6e7),128);continue;case"2":_0x487117[_0x4567ec++]=KXYhhK[t(600)](KXYhhK[t(1805)](_0x442d0f,12)&63,128);continue;case"3":_0x35878a=65536+KXYhhK[t(951)](1023&_0x10fa37,10)+KXYhhK[t(799)](1023,_0x452b6c);continue;case"4":_0xf0505[_0x29ff73++]=_0x86cae8>>18|240;continue;case"5":++_0x428945;continue}break}}else _0x3b3b1d[_0x3fd0a4++]=KXYhhK.vMRvo(_0x1ca68b>>12,224),_0x5cc801[_0x863bae++]=KXYhhK[t(858)](KXYhhK.uoNyl(KXYhhK.sttnB(_0x4f8d17,6),63),128),_0x3d57a7[_0x1cf1c0++]=KXYhhK[t(1572)](KXYhhK[t(1395)](63,_0x469139),128);else{let a=e[t(1360)][t(675)]("|"),x=0;for(;;){switch(a[x++]){case"0":this[t(1194)][t(1531)+t(623)+t(1315)](e.zBSbu,this._onClose);continue;case"1":if(!this[t(1194)])return;continue;case"2":this[t(1194)][t(1531)+t(623)+t(1315)](e[t(724)],this[t(1026)]);continue;case"3":this[t(1194)][t(1531)+t(623)+t(1315)](e.WZMXV,this[t(877)]);continue;case"4":this[t(1194)][t(1531)+"entListe"+t(1315)](e[t(1174)],this[t(826)+"ge"]);continue}break}}}[n(1123)+"steners"](){let t=n,r=e.bHujz[t(675)]("|"),a=0;for(;;){switch(r[a++]){case"0":this[t(1194)][t(597)+t(667)](e.zBSbu,this[t(389)]);continue;case"1":if(!this._ws)return;continue;case"2":this._ws[t(597)+t(667)](t(1948),this[t(1026)]);continue;case"3":this[t(1194)]["addEvent"+t(667)](e.MeDbI,this[t(826)+"ge"]);continue;case"4":this[t(1194)][t(597)+"Listener"](e[t(1177)],this[t(877)]);continue}break}}["_wsInsta"+n(1147)](t=1e3,r=""){let a=n;try{this[a(1194)]&&this[a(1194)][a(380)](t,r)}catch{}}["_destroy"+n(1639)+"t"](t=1e3,r="",a=!1){let x=n;if(this[x(1468)+x(1576)](),this[x(1517)+x(969)](),this[x(974)+"sListeners"](),this[x(897)+x(1147)](1e3,r),this["_connect"+x(1724)]=!1,a&&this[x(1233)+x(1583)]()&&!this[x(971)+x(572)]){if(this[x(695)+x(1095)]?.["checkRea"+x(1631)+"es"]()){let l=this[x(695)+x(1095)]?.[x(545)+x(1568)+"nt"]();this[x(905)+x(1470)+x(1723)](e[x(864)](Re,e.zBSbu,{code:1006,reason:x(1582)+l+(x(447)+", max re"+x(1767)+x(1386)),wasClean:!0}))}else{let l=this[x(1492)]["reconnec"+x(767)+x(1214)](t,r);this[x(905)+x(1470)+x(1723)](Re(x(380),{code:t,reason:r,wasClean:!0,willReconnect:l})),l&&this[x(1963)]()}return}this[x(1233)+x(1583)]()||this[x(971)+"osed"]?this[x(905)+x(1470)+x(1723)](e[x(579)](Re,e[x(412)],{code:t,reason:"bye"})):this[x(905)+x(1470)+x(1723)](Re(x(380),{code:1006,reason:x(616)+x(1015)+"ork offline"})),this[x(1194)]=null,this[x(695)+x(1095)]?.["resetEndpointCon"+x(473)](),this["_pingLos"+x(930)]?.[x(709)+x(1881)]()}["_dispatc"+n(643)+"nt"](t){let r=n;if(e[r(1051)]("bLmWX",r(1858))){if(!this[r(1963)+r(1724)]){let a="3|2|4|1|0"[r(675)]("|"),x=0;for(;;){switch(a[x++]){case"0":this[r(1963)]();continue;case"1":this[r(1088)]=!0;continue;case"2":this[r(1829)+r(930)]?.["resetCou"+r(1881)]();continue;case"3":this[r(695)+r(1095)]?.[r(1467)+r(819)+r(473)]();continue;case"4":this[r(971)+r(572)]=!1;continue}break}}}else this.emit(e[r(1177)],t),this[r(1176)]&&this[r(1176)](t)}[n(905)+n(1441)+n(1220)](t){let r=n;this.emit(e[r(1174)],t),this.onmessage&&this.onmessage(t)}[n(905)+n(1234)+n(1289)](t){let r=n,a={nvMGP:function(x,f,l,w){return e.QDDXy(x,f,l,w)},ZveGN:e[r(458)],QLgwL:e.IQgEZ,vpQOv:function(x,f){return x||f},oLrnx:function(x){return e.kmPBZ(x)}};if(e.iCCeE(r(415),e[r(1636)])){let{enableAutoAck:x}=this[r(1492)],f=eTvhEp.nvMGP(_0x3ab4d8,_0x23ef2c[r(1372)][r(1401)],eTvhEp[r(1927)],"1"),l=eTvhEp[r(408)](_0x3c4b24,_0x25921f[r(1372)][r(1401)],r(612),"1"),w=_0x46e57b[r(1045)](this,_0x2c0295);if(x&&f){let{SeqID:h,LogID:v,service:k,LogIDNew:R,method:B}=_0x1d2aa1[r(1372)];this[r(874)]({SeqID:h,LogID:v,LogIDNew:R,service:k,method:B,headers:[{key:eTvhEp[r(800)],value:"1"},{key:r(1705),value:eTvhEp[r(759)](R,"")},{key:"ack_code",value:"0"}]})}l&&!w[r(1728)]&&this[r(905)+r(1234)+r(1289)](_0x24a30b),eTvhEp[r(580)](_0x9aa229)}else this[r(854)](e[r(635)],t),this["onReceiv"+r(342)]&&this["onReceiv"+r(342)](t)}[n(905)+"hErrorEv"+n(1723)](t){let r=n;this.emit(e[r(724)],t),this.onerror&&this[r(1634)](t)}[n(905)+n(1470)+"ent"](t){let r=n;if(r(987)===e[r(750)])return this[r(1440)].isReady;this.emit(e.zBSbu,t),this.onclose&&this[r(1479)](t)}get[n(435)+"pe"](){let t=n;if(e[t(1087)](e[t(620)],e[t(620)])){let r=t(1582)+_0x1bf76f+(" fail, max retri"+t(1871)+"ed");this[t(905)+t(1353)+"ent"](e[t(1402)](_0x375723,e[t(724)],{message:r,code:_0x4dbb82[t(1281)+t(1010)+"R"],error:_0x975757}));return}else return this._ws?this[t(1194)][t(435)+"pe"]:this[t(967)+"ype"]}set[n(435)+"pe"](t){let r=n,a={kNVEv:function(x,f){return x(f)},oUeom:r(832)+r(1465)};e[r(1691)](r(1654),e.VXMpp)?(_0x23b4e5[r(1929)+"JSONP"]=void 0,ZxaSsv[r(407)](_0x5168bb,ZxaSsv[r(1438)])):(this[r(967)+r(1913)]=t,this[r(1194)]&&(this[r(1194)][r(435)+"pe"]=t))}get retryCount(){let t=n;return this["_endpoin"+t(1095)]?.[t(545)+t(1568)+t(1247)+t(521)]()||0}get[n(1451)+n(571)](){let t=n,r=this[t(798)+t(1027)][t(550)]((a,x)=>(a+=x&&x[t(1241)+"th"]||0,a),0);return e[t(865)](r,this[t(1194)]?this[t(1194)]["buffered"+t(571)]:0)}get extensions(){let t=n;if(e[t(983)](e[t(790)],"zmecZ"))return this[t(1194)]?this[t(1194)][t(763)+"ns"]:"";{let r=e[t(1557)](_0x2be939,_0x3077ee,_0x333021);return _0x49feef[t(1065)][t(1713)](r,e[t(1933)](r,_0x24ccd5))}}get[n(1526)](){let t=n;return this[t(1194)]?this[t(1194)][t(1526)]:""}get[n(1633)+"te"](){let t=n;return this._ws?this[t(1194)][t(1633)+"te"]:this[t(1492)][t(613)+"cOpen"]?this.CONNECTING:this[t(366)]}get[n(430)](){let t=n;return this[t(1194)]?this[t(1194)].url:this[t(517)]}close(t=1e3,r){let a=n;if(e[a(1511)](a(1291),e.JrKtI)){let x=e[a(1773)][a(675)]("|"),f=0;for(;;){switch(x[f++]){case"0":this[a(1468)+a(1576)]();continue;case"1":this[a(1264)+a(1212)]?.[a(1420)]();continue;case"2":if(this[a(1194)][a(1633)+"te"]===this[a(366)]||e[a(758)](this._ws[a(1633)+"te"],this[a(1048)]))return void this[a(1277)](a(870)+"s already closed");continue;case"3":this["_clearTi"+a(969)]();continue;case"4":this["_readyCl"+a(572)]=!0;continue;case"5":if(!this._ws)return void this[a(1277)](e[a(370)]);continue;case"6":this[a(1882)+a(1639)+"t"](t,r);continue;case"7":this[a(1452)+a(791)+"Listener"]();continue}break}}else{let{SeqID:x,LogID:f,service:l,LogIDNew:w,method:h}=_0x38da54[a(1372)];this[a(874)]({SeqID:x,LogID:f,LogIDNew:w,service:l,method:h,headers:[{key:e[a(1364)],value:"1"},{key:e.MPZKg,value:w||""},{key:e[a(840)],value:"0"}]})}}async[n(1316)](t,r){let a=n,x={XZfrl:function(H,ve){return e[D(1537)](H,ve)},QAgyn:function(H,ve){return e.VeInl(H,ve)},xwrod:function(H,ve){return e[D(1848)](H,ve)}};if(e.rlNTB(null,t))throw new Error(e[a(817)]);e[a(814)](e[a(1957)],typeof t)&&(t=JSON[a(1926)+"y"](t)),e[a(756)](e[a(666)],typeof t)&&!(t instanceof ArrayBuffer)&&!(t[a(1816)]&&e[a(1294)](t.buffer,ArrayBuffer))&&(t=JSON[a(1926)+"y"](t));let f=await xs(t),l=e[a(419)]($c,t),{method:w=0,service:h=this[a(1492)][a(1208)],logID:v=this._options[a(1488)+a(731)](),headers:k=this[a(1492)].headers,payloadEncoding:R=this[a(1492)][a(1566)+a(1428)],payloadType:B=this._options[a(1092)+"ype"],logIDNew:A=this[a(1492)][a(1429)+a(721)][a(1669)+a(1301)+a(461)+"ew"]?e[a(714)](o,this._options[a(1429)+a(721)][a(1387)]):""}=e.bwYUg(r,{});if(!h)throw new Error(e.ZpNhZ);let O={SeqID:J[a(1302)+"er"](this[a(844)]++),LogID:J.fromNumber(v),service:h,method:w,headers:k,payloadEncoding:R instanceof Object?R.encoding?R[a(1477)]:"":R,payloadType:B instanceof Object?B[a(1124)]?B[a(1124)]:l:B||l,payload:f,LogIDNew:A},F=e[a(1565)](ie,O);if(this[a(1194)]&&e.kqpbU(this[a(1194)][a(1633)+"te"],this[a(1770)])){if(e[a(1128)]===e.SCBDe)return a(1929)+"_"+this[a(1599)];this._ws&&this[a(1194)][a(1316)](F),this[a(1277)](e.znuQB,O)}else if(e[a(656)](this[a(798)+a(1027)][a(1804)],this[a(1492)][a(868)+a(1535)+a(1392)]))if(e[a(728)](a(1162),e[a(1421)]))this[a(798)+a(1027)].push(F),this[a(1277)](e[a(1624)],O);else{let{initReconnectInterval:H,maxReconnectInterval:ve,reconnectIntervalGrowFactor:At}=this[a(1492)],wn=lUnzdn[a(932)](H,_0x3e393a[a(668)](At,_0x34d6ac-1));return lUnzdn.QAgyn(wn,ve)?ve:wn}else e[a(1907)]===e[a(1682)]?(lUnzdn.xwrod(_0x8ad71c,this[a(1963)+a(1012)+"utId"]),this["_connect"+a(1012)+a(1681)]=null):(this[a(798)+"Queue"].shift(),this["_message"+a(1027)][a(1274)](F));return{seqID:this[a(844)],logID:v,logIDNew:A}}async[n(1126)+"t"](t){let r=n,{url:a}=e.EhelK(t,{}),x=Array[r(1356)](a)?a:e[r(581)](r(1525),typeof a)?[a]:[];t&&Object[r(856)](this[r(1492)],t),x&&x[r(1804)]?this[r(695)+"tManager"]=new ss(x,this[r(1492)][r(924)+"es"]):this[r(695)+"tManager"]?.[r(1467)+"pointCon"+r(473)](),this[r(1829)+r(930)]?.["resetCou"+r(1881)](this[r(1492)][r(672)+r(445)]),this["_readyCl"+r(572)]=!1,this[r(1194)]&&this[r(1194)][r(1633)+"te"]!==this.CLOSED?this["_disconn"+r(744)](1e3,e.fhFWa,!0):(this[r(1088)]=!0,this._connect())}async[n(361)](){let t=n;if(!this[t(1963)+t(1724)]){let r=e[t(1512)][t(675)]("|"),a=0;for(;;){switch(r[a++]){case"0":this[t(695)+"tManager"]?.[t(1467)+t(819)+t(473)]();continue;case"1":this[t(971)+"osed"]=!1;continue;case"2":this._isInit=!0;continue;case"3":this[t(1963)]();continue;case"4":this[t(1829)+t(930)]?.[t(709)+t(1881)]();continue}break}}}[n(597)+n(667)](t,r){let a=n;if(e[a(1707)]("OquUf",e[a(821)]))this.on(t,r);else try{return!!this._qosDB}catch(x){return _0x5228ab[a(1024)](x),!1}}[n(1454)+"Event"](t){let r=n,a={FRaKF:function(x,f){return e[D(1722)](x,f)},YoDct:function(x,f){return e.ThBfU(x,f)},HNQof:function(x,f){return x+f},ziLTy:function(x,f){return e[D(385)](x,f)}};if(e[r(629)]!==r(1139))return uMxSGf[r(1018)](-1,this[r(1425)])&&this.high===-1?_0x4ca5f9[r(1714)](0,0,this.unsigned):uMxSGf[r(1753)](-1,this[r(1425)])?_0x2c0da4[r(1714)](0,uMxSGf[r(889)](this[r(1642)],1),this[r(1171)]):_0x539902.fromBits(uMxSGf.ziLTy(this[r(1425)],1),this[r(1642)],this[r(1171)]);{let{type:x}=t;this[r(854)](x,t)}}[n(1531)+"entListe"+n(1315)](t,r){this[n(1912)](t,r)}[n(820)](){let t=n,r={GQpxi:"ping_once_success",rCNrO:t(596)+"e_timeout",LzjuO:e[t(1193)],OckPF:function(a,x,f){return e[t(975)](a,x,f)}};return new Promise((a,x)=>{let f=t;this[f(1468)+f(1576)](),this["_pingPon"+f(638)+"Id"]=r.OckPF(setTimeout,this._ping[f(1068)](this),this[f(1492)]["pingInte"+f(631)]);let l=()=>{let h=f;a("success"),this[h(1912)](r.GQpxi,l),this.off(r[h(1324)],w)},w=()=>{let h=f;x(r[h(1502)]),this[h(1912)](r[h(1053)],l),this[h(1912)](r[h(1324)],w)};this.on(r[f(1053)],l),this.on(r[f(1324)],w),this[f(603)]()})}}})(),oe.CustomCloseEvent=ne[I(1794)+I(395)],oe[I(665)+I(885)]=ne[I(665)+I(885)],oe[I(1058)+"e"]=ne[I(1058)+"e"],oe[I(1220)]=ne.Event,oe[I(1407)]=ne[I(1407)],oe[I(562)+"MessageEvent"]=ne["Frontier"+I(554)+I(443)],oe[I(554)+I(443)]=ne[I(554)+I(443)],oe[I(947)+"t"]=ne[I(947)+"t"],oe[I(1960)+"tEvent"]=ne["Reconnec"+I(972)],oe[I(934)+"oseEvent"]=ne[I(934)+"oseEvent"],oe[I(1575)+"rorEvent"]=ne["createEr"+I(885)],oe.createMessageEvent=ne["createMe"+I(601)+"nt"],oe[I(1085)+I(1149)]=ne[I(1085)+"enEvent"],oe[I(676)+I(1195)+I(443)]=ne[I(676)+"connectEvent"],oe[I(1939)+I(1761)]=ne["decodedF"+I(1761)],oe[I(615)+"ame"]=ne[I(615)+I(1280)];for(Xn in ne)[I(1794)+"oseEvent",I(665)+I(885),I(1058)+"e","Event",I(1407),I(562)+"MessageE"+I(443),I(554)+I(443),I(947)+"t",I(1960)+I(972),"createCloseEvent","createEr"+I(885),I(869)+I(601)+"nt",I(1085)+I(1149),I(676)+"connectE"+I(443),"decodedF"+I(1761),"encodeFr"+I(1280)][I(991)](Xn)===-1&&(oe[Xn]=ne[Xn]);var Xn;Object[I(1439)+I(1698)](oe,I(964)+"le",{value:!0})});var $e=ye((t_,na)=>{"use strict";var ea=["nodebuffer","arraybuffer","fragments"],ta=typeof Blob<"u";ta&&ea.push("blob");na.exports={BINARY_TYPES:ea,CLOSE_TIMEOUT:3e4,EMPTY_BUFFER:Buffer.alloc(0),GUID:"258EAFA5-E914-47DA-95CA-C5AB0DC85B11",hasBlob:ta,kForOnEventAttribute:Symbol("kIsForOnEventAttribute"),kListener:Symbol("kListener"),kStatusCode:Symbol("status-code"),kWebSocket:Symbol("websocket"),NOOP:()=>{}}});var cn=ye((n_,ir)=>{"use strict";var{EMPTY_BUFFER:sf}=$e(),ui=Buffer[Symbol.species];function of(n,e){if(n.length===0)return sf;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 ui(s.buffer,s.byteOffset,o):s}function ra(n,e,s,o,c){for(let d=0;d<c;d++)s[o+d]=n[d]^e[d&3]}function ia(n,e){for(let s=0;s<n.length;s++)n[s]^=e[s&3]}function af(n){return n.length===n.buffer.byteLength?n.buffer:n.buffer.slice(n.byteOffset,n.byteOffset+n.length)}function fi(n){if(fi.readOnly=!0,Buffer.isBuffer(n))return n;let e;return n instanceof ArrayBuffer?e=new ui(n):ArrayBuffer.isView(n)?e=new ui(n.buffer,n.byteOffset,n.byteLength):(e=Buffer.from(n),fi.readOnly=!1),e}ir.exports={concat:of,mask:ra,toArrayBuffer:af,toBuffer:fi,unmask:ia};if(!process.env.WS_NO_BUFFER_UTIL)try{let n=te("bufferutil");ir.exports.mask=function(e,s,o,c,d){d<48?ra(e,s,o,c,d):n.mask(e,s,o,c,d)},ir.exports.unmask=function(e,s){e.length<32?ia(e,s):n.unmask(e,s)}}catch{}});var aa=ye((r_,oa)=>{"use strict";var sa=Symbol("kDone"),li=Symbol("kRun"),gi=class{constructor(e){this[sa]=()=>{this.pending--,this[li]()},this.concurrency=e||1/0,this.jobs=[],this.pending=0}add(e){this.jobs.push(e),this[li]()}[li](){if(this.pending!==this.concurrency&&this.jobs.length){let e=this.jobs.shift();this.pending++,e(this[sa])}}};oa.exports=gi});var zt=ye((i_,ua)=>{"use strict";var xn=te("zlib"),ca=cn(),cf=aa(),{kStatusCode:xa}=$e(),xf=Buffer[Symbol.species],df=Buffer.from([0,0,255,255]),or=Symbol("permessage-deflate"),Ve=Symbol("total-length"),Bt=Symbol("callback"),xt=Symbol("buffers"),Mt=Symbol("error"),sr,hi=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,!sr){let s=this._options.concurrencyLimit!==void 0?this._options.concurrencyLimit:10;sr=new cf(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){sr.add(c=>{this._decompress(e,s,(d,u)=>{c(),o(d,u)})})}compress(e,s,o){sr.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"?xn.Z_DEFAULT_WINDOWBITS:this.params[d];this._inflate=xn.createInflateRaw({...this._options.zlibInflateOptions,windowBits:u}),this._inflate[or]=this,this._inflate[Ve]=0,this._inflate[xt]=[],this._inflate.on("error",ff),this._inflate.on("data",da)}this._inflate[Bt]=o,this._inflate.write(e),s&&this._inflate.write(df),this._inflate.flush(()=>{let d=this._inflate[Mt];if(d){this._inflate.close(),this._inflate=null,o(d);return}let u=ca.concat(this._inflate[xt],this._inflate[Ve]);this._inflate._readableState.endEmitted?(this._inflate.close(),this._inflate=null):(this._inflate[Ve]=0,this._inflate[xt]=[],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"?xn.Z_DEFAULT_WINDOWBITS:this.params[d];this._deflate=xn.createDeflateRaw({...this._options.zlibDeflateOptions,windowBits:u}),this._deflate[Ve]=0,this._deflate[xt]=[],this._deflate.on("data",uf)}this._deflate[Bt]=o,this._deflate.write(e),this._deflate.flush(xn.Z_SYNC_FLUSH,()=>{if(!this._deflate)return;let d=ca.concat(this._deflate[xt],this._deflate[Ve]);s&&(d=new xf(d.buffer,d.byteOffset,d.length-4)),this._deflate[Bt]=null,this._deflate[Ve]=0,this._deflate[xt]=[],s&&this.params[`${c}_no_context_takeover`]&&this._deflate.reset(),o(null,d)})}};ua.exports=hi;function uf(n){this[xt].push(n),this[Ve]+=n.length}function da(n){if(this[Ve]+=n.length,this[or]._maxPayload<1||this[Ve]<=this[or]._maxPayload){this[xt].push(n);return}this[Mt]=new RangeError("Max payload size exceeded"),this[Mt].code="WS_ERR_UNSUPPORTED_MESSAGE_LENGTH",this[Mt][xa]=1009,this.removeListener("data",da),this.reset()}function ff(n){if(this[or]._inflate=null,this[Mt]){this[Bt](this[Mt]);return}n[xa]=1007,this[Bt](n)}});var Ft=ye((s_,ar)=>{"use strict";var{isUtf8:fa}=te("buffer"),{hasBlob:lf}=$e(),gf=[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 hf(n){return n>=1e3&&n<=1014&&n!==1004&&n!==1005&&n!==1006||n>=3e3&&n<=4999}function pi(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 pf(n){return lf&&typeof n=="object"&&typeof n.arrayBuffer=="function"&&typeof n.type=="string"&&typeof n.stream=="function"&&(n[Symbol.toStringTag]==="Blob"||n[Symbol.toStringTag]==="File")}ar.exports={isBlob:pf,isValidStatusCode:hf,isValidUTF8:pi,tokenChars:gf};if(fa)ar.exports.isValidUTF8=function(n){return n.length<24?pi(n):fa(n)};else if(!process.env.WS_NO_UTF_8_VALIDATE)try{let n=te("utf-8-validate");ar.exports.isValidUTF8=function(e){return e.length<32?pi(e):n(e)}}catch{}});var bi=ye((o_,_a)=>{"use strict";var{Writable:mf}=te("stream"),la=zt(),{BINARY_TYPES:wf,EMPTY_BUFFER:ga,kStatusCode:_f,kWebSocket:yf}=$e(),{concat:mi,toArrayBuffer:bf,unmask:vf}=cn(),{isValidStatusCode:Sf,isValidUTF8:ha}=Ft(),cr=Buffer[Symbol.species],ke=0,pa=1,ma=2,wa=3,wi=4,_i=5,xr=6,yi=class extends mf{constructor(e={}){super(),this._allowSynchronousEvents=e.allowSynchronousEvents!==void 0?e.allowSynchronousEvents:!0,this._binaryType=e.binaryType||wf[0],this._extensions=e.extensions||{},this._isServer=!!e.isServer,this._maxPayload=e.maxPayload|0,this._skipUTF8Validation=!!e.skipUTF8Validation,this[yf]=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=ke}_write(e,s,o){if(this._opcode===8&&this._state==ke)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 cr(o.buffer,o.byteOffset+e,o.length-e),new cr(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 cr(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 ke:this.getInfo(e);break;case pa:this.getPayloadLength16(e);break;case ma:this.getPayloadLength64(e);break;case wa:this.getMask();break;case wi:this.getData(e);break;case _i:case xr: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[la.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=pa:this._payloadLength===127?this._state=ma: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=wa:this._state=wi}getMask(){if(this._bufferedBytes<4){this._loop=!1;return}this._mask=this.consume(4),this._state=wi}getData(e){let s=ga;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&&vf(s,this._mask)}if(this._opcode>7){this.controlMessage(s,e);return}if(this._compressed){this._state=_i,this.decompress(s,e);return}s.length&&(this._messageLength=this._totalPayloadLength,this._fragments.push(s)),this.dataMessage(e)}decompress(e,s){this._extensions[la.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===ke&&this.startLoop(s)})}dataMessage(e){if(!this._fin){this._state=ke;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=mi(o,s):this._binaryType==="arraybuffer"?c=bf(mi(o,s)):this._binaryType==="blob"?c=new Blob(o):c=o,this._allowSynchronousEvents?(this.emit("message",c,!0),this._state=ke):(this._state=xr,setImmediate(()=>{this.emit("message",c,!0),this._state=ke,this.startLoop(e)}))}else{let c=mi(o,s);if(!this._skipUTF8Validation&&!ha(c)){let d=this.createError(Error,"invalid UTF-8 sequence",!0,1007,"WS_ERR_INVALID_UTF8");e(d);return}this._state===_i||this._allowSynchronousEvents?(this.emit("message",c,!1),this._state=ke):(this._state=xr,setImmediate(()=>{this.emit("message",c,!1),this._state=ke,this.startLoop(e)}))}}controlMessage(e,s){if(this._opcode===8){if(e.length===0)this._loop=!1,this.emit("conclude",1005,ga),this.end();else{let o=e.readUInt16BE(0);if(!Sf(o)){let d=this.createError(RangeError,`invalid status code ${o}`,!0,1002,"WS_ERR_INVALID_CLOSE_CODE");s(d);return}let c=new cr(e.buffer,e.byteOffset+2,e.length-2);if(!this._skipUTF8Validation&&!ha(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=ke;return}this._allowSynchronousEvents?(this.emit(this._opcode===9?"ping":"pong",e),this._state=ke):(this._state=xr,setImmediate(()=>{this.emit(this._opcode===9?"ping":"pong",e),this._state=ke,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[_f]=c,u}};_a.exports=yi});var Ei=ye((c_,va)=>{"use strict";var{Duplex:a_}=te("stream"),{randomFillSync:Ef}=te("crypto"),ya=zt(),{EMPTY_BUFFER:Af,kWebSocket:If,NOOP:Cf}=$e(),{isBlob:Ut,isValidStatusCode:Pf}=Ft(),{mask:ba,toBuffer:gt}=cn(),Te=Symbol("kByteLength"),kf=Buffer.alloc(4),dr=8*1024,ht,qt=dr,Le=0,Tf=1,Df=2,vi=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=Le,this.onerror=Cf,this[If]=void 0}static frame(e,s){let o,c=!1,d=2,u=!1;s.mask&&(o=s.maskBuffer||kf,s.generateMask?s.generateMask(o):(qt===dr&&(ht===void 0&&(ht=Buffer.alloc(dr)),Ef(ht,0,dr),qt=0),o[0]=ht[qt++],o[1]=ht[qt++],o[2]=ht[qt++],o[3]=ht[qt++]),u=(o[0]|o[1]|o[2]|o[3])===0,d=6);let g;typeof e=="string"?(!s.mask||u)&&s[Te]!==void 0?g=s[Te]:(e=Buffer.from(e),g=e.length):(g=e.length,c=s.mask&&s.readOnly&&!u);let p=g;g>=65536?(d+=8,p=127):g>125&&(d+=2,p=126);let m=Buffer.allocUnsafe(c?g+d:d);return m[0]=s.fin?s.opcode|128:s.opcode,s.rsv1&&(m[0]|=64),m[1]=p,p===126?m.writeUInt16BE(g,2):p===127&&(m[2]=m[3]=0,m.writeUIntBE(g,4,6)),s.mask?(m[1]|=128,m[d-4]=o[0],m[d-3]=o[1],m[d-2]=o[2],m[d-1]=o[3],u?[m,e]:c?(ba(e,o,m,d,g),[m]):(ba(e,o,e,0,g),[m,e])):[m,e]}close(e,s,o,c){let d;if(e===void 0)d=Af;else{if(typeof e!="number"||!Pf(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 g=Buffer.byteLength(s);if(g>123)throw new RangeError("The message must not be greater than 123 bytes");d=Buffer.allocUnsafe(2+g),d.writeUInt16BE(e,0),typeof s=="string"?d.write(s,2):d.set(s,2)}}let u={[Te]:d.length,fin:!0,generateMask:this._generateMask,mask:o,maskBuffer:this._maskBuffer,opcode:8,readOnly:!1,rsv1:!1};this._state!==Le?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):Ut(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={[Te]:c,fin:!0,generateMask:this._generateMask,mask:s,maskBuffer:this._maskBuffer,opcode:9,readOnly:d,rsv1:!1};Ut(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,s,o){let c,d;if(typeof e=="string"?(c=Buffer.byteLength(e),d=!1):Ut(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={[Te]:c,fin:!0,generateMask:this._generateMask,mask:s,maskBuffer:this._maskBuffer,opcode:10,readOnly:d,rsv1:!1};Ut(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,s,o){let c=this._extensions[ya.extensionName],d=s.binary?2:1,u=s.compress,g,p;typeof e=="string"?(g=Buffer.byteLength(e),p=!1):Ut(e)?(g=e.size,p=!1):(e=gt(e),g=e.length,p=gt.readOnly),this._firstFragment?(this._firstFragment=!1,u&&c&&c.params[c._isServer?"server_no_context_takeover":"client_no_context_takeover"]&&(u=g>=c._threshold),this._compress=u):(u=!1,d=0),s.fin&&(this._firstFragment=!0);let m={[Te]:g,fin:s.fin,generateMask:this._generateMask,mask:s.mask,maskBuffer:this._maskBuffer,opcode:d,readOnly:p,rsv1:u};Ut(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,s,o,c){this._bufferedBytes+=o[Te],this._state=Df,e.arrayBuffer().then(d=>{if(this._socket.destroyed){let g=new Error("The socket was closed while the blob was being read");process.nextTick(Si,this,g,c);return}this._bufferedBytes-=o[Te];let u=gt(d);s?this.dispatch(u,s,o,c):(this._state=Le,this.sendFrame(n.frame(u,o),c),this.dequeue())}).catch(d=>{process.nextTick(Rf,this,d,c)})}dispatch(e,s,o,c){if(!s){this.sendFrame(n.frame(e,o),c);return}let d=this._extensions[ya.extensionName];this._bufferedBytes+=o[Te],this._state=Tf,d.compress(e,o.fin,(u,g)=>{if(this._socket.destroyed){let p=new Error("The socket was closed while data was being compressed");Si(this,p,c);return}this._bufferedBytes-=o[Te],this._state=Le,o.readOnly=!1,this.sendFrame(n.frame(g,o),c),this.dequeue()})}dequeue(){for(;this._state===Le&&this._queue.length;){let e=this._queue.shift();this._bufferedBytes-=e[3][Te],Reflect.apply(e[0],this,e.slice(1))}}enqueue(e){this._bufferedBytes+=e[3][Te],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)}};va.exports=vi;function Si(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 Rf(n,e,s){Si(n,e,s),n.onerror(e)}});var Da=ye((x_,Ta)=>{"use strict";var{kForOnEventAttribute:dn,kListener:Ai}=$e(),Sa=Symbol("kCode"),Ea=Symbol("kData"),Aa=Symbol("kError"),Ia=Symbol("kMessage"),Ca=Symbol("kReason"),Kt=Symbol("kTarget"),Pa=Symbol("kType"),ka=Symbol("kWasClean"),Ye=class{constructor(e){this[Kt]=null,this[Pa]=e}get target(){return this[Kt]}get type(){return this[Pa]}};Object.defineProperty(Ye.prototype,"target",{enumerable:!0});Object.defineProperty(Ye.prototype,"type",{enumerable:!0});var pt=class extends Ye{constructor(e,s={}){super(e),this[Sa]=s.code===void 0?0:s.code,this[Ca]=s.reason===void 0?"":s.reason,this[ka]=s.wasClean===void 0?!1:s.wasClean}get code(){return this[Sa]}get reason(){return this[Ca]}get wasClean(){return this[ka]}};Object.defineProperty(pt.prototype,"code",{enumerable:!0});Object.defineProperty(pt.prototype,"reason",{enumerable:!0});Object.defineProperty(pt.prototype,"wasClean",{enumerable:!0});var Ht=class extends Ye{constructor(e,s={}){super(e),this[Aa]=s.error===void 0?null:s.error,this[Ia]=s.message===void 0?"":s.message}get error(){return this[Aa]}get message(){return this[Ia]}};Object.defineProperty(Ht.prototype,"error",{enumerable:!0});Object.defineProperty(Ht.prototype,"message",{enumerable:!0});var un=class extends Ye{constructor(e,s={}){super(e),this[Ea]=s.data===void 0?null:s.data}get data(){return this[Ea]}};Object.defineProperty(un.prototype,"data",{enumerable:!0});var Lf={addEventListener(n,e,s={}){for(let c of this.listeners(n))if(!s[dn]&&c[Ai]===e&&!c[dn])return;let o;if(n==="message")o=function(d,u){let g=new un("message",{data:u?d:d.toString()});g[Kt]=this,ur(e,this,g)};else if(n==="close")o=function(d,u){let g=new pt("close",{code:d,reason:u.toString(),wasClean:this._closeFrameReceived&&this._closeFrameSent});g[Kt]=this,ur(e,this,g)};else if(n==="error")o=function(d){let u=new Ht("error",{error:d,message:d.message});u[Kt]=this,ur(e,this,u)};else if(n==="open")o=function(){let d=new Ye("open");d[Kt]=this,ur(e,this,d)};else return;o[dn]=!!s[dn],o[Ai]=e,s.once?this.once(n,o):this.on(n,o)},removeEventListener(n,e){for(let s of this.listeners(n))if(s[Ai]===e&&!s[dn]){this.removeListener(n,s);break}}};Ta.exports={CloseEvent:pt,ErrorEvent:Ht,Event:Ye,EventTarget:Lf,MessageEvent:un};function ur(n,e,s){typeof n=="object"&&n.handleEvent?n.handleEvent.call(n,s):n.call(e,s)}});var fr=ye((d_,Ra)=>{"use strict";var{tokenChars:fn}=Ft();function Ke(n,e,s){n[e]===void 0?n[e]=[s]:n[e].push(s)}function Of(n){let e=Object.create(null),s=Object.create(null),o=!1,c=!1,d=!1,u,g,p=-1,m=-1,_=-1,y=0;for(;y<n.length;y++)if(m=n.charCodeAt(y),u===void 0)if(_===-1&&fn[m]===1)p===-1&&(p=y);else if(y!==0&&(m===32||m===9))_===-1&&p!==-1&&(_=y);else if(m===59||m===44){if(p===-1)throw new SyntaxError(`Unexpected character at index ${y}`);_===-1&&(_=y);let T=n.slice(p,_);m===44?(Ke(e,T,s),s=Object.create(null)):u=T,p=_=-1}else throw new SyntaxError(`Unexpected character at index ${y}`);else if(g===void 0)if(_===-1&&fn[m]===1)p===-1&&(p=y);else if(m===32||m===9)_===-1&&p!==-1&&(_=y);else if(m===59||m===44){if(p===-1)throw new SyntaxError(`Unexpected character at index ${y}`);_===-1&&(_=y),Ke(s,n.slice(p,_),!0),m===44&&(Ke(e,u,s),s=Object.create(null),u=void 0),p=_=-1}else if(m===61&&p!==-1&&_===-1)g=n.slice(p,y),p=_=-1;else throw new SyntaxError(`Unexpected character at index ${y}`);else if(c){if(fn[m]!==1)throw new SyntaxError(`Unexpected character at index ${y}`);p===-1?p=y:o||(o=!0),c=!1}else if(d)if(fn[m]===1)p===-1&&(p=y);else if(m===34&&p!==-1)d=!1,_=y;else if(m===92)c=!0;else throw new SyntaxError(`Unexpected character at index ${y}`);else if(m===34&&n.charCodeAt(y-1)===61)d=!0;else if(_===-1&&fn[m]===1)p===-1&&(p=y);else if(p!==-1&&(m===32||m===9))_===-1&&(_=y);else if(m===59||m===44){if(p===-1)throw new SyntaxError(`Unexpected character at index ${y}`);_===-1&&(_=y);let T=n.slice(p,_);o&&(T=T.replace(/\\/g,""),o=!1),Ke(s,g,T),m===44&&(Ke(e,u,s),s=Object.create(null),u=void 0),g=void 0,p=_=-1}else throw new SyntaxError(`Unexpected character at index ${y}`);if(p===-1||d||m===32||m===9)throw new SyntaxError("Unexpected end of input");_===-1&&(_=y);let S=n.slice(p,_);return u===void 0?Ke(e,S,s):(g===void 0?Ke(s,S,!0):o?Ke(s,g,S.replace(/\\/g,"")):Ke(s,g,S),Ke(e,u,s)),e}function Nf(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(", ")}Ra.exports={format:Nf,parse:Of}});var pr=ye((l_,Ga)=>{"use strict";var Bf=te("events"),Mf=te("https"),zf=te("http"),Na=te("net"),Ff=te("tls"),{randomBytes:Uf,createHash:qf}=te("crypto"),{Duplex:u_,Readable:f_}=te("stream"),{URL:Ii}=te("url"),dt=zt(),Kf=bi(),Hf=Ei(),{isBlob:Gf}=Ft(),{BINARY_TYPES:La,CLOSE_TIMEOUT:jf,EMPTY_BUFFER:lr,GUID:Wf,kForOnEventAttribute:Ci,kListener:Jf,kStatusCode:$f,kWebSocket:de,NOOP:Ba}=$e(),{EventTarget:{addEventListener:Vf,removeEventListener:Yf}}=Da(),{format:Xf,parse:Zf}=fr(),{toBuffer:Qf}=cn(),Ma=Symbol("kAborted"),Pi=[8,13],Xe=["CONNECTING","OPEN","CLOSING","CLOSED"],el=/^[!#$%&'*+\-.0-9A-Z^_`|a-z~]+$/,V=class n extends Bf{constructor(e,s,o){super(),this._binaryType=La[0],this._closeCode=1006,this._closeFrameReceived=!1,this._closeFrameSent=!1,this._closeMessage=lr,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]),za(this,e,s,o)):(this._autoPong=o.autoPong,this._closeTimeout=o.closeTimeout,this._isServer=!0)}get binaryType(){return this._binaryType}set binaryType(e){La.includes(e)&&(this._binaryType=e,this._receiver&&(this._receiver._binaryType=e))}get bufferedAmount(){return this._socket?this._socket._writableState.length+this._sender._bufferedBytes:this._bufferedAmount}get extensions(){return Object.keys(this._extensions).join()}get isPaused(){return this._paused}get onclose(){return null}get onerror(){return null}get onopen(){return null}get onmessage(){return null}get protocol(){return this._protocol}get readyState(){return this._readyState}get url(){return this._url}setSocket(e,s,o){let c=new Kf({allowSynchronousEvents:o.allowSynchronousEvents,binaryType:this.binaryType,extensions:this._extensions,isServer:this._isServer,maxPayload:o.maxPayload,skipUTF8Validation:o.skipUTF8Validation}),d=new Hf(e,this._extensions,o.generateMask);this._receiver=c,this._sender=d,this._socket=e,c[de]=this,d[de]=this,e[de]=this,c.on("conclude",rl),c.on("drain",il),c.on("error",sl),c.on("message",ol),c.on("ping",al),c.on("pong",cl),d.onerror=xl,e.setTimeout&&e.setTimeout(0),e.setNoDelay&&e.setNoDelay(),s.length>0&&e.unshift(s),e.on("close",qa),e.on("data",hr),e.on("end",Ka),e.on("error",Ha),this._readyState=n.OPEN,this.emit("open")}emitClose(){if(!this._socket){this._readyState=n.CLOSED,this.emit("close",this._closeCode,this._closeMessage);return}this._extensions[dt.extensionName]&&this._extensions[dt.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){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,s,!this._isServer,o=>{o||(this._closeFrameSent=!0,(this._closeFrameReceived||this._receiver._writableState.errorEmitted)&&this._socket.end())}),Ua(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){ki(this,e,o);return}s===void 0&&(s=!this._isServer),this._sender.ping(e||lr,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){ki(this,e,o);return}s===void 0&&(s=!this._isServer),this._sender.pong(e||lr,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){ki(this,e,o);return}let c={binary:typeof e!="string",mask:!this._isServer,compress:!0,fin:!0,...s};this._extensions[dt.extensionName]||(c.compress=!1),this._sender.send(e||lr,c,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(V,"CONNECTING",{enumerable:!0,value:Xe.indexOf("CONNECTING")});Object.defineProperty(V.prototype,"CONNECTING",{enumerable:!0,value:Xe.indexOf("CONNECTING")});Object.defineProperty(V,"OPEN",{enumerable:!0,value:Xe.indexOf("OPEN")});Object.defineProperty(V.prototype,"OPEN",{enumerable:!0,value:Xe.indexOf("OPEN")});Object.defineProperty(V,"CLOSING",{enumerable:!0,value:Xe.indexOf("CLOSING")});Object.defineProperty(V.prototype,"CLOSING",{enumerable:!0,value:Xe.indexOf("CLOSING")});Object.defineProperty(V,"CLOSED",{enumerable:!0,value:Xe.indexOf("CLOSED")});Object.defineProperty(V.prototype,"CLOSED",{enumerable:!0,value:Xe.indexOf("CLOSED")});["binaryType","bufferedAmount","extensions","isPaused","protocol","readyState","url"].forEach(n=>{Object.defineProperty(V.prototype,n,{enumerable:!0})});["open","error","close","message"].forEach(n=>{Object.defineProperty(V.prototype,`on${n}`,{enumerable:!0,get(){for(let e of this.listeners(n))if(e[Ci])return e[Jf];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})}})});V.prototype.addEventListener=Vf;V.prototype.removeEventListener=Yf;Ga.exports=V;function za(n,e,s,o){let c={allowSynchronousEvents:!0,autoPong:!0,closeTimeout:jf,protocolVersion:Pi[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,!Pi.includes(c.protocolVersion))throw new RangeError(`Unsupported protocol version: ${c.protocolVersion} (supported versions: ${Pi.join(", ")})`);let d;if(e instanceof Ii)d=e;else try{d=new Ii(e)}catch{throw new SyntaxError(`Invalid URL: ${e}`)}d.protocol==="http:"?d.protocol="ws:":d.protocol==="https:"&&(d.protocol="wss:"),n._url=d.href;let u=d.protocol==="wss:",g=d.protocol==="ws+unix:",p;if(d.protocol!=="ws:"&&!u&&!g?p=`The URL's protocol must be one of "ws:", "wss:", "http:", "https:", or "ws+unix:"`:g&&!d.pathname?p="The URL's pathname is empty":d.hash&&(p="The URL contains a fragment identifier"),p){let P=new SyntaxError(p);if(n._redirects===0)throw P;gr(n,P);return}let m=u?443:80,_=Uf(16).toString("base64"),y=u?Mf.request:zf.request,S=new Set,T;if(c.createConnection=c.createConnection||(u?nl:tl),c.defaultPort=c.defaultPort||m,c.port=d.port||m,c.host=d.hostname.startsWith("[")?d.hostname.slice(1,-1):d.hostname,c.headers={...c.headers,"Sec-WebSocket-Version":c.protocolVersion,"Sec-WebSocket-Key":_,Connection:"Upgrade",Upgrade:"websocket"},c.path=d.pathname+d.search,c.timeout=c.handshakeTimeout,c.perMessageDeflate&&(T=new dt({...c.perMessageDeflate,isServer:!1,maxPayload:c.maxPayload}),c.headers["Sec-WebSocket-Extensions"]=Xf({[dt.extensionName]:T.offer()})),s.length){for(let P of s){if(typeof P!="string"||!el.test(P)||S.has(P))throw new SyntaxError("An invalid or duplicated subprotocol was specified");S.add(P)}c.headers["Sec-WebSocket-Protocol"]=s.join(",")}if(c.origin&&(c.protocolVersion<13?c.headers["Sec-WebSocket-Origin"]=c.origin:c.headers.Origin=c.origin),(d.username||d.password)&&(c.auth=`${d.username}:${d.password}`),g){let P=c.path.split(":");c.socketPath=P[0],c.path=P[1]}let C;if(c.followRedirects){if(n._redirects===0){n._originalIpc=g,n._originalSecure=u,n._originalHostOrSocketPath=g?c.socketPath:d.host;let P=o&&o.headers;if(o={...o,headers:{}},P)for(let[j,Q]of Object.entries(P))o.headers[j.toLowerCase()]=Q}else if(n.listenerCount("redirect")===0){let P=g?n._originalIpc?c.socketPath===n._originalHostOrSocketPath:!1:n._originalIpc?!1:d.host===n._originalHostOrSocketPath;(!P||n._originalSecure&&!u)&&(delete c.headers.authorization,delete c.headers.cookie,P||delete c.headers.host,c.auth=void 0)}c.auth&&!o.headers.authorization&&(o.headers.authorization="Basic "+Buffer.from(c.auth).toString("base64")),C=n._req=y(c),n._redirects&&n.emit("redirect",n.url,C)}else C=n._req=y(c);c.timeout&&C.on("timeout",()=>{Ae(n,C,"Opening handshake has timed out")}),C.on("error",P=>{C===null||C[Ma]||(C=n._req=null,gr(n,P))}),C.on("response",P=>{let j=P.headers.location,Q=P.statusCode;if(j&&c.followRedirects&&Q>=300&&Q<400){if(++n._redirects>c.maxRedirects){Ae(n,C,"Maximum redirects exceeded");return}C.abort();let W;try{W=new Ii(j,e)}catch{let ae=new SyntaxError(`Invalid URL: ${j}`);gr(n,ae);return}za(n,W,s,o)}else n.emit("unexpected-response",C,P)||Ae(n,C,`Unexpected server response: ${P.statusCode}`)}),C.on("upgrade",(P,j,Q)=>{if(n.emit("upgrade",P),n.readyState!==V.CONNECTING)return;C=n._req=null;let W=P.headers.upgrade;if(W===void 0||W.toLowerCase()!=="websocket"){Ae(n,j,"Invalid Upgrade header");return}let Y=qf("sha1").update(_+Wf).digest("base64");if(P.headers["sec-websocket-accept"]!==Y){Ae(n,j,"Invalid Sec-WebSocket-Accept header");return}let ae=P.headers["sec-websocket-protocol"],ce;if(ae!==void 0?S.size?S.has(ae)||(ce="Server sent an invalid subprotocol"):ce="Server sent a subprotocol but none was requested":S.size&&(ce="Server sent no subprotocol"),ce){Ae(n,j,ce);return}ae&&(n._protocol=ae);let De=P.headers["sec-websocket-extensions"];if(De!==void 0){if(!T){Ae(n,j,"Server sent a Sec-WebSocket-Extensions header but no extension was requested");return}let me;try{me=Zf(De)}catch{Ae(n,j,"Invalid Sec-WebSocket-Extensions header");return}let ue=Object.keys(me);if(ue.length!==1||ue[0]!==dt.extensionName){Ae(n,j,"Server indicated an extension that was not requested");return}try{T.accept(me[dt.extensionName])}catch{Ae(n,j,"Invalid Sec-WebSocket-Extensions header");return}n._extensions[dt.extensionName]=T}n.setSocket(j,Q,{allowSynchronousEvents:c.allowSynchronousEvents,generateMask:c.generateMask,maxPayload:c.maxPayload,skipUTF8Validation:c.skipUTF8Validation})}),c.finishRequest?c.finishRequest(C,n):C.end()}function gr(n,e){n._readyState=V.CLOSING,n._errorEmitted=!0,n.emit("error",e),n.emitClose()}function tl(n){return n.path=n.socketPath,Na.connect(n)}function nl(n){return n.path=void 0,!n.servername&&n.servername!==""&&(n.servername=Na.isIP(n.host)?"":n.host),Ff.connect(n)}function Ae(n,e,s){n._readyState=V.CLOSING;let o=new Error(s);Error.captureStackTrace(o,Ae),e.setHeader?(e[Ma]=!0,e.abort(),e.socket&&!e.socket.destroyed&&e.socket.destroy(),process.nextTick(gr,n,o)):(e.destroy(o),e.once("error",n.emit.bind(n,"error")),e.once("close",n.emitClose.bind(n)))}function ki(n,e,s){if(e){let o=Gf(e)?e.size:Qf(e).length;n._socket?n._sender._bufferedBytes+=o:n._bufferedAmount+=o}if(s){let o=new Error(`WebSocket is not open: readyState ${n.readyState} (${Xe[n.readyState]})`);process.nextTick(s,o)}}function rl(n,e){let s=this[de];s._closeFrameReceived=!0,s._closeMessage=e,s._closeCode=n,s._socket[de]!==void 0&&(s._socket.removeListener("data",hr),process.nextTick(Fa,s._socket),n===1005?s.close():s.close(n,e))}function il(){let n=this[de];n.isPaused||n._socket.resume()}function sl(n){let e=this[de];e._socket[de]!==void 0&&(e._socket.removeListener("data",hr),process.nextTick(Fa,e._socket),e.close(n[$f])),e._errorEmitted||(e._errorEmitted=!0,e.emit("error",n))}function Oa(){this[de].emitClose()}function ol(n,e){this[de].emit("message",n,e)}function al(n){let e=this[de];e._autoPong&&e.pong(n,!this._isServer,Ba),e.emit("ping",n)}function cl(n){this[de].emit("pong",n)}function Fa(n){n.resume()}function xl(n){let e=this[de];e.readyState!==V.CLOSED&&(e.readyState===V.OPEN&&(e._readyState=V.CLOSING,Ua(e)),this._socket.end(),e._errorEmitted||(e._errorEmitted=!0,e.emit("error",n)))}function Ua(n){n._closeTimer=setTimeout(n._socket.destroy.bind(n._socket),n._closeTimeout)}function qa(){let n=this[de];if(this.removeListener("close",qa),this.removeListener("data",hr),this.removeListener("end",Ka),n._readyState=V.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",Oa),n._receiver.on("finish",Oa))}function hr(n){this[de]._receiver.write(n)||this.pause()}function Ka(){let n=this[de];n._readyState=V.CLOSING,n._receiver.end(),this.end()}function Ha(){let n=this[de];this.removeListener("error",Ha),this.on("error",Ba),n&&(n._readyState=V.CLOSING,this.destroy())}});var $a=ye((h_,Ja)=>{"use strict";var g_=pr(),{Duplex:dl}=te("stream");function ja(n){n.emit("close")}function ul(){!this.destroyed&&this._writableState.finished&&this.destroy()}function Wa(n){this.removeListener("error",Wa),this.destroy(),this.listenerCount("error")===0&&this.emit("error",n)}function fl(n,e){let s=!0,o=new dl({...e,autoDestroy:!1,emitClose:!1,objectMode:!1,writableObjectMode:!1});return n.on("message",function(d,u){let g=!u&&o._readableState.objectMode?d.toString():d;o.push(g)||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(ja,o);return}let u=!1;n.once("error",function(p){u=!0,d(p)}),n.once("close",function(){u||d(c),process.nextTick(ja,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",ul),o.on("error",Wa),o}Ja.exports=fl});var Ti=ye((p_,Va)=>{"use strict";var{tokenChars:ll}=Ft();function gl(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&&ll[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 g=n.slice(s,o);if(e.has(g))throw new SyntaxError(`The "${g}" subprotocol is duplicated`);e.add(g),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}Va.exports={parse:gl}});var nc=ye((w_,tc)=>{"use strict";var hl=te("events"),mr=te("http"),{Duplex:m_}=te("stream"),{createHash:pl}=te("crypto"),Ya=fr(),mt=zt(),ml=Ti(),wl=pr(),{CLOSE_TIMEOUT:_l,GUID:yl,kWebSocket:bl}=$e(),vl=/^[+/0-9A-Za-z]{22}==$/,Xa=0,Za=1,ec=2,Di=class extends hl{constructor(e,s){if(super(),e={allowSynchronousEvents:!0,autoPong:!0,maxPayload:100*1024*1024,skipUTF8Validation:!1,perMessageDeflate:!1,handleProtocols:null,clientTracking:!0,closeTimeout:_l,verifyClient:null,noServer:!1,backlog:null,server:null,host:null,path:null,port:null,WebSocket:wl,...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=mr.createServer((o,c)=>{let d=mr.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=Sl(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=Xa}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===ec){e&&this.once("close",()=>{e(new Error("The server is not running"))}),process.nextTick(ln,this);return}if(e&&this.once("close",e),this._state!==Za)if(this._state=Za,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(ln,this):process.nextTick(ln,this);else{let s=this._server;this._removeListeners(),this._removeListeners=this._server=null,s.close(()=>{ln(this)})}}shouldHandle(e){if(this.options.path){let s=e.url.indexOf("?");if((s!==-1?e.url.slice(0,s):e.url)!==this.options.path)return!1}return!0}handleUpgrade(e,s,o,c){s.on("error",Qa);let d=e.headers["sec-websocket-key"],u=e.headers.upgrade,g=+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||!vl.test(d)){wt(this,e,s,400,"Missing or invalid Sec-WebSocket-Key header");return}if(g!==13&&g!==8){wt(this,e,s,400,"Missing or invalid Sec-WebSocket-Version header",{"Sec-WebSocket-Version":"13, 8"});return}if(!this.shouldHandle(e)){gn(s,400);return}let p=e.headers["sec-websocket-protocol"],m=new Set;if(p!==void 0)try{m=ml.parse(p)}catch{wt(this,e,s,400,"Invalid Sec-WebSocket-Protocol header");return}let _=e.headers["sec-websocket-extensions"],y={};if(this.options.perMessageDeflate&&_!==void 0){let S=new mt({...this.options.perMessageDeflate,isServer:!0,maxPayload:this.options.maxPayload});try{let T=Ya.parse(_);T[mt.extensionName]&&(S.accept(T[mt.extensionName]),y[mt.extensionName]=S)}catch{wt(this,e,s,400,"Invalid or unacceptable Sec-WebSocket-Extensions header");return}}if(this.options.verifyClient){let S={origin:e.headers[`${g===8?"sec-websocket-origin":"origin"}`],secure:!!(e.socket.authorized||e.socket.encrypted),req:e};if(this.options.verifyClient.length===2){this.options.verifyClient(S,(T,C,P,j)=>{if(!T)return gn(s,C||401,P,j);this.completeUpgrade(y,d,m,e,s,o,c)});return}if(!this.options.verifyClient(S))return gn(s,401)}this.completeUpgrade(y,d,m,e,s,o,c)}completeUpgrade(e,s,o,c,d,u,g){if(!d.readable||!d.writable)return d.destroy();if(d[bl])throw new Error("server.handleUpgrade() was called more than once with the same socket, possibly due to a misconfiguration");if(this._state>Xa)return gn(d,503);let m=["HTTP/1.1 101 Switching Protocols","Upgrade: websocket","Connection: Upgrade",`Sec-WebSocket-Accept: ${pl("sha1").update(s+yl).digest("base64")}`],_=new this.options.WebSocket(null,void 0,this.options);if(o.size){let y=this.options.handleProtocols?this.options.handleProtocols(o,c):o.values().next().value;y&&(m.push(`Sec-WebSocket-Protocol: ${y}`),_._protocol=y)}if(e[mt.extensionName]){let y=e[mt.extensionName].params,S=Ya.format({[mt.extensionName]:[y]});m.push(`Sec-WebSocket-Extensions: ${S}`),_._extensions=e}this.emit("headers",m,c),d.write(m.concat(`\r
|
|
12
12
|
`).join(`\r
|
|
13
|
-
`)),d.removeListener("error",Qa),_.setSocket(d,u,{allowSynchronousEvents:this.options.allowSynchronousEvents,maxPayload:this.options.maxPayload,skipUTF8Validation:this.options.skipUTF8Validation}),this.clients&&(this.clients.add(_),_.on("close",()=>{this.clients.delete(_),this._shouldEmitClose&&!this.clients.size&&process.nextTick(
|
|
13
|
+
`)),d.removeListener("error",Qa),_.setSocket(d,u,{allowSynchronousEvents:this.options.allowSynchronousEvents,maxPayload:this.options.maxPayload,skipUTF8Validation:this.options.skipUTF8Validation}),this.clients&&(this.clients.add(_),_.on("close",()=>{this.clients.delete(_),this._shouldEmitClose&&!this.clients.size&&process.nextTick(ln,this)})),g(_,c)}};tc.exports=Di;function Sl(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 ln(n){n._state=ec,n.emit("close")}function Qa(){this.destroy()}function gn(n,e,s,o){s=s||mr.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} ${mr.STATUS_CODES[e]}\r
|
|
14
14
|
`+Object.keys(o).map(c=>`${c}: ${o[c]}`).join(`\r
|
|
15
15
|
`)+`\r
|
|
16
16
|
\r
|
|
17
|
-
`+s)}function
|
|
17
|
+
`+s)}function 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 gn(s,o,c,d)}});import{spawn as Xl}from"node:child_process";import{existsSync as Zl,openSync as Ql}from"node:fs";import{mkdir as eg}from"node:fs/promises";import{dirname as tg}from"node:path";import{fileURLToPath as ng}from"node:url";function Ni(n=K()){return Zl(n.libEntry)?n.libEntry:ng(new URL("../index.ts",import.meta.url))}async function mn(n={}){let e=n.paths??K(),s=n.entryOverride??Ni(e);await eg(tg(e.logFile),{recursive:!0});let o=Ql(e.logFile,"a"),d=s.endsWith(".ts")?["--import","tsx/esm",s,"--daemon"]:[s,"--daemon"],u=Xl(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 rg.info("daemon spawned",{pid:u.pid,entry:s}),{pid:u.pid,entry:s}}var rg,Sr=Ce(()=>{"use strict";q();se();rg=L("spawn-daemon")});import{readFile as yc}from"node:fs/promises";async function Er(n){try{let[e,s]=await Promise.all([yc(n.portFile,"utf8"),yc(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 ig(n){if(!n)return null;try{return JSON.parse(n)}catch{return n}}function sg(n){return n instanceof Error?n.message:String(n)}var Oe,Ar=Ce(()=>{"use strict";se();Oe=class{paths;constructor(e){this.paths=e??K()}async probe(e=1e3){let s=await Er(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:sg(o)}}}async request(e){let s=await Er(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 g=await fetch(`http://127.0.0.1:${e.port}${s.path}`,{method:s.method,headers:c,body:o?JSON.stringify(s.body):void 0,signal:d.signal}),p=await g.text();return{status:g.status,body:ig(p)}}finally{clearTimeout(u)}}}});var Pc={};jr(Pc,{DEFAULT_PROBE_TIMEOUT_MS:()=>Cc,DEFAULT_WAIT_PID_EXIT_MS:()=>Ic,runUpgradeHelper:()=>Sg});import{copyFile as wg,rename as Fi,unlink as Ui}from"node:fs/promises";async function Sg(n){let e=n.paths??K(),s=n.spawnDaemon??mn,o=n.probeDaemon??Ig,c=n.sleep??Cg,d=n.waitPidExitMs??Ic,u=n.probeTimeoutMs??Cc,g=n.killPid??((P,j)=>process.kill(P,j)),{targetVersion:p,oldPid:m}=n;He.info("upgrade-helper start",{targetVersion:p,oldPid:m}),await Eg(m,d,c,g);let _=e.libEntry,y=`${_}.bak`,S=`${_}.next`;try{await wg(_,y)}catch(P){return He.error("backup failed, abort",{err:String(P)}),1}try{await Fi(S,_)}catch(P){return He.error("rename .next \u2192 live failed, abort + rollback",{err:String(P)}),await Fi(y,_).catch(()=>{}),1}let T,C=!1;try{await s({paths:e}),C=await Ag(()=>o(e),u,c),C||(T="new daemon failed to come up within probeTimeout")}catch(P){T=`spawn new daemon failed: ${String(P)}`,He.warn(T)}return C?(await Ec(e,p,{ok:!0,setLibVersion:!0}),await Ui(y).catch(()=>{}),await Ui(S).catch(()=>{}),He.info("upgrade succeeded",{targetVersion:p}),0):(He.warn("upgrade failed, rolling back",{lastError:T}),await Fi(y,_).catch(P=>He.error("rollback rename failed",{err:String(P)})),await s({paths:e}).catch(P=>He.error("spawn old daemon after rollback failed",{err:String(P)})),await Ec(e,p,{ok:!1,lastError:T}),await Ui(S).catch(()=>{}),1)}async function Ec(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 Fe(o,n.configFile)}async function Eg(n,e,s,o){let c=Date.now()+e;for(;Date.now()<c;){if(!Ac(n,o))return;await s(bg)}He.warn("oldPid did not exit in time, sending SIGTERM",{pid:n});try{o(n,"SIGTERM")}catch{}if(await s(_g),!!Ac(n,o)){He.warn("SIGTERM ineffective, sending SIGKILL",{pid:n});try{o(n,"SIGKILL")}catch{}await s(yg)}}function Ac(n,e){try{return e(n,0),!0}catch{return!1}}async function Ag(n,e,s){let o=Date.now()+e;for(;Date.now()<o;){if(await n().catch(()=>!1))return!0;await s(vg)}return!1}async function Ig(n){return(await new Oe(n).probe(1e3).catch(()=>null))?.kind==="connected"}function Cg(n){return new Promise(e=>setTimeout(e,n))}var He,Ic,Cc,_g,yg,bg,vg,kc=Ce(()=>{"use strict";Nt();Sr();Ar();q();se();He=L("upgrade-helper"),Ic=3e4,Cc=3e4,_g=5e3,yg=2e3,bg=200,vg=500});import{spawn as Pg}from"node:child_process";import{mkdir as kg,unlink as Tg,writeFile as Dg}from"node:fs/promises";import{dirname as Rg,join as Lg}from"node:path";function Pr(n){return n.replace(/&/g,"&").replace(/</g,"<").replace(/>/g,">").replace(/"/g,""")}function Tc(n,e){return new Promise((s,o)=>{let c=Pg(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,qi,Ki,Dc=Ce(()=>{"use strict";q();Cr=L("supervisor.launchd"),qi="ai.coze.bridge",Ki={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>${qi}</string>
|
|
23
23
|
<key>ProgramArguments</key>
|
|
24
24
|
<array>
|
|
25
|
-
<string>${
|
|
26
|
-
<string>${
|
|
25
|
+
<string>${Pr(n.nodeBin)}</string>
|
|
26
|
+
<string>${Pr(n.entry)}</string>
|
|
27
27
|
<string>--daemon</string>
|
|
28
28
|
</array>
|
|
29
29
|
<key>RunAtLoad</key>
|
|
@@ -33,12 +33,12 @@ var D0=Object.create;var jr=Object.defineProperty;var R0=Object.getOwnPropertyDe
|
|
|
33
33
|
<key>ThrottleInterval</key>
|
|
34
34
|
<integer>10</integer>
|
|
35
35
|
<key>StandardOutPath</key>
|
|
36
|
-
<string>${
|
|
36
|
+
<string>${Pr(n.logFile)}</string>
|
|
37
37
|
<key>StandardErrorPath</key>
|
|
38
|
-
<string>${
|
|
38
|
+
<string>${Pr(n.logFile)}</string>
|
|
39
39
|
</dict>
|
|
40
40
|
</plist>
|
|
41
|
-
`},configPath(n){return
|
|
41
|
+
`},configPath(n){return Lg(n.homeDir,"Library","LaunchAgents",`${qi}.plist`)},async install(n){let e=this.configPath(n);await kg(Rg(e),{recursive:!0}),await Dg(e,this.renderConfig(n),"utf8"),Cr.info("plist written",{plistPath:e}),await Tc("launchctl",["load","-w",e]),Cr.info("launchd job loaded",{label:qi})},async uninstall(n){let e=this.configPath(n);await Tc("launchctl",["unload","-w",e]).catch(s=>Cr.warn("launchctl unload failed (ignored)",{err:String(s)})),await Tg(e).catch(s=>{if(s.code!=="ENOENT")throw s}),Cr.info("launchd job removed",{plistPath:e})}}});import{spawn as Og}from"node:child_process";import{mkdir as Ng,unlink as Bg,writeFile as Mg}from"node:fs/promises";import{dirname as zg,join as Fg}from"node:path";function Dr(n,e){return new Promise((s,o)=>{let c=Og(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 kr,Tr,Hi,Rc=Ce(()=>{"use strict";q();kr=L("supervisor.systemd"),Tr="coze-bridge.service",Hi={platform:"linux",renderConfig(n){return`[Unit]
|
|
42
42
|
Description=Coze Bridge daemon
|
|
43
43
|
After=network.target
|
|
44
44
|
|
|
@@ -52,7 +52,7 @@ StandardError=append:${n.logFile}
|
|
|
52
52
|
|
|
53
53
|
[Install]
|
|
54
54
|
WantedBy=default.target
|
|
55
|
-
`},configPath(n){return
|
|
55
|
+
`},configPath(n){return Fg(n.homeDir,".config","systemd","user",Tr)},async install(n){let e=this.configPath(n);await Ng(zg(e),{recursive:!0}),await Mg(e,this.renderConfig(n),"utf8"),kr.info("systemd unit written",{unitPath:e}),await Dr("systemctl",["--user","daemon-reload"]),await Dr("systemctl",["--user","enable","--now",Tr]),kr.info("systemd unit enabled",{unitName:Tr})},async uninstall(n){let e=this.configPath(n);await Dr("systemctl",["--user","disable","--now",Tr]).catch(s=>kr.warn("systemctl disable failed (ignored)",{err:String(s)})),await Bg(e).catch(s=>{if(s.code!=="ENOENT")throw s}),await Dr("systemctl",["--user","daemon-reload"]).catch(()=>{}),kr.info("systemd unit removed",{unitPath:e})}}});import{spawn as Ug}from"node:child_process";import{join as qg}from"node:path";function Lc(n,e){return new Promise((s,o)=>{let c=Ug(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 Gi,Rr,ji,Oc=Ce(()=>{"use strict";q();Gi=L("supervisor.taskscheduler"),Rr="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,9 +76,9 @@ WantedBy=default.target
|
|
|
76
76
|
</Exec>
|
|
77
77
|
</Actions>
|
|
78
78
|
</Task>
|
|
79
|
-
`},configPath(n){return
|
|
80
|
-
${n.stack??""}`:String(n);return W0.test(s)||J0.test(s)}var
|
|
81
|
-
`)[0]?.trim()||void 0}catch{return}}async function
|
|
79
|
+
`},configPath(n){return qg(n.homeDir,".coze","bridge","task.xml")},async install(n){let e=`"${n.nodeBin}" "${n.entry}" --daemon`;await Lc("schtasks",["/Create","/SC","ONLOGON","/TN",Rr,"/TR",e,"/RU",n.userName,"/F"]),Gi.info("task scheduler entry created",{task:Rr})},async uninstall(n){await Lc("schtasks",["/Delete","/TN",Rr,"/F"]).catch(e=>Gi.warn("schtasks /Delete failed (ignored)",{err:String(e)})),Gi.info("task scheduler entry removed",{task:Rr})}}});var Wi={};jr(Wi,{buildContext:()=>jg,getSupervisor:()=>Gg,launchdSupervisor:()=>Ki,systemdSupervisor:()=>Hi,taskSchedulerSupervisor:()=>ji});import{homedir as Kg,userInfo as Hg}from"node:os";function Gg(n=process.platform){switch(n){case"darwin":return Ki;case"linux":return Hi;case"win32":return ji;default:throw new Error(`unsupported platform for OS supervisor: ${n}`)}}function jg(){let n=K();return{nodeBin:process.execPath,entry:Ni(n),logFile:n.logFile,homeDir:Kg(),userName:Hg().username}}var Ji=Ce(()=>{"use strict";se();Sr();Dc();Rc();Oc()});q();q();import{execFile as F0}from"node:child_process";import{promisify as U0}from"node:util";var ws=U0(F0),Jt=L("agents.acp-installer"),q0={"claude-code":{npmPackage:"@agentclientprotocol/claude-agent-acp",binary:"claude-agent-acp"},codex:{npmPackage:"@zed-industries/codex-acp",binary:"codex-acp"}},K0=5e4,H0=5e3,G0=5*6e4,j0=new Set(["ETIMEDOUT","ECONNRESET","ECONNREFUSED","ENETUNREACH","EAI_AGAIN","ERR_SOCKET_TIMEOUT","ENOTFOUND"]),W0=/\b(5\d\d|408|429)\b\s+(Bad Gateway|Service Unavailable|Gateway Timeout|Internal Server Error|Too Many Requests|Request Timeout)/i,J0=/fetch failed|request timed out|socket hang up|network timeout/i;function $0(n){let e=n?.code;if(e&&j0.has(e))return!0;let s=n instanceof Error?`${n.message}
|
|
80
|
+
${n.stack??""}`:String(n);return W0.test(s)||J0.test(s)}function V0(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 Sn=new Map,vn=new Map,Wr=new Map;async function ms(n){let e=process.platform==="win32"?"where":"which";try{let{stdout:s}=await ws(e,[n],{timeout:H0});return s.split(`
|
|
81
|
+
`)[0]?.trim()||void 0}catch{return}}async function Y0(n,e){Jt.info("npm install -g start",{npmPackage:n}),await ws("npm",["install","-g",`${n}@latest`],{timeout:K0,maxBuffer:10*1024*1024,...e?{signal:e}:{}}),Jt.info("npm install -g done",{npmPackage:n})}async function En(n,e){let s=q0[n];if(!s)return;let o=Sn.get(n);if(o)return o;let c=vn.get(n);if(c&&Date.now()-c<G0)return;let d=Wr.get(n);if(d)return d;let u=(async()=>{let g=await ms(s.binary);if(g)return Sn.set(n,g),Jt.info("acp wrapper found on PATH",{binary:s.binary,path:g}),g;try{await Y0(s.npmPackage,e)}catch(m){let _=$0(m);Jt.warn("acp wrapper install failed (will fallback to npx)",{npmPackage:s.npmPackage,transient:_,err:V0(m)}),_||vn.set(n,Date.now());return}let p=await ms(s.binary);if(!p){Jt.warn("acp wrapper installed but binary not found on PATH",{binary:s.binary}),vn.set(n,Date.now());return}return Sn.set(n,p),vn.delete(n),p})().finally(()=>{Wr.delete(n)});return Wr.set(n,u),u}function An(n){return Sn.get(n)}var _s=L("acp-installer-warmup"),X0=["claude-code","codex"];async function ys(n={}){let e=n.ensure??En,o=(await Promise.allSettled(X0.map(async c=>{let d=await e(c);_s.info("acp wrapper warmup ok",{framework:c,installed:!!d,path:d??""})}))).filter(c=>c.status==="rejected");o.length>0&&_s.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))})}rt();q();import{readdir as dx}from"node:fs/promises";import{mkdir as Cs,writeFile as Ps}from"node:fs/promises";import{join as $r}from"node:path";var ax={"claude-code":"CLAUDE.md",codex:"AGENTS.md",openclaw:"SOUL.md"};async function Ct(n,e,s,o){await Cs(n,{recursive:!0});let c=ax[e],d=$r(n,c),u=cx(e,s,o);return await Ps(d,u,"utf8"),d}async function ks(n){let e=$r(n,".claude");await Cs(e,{recursive:!0});let s=$r(e,"settings.local.json"),o=JSON.stringify({permissions:{defaultMode:"bypassPermissions"}},null,2);return await Ps(s,o,"utf8"),s}function cx(n,e,s){let o=`# Coze Agent: ${e}
|
|
82
82
|
|
|
83
83
|
> framework: \`${n}\`
|
|
84
84
|
|
|
@@ -88,7 +88,7 @@ ${n.stack??""}`:String(n);return W0.test(s)||J0.test(s)}var vn=new Map,bn=new Ma
|
|
|
88
88
|
`;return`${o}---
|
|
89
89
|
|
|
90
90
|
${c}
|
|
91
|
-
${
|
|
91
|
+
${xx}`}var xx=`## \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 @@ ${cx}`}var cx=`## \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 Xr(n){return`coze-session-${n.replace(/[^A-Za-z0-9_-]+/g,"-")}`}function js(n,e){if(!n.modelToken)return null;let s=n.model||Ne,o=Yr(e),c={baseUrl:`${Vr}/v1`,api:"openai-completions",apiKey:n.modelToken,models:[{id:s,name:s,reasoning:!1,input:["text"],cost:{input:0,output:0,cacheRead:0,cacheWrite:0},contextWindow:128e3,maxTokens:8192,api:"openai-completions"}]};return Object.keys(o).length>0&&(c.headers=o),c}function Ks(n,e){if(!n.modelToken)return[];let s=Yr(e),o=[];for(let[c,d]of Object.entries(s))o.push("-c",`model_providers.coze.http_headers.${c}="${d}"`);return o}var ae=D("agent-handlers"),Ws=5*1024*1024,bx=1,vx=6,Sx=new Set(["node_modules",".git",".coze","dist","build",".next"]),Nn=class{constructor(e){this.opts=e}opts;async listSkills(e){We(e._meta,"_agent/listSkills");let s=At(e._meta),o=await this.loadAgentCfg(s),c=o?.workspace??Ge(s).workspace,d=o?.skills??[],u=[];for(let l of d){let p=Me(c,l.relPath,"SKILL.md");await mx(p).then(_=>_.isFile()).catch(()=>!1)&&u.push(Px(l))}return{skills:u}}async addSkills(e){We(e._meta,"_agent/addSkills");let s=At(e._meta),o=await this.requireAgentCfg(s),c=e.skills??[],d=[...o.skills??[]],u=new Map(d.map((p,m)=>[p.skillId,m])),l=[];for(let p of c){let m=await Zr({agentId:s,workspace:o.workspace,framework:o.framework,skill:p});ei(d,u,m),l.push(p)}return await Pn(s,d),this.reloadAgentSessions(s,"skills-added"),{installedSkills:l}}async removeSkills(e){We(e._meta,"_agent/removeSkills");let s=At(e._meta),o=await this.requireAgentCfg(s),c=new Set(e.skillIds??[]),d=o.skills??[],u=[];for(let l of d){if(!c.has(l.skillId)){u.push(l);continue}let p=Me(o.workspace,l.relPath);await px(p,{recursive:!0,force:!0}),ae.info("skill removed",{agentId:s,skillId:l.skillId,relPath:l.relPath})}return await Pn(s,u),this.reloadAgentSessions(s,"skills-removed"),{ok:!0}}reloadAgentSessionsPublic(e,s){this.reloadAgentSessions(e,s)}reloadAgentSessions(e,s){let o=this.opts.agents.get(e);if(o)for(let[c,d]of o.sessions){if(!d.downstream)continue;let u=d.acpSessionId;if(u&&o.activeTriggers.has(u)||this.isRuntimePendingPermission(d)){d.reloadAfterTurn=!0,ae.info("downstream busy, scheduling reload after turn",{reason:s,agentId:e,framework:o.framework,cloudId:c,acpId:u});continue}let p=d.downstream;d.downstream=void 0,ae.info("killing downstream for workspace reload (idle)",{reason:s,agentId:e,framework:o.framework,cloudId:c,acpId:u}),p.stop(s).catch(m=>ae.warn("downstream stop failed during reload (ignored)",{reason:s,agentId:e,cloudId:c,err:String(m)}))}}isRuntimePendingPermission(e){let s=this.opts.isRuntimePendingPermission;return!s||!e.downstream?!1:s(e.downstream)}async updateAgent(e){if(!e.cozeIdentity?.trim())return ae.info("_agent/update: empty cozeIdentity, noop",{agentId:e.agentId}),{ok:!0};let s=e.agentId,o=await me(s);if(!o)throw new S("AGENT_NOT_FOUND",`agent not found: ${s}`);if(o.cozeIdentity===e.cozeIdentity)return ae.info("_agent/update: cozeIdentity unchanged, noop",{agentId:s}),{ok:!0};try{await It(o.workspace,o.framework,s,e.cozeIdentity)}catch(c){throw ae.error("_agent/update: writeInstructionFile failed, aborting update",{agentId:s,framework:o.framework,workspace:o.workspace,err:String(c)}),new S("AGENT_PROTOCOL_ERROR",`failed to write instruction file for agent ${s}: ${String(c)}`,{cause:c})}return o.cozeIdentity=e.cozeIdentity,await Ce(o),ae.info("_agent/update: cozeIdentity rewritten",{agentId:s,framework:o.framework}),this.reloadAgentSessions(s,"identity-changed"),{ok:!0}}async disconnectAgent(e){let s=e.agentId;if(!s)throw new S("IPC_BAD_REQUEST","_agent/disconnect: missing agentId");let o=await me(s);return o?(o.disconnectedAt=Date.now(),o.disconnectReason=e.reason??"",await Ce(o),ae.info("agent disconnected",{agentId:s,reason:e.reason??"",force:e.force??!1}),this.opts.disposeAndMarkDisconnected&&await this.opts.disposeAndMarkDisconnected(s,e.reason??"disconnect"),{ok:!0}):(ae.warn("_agent/disconnect: agent not found, ignoring",{agentId:s}),{ok:!0})}async switchModel(e){if(We(e._meta,"_agent/switchModel"),!e.agentId)throw new S("IPC_BAD_REQUEST","_agent/switchModel: missing agentId");let s=e.model?.trim()?e.model:Ne,o=await me(e.agentId);if(!o)throw new S("AGENT_NOT_FOUND",`agent not found: ${e.agentId}`);o.model=s,await Ce(o),ae.info("_agent/switchModel: model persisted",{agentId:e.agentId,model:s,reason:e.reason??""});let c=this.opts.agents.get(e.agentId);if(!c)return ae.info("_agent/switchModel: agent not running, config persisted only",{agentId:e.agentId}),{ok:!0};c.model=s,this.opts.cleanupOpenclawProviders&&await this.opts.cleanupOpenclawProviders(c).catch(u=>ae.warn("cleanupOpenclawProviders before switchModel failed (ignored)",{agentId:e.agentId,err:String(u)}));let d=[];for(let[u,l]of c.allSessionQueues())d.push(l.enqueue(async()=>{let p=c.sessions.get(u);p?.downstream&&(await p.downstream.stop(`switchModel: ${s}`).catch(()=>{}),p.downstream=void 0)}));return await Promise.all(d),ae.info("_agent/switchModel: all session runtimes killed, next prompt will respawn",{agentId:e.agentId,model:s,cloudSessions:d.length}),{ok:!0}}async resetAgent(e){if(We(e._meta,Oe.RESET),!e.agentId)throw new S("IPC_BAD_REQUEST",`${Oe.RESET}: missing agentId`);return await this.runDetailSync(e.agentId,Oe.RESET,e.reason),{ok:!0}}async repairAgent(e){if(We(e._meta,Oe.REPAIR),!e.agentId)throw new S("IPC_BAD_REQUEST",`${Oe.REPAIR}: missing agentId`);let s=await this.loadAgentCfg(e.agentId);if(s&&s.framework!=="openclaw")throw new S("IPC_BAD_REQUEST",`${Oe.REPAIR} only allowed for openclaw, got ${s.framework}`);if(s&&this.opts.openclawRepair)try{await this.opts.openclawRepair(e.agentId,s.workspace)}catch(o){ae.warn("openclaw repair (delete+add) failed (ignored)",{agentId:e.agentId,reason:e.reason,err:String(o)})}return await this.runDetailSync(e.agentId,Oe.REPAIR,e.reason),{ok:!0}}async runDetailSync(e,s,o){if(!this.opts.detailSyncer){ae.warn("detailSyncer not wired, skipping sync",{method:s,agentId:e});return}try{await this.opts.detailSyncer(e)}catch(c){ae.warn("detail sync failed (ignored)",{method:s,agentId:e,reason:o,err:String(c)})}}async getFileTree(e){We(e._meta,"_agent/getFileTree");let s=e._meta,o=At(s),c=await this.resolveWorkspace(o),d=e.filePath??"",u=this.safeJoin(c,d),l=await Qr(u).catch(()=>null);if(!l)throw new S("IPC_BAD_REQUEST",`path not found: ${d}`);if(l.isSymbolicLink())throw new S("IPC_BAD_REQUEST",`symlink not allowed: ${d}`);let p=Mx(e.depth);return l.isDirectory()?{tree:await Nx(c,u,d,p)}:{tree:[{name:Bx(d),path:Qs(d||"."),isDir:!1,size:l.size,modifiedAt:Math.floor(l.mtimeMs)}]}}async getFileContent(e){We(e._meta,"_agent/getFileContent");let s=At(e._meta),o=await this.resolveWorkspace(s);if(!e.filePath)throw new S("IPC_BAD_REQUEST","filePath required");let c=this.safeJoin(o,e.filePath),d=await Qr(c).catch(()=>null);if(!d||!d.isFile())throw new S("IPC_BAD_REQUEST",`not a file: ${e.filePath}`);if(d.isSymbolicLink())throw new S("IPC_BAD_REQUEST",`symlink not allowed: ${e.filePath}`);if(d.size>Ws)throw new S("IPC_BAD_REQUEST",`file too large: ${d.size} bytes (max ${Ws})`);let u=await $s(c);return u.includes(0)?{content:u.toString("base64"),encoding:"base64",size:d.size}:{content:u.toString("utf8"),encoding:"utf-8",size:d.size}}async resolveWorkspace(e){let s=this.opts.agents.get(e);return s?s.workspace:(await me(e).catch(()=>null))?.workspace??Ge(e).workspace}safeJoin(e,s){let o=yx(e,s||"."),c=Vs(e,o);if(c.startsWith("..")||c===".."||c.startsWith(`..${Ys}`))throw new S("IPC_BAD_REQUEST",`path escapes workspace: ${s}`);return o}loadAgentCfg(e){return me(e)}async requireAgentCfg(e){let s=await this.loadAgentCfg(e);if(!s)throw new S("AGENT_NOT_FOUND",`no config for agent: ${e}`);return s}};function Ex(n){let e=n.trim().replace(/[\x00-\x1f<>:"|?*/\\]+/g,"-").replace(/^[\s.-]+|[\s.-]+$/g,"").slice(0,64);if(!e||e==="."||e==="..")throw new S("IPC_BAD_REQUEST",`invalid skill name: ${n}`);if(/^(con|prn|aux|nul|com[1-9]|lpt[1-9])$/i.test(e))throw new S("IPC_BAD_REQUEST",`reserved windows filename: ${n}`);return e}function Ix(n){return n==="claude-code"?Me(".claude","skills"):Me(".agents","skills")}var Ax=3e4,Cx=50*1024*1024,Mn=3e4;async function Zr(n){let{agentId:e,workspace:s,framework:o,skill:c}=n;if(!c.skillName)throw new S("IPC_BAD_REQUEST","skill missing skillName");let d=typeof c.content=="string"&&c.content.length>0,u=typeof c.downloadUrl=="string"&&c.downloadUrl.length>0;if(!d&&!u)throw new S("IPC_BAD_REQUEST",`skill ${c.skillId} missing both content and downloadUrl`);let l=Ex(c.skillName),p=Ix(o),m=Me(p,l),_=Me(s,m);if(await gx(_,{recursive:!0}),d){let I=Buffer.from(c.content,"utf8");Vt(I.length),await Gs(Me(_,"SKILL.md"),I,"utf8")}else{let I=await kx(c.downloadUrl);Dx(I)?await Rx(I,_):await Gs(Me(_,"SKILL.md"),I.toString("utf8"),"utf8")}let y={skillId:c.skillId,skillName:c.skillName,relPath:m,installedAt:Date.now(),...c.description?{description:c.description}:{},...c.icon?{icon:c.icon}:{},...c.version?{version:c.version}:{},...c.downloadUrl?{downloadUrl:c.downloadUrl}:{},...c.config?{config:c.config}:{},...c.builtin?{builtin:c.builtin}:{}};return ae.info("skill installed",{agentId:e,skillId:c.skillId,skillName:c.skillName,relPath:m,source:d?"content":"downloadUrl"}),y}function ei(n,e,s){let o=e.get(s.skillId);if(o!==void 0){n[o]=s;return}e.set(s.skillId,n.length),n.push(s)}function Px(n){return{skillId:n.skillId,skillName:n.skillName,...n.description?{description:n.description}:{},...n.icon?{icon:n.icon}:{},...n.version?{version:n.version}:{},...n.config?{config:n.config}:{},...n.builtin?{builtin:n.builtin}:{}}}async function kx(n){if(!n)throw new S("IPC_BAD_REQUEST","skill missing downloadUrl");if(n.startsWith("data:")){let e=Math.floor(n.length*3/4);Vt(e);let s=Tx(n);return Vt(s.length),s}if(n.startsWith("file:")){let e=new URL(n).pathname,s=await $s(e);return Vt(s.length),s}if(Dn(n)){let e=new AbortController,s=setTimeout(()=>e.abort(),Ax);try{let o=await fetch(n,{signal:e.signal});if(!o.ok)throw new S("IPC_BAD_REQUEST",`fetch skill failed HTTP ${o.status} ${n}`);let c=await o.arrayBuffer();return Vt(c.byteLength),Buffer.from(c)}finally{clearTimeout(s)}}throw new S("IPC_BAD_REQUEST",`unsupported downloadUrl scheme (\u8981 https/data/file): ${n.slice(0,80)}`)}function Vt(n){if(n>Cx)throw new S("IPC_BAD_REQUEST",`skill too large: ${n} bytes`)}function Tx(n){let e=/^data:([^,;]*)(;base64)?,(.*)$/s.exec(n);if(!e)throw new S("IPC_BAD_REQUEST","bad data URL");let s=!!e[2],o=e[3]??"";return s?Buffer.from(o,"base64"):Buffer.from(decodeURIComponent(o),"utf8")}function Dx(n){return n.length>=2&&n[0]===31&&n[1]===139}async function Rx(n,e){await Lx(n),await new Promise((s,o)=>{let c=Js("tar",["-xzf","-","-C",e,"--strip-components=1","--no-same-owner"],{stdio:["pipe","pipe","pipe"]}),d="";c.stderr?.on("data",l=>{d+=String(l)});let u=setTimeout(()=>{c.kill("SIGKILL"),o(new S("IPC_BAD_REQUEST",`tar extract timeout (${Mn}ms)`))},Mn);c.on("error",l=>{clearTimeout(u),o(new S("IPC_BAD_REQUEST",`tar spawn failed: ${l.message}`,{cause:l}))}),c.on("exit",l=>{clearTimeout(u),l===0?s():o(new S("IPC_BAD_REQUEST",`tar exit ${l}${d?`: ${d.trim().slice(0,200)}`:""}`))}),c.stdin?.end(n)})}async function Lx(n){let e=await new Promise((s,o)=>{let c=Js("tar",["-tzvf","-"],{stdio:["pipe","pipe","pipe"]}),d="",u="";c.stdout?.on("data",p=>{d+=String(p)}),c.stderr?.on("data",p=>{u+=String(p)});let l=setTimeout(()=>{c.kill("SIGKILL"),o(new S("IPC_BAD_REQUEST",`tar list timeout (${Mn}ms)`))},Mn);c.on("error",p=>{clearTimeout(l),o(new S("IPC_BAD_REQUEST",`tar list spawn failed: ${p.message}`))}),c.on("exit",p=>{clearTimeout(l),p===0?s(d):o(new S("IPC_BAD_REQUEST",`tar list exit ${p}${u?`: ${u.trim().slice(0,200)}`:""}`))}),c.stdin?.end(n)});for(let s of e.split(`
|
|
117
|
-
`)){let o=s.trim();if(!o)continue;let c=o.charCodeAt(0);if(c!==45&&c!==100)throw new
|
|
118
|
-
`}var
|
|
119
|
-
`);this.buffer=s.pop()??"";let o=[];for(let c of s){let d=c.replace(/\r$/,"").trim();if(d)try{o.push(JSON.parse(d))}catch(u){this.onError?.({line:d,error:u})}}return o}flush(){if(!this.buffer)return[];let e=this.buffer.replace(/\r$/,"").trim();if(this.buffer="",!e)return[];try{return[JSON.parse(e)]}catch(s){return this.onError?.({line:e,error:s}),[]}}};var so={"session/prompt":"session.prompt","session/cancel":"session.cancel","session/new":"session.new","session/load":"session.load","_agent/create":"agent.create","_agent/health":"agent.health","_agent/pair":"agent.pair","_agent/listSkills":"agent.listSkills","_agent/addSkills":"agent.addSkills","_agent/removeSkills":"agent.removeSkills","_agent/getFileTree":"agent.getFileTree","_agent/getFileContent":"agent.getFileContent","_agent/detail":"agent.detail","_agent/update":"agent.update","_agent/disconnect":"agent.disconnect","_agent/switchModel":"agent.switchModel","_agent/genModelToken":"agent.genModelToken","_agent/reset":"agent.reset","_agent/repair":"agent.repair","session/request_permission":"session.requestPermission",initialize:"initialize"},vp=Object.fromEntries(Object.entries(so).map(([n,e])=>[e,n])),Kx={"session.prompt":["agentId","triggerMsgId","sessionId"],"session.cancel":["agentId","triggerMsgId","sessionId"],"session.new":["agentId"],"session.load":["agentId"],"agent.create":["agentId"],"agent.health":[],"agent.listSkills":["agentId"],"agent.addSkills":["agentId"],"agent.removeSkills":["agentId"],"agent.getFileTree":["agentId"],"agent.getFileContent":["agentId"],"agent.detail":["agentId"],"agent.update":["agentId"],"agent.disconnect":["agentId"],"agent.switchModel":["agentId"],"agent.genModelToken":["agentId","sessionId"],"agent.reset":["agentId"],"agent.repair":["agentId"],"session.requestPermission":["agentId","sessionId"],"agent.pair":[],initialize:[]},kt=class{seq=0;next(e,s){this.seq+=1;let o=so[e]??Gx(e),c=Kx[o]??[],d=[o,String(this.seq)];if(c.length>0){let u=c.map(p=>io(s?.[p]??"")),l=Wx(u).join(":");l&&d.push(l)}else s&&Object.values(s).some(u=>u)&&d.push(Object.values(s).filter(Boolean).map(u=>io(String(u))).join(":"));return d.join("_")}reset(){this.seq=0}};function Gx(n){return n.replace(/[\s/]+/g,".").replace(/_+/g,"-")}function io(n){return n.replace(/[:_\s]+/g,"-")}function Wx(n){let e=n.length;for(;e>0&&!n[e-1];)e-=1;return n.slice(0,e)}function Un(n,e){let s=process.env[n];if(!s)return e;let o=Number(s);return Number.isFinite(o)&&o>0?o:e}U();var Vx=3e4,Yx=200,Xx=Un("COZE_BRIDGE_SESSION_PROMPT_MAX_MS",3600*1e3),oo=500;function Qx(n){try{let e=JSON.stringify(n);return e===void 0||e.length<=oo?n:`${e.slice(0,oo)}...<truncated, total ${e.length} chars>`}catch{return"<unserializable>"}}function ao(n,e){if(!(typeof n!="number"||n<=0))try{if(process.platform==="win32"){let s=["/PID",String(n),"/T"];e==="SIGKILL"&&s.push("/F"),$x("taskkill",s,{stdio:"ignore",windowsHide:!0})}else process.kill(-n,e)}catch{}}var st=class{constructor(e){this.opts=e;this.log=D(`downstream.${this.constructor.name}`),this.decoder=new Fn({onError:s=>this.log.warn("decode line failed",{line:s.line})})}opts;child;decoder;pending=new Map;idAllocator=new kt;updateHandlers=[];agentRequestHandlers=[];exitHandlers=[];log;stopped=!1;stderrRing=[];sanitizeEnv(e){return e}async start(){if(this.child)throw new S("BRIDGE_INTERNAL","Downstream already started");let e=process.platform!=="win32",s=Jx(this.opts.command,this.opts.args,{cwd:this.opts.cwd,env:{...this.sanitizeEnv(process.env),...this.opts.env},stdio:["pipe","pipe","pipe"],detached:e});this.child=s,s.stdout?.setEncoding("utf8"),s.stdout?.on("data",o=>{try{for(let c of this.decoder.push(o))this.dispatch(c)}catch(c){this.log.warn("stdout dispatch threw, swallowed to keep daemon alive",{err:String(c)})}}),s.stderr?.setEncoding("utf8"),s.stderr?.on("data",o=>{let c=o.trimEnd();this.stderrRing.push(c),this.stderrRing.length>Yx&&this.stderrRing.shift(),this.log.debug("stderr",{text:c})}),s.stdin?.on("error",o=>{this.log.warn("child stdin error",{err:String(o)})}),s.stdout?.on("error",o=>{this.log.warn("child stdout error",{err:String(o)})}),s.stderr?.on("error",o=>{this.log.warn("child stderr error",{err:String(o)})}),s.on("exit",(o,c)=>{this.stopped=!0,(o!==0||c!==null)&&this.stderrRing.length>0&&this.log.warn("downstream exited abnormally, recent stderr",{code:o,signal:c,recentStderr:[...this.stderrRing]});try{for(let u of this.decoder.flush())this.dispatch(u)}catch(u){this.log.debug("decoder.flush on exit threw (ignored)",{err:String(u)})}this.failAllPending(new S("AGENT_PROTOCOL_ERROR",`agent exited (${o}/${c})`));for(let u of this.exitHandlers)u(o,c)}),s.on("error",o=>{this.log.error("child error",{err:String(o)}),this.failAllPending(new S("AGENT_SPAWN_FAILED",String(o),{cause:o}))}),this.log.info("downstream started",{command:this.opts.command,pid:s.pid,cwd:this.opts.cwd})}async stop(e){if(!this.child||this.stopped)return;this.stopped=!0,this.log.info("downstream stopping",{reason:e});let s=this.child,o=new Promise(d=>s.once("exit",()=>d()));ao(s.pid,"SIGTERM");let c=setTimeout(()=>{s.killed||ao(s.pid,"SIGKILL")},5e3);try{await o}finally{clearTimeout(c)}}pid(){return this.child?.pid}isAlive(){return!!this.child&&!this.stopped}initialize(e){return this.call("initialize",e)}sessionNew(e){return this.call("session/new",{mcpServers:[],...e})}sessionLoad(e){return this.call("session/load",{mcpServers:[],...e})}sessionPrompt(e,s=Xx){return this.call("session/prompt",e,s)}async sessionCancel(e){!this.child||this.stopped||this.writeFrame(Qt("session/cancel",e))}onUpdate(e){this.updateHandlers.push(e)}onAgentRequest(e){this.agentRequestHandlers.push(e)}respondAgentRequest(e,s){if(!(!this.child||this.stopped))try{this.writeFrame(Pt(e,s))}catch(o){this.log.warn("respondAgentRequest write failed",{id:e,err:String(o)})}}respondAgentRequestError(e,s){if(!(!this.child||this.stopped))try{this.writeFrame(it(e,s))}catch(o){this.log.warn("respondAgentRequestError write failed",{id:e,err:String(o)})}}onExit(e){this.exitHandlers.push(e)}call(e,s,o=Vx){if(!this.child||this.stopped)return Promise.reject(new S("AGENT_PROTOCOL_ERROR","downstream not started"));let c=this.idAllocator.next(e),d=Xt(c,e,s),u=o>0&&Number.isFinite(o);return new Promise((l,p)=>{let m=u?setTimeout(()=>{this.pending.delete(c),p(new S("AGENT_TIMEOUT",`${e} timed out after ${o}ms`))},o):null;this.pending.set(c,{resolve:l,reject:p,timer:m,method:e});try{this.writeFrame(d)}catch(_){m&&clearTimeout(m),this.pending.delete(c),p(_)}})}writeFrame(e){if(!this.child?.stdin||this.child.stdin.destroyed)throw new S("AGENT_PROTOCOL_ERROR","downstream stdin not writable");this.child.stdin.write(ro(e),s=>{s&&this.log.warn("stdin write callback err",{err:String(s)})})}dispatch(e){if(zn(e)){let s=e.id!==null?this.pending.get(e.id):void 0;if(!s){this.log.warn("orphan response",{id:e.id});return}this.pending.delete(e.id),s.timer&&clearTimeout(s.timer),e.error?(this.log.warn("downstream returned error frame",{id:e.id,method:s.method,code:e.error.code,message:e.error.message,data:e.error.data}),s.reject(to(e.error))):e.result===void 0?(this.log.warn("downstream response missing both result and error",{id:e.id,method:s.method}),s.reject(new S("AGENT_PROTOCOL_ERROR",`${s.method} response missing both result and error`))):(this.log.info("downstream returned result",{id:e.id,method:s.method,result:Qx(e.result)}),s.resolve(e.result));return}if(eo(e)){if(e.method==="session/update")for(let s of this.updateHandlers)try{Promise.resolve(s(e.params)).catch(o=>this.log.warn("update handler failed (async)",{err:String(o)}))}catch(o){this.log.warn("update handler threw sync, swallowed",{err:String(o)})}else this.log.info("unknown notification (drop, not forwarded)",{method:e.method});return}if(Zs(e)){let s=e;try{this.handleAgentRequest(s).catch(o=>this.log.error("agent request handler failed (async)",{method:s.method,err:String(o)}))}catch(o){this.log.warn("handleAgentRequest threw sync, swallowed",{method:s.method,err:String(o)})}}}async handleAgentRequest(e){if(this.agentRequestHandlers.length===0){this.writeFrame(it(e.id,{code:-32601,message:`method not handled by Bridge: ${e.method}`}));return}for(let s of this.agentRequestHandlers)try{await s(e)}catch(o){this.log.error("agentRequestHandler threw",{method:e.method,err:String(o)});try{this.writeFrame(it(e.id,en(o)))}catch{}}}failAllPending(e){for(let s of this.pending.values())s.timer&&clearTimeout(s.timer),s.reject(e);this.pending.clear()}};var Zx="@agentclientprotocol/claude-agent-acp@latest";function ed(n){let e={};for(let[s,o]of Object.entries(n))o!==void 0&&(s.startsWith("CLAUDE")||s==="AI_AGENT"||s==="BAGGAGE"||(e[s]=o));return e}var qn=class extends st{framework="claude-code";constructor(e){let s=En("claude-code"),[o,c]=s?[s,[]]:["npx",["-y",Zx]],d=e.command??o,u=e.args??c,l={command:d,args:u,cwd:e.cwd,...e.env?{env:e.env}:{}};super(l)}sanitizeEnv(e){return ed(e)}};import{mkdtempSync as td,rmSync as nd}from"node:fs";import{tmpdir as rd}from"node:os";import{join as id}from"node:path";var sd="@zed-industries/codex-acp@latest",Hn=class extends st{framework="codex";authMethodId;codexHomeDir;constructor(e){let s=En("codex"),[o,c]=s?[s,[]]:["npx",["-y",sd]],d=e.command??o,u=e.args??c,l=e.extraArgs?[...u,...e.extraArgs]:u,p=e.isolateCodexHome?td(id(rd(),"coze-bridge-codex-home-")):void 0,m=p?{...e.env??{},CODEX_HOME:p}:e.env,_={command:d,args:l,cwd:e.cwd,...m?{env:m}:{}};super(_),this.authMethodId=e.authMethodId,this.codexHomeDir=p}async initialize(e){let s=await super.initialize(e);return this.authMethodId&&await this.call("authenticate",{methodId:this.authMethodId}),s}async stop(e){if(await super.stop(e),this.codexHomeDir)try{nd(this.codexHomeDir,{recursive:!0,force:!0})}catch{}}};var od=3e4,Tt=class extends st{framework="openclaw";agentId;sessionName;slashModelOnStart;constructor(e){let s=e.sessionName??"default",o=["acp","--session",`agent:${e.agentId}:${s}`];e.gatewayToken&&o.push("--token",e.gatewayToken);let c={command:e.command,args:o,cwd:e.cwd,...e.env?{env:e.env}:{}};super(c),this.agentId=e.agentId,this.sessionName=s,this.slashModelOnStart=e.slashModelOnStart}async afterSessionEstablished(e){this.slashModelOnStart&&(this.log.info("switching session to per-session provider via /model",{agentId:this.agentId,sessionName:this.sessionName,slash:this.slashModelOnStart}),await this.sessionPrompt({sessionId:e,prompt:[{type:"text",text:`/model ${this.slashModelOnStart}`}]},od))}get acpSessionName(){return this.sessionName}};U();ie();function ti(n){return n.replace(/[^A-Za-z0-9._-]+/g,"-")}var Dt=class{slots=[];running=!1;closed=!1;disposed=!1;enqueue(e){return this.disposed?Promise.reject(new Error("AsyncQueue disposed")):this.closed?Promise.reject(new Error("AsyncQueue closed")):new Promise((s,o)=>{this.slots.push({task:e,resolve:s,reject:o}),this.drain()})}close(){this.closed=!0}dispose(e=new Error("AsyncQueue disposed")){for(this.disposed=!0,this.closed=!0;this.slots.length>0;)this.slots.shift()?.reject(e)}get size(){return this.slots.length}get isRunning(){return this.running}get isDisposed(){return this.disposed}async drain(){if(!this.running){this.running=!0;try{for(;this.slots.length>0&&!this.disposed;){let e=this.slots.shift();if(!e)break;try{let s=await e.task();e.resolve(s)}catch(s){e.reject(s)}}}finally{this.running=!1}}}};var jn=class{agentId;framework;workspace;deployType;accountId;patToken;sessions=new Map;sessionQueues=new Map;activeTriggers=new Map;status="ok";model;lastActiveAt=Date.now();constructor(e){this.agentId=e.agentId,this.framework=e.framework,this.workspace=e.workspace,this.model=e.model,this.deployType=e.deployType??"local",e.accountId&&(this.accountId=e.accountId),e.patToken&&(this.patToken=e.patToken)}setPatToken(e){this.patToken=e}getSessionQueue(e){let s=this.sessionQueues.get(e);return(!s||s.isDisposed)&&(s=new Dt,this.sessionQueues.set(e,s)),s}allSessionQueues(){return this.sessionQueues.entries()}hasSessionQueue(e){let s=this.sessionQueues.get(e);return!!s&&!s.isDisposed}async dispose(e){this.status="stopped";let s=new Error(`AgentSession disposed${e?`: ${e}`:""}`);for(let o of this.sessionQueues.values())o.dispose(s);this.sessionQueues.clear(),await this.killAllRuntimes(e??"dispose")}async killAllRuntimes(e){let s=[];for(let[,o]of this.sessions)tn(o),o.downstream&&(s.push(o.downstream.stop(e).catch(()=>{})),o.downstream=void 0);await Promise.all(s),this.activeTriggers.clear()}};function tn(n){n.idleTimer&&(clearTimeout(n.idleTimer),n.idleTimer=void 0)}import{spawn as ad}from"node:child_process";import{homedir as cd}from"node:os";import{join as xd}from"node:path";An();U();async function uo(){let n=xd(cd(),".openclaw/openclaw.json");return(await Et(n))?.gateway?.auth?.token??""}var co=D("openclaw.config"),dd=[0,5e3,5e3],xo="models.providers.",Kn="agents.defaults.models",Gn=class{command;env;retryDelaysMs;queue=new Dt;constructor(e){this.command=e.command,this.env=e.env??process.env,this.retryDelaysMs=e.retryDelaysMs??dd}async withRetry(e,s){let o;for(let c=0;c<this.retryDelaysMs.length;c++){let d=this.retryDelaysMs[c]??0;d>0&&await new Promise(u=>setTimeout(u,d));try{return await s()}catch(u){o=u,co.warn("openclaw cli failed, will retry",{label:e,attempt:c+1,err:String(u)})}}throw new S("AGENT_SPAWN_FAILED",`openclaw cli ${e} failed after ${this.retryDelaysMs.length} attempts: ${o?.message??"unknown"}`)}runCli(e){return new Promise((s,o)=>{let c=ad(this.command,e,{stdio:["ignore","pipe","pipe"],env:this.env}),d="";c.stderr?.on("data",u=>{d+=u.toString("utf8")}),c.on("error",o),c.on("close",u=>{u===0?s():o(new Error(`exit ${u}: ${d.trim().slice(0,500)}`))})})}async runCliTolerant(e,s){try{await this.runCli(e)}catch(o){let c=String(o);if(s.some(d=>c.includes(d)))return;throw o}}async bestEffortUnset(e,s){try{await this.queue.enqueue(()=>this.withRetry(e,()=>this.runCli(["config","unset",s])))}catch(o){co.warn(`${e} failed (best-effort)`,{configPath:s,err:String(o)})}}ensureProvider(e,s){return this.queue.enqueue(()=>this.withRetry(`config set models.providers.${e}`,()=>this.runCli(["config","set",`${xo}${e}`,JSON.stringify(s),"--strict-json","--merge"])))}removeProvider(e){return this.bestEffortUnset(`config unset models.providers.${e}`,`${xo}${e}`)}addModelToAllowlist(e,s){let o={[e]:s?{alias:s}:{}};return this.queue.enqueue(()=>this.withRetry(`config set ${Kn}[${e}]`,()=>this.runCli(["config","set",Kn,JSON.stringify(o),"--strict-json","--merge"])))}removeModelFromAllowlist(e){return this.bestEffortUnset(`config unset ${Kn}[${e}]`,`${Kn}.${e}`)}ensureAgent(e,s,o){let c=["agents","add",e,"--workspace",s,"--non-interactive"];return o&&c.push("--model",o),this.queue.enqueue(()=>this.withRetry(`agents add ${e}`,()=>this.runCliTolerant(c,["already exists","already registered"])))}deleteAgent(e){return this.queue.enqueue(()=>this.withRetry(`agents delete ${e}`,()=>this.runCliTolerant(["agents","delete",e,"--force"],["not found","does not exist"])))}};var Se=D("agent-manager"),fd=(n,e,s,o,c,d,u,l)=>{switch(n){case"claude-code":{let p={...c?{...Fs(c),...Hs(c,u)}:{},...l??{}};return new qn({cwd:s,...Object.keys(p).length>0?{env:p}:{}})}case"codex":{let p=c?[...Us(c),...Ks(c,u),"-c",'sandbox_mode="danger-full-access"',"-c",'approval_policy="never"']:[],m={...c?qs(c):{},...l??{}},_=!!c;return new Hn({cwd:s,...p.length>0?{extraArgs:p}:{},...Object.keys(m).length>0?{env:m}:{},..._?{authMethodId:"openai-api-key",isolateCodexHome:!0}:{}})}case"openclaw":return new Tt({command:e,cwd:s,agentId:o,...d?{sessionName:ti(d)}:{}})}};function fo(n){return n==="claude-code"||n==="codex"}var ld={path:"",version:"cloud-deployed"},gd={protocolVersion:1,clientCapabilities:{fs:{readTextFile:!0,writeTextFile:!0}}},hd=6e4,Wn=class{paths;config;registry;factory;createTimeoutMs;openclawConfigCache;ensuredProviders=new Set;constructor(e){this.paths=e.paths,this.config=e.config,this.registry=e.registry,this.factory=e.downstreamFactory??fd,this.createTimeoutMs=e.createTimeoutMs??hd}buildBinShimPathEnv(){let e=process.platform==="win32"?";":":";return{PATH:`${this.paths.binDir}${e}${process.env.PATH??""}`}}getOpenclawConfig(){if(!this.openclawConfigCache){let e=this.config.frameworksCache?.openclaw;if(!e?.path)throw new S("AGENT_SPAWN_FAILED","openclaw binary not detected on this machine");this.openclawConfigCache=new Gn({command:e.path})}return this.openclawConfigCache}async createAgent(e){if(!e.agentId)throw new S("IPC_BAD_REQUEST","agentId required");if(!e.framework)throw new S("IPC_BAD_REQUEST","framework required");let s=Jt(e._meta)==="cloud";this.registry.reviveIfDisconnected?.(e.agentId);let o=this.registry.get(e.agentId);if(o){if(o.framework!==e.framework)throw new S("AGENT_BUSY",`agent ${e.agentId} exists with different framework (${o.framework})`);if(o.status==="error")Se.warn("existing agent in error state, rebuilding",{agentId:e.agentId}),await o.dispose("rebuild after error").catch(T=>Se.warn("dispose stale agent failed (ignored)",{err:String(T)})),this.registry.unregister(e.agentId);else{if(e.patToken&&e.patToken!==o.patToken){Se.info("updating agent patToken on re-create (reconnect with new PAT)",{agentId:e.agentId}),o.setPatToken(e.patToken);let T=await me(e.agentId,this.paths).catch(()=>null);T&&(T.patToken=e.patToken,await Ce(T,this.paths))}return Se.info("agent already exists, return current",{agentId:e.agentId}),{ok:!0,agentId:o.agentId,workspace:o.workspace,framework:o.framework}}}if(!s&&!this.config.frameworksCache?.[e.framework])throw new S("AGENT_SPAWN_FAILED",`framework ${e.framework} not detected on this machine; rerun daemon to refresh frameworks_cache`);let d=Ge(e.agentId,this.paths),u=Jt(e._meta),l=e.framework==="openclaw"&&u==="local",p=l?this.config.frameworksCache?.openclaw?.defaultAgent?.workspace:void 0,m=e.workspace??p??d.workspace,_=new AbortController,y=setTimeout(()=>_.abort(new S("AGENT_TIMEOUT",`_agent/create timed out after ${this.createTimeoutMs}ms`)),this.createTimeoutMs),I,L=!1;try{s&&fo(e.framework)&&await Sn(e.framework,_.signal);let T=()=>{if(_.signal.aborted)throw _.signal.reason instanceof Error?_.signal.reason:new S("AGENT_TIMEOUT","_agent/create aborted")};await ni(d.root,{recursive:!0}),await ni(m,{recursive:!0}),await ni(d.logs,{recursive:!0}),T(),l||await It(m,e.framework,e.agentId,e.cozeIdentity),s&&e.framework==="claude-code"&&await Ps(m),T();let P=await me(e.agentId,this.paths).catch(()=>null),j=Bs({model:e.model??P?.model}),Q=ks(e._meta)??P?.accountId,K=e.patToken??P?.patToken;if(I=new jn({agentId:e.agentId,framework:e.framework,workspace:m,model:j.model??Ne,deployType:u,...Q?{accountId:Q}:{},...K?{patToken:K}:{}}),I.status="ok",P?.sessions){for(let[Te,pe]of Object.entries(P.sessions))I.sessions.set(Te,{acpSessionId:pe.acpSessionId,modelToken:pe.modelToken,tokenGeneratedAt:pe.tokenGeneratedAt,lastActiveAt:Date.now(),loadingSession:!1,replySeq:0});let oe=Object.keys(P.sessions).length;oe>0&&Se.info("restored persisted session records (no spawn)",{agentId:e.agentId,count:oe})}this.registry.register(I),L=!0;let $={agentId:e.agentId,framework:e.framework,workspace:m,cozeIdentity:e.cozeIdentity,createdAt:P?.createdAt??Date.now(),sessions:P?.sessions??{},model:j.model};u==="cloud"&&($.deployType="cloud"),Q&&($.accountId=Q),K&&($.patToken=K),P?.skills&&($.skills=P.skills),P?.agentName&&($.agentName=P.agentName),P?.description&&($.description=P.description),e.framework==="openclaw"&&u==="cloud"&&(this.config.frameworksCache?.openclaw?.path?await this.getOpenclawConfig().ensureAgent(e.agentId,m):Se.warn("openclaw binary not on this machine, skip agents add (will fail at session/prompt)",{agentId:e.agentId}));let se=e.initialSkills??[];if(se.length>0){let oe=[...$.skills??[]],Te=new Map(oe.map((xe,de)=>[xe.skillId,de])),pe=0;for(let xe of se)try{let de=await Zr({agentId:e.agentId,workspace:m,framework:e.framework,skill:xe});ei(oe,Te,de),pe++}catch(de){Se.warn("initialSkill install failed (skipping)",{agentId:e.agentId,skillId:xe.skillId,skillName:xe.skillName,err:String(de)})}pe>0&&($.skills=oe,Se.info("initialSkills installed",{agentId:e.agentId,installed:pe,requested:se.length}))}return await Ce($,this.paths),Se.info("agent created (no spawn, lazy on first prompt)",{agentId:e.agentId,framework:e.framework,deployType:u}),{ok:!0,agentId:e.agentId,workspace:m,framework:e.framework}}catch(T){throw Se.error("agent create failed, rolling back",{agentId:e.agentId,err:String(T)}),L&&I&&(await I.dispose("rollback").catch(()=>{}),this.registry.unregister(e.agentId)),await ud(d.root,{recursive:!0,force:!0}).catch(P=>Se.warn("rm agent dir failed (ignored)",{err:String(P)})),T instanceof S?T:new S("AGENT_SPAWN_FAILED",String(T),{cause:T})}finally{clearTimeout(y)}}async spawnSessionDownstream(e,s,o,c){let u=this.config.frameworksCache?.[e.framework];if(!u)if(e.deployType==="cloud"&&fo(e.framework))u=ld;else throw new S("AGENT_SPAWN_FAILED",`framework ${e.framework} not detected on this machine`);let l=e.deployType==="cloud"?{model:e.model,modelToken:s}:void 0,p;e.framework==="openclaw"?p=await this.buildOpenclawDownstream({session:e,modelConfig:l,cloudSessionId:o,cozeEnv:c,command:u.path}):p=this.factory(e.framework,u.path,e.workspace,e.agentId,l,o,c,this.buildBinShimPathEnv());try{return await p.start(),await p.initialize(gd),p}catch(m){throw await p.stop("spawnSessionDownstream failed").catch(()=>{}),m instanceof S?m:new S("AGENT_SPAWN_FAILED",m instanceof Error?m.message:String(m),{cause:m})}}async buildOpenclawDownstream(e){let{session:s,modelConfig:o,cloudSessionId:c,cozeEnv:d,command:u}=e,l=ti(c);if(s.deployType==="local"){let y=this.config.frameworksCache?.openclaw?.defaultAgent;if(!y?.id||!y.workspace)throw new S("AGENT_SPAWN_FAILED","openclaw default agent \u672A\u63A2\u6D4B\u5230; \u8BF7\u5148\u8DD1 `openclaw setup` \u6216 `openclaw agents add` \u521B\u5EFA\u9ED8\u8BA4 agent");return new Tt({command:u,cwd:y.workspace,agentId:y.id,sessionName:l})}let p=await uo(),m=o?js(o,d):null,_;if(m){let y=Xr(c),L=m.models[0]?.id??Ne,T=`${y}/${L}`;if(!this.ensuredProviders.has(T)){let P=this.getOpenclawConfig();await P.ensureProvider(y,m),await P.addModelToAllowlist(T),this.ensuredProviders.add(T)}_=T}return new Tt({command:u,cwd:s.workspace,agentId:s.agentId,sessionName:l,...p?{gatewayToken:p}:{},..._?{slashModelOnStart:_}:{}})}async openclawRepair(e,s){let o=this.getOpenclawConfig();await o.deleteAgent(e),await o.ensureAgent(e,s)}async cleanupOpenclawSessionProviders(e){if(e.framework!=="openclaw"||!this.openclawConfigCache)return;let s=this.openclawConfigCache;for(let o of e.sessions.keys()){let c=Xr(o),d=`${c}/${e.model}`,u=!0;try{await s.removeProvider(c)}catch(l){u=!1,Se.warn("removeProvider failed, keeping ensuredProviders entry",{providerId:c,err:String(l)})}try{await s.removeModelFromAllowlist(d)}catch(l){u=!1,Se.warn("removeModelFromAllowlist failed, keeping ensuredProviders entry",{fullModelId:d,err:String(l)})}u&&this.ensuredProviders.delete(d)}}};import{randomUUID as Ad}from"node:crypto";import{promises as Cd}from"node:fs";import{basename as Pd}from"node:path";import{promises as md}from"node:fs";import{basename as wd}from"node:path";U();var lo=D("file-upload"),_d="/api/coze_claw/file/agent_upload",yd=6e4;async function go(n,e={}){let o=`${Rn(On(e.handshakeBase))}${_d}`,c=e.timeoutMs??yd,d=await md.readFile(n.path),u=new FormData;u.append("agent_id",n.agentId),u.append("session_id",n.sessionId),u.append("file_name",n.name),u.append("file_content",new Blob([d],{type:n.mimeType}),n.name);let l={Authorization:`Bearer ${n.patToken}`,Accept:"application/json","x-coze-version":"3.0",...Ct(e.ppeOverride),...n.accountId?{"x-coze-account":n.accountId}:{}},p=new AbortController,m=setTimeout(()=>p.abort(),c);lo.info("file upload start",{url:o,agentId:n.agentId,sessionId:n.sessionId,name:n.name,bytes:n.sizeBytes,mime:n.mimeType});try{let _=await fetch(o,{method:"POST",headers:l,body:u,signal:p.signal}),y=_.headers.get("x-tt-logid")??"";if(!_.ok){let T=await _.text().catch(()=>"");throw new S("UPLOAD_FAILED",`upload HTTP ${_.status} logid=${y}: ${T.slice(0,200)}`)}let I=await _.json();if(I.code!==void 0&&I.code!==0)throw new S("UPLOAD_FAILED",`upload code=${I.code} msg=${I.msg??"-"} logid=${y}`);let L=I.data?.file?.file_url;if(!L)throw new S("UPLOAD_FAILED",`upload response missing data.file.file_url logid=${y}: ${JSON.stringify(I).slice(0,200)}`);return lo.info("file upload ok",{uri:L,logid:y}),{uri:L}}catch(_){throw _ instanceof S?_:_.name==="AbortError"?new S("UPLOAD_FAILED",`upload timeout (${c}ms) for ${wd(n.path)}`):new S("UPLOAD_FAILED",String(_),{cause:_})}finally{clearTimeout(m)}}U();import{promises as bd}from"node:fs";import{extname as vd}from"node:path";var Sd=[{mime:"image/png",prefix:[137,80,78,71]},{mime:"image/jpeg",prefix:[255,216,255]},{mime:"image/gif",prefix:[71,73,70,56]},{mime:"application/pdf",prefix:[37,80,68,70]}];function Ed(n){return n[0]===82&&n[1]===73&&n[2]===70&&n[3]===70&&n[8]===87&&n[9]===69&&n[10]===66&&n[11]===80}var Id={".txt":"text/plain",".md":"text/markdown",".svg":"image/svg+xml",".json":"application/json"};async function ho(n){let e=await bd.open(n,"r");try{let s=Buffer.alloc(16);if(await e.read(s,0,16,0),Ed(s))return"image/webp";for(let o of Sd)if(o.prefix.every((c,d)=>s[d]===c))return o.mime}finally{await e.close()}return Id[vd(n).toLowerCase()]??"application/octet-stream"}ie();var po=D("agent-send"),mo=50*1024*1024,kd=new Set(["image/png","image/jpeg","image/webp","image/gif","image/svg+xml","application/pdf","application/json","text/plain","text/markdown"]);async function wo(n,e){let s=e.core.get(n.agentId);if(!s)throw new S("AGENT_NOT_FOUND",`agent=${n.agentId}`);if(e.core.disconnectedAgents.has(n.agentId))throw new S("AGENT_DISCONNECTED",`agent=${n.agentId} was disconnected by cloud`);if(s.deployType!=="cloud")throw new S("IPC_BAD_REQUEST",`agent=${n.agentId} is not a cloud agent (deployType=${s.deployType}); send only available for cloud agents`);let o=s.sessions.get(n.sessionId);if(!o)throw new S("AGENT_NOT_FOUND",`session=${n.sessionId} not active in agent=${n.agentId}`);if(!await Es(n.path,s.workspace))throw new S("PATH_OUTSIDE_WORKSPACE",`path=${n.path} not under workspace=${s.workspace}`);let c=await Cd.stat(n.path).catch(()=>null);if(!c||!c.isFile())throw new S("IPC_BAD_REQUEST",`path is not a regular file: ${n.path}`);if(c.size>mo)throw new S("FILE_TOO_LARGE",`${c.size} bytes > limit ${mo}`);let d=await ho(n.path);if(!kd.has(d))throw new S("UNSUPPORTED_MIME",`mime=${d} not in whitelist`);if(n.kind==="image"&&!d.startsWith("image/"))throw new S("UNSUPPORTED_MIME",`kind=image but mime=${d}`);if(!e.core.upstream.isConnected())throw new S("UPSTREAM_NOT_READY","cloud WS not connected");let u=n.name??Pd(n.path),l=await go({patToken:e.patToken,agentId:n.agentId,sessionId:n.sessionId,path:n.path,mimeType:d,name:u,sizeBytes:c.size,...s.accountId?{accountId:s.accountId}:{}},{handshakeBase:e.handshakeBase,ppeOverride:e.ppeOverride}),p={sessionUpdate:"agent_file",messageId:Ad(),content:{type:n.kind==="image"?"image":"resource",uri:l.uri,mimeType:d,name:u,sizeBytes:c.size,...l.fileId!==void 0?{fileId:l.fileId}:{},...n.caption!==void 0?{caption:n.caption}:{}}},m=2,_;for(let y=0;y<=m;y++)try{await e.core.sendAgentFileUpdate(s,o,n.sessionId,p),_=void 0;break}catch(I){_=I,y<m&&(po.warn("sendAgentFileUpdate failed, retrying",{attempt:y+1,err:String(I)}),await new Promise(L=>setTimeout(L,5e3)))}if(_)throw new S("UPSTREAM_NOT_READY",`agent file uploaded to cloud but sendAgentFileUpdate failed after ${m+1} attempts: ${String(_)}`,{cause:_});return po.info("agent file sent",{agentId:n.agentId,sessionId:n.sessionId,kind:n.kind,name:u,bytes:c.size,mime:d,uri:l.uri}),{ok:!0,uri:l.uri,bytes:c.size,mimeType:d,...l.fileId!==void 0?{fileId:l.fileId}:{}}}U();import{execFile as Td}from"node:child_process";import{promisify as Dd}from"node:util";var Rd=Dd(Td),ot=D("coze-cli-installer"),_o="@coze/cli@0.1.3-alpha.89c42a",yo="https://bnpm.byted.org",Ld="coze",Od=5e3,Nd=9e4,bo=1e4,nn=null,ri=!1;async function ii(n,e={}){if(ri)return;if(nn)return nn;let s=e.exec??Rd;return nn=(async()=>{try{let o=await Md(Ld,s);if(o){ot.info("coze-cli already on PATH, skip install + config + auth",{path:o}),ri=!0;return}ot.info("coze-cli install start",{package:_o,registry:yo});try{await s("npm",["i","-g",_o,"--registry",yo],{timeout:Nd,maxBuffer:10*1024*1024}),ot.info("coze-cli install ok")}catch(c){ot.warn("coze-cli install failed (skip subsequent steps)",{err:String(c)});return}if(n.env)try{await s("coze",["config","set","xTTEnv",n.env],{timeout:bo}),ot.info("coze config set xTTEnv ok",{env:n.env})}catch(c){ot.warn("coze config set failed (continue to auth login)",{err:String(c)})}try{await s("coze",["auth","login","--token",n.patToken],{timeout:bo}),ot.info("coze auth login ok")}catch(c){ot.warn("coze auth login failed",{err:String(c)});return}ri=!0}finally{nn=null}})(),nn}async function Md(n,e){let s=process.platform==="win32"?"where":"which";try{let{stdout:o}=await e(s,[n],{timeout:Od});return o.split(`
|
|
120
|
-
`)[0]?.trim()||void 0}catch{return}}
|
|
121
|
-
`),p=Math.max(0,(n.line??1)-1),m=typeof n.limit=="number"?p+n.limit:void 0;d=
|
|
122
|
-
`)}else d=u}return
|
|
123
|
-
`)}async function Do(n,e){if(typeof n!="string"||n.length===0)throw new S("IPC_BAD_REQUEST","path must be a non-empty string");let[s,o]=await Promise.all([Co(Ao(e)),Co(Ao(n))]),c=Zd(s,o);if(c.startsWith("..")||c===".."||c.startsWith(`..${eu}`))throw new S("IPC_BAD_REQUEST",`path escapes workspace: ${n}`);return o}async function Co(n){let e=[],s=n;for(;s!==si(s);)try{let o=await $d(s);return e.length?Qd(o,...e.reverse()):o}catch{e.push(Xd(s)),s=si(s)}return n}U();var Ro=D("prompt-multimodal"),Lo=10*1024*1024,ru=15e3,iu=6;async function Oo(n){let e=new Array(n.length),s=0;async function o(){for(;s<n.length;){let d=s++,u=n[d];u!==void 0&&(e[d]=await su(u))}}let c=Array.from({length:Math.min(iu,n.length)},()=>o());return await Promise.all(c),e}async function su(n){if(n.type!=="image")return n;let e=n;if(e.data||!e.uri||!Dn(e.uri))return n;try{let{buf:s,contentType:o}=await au(e.uri),c=e.mimeType||ou(o)||"application/octet-stream";return Ro.info("image uri fetched and inlined",{uri:e.uri,bytes:s.length,mimeType:c}),{type:"image",data:s.toString("base64"),mimeType:c}}catch(s){return Ro.warn("image fetch failed, degrading to text block",{uri:e.uri,err:String(s)}),{type:"text",text:`[image load failed: ${e.uri}]`}}}function ou(n){if(!n)return;let e=n.indexOf(";");return(e===-1?n:n.slice(0,e)).trim()||void 0}async function au(n){let e=new AbortController,s=setTimeout(()=>e.abort(),ru);try{let o=await fetch(n,{signal:e.signal});if(!o.ok)throw new Error(`HTTP ${o.status} ${o.statusText}`);let c=await o.arrayBuffer();if(c.byteLength>Lo)throw new Error(`image too large: ${c.byteLength} bytes (max ${Lo})`);return{buf:Buffer.from(c),contentType:o.headers.get("content-type")??void 0}}finally{clearTimeout(s)}}nt();Lt();U();var B=D("core"),xu=3e4,du=/^(boe|ppe)_[A-Za-z0-9_-]+$/,uu=3e4,fu=new Set(["_agent/create","session/new","session/load","session/prompt"]),Jn=class{upstream;agents=new Map;disconnectedAgents=new Set;extensions;paths;sessionSpawner;sessionIdleTimeoutMs;upgradeGate;upstreamIds=new kt;pendingUpstream=new Map;pendingBridge=new Map;currentCozeEnv;constructor(e){this.upstream=e.upstream,this.extensions=e.extensions??{},this.paths=e.paths,this.sessionSpawner=e.sessionSpawner,this.sessionIdleTimeoutMs=Io(e.bridgeConfig),this.upgradeGate=e.upgradeGate}registerExtension(e,s){this.extensions[e]=s}getCozeEnv(){return this.currentCozeEnv}async start(){this.upstream.onFrame(e=>this.handleFrame(e)),this.upstream.onConnect?.(({initial:e})=>{e||this.rejectAllPendingOnReconnect()}),await this.upstream.start(),B.info("Core started",{extensions:Object.keys(this.extensions)})}async stop(e){B.info("Core stopping",{reason:e}),await Promise.all([...this.agents.values()].map(s=>s.dispose(e))),this.agents.clear(),await this.upstream.stop(e)}get(e){return this.agents.get(e)}register(e){this.agents.set(e.agentId,e),B.info("agent registered",{agentId:e.agentId,framework:e.framework});for(let s of this.registerHandlers)try{s(e.agentId)}catch(o){B.warn("onAgentRegister handler threw (ignored)",{agentId:e.agentId,err:String(o)})}}onAgentRegister(e){return this.registerHandlers.add(e),()=>this.registerHandlers.delete(e)}registerHandlers=new Set;unregister(e){this.agents.delete(e)}reviveIfDisconnected(e){this.disconnectedAgents.delete(e)&&B.info("agent revived from disconnect",{agentId:e})}attachRuntimeHooks(e,s,o){let c=o.downstream;c&&(c.onUpdate(d=>{o.loadingSession||this.forwardUpdate(e,d)}),c.onAgentRequest(d=>{this.handleAgentRequest(e,c,d)}),c.onExit((d,u)=>{B.info("session runtime exited",{agentId:e.agentId,cloudId:s,code:d,signal:u}),tn(o),o.downstream=void 0,o.replySeq=0,o.acpSessionId&&e.activeTriggers.delete(o.acpSessionId),this.rejectPendingForDownstream(c,"downstream exited")}))}hasPendingPermissionFor(e){for(let s of this.pendingUpstream.values())if(s.downstream===e)return!0;return!1}rejectPendingForDownstream(e,s){let o=[];for(let[c,d]of this.pendingUpstream)d.downstream===e&&o.push(c);if(o.length!==0){B.info("reject pendingUpstream entries (downstream gone)",{reason:s,count:o.length});for(let c of o){let d=this.pendingUpstream.get(c);if(d){this.pendingUpstream.delete(c),this.upstream.send(it(c,{code:H.INTERNAL_ERROR,message:`bridge downstream gone: ${s}`})).catch(u=>B.debug("send error response to upstream failed (ignored)",{err:String(u)}));try{d.downstream.respondAgentRequestError(d.agentRequestId,{code:H.INTERNAL_ERROR,message:`bridge: ${s}`})}catch{}}}}}rejectAllPendingOnReconnect(){let e=this.pendingUpstream.size,s=this.pendingBridge.size;if(!(e===0&&s===0)){B.warn("upstream reconnected, rejecting stale pending requests",{pendingUpstream:e,pendingBridge:s});for(let[,o]of this.pendingUpstream)try{o.downstream.respondAgentRequestError(o.agentRequestId,{code:H.INTERNAL_ERROR,message:"upstream reconnected; please retry"})}catch{}this.pendingUpstream.clear();for(let[,o]of this.pendingBridge)clearTimeout(o.timer),o.reject(new S("UPSTREAM_DISCONNECTED",`${o.method} aborted: upstream reconnected`));this.pendingBridge.clear()}}async handleFrame(e){if(zn(e)){this.handleUpstreamResponse(e);return}if(!("method"in e)||typeof e.method!="string")return;let s="id"in e&&e.id!==void 0?e.id:null,o=e.params?._meta?.cozeEnv;o&&du.test(o)?this.currentCozeEnv=o:o&&B.warn("rejecting cozeEnv with invalid shape, keeping previous",{rejected:o});try{if(this.upgradeGate?.isUpgrading()&&fu.has(e.method)){let c=this.upgradeGate.pendingTarget()??"";throw new S("BRIDGE_UPGRADING",`bridge upgrading to ${c}, retry shortly`,{retriable:!0})}if(e.method.startsWith("_agent/")){let c=this.extensions[e.method];if(!c){s!==null?await this.sendError(s,H.METHOD_NOT_FOUND,`extension not registered: ${e.method}`):B.warn("drop notification: extension not registered",{method:e.method});return}let d=await c(e,this);s!==null&&await this.upstream.send(Pt(s,d));return}if(e.method.startsWith("session/")){let c=await this.routeSessionMethod(e);s!==null&&await this.upstream.send(Pt(s,c));return}if(e.method==="initialize"){s!==null&&await this.upstream.send(Pt(s,{protocolVersion:1,agentCapabilities:{loadSession:!0}}));return}s!==null?await this.sendError(s,H.METHOD_NOT_FOUND,`method not implemented: ${e.method}`):B.warn("drop unknown notification",{method:e.method})}catch(c){B.error("handleFrame failed",{method:e.method,err:String(c)}),s!==null&&await this.upstream.send(it(s,en(c)))}}async routeSessionMethod(e){if(!e.params||typeof e.params!="object")throw new S("IPC_BAD_REQUEST",`${e.method} requires params`);let s=e.params,o=s._meta?.cozeAgentId;if(!o)throw new S("IPC_BAD_REQUEST",`${e.method}: missing _meta.cozeAgentId`);let c=this.agents.get(o);if(!c)throw this.disconnectedAgents.has(o)?new S("AGENT_DISCONNECTED",`agent ${o} has been disconnected; cloud must _agent/create to revive`):new S("AGENT_NOT_FOUND",`agent not found: ${o}`);let d=typeof s.sessionId=="string"?s.sessionId:void 0;if(e.method==="session/cancel"||e.method==="session/new"||!d)return this.dispatchSessionCall(c,e.method,s);let u=Date.now(),l=!1,p=e.method==="session/prompt";p&&this.upgradeGate?.incActive();try{let m=await c.getSessionQueue(d).enqueue(()=>this.dispatchSessionCall(c,e.method,s));return l=!0,m}finally{p&&this.upgradeGate?.decActive(),B.info("session call done",{agentId:c.agentId,method:e.method,durationMs:Date.now()-u,ok:l})}}async dispatchSessionCall(e,s,o){e.lastActiveAt=Date.now();let{stripped:c}=Ts(o);switch(s){case"session/new":{let d=lu();return B.info("session/new ack (lazy spawn)",{agentId:e.agentId,cloudId:d}),{sessionId:d}}case"session/load":{let d=c;return B.info("session/load ack (lazy spawn)",{agentId:e.agentId,cloudId:d.sessionId}),{}}case"session/prompt":{let d=c,u=d.sessionId;if(!u)throw new S("IPC_BAD_REQUEST","session/prompt: missing sessionId");let l=await this.ensureRuntime(e,u);if(l.replySeq=0,await this.ensureDownstream(e,u,l),!l.downstream||!l.acpSessionId)throw new S("BRIDGE_INTERNAL","session runtime not ready after ensureDownstream");let p=o._meta?.cozeTriggerMsgId;p?e.activeTriggers.set(l.acpSessionId,p):e.activeTriggers.delete(l.acpSessionId);let m=await Oo(d.prompt);try{let _=await l.downstream.sessionPrompt({...d,sessionId:l.acpSessionId,prompt:m});return l.lastActiveAt=Date.now(),_}finally{if(e.activeTriggers.delete(l.acpSessionId),l.reloadAfterTurn){l.reloadAfterTurn=!1;let _=l.downstream;_&&(l.downstream=void 0,B.info("reloadAfterTurn: stopping downstream",{agentId:e.agentId,cloudId:u,acpId:l.acpSessionId}),_.stop("reload-after-turn").catch(y=>B.warn("reload-after-turn stop failed (ignored)",{agentId:e.agentId,cloudId:u,err:String(y)})))}else l.downstream?.isAlive()&&this.armIdleTimer(e,u,l)}}case"session/cancel":{let u=c.sessionId;if(!u)throw new S("IPC_BAD_REQUEST","session/cancel: missing sessionId");let l=e.sessions.get(u);if(e.hasSessionQueue(u)){let p=e.getSessionQueue(u);p.size>0&&(B.info("session/cancel: draining queued tasks",{agentId:e.agentId,cloudId:u,queuedCount:p.size}),p.dispose(new S("AGENT_PROTOCOL_ERROR",`cancelled by session/cancel on ${u}`)))}return l?.downstream?.isAlive()&&l.acpSessionId&&await l.downstream.sessionCancel({sessionId:l.acpSessionId}),{ok:!0}}default:throw new S("IPC_BAD_REQUEST",`session method not supported: ${s}`)}}async ensureRuntime(e,s){let o=e.sessions.get(s);if(o)return o;let d={modelToken:e.deployType==="cloud"?await this.requestSessionToken(e.agentId,s):"",tokenGeneratedAt:Date.now(),lastActiveAt:Date.now(),loadingSession:!1,replySeq:0};return e.sessions.set(s,d),await this.persistSessionMapping(e),d}async requestSessionToken(e,s){let o={sessionId:s,_meta:{cozeAgentId:e}};try{let c=await this.sendRequest(Oe.GEN_MODEL_TOKEN,o,uu);if(!c?.modelToken)throw new S("MODEL_TOKEN_GEN_FAILED",`cloud returned empty modelToken (agentId=${e}, cloudSessionId=${s})`);return c.modelToken}catch(c){throw c instanceof S&&c.code==="MODEL_TOKEN_GEN_FAILED"?c:new S("MODEL_TOKEN_GEN_FAILED",c instanceof Error?c.message:String(c),{cause:c})}}async ensureDownstream(e,s,o){if(tn(o),o.downstream?.isAlive())return;if(!this.sessionSpawner)throw new S("AGENT_SPAWN_FAILED","sessionSpawner not wired (cannot spawn per-session downstream)");let c=3,d=3e4,u=o.spawnFailCount??0,l=o.spawnFailedAt??0;if(u>=c&&Date.now()-l<d)throw new S("AGENT_SPAWN_FAILED",`agent ${e.agentId} session ${s} spawn failed ${u} times in a row; please check framework binary / network and retry after ${Math.ceil((d-(Date.now()-l))/1e3)}s`);let p;try{p=await this.sessionSpawner(e,o.modelToken,s,this.currentCozeEnv)}catch(m){throw o.spawnFailCount=u+1,o.spawnFailedAt=Date.now(),o.spawnFailCount>=c&&o.acpSessionId&&(B.warn("clearing stale acpSessionId after repeated spawn failures",{agentId:e.agentId,cloudId:s,staleAcpId:o.acpSessionId}),o.acpSessionId=void 0),m}if(o.spawnFailCount=0,o.spawnFailedAt=void 0,o.downstream=p,this.attachRuntimeHooks(e,s,o),o.acpSessionId){o.loadingSession=!0;try{await p.sessionLoad({sessionId:o.acpSessionId,cwd:e.workspace}),B.info("session restored via session/load",{agentId:e.agentId,cloudId:s,acpId:o.acpSessionId})}catch(m){B.warn("session/load failed, fallback to session/new",{agentId:e.agentId,cloudId:s,acpId:o.acpSessionId,err:String(m)}),o.acpSessionId=void 0;let _=await p.sessionNew({cwd:e.workspace});o.acpSessionId=_.sessionId,await this.persistSessionMapping(e)}finally{o.loadingSession=!1}}else{let m=await p.sessionNew({cwd:e.workspace});o.acpSessionId=m.sessionId,await this.persistSessionMapping(e)}p.afterSessionEstablished&&o.acpSessionId&&await p.afterSessionEstablished(o.acpSessionId)}armIdleTimer(e,s,o){if(tn(o),this.isRuntimeBusy(e,o)){B.debug("skip idle timer: runtime busy (in-flight turn / pending permission)",{agentId:e.agentId,cloudId:s});return}o.idleTimer=setTimeout(()=>{if(o.idleTimer=void 0,this.isRuntimeBusy(e,o)){B.info("idle reaper fired but runtime busy, re-arming",{agentId:e.agentId,cloudId:s}),this.armIdleTimer(e,s,o);return}B.info("session runtime idle timeout, killing downstream",{agentId:e.agentId,cloudId:s});let c=o.downstream;o.downstream=void 0,o.acpSessionId&&e.activeTriggers.delete(o.acpSessionId),c&&c.stop("idle timeout").catch(d=>B.warn("idle stop failed (ignored)",{agentId:e.agentId,cloudId:s,err:String(d)}))},this.sessionIdleTimeoutMs),o.idleTimer.unref?.()}isRuntimeBusy(e,s){if(s.acpSessionId&&e.activeTriggers.has(s.acpSessionId))return!0;let o=s.downstream;if(!o)return!1;for(let c of this.pendingUpstream.values())if(c.downstream===o)return!0;return!1}async sendAgentFileUpdate(e,s,o,c){let d={cozeAgentId:e.agentId,cozeReplySeqID:++s.replySeq};if(s.acpSessionId){let u=e.activeTriggers.get(s.acpSessionId);u&&(d.cozeTriggerMsgId=u)}await this.upstream.send(Qt("session/update",{sessionId:o,update:c,_meta:d}))}forwardUpdate(e,s){let o=s.sessionId,c=this.reverseSessionId(e,o);if(!c){B.debug("drop update for unknown session",{agentId:e.agentId,acpId:o});return}let d=e.sessions.get(c);if(!d){B.debug("drop update: runtime gone",{agentId:e.agentId,cloudId:c});return}if(hu(s)){B.debug("drop codex metadata-warn chunk",{agentId:e.agentId,acpId:o});return}let u={cozeAgentId:e.agentId,cozeReplySeqID:++d.replySeq},l=e.activeTriggers.get(o);l&&(u.cozeTriggerMsgId=l),this.upstream.send(Qt("session/update",{...s,sessionId:c,_meta:u})).catch(p=>B.warn("forward update failed",{agentId:e.agentId,err:String(p)}))}handleAgentRequest(e,s,o){if(o.method==="session/request_permission"){this.forwardPermissionRequest(e,s,o);return}if(o.method==="fs/write_text_file"||o.method==="fs/read_text_file"){this.handleFsRpcRequest(e,s,o);return}B.warn("unhandled agent request,returning method_not_found",{agentId:e.agentId,method:o.method}),s.respondAgentRequestError(o.id,{code:H.METHOD_NOT_FOUND,message:`method not handled by Bridge: ${o.method}`})}async handleFsRpcRequest(e,s,o){try{let c=e.workspace;if(o.method==="fs/write_text_file"){let d=o.params??{},u=await ko(d,c);s.respondAgentRequest(o.id,u)}else{let d=o.params??{},u=await To(d,c);s.respondAgentRequest(o.id,u)}}catch(c){B.warn("fs rpc handler failed",{agentId:e.agentId,method:o.method,err:String(c)}),s.respondAgentRequestError(o.id,en(c))}}forwardPermissionRequest(e,s,o){let c=this.upstreamIds.next("session/request_permission"),d=o.params??{},l=d.sessionId,p=l?e.activeTriggers.get(l):void 0,m={cozeAgentId:e.agentId};p&&(m.cozeTriggerMsgId=p);let _=l?this.reverseSessionId(e,l):void 0,y={...d,..._?{sessionId:_}:{},_meta:m};this.pendingUpstream.set(c,{agentRequestId:o.id,agentId:e.agentId,downstream:s,method:o.method}),B.info("forward permission_request \u2192 upstream",{agentId:e.agentId,upstreamId:c,acpSessionId:l,cloudSessionId:_,toolCallId:d.toolCall?.toolCallId,options:d.options?.map(I=>({optionId:I.optionId,kind:I.kind,name:I.name}))}),this.upstream.send(Xt(c,"session/request_permission",y)).catch(I=>{this.pendingUpstream.delete(c),B.error("forward permission request failed",{agentId:e.agentId,err:String(I)}),s.respondAgentRequestError(o.id,{code:H.INTERNAL_ERROR,message:`upstream send failed: ${String(I)}`})})}handleUpstreamResponse(e){if(e.id===null)return;let s=this.lookupPending(this.pendingUpstream,e.id,"upstream");if(s){this.pendingUpstream.delete(s.key);let c=s.value;e.error?(B.info("upstream \u2192 permission response (error)",{agentId:c.agentId,upstreamId:e.id,method:c.method,error:e.error}),c.downstream.respondAgentRequestError(c.agentRequestId,e.error)):(c.method==="session/request_permission"&&gu(e.result,c),B.info("upstream \u2192 permission response (result)",{agentId:c.agentId,upstreamId:e.id,method:c.method,result:e.result}),c.downstream.respondAgentRequest(c.agentRequestId,e.result));return}let o=this.lookupPending(this.pendingBridge,e.id,"bridge");if(o){this.pendingBridge.delete(o.key),clearTimeout(o.value.timer),e.error?o.value.reject(new Bn(e.error)):o.value.resolve(e.result);return}B.debug("orphan upstream response (no pending)",{id:e.id})}lookupPending(e,s,o){let c=e.get(s);if(c)return{value:c,key:s};if(typeof s=="number"){let d=String(s),u=e.get(d);if(u)return B.warn(`${o} id type mismatch: number received but Bridge expected string`,{rawId:s,normalizedId:d}),{value:u,key:d}}}sendRequest(e,s,o=xu){let c=this.upstreamIds.next(e);return new Promise((d,u)=>{let l=setTimeout(()=>{this.pendingBridge.delete(c),u(new S("AGENT_TIMEOUT",`${e} timed out after ${o}ms`))},o);this.pendingBridge.set(c,{method:e,resolve:d,reject:u,timer:l}),this.upstream.send(Xt(c,e,s)).catch(p=>{let m=this.pendingBridge.get(c);m&&(clearTimeout(m.timer),this.pendingBridge.delete(c)),u(p)})})}async persistSessionMapping(e){if(this.paths)try{let s=new Map;for(let[o,c]of e.sessions){let d={modelToken:c.modelToken,tokenGeneratedAt:c.tokenGeneratedAt};c.acpSessionId&&(d.acpSessionId=c.acpSessionId),s.set(o,d)}await Wr(e.agentId,s,this.paths)}catch(s){B.warn("persist session mapping failed",{agentId:e.agentId,err:String(s)})}}reverseSessionId(e,s){for(let[o,c]of e.sessions.entries())if(c.acpSessionId===s)return o}sendError(e,s,o){return this.upstream.send(it(e,{code:s,message:o,data:{bridgeVersion:rt}}))}};function lu(){return cu(16).toString("hex")}function gu(n,e){if(!n||typeof n!="object"){B.warn("permission response: result not an object (suspicious)",{agentId:e.agentId,result:n});return}let s=n;if("kind"in s&&!("outcome"in s)){B.warn('permission response: top-level "kind" field (D66 historical bug shape)',{agentId:e.agentId,result:n});return}let o=s.outcome;if(!o||typeof o!="object"){B.warn("permission response: missing or non-object outcome field",{agentId:e.agentId,result:n});return}let d=o.outcome;(typeof d!="string"||d!=="selected"&&d!=="cancelled")&&B.warn("permission response: unknown outcome discriminant",{agentId:e.agentId,outcomeValue:d,result:n})}function hu(n){let e=n.update;if(e?.sessionUpdate!=="agent_message_chunk")return!1;let s=e.content;if(!s||typeof s!="object")return!1;let o=s;return o.type!=="text"||typeof o.text!="string"?!1:o.text.startsWith("Model metadata for `")}U();ie();import{randomBytes as pu}from"node:crypto";import{chmod as mu,mkdir as wu,writeFile as No}from"node:fs/promises";import{createServer as _u}from"node:http";import{dirname as yu}from"node:path";var bu=1e6,oi=D("ipc"),$n=class{server=null;port=0;token="";routes;paths;constructor(e){this.routes=new Map(e.routes.map(s=>[`${s.method} ${s.path}`,s])),this.paths=e.paths??q()}async start(){this.token=pu(32).toString("hex");let e=_u((o,c)=>{this.dispatch(o,c)});this.server=e,await new Promise((o,c)=>{e.once("error",c),e.listen(0,"127.0.0.1",()=>o())});let s=e.address();if(!s||typeof s!="object")throw new Error("failed to obtain IPC port");return this.port=s.port,await this.persistAuthFiles(),oi.info("IPC listening",{port:this.port}),{port:this.port,token:this.token}}async stop(){let e=this.server;e&&(await new Promise((s,o)=>{e.close(c=>c?o(c):s())}),this.server=null)}async persistAuthFiles(){await wu(yu(this.paths.portFile),{recursive:!0}),await No(this.paths.portFile,String(this.port),"utf8"),await No(this.paths.tokenFile,this.token,{encoding:"utf8",mode:384});try{await mu(this.paths.tokenFile,384)}catch(e){oi.warn("chmod token file failed (non-POSIX?)",{err:String(e)})}}async dispatch(e,s){if(e.headers.authorization!==`Bearer ${this.token}`){sn(s,401,{error:"unauthorized"});return}let c=`${e.method} ${(e.url??"").split("?")[0]}`,d=this.routes.get(c);if(!d){sn(s,404,{error:"not found"});return}let u=null;if(e.method==="POST")try{u=await vu(e)}catch(l){sn(s,400,{error:"invalid json",detail:String(l)});return}try{let l=await d.handler(u,e);sn(s,200,l??{ok:!0})}catch(l){oi.error("IPC handler failed",{key:c,err:String(l)}),sn(s,500,{error:l instanceof Error?l.message:String(l)})}}};function sn(n,e,s){n.statusCode=e,n.setHeader("content-type","application/json"),n.end(JSON.stringify(s))}async function vu(n){let e=[],s=0;for await(let c of n){let d=c;if(s+=d.length,s>bu)throw new Error("body too large");e.push(d)}let o=Buffer.concat(e).toString("utf8");return o?JSON.parse(o):null}import{sep as Mo}from"node:path";import{fileURLToPath as Su}from"node:url";function Bo(){return Eu(Su(import.meta.url))}function Eu(n){let e=`${Mo}src${Mo}`;return n.includes(e)}U();ie();import{spawn as Iu}from"node:child_process";import{existsSync as Au,mkdirSync as Cu,openSync as Pu}from"node:fs";import{dirname as ku}from"node:path";import{fileURLToPath as Tu}from"node:url";var Du=D("spawn-helper");function Ru(n){return Au(n.libEntry)?n.libEntry:Tu(new URL("../index.ts",import.meta.url))}function Lu(n,e,s){let o=n.endsWith(".ts"),c=["--upgrade-helper",`--target-version=${e}`,`--old-pid=${s}`];return o?["--import","tsx/esm",n,...c]:[n,...c]}async function zo(n,e,s={}){let o=s.paths??q(),c=Ru(o);Cu(ku(o.logFile),{recursive:!0});let d=Pu(o.logFile,"a"),u=Lu(c,n,e),l=Iu(process.execPath,u,{detached:!0,stdio:["ignore",d,d],env:{...process.env,COZE_BRIDGE_UPGRADE_HELPER:"1"}});if(l.unref(),typeof l.pid!="number")throw new Error("failed to spawn upgrade helper (no pid)");Du.info("upgrade helper spawned",{pid:l.pid,targetVersion:n,oldPid:e,entry:c})}U();import{mkdir as Ou,writeFile as Nu}from"node:fs/promises";import{dirname as Mu}from"node:path";import{gunzipSync as Bu}from"node:zlib";var ai=D("tarball-downloader"),zu="https://registry.npmjs.org",Fo="package/dist/index.js";async function Uo(n,e,s={}){if(!/^[\w.\-+]+$/.test(n))throw new Error(`invalid version string: ${JSON.stringify(n)}`);let c=`${(s.registry??zu).replace(/\/+$/,"")}/coze-bridge/${n}`;ai.info("fetching tarball metadata",{metaUrl:c});let d=await fetch(c);if(!d.ok)throw new Error(`registry metadata ${c} returned ${d.status}`);let l=(await d.json())?.dist?.tarball;if(!l)throw new Error(`registry metadata missing dist.tarball for ${n}`);ai.info("downloading tarball",{tarballUrl:l});let p=await fetch(l);if(!p.ok)throw new Error(`tarball ${l} returned ${p.status}`);let m=Buffer.from(await p.arrayBuffer()),_=Bu(m),y=Fu(_,Fo);if(!y)throw new Error(`tarball missing entry ${Fo}`);await Ou(Mu(e),{recursive:!0}),await Nu(e,y),ai.info("dist extracted",{destPath:e,bytes:y.length})}function Fu(n,e){let s=0;for(;s+512<=n.length;){let o=n.subarray(s,s+512);if(o.every(_=>_===0))return null;let c=o.subarray(0,100),d=c.indexOf(0),u=c.subarray(0,d===-1?100:d).toString("utf8"),l=o.subarray(124,136).toString("ascii").trim().replace(/\0/g,""),p=Number.parseInt(l,8)||0,m=s+512;if(u===e)return n.subarray(m,m+p);s=m+Math.ceil(p/512)*512}return null}Lt();U();import{resolve as Uu}from"node:path";function qo(n,e){let s=n.split(".").map(Number),o=e.split(".").map(Number),c=Math.max(s.length,o.length);for(let d=0;d<c;d++){let u=s[d]??0,l=o[d]??0;if(u<l)return!0;if(u>l)return!1}return!1}var ft=D("upgrade-manager"),qu=300*1e3,Hu=3,Vn=class{constructor(e){this.opts=e}opts;inFlightTarget=null;async requestUpgrade(e){if(this.inFlightTarget===e){ft.debug("upgrade already in-flight, skip",{targetVersion:e});return}this.inFlightTarget=e;try{let s=await at(this.opts.paths.configFile)??{};if(s.disableAutoUpgrade){ft.info("disableAutoUpgrade=true, skip",{targetVersion:e});return}if(this.opts.isDevMode()){ft.warn("dev mode, skip auto-upgrade",{targetVersion:e});return}if(!qo(this.opts.currentVersion,e)){ft.debug("local version >= target, skip",{local:this.opts.currentVersion,target:e});return}let o=s.upgradeAttempts?.[e];if((o?.count??0)>=Hu){ft.warn("upgrade attempts cap reached, skip",{targetVersion:e,count:o?.count});return}let c=Uu(this.opts.paths.libDir,"index.js.next");try{await this.opts.download(e,c)}catch(u){await this.recordAttempt(s,e,String(u)),ft.warn("download failed, attempt recorded",{targetVersion:e,err:String(u)});return}this.opts.daemon.markUpgradePending(e);let d=await this.opts.daemon.waitIdle(qu);ft.info("waitIdle done",{result:d}),await this.opts.spawnHelper(e,process.pid),this.opts.daemon.exit(0)}finally{this.inFlightTarget=null}}async recordAttempt(e,s,o){e.upgradeAttempts=e.upgradeAttempts??{};let c=e.upgradeAttempts[s];e.upgradeAttempts[s]={count:(c?.count??0)+1,lastAt:Date.now(),...o?{lastError:o}:{}},await ze(e,this.opts.paths.configFile)}};var xc=Ke(Qo(),1);var Sl=Ke(Ja(),1),El=Ke(ur(),1),Il=Ke(Mt(),1),Al=Ke(yi(),1),Cl=Ke(Si(),1),Pl=Ke(ki(),1),nc=Ke(hr(),1),kl=Ke(tc(),1);var rc=nc.default;U();var ge=D("upstream.frontier"),sc="application/json",oc="none",gn=class{constructor(e){this.opts=e}opts;fws=null;handler=null;connectHandlers=[];opened=!1;openCount=0;async start(){if(this.fws){ge.warn("start called on already-started FrontierUpstream; noop");return}let e={Authorization:`Bearer ${this.opts.privatecode}`,Origin:Ls,...Ct(this.opts.ppeOverride)};class s extends rc{constructor(l){super(l,Rs,{headers:e})}send(l,...p){if(hs("debug"))try{let m;typeof l=="string"?m=Buffer.from(l,"utf8"):l instanceof Buffer?m=l:l instanceof ArrayBuffer?m=new Uint8Array(l):ArrayBuffer.isView(l)?m=new Uint8Array(l.buffer,l.byteOffset,l.byteLength):m=new Uint8Array(0);let _=Buffer.from(m.slice(0,128)).toString("hex");ge.debug("WS raw frame out",{bytes:m.byteLength,headHex:_})}catch(m){ge.warn("WS raw frame dump failed",{err:String(m)})}super.send(l,...p)}}let o=Ns(this.opts.urlOverride),c={url:o,ws:s,fpID:Ds,aID:Ln,accessKey:this.opts.handshake.accessKey,deviceID:this.opts.handshake.deviceId,payloadType:{type:sc,force:!0},payloadEncoding:{encoding:oc,force:!0},enableTransformTextPayload:!0,enableQoS:!1,enableAutoAck:!1,automaticOpen:!1,maxRetries:Number.POSITIVE_INFINITY,debug:this.opts.debug??!1},d=new xc.FWS(c);d.onopen=()=>{this.opened=!0,this.openCount+=1;let u=this.openCount===1;ge.info("frontier opened",{url:o,remoteDeviceId:this.opts.handshake.deviceId,initial:u,openCount:this.openCount});for(let l of this.connectHandlers)Promise.resolve(l({initial:u})).catch(p=>ge.warn("onConnect handler threw (ignored)",{err:String(p)}))},d.onclose=u=>{this.opened=!1,ge.info("frontier closed",{code:u.code,reason:u.reason,willReconnect:u.willReconnect})},d.onerror=u=>{ge.warn("frontier error",{code:u.code,msg:u.message})},d.onmessage=u=>this.handleMessage(u),this.fws=d,await d.connect()}async stop(e){let s=this.fws;if(s){this.fws=null,this.opened=!1;try{s.close(1e3,e??"bridge shutdown")}catch(o){ge.warn("frontier close threw (ignored)",{err:String(o)})}}}async send(e){let s=this.fws;if(!s)throw new S("UPSTREAM_DISCONNECTED","frontier upstream not started");if(!this.isConnected())throw new S("UPSTREAM_DISCONNECTED",`frontier ws not open (opened=${this.opened}, readyState=${s.readyState}); refusing to silently buffer`);this.injectAgentPatToken(e);let o=JSON.stringify(e),c=e;ac(c)||ge.info("frontier frame out",{method:c.method,jsonrpcId:c.id,size:o.length});try{await s.send(o,{service:33555712,method:1,payloadType:sc,payloadEncoding:oc})}catch(u){throw ge.warn("frontier frame send failed",{method:c.method,jsonrpcId:c.id,err:String(u)}),new S("UPSTREAM_DISCONNECTED",`frontier send failed: ${String(u)}`,{cause:u})}}onFrame(e){this.handler=e}onConnect(e){this.connectHandlers.push(e)}isConnected(){return this.opened&&this.fws?.readyState===1}injectAgentPatToken(e){let s=this.opts.getPatTokenForAgent;if(!s)return;let o=e.params?._meta;if(!o?.cozeAgentId)return;let c=s(o.cozeAgentId);c&&(o.cozePatToken=c)}handleMessage(e){let s=e.message?.service;if(s!==33555712){ge.debug("drop non-adapter frontier frame",{service:s});return}let o=Ll(e);if(!o){ge.debug("frontier message without text payload, drop",{payloadType:e.message?.payloadType});return}if(!this.handler){ge.debug("frame received but no onFrame handler",{size:o.length});return}let c;try{c=JSON.parse(o)}catch(u){ge.warn("frontier message JSON parse failed",{err:String(u),head:o.slice(0,80)});return}let d=c;ac(d)||ge.info("frontier frame in",{logid:Rl(e.message?.LogID),logidNew:e.message?.LogIDNew,msgId:e.message?.msgID,jsonrpcId:d.id,method:d.method,body:Dl(o)}),Promise.resolve(this.handler(c)).catch(u=>ge.warn("frontier frame handler threw",{err:String(u)}))}};function ac(n){return n.method==="_agent/health"?!0:typeof n.id=="string"&&n.id.startsWith("agent.health_")}var cc=2e3;function Dl(n){return n.length<=cc?n:`${n.slice(0,cc)}...<truncated, total ${n.length} chars>`}function Rl(n){return n?n.high===0?String(n.low>>>0):`${n.high.toString(16)}${(n.low>>>0).toString(16).padStart(8,"0")}`:""}function Ll(n){let e=n.message;if(e?.textPayload)return e.textPayload;let s=e?.payload;if(!s)return null;try{return Buffer.from(s).toString("utf8")}catch{return null}}U();var Di=D("upstream.switchable"),mr=class{inner;handler=null;connectHandlers=[];constructor(e){this.inner=e}async swap(e,s){if(this.inner===e)return;Di.info("swap upstream",{reason:s});let o=this.inner;if(this.inner=e,this.handler&&e.onFrame(this.handler),e.onConnect)for(let c of this.connectHandlers)e.onConnect(c);try{await e.start()}catch(c){throw Di.error("swap target start failed, reverting",{err:String(c)}),this.inner=o,c}await o.stop(s??"swapped").catch(c=>Di.warn("previous upstream stop threw (ignored)",{err:String(c)}))}current(){return this.inner}start(){return this.inner.start()}stop(e){return this.inner.stop(e)}send(e){return this.inner.send(e)}onFrame(e){this.handler=e,this.inner.onFrame(e)}onConnect(e){this.connectHandlers.push(e),this.inner.onConnect?.(e)}isConnected(){return this.inner.isConnected()}};U();var Ri=D("upstream"),Ht=class{handler=null;async start(){Ri.info("NoopUpstream started (M1 skeleton; real Frontier wired in M4)")}async stop(e){Ri.info("NoopUpstream stopped",{reason:e})}async send(e){Ri.debug("NoopUpstream.send (dropped)",{method:"method"in e?e.method:void 0})}onFrame(e){this.handler=e}isConnected(){return!1}async injectFrame(e){this.handler&&await this.handler(e)}};U();U();ie();import{promises as Li}from"node:fs";import{dirname as Ol}from"node:path";var Nl=D("pat-token-store");async function dc(n=q()){try{let s=(await Li.readFile(n.patTokenFile,"utf8")).trim();return s.length>0?s:null}catch(e){return e?.code!=="ENOENT"&&Nl.warn("read pat-token failed (treating as missing)",{err:String(e)}),null}}async function hn(n,e=q()){if(!n)throw new Error("writePatToken: empty patToken");await Li.mkdir(Ol(e.patTokenFile),{recursive:!0}),await Li.writeFile(e.patTokenFile,n,{encoding:"utf8",mode:384})}ie();ie();import{promises as wr}from"node:fs";import{join as Ml}from"node:path";function Bl(n){return`#!/bin/sh
|
|
115
|
+
`;var Se=L("agent-detail-sync"),ux=6e4,fx=5*6e4,Dn=class{constructor(e){this.opts=e}opts;retryQueue=new Map;async syncAll(e){let s=this.opts.paths.agentsRoot,o;try{o=await dx(s)}catch(c){Se.info("agents dir not found, skip detail sync",{root:s,err:String(c)});return}Se.info("starting detail sync",{reason:e,count:o.length}),await Promise.allSettled(o.map(async c=>{let d=await we(c,this.opts.paths).catch(()=>null);if(d){if(d.disconnectedAt){Se.debug("detail sync: skip disconnected agent",{agentId:c});return}try{await this.syncOne(c,d)}catch(u){Se.warn("detail sync failed for agent, skipping",{agentId:c,err:String(u)})}}})),Se.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){Se.info("retrying pending detail syncs",{count:s.length});for(let o of s)try{await this.syncOne(o)}catch(c){Se.debug("detail sync retry still failing, will try again",{agentId:o,err:String(c)})}}}async syncOne(e,s){let o=s??await we(e,this.opts.paths);if(!o){Se.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(g){Se.warn("detail RPC failed, using local data",{agentId:e,err:String(g)});let p=this.retryQueue.get(e),m=p?Math.min(p.currentDelay*2,fx):ux;this.retryQueue.set(e,{dueAt:Date.now()+m,currentDelay:m});return}if(c.agentId&&c.agentId!==e){Se.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&&Se.info("detail.deployType",{agentId:e,deployType:c.deployType}),!d){Se.debug("detail sync: no diff",{agentId:e});return}await Pe(o,this.opts.paths),Se.info("detail sync: config updated",{agentId:e,identityChanged:u,agentName:o.agentName}),u&&(await Ct(o.workspace,o.framework,e,o.cozeIdentity),this.opts.handlers.reloadAgentSessionsPublic(e,"detail-sync"))}};rt();import{spawn as $s}from"node:child_process";import{lstat as Qr,mkdir as hx,readFile as Vs,readdir as px,rm as mx,stat as _x,writeFile as Ws}from"node:fs/promises";import{join as Me,normalize as yx,relative as Ys,resolve as bx,sep as Xs}from"node:path";var Ne={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 $t(n){return n?.cozeDeployType==="cloud"?"cloud":"local"}function Ts(n){let e=n?.cozeAccountId?.trim();if(!(!e||e==="0"))return e}function Ds(n){let{_meta:e,...s}=n;return{stripped:s,meta:e}}function Pt(n){if(!n?.cozeAgentId)throw new Error("missing _meta.cozeAgentId");return n.cozeAgentId}var b=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();se();function Je(n,e){if($t(n)!=="cloud")throw new b("OPERATION_NOT_ALLOWED_FOR_LOCAL",`${e} is not allowed for local agent`)}function Rn(n){return n.startsWith("http://")||n.startsWith("https://")}function Ln(n){return n.endsWith("/")?n.slice(0,-1):n}q();var On="1008033",Rs="1289";var Ls="pbbp2",Os="https://www.coze.cn",Ns="/api/coze_claw/resource/get_frontier_key",lx="https://www.coze.cn",gx="wss://frontier.coze.cn";function Nn(n){return n??process.env.COZE_BRIDGE_HANDSHAKE_URL??lx}function Bs(n){return n??process.env.COZE_BRIDGE_FRONTIER_URL??gx}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 Vt(n){return n?n.startsWith("boe_")?{ttEnv:n}:{ttEnv:n,usePpe:"1"}:{}}var Ms=L("handshake");async function Vr(n){let e=Nn(n.endpoint),s=n.timeoutMs??1e4,o=`${Ln(e)}${Ns}?aid=${encodeURIComponent(On)}`,c={Authorization:`Bearer ${n.privatecode}`,Accept:"application/json",...kt(n.ppeOverride)},d=new AbortController,u=setTimeout(()=>d.abort(),s);Ms.info("frontier key handshake",{base:e});try{let g=await fetch(o,{method:"GET",headers:c,signal:d.signal}),p=g.headers.get("x-tt-logid")??"",m=g.headers.get("x-tt-trace-id")??"";if(!g.ok){let C=await g.text().catch(()=>"");throw new b("UPSTREAM_HANDSHAKE_FAILED",`handshake HTTP ${g.status} logid=${p}: ${C.slice(0,200)}`)}let _=await g.json();if(_.code!==void 0&&_.code!==0)throw new b("UPSTREAM_HANDSHAKE_FAILED",`handshake code=${_.code} msg=${_.msg??"-"} logid=${p}`);let y=_.data??{},S=typeof y.access_key=="string"&&y.access_key||typeof y.accessKey=="string"&&y.accessKey||void 0,T=typeof y.device_id=="string"&&y.device_id||typeof y.deviceId=="string"&&y.deviceId||void 0;if(!S||!T){let C=JSON.stringify(_).slice(0,500);throw new b("UPSTREAM_HANDSHAKE_FAILED",`handshake response missing access_key/device_id (also tried camelCase) logid=${p}: ${C}`)}return Ms.info("handshake ok",{remoteDeviceId:T,logid:p,traceId:m}),{accessKey:S,deviceId:T}}catch(g){throw g instanceof b?g:g.name==="AbortError"?new b("UPSTREAM_HANDSHAKE_FAILED",`handshake timeout (${s}ms)`):new b("UPSTREAM_HANDSHAKE_FAILED",String(g),{cause:g})}finally{clearTimeout(u)}}var Yr=process.env.COZE_BRIDGE_LLM_GATEWAY_URL?.trim()||"https://llm-gateway.coze.cn",Be="auto";function zs(n){return{model:n.model??Be,...n.modelToken?{modelToken:n.modelToken}:{}}}function Fs(n){return!n||n===Be}function Us(n){let e={};return n.modelToken?(e.ANTHROPIC_BASE_URL=Yr,e.ANTHROPIC_AUTH_TOKEN=n.modelToken,e.ANTHROPIC_MODEL=n.model||Be):Fs(n.model)||(e.ANTHROPIC_MODEL=n.model),e}function qs(n){let e=[];return n.modelToken?e.push("-c",`model="${n.model||Be}"`):Fs(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="${Yr}/v1"`),e.push("-c",'model_providers.coze.env_key="OPENAI_API_KEY"'),e.push("-c",'model_providers.coze.wire_api="responses"'),e.push("-c","model_providers.coze.requires_openai_auth=false"),e.push("-c","model_providers.coze.supports_websockets=false"),e.push("-c",'model_provider="coze"')),e}function Ks(n){return n.modelToken?{OPENAI_API_KEY:n.modelToken}:{}}function Xr(n){let{ttEnv:e,usePpe:s}=Vt(n),o={};return e&&(o["x-tt-env"]=e),s&&(o["x-use-ppe"]=s),o}function Hs(n,e){if(!n.modelToken)return{};let s=Xr(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 Gs(n,e){if(!n.modelToken)return null;let s=n.model||Be,o=Xr(e),c={baseUrl:`${Yr}/v1`,api:"openai-completions",apiKey:n.modelToken,models:[{id:s,name:s,reasoning:!1,input:["text"],cost:{input:0,output:0,cacheRead:0,cacheWrite:0},contextWindow:128e3,maxTokens:8192,api:"openai-completions"}]};return Object.keys(o).length>0&&(c.headers=o),c}function js(n,e){if(!n.modelToken)return[];let s=Xr(e),o=[];for(let[c,d]of Object.entries(s))o.push("-c",`model_providers.coze.http_headers.${c}="${d}"`);return o}var xe=L("agent-handlers"),Js=5*1024*1024,vx=1,Sx=6,Ex=new Set(["node_modules",".git",".coze","dist","build",".next"]),Bn=class{constructor(e){this.opts=e}opts;async listSkills(e){Je(e._meta,"_agent/listSkills");let s=Pt(e._meta),o=await this.loadAgentCfg(s),c=o?.workspace??We(s).workspace,d=o?.skills??[],u=[];for(let g of d){let p=Me(c,g.relPath,"SKILL.md");await _x(p).then(_=>_.isFile()).catch(()=>!1)&&u.push(kx(g))}return{skills:u}}async addSkills(e){Je(e._meta,"_agent/addSkills");let s=Pt(e._meta),o=await this.requireAgentCfg(s),c=e.skills??[],d=[...o.skills??[]],u=new Map(d.map((p,m)=>[p.skillId,m])),g=[];for(let p of c){let m=await ei({agentId:s,workspace:o.workspace,framework:o.framework,skill:p});ti(d,u,m),g.push(p)}return await kn(s,d),this.reloadAgentSessions(s,"skills-added"),{installedSkills:g}}async removeSkills(e){Je(e._meta,"_agent/removeSkills");let s=Pt(e._meta),o=await this.requireAgentCfg(s),c=new Set(e.skillIds??[]),d=o.skills??[],u=[];for(let g of d){if(!c.has(g.skillId)){u.push(g);continue}let p=Me(o.workspace,g.relPath);await mx(p,{recursive:!0,force:!0}),xe.info("skill removed",{agentId:s,skillId:g.skillId,relPath:g.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,xe.info("downstream busy, scheduling reload after turn",{reason:s,agentId:e,framework:o.framework,cloudId:c,acpId:u});continue}let p=d.downstream;d.downstream=void 0,xe.info("killing downstream for workspace reload (idle)",{reason:s,agentId:e,framework:o.framework,cloudId:c,acpId:u}),p.stop(s).catch(m=>xe.warn("downstream stop failed during reload (ignored)",{reason:s,agentId:e,cloudId:c,err:String(m)}))}}isRuntimePendingPermission(e){let s=this.opts.isRuntimePendingPermission;return!s||!e.downstream?!1:s(e.downstream)}async updateAgent(e){if(!e.cozeIdentity?.trim())return xe.info("_agent/update: empty cozeIdentity, noop",{agentId:e.agentId}),{ok:!0};let s=e.agentId,o=await we(s);if(!o)throw new b("AGENT_NOT_FOUND",`agent not found: ${s}`);if(o.cozeIdentity===e.cozeIdentity)return xe.info("_agent/update: cozeIdentity unchanged, noop",{agentId:s}),{ok:!0};try{await Ct(o.workspace,o.framework,s,e.cozeIdentity)}catch(c){throw xe.error("_agent/update: writeInstructionFile failed, aborting update",{agentId:s,framework:o.framework,workspace:o.workspace,err:String(c)}),new b("AGENT_PROTOCOL_ERROR",`failed to write instruction file for agent ${s}: ${String(c)}`,{cause:c})}return o.cozeIdentity=e.cozeIdentity,await Pe(o),xe.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 b("IPC_BAD_REQUEST","_agent/disconnect: missing agentId");let o=await we(s);return o?(o.disconnectedAt=Date.now(),o.disconnectReason=e.reason??"",await Pe(o),xe.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}):(xe.warn("_agent/disconnect: agent not found, ignoring",{agentId:s}),{ok:!0})}async switchModel(e){if(Je(e._meta,"_agent/switchModel"),!e.agentId)throw new b("IPC_BAD_REQUEST","_agent/switchModel: missing agentId");let s=e.model?.trim()?e.model:Be,o=await we(e.agentId);if(!o)throw new b("AGENT_NOT_FOUND",`agent not found: ${e.agentId}`);o.model=s,await Pe(o),xe.info("_agent/switchModel: model persisted",{agentId:e.agentId,model:s,reason:e.reason??""});let c=this.opts.agents.get(e.agentId);if(!c)return xe.info("_agent/switchModel: agent not running, config persisted only",{agentId:e.agentId}),{ok:!0};c.model=s,this.opts.cleanupOpenclawProviders&&await this.opts.cleanupOpenclawProviders(c).catch(u=>xe.warn("cleanupOpenclawProviders before switchModel failed (ignored)",{agentId:e.agentId,err:String(u)}));let d=[];for(let[u,g]of c.allSessionQueues())d.push(g.enqueue(async()=>{let p=c.sessions.get(u);p?.downstream&&(await p.downstream.stop(`switchModel: ${s}`).catch(()=>{}),p.downstream=void 0)}));return await Promise.all(d),xe.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(Je(e._meta,Ne.RESET),!e.agentId)throw new b("IPC_BAD_REQUEST",`${Ne.RESET}: missing agentId`);return await this.runDetailSync(e.agentId,Ne.RESET,e.reason),{ok:!0}}async repairAgent(e){if(Je(e._meta,Ne.REPAIR),!e.agentId)throw new b("IPC_BAD_REQUEST",`${Ne.REPAIR}: missing agentId`);let s=await this.loadAgentCfg(e.agentId);if(s&&s.framework!=="openclaw")throw new b("IPC_BAD_REQUEST",`${Ne.REPAIR} only allowed for openclaw, got ${s.framework}`);if(s&&this.opts.openclawRepair)try{await this.opts.openclawRepair(e.agentId,s.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,Ne.REPAIR,e.reason),{ok:!0}}async runDetailSync(e,s,o){if(!this.opts.detailSyncer){xe.warn("detailSyncer not wired, skipping sync",{method:s,agentId:e});return}try{await this.opts.detailSyncer(e)}catch(c){xe.warn("detail sync failed (ignored)",{method:s,agentId:e,reason:o,err:String(c)})}}async getFileTree(e){Je(e._meta,"_agent/getFileTree");let s=e._meta,o=Pt(s),c=await this.resolveWorkspace(o),d=e.filePath??"",u=this.safeJoin(c,d),g=await Qr(u).catch(()=>null);if(!g)throw new b("IPC_BAD_REQUEST",`path not found: ${d}`);if(g.isSymbolicLink())throw new b("IPC_BAD_REQUEST",`symlink not allowed: ${d}`);let p=Mx(e.depth);return g.isDirectory()?{tree:await Bx(c,u,d,p)}:{tree:[{name:zx(d),path:Qs(d||"."),isDir:!1,size:g.size,modifiedAt:Math.floor(g.mtimeMs)}]}}async getFileContent(e){Je(e._meta,"_agent/getFileContent");let s=Pt(e._meta),o=await this.resolveWorkspace(s);if(!e.filePath)throw new b("IPC_BAD_REQUEST","filePath required");let c=this.safeJoin(o,e.filePath),d=await Qr(c).catch(()=>null);if(!d||!d.isFile())throw new b("IPC_BAD_REQUEST",`not a file: ${e.filePath}`);if(d.isSymbolicLink())throw new b("IPC_BAD_REQUEST",`symlink not allowed: ${e.filePath}`);if(d.size>Js)throw new b("IPC_BAD_REQUEST",`file too large: ${d.size} bytes (max ${Js})`);let u=await Vs(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 we(e).catch(()=>null))?.workspace??We(e).workspace}safeJoin(e,s){let o=bx(e,s||"."),c=Ys(e,o);if(c.startsWith("..")||c===".."||c.startsWith(`..${Xs}`))throw new b("IPC_BAD_REQUEST",`path escapes workspace: ${s}`);return o}loadAgentCfg(e){return we(e)}async requireAgentCfg(e){let s=await this.loadAgentCfg(e);if(!s)throw new b("AGENT_NOT_FOUND",`no config for agent: ${e}`);return s}};function Ax(n){let e=n.trim().replace(/[\x00-\x1f<>:"|?*/\\]+/g,"-").replace(/^[\s.-]+|[\s.-]+$/g,"").slice(0,64);if(!e||e==="."||e==="..")throw new b("IPC_BAD_REQUEST",`invalid skill name: ${n}`);if(/^(con|prn|aux|nul|com[1-9]|lpt[1-9])$/i.test(e))throw new b("IPC_BAD_REQUEST",`reserved windows filename: ${n}`);return e}function Ix(n){return n==="claude-code"?Me(".claude","skills"):Me(".agents","skills")}var Cx=3e4,Px=50*1024*1024,Mn=3e4;async function ei(n){let{agentId:e,workspace:s,framework:o,skill:c}=n;if(!c.skillName)throw new b("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 b("IPC_BAD_REQUEST",`skill ${c.skillId} missing both content and downloadUrl`);let g=Ax(c.skillName),p=Ix(o),m=Me(p,g),_=Me(s,m);if(await hx(_,{recursive:!0}),d){let S=Buffer.from(c.content,"utf8");Yt(S.length),await Ws(Me(_,"SKILL.md"),S,"utf8")}else{let S=await Tx(c.downloadUrl);Rx(S)?await Lx(S,_):await Ws(Me(_,"SKILL.md"),S.toString("utf8"),"utf8")}let y={skillId:c.skillId,skillName:c.skillName,relPath:m,installedAt:Date.now(),...c.description?{description:c.description}:{},...c.icon?{icon:c.icon}:{},...c.version?{version:c.version}:{},...c.downloadUrl?{downloadUrl:c.downloadUrl}:{},...c.config?{config:c.config}:{},...c.builtin?{builtin:c.builtin}:{}};return xe.info("skill installed",{agentId:e,skillId:c.skillId,skillName:c.skillName,relPath:m,source:d?"content":"downloadUrl"}),y}function ti(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 kx(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 Tx(n){if(!n)throw new b("IPC_BAD_REQUEST","skill missing downloadUrl");if(n.startsWith("data:")){let e=Math.floor(n.length*3/4);Yt(e);let s=Dx(n);return Yt(s.length),s}if(n.startsWith("file:")){let e=new URL(n).pathname,s=await Vs(e);return Yt(s.length),s}if(Rn(n)){let e=new AbortController,s=setTimeout(()=>e.abort(),Cx);try{let o=await fetch(n,{signal:e.signal});if(!o.ok)throw new b("IPC_BAD_REQUEST",`fetch skill failed HTTP ${o.status} ${n}`);let c=await o.arrayBuffer();return Yt(c.byteLength),Buffer.from(c)}finally{clearTimeout(s)}}throw new b("IPC_BAD_REQUEST",`unsupported downloadUrl scheme (\u8981 https/data/file): ${n.slice(0,80)}`)}function Yt(n){if(n>Px)throw new b("IPC_BAD_REQUEST",`skill too large: ${n} bytes`)}function Dx(n){let e=/^data:([^,;]*)(;base64)?,(.*)$/s.exec(n);if(!e)throw new b("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 Rx(n){return n.length>=2&&n[0]===31&&n[1]===139}async function Lx(n,e){await Ox(n),await new Promise((s,o)=>{let c=$s("tar",["-xzf","-","-C",e,"--strip-components=1","--no-same-owner"],{stdio:["pipe","pipe","pipe"]}),d="";c.stderr?.on("data",g=>{d+=String(g)});let u=setTimeout(()=>{c.kill("SIGKILL"),o(new b("IPC_BAD_REQUEST",`tar extract timeout (${Mn}ms)`))},Mn);c.on("error",g=>{clearTimeout(u),o(new b("IPC_BAD_REQUEST",`tar spawn failed: ${g.message}`,{cause:g}))}),c.on("exit",g=>{clearTimeout(u),g===0?s():o(new b("IPC_BAD_REQUEST",`tar exit ${g}${d?`: ${d.trim().slice(0,200)}`:""}`))}),c.stdin?.end(n)})}async function Ox(n){let e=await new Promise((s,o)=>{let c=$s("tar",["-tzvf","-"],{stdio:["pipe","pipe","pipe"]}),d="",u="";c.stdout?.on("data",p=>{d+=String(p)}),c.stderr?.on("data",p=>{u+=String(p)});let g=setTimeout(()=>{c.kill("SIGKILL"),o(new b("IPC_BAD_REQUEST",`tar list timeout (${Mn}ms)`))},Mn);c.on("error",p=>{clearTimeout(g),o(new b("IPC_BAD_REQUEST",`tar list spawn failed: ${p.message}`))}),c.on("exit",p=>{clearTimeout(g),p===0?s(d):o(new b("IPC_BAD_REQUEST",`tar list exit ${p}${u?`: ${u.trim().slice(0,200)}`:""}`))}),c.stdin?.end(n)});for(let s of e.split(`
|
|
117
|
+
`)){let o=s.trim();if(!o)continue;let c=o.charCodeAt(0);if(c!==45&&c!==100)throw new b("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 b("IPC_BAD_REQUEST",`tar entry absolute path: ${u}`);if(u.split(/[/\\]/).some(p=>p===".."))throw new b("IPC_BAD_REQUEST",`tar entry contains '..': ${u}`)}}var Nx=5e3;async function Bx(n,e,s,o){return Zs(n,e,s,o,{count:0})}async function Zs(n,e,s,o,c){if(o<=0)return[];let d;try{d=await px(e,{withFileTypes:!0})}catch{return[]}let u=[];for(let g of d){if(Ex.has(g.name)||g.isSymbolicLink())continue;if(c.count>=Nx){u.push({name:"...",path:"...",isDir:!1,size:0,modifiedAt:0,hasMore:!0});break}let p=Me(e,g.name),m=yx(Me(s,g.name)),_=null;try{_=await Qr(p)}catch{continue}if(_.isSymbolicLink())continue;c.count++;let y={name:g.name,path:Qs(Ys(n,p)),isDir:_.isDirectory(),size:_.size,modifiedAt:Math.floor(_.mtimeMs)};_.isDirectory()&&o>1&&(y.children=await Zs(n,p,m,o-1,c)),u.push(y)}return u.sort((g,p)=>g.isDir!==p.isDir?g.isDir?-1:1:g.name.localeCompare(p.name)),u}function Mx(n){return!n||n<=0?vx:Math.min(n,Sx)}function zx(n){if(!n||n==="."||n==="/")return".";let e=n.split(/[/\\]/);return e[e.length-1]||"."}function Qs(n){return n.split(Xs).join("/")}q();import{readFileSync as ap}from"node:fs";import{dirname as xp,join as dp}from"node:path";import{fileURLToPath as fp}from"node:url";var it="0.1.51";var ze=L("agent-health-reporter"),Fx=1e4,Xt=class{constructor(e){this.opts=e;this.intervalMs=e.intervalMs??Fx}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()}),ze.info("heartbeat started",{intervalMs:this.intervalMs}),this.tick())}stop(){this.timer&&(clearInterval(this.timer),this.timer=null,this.unsubscribeRegister&&(this.unsubscribeRegister(),this.unsubscribeRegister=null),ze.info("heartbeat stopped"))}async tick(){if(this.inFlight){ze.debug("previous tick still in-flight, skip");return}let e=this.opts.getDeviceId();if(!e){ze.debug("deviceId not available, skip tick (\u5C1A\u672A pair)");return}this.inFlight=!0;try{let s=[];for(let g of this.opts.core.agents.values()){let p=Ux(g);if(!p)continue;let m={agentId:g.agentId,status:p};g.patToken&&(m.patToken=g.patToken),g.accountId&&(m.accountId=g.accountId),s.push(m)}if(s.length===0)return;let o={agents:s,bridgeVersion:it,_meta:{cozeDeviceId:e}},c;try{c=await this.opts.core.sendRequest("_agent/health",o,5e3)}catch(g){ze.warn("heartbeat batch send failed",{count:s.length,err:String(g)})}let d=c?.authFailures;if(d&&d.length>0&&(ze.warn("heartbeat received authFailures from cloud",{count:d.length,agentIds:d.map(g=>g.agentId)}),this.opts.onAuthFailures))try{await this.opts.onAuthFailures(d)}catch(g){ze.warn("onAuthFailures callback failed (ignored)",{err:String(g)})}let u=c?.minBridgeVersion;if(u&&(ze.info("heartbeat received minBridgeVersion from cloud",{minV:u}),this.opts.onMinBridgeVersion))try{await this.opts.onMinBridgeVersion(u)}catch(g){ze.warn("onMinBridgeVersion callback failed (ignored)",{err:String(g)})}}finally{this.inFlight=!1}if(this.opts.onTickEnd)try{await this.opts.onTickEnd()}catch(s){ze.warn("onTickEnd hook failed",{err:String(s)})}}};function Ux(n){return n.status==="error"?"error":n.activeTriggers.size>0?"busy":n.status==="ok"?"online":null}rt();import{mkdir as ri,rm as fd}from"node:fs/promises";import{spawn as $x,spawnSync as Vx}from"node:child_process";function Zt(n,e,s){return s===void 0?{jsonrpc:"2.0",id:n,method:e}:{jsonrpc:"2.0",id:n,method:e,params:s}}function Qt(n,e){return e===void 0?{jsonrpc:"2.0",method:n}:{jsonrpc:"2.0",method:n,params:e}}function Tt(n,e){return{jsonrpc:"2.0",id:n,result:e}}function st(n,e){return{jsonrpc:"2.0",id:n,error:e}}var zn=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)}},G={PARSE_ERROR:-32700,INVALID_REQUEST:-32600,METHOD_NOT_FOUND:-32601,INVALID_PARAMS:-32602,INTERNAL_ERROR:-32603,AGENT_NOT_FOUND:-32001,AGENT_BUSY:-32002,AGENT_TIMEOUT:-32003,AGENT_SPAWN_FAILED:-32004,OPERATION_NOT_ALLOWED_FOR_LOCAL:-32005,AGENT_DISCONNECTED:-32006,MODEL_TOKEN_GEN_FAILED:-32009,PATH_OUTSIDE_WORKSPACE:-32010,FILE_TOO_LARGE:-32011,UNSUPPORTED_MIME:-32012,UPLOAD_FAILED:-32013,UPSTREAM_NOT_READY:-32014,BRIDGE_UPGRADING:-32015};function eo(n){return"method"in n&&"id"in n&&n.id!==void 0}function to(n){return"method"in n&&!("id"in n)}function Fn(n){return!("method"in n)&&"id"in n}var qx={AGENT_NOT_FOUND:G.AGENT_NOT_FOUND,AGENT_BUSY:G.AGENT_BUSY,AGENT_DISCONNECTED:G.AGENT_DISCONNECTED,AGENT_TIMEOUT:G.AGENT_TIMEOUT,AGENT_SPAWN_FAILED:G.AGENT_SPAWN_FAILED,AGENT_PROTOCOL_ERROR:G.INTERNAL_ERROR,BRIDGE_CONFIG_INVALID:G.INTERNAL_ERROR,BRIDGE_INTERNAL:G.INTERNAL_ERROR,IPC_AUTH_FAILED:G.INTERNAL_ERROR,IPC_BAD_REQUEST:G.INVALID_REQUEST,MODEL_TOKEN_GEN_FAILED:G.MODEL_TOKEN_GEN_FAILED,OPERATION_NOT_ALLOWED_FOR_LOCAL:G.OPERATION_NOT_ALLOWED_FOR_LOCAL,UPSTREAM_DISCONNECTED:G.INTERNAL_ERROR,UPSTREAM_HANDSHAKE_FAILED:G.INTERNAL_ERROR,PATH_OUTSIDE_WORKSPACE:G.PATH_OUTSIDE_WORKSPACE,FILE_TOO_LARGE:G.FILE_TOO_LARGE,UNSUPPORTED_MIME:G.UNSUPPORTED_MIME,UPLOAD_FAILED:G.UPLOAD_FAILED,UPSTREAM_NOT_READY:G.UPSTREAM_NOT_READY,BRIDGE_UPGRADING:G.BRIDGE_UPGRADING};function Kx(n){if(n!=null)return n instanceof Error?{name:n.name,message:en(n.message)}:typeof n=="string"?en(n):typeof n=="object"?Gx(n):n}var Hx=[[/\/Users\/[^/\s'"`)]+/g,"/Users/<redacted>"],[/\/home\/[^/\s'"`)]+/g,"/home/<redacted>"],[/[A-Za-z]:\\Users\\[^\\\s'"`)]+/g,"C:\\Users\\<redacted>"],[/(Bearer|Token|Authorization:)\s+[\w._-]+/gi,"$1 <redacted>"],[/\b(sk|pat|ak)[-_][A-Za-z0-9_-]{20,}\b/g,"<redacted-key>"]];function en(n){let e=n;for(let[s,o]of Hx)e=e.replace(s,o);return e}function Gx(n){let e={};for(let[s,o]of Object.entries(n))typeof o=="string"?e[s]=en(o):e[s]=o;return e}function tn(n){if(n instanceof b){let e=Kx(n.cause),s={bridgeCode:n.code,retriable:n.retriable};return e!==void 0&&(s.cause=e),{code:qx[n.code]??G.INTERNAL_ERROR,message:en(n.message),data:s}}return{code:G.INTERNAL_ERROR,message:en(n instanceof Error?n.message:String(n))}}function no(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,...g}=e;d=g}return new b(s,c,{retriable:e?.retriable??!1,cause:d})}function io(n){return`${JSON.stringify(n)}
|
|
118
|
+
`}var ro=10*1024*1024,Un=class{buffer="";onError;constructor(e={}){this.onError=e.onError}push(e){if(this.buffer+=typeof e=="string"?e:e.toString("utf8"),this.buffer.length>ro){let c=this.buffer.length;return this.buffer="",this.onError?.({line:`<buffer overflow: ${c} bytes, dropped>`,error:new Error(`LdjsonDecoder buffer exceeded ${ro} 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 oo={"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"},Sp=Object.fromEntries(Object.entries(oo).map(([n,e])=>[e,n])),jx={"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:[]},Dt=class{seq=0;next(e,s){this.seq+=1;let o=oo[e]??Wx(e),c=jx[o]??[],d=[o,String(this.seq)];if(c.length>0){let u=c.map(p=>so(s?.[p]??"")),g=Jx(u).join(":");g&&d.push(g)}else s&&Object.values(s).some(u=>u)&&d.push(Object.values(s).filter(Boolean).map(u=>so(String(u))).join(":"));return d.join("_")}reset(){this.seq=0}};function Wx(n){return n.replace(/[\s/]+/g,".").replace(/_+/g,"-")}function so(n){return n.replace(/[:_\s]+/g,"-")}function Jx(n){let e=n.length;for(;e>0&&!n[e-1];)e-=1;return n.slice(0,e)}function qn(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 Yx=3e4,Xx=200,Zx=qn("COZE_BRIDGE_SESSION_PROMPT_MAX_MS",3600*1e3),ao=500;function Qx(n){try{let e=JSON.stringify(n);return e===void 0||e.length<=ao?n:`${e.slice(0,ao)}...<truncated, total ${e.length} chars>`}catch{return"<unserializable>"}}function co(n,e){if(!(typeof n!="number"||n<=0))try{if(process.platform==="win32"){let s=["/PID",String(n),"/T"];e==="SIGKILL"&&s.push("/F"),Vx("taskkill",s,{stdio:"ignore",windowsHide:!0})}else process.kill(-n,e)}catch{}}var ot=class{constructor(e){this.opts=e;this.log=L(`downstream.${this.constructor.name}`),this.decoder=new Un({onError:s=>this.log.warn("decode line failed",{line:s.line})})}opts;child;decoder;pending=new Map;idAllocator=new Dt;updateHandlers=[];agentRequestHandlers=[];exitHandlers=[];log;stopped=!1;stderrRing=[];sanitizeEnv(e){return e}async start(){if(this.child)throw new b("BRIDGE_INTERNAL","Downstream already started");let e=process.platform!=="win32",s=$x(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>Xx&&this.stderrRing.shift(),this.log.debug("stderr",{text:c})}),s.stdin?.on("error",o=>{this.log.warn("child stdin error",{err:String(o)})}),s.stdout?.on("error",o=>{this.log.warn("child stdout error",{err:String(o)})}),s.stderr?.on("error",o=>{this.log.warn("child stderr error",{err:String(o)})}),s.on("exit",(o,c)=>{this.stopped=!0,(o!==0||c!==null)&&this.stderrRing.length>0&&this.log.warn("downstream exited abnormally, recent stderr",{code:o,signal:c,recentStderr:[...this.stderrRing]});try{for(let u of this.decoder.flush())this.dispatch(u)}catch(u){this.log.debug("decoder.flush on exit threw (ignored)",{err:String(u)})}this.failAllPending(new b("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 b("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()));co(s.pid,"SIGTERM");let c=setTimeout(()=>{s.killed||co(s.pid,"SIGKILL")},5e3);try{await o}finally{clearTimeout(c)}}pid(){return this.child?.pid}isAlive(){return!!this.child&&!this.stopped}initialize(e){return this.call("initialize",e)}sessionNew(e){return this.call("session/new",{mcpServers:[],...e})}sessionLoad(e){return this.call("session/load",{mcpServers:[],...e})}sessionPrompt(e,s=Zx){return this.call("session/prompt",e,s)}async sessionCancel(e){!this.child||this.stopped||this.writeFrame(Qt("session/cancel",e))}onUpdate(e){this.updateHandlers.push(e)}onAgentRequest(e){this.agentRequestHandlers.push(e)}respondAgentRequest(e,s){if(!(!this.child||this.stopped))try{this.writeFrame(Tt(e,s))}catch(o){this.log.warn("respondAgentRequest write failed",{id:e,err:String(o)})}}respondAgentRequestError(e,s){if(!(!this.child||this.stopped))try{this.writeFrame(st(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=Yx){if(!this.child||this.stopped)return Promise.reject(new b("AGENT_PROTOCOL_ERROR","downstream not started"));let c=this.idAllocator.next(e),d=Zt(c,e,s),u=o>0&&Number.isFinite(o);return new Promise((g,p)=>{let m=u?setTimeout(()=>{this.pending.delete(c),p(new b("AGENT_TIMEOUT",`${e} timed out after ${o}ms`))},o):null;this.pending.set(c,{resolve:g,reject:p,timer:m,method:e});try{this.writeFrame(d)}catch(_){m&&clearTimeout(m),this.pending.delete(c),p(_)}})}writeFrame(e){if(!this.child?.stdin||this.child.stdin.destroyed)throw new b("AGENT_PROTOCOL_ERROR","downstream stdin not writable");this.child.stdin.write(io(e),s=>{s&&this.log.warn("stdin write callback err",{err:String(s)})})}dispatch(e){if(Fn(e)){let s=e.id!==null?this.pending.get(e.id):void 0;if(!s){this.log.warn("orphan response",{id:e.id});return}this.pending.delete(e.id),s.timer&&clearTimeout(s.timer),e.error?(this.log.warn("downstream returned error frame",{id:e.id,method:s.method,code:e.error.code,message:e.error.message,data:e.error.data}),s.reject(no(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 b("AGENT_PROTOCOL_ERROR",`${s.method} response missing both result and error`))):(this.log.info("downstream returned result",{id:e.id,method:s.method,result:Qx(e.result)}),s.resolve(e.result));return}if(to(e)){if(e.method==="session/update")for(let s of this.updateHandlers)try{Promise.resolve(s(e.params)).catch(o=>this.log.warn("update handler failed (async)",{err:String(o)}))}catch(o){this.log.warn("update handler threw sync, swallowed",{err:String(o)})}else this.log.info("unknown notification (drop, not forwarded)",{method:e.method});return}if(eo(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(st(e.id,{code:-32601,message:`method not handled by Bridge: ${e.method}`}));return}for(let s of this.agentRequestHandlers)try{await s(e)}catch(o){this.log.error("agentRequestHandler threw",{method:e.method,err:String(o)});try{this.writeFrame(st(e.id,tn(o)))}catch{}}}failAllPending(e){for(let s of this.pending.values())s.timer&&clearTimeout(s.timer),s.reject(e);this.pending.clear()}};var ed="@agentclientprotocol/claude-agent-acp@latest";function td(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 Kn=class extends ot{framework="claude-code";constructor(e){let s=An("claude-code"),[o,c]=s?[s,[]]:["npx",["-y",ed]],d=e.command??o,u=e.args??c,g={command:d,args:u,cwd:e.cwd,...e.env?{env:e.env}:{}};super(g)}sanitizeEnv(e){return td(e)}};import{mkdtempSync as nd,rmSync as rd}from"node:fs";import{tmpdir as id}from"node:os";import{join as sd}from"node:path";var od="@zed-industries/codex-acp@latest",Hn=class extends ot{framework="codex";authMethodId;codexHomeDir;constructor(e){let s=An("codex"),[o,c]=s?[s,[]]:["npx",["-y",od]],d=e.command??o,u=e.args??c,g=e.extraArgs?[...u,...e.extraArgs]:u,p=e.isolateCodexHome?nd(sd(id(),"coze-bridge-codex-home-")):void 0,m=p?{...e.env??{},CODEX_HOME:p}:e.env,_={command:d,args:g,cwd:e.cwd,...m?{env:m}:{}};super(_),this.authMethodId=e.authMethodId,this.codexHomeDir=p}async initialize(e){let s=await super.initialize(e);return this.authMethodId&&await this.call("authenticate",{methodId:this.authMethodId}),s}async stop(e){if(await super.stop(e),this.codexHomeDir)try{rd(this.codexHomeDir,{recursive:!0,force:!0})}catch{}}};var ad=3e4,Rt=class extends ot{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}`}]},ad))}get acpSessionName(){return this.sessionName}};q();se();function ni(n){return n.replace(/[^A-Za-z0-9._-]+/g,"-")}var Lt=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 Gn=class{agentId;framework;workspace;deployType;accountId;patToken;sessions=new Map;sessionQueues=new Map;activeTriggers=new Map;status="ok";model;lastActiveAt=Date.now();constructor(e){this.agentId=e.agentId,this.framework=e.framework,this.workspace=e.workspace,this.model=e.model,this.deployType=e.deployType??"local",e.accountId&&(this.accountId=e.accountId),e.patToken&&(this.patToken=e.patToken)}setPatToken(e){this.patToken=e}getSessionQueue(e){let s=this.sessionQueues.get(e);return(!s||s.isDisposed)&&(s=new Lt,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)nn(o),o.downstream&&(s.push(o.downstream.stop(e).catch(()=>{})),o.downstream=void 0);await Promise.all(s),this.activeTriggers.clear()}};function nn(n){n.idleTimer&&(clearTimeout(n.idleTimer),n.idleTimer=void 0)}import{spawn as cd}from"node:child_process";import{homedir as xd}from"node:os";import{join as dd}from"node:path";Cn();q();async function fo(){let n=dd(xd(),".openclaw/openclaw.json");return(await It(n))?.gateway?.auth?.token??""}var xo=L("openclaw.config"),ud=[0,5e3,5e3],uo="models.providers.",jn="agents.defaults.models",Wn=class{command;env;retryDelaysMs;queue=new Lt;constructor(e){this.command=e.command,this.env=e.env??process.env,this.retryDelaysMs=e.retryDelaysMs??ud}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,xo.warn("openclaw cli failed, will retry",{label:e,attempt:c+1,err:String(u)})}}throw new b("AGENT_SPAWN_FAILED",`openclaw cli ${e} failed after ${this.retryDelaysMs.length} attempts: ${o?.message??"unknown"}`)}runCli(e){return new Promise((s,o)=>{let c=cd(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){xo.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",`${uo}${e}`,JSON.stringify(s),"--strict-json","--merge"])))}removeProvider(e){return this.bestEffortUnset(`config unset models.providers.${e}`,`${uo}${e}`)}addModelToAllowlist(e,s){let o={[e]:s?{alias:s}:{}};return this.queue.enqueue(()=>this.withRetry(`config set ${jn}[${e}]`,()=>this.runCli(["config","set",jn,JSON.stringify(o),"--strict-json","--merge"])))}removeModelFromAllowlist(e){return this.bestEffortUnset(`config unset ${jn}[${e}]`,`${jn}.${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 Ee=L("agent-manager"),ld=(n,e,s,o,c,d,u,g)=>{switch(n){case"claude-code":{let p={...c?{...Us(c),...Hs(c,u)}:{},...g??{},IS_SANDBOX:"1"};return new Kn({cwd:s,env:p})}case"codex":{let m=[...c?[...qs(c),...js(c,u)]:[],"-c",'sandbox_mode="danger-full-access"',"-c",'approval_policy="never"'],_={...c?Ks(c):{},...g??{}},y=!!c;return new Hn({cwd:s,...m.length>0?{extraArgs:m}:{},...Object.keys(_).length>0?{env:_}:{},...y?{authMethodId:"openai-api-key",isolateCodexHome:!0}:{}})}case"openclaw":return new Rt({command:e,cwd:s,agentId:o,...d?{sessionName:ni(d)}:{}})}};function lo(n){return n==="claude-code"||n==="codex"}var gd={path:"",version:"cloud-deployed"},hd={protocolVersion:1,clientCapabilities:{fs:{readTextFile:!0,writeTextFile:!0}}},pd=6e4,Jn=class{paths;config;registry;factory;createTimeoutMs;openclawConfigCache;ensuredProviders=new Set;constructor(e){this.paths=e.paths,this.config=e.config,this.registry=e.registry,this.factory=e.downstreamFactory??ld,this.createTimeoutMs=e.createTimeoutMs??pd}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 b("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 b("IPC_BAD_REQUEST","agentId required");if(!e.framework)throw new b("IPC_BAD_REQUEST","framework required");let s=$t(e._meta)==="cloud";this.registry.reviveIfDisconnected?.(e.agentId);let o=this.registry.get(e.agentId);if(o){if(o.framework!==e.framework)throw new b("AGENT_BUSY",`agent ${e.agentId} exists with different framework (${o.framework})`);if(o.status==="error")Ee.warn("existing agent in error state, rebuilding",{agentId:e.agentId}),await o.dispose("rebuild after error").catch(C=>Ee.warn("dispose stale agent failed (ignored)",{err:String(C)})),this.registry.unregister(e.agentId);else{if(e.patToken&&e.patToken!==o.patToken){Ee.info("updating agent patToken on re-create (reconnect with new PAT)",{agentId:e.agentId}),o.setPatToken(e.patToken);let C=await we(e.agentId,this.paths).catch(()=>null);C&&(C.patToken=e.patToken,await Pe(C,this.paths))}return Ee.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 b("AGENT_SPAWN_FAILED",`framework ${e.framework} not detected on this machine; rerun daemon to refresh frameworks_cache`);let d=We(e.agentId,this.paths),u=$t(e._meta),g=e.framework==="openclaw"&&u==="local",p=g?this.config.frameworksCache?.openclaw?.defaultAgent?.workspace:void 0,m=e.workspace??p??d.workspace,_=new AbortController,y=setTimeout(()=>_.abort(new b("AGENT_TIMEOUT",`_agent/create timed out after ${this.createTimeoutMs}ms`)),this.createTimeoutMs),S,T=!1;try{s&&lo(e.framework)&&await En(e.framework,_.signal);let C=()=>{if(_.signal.aborted)throw _.signal.reason instanceof Error?_.signal.reason:new b("AGENT_TIMEOUT","_agent/create aborted")};await ri(d.root,{recursive:!0}),await ri(m,{recursive:!0}),await ri(d.logs,{recursive:!0}),C(),g||await Ct(m,e.framework,e.agentId,e.cozeIdentity),e.framework==="claude-code"&&await ks(m),C();let P=await we(e.agentId,this.paths).catch(()=>null),j=zs({model:e.model??P?.model}),Q=Ts(e._meta)??P?.accountId,W=e.patToken??P?.patToken;if(S=new Gn({agentId:e.agentId,framework:e.framework,workspace:m,model:j.model??Be,deployType:u,...Q?{accountId:Q}:{},...W?{patToken:W}:{}}),S.status="ok",P?.sessions){for(let[De,me]of Object.entries(P.sessions))S.sessions.set(De,{acpSessionId:me.acpSessionId,modelToken:me.modelToken,tokenGeneratedAt:me.tokenGeneratedAt,lastActiveAt:Date.now(),loadingSession:!1,replySeq:0});let ce=Object.keys(P.sessions).length;ce>0&&Ee.info("restored persisted session records (no spawn)",{agentId:e.agentId,count:ce})}this.registry.register(S),T=!0;let Y={agentId:e.agentId,framework:e.framework,workspace:m,cozeIdentity:e.cozeIdentity,createdAt:P?.createdAt??Date.now(),sessions:P?.sessions??{},model:j.model};u==="cloud"&&(Y.deployType="cloud"),Q&&(Y.accountId=Q),W&&(Y.patToken=W),P?.skills&&(Y.skills=P.skills),P?.agentName&&(Y.agentName=P.agentName),P?.description&&(Y.description=P.description),e.framework==="openclaw"&&u==="cloud"&&(this.config.frameworksCache?.openclaw?.path?await this.getOpenclawConfig().ensureAgent(e.agentId,m):Ee.warn("openclaw binary not on this machine, skip agents add (will fail at session/prompt)",{agentId:e.agentId}));let ae=e.initialSkills??[];if(ae.length>0){let ce=[...Y.skills??[]],De=new Map(ce.map((ue,fe)=>[ue.skillId,fe])),me=0;for(let ue of ae)try{let fe=await ei({agentId:e.agentId,workspace:m,framework:e.framework,skill:ue});ti(ce,De,fe),me++}catch(fe){Ee.warn("initialSkill install failed (skipping)",{agentId:e.agentId,skillId:ue.skillId,skillName:ue.skillName,err:String(fe)})}me>0&&(Y.skills=ce,Ee.info("initialSkills installed",{agentId:e.agentId,installed:me,requested:ae.length}))}return await Pe(Y,this.paths),Ee.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(C){throw Ee.error("agent create failed, rolling back",{agentId:e.agentId,err:String(C)}),T&&S&&(await S.dispose("rollback").catch(()=>{}),this.registry.unregister(e.agentId)),await fd(d.root,{recursive:!0,force:!0}).catch(P=>Ee.warn("rm agent dir failed (ignored)",{err:String(P)})),C instanceof b?C:new b("AGENT_SPAWN_FAILED",String(C),{cause:C})}finally{clearTimeout(y)}}async spawnSessionDownstream(e,s,o,c){let u=this.config.frameworksCache?.[e.framework];if(!u)if(e.deployType==="cloud"&&lo(e.framework))u=gd;else throw new b("AGENT_SPAWN_FAILED",`framework ${e.framework} not detected on this machine`);let g=e.deployType==="cloud"?{model:e.model,modelToken:s}:void 0,p;e.framework==="openclaw"?p=await this.buildOpenclawDownstream({session:e,modelConfig:g,cloudSessionId:o,cozeEnv:c,command:u.path}):p=this.factory(e.framework,u.path,e.workspace,e.agentId,g,o,c,this.buildBinShimPathEnv());try{return await p.start(),await p.initialize(hd),p}catch(m){throw await p.stop("spawnSessionDownstream failed").catch(()=>{}),m instanceof b?m:new b("AGENT_SPAWN_FAILED",m instanceof Error?m.message:String(m),{cause:m})}}async buildOpenclawDownstream(e){let{session:s,modelConfig:o,cloudSessionId:c,cozeEnv:d,command:u}=e,g=ni(c);if(s.deployType==="local"){let y=this.config.frameworksCache?.openclaw?.defaultAgent;if(!y?.id||!y.workspace)throw new b("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 Rt({command:u,cwd:y.workspace,agentId:y.id,sessionName:g})}let p=await fo(),m=o?Gs(o,d):null,_;if(m){let y=Zr(c),T=m.models[0]?.id??Be,C=`${y}/${T}`;if(!this.ensuredProviders.has(C)){let P=this.getOpenclawConfig();await P.ensureProvider(y,m),await P.addModelToAllowlist(C),this.ensuredProviders.add(C)}_=C}return new Rt({command:u,cwd:s.workspace,agentId:s.agentId,sessionName:g,...p?{gatewayToken:p}:{},..._?{slashModelOnStart:_}:{}})}async openclawRepair(e,s){let o=this.getOpenclawConfig();await o.deleteAgent(e),await o.ensureAgent(e,s)}async cleanupOpenclawSessionProviders(e){if(e.framework!=="openclaw"||!this.openclawConfigCache)return;let s=this.openclawConfigCache;for(let o of e.sessions.keys()){let c=Zr(o),d=`${c}/${e.model}`,u=!0;try{await s.removeProvider(c)}catch(g){u=!1,Ee.warn("removeProvider failed, keeping ensuredProviders entry",{providerId:c,err:String(g)})}try{await s.removeModelFromAllowlist(d)}catch(g){u=!1,Ee.warn("removeModelFromAllowlist failed, keeping ensuredProviders entry",{fullModelId:d,err:String(g)})}u&&this.ensuredProviders.delete(d)}}};import{randomUUID as Cd}from"node:crypto";import{promises as Pd}from"node:fs";import{basename as kd}from"node:path";import{promises as wd}from"node:fs";import{basename as _d}from"node:path";q();var go=L("file-upload"),yd="/api/coze_claw/file/agent_upload",bd=6e4;async function ho(n,e={}){let o=`${Ln(Nn(e.handshakeBase))}${yd}`,c=e.timeoutMs??bd,d=await wd.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 g={Authorization:`Bearer ${n.patToken}`,Accept:"application/json","x-coze-version":"3.0",...kt(e.ppeOverride),...n.accountId?{"x-coze-account":n.accountId}:{}},p=new AbortController,m=setTimeout(()=>p.abort(),c);go.info("file upload start",{url:o,agentId:n.agentId,sessionId:n.sessionId,name:n.name,bytes:n.sizeBytes,mime:n.mimeType});try{let _=await fetch(o,{method:"POST",headers:g,body:u,signal:p.signal}),y=_.headers.get("x-tt-logid")??"";if(!_.ok){let C=await _.text().catch(()=>"");throw new b("UPLOAD_FAILED",`upload HTTP ${_.status} logid=${y}: ${C.slice(0,200)}`)}let S=await _.json();if(S.code!==void 0&&S.code!==0)throw new b("UPLOAD_FAILED",`upload code=${S.code} msg=${S.msg??"-"} logid=${y}`);let T=S.data?.file?.file_url;if(!T)throw new b("UPLOAD_FAILED",`upload response missing data.file.file_url logid=${y}: ${JSON.stringify(S).slice(0,200)}`);return go.info("file upload ok",{uri:T,logid:y}),{uri:T}}catch(_){throw _ instanceof b?_:_.name==="AbortError"?new b("UPLOAD_FAILED",`upload timeout (${c}ms) for ${_d(n.path)}`):new b("UPLOAD_FAILED",String(_),{cause:_})}finally{clearTimeout(m)}}q();import{promises as vd}from"node:fs";import{extname as Sd}from"node:path";var Ed=[{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 Ad(n){return n[0]===82&&n[1]===73&&n[2]===70&&n[3]===70&&n[8]===87&&n[9]===69&&n[10]===66&&n[11]===80}var Id={".txt":"text/plain",".md":"text/markdown",".svg":"image/svg+xml",".json":"application/json"};async function po(n){let e=await vd.open(n,"r");try{let s=Buffer.alloc(16);if(await e.read(s,0,16,0),Ad(s))return"image/webp";for(let o of Ed)if(o.prefix.every((c,d)=>s[d]===c))return o.mime}finally{await e.close()}return Id[Sd(n).toLowerCase()]??"application/octet-stream"}se();var mo=L("agent-send"),wo=50*1024*1024,Td=new Set(["image/png","image/jpeg","image/webp","image/gif","image/svg+xml","application/pdf","application/json","text/plain","text/markdown"]);async function _o(n,e){let s=e.core.get(n.agentId);if(!s)throw new b("AGENT_NOT_FOUND",`agent=${n.agentId}`);if(e.core.disconnectedAgents.has(n.agentId))throw new b("AGENT_DISCONNECTED",`agent=${n.agentId} was disconnected by cloud`);if(s.deployType!=="cloud")throw new b("IPC_BAD_REQUEST",`agent=${n.agentId} is not a cloud agent (deployType=${s.deployType}); send only available for cloud agents`);let o=s.sessions.get(n.sessionId);if(!o)throw new b("AGENT_NOT_FOUND",`session=${n.sessionId} not active in agent=${n.agentId}`);if(!await As(n.path,s.workspace))throw new b("PATH_OUTSIDE_WORKSPACE",`path=${n.path} not under workspace=${s.workspace}`);let c=await Pd.stat(n.path).catch(()=>null);if(!c||!c.isFile())throw new b("IPC_BAD_REQUEST",`path is not a regular file: ${n.path}`);if(c.size>wo)throw new b("FILE_TOO_LARGE",`${c.size} bytes > limit ${wo}`);let d=await po(n.path);if(!Td.has(d))throw new b("UNSUPPORTED_MIME",`mime=${d} not in whitelist`);if(n.kind==="image"&&!d.startsWith("image/"))throw new b("UNSUPPORTED_MIME",`kind=image but mime=${d}`);if(!e.core.upstream.isConnected())throw new b("UPSTREAM_NOT_READY","cloud WS not connected");let u=n.name??kd(n.path),g=await ho({patToken:e.patToken,agentId:n.agentId,sessionId:n.sessionId,path:n.path,mimeType:d,name:u,sizeBytes:c.size,...s.accountId?{accountId:s.accountId}:{}},{handshakeBase:e.handshakeBase,ppeOverride:e.ppeOverride}),p={sessionUpdate:"agent_file",messageId:Cd(),content:{type:n.kind==="image"?"image":"resource",uri:g.uri,mimeType:d,name:u,sizeBytes:c.size,...g.fileId!==void 0?{fileId:g.fileId}:{},...n.caption!==void 0?{caption:n.caption}:{}}},m=2,_;for(let y=0;y<=m;y++)try{await e.core.sendAgentFileUpdate(s,o,n.sessionId,p),_=void 0;break}catch(S){_=S,y<m&&(mo.warn("sendAgentFileUpdate failed, retrying",{attempt:y+1,err:String(S)}),await new Promise(T=>setTimeout(T,5e3)))}if(_)throw new b("UPSTREAM_NOT_READY",`agent file uploaded to cloud but sendAgentFileUpdate failed after ${m+1} attempts: ${String(_)}`,{cause:_});return mo.info("agent file sent",{agentId:n.agentId,sessionId:n.sessionId,kind:n.kind,name:u,bytes:c.size,mime:d,uri:g.uri}),{ok:!0,uri:g.uri,bytes:c.size,mimeType:d,...g.fileId!==void 0?{fileId:g.fileId}:{}}}q();import{execFile as Dd}from"node:child_process";import{promisify as Rd}from"node:util";var Ld=Rd(Dd),at=L("coze-cli-installer"),yo="@coze/cli@0.1.3-alpha.89c42a",bo="https://bnpm.byted.org",Od="coze",Nd=5e3,Bd=9e4,vo=1e4,rn=null,ii=!1;async function si(n,e={}){if(ii)return;if(rn)return rn;let s=e.exec??Ld;return rn=(async()=>{try{let o=await Md(Od,s);if(o){at.info("coze-cli already on PATH, skip install + config + auth",{path:o}),ii=!0;return}at.info("coze-cli install start",{package:yo,registry:bo});try{await s("npm",["i","-g",yo,"--registry",bo],{timeout:Bd,maxBuffer:10*1024*1024}),at.info("coze-cli install ok")}catch(c){at.warn("coze-cli install failed (skip subsequent steps)",{err:String(c)});return}if(n.env)try{await s("coze",["config","set","xTTEnv",n.env],{timeout:vo}),at.info("coze config set xTTEnv ok",{env:n.env})}catch(c){at.warn("coze config set failed (continue to auth login)",{err:String(c)})}try{await s("coze",["auth","login","--token",n.patToken],{timeout:vo}),at.info("coze auth login ok")}catch(c){at.warn("coze auth login failed",{err:String(c)});return}ii=!0}finally{rn=null}})(),rn}async function Md(n,e){let s=process.platform==="win32"?"where":"which";try{let{stdout:o}=await e(s,[n],{timeout:Nd});return o.split(`
|
|
120
|
+
`)[0]?.trim()||void 0}catch{return}}q();import{spawn as zd}from"node:child_process";import{constants as So,access as Fd}from"node:fs/promises";import{delimiter as Ud,join as qd}from"node:path";var Eo=L("framework-detector"),Ao={"claude-code":"claude",codex:"codex",openclaw:"openclaw"},Kd=[".exe",".cmd",".bat",".ps1"],Ot=class{env;constructor(e={}){this.env={pathEnv:e.pathEnv??process.env.PATH??"",platform:e.platform??process.platform,spawn:e.spawn??zd,access:e.access??Fd}}async detect(e){let s=Ao[e],o=await this.which(s);if(!o)return Eo.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)]),g={path:o,version:d};return u&&(g.defaultAgent=u),g}async detectAll(){let e=await Promise.all(Object.keys(Ao).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(Ud).filter(Boolean),o=this.env.platform==="win32"?["",...Kd]:[""];for(let c of s)for(let d of o){let u=qd(c,e+d);if(await this.isExecutable(u))return u}return null}async isExecutable(e){try{let s=this.env.platform==="win32"?So.F_OK:So.X_OK;return await this.env.access(e,s),!0}catch{return!1}}async probeOpenclawDefaultAgent(e){let s=await this.runProbe(e,["--log-level","silent","agents","list","--json"]);if(!s||s.code!==0)return null;try{let o=JSON.parse(s.stdout);if(!Array.isArray(o))return null;let c=o.find(d=>d?.isDefault===!0);return!c?.id||!c.workspace?null:{id:c.id,workspace:c.workspace}}catch(o){return Eo.warn("openclaw agents list --json parse failed",{err:String(o)}),null}}async probeVersion(e,s=[]){let o=await this.runProbe(e,[...s,"--version"]);return o&&(Gd(o.stdout).split(/\r?\n/)[0]??"").trim()||"unknown"}runProbe(e,s){return new Promise(o=>{let c="",d=!1,u,g=p=>{d||(d=!0,u&&clearTimeout(u),o(p))};try{let p=this.env.spawn(e,s,{stdio:["ignore","pipe","pipe"]});u=setTimeout(()=>{p.kill("SIGKILL"),g(null)},5e3),p.stdout?.on("data",m=>{c+=m.toString("utf8")}),p.on("error",()=>g(null)),p.on("close",m=>g({code:m,stdout:c}))}catch{g(null)}})}},Hd=new RegExp("\x1B\\[[0-9;]*[A-Za-z]","g");function Gd(n){return n.replace(Hd,"")}Nt();import{randomBytes as xu}from"node:crypto";import{createReadStream as Wd}from"node:fs";import{mkdir as Jd,readFile as $d,realpath as Vd,stat as Yd,writeFile as Xd}from"node:fs/promises";import{basename as Zd,dirname as oi,join as Qd,relative as eu,resolve as Co,sep as tu}from"node:path";import{createInterface as nu}from"node:readline";q();var ko=L("fs-rpc"),sn=qn("COZE_BRIDGE_FS_RPC_MAX_BYTES",20*1024*1024);async function To(n,e){let s=Buffer.byteLength(n.content,"utf8");if(s>sn)throw new b("IPC_BAD_REQUEST",`fs/write_text_file content too large: ${s} bytes > limit ${sn} bytes`);let o=await Ro(n.path,e);return await Jd(oi(o),{recursive:!0}),await Xd(o,n.content,"utf8"),ko.info("fs/write_text_file ok",{path:o,size:n.content.length}),null}async function Do(n,e){let s=await Ro(n.path,e),o=await Yd(s),c=typeof n.line=="number"||typeof n.limit=="number";if(o.size>sn&&!c)throw new b("IPC_BAD_REQUEST",`fs/read_text_file too large without line/limit slicing: ${o.size} bytes > ${sn} bytes`);let d;if(c&&o.size>sn)d=await ru(s,n.line??1,n.limit);else{let u=await $d(s,"utf8");if(c){let g=u.split(`
|
|
121
|
+
`),p=Math.max(0,(n.line??1)-1),m=typeof n.limit=="number"?p+n.limit:void 0;d=g.slice(p,m).join(`
|
|
122
|
+
`)}else d=u}return ko.info("fs/read_text_file ok",{path:s,size:d.length}),{content:d}}async function ru(n,e,s){let o=nu({input:Wd(n,{encoding:"utf8"}),crlfDelay:Number.POSITIVE_INFINITY}),c=Math.max(0,e-1),d=typeof s=="number"?c+s:Number.POSITIVE_INFINITY,u=[],g=0;try{for await(let p of o)if(g>=c&&g<d&&u.push(p),g++,g>=d)break}finally{o.close()}return u.join(`
|
|
123
|
+
`)}async function Ro(n,e){if(typeof n!="string"||n.length===0)throw new b("IPC_BAD_REQUEST","path must be a non-empty string");let[s,o]=await Promise.all([Po(Co(e)),Po(Co(n))]),c=eu(s,o);if(c.startsWith("..")||c===".."||c.startsWith(`..${tu}`))throw new b("IPC_BAD_REQUEST",`path escapes workspace: ${n}`);return o}async function Po(n){let e=[],s=n;for(;s!==oi(s);)try{let o=await Vd(s);return e.length?Qd(o,...e.reverse()):o}catch{e.push(Zd(s)),s=oi(s)}return n}q();var Lo=L("prompt-multimodal"),Oo=10*1024*1024,iu=15e3,su=6;async function No(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 ou(u))}}let c=Array.from({length:Math.min(su,n.length)},()=>o());return await Promise.all(c),e}async function ou(n){if(n.type!=="image")return n;let e=n;if(e.data||!e.uri||!Rn(e.uri))return n;try{let{buf:s,contentType:o}=await cu(e.uri),c=e.mimeType||au(o)||"application/octet-stream";return Lo.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 Lo.warn("image fetch failed, degrading to text block",{uri:e.uri,err:String(s)}),{type:"text",text:`[image load failed: ${e.uri}]`}}}function au(n){if(!n)return;let e=n.indexOf(";");return(e===-1?n:n.slice(0,e)).trim()||void 0}async function cu(n){let e=new AbortController,s=setTimeout(()=>e.abort(),iu);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>Oo)throw new Error(`image too large: ${c.byteLength} bytes (max ${Oo})`);return{buf:Buffer.from(c),contentType:o.headers.get("content-type")??void 0}}finally{clearTimeout(s)}}rt();Nt();q();var z=L("core"),du=3e4,uu=/^(boe|ppe)_[A-Za-z0-9_-]+$/,fu=3e4,lu=new Set(["_agent/create","session/new","session/load","session/prompt"]),$n=class{upstream;agents=new Map;disconnectedAgents=new Set;extensions;paths;sessionSpawner;sessionIdleTimeoutMs;upgradeGate;upstreamIds=new Dt;pendingUpstream=new Map;pendingBridge=new Map;currentCozeEnv;constructor(e){this.upstream=e.upstream,this.extensions=e.extensions??{},this.paths=e.paths,this.sessionSpawner=e.sessionSpawner,this.sessionIdleTimeoutMs=Io(e.bridgeConfig),this.upgradeGate=e.upgradeGate}registerExtension(e,s){this.extensions[e]=s}getCozeEnv(){return this.currentCozeEnv}async start(){this.upstream.onFrame(e=>this.handleFrame(e)),this.upstream.onConnect?.(({initial:e})=>{e||this.rejectAllPendingOnReconnect()}),await this.upstream.start(),z.info("Core started",{extensions:Object.keys(this.extensions)})}async stop(e){z.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),z.info("agent registered",{agentId:e.agentId,framework:e.framework});for(let s of this.registerHandlers)try{s(e.agentId)}catch(o){z.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)&&z.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)=>{z.info("session runtime exited",{agentId:e.agentId,cloudId:s,code:d,signal:u}),nn(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){z.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(st(c,{code:G.INTERNAL_ERROR,message:`bridge downstream gone: ${s}`})).catch(u=>z.debug("send error response to upstream failed (ignored)",{err:String(u)}));try{d.downstream.respondAgentRequestError(d.agentRequestId,{code:G.INTERNAL_ERROR,message:`bridge: ${s}`})}catch{}}}}}rejectAllPendingOnReconnect(){let e=this.pendingUpstream.size,s=this.pendingBridge.size;if(!(e===0&&s===0)){z.warn("upstream reconnected, rejecting stale pending requests",{pendingUpstream:e,pendingBridge:s});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 b("UPSTREAM_DISCONNECTED",`${o.method} aborted: upstream reconnected`));this.pendingBridge.clear()}}async handleFrame(e){if(Fn(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&&uu.test(o)?this.currentCozeEnv=o:o&&z.warn("rejecting cozeEnv with invalid shape, keeping previous",{rejected:o});try{if(this.upgradeGate?.isUpgrading()&&lu.has(e.method)){let c=this.upgradeGate.pendingTarget()??"";throw new b("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,G.METHOD_NOT_FOUND,`extension not registered: ${e.method}`):z.warn("drop notification: extension not registered",{method:e.method});return}let d=await c(e,this);s!==null&&await this.upstream.send(Tt(s,d));return}if(e.method.startsWith("session/")){let c=await this.routeSessionMethod(e);s!==null&&await this.upstream.send(Tt(s,c));return}if(e.method==="initialize"){s!==null&&await this.upstream.send(Tt(s,{protocolVersion:1,agentCapabilities:{loadSession:!0}}));return}s!==null?await this.sendError(s,G.METHOD_NOT_FOUND,`method not implemented: ${e.method}`):z.warn("drop unknown notification",{method:e.method})}catch(c){z.error("handleFrame failed",{method:e.method,err:String(c)}),s!==null&&await this.upstream.send(st(s,tn(c)))}}async routeSessionMethod(e){if(!e.params||typeof e.params!="object")throw new b("IPC_BAD_REQUEST",`${e.method} requires params`);let s=e.params,o=s._meta?.cozeAgentId;if(!o)throw new b("IPC_BAD_REQUEST",`${e.method}: missing _meta.cozeAgentId`);let c=this.agents.get(o);if(!c)throw this.disconnectedAgents.has(o)?new b("AGENT_DISCONNECTED",`agent ${o} has been disconnected; cloud must _agent/create to revive`):new b("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(),g=!1,p=e.method==="session/prompt";p&&this.upgradeGate?.incActive();try{let m=await c.getSessionQueue(d).enqueue(()=>this.dispatchSessionCall(c,e.method,s));return g=!0,m}finally{p&&this.upgradeGate?.decActive(),z.info("session call done",{agentId:c.agentId,method:e.method,durationMs:Date.now()-u,ok:g})}}async dispatchSessionCall(e,s,o){e.lastActiveAt=Date.now();let{stripped:c}=Ds(o);switch(s){case"session/new":{let d=gu();return z.info("session/new ack (lazy spawn)",{agentId:e.agentId,cloudId:d}),{sessionId:d}}case"session/load":{let d=c;return z.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 b("IPC_BAD_REQUEST","session/prompt: missing sessionId");let g=await this.ensureRuntime(e,u);if(g.replySeq=0,await this.ensureDownstream(e,u,g),!g.downstream||!g.acpSessionId)throw new b("BRIDGE_INTERNAL","session runtime not ready after ensureDownstream");let p=o._meta?.cozeTriggerMsgId;p?e.activeTriggers.set(g.acpSessionId,p):e.activeTriggers.delete(g.acpSessionId);let m=await No(d.prompt);try{let _=await g.downstream.sessionPrompt({...d,sessionId:g.acpSessionId,prompt:m});return g.lastActiveAt=Date.now(),_}finally{if(e.activeTriggers.delete(g.acpSessionId),g.reloadAfterTurn){g.reloadAfterTurn=!1;let _=g.downstream;_&&(g.downstream=void 0,z.info("reloadAfterTurn: stopping downstream",{agentId:e.agentId,cloudId:u,acpId:g.acpSessionId}),_.stop("reload-after-turn").catch(y=>z.warn("reload-after-turn stop failed (ignored)",{agentId:e.agentId,cloudId:u,err:String(y)})))}else g.downstream?.isAlive()&&this.armIdleTimer(e,u,g)}}case"session/cancel":{let u=c.sessionId;if(!u)throw new b("IPC_BAD_REQUEST","session/cancel: missing sessionId");let g=e.sessions.get(u);if(e.hasSessionQueue(u)){let p=e.getSessionQueue(u);p.size>0&&(z.info("session/cancel: draining queued tasks",{agentId:e.agentId,cloudId:u,queuedCount:p.size}),p.dispose(new b("AGENT_PROTOCOL_ERROR",`cancelled by session/cancel on ${u}`)))}return g?.downstream?.isAlive()&&g.acpSessionId&&await g.downstream.sessionCancel({sessionId:g.acpSessionId}),{ok:!0}}default:throw new b("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(Ne.GEN_MODEL_TOKEN,o,fu);if(!c?.modelToken)throw new b("MODEL_TOKEN_GEN_FAILED",`cloud returned empty modelToken (agentId=${e}, cloudSessionId=${s})`);return c.modelToken}catch(c){throw c instanceof b&&c.code==="MODEL_TOKEN_GEN_FAILED"?c:new b("MODEL_TOKEN_GEN_FAILED",c instanceof Error?c.message:String(c),{cause:c})}}async ensureDownstream(e,s,o){if(nn(o),o.downstream?.isAlive())return;if(!this.sessionSpawner)throw new b("AGENT_SPAWN_FAILED","sessionSpawner not wired (cannot spawn per-session downstream)");let c=3,d=3e4,u=o.spawnFailCount??0,g=o.spawnFailedAt??0;if(u>=c&&Date.now()-g<d)throw new b("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()-g))/1e3)}s`);let p;try{p=await this.sessionSpawner(e,o.modelToken,s,this.currentCozeEnv)}catch(m){throw o.spawnFailCount=u+1,o.spawnFailedAt=Date.now(),o.spawnFailCount>=c&&o.acpSessionId&&(z.warn("clearing stale acpSessionId after repeated spawn failures",{agentId:e.agentId,cloudId:s,staleAcpId:o.acpSessionId}),o.acpSessionId=void 0),m}if(o.spawnFailCount=0,o.spawnFailedAt=void 0,o.downstream=p,this.attachRuntimeHooks(e,s,o),o.acpSessionId){o.loadingSession=!0;try{await p.sessionLoad({sessionId:o.acpSessionId,cwd:e.workspace}),z.info("session restored via session/load",{agentId:e.agentId,cloudId:s,acpId:o.acpSessionId})}catch(m){z.warn("session/load failed, fallback to session/new",{agentId:e.agentId,cloudId:s,acpId:o.acpSessionId,err:String(m)}),o.acpSessionId=void 0;let _=await p.sessionNew({cwd:e.workspace});o.acpSessionId=_.sessionId,await this.persistSessionMapping(e)}finally{o.loadingSession=!1}}else{let m=await p.sessionNew({cwd:e.workspace});o.acpSessionId=m.sessionId,await this.persistSessionMapping(e)}p.afterSessionEstablished&&o.acpSessionId&&await p.afterSessionEstablished(o.acpSessionId)}armIdleTimer(e,s,o){if(nn(o),this.isRuntimeBusy(e,o)){z.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)){z.info("idle reaper fired but runtime busy, re-arming",{agentId:e.agentId,cloudId:s}),this.armIdleTimer(e,s,o);return}z.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=>z.warn("idle stop failed (ignored)",{agentId:e.agentId,cloudId:s,err:String(d)}))},this.sessionIdleTimeoutMs),o.idleTimer.unref?.()}isRuntimeBusy(e,s){if(s.acpSessionId&&e.activeTriggers.has(s.acpSessionId))return!0;let o=s.downstream;if(!o)return!1;for(let c of this.pendingUpstream.values())if(c.downstream===o)return!0;return!1}async sendAgentFileUpdate(e,s,o,c){let d={cozeAgentId:e.agentId,cozeReplySeqID:++s.replySeq};if(s.acpSessionId){let u=e.activeTriggers.get(s.acpSessionId);u&&(d.cozeTriggerMsgId=u)}await this.upstream.send(Qt("session/update",{sessionId:o,update:c,_meta:d}))}forwardUpdate(e,s){let o=s.sessionId,c=this.reverseSessionId(e,o);if(!c){z.debug("drop update for unknown session",{agentId:e.agentId,acpId:o});return}let d=e.sessions.get(c);if(!d){z.debug("drop update: runtime gone",{agentId:e.agentId,cloudId:c});return}if(pu(s)){z.debug("drop codex metadata-warn chunk",{agentId:e.agentId,acpId:o});return}let u={cozeAgentId:e.agentId,cozeReplySeqID:++d.replySeq},g=e.activeTriggers.get(o);g&&(u.cozeTriggerMsgId=g),this.upstream.send(Qt("session/update",{...s,sessionId:c,_meta:u})).catch(p=>z.warn("forward update failed",{agentId:e.agentId,err:String(p)}))}handleAgentRequest(e,s,o){if(o.method==="session/request_permission"){this.forwardPermissionRequest(e,s,o);return}if(o.method==="fs/write_text_file"||o.method==="fs/read_text_file"){this.handleFsRpcRequest(e,s,o);return}z.warn("unhandled agent request,returning method_not_found",{agentId:e.agentId,method:o.method}),s.respondAgentRequestError(o.id,{code:G.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 To(d,c);s.respondAgentRequest(o.id,u)}else{let d=o.params??{},u=await Do(d,c);s.respondAgentRequest(o.id,u)}}catch(c){z.warn("fs rpc handler failed",{agentId:e.agentId,method:o.method,err:String(c)}),s.respondAgentRequestError(o.id,tn(c))}}forwardPermissionRequest(e,s,o){let c=this.upstreamIds.next("session/request_permission"),d=o.params??{},g=d.sessionId,p=g?e.activeTriggers.get(g):void 0,m={cozeAgentId:e.agentId};p&&(m.cozeTriggerMsgId=p);let _=g?this.reverseSessionId(e,g):void 0,y={...d,..._?{sessionId:_}:{},_meta:m};this.pendingUpstream.set(c,{agentRequestId:o.id,agentId:e.agentId,downstream:s,method:o.method}),z.info("forward permission_request \u2192 upstream",{agentId:e.agentId,upstreamId:c,acpSessionId:g,cloudSessionId:_,toolCallId:d.toolCall?.toolCallId,options:d.options?.map(S=>({optionId:S.optionId,kind:S.kind,name:S.name}))}),this.upstream.send(Zt(c,"session/request_permission",y)).catch(S=>{this.pendingUpstream.delete(c),z.error("forward permission request failed",{agentId:e.agentId,err:String(S)}),s.respondAgentRequestError(o.id,{code:G.INTERNAL_ERROR,message:`upstream send failed: ${String(S)}`})})}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?(z.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"&&hu(e.result,c),z.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 zn(e.error)):o.value.resolve(e.result);return}z.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 z.warn(`${o} id type mismatch: number received but Bridge expected string`,{rawId:s,normalizedId:d}),{value:u,key:d}}}sendRequest(e,s,o=du){let c=this.upstreamIds.next(e);return new Promise((d,u)=>{let g=setTimeout(()=>{this.pendingBridge.delete(c),u(new b("AGENT_TIMEOUT",`${e} timed out after ${o}ms`))},o);this.pendingBridge.set(c,{method:e,resolve:d,reject:u,timer:g}),this.upstream.send(Zt(c,e,s)).catch(p=>{let m=this.pendingBridge.get(c);m&&(clearTimeout(m.timer),this.pendingBridge.delete(c)),u(p)})})}async persistSessionMapping(e){if(this.paths)try{let s=new Map;for(let[o,c]of e.sessions){let d={modelToken:c.modelToken,tokenGeneratedAt:c.tokenGeneratedAt};c.acpSessionId&&(d.acpSessionId=c.acpSessionId),s.set(o,d)}await Jr(e.agentId,s,this.paths)}catch(s){z.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(st(e,{code:s,message:o,data:{bridgeVersion:it}}))}};function gu(){return xu(16).toString("hex")}function hu(n,e){if(!n||typeof n!="object"){z.warn("permission response: result not an object (suspicious)",{agentId:e.agentId,result:n});return}let s=n;if("kind"in s&&!("outcome"in s)){z.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"){z.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")&&z.warn("permission response: unknown outcome discriminant",{agentId:e.agentId,outcomeValue:d,result:n})}function pu(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();se();import{randomBytes as mu}from"node:crypto";import{chmod as wu,mkdir as _u,writeFile as Bo}from"node:fs/promises";import{createServer as yu}from"node:http";import{dirname as bu}from"node:path";var vu=1e6,ai=L("ipc"),Vn=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??K()}async start(){this.token=mu(32).toString("hex");let e=yu((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(),ai.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 _u(bu(this.paths.portFile),{recursive:!0}),await Bo(this.paths.portFile,String(this.port),"utf8"),await Bo(this.paths.tokenFile,this.token,{encoding:"utf8",mode:384});try{await wu(this.paths.tokenFile,384)}catch(e){ai.warn("chmod token file failed (non-POSIX?)",{err:String(e)})}}async dispatch(e,s){if(e.headers.authorization!==`Bearer ${this.token}`){on(s,401,{error:"unauthorized"});return}let c=`${e.method} ${(e.url??"").split("?")[0]}`,d=this.routes.get(c);if(!d){on(s,404,{error:"not found"});return}let u=null;if(e.method==="POST")try{u=await Su(e)}catch(g){on(s,400,{error:"invalid json",detail:String(g)});return}try{let g=await d.handler(u,e);on(s,200,g??{ok:!0})}catch(g){ai.error("IPC handler failed",{key:c,err:String(g)}),on(s,500,{error:g instanceof Error?g.message:String(g)})}}};function on(n,e,s){n.statusCode=e,n.setHeader("content-type","application/json"),n.end(JSON.stringify(s))}async function Su(n){let e=[],s=0;for await(let c of n){let d=c;if(s+=d.length,s>vu)throw new Error("body too large");e.push(d)}let o=Buffer.concat(e).toString("utf8");return o?JSON.parse(o):null}import{sep as Mo}from"node:path";import{fileURLToPath as Eu}from"node:url";function zo(){return Au(Eu(import.meta.url))}function Au(n){let e=`${Mo}src${Mo}`;return n.includes(e)}q();se();import{spawn as Iu}from"node:child_process";import{existsSync as Cu,mkdirSync as Pu,openSync as ku}from"node:fs";import{dirname as Tu}from"node:path";import{fileURLToPath as Du}from"node:url";var Ru=L("spawn-helper");function Lu(n){return Cu(n.libEntry)?n.libEntry:Du(new URL("../index.ts",import.meta.url))}function Ou(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 Fo(n,e,s={}){let o=s.paths??K(),c=Lu(o);Pu(Tu(o.logFile),{recursive:!0});let d=ku(o.logFile,"a"),u=Ou(c,n,e),g=Iu(process.execPath,u,{detached:!0,stdio:["ignore",d,d],env:{...process.env,COZE_BRIDGE_UPGRADE_HELPER:"1"}});if(g.unref(),typeof g.pid!="number")throw new Error("failed to spawn upgrade helper (no pid)");Ru.info("upgrade helper spawned",{pid:g.pid,targetVersion:n,oldPid:e,entry:c})}q();import{mkdir as Nu,writeFile as Bu}from"node:fs/promises";import{dirname as Mu}from"node:path";import{gunzipSync as zu}from"node:zlib";var ci=L("tarball-downloader"),Fu="https://registry.npmjs.org",Uo="package/dist/index.js";async function qo(n,e,s={}){if(!/^[\w.\-+]+$/.test(n))throw new Error(`invalid version string: ${JSON.stringify(n)}`);let c=`${(s.registry??Fu).replace(/\/+$/,"")}/coze-bridge/${n}`;ci.info("fetching tarball metadata",{metaUrl:c});let d=await fetch(c);if(!d.ok)throw new Error(`registry metadata ${c} returned ${d.status}`);let g=(await d.json())?.dist?.tarball;if(!g)throw new Error(`registry metadata missing dist.tarball for ${n}`);ci.info("downloading tarball",{tarballUrl:g});let p=await fetch(g);if(!p.ok)throw new Error(`tarball ${g} returned ${p.status}`);let m=Buffer.from(await p.arrayBuffer()),_=zu(m),y=Uu(_,Uo);if(!y)throw new Error(`tarball missing entry ${Uo}`);await Nu(Mu(e),{recursive:!0}),await Bu(e,y),ci.info("dist extracted",{destPath:e,bytes:y.length})}function Uu(n,e){let s=0;for(;s+512<=n.length;){let o=n.subarray(s,s+512);if(o.every(_=>_===0))return null;let c=o.subarray(0,100),d=c.indexOf(0),u=c.subarray(0,d===-1?100:d).toString("utf8"),g=o.subarray(124,136).toString("ascii").trim().replace(/\0/g,""),p=Number.parseInt(g,8)||0,m=s+512;if(u===e)return n.subarray(m,m+p);s=m+Math.ceil(p/512)*512}return null}Nt();q();import{resolve as qu}from"node:path";function Ko(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,g=o[d]??0;if(u<g)return!0;if(u>g)return!1}return!1}var lt=L("upgrade-manager"),Ku=300*1e3,Hu=3,Yn=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(!Ko(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)>=Hu){lt.warn("upgrade attempts cap reached, skip",{targetVersion:e,count:o?.count});return}let c=qu(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(Ku);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 Fe(e,this.opts.paths.configFile)}};var dc=je(Qo(),1);var El=je($a(),1),Al=je(fr(),1),Il=je(zt(),1),Cl=je(bi(),1),Pl=je(Ei(),1),kl=je(Ti(),1),rc=je(pr(),1),Tl=je(nc(),1);var ic=rc.default;q();var he=L("upstream.frontier"),oc="application/json",ac="none",hn=class{constructor(e){this.opts=e}opts;fws=null;handler=null;connectHandlers=[];opened=!1;openCount=0;async start(){if(this.fws){he.warn("start called on already-started FrontierUpstream; noop");return}let e={Authorization:`Bearer ${this.opts.privatecode}`,Origin:Os,...kt(this.opts.ppeOverride)};class s extends ic{constructor(g){super(g,Ls,{headers:e})}send(g,...p){if(ps("debug"))try{let m;typeof g=="string"?m=Buffer.from(g,"utf8"):g instanceof Buffer?m=g:g instanceof ArrayBuffer?m=new Uint8Array(g):ArrayBuffer.isView(g)?m=new Uint8Array(g.buffer,g.byteOffset,g.byteLength):m=new Uint8Array(0);let _=Buffer.from(m.slice(0,128)).toString("hex");he.debug("WS raw frame out",{bytes:m.byteLength,headHex:_})}catch(m){he.warn("WS raw frame dump failed",{err:String(m)})}super.send(g,...p)}}let o=Bs(this.opts.urlOverride),c={url:o,ws:s,fpID:Rs,aID:On,accessKey:this.opts.handshake.accessKey,deviceID:this.opts.handshake.deviceId,payloadType:{type:oc,force:!0},payloadEncoding:{encoding:ac,force:!0},enableTransformTextPayload:!0,enableQoS:!1,enableAutoAck:!1,automaticOpen:!1,maxRetries:Number.POSITIVE_INFINITY,debug:this.opts.debug??!1},d=new dc.FWS(c);d.onopen=()=>{this.opened=!0,this.openCount+=1;let u=this.openCount===1;he.info("frontier opened",{url:o,remoteDeviceId:this.opts.handshake.deviceId,initial:u,openCount:this.openCount});for(let g of this.connectHandlers)Promise.resolve(g({initial:u})).catch(p=>he.warn("onConnect handler threw (ignored)",{err:String(p)}))},d.onclose=u=>{this.opened=!1,he.info("frontier closed",{code:u.code,reason:u.reason,willReconnect:u.willReconnect})},d.onerror=u=>{he.warn("frontier error",{code:u.code,msg:u.message})},d.onmessage=u=>this.handleMessage(u),this.fws=d,await d.connect()}async stop(e){let s=this.fws;if(s){this.fws=null,this.opened=!1;try{s.close(1e3,e??"bridge shutdown")}catch(o){he.warn("frontier close threw (ignored)",{err:String(o)})}}}async send(e){let s=this.fws;if(!s)throw new b("UPSTREAM_DISCONNECTED","frontier upstream not started");if(!this.isConnected())throw new b("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;cc(c)||he.info("frontier frame out",{method:c.method,jsonrpcId:c.id,size:o.length});try{await s.send(o,{service:33555712,method:1,payloadType:oc,payloadEncoding:ac})}catch(u){throw he.warn("frontier frame send failed",{method:c.method,jsonrpcId:c.id,err:String(u)}),new b("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){he.debug("drop non-adapter frontier frame",{service:s});return}let o=Ol(e);if(!o){he.debug("frontier message without text payload, drop",{payloadType:e.message?.payloadType});return}if(!this.handler){he.debug("frame received but no onFrame handler",{size:o.length});return}let c;try{c=JSON.parse(o)}catch(u){he.warn("frontier message JSON parse failed",{err:String(u),head:o.slice(0,80)});return}let d=c;cc(d)||he.info("frontier frame in",{logid:Ll(e.message?.LogID),logidNew:e.message?.LogIDNew,msgId:e.message?.msgID,jsonrpcId:d.id,method:d.method,body:Rl(o)}),Promise.resolve(this.handler(c)).catch(u=>he.warn("frontier frame handler threw",{err:String(u)}))}};function cc(n){return n.method==="_agent/health"?!0:typeof n.id=="string"&&n.id.startsWith("agent.health_")}var xc=2e3;function Rl(n){return n.length<=xc?n:`${n.slice(0,xc)}...<truncated, total ${n.length} chars>`}function Ll(n){return n?n.high===0?String(n.low>>>0):`${n.high.toString(16)}${(n.low>>>0).toString(16).padStart(8,"0")}`:""}function Ol(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 Ri=L("upstream.switchable"),wr=class{inner;handler=null;connectHandlers=[];constructor(e){this.inner=e}async swap(e,s){if(this.inner===e)return;Ri.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 Ri.error("swap target start failed, reverting",{err:String(c)}),this.inner=o,c}await o.stop(s??"swapped").catch(c=>Ri.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=L("upstream"),Gt=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();se();import{promises as Oi}from"node:fs";import{dirname as Nl}from"node:path";var Bl=L("pat-token-store");async function uc(n=K()){try{let s=(await Oi.readFile(n.patTokenFile,"utf8")).trim();return s.length>0?s:null}catch(e){return e?.code!=="ENOENT"&&Bl.warn("read pat-token failed (treating as missing)",{err:String(e)}),null}}async function pn(n,e=K()){if(!n)throw new Error("writePatToken: empty patToken");await Oi.mkdir(Nl(e.patTokenFile),{recursive:!0}),await Oi.writeFile(e.patTokenFile,n,{encoding:"utf8",mode:384})}se();se();import{promises as _r}from"node:fs";import{join as Ml}from"node:path";function zl(n){return`#!/bin/sh
|
|
124
124
|
exec node ${JSON.stringify(n)} "$@"
|
|
125
|
-
`}function
|
|
125
|
+
`}function Fl(n){return`@echo off
|
|
126
126
|
node ${JSON.stringify(n)} %*
|
|
127
|
-
`}async function uc(n,e=q()){let s=e.binDir;await wr.mkdir(s,{recursive:!0});let o=Ml(s,process.platform==="win32"?"coze-bridge.cmd":"coze-bridge"),c=process.platform==="win32"?zl(n):Bl(n);return await wr.readFile(o,"utf8").catch(()=>null)===c||(await wr.writeFile(o,c,"utf8"),process.platform!=="win32"&&await wr.chmod(o,493)),s}U();ie();import{execSync as lc}from"node:child_process";import{readFileSync as gc,unlinkSync as Fl}from"node:fs";import{mkdir as Ul,readFile as hc,unlink as pc,writeFile as ql}from"node:fs/promises";import{dirname as Hl}from"node:path";function fc(n){try{return process.kill(n,0),!0}catch(e){return e.code==="EPERM"}}var jl=D("single-instance"),_r=class{pidFile;acquired=!1;constructor(e={}){this.pidFile=e.pidFile??q().pidFile,e.processTitle&&(process.title=e.processTitle)}async acquire(){let e=await this.readExistingPid();return e!==null&&this.isAlive(e)?{kind:"already-running",pid:e}:(e!==null&&(jl.warn("removing stale pid file",{stalePid:e}),await pc(this.pidFile).catch(()=>{})),await Ul(Hl(this.pidFile),{recursive:!0}),await ql(this.pidFile,String(process.pid),"utf8"),this.acquired=!0,this.installCleanupHooks(),{kind:"acquired"})}async release(){if(this.acquired){try{(await hc(this.pidFile,"utf8")).trim()===String(process.pid)&&await pc(this.pidFile)}catch{}this.acquired=!1}}async readExistingPid(){try{let e=await hc(this.pidFile,"utf8"),s=Number.parseInt(e.trim(),10);return Number.isFinite(s)&&s>0?s:null}catch(e){if(e.code==="ENOENT")return null;throw e}}isAlive(e){return fc(e)?this.matchesDaemonTitle(e):!1}matchesDaemonTitle(e){if(process.platform==="win32")return this.matchesDaemonTitleWindows(e);try{let s=gc(`/proc/${e}/cmdline`,"utf8").replace(/\0/g," ");return!!(s.includes("coze-bridge-daemon")||s.includes("lib/index.js"))}catch{}try{let s=lc(`ps -o command= -p ${e}`,{stdio:["ignore","pipe","ignore"],timeout:1e3}).toString();return s.trim()?s.includes("coze-bridge-daemon")||s.includes("lib/index.js"):!1}catch{return!0}}matchesDaemonTitleWindows(e){try{let o=lc(`tasklist /FI "PID eq ${e}" /FO CSV /NH`,{stdio:["ignore","pipe","ignore"],timeout:2e3}).toString().trim();if(!o||o.startsWith("INFO:"))return!1;let c=o.split(",",1)[0]?.replace(/^"|"$/g,"").toLowerCase()??"";return c.includes("node")||c.includes("coze-bridge")}catch{return!0}}installCleanupHooks(){process.once("exit",()=>{if(this.acquired)try{gc(this.pidFile,"utf8").trim()===String(process.pid)&&Fl(this.pidFile)}catch{}})}};function Kl(){let n=0,e=null;return{incActive(){n++},decActive(){n>0&&n--},activeCount(){return n},markUpgradePending(s){e=s},isUpgrading(){return e!==null},pendingTarget(){return e},async waitIdle(s){let o=Date.now()+s;for(;Date.now()<o;){if(n===0)return"idle";await new Promise(c=>setTimeout(c,200))}return n===0?"idle":"timeout"}}}var M=D("daemon"),Gl="coze-bridge-daemon";async function wc(){let n=new _r({processTitle:Gl}),e=await n.acquire();if(e.kind==="already-running")throw new Error(`coze-bridge daemon already running (pid=${e.pid})`);let s=await at(),o=s??{};yn({pid:process.pid}),M.info(s?"loaded bridge config":"initialized bridge config");try{let A=new Rt;o.frameworksCache=await A.detectAll(),M.info("refreshed frameworks_cache",{detected:Object.keys(o.frameworksCache)})}catch(A){M.warn("framework detection failed",{err:String(A)})}await ze(o);let c=new mr(new Ht),d=q(),u=Kl(),l=null,p=new Jn({upstream:c,paths:d,bridgeConfig:o,upgradeGate:u,sessionSpawner:async(A,N,z,ye)=>{if(!l)throw new Error("agentManager not ready");return l.spawnSessionDownstream(A,N,z,ye)}});await Jl(d,p);let m=new Wn({paths:d,config:o,registry:p});l=m;let _,y,I=null,L={},T,P=null,j=null;p.registerExtension("_agent/create",async A=>m.createAgent(A.params)),p.registerExtension("_agent/health",async()=>({ok:!0}));let Q={},K=new Nn({agents:p.agents,disposeAndMarkDisconnected:async(A,N)=>{let z=p.agents.get(A);if(z){await m.cleanupOpenclawSessionProviders(z).catch(Z=>M.warn("cleanup openclaw providers failed (ignored)",{agentId:A,err:String(Z)}));let ye=!0;try{await z.dispose(`disconnect: ${N}`)}catch(Z){ye=!1,M.error("dispose during disconnect FAILED, leaving agent in error state",{agentId:A,err:String(Z)}),z.status="error"}ye&&(z.status="disconnected",p.unregister(A),p.disconnectedAgents.add(A))}else p.disconnectedAgents.add(A)},detailSyncer:async A=>{if(!Q.ref)throw new Error("agent-detail-sync not initialized yet");await Q.ref.syncOne(A)},cleanupOpenclawProviders:async A=>{await m.cleanupOpenclawSessionProviders(A)},openclawRepair:async(A,N)=>{await m.openclawRepair(A,N)},isRuntimePendingPermission:A=>p.hasPendingPermissionFor(A)});p.registerExtension("_agent/listSkills",A=>K.listSkills(A.params)),p.registerExtension("_agent/addSkills",A=>K.addSkills(A.params)),p.registerExtension("_agent/removeSkills",A=>K.removeSkills(A.params)),p.registerExtension("_agent/getFileTree",A=>K.getFileTree(A.params)),p.registerExtension("_agent/getFileContent",A=>K.getFileContent(A.params)),p.registerExtension("_agent/update",A=>K.updateAgent(A.params)),p.registerExtension("_agent/disconnect",A=>K.disconnectAgent(A.params)),p.registerExtension("_agent/switchModel",A=>K.switchModel(A.params)),p.registerExtension("_agent/reset",A=>K.resetAgent(A.params)),p.registerExtension("_agent/repair",A=>K.repairAgent(A.params));let $=new Tn({paths:d,handlers:K,sendDetail:A=>p.sendRequest("_agent/detail",A)});Q.ref=$;let se=async A=>{await Promise.allSettled(A.map(async N=>{try{await K.disconnectAgent({agentId:N.agentId,reason:`auth_failure: code=${N.code} ${N.message}`}),M.info("agent disconnected due to auth failure from heartbeat response",{agentId:N.agentId,code:N.code,message:N.message})}catch(z){M.warn("disconnect during authFailure handling failed (ignored)",{agentId:N.agentId,err:String(z)})}}))};c.onConnect(({initial:A})=>{M.info("frontier upstream connected, triggering detail sync",{initial:A}),$.syncAll(A?"initial-connect":"reconnect").catch(N=>M.warn("detail sync top-level error (ignored)",{err:String(N)}))});let oe=new $n({paths:d,routes:[{method:"GET",path:"/status",handler:async()=>({running:!0,pid:process.pid,agents:[...p.agents.keys()],deviceId:I??"",frameworksCache:o.frameworksCache??{}})},{method:"POST",path:"/pair",handler:async A=>{let N=A,z=N?.privatecode,ye=N?.pairing_code;if(!z||!ye)throw new S("IPC_BAD_REQUEST","/pair requires privatecode + pairing_code");let Z=$t(N.env),le=N.handshake_url,je=N.frontier_url,ne=mc(N.env,le,je),Xe=!!_&&_!==z,X=y!==void 0&&y!==ne,V=Xe||X,dt=await $r({privatecode:z,...le?{endpoint:le}:{},ppeOverride:Z});if(V){M.warn("pair config switched, resetting agents",{pcChanged:Xe,envChanged:X,previousPc:_?yr(_):"",nextPc:yr(z),previousEnvKey:y??"",nextEnvKey:ne});for(let re of[...p.agents.values()])await re.dispose("pair config switch").catch(()=>{}),p.agents.delete(re.agentId);p.disconnectedAgents.size>0&&(M.info("clearing disconnectedAgents set on pair config switch",{count:p.disconnectedAgents.size}),p.disconnectedAgents.clear()),await c.swap(new Ht,"pair switch").catch(()=>{})}I=dt.deviceId,yn({deviceId:I,pid:process.pid}),ii({patToken:z,env:N.env}).catch(re=>M.warn("coze-cli setup error (ignored)",{err:String(re)}));let W=new gn({handshake:dt,privatecode:z,...je?{urlOverride:je}:{},ppeOverride:Z,getPatTokenForAgent:re=>p.agents.get(re)?.patToken});await c.swap(W,"pair");try{let re=new Rt;o.frameworksCache=await re.detectAll(),await ze(o),M.info("frameworks_cache refreshed before pair",{detected:Object.keys(o.frameworksCache)})}catch(re){M.warn("frameworks_cache refresh failed (ignored, using cached)",{err:String(re)})}let wt=Object.keys(o.frameworksCache??{});try{let re=await p.sendRequest("_agent/pair",{pairCode:ye,patToken:z,frameworks:wt,_meta:{cozeDeviceId:I}});M.info("_agent/pair ok",{pairResult:re}),_=z,y=ne,L=Z,T=le,hn(z,d).catch(we=>M.warn("writePatToken after /pair failed (ignored)",{err:String(we)})),P||(P=new Yt({core:p,getDeviceId:()=>I??"",onTickEnd:()=>$.retryPending().catch(we=>M.warn("detailSync.retryPending failed (ignored)",{err:String(we)})),onAuthFailures:se,onMinBridgeVersion:we=>j?.requestUpgrade(we)})),P.start(),V&&br(d,m).catch(we=>M.warn("post-pair-switch auto-revive error (ignored)",{err:String(we)}));let _t;return N.agent_id&&(_t=await $l(N.agent_id,d,m,we=>p.sendRequest("_agent/detail",we),z).catch(we=>(M.error("--agent-id ensureAgent failed",{agentId:N.agent_id,err:String(we)}),{ok:!1,agentId:N.agent_id??"",note:String(we)}))),{ok:!0,note:"paired with cloud",..._t?{agent:_t}:{}}}catch(re){return M.error("_agent/pair failed",{err:String(re)}),{ok:!1,note:`pair failed: ${String(re)}`}}}},{method:"POST",path:"/connect",handler:async A=>{let N=A,z=N?.privatecode;if(!z)throw new S("IPC_BAD_REQUEST","/connect requires privatecode");let ye=$t(N.env),Z=N.handshake_url,le=N.frontier_url,je=mc(N.env,Z,le);if(_===z&&y===je){let W=await Wl(d);return p.agents.size===0&&W?(M.warn("/connect noop but core.agents empty with configs on disk; re-running auto-revive"),br(d,m).catch(wt=>M.warn("connect-noop auto-revive error (ignored)",{err:String(wt)}))):M.info("/connect: already connected with same PAT + env, noop"),{ok:!0,note:"already connected"}}let ne=!!_&&_!==z,Xe=y!==void 0&&y!==je,X=ne||Xe,V=await $r({privatecode:z,...Z?{endpoint:Z}:{},ppeOverride:ye});if(X){M.warn("connect config switched, resetting agents",{pcChanged:ne,envChanged:Xe,previousPc:_?yr(_):"",nextPc:yr(z)});for(let W of[...p.agents.values()])await W.dispose("connect config switch").catch(()=>{}),p.agents.delete(W.agentId);p.disconnectedAgents.size>0&&(M.info("clearing disconnectedAgents set on connect config switch",{count:p.disconnectedAgents.size}),p.disconnectedAgents.clear()),await c.swap(new Ht,"connect switch").catch(()=>{})}I=V.deviceId,yn({deviceId:I,pid:process.pid}),ii({patToken:z,env:N.env}).catch(W=>M.warn("coze-cli setup error (ignored)",{err:String(W)}));let dt=new gn({handshake:V,privatecode:z,...le?{urlOverride:le}:{},ppeOverride:ye,getPatTokenForAgent:W=>p.agents.get(W)?.patToken});return await c.swap(dt,"connect"),_=z,y=je,L=ye,T=Z,P||(P=new Yt({core:p,getDeviceId:()=>I??"",onTickEnd:()=>$.retryPending().catch(W=>M.warn("detailSync.retryPending failed (ignored)",{err:String(W)})),onAuthFailures:se,onMinBridgeVersion:W=>j?.requestUpgrade(W)})),P.start(),X&&br(d,m).catch(W=>M.warn("post-connect-switch auto-revive error (ignored)",{err:String(W)})),hn(z,d).catch(W=>M.warn("writePatToken after /connect failed (ignored)",{err:String(W)})),M.info("/connect: WS established",{deviceId:I}),{ok:!0,note:"connected"}}},{method:"POST",path:"/_agent/create",handler:async A=>{let N=A;return{ok:!0,result:await m.createAgent(N)}}},{method:"POST",path:"/agent/send",handler:async A=>{let N=A;if(!N?.agentId||!N?.sessionId||!N?.kind||!N?.path)throw new S("IPC_BAD_REQUEST","/agent/send requires agentId, sessionId, kind, path");if(!_)throw new S("UPSTREAM_NOT_READY","daemon not yet paired with cloud (run --pair-code first)");try{return await wo(N,{core:p,patToken:_,handshakeBase:T,ppeOverride:L})}catch(z){if(z instanceof S)return{ok:!1,code:z.code,message:z.message};throw z}}},{method:"POST",path:"/refresh",handler:async()=>{M.info("IPC /refresh: re-detecting frameworks");let A=new Rt;return o.frameworksCache=await A.detectAll(),await ze(o),{ok:!0,frameworks:o.frameworksCache}}},{method:"POST",path:"/shutdown",handler:async()=>(M.info("IPC /shutdown received"),setImmediate(()=>{de.shutdown("ipc /shutdown")}),{ok:!0})}]}),{port:Te,token:pe}=await oe.start();try{await uc(d.libEntry,d)}catch(A){M.warn("bin shim install failed (D72 send \u547D\u4EE4\u53EF\u80FD\u4E0D\u53EF\u7528)",{err:String(A)})}await p.start(),br(d,m).catch(A=>M.warn("auto-revive top-level error (ignored)",{err:String(A)})),_s().catch(A=>M.warn("acp wrapper warmup top-level error (ignored)",{err:String(A)}));let xe=null,de={port:Te,token:pe,core:p,ipc:oe,shutdown(A){return xe||(M.info("daemon shutdown",{reason:A}),xe=(async()=>{P?.stop(),await p.stop(A),await oe.stop(),await n.release()})(),xe)}};j=new Vn({paths:d,currentVersion:rt,isDevMode:Bo,download:(A,N)=>Uo(A,N),spawnHelper:(A,N)=>zo(A,N,{paths:d}),daemon:{markUpgradePending:A=>{M.warn("upgrade pending, ACP gate engaged",{target:A}),u.markUpgradePending(A)},waitIdle:A=>u.waitIdle(A),exit:A=>{de.shutdown("upgrade").then(()=>process.exit(A))}}});for(let A of["SIGTERM","SIGINT"])process.on(A,()=>{de.shutdown(A).then(()=>process.exit(0))});return M.info("daemon ready",{port:Te,pid:process.pid,nodeVersion:process.version,platform:process.platform,frameworks:Object.keys(o.frameworksCache??{}),libVersion:o.libVersion??"dev"}),de}async function Wl(n){let{readdir:e}=await import("node:fs/promises");try{return(await e(n.agentsRoot)).length>0}catch{return!1}}function yr(n){return n.length<=8?"***":`${n.slice(0,4)}***${n.slice(-4)}`}function mc(n,e,s){return`${n??""}|${e??""}|${s??""}`}async function Jl(n,e){let{readdir:s}=await import("node:fs/promises"),o;try{o=await s(n.agentsRoot)}catch{return}let{loadAgentConfig:c,enforceAgentConfigMode:d}=await Promise.resolve().then(()=>(nt(),kn));for(let u of o){await d(u,n).catch(l=>M.warn("enforceAgentConfigMode failed (ignored)",{agentId:u,err:String(l)}));try{let l=await c(u,n);l?.disconnectedAt&&(e.disconnectedAgents.add(u),M.info("agent marked disconnected on startup",{agentId:u,disconnectedAt:l.disconnectedAt,reason:l.disconnectReason??""}))}catch(l){M.warn("failed to load agent config on startup, skipping",{agentId:u,err:String(l)})}}}async function $l(n,e,s,o,c){let{loadAgentConfig:d}=await Promise.resolve().then(()=>(nt(),kn)),u=await d(n,e);if(u){M.info("--agent-id: local config found, reconnecting",{agentId:n,framework:u.framework,hadDisconnect:!!u.disconnectedAt});let _={agentId:u.agentId,framework:u.framework,...u.cozeIdentity?{cozeIdentity:u.cozeIdentity}:{},...u.model?{model:u.model}:{},...c?{patToken:c}:{}};return await s.createAgent(_),{ok:!0,agentId:n,note:u.disconnectedAt?"revived from local config":"connected from local config"}}M.info("--agent-id: local config missing, pulling _agent/detail from cloud",{agentId:n});let l=await o({_meta:{cozeAgentId:n}});if(!l.framework)throw new S("AGENT_NOT_FOUND",`agent ${n} \u4E0D\u5728\u672C\u5730; \u4E91\u7AEF _agent/detail \u54CD\u5E94\u7F3A framework \u5B57\u6BB5 (D36 \u534F\u8BAE\u6269\u5C55\u672A\u751F\u6548), \u65E0\u6CD5\u5728\u672C\u673A\u65B0\u5EFA`);let p={agentId:l.agentId,framework:l.framework,...l.cozeIdentity?{cozeIdentity:l.cozeIdentity}:{},...l.model?{model:l.model}:{},...c?{patToken:c}:{},...l.deployType?{_meta:{cozeDeployType:l.deployType}}:{}};await s.createAgent(p);let m=l.deployType==="cloud"&&l.framework==="openclaw";return{ok:!0,agentId:n,note:m?"cloud agent acknowledged":"created from cloud detail"}}async function br(n,e){let{readdir:s}=await import("node:fs/promises"),o;try{o=await s(n.agentsRoot)}catch{return{revived:0,skipped:0,total:0}}if(o.length===0)return{revived:0,skipped:0,total:0};let{loadAgentConfig:c}=await Promise.resolve().then(()=>(nt(),kn));M.info("auto-revive: scanning local agents on startup",{count:o.length});let d=0,u=0;for(let l of o){let p;try{p=await c(l,n)}catch(m){M.warn("auto-revive: load config failed (skipping)",{agentId:l,err:String(m)}),u+=1;continue}if(!p){u+=1;continue}if(p.disconnectedAt){M.info("auto-revive: skip disconnected agent",{agentId:l,disconnectedAt:p.disconnectedAt}),u+=1;continue}try{M.info("auto-revive: re-registering agent (D44 no spawn)",{agentId:l,framework:p.framework});let m=Vl(p);await e.createAgent({agentId:p.agentId,framework:p.framework,...p.cozeIdentity?{cozeIdentity:p.cozeIdentity}:{},...p.model?{model:p.model}:{},...m?{_meta:m}:{}}),d+=1}catch(m){M.warn("auto-revive: createAgent failed (skipping)",{agentId:l,framework:p.framework,err:String(m)}),u+=1}}return M.info("auto-revive: done",{revived:d,skipped:u,total:o.length}),{revived:d,skipped:u,total:o.length}}function Vl(n){let e={};return n.deployType&&(e.cozeDeployType=n.deployType),n.accountId&&(e.cozeAccountId=n.accountId),Object.keys(e).length>0?e:void 0}vr();Er();U();ie();Lt();U();ie();import{copyFile as yc,mkdir as sg,readFile as Ni,writeFile as og}from"node:fs/promises";import{dirname as ag,resolve as Mi,sep as Ir}from"node:path";import{fileURLToPath as cg}from"node:url";var bc=D("dist-install");function xg(n){let e=cg(n),s=ag(e),o=`${Ir}src${Ir}`;if(s.includes(o)||s.endsWith(`${Ir}src${Ir}cli`))return null;let c=Mi(s,"index.js"),d=Mi(s,"..","package.json");return{dist:c,pkgJson:d}}async function Bi(n={}){let e=n.paths??q(),s=xg(import.meta.url),o=n.sourceDist??s?.dist,c=n.sourcePackageJson??s?.pkgJson;if(!o||!c)return{kind:"dev-mode-skip",reason:"running from src/(tsx loader);no dist/ to install"};let d;try{d=JSON.parse(await Ni(c,"utf8")).version??"unknown"}catch(y){return bc.warn("cannot read source package.json,skip dist install",{err:String(y)}),{kind:"dev-mode-skip",reason:`package.json read failed: ${String(y)}`}}let u=await at(e.configFile)??{},l=u.libVersion;if(l===d)try{return await Ni(e.libEntry),{kind:"already-current",libVersion:d}}catch{}await sg(e.libDir,{recursive:!0}),await yc(o,e.libEntry),await yc(`${o}.map`,`${e.libEntry}.map`).catch(()=>{});let p=Mi(e.libDir,"package.json"),m=`${JSON.stringify({type:"module"},null,2)}
|
|
128
|
-
`;return await
|
|
129
|
-
`),4;let o=await
|
|
130
|
-
`),4;let c={agentId:n.agentId,sessionId:n.sessionId,kind:n.kind,path:
|
|
127
|
+
`}async function fc(n,e=K()){let s=e.binDir;await _r.mkdir(s,{recursive:!0});let o=Ml(s,process.platform==="win32"?"coze-bridge.cmd":"coze-bridge"),c=process.platform==="win32"?Fl(n):zl(n);return await _r.readFile(o,"utf8").catch(()=>null)===c||(await _r.writeFile(o,c,"utf8"),process.platform!=="win32"&&await _r.chmod(o,493)),s}q();se();import{execSync as gc}from"node:child_process";import{readFileSync as hc,unlinkSync as Ul}from"node:fs";import{mkdir as ql,readFile as pc,unlink as mc,writeFile as Kl}from"node:fs/promises";import{dirname as Hl}from"node:path";function lc(n){try{return process.kill(n,0),!0}catch(e){return e.code==="EPERM"}}var Gl=L("single-instance"),yr=class{pidFile;acquired=!1;constructor(e={}){this.pidFile=e.pidFile??K().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&&(Gl.warn("removing stale pid file",{stalePid:e}),await mc(this.pidFile).catch(()=>{})),await ql(Hl(this.pidFile),{recursive:!0}),await Kl(this.pidFile,String(process.pid),"utf8"),this.acquired=!0,this.installCleanupHooks(),{kind:"acquired"})}async release(){if(this.acquired){try{(await pc(this.pidFile,"utf8")).trim()===String(process.pid)&&await mc(this.pidFile)}catch{}this.acquired=!1}}async readExistingPid(){try{let e=await pc(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 lc(e)?this.matchesDaemonTitle(e):!1}matchesDaemonTitle(e){if(process.platform==="win32")return this.matchesDaemonTitleWindows(e);try{let s=hc(`/proc/${e}/cmdline`,"utf8").replace(/\0/g," ");return!!(s.includes("coze-bridge-daemon")||s.includes("lib/index.js"))}catch{}try{let s=gc(`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=gc(`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{hc(this.pidFile,"utf8").trim()===String(process.pid)&&Ul(this.pidFile)}catch{}})}};function jl(){let n=0,e=null;return{incActive(){n++},decActive(){n>0&&n--},activeCount(){return n},markUpgradePending(s){e=s},isUpgrading(){return e!==null},pendingTarget(){return e},async waitIdle(s){let o=Date.now()+s;for(;Date.now()<o;){if(n===0)return"idle";await new Promise(c=>setTimeout(c,200))}return n===0?"idle":"timeout"}}}var M=L("daemon"),Wl="coze-bridge-daemon";async function _c(){let n=new yr({processTitle:Wl}),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??{};bn({pid:process.pid}),M.info(s?"loaded bridge config":"initialized bridge config");try{let E=new Ot;o.frameworksCache=await E.detectAll(),M.info("refreshed frameworks_cache",{detected:Object.keys(o.frameworksCache)})}catch(E){M.warn("framework detection failed",{err:String(E)})}await Fe(o);let c=new wr(new Gt),d=K(),u=jl(),g=null,p=new $n({upstream:c,paths:d,bridgeConfig:o,upgradeGate:u,sessionSpawner:async(E,N,U,be)=>{if(!g)throw new Error("agentManager not ready");return g.spawnSessionDownstream(E,N,U,be)}});await $l(d,p);let m=new Jn({paths:d,config:o,registry:p});g=m;let _,y,S=null,T={},C,P=null,j=null;p.registerExtension("_agent/create",async E=>m.createAgent(E.params)),p.registerExtension("_agent/health",async()=>({ok:!0}));let Q={},W=new Bn({agents:p.agents,disposeAndMarkDisconnected:async(E,N)=>{let U=p.agents.get(E);if(U){await m.cleanupOpenclawSessionProviders(U).catch(ee=>M.warn("cleanup openclaw providers failed (ignored)",{agentId:E,err:String(ee)}));let be=!0;try{await U.dispose(`disconnect: ${N}`)}catch(ee){be=!1,M.error("dispose during disconnect FAILED, leaving agent in error state",{agentId:E,err:String(ee)}),U.status="error"}be&&(U.status="disconnected",p.unregister(E),p.disconnectedAgents.add(E))}else p.disconnectedAgents.add(E)},detailSyncer:async E=>{if(!Q.ref)throw new Error("agent-detail-sync not initialized yet");await Q.ref.syncOne(E)},cleanupOpenclawProviders:async E=>{await m.cleanupOpenclawSessionProviders(E)},openclawRepair:async(E,N)=>{await m.openclawRepair(E,N)},isRuntimePendingPermission:E=>p.hasPendingPermissionFor(E)});p.registerExtension("_agent/listSkills",E=>W.listSkills(E.params)),p.registerExtension("_agent/addSkills",E=>W.addSkills(E.params)),p.registerExtension("_agent/removeSkills",E=>W.removeSkills(E.params)),p.registerExtension("_agent/getFileTree",E=>W.getFileTree(E.params)),p.registerExtension("_agent/getFileContent",E=>W.getFileContent(E.params)),p.registerExtension("_agent/update",E=>W.updateAgent(E.params)),p.registerExtension("_agent/disconnect",E=>W.disconnectAgent(E.params)),p.registerExtension("_agent/switchModel",E=>W.switchModel(E.params)),p.registerExtension("_agent/reset",E=>W.resetAgent(E.params)),p.registerExtension("_agent/repair",E=>W.repairAgent(E.params));let Y=new Dn({paths:d,handlers:W,sendDetail:E=>p.sendRequest("_agent/detail",E)});Q.ref=Y;let ae=async E=>{await Promise.allSettled(E.map(async N=>{try{await W.disconnectAgent({agentId:N.agentId,reason:`auth_failure: code=${N.code} ${N.message}`}),M.info("agent disconnected due to auth failure from heartbeat response",{agentId:N.agentId,code:N.code,message:N.message})}catch(U){M.warn("disconnect during authFailure handling failed (ignored)",{agentId:N.agentId,err:String(U)})}}))};c.onConnect(({initial:E})=>{M.info("frontier upstream connected, triggering detail sync",{initial:E}),Y.syncAll(E?"initial-connect":"reconnect").catch(N=>M.warn("detail sync top-level error (ignored)",{err:String(N)}))});let ce=new Vn({paths:d,routes:[{method:"GET",path:"/status",handler:async()=>({running:!0,pid:process.pid,agents:[...p.agents.keys()],deviceId:S??"",frameworksCache:o.frameworksCache??{}})},{method:"POST",path:"/pair",handler:async E=>{let N=E,U=N?.privatecode,be=N?.pairing_code;if(!U||!be)throw new b("IPC_BAD_REQUEST","/pair requires privatecode + pairing_code");let ee=Vt(N.env),ge=N.handshake_url,Ge=N.frontier_url,re=wc(N.env,ge,Ge),Ze=!!_&&_!==U,Z=y!==void 0&&y!==re,X=Ze||Z,ut=await Vr({privatecode:U,...ge?{endpoint:ge}:{},ppeOverride:ee});if(X){M.warn("pair config switched, resetting agents",{pcChanged:Ze,envChanged:Z,previousPc:_?br(_):"",nextPc:br(U),previousEnvKey:y??"",nextEnvKey:re});for(let ie of[...p.agents.values()])await ie.dispose("pair config switch").catch(()=>{}),p.agents.delete(ie.agentId);p.disconnectedAgents.size>0&&(M.info("clearing disconnectedAgents set on pair config switch",{count:p.disconnectedAgents.size}),p.disconnectedAgents.clear()),await c.swap(new Gt,"pair switch").catch(()=>{})}S=ut.deviceId,bn({deviceId:S,pid:process.pid}),si({patToken:U,env:N.env}).catch(ie=>M.warn("coze-cli setup error (ignored)",{err:String(ie)}));let $=new hn({handshake:ut,privatecode:U,...Ge?{urlOverride:Ge}:{},ppeOverride:ee,getPatTokenForAgent:ie=>p.agents.get(ie)?.patToken});await c.swap($,"pair");try{let ie=new Ot;o.frameworksCache=await ie.detectAll(),await Fe(o),M.info("frameworks_cache refreshed before pair",{detected:Object.keys(o.frameworksCache)})}catch(ie){M.warn("frameworks_cache refresh failed (ignored, using cached)",{err:String(ie)})}let _t=Object.keys(o.frameworksCache??{});try{let ie=await p.sendRequest("_agent/pair",{pairCode:be,patToken:U,frameworks:_t,_meta:{cozeDeviceId:S}});M.info("_agent/pair ok",{pairResult:ie}),_=U,y=re,T=ee,C=ge,pn(U,d).catch(_e=>M.warn("writePatToken after /pair failed (ignored)",{err:String(_e)})),P||(P=new Xt({core:p,getDeviceId:()=>S??"",onTickEnd:()=>Y.retryPending().catch(_e=>M.warn("detailSync.retryPending failed (ignored)",{err:String(_e)})),onAuthFailures:ae,onMinBridgeVersion:_e=>j?.requestUpgrade(_e)})),P.start(),X&&vr(d,m).catch(_e=>M.warn("post-pair-switch auto-revive error (ignored)",{err:String(_e)}));let yt;return N.agent_id&&(yt=await Vl(N.agent_id,d,m,_e=>p.sendRequest("_agent/detail",_e),U).catch(_e=>(M.error("--agent-id ensureAgent failed",{agentId:N.agent_id,err:String(_e)}),{ok:!1,agentId:N.agent_id??"",note:String(_e)}))),{ok:!0,note:"paired with cloud",...yt?{agent:yt}:{}}}catch(ie){return M.error("_agent/pair failed",{err:String(ie)}),{ok:!1,note:`pair failed: ${String(ie)}`}}}},{method:"POST",path:"/connect",handler:async E=>{let N=E,U=N?.privatecode;if(!U)throw new b("IPC_BAD_REQUEST","/connect requires privatecode");let be=Vt(N.env),ee=N.handshake_url,ge=N.frontier_url,Ge=wc(N.env,ee,ge);if(_===U&&y===Ge){let $=await Jl(d);return p.agents.size===0&&$?(M.warn("/connect noop but core.agents empty with configs on disk; re-running auto-revive"),vr(d,m).catch(_t=>M.warn("connect-noop auto-revive error (ignored)",{err:String(_t)}))):M.info("/connect: already connected with same PAT + env, noop"),{ok:!0,note:"already connected"}}let re=!!_&&_!==U,Ze=y!==void 0&&y!==Ge,Z=re||Ze,X=await Vr({privatecode:U,...ee?{endpoint:ee}:{},ppeOverride:be});if(Z){M.warn("connect config switched, resetting agents",{pcChanged:re,envChanged:Ze,previousPc:_?br(_):"",nextPc:br(U)});for(let $ of[...p.agents.values()])await $.dispose("connect config switch").catch(()=>{}),p.agents.delete($.agentId);p.disconnectedAgents.size>0&&(M.info("clearing disconnectedAgents set on connect config switch",{count:p.disconnectedAgents.size}),p.disconnectedAgents.clear()),await c.swap(new Gt,"connect switch").catch(()=>{})}S=X.deviceId,bn({deviceId:S,pid:process.pid}),si({patToken:U,env:N.env}).catch($=>M.warn("coze-cli setup error (ignored)",{err:String($)}));let ut=new hn({handshake:X,privatecode:U,...ge?{urlOverride:ge}:{},ppeOverride:be,getPatTokenForAgent:$=>p.agents.get($)?.patToken});return await c.swap(ut,"connect"),_=U,y=Ge,T=be,C=ee,P||(P=new Xt({core:p,getDeviceId:()=>S??"",onTickEnd:()=>Y.retryPending().catch($=>M.warn("detailSync.retryPending failed (ignored)",{err:String($)})),onAuthFailures:ae,onMinBridgeVersion:$=>j?.requestUpgrade($)})),P.start(),Z&&vr(d,m).catch($=>M.warn("post-connect-switch auto-revive error (ignored)",{err:String($)})),pn(U,d).catch($=>M.warn("writePatToken after /connect failed (ignored)",{err:String($)})),M.info("/connect: WS established",{deviceId:S}),{ok:!0,note:"connected"}}},{method:"POST",path:"/_agent/create",handler:async E=>{let N=E;return{ok:!0,result:await m.createAgent(N)}}},{method:"POST",path:"/agent/send",handler:async E=>{let N=E;if(!N?.agentId||!N?.sessionId||!N?.kind||!N?.path)throw new b("IPC_BAD_REQUEST","/agent/send requires agentId, sessionId, kind, path");if(!_)throw new b("UPSTREAM_NOT_READY","daemon not yet paired with cloud (run --pair-code first)");try{return await _o(N,{core:p,patToken:_,handshakeBase:C,ppeOverride:T})}catch(U){if(U instanceof b)return{ok:!1,code:U.code,message:U.message};throw U}}},{method:"POST",path:"/refresh",handler:async()=>{M.info("IPC /refresh: re-detecting frameworks");let E=new Ot;return o.frameworksCache=await E.detectAll(),await Fe(o),{ok:!0,frameworks:o.frameworksCache}}},{method:"POST",path:"/shutdown",handler:async()=>(M.info("IPC /shutdown received"),setImmediate(()=>{fe.shutdown("ipc /shutdown")}),{ok:!0})}]}),{port:De,token:me}=await ce.start();try{await fc(d.libEntry,d)}catch(E){M.warn("bin shim install failed (D72 send \u547D\u4EE4\u53EF\u80FD\u4E0D\u53EF\u7528)",{err:String(E)})}await p.start(),vr(d,m).catch(E=>M.warn("auto-revive top-level error (ignored)",{err:String(E)})),ys().catch(E=>M.warn("acp wrapper warmup top-level error (ignored)",{err:String(E)}));let ue=null,fe={port:De,token:me,core:p,ipc:ce,shutdown(E){return ue||(M.info("daemon shutdown",{reason:E}),ue=(async()=>{P?.stop(),await p.stop(E),await ce.stop(),await n.release()})(),ue)}};j=new Yn({paths:d,currentVersion:it,isDevMode:zo,download:(E,N)=>qo(E,N),spawnHelper:(E,N)=>Fo(E,N,{paths:d}),daemon:{markUpgradePending:E=>{M.warn("upgrade pending, ACP gate engaged",{target:E}),u.markUpgradePending(E)},waitIdle:E=>u.waitIdle(E),exit:E=>{fe.shutdown("upgrade").then(()=>process.exit(E))}}});for(let E of["SIGTERM","SIGINT"])process.on(E,()=>{fe.shutdown(E).then(()=>process.exit(0))});return M.info("daemon ready",{port:De,pid:process.pid,nodeVersion:process.version,platform:process.platform,frameworks:Object.keys(o.frameworksCache??{}),libVersion:o.libVersion??"dev"}),fe}async function Jl(n){let{readdir:e}=await import("node:fs/promises");try{return(await e(n.agentsRoot)).length>0}catch{return!1}}function br(n){return n.length<=8?"***":`${n.slice(0,4)}***${n.slice(-4)}`}function wc(n,e,s){return`${n??""}|${e??""}|${s??""}`}async function $l(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(()=>(rt(),Tn));for(let u of o){await d(u,n).catch(g=>M.warn("enforceAgentConfigMode failed (ignored)",{agentId:u,err:String(g)}));try{let g=await c(u,n);g?.disconnectedAt&&(e.disconnectedAgents.add(u),M.info("agent marked disconnected on startup",{agentId:u,disconnectedAt:g.disconnectedAt,reason:g.disconnectReason??""}))}catch(g){M.warn("failed to load agent config on startup, skipping",{agentId:u,err:String(g)})}}}async function Vl(n,e,s,o,c){let{loadAgentConfig:d}=await Promise.resolve().then(()=>(rt(),Tn)),u=await d(n,e);if(u){M.info("--agent-id: local config found, reconnecting",{agentId:n,framework:u.framework,hadDisconnect:!!u.disconnectedAt});let _={agentId:u.agentId,framework:u.framework,...u.cozeIdentity?{cozeIdentity:u.cozeIdentity}:{},...u.model?{model:u.model}:{},...c?{patToken:c}:{}};return await s.createAgent(_),{ok:!0,agentId:n,note:u.disconnectedAt?"revived from local config":"connected from local config"}}M.info("--agent-id: local config missing, pulling _agent/detail from cloud",{agentId:n});let g=await o({_meta:{cozeAgentId:n}});if(!g.framework)throw new b("AGENT_NOT_FOUND",`agent ${n} \u4E0D\u5728\u672C\u5730; \u4E91\u7AEF _agent/detail \u54CD\u5E94\u7F3A framework \u5B57\u6BB5 (D36 \u534F\u8BAE\u6269\u5C55\u672A\u751F\u6548), \u65E0\u6CD5\u5728\u672C\u673A\u65B0\u5EFA`);let p={agentId:g.agentId,framework:g.framework,...g.cozeIdentity?{cozeIdentity:g.cozeIdentity}:{},...g.model?{model:g.model}:{},...c?{patToken:c}:{},...g.deployType?{_meta:{cozeDeployType:g.deployType}}:{}};await s.createAgent(p);let m=g.deployType==="cloud"&&g.framework==="openclaw";return{ok:!0,agentId:n,note:m?"cloud agent acknowledged":"created from cloud detail"}}async function vr(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(()=>(rt(),Tn));M.info("auto-revive: scanning local agents on startup",{count:o.length});let d=0,u=0;for(let g of o){let p;try{p=await c(g,n)}catch(m){M.warn("auto-revive: load config failed (skipping)",{agentId:g,err:String(m)}),u+=1;continue}if(!p){u+=1;continue}if(p.disconnectedAt){M.info("auto-revive: skip disconnected agent",{agentId:g,disconnectedAt:p.disconnectedAt}),u+=1;continue}try{M.info("auto-revive: re-registering agent (D44 no spawn)",{agentId:g,framework:p.framework});let m=Yl(p);await e.createAgent({agentId:p.agentId,framework:p.framework,...p.cozeIdentity?{cozeIdentity:p.cozeIdentity}:{},...p.model?{model:p.model}:{},...m?{_meta:m}:{}}),d+=1}catch(m){M.warn("auto-revive: createAgent failed (skipping)",{agentId:g,framework:p.framework,err:String(m)}),u+=1}}return M.info("auto-revive: done",{revived:d,skipped:u,total:o.length}),{revived:d,skipped:u,total:o.length}}function Yl(n){let e={};return n.deployType&&(e.cozeDeployType=n.deployType),n.accountId&&(e.cozeAccountId=n.accountId),Object.keys(e).length>0?e:void 0}Sr();Ar();q();se();Nt();q();se();import{copyFile as bc,mkdir as og,readFile as Bi,writeFile as ag}from"node:fs/promises";import{dirname as cg,resolve as Mi,sep as Ir}from"node:path";import{fileURLToPath as xg}from"node:url";var vc=L("dist-install");function dg(n){let e=xg(n),s=cg(e),o=`${Ir}src${Ir}`;if(s.includes(o)||s.endsWith(`${Ir}src${Ir}cli`))return null;let c=Mi(s,"index.js"),d=Mi(s,"..","package.json");return{dist:c,pkgJson:d}}async function zi(n={}){let e=n.paths??K(),s=dg(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 Bi(c,"utf8")).version??"unknown"}catch(y){return vc.warn("cannot read source package.json,skip dist install",{err:String(y)}),{kind:"dev-mode-skip",reason:`package.json read failed: ${String(y)}`}}let u=await ct(e.configFile)??{},g=u.libVersion;if(g===d)try{return await Bi(e.libEntry),{kind:"already-current",libVersion:d}}catch{}await og(e.libDir,{recursive:!0}),await bc(o,e.libEntry),await bc(`${o}.map`,`${e.libEntry}.map`).catch(()=>{});let p=Mi(e.libDir,"package.json"),m=`${JSON.stringify({type:"module"},null,2)}
|
|
128
|
+
`;return await Bi(p,"utf8").catch(()=>null)!==m&&await ag(p,m),u.libVersion=d,await Fe(u,e.configFile),vc.info("dist installed",{libEntry:e.libEntry,fromVersion:g,toVersion:d}),g?{kind:"version-changed",fromVersion:g,toVersion:d,libEntry:e.libEntry}:{kind:"first-install",libVersion:d,libEntry:e.libEntry}}Ar();se();import{basename as ug,resolve as fg}from"node:path";var lg=9e4,gg={PATH_OUTSIDE_WORKSPACE:3,FILE_TOO_LARGE:3,UNSUPPORTED_MIME:3,IPC_BAD_REQUEST:3,AGENT_NOT_FOUND:4,IPC_AUTH_FAILED:4,AGENT_DISCONNECTED:5,UPLOAD_FAILED:5,UPSTREAM_NOT_READY:5,UPSTREAM_DISCONNECTED:5,UPSTREAM_HANDSHAKE_FAILED:5,AGENT_BUSY:1,AGENT_SPAWN_FAILED:1,AGENT_TIMEOUT:1,AGENT_PROTOCOL_ERROR:1,BRIDGE_CONFIG_INVALID:1,BRIDGE_INTERNAL:1,MODEL_TOKEN_GEN_FAILED:1,OPERATION_NOT_ALLOWED_FOR_LOCAL:1,BRIDGE_UPGRADING:5};function hg(n){return gg[n]??1}async function Sc(n,e={}){let s=e.paths??K();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 Er(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:fg(process.cwd(),n.path),...n.caption?{caption:n.caption}:{},...n.name?{name:n.name}:{}},d;try{d=await pg(o,"/agent/send",c,lg)}catch(u){return process.stderr.write(`Error: daemon IPC failed: ${u instanceof Error?u.message:String(u)}
|
|
131
131
|
`),4}if(!d.ok)return process.stderr.write(`Error: ${d.code}: ${d.message}
|
|
132
|
-
`),
|
|
133
|
-
`);else{let u=n.name??
|
|
134
|
-
`)}return 0}async function
|
|
132
|
+
`),hg(d.code);if(n.json)process.stdout.write(`${JSON.stringify(d)}
|
|
133
|
+
`);else{let u=n.name??ug(c.path);process.stdout.write(`Sent ${n.kind} ${u} (${mg(d.bytes)})
|
|
134
|
+
`)}return 0}async function pg(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}),g=await u.text(),p=g?JSON.parse(g):null;return p&&typeof p=="object"&&"ok"in p?p:{ok:!1,code:"BRIDGE_INTERNAL",message:`unexpected daemon response (status=${u.status}): ${g.slice(0,200)}`}}finally{clearTimeout(d)}}function mg(n){return n<1024?`${n}B`:n<1024*1024?`${(n/1024).toFixed(1)}KB`:`${(n/1024/1024).toFixed(1)}MB`}var Nc=L("cli");function pe(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 Wg(n){let e=n.slice(2);if(e.includes("--version")||e.includes("-v"))return{mode:"version"};if(e.includes("--daemon"))return{mode:"daemon"};if(e.includes("--status"))return{mode:"status"};if(e.includes("--stop"))return{mode:"stop"};if(e.includes("--refresh"))return{mode:"refresh"};if(e.includes("--uninstall"))return{mode:"uninstall"};if(e.includes("--install-service"))return{mode:"install-service"};if(e.includes("--upgrade-helper")){let P=e.filter(ae=>ae!=="--upgrade-helper"),{value:j,rest:Q}=pe(P,"--target-version"),{value:W}=pe(Q,"--old-pid"),Y=W?Number.parseInt(W,10):Number.NaN;return!j||!Number.isFinite(Y)?{mode:"help"}:{mode:"upgrade-helper",targetVersion:j,oldPid:Y}}if(e[0]==="send")return Jg(e.slice(1));if(e[0]==="connect")return $g(e.slice(1));if(e.includes("--help")||e.includes("-h")||e.length===0)return{mode:"help"};let s=e,{value:o,rest:c}=pe(s,"--pat-token");s=c;let{value:d,rest:u}=pe(s,"--pair-code");s=u;let{value:g,rest:p}=pe(s,"--env");s=p;let{value:m,rest:_}=pe(s,"--handshake-url");s=_;let{value:y,rest:S}=pe(s,"--frontier-url");s=S;let{value:T}=pe(s,"--agent-id");if(!o||!d)return{mode:"help"};let C={mode:"pair",privatecode:o,pairingCode:d};return g&&(C.env=g),m&&(C.handshakeUrl=m),y&&(C.frontierUrl=y),T&&(C.agentId=T),C}function Jg(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}=pe(o,"--caption");o=d;let{value:u,rest:g}=pe(o,"--name");o=g;let{value:p,rest:m}=pe(o,"--agent-id");o=m;let{value:_,rest:y}=pe(o,"--session-id");o=y;let S=o.includes("--json"),T={mode:"send",kind:e,path:s,json:S};return c&&(T.caption=c),u&&(T.name=u),p&&(T.agentId=p),_&&(T.sessionId=_),T}function $g(n){let e=n,{value:s,rest:o}=pe(e,"--pat-token");e=o;let{value:c,rest:d}=pe(e,"--env");e=d;let{value:u,rest:g}=pe(e,"--handshake-url");e=g;let{value:p}=pe(e,"--frontier-url"),m={mode:"connect"};return s&&(m.privatecode=s),c&&(m.env=c),u&&(m.handshakeUrl=u),p&&(m.frontierUrl=p),m}var Vg=`
|
|
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
|
|
178
|
+
`.trimStart();async function Bc(n=process.argv,e={}){let s=Wg(n);switch(s.mode){case"help":return process.stdout.write(Vg),0;case"version":return process.stdout.write(`${it}
|
|
179
|
+
`),0;case"daemon":{try{await _c()}catch(o){return Nc.error("daemon start failed",{err:String(o)}),1}return new Promise(()=>{})}case"status":return Yg(e);case"stop":return Xg(e);case"refresh":return Zg(e);case"uninstall":return Qg(e);case"install-service":return eh();case"pair":{let o={};return s.env&&(o.env=s.env),s.handshakeUrl&&(o.handshakeUrl=s.handshakeUrl),s.frontierUrl&&(o.frontierUrl=s.frontierUrl),th(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),nh(s.privatecode,e,o)}case"upgrade-helper":{let{runUpgradeHelper:o}=await Promise.resolve().then(()=>(kc(),Pc));return await o({targetVersion:s.targetVersion,oldPid:s.oldPid,...e.paths?{paths:e.paths}:{}})}case"send":return Sc({kind:s.kind,path:s.path,...s.agentId?{agentId:s.agentId}:{},...s.sessionId?{sessionId:s.sessionId}:{},...s.caption?{caption:s.caption}:{},...s.name?{name:s.name}:{},json:s.json},e)}}async function Mc(n){let{unlink:e}=await import("node:fs/promises");await Promise.all([e(n.pidFile).catch(()=>{}),e(n.portFile).catch(()=>{}),e(n.tokenFile).catch(()=>{})])}async function Yg(n){let e=n.paths??K(),s=new Oe(e),o=await s.probe();if(o.kind==="not-running")return process.stdout.write(`coze-bridge: not running
|
|
180
180
|
`),1;if(o.kind==="stale")return await Mc(e),process.stdout.write(`coze-bridge: not running (cleaned stale state)
|
|
181
181
|
`),1;let c=await s.request({method:"GET",path:"/status"});return process.stdout.write(`coze-bridge: running
|
|
182
182
|
${JSON.stringify(c.body,null,2)}
|
|
183
|
-
`),0}async function
|
|
183
|
+
`),0}async function Xg(n){let e=n.paths??K(),s=new Oe(e),o=await s.probe();if(o.kind==="not-running")return process.stdout.write(`coze-bridge: not running
|
|
184
184
|
`),0;if(o.kind==="stale")return await Mc(e),process.stdout.write(`coze-bridge: not running (cleaned stale state)
|
|
185
185
|
`),0;try{return await s.request({method:"POST",path:"/shutdown"}),process.stdout.write(`coze-bridge: stopped
|
|
186
186
|
`),0}catch(c){return process.stdout.write(`coze-bridge: stop failed: ${String(c)}
|
|
187
|
-
`),1}}async function
|
|
187
|
+
`),1}}async function Zg(n){let e=new Oe(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 Qg(n){let e=new
|
|
192
|
+
`),1}}async function Qg(n){let e=new Oe(n.paths);if((await e.probe()).kind==="connected"){process.stdout.write(`coze-bridge: stopping daemon...
|
|
193
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(()=>(
|
|
194
|
+
`)}await new Promise(d=>setTimeout(d,500))}if(!n.skipSupervisor)try{let{getSupervisor:d,buildContext:u}=await Promise.resolve().then(()=>(Ji(),Wi)),g=d();await g.uninstall(u()),process.stdout.write(`coze-bridge: ${g.platform} supervisor unregistered
|
|
195
195
|
`)}catch(d){process.stderr.write(`coze-bridge: supervisor uninstall failed (continuing): ${String(d)}
|
|
196
|
-
`)}let o=n.paths??
|
|
196
|
+
`)}let o=n.paths??K(),{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
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
|
|
199
|
+
`),0}async function eh(){try{let{getSupervisor:n,buildContext:e}=await Promise.resolve().then(()=>(Ji(),Wi)),s=n(),o=e();return process.stdout.write(`coze-bridge: installing ${s.platform} supervisor...
|
|
200
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
|
|
202
|
+
`),1}}async function th(n,e,s,o={},c){let d=new Oe(s.paths),u=s.spawnDaemon??mn;if(!s.skipDistInstall){let m=await zi({paths:s.paths});m.kind==="version-changed"?(process.stdout.write(`coze-bridge: upgraded ${m.fromVersion} \u2192 ${m.toVersion}
|
|
203
203
|
`),(await d.probe()).kind==="connected"&&(await d.request({method:"POST",path:"/shutdown"}).catch(()=>{}),await new Promise(y=>setTimeout(y,500)))):m.kind==="first-install"&&process.stdout.write(`coze-bridge: installed ${m.libVersion}
|
|
204
|
-
`)}let
|
|
205
|
-
`),await u({paths:s.paths}),
|
|
204
|
+
`)}let g=await d.probe();if(g.kind!=="connected"&&(process.stdout.write(`coze-bridge: starting daemon...
|
|
205
|
+
`),await u({paths:s.paths}),g=await zc(d,s.waitTimeoutMs??1e4,s.sleep??Fc),g.kind!=="connected"))return process.stderr.write(`coze-bridge: daemon did not come up: ${g.kind}
|
|
206
206
|
`),1;let p={privatecode:n,pairing_code:e};o.env&&(p.env=o.env),o.handshakeUrl&&(p.handshake_url=o.handshakeUrl),o.frontierUrl&&(p.frontier_url=o.frontierUrl),c&&(p.agent_id=c);try{let m=await d.request({method:"POST",path:"/pair",body:p,timeoutMs:35e3});return m.status===200&&m.body?.ok?(process.stdout.write(`coze-bridge: paired (${m.body.note??"ok"})
|
|
207
207
|
`),0):(process.stderr.write(`coze-bridge: pair failed: ${JSON.stringify(m.body)}
|
|
208
208
|
`),1)}catch(m){return process.stderr.write(`coze-bridge: pair failed: ${String(m)}
|
|
209
|
-
`),1}}async function
|
|
209
|
+
`),1}}async function nh(n,e,s={}){let o=e.paths??K(),c=n??await uc(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 Oe(e.paths),u=e.spawnDaemon??mn;if(!e.skipDistInstall){let m=await zi({paths:e.paths});m.kind==="version-changed"?(process.stdout.write(`coze-bridge: upgraded ${m.fromVersion} \u2192 ${m.toVersion}
|
|
210
210
|
`),(await d.probe()).kind==="connected"&&(await d.request({method:"POST",path:"/shutdown"}).catch(()=>{}),await new Promise(y=>setTimeout(y,500)))):m.kind==="first-install"&&process.stdout.write(`coze-bridge: installed ${m.libVersion}
|
|
211
|
-
`)}let
|
|
212
|
-
`),await u({paths:e.paths}),
|
|
211
|
+
`)}let g=await d.probe();if(g.kind!=="connected"&&(process.stdout.write(`coze-bridge: starting daemon...
|
|
212
|
+
`),await u({paths:e.paths}),g=await zc(d,e.waitTimeoutMs??1e4,e.sleep??Fc),g.kind!=="connected"))return process.stderr.write(`coze-bridge: daemon did not come up: ${g.kind}
|
|
213
213
|
`),1;let p={privatecode:c};s.env&&(p.env=s.env),s.handshakeUrl&&(p.handshake_url=s.handshakeUrl),s.frontierUrl&&(p.frontier_url=s.frontierUrl);try{let m=await d.request({method:"POST",path:"/connect",body:p,timeoutMs:35e3});return m.status===200&&m.body?.ok?(process.stdout.write(`coze-bridge: connected (${m.body.note??"ok"})
|
|
214
|
-
`),await
|
|
214
|
+
`),await pn(c,o).catch(_=>Nc.warn("writePatToken after connect failed (ignored)",{err:String(_)})),0):(process.stderr.write(`coze-bridge: connect failed: ${JSON.stringify(m.body)}
|
|
215
215
|
`),1)}catch(m){return process.stderr.write(`coze-bridge: connect failed: ${String(m)}
|
|
216
|
-
`),1}}async function
|
|
216
|
+
`),1}}async function zc(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 Fc(n){return new Promise(e=>setTimeout(e,n))}Bc(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)});
|