coze-bridge 0.1.48 → 0.1.50

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.
Files changed (2) hide show
  1. package/dist/index.js +69 -69
  2. 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 jr=Object.defineProperty;var R0=Object.getOwnPropertyDescriptor;var L0=Object.getOwnPropertyNames;var O0=Object.getPrototypeOf,N0=Object.prototype.hasOwnProperty;var ee=(n=>typeof require<"u"?require:typeof Proxy<"u"?new Proxy(n,{get:(e,s)=>(typeof require<"u"?require:e)[s]}):n)(function(n){if(typeof require<"u")return require.apply(this,arguments);throw Error('Dynamic require of "'+n+'" is not supported')});var Ae=(n,e)=>()=>(n&&(e=n(n=0)),e);var _e=(n,e)=>()=>(e||n((e={exports:{}}).exports,e),e.exports),Kr=(n,e)=>{for(var s in e)jr(n,s,{get:e[s],enumerable:!0})},M0=(n,e,s,o)=>{if(e&&typeof e=="object"||typeof e=="function")for(let c of L0(e))!N0.call(n,c)&&c!==s&&jr(n,c,{get:()=>e[c],enumerable:!(o=R0(e,c))||o.enumerable});return n};var Ke=(n,e,s)=>(s=n!=null?D0(O0(n)):{},M0(e||!n||!n.__esModule?jr(s,"default",{value:n,enumerable:!0}):s,n));function hs(n){return _n[ls]<=_n[n]}function yn(n){gs={...n}}function wn(n,e,s,o){if(_n[n]<_n[ls])return;let c=JSON.stringify({ts:new Date().toISOString(),level:n,module:e,msg:s,...gs,...o});n==="error"||n==="warn"?z0.write(`${c}
9
- `):B0.write(`${c}
10
- `)}function D(n){return{debug:(e,s)=>wn("debug",n,e,s),info:(e,s)=>wn("info",n,e,s),warn:(e,s)=>wn("warn",n,e,s),error:(e,s)=>wn("error",n,e,s),child:e=>D(`${n}.${e}`)}}var _n,ls,B0,z0,gs,U=Ae(()=>{"use strict";_n={debug:10,info:20,warn:30,error:40},ls=(()=>{let n=process.env.COZE_BRIDGE_LOG_LEVEL;return n==="debug"||n==="info"||n==="warn"||n==="error"?n:"info"})(),B0=process.stdout,z0=process.stderr,gs={}});import{chmod as X0,mkdir as Q0,readFile as Z0,rename as ys,writeFile as bs}from"node:fs/promises";import{dirname as ex}from"node:path";async function Et(n){try{let e=await Z0(n,"utf8");return JSON.parse(e)}catch(e){if(e.code==="ENOENT")return null;throw e}}async function In(n,e,s){await Q0(ex(n),{recursive:!0});let o=`${JSON.stringify(e,null,2)}
11
- `,c=`${n}.tmp-${process.pid}-${Math.random().toString(36).slice(2,10)}`;try{s?.mode!==void 0?await bs(c,o,{encoding:"utf8",mode:s.mode}):await bs(c,o,"utf8"),await ys(c,n),s?.mode!==void 0&&await X0(n,s.mode)}catch(d){await ys(c,c).catch(()=>{});let{rm:u}=await import("node:fs/promises");throw await u(c,{force:!0}).catch(()=>{}),d}}var An=Ae(()=>{"use strict"});import{promises as vs}from"node:fs";import{homedir as tx}from"node:os";import{sep as nx,join as fe,resolve as Ss}from"node:path";function q(n){let e=n??tx(),s=fe(e,".coze"),o=fe(s,"bridge"),c=fe(o,"lib");return{cozeRoot:s,bridgeRoot:o,libDir:c,libEntry:fe(c,"index.js"),binDir:fe(o,"bin"),pidFile:fe(o,"bridge.pid"),portFile:fe(o,"bridge.port"),tokenFile:fe(o,"bridge.token"),patTokenFile:fe(o,"pat-token"),logFile:fe(o,"bridge.log"),installLock:fe(o,"install.lock"),configFile:fe(o,"config.json"),agentsRoot:fe(s,"agents")}}function Ge(n,e=q()){let s=fe(e.agentsRoot,n);return{root:s,config:fe(s,"config.json"),workspace:fe(s,"workspace"),logs:fe(s,"logs")}}async function Es(n,e){let s=await vs.realpath(Ss(n)).catch(()=>null);if(!s)return!1;let o=await vs.realpath(Ss(e)).catch(()=>null);if(!o)return!1;let c=process.platform==="win32"?s.toLowerCase():s,d=process.platform==="win32"?o.toLowerCase():o;return c===d||c.startsWith(d+nx)}var ie=Ae(()=>{"use strict"});var kn={};Kr(kn,{AGENT_CONFIG_FILE_MODE:()=>Cn,enforceAgentConfigMode:()=>sx,loadAgentConfig:()=>me,persistAgentSessions:()=>Wr,persistAgentSkills:()=>Pn,saveAgentConfig:()=>Ce});import{chmod as rx,stat as ix}from"node:fs/promises";function me(n,e){return Et(Ge(n,e).config)}function Ce(n,e){return In(Ge(n.agentId,e).config,n,{mode:Cn})}async function sx(n,e){if(process.platform==="win32")return;let s=Ge(n,e).config;try{let o=await ix(s);if(!o.isFile())return;let c=o.mode&511;c!==Cn&&(await rx(s,Cn),Is.warn("agent config mode auto-corrected to 0600",{path:s,from:c.toString(8)}))}catch(o){if(o.code==="ENOENT")return;Is.warn("enforceAgentConfigMode: chmod failed (ignored)",{path:s,err:String(o)})}}async function Wr(n,e,s){let o=await me(n,s);o&&(o.sessions=Object.fromEntries(e),await Ce(o,s))}async function Pn(n,e,s){let o=await me(n,s);o&&(o.skills=e,await Ce(o,s))}var Is,Cn,nt=Ae(()=>{"use strict";An();U();ie();Is=D("agent-config"),Cn=384});function Io(n){let e=n?.sessionIdleTimeoutMs;return typeof e!="number"||!Number.isFinite(e)||e<=0?Kd:e}function at(n){return Et(n??q().configFile)}function ze(n,e){return In(e??q().configFile,n)}var Kd,Lt=Ae(()=>{"use strict";An();ie();Kd=10*6e4});var Qo=_e(Y=>{"use strict";var E=k;(function(n,e){let s=k,o=n();for(;;)try{if(-parseInt(s(920))/1+parseInt(s(760))/2*(-parseInt(s(1375))/3)+-parseInt(s(1436))/4*(-parseInt(s(1702))/5)+parseInt(s(1610))/6+parseInt(s(865))/7*(parseInt(s(1077))/8)+-parseInt(s(1595))/9+parseInt(s(1135))/10===e)break;o.push(o.shift())}catch{o.push(o.shift())}})(Zn,501112);var ju=Object[E(1512)+E(1778)],Ku=Object[E(324)+"opertyNa"+E(1776)],Jo=(n,e)=>function(){return n&&(e=(0,n[{hkZbc:function(d,u){return d(u)}}[E(563)](Ku,n)[0]])(n=0)),e},Gu=(n,e)=>{let s=E,o={lSBmM:function(d,u,l,p){return d(u,l,p)}};for(var c in e)o[s(608)](ju,n,c,{get:e[c],enumerable:!0})};function Wu(){return Ho||(Ho=[IDBDatabase,IDBObjectStore,IDBIndex,IDBCursor,IDBTransaction])}function Ju(){let n=E;return jo||(jo=[IDBCursor[n(1349)+"e"][n(630)],IDBCursor[n(1349)+"e"][n(965)],IDBCursor[n(1349)+"e"][n(965)+n(1279)+"ey"]])}function $u(n){let e=E,s={rIfAb:e(321),kvZcc:function(c,d){return c===d},jChUo:e(1504),cyIpI:function(c,d){return c(d)},LeEFx:function(c){return c()},mJDme:e(1255),eeoHQ:function(c,d){return c instanceof d}},o=new Promise((c,d)=>{let u=e,l={aAxbJ:function(y,I){return y|I}},p=()=>{let y=k;n[y(605)+y(720)+y(396)](y(1255),m),n[y(605)+y(720)+"ner"](s[y(881)],_)},m=()=>{let y=k;s[y(1585)](s[y(347)],s[y(347)])?(c(s[y(467)](Ue,n[y(679)])),s[y(591)](p)):(_0x108c45[_0x45056c++]=l[y(1638)](_0x3364e2>>6,192),_0x45ad11[_0x5a78b6++]=l[y(1638)](63&_0x259db0,128))},_=()=>{let y=k;s[y(467)](d,n.error),s[y(591)](p)};n[u(884)+"Listener"](s.mJDme,m),n[u(884)+"Listener"](s[u(881)],_)});return o[e(317)](c=>{let d=e;s[d(1729)](c,IDBCursor)&&xi[d(1651)](c,n)}).catch(()=>{}),tr[e(1651)](o,n),o}function Zn(){let n=["uxL1ze8","twvZC2fNzuu","v3bUDNO","A1L5zMu","t05yEfq","DK1dq3q","tKnqsxq","tuD2swe","A2v5CW","re55EMW","C2nYAxb0","A1L3u2C","BxnN","BxjvEvy","zKHTsgW","veP4sfG","suvtx0vsuK8","z29sD0C","DfDut08","BgLTAxq","DwDiq2K","zw5NDgG","BLH2D2m","ELzMuxi","C3rYAw5NAwy","igzPzwXKoIa","q09otKvdveK","wfH0EuG","t3HbCwq","yNL0zxm","yw5Nzq","CKnwEgi","A3zAy2m","zgLZCgf0y2G","D2fZq2XLyw4","Dev2zw50","vwztEKe","B2nRzxrtDwm","ENfzt0q","B2nRzxq","revvuwO","u3juuuq","mtiYotCWnNncBgnwDa","zLrrBMy","svf0Cge","rxnluu0","z3LpsfG","ruXkzhu","zxfPwMC","aaaaaaaaaaa","Bwf4tg9ZC0m","y2uGBM90igK","Dg9tDhjPBMC","vLjNCM8","q1HXz2W","vhjVq0e","CevftwO","mtyXmJi3oe9rrxbSDW","DvLyqwO","shnJA0u","ENPAAw0","r1fytwu","EvvWugO","A2TyzLi","zxH0zw5ZAw8","zxPtzMe","Ewnst0S","D1DisKW","tLzhBLm","B2XKvMvYC2K","AKzMDwS","Cg9PBNrbBMq","D1rZEhK","EvzNwgu","y1b2EgS","y0nhyMi","zgHJq1O","B3jRig9MzMW","Dw5KzwzPBMu","y25tuu8","BvjiANC","wvj4zu0","BMfVr0W","AgLxtNi","EvjLy29UBMu","yuf4yKO","vgnPzK4","DhnrBNa","DeXIEu4","A2v5","zhrYtNi","y3jLyxrLt2i","EMDTr3K","DgvZDa","Aw9UvgLTzw8","AefJA01LC3m","uLDhwNu","zMX1C2HfEha","C2v0","wLv3Ce4","ywXty29Wzq","uhvitvq","B3bLBG","t3fyEfG","z2v0","CLjwC3G","t1HZsu8","EeL5rey","zgf0yq","y2XVC2uSihC","Cvf5vNy","t1bftG","q1bdv3q","BvLkDgi","q3Lvruq","m3W1Fdb8mxW","yM9L","y3jLyxrLt3a","u3HlAwy","DNn6uNq","Eu9cv2i","sMzpzgC","AuXMuvq","ANb3B3q","mxWW","z0Tvq20","uvnVque","Chv0","nxWYFdn8nhW","CNvMr3C","DLb1AvO","tKrXuKO","yxv0BW","C29YDa","vevSD1C","s0Xsuhq","wxL4BLm","q1rzrwG","C0LmvwO","u2HHCMvKv28","tLnjALC","sKDmquy","r1DMrKi","Ew1kwM4","BwvZC2fNzq","D3m6lY8","BwLUzW","q29Kzq","ANvSs1O","mtK0mdvczerLrgW","Dw9hu0q","yMLUyxj5vhK","v2vPEgLUsLm","x2DLDeLUDgu","DxntsvC","sLLUvuO","r2r5EgK","ENbxsNq","B2nRzxrgywK","svjevgG","ywDLrxzLBNq","yMXVy2TLza","zwvKzwq","yxnJCMLWDa","zwn0","vw1dsgm","zxPbqvy","C0P6vuq","BNruCMLLC0m","ywDLsgLKzq","CgLUz19VBMm","u2HLqLq","zxrxB3jRq2G","tw1xr08","C2vYDMvYvgK","zwzPDgi","zwvVsfe","Euz0seu","z29PBMCGyxC","D3LYAwC","wMHXC3m","D29PDMC","tKvruuC","C2vYDMLJzs0","DhLWzq","ufvzsei","teX0qwm","DgLTzw91Da","tw5xu3e","BhrPCgXLihq","BMCGDxjSoIa","tMfQyMO","BgfgvNC","zwD3qKe","Dvjiu1i","BwvZC2fNzv8","zxjHDg9Y","x2XPC3rLBMu","yLD1ufO","veLgzKG","yvzQDvK","uKjvwey","u2vXsuq","txDZy1q","wMPUzxm","s3jkCg0","u1HODMW","AhzpA2u","BeTNBu0","DNDrEw4","vgLTzw91Da","zNDZxZeUmc4","BxnNsuq","u0T2shK","Cg5cwMe","ChrVCG","ruHXCNy","Dgv4Dc9Qyxy","Cg93","sKP5zw4","AvP0uwC","ChvZAa","AvnOAeC","BwvZ","AwXLtMfTzq","B3bLCNr5","z05gDfa","BM93","DxjS","ve5htwS","Aw5KzxGGB3u","EgzTuvC","Dg9cExrLCW","yxnL","y0TPvhe","BMDLza","r0jfCxK","ywjVCNq","thHxuxG","EK9zChq","A05iqu4","CMvHzhLtDge","tg9JAW","A3v0ChO","Dg9mB3DLCKm","uMjTu0K","wKTsCwu","A2Hqyui","zMLSDgvY","FdeXFdj8ohW","swvhChq","reiGzMfPBgu","yxKSig5LDhC","zwjzwxm","B3bLBIa","yuzmqKO","C2Hks24","rhnYBMK","qLPdseC","sLDUEMK","ve52Bgm","BMrWB2LUDca","Bxv3wvO","x29Ut3bLBG","CMLMzxG","o2nOyxjZzxq","CMvZzxrfBMq","wMTYuK8","BNvTyMvY","x194x21Zz18","BejeshC","B3j3zwS","yM9KEq","DxnLCKLW","tg9NsurozxC","CxfPqvi","qLrtENO","mdaWma","DxrMofDYAxq","wfLJyMq","x2vUzhbVAw4","y3jLyxrLq2W","EffLBeO","BfLcDva","suzMA1m","BwvY","vxblze0","uff2ENm","v2PYtve","AgHmBui","zM9ZCK4","uLPWteO","sw9Xsu4","DM1zDMC","zNjVBuHHC2G","y2vZC0HHBMq","DMvY","yvnMCgy","rgvKAwnHDgu","CuL2y2y","ihzHBgLKihm","Euf0vLa","swHvsuO","s3PQvMe","BxrKtge","sLnhEe4","EujqtKy","vxbKyxrLq28","zxLhD1i","rvjst1i","zxj2AwnL","BwvZC2fNztO","ihrVihjLDhi","x3bPBMDmB3m","DhjPBq","AeHYz0C","sfzXy2G","zMLN","zev5u1G","B25pCgvU","AenQCg8","CLzjsKu","sKznzMm","z2vY","Aw5PDcbrB1m","y3vYCMvUDeu","CMvWBgfJzui","BM5Ly3q","vMTWu2W","x3DZ","qNbZAgu","DLjpz2W","y29UBMvJDeu","ExnfD2e","s09RsKG","C0jf","r2XJAuS","uuDMCvG","s2PjBgy","CgLUz0XVC3m","rKjWCve","zxjFAxnFywm","De1HBMfNzxi","uxrItvG","qvHezeu","yNbHwM4","DufeEwe","ALHzqu8","AfLZs0S","ANrVALC","BMfTzq","z2v0qwXSs2u","DvzZChu","CxjTAg4","wxr0tNe","r3vSvxG","CNzHBa","DgHLBG","CgLUz0LUDgu","sMvWwKK","BvDhufm","zxjYB3i","A1vJzNa","AwrI","z2v0t3DUuhi","AgvKtwf4uMu","tenwt3G","BMrWB2LUDfq","quXLAgi","seTSyuq","mNW1Fdf8mhW","sLngrwu","C21tDxC","AKHYA04","EuHwCKG","ENjAAuO","ug5ptfG","tLHlC3m","zw5JB2rLrNi","qxfJq24","Aw5L","Dgv4Dc9WBge","vgT5vxC","y3bKtg8","ywXSq3vYC28","B2LUDfjLywm","sePoCNa","AKnOvw8","zgL6yxG","zw5jywu","yvnsEvi","y3Hzzw4","wKD5Bvy","ChvsAgO","B3jLtMfTzxm","BxHwre0","EfLJEvm","sMr1v08","AenSB3nLrxy","BgvY","Efrurw52","y1DjB0i","uu9PBee","EgLpAeW","sxjZwvm","BgLfD2u","ueDeu3q","txjdzvi","sfn6CMm","BwzyDwu","AxLMuhC","tLL4t04","qLvtz3O","yw1LoIa","z3LdDuK","x2nSzwfYugK","vu1gBuu","x3bPBMDqB24","EgvdyuO","y29UC3rYDwm","EsbJBg9Zzwq","uMvcyKe","sg91Eve","AMP6qMe","Cgf5Bg9Hzfq","zgvJB2rLzey","DffPEu8","y3jLyxrLuMu","x29WDgLVBNm","rvPprgG","zvvYBa","ihrYEsbYzwm","Eu5iyMm","x2LZsw5PDa","Cu9vCem","x3DHAxq","BMvY","B2zMC2v0","qvjuzxC","tufyx1jfvfi","v3zJyLa","B2ncy3i","BwHXq0e","weTrEfq","Cg9PBNrdB24","y05UueW","D25PuK8","C2v0u3rVCMe","C2fNzq","x1fVu01HBMe","C3rYAw5N","EeTtsfm","B0Tivhy","vMndzhq","t1bftL9fuLi","v3PNDKW","zxHWB3j0CW","r2jvtM8","BMfIBNG","y3r4","vhLKrhK","z2v0u3rVCMe","vxjPqvC","DKHjwLO","De1ct08","sNbpuuW","AuXAqvi","B3jRzxjhBg8","oxW3Fdf8nhW","CNPSB0O","Bwv0Ag9K","z3fMANe","tgHrwg8","x2HHBMrSzu8","AKD2r2i","CMvTB3zLq2G","u0zgwge","shPVwMK","zMzMzG","CMvQzwn0","B25LCNjVCG","shDnvvu","DMfSDwvZ","x2rPC3bHDgm","CNzHBfzHBhu","ywnRx2LK","y29UDgv4Da","tgjsr20","ww1Rvvm","x2LUAxrhBg8","Cg1Jt1y","r0D6sxO","BNPVuNe","q3Dwr24","DM9JtMO","s0zgz3q","vurXsfe","A3rhz0e","D2Dyv1K","BNrbBMrvCgq","rMfND2m","ruz6Euy","BNjjzgK","zw5HyMXLqxu","zw5KCg9PBNq","A09et2m","sfvvDhO","y3LjCeK","tgHAyLC","A2v0ignVBNm","tw1qDKu","v2vIu29JA2u","BgTbtLu","A1r5D2e","DhLIquK","BNrsueu","DMfS","AwXK","yxKSihrYEsa","y3vYC29Yx2y","wKP4C3K","BMvLzf9Hy2S","D25lswS","BMnLq2XVC2u","CvrfAvK","wgH4seu","C29Tzq","q0Phyui","wLHjuuO","BMvJDa","ufLjBM8","verrDLa","ufvey0C","sK1Krey","tgfUugm","Aw5KzxHpzG","AK1sELi","yuLNtgi","D2vI","AKrgA3C","CgXLyxnLiha","zgrcBhO","BvzJr0q","s3bWrfu","uKrKveq","DKrtDNy","x2rLC3rYB3K","DwLKuLu","u2TPCcbWyxm","DfrTAw4","BgXIy2O","CM92AwrLigi","C1PSCeO","igfYCMf5yNu","uMHisNy","C0PIq3q","AKHdr3K","AxnAwMy","rNLdDwO","D29kCe8","D1rREuq","EhDxExO","yxrHlcbKyxq","CwXlsey","x3fVC0rc","y29UBMvJDfm","sfvPCLC","Dxrjza","vgDKuwy","ywWGy3vYC28","C2vUza","Eu9wB1q","DMLJzuLeig8","rMTMDLi","vufXzNm","Ae1LC3nHz2u","uhzsvKG","AxnFywnR","B25ozxr3B3i","CwDcvei","CLjKCMC","y09Wzw4","CM92AwrLihC","rezjBeW","ELbNwvm","nxWXFdj8nNW","x2LZtM9Kzq","BLfRsNm","zeD0sw0","B25Uzwn0Aw4","uxvLDwu","BfvQq08","ywrKt25L","z1DQrwO","rw14DM4","rKLgvKW","C1nZwMO","DNLpuNm","t3PVz3K","BezSDxnO","B0XWAMG","r1jyDgi","CgDUswq","AgTAyMm","pxv0zI04","BeHHBMrSzxi","q2TlsLO","vMrMqLe","Ec1TC2CTCw8","ELrvEgC","Aw50zwDLCIa","zKzytwy","uxvQuNe","u1HKDgC","tef0C3C","shbRCKW","CMvJB25Uzwm","DuvRvLO","zLv2yLG","AxnrB1nnzxm","AxHLCxG","r051BNy","zgvIDwC","CuDcBwG","B2f5uwS","txDAy2C","igzHAwWSig0","wevlsNa","BxfUA3C","zwXhAM0","r0TxAKO","tgvfrNG","y3vZDg9Tshq","AfzUChK","Dwj0qwS","ww5YAuq","A1fZBLa","s3PkBwq","B2fK","q0Xpu0LorW","yxrLq291BNq","zMLUza","CNjVCK1LC3m","Ec1TC2CTy3u","zePJC1C","CMvTB3zLrxy","z2j1z2K","zM5YDum","BfncBu0","qxvzrLu","vLHWDKy","wwT5Duq","BM1UCeq","uhntvMe","ywrKq291BNq","CwHtyu4","rvvKA3O","DgXsDwK","zNzHs1a","sLzzzgC","D2Dyy1y","vxzetfO","ywXSB2nvBNm","AwLNwKe","revRvKC","AgPoy1q","x2LZqNjVD3m","zvPytxC","y3vYC29Y","zNjVBujPDhm","ywr2yw5Jzq","BLHQsxu","y29Uy2f0","DfbYEMe","rvzizeK","DMrQuhq","CgfYC2u","vgfN","BLjqDMy","Cw9Zx18","CIb0DhDjra","B25TzxnZywC","mhWXmhW0Fdu","B25tDgfYDfi","C3vIC3rYAw4","ChPKv1m","yLvouge","wfzrBuW","uxrPCve","C25SCuK","sfv1rvG","vvDIzfu","CYbPBNn0yw4","z1rPBwvVDxq","v29Wu0S","rhzKALu","vuHuD08","B2zM","z09Qwe0","s1bjrMm","B1H2z3y","Eu9Mr0y","vMnevhC","B3nLrxzLBNq","rhLfquu","C2vUDa","zMLvCvK","B2jQzwn0u3q","ihrPBwvZ","x29UrxjYB3i","x2DLBMvYyxq","y0LdsvK","Du1jDuG","AuLPseG","x2n1CNnVCK0","EujPsem","EhHgq08","vw9HteK","AxnrB1nby2S","CMvZDwX0","C0rqwhe","thjKtMG","Dw5jENK","zNjVBuj5Dgu","y2HnyxHuCMK","wgnbDMy","EhjIvNy","weHVBwC","rNHOrfi","zgLZywjSzue","yMfSu2nVCgu","q3nvrhG","zNjVBNrPzxi","y2XLyxjtDg8","wufmEue","z2v0q3vYCMu","uuLHrgO","wuXNBhO","A0Lrzha","txzmBxa","q09oveLovuu","wxDLAw8","tez3CMy","zK1YBLy","uKnyse8","Cgu6ia","AM1rCe0","zLbUsgW","DxbKyxrLq3u","rwrXuxC","Cw9Z","ENPhDuO","C2v0zgi","se9iD1u","zw5XDwv1zq","BMv3vMvYC2K","Affju2y","vgPkuMu","x2fKzfDZtgK","zMzmAw5L","zw50tgLZDgu","jMPZy2fSBgi","BLjRsvi","CMvHC29U","EK96rMK","x2LUAxrqCM8","y2XLyxi","rNjVBNrPzxi","BgLUzq","CM9YrxzLBNq","y2jdC0W","wenKsw4","sgHJwLq","q01wr2O","zeTiwxi","zxjFCw9Z","AxnbCNjHEq","BwvKAwf0zwW","y3vYC29Yx24","v3Hxu0i","s21dvNC","C3rHy2y","vuLbwNu","ywnRtxnNswq","Ahr0Ca","C2vYDMLJzq","sgr2quy","zvrtwva","DcbSAw1PDa","seriweW","ugLQuKO","zK5xyNm","q0P2y2i","zfDVCMTLCKC","BwfW","rNzksvq","y3vYCMvUDeK","zxjFCw9Zx2e","zwHerKi","ihzHBgLKigq","mZq1nJaYEKzxBNvH","D2T0sxm","Bg9NsurozxC","z0XHCwy","zNjVBu51Bwi","EhDWAxu","zLfNvhC","nhWWFdv8mxW","D1zlC3q","mxWYFdb8nhW","y3zJCwG","sM1LCxO","B3Dgrhy","wxffrM4","ign1CNnVCIa","y1bWDw8","AevYCM9Yrxy","sKjjyM8","t3H2zKS","DgTKtvK","wvjNz0S","BMCGB3iGyw4","B1fMrxi","v2LUzg93","qu9hCM4","qKT1D3y","z3fOt1e","ChbkuuW","tKrxtwi","D01Vuuu","rurrAe8","sM9qtee","A1jtA1y","B3v0sw50zxi","wenWEuO","uLHTs2u","BgvUz3rO","ywX3yxLZ","zcWGDw5RBM8","BM9Uzv9UB24","C0z6q3a","lcbxzwjtB2m","zv90Aw1LB3u","ywnRpwzYB24","B25szwnLAxy","v01UAeK","B2XRCeC","Ef9MCM9UDgK","uNzSDLC","r25rtwe","CgfNzxnOB3C","tgnVwuO","vMD2wLO","zxjFywnRx20","yvbiuNi","x2nVBM5Ly3q","sLPAChq","rvLvqKK","BKXPBMu","CxvRCwe","CLzHBhvLCW","C0XPC3rLBMu","x2rYB3bhBg8","D3jPDgu","C2v0sxrLBq","Dw50","EgvyC1y","CufYu2e","vNPfD3O","y1rPrMG","zNjUvgO","DuzUz2m","qNzkANO","CvPzt2W","D3LdDNm","yKPqCKm","ueXXrfa","q0zQqw4","yMfSrxzLBNq","ru9REfK","yMzOEum","D1jZAeG","yMHbqMe","uenhzvO","C0nVDw50zxi","BeDKrLe","DuLVteG","Cxviru8","BwLZzq","zMvY","BMnVzgLUzW","ANrYB3q","zKzYwMK","CgvYC2LZDgu","yMLUza","A0jouuW","rKn1teG","BuXIwey","y3jLyxrLtwu","wNnPugO","zMfwqwC","zNjVBunOyxi","DKTcBhq","sNferuG","u3rYyxrLz3K","mJi3ndK3oxzjAM1yyW","C2vUzf9Hy2S","B3jL","DKfuB0K","B1Ljr20","zfL4BLu","Bff0Cvm","AxnmB25N","x29UugfNzu4","y2HLy2Tszwe","B3bLBKrc","t3joANG","EuztyNe","D1zIDLG","tMz6uLy","D24GCMvHC28","CKLMqwi","yxjYyxLIDwy","zwXAvK0","ywrKrxzLBNq","zNvSqNy","AuLzz3i","tKfusvzfx0u","CgP3qMO","DgLLCKPtt04","qw1VDw50","yNvMzMvYzwq","uNnpr28","DgHHBIbSB2m","vMLKyKK","mdaWmdaWmda","wejItg4","ELPHrgm","rxjYB3jdB2q","m3W4FdeW","Cgf5Bg9Hzeu","yxHtqNe","zxf1ywXZ","txjiywK","yvbtvLa","Bg9N","sKPXuwO","DcbVzIbYyw4","s0fyvMK","CMTLCKDSB2i","ExbqA1G","CMvHzfvjBNq","uMvJB25Uzwm","zgvSzxrLrge","CgXYyva","qKnjt1i","DMfSDwu","yMH6Dg4","AM1jBNa","uwvgANu","mJy3ndu3r054Cg1j","t3Lrqwi","y2DXu0K","vhH6zue","tK5wv2S","wM90EKq","yurWseK","y2n3qLO","D3jPDgvvAw4","Aw5Lza","y2HLy2TdDxi","C0PkBwS","x29Uq2XVC2u","Bu5wrxO","ANjwt1e","DNzVuue","igXHCMDLCIa","BgLUzw5V","y2XVC2veqG","z2TmCuW","uKTSrfu","zxjFBxnNAwq","reP3rxK","B25JBg9Zzq","tvnws3q","ELPXDMS","rM1ewhm","tw10tei","ywnR","m3WYFdf8mhW","zgjfC1O","AgvHzgvYCW","wLbqv1u","yuTHtui","vwf0uxu","wfnIvwG","AgDPtNO","yu1PDwK","x3nVy2TLDa","C1HRs0i","Eg9YAMS","Dw1xwxa","x2rItMfTzq","wNfrr2C","DKHsuuu","y29UDgLUDwu","tKzxyvq","v0vMsuG","yunKAxu","r0HwAvy","Cu9qBfy","CMvZzxrdB3u","q2rguxi","Bhm6ia","Du9Nv2y","suX4ENy","vfvhsxy","C3H0vvy","tLf3BuK","zufJAW","vwfLteW","yw1L","u1PtuwS","BvfZuxy","BNvHs0i","ChjVwwW","yvfcBgq","BhL5AKS","nNWWFdn8n3W","zgvSzxrL","D3j2qxi","CMfTzq","uuLlq1i","C3vIyxjYyxK","CezXBei","BuzAvuG","CMvUDevUzha","zsbHihn0CMK","weDAt04","wuf1Ag4","z2fgCLy","s3nWy1a","vvHcwvi","v0Ltrgy","A2zMteu","B25tDg9Wsw0","x3bHDgHlzxK","BuTzrwi","uwrmvxe","s3Lszvm","y3ruAw1LB3u","DLL1Cuy","r2r4Ewe","z2v0s2v5","Bwf4twvZC2e","x2zVCM1HDeu","CuXwywu","uxDvC2u","BuL4tfa","AhHswem","CxDjEw0","u2vYDMLJzvC","AgzJswO","zfPtB2S","uNH0vMK","x3bYB3rVy28","s3HvrMW","C3rVCMu","B0jVuhG","FdL8mxW3Fdy","CNnVCKzPBgu","qNvXDuW","Bwf4uMv0CMK","DLf2Axm","B2zMBgLUzq","q1n2D0q","BfrPBwvVDxq","t3Pcwve","ihrPBwvVDxq","Du5fAem","DhDVCMTdAge","swfbEwC","Cxv2rLe","sLvPC28","zw5HyMXLuw8","rKnHEK0","z2vtEw5J","BKjYA1u","teLlDfK","zxjYtxnN","Dxv6vfe","Ec11C2uT","zfjvzMG","B3vUDa","yNvMzMvY","DhjPzxm","x19LC01Vzhu","zMzLCG","rg5ZDfy","Aw47y2HHCNm","Aw9U","yw51Ce1LC3m","yNL0zuXLBMC","yxbWBhK","CMv0CNLdB3u","yMjVze8","uhfPsey","q0Xpu0ve","yNvlzfK","qK92sNy","AgLNAa","DgLTzw91DcW","rwnxC3m","vKzWDMm","C3bSAwnL","tNHiAeW","Cwj3qK4","ofbXtMznyW","uLjpuG","De92CMy","Dg1IsxC","rxzLBNq","mxWWFdj8nhW","AfjQwvy","Cu1nDei","yNL0zu9MzNm","Aw5JBhvKzxm","tMnYB2y","r2fRuLm","Ahj4BLK","AgfUz2u","CMvKDwnL","x2HHBMrSzvi","tevwtge","u2zuDuK","q3vZDg9Trxi","CMvXDwLYzwq","Cgf5Bg9Hza","tMDzuMe","sND0EK8","B1DgCK0","BLLLwfu","A2LgseK","DeLUDgvYy2u","zNjHBwvuExa","DNbtCxC","yxf6DMO","nhWXFdj8m3W","q3H5CKu","x21PBMLoyxy","sNn6C1C","x2LUDgvYDMe","BMH6z2K","D2TnAu8","mNWWFdn8mxW","shHYwu0","ENjRD2W","sNn5D3G","rufUzwu","vNvMEwO","ywDLu2HVDW","vhDMzMm","ywDL","y29UBMvJDca","wMXnBve","t0PirKG","uuDZwuO","x2TLEvbHDgG","EfzZqLa","BhPkru4","wvjdz1C","ExbL","yxbWzw5Kq2G","ALnMtve","DgfYz2v0","ndi2ndy1mfPKyxzKAa","Dg9cExrLC0i","CMvJzxzPzwq","wMTNtee","D1r5rwC","y29SBM8","EefAsKW","Aw9Ul2PZB24","CMvZB2X2zq","uvbMA0m","z2v0sxrLBq","x2LZtwLUAvC","ugjJAfm","nNWWFdj8nxW","wfHlqMm","vw5Oyw5KBgu","CvnWr1q","r1vszfK","FdeXFdL8n3W","DLDAy2S","z29dy3K","DxbNCMfKzw4","zw5HyMXLvhi","BKrAB3u","uxHHzfm","zen4tMG","rgjHB3O","zg9Uzq","yxnZAwDU","v0Pcqu4","DLHZvLm","tw9KDwXL","DfLmA1C","x2LUAxq","v1netfK","ugfMAg0","zw5fDMvUDa","s2XMwe0","Dg9oDw1Izxi","DwjuDNy","sxD3u08","AxjtwfO","tMzcuLK","t2rnyLa","zfvgD2q","BNrfBMrWB2K","D29nueC","y2fSBa","CNnVCL9Uyw0","AgfZ","id4G","lcbTyxGGCMu","zNvUy3rPB24","z0XrCNK","BMDuAw1LCG","rMP1yw8","rM9XBeW","vKTxt2y","Exb6rMu","tuXPqKO","C3rLBMvYCW","v3znwve","uxHNwNi","x2LZv29YA2u","z0PqBgq","DhjHBNnHy3q","D3HYzxG","rLfYtMi","zNblzvC","senorgK","DwzJEKS","u1fJrgu","q291BNq","yw5ZzM9YBvq","zv9ZDwnJzxm","x3jLBw92zvC","x2HHBMrSzva","CMvWBgfJzq","DgLUzYbZzxi","C3vRvNm","uMLTvxi","zw1PDa","x3DZsw5ZDge","vhrUDwq","wM9wv2W","zxjYtM8","DKjftg4","DM96t2i","sLH4vMm","A3rssKy","x2rLyNvN","vKv4zK4","te5jEhu","zgfUB0S","zLDJEgS","z0znwfe","v2TfAKS","v1vTuhe","zfDkAuy","y29TCgXLDgu","DMvUDa","DfzHtuq","BNz2sNy","sw5iDxq","reTnwMC","vevqy2y","CMPrzxu","D3nZoI8V","vuzLzgi","uNLnAMy","y2HnyxHdB3u","Eg1PwKq","z1fmsMi","ChjVy2vZCW","Dg9cExrLC0W","x2n1CNnVCKy","x3nLCuLK","ruHjufe","t1b4Cwe","vgXzr3K","C3vJy2vZCW","vNfwv2i","y3nJrLu","uhr2Bu0","r0jxqMO","B25fCNjVCG","tKDFrvjst1i","x0rctMfTzq","rLDyvNe","yKLoCNK","t0X1re4","sfvyDgi","z2jiwgO","y1vVrfu","DKf1Cg4","CfLuBui","y291BNq","DhjPzxmGCMu","rxn4CxG","CMvJzwL2zwq","Dhj1y3rVCIa","A3PYzxa","q3vZDg9Tq2W","zxmGCMvHy2G","uhjPBwfYEuS","uMriC0y","AhbPrgK","C0Xf","t1rNDem","uunvBwC","tejiy3K","y29UBMvJDgK","reHRCLa","Aw9Areu","EuDzu2W","ignVzgu6ia","ufn3C1u","u01hyLK","mhWZFdf8mNW","sMrTu1q","uNfAywO","BwfUDwfSihi","AKzwBxu","Dgv4DfbHEwW","zhPAsgG","m3WYFdy","A0PZDhe","BM1Lvhm","AxnszwfKEq","s1LXtfq","B2T3vw0","DMnJC2O","C1Lrr3q","y3vYC29YlNm","yw1jBM0","AxjLza","ruDZyxm","DgDjwKi","z2vjBMzVu3K","swn0ExC","C2v0q3vYC28","Eu5yv1y","ywXPzcb1CMW","sM1qq20","zcWG","qwjVCNrfCNi","BNrLCG","sevNBxG","zw5JB2rPBMC","AMfkEvK","rg9hsg0","y3jLyxrLrwW","swjkENK","CMfUzg9T","ruzIDhu","D2viBwW","vwznDuW","x25HDMLNyxq","x29UvgLTzw8","B3Pfrvi","vhz4C1C","rMHAq0O","reDrtM8","quDyALm","DNvpq1q","q2HNDw8","Ahz1zuy","vK9Ts00","B3jpBMXPBMu","vgHlvM0","zwnVBM5Ly3q","wxPfC0W","zM9Yy2u","DgT5Beq","ChjVDg90Exa","ywnRx2nVzgu","CgLgvhK","z2riBhq","CgLUz09Uy2u","tuDMu0O","CgfNzwHPzgu","Bwvrsxu","rLDt","Dwrfzhu","D3L5Eum","y2XVC2u","vLbouu4","rKf2Buy","x3nLBMrby2S","B25VCgvU","zKHyBhy","ChbL","rfznrNK","AMvJDfn0B3i","yxv0B21HDgK","vuzRCKq","tuTMA3C","twXpt0S","Be9QC2K","uufXDxu","mtvtyNrWzeW","EgjpBgS","Evjtv3u","BxnSsNi","AxnYvgy","y2HHCKnVzgu","Dw5ZAwDUzwq","lcbOB3n0BMe","vvL0uMW","ugL2tMO","wKTks1u","DhbizwfKzxi","uLPntvG","AMXQELa","wu5HwNe","yMrPuw0","BuDTzNu","tuvtu0fhrv8","uNrWu0O","y29UBMvJDa","zvDpvfu","y09ewNq","tg9Nsuq","z2v0qwXS","x2nSzwfYvgK","v0zPyvm","CuvIy0e","DgTpthG","z2v0q3vYC28","AgXJEe4","uNfozKq","AfLxBK4","DLD2yxy","ChjVDg9JB2W","sfzxCfC","rM9ZwNe","C2DPza","l3DZl3yY","C3bSAxq","zgvS","x2n1CNnVCK4","zvLju2m","x3vYBa","ywnOzwq","DNfwuwS","AfrKwgm","DeLK","sLnptLa","ugDmz3O","C2XPy2u","tgLZDgvUzxi","C2v0y3vYC28","D2rkCw8","twLZC2LUzYa","rKrXt0q","DhDyBLG","AxnAzxjV","D2LSBfjLy28","zcbLCNjVCI4","zw50","AgPUwKK","nZCYCNDRBurx","BMCGzMfPBgu","ugjJs0K","qMnet0u","AwXLx25HBwu","rKzNAe4","zfPPz3m","sfr2te4","v1zKrwW","ywnRDxbfBMq","qLHRAKe","rhv1qwi","u1foCLu","BIWGAg9ZDg4","x2jPBMfYEvq","nhWYFdf8nq","ChfLywG","AM9PBG","Bg93","x2rPC2nVBM4","C3nHz2vfDMu","s3bqEgK","y3vYDMfSDwu","DwLLC2W","qw1RCK4","x2nYzwf0zvm","Bg9IywXty28","AuX5twm","r2TOy2m","wxnTu2e","Cg9W","mtb8mhW0Fdm","zM96wuy","A2P3C0q","q29UzMLN","BMrLEa","D2TUD0O","B3nLza","rKLmrv9ot1q","v05tuge","z1HrwvK","rKDhB20","nhWXFdb8m3W","x3bYzwzPEa","rLzREeq","x3bPBMC","uunXAhe","CM92AwrLige","yw1Lu3bHy2u","x2LZtwLUAvq","EurKu2G","zxH0ugf5Bg8","twT2Dvm","B1nPCw8","s3nAt0e","sLflCge","Dg9Y","y2nQCMq","vw5PBxbSzw0","qMzkufa","BK1dEgS","zLHLAuC","tMfTzq","BLjHzLi","uKzywgq","r1LRvNa","B25SAw5L","BergEMS","vMLHtvu","AwDHDg9Yt24","Ae9Wzw5fDMu","svHozvK","BxPez3q","ywzL","txLjrLi","x3jLy29UBMu","zgvMAw5Luhi","x0vysvnu","DxrVuMvJB24","DMvYC2LVBG","Defvs3i","vNHYwxm","BgLZDgvUtMu","zM9YrwfJAa","tMjrDva","BgffCMe","CMLLC0nVDw4","Aw5N","Axnby2TdBgu","qurqrM0","vM9Jr2y","wvfit3i","tMjIswe","C0PrvNm","shPptM0","DfLNrgi","y29Kzq","Dhr3Awq","EM9tELm","x29UtwvZC2e","ywrK","x21LC3nHz2u","x3jLywr5q2W","CgjICdi","u0Tfu3O","sLLzAgG","zKXnAeW","ugLnAMG","z2u6ia","uK1Wruy","shDJwe4","CgLUz1rPBwu","Bg9Nsurhzw4","vgvLBNO","y3jLyxrLrxi","yw5Hz2vY","AMHXqMS"];return Zn=function(){return n},Zn()}function Vu(n){let e=E,s={WopSK:function(c){return c()},UfDRF:function(c){return c()},PiMjh:e(1320)+"or",PqiHF:e(1234),FGGom:e(321),Fjuao:"abort"};if(er.has(n))return;let o=new Promise((c,d)=>{let u=e,l={tlRui:s.PqiHF,bbodO:s[u(1477)],stacf:s.Fjuao},p=()=>{let y=u;n[y(605)+"entListe"+y(396)](l[y(617)],m),n[y(605)+"entListe"+y(396)](l[y(1065)],_),n["removeEventListe"+y(396)](l[y(741)],_)},m=()=>{s[u(654)](c),s.UfDRF(p)},_=()=>{let y=u;d(n[y(321)]||new DOMException("AbortError",s[y(1543)])),p()};n.addEventListener(s[u(1066)],m),n[u(884)+"Listener"](s[u(1477)],_),n[u(884)+"Listener"](s[u(1190)],_)});er[e(1651)](n,o)}function Yu(n){nr={qlKHF:function(o,c){return o(c)}}[E(523)](n,nr)}function Xu(n){let e=E,s={gyOHX:function(o,c){return o(c)},DFIlL:function(o,c){return o(c)},jtkMC:function(o,c){return o+c},nirSY:function(o,c){return o!==c},GURdY:function(o,c){return o&c},YqEFn:function(o,c){return o|c},KpPxi:function(o,c){return o<<c},ezAAV:function(o,c){return o|c},RDdTD:function(o,c){return o&c},yuPOu:function(o,c){return o<<c},KxUFl:function(o,c){return o<c},TydDy:function(o,c){return o>=c},nkdmi:function(o,c){return o<=c},IFfkS:function(o,c){return o(c)},Vufyj:function(o,c){return o(c)},ioZDE:function(o,c){return o(c)},ypPkX:function(o,c){return o===c},XXtyH:function(o,c){return o in c},njHUs:e(667)+e(354),wmCKb:function(o,c){return o===c},QGfqX:e(998),FoqlL:function(o){return o()},UfSzA:function(o,c){return o===c}};if(s[e(910)](n,IDBDatabase.prototype[e(1200)+e(1060)])&&!s[e(1580)](s.njHUs,IDBTransaction[e(1349)+"e"]))if(s.wmCKb(s[e(297)],e(505)))_0x56a659[e(905)](_0x44c05f);else return function(o,...c){let d=e,u=n[d(1182)](on(this),o,...c);return ci[d(1651)](u,o[d(1686)]?o[d(1686)]():[o]),Ue(u)};if(s[e(1191)](Ju)[e(1086)](n)){if(s[e(1589)](e(859),e(859)))return function(...o){let c=e;return n.apply(s[c(1599)](on,this),o),s[c(543)](Ue,xi[c(1657)](this))};_0x52acf1=_0x30981b[_0x2ef7be+_0x39e0ac+1],_0x3b1349=_0x56fbbe[s.jtkMC(_0x280555+_0x11770d,2)],s.nirSY(s[e(1152)](s[e(773)](_0x2fe8ba,s[e(1457)](_0x8c4b74,8)),49344),32896)?_0xd0e4a1+=_0x15fd89:(_0x2f32c6=s[e(1719)](s[e(1457)](s[e(504)](15,_0x4af702),12),s.yuPOu(63&_0x4025e1,6))|s.RDdTD(63,_0x702ac4),s[e(1026)](_0x56218e,2048)||s[e(420)](_0x1bfeb0,55296)&&s.nkdmi(_0x358851,57343)?_0x55524c+=_0x55a89d:(_0x588a02+=s[e(244)](_0x1809e2,_0x2bc3fe),_0x311bfc+=2))}return function(...o){let c=e;return s[c(1119)](Ue,n[c(1063)](s[c(1288)](on,this),o))}}function Qu(n){let e=E,s={qZYOl:function(o,c){return o===c},ysEwa:e(1187),PnOLX:function(o,c){return o instanceof c},JWnzi:function(o,c){return o(c)},fmmTR:function(o,c,d){return o(c,d)},wgXWY:function(o){return o()}};return s[e(833)](typeof n,s[e(293)])?Xu(n):(s[e(336)](n,IDBTransaction)&&s[e(219)](Vu,n),s.fmmTR($o,n,s[e(458)](Wu))?new Proxy(n,nr):n)}function k(n,e){n=n-196;let s=Zn(),o=s[n];if(k.bkGpaF===void 0){var c=function(p){let m="abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789+/=",_="",y="";for(let I=0,L,T,P=0;T=p.charAt(P++);~T&&(L=I%4?L*64+T:T,I++%4)?_+=String.fromCharCode(255&L>>(-2*I&6)):0)T=m.indexOf(T);for(let I=0,L=_.length;I<L;I++)y+="%"+("00"+_.charCodeAt(I).toString(16)).slice(-2);return decodeURIComponent(y)};k.PTJJTN=c,k.IkNHQH={},k.bkGpaF=!0}let d=s[0],u=n+d,l=k.IkNHQH[u];return l?o=l:(o=k.PTJJTN(o),k.IkNHQH[u]=o),o}function Ue(n){let e=E,s={iUERx:function(c,d){return c instanceof d},BNSAJ:function(c,d){return c(d)},icBGr:function(c,d){return c(d)},HDHXL:function(c,d){return c!==d}};if(s.iUERx(n,IDBRequest))return s.BNSAJ($u,n);if(Xn.has(n))return Xn[e(1657)](n);let o=s.icBGr(Qu,n);return s[e(749)](o,n)&&(Xn.set(n,o),tr[e(1651)](o,n)),o}var $o,Ho,jo,xi,er,ci,Xn,tr,nr,on,Ko=Jo({"node_modules/idb/build/wrap-idb-value.js"(){let n=E,e={JdmST:function(s,o){return s instanceof o},AiQho:function(s,o){return s===o},GRXtb:n(667)+n(354),iShhG:n(1027),OxvfK:function(s,o){return s(o)},gXLnT:function(s,o,c){return s(o,c)},MvLmp:"uWFrq",IbJzy:function(s){return s()},NuSOe:n(1234),tgIZB:n(321),gXPRc:"abort",FWXVq:n(569),HwMUU:"zYYXC",sSsZj:function(s,o){return s===o},HmFDQ:n(1162),LanPc:function(s,o){return s===o},PQvzs:function(s,o){return s===o},dKHYr:n(462),JmPCm:n(934),tMBOO:function(s,o){return s in o}};$o=(s,o)=>o[n(486)](c=>s instanceof c),xi=new WeakMap,er=new WeakMap,ci=new WeakMap,Xn=new WeakMap,tr=new WeakMap,nr={get(s,o,c){let d=n;if(e.JdmST(s,IDBTransaction)){if(e.AiQho(o,d(1162)))return er[d(1657)](s);if(o===e[d(561)])return s.objectStoreNames||ci.get(s);if(o===e[d(1775)])return c[d(667)+d(354)][1]?void 0:c[d(667)+d(867)](c[d(667)+"oreNames"][0])}return e[d(778)](Ue,s[o])},set(s,o,c){let d=n;if(e.AiQho(e[d(699)],"uWFrq"))return s[o]=c,!0;{let u=e.gXLnT(_0x18a8a8,_0x4f1f75,_0x3a07d5[d(1572)]),l=_0xc67332[d(1582)],p=_0x272d57[d(1582)];for(let m=0,_=_0x304057[d(1572)];m<_;m++)l[m+u]=p[m]}},has(s,o){let c=n,d={CXDyn:c(1234),LxWQx:e.tgIZB,RnTjU:e.gXPRc,qGBmh:function(u,l){return e[c(778)](u,l)},qhSaN:"AbortError",Oknnz:function(u){return e.IbJzy(u)}};if(e[c(1263)]===e[c(441)])this[c(289)]&&this[c(289)][c(530)](_0x196512),this._debug("send_ack",_0x5e9341);else{if(e[c(1294)](s,IDBTransaction)&&(e[c(556)](o,e.HmFDQ)||e[c(494)](o,c(1027))))if(e[c(247)](e[c(734)],e[c(1318)])){let u={plNxS:function(_){let y=c;return zdBpYN[y(1327)](_)},HUUtz:function(_){return _()}},l=()=>{let _=c;_0x2aadef["removeEv"+_(720)+_(396)](MIlDIU.CXDyn,p),_0x4237a7[_(605)+_(720)+_(396)](MIlDIU[_(198)],m),_0x358a31[_(605)+_(720)+_(396)](MIlDIU.RnTjU,m)},p=()=>{let _=c;u.plNxS(_0x23b668),u[_(466)](l)},m=()=>{let _=c;MIlDIU[_(583)](_0x3aee9e,_0x34e56b.error||new _0x2894de(MIlDIU.qhSaN,MIlDIU[_(615)])),MIlDIU.Oknnz(l)};_0x228537[c(884)+c(1425)](zdBpYN.NuSOe,p),_0x1185af[c(884)+c(1425)](zdBpYN[c(1312)],m),_0x3ce8f1["addEvent"+c(1425)](zdBpYN.gXPRc,m)}else return!0;return e[c(424)](o,s)}}},on=s=>tr[n(1657)](s)}}),Vo={};Gu(Vo,{deleteDB:()=>ef,openDB:()=>Zu,unwrap:()=>on,wrap:()=>Ue});function Zu(n,e,{blocked:s,upgrade:o,blocking:c,terminated:d}={}){let u=E,l={yNHbc:"online",vuOCT:"offline",CtVrc:u(1355),AuYFU:u(810),GKWjJ:function(_,y){return _!==y},ddBlz:"MieLm",sxtUV:u(544),zpWJt:function(_,y){return _(y)},YmkUS:u(1320)+"or",HUXtb:function(_,y){return _===y},hVZfh:u(1501),OJHFH:u(1360),fXFtq:"versionc"+u(1090)},p=indexedDB[u(1655)](n,e),m=Ue(p);return o&&p[u(884)+u(1425)](u(1156)+u(1715),_=>{let y=u;l[y(590)](l[y(501)],l[y(977)])?o(l.zpWJt(Ue,p[y(679)]),_[y(1622)+"on"],_[y(715)+"on"],Ue(p[y(1200)+y(1060)])):(this[y(626)+"er"]&&_0x15335b[y(884)+y(1425)](l[y(392)],this[y(433)+"nLine"]),this._isBrowser&&_0x3f8571["addEvent"+y(1425)](l[y(1339)],this[y(433)+y(719)]),this[y(626)+"er"]&&_0x34cda9[y(884)+y(1425)](l.CtVrc,this[y(1211)+y(1722)]),this._isBrowser&&_0x552bc7[y(884)+y(1425)](l[y(609)],this[y(1211)+"ageShow"]))}),s&&p[u(884)+u(1425)]("blocked",()=>s()),m.then(_=>{let y=u;l[y(1266)]("GYkVp",l.hVZfh)?(d&&_[y(884)+y(1425)](l[y(1125)],()=>d()),c&&_[y(884)+y(1425)](l.fXFtq,()=>c())):(mhfRva[y(1710)](_0x5c60df,_0x2bc0f9[y(321)]||new _0x34ebd0(mhfRva[y(448)],y(1320)+"or")),_0x390b6a())}).catch(()=>{}),m}function ef(n,{blocked:e}={}){let s=E,o={yQbOy:s(1714),JSFEe:function(d,u){return d(u)}},c=indexedDB[s(913)+"tabase"](n);return e&&c[s(884)+s(1425)](o.yQbOy,()=>e()),o[s(331)](Ue,c)[s(317)](()=>{})}function Go(n,e){let s=E,o={hqmLK:function(p,m){return p instanceof m},JszsW:function(p,m){return p in m},tAUKr:function(p,m){return p===m},EVHdI:"string",jFVmu:function(p,m){return p!==m},VRgro:function(p,m){return p in m}};if(!(o.hqmLK(n,IDBDatabase)&&!o[s(1110)](e,n)&&o[s(1516)](typeof e,o[s(634)])))return;if(Qn[s(1657)](e))return Qn.get(e);let c=e.replace(/FromIndex$/,""),d=o[s(1297)](e,c),u=Xo[s(1086)](c);if(!o[s(1606)](c,(d?IDBIndex:IDBObjectStore).prototype)||!(u||Yo[s(1086)](c)))return;let l=async function(p,...m){let _=s,y=this[_(1200)+_(1060)](p,u?"readwrite":"readonly"),I=y.store;return d&&(I=I.index(m.shift())),(await Promise.all([I[c](...m),u&&y.done]))[0]};return Qn[s(1651)](e,l),l}var Yo,Xo,Qn,tf=Jo({"node_modules/idb/build/index.js"(){let n=E,e={sZlpJ:n(1681)+n(1677),aMiui:function(c,d){return c(d)},DvdjU:function(c){return c()},wdJqo:"get",pbbyS:"getAll",Pqeqp:"getAllKeys",AXDdE:n(1271),ubTvv:n(1536),xrbVv:n(989),BgpYU:"clear"},s=e[n(512)][n(1413)]("|"),o=0;for(;;){switch(s[o++]){case"0":e[n(957)](Yu,c=>({...c,get:(d,u,l)=>Go(d,u)||c[n(1657)](d,u,l),has:(d,u)=>!!Go(d,u)||c[n(1184)](d,u)}));continue;case"1":Qn=new Map;continue;case"2":e[n(655)](Ko);continue;case"3":Yo=[e[n(1427)],"getKey",e.pbbyS,e.Pqeqp,e[n(304)]];continue;case"4":Xo=[n(1680),e[n(1174)],e[n(686)],e.BgpYU];continue;case"5":e[n(655)](Ko);continue}break}}}),nf={idb:function(n){let e=E,s={MrHai:function(o,c){return o(c)},PSwsU:function(o,c){return o!==c},BKuwv:e(1496),XYcbd:"TjdzW"};n[e(416)]=Promise[e(1143)]().then(()=>(tf(),Vo))[e(317)](function(o){let c=e,d={mzDgt:function(u,l){return s[k(903)](u,l)}};return s[c(1291)](s[c(785)],s[c(239)])?o:(_0x289c3d[c(1063)](BgStRA[c(1508)](_0x240330,this),_0x5b9d4b),_0x53feda(_0x299971[c(1657)](this)))})}},Wo={};function Fe(n){let e=E,s={EAnee:e(1082)+"3",tjwNK:function(l,p){return l!==p}},o=s[e(1118)][e(1413)]("|"),c=0;for(;;){switch(o[c++]){case"0":if(s.tjwNK(void 0,d))return d[e(416)];continue;case"1":var d=Wo[n];continue;case"2":var u=Wo[n]={exports:{}};continue;case"3":return u[e(416)];case"4":nf[n](u,u[e(416)],Fe);continue}break}}Fe.d=(n,e)=>{let s=k;for(var o in e)Fe.o(e,o)&&!Fe.o(n,o)&&Object[s(1512)+s(1778)](n,o,{enumerable:!0,get:e[o]})},(()=>{let n=E;Fe.o=(e,s)=>Object[n(1349)+"e"].hasOwnProperty[n(1182)](e,s)})(),(()=>{let n=E,e={UFedb:function(s,o){return s!=o},FCuLH:n(1631)+"d",olkpG:n(1166)};Fe.r=s=>{let o=n;e[o(1243)](e[o(856)],typeof Symbol)&&Symbol[o(1605)+"Tag"]&&Object[o(1512)+o(1778)](s,Symbol[o(1605)+o(637)],{value:e[o(806)]}),Object[o(1512)+o(1778)](s,"__esModule",{value:!0})}})();var te={};(()=>{let n=E,e={VFpvc:function(i,t){return i+t},JduWO:function(i,t){return i+t},ymJZn:function(i,t){return i+t},nmnpD:function(i,t){return i*t},rRVsx:function(i,t){return i!==t},rzloJ:"lsobL",ZPPWU:function(i,t){return i+t},hTdXc:function(i,t){return i(t)},rufGw:function(i,t,r){return i(t,r)},OLuDN:function(i,t,r){return i(t,r)},cJSVZ:"complete",VXpvF:n(197),bSNKF:n(264),TEPcf:n(237),YJNZl:n(438),dRUfh:function(i,t){return i|t},dUFwd:function(i,t){return i|t},cODZt:function(i,t){return i<<t},LIKtY:function(i,t){return i<<t},KzJmd:function(i,t){return i<<t},ZXIQJ:function(i,t){return i+t},cWIoB:function(i,t){return i+t},iyfPw:function(i,t){return i|t},sJQVs:function(i,t){return i|t},goCcy:function(i,t){return i+t},UfMuL:function(i,t){return i+t},DHkrP:n(852),cbCsL:n(895)+n(895)+n(895)+"00000000",isZZf:function(i){return i()},JXxVc:function(i,t){return i>t},hYsKK:function(i,t){return i<t},qukqa:n(554),mYJtb:function(i,t){return i!==t},evZjp:function(i,t){return i-t},WxWSB:function(i,t){return i<t},QtbMX:function(i,t){return i-t},uIoLH:function(i,t){return i===t},mFZUH:function(i,t){return i<t},ubtAk:function(i,t,r){return i(t,r)},vvoQA:function(i,t){return i!==t},LLtAc:function(i,t,r){return i(t,r)},pqeah:function(i,t,r){return i(t,r)},HwcXN:function(i,t,r){return i(t,r)},kzrep:function(i,t){return i&t},TgdQf:function(i,t){return i===t},plraP:n(1428)+n(1096)+n(1578)+"value",SrTQD:function(i,t,r){return i(t,r)},TJxHX:function(i,t){return i(t)},FxhDR:n(1502),elGjm:n(1034),nRkIR:n(1355),fulBv:n(810),wVKst:"ping_onc"+n(1209)+"s",dYxnU:n(1255),fNWbs:function(i,t,r,a){return i(t,r,a)},sukVs:n(321),IhUIJ:function(i,t,r){return i(t,r)},yOVoT:function(i,t){return i!==t},aDpHI:function(i,t,r){return i(t,r)},oayQk:function(i,t,r){return i(t,r)},ONXxT:function(i,t){return i!==t},buKdY:n(491),YALyA:function(i,t,r){return i(t,r)},GWfFB:function(i,t){return i!==t},CTYEh:function(i,t,r){return i(t,r)},xpfen:function(i,t){return i!==t},SXhvl:function(i,t,r){return i(t,r)},iigZA:function(i,t){return i===t},iZtQg:n(716),gQLJb:function(i,t,r){return i(t,r)},LhQXo:function(i,t){return i!==t},qqiAR:n(685),gbHXj:function(i,t,r){return i(t,r)},vAupn:function(i,t,r){return i(t,r)},RZMMX:function(i,t){return i!==t},lGdFQ:function(i,t,r){return i(t,r)},gLaqf:function(i,t,r){return i(t,r)},WjLSS:function(i,t,r){return i(t,r)},yFSbq:function(i,t){return i(t)},IQtpa:function(i,t){return i(t)},mxQlT:function(i,t){return i(t)},YtCcr:function(i,t){return i(t)},UoaLI:function(i,t){return i(t)},kODOc:function(i,t){return i(t)},cUoDU:function(i,t,r){return i(t,r)},uiesl:function(i,t){return i===t},JJyen:"Missing "+n(1096)+n(1578)+n(1755),KAXVi:n(1428)+n(1096)+n(1578)+"LogID",QIaDj:n(1428)+n(1096)+n(1578)+"service",UmCHc:n(1428)+n(1096)+n(1578)+n(430),SFFXa:function(i,t){return i(t)},sDPXq:n(519),qwIym:function(i,t,r){return i(t,r)},TElwW:function(i,t){return i+t},LcoYJ:n(1494)+"ented ty"+n(705),cNnPL:function(i,t){return i>=t},nuaKB:n(508)+"t limit",YyxnS:function(i){return i()},kIQdp:function(i){return i()},SfTuI:function(i,t){return i!==t},axSBq:n(1256),yGYSl:function(i,t){return i>=t},WSDLY:n(389),HxrYM:"Read pas"+n(748),mxVDM:function(i,t,r){return i(t,r)},wMoQE:function(i,t){return i||t},Ttnud:function(i,t){return i<t},QyudO:function(i,t){return i+t},QtiqQ:function(i,t){return i===t},lQtqS:function(i,t){return i>=t},lBDHw:function(i,t){return i+t},aqzvj:function(i,t){return i+t},PijRJ:function(i,t){return i!==t},WFiaS:function(i,t){return i(t)},tWTOO:function(i,t){return i==t},WNSPa:function(i,t){return i&t},Zjnes:function(i,t){return i+t},boCKR:function(i,t){return i+t},kkXfR:function(i,t){return i<<t},NXKss:function(i,t){return i<=t},zMxJO:function(i,t){return i(t)},FCazM:function(i,t){return i+t},cPpuo:function(i,t){return i+t},wTyEg:function(i,t){return i!==t},FQrNb:function(i,t){return i&t},kRSkV:function(i,t){return i|t},EOkxY:function(i,t){return i|t},CFjAn:n(1128),yHVrH:function(i,t){return i+t},mQsQv:function(i,t){return i+t},mRHjw:function(i,t){return i<=t},wVbvX:function(i,t){return i+t},gbugi:function(i,t){return i-t},afaVg:function(i,t){return i+t},Ictyw:function(i,t){return i<t},bDTmC:function(i,t,r){return i(t,r)},IGafw:function(i,t){return i<<t},zrZiJ:function(i,t){return i|t},kNHAN:function(i,t){return i>>t},iIYgr:function(i,t){return i|t},FosZq:function(i,t){return i&t},WkEjK:function(i,t){return i>>t},gXQYY:function(i,t){return i&t},dJcsW:function(i,t){return i|t},vIHDf:function(i,t,r){return i(t,r)},UatQu:function(i,t){return i+t},gaFrV:function(i,t,r){return i(t,r)},dZigs:function(i,t){return i<t},PGDSt:function(i,t){return i&t},UVtKw:function(i,t){return i&t},WzgvL:function(i,t){return i>=t},tybAI:function(i,t,r){return i(t,r)},snlqI:function(i,t){return i&t},KOkJH:function(i,t){return i(t)},dZXhc:function(i,t){return i(t)},tQiyO:function(i,t){return i&t},gdHlt:function(i,t){return i&t},piFTy:function(i,t){return i<<t},BbYpg:function(i,t){return i(t)},MwscT:function(i,t){return i<<t},mnrEh:function(i,t){return i&t},DuuAb:function(i,t){return i(t)},HEgmx:function(i,t){return i|t},RXmKe:function(i,t){return i>>>t},mLbXF:function(i,t){return i|t},sJzUD:function(i,t){return i>>>t},aSfpf:function(i,t){return i<<t},ZGymV:function(i,t){return i===t},qiQqS:function(i,t){return i<t},FhZCJ:function(i,t){return i<t},SxKif:function(i,t,r){return i(t,r)},gWjEj:function(i,t){return i!==t},NfzRV:function(i,t){return i!==t},vBELn:function(i,t){return i>>>t},UrDnl:function(i,t){return i&t},kQsnP:function(i,t){return i+t},bINry:function(i,t){return i!==t},qrmhn:function(i,t){return i>>>t},GQXMe:function(i,t){return i&t},mhqCA:function(i,t){return i&t},nstmr:function(i,t){return i>>>t},RhHJv:function(i,t){return i!==t},BXkjA:function(i,t){return i|t},ELJdu:function(i,t){return i+t},UFkrD:function(i,t){return i!==t},NgYRa:function(i,t){return i&t},sJJmk:function(i,t){return i>>>t},FkfvR:function(i,t){return i+t},jSfMQ:function(i,t){return i!==t},zZqvk:function(i,t){return i|t},ntRPE:function(i,t){return i>>>t},MkvuS:function(i,t){return i&t},xxFCO:function(i,t){return i!==t},hrxnY:function(i,t){return i&t},InHut:n(703),wRshH:function(i,t){return i(t)},aIgLb:function(i,t){return i+t},ysgAY:function(i,t){return i!==t},cscFU:n(276),SXdtg:function(i,t){return i===t},nXJsU:n(1075),PYIno:function(i,t){return i|t},vmYvg:function(i,t){return i<<t},bWuPZ:function(i,t){return i<<t},VhytP:function(i,t){return i<<t},ZKJKU:function(i,t){return i|t},acLsI:function(i,t){return i<<t},nBrkU:function(i,t){return i<<t},amInm:function(i,t){return i<<t},pjwBj:function(i,t){return i|t},GHViV:function(i,t){return i<<t},gqfjq:function(i,t){return i<<t},laEra:function(i,t){return i<<t},okwUm:function(i,t){return i===t},kjwsD:function(i,t){return i>>>t},IwwSO:function(i,t){return i|t},gsmKZ:function(i,t){return i<<t},uidRU:function(i,t){return i<<t},vpSqw:function(i,t){return i<<t},eyGwR:function(i,t){return i&t},xKSHS:function(i,t){return i>>>t},cpdLo:function(i,t){return i>>>t},oWFrM:function(i,t){return i(t)},pEEMj:function(i,t){return i===t},FAvmF:function(i,t){return i===t},ZqQGg:n(249),vwQyn:function(i,t){return i!==t},FBpqQ:"mAUnZ",XKQxT:n(1758),cTiFh:"DyEAE",CJvcb:function(i,t){return i<=t},proYl:function(i,t){return i+t},lUjCO:function(i,t){return i%t},VkpSl:function(i,t){return i/t},aPHRr:n(1467)+n(1153)+n(545)+"8",JfOdg:function(i,t){return i|t},sXkKB:function(i,t){return i>t},YNaZq:function(i,t){return i>>>t},WvcbP:function(i,t){return i===t},VPNQN:n(1570),dizax:function(i,t){return i+t},CxyrE:function(i,t){return i*t},DbnXW:function(i,t){return i+t},vROgl:function(i,t){return i===t},UaeLL:n(410),OXsIO:function(i,t){return i(t)},HUirW:function(i,t,r,a){return i(t,r,a)},IeGpt:function(i,t){return i instanceof t},hRjYV:"dsrOa",QujRq:function(i,t){return i>>>t},HhcZT:function(i,t){return i&t},BCIOR:function(i,t){return i>>>t},HdvAF:function(i,t){return i+t},fTQnf:function(i,t){return i===t},VcCdt:function(i,t){return i===t},ZkrRO:function(i,t){return i===t},kffLE:function(i,t){return i+t},KzjVa:function(i,t){return i&t},KVkhV:function(i,t){return i&t},pzdWS:function(i,t){return i>>>t},wyCvs:function(i,t){return i>>>t},dCxNh:function(i,t){return i>>>t},jtrot:function(i,t){return i>>>t},shJKn:function(i,t){return i>>>t},vWZck:function(i,t){return i&t},fFXMf:function(i,t){return i&t},hYWnN:n(887)+n(1078),sFzCp:n(1579)+n(1261),pFqlB:n(399)+"IES_ERROR",kTywa:"MESSAGE_"+n(269),xbOlk:n(414)+"OR",hvueF:n(767)+n(1300),liEwe:function(i,t,r){return i(t,r)},vYuqF:n(1735),hiWNr:n(769)+"3",mVcGD:function(i,t){return i!==t},jDFkw:"SgkCv",arJQq:n(1035),Najbj:function(i,t){return i||t},IRDTh:"undefined",gFMXQ:"awJJa",qMMtB:n(1019),ktGgA:function(i,t){return i instanceof t},fOzds:function(i,t){return i+t},kBNQL:n(766),PbcKI:function(i,t){return i>>>t},bhABa:function(i,t){return i<<t},BTSzz:function(i,t){return i===t},VocGf:function(i,t){return i-t},gzVnK:function(i,t){return i===t},SFxCa:function(i,t){return i>t},Jmeqz:n(904),iLyMc:function(i,t){return i|t},ALehb:function(i,t){return i===t},LEVLa:n(724),QAquu:function(i,t){return i+t},aFLBJ:n(1150)+"d error.",RdHsF:function(i,t){return i+t},HSzrc:function(i,t){return i+t},yDdSh:function(i,t){return i===t},RXaMB:function(i,t){return i===t},OTgtC:n(1058),dZSok:function(i,t){return i===t},vHRQE:function(i,t){return i>>t},FDqOD:n(1611),ehDFB:function(i,t){return i(t)},xwpiu:"unknown reason",MnWSq:function(i,t,r){return i(t,r)},XEKJp:n(1360),cPvxk:function(i,t){return i===t},hpiDi:n(624),NQwmI:n(305),QCUmg:n(1697),wyrig:function(i,t,r){return i(t,r)},ccwBZ:function(i,t){return i!==t},jXYAO:function(i,t){return i-t},RbmSI:function(i,t){return i&t},FnxYW:"OOXzs",JqDEH:n(1655),smSuw:function(i,t){return i===t},nDZou:"jzrAQ",vMCCt:function(i,t){return i+t},HUuEX:n(1293)+"4",WISDf:function(i,t){return i===t},LbRGm:function(i,t){return i+t},ozEER:"NWYPO",MwZcg:function(i,t){return i<t},rSztB:function(i,t){return i&t},vdjPt:function(i,t){return i+t},oSiqo:function(i,t){return i!==t},fosrN:function(i,t){return i===t},GBWBj:function(i,t){return i>>>t},FIFVL:function(i,t){return i<t},uoGSD:function(i,t){return i&t},lOjsi:function(i,t){return i&t},xmiZD:function(i,t){return i>=t},ktRJF:function(i,t){return i<t},zgmGy:function(i,t){return i|t},HouyQ:function(i,t){return i<<t},uEkVZ:function(i,t){return i&t},jjzBa:n(342),HqKEk:n(671),MlOOK:function(i,t){return i|t},woMPG:function(i,t){return i<<t},mqHtZ:function(i,t){return i<<t},JUiso:function(i,t){return i&t},SmfAX:function(i,t){return i+t},MmPvE:function(i,t){return i(t)},ccjrd:function(i,t){return i|t},ppJQL:"YgJGA",fozYF:function(i,t){return i<t},aSRyR:function(i,t){return i|t},zVfQr:function(i,t){return i&t},QxadS:function(i,t){return i===t},IxSuT:function(i,t){return i&t},gxRXI:n(1668)+"4|2",uvHcg:function(i,t){return i|t},oKHTv:function(i,t){return i|t},EYUBI:function(i,t){return i&t},quvFQ:function(i,t){return i+t},fpKeW:function(i,t){return i<<t},RKlDU:function(i,t){return i&t},LcysV:function(i,t){return i|t},ILxzv:function(i,t){return i&t},fPnHl:"PtvmM",CwVGn:function(i,t){return i|t},RMpEF:function(i,t){return i>>t},ycROK:function(i,t){return i&t},GuYBs:function(i,t){return i|t},kJstq:function(i,t){return i==t},vKBlt:function(i,t){return i instanceof t},YzEsL:function(i,t){return i|t},WvMYQ:function(i,t){return i|t},hvOke:function(i,t){return i<<t},tkdMY:function(i,t){return i&t},vPuiZ:function(i,t){return i+t},unIzy:n(1253),MyIFR:function(i,t){return i!=t},UAqfs:function(i,t){return i instanceof t},bJPrC:function(i,t){return i!=t},xQelJ:"applicat"+n(1142),Jtxnb:n(1769),fHmHl:function(i,t){return i!==t},KYqLT:"kaVRC",GWBtw:n(1669),hfcIj:n(1366),qArSa:function(i,t){return i<t},ndHgx:n(451),JGLAF:n(1563),CXqgl:function(i,t){return i+t},HTvLN:n(721)+n(803)+n(889)+"P",RxtVi:n(710),lKgmM:n(1748)+"id",WVdEl:"zRFNQ",JwtzO:"JjAzF",aGYhe:n(323),NbQuP:n(1517),oQfEr:function(i,t){return i!==t},XHomg:n(1033),vccsj:function(i,t){return i>=t},yEtUz:n(1116),LRIoT:function(i,t,r){return i(t,r)},julKZ:n(539),EdqQw:function(i,t){return i===t},Esxqx:n(1691),DKMZg:n(986),pgnId:n(1383),mqnkw:n(1206),LhZbW:function(i,t){return i||t},VExfN:n(738)+n(981),VdfBQ:"Zzqwe",uNhrz:n(1012),lkANU:function(i,t){return i||t},aVflX:function(i,t){return i(t)},CweRD:function(i,t){return i!==t},xiOhL:"AxeRd",mslJr:function(i,t){return i!==t},ThKVm:n(1222),JoPLA:function(i,t){return i||t},TjJRe:function(i,t){return i===t},VKWOf:n(1684),DvQNN:function(i,t){return i||t},nzoRq:function(i,t){return i!==t},aVjuY:"PrGDy",QsKzm:function(i,t){return i||t},QCqhq:function(i,t){return i||t},BUSgz:function(i,t){return i||t},jHCGy:n(284)+n(211)+"d",BZCHG:function(i,t,r){return i(t,r)},ZlMmQ:n(521),JFMfc:"dvGzO",PsSVa:function(i,t){return i(t)},hVnpy:function(i,t){return i-t},wrvAr:"VZHYP",ARTew:n(1129),zzTwP:n(807)+n(735),RWGZu:function(i,t,r){return i(t,r)},AHVMX:n(807)+n(813)+n(1411),SKvHy:n(481),KyReS:n(537),yAtVP:function(i,t){return i&&t},uNEhC:n(1365),uTKdp:n(445),yRSWu:function(i,t){return i||t},JeDpQ:n(1350),HJNrp:n(278),DoGHm:n(1274),fUvbX:function(i,t){return i(t)},llbcj:function(i,t){return i instanceof t},jHrkN:n(341)+n(1059)+"et=utf-8",uADya:"applicat"+n(1142)+n(225)+n(564),KjIlf:"binary",Dbaoz:function(i,t){return i+t},CiPOh:function(i,t){return i(t)},yOfGF:function(i,t){return i+t},XrZuJ:function(i,t){return i|t},laFVw:function(i,t){return i||t},VgvZZ:function(i,t){return i+t},YRggK:function(i,t){return i+t},DJwEy:function(i,t){return i+t},HGhwT:n(1783)+n(907)+n(1544),xeCaJ:" + ",JYnUJ:n(1185),rRdrg:n(570)+"too large",uOgWf:function(i,t){return i&t},kutpz:function(i,t){return i+t},lhpaO:function(i,t){return i===t},nnUuP:"TZusq",fLMhL:function(i,t,r){return i(t,r)},JBIbo:function(i,t){return i<<t},CkKJZ:function(i,t){return i+t},CPCWt:function(i,t){return i+t},gyCuI:function(i,t){return i|t},dNAMH:function(i,t){return i+t},soGkl:function(i,t){return i+t},jGvGb:function(i,t){return i|t},NFWaT:function(i,t){return i|t},vqVQk:function(i,t){return i+t},nYeXU:function(i,t){return i+t},vqmIh:function(i,t){return i+t},eqiZg:function(i,t){return i+t},pYTmB:function(i,t){return i>>>t},SCuwf:function(i,t){return i&t},mGmfu:function(i,t){return i>>>t},Twffc:function(i,t){return i>>>t},zzZim:function(i,t){return i+t},MhLSF:function(i,t){return i instanceof t},elZVM:function(i,t){return i!==t},nabnx:n(280),twXnX:function(i,t){return i&t},TUGIv:function(i,t,r){return i(t,r)},sJbCt:function(i,t){return i!==t},usSIW:n(518),mKvYi:function(i,t){return i+t},bhztn:function(i,t){return i(t)},IoqIN:function(i,t){return i||t},Pafhm:n(947),vHIZZ:function(i,t){return i|t},NNVWk:function(i,t){return i<<t},lYBuP:function(i,t){return i<t},Bpshe:function(i,t){return i>t},phtMy:function(i,t){return i&t},VOmKM:function(i,t){return i|t},oXvgv:function(i,t){return i>>>t},ebYYs:function(i,t){return i<<t},fAMpO:function(i,t){return i===t},nbBKM:n(1008),HzONm:function(i,t){return i(t)},xfrZF:function(i,t){return i(t)},tkOLx:function(i,t){return i&t},fZwjp:function(i,t){return i(t)},tPrza:n(1148)+n(428)+n(899),sYQGt:n(1308)+n(270),dbEsZ:n(745),BOvJv:n(1458),KlfXM:function(i,t){return i|t},Ozogy:function(i,t){return i<<t},vszRt:function(i,t){return i!==t},WJCFT:n(831),KPIFc:"obvcC",rjQeu:function(i,t){return i+t},iLZAR:n(479)+"ile_name",AOGrn:n(1474)+n(1513),Fagwc:n(344)+n(820),CyUED:"ALL",pnBZa:"INSTANT",PbchS:n(700),tkylD:function(i,t,r,a){return i(t,r,a)},aKaMB:function(i){return i()},eZXMw:n(712),mrUyV:function(i,t){return i!==t},tTmin:n(406),WSGEd:function(i,t){return i(t)},enIae:n(1426)+"r",wyyyC:function(i,t){return i+t},nmeTs:function(i,t){return i!==t},LrdNh:function(i,t){return i&t},Zhqss:function(i,t){return i<<t},gDGYq:function(i,t){return i&t},aCdiu:function(i,t){return i<t},dWJiF:function(i,t){return i===t},tLbyN:n(353),gNFtP:n(733),rCVxb:function(i,t){return i!==t},naoGL:n(312),dzZHh:n(1556),QxgZr:"2|1|0|4|3",KFFgt:function(i,t){return i+t},DGQNo:function(i,t){return i+t},cCGbb:n(1528),irSXZ:function(i,t,r){return i(t,r)},UriAW:n(568)+"s",cKiTq:n(603)+n(1183)+"e",QwUse:function(i,t){return i(t)},QIKCR:function(i,t,r){return i(t,r)},QGsYJ:n(603)+"rsor_value",jaJyY:function(i){return i()},aURdb:function(i,t){return i>t},ygBus:function(i,t){return i+t},XhxHE:function(i){return i()},TcifN:function(i,t){return i&&t},nXvwc:function(i){return i()},dGtIm:function(i,t){return i(t)},WUmPq:function(i){return i()},HSddo:function(i){return i()},VzEwz:"always",pVolg:function(i,t){return i===t},DiXaT:n(1685),WJBAN:function(i,t,r){return i(t,r)},wknwJ:function(i,t){return i===t},efitb:function(i,t,r,a){return i(t,r,a)},vyORs:function(i,t,r){return i(t,r)},Yweio:function(i,t){return i===t},RqZaj:function(i,t,r){return i(t,r)},GnQMa:"bye",yFtHE:function(i,t,r){return i(t,r)},DRnPB:n(882)+n(849),QMNlb:n(1539),FVkxD:function(i,t){return i===t},danoK:n(500)+"rovide v"+n(1317),YsmSa:function(i,t){return i!==t},JVYdg:n(251),XBbLn:function(i,t){return i===t},MwUuB:n(199),OyQAb:n(1072),zzGuJ:function(i,t,r){return i(t,r)},HsckE:"stop immediately reconnect",uVcRl:n(949)+"4",isrTf:n(672),LNIxu:"https:",QOilA:n(1242),RyMjf:n(1698),SZSQk:"bd_did",eWOTU:"device_id",cIrPe:n(1187),mWGPS:n(498),UWbdU:n(1764)+"0",TvxsW:n(330)+"3|4",LCVOx:n(1657),zoSzS:n(1013),jmQpM:"count",tYLkW:function(i){return i()},EsKQM:n(496),bdiQm:"oxORc",fXmow:function(i,t){return i===t},khPaB:"VCIwc",HVWpW:function(i,t){return i!==t},FvJIT:n(1581),VcDTw:function(i,t){return i===t},qQyVv:function(i,t,r){return i(t,r)},OdMbP:"reconnect",jpwot:"start",bUxDN:function(i,t){return i>t},NfBRY:function(i,t,r){return i(t,r)},BuquL:function(i,t){return i!==t},RBUXF:n(1041),WMnhI:n(933),jtojW:function(i,t){return i(t)},iIiHH:"FRONTIER>",OhKug:function(i,t){return i>t},cvcqh:function(i,t,r){return i(t,r)},RdwyV:n(1731)+n(478)+n(576)+n(1213)+n(256),BfJPP:n(1541),kiFHI:n(956),SMGbY:function(i,t,r){return i(t,r)},hrlXj:n(1071)+" try rec"+n(549)+"g",fnruC:function(i,t){return i!=t},tYgDb:n(1166),ReBbA:function(i,t){return i(t)},qOPlV:function(i,t){return i===t},CjjOK:n(1194),yVgXe:n(866),woivg:n(1114)+"4",vocNj:function(i,t){return i===t},umWYp:n(1371),dhcCZ:n(580),ocBcr:n(1724),HCNDi:function(i,t,r){return i(t,r)},xYcyS:function(i,t,r){return i(t,r)},zqYOD:n(1731)+n(212)+n(1630)+n(340),pUhme:n(948),XCpyJ:n(988)+n(1451),OfEqP:"close, ws alread"+n(380),yaYQc:n(1662)+n(652)+n(1604)+"nitialized",PHnMf:function(i,t){return i==t},jhqBk:function(i,t){return i==t},fiUqY:n(228),yNXWV:function(i,t){return i instanceof t},nQkJs:function(i,t){return i(t)},KsZOA:function(i,t){return i(t)},gKUCm:function(i,t){return i(t)},DVMFy:n(500)+n(1483)+n(260)+n(270),cXPRr:function(i,t){return i===t},bfhyC:n(665),WxsID:n(1407),fWcxk:n(1107)+"0",xorjk:n(1740),YkyuD:"ping_onc"+n(802)+"t",XXKBc:function(i,t){return i(t)},qbwBN:n(1602),JZZpt:function(i,t){return i*t},CiDYH:function(i,t){return i*t},wxrex:function(i,t){return i!=t},UDqHQ:n(783),ZUwpN:function(i,t){return i===t},picLB:function(i,t){return i!=t},KmCVw:function(i,t){return i!=t},eTSYP:"Object",oAVAm:function(i,t){return i===t},HpkrL:n(258)+n(753)+"lobalScope",gLQry:function(i,t){return i===t},UIAZu:function(i,t){return i!=t},hjnZI:function(i,t){return i!=t},vXsVS:function(i,t){return i===t},OzBYQ:n(1021)+n(427)+n(690),pmcOV:function(i,t){return i!=t},GakRS:n(229)+n(639)};Fe.r(te),Fe.d(te,{FWS:()=>C0,CustomErrorEvent:()=>Xi,createCloseEvent:()=>De,ReconnectEvent:()=>Yi,createErrorEvent:()=>Ie,decodedFrame:()=>wt,createOpenEvent:()=>rs,CustomCloseEvent:()=>Qi,createReconnectEvent:()=>Rr,FrontierMessageEvent:()=>es,encodeFrame:()=>re,createMessageEvent:()=>ns,OpenEvent:()=>ts,ErrorCode:()=>Ze,Event:()=>bt,MessageEvent:()=>Zi});let s="";function o(i=""){let t=n,r="02",a=""+Date[t(1780)](),x=s||(s=p(i)),f=Math[t(1328)]()[t(1605)](16)[t(1424)](-6);return e[t(1073)](e.VFpvc(e.JduWO(r,a),x),f)}function c(){let i=n;return e[i(1696)](1e4*Date[i(1780)](),Math.floor(e.nmnpD(1e4,Math.random())))}function d(i){let t=n;return e.rRVsx(e[t(429)],e.rzloJ)?this[t(524)]?.[t(1657)](_0x5d634f):e[t(952)](e[t(1420)](Array,8).join("0"),e[t(1682)](parseInt,i,10).toString(2))[t(1424)](-8)}function u(i){let t=n;return(e[t(1420)](Array,4)[t(1453)]("0")+e[t(1265)](parseInt,i,2).toString(16))[t(1424)](-4)}function l(i){let t=n,r={tSqkV:e.cJSVZ,IrsYS:"error",MvNgu:e[t(610)]};if(e[t(1658)](e.bSNKF,"bzAHo")){let a=i[t(1413)](/\./)[t(754)](h=>d(h)),x=[];return x[0]=e[t(1420)](u,a[0]+a[1]),x[1]=u(a[2]+a[3]),["0000",e[t(1240)],e.TEPcf,t(237),e[t(1240)],e.YJNZl,x[0],x[1]][t(1453)]("")}else _0x18f454[t(605)+t(720)+t(396)](UYomjE.tSqkV,_0x3ad4ce),_0x3d67e5[t(605)+t(720)+t(396)](UYomjE[t(364)],_0x42b9b9),_0xd37e77[t(605)+"entListe"+t(396)](UYomjE.MvNgu,_0x461473)}function p(i){let t=n;if(e[t(1287)]!==t(1564)){let r=/(25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?)(\.(25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?)){3}/[t(1646)](i),a=/(([0-9a-fA-F]{1,4}:){7,7}[0-9a-fA-F]{1,4}|([0-9a-fA-F]{1,4}:){1,7}:|([0-9a-fA-F]{1,4}:){1,6}:[0-9a-fA-F]{1,4}|([0-9a-fA-F]{1,4}:){1,5}(:[0-9a-fA-F]{1,4}){1,2}|([0-9a-fA-F]{1,4}:){1,4}(:[0-9a-fA-F]{1,4}){1,3}|([0-9a-fA-F]{1,4}:){1,3}(:[0-9a-fA-F]{1,4}){1,4}|([0-9a-fA-F]{1,4}:){1,2}(:[0-9a-fA-F]{1,4}){1,5}|[0-9a-fA-F]{1,4}:((:[0-9a-fA-F]{1,4}){1,6})|:((:[0-9a-fA-F]{1,4}){1,7}|:)|fe80:(:[0-9a-fA-F]{0,4}){0,4}%[0-9a-zA-Z]{1,}|::(ffff(:0{1,4}){0,1}:){0,1}((25[0-5]|(2[0-4]|1{0,1}[0-9]){0,1}[0-9])\.){3,3}(25[0-5]|(2[0-4]|1{0,1}[0-9]){0,1}[0-9])|([0-9a-fA-F]{1,4}:){1,4}:((25[0-5]|(2[0-4]|1{0,1}[0-9]){0,1}[0-9])\.){3,3}(25[0-5]|(2[0-4]|1{0,1}[0-9]){0,1}[0-9]))/.test(i);return r?e[t(1420)](l,i):a?m(i):e[t(730)]}else{let r=new _0x3d89ca(e[t(1052)](e[t(1052)](e.dUFwd(e.cODZt(_0x2f35eb[e[t(1073)](_0x3debb6,4)],24),e[t(1048)](_0x287337[e[t(1073)](_0x313e2a,5)],16)),e[t(597)](_0x27207d[e.ZXIQJ(_0x3125e0,6)],8)),_0x3eeb57[e.cWIoB(_0x5c9782,7)]),e[t(370)](e[t(1529)](_0x38514a[_0x5cd7ab+0]<<24,_0x51f193[e[t(1155)](_0x4a165c,1)]<<16),e[t(597)](_0x52c0b8[e[t(1331)](_0x4c5122,2)],8))|_0x1cc812[_0x5c5ac8+3],!0);return _0x25dcd5+=8,{value:r,offset:_0x3d50f2+8}}}function m(i){let t=n,r={LAtsw:function(b){return e.isZZf(b)}},a="",x=[],f=0,h=0,w=!0,g=e[t(1240)];if(e[t(1223)](i[t(495)]("::"),-1)){let b=i.split("::");for(let C=0;C<b[t(796)];C++){let O=b[C];if(e[t(1223)](O[t(495)](":"),0)){let R=O.split(":");w&&(f=R.length),h+=R[t(796)];for(let F=0;e[t(308)](F,R[t(796)]);F++)if(e[t(1658)](4,R[F].length)){if(t(315)===e[t(819)])return this[t(443)+"hMessage"+t(1081)](_0x7b377a),r[t(574)](_0x394c37);{let ue=g.substring(0,4-R[F][t(796)]),be=ue[t(632)](R[F]);x[t(1774)](be)}}else x[t(1774)](R[F]);w=!1}else{if(e[t(1666)](4,O[t(796)])){let R=g[t(644)+"g"](0,e.evZjp(4,O[t(796)])),F=R[t(632)](O);x[t(1774)](F)}else x[t(1774)](O);w&&(f+=1),h+=1,w=!1}}let v="";for(let C=0;e[t(739)](C,e[t(303)](8,h));C++)v=v[t(632)](g);for(let C=0;e[t(739)](C,x.length);C++)e[t(846)](C,f)?(a=a.concat(v),a=a[t(632)](x[C])):a=a.concat(x[C]);return a}{let b=i[t(1413)](":");for(let v=0;e[t(995)](v,b.length);v++){let C=b[v];if(e.mYJtb(4,b[v][t(796)])){let O=g[t(644)+"g"](0,e[t(303)](4,b[v][t(796)])),R=O[t(632)](C);a=a.concat(R)}else a=a[t(632)](C)}return a}}function _(i,t){let r=n,a=i[r(1642)];e.rRVsx(void 0,a)&&(e.rufGw(V,t,10),e.ubtAk(le,t,a));let x=i.value;e[r(935)](void 0,x)&&(e[r(1265)](V,t,18),e[r(1739)](le,t,x))}function y(i){let t=n,r={};e:for(;!de(i);){let a=X(i);switch(a>>>3){case 0:break e;case 1:r.key=e[t(1452)](Z,i,X(i));break;case 2:r[t(916)]=e.OLuDN(Z,i,e[t(1420)](X,i));break;default:e[t(1546)](Q,i,e[t(1276)](7,a))}}if(e[t(528)](void 0,r[t(1642)]))throw new Error("Missing "+t(1096)+t(1578)+t(1642));if(e.uIoLH(void 0,r[t(916)]))throw new Error(e[t(914)]);return r}function I(i){let t=n,r=e[t(517)](se);return e[t(1594)](L,i,r),e[t(1568)](pe,r)}function L(i,t){let r=n,a=i[r(1755)];e[r(531)](void 0,a)&&(e[r(926)](V,t,8),e[r(584)](W,t,a));let x=i.LogID;e.ONXxT(void 0,x)&&(e.buKdY!==e[r(1068)]?(this._isBrowser&&_0x5a6942[r(605)+r(720)+r(396)](e.FxhDR,this[r(433)+"nLine"]),this[r(626)+"er"]&&_0x48a923[r(605)+r(720)+r(396)](e[r(589)],this[r(433)+"ffLine"]),this._isBrowser&&_0x3a2278[r(605)+r(720)+r(396)](e[r(722)],this[r(1211)+r(1722)]),this._isBrowser&&_0x1f4563[r(605)+r(720)+r(396)](e[r(885)],this[r(1211)+"ageShow"])):(e[r(694)](V,t,16),e[r(1594)](W,t,x)));let f=i[r(745)];e[r(1695)](void 0,f)&&(V(t,24),e[r(1690)](W,t,K(f)));let h=i[r(430)];h!==void 0&&(e[r(584)](V,t,32),e[r(1682)](W,t,e.hTdXc(K,h)));let w=i[r(951)];if(e.xpfen(void 0,w))for(let ue of w){V(t,42);let be=se();_(ue,be),V(t,be[r(1572)]),e.SXhvl(je,t,be),oe(be)}let g=i[r(900)+r(850)];if(g!==void 0)if(e.iigZA(e[r(1773)],e.iZtQg))e[r(1594)](V,t,50),le(t,g);else{let{pingInterval:ue,pingFrequency:be}=this[r(388)];if((_0x383365[r(1661)]==="hi"&&e.uIoLH(r(797),be)||e.uIoLH("auto",be))&&(this[r(375)+"ngTimer"](),this.emit(e.wVKst,e.dYxnU),this._pingPongTimeoutId=e[r(594)](_0x32a821,this._ping[r(854)](this),ue)),e.TgdQf("hi",_0x236811[r(1661)]))return;try{e[r(751)](_0x13e592,this,_0x14241f,[_0x12bf1c,_0x3b48f9,_0x290bf6,_0x1de593,_0x2a4943,_0x5c318f])}catch(Gt){let mn=e[r(1452)](_0x59fc4b,e[r(1214)],{message:Gt[r(1697)],code:_0x26d72b[r(1392)+r(269)],error:Gt});this[r(443)+"hErrorEvent"](mn)}}let b=i[r(384)+"ype"];e[r(1557)](void 0,b)&&(V(t,58),e[r(1247)](le,t,b));let v=i[r(1097)];e[r(432)](void 0,v)&&(e.qqiAR!==e[r(235)]?e[r(262)](_0x22fc90,_0x69e17e,this[r(1706)+r(444)+"e"](_0x2ddd49)):(e[r(1267)](V,t,66),e[r(1739)](V,t,v[r(796)]),e[r(1546)](ye,t,v)));let C=i[r(234)];e[r(1658)](void 0,C)&&(e.SXhvl(V,t,74),e[r(584)](le,t,C));let O=i[r(1727)+r(1699)];e[r(1557)](void 0,O)&&(e[r(1269)](V,t,82),e[r(1247)](le,t,O));let R=i[r(1765)];e[r(1387)](void 0,R)&&(e[r(845)](V,t,90),le(t,R));let F=i[r(1104)+"e"];e[r(1387)](void 0,F)&&(e[r(763)](V,t,96),e.WjLSS(W,t,e[r(1420)](K,F)))}function T(i){let t=n;return e[t(877)](P,e[t(1597)](Te,i))}function P(i){let t=n,r={};e:for(;!de(i);){let a=e[t(1420)](X,i);switch(a>>>3){case 0:break e;case 1:r[t(1755)]=e[t(594)](dt,i,!0);break;case 2:r.LogID=e[t(763)](dt,i,!0);break;case 3:r[t(745)]=e.mxQlT(X,i);break;case 4:r[t(430)]=e.yFSbq(X,i);break;case 5:{let x=e[t(877)](j,i);(r.headers||(r[t(951)]=[]))[t(1774)](e[t(1597)](y,i)),i.limit=x;break}case 6:r[t(900)+"ncoding"]=e[t(1269)](Z,i,e[t(877)](X,i));break;case 7:r.payloadType=Z(i,e.YtCcr(X,i));break;case 8:r[t(1097)]=z(i,e[t(677)](X,i));break;case 9:r[t(234)]=e[t(1267)](Z,i,X(i));break;case 10:r["serverTi"+t(1699)]=e.vAupn(Z,i,e.kODOc(X,i));break;case 11:r[t(1765)]=e[t(1268)](Z,i,e.YtCcr(X,i));break;case 12:r[t(1104)+"e"]=e[t(877)](X,i);break;default:Q(i,e[t(1276)](7,a))}}if(e[t(1459)](void 0,r[t(1755)]))throw new Error(e[t(1772)]);if(e[t(623)](void 0,r[t(1397)]))throw new Error(e[t(908)]);if(e[t(846)](void 0,r[t(745)]))throw new Error(e[t(696)]);if(e[t(528)](void 0,r[t(430)]))throw new Error(e[t(1718)]);return r}function j(i){let t=n,r=e[t(436)](X,i),a=i.limit;return i[t(1572)]=i.offset+r,a}function Q(i,t){let r=n;if(e[r(1557)](e.sDPXq,e[r(680)]))this[r(285)+"ndpointT"+r(1522)+"t"]=0;else switch(t){case 0:for(;128&ne(i););break;case 2:e[r(1020)](xe,i,e.IQtpa(X,i));break;case 5:xe(i,4);break;case 1:xe(i,8);break;default:throw new Error(e[r(1687)](e[r(811)],t))}}function K(i){let t=n;return i|=0,{low:i,high:i>>31,unsigned:e[t(405)](i,0)}}let $=[];function se(){let i=n,t=$[i(1466)]();return t?(t[i(397)]=t[i(1572)]=0,t):{bytes:new Uint8Array(64),offset:0,limit:0}}function oe(i){$.push(i)}function Te(i){return{bytes:i,offset:0,limit:i[n(796)]}}function pe(i){let t=n,r=i[t(1582)],a=i[t(1572)];return r.length===a?r:r[t(993)](0,a)}function xe(i,t){let r=n;if(e[r(361)](i[r(397)],t)>i[r(1572)])throw new Error(e[r(984)]);i[r(397)]+=t}function de(i){let t=n;if(e[t(1094)](e[t(901)],e[t(901)]))Pqqzol[t(1689)](_0x4ae0d5),Pqqzol[t(698)](_0x52811e);else return e[t(1289)](i[t(397)],i.limit)}function A(i,t){let r=n,a=i[r(1582)],x=i[r(397)],f=i[r(1572)],h=x+t;if(e[r(1223)](h,a[r(796)]))if(e[r(1169)]===e[r(1169)]){let w=new Uint8Array(e[r(612)](2,h));w[r(1651)](a),i.bytes=w}else return this._qosDB.clear();return i.offset=h,h>f&&(i.limit=h),x}function N(i,t){let r=n,a=i[r(397)];if(e.ZPPWU(a,t)>i.limit)throw new Error(e[r(1115)]);return i[r(397)]+=t,a}function z(i,t){let r=n,a=N(i,t);return i[r(1582)][r(993)](a,e[r(357)](a,t))}function ye(i,t){let r=n,a=e[r(355)](A,i,t.length);i[r(1582)][r(1651)](t,a)}function Z(i,t){let r=n,a=N(i,t),x=String["fromChar"+r(1700)],f=i[r(1582)],h="\uFFFD",w="";for(let g=0;e[r(1218)](g,t);g++){let b=f[e[r(1553)](g,a)],v,C,O,R;if(e[r(648)](128&b,0))w+=e[r(677)](x,b);else if(e[r(1276)](224,b)===192)e[r(871)](e[r(230)](g,1),t)?w+=h:(v=f[e[r(488)](e[r(1106)](g,a),1)],e[r(750)](192&v,128)?w+=h:(R=e[r(1048)](e[r(1276)](31,b),6)|e[r(1276)](63,v),e[r(739)](R,128)?w+=h:(w+=e.WFiaS(x,R),g++)));else if(e[r(1571)](e[r(1475)](240,b),224))e.lQtqS(g+2,t)?w+=h:(v=f[e[r(1757)](e.boCKR(g,a),1)],C=f[e[r(1106)](g,a)+2],e[r(1276)](e[r(1052)](v,C<<8),49344)!==32896?w+=h:(R=e[r(1529)](e[r(1529)](e[r(1048)](e[r(1475)](15,b),12),e[r(1616)](63&v,6)),e[r(1475)](63,C)),e[r(995)](R,2048)||e[r(1289)](R,55296)&&e[r(337)](R,57343)?w+=h:(w+=e.zMxJO(x,R),g+=2)));else if(e[r(1571)](248&b,240))if(e[r(405)](e[r(1696)](g,3),t))w+=h;else if(r(1441)==="FFghN")if(v=f[e[r(357)](e[r(361)](g,a),1)],C=f[e[r(488)](e[r(1045)](g,a),2)],O=f[e[r(775)](g,a)+3],e[r(1139)](e[r(1202)](e.kRSkV(v,e.cODZt(C,8))|e[r(1396)](O,16),12632256),8421504))w+=h;else if(R=e[r(839)]((7&b)<<18|e[r(1202)](63,v)<<12|e[r(1202)](63,C)<<6,63&O),e.Ttnud(R,65536)||R>1114111)w+=h;else if(e.QtiqQ(e[r(837)],e[r(837)]))R-=65536,w+=e[r(594)](x,e[r(334)](R>>10,55296),e[r(983)](e.FQrNb(1023,R),56320)),g+=3;else{let F=this[r(524)].getItem(this._prefix),ue=_0x5ad08d[r(636)](F||"{}");return ue[_0x14a0fc]=void 0,this[r(524)][r(824)](this[r(1479)],_0x482e2d.stringify(ue))}else{let F=this._qosDB[r(421)+"geInfoSync"](this._prefix),ue=_0x178d98[r(636)](e.wMoQE(F,"{}"));return _0x52e77d[r(1561)](ue)}else w+=h}return w}function le(i,t){let r=n,a=t[r(796)],x=0;for(let w=0;e[r(308)](w,a);w++){let g=t[r(1380)+"At"](w);g>=55296&&e[r(1633)](g,56319)&&e[r(878)](w,1)<a&&(g=e.gbugi(e.afaVg(e.LIKtY(g,10),t[r(1380)+"At"](++w)),56613888)),x+=g<128?1:e.Ictyw(g,2048)?2:g<65536?3:4}V(i,x);let f=e.bDTmC(A,i,x),h=i[r(1582)];for(let w=0;e[r(739)](w,a);w++){let g=t[r(1380)+"At"](w);g>=55296&&g<=56319&&e[r(995)](w+1,a)&&(g=e.IGafw(g,10)+t[r(1380)+"At"](++w)-56613888),g<128?h[f++]=g:(e[r(995)](g,2048)?h[f++]=e[r(335)](e[r(200)](g,6)&31,192):(e[r(308)](g,65536)?h[f++]=e[r(886)](e[r(1410)](e[r(1231)](g,12),15),224):(h[f++]=e[r(1476)](g>>18,7)|240,h[f++]=e[r(1475)](g>>12,63)|128),h[f++]=e[r(604)](e[r(1231)](g,6)&63,128)),h[f++]=e[r(335)](e[r(1410)](63,g),128))}}function je(i,t){let r=n,a=e.vIHDf(A,i,t.limit),x=i[r(1582)],f=t[r(1582)];for(let h=0,w=t[r(1572)];h<w;h++)x[e[r(954)](h,a)]=f[h]}function ne(i){return i[n(1582)][e.gbHXj(N,i,1)]}function Xe(i,t){let r=n,a=e[r(1e3)](A,i,1);i[r(1582)][a]=t}function X(i){let t=n,r=0,a=0,x;do x=e[t(877)](ne,i),e.dZigs(r,32)&&(a|=e[t(1616)](e[t(366)](127,x),r)),r+=7;while(e.UVtKw(128,x));return a}function V(i,t){let r=n;for(t>>>=0;e.WzgvL(t,128);)e[r(474)](Xe,i,e[r(839)](e[r(649)](127,t),128)),t>>>=7;e[r(694)](Xe,i,t)}function dt(i,t){let r=n,a=0,x=0,f=0,h;return h=e.KOkJH(ne,i),a=e[r(1476)](127,h),e[r(1276)](128,h)&&(h=e.dZXhc(ne,i),a|=e[r(1048)](127&h,7),e[r(386)](128,h)&&(h=e[r(465)](ne,i),a|=(127&h)<<14,e[r(1352)](128,h)&&(h=e[r(1568)](ne,i),a|=e[r(1351)](127&h,21),e[r(1410)](128,h)&&(h=ne(i),x=e[r(649)](127,h),128&h&&(h=e[r(1400)](ne,i),x|=e.IGafw(e[r(1352)](127,h),7),e[r(1475)](128,h)&&(h=e.BbYpg(ne,i),x|=e.snlqI(127,h)<<14,e.FosZq(128,h)&&(h=ne(i),x|=e[r(1756)](127&h,21),e.mnrEh(128,h)&&(h=ne(i),f=e[r(649)](127,h),128&h&&(h=e[r(1447)](ne,i),f|=e[r(1351)](127&h,7)))))))))),{low:e[r(1322)](a,e.KzJmd(x,28)),high:e[r(795)](x,4)|e[r(1756)](f,24),unsigned:t}}function W(i,t){let r=n,a=e[r(795)](t[r(1454)],0),x=e[r(857)](e[r(1720)](t[r(1454)],28),e[r(257)](t.high,4))>>>0,f=e[r(1720)](t.high,24),h=e.ZGymV(0,f)?e.ZGymV(0,x)?e[r(1218)](a,16384)?e.qiQqS(a,128)?1:2:a<2097152?3:4:e[r(308)](x,16384)?x<128?5:6:e[r(1336)](x,2097152)?7:8:f<128?9:10,w=e[r(1671)](A,i,h),g=i[r(1582)];switch(h){case 10:g[e[r(230)](w,9)]=e[r(366)](e.sJzUD(f,7),1);case 9:g[e[r(1106)](w,8)]=e[r(553)](9,h)?e[r(792)](128,f):e.PGDSt(127,f);case 8:g[e[r(954)](w,7)]=e[r(879)](8,h)?e[r(1221)](x,21)|128:e.UrDnl(x>>>21,127);case 7:g[e[r(596)](w,6)]=e[r(1264)](7,h)?e.dUFwd(e[r(313)](x,14),128):e[r(1614)](x>>>14,127);case 6:g[w+5]=e[r(432)](6,h)?e[r(1529)](e.RXmKe(x,7),128):e[r(402)](e.nstmr(x,7),127);case 5:g[e.afaVg(w,4)]=e[r(514)](5,h)?e[r(1446)](128,x):e[r(366)](127,x);case 4:g[e[r(1600)](w,3)]=e[r(1370)](4,h)?e.sJQVs(e[r(1720)](a,21),128):e[r(1098)](e[r(1221)](a,21),127);case 3:g[w+2]=e.bINry(3,h)?e.mLbXF(e[r(313)](a,14),128):e[r(386)](e.sJJmk(a,14),127);case 2:g[e[r(533)](w,1)]=e[r(1133)](2,h)?e[r(945)](e[r(475)](a,7),128):e[r(1488)](e[r(475)](a,7),127);case 1:g[w]=e[r(676)](1,h)?128|a:e[r(1089)](127,a)}}function wt(i){return e[n(677)](T,i)}function re(i){let t=n;return e[t(352)](e[t(1238)],t(703))?e[t(841)](I,i):new _0x3ac472(_0x4860a6)}let _t=65536,we=e[n(1076)],yt=e[n(816)](_t,_t),Ji=e.CiDYH(yt,yt),$i=Ji/2,Qe=String[n(1349)+"e"][n(1380)+"At"];class G{constructor(t,r,a){let x=n;this.isLong=!0,this[x(1454)]=e[x(857)](0,t),this[x(1070)]=0|r,this[x(1381)]=!!a}static[n(872)](t){let r=n;return e.ysgAY(e[r(1257)],r(276))?(_0x3b3c93[r(928)+"t8"]?_0x336196.writeUint8(_0x380e05,_0x15e096):_0x141be5[_0x34d144]=e[r(366)](255,_0xad7737),e.aIgLb(_0x1800ce,1)):t&&e[r(573)](!0,t[r(872)])}static fromBits(t,r,a){let x=n;if(e.UFkrD(e.nXJsU,x(647)))return new G(t,r,a);_0x15e9ec[x(1298)+x(598)]="",_0x50ce6f[x(905)](_0x116672)}static[n(683)+"s"](t,r,a){let x=n;return a?G[x(683)+x(1282)](t,r):G[x(683)+x(295)](t,r)}static["fromByte"+n(1282)](t,r){let a=n;return new G(e.PYIno(e[a(945)](t[0],e.vmYvg(t[1],8)),e[a(1751)](t[2],16))|e.VhytP(t[3],24),e[a(857)](e[a(1385)](t[4]|e.acLsI(t[5],8),e.vmYvg(t[6],16)),e[a(1047)](t[7],24)),r)}static[n(683)+n(295)](t,r){let a=n;return new G(e[a(370)](e[a(839)](e[a(945)](t[4]<<24,t[5]<<16),e[a(1309)](t[6],8)),t[7]),e[a(490)](e.pjwBj(e[a(969)](t[0],24),e[a(431)](t[1],16))|e.laEra(t[2],8),t[3]),r)}static[n(254)](t){let r=n;return e[r(1305)](t,we)?Vi:new G(e[r(1469)](e[r(1175)](e[r(335)](Qe.call(t,0)|e.gsmKZ(Qe.call(t,1),8),e[r(507)](Qe.call(t,2),16)),e.amInm(Qe[r(1182)](t,3),24)),0),e[r(335)](e[r(888)](e[r(792)](Qe[r(1182)](t,4),Qe[r(1182)](t,5)<<8),e[r(1105)](Qe.call(t,6),16)),e[r(1047)](Qe[r(1182)](t,7),24))>>>0,!0)}toHash(){let t=n;return String[t(861)+t(1700)](e[t(268)](255,this[t(1454)]),e[t(386)](this[t(1454)]>>>8,255),e[t(1410)](this.low>>>16,255),e.ntRPE(this.low,24),e[t(366)](255,this[t(1070)]),e.RXmKe(this.high,8)&255,e[t(1276)](e.xKSHS(this[t(1070)],16),255),e[t(343)](this.high,24))}static fromNumber(t,r=!0){let a=n,x={QqTJx:function(f,h){return e[k(1609)](f,h)}};if(e[a(1362)](e[a(963)],e.ZqQGg)){if(isNaN(t))return r?Fc:Vi;if(r)if(e[a(1762)](e[a(300)],e[a(403)])){if(t>=Ji)return qc}else this["_miniNavigatorOn"+a(728)]=_0x3e4c80,_0x15a92d?this[a(433)+a(818)]():this["_handleO"+a(719)]();else if(a(664)===e[a(829)]){if(e[a(752)](t,-$i))return Hc;if(e[a(985)](t,1)>=$i)return Uc}else e[a(1100)](_0xb594b3,this[a(377)+a(653)+"Id"]),_0x510da0(this["_reconne"+a(1010)+a(1421)]),this["_pingPon"+a(653)+"Id"]=null,this[a(1511)+a(1010)+a(1421)]=null;return G[a(629)](e[a(1175)](e[a(551)](t,yt),0),e[a(1179)](e.VkpSl(t,yt),0),r)}else return x.QqTJx(0,this[a(1070)])&&x.QqTJx(0,this[a(1454)])}[n(1173)](){let t=n,r={gkLqL:e[t(814)],XJRWm:function(a,x){return e.qiQqS(a,x)},udEdu:function(a,x){return e[t(1052)](a,x)},kUcfp:function(a,x){return e[t(931)](a,x)},TIFfH:function(a,x){return a<<x},Wpnvz:function(a,x){return e.GQXMe(a,x)},uRHSR:function(a,x){return e[t(1674)](a,x)},ZotzD:function(a,x){return a|x},mIxLP:function(a,x){return e.sXkKB(a,x)},PUYHB:function(a,x){return e[t(1352)](a,x)},ugHCi:function(a,x){return e[t(1389)](a,x)}};if(e[t(400)](e[t(1361)],e.VPNQN))return this[t(1381)]?e[t(348)](e[t(1108)](e.ntRPE(this[t(1070)],0),yt),e[t(795)](this[t(1454)],0)):e.DbnXW(e[t(612)](this[t(1070)],yt),e[t(313)](this[t(1454)],0));{let a={xKmmF:r[t(939)],XSbUh:function(f,h){return r.XJRWm(f,h)},fXeiG:function(f,h){return r[t(1358)](f,h)},UpKdM:function(f,h){return r[t(322)](f,h)},TNGMk:function(f,h){return r[t(1752)](f,h)},wTsxy:function(f,h){return r[t(1555)](f,h)},ZKRqe:function(f,h){return r[t(1747)](f,h)},TlYGy:function(f,h){return r[t(1358)](f,h)},wkMiO:function(f,h){return r[t(925)](f,h)},PuHMT:function(f,h){return r[t(1018)](f,h)},JMdDF:function(f,h,w,g){return f(h,w,g)},CdFQr:function(f,h){return f>>>h},GlciK:function(f,h){return f<<h},hjNcT:function(f,h){return r[t(1738)](f,h)},iMzps:function(f,h){return f|h},dypVO:function(f,h){return r[t(1573)](f,h)}},x=4294967295;return function(f,h,w=!0){let g=t,b=a.xKmmF[g(1413)]("|"),v=0;for(;;){switch(b[v++]){case"0":if(a[g(955)](f[h++],128))return{value:w?x:a[g(1497)](0,x),offset:h};continue;case"1":x=a[g(246)](x|a[g(1782)](a[g(1625)](15,f[h]),28),0);continue;case"2":if(a.XSbUh(f[h++],128))return{value:w?x:a[g(206)](0,x),offset:h};continue;case"3":if(f[h++]<128)return{value:w?x:a[g(1254)](0,x),offset:h};continue;case"4":x=a[g(246)](a[g(1497)](x,a[g(1782)](a[g(1625)](127,f[h]),7)),0);continue;case"5":if(a[g(955)](f[h++],128))return{value:w?x:a[g(1113)](0,x),offset:h};continue;case"6":if(a[g(1654)](h+=5,f[g(796)]))throw h=f[g(796)],a[g(493)](_0x40c2a6,h,10,f[g(796)]);continue;case"7":x=a[g(972)](a[g(1497)](x,a[g(296)](a[g(625)](127,f[h]),21)),0);continue;case"8":return{value:w?x:0|x,offset:h};case"9":if(f[h++]<128)return{value:w?x:a.iMzps(0,x),offset:h};continue;case"10":x=a[g(1625)](127,f[h])>>>0;continue;case"11":x=a.dypVO(x|a[g(1782)](127&f[h],14),0);continue}break}}}}[n(1431)](){let t=n;return e.vROgl(0,this.high)&&e[t(352)](0,this[t(1454)])}[n(1536)](t){let r=n;if(r(595)===e[r(1083)]){if(e[r(1571)](e[r(980)],typeof _0x3d2d87)){let a=new _0x19a5e0(e[r(1659)](_0x17e9e5,_0x54db3b));return e[r(526)](_0x16349f,_0x2b4205,a,0),a}return e[r(210)](_0x3f8e0d,_0x7acd5b)?new _0x1dbf12(_0x5a58e7):new _0x11b4db(_0x2d29b5[r(1054)],_0x3bdca0[r(1085)+"et"],_0x24c83d[r(1062)+"th"])}else{G.isLong(t)||(t=G.fromNumber(t));let a=e.ntRPE(this[r(1070)],16),x=65535&this[r(1070)],f=e[r(572)](this.low,16),h=e[r(386)](65535,this[r(1454)]),w=t[r(1070)]>>>16,g=e[r(732)](65535,t.high),b=e[r(931)](t[r(1454)],16),v=e[r(386)](65535,t[r(1454)]),C=0,O=0,R=0,F=0;return F+=e.Zjnes(h,v),R+=e[r(915)](F,16),F&=65535,R+=e[r(746)](f,b),O+=R>>>16,R&=65535,O+=e[r(533)](x,g),C+=O>>>16,O&=65535,C+=e[r(746)](a,w),C&=65535,G[r(629)](e[r(1446)](R<<16,F),e[r(597)](C,16)|O,this[r(1381)])}}[n(902)](t){let r=n;return G[r(872)](t)||(t=G[r(764)+"er"](t)),e[r(1133)](this[r(1381)],t[r(1381)])&&e[r(1596)](e[r(1221)](this.high,31),1)&&e.qrmhn(t[r(1070)],31)===1?!1:this[r(1070)]===t[r(1070)]&&e[r(846)](this[r(1454)],t[r(1454)])}[n(552)](){let t=n;return this[t(1454)]===-1&&e.VcCdt(-1,this[t(1070)])?G[t(629)](0,0,this[t(1381)]):e[t(227)](-1,this[t(1454)])?G[t(629)](0,e[t(985)](this.high,1),this[t(1381)]):G[t(629)](e[t(1004)](this[t(1454)],1),this[t(1070)],this[t(1381)])}[n(1785)](t){let r=n;return t?this[r(1249)+"E"]():this[r(1136)+"E"]()}[n(1249)+"E"](){let t=n,r=this.high,a=this[t(1454)];return[255&a,e[t(263)](e[t(411)](a,8),255),e.KVkhV(e[t(645)](a,16),255),a>>>24,e[t(1352)](255,r),e[t(1221)](r,8)&255,e[t(366)](e[t(834)](r,16),255),e.dCxNh(r,24)]}[n(1136)+"E"](){let t=n,r=this.high,a=this.low;return[e[t(645)](r,24),e[t(1475)](e.jtrot(r,16),255),e[t(1488)](e[t(216)](r,8),255),e[t(366)](255,r),e[t(216)](a,24),e[t(1154)](a>>>16,255),e[t(571)](a>>>8,255),255&a]}}let Vi=new G(0,0,!1),Fc=new G(0,0,!0),Uc=G[n(629)](-1,2147483647,!1),qc=G[n(629)](-1,-1,!0),Hc=G[n(629)](0,-2147483648,!1);var Ze=(function(i){let t=n;return i[i[e[t(1406)]]=5001]=e.hYWnN,i[i[e[t(800)]]=5002]=e[t(800)],i[i[e[t(994)]]=5003]=e.pFqlB,i[i[e[t(473)]]=5004]=e[t(473)],i[i[e[t(1376)]]=5005]=e[t(1376)],i})({});class bt{constructor(t){let r=n;this.type=t,this[r(1134)]=null}}class Yi extends bt{constructor(t,r){let a=n;super(t),this[a(1697)]=r&&r[a(1697)]||null}}class Xi extends bt{constructor(t,r){let a=n,x=e[a(1341)].split("|"),f=0;for(;;){switch(x[f++]){case"0":this[a(321)]=r&&r.error||null;continue;case"1":this.filename=r&&r.filename||"";continue;case"2":this[a(1697)]=r&&r[a(1697)]||"";continue;case"3":this[a(937)]=r&&r.lineno||0;continue;case"4":super(t);continue;case"5":this[a(1140)]=r&&r.colno||0;continue;case"6":this[a(1532)]=r&&r[a(1532)]||5001;continue}break}}}class Qi extends bt{constructor(t,r){let a=n,x={HKlaD:function(f,h,w){return f(h,w)},rVIJE:function(f){return e[k(1689)](f)},AmkrN:function(f,h,w){return e[k(365)](f,h,w)},cSzWs:function(f,h){return e.wRshH(f,h)}};if(e[a(1011)]===e[a(1011)]){let f=e[a(1636)].split("|"),h=0;for(;;){switch(f[h++]){case"0":this.reason=r&&r[a(723)]||"";continue;case"1":super(t);continue;case"2":this.code=r&&r[a(1532)]||0;continue;case"3":this[a(1432)+a(287)]=r&&r[a(1432)+a(287)]||!1;continue;case"4":this[a(1587)]=r&&r.wasClean||!1;continue}break}}else{cwcUjk[a(329)](_0x384fff,_0x4a0f3a,42);let f=cwcUjk[a(281)](_0x4ffe0a);cwcUjk[a(329)](_0x39d82e,_0x13e119,f),cwcUjk[a(1460)](_0x324db3,_0x587a34,f.limit),_0x5246e2(_0x4dbf76,f),cwcUjk.cSzWs(_0x737f68,f)}}}class Zi extends bt{constructor(t,r){let a=n;if(e[a(502)](e[a(499)],e.arJQq))super(t),this[a(1661)]=r&&r[a(1661)]||null;else return new _0x506ca9(_0x562cf7,{data:_0x51a9a0})}}class es extends Zi{constructor(t,r){let a=n;super(t),this[a(1661)]=r&&r[a(1661)]||null,this.message=r&&r[a(1697)]||null}}class ts extends bt{constructor(t,r){let a=n;super(t),this[a(1661)]=r&&r[a(1661)]||null}}function Ie(i,{message:t,code:r,error:a}){return new Xi(i,{message:t,code:r,error:a})}function De(i,{code:t,reason:r,wasClean:a,willReconnect:x}){return new Qi(i,{code:t,reason:r,wasClean:a,willReconnect:x})}function ns(i,{data:t,message:r}){let a=n,x={weHml:function(f,h){return e.Najbj(f,h)},PUDcG:e[a(1712)]};if(e[a(1230)]!==e[a(1084)])return new es(i,{data:t,message:r});if(_0x48e302)return new _0x44e7f3(_0xa590fd[a(1781)],_0x11f697[a(1408)]);if(x[a(1330)](_0x3a37c6,_0x50654f))return new _0x2fcea8(_0x2c1a30[a(1781)],_0x4b71c0[a(1408)],_0xbd76c8[a(951)]);if(x[a(1330)](_0xcb1442,_0x554326)&&x[a(492)]!=typeof _0x14a1ee&&_0x567c99)return new _0xebee8e(_0x125bc5.url,_0x1ea8a8.protocols)}function rs(i,{data:t}){return new ts(i,{data:t})}function Rr(i,{message:t}){return new Yi(i,{message:t})}class is{constructor(t,r){let a=n,x={NSIjW:function(f,h){return e[k(1596)](f,h)},wuOFY:e[a(1214)],UMFmE:function(f,h){return e.ktGgA(f,h)},dtrNr:function(f,h){return f+h},MmWGO:a(1150)+a(1433),FmDXs:function(f,h){return e.fOzds(f,h)},gQmfx:function(f,h){return e.ELJdu(f,h)}};if(e[a(855)]!==e[a(855)]){let f=this[a(1750)+"rs"][_0x207960];if(f)f[a(1424)]()[a(1519)](h=>h.fn[a(1063)](h[a(419)],_0x29e240));else if(x[a(1693)](x.wuOFY,_0x227c35)&&!this.onerror){let h=_0x2343aa.length&&_0x206dd4[0];if(x[a(376)](h,_0x3d744a))throw h;let w=new _0x2e1ef3(x[a(1643)](x[a(1726)],h?x[a(946)](x.gQmfx(" (",h[a(1697)]),")"):""));throw w[a(446)]=h,h}return this}else this[a(464)+"s"]=t,this[a(1032)+"es"]=r,this[a(756)+a(1471)]=0,this[a(285)+a(327)+"riesCount"]=0}[n(226)+n(404)+"fig"](){let t=n,r={vPYIO:function(a,x,f){return a(x,f)},qOUpC:function(a,x){return e[k(1438)](a,x)},oBoPx:function(a,x){return e[k(842)](a,x)}};if(t(482)!==t(482)){let a=0,x=_0x15824d,f=_0x169cda+4;for(;x<f;){let{value:h,offset:w}=r.vPYIO(_0x363b4e,_0x4258ae,x);x=w,a=r[t(394)](r[t(1028)](a,8),0),a+=h}return{value:a,offset:f}}else this[t(756)+t(1471)]=0,this[t(285)+"ndpointT"+t(1522)+"t"]=0}resetTries(){let t=n;this[t(285)+t(327)+t(1522)+"t"]=0}[n(695)+n(1180)+"nt"](){let t=n;return this[t(464)+"s"][this[t(756)+"ndex"]]}[n(695)+n(1180)+"ntTriesC"+n(1053)](){let t=n;return this["currentE"+t(327)+t(1522)+"t"]}[n(874)+"chMaxTries"](){let t=n;return!!(e[t(1289)](this["currentI"+t(1471)],this[t(464)+"s"][t(796)])||e[t(236)](this.currentIndex,e[t(1526)](this[t(464)+"s"][t(796)],1))&&this[t(285)+"ndpointT"+t(1522)+"t"]===this[t(1032)+"es"])}["checkCurrentEndp"+n(345)+n(325)+n(1055)](){let t=n;if(e.gzVnK(t(876),"VsvIk"))this[t(657)](_0x302b7c,_0x59e9c9);else return this[t(756)+t(1471)]==this[t(464)+"s"][t(796)]?!0:e.SFxCa(this["currentE"+t(327)+t(1522)+"t"],this[t(1032)+"es"])}[n(286)+n(1445)+n(1624)+"UpdateCo"+n(825)](){let t=n,r={EGsas:function(a,x){return e[k(1568)](a,x)}};if(e[t(771)]!==e[t(771)])eVpmRq[t(1311)](_0x402e66,eVpmRq.EGsas(_0x60e083,_0x47ae1f[t(679)])),_0x3dcbbe();else return this[t(285)+t(327)+t(1522)+"t"]=1,this.currentIndex++,this[t(464)+"s"][this[t(756)+"ndex"]]}["getCurre"+n(1180)+n(459)+n(600)](){let t=n;return this[t(285)+t(327)+t(1522)+"t"]++,this[t(695)+t(1180)+"nt"]()}}let vt=(e[n(1201)](e[n(1712)],typeof globalThis)&&e[n(456)]===globalThis.constructor.name||e.IRDTh!=typeof window&&e[n(1652)](e[n(456)],window[n(379)+"tor"][n(310)]))&&e.picLB(e[n(1712)],typeof document),ut=e[n(740)](e[n(1712)],typeof globalThis)&&(e[n(747)]===globalThis["construc"+n(1492)][n(310)]||e.oAVAm(e[n(575)],globalThis[n(379)+n(1492)][n(310)]))&&e[n(1201)](e.IRDTh,typeof tt),jt=(e[n(835)](e[n(1712)],typeof globalThis)&&e[n(1188)](e[n(747)],globalThis["construc"+n(1492)][n(310)])||e.tWTOO(e[n(1712)],typeof globalThis)||e[n(1712)]!=typeof globalThis&&!!globalThis[n(1705)+"Bridge"])&&e.UIAZu(e.IRDTh,typeof wx),Kt=e[n(1435)](e[n(1712)],typeof globalThis)&&(e[n(1023)](n(258)+n(753)+n(1462)+"pe",globalThis[n(379)+n(1492)][n(310)])||e.VcDTw(n(1692)+n(909)+n(1653),globalThis[n(379)+n(1492)].name)||e[n(1165)](e[n(1037)],globalThis["construc"+n(1492)][n(310)]))&&e.MyIFR(e.IRDTh,typeof self),jc=e[n(450)](e.IRDTh,typeof globalThis)&&e[n(747)]===globalThis[n(379)+n(1492)][n(310)]&&e[n(742)](e.IRDTh,typeof global)&&e[n(747)]===global[n(379)+"tor"][n(310)]&&e[n(1435)](e[n(1712)],typeof process)&&!!process[n(1515)];class Lr{constructor(){let t=n;e[t(328)](e.LEVLa,e[t(1093)])?this[t(1750)+"rs"]={}:(this[t(872)]=!0,this.low=0|_0x223b4b,this[t(1070)]=e[t(1463)](0,_0x19b3d5),this[t(1381)]=!!_0x138753)}[n(1216)](t,...r){let a=n,x=this._listeners[t];if(x)x[a(1424)]()[a(1519)](f=>f.fn[a(1063)](f.ctx,r));else if(e.okwUm(a(321),t)&&!this[a(440)]){let f=r[a(796)]&&r[0];if(e[a(457)](f,Error))throw f;let h=new Error(e[a(1374)](e[a(215)],f?e[a(1280)](e[a(368)](" (",f[a(1697)]),")"):""));throw h[a(446)]=f,f}return this}[n(657)](t,r){let a=n;if(t===void 0)this[a(1750)+"rs"]={};else if(e[a(1486)](void 0,r))this[a(1750)+"rs"][t]=null;else if(e.RXaMB(e.OTgtC,e[a(1283)])){let x=this._listeners[t];if(x)for(let f=0;e[a(995)](f,x[a(796)]);)e[a(1023)](x[f].fn,r)?x.splice(f,1):++f}else _0xf3c3.resolve()[a(317)](()=>{this[a(718)+"steners"]()});return this}on(t,r,a){let x=n;return(this._listeners[t]||(this[x(1750)+"rs"][t]=[]))[x(1774)]({fn:r,ctx:a||this}),this}}class Kc extends Lr{[n(1015)+n(602)+n(1122)](t){let r=n;return t[r(1049)]||t.errNo?(r(271)+" "+(t[r(1049)]||"")+r(1290)+(t[r(1220)]||""))[r(274)]():JSON[r(1577)+"y"](t)}constructor(t,r,a){let x=n;super(),this[x(958)]=null,jt&&wx[x(525)+x(1592)]&&(this[x(958)]=wx[x(525)+x(1592)]({url:t,protocols:r,header:a,fail:this[x(1461)+"ocketFai"+x(565)][x(854)](this),success:this["_createS"+x(1590)+"cessHand"+x(359)].bind(this)})),ut&&tt[x(525)+x(1592)]&&(this[x(958)]=tt[x(525)+x(1592)]({url:t,protocols:r,header:a,fail:this[x(1461)+x(1711)+x(565)][x(854)](this),success:this[x(1461)+x(1590)+x(255)+x(359)].bind(this)}))}[n(1461)+"ocketSuc"+n(255)+n(359)](){let t=n;Promise[t(1143)]()[t(317)](()=>{let r=t,a={ufczK:function(x,f){return x|f},qTEiY:function(x,f){return x&f},ZoVWl:function(x,f){return e[k(964)](x,f)},xeXsV:function(x,f){return e[k(839)](x,f)},qEbcA:function(x,f){return x>>f},kUdXB:function(x,f){return x|f},IUeln:function(x,f){return x>>f},tsQnp:function(x,f){return x|f},JdczC:function(x,f){return e[k(945)](x,f)}};e[r(1429)]===r(1285)?(_0x3134a5<2048?_0x379969[_0x39894b++]=JqBswd[r(1205)](_0x236734>>6&31,192):(_0x2e17ec<65536?_0x3b2084[_0x5639a4++]=JqBswd[r(484)](JqBswd[r(1219)](_0x5b0c5f,12),15)|224:(_0x20b195[_0x406a5e++]=JqBswd[r(826)](JqBswd[r(484)](JqBswd[r(1401)](_0x5b2c51,18),7),240),_0x1dd279[_0x1733ea++]=JqBswd.kUdXB(JqBswd.IUeln(_0x1bcd3e,12)&63,128)),_0x43cd06[_0x1b1166++]=JqBswd[r(1640)](JqBswd[r(484)](_0x448382>>6,63),128)),_0x5444ba[_0x384e09++]=JqBswd.JdczC(JqBswd[r(484)](63,_0x17b301),128)):this[r(718)+r(1195)]()})}[n(1461)+n(1711)+"lHandler"](t){let r=n,a={EUdkz:function(x,f,h){return e[k(1741)](x,f,h)},Ncrof:e[r(1214)],hxnMz:e[r(587)]};e[r(1627)](e[r(1281)],e[r(978)])?(_0x1ae29d[r(692)+r(1422)]=void 0,e[r(758)](_0x218ae3,e[r(765)])):Promise[r(1143)]()[r(317)](()=>{let x=r,f=a[x(616)](Ie,x(321),{message:this[x(1015)+x(602)+"age"](t)});this[x(1216)](a[x(1087)],f);let h=De(a.hxnMz,{reason:this[x(1015)+x(602)+x(1122)](t)});this[x(1216)]("close",h)})}[n(718)+"steners"](){let t=n,r={PivNj:function(a,x,f){return e[k(1759)](a,x,f)},wWHJL:function(a,x){return e[k(927)](a,x)},iLfQT:function(a,x){return e[k(995)](a,x)},yBiHC:function(a,x){return e[k(307)](a,x)},Dpucr:function(a,x){return a<x},WJpdM:function(a,x){return a<=x},PgLgz:function(a,x){return a>=x},rifex:function(a,x){return a|x},UXBYR:function(a,x){return a<<x},hlcxN:function(a,x){return e[k(205)](a,x)},DaALv:function(a,x){return a<<x},GbUNo:function(a,x){return e[k(1476)](a,x)},NyAoU:function(a,x){return e.WkEjK(a,x)},PLqDP:function(a,x){return a+x},muwYZ:e.FnxYW,nRPvf:e[t(863)],YttNq:function(a,x,f){return e[t(1759)](a,x,f)},Gdyxi:e[t(587)],quHEO:function(a,x,f){return a(x,f)}};if(e[t(332)](t(1623),e[t(1158)])){if(this[t(289)]&&this._ws[t(201)+"te"]===this[t(1579)+"NG"]){this[t(375)+t(1189)](),this[t(377)+"gTimeoutId"]=r[t(1384)](_0x4ff9ab,this[t(1481)].bind(this),this[t(388)][t(318)+t(316)]);return}if(!this[t(289)]||r[t(1620)](this[t(289)].readyState,this[t(1664)]))return void this[t(1092)+t(1345)]();this[t(289)]&&this._ws[t(530)]("hi"),this[t(1511)+"ctTimeou"+t(1421)]=r[t(1384)](_0x19a082,this[t(1092)+t(1345)+t(1763)][t(854)](this),this[t(388)][t(1547)+t(793)+t(476)])}else this[t(958)][t(279)](a=>{let x=t,f={Gkhcc:function(h,w){return r[k(1675)](h,w)},bUNPa:function(h,w){return r[k(675)](h,w)},RFXXd:function(h,w){return r.Dpucr(h,w)},PCGeZ:function(h,w){return r.WJpdM(h,w)},KLRPt:function(h,w){return r[k(1423)](h,w)},gJPld:function(h,w){return r[k(224)](h,w)},ADPFm:function(h,w){return r[k(1002)](h,w)},ZJxsy:function(h,w){return r[k(1404)](h,w)},jmInp:function(h,w){return r.DaALv(h,w)},VidbI:function(h,w){return h|w},SQNrU:function(h,w){return r[k(417)](h,w)},GBEqy:function(h,w){return h<<w},TLxjg:function(h,w){return r.NyAoU(h,w)},KppDU:function(h,w){return r[k(836)](h,w)}};if(r.wWHJL(r[x(222)],x(351)))this[x(1216)](r[x(638)],r[x(314)](rs,r[x(638)],{...a,data:a[x(1049)]||""}));else{if(f[x(1464)](f[x(646)](_0x6d6371,_0x581027),1))return"";let h="";for(let w=_0x54cc0e;f[x(1500)](w,_0x1eb4b0);){let g=_0x3682ef[w++];if(f[x(843)](g,127))h+=_0x12ae46[x(861)+x(1700)](g);else if(f[x(1688)](g,192)&&f.Gkhcc(g,224))h+=_0x306656[x(861)+x(1700)](f[x(1199)](f[x(1525)](31&g,6),f[x(480)](63,_0x2dced2[w++])));else if(f[x(1688)](g,224)&&f[x(1464)](g,240))h+=_0x4b71a8[x(861)+"Code"](f[x(1199)](f[x(1199)](f[x(1525)](15&g,12),f[x(918)](63&_0x2960f2[w++],6)),f[x(480)](63,_0x3ccf84[w++])));else if(f[x(1688)](g,240)){let b=f[x(646)](f[x(894)](f[x(1525)](f[x(1448)](7,g),18),f[x(196)](f[x(1448)](63,_0x3d8ec7[w++]),12))|f[x(1525)](63&_0x35f6d9[w++],6)|f[x(480)](63,_0x20d240[w++]),65536);h+=_0x1d83c4[x(861)+"Code"](55296+f.TLxjg(b,10)),h+=_0x18d7c6[x(861)+"Code"](f[x(503)](56320,f[x(1448)](1023,b)))}}return h}}),this[t(958)].onClose(a=>{let x=t;this[x(1216)](r[x(1709)],r[x(847)](De,r[x(1709)],{...a}))}),this[t(958)].onMessage(a=>{let x=t;this.emit(e[x(1284)],e[x(1732)](ns,e[x(1284)],{...a}))}),this[t(958)][t(1260)](a=>{let x=t;this[x(1216)](x(321),Ie(x(321),{...a,message:a[x(1049)]||""}))})}send(t){let r=n,a={cnSQO:r(321),vAToI:function(x,f,h){return e.IhUIJ(x,f,h)}};if(t instanceof Uint8Array){let x=t[r(1054)][r(1424)](t[r(1085)+"et"],e[r(1558)](t[r(1062)+"th"],t.byteOffset));this[r(958)]&&this._socket[r(530)]({data:x,fail:f=>{let h=r;this[h(1216)](e[h(1214)],Ie(h(321),{message:this[h(1015)+h(602)+h(1122)](f)}))}})}else this[r(958)]&&this[r(958)].send({data:t,fail:x=>{let f=r;this[f(1216)](a[f(1632)],a[f(868)](Ie,a[f(1632)],{message:this[f(1015)+f(602)+f(1122)](x)}))}})}[n(1360)](t,r){this._socket&&this._socket.close({code:t,reason:r})}[n(884)+n(1425)](t,r){this.on(t,r)}[n(605)+"entListe"+n(396)](t,r){this[n(657)](t,r)}get[n(201)+"te"](){let t=n;return this[t(958)][t(201)+"te"]}get[n(1704)+"pe"](){return this[n(958)].binaryType}set[n(1704)+"pe"](t){}get[n(1781)](){return this[n(958)].url}get[n(1408)](){let t=n;return this._socket[t(1408)]}get[n(1617)+"ns"](){let t=n;return this._socket[t(1617)+"ns"]}get[n(891)+"Amount"](){return 0}}function Gc(i,t){let r=n;if(t)return new t(i.url,i[r(1408)]);if(e[r(789)](jt,ut))return new Kc(i.url,i[r(1408)],i.headers);if(e[r(789)](vt,Kt)&&r(1631)+"d"!=typeof WebSocket&&WebSocket)return new WebSocket(i[r(1781)],i.protocols)}function Wc(i){let t=n,r=e[t(650)][t(1413)]("|"),a=0;for(;;){switch(r[a++]){case"0":if(i)return!0;continue;case"1":if(ut&&tt[t(525)+t(1592)])return!0;continue;case"2":if(e[t(789)](vt,Kt)&&e.IRDTh!=typeof WebSocket&&WebSocket)return!0;continue;case"3":if(jt&&wx[t(525)+t(1592)])return!0;continue;case"4":return!1}break}}function ss(i,t,r){let a=n,x={ZkgLA:function(f,h){return e[k(337)](f,h)},JepZI:function(f,h){return f===h},GNunv:function(f,h){return e[k(447)](f,h)}};if(e[a(400)](e[a(1334)],e[a(1334)])){let f=-1;async function h(w){let g=a;return x[g(1138)](w,f)?Promise[g(439)](new Error("next() called mu"+g(1742)+"imes in "+g(1248))):(f=w,x[g(319)](w,r.length)?Promise[g(1143)]():r[w][g(854)](i)(t,h[g(854)](null,x[g(581)](w,1))))}e[a(758)](h,0)}else return _0xc87e73&&e.WISDf(!0,_0x432389.isLong)}function os(i){let t=n,r=0,a=0;for(let x=0;e.WxWSB(x,i[t(796)]);++x)a=i[t(1380)+"At"](x),e[t(585)](a,128)?r+=1:e[t(1442)](a,2048)?r+=2:e[t(1098)](64512,a)===55296&&e.uIoLH(e.rSztB(64512,i[t(1380)+"At"](e.vdjPt(x,1))),56320)?(++x,r+=4):r+=3;return r}function as(i,t,r){let a=n;if(e.FIFVL(e[a(606)](r,t),1))return"";let x="";for(let f=t;e[a(555)](f,r);){let h=i[f++];if(e.NXKss(h,127))x+=String["fromChar"+a(1700)](h);else if(e[a(415)](h,192)&&e.hYsKK(h,224))x+=String[a(861)+a(1700)](e[a(1052)](e[a(1703)](31,h)<<6,e[a(1373)](63,i[f++])));else if(e[a(1246)](h,224)&&e[a(1224)](h,240))x+=String.fromCharCode(e[a(1645)](e.iIYgr((15&h)<<12,e[a(382)](e[a(577)](63,i[f++]),6)),63&i[f++]));else if(h>=240)if(e[a(1094)](e[a(383)],e.HqKEk)){let w=e[a(1372)](e[a(1372)](e[a(1181)](7&h,18),e.mqHtZ(63&i[f++],12))|e[a(253)](e[a(1614)](63,i[f++]),6),e[a(1043)](63,i[f++]))-65536;x+=String[a(861)+a(1700)](55296+e[a(964)](w,10)),x+=String[a(861)+"Code"](e.SmfAX(56320,e.UrDnl(1023,w)))}else return _0x40cfef[a(872)](_0x3544e3)||(_0x2004aa=_0x30f9a7[a(764)+"er"](_0x2a99fe)),e[a(1489)](this[a(1381)],_0x3a38a2[a(1381)])&&e[a(250)](e[a(1259)](this.high,31),1)&&e[a(851)](_0x304f21[a(1070)],31)===1?!1:this[a(1070)]===_0x351219[a(1070)]&&e[a(328)](this[a(1454)],_0x56f35a[a(1454)])}return x}function Or(i,t,r){let a=n,x={yUpPj:function(g,b){return e[k(470)](g,b)},LFwrf:function(g,b){return g>=b},jCPqb:function(g,b){return e[k(635)](g,b)},tVaMD:function(g,b){return e.ccjrd(g,b)},RsOGo:function(g,b){return e.lUjCO(g,b)},xfmQW:function(g,b){return g/b}},f=r,h,w;for(let g=0;e.FIFVL(g,i[a(796)]);++g)if(e[a(787)]===e[a(787)])if(h=i[a(1380)+"At"](g),e[a(1468)](h,128))t[r++]=h;else if(h<2048)t[r++]=e[a(1179)](e[a(1231)](h,6),192),t[r++]=e[a(350)](e.FQrNb(63,h),128);else if(e[a(291)](e[a(1576)](64512,h),55296)&&e[a(1159)](e.IxSuT(64512,w=i[a(1380)+"At"](e[a(775)](g,1))),56320)){let b=e.gxRXI[a(1413)]("|"),v=0;for(;;){switch(b[v++]){case"0":t[r++]=e.uvHcg(h>>18,240);continue;case"1":t[r++]=e[a(350)](e[a(1703)](h>>12,63),128);continue;case"2":t[r++]=e[a(412)](e.EYUBI(63,h),128);continue;case"3":h=e[a(1042)](e[a(533)](65536,e[a(1203)](e[a(940)](1023,h),10)),1023&w);continue;case"4":t[r++]=e.LcysV(e[a(975)](h>>6,63),128);continue;case"5":++g;continue}break}}else if(a(1258)===e[a(707)])t[r++]=e[a(453)](e[a(1545)](h,12),224),t[r++]=e.EOkxY(e[a(1619)](e[a(1231)](h,6),63),128),t[r++]=e.GuYBs(e[a(571)](63,h),128);else{if(QfbbKs[a(1615)](_0x154858,_0x49091c))return _0x5c5dc4?_0x4a7956:_0x2e45bf;if(_0x384a20){if(QfbbKs[a(702)](_0x10af83,_0x43bb77))return _0x48470c}else{if(_0x111a21<=-_0x8463b8)return _0x18b515;if(QfbbKs[a(702)](QfbbKs.jCPqb(_0x2a291b,1),_0x115ad9))return _0x52b121}return _0x1a7aff.fromBits(QfbbKs[a(1236)](QfbbKs[a(892)](_0x208187,_0x136a3b),0),QfbbKs[a(1236)](QfbbKs[a(1784)](_0x1bb35c,_0x31674a),0),_0x118348)}else{let b=this[a(240)+a(302)]?.[a(695)+a(1180)+"nt"]();this._debug(a(1123)+b+a(1038)),this["_disconn"+a(1717)](1001,a(1071)+a(391)+a(549)+"g",!0)}return e.evZjp(r,f)}async function cs(i){let t=n;if(e[t(1301)](e.UaeLL,typeof i)){let r=new Uint8Array(os(i));return e[t(526)](Or,i,r,0),r}return e[t(862)](i,ArrayBuffer)?new Uint8Array(i):new Uint8Array(i[t(1054)],i.byteOffset,i[t(1062)+"th"])}function Jc(i){let t=n,r={wktIs:function(a,x){return e[k(1346)](a,x)},DNyzl:function(a,x){return e[k(1196)](a,x)},oLpjh:function(a,x){return e[k(1760)](a,x)},NYxON:function(a,x){return a<<x},lyyjK:function(a,x){return e[k(779)](a,x)},HzoZi:function(a,x){return e[k(1314)](a,x)},MGvIa:function(a,x){return a>x},ezSfa:function(a,x,f){return e[k(355)](a,x,f)},EDQhO:function(a,x){return e[k(1280)](a,x)},JUckI:function(a,x){return a>>x},MSVKt:function(a,x){return e.vPuiZ(a,x)}};try{return t(1253)===e[t(682)]?e[t(1510)]("string",typeof i)&&(e[t(534)](i,ArrayBuffer)||i[t(1054)]&&i[t(1054)]instanceof ArrayBuffer)||e[t(835)](e[t(980)],typeof i)?"":(JSON.parse(i),e.xQelJ):void 0}catch{if(e.ccwBZ(e.Jtxnb,"tfvTJ"))return t(410)==typeof i?"text/plain;charset=utf-8":"";_0x516a4a=OpbALI[t(761)](OpbALI[t(761)](OpbALI[t(1562)]((7&_0x3b8b52)<<18,OpbALI[t(560)](63&_0x5a8ff3,12)),OpbALI[t(371)](OpbALI.lyyjK(63,_0x5f27fa),6)),OpbALI[t(987)](63,_0x5d31d3)),OpbALI[t(437)](_0x4c4603,65536)||OpbALI[t(1560)](_0x199525,1114111)?_0x57bf65+=_0x477344:(_0x360dbd-=65536,_0xd0efa5+=OpbALI[t(1618)](_0x845a47,OpbALI[t(790)](OpbALI.JUckI(_0x59cb24,10),55296),OpbALI[t(944)](OpbALI.lyyjK(1023,_0x3ab7f9),56320)),_0x40016c+=3)}}let $c=(i,t)=>{let r=n,a={tmbIw:function(x,f){return e.SFFXa(x,f)},HOHwU:e[r(870)],nhzgi:r(1723)+r(1209)+"s"};if(e[r(1567)](r(1237),e[r(1304)]))switch(i){case e.GWBtw:case e[r(1022)]:return{[r(1051)+i]:1,"x-tt-env":t};default:return{}}else a[r(1080)](_0xffd24f,a[r(713)]),Y[r(657)](a[r(1112)],_0x3fb4a9),Y[r(657)](r(1723)+r(802)+"t",_0x2f9ce3)};class Vc{constructor(t){let r=n;this[r(1603)+r(1053)]=t,this.count=0}[n(614)](){this.count++}["checkRea"+n(1245)+"nt"](){let t=n,r={TroCA:function(a,x){return e[k(1023)](a,x)},ICmRn:function(a,x){return e[k(1596)](a,x)},qIvcf:function(a,x){return e[k(827)](a,x)},eAMml:function(a,x){return e[k(332)](a,x)}};if(e[t(1627)](t(451),e.ndHgx))return e.lQtqS(this[t(1271)],this[t(1603)+t(1053)]);if(nEtWUR[t(1608)](void 0,_0x444857))this[t(1750)+"rs"]={};else if(nEtWUR.ICmRn(void 0,_0x170c9b))this[t(1750)+"rs"][_0x3794c2]=null;else{let a=this[t(1750)+"rs"][_0x37511c];if(a)for(let x=0;nEtWUR[t(259)](x,a[t(796)]);)nEtWUR.eAMml(a[x].fn,_0x566f91)?a[t(1074)](x,1):++x}return this}[n(971)+n(1321)](t=0){let r=n;this[r(1603)+r(1053)]=t,this[r(1271)]=0}}async function Yc(i){let t={RvlvW:e.xwpiu};return new Promise(r=>{let a=k;if(!vt)return e[a(1447)](r,"unknown "+a(723));try{let x=document[a(1326)+"ement"](e[a(1694)]);window[a(692)+a(1422)]=f=>{let h=a;document[h(232)][h(435)+h(477)](x),window["frontier"+h(1422)]=void 0,r(f&&f[h(1565)]||t[h(808)])},x[a(1737)]=a(1770)+a(1716),x.src=e[a(1607)](i[a(1212)](/^ws/,a(744)),e[a(1443)]);try{document.body[a(1132)+"ild"](x)}catch{document[a(232)][a(435)+"ild"](x)}}catch{window[a(692)+a(1422)]=void 0,r(e[a(765)])}})}function et(i,t,r){let a=n;return!!i?.find(x=>x[a(1642)]===t&&x[a(916)]===r)}function St(i,t){let r=n;return i?.[r(601)](a=>a[r(1642)]===t)?.[r(916)]}let Nr=null;async function Xc(){let i=n;if(e[i(1444)]!==e[i(1099)])return Nr||(Nr=Promise[i(1143)]()[i(317)](Fe[i(854)](Fe,e.aGYhe))),Nr;this[i(1111)+"lTimeoutId"]=null,this[i(1111)+"l"]=36e5,this._qosDB=e[i(365)](_0x38a16a,e[i(1024)],e[i(1761)])}class Qc extends Lr{constructor(t,r){let a=n;super(),this[a(962)]=t,this[a(1127)]=r,this[a(524)]=void 0,this[a(725)+a(848)]=null}async[n(875)](){let t=n;if(e[t(432)](t(1130),e[t(1520)]))await this._init();else return new _0x3e7963(_0x16521a,{data:_0x28c89c,message:_0x2d0f94})}async[n(1168)](){let t=n,r={qLVae:function(a){return a()}};if(e.oQfEr("vQvis",e[t(687)])){let a=this[t(240)+t(302)]?.[t(695)+t(1180)+"nt"]();this[t(1225)](t(214)+a),r[t(1016)](_0x19c8bd)}else{if(this._qosDB)return;if(this[t(725)+t(848)])return this[t(725)+t(848)];try{let a=this[t(962)],x=this[t(1127)];this[t(725)+t(848)]=(async()=>{let f=t,{openDB:h}=await Xc();this[f(524)]=await h(f(692)+"_"+a,1,{upgrade(w){let g=f;w[g(1644)+g(1368)+"e"](a,{keyPath:x})}})})(),await this[t(725)+t(848)]}catch(a){console[t(905)](a)}finally{this["_initPro"+t(848)]=null}}}async[n(1657)](t){let r=n;try{return await this[r(1168)](),this._qosDB?.get(this[r(962)],t)}catch(a){if(e[r(782)](r(1116),e.yEtUz)){if(e[r(337)](_0x495339,-_0x31d390))return _0x51b577;if(e[r(1306)](_0x12067b+1,_0x4266ce))return _0x5d8e09}else console[r(905)](a)}}async[n(1651)](t,r){let a=n;return await this[a(1168)](),this[a(524)]?.[a(1680)](this[a(962)],t)}async del(t){let r=n;try{return await this._init(),this[r(524)]?.[r(989)](this[r(962)],t)}catch(a){console.log(a)}}async clear(){let t=n;try{return await this[t(1168)](),this._qosDB?.[t(726)](this._dbName)}catch(r){console[t(905)](r)}}async[n(1561)](){let t=n;return await this[t(1168)](),this._qosDB?.[t(311)+"ys"](this[t(962)])}async[n(1398)](){let t=n;if(e[t(1666)](t(539),e[t(1701)])){let r=this[t(240)+t(302)]?.[t(695)+t(1180)+"nt"]();this[t(443)+t(358)+t(1434)](e.LRIoT(_0x50f0ae,"close",{code:1006,reason:t(1123)+r+(t(1038)+t(1186)+t(1272)+t(1418)),wasClean:!0}))}else return await this[t(1168)](),this._qosDB?.getAll(this[t(962)])}async[n(938)](){let t=n;try{if(e[t(709)](e[t(1273)],e[t(1239)]))return this[t(958)][t(1408)];this[t(524)]?.[t(1360)](),this[t(524)]=void 0}catch(r){console[t(905)](r)}}get isReady(){let t=n;if(e[t(935)](e[t(562)],e[t(588)]))try{return!!this[t(524)]}catch(r){return console[t(905)](r),!1}else return _0xcd8789[_0x33c0f5]=_0xbe5ada,!0}}class Zc{constructor(t,r){let a=n;this[a(1262)]=t,this[a(1006)]=r,this._qosDB=localStorage}async openDB(){}get[n(1479)](){let t=n;return t(692)+"_"+this[t(1262)]}async[n(1657)](t){let r=n,a=this[r(524)][r(1145)](this[r(1479)]);return JSON[r(636)](e[r(1744)](a,"{}"))[t]}async[n(1651)](t,r){let a=n,x=this._qosDB[a(1145)](this[a(1479)]),f=JSON[a(636)](e[a(468)](x,"{}"));return f[r||t[this[a(1006)]]]=t,this[a(524)].setItem(this[a(1479)],JSON[a(1577)+"y"](f)),r||t[this[a(1006)]]}async[n(1414)](t){let r=n,a=this[r(524)][r(1145)](this[r(1479)]),x=JSON[r(636)](a||"{}");return x[t]=void 0,this._qosDB.setItem(this[r(1479)],JSON[r(1577)+"y"](x))}async[n(726)](){let t=n;return this[t(524)][t(726)]()}async[n(1561)](){let t=n,r={gqhOQ:function(a,x,f){return e[k(1739)](a,x,f)},PvRVH:e[t(1226)]};if(e[t(567)]!==e.uNhrz){let a=this[t(524)][t(1145)](this[t(1479)]),x=JSON[t(636)](e[t(472)](a,"{}"));return Object.keys(x)}else this[t(1415)+t(1484)]=_0xf97be2,this[t(1250)+t(1777)]=_0x5de017,this[t(1537)+t(864)]=_0x3d62da,this[t(524)]=r[t(786)](_0x47765c,this[t(1415)+t(1484)],r[t(536)])}async[n(1398)](){let t=n;if(e.CweRD(e[t(363)],t(1001))){let r=this._qosDB[t(1145)](this._prefix),a=JSON[t(636)](r||"{}");return Object[t(442)](a)}else _0x28a631(Pqqzol.aVflX(_0x30a226,_0x2c9008[t(679)]),_0x8a2bf6[t(1622)+"on"],_0xc9398c[t(715)+"on"],Pqqzol[t(1400)](_0x5a4b51,_0x3f781c[t(1200)+"ion"]))}[n(938)](){return Promise[n(1143)]()}get isReady(){return!!this[n(524)]}}class e0{constructor(t,r){let a=n;this[a(1262)]=t,this[a(1006)]=r,this._qosDB=ut?tt:jt?wx:null}async[n(875)](){}get[n(1479)](){let t=n;if(e[t(1378)](e[t(1344)],e[t(1344)])){let r={DEUQj:function(a,x){return a(x)}};return function(...a){let x=t;return _0x573e7c[x(1063)](r[x(1593)](_0x431dc0,this),a),r[x(1593)](_0x42a9c2,_0x307d42.get(this))}}else return t(692)+"_"+this[t(1262)]}async[n(1657)](t){let r=n,a=this[r(524)][r(421)+"geSync"](this[r(1479)]);return JSON.parse(a||"{}")[t]}async set(t,r){let a=n,x=this._qosDB["getStora"+a(1046)](this[a(1479)]),f=JSON[a(636)](e[a(791)](x,"{}"));return f[r||t[this[a(1006)]]]=t,this[a(524)][a(407)+a(1046)](this[a(1479)],JSON.stringify(f)),r||t[this._pathKey]}async[n(1414)](t){let r=n,a=this[r(524)]["getStora"+r(1046)](this._prefix),x=JSON[r(636)](e.wMoQE(a,"{}"));return x[t]=void 0,this[r(524)]["setStora"+r(1046)](this[r(1479)],JSON[r(1577)+"y"](x))}async clear(){let t=n;if(e[t(717)](e[t(1192)],t(1151)))_0x57df39[t(853)+"d"]&&(this[t(1332)+t(1343)]()&&(!this[t(289)]||e.rRVsx(this[t(289)][t(201)+"te"],this.OPEN)||this[t(289)][t(201)+"te"]!==this[t(1579)+"NG"])&&this[t(433)+t(818)](),this[t(626)+"er"]&&_0x498ffe[t(884)+t(1425)](e[t(688)],this[t(433)+t(818)]),this._isBrowser&&_0xb7a804["addEvent"+t(1425)](e[t(589)],this[t(433)+"ffLine"]));else return this[t(524)][t(693)+"rageSync"]()}async keys(){let t=n,r=this._qosDB[t(421)+"geInfoSync"](this[t(1479)]),a=JSON.parse(e.DvQNN(r,"{}"));return Object[t(1561)](a)}async getAll(){let t=n,r={cgqSI:function(a,x){return a(x)}};if(e[t(452)](e.aVjuY,e[t(1753)])){let a={wmwET:function(x,f){let h=t;return UNEhxy[h(922)](x,f)}};return function(x,...f){let h=t,w=_0x2343f3[h(1182)](a.wmwET(_0x375c61,this),x,...f);return _0x5542aa.set(w,x[h(1686)]?x[h(1686)]():[x]),a.wmwET(_0x27a079,w)}}else{let a=this[t(524)][t(421)+t(1313)+"nc"](this[t(1479)]),x=JSON[t(636)](e.QsKzm(a,"{}"));return Object[t(442)](x)}}[n(938)](){return Promise[n(1143)]()}get isReady(){return!!this[n(524)]}}function xs(i,t){let r=n;if(e[r(1482)](ut,ut))return new e0(i,t);if((vt||Kt)&&e[r(835)](e[r(1712)],typeof indexedDB))return new Qc(i,t);if(e[r(372)](vt,Kt)&&r(1631)+"d"!=typeof localStorage)return new Zc(i,t);throw new Error(e[r(516)])}class t0{constructor(){let t=n;this[t(1111)+t(1036)+"Id"]=null,this._interval=36e5,this[t(524)]=e[t(218)](xs,e[t(1024)],e.lKgmM)}async[n(1111)+n(559)](){let t=n;e[t(613)](clearInterval,this["_interva"+t(1036)+"Id"]),this[t(1111)+t(1036)+"Id"]=setInterval(()=>{let r=t;e[r(1003)](e[r(1124)],e[r(282)])?_0x37268c[r(1774)](_0x36f63a):this[r(1650)+"ired"]()},this[t(1111)+"l"])}async openDB(){let t=n;await this[t(524)][t(875)]()[t(317)](()=>{let r=t;this[r(1111)+r(559)]()})}async["flushExp"+n(1310)](){let t=n;(await this._qosDB?.[t(1398)]()||[])[t(208)](({timestamp:x})=>x<Date.now())[t(1519)](x=>{let f=t;this[f(524)]?.[f(1414)](x[f(1748)+"id"])})}async[n(1414)](t){let r=n;return this[r(524)]?.[r(1414)](t)}async[n(1651)](t,r){let a=n;return this[a(524)]?.[a(1651)]({message_id:t,timestamp:r})}async get(t){let r=n,a={hHrgG:function(x,f){return x<f},akawt:function(x,f){return e[k(1666)](x,f)},yBPNF:function(x,f){return e[k(593)](x,f)}};if(e[r(413)](e[r(990)],e[r(398)])){let x=_0x2fba9b[r(1413)](":");for(let f=0;XcrsHz[r(275)](f,x[r(796)]);f++){let h=x[f];if(XcrsHz.akawt(4,x[f][r(796)])){let w=_0x39a228[r(644)+"g"](0,XcrsHz[r(266)](4,x[f].length)),g=w[r(632)](h);_0x33c862=_0x309433[r(632)](g)}else _0x544c4f=_0x3c24a1.concat(h)}return _0x1cd123}else return this[r(524)]?.[r(1657)](t)}async closeDB(){let t=n;e.YtCcr(clearInterval,this["_interva"+t(1036)+"Id"]),await this._qosDB?.[t(938)]()}get isReady(){let t=n;return this[t(524)]?.[t(1303)]}}function Mr(i){let t=n,r=!!this[t(388)][t(1044)+"S"];if(!r)return{enabled:r,isQoSMessage:!1,isQoSAck:!1,isAckCleanupMessage:!1,ackMsgIds:[]};let a=et(i[t(1697)][t(951)],e.zzTwP,"2"),x=a&&e.fNWbs(et,i.message[t(951)],"x_fronti"+t(757)+"ck","1"),f=a&&et(i[t(1697)][t(951)],t(807)+t(301)+"k","1"),h=f?e[t(1649)](St,i.message[t(951)],e.AHVMX)?.[t(1413)](",").filter(Boolean)||[]:[];return{enabled:r,isQoSMessage:a,isQoSAck:x,isAckCleanupMessage:f,ackMsgIds:h}}async function ds(){let i=n;return this[i(409)+i(283)]||(this[i(409)+i(283)]=new t0),this[i(409)+i(283)].isReady||await this[i(409)+i(283)].openDB(),this[i(409)+"ger"]}async function n0(i,t){let r=n,a={JpOQL:function(g,b,v){return e.gQLJb(g,b,v)},nXjIu:e[r(587)]},{enableAutoAck:x}=this._options,f=et(i[r(1697)][r(951)],e[r(1766)],"1"),h=e[r(526)](et,i.message.headers,e.KyReS,"1"),w=Mr[r(1182)](this,i);if(e[r(261)](x,f))if(e.fHmHl(e[r(1039)],r(1365))){let g=this[r(240)+"tManager"]?.["getCurre"+r(1180)+"nt"](),b=this[r(388)][r(576)+"tInterce"+r(1768)](_0x259aaf.code,_0x35b365[r(723)]);this[r(443)+r(358)+"ent"](a[r(425)](_0x2520e5,a[r(631)],{code:1006,reason:_0x14ed81[r(723)]||r(1286)+r(1437)+r(798)+r(880)+r(1449)+r(373)+g,willReconnect:b})),b&&this[r(815)]();return}else{let{SeqID:g,LogID:b,service:v,LogIDNew:C,method:O}=i[r(1697)];this[r(1363)]({SeqID:g,LogID:b,LogIDNew:C,service:v,method:O,headers:[{key:e.KyReS,value:"1"},{key:e.uTKdp,value:e[r(1377)](C,"")},{key:e.JeDpQ,value:"0"}]})}h&&!w.isQoSAck&&this[r(443)+"hAckMessageEvent"](i),t()}async function r0(i,t){let r=n,a={AGXjS:function(x,f){return e.vMCCt(x,f)},EFzyF:function(x,f){return e.DuuAb(x,f)},CsUDx:function(x,f,h){return x(f,h)}};if(e[r(1596)](r(1673),e[r(346)]))return FXTQdf[r(1338)](FXTQdf[r(461)](_0x752eea,8)[r(1453)]("0"),FXTQdf[r(691)](_0x566b83,_0x40c066,10)[r(1605)](2))[r(1424)](-8);this._debug(e[r(1325)],i[r(1697)]),t()}async function i0(i,t){let r=n,a=e[r(1597)](wt,await e[r(578)](cs,i.data));try{if(e.IeGpt(a[r(1097)],Uint8Array)){let x=e[r(862)](this[r(388)]["payloadE"+r(850)],Object)?{force:!!this[r(388)][r(900)+"ncoding"][r(1347)],encoding:this[r(388)][r(900)+r(850)][r(1323)]?this[r(388)]["payloadE"+r(850)][r(1323)][r(1212)](/\s/g,"")[r(204)+r(1786)]():""}:{force:!1,encoding:this[r(388)].payloadEncoding?this._options["payloadE"+r(850)][r(1212)](/\s/g,"")["toLowerC"+r(1786)]():""},f=a["payloadE"+r(850)]?a[r(900)+r(850)].replace(/\s/g,"")[r(204)+r(1786)]():"",h=e.llbcj(this._options.payloadType,Object)?{force:!!this[r(388)][r(384)+r(1131)][r(1347)],type:this._options["payloadT"+r(1131)][r(1737)]?this[r(388)][r(384)+r(1131)][r(1737)][r(1212)](/\s/g,"")[r(204)+"ase"]():""}:{force:!1,type:this[r(388)]["payloadT"+r(1131)]?this[r(388)][r(384)+r(1131)].replace(/\s/g,"")[r(204)+"ase"]():""},w=a[r(384)+r(1131)]?a[r(384)+"ype"][r(1212)](/\s/g,"")[r(204)+r(1786)]():"",g=h[r(1347)]?h[r(1737)]:w||h.type,b=x[r(1347)]?x[r(1323)]:f||x[r(1323)],v=[e[r(333)],e[r(242)],e[r(306)],r(410)],C=[r(799)+"e",e[r(298)]];this[r(388)][r(1157)+r(1208)+r(1487)+"ad"]&&v[r(1086)](g)&&(!b||C[r(1086)](b))?a[r(1298)+r(598)]=e[r(751)](as,a.payload,0,a.payload[r(1062)+"th"]):a.textPayload=""}else a[r(1298)+r(598)]=""}catch(x){a["textPayl"+r(598)]="",console[r(905)](x)}i[r(1697)]=a,e[r(517)](t)}function s0(i,t,r){let a=n,x=e[a(1745)](r,8192),f=e[a(216)](x,1),h=null,w=x;return function(g){let b=a;if(g<1||g>f)return e.oWFrM(i,g);e[b(959)](e[b(1161)](w,g),x)&&(h=e.CiPOh(i,x),w=0);let v=t.call(h,w,w+=g);return e.kzrep(7,w)&&(w=e[b(661)](e.XrZuJ(7,w),1)),v}}let o0=4294967295;function a0(i,t,r){let a=n;return e[a(436)](RangeError,e[a(812)](e[a(780)](e[a(942)](e.HGhwT,i)+e.xeCaJ,e[a(468)](t,1)),e.JYnUJ)+r)}function c0(i,t,r){let a=n;if(e[a(959)](r,o0))throw new Error(e[a(540)]);let x=3;for(;x>=0;){let f=e[a(974)](255,r);zr(f,i,t+x),r>>>=8,x--}return e[a(203)](t,4)}function x0(i,t){let r=n,a=0,x=t,f=e[r(596)](t,4);for(;x<f;)if(e.lhpaO("TZusq",e.nnUuP)){let{value:h,offset:w}=e.fLMhL(Br,i,x);x=w,a=e[r(1160)](e[r(777)](a,8),0),a+=h}else _0x4eecd3.log(_0x4c0e3b);return{value:a,offset:f}}function d0(i,t,r){let a=n;return i?e[a(1442)](i[a(796)],40)?Or(i,t,r)+r:t[a(238)+"e"]?e[a(566)](t.utf8Write(i,r),r):t[a(823)]?t[a(823)](i,r)+r:e[a(1665)](Or(i,t,r),r):r}function u0(i,t){let r=n,a=new G(e[r(374)](e.oKHTv(e[r(597)](i[e.dNAMH(t,4)],24)|e.vmYvg(i[e[r(348)](t,5)],16),e[r(257)](i[e.soGkl(t,6)],8)),i[t+7]),e[r(1322)](e[r(434)](e[r(966)](e.mqHtZ(i[e[r(1419)](t,0)],24),i[e[r(812)](t,1)]<<16),i[e[r(1101)](t,2)]<<8),i[e.vqmIh(t,3)]),!0);return t+=8,{value:a,offset:e[r(1601)](t,8)}}function f0(i,t,r){let a=n,x=i[a(1454)],f=i[a(1070)];return t[r]=e.pzdWS(f,24),t[e[a(775)](r,1)]=e[a(1270)](f,16)&255,t[e[a(1687)](r,2)]=e.SCuwf(e[a(1259)](f,8),255),t[r+3]=255&f,t[r+4]=x>>>24,t[r+5]=e[a(1391)](x,16)&255,t[r+6]=e[a(1121)](x,8)&255,t[e[a(1613)](r,7)]=e.uOgWf(255,x),r+=8,r}function Br(i,t){let r=n;if(e[r(883)](e[r(418)],e.nabnx))try{return e.UaeLL!=typeof _0x1da8ff&&(e.MhLSF(_0x457d33,_0x47619e)||_0xe18d23[r(1054)]&&e[r(510)](_0x215ed8[r(1054)],_0x14d7c4))||e[r(1510)](e[r(980)],typeof _0x1cd600)?"":(_0x5bb4b6.parse(_0xdef41c),e[r(242)])}catch{return e[r(1571)](e[r(980)],typeof _0x3cb195)?e[r(333)]:""}else return i.readUInt8?{value:i[r(911)+"8"](t),offset:e[r(1683)](t,1)}:{value:e[r(1430)](255,i[t]),offset:e[r(812)](t,1)}}function zr(i,t,r){let a=n;if(e[a(515)](a(518),e[a(1707)]))try{_0x1bffec(this,_0x236b53,[_0x35966f,_0x5d1f6b,_0x270bfe])}catch(x){let f=e[a(976)](_0x29913f,e[a(1214)],{message:x[a(1697)],code:_0x3639bb.OPEN_ERROR,error:x});this["_dispatc"+a(776)+a(1434)](f)}else return t[a(928)+"t8"]?t[a(928)+"t8"](i,r):t[r]=e.snlqI(255,i),e.mKvYi(r,1)}let l0=function(i){return new Uint8Array(i)},g0=e[n(607)](n(1631)+"d",typeof Buffer)?Buffer[n(622)+n(1509)]:e[n(845)](s0,l0,Uint8Array.prototype[n(993)]);(()=>{let i=n;if(e.fAMpO(i(1008),e.nbBKM)){let t=4294967295;return function(r,a,x=!0){let f=i,h={OqXxX:function(w,g){return e.bhztn(w,g)},owFDv:function(w,g){return e.CPCWt(w,g)},WEfIH:function(w,g){return e.fOzds(w,g)},ntAEw:function(w,g){return e[k(780)](w,g)},dZdNJ:function(w,g){return w+g},qNvNO:e[f(378)],fqEtp:function(w,g){return e[f(252)](w,g)},frnTj:e[f(1708)]};if(e[f(1170)]!==f(1679)){let w=(f(642)+f(1029)+f(209)+"3")[f(1413)]("|"),g=0;for(;;){switch(w[g++]){case"0":t=e.sJJmk(e.gdHlt(127,r[a]),0);continue;case"1":if(e[f(1224)](r[a++],128))return{value:x?t:e.JfOdg(0,t),offset:a};continue;case"2":if(e[f(1442)](r[a++],128))return{value:x?t:e[f(423)](0,t),offset:a};continue;case"3":return{value:x?t:e[f(1493)](0,t),offset:a};case"4":t=e[f(645)](e[f(1493)](t,e[f(924)](127&r[a],7)),0);continue;case"5":if(e[f(243)](r[a++],128))return{value:x?t:e.dRUfh(0,t),offset:a};continue;case"6":if(e[f(1468)](r[a++],128))return{value:x?t:e[f(857)](0,t),offset:a};continue;case"7":t=e[f(1391)](t|e[f(732)](127,r[a])<<21,0);continue;case"8":if(e[f(290)](a+=5,r[f(796)]))throw a=r.length,a0(a,10,r.length);continue;case"9":t=e[f(1645)](t,e.IGafw(e.phtMy(127,r[a]),14))>>>0;continue;case"10":if(e[f(739)](r[a++],128))return{value:x?t:e[f(1342)](0,t),offset:a};continue;case"11":t=e[f(660)](t|e[f(213)](15&r[a],28),0);continue}break}}else return WVMdnt[f(1656)](_0x32e551,WVMdnt[f(772)](WVMdnt[f(967)](WVMdnt.ntAEw(WVMdnt.dZdNJ(f(1783)+f(907)+f(1544),_0x2efeed)+WVMdnt.qNvNO,WVMdnt.fqEtp(_0x28f4c3,1)),WVMdnt[f(830)]),_0x36686d))}}else return Y[i(958)].binaryType})();let h0=16,Fr=32;function p0(i){let t=n,r=0,a={};for(let x=0;x<i[t(796)];x++)a[i[x][t(738)+t(981)]]=e[t(1530)](os,i[x]["cursor_n"+t(981)]),r+=14+a[i[x][t(738)+t(981)]];return[r,a]}function us(i,t,r){let a=n,x={RimUr:function(b,v){return e.xfrZF(b,v)},YAuhn:function(b,v){return e[k(1521)](b,v)},YLglz:function(b,v){return e[k(1402)](b,v)},UHTwO:function(b,v){return e.fZwjp(b,v)},RqNfD:function(b,v){return e.FosZq(b,v)},nRafR:function(b,v){return e.NfzRV(b,v)},wWYMa:a(367),CJGaB:e[a(633)],mKYEb:function(b,v,C,O){return b(v,C,O)},RtpSJ:a(1736)+a(310),XCdIn:"header",eYISc:a(310),wliGh:e[a(1307)],Jsywx:e[a(950)],Dsrni:e[a(1069)]},[f,h]=e[a(294)](p0,i),w=g0(f),g=0;return i[a(1519)](b=>{let v=a,C={SKESz:function(O,R){return x[k(1215)](O,R)},UvDLZ:function(O,R){return x[k(999)](O,R)},IdnTh:function(O,R){return x[k(697)](O,R)},IXNeY:function(O,R){return x[k(697)](O,R)},dpMvS:function(O,R){return x[k(656)](O,R)},zZaDc:function(O,R){return x[k(1405)](O,R)}};if(x[v(1499)]("MrCeR",x.wWYMa))_0x4b08f7=lBLYqp.SKESz(_0x2acc3a,_0x5a2b26),_0x391847|=lBLYqp[v(621)](lBLYqp.IdnTh(127,_0x384c46),21),lBLYqp[v(1507)](128,_0x4ac38d)&&(_0xd3eb45=lBLYqp.dpMvS(_0x4caf8c,_0x567438),_0x56c51d=lBLYqp[v(897)](127,_0x239c64),lBLYqp[v(897)](128,_0x93d009)&&(_0x3dc846=lBLYqp[v(1540)](_0x53fa8d,_0x3a29f2),_0x43d3be|=lBLYqp[v(621)](127&_0x35b502,7)));else{let O=x[v(487)].split("|"),R=0;for(;;){switch(O[R++]){case"0":g=x[v(1007)](zr,0,w,g);continue;case"1":console[v(905)](x[v(1393)],g);continue;case"2":console[v(905)](x[v(731)],g);continue;case"3":console[v(905)](x[v(1416)],g);continue;case"4":g=x.mKYEb(d0,b[v(738)+v(981)],w,g);continue;case"5":g=c0(w,g,b[v(745)]||0);continue;case"6":console[v(905)](x.wliGh,b,b.service);continue;case"7":g=x[v(1007)](zr,h[b[v(738)+v(981)]],w,g);continue;case"8":g=x[v(1007)](f0,G.fromNumber(b[v(628)]||t),w,g);continue;case"9":console[v(905)](x[v(1117)],g);continue;case"10":console[v(905)](x[v(217)],g);continue}break}}}),{frameType:Fr,headers:[{key:a(479)+a(1440),value:r}],payload:w}}function m0(i){let t=n,r={Chguo:function(a,x){return a-x},xIyDF:function(a,x){return e[k(1172)](a,x)},orwek:function(a,x){return e[k(558)](a,x)},BcDOE:function(a,x){return e[k(1475)](a,x)},EFbtu:function(a,x){return a<<x},fvaKP:function(a,x){return e[k(447)](a,x)}};if(e[t(1672)](e.WJCFT,e[t(659)])){let a=0,x=[];for(;e[t(1336)](a,i[t(1062)+"th"]);){let{offset:f}=e[t(763)](Br,i,a);a=f;let h={cursor_name:"",cursor:0,service:0},{value:w,offset:g}=x0(i,a);h[t(745)]=w,a=g;let{value:b,offset:v}=e[t(262)](Br,i,a);a=v,h[t(738)+t(981)]=e[t(526)](as,i,a,e[t(1241)](a,b)),a+=b;let{value:C,offset:O}=e.MnWSq(u0,i,a);h[t(628)]=C.toNumber(),a=O,x[t(1774)](h)}return x}else{let a=uuTSwI[t(1340)](uuTSwI[t(1660)](uuTSwI[t(1660)](uuTSwI[t(231)](uuTSwI[t(1439)](7,_0x41a652),18)|uuTSwI[t(1329)](uuTSwI[t(1439)](63,_0x2135a8[_0x54a835++]),12),uuTSwI[t(1329)](uuTSwI[t(1439)](63,_0xd08c7[_0x481a92++]),6)),uuTSwI[t(1439)](63,_0x10a3bb[_0x18e3c9++])),65536);_0x1e99cf+=_0x2b8993[t(861)+"Code"](55296+(a>>10)),_0xf27b9b+=_0x5adf63.fromCharCode(uuTSwI[t(618)](56320,uuTSwI[t(1439)](1023,a)))}}function w0(){let i=n;return{frameType:Fr,headers:[{key:e[i(426)],value:e[i(784)]}],payload:void 0}}class _0{constructor(t,r,a){let x=n;this[x(1415)+x(1484)]=t,this["_cursorF"+x(1777)]=r,this[x(1537)+x(864)]=a,this[x(524)]=xs(this[x(1415)+x(1484)],e[x(1226)])}async[n(875)](){let t=n;await this[t(524)][t(875)]()}async[n(1403)+"rs"](){let t=n;if(!this._qosDB.isReady)return;let r=this[t(1537)+t(864)],a=await this[t(524)][t(1398)]();switch(console[t(905)](e[t(460)],a),r){case e[t(1667)]:return a&&a[t(796)]?e[t(751)](us,a,0,this[t(1250)+"ileName"]):void 0;case e[t(1767)]:return;case e[t(1147)]:return a&&a[t(796)]?e[t(1348)](us,a,0,this[t(1250)+t(1777)]):e[t(953)](w0)}}async[n(1651)](t,r,a){let x=n;return console[x(905)](e[x(627)],t,r,a),this[x(524)][x(1651)]({cursor_name:t,cursor:r,service:a})}async[n(1315)+"rs"](t){let r=n;if(e.mrUyV(e[r(509)],e[r(509)])){if(!this._connectLock){let a=(r(1478)+"2")[r(1413)]("|"),x=0;for(;;){switch(a[x++]){case"0":this[r(1538)+"osed"]=!1;continue;case"1":this[r(273)+r(844)]?.[r(971)+"nter"]();continue;case"2":this[r(815)]();continue;case"3":this[r(393)]=!0;continue;case"4":this[r(240)+"tManager"]?.[r(226)+r(404)+r(277)]();continue}break}}}else{let a=e.WSGEd(m0,t);for(let x of a)console.log(e[r(349)],a),await this._qosDB[r(1651)](x)}}async get(t){let r=n;return(await this[r(524)][r(1657)](t))?.cursor}async closeDB(){let t=n;e[t(1233)](e[t(1641)],e[t(1779)])?(_0xf2f928=_0x1b1d31[e[t(1359)](e[t(596)](_0x49dfdf,_0x59734e),1)],e[t(1302)](e[t(681)](192,_0x626819),128)?_0x335c5b+=_0x7d035b:(_0x35deee=e[t(1733)](e.gDGYq(31,_0x3aca4b),6)|e[t(817)](63,_0x2d6ba6),e[t(968)](_0x5e901f,128)?_0x12d048+=_0x17722b:(_0x5c83db+=_0x30a0e5(_0x3b3fa6),_0x28bbed++))):await this[t(524)].closeDB()}[n(708)+n(1030)+n(1498)](t){let r=n;this[r(1250)+"ileName"]=t}get[n(1303)](){let t=n;if(e[t(1584)](t(1141),e[t(1635)]))return this._qosDB[t(1303)];this[t(1271)]++}}let y0=e[n(1088)];async function fs(i){let t=n;if(e[t(515)](e[t(1299)],e[t(1299)]))_0x13644f&&_0x5cdfc5.addEventListener(t(1360),()=>_0x4cdb9c()),_0x2d3974&&_0x11d763[t(884)+t(1425)]("versionchange",()=>_0x35fc32());else{if(!this[t(388)][t(1044)+"S"])return null;let{aID:r,fpID:a,messageStrategy:x}=this[t(388)],f=i||y0;try{return this[t(674)+t(1551)]?i&&this._cursorManager[t(708)+t(1030)+t(1498)](i):this[t(674)+t(1551)]=new _0(a+"_"+r+"_"+f,f,x),this[t(674)+t(1551)][t(1303)]||await this[t(674)+"anager"].openDB(),this["_cursorM"+t(1551)]}catch{return null}}}async function b0(i,t){let r=n,a={JJqQj:e[r(1197)],wgXcV:function(x,f){return e[r(455)](x,f)},EHIPQ:function(x,f){return e[r(1337)](x,f)},stnoz:function(x,f){return e[r(497)](x,f)}};if(e[r(1139)](e[r(1628)],r(1528))){let x=a[r(906)][r(1413)]("|"),f=0;for(;;){switch(x[f++]){case"0":if(_0x30ce7d.utf8Write)return xsjpOQ[r(620)](_0x5c3c35[r(238)+"e"](_0x1ee9c0,_0x2afa42),_0x2a25d5);continue;case"1":if(_0x227d3d.length<40)return xsjpOQ[r(1252)](_0x55a210(_0x95bfc9,_0x5e6d82,_0x398916),_0x5c29a1);continue;case"2":if(!_0x37e24c)return _0x215698;continue;case"3":return _0x4768ae(_0x39a1fb,_0x1f4cfa,_0x3c7227)+_0x27376e;case"4":if(_0x39cc29[r(823)])return xsjpOQ.stnoz(_0xa8497d.write(_0xf1586d,_0x100b63),_0x21ac79);continue}break}}else{let x=et(i[r(1697)][r(951)],r(1532),"-1"),f=et(i[r(1697)][r(951)],e[r(1009)],"1"),h=e.irSXZ(St,i.message[r(951)],r(807)+r(941)),w=e[r(1568)](Number,e[r(1020)](St,i.message[r(951)],r(807)+"er_ttl"))||0,g=Mr[r(1182)](this,i),b=e[r(1348)](et,i[r(1697)].headers,e[r(422)],"2"),v=e[r(1452)](St,i[r(1697)][r(951)],e[r(1787)]),C=e[r(1017)](Number,e[r(992)](St,i[r(1697)][r(951)],e[r(1126)]));if(g[r(678)])return e.jaJyY(t);let O=g[r(579)+"sage"]?await ds[r(1182)](this):null;if(e.SFxCa(i.message.service,0)&&f&&!x||e.aURdb(i[r(1697)][r(745)],0)){if(h&&g[r(579)+r(408)]&&O)return!!!await O[r(1657)](h)&&(this["_dispatc"+r(535)+r(1081)](i),await O[r(1651)](h,e.ygBus(Date[r(1780)](),w))),e[r(517)](t);if(b){let R=await fs.call(this);if(!R)return this[r(443)+r(535)+r(1081)](i),e[r(485)](t);let F=await R[r(1657)](v)??-1;if(e[r(243)](F,C))this[r(443)+r(535)+r(1081)](i),R.set(v,C,i[r(1697)][r(745)]);else throw new Error(r(1137)+" message"+r(774)+C+(r(936)+r(893)+r(529)+"r ")+F);return t()}return this[r(443)+r(535)+"Event"](i),e.YyxnS(t)}}}async function v0(i,t){let r=n,a=Mr.call(this,i);if(!a[r(579)+r(408)])return t();let x=await ds.call(this);if(a[r(1524)+r(1061)+r(1122)]&&a.ackMsgIds[r(796)])for(let f of a[r(743)+"s"])await x.del(f);t()}async function S0(i,t){let r=n,a=e[r(1627)](i[r(1697)][r(1104)+"e"],h0),x=e[r(1486)](i.message.frameType,Fr);if(e[r(1639)](!a,!x))return e[r(1324)](t);let f=e[r(1690)](St,i.message[r(951)],e[r(426)]);if(!f)return e[r(1575)](t);let h=await fs.call(this,f);if(!h)return t();if(a){let w=await h[r(1403)+"rs"](),g={frameType:w?.["frameType"],SeqID:G[r(764)+"er"](this[r(1251)]++),LogID:G[r(764)+"er"](this[r(388)][r(1548)+r(1749)]()),service:9e3,method:5,headers:w?.[r(951)],payload:w?.[r(1097)]},b=e[r(548)](I,g);this._ws&&this._ws.readyState&&this[r(289)].send(b)}if(x){let w=i.message[r(1097)];w&&h.setCursors(w)}}let E0=async function(i,t){let r=n;this[r(393)]=!1,e[r(917)](clearTimeout,this[r(815)+r(1647)+r(527)]),e[r(1232)](t)},I0=async function(i,t){let r=n;if(!this[r(289)]||this[r(289)].readyState!==this[r(1664)])return e.HSddo(t);let{pingInterval:a}=this._options;this["_endpoin"+r(302)]?.[r(226)+"pointCon"+r(277)]();for(let f=0;e[r(968)](f,this[r(1537)+r(550)].length);f++){let h=this[r(1537)+r(550)][f];if(this[r(289)].readyState===this[r(1664)]&&e[r(1584)](null,h))this[r(289)]&&this[r(289)].send(h),this[r(1537)+"Queue"][f]=null;else break}this[r(1537)+r(550)]=this[r(1537)+"Queue"][r(208)](f=>!!f),this["_pingPon"+r(653)+"Id"]=e.YALyA(setTimeout,()=>this[r(1481)](),a),this._dispatchOpenEvent(i),this[r(626)+"er"]&&this._ws&&(this[r(289)][r(1704)+"pe"]=this["_binaryT"+r(1131)]);let x=this[r(240)+"tManager"]?.[r(695)+r(1180)+"nt"]();this[r(1225)]("open "+x+" success"),e.kIQdp(t)},A0=async function(i,t){let r=n,a=this[r(240)+r(302)]?.[r(695)+"ntEndpoint"]();this[r(1225)](r(214)+a),e[r(517)](t)};class C0 extends Lr{constructor(t){let r=n,a={lcrZb:function(w,g,b,v){return e[k(751)](w,g,b,v)},BvJjz:e[r(1214)],QeFju:e.XEKJp,MGfSJ:function(w,g,b){return e[r(1295)](w,g,b)},NDWMb:e[r(809)],Teenz:function(w,g){return w!==g},jDGJf:function(w,g){return e.DuuAb(w,g)},uuzTQ:function(w,g){return e[r(432)](w,g)},rGgNZ:function(w,g,b){return e[r(1730)](w,g,b)}};super(),this[r(1109)+r(1505)+r(728)]=!0,this[r(626)+"er"]=vt,this[r(546)]=jc,this[r(1485)+"T"]=ut,this[r(1146)+"X"]=jt,this[r(1198)+"r"]=Kt,this["_message"+r(550)]=[],this["_endpoin"+r(302)]=null,this._readyClosed=!1,this._binaryType=e.DRnPB,this["_connect"+r(202)]=!1,this["_connectionTimeo"+r(527)]=null,this[r(1511)+r(1010)+r(1421)]=null,this[r(377)+"gTimeoutId"]=null,this[r(1251)]=0,this[r(393)]=!1,this[r(1417)]="",this["_QoSMana"+r(283)]=null,this._cursorManager=null,this[r(273)+r(844)]=null,this._protocols=e.QMNlb,this[r(1067)]=3,this[r(1579)+"NG"]=0,this[r(1664)]=1,this[r(599)]=2,this[r(223)]=w=>{let g=r;try{a.lcrZb(ss,this,w,[E0,I0,A0])}catch(b){let v=Ie(a[g(832)],{message:b[g(1697)],code:Ze[g(414)+"OR"],error:b});this[g(443)+g(776)+g(1434)](v)}},this[r(1535)+"ge"]=async w=>{let g=r,{pingInterval:b,pingFrequency:v}=this[g(388)];if((w[g(1661)]==="hi"&&e[g(828)]===v||e.pVolg(e.DiXaT,v))&&(this._clearPingTimer(),this[g(1216)](e[g(768)],e[g(870)]),this[g(377)+"gTimeoutId"]=e[g(1164)](setTimeout,this[g(1481)][g(854)](this),b)),!e[g(1472)]("hi",w[g(1661)]))try{e[g(1728)](ss,this,w,[i0,n0,v0,S0,b0,r0])}catch(C){let O=e[g(557)](Ie,e[g(1214)],{message:C.message,code:Ze["MESSAGE_"+g(269)],error:C});this[g(443)+g(776)+g(1434)](O)}},this[r(669)]=w=>{let g=r,b=this[g(240)+g(302)]?.[g(874)+g(684)+"es"](),v=this[g(240)+"tManager"]?.[g(695)+"ntEndpoint"]();if(b&&!w[g(1697)]){let C=g(1123)+v+(" fail, max retri"+g(1278)+"ed");this[g(443)+"hErrorEv"+g(1434)](e[g(1739)](Ie,e[g(1214)],{message:C,code:Ze[g(399)+"IES_ERROR"],error:w}));return}this[g(289)]&&e[g(701)](this[g(289)][g(201)+"te"],this[g(1664)])&&this[g(1455)+g(1717)](),this[g(443)+g(776)+g(1434)](e[g(1682)](Ie,e[g(1214)],{message:w.message,code:Ze[g(887)+g(1078)],error:w}))},this[r(932)]=async w=>{let g=r;this[g(1399)+"mer"](),this[g(375)+g(1189)](),this["_removeW"+g(821)+"rs"](),this[g(289)]=null,this[g(815)+g(202)]=!1;let b=this[g(240)+"tManager"]?.[g(874)+g(684)+"es"]();if(!b&&this[g(1332)+g(1343)]()&&!this[g(1538)+g(1473)]){let v=this[g(240)+g(302)]?.[g(695)+g(1180)+"nt"](),C=this[g(388)][g(576)+g(1103)+g(1768)](w[g(1532)],w.reason);this[g(443)+g(358)+"ent"](De(a[g(919)],{code:1006,reason:w.reason||g(1286)+"ng faile"+g(798)+g(880)+g(1449)+g(373)+v,willReconnect:C})),C&&this[g(815)]();return}if(w[g(1532)]!==1e3&&this[g(1538)+g(1473)]){this[g(443)+g(358)+g(1434)](a[g(1354)](De,a[g(919)],{code:1e3,reason:a[g(788)]})),this["_endpoin"+g(302)]?.["resetEnd"+g(404)+g(277)](),this[g(273)+g(844)]?.resetCounter();return}if(a[g(1549)](1e3,w[g(1532)])&&b){let v=this[g(240)+"tManager"]?.[g(695)+g(1180)+"nt"](),C=w[g(723)];C||(C=await a.jDGJf(Yc,this._url)),C=g(1286)+g(1437)+g(1319)+C+(g(1382)+"me: ")+v+(g(1186)+g(1272)+g(1418)),this["_dispatc"+g(358)+g(1434)](De(a[g(919)],{code:w.code,reason:C}));let O="connect "+v+(g(586)+"ax retri"+g(1278)+"ed");this[g(443)+g(776)+g(1434)](a[g(1354)](Ie,a.BvJjz,{message:O,code:Ze["MAX_RETR"+g(1569)+"R"]})),this[g(240)+g(302)]?.[g(226)+g(404)+g(277)](),this[g(273)+"sCounter"]?.[g(971)+"nter"]();return}if(a[g(1050)](1e3,w.code)&&!w[g(723)]){let v=this["_endpoin"+g(302)]?.[g(695)+"ntEndpoint"]();this[g(443)+g(358)+g(1434)](a[g(1354)](De,a.QeFju,{code:w[g(1532)],reason:g(1286)+g(1437)+g(798)+"wn reaso"+g(1449)+"ame: "+v})),this._endpointManager?.[g(226)+"pointCon"+g(277)](),this[g(273)+g(844)]?.["resetCou"+g(1321)]();return}this["_dispatchCloseEv"+g(1434)](w),this["_endpoin"+g(302)]?.[g(226)+g(404)+"fig"](),this["_pingLos"+g(844)]?.[g(971)+"nter"]()},this.onclose=null,this[r(440)]=null,this[r(641)+"e"]=null,this[r(1364)]=null,this[r(643)+r(1345)]=null,this["onReceiv"+r(979)]=null,this[r(1005)+r(737)+"yReconnect"]=null,this[r(433)+r(818)]=this[r(433)+r(818)][r(854)](this),this[r(433)+"ffLine"]=this["_handleO"+r(719)].bind(this),this[r(1211)+r(1722)]=this[r(1211)+r(1722)][r(854)](this),this[r(1211)+r(1120)]=this[r(1211)+r(1120)].bind(this),this[r(388)]={url:"",automaticOpen:!0,initReconnectInterval:1e3,maxReconnectInterval:1e4,reconnectIntervalGrowFactor:2,timeoutInterval:5e3,maxRetries:5,debug:!1,maxMessageQueueLength:e[r(288)](1,0),service:0,logIDGenerator:c,headers:void 0,payloadEncoding:"",payloadType:"",fpID:"",deviceID:"",accessKey:"",ttwID:"",bddID:"",aID:"",disableAutoReconnect:!1,customParams:{},pingInterval:15e3,pingTimeoutInterval:4e3,pingFrequency:r(1685),pingLossCount:2,enableTransformTextPayload:!1,logIDNewConfig:{enableAutoGenerateLogIDNew:!1,userIp:""},miniProgramParams:{customHttpHeader:{}},enableAutoAck:!1,reconnectInterceptor:()=>!0,enableQoS:!1,QoSLevel:2,messageStrategy:"CONTINUE",env:{xTTEnv:"",xUseEnv:""},listenNetworkChanged:!0};let{url:x,ws:f}=t,h=Array[r(736)](x)?x:e[r(980)]==typeof x?[x]:[];if(!h||e[r(1480)](0,h[r(796)]))throw new Error(e[r(1228)]);if(!Wc(f))throw new Error(r(500)+r(542)+"s params"+r(801)+r(469)+r(1275)+"is undef"+r(929));if(Object.assign(this._options,t),this[r(240)+r(302)]=new is(h,this[r(388)][r(1032)+"es"]),this[r(273)+r(844)]=new Vc(this[r(388)][r(299)+r(1207)]),this[r(388)][r(1369)+r(541)]&&(this._isInit=!0,this[r(815)]()),this._options[r(1518)+r(1040)+r(1788)])if(e.YsmSa(e[r(619)],r(369)))this[r(1485)+"T"]||this[r(1146)+"X"]?this["_onPageN"+r(1725)+r(1583)]():this[r(626)+"er"]&&this["_initGlo"+r(838)+r(1425)]();else{let w=this._options[r(576)+"tInterce"+r(1768)](_0x999dda,_0xd03bf3);this["_dispatc"+r(358)+r(1434)](a.rGgNZ(_0x583155,a[r(919)],{code:_0x582678,reason:_0x33cbf2,wasClean:!0,willReconnect:w})),w&&this[r(815)]()}}[n(433)+n(818)](){let t=n;this[t(388)][t(689)+t(1514)+t(489)]||this[t(1538)+t(1473)]||this[t(1092)+t(1345)]()}[n(433)+n(719)](){let t=n;if(e[t(896)](e.MwUuB,e[t(921)]))this[t(1603)+"ount"]=_0x2bfe45,this[t(1271)]=0;else{this["_destroy"+t(471)+"t"]();let r=e[t(711)](Rr,t(576)+"t",{message:e[t(1612)]});this[t(1005)+"mediatel"+t(1637)+"ct"]&&this["onStopIm"+t(737)+t(1637)+"ct"](r)}}[n(449)+"balEvent"+n(1425)](){let t=n;this[t(626)+"er"]&&window.addEventListener(e[t(688)],this[t(433)+t(818)]),this[t(626)+"er"]&&window[t(884)+"Listener"](e[t(589)],this["_handleO"+t(719)]),this[t(626)+"er"]&&window["addEvent"+t(1425)](e[t(722)],this[t(1211)+t(1722)]),this._isBrowser&&window[t(884)+t(1425)](e[t(885)],this._handlePageShow)}[n(822)+n(838)+"Listener"](){let t=n,r={GhMEs:e.uVcRl,YRxeM:function(a,x){return a||x},wTkyD:e[t(1712)]};if(e[t(1566)](e[t(1379)],e[t(1379)])){let a=r.GhMEs[t(1413)]("|"),x=0;for(;;){switch(a[x++]){case"0":if(bhXzEr[t(1634)](_0x2400fd,_0x1a4ac7)&&bhXzEr[t(520)]!=typeof _0x793980&&_0x25e483)return!0;continue;case"1":if(_0x741b54&&_0x27d251["connectS"+t(1592)])return!0;continue;case"2":if(_0x3eb92d&&_0x1abd0d.connectSocket)return!0;continue;case"3":if(_0x3c827d)return!0;continue;case"4":return!1}break}}else this[t(626)+"er"]&&window[t(605)+t(720)+t(396)](e[t(688)],this["_handleO"+t(818)]),this._isBrowser&&window[t(605)+t(720)+t(396)](e[t(589)],this["_handleO"+t(719)]),this[t(626)+"er"]&&window["removeEv"+t(720)+t(396)](e[t(722)],this[t(1211)+"ageHide"]),this[t(626)+"er"]&&window[t(605)+t(720)+t(396)](t(810),this[t(1211)+"ageShow"])}[n(1211)+n(1722)](t){let r=n;!t[r(853)+"d"]&&(this[r(626)+"er"]&&window[r(605)+"entListe"+r(396)](e.nRkIR,this[r(1211)+"ageHide"]),this._isBrowser&&window[r(605)+"entListe"+r(396)](e[r(885)],this[r(1211)+r(1120)]),this[r(1360)]()),this[r(626)+"er"]&&window[r(605)+"entListe"+r(396)](e[r(688)],this[r(433)+"nLine"]),this._isBrowser&&window[r(605)+r(720)+r(396)](e[r(589)],this[r(433)+r(719)])}[n(1211)+n(1120)](t){let r=n;t[r(853)+"d"]&&(this[r(1332)+r(1343)]()&&(!this[r(289)]||this[r(289)][r(201)+"te"]!==this.OPEN||e.xpfen(this._ws.readyState,this[r(1579)+"NG"]))&&this["_handleO"+r(818)](),this._isBrowser&&window["addEvent"+r(1425)](e[r(688)],this[r(433)+r(818)]),this[r(626)+"er"]&&window.addEventListener("offline",this[r(433)+r(719)]))}async["_generat"+n(390)](t){let r=n,{fpID:a,deviceID:x,bddID:f,ttwID:h,accessKey:w,aID:g,customParams:b={},enableAutoAck:v,enableQoS:C,QoSLevel:O,env:R}=this[r(388)],F,ue,be;this[r(626)+"er"]||this._isMiniWX||this._isMiniTT?(F=location&&e[r(1227)]==location[r(1408)]?e[r(362)]:e[r(1244)],ue=t[r(1212)](/((^ws)|(^http))((?:[s]*:\/\/))/,""),be=/^wss(.*:\/\/)/[r(1646)](t)?t:""+F+ue):(F=e[r(362)],ue=t[r(1212)](/(^http)((?:[s]*:\/\/))/,""),be=/(^ws)((?:[s]*:\/\/))/[r(1646)](ue)?ue:""+F+ue);let Gt=f?e[r(982)]:h?r(1533):e[r(1395)],mn=f||h||x;if(!mn||!Gt)throw new Error(r(500)+r(511)+"ddID, de"+r(532)+r(640));let P0=e.cIrPe==typeof b?await e.XhxHE(b):b,k0=R?e[r(1176)]($c,R.xUseEnv,R[r(360)]):{},Ur=Object[r(1163)]({device_platform:e[r(320)],version_code:e[r(651)],access_key:w,fpid:a,aid:g,[Gt]:mn,xsack:v?1:0,xaack:v?1:0,xsqos:C?1:0,qos_level:C?O:void 0,qos_sdk_version:2,...k0},P0),T0=Object[r(1561)](Ur)[r(1091)]((qr,Hr)=>Ur[Hr]!==void 0?""+qr+(qr?"&":"?")+Hr+"="+Ur[Hr]:qr,"");return be+r(1412)+T0}async[n(815)](){let t=n,r={NVGnS:t(1697)};if(!(this[t(815)+t(202)]||this[t(1538)+t(1473)])){this[t(815)+t(202)]=!0;try{if(e[t(1598)]===e[t(1598)]){let x=this["_endpoin"+t(302)]?.[t(930)+t(996)+t(345)+t(325)+t(1055)](),{timeoutInterval:f}=this._options;if(x)if(e[t(1390)]!=="oxORc")for(var a in _0x282373)_0x3cebe8.o(_0x561d95,a)&&!_0x2416d5.o(_0x3d0246,a)&&_0x4a6705[t(1512)+t(1778)](_0x374e0d,a,{enumerable:!0,get:_0x5b1bb8[a]});else{let w=this[t(240)+"tManager"]?.[t(695)+"ntEndpoint"](),g=this[t(240)+t(302)]?.[t(286)+t(1445)+t(1624)+t(267)+t(825)](),b=this[t(240)+t(302)]?.[t(695)+t(1180)+t(1721)+t(1053)]();if(g){if(e.fXmow(e[t(207)],t(265)))return{frameType:_0x48d70e,headers:[{key:e.iLZAR,value:e[t(784)]}],payload:void 0};{let v=t(1123)+w+(" timeout"+t(1186)+t(1272)+"ached, will use backup e"+t(221))+g+(t(272)+"y"),C=e[t(365)](Ie,"error",{message:v,code:Ze[t(399)+t(1569)+"R"]});this._debug(v),this[t(443)+t(776)+t(1434)](C),this[t(1417)]=await this[t(670)+t(390)](g),this._debug(t(1123)+g+" "+b+t(668)),this[t(1210)+"sListeners"]()}}else{let v=t(1123)+w+(" timeout, max re"+t(1272)+t(1418));this[t(1225)](v),this["_dispatc"+t(776)+t(1434)](e[t(711)](Ie,e.sukVs,{message:v,code:Ze["MAX_RETR"+t(1569)+"R"]}));return}}else if(e[t(1409)](e[t(755)],t(658))){let w=this[t(240)+t(302)]?.[t(695)+t(1180)+t(459)+t(600)](),g=this[t(240)+t(302)]?.["getCurrentEndpoi"+t(1721)+t(1053)]();this[t(1417)]=await this._generateUrl(w||""),this[t(1225)](t(1123)+w+" "+g+t(668)),this[t(1210)+t(821)+"rs"]()}else{let w=e[t(1335)][t(1413)]("|"),g=0;for(;;){switch(w[g++]){case"0":_0x4d9583=["put","add",t(989),t(726)];continue;case"1":_0x3c49eb=[Pqqzol[t(326)],Pqqzol[t(1534)],t(1398),t(311)+"ys",Pqqzol[t(706)]];continue;case"2":Pqqzol[t(1167)](_0x3bf97d);continue;case"3":_0x1eef0b=new _0x5ef5e2;continue;case"4":Pqqzol[t(465)](_0x3a948a,b=>({...b,get:(v,C,O)=>_0x47e1d0(v,C)||b.get(v,C,O),has:(v,C)=>!!_0xb9f923(v,C)||b[t(1184)](v,C)}));continue;case"5":_0x718e0e();continue}break}}if(this._isInit)this._isInit=!1;else if(e[t(662)]("TxzeA",t(923))){let w=e[t(1663)](Rr,e[t(1178)],{message:e[t(1676)]});this[t(643)+t(1345)]&&this[t(643)+t(1345)](w)}else this[t(1216)](r[t(1621)],_0x49c800),this[t(641)+"e"]&&this[t(641)+"e"](_0x3267b3);let h=this[t(240)+t(302)]?.[t(695)+t(1180)+"ntTriesC"+t(1053)]()||0;e.bUxDN(h,1)&&await this[t(395)](h-1),this[t(1225)](t(1286)+t(1743)+this[t(1417)]+(" protoco"+t(973))+this[t(1025)+"ls"]),this[t(289)]=Gc({url:this[t(1417)],protocols:[this[t(1025)+"ls"]],headers:this[t(388)].miniProgramParams[t(592)+t(1386)]},this._options.ws),(this[t(626)+"er"]||this[t(1198)+"r"])&&this._ws&&(this[t(289)][t(1704)+"pe"]=this[t(1450)+"ype"]),this[t(718)+t(1195)](),this["_connectionTimeo"+t(527)]=e[t(1177)](setTimeout,this[t(1333)+"ut"][t(854)](this),f)}else{let{initReconnectInterval:x,maxReconnectInterval:f,reconnectIntervalGrowFactor:h}=this[t(388)],w=x*_0x8d434d[t(1771)](h,e[t(606)](_0x2a66fd,1));return e[t(290)](w,f)?f:w}}catch(x){throw this[t(815)+"Lock"]=!1,x}}}[n(1399)+n(245)](){let t=n;if(e[t(553)](e[t(1754)],e[t(805)]))e[t(309)](clearTimeout,this[t(815)+"ionTimeoutId"]),this[t(815)+t(1647)+t(527)]=null;else{if(e[t(1031)](4,_0x45985d[t(796)])){let r=_0x34e00b[t(644)+"g"](0,e[t(1526)](4,_0x1f6cad[t(796)])),a=r[t(632)](_0x206d89);_0x592853[t(1774)](a)}else _0x2bbe2d[t(1774)](_0x16a40c);_0x419a53&&(_0xb79832+=1),_0xe2a2f+=1,_0x29d1a7=!1}}[n(375)+n(1189)](){let t=n;clearTimeout(this[t(377)+"gTimeoutId"]),clearTimeout(this[t(1511)+"ctTimeoutId"]),this[t(377)+t(653)+"Id"]=null,this[t(1511)+t(1010)+"tId"]=null}_debug(...t){let r=n;this[r(388)][r(582)]&&console.log[r(1063)](console,[e[r(673)],...t])}[n(1706)+n(444)+"e"](t){let r=n,{initReconnectInterval:a,maxReconnectInterval:x,reconnectIntervalGrowFactor:f}=this._options,h=e.CxyrE(a,Math[r(1771)](f,e[r(606)](t,1)));return e.OhKug(h,x)?x:h}[n(1481)](){let t=n;if(this[t(289)]&&this[t(289)][t(201)+"te"]===this[t(1579)+"NG"]){this[t(375)+t(1189)](),this[t(377)+t(653)+"Id"]=setTimeout(this._ping[t(854)](this),this._options[t(318)+t(316)]);return}if(!this._ws||e[t(1465)](this[t(289)][t(201)+"te"],this[t(1664)]))return void this["_handleR"+t(1345)]();this[t(289)]&&this[t(289)][t(530)]("hi"),this["_reconne"+t(1010)+t(1421)]=e[t(770)](setTimeout,this["_handleR"+t(1345)+t(1763)][t(854)](this),this[t(388)]["pingTime"+t(793)+"val"])}[n(1092)+n(1345)+n(1763)](){let t=n;this._pingLossCounter?.[t(614)](),this[t(1216)](t(1723)+t(802)+"t",t(1740)),this["_pingLos"+t(844)]?.["checkRea"+t(1245)+"nt"]()?this[t(1092)+t(1345)]():this[t(1481)]()}[n(1332)+n(1343)](){let t=n;return this._isMiniTT||this._isMiniWX?this[t(1109)+t(1505)+t(728)]:(this._isBrowser||this._isWorker)&&this[t(388)][t(1518)+"tworkCha"+t(1788)]?navigator.onLine:!0}[n(1092)+n(1345)](){let t=n;!this[t(1332)+t(1343)]()||this[t(1538)+"osed"]||(this[t(240)+t(302)]?.[t(226)+t(404)+"fig"](),this[t(273)+t(844)]?.["resetCou"+t(1321)](),this._ws?this[t(1455)+t(1717)](1001,e.RdwyV,!0):this._connect())}[n(873)+n(1725)+n(1583)](){let t=n;if(e[t(927)](e[t(1495)],e[t(1102)]))this[t(1485)+"T"]?tt["onNetworkStatusC"+t(1090)](({isConnected:r})=>{let a=t;this["_miniNav"+a(1505)+"line"]=r,r?this[a(433)+a(818)]():this["_handleO"+a(719)]()}):this._isMiniWX&&wx[t(538)+"kStatusC"+t(1090)](({isConnected:r})=>{let a=t;this[a(1109)+"igatorOnline"]=r,r?this[a(433)+a(818)]():this[a(433)+"ffLine"]()});else return this[t(289)]?this[t(289)][t(1617)+"ns"]:""}_wait(t){let r={YQHOr:function(a,x,f){return e[k(1292)](a,x,f)}};return new Promise(a=>{let x=k;r[x(1527)](setTimeout,a,this["_getInte"+x(444)+"e"](t))})}[n(1455)+n(1717)](t=1e3,r="",a=!1){let x=n;this[x(289)]&&this[x(506)+"WebSocket"](t,r,a)}[n(1333)+"ut"](){let t=n,r=this[t(240)+t(302)]?.[t(695)+t(1180)+"nt"]();this._debug(t(1123)+r+t(1038)),this[t(1455)+t(1717)](1001,e.hrlXj,!0)}_sendAck(t){let r=n,a={JQKpa:function(f,h){return e[k(607)](f,h)},NCPIt:e.IRDTh,nbfsc:e[r(1531)],lDFzk:"__esModule"},x=e[r(381)](re,t);this[r(289)]&&e[r(970)](this[r(289)].readyState,this[r(1664)])&&(e.mVcGD(e.CjjOK,r(1144))?(this._ws&&this[r(289)].send(x),this[r(1225)](e[r(1626)],t)):_0x19d4af.r=f=>{let h=r;tAoHrX[h(1491)](tAoHrX[h(1559)],typeof _0x378a29)&&_0x7a8818.toStringTag&&_0x560f8b["definePr"+h(1778)](f,_0x5c33f9[h(1605)+h(637)],{value:tAoHrX.nbfsc}),_0x4dbb03[h(1512)+h(1778)](f,tAoHrX[h(1503)],{value:!0})})}["_removeW"+n(821)+"rs"](){let t=n,r=e[t(1734)][t(1413)]("|"),a=0;for(;;){switch(r[a++]){case"0":this[t(289)][t(605)+t(720)+t(396)](e[t(863)],this[t(223)]);continue;case"1":this[t(289)]["removeEv"+t(720)+t(396)](e[t(1284)],this[t(1535)+"ge"]);continue;case"2":if(!this[t(289)])return;continue;case"3":this._ws["removeEv"+t(720)+t(396)]("close",this[t(932)]);continue;case"4":this[t(289)][t(605)+t(720)+t(396)](e[t(1214)],this[t(669)]);continue}break}}[n(718)+n(1195)](){let t=n,r={meQIu:function(a,x,f){return e[k(1542)](a,x,f)}};if(e[t(454)](e[t(961)],e[t(961)])){if(!this._ws)return;this[t(289)][t(884)+t(1425)](e[t(863)],this[t(223)]),this[t(289)][t(884)+"Listener"](t(1360),this[t(932)]),this[t(289)][t(884)+t(1425)](e.QCUmg,this[t(1535)+"ge"]),this[t(289)]["addEvent"+t(1425)](e.sukVs,this._onError)}else{let a=OFSyAS[t(1356)](_0x102534,_0x37141b,_0xf3ee67.length);_0x51292b[t(1582)][t(1651)](_0x35a005,a)}}[n(1217)+n(483)](t=1e3,r=""){let a=n;try{e[a(1629)]!==e[a(401)]?this[a(289)]&&this[a(289)][a(1360)](t,r):_0x21a84a.log(_0x482b1e)}catch{}}[n(506)+n(471)+"t"](t=1e3,r="",a=!1){let x=n;if(this[x(375)+x(1189)](),this[x(1399)+x(245)](),this[x(1210)+x(821)+"rs"](),this[x(1217)+x(483)](1e3,r),this[x(815)+x(202)]=!1,a&&this[x(1332)+x(1343)]()&&!this[x(1538)+x(1473)]){if(this[x(240)+x(302)]?.[x(874)+"chMaxTries"]()){let h=this[x(240)+x(302)]?.[x(695)+x(1180)+"nt"]();this[x(443)+"hCloseEv"+x(1434)](e[x(1204)](De,e[x(587)],{code:1006,reason:"connect "+h+(x(1038)+x(1186)+x(1272)+x(1418)),wasClean:!0}))}else{let h=this[x(388)][x(576)+x(1103)+x(1768)](t,r);this[x(443)+x(358)+x(1434)](e[x(976)](De,e.XEKJp,{code:t,reason:r,wasClean:!0,willReconnect:h})),h&&this[x(815)]()}return}this["_navigat"+x(1343)]()||this[x(1538)+"osed"]?this[x(443)+x(358)+"ent"](e[x(992)](De,x(1360),{code:t,reason:e[x(809)]})):this[x(443)+x(358)+x(1434)](e[x(356)](De,x(1360),{code:1006,reason:e[x(1591)]})),this[x(289)]=null,this[x(240)+x(302)]?.[x(226)+"pointCon"+x(277)](),this[x(273)+x(844)]?.[x(971)+x(1321)]()}[n(443)+n(1506)+"nt"](t){let r=n;this[r(1216)]("open",t),this[r(1364)]&&this[r(1364)](t)}[n(443)+n(535)+n(1081)](t){let r=n;this[r(1216)](e[r(1284)],t),this[r(641)+"e"]&&this.onmessage(t)}[n(443)+n(1648)+n(1713)](t){let r=n;this[r(1216)](e.pUhme,t),this[r(804)+r(979)]&&this[r(804)+"eAck"](t)}[n(443)+"hErrorEvent"](t){let r=n;this[r(1216)](e[r(1214)],t),this[r(440)]&&this[r(440)](t)}[n(443)+n(358)+"ent"](t){let r=n;this[r(1216)](r(1360),t),this[r(943)]&&this[r(943)](t)}get[n(1704)+"pe"](){let t=n;return this[t(289)]?this[t(289)].binaryType:this[t(1450)+t(1131)]}set binaryType(t){let r=n;this[r(1450)+"ype"]=t,this[r(289)]&&(this._ws.binaryType=t)}get[n(1064)+"nt"](){let t=n;if(t(339)===t(1079)){let r=_0x191465[t(1466)]();return r?(r[t(397)]=r[t(1572)]=0,r):{bytes:new _0x32041d(64),offset:0,limit:0}}else return this[t(240)+t(302)]?.["getCurre"+t(1180)+t(1721)+"ount"]()||0}get[n(891)+"Amount"](){let t=n;return this[t(1537)+t(550)][t(1091)]((a,x)=>(a+=x&&x[t(1062)+"th"]||0,a),0)+(this[t(289)]?this[t(289)][t(891)+t(890)]:0)}get extensions(){let t=n;return this[t(289)]?this[t(289)][t(1617)+"ns"]:""}get[n(1408)](){let t=n;return this[t(289)]?this[t(289)][t(1408)]:""}get readyState(){let t=n;return this[t(289)]?this._ws.readyState:this._options[t(1369)+t(541)]?this[t(1579)+"NG"]:this.CLOSED}get[n(1781)](){let t=n;return this[t(289)]?this[t(289)][t(1781)]:this[t(1417)]}close(t=1e3,r){let a=n,x=e[a(794)][a(1413)]("|"),f=0;for(;;){switch(x[f++]){case"0":this["_clearTi"+a(245)]();continue;case"1":if(this[a(289)][a(201)+"te"]===this[a(1067)]||this[a(289)][a(201)+"te"]===this[a(599)])return void this._debug(e.OfEqP);continue;case"2":if(!this._ws)return void this[a(1225)](e.yaYQc);continue;case"3":this[a(375)+a(1189)]();continue;case"4":this[a(409)+a(283)]?.[a(938)]();continue;case"5":this[a(506)+"WebSocket"](t,r);continue;case"6":this["_readyCl"+a(1473)]=!0;continue;case"7":this[a(822)+a(838)+a(1425)]();continue}break}}async[n(530)](t,r){let a=n;if(e.PHnMf(null,t))throw new Error(a(500)+a(1483)+a(759)+a(522)+"a must b"+a(997)+a(781)+a(513)+a(1057));e[a(1552)](e[a(666)],typeof t)&&(t=JSON[a(1577)+"y"](t)),e[a(607)](a(410),typeof t)&&!e.IeGpt(t,ArrayBuffer)&&!(t[a(1054)]&&e[a(1316)](t[a(1054)],ArrayBuffer))&&(t=JSON.stringify(t));let x=await e[a(547)](cs,t),f=e[a(1490)](Jc,t),{method:h=0,service:w=this[a(388)][a(745)],logID:g=this._options[a(1548)+a(1749)](),headers:b=this[a(388)][a(951)],payloadEncoding:v=this._options[a(900)+"ncoding"],payloadType:C=this[a(388)][a(384)+a(1131)],logIDNew:O=this._options[a(762)+a(1470)][a(463)+"toGenerateLogIDNew"]?e[a(1678)](o,this[a(388)][a(762)+"Config"][a(233)]):""}=r||{};if(!w)throw new Error(e[a(1367)]);let R={SeqID:G[a(764)+"er"](this[a(1251)]++),LogID:G[a(764)+"er"](g),service:w,method:h,headers:b,payloadEncoding:v instanceof Object?v[a(1323)]?v[a(1323)]:"":v,payloadType:C instanceof Object?C[a(1737)]?C[a(1737)]:f:C||f,payload:x,LogIDNew:O},F=e.mxQlT(re,R);return this[a(289)]&&e.cXPRr(this[a(289)][a(201)+"te"],this[a(1664)])?(this[a(289)]&&this[a(289)].send(F),this[a(1225)](e[a(840)],R)):this[a(1537)+a(550)].length<this._options[a(1014)+"geQueueL"+a(1574)]?(this[a(1537)+"Queue"][a(1774)](F),this[a(1225)](a(714),R)):(this._messageQueue.shift(),this[a(1537)+"Queue"][a(1774)](F)),{seqID:this[a(1251)],logID:g,logIDNew:O}}async[n(576)+"t"](t){let r=n,{url:a}=e[r(372)](t,{}),x=Array.isArray(a)?a:e.UaeLL==typeof a?[a]:[];t&&Object[r(1163)](this[r(388)],t),x&&x[r(796)]?this[r(240)+r(302)]=new is(x,this[r(388)][r(1032)+"es"]):this[r(240)+r(302)]?.["resetEnd"+r(404)+"fig"](),this[r(273)+r(844)]?.[r(971)+r(1321)](this[r(388)][r(299)+"Count"]),this[r(1538)+"osed"]=!1,this[r(289)]&&this[r(289)].readyState!==this.CLOSED?this[r(1455)+r(1717)](1e3,r(1296)+r(1345)+r(1523),!0):(this[r(393)]=!0,this._connect())}async[n(1394)](){let t=n;if(!this[t(815)+t(202)])if(e[t(896)](e.WxsID,t(220))){let r=e[t(594)](_0xdfd0a2,_0x46584c,1);_0x1560bf[t(1582)][r]=_0x175290}else{let r=e[t(1229)][t(1413)]("|"),a=0;for(;;){switch(r[a++]){case"0":this._connect();continue;case"1":this[t(273)+t(844)]?.[t(971)+t(1321)]();continue;case"2":this[t(1538)+t(1473)]=!1;continue;case"3":this[t(393)]=!0;continue;case"4":this[t(240)+t(302)]?.[t(226)+t(404)+"fig"]();continue}break}}}[n(884)+"Listener"](t,r){this.on(t,r)}[n(1586)+n(1081)](t){let r=n,{type:a}=t;this[r(1216)](a,t)}[n(605)+"entListe"+n(396)](t,r){this.off(t,r)}[n(1353)](){let t=n,r={RCXHO:function(a,x){return e[k(1149)](a,x)},egwBA:e[t(870)],oYIGm:e[t(611)]};return new Promise((a,x)=>{let f=t,h={ypzFe:function(b,v){return b(v)},jljzP:e[f(960)],WjrMQ:e.wVKst,faVAg:e[f(611)]};this["_clearPi"+f(1189)](),this._pingPongTimeoutId=setTimeout(this[f(1481)][f(854)](this),this._options[f(318)+"rval"]);let w=()=>{let b=f;r[b(704)](a,r[b(1746)]),this.off(b(1723)+b(1209)+"s",w),this[b(657)](r[b(869)],g)},g=()=>{let b=f;h[b(1193)](x,h[b(1388)]),this[b(657)](h[b(248)],w),this[b(657)](h[b(860)],g)};this.on(e[f(768)],w),this.on(e[f(611)],g),this[f(1481)]()})}}})(),Y["CustomCl"+E(663)]=te.CustomCloseEvent,Y[E(1095)+E(729)]=te[E(1095)+E(729)],Y[E(898)+"e"]=te[E(898)+"e"],Y[E(1081)]=te[E(1081)],Y[E(1357)]=te[E(1357)],Y["Frontier"+E(1554)+"vent"]=te["Frontier"+E(1554)+E(1235)],Y[E(1554)+E(1235)]=te[E(1554)+E(1235)],Y.OpenEvent=te.OpenEvent,Y[E(912)+E(1588)]=te[E(912)+E(1588)],Y[E(241)+E(663)]=te[E(241)+E(663)],Y.createErrorEvent=te[E(1550)+E(729)],Y[E(858)+E(1456)+"nt"]=te["createMe"+E(1456)+"nt"],Y[E(1670)+E(1171)]=te[E(1670)+E(1171)],Y[E(387)+"connectE"+E(1235)]=te[E(387)+E(292)+E(1235)],Y[E(385)+E(991)]=te[E(385)+E(991)],Y[E(338)+E(981)]=te[E(338)+E(981)];for(Yn in te)[E(1277)+E(663),"CustomEr"+E(729),E(898)+"e",E(1081),E(1357),E(727)+E(1554)+E(1235),E(1554)+E(1235),"OpenEvent",E(912)+E(1588),E(241)+E(663),E(1550)+E(729),E(858)+E(1456)+"nt","createOpenEvent",E(387)+"connectE"+E(1235),E(385)+E(991),E(338)+E(981)].indexOf(Yn)===-1&&(Y[Yn]=te[Yn]);var Yn;Object["definePr"+E(1778)](Y,E(1056)+"le",{value:!0})});var Je=_e((e_,ta)=>{"use strict";var Zo=["nodebuffer","arraybuffer","fragments"],ea=typeof Blob<"u";ea&&Zo.push("blob");ta.exports={BINARY_TYPES:Zo,CLOSE_TIMEOUT:3e4,EMPTY_BUFFER:Buffer.alloc(0),GUID:"258EAFA5-E914-47DA-95CA-C5AB0DC85B11",hasBlob:ea,kForOnEventAttribute:Symbol("kIsForOnEventAttribute"),kListener:Symbol("kListener"),kStatusCode:Symbol("status-code"),kWebSocket:Symbol("websocket"),NOOP:()=>{}}});var an=_e((t_,rr)=>{"use strict";var{EMPTY_BUFFER:rf}=Je(),di=Buffer[Symbol.species];function sf(n,e){if(n.length===0)return rf;if(n.length===1)return n[0];let s=Buffer.allocUnsafe(e),o=0;for(let c=0;c<n.length;c++){let d=n[c];s.set(d,o),o+=d.length}return o<e?new di(s.buffer,s.byteOffset,o):s}function na(n,e,s,o,c){for(let d=0;d<c;d++)s[o+d]=n[d]^e[d&3]}function ra(n,e){for(let s=0;s<n.length;s++)n[s]^=e[s&3]}function of(n){return n.length===n.buffer.byteLength?n.buffer:n.buffer.slice(n.byteOffset,n.byteOffset+n.length)}function ui(n){if(ui.readOnly=!0,Buffer.isBuffer(n))return n;let e;return n instanceof ArrayBuffer?e=new di(n):ArrayBuffer.isView(n)?e=new di(n.buffer,n.byteOffset,n.byteLength):(e=Buffer.from(n),ui.readOnly=!1),e}rr.exports={concat:sf,mask:na,toArrayBuffer:of,toBuffer:ui,unmask:ra};if(!process.env.WS_NO_BUFFER_UTIL)try{let n=ee("bufferutil");rr.exports.mask=function(e,s,o,c,d){d<48?na(e,s,o,c,d):n.mask(e,s,o,c,d)},rr.exports.unmask=function(e,s){e.length<32?ra(e,s):n.unmask(e,s)}}catch{}});var oa=_e((n_,sa)=>{"use strict";var ia=Symbol("kDone"),fi=Symbol("kRun"),li=class{constructor(e){this[ia]=()=>{this.pending--,this[fi]()},this.concurrency=e||1/0,this.jobs=[],this.pending=0}add(e){this.jobs.push(e),this[fi]()}[fi](){if(this.pending!==this.concurrency&&this.jobs.length){let e=this.jobs.shift();this.pending++,e(this[ia])}}};sa.exports=li});var Mt=_e((r_,da)=>{"use strict";var cn=ee("zlib"),aa=an(),af=oa(),{kStatusCode:ca}=Je(),cf=Buffer[Symbol.species],xf=Buffer.from([0,0,255,255]),sr=Symbol("permessage-deflate"),$e=Symbol("total-length"),Ot=Symbol("callback"),ct=Symbol("buffers"),Nt=Symbol("error"),ir,gi=class{constructor(e){if(this._options=e||{},this._threshold=this._options.threshold!==void 0?this._options.threshold:1024,this._maxPayload=this._options.maxPayload|0,this._isServer=!!this._options.isServer,this._deflate=null,this._inflate=null,this.params=null,!ir){let s=this._options.concurrencyLimit!==void 0?this._options.concurrencyLimit:10;ir=new af(s)}}static get extensionName(){return"permessage-deflate"}offer(){let e={};return this._options.serverNoContextTakeover&&(e.server_no_context_takeover=!0),this._options.clientNoContextTakeover&&(e.client_no_context_takeover=!0),this._options.serverMaxWindowBits&&(e.server_max_window_bits=this._options.serverMaxWindowBits),this._options.clientMaxWindowBits?e.client_max_window_bits=this._options.clientMaxWindowBits:this._options.clientMaxWindowBits==null&&(e.client_max_window_bits=!0),e}accept(e){return e=this.normalizeParams(e),this.params=this._isServer?this.acceptAsServer(e):this.acceptAsClient(e),this.params}cleanup(){if(this._inflate&&(this._inflate.close(),this._inflate=null),this._deflate){let e=this._deflate[Ot];this._deflate.close(),this._deflate=null,e&&e(new Error("The deflate stream was closed while data was being processed"))}}acceptAsServer(e){let s=this._options,o=e.find(c=>!(s.serverNoContextTakeover===!1&&c.server_no_context_takeover||c.server_max_window_bits&&(s.serverMaxWindowBits===!1||typeof s.serverMaxWindowBits=="number"&&s.serverMaxWindowBits>c.server_max_window_bits)||typeof s.clientMaxWindowBits=="number"&&!c.client_max_window_bits));if(!o)throw new Error("None of the extension offers can be accepted");return s.serverNoContextTakeover&&(o.server_no_context_takeover=!0),s.clientNoContextTakeover&&(o.client_no_context_takeover=!0),typeof s.serverMaxWindowBits=="number"&&(o.server_max_window_bits=s.serverMaxWindowBits),typeof s.clientMaxWindowBits=="number"?o.client_max_window_bits=s.clientMaxWindowBits:(o.client_max_window_bits===!0||s.clientMaxWindowBits===!1)&&delete o.client_max_window_bits,o}acceptAsClient(e){let s=e[0];if(this._options.clientNoContextTakeover===!1&&s.client_no_context_takeover)throw new Error('Unexpected parameter "client_no_context_takeover"');if(!s.client_max_window_bits)typeof this._options.clientMaxWindowBits=="number"&&(s.client_max_window_bits=this._options.clientMaxWindowBits);else if(this._options.clientMaxWindowBits===!1||typeof this._options.clientMaxWindowBits=="number"&&s.client_max_window_bits>this._options.clientMaxWindowBits)throw new Error('Unexpected or invalid parameter "client_max_window_bits"');return s}normalizeParams(e){return e.forEach(s=>{Object.keys(s).forEach(o=>{let c=s[o];if(c.length>1)throw new Error(`Parameter "${o}" must have only a single value`);if(c=c[0],o==="client_max_window_bits"){if(c!==!0){let d=+c;if(!Number.isInteger(d)||d<8||d>15)throw new TypeError(`Invalid value for parameter "${o}": ${c}`);c=d}else if(!this._isServer)throw new TypeError(`Invalid value for parameter "${o}": ${c}`)}else if(o==="server_max_window_bits"){let d=+c;if(!Number.isInteger(d)||d<8||d>15)throw new TypeError(`Invalid value for parameter "${o}": ${c}`);c=d}else if(o==="client_no_context_takeover"||o==="server_no_context_takeover"){if(c!==!0)throw new TypeError(`Invalid value for parameter "${o}": ${c}`)}else throw new Error(`Unknown parameter "${o}"`);s[o]=c})}),e}decompress(e,s,o){ir.add(c=>{this._decompress(e,s,(d,u)=>{c(),o(d,u)})})}compress(e,s,o){ir.add(c=>{this._compress(e,s,(d,u)=>{c(),o(d,u)})})}_decompress(e,s,o){let c=this._isServer?"client":"server";if(!this._inflate){let d=`${c}_max_window_bits`,u=typeof this.params[d]!="number"?cn.Z_DEFAULT_WINDOWBITS:this.params[d];this._inflate=cn.createInflateRaw({...this._options.zlibInflateOptions,windowBits:u}),this._inflate[sr]=this,this._inflate[$e]=0,this._inflate[ct]=[],this._inflate.on("error",uf),this._inflate.on("data",xa)}this._inflate[Ot]=o,this._inflate.write(e),s&&this._inflate.write(xf),this._inflate.flush(()=>{let d=this._inflate[Nt];if(d){this._inflate.close(),this._inflate=null,o(d);return}let u=aa.concat(this._inflate[ct],this._inflate[$e]);this._inflate._readableState.endEmitted?(this._inflate.close(),this._inflate=null):(this._inflate[$e]=0,this._inflate[ct]=[],s&&this.params[`${c}_no_context_takeover`]&&this._inflate.reset()),o(null,u)})}_compress(e,s,o){let c=this._isServer?"server":"client";if(!this._deflate){let d=`${c}_max_window_bits`,u=typeof this.params[d]!="number"?cn.Z_DEFAULT_WINDOWBITS:this.params[d];this._deflate=cn.createDeflateRaw({...this._options.zlibDeflateOptions,windowBits:u}),this._deflate[$e]=0,this._deflate[ct]=[],this._deflate.on("data",df)}this._deflate[Ot]=o,this._deflate.write(e),this._deflate.flush(cn.Z_SYNC_FLUSH,()=>{if(!this._deflate)return;let d=aa.concat(this._deflate[ct],this._deflate[$e]);s&&(d=new cf(d.buffer,d.byteOffset,d.length-4)),this._deflate[Ot]=null,this._deflate[$e]=0,this._deflate[ct]=[],s&&this.params[`${c}_no_context_takeover`]&&this._deflate.reset(),o(null,d)})}};da.exports=gi;function df(n){this[ct].push(n),this[$e]+=n.length}function xa(n){if(this[$e]+=n.length,this[sr]._maxPayload<1||this[$e]<=this[sr]._maxPayload){this[ct].push(n);return}this[Nt]=new RangeError("Max payload size exceeded"),this[Nt].code="WS_ERR_UNSUPPORTED_MESSAGE_LENGTH",this[Nt][ca]=1009,this.removeListener("data",xa),this.reset()}function uf(n){if(this[sr]._inflate=null,this[Nt]){this[Ot](this[Nt]);return}n[ca]=1007,this[Ot](n)}});var Bt=_e((i_,or)=>{"use strict";var{isUtf8:ua}=ee("buffer"),{hasBlob:ff}=Je(),lf=[0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,1,0,1,1,1,1,1,0,0,1,1,0,1,1,0,1,1,1,1,1,1,1,1,1,1,0,0,0,0,0,0,0,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,0,0,0,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,0,1,0,1,0];function gf(n){return n>=1e3&&n<=1014&&n!==1004&&n!==1005&&n!==1006||n>=3e3&&n<=4999}function hi(n){let e=n.length,s=0;for(;s<e;)if((n[s]&128)===0)s++;else if((n[s]&224)===192){if(s+1===e||(n[s+1]&192)!==128||(n[s]&254)===192)return!1;s+=2}else if((n[s]&240)===224){if(s+2>=e||(n[s+1]&192)!==128||(n[s+2]&192)!==128||n[s]===224&&(n[s+1]&224)===128||n[s]===237&&(n[s+1]&224)===160)return!1;s+=3}else if((n[s]&248)===240){if(s+3>=e||(n[s+1]&192)!==128||(n[s+2]&192)!==128||(n[s+3]&192)!==128||n[s]===240&&(n[s+1]&240)===128||n[s]===244&&n[s+1]>143||n[s]>244)return!1;s+=4}else return!1;return!0}function hf(n){return ff&&typeof n=="object"&&typeof n.arrayBuffer=="function"&&typeof n.type=="string"&&typeof n.stream=="function"&&(n[Symbol.toStringTag]==="Blob"||n[Symbol.toStringTag]==="File")}or.exports={isBlob:hf,isValidStatusCode:gf,isValidUTF8:hi,tokenChars:lf};if(ua)or.exports.isValidUTF8=function(n){return n.length<24?hi(n):ua(n)};else if(!process.env.WS_NO_UTF_8_VALIDATE)try{let n=ee("utf-8-validate");or.exports.isValidUTF8=function(e){return e.length<32?hi(e):n(e)}}catch{}});var yi=_e((s_,wa)=>{"use strict";var{Writable:pf}=ee("stream"),fa=Mt(),{BINARY_TYPES:mf,EMPTY_BUFFER:la,kStatusCode:wf,kWebSocket:_f}=Je(),{concat:pi,toArrayBuffer:yf,unmask:bf}=an(),{isValidStatusCode:vf,isValidUTF8:ga}=Bt(),ar=Buffer[Symbol.species],Pe=0,ha=1,pa=2,ma=3,mi=4,wi=5,cr=6,_i=class extends pf{constructor(e={}){super(),this._allowSynchronousEvents=e.allowSynchronousEvents!==void 0?e.allowSynchronousEvents:!0,this._binaryType=e.binaryType||mf[0],this._extensions=e.extensions||{},this._isServer=!!e.isServer,this._maxPayload=e.maxPayload|0,this._skipUTF8Validation=!!e.skipUTF8Validation,this[_f]=void 0,this._bufferedBytes=0,this._buffers=[],this._compressed=!1,this._payloadLength=0,this._mask=void 0,this._fragmented=0,this._masked=!1,this._fin=!1,this._opcode=0,this._totalPayloadLength=0,this._messageLength=0,this._fragments=[],this._errored=!1,this._loop=!1,this._state=Pe}_write(e,s,o){if(this._opcode===8&&this._state==Pe)return o();this._bufferedBytes+=e.length,this._buffers.push(e),this.startLoop(o)}consume(e){if(this._bufferedBytes-=e,e===this._buffers[0].length)return this._buffers.shift();if(e<this._buffers[0].length){let o=this._buffers[0];return this._buffers[0]=new ar(o.buffer,o.byteOffset+e,o.length-e),new ar(o.buffer,o.byteOffset,e)}let s=Buffer.allocUnsafe(e);do{let o=this._buffers[0],c=s.length-e;e>=o.length?s.set(this._buffers.shift(),c):(s.set(new Uint8Array(o.buffer,o.byteOffset,e),c),this._buffers[0]=new ar(o.buffer,o.byteOffset+e,o.length-e)),e-=o.length}while(e>0);return s}startLoop(e){this._loop=!0;do switch(this._state){case Pe:this.getInfo(e);break;case ha:this.getPayloadLength16(e);break;case pa:this.getPayloadLength64(e);break;case ma:this.getMask();break;case mi:this.getData(e);break;case wi:case cr:this._loop=!1;return}while(this._loop);this._errored||e()}getInfo(e){if(this._bufferedBytes<2){this._loop=!1;return}let s=this.consume(2);if((s[0]&48)!==0){let c=this.createError(RangeError,"RSV2 and RSV3 must be clear",!0,1002,"WS_ERR_UNEXPECTED_RSV_2_3");e(c);return}let o=(s[0]&64)===64;if(o&&!this._extensions[fa.extensionName]){let c=this.createError(RangeError,"RSV1 must be clear",!0,1002,"WS_ERR_UNEXPECTED_RSV_1");e(c);return}if(this._fin=(s[0]&128)===128,this._opcode=s[0]&15,this._payloadLength=s[1]&127,this._opcode===0){if(o){let c=this.createError(RangeError,"RSV1 must be clear",!0,1002,"WS_ERR_UNEXPECTED_RSV_1");e(c);return}if(!this._fragmented){let c=this.createError(RangeError,"invalid opcode 0",!0,1002,"WS_ERR_INVALID_OPCODE");e(c);return}this._opcode=this._fragmented}else if(this._opcode===1||this._opcode===2){if(this._fragmented){let c=this.createError(RangeError,`invalid opcode ${this._opcode}`,!0,1002,"WS_ERR_INVALID_OPCODE");e(c);return}this._compressed=o}else if(this._opcode>7&&this._opcode<11){if(!this._fin){let c=this.createError(RangeError,"FIN must be set",!0,1002,"WS_ERR_EXPECTED_FIN");e(c);return}if(o){let c=this.createError(RangeError,"RSV1 must be clear",!0,1002,"WS_ERR_UNEXPECTED_RSV_1");e(c);return}if(this._payloadLength>125||this._opcode===8&&this._payloadLength===1){let c=this.createError(RangeError,`invalid payload length ${this._payloadLength}`,!0,1002,"WS_ERR_INVALID_CONTROL_PAYLOAD_LENGTH");e(c);return}}else{let c=this.createError(RangeError,`invalid opcode ${this._opcode}`,!0,1002,"WS_ERR_INVALID_OPCODE");e(c);return}if(!this._fin&&!this._fragmented&&(this._fragmented=this._opcode),this._masked=(s[1]&128)===128,this._isServer){if(!this._masked){let c=this.createError(RangeError,"MASK must be set",!0,1002,"WS_ERR_EXPECTED_MASK");e(c);return}}else if(this._masked){let c=this.createError(RangeError,"MASK must be clear",!0,1002,"WS_ERR_UNEXPECTED_MASK");e(c);return}this._payloadLength===126?this._state=ha:this._payloadLength===127?this._state=pa:this.haveLength(e)}getPayloadLength16(e){if(this._bufferedBytes<2){this._loop=!1;return}this._payloadLength=this.consume(2).readUInt16BE(0),this.haveLength(e)}getPayloadLength64(e){if(this._bufferedBytes<8){this._loop=!1;return}let s=this.consume(8),o=s.readUInt32BE(0);if(o>Math.pow(2,21)-1){let c=this.createError(RangeError,"Unsupported WebSocket frame: payload length > 2^53 - 1",!1,1009,"WS_ERR_UNSUPPORTED_DATA_PAYLOAD_LENGTH");e(c);return}this._payloadLength=o*Math.pow(2,32)+s.readUInt32BE(4),this.haveLength(e)}haveLength(e){if(this._payloadLength&&this._opcode<8&&(this._totalPayloadLength+=this._payloadLength,this._totalPayloadLength>this._maxPayload&&this._maxPayload>0)){let s=this.createError(RangeError,"Max payload size exceeded",!1,1009,"WS_ERR_UNSUPPORTED_MESSAGE_LENGTH");e(s);return}this._masked?this._state=ma:this._state=mi}getMask(){if(this._bufferedBytes<4){this._loop=!1;return}this._mask=this.consume(4),this._state=mi}getData(e){let s=la;if(this._payloadLength){if(this._bufferedBytes<this._payloadLength){this._loop=!1;return}s=this.consume(this._payloadLength),this._masked&&(this._mask[0]|this._mask[1]|this._mask[2]|this._mask[3])!==0&&bf(s,this._mask)}if(this._opcode>7){this.controlMessage(s,e);return}if(this._compressed){this._state=wi,this.decompress(s,e);return}s.length&&(this._messageLength=this._totalPayloadLength,this._fragments.push(s)),this.dataMessage(e)}decompress(e,s){this._extensions[fa.extensionName].decompress(e,this._fin,(c,d)=>{if(c)return s(c);if(d.length){if(this._messageLength+=d.length,this._messageLength>this._maxPayload&&this._maxPayload>0){let u=this.createError(RangeError,"Max payload size exceeded",!1,1009,"WS_ERR_UNSUPPORTED_MESSAGE_LENGTH");s(u);return}this._fragments.push(d)}this.dataMessage(s),this._state===Pe&&this.startLoop(s)})}dataMessage(e){if(!this._fin){this._state=Pe;return}let s=this._messageLength,o=this._fragments;if(this._totalPayloadLength=0,this._messageLength=0,this._fragmented=0,this._fragments=[],this._opcode===2){let c;this._binaryType==="nodebuffer"?c=pi(o,s):this._binaryType==="arraybuffer"?c=yf(pi(o,s)):this._binaryType==="blob"?c=new Blob(o):c=o,this._allowSynchronousEvents?(this.emit("message",c,!0),this._state=Pe):(this._state=cr,setImmediate(()=>{this.emit("message",c,!0),this._state=Pe,this.startLoop(e)}))}else{let c=pi(o,s);if(!this._skipUTF8Validation&&!ga(c)){let d=this.createError(Error,"invalid UTF-8 sequence",!0,1007,"WS_ERR_INVALID_UTF8");e(d);return}this._state===wi||this._allowSynchronousEvents?(this.emit("message",c,!1),this._state=Pe):(this._state=cr,setImmediate(()=>{this.emit("message",c,!1),this._state=Pe,this.startLoop(e)}))}}controlMessage(e,s){if(this._opcode===8){if(e.length===0)this._loop=!1,this.emit("conclude",1005,la),this.end();else{let o=e.readUInt16BE(0);if(!vf(o)){let d=this.createError(RangeError,`invalid status code ${o}`,!0,1002,"WS_ERR_INVALID_CLOSE_CODE");s(d);return}let c=new ar(e.buffer,e.byteOffset+2,e.length-2);if(!this._skipUTF8Validation&&!ga(c)){let d=this.createError(Error,"invalid UTF-8 sequence",!0,1007,"WS_ERR_INVALID_UTF8");s(d);return}this._loop=!1,this.emit("conclude",o,c),this.end()}this._state=Pe;return}this._allowSynchronousEvents?(this.emit(this._opcode===9?"ping":"pong",e),this._state=Pe):(this._state=cr,setImmediate(()=>{this.emit(this._opcode===9?"ping":"pong",e),this._state=Pe,this.startLoop(s)}))}createError(e,s,o,c,d){this._loop=!1,this._errored=!0;let u=new e(o?`Invalid WebSocket frame: ${s}`:s);return Error.captureStackTrace(u,this.createError),u.code=d,u[wf]=c,u}};wa.exports=_i});var Si=_e((a_,ba)=>{"use strict";var{Duplex:o_}=ee("stream"),{randomFillSync:Sf}=ee("crypto"),_a=Mt(),{EMPTY_BUFFER:Ef,kWebSocket:If,NOOP:Af}=Je(),{isBlob:zt,isValidStatusCode:Cf}=Bt(),{mask:ya,toBuffer:lt}=an(),ke=Symbol("kByteLength"),Pf=Buffer.alloc(4),xr=8*1024,gt,Ft=xr,Re=0,kf=1,Tf=2,bi=class n{constructor(e,s,o){this._extensions=s||{},o&&(this._generateMask=o,this._maskBuffer=Buffer.alloc(4)),this._socket=e,this._firstFragment=!0,this._compress=!1,this._bufferedBytes=0,this._queue=[],this._state=Re,this.onerror=Af,this[If]=void 0}static frame(e,s){let o,c=!1,d=2,u=!1;s.mask&&(o=s.maskBuffer||Pf,s.generateMask?s.generateMask(o):(Ft===xr&&(gt===void 0&&(gt=Buffer.alloc(xr)),Sf(gt,0,xr),Ft=0),o[0]=gt[Ft++],o[1]=gt[Ft++],o[2]=gt[Ft++],o[3]=gt[Ft++]),u=(o[0]|o[1]|o[2]|o[3])===0,d=6);let l;typeof e=="string"?(!s.mask||u)&&s[ke]!==void 0?l=s[ke]:(e=Buffer.from(e),l=e.length):(l=e.length,c=s.mask&&s.readOnly&&!u);let p=l;l>=65536?(d+=8,p=127):l>125&&(d+=2,p=126);let m=Buffer.allocUnsafe(c?l+d:d);return m[0]=s.fin?s.opcode|128:s.opcode,s.rsv1&&(m[0]|=64),m[1]=p,p===126?m.writeUInt16BE(l,2):p===127&&(m[2]=m[3]=0,m.writeUIntBE(l,4,6)),s.mask?(m[1]|=128,m[d-4]=o[0],m[d-3]=o[1],m[d-2]=o[2],m[d-1]=o[3],u?[m,e]:c?(ya(e,o,m,d,l),[m]):(ya(e,o,e,0,l),[m,e])):[m,e]}close(e,s,o,c){let d;if(e===void 0)d=Ef;else{if(typeof e!="number"||!Cf(e))throw new TypeError("First argument must be a valid error code number");if(s===void 0||!s.length)d=Buffer.allocUnsafe(2),d.writeUInt16BE(e,0);else{let l=Buffer.byteLength(s);if(l>123)throw new RangeError("The message must not be greater than 123 bytes");d=Buffer.allocUnsafe(2+l),d.writeUInt16BE(e,0),typeof s=="string"?d.write(s,2):d.set(s,2)}}let u={[ke]:d.length,fin:!0,generateMask:this._generateMask,mask:o,maskBuffer:this._maskBuffer,opcode:8,readOnly:!1,rsv1:!1};this._state!==Re?this.enqueue([this.dispatch,d,!1,u,c]):this.sendFrame(n.frame(d,u),c)}ping(e,s,o){let c,d;if(typeof e=="string"?(c=Buffer.byteLength(e),d=!1):zt(e)?(c=e.size,d=!1):(e=lt(e),c=e.length,d=lt.readOnly),c>125)throw new RangeError("The data size must not be greater than 125 bytes");let u={[ke]:c,fin:!0,generateMask:this._generateMask,mask:s,maskBuffer:this._maskBuffer,opcode:9,readOnly:d,rsv1:!1};zt(e)?this._state!==Re?this.enqueue([this.getBlobData,e,!1,u,o]):this.getBlobData(e,!1,u,o):this._state!==Re?this.enqueue([this.dispatch,e,!1,u,o]):this.sendFrame(n.frame(e,u),o)}pong(e,s,o){let c,d;if(typeof e=="string"?(c=Buffer.byteLength(e),d=!1):zt(e)?(c=e.size,d=!1):(e=lt(e),c=e.length,d=lt.readOnly),c>125)throw new RangeError("The data size must not be greater than 125 bytes");let u={[ke]:c,fin:!0,generateMask:this._generateMask,mask:s,maskBuffer:this._maskBuffer,opcode:10,readOnly:d,rsv1:!1};zt(e)?this._state!==Re?this.enqueue([this.getBlobData,e,!1,u,o]):this.getBlobData(e,!1,u,o):this._state!==Re?this.enqueue([this.dispatch,e,!1,u,o]):this.sendFrame(n.frame(e,u),o)}send(e,s,o){let c=this._extensions[_a.extensionName],d=s.binary?2:1,u=s.compress,l,p;typeof e=="string"?(l=Buffer.byteLength(e),p=!1):zt(e)?(l=e.size,p=!1):(e=lt(e),l=e.length,p=lt.readOnly),this._firstFragment?(this._firstFragment=!1,u&&c&&c.params[c._isServer?"server_no_context_takeover":"client_no_context_takeover"]&&(u=l>=c._threshold),this._compress=u):(u=!1,d=0),s.fin&&(this._firstFragment=!0);let m={[ke]:l,fin:s.fin,generateMask:this._generateMask,mask:s.mask,maskBuffer:this._maskBuffer,opcode:d,readOnly:p,rsv1:u};zt(e)?this._state!==Re?this.enqueue([this.getBlobData,e,this._compress,m,o]):this.getBlobData(e,this._compress,m,o):this._state!==Re?this.enqueue([this.dispatch,e,this._compress,m,o]):this.dispatch(e,this._compress,m,o)}getBlobData(e,s,o,c){this._bufferedBytes+=o[ke],this._state=Tf,e.arrayBuffer().then(d=>{if(this._socket.destroyed){let l=new Error("The socket was closed while the blob was being read");process.nextTick(vi,this,l,c);return}this._bufferedBytes-=o[ke];let u=lt(d);s?this.dispatch(u,s,o,c):(this._state=Re,this.sendFrame(n.frame(u,o),c),this.dequeue())}).catch(d=>{process.nextTick(Df,this,d,c)})}dispatch(e,s,o,c){if(!s){this.sendFrame(n.frame(e,o),c);return}let d=this._extensions[_a.extensionName];this._bufferedBytes+=o[ke],this._state=kf,d.compress(e,o.fin,(u,l)=>{if(this._socket.destroyed){let p=new Error("The socket was closed while data was being compressed");vi(this,p,c);return}this._bufferedBytes-=o[ke],this._state=Re,o.readOnly=!1,this.sendFrame(n.frame(l,o),c),this.dequeue()})}dequeue(){for(;this._state===Re&&this._queue.length;){let e=this._queue.shift();this._bufferedBytes-=e[3][ke],Reflect.apply(e[0],this,e.slice(1))}}enqueue(e){this._bufferedBytes+=e[3][ke],this._queue.push(e)}sendFrame(e,s){e.length===2?(this._socket.cork(),this._socket.write(e[0]),this._socket.write(e[1],s),this._socket.uncork()):this._socket.write(e[0],s)}};ba.exports=bi;function vi(n,e,s){typeof s=="function"&&s(e);for(let o=0;o<n._queue.length;o++){let c=n._queue[o],d=c[c.length-1];typeof d=="function"&&d(e)}}function Df(n,e,s){vi(n,e,s),n.onerror(e)}});var Ta=_e((c_,ka)=>{"use strict";var{kForOnEventAttribute:xn,kListener:Ei}=Je(),va=Symbol("kCode"),Sa=Symbol("kData"),Ea=Symbol("kError"),Ia=Symbol("kMessage"),Aa=Symbol("kReason"),Ut=Symbol("kTarget"),Ca=Symbol("kType"),Pa=Symbol("kWasClean"),Ve=class{constructor(e){this[Ut]=null,this[Ca]=e}get target(){return this[Ut]}get type(){return this[Ca]}};Object.defineProperty(Ve.prototype,"target",{enumerable:!0});Object.defineProperty(Ve.prototype,"type",{enumerable:!0});var ht=class extends Ve{constructor(e,s={}){super(e),this[va]=s.code===void 0?0:s.code,this[Aa]=s.reason===void 0?"":s.reason,this[Pa]=s.wasClean===void 0?!1:s.wasClean}get code(){return this[va]}get reason(){return this[Aa]}get wasClean(){return this[Pa]}};Object.defineProperty(ht.prototype,"code",{enumerable:!0});Object.defineProperty(ht.prototype,"reason",{enumerable:!0});Object.defineProperty(ht.prototype,"wasClean",{enumerable:!0});var qt=class extends Ve{constructor(e,s={}){super(e),this[Ea]=s.error===void 0?null:s.error,this[Ia]=s.message===void 0?"":s.message}get error(){return this[Ea]}get message(){return this[Ia]}};Object.defineProperty(qt.prototype,"error",{enumerable:!0});Object.defineProperty(qt.prototype,"message",{enumerable:!0});var dn=class extends Ve{constructor(e,s={}){super(e),this[Sa]=s.data===void 0?null:s.data}get data(){return this[Sa]}};Object.defineProperty(dn.prototype,"data",{enumerable:!0});var Rf={addEventListener(n,e,s={}){for(let c of this.listeners(n))if(!s[xn]&&c[Ei]===e&&!c[xn])return;let o;if(n==="message")o=function(d,u){let l=new dn("message",{data:u?d:d.toString()});l[Ut]=this,dr(e,this,l)};else if(n==="close")o=function(d,u){let l=new ht("close",{code:d,reason:u.toString(),wasClean:this._closeFrameReceived&&this._closeFrameSent});l[Ut]=this,dr(e,this,l)};else if(n==="error")o=function(d){let u=new qt("error",{error:d,message:d.message});u[Ut]=this,dr(e,this,u)};else if(n==="open")o=function(){let d=new Ve("open");d[Ut]=this,dr(e,this,d)};else return;o[xn]=!!s[xn],o[Ei]=e,s.once?this.once(n,o):this.on(n,o)},removeEventListener(n,e){for(let s of this.listeners(n))if(s[Ei]===e&&!s[xn]){this.removeListener(n,s);break}}};ka.exports={CloseEvent:ht,ErrorEvent:qt,Event:Ve,EventTarget:Rf,MessageEvent:dn};function dr(n,e,s){typeof n=="object"&&n.handleEvent?n.handleEvent.call(n,s):n.call(e,s)}});var ur=_e((x_,Da)=>{"use strict";var{tokenChars:un}=Bt();function qe(n,e,s){n[e]===void 0?n[e]=[s]:n[e].push(s)}function Lf(n){let e=Object.create(null),s=Object.create(null),o=!1,c=!1,d=!1,u,l,p=-1,m=-1,_=-1,y=0;for(;y<n.length;y++)if(m=n.charCodeAt(y),u===void 0)if(_===-1&&un[m]===1)p===-1&&(p=y);else if(y!==0&&(m===32||m===9))_===-1&&p!==-1&&(_=y);else if(m===59||m===44){if(p===-1)throw new SyntaxError(`Unexpected character at index ${y}`);_===-1&&(_=y);let L=n.slice(p,_);m===44?(qe(e,L,s),s=Object.create(null)):u=L,p=_=-1}else throw new SyntaxError(`Unexpected character at index ${y}`);else if(l===void 0)if(_===-1&&un[m]===1)p===-1&&(p=y);else if(m===32||m===9)_===-1&&p!==-1&&(_=y);else if(m===59||m===44){if(p===-1)throw new SyntaxError(`Unexpected character at index ${y}`);_===-1&&(_=y),qe(s,n.slice(p,_),!0),m===44&&(qe(e,u,s),s=Object.create(null),u=void 0),p=_=-1}else if(m===61&&p!==-1&&_===-1)l=n.slice(p,y),p=_=-1;else throw new SyntaxError(`Unexpected character at index ${y}`);else if(c){if(un[m]!==1)throw new SyntaxError(`Unexpected character at index ${y}`);p===-1?p=y:o||(o=!0),c=!1}else if(d)if(un[m]===1)p===-1&&(p=y);else if(m===34&&p!==-1)d=!1,_=y;else if(m===92)c=!0;else throw new SyntaxError(`Unexpected character at index ${y}`);else if(m===34&&n.charCodeAt(y-1)===61)d=!0;else if(_===-1&&un[m]===1)p===-1&&(p=y);else if(p!==-1&&(m===32||m===9))_===-1&&(_=y);else if(m===59||m===44){if(p===-1)throw new SyntaxError(`Unexpected character at index ${y}`);_===-1&&(_=y);let L=n.slice(p,_);o&&(L=L.replace(/\\/g,""),o=!1),qe(s,l,L),m===44&&(qe(e,u,s),s=Object.create(null),u=void 0),l=void 0,p=_=-1}else throw new SyntaxError(`Unexpected character at index ${y}`);if(p===-1||d||m===32||m===9)throw new SyntaxError("Unexpected end of input");_===-1&&(_=y);let I=n.slice(p,_);return u===void 0?qe(e,I,s):(l===void 0?qe(s,I,!0):o?qe(s,l,I.replace(/\\/g,"")):qe(s,l,I),qe(e,u,s)),e}function Of(n){return Object.keys(n).map(e=>{let s=n[e];return Array.isArray(s)||(s=[s]),s.map(o=>[e].concat(Object.keys(o).map(c=>{let d=o[c];return Array.isArray(d)||(d=[d]),d.map(u=>u===!0?c:`${c}=${u}`).join("; ")})).join("; ")).join(", ")}).join(", ")}Da.exports={format:Of,parse:Lf}});var hr=_e((f_,ja)=>{"use strict";var Nf=ee("events"),Mf=ee("https"),Bf=ee("http"),Oa=ee("net"),zf=ee("tls"),{randomBytes:Ff,createHash:Uf}=ee("crypto"),{Duplex:d_,Readable:u_}=ee("stream"),{URL:Ii}=ee("url"),xt=Mt(),qf=yi(),Hf=Si(),{isBlob:jf}=Bt(),{BINARY_TYPES:Ra,CLOSE_TIMEOUT:Kf,EMPTY_BUFFER:fr,GUID:Gf,kForOnEventAttribute:Ai,kListener:Wf,kStatusCode:Jf,kWebSocket:ce,NOOP:Na}=Je(),{EventTarget:{addEventListener:$f,removeEventListener:Vf}}=Ta(),{format:Yf,parse:Xf}=ur(),{toBuffer:Qf}=an(),Ma=Symbol("kAborted"),Ci=[8,13],Ye=["CONNECTING","OPEN","CLOSING","CLOSED"],Zf=/^[!#$%&'*+\-.0-9A-Z^_`|a-z~]+$/,J=class n extends Nf{constructor(e,s,o){super(),this._binaryType=Ra[0],this._closeCode=1006,this._closeFrameReceived=!1,this._closeFrameSent=!1,this._closeMessage=fr,this._closeTimer=null,this._errorEmitted=!1,this._extensions={},this._paused=!1,this._protocol="",this._readyState=n.CONNECTING,this._receiver=null,this._sender=null,this._socket=null,e!==null?(this._bufferedAmount=0,this._isServer=!1,this._redirects=0,s===void 0?s=[]:Array.isArray(s)||(typeof s=="object"&&s!==null?(o=s,s=[]):s=[s]),Ba(this,e,s,o)):(this._autoPong=o.autoPong,this._closeTimeout=o.closeTimeout,this._isServer=!0)}get binaryType(){return this._binaryType}set binaryType(e){Ra.includes(e)&&(this._binaryType=e,this._receiver&&(this._receiver._binaryType=e))}get bufferedAmount(){return this._socket?this._socket._writableState.length+this._sender._bufferedBytes:this._bufferedAmount}get extensions(){return Object.keys(this._extensions).join()}get isPaused(){return this._paused}get onclose(){return null}get onerror(){return null}get onopen(){return null}get onmessage(){return null}get protocol(){return this._protocol}get readyState(){return this._readyState}get url(){return this._url}setSocket(e,s,o){let c=new qf({allowSynchronousEvents:o.allowSynchronousEvents,binaryType:this.binaryType,extensions:this._extensions,isServer:this._isServer,maxPayload:o.maxPayload,skipUTF8Validation:o.skipUTF8Validation}),d=new Hf(e,this._extensions,o.generateMask);this._receiver=c,this._sender=d,this._socket=e,c[ce]=this,d[ce]=this,e[ce]=this,c.on("conclude",nl),c.on("drain",rl),c.on("error",il),c.on("message",sl),c.on("ping",ol),c.on("pong",al),d.onerror=cl,e.setTimeout&&e.setTimeout(0),e.setNoDelay&&e.setNoDelay(),s.length>0&&e.unshift(s),e.on("close",Ua),e.on("data",gr),e.on("end",qa),e.on("error",Ha),this._readyState=n.OPEN,this.emit("open")}emitClose(){if(!this._socket){this._readyState=n.CLOSED,this.emit("close",this._closeCode,this._closeMessage);return}this._extensions[xt.extensionName]&&this._extensions[xt.extensionName].cleanup(),this._receiver.removeAllListeners(),this._readyState=n.CLOSED,this.emit("close",this._closeCode,this._closeMessage)}close(e,s){if(this.readyState!==n.CLOSED){if(this.readyState===n.CONNECTING){Ee(this,this._req,"WebSocket was closed before the connection was established");return}if(this.readyState===n.CLOSING){this._closeFrameSent&&(this._closeFrameReceived||this._receiver._writableState.errorEmitted)&&this._socket.end();return}this._readyState=n.CLOSING,this._sender.close(e,s,!this._isServer,o=>{o||(this._closeFrameSent=!0,(this._closeFrameReceived||this._receiver._writableState.errorEmitted)&&this._socket.end())}),Fa(this)}}pause(){this.readyState===n.CONNECTING||this.readyState===n.CLOSED||(this._paused=!0,this._socket.pause())}ping(e,s,o){if(this.readyState===n.CONNECTING)throw new Error("WebSocket is not open: readyState 0 (CONNECTING)");if(typeof e=="function"?(o=e,e=s=void 0):typeof s=="function"&&(o=s,s=void 0),typeof e=="number"&&(e=e.toString()),this.readyState!==n.OPEN){Pi(this,e,o);return}s===void 0&&(s=!this._isServer),this._sender.ping(e||fr,s,o)}pong(e,s,o){if(this.readyState===n.CONNECTING)throw new Error("WebSocket is not open: readyState 0 (CONNECTING)");if(typeof e=="function"?(o=e,e=s=void 0):typeof s=="function"&&(o=s,s=void 0),typeof e=="number"&&(e=e.toString()),this.readyState!==n.OPEN){Pi(this,e,o);return}s===void 0&&(s=!this._isServer),this._sender.pong(e||fr,s,o)}resume(){this.readyState===n.CONNECTING||this.readyState===n.CLOSED||(this._paused=!1,this._receiver._writableState.needDrain||this._socket.resume())}send(e,s,o){if(this.readyState===n.CONNECTING)throw new Error("WebSocket is not open: readyState 0 (CONNECTING)");if(typeof s=="function"&&(o=s,s={}),typeof e=="number"&&(e=e.toString()),this.readyState!==n.OPEN){Pi(this,e,o);return}let c={binary:typeof e!="string",mask:!this._isServer,compress:!0,fin:!0,...s};this._extensions[xt.extensionName]||(c.compress=!1),this._sender.send(e||fr,c,o)}terminate(){if(this.readyState!==n.CLOSED){if(this.readyState===n.CONNECTING){Ee(this,this._req,"WebSocket was closed before the connection was established");return}this._socket&&(this._readyState=n.CLOSING,this._socket.destroy())}}};Object.defineProperty(J,"CONNECTING",{enumerable:!0,value:Ye.indexOf("CONNECTING")});Object.defineProperty(J.prototype,"CONNECTING",{enumerable:!0,value:Ye.indexOf("CONNECTING")});Object.defineProperty(J,"OPEN",{enumerable:!0,value:Ye.indexOf("OPEN")});Object.defineProperty(J.prototype,"OPEN",{enumerable:!0,value:Ye.indexOf("OPEN")});Object.defineProperty(J,"CLOSING",{enumerable:!0,value:Ye.indexOf("CLOSING")});Object.defineProperty(J.prototype,"CLOSING",{enumerable:!0,value:Ye.indexOf("CLOSING")});Object.defineProperty(J,"CLOSED",{enumerable:!0,value:Ye.indexOf("CLOSED")});Object.defineProperty(J.prototype,"CLOSED",{enumerable:!0,value:Ye.indexOf("CLOSED")});["binaryType","bufferedAmount","extensions","isPaused","protocol","readyState","url"].forEach(n=>{Object.defineProperty(J.prototype,n,{enumerable:!0})});["open","error","close","message"].forEach(n=>{Object.defineProperty(J.prototype,`on${n}`,{enumerable:!0,get(){for(let e of this.listeners(n))if(e[Ai])return e[Wf];return null},set(e){for(let s of this.listeners(n))if(s[Ai]){this.removeListener(n,s);break}typeof e=="function"&&this.addEventListener(n,e,{[Ai]:!0})}})});J.prototype.addEventListener=$f;J.prototype.removeEventListener=Vf;ja.exports=J;function Ba(n,e,s,o){let c={allowSynchronousEvents:!0,autoPong:!0,closeTimeout:Kf,protocolVersion:Ci[1],maxPayload:104857600,skipUTF8Validation:!1,perMessageDeflate:!0,followRedirects:!1,maxRedirects:10,...o,socketPath:void 0,hostname:void 0,protocol:void 0,timeout:void 0,method:"GET",host:void 0,path:void 0,port:void 0};if(n._autoPong=c.autoPong,n._closeTimeout=c.closeTimeout,!Ci.includes(c.protocolVersion))throw new RangeError(`Unsupported protocol version: ${c.protocolVersion} (supported versions: ${Ci.join(", ")})`);let d;if(e instanceof Ii)d=e;else try{d=new Ii(e)}catch{throw new SyntaxError(`Invalid URL: ${e}`)}d.protocol==="http:"?d.protocol="ws:":d.protocol==="https:"&&(d.protocol="wss:"),n._url=d.href;let u=d.protocol==="wss:",l=d.protocol==="ws+unix:",p;if(d.protocol!=="ws:"&&!u&&!l?p=`The URL's protocol must be one of "ws:", "wss:", "http:", "https:", or "ws+unix:"`:l&&!d.pathname?p="The URL's pathname is empty":d.hash&&(p="The URL contains a fragment identifier"),p){let P=new SyntaxError(p);if(n._redirects===0)throw P;lr(n,P);return}let m=u?443:80,_=Ff(16).toString("base64"),y=u?Mf.request:Bf.request,I=new Set,L;if(c.createConnection=c.createConnection||(u?tl:el),c.defaultPort=c.defaultPort||m,c.port=d.port||m,c.host=d.hostname.startsWith("[")?d.hostname.slice(1,-1):d.hostname,c.headers={...c.headers,"Sec-WebSocket-Version":c.protocolVersion,"Sec-WebSocket-Key":_,Connection:"Upgrade",Upgrade:"websocket"},c.path=d.pathname+d.search,c.timeout=c.handshakeTimeout,c.perMessageDeflate&&(L=new xt({...c.perMessageDeflate,isServer:!1,maxPayload:c.maxPayload}),c.headers["Sec-WebSocket-Extensions"]=Yf({[xt.extensionName]:L.offer()})),s.length){for(let P of s){if(typeof P!="string"||!Zf.test(P)||I.has(P))throw new SyntaxError("An invalid or duplicated subprotocol was specified");I.add(P)}c.headers["Sec-WebSocket-Protocol"]=s.join(",")}if(c.origin&&(c.protocolVersion<13?c.headers["Sec-WebSocket-Origin"]=c.origin:c.headers.Origin=c.origin),(d.username||d.password)&&(c.auth=`${d.username}:${d.password}`),l){let P=c.path.split(":");c.socketPath=P[0],c.path=P[1]}let T;if(c.followRedirects){if(n._redirects===0){n._originalIpc=l,n._originalSecure=u,n._originalHostOrSocketPath=l?c.socketPath:d.host;let P=o&&o.headers;if(o={...o,headers:{}},P)for(let[j,Q]of Object.entries(P))o.headers[j.toLowerCase()]=Q}else if(n.listenerCount("redirect")===0){let P=l?n._originalIpc?c.socketPath===n._originalHostOrSocketPath:!1:n._originalIpc?!1:d.host===n._originalHostOrSocketPath;(!P||n._originalSecure&&!u)&&(delete c.headers.authorization,delete c.headers.cookie,P||delete c.headers.host,c.auth=void 0)}c.auth&&!o.headers.authorization&&(o.headers.authorization="Basic "+Buffer.from(c.auth).toString("base64")),T=n._req=y(c),n._redirects&&n.emit("redirect",n.url,T)}else T=n._req=y(c);c.timeout&&T.on("timeout",()=>{Ee(n,T,"Opening handshake has timed out")}),T.on("error",P=>{T===null||T[Ma]||(T=n._req=null,lr(n,P))}),T.on("response",P=>{let j=P.headers.location,Q=P.statusCode;if(j&&c.followRedirects&&Q>=300&&Q<400){if(++n._redirects>c.maxRedirects){Ee(n,T,"Maximum redirects exceeded");return}T.abort();let K;try{K=new Ii(j,e)}catch{let se=new SyntaxError(`Invalid URL: ${j}`);lr(n,se);return}Ba(n,K,s,o)}else n.emit("unexpected-response",T,P)||Ee(n,T,`Unexpected server response: ${P.statusCode}`)}),T.on("upgrade",(P,j,Q)=>{if(n.emit("upgrade",P),n.readyState!==J.CONNECTING)return;T=n._req=null;let K=P.headers.upgrade;if(K===void 0||K.toLowerCase()!=="websocket"){Ee(n,j,"Invalid Upgrade header");return}let $=Uf("sha1").update(_+Gf).digest("base64");if(P.headers["sec-websocket-accept"]!==$){Ee(n,j,"Invalid Sec-WebSocket-Accept header");return}let se=P.headers["sec-websocket-protocol"],oe;if(se!==void 0?I.size?I.has(se)||(oe="Server sent an invalid subprotocol"):oe="Server sent a subprotocol but none was requested":I.size&&(oe="Server sent no subprotocol"),oe){Ee(n,j,oe);return}se&&(n._protocol=se);let Te=P.headers["sec-websocket-extensions"];if(Te!==void 0){if(!L){Ee(n,j,"Server sent a Sec-WebSocket-Extensions header but no extension was requested");return}let pe;try{pe=Xf(Te)}catch{Ee(n,j,"Invalid Sec-WebSocket-Extensions header");return}let xe=Object.keys(pe);if(xe.length!==1||xe[0]!==xt.extensionName){Ee(n,j,"Server indicated an extension that was not requested");return}try{L.accept(pe[xt.extensionName])}catch{Ee(n,j,"Invalid Sec-WebSocket-Extensions header");return}n._extensions[xt.extensionName]=L}n.setSocket(j,Q,{allowSynchronousEvents:c.allowSynchronousEvents,generateMask:c.generateMask,maxPayload:c.maxPayload,skipUTF8Validation:c.skipUTF8Validation})}),c.finishRequest?c.finishRequest(T,n):T.end()}function lr(n,e){n._readyState=J.CLOSING,n._errorEmitted=!0,n.emit("error",e),n.emitClose()}function el(n){return n.path=n.socketPath,Oa.connect(n)}function tl(n){return n.path=void 0,!n.servername&&n.servername!==""&&(n.servername=Oa.isIP(n.host)?"":n.host),zf.connect(n)}function Ee(n,e,s){n._readyState=J.CLOSING;let o=new Error(s);Error.captureStackTrace(o,Ee),e.setHeader?(e[Ma]=!0,e.abort(),e.socket&&!e.socket.destroyed&&e.socket.destroy(),process.nextTick(lr,n,o)):(e.destroy(o),e.once("error",n.emit.bind(n,"error")),e.once("close",n.emitClose.bind(n)))}function Pi(n,e,s){if(e){let o=jf(e)?e.size:Qf(e).length;n._socket?n._sender._bufferedBytes+=o:n._bufferedAmount+=o}if(s){let o=new Error(`WebSocket is not open: readyState ${n.readyState} (${Ye[n.readyState]})`);process.nextTick(s,o)}}function nl(n,e){let s=this[ce];s._closeFrameReceived=!0,s._closeMessage=e,s._closeCode=n,s._socket[ce]!==void 0&&(s._socket.removeListener("data",gr),process.nextTick(za,s._socket),n===1005?s.close():s.close(n,e))}function rl(){let n=this[ce];n.isPaused||n._socket.resume()}function il(n){let e=this[ce];e._socket[ce]!==void 0&&(e._socket.removeListener("data",gr),process.nextTick(za,e._socket),e.close(n[Jf])),e._errorEmitted||(e._errorEmitted=!0,e.emit("error",n))}function La(){this[ce].emitClose()}function sl(n,e){this[ce].emit("message",n,e)}function ol(n){let e=this[ce];e._autoPong&&e.pong(n,!this._isServer,Na),e.emit("ping",n)}function al(n){this[ce].emit("pong",n)}function za(n){n.resume()}function cl(n){let e=this[ce];e.readyState!==J.CLOSED&&(e.readyState===J.OPEN&&(e._readyState=J.CLOSING,Fa(e)),this._socket.end(),e._errorEmitted||(e._errorEmitted=!0,e.emit("error",n)))}function Fa(n){n._closeTimer=setTimeout(n._socket.destroy.bind(n._socket),n._closeTimeout)}function Ua(){let n=this[ce];if(this.removeListener("close",Ua),this.removeListener("data",gr),this.removeListener("end",qa),n._readyState=J.CLOSING,!this._readableState.endEmitted&&!n._closeFrameReceived&&!n._receiver._writableState.errorEmitted&&this._readableState.length!==0){let e=this.read(this._readableState.length);n._receiver.write(e)}n._receiver.end(),this[ce]=void 0,clearTimeout(n._closeTimer),n._receiver._writableState.finished||n._receiver._writableState.errorEmitted?n.emitClose():(n._receiver.on("error",La),n._receiver.on("finish",La))}function gr(n){this[ce]._receiver.write(n)||this.pause()}function qa(){let n=this[ce];n._readyState=J.CLOSING,n._receiver.end(),this.end()}function Ha(){let n=this[ce];this.removeListener("error",Ha),this.on("error",Na),n&&(n._readyState=J.CLOSING,this.destroy())}});var Ja=_e((g_,Wa)=>{"use strict";var l_=hr(),{Duplex:xl}=ee("stream");function Ka(n){n.emit("close")}function dl(){!this.destroyed&&this._writableState.finished&&this.destroy()}function Ga(n){this.removeListener("error",Ga),this.destroy(),this.listenerCount("error")===0&&this.emit("error",n)}function ul(n,e){let s=!0,o=new xl({...e,autoDestroy:!1,emitClose:!1,objectMode:!1,writableObjectMode:!1});return n.on("message",function(d,u){let l=!u&&o._readableState.objectMode?d.toString():d;o.push(l)||n.pause()}),n.once("error",function(d){o.destroyed||(s=!1,o.destroy(d))}),n.once("close",function(){o.destroyed||o.push(null)}),o._destroy=function(c,d){if(n.readyState===n.CLOSED){d(c),process.nextTick(Ka,o);return}let u=!1;n.once("error",function(p){u=!0,d(p)}),n.once("close",function(){u||d(c),process.nextTick(Ka,o)}),s&&n.terminate()},o._final=function(c){if(n.readyState===n.CONNECTING){n.once("open",function(){o._final(c)});return}n._socket!==null&&(n._socket._writableState.finished?(c(),o._readableState.endEmitted&&o.destroy()):(n._socket.once("finish",function(){c()}),n.close()))},o._read=function(){n.isPaused&&n.resume()},o._write=function(c,d,u){if(n.readyState===n.CONNECTING){n.once("open",function(){o._write(c,d,u)});return}n.send(c,u)},o.on("end",dl),o.on("error",Ga),o}Wa.exports=ul});var ki=_e((h_,$a)=>{"use strict";var{tokenChars:fl}=Bt();function ll(n){let e=new Set,s=-1,o=-1,c=0;for(c;c<n.length;c++){let u=n.charCodeAt(c);if(o===-1&&fl[u]===1)s===-1&&(s=c);else if(c!==0&&(u===32||u===9))o===-1&&s!==-1&&(o=c);else if(u===44){if(s===-1)throw new SyntaxError(`Unexpected character at index ${c}`);o===-1&&(o=c);let l=n.slice(s,o);if(e.has(l))throw new SyntaxError(`The "${l}" subprotocol is duplicated`);e.add(l),s=o=-1}else throw new SyntaxError(`Unexpected character at index ${c}`)}if(s===-1||o!==-1)throw new SyntaxError("Unexpected end of input");let d=n.slice(s,c);if(e.has(d))throw new SyntaxError(`The "${d}" subprotocol is duplicated`);return e.add(d),e}$a.exports={parse:ll}});var tc=_e((m_,ec)=>{"use strict";var gl=ee("events"),pr=ee("http"),{Duplex:p_}=ee("stream"),{createHash:hl}=ee("crypto"),Va=ur(),pt=Mt(),pl=ki(),ml=hr(),{CLOSE_TIMEOUT:wl,GUID:_l,kWebSocket:yl}=Je(),bl=/^[+/0-9A-Za-z]{22}==$/,Ya=0,Xa=1,Za=2,Ti=class extends gl{constructor(e,s){if(super(),e={allowSynchronousEvents:!0,autoPong:!0,maxPayload:100*1024*1024,skipUTF8Validation:!1,perMessageDeflate:!1,handleProtocols:null,clientTracking:!0,closeTimeout:wl,verifyClient:null,noServer:!1,backlog:null,server:null,host:null,path:null,port:null,WebSocket:ml,...e},e.port==null&&!e.server&&!e.noServer||e.port!=null&&(e.server||e.noServer)||e.server&&e.noServer)throw new TypeError('One and only one of the "port", "server", or "noServer" options must be specified');if(e.port!=null?(this._server=pr.createServer((o,c)=>{let d=pr.STATUS_CODES[426];c.writeHead(426,{"Content-Length":d.length,"Content-Type":"text/plain"}),c.end(d)}),this._server.listen(e.port,e.host,e.backlog,s)):e.server&&(this._server=e.server),this._server){let o=this.emit.bind(this,"connection");this._removeListeners=vl(this._server,{listening:this.emit.bind(this,"listening"),error:this.emit.bind(this,"error"),upgrade:(c,d,u)=>{this.handleUpgrade(c,d,u,o)}})}e.perMessageDeflate===!0&&(e.perMessageDeflate={}),e.clientTracking&&(this.clients=new Set,this._shouldEmitClose=!1),this.options=e,this._state=Ya}address(){if(this.options.noServer)throw new Error('The server is operating in "noServer" mode');return this._server?this._server.address():null}close(e){if(this._state===Za){e&&this.once("close",()=>{e(new Error("The server is not running"))}),process.nextTick(fn,this);return}if(e&&this.once("close",e),this._state!==Xa)if(this._state=Xa,this.options.noServer||this.options.server)this._server&&(this._removeListeners(),this._removeListeners=this._server=null),this.clients?this.clients.size?this._shouldEmitClose=!0:process.nextTick(fn,this):process.nextTick(fn,this);else{let s=this._server;this._removeListeners(),this._removeListeners=this._server=null,s.close(()=>{fn(this)})}}shouldHandle(e){if(this.options.path){let s=e.url.indexOf("?");if((s!==-1?e.url.slice(0,s):e.url)!==this.options.path)return!1}return!0}handleUpgrade(e,s,o,c){s.on("error",Qa);let d=e.headers["sec-websocket-key"],u=e.headers.upgrade,l=+e.headers["sec-websocket-version"];if(e.method!=="GET"){mt(this,e,s,405,"Invalid HTTP method");return}if(u===void 0||u.toLowerCase()!=="websocket"){mt(this,e,s,400,"Invalid Upgrade header");return}if(d===void 0||!bl.test(d)){mt(this,e,s,400,"Missing or invalid Sec-WebSocket-Key header");return}if(l!==13&&l!==8){mt(this,e,s,400,"Missing or invalid Sec-WebSocket-Version header",{"Sec-WebSocket-Version":"13, 8"});return}if(!this.shouldHandle(e)){ln(s,400);return}let p=e.headers["sec-websocket-protocol"],m=new Set;if(p!==void 0)try{m=pl.parse(p)}catch{mt(this,e,s,400,"Invalid Sec-WebSocket-Protocol header");return}let _=e.headers["sec-websocket-extensions"],y={};if(this.options.perMessageDeflate&&_!==void 0){let I=new pt({...this.options.perMessageDeflate,isServer:!0,maxPayload:this.options.maxPayload});try{let L=Va.parse(_);L[pt.extensionName]&&(I.accept(L[pt.extensionName]),y[pt.extensionName]=I)}catch{mt(this,e,s,400,"Invalid or unacceptable Sec-WebSocket-Extensions header");return}}if(this.options.verifyClient){let I={origin:e.headers[`${l===8?"sec-websocket-origin":"origin"}`],secure:!!(e.socket.authorized||e.socket.encrypted),req:e};if(this.options.verifyClient.length===2){this.options.verifyClient(I,(L,T,P,j)=>{if(!L)return ln(s,T||401,P,j);this.completeUpgrade(y,d,m,e,s,o,c)});return}if(!this.options.verifyClient(I))return ln(s,401)}this.completeUpgrade(y,d,m,e,s,o,c)}completeUpgrade(e,s,o,c,d,u,l){if(!d.readable||!d.writable)return d.destroy();if(d[yl])throw new Error("server.handleUpgrade() was called more than once with the same socket, possibly due to a misconfiguration");if(this._state>Ya)return ln(d,503);let m=["HTTP/1.1 101 Switching Protocols","Upgrade: websocket","Connection: Upgrade",`Sec-WebSocket-Accept: ${hl("sha1").update(s+_l).digest("base64")}`],_=new this.options.WebSocket(null,void 0,this.options);if(o.size){let y=this.options.handleProtocols?this.options.handleProtocols(o,c):o.values().next().value;y&&(m.push(`Sec-WebSocket-Protocol: ${y}`),_._protocol=y)}if(e[pt.extensionName]){let y=e[pt.extensionName].params,I=Va.format({[pt.extensionName]:[y]});m.push(`Sec-WebSocket-Extensions: ${I}`),_._extensions=e}this.emit("headers",m,c),d.write(m.concat(`\r
8
+ var R0=Object.create;var $r=Object.defineProperty;var O0=Object.getOwnPropertyDescriptor;var N0=Object.getOwnPropertyNames;var L0=Object.getPrototypeOf,M0=Object.prototype.hasOwnProperty;var ee=(n=>typeof require<"u"?require:typeof Proxy<"u"?new Proxy(n,{get:(e,s)=>(typeof require<"u"?require:e)[s]}):n)(function(n){if(typeof require<"u")return require.apply(this,arguments);throw Error('Dynamic require of "'+n+'" is not supported')});var 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)$r(n,s,{get:e[s],enumerable:!0})},B0=(n,e,s,o)=>{if(e&&typeof e=="object"||typeof e=="function")for(let a of N0(e))!M0.call(n,a)&&a!==s&&$r(n,a,{get:()=>e[a],enumerable:!(o=O0(e,a))||o.enumerable});return n};var je=(n,e,s)=>(s=n!=null?R0(L0(n)):{},B0(e||!n||!n.__esModule?$r(s,"default",{value:n,enumerable:!0}):s,n));function _s(n){return Sn[ms]<=Sn[n]}function En(n){ws={...n}}function vn(n,e,s,o){if(Sn[n]<Sn[ms])return;let a=JSON.stringify({ts:new Date().toISOString(),level:n,module:e,msg:s,...ws,...o});n==="error"||n==="warn"?F0.write(`${a}
9
+ `):z0.write(`${a}
10
+ `)}function D(n){return{debug:(e,s)=>vn("debug",n,e,s),info:(e,s)=>vn("info",n,e,s),warn:(e,s)=>vn("warn",n,e,s),error:(e,s)=>vn("error",n,e,s),child:e=>D(`${n}.${e}`)}}var Sn,ms,z0,F0,ws,U=Ce(()=>{"use strict";Sn={debug:10,info:20,warn:30,error:40},ms=(()=>{let n=process.env.COZE_BRIDGE_LOG_LEVEL;return n==="debug"||n==="info"||n==="warn"||n==="error"?n:"info"})(),z0=process.stdout,F0=process.stderr,ws={}});import{chmod as Z0,mkdir as ex,readFile as tx,rename as Es,writeFile as As}from"node:fs/promises";import{dirname as nx}from"node:path";async function It(n){try{let e=await tx(n,"utf8");return JSON.parse(e)}catch(e){if(e.code==="ENOENT")return null;throw e}}async function kn(n,e,s){await ex(nx(n),{recursive:!0});let o=`${JSON.stringify(e,null,2)}
11
+ `,a=`${n}.tmp-${process.pid}-${Math.random().toString(36).slice(2,10)}`;try{s?.mode!==void 0?await As(a,o,{encoding:"utf8",mode:s.mode}):await As(a,o,"utf8"),await Es(a,n),s?.mode!==void 0&&await Z0(n,s.mode)}catch(x){await Es(a,a).catch(()=>{});let{rm:u}=await import("node:fs/promises");throw await u(a,{force:!0}).catch(()=>{}),x}}var Tn=Ce(()=>{"use strict"});import{promises as Cs}from"node:fs";import{homedir as rx}from"node:os";import{sep as ix,join as le,resolve as Is}from"node:path";function q(n){let e=n??rx(),s=le(e,".coze"),o=le(s,"bridge"),a=le(o,"lib");return{cozeRoot:s,bridgeRoot:o,libDir:a,libEntry:le(a,"index.js"),binDir:le(o,"bin"),pidFile:le(o,"bridge.pid"),portFile:le(o,"bridge.port"),tokenFile:le(o,"bridge.token"),patTokenFile:le(o,"pat-token"),logFile:le(o,"bridge.log"),installLock:le(o,"install.lock"),configFile:le(o,"config.json"),agentsRoot:le(s,"agents")}}function We(n,e=q()){let s=le(e.agentsRoot,n);return{root:s,config:le(s,"config.json"),workspace:le(s,"workspace"),logs:le(s,"logs")}}async function Ps(n,e){let s=await Cs.realpath(Is(n)).catch(()=>null);if(!s)return!1;let o=await Cs.realpath(Is(e)).catch(()=>null);if(!o)return!1;let a=process.platform==="win32"?s.toLowerCase():s,x=process.platform==="win32"?o.toLowerCase():o;return a===x||a.startsWith(x+ix)}var ie=Ce(()=>{"use strict"});var On={};Jr(On,{AGENT_CONFIG_FILE_MODE:()=>Dn,enforceAgentConfigMode:()=>ax,loadAgentConfig:()=>we,persistAgentSessions:()=>Yr,persistAgentSkills:()=>Rn,saveAgentConfig:()=>Ie});import{chmod as sx,stat as ox}from"node:fs/promises";function we(n,e){return It(We(n,e).config)}function Ie(n,e){return kn(We(n.agentId,e).config,n,{mode:Dn})}async function ax(n,e){if(process.platform==="win32")return;let s=We(n,e).config;try{let o=await ox(s);if(!o.isFile())return;let a=o.mode&511;a!==Dn&&(await sx(s,Dn),ks.warn("agent config mode auto-corrected to 0600",{path:s,from:a.toString(8)}))}catch(o){if(o.code==="ENOENT")return;ks.warn("enforceAgentConfigMode: chmod failed (ignored)",{path:s,err:String(o)})}}async function Yr(n,e,s){let o=await we(n,s);o&&(o.sessions=Object.fromEntries(e),await Ie(o,s))}async function Rn(n,e,s){let o=await we(n,s);o&&(o.skills=e,await Ie(o,s))}var ks,Dn,rt=Ce(()=>{"use strict";Tn();U();ie();ks=D("agent-config"),Dn=384});function ko(n){let e=n?.sessionIdleTimeoutMs;return typeof e!="number"||!Number.isFinite(e)||e<=0?Wd:e}function ct(n){return It(n??q().configFile)}function Fe(n,e){return kn(e??q().configFile,n)}var Wd,Mt=Ce(()=>{"use strict";Tn();ie();Wd=10*6e4});var na=ye(se=>{"use strict";var C=B;(function(n,e){let s=B,o=n();for(;;)try{if(parseInt(s(590))/1+parseInt(s(1234))/2+-parseInt(s(916))/3+-parseInt(s(322))/4+parseInt(s(1264))/5+-parseInt(s(624))/6+-parseInt(s(1294))/7*(parseInt(s(1202))/8)===e)break;o.push(o.shift())}catch{o.push(o.shift())}})(or,745815);var ju=Object[C(437)+"operty"],Wu=Object["getOwnPr"+C(748)+C(484)],Xo=(n,e)=>function(){return n&&(e=(0,n[Wu(n)[0]])(n=0)),e},$u=(n,e)=>{for(var s in e)ju(n,s,{get:e[s],enumerable:!0})};function Ju(){return Wo||(Wo=[IDBDatabase,IDBObjectStore,IDBIndex,IDBCursor,IDBTransaction])}function Vu(){let n=C;return $o||($o=[IDBCursor[n(648)+"e"][n(800)],IDBCursor[n(648)+"e"][n(1540)],IDBCursor.prototype[n(1540)+n(1774)+"ey"]])}function Yu(n){let e=C,s={XzeFu:function(a,x){return a!==x},syOMZ:e(1125),IdyOd:function(a,x){return a(x)},bEzjM:function(a){return a()},fZQfJ:function(a,x){return a===x},chJqf:e(352),JXZYL:e(1154),FTXck:e(1013),FTVfz:function(a,x,u){return a(x,u)},jGjZE:function(a,x){return a+x},ZIFVp:e(1316),mFgfW:function(a){return a()},AMQrY:function(a,x){return a instanceof x}},o=new Promise((a,x)=>{let u=e,f={RxANc:function(w,E){return s[B(336)](w,E)},TbnDU:s.chJqf,qosAy:s[u(820)],FXCtf:s[u(907)],ZWLQM:function(w,E,T){return s[u(1222)](w,E,T)},dDVGX:function(w,E){return s[u(1383)](w,E)},qmUEe:function(w,E){return s.XzeFu(w,E)},YCCVM:s.ZIFVp,veDAV:function(w,E){return w(E)},pApun:function(w){return s.mFgfW(w)}},g=()=>{let w=u;f[w(469)](w(352),f.TbnDU)?(n[w(548)+"entListener"](f.qosAy,p),n[w(548)+w(408)+"ner"](f[w(1437)],_)):this.on(_0x4c0a49,_0x1e9e32)},p=()=>{let w=u;if(s[w(1654)](s[w(872)],s[w(872)])){let E=this[w(981)+w(908)]?.getCurrentEndpoint();this[w(1121)](w(1079)+E+w(959)),this[w(736)+w(629)](1001,w(436)+w(451)+w(1618)+"g",!0)}else s.IdyOd(a,qe(n.result)),s.bEzjM(g)},_=()=>{let w=u,E={USuSe:function(T,k,P){return f[B(558)](T,k,P)},Zcvmt:function(T,k){return f[B(1055)](T,k)}};if(f[w(723)](f.YCCVM,f[w(1157)])){let T=E[w(1351)](_0x1ec7e6,_0x45745a,_0x5b3a57);return _0xddf52b[w(1140)].subarray(T,E[w(749)](T,_0x3b8163))}else f[w(1456)](x,n[w(1013)]),f[w(1591)](g)};n[u(1572)+u(1261)](s[u(820)],p),n["addEvent"+u(1261)](s[u(907)],_)});return o[e(1123)](a=>{let x=e;s[x(1519)](a,IDBCursor)&&li[x(406)](a,n)})[e(549)](()=>{}),ir[e(406)](o,n),o}function Xu(n){let e=C,s={IsiAE:e(1439),fsnoM:"error",xMXpQ:e(1018),wOoJx:function(a,x){return a!==x},psItf:"msYVE",OAWtB:function(a){return a()},SObje:function(a,x){return a(x)},SDqUQ:"AbortError"};if(rr.has(n))return;let o=new Promise((a,x)=>{let u=e,f={lyUYI:s[u(1529)],xEVGn:s[u(1652)],FWrhl:s[u(1459)],iBefP:function(w,E){return s[u(1250)](w,E)},ioYGn:s[u(1550)],skhKU:function(w){return s[u(1782)](w)},aUZpg:function(w,E){return s.SObje(w,E)},vEoOq:s[u(1167)]},g=()=>{let w=u;n["removeEv"+w(408)+w(1160)](f[w(1067)],p),n["removeEv"+w(408)+w(1160)](f[w(435)],_),n[w(548)+w(408)+w(1160)](f.FWrhl,_)},p=()=>{let w=u;if(f[w(965)](w(1718),f[w(1146)]))return this[w(758)]?this[w(758)].readyState:this._options[w(1022)+w(1371)]?this[w(1139)+"NG"]:this.CLOSED;f[w(1696)](a),f[w(1696)](g)},_=()=>{let w=u;f[w(1165)](x,n[w(1013)]||new DOMException(f[w(739)],f[w(739)])),f[w(1696)](g)};n[u(1572)+u(1261)](s[u(1529)],p),n[u(1572)+u(1261)](s[u(1652)],_),n[u(1572)+u(1261)](s.xMXpQ,_)});rr.set(n,o)}function Qu(n){sr=n(sr)}function Zu(n){let e=C,s={DmVUv:function(a,x){return a(x)},ZsjBN:function(a,x){return a|x},uKCRO:function(a,x){return a<<x},Rsidd:function(a,x){return a&x},EIeSr:function(a,x){return a<x},uUOgT:function(a,x){return a(x)},YtnId:"NbWzF",mSGMY:e(384),dHqeV:function(a,x){return a(x)},LHhGj:function(a,x){return a===x},eBOBx:function(a,x){return a in x},qkZaY:e(550)+e(305),ELjUd:function(a){return a()},nAMRh:function(a,x){return a!==x},ksOeN:e(595),mgxJu:"kamud"};if(s[e(1373)](n,IDBDatabase.prototype["transact"+e(1126)])&&!s[e(523)](s[e(1184)],IDBTransaction.prototype))return function(a,...x){let u=e,f=n[u(608)](dn(this),a,...x);return fi[u(406)](f,a[u(1746)]?a[u(1746)]():[a]),s[u(635)](qe,f)};if(s.ELjUd(Vu)[e(1465)](n)){if(s[e(1528)](s[e(375)],s.mgxJu))return function(...a){let x=e;if(s[x(325)]!==s[x(713)])return n[x(400)](s[x(476)](dn,this),a),s[x(635)](qe,li.get(this));_0x39e38f=s.ZsjBN(s[x(962)](s[x(306)](31,_0x3f9bd8),6),s.Rsidd(63,_0x422e3d)),s[x(459)](_0x512bb6,128)?_0x3181dc+=_0x312952:(_0x4d8e9f+=s[x(1551)](_0x23077f,_0x530e3c),_0x4c0144++)};for(var o in _0x4a87bd)_0x491528(_0x4589eb,o,{get:_0x67c8e3[o],enumerable:!0})}return function(...a){return s[e(635)](qe,n.apply(dn(this),a))}}function ef(n){let e=C,s={dGWNj:function(o,a){return o===a},LGoZD:"function",kggCF:function(o,a){return o(a)},xwPDU:function(o,a){return o instanceof a},bqDnf:function(o,a){return o(a)},IZNJv:function(o,a,x){return o(a,x)},yRjQZ:function(o){return o()}};return s[e(409)](typeof n,s[e(1056)])?s[e(1077)](Zu,n):(s.xwPDU(n,IDBTransaction)&&s.bqDnf(Xu,n),s[e(1106)](Qo,n,s.yRjQZ(Ju))?new Proxy(n,sr):n)}function qe(n){let e=C,s={srYej:function(a,x){return a+x},UDaeY:function(a,x,u){return a(x,u)},NJLNt:function(a,x){return a>>>x},xEzvY:function(a,x){return a<<x},YiPYS:function(a,x){return a(x)},SCBfN:function(a,x){return a!==x},gZEhS:function(a,x){return a!==x},OsAli:e(1188)};if(n instanceof IDBRequest)return s[e(1115)](Yu,n);if(tr.has(n))return tr[e(571)](n);let o=s[e(1115)](ef,n);if(s[e(1665)](o,n))if(s[e(1534)](s[e(1474)],e(1188))){let a=0,x=_0x599bc6,u=s.srYej(_0x48be7b,4);for(;x<u;){let{value:f,offset:g}=s[e(1736)](_0x1935ab,_0x4659d1,x);x=g,a=s.NJLNt(s[e(1505)](a,8),0),a+=f}return{value:a,offset:u}}else tr[e(406)](n,o),ir[e(406)](o,n);return o}var Qo,Wo,$o,li,rr,fi,tr,ir,sr,dn,Jo=Xo({"node_modules/idb/build/wrap-idb-value.js"(){let n=C,e={lkUDb:"done",kEZWR:function(s,o){return s===o},HwETP:function(s,o){return s===o},IvVjA:n(284),VlrbP:function(s,o){return s(o)},OCPQP:n(951),JQuJk:function(s,o){return s!==o},geeWJ:n(1592),CDILF:function(s,o){return s===o},Jwecb:function(s,o){return s in o}};Qo=(s,o)=>o[n(516)](a=>s instanceof a),li=new WeakMap,rr=new WeakMap,fi=new WeakMap,tr=new WeakMap,ir=new WeakMap,sr={get(s,o,a){let x=n;if(s instanceof IDBTransaction){if(o===e.lkUDb)return rr[x(571)](s);if(e[x(1168)](o,"objectStoreNames"))return s[x(550)+x(305)]||fi[x(571)](s);if(e[x(1614)](o,e[x(1025)]))return a[x(550)+x(305)][1]?void 0:a[x(550)+x(467)](a[x(550)+x(305)][0])}return e[x(892)](qe,s[o])},set(s,o,a){return s[o]=a,!0},has(s,o){let a=n,x={xBKTw:e[a(380)],qmIuC:a(427)};if(e[a(794)](a(1592),e.geeWJ))this[a(449)+"er"]&&_0x178e0c[a(548)+a(408)+a(1160)]("online",this[a(385)+a(647)]),this[a(449)+"er"]&&_0x518aad["removeEv"+a(408)+a(1160)](a(1379),this[a(385)+a(937)]),this[a(449)+"er"]&&_0x46a661[a(548)+a(408)+a(1160)](x[a(361)],this[a(445)+a(699)]),this[a(449)+"er"]&&_0x33496d[a(548)+a(408)+a(1160)](x[a(1571)],this[a(445)+"ageShow"]);else return s instanceof IDBTransaction&&(e[a(1614)](o,e[a(622)])||e[a(1392)](o,"store"))?!0:e[a(1780)](o,s)}},dn=s=>ir.get(s)}}),Zo={};$u(Zo,{deleteDB:()=>nf,openDB:()=>tf,unwrap:()=>dn,wrap:()=>qe});function tf(n,e,{blocked:s,upgrade:o,blocking:a,terminated:x}={}){let u=C,f={HmROA:function(_,w){return _(w)},DxDHe:u(1131),pmBDk:u(479)+u(1418),wCwzT:"upgraden"+u(825),TLvIj:"blocked"},g=indexedDB[u(1020)](n,e),p=qe(g);return o&&g[u(1572)+u(1261)](f[u(607)],_=>{let w=u;o(qe(g.result),_[w(1520)+"on"],_[w(443)+"on"],f[w(1603)](qe,g["transact"+w(1126)]))}),s&&g[u(1572)+"Listener"](f[u(296)],()=>s()),p.then(_=>{let w=u;x&&_[w(1572)+w(1261)](f[w(1707)],()=>x()),a&&_[w(1572)+w(1261)](f.pmBDk,()=>a())}).catch(()=>{}),p}function nf(n,{blocked:e}={}){let s=C,o={preVy:s(824),QKYcu:function(x,u){return x(u)}},a=indexedDB["deleteDa"+s(1248)](n);return e&&a[s(1572)+s(1261)](o[s(1559)],()=>e()),o[s(448)](qe,a).then(()=>{})}function Vo(n,e){let s=C,o={Ohytb:s(1544),iPHSy:s(1134)+"e",FzwqX:s(1368),LdLkh:function(g,p){return g instanceof p},koXjP:function(g,p){return g in p},hhiMV:s(1231),hcPKf:function(g,p){return g!==p},FGiZI:function(g,p){return g in p}};if(!(o[s(1191)](n,IDBDatabase)&&!o.koXjP(e,n)&&typeof e===o[s(1187)]))return;if(nr[s(571)](e))return nr[s(571)](e);let a=e[s(763)](/FromIndex$/,""),x=o[s(730)](e,a),u=ta[s(1465)](a);if(!o.FGiZI(a,(x?IDBIndex:IDBObjectStore)[s(648)+"e"])||!(u||ea[s(1465)](a)))return;let f=async function(g,...p){let _=s;if(o.Ohytb!==o[_(986)]){let w=_0x220990(_0x1fd831,_0x59a754[_(680)]);_0x2dbfe6[_(1140)].set(_0x93eee2,w)}else{let w=this[_(1498)+"ion"](g,u?o.iPHSy:o.FzwqX),E=w[_(284)];return x&&(E=E[_(779)](p[_(504)]())),(await Promise.all([E[a](...p),u&&w[_(1569)]]))[0]}};return nr[s(406)](e,f),f}function B(n,e){n=n-277;let s=or(),o=s[n];if(B.MDjXKW===void 0){var a=function(g){let p="abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789+/=",_="",w="";for(let E=0,T,k,P=0;k=g.charAt(P++);~k&&(T=E%4?T*64+k:k,E++%4)?_+=String.fromCharCode(255&T>>(-2*E&6)):0)k=p.indexOf(k);for(let E=0,T=_.length;E<T;E++)w+="%"+("00"+_.charCodeAt(E).toString(16)).slice(-2);return decodeURIComponent(w)};B.MqoSiq=a,B.yjztMH={},B.MDjXKW=!0}let x=s[0],u=n+x,f=B.yjztMH[u];return f?o=f:(o=B.MqoSiq(o),B.yjztMH[u]=o),o}var ea,ta,nr,rf=Xo({"node_modules/idb/build/index.js"(){let n=C,e={AQAFa:n(571),KZsTt:n(1333),RtlhA:n(574)+"ys",pevfz:"count",dyMHI:n(1367),RWMGb:n(1208),fzpsW:n(1705),HbaZt:n(1666),tuxCq:function(s,o){return s(o)}};Jo(),Jo(),ea=[e[n(1499)],"getKey",e[n(407)],e[n(337)],e[n(1312)]],ta=[e.dyMHI,e[n(997)],e[n(863)],e[n(307)]],nr=new Map,e[n(1753)](Qu,s=>({...s,get:(o,a,x)=>Vo(o,a)||s[n(571)](o,a,x),has:(o,a)=>!!Vo(o,a)||s[n(324)](o,a)}))}}),sf={idb:function(n){let e=C;n[e(386)]=Promise.resolve().then(()=>(rf(),Zo))[e(1123)](function(s){return s})}},Yo={};function Ue(n){let e=C,s={BAeXU:e(980)+"0",ZGWaO:function(f,g){return f!==g}},o=s[e(1085)][e(961)]("|"),a=0;for(;;){switch(o[a++]){case"0":return x[e(386)];case"1":sf[n](x,x[e(386)],Ue);continue;case"2":if(s[e(1124)](void 0,u))return u[e(386)];continue;case"3":var x=Yo[n]={exports:{}};continue;case"4":var u=Yo[n];continue}break}}Ue.d=(n,e)=>{let s=B;for(var o in e)Ue.o(e,o)&&!Ue.o(n,o)&&Object[s(437)+s(434)](n,o,{enumerable:!0,get:e[o]})},(()=>{let n=C;Ue.o=(e,s)=>Object[n(648)+"e"][n(509)+n(434)][n(608)](e,s)})(),(()=>{let n=C,e={DWWum:function(s,o){return s|o},IgdRI:function(s,o){return s>>o},WWPGE:function(s,o){return s&o},wizsw:function(s,o){return s===o},cheRN:n(966),mUJkA:function(s,o){return s!=o},yhmBY:n(498)+"d",GWhHA:n(766),sIrDT:n(1440)+"le"};Ue.r=s=>{let o=n,a={YKcrq:function(x,u){return e.DWWum(x,u)},SjzrF:function(x,u){return e[B(1004)](x,u)},ALnOo:function(x,u){return e[B(1108)](x,u)},SLERe:function(x,u){return x&u}};e.wizsw(e[o(1393)],e[o(1393)])?(e.mUJkA(e[o(319)],typeof Symbol)&&Symbol["toString"+o(551)]&&Object["definePr"+o(434)](s,Symbol[o(735)+o(551)],{value:e[o(1370)]}),Object[o(437)+o(434)](s,e[o(895)],{value:!0})):(_0x2030a3[_0x5d3315++]=a[o(1700)](a[o(877)](_0x39472a,12),224),_0x15bfaf[_0x4fe912++]=a[o(1700)](a[o(1136)](_0x5f342d>>6,63),128),_0xbb7f93[_0x443155++]=a.YKcrq(a[o(1690)](63,_0x6f0713),128))}})();var te={};(()=>{let n=C,e={egHuX:function(i,t){return i+t},kpNOU:function(i,t){return i*t},IHmZt:function(i,t){return i*t},uxmKs:function(i,t){return i+t},mHpqJ:function(i,t){return i(t)},dxuzy:function(i,t,r){return i(t,r)},iSbLQ:function(i,t){return i(t)},irmyq:function(i,t){return i+t},RJOMC:n(1344),nGlhH:n(1585)+n(1585)+n(1585)+n(1585),tVNTc:function(i,t){return i+t},zAYjf:"Skip pas"+n(1057),QZLvk:function(i,t,r){return i(t,r)},LJAho:function(i,t){return i>t},wOpRS:function(i,t){return i>t},IOvbw:function(i,t){return i<t},dKlpA:function(i,t){return i!==t},otUak:n(998),toigU:function(i,t){return i!==t},fzzpf:n(1627),lgaeI:n(530),Aalny:function(i,t){return i-t},wEoqE:function(i,t){return i<t},Eeisv:function(i,t){return i-t},svbhX:function(i,t){return i<t},sijhM:function(i,t){return i-t},pfDSr:function(i,t){return i!==t},LJwlC:function(i,t,r){return i(t,r)},WlivM:function(i,t){return i(t)},vVLAR:function(i,t,r){return i(t,r)},oIaVb:function(i,t){return i(t)},nIeoS:function(i,t){return i&t},yiqte:n(603)+"required"+n(1304)+n(1791),VOsWK:n(603)+n(1687)+" field: "+n(414),eGYsO:function(i){return i()},XMbSZ:function(i,t,r,c){return i(t,r,c)},HQtNu:function(i,t){return i&&t},gtZDw:n(1773),pDiIj:function(i,t){return i||t},ekGKH:n(1295),gyjLu:function(i,t){return i!==t},JFrXa:function(i,t,r){return i(t,r)},nzJkx:function(i,t){return i!==t},YhfTj:function(i,t,r){return i(t,r)},IXkfY:function(i,t,r){return i(t,r)},QFHRN:function(i,t,r){return i(t,r)},UQdsZ:function(i,t){return i(t)},eabRR:function(i,t,r){return i(t,r)},vmRwu:function(i,t,r){return i(t,r)},muUha:function(i,t){return i!==t},dJpdO:function(i,t,r){return i(t,r)},zbHPZ:function(i,t,r){return i(t,r)},lnpmv:n(1052),sStcX:n(879),QbMhN:function(i,t){return i!==t},EgIcM:function(i,t,r){return i(t,r)},byBHD:function(i,t,r){return i(t,r)},rDKkB:function(i,t){return i(t)},KSeCT:function(i,t){return i>>>t},kIeUh:function(i,t,r){return i(t,r)},opuUD:function(i,t,r){return i(t,r)},bnINE:function(i,t,r){return i(t,r)},nkIYl:function(i,t){return i(t)},jpiQI:function(i,t){return i(t)},SyXfk:function(i,t,r){return i(t,r)},GtDCt:function(i,t,r){return i(t,r)},CLHdP:function(i,t){return i(t)},NZUyN:function(i,t){return i===t},yvaom:n(603)+n(1687)+n(1304)+n(865),AbfGo:n(603)+"required"+n(1304)+n(1516),sIXhF:n(603)+n(1687)+" field: "+n(1158),BKKEY:n(603)+n(1687)+" field: "+n(1412),iwCfB:function(i,t){return i(t)},oMMoZ:function(i,t,r){return i(t,r)},NVADU:function(i,t,r){return i(t,r)},qoRNq:function(i,t){return i+t},VpeIX:n(1097)+n(1211)+n(424),pjOGO:function(i,t){return i>>t},lJFeT:function(i,t){return i>=t},jzYPm:n(1580),tPYms:"DoPUk",yUeEE:"mpNXs",XtagX:function(i,t){return i===t},LSgDN:function(i,t){return i===t},FUDVZ:n(1650),hgYCh:function(i,t){return i>=t},bkOPP:function(i,t){return i+t},pbGDZ:function(i,t){return i>t},qVvJK:function(i,t){return i*t},LAjsg:function(i,t){return i>t},gNMcm:n(1161)+n(1057),DvmSr:function(i,t){return i(t)},IBksC:n(1154),jelHw:"ping_onc"+n(1272)+"t",wIvgB:"TURXy",IPGMH:function(i,t,r){return i(t,r)},DwEoY:"cVjyf",NuMHA:n(520),zanTJ:function(i,t){return i+t},DQkTM:function(i,t){return i(t)},kUHkK:function(i,t){return i===t},VmlnP:function(i,t){return i&t},IkQNv:function(i,t){return i>=t},sRhvt:function(i,t){return i+t},jmvxV:function(i,t){return i!==t},tvKcG:function(i,t){return i&t},kXjkt:function(i,t){return i|t},LxoeE:function(i,t){return i&t},cFUIy:function(i,t){return i(t)},EoHkA:function(i,t){return i>=t},aUVxN:function(i,t){return i+t},DFrEJ:function(i,t){return i+t},XdTkf:function(i,t){return i|t},BCuwh:function(i,t){return i<<t},FJpKX:function(i,t){return i<<t},LCYSG:function(i,t){return i&t},sWLOB:function(i,t){return i<<t},igtyB:function(i,t){return i>=t},rlkju:function(i,t){return i<=t},pRNwZ:function(i,t){return i(t)},Wtwbr:function(i,t){return i==t},gIOAf:function(i,t){return i&t},ulvBq:function(i,t){return i+t},xCaZy:"vHVeG",MmkgW:function(i,t){return i+t},JTxwK:function(i,t){return i|t},RsyKg:function(i,t){return i|t},hDyFt:function(i,t){return i|t},ryAgK:function(i,t){return i<<t},fNqxd:function(i,t){return i>t},SnKQa:function(i,t){return i>>t},Mwjqd:function(i,t){return i+t},Hnrzg:function(i,t){return i&t},EQMhw:function(i,t){return i<<t},LQQav:function(i,t){return i<t},SMxAa:function(i,t){return i<t},KYWqQ:function(i,t,r){return i(t,r)},dRsGz:function(i,t){return i<t},hpNvt:function(i,t){return i<=t},zIAga:function(i,t){return i-t},DwczN:function(i,t){return i+t},vNxxF:function(i,t){return i<t},rUIUW:function(i,t){return i&t},FGLtV:function(i,t){return i|t},htyrz:function(i,t){return i&t},EUaYu:function(i,t){return i|t},MfDrL:function(i,t){return i&t},HBXLq:function(i,t){return i>>t},CRsLN:function(i,t){return i|t},kcuce:function(i,t){return i&t},CqyCV:function(i,t){return i|t},MDObu:function(i,t){return i&t},iuhSk:function(i,t){return i>>t},ePCUw:function(i,t){return i|t},hzqjS:function(i,t){return i&t},htIOp:function(i,t,r){return i(t,r)},MNfbi:n(1720)+n(746),KMIKq:"CggOX",xyptn:function(i,t){return i&t},drTWS:function(i,t){return i>=t},LPCUM:function(i,t,r){return i(t,r)},JBHLn:function(i,t){return i&t},smWAv:function(i,t){return i+t},HiGxP:function(i,t){return i&t},KGEFq:function(i,t){return i&t},BgWcO:function(i,t){return i(t)},KceqD:n(427),vBnDR:function(i,t,r){return i(t,r)},McQpH:n(1013),MVvoa:function(i,t){return i(t)},kcuNX:function(i,t){return i<<t},qZtpt:function(i,t){return i&t},iANYr:function(i,t){return i<<t},woURD:function(i,t){return i&t},UgbBA:function(i,t){return i!==t},qnCZG:function(i,t){return i(t)},vkrFQ:function(i,t){return i!==t},GSQuw:n(883),oZVPZ:function(i,t){return i(t)},UtWiz:function(i,t){return i(t)},dnduI:function(i,t){return i<<t},jHdsJ:function(i,t){return i&t},wZFqi:n(522),oHHvz:function(i,t){return i&t},zgJta:n(1193),nyarH:function(i,t){return i|t},PMjtc:function(i,t){return i<<t},moZps:function(i,t){return i>>>t},InhIN:function(i,t){return i|t},rPUck:function(i,t){return i>>>t},YnAwQ:function(i,t){return i>>>t},rLlep:function(i,t){return i===t},YGlVl:function(i,t){return i<t},wzJUE:function(i,t){return i<t},lvIVK:function(i,t,r){return i(t,r)},kFAjC:function(i,t){return i&t},yVvKR:function(i,t){return i+t},lpywf:function(i,t){return i&t},RcvOd:function(i,t){return i|t},MmEAt:function(i,t){return i|t},CpQwH:function(i,t){return i>>>t},UUbXb:function(i,t){return i+t},CgUIX:function(i,t){return i|t},bEkcv:function(i,t){return i>>>t},fdxax:function(i,t){return i&t},ljPhv:function(i,t){return i!==t},GMVDG:function(i,t){return i|t},btQsp:function(i,t){return i>>>t},DqqFe:function(i,t){return i|t},OTbCB:function(i,t){return i(t)},fxtwb:function(i,t){return i===t},XrSDO:n(1235),YBVDX:function(i,t){return i(t)},vgIBt:function(i,t){return i|t},wfWGX:function(i,t){return i<<t},bOKpW:function(i,t){return i|t},svOil:function(i,t){return i|t},ZcvdW:function(i,t){return i<<t},aPdIU:function(i,t){return i<<t},Cjzjp:function(i,t){return i<<t},TwRab:function(i,t){return i|t},haEyF:function(i,t){return i<<t},dbJEq:function(i,t){return i|t},WgLwx:function(i,t){return i|t},TFxOY:function(i,t){return i|t},CsLkW:function(i,t){return i<<t},yhEgS:function(i,t){return i<<t},hGvsq:function(i,t){return i===t},ZAUVv:function(i,t){return i>>>t},aGLbF:function(i,t){return i>>>t},nSnwC:function(i,t){return i|t},yytOc:function(i,t){return i&t},TeLnJ:function(i,t){return i>>>t},lwMLc:function(i,t){return i&t},bnFxQ:function(i,t){return i>>>t},tuPeN:function(i,t){return i>=t},AMJAv:function(i,t){return i>=t},ocKeC:function(i,t){return i+t},oEcJa:function(i,t){return i%t},wyZTk:function(i,t){return i/t},FdWIO:function(i,t){return i>>>t},pWmYT:function(i,t){return i>>>t},oFJEY:function(i,t){return i*t},URUmx:function(i,t){return i>>>t},xAJvP:function(i,t){return i||t},IHHJg:n(444),hFTqz:function(i,t){return i>>>t},XjjSR:function(i,t){return i&t},MWOax:function(i,t){return i>>>t},QnfYN:function(i,t){return i>>>t},zpQcw:function(i,t){return i+t},GWBjV:function(i,t){return i>>>t},MhDSl:function(i,t){return i|t},dKlDg:"open",eoFTB:function(i,t){return i>>>t},qyczf:function(i,t){return i===t},QxpTd:function(i,t){return i===t},Kzzqa:function(i,t){return i!==t},uVqYS:n(1339),BCrDF:n(1567),KNwLl:function(i,t){return i===t},Cnjxy:function(i,t){return i&t},AoDRa:function(i,t){return i&t},ttfms:function(i,t){return i>>>t},pOcmv:function(i,t){return i&t},MMiYe:function(i,t){return i>>>t},hHHVw:"HvIGc",NSFCi:function(i,t){return i&t},RDJMO:function(i,t){return i>>>t},fDOLv:function(i,t){return i>>>t},QToOf:function(i,t){return i&t},hqSyP:function(i,t){return i&t},mUxze:n(942)+n(626),FEmWY:"CONNECTING_ERROR",ZJREj:n(806)+"IES_ERROR",IkoKG:"MESSAGE_"+n(1408),lCEaZ:n(483)+"OR",yjlTg:"4|1|0|2|3",rhlLH:"3|2|1|0|4",QTMPj:"message",SeBWW:"wXdxM",tEoPj:"TgsIA",WOwHl:function(i,t,r){return i(t,r)},aAxTO:n(725),LoLzF:n(809),nEKcK:n(1008)+"2",EQJQh:function(i,t){return i+t},CFakY:function(i,t){return i<t},edims:function(i,t){return i!==t},qTMBN:n(1406),uSdCb:n(922),SFGBW:function(i,t){return i instanceof t},LsYVc:function(i,t){return i+t},Clvwz:n(376)+n(332),QVMuH:function(i,t){return i===t},qedXj:function(i,t){return i===t},kShls:function(i,t){return i!==t},CpBlB:n(1395),pJUML:"fyEYh",hmNug:function(i,t,r){return i(t,r)},XzUeF:n(1131),yHUBt:function(i,t){return i!==t},VCZGA:"MYXlN",mLEil:n(1361),umnfM:function(i,t,r){return i(t,r)},PDGuP:n(1012),uhEvr:n(1714)+"id",LeMuU:"KgTuE",AbFYY:"mTpgr",liLcY:function(i,t){return i||t},zpIJK:function(i,t){return i||t},hcEcn:n(777)+"1",MaOYl:function(i,t){return i!=t},eFSls:function(i,t){return i<=t},yAcFI:"next() called mu"+n(1769)+n(1599)+"process",QykLq:function(i,t){return i===t},HTbvj:function(i,t){return i<t},dWCmh:function(i,t){return i<t},nPBXd:function(i,t){return i===t},fmEoU:function(i,t){return i&t},tDqNl:function(i,t){return i+t},rkVHI:function(i,t){return i<t},DgdoJ:function(i,t){return i<t},SJLcB:function(i,t){return i<=t},zyOiC:function(i,t){return i<t},GpFCB:function(i,t){return i<<t},LUgRm:function(i,t){return i&t},iSeLG:function(i,t){return i>=t},gpkcA:function(i,t){return i<t},avBlY:function(i,t){return i|t},TZNaX:function(i,t){return i<<t},yWFEA:function(i,t){return i&t},pRuxp:function(i,t){return i>=t},wXgHK:function(i,t){return i<<t},aZdzr:function(i,t){return i&t},MgYGp:function(i,t){return i<<t},CKfvt:function(i,t){return i&t},zeTXI:function(i,t){return i<<t},rbtbf:function(i,t){return i&t},ZsRAy:function(i,t){return i+t},EcaYi:function(i,t){return i===t},AqPoJ:n(1245),FpbJj:function(i,t){return i|t},gaJXF:function(i,t){return i&t},gmSxS:function(i,t){return i>>t},nFCPm:function(i,t){return i&t},RRDzF:function(i,t){return i&t},nSfBj:n(1725),SNQBA:n(1269),Rlzbg:function(i,t){return i&t},ORbih:function(i,t){return i&t},kxWjE:"send_ack",pyBTK:function(i,t){return i!==t},GSwfh:n(1203),GHTBJ:n(544),higjG:function(i,t){return i instanceof t},lhBtm:function(i,t){return i!=t},CaUSZ:n(1231),jpfaH:function(i,t){return i instanceof t},VPZEn:n(743)+n(1281),YqKzC:"text/pla"+n(356)+"et=utf-8",uPrmX:"boe",fXavX:"ppe",Yaoqq:n(1763),cfBZy:"eQSUS",SVUis:n(1323)+"ascript",IeqZx:function(i,t){return i(t)},wUJwW:n(921),iOekH:n(1349),RWGnH:n(1506),KDxsX:"qoQRq",goskX:n(933),XTdRz:function(i){return i()},iEIBC:function(i,t){return i!==t},uQlDH:n(533),ZtzQH:n(1539),FgqqI:function(i,t){return i||t},XsUtH:"TrLSV",IfBmo:function(i,t){return i(t)},irQnK:function(i,t){return i(t)},QcFVy:function(i,t){return i<<t},dLJYU:function(i,t){return i&t},zGXHq:function(i,t){return i!==t},uhiBx:n(426),EnqZq:function(i,t){return i!==t},JRwHZ:n(968),VFatf:function(i,t,r){return i(t,r)},yyXUL:function(i,t,r){return i(t,r)},cRYHn:function(i,t){return i!==t},HlYoW:"OAvIP",CBDcP:function(i,t){return i(t)},VDfjh:function(i,t){return i<=t},xeUDO:function(i,t){return i+t},IAEYb:function(i,t){return i|t},rQdLX:n(991),ifKty:n(278),mYfrA:function(i,t){return i||t},CveIy:function(i,t){return i|t},FNUpN:function(i,t){return i<t},dEtWc:function(i,t){return i|t},gScGX:function(i,t){return i>>t},yDzMd:function(i,t){return i&t},zmCYa:function(i,t){return i>>t},oyydH:function(i,t){return i&t},hhqCa:n(1096),dwdfS:n(1557),gpWUp:function(i,t){return i(t)},hwtaz:function(i,t){return i===t},JzhLn:n(897),MYqul:function(i,t){return i||t},kxnJn:n(498)+"d",STWzc:function(i,t){return i||t},Zbmth:"init QoS"+n(931)+"d",CgRPD:function(i,t,r){return i(t,r)},NAydj:n(1777),jirip:n(1610),ToWXl:function(i,t){return i!==t},sviab:n(1404),TIpYx:"sent",IVHLl:n(1770),YfvtS:function(i,t){return i(t)},hMdQe:n(1771),HLMZw:function(i,t){return i(t)},fUoHf:function(i,t){return i===t},WHvCK:"FzBst",UFulz:"PpdoV",HGLeh:"yQAcT",OAOlF:n(1413)+n(753),ToAfa:function(i,t,r,c){return i(t,r,c)},oybkn:n(1413)+n(1512)+"ck",UzZSP:n(1413)+"er_is_ack",dxBDq:n(1413)+n(474)+n(331),MyVbL:function(i,t){return i&t},kdteF:function(i,t){return i>>>t},GcbNd:function(i,t){return i&t},eHYOc:"KNaVL",UxPQD:n(727),MrtEB:n(586),NPXIt:function(i,t,r,c){return i(t,r,c)},iSPAn:n(462),IDQCv:function(i,t){return i!==t},DkXHu:n(1467),JEoIV:function(i){return i()},nGOfK:n(695),airUY:function(i,t){return i instanceof t},PfkEa:function(i,t){return i instanceof t},rHSkV:"applicat"+n(1281)+";charset"+n(1083),TvTrO:n(1644)+"e",yFEBT:n(734),jXJzl:function(i,t,r,c){return i(t,r,c)},cPpDu:function(i,t){return i>t},zPCKf:function(i,t){return i(t)},xHmtf:function(i,t){return i|t},FPECX:function(i,t){return i(t)},CIXxu:function(i,t){return i+t},PlDEP:function(i,t){return i+t},ukglZ:"index ou"+n(521)+n(1524),IJOtM:" + ",OavCd:" > ",AiRru:n(1159)+"too large",fZgmS:function(i,t){return i+t},QQPiR:function(i,t){return i+t},aVMiJ:function(i,t){return i<t},bvxmb:function(i,t,r){return i(t,r)},RKlIY:n(288)+"4",dBCBc:function(i,t){return i+t},VHmIw:function(i,t){return i|t},fSFsK:function(i,t){return i+t},DAjqR:function(i,t){return i+t},webJg:function(i,t){return i+t},VWtkg:function(i,t){return i+t},kfIZL:function(i,t){return i|t},lCSfE:function(i,t){return i+t},QvmsJ:function(i,t){return i<<t},Vorsg:function(i,t){return i+t},oRUlD:function(i,t){return i+t},PKtBI:n(1230),Tonfq:function(i,t){return i+t},FrjZQ:function(i,t){return i&t},GQjDW:function(i,t){return i>>>t},lPgzA:function(i,t){return i&t},qOzfz:function(i,t){return i>>>t},CXJbC:function(i,t){return i&t},BzbMv:function(i,t){return i+t},VukBw:function(i,t){return i&t},sQUJe:function(i,t){return i+t},ysubV:function(i,t){return i>>>t},qlRjl:function(i,t){return i+t},qUrTr:function(i,t){return i+t},EjchH:function(i,t){return i&t},HIUBT:function(i,t){return i&t},AiECl:function(i,t){return i+t},xPoXt:"3|2|1|11"+n(726)+"0|6|0|9|5",ADfle:function(i,t){return i|t},QCqqy:function(i,t){return i<<t},miDFH:function(i,t){return i&t},oUVUi:function(i,t){return i>>>t},kgtAE:function(i,t){return i|t},KQoes:function(i,t){return i&t},CuQuG:function(i,t){return i|t},VlIzd:function(i,t){return i&t},NGwjE:function(i,t){return i|t},KLrAM:function(i,t){return i>t},usarS:function(i,t,r,c){return i(t,r,c)},PURbf:function(i,t){return i<t},CASxu:function(i,t){return i|t},roQmr:function(i,t){return i<t},vhduq:n(938)+n(1518)+n(1386),pEvXY:n(1463)+n(291),TmmdH:n(291),AbyzD:function(i,t,r,c){return i(t,r,c)},xRRKy:"cursor_f"+n(1362),TcunG:function(i,t,r){return i(t,r)},SDRwZ:function(i,t){return i+t},rbVhO:function(i){return i()},bRwXB:function(i,t){return i!==t},eoIuz:n(634),mObAA:n(1742)+n(904),UkSpv:n(1319)+n(1536),MkcRJ:n(1624),LvwVz:n(1380),wzEWK:function(i,t,r,c){return i(t,r,c)},FbMbi:n(913),qFDzw:function(i,t){return i(t)},qFIlt:function(i,t){return i-t},Blwzv:function(i,t){return i|t},pxcVJ:function(i,t){return i<<t},ogYOB:function(i,t){return i<<t},agndu:function(i,t){return i&t},eVKJb:"CkccC",gQwNi:n(1502),ohCIi:n(1413)+n(1216),nTiyj:function(i,t){return i(t)},gHqWF:n(1413)+n(1062),nVAXg:function(i,t,r,c){return i(t,r,c)},sYPUY:n(1032)+"s",Dviof:"x-msg-cursor_value",KVPhW:function(i){return i()},NUMKU:function(i,t){return i>t},cBOaP:function(i,t){return i>t},EvIhs:"pcPrD",jWzwu:function(i,t){return i!==t},iBvMm:n(1336),rDdlb:function(i,t){return i+t},XWSat:function(i){return i()},NFblS:"XofSC",dKHJn:function(i,t){return i!==t},aObuq:n(1379),dSqpv:function(i,t){return i!==t},roJmc:n(423),WSnZm:function(i){return i()},PMYfO:function(i,t){return i&&t},bCLbR:function(i,t,r){return i(t,r)},YsCeN:function(i){return i()},VWnLT:function(i,t){return i!==t},NahTI:function(i,t){return i!==t},yrssJ:function(i,t){return i===t},ykBcJ:n(292),HfwcP:function(i,t,r,c){return i(t,r,c)},zNKmf:function(i,t){return i===t},IPDNi:n(909),GtwUL:function(i,t){return i===t},UVRAy:n(1422),BHleW:n(1621)+"e_success",OyZIc:n(773),vjWKD:"pVcXR",pHrOT:function(i,t,r){return i(t,r)},JMSTu:function(i,t){return i===t},fZDAd:function(i,t){return i>>>t},ZkYjS:function(i,t){return i&t},YlKWD:function(i,t){return i+t},UvEur:n(1604),OemNC:function(i,t){return i!==t},Nayux:function(i,t,r){return i(t,r)},XvYmg:n(652),aGQwx:function(i,t,r){return i(t,r)},oEutv:function(i,t,r){return i(t,r)},sWEPv:function(i,t){return i!==t},KGKxH:function(i,t){return i!==t},jhsad:n(289),AXUNr:n(531),aqpay:function(i,t,r){return i(t,r)},iKCfD:n(1449)+n(1420),FuxHd:n(1132),skrpO:function(i,t){return i/t},QGtxM:function(i,t){return i==t},ktpFA:function(i,t){return i===t},FXkCc:n(1729)+"rovide v"+n(1181),UCoWB:"please provide w"+n(1584)+n(464)+"ket cons"+n(1504)+n(1009)+n(471),kuiCe:n(1485),hSnsm:n(293),lImLY:function(i,t,r){return i(t,r)},VWDSu:n(693)+"t",XSXyy:n(470),UMboT:n(951),lqlcz:function(i,t,r){return i(t,r)},PHrhl:function(i,t){return i!==t},EyLgm:n(633),pFOss:n(297),OApuG:n(737),bbCaL:function(i,t){return i!==t},pnfYs:function(i,t){return i!==t},MqRFn:"FQMCF",UcMJh:function(i,t){return i==t},WOYrb:n(1330),emRoO:n(363),GuIwU:n(1590),gdhjF:n(349),OJqGE:n(489),XrVfy:n(540)+"d",xhmsm:function(i,t){return i||t},HOuOt:n(1729)+n(501)+n(301)+n(1686)+n(630),PcUad:function(i,t){return i==t},UaRPW:n(1487),hwsrI:n(1075)+"0",qrjbq:n(766),HVygY:n(1440)+"le",AzmZd:function(i,t){return i!==t},oGNCn:n(1587),odsJh:"FvcVi",KLFqF:function(i,t,r){return i(t,r)},zwYnz:function(i,t,r){return i(t,r)},WtgmA:n(493),eMBsK:function(i,t){return i>t},TkAYc:function(i,t,r){return i(t,r)},MMERW:function(i,t){return i(t)},nxzhb:function(i,t){return i(t)},SAYrP:n(976)+">",wbhdk:function(i,t){return i*t},lsCZD:n(768),SkvpJ:n(1414),sckRq:"BpYwh",akMin:"FIhOz",puqTq:function(i,t,r){return i(t,r)},MSVnL:n(436)+n(451)+"onnecting",eEZLb:function(i,t){return i(t)},gcWFq:function(i,t){return i===t},bnpCA:function(i,t){return i===t},AnRtR:n(348),fddpF:"0|3|2|1|4",RIkUf:n(950)+n(825),gVNDZ:n(1494),yWwRn:n(1162),wQSJJ:function(i,t,r){return i(t,r)},buecW:function(i,t,r){return i(t,r)},QkHXe:n(1762)+n(802)+n(1045)+n(873),fIXTb:n(954),DfTPT:n(920),Xekmw:n(1024),vLNNE:"close, w"+n(1279)+n(1625)+n(1760)+"ed",chBsa:function(i,t){return i===t},xrPgK:function(i,t){return i(t)},gWbHf:n(767)+"or",QVuAr:function(i,t){return i===t},RjOvo:n(1757),QbVCp:n(1388),VaMdq:function(i,t){return i==t},OQRWw:n(1729)+n(570)+n(670)+n(935)+"a must b"+n(1399)+n(1290)+n(1409)+n(458),iEkqn:n(1142),Uxczj:function(i,t){return i(t)},NreJS:function(i,t){return i(t)},mPzwz:n(1729)+n(570)+" valid s"+n(1629),JHlkP:function(i,t){return i instanceof t},uOyIl:n(1697),bFZme:function(i,t){return i==t},LTONQ:n(1586)+"econnect"+n(830),mLOzo:function(i,t){return i instanceof t},tnotJ:function(i,t){return i!==t},NatRu:"qTEHD",vYDBo:function(i,t){return i(t)},lsFxp:n(1620),JpFLh:function(i,t){return i*t},DVAqF:function(i,t){return i*t},VwrHy:function(i,t){return i!=t},uTbbq:"Window",SfrYq:function(i,t){return i===t},fwoQW:n(534)+n(642)+"lobalScope",rIxvb:function(i,t){return i!=t},qWDMJ:function(i,t){return i===t},adtLz:n(1473),kajec:function(i,t){return i!=t},DYzAB:function(i,t){return i!=t},RNyTy:function(i,t){return i!=t},SoOfo:function(i,t){return i!=t},qWuVE:n(1442)+"qos__"};Ue.r(te),Ue.d(te,{FWS:()=>D0,CustomErrorEvent:()=>ts,createCloseEvent:()=>De,ReconnectEvent:()=>es,createErrorEvent:()=>Ae,decodedFrame:()=>yt,createOpenEvent:()=>as,CustomCloseEvent:()=>ns,createReconnectEvent:()=>Mr,FrontierMessageEvent:()=>is,encodeFrame:()=>re,createMessageEvent:()=>os,OpenEvent:()=>ss,ErrorCode:()=>et,Event:()=>St,MessageEvent:()=>rs});let s="";function o(i=""){let t=n,r="02",c=""+Date[t(702)](),d=s||(s=g(i)),h=Math.random()[t(735)](16).slice(-6);return e.egHuX(e.egHuX(e[t(1014)](r,c),d),h)}function a(){let i=n;return e[i(1286)](1e4,Date[i(702)]())+Math[i(1355)](e[i(823)](1e4,Math[i(729)]()))}function x(i){let t=n;return e[t(410)](e[t(1566)](Array,8)[t(1640)]("0"),e[t(1510)](parseInt,i,10)[t(735)](2))[t(799)](-8)}function u(i){let t=n;return e.uxmKs(Array(4)[t(1640)]("0"),parseInt(i,2)[t(735)](16))[t(799)](-4)}function f(i){let t=n,r=i[t(961)](/\./)[t(1101)](h=>x(h)),c=[];return c[0]=e[t(1566)](u,r[0]+r[1]),c[1]=e[t(1727)](u,e[t(1178)](r[2],r[3])),[e[t(1421)],e[t(1421)],t(1344),e[t(1421)],e.RJOMC,t(994),c[0],c[1]][t(1640)]("")}function g(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(566)](i),c=/(([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(566)](i);return r?e.iSbLQ(f,i):c?e[t(1566)](p,i):e[t(650)]}function p(i){let t=n,r={CanYf:function(y,b){return e.tVNTc(y,b)},kCton:e.zAYjf,GzNMa:function(y,b,A){return e[B(1510)](y,b,A)},OSOaI:function(y,b,A){return e[B(1513)](y,b,A)}},c="",d=[],h=0,m=0,l=!0,v=e.RJOMC;if(e[t(1749)](i[t(1326)]("::"),-1)){let y=i[t(961)]("::");for(let A=0;A<y[t(680)];A++){let R=y[A];if(e[t(797)](R.indexOf(":"),0)){let z=R[t(961)](":");l&&(h=z[t(680)]),m+=z[t(680)];for(let L=0;e[t(1066)](L,z[t(680)]);L++)if(e[t(858)](4,z[L].length)){let Ne=v[t(1291)+"g"](0,4-z[L][t(680)]),Z=Ne.concat(z[L]);d[t(1734)](Z)}else d[t(1734)](z[L]);l=!1}else if(t(998)===e[t(1475)]){if(e[t(858)](4,R[t(680)]))if(e.toigU(e[t(1064)],e.lgaeI)){let z=v[t(1291)+"g"](0,e[t(1166)](4,R[t(680)])),L=z.concat(R);d[t(1734)](L)}else{if(r.CanYf(_0xbd038[t(1515)],_0x32d6df)>_0x4163af.limit)throw new _0x4a767d(r[t(1340)]);_0x5928f7[t(1515)]+=_0x2e9403}else d[t(1734)](R);l&&(h+=1),m+=1,l=!1}else r[t(1607)](_0xeaf2d0,_0xdff0a8,18),r[t(1054)](_0x5d122d,_0x3f4473,_0xabbeb3)}let b="";for(let A=0;e[t(900)](A,e[t(1110)](8,m));A++)b=b.concat(v);for(let A=0;e[t(1066)](A,d[t(680)]);A++)A===h&&(c=c[t(357)](b)),c=c[t(357)](d[A]);return c}{let y=i[t(961)](":");for(let b=0;e[t(1070)](b,y[t(680)]);b++){let A=y[b];if(y[b][t(680)]!==4){let R=v[t(1291)+"g"](0,e[t(1280)](4,y[b][t(680)])),z=R.concat(A);c=c[t(357)](z)}else c=c[t(357)](A)}return c}}function _(i,t){let r=n,c=i[r(1791)];e[r(858)](void 0,c)&&(e[r(1510)](V,t,10),ge(t,c));let d=i[r(414)];e.pfDSr(void 0,d)&&(e[r(1531)](V,t,18),e.QZLvk(ge,t,d))}function w(i){let t=n,r={};e:for(;!e.iSbLQ(ue,i);){let c=e.WlivM(Y,i);switch(c>>>3){case 0:break e;case 1:r[t(1791)]=e[t(1118)](Q,i,e[t(461)](Y,i));break;case 2:r[t(414)]=Q(i,e[t(637)](Y,i));break;default:e[t(1118)](X,i,e[t(1695)](7,c))}}if(r[t(1791)]===void 0)throw new Error(e[t(592)]);if(r[t(414)]===void 0)throw new Error(e[t(1385)]);return r}function E(i){let t=n,r=e[t(1651)](oe);return e[t(1531)](T,i,r),me(r)}function T(i,t){let r=n,c={REeRq:r(586),rycCL:function(Z,fe,lt,Ct){return e.XMbSZ(Z,fe,lt,Ct)},jrWXZ:function(Z,fe){return e.HQtNu(Z,fe)},AQebZ:r(462),VPJTQ:e[r(853)],mVcGk:function(Z,fe){return e[r(893)](Z,fe)},sRSSZ:e.ekGKH,CFAzq:function(Z){return e[r(1651)](Z)}},d=i[r(865)];e.gyjLu(void 0,d)&&(V(t,8),e.vVLAR(W,t,d));let h=i[r(1516)];h!==void 0&&(V(t,16),e[r(1282)](W,t,h));let m=i.service;e[r(1026)](void 0,m)&&(e[r(1118)](V,t,24),e.LJwlC(W,t,e[r(637)](K,m)));let l=i[r(1412)];e[r(365)](void 0,l)&&(e[r(1282)](V,t,32),W(t,e[r(637)](K,l)));let v=i[r(391)];if(e[r(651)](void 0,v))for(let Z of v){e.YhfTj(V,t,42);let fe=e.eGYsO(oe);e[r(1028)](_,Z,fe),e[r(609)](V,t,fe[r(721)]),e[r(1118)](Ke,t,fe),e[r(329)](ae,fe)}let y=i[r(732)+r(890)];e[r(858)](void 0,y)&&(e[r(905)](V,t,50),e[r(373)](ge,t,y));let b=i[r(1417)+r(1334)];e[r(651)](void 0,b)&&(V(t,58),e[r(1118)](ge,t,b));let A=i.payload;e[r(1314)](void 0,A)&&(e.QFHRN(V,t,66),e.dJpdO(V,t,A[r(680)]),e[r(1708)](be,t,A));let R=i[r(939)];if(e[r(1026)](void 0,R))if(e[r(1543)]===e.sStcX){let{enableAutoAck:Z}=this[r(1209)],fe=_0x52d998(_0x22af5e.message[r(391)],c[r(614)],"1"),lt=c[r(499)](_0x141791,_0x5e4c00.message[r(391)],"is_ack","1"),Ct=_0x272969[r(608)](this,_0x5a0c49);if(c[r(899)](Z,fe)){let{SeqID:Kr,LogID:jr,service:Jt,LogIDNew:bn,method:Vt}=_0x3d46e9.message;this[r(1111)]({SeqID:Kr,LogID:jr,LogIDNew:bn,service:Jt,method:Vt,headers:[{key:c[r(1480)],value:"1"},{key:c[r(993)],value:c[r(1369)](bn,"")},{key:c[r(1297)],value:"0"}]})}lt&&!Ct[r(556)]&&this[r(1633)+r(1722)+r(902)](_0x495af0),c[r(774)](_0x5ef31f)}else e.zbHPZ(V,t,74),e[r(373)](ge,t,R);let z=i[r(497)+r(1201)];z!==void 0&&(e[r(1118)](V,t,82),e[r(609)](ge,t,z));let L=i.msgID;e[r(1314)](void 0,L)&&(e[r(1708)](V,t,90),e[r(1531)](ge,t,L));let Ne=i.frameType;e[r(654)](void 0,Ne)&&(e[r(952)](V,t,96),e[r(792)](W,t,e[r(1563)](K,Ne)))}function k(i){return e[n(1566)](P,Te(i))}function P(i){let t=n,r={};e:for(;!e[t(1563)](ue,i);){let c=Y(i);switch(e.KSeCT(c,3)){case 0:break e;case 1:r[t(865)]=ut(i,!0);break;case 2:r[t(1516)]=e[t(1338)](ut,i,!0);break;case 3:r.service=Y(i);break;case 4:r.method=e[t(329)](Y,i);break;case 5:{let d=H(i);(r[t(391)]||(r[t(391)]=[]))[t(1734)](e[t(329)](w,i)),i[t(721)]=d;break}case 6:r["payloadE"+t(890)]=e[t(1300)](Q,i,e[t(1727)](Y,i));break;case 7:r[t(1417)+"ype"]=e[t(1394)](Q,i,e[t(323)](Y,i));break;case 8:r.payload=e[t(1394)](F,i,e[t(1563)](Y,i));break;case 9:r[t(939)]=e[t(1513)](Q,i,e[t(1320)](Y,i));break;case 10:r.serverTiming=e[t(1082)](Q,i,Y(i));break;case 11:r[t(1555)]=e[t(1704)](Q,i,e[t(958)](Y,i));break;case 12:r.frameType=e[t(329)](Y,i);break;default:X(i,e[t(1695)](7,c))}}if(e[t(815)](void 0,r[t(865)]))throw new Error(e[t(1364)]);if(e[t(815)](void 0,r[t(1516)]))throw new Error(e[t(298)]);if(e[t(815)](void 0,r[t(1158)]))throw new Error(e[t(659)]);if(e[t(815)](void 0,r.method))throw new Error(e[t(1663)]);return r}function H(i){let t=n,r=e[t(1566)](Y,i),c=i[t(721)];return i.limit=e[t(1014)](i[t(1515)],r),c}function X(i,t){let r=n;switch(t){case 0:for(;128&e[r(764)](ne,i););break;case 2:e[r(1582)](de,i,Y(i));break;case 5:e.NVADU(de,i,4);break;case 1:de(i,8);break;default:throw new Error(e.qoRNq(e[r(917)],t))}}function K(i){let t=n;return i|=0,{low:i,high:e.pjOGO(i,31),unsigned:e[t(1019)](i,0)}}let J=[];function oe(){let i=n,t=J[i(473)]();return t?(t[i(1515)]=t[i(721)]=0,t):{bytes:new Uint8Array(64),offset:0,limit:0}}function ae(i){let t=n;if(e[t(815)](e[t(345)],t(1580)))J[t(1734)](i);else{if(!this._ws)return;this[t(1265)+t(395)+"t"](_0x2445cd,_0x24bd9c,_0x1ec396)}}function Te(i){return{bytes:i,offset:0,limit:i.length}}function me(i){let t=n;if(e[t(815)](e.tPYms,e[t(846)]))return this[t(742)].readyState;{let r=i[t(1140)],c=i.limit;return e[t(282)](r[t(680)],c)?r:r[t(1668)](0,c)}}function de(i,t){let r=n;if(e[r(1313)](r(1558),e[r(816)]))return this[r(1060)].isReady;if(i[r(1515)]+t>i[r(721)])throw new Error(r(705)+r(1057));i[r(1515)]+=t}function ue(i){let t=n;return e[t(1285)](i[t(1515)],i[t(721)])}function I(i,t){let r=n,c=i[r(1140)],d=i.offset,h=i[r(721)],m=e[r(532)](d,t);if(e[r(839)](m,c[r(680)])){let l=new Uint8Array(e.qVvJK(2,m));l[r(406)](c),i[r(1140)]=l}return i.offset=m,e[r(1617)](m,h)&&(i[r(721)]=m),d}function O(i,t){let r=n,c=i.offset;if(c+t>i[r(721)])throw new Error(e[r(1481)]);return i[r(1515)]+=t,c}function F(i,t){let r=n,c=e[r(905)](O,i,t);return i[r(1140)][r(1668)](c,e[r(833)](c,t))}function be(i,t){let r=n,c=I(i,t.length);i[r(1140)][r(406)](t,c)}function Q(i,t){let r=n,c={YOPBw:function(d){return e[B(1651)](d)},JrjOg:function(d,h,m){return e[B(1510)](d,h,m)},GkvGK:function(d,h){return e[B(368)](d,h)},ZjGHq:e[r(419)],BdSMB:e.jelHw};if(e.muUha(e[r(963)],e[r(963)]))return!!_0x41c959?.[r(689)](d=>d[r(1791)]===_0x11ee18&&d[r(414)]===_0x35cc11);{let d=e.IPGMH(O,i,t),h=String[r(1631)+r(299)],m=i[r(1140)],l="\uFFFD",v="";for(let y=0;e.IOvbw(y,t);y++)if(e[r(815)](e[r(1527)],e[r(1003)])){let b=gmxvpj[r(399)](_0x5c5eb3);return gmxvpj[r(999)](_0x344044,_0x41ae47,b),gmxvpj[r(926)](_0x20c2cd,b)}else{let b=m[e.zanTJ(y,d)],A,R,z,L;(128&b)===0?v+=e[r(1044)](h,b):e[r(967)](e[r(492)](224,b),192)?e[r(338)](e[r(410)](y,1),t)?v+=l:(A=m[e[r(310)](y,d)+1],e[r(1104)](e.tvKcG(192,A),128)?v+=l:(L=e[r(480)](e[r(1693)](31,b)<<6,e[r(1693)](63,A)),e[r(1070)](L,128)?v+=l:(v+=e[r(1324)](h,L),y++))):e[r(492)](240,b)==224?e[r(1423)](e.aUVxN(y,2),t)?v+=l:(A=m[e[r(1284)](e[r(370)](y,d),1)],R=m[e.uxmKs(e[r(1596)](y,d),2)],(e.XdTkf(A,e[r(369)](R,8))&49344)!==32896?v+=l:(L=e[r(480)](e[r(605)](e[r(1309)](15,b),12)|e.sWLOB(63&A,6),63&R),e[r(900)](L,2048)||e[r(1681)](L,55296)&&e[r(1275)](L,57343)?v+=l:(v+=e[r(1486)](h,L),y+=2))):e.Wtwbr(e.gIOAf(248,b),240)?e[r(1493)](y,3)>=t?v+=l:e[r(1313)](r(1427),e.xCaZy)?(A=m[e.MmkgW(y+d,1)],R=m[y+d+2],z=m[e[r(532)](e.aUVxN(y,d),3)],e[r(651)](e[r(602)](e.JTxwK(e.RsyKg(A,R<<8),e.sWLOB(z,16)),12632256),8421504)?v+=l:(L=e[r(1751)](e.XdTkf(e[r(1343)](e.ryAgK(7&b,18),e[r(492)](63,A)<<12),e[r(605)](e[r(1695)](63,R),6)),63&z),e[r(1066)](L,65536)||e.fNqxd(L,1114111)?v+=l:(L-=65536,v+=e.YhfTj(h,e[r(619)](L,10)+55296,e[r(1574)](e[r(486)](1023,L),56320)),y+=3))):(c[r(926)](_0x1af462,c[r(1011)]),this.off(r(1621)+r(1220)+"s",_0x36111c),this[r(559)](c.BdSMB,_0x1602df)):v+=l}return v}}function ge(i,t){let r=n,c=t[r(680)],d=0;for(let l=0;e[r(900)](l,c);l++){let v=t[r(1138)+"At"](l);e[r(1019)](v,55296)&&e.rlkju(v,56319)&&e[r(1070)](l+1,c)&&(v=e.Eeisv(e[r(750)](v,10)+t[r(1138)+"At"](++l),56613888)),d+=e[r(1522)](v,128)?1:e[r(1446)](v,2048)?2:e[r(1070)](v,65536)?3:4}e[r(411)](V,i,d);let h=e[r(1656)](I,i,d),m=i[r(1140)];for(let l=0;e[r(1466)](l,c);l++){let v=t[r(1138)+"At"](l);e[r(1423)](v,55296)&&e[r(1061)](v,56319)&&e.dRsGz(l+1,c)&&(v=e[r(1683)](e[r(1733)](v<<10,t[r(1138)+"At"](++l)),56613888)),v<128?m[h++]=v:(e[r(1049)](v,2048)?m[h++]=e.kXjkt(e[r(1277)](v>>6,31),192):(v<65536?m[h++]=e[r(1283)](e[r(1236)](e.SnKQa(v,12),15),224):(m[h++]=e.EUaYu(e[r(932)](e[r(835)](v,18),7),240),m[h++]=e[r(1129)](e[r(1263)](e[r(835)](v,12),63),128)),m[h++]=e[r(864)](e.MDObu(e[r(1744)](v,6),63),128)),m[h++]=e.ePCUw(e[r(1713)](63,v),128))}}function Ke(i,t){let r=n,c=e[r(1267)](I,i,t.limit),d=i[r(1140)],h=t.bytes;for(let m=0,l=t[r(721)];m<l;m++)d[e[r(410)](m,c)]=h[m]}function ne(i){return i[n(1140)][O(i,1)]}function Qe(i,t){let r=n,c=e[r(1708)](I,i,1);i[r(1140)][c]=t}function Y(i){let t=n,r={VWQiZ:function(m,l){return m(l)},UrQGA:e[t(364)]},c=0,d=0,h;do e[t(365)](t(974),e.KMIKq)?(_0x6f40fa[t(1221)+t(701)]=void 0,r[t(658)](_0x395fc7,r[t(535)])):(h=ne(i),e[t(1522)](c,32)&&(d|=e[t(848)](e.MfDrL(127,h),c)),c+=7);while(e[t(1662)](128,h));return d}function V(i,t){let r=n;for(t>>>=0;e[r(525)](t,128);)e.LPCUM(Qe,i,e.XdTkf(e.JBHLn(127,t),128)),t>>>=7;e[r(1768)](Qe,i,t)}function ut(i,t){let r=n,c={PNUkC:function(v,y,b){return e[B(724)](v,y,b)},CsxiZ:e[r(960)]},d=0,h=0,m=0,l;if(l=e[r(1426)](ne,i),d=e[r(1277)](127,l),e.LCYSG(128,l)&&(l=e[r(1563)](ne,i),d|=e[r(417)](e.qZtpt(127,l),7),e.MDObu(128,l)&&(l=e[r(637)](ne,i),d|=e[r(862)](e[r(594)](127,l),14),e[r(1263)](128,l)))){if(e[r(1576)]("RiLci","RiLci"))_0x59b4f6=_0x4213c8[e[r(832)](e.irmyq(_0x116619,_0x5d1373),1)],e[r(365)](e[r(545)](192,_0x95ac7f),128)?_0x1954d4+=_0x41cdb8:(_0x82907e=e[r(864)](e[r(1575)](e[r(602)](31,_0x591262),6),e[r(313)](63,_0x3cb7a6)),e.IOvbw(_0xf1960f,128)?_0xc80ee7+=_0x45a0ea:(_0x81eb75+=e.BgWcO(_0x3cd989,_0x4c3f84),_0x457e44++));else if(l=ne(i),d|=e[r(848)](127&l,21),e[r(1713)](128,l))if(r(1204)!==r(1441)){if(l=e[r(285)](ne,i),h=127&l,e[r(1415)](128,l))if(e[r(1482)](r(1273),e[r(808)])){if(l=e[r(795)](ne,i),h|=(127&l)<<7,e[r(1693)](128,l)&&(l=e[r(859)](ne,i),h|=e[r(911)](e[r(568)](127,l),14),e[r(492)](128,l)))if(e.NZUyN(e[r(831)],r(522))){if(l=e[r(1320)](ne,i),h|=(127&l)<<21,e[r(1263)](128,l)&&(l=e.oIaVb(ne,i),m=e.oHHvz(127,l),128&l))if(e.muUha(e.zgJta,e.zgJta)){let v=r(1079)+_0x255902+(r(959)+r(1274)+r(710)+r(1669));this[r(1121)](v),this[r(1633)+r(1643)+r(1424)](c.PNUkC(_0x12cd3f,c[r(639)],{message:v,code:_0x5e277f["MAX_RETR"+r(681)+"R"]}));return}else l=ne(i),m|=(127&l)<<7}else this[r(449)+"er"]&&_0xd3b437[r(548)+r(408)+r(1160)](r(951),this[r(445)+r(699)]),this[r(449)+"er"]&&_0x1e2e4a[r(548)+r(408)+r(1160)](e[r(1601)],this[r(445)+r(340)]),this[r(1131)]()}else return new _0x27250f(_0x5eaf35,{message:_0x4b2b07})}else _0x1981af=DTZqle[r(323)](_0x3b14e2,_0x16f43a)}return{low:e[r(552)](d,e[r(1094)](h,28)),high:e.KSeCT(h,4)|e.ryAgK(m,24),unsigned:t}}function W(i,t){let r=n,c=e[r(335)](t[r(389)],0),d=e[r(1186)](e[r(706)](t.low,28),t[r(972)]<<4)>>>0,h=e[r(413)](t[r(972)],24),m=e.XtagX(0,h)?e[r(667)](0,d)?c<16384?e[r(1302)](c,128)?1:2:e[r(1070)](c,2097152)?3:4:e.SMxAa(d,16384)?e[r(673)](d,128)?5:6:d<2097152?7:8:h<128?9:10,l=e[r(1352)](I,i,m),v=i[r(1140)];switch(m){case 10:v[l+9]=e[r(1547)](e.YnAwQ(h,7),1);case 9:v[e.yVvKR(l,8)]=m!==9?e[r(1751)](128,h):e.lpywf(127,h);case 8:v[l+7]=e.jmvxV(8,m)?e[r(1497)](d>>>21,128):e[r(1711)](e.YnAwQ(d,21),127);case 7:v[e.qoRNq(l,6)]=e[r(1314)](7,m)?e[r(1615)](e[r(706)](d,14),128):e[r(313)](e.YnAwQ(d,14),127);case 6:v[l+5]=e[r(505)](6,m)?e.EUaYu(d>>>7,128):e[r(826)](d,7)&127;case 5:v[e[r(1178)](l,4)]=e[r(1104)](5,m)?128|d:e[r(313)](127,d);case 4:v[e.UUbXb(l,3)]=m!==4?e.CgUIX(e[r(1530)](c,21),128):e[r(1641)](e[r(826)](c,21),127);case 3:v[l+2]=e[r(1199)](3,m)?e[r(413)](c,14)|128:e[r(545)](e[r(826)](c,14),127);case 2:v[e[r(370)](l,1)]=m!==2?e[r(478)](e.btQsp(c,7),128):e.JBHLn(e[r(826)](c,7),127);case 1:v[l]=e[r(1482)](1,m)?e.DqqFe(128,c):e[r(1309)](127,c)}}function yt(i){return e.OTbCB(k,i)}function re(i){let t=n,r={InFwV:function(c,d){return e.dnduI(c,d)}};if(e.fxtwb(e[t(1091)],t(1235)))return e[t(1432)](E,i);_0x1c327e=_0x6d8d93(_0x114150),_0x2407cc|=IUGtCP.InFwV(127&_0x352833,7)}let bt=65536,_e=e[n(1745)],vt=e[n(903)](bt,bt),Xi=e[n(971)](vt,vt),Qi=e[n(1546)](Xi,2),Ze=String.prototype[n(1138)+"At"];class j{constructor(t,r,c){let d=n;this[d(1470)]=!0,this[d(389)]=e[d(690)](0,t),this[d(972)]=0|r,this.unsigned=!!c}static[n(1470)](t){let r=n;return t&&e[r(815)](!0,t[r(1470)])}static[n(884)](t,r,c){return new j(t,r,c)}static[n(646)+"s"](t,r,c){let d=n;return c?j[d(646)+d(1535)](t,r):j[d(646)+d(1041)](t,r)}static[n(646)+n(1535)](t,r){let c=n;return new j(e[c(1239)](e[c(1129)](e[c(864)](t[0],e[c(848)](t[1],8)),e.wfWGX(t[2],16)),t[3]<<24),e.bOKpW(e[c(945)](e[c(1343)](t[4],e[c(519)](t[5],8)),e[c(378)](t[6],16)),e[c(1224)](t[7],24)),r)}static["fromByte"+n(1041)](t,r){let c=n;return new j(e[c(1488)](e.vgIBt(e[c(1575)](t[4],24),e[c(1076)](t[5],16))|t[6]<<8,t[7]),e[c(870)](e.WgLwx(e[c(941)](e.CsLkW(t[0],24),e[c(620)](t[1],16)),e[c(457)](t[2],8)),t[3]),r)}static[n(1137)](t){let r=n;return e.hGvsq(t,_e)?Zi:new j(e.ZAUVv(e[r(1239)](Ze.call(t,0)|Ze[r(608)](t,1)<<8,e[r(1575)](Ze[r(608)](t,2),16))|Ze.call(t,3)<<24,0),e.aGLbF(e[r(1129)](e[r(1497)](e[r(454)](Ze[r(608)](t,4),e.ryAgK(Ze[r(608)](t,5),8)),Ze.call(t,6)<<16),Ze[r(608)](t,7)<<24),0),!0)}[n(716)](){let t=n;return String[t(1631)+"Code"](e[t(416)](255,this[t(389)]),e[t(1415)](this[t(389)]>>>8,255),this.low>>>16&255,e[t(826)](this.low,24),e.yytOc(255,this[t(972)]),e[t(1713)](e.TeLnJ(this[t(972)],8),255),e.lwMLc(this.high>>>16,255),e.bnFxQ(this[t(972)],24))}static fromNumber(t,r=!0){let c=n;if(e.iSbLQ(isNaN,t))return r?Gc:Zi;if(r){if(e[c(1271)](t,Xi))return jc}else{if(t<=-Qi)return Wc;if(e[c(418)](e[c(762)](t,1),Qi))return Kc}return j.fromBits(e[c(697)](t,vt)|0,e[c(870)](e.wyZTk(t,vt),0),r)}[n(684)](){let t=n;return this[t(1359)]?e[t(310)](e[t(1346)](this[t(972)],0)*vt,e.pWmYT(this[t(389)],0)):e.aUVxN(e[t(446)](this[t(972)],vt),e.URUmx(this[t(389)],0))}isZero(){let t=n;if(t(444)===e[t(1387)])return e[t(967)](0,this.high)&&e.rLlep(0,this.low);if(_0x1667a3)return new _0x44fe12(_0x160e11[t(604)],_0x498d48[t(910)]);if(e[t(893)](_0x122bf0,_0x526fb3))return new _0x228ab6(_0x5441b0[t(604)],_0x1192a2[t(910)],_0x557f38.headers);if(e.xAJvP(_0x1e31a2,_0x5438aa)&&typeof _0x465e42<"u"&&_0x462448)return new _0xb1ac91(_0x327065.url,_0x1c4065[t(910)+"s"])}[n(1208)](t){let r=n;j[r(1470)](t)||(t=j.fromNumber(t));let c=e[r(328)](this[r(972)],16),d=e[r(925)](65535,this[r(972)]),h=e[r(404)](this.low,16),m=65535&this[r(389)],l=e[r(649)](t.high,16),v=e[r(1236)](65535,t[r(972)]),y=t.low>>>16,b=e.gIOAf(65535,t[r(389)]),A=0,R=0,z=0,L=0;return L+=m+b,z+=L>>>16,L&=65535,z+=e[r(1389)](h,y),R+=e[r(1464)](z,16),z&=65535,R+=e.ocKeC(d,v),A+=e[r(1530)](R,16),R&=65535,A+=c+l,A&=65535,j[r(884)](e[r(1593)](z<<16,L),e[r(440)](A<<16,R),this.unsigned)}equals(t){let r=n,c={SSaoh:e.dKlDg};if(r(1360)===r(1360))return j[r(1470)](t)||(t=j[r(1776)+"er"](t)),e.toigU(this.unsigned,t[r(1359)])&&e[r(326)](e[r(517)](this[r(972)],31),1)&&t[r(972)]>>>31===1?!1:e[r(664)](this.high,t.high)&&e[r(1180)](this.low,t[r(389)]);this[r(601)](c[r(1478)],_0x1b097c),this[r(1254)]&&this[r(1254)](_0x15a6db)}[n(854)](){let t=n;return e.Kzzqa(e[t(283)],e[t(665)])?this[t(389)]===-1&&e[t(326)](-1,this[t(972)])?j[t(884)](0,0,this[t(1359)]):e[t(1703)](-1,this.low)?j[t(884)](0,e[t(532)](this[t(972)],1),this[t(1359)]):j[t(884)](e[t(1178)](this.low,1),this[t(972)],this[t(1359)]):(this[t(643)+"ndpointTriesCount"]++,this[t(1477)+"ntEndpoint"]())}[n(466)](t){return t?this.toBytesLE():this[n(430)+"E"]()}[n(1511)+"E"](){let t=n,r=this[t(972)],c=this[t(389)];return[255&c,e[t(494)](c>>>8,255),e[t(934)](e.ttfms(c,16),255),c>>>24,e.rUIUW(255,r),e[t(1087)](e[t(1017)](r,8),255),e[t(602)](e[t(1397)](r,16),255),e[t(887)](r,24)]}[n(430)+"E"](){let t=n;if(e[t(1552)]===e[t(1552)]){let r=this[t(972)],c=this.low;return[e[t(328)](r,24),e[t(575)](e[t(875)](r,16),255),e[t(1236)](e.bnFxQ(r,8),255),e[t(932)](255,r),e[t(277)](c,24),e[t(1641)](e.fDOLv(c,16),255),e.QToOf(c>>>8,255),e[t(1382)](255,c)]}else return this[t(742)][t(604)]}}let Zi=new j(0,0,!1),Gc=new j(0,0,!0),Kc=j[n(884)](-1,2147483647,!1),jc=j.fromBits(-1,-1,!0),Wc=j.fromBits(0,-2147483648,!1);var et=(function(i){let t=n;return i[i[e[t(636)]]=5001]="NATIVE_E"+t(626),i[i[t(1139)+"NG_ERROR"]=5002]=e[t(1719)],i[i[e[t(1213)]]=5003]=e[t(1213)],i[i[e[t(761)]]=5004]=e.IkoKG,i[i[e[t(1562)]]=5005]=e[t(1562)],i})({});class St{constructor(t){this.type=t,this.target=null}}class es extends St{constructor(t,r){let c=n;super(t),this[c(1509)]=r&&r[c(1509)]||null}}class ts extends St{constructor(t,r){let c=n,d=(c(1183)+c(315))[c(961)]("|"),h=0;for(;;){switch(d[h++]){case"0":this[c(1732)]=r&&r[c(1732)]||0;continue;case"1":this[c(741)]=r&&r[c(741)]||"";continue;case"2":super(t);continue;case"3":this[c(1509)]=r&&r.message||"";continue;case"4":this.colno=r&&r[c(711)]||0;continue;case"5":this.code=r&&r[c(1303)]||5001;continue;case"6":this.error=r&&r[c(1013)]||null;continue}break}}}class ns extends St{constructor(t,r){let c=n,d=e[c(460)].split("|"),h=0;for(;;){switch(d[h++]){case"0":this[c(746)]=r&&r[c(746)]||"";continue;case"1":this.code=r&&r.code||0;continue;case"2":this[c(1150)]=r&&r[c(1150)]||!1;continue;case"3":this[c(355)+"nnect"]=r&&r[c(355)+c(818)]||!1;continue;case"4":super(t);continue}break}}}class rs extends St{constructor(t,r){let c=n;super(t),this[c(1084)]=r&&r[c(1084)]||null}}class is extends rs{constructor(t,r){let c=n,d={YdbkA:e.rhlLH,MICuI:e[c(1429)],IwXGG:e[c(428)]};if(e[c(1314)](c(442),e[c(662)])){let h=d[c(1377)][c(961)]("|"),m=0;for(;;){switch(h[m++]){case"0":this[c(758)][c(1572)+"Listener"](d.MICuI,this[c(1612)+"ge"]);continue;case"1":this[c(758)][c(1572)+c(1261)](c(1131),this._onClose);continue;case"2":this._ws[c(1572)+c(1261)](d.IwXGG,this[c(1738)]);continue;case"3":if(!this[c(758)])return;continue;case"4":this[c(758)][c(1572)+c(1261)](c(1013),this[c(1088)]);continue}break}}else super(t),this[c(1084)]=r&&r[c(1084)]||null,this.message=r&&r[c(1509)]||null}}class ss extends St{constructor(t,r){let c=n;super(t),this[c(1084)]=r&&r[c(1084)]||null}}function Ae(i,{message:t,code:r,error:c}){return new ts(i,{message:t,code:r,error:c})}function De(i,{code:t,reason:r,wasClean:c,willReconnect:d}){return new ns(i,{code:t,reason:r,wasClean:c,willReconnect:d})}function os(i,{data:t,message:r}){let c=n;if(e.LSgDN(e[c(1329)],e.tEoPj))return new is(i,{data:t,message:r});this[c(742)]&&this[c(742)][c(1131)]({code:_0x149822,reason:_0x2a2f6b})}function as(i,{data:t}){return new ss(i,{data:t})}function Mr(i,{message:t}){let r=n;if(e[r(1576)](e[r(882)],e[r(1042)]))return new es(i,{message:t});{let c=e[r(623)](_0x293fe5,e[r(960)],{message:_0x3ddc63[r(1509)],code:_0x893ba3[r(483)+"OR"],error:_0x37cff2});this["_dispatc"+r(1643)+"ent"](c)}}class cs{constructor(t,r){let c=n;this[c(1501)+"s"]=t,this[c(495)+"es"]=r,this[c(465)+"ndex"]=0,this[c(643)+c(1232)+c(717)+"t"]=0}[n(1786)+n(1698)+n(577)](){let t=n;this[t(465)+"ndex"]=0,this["currentE"+t(1232)+t(717)+"t"]=0}[n(1602)+"es"](){let t=n;this[t(643)+"ndpointTriesCount"]=0}[n(1477)+n(308)+"nt"](){let t=n;return this[t(1501)+"s"][this[t(465)+"ndex"]]}[n(1477)+n(308)+n(477)+"ount"](){let t=n;return this[t(643)+t(1232)+t(717)+"t"]}[n(845)+n(1327)+"es"](){let t=n;return!!(e[t(1271)](this[t(465)+"ndex"],this.endpoints[t(680)])||this[t(465)+"ndex"]===e.Eeisv(this[t(1501)+"s"].length,1)&&this[t(643)+t(1232)+t(717)+"t"]===this.maxRetries)}[n(1276)+n(709)+n(342)+n(1278)+"tries"](){let t=n,r={BQxXN:e[t(367)],gRdXw:function(c,d){return e[t(529)](c,d)},rJbUz:function(c,d){return e[t(502)](c,d)},MsJej:function(c,d,h,m){return e.XMbSZ(c,d,h,m)},ZAZQh:function(c,d){return e[t(1701)](c,d)}};if(e.edims(t(1406),e[t(1737)])){let c=r.BQxXN[t(961)]("|"),d=0;for(;;){switch(c[d++]){case"0":if(_0x57f48a[t(669)+"e"])return r[t(510)](_0xf47399[t(669)+"e"](_0x16909d,_0x2a7b8e),_0x2aedce);continue;case"1":if(_0xeda99a.write)return r.gRdXw(_0x16e3e5[t(1174)](_0x1602c0,_0x4135cc),_0x201b85);continue;case"2":return r[t(1765)](r[t(851)](_0x48389c,_0x41c30b,_0x140196,_0x2b5b66),_0x207956);case"3":if(r[t(671)](_0x279703[t(680)],40))return _0x52f184(_0x191ea8,_0x546e69,_0x9e59b)+_0x224989;continue;case"4":if(!_0x5e19fb)return _0x38ca32;continue}break}}else return e[t(1080)](this[t(465)+t(1093)],this[t(1501)+"s"].length)?!0:e[t(797)](this[t(643)+"ndpointT"+t(717)+"t"],this[t(495)+"es"])}["replaceBackupEnd"+n(957)+n(1402)+"unt"](){let t=n;return this[t(643)+t(1232)+t(717)+"t"]=1,this[t(465)+t(1093)]++,this.endpoints[this["currentI"+t(1093)]]}["getCurre"+n(308)+"ntAndUpd"+n(871)](){let t=n;return this["currentE"+t(1232)+t(717)+"t"]++,this[t(1477)+t(308)+"nt"]()}}let Et=(e[n(785)](e.kxnJn,typeof globalThis)&&e.ktpFA(e[n(397)],globalThis[n(1451)+n(1735)][n(291)])||e.VwrHy(e.kxnJn,typeof window)&&e[n(918)]("Window",window[n(1451)+n(1735)].name))&&e.MaOYl(e[n(481)],typeof document),ft=e.VwrHy(e.kxnJn,typeof globalThis)&&(e[n(1180)](n(1473),globalThis["construc"+n(1735)][n(291)])||e[n(984)]===globalThis[n(1451)+n(1735)].name)&&e.rIxvb(e[n(481)],typeof tt),Wt=(e.kxnJn!=typeof globalThis&&e[n(1308)](e[n(876)],globalThis[n(1451)+n(1735)][n(291)])||e.bFZme(e[n(481)],typeof globalThis)||e.MaOYl(e[n(481)],typeof globalThis)&&!!globalThis[n(751)+n(1038)])&&e[n(539)](n(498)+"d",typeof wx),$t=e[n(539)](e[n(481)],typeof globalThis)&&(e.EcaYi(e.fwoQW,globalThis[n(1451)+n(1735)][n(291)])||e[n(1670)](n(1523)+"rkerGlob"+n(817),globalThis.constructor[n(291)])||e.chBsa(n(1678)+n(1443)+n(668),globalThis[n(1451)+"tor"][n(291)]))&&e[n(1071)](e[n(481)],typeof self),$c=e[n(1410)](e[n(481)],typeof globalThis)&&e[n(876)]===globalThis[n(1451)+n(1735)][n(291)]&&e[n(785)](n(498)+"d",typeof global)&&e[n(563)](n(1473),global[n(1451)+n(1735)][n(291)])&&e[n(803)](e[n(481)],typeof process)&&!!process[n(1210)];class Br{constructor(){let t=n,r={mhces:function(c,d){return e[B(859)](c,d)}};if(e[t(1703)](e.uSdCb,e[t(682)]))this._listeners={};else{let c=_0x1c217a[t(608)](_0x42af29(this),_0x2f38b8,..._0x1293f6);return _0x43b9a9[t(406)](c,_0x500646[t(1746)]?_0x1a2df5.sort():[_0x4ce8e4]),GheRhx[t(1090)](_0x2852fd,c)}}[n(601)](t,...r){let c=n,d=this._listeners[t];if(d)d[c(799)]().forEach(h=>h.fn.apply(h[c(557)],r));else if(e[c(664)](c(1013),t)&&!this[c(1560)]){let h=r[c(680)]&&r[0];if(e.SFGBW(h,Error))throw h;let m=new Error(e.LsYVc(e[c(786)],h?e[c(832)](" (",h[c(1509)])+")":""));throw m[c(311)]=h,h}return this}off(t,r){let c=n;if(e[c(1605)](void 0,t))this[c(1495)+"rs"]={};else if(e.qedXj(void 0,r))this[c(1495)+"rs"][t]=null;else{let d=this[c(1495)+"rs"][t];if(d)for(let h=0;h<d.length;)d[h].fn===r?d[c(576)](h,1):++h}return this}on(t,r,c){let d=n;return(this._listeners[t]||(this[d(1495)+"rs"][t]=[])).push({fn:r,ctx:c||this}),this}}class Jc extends Br{[n(1321)+n(431)+"age"](t){let r=n;return t[r(401)]||t[r(657)]?(r(463)+" "+(t.errMsg||"")+r(390)+(t[r(657)]||""))[r(1673)]():JSON[r(1578)+"y"](t)}constructor(t,r,c){let d=n;e.kShls(e[d(1452)],e[d(1452)])?(this[d(1401)+d(869)+"line"]=_0x5eed53,_0x110a39?this[d(385)+"nLine"]():this[d(385)+d(937)]()):(super(),this[d(742)]=null,Wt&&wx[d(496)+d(599)]&&(this._socket=wx[d(496)+"ocket"]({url:t,protocols:r,header:c,fail:this["_createS"+d(1328)+d(1391)].bind(this),success:this[d(1293)+d(468)+"cessHand"+d(1365)][d(841)](this)})),ft&&tt[d(496)+d(599)]&&(this[d(742)]=tt[d(496)+d(599)]({url:t,protocols:r,header:c,fail:this[d(1293)+d(1328)+"lHandler"][d(841)](this),success:this[d(1293)+d(468)+d(1712)+d(1365)][d(841)](this)})))}[n(1293)+n(468)+n(1712)+"ler"](){let t=n;Promise[t(645)]().then(()=>{this[t(843)+"steners"]()})}[n(1293)+n(1328)+n(1391)](t){let r=n,c={GZBpP:function(d,h,m){return e.vmRwu(d,h,m)},bZsqP:e[r(960)],TCDYG:function(d,h,m){return d(h,m)},kDDbX:r(1131)};Promise[r(645)]()[r(1123)](()=>{let d=r,h=c[d(1645)](Ae,c[d(542)],{message:this[d(1321)+"rrorMessage"](t)});this[d(601)](c[d(542)],h);let m=c[d(584)](De,c[d(330)],{reason:this[d(1321)+d(431)+d(425)](t)});this[d(601)](d(1131),m)})}[n(843)+n(989)](){let t=n;this._socket[t(1147)](r=>{let c=t,d={wInPN:function(h,m){return h==m},VigxU:c(1231),GhnKV:c(906)+c(356)+c(703)};if(e[c(1703)]("HtEUX",e[c(1491)]))return d[c(1450)](d[c(343)],typeof _0x473ac3)?d.GhnKV:"";this[c(601)](e[c(428)],e[c(627)](as,"open",{...r,data:r.errMsg||""}))}),this[t(742)].onClose(r=>{let c=t;this[c(601)](e[c(1435)],De(c(1131),{...r}))}),this[t(742)].onMessage(r=>{let c=t;this[c(601)](e[c(1429)],os(e[c(1429)],{...r}))}),this._socket[t(565)](r=>{let c=t;this.emit(e[c(960)],e[c(1118)](Ae,e[c(960)],{...r,message:r[c(401)]||""}))})}[n(1545)](t){let r=n,c={gGNuo:"error"};if(t instanceof Uint8Array){let d=t.buffer[r(799)](t[r(844)+"et"],t.byteLength+t[r(844)+"et"]);this._socket&&this[r(742)][r(1545)]({data:d,fail:h=>{let m=r;this.emit(e[m(960)],e[m(1338)](Ae,e[m(960)],{message:this["_formatE"+m(431)+"age"](h)}))}})}else this[r(742)]&&this[r(742)][r(1545)]({data:t,fail:d=>{let h=r;this[h(601)]("error",Ae(c[h(1189)],{message:this[h(1321)+h(431)+h(425)](d)}))}})}close(t,r){let c=n;this[c(742)]&&this._socket[c(1131)]({code:t,reason:r})}["addEvent"+n(1261)](t,r){this.on(t,r)}[n(548)+n(408)+n(1160)](t,r){let c=n;if(e.yHUBt(e.VCZGA,e[c(1034)]))this[c(559)](t,r);else{let d=this[c(1060)].getItem(this[c(1059)]),h=_0x45ac80[c(1407)](e[c(919)](d,"{}"));return h[_0xf356b6]=void 0,this._qosDB[c(1289)](this._prefix,_0x2e522f[c(1578)+"y"](h))}}get[n(1667)+"te"](){let t=n;return this[t(742)][t(1667)+"te"]}get binaryType(){let t=n;if(e[t(1613)]===t(874))return this._socket.binaryType;this[t(782)+t(722)+"Id"]=null,this[t(782)+"l"]=36e5,this._qosDB=e[t(398)](_0xde16ec,e[t(1639)],e[t(1706)])}set[n(632)+"pe"](t){}get[n(604)](){let t=n;return this._socket[t(604)]}get[n(910)](){let t=n;if(e[t(651)](e[t(1332)],e[t(1332)])){let r=(t(1270)+"0").split("|"),c=0;for(;;){switch(r[c++]){case"0":this[t(758)]["removeEv"+t(408)+"ner"](e[t(960)],this._onError);continue;case"1":this[t(758)]["removeEv"+t(408)+t(1160)](e[t(1435)],this._onClose);continue;case"2":if(!this[t(758)])return;continue;case"3":this[t(758)][t(548)+t(408)+t(1160)](t(1509),this[t(1612)+"ge"]);continue;case"4":this[t(758)][t(548)+"entListener"](e[t(428)],this[t(1738)]);continue}break}}else return this[t(742)][t(910)]}get[n(1521)+"ns"](){return this[n(742)].extensions}get[n(1243)+n(970)](){return 0}}function Vc(i,t){let r=n;if(t)return new t(i[r(604)],i.protocol);if(e[r(948)](Wt,ft))return new Jc(i[r(604)],i[r(910)],i[r(391)]);if(e.zpIJK(Et,$t)&&r(498)+"d"!=typeof WebSocket&&WebSocket)return new WebSocket(i[r(604)],i[r(910)+"s"])}function Yc(i){let t=n,r=e[t(1299)][t(961)]("|"),c=0;for(;;){switch(r[c++]){case"0":if(ft&&tt[t(496)+"ocket"])return!0;continue;case"1":return!1;case"2":if(Wt&&wx.connectSocket)return!0;continue;case"3":if((Et||$t)&&e[t(955)]("undefined",typeof WebSocket)&&WebSocket)return!0;continue;case"4":if(i)return!0;continue}break}}function xs(i,t,r){let c=n,d=-1;async function h(m){let l=B;return e[l(1679)](m,d)?Promise[l(719)](new Error(e[l(1636)])):(d=m,e.QykLq(m,r[l(680)])?Promise[l(645)]():r[m].bind(i)(t,h.bind(null,m+1)))}e[c(1486)](h,0)}function ds(i){let t=n,r=0,c=0;for(let d=0;e[t(1446)](d,i[t(680)]);++d)c=i[t(1138)+"At"](d),e[t(1390)](c,128)?r+=1:e[t(374)](c,2048)?r+=2:e.nPBXd(e[t(1015)](64512,c),55296)&&e[t(1710)](64512&i[t(1138)+"At"](e[t(821)](d,1)),56320)?(++d,r+=4):r+=3;return r}function us(i,t,r){let c=n;if(e[c(757)](r-t,1))return"";let d="";for(let h=t;e.DgdoJ(h,r);){let m=i[h++];if(e.SJLcB(m,127))d+=String[c(1631)+c(299)](m);else if(e[c(1271)](m,192)&&e[c(453)](m,224))d+=String[c(1631)+"Code"](e[c(1129)](e[c(1381)](31&m,6),e[c(1152)](63,i[h++])));else if(e[c(1469)](m,224)&&e[c(455)](m,240))d+=String[c(1631)+c(299)](e[c(842)](e.TZNaX(e.LxoeE(15,m),12),e[c(457)](e[c(1547)](63,i[h++]),6))|e[c(1241)](63,i[h++]));else if(e[c(1001)](m,240)){let l=e[c(1166)](e.MhDSl(e[c(420)](e.aZdzr(7,m),18)|e.MgYGp(e[c(990)](63,i[h++]),12)|e[c(304)](e[c(1597)](63,i[h++]),6),e[c(575)](63,i[h++])),65536);d+=String[c(1631)+c(299)](e[c(833)](55296,l>>10)),d+=String[c(1631)+c(299)](e.ZsRAy(56320,1023&l))}}return d}function zr(i,t,r){let c=n,d=r,h,m;for(let l=0;l<i.length;++l)if(e[c(1594)](e.AqPoJ,"OVUhs"))if(h=i[c(1138)+"At"](l),h<128)t[r++]=h;else if(h<2048)t[r++]=e.FpbJj(e[c(619)](h,6),192),t[r++]=e.CgUIX(63&h,128);else if(e.nPBXd(e[c(300)](64512,h),55296)&&e[c(594)](64512,m=i[c(1138)+"At"](e[c(410)](l,1)))===56320)h=e[c(1789)](e.sRhvt(65536,e[c(1381)](e.HiGxP(1023,h),10)),e[c(388)](1023,m)),++l,t[r++]=e[c(1252)](e[c(1577)](h,18),240),t[r++]=e[c(1747)](h>>12,63)|128,t[r++]=e.RRDzF(e[c(1447)](h,6),63)|128,t[r++]=e.nyarH(e[c(309)](63,h),128);else if(e.nSfBj===e[c(1405)]){let v={yReNO:function(y,b,A){return e[c(1267)](y,b,A)},RDhnS:e[c(960)],Horul:e[c(1435)]};_0x45cda7.resolve().then(()=>{let y=c,b=v[y(1173)](_0x493d2b,v[y(745)],{message:this[y(1321)+y(431)+y(425)](_0x440bb4)});this.emit(v[y(745)],b);let A=v[y(1173)](_0x5c043b,v[y(1549)],{reason:this[y(1321)+"rrorMessage"](_0xa74ead)});this[y(601)](v[y(1549)],A)})}else t[r++]=e[c(870)](e.pjOGO(h,12),224),t[r++]=e[c(491)](e[c(640)](e[c(1577)](h,6),63),128),t[r++]=e.WgLwx(e[c(1533)](63,h),128);else _0xdbd55a.set(_0x464381,_0x43adcc);return r-d}async function fs(i){let t=n;if(e[t(1080)](t(1231),typeof i))if(e.pyBTK(e[t(982)],e[t(784)])){let r=new Uint8Array(e.YBVDX(ds,i));return e[t(857)](zr,i,r,0),r}else this[t(758)]&&this._ws.send(_0x2ce9a9),this._debug(e[t(1778)],_0x48446a);return e[t(688)](i,ArrayBuffer)?new Uint8Array(i):new Uint8Array(i.buffer,i[t(844)+"et"],i[t(518)+"th"])}function Xc(i){let t=n;try{return e.lhBtm(e[t(1788)],typeof i)&&(e.SFGBW(i,ArrayBuffer)||i.buffer&&e[t(1348)](i.buffer,ArrayBuffer))||e.lhBtm(e[t(1788)],typeof i)?"":(JSON[t(1407)](i),e[t(1680)])}catch{return e[t(1080)](e.CaUSZ,typeof i)?e[t(866)]:""}}let Qc=(i,t)=>{let r=n;switch(i){case e[r(1113)]:case e[r(755)]:return{[r(1739)+i]:1,"x-tt-env":t};default:return{}}};class Zc{constructor(t){let r=n;this[r(801)+r(1206)]=t,this[r(294)]=0}addCount(){let t=n;e[t(641)]!==e.cfBZy?this[t(294)]++:(this[t(1401)+t(869)+t(1122)]=_0x55c431,_0x374a9e?this[t(385)+t(647)]():this[t(385)+t(937)]())}["checkRea"+n(560)+"nt"](){return this[n(294)]>=this.maxLossCount}[n(898)+n(1226)](t=0){let r=n;this[r(801)+r(1206)]=t,this[r(294)]=0}}async function e0(i){return new Promise(t=>{let r=B;if(!Et)return t(e[r(364)]);try{let c=document[r(500)+"ement"](r(617));window[r(1221)+r(701)]=d=>{let h=r;document[h(849)][h(1750)+"ild"](c),window[h(1221)+"JSONP"]=void 0,t(d&&d[h(889)]||h(1720)+"reason")},c[r(756)]=e[r(1207)],c.src=e[r(1389)](i[r(763)](/^ws/,r(1772)),r(1588)+"ack=fron"+r(847)+"P");try{document[r(849)][r(811)+r(1457)](c)}catch{document[r(849)].removeChild(c)}}catch{window[r(1221)+r(701)]=void 0,e.IeqZx(t,e[r(364)])}})}function nt(i,t,r){let c=n,d={PXFWG:function(h,m){return e[B(453)](h,m)}};if(e[c(1253)]===e[c(1069)]){let h=0,m={};for(let l=0;d[c(553)](l,_0xfac77c[c(680)]);l++)m[_0x17778a[l][c(1742)+c(904)]]=_0x197f5a(_0x5b7932[l][c(1742)+c(904)]),h+=14+m[_0x270d7a[l][c(1742)+c(904)]];return[h,m]}else return!!i?.[c(689)](h=>h.key===t&&h[c(414)]===r)}function At(i,t){let r=n;return i?.[r(689)](c=>c[r(1791)]===t)?.[r(414)]}let Fr=null;async function t0(){let i=n;if(e[i(1199)](e[i(1781)],e[i(914)]))return Fr||(Fr=Promise[i(645)]()[i(1123)](Ue[i(841)](Ue,e[i(507)]))),Fr;_0x58a69d.set(_0x4d0f17,_0x3440a4),_0xec1518[i(406)](_0x1f95e0,_0x23292e)}class n0 extends Br{constructor(t,r){let c=n;super(),this[c(1151)]=t,this[c(578)]=r,this[c(1060)]=void 0,this["_initPro"+c(1296)]=null}async[n(798)](){await this._init()}async[n(1177)](){let t=n;if(e[t(1099)](e[t(638)],e[t(583)])){if(this._qosDB)return;if(this[t(597)+"mise"])return this[t(597)+t(1296)];try{let r=this[t(1151)],c=this._keyPath;this["_initPro"+t(1296)]=(async()=>{let d=t,{openDB:h}=await e[d(1455)](t0);this[d(1060)]=await h(d(1221)+"_"+r,1,{upgrade(m){let l=d;m[l(1030)+l(1325)+"e"](r,{keyPath:c})}})})(),await this[t(597)+t(1296)]}catch(r){console[t(1e3)](r)}finally{this[t(597)+"mise"]=null}}else return _0x18577c?this[t(1511)+"E"]():this.toBytesBE()}async get(t){let r=n;try{if(e.XsUtH===e.XsUtH)return await this[r(1177)](),this[r(1060)]?.[r(571)](this[r(1151)],t);{let c=this[r(1060)].getItem(this._prefix),d=_0xb1595d[r(1407)](e[r(778)](c,"{}"));return _0x5b8771[r(707)](d)}}catch(c){console[r(1e3)](c)}}async[n(406)](t,r){let c=n;return await this._init(),this[c(1060)]?.[c(1367)](this[c(1151)],t)}async[n(1292)](t){let r=n;try{if(e[r(354)](e[r(1119)],e.uhiBx))_0x57b3e3=e[r(731)](_0x18f270,_0x4b349b),_0x20c257=e[r(1087)](127,_0x4184ec),e[r(934)](128,_0x4e85c2)&&(_0xf7d3e1=e[r(616)](_0x5623cb,_0x6cd19e),_0x293ab1|=e[r(383)](e[r(733)](127,_0x3ada63),7));else return await this._init(),this._qosDB?.delete(this[r(1151)],t)}catch(c){e[r(1579)](e.JRwHZ,r(740))?console[r(1e3)](c):this[r(643)+"ndpointT"+r(717)+"t"]=0}}async[n(1666)](){let t=n;try{return await this[t(1177)](),this[t(1060)]?.[t(1666)](this[t(1151)])}catch(r){console[t(1e3)](r)}}async keys(){let t=n;return await this[t(1177)](),this._qosDB?.[t(574)+"ys"](this[t(1151)])}async[n(1333)](){let t=n;return await this[t(1177)](),this[t(1060)]?.[t(1333)](this[t(1151)])}async closeDB(){let t=n;if(e.cRYHn(e[t(783)],e.HlYoW))e[t(1016)](_0x24480d,_0x49421d,66),e[t(744)](_0x57e303,_0x11a53c,_0x550468.length),e[t(804)](_0x3aa4ab,_0x419d96,_0x544684);else try{this[t(1060)]?.[t(1131)](),this[t(1060)]=void 0}catch(r){console[t(1e3)](r)}}get isReady(){let t=n;try{if(e[t(654)](e.rQdLX,"ankOW"))return!!this._qosDB;if(e[t(754)](_0x5b735b,_0x2abde8))return _0x14dd72?_0x20c958:_0x267c00;if(_0x300588){if(e[t(418)](_0x22f046,_0x5a40e9))return _0x3f5e46}else{if(e[t(1133)](_0x4ffa74,-_0x4073))return _0x4f3faf;if(e.xeUDO(_0x4a8190,1)>=_0x37956a)return _0x1aa688}return _0x90ab7f[t(884)](e[t(697)](_0x5a1c7c,_0x5ce22e)|0,e[t(1541)](e.wyZTk(_0x34cc95,_0xdcdf06),0),_0x4fe5d8)}catch(r){return console[t(1e3)](r),!1}}}class r0{constructor(t,r){let c=n;this[c(964)]=t,this[c(610)]=r,this._qosDB=localStorage}async[n(798)](){}get[n(1059)](){return"frontier_"+this[n(964)]}async get(t){let r=n;if(e[r(660)](e.ifKty,e[r(339)]))this._isInit=!0,this._connect();else{let c=this[r(1060)][r(441)](this[r(1059)]);return JSON.parse(c||"{}")[t]}}async[n(406)](t,r){let c=n,d=this[c(1060)].getItem(this[c(1059)]),h=JSON[c(1407)](d||"{}");return h[r||t[this[c(610)]]]=t,this[c(1060)][c(1289)](this[c(1059)],JSON[c(1578)+"y"](h)),r||t[this._pathKey]}async[n(1292)](t){let r=n,c=this._qosDB[r(441)](this[r(1059)]),d=JSON.parse(c||"{}");return d[t]=void 0,this._qosDB[r(1289)](this[r(1059)],JSON.stringify(d))}async[n(1666)](){let t=n;return this._qosDB[t(1666)]()}async[n(707)](){let t=n,r=this[t(1060)][t(441)](this[t(1059)]),c=JSON[t(1407)](e.pDiIj(r,"{}"));return Object[t(707)](c)}async[n(1333)](){let t=n,r=this[t(1060)][t(441)](this._prefix),c=JSON.parse(e[t(1345)](r,"{}"));return Object[t(433)](c)}[n(927)](){return Promise[n(645)]()}get[n(1630)](){let t=n;if(e.NZUyN(e[t(1036)],e.dwdfS))e.dWCmh(_0x4e3a44,2048)?_0x519f7e[_0x1f194a++]=e[t(1098)](e[t(492)](e[t(835)](_0x1d3c14,6),31),192):(e[t(1634)](_0x2fd4f2,65536)?_0x34b626[_0x3bfb23++]=e.dEtWc(e[t(1458)](_0x265360,12)&15,224):(_0x44a7be[_0x37fa61++]=e[t(842)](e[t(360)](e[t(1622)](_0x4c4760,18),7),240),_0x2b9675[_0x63a446++]=e.RsyKg(e.dLJYU(_0xc3d06>>12,63),128)),_0x279f07[_0x3ca8f6++]=e.dbJEq(e.oyydH(_0x31eac6>>6,63),128)),_0x2fe3fa[_0x421d3d++]=e[t(1098)](e[t(1236)](63,_0xa5673f),128);else return!!this[t(1060)]}}class i0{constructor(t,r){let c=n;this[c(964)]=t,this[c(610)]=r,this._qosDB=ft?tt:Wt?wx:null}async[n(798)](){}get[n(1059)](){let t=n;return t(1221)+"_"+this[t(964)]}async[n(571)](t){let r=n,c=this._qosDB["getStora"+r(829)](this[r(1059)]);return JSON[r(1407)](c||"{}")[t]}async set(t,r){let c=n,d=this[c(1060)][c(1212)+c(829)](this._prefix),h=JSON[c(1407)](e.xAJvP(d,"{}"));return h[r||t[this[c(610)]]]=t,this._qosDB[c(524)+"geSync"](this._prefix,JSON[c(1578)+"y"](h)),r||t[this[c(610)]]}async[n(1292)](t){let r=n,c=this._qosDB[r(1212)+r(829)](this[r(1059)]),d=JSON[r(1407)](c||"{}");return d[t]=void 0,this._qosDB[r(524)+r(829)](this[r(1059)],JSON.stringify(d))}async[n(1666)](){let t=n,r={UamYK:function(c,d){return e[B(347)](c,d)},lAoOK:function(c,d){return e[B(1389)](c,d)}};if(e.hwtaz(e.JzhLn,e.JzhLn))return this[t(1060)].clearStorageSync();_0x1a2553[_0x5cf3d8[_0x44ba97][t(1742)+"ame"]]=r[t(912)](_0x11427d,_0x589af6[_0x27de8c][t(1742)+t(904)]),_0x1239a9+=r[t(1306)](14,_0x159369[_0x319b8b[_0x1d5944].cursor_name])}async[n(707)](){let t=n,r=this._qosDB["getStora"+t(403)+"nc"](this[t(1059)]),c=JSON[t(1407)](r||"{}");return Object[t(707)](c)}async getAll(){let t=n,r=this[t(1060)][t(1212)+"geInfoSync"](this[t(1059)]),c=JSON.parse(e[t(893)](r,"{}"));return Object[t(433)](c)}closeDB(){return Promise[n(645)]()}get[n(1630)](){return!!this[n(1060)]}}function ls(i,t){let r=n;if(e[r(893)](ft,ft))return new i0(i,t);if(e.MYqul(Et,$t)&&e[r(1039)](e.kxnJn,typeof indexedDB))return new n0(i,t);if(e[r(412)](Et,$t)&&e.kxnJn!=typeof localStorage)return new r0(i,t);throw new Error(e[r(1255)])}class s0{constructor(){let t=n;this[t(782)+t(722)+"Id"]=null,this[t(782)+"l"]=36e5,this[t(1060)]=e.umnfM(ls,e.PDGuP,e[t(1706)])}async[n(782)+"lFlush"](){let t=n;e[t(329)](clearInterval,this["_interva"+t(722)+"Id"]),this[t(782)+t(722)+"Id"]=e.CgRPD(setInterval,()=>{this["flushExp"+t(656)]()},this[t(782)+"l"])}async[n(798)](){let t=n;await this[t(1060)][t(798)]()[t(1123)](()=>{let r=t,c={WkYNN:function(d,h){return e[B(1001)](d,h)},LNGgx:function(d,h,m){return e.YhfTj(d,h,m)},FhnYr:function(d,h){return d|h}};if(e[r(967)](e.NAydj,e[r(775)])){for(_0x17940e>>>=0;Oseque[r(1537)](_0x899634,128);)Oseque[r(1740)](_0x134e88,_0x58af75,Oseque.FhnYr(127&_0x43176e,128)),_0x18faf9>>>=7;Oseque[r(1740)](_0x47fe95,_0x117527,_0x2df91)}else this["_interva"+r(837)]()})}async["flushExp"+n(656)](){let t=n,r={DUoUO:e[t(1689)],PUJqH:e[t(1374)],NWNyY:function(c,d){return c(d)},tQSLg:function(c,d){return e[t(392)](c,d)},ModkM:function(c,d,h){return e.kIeUh(c,d,h)},MKxHO:function(c){return e.XTdRz(c)}};e[t(1314)](e[t(600)],"mdlmN")?(this[t(758)]&&this._ws[t(1545)](_0xede6),this[t(1121)](r[t(1715)],_0x588320)):(await this[t(1060)]?.[t(1333)]()||[])[t(1288)](({timestamp:h})=>h<Date[t(702)]())[t(1542)](h=>{let m=t;if(e[m(1731)](e[m(1112)],e.sviab))return typeof _0x2ab0a6===FQmYed.PUJqH?FQmYed.NWNyY(_0xab8261,_0x555593):(_0x243b01 instanceof _0x42c735&&FQmYed[m(1244)](_0x2da4b1,_0x50f508),FQmYed[m(1784)](_0x24cab9,_0x4ff96f,FQmYed[m(450)](_0x20f553))?new _0xce9b91(_0x3931ea,_0x59d08f):_0x4e4645);this[m(1060)]?.[m(1292)](h[m(1714)+"id"])})}async[n(1292)](t){let r=n;return this[r(1060)]?.[r(1292)](t)}async[n(406)](t,r){return this[n(1060)]?.set({message_id:t,timestamp:r})}async[n(571)](t){let r=n;return this[r(1060)]?.[r(571)](t)}async[n(927)](){let t=n;e.HLMZw(clearInterval,this[t(782)+t(722)+"Id"]),await this[t(1060)]?.[t(927)]()}get[n(1630)](){let t=n;if(e[t(1376)](e[t(1554)],e.WHvCK))return this[t(1060)]?.[t(1630)];this[t(597)+"mise"]=null}}function Ur(i){let t=n;if(e.UgbBA(e[t(1347)],e[t(1583)])){let r=!!this[t(1209)][t(1105)+"S"];if(!r)return{enabled:r,isQoSMessage:!1,isQoSAck:!1,isAckCleanupMessage:!1,ackMsgIds:[]};let c=e[t(857)](nt,i[t(1509)][t(391)],e[t(1726)],"2"),d=c&&e[t(1699)](nt,i[t(1509)][t(391)],e.oybkn,"1"),h=c&&e.XMbSZ(nt,i[t(1509)].headers,e[t(1448)],"1"),m=h?e[t(371)](At,i[t(1509)][t(391)],e.dxBDq)?.[t(961)](",").filter(Boolean)||[]:[];return{enabled:r,isQoSMessage:c,isQoSAck:d,isAckCleanupMessage:h,ackMsgIds:m}}else this[t(1752)+t(770)]=_0x5c3709}async function gs(){let i=n;return this[i(485)+"ger"]||(this[i(485)+i(834)]=new s0),this[i(485)+i(834)][i(1630)]||await this[i(485)+"ger"][i(798)](),this[i(485)+i(834)]}async function o0(i,t){let r=n;if(e[r(1594)](e[r(1185)],e.UxPQD)){let c=this[r(972)],d=this[r(389)];return[255&d,e.MyVbL(e[r(1767)](d,8),255),e[r(1396)](e.QnfYN(d,16),255),e[r(1464)](d,24),255&c,e[r(1152)](c>>>8,255),c>>>16&255,c>>>24]}else{let{enableAutoAck:c}=this[r(1209)],d=nt(i.message[r(391)],e[r(1046)],"1"),h=e.NPXIt(nt,i.message.headers,e[r(1648)],"1"),m=Ur[r(608)](this,i);if(c&&d)if(e[r(1508)]("lATFa",e[r(878)])){let{SeqID:l,LogID:v,service:y,LogIDNew:b,method:A}=i.message;this[r(1111)]({SeqID:l,LogID:v,LogIDNew:b,service:y,method:A,headers:[{key:e[r(1648)],value:"1"},{key:e.gtZDw,value:b||""},{key:r(1295),value:"0"}]})}else return e[r(418)](this[r(294)],this[r(801)+r(1206)]);h&&!m[r(556)]&&this[r(1633)+r(1722)+r(902)](i),e[r(1532)](t)}}async function a0(i,t){let r=n;this[r(1121)](e[r(318)],i[r(1509)]),e[r(1651)](t)}async function c0(i,t){let r=n,c=e[r(1727)](yt,await e[r(731)](fs,i[r(1084)]));try{if(e[r(987)](c[r(1779)],Uint8Array)){let d=this._options[r(732)+r(890)]instanceof Object?{force:!!this[r(1209)][r(732)+r(890)][r(1790)],encoding:this[r(1209)][r(732)+r(890)][r(780)]?this._options[r(732)+r(890)][r(780)].replace(/\s/g,"")[r(611)+r(943)]():""}:{force:!1,encoding:this[r(1209)][r(732)+r(890)]?this[r(1209)][r(732)+"ncoding"][r(763)](/\s/g,"").toLowerCase():""},h=c.payloadEncoding?c[r(732)+"ncoding"].replace(/\s/g,"")[r(611)+r(943)]():"",m=e.PfkEa(this[r(1209)][r(1417)+r(1334)],Object)?{force:!!this[r(1209)][r(1417)+r(1334)][r(1790)],type:this[r(1209)][r(1417)+r(1334)][r(756)]?this[r(1209)][r(1417)+"ype"].type.replace(/\s/g,"")[r(611)+r(943)]():""}:{force:!1,type:this[r(1209)][r(1417)+"ype"]?this[r(1209)][r(1417)+r(1334)][r(763)](/\s/g,"")[r(611)+r(943)]():""},l=c[r(1417)+"ype"]?c[r(1417)+r(1334)][r(763)](/\s/g,"")[r(611)+r(943)]():"",v=m[r(1790)]?m[r(756)]:l||m[r(756)],y=d[r(1790)]?d[r(780)]:h||d.encoding,b=[e[r(866)],r(743)+r(1281),e[r(405)],e.CaUSZ],A=[e[r(686)],e[r(940)]];this[r(1209)]["enableTr"+r(1677)+r(1461)+"ad"]&&b.includes(v)&&(!y||A[r(1465)](y))?c["textPayl"+r(996)]=e[r(1144)](us,c[r(1779)],0,c[r(1779)].byteLength):c[r(1517)+r(996)]=""}else c[r(1517)+"oad"]=""}catch(d){c[r(1517)+r(996)]="",console[r(1e3)](d)}i.message=c,t()}function x0(i,t,r){let c=n,d={mqlgM:function(y,b){return e.cPpDu(y,b)},BGZcb:function(y,b){return e[B(452)](y,b)},FAWBE:function(y,b){return y(b)},oNURh:function(y,b){return y&b},KWKxL:function(y,b){return e[B(529)](y,b)},adaKr:function(y,b){return e.xHmtf(y,b)}},h=e[c(880)](r,8192),m=h>>>1,l=null,v=h;return function(y){let b=c;if(y<1||d[b(915)](y,m))return d[b(1419)](i,y);v+y>h&&(l=d[b(1431)](i,h),v=0);let A=t[b(608)](l,v,v+=y);return d[b(628)](7,v)&&(v=d[b(621)](d[b(1608)](7,v),1)),A}}let d0=4294967295;function u0(i,t,r){let c=n;return e[c(1315)](RangeError,e[c(1646)](e.bkOPP(e[c(1436)](e.uxmKs(e.ukglZ+i,e[c(359)]),t||1),e[c(334)]),r))}function f0(i,t,r){let c=n;if(r>d0)throw new Error(e[c(1356)]);let d=3;for(;e[c(338)](d,0);){let h=e.Hnrzg(255,r);e.XMbSZ(Hr,h,i,e[c(1493)](t,d)),r>>>=8,d--}return e[c(1229)](t,4)}function l0(i,t){let r=n,c=0,d=t,h=e[r(1081)](t,4);for(;e[r(344)](d,h);){let{value:m,offset:l}=e[r(923)](qr,i,d);d=l,c=e[r(1397)](e[r(369)](c,8),0),c+=m}return{value:c,offset:h}}function g0(i,t,r){let c=n,d=e[c(1445)].split("|"),h=0;for(;;){switch(d[h++]){case"0":if(e[c(698)](i[c(680)],40))return e[c(1178)](e[c(1144)](zr,i,t,r),r);continue;case"1":if(!i)return r;continue;case"2":if(t[c(1174)])return e[c(1596)](t.write(i,r),r);continue;case"3":if(t.utf8Write)return t[c(669)+"e"](i,r)+r;continue;case"4":return e[c(508)](e[c(1144)](zr,i,t,r),r)}break}}function h0(i,t){let r=n,c=new j(e[r(1186)](e[r(1148)](e[r(620)](i[e.fSFsK(t,4)],24),e[r(1381)](i[e[r(421)](t,5)],16))|e[r(862)](i[e[r(372)](t,6)],8),i[e[r(1657)](t,7)]),e[r(1287)](e[r(1593)](e[r(538)](i[e.lCSfE(t,0)],24),e[r(1632)](i[e[r(1493)](t,1)],16))|i[e[r(1411)](t,2)]<<8,i[e.Vorsg(t,3)]),!0);return t+=8,{value:c,offset:e[r(1561)](t,8)}}function p0(i,t,r){let c=n;if(e.PKtBI===c(885))return DTZqle[c(1727)](_0x524ee4,_0x5deca9[c(400)](_0x2a0cc7(this),_0x4de569));{let d=i[c(389)],h=i[c(972)];return t[r]=e[c(1464)](h,24),t[e.Tonfq(r,1)]=e.FrjZQ(e.GQjDW(h,16),255),t[e.dBCBc(r,2)]=e[c(541)](e[c(1072)](h,8),255),t[e[c(1436)](r,3)]=e[c(1141)](255,h),t[e[c(314)](r,4)]=d>>>24,t[e[c(582)](r,5)]=e[c(512)](d>>>16,255),t[e[c(358)](r,6)]=e[c(712)](d,8)&255,t[e[c(1490)](r,7)]=e[c(640)](255,d),r+=8,r}}function qr(i,t){let r=n;return i[r(1766)+"8"]?{value:i[r(1766)+"8"](t),offset:e[r(320)](t,1)}:{value:e[r(1366)](255,i[t]),offset:e.tDqNl(t,1)}}function Hr(i,t,r){let c=n;return t[c(1035)+"t8"]?t[c(1035)+"t8"](i,r):t[r]=e[c(663)](255,i),e.AiECl(r,1)}let m0=function(i){return new Uint8Array(i)},w0=e[n(969)](e[n(481)],typeof Buffer)?Buffer["allocUns"+n(789)]:x0(m0,Uint8Array[n(648)+"e"][n(1668)]),_0=16,Gr=32;function y0(i){let t=n,r=0,c={};for(let d=0;e[t(573)](d,i[t(680)]);d++)c[i[d][t(1742)+t(904)]]=ds(i[d][t(1742)+t(904)]),r+=e[t(762)](14,c[i[d][t(1742)+"ame"]]);return[r,c]}function hs(i,t,r){let c=n,d={YhsWS:e[c(1153)],BWbyt:function(y,b,A,R){return y(b,A,R)},UTDRz:e[c(1709)],qGUId:c(1158),cndkQ:e.TmmdH,vCSIb:function(y,b,A,R){return e[c(704)](y,b,A,R)},ZEKWq:function(y,b,A,R){return e[c(704)](y,b,A,R)},DbLgF:c(1716)+c(1629)},[h,m]=y0(i),l=w0(h),v=0;return i.forEach(y=>{let b=c,A=d[b(1556)][b(961)]("|"),R=0;for(;;){switch(A[R++]){case"0":v=d[b(781)](p0,j[b(1776)+"er"](y[b(555)]||t),l,v);continue;case"1":console.log(b(1194),v);continue;case"2":console[b(1e3)](d[b(827)],v);continue;case"3":console[b(1e3)](d[b(1785)],v);continue;case"4":v=g0(y[b(1742)+b(904)],l,v);continue;case"5":v=d[b(781)](Hr,0,l,v);continue;case"6":console.log(d.cndkQ,v);continue;case"7":v=d[b(1217)](Hr,m[y[b(1742)+b(904)]],l,v);continue;case"8":v=d[b(1246)](f0,l,v,y.service||0);continue;case"9":console[b(1e3)](d.DbLgF,y,y[b(1158)]);continue;case"10":console[b(1e3)](b(691),v);continue}break}}),{frameType:Gr,headers:[{key:e.xRRKy,value:r}],payload:l}}function b0(i){let t=n,r=0,c=[];for(;e[t(698)](r,i[t(518)+"th"]);){let{offset:d}=e.TcunG(qr,i,r);r=d;let h={cursor_name:"",cursor:0,service:0},{value:m,offset:l}=l0(i,r);h[t(1158)]=m,r=l;let{value:v,offset:y}=e.dxuzy(qr,i,r);r=y,h[t(1742)+"ame"]=e[t(1092)](us,i,r,e[t(679)](r,v)),r+=v;let{value:b,offset:A}=e.zbHPZ(h0,i,r);h[t(555)]=b[t(684)](),r=A,c[t(1734)](h)}return c}function v0(){let i=n;return{frameType:Gr,headers:[{key:e.xRRKy,value:i(1647)+"_EXIST"}],payload:void 0}}class S0{constructor(t,r,c){let d=n;e[d(1472)](e[d(1043)],e[d(1043)])?(DTZqle[d(1728)](_0x5ba95f),_0x2679da()):(this[d(1616)+d(1023)]=t,this[d(1752)+"ileName"]=r,this[d(1761)+"Strategy"]=c,this[d(1060)]=e[d(1394)](ls,this[d(1616)+d(1023)],e[d(881)]))}async openDB(){let t=n;await this[t(1060)][t(798)]()}async[n(591)+"rs"](){let t=n;if(!this[t(1060)][t(1630)])return;let r=this[t(1761)+t(393)],c=await this[t(1060)][t(1333)]();switch(console.log(e.UkSpv,c),r){case t(1378):return c&&c.length?e[t(1144)](hs,c,0,this[t(1752)+t(770)]):void 0;case e[t(1350)]:return;case e[t(439)]:return c&&c[t(680)]?e[t(350)](hs,c,0,this[t(1752)+t(770)]):v0()}}async[n(406)](t,r,c){let d=n;return console.log(e[d(928)],t,r,c),this[d(1060)][d(406)]({cursor_name:t,cursor:r,service:c})}async[n(1428)+"rs"](t){let r=n,c=e.qFDzw(b0,t);for(let d of c)console[r(1e3)]("setcursor",c),await this[r(1060)][r(406)](d)}async[n(571)](t){let r=n;return(await this[r(1060)][r(571)](t))?.cursor}async[n(927)](){let t=n;await this[t(1060)][t(927)]()}[n(1626)+n(944)+n(379)](t){let r=n;if(r(286)===e[r(1116)])this._cursorFileName=t;else{let c=e[r(1721)](e[r(718)](e[r(1343)](e.pxcVJ(e[r(1415)](7,_0x3aa699),18),e.ogYOB(e[r(1396)](63,_0x2363d6[_0x4dbb49++]),12)),e[r(640)](63,_0x566bf8[_0x19161e++])<<6)|e[r(1396)](63,_0x3415af[_0x10d478++]),65536);_0x2733fc+=_0x293e8c["fromChar"+r(299)](e[r(1081)](55296,c>>10)),_0x16a52+=_0x4b4de1["fromChar"+r(299)](e.zpQcw(56320,e[r(1759)](1023,c)))}}get[n(1630)](){let t=n;return e[t(1104)](t(1730),e[t(985)])?this._qosDB[t(1630)]:new _0x44a9e2(_0x20dfe6,{data:_0x271e0d,message:_0x545837})}}let E0=e[n(511)];async function ps(i){let t=n;if(!this[t(1209)][t(1105)+"S"])return null;let{aID:r,fpID:c,messageStrategy:d}=this[t(1209)],h=i||E0;try{return this["_cursorM"+t(828)]?i&&this["_cursorM"+t(828)][t(1626)+"rsorFile"+t(379)](i):this[t(1335)+t(828)]=new S0(c+"_"+r+"_"+h,h,d),this[t(1335)+t(828)].isReady||await this[t(1335)+"anager"][t(798)](),this[t(1335)+t(828)]}catch{return null}}async function A0(i,t){let r=n,c={wyvxb:function(z,L){return e[B(958)](z,L)}},d=nt(i[r(1509)][r(391)],r(1303),"-1"),h=e[r(1144)](nt,i[r(1509)][r(391)],e.iSPAn,"1"),m=At(i[r(1509)][r(391)],e[r(588)]),l=e[r(1425)](Number,At(i[r(1509)].headers,e[r(1638)]))||0,v=Ur[r(608)](this,i),y=e[r(472)](nt,i.message[r(391)],e[r(672)],"2"),b=e[r(371)](At,i.message[r(391)],r(1223)+r(1155)+"e"),A=Number(e[r(1352)](At,i[r(1509)][r(391)],e[r(677)]));if(v[r(556)])return e.KVPhW(t);let R=v[r(1006)+r(653)]?await gs[r(608)](this):null;if(e[r(1337)](i[r(1509)].service,0)&&h&&!d||e[r(1135)](i[r(1509)][r(1158)],0))if(e.EvIhs===r(1658))_0x371a9d.body[r(1750)+r(1457)](_0x352247);else{if(m&&v[r(1006)+r(653)]&&R)return e[r(685)](e[r(1676)],e[r(1676)])?DfmxTp[r(819)](_0x2d605f,_0x283437):(!!!await R[r(571)](m)&&(this[r(1633)+r(488)+r(396)](i),await R[r(406)](m,e.rDdlb(Date[r(702)](),l))),e[r(1455)](t));if(y){let z=await ps.call(this);if(!z)return this[r(1633)+r(488)+r(396)](i),e[r(1635)](t);let L=await z[r(571)](b)??-1;if(e[r(1049)](L,A))e.vkrFQ(e[r(1100)],r(676))?(this["_dispatc"+r(488)+"Event"](i),z.set(b,A,i[r(1509)][r(1158)])):_0x54ee31[r(1e3)](_0x54cfe4);else throw new Error(r(787)+r(1047)+r(1430)+A+(" larger "+r(1357)+"al cursor ")+L);return t()}return this["_dispatchMessage"+r(396)](i),e.KVPhW(t)}}async function C0(i,t){let r=n;if(e[r(1416)](r(423),e[r(1496)]))_0x47cb52[r(1164)+"d"]&&(this[r(1375)+r(1471)]()&&(!this[r(758)]||e[r(1508)](this[r(758)].readyState,this[r(714)])||e[r(1103)](this[r(758)][r(1667)+"te"],this.CONNECTING))&&this[r(385)+r(647)](),this[r(449)+"er"]&&_0x38e07c[r(1572)+"Listener"]("online",this[r(385)+r(647)]),this[r(449)+"er"]&&_0x5c00cb["addEvent"+r(1261)](e.aObuq,this[r(385)+r(937)]));else{let c=Ur[r(608)](this,i);if(!c["isQoSMes"+r(653)])return e.WSnZm(t);let d=await gs[r(608)](this);if(c[r(813)+r(1755)+"age"]&&c.ackMsgIds[r(680)])for(let h of c[r(1553)+"s"])await d[r(1292)](h);e[r(1128)](t)}}async function I0(i,t){let r=n,c=e[r(1376)](i[r(1509)][r(1256)+"e"],_0),d=e.NZUyN(i[r(1509)][r(1256)+"e"],Gr);if(e[r(1078)](!c,!d))return e[r(1635)](t);let h=e[r(280)](At,i.message[r(391)],e[r(692)]);if(!h)return t();let m=await ps[r(608)](this,h);if(!m)return e[r(979)](t);if(c){let l=await m[r(591)+"rs"](),v={frameType:l?.[r(1256)+"e"],SeqID:j[r(1776)+"er"](this[r(562)]++),LogID:j[r(1776)+"er"](this[r(1209)][r(814)+"erator"]()),service:9e3,method:5,headers:l?.headers,payload:l?.[r(1779)]},y=e[r(1320)](E,v);this[r(758)]&&this[r(758)][r(1667)+"te"]&&this[r(758)][r(1545)](y)}if(d){let l=i[r(1509)][r(1779)];l&&m.setCursors(l)}}let P0=async function(i,t){let r=n;this[r(988)]=!1,e[r(1425)](clearTimeout,this["_connect"+r(687)+"utId"]),t()},k0=async function(i,t){let r=n;if(!this[r(758)]||e[r(1684)](this[r(758)][r(1667)+"te"],this[r(714)]))return e[r(1635)](t);let{pingInterval:c}=this[r(1209)];this[r(981)+r(908)]?.[r(1786)+r(1698)+"fig"]();for(let h=0;e[r(1522)](h,this[r(1761)+"Queue"][r(680)]);h++){let m=this[r(1761)+r(1363)][h];if(this[r(758)][r(1667)+"te"]===this[r(714)]&&e.NahTI(null,m))this[r(758)]&&this._ws[r(1545)](m),this[r(1761)+"Queue"][h]=null;else break}this[r(1761)+"Queue"]=this["_message"+r(1363)][r(1288)](h=>!!h),this[r(1260)+r(1661)+"Id"]=e.CgRPD(setTimeout,()=>this[r(615)](),c),this["_dispatc"+r(1169)+"nt"](i),this[r(449)+"er"]&&this[r(758)]&&(this._ws[r(632)+"pe"]=this[r(1002)+r(1334)]);let d=this[r(981)+"tManager"]?.[r(1477)+r(308)+"nt"]();this._debug(r(805)+d+r(290)),e[r(1010)](t)},T0=async function(i,t){let r=n,c=this[r(981)+"tManager"]?.[r(1477)+r(308)+"nt"]();this._debug(r(805)+c),t()};class D0 extends Br{constructor(t){let r=n;super(),this["_miniNav"+r(869)+r(1122)]=!0,this[r(449)+"er"]=Et,this[r(1048)]=$c,this[r(759)+"T"]=ft,this[r(1171)+"X"]=Wt,this._isWorker=$t,this._messageQueue=[],this["_endpoin"+r(908)]=null,this["_readyCl"+r(554)]=!1,this[r(1002)+r(1334)]=e[r(946)],this[r(1525)+r(569)]=!1,this["_connect"+r(687)+r(1438)]=null,this[r(1653)+r(1086)+r(1259)]=null,this[r(1260)+r(1661)+"Id"]=null,this[r(562)]=0,this._isInit=!1,this[r(1642)]="",this["_QoSMana"+r(834)]=null,this[r(1335)+r(828)]=null,this[r(1606)+r(1444)]=null,this._protocols=e[r(1107)],this.CLOSED=3,this[r(1139)+"NG"]=0,this[r(714)]=1,this.CLOSING=2,this[r(1738)]=m=>{let l=r,v={leDYz:function(y,b){return e[B(461)](y,b)}};try{if(e.yrssJ(e.ykBcJ,e[l(515)]))e.HfwcP(xs,this,m,[P0,k0,T0]);else return ancTZv[l(1685)](_0x12822a,_0x56bbf5)}catch(y){let b=Ae(l(1013),{message:y[l(1509)],code:et[l(483)+"OR"],error:y});this[l(1633)+l(1643)+l(1424)](b)}},this[r(1612)+"ge"]=async m=>{let l=r,v={rjrxG:e[l(364)]},{pingInterval:y,pingFrequency:b}=this[l(1209)];if((m.data==="hi"&&e[l(625)](e[l(1192)],b)||e[l(1655)](e.UVRAy,b))&&(this["_clearPi"+l(1007)](),this[l(601)](e.BHleW,l(1154)),this[l(1260)+l(1661)+"Id"]=setTimeout(this[l(615)][l(841)](this),y)),!e[l(1507)]("hi",m[l(1084)]))try{e[l(747)](e.OyZIc,e[l(836)])?(_0x14ee67.body[l(1750)+l(1457)](_0x5ed172),_0xeb9fe5[l(1221)+"JSONP"]=void 0,_0x11c8a6(_0x1155db&&_0x29ac0b[l(889)]||wqJaEN[l(528)])):e[l(1589)](xs,this,m,[c0,o0,C0,I0,A0,a0])}catch(A){let R=e.pHrOT(Ae,l(1013),{message:A[l(1509)],code:et["MESSAGE_"+l(1408)],error:A});this[l(1633)+l(1643)+l(1424)](R)}},this[r(1088)]=m=>{let l=r,v=this["_endpoin"+l(908)]?.[l(845)+"chMaxTries"](),y=this[l(981)+l(908)]?.["getCurre"+l(308)+"nt"]();if(v&&!m[l(1509)]){let b="connect "+y+(l(1242)+l(1120)+"es reached");this[l(1633)+l(1643)+l(1424)](Ae(e[l(960)],{message:b,code:et[l(806)+l(681)+"R"],error:m}));return}this[l(758)]&&e[l(760)](this[l(758)][l(1667)+"te"],this[l(714)])&&this[l(736)+l(629)](),this[l(1633)+l(1643)+l(1424)](Ae(e[l(960)],{message:m.message,code:et[l(942)+"RROR"],error:m}))},this[r(1143)]=async m=>{let l=r,v={HUXBw:function(y,b){return e[B(1348)](y,b)},qlqxW:function(y,b){return e[B(760)](y,b)},wKipJ:l(284),mKzPa:function(y,b){return y in b},fiixY:function(y,b){return e[l(995)](y,b)},NJjQf:function(y,b){return e.dBCBc(y,b)},Mesfx:function(y,b){return y&b},wEqvY:function(y,b){return e[l(930)](y,b)},cODGl:function(y,b){return e[l(335)](y,b)},JJUoA:function(y,b){return e[l(666)](y,b)},owerg:function(y,b){return e[l(541)](y,b)}};if(e[l(1605)](e[l(812)],e[l(812)])){this[l(776)+l(1021)](),this[l(547)+l(1007)](),this["_removeW"+l(1053)+"rs"](),this[l(758)]=null,this[l(1525)+l(569)]=!1;let y=this["_endpoin"+l(908)]?.[l(845)+"chMaxTries"]();if(!y&&this["_navigat"+l(1471)]()&&!this[l(402)+l(554)]){let b=this[l(981)+l(908)]?.[l(1477)+"ntEndpoint"](),A=this._options[l(693)+"tInterce"+l(696)](m[l(1303)],m[l(746)]);this[l(1633)+l(1688)+l(1424)](e.kIeUh(De,e[l(1435)],{code:1006,reason:m.reason||"connecting failed, unkno"+l(567)+"n, hostn"+l(1694)+b,willReconnect:A})),A&&this[l(1525)]();return}if(e[l(1609)](1e3,m[l(1303)])&&this._readyClosed){this[l(1633)+l(1688)+"ent"](e[l(1065)](De,"close",{code:1e3,reason:e[l(387)]})),this[l(981)+l(908)]?.[l(1786)+l(1698)+l(577)](),this[l(1606)+l(1444)]?.[l(898)+l(1226)]();return}if(m.code!==1e3&&y){let b=this[l(981)+"tManager"]?.["getCurre"+l(308)+"nt"](),A=m[l(746)];A||(A=await e[l(1044)](e0,this[l(1642)])),A="connecti"+l(366)+"d, "+A+(l(1462)+"me: ")+b+(l(1274)+l(710)+l(1669)),this[l(1633)+l(1688)+l(1424)](e.aGQwx(De,"close",{code:m[l(1303)],reason:A}));let R=l(1079)+b+(l(1242)+l(1120)+l(1268)+"ed");this[l(1633)+"hErrorEvent"](e[l(1029)](Ae,e[l(960)],{message:R,code:et[l(806)+l(681)+"R"]})),this[l(981)+"tManager"]?.[l(1786)+"pointCon"+l(577)](),this[l(1606)+l(1444)]?.[l(898)+l(1226)]();return}if(e[l(1637)](1e3,m[l(1303)])&&!m[l(746)])if(e[l(769)](e[l(598)],e[l(1037)])){let b=this["_endpoin"+l(908)]?.[l(1477)+l(308)+"nt"]();this["_dispatc"+l(1688)+l(1424)](e[l(581)](De,e.XzUeF,{code:m[l(1303)],reason:l(1372)+l(366)+"d, unkno"+l(567)+l(287)+l(1694)+b})),this[l(981)+l(908)]?.[l(1786)+"pointCon"+l(577)](),this["_pingLos"+l(1444)]?.resetCounter();return}else return OQXwMC[l(1215)](_0x285057,_0x43cc0b)&&(_0x7e5ded==="done"||OQXwMC[l(720)](_0x5bdd0f,OQXwMC[l(1548)]))?!0:OQXwMC[l(1564)](_0x4ebad4,_0x4bb868);this["_dispatchCloseEv"+l(1424)](m),this[l(981)+l(908)]?.[l(1786)+l(1698)+l(577)](),this._pingLossCounter?.[l(898)+l(1226)]()}else{let y=_0x1ddb6d[l(389)],b=_0x70fb32[l(972)];return _0x5cfad1[_0x4a5de3]=OQXwMC[l(1692)](b,24),_0x124e7b[OQXwMC[l(1354)](_0xcdee79,1)]=OQXwMC.Mesfx(OQXwMC[l(1692)](b,16),255),_0x14dff[_0x23ef4f+2]=OQXwMC.Mesfx(OQXwMC[l(1692)](b,8),255),_0x3cf153[OQXwMC[l(1354)](_0x46dd10,3)]=OQXwMC[l(631)](255,b),_0x1018d8[OQXwMC[l(1354)](_0x4eae37,4)]=OQXwMC.fiixY(y,24),_0x484ea6[OQXwMC[l(1354)](_0x557f49,5)]=OQXwMC[l(1198)](OQXwMC[l(543)](y,16),255),_0x5d7b4a[OQXwMC[l(613)](_0x18d068,6)]=OQXwMC[l(1758)](OQXwMC[l(1692)](y,8),255),_0x4895b1[_0x436086+7]=OQXwMC[l(1198)](255,y),_0x25fb87+=8,_0x4f4f9e}},this[r(1717)]=null,this[r(1560)]=null,this.onmessage=null,this[r(1254)]=null,this.onStartReconnect=null,this[r(1311)+r(973)]=null,this["onStopIm"+r(1156)+r(561)+"ct"]=null,this._handleOnLine=this[r(385)+r(647)][r(841)](this),this[r(385)+r(937)]=this[r(385)+r(937)].bind(this),this[r(445)+r(699)]=this[r(445)+r(699)].bind(this),this[r(445)+"ageShow"]=this["_handleP"+r(340)].bind(this),this[r(1209)]={url:"",automaticOpen:!0,initReconnectInterval:1e3,maxReconnectInterval:1e4,reconnectIntervalGrowFactor:2,timeoutInterval:5e3,maxRetries:5,debug:!1,maxMessageQueueLength:e[r(1546)](1,0),service:0,logIDGenerator:a,headers:void 0,payloadEncoding:"",payloadType:"",fpID:"",deviceID:"",accessKey:"",ttwID:"",bddID:"",aID:"",disableAutoReconnect:!1,customParams:{},pingInterval:15e3,pingTimeoutInterval:4e3,pingFrequency:r(1422),pingLossCount:2,enableTransformTextPayload:!1,logIDNewConfig:{enableAutoGenerateLogIDNew:!1,userIp:""},miniProgramParams:{customHttpHeader:{}},enableAutoAck:!1,reconnectInterceptor:()=>!0,enableQoS:!1,QoSLevel:2,messageStrategy:e.LvwVz,env:{xTTEnv:"",xUseEnv:""},listenNetworkChanged:!0};let{url:c,ws:d}=t,h=Array[r(546)](c)?c:e[r(1196)](e[r(1788)],typeof c)?[c]:[];if(!h||e[r(1670)](0,h.length))throw new Error(e[r(596)]);if(!e.DvmSr(Yc,d))throw new Error(e.UCoWB);Object[r(1492)](this[r(1209)],t),this[r(981)+r(908)]=new cs(h,this._options[r(495)+"es"]),this._pingLossCounter=new Zc(this[r(1209)].pingLossCount),this[r(1209)][r(1022)+r(1371)]&&(e[r(587)]!==e.hSnsm?(this[r(988)]=!0,this._connect()):this[r(759)+"T"]?_0x4f5d47["onNetwor"+r(867)+"hange"](({isConnected:m})=>{let l=r;this["_miniNavigatorOn"+l(1122)]=m,m?this[l(385)+l(647)]():this[l(385)+l(937)]()}):this[r(1171)+"X"]&&_0x2c72e6["onNetworkStatusC"+r(1418)](({isConnected:m})=>{let l=r;this[l(1401)+l(869)+l(1122)]=m,m?this["_handleO"+l(647)]():this[l(385)+l(937)]()})),this._options[r(1225)+r(1672)+r(1453)]&&(this[r(759)+"T"]||this[r(1171)+"X"]?this["_onPageN"+r(1033)+r(1611)]():this[r(449)+"er"]&&this[r(1068)+r(1568)+r(1261)]())}[n(385)+n(647)](){let t=n;this._options["disableA"+t(279)+t(1257)]||this[t(402)+t(554)]||this[t(856)+"econnect"]()}["_handleO"+n(937)](){let t=n;this[t(1265)+t(395)+"t"]();let r=e.lImLY(Mr,e[t(1089)],{message:t(1305)+t(1130)+t(1301)+"ct"});this[t(475)+t(1156)+t(561)+"ct"]&&this[t(475)+t(1156)+"yReconnect"](r)}[n(1068)+"balEvent"+n(1261)](){let t=n;this[t(449)+"er"]&&window[t(1572)+t(1261)](e[t(790)],this[t(385)+t(647)]),this[t(449)+"er"]&&window[t(1572)+t(1261)](e.aObuq,this["_handleO"+t(937)]),this[t(449)+"er"]&&window[t(1572)+"Listener"](e[t(1027)],this[t(445)+"ageHide"]),this[t(449)+"er"]&&window[t(1572)+t(1261)](e[t(1601)],this["_handleP"+t(340)])}["_dropGlo"+n(1568)+n(1261)](){let t=n;this[t(449)+"er"]&&window[t(548)+t(408)+"ner"](e[t(790)],this["_handleO"+t(647)]),this[t(449)+"er"]&&window[t(548)+"entListe"+t(1160)](e[t(1468)],this["_handleO"+t(937)]),this[t(449)+"er"]&&window[t(548)+t(408)+"ner"]("pagehide",this[t(445)+"ageHide"]),this[t(449)+"er"]&&window[t(548)+t(408)+"ner"](e[t(1601)],this[t(445)+"ageShow"])}[n(445)+"ageHide"](t){let r=n;e.PHrhl(e.EyLgm,e[r(415)])?(e[r(1317)](_0x27afa4,_0xab942c,16),e.lqlcz(_0x41d8fe,_0x21aaa2,_0xcb2823)):(!t[r(1164)+"d"]&&(this._isBrowser&&window[r(548)+r(408)+r(1160)](r(951),this[r(445)+r(699)]),this[r(449)+"er"]&&window[r(548)+r(408)+r(1160)](e.KceqD,this["_handleP"+r(340)]),this.close()),this._isBrowser&&window[r(548)+r(408)+r(1160)](e.XSXyy,this["_handleO"+r(647)]),this[r(449)+"er"]&&window["removeEv"+r(408)+"ner"](e[r(1468)],this[r(385)+r(937)]))}[n(445)+n(340)](t){let r=n;if(t[r(1164)+"d"])if(e[r(858)](e.pFOss,e[r(1743)]))this[r(1375)+r(1471)]()&&(!this[r(758)]||e[r(1472)](this[r(758)][r(1667)+"te"],this.OPEN)||e[r(1484)](this[r(758)][r(1667)+"te"],this.CONNECTING))&&this[r(385)+r(647)](),this._isBrowser&&window[r(1572)+r(1261)](e[r(790)],this["_handleO"+r(647)]),this._isBrowser&&window[r(1572)+r(1261)](e[r(1468)],this[r(385)+r(937)]);else return _0x39bb99&&(_0x236f60=(0,_0x2532ba[_0x333566(_0x3355d7)[0]])(_0x3f6a1a=0)),_0x4d1e7c}async[n(377)+n(850)](t){let r=n,c={ljcTo:function(d,h,m){return d(h,m)},UZtZQ:function(d,h,m){return e[B(1656)](d,h,m)}};if(e.pnfYs(r(1298),e.MqRFn))byKIYA[r(438)](_0x5e4aec,_0x3b9ac3,74),byKIYA[r(728)](_0x57564f,_0x1845e4,_0x34b660);else{let{fpID:d,deviceID:h,bddID:m,ttwID:l,accessKey:v,aID:y,customParams:b={},enableAutoAck:A,enableQoS:R,QoSLevel:z,env:L}=this[r(1209)],Ne,Z,fe;this._isBrowser||this[r(1171)+"X"]||this[r(759)+"T"]?(Ne=location&&e[r(1454)](e[r(353)],location.protocol)?e[r(1247)]:e[r(1200)],Z=t[r(763)](/((^ws)|(^http))((?:[s]*:\/\/))/,""),fe=/^wss(.*:\/\/)/[r(566)](t)?t:""+Ne+Z):(Ne=e[r(1247)],Z=t[r(763)](/(^http)((?:[s]*:\/\/))/,""),fe=/(^ws)((?:[s]*:\/\/))/[r(566)](Z)?Z:""+Ne+Z);let lt=m?e[r(861)]:l?e[r(924)]:e[r(1384)],Ct=m||l||h;if(e[r(888)](!Ct,!lt))throw new Error(e[r(1682)]);let Kr=e[r(1702)](r(1770),typeof b)?await e[r(1635)](b):b,jr=L?e[r(1398)](Qc,L[r(1249)],L[r(1051)]):{},Jt=Object.assign({device_platform:e[r(1741)],version_code:e[r(1233)],access_key:v,fpid:d,aid:y,[lt]:Ct,xsack:A?1:0,xaack:A?1:0,xsqos:R?1:0,qos_level:R?z:void 0,qos_sdk_version:2,...jr},Kr),bn=Object[r(707)](Jt)[r(1623)]((Vt,Wr)=>Jt[Wr]!==void 0?""+Vt+(Vt?"&":"?")+Wr+"="+Jt[Wr]:Vt,"");return fe+"/ws/v2"+bn}}async _connect(){let t=n,r={LubGA:e.qrjbq,AXXxy:e[t(1190)],dlvhW:function(c,d){return c!==d},BaGCs:function(c,d){return e[t(1026)](c,d)},WPpdQ:e[t(790)],CXYww:e[t(1468)]};if(!(this[t(1525)+t(569)]||this[t(402)+t(554)])){this[t(1525)+t(569)]=!0;try{if(e[t(580)](t(1587),e[t(1503)]))t(498)+"d"!=typeof _0x1434e6&&_0x2253de["toString"+t(551)]&&_0x35418a[t(437)+t(434)](_0x333751,_0x4b856f[t(735)+t(551)],{value:XqZGYJ[t(1258)]}),_0x1b41ed[t(437)+t(434)](_0x268436,XqZGYJ[t(606)],{value:!0});else{let c=this[t(981)+t(908)]?.[t(1276)+t(709)+t(342)+t(1278)+t(618)](),{timeoutInterval:d}=this[t(1209)];if(c){let m=this[t(981)+t(908)]?.[t(1477)+t(308)+"nt"](),l=this[t(981)+t(908)]?.[t(1573)+t(655)+t(957)+t(1402)+t(1748)](),v=this[t(981)+"tManager"]?.[t(1477)+"ntEndpoi"+t(477)+t(1206)]();if(l){let y=t(1079)+m+(t(959)+", max re"+t(710)+t(537)+t(1266)+t(1403)+t(894))+l+(t(1659)+"y"),b=e.QFHRN(Ae,e[t(960)],{message:y,code:et[t(806)+"IES_ERROR"]});this[t(1121)](y),this[t(1633)+t(1643)+t(1424)](b),this[t(1642)]=await this[t(377)+t(850)](l),this[t(1121)](t(1079)+l+" "+v+t(1660)),this[t(1182)+"sListeners"]()}else if(e.dSqpv(e[t(1691)],e.odsJh))this[t(1375)+t(1471)]()&&(!this[t(758)]||XqZGYJ[t(1176)](this._ws[t(1667)+"te"],this[t(714)])||XqZGYJ[t(447)](this[t(758)].readyState,this[t(1139)+"NG"]))&&this[t(385)+t(647)](),this[t(449)+"er"]&&_0x32a410[t(1572)+t(1261)](XqZGYJ.WPpdQ,this[t(385)+t(647)]),this[t(449)+"er"]&&_0x363af9[t(1572)+t(1261)](XqZGYJ.CXYww,this[t(385)+"ffLine"]);else{let y="connect "+m+(t(959)+t(1274)+t(710)+t(1669));this[t(1121)](y),this[t(1633)+"hErrorEv"+t(1424)](e[t(1219)](Ae,e.McQpH,{message:y,code:et[t(806)+t(681)+"R"]}));return}}else{let m=this[t(981)+t(908)]?.["getCurre"+t(308)+t(860)+t(871)](),l=this["_endpoin"+t(908)]?.[t(1477)+t(308)+t(477)+t(1206)]();this[t(1642)]=await this["_generat"+t(850)](e[t(919)](m,"")),this[t(1121)](t(1079)+m+" "+l+" times"),this[t(1182)+t(1053)+"rs"]()}if(this._isInit)this[t(988)]=!1;else{let m=e[t(975)](Mr,e[t(1089)],{message:e[t(1031)]});this[t(700)+t(341)]&&this[t(700)+t(341)](m)}let h=this[t(981)+t(908)]?.[t(1477)+t(308)+t(477)+t(1206)]()||0;e[t(506)](h,1)&&await this[t(765)](e[t(1721)](h,1)),this._debug(t(1372)+t(1675)+this[t(1642)]+(t(1237)+"ls: ")+this._protocols),this[t(758)]=e.TkAYc(Vc,{url:this[t(1642)],protocols:[this._protocols],headers:this[t(1209)][t(1358)+t(1331)+"s"][t(321)+t(1228)]},this[t(1209)].ws),(this[t(449)+"er"]||this._isWorker)&&this[t(758)]&&(this[t(758)][t(632)+"pe"]=this["_binaryT"+t(1334)]),this["_addWsLi"+t(989)](),this[t(1525)+t(687)+"utId"]=e.pHrOT(setTimeout,this[t(327)+"ut"][t(841)](this),d)}}catch(c){throw this["_connect"+t(569)]=!1,c}}}[n(776)+n(1021)](){let t=n;clearTimeout(this[t(1525)+t(687)+"utId"]),this[t(1525)+t(687)+t(1438)]=null}[n(547)+"ngTimer"](){let t=n;e[t(838)](clearTimeout,this._pingPongTimeoutId),e.nxzhb(clearTimeout,this[t(1653)+t(1086)+t(1259)]),this[t(1260)+t(1661)+"Id"]=null,this._reconnectTimeoutId=null}[n(1121)](...t){let r=n;this[r(1209)][r(1754)]&&console[r(1e3)][r(400)](console,[e.SAYrP,...t])}[n(295)+n(715)+"e"](t){let r=n,{initReconnectInterval:c,maxReconnectInterval:d,reconnectIntervalGrowFactor:h}=this[r(1209)],m=e[r(1310)](c,Math[r(482)](h,t-1));return e.LJAho(m,d)?d:m}[n(615)](){let t=n;if(this[t(758)]&&e[t(1313)](this._ws[t(1667)+"te"],this[t(1139)+"NG"])){this["_clearPi"+t(1007)](),this._pingPongTimeoutId=e.GtDCt(setTimeout,this[t(615)].bind(this),this._options[t(536)+t(1307)]);return}if(!this._ws||e.jmvxV(this[t(758)][t(1667)+"te"],this.OPEN))return void this[t(856)+t(341)]();this[t(758)]&&this[t(758)][t(1545)]("hi"),this[t(1653)+t(1086)+t(1259)]=setTimeout(this[t(856)+t(341)+t(514)].bind(this),this._options[t(1565)+t(738)+t(1600)])}[n(856)+n(341)+"Timeout"](){let t=n;this[t(1606)+"sCounter"]?.[t(612)](),this[t(601)](e[t(1595)],e.lsCZD),this[t(1606)+t(1444)]?.checkReachMaxCount()?this[t(856)+"econnect"]():this[t(615)]()}[n(1375)+"orOnline"](){let t=n;return e[t(967)](e[t(1251)],e[t(1526)])?new _0x2e2e79(_0x2188ed,{data:_0x46abdc}):this[t(759)+"T"]||this[t(1171)+"X"]?this["_miniNav"+t(869)+t(1122)]:(this[t(449)+"er"]||this[t(678)+"r"])&&this[t(1209)][t(1225)+t(1672)+t(1453)]?navigator[t(788)]:!0}[n(856)+"econnect"](){let t=n;!this[t(1375)+"orOnline"]()||this[t(402)+t(554)]||(this[t(981)+"tManager"]?.resetEndpointConfig(),this[t(1606)+t(1444)]?.[t(898)+t(1226)](),this._ws?this["_disconn"+t(629)](1001,t(1762)+t(1073)+t(693)+t(852)+t(589),!0):this[t(1525)]())}[n(1479)+n(1033)+"ange"](){let t=n,r={yxpiQ:e[t(593)]};this._isMiniTT?tt["onNetwor"+t(867)+t(1418)](({isConnected:c})=>{let d=t;if(d(1674)===r[d(796)]){if(this._options[d(896)+d(279)+"nect"]||this[d(402)+"osed"])return;this["_handleR"+d(341)]()}else this[d(1401)+d(869)+d(1122)]=c,c?this[d(385)+d(647)]():this[d(385)+d(937)]()}):this._isMiniWX&&wx[t(1149)+t(867)+t(1418)](({isConnected:c})=>{let d=t;this[d(1401)+"igatorOnline"]=c,c?this[d(385)+d(647)]():this[d(385)+d(937)]()})}[n(765)](t){return new Promise(r=>{let c=B;e[c(953)](setTimeout,r,this[c(295)+"rvalValue"](t))})}["_disconn"+n(629)](t=1e3,r="",c=!1){let d=n;this[d(758)]&&this[d(1265)+"WebSocket"](t,r,c)}_onTimeout(){let t=n,r=this[t(981)+t(908)]?.getCurrentEndpoint();this[t(1121)](t(1079)+r+t(959)),this[t(736)+"ect"](1001,e[t(382)],!0)}[n(1111)](t){let r=n,c=e[r(616)](re,t);if(this[r(758)]&&this._ws.readyState===this[r(714)])if(e[r(563)](e[r(1227)],r(348)))this[r(758)]&&this[r(758)][r(1545)](c),this[r(1121)](r(1434),t);else{let d=e[r(429)](_0x5a4342,_0x771d64);this[r(758)]&&e.gcWFq(this[r(758)][r(1667)+"te"],this[r(714)])&&(this[r(758)]&&this[r(758)][r(1545)](d),this[r(1121)](e[r(1778)],_0x15304e))}}[n(1182)+n(1053)+"rs"](){let t=n,r=e[t(1318)][t(961)]("|"),c=0;for(;;){switch(r[c++]){case"0":if(!this._ws)return;continue;case"1":this._ws[t(548)+"entListener"]("message",this[t(1612)+"ge"]);continue;case"2":this[t(758)][t(548)+t(408)+"ner"](e[t(1435)],this[t(1143)]);continue;case"3":this[t(758)][t(548)+t(408)+"ner"]("open",this._onOpen);continue;case"4":this._ws[t(548)+t(408)+t(1160)](e[t(960)],this[t(1088)]);continue}break}}_addWsListeners(){let t=n;this[t(758)]&&(this[t(758)][t(1572)+"Listener"](e.dKlDg,this[t(1738)]),this[t(758)][t(1572)+t(1261)](e[t(1435)],this[t(1143)]),this[t(758)][t(1572)+"Listener"](e.QTMPj,this[t(1612)+"ge"]),this[t(758)][t(1572)+t(1261)](e.McQpH,this[t(1088)]))}_wsInstanceClose(t=1e3,r=""){let c=n,d={VKETM:function(h,m){return h(m)},FvPoy:function(h,m){return h(m)},IBOSc:e[c(1218)]};try{if(e.NZUyN(e.gVNDZ,c(1764))){let h={NtKTz:function(m,l){let v=c;return BapYVh[v(947)](m,l)},bjeUr:function(m,l){let v=c;return BapYVh[v(1095)](m,l)}};_0x12150b[c(1572)+c(1261)](BapYVh[c(1460)],m=>{let l=c;_0x2e3894(h[l(1117)](_0x2b6264,_0x18acc3[l(362)]),m[l(1520)+"on"],m[l(443)+"on"],h[l(526)](_0xc581ba,_0xd1955f[l(1498)+l(1126)]))})}else this[c(758)]&&this[c(758)].close(t,r)}catch{}}["_destroy"+n(395)+"t"](t=1e3,r="",c=!1){let d=n;if(this._clearPingTimer(),this["_clearTi"+d(1021)](),this._removeWsListeners(),this[d(1262)+d(807)](1e3,r),this[d(1525)+d(569)]=!1,c&&this[d(1375)+d(1471)]()&&!this["_readyCl"+d(554)]){if(this["_endpoin"+d(908)]?.[d(845)+d(1327)+"es"]()){let m=this["_endpoin"+d(908)]?.["getCurre"+d(308)+"nt"]();this[d(1633)+d(1688)+d(1424)](e[d(373)](De,e[d(1435)],{code:1006,reason:d(1079)+m+(d(959)+", max re"+d(710)+d(1669)),wasClean:!0}))}else if(e[d(580)](e[d(1783)],e[d(1783)]))!_0x4c3d7b[d(1164)+"d"]&&(this[d(449)+"er"]&&_0x5e3d68[d(548)+d(408)+d(1160)](d(951),this[d(445)+d(699)]),this[d(449)+"er"]&&_0x11c358[d(548)+d(408)+"ner"](d(427),this[d(445)+d(340)]),this.close()),this._isBrowser&&_0x1bcda6[d(548)+d(408)+d(1160)](e[d(790)],this[d(385)+d(647)]),this[d(449)+"er"]&&_0x4e4588["removeEv"+d(408)+d(1160)](e[d(1468)],this[d(385)+"ffLine"]);else{let m=this[d(1209)][d(693)+d(1671)+d(696)](t,r);this[d(1633)+d(1688)+"ent"](e[d(346)](De,e[d(1435)],{code:t,reason:r,wasClean:!0,willReconnect:m})),m&&this[d(1525)]()}return}this[d(1375)+d(1471)]()||this[d(402)+d(554)]?this[d(1633)+"hCloseEv"+d(1424)](e[d(422)](De,e.XzUeF,{code:t,reason:d(652)})):this[d(1633)+d(1688)+d(1424)](e[d(752)](De,e[d(1435)],{code:1006,reason:e[d(771)]})),this[d(758)]=null,this[d(981)+d(908)]?.[d(1786)+d(1698)+d(577)](),this[d(1606)+d(1444)]?.[d(898)+d(1226)]()}[n(1633)+n(1169)+"nt"](t){let r=n;this[r(601)](e[r(428)],t),this[r(1254)]&&this[r(1254)](t)}[n(1633)+n(488)+n(396)](t){let r=n;this[r(601)](e[r(1429)],t),this[r(977)+"e"]&&this.onmessage(t)}[n(1633)+n(1722)+n(902)](t){let r=n;this[r(601)](r(1195),t),this[r(1311)+r(973)]&&this[r(1311)+r(973)](t)}[n(1633)+n(1643)+n(1424)](t){let r=n;this[r(601)](e[r(960)],t),this.onerror&&this.onerror(t)}[n(1633)+n(1688)+n(1424)](t){let r=n;this.emit(e.XzUeF,t),this[r(1717)]&&this[r(1717)](t)}get[n(632)+"pe"](){let t=n;if(t(954)!==e[t(1649)]){let r=_0xe86a1a[t(1140)],c=_0x255867[t(721)];return r[t(680)]===c?r:r[t(1668)](0,c)}else return this[t(758)]?this[t(758)][t(632)+"pe"]:this[t(1002)+"ype"]}set binaryType(t){let r=n;this[r(1002)+r(1334)]=t,this[r(758)]&&(this[r(758)][r(632)+"pe"]=t)}get retryCount(){let t=n;if(e[t(333)]!==e[t(791)])return this[t(981)+"tManager"]?.[t(1477)+"ntEndpointTriesC"+t(1206)]()||0;_0x393af5[t(386)]=_0x5c4860[t(645)]()[t(1123)](()=>(_0x46809f(),_0x13ea52))[t(1123)](function(r){return r})}get[n(1243)+n(970)](){let t=n;return this._messageQueue[t(1623)]((c,d)=>(c+=d&&d[t(518)+"th"]||0,c),0)+(this._ws?this[t(758)][t(1243)+"Amount"]:0)}get[n(1521)+"ns"](){let t=n;return this._ws?this[t(758)][t(1521)+"ns"]:""}get[n(910)](){let t=n;return this._ws?this[t(758)][t(910)]:""}get[n(1667)+"te"](){let t=n;return this[t(758)]?this[t(758)][t(1667)+"te"]:this[t(1209)][t(1022)+"cOpen"]?this[t(1139)+"NG"]:this[t(772)]}get[n(604)](){let t=n;return this[t(758)]?this[t(758)].url:this[t(1642)]}[n(1131)](t=1e3,r){let c=n;if(this._readyClosed=!0,this._clearTimer(),this[c(547)+c(1007)](),this[c(1238)+"balEvent"+c(1261)](),this[c(485)+c(834)]?.[c(927)](),!this[c(758)])return void this._debug(e.vLNNE);if(this[c(758)][c(1667)+"te"]===this[c(772)]||e.chBsa(this[c(758)][c(1667)+"te"],this[c(886)]))return void this[c(1121)]("close, w"+c(1240)+"y closed");this[c(1265)+c(395)+"t"](t,r)}async[n(1545)](t,r){let c=n;if(e[c(1664)](e[c(1341)],e[c(490)]))DTZqle[c(1197)](_0x384c04,_0x381547[c(1013)]||new _0x8c962e(DTZqle.gWbHf,DTZqle[c(822)])),DTZqle[c(1635)](_0x543c30);else{if(e[c(1787)](null,t))throw new Error(e.OQRWw);e[c(1080)](e[c(1063)],typeof t)&&(t=JSON.stringify(t)),e.CaUSZ!=typeof t&&!(t instanceof ArrayBuffer)&&!(t[c(1514)]&&e[c(1348)](t[c(1514)],ArrayBuffer))&&(t=JSON[c(1578)+"y"](t));let d=await e[c(1723)](fs,t),h=e[c(1127)](Xc,t),{method:m=0,service:l=this[c(1209)].service,logID:v=this[c(1209)][c(814)+c(1205)](),headers:y=this[c(1209)].headers,payloadEncoding:b=this[c(1209)][c(732)+c(890)],payloadType:A=this._options[c(1417)+c(1334)],logIDNew:R=this[c(1209)][c(381)+c(394)]["enableAu"+c(956)+c(527)+"ew"]?e[c(1324)](o,this._options[c(381)+c(394)][c(793)]):""}=r||{};if(!l)throw new Error(e[c(694)]);let z={SeqID:j[c(1776)+"er"](this[c(562)]++),LogID:j[c(1776)+"er"](v),service:l,method:m,headers:y,payloadEncoding:e[c(316)](b,Object)?b[c(780)]?b[c(780)]:"":b,payloadType:e[c(513)](A,Object)?A.type?A[c(756)]:h:A||h,payload:d,LogIDNew:R},L=e[c(1426)](re,z);return this[c(758)]&&this[c(758)].readyState===this[c(714)]?(this[c(758)]&&this[c(758)][c(1545)](L),this[c(1121)](e.TIpYx,z)):e[c(1466)](this._messageQueue[c(680)],this[c(1209)][c(1489)+c(1400)+c(281)])?(this[c(1761)+c(1363)][c(1734)](L),this[c(1121)](e[c(1598)],z)):(this["_message"+c(1363)][c(504)](),this[c(1761)+c(1363)][c(1734)](L)),{seqID:this[c(562)],logID:v,logIDNew:R}}}async[n(693)+"t"](t){let r=n,{url:c}=e[r(880)](t,{}),d=Array[r(546)](c)?c:e[r(868)](e.CaUSZ,typeof c)?[c]:[];t&&Object.assign(this._options,t),d&&d[r(680)]?this[r(981)+"tManager"]=new cs(d,this[r(1209)][r(495)+"es"]):this[r(981)+r(908)]?.[r(1786)+r(1698)+r(577)](),this[r(1606)+r(1444)]?.[r(898)+r(1226)](this[r(1209)][r(487)+r(683)]),this["_readyCl"+r(554)]=!1,this[r(758)]&&this[r(758)][r(1667)+"te"]!==this[r(772)]?this[r(736)+r(629)](1e3,e.LTONQ,!0):(this[r(988)]=!0,this._connect())}async[n(1342)](){let t=n;if(!this["_connect"+t(569)]){let r=(t(1040)+"0")[t(961)]("|"),c=0;for(;;){switch(r[c++]){case"0":this[t(1525)]();continue;case"1":this[t(1606)+t(1444)]?.resetCounter();continue;case"2":this["_readyCl"+t(554)]=!1;continue;case"3":this[t(981)+t(908)]?.[t(1786)+t(1698)+t(577)]();continue;case"4":this[t(988)]=!0;continue}break}}}addEventListener(t,r){this.on(t,r)}[n(1114)+"Event"](t){let r=n,{type:c}=t;this[r(601)](c,t)}[n(548)+n(408)+"ner"](t,r){let c=n,d={MbEsK:function(h,m){return e[B(456)](h,m)},tAZmk:e[c(1680)],QIIWh:"applicat"+c(1281)+c(1619)+"=utf-8",NEHwJ:e.CaUSZ,lfKyR:e.TvTrO,KQgjK:c(734),JKJlk:function(h,m,l,v){return e[c(1092)](h,m,l,v)}};if(e[c(1538)](e[c(1500)],e.NatRu))if(_0x188afb[c(1779)]instanceof _0x1fbce9){let h=nirHVH[c(302)](this[c(1209)]["payloadE"+c(890)],_0x1b2ac1)?{force:!!this[c(1209)][c(732)+c(890)][c(1790)],encoding:this[c(1209)][c(732)+"ncoding"][c(780)]?this[c(1209)][c(732)+"ncoding"][c(780)][c(763)](/\s/g,"")[c(611)+c(943)]():""}:{force:!1,encoding:this[c(1209)]["payloadE"+c(890)]?this[c(1209)][c(732)+c(890)][c(763)](/\s/g,"")[c(611)+c(943)]():""},m=_0x437eeb.payloadEncoding?_0x15594e[c(732)+"ncoding"][c(763)](/\s/g,"")["toLowerC"+c(943)]():"",l=nirHVH[c(302)](this[c(1209)][c(1417)+c(1334)],_0x312794)?{force:!!this[c(1209)][c(1417)+c(1334)][c(1790)],type:this[c(1209)][c(1417)+"ype"][c(756)]?this._options.payloadType[c(756)][c(763)](/\s/g,"")[c(611)+c(943)]():""}:{force:!1,type:this[c(1209)][c(1417)+"ype"]?this[c(1209)][c(1417)+"ype"][c(763)](/\s/g,"")[c(611)+c(943)]():""},v=_0x123cb2[c(1417)+c(1334)]?_0x5ba15e[c(1417)+c(1334)][c(763)](/\s/g,"")[c(611)+c(943)]():"",y=l.force?l[c(756)]:v||l[c(756)],b=h[c(1790)]?h[c(780)]:m||h[c(780)],A=[c(906)+c(356)+c(703),nirHVH.tAZmk,nirHVH[c(1570)],nirHVH[c(303)]],R=[nirHVH[c(1179)],nirHVH[c(1476)]];this[c(1209)][c(810)+c(1677)+c(1461)+"ad"]&&A[c(1465)](y)&&(!b||R[c(1465)](b))?_0x383856["textPayl"+c(996)]=nirHVH[c(1005)](_0x5cbaac,_0x33df43[c(1779)],0,_0x4bef85.payload[c(518)+"th"]):_0x30b153.textPayload=""}else _0x5d3756[c(1517)+"oad"]="";else this[c(559)](t,r)}pingOnce(){let t=n,r={YXpNc:function(c,d){return e[B(1074)](c,d)},NLTni:function(c,d){return e[B(1044)](c,d)},mlJrw:t(768),DnGve:t(1621)+t(1220)+"s",rLDEg:function(c,d,h){return c(d,h)},zmCwD:e.jelHw};return new Promise((c,d)=>{let h=t,m={DnjPn:function(y,b){return r[B(1433)](y,b)},bmpEQ:h(1154),cYomc:function(y,b){return r[h(1172)](y,b)},tQPdV:r[h(572)],BhOol:r[h(1058)]};this["_clearPi"+h(1007)](),this[h(1260)+h(1661)+"Id"]=r[h(674)](setTimeout,this[h(615)].bind(this),this._options["pingInte"+h(1307)]);let l=()=>{let y=h;m[y(1581)](c,m.bmpEQ),this.off(y(1621)+y(1220)+"s",l),this.off(y(1621)+"e_timeout",v)},v=()=>{let y=h;m[y(978)](d,m[y(579)]),this[y(559)](m[y(1163)],l),this[y(559)](y(1621)+y(1272)+"t",v)};this.on(r[h(1058)],l),this.on(r.zmCwD,v),this[h(615)]()})}}})(),se[C(1102)+C(661)]=te[C(1102)+C(661)],se["CustomEr"+C(1756)]=te[C(644)+C(1756)],se[C(929)+"e"]=te[C(929)+"e"],se[C(396)]=te[C(396)],se[C(351)]=te[C(351)],se[C(1214)+C(1050)+"vent"]=te["FrontierMessageE"+C(1322)],se.MessageEvent=te[C(1050)+C(1322)],se.OpenEvent=te[C(708)+"t"],se["Reconnec"+C(585)]=te[C(992)+"tEvent"],se[C(564)+C(661)]=te[C(564)+C(661)],se[C(891)+C(1756)]=te[C(891)+C(1756)],se[C(855)+C(901)+"nt"]=te["createMe"+C(901)+"nt"],se[C(1145)+C(1775)]=te["createOp"+C(1775)],se[C(317)+C(1483)+C(1322)]=te[C(317)+C(1483)+"vent"],se[C(1109)+"rame"]=te["decodedF"+C(503)],se[C(675)+C(904)]=te[C(675)+C(904)];for(er in te)["CustomCl"+C(661),C(644)+"rorEvent",C(929)+"e",C(396),C(351),C(1214)+C(1050)+"vent",C(1050)+C(1322),"OpenEvent",C(992)+C(585),C(564)+C(661),C(891)+C(1756),C(855)+C(901)+"nt",C(1145)+"enEvent",C(317)+C(1483)+C(1322),C(1109)+"rame",C(675)+C(904)][C(1326)](er)===-1&&(se[er]=te[er]);var er;function or(){let n=["DxfOB1e","AwXLx25HBwu","uxvLDwu","ExzHB20","BgvY","rwPJAeG","Chv0","CMvHzg9UBhK","BvzJr2S","r1DOsee","y09Wzw4","y29UBMvJDgK","teHOr2O","svzitgW","x25HDMLNyxq","zLvVsgy","wwrIA0e","quXm","B2zMBgLUzq","q09oveLovuu","r3bgq0i","AhftEva","AKDQwKu","whjwzNK","vK9Zv0S","nNWWFdeW","suHisMC","DNfLsKK","ENbry3C","sfrIDMO","BeHHBMrSzxi","q0rjtey","y2HLuK4","yM5jtKu","AhLuD1q","r2nItMq","tu1Pwwu","q2Dsueq","zsbHihn0CMK","z2vrDwv1zuW","x21PBMLoyxy","vxbKyxrLq28","yMfJA3vWigu","DMTwwe4","u05rqKe","CxfSzwq","CgfYC2u","rvjst1i","igfYCMf5yNu","CKL4DMi","Egvvre8","Bwv0Ag9K","Ef9MCM9UDgK","tgPWz0e","sKjitg4","zfnXChy","Cgf5Bg9Hzfq","AgfUz2u","qKDAy2i","zMvY","uKPptum","yxv0BW","rw9iA0e","zw50","BLrPEwO","tvz2B2e","DKHwzuC","C2v0q3vYC28","uvrnugO","ign1CNnVCIa","rKfxqKu","wujwrfG","wvHWtMm","C2vUzf9Hy2S","whPvzuy","ugXerva","rLHdDgy","Dxrjza","y29TCgXLDgu","x19LC01Vzhu","EwjAAMK","x194x21Zz18","B3jRzxjhBg8","C0nVDw50zxi","uKTSsvK","u014qwe","CgPpr08","vxPAu1a","yxjYyxLIDwy","D0LUue4","y29UC3rYDwm","q3bcBei","BMDLza","vwnnsMG","wfrKuNO","DMveqvy","AwXK","z1nJr1G","Ee1yCfe","sujpu2m","zxH0ugf5Bg8","lcbOB3n0BMe","C2vYDMLJzs0","r1DcALy","Aw5JBhvKzxm","zfjZr3O","DwDJwvK","yu9IDxe","AvnLteC","AxnmB25N","B3jpBMXPBMu","yLj3wei","t2jQzwn0","t3nbBgK","B3rvywS","s1fNAKS","z2v0q3vYCMu","u1nHB2G","x29UugfNzu4","qvfLyLO","z05ny20","DMTYrLe","y29UBMvJDeu","yMjdyuW","seTpuKK","CfjoD1O","D2vI","vhDsywi","Bwf4twvZC2e","CwXsAMW","CePvtuW","yxnZAwDU","DwX2qNe","u3LivhG","x2XPC3rLBMu","CM9kBwm","uMn2t2q","DhjHBNnHy3q","qvfbrMe","tMf0uNu","zw5KCg9PBNq","txjHEeO","B0Doq24","Dhj1y3rVCIa","Eev6DLK","qwXdu1e","ExjZC0O","surrq3y","BwvZC2fNzq","zhH1ENK","Dg9cExrLC0W","zxjFCw9Zx2e","uvPmDMS","yNvMzMvY","B2zMC2v0","tg9Nsuq","Dgv4DfbHEwW","m3W3Fdj8nhW","qu1rCLK","B2XKvMvYC2K","zxH0zw5ZAw8","tffryxy","u2HHCMvKv28","z2u6ia","x2nVBM5Ly3q","C2nRuNe","rhDfB1K","BKfnuMG","sxnPquu","yKvRy3y","teP3Bem","sKvVsvy","t1jIAwG","z1PfAfm","C0Xf","CLzHBhvLCW","v2TztK4","Dg5VDeO","yvDuBK4","y29UDgLUDwu","suffwwi","zM9YrwfJAa","Bg5WBxy","EwvtwxC","C2vUza","C2TYCe8","A0zbAKm","D0TPCeO","sg9YDwW","ChnjDgy","Dvvpz1q","AeHivNC","ywnRtxnNswq","v0H2q0S","BxnNsuq","wwHZv1m","EhfXwwC","DgLsz3i","ChjLvNK","B25LCNjVCG","B1jvBeq","BenfyvO","CKrlA0i","BuT6uge","CgLUz1rPBwu","BuHWCuO","rLPQtuu","yMfSrxzLBNq","zg9Uzq","uuLjv2G","Cw1jDum","ywrKrxzLBNq","CMvWBgfJzui","txDQCwq","CNLbz0S","vwDIqKe","z21tEfm","C3rYAw5NAwy","rw5XwNe","zNHZreu","rg5Qug4","B01nB1O","seDmzwG","CYbWyxjHBxm","mdaWmdaWmda","BwfUDwfSihi","CgDMuwy","jMPZy2fSBgi","sgz3y1a","D3m6lY8","CefWDw4","qujoA2q","zvbdvxC","rwnHwwK","AMvSshC","rezYruO","CMj0yMy","Du95swW","Aw1LCYbPBIa","DMfS","s2nLCuq","CMvZzxruCMK","sg1st0e","ChfYt3m","uvznDuG","x3bPBMDmB3m","r3Potwe","ywrHs3i","t2vTtKm","ww5LuMS","yw5Nzq","x29UtwvZC2e","tgvnDvu","shDfvfa","tw1fqxq","x2n1CNnVCK4","tefQC2C","B25Uzwn0Aw4","o2nOyxjZzxq","aaaaaaaaaaa","CgLUz19VBMm","EM1dwwe","CMvKDwnL","su5tvefova","y2uGBM90igK","DxbKyxrLq3u","qLjRt3q","qurMBgu","zxj2AwnL","AxnszwfKEq","zNjVBunOyxi","uxzTC0O","x2rPC3bHDgm","rK5vCe4","wfDtyxq","EufJrKK","C1Dfuhy","z0HXv0y","uerhDva","AM9PBG","zMr4yxG","x3vYBa","AevYCM9Yrxy","BM9Uzv9UB24","r1PcCfa","q0LyEhu","rKLmrv9ot1q","Avnqqw4","zKLyvgi","z3vsrvC","zuDzC08","zNnUB00","x3jLy29UBMu","whPLrNu","r3r3vuW","s1LxCve","vLD0A2C","BNvPte0","ihrVihjLDhi","ihrPBwvZ","z1rPBwvVDxq","EhLWDg4","qKTlrvK","uvz1qxi","u0nczK4","y2XLyxi","CMvHzhLtDge","C3vIyxjYyxK","ywnOzwq","A3rWrKe","DeLUDgvYy2u","DhDVCMTdAge","DhjPBq","D05su2u","BMCGDxjSoIa","Auj2tw0","yw5ZzM9YBvq","u2vYDMLJzvC","zuztBhm","vLbArw4","AwD0Eui","se91t3q","EKLbz2e","vLDUtfq","BgvewxO","DMLJzuLeig8","CMvXDwLYzwq","AenSB3nLrxy","veLWwxG","u0XfuMu","B2rZsMG","zMLPEfK","thHVzuu","yw1LoIa","BKLLB1m","C2TOs1u","zw5XDwv1zq","Cg9PBNrdB24","vg9bzMe","wuTJCNe","q0zHA1K","ugnvywq","s053tgW","r3req3q","zgvSzxrL","DwHfDNi","rhHesgu","EMjiufO","Cev2wfK","BLbcwgq","z0Lpqwy","y2vZC0HHBMq","AhPXALm","BwvZC2fNzv8","rfvVvu8","y3vYC29YlNm","B25JBg9Zzq","BxnzvKu","rKvTv1K","Dw5RBM93BIa","CuzjBhq","AefJA01LC3m","vxHJEMO","s1fVzxm","thjwAvu","t0fpBey","AvnItfe","CMjwAe8","CgXLyxnLiha","ALPMrMy","vg9xwgW","BgLUzw5V","rhDJEK4","ChvZAa","Dg9Y","vurHzvK","CvrnqK4","x29Ut3bLBG","Ec11C2uT","te5hz3G","vwfsufC","y3vYC29Yx24","t0fWDuC","AxvOu2S","BhngEha","C29YDa","BKzdug0","Dw50","tePbAg8","CMvTB3zLq2G","uNn5s2C","x2n1CNnVCKy","Dhv4q3e","zgvIDwC","yw51Ce1LC3m","CM9YrxzLBNq","wLv1sK0","B3DLCMC","ywDUzhu","BML0AwfSAxO","x21LC3nHz2u","z29PBMCGyxC","DvH6zu4","Cw1IBgS","CKPIvxO","CMvHzfvjBNq","A2r0zuy","zePWze8","BhrPCgXLihq","zNvUy3rPB24","BwrSBu4","Ahr0Ca","ywnRx2LK","uhjPBwfYEuS","zw5fDMvUDa","zNjVBu51Bwi","ruvUtwu","A3HxAKu","Cgf5Bg9Hza","sNDLy2i","uLDhBKG","t0fxDei","EvD3uM4","tw9KA00","CuDvswq","CMvZzxrfBMq","vMfnzhe","q2fvu1O","wNnsqxK","zM9Yy2u","A2v5","yM5gEfe","q2fytxm","DxrVuMvJB24","yKnmyLi","zw5NDgG","whrHz1G","DvzXwvm","C3rVCMu","Cw5dwKC","q2TJy0m","BIWGAg9ZDg4","mxWWFdn8mNW","zwr3sLy","ihn1y2nLC3m","BMfTzq","r2nAr1u","sgLYCxy","y291BNq","x2DLDeLUDgu","veX2swO","A0fTu2m","qwjMr28","q29Kzq","z2fkwey","zgrjrcWGzgu","twjfC0S","tKviD0O","EMvuweK","B3jLtMfTzxm","uNnPzgq","sgjHwNq","BNrfBMrWB2K","Bhb5D2y","C1jODNq","y29UDgv4Da","vMXjEMq","s0DfrNe","qNPItxy","mhWZFdu","u0zhqLC","y3jLyxrLuMu","BKDpzKS","EwHTqLK","CvvYvhi","y3vZDg9Tshq","ota4mtqWtujMzfPH","BMTjwwW","AgfZ","wxrUswq","zNH0D2i","x29UvgLTzw8","AezuCxO","vvfKC1O","A0reyLG","C2DPza","zcbLCNjVCI4","rgzuufq","t2f2q2q","Bw9AChm","zLPrzKO","uNrSAee","swTrtNy","AwzlDhK","ywDLu2HVDW","zwnVBM5Ly3q","B2LUDfjLywm","vMLNEfu","yvznAuO","ANPzug0","D1ftsKO","z3bxvxa","y0zjzve","yMrFzgLK","D3Pfv0S","rLDt","rNHRtLG","v09zCMi","EKDyshe","D2LSBfjLy28","Aw47y2HHCNm","y29Uy2f0","C1fvsMu","suPpDe0","Eur6twq","EejlvhC","CMvZDwX0","D3nZoI8V","tu5MyMK","BNPkA3G","BMCGzMfPBgu","BKvly0S","rhzTu3i","qKn1D2G","Cw9stNe","tLzbrfu","D2vIsMC","DM1sD3u","zfDdBwG","A3npzu4","vw5Oyw5KBgu","x2DLBMvYyxq","yvbKsvu","tMfTzq","t0nquva","Bg9NsurozxC","tvnwBKW","uwngvNK","ru5Xu1y","x2HHBMrSzu8","zxHWB3j0CW","whzzBwC","CvP0Chq","Bg93","ignVzgu6ia","AgvHzgvYCW","wwz2Dfm","u3rYyxrLz3K","q29UzMLN","v2vIu29JA2u","rxzLBNq","DvrIyNe","Dw1UzK0","wu9qqNC","yxbWBhK","zxjYtxnN","x3jLywr5q2W","z2vjBMzVu3K","tvDpyxG","CKHtA1y","C2v0","s1PZvhq","zw50tgLZDgu","zeDxtMO","DxHTs3m","svbhtuG","u1rxEMm","ww5bD1e","DMfSDwu","rxLmz20","turpyNu","A2n1tLG","qu1kqxy","sujRC0m","D1HNseS","refQCvi","yuDrD3G","CwLtt2S","Cgu6ia","ywDL","v01Rwhm","CgfNzxnOB3C","zeTSrgC","zuvAtgi","Dg9cExrLC0i","CNjVCK1LC3m","ufvsyMy","DMfSDwvZ","B3bLCNr5","Eevwr24","DgLTzw91DcW","zgvMAw5Luhi","BgPJvg8","thz3vNO","twHeu2W","z2v0sxrLBq","D1HKEe0","BMv3vMvYC2K","A05Vv2G","x2HHBMrSzva","B0zkrvK","qMfhq3m","uuTzy3u","x2LZqNjVD3m","tuT4se8","ihrYEsbYzwm","ELbds2y","ENLpAum","BLnUD0m","z3bRy0e","BuXpEM8","EwHfz1m","zMzLCG","ruLLu3i","EwPSvgC","v2XPDK0","AxnFywnR","BwvZC2fNztO","lcbxzwjtB2m","y3vYCMvUDeK","Dg9cExrLCW","B3jL","B2nRzxrtDwm","uNHbtMm","B25SAw5L","Aw5Lza","BLzbwgC","Cg9W","zxjFywnRx20","B25tDg9Wsw0","zeHXzvy","BNruCMLLC0m","r01wreC","DMvYC2LVBMm","A1HQA3q","A3HUsM4","Cg93","t1bftL9fuLi","BwvZ","x1fVu01HBMe","sg5YEMC","CgLUz0XVC3m","Ae1LC3nHz2u","Dhr3Awq","uwjwq3a","wgruA2y","vM1SBLa","C3rHCNq","q25QEhK","Bwf4uMv0CMK","y29UBMvJDfm","C2vYDMvYvgK","Dw5KzwzPBMu","CNLJq0W","y3jLyxrLrwW","CM92AwrLigi","rvfkuwG","CMfTzq","C2HPzNq","z3LQthu","zu1cC0S","z29ZA1G","zejdqMm","AgfZt3DUuhi","z1jKwhC","CvD1vKu","vNvRqNC","sKHSA1a","vgLTzw91Da","EwTcy0O","C29Tzq","zw9gvei","yNL0zuXLBMC","wMn2zfC","Au9fCgu","DcbVzIbYyw4","s25uuu4","zujpqNG","C2v0u3rVCMe","zhjuv1m","yMPLvxi","DgvmB2Djre4","CMPYEeC","yvvwEe4","EfrQCMK","y2XMzuS","yMTpufa","wMngDhq","rgvKAwnHDgu","vxjrr0e","CgLUz0LUDgu","ywnOzwqSihC","q3nmA1C","A2fQzwm","zgv2AwnLx2K","BfbNEKe","yLPZCva","y09er2W","y1bZsMS","sgLhEfa","AxnbCNjHEq","x2nSzwfYugK","CMvTB3zLrxy","y2f0y2G","B2jQzwn0u3q","vgfN","BNLHCKG","ufHgv0C","B3nLza","y3vYC29Y","AxnrB1nby2S","y3r4","wLDmuu0","B2zM","y2HnyxHdB3u","EvjLy29UBMu","x3nLCuLK","yM5Wq0e","y3jLyxrLq2W","B25fCNjVCG","DgvZDa","D24GCMvHC28","AKHKC0O","tg9JAW","CM92AwrLige","z2v0","BwXkCNC","CM9rBxi","z2v0qwXSs2u","tLngq2K","C3bSAwnL","zMLN","x2TLEvbHDgG","Dffqzfy","qxPTwMq","yxfWyxK","BentzKu","wNr6uuG","venewuC","Dev2zw50","BMvLzf9Hy2S","A3vPq2u","B2HdswK","DMvY","otq1otmWEgzSy0nV","z2v0q3vYC28","EwLXDgu","ywTnAw4","D29vuKq","y05vvfu","rLHRq2m","x2LUAxrqCM8","AMHZywq","B2nRzxq","Ae1Kuwu","zw1PDa","Dhzly0C","twLZC2LUzYa","DxjS","rKPWs1G","qvHyEhK","D0n3ELq","y2fSBa","uuziuK4","x3bHDgHlzxK","Dg9mB3DLCKm","ywrKq291BNq","sKPvB0e","uKvLuNe","x3bPBMC","AxjrBKS","C2nYAxb0","DhjPzxm","u25luwe","D2zxr1G","s1DlEeW","BgTvrgi","v093sgW","mZuZotC4ngjjyNHKAa","EK5lBwy","uLjpuG","Ag1oDwC","B05vuMG","zwn0","CIb0DhDjra","twvZzNG","yMLUyxj5vhK","qvbSsvK","CwzRrxO","rg1wvxy","Bvv4EMu","B0LHvMi","DvfSreG","q3n4AvO","uMX6yMC","wwfVCxe","zfDVCMTLCKC","y3vYCMvUDeu","q3vZDg9Trxi","CMvZB2X2zq","zNjVBuj5Dgu","BKXPBMu","ChjVDg90Exa","uw5Mwu4","BKDSAeG","Cgzeu3i","yNLL","C2fNzq","uwjnAe4","ywnRDxbfBMq","AxjLza","zxjYtM8","vLDrAvO","C0LyAey","y1jzsg4","B3nLrxzLBNq","u2vcv1C","seLvqLq","CxLJEMy","qKnYrey","wwXlv0q","CKXSzxa","yMfSu2nVCgu","DxrMofDYAxq","ihzHBgLKigq","wKfAuwG","C1LqvvK","D3Pkvuu","CKXerwC","zw5JB2rLrNi","ug9AuNC","rhzPB2y","x2LZv29YA2u","u0rsD1O","BgvUz3rO","suvtx0vsuK8","DvnKq2i","q291BNq","Dg9oDw1Izxi","ALD6D3u","vhzuCK8","Aw9UvgLTzw8","AgLNAKC","zMLUza","rvvHwxu","y3vYDMfSDwu","Efjss3K","CMvJB25Uzwm","Bvb6D3O","CMvJzwL2zwq","ChrVCG","B0vJsMe","rgDKB0O","ywDLsgLKzq","B25tDgfYDfi","sLnptLa","BM93","zxq9DxrMltG","qwj5EKq","u2TPCcbWyxm","CLbvy2S","A2v5CW","t3bLBKv2zw4","CMvUDevUzha","DhjPzxmGCMu","y29SBM8","Exn1yLy","BvnhtvK","t1bftG","CNzHBfzHBhu","Dg9iyxnO","CMLLC0nVDw4","qMX3ENy","CMvQzwn0","CwXXEfC","BgLTAxq","BfrPBwvVDxq","Cw1vrwu","DKjUrfi","AMT4vMq","FdH8nhW3Fde","DM5ItKW","vvP0wLe","CMfUzg9T","Agnqs2y","swzcBw8","Cgf5Bg9Hzeu","zeXkwvu","yMLUyxj5","Dg9tDhjPBMC","x2rPC2nVBM4","r3b4yMq","B3v0sw50zxi","DKvVt3e","v0vHDNm","zMLSzw5HBwu","x3nVy2TLDa","yxbWBgLJyxq","wwHMvgO","uKrOBLm","CMvHC29U","CwvKwgO","B3bLCNr5tMe","wMn2Bxq","rvfnAhC","v2vPEgLUsLm","yNvLy1C","zxjFCw9Z","q0jey1a","zLHHDLG","DhLWzq","CMTwseK","x3DZ","x2LZtwLUAvq","sK1tvhu","swTVs0C","B2nlzum","CMvWBgfJzq","AxDdzKi","x3DHAxq","tw9KDwXL","qwjVCNrfCNi","DgLTzw91Da","s0DlEeG","AwXLtMfTzq","uwTiwgu","q0Xpu0ve","rK9ty04","q0zbENe","AMLYAxa","x2nSzwfYvgK","nhWYFdb8m3W","rMDXCuK","Aw5KzxG","zw5JB2rPBMC","qLDIExq","x2LUDgvYDMe","sgXzB1C","r0HuqKO","vNDYshK","q2X2D3O","CMvJzxzPzwq","B25mAw5L","ywzL","wfnyExK","wgvRBxC","yNLcseq","DxnLCKLW","sLf1sMS","B1PwufO","ExHWAve","D09WuLm","B3bLBKrc","C2XPy2u","ywr2yw5Jzq","Bwf4tg9ZC0m","yxKSig5LDhC","uK55vhK","ExLyvuW","B3bLBIa","tufyx1jfvfi","BMnLq2XVC2u","r1nrDxC","BK5QBxm","zw5HyMXLvhi","yxbWzw5Kq2G","vxzfDxi","Axnby2TdBgu","Bg9Nsurhzw4","tLPvEu4","rLvevLO","ywXty29Wzq","BM5Ly3q","D3L2Egi","sLHAwuW","DerXtMW","z1DIsgy","suHTwNq","yMXVy2TLza","zwvKzwq","q3brD0G","vvreuNO","yw5Hz2vY","z2vtEw5J","Aw5N","D1PgCwK","C21xqxy","Dfzovgm","z2vY","sejythe","DMPxs0q","BezSDxnO","tu1fuLC","CgjhrfO","DxnHCLm","yMLUza","yxzcBfK","x2fKzfDZtgK","yNL0zu9MzNm","y2HLy2Tszwe","EvvLruu","DgLLCKPtt04","C1Dmt0i","yM9KEq","zvvYBa","txnkzwO","DgLUzYbZzxi","z3rArhC","ywrKt25L","y3jLyxrLtwu","x2HHBMrSzvi","we1Iu1O","zeTSCee","vxrxAxO","BNrbBMrvCgq","z2rOAKy","Aufowxi","zNPWC1C","q3f5q1y","u2vXsuq","wxflEKm","A1n0yxr1C0m","yKzABwu","AwDHDg9Yt24","zgjkrxe","yxrLq291BNq","C3LptvO","Aw5L","s2DuDuu","uKrktu8","ywr0thO","u2P6CKy","rgTyshu","sw1xC0K","tvLXDwW","Bu9Ique","yuf4ve8","ugLqz3K","zNjVBujPDhm","uhzWrwy","q0Xpu0LorW","yNrrC3a","EgHTC20","BxnN","BMnVzgLUzW","y3jLyxrLrxi","vMXYyLa","CerPswO","BMrWB2LUDca","C0LYrfq","zgLZywjSzue","AvLyyuy","CMvZzxrdB3u","ANjxwfO","D0vVCuu","C3nHz2vfDMu","ywDLrxzLBNq","sNbgtgG","yw1L","zwfIuLi","Dgv4Dc9WBge","rLryy2S","De1HBMfNzxi","ywX3yxLZ","ChjVDg9JB2W","zg5KDuK","vwfTwuS","C2v0zgi","s0r4C1G","BxfSz00","mtm2mJiXovPqtvvQAW","vNbLsvG","u2zYwxe","EefkDLa","AhPYzvm","t1H5B1O","q2vkC1O","yNz4Bwi","t0PXr0u","wgPQu1i","r2T2r0S","y2XVC2veqG","rMjnyMK","rxjYB3jdB2q","wMTzALm","reiGzMfPBgu","twzeCKW","AwrI","qw9euMe","yxrHlcbKyxq","q3vrDuC","zMzmAw5L","oxW1Fdf8ohW","tg9NsurozxC","EuzfqLq","vez4t1K","tKfusvzfx0u","yxnL","CNnVCKzPBgu","C3zpAwW","AuTdzKq","vKTfve0","BgLmy1K","A2D0quu","DxbNCMfKzw4","CgfNzwHPzgu","rwDjy00","ChvXvhe","yxPRtxu","twfpwwW","Dg9hzw5LCMe","Cg9PBNrbBMq","q0Xizfa","ihrPBwvVDxq","twnrCeG","C3bSAxq","DuTduK8","D0L2z0i","x0rctMfTzq","AujLzLa","EgnMtxa","A1viA0S","Dxn2wKq","u29pzM8","qw1VDw50","rfzbCuy","AgLNAa","zufJAW","q2DNt1G","ENDzBNO","rLjptLrjrvi","B25TzxnZywC","y1LVBwm","wxndzu4","nhWYFdn8mxW","x2vUzhbVAw4","r1n3zMG","BwLerKG","zNDVuvC","z1f3tMK","t2H5Dgi","ywLYvvK","x2LZsw5PDa","C3rLBMvYCW","q0TMDNq","A2jovMW","uMvJB25Uzwm","vLbkvfe","zMzMzG","zLPeqwq","B2fK","uLDnr2i","uNbPuue","sNjQt2C","Bg9N","Cfj1Eha","x2jPBMfYEvq","tNvnsee","swDKuKK","sKTkBgS","AxnrB1nnzxm","BMDuAw1LCG","nhWZFdb8mxW","AxmGDw5Kzwy","v1nUwM0","wMPhshe","Cw9Z","zxjYB3i","zwDiDvG","zM1fB1u","vKzHDgy","DhrMBxm","ywjVCNq","BePgzvq","B3bLBG","BwvY","yxv0B21HDgK","yw1Lu3bHy2u","r0XqD1K","sxzwAKe","Dg9Pz1u","vu1IB1q","svHRzLK","B0v1Dhy","y3jLyxrLt2i","v3rNBue","Ec1TC2CTCw8","zxrxB3jRq2G","BuXfAwW","D3jPDgvvAw4","AgHXq2e","qvHvtNi","qNjPzgDL","BgHcDg0","m3WXFdj8nhW","C0jf","tg9mEKy","zw9jDxO","rffRve0","B3jRig9MzMW","txj0rui","ig1LC3nHz2u","x2LZtM9Kzq","DK54Eey","twvZC2fNzuu","Efrurw52","vxjfrNC","C0XPC3rLBMu","t1npyuK","zerwr1G","teDVwKq","DcbSAw1PDa","rg5hDMu","x3bYzwzPEa","x3fVC0rc","AhboDNq","zxjFDhrS","AuvRCw4","zNP6Cgy","tMf5DxG","su92yNC","BhLvwuK","x2LUAxrhBg8","Au9LA0G","C3zIAfG","rfL6qui","Cu96zNO","yxKSihrYEsa","DLLeqM8","zNDZxZeUmc4","AgffEuy","A2DNq0y","ue1zzK8","y29UBMvJDca","v3r3yNi","uvfqAvi","u3LyzMS","pxv0zI04","zgf0yq","qKfLwfu","y3ruAw1LB3u","Ce9JBxy","x29UrxjYB3i","vLDeu3u","BwHJzxm","whjtre8","tLbysxq","BMrLEa","ue1QDgm","rNzqB3K","vNfNz0q","vw5PBxbSzw0","q3zLsxK","AuvjqKm","tKzIBfm","BwfW","q3vZDg9Tq2W","zeTisM4","AM12Efy","zw5HyMXLuw8","svPosNy","rNv4sgq","v1Dqr0u","zgvJB2rLzey","rwvPC3y","x3nLBMrby2S","C3zPywi","DvbYBvG","zgLZCgf0y2G","wwLqwvm","zvzlsMi","tNrlvhO","DLzmqvi","DwHPqNG","yxGGCMv0CMK","x2rLyNvN","BgLUzq","DgHLBG","wKDxyu8","t0fYz0i","Aw9U","tNjLsLm","s1zqAfC","q1jZte4","zwrPyxrLBhK","y2XVC2u","CgjICdi","vKrMAMG","CMvHzhDYAxq","y0jpyva","quXUt28","zNjVBuHHC2G","y2HHCKnVzgu","q09otKvdveK","yNL0zxm","q1HkyKm","BNvTyMvY","x29Uq2XVC2u","ALHkEMW","y3jLyxrLt3a","Aw9zr24","B25pCgvU","vKHTsxC","B25ozxr3B3i","D2fZq2XLyw4","x2rItMfTzq","tfvNuM0","DMHKDxe","C3vJy2vZCW","CNnVCL9Uyw0","BwvKAwf0zwW","wundvK0","C2vYDMLJzq","Aw50zwDLCIa","BMvY","uMvHzcbWyxm","rwTSDKG","qMHpB2W","CgvYC2LZDgu","yvvACgC","qwfSBNK","u0rXvve","A0vAv1i","Ae9Wzw5fDMu","q0ftEhu","x2LZtwLUAvC","tKXuBMK","EvjLtK8","D3jPDgu","uunXCxK","zgX2AfC","x2LUAxq","AxjTExe","BgzlEvi","uxHWvgq","ywXPzcb1CMW","x3jLBw92zvC","mNW2Fdr8mxW","CwTAyvK","zuHzt2m","sw5Osu4","AgHPtvy","rej5BhG","z0DoDw8","sfz5z1K","tgrmA2G","svbetMK","suviC2e","AgvHzgvY","ywnR","uuD0Ee0","Ehjqz0S","D0vXDLK","BgPqAhy","r3vjD1u","BwLUzW","nJmWmtC5mNjRrunfAa","B2jUr0y","wMfUrxO","zxjHDg9Y","B3vUDa","u1zvAxm","ywrK","x29WDgLVBNm","DMvYC2LVBG","zw50zwqGDhK","z2v0u3rVCMe","wKPsrwO","rNjVBNrPzxi","sfvyqNC","zxjFBxnNAwq","DKntswi","uKLRvwy","s0XgCuy","zv9ZDwnJzxm","zNjVBNrPzxi","rLrwzNO","Ec1TC2CTy3u","q2P6ANa","BgLZDgvUtMu","BNrLCG","qw5sDfi","DhbizwfKzxi","zLPNBvm","q1D1yxa","C3rYAw5N","BMrWB2LUDfq","AhDZCKK","mJu3ndq5oeXosK1SAG","wfjqDhe","Ahr5CNO","ihbYB3rVy28","x2rYB3bhBg8","DMDjqNq","CYbHBhjLywq","EvDgrue","igzHAwWSig0","yNvMzMvYzwq","DffttgC","t1zvAhm","wKvlv3e","zw1sB08","DgfIyxnL","EfvZzuvUDG","D09VsNG","u2T2CeO","sLr4D0S","D1vkD1C","B25VCgvU","wMjTDgG","zNjHBwvuExa","BMvJDa","thvIr0e","DeLK","x3bPBMDqB24","tgLZDgvUzxi","x3DZsw5ZDge","A2n1y2u","nJC5ntC4me1nCwfZvG","x2rLC3rYB3K","AwXSihvZzsa","Ahrjt3a","zxmGCMvHy2G","BK9QB3m","mNW0Fdf8m3W","Dhvqzu4","zv90Aw1LB3u","sfbPCwC","lcbTyxGGCMu","CMXRANu","y2HLy2TdDxi","CLvjvvC","AgvKtwf4uMu","CYbPBNn0yw4","C2LQAe0","Aw9Ul2PZB24","sKzYwge","rKDmDfy","EMfUveO","AgDzq2G","A3bot1u","A2zjwKW","zMLSDgvY","C2v0sxrLBq","BMCGB3iGyw4","C3vIC3rYAw4","zgvS","x2nYzwf0zvm","mtrAufHgs0q","ywnRx2nVzgu","BwLZzq","C1jtu1O","rLfnq0y","Agnfy24","B3b1vuq","ihjLy29UBMu","wuDSvMW","y29Kzq","igzPzwXKoIa","C3rVCcbPBw0","BefVt0S","CNzHBa","CvDetuO","tenzu0C","D2jOzgS","B25szwnLAxy","Cgv2zNO","tfnNre4","BxvvAge","rLbfq1G","EM9rtxO","CeHYt1q","zMrKCey","ywXSq3vYC28","ANbPuuK","x2zVCM1HDeu","DMvUDa","Dgv4Dc9Qyxy","y0zvsxK","AMvJDfn0B3i","Aw5KzxHpzG","y2HnyxHuCMK","B2nRzxrgywK","DevVugO","Ahr0Chm6","CMfTugfYyw0","qwjgwvK","z2v0qwXS","ExbL","x2n1CNnVCK0","y0HSAw8","tLvns1u","A0LLvwG","quTMuKe","A0n0B24","uMPpDM8","y29UBMvJDa","Aer5rNq","mdaWma","BvLMCKe","rMrxsu8","vuz1BhO","ANbMyuG","DNbAEuG","twTJuKO","vvn1u2u","BhzjvKS","s0XYqu0","tKPQuwy","zMXVB3i","qwLsCNu","DgHHBIbSB2m","BwLUAvbYB2C","Dw5ZAwDUzwq","AxbLBMm"];return or=function(){return n},or()}Object[C(437)+C(434)](se,C(1440)+"le",{value:!0})});var Je=ye((n_,sa)=>{"use strict";var ra=["nodebuffer","arraybuffer","fragments"],ia=typeof Blob<"u";ia&&ra.push("blob");sa.exports={BINARY_TYPES:ra,CLOSE_TIMEOUT:3e4,EMPTY_BUFFER:Buffer.alloc(0),GUID:"258EAFA5-E914-47DA-95CA-C5AB0DC85B11",hasBlob:ia,kForOnEventAttribute:Symbol("kIsForOnEventAttribute"),kListener:Symbol("kListener"),kStatusCode:Symbol("status-code"),kWebSocket:Symbol("websocket"),NOOP:()=>{}}});var un=ye((r_,ar)=>{"use strict";var{EMPTY_BUFFER:of}=Je(),gi=Buffer[Symbol.species];function af(n,e){if(n.length===0)return of;if(n.length===1)return n[0];let s=Buffer.allocUnsafe(e),o=0;for(let a=0;a<n.length;a++){let x=n[a];s.set(x,o),o+=x.length}return o<e?new gi(s.buffer,s.byteOffset,o):s}function oa(n,e,s,o,a){for(let x=0;x<a;x++)s[o+x]=n[x]^e[x&3]}function aa(n,e){for(let s=0;s<n.length;s++)n[s]^=e[s&3]}function cf(n){return n.length===n.buffer.byteLength?n.buffer:n.buffer.slice(n.byteOffset,n.byteOffset+n.length)}function hi(n){if(hi.readOnly=!0,Buffer.isBuffer(n))return n;let e;return n instanceof ArrayBuffer?e=new gi(n):ArrayBuffer.isView(n)?e=new gi(n.buffer,n.byteOffset,n.byteLength):(e=Buffer.from(n),hi.readOnly=!1),e}ar.exports={concat:af,mask:oa,toArrayBuffer:cf,toBuffer:hi,unmask:aa};if(!process.env.WS_NO_BUFFER_UTIL)try{let n=ee("bufferutil");ar.exports.mask=function(e,s,o,a,x){x<48?oa(e,s,o,a,x):n.mask(e,s,o,a,x)},ar.exports.unmask=function(e,s){e.length<32?aa(e,s):n.unmask(e,s)}}catch{}});var da=ye((i_,xa)=>{"use strict";var ca=Symbol("kDone"),pi=Symbol("kRun"),mi=class{constructor(e){this[ca]=()=>{this.pending--,this[pi]()},this.concurrency=e||1/0,this.jobs=[],this.pending=0}add(e){this.jobs.push(e),this[pi]()}[pi](){if(this.pending!==this.concurrency&&this.jobs.length){let e=this.jobs.shift();this.pending++,e(this[ca])}}};xa.exports=mi});var Ft=ye((s_,ga)=>{"use strict";var fn=ee("zlib"),ua=un(),xf=da(),{kStatusCode:fa}=Je(),df=Buffer[Symbol.species],uf=Buffer.from([0,0,255,255]),xr=Symbol("permessage-deflate"),Ve=Symbol("total-length"),Bt=Symbol("callback"),xt=Symbol("buffers"),zt=Symbol("error"),cr,wi=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,!cr){let s=this._options.concurrencyLimit!==void 0?this._options.concurrencyLimit:10;cr=new xf(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(a=>!(s.serverNoContextTakeover===!1&&a.server_no_context_takeover||a.server_max_window_bits&&(s.serverMaxWindowBits===!1||typeof s.serverMaxWindowBits=="number"&&s.serverMaxWindowBits>a.server_max_window_bits)||typeof s.clientMaxWindowBits=="number"&&!a.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 a=s[o];if(a.length>1)throw new Error(`Parameter "${o}" must have only a single value`);if(a=a[0],o==="client_max_window_bits"){if(a!==!0){let x=+a;if(!Number.isInteger(x)||x<8||x>15)throw new TypeError(`Invalid value for parameter "${o}": ${a}`);a=x}else if(!this._isServer)throw new TypeError(`Invalid value for parameter "${o}": ${a}`)}else if(o==="server_max_window_bits"){let x=+a;if(!Number.isInteger(x)||x<8||x>15)throw new TypeError(`Invalid value for parameter "${o}": ${a}`);a=x}else if(o==="client_no_context_takeover"||o==="server_no_context_takeover"){if(a!==!0)throw new TypeError(`Invalid value for parameter "${o}": ${a}`)}else throw new Error(`Unknown parameter "${o}"`);s[o]=a})}),e}decompress(e,s,o){cr.add(a=>{this._decompress(e,s,(x,u)=>{a(),o(x,u)})})}compress(e,s,o){cr.add(a=>{this._compress(e,s,(x,u)=>{a(),o(x,u)})})}_decompress(e,s,o){let a=this._isServer?"client":"server";if(!this._inflate){let x=`${a}_max_window_bits`,u=typeof this.params[x]!="number"?fn.Z_DEFAULT_WINDOWBITS:this.params[x];this._inflate=fn.createInflateRaw({...this._options.zlibInflateOptions,windowBits:u}),this._inflate[xr]=this,this._inflate[Ve]=0,this._inflate[xt]=[],this._inflate.on("error",lf),this._inflate.on("data",la)}this._inflate[Bt]=o,this._inflate.write(e),s&&this._inflate.write(uf),this._inflate.flush(()=>{let x=this._inflate[zt];if(x){this._inflate.close(),this._inflate=null,o(x);return}let u=ua.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[`${a}_no_context_takeover`]&&this._inflate.reset()),o(null,u)})}_compress(e,s,o){let a=this._isServer?"server":"client";if(!this._deflate){let x=`${a}_max_window_bits`,u=typeof this.params[x]!="number"?fn.Z_DEFAULT_WINDOWBITS:this.params[x];this._deflate=fn.createDeflateRaw({...this._options.zlibDeflateOptions,windowBits:u}),this._deflate[Ve]=0,this._deflate[xt]=[],this._deflate.on("data",ff)}this._deflate[Bt]=o,this._deflate.write(e),this._deflate.flush(fn.Z_SYNC_FLUSH,()=>{if(!this._deflate)return;let x=ua.concat(this._deflate[xt],this._deflate[Ve]);s&&(x=new df(x.buffer,x.byteOffset,x.length-4)),this._deflate[Bt]=null,this._deflate[Ve]=0,this._deflate[xt]=[],s&&this.params[`${a}_no_context_takeover`]&&this._deflate.reset(),o(null,x)})}};ga.exports=wi;function ff(n){this[xt].push(n),this[Ve]+=n.length}function la(n){if(this[Ve]+=n.length,this[xr]._maxPayload<1||this[Ve]<=this[xr]._maxPayload){this[xt].push(n);return}this[zt]=new RangeError("Max payload size exceeded"),this[zt].code="WS_ERR_UNSUPPORTED_MESSAGE_LENGTH",this[zt][fa]=1009,this.removeListener("data",la),this.reset()}function lf(n){if(this[xr]._inflate=null,this[zt]){this[Bt](this[zt]);return}n[fa]=1007,this[Bt](n)}});var Ut=ye((o_,dr)=>{"use strict";var{isUtf8:ha}=ee("buffer"),{hasBlob:gf}=Je(),hf=[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 pf(n){return n>=1e3&&n<=1014&&n!==1004&&n!==1005&&n!==1006||n>=3e3&&n<=4999}function _i(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 mf(n){return gf&&typeof n=="object"&&typeof n.arrayBuffer=="function"&&typeof n.type=="string"&&typeof n.stream=="function"&&(n[Symbol.toStringTag]==="Blob"||n[Symbol.toStringTag]==="File")}dr.exports={isBlob:mf,isValidStatusCode:pf,isValidUTF8:_i,tokenChars:hf};if(ha)dr.exports.isValidUTF8=function(n){return n.length<24?_i(n):ha(n)};else if(!process.env.WS_NO_UTF_8_VALIDATE)try{let n=ee("utf-8-validate");dr.exports.isValidUTF8=function(e){return e.length<32?_i(e):n(e)}}catch{}});var Ei=ye((a_,va)=>{"use strict";var{Writable:wf}=ee("stream"),pa=Ft(),{BINARY_TYPES:_f,EMPTY_BUFFER:ma,kStatusCode:yf,kWebSocket:bf}=Je(),{concat:yi,toArrayBuffer:vf,unmask:Sf}=un(),{isValidStatusCode:Ef,isValidUTF8:wa}=Ut(),ur=Buffer[Symbol.species],Pe=0,_a=1,ya=2,ba=3,bi=4,vi=5,fr=6,Si=class extends wf{constructor(e={}){super(),this._allowSynchronousEvents=e.allowSynchronousEvents!==void 0?e.allowSynchronousEvents:!0,this._binaryType=e.binaryType||_f[0],this._extensions=e.extensions||{},this._isServer=!!e.isServer,this._maxPayload=e.maxPayload|0,this._skipUTF8Validation=!!e.skipUTF8Validation,this[bf]=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 ur(o.buffer,o.byteOffset+e,o.length-e),new ur(o.buffer,o.byteOffset,e)}let s=Buffer.allocUnsafe(e);do{let o=this._buffers[0],a=s.length-e;e>=o.length?s.set(this._buffers.shift(),a):(s.set(new Uint8Array(o.buffer,o.byteOffset,e),a),this._buffers[0]=new ur(o.buffer,o.byteOffset+e,o.length-e)),e-=o.length}while(e>0);return s}startLoop(e){this._loop=!0;do switch(this._state){case Pe:this.getInfo(e);break;case _a:this.getPayloadLength16(e);break;case ya:this.getPayloadLength64(e);break;case ba:this.getMask();break;case bi:this.getData(e);break;case vi:case fr: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 a=this.createError(RangeError,"RSV2 and RSV3 must be clear",!0,1002,"WS_ERR_UNEXPECTED_RSV_2_3");e(a);return}let o=(s[0]&64)===64;if(o&&!this._extensions[pa.extensionName]){let a=this.createError(RangeError,"RSV1 must be clear",!0,1002,"WS_ERR_UNEXPECTED_RSV_1");e(a);return}if(this._fin=(s[0]&128)===128,this._opcode=s[0]&15,this._payloadLength=s[1]&127,this._opcode===0){if(o){let a=this.createError(RangeError,"RSV1 must be clear",!0,1002,"WS_ERR_UNEXPECTED_RSV_1");e(a);return}if(!this._fragmented){let a=this.createError(RangeError,"invalid opcode 0",!0,1002,"WS_ERR_INVALID_OPCODE");e(a);return}this._opcode=this._fragmented}else if(this._opcode===1||this._opcode===2){if(this._fragmented){let a=this.createError(RangeError,`invalid opcode ${this._opcode}`,!0,1002,"WS_ERR_INVALID_OPCODE");e(a);return}this._compressed=o}else if(this._opcode>7&&this._opcode<11){if(!this._fin){let a=this.createError(RangeError,"FIN must be set",!0,1002,"WS_ERR_EXPECTED_FIN");e(a);return}if(o){let a=this.createError(RangeError,"RSV1 must be clear",!0,1002,"WS_ERR_UNEXPECTED_RSV_1");e(a);return}if(this._payloadLength>125||this._opcode===8&&this._payloadLength===1){let a=this.createError(RangeError,`invalid payload length ${this._payloadLength}`,!0,1002,"WS_ERR_INVALID_CONTROL_PAYLOAD_LENGTH");e(a);return}}else{let a=this.createError(RangeError,`invalid opcode ${this._opcode}`,!0,1002,"WS_ERR_INVALID_OPCODE");e(a);return}if(!this._fin&&!this._fragmented&&(this._fragmented=this._opcode),this._masked=(s[1]&128)===128,this._isServer){if(!this._masked){let a=this.createError(RangeError,"MASK must be set",!0,1002,"WS_ERR_EXPECTED_MASK");e(a);return}}else if(this._masked){let a=this.createError(RangeError,"MASK must be clear",!0,1002,"WS_ERR_UNEXPECTED_MASK");e(a);return}this._payloadLength===126?this._state=_a:this._payloadLength===127?this._state=ya:this.haveLength(e)}getPayloadLength16(e){if(this._bufferedBytes<2){this._loop=!1;return}this._payloadLength=this.consume(2).readUInt16BE(0),this.haveLength(e)}getPayloadLength64(e){if(this._bufferedBytes<8){this._loop=!1;return}let s=this.consume(8),o=s.readUInt32BE(0);if(o>Math.pow(2,21)-1){let a=this.createError(RangeError,"Unsupported WebSocket frame: payload length > 2^53 - 1",!1,1009,"WS_ERR_UNSUPPORTED_DATA_PAYLOAD_LENGTH");e(a);return}this._payloadLength=o*Math.pow(2,32)+s.readUInt32BE(4),this.haveLength(e)}haveLength(e){if(this._payloadLength&&this._opcode<8&&(this._totalPayloadLength+=this._payloadLength,this._totalPayloadLength>this._maxPayload&&this._maxPayload>0)){let s=this.createError(RangeError,"Max payload size exceeded",!1,1009,"WS_ERR_UNSUPPORTED_MESSAGE_LENGTH");e(s);return}this._masked?this._state=ba:this._state=bi}getMask(){if(this._bufferedBytes<4){this._loop=!1;return}this._mask=this.consume(4),this._state=bi}getData(e){let s=ma;if(this._payloadLength){if(this._bufferedBytes<this._payloadLength){this._loop=!1;return}s=this.consume(this._payloadLength),this._masked&&(this._mask[0]|this._mask[1]|this._mask[2]|this._mask[3])!==0&&Sf(s,this._mask)}if(this._opcode>7){this.controlMessage(s,e);return}if(this._compressed){this._state=vi,this.decompress(s,e);return}s.length&&(this._messageLength=this._totalPayloadLength,this._fragments.push(s)),this.dataMessage(e)}decompress(e,s){this._extensions[pa.extensionName].decompress(e,this._fin,(a,x)=>{if(a)return s(a);if(x.length){if(this._messageLength+=x.length,this._messageLength>this._maxPayload&&this._maxPayload>0){let u=this.createError(RangeError,"Max payload size exceeded",!1,1009,"WS_ERR_UNSUPPORTED_MESSAGE_LENGTH");s(u);return}this._fragments.push(x)}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 a;this._binaryType==="nodebuffer"?a=yi(o,s):this._binaryType==="arraybuffer"?a=vf(yi(o,s)):this._binaryType==="blob"?a=new Blob(o):a=o,this._allowSynchronousEvents?(this.emit("message",a,!0),this._state=Pe):(this._state=fr,setImmediate(()=>{this.emit("message",a,!0),this._state=Pe,this.startLoop(e)}))}else{let a=yi(o,s);if(!this._skipUTF8Validation&&!wa(a)){let x=this.createError(Error,"invalid UTF-8 sequence",!0,1007,"WS_ERR_INVALID_UTF8");e(x);return}this._state===vi||this._allowSynchronousEvents?(this.emit("message",a,!1),this._state=Pe):(this._state=fr,setImmediate(()=>{this.emit("message",a,!1),this._state=Pe,this.startLoop(e)}))}}controlMessage(e,s){if(this._opcode===8){if(e.length===0)this._loop=!1,this.emit("conclude",1005,ma),this.end();else{let o=e.readUInt16BE(0);if(!Ef(o)){let x=this.createError(RangeError,`invalid status code ${o}`,!0,1002,"WS_ERR_INVALID_CLOSE_CODE");s(x);return}let a=new ur(e.buffer,e.byteOffset+2,e.length-2);if(!this._skipUTF8Validation&&!wa(a)){let x=this.createError(Error,"invalid UTF-8 sequence",!0,1007,"WS_ERR_INVALID_UTF8");s(x);return}this._loop=!1,this.emit("conclude",o,a),this.end()}this._state=Pe;return}this._allowSynchronousEvents?(this.emit(this._opcode===9?"ping":"pong",e),this._state=Pe):(this._state=fr,setImmediate(()=>{this.emit(this._opcode===9?"ping":"pong",e),this._state=Pe,this.startLoop(s)}))}createError(e,s,o,a,x){this._loop=!1,this._errored=!0;let u=new e(o?`Invalid WebSocket frame: ${s}`:s);return Error.captureStackTrace(u,this.createError),u.code=x,u[yf]=a,u}};va.exports=Si});var Ii=ye((x_,Aa)=>{"use strict";var{Duplex:c_}=ee("stream"),{randomFillSync:Af}=ee("crypto"),Sa=Ft(),{EMPTY_BUFFER:Cf,kWebSocket:If,NOOP:Pf}=Je(),{isBlob:qt,isValidStatusCode:kf}=Ut(),{mask:Ea,toBuffer:ht}=un(),ke=Symbol("kByteLength"),Tf=Buffer.alloc(4),lr=8*1024,pt,Ht=lr,Re=0,Df=1,Rf=2,Ai=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=Pf,this[If]=void 0}static frame(e,s){let o,a=!1,x=2,u=!1;s.mask&&(o=s.maskBuffer||Tf,s.generateMask?s.generateMask(o):(Ht===lr&&(pt===void 0&&(pt=Buffer.alloc(lr)),Af(pt,0,lr),Ht=0),o[0]=pt[Ht++],o[1]=pt[Ht++],o[2]=pt[Ht++],o[3]=pt[Ht++]),u=(o[0]|o[1]|o[2]|o[3])===0,x=6);let f;typeof e=="string"?(!s.mask||u)&&s[ke]!==void 0?f=s[ke]:(e=Buffer.from(e),f=e.length):(f=e.length,a=s.mask&&s.readOnly&&!u);let g=f;f>=65536?(x+=8,g=127):f>125&&(x+=2,g=126);let p=Buffer.allocUnsafe(a?f+x:x);return p[0]=s.fin?s.opcode|128:s.opcode,s.rsv1&&(p[0]|=64),p[1]=g,g===126?p.writeUInt16BE(f,2):g===127&&(p[2]=p[3]=0,p.writeUIntBE(f,4,6)),s.mask?(p[1]|=128,p[x-4]=o[0],p[x-3]=o[1],p[x-2]=o[2],p[x-1]=o[3],u?[p,e]:a?(Ea(e,o,p,x,f),[p]):(Ea(e,o,e,0,f),[p,e])):[p,e]}close(e,s,o,a){let x;if(e===void 0)x=Cf;else{if(typeof e!="number"||!kf(e))throw new TypeError("First argument must be a valid error code number");if(s===void 0||!s.length)x=Buffer.allocUnsafe(2),x.writeUInt16BE(e,0);else{let f=Buffer.byteLength(s);if(f>123)throw new RangeError("The message must not be greater than 123 bytes");x=Buffer.allocUnsafe(2+f),x.writeUInt16BE(e,0),typeof s=="string"?x.write(s,2):x.set(s,2)}}let u={[ke]:x.length,fin:!0,generateMask:this._generateMask,mask:o,maskBuffer:this._maskBuffer,opcode:8,readOnly:!1,rsv1:!1};this._state!==Re?this.enqueue([this.dispatch,x,!1,u,a]):this.sendFrame(n.frame(x,u),a)}ping(e,s,o){let a,x;if(typeof e=="string"?(a=Buffer.byteLength(e),x=!1):qt(e)?(a=e.size,x=!1):(e=ht(e),a=e.length,x=ht.readOnly),a>125)throw new RangeError("The data size must not be greater than 125 bytes");let u={[ke]:a,fin:!0,generateMask:this._generateMask,mask:s,maskBuffer:this._maskBuffer,opcode:9,readOnly:x,rsv1:!1};qt(e)?this._state!==Re?this.enqueue([this.getBlobData,e,!1,u,o]):this.getBlobData(e,!1,u,o):this._state!==Re?this.enqueue([this.dispatch,e,!1,u,o]):this.sendFrame(n.frame(e,u),o)}pong(e,s,o){let a,x;if(typeof e=="string"?(a=Buffer.byteLength(e),x=!1):qt(e)?(a=e.size,x=!1):(e=ht(e),a=e.length,x=ht.readOnly),a>125)throw new RangeError("The data size must not be greater than 125 bytes");let u={[ke]:a,fin:!0,generateMask:this._generateMask,mask:s,maskBuffer:this._maskBuffer,opcode:10,readOnly:x,rsv1:!1};qt(e)?this._state!==Re?this.enqueue([this.getBlobData,e,!1,u,o]):this.getBlobData(e,!1,u,o):this._state!==Re?this.enqueue([this.dispatch,e,!1,u,o]):this.sendFrame(n.frame(e,u),o)}send(e,s,o){let a=this._extensions[Sa.extensionName],x=s.binary?2:1,u=s.compress,f,g;typeof e=="string"?(f=Buffer.byteLength(e),g=!1):qt(e)?(f=e.size,g=!1):(e=ht(e),f=e.length,g=ht.readOnly),this._firstFragment?(this._firstFragment=!1,u&&a&&a.params[a._isServer?"server_no_context_takeover":"client_no_context_takeover"]&&(u=f>=a._threshold),this._compress=u):(u=!1,x=0),s.fin&&(this._firstFragment=!0);let p={[ke]:f,fin:s.fin,generateMask:this._generateMask,mask:s.mask,maskBuffer:this._maskBuffer,opcode:x,readOnly:g,rsv1:u};qt(e)?this._state!==Re?this.enqueue([this.getBlobData,e,this._compress,p,o]):this.getBlobData(e,this._compress,p,o):this._state!==Re?this.enqueue([this.dispatch,e,this._compress,p,o]):this.dispatch(e,this._compress,p,o)}getBlobData(e,s,o,a){this._bufferedBytes+=o[ke],this._state=Rf,e.arrayBuffer().then(x=>{if(this._socket.destroyed){let f=new Error("The socket was closed while the blob was being read");process.nextTick(Ci,this,f,a);return}this._bufferedBytes-=o[ke];let u=ht(x);s?this.dispatch(u,s,o,a):(this._state=Re,this.sendFrame(n.frame(u,o),a),this.dequeue())}).catch(x=>{process.nextTick(Of,this,x,a)})}dispatch(e,s,o,a){if(!s){this.sendFrame(n.frame(e,o),a);return}let x=this._extensions[Sa.extensionName];this._bufferedBytes+=o[ke],this._state=Df,x.compress(e,o.fin,(u,f)=>{if(this._socket.destroyed){let g=new Error("The socket was closed while data was being compressed");Ci(this,g,a);return}this._bufferedBytes-=o[ke],this._state=Re,o.readOnly=!1,this.sendFrame(n.frame(f,o),a),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)}};Aa.exports=Ai;function Ci(n,e,s){typeof s=="function"&&s(e);for(let o=0;o<n._queue.length;o++){let a=n._queue[o],x=a[a.length-1];typeof x=="function"&&x(e)}}function Of(n,e,s){Ci(n,e,s),n.onerror(e)}});var Na=ye((d_,Oa)=>{"use strict";var{kForOnEventAttribute:ln,kListener:Pi}=Je(),Ca=Symbol("kCode"),Ia=Symbol("kData"),Pa=Symbol("kError"),ka=Symbol("kMessage"),Ta=Symbol("kReason"),Gt=Symbol("kTarget"),Da=Symbol("kType"),Ra=Symbol("kWasClean"),Ye=class{constructor(e){this[Gt]=null,this[Da]=e}get target(){return this[Gt]}get type(){return this[Da]}};Object.defineProperty(Ye.prototype,"target",{enumerable:!0});Object.defineProperty(Ye.prototype,"type",{enumerable:!0});var mt=class extends Ye{constructor(e,s={}){super(e),this[Ca]=s.code===void 0?0:s.code,this[Ta]=s.reason===void 0?"":s.reason,this[Ra]=s.wasClean===void 0?!1:s.wasClean}get code(){return this[Ca]}get reason(){return this[Ta]}get wasClean(){return this[Ra]}};Object.defineProperty(mt.prototype,"code",{enumerable:!0});Object.defineProperty(mt.prototype,"reason",{enumerable:!0});Object.defineProperty(mt.prototype,"wasClean",{enumerable:!0});var Kt=class extends Ye{constructor(e,s={}){super(e),this[Pa]=s.error===void 0?null:s.error,this[ka]=s.message===void 0?"":s.message}get error(){return this[Pa]}get message(){return this[ka]}};Object.defineProperty(Kt.prototype,"error",{enumerable:!0});Object.defineProperty(Kt.prototype,"message",{enumerable:!0});var gn=class extends Ye{constructor(e,s={}){super(e),this[Ia]=s.data===void 0?null:s.data}get data(){return this[Ia]}};Object.defineProperty(gn.prototype,"data",{enumerable:!0});var Nf={addEventListener(n,e,s={}){for(let a of this.listeners(n))if(!s[ln]&&a[Pi]===e&&!a[ln])return;let o;if(n==="message")o=function(x,u){let f=new gn("message",{data:u?x:x.toString()});f[Gt]=this,gr(e,this,f)};else if(n==="close")o=function(x,u){let f=new mt("close",{code:x,reason:u.toString(),wasClean:this._closeFrameReceived&&this._closeFrameSent});f[Gt]=this,gr(e,this,f)};else if(n==="error")o=function(x){let u=new Kt("error",{error:x,message:x.message});u[Gt]=this,gr(e,this,u)};else if(n==="open")o=function(){let x=new Ye("open");x[Gt]=this,gr(e,this,x)};else return;o[ln]=!!s[ln],o[Pi]=e,s.once?this.once(n,o):this.on(n,o)},removeEventListener(n,e){for(let s of this.listeners(n))if(s[Pi]===e&&!s[ln]){this.removeListener(n,s);break}}};Oa.exports={CloseEvent:mt,ErrorEvent:Kt,Event:Ye,EventTarget:Nf,MessageEvent:gn};function gr(n,e,s){typeof n=="object"&&n.handleEvent?n.handleEvent.call(n,s):n.call(e,s)}});var hr=ye((u_,La)=>{"use strict";var{tokenChars:hn}=Ut();function He(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,a=!1,x=!1,u,f,g=-1,p=-1,_=-1,w=0;for(;w<n.length;w++)if(p=n.charCodeAt(w),u===void 0)if(_===-1&&hn[p]===1)g===-1&&(g=w);else if(w!==0&&(p===32||p===9))_===-1&&g!==-1&&(_=w);else if(p===59||p===44){if(g===-1)throw new SyntaxError(`Unexpected character at index ${w}`);_===-1&&(_=w);let T=n.slice(g,_);p===44?(He(e,T,s),s=Object.create(null)):u=T,g=_=-1}else throw new SyntaxError(`Unexpected character at index ${w}`);else if(f===void 0)if(_===-1&&hn[p]===1)g===-1&&(g=w);else if(p===32||p===9)_===-1&&g!==-1&&(_=w);else if(p===59||p===44){if(g===-1)throw new SyntaxError(`Unexpected character at index ${w}`);_===-1&&(_=w),He(s,n.slice(g,_),!0),p===44&&(He(e,u,s),s=Object.create(null),u=void 0),g=_=-1}else if(p===61&&g!==-1&&_===-1)f=n.slice(g,w),g=_=-1;else throw new SyntaxError(`Unexpected character at index ${w}`);else if(a){if(hn[p]!==1)throw new SyntaxError(`Unexpected character at index ${w}`);g===-1?g=w:o||(o=!0),a=!1}else if(x)if(hn[p]===1)g===-1&&(g=w);else if(p===34&&g!==-1)x=!1,_=w;else if(p===92)a=!0;else throw new SyntaxError(`Unexpected character at index ${w}`);else if(p===34&&n.charCodeAt(w-1)===61)x=!0;else if(_===-1&&hn[p]===1)g===-1&&(g=w);else if(g!==-1&&(p===32||p===9))_===-1&&(_=w);else if(p===59||p===44){if(g===-1)throw new SyntaxError(`Unexpected character at index ${w}`);_===-1&&(_=w);let T=n.slice(g,_);o&&(T=T.replace(/\\/g,""),o=!1),He(s,f,T),p===44&&(He(e,u,s),s=Object.create(null),u=void 0),f=void 0,g=_=-1}else throw new SyntaxError(`Unexpected character at index ${w}`);if(g===-1||x||p===32||p===9)throw new SyntaxError("Unexpected end of input");_===-1&&(_=w);let E=n.slice(g,_);return u===void 0?He(e,E,s):(f===void 0?He(s,E,!0):o?He(s,f,E.replace(/\\/g,"")):He(s,f,E),He(e,u,s)),e}function Mf(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(a=>{let x=o[a];return Array.isArray(x)||(x=[x]),x.map(u=>u===!0?a:`${a}=${u}`).join("; ")})).join("; ")).join(", ")}).join(", ")}La.exports={format:Mf,parse:Lf}});var _r=ye((g_,$a)=>{"use strict";var Bf=ee("events"),zf=ee("https"),Ff=ee("http"),za=ee("net"),Uf=ee("tls"),{randomBytes:qf,createHash:Hf}=ee("crypto"),{Duplex:f_,Readable:l_}=ee("stream"),{URL:ki}=ee("url"),dt=Ft(),Gf=Ei(),Kf=Ii(),{isBlob:jf}=Ut(),{BINARY_TYPES:Ma,CLOSE_TIMEOUT:Wf,EMPTY_BUFFER:pr,GUID:$f,kForOnEventAttribute:Ti,kListener:Jf,kStatusCode:Vf,kWebSocket:xe,NOOP:Fa}=Je(),{EventTarget:{addEventListener:Yf,removeEventListener:Xf}}=Na(),{format:Qf,parse:Zf}=hr(),{toBuffer:el}=un(),Ua=Symbol("kAborted"),Di=[8,13],Xe=["CONNECTING","OPEN","CLOSING","CLOSED"],tl=/^[!#$%&'*+\-.0-9A-Z^_`|a-z~]+$/,$=class n extends Bf{constructor(e,s,o){super(),this._binaryType=Ma[0],this._closeCode=1006,this._closeFrameReceived=!1,this._closeFrameSent=!1,this._closeMessage=pr,this._closeTimer=null,this._errorEmitted=!1,this._extensions={},this._paused=!1,this._protocol="",this._readyState=n.CONNECTING,this._receiver=null,this._sender=null,this._socket=null,e!==null?(this._bufferedAmount=0,this._isServer=!1,this._redirects=0,s===void 0?s=[]:Array.isArray(s)||(typeof s=="object"&&s!==null?(o=s,s=[]):s=[s]),qa(this,e,s,o)):(this._autoPong=o.autoPong,this._closeTimeout=o.closeTimeout,this._isServer=!0)}get binaryType(){return this._binaryType}set binaryType(e){Ma.includes(e)&&(this._binaryType=e,this._receiver&&(this._receiver._binaryType=e))}get bufferedAmount(){return this._socket?this._socket._writableState.length+this._sender._bufferedBytes:this._bufferedAmount}get extensions(){return Object.keys(this._extensions).join()}get isPaused(){return this._paused}get onclose(){return null}get onerror(){return null}get onopen(){return null}get onmessage(){return null}get protocol(){return this._protocol}get readyState(){return this._readyState}get url(){return this._url}setSocket(e,s,o){let a=new Gf({allowSynchronousEvents:o.allowSynchronousEvents,binaryType:this.binaryType,extensions:this._extensions,isServer:this._isServer,maxPayload:o.maxPayload,skipUTF8Validation:o.skipUTF8Validation}),x=new Kf(e,this._extensions,o.generateMask);this._receiver=a,this._sender=x,this._socket=e,a[xe]=this,x[xe]=this,e[xe]=this,a.on("conclude",il),a.on("drain",sl),a.on("error",ol),a.on("message",al),a.on("ping",cl),a.on("pong",xl),x.onerror=dl,e.setTimeout&&e.setTimeout(0),e.setNoDelay&&e.setNoDelay(),s.length>0&&e.unshift(s),e.on("close",Ka),e.on("data",wr),e.on("end",ja),e.on("error",Wa),this._readyState=n.OPEN,this.emit("open")}emitClose(){if(!this._socket){this._readyState=n.CLOSED,this.emit("close",this._closeCode,this._closeMessage);return}this._extensions[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){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())}),Ga(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){Ri(this,e,o);return}s===void 0&&(s=!this._isServer),this._sender.ping(e||pr,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){Ri(this,e,o);return}s===void 0&&(s=!this._isServer),this._sender.pong(e||pr,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){Ri(this,e,o);return}let a={binary:typeof e!="string",mask:!this._isServer,compress:!0,fin:!0,...s};this._extensions[dt.extensionName]||(a.compress=!1),this._sender.send(e||pr,a,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($,"CONNECTING",{enumerable:!0,value:Xe.indexOf("CONNECTING")});Object.defineProperty($.prototype,"CONNECTING",{enumerable:!0,value:Xe.indexOf("CONNECTING")});Object.defineProperty($,"OPEN",{enumerable:!0,value:Xe.indexOf("OPEN")});Object.defineProperty($.prototype,"OPEN",{enumerable:!0,value:Xe.indexOf("OPEN")});Object.defineProperty($,"CLOSING",{enumerable:!0,value:Xe.indexOf("CLOSING")});Object.defineProperty($.prototype,"CLOSING",{enumerable:!0,value:Xe.indexOf("CLOSING")});Object.defineProperty($,"CLOSED",{enumerable:!0,value:Xe.indexOf("CLOSED")});Object.defineProperty($.prototype,"CLOSED",{enumerable:!0,value:Xe.indexOf("CLOSED")});["binaryType","bufferedAmount","extensions","isPaused","protocol","readyState","url"].forEach(n=>{Object.defineProperty($.prototype,n,{enumerable:!0})});["open","error","close","message"].forEach(n=>{Object.defineProperty($.prototype,`on${n}`,{enumerable:!0,get(){for(let e of this.listeners(n))if(e[Ti])return e[Jf];return null},set(e){for(let s of this.listeners(n))if(s[Ti]){this.removeListener(n,s);break}typeof e=="function"&&this.addEventListener(n,e,{[Ti]:!0})}})});$.prototype.addEventListener=Yf;$.prototype.removeEventListener=Xf;$a.exports=$;function qa(n,e,s,o){let a={allowSynchronousEvents:!0,autoPong:!0,closeTimeout:Wf,protocolVersion:Di[1],maxPayload:104857600,skipUTF8Validation:!1,perMessageDeflate:!0,followRedirects:!1,maxRedirects:10,...o,socketPath:void 0,hostname:void 0,protocol:void 0,timeout:void 0,method:"GET",host:void 0,path:void 0,port:void 0};if(n._autoPong=a.autoPong,n._closeTimeout=a.closeTimeout,!Di.includes(a.protocolVersion))throw new RangeError(`Unsupported protocol version: ${a.protocolVersion} (supported versions: ${Di.join(", ")})`);let x;if(e instanceof ki)x=e;else try{x=new ki(e)}catch{throw new SyntaxError(`Invalid URL: ${e}`)}x.protocol==="http:"?x.protocol="ws:":x.protocol==="https:"&&(x.protocol="wss:"),n._url=x.href;let u=x.protocol==="wss:",f=x.protocol==="ws+unix:",g;if(x.protocol!=="ws:"&&!u&&!f?g=`The URL's protocol must be one of "ws:", "wss:", "http:", "https:", or "ws+unix:"`:f&&!x.pathname?g="The URL's pathname is empty":x.hash&&(g="The URL contains a fragment identifier"),g){let P=new SyntaxError(g);if(n._redirects===0)throw P;mr(n,P);return}let p=u?443:80,_=qf(16).toString("base64"),w=u?zf.request:Ff.request,E=new Set,T;if(a.createConnection=a.createConnection||(u?rl:nl),a.defaultPort=a.defaultPort||p,a.port=x.port||p,a.host=x.hostname.startsWith("[")?x.hostname.slice(1,-1):x.hostname,a.headers={...a.headers,"Sec-WebSocket-Version":a.protocolVersion,"Sec-WebSocket-Key":_,Connection:"Upgrade",Upgrade:"websocket"},a.path=x.pathname+x.search,a.timeout=a.handshakeTimeout,a.perMessageDeflate&&(T=new dt({...a.perMessageDeflate,isServer:!1,maxPayload:a.maxPayload}),a.headers["Sec-WebSocket-Extensions"]=Qf({[dt.extensionName]:T.offer()})),s.length){for(let P of s){if(typeof P!="string"||!tl.test(P)||E.has(P))throw new SyntaxError("An invalid or duplicated subprotocol was specified");E.add(P)}a.headers["Sec-WebSocket-Protocol"]=s.join(",")}if(a.origin&&(a.protocolVersion<13?a.headers["Sec-WebSocket-Origin"]=a.origin:a.headers.Origin=a.origin),(x.username||x.password)&&(a.auth=`${x.username}:${x.password}`),f){let P=a.path.split(":");a.socketPath=P[0],a.path=P[1]}let k;if(a.followRedirects){if(n._redirects===0){n._originalIpc=f,n._originalSecure=u,n._originalHostOrSocketPath=f?a.socketPath:x.host;let P=o&&o.headers;if(o={...o,headers:{}},P)for(let[H,X]of Object.entries(P))o.headers[H.toLowerCase()]=X}else if(n.listenerCount("redirect")===0){let P=f?n._originalIpc?a.socketPath===n._originalHostOrSocketPath:!1:n._originalIpc?!1:x.host===n._originalHostOrSocketPath;(!P||n._originalSecure&&!u)&&(delete a.headers.authorization,delete a.headers.cookie,P||delete a.headers.host,a.auth=void 0)}a.auth&&!o.headers.authorization&&(o.headers.authorization="Basic "+Buffer.from(a.auth).toString("base64")),k=n._req=w(a),n._redirects&&n.emit("redirect",n.url,k)}else k=n._req=w(a);a.timeout&&k.on("timeout",()=>{Ee(n,k,"Opening handshake has timed out")}),k.on("error",P=>{k===null||k[Ua]||(k=n._req=null,mr(n,P))}),k.on("response",P=>{let H=P.headers.location,X=P.statusCode;if(H&&a.followRedirects&&X>=300&&X<400){if(++n._redirects>a.maxRedirects){Ee(n,k,"Maximum redirects exceeded");return}k.abort();let K;try{K=new ki(H,e)}catch{let oe=new SyntaxError(`Invalid URL: ${H}`);mr(n,oe);return}qa(n,K,s,o)}else n.emit("unexpected-response",k,P)||Ee(n,k,`Unexpected server response: ${P.statusCode}`)}),k.on("upgrade",(P,H,X)=>{if(n.emit("upgrade",P),n.readyState!==$.CONNECTING)return;k=n._req=null;let K=P.headers.upgrade;if(K===void 0||K.toLowerCase()!=="websocket"){Ee(n,H,"Invalid Upgrade header");return}let J=Hf("sha1").update(_+$f).digest("base64");if(P.headers["sec-websocket-accept"]!==J){Ee(n,H,"Invalid Sec-WebSocket-Accept header");return}let oe=P.headers["sec-websocket-protocol"],ae;if(oe!==void 0?E.size?E.has(oe)||(ae="Server sent an invalid subprotocol"):ae="Server sent a subprotocol but none was requested":E.size&&(ae="Server sent no subprotocol"),ae){Ee(n,H,ae);return}oe&&(n._protocol=oe);let Te=P.headers["sec-websocket-extensions"];if(Te!==void 0){if(!T){Ee(n,H,"Server sent a Sec-WebSocket-Extensions header but no extension was requested");return}let me;try{me=Zf(Te)}catch{Ee(n,H,"Invalid Sec-WebSocket-Extensions header");return}let de=Object.keys(me);if(de.length!==1||de[0]!==dt.extensionName){Ee(n,H,"Server indicated an extension that was not requested");return}try{T.accept(me[dt.extensionName])}catch{Ee(n,H,"Invalid Sec-WebSocket-Extensions header");return}n._extensions[dt.extensionName]=T}n.setSocket(H,X,{allowSynchronousEvents:a.allowSynchronousEvents,generateMask:a.generateMask,maxPayload:a.maxPayload,skipUTF8Validation:a.skipUTF8Validation})}),a.finishRequest?a.finishRequest(k,n):k.end()}function mr(n,e){n._readyState=$.CLOSING,n._errorEmitted=!0,n.emit("error",e),n.emitClose()}function nl(n){return n.path=n.socketPath,za.connect(n)}function rl(n){return n.path=void 0,!n.servername&&n.servername!==""&&(n.servername=za.isIP(n.host)?"":n.host),Uf.connect(n)}function Ee(n,e,s){n._readyState=$.CLOSING;let o=new Error(s);Error.captureStackTrace(o,Ee),e.setHeader?(e[Ua]=!0,e.abort(),e.socket&&!e.socket.destroyed&&e.socket.destroy(),process.nextTick(mr,n,o)):(e.destroy(o),e.once("error",n.emit.bind(n,"error")),e.once("close",n.emitClose.bind(n)))}function Ri(n,e,s){if(e){let o=jf(e)?e.size:el(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 il(n,e){let s=this[xe];s._closeFrameReceived=!0,s._closeMessage=e,s._closeCode=n,s._socket[xe]!==void 0&&(s._socket.removeListener("data",wr),process.nextTick(Ha,s._socket),n===1005?s.close():s.close(n,e))}function sl(){let n=this[xe];n.isPaused||n._socket.resume()}function ol(n){let e=this[xe];e._socket[xe]!==void 0&&(e._socket.removeListener("data",wr),process.nextTick(Ha,e._socket),e.close(n[Vf])),e._errorEmitted||(e._errorEmitted=!0,e.emit("error",n))}function Ba(){this[xe].emitClose()}function al(n,e){this[xe].emit("message",n,e)}function cl(n){let e=this[xe];e._autoPong&&e.pong(n,!this._isServer,Fa),e.emit("ping",n)}function xl(n){this[xe].emit("pong",n)}function Ha(n){n.resume()}function dl(n){let e=this[xe];e.readyState!==$.CLOSED&&(e.readyState===$.OPEN&&(e._readyState=$.CLOSING,Ga(e)),this._socket.end(),e._errorEmitted||(e._errorEmitted=!0,e.emit("error",n)))}function Ga(n){n._closeTimer=setTimeout(n._socket.destroy.bind(n._socket),n._closeTimeout)}function Ka(){let n=this[xe];if(this.removeListener("close",Ka),this.removeListener("data",wr),this.removeListener("end",ja),n._readyState=$.CLOSING,!this._readableState.endEmitted&&!n._closeFrameReceived&&!n._receiver._writableState.errorEmitted&&this._readableState.length!==0){let e=this.read(this._readableState.length);n._receiver.write(e)}n._receiver.end(),this[xe]=void 0,clearTimeout(n._closeTimer),n._receiver._writableState.finished||n._receiver._writableState.errorEmitted?n.emitClose():(n._receiver.on("error",Ba),n._receiver.on("finish",Ba))}function wr(n){this[xe]._receiver.write(n)||this.pause()}function ja(){let n=this[xe];n._readyState=$.CLOSING,n._receiver.end(),this.end()}function Wa(){let n=this[xe];this.removeListener("error",Wa),this.on("error",Fa),n&&(n._readyState=$.CLOSING,this.destroy())}});var Xa=ye((p_,Ya)=>{"use strict";var h_=_r(),{Duplex:ul}=ee("stream");function Ja(n){n.emit("close")}function fl(){!this.destroyed&&this._writableState.finished&&this.destroy()}function Va(n){this.removeListener("error",Va),this.destroy(),this.listenerCount("error")===0&&this.emit("error",n)}function ll(n,e){let s=!0,o=new ul({...e,autoDestroy:!1,emitClose:!1,objectMode:!1,writableObjectMode:!1});return n.on("message",function(x,u){let f=!u&&o._readableState.objectMode?x.toString():x;o.push(f)||n.pause()}),n.once("error",function(x){o.destroyed||(s=!1,o.destroy(x))}),n.once("close",function(){o.destroyed||o.push(null)}),o._destroy=function(a,x){if(n.readyState===n.CLOSED){x(a),process.nextTick(Ja,o);return}let u=!1;n.once("error",function(g){u=!0,x(g)}),n.once("close",function(){u||x(a),process.nextTick(Ja,o)}),s&&n.terminate()},o._final=function(a){if(n.readyState===n.CONNECTING){n.once("open",function(){o._final(a)});return}n._socket!==null&&(n._socket._writableState.finished?(a(),o._readableState.endEmitted&&o.destroy()):(n._socket.once("finish",function(){a()}),n.close()))},o._read=function(){n.isPaused&&n.resume()},o._write=function(a,x,u){if(n.readyState===n.CONNECTING){n.once("open",function(){o._write(a,x,u)});return}n.send(a,u)},o.on("end",fl),o.on("error",Va),o}Ya.exports=ll});var Oi=ye((m_,Qa)=>{"use strict";var{tokenChars:gl}=Ut();function hl(n){let e=new Set,s=-1,o=-1,a=0;for(a;a<n.length;a++){let u=n.charCodeAt(a);if(o===-1&&gl[u]===1)s===-1&&(s=a);else if(a!==0&&(u===32||u===9))o===-1&&s!==-1&&(o=a);else if(u===44){if(s===-1)throw new SyntaxError(`Unexpected character at index ${a}`);o===-1&&(o=a);let f=n.slice(s,o);if(e.has(f))throw new SyntaxError(`The "${f}" subprotocol is duplicated`);e.add(f),s=o=-1}else throw new SyntaxError(`Unexpected character at index ${a}`)}if(s===-1||o!==-1)throw new SyntaxError("Unexpected end of input");let x=n.slice(s,a);if(e.has(x))throw new SyntaxError(`The "${x}" subprotocol is duplicated`);return e.add(x),e}Qa.exports={parse:hl}});var sc=ye((__,ic)=>{"use strict";var pl=ee("events"),yr=ee("http"),{Duplex:w_}=ee("stream"),{createHash:ml}=ee("crypto"),Za=hr(),wt=Ft(),wl=Oi(),_l=_r(),{CLOSE_TIMEOUT:yl,GUID:bl,kWebSocket:vl}=Je(),Sl=/^[+/0-9A-Za-z]{22}==$/,ec=0,tc=1,rc=2,Ni=class extends pl{constructor(e,s){if(super(),e={allowSynchronousEvents:!0,autoPong:!0,maxPayload:100*1024*1024,skipUTF8Validation:!1,perMessageDeflate:!1,handleProtocols:null,clientTracking:!0,closeTimeout:yl,verifyClient:null,noServer:!1,backlog:null,server:null,host:null,path:null,port:null,WebSocket:_l,...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=yr.createServer((o,a)=>{let x=yr.STATUS_CODES[426];a.writeHead(426,{"Content-Length":x.length,"Content-Type":"text/plain"}),a.end(x)}),this._server.listen(e.port,e.host,e.backlog,s)):e.server&&(this._server=e.server),this._server){let o=this.emit.bind(this,"connection");this._removeListeners=El(this._server,{listening:this.emit.bind(this,"listening"),error:this.emit.bind(this,"error"),upgrade:(a,x,u)=>{this.handleUpgrade(a,x,u,o)}})}e.perMessageDeflate===!0&&(e.perMessageDeflate={}),e.clientTracking&&(this.clients=new Set,this._shouldEmitClose=!1),this.options=e,this._state=ec}address(){if(this.options.noServer)throw new Error('The server is operating in "noServer" mode');return this._server?this._server.address():null}close(e){if(this._state===rc){e&&this.once("close",()=>{e(new Error("The server is not running"))}),process.nextTick(pn,this);return}if(e&&this.once("close",e),this._state!==tc)if(this._state=tc,this.options.noServer||this.options.server)this._server&&(this._removeListeners(),this._removeListeners=this._server=null),this.clients?this.clients.size?this._shouldEmitClose=!0:process.nextTick(pn,this):process.nextTick(pn,this);else{let s=this._server;this._removeListeners(),this._removeListeners=this._server=null,s.close(()=>{pn(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,a){s.on("error",nc);let x=e.headers["sec-websocket-key"],u=e.headers.upgrade,f=+e.headers["sec-websocket-version"];if(e.method!=="GET"){_t(this,e,s,405,"Invalid HTTP method");return}if(u===void 0||u.toLowerCase()!=="websocket"){_t(this,e,s,400,"Invalid Upgrade header");return}if(x===void 0||!Sl.test(x)){_t(this,e,s,400,"Missing or invalid Sec-WebSocket-Key header");return}if(f!==13&&f!==8){_t(this,e,s,400,"Missing or invalid Sec-WebSocket-Version header",{"Sec-WebSocket-Version":"13, 8"});return}if(!this.shouldHandle(e)){mn(s,400);return}let g=e.headers["sec-websocket-protocol"],p=new Set;if(g!==void 0)try{p=wl.parse(g)}catch{_t(this,e,s,400,"Invalid Sec-WebSocket-Protocol header");return}let _=e.headers["sec-websocket-extensions"],w={};if(this.options.perMessageDeflate&&_!==void 0){let E=new wt({...this.options.perMessageDeflate,isServer:!0,maxPayload:this.options.maxPayload});try{let T=Za.parse(_);T[wt.extensionName]&&(E.accept(T[wt.extensionName]),w[wt.extensionName]=E)}catch{_t(this,e,s,400,"Invalid or unacceptable Sec-WebSocket-Extensions header");return}}if(this.options.verifyClient){let E={origin:e.headers[`${f===8?"sec-websocket-origin":"origin"}`],secure:!!(e.socket.authorized||e.socket.encrypted),req:e};if(this.options.verifyClient.length===2){this.options.verifyClient(E,(T,k,P,H)=>{if(!T)return mn(s,k||401,P,H);this.completeUpgrade(w,x,p,e,s,o,a)});return}if(!this.options.verifyClient(E))return mn(s,401)}this.completeUpgrade(w,x,p,e,s,o,a)}completeUpgrade(e,s,o,a,x,u,f){if(!x.readable||!x.writable)return x.destroy();if(x[vl])throw new Error("server.handleUpgrade() was called more than once with the same socket, possibly due to a misconfiguration");if(this._state>ec)return mn(x,503);let p=["HTTP/1.1 101 Switching Protocols","Upgrade: websocket","Connection: Upgrade",`Sec-WebSocket-Accept: ${ml("sha1").update(s+bl).digest("base64")}`],_=new this.options.WebSocket(null,void 0,this.options);if(o.size){let w=this.options.handleProtocols?this.options.handleProtocols(o,a):o.values().next().value;w&&(p.push(`Sec-WebSocket-Protocol: ${w}`),_._protocol=w)}if(e[wt.extensionName]){let w=e[wt.extensionName].params,E=Za.format({[wt.extensionName]:[w]});p.push(`Sec-WebSocket-Extensions: ${E}`),_._extensions=e}this.emit("headers",p,a),x.write(p.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(fn,this)})),l(_,c)}};ec.exports=Ti;function vl(n,e){for(let s of Object.keys(e))n.on(s,e[s]);return function(){for(let o of Object.keys(e))n.removeListener(o,e[o])}}function fn(n){n._state=Za,n.emit("close")}function Qa(){this.destroy()}function ln(n,e,s,o){s=s||pr.STATUS_CODES[e],o={Connection:"close","Content-Type":"text/html","Content-Length":Buffer.byteLength(s),...o},n.once("finish",n.destroy),n.end(`HTTP/1.1 ${e} ${pr.STATUS_CODES[e]}\r
14
- `+Object.keys(o).map(c=>`${c}: ${o[c]}`).join(`\r
13
+ `)),x.removeListener("error",nc),_.setSocket(x,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(pn,this)})),f(_,a)}};ic.exports=Ni;function El(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 pn(n){n._state=rc,n.emit("close")}function nc(){this.destroy()}function mn(n,e,s,o){s=s||yr.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} ${yr.STATUS_CODES[e]}\r
14
+ `+Object.keys(o).map(a=>`${a}: ${o[a]}`).join(`\r
15
15
  `)+`\r
16
16
  \r
17
- `+s)}function mt(n,e,s,o,c,d){if(n.listenerCount("wsClientError")){let u=new Error(c);Error.captureStackTrace(u,mt),n.emit("wsClientError",u,s,e)}else ln(s,o,c,d)}});import{spawn as Yl}from"node:child_process";import{existsSync as Xl,openSync as Ql}from"node:fs";import{mkdir as Zl}from"node:fs/promises";import{dirname as eg}from"node:path";import{fileURLToPath as tg}from"node:url";function Oi(n=q()){return Xl(n.libEntry)?n.libEntry:tg(new URL("../index.ts",import.meta.url))}async function pn(n={}){let e=n.paths??q(),s=n.entryOverride??Oi(e);await Zl(eg(e.logFile),{recursive:!0});let o=Ql(e.logFile,"a"),d=s.endsWith(".ts")?["--import","tsx/esm",s,"--daemon"]:[s,"--daemon"],u=Yl(process.execPath,d,{detached:!0,stdio:["ignore",o,o],env:{...process.env,COZE_BRIDGE_DAEMON:"1"}});if(u.unref(),typeof u.pid!="number")throw new Error("failed to spawn daemon (no pid)");return ng.info("daemon spawned",{pid:u.pid,entry:s}),{pid:u.pid,entry:s}}var ng,vr=Ae(()=>{"use strict";U();ie();ng=D("spawn-daemon")});import{readFile as _c}from"node:fs/promises";async function Sr(n){try{let[e,s]=await Promise.all([_c(n.portFile,"utf8"),_c(n.tokenFile,"utf8")]),o=Number.parseInt(e.trim(),10),c=s.trim();return!Number.isFinite(o)||o<=0||!c?null:{port:o,token:c}}catch(e){if(e.code==="ENOENT")return null;throw e}}function rg(n){if(!n)return null;try{return JSON.parse(n)}catch{return n}}function ig(n){return n instanceof Error?n.message:String(n)}var Le,Er=Ae(()=>{"use strict";ie();Le=class{paths;constructor(e){this.paths=e??q()}async probe(e=1e3){let s=await Sr(this.paths);if(!s)return{kind:"not-running"};try{let o=await this.fetch(s,{method:"GET",path:"/status",timeoutMs:e});return o.status===200?{kind:"connected",...s}:{kind:"stale",reason:`unexpected status ${o.status}`}}catch(o){return{kind:"stale",reason:ig(o)}}}async request(e){let s=await Sr(this.paths);if(!s)throw new Error("coze-bridge daemon not running (no port/token files)");return this.fetch(s,e)}async fetch(e,s){let o=s.body!==void 0,c={Authorization:`Bearer ${e.token}`};o&&(c["content-type"]="application/json");let d=new AbortController,u=setTimeout(()=>d.abort(),s.timeoutMs??5e3);try{let l=await fetch(`http://127.0.0.1:${e.port}${s.path}`,{method:s.method,headers:c,body:o?JSON.stringify(s.body):void 0,signal:d.signal}),p=await l.text();return{status:l.status,body:rg(p)}}finally{clearTimeout(u)}}}});var Cc={};Kr(Cc,{DEFAULT_PROBE_TIMEOUT_MS:()=>Ac,DEFAULT_WAIT_PID_EXIT_MS:()=>Ic,runUpgradeHelper:()=>vg});import{copyFile as mg,rename as zi,unlink as Fi}from"node:fs/promises";async function vg(n){let e=n.paths??q(),s=n.spawnDaemon??pn,o=n.probeDaemon??Ig,c=n.sleep??Ag,d=n.waitPidExitMs??Ic,u=n.probeTimeoutMs??Ac,l=n.killPid??((P,j)=>process.kill(P,j)),{targetVersion:p,oldPid:m}=n;He.info("upgrade-helper start",{targetVersion:p,oldPid:m}),await Sg(m,d,c,l);let _=e.libEntry,y=`${_}.bak`,I=`${_}.next`;try{await mg(_,y)}catch(P){return He.error("backup failed, abort",{err:String(P)}),1}try{await zi(I,_)}catch(P){return He.error("rename .next \u2192 live failed, abort + rollback",{err:String(P)}),await zi(y,_).catch(()=>{}),1}let L,T=!1;try{await s({paths:e}),T=await Eg(()=>o(e),u,c),T||(L="new daemon failed to come up within probeTimeout")}catch(P){L=`spawn new daemon failed: ${String(P)}`,He.warn(L)}return T?(await Sc(e,p,{ok:!0,setLibVersion:!0}),await Fi(y).catch(()=>{}),await Fi(I).catch(()=>{}),He.info("upgrade succeeded",{targetVersion:p}),0):(He.warn("upgrade failed, rolling back",{lastError:L}),await zi(y,_).catch(P=>He.error("rollback rename failed",{err:String(P)})),await s({paths:e}).catch(P=>He.error("spawn old daemon after rollback failed",{err:String(P)})),await Sc(e,p,{ok:!1,lastError:L}),await Fi(I).catch(()=>{}),1)}async function Sc(n,e,s){let o=await at(n.configFile)??{};s.setLibVersion&&(o.libVersion=e),o.upgradeAttempts=o.upgradeAttempts??{},o.upgradeAttempts[e]={count:(o.upgradeAttempts[e]?.count??0)+1,lastAt:Date.now(),ok:s.ok,...s.lastError?{lastError:s.lastError}:{}},await ze(o,n.configFile)}async function Sg(n,e,s,o){let c=Date.now()+e;for(;Date.now()<c;){if(!Ec(n,o))return;await s(yg)}He.warn("oldPid did not exit in time, sending SIGTERM",{pid:n});try{o(n,"SIGTERM")}catch{}if(await s(wg),!!Ec(n,o)){He.warn("SIGTERM ineffective, sending SIGKILL",{pid:n});try{o(n,"SIGKILL")}catch{}await s(_g)}}function Ec(n,e){try{return e(n,0),!0}catch{return!1}}async function Eg(n,e,s){let o=Date.now()+e;for(;Date.now()<o;){if(await n().catch(()=>!1))return!0;await s(bg)}return!1}async function Ig(n){return(await new Le(n).probe(1e3).catch(()=>null))?.kind==="connected"}function Ag(n){return new Promise(e=>setTimeout(e,n))}var He,Ic,Ac,wg,_g,yg,bg,Pc=Ae(()=>{"use strict";Lt();vr();Er();U();ie();He=D("upgrade-helper"),Ic=3e4,Ac=3e4,wg=5e3,_g=2e3,yg=200,bg=500});import{spawn as Cg}from"node:child_process";import{mkdir as Pg,unlink as kg,writeFile as Tg}from"node:fs/promises";import{dirname as Dg,join as Rg}from"node:path";function Cr(n){return n.replace(/&/g,"&amp;").replace(/</g,"&lt;").replace(/>/g,"&gt;").replace(/"/g,"&quot;")}function kc(n,e){return new Promise((s,o)=>{let c=Cg(n,e,{stdio:["ignore","pipe","pipe"]}),d="";c.stderr?.on("data",u=>{d+=u.toString("utf8")}),c.on("error",o),c.on("close",u=>{u===0?s():o(new Error(`${n} ${e.join(" ")} exited ${u}: ${d.trim()}`))})})}var Ar,Ui,qi,Tc=Ae(()=>{"use strict";U();Ar=D("supervisor.launchd"),Ui="ai.coze.bridge",qi={platform:"darwin",renderConfig(n){return`<?xml version="1.0" encoding="UTF-8"?>
17
+ `+s)}function _t(n,e,s,o,a,x){if(n.listenerCount("wsClientError")){let u=new Error(a);Error.captureStackTrace(u,_t),n.emit("wsClientError",u,s,e)}else mn(s,o,a,x)}});import{spawn as Ql}from"node:child_process";import{existsSync as Zl,openSync as eg}from"node:fs";import{mkdir as tg}from"node:fs/promises";import{dirname as ng}from"node:path";import{fileURLToPath as rg}from"node:url";function zi(n=q()){return Zl(n.libEntry)?n.libEntry:rg(new URL("../index.ts",import.meta.url))}async function yn(n={}){let e=n.paths??q(),s=n.entryOverride??zi(e);await tg(ng(e.logFile),{recursive:!0});let o=eg(e.logFile,"a"),x=s.endsWith(".ts")?["--import","tsx/esm",s,"--daemon"]:[s,"--daemon"],u=Ql(process.execPath,x,{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 ig.info("daemon spawned",{pid:u.pid,entry:s}),{pid:u.pid,entry:s}}var ig,Cr=Ce(()=>{"use strict";U();ie();ig=D("spawn-daemon")});import{readFile as Sc}from"node:fs/promises";async function Ir(n){try{let[e,s]=await Promise.all([Sc(n.portFile,"utf8"),Sc(n.tokenFile,"utf8")]),o=Number.parseInt(e.trim(),10),a=s.trim();return!Number.isFinite(o)||o<=0||!a?null:{port:o,token:a}}catch(e){if(e.code==="ENOENT")return null;throw e}}function sg(n){if(!n)return null;try{return JSON.parse(n)}catch{return n}}function og(n){return n instanceof Error?n.message:String(n)}var Oe,Pr=Ce(()=>{"use strict";ie();Oe=class{paths;constructor(e){this.paths=e??q()}async probe(e=1e3){let s=await Ir(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:og(o)}}}async request(e){let s=await Ir(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,a={Authorization:`Bearer ${e.token}`};o&&(a["content-type"]="application/json");let x=new AbortController,u=setTimeout(()=>x.abort(),s.timeoutMs??5e3);try{let f=await fetch(`http://127.0.0.1:${e.port}${s.path}`,{method:s.method,headers:a,body:o?JSON.stringify(s.body):void 0,signal:x.signal}),g=await f.text();return{status:f.status,body:sg(g)}}finally{clearTimeout(u)}}}});var Dc={};Jr(Dc,{DEFAULT_PROBE_TIMEOUT_MS:()=>Tc,DEFAULT_WAIT_PID_EXIT_MS:()=>kc,runUpgradeHelper:()=>Eg});import{copyFile as _g,rename as Hi,unlink as Gi}from"node:fs/promises";async function Eg(n){let e=n.paths??q(),s=n.spawnDaemon??yn,o=n.probeDaemon??Ig,a=n.sleep??Pg,x=n.waitPidExitMs??kc,u=n.probeTimeoutMs??Tc,f=n.killPid??((P,H)=>process.kill(P,H)),{targetVersion:g,oldPid:p}=n;Ge.info("upgrade-helper start",{targetVersion:g,oldPid:p}),await Ag(p,x,a,f);let _=e.libEntry,w=`${_}.bak`,E=`${_}.next`;try{await _g(_,w)}catch(P){return Ge.error("backup failed, abort",{err:String(P)}),1}try{await Hi(E,_)}catch(P){return Ge.error("rename .next \u2192 live failed, abort + rollback",{err:String(P)}),await Hi(w,_).catch(()=>{}),1}let T,k=!1;try{await s({paths:e}),k=await Cg(()=>o(e),u,a),k||(T="new daemon failed to come up within probeTimeout")}catch(P){T=`spawn new daemon failed: ${String(P)}`,Ge.warn(T)}return k?(await Ic(e,g,{ok:!0,setLibVersion:!0}),await Gi(w).catch(()=>{}),await Gi(E).catch(()=>{}),Ge.info("upgrade succeeded",{targetVersion:g}),0):(Ge.warn("upgrade failed, rolling back",{lastError:T}),await Hi(w,_).catch(P=>Ge.error("rollback rename failed",{err:String(P)})),await s({paths:e}).catch(P=>Ge.error("spawn old daemon after rollback failed",{err:String(P)})),await Ic(e,g,{ok:!1,lastError:T}),await Gi(E).catch(()=>{}),1)}async function Ic(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 Ag(n,e,s,o){let a=Date.now()+e;for(;Date.now()<a;){if(!Pc(n,o))return;await s(vg)}Ge.warn("oldPid did not exit in time, sending SIGTERM",{pid:n});try{o(n,"SIGTERM")}catch{}if(await s(yg),!!Pc(n,o)){Ge.warn("SIGTERM ineffective, sending SIGKILL",{pid:n});try{o(n,"SIGKILL")}catch{}await s(bg)}}function Pc(n,e){try{return e(n,0),!0}catch{return!1}}async function Cg(n,e,s){let o=Date.now()+e;for(;Date.now()<o;){if(await n().catch(()=>!1))return!0;await s(Sg)}return!1}async function Ig(n){return(await new Oe(n).probe(1e3).catch(()=>null))?.kind==="connected"}function Pg(n){return new Promise(e=>setTimeout(e,n))}var Ge,kc,Tc,yg,bg,vg,Sg,Rc=Ce(()=>{"use strict";Mt();Cr();Pr();U();ie();Ge=D("upgrade-helper"),kc=3e4,Tc=3e4,yg=5e3,bg=2e3,vg=200,Sg=500});import{spawn as kg}from"node:child_process";import{mkdir as Tg,unlink as Dg,writeFile as Rg}from"node:fs/promises";import{dirname as Og,join as Ng}from"node:path";function Dr(n){return n.replace(/&/g,"&amp;").replace(/</g,"&lt;").replace(/>/g,"&gt;").replace(/"/g,"&quot;")}function Oc(n,e){return new Promise((s,o)=>{let a=kg(n,e,{stdio:["ignore","pipe","pipe"]}),x="";a.stderr?.on("data",u=>{x+=u.toString("utf8")}),a.on("error",o),a.on("close",u=>{u===0?s():o(new Error(`${n} ${e.join(" ")} exited ${u}: ${x.trim()}`))})})}var Tr,Ki,ji,Nc=Ce(()=>{"use strict";U();Tr=D("supervisor.launchd"),Ki="ai.coze.bridge",ji={platform:"darwin",renderConfig(n){return`<?xml version="1.0" encoding="UTF-8"?>
18
18
  <!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
19
19
  <plist version="1.0">
20
20
  <dict>
21
21
  <key>Label</key>
22
- <string>${Ui}</string>
22
+ <string>${Ki}</string>
23
23
  <key>ProgramArguments</key>
24
24
  <array>
25
- <string>${Cr(n.nodeBin)}</string>
26
- <string>${Cr(n.entry)}</string>
25
+ <string>${Dr(n.nodeBin)}</string>
26
+ <string>${Dr(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>${Cr(n.logFile)}</string>
36
+ <string>${Dr(n.logFile)}</string>
37
37
  <key>StandardErrorPath</key>
38
- <string>${Cr(n.logFile)}</string>
38
+ <string>${Dr(n.logFile)}</string>
39
39
  </dict>
40
40
  </plist>
41
- `},configPath(n){return Rg(n.homeDir,"Library","LaunchAgents",`${Ui}.plist`)},async install(n){let e=this.configPath(n);await Pg(Dg(e),{recursive:!0}),await Tg(e,this.renderConfig(n),"utf8"),Ar.info("plist written",{plistPath:e}),await kc("launchctl",["load","-w",e]),Ar.info("launchd job loaded",{label:Ui})},async uninstall(n){let e=this.configPath(n);await kc("launchctl",["unload","-w",e]).catch(s=>Ar.warn("launchctl unload failed (ignored)",{err:String(s)})),await kg(e).catch(s=>{if(s.code!=="ENOENT")throw s}),Ar.info("launchd job removed",{plistPath:e})}}});import{spawn as Lg}from"node:child_process";import{mkdir as Og,unlink as Ng,writeFile as Mg}from"node:fs/promises";import{dirname as Bg,join as zg}from"node:path";function Tr(n,e){return new Promise((s,o)=>{let c=Lg(n,e,{stdio:["ignore","pipe","pipe"]}),d="";c.stderr?.on("data",u=>{d+=u.toString("utf8")}),c.on("error",o),c.on("close",u=>{u===0?s():o(new Error(`${n} ${e.join(" ")} exited ${u}: ${d.trim()}`))})})}var Pr,kr,Hi,Dc=Ae(()=>{"use strict";U();Pr=D("supervisor.systemd"),kr="coze-bridge.service",Hi={platform:"linux",renderConfig(n){return`[Unit]
41
+ `},configPath(n){return Ng(n.homeDir,"Library","LaunchAgents",`${Ki}.plist`)},async install(n){let e=this.configPath(n);await Tg(Og(e),{recursive:!0}),await Rg(e,this.renderConfig(n),"utf8"),Tr.info("plist written",{plistPath:e}),await Oc("launchctl",["load","-w",e]),Tr.info("launchd job loaded",{label:Ki})},async uninstall(n){let e=this.configPath(n);await Oc("launchctl",["unload","-w",e]).catch(s=>Tr.warn("launchctl unload failed (ignored)",{err:String(s)})),await Dg(e).catch(s=>{if(s.code!=="ENOENT")throw s}),Tr.info("launchd job removed",{plistPath:e})}}});import{spawn as Lg}from"node:child_process";import{mkdir as Mg,unlink as Bg,writeFile as zg}from"node:fs/promises";import{dirname as Fg,join as Ug}from"node:path";function Nr(n,e){return new Promise((s,o)=>{let a=Lg(n,e,{stdio:["ignore","pipe","pipe"]}),x="";a.stderr?.on("data",u=>{x+=u.toString("utf8")}),a.on("error",o),a.on("close",u=>{u===0?s():o(new Error(`${n} ${e.join(" ")} exited ${u}: ${x.trim()}`))})})}var Rr,Or,Wi,Lc=Ce(()=>{"use strict";U();Rr=D("supervisor.systemd"),Or="coze-bridge.service",Wi={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 zg(n.homeDir,".config","systemd","user",kr)},async install(n){let e=this.configPath(n);await Og(Bg(e),{recursive:!0}),await Mg(e,this.renderConfig(n),"utf8"),Pr.info("systemd unit written",{unitPath:e}),await Tr("systemctl",["--user","daemon-reload"]),await Tr("systemctl",["--user","enable","--now",kr]),Pr.info("systemd unit enabled",{unitName:kr})},async uninstall(n){let e=this.configPath(n);await Tr("systemctl",["--user","disable","--now",kr]).catch(s=>Pr.warn("systemctl disable failed (ignored)",{err:String(s)})),await Ng(e).catch(s=>{if(s.code!=="ENOENT")throw s}),await Tr("systemctl",["--user","daemon-reload"]).catch(()=>{}),Pr.info("systemd unit removed",{unitPath:e})}}});import{spawn as Fg}from"node:child_process";import{join as Ug}from"node:path";function Rc(n,e){return new Promise((s,o)=>{let c=Fg(n,e,{stdio:["ignore","pipe","pipe"],shell:!1}),d="";c.stderr?.on("data",u=>{d+=u.toString("utf8")}),c.on("error",o),c.on("close",u=>{u===0?s():o(new Error(`${n} ${e.join(" ")} exited ${u}: ${d.trim()}`))})})}var ji,Dr,Ki,Lc=Ae(()=>{"use strict";U();ji=D("supervisor.taskscheduler"),Dr="CozeBridge",Ki={platform:"win32",renderConfig(n){return`<?xml version="1.0" encoding="UTF-16"?>
55
+ `},configPath(n){return Ug(n.homeDir,".config","systemd","user",Or)},async install(n){let e=this.configPath(n);await Mg(Fg(e),{recursive:!0}),await zg(e,this.renderConfig(n),"utf8"),Rr.info("systemd unit written",{unitPath:e}),await Nr("systemctl",["--user","daemon-reload"]),await Nr("systemctl",["--user","enable","--now",Or]),Rr.info("systemd unit enabled",{unitName:Or})},async uninstall(n){let e=this.configPath(n);await Nr("systemctl",["--user","disable","--now",Or]).catch(s=>Rr.warn("systemctl disable failed (ignored)",{err:String(s)})),await Bg(e).catch(s=>{if(s.code!=="ENOENT")throw s}),await Nr("systemctl",["--user","daemon-reload"]).catch(()=>{}),Rr.info("systemd unit removed",{unitPath:e})}}});import{spawn as qg}from"node:child_process";import{join as Hg}from"node:path";function Mc(n,e){return new Promise((s,o)=>{let a=qg(n,e,{stdio:["ignore","pipe","pipe"],shell:!1}),x="";a.stderr?.on("data",u=>{x+=u.toString("utf8")}),a.on("error",o),a.on("close",u=>{u===0?s():o(new Error(`${n} ${e.join(" ")} exited ${u}: ${x.trim()}`))})})}var $i,Lr,Ji,Bc=Ce(()=>{"use strict";U();$i=D("supervisor.taskscheduler"),Lr="CozeBridge",Ji={platform:"win32",renderConfig(n){return`<?xml version="1.0" encoding="UTF-16"?>
56
56
  <Task version="1.2" xmlns="http://schemas.microsoft.com/windows/2004/02/mit/task">
57
57
  <RegistrationInfo>
58
58
  <Description>Coze Bridge daemon</Description>
@@ -76,19 +76,19 @@ WantedBy=default.target
76
76
  </Exec>
77
77
  </Actions>
78
78
  </Task>
79
- `},configPath(n){return Ug(n.homeDir,".coze","bridge","task.xml")},async install(n){let e=`"${n.nodeBin}" "${n.entry}" --daemon`;await Rc("schtasks",["/Create","/SC","ONLOGON","/TN",Dr,"/TR",e,"/RU",n.userName,"/F"]),ji.info("task scheduler entry created",{task:Dr})},async uninstall(n){await Rc("schtasks",["/Delete","/TN",Dr,"/F"]).catch(e=>ji.warn("schtasks /Delete failed (ignored)",{err:String(e)})),ji.info("task scheduler entry removed",{task:Dr})}}});var Gi={};Kr(Gi,{buildContext:()=>Kg,getSupervisor:()=>jg,launchdSupervisor:()=>qi,systemdSupervisor:()=>Hi,taskSchedulerSupervisor:()=>Ki});import{homedir as qg,userInfo as Hg}from"node:os";function jg(n=process.platform){switch(n){case"darwin":return qi;case"linux":return Hi;case"win32":return Ki;default:throw new Error(`unsupported platform for OS supervisor: ${n}`)}}function Kg(){let n=q();return{nodeBin:process.execPath,entry:Oi(n),logFile:n.logFile,homeDir:qg(),userName:Hg().username}}var Wi=Ae(()=>{"use strict";ie();vr();Tc();Dc();Lc()});U();U();import{execFile as F0}from"node:child_process";import{promisify as U0}from"node:util";var ms=U0(F0),Wt=D("agents.acp-installer"),q0={"claude-code":{npmPackage:"@agentclientprotocol/claude-agent-acp",binary:"claude-agent-acp"},codex:{npmPackage:"@zed-industries/codex-acp",binary:"codex-acp"}},H0=5e4,j0=5e3,K0=5*6e4,G0=new Set(["ETIMEDOUT","ECONNRESET","ECONNREFUSED","ENETUNREACH","EAI_AGAIN","ERR_SOCKET_TIMEOUT","ENOTFOUND"]),W0=/\b(5\d\d|408|429)\b\s+(Bad Gateway|Service Unavailable|Gateway Timeout|Internal Server Error|Too Many Requests|Request Timeout)/i,J0=/fetch failed|request timed out|socket hang up|network timeout/i;function $0(n){let e=n?.code;if(e&&G0.has(e))return!0;let s=n instanceof Error?`${n.message}
80
- ${n.stack??""}`:String(n);return W0.test(s)||J0.test(s)}var vn=new Map,bn=new Map,Gr=new Map;async function ps(n){let e=process.platform==="win32"?"where":"which";try{let{stdout:s}=await ms(e,[n],{timeout:j0});return s.split(`
81
- `)[0]?.trim()||void 0}catch{return}}async function V0(n,e){Wt.info("npm install -g start",{npmPackage:n}),await ms("npm",["install","-g",`${n}@latest`],{timeout:H0,maxBuffer:10*1024*1024,...e?{signal:e}:{}}),Wt.info("npm install -g done",{npmPackage:n})}async function Sn(n,e){let s=q0[n];if(!s)return;let o=vn.get(n);if(o)return o;let c=bn.get(n);if(c&&Date.now()-c<K0)return;let d=Gr.get(n);if(d)return d;let u=(async()=>{let l=await ps(s.binary);if(l)return vn.set(n,l),Wt.info("acp wrapper found on PATH",{binary:s.binary,path:l}),l;try{await V0(s.npmPackage,e)}catch(m){let _=$0(m);Wt.warn("acp wrapper install failed (will fallback to npx)",{npmPackage:s.npmPackage,transient:_,err:String(m)}),_||bn.set(n,Date.now());return}let p=await ps(s.binary);if(!p){Wt.warn("acp wrapper installed but binary not found on PATH",{binary:s.binary}),bn.set(n,Date.now());return}return vn.set(n,p),bn.delete(n),p})().finally(()=>{Gr.delete(n)});return Gr.set(n,u),u}function En(n){return vn.get(n)}var ws=D("acp-installer-warmup"),Y0=["claude-code","codex"];async function _s(n={}){let e=n.ensure??Sn,o=(await Promise.allSettled(Y0.map(async c=>{let d=await e(c);ws.info("acp wrapper warmup ok",{framework:c,installed:!!d,path:d??""})}))).filter(c=>c.status==="rejected");o.length>0&&ws.warn("acp wrapper warmup partial failure (acp-installer negative cache 5min \u5185\u4E0D\u91CD\u8BD5)",{failedCount:o.length,reasons:o.map(c=>String(c.reason))})}nt();U();import{readdir as xx}from"node:fs/promises";import{mkdir as As,writeFile as Cs}from"node:fs/promises";import{join as Jr}from"node:path";var ox={"claude-code":"CLAUDE.md",codex:"AGENTS.md",openclaw:"SOUL.md"};async function It(n,e,s,o){await As(n,{recursive:!0});let c=ox[e],d=Jr(n,c),u=ax(e,s,o);return await Cs(d,u,"utf8"),d}async function Ps(n){let e=Jr(n,".claude");await As(e,{recursive:!0});let s=Jr(e,"settings.local.json"),o=JSON.stringify({permissions:{defaultMode:"bypassPermissions"}},null,2);return await Cs(s,o,"utf8"),s}function ax(n,e,s){let o=`# Coze Agent: ${e}
79
+ `},configPath(n){return Hg(n.homeDir,".coze","bridge","task.xml")},async install(n){let e=`"${n.nodeBin}" "${n.entry}" --daemon`;await Mc("schtasks",["/Create","/SC","ONLOGON","/TN",Lr,"/TR",e,"/RU",n.userName,"/F"]),$i.info("task scheduler entry created",{task:Lr})},async uninstall(n){await Mc("schtasks",["/Delete","/TN",Lr,"/F"]).catch(e=>$i.warn("schtasks /Delete failed (ignored)",{err:String(e)})),$i.info("task scheduler entry removed",{task:Lr})}}});var Vi={};Jr(Vi,{buildContext:()=>Wg,getSupervisor:()=>jg,launchdSupervisor:()=>ji,systemdSupervisor:()=>Wi,taskSchedulerSupervisor:()=>Ji});import{homedir as Gg,userInfo as Kg}from"node:os";function jg(n=process.platform){switch(n){case"darwin":return ji;case"linux":return Wi;case"win32":return Ji;default:throw new Error(`unsupported platform for OS supervisor: ${n}`)}}function Wg(){let n=q();return{nodeBin:process.execPath,entry:zi(n),logFile:n.logFile,homeDir:Gg(),userName:Kg().username}}var Yi=Ce(()=>{"use strict";ie();Cr();Nc();Lc();Bc()});U();U();import{execFile as U0}from"node:child_process";import{promisify as q0}from"node:util";var bs=q0(U0),Yt=D("agents.acp-installer"),H0={"claude-code":{npmPackage:"@agentclientprotocol/claude-agent-acp",binary:"claude-agent-acp"},codex:{npmPackage:"@zed-industries/codex-acp",binary:"codex-acp"}},G0=5e4,K0=5e3,j0=5*6e4,W0=new Set(["ETIMEDOUT","ECONNRESET","ECONNREFUSED","ENETUNREACH","EAI_AGAIN","ERR_SOCKET_TIMEOUT","ENOTFOUND"]),$0=/\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 V0(n){let e=n?.code;if(e&&W0.has(e))return!0;let s=n instanceof Error?`${n.message}
80
+ ${n.stack??""}`:String(n);return $0.test(s)||J0.test(s)}function Y0(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 a=e.stdout?.toString().trim();return a&&s.push(`stdout=${a.slice(0,2e3)}`),s.length>0?s.join(" | "):String(n)}var Cn=new Map,An=new Map,Vr=new Map;async function ys(n){let e=process.platform==="win32"?"where":"which";try{let{stdout:s}=await bs(e,[n],{timeout:K0});return s.split(`
81
+ `)[0]?.trim()||void 0}catch{return}}async function X0(n,e){Yt.info("npm install -g start",{npmPackage:n}),await bs("npm",["install","-g",`${n}@latest`],{timeout:G0,maxBuffer:10*1024*1024,...e?{signal:e}:{}}),Yt.info("npm install -g done",{npmPackage:n})}async function In(n,e){let s=H0[n];if(!s)return;let o=Cn.get(n);if(o)return o;let a=An.get(n);if(a&&Date.now()-a<j0)return;let x=Vr.get(n);if(x)return x;let u=(async()=>{let f=await ys(s.binary);if(f)return Cn.set(n,f),Yt.info("acp wrapper found on PATH",{binary:s.binary,path:f}),f;try{await X0(s.npmPackage,e)}catch(p){let _=V0(p);Yt.warn("acp wrapper install failed (will fallback to npx)",{npmPackage:s.npmPackage,transient:_,err:Y0(p)}),_||An.set(n,Date.now());return}let g=await ys(s.binary);if(!g){Yt.warn("acp wrapper installed but binary not found on PATH",{binary:s.binary}),An.set(n,Date.now());return}return Cn.set(n,g),An.delete(n),g})().finally(()=>{Vr.delete(n)});return Vr.set(n,u),u}function Pn(n){return Cn.get(n)}var vs=D("acp-installer-warmup"),Q0=["claude-code","codex"];async function Ss(n={}){let e=n.ensure??In,o=(await Promise.allSettled(Q0.map(async a=>{let x=await e(a);vs.info("acp wrapper warmup ok",{framework:a,installed:!!x,path:x??""})}))).filter(a=>a.status==="rejected");o.length>0&&vs.warn("acp wrapper warmup partial failure (acp-installer negative cache 5min \u5185\u4E0D\u91CD\u8BD5)",{failedCount:o.length,reasons:o.map(a=>String(a.reason))})}rt();U();import{readdir as ux}from"node:fs/promises";import{mkdir as Ts,writeFile as Ds}from"node:fs/promises";import{join as Xr}from"node:path";var cx={"claude-code":"CLAUDE.md",codex:"AGENTS.md",openclaw:"SOUL.md"};async function Pt(n,e,s,o){await Ts(n,{recursive:!0});let a=cx[e],x=Xr(n,a),u=xx(e,s,o);return await Ds(x,u,"utf8"),x}async function Rs(n){let e=Xr(n,".claude");await Ts(e,{recursive:!0});let s=Xr(e,"settings.local.json"),o=JSON.stringify({permissions:{defaultMode:"bypassPermissions"}},null,2);return await Ds(s,o,"utf8"),s}function xx(n,e,s){let o=`# Coze Agent: ${e}
82
82
 
83
83
  > framework: \`${n}\`
84
84
 
85
- `,c=s?.trim()?s.endsWith(`
85
+ `,a=s?.trim()?s.endsWith(`
86
86
  `)?s:`${s}
87
87
  `:`_No instructions provided._
88
88
  `;return`${o}---
89
89
 
90
- ${c}
91
- ${cx}`}var cx=`## \u53D1\u9001\u6587\u4EF6 / \u56FE\u7247\u7ED9\u7528\u6237
90
+ ${a}
91
+ ${dx}`}var dx=`## \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 ve=D("agent-detail-sync"),dx=6e4,ux=5*6e4,Tn=class{constructor(e){this.opts=e}opts;retryQueue=new Map;async syncAll(e){let s=this.opts.paths.agentsRoot,o;try{o=await xx(s)}catch(c){ve.info("agents dir not found, skip detail sync",{root:s,err:String(c)});return}ve.info("starting detail sync",{reason:e,count:o.length}),await Promise.allSettled(o.map(async c=>{let d=await me(c,this.opts.paths).catch(()=>null);if(d){if(d.disconnectedAt){ve.debug("detail sync: skip disconnected agent",{agentId:c});return}try{await this.syncOne(c,d)}catch(u){ve.warn("detail sync failed for agent, skipping",{agentId:c,err:String(u)})}}})),ve.info("detail sync done",{reason:e})}async retryPending(){if(this.retryQueue.size===0)return;let e=Date.now(),s=[];for(let[o,c]of this.retryQueue)e>=c.dueAt&&s.push(o);if(s.length!==0){ve.info("retrying pending detail syncs",{count:s.length});for(let o of s)try{await this.syncOne(o)}catch(c){ve.debug("detail sync retry still failing, will try again",{agentId:o,err:String(c)})}}}async syncOne(e,s){let o=s??await me(e,this.opts.paths);if(!o){ve.info("detail sync: agent config missing, skip",{agentId:e});return}let c;try{c=await this.opts.sendDetail({_meta:{cozeAgentId:e}}),this.retryQueue.delete(e)}catch(l){ve.warn("detail RPC failed, using local data",{agentId:e,err:String(l)});let p=this.retryQueue.get(e),m=p?Math.min(p.currentDelay*2,ux):dx;this.retryQueue.set(e,{dueAt:Date.now()+m,currentDelay:m});return}if(c.agentId&&c.agentId!==e){ve.warn("detail response agentId mismatch, ignoring",{agentId:e,responseAgentId:c.agentId});return}let d=!1,u=!1;if(c.agentName&&c.agentName!==o.agentName&&(o.agentName=c.agentName,d=!0),c.description!==void 0&&c.description!==o.description&&(o.description=c.description,d=!0),c.cozeIdentity&&c.cozeIdentity!==o.cozeIdentity&&(o.cozeIdentity=c.cozeIdentity,d=!0,u=!0),c.deployType&&ve.info("detail.deployType",{agentId:e,deployType:c.deployType}),!d){ve.debug("detail sync: no diff",{agentId:e});return}await Ce(o,this.opts.paths),ve.info("detail sync: config updated",{agentId:e,identityChanged:u,agentName:o.agentName}),u&&(await It(o.workspace,o.framework,e,o.cozeIdentity),this.opts.handlers.reloadAgentSessionsPublic(e,"detail-sync"))}};nt();import{spawn as Js}from"node:child_process";import{lstat as Qr,mkdir as gx,readFile as $s,readdir as hx,rm as px,stat as mx,writeFile as Gs}from"node:fs/promises";import{join as Me,normalize as _x,relative as Vs,resolve as yx,sep as Ys}from"node:path";var Oe={PAIR:"_agent/pair",CREATE:"_agent/create",HEALTH:"_agent/health",LIST_SKILLS:"_agent/listSkills",ADD_SKILLS:"_agent/addSkills",REMOVE_SKILLS:"_agent/removeSkills",GET_FILE_TREE:"_agent/getFileTree",GET_FILE_CONTENT:"_agent/getFileContent",DETAIL:"_agent/detail",UPDATE:"_agent/update",DISCONNECT:"_agent/disconnect",SWITCH_MODEL:"_agent/switchModel",GEN_MODEL_TOKEN:"_agent/genModelToken",RESET:"_agent/reset",REPAIR:"_agent/repair",DELETE:"_agent/delete"};function Jt(n){return n?.cozeDeployType==="cloud"?"cloud":"local"}function ks(n){let e=n?.cozeAccountId?.trim();if(!(!e||e==="0"))return e}function Ts(n){let{_meta:e,...s}=n;return{stripped:s,meta:e}}function At(n){if(!n?.cozeAgentId)throw new Error("missing _meta.cozeAgentId");return n.cozeAgentId}var S=class extends Error{code;retriable;cause;constructor(e,s,o){super(s),this.name="BridgeError",this.code=e,this.retriable=o?.retriable??!1,o?.cause!==void 0&&(this.cause=o.cause)}};U();ie();function We(n,e){if(Jt(n)!=="cloud")throw new S("OPERATION_NOT_ALLOWED_FOR_LOCAL",`${e} is not allowed for local agent`)}function Dn(n){return n.startsWith("http://")||n.startsWith("https://")}function Rn(n){return n.endsWith("/")?n.slice(0,-1):n}U();var Ln="1008033",Ds="1289";var Rs="pbbp2",Ls="https://www.coze.cn",Os="/api/coze_claw/resource/get_frontier_key",fx="https://www.coze.cn",lx="wss://frontier.coze.cn";function On(n){return n??process.env.COZE_BRIDGE_HANDSHAKE_URL??fx}function Ns(n){return n??process.env.COZE_BRIDGE_FRONTIER_URL??lx}function Ct(n){let e={},s=n?.ttEnv??process.env.COZE_BRIDGE_TT_ENV,o=n?.usePpe??process.env.COZE_BRIDGE_USE_PPE;return s&&(e["x-tt-env"]=s),o&&(e["x-use-ppe"]=o),e}function $t(n){return n?n.startsWith("boe_")?{ttEnv:n}:{ttEnv:n,usePpe:"1"}:{}}var Ms=D("handshake");async function $r(n){let e=On(n.endpoint),s=n.timeoutMs??1e4,o=`${Rn(e)}${Os}?aid=${encodeURIComponent(Ln)}`,c={Authorization:`Bearer ${n.privatecode}`,Accept:"application/json",...Ct(n.ppeOverride)},d=new AbortController,u=setTimeout(()=>d.abort(),s);Ms.info("frontier key handshake",{base:e});try{let l=await fetch(o,{method:"GET",headers:c,signal:d.signal}),p=l.headers.get("x-tt-logid")??"",m=l.headers.get("x-tt-trace-id")??"";if(!l.ok){let T=await l.text().catch(()=>"");throw new S("UPSTREAM_HANDSHAKE_FAILED",`handshake HTTP ${l.status} logid=${p}: ${T.slice(0,200)}`)}let _=await l.json();if(_.code!==void 0&&_.code!==0)throw new S("UPSTREAM_HANDSHAKE_FAILED",`handshake code=${_.code} msg=${_.msg??"-"} logid=${p}`);let y=_.data??{},I=typeof y.access_key=="string"&&y.access_key||typeof y.accessKey=="string"&&y.accessKey||void 0,L=typeof y.device_id=="string"&&y.device_id||typeof y.deviceId=="string"&&y.deviceId||void 0;if(!I||!L){let T=JSON.stringify(_).slice(0,500);throw new S("UPSTREAM_HANDSHAKE_FAILED",`handshake response missing access_key/device_id (also tried camelCase) logid=${p}: ${T}`)}return Ms.info("handshake ok",{remoteDeviceId:L,logid:p,traceId:m}),{accessKey:I,deviceId:L}}catch(l){throw l instanceof S?l:l.name==="AbortError"?new S("UPSTREAM_HANDSHAKE_FAILED",`handshake timeout (${s}ms)`):new S("UPSTREAM_HANDSHAKE_FAILED",String(l),{cause:l})}finally{clearTimeout(u)}}var Vr=process.env.COZE_BRIDGE_LLM_GATEWAY_URL?.trim()||"https://llm-gateway.coze.cn",Ne="auto";function Bs(n){return{model:n.model??Ne,...n.modelToken?{modelToken:n.modelToken}:{}}}function zs(n){return!n||n===Ne}function Fs(n){let e={};return n.modelToken?(e.ANTHROPIC_BASE_URL=Vr,e.ANTHROPIC_AUTH_TOKEN=n.modelToken,e.ANTHROPIC_MODEL=n.model||Ne):zs(n.model)||(e.ANTHROPIC_MODEL=n.model),e}function Us(n){let e=[];return n.modelToken?e.push("-c",`model="${n.model||Ne}"`):zs(n.model)||e.push("-c",`model="${n.model}"`),n.modelToken&&(e.push("-c",'model_providers.coze.name="coze"'),e.push("-c",`model_providers.coze.base_url="${Vr}/v1"`),e.push("-c",'model_providers.coze.env_key="OPENAI_API_KEY"'),e.push("-c",'model_providers.coze.wire_api="responses"'),e.push("-c","model_providers.coze.requires_openai_auth=false"),e.push("-c","model_providers.coze.supports_websockets=false"),e.push("-c",'model_provider="coze"')),e}function qs(n){return n.modelToken?{OPENAI_API_KEY:n.modelToken}:{}}function Yr(n){let{ttEnv:e,usePpe:s}=$t(n),o={};return e&&(o["x-tt-env"]=e),s&&(o["x-use-ppe"]=s),o}function Hs(n,e){if(!n.modelToken)return{};let s=Yr(e);return Object.keys(s).length===0?{}:{ANTHROPIC_CUSTOM_HEADERS:Object.entries(s).map(([c,d])=>`${c}:${d}`).join(`
116
- `)}}function Xr(n){return`coze-session-${n.replace(/[^A-Za-z0-9_-]+/g,"-")}`}function js(n,e){if(!n.modelToken)return null;let s=n.model||Ne,o=Yr(e),c={baseUrl:`${Vr}/v1`,api:"openai-completions",apiKey:n.modelToken,models:[{id:s,name:s,reasoning:!1,input:["text"],cost:{input:0,output:0,cacheRead:0,cacheWrite:0},contextWindow:128e3,maxTokens:8192,api:"openai-completions"}]};return Object.keys(o).length>0&&(c.headers=o),c}function Ks(n,e){if(!n.modelToken)return[];let s=Yr(e),o=[];for(let[c,d]of Object.entries(s))o.push("-c",`model_providers.coze.http_headers.${c}="${d}"`);return o}var ae=D("agent-handlers"),Ws=5*1024*1024,bx=1,vx=6,Sx=new Set(["node_modules",".git",".coze","dist","build",".next"]),Nn=class{constructor(e){this.opts=e}opts;async listSkills(e){We(e._meta,"_agent/listSkills");let s=At(e._meta),o=await this.loadAgentCfg(s),c=o?.workspace??Ge(s).workspace,d=o?.skills??[],u=[];for(let l of d){let p=Me(c,l.relPath,"SKILL.md");await mx(p).then(_=>_.isFile()).catch(()=>!1)&&u.push(Px(l))}return{skills:u}}async addSkills(e){We(e._meta,"_agent/addSkills");let s=At(e._meta),o=await this.requireAgentCfg(s),c=e.skills??[],d=[...o.skills??[]],u=new Map(d.map((p,m)=>[p.skillId,m])),l=[];for(let p of c){let m=await Zr({agentId:s,workspace:o.workspace,framework:o.framework,skill:p});ei(d,u,m),l.push(p)}return await Pn(s,d),this.reloadAgentSessions(s,"skills-added"),{installedSkills:l}}async removeSkills(e){We(e._meta,"_agent/removeSkills");let s=At(e._meta),o=await this.requireAgentCfg(s),c=new Set(e.skillIds??[]),d=o.skills??[],u=[];for(let l of d){if(!c.has(l.skillId)){u.push(l);continue}let p=Me(o.workspace,l.relPath);await px(p,{recursive:!0,force:!0}),ae.info("skill removed",{agentId:s,skillId:l.skillId,relPath:l.relPath})}return await Pn(s,u),this.reloadAgentSessions(s,"skills-removed"),{ok:!0}}reloadAgentSessionsPublic(e,s){this.reloadAgentSessions(e,s)}reloadAgentSessions(e,s){let o=this.opts.agents.get(e);if(o)for(let[c,d]of o.sessions){if(!d.downstream)continue;let u=d.acpSessionId;if(u&&o.activeTriggers.has(u)||this.isRuntimePendingPermission(d)){d.reloadAfterTurn=!0,ae.info("downstream busy, scheduling reload after turn",{reason:s,agentId:e,framework:o.framework,cloudId:c,acpId:u});continue}let p=d.downstream;d.downstream=void 0,ae.info("killing downstream for workspace reload (idle)",{reason:s,agentId:e,framework:o.framework,cloudId:c,acpId:u}),p.stop(s).catch(m=>ae.warn("downstream stop failed during reload (ignored)",{reason:s,agentId:e,cloudId:c,err:String(m)}))}}isRuntimePendingPermission(e){let s=this.opts.isRuntimePendingPermission;return!s||!e.downstream?!1:s(e.downstream)}async updateAgent(e){if(!e.cozeIdentity?.trim())return ae.info("_agent/update: empty cozeIdentity, noop",{agentId:e.agentId}),{ok:!0};let s=e.agentId,o=await me(s);if(!o)throw new S("AGENT_NOT_FOUND",`agent not found: ${s}`);if(o.cozeIdentity===e.cozeIdentity)return ae.info("_agent/update: cozeIdentity unchanged, noop",{agentId:s}),{ok:!0};try{await It(o.workspace,o.framework,s,e.cozeIdentity)}catch(c){throw ae.error("_agent/update: writeInstructionFile failed, aborting update",{agentId:s,framework:o.framework,workspace:o.workspace,err:String(c)}),new S("AGENT_PROTOCOL_ERROR",`failed to write instruction file for agent ${s}: ${String(c)}`,{cause:c})}return o.cozeIdentity=e.cozeIdentity,await Ce(o),ae.info("_agent/update: cozeIdentity rewritten",{agentId:s,framework:o.framework}),this.reloadAgentSessions(s,"identity-changed"),{ok:!0}}async disconnectAgent(e){let s=e.agentId;if(!s)throw new S("IPC_BAD_REQUEST","_agent/disconnect: missing agentId");let o=await me(s);return o?(o.disconnectedAt=Date.now(),o.disconnectReason=e.reason??"",await Ce(o),ae.info("agent disconnected",{agentId:s,reason:e.reason??"",force:e.force??!1}),this.opts.disposeAndMarkDisconnected&&await this.opts.disposeAndMarkDisconnected(s,e.reason??"disconnect"),{ok:!0}):(ae.warn("_agent/disconnect: agent not found, ignoring",{agentId:s}),{ok:!0})}async switchModel(e){if(We(e._meta,"_agent/switchModel"),!e.agentId)throw new S("IPC_BAD_REQUEST","_agent/switchModel: missing agentId");let s=e.model?.trim()?e.model:Ne,o=await me(e.agentId);if(!o)throw new S("AGENT_NOT_FOUND",`agent not found: ${e.agentId}`);o.model=s,await Ce(o),ae.info("_agent/switchModel: model persisted",{agentId:e.agentId,model:s,reason:e.reason??""});let c=this.opts.agents.get(e.agentId);if(!c)return ae.info("_agent/switchModel: agent not running, config persisted only",{agentId:e.agentId}),{ok:!0};c.model=s,this.opts.cleanupOpenclawProviders&&await this.opts.cleanupOpenclawProviders(c).catch(u=>ae.warn("cleanupOpenclawProviders before switchModel failed (ignored)",{agentId:e.agentId,err:String(u)}));let d=[];for(let[u,l]of c.allSessionQueues())d.push(l.enqueue(async()=>{let p=c.sessions.get(u);p?.downstream&&(await p.downstream.stop(`switchModel: ${s}`).catch(()=>{}),p.downstream=void 0)}));return await Promise.all(d),ae.info("_agent/switchModel: all session runtimes killed, next prompt will respawn",{agentId:e.agentId,model:s,cloudSessions:d.length}),{ok:!0}}async resetAgent(e){if(We(e._meta,Oe.RESET),!e.agentId)throw new S("IPC_BAD_REQUEST",`${Oe.RESET}: missing agentId`);return await this.runDetailSync(e.agentId,Oe.RESET,e.reason),{ok:!0}}async repairAgent(e){if(We(e._meta,Oe.REPAIR),!e.agentId)throw new S("IPC_BAD_REQUEST",`${Oe.REPAIR}: missing agentId`);let s=await this.loadAgentCfg(e.agentId);if(s&&s.framework!=="openclaw")throw new S("IPC_BAD_REQUEST",`${Oe.REPAIR} only allowed for openclaw, got ${s.framework}`);if(s&&this.opts.openclawRepair)try{await this.opts.openclawRepair(e.agentId,s.workspace)}catch(o){ae.warn("openclaw repair (delete+add) failed (ignored)",{agentId:e.agentId,reason:e.reason,err:String(o)})}return await this.runDetailSync(e.agentId,Oe.REPAIR,e.reason),{ok:!0}}async runDetailSync(e,s,o){if(!this.opts.detailSyncer){ae.warn("detailSyncer not wired, skipping sync",{method:s,agentId:e});return}try{await this.opts.detailSyncer(e)}catch(c){ae.warn("detail sync failed (ignored)",{method:s,agentId:e,reason:o,err:String(c)})}}async getFileTree(e){We(e._meta,"_agent/getFileTree");let s=e._meta,o=At(s),c=await this.resolveWorkspace(o),d=e.filePath??"",u=this.safeJoin(c,d),l=await Qr(u).catch(()=>null);if(!l)throw new S("IPC_BAD_REQUEST",`path not found: ${d}`);if(l.isSymbolicLink())throw new S("IPC_BAD_REQUEST",`symlink not allowed: ${d}`);let p=Mx(e.depth);return l.isDirectory()?{tree:await Nx(c,u,d,p)}:{tree:[{name:Bx(d),path:Qs(d||"."),isDir:!1,size:l.size,modifiedAt:Math.floor(l.mtimeMs)}]}}async getFileContent(e){We(e._meta,"_agent/getFileContent");let s=At(e._meta),o=await this.resolveWorkspace(s);if(!e.filePath)throw new S("IPC_BAD_REQUEST","filePath required");let c=this.safeJoin(o,e.filePath),d=await Qr(c).catch(()=>null);if(!d||!d.isFile())throw new S("IPC_BAD_REQUEST",`not a file: ${e.filePath}`);if(d.isSymbolicLink())throw new S("IPC_BAD_REQUEST",`symlink not allowed: ${e.filePath}`);if(d.size>Ws)throw new S("IPC_BAD_REQUEST",`file too large: ${d.size} bytes (max ${Ws})`);let u=await $s(c);return u.includes(0)?{content:u.toString("base64"),encoding:"base64",size:d.size}:{content:u.toString("utf8"),encoding:"utf-8",size:d.size}}async resolveWorkspace(e){let s=this.opts.agents.get(e);return s?s.workspace:(await me(e).catch(()=>null))?.workspace??Ge(e).workspace}safeJoin(e,s){let o=yx(e,s||"."),c=Vs(e,o);if(c.startsWith("..")||c===".."||c.startsWith(`..${Ys}`))throw new S("IPC_BAD_REQUEST",`path escapes workspace: ${s}`);return o}loadAgentCfg(e){return me(e)}async requireAgentCfg(e){let s=await this.loadAgentCfg(e);if(!s)throw new S("AGENT_NOT_FOUND",`no config for agent: ${e}`);return s}};function Ex(n){let e=n.trim().replace(/[\x00-\x1f<>:"|?*/\\]+/g,"-").replace(/^[\s.-]+|[\s.-]+$/g,"").slice(0,64);if(!e||e==="."||e==="..")throw new S("IPC_BAD_REQUEST",`invalid skill name: ${n}`);if(/^(con|prn|aux|nul|com[1-9]|lpt[1-9])$/i.test(e))throw new S("IPC_BAD_REQUEST",`reserved windows filename: ${n}`);return e}function Ix(n){return n==="claude-code"?Me(".claude","skills"):Me(".agents","skills")}var Ax=3e4,Cx=50*1024*1024,Mn=3e4;async function Zr(n){let{agentId:e,workspace:s,framework:o,skill:c}=n;if(!c.skillName)throw new S("IPC_BAD_REQUEST","skill missing skillName");let d=typeof c.content=="string"&&c.content.length>0,u=typeof c.downloadUrl=="string"&&c.downloadUrl.length>0;if(!d&&!u)throw new S("IPC_BAD_REQUEST",`skill ${c.skillId} missing both content and downloadUrl`);let l=Ex(c.skillName),p=Ix(o),m=Me(p,l),_=Me(s,m);if(await gx(_,{recursive:!0}),d){let I=Buffer.from(c.content,"utf8");Vt(I.length),await Gs(Me(_,"SKILL.md"),I,"utf8")}else{let I=await kx(c.downloadUrl);Dx(I)?await Rx(I,_):await Gs(Me(_,"SKILL.md"),I.toString("utf8"),"utf8")}let y={skillId:c.skillId,skillName:c.skillName,relPath:m,installedAt:Date.now(),...c.description?{description:c.description}:{},...c.icon?{icon:c.icon}:{},...c.version?{version:c.version}:{},...c.downloadUrl?{downloadUrl:c.downloadUrl}:{},...c.config?{config:c.config}:{},...c.builtin?{builtin:c.builtin}:{}};return ae.info("skill installed",{agentId:e,skillId:c.skillId,skillName:c.skillName,relPath:m,source:d?"content":"downloadUrl"}),y}function ei(n,e,s){let o=e.get(s.skillId);if(o!==void 0){n[o]=s;return}e.set(s.skillId,n.length),n.push(s)}function Px(n){return{skillId:n.skillId,skillName:n.skillName,...n.description?{description:n.description}:{},...n.icon?{icon:n.icon}:{},...n.version?{version:n.version}:{},...n.config?{config:n.config}:{},...n.builtin?{builtin:n.builtin}:{}}}async function kx(n){if(!n)throw new S("IPC_BAD_REQUEST","skill missing downloadUrl");if(n.startsWith("data:")){let e=Math.floor(n.length*3/4);Vt(e);let s=Tx(n);return Vt(s.length),s}if(n.startsWith("file:")){let e=new URL(n).pathname,s=await $s(e);return Vt(s.length),s}if(Dn(n)){let e=new AbortController,s=setTimeout(()=>e.abort(),Ax);try{let o=await fetch(n,{signal:e.signal});if(!o.ok)throw new S("IPC_BAD_REQUEST",`fetch skill failed HTTP ${o.status} ${n}`);let c=await o.arrayBuffer();return Vt(c.byteLength),Buffer.from(c)}finally{clearTimeout(s)}}throw new S("IPC_BAD_REQUEST",`unsupported downloadUrl scheme (\u8981 https/data/file): ${n.slice(0,80)}`)}function Vt(n){if(n>Cx)throw new S("IPC_BAD_REQUEST",`skill too large: ${n} bytes`)}function Tx(n){let e=/^data:([^,;]*)(;base64)?,(.*)$/s.exec(n);if(!e)throw new S("IPC_BAD_REQUEST","bad data URL");let s=!!e[2],o=e[3]??"";return s?Buffer.from(o,"base64"):Buffer.from(decodeURIComponent(o),"utf8")}function Dx(n){return n.length>=2&&n[0]===31&&n[1]===139}async function Rx(n,e){await Lx(n),await new Promise((s,o)=>{let c=Js("tar",["-xzf","-","-C",e,"--strip-components=1","--no-same-owner"],{stdio:["pipe","pipe","pipe"]}),d="";c.stderr?.on("data",l=>{d+=String(l)});let u=setTimeout(()=>{c.kill("SIGKILL"),o(new S("IPC_BAD_REQUEST",`tar extract timeout (${Mn}ms)`))},Mn);c.on("error",l=>{clearTimeout(u),o(new S("IPC_BAD_REQUEST",`tar spawn failed: ${l.message}`,{cause:l}))}),c.on("exit",l=>{clearTimeout(u),l===0?s():o(new S("IPC_BAD_REQUEST",`tar exit ${l}${d?`: ${d.trim().slice(0,200)}`:""}`))}),c.stdin?.end(n)})}async function Lx(n){let e=await new Promise((s,o)=>{let c=Js("tar",["-tzvf","-"],{stdio:["pipe","pipe","pipe"]}),d="",u="";c.stdout?.on("data",p=>{d+=String(p)}),c.stderr?.on("data",p=>{u+=String(p)});let l=setTimeout(()=>{c.kill("SIGKILL"),o(new S("IPC_BAD_REQUEST",`tar list timeout (${Mn}ms)`))},Mn);c.on("error",p=>{clearTimeout(l),o(new S("IPC_BAD_REQUEST",`tar list spawn failed: ${p.message}`))}),c.on("exit",p=>{clearTimeout(l),p===0?s(d):o(new S("IPC_BAD_REQUEST",`tar list exit ${p}${u?`: ${u.trim().slice(0,200)}`:""}`))}),c.stdin?.end(n)});for(let s of e.split(`
117
- `)){let o=s.trim();if(!o)continue;let c=o.charCodeAt(0);if(c!==45&&c!==100)throw new S("IPC_BAD_REQUEST",`tar entry kind '${o[0]}' not allowed (symlink/hardlink/special): ${o.slice(0,100)}`);let u=(o.match(/\s(\S.*)$/)?.[1]??"").split(" -> ")[0]?.trim()??"";if(!u)continue;if(u.startsWith("/"))throw new S("IPC_BAD_REQUEST",`tar entry absolute path: ${u}`);if(u.split(/[/\\]/).some(p=>p===".."))throw new S("IPC_BAD_REQUEST",`tar entry contains '..': ${u}`)}}var Ox=5e3;async function Nx(n,e,s,o){return Xs(n,e,s,o,{count:0})}async function Xs(n,e,s,o,c){if(o<=0)return[];let d;try{d=await hx(e,{withFileTypes:!0})}catch{return[]}let u=[];for(let l of d){if(Sx.has(l.name)||l.isSymbolicLink())continue;if(c.count>=Ox){u.push({name:"...",path:"...",isDir:!1,size:0,modifiedAt:0,hasMore:!0});break}let p=Me(e,l.name),m=_x(Me(s,l.name)),_=null;try{_=await Qr(p)}catch{continue}if(_.isSymbolicLink())continue;c.count++;let y={name:l.name,path:Qs(Vs(n,p)),isDir:_.isDirectory(),size:_.size,modifiedAt:Math.floor(_.mtimeMs)};_.isDirectory()&&o>1&&(y.children=await Xs(n,p,m,o-1,c)),u.push(y)}return u.sort((l,p)=>l.isDir!==p.isDir?l.isDir?-1:1:l.name.localeCompare(p.name)),u}function Mx(n){return!n||n<=0?bx:Math.min(n,vx)}function Bx(n){if(!n||n==="."||n==="/")return".";let e=n.split(/[/\\]/);return e[e.length-1]||"."}function Qs(n){return n.split(Ys).join("/")}U();import{readFileSync as op}from"node:fs";import{dirname as cp,join as xp}from"node:path";import{fileURLToPath as up}from"node:url";var rt="0.1.48";var Be=D("agent-health-reporter"),zx=1e4,Yt=class{constructor(e){this.opts=e;this.intervalMs=e.intervalMs??zx}opts;timer=null;inFlight=!1;unsubscribeRegister=null;intervalMs;start(){this.timer||(this.timer=setInterval(()=>{this.tick()},this.intervalMs),this.timer.unref?.(),this.unsubscribeRegister=this.opts.core.onAgentRegister(()=>{this.tick()}),Be.info("heartbeat started",{intervalMs:this.intervalMs}),this.tick())}stop(){this.timer&&(clearInterval(this.timer),this.timer=null,this.unsubscribeRegister&&(this.unsubscribeRegister(),this.unsubscribeRegister=null),Be.info("heartbeat stopped"))}async tick(){if(this.inFlight){Be.debug("previous tick still in-flight, skip");return}let e=this.opts.getDeviceId();if(!e){Be.debug("deviceId not available, skip tick (\u5C1A\u672A pair)");return}this.inFlight=!0;try{let s=[];for(let l of this.opts.core.agents.values()){let p=Fx(l);if(!p)continue;let m={agentId:l.agentId,status:p};l.patToken&&(m.patToken=l.patToken),l.accountId&&(m.accountId=l.accountId),s.push(m)}if(s.length===0)return;let o={agents:s,bridgeVersion:rt,_meta:{cozeDeviceId:e}},c;try{c=await this.opts.core.sendRequest("_agent/health",o,5e3)}catch(l){Be.warn("heartbeat batch send failed",{count:s.length,err:String(l)})}let d=c?.authFailures;if(d&&d.length>0&&(Be.warn("heartbeat received authFailures from cloud",{count:d.length,agentIds:d.map(l=>l.agentId)}),this.opts.onAuthFailures))try{await this.opts.onAuthFailures(d)}catch(l){Be.warn("onAuthFailures callback failed (ignored)",{err:String(l)})}let u=c?.minBridgeVersion;if(u&&(Be.info("heartbeat received minBridgeVersion from cloud",{minV:u}),this.opts.onMinBridgeVersion))try{await this.opts.onMinBridgeVersion(u)}catch(l){Be.warn("onMinBridgeVersion callback failed (ignored)",{err:String(l)})}}finally{this.inFlight=!1}if(this.opts.onTickEnd)try{await this.opts.onTickEnd()}catch(s){Be.warn("onTickEnd hook failed",{err:String(s)})}}};function Fx(n){return n.status==="error"?"error":n.activeTriggers.size>0?"busy":n.status==="ok"?"online":null}nt();import{mkdir as ni,rm as ud}from"node:fs/promises";import{spawn as Jx,spawnSync as $x}from"node:child_process";function Xt(n,e,s){return s===void 0?{jsonrpc:"2.0",id:n,method:e}:{jsonrpc:"2.0",id:n,method:e,params:s}}function Qt(n,e){return e===void 0?{jsonrpc:"2.0",method:n}:{jsonrpc:"2.0",method:n,params:e}}function Pt(n,e){return{jsonrpc:"2.0",id:n,result:e}}function it(n,e){return{jsonrpc:"2.0",id:n,error:e}}var Bn=class extends Error{code;data;constructor(e){super(`JSON-RPC error code=${e.code} ${e.message}`),this.name="RemoteRpcError",this.code=e.code,e.data!==void 0&&(this.data=e.data)}},H={PARSE_ERROR:-32700,INVALID_REQUEST:-32600,METHOD_NOT_FOUND:-32601,INVALID_PARAMS:-32602,INTERNAL_ERROR:-32603,AGENT_NOT_FOUND:-32001,AGENT_BUSY:-32002,AGENT_TIMEOUT:-32003,AGENT_SPAWN_FAILED:-32004,OPERATION_NOT_ALLOWED_FOR_LOCAL:-32005,AGENT_DISCONNECTED:-32006,MODEL_TOKEN_GEN_FAILED:-32009,PATH_OUTSIDE_WORKSPACE:-32010,FILE_TOO_LARGE:-32011,UNSUPPORTED_MIME:-32012,UPLOAD_FAILED:-32013,UPSTREAM_NOT_READY:-32014,BRIDGE_UPGRADING:-32015};function Zs(n){return"method"in n&&"id"in n&&n.id!==void 0}function eo(n){return"method"in n&&!("id"in n)}function zn(n){return!("method"in n)&&"id"in n}var Ux={AGENT_NOT_FOUND:H.AGENT_NOT_FOUND,AGENT_BUSY:H.AGENT_BUSY,AGENT_DISCONNECTED:H.AGENT_DISCONNECTED,AGENT_TIMEOUT:H.AGENT_TIMEOUT,AGENT_SPAWN_FAILED:H.AGENT_SPAWN_FAILED,AGENT_PROTOCOL_ERROR:H.INTERNAL_ERROR,BRIDGE_CONFIG_INVALID:H.INTERNAL_ERROR,BRIDGE_INTERNAL:H.INTERNAL_ERROR,IPC_AUTH_FAILED:H.INTERNAL_ERROR,IPC_BAD_REQUEST:H.INVALID_REQUEST,MODEL_TOKEN_GEN_FAILED:H.MODEL_TOKEN_GEN_FAILED,OPERATION_NOT_ALLOWED_FOR_LOCAL:H.OPERATION_NOT_ALLOWED_FOR_LOCAL,UPSTREAM_DISCONNECTED:H.INTERNAL_ERROR,UPSTREAM_HANDSHAKE_FAILED:H.INTERNAL_ERROR,PATH_OUTSIDE_WORKSPACE:H.PATH_OUTSIDE_WORKSPACE,FILE_TOO_LARGE:H.FILE_TOO_LARGE,UNSUPPORTED_MIME:H.UNSUPPORTED_MIME,UPLOAD_FAILED:H.UPLOAD_FAILED,UPSTREAM_NOT_READY:H.UPSTREAM_NOT_READY,BRIDGE_UPGRADING:H.BRIDGE_UPGRADING};function qx(n){if(n!=null)return n instanceof Error?{name:n.name,message:Zt(n.message)}:typeof n=="string"?Zt(n):typeof n=="object"?jx(n):n}var Hx=[[/\/Users\/[^/\s'"`)]+/g,"/Users/<redacted>"],[/\/home\/[^/\s'"`)]+/g,"/home/<redacted>"],[/[A-Za-z]:\\Users\\[^\\\s'"`)]+/g,"C:\\Users\\<redacted>"],[/(Bearer|Token|Authorization:)\s+[\w._-]+/gi,"$1 <redacted>"],[/\b(sk|pat|ak)[-_][A-Za-z0-9_-]{20,}\b/g,"<redacted-key>"]];function Zt(n){let e=n;for(let[s,o]of Hx)e=e.replace(s,o);return e}function jx(n){let e={};for(let[s,o]of Object.entries(n))typeof o=="string"?e[s]=Zt(o):e[s]=o;return e}function en(n){if(n instanceof S){let e=qx(n.cause),s={bridgeCode:n.code,retriable:n.retriable};return e!==void 0&&(s.cause=e),{code:Ux[n.code]??H.INTERNAL_ERROR,message:Zt(n.message),data:s}}return{code:H.INTERNAL_ERROR,message:Zt(n instanceof Error?n.message:String(n))}}function to(n){let e=n.data,s=e?.bridgeCode??"AGENT_PROTOCOL_ERROR",o=!!e&&typeof e.message=="string"&&!!e.message,c=o?e?.message:n.message,d=n.data;if(o&&e){let{message:u,...l}=e;d=l}return new S(s,c,{retriable:e?.retriable??!1,cause:d})}function ro(n){return`${JSON.stringify(n)}
118
- `}var no=10*1024*1024,Fn=class{buffer="";onError;constructor(e={}){this.onError=e.onError}push(e){if(this.buffer+=typeof e=="string"?e:e.toString("utf8"),this.buffer.length>no){let c=this.buffer.length;return this.buffer="",this.onError?.({line:`<buffer overflow: ${c} bytes, dropped>`,error:new Error(`LdjsonDecoder buffer exceeded ${no} bytes`)}),[]}let s=this.buffer.split(`
119
- `);this.buffer=s.pop()??"";let o=[];for(let c of s){let d=c.replace(/\r$/,"").trim();if(d)try{o.push(JSON.parse(d))}catch(u){this.onError?.({line:d,error:u})}}return o}flush(){if(!this.buffer)return[];let e=this.buffer.replace(/\r$/,"").trim();if(this.buffer="",!e)return[];try{return[JSON.parse(e)]}catch(s){return this.onError?.({line:e,error:s}),[]}}};var so={"session/prompt":"session.prompt","session/cancel":"session.cancel","session/new":"session.new","session/load":"session.load","_agent/create":"agent.create","_agent/health":"agent.health","_agent/pair":"agent.pair","_agent/listSkills":"agent.listSkills","_agent/addSkills":"agent.addSkills","_agent/removeSkills":"agent.removeSkills","_agent/getFileTree":"agent.getFileTree","_agent/getFileContent":"agent.getFileContent","_agent/detail":"agent.detail","_agent/update":"agent.update","_agent/disconnect":"agent.disconnect","_agent/switchModel":"agent.switchModel","_agent/genModelToken":"agent.genModelToken","_agent/reset":"agent.reset","_agent/repair":"agent.repair","session/request_permission":"session.requestPermission",initialize:"initialize"},vp=Object.fromEntries(Object.entries(so).map(([n,e])=>[e,n])),Kx={"session.prompt":["agentId","triggerMsgId","sessionId"],"session.cancel":["agentId","triggerMsgId","sessionId"],"session.new":["agentId"],"session.load":["agentId"],"agent.create":["agentId"],"agent.health":[],"agent.listSkills":["agentId"],"agent.addSkills":["agentId"],"agent.removeSkills":["agentId"],"agent.getFileTree":["agentId"],"agent.getFileContent":["agentId"],"agent.detail":["agentId"],"agent.update":["agentId"],"agent.disconnect":["agentId"],"agent.switchModel":["agentId"],"agent.genModelToken":["agentId","sessionId"],"agent.reset":["agentId"],"agent.repair":["agentId"],"session.requestPermission":["agentId","sessionId"],"agent.pair":[],initialize:[]},kt=class{seq=0;next(e,s){this.seq+=1;let o=so[e]??Gx(e),c=Kx[o]??[],d=[o,String(this.seq)];if(c.length>0){let u=c.map(p=>io(s?.[p]??"")),l=Wx(u).join(":");l&&d.push(l)}else s&&Object.values(s).some(u=>u)&&d.push(Object.values(s).filter(Boolean).map(u=>io(String(u))).join(":"));return d.join("_")}reset(){this.seq=0}};function Gx(n){return n.replace(/[\s/]+/g,".").replace(/_+/g,"-")}function io(n){return n.replace(/[:_\s]+/g,"-")}function Wx(n){let e=n.length;for(;e>0&&!n[e-1];)e-=1;return n.slice(0,e)}function Un(n,e){let s=process.env[n];if(!s)return e;let o=Number(s);return Number.isFinite(o)&&o>0?o:e}U();var Vx=3e4,Yx=200,Xx=Un("COZE_BRIDGE_SESSION_PROMPT_MAX_MS",3600*1e3),oo=500;function Qx(n){try{let e=JSON.stringify(n);return e===void 0||e.length<=oo?n:`${e.slice(0,oo)}...<truncated, total ${e.length} chars>`}catch{return"<unserializable>"}}function ao(n,e){if(!(typeof n!="number"||n<=0))try{if(process.platform==="win32"){let s=["/PID",String(n),"/T"];e==="SIGKILL"&&s.push("/F"),$x("taskkill",s,{stdio:"ignore",windowsHide:!0})}else process.kill(-n,e)}catch{}}var st=class{constructor(e){this.opts=e;this.log=D(`downstream.${this.constructor.name}`),this.decoder=new Fn({onError:s=>this.log.warn("decode line failed",{line:s.line})})}opts;child;decoder;pending=new Map;idAllocator=new kt;updateHandlers=[];agentRequestHandlers=[];exitHandlers=[];log;stopped=!1;stderrRing=[];sanitizeEnv(e){return e}async start(){if(this.child)throw new S("BRIDGE_INTERNAL","Downstream already started");let e=process.platform!=="win32",s=Jx(this.opts.command,this.opts.args,{cwd:this.opts.cwd,env:{...this.sanitizeEnv(process.env),...this.opts.env},stdio:["pipe","pipe","pipe"],detached:e});this.child=s,s.stdout?.setEncoding("utf8"),s.stdout?.on("data",o=>{try{for(let c of this.decoder.push(o))this.dispatch(c)}catch(c){this.log.warn("stdout dispatch threw, swallowed to keep daemon alive",{err:String(c)})}}),s.stderr?.setEncoding("utf8"),s.stderr?.on("data",o=>{let c=o.trimEnd();this.stderrRing.push(c),this.stderrRing.length>Yx&&this.stderrRing.shift(),this.log.debug("stderr",{text:c})}),s.stdin?.on("error",o=>{this.log.warn("child stdin error",{err:String(o)})}),s.stdout?.on("error",o=>{this.log.warn("child stdout error",{err:String(o)})}),s.stderr?.on("error",o=>{this.log.warn("child stderr error",{err:String(o)})}),s.on("exit",(o,c)=>{this.stopped=!0,(o!==0||c!==null)&&this.stderrRing.length>0&&this.log.warn("downstream exited abnormally, recent stderr",{code:o,signal:c,recentStderr:[...this.stderrRing]});try{for(let u of this.decoder.flush())this.dispatch(u)}catch(u){this.log.debug("decoder.flush on exit threw (ignored)",{err:String(u)})}this.failAllPending(new S("AGENT_PROTOCOL_ERROR",`agent exited (${o}/${c})`));for(let u of this.exitHandlers)u(o,c)}),s.on("error",o=>{this.log.error("child error",{err:String(o)}),this.failAllPending(new S("AGENT_SPAWN_FAILED",String(o),{cause:o}))}),this.log.info("downstream started",{command:this.opts.command,pid:s.pid,cwd:this.opts.cwd})}async stop(e){if(!this.child||this.stopped)return;this.stopped=!0,this.log.info("downstream stopping",{reason:e});let s=this.child,o=new Promise(d=>s.once("exit",()=>d()));ao(s.pid,"SIGTERM");let c=setTimeout(()=>{s.killed||ao(s.pid,"SIGKILL")},5e3);try{await o}finally{clearTimeout(c)}}pid(){return this.child?.pid}isAlive(){return!!this.child&&!this.stopped}initialize(e){return this.call("initialize",e)}sessionNew(e){return this.call("session/new",{mcpServers:[],...e})}sessionLoad(e){return this.call("session/load",{mcpServers:[],...e})}sessionPrompt(e,s=Xx){return this.call("session/prompt",e,s)}async sessionCancel(e){!this.child||this.stopped||this.writeFrame(Qt("session/cancel",e))}onUpdate(e){this.updateHandlers.push(e)}onAgentRequest(e){this.agentRequestHandlers.push(e)}respondAgentRequest(e,s){if(!(!this.child||this.stopped))try{this.writeFrame(Pt(e,s))}catch(o){this.log.warn("respondAgentRequest write failed",{id:e,err:String(o)})}}respondAgentRequestError(e,s){if(!(!this.child||this.stopped))try{this.writeFrame(it(e,s))}catch(o){this.log.warn("respondAgentRequestError write failed",{id:e,err:String(o)})}}onExit(e){this.exitHandlers.push(e)}call(e,s,o=Vx){if(!this.child||this.stopped)return Promise.reject(new S("AGENT_PROTOCOL_ERROR","downstream not started"));let c=this.idAllocator.next(e),d=Xt(c,e,s),u=o>0&&Number.isFinite(o);return new Promise((l,p)=>{let m=u?setTimeout(()=>{this.pending.delete(c),p(new S("AGENT_TIMEOUT",`${e} timed out after ${o}ms`))},o):null;this.pending.set(c,{resolve:l,reject:p,timer:m,method:e});try{this.writeFrame(d)}catch(_){m&&clearTimeout(m),this.pending.delete(c),p(_)}})}writeFrame(e){if(!this.child?.stdin||this.child.stdin.destroyed)throw new S("AGENT_PROTOCOL_ERROR","downstream stdin not writable");this.child.stdin.write(ro(e),s=>{s&&this.log.warn("stdin write callback err",{err:String(s)})})}dispatch(e){if(zn(e)){let s=e.id!==null?this.pending.get(e.id):void 0;if(!s){this.log.warn("orphan response",{id:e.id});return}this.pending.delete(e.id),s.timer&&clearTimeout(s.timer),e.error?(this.log.warn("downstream returned error frame",{id:e.id,method:s.method,code:e.error.code,message:e.error.message,data:e.error.data}),s.reject(to(e.error))):e.result===void 0?(this.log.warn("downstream response missing both result and error",{id:e.id,method:s.method}),s.reject(new S("AGENT_PROTOCOL_ERROR",`${s.method} response missing both result and error`))):(this.log.info("downstream returned result",{id:e.id,method:s.method,result:Qx(e.result)}),s.resolve(e.result));return}if(eo(e)){if(e.method==="session/update")for(let s of this.updateHandlers)try{Promise.resolve(s(e.params)).catch(o=>this.log.warn("update handler failed (async)",{err:String(o)}))}catch(o){this.log.warn("update handler threw sync, swallowed",{err:String(o)})}else this.log.info("unknown notification (drop, not forwarded)",{method:e.method});return}if(Zs(e)){let s=e;try{this.handleAgentRequest(s).catch(o=>this.log.error("agent request handler failed (async)",{method:s.method,err:String(o)}))}catch(o){this.log.warn("handleAgentRequest threw sync, swallowed",{method:s.method,err:String(o)})}}}async handleAgentRequest(e){if(this.agentRequestHandlers.length===0){this.writeFrame(it(e.id,{code:-32601,message:`method not handled by Bridge: ${e.method}`}));return}for(let s of this.agentRequestHandlers)try{await s(e)}catch(o){this.log.error("agentRequestHandler threw",{method:e.method,err:String(o)});try{this.writeFrame(it(e.id,en(o)))}catch{}}}failAllPending(e){for(let s of this.pending.values())s.timer&&clearTimeout(s.timer),s.reject(e);this.pending.clear()}};var Zx="@agentclientprotocol/claude-agent-acp@latest";function ed(n){let e={};for(let[s,o]of Object.entries(n))o!==void 0&&(s.startsWith("CLAUDE")||s==="AI_AGENT"||s==="BAGGAGE"||(e[s]=o));return e}var qn=class extends st{framework="claude-code";constructor(e){let s=En("claude-code"),[o,c]=s?[s,[]]:["npx",["-y",Zx]],d=e.command??o,u=e.args??c,l={command:d,args:u,cwd:e.cwd,...e.env?{env:e.env}:{}};super(l)}sanitizeEnv(e){return ed(e)}};import{mkdtempSync as td,rmSync as nd}from"node:fs";import{tmpdir as rd}from"node:os";import{join as id}from"node:path";var sd="@zed-industries/codex-acp@latest",Hn=class extends st{framework="codex";authMethodId;codexHomeDir;constructor(e){let s=En("codex"),[o,c]=s?[s,[]]:["npx",["-y",sd]],d=e.command??o,u=e.args??c,l=e.extraArgs?[...u,...e.extraArgs]:u,p=e.isolateCodexHome?td(id(rd(),"coze-bridge-codex-home-")):void 0,m=p?{...e.env??{},CODEX_HOME:p}:e.env,_={command:d,args:l,cwd:e.cwd,...m?{env:m}:{}};super(_),this.authMethodId=e.authMethodId,this.codexHomeDir=p}async initialize(e){let s=await super.initialize(e);return this.authMethodId&&await this.call("authenticate",{methodId:this.authMethodId}),s}async stop(e){if(await super.stop(e),this.codexHomeDir)try{nd(this.codexHomeDir,{recursive:!0,force:!0})}catch{}}};var od=3e4,Tt=class extends st{framework="openclaw";agentId;sessionName;slashModelOnStart;constructor(e){let s=e.sessionName??"default",o=["acp","--session",`agent:${e.agentId}:${s}`];e.gatewayToken&&o.push("--token",e.gatewayToken);let c={command:e.command,args:o,cwd:e.cwd,...e.env?{env:e.env}:{}};super(c),this.agentId=e.agentId,this.sessionName=s,this.slashModelOnStart=e.slashModelOnStart}async afterSessionEstablished(e){this.slashModelOnStart&&(this.log.info("switching session to per-session provider via /model",{agentId:this.agentId,sessionName:this.sessionName,slash:this.slashModelOnStart}),await this.sessionPrompt({sessionId:e,prompt:[{type:"text",text:`/model ${this.slashModelOnStart}`}]},od))}get acpSessionName(){return this.sessionName}};U();ie();function ti(n){return n.replace(/[^A-Za-z0-9._-]+/g,"-")}var Dt=class{slots=[];running=!1;closed=!1;disposed=!1;enqueue(e){return this.disposed?Promise.reject(new Error("AsyncQueue disposed")):this.closed?Promise.reject(new Error("AsyncQueue closed")):new Promise((s,o)=>{this.slots.push({task:e,resolve:s,reject:o}),this.drain()})}close(){this.closed=!0}dispose(e=new Error("AsyncQueue disposed")){for(this.disposed=!0,this.closed=!0;this.slots.length>0;)this.slots.shift()?.reject(e)}get size(){return this.slots.length}get isRunning(){return this.running}get isDisposed(){return this.disposed}async drain(){if(!this.running){this.running=!0;try{for(;this.slots.length>0&&!this.disposed;){let e=this.slots.shift();if(!e)break;try{let s=await e.task();e.resolve(s)}catch(s){e.reject(s)}}}finally{this.running=!1}}}};var jn=class{agentId;framework;workspace;deployType;accountId;patToken;sessions=new Map;sessionQueues=new Map;activeTriggers=new Map;status="ok";model;lastActiveAt=Date.now();constructor(e){this.agentId=e.agentId,this.framework=e.framework,this.workspace=e.workspace,this.model=e.model,this.deployType=e.deployType??"local",e.accountId&&(this.accountId=e.accountId),e.patToken&&(this.patToken=e.patToken)}setPatToken(e){this.patToken=e}getSessionQueue(e){let s=this.sessionQueues.get(e);return(!s||s.isDisposed)&&(s=new Dt,this.sessionQueues.set(e,s)),s}allSessionQueues(){return this.sessionQueues.entries()}hasSessionQueue(e){let s=this.sessionQueues.get(e);return!!s&&!s.isDisposed}async dispose(e){this.status="stopped";let s=new Error(`AgentSession disposed${e?`: ${e}`:""}`);for(let o of this.sessionQueues.values())o.dispose(s);this.sessionQueues.clear(),await this.killAllRuntimes(e??"dispose")}async killAllRuntimes(e){let s=[];for(let[,o]of this.sessions)tn(o),o.downstream&&(s.push(o.downstream.stop(e).catch(()=>{})),o.downstream=void 0);await Promise.all(s),this.activeTriggers.clear()}};function tn(n){n.idleTimer&&(clearTimeout(n.idleTimer),n.idleTimer=void 0)}import{spawn as ad}from"node:child_process";import{homedir as cd}from"node:os";import{join as xd}from"node:path";An();U();async function uo(){let n=xd(cd(),".openclaw/openclaw.json");return(await Et(n))?.gateway?.auth?.token??""}var co=D("openclaw.config"),dd=[0,5e3,5e3],xo="models.providers.",Kn="agents.defaults.models",Gn=class{command;env;retryDelaysMs;queue=new Dt;constructor(e){this.command=e.command,this.env=e.env??process.env,this.retryDelaysMs=e.retryDelaysMs??dd}async withRetry(e,s){let o;for(let c=0;c<this.retryDelaysMs.length;c++){let d=this.retryDelaysMs[c]??0;d>0&&await new Promise(u=>setTimeout(u,d));try{return await s()}catch(u){o=u,co.warn("openclaw cli failed, will retry",{label:e,attempt:c+1,err:String(u)})}}throw new S("AGENT_SPAWN_FAILED",`openclaw cli ${e} failed after ${this.retryDelaysMs.length} attempts: ${o?.message??"unknown"}`)}runCli(e){return new Promise((s,o)=>{let c=ad(this.command,e,{stdio:["ignore","pipe","pipe"],env:this.env}),d="";c.stderr?.on("data",u=>{d+=u.toString("utf8")}),c.on("error",o),c.on("close",u=>{u===0?s():o(new Error(`exit ${u}: ${d.trim().slice(0,500)}`))})})}async runCliTolerant(e,s){try{await this.runCli(e)}catch(o){let c=String(o);if(s.some(d=>c.includes(d)))return;throw o}}async bestEffortUnset(e,s){try{await this.queue.enqueue(()=>this.withRetry(e,()=>this.runCli(["config","unset",s])))}catch(o){co.warn(`${e} failed (best-effort)`,{configPath:s,err:String(o)})}}ensureProvider(e,s){return this.queue.enqueue(()=>this.withRetry(`config set models.providers.${e}`,()=>this.runCli(["config","set",`${xo}${e}`,JSON.stringify(s),"--strict-json","--merge"])))}removeProvider(e){return this.bestEffortUnset(`config unset models.providers.${e}`,`${xo}${e}`)}addModelToAllowlist(e,s){let o={[e]:s?{alias:s}:{}};return this.queue.enqueue(()=>this.withRetry(`config set ${Kn}[${e}]`,()=>this.runCli(["config","set",Kn,JSON.stringify(o),"--strict-json","--merge"])))}removeModelFromAllowlist(e){return this.bestEffortUnset(`config unset ${Kn}[${e}]`,`${Kn}.${e}`)}ensureAgent(e,s,o){let c=["agents","add",e,"--workspace",s,"--non-interactive"];return o&&c.push("--model",o),this.queue.enqueue(()=>this.withRetry(`agents add ${e}`,()=>this.runCliTolerant(c,["already exists","already registered"])))}deleteAgent(e){return this.queue.enqueue(()=>this.withRetry(`agents delete ${e}`,()=>this.runCliTolerant(["agents","delete",e,"--force"],["not found","does not exist"])))}};var Se=D("agent-manager"),fd=(n,e,s,o,c,d,u,l)=>{switch(n){case"claude-code":{let p={...c?{...Fs(c),...Hs(c,u)}:{},...l??{}};return new qn({cwd:s,...Object.keys(p).length>0?{env:p}:{}})}case"codex":{let p=c?[...Us(c),...Ks(c,u),"-c",'sandbox_mode="danger-full-access"',"-c",'approval_policy="never"']:[],m={...c?qs(c):{},...l??{}},_=!!c;return new Hn({cwd:s,...p.length>0?{extraArgs:p}:{},...Object.keys(m).length>0?{env:m}:{},..._?{authMethodId:"openai-api-key",isolateCodexHome:!0}:{}})}case"openclaw":return new Tt({command:e,cwd:s,agentId:o,...d?{sessionName:ti(d)}:{}})}};function fo(n){return n==="claude-code"||n==="codex"}var ld={path:"",version:"cloud-deployed"},gd={protocolVersion:1,clientCapabilities:{fs:{readTextFile:!0,writeTextFile:!0}}},hd=6e4,Wn=class{paths;config;registry;factory;createTimeoutMs;openclawConfigCache;ensuredProviders=new Set;constructor(e){this.paths=e.paths,this.config=e.config,this.registry=e.registry,this.factory=e.downstreamFactory??fd,this.createTimeoutMs=e.createTimeoutMs??hd}buildBinShimPathEnv(){let e=process.platform==="win32"?";":":";return{PATH:`${this.paths.binDir}${e}${process.env.PATH??""}`}}getOpenclawConfig(){if(!this.openclawConfigCache){let e=this.config.frameworksCache?.openclaw;if(!e?.path)throw new S("AGENT_SPAWN_FAILED","openclaw binary not detected on this machine");this.openclawConfigCache=new Gn({command:e.path})}return this.openclawConfigCache}async createAgent(e){if(!e.agentId)throw new S("IPC_BAD_REQUEST","agentId required");if(!e.framework)throw new S("IPC_BAD_REQUEST","framework required");let s=Jt(e._meta)==="cloud";this.registry.reviveIfDisconnected?.(e.agentId);let o=this.registry.get(e.agentId);if(o){if(o.framework!==e.framework)throw new S("AGENT_BUSY",`agent ${e.agentId} exists with different framework (${o.framework})`);if(o.status==="error")Se.warn("existing agent in error state, rebuilding",{agentId:e.agentId}),await o.dispose("rebuild after error").catch(T=>Se.warn("dispose stale agent failed (ignored)",{err:String(T)})),this.registry.unregister(e.agentId);else{if(e.patToken&&e.patToken!==o.patToken){Se.info("updating agent patToken on re-create (reconnect with new PAT)",{agentId:e.agentId}),o.setPatToken(e.patToken);let T=await me(e.agentId,this.paths).catch(()=>null);T&&(T.patToken=e.patToken,await Ce(T,this.paths))}return Se.info("agent already exists, return current",{agentId:e.agentId}),{ok:!0,agentId:o.agentId,workspace:o.workspace,framework:o.framework}}}if(!s&&!this.config.frameworksCache?.[e.framework])throw new S("AGENT_SPAWN_FAILED",`framework ${e.framework} not detected on this machine; rerun daemon to refresh frameworks_cache`);let d=Ge(e.agentId,this.paths),u=Jt(e._meta),l=e.framework==="openclaw"&&u==="local",p=l?this.config.frameworksCache?.openclaw?.defaultAgent?.workspace:void 0,m=e.workspace??p??d.workspace,_=new AbortController,y=setTimeout(()=>_.abort(new S("AGENT_TIMEOUT",`_agent/create timed out after ${this.createTimeoutMs}ms`)),this.createTimeoutMs),I,L=!1;try{s&&fo(e.framework)&&await Sn(e.framework,_.signal);let T=()=>{if(_.signal.aborted)throw _.signal.reason instanceof Error?_.signal.reason:new S("AGENT_TIMEOUT","_agent/create aborted")};await ni(d.root,{recursive:!0}),await ni(m,{recursive:!0}),await ni(d.logs,{recursive:!0}),T(),l||await It(m,e.framework,e.agentId,e.cozeIdentity),s&&e.framework==="claude-code"&&await Ps(m),T();let P=await me(e.agentId,this.paths).catch(()=>null),j=Bs({model:e.model??P?.model}),Q=ks(e._meta)??P?.accountId,K=e.patToken??P?.patToken;if(I=new jn({agentId:e.agentId,framework:e.framework,workspace:m,model:j.model??Ne,deployType:u,...Q?{accountId:Q}:{},...K?{patToken:K}:{}}),I.status="ok",P?.sessions){for(let[Te,pe]of Object.entries(P.sessions))I.sessions.set(Te,{acpSessionId:pe.acpSessionId,modelToken:pe.modelToken,tokenGeneratedAt:pe.tokenGeneratedAt,lastActiveAt:Date.now(),loadingSession:!1,replySeq:0});let oe=Object.keys(P.sessions).length;oe>0&&Se.info("restored persisted session records (no spawn)",{agentId:e.agentId,count:oe})}this.registry.register(I),L=!0;let $={agentId:e.agentId,framework:e.framework,workspace:m,cozeIdentity:e.cozeIdentity,createdAt:P?.createdAt??Date.now(),sessions:P?.sessions??{},model:j.model};u==="cloud"&&($.deployType="cloud"),Q&&($.accountId=Q),K&&($.patToken=K),P?.skills&&($.skills=P.skills),P?.agentName&&($.agentName=P.agentName),P?.description&&($.description=P.description),e.framework==="openclaw"&&u==="cloud"&&(this.config.frameworksCache?.openclaw?.path?await this.getOpenclawConfig().ensureAgent(e.agentId,m):Se.warn("openclaw binary not on this machine, skip agents add (will fail at session/prompt)",{agentId:e.agentId}));let se=e.initialSkills??[];if(se.length>0){let oe=[...$.skills??[]],Te=new Map(oe.map((xe,de)=>[xe.skillId,de])),pe=0;for(let xe of se)try{let de=await Zr({agentId:e.agentId,workspace:m,framework:e.framework,skill:xe});ei(oe,Te,de),pe++}catch(de){Se.warn("initialSkill install failed (skipping)",{agentId:e.agentId,skillId:xe.skillId,skillName:xe.skillName,err:String(de)})}pe>0&&($.skills=oe,Se.info("initialSkills installed",{agentId:e.agentId,installed:pe,requested:se.length}))}return await Ce($,this.paths),Se.info("agent created (no spawn, lazy on first prompt)",{agentId:e.agentId,framework:e.framework,deployType:u}),{ok:!0,agentId:e.agentId,workspace:m,framework:e.framework}}catch(T){throw Se.error("agent create failed, rolling back",{agentId:e.agentId,err:String(T)}),L&&I&&(await I.dispose("rollback").catch(()=>{}),this.registry.unregister(e.agentId)),await ud(d.root,{recursive:!0,force:!0}).catch(P=>Se.warn("rm agent dir failed (ignored)",{err:String(P)})),T instanceof S?T:new S("AGENT_SPAWN_FAILED",String(T),{cause:T})}finally{clearTimeout(y)}}async spawnSessionDownstream(e,s,o,c){let u=this.config.frameworksCache?.[e.framework];if(!u)if(e.deployType==="cloud"&&fo(e.framework))u=ld;else throw new S("AGENT_SPAWN_FAILED",`framework ${e.framework} not detected on this machine`);let l=e.deployType==="cloud"?{model:e.model,modelToken:s}:void 0,p;e.framework==="openclaw"?p=await this.buildOpenclawDownstream({session:e,modelConfig:l,cloudSessionId:o,cozeEnv:c,command:u.path}):p=this.factory(e.framework,u.path,e.workspace,e.agentId,l,o,c,this.buildBinShimPathEnv());try{return await p.start(),await p.initialize(gd),p}catch(m){throw await p.stop("spawnSessionDownstream failed").catch(()=>{}),m instanceof S?m:new S("AGENT_SPAWN_FAILED",m instanceof Error?m.message:String(m),{cause:m})}}async buildOpenclawDownstream(e){let{session:s,modelConfig:o,cloudSessionId:c,cozeEnv:d,command:u}=e,l=ti(c);if(s.deployType==="local"){let y=this.config.frameworksCache?.openclaw?.defaultAgent;if(!y?.id||!y.workspace)throw new S("AGENT_SPAWN_FAILED","openclaw default agent \u672A\u63A2\u6D4B\u5230; \u8BF7\u5148\u8DD1 `openclaw setup` \u6216 `openclaw agents add` \u521B\u5EFA\u9ED8\u8BA4 agent");return new Tt({command:u,cwd:y.workspace,agentId:y.id,sessionName:l})}let p=await uo(),m=o?js(o,d):null,_;if(m){let y=Xr(c),L=m.models[0]?.id??Ne,T=`${y}/${L}`;if(!this.ensuredProviders.has(T)){let P=this.getOpenclawConfig();await P.ensureProvider(y,m),await P.addModelToAllowlist(T),this.ensuredProviders.add(T)}_=T}return new Tt({command:u,cwd:s.workspace,agentId:s.agentId,sessionName:l,...p?{gatewayToken:p}:{},..._?{slashModelOnStart:_}:{}})}async openclawRepair(e,s){let o=this.getOpenclawConfig();await o.deleteAgent(e),await o.ensureAgent(e,s)}async cleanupOpenclawSessionProviders(e){if(e.framework!=="openclaw"||!this.openclawConfigCache)return;let s=this.openclawConfigCache;for(let o of e.sessions.keys()){let c=Xr(o),d=`${c}/${e.model}`,u=!0;try{await s.removeProvider(c)}catch(l){u=!1,Se.warn("removeProvider failed, keeping ensuredProviders entry",{providerId:c,err:String(l)})}try{await s.removeModelFromAllowlist(d)}catch(l){u=!1,Se.warn("removeModelFromAllowlist failed, keeping ensuredProviders entry",{fullModelId:d,err:String(l)})}u&&this.ensuredProviders.delete(d)}}};import{randomUUID as Ad}from"node:crypto";import{promises as Cd}from"node:fs";import{basename as Pd}from"node:path";import{promises as md}from"node:fs";import{basename as wd}from"node:path";U();var lo=D("file-upload"),_d="/api/coze_claw/file/agent_upload",yd=6e4;async function go(n,e={}){let o=`${Rn(On(e.handshakeBase))}${_d}`,c=e.timeoutMs??yd,d=await md.readFile(n.path),u=new FormData;u.append("agent_id",n.agentId),u.append("session_id",n.sessionId),u.append("file_name",n.name),u.append("file_content",new Blob([d],{type:n.mimeType}),n.name);let l={Authorization:`Bearer ${n.patToken}`,Accept:"application/json","x-coze-version":"3.0",...Ct(e.ppeOverride),...n.accountId?{"x-coze-account":n.accountId}:{}},p=new AbortController,m=setTimeout(()=>p.abort(),c);lo.info("file upload start",{url:o,agentId:n.agentId,sessionId:n.sessionId,name:n.name,bytes:n.sizeBytes,mime:n.mimeType});try{let _=await fetch(o,{method:"POST",headers:l,body:u,signal:p.signal}),y=_.headers.get("x-tt-logid")??"";if(!_.ok){let T=await _.text().catch(()=>"");throw new S("UPLOAD_FAILED",`upload HTTP ${_.status} logid=${y}: ${T.slice(0,200)}`)}let I=await _.json();if(I.code!==void 0&&I.code!==0)throw new S("UPLOAD_FAILED",`upload code=${I.code} msg=${I.msg??"-"} logid=${y}`);let L=I.data?.file?.file_url;if(!L)throw new S("UPLOAD_FAILED",`upload response missing data.file.file_url logid=${y}: ${JSON.stringify(I).slice(0,200)}`);return lo.info("file upload ok",{uri:L,logid:y}),{uri:L}}catch(_){throw _ instanceof S?_:_.name==="AbortError"?new S("UPLOAD_FAILED",`upload timeout (${c}ms) for ${wd(n.path)}`):new S("UPLOAD_FAILED",String(_),{cause:_})}finally{clearTimeout(m)}}U();import{promises as bd}from"node:fs";import{extname as vd}from"node:path";var Sd=[{mime:"image/png",prefix:[137,80,78,71]},{mime:"image/jpeg",prefix:[255,216,255]},{mime:"image/gif",prefix:[71,73,70,56]},{mime:"application/pdf",prefix:[37,80,68,70]}];function Ed(n){return n[0]===82&&n[1]===73&&n[2]===70&&n[3]===70&&n[8]===87&&n[9]===69&&n[10]===66&&n[11]===80}var Id={".txt":"text/plain",".md":"text/markdown",".svg":"image/svg+xml",".json":"application/json"};async function ho(n){let e=await bd.open(n,"r");try{let s=Buffer.alloc(16);if(await e.read(s,0,16,0),Ed(s))return"image/webp";for(let o of Sd)if(o.prefix.every((c,d)=>s[d]===c))return o.mime}finally{await e.close()}return Id[vd(n).toLowerCase()]??"application/octet-stream"}ie();var po=D("agent-send"),mo=50*1024*1024,kd=new Set(["image/png","image/jpeg","image/webp","image/gif","image/svg+xml","application/pdf","application/json","text/plain","text/markdown"]);async function wo(n,e){let s=e.core.get(n.agentId);if(!s)throw new S("AGENT_NOT_FOUND",`agent=${n.agentId}`);if(e.core.disconnectedAgents.has(n.agentId))throw new S("AGENT_DISCONNECTED",`agent=${n.agentId} was disconnected by cloud`);if(s.deployType!=="cloud")throw new S("IPC_BAD_REQUEST",`agent=${n.agentId} is not a cloud agent (deployType=${s.deployType}); send only available for cloud agents`);let o=s.sessions.get(n.sessionId);if(!o)throw new S("AGENT_NOT_FOUND",`session=${n.sessionId} not active in agent=${n.agentId}`);if(!await Es(n.path,s.workspace))throw new S("PATH_OUTSIDE_WORKSPACE",`path=${n.path} not under workspace=${s.workspace}`);let c=await Cd.stat(n.path).catch(()=>null);if(!c||!c.isFile())throw new S("IPC_BAD_REQUEST",`path is not a regular file: ${n.path}`);if(c.size>mo)throw new S("FILE_TOO_LARGE",`${c.size} bytes > limit ${mo}`);let d=await ho(n.path);if(!kd.has(d))throw new S("UNSUPPORTED_MIME",`mime=${d} not in whitelist`);if(n.kind==="image"&&!d.startsWith("image/"))throw new S("UNSUPPORTED_MIME",`kind=image but mime=${d}`);if(!e.core.upstream.isConnected())throw new S("UPSTREAM_NOT_READY","cloud WS not connected");let u=n.name??Pd(n.path),l=await go({patToken:e.patToken,agentId:n.agentId,sessionId:n.sessionId,path:n.path,mimeType:d,name:u,sizeBytes:c.size,...s.accountId?{accountId:s.accountId}:{}},{handshakeBase:e.handshakeBase,ppeOverride:e.ppeOverride}),p={sessionUpdate:"agent_file",messageId:Ad(),content:{type:n.kind==="image"?"image":"resource",uri:l.uri,mimeType:d,name:u,sizeBytes:c.size,...l.fileId!==void 0?{fileId:l.fileId}:{},...n.caption!==void 0?{caption:n.caption}:{}}},m=2,_;for(let y=0;y<=m;y++)try{await e.core.sendAgentFileUpdate(s,o,n.sessionId,p),_=void 0;break}catch(I){_=I,y<m&&(po.warn("sendAgentFileUpdate failed, retrying",{attempt:y+1,err:String(I)}),await new Promise(L=>setTimeout(L,5e3)))}if(_)throw new S("UPSTREAM_NOT_READY",`agent file uploaded to cloud but sendAgentFileUpdate failed after ${m+1} attempts: ${String(_)}`,{cause:_});return po.info("agent file sent",{agentId:n.agentId,sessionId:n.sessionId,kind:n.kind,name:u,bytes:c.size,mime:d,uri:l.uri}),{ok:!0,uri:l.uri,bytes:c.size,mimeType:d,...l.fileId!==void 0?{fileId:l.fileId}:{}}}U();import{execFile as Td}from"node:child_process";import{promisify as Dd}from"node:util";var Rd=Dd(Td),ot=D("coze-cli-installer"),_o="@coze/cli@0.1.3-alpha.89c42a",yo="https://bnpm.byted.org",Ld="coze",Od=5e3,Nd=9e4,bo=1e4,nn=null,ri=!1;async function ii(n,e={}){if(ri)return;if(nn)return nn;let s=e.exec??Rd;return nn=(async()=>{try{let o=await Md(Ld,s);if(o){ot.info("coze-cli already on PATH, skip install + config + auth",{path:o}),ri=!0;return}ot.info("coze-cli install start",{package:_o,registry:yo});try{await s("npm",["i","-g",_o,"--registry",yo],{timeout:Nd,maxBuffer:10*1024*1024}),ot.info("coze-cli install ok")}catch(c){ot.warn("coze-cli install failed (skip subsequent steps)",{err:String(c)});return}if(n.env)try{await s("coze",["config","set","xTTEnv",n.env],{timeout:bo}),ot.info("coze config set xTTEnv ok",{env:n.env})}catch(c){ot.warn("coze config set failed (continue to auth login)",{err:String(c)})}try{await s("coze",["auth","login","--token",n.patToken],{timeout:bo}),ot.info("coze auth login ok")}catch(c){ot.warn("coze auth login failed",{err:String(c)});return}ri=!0}finally{nn=null}})(),nn}async function Md(n,e){let s=process.platform==="win32"?"where":"which";try{let{stdout:o}=await e(s,[n],{timeout:Od});return o.split(`
120
- `)[0]?.trim()||void 0}catch{return}}U();import{spawn as Bd}from"node:child_process";import{constants as vo,access as zd}from"node:fs/promises";import{delimiter as Fd,join as Ud}from"node:path";var So=D("framework-detector"),Eo={"claude-code":"claude",codex:"codex",openclaw:"openclaw"},qd=[".exe",".cmd",".bat",".ps1"],Rt=class{env;constructor(e={}){this.env={pathEnv:e.pathEnv??process.env.PATH??"",platform:e.platform??process.platform,spawn:e.spawn??Bd,access:e.access??zd}}async detect(e){let s=Eo[e],o=await this.which(s);if(!o)return So.debug("framework binary not found",{framework:e,bin:s}),null;let c=e==="openclaw"?["--log-level","silent"]:[],[d,u]=await Promise.all([this.probeVersion(o,c),e==="openclaw"?this.probeOpenclawDefaultAgent(o):Promise.resolve(null)]),l={path:o,version:d};return u&&(l.defaultAgent=u),l}async detectAll(){let e=await Promise.all(Object.keys(Eo).map(async o=>[o,await this.detect(o)])),s={};for(let[o,c]of e)c&&(s[o]=c);return s}async which(e){let s=this.env.pathEnv.split(Fd).filter(Boolean),o=this.env.platform==="win32"?["",...qd]:[""];for(let c of s)for(let d of o){let u=Ud(c,e+d);if(await this.isExecutable(u))return u}return null}async isExecutable(e){try{let s=this.env.platform==="win32"?vo.F_OK:vo.X_OK;return await this.env.access(e,s),!0}catch{return!1}}async probeOpenclawDefaultAgent(e){let s=await this.runProbe(e,["--log-level","silent","agents","list","--json"]);if(!s||s.code!==0)return null;try{let o=JSON.parse(s.stdout);if(!Array.isArray(o))return null;let c=o.find(d=>d?.isDefault===!0);return!c?.id||!c.workspace?null:{id:c.id,workspace:c.workspace}}catch(o){return So.warn("openclaw agents list --json parse failed",{err:String(o)}),null}}async probeVersion(e,s=[]){let o=await this.runProbe(e,[...s,"--version"]);return o&&(jd(o.stdout).split(/\r?\n/)[0]??"").trim()||"unknown"}runProbe(e,s){return new Promise(o=>{let c="",d=!1,u,l=p=>{d||(d=!0,u&&clearTimeout(u),o(p))};try{let p=this.env.spawn(e,s,{stdio:["ignore","pipe","pipe"]});u=setTimeout(()=>{p.kill("SIGKILL"),l(null)},5e3),p.stdout?.on("data",m=>{c+=m.toString("utf8")}),p.on("error",()=>l(null)),p.on("close",m=>l({code:m,stdout:c}))}catch{l(null)}})}},Hd=new RegExp("\x1B\\[[0-9;]*[A-Za-z]","g");function jd(n){return n.replace(Hd,"")}Lt();import{randomBytes as cu}from"node:crypto";import{createReadStream as Gd}from"node:fs";import{mkdir as Wd,readFile as Jd,realpath as $d,stat as Vd,writeFile as Yd}from"node:fs/promises";import{basename as Xd,dirname as si,join as Qd,relative as Zd,resolve as Ao,sep as eu}from"node:path";import{createInterface as tu}from"node:readline";U();var Po=D("fs-rpc"),rn=Un("COZE_BRIDGE_FS_RPC_MAX_BYTES",20*1024*1024);async function ko(n,e){let s=Buffer.byteLength(n.content,"utf8");if(s>rn)throw new S("IPC_BAD_REQUEST",`fs/write_text_file content too large: ${s} bytes > limit ${rn} bytes`);let o=await Do(n.path,e);return await Wd(si(o),{recursive:!0}),await Yd(o,n.content,"utf8"),Po.info("fs/write_text_file ok",{path:o,size:n.content.length}),null}async function To(n,e){let s=await Do(n.path,e),o=await Vd(s),c=typeof n.line=="number"||typeof n.limit=="number";if(o.size>rn&&!c)throw new S("IPC_BAD_REQUEST",`fs/read_text_file too large without line/limit slicing: ${o.size} bytes > ${rn} bytes`);let d;if(c&&o.size>rn)d=await nu(s,n.line??1,n.limit);else{let u=await Jd(s,"utf8");if(c){let l=u.split(`
121
- `),p=Math.max(0,(n.line??1)-1),m=typeof n.limit=="number"?p+n.limit:void 0;d=l.slice(p,m).join(`
122
- `)}else d=u}return Po.info("fs/read_text_file ok",{path:s,size:d.length}),{content:d}}async function nu(n,e,s){let o=tu({input:Gd(n,{encoding:"utf8"}),crlfDelay:Number.POSITIVE_INFINITY}),c=Math.max(0,e-1),d=typeof s=="number"?c+s:Number.POSITIVE_INFINITY,u=[],l=0;try{for await(let p of o)if(l>=c&&l<d&&u.push(p),l++,l>=d)break}finally{o.close()}return u.join(`
123
- `)}async function Do(n,e){if(typeof n!="string"||n.length===0)throw new S("IPC_BAD_REQUEST","path must be a non-empty string");let[s,o]=await Promise.all([Co(Ao(e)),Co(Ao(n))]),c=Zd(s,o);if(c.startsWith("..")||c===".."||c.startsWith(`..${eu}`))throw new S("IPC_BAD_REQUEST",`path escapes workspace: ${n}`);return o}async function Co(n){let e=[],s=n;for(;s!==si(s);)try{let o=await $d(s);return e.length?Qd(o,...e.reverse()):o}catch{e.push(Xd(s)),s=si(s)}return n}U();var Ro=D("prompt-multimodal"),Lo=10*1024*1024,ru=15e3,iu=6;async function Oo(n){let e=new Array(n.length),s=0;async function o(){for(;s<n.length;){let d=s++,u=n[d];u!==void 0&&(e[d]=await su(u))}}let c=Array.from({length:Math.min(iu,n.length)},()=>o());return await Promise.all(c),e}async function su(n){if(n.type!=="image")return n;let e=n;if(e.data||!e.uri||!Dn(e.uri))return n;try{let{buf:s,contentType:o}=await au(e.uri),c=e.mimeType||ou(o)||"application/octet-stream";return Ro.info("image uri fetched and inlined",{uri:e.uri,bytes:s.length,mimeType:c}),{type:"image",data:s.toString("base64"),mimeType:c}}catch(s){return Ro.warn("image fetch failed, degrading to text block",{uri:e.uri,err:String(s)}),{type:"text",text:`[image load failed: ${e.uri}]`}}}function ou(n){if(!n)return;let e=n.indexOf(";");return(e===-1?n:n.slice(0,e)).trim()||void 0}async function au(n){let e=new AbortController,s=setTimeout(()=>e.abort(),ru);try{let o=await fetch(n,{signal:e.signal});if(!o.ok)throw new Error(`HTTP ${o.status} ${o.statusText}`);let c=await o.arrayBuffer();if(c.byteLength>Lo)throw new Error(`image too large: ${c.byteLength} bytes (max ${Lo})`);return{buf:Buffer.from(c),contentType:o.headers.get("content-type")??void 0}}finally{clearTimeout(s)}}nt();Lt();U();var B=D("core"),xu=3e4,du=/^(boe|ppe)_[A-Za-z0-9_-]+$/,uu=3e4,fu=new Set(["_agent/create","session/new","session/load","session/prompt"]),Jn=class{upstream;agents=new Map;disconnectedAgents=new Set;extensions;paths;sessionSpawner;sessionIdleTimeoutMs;upgradeGate;upstreamIds=new kt;pendingUpstream=new Map;pendingBridge=new Map;currentCozeEnv;constructor(e){this.upstream=e.upstream,this.extensions=e.extensions??{},this.paths=e.paths,this.sessionSpawner=e.sessionSpawner,this.sessionIdleTimeoutMs=Io(e.bridgeConfig),this.upgradeGate=e.upgradeGate}registerExtension(e,s){this.extensions[e]=s}getCozeEnv(){return this.currentCozeEnv}async start(){this.upstream.onFrame(e=>this.handleFrame(e)),this.upstream.onConnect?.(({initial:e})=>{e||this.rejectAllPendingOnReconnect()}),await this.upstream.start(),B.info("Core started",{extensions:Object.keys(this.extensions)})}async stop(e){B.info("Core stopping",{reason:e}),await Promise.all([...this.agents.values()].map(s=>s.dispose(e))),this.agents.clear(),await this.upstream.stop(e)}get(e){return this.agents.get(e)}register(e){this.agents.set(e.agentId,e),B.info("agent registered",{agentId:e.agentId,framework:e.framework});for(let s of this.registerHandlers)try{s(e.agentId)}catch(o){B.warn("onAgentRegister handler threw (ignored)",{agentId:e.agentId,err:String(o)})}}onAgentRegister(e){return this.registerHandlers.add(e),()=>this.registerHandlers.delete(e)}registerHandlers=new Set;unregister(e){this.agents.delete(e)}reviveIfDisconnected(e){this.disconnectedAgents.delete(e)&&B.info("agent revived from disconnect",{agentId:e})}attachRuntimeHooks(e,s,o){let c=o.downstream;c&&(c.onUpdate(d=>{o.loadingSession||this.forwardUpdate(e,d)}),c.onAgentRequest(d=>{this.handleAgentRequest(e,c,d)}),c.onExit((d,u)=>{B.info("session runtime exited",{agentId:e.agentId,cloudId:s,code:d,signal:u}),tn(o),o.downstream=void 0,o.replySeq=0,o.acpSessionId&&e.activeTriggers.delete(o.acpSessionId),this.rejectPendingForDownstream(c,"downstream exited")}))}hasPendingPermissionFor(e){for(let s of this.pendingUpstream.values())if(s.downstream===e)return!0;return!1}rejectPendingForDownstream(e,s){let o=[];for(let[c,d]of this.pendingUpstream)d.downstream===e&&o.push(c);if(o.length!==0){B.info("reject pendingUpstream entries (downstream gone)",{reason:s,count:o.length});for(let c of o){let d=this.pendingUpstream.get(c);if(d){this.pendingUpstream.delete(c),this.upstream.send(it(c,{code:H.INTERNAL_ERROR,message:`bridge downstream gone: ${s}`})).catch(u=>B.debug("send error response to upstream failed (ignored)",{err:String(u)}));try{d.downstream.respondAgentRequestError(d.agentRequestId,{code:H.INTERNAL_ERROR,message:`bridge: ${s}`})}catch{}}}}}rejectAllPendingOnReconnect(){let e=this.pendingUpstream.size,s=this.pendingBridge.size;if(!(e===0&&s===0)){B.warn("upstream reconnected, rejecting stale pending requests",{pendingUpstream:e,pendingBridge:s});for(let[,o]of this.pendingUpstream)try{o.downstream.respondAgentRequestError(o.agentRequestId,{code:H.INTERNAL_ERROR,message:"upstream reconnected; please retry"})}catch{}this.pendingUpstream.clear();for(let[,o]of this.pendingBridge)clearTimeout(o.timer),o.reject(new S("UPSTREAM_DISCONNECTED",`${o.method} aborted: upstream reconnected`));this.pendingBridge.clear()}}async handleFrame(e){if(zn(e)){this.handleUpstreamResponse(e);return}if(!("method"in e)||typeof e.method!="string")return;let s="id"in e&&e.id!==void 0?e.id:null,o=e.params?._meta?.cozeEnv;o&&du.test(o)?this.currentCozeEnv=o:o&&B.warn("rejecting cozeEnv with invalid shape, keeping previous",{rejected:o});try{if(this.upgradeGate?.isUpgrading()&&fu.has(e.method)){let c=this.upgradeGate.pendingTarget()??"";throw new S("BRIDGE_UPGRADING",`bridge upgrading to ${c}, retry shortly`,{retriable:!0})}if(e.method.startsWith("_agent/")){let c=this.extensions[e.method];if(!c){s!==null?await this.sendError(s,H.METHOD_NOT_FOUND,`extension not registered: ${e.method}`):B.warn("drop notification: extension not registered",{method:e.method});return}let d=await c(e,this);s!==null&&await this.upstream.send(Pt(s,d));return}if(e.method.startsWith("session/")){let c=await this.routeSessionMethod(e);s!==null&&await this.upstream.send(Pt(s,c));return}if(e.method==="initialize"){s!==null&&await this.upstream.send(Pt(s,{protocolVersion:1,agentCapabilities:{loadSession:!0}}));return}s!==null?await this.sendError(s,H.METHOD_NOT_FOUND,`method not implemented: ${e.method}`):B.warn("drop unknown notification",{method:e.method})}catch(c){B.error("handleFrame failed",{method:e.method,err:String(c)}),s!==null&&await this.upstream.send(it(s,en(c)))}}async routeSessionMethod(e){if(!e.params||typeof e.params!="object")throw new S("IPC_BAD_REQUEST",`${e.method} requires params`);let s=e.params,o=s._meta?.cozeAgentId;if(!o)throw new S("IPC_BAD_REQUEST",`${e.method}: missing _meta.cozeAgentId`);let c=this.agents.get(o);if(!c)throw this.disconnectedAgents.has(o)?new S("AGENT_DISCONNECTED",`agent ${o} has been disconnected; cloud must _agent/create to revive`):new S("AGENT_NOT_FOUND",`agent not found: ${o}`);let d=typeof s.sessionId=="string"?s.sessionId:void 0;if(e.method==="session/cancel"||e.method==="session/new"||!d)return this.dispatchSessionCall(c,e.method,s);let u=Date.now(),l=!1,p=e.method==="session/prompt";p&&this.upgradeGate?.incActive();try{let m=await c.getSessionQueue(d).enqueue(()=>this.dispatchSessionCall(c,e.method,s));return l=!0,m}finally{p&&this.upgradeGate?.decActive(),B.info("session call done",{agentId:c.agentId,method:e.method,durationMs:Date.now()-u,ok:l})}}async dispatchSessionCall(e,s,o){e.lastActiveAt=Date.now();let{stripped:c}=Ts(o);switch(s){case"session/new":{let d=lu();return B.info("session/new ack (lazy spawn)",{agentId:e.agentId,cloudId:d}),{sessionId:d}}case"session/load":{let d=c;return B.info("session/load ack (lazy spawn)",{agentId:e.agentId,cloudId:d.sessionId}),{}}case"session/prompt":{let d=c,u=d.sessionId;if(!u)throw new S("IPC_BAD_REQUEST","session/prompt: missing sessionId");let l=await this.ensureRuntime(e,u);if(l.replySeq=0,await this.ensureDownstream(e,u,l),!l.downstream||!l.acpSessionId)throw new S("BRIDGE_INTERNAL","session runtime not ready after ensureDownstream");let p=o._meta?.cozeTriggerMsgId;p?e.activeTriggers.set(l.acpSessionId,p):e.activeTriggers.delete(l.acpSessionId);let m=await Oo(d.prompt);try{let _=await l.downstream.sessionPrompt({...d,sessionId:l.acpSessionId,prompt:m});return l.lastActiveAt=Date.now(),_}finally{if(e.activeTriggers.delete(l.acpSessionId),l.reloadAfterTurn){l.reloadAfterTurn=!1;let _=l.downstream;_&&(l.downstream=void 0,B.info("reloadAfterTurn: stopping downstream",{agentId:e.agentId,cloudId:u,acpId:l.acpSessionId}),_.stop("reload-after-turn").catch(y=>B.warn("reload-after-turn stop failed (ignored)",{agentId:e.agentId,cloudId:u,err:String(y)})))}else l.downstream?.isAlive()&&this.armIdleTimer(e,u,l)}}case"session/cancel":{let u=c.sessionId;if(!u)throw new S("IPC_BAD_REQUEST","session/cancel: missing sessionId");let l=e.sessions.get(u);if(e.hasSessionQueue(u)){let p=e.getSessionQueue(u);p.size>0&&(B.info("session/cancel: draining queued tasks",{agentId:e.agentId,cloudId:u,queuedCount:p.size}),p.dispose(new S("AGENT_PROTOCOL_ERROR",`cancelled by session/cancel on ${u}`)))}return l?.downstream?.isAlive()&&l.acpSessionId&&await l.downstream.sessionCancel({sessionId:l.acpSessionId}),{ok:!0}}default:throw new S("IPC_BAD_REQUEST",`session method not supported: ${s}`)}}async ensureRuntime(e,s){let o=e.sessions.get(s);if(o)return o;let d={modelToken:e.deployType==="cloud"?await this.requestSessionToken(e.agentId,s):"",tokenGeneratedAt:Date.now(),lastActiveAt:Date.now(),loadingSession:!1,replySeq:0};return e.sessions.set(s,d),await this.persistSessionMapping(e),d}async requestSessionToken(e,s){let o={sessionId:s,_meta:{cozeAgentId:e}};try{let c=await this.sendRequest(Oe.GEN_MODEL_TOKEN,o,uu);if(!c?.modelToken)throw new S("MODEL_TOKEN_GEN_FAILED",`cloud returned empty modelToken (agentId=${e}, cloudSessionId=${s})`);return c.modelToken}catch(c){throw c instanceof S&&c.code==="MODEL_TOKEN_GEN_FAILED"?c:new S("MODEL_TOKEN_GEN_FAILED",c instanceof Error?c.message:String(c),{cause:c})}}async ensureDownstream(e,s,o){if(tn(o),o.downstream?.isAlive())return;if(!this.sessionSpawner)throw new S("AGENT_SPAWN_FAILED","sessionSpawner not wired (cannot spawn per-session downstream)");let c=3,d=3e4,u=o.spawnFailCount??0,l=o.spawnFailedAt??0;if(u>=c&&Date.now()-l<d)throw new S("AGENT_SPAWN_FAILED",`agent ${e.agentId} session ${s} spawn failed ${u} times in a row; please check framework binary / network and retry after ${Math.ceil((d-(Date.now()-l))/1e3)}s`);let p;try{p=await this.sessionSpawner(e,o.modelToken,s,this.currentCozeEnv)}catch(m){throw o.spawnFailCount=u+1,o.spawnFailedAt=Date.now(),o.spawnFailCount>=c&&o.acpSessionId&&(B.warn("clearing stale acpSessionId after repeated spawn failures",{agentId:e.agentId,cloudId:s,staleAcpId:o.acpSessionId}),o.acpSessionId=void 0),m}if(o.spawnFailCount=0,o.spawnFailedAt=void 0,o.downstream=p,this.attachRuntimeHooks(e,s,o),o.acpSessionId){o.loadingSession=!0;try{await p.sessionLoad({sessionId:o.acpSessionId,cwd:e.workspace}),B.info("session restored via session/load",{agentId:e.agentId,cloudId:s,acpId:o.acpSessionId})}catch(m){B.warn("session/load failed, fallback to session/new",{agentId:e.agentId,cloudId:s,acpId:o.acpSessionId,err:String(m)}),o.acpSessionId=void 0;let _=await p.sessionNew({cwd:e.workspace});o.acpSessionId=_.sessionId,await this.persistSessionMapping(e)}finally{o.loadingSession=!1}}else{let m=await p.sessionNew({cwd:e.workspace});o.acpSessionId=m.sessionId,await this.persistSessionMapping(e)}p.afterSessionEstablished&&o.acpSessionId&&await p.afterSessionEstablished(o.acpSessionId)}armIdleTimer(e,s,o){if(tn(o),this.isRuntimeBusy(e,o)){B.debug("skip idle timer: runtime busy (in-flight turn / pending permission)",{agentId:e.agentId,cloudId:s});return}o.idleTimer=setTimeout(()=>{if(o.idleTimer=void 0,this.isRuntimeBusy(e,o)){B.info("idle reaper fired but runtime busy, re-arming",{agentId:e.agentId,cloudId:s}),this.armIdleTimer(e,s,o);return}B.info("session runtime idle timeout, killing downstream",{agentId:e.agentId,cloudId:s});let c=o.downstream;o.downstream=void 0,o.acpSessionId&&e.activeTriggers.delete(o.acpSessionId),c&&c.stop("idle timeout").catch(d=>B.warn("idle stop failed (ignored)",{agentId:e.agentId,cloudId:s,err:String(d)}))},this.sessionIdleTimeoutMs),o.idleTimer.unref?.()}isRuntimeBusy(e,s){if(s.acpSessionId&&e.activeTriggers.has(s.acpSessionId))return!0;let o=s.downstream;if(!o)return!1;for(let c of this.pendingUpstream.values())if(c.downstream===o)return!0;return!1}async sendAgentFileUpdate(e,s,o,c){let d={cozeAgentId:e.agentId,cozeReplySeqID:++s.replySeq};if(s.acpSessionId){let u=e.activeTriggers.get(s.acpSessionId);u&&(d.cozeTriggerMsgId=u)}await this.upstream.send(Qt("session/update",{sessionId:o,update:c,_meta:d}))}forwardUpdate(e,s){let o=s.sessionId,c=this.reverseSessionId(e,o);if(!c){B.debug("drop update for unknown session",{agentId:e.agentId,acpId:o});return}let d=e.sessions.get(c);if(!d){B.debug("drop update: runtime gone",{agentId:e.agentId,cloudId:c});return}if(hu(s)){B.debug("drop codex metadata-warn chunk",{agentId:e.agentId,acpId:o});return}let u={cozeAgentId:e.agentId,cozeReplySeqID:++d.replySeq},l=e.activeTriggers.get(o);l&&(u.cozeTriggerMsgId=l),this.upstream.send(Qt("session/update",{...s,sessionId:c,_meta:u})).catch(p=>B.warn("forward update failed",{agentId:e.agentId,err:String(p)}))}handleAgentRequest(e,s,o){if(o.method==="session/request_permission"){this.forwardPermissionRequest(e,s,o);return}if(o.method==="fs/write_text_file"||o.method==="fs/read_text_file"){this.handleFsRpcRequest(e,s,o);return}B.warn("unhandled agent request,returning method_not_found",{agentId:e.agentId,method:o.method}),s.respondAgentRequestError(o.id,{code:H.METHOD_NOT_FOUND,message:`method not handled by Bridge: ${o.method}`})}async handleFsRpcRequest(e,s,o){try{let c=e.workspace;if(o.method==="fs/write_text_file"){let d=o.params??{},u=await ko(d,c);s.respondAgentRequest(o.id,u)}else{let d=o.params??{},u=await To(d,c);s.respondAgentRequest(o.id,u)}}catch(c){B.warn("fs rpc handler failed",{agentId:e.agentId,method:o.method,err:String(c)}),s.respondAgentRequestError(o.id,en(c))}}forwardPermissionRequest(e,s,o){let c=this.upstreamIds.next("session/request_permission"),d=o.params??{},l=d.sessionId,p=l?e.activeTriggers.get(l):void 0,m={cozeAgentId:e.agentId};p&&(m.cozeTriggerMsgId=p);let _=l?this.reverseSessionId(e,l):void 0,y={...d,..._?{sessionId:_}:{},_meta:m};this.pendingUpstream.set(c,{agentRequestId:o.id,agentId:e.agentId,downstream:s,method:o.method}),B.info("forward permission_request \u2192 upstream",{agentId:e.agentId,upstreamId:c,acpSessionId:l,cloudSessionId:_,toolCallId:d.toolCall?.toolCallId,options:d.options?.map(I=>({optionId:I.optionId,kind:I.kind,name:I.name}))}),this.upstream.send(Xt(c,"session/request_permission",y)).catch(I=>{this.pendingUpstream.delete(c),B.error("forward permission request failed",{agentId:e.agentId,err:String(I)}),s.respondAgentRequestError(o.id,{code:H.INTERNAL_ERROR,message:`upstream send failed: ${String(I)}`})})}handleUpstreamResponse(e){if(e.id===null)return;let s=this.lookupPending(this.pendingUpstream,e.id,"upstream");if(s){this.pendingUpstream.delete(s.key);let c=s.value;e.error?(B.info("upstream \u2192 permission response (error)",{agentId:c.agentId,upstreamId:e.id,method:c.method,error:e.error}),c.downstream.respondAgentRequestError(c.agentRequestId,e.error)):(c.method==="session/request_permission"&&gu(e.result,c),B.info("upstream \u2192 permission response (result)",{agentId:c.agentId,upstreamId:e.id,method:c.method,result:e.result}),c.downstream.respondAgentRequest(c.agentRequestId,e.result));return}let o=this.lookupPending(this.pendingBridge,e.id,"bridge");if(o){this.pendingBridge.delete(o.key),clearTimeout(o.value.timer),e.error?o.value.reject(new Bn(e.error)):o.value.resolve(e.result);return}B.debug("orphan upstream response (no pending)",{id:e.id})}lookupPending(e,s,o){let c=e.get(s);if(c)return{value:c,key:s};if(typeof s=="number"){let d=String(s),u=e.get(d);if(u)return B.warn(`${o} id type mismatch: number received but Bridge expected string`,{rawId:s,normalizedId:d}),{value:u,key:d}}}sendRequest(e,s,o=xu){let c=this.upstreamIds.next(e);return new Promise((d,u)=>{let l=setTimeout(()=>{this.pendingBridge.delete(c),u(new S("AGENT_TIMEOUT",`${e} timed out after ${o}ms`))},o);this.pendingBridge.set(c,{method:e,resolve:d,reject:u,timer:l}),this.upstream.send(Xt(c,e,s)).catch(p=>{let m=this.pendingBridge.get(c);m&&(clearTimeout(m.timer),this.pendingBridge.delete(c)),u(p)})})}async persistSessionMapping(e){if(this.paths)try{let s=new Map;for(let[o,c]of e.sessions){let d={modelToken:c.modelToken,tokenGeneratedAt:c.tokenGeneratedAt};c.acpSessionId&&(d.acpSessionId=c.acpSessionId),s.set(o,d)}await Wr(e.agentId,s,this.paths)}catch(s){B.warn("persist session mapping failed",{agentId:e.agentId,err:String(s)})}}reverseSessionId(e,s){for(let[o,c]of e.sessions.entries())if(c.acpSessionId===s)return o}sendError(e,s,o){return this.upstream.send(it(e,{code:s,message:o,data:{bridgeVersion:rt}}))}};function lu(){return cu(16).toString("hex")}function gu(n,e){if(!n||typeof n!="object"){B.warn("permission response: result not an object (suspicious)",{agentId:e.agentId,result:n});return}let s=n;if("kind"in s&&!("outcome"in s)){B.warn('permission response: top-level "kind" field (D66 historical bug shape)',{agentId:e.agentId,result:n});return}let o=s.outcome;if(!o||typeof o!="object"){B.warn("permission response: missing or non-object outcome field",{agentId:e.agentId,result:n});return}let d=o.outcome;(typeof d!="string"||d!=="selected"&&d!=="cancelled")&&B.warn("permission response: unknown outcome discriminant",{agentId:e.agentId,outcomeValue:d,result:n})}function hu(n){let e=n.update;if(e?.sessionUpdate!=="agent_message_chunk")return!1;let s=e.content;if(!s||typeof s!="object")return!1;let o=s;return o.type!=="text"||typeof o.text!="string"?!1:o.text.startsWith("Model metadata for `")}U();ie();import{randomBytes as pu}from"node:crypto";import{chmod as mu,mkdir as wu,writeFile as No}from"node:fs/promises";import{createServer as _u}from"node:http";import{dirname as yu}from"node:path";var bu=1e6,oi=D("ipc"),$n=class{server=null;port=0;token="";routes;paths;constructor(e){this.routes=new Map(e.routes.map(s=>[`${s.method} ${s.path}`,s])),this.paths=e.paths??q()}async start(){this.token=pu(32).toString("hex");let e=_u((o,c)=>{this.dispatch(o,c)});this.server=e,await new Promise((o,c)=>{e.once("error",c),e.listen(0,"127.0.0.1",()=>o())});let s=e.address();if(!s||typeof s!="object")throw new Error("failed to obtain IPC port");return this.port=s.port,await this.persistAuthFiles(),oi.info("IPC listening",{port:this.port}),{port:this.port,token:this.token}}async stop(){let e=this.server;e&&(await new Promise((s,o)=>{e.close(c=>c?o(c):s())}),this.server=null)}async persistAuthFiles(){await wu(yu(this.paths.portFile),{recursive:!0}),await No(this.paths.portFile,String(this.port),"utf8"),await No(this.paths.tokenFile,this.token,{encoding:"utf8",mode:384});try{await mu(this.paths.tokenFile,384)}catch(e){oi.warn("chmod token file failed (non-POSIX?)",{err:String(e)})}}async dispatch(e,s){if(e.headers.authorization!==`Bearer ${this.token}`){sn(s,401,{error:"unauthorized"});return}let c=`${e.method} ${(e.url??"").split("?")[0]}`,d=this.routes.get(c);if(!d){sn(s,404,{error:"not found"});return}let u=null;if(e.method==="POST")try{u=await vu(e)}catch(l){sn(s,400,{error:"invalid json",detail:String(l)});return}try{let l=await d.handler(u,e);sn(s,200,l??{ok:!0})}catch(l){oi.error("IPC handler failed",{key:c,err:String(l)}),sn(s,500,{error:l instanceof Error?l.message:String(l)})}}};function sn(n,e,s){n.statusCode=e,n.setHeader("content-type","application/json"),n.end(JSON.stringify(s))}async function vu(n){let e=[],s=0;for await(let c of n){let d=c;if(s+=d.length,s>bu)throw new Error("body too large");e.push(d)}let o=Buffer.concat(e).toString("utf8");return o?JSON.parse(o):null}import{sep as Mo}from"node:path";import{fileURLToPath as Su}from"node:url";function Bo(){return Eu(Su(import.meta.url))}function Eu(n){let e=`${Mo}src${Mo}`;return n.includes(e)}U();ie();import{spawn as Iu}from"node:child_process";import{existsSync as Au,mkdirSync as Cu,openSync as Pu}from"node:fs";import{dirname as ku}from"node:path";import{fileURLToPath as Tu}from"node:url";var Du=D("spawn-helper");function Ru(n){return Au(n.libEntry)?n.libEntry:Tu(new URL("../index.ts",import.meta.url))}function Lu(n,e,s){let o=n.endsWith(".ts"),c=["--upgrade-helper",`--target-version=${e}`,`--old-pid=${s}`];return o?["--import","tsx/esm",n,...c]:[n,...c]}async function zo(n,e,s={}){let o=s.paths??q(),c=Ru(o);Cu(ku(o.logFile),{recursive:!0});let d=Pu(o.logFile,"a"),u=Lu(c,n,e),l=Iu(process.execPath,u,{detached:!0,stdio:["ignore",d,d],env:{...process.env,COZE_BRIDGE_UPGRADE_HELPER:"1"}});if(l.unref(),typeof l.pid!="number")throw new Error("failed to spawn upgrade helper (no pid)");Du.info("upgrade helper spawned",{pid:l.pid,targetVersion:n,oldPid:e,entry:c})}U();import{mkdir as Ou,writeFile as Nu}from"node:fs/promises";import{dirname as Mu}from"node:path";import{gunzipSync as Bu}from"node:zlib";var ai=D("tarball-downloader"),zu="https://registry.npmjs.org",Fo="package/dist/index.js";async function Uo(n,e,s={}){if(!/^[\w.\-+]+$/.test(n))throw new Error(`invalid version string: ${JSON.stringify(n)}`);let c=`${(s.registry??zu).replace(/\/+$/,"")}/coze-bridge/${n}`;ai.info("fetching tarball metadata",{metaUrl:c});let d=await fetch(c);if(!d.ok)throw new Error(`registry metadata ${c} returned ${d.status}`);let l=(await d.json())?.dist?.tarball;if(!l)throw new Error(`registry metadata missing dist.tarball for ${n}`);ai.info("downloading tarball",{tarballUrl:l});let p=await fetch(l);if(!p.ok)throw new Error(`tarball ${l} returned ${p.status}`);let m=Buffer.from(await p.arrayBuffer()),_=Bu(m),y=Fu(_,Fo);if(!y)throw new Error(`tarball missing entry ${Fo}`);await Ou(Mu(e),{recursive:!0}),await Nu(e,y),ai.info("dist extracted",{destPath:e,bytes:y.length})}function Fu(n,e){let s=0;for(;s+512<=n.length;){let o=n.subarray(s,s+512);if(o.every(_=>_===0))return null;let c=o.subarray(0,100),d=c.indexOf(0),u=c.subarray(0,d===-1?100:d).toString("utf8"),l=o.subarray(124,136).toString("ascii").trim().replace(/\0/g,""),p=Number.parseInt(l,8)||0,m=s+512;if(u===e)return n.subarray(m,m+p);s=m+Math.ceil(p/512)*512}return null}Lt();U();import{resolve as Uu}from"node:path";function qo(n,e){let s=n.split(".").map(Number),o=e.split(".").map(Number),c=Math.max(s.length,o.length);for(let d=0;d<c;d++){let u=s[d]??0,l=o[d]??0;if(u<l)return!0;if(u>l)return!1}return!1}var ft=D("upgrade-manager"),qu=300*1e3,Hu=3,Vn=class{constructor(e){this.opts=e}opts;inFlightTarget=null;async requestUpgrade(e){if(this.inFlightTarget===e){ft.debug("upgrade already in-flight, skip",{targetVersion:e});return}this.inFlightTarget=e;try{let s=await at(this.opts.paths.configFile)??{};if(s.disableAutoUpgrade){ft.info("disableAutoUpgrade=true, skip",{targetVersion:e});return}if(this.opts.isDevMode()){ft.warn("dev mode, skip auto-upgrade",{targetVersion:e});return}if(!qo(this.opts.currentVersion,e)){ft.debug("local version >= target, skip",{local:this.opts.currentVersion,target:e});return}let o=s.upgradeAttempts?.[e];if((o?.count??0)>=Hu){ft.warn("upgrade attempts cap reached, skip",{targetVersion:e,count:o?.count});return}let c=Uu(this.opts.paths.libDir,"index.js.next");try{await this.opts.download(e,c)}catch(u){await this.recordAttempt(s,e,String(u)),ft.warn("download failed, attempt recorded",{targetVersion:e,err:String(u)});return}this.opts.daemon.markUpgradePending(e);let d=await this.opts.daemon.waitIdle(qu);ft.info("waitIdle done",{result:d}),await this.opts.spawnHelper(e,process.pid),this.opts.daemon.exit(0)}finally{this.inFlightTarget=null}}async recordAttempt(e,s,o){e.upgradeAttempts=e.upgradeAttempts??{};let c=e.upgradeAttempts[s];e.upgradeAttempts[s]={count:(c?.count??0)+1,lastAt:Date.now(),...o?{lastError:o}:{}},await ze(e,this.opts.paths.configFile)}};var xc=Ke(Qo(),1);var Sl=Ke(Ja(),1),El=Ke(ur(),1),Il=Ke(Mt(),1),Al=Ke(yi(),1),Cl=Ke(Si(),1),Pl=Ke(ki(),1),nc=Ke(hr(),1),kl=Ke(tc(),1);var rc=nc.default;U();var ge=D("upstream.frontier"),sc="application/json",oc="none",gn=class{constructor(e){this.opts=e}opts;fws=null;handler=null;connectHandlers=[];opened=!1;openCount=0;async start(){if(this.fws){ge.warn("start called on already-started FrontierUpstream; noop");return}let e={Authorization:`Bearer ${this.opts.privatecode}`,Origin:Ls,...Ct(this.opts.ppeOverride)};class s extends rc{constructor(l){super(l,Rs,{headers:e})}send(l,...p){if(hs("debug"))try{let m;typeof l=="string"?m=Buffer.from(l,"utf8"):l instanceof Buffer?m=l:l instanceof ArrayBuffer?m=new Uint8Array(l):ArrayBuffer.isView(l)?m=new Uint8Array(l.buffer,l.byteOffset,l.byteLength):m=new Uint8Array(0);let _=Buffer.from(m.slice(0,128)).toString("hex");ge.debug("WS raw frame out",{bytes:m.byteLength,headHex:_})}catch(m){ge.warn("WS raw frame dump failed",{err:String(m)})}super.send(l,...p)}}let o=Ns(this.opts.urlOverride),c={url:o,ws:s,fpID:Ds,aID:Ln,accessKey:this.opts.handshake.accessKey,deviceID:this.opts.handshake.deviceId,payloadType:{type:sc,force:!0},payloadEncoding:{encoding:oc,force:!0},enableTransformTextPayload:!0,enableQoS:!1,enableAutoAck:!1,automaticOpen:!1,maxRetries:Number.POSITIVE_INFINITY,debug:this.opts.debug??!1},d=new xc.FWS(c);d.onopen=()=>{this.opened=!0,this.openCount+=1;let u=this.openCount===1;ge.info("frontier opened",{url:o,remoteDeviceId:this.opts.handshake.deviceId,initial:u,openCount:this.openCount});for(let l of this.connectHandlers)Promise.resolve(l({initial:u})).catch(p=>ge.warn("onConnect handler threw (ignored)",{err:String(p)}))},d.onclose=u=>{this.opened=!1,ge.info("frontier closed",{code:u.code,reason:u.reason,willReconnect:u.willReconnect})},d.onerror=u=>{ge.warn("frontier error",{code:u.code,msg:u.message})},d.onmessage=u=>this.handleMessage(u),this.fws=d,await d.connect()}async stop(e){let s=this.fws;if(s){this.fws=null,this.opened=!1;try{s.close(1e3,e??"bridge shutdown")}catch(o){ge.warn("frontier close threw (ignored)",{err:String(o)})}}}async send(e){let s=this.fws;if(!s)throw new S("UPSTREAM_DISCONNECTED","frontier upstream not started");if(!this.isConnected())throw new S("UPSTREAM_DISCONNECTED",`frontier ws not open (opened=${this.opened}, readyState=${s.readyState}); refusing to silently buffer`);this.injectAgentPatToken(e);let o=JSON.stringify(e),c=e;ac(c)||ge.info("frontier frame out",{method:c.method,jsonrpcId:c.id,size:o.length});try{await s.send(o,{service:33555712,method:1,payloadType:sc,payloadEncoding:oc})}catch(u){throw ge.warn("frontier frame send failed",{method:c.method,jsonrpcId:c.id,err:String(u)}),new S("UPSTREAM_DISCONNECTED",`frontier send failed: ${String(u)}`,{cause:u})}}onFrame(e){this.handler=e}onConnect(e){this.connectHandlers.push(e)}isConnected(){return this.opened&&this.fws?.readyState===1}injectAgentPatToken(e){let s=this.opts.getPatTokenForAgent;if(!s)return;let o=e.params?._meta;if(!o?.cozeAgentId)return;let c=s(o.cozeAgentId);c&&(o.cozePatToken=c)}handleMessage(e){let s=e.message?.service;if(s!==33555712){ge.debug("drop non-adapter frontier frame",{service:s});return}let o=Ll(e);if(!o){ge.debug("frontier message without text payload, drop",{payloadType:e.message?.payloadType});return}if(!this.handler){ge.debug("frame received but no onFrame handler",{size:o.length});return}let c;try{c=JSON.parse(o)}catch(u){ge.warn("frontier message JSON parse failed",{err:String(u),head:o.slice(0,80)});return}let d=c;ac(d)||ge.info("frontier frame in",{logid:Rl(e.message?.LogID),logidNew:e.message?.LogIDNew,msgId:e.message?.msgID,jsonrpcId:d.id,method:d.method,body:Dl(o)}),Promise.resolve(this.handler(c)).catch(u=>ge.warn("frontier frame handler threw",{err:String(u)}))}};function ac(n){return n.method==="_agent/health"?!0:typeof n.id=="string"&&n.id.startsWith("agent.health_")}var cc=2e3;function Dl(n){return n.length<=cc?n:`${n.slice(0,cc)}...<truncated, total ${n.length} chars>`}function Rl(n){return n?n.high===0?String(n.low>>>0):`${n.high.toString(16)}${(n.low>>>0).toString(16).padStart(8,"0")}`:""}function Ll(n){let e=n.message;if(e?.textPayload)return e.textPayload;let s=e?.payload;if(!s)return null;try{return Buffer.from(s).toString("utf8")}catch{return null}}U();var Di=D("upstream.switchable"),mr=class{inner;handler=null;connectHandlers=[];constructor(e){this.inner=e}async swap(e,s){if(this.inner===e)return;Di.info("swap upstream",{reason:s});let o=this.inner;if(this.inner=e,this.handler&&e.onFrame(this.handler),e.onConnect)for(let c of this.connectHandlers)e.onConnect(c);try{await e.start()}catch(c){throw Di.error("swap target start failed, reverting",{err:String(c)}),this.inner=o,c}await o.stop(s??"swapped").catch(c=>Di.warn("previous upstream stop threw (ignored)",{err:String(c)}))}current(){return this.inner}start(){return this.inner.start()}stop(e){return this.inner.stop(e)}send(e){return this.inner.send(e)}onFrame(e){this.handler=e,this.inner.onFrame(e)}onConnect(e){this.connectHandlers.push(e),this.inner.onConnect?.(e)}isConnected(){return this.inner.isConnected()}};U();var Ri=D("upstream"),Ht=class{handler=null;async start(){Ri.info("NoopUpstream started (M1 skeleton; real Frontier wired in M4)")}async stop(e){Ri.info("NoopUpstream stopped",{reason:e})}async send(e){Ri.debug("NoopUpstream.send (dropped)",{method:"method"in e?e.method:void 0})}onFrame(e){this.handler=e}isConnected(){return!1}async injectFrame(e){this.handler&&await this.handler(e)}};U();U();ie();import{promises as Li}from"node:fs";import{dirname as Ol}from"node:path";var Nl=D("pat-token-store");async function dc(n=q()){try{let s=(await Li.readFile(n.patTokenFile,"utf8")).trim();return s.length>0?s:null}catch(e){return e?.code!=="ENOENT"&&Nl.warn("read pat-token failed (treating as missing)",{err:String(e)}),null}}async function hn(n,e=q()){if(!n)throw new Error("writePatToken: empty patToken");await Li.mkdir(Ol(e.patTokenFile),{recursive:!0}),await Li.writeFile(e.patTokenFile,n,{encoding:"utf8",mode:384})}ie();ie();import{promises as wr}from"node:fs";import{join as Ml}from"node:path";function Bl(n){return`#!/bin/sh
115
+ `;var ve=D("agent-detail-sync"),fx=6e4,lx=5*6e4,Nn=class{constructor(e){this.opts=e}opts;retryQueue=new Map;async syncAll(e){let s=this.opts.paths.agentsRoot,o;try{o=await ux(s)}catch(a){ve.info("agents dir not found, skip detail sync",{root:s,err:String(a)});return}ve.info("starting detail sync",{reason:e,count:o.length}),await Promise.allSettled(o.map(async a=>{let x=await we(a,this.opts.paths).catch(()=>null);if(x){if(x.disconnectedAt){ve.debug("detail sync: skip disconnected agent",{agentId:a});return}try{await this.syncOne(a,x)}catch(u){ve.warn("detail sync failed for agent, skipping",{agentId:a,err:String(u)})}}})),ve.info("detail sync done",{reason:e})}async retryPending(){if(this.retryQueue.size===0)return;let e=Date.now(),s=[];for(let[o,a]of this.retryQueue)e>=a.dueAt&&s.push(o);if(s.length!==0){ve.info("retrying pending detail syncs",{count:s.length});for(let o of s)try{await this.syncOne(o)}catch(a){ve.debug("detail sync retry still failing, will try again",{agentId:o,err:String(a)})}}}async syncOne(e,s){let o=s??await we(e,this.opts.paths);if(!o){ve.info("detail sync: agent config missing, skip",{agentId:e});return}let a;try{a=await this.opts.sendDetail({_meta:{cozeAgentId:e}}),this.retryQueue.delete(e)}catch(f){ve.warn("detail RPC failed, using local data",{agentId:e,err:String(f)});let g=this.retryQueue.get(e),p=g?Math.min(g.currentDelay*2,lx):fx;this.retryQueue.set(e,{dueAt:Date.now()+p,currentDelay:p});return}if(a.agentId&&a.agentId!==e){ve.warn("detail response agentId mismatch, ignoring",{agentId:e,responseAgentId:a.agentId});return}let x=!1,u=!1;if(a.agentName&&a.agentName!==o.agentName&&(o.agentName=a.agentName,x=!0),a.description!==void 0&&a.description!==o.description&&(o.description=a.description,x=!0),a.cozeIdentity&&a.cozeIdentity!==o.cozeIdentity&&(o.cozeIdentity=a.cozeIdentity,x=!0,u=!0),a.deployType&&ve.info("detail.deployType",{agentId:e,deployType:a.deployType}),!x){ve.debug("detail sync: no diff",{agentId:e});return}await Ie(o,this.opts.paths),ve.info("detail sync: config updated",{agentId:e,identityChanged:u,agentName:o.agentName}),u&&(await Pt(o.workspace,o.framework,e,o.cozeIdentity),this.opts.handlers.reloadAgentSessionsPublic(e,"detail-sync"))}};rt();import{spawn as Xs}from"node:child_process";import{lstat as ni,mkdir as px,readFile as Qs,readdir as mx,rm as _x,stat as yx,writeFile as Vs}from"node:fs/promises";import{join as Be,normalize as bx,relative as Zs,resolve as vx,sep as eo}from"node:path";var Le={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 Xt(n){return n?.cozeDeployType==="cloud"?"cloud":"local"}function Os(n){let e=n?.cozeAccountId?.trim();if(!(!e||e==="0"))return e}function Ns(n){let{_meta:e,...s}=n;return{stripped:s,meta:e}}function kt(n){if(!n?.cozeAgentId)throw new Error("missing _meta.cozeAgentId");return n.cozeAgentId}var S=class extends Error{code;retriable;cause;constructor(e,s,o){super(s),this.name="BridgeError",this.code=e,this.retriable=o?.retriable??!1,o?.cause!==void 0&&(this.cause=o.cause)}};U();ie();function $e(n,e){if(Xt(n)!=="cloud")throw new S("OPERATION_NOT_ALLOWED_FOR_LOCAL",`${e} is not allowed for local agent`)}function Ln(n){return n.startsWith("http://")||n.startsWith("https://")}function Mn(n){return n.endsWith("/")?n.slice(0,-1):n}U();var Bn="1008033",Ls="1289";var Ms="pbbp2",Bs="https://www.coze.cn",zs="/api/coze_claw/resource/get_frontier_key",gx="https://www.coze.cn",hx="wss://frontier.coze.cn";function zn(n){return n??process.env.COZE_BRIDGE_HANDSHAKE_URL??gx}function Fs(n){return n??process.env.COZE_BRIDGE_FRONTIER_URL??hx}function Tt(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 Qt(n){return n?n.startsWith("boe_")?{ttEnv:n}:{ttEnv:n,usePpe:"1"}:{}}var Us=D("handshake");async function Qr(n){let e=zn(n.endpoint),s=n.timeoutMs??1e4,o=`${Mn(e)}${zs}?aid=${encodeURIComponent(Bn)}`,a={Authorization:`Bearer ${n.privatecode}`,Accept:"application/json",...Tt(n.ppeOverride)},x=new AbortController,u=setTimeout(()=>x.abort(),s);Us.info("frontier key handshake",{base:e});try{let f=await fetch(o,{method:"GET",headers:a,signal:x.signal}),g=f.headers.get("x-tt-logid")??"",p=f.headers.get("x-tt-trace-id")??"";if(!f.ok){let k=await f.text().catch(()=>"");throw new S("UPSTREAM_HANDSHAKE_FAILED",`handshake HTTP ${f.status} logid=${g}: ${k.slice(0,200)}`)}let _=await f.json();if(_.code!==void 0&&_.code!==0)throw new S("UPSTREAM_HANDSHAKE_FAILED",`handshake code=${_.code} msg=${_.msg??"-"} logid=${g}`);let w=_.data??{},E=typeof w.access_key=="string"&&w.access_key||typeof w.accessKey=="string"&&w.accessKey||void 0,T=typeof w.device_id=="string"&&w.device_id||typeof w.deviceId=="string"&&w.deviceId||void 0;if(!E||!T){let k=JSON.stringify(_).slice(0,500);throw new S("UPSTREAM_HANDSHAKE_FAILED",`handshake response missing access_key/device_id (also tried camelCase) logid=${g}: ${k}`)}return Us.info("handshake ok",{remoteDeviceId:T,logid:g,traceId:p}),{accessKey:E,deviceId:T}}catch(f){throw f instanceof S?f:f.name==="AbortError"?new S("UPSTREAM_HANDSHAKE_FAILED",`handshake timeout (${s}ms)`):new S("UPSTREAM_HANDSHAKE_FAILED",String(f),{cause:f})}finally{clearTimeout(u)}}var Zr=process.env.COZE_BRIDGE_LLM_GATEWAY_URL?.trim()||"https://llm-gateway.coze.cn",Me="auto";function qs(n){return{model:n.model??Me,...n.modelToken?{modelToken:n.modelToken}:{}}}function Hs(n){return!n||n===Me}function Gs(n){let e={};return n.modelToken?(e.ANTHROPIC_BASE_URL=Zr,e.ANTHROPIC_AUTH_TOKEN=n.modelToken,e.ANTHROPIC_MODEL=n.model||Me):Hs(n.model)||(e.ANTHROPIC_MODEL=n.model),e}function Ks(n){let e=[];return n.modelToken?e.push("-c",`model="${n.model||Me}"`):Hs(n.model)||e.push("-c",`model="${n.model}"`),n.modelToken&&(e.push("-c",'model_providers.coze.name="coze"'),e.push("-c",`model_providers.coze.base_url="${Zr}/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 js(n){return n.modelToken?{OPENAI_API_KEY:n.modelToken}:{}}function ei(n){let{ttEnv:e,usePpe:s}=Qt(n),o={};return e&&(o["x-tt-env"]=e),s&&(o["x-use-ppe"]=s),o}function Ws(n,e){if(!n.modelToken)return{};let s=ei(e);return Object.keys(s).length===0?{}:{ANTHROPIC_CUSTOM_HEADERS:Object.entries(s).map(([a,x])=>`${a}:${x}`).join(`
116
+ `)}}function ti(n){return`coze-session-${n.replace(/[^A-Za-z0-9_-]+/g,"-")}`}function $s(n,e){if(!n.modelToken)return null;let s=n.model||Me,o=ei(e),a={baseUrl:`${Zr}/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&&(a.headers=o),a}function Js(n,e){if(!n.modelToken)return[];let s=ei(e),o=[];for(let[a,x]of Object.entries(s))o.push("-c",`model_providers.coze.http_headers.${a}="${x}"`);return o}var ce=D("agent-handlers"),Ys=5*1024*1024,Sx=1,Ex=6,Ax=new Set(["node_modules",".git",".coze","dist","build",".next"]),Fn=class{constructor(e){this.opts=e}opts;async listSkills(e){$e(e._meta,"_agent/listSkills");let s=kt(e._meta),o=await this.loadAgentCfg(s),a=o?.workspace??We(s).workspace,x=o?.skills??[],u=[];for(let f of x){let g=Be(a,f.relPath,"SKILL.md");await yx(g).then(_=>_.isFile()).catch(()=>!1)&&u.push(Tx(f))}return{skills:u}}async addSkills(e){$e(e._meta,"_agent/addSkills");let s=kt(e._meta),o=await this.requireAgentCfg(s),a=e.skills??[],x=[...o.skills??[]],u=new Map(x.map((g,p)=>[g.skillId,p])),f=[];for(let g of a){let p=await ri({agentId:s,workspace:o.workspace,framework:o.framework,skill:g});ii(x,u,p),f.push(g)}return await Rn(s,x),this.reloadAgentSessions(s,"skills-added"),{installedSkills:f}}async removeSkills(e){$e(e._meta,"_agent/removeSkills");let s=kt(e._meta),o=await this.requireAgentCfg(s),a=new Set(e.skillIds??[]),x=o.skills??[],u=[];for(let f of x){if(!a.has(f.skillId)){u.push(f);continue}let g=Be(o.workspace,f.relPath);await _x(g,{recursive:!0,force:!0}),ce.info("skill removed",{agentId:s,skillId:f.skillId,relPath:f.relPath})}return await Rn(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[a,x]of o.sessions){if(!x.downstream)continue;let u=x.acpSessionId;if(u&&o.activeTriggers.has(u)||this.isRuntimePendingPermission(x)){x.reloadAfterTurn=!0,ce.info("downstream busy, scheduling reload after turn",{reason:s,agentId:e,framework:o.framework,cloudId:a,acpId:u});continue}let g=x.downstream;x.downstream=void 0,ce.info("killing downstream for workspace reload (idle)",{reason:s,agentId:e,framework:o.framework,cloudId:a,acpId:u}),g.stop(s).catch(p=>ce.warn("downstream stop failed during reload (ignored)",{reason:s,agentId:e,cloudId:a,err:String(p)}))}}isRuntimePendingPermission(e){let s=this.opts.isRuntimePendingPermission;return!s||!e.downstream?!1:s(e.downstream)}async updateAgent(e){if(!e.cozeIdentity?.trim())return ce.info("_agent/update: empty cozeIdentity, noop",{agentId:e.agentId}),{ok:!0};let s=e.agentId,o=await we(s);if(!o)throw new S("AGENT_NOT_FOUND",`agent not found: ${s}`);if(o.cozeIdentity===e.cozeIdentity)return ce.info("_agent/update: cozeIdentity unchanged, noop",{agentId:s}),{ok:!0};try{await Pt(o.workspace,o.framework,s,e.cozeIdentity)}catch(a){throw ce.error("_agent/update: writeInstructionFile failed, aborting update",{agentId:s,framework:o.framework,workspace:o.workspace,err:String(a)}),new S("AGENT_PROTOCOL_ERROR",`failed to write instruction file for agent ${s}: ${String(a)}`,{cause:a})}return o.cozeIdentity=e.cozeIdentity,await Ie(o),ce.info("_agent/update: cozeIdentity rewritten",{agentId:s,framework:o.framework}),this.reloadAgentSessions(s,"identity-changed"),{ok:!0}}async disconnectAgent(e){let s=e.agentId;if(!s)throw new S("IPC_BAD_REQUEST","_agent/disconnect: missing agentId");let o=await we(s);return o?(o.disconnectedAt=Date.now(),o.disconnectReason=e.reason??"",await Ie(o),ce.info("agent disconnected",{agentId:s,reason:e.reason??"",force:e.force??!1}),this.opts.disposeAndMarkDisconnected&&await this.opts.disposeAndMarkDisconnected(s,e.reason??"disconnect"),{ok:!0}):(ce.warn("_agent/disconnect: agent not found, ignoring",{agentId:s}),{ok:!0})}async switchModel(e){if($e(e._meta,"_agent/switchModel"),!e.agentId)throw new S("IPC_BAD_REQUEST","_agent/switchModel: missing agentId");let s=e.model?.trim()?e.model:Me,o=await we(e.agentId);if(!o)throw new S("AGENT_NOT_FOUND",`agent not found: ${e.agentId}`);o.model=s,await Ie(o),ce.info("_agent/switchModel: model persisted",{agentId:e.agentId,model:s,reason:e.reason??""});let a=this.opts.agents.get(e.agentId);if(!a)return ce.info("_agent/switchModel: agent not running, config persisted only",{agentId:e.agentId}),{ok:!0};a.model=s,this.opts.cleanupOpenclawProviders&&await this.opts.cleanupOpenclawProviders(a).catch(u=>ce.warn("cleanupOpenclawProviders before switchModel failed (ignored)",{agentId:e.agentId,err:String(u)}));let x=[];for(let[u,f]of a.allSessionQueues())x.push(f.enqueue(async()=>{let g=a.sessions.get(u);g?.downstream&&(await g.downstream.stop(`switchModel: ${s}`).catch(()=>{}),g.downstream=void 0)}));return await Promise.all(x),ce.info("_agent/switchModel: all session runtimes killed, next prompt will respawn",{agentId:e.agentId,model:s,cloudSessions:x.length}),{ok:!0}}async resetAgent(e){if($e(e._meta,Le.RESET),!e.agentId)throw new S("IPC_BAD_REQUEST",`${Le.RESET}: missing agentId`);return await this.runDetailSync(e.agentId,Le.RESET,e.reason),{ok:!0}}async repairAgent(e){if($e(e._meta,Le.REPAIR),!e.agentId)throw new S("IPC_BAD_REQUEST",`${Le.REPAIR}: missing agentId`);let s=await this.loadAgentCfg(e.agentId);if(s&&s.framework!=="openclaw")throw new S("IPC_BAD_REQUEST",`${Le.REPAIR} only allowed for openclaw, got ${s.framework}`);if(s&&this.opts.openclawRepair)try{await this.opts.openclawRepair(e.agentId,s.workspace)}catch(o){ce.warn("openclaw repair (delete+add) failed (ignored)",{agentId:e.agentId,reason:e.reason,err:String(o)})}return await this.runDetailSync(e.agentId,Le.REPAIR,e.reason),{ok:!0}}async runDetailSync(e,s,o){if(!this.opts.detailSyncer){ce.warn("detailSyncer not wired, skipping sync",{method:s,agentId:e});return}try{await this.opts.detailSyncer(e)}catch(a){ce.warn("detail sync failed (ignored)",{method:s,agentId:e,reason:o,err:String(a)})}}async getFileTree(e){$e(e._meta,"_agent/getFileTree");let s=e._meta,o=kt(s),a=await this.resolveWorkspace(o),x=e.filePath??"",u=this.safeJoin(a,x),f=await ni(u).catch(()=>null);if(!f)throw new S("IPC_BAD_REQUEST",`path not found: ${x}`);if(f.isSymbolicLink())throw new S("IPC_BAD_REQUEST",`symlink not allowed: ${x}`);let g=zx(e.depth);return f.isDirectory()?{tree:await Bx(a,u,x,g)}:{tree:[{name:Fx(x),path:no(x||"."),isDir:!1,size:f.size,modifiedAt:Math.floor(f.mtimeMs)}]}}async getFileContent(e){$e(e._meta,"_agent/getFileContent");let s=kt(e._meta),o=await this.resolveWorkspace(s);if(!e.filePath)throw new S("IPC_BAD_REQUEST","filePath required");let a=this.safeJoin(o,e.filePath),x=await ni(a).catch(()=>null);if(!x||!x.isFile())throw new S("IPC_BAD_REQUEST",`not a file: ${e.filePath}`);if(x.isSymbolicLink())throw new S("IPC_BAD_REQUEST",`symlink not allowed: ${e.filePath}`);if(x.size>Ys)throw new S("IPC_BAD_REQUEST",`file too large: ${x.size} bytes (max ${Ys})`);let u=await Qs(a);return u.includes(0)?{content:u.toString("base64"),encoding:"base64",size:x.size}:{content:u.toString("utf8"),encoding:"utf-8",size:x.size}}async resolveWorkspace(e){let s=this.opts.agents.get(e);return s?s.workspace:(await we(e).catch(()=>null))?.workspace??We(e).workspace}safeJoin(e,s){let o=vx(e,s||"."),a=Zs(e,o);if(a.startsWith("..")||a===".."||a.startsWith(`..${eo}`))throw new S("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 S("AGENT_NOT_FOUND",`no config for agent: ${e}`);return s}};function Cx(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"?Be(".claude","skills"):Be(".agents","skills")}var Px=3e4,kx=50*1024*1024,Un=3e4;async function ri(n){let{agentId:e,workspace:s,framework:o,skill:a}=n;if(!a.skillName)throw new S("IPC_BAD_REQUEST","skill missing skillName");let x=typeof a.content=="string"&&a.content.length>0,u=typeof a.downloadUrl=="string"&&a.downloadUrl.length>0;if(!x&&!u)throw new S("IPC_BAD_REQUEST",`skill ${a.skillId} missing both content and downloadUrl`);let f=Cx(a.skillName),g=Ix(o),p=Be(g,f),_=Be(s,p);if(await px(_,{recursive:!0}),x){let E=Buffer.from(a.content,"utf8");Zt(E.length),await Vs(Be(_,"SKILL.md"),E,"utf8")}else{let E=await Dx(a.downloadUrl);Ox(E)?await Nx(E,_):await Vs(Be(_,"SKILL.md"),E.toString("utf8"),"utf8")}let w={skillId:a.skillId,skillName:a.skillName,relPath:p,installedAt:Date.now(),...a.description?{description:a.description}:{},...a.icon?{icon:a.icon}:{},...a.version?{version:a.version}:{},...a.downloadUrl?{downloadUrl:a.downloadUrl}:{},...a.config?{config:a.config}:{},...a.builtin?{builtin:a.builtin}:{}};return ce.info("skill installed",{agentId:e,skillId:a.skillId,skillName:a.skillName,relPath:p,source:x?"content":"downloadUrl"}),w}function ii(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 Tx(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 Dx(n){if(!n)throw new S("IPC_BAD_REQUEST","skill missing downloadUrl");if(n.startsWith("data:")){let e=Math.floor(n.length*3/4);Zt(e);let s=Rx(n);return Zt(s.length),s}if(n.startsWith("file:")){let e=new URL(n).pathname,s=await Qs(e);return Zt(s.length),s}if(Ln(n)){let e=new AbortController,s=setTimeout(()=>e.abort(),Px);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 a=await o.arrayBuffer();return Zt(a.byteLength),Buffer.from(a)}finally{clearTimeout(s)}}throw new S("IPC_BAD_REQUEST",`unsupported downloadUrl scheme (\u8981 https/data/file): ${n.slice(0,80)}`)}function Zt(n){if(n>kx)throw new S("IPC_BAD_REQUEST",`skill too large: ${n} bytes`)}function Rx(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 Ox(n){return n.length>=2&&n[0]===31&&n[1]===139}async function Nx(n,e){await Lx(n),await new Promise((s,o)=>{let a=Xs("tar",["-xzf","-","-C",e,"--strip-components=1","--no-same-owner"],{stdio:["pipe","pipe","pipe"]}),x="";a.stderr?.on("data",f=>{x+=String(f)});let u=setTimeout(()=>{a.kill("SIGKILL"),o(new S("IPC_BAD_REQUEST",`tar extract timeout (${Un}ms)`))},Un);a.on("error",f=>{clearTimeout(u),o(new S("IPC_BAD_REQUEST",`tar spawn failed: ${f.message}`,{cause:f}))}),a.on("exit",f=>{clearTimeout(u),f===0?s():o(new S("IPC_BAD_REQUEST",`tar exit ${f}${x?`: ${x.trim().slice(0,200)}`:""}`))}),a.stdin?.end(n)})}async function Lx(n){let e=await new Promise((s,o)=>{let a=Xs("tar",["-tzvf","-"],{stdio:["pipe","pipe","pipe"]}),x="",u="";a.stdout?.on("data",g=>{x+=String(g)}),a.stderr?.on("data",g=>{u+=String(g)});let f=setTimeout(()=>{a.kill("SIGKILL"),o(new S("IPC_BAD_REQUEST",`tar list timeout (${Un}ms)`))},Un);a.on("error",g=>{clearTimeout(f),o(new S("IPC_BAD_REQUEST",`tar list spawn failed: ${g.message}`))}),a.on("exit",g=>{clearTimeout(f),g===0?s(x):o(new S("IPC_BAD_REQUEST",`tar list exit ${g}${u?`: ${u.trim().slice(0,200)}`:""}`))}),a.stdin?.end(n)});for(let s of e.split(`
117
+ `)){let o=s.trim();if(!o)continue;let a=o.charCodeAt(0);if(a!==45&&a!==100)throw new S("IPC_BAD_REQUEST",`tar entry kind '${o[0]}' not allowed (symlink/hardlink/special): ${o.slice(0,100)}`);let u=(o.match(/\s(\S.*)$/)?.[1]??"").split(" -> ")[0]?.trim()??"";if(!u)continue;if(u.startsWith("/"))throw new S("IPC_BAD_REQUEST",`tar entry absolute path: ${u}`);if(u.split(/[/\\]/).some(g=>g===".."))throw new S("IPC_BAD_REQUEST",`tar entry contains '..': ${u}`)}}var Mx=5e3;async function Bx(n,e,s,o){return to(n,e,s,o,{count:0})}async function to(n,e,s,o,a){if(o<=0)return[];let x;try{x=await mx(e,{withFileTypes:!0})}catch{return[]}let u=[];for(let f of x){if(Ax.has(f.name)||f.isSymbolicLink())continue;if(a.count>=Mx){u.push({name:"...",path:"...",isDir:!1,size:0,modifiedAt:0,hasMore:!0});break}let g=Be(e,f.name),p=bx(Be(s,f.name)),_=null;try{_=await ni(g)}catch{continue}if(_.isSymbolicLink())continue;a.count++;let w={name:f.name,path:no(Zs(n,g)),isDir:_.isDirectory(),size:_.size,modifiedAt:Math.floor(_.mtimeMs)};_.isDirectory()&&o>1&&(w.children=await to(n,g,p,o-1,a)),u.push(w)}return u.sort((f,g)=>f.isDir!==g.isDir?f.isDir?-1:1:f.name.localeCompare(g.name)),u}function zx(n){return!n||n<=0?Sx:Math.min(n,Ex)}function Fx(n){if(!n||n==="."||n==="/")return".";let e=n.split(/[/\\]/);return e[e.length-1]||"."}function no(n){return n.split(eo).join("/")}U();import{readFileSync as cp}from"node:fs";import{dirname as dp,join as up}from"node:path";import{fileURLToPath as lp}from"node:url";var it="0.1.50";var ze=D("agent-health-reporter"),Ux=1e4,en=class{constructor(e){this.opts=e;this.intervalMs=e.intervalMs??Ux}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 f of this.opts.core.agents.values()){let g=qx(f);if(!g)continue;let p={agentId:f.agentId,status:g};f.patToken&&(p.patToken=f.patToken),f.accountId&&(p.accountId=f.accountId),s.push(p)}if(s.length===0)return;let o={agents:s,bridgeVersion:it,_meta:{cozeDeviceId:e}},a;try{a=await this.opts.core.sendRequest("_agent/health",o,5e3)}catch(f){ze.warn("heartbeat batch send failed",{count:s.length,err:String(f)})}let x=a?.authFailures;if(x&&x.length>0&&(ze.warn("heartbeat received authFailures from cloud",{count:x.length,agentIds:x.map(f=>f.agentId)}),this.opts.onAuthFailures))try{await this.opts.onAuthFailures(x)}catch(f){ze.warn("onAuthFailures callback failed (ignored)",{err:String(f)})}let u=a?.minBridgeVersion;if(u&&(ze.info("heartbeat received minBridgeVersion from cloud",{minV:u}),this.opts.onMinBridgeVersion))try{await this.opts.onMinBridgeVersion(u)}catch(f){ze.warn("onMinBridgeVersion callback failed (ignored)",{err:String(f)})}}finally{this.inFlight=!1}if(this.opts.onTickEnd)try{await this.opts.onTickEnd()}catch(s){ze.warn("onTickEnd hook failed",{err:String(s)})}}};function qx(n){return n.status==="error"?"error":n.activeTriggers.size>0?"busy":n.status==="ok"?"online":null}rt();import{mkdir as oi,rm as ld}from"node:fs/promises";import{spawn as Vx,spawnSync as Yx}from"node:child_process";function tn(n,e,s){return s===void 0?{jsonrpc:"2.0",id:n,method:e}:{jsonrpc:"2.0",id:n,method:e,params:s}}function nn(n,e){return e===void 0?{jsonrpc:"2.0",method:n}:{jsonrpc:"2.0",method:n,params:e}}function Dt(n,e){return{jsonrpc:"2.0",id:n,result:e}}function st(n,e){return{jsonrpc:"2.0",id:n,error:e}}var qn=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 ro(n){return"method"in n&&"id"in n&&n.id!==void 0}function io(n){return"method"in n&&!("id"in n)}function Hn(n){return!("method"in n)&&"id"in n}var Hx={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 Gx(n){if(n!=null)return n instanceof Error?{name:n.name,message:rn(n.message)}:typeof n=="string"?rn(n):typeof n=="object"?jx(n):n}var Kx=[[/\/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 rn(n){let e=n;for(let[s,o]of Kx)e=e.replace(s,o);return e}function jx(n){let e={};for(let[s,o]of Object.entries(n))typeof o=="string"?e[s]=rn(o):e[s]=o;return e}function sn(n){if(n instanceof S){let e=Gx(n.cause),s={bridgeCode:n.code,retriable:n.retriable};return e!==void 0&&(s.cause=e),{code:Hx[n.code]??G.INTERNAL_ERROR,message:rn(n.message),data:s}}return{code:G.INTERNAL_ERROR,message:rn(n instanceof Error?n.message:String(n))}}function so(n){let e=n.data,s=e?.bridgeCode??"AGENT_PROTOCOL_ERROR",o=!!e&&typeof e.message=="string"&&!!e.message,a=o?e?.message:n.message,x=n.data;if(o&&e){let{message:u,...f}=e;x=f}return new S(s,a,{retriable:e?.retriable??!1,cause:x})}function ao(n){return`${JSON.stringify(n)}
118
+ `}var oo=10*1024*1024,Gn=class{buffer="";onError;constructor(e={}){this.onError=e.onError}push(e){if(this.buffer+=typeof e=="string"?e:e.toString("utf8"),this.buffer.length>oo){let a=this.buffer.length;return this.buffer="",this.onError?.({line:`<buffer overflow: ${a} bytes, dropped>`,error:new Error(`LdjsonDecoder buffer exceeded ${oo} bytes`)}),[]}let s=this.buffer.split(`
119
+ `);this.buffer=s.pop()??"";let o=[];for(let a of s){let x=a.replace(/\r$/,"").trim();if(x)try{o.push(JSON.parse(x))}catch(u){this.onError?.({line:x,error:u})}}return o}flush(){if(!this.buffer)return[];let e=this.buffer.replace(/\r$/,"").trim();if(this.buffer="",!e)return[];try{return[JSON.parse(e)]}catch(s){return this.onError?.({line:e,error:s}),[]}}};var xo={"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"},Ep=Object.fromEntries(Object.entries(xo).map(([n,e])=>[e,n])),Wx={"session.prompt":["agentId","triggerMsgId","sessionId"],"session.cancel":["agentId","triggerMsgId","sessionId"],"session.new":["agentId"],"session.load":["agentId"],"agent.create":["agentId"],"agent.health":[],"agent.listSkills":["agentId"],"agent.addSkills":["agentId"],"agent.removeSkills":["agentId"],"agent.getFileTree":["agentId"],"agent.getFileContent":["agentId"],"agent.detail":["agentId"],"agent.update":["agentId"],"agent.disconnect":["agentId"],"agent.switchModel":["agentId"],"agent.genModelToken":["agentId","sessionId"],"agent.reset":["agentId"],"agent.repair":["agentId"],"session.requestPermission":["agentId","sessionId"],"agent.pair":[],initialize:[]},Rt=class{seq=0;next(e,s){this.seq+=1;let o=xo[e]??$x(e),a=Wx[o]??[],x=[o,String(this.seq)];if(a.length>0){let u=a.map(g=>co(s?.[g]??"")),f=Jx(u).join(":");f&&x.push(f)}else s&&Object.values(s).some(u=>u)&&x.push(Object.values(s).filter(Boolean).map(u=>co(String(u))).join(":"));return x.join("_")}reset(){this.seq=0}};function $x(n){return n.replace(/[\s/]+/g,".").replace(/_+/g,"-")}function co(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 Kn(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 Xx=3e4,Qx=200,Zx=Kn("COZE_BRIDGE_SESSION_PROMPT_MAX_MS",3600*1e3),uo=500;function ed(n){try{let e=JSON.stringify(n);return e===void 0||e.length<=uo?n:`${e.slice(0,uo)}...<truncated, total ${e.length} chars>`}catch{return"<unserializable>"}}function fo(n,e){if(!(typeof n!="number"||n<=0))try{if(process.platform==="win32"){let s=["/PID",String(n),"/T"];e==="SIGKILL"&&s.push("/F"),Yx("taskkill",s,{stdio:"ignore",windowsHide:!0})}else process.kill(-n,e)}catch{}}var ot=class{constructor(e){this.opts=e;this.log=D(`downstream.${this.constructor.name}`),this.decoder=new Gn({onError:s=>this.log.warn("decode line failed",{line:s.line})})}opts;child;decoder;pending=new Map;idAllocator=new Rt;updateHandlers=[];agentRequestHandlers=[];exitHandlers=[];log;stopped=!1;stderrRing=[];sanitizeEnv(e){return e}async start(){if(this.child)throw new S("BRIDGE_INTERNAL","Downstream already started");let e=process.platform!=="win32",s=Vx(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 a of this.decoder.push(o))this.dispatch(a)}catch(a){this.log.warn("stdout dispatch threw, swallowed to keep daemon alive",{err:String(a)})}}),s.stderr?.setEncoding("utf8"),s.stderr?.on("data",o=>{let a=o.trimEnd();this.stderrRing.push(a),this.stderrRing.length>Qx&&this.stderrRing.shift(),this.log.debug("stderr",{text:a})}),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,a)=>{this.stopped=!0,(o!==0||a!==null)&&this.stderrRing.length>0&&this.log.warn("downstream exited abnormally, recent stderr",{code:o,signal:a,recentStderr:[...this.stderrRing]});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}/${a})`));for(let u of this.exitHandlers)u(o,a)}),s.on("error",o=>{this.log.error("child error",{err:String(o)}),this.failAllPending(new S("AGENT_SPAWN_FAILED",String(o),{cause:o}))}),this.log.info("downstream started",{command:this.opts.command,pid:s.pid,cwd:this.opts.cwd})}async stop(e){if(!this.child||this.stopped)return;this.stopped=!0,this.log.info("downstream stopping",{reason:e});let s=this.child,o=new Promise(x=>s.once("exit",()=>x()));fo(s.pid,"SIGTERM");let a=setTimeout(()=>{s.killed||fo(s.pid,"SIGKILL")},5e3);try{await o}finally{clearTimeout(a)}}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(nn("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(Dt(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=Xx){if(!this.child||this.stopped)return Promise.reject(new S("AGENT_PROTOCOL_ERROR","downstream not started"));let a=this.idAllocator.next(e),x=tn(a,e,s),u=o>0&&Number.isFinite(o);return new Promise((f,g)=>{let p=u?setTimeout(()=>{this.pending.delete(a),g(new S("AGENT_TIMEOUT",`${e} timed out after ${o}ms`))},o):null;this.pending.set(a,{resolve:f,reject:g,timer:p,method:e});try{this.writeFrame(x)}catch(_){p&&clearTimeout(p),this.pending.delete(a),g(_)}})}writeFrame(e){if(!this.child?.stdin||this.child.stdin.destroyed)throw new S("AGENT_PROTOCOL_ERROR","downstream stdin not writable");this.child.stdin.write(ao(e),s=>{s&&this.log.warn("stdin write callback err",{err:String(s)})})}dispatch(e){if(Hn(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(so(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:ed(e.result)}),s.resolve(e.result));return}if(io(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(ro(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,sn(o)))}catch{}}}failAllPending(e){for(let s of this.pending.values())s.timer&&clearTimeout(s.timer),s.reject(e);this.pending.clear()}};var td="@agentclientprotocol/claude-agent-acp@latest";function nd(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 jn=class extends ot{framework="claude-code";constructor(e){let s=Pn("claude-code"),[o,a]=s?[s,[]]:["npx",["-y",td]],x=e.command??o,u=e.args??a,f={command:x,args:u,cwd:e.cwd,...e.env?{env:e.env}:{}};super(f)}sanitizeEnv(e){return nd(e)}};import{mkdtempSync as rd,rmSync as id}from"node:fs";import{tmpdir as sd}from"node:os";import{join as od}from"node:path";var ad="@zed-industries/codex-acp@latest",Wn=class extends ot{framework="codex";authMethodId;codexHomeDir;constructor(e){let s=Pn("codex"),[o,a]=s?[s,[]]:["npx",["-y",ad]],x=e.command??o,u=e.args??a,f=e.extraArgs?[...u,...e.extraArgs]:u,g=e.isolateCodexHome?rd(od(sd(),"coze-bridge-codex-home-")):void 0,p=g?{...e.env??{},CODEX_HOME:g}:e.env,_={command:x,args:f,cwd:e.cwd,...p?{env:p}:{}};super(_),this.authMethodId=e.authMethodId,this.codexHomeDir=g}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{id(this.codexHomeDir,{recursive:!0,force:!0})}catch{}}};var cd=3e4,Ot=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 a={command:e.command,args:o,cwd:e.cwd,...e.env?{env:e.env}:{}};super(a),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}`}]},cd))}get acpSessionName(){return this.sessionName}};U();ie();function si(n){return n.replace(/[^A-Za-z0-9._-]+/g,"-")}var Nt=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 $n=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 Nt,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)on(o),o.downstream&&(s.push(o.downstream.stop(e).catch(()=>{})),o.downstream=void 0);await Promise.all(s),this.activeTriggers.clear()}};function on(n){n.idleTimer&&(clearTimeout(n.idleTimer),n.idleTimer=void 0)}import{spawn as xd}from"node:child_process";import{homedir as dd}from"node:os";import{join as ud}from"node:path";Tn();U();async function ho(){let n=ud(dd(),".openclaw/openclaw.json");return(await It(n))?.gateway?.auth?.token??""}var lo=D("openclaw.config"),fd=[0,5e3,5e3],go="models.providers.",Jn="agents.defaults.models",Vn=class{command;env;retryDelaysMs;queue=new Nt;constructor(e){this.command=e.command,this.env=e.env??process.env,this.retryDelaysMs=e.retryDelaysMs??fd}async withRetry(e,s){let o;for(let a=0;a<this.retryDelaysMs.length;a++){let x=this.retryDelaysMs[a]??0;x>0&&await new Promise(u=>setTimeout(u,x));try{return await s()}catch(u){o=u,lo.warn("openclaw cli failed, will retry",{label:e,attempt:a+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 a=xd(this.command,e,{stdio:["ignore","pipe","pipe"],env:this.env}),x="";a.stderr?.on("data",u=>{x+=u.toString("utf8")}),a.on("error",o),a.on("close",u=>{u===0?s():o(new Error(`exit ${u}: ${x.trim().slice(0,500)}`))})})}async runCliTolerant(e,s){try{await this.runCli(e)}catch(o){let a=String(o);if(s.some(x=>a.includes(x)))return;throw o}}async bestEffortUnset(e,s){try{await this.queue.enqueue(()=>this.withRetry(e,()=>this.runCli(["config","unset",s])))}catch(o){lo.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",`${go}${e}`,JSON.stringify(s),"--strict-json","--merge"])))}removeProvider(e){return this.bestEffortUnset(`config unset models.providers.${e}`,`${go}${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 a=["agents","add",e,"--workspace",s,"--non-interactive"];return o&&a.push("--model",o),this.queue.enqueue(()=>this.withRetry(`agents add ${e}`,()=>this.runCliTolerant(a,["already exists","already registered"])))}deleteAgent(e){return this.queue.enqueue(()=>this.withRetry(`agents delete ${e}`,()=>this.runCliTolerant(["agents","delete",e,"--force"],["not found","does not exist"])))}};var Se=D("agent-manager"),gd=(n,e,s,o,a,x,u,f)=>{switch(n){case"claude-code":{let g={...a?{...Gs(a),...Ws(a,u)}:{},...f??{}};return new jn({cwd:s,...Object.keys(g).length>0?{env:g}:{}})}case"codex":{let p=[...a?[...Ks(a),...Js(a,u)]:[],"-c",'sandbox_mode="danger-full-access"',"-c",'approval_policy="never"'],_={...a?js(a):{},...f??{}},w=!!a;return new Wn({cwd:s,...p.length>0?{extraArgs:p}:{},...Object.keys(_).length>0?{env:_}:{},...w?{authMethodId:"openai-api-key",isolateCodexHome:!0}:{}})}case"openclaw":return new Ot({command:e,cwd:s,agentId:o,...x?{sessionName:si(x)}:{}})}};function po(n){return n==="claude-code"||n==="codex"}var hd={path:"",version:"cloud-deployed"},pd={protocolVersion:1,clientCapabilities:{fs:{readTextFile:!0,writeTextFile:!0}}},md=6e4,Yn=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??gd,this.createTimeoutMs=e.createTimeoutMs??md}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 Vn({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=Xt(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(k=>Se.warn("dispose stale agent failed (ignored)",{err:String(k)})),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 k=await we(e.agentId,this.paths).catch(()=>null);k&&(k.patToken=e.patToken,await Ie(k,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 x=We(e.agentId,this.paths),u=Xt(e._meta),f=e.framework==="openclaw"&&u==="local",g=f?this.config.frameworksCache?.openclaw?.defaultAgent?.workspace:void 0,p=e.workspace??g??x.workspace,_=new AbortController,w=setTimeout(()=>_.abort(new S("AGENT_TIMEOUT",`_agent/create timed out after ${this.createTimeoutMs}ms`)),this.createTimeoutMs),E,T=!1;try{s&&po(e.framework)&&await In(e.framework,_.signal);let k=()=>{if(_.signal.aborted)throw _.signal.reason instanceof Error?_.signal.reason:new S("AGENT_TIMEOUT","_agent/create aborted")};await oi(x.root,{recursive:!0}),await oi(p,{recursive:!0}),await oi(x.logs,{recursive:!0}),k(),f||await Pt(p,e.framework,e.agentId,e.cozeIdentity),e.framework==="claude-code"&&await Rs(p),k();let P=await we(e.agentId,this.paths).catch(()=>null),H=qs({model:e.model??P?.model}),X=Os(e._meta)??P?.accountId,K=e.patToken??P?.patToken;if(E=new $n({agentId:e.agentId,framework:e.framework,workspace:p,model:H.model??Me,deployType:u,...X?{accountId:X}:{},...K?{patToken:K}:{}}),E.status="ok",P?.sessions){for(let[Te,me]of Object.entries(P.sessions))E.sessions.set(Te,{acpSessionId:me.acpSessionId,modelToken:me.modelToken,tokenGeneratedAt:me.tokenGeneratedAt,lastActiveAt:Date.now(),loadingSession:!1,replySeq:0});let ae=Object.keys(P.sessions).length;ae>0&&Se.info("restored persisted session records (no spawn)",{agentId:e.agentId,count:ae})}this.registry.register(E),T=!0;let J={agentId:e.agentId,framework:e.framework,workspace:p,cozeIdentity:e.cozeIdentity,createdAt:P?.createdAt??Date.now(),sessions:P?.sessions??{},model:H.model};u==="cloud"&&(J.deployType="cloud"),X&&(J.accountId=X),K&&(J.patToken=K),P?.skills&&(J.skills=P.skills),P?.agentName&&(J.agentName=P.agentName),P?.description&&(J.description=P.description),e.framework==="openclaw"&&u==="cloud"&&(this.config.frameworksCache?.openclaw?.path?await this.getOpenclawConfig().ensureAgent(e.agentId,p):Se.warn("openclaw binary not on this machine, skip agents add (will fail at session/prompt)",{agentId:e.agentId}));let oe=e.initialSkills??[];if(oe.length>0){let ae=[...J.skills??[]],Te=new Map(ae.map((de,ue)=>[de.skillId,ue])),me=0;for(let de of oe)try{let ue=await ri({agentId:e.agentId,workspace:p,framework:e.framework,skill:de});ii(ae,Te,ue),me++}catch(ue){Se.warn("initialSkill install failed (skipping)",{agentId:e.agentId,skillId:de.skillId,skillName:de.skillName,err:String(ue)})}me>0&&(J.skills=ae,Se.info("initialSkills installed",{agentId:e.agentId,installed:me,requested:oe.length}))}return await Ie(J,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:p,framework:e.framework}}catch(k){throw Se.error("agent create failed, rolling back",{agentId:e.agentId,err:String(k)}),T&&E&&(await E.dispose("rollback").catch(()=>{}),this.registry.unregister(e.agentId)),await ld(x.root,{recursive:!0,force:!0}).catch(P=>Se.warn("rm agent dir failed (ignored)",{err:String(P)})),k instanceof S?k:new S("AGENT_SPAWN_FAILED",String(k),{cause:k})}finally{clearTimeout(w)}}async spawnSessionDownstream(e,s,o,a){let u=this.config.frameworksCache?.[e.framework];if(!u)if(e.deployType==="cloud"&&po(e.framework))u=hd;else throw new S("AGENT_SPAWN_FAILED",`framework ${e.framework} not detected on this machine`);let f=e.deployType==="cloud"?{model:e.model,modelToken:s}:void 0,g;e.framework==="openclaw"?g=await this.buildOpenclawDownstream({session:e,modelConfig:f,cloudSessionId:o,cozeEnv:a,command:u.path}):g=this.factory(e.framework,u.path,e.workspace,e.agentId,f,o,a,this.buildBinShimPathEnv());try{return await g.start(),await g.initialize(pd),g}catch(p){throw await g.stop("spawnSessionDownstream failed").catch(()=>{}),p instanceof S?p:new S("AGENT_SPAWN_FAILED",p instanceof Error?p.message:String(p),{cause:p})}}async buildOpenclawDownstream(e){let{session:s,modelConfig:o,cloudSessionId:a,cozeEnv:x,command:u}=e,f=si(a);if(s.deployType==="local"){let w=this.config.frameworksCache?.openclaw?.defaultAgent;if(!w?.id||!w.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 Ot({command:u,cwd:w.workspace,agentId:w.id,sessionName:f})}let g=await ho(),p=o?$s(o,x):null,_;if(p){let w=ti(a),T=p.models[0]?.id??Me,k=`${w}/${T}`;if(!this.ensuredProviders.has(k)){let P=this.getOpenclawConfig();await P.ensureProvider(w,p),await P.addModelToAllowlist(k),this.ensuredProviders.add(k)}_=k}return new Ot({command:u,cwd:s.workspace,agentId:s.agentId,sessionName:f,...g?{gatewayToken:g}:{},..._?{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 a=ti(o),x=`${a}/${e.model}`,u=!0;try{await s.removeProvider(a)}catch(f){u=!1,Se.warn("removeProvider failed, keeping ensuredProviders entry",{providerId:a,err:String(f)})}try{await s.removeModelFromAllowlist(x)}catch(f){u=!1,Se.warn("removeModelFromAllowlist failed, keeping ensuredProviders entry",{fullModelId:x,err:String(f)})}u&&this.ensuredProviders.delete(x)}}};import{randomUUID as Pd}from"node:crypto";import{promises as kd}from"node:fs";import{basename as Td}from"node:path";import{promises as _d}from"node:fs";import{basename as yd}from"node:path";U();var mo=D("file-upload"),bd="/api/coze_claw/file/agent_upload",vd=6e4;async function wo(n,e={}){let o=`${Mn(zn(e.handshakeBase))}${bd}`,a=e.timeoutMs??vd,x=await _d.readFile(n.path),u=new FormData;u.append("agent_id",n.agentId),u.append("session_id",n.sessionId),u.append("file_name",n.name),u.append("file_content",new Blob([x],{type:n.mimeType}),n.name);let f={Authorization:`Bearer ${n.patToken}`,Accept:"application/json","x-coze-version":"3.0",...Tt(e.ppeOverride),...n.accountId?{"x-coze-account":n.accountId}:{}},g=new AbortController,p=setTimeout(()=>g.abort(),a);mo.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:f,body:u,signal:g.signal}),w=_.headers.get("x-tt-logid")??"";if(!_.ok){let k=await _.text().catch(()=>"");throw new S("UPLOAD_FAILED",`upload HTTP ${_.status} logid=${w}: ${k.slice(0,200)}`)}let E=await _.json();if(E.code!==void 0&&E.code!==0)throw new S("UPLOAD_FAILED",`upload code=${E.code} msg=${E.msg??"-"} logid=${w}`);let T=E.data?.file?.file_url;if(!T)throw new S("UPLOAD_FAILED",`upload response missing data.file.file_url logid=${w}: ${JSON.stringify(E).slice(0,200)}`);return mo.info("file upload ok",{uri:T,logid:w}),{uri:T}}catch(_){throw _ instanceof S?_:_.name==="AbortError"?new S("UPLOAD_FAILED",`upload timeout (${a}ms) for ${yd(n.path)}`):new S("UPLOAD_FAILED",String(_),{cause:_})}finally{clearTimeout(p)}}U();import{promises as Sd}from"node:fs";import{extname as Ed}from"node:path";var Ad=[{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 Cd(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 _o(n){let e=await Sd.open(n,"r");try{let s=Buffer.alloc(16);if(await e.read(s,0,16,0),Cd(s))return"image/webp";for(let o of Ad)if(o.prefix.every((a,x)=>s[x]===a))return o.mime}finally{await e.close()}return Id[Ed(n).toLowerCase()]??"application/octet-stream"}ie();var yo=D("agent-send"),bo=50*1024*1024,Dd=new Set(["image/png","image/jpeg","image/webp","image/gif","image/svg+xml","application/pdf","application/json","text/plain","text/markdown"]);async function vo(n,e){let s=e.core.get(n.agentId);if(!s)throw new S("AGENT_NOT_FOUND",`agent=${n.agentId}`);if(e.core.disconnectedAgents.has(n.agentId))throw new S("AGENT_DISCONNECTED",`agent=${n.agentId} was disconnected by cloud`);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 Ps(n.path,s.workspace))throw new S("PATH_OUTSIDE_WORKSPACE",`path=${n.path} not under workspace=${s.workspace}`);let a=await kd.stat(n.path).catch(()=>null);if(!a||!a.isFile())throw new S("IPC_BAD_REQUEST",`path is not a regular file: ${n.path}`);if(a.size>bo)throw new S("FILE_TOO_LARGE",`${a.size} bytes > limit ${bo}`);let x=await _o(n.path);if(!Dd.has(x))throw new S("UNSUPPORTED_MIME",`mime=${x} not in whitelist`);if(n.kind==="image"&&!x.startsWith("image/"))throw new S("UNSUPPORTED_MIME",`kind=image but mime=${x}`);if(!e.core.upstream.isConnected())throw new S("UPSTREAM_NOT_READY","cloud WS not connected");let u=n.name??Td(n.path),f=await wo({patToken:e.patToken,agentId:n.agentId,sessionId:n.sessionId,path:n.path,mimeType:x,name:u,sizeBytes:a.size,...s.accountId?{accountId:s.accountId}:{}},{handshakeBase:e.handshakeBase,ppeOverride:e.ppeOverride}),g={sessionUpdate:"agent_file",messageId:Pd(),content:{type:n.kind==="image"?"image":"resource",uri:f.uri,mimeType:x,name:u,sizeBytes:a.size,...f.fileId!==void 0?{fileId:f.fileId}:{},...n.caption!==void 0?{caption:n.caption}:{}}},p=2,_;for(let w=0;w<=p;w++)try{await e.core.sendAgentFileUpdate(s,o,n.sessionId,g),_=void 0;break}catch(E){_=E,w<p&&(yo.warn("sendAgentFileUpdate failed, retrying",{attempt:w+1,err:String(E)}),await new Promise(T=>setTimeout(T,5e3)))}if(_)throw new S("UPSTREAM_NOT_READY",`agent file uploaded to cloud but sendAgentFileUpdate failed after ${p+1} attempts: ${String(_)}`,{cause:_});return yo.info("agent file sent",{agentId:n.agentId,sessionId:n.sessionId,kind:n.kind,name:u,bytes:a.size,mime:x,uri:f.uri}),{ok:!0,uri:f.uri,bytes:a.size,mimeType:x,...f.fileId!==void 0?{fileId:f.fileId}:{}}}U();import{execFile as Rd}from"node:child_process";import{promisify as Od}from"node:util";var Nd=Od(Rd),at=D("coze-cli-installer"),So="@coze/cli@0.1.3-alpha.89c42a",Eo="https://bnpm.byted.org",Ld="coze",Md=5e3,Bd=9e4,Ao=1e4,an=null,ai=!1;async function ci(n,e={}){if(ai)return;if(an)return an;let s=e.exec??Nd;return an=(async()=>{try{let o=await zd(Ld,s);if(o){at.info("coze-cli already on PATH, skip install + config + auth",{path:o}),ai=!0;return}at.info("coze-cli install start",{package:So,registry:Eo});try{await s("npm",["i","-g",So,"--registry",Eo],{timeout:Bd,maxBuffer:10*1024*1024}),at.info("coze-cli install ok")}catch(a){at.warn("coze-cli install failed (skip subsequent steps)",{err:String(a)});return}if(n.env)try{await s("coze",["config","set","xTTEnv",n.env],{timeout:Ao}),at.info("coze config set xTTEnv ok",{env:n.env})}catch(a){at.warn("coze config set failed (continue to auth login)",{err:String(a)})}try{await s("coze",["auth","login","--token",n.patToken],{timeout:Ao}),at.info("coze auth login ok")}catch(a){at.warn("coze auth login failed",{err:String(a)});return}ai=!0}finally{an=null}})(),an}async function zd(n,e){let s=process.platform==="win32"?"where":"which";try{let{stdout:o}=await e(s,[n],{timeout:Md});return o.split(`
120
+ `)[0]?.trim()||void 0}catch{return}}U();import{spawn as Fd}from"node:child_process";import{constants as Co,access as Ud}from"node:fs/promises";import{delimiter as qd,join as Hd}from"node:path";var Io=D("framework-detector"),Po={"claude-code":"claude",codex:"codex",openclaw:"openclaw"},Gd=[".exe",".cmd",".bat",".ps1"],Lt=class{env;constructor(e={}){this.env={pathEnv:e.pathEnv??process.env.PATH??"",platform:e.platform??process.platform,spawn:e.spawn??Fd,access:e.access??Ud}}async detect(e){let s=Po[e],o=await this.which(s);if(!o)return Io.debug("framework binary not found",{framework:e,bin:s}),null;let a=e==="openclaw"?["--log-level","silent"]:[],[x,u]=await Promise.all([this.probeVersion(o,a),e==="openclaw"?this.probeOpenclawDefaultAgent(o):Promise.resolve(null)]),f={path:o,version:x};return u&&(f.defaultAgent=u),f}async detectAll(){let e=await Promise.all(Object.keys(Po).map(async o=>[o,await this.detect(o)])),s={};for(let[o,a]of e)a&&(s[o]=a);return s}async which(e){let s=this.env.pathEnv.split(qd).filter(Boolean),o=this.env.platform==="win32"?["",...Gd]:[""];for(let a of s)for(let x of o){let u=Hd(a,e+x);if(await this.isExecutable(u))return u}return null}async isExecutable(e){try{let s=this.env.platform==="win32"?Co.F_OK:Co.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 a=o.find(x=>x?.isDefault===!0);return!a?.id||!a.workspace?null:{id:a.id,workspace:a.workspace}}catch(o){return Io.warn("openclaw agents list --json parse failed",{err:String(o)}),null}}async probeVersion(e,s=[]){let o=await this.runProbe(e,[...s,"--version"]);return o&&(jd(o.stdout).split(/\r?\n/)[0]??"").trim()||"unknown"}runProbe(e,s){return new Promise(o=>{let a="",x=!1,u,f=g=>{x||(x=!0,u&&clearTimeout(u),o(g))};try{let g=this.env.spawn(e,s,{stdio:["ignore","pipe","pipe"]});u=setTimeout(()=>{g.kill("SIGKILL"),f(null)},5e3),g.stdout?.on("data",p=>{a+=p.toString("utf8")}),g.on("error",()=>f(null)),g.on("close",p=>f({code:p,stdout:a}))}catch{f(null)}})}},Kd=new RegExp("\x1B\\[[0-9;]*[A-Za-z]","g");function jd(n){return n.replace(Kd,"")}Mt();import{randomBytes as du}from"node:crypto";import{createReadStream as $d}from"node:fs";import{mkdir as Jd,readFile as Vd,realpath as Yd,stat as Xd,writeFile as Qd}from"node:fs/promises";import{basename as Zd,dirname as xi,join as eu,relative as tu,resolve as To,sep as nu}from"node:path";import{createInterface as ru}from"node:readline";U();var Ro=D("fs-rpc"),cn=Kn("COZE_BRIDGE_FS_RPC_MAX_BYTES",20*1024*1024);async function Oo(n,e){let s=Buffer.byteLength(n.content,"utf8");if(s>cn)throw new S("IPC_BAD_REQUEST",`fs/write_text_file content too large: ${s} bytes > limit ${cn} bytes`);let o=await Lo(n.path,e);return await Jd(xi(o),{recursive:!0}),await Qd(o,n.content,"utf8"),Ro.info("fs/write_text_file ok",{path:o,size:n.content.length}),null}async function No(n,e){let s=await Lo(n.path,e),o=await Xd(s),a=typeof n.line=="number"||typeof n.limit=="number";if(o.size>cn&&!a)throw new S("IPC_BAD_REQUEST",`fs/read_text_file too large without line/limit slicing: ${o.size} bytes > ${cn} bytes`);let x;if(a&&o.size>cn)x=await iu(s,n.line??1,n.limit);else{let u=await Vd(s,"utf8");if(a){let f=u.split(`
121
+ `),g=Math.max(0,(n.line??1)-1),p=typeof n.limit=="number"?g+n.limit:void 0;x=f.slice(g,p).join(`
122
+ `)}else x=u}return Ro.info("fs/read_text_file ok",{path:s,size:x.length}),{content:x}}async function iu(n,e,s){let o=ru({input:$d(n,{encoding:"utf8"}),crlfDelay:Number.POSITIVE_INFINITY}),a=Math.max(0,e-1),x=typeof s=="number"?a+s:Number.POSITIVE_INFINITY,u=[],f=0;try{for await(let g of o)if(f>=a&&f<x&&u.push(g),f++,f>=x)break}finally{o.close()}return u.join(`
123
+ `)}async function Lo(n,e){if(typeof n!="string"||n.length===0)throw new S("IPC_BAD_REQUEST","path must be a non-empty string");let[s,o]=await Promise.all([Do(To(e)),Do(To(n))]),a=tu(s,o);if(a.startsWith("..")||a===".."||a.startsWith(`..${nu}`))throw new S("IPC_BAD_REQUEST",`path escapes workspace: ${n}`);return o}async function Do(n){let e=[],s=n;for(;s!==xi(s);)try{let o=await Yd(s);return e.length?eu(o,...e.reverse()):o}catch{e.push(Zd(s)),s=xi(s)}return n}U();var Mo=D("prompt-multimodal"),Bo=10*1024*1024,su=15e3,ou=6;async function zo(n){let e=new Array(n.length),s=0;async function o(){for(;s<n.length;){let x=s++,u=n[x];u!==void 0&&(e[x]=await au(u))}}let a=Array.from({length:Math.min(ou,n.length)},()=>o());return await Promise.all(a),e}async function au(n){if(n.type!=="image")return n;let e=n;if(e.data||!e.uri||!Ln(e.uri))return n;try{let{buf:s,contentType:o}=await xu(e.uri),a=e.mimeType||cu(o)||"application/octet-stream";return Mo.info("image uri fetched and inlined",{uri:e.uri,bytes:s.length,mimeType:a}),{type:"image",data:s.toString("base64"),mimeType:a}}catch(s){return Mo.warn("image fetch failed, degrading to text block",{uri:e.uri,err:String(s)}),{type:"text",text:`[image load failed: ${e.uri}]`}}}function cu(n){if(!n)return;let e=n.indexOf(";");return(e===-1?n:n.slice(0,e)).trim()||void 0}async function xu(n){let e=new AbortController,s=setTimeout(()=>e.abort(),su);try{let o=await fetch(n,{signal:e.signal});if(!o.ok)throw new Error(`HTTP ${o.status} ${o.statusText}`);let a=await o.arrayBuffer();if(a.byteLength>Bo)throw new Error(`image too large: ${a.byteLength} bytes (max ${Bo})`);return{buf:Buffer.from(a),contentType:o.headers.get("content-type")??void 0}}finally{clearTimeout(s)}}rt();Mt();U();var M=D("core"),uu=3e4,fu=/^(boe|ppe)_[A-Za-z0-9_-]+$/,lu=3e4,gu=new Set(["_agent/create","session/new","session/load","session/prompt"]),Xn=class{upstream;agents=new Map;disconnectedAgents=new Set;extensions;paths;sessionSpawner;sessionIdleTimeoutMs;upgradeGate;upstreamIds=new Rt;pendingUpstream=new Map;pendingBridge=new Map;currentCozeEnv;constructor(e){this.upstream=e.upstream,this.extensions=e.extensions??{},this.paths=e.paths,this.sessionSpawner=e.sessionSpawner,this.sessionIdleTimeoutMs=ko(e.bridgeConfig),this.upgradeGate=e.upgradeGate}registerExtension(e,s){this.extensions[e]=s}getCozeEnv(){return this.currentCozeEnv}async start(){this.upstream.onFrame(e=>this.handleFrame(e)),this.upstream.onConnect?.(({initial:e})=>{e||this.rejectAllPendingOnReconnect()}),await this.upstream.start(),M.info("Core started",{extensions:Object.keys(this.extensions)})}async stop(e){M.info("Core stopping",{reason:e}),await Promise.all([...this.agents.values()].map(s=>s.dispose(e))),this.agents.clear(),await this.upstream.stop(e)}get(e){return this.agents.get(e)}register(e){this.agents.set(e.agentId,e),M.info("agent registered",{agentId:e.agentId,framework:e.framework});for(let s of this.registerHandlers)try{s(e.agentId)}catch(o){M.warn("onAgentRegister handler threw (ignored)",{agentId:e.agentId,err:String(o)})}}onAgentRegister(e){return this.registerHandlers.add(e),()=>this.registerHandlers.delete(e)}registerHandlers=new Set;unregister(e){this.agents.delete(e)}reviveIfDisconnected(e){this.disconnectedAgents.delete(e)&&M.info("agent revived from disconnect",{agentId:e})}attachRuntimeHooks(e,s,o){let a=o.downstream;a&&(a.onUpdate(x=>{o.loadingSession||this.forwardUpdate(e,x)}),a.onAgentRequest(x=>{this.handleAgentRequest(e,a,x)}),a.onExit((x,u)=>{M.info("session runtime exited",{agentId:e.agentId,cloudId:s,code:x,signal:u}),on(o),o.downstream=void 0,o.replySeq=0,o.acpSessionId&&e.activeTriggers.delete(o.acpSessionId),this.rejectPendingForDownstream(a,"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[a,x]of this.pendingUpstream)x.downstream===e&&o.push(a);if(o.length!==0){M.info("reject pendingUpstream entries (downstream gone)",{reason:s,count:o.length});for(let a of o){let x=this.pendingUpstream.get(a);if(x){this.pendingUpstream.delete(a),this.upstream.send(st(a,{code:G.INTERNAL_ERROR,message:`bridge downstream gone: ${s}`})).catch(u=>M.debug("send error response to upstream failed (ignored)",{err:String(u)}));try{x.downstream.respondAgentRequestError(x.agentRequestId,{code:G.INTERNAL_ERROR,message:`bridge: ${s}`})}catch{}}}}}rejectAllPendingOnReconnect(){let e=this.pendingUpstream.size,s=this.pendingBridge.size;if(!(e===0&&s===0)){M.warn("upstream reconnected, rejecting stale pending requests",{pendingUpstream:e,pendingBridge:s});for(let[,o]of this.pendingUpstream)try{o.downstream.respondAgentRequestError(o.agentRequestId,{code:G.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(Hn(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&&fu.test(o)?this.currentCozeEnv=o:o&&M.warn("rejecting cozeEnv with invalid shape, keeping previous",{rejected:o});try{if(this.upgradeGate?.isUpgrading()&&gu.has(e.method)){let a=this.upgradeGate.pendingTarget()??"";throw new S("BRIDGE_UPGRADING",`bridge upgrading to ${a}, retry shortly`,{retriable:!0})}if(e.method.startsWith("_agent/")){let a=this.extensions[e.method];if(!a){s!==null?await this.sendError(s,G.METHOD_NOT_FOUND,`extension not registered: ${e.method}`):M.warn("drop notification: extension not registered",{method:e.method});return}let x=await a(e,this);s!==null&&await this.upstream.send(Dt(s,x));return}if(e.method.startsWith("session/")){let a=await this.routeSessionMethod(e);s!==null&&await this.upstream.send(Dt(s,a));return}if(e.method==="initialize"){s!==null&&await this.upstream.send(Dt(s,{protocolVersion:1,agentCapabilities:{loadSession:!0}}));return}s!==null?await this.sendError(s,G.METHOD_NOT_FOUND,`method not implemented: ${e.method}`):M.warn("drop unknown notification",{method:e.method})}catch(a){M.error("handleFrame failed",{method:e.method,err:String(a)}),s!==null&&await this.upstream.send(st(s,sn(a)))}}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 a=this.agents.get(o);if(!a)throw this.disconnectedAgents.has(o)?new S("AGENT_DISCONNECTED",`agent ${o} has been disconnected; cloud must _agent/create to revive`):new S("AGENT_NOT_FOUND",`agent not found: ${o}`);let x=typeof s.sessionId=="string"?s.sessionId:void 0;if(e.method==="session/cancel"||e.method==="session/new"||!x)return this.dispatchSessionCall(a,e.method,s);let u=Date.now(),f=!1,g=e.method==="session/prompt";g&&this.upgradeGate?.incActive();try{let p=await a.getSessionQueue(x).enqueue(()=>this.dispatchSessionCall(a,e.method,s));return f=!0,p}finally{g&&this.upgradeGate?.decActive(),M.info("session call done",{agentId:a.agentId,method:e.method,durationMs:Date.now()-u,ok:f})}}async dispatchSessionCall(e,s,o){e.lastActiveAt=Date.now();let{stripped:a}=Ns(o);switch(s){case"session/new":{let x=hu();return M.info("session/new ack (lazy spawn)",{agentId:e.agentId,cloudId:x}),{sessionId:x}}case"session/load":{let x=a;return M.info("session/load ack (lazy spawn)",{agentId:e.agentId,cloudId:x.sessionId}),{}}case"session/prompt":{let x=a,u=x.sessionId;if(!u)throw new S("IPC_BAD_REQUEST","session/prompt: missing sessionId");let f=await this.ensureRuntime(e,u);if(f.replySeq=0,await this.ensureDownstream(e,u,f),!f.downstream||!f.acpSessionId)throw new S("BRIDGE_INTERNAL","session runtime not ready after ensureDownstream");let g=o._meta?.cozeTriggerMsgId;g?e.activeTriggers.set(f.acpSessionId,g):e.activeTriggers.delete(f.acpSessionId);let p=await zo(x.prompt);try{let _=await f.downstream.sessionPrompt({...x,sessionId:f.acpSessionId,prompt:p});return f.lastActiveAt=Date.now(),_}finally{if(e.activeTriggers.delete(f.acpSessionId),f.reloadAfterTurn){f.reloadAfterTurn=!1;let _=f.downstream;_&&(f.downstream=void 0,M.info("reloadAfterTurn: stopping downstream",{agentId:e.agentId,cloudId:u,acpId:f.acpSessionId}),_.stop("reload-after-turn").catch(w=>M.warn("reload-after-turn stop failed (ignored)",{agentId:e.agentId,cloudId:u,err:String(w)})))}else f.downstream?.isAlive()&&this.armIdleTimer(e,u,f)}}case"session/cancel":{let u=a.sessionId;if(!u)throw new S("IPC_BAD_REQUEST","session/cancel: missing sessionId");let f=e.sessions.get(u);if(e.hasSessionQueue(u)){let g=e.getSessionQueue(u);g.size>0&&(M.info("session/cancel: draining queued tasks",{agentId:e.agentId,cloudId:u,queuedCount:g.size}),g.dispose(new S("AGENT_PROTOCOL_ERROR",`cancelled by session/cancel on ${u}`)))}return f?.downstream?.isAlive()&&f.acpSessionId&&await f.downstream.sessionCancel({sessionId:f.acpSessionId}),{ok:!0}}default:throw new S("IPC_BAD_REQUEST",`session method not supported: ${s}`)}}async ensureRuntime(e,s){let o=e.sessions.get(s);if(o)return o;let x={modelToken:e.deployType==="cloud"?await this.requestSessionToken(e.agentId,s):"",tokenGeneratedAt:Date.now(),lastActiveAt:Date.now(),loadingSession:!1,replySeq:0};return e.sessions.set(s,x),await this.persistSessionMapping(e),x}async requestSessionToken(e,s){let o={sessionId:s,_meta:{cozeAgentId:e}};try{let a=await this.sendRequest(Le.GEN_MODEL_TOKEN,o,lu);if(!a?.modelToken)throw new S("MODEL_TOKEN_GEN_FAILED",`cloud returned empty modelToken (agentId=${e}, cloudSessionId=${s})`);return a.modelToken}catch(a){throw a instanceof S&&a.code==="MODEL_TOKEN_GEN_FAILED"?a:new S("MODEL_TOKEN_GEN_FAILED",a instanceof Error?a.message:String(a),{cause:a})}}async ensureDownstream(e,s,o){if(on(o),o.downstream?.isAlive())return;if(!this.sessionSpawner)throw new S("AGENT_SPAWN_FAILED","sessionSpawner not wired (cannot spawn per-session downstream)");let a=3,x=3e4,u=o.spawnFailCount??0,f=o.spawnFailedAt??0;if(u>=a&&Date.now()-f<x)throw new 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((x-(Date.now()-f))/1e3)}s`);let g;try{g=await this.sessionSpawner(e,o.modelToken,s,this.currentCozeEnv)}catch(p){throw o.spawnFailCount=u+1,o.spawnFailedAt=Date.now(),o.spawnFailCount>=a&&o.acpSessionId&&(M.warn("clearing stale acpSessionId after repeated spawn failures",{agentId:e.agentId,cloudId:s,staleAcpId:o.acpSessionId}),o.acpSessionId=void 0),p}if(o.spawnFailCount=0,o.spawnFailedAt=void 0,o.downstream=g,this.attachRuntimeHooks(e,s,o),o.acpSessionId){o.loadingSession=!0;try{await g.sessionLoad({sessionId:o.acpSessionId,cwd:e.workspace}),M.info("session restored via session/load",{agentId:e.agentId,cloudId:s,acpId:o.acpSessionId})}catch(p){M.warn("session/load failed, fallback to session/new",{agentId:e.agentId,cloudId:s,acpId:o.acpSessionId,err:String(p)}),o.acpSessionId=void 0;let _=await g.sessionNew({cwd:e.workspace});o.acpSessionId=_.sessionId,await this.persistSessionMapping(e)}finally{o.loadingSession=!1}}else{let p=await g.sessionNew({cwd:e.workspace});o.acpSessionId=p.sessionId,await this.persistSessionMapping(e)}g.afterSessionEstablished&&o.acpSessionId&&await g.afterSessionEstablished(o.acpSessionId)}armIdleTimer(e,s,o){if(on(o),this.isRuntimeBusy(e,o)){M.debug("skip idle timer: runtime busy (in-flight turn / pending permission)",{agentId:e.agentId,cloudId:s});return}o.idleTimer=setTimeout(()=>{if(o.idleTimer=void 0,this.isRuntimeBusy(e,o)){M.info("idle reaper fired but runtime busy, re-arming",{agentId:e.agentId,cloudId:s}),this.armIdleTimer(e,s,o);return}M.info("session runtime idle timeout, killing downstream",{agentId:e.agentId,cloudId:s});let a=o.downstream;o.downstream=void 0,o.acpSessionId&&e.activeTriggers.delete(o.acpSessionId),a&&a.stop("idle timeout").catch(x=>M.warn("idle stop failed (ignored)",{agentId:e.agentId,cloudId:s,err:String(x)}))},this.sessionIdleTimeoutMs),o.idleTimer.unref?.()}isRuntimeBusy(e,s){if(s.acpSessionId&&e.activeTriggers.has(s.acpSessionId))return!0;let o=s.downstream;if(!o)return!1;for(let a of this.pendingUpstream.values())if(a.downstream===o)return!0;return!1}async sendAgentFileUpdate(e,s,o,a){let x={cozeAgentId:e.agentId,cozeReplySeqID:++s.replySeq};if(s.acpSessionId){let u=e.activeTriggers.get(s.acpSessionId);u&&(x.cozeTriggerMsgId=u)}await this.upstream.send(nn("session/update",{sessionId:o,update:a,_meta:x}))}forwardUpdate(e,s){let o=s.sessionId,a=this.reverseSessionId(e,o);if(!a){M.debug("drop update for unknown session",{agentId:e.agentId,acpId:o});return}let x=e.sessions.get(a);if(!x){M.debug("drop update: runtime gone",{agentId:e.agentId,cloudId:a});return}if(mu(s)){M.debug("drop codex metadata-warn chunk",{agentId:e.agentId,acpId:o});return}let u={cozeAgentId:e.agentId,cozeReplySeqID:++x.replySeq},f=e.activeTriggers.get(o);f&&(u.cozeTriggerMsgId=f),this.upstream.send(nn("session/update",{...s,sessionId:a,_meta:u})).catch(g=>M.warn("forward update failed",{agentId:e.agentId,err:String(g)}))}handleAgentRequest(e,s,o){if(o.method==="session/request_permission"){this.forwardPermissionRequest(e,s,o);return}if(o.method==="fs/write_text_file"||o.method==="fs/read_text_file"){this.handleFsRpcRequest(e,s,o);return}M.warn("unhandled agent request,returning method_not_found",{agentId:e.agentId,method:o.method}),s.respondAgentRequestError(o.id,{code:G.METHOD_NOT_FOUND,message:`method not handled by Bridge: ${o.method}`})}async handleFsRpcRequest(e,s,o){try{let a=e.workspace;if(o.method==="fs/write_text_file"){let x=o.params??{},u=await Oo(x,a);s.respondAgentRequest(o.id,u)}else{let x=o.params??{},u=await No(x,a);s.respondAgentRequest(o.id,u)}}catch(a){M.warn("fs rpc handler failed",{agentId:e.agentId,method:o.method,err:String(a)}),s.respondAgentRequestError(o.id,sn(a))}}forwardPermissionRequest(e,s,o){let a=this.upstreamIds.next("session/request_permission"),x=o.params??{},f=x.sessionId,g=f?e.activeTriggers.get(f):void 0,p={cozeAgentId:e.agentId};g&&(p.cozeTriggerMsgId=g);let _=f?this.reverseSessionId(e,f):void 0,w={...x,..._?{sessionId:_}:{},_meta:p};this.pendingUpstream.set(a,{agentRequestId:o.id,agentId:e.agentId,downstream:s,method:o.method}),M.info("forward permission_request \u2192 upstream",{agentId:e.agentId,upstreamId:a,acpSessionId:f,cloudSessionId:_,toolCallId:x.toolCall?.toolCallId,options:x.options?.map(E=>({optionId:E.optionId,kind:E.kind,name:E.name}))}),this.upstream.send(tn(a,"session/request_permission",w)).catch(E=>{this.pendingUpstream.delete(a),M.error("forward permission request failed",{agentId:e.agentId,err:String(E)}),s.respondAgentRequestError(o.id,{code:G.INTERNAL_ERROR,message:`upstream send failed: ${String(E)}`})})}handleUpstreamResponse(e){if(e.id===null)return;let s=this.lookupPending(this.pendingUpstream,e.id,"upstream");if(s){this.pendingUpstream.delete(s.key);let a=s.value;e.error?(M.info("upstream \u2192 permission response (error)",{agentId:a.agentId,upstreamId:e.id,method:a.method,error:e.error}),a.downstream.respondAgentRequestError(a.agentRequestId,e.error)):(a.method==="session/request_permission"&&pu(e.result,a),M.info("upstream \u2192 permission response (result)",{agentId:a.agentId,upstreamId:e.id,method:a.method,result:e.result}),a.downstream.respondAgentRequest(a.agentRequestId,e.result));return}let o=this.lookupPending(this.pendingBridge,e.id,"bridge");if(o){this.pendingBridge.delete(o.key),clearTimeout(o.value.timer),e.error?o.value.reject(new qn(e.error)):o.value.resolve(e.result);return}M.debug("orphan upstream response (no pending)",{id:e.id})}lookupPending(e,s,o){let a=e.get(s);if(a)return{value:a,key:s};if(typeof s=="number"){let x=String(s),u=e.get(x);if(u)return M.warn(`${o} id type mismatch: number received but Bridge expected string`,{rawId:s,normalizedId:x}),{value:u,key:x}}}sendRequest(e,s,o=uu){let a=this.upstreamIds.next(e);return new Promise((x,u)=>{let f=setTimeout(()=>{this.pendingBridge.delete(a),u(new S("AGENT_TIMEOUT",`${e} timed out after ${o}ms`))},o);this.pendingBridge.set(a,{method:e,resolve:x,reject:u,timer:f}),this.upstream.send(tn(a,e,s)).catch(g=>{let p=this.pendingBridge.get(a);p&&(clearTimeout(p.timer),this.pendingBridge.delete(a)),u(g)})})}async persistSessionMapping(e){if(this.paths)try{let s=new Map;for(let[o,a]of e.sessions){let x={modelToken:a.modelToken,tokenGeneratedAt:a.tokenGeneratedAt};a.acpSessionId&&(x.acpSessionId=a.acpSessionId),s.set(o,x)}await Yr(e.agentId,s,this.paths)}catch(s){M.warn("persist session mapping failed",{agentId:e.agentId,err:String(s)})}}reverseSessionId(e,s){for(let[o,a]of e.sessions.entries())if(a.acpSessionId===s)return o}sendError(e,s,o){return this.upstream.send(st(e,{code:s,message:o,data:{bridgeVersion:it}}))}};function hu(){return du(16).toString("hex")}function pu(n,e){if(!n||typeof n!="object"){M.warn("permission response: result not an object (suspicious)",{agentId:e.agentId,result:n});return}let s=n;if("kind"in s&&!("outcome"in s)){M.warn('permission response: top-level "kind" field (D66 historical bug shape)',{agentId:e.agentId,result:n});return}let o=s.outcome;if(!o||typeof o!="object"){M.warn("permission response: missing or non-object outcome field",{agentId:e.agentId,result:n});return}let x=o.outcome;(typeof x!="string"||x!=="selected"&&x!=="cancelled")&&M.warn("permission response: unknown outcome discriminant",{agentId:e.agentId,outcomeValue:x,result:n})}function mu(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 wu}from"node:crypto";import{chmod as _u,mkdir as yu,writeFile as Fo}from"node:fs/promises";import{createServer as bu}from"node:http";import{dirname as vu}from"node:path";var Su=1e6,di=D("ipc"),Qn=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=wu(32).toString("hex");let e=bu((o,a)=>{this.dispatch(o,a)});this.server=e,await new Promise((o,a)=>{e.once("error",a),e.listen(0,"127.0.0.1",()=>o())});let s=e.address();if(!s||typeof s!="object")throw new Error("failed to obtain IPC port");return this.port=s.port,await this.persistAuthFiles(),di.info("IPC listening",{port:this.port}),{port:this.port,token:this.token}}async stop(){let e=this.server;e&&(await new Promise((s,o)=>{e.close(a=>a?o(a):s())}),this.server=null)}async persistAuthFiles(){await yu(vu(this.paths.portFile),{recursive:!0}),await Fo(this.paths.portFile,String(this.port),"utf8"),await Fo(this.paths.tokenFile,this.token,{encoding:"utf8",mode:384});try{await _u(this.paths.tokenFile,384)}catch(e){di.warn("chmod token file failed (non-POSIX?)",{err:String(e)})}}async dispatch(e,s){if(e.headers.authorization!==`Bearer ${this.token}`){xn(s,401,{error:"unauthorized"});return}let a=`${e.method} ${(e.url??"").split("?")[0]}`,x=this.routes.get(a);if(!x){xn(s,404,{error:"not found"});return}let u=null;if(e.method==="POST")try{u=await Eu(e)}catch(f){xn(s,400,{error:"invalid json",detail:String(f)});return}try{let f=await x.handler(u,e);xn(s,200,f??{ok:!0})}catch(f){di.error("IPC handler failed",{key:a,err:String(f)}),xn(s,500,{error:f instanceof Error?f.message:String(f)})}}};function xn(n,e,s){n.statusCode=e,n.setHeader("content-type","application/json"),n.end(JSON.stringify(s))}async function Eu(n){let e=[],s=0;for await(let a of n){let x=a;if(s+=x.length,s>Su)throw new Error("body too large");e.push(x)}let o=Buffer.concat(e).toString("utf8");return o?JSON.parse(o):null}import{sep as Uo}from"node:path";import{fileURLToPath as Au}from"node:url";function qo(){return Cu(Au(import.meta.url))}function Cu(n){let e=`${Uo}src${Uo}`;return n.includes(e)}U();ie();import{spawn as Iu}from"node:child_process";import{existsSync as Pu,mkdirSync as ku,openSync as Tu}from"node:fs";import{dirname as Du}from"node:path";import{fileURLToPath as Ru}from"node:url";var Ou=D("spawn-helper");function Nu(n){return Pu(n.libEntry)?n.libEntry:Ru(new URL("../index.ts",import.meta.url))}function Lu(n,e,s){let o=n.endsWith(".ts"),a=["--upgrade-helper",`--target-version=${e}`,`--old-pid=${s}`];return o?["--import","tsx/esm",n,...a]:[n,...a]}async function Ho(n,e,s={}){let o=s.paths??q(),a=Nu(o);ku(Du(o.logFile),{recursive:!0});let x=Tu(o.logFile,"a"),u=Lu(a,n,e),f=Iu(process.execPath,u,{detached:!0,stdio:["ignore",x,x],env:{...process.env,COZE_BRIDGE_UPGRADE_HELPER:"1"}});if(f.unref(),typeof f.pid!="number")throw new Error("failed to spawn upgrade helper (no pid)");Ou.info("upgrade helper spawned",{pid:f.pid,targetVersion:n,oldPid:e,entry:a})}U();import{mkdir as Mu,writeFile as Bu}from"node:fs/promises";import{dirname as zu}from"node:path";import{gunzipSync as Fu}from"node:zlib";var ui=D("tarball-downloader"),Uu="https://registry.npmjs.org",Go="package/dist/index.js";async function Ko(n,e,s={}){if(!/^[\w.\-+]+$/.test(n))throw new Error(`invalid version string: ${JSON.stringify(n)}`);let a=`${(s.registry??Uu).replace(/\/+$/,"")}/coze-bridge/${n}`;ui.info("fetching tarball metadata",{metaUrl:a});let x=await fetch(a);if(!x.ok)throw new Error(`registry metadata ${a} returned ${x.status}`);let f=(await x.json())?.dist?.tarball;if(!f)throw new Error(`registry metadata missing dist.tarball for ${n}`);ui.info("downloading tarball",{tarballUrl:f});let g=await fetch(f);if(!g.ok)throw new Error(`tarball ${f} returned ${g.status}`);let p=Buffer.from(await g.arrayBuffer()),_=Fu(p),w=qu(_,Go);if(!w)throw new Error(`tarball missing entry ${Go}`);await Mu(zu(e),{recursive:!0}),await Bu(e,w),ui.info("dist extracted",{destPath:e,bytes:w.length})}function qu(n,e){let s=0;for(;s+512<=n.length;){let o=n.subarray(s,s+512);if(o.every(_=>_===0))return null;let a=o.subarray(0,100),x=a.indexOf(0),u=a.subarray(0,x===-1?100:x).toString("utf8"),f=o.subarray(124,136).toString("ascii").trim().replace(/\0/g,""),g=Number.parseInt(f,8)||0,p=s+512;if(u===e)return n.subarray(p,p+g);s=p+Math.ceil(g/512)*512}return null}Mt();U();import{resolve as Hu}from"node:path";function jo(n,e){let s=n.split(".").map(Number),o=e.split(".").map(Number),a=Math.max(s.length,o.length);for(let x=0;x<a;x++){let u=s[x]??0,f=o[x]??0;if(u<f)return!0;if(u>f)return!1}return!1}var gt=D("upgrade-manager"),Gu=300*1e3,Ku=3,Zn=class{constructor(e){this.opts=e}opts;inFlightTarget=null;async requestUpgrade(e){if(this.inFlightTarget===e){gt.debug("upgrade already in-flight, skip",{targetVersion:e});return}this.inFlightTarget=e;try{let s=await ct(this.opts.paths.configFile)??{};if(s.disableAutoUpgrade){gt.info("disableAutoUpgrade=true, skip",{targetVersion:e});return}if(this.opts.isDevMode()){gt.warn("dev mode, skip auto-upgrade",{targetVersion:e});return}if(!jo(this.opts.currentVersion,e)){gt.debug("local version >= target, skip",{local:this.opts.currentVersion,target:e});return}let o=s.upgradeAttempts?.[e];if((o?.count??0)>=Ku){gt.warn("upgrade attempts cap reached, skip",{targetVersion:e,count:o?.count});return}let a=Hu(this.opts.paths.libDir,"index.js.next");try{await this.opts.download(e,a)}catch(u){await this.recordAttempt(s,e,String(u)),gt.warn("download failed, attempt recorded",{targetVersion:e,err:String(u)});return}this.opts.daemon.markUpgradePending(e);let x=await this.opts.daemon.waitIdle(Gu);gt.info("waitIdle done",{result:x}),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 a=e.upgradeAttempts[s];e.upgradeAttempts[s]={count:(a?.count??0)+1,lastAt:Date.now(),...o?{lastError:o}:{}},await Fe(e,this.opts.paths.configFile)}};var lc=je(na(),1);var Al=je(Xa(),1),Cl=je(hr(),1),Il=je(Ft(),1),Pl=je(Ei(),1),kl=je(Ii(),1),Tl=je(Oi(),1),oc=je(_r(),1),Dl=je(sc(),1);var ac=oc.default;U();var he=D("upstream.frontier"),xc="application/json",dc="none",wn=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:Bs,...Tt(this.opts.ppeOverride)};class s extends ac{constructor(f){super(f,Ms,{headers:e})}send(f,...g){if(_s("debug"))try{let p;typeof f=="string"?p=Buffer.from(f,"utf8"):f instanceof Buffer?p=f:f instanceof ArrayBuffer?p=new Uint8Array(f):ArrayBuffer.isView(f)?p=new Uint8Array(f.buffer,f.byteOffset,f.byteLength):p=new Uint8Array(0);let _=Buffer.from(p.slice(0,128)).toString("hex");he.debug("WS raw frame out",{bytes:p.byteLength,headHex:_})}catch(p){he.warn("WS raw frame dump failed",{err:String(p)})}super.send(f,...g)}}let o=Fs(this.opts.urlOverride),a={url:o,ws:s,fpID:Ls,aID:Bn,accessKey:this.opts.handshake.accessKey,deviceID:this.opts.handshake.deviceId,payloadType:{type:xc,force:!0},payloadEncoding:{encoding:dc,force:!0},enableTransformTextPayload:!0,enableQoS:!1,enableAutoAck:!1,automaticOpen:!1,maxRetries:Number.POSITIVE_INFINITY,debug:this.opts.debug??!1},x=new lc.FWS(a);x.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 f of this.connectHandlers)Promise.resolve(f({initial:u})).catch(g=>he.warn("onConnect handler threw (ignored)",{err:String(g)}))},x.onclose=u=>{this.opened=!1,he.info("frontier closed",{code:u.code,reason:u.reason,willReconnect:u.willReconnect})},x.onerror=u=>{he.warn("frontier error",{code:u.code,msg:u.message})},x.onmessage=u=>this.handleMessage(u),this.fws=x,await x.connect()}async stop(e){let s=this.fws;if(s){this.fws=null,this.opened=!1;try{s.close(1e3,e??"bridge shutdown")}catch(o){he.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),a=e;uc(a)||he.info("frontier frame out",{method:a.method,jsonrpcId:a.id,size:o.length});try{await s.send(o,{service:33555712,method:1,payloadType:xc,payloadEncoding:dc})}catch(u){throw he.warn("frontier frame send failed",{method:a.method,jsonrpcId:a.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 a=s(o.cozeAgentId);a&&(o.cozePatToken=a)}handleMessage(e){let s=e.message?.service;if(s!==33555712){he.debug("drop non-adapter frontier frame",{service:s});return}let o=Ll(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 a;try{a=JSON.parse(o)}catch(u){he.warn("frontier message JSON parse failed",{err:String(u),head:o.slice(0,80)});return}let x=a;uc(x)||he.info("frontier frame in",{logid:Nl(e.message?.LogID),logidNew:e.message?.LogIDNew,msgId:e.message?.msgID,jsonrpcId:x.id,method:x.method,body:Ol(o)}),Promise.resolve(this.handler(a)).catch(u=>he.warn("frontier frame handler threw",{err:String(u)}))}};function uc(n){return n.method==="_agent/health"?!0:typeof n.id=="string"&&n.id.startsWith("agent.health_")}var fc=2e3;function Ol(n){return n.length<=fc?n:`${n.slice(0,fc)}...<truncated, total ${n.length} chars>`}function Nl(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 Li=D("upstream.switchable"),br=class{inner;handler=null;connectHandlers=[];constructor(e){this.inner=e}async swap(e,s){if(this.inner===e)return;Li.info("swap upstream",{reason:s});let o=this.inner;if(this.inner=e,this.handler&&e.onFrame(this.handler),e.onConnect)for(let a of this.connectHandlers)e.onConnect(a);try{await e.start()}catch(a){throw Li.error("swap target start failed, reverting",{err:String(a)}),this.inner=o,a}await o.stop(s??"swapped").catch(a=>Li.warn("previous upstream stop threw (ignored)",{err:String(a)}))}current(){return this.inner}start(){return this.inner.start()}stop(e){return this.inner.stop(e)}send(e){return this.inner.send(e)}onFrame(e){this.handler=e,this.inner.onFrame(e)}onConnect(e){this.connectHandlers.push(e),this.inner.onConnect?.(e)}isConnected(){return this.inner.isConnected()}};U();var Mi=D("upstream"),jt=class{handler=null;async start(){Mi.info("NoopUpstream started (M1 skeleton; real Frontier wired in M4)")}async stop(e){Mi.info("NoopUpstream stopped",{reason:e})}async send(e){Mi.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 Bi}from"node:fs";import{dirname as Ml}from"node:path";var Bl=D("pat-token-store");async function gc(n=q()){try{let s=(await Bi.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 _n(n,e=q()){if(!n)throw new Error("writePatToken: empty patToken");await Bi.mkdir(Ml(e.patTokenFile),{recursive:!0}),await Bi.writeFile(e.patTokenFile,n,{encoding:"utf8",mode:384})}ie();ie();import{promises as vr}from"node:fs";import{join as zl}from"node:path";function Fl(n){return`#!/bin/sh
124
124
  exec node ${JSON.stringify(n)} "$@"
125
- `}function zl(n){return`@echo off
125
+ `}function Ul(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 Ni(p,"utf8").catch(()=>null)!==m&&await og(p,m),u.libVersion=d,await ze(u,e.configFile),bc.info("dist installed",{libEntry:e.libEntry,fromVersion:l,toVersion:d}),l?{kind:"version-changed",fromVersion:l,toVersion:d,libEntry:e.libEntry}:{kind:"first-install",libVersion:d,libEntry:e.libEntry}}Er();ie();import{basename as dg,resolve as ug}from"node:path";var fg=9e4,lg={PATH_OUTSIDE_WORKSPACE:3,FILE_TOO_LARGE:3,UNSUPPORTED_MIME:3,IPC_BAD_REQUEST:3,AGENT_NOT_FOUND:4,IPC_AUTH_FAILED:4,AGENT_DISCONNECTED:5,UPLOAD_FAILED:5,UPSTREAM_NOT_READY:5,UPSTREAM_DISCONNECTED:5,UPSTREAM_HANDSHAKE_FAILED:5,AGENT_BUSY:1,AGENT_SPAWN_FAILED:1,AGENT_TIMEOUT:1,AGENT_PROTOCOL_ERROR:1,BRIDGE_CONFIG_INVALID:1,BRIDGE_INTERNAL:1,MODEL_TOKEN_GEN_FAILED:1,OPERATION_NOT_ALLOWED_FOR_LOCAL:1,BRIDGE_UPGRADING:5};function gg(n){return lg[n]??1}async function vc(n,e={}){let s=e.paths??q();if(!n.agentId||!n.sessionId)return process.stderr.write(`Error: missing --agent-id and/or --session-id. These IDs come from the <coze-context> block injected at the top of each prompt \u2014 extract agentId and sessionId from there and pass them as flags. Example: coze-bridge send image x.png --agent-id <id> --session-id <id>
129
- `),4;let o=await Sr(s).catch(()=>null);if(!o)return process.stderr.write(`Error: coze-bridge daemon not running (cannot read ${s.portFile} / ${s.tokenFile}). Make sure you are inside an agent session spawned by the daemon.
130
- `),4;let c={agentId:n.agentId,sessionId:n.sessionId,kind:n.kind,path:ug(process.cwd(),n.path),...n.caption?{caption:n.caption}:{},...n.name?{name:n.name}:{}},d;try{d=await hg(o,"/agent/send",c,fg)}catch(u){return process.stderr.write(`Error: daemon IPC failed: ${u instanceof Error?u.message:String(u)}
131
- `),4}if(!d.ok)return process.stderr.write(`Error: ${d.code}: ${d.message}
132
- `),gg(d.code);if(n.json)process.stdout.write(`${JSON.stringify(d)}
133
- `);else{let u=n.name??dg(c.path);process.stdout.write(`Sent ${n.kind} ${u} (${pg(d.bytes)})
134
- `)}return 0}async function hg(n,e,s,o){let c=new AbortController,d=setTimeout(()=>c.abort(),o);try{let u=await fetch(`http://127.0.0.1:${n.port}${e}`,{method:"POST",headers:{Authorization:`Bearer ${n.token}`,"content-type":"application/json"},body:JSON.stringify(s),signal:c.signal}),l=await u.text(),p=l?JSON.parse(l):null;return p&&typeof p=="object"&&"ok"in p?p:{ok:!1,code:"BRIDGE_INTERNAL",message:`unexpected daemon response (status=${u.status}): ${l.slice(0,200)}`}}finally{clearTimeout(d)}}function pg(n){return n<1024?`${n}B`:n<1024*1024?`${(n/1024).toFixed(1)}KB`:`${(n/1024/1024).toFixed(1)}MB`}var Oc=D("cli");function he(n,e){let s=[],o;for(let c=0;c<n.length;c++){let d=n[c];if(d===e){o=n[c+1],c+=1;continue}if(d.startsWith(`${e}=`)){o=d.slice(e.length+1);continue}s.push(d)}return{value:o,rest:s}}function Gg(n){let e=n.slice(2);if(e.includes("--version")||e.includes("-v"))return{mode:"version"};if(e.includes("--daemon"))return{mode:"daemon"};if(e.includes("--status"))return{mode:"status"};if(e.includes("--stop"))return{mode:"stop"};if(e.includes("--refresh"))return{mode:"refresh"};if(e.includes("--uninstall"))return{mode:"uninstall"};if(e.includes("--install-service"))return{mode:"install-service"};if(e.includes("--upgrade-helper")){let P=e.filter(se=>se!=="--upgrade-helper"),{value:j,rest:Q}=he(P,"--target-version"),{value:K}=he(Q,"--old-pid"),$=K?Number.parseInt(K,10):Number.NaN;return!j||!Number.isFinite($)?{mode:"help"}:{mode:"upgrade-helper",targetVersion:j,oldPid:$}}if(e[0]==="send")return Wg(e.slice(1));if(e[0]==="connect")return Jg(e.slice(1));if(e.includes("--help")||e.includes("-h")||e.length===0)return{mode:"help"};let s=e,{value:o,rest:c}=he(s,"--pat-token");s=c;let{value:d,rest:u}=he(s,"--pair-code");s=u;let{value:l,rest:p}=he(s,"--env");s=p;let{value:m,rest:_}=he(s,"--handshake-url");s=_;let{value:y,rest:I}=he(s,"--frontier-url");s=I;let{value:L}=he(s,"--agent-id");if(!o||!d)return{mode:"help"};let T={mode:"pair",privatecode:o,pairingCode:d};return l&&(T.env=l),m&&(T.handshakeUrl=m),y&&(T.frontierUrl=y),L&&(T.agentId=L),T}function Wg(n){let e=n[0],s=n[1];if(e!=="image"&&e!=="file")return{mode:"help"};if(!s||s.startsWith("--"))return{mode:"help"};let o=n.slice(2),{value:c,rest:d}=he(o,"--caption");o=d;let{value:u,rest:l}=he(o,"--name");o=l;let{value:p,rest:m}=he(o,"--agent-id");o=m;let{value:_,rest:y}=he(o,"--session-id");o=y;let I=o.includes("--json"),L={mode:"send",kind:e,path:s,json:I};return c&&(L.caption=c),u&&(L.name=u),p&&(L.agentId=p),_&&(L.sessionId=_),L}function Jg(n){let e=n,{value:s,rest:o}=he(e,"--pat-token");e=o;let{value:c,rest:d}=he(e,"--env");e=d;let{value:u,rest:l}=he(e,"--handshake-url");e=l;let{value:p}=he(e,"--frontier-url"),m={mode:"connect"};return s&&(m.privatecode=s),c&&(m.env=c),u&&(m.handshakeUrl=u),p&&(m.frontierUrl=p),m}var $g=`
127
+ `}async function hc(n,e=q()){let s=e.binDir;await vr.mkdir(s,{recursive:!0});let o=zl(s,process.platform==="win32"?"coze-bridge.cmd":"coze-bridge"),a=process.platform==="win32"?Ul(n):Fl(n);return await vr.readFile(o,"utf8").catch(()=>null)===a||(await vr.writeFile(o,a,"utf8"),process.platform!=="win32"&&await vr.chmod(o,493)),s}U();ie();import{execSync as mc}from"node:child_process";import{readFileSync as wc,unlinkSync as ql}from"node:fs";import{mkdir as Hl,readFile as _c,unlink as yc,writeFile as Gl}from"node:fs/promises";import{dirname as Kl}from"node:path";function pc(n){try{return process.kill(n,0),!0}catch(e){return e.code==="EPERM"}}var jl=D("single-instance"),Sr=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 yc(this.pidFile).catch(()=>{})),await Hl(Kl(this.pidFile),{recursive:!0}),await Gl(this.pidFile,String(process.pid),"utf8"),this.acquired=!0,this.installCleanupHooks(),{kind:"acquired"})}async release(){if(this.acquired){try{(await _c(this.pidFile,"utf8")).trim()===String(process.pid)&&await yc(this.pidFile)}catch{}this.acquired=!1}}async readExistingPid(){try{let e=await _c(this.pidFile,"utf8"),s=Number.parseInt(e.trim(),10);return Number.isFinite(s)&&s>0?s:null}catch(e){if(e.code==="ENOENT")return null;throw e}}isAlive(e){return pc(e)?this.matchesDaemonTitle(e):!1}matchesDaemonTitle(e){if(process.platform==="win32")return this.matchesDaemonTitleWindows(e);try{let s=wc(`/proc/${e}/cmdline`,"utf8").replace(/\0/g," ");return!!(s.includes("coze-bridge-daemon")||s.includes("lib/index.js"))}catch{}try{let s=mc(`ps -o command= -p ${e}`,{stdio:["ignore","pipe","ignore"],timeout:1e3}).toString();return s.trim()?s.includes("coze-bridge-daemon")||s.includes("lib/index.js"):!1}catch{return!0}}matchesDaemonTitleWindows(e){try{let o=mc(`tasklist /FI "PID eq ${e}" /FO CSV /NH`,{stdio:["ignore","pipe","ignore"],timeout:2e3}).toString().trim();if(!o||o.startsWith("INFO:"))return!1;let a=o.split(",",1)[0]?.replace(/^"|"$/g,"").toLowerCase()??"";return a.includes("node")||a.includes("coze-bridge")}catch{return!0}}installCleanupHooks(){process.once("exit",()=>{if(this.acquired)try{wc(this.pidFile,"utf8").trim()===String(process.pid)&&ql(this.pidFile)}catch{}})}};function Wl(){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(a=>setTimeout(a,200))}return n===0?"idle":"timeout"}}}var N=D("daemon"),$l="coze-bridge-daemon";async function vc(){let n=new Sr({processTitle:$l}),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??{};En({pid:process.pid}),N.info(s?"loaded bridge config":"initialized bridge config");try{let I=new Lt;o.frameworksCache=await I.detectAll(),N.info("refreshed frameworks_cache",{detected:Object.keys(o.frameworksCache)})}catch(I){N.warn("framework detection failed",{err:String(I)})}await Fe(o);let a=new br(new jt),x=q(),u=Wl(),f=null,g=new Xn({upstream:a,paths:x,bridgeConfig:o,upgradeGate:u,sessionSpawner:async(I,O,F,be)=>{if(!f)throw new Error("agentManager not ready");return f.spawnSessionDownstream(I,O,F,be)}});await Vl(x,g);let p=new Yn({paths:x,config:o,registry:g});f=p;let _,w,E=null,T={},k,P=null,H=null;g.registerExtension("_agent/create",async I=>p.createAgent(I.params)),g.registerExtension("_agent/health",async()=>({ok:!0}));let X={},K=new Fn({agents:g.agents,disposeAndMarkDisconnected:async(I,O)=>{let F=g.agents.get(I);if(F){await p.cleanupOpenclawSessionProviders(F).catch(Q=>N.warn("cleanup openclaw providers failed (ignored)",{agentId:I,err:String(Q)}));let be=!0;try{await F.dispose(`disconnect: ${O}`)}catch(Q){be=!1,N.error("dispose during disconnect FAILED, leaving agent in error state",{agentId:I,err:String(Q)}),F.status="error"}be&&(F.status="disconnected",g.unregister(I),g.disconnectedAgents.add(I))}else g.disconnectedAgents.add(I)},detailSyncer:async I=>{if(!X.ref)throw new Error("agent-detail-sync not initialized yet");await X.ref.syncOne(I)},cleanupOpenclawProviders:async I=>{await p.cleanupOpenclawSessionProviders(I)},openclawRepair:async(I,O)=>{await p.openclawRepair(I,O)},isRuntimePendingPermission:I=>g.hasPendingPermissionFor(I)});g.registerExtension("_agent/listSkills",I=>K.listSkills(I.params)),g.registerExtension("_agent/addSkills",I=>K.addSkills(I.params)),g.registerExtension("_agent/removeSkills",I=>K.removeSkills(I.params)),g.registerExtension("_agent/getFileTree",I=>K.getFileTree(I.params)),g.registerExtension("_agent/getFileContent",I=>K.getFileContent(I.params)),g.registerExtension("_agent/update",I=>K.updateAgent(I.params)),g.registerExtension("_agent/disconnect",I=>K.disconnectAgent(I.params)),g.registerExtension("_agent/switchModel",I=>K.switchModel(I.params)),g.registerExtension("_agent/reset",I=>K.resetAgent(I.params)),g.registerExtension("_agent/repair",I=>K.repairAgent(I.params));let J=new Nn({paths:x,handlers:K,sendDetail:I=>g.sendRequest("_agent/detail",I)});X.ref=J;let oe=async I=>{await Promise.allSettled(I.map(async O=>{try{await K.disconnectAgent({agentId:O.agentId,reason:`auth_failure: code=${O.code} ${O.message}`}),N.info("agent disconnected due to auth failure from heartbeat response",{agentId:O.agentId,code:O.code,message:O.message})}catch(F){N.warn("disconnect during authFailure handling failed (ignored)",{agentId:O.agentId,err:String(F)})}}))};a.onConnect(({initial:I})=>{N.info("frontier upstream connected, triggering detail sync",{initial:I}),J.syncAll(I?"initial-connect":"reconnect").catch(O=>N.warn("detail sync top-level error (ignored)",{err:String(O)}))});let ae=new Qn({paths:x,routes:[{method:"GET",path:"/status",handler:async()=>({running:!0,pid:process.pid,agents:[...g.agents.keys()],deviceId:E??"",frameworksCache:o.frameworksCache??{}})},{method:"POST",path:"/pair",handler:async I=>{let O=I,F=O?.privatecode,be=O?.pairing_code;if(!F||!be)throw new S("IPC_BAD_REQUEST","/pair requires privatecode + pairing_code");let Q=Qt(O.env),ge=O.handshake_url,Ke=O.frontier_url,ne=bc(O.env,ge,Ke),Qe=!!_&&_!==F,Y=w!==void 0&&w!==ne,V=Qe||Y,ut=await Qr({privatecode:F,...ge?{endpoint:ge}:{},ppeOverride:Q});if(V){N.warn("pair config switched, resetting agents",{pcChanged:Qe,envChanged:Y,previousPc:_?Er(_):"",nextPc:Er(F),previousEnvKey:w??"",nextEnvKey:ne});for(let re of[...g.agents.values()])await re.dispose("pair config switch").catch(()=>{}),g.agents.delete(re.agentId);g.disconnectedAgents.size>0&&(N.info("clearing disconnectedAgents set on pair config switch",{count:g.disconnectedAgents.size}),g.disconnectedAgents.clear()),await a.swap(new jt,"pair switch").catch(()=>{})}E=ut.deviceId,En({deviceId:E,pid:process.pid}),ci({patToken:F,env:O.env}).catch(re=>N.warn("coze-cli setup error (ignored)",{err:String(re)}));let W=new wn({handshake:ut,privatecode:F,...Ke?{urlOverride:Ke}:{},ppeOverride:Q,getPatTokenForAgent:re=>g.agents.get(re)?.patToken});await a.swap(W,"pair");try{let re=new Lt;o.frameworksCache=await re.detectAll(),await Fe(o),N.info("frameworks_cache refreshed before pair",{detected:Object.keys(o.frameworksCache)})}catch(re){N.warn("frameworks_cache refresh failed (ignored, using cached)",{err:String(re)})}let yt=Object.keys(o.frameworksCache??{});try{let re=await g.sendRequest("_agent/pair",{pairCode:be,patToken:F,frameworks:yt,_meta:{cozeDeviceId:E}});N.info("_agent/pair ok",{pairResult:re}),_=F,w=ne,T=Q,k=ge,_n(F,x).catch(_e=>N.warn("writePatToken after /pair failed (ignored)",{err:String(_e)})),P||(P=new en({core:g,getDeviceId:()=>E??"",onTickEnd:()=>J.retryPending().catch(_e=>N.warn("detailSync.retryPending failed (ignored)",{err:String(_e)})),onAuthFailures:oe,onMinBridgeVersion:_e=>H?.requestUpgrade(_e)})),P.start(),V&&Ar(x,p).catch(_e=>N.warn("post-pair-switch auto-revive error (ignored)",{err:String(_e)}));let bt;return O.agent_id&&(bt=await Yl(O.agent_id,x,p,_e=>g.sendRequest("_agent/detail",_e),F).catch(_e=>(N.error("--agent-id ensureAgent failed",{agentId:O.agent_id,err:String(_e)}),{ok:!1,agentId:O.agent_id??"",note:String(_e)}))),{ok:!0,note:"paired with cloud",...bt?{agent:bt}:{}}}catch(re){return N.error("_agent/pair failed",{err:String(re)}),{ok:!1,note:`pair failed: ${String(re)}`}}}},{method:"POST",path:"/connect",handler:async I=>{let O=I,F=O?.privatecode;if(!F)throw new S("IPC_BAD_REQUEST","/connect requires privatecode");let be=Qt(O.env),Q=O.handshake_url,ge=O.frontier_url,Ke=bc(O.env,Q,ge);if(_===F&&w===Ke){let W=await Jl(x);return g.agents.size===0&&W?(N.warn("/connect noop but core.agents empty with configs on disk; re-running auto-revive"),Ar(x,p).catch(yt=>N.warn("connect-noop auto-revive error (ignored)",{err:String(yt)}))):N.info("/connect: already connected with same PAT + env, noop"),{ok:!0,note:"already connected"}}let ne=!!_&&_!==F,Qe=w!==void 0&&w!==Ke,Y=ne||Qe,V=await Qr({privatecode:F,...Q?{endpoint:Q}:{},ppeOverride:be});if(Y){N.warn("connect config switched, resetting agents",{pcChanged:ne,envChanged:Qe,previousPc:_?Er(_):"",nextPc:Er(F)});for(let W of[...g.agents.values()])await W.dispose("connect config switch").catch(()=>{}),g.agents.delete(W.agentId);g.disconnectedAgents.size>0&&(N.info("clearing disconnectedAgents set on connect config switch",{count:g.disconnectedAgents.size}),g.disconnectedAgents.clear()),await a.swap(new jt,"connect switch").catch(()=>{})}E=V.deviceId,En({deviceId:E,pid:process.pid}),ci({patToken:F,env:O.env}).catch(W=>N.warn("coze-cli setup error (ignored)",{err:String(W)}));let ut=new wn({handshake:V,privatecode:F,...ge?{urlOverride:ge}:{},ppeOverride:be,getPatTokenForAgent:W=>g.agents.get(W)?.patToken});return await a.swap(ut,"connect"),_=F,w=Ke,T=be,k=Q,P||(P=new en({core:g,getDeviceId:()=>E??"",onTickEnd:()=>J.retryPending().catch(W=>N.warn("detailSync.retryPending failed (ignored)",{err:String(W)})),onAuthFailures:oe,onMinBridgeVersion:W=>H?.requestUpgrade(W)})),P.start(),Y&&Ar(x,p).catch(W=>N.warn("post-connect-switch auto-revive error (ignored)",{err:String(W)})),_n(F,x).catch(W=>N.warn("writePatToken after /connect failed (ignored)",{err:String(W)})),N.info("/connect: WS established",{deviceId:E}),{ok:!0,note:"connected"}}},{method:"POST",path:"/_agent/create",handler:async I=>{let O=I;return{ok:!0,result:await p.createAgent(O)}}},{method:"POST",path:"/agent/send",handler:async I=>{let O=I;if(!O?.agentId||!O?.sessionId||!O?.kind||!O?.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 vo(O,{core:g,patToken:_,handshakeBase:k,ppeOverride:T})}catch(F){if(F instanceof S)return{ok:!1,code:F.code,message:F.message};throw F}}},{method:"POST",path:"/refresh",handler:async()=>{N.info("IPC /refresh: re-detecting frameworks");let I=new Lt;return o.frameworksCache=await I.detectAll(),await Fe(o),{ok:!0,frameworks:o.frameworksCache}}},{method:"POST",path:"/shutdown",handler:async()=>(N.info("IPC /shutdown received"),setImmediate(()=>{ue.shutdown("ipc /shutdown")}),{ok:!0})}]}),{port:Te,token:me}=await ae.start();try{await hc(x.libEntry,x)}catch(I){N.warn("bin shim install failed (D72 send \u547D\u4EE4\u53EF\u80FD\u4E0D\u53EF\u7528)",{err:String(I)})}await g.start(),Ar(x,p).catch(I=>N.warn("auto-revive top-level error (ignored)",{err:String(I)})),Ss().catch(I=>N.warn("acp wrapper warmup top-level error (ignored)",{err:String(I)}));let de=null,ue={port:Te,token:me,core:g,ipc:ae,shutdown(I){return de||(N.info("daemon shutdown",{reason:I}),de=(async()=>{P?.stop(),await g.stop(I),await ae.stop(),await n.release()})(),de)}};H=new Zn({paths:x,currentVersion:it,isDevMode:qo,download:(I,O)=>Ko(I,O),spawnHelper:(I,O)=>Ho(I,O,{paths:x}),daemon:{markUpgradePending:I=>{N.warn("upgrade pending, ACP gate engaged",{target:I}),u.markUpgradePending(I)},waitIdle:I=>u.waitIdle(I),exit:I=>{ue.shutdown("upgrade").then(()=>process.exit(I))}}});for(let I of["SIGTERM","SIGINT"])process.on(I,()=>{ue.shutdown(I).then(()=>process.exit(0))});return N.info("daemon ready",{port:Te,pid:process.pid,nodeVersion:process.version,platform:process.platform,frameworks:Object.keys(o.frameworksCache??{}),libVersion:o.libVersion??"dev"}),ue}async function Jl(n){let{readdir:e}=await import("node:fs/promises");try{return(await e(n.agentsRoot)).length>0}catch{return!1}}function Er(n){return n.length<=8?"***":`${n.slice(0,4)}***${n.slice(-4)}`}function bc(n,e,s){return`${n??""}|${e??""}|${s??""}`}async function Vl(n,e){let{readdir:s}=await import("node:fs/promises"),o;try{o=await s(n.agentsRoot)}catch{return}let{loadAgentConfig:a,enforceAgentConfigMode:x}=await Promise.resolve().then(()=>(rt(),On));for(let u of o){await x(u,n).catch(f=>N.warn("enforceAgentConfigMode failed (ignored)",{agentId:u,err:String(f)}));try{let f=await a(u,n);f?.disconnectedAt&&(e.disconnectedAgents.add(u),N.info("agent marked disconnected on startup",{agentId:u,disconnectedAt:f.disconnectedAt,reason:f.disconnectReason??""}))}catch(f){N.warn("failed to load agent config on startup, skipping",{agentId:u,err:String(f)})}}}async function Yl(n,e,s,o,a){let{loadAgentConfig:x}=await Promise.resolve().then(()=>(rt(),On)),u=await x(n,e);if(u){N.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}:{},...a?{patToken:a}:{}};return await s.createAgent(_),{ok:!0,agentId:n,note:u.disconnectedAt?"revived from local config":"connected from local config"}}N.info("--agent-id: local config missing, pulling _agent/detail from cloud",{agentId:n});let f=await o({_meta:{cozeAgentId:n}});if(!f.framework)throw new S("AGENT_NOT_FOUND",`agent ${n} \u4E0D\u5728\u672C\u5730; \u4E91\u7AEF _agent/detail \u54CD\u5E94\u7F3A framework \u5B57\u6BB5 (D36 \u534F\u8BAE\u6269\u5C55\u672A\u751F\u6548), \u65E0\u6CD5\u5728\u672C\u673A\u65B0\u5EFA`);let g={agentId:f.agentId,framework:f.framework,...f.cozeIdentity?{cozeIdentity:f.cozeIdentity}:{},...f.model?{model:f.model}:{},...a?{patToken:a}:{},...f.deployType?{_meta:{cozeDeployType:f.deployType}}:{}};await s.createAgent(g);let p=f.deployType==="cloud"&&f.framework==="openclaw";return{ok:!0,agentId:n,note:p?"cloud agent acknowledged":"created from cloud detail"}}async function Ar(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:a}=await Promise.resolve().then(()=>(rt(),On));N.info("auto-revive: scanning local agents on startup",{count:o.length});let x=0,u=0;for(let f of o){let g;try{g=await a(f,n)}catch(p){N.warn("auto-revive: load config failed (skipping)",{agentId:f,err:String(p)}),u+=1;continue}if(!g){u+=1;continue}if(g.disconnectedAt){N.info("auto-revive: skip disconnected agent",{agentId:f,disconnectedAt:g.disconnectedAt}),u+=1;continue}try{N.info("auto-revive: re-registering agent (D44 no spawn)",{agentId:f,framework:g.framework});let p=Xl(g);await e.createAgent({agentId:g.agentId,framework:g.framework,...g.cozeIdentity?{cozeIdentity:g.cozeIdentity}:{},...g.model?{model:g.model}:{},...p?{_meta:p}:{}}),x+=1}catch(p){N.warn("auto-revive: createAgent failed (skipping)",{agentId:f,framework:g.framework,err:String(p)}),u+=1}}return N.info("auto-revive: done",{revived:x,skipped:u,total:o.length}),{revived:x,skipped:u,total:o.length}}function Xl(n){let e={};return n.deployType&&(e.cozeDeployType=n.deployType),n.accountId&&(e.cozeAccountId=n.accountId),Object.keys(e).length>0?e:void 0}Cr();Pr();U();ie();Mt();U();ie();import{copyFile as Ec,mkdir as ag,readFile as Fi,writeFile as cg}from"node:fs/promises";import{dirname as xg,resolve as Ui,sep as kr}from"node:path";import{fileURLToPath as dg}from"node:url";var Ac=D("dist-install");function ug(n){let e=dg(n),s=xg(e),o=`${kr}src${kr}`;if(s.includes(o)||s.endsWith(`${kr}src${kr}cli`))return null;let a=Ui(s,"index.js"),x=Ui(s,"..","package.json");return{dist:a,pkgJson:x}}async function qi(n={}){let e=n.paths??q(),s=ug(import.meta.url),o=n.sourceDist??s?.dist,a=n.sourcePackageJson??s?.pkgJson;if(!o||!a)return{kind:"dev-mode-skip",reason:"running from src/(tsx loader);no dist/ to install"};let x;try{x=JSON.parse(await Fi(a,"utf8")).version??"unknown"}catch(w){return Ac.warn("cannot read source package.json,skip dist install",{err:String(w)}),{kind:"dev-mode-skip",reason:`package.json read failed: ${String(w)}`}}let u=await ct(e.configFile)??{},f=u.libVersion;if(f===x)try{return await Fi(e.libEntry),{kind:"already-current",libVersion:x}}catch{}await ag(e.libDir,{recursive:!0}),await Ec(o,e.libEntry),await Ec(`${o}.map`,`${e.libEntry}.map`).catch(()=>{});let g=Ui(e.libDir,"package.json"),p=`${JSON.stringify({type:"module"},null,2)}
128
+ `;return await Fi(g,"utf8").catch(()=>null)!==p&&await cg(g,p),u.libVersion=x,await Fe(u,e.configFile),Ac.info("dist installed",{libEntry:e.libEntry,fromVersion:f,toVersion:x}),f?{kind:"version-changed",fromVersion:f,toVersion:x,libEntry:e.libEntry}:{kind:"first-install",libVersion:x,libEntry:e.libEntry}}Pr();ie();import{basename as fg,resolve as lg}from"node:path";var gg=9e4,hg={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 pg(n){return hg[n]??1}async function Cc(n,e={}){let s=e.paths??q();if(!n.agentId||!n.sessionId)return process.stderr.write(`Error: missing --agent-id and/or --session-id. These IDs come from the <coze-context> block injected at the top of each prompt \u2014 extract agentId and sessionId from there and pass them as flags. Example: coze-bridge send image x.png --agent-id <id> --session-id <id>
129
+ `),4;let o=await Ir(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 a={agentId:n.agentId,sessionId:n.sessionId,kind:n.kind,path:lg(process.cwd(),n.path),...n.caption?{caption:n.caption}:{},...n.name?{name:n.name}:{}},x;try{x=await mg(o,"/agent/send",a,gg)}catch(u){return process.stderr.write(`Error: daemon IPC failed: ${u instanceof Error?u.message:String(u)}
131
+ `),4}if(!x.ok)return process.stderr.write(`Error: ${x.code}: ${x.message}
132
+ `),pg(x.code);if(n.json)process.stdout.write(`${JSON.stringify(x)}
133
+ `);else{let u=n.name??fg(a.path);process.stdout.write(`Sent ${n.kind} ${u} (${wg(x.bytes)})
134
+ `)}return 0}async function mg(n,e,s,o){let a=new AbortController,x=setTimeout(()=>a.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:a.signal}),f=await u.text(),g=f?JSON.parse(f):null;return g&&typeof g=="object"&&"ok"in g?g:{ok:!1,code:"BRIDGE_INTERNAL",message:`unexpected daemon response (status=${u.status}): ${f.slice(0,200)}`}}finally{clearTimeout(x)}}function wg(n){return n<1024?`${n}B`:n<1024*1024?`${(n/1024).toFixed(1)}KB`:`${(n/1024/1024).toFixed(1)}MB`}var zc=D("cli");function pe(n,e){let s=[],o;for(let a=0;a<n.length;a++){let x=n[a];if(x===e){o=n[a+1],a+=1;continue}if(x.startsWith(`${e}=`)){o=x.slice(e.length+1);continue}s.push(x)}return{value:o,rest:s}}function $g(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(oe=>oe!=="--upgrade-helper"),{value:H,rest:X}=pe(P,"--target-version"),{value:K}=pe(X,"--old-pid"),J=K?Number.parseInt(K,10):Number.NaN;return!H||!Number.isFinite(J)?{mode:"help"}:{mode:"upgrade-helper",targetVersion:H,oldPid:J}}if(e[0]==="send")return Jg(e.slice(1));if(e[0]==="connect")return Vg(e.slice(1));if(e.includes("--help")||e.includes("-h")||e.length===0)return{mode:"help"};let s=e,{value:o,rest:a}=pe(s,"--pat-token");s=a;let{value:x,rest:u}=pe(s,"--pair-code");s=u;let{value:f,rest:g}=pe(s,"--env");s=g;let{value:p,rest:_}=pe(s,"--handshake-url");s=_;let{value:w,rest:E}=pe(s,"--frontier-url");s=E;let{value:T}=pe(s,"--agent-id");if(!o||!x)return{mode:"help"};let k={mode:"pair",privatecode:o,pairingCode:x};return f&&(k.env=f),p&&(k.handshakeUrl=p),w&&(k.frontierUrl=w),T&&(k.agentId=T),k}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:a,rest:x}=pe(o,"--caption");o=x;let{value:u,rest:f}=pe(o,"--name");o=f;let{value:g,rest:p}=pe(o,"--agent-id");o=p;let{value:_,rest:w}=pe(o,"--session-id");o=w;let E=o.includes("--json"),T={mode:"send",kind:e,path:s,json:E};return a&&(T.caption=a),u&&(T.name=u),g&&(T.agentId=g),_&&(T.sessionId=_),T}function Vg(n){let e=n,{value:s,rest:o}=pe(e,"--pat-token");e=o;let{value:a,rest:x}=pe(e,"--env");e=x;let{value:u,rest:f}=pe(e,"--handshake-url");e=f;let{value:g}=pe(e,"--frontier-url"),p={mode:"connect"};return s&&(p.privatecode=s),a&&(p.env=a),u&&(p.handshakeUrl=u),g&&(p.frontierUrl=g),p}var Yg=`
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 Nc(n=process.argv,e={}){let s=Gg(n);switch(s.mode){case"help":return process.stdout.write($g),0;case"version":return process.stdout.write(`${rt}
179
- `),0;case"daemon":{try{await wc()}catch(o){return Oc.error("daemon start failed",{err:String(o)}),1}return new Promise(()=>{})}case"status":return Vg(e);case"stop":return Yg(e);case"refresh":return Xg(e);case"uninstall":return Qg(e);case"install-service":return Zg();case"pair":{let o={};return s.env&&(o.env=s.env),s.handshakeUrl&&(o.handshakeUrl=s.handshakeUrl),s.frontierUrl&&(o.frontierUrl=s.frontierUrl),eh(s.privatecode,s.pairingCode,e,o,s.agentId)}case"connect":{let o={};return s.env&&(o.env=s.env),s.handshakeUrl&&(o.handshakeUrl=s.handshakeUrl),s.frontierUrl&&(o.frontierUrl=s.frontierUrl),th(s.privatecode,e,o)}case"upgrade-helper":{let{runUpgradeHelper:o}=await Promise.resolve().then(()=>(Pc(),Cc));return await o({targetVersion:s.targetVersion,oldPid:s.oldPid,...e.paths?{paths:e.paths}:{}})}case"send":return vc({kind:s.kind,path:s.path,...s.agentId?{agentId:s.agentId}:{},...s.sessionId?{sessionId:s.sessionId}:{},...s.caption?{caption:s.caption}:{},...s.name?{name:s.name}:{},json:s.json},e)}}async function Mc(n){let{unlink:e}=await import("node:fs/promises");await Promise.all([e(n.pidFile).catch(()=>{}),e(n.portFile).catch(()=>{}),e(n.tokenFile).catch(()=>{})])}async function Vg(n){let e=n.paths??q(),s=new Le(e),o=await s.probe();if(o.kind==="not-running")return process.stdout.write(`coze-bridge: not running
180
- `),1;if(o.kind==="stale")return await Mc(e),process.stdout.write(`coze-bridge: not running (cleaned stale state)
181
- `),1;let c=await s.request({method:"GET",path:"/status"});return process.stdout.write(`coze-bridge: running
182
- ${JSON.stringify(c.body,null,2)}
183
- `),0}async function Yg(n){let e=n.paths??q(),s=new Le(e),o=await s.probe();if(o.kind==="not-running")return process.stdout.write(`coze-bridge: not running
184
- `),0;if(o.kind==="stale")return await Mc(e),process.stdout.write(`coze-bridge: not running (cleaned stale state)
178
+ `.trimStart();async function Fc(n=process.argv,e={}){let s=$g(n);switch(s.mode){case"help":return process.stdout.write(Yg),0;case"version":return process.stdout.write(`${it}
179
+ `),0;case"daemon":{try{await vc()}catch(o){return zc.error("daemon start failed",{err:String(o)}),1}return new Promise(()=>{})}case"status":return Xg(e);case"stop":return Qg(e);case"refresh":return Zg(e);case"uninstall":return eh(e);case"install-service":return th();case"pair":{let o={};return s.env&&(o.env=s.env),s.handshakeUrl&&(o.handshakeUrl=s.handshakeUrl),s.frontierUrl&&(o.frontierUrl=s.frontierUrl),nh(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),rh(s.privatecode,e,o)}case"upgrade-helper":{let{runUpgradeHelper:o}=await Promise.resolve().then(()=>(Rc(),Dc));return await o({targetVersion:s.targetVersion,oldPid:s.oldPid,...e.paths?{paths:e.paths}:{}})}case"send":return Cc({kind:s.kind,path:s.path,...s.agentId?{agentId:s.agentId}:{},...s.sessionId?{sessionId:s.sessionId}:{},...s.caption?{caption:s.caption}:{},...s.name?{name:s.name}:{},json:s.json},e)}}async function Uc(n){let{unlink:e}=await import("node:fs/promises");await Promise.all([e(n.pidFile).catch(()=>{}),e(n.portFile).catch(()=>{}),e(n.tokenFile).catch(()=>{})])}async function Xg(n){let e=n.paths??q(),s=new Oe(e),o=await s.probe();if(o.kind==="not-running")return process.stdout.write(`coze-bridge: not running
180
+ `),1;if(o.kind==="stale")return await Uc(e),process.stdout.write(`coze-bridge: not running (cleaned stale state)
181
+ `),1;let a=await s.request({method:"GET",path:"/status"});return process.stdout.write(`coze-bridge: running
182
+ ${JSON.stringify(a.body,null,2)}
183
+ `),0}async function Qg(n){let e=n.paths??q(),s=new Oe(e),o=await s.probe();if(o.kind==="not-running")return process.stdout.write(`coze-bridge: not running
184
+ `),0;if(o.kind==="stale")return await Uc(e),process.stdout.write(`coze-bridge: not running (cleaned stale state)
185
185
  `),0;try{return await s.request({method:"POST",path:"/shutdown"}),process.stdout.write(`coze-bridge: stopped
186
- `),0}catch(c){return process.stdout.write(`coze-bridge: stop failed: ${String(c)}
187
- `),1}}async function Xg(n){let e=new Le(n.paths);if((await e.probe()).kind==="not-running")return process.stdout.write(`coze-bridge: not running (start daemon first)
186
+ `),0}catch(a){return process.stdout.write(`coze-bridge: stop failed: ${String(a)}
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 Le(n.paths);if((await e.probe()).kind==="connected"){process.stdout.write(`coze-bridge: stopping daemon...
193
- `);try{await e.request({method:"POST",path:"/shutdown"})}catch(d){process.stderr.write(`coze-bridge: stop failed (continuing): ${String(d)}
194
- `)}await new Promise(d=>setTimeout(d,500))}if(!n.skipSupervisor)try{let{getSupervisor:d,buildContext:u}=await Promise.resolve().then(()=>(Wi(),Gi)),l=d();await l.uninstall(u()),process.stdout.write(`coze-bridge: ${l.platform} supervisor unregistered
195
- `)}catch(d){process.stderr.write(`coze-bridge: supervisor uninstall failed (continuing): ${String(d)}
196
- `)}let o=n.paths??q(),{rm:c}=await import("node:fs/promises");try{await c(o.cozeRoot,{recursive:!0,force:!0}),process.stdout.write(`coze-bridge: removed ${o.cozeRoot}
197
- `)}catch(d){return process.stderr.write(`coze-bridge: remove failed: ${String(d)}
192
+ `),1}}async function eh(n){let e=new Oe(n.paths);if((await e.probe()).kind==="connected"){process.stdout.write(`coze-bridge: stopping daemon...
193
+ `);try{await e.request({method:"POST",path:"/shutdown"})}catch(x){process.stderr.write(`coze-bridge: stop failed (continuing): ${String(x)}
194
+ `)}await new Promise(x=>setTimeout(x,500))}if(!n.skipSupervisor)try{let{getSupervisor:x,buildContext:u}=await Promise.resolve().then(()=>(Yi(),Vi)),f=x();await f.uninstall(u()),process.stdout.write(`coze-bridge: ${f.platform} supervisor unregistered
195
+ `)}catch(x){process.stderr.write(`coze-bridge: supervisor uninstall failed (continuing): ${String(x)}
196
+ `)}let o=n.paths??q(),{rm:a}=await import("node:fs/promises");try{await a(o.cozeRoot,{recursive:!0,force:!0}),process.stdout.write(`coze-bridge: removed ${o.cozeRoot}
197
+ `)}catch(x){return process.stderr.write(`coze-bridge: remove failed: ${String(x)}
198
198
  `),1}return process.stdout.write(`coze-bridge: uninstalled
199
- `),0}async function Zg(){try{let{getSupervisor:n,buildContext:e}=await Promise.resolve().then(()=>(Wi(),Gi)),s=n(),o=e();return process.stdout.write(`coze-bridge: installing ${s.platform} supervisor...
199
+ `),0}async function th(){try{let{getSupervisor:n,buildContext:e}=await Promise.resolve().then(()=>(Yi(),Vi)),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 eh(n,e,s,o={},c){let d=new Le(s.paths),u=s.spawnDaemon??pn;if(!s.skipDistInstall){let m=await Bi({paths:s.paths});m.kind==="version-changed"?(process.stdout.write(`coze-bridge: upgraded ${m.fromVersion} \u2192 ${m.toVersion}
203
- `),(await d.probe()).kind==="connected"&&(await d.request({method:"POST",path:"/shutdown"}).catch(()=>{}),await new Promise(y=>setTimeout(y,500)))):m.kind==="first-install"&&process.stdout.write(`coze-bridge: installed ${m.libVersion}
204
- `)}let l=await d.probe();if(l.kind!=="connected"&&(process.stdout.write(`coze-bridge: starting daemon...
205
- `),await u({paths:s.paths}),l=await Bc(d,s.waitTimeoutMs??1e4,s.sleep??zc),l.kind!=="connected"))return process.stderr.write(`coze-bridge: daemon did not come up: ${l.kind}
206
- `),1;let p={privatecode:n,pairing_code:e};o.env&&(p.env=o.env),o.handshakeUrl&&(p.handshake_url=o.handshakeUrl),o.frontierUrl&&(p.frontier_url=o.frontierUrl),c&&(p.agent_id=c);try{let m=await d.request({method:"POST",path:"/pair",body:p,timeoutMs:35e3});return m.status===200&&m.body?.ok?(process.stdout.write(`coze-bridge: paired (${m.body.note??"ok"})
207
- `),0):(process.stderr.write(`coze-bridge: pair failed: ${JSON.stringify(m.body)}
208
- `),1)}catch(m){return process.stderr.write(`coze-bridge: pair failed: ${String(m)}
209
- `),1}}async function th(n,e,s={}){let o=e.paths??q(),c=n??await dc(o);if(!c)return process.stderr.write("coze-bridge: \u627E\u4E0D\u5230 patToken \u2014 \u5148\u8DD1\u4E00\u6B21 `coze-bridge --pat-token=<sat_xxx> --pair-code=<xxx>` \u914D\u5BF9, \u6216\u672C\u6B21\u7528 `--pat-token` \u6307\u5B9A\n"),1;let d=new Le(e.paths),u=e.spawnDaemon??pn;if(!e.skipDistInstall){let m=await Bi({paths:e.paths});m.kind==="version-changed"?(process.stdout.write(`coze-bridge: upgraded ${m.fromVersion} \u2192 ${m.toVersion}
210
- `),(await d.probe()).kind==="connected"&&(await d.request({method:"POST",path:"/shutdown"}).catch(()=>{}),await new Promise(y=>setTimeout(y,500)))):m.kind==="first-install"&&process.stdout.write(`coze-bridge: installed ${m.libVersion}
211
- `)}let l=await d.probe();if(l.kind!=="connected"&&(process.stdout.write(`coze-bridge: starting daemon...
212
- `),await u({paths:e.paths}),l=await Bc(d,e.waitTimeoutMs??1e4,e.sleep??zc),l.kind!=="connected"))return process.stderr.write(`coze-bridge: daemon did not come up: ${l.kind}
213
- `),1;let p={privatecode:c};s.env&&(p.env=s.env),s.handshakeUrl&&(p.handshake_url=s.handshakeUrl),s.frontierUrl&&(p.frontier_url=s.frontierUrl);try{let m=await d.request({method:"POST",path:"/connect",body:p,timeoutMs:35e3});return m.status===200&&m.body?.ok?(process.stdout.write(`coze-bridge: connected (${m.body.note??"ok"})
214
- `),await hn(c,o).catch(_=>Oc.warn("writePatToken after connect failed (ignored)",{err:String(_)})),0):(process.stderr.write(`coze-bridge: connect failed: ${JSON.stringify(m.body)}
215
- `),1)}catch(m){return process.stderr.write(`coze-bridge: connect failed: ${String(m)}
216
- `),1}}async function Bc(n,e,s){let o=Date.now()+e;for(;Date.now()<o;){let c=await n.probe(500);if(c.kind==="connected")return c;await s(200)}return n.probe(500)}function zc(n){return new Promise(e=>setTimeout(e,n))}Nc(process.argv).then(n=>process.exit(n),n=>{process.stderr.write(`fatal: ${n instanceof Error?n.stack??n.message:String(n)}
202
+ `),1}}async function nh(n,e,s,o={},a){let x=new Oe(s.paths),u=s.spawnDaemon??yn;if(!s.skipDistInstall){let p=await qi({paths:s.paths});p.kind==="version-changed"?(process.stdout.write(`coze-bridge: upgraded ${p.fromVersion} \u2192 ${p.toVersion}
203
+ `),(await x.probe()).kind==="connected"&&(await x.request({method:"POST",path:"/shutdown"}).catch(()=>{}),await new Promise(w=>setTimeout(w,500)))):p.kind==="first-install"&&process.stdout.write(`coze-bridge: installed ${p.libVersion}
204
+ `)}let f=await x.probe();if(f.kind!=="connected"&&(process.stdout.write(`coze-bridge: starting daemon...
205
+ `),await u({paths:s.paths}),f=await qc(x,s.waitTimeoutMs??1e4,s.sleep??Hc),f.kind!=="connected"))return process.stderr.write(`coze-bridge: daemon did not come up: ${f.kind}
206
+ `),1;let g={privatecode:n,pairing_code:e};o.env&&(g.env=o.env),o.handshakeUrl&&(g.handshake_url=o.handshakeUrl),o.frontierUrl&&(g.frontier_url=o.frontierUrl),a&&(g.agent_id=a);try{let p=await x.request({method:"POST",path:"/pair",body:g,timeoutMs:35e3});return p.status===200&&p.body?.ok?(process.stdout.write(`coze-bridge: paired (${p.body.note??"ok"})
207
+ `),0):(process.stderr.write(`coze-bridge: pair failed: ${JSON.stringify(p.body)}
208
+ `),1)}catch(p){return process.stderr.write(`coze-bridge: pair failed: ${String(p)}
209
+ `),1}}async function rh(n,e,s={}){let o=e.paths??q(),a=n??await gc(o);if(!a)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 x=new Oe(e.paths),u=e.spawnDaemon??yn;if(!e.skipDistInstall){let p=await qi({paths:e.paths});p.kind==="version-changed"?(process.stdout.write(`coze-bridge: upgraded ${p.fromVersion} \u2192 ${p.toVersion}
210
+ `),(await x.probe()).kind==="connected"&&(await x.request({method:"POST",path:"/shutdown"}).catch(()=>{}),await new Promise(w=>setTimeout(w,500)))):p.kind==="first-install"&&process.stdout.write(`coze-bridge: installed ${p.libVersion}
211
+ `)}let f=await x.probe();if(f.kind!=="connected"&&(process.stdout.write(`coze-bridge: starting daemon...
212
+ `),await u({paths:e.paths}),f=await qc(x,e.waitTimeoutMs??1e4,e.sleep??Hc),f.kind!=="connected"))return process.stderr.write(`coze-bridge: daemon did not come up: ${f.kind}
213
+ `),1;let g={privatecode:a};s.env&&(g.env=s.env),s.handshakeUrl&&(g.handshake_url=s.handshakeUrl),s.frontierUrl&&(g.frontier_url=s.frontierUrl);try{let p=await x.request({method:"POST",path:"/connect",body:g,timeoutMs:35e3});return p.status===200&&p.body?.ok?(process.stdout.write(`coze-bridge: connected (${p.body.note??"ok"})
214
+ `),await _n(a,o).catch(_=>zc.warn("writePatToken after connect failed (ignored)",{err:String(_)})),0):(process.stderr.write(`coze-bridge: connect failed: ${JSON.stringify(p.body)}
215
+ `),1)}catch(p){return process.stderr.write(`coze-bridge: connect failed: ${String(p)}
216
+ `),1}}async function qc(n,e,s){let o=Date.now()+e;for(;Date.now()<o;){let a=await n.probe(500);if(a.kind==="connected")return a;await s(200)}return n.probe(500)}function Hc(n){return new Promise(e=>setTimeout(e,n))}Fc(process.argv).then(n=>process.exit(n),n=>{process.stderr.write(`fatal: ${n instanceof Error?n.stack??n.message:String(n)}
217
217
  `),process.exit(1)});