coze-bridge 0.1.67 → 0.1.69

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 +3 -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 j0=Object.create;var Wr=Object.defineProperty;var H0=Object.getOwnPropertyDescriptor;var K0=Object.getOwnPropertyNames;var W0=Object.getPrototypeOf,$0=Object.prototype.hasOwnProperty;var ne=(n=>typeof require<"u"?require:typeof Proxy<"u"?new Proxy(n,{get:(e,s)=>(typeof require<"u"?require:e)[s]}):n)(function(n){if(typeof require<"u")return require.apply(this,arguments);throw Error('Dynamic require of "'+n+'" is not supported')});var Te=(n,e)=>()=>(n&&(e=n(n=0)),e);var ve=(n,e)=>()=>(e||n((e={exports:{}}).exports,e),e.exports),$r=(n,e)=>{for(var s in e)Wr(n,s,{get:e[s],enumerable:!0})},J0=(n,e,s,o)=>{if(e&&typeof e=="object"||typeof e=="function")for(let a of K0(e))!$0.call(n,a)&&a!==s&&Wr(n,a,{get:()=>e[a],enumerable:!(o=H0(e,a))||o.enumerable});return n};var We=(n,e,s)=>(s=n!=null?j0(W0(n)):{},J0(e||!n||!n.__esModule?Wr(s,"default",{value:n,enumerable:!0}):s,n));function ys(n){return vn[ws]<=vn[n]}function Sn(n){_s={...n}}function Y0(n){let e=(f,p=2)=>String(f).padStart(p,"0"),s=-n.getTimezoneOffset(),o=s>=0?"+":"-",a=Math.abs(s),d=e(Math.floor(a/60)),u=e(a%60);return`${n.getFullYear()}-${e(n.getMonth()+1)}-${e(n.getDate())}T${e(n.getHours())}:${e(n.getMinutes())}:${e(n.getSeconds())}.${e(n.getMilliseconds(),3)}${o}${d}:${u}`}function bn(n,e,s,o){if(vn[n]<vn[ws])return;let a=JSON.stringify({ts:Y0(new Date),level:n,module:e,msg:s,..._s,...o});n==="error"||n==="warn"?X0.write(`${a}
9
- `):V0.write(`${a}
10
- `)}function D(n){return{debug:(e,s)=>bn("debug",n,e,s),info:(e,s)=>bn("info",n,e,s),warn:(e,s)=>bn("warn",n,e,s),error:(e,s)=>bn("error",n,e,s),child:e=>D(`${n}.${e}`)}}var vn,ws,V0,X0,_s,q=Te(()=>{"use strict";vn={debug:10,info:20,warn:30,error:40},ws=(()=>{let n=process.env.COZE_BRIDGE_LOG_LEVEL;return n==="debug"||n==="info"||n==="warn"||n==="error"?n:"info"})(),V0=process.stdout,X0=process.stderr,_s={}});import{chmod as ux,mkdir as fx,readFile as lx,rename as Is,writeFile as Ts}from"node:fs/promises";import{dirname as gx}from"node:path";async function Pt(n){try{let e=await lx(n,"utf8");return JSON.parse(e)}catch(e){if(e.code==="ENOENT")return null;throw e}}async function Tn(n,e,s){await fx(gx(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 Ts(a,o,{encoding:"utf8",mode:s.mode}):await Ts(a,o,"utf8"),await Is(a,n),s?.mode!==void 0&&await ux(n,s.mode)}catch(d){await Is(a,a).catch(()=>{});let{rm:u}=await import("node:fs/promises");throw await u(a,{force:!0}).catch(()=>{}),d}}var Pn=Te(()=>{"use strict"});import{promises as Ps}from"node:fs";import{homedir as px}from"node:os";import{sep as hx,join as ue,resolve as Cs}from"node:path";function G(n){let e=n??px(),s=ue(e,".coze"),o=ue(s,"bridge"),a=ue(o,"lib");return{cozeRoot:s,bridgeRoot:o,libDir:a,libEntry:ue(a,"index.js"),binDir:ue(o,"bin"),pidFile:ue(o,"bridge.pid"),portFile:ue(o,"bridge.port"),tokenFile:ue(o,"bridge.token"),patTokenFile:ue(o,"pat-token"),logFile:ue(o,"bridge.log"),installLock:ue(o,"install.lock"),configFile:ue(o,"config.json"),agentsRoot:ue(s,"agents")}}function $e(n,e=G()){let s=ue(e.agentsRoot,n);return{root:s,config:ue(s,"config.json"),workspace:ue(s,"workspace"),logs:ue(s,"logs")}}async function ks(n,e){let s=await Ps.realpath(Cs(n)).catch(()=>null);if(!s)return!1;let o=await Ps.realpath(Cs(e)).catch(()=>null);if(!o)return!1;let a=process.platform==="win32"?s.toLowerCase():s,d=process.platform==="win32"?o.toLowerCase():o;return a===d||a.startsWith(d+hx)}var oe=Te(()=>{"use strict"});var Dn={};$r(Dn,{AGENT_CONFIG_FILE_MODE:()=>Cn,enforceAgentConfigMode:()=>yx,loadAgentConfig:()=>he,persistAgentSessions:()=>Jr,persistAgentSkills:()=>kn,saveAgentConfig:()=>Se});import{chmod as mx,stat as _x}from"node:fs/promises";function he(n,e){return Pt($e(n,e).config)}function Se(n,e){return Tn($e(n.agentId,e).config,n,{mode:Cn})}async function yx(n,e){if(process.platform==="win32")return;let s=$e(n,e).config;try{let o=await _x(s);if(!o.isFile())return;let a=o.mode&511;a!==Cn&&(await mx(s,Cn),Ds.warn("agent config mode auto-corrected to 0600",{path:s,from:a.toString(8)}))}catch(o){if(o.code==="ENOENT")return;Ds.warn("enforceAgentConfigMode: chmod failed (ignored)",{path:s,err:String(o)})}}async function Jr(n,e,s){let o=await he(n,s);o&&(o.sessions=Object.fromEntries(e),await Se(o,s))}async function kn(n,e,s){let o=await he(n,s);o&&(o.skills=e,await Se(o,s))}var Ds,Cn,it=Te(()=>{"use strict";Pn();q();oe();Ds=D("agent-config"),Cn=384});function Lo(n){let e=n?.sessionIdleTimeoutMs;return typeof e!="number"||!Number.isFinite(e)||e<=0?au:e}function ct(n){return Pt(n??G().configFile)}function Ue(n,e){return Tn(e??G().configFile,n)}var au,Bt=Te(()=>{"use strict";Pn();oe();au=10*6e4});var ca=ve(Y=>{"use strict";var C=M;(function(n,e){let s=M,o=n();for(;;)try{if(-parseInt(s(1680))/1+parseInt(s(1948))/2*(-parseInt(s(795))/3)+-parseInt(s(560))/4+-parseInt(s(1540))/5*(-parseInt(s(1588))/6)+parseInt(s(1125))/7*(parseInt(s(591))/8)+-parseInt(s(1885))/9*(parseInt(s(1707))/10)+-parseInt(s(1917))/11*(-parseInt(s(1178))/12)===e)break;o.push(o.shift())}catch{o.push(o.shift())}})(nr,470065);var af=Object[C(1990)+C(1891)],cf=Object["getOwnPropertyNa"+C(1933)],ra=(n,e)=>function(){return n&&(e=(0,n[{lNEaA:function(d,u){return d(u)}}[C(1301)](cf,n)[0]])(n=0)),e},xf=(n,e)=>{for(var s in e)af(n,s,{get:e[s],enumerable:!0})};function df(){return Zo||(Zo=[IDBDatabase,IDBObjectStore,IDBIndex,IDBCursor,IDBTransaction])}function uf(){let n=C;return Qo||(Qo=[IDBCursor.prototype[n(1740)],IDBCursor[n(575)+"e"][n(740)],IDBCursor[n(575)+"e"]["continue"+n(798)+"ey"]])}function ff(n){let e=C,s={lgGxz:e(1761),YgLbF:function(a,d){return a&d},suDMT:function(a,d){return a>>>d},OeKVr:e(1242),zkdhy:function(a,d){return a(d)},RNofF:function(a){return a()},YtuZN:function(a,d){return a instanceof d},ukVhZ:e(1011)+e(824),JbqWA:e(1650),OUgOL:"none_none",Iywst:"binary",pKaEt:function(a,d){return a===d},LjiMT:"error",fQCQi:"setdb",YAKfA:e(466),uoTqY:e(1241)},o=new Promise((a,d)=>{let u=e,f={WYzDp:function(p,h){return s.YtuZN(p,h)},CGhvr:function(p,h){return p instanceof h},HiJrq:s[u(626)],HKVqp:u(1011)+"ion/json"+u(1490)+u(1615),vKgPu:s[u(584)],elAJm:s.OUgOL,wlXVw:s.Iywst,LqyXC:function(p,h,y,w){return p(h,y,w)},ZlokJ:function(p,h){return s[u(1297)](p,h)},UmDvn:function(p){return s[u(736)](p)}};if(s.pKaEt("dBOvp","GRhQQ"))if(f[u(1687)](_0x754c43[u(426)],_0x1df3e3)){let p=f[u(868)](this[u(918)][u(712)+u(1258)],_0x28f56f)?{force:!!this[u(918)][u(712)+"ncoding"][u(1708)],encoding:this[u(918)][u(712)+u(1258)][u(1830)]?this[u(918)]["payloadE"+u(1258)][u(1830)].replace(/\s/g,"")[u(944)+u(421)]():""}:{force:!1,encoding:this[u(918)][u(712)+u(1258)]?this[u(918)][u(712)+u(1258)][u(430)](/\s/g,"")[u(944)+u(421)]():""},h=_0x10de94[u(712)+u(1258)]?_0x37f38c[u(712)+u(1258)][u(430)](/\s/g,"")[u(944)+u(421)]():"",y=this[u(918)][u(1994)+u(875)]instanceof _0x282d43?{force:!!this[u(918)][u(1994)+u(875)][u(1708)],type:this[u(918)][u(1994)+"ype"][u(773)]?this[u(918)][u(1994)+u(875)][u(773)][u(430)](/\s/g,"")[u(944)+u(421)]():""}:{force:!1,type:this[u(918)][u(1994)+u(875)]?this[u(918)][u(1994)+u(875)].replace(/\s/g,"")[u(944)+u(421)]():""},w=_0x298694[u(1994)+u(875)]?_0x2ef0b6[u(1994)+"ype"][u(430)](/\s/g,"")[u(944)+u(421)]():"",A=y.force?y.type:w||y[u(773)],I=p[u(1708)]?p.encoding:h||p.encoding,E=[u(1627)+u(820)+u(1182),f[u(711)],f[u(777)],f[u(984)]],k=[f[u(1344)],f[u(1338)]];this[u(918)][u(1532)+u(1929)+"extPayload"]&&E[u(1610)](A)&&(!I||k[u(1610)](I))?_0x358a98[u(439)+u(1946)]=f.LqyXC(_0x5333f8,_0x509250[u(426)],0,_0x508270[u(426)][u(823)+"th"]):_0x6332e6["textPayl"+u(1946)]=""}else _0x36a9c2[u(439)+"oad"]="";else{let p=()=>{let w=u;n[w(1210)+w(607)+w(622)](s[w(973)],h),n[w(1210)+"entListe"+w(622)](w(654),y)},h=()=>{let w=u,A={xkFxe:function(I,E){return I>>>E},XbFTt:function(I,E){return s[M(1067)](I,E)},rfGBr:function(I,E){return s[M(1067)](I,E)},VZJNM:function(I,E){return s.suDMT(I,E)}};if(w(1242)===s.OeKVr)a(s.zkdhy(Ge,n.result)),s.RNofF(p);else{let I=this[w(1244)],E=this.low;return[A[w(842)](I,24),A[w(1747)](A[w(842)](I,16),255),A[w(1637)](I>>>8,255),A[w(1747)](255,I),A[w(842)](E,24),A[w(1747)](E>>>16,255),A[w(425)](E,8)&255,255&E]}},y=()=>{let w=u;f[w(1828)](d,n.error),f[w(526)](p)};n[u(1614)+"Listener"](s[u(973)],h),n["addEvent"+u(1955)](s[u(1060)],y)}});return o[e(498)](a=>{let d=e,u={vzatH:s[d(810)]};if(s[d(1555)](a,IDBCursor)){if(s[d(729)](s[d(1734)],s[d(1543)]))return _0x545bf5[d(881)](u[d(1013)],_0x444a9b,_0x1c7e87,_0x9ab2bb),this[d(718)].set({cursor_name:_0x54ae94,cursor:_0x1930f8,service:_0x248e85});li.set(a,n)}})[e(1538)](()=>{}),ir[e(1593)](o,n),o}function lf(n){let e=C,s={rWXZH:function(a){return a()},KPzKh:function(a,d){return a(d)},hDnYa:e(533)+"or",GMlsK:e(654),UeBuJ:e(1080),ecpYq:e(1938)};if(rr.has(n))return;let o=new Promise((a,d)=>{let u=e,f={rPmET:s[u(1693)],Yddpr:s[u(1721)]},p=()=>{let w=u;n[w(1210)+"entListener"](w(1938),h),n[w(1210)+w(607)+w(622)](f.rPmET,y),n[w(1210)+w(607)+w(622)](f.Yddpr,y)},h=()=>{s[u(523)](a),s.rWXZH(p)},y=()=>{let w=u;s[w(894)](d,n[w(654)]||new DOMException(s[w(485)],"AbortError")),p()};n[u(1614)+u(1955)](s[u(1091)],h),n[u(1614)+u(1955)](s[u(1693)],y),n["addEvent"+u(1955)](s[u(1721)],y)});rr[e(1593)](n,o)}function M(n,e){n=n-408;let s=nr(),o=s[n];if(M.OQlgsg===void 0){var a=function(p){let h="abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789+/=",y="",w="";for(let A=0,I,E,k=0;E=p.charAt(k++);~E&&(I=A%4?I*64+E:E,A++%4)?y+=String.fromCharCode(255&I>>(-2*A&6)):0)E=h.indexOf(E);for(let A=0,I=y.length;A<I;A++)w+="%"+("00"+y.charCodeAt(A).toString(16)).slice(-2);return decodeURIComponent(w)};M.QwCeWp=a,M.oQlVAY={},M.OQlgsg=!0}let d=s[0],u=n+d,f=M.oQlVAY[u];return f?o=f:(o=M.QwCeWp(o),M.oQlVAY[u]=o),o}function gf(n){sr={BCAYy:function(s,o){return s(o)}}.BCAYy(n,sr)}function pf(n){let e=C,s={sqqeX:function(o,a){return o(a)},GbMRB:function(o,a){return o===a},xWXId:function(o){return o()}};return s[e(655)](n,IDBDatabase.prototype[e(1628)+"ion"])&&!("objectSt"+e(1267)in IDBTransaction.prototype)?function(o,...a){let d=e,u=n[d(1352)](s.sqqeX(xn,this),o,...a);return fi.set(u,o[d(1998)]?o[d(1998)]():[o]),s.sqqeX(Ge,u)}:s.xWXId(uf)[e(1610)](n)?function(...o){let a=e;return n[a(1714)](s[a(1279)](xn,this),o),Ge(li[a(791)](this))}:function(...o){let a=e;return Ge(n[a(1714)](s[a(1279)](xn,this),o))}}function nr(){let n=["zNDZxZeUmc4","BKjlDxC","B0XxzKq","qNjOsve","DMLJzuLeig8","B25tDg9Wsw0","nNWXmhW0","DNz3wvu","EgTrEfC","wfH0DwK","uvLfsNi","AvvzB3G","uwjvuwu","vLDmzhm","D2vsDM4","x29UrxjYB3i","veL1uhC","t3rewKi","BgLUzq","wvD4suS","mJiZmti1DuzMA1Lb","z2vY","x2LZsw5PDa","B2nRzxrgywK","vMfRqNO","x2rPC2nVBM4","rw55CLG","v1L6rha","yur6BMC","B3vnrMy","EwjlB3m","rMP1Dhe","shHxt3q","r01SC0S","vgjUA3e","zw5XDwv1zq","ywrK","vw5Oyw5KBgu","vw9iwe0","uMvHzcbWyxm","Bg93","zw5fDMvUDa","FdH8mxW0","tuDHsuG","Axjgtva","zgvnuMe","x3DZsw5ZDge","mtbluMTbCLe","zM9Yy2u","q1LYufu","zNjVBunOyxi","zu9YCwi","BIWGAg9ZDg4","C3Pvtu8","yxbWBhK","sMHmDhu","AM5jy3m","wLboEwi","q2jwr3i","DgHHBIbSB2m","shbvr1q","vwvcDuO","tLfVCgi","B25szwnLAxy","y2XLyxi","BujMuMG","AKLfy0W","tfPYCKq","vNzkqLu","CMndBMy","sgrpBMm","x2XPC3rLBMu","Ae5brvC","s2P6Age","wuflzKe","zNjVBNrPzxi","rMDtuMm","tvPbDva","y3PbAKe","y29SBM8","ywr2yw5Jzq","A1bfDg4","vxbzAxK","EevdCfu","BefAyMS","yKTrCMi","tKDWChy","wgjgvhq","Awrgr3i","z2j4t2G","x3bYB3rVy28","qxrJAeS","y2HHCKnVzgu","x3bYzwzPEa","ChfizLG","tg9NsurozxC","rvffrgu","x3jLywr5q2W","B2nRzxrtDwm","z3nctwO","B25LCNjVCG","C3vJy2vZCW","Ae9KBu0","zvPKse8","r2TPAgm","CM92AwrLige","thDwshC","zxrxB3jRq2G","CeD2rKe","vhD0t1i","AMvJDfn0B3i","C3bSAxq","m3W1Fdj8mhW","Dg9VigXHCMC","CKXWB20","zNjHBwvuExa","vvn5zKy","DLLhBxm","CMvJB25Uzwm","zuHPA1m","wMjmEuO","y2vZC0HHBMq","zwnVBM5Ly3q","v2vPEgLUsLm","AxnbCNjHEq","Cvr5B0y","z2vjBMzVu3K","Dhviv2y","B1vVtLG","wg5jAhO","CxzoENi","BwLZzq","rMrkCgK","vwvTBKG","DxDmCMy","zwn0","q0Xpu0LorW","qKnQzgm","vuPHBwC","wvvIq2K","B25dBg9Zzq","A09Vrue","qMzWswq","m3WXFdj8nxW","zxHWB3j0CW","BxHAveS","BfzvtvG","z3Ptu3u","DM9ZEhi","yxKSig5LDhC","CYbHBhjLywq","B25QsuK","yxjYyxLIDwy","EK5QtLa","suPcCwi","v3DWzfi","DxrVuMvJB24","A3bWDgm","vw5PBxbSzw0","t1DMqMS","wuDXyvK","AxH6u3C","AevYCM9Yrxy","y2TtufG","A1n0yxr1C0m","uezyte4","BNPXz3m","CM92AwrLihy","wMXVA0O","vfPsr3u","zw5JB2rPBMC","DuPVDM0","qKnVCeO","yxGGCMv0CMK","Euroruu","y29UBMvJDeu","v0rVAva","AxnmB25N","zNjVBuj5Dgu","r01XCfi","Bu1JCeW","y3vYC29Yx2y","mhWZFdr8mxW","uvveyNe","sgTdte0","ChrVCG","t0DIrgy","zhfpvuC","tM9uBw4","mNWXFdb8nhW","C25LBKC","zw5KCg9PBNq","BfvnCKO","B09LwM4","y29UBMvJDgK","D0njtKW","r1rxzNu","DMTVBM0","tw1HvxG","zxjYtM8","CMvHzg9UBhK","AxnYv0q","BgD4zgG","z29PBMCGyxC","y0rIshq","DLzttgG","C3fJqMK","wfrMELO","ihzHBgLKigq","BxvZCxO","Axnby2TdBgu","Dw1ly1O","EeflD0W","y3vYC29Yx24","q09otKvdveK","BKDKruC","tLr4veW","q0rJDxa","wvDACvy","C1rowe0","rxPYD3q","Dw5KzwzPBMu","y2HLy2TdDxi","ihjLy29UBMu","te5kzgW","ntK2nZaYn3LZAuzqwq","tefvr0i","nxWZFdr8mhW","EevusKq","tercvgm","C29Tzq","B3bLCNr5","u2fvAwm","Ewv0CNG","BLfcC0C","B2zM","wKLvCem","DgLLCKPtt04","B05Vtfy","y3jLyxrLt3a","ihrVihjLDhi","rffftvO","y1v0EvO","yMXVy2TLza","Ee9WqKu","twzKugu","Dw5RBM93BIa","x2n1CNnVCKy","B21jtgy","zgf0yq","y2XLyxjtDg8","Dev2qvy","D1riv2S","ALnLsMC","v09MBMW","DMX2C2K","DMvYC2LVBMm","mJG2zvDjCNft","v2fvBfO","CNjVCK1LC3m","zKXsy2G","zMffzva","zhbqBKe","Be1NDKO","ALHuANC","AKX1C04","y2f5rNm","DgLUzYbZzxi","C2vYDMLJzs0","yw5ZzM9YBvq","CMvXDwLYzwq","BxnNsuq","C1rOq0u","BwvZ","DgfIyxnL","yw9TrfG","Dg9cExrLCW","tKXOzhe","y29TCgXLDgu","vgTJD1G","x3bHDgHlzxK","rxzLBNq","x2rPC3bHDgm","wLnjwu4","BhngCuy","sg1uy3y","B2fK","zxjYtxnN","nKTmvhDxtW","A1rVt0S","we94tuC","r0z5shO","x2HHBMrSzva","ELbMzw0","EKLXyM8","tgLZDgvUzxi","DgLTzw91DcW","AfbzA1y","y3vYC29YlNm","uKTND3u","zgv2AwnLx2K","Eg1mufC","x2rYB3bhBg8","BKXHufi","DhzjsNG","Dhr3Awq","B3jpBMXPBMu","t3bgyM8","Aw5KzxG","ywnOzwq","yuTpEvC","CMvZzxrfBMq","wertBxq","tuT4r0u","z2v0qwXSs2u","Dw5ZAwDUzwq","rMTzvg4","t3HdBLe","rxbhyMK","x2LZtwLUAvC","wLvgyMS","t3r3uLy","z1rPBwvVDxq","q251uLe","ANPlqKK","sfbrtu8","ywnRDxbfBMq","whvYv3K","vezPwKi","B3bLBKrc","zgvMAw5Luhi","CgzntLy","wxrKvKG","y3H4CuW","Cgf5Bg9Hzfq","AvDAz3e","qwrkzwG","Ee5Kswi","C29YDa","ENLOvwW","x29UvgLTzw8","BKjczue","q2XIqKS","DeLK","C2LnvKy","v0DVwgG","DMvUDa","vLfosxK","rez2zee","DcbSAw1PDa","ENjABe8","t2jTD2C","sur5tMS","DhjPBq","AgvKtwf4uMu","B0Plvu4","Ef9MCM9UDgK","zxjFywnRx20","y291BNq","CxzwwKy","yxnL","y29UBMvJDfm","x29Uq2XVC2u","C0Ddsfa","vLPktK0","Cgf5Bg9Hza","qMLuqMi","BwvY","qKHSDvm","CMvWBgfJzq","yw1Lu3bHy2u","y0v5uKq","q29NEva","EhPSBha","zxjFDhrS","vvf4uKy","qxnPA1e","sNLdC3m","Dgv4DfbHEwW","shj0r2u","EMPvC0C","uLr5yKy","A25qquy","AwXLtMfTzq","wvf0CNO","EMjlzKy","AvvZsNO","ugvdBgi","ywzL","D2LSBfjLy28","zxf1ywXZ","vwDuzg0","BNrLCG","AwTtuxy","x29Ut3bLBG","z3HWqvm","zgrjrcWGzgu","x3nVy2TLDa","ufnOwKK","su5vrLO","yxDtBwi","z3riAw8","mNW0Fdn8mhW","zMzmAw5L","y3jLyxrLuMu","zfLMA2O","zwvKzwq","q3PHvfu","BgvY","DunIy1O","DNDxBMm","C3rLBMvYCW","CMvZzxrdB3u","z05kCg4","yxrIuMG","CKP2CuG","z2zAC0e","C3rHCNq","x2LZtM9Kzq","ufbwu1a","ELHhtvC","t1vryKq","Egj6Eey","zgvIDwC","AerUwwe","AvL1reO","nNW1FdeWFda","AxPnzgq","rvzUuum","zcbLCNjVCI4","re5fvKO","s0nXshu","vwPIBgm","vgTsrey","AxmGDw5Kzwy","CMfTugfYyw0","DMfS","DgHLBG","y3jLyxrLtwu","Evn1qvK","zw9dz2y","B3ngELO","AxDAqxG","DwPsDhC","Ec1TC2CTy3u","rfn1yLm","wujhEKe","twPHvNa","BgvUz3rO","BMCGzMfPBgu","DevHthG","seHLB28","x19LC01Vzhu","shHvr20","B01stey","tufyx1jfvfi","DcbVzIbYyw4","BwvZC2fNztO","uhnNzvm","tgrHqve","rM5AzxK","tenZC0u","CLDywKG","u3rYyxrLz3K","zw5JB2rLrNi","vw1eDM4","veTtBuC","CgHJrgS","z2v0u3rVCMe","qvjcufa","zezPsgC","A3jtueO","qwjVCNrfCNi","q291BNq","Cw1Hs2W","C2nouhm","A09jDNa","y2XVC2u","x3bPBMC","yNvMzMvY","rgDSCNq","DfjXAKC","D2nmv1y","sevhCeK","sfzKCKe","vu5owK8","mNWX","Cu5SAMG","Bg5LB1q","Exf1q0m","CNrStwy","ihrPBwvVDxq","Aw5PDcbrB1m","BMnLq2XVC2u","zunYwgu","x2fKzfDZtgK","tg9JAW","CeT4A20","C3bSAwnL","mtq2nJC0mgrXC1jysG","yw1LoIa","B0j4DKK","qxzKrMm","DuXdAu8","rffLAhO","x0rctMfTzq","q3voz1i","tuzLs0K","C2vUza","CgXLyxnLiha","Efrurw52","rvHiuvm","AvzgELq","DuLUAwG","ChjVDg90Exa","twPABw0","AM9PBG","Dg9oDw1Izxi","tMPxzuO","A3jRsKK","EMr5vxq","rufOufi","EfjKBKy","sMjXv0e","rvrZtgm","tLb2qLG","wvnwEhO","DNnTsKq","yvPpAfa","zw50","mJK2AKzwELP4","r2TPEfO","CfDAr2G","tgHdD3O","qNrVDwK","D1L0rMu","yw1L","wMz2qwi","seHcCNq","ugjot2y","CgLUz09Uy2u","Bg9Nsurhzw4","Bvjwr0y","vKnkzg8","tgfpCuy","uNbYv2q","zw50tgLZDgu","y29Uy2f0","D2vI","BgLZDgvUtMu","CMTLCKDSB2i","Dg9iyxnO","ufLYDuq","x2LZqNjVD3m","x3bPBMDqB24","rgHYsuq","ywnR","AwvAy0O","BxDWwfm","zv90Aw1LB3u","AfjZuKy","BMvY","ENzVyMK","CMvWBgfJzui","vffoyxm","DwTwAfO","u0ToBu8","rxDwtvO","rvjst1i","qvD6rfy","s1zoruW","rxPcsNC","BMDuAw1LCG","t3bsEvu","EeLpC3q","BurTAuG","y0Pds3C","q3vZDg9Trxi","Effqtui","tenuyu0","AgfMEeq","r2z4thG","AMr4BLi","zujAwuy","qwLgAKW","su9ky0y","ruHhBgW","vufjrue","qK1UzKW","C0zZENu","ihrPBwvZ","C2jIA24","z2v0s2v5","zxjYB3i","r2jnuKi","zw50zwqGDhK","y2uGBM90igK","ywrKt25L","B25TzxnZywC","B2jQzwn0u3q","s0nIrNC","r1H6yKO","uxzYDNa","rKLmrv9ot1q","y2HLy2Tszwe","AKPZrfK","Bg9IywXty28","ywrKq291BNq","CufOvuS","zxmGCMvHy2G","AKLRqvi","mdaWmdaWmda","Eg5NDha","seDlz1m","y0XKwfm","rMvrug8","uuP2vK0","vvnmvhu","rhrYCM8","y09ZCgG","yK1Vzhe","B2zMC2v0","qxzmAfy","r2rtA1u","uxvLDwu","q2nUBNG","x2nSzwfYugK","mtf8mtb8n3W","u25yDe8","rvrwC1K","Efn1uKu","ruHXDfq","Dvrwu3G","u2HHCMvKv28","s05kwKS","B2Hdy04","shreuKy","x1fVu01HBMe","B3bLBG","uKDbyMW","y3jLyxrLq2W","qMvVDuq","AMv6qxO","qNjPzgDL","BMzWwNq","A2fSDuu","B25nzxnZywC","DhDSrKS","zhvWC2O","u0XxENy","sgLkCNe","Cgf5Bg9Hzeu","AK9pCeO","C2vUzf9Hy2S","ChjVDg9JB2W","Bg9NsurozxC","BMrLEa","x3fVC0rc","B3jRig9MzMW","CuHPAe0","Avbxqu8","x2jPBMfYEvq","DfjTAuK","BM5kDLm","AMncALG","tfzeC0S","vvjsChu","CgvYC2LZDgu","CeTHrxq","q3bdDe4","yM9KEq","wwnuALm","sxDzu2G","svjfz0y","AuHtzMe","uK5VzKy","rKDnD0G","v25WBuS","x2TLEvbHDgG","y29UDgLUDwu","ALfXDKq","mdaWma","A1rds2e","t0L3r3u","quXm","CNzHBa","n3WYFdn8oxW","BwfW","suXevLi","Aw5Lza","sfbxEgy","t2Dosfi","CMfTzq","AvDUCxe","ywXSzwqGBxu","shn0vwK","qLLsrLu","BMrWB2LUDfq","r2DmDK0","rw1ktw8","q0HNvgK","ChzWAvi","sNzjA2y","B3vUDa","Du1LA2K","Cfvot1m","y29Kzq","DhDVCMTdAge","zezcqum","wenYq1C","EKPhC1i","wLreugi","DhLWzq","qMzdB3i","DgfYz2v0","yxPZCKO","seTwCxa","u2LbCfm","C0rJvxi","DeLNDum","DLzAu3C","veP6v0W","u1DLEMC","uLbRrgi","u2ruvvK","s3nnsNu","ug9YEve","CMvHzhLtDge","tMXfsvy","A2v5CW","z2v0","vhndA00","D3nPyM8","y1vqzgi","mJa4ode1qvj2AvfU","rLDt","BLzpq2m","uhjPBwfYEuS","B2LUDfjLywm","zNzsweK","sNvNv3C","CM9YrxzLBNq","yNL0zu9MzNm","AenSB3nLrxy","wNbNqw4","C2XPy2u","x21PBMLoyxy","zg9Uzq","qxboBMy","zLfduwK","m3W0Fdf8mNW","A1DSzgO","zcWGDw5RBM8","x2LZtwLUAvq","wLnftem","A1fnqKG","DxbKrM8","CgfRDwC","AxnszwfKEq","Aw47y2HHCNm","we9KqM4","C3nHz2vfDMu","yNL0zuXLBMC","Aw9Ul2PZB24","yMLUyxj5","sefxDNe","uufXEKm","BuTcu20","uvzrwhG","BNbpthy","uxzUrKq","CvHKBwq","ihrYEsbYzwm","D0DuyM8","Aw5KzxHpzG","DNLxCNy","x25HDMLNyxq","BuvWs2W","BNnpAuG","qvvoDeu","sMzgr3y","EgTgEgu","qNzJy3a","z21uyKS","yxbWzw5Kq2G","tLfqrMy","Cg9W","x2HHBMrSzu8","re1uyKK","wefZEva","AwDHDg9Yt24","rfLOrw4","CNnVCKzPBgu","uK1Qu3G","uLjpuG","AgfUz2u","CfjkBeG","C2jPAxu","zgvQDKS","vwnmuw4","v0zIAvm","s3LxEvq","yM9L","A0jfuNC","q0LJwM0","BwvZC2fNzq","DxbNCMfKzw4","q0DODNi","BunWrKm","AwzeCgy","y3vYCMvUDeu","rxndzNm","z0z6sM0","vLz4qKG","ExbL","CMvJzxzPzwq","u2jHwgW","CMfNzvn5BMm","zxjHDg9Y","rgrMtLK","Bg9N","AKXUBeS","zKLMuLi","u2XiDg0","AuDND0i","thjIrgK","ignVzgu6ia","C0jf","swHItKS","Afv0sMW","whz1tw0","v0Plt2G","zMLN","s1b6s2G","nhWW","ze9JsLu","yKfSwuy","Be5oDuW","DvDAufO","y2XVC2veqG","CMDbueu","C2v0sxrLBq","BeXQzMO","AgfZ","BMDssgi","rxjYB3jdB2q","v0Dyue4","y2XVC2uSihC","ywDLrxzLBNq","DeLUDgvYy2u","ug9orNm","x3vYBa","uLnlv0S","zvPsr3i","CLzZsvu","s29zC3u","s2HUyK0","x29WDgLVBNm","wwTXvwG","rNjVBNrPzxi","nhWXFdz8oxW","A1rcDMm","q3zVueG","q0Xpu0ve","tuvUzxm","q1zAB0S","yLz0v3q","uxHVz0i","u21nExm","tw9WD2u","ExrTz3q","ywnRx2nVzgu","EhrcCMq","Dwfouey","yMLUza","BujsCvG","rgHtEhe","Bwf4uMv0CMK","vhjSqva","Aw5N","yMfJA3vWigu","q3P0Axa","D0Tlwgu","Dg9mB3DLCKm","AMPezfq","ChvZAa","r0PMDhe","u1j4D0K","yw9KB1u","Dev2zw50","B25JBg9Zzq","EgLNuKm","CLvgvhG","CgjICdi","ALj0Dgm","BhrPCgXLihq","Eg1VEgO","CMvQzwn0","vK5eu0C","rMfez3e","wvDVCKq","x0vysvnu","CM92AwrLigi","BMvJDa","whbcDw4","C2v0u3rVCMe","sgfmwxK","EuXICwW","vxbKyxrLq28","BM5Ly3q","AgfZt3DUuhi","EfvZzuvUDG","BgDhEhO","suvtx0vsuK8","wfnoD0m","zw5NDgG","y3vYDMfSDwu","BMfTzq","qNverLO","vKXLv0K","DeDNvMq","y3vYCMvUDeK","zMvY","DKTNuhu","Dgf1zNK","igXHCMDLCIa","y1jJsgq","DvLYvfu","Ae1LC3nHz2u","t1jJv24","CgfNzxnOB3C","D3jPDgvvAw4","ywXty29Wzq","zfnhtfa","y29UBMvJDca","u2TPCcbWyxm","BNrfBMrWB2K","y3jLyxrLrwW","x2n1CNnVCK0","y1DkyvK","D1LjrKu","CMvTB3zLq2G","zwPHuxu","zKXTuMS","z2v0sxrLBq","AwTYExi","tLbOCMG","x2vUzhbVAw4","qKnyu3y","qKjnDMC","yxbWBgLJyxq","CgLUz0LUDgu","DNPHDeG","tg9Nsuq","s3LoEvi","ywWGy3vYC28","C0LUrue","CwTzqxu","Bwu6ia","x2rLyNvN","DvrNEgK","u2vzDeu","Dwrht2C","ywDLu2HVDW","Efj2Aha","CMvZzxruCMK","qKngBM4","yxfjCvO","whPcwem","yMfSu2nVCgu","uhL0CKO","Cg93","zw1PDa","D2fZq2XLyw4","C0Xf","sLrSuLa","q29UzMLN","BwvKAwf0zwW","BgLUzw5V","t3bLBKv2zw4","sMrcyuy","BwfUDwfSihi","v2vIu29JA2u","Ae96rfm","zgLZCgf0y2G","Dgnstwu","ywnRtxnNswq","Dw50","yMLUyxj5vhK","qxj3wue","CvD3DLO","DLnlrMe","Aw9U","yxDZsMW","renRCeu","C2DPza","u0LYq1q","Axz0Dxy","x2LUAxrhBg8","tgPPtvq","C21PqMS","B2nRzxq","zMzMzG","sLnptLa","s21dCvO","AwH5ywS","wwDmyKy","zvvYBa","rxruvwq","vwDgEvK","yxLQEMm","rwXwy2G","yurwEhm","uhrJAKW","sgD4Cvy","ANv4Auy","yuHOrg0","x3jLBw92zvC","DMvYC2LVBG","ywjVCNq","BxnN","ANPPzve","qw1VDw50","rLHVCKq","v050DwK","CxbcBMy","Cu1ytLO","D0HtBgq","zxH0zw5ZAw8","s2zTCxm","zwnWwxe","x2DLDeLUDgu","x3DZ","EM5iyKm","shPUEMC","yxrHlcbKyxq","sxH4r1y","AMnJy0e","u0DnEhq","y3jLyxrLrxi","BML0AwfSAxO","y2nMCNK","CMncvNu","zhLnC1q","tNLqvgq","Cu1ktNi","Dwr3DM8","wKz0rfq","DuTfyK0","sg95vM4","zMzLCG","DNnczgq","BNrbBMrvCgq","zu5qwue","CeHvA2G","Ec11C2uT","q3L6Chy","zgvS","zfrKDfa","q3zAswm","Dxrjza","u0rjvvq","BwHQAui","DLHWru8","nJa2mZr2CgP5thG","vgjqDwi","Auj0C2S","BM93","qxDPzeC","zgnZCfi","qvrcCeq","yw5Nzq","zLLqsfe","DvLrCgu","AKHyELu","BMrWB2LUDca","x2rLC3rYB3K","zffws3e","B25VCgvU","id4G","BgjPwMO","x3bPBMDmB3m","u2XfsMu","veTQruG","x2nYzwf0zvm","ywX3yxLZ","ywjqD2K","y3jLyxrLt2i","wxb3r0e","BMnLEvi","B0vSAgK","Bg5xDMi","ywXSq3vYC28","CMXYrM4","yw5Hz2vY","AwXSihvZzsa","EuXrsfu","AMn6txi","B2zMBgLUzq","zgLAsMG","Dg9cExrLC0W","AxzKrvG","yw9rt1G","x2zVCM1HDeu","ufDhweC","vgLTzw91Da","q1rYruO","BK96AfO","v0XjENa","zv9ZDwnJzxm","CMvHC29U","B1fwwMm","C1buDfe","BwHKDKi","C2LWvu0","igfYCMf5yNu","A0PozM0","ndC0mZq4EhDvuNrk","B3nLrxzLBNq","l3DZl3yY","Cw9Z","zxq9DxrMltG","A2v5","yxv0BW","DxH4z2K","Dgv4Dc9Qyxy","t2PbtvK","aaaaaaaaaaa","CvDIvxy","C2fNzq","ue11zwW","qLDOC0C","ExDpA3K","CMvHzfvjBNq","vhf2ruK","vgfN","reiGzMfPBgu","zNjVBu51Bwi","Avflv0G","u0jMq2W","DMz2CMq","A055sw4","wg5ktwq","vMDZD1e","zMLSzw5HBwu","t2fwA2q","z2v0qwXS","B25tDgfYDfi","z2rMqxG","CMvTB3zLrxy","B3jRzxjhBg8","mNWWFdr8mxW","D3PPyNK","tKXAD3e","rfndAgi","t2fWAuC","ChbL","zu9WANa","AxnFywnR","BMCGDxjSoIa","DLPizwu","t2jQzwn0","wNLTCKK","sMv2uwq","twLZC2LUzYa","twXAq2e","qLryzvq","qLjWvNK","DvDevfe","yw51Ce1LC3m","u0fJvha","ChnuCem","AxHHqxi","v2LAsgK","BeXMELe","Cgzgr3C","Dhj1y3rVCIa","v1DrtKm","u0HHCLO","Axn5Eu4","rND5tMO","rMfQr1a","q21Otg4","AgLNAa","Bgziwhq","y2fWAxe","swrnBhO","t1bftG","Aw50zwDLCIa","EezdrgO","zMX1C2HfEha","BgLTAxq","veP0txi","x2n1CNnVCK4","shLLvfm","ue9iBKq","DgvZDa","BMnVzgLUzW","CNnVCL9Uyw0","B3LezhK","wMTkzfa","Bxj3vgW","D1PVzfu","qNzhy3O","C0XPC3rLBMu","Dfv1rLi","B3jLtMfTzxm","CM1Xshu","CfrVA1m","uw5hsNK","vNDer1m","ysbTDxn0igi","v2zQsLG","zgLwDgW","s09LA28","r2XVAwm","z2D4tvC","wfb2yu8","C3fXzvG","zgvSzxrL","t0X2rfy","t2jpuwi","rgTluuS","A3jlA20","CvjlBgm","r2jJA20","nhWYFdb8m3W","quzTtKq","txzbvui","ELDmCxa","Ae9Wzw5fDMu","AxjMBvy","y2v6twq","nxWX","runhr0i","B3PlB0e","EMTKAhK","rwTvz0W","igzPzwXKoIa","D1P1B3G","Be5fyue","rw1Wuwe","C2vUDa","rg5ztLK","uuL6sLG","tLPTEMG","yxv0B21HDgK","CMvKDwnL","AM95yKm","zNviEgq","mhW2Fdv8nW","yMfnANO","BwvZC2fNzv8","y29UDgv4Da","igzHAwWSig0","DML0Exq","zxH0ugf5Bg8","CNzHBfzHBhu","zufJAW","AhzYsNe","EKPXtM4","zffjwgG","y2HnyxHdB3u","D1bOBuy","D0LgCum","z2vtEw5J","zgLZywjSzue","sgPhC3G","z2v0q3vYCMu","BvbyAeK","CgLUz0XVC3m","A2rfvLa","vgnzy2i","x2LZv29YA2u","BfrPBwvVDxq","Aw9UvgLTzw8","CMfUzg9T","D2XyvNC","C3vIC3rYAw4","r2nNDKW","y2niyMW","y2rrBw0","ywDLsgLKzq","zwXbsM0","DKLwvg4","x3DHAxq","txrbq0i","Chv0","zKTiAMm","tMTKCuO","D3jPDgu","y2fSBa","uMX4zLa","twvZC2fNzuu","AxjLza","EvjLy29UBMu","txnRB0G","C3rVCcbPBw0","EMzLD0e","surNte0","y3ruAw1LB3u","C2vYDMvYvgK","rgDusNi","zgvSzxrLrge","D3bQsMq","Bwf4twvZC2e","C2vYDMLJzq","t2D4Eg8","uwjJAwW","ChjVy2vZCW","D24GCMvHC28","Bu9PzLi","BeHHBMrSzxi","CgLUz19VBMm","Dg9tDhjPBMC","wuXcAhi","D3m6lY8","A2v0ignVBNm","zhrnBwy","rvHoD1a","yNLL","q29Kzq","AxHVsxO","zgvJB2rLzey","u2Hhv0C","B25SAw5L","zfLvs1C","Efv5tNa","u2jmyLu","Ag9rr2G","tgPstLC","ufP3vhe","ohW5FdD8mxW","Aw1LCYbPBIa","zefos2y","BMLVEwO","Dg9Tsei","uevhC1C","x2nVBM5Ly3q","y09Wzw4","ANL0DMu","yMPxAhO","BNruCMLLC0m","Dg9Y","Dg9hzw5LCMe","y1rTtu8","Dur1v08","CgfNzwHPzgu","BNHls0y","CLvtyK4","rgngs1y","AefJA01LC3m","B1bRrxC","ywDWsu4","x21LC3nHz2u","sxzkExq","t1bftL9fuLi","mhWYFdr8m3W","C3rYAw5NAwy","DxjS","BKrRrgO","x2nSzwfYvgK","BNvTyMvY","sMjqBMC","tefIEeC","De1HBMfNzxi","rKrOtha","nhWZ","ugDmENa","vK5JCwq","CMvZB2X2zq","ig1LC3nHz2u","suzNEg8","zMHlywO","A2vpue8","z2vrDwv1zuW","zvDfAeu","BMCGB3iGyw4","y1HeC0m","rffRwhG","rwPQrM8","BwDxwMq","B3bLBIa","wNLcs0O","C3rVCMu","yMfSrxzLBNq","tu5ezMu","CLDXweK","vfDSBK8","x2LUAxq","v0nZEg0","x2LUAxrqCM8","CxfXBwK","y2TNrfG","sgfYBhi","C3vIyxjYyxK","uhj1AM0","vuvXrNG","yKjODe0","y0nrA3q","vMrJue0","nxWYFdf8mhW","vKfRuhi","CIb0DhDjra","uNzttNq","Cg9PBNrbBMq","ufbmy28","r3Dhsey","DgvmB2Djre4","zLrqy1m","wezzuva","x29UtwvZC2e","CwnQEvO","uLbYyKW","q3vZDg9Tq2W","ihn1y2nLC3m","D3nZoI8V","vKHyv0y","sKPNuwO","zNjkvMW","B25fCNjVCG","ve9RCLG","Bwv0Ag9K","BePeyxi","C1busM0","CM92AwrLihC","teL1zNy","sNnWwKy","tMfTzq","o2nOyxjZzxq","z1Hrthm","zuTRthq","Bez4ChO","CLzHBhvLCW","AgvHzgvYCW","BezSDxnO","zNvUy3rPB24","x2HHBMrSzvi","v3Lrwee","v0ThDhi","zeTbqwu","rgn5qNC","t1Phzva","BMDLza","v2zRshi","AgvHzgvY","DhjPzxmGCMu","BfnrAMm","zgrAAMm","wfb3CgK","CMLLC0nVDw4","vvj4reK","shD5z1y","qLHOEKm","uwT3rMe","yNvMzMvYzwq","y29UC3rYDwm","mhWYFdn8nhW","AwXK","B3jL","q0LmuhG","B1Hdzve","BMv4DcGPigm","zMLSDgvY","vezryu8","txrAzMe","yNL0zxm","wK9osfK","rvLjvKK","t3v1qKm","x29UugfNzu4","zw5HyMXLvhi","vLrHCKe","B25ozxr3B3i","quTQywS","DxrMofDYAxq","DerqvLC","y2f0y2G","C0nVDw50zxi","ntGZndq1r0DVse9w","ywDL","Dg9cExrLC0i","Dw9uCvK","u0Dkwuy","B21rA3e","C2v0y3vYC28","vffwyLi","z0j4v0W","qNnLweS","y3r4","A3rJwwW","Certwui","qwzurxe","zfDVCMTLCKC","wxr1wK4","rfLpALK","C2v0q3vYC28","CeTfrw0","x3jLy29UBMu","zxjFCw9Zx2e","BKXPBMu","DhjPzxm","DMfSDwvZ","thHusxi","BvLxq3m","B3nLza","r2niq1G","CMvHzhDYAxq","yxnJCMLWDa","AeTzrhy","v1zNBxa","vxntBhu","t0T3ALy","swDmv2G","y3blqMe","zMLUza","zuLiwfy","yuTwEhu","AxnrB1nnzxm","z2v0q3vYC28","CYbPBNn0yw4","vNb1CKK","tvr0z2K","x2LUDgvYDMe","BM1tEvO","rLjptLrjrvi","B25mAw5L","mZbzAvbRvM8","C05btwW","qvnwrvC","y3bLu1O","u21uA0e","C2v0","rLD4vKS","tKfusvzfx0u","Bwf4tg9ZC0m","AxnrB1nby2S","rufHCLG","sKTsy00","yLLzBKy","tfn2r2q","Cw9Zx18","vuf1vxG","Dfrgwgy","Aw5L","y2HnyxHuCMK","vhvQwfu","uefQvxm","t1Pqzw4","Aw5JBhvKzxm","zxj2AwnL","wvD4zwG","Egn5uMW","ywrKrxzLBNq","pxv0zI04","DxbKyxrLq3u","zKTwqvC","Cg9PBNrdB24","x3nLCuLK","vKruD2m","uwziufy","thzly0q","u2vYDMLJzvC","rwXqrve","yxnZAwDU","lcbxzwjtB2m","Dgv4Dc9WBge","DhjHBNnHy3q","m3WYFdb8nhW","EvzXsvy","CMvJzwL2zwq","EwPsAgy","quvoz3u","u2vXsuq","Ew93wvK","ywXPzcb1CMW","CMzhqNi","se1qwe8","q21Orfu","s2L4vxC","y3vYC29Y","uLH0CKG","yMzZA1m","zM9YrwfJAa","vfn1sw0","Ahr0Chm6","Dev4vva","zxjFAxnFywm","zNjVBujPDhm","C3rYAw5N","DMfSDwu","lcbTyxGGCMu","BxvtquO","vMLQEwq","yxrLq291BNq","CgfYC2u","veHrENC","BwLUzW","x2rItMfTzq"];return nr=function(){return n},nr()}function hf(n){let e=C,s={bfmPp:function(o,a){return o===a},tTFXf:e(1497),nceyR:function(o,a){return o(a)},HjGsx:function(o,a){return o instanceof a},qWbUv:function(o,a,d){return o(a,d)}};return s.bfmPp(typeof n,s[e(1604)])?s[e(1150)](pf,n):(s[e(1328)](n,IDBTransaction)&&s.nceyR(lf,n),s[e(1189)](ia,n,df())?new Proxy(n,sr):n)}function Ge(n){let e=C,s={VBckS:function(a,d){return a instanceof d},BRpVy:function(a,d){return a(d)},aMXLK:function(a,d){return a!==d}};if(s.VBckS(n,IDBRequest))return s[e(1228)](ff,n);if(er.has(n))return er[e(791)](n);let o=s[e(1228)](hf,n);return s.aMXLK(o,n)&&(er[e(1593)](n,o),ir.set(o,n)),o}var ia,Zo,Qo,li,rr,fi,er,ir,sr,xn,ea=ra({"node_modules/idb/build/wrap-idb-value.js"(){let n=C,e={azsrJ:n(1287)+"1|5",OeFtu:"get",ZnelP:n(1207),oXCeQ:n(1974)+"ys",pvpiR:n(419),TKSmG:function(s){return s()},tEaLx:n(1348),ruDyA:"delete",BCopJ:function(s,o){return s(o)},BYRFU:function(s,o){return s instanceof o},AUNtE:function(s,o){return s!==o},nQBsG:"NDTyP",jHXzU:function(s,o){return s===o},krKkm:n(808),mxZTK:function(s,o){return s===o},DkKQK:n(660)+"oreNames",kpptc:n(1445),LKoNl:function(s,o){return s===o}};ia=(s,o)=>o[n(1890)](a=>s instanceof a),li=new WeakMap,rr=new WeakMap,fi=new WeakMap,er=new WeakMap,ir=new WeakMap,sr={get(s,o,a){let d=n,u={WpBVq:e[d(776)],aodoU:e.OeFtu,jzKBI:e.ZnelP,WaUlZ:e[d(1522)],CFern:e[d(762)],iUsJz:function(f){return e[d(527)](f)},MmaUx:e[d(511)],SiApS:e.ruDyA,wGTbo:function(f){return e[d(527)](f)},SRxwI:function(f,p){return e[d(1832)](f,p)}};if(e[d(757)](s,IDBTransaction))if(e[d(840)]("NDTyP",e[d(1894)])){let f=u.WpBVq.split("|"),p=0;for(;;){switch(f[p++]){case"0":_0x1c4b65=[u[d(949)],d(653),u[d(1984)],u[d(1918)],u.CFern];continue;case"1":_0x4793a6=new _0x38433c;continue;case"2":u[d(447)](_0x52f1ee);continue;case"3":_0xce3cb5=[u[d(1858)],"add",u[d(778)],d(1724)];continue;case"4":u[d(834)](_0x38357d);continue;case"5":u[d(948)](_0x325782,h=>({...h,get:(y,w,A)=>_0x469d12(y,w)||h[d(791)](y,w,A),has:(y,w)=>!!_0x6dcf4f(y,w)||h[d(904)](y,w)}));continue}break}}else{if(e[d(1135)](o,e.krKkm))return rr[d(791)](s);if(e[d(1805)](o,e[d(1283)]))return s["objectSt"+d(1267)]||fi.get(s);if(o===e[d(1817)])return a[d(660)+d(1267)][1]?void 0:a["objectSt"+d(1520)](a["objectSt"+d(1267)][0])}return e[d(1832)](Ge,s[o])},set(s,o,a){return s[o]=a,!0},has(s,o){let a=n;return e[a(757)](s,IDBTransaction)&&(e.mxZTK(o,e[a(1284)])||e.LKoNl(o,e[a(1817)]))?!0:o in s}},xn=s=>ir[n(791)](s)}}),sa={};xf(sa,{deleteDB:()=>wf,openDB:()=>mf,unwrap:()=>xn,wrap:()=>Ge});function mf(n,e,{blocked:s,upgrade:o,blocking:a,terminated:d}={}){let u=C,f={NecZK:function(y,w,A,I,E){return y(w,A,I,E)},EFXCH:function(y,w){return y(w)},WnpmK:u(538),dSGLP:function(y,w){return y(w)},yDNEE:u(867)+u(467),TJtMr:u(1903)},p=indexedDB[u(699)](n,e),h=f[u(994)](Ge,p);return o&&p[u(1614)+"Listener"](f[u(1834)],y=>{let w=u;f.NecZK(o,Ge(p.result),y.oldVersion,y.newVersion,f.EFXCH(Ge,p[w(1628)+"ion"]))}),s&&p[u(1614)+u(1955)](f[u(1253)],()=>s()),h[u(498)](y=>{let w=u;d&&y[w(1614)+w(1955)](f[w(738)],()=>d()),a&&y["addEvent"+w(1955)](w(1916)+"hange",()=>a())})[u(1538)](()=>{}),h}function wf(n,{blocked:e}={}){let s=C,o={uCVlF:s(1903)},a=indexedDB[s(1364)+s(1934)](n);return e&&a[s(1614)+s(1955)](o.uCVlF,()=>e()),Ge(a)[s(498)](()=>{})}function ta(n,e){let s=C,o={xzllp:s(1568)+"e",cXjVm:function(p,h){return p instanceof h},irFMP:function(p,h){return p in h},XGjnh:function(p,h){return p===h},phhue:function(p,h){return p!==h},xbzxF:function(p,h){return p in h}};if(!(o.cXjVm(n,IDBDatabase)&&!o[s(1704)](e,n)&&o.XGjnh(typeof e,s(1650))))return;if(tr[s(791)](e))return tr[s(791)](e);let a=e[s(430)](/FromIndex$/,""),d=o.phhue(e,a),u=aa[s(1610)](a);if(!o[s(483)](a,(d?IDBIndex:IDBObjectStore)[s(575)+"e"])||!(u||oa[s(1610)](a)))return;let f=async function(p,...h){let y=s,w=this["transact"+y(1053)](p,u?o[y(434)]:y(1860)),A=w[y(1445)];return d&&(A=A[y(1968)](h.shift())),(await Promise.all([A[a](...h),u&&w[y(808)]]))[0]};return tr.set(e,f),f}var oa,aa,tr,_f=ra({"node_modules/idb/build/index.js"(){let n=C,e={WgFtk:function(s){return s()},uNQjf:n(791),MIRSP:"getAll",CuNgR:"count",EjjFo:n(1348),FGMwH:n(1696),nrofa:n(1280),Dptrk:"clear"};e.WgFtk(ea),ea(),oa=[e.uNQjf,n(653),e.MIRSP,"getAllKeys",e[n(567)]],aa=[e[n(1441)],e[n(737)],e.nrofa,e.Dptrk],tr=new Map,gf(s=>({...s,get:(o,a,d)=>ta(o,a)||s[n(791)](o,a,d),has:(o,a)=>!!ta(o,a)||s[n(904)](o,a)}))}}),yf={idb:function(n){let e=C;n[e(1804)]=Promise[e(1431)]().then(()=>(_f(),sa))[e(498)](function(s){return s})}},na={};function qe(n){let e=C,s={ZlcsQ:function(f,p){return f!==p}},o=(e(1849)+"3").split("|"),a=0;for(;;){switch(o[a++]){case"0":var d=na[n]={exports:{}};continue;case"1":if(s.ZlcsQ(void 0,u))return u[e(1804)];continue;case"2":var u=na[n];continue;case"3":return d[e(1804)];case"4":yf[n](d,d[e(1804)],qe);continue}break}}(()=>{let n=C,e={PEGsW:function(s,o,a){return s(o,a)},sPTtQ:function(s,o){return s(o)},MNDfe:function(s,o){return s===o},gmTbK:n(1162)};qe.d=(s,o)=>{let a=n,d={Qbcil:function(f,p,h){return e[M(1398)](f,p,h)},TJzWL:function(f,p){return e[M(1173)](f,p)}};if(e[a(1447)](e[a(844)],e[a(844)]))for(var u in o)qe.o(o,u)&&!qe.o(s,u)&&Object[a(1990)+a(1891)](s,u,{enumerable:!0,get:o[u]});else d[a(1369)](_0x24c602,_0x169308,96),d[a(1369)](_0x47a0ed,_0x7b7e3,d[a(782)](_0x25dfa4,_0x2dd86c))}})(),(()=>{let n=C;qe.o=(e,s)=>Object[n(575)+"e"][n(971)+n(1891)][n(1352)](e,s)})(),(()=>{let n=C,e={aDzng:function(s,o,a){return s(o,a)},MKejY:n(654),UgTdm:function(s,o){return s+o},zrZlO:function(s,o){return s!==o},UAIEA:n(794),HAWvq:function(s,o){return s!=o},rLpom:"Module"};qe.r=s=>{let o=n;if(e[o(411)](o(1964),e[o(648)]))e[o(826)](o(1881)+"d",typeof Symbol)&&Symbol["toString"+o(1196)]&&Object[o(1990)+"operty"](s,Symbol[o(1375)+"Tag"],{value:e[o(1774)]}),Object[o(1990)+"operty"](s,o(513)+"le",{value:!0});else{let a={eBZYF:function(u,f,p){return e[o(1688)](u,f,p)},qWwvZ:e.MKejY},d=_0x7baf11[o(540)][o(806)](_0x57e5d0[o(803)+"et"],e[o(452)](_0x43f83d[o(823)+"th"],_0x1f4f9c[o(803)+"et"]));Y[o(458)]&&Y[o(458)][o(569)]({data:d,fail:u=>{let f=o;Y[f(1033)](f(654),a[f(644)](_0x48a942,a[f(1051)],{message:Y[f(1164)+"rrorMessage"](u)}))}})}}})();var re={};(()=>{let n=C,e={VNcqd:function(i,t,r){return i(t,r)},ClbBK:n(1374)+n(1170)+"s",uWZPZ:n(1374)+n(620)+"t",LdaAQ:function(i,t){return i(t)},vyWrv:n(1761),Gbckm:"timeout",pfMNV:n(1474),IDyNk:function(i,t){return i+t},gdfAx:function(i,t){return i<t},keOPO:function(i,t){return i>>t},Dglrt:function(i,t){return i|t},wTHWk:n(1803)+n(895),VdcPM:function(i,t){return i&t},tRqjG:function(i,t){return i>>t},IhbNK:function(i,t){return i&t},xRvhp:function(i,t){return i&t},lLjfj:function(i,t){return i!==t},GJftq:n(1577),uWDTQ:function(i,t){return i*t},abPwi:function(i,t){return i(t)},Ezrwt:function(i,t,r){return i(t,r)},ApNnf:function(i,t){return i(t)},WKGtr:function(i,t){return i(t)},dFiHg:function(i,t){return i(t)},lAZbk:function(i,t){return i+t},rWqXI:n(742),aKOyW:n(1063),JKRcM:n(672)+"00000000"+n(672)+"00000000",ixoIz:n(1778)+"t",Obmwg:n(1358)+"ediately"+n(1883)+"ct",OpRyU:function(i,t){return i===t},jIEcL:n(1722),XTfzZ:"YABmF",EwVMZ:function(i,t){return i>t},AtchK:n(1764),fhKaj:n(1036),GFyHz:function(i,t){return i!==t},EXHQS:n(1647),PoryQ:function(i,t){return i<t},AENgu:function(i,t){return i-t},CvoPH:function(i,t){return i!==t},MjZmm:function(i,t){return i<t},HgxqV:function(i,t){return i-t},QvnFD:function(i,t){return i===t},psTpC:n(1923),JugWw:function(i,t){return i<t},YLBhr:function(i,t){return i!==t},wHSld:n(1015),KsMJu:function(i,t,r){return i(t,r)},ZFtDT:function(i,t){return i!==t},wpjJd:function(i,t){return i(t)},WDoiP:function(i,t){return i>>>t},zJGsR:function(i,t,r){return i(t,r)},nDkDj:function(i,t){return i(t)},eHikS:function(i,t,r){return i(t,r)},gBxWL:function(i,t){return i(t)},updFo:function(i,t,r){return i(t,r)},yetrx:n(1225)+"required"+n(1299)+"key",ECGGB:n(1225)+"required"+n(1299)+"value",NlEIV:function(i){return i()},mPXhI:function(i,t,r){return i(t,r)},AdJeh:function(i,t){return i(t)},KyWyT:function(i,t){return i!==t},FWxVK:function(i,t,r){return i(t,r)},JhLtu:function(i,t,r){return i(t,r)},QxogB:function(i,t){return i!==t},LhCwz:function(i){return i()},oJKUN:function(i,t,r){return i(t,r)},ObOQb:function(i,t){return i(t)},ASVEW:function(i,t,r){return i(t,r)},XfPCr:function(i,t){return i!==t},VgswQ:function(i,t,r){return i(t,r)},iFFFH:function(i,t){return i!==t},ozKoA:function(i,t,r){return i(t,r)},pGvFA:function(i,t,r){return i(t,r)},xECpU:function(i,t,r){return i(t,r)},BvGcz:function(i,t,r){return i(t,r)},HoyVn:function(i,t){return i(t)},HxWOt:function(i,t){return i(t)},ouMFf:function(i,t){return i(t)},LIufv:function(i,t){return i(t)},DFvdA:function(i,t){return i(t)},DMTbI:function(i,t,r){return i(t,r)},lgxdh:function(i,t,r){return i(t,r)},SnXtO:function(i,t){return i(t)},jJsDY:function(i,t,r){return i(t,r)},NTxTL:function(i,t){return i(t)},DnYNY:function(i,t,r){return i(t,r)},bEgbf:function(i,t,r){return i(t,r)},HstUi:function(i,t){return i(t)},phlFb:function(i,t){return i(t)},TkcwX:function(i,t){return i===t},SmTkA:n(1225)+n(1930)+n(1299)+"service",ikSQv:n(1225)+n(1930)+n(1299)+n(1483),JJgQj:function(i,t){return i!==t},krkJI:n(588),jytve:"WwFWX",REdcU:function(i,t){return i(t)},XPvaO:function(i,t,r){return i(t,r)},BfCor:function(i,t,r){return i(t,r)},znHbC:n(1818)+n(656)+"pe: ",EmJMo:function(i,t){return i>=t},taufy:function(i,t){return i!==t},myLzc:n(1813),CIcZm:n(1488),TsCkM:function(i,t){return i>t},HwygV:function(i,t){return i+t},uaNPF:n(996)+n(410),WGXPN:function(i,t){return i>=t},pULyc:function(i,t){return i>t},uYrTU:function(i,t){return i>t},szUMO:function(i,t){return i+t},UpYiy:n(1699)+n(410),CILPx:function(i,t,r){return i(t,r)},DgTJr:function(i,t){return i===t},dcspR:"sDBGt",OaVkd:function(i,t,r){return i(t,r)},ZfvAb:function(i,t,r){return i(t,r)},iYuDJ:function(i,t){return i<t},VLeWI:function(i,t){return i===t},TkRDF:function(i,t){return i&t},nGdEG:function(i,t){return i&t},XSNwC:function(i,t){return i+t},yhaFj:function(i,t){return i+t},sInEA:function(i,t){return i&t},YpwGA:function(i,t){return i<<t},kTBvc:function(i,t){return i&t},SAcTp:function(i,t){return i==t},gxpAS:function(i,t){return i+t},FRIIK:function(i,t){return i+t},ouLDD:function(i,t){return i!==t},kdEVP:function(i,t){return i&t},cTmMO:function(i,t){return i===t},xkQxW:n(437),LjRNW:n(1480),zbKfF:function(i,t){return i|t},dejvK:function(i,t){return i&t},CnuRQ:function(i,t){return i<<t},Fjutq:function(i,t){return i<=t},TcYcb:function(i,t){return i(t)},VDTwc:function(i,t){return i+t},pGmhy:function(i,t){return i===t},mBfRh:n(1877),FgSRc:function(i,t){return i+t},IvJyt:function(i,t){return i+t},aZOhP:function(i,t){return i&t},aDVxs:function(i,t){return i<<t},LwVHw:function(i,t){return i<<t},AfTEq:function(i,t){return i|t},SlHtm:function(i,t){return i&t},OjAMY:function(i,t){return i&t},Bvccp:function(i,t){return i>t},AvdFc:function(i,t){return i+t},lLfzQ:function(i,t){return i&t},FkYTn:n(1052),kOoEA:function(i,t){return i<t},VTarA:function(i,t){return i<=t},sqcBi:function(i,t){return i<t},WNtui:function(i,t){return i<<t},Prujm:function(i,t){return i<t},cOsph:function(i,t){return i-t},CHgTi:function(i,t){return i<<t},JevQd:function(i,t){return i<t},WWQNC:function(i,t){return i&t},dYUKW:function(i,t){return i>>t},HMPXO:function(i,t){return i>>t},PvUIF:function(i,t){return i|t},OLvDV:function(i,t){return i&t},ATyGM:function(i,t){return i|t},RprWd:function(i,t){return i&t},mBRqX:function(i,t){return i<t},oQVZc:function(i,t){return i|t},NoTmn:function(i,t){return i<t},NzpwO:function(i,t){return i>>t},jnIcs:function(i,t){return i|t},dpPnA:function(i,t){return i>>t},VakBz:function(i,t){return i|t},twlFK:function(i,t){return i&t},KCbFw:function(i,t){return i+t},dQIXh:"gCMKJ",sThCE:"fmoGt",capiq:function(i,t){return i<<t},LaOqF:function(i,t){return i&t},aydTd:function(i,t){return i&t},KhnbM:function(i,t){return i>>t},XOdBn:function(i,t){return i+t},PZwTq:n(536),GTWfu:function(i,t,r){return i(t,r)},nzqgs:function(i,t){return i&t},Ujblc:n(1535),xmoxj:function(i,t){return i&t},SGJYF:function(i,t){return i<<t},oOeZn:function(i,t){return i(t)},AiFjL:function(i,t){return i(t)},wCINL:function(i,t){return i&t},IFgxo:function(i,t){return i(t)},nQDZw:function(i,t){return i<<t},xSuRE:function(i,t){return i&t},SrDMT:function(i,t){return i(t)},gbxOh:function(i,t){return i&t},MlZCa:function(i,t){return i(t)},WfkHr:function(i,t){return i&t},zvobi:function(i,t){return i(t)},lsFqF:function(i,t){return i<<t},rgAPE:function(i,t){return i>>>t},wKemu:function(i,t){return i|t},Btoui:function(i,t){return i<t},XKXOY:function(i,t){return i<t},SmMys:function(i,t){return i<t},jLusN:function(i,t){return i+t},ZPNyb:function(i,t){return i>>>t},CvzJR:function(i,t){return i|t},ayjzc:function(i,t){return i>>>t},MtACB:function(i,t){return i+t},pakug:function(i,t){return i>>>t},USLTu:function(i,t){return i&t},vXpEO:function(i,t){return i+t},FaDgq:function(i,t){return i!==t},MGaIH:function(i,t){return i|t},lbiZj:function(i,t){return i+t},kaluE:function(i,t){return i|t},ieZcJ:function(i,t){return i!==t},fLmRk:function(i,t){return i|t},nOzhZ:function(i,t){return i>>>t},kVUGu:function(i,t){return i&t},mPfEg:function(i,t){return i+t},KCqHu:function(i,t){return i!==t},BCjdc:function(i,t){return i>>>t},Qvrvp:function(i,t){return i&t},BrhIQ:function(i,t){return i|t},qMXNZ:function(i,t){return i&t},CBHzE:function(i,t){return i(t)},aUupD:n(1491),MfdPe:"mRVGF",GXzbJ:function(i,t){return i|t},aHhDm:function(i,t){return i<<t},rUSbN:function(i,t){return i<<t},NPhrh:function(i,t){return i<<t},lnWvb:function(i,t){return i<<t},XzBXC:function(i,t){return i|t},jRttc:function(i,t){return i<<t},skGVH:function(i,t){return i<<t},lfHXt:function(i,t){return i>>>t},ytmgt:function(i,t){return i|t},cWJaY:function(i,t){return i<<t},dqOUG:"UfHbF",bVtWt:n(1107),TwtOR:function(i,t){return i&t},ixaAr:function(i,t){return i&t},OTbOc:function(i,t){return i>>>t},UoHXM:function(i,t){return i&t},pDSYB:function(i,t){return i>>>t},QnGJy:function(i,t){return i>>>t},INUFZ:function(i,t){return i&t},SGMxt:function(i,t){return i>>>t},OgNHR:function(i,t){return i(t)},GcHCX:n(857),cJCKw:function(i,t){return i>=t},UNNZO:function(i,t){return i+t},dQVKq:function(i,t){return i%t},kToOK:function(i,t){return i|t},baMjz:function(i,t){return i*t},SKNmO:function(i,t){return i>>>t},eNPYA:function(i,t){return i>>>t},tomHB:"DTSPi",ySuAY:function(i,t){return i===t},wPhmF:function(i,t){return i===t},qMJNr:n(1650),cLdXS:function(i,t){return i===t},nmSyZ:n(1097),qmaKl:function(i,t){return i&t},RTybF:function(i,t){return i>>>t},pfFGw:function(i,t){return i+t},VVxBH:function(i,t){return i+t},hmvLw:function(i,t){return i>>>t},iwZAx:function(i,t){return i<<t},rVsIU:n(538),juxiF:function(i,t){return i!==t},wZodU:n(1223),rJvqH:function(i,t){return i!==t},jXTjw:function(i,t){return i===t},zRZhk:function(i,t){return i>>>t},PsgeS:function(i,t){return i===t},TbPub:function(i,t){return i===t},XnIhz:function(i,t,r,c){return i(t,r,c)},XAsyP:n(727),IwYSh:function(i,t){return i&t},IDFVP:function(i,t){return i&t},BCFnn:function(i,t){return i>>>t},Ogxxo:function(i,t){return i&t},awsJl:function(i,t){return i&t},vVSLh:n(1408),phcDk:n(991),qcjyZ:function(i,t){return i===t},SlEJe:n(1995),YWZqV:function(i,t){return i&t},mgWZd:function(i,t){return i>>>t},YtdVH:function(i,t){return i>>>t},DdfNY:function(i,t){return i>>>t},SDIUT:"MESSAGE_"+n(629),nxKKF:n(1874)+"NG_ERROR",wIFqC:n(516)+"IES_ERROR",npOLv:n(1595)+n(855),Ujdht:function(i,t){return i>>>t},cDbHt:function(i,t){return i===t},JvIkf:n(512),jHLbU:n(1518)+"1",OtwRV:"WjUnz",UEqFx:n(1120),MjaVp:function(i,t){return i===t},zIqbo:n(1515),RSKWK:function(i,t){return i===t},ORcWn:n(438),NKUyg:function(i,t){return i==t},WiZHi:function(i,t){return i>t},fKVAW:n(654),ueqII:function(i,t){return i instanceof t},diZJh:function(i,t){return i+t},bBhtM:function(i,t){return i+t},dOcJU:function(i,t){return i+t},SBfCl:function(i,t){return i&t},NZmzh:n(979),NQPFf:function(i,t){return i<=t},HmTcv:function(i,t){return i<t},cpKBa:function(i,t){return i<<t},OGbDf:function(i,t){return i<t},dIIqg:function(i,t){return i&t},idFGr:function(i,t){return i|t},irfmV:function(i,t){return i&t},iUYox:"qYkxC",zPfem:function(i,t,r){return i(t,r)},cRcHd:function(i,t,r){return i(t,r)},PytrJ:"knZUj",zXGMW:"open",JbPng:"message",vrTKT:function(i,t,r){return i(t,r)},LvKcD:function(i,t){return i(t)},ZyBKJ:function(i,t,r){return i(t,r)},JPZUh:function(i,t,r){return i(t,r)},RbmDC:function(i,t){return i instanceof t},xOpBE:function(i,t){return i!==t},YkqUh:n(967),hDkJk:n(1463),nioyj:n(1070),vkonm:function(i,t){return i!=t},XnJMd:n(1881)+"d",GwGHF:n(1842)+"2",oNoLV:function(i,t){return i||t},nsOiH:function(i,t){return i!=t},hOdmM:function(i,t){return i!==t},ngRHb:n(474),XPEDz:n(1871),jOOpJ:function(i,t){return i(t)},PoNFs:function(i,t){return i<t},STlOM:function(i,t){return i<t},xIOst:function(i,t){return i===t},LCTaM:function(i,t){return i===t},jjDdT:function(i,t){return i&t},fvRXI:function(i,t,r){return i(t,r)},zfewA:function(i,t){return i<=t},LHEBj:function(i,t){return i<t},DSubS:function(i,t){return i|t},izMdd:function(i,t){return i&t},bAlYF:function(i,t){return i<t},HdOnc:function(i,t){return i|t},VpurI:function(i,t){return i<<t},tDPVW:function(i,t){return i&t},ujRtw:function(i,t){return i>=t},mCpFC:function(i,t){return i===t},kBERw:"utGbU",vvwYU:n(1609),xQPMB:function(i,t){return i&t},BXhzC:n(1956)+n(833)+"onnecting",RdZBx:function(i,t){return i!==t},qpBnf:"iPWAO",CVZoK:function(i,t){return i<t},NLZwq:n(743),TujXU:function(i,t){return i<t},vwWnc:function(i,t){return i|t},Mopwe:function(i,t){return i>>t},cnWOk:function(i,t){return i|t},xFCDj:function(i,t){return i!==t},ktcYl:n(781),oread:function(i,t){return i|t},DQEMZ:function(i,t){return i>>t},ckSPX:function(i,t){return i|t},isrWD:function(i,t){return i&t},AFmND:function(i,t){return i>>t},kWldj:function(i,t){return i&t},gfZsA:n(599),RPkDb:function(i,t){return i|t},XpBun:function(i,t){return i|t},TOkrX:function(i,t){return i&t},ihyak:function(i,t){return i(t)},DDozK:function(i,t){return i!==t},gtHio:function(i,t,r,c){return i(t,r,c)},kOIvp:function(i,t){return i instanceof t},IgLWh:function(i,t){return i||t},sPTJm:function(i,t){return i===t},HpUGT:n(1069),tAgtV:"hfPKP",ixzSw:function(i,t){return i!=t},xngtp:function(i,t){return i instanceof t},EVnQC:function(i,t){return i!=t},oPkEw:n(1573),wYtFe:n(696),wHPcH:n(863),XRxyc:n(1217),llsJu:function(i,t){return i>=t},WwpdR:n(1906)+"reason",bKQrb:function(i,t){return i===t},QfHPV:"ABbXz",SkZEd:"yowYY",VxerG:n(1186)+n(1569),HkCLM:"http",BCXSv:"&jscallback=fron"+n(1897)+"P",oyDdy:n(669),IZWxY:function(i,t){return i>>t},OtDZB:function(i,t){return i===t},hOzDS:n(766),SbaXl:"idb",nOTPy:function(i,t){return i!==t},BBMvg:"SkXUb",RzjOT:n(530),iBtsk:n(1729),TSuIm:function(i,t){return i||t},aqIqZ:function(i,t){return i||t},LSvGd:function(i,t){return i instanceof t},qSjJy:function(i,t){return i!==t},DhrID:n(1104),DQkXx:function(i,t){return i!=t},cayFs:n(553)+n(1197)+"d",OapiG:n(852),mhdvB:n(1313)+"id",VHXWF:"teWaO",fVwoc:n(709),EAarX:n(1814),TQVbR:n(705),uTgxi:n(959),cxxqL:function(i,t){return i(t)},HrtGe:n(417)+"er_qos",PmFfJ:function(i,t,r,c){return i(t,r,c)},bYYnF:n(417)+n(1560)+"ck",dRNmd:function(i,t,r){return i(t,r)},Gloic:n(417)+n(418)+n(1056),eWEhE:"need_ack",xUyNp:n(1219),PFXLN:function(i,t){return i&&t},POHnD:"ack_id",TFiZB:n(932),eKkLt:n(1631),FXorD:function(i){return i()},LNJdl:"versionc"+n(856),uLCiO:function(i,t){return i(t)},YrZrh:n(1271),NyTZi:n(797),KosGs:function(i,t){return i instanceof t},SWezg:n(1627)+n(820)+n(1182),gsBMj:"applicat"+n(824)+n(1490)+"=utf-8",FnZey:function(i,t,r,c){return i(t,r,c)},hoQGh:function(i){return i()},GKICS:function(i,t){return i>t},XCrCW:function(i,t){return i>>>t},uRzlG:function(i,t){return i+t},DcyBw:function(i,t){return i+t},aomDX:"index ou"+n(517)+"ge: ",fIfRR:function(i,t){return i||t},JQAIw:function(i,t){return i>t},rmqHu:n(1249)+n(1773)+"e",dciJv:function(i,t){return i&t},IDgLM:function(i,t,r,c){return i(t,r,c)},vosxr:function(i,t){return i===t},AvLhV:n(544),XSeZX:n(1629)+"1",YUbCi:function(i,t,r,c){return i(t,r,c)},qvNzr:function(i,t){return i<t},BfpId:function(i,t){return i+t},KNJZK:n(1175),DCkpE:function(i,t){return i|t},wZuox:function(i,t){return i|t},WyQXA:function(i,t){return i<<t},cpeSZ:function(i,t){return i<<t},Kjzha:function(i,t){return i<<t},PMuel:function(i,t){return i+t},EloHU:function(i,t){return i+t},WAXHe:function(i,t){return i|t},Vijyd:function(i,t){return i|t},DNEVJ:function(i,t){return i<<t},kJNfm:function(i,t){return i<<t},BMnfL:function(i,t){return i+t},ggxMW:function(i,t){return i+t},SbLbU:function(i,t){return i+t},CmhDU:function(i,t){return i>>>t},QAqzC:function(i,t){return i+t},SeYtE:function(i,t){return i+t},cxUUs:function(i,t){return i&t},TQNas:function(i,t){return i+t},hRsRF:function(i,t){return i>>>t},QJvVM:function(i,t){return i&t},LxTIr:function(i,t){return i>>>t},IREgF:function(i,t){return i+t},BseXK:function(i,t){return i&t},CYrPU:function(i,t){return i+t},WFbiS:function(i,t){return i<t},uCbcZ:function(i,t){return i&t},ZIUpC:function(i,t){return i>>>t},ShGWG:function(i,t){return i+t},DcFKV:function(i,t,r,c){return i(t,r,c)},fYPHQ:n(1506),eOpjp:n(978),oxdoA:function(i,t){return i(t)},VvJBU:n(1841)+"ile_name",WjjCg:function(i,t,r){return i(t,r)},mMcpL:function(i,t,r){return i(t,r)},oLWfD:function(i,t,r,c){return i(t,r,c)},MFeKI:n(664)+n(962),nLaPR:n(674),NPvBX:n(647),URxDI:n(1393)+n(1772)+n(1666),ZUFbk:"service-"+n(978),CmhLn:n(977),siMVF:n(1958)+"ervice",ILeEQ:function(i,t,r,c){return i(t,r,c)},UQxRF:n(710),ybKos:function(i,t){return i>>t},PgLzp:function(i,t){return i|t},muSAJ:function(i,t){return i&t},qTyoF:function(i,t){return i>>t},dtMmf:function(i,t){return i&t},uVbmi:function(i,t){return i===t},YSVxz:n(882),vZHee:n(1153)+n(1494),JfFGv:n(745),DQehz:function(i,t,r,c){return i(t,r,c)},tGgVd:"CONTINUE",iWnqq:function(i){return i()},tIguC:n(1381),MEnes:function(i,t,r){return i(t,r)},iHSfa:n(1863)+n(1809)+n(719)+n(1605),cdQmm:function(i,t){return i===t},LAUGB:"wqykR",ElVch:"setdb",TFQaO:"complete",GcgvL:function(i,t){return i!==t},PtcjL:n(1345),oBxvI:function(i,t){return i===t},LZrrD:n(1732),iQKWH:function(i,t){return i||t},vityt:function(i,t){return i*t},ZSELC:function(i,t){return i>t},YWxIK:function(i,t){return i!==t},Cztip:function(i,t,r){return i(t,r)},lJDar:function(i,t,r){return i(t,r)},MTtgi:function(i,t){return i!==t},HxUGm:function(i,t,r){return i(t,r)},zWLqp:function(i,t,r){return i(t,r)},uwLrf:function(i,t){return i(t)},EAhPR:"WaXQI",wziby:"code",rtlMf:n(417)+"er_msgid",jcBjX:function(i,t,r){return i(t,r)},NLhdq:n(505)+n(1259)+"e",YcTjS:function(i,t){return i(t)},xmLPW:function(i,t,r){return i(t,r)},XDSmt:n(505)+"rsor_value",EHqtT:function(i){return i()},KOeko:function(i,t){return i>t},ZpgAn:n(1670),jzieQ:n(1285),DuWsj:n(1530),WOfnl:function(i,t){return i<=t},ZkJdP:function(i,t){return i<t},lNNuL:function(i,t){return i>=t},vlvsi:function(i,t){return i&t},CpCtN:function(i,t){return i&t},ETVsY:function(i,t){return i>=t},CNpwS:function(i,t){return i-t},HyeTS:function(i,t){return i|t},IKvLo:function(i,t){return i|t},fTPcS:function(i,t){return i&t},ZQHFg:function(i,t){return i&t},cVtSM:function(i,t){return i>>t},sNAMl:function(i,t){return i+t},THQzw:function(i,t){return i!==t},PAjUs:"PaDgL",Harlr:function(i){return i()},VCJdo:function(i){return i()},FDhLp:function(i,t){return i===t},VzCDO:function(i,t){return i===t},WVgmp:function(i){return i()},ZONHY:function(i){return i()},ckgDX:n(808),HVdrA:n(660)+n(1267),eCrXe:function(i,t){return i===t},BIMuq:n(463)+n(1294),jdxnR:n(1417)+"OR",dTdtP:function(i,t){return i!==t},wYIFE:"PdIpD",pWZGh:function(i,t){return i!==t},zjUsG:function(i){return i()},OxCnQ:function(i,t){return i<t},WxOxJ:function(i,t){return i===t},LVDsK:n(1985),SdTUY:function(i){return i()},SIrCT:function(i){return i()},zJqNn:"kpDNN",SYKiM:"SSHiZ",ArwYA:function(i,t,r){return i(t,r)},xigRC:function(i,t){return i===t},rlrFn:n(1184),nxTLQ:n(1738),PPLco:function(i,t){return i===t},BrsDT:"UEgws",cezMd:function(i,t,r){return i(t,r)},EQEDe:n(1812)+n(983),jIkAR:n(954),YWorD:function(i,t){return i/t},USyfF:function(i,t){return i==t},BoAeR:function(i,t){return i===t},vsBdd:"please p"+n(1827)+n(1636),CogyP:n(570)+n(1486)+"s params"+n(1626)+n(1378)+n(1237)+n(495)+n(750),VQNIy:n(1386),QbUQe:n(1159),EnyrX:"dHHxI",yAaSf:n(1006),nBKuw:n(1646),YWxeh:n(1377),ddZjc:n(1477),hUtJl:n(1965),PYruD:n(1960)+"d",smiBk:function(i,t){return i||t},DoMCz:function(i,t){return i==t},Dtrro:n(1497),sbiiu:function(i){return i()},pLRDh:n(609),lVUMX:n(1660)+"0",QUDbq:function(i,t){return i<<t},uYQpe:function(i,t){return i&t},NXKzt:function(i,t){return i&t},tRmiI:function(i,t){return i<t},ccHbl:function(i,t){return i(t)},xtBrd:n(1123),mYWCs:function(i,t,r){return i(t,r)},zdyUt:function(i,t,r){return i(t,r)},EgUsp:function(i,t){return i(t)},zqZiY:function(i,t){return i(t)},cEyRD:n(1586)+">",RNZxQ:function(i,t){return i(t)},piaff:function(i,t){return i===t},NjWeJ:function(i,t){return i-t},jsiQo:function(i,t){return i===t},EkUgL:function(i,t){return i!==t},atbRh:n(1863)+"ay, try "+n(1778)+n(1927)+"ver",LDBTc:function(i,t){return i!==t},deMRa:n(1163),hKYDv:n(1305),jQqvD:n(420),BeouD:"AvLUj",NRtPt:n(714),uDuWO:n(1418)+"1",yVqIV:"0|4|2|1|3",musqz:function(i,t,r){return i(t,r)},GMqpR:function(i,t){return i&t},JCYcV:"BMhtS",qNljh:"FpuHP",osFzZ:n(617),wzjPz:function(i,t){return i<t},tUuFR:function(i,t){return i<t},fLRch:function(i,t){return i<t},qqqmi:function(i,t){return i+t},kPEtn:function(i,t){return i===t},yquCC:n(828),MtZfa:n(1508),ZbLyJ:n(811)+n(1311),tuHWf:function(i,t){return i===t},rUFTx:n(908)+n(1810)+"y closed",uInih:n(908)+n(1581)+n(657)+n(1101)+"ed",hPYkV:"please p"+n(1765)+n(1868)+n(1096)+n(1272)+"e a stri"+n(1438)+n(1176)+n(1111),xETJD:function(i,t){return i==t},eugmK:n(1423),aKVxu:function(i,t){return i!=t},dANKf:function(i,t){return i instanceof t},lWLTI:function(i,t){return i instanceof t},bModq:function(i,t){return i||t},RMjSx:"please p"+n(1765)+" valid s"+n(1611),Ocyhr:function(i,t){return i instanceof t},GgLvM:function(i,t){return i(t)},gzSSu:function(i,t){return i===t},eKfeU:function(i,t){return i<t},tEeWX:n(1695),oMRLF:function(i,t){return i(t)},SHarZ:function(i,t,r,c){return i(t,r,c)},krSPJ:function(i,t){return i!==t},MZAuP:n(1042)+n(1782)+n(940),rcBVu:"jtvSz",tojus:n(724),TXHzV:n(1212)+"3",derwt:n(2005),pTokS:n(1997),sFszu:function(i,t){return i*t},WLIzp:function(i,t){return i/t},lneoT:"Window",haNxc:function(i,t){return i!=t},OpFbo:function(i,t){return i===t},CTrEJ:n(1222),ifDpf:function(i,t){return i===t},iVFzT:"Dedicate"+n(1554)+n(667)+"pe",yLbql:function(i,t){return i===t},Kfmqs:function(i,t){return i!=t},lUMrJ:n(694)+n(611)+n(993),tEvAV:function(i,t){return i===t},UCkan:n(1623)+n(1211)+n(1030),LCssE:function(i,t){return i!=t},tJYsc:function(i,t){return i===t},xeTDk:function(i,t){return i===t},Ccnnx:function(i,t,r){return i(t,r)},hvrJq:"__x_msg_"+n(1602)};qe.r(re),qe.d(re,{FWS:()=>F0,CustomErrorEvent:()=>es,createCloseEvent:()=>De,ReconnectEvent:()=>Qi,createErrorEvent:()=>Ie,decodedFrame:()=>_t,createOpenEvent:()=>os,CustomCloseEvent:()=>ts,createReconnectEvent:()=>Lr,FrontierMessageEvent:()=>rs,encodeFrame:()=>se,createMessageEvent:()=>ss,OpenEvent:()=>is,ErrorCode:()=>nt,Event:()=>vt,MessageEvent:()=>ns});let s="";function o(i=""){let t=n,r={gFzJm:function(c,x){return e.LdaAQ(c,x)},TWlnO:e.vyWrv,HsVbv:e[t(2002)],KoYsu:e[t(1286)]};if(e.pfMNV!==e[t(1991)]){this[t(687)+t(633)](),this[t(615)+t(1982)+"Id"]=e[t(1430)](_0x4b1c3f,this[t(539)][t(935)](this),this._options[t(1012)+t(746)]);let c=()=>{let g=t;r[g(873)](_0x38bc4b,r[g(1449)]),this[g(1895)](r.HsVbv,c),this[g(1895)](g(1374)+g(620)+"t",x)},x=()=>{let g=t;r[g(873)](_0x11e146,r[g(916)]),this.off(g(1374)+"e_success",c),this[g(1895)](g(1374)+g(620)+"t",x)};this.on(e[t(2002)],c),this.on(e[t(899)],x),this[t(539)]()}else{let x=""+Date.now(),g=s||(s=p(i)),m=Math[t(1337)]().toString(16)[t(806)](-6);return e[t(413)](e.IDyNk("02",x)+g,m)}}function a(){let i=n,t={bfskS:function(r,c){return e[M(1209)](r,c)},TKjEH:function(r,c){return e[M(1435)](r,c)},PPVSP:function(r,c){return e[M(541)](r,c)},UJamg:function(r,c){return r&c},tcRMe:e[i(1912)],DSChb:function(r,c){return e[i(1461)](r,c)},DKAxr:function(r,c){return e[i(542)](r,c)},TZRGu:function(r,c){return e[i(413)](r,c)},ywOky:function(r,c){return r&c},eoCgf:function(r,c){return e[i(889)](r,c)},xRdnF:function(r,c){return e[i(541)](r,c)},eZRGr:function(r,c){return e[i(1025)](r,c)},BWhsG:function(r,c){return e[i(1435)](r,c)},dFBAC:function(r,c){return e.tRqjG(r,c)},xAKwL:function(r,c){return r&c},uMeki:function(r,c){return r|c}};if(e[i(903)](i(1185),e[i(947)]))return e[i(413)](e[i(1229)](1e4,Date[i(1128)]()),Math.floor(1e4*Math.random()));if(_0x529632=_0x1d1464.charCodeAt(_0x3a72b4),t[i(1643)](_0xafa01a,128))_0x1ba439[_0x27b42e++]=_0x29d684;else if(t.bfskS(_0x52a8f0,2048))_0x6bd419[_0x230936++]=t[i(1144)](_0x62a7e2,6)|192,_0x401eae[_0x2a2066++]=t[i(480)](63&_0x43ed99,128);else if(t.UJamg(64512,_0x53427a)===55296&&(64512&(_0x33e939=_0x436a57[i(1752)+"At"](_0x4eef8f+1)))===56320){let r=t[i(1046)][i(1771)]("|"),c=0;for(;;){switch(r[c++]){case"0":_0x5215a7[_0x4f3fd4++]=t[i(1215)](63,_0x437c68)|128;continue;case"1":++_0x5df646;continue;case"2":_0x2be51f[_0xf799df++]=t.PPVSP(t.DKAxr(_0x1df554,18),240);continue;case"3":_0x17731f=t[i(1829)](t.TZRGu(65536,t[i(1193)](1023,_0x55a521)<<10),t[i(501)](1023,_0x3db416));continue;case"4":_0x402ee1[_0x3e09c8++]=t.xRdnF(t[i(914)](t[i(1192)](_0x5c90ba,6),63),128);continue;case"5":_0x4365a6[_0x51158e++]=t.PPVSP(t[i(769)](_0x126446,12)&63,128);continue}break}}else _0x5cb6a3[_0x5da341++]=t[i(583)](t[i(1192)](_0x5239e5,12),224),_0x31a1a5[_0x321826++]=t[i(480)](t[i(1872)](t[i(769)](_0x5956ff,6),63),128),_0xbdf43[_0x23f874++]=t[i(765)](t[i(1798)](63,_0x3a189e),128)}function d(i){let t=n;return e.IDyNk(e[t(1147)](Array,8).join("0"),e.Ezrwt(parseInt,i,10)[t(1375)](2))[t(806)](-8)}function u(i){let t=n;return(e[t(809)](Array,4)[t(577)]("0")+parseInt(i,2)[t(1375)](16))[t(806)](-4)}function f(i){let t=n,r=i[t(1771)](/\./)[t(748)](g=>d(g)),c=[];return c[0]=e[t(1500)](u,e[t(413)](r[0],r[1])),c[1]=e[t(531)](u,e.lAZbk(r[2],r[3])),[e[t(1448)],t(742),t(742),t(742),e.rWqXI,e[t(1970)],c[0],c[1]].join("")}function p(i){let t=n,r=/(25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?)(\.(25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?)){3}/.test(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(1257)](i);return r?e.LdaAQ(f,i):c?h(i):e[t(1599)]}function h(i){let t=n,r={BTXeT:e[t(899)],wcLWV:e[t(1286)],PeClb:function(c,x){return e[t(1209)](c,x)},GdSkU:function(c,x){return c===x},awSmb:function(c,x){return c&x},fKHjc:function(c,x){return c+x},wsibo:function(c,x){return e[t(903)](c,x)},nBBeA:function(c,x){return c-x}};if(e[t(634)](e[t(1726)],e[t(1867)]))this["_pingLos"+t(1539)]?.[t(668)](),this[t(1033)](r[t(1227)],r[t(543)]),this[t(1142)+t(1539)]?.[t(665)+t(1323)+"nt"]()?this[t(1498)+t(1782)]():this[t(539)]();else{let c="",x=[],g=0,m=0,_=!0,l=e[t(1448)];if(e[t(628)](i[t(835)]("::"),-1)){let S=i[t(1771)]("::");for(let P=0;e[t(1209)](P,S[t(509)]);P++)if(e.lLjfj(e[t(1751)],e[t(1434)])){let R=S[P];if(R[t(835)](":")>0)if(e[t(1951)](e[t(572)],e[t(572)]))_0x5867db=_0x556c8f[t(1752)+"At"](_0x2a8e8d),_0x2a4fba<128?_0x4b1ab0+=1:r[t(448)](_0x55bf72,2048)?_0x1c60cc+=2:r[t(684)](64512&_0x53be7f,55296)&&r[t(461)](64512,_0x517421.charCodeAt(r[t(1349)](_0x2979f6,1)))===56320?(++_0x2300da,_0x1cc05a+=4):_0x44628c+=3;else{let B=R[t(1771)](":");_&&(g=B[t(509)]),m+=B.length;for(let z=0;e[t(787)](z,B[t(509)]);z++)if(e[t(1951)](4,B[z][t(509)])){let ee=l.substring(0,e[t(1633)](4,B[z][t(509)])),Z=ee[t(608)](B[z]);x[t(946)](Z)}else x[t(946)](B[z]);_=!1}else{if(e[t(923)](4,R[t(509)])){let B=l[t(1339)+"g"](0,4-R[t(509)]),z=B[t(608)](R);x[t(946)](z)}else x[t(946)](R);_&&(g+=1),m+=1,_=!1}}else return this._socket[t(1420)];let v="";for(let P=0;e[t(576)](P,e[t(1075)](8,m));P++)v=v.concat(l);for(let P=0;P<x[t(509)];P++)e[t(831)](P,g)&&(c=c[t(608)](v)),c=c.concat(x[P]);return c}if(e[t(1951)](e[t(1232)],e[t(1232)])){let S=_0x560ae8[t(1771)](":");_0x74e37b&&(_0x2c7056=S.length),_0x233f73+=S[t(509)];for(let v=0;r[t(448)](v,S[t(509)]);v++)if(r[t(793)](4,S[v][t(509)])){let P=_0x47dafd[t(1339)+"g"](0,r[t(2001)](4,S[v][t(509)])),R=P[t(608)](S[v]);_0x111678[t(946)](R)}else _0x27d4a[t(946)](S[v]);_0x37354b=!1}else{let S=i[t(1771)](":");for(let v=0;e[t(801)](v,S.length);v++){let P=S[v];if(e[t(1376)](4,S[v][t(509)]))if(e[t(903)](e[t(1088)],e[t(1088)])){this["_destroy"+t(1043)+"t"]();let R=_0x2e82f7(e[t(1383)],{message:e[t(412)]});this[t(1665)+t(1038)+t(1356)+"ct"]&&this["onStopImmediatel"+t(1356)+"ct"](R)}else{let R=l[t(1339)+"g"](0,e[t(1633)](4,S[v][t(509)])),B=R[t(608)](P);c=c[t(608)](B)}else c=c.concat(P)}return c}}}function y(i,t){let r=n,c=i.key;e.GFyHz(void 0,c)&&(e.KsMJu(X,t,10),e[r(786)](pe,t,c));let x=i[r(1651)];e.ZFtDT(void 0,x)&&(e[r(786)](X,t,18),e[r(786)](pe,t,x))}function w(i){let t=n,r={};e:for(;!we(i);){let c=e[t(1365)](Q,i);switch(e.WDoiP(c,3)){case 0:break e;case 1:r[t(1183)]=e[t(771)](te,i,e[t(1421)](Q,i));break;case 2:r[t(1651)]=e[t(1779)](te,i,e[t(1548)](Q,i));break;default:e[t(817)]($,i,e.xRvhp(7,c))}}if(r[t(1183)]===void 0)throw new Error(e[t(1893)]);if(r[t(1651)]===void 0)throw new Error(e[t(1295)]);return r}function A(i){let t=n,r=e[t(789)](W);return e[t(1330)](I,i,r),e[t(1996)](ke,r)}function I(i,t){let r=n,c=i[r(1634)];e[r(1376)](void 0,c)&&(X(t,8),e[r(817)](J,t,c));let x=i.LogID;e[r(1376)](void 0,x)&&(X(t,16),e[r(771)](J,t,x));let g=i.service;e[r(862)](void 0,g)&&(e[r(1779)](X,t,24),e[r(1594)](J,t,H(g)));let m=i[r(1483)];m!==void 0&&(X(t,32),e[r(1715)](J,t,H(m)));let _=i.headers;if(e[r(928)](void 0,_))for(let ee of _){X(t,42);let Z=e[r(594)](W);e.updFo(y,ee,Z),e[r(416)](X,t,Z[r(1252)]),Ke(t,Z),e[r(1282)](ge,Z)}let l=i[r(712)+"ncoding"];e[r(1376)](void 0,l)&&(e[r(1590)](X,t,50),pe(t,l));let S=i[r(1994)+r(875)];e.XfPCr(void 0,S)&&(e[r(1779)](X,t,58),pe(t,S));let v=i[r(426)];e[r(1376)](void 0,v)&&(e[r(1590)](X,t,66),e[r(1330)](X,t,v[r(509)]),ye(t,v));let P=i.LogIDNew;e[r(1108)](void 0,P)&&(X(t,74),e[r(1204)](pe,t,P));let R=i[r(1362)+"ming"];e.iFFFH(void 0,R)&&(e.ozKoA(X,t,82),e[r(1768)](pe,t,R));let B=i[r(1931)];e[r(1108)](void 0,B)&&(e[r(1743)](X,t,90),e[r(1430)](pe,t,B));let z=i[r(1775)+"e"];e[r(903)](void 0,z)&&(e[r(1204)](X,t,96),e[r(1264)](J,t,e[r(1110)](H,z)))}function E(i){return k(e[n(1692)](_e,i))}function k(i){let t=n,r={};e:for(;!e[t(1365)](we,i);){let c=e[t(1689)](Q,i);switch(e[t(1836)](c,3)){case 0:break e;case 1:r[t(1634)]=ut(i,!0);break;case 2:r[t(1014)]=ut(i,!0);break;case 3:r[t(1367)]=e[t(1487)](Q,i);break;case 4:r[t(1483)]=e[t(409)](Q,i);break;case 5:{let x=L(i);(r.headers||(r[t(1495)]=[]))[t(946)](e[t(531)](w,i)),i[t(1252)]=x;break}case 6:r["payloadE"+t(1258)]=e[t(849)](te,i,Q(i));break;case 7:r[t(1994)+"ype"]=e[t(1743)](te,i,e.dFiHg(Q,i));break;case 8:r[t(426)]=e[t(1862)](F,i,e[t(689)](Q,i));break;case 9:r[t(1755)]=e[t(666)](te,i,e[t(1876)](Q,i));break;case 10:r[t(1362)+t(1658)]=e[t(1304)](te,i,e[t(1421)](Q,i));break;case 11:r[t(1931)]=e.bEgbf(te,i,e.HstUi(Q,i));break;case 12:r[t(1775)+"e"]=e.phlFb(Q,i);break;default:$(i,7&c)}}if(e[t(634)](void 0,r[t(1634)]))throw new Error("Missing required field: "+t(1634));if(r[t(1014)]===void 0)throw new Error("Missing required"+t(1299)+t(1014));if(e[t(1939)](void 0,r[t(1367)]))throw new Error(e[t(1592)]);if(e.OpRyU(void 0,r[t(1483)]))throw new Error(e[t(454)]);return r}function L(i){let t=n,r=e[t(1692)](Q,i),c=i.limit;return i[t(1252)]=i[t(682)]+r,c}function $(i,t){let r=n;if(e.JJgQj(e[r(580)],e[r(1401)]))switch(t){case 0:for(;e[r(1461)](128,e.REdcU(ie,i)););break;case 2:e[r(1278)](de,i,e[r(1996)](Q,i));break;case 5:e.JhLtu(de,i,4);break;case 1:e.BfCor(de,i,8);break;default:throw new Error(e[r(413)](e[r(1094)],t))}else return _0x310026[r(1947)]||_0x4cfc6a[r(1859)]?(r(518)+" "+(_0x559b5f[r(1947)]||"")+r(887)+(_0x13a61b[r(1859)]||""))[r(414)]():_0x4d2823[r(1419)+"y"](_0x260283)}function H(i){let t=n;return i|=0,{low:i,high:e[t(1435)](i,31),unsigned:e[t(760)](i,0)}}let ae=[];function W(){let i=n;if(e[i(985)](e.myLzc,e[i(865)])){let t=ae[i(847)]();return t?(t[i(682)]=t[i(1252)]=0,t):{bytes:new Uint8Array(64),offset:0,limit:0}}else _0x586084(_0x3a18bf,this["_getInte"+i(1318)+"e"](_0x6fb0b4))}function ge(i){ae[n(946)](i)}function _e(i){return{bytes:i,offset:0,limit:i[n(509)]}}function ke(i){let t=n,r=i[t(1527)],c=i.limit;return r.length===c?r:r[t(1456)](0,c)}function de(i,t){let r=n;if(e[r(792)](e[r(1513)](i[r(682)],t),i[r(1252)]))throw new Error(e[r(934)]);i[r(682)]+=t}function we(i){let t=n;return e[t(907)](i.offset,i[t(1252)])}function T(i,t){let r=n,c=i[r(1527)],x=i.offset,g=i[r(1252)],m=e[r(1513)](x,t);if(e.TsCkM(m,c[r(509)])){let _=new Uint8Array(2*m);_[r(1593)](c),i.bytes=_}return i[r(682)]=m,e.pULyc(m,g)&&(i[r(1252)]=m),x}function O(i,t){let r=n,c=i[r(682)];if(e[r(988)](e[r(1713)](c,t),i[r(1252)]))throw new Error(e[r(1742)]);return i[r(682)]+=t,c}function F(i,t){let r=n,c=e.CILPx(O,i,t);return i[r(1527)].subarray(c,e[r(413)](c,t))}function ye(i,t){let r=n,c={cPmMw:function(x,g){return e[M(1836)](x,g)},MvAUB:function(x,g){return x<<g}};if(e[r(1363)](e[r(1130)],r(1402))){let x=0,g=_0x43055b,m=_0x472a01+4;for(;g<m;){let{value:_,offset:l}=_0x22440a(_0x4265c1,g);g=l,x=c.cPmMw(c[r(1289)](x,8),0),x+=_}return{value:x,offset:m}}else{let x=e[r(1206)](T,i,t.length);i[r(1527)][r(1593)](t,x)}}function te(i,t){let r=n,c={IGFaw:function(S,v,P){return e[M(598)](S,v,P)},AwidG:function(S,v){return S*v}},x=e[r(1715)](O,i,t),g=String.fromCharCode,m=i.bytes,_="\uFFFD",l="";for(let S=0;e[r(486)](S,t);S++){let v=m[e[r(1713)](S,x)],P,R,B,z;if(e[r(980)](e[r(494)](128,v),0))l+=e[r(689)](g,v);else if(e[r(1875)](224,v)===192)e[r(760)](e[r(975)](S,1),t)?l+=_:(P=m[e.IDyNk(e.yhaFj(S,x),1)],e[r(1017)](192,P)!==128?l+=_:(z=e[r(541)](e[r(1149)](e[r(922)](31,v),6),e[r(494)](63,P)),e[r(801)](z,128)?l+=_:(l+=e[r(1689)](g,z),S++)));else if(e[r(1231)](240&v,224))e[r(456)](S,2)>=t?l+=_:(P=m[e.FRIIK(S+x,1)],R=m[e[r(1513)](e[r(456)](S,x),2)],e.ouLDD(e[r(1332)](P|R<<8,49344),32896)?l+=_:e.cTmMO(e[r(1668)],e[r(1391)])?(_0x57255d(_0x29bae2,90),UVirtu.IGFaw(_0x3c6eb3,_0xe83c39,_0x3381a8)):(z=e[r(446)](e.dejvK(15,v)<<12|e[r(1983)](63&P,6),e[r(1461)](63,R)),z<2048||e[r(907)](z,55296)&&e[r(1691)](z,57343)?l+=_:(l+=e.TcYcb(g,z),S+=2)));else if(e[r(859)](248,v)==240)if(e[r(1620)](S,3)>=t)l+=_;else if(e.pGmhy(e[r(1725)],e[r(1725)]))P=m[e[r(1620)](e[r(1736)](S,x),1)],R=m[e[r(1620)](e[r(1736)](S,x),2)],B=m[e[r(1416)](S,x)+3],e[r(589)](e[r(446)](e.Dglrt(P,e[r(1073)](R,8)),e[r(1766)](B,16)),12632256)!==8421504?l+=_:(z=e.Dglrt(e[r(1553)](e.LwVHw(e[r(884)](7,v),18),e[r(1983)](e[r(1187)](63,P),12)),(63&R)<<6)|e[r(494)](63,B),z<65536||e[r(843)](z,1114111)?l+=_:(z-=65536,l+=e[r(1206)](g,e[r(563)](e[r(1435)](z,10),55296),e[r(1736)](e[r(1235)](1023,z),56320)),S+=3));else{let ee=new _0x1a2b15(UVirtu[r(1129)](2,_0x3df71a));ee[r(1593)](_0x117a82),_0x2264d0[r(1527)]=ee}else l+=_}return l}function pe(i,t){let r=n;if(e.VLeWI(e.FkYTn,e[r(1976)])){let c=t[r(509)],x=0;for(let _=0;e[r(1801)](_,c);_++){let l=t.charCodeAt(_);e[r(907)](l,55296)&&e[r(1533)](l,56319)&&e[r(1866)](e[r(456)](_,1),c)&&(l=e.FgSRc(e.WNtui(l,10),t[r(1752)+"At"](++_))-56613888),x+=e[r(1209)](l,128)?1:e[r(787)](l,2048)?2:e[r(801)](l,65536)?3:4}X(i,x);let g=e[r(1594)](T,i,x),m=i[r(1527)];for(let _=0;e[r(1866)](_,c);_++){let l=t[r(1752)+"At"](_);e[r(760)](l,55296)&&e[r(1691)](l,56319)&&e[r(1457)](_+1,c)&&(l=e.cOsph(e[r(1713)](e[r(761)](l,10),t[r(1752)+"At"](++_)),56613888)),e.kOoEA(l,128)?m[g++]=l:(e[r(1224)](l,2048)?m[g++]=e[r(1238)](e[r(1387)](l,6),31)|192:(l<65536?m[g++]=e[r(541)](e[r(1638)](l,12)&15,224):(m[g++]=e.PvUIF(e[r(1281)](l>>18,7),240),m[g++]=e[r(1332)](l>>12,63)|128),m[g++]=e.ATyGM(e.tRqjG(l,6)&63,128)),m[g++]=e.Dglrt(e[r(606)](63,l),128))}}else _0x4e3c9e.body[r(1002)+r(1519)](_0x18fd9b)}function Ke(i,t){let r=n,c=e[r(666)](T,i,t[r(1252)]),x=i[r(1527)],g=t.bytes;for(let m=0,_=t[r(1252)];e[r(936)](m,_);m++)x[e[r(1620)](m,c)]=g[m]}function ie(i){return i[n(1527)][O(i,1)]}function Qe(i,t){let r=T(i,1);i.bytes[r]=t}function Q(i){let t=n,r={ElPEQ:function(c,x){return e[M(760)](c,x)},UcLQn:function(c,x){return e[M(661)](c,x)}};if(e.dQIXh===e[t(1322)]){let c=0,x=0,g;do if(e[t(1376)](e[t(1932)],e[t(1932)])){if(_0x219b10<=-_0x21ca34)return _0x172e31;if(r[t(1624)](r[t(860)](_0x13ac79,1),_0x31df11))return _0x73b038}else g=e[t(1876)](ie,i),e[t(1801)](c,32)&&(x|=e[t(1246)](e[t(605)](127,g),c)),c+=7;while(e.aydTd(128,g));return x}else _0x226e6e<2048?_0x3af9c8[_0x3b69a6++]=e[t(1172)](e[t(606)](_0x152012>>6,31),192):(e[t(1848)](_0x22de5e,65536)?_0x40f65a[_0x440a3c++]=e.AfTEq(e[t(922)](e.NzpwO(_0x2b3efe,12),15),224):(_0x4a83fc[_0x42d806++]=e.jnIcs(e[t(1187)](e[t(1922)](_0xbc7599,18),7),240),_0x4e3e7e[_0x22952a++]=e.VakBz(e[t(1387)](_0xa46582,12)&63,128)),_0x345f67[_0x236aa0++]=e[t(708)](e.dYUKW(_0x200ba9,6),63)|128),_0x295d99[_0x3b5825++]=e[t(446)](63&_0xa069ea,128)}function X(i,t){let r=n,c={PbHTs:function(x,g,m){return e[M(774)](x,g,m)},jczMr:function(x,g){return x+g},mwpXS:function(x,g){return e[M(917)](x,g)},NdWxx:function(x,g){return e[M(821)](x,g)},oUoNX:function(x,g){return x&g}};for(t>>>=0;t>=128;)e[r(634)](e[r(1392)],e.PZwTq)?(e[r(1856)](Qe,i,e[r(446)](e[r(1826)](127,t),128)),t>>>=7):(_0xde23c0-=65536,_0x4ce232+=EZwYnf.PbHTs(_0x4d18a4,EZwYnf[r(1158)](EZwYnf[r(619)](_0x348d7a,10),55296),EZwYnf.NdWxx(EZwYnf[r(1788)](1023,_0x47a189),56320)),_0x503812+=3);e[r(1296)](Qe,i,t)}function ut(i,t){let r=n;if(e[r(493)]===r(1510))return this._isMiniTT||this[r(1979)+"X"]?this["_miniNav"+r(851)+r(1678)]:(this[r(614)+"er"]||this._isWorker)&&this[r(918)][r(610)+r(768)+r(1504)]?_0x5627b6.onLine:!0;{let c=0,x=0,g=0,m;return m=ie(i),c=e.twlFK(127,m),e[r(957)](128,m)&&(m=ie(i),c|=e[r(1544)](e.SlHtm(127,m),7),e[r(1281)](128,m)&&(m=e[r(1853)](ie,i),c|=e[r(1085)](127&m,14),e[r(957)](128,m)&&(m=e[r(645)](ie,i),c|=e[r(1073)](e.nzqgs(127,m),21),e[r(1855)](128,m)&&(m=e[r(1433)](ie,i),x=127&m,e.WWQNC(128,m)&&(m=e[r(1996)](ie,i),x|=e.nQDZw(e[r(691)](127,m),7),e[r(708)](128,m)&&(m=e.SrDMT(ie,i),x|=e[r(1246)](127&m,14),e[r(1749)](128,m)&&(m=e[r(1226)](ie,i),x|=e[r(1085)](e[r(1505)](127,m),21),128&m&&(m=e[r(623)](ie,i),g=127&m,e[r(1281)](128,m)&&(m=e[r(520)](ie,i),g|=e[r(1944)](e.nzqgs(127,m),7)))))))))),{low:c|e.SGJYF(x,28),high:e[r(1716)](e.rgAPE(x,4),g<<24),unsigned:t}}}function J(i,t){let r=n,c=t[r(1700)]>>>0,x=e[r(901)](e.wKemu(e[r(1836)](t[r(1700)],28),e[r(1149)](t[r(1244)],4)),0),g=e.WDoiP(t[r(1244)],24),m=g===0?e[r(1363)](0,x)?e[r(595)](c,16384)?e.mBRqX(c,128)?1:2:e.XKXOY(c,2097152)?3:4:e[r(1866)](x,16384)?e[r(1866)](x,128)?5:6:e[r(929)](x,2097152)?7:8:e[r(576)](g,128)?9:10,_=T(i,m),l=i.bytes;switch(m){case 10:l[e.jLusN(_,9)]=e[r(1826)](e[r(1717)](g,7),1);case 9:l[e.FgSRc(_,8)]=m!==9?e[r(1684)](128,g):127&g;case 8:l[_+7]=m!==8?e[r(1836)](x,21)|128:e[r(889)](x>>>21,127);case 7:l[e[r(1925)](_,6)]=e.XfPCr(7,m)?e.CvzJR(e[r(1071)](x,14),128):e.twlFK(x>>>14,127);case 6:l[e[r(1347)](_,5)]=e.JJgQj(6,m)?e.jnIcs(e[r(818)](x,7),128):e.USLTu(e[r(818)](x,7),127);case 5:l[e[r(1124)](_,4)]=e[r(960)](5,m)?e.MGaIH(128,x):e.TkRDF(127,x);case 4:l[e.lbiZj(_,3)]=e.taufy(4,m)?e[r(706)](e[r(1071)](c,21),128):e.aZOhP(e.rgAPE(c,21),127);case 3:l[e[r(975)](_,2)]=e[r(618)](3,m)?e[r(1004)](e[r(1168)](c,14),128):e.kVUGu(e.ayjzc(c,14),127);case 2:l[e.mPfEg(_,1)]=e[r(492)](2,m)?e[r(1797)](c,7)|128:e[r(663)](e.ZPNyb(c,7),127);case 1:l[_]=e[r(923)](1,m)?e[r(1663)](128,c):e.qMXNZ(127,c)}}function _t(i){return e.CBHzE(E,i)}function se(i){let t=n;if(e[t(928)](e.aUupD,e.aUupD))for(var r in _0x53b864)_0x568322.o(_0x4194af,r)&&!_0x5da823.o(_0x34e6de,r)&&_0x4fb2cd["definePr"+t(1891)](_0x18d2c0,r,{enumerable:!0,get:_0xd8d1c3[r]});else return e[t(1996)](A,i)}let yt=65536,be=n(1188),bt=e[n(1316)](yt,yt),Xi=e[n(650)](bt,bt),Yi=e[n(1169)](Xi,2),et=String.prototype[n(1752)+"At"];class K{constructor(t,r,c){let x=n;this[x(1837)]=!0,this[x(1700)]=e[x(446)](0,t),this[x(1244)]=0|r,this[x(1975)]=!!c}static[n(1837)](t){let r=n;if(e[r(923)](r(603),e[r(1905)]))_0x39d1e8[r(439)+r(1946)]="",_0x27ab7f.log(_0x3cdead);else return t&&t[r(1837)]===!0}static[n(1649)](t,r,c){return new K(t,r,c)}static[n(1838)+"s"](t,r,c){let x=n;return c?K["fromByte"+x(1035)](t,r):K[x(1838)+x(888)](t,r)}static[n(1838)+"sLE"](t,r){let c=n;return new K(e[c(1716)](e[c(662)](t[0]|e[c(1077)](t[1],8),e[c(1410)](t[2],16)),e.lsFqF(t[3],24)),e.AfTEq(t[4],e[c(1246)](t[5],8))|e[c(1007)](t[6],16)|e[c(1983)](t[7],24),r)}static["fromByte"+n(888)](t,r){let c=n;return new K(e[c(1716)](e[c(1716)](t[4]<<24|e[c(1766)](t[5],16),t[6]<<8),t[7]),e[c(662)](e.wKemu(e[c(1544)](t[0],24)|t[1]<<16,e.lnWvb(t[2],8)),t[3]),r)}static fromHash(t){let r=n;return e[r(980)](t,be)?Zi:new K(e.WDoiP(e[r(1029)](e.VakBz(et.call(t,0),e[r(955)](et[r(1352)](t,1),8))|e.skGVH(et[r(1352)](t,2),16),et.call(t,3)<<24),0),e[r(1245)](e[r(706)](e[r(931)](et[r(1352)](t,4),e[r(1e3)](et.call(t,5),8)),e[r(1152)](et[r(1352)](t,6),16))|e[r(1766)](et.call(t,7),24),0),!0)}[n(612)](){let t=n;if(e.TkcwX(e[t(1847)],e[t(927)])){let r={onjII:function(c,x){return c(x)}};return function(...c){let x=t;return _0x5859ad[x(1714)](r[x(1811)](_0x486856,this),c),r[x(1811)](_0x1107ee,_0x36e0d7.get(this))}}else return String[t(1710)+t(1382)](e[t(1769)](255,this[t(1700)]),e[t(1233)](e.OTbOc(this[t(1700)],8),255),e[t(1698)](e[t(1552)](this[t(1700)],16),255),e[t(1270)](this.low,24),e[t(460)](255,this[t(1244)]),e[t(1749)](e[t(901)](this[t(1244)],8),255),this[t(1244)]>>>16&255,e[t(1099)](this[t(1244)],24))}static[n(1198)+"er"](t,r=!0){let c=n;if(e[c(752)](isNaN,t))return r?Yc:Zi;if(r){if(e.WGXPN(t,Xi))return Qc}else{if(e[c(1567)]!==e.GcHCX)return this[c(458)][c(1049)+"pe"];if(e[c(1533)](t,-Yi))return e0;if(e[c(637)](e[c(546)](t,1),Yi))return Zc}return K[c(1649)](e[c(1553)](e[c(1138)](t,bt),0),e[c(1949)](t/bt,0),r)}[n(578)](){let t=n;return this.unsigned?e[t(1312)](this[t(1244)]>>>0,bt)+e[t(627)](this[t(1700)],0):this[t(1244)]*bt+e[t(1114)](this[t(1700)],0)}isZero(){let t=n,r={XXtui:function(c,x,g){return c(x,g)}};if(e[t(1397)]===t(1572)){let c=pOPjzK[t(1669)](_0x3834e1,_0x4079e2,_0x417a58[t(509)]);_0x398f0e.bytes[t(1593)](_0x4bad2b,c)}else return e.ySuAY(0,this[t(1244)])&&e[t(1324)](0,this[t(1700)])}[n(1696)](t){let r=n,c={bYqbZ:function(x,g){return x==g},lFxpz:e[r(1106)]};if(e[r(675)](e[r(1585)],r(632)))return c.bYqbZ(c[r(1493)],typeof _0x4e451c)?r(1627)+r(820)+"et=utf-8":"";{K[r(1837)](t)||(t=K[r(1198)+"er"](t));let x=this[r(1244)]>>>16,g=e[r(1087)](65535,this.high),m=this.low>>>16,_=e[r(535)](65535,this.low),l=e[r(627)](t[r(1244)],16),S=65535&t[r(1244)],v=e[r(442)](t[r(1700)],16),P=e[r(1826)](65535,t[r(1700)]),R=0,B=0,z=0,ee=0;return ee+=e[r(1236)](_,P),z+=ee>>>16,ee&=65535,z+=e[r(874)](m,v),B+=e.hmvLw(z,16),z&=65535,B+=e[r(456)](g,S),R+=e.BCjdc(B,16),B&=65535,R+=x+l,R&=65535,K[r(1649)](e[r(706)](e[r(503)](z,16),ee),R<<16|B,this.unsigned)}}[n(451)](t){let r=n;if(e[r(1076)](e.wZodU,e[r(1263)])){let c=this[r(1008)+"tManager"]?.[r(1329)+r(997)+"nt"]();this[r(1942)+r(804)+r(590)](e[r(1278)](_0x5f323b,e[r(915)],{code:_0x271ee7[r(767)],reason:r(1854)+r(510)+"d, unknown reaso"+r(1712)+r(561)+c})),this[r(1008)+r(1426)]?.[r(1971)+r(1618)+r(893)](),this[r(1142)+r(1539)]?.[r(473)+r(453)]();return}else return K.isLong(t)||(t=K[r(1198)+"er"](t)),e[r(476)](this[r(1975)],t.unsigned)&&e[r(1924)](e.zRZhk(this[r(1244)],31),1)&&e[r(1406)](t.high>>>31,1)?!1:e[r(519)](this[r(1244)],t.high)&&this.low===t[r(1700)]}[n(658)](){let t=n;return e[t(1939)](-1,this[t(1700)])&&this[t(1244)]===-1?K[t(1649)](0,0,this.unsigned):e[t(1126)](-1,this[t(1700)])?K[t(1649)](0,this[t(1244)]+1,this[t(1975)]):K[t(1649)](e[t(1744)](this[t(1700)],1),this[t(1244)],this[t(1975)])}[n(1936)](t){let r=n,c={YGqaY:function(g,m,_,l){return e[M(1789)](g,m,_,l)}};if(e[r(850)]!==e.XAsyP)for(var x in _0x5b0d5f)XPKIRJ[r(1820)](_0x300274,_0x5d83fb,x,{get:_0x10eeba[x],enumerable:!0});else return t?this[r(1161)+"E"]():this[r(1542)+"E"]()}toBytesLE(){let t=n,r=this[t(1244)],c=this[t(1700)];return[e[t(733)](255,c),e.IDFVP(c>>>8,255),e.BCjdc(c,16)&255,e[t(1027)](c,24),e[t(1368)](255,r),e[t(1717)](r,8)&255,e[t(1054)](e[t(627)](r,16),255),e[t(1099)](r,24)]}[n(1542)+"E"](){let t=n;if(e[t(1473)](e[t(1143)],e[t(1143)])){let r=this[t(1244)],c=this.low;return[r>>>24,e.zRZhk(r,16)&255,e[t(1878)](e[t(1442)](r,8),255),e[t(889)](255,r),e[t(1114)](c,24),e[t(1992)](c,16)&255,e.Qvrvp(e[t(880)](c,8),255),255&c]}else this[t(614)+"er"]&&_0x22cda1[t(1210)+t(607)+t(622)](e.vVSLh,this[t(1952)+t(1343)]),this._isBrowser&&_0xe415a7[t(1210)+"entListe"+t(622)](e.phcDk,this._handlePageShow),this.close()}}let Zi=new K(0,0,!1),Yc=new K(0,0,!0),Zc=K.fromBits(-1,2147483647,!1),Qc=K.fromBits(-1,-1,!0),e0=K[n(1649)](0,-2147483648,!1);var nt=(function(i){let t=n,r=(t(1887)+t(547))[t(1771)]("|"),c=0;for(;;){switch(r[c++]){case"0":i[i[e[t(1122)]]=5004]=e[t(1122)];continue;case"1":return i;case"2":i[i[t(1417)+"OR"]=5005]=t(1417)+"OR";continue;case"3":i[i[e[t(1409)]]=5002]=e[t(1409)];continue;case"4":i[i[e[t(1325)]]=5003]=e[t(1325)];continue;case"5":i[i[e[t(830)]]=5001]=e.npOLv;continue}break}})({});class vt{constructor(t){let r=n;this.type=t,this[r(775)]=null}}class Qi extends vt{constructor(t,r){let c=n;super(t),this[c(866)]=r&&r[c(866)]||null}}class es extends vt{constructor(t,r){let c=n;if(e[c(1864)](c(512),e[c(763)]))super(t),this[c(654)]=r&&r[c(654)]||null,this[c(1739)]=r&&r[c(1739)]||0,this.filename=r&&r[c(1205)]||"",this[c(1039)]=r&&r[c(1039)]||0,this[c(866)]=r&&r[c(866)]||"",this[c(767)]=r&&r[c(767)]||5001;else return this[c(1975)]?e.XOdBn(e[c(1312)](e[c(1797)](this.high,0),_0x2a95d4),e.Ujdht(this[c(1700)],0)):this[c(1244)]*_0x44185d+(this[c(1700)]>>>0)}}class ts extends vt{constructor(t,r){let c=n,x=e.jHLbU.split("|"),g=0;for(;;){switch(x[g++]){case"0":super(t);continue;case"1":this[c(450)+c(970)]=r&&r["willReco"+c(970)]||!1;continue;case"2":this[c(767)]=r&&r[c(767)]||0;continue;case"3":this[c(1171)]=r&&r[c(1171)]||"";continue;case"4":this[c(1034)]=r&&r[c(1034)]||!1;continue}break}}}class ns extends vt{constructor(t,r){let c=n;if(e.ySuAY("WjUnz",e[c(1981)]))super(t),this[c(1909)]=r&&r[c(1909)]||null;else{let x=_0x61b9d8[c(1339)+"g"](0,e[c(680)](4,_0x4a07ce[_0x5eb881][c(509)])),g=x[c(608)](_0x47428a);_0x1d436e=_0x4a8d21[c(608)](g)}}}class rs extends ns{constructor(t,r){let c=n;if(e[c(1458)]!==c(1120))return{bytes:_0x38b243,offset:0,limit:_0x19dec4.length};super(t),this[c(1909)]=r&&r[c(1909)]||null,this[c(866)]=r&&r.message||null}}class is extends vt{constructor(t,r){let c=n;super(t),this.data=r&&r[c(1909)]||null}}function Ie(i,{message:t,code:r,error:c}){return new es(i,{message:t,code:r,error:c})}function De(i,{code:t,reason:r,wasClean:c,willReconnect:x}){let g=n;return e[g(508)](e[g(1954)],e[g(1954)])?new ts(i,{code:t,reason:r,wasClean:c,willReconnect:x}):this[g(458)].extensions}function ss(i,{data:t,message:r}){return new rs(i,{data:t,message:r})}function os(i,{data:t}){return new is(i,{data:t})}function Lr(i,{message:t}){return new Qi(i,{message:t})}class as{constructor(t,r){let c=n;this.endpoints=t,this[c(938)+"es"]=r,this[c(982)+c(717)]=0,this[c(871)+c(758)+c(1511)+"t"]=0}[n(1971)+n(1618)+n(893)](){let t=n;this[t(982)+t(717)]=0,this[t(871)+t(758)+t(1511)+"t"]=0}[n(1026)+"es"](){let t=n;e[t(913)](e[t(990)],e[t(990)])?this[t(871)+t(758)+t(1511)+"t"]=0:(e[t(666)](_0x3a2e38,_0x566bf4,18),e.ASVEW(_0x56c960,_0x10aaa1,_0x4db5c5))}[n(1329)+"ntEndpoint"](){let t=n;return this[t(1851)+"s"][this[t(982)+t(717)]]}["getCurre"+n(997)+n(1403)+n(764)](){let t=n;return this[t(871)+"ndpointT"+t(1511)+"t"]}[n(665)+n(1606)+"es"](){let t=n;return!!(e[t(760)](this[t(982)+t(717)],this[t(1851)+"s"][t(509)])||this[t(982)+t(717)]===e[t(1075)](this.endpoints[t(509)],1)&&e[t(831)](this["currentE"+t(758)+"riesCount"],this[t(938)+"es"]))}[n(1882)+"rentEndp"+n(799)+n(415)+n(1562)](){let t=n;return e.NKUyg(this[t(982)+t(717)],this[t(1851)+"s"][t(509)])?!0:e[t(1234)](this["currentEndpointT"+t(1511)+"t"],this[t(938)+"es"])}[n(624)+n(1986)+n(1466)+n(969)+n(1048)](){let t=n;return this[t(871)+"ndpointT"+t(1511)+"t"]=1,this["currentI"+t(717)]++,this[t(1851)+"s"][this[t(982)+t(717)]]}[n(1329)+n(997)+n(1113)+n(1655)](){let t=n;return this[t(871)+"ndpointT"+t(1511)+"t"]++,this.getCurrentEndpoint()}}let St=(e[n(1203)]!=typeof globalThis&&e.lneoT===globalThis[n(1517)+"tor"].name||e[n(1821)](e[n(1203)],typeof window)&&e[n(549)]===window[n(1517)+"tor"][n(978)])&&e.haNxc(e[n(1203)],typeof document),ft=n(1881)+"d"!=typeof globalThis&&(e[n(1967)](e[n(1167)],globalThis[n(1517)+"tor"][n(978)])||e[n(870)](e[n(573)],globalThis[n(1517)+"tor"][n(978)]))&&e[n(839)](e[n(1203)],typeof tt),$t=(e.aKVxu(n(1881)+"d",typeof globalThis)&&e[n(968)](n(1222),globalThis.constructor[n(978)])||e[n(1203)]==typeof globalThis||e[n(1821)](e[n(1203)],typeof globalThis)&&!!globalThis[n(1783)+n(704)])&&e[n(1090)](e[n(1203)],typeof wx),Jt=n(1881)+"d"!=typeof globalThis&&(e.iVFzT===globalThis[n(1517)+n(1404)].name||e[n(952)](e[n(1852)],globalThis[n(1517)+n(1404)].name)||e[n(1911)](e.UCkan,globalThis["construc"+n(1404)].name))&&e[n(1857)](e.XnJMd,typeof self),t0=e[n(522)](e[n(1203)],typeof globalThis)&&e.tJYsc(e[n(1167)],globalThis[n(1517)+"tor"][n(978)])&&e.LCssE(n(1881)+"d",typeof global)&&e.xeTDk(e[n(1167)],global[n(1517)+"tor"][n(978)])&&e.haNxc("undefined",typeof process)&&!!process[n(1079)];class Mr{constructor(){let t=n;this[t(1731)+"rs"]={}}[n(1033)](t,...r){let c=n,x=this._listeners[t];if(x)x.slice()[c(1644)](g=>g.fn[c(1714)](g[c(1550)],r));else if(e[c(831)](e[c(1617)],t)&&!this[c(1760)]){let g=r[c(509)]&&r[0];if(e.ueqII(g,Error))throw g;let m=new Error(e[c(1160)](c(1697)+c(490),g?e[c(1459)](e[c(896)](" (",g[c(866)]),")"):""));throw m[c(1314)]=g,g}return this}off(t,r){let c=n;if(e[c(500)](void 0,t))this[c(1731)+"rs"]={};else if(e.QvnFD(void 0,r))this[c(1731)+"rs"][t]=null;else if(c(1202)===e[c(1306)]){let x=e[c(1200)](255,_0x22099b);_0x25e0dd(x,_0x3228d0,_0x4f84e0+_0x4e3c6c),_0x29da5b>>>=8,_0x104e98--}else{let x=this._listeners[t];if(x)for(let g=0;e[c(595)](g,x[c(509)]);)x[g].fn===r?x[c(559)](g,1):++g}return this}on(t,r,c){let x=n;return(this._listeners[t]||(this[x(1731)+"rs"][t]=[]))[x(946)]({fn:r,ctx:c||this}),this}}class n0 extends Mr{[n(1164)+n(1919)+n(1541)](t){let r=n;return t[r(1947)]||t[r(1859)]?(r(518)+" "+(t.errMsg||"")+r(887)+(t.errNo||"")).trim():JSON.stringify(t)}constructor(t,r,c){let x=n;super(),this[x(458)]=null,$t&&wx.connectSocket&&(this[x(458)]=wx[x(422)+x(1062)]({url:t,protocols:r,header:c,fail:this["_createSocketFai"+x(1373)][x(935)](this),success:this[x(1145)+x(1758)+"cessHand"+x(469)].bind(this)})),ft&&tt["connectS"+x(1062)]&&(this[x(458)]=tt[x(422)+x(1062)]({url:t,protocols:r,header:c,fail:this["_createSocketFai"+x(1373)][x(935)](this),success:this["_createSocketSuc"+x(1781)+"ler"][x(935)](this)}))}[n(1145)+n(1758)+"cessHand"+n(469)](){let t=n;Promise[t(1431)]()[t(498)](()=>{let r=t,c={iGgwB:function(x,g){return e.WGXPN(x,g)},jezAz:function(x,g){return e[M(846)](x,g)},RXtrH:function(x,g){return e[M(1945)](x,g)},sbbkn:function(x,g){return e.yhaFj(x,g)},weRvn:function(x,g){return e[M(1575)](x,g)},xukSA:function(x,g){return e[M(1846)](x,g)},xcyRl:function(x,g){return x<g},HPWxf:function(x,g){return e.dIIqg(x,g)},joybC:function(x,g){return x&g},pUxLg:function(x,g){return e.NzpwO(x,g)},snenG:function(x,g){return x|g},eOrqb:function(x,g){return e[M(678)](x,g)},ccfry:function(x,g){return e[M(1387)](x,g)},mDmiH:function(x,g){return e.idFGr(x,g)},IdMlz:function(x,g){return e[M(1748)](x,g)},cXDsC:function(x,g){return e[M(1292)](x,g)}};if(e[r(1671)]!=="qYkxC"){let x=_0x14bf4c[r(1752)+"At"](_0xf335bf);wgwdPj[r(885)](x,55296)&&wgwdPj[r(703)](x,56319)&&wgwdPj[r(1642)](wgwdPj[r(652)](_0x34fd17,1),_0x19153e)&&(x=wgwdPj[r(652)](wgwdPj[r(1674)](x,10),_0x4dcd4c[r(1752)+"At"](++_0x23d7ef))-56613888),wgwdPj.xukSA(x,128)?_0x5ed61f[_0xf4e476++]=x:(wgwdPj[r(1613)](x,2048)?_0x124094[_0x1ec834++]=wgwdPj[r(751)](x>>6,31)|192:(wgwdPj[r(1642)](x,65536)?_0x1d38d1[_0x74a0df++]=wgwdPj[r(1309)](wgwdPj.pUxLg(x,12),15)|224:(_0x2b6a7d[_0x4f2d7d++]=wgwdPj[r(1850)](wgwdPj[r(1711)](wgwdPj[r(1102)](x,18),7),240),_0x15f81a[_0xa832e9++]=wgwdPj[r(636)](wgwdPj[r(1309)](x>>12,63),128)),_0x372bac[_0x5d5acf++]=wgwdPj[r(1247)](wgwdPj[r(1439)](wgwdPj.pUxLg(x,6),63),128)),_0x55eb4d[_0x4e2309++]=wgwdPj[r(636)](wgwdPj[r(1309)](63,x),128))}else this._addWsListeners()})}[n(1145)+n(1683)+n(1373)](t){let r=n,c={Hznzg:function(x,g,m){return e.cRcHd(x,g,m)},EsCfs:e[r(1617)],hafxD:e.rVsIU};e.KyWyT(e[r(1031)],e[r(1031)])?_0x1914a6[r(1431)]().then(()=>{let x=r,g=c[x(1095)](_0x59d6c6,c[x(872)],{message:this[x(1164)+"rrorMess"+x(1541)](_0x436a4e)});this[x(1033)](c[x(872)],g);let m=c[x(1095)](_0x35bf54,c.hafxD,{reason:this[x(1164)+x(1919)+x(1541)](_0x33ab27)});this.emit(c[x(641)],m)}):Promise.resolve()[r(498)](()=>{let x=r,g=e[x(1953)](Ie,e[x(1617)],{message:this[x(1164)+x(1919)+"age"](t)});this[x(1033)](x(654),g);let m=De("close",{reason:this["_formatErrorMess"+x(1541)](t)});this[x(1033)](e[x(915)],m)})}[n(556)+n(472)](){let t=n,r={jSeJg:t(538),wKKXe:function(c,x,g){return c(x,g)},KmCqZ:e[t(1424)],cCQkt:function(c,x,g){return e.vrTKT(c,x,g)}};this[t(458)].onOpen(c=>{let x=t;this[x(1033)](x(699),e[x(1304)](os,e.zXGMW,{...c,data:c[x(1947)]||""}))}),this[t(458)][t(1800)](c=>{let x=t;this[x(1033)](r[x(1913)],r[x(943)](De,r[x(1913)],{...c}))}),this._socket[t(707)+"e"](c=>{let x=t;this.emit(r[x(1065)],r[x(1460)](ss,r[x(1065)],{...c}))}),this[t(458)][t(1481)](c=>{let x=t;this.emit(x(654),e[x(1264)](Ie,e.fKVAW,{...c,message:c[x(1947)]||""}))})}send(t){let r=n,c={bEYbW:function(x,g,m){return e[M(1444)](x,g,m)},ZSIYN:e[r(1617)],ETsLc:function(x,g,m){return e.JPZUh(x,g,m)}};if(e.RbmDC(t,Uint8Array))if(e[r(1904)](r(1987),e[r(919)])){let x=t.buffer[r(806)](t[r(803)+"et"],e.FRIIK(t[r(823)+"th"],t[r(803)+"et"]));this[r(458)]&&this[r(458)].send({data:x,fail:g=>{let m=r;this[m(1033)](m(654),c.bEYbW(Ie,c.ZSIYN,{message:this["_formatE"+m(1919)+"age"](g)}))}})}else return _0x1b20ac[r(1714)](QTvxnE[r(1622)](_0xc75dc7,this),_0x52ce5f),_0x1c7fe6(_0x21327f[r(791)](this));else this[r(458)]&&this._socket[r(569)]({data:t,fail:x=>{let g=r;this[g(1033)](g(654),c[g(585)](Ie,c[g(1943)],{message:this["_formatE"+g(1919)+g(1541)](x)}))}})}[n(538)](t,r){let c=n;this._socket&&this[c(458)].close({code:t,reason:r})}[n(1614)+"Listener"](t,r){this.on(t,r)}[n(1210)+"entListe"+n(622)](t,r){this[n(1895)](t,r)}get[n(788)+"te"](){return this[n(458)].readyState}get[n(1049)+"pe"](){let t=n;return this[t(458)][t(1049)+"pe"]}set[n(1049)+"pe"](t){}get[n(1420)](){let t=n;return this[t(458)][t(1420)]}get[n(715)](){return this._socket.protocol}get[n(1089)+"ns"](){let t=n;return e[t(634)](e.hDkJk,e[t(1396)])?e[t(520)](_0x4db28b,_0x5ae5f6):this[t(458)][t(1089)+"ns"]}get[n(1516)+n(1083)](){return 0}}function r0(i,t){let r=n;if(t)return new t(i[r(1420)],i[r(715)]);if($t||ft)return new n0(i[r(1420)],i[r(715)],i[r(1495)]);if((St||Jt)&&e[r(1857)](e[r(1203)],typeof WebSocket)&&WebSocket)return new WebSocket(i[r(1420)],i[r(715)+"s"])}function i0(i){let t=n,r=e[t(1468)][t(1771)]("|"),c=0;for(;;){switch(r[c++]){case"0":if(i)return!0;continue;case"1":if(e[t(1898)](St,Jt)&&e[t(839)](e[t(1203)],typeof WebSocket)&&WebSocket)return!0;continue;case"2":return!1;case"3":if($t&&wx["connectS"+t(1062)])return!0;continue;case"4":if(ft&&tt[t(422)+t(1062)])return!0;continue}break}}function cs(i,t,r){let c=n,x={RvSNt:function(g,m){return g===m},ltBEb:function(g,m){return g+m}};if(e.cDbHt(e[c(905)],e.XPEDz))this["_navigat"+c(1966)]()&&(!this._ws||e[c(1762)](this[c(1093)][c(788)+"te"],this[c(1248)])||e[c(476)](this[c(1093)].readyState,this[c(1874)+"NG"]))&&this[c(848)+c(1561)](),this[c(614)+"er"]&&_0x40d954[c(1614)+"Listener"]("online",this[c(848)+c(1561)]),this[c(614)+"er"]&&_0x59cbd4[c(1614)+c(1955)]("offline",this["_handleO"+c(464)]);else{let g=-1;async function m(_){let l=c;return _<=g?Promise[l(958)](new Error(l(1523)+l(755)+l(956)+l(1394)+l(1370))):(g=_,x[l(1465)](_,r.length)?Promise.resolve():r[_][l(935)](i)(t,m[l(935)](null,x.ltBEb(_,1))))}e[c(713)](m,0)}}function xs(i){let t=n,r=0,c=0;for(let x=0;e[t(911)](x,i[t(509)]);++x)c=i[t(1752)+"At"](x),e.STlOM(c,128)?r+=1:c<2048?r+=2:e[t(635)](e[t(922)](64512,c),55296)&&e[t(640)](e[t(945)](64512,i.charCodeAt(x+1)),56320)?(++x,r+=4):r+=3;return r}function ds(i,t,r){let c=n;if(e[c(1633)](r,t)<1)return"";let x="";for(let g=t;e[c(787)](g,r);){let m=i[g++];if(e[c(1359)](m,127))x+=String[c(1710)+"Code"](m);else if(e[c(907)](m,192)&&e.LHEBj(m,224))x+=String[c(1710)+c(1382)](e[c(506)](e.skGVH(e[c(1054)](31,m),6),e[c(488)](63,i[g++])));else if(m>=224&&e[c(897)](m,240))x+=String[c(1710)+c(1382)](e[c(1730)]((15&m)<<12,e[c(1582)](63&i[g++],6))|e[c(1537)](63,i[g++]));else if(e[c(504)](m,240))if(e.mCpFC(e[c(864)],e[c(1667)])){let _=e[c(800)](_0x308077,e[c(1383)],{message:"start"});this["onStartR"+c(1782)]&&this.onStartReconnect(_)}else{let _=e[c(1633)](e.kaluE(e[c(1703)](e[c(1766)](7&m,18),e[c(1983)](e[c(884)](63,i[g++]),12)),e[c(1826)](63,i[g++])<<6)|e[c(639)](63,i[g++]),65536);x+=String[c(1710)+"Code"](e.UNNZO(55296,e.tRqjG(_,10))),x+=String[c(1710)+"Code"](e[c(1513)](56320,1023&_))}}return x}function Br(i,t,r){let c=n;if(e.RdZBx(c(721),e[c(1086)]))return _0x1ec6a8||(_0x1dd0fb=[_0x5de029[c(575)+"e"][c(1740)],_0x272e78.prototype[c(740)],_0xa54ab0[c(575)+"e"][c(740)+c(798)+"ey"]]);{let x=r,g,m;for(let _=0;e[c(926)](_,i[c(509)]);++_){if(e[c(869)](e[c(1214)],c(1819)))return _0x3d844a[c(660)+c(1267)][1]?void 0:_0x18d76c[c(660)+c(1520)](_0x26aa20.objectStoreNames[0]);if(g=i[c(1752)+"At"](_),e[c(1607)](g,128))t[r++]=g;else if(g<2048)t[r++]=e[c(471)](e[c(930)](g,6),192),t[r++]=e.cnWOk(63&g,128);else if(e.DgTJr(64512&g,55296)&&e[c(1769)](64512,m=i[c(1752)+"At"](e[c(661)](_,1)))===56320){if(e[c(1250)](e.ktcYl,e[c(1551)]))return _0x6194b2?this[c(1161)+"E"]():this[c(1542)+"E"]();{let l=(c(1462)+c(1428)).split("|"),S=0;for(;;){switch(l[S++]){case"0":t[r++]=e.oread(e[c(884)](e.dpPnA(g,12),63),128);continue;case"1":t[r++]=e.XzBXC(e[c(1901)](g,18),240);continue;case"2":++_;continue;case"3":t[r++]=e.XzBXC(63&g,128);continue;case"4":t[r++]=e[c(1823)](e[c(1861)](e[c(1288)](g,6),63),128);continue;case"5":g=e[c(1736)](65536+e[c(1410)](e.qMXNZ(1023,g),10),e[c(812)](1023,m));continue}break}}}else if(e.xFCDj(e[c(477)],c(599))){let l=this["_endpoin"+c(1426)]?.[c(1329)+"ntEndpoint"]();this[c(1020)](c(995)+l+c(552)),this[c(1685)+c(1795)](1001,e[c(1514)],!0)}else t[r++]=e[c(784)](g>>12,224),t[r++]=e[c(965)](e[c(1482)](e[c(542)](g,6),63),128),t[r++]=e[c(678)](63,g)|128}return e[c(680)](r,x)}}async function us(i){let t=n;if(e[t(1106)]==typeof i)if(e.DDozK(t(1105),t(1793))){let r=new Uint8Array(xs(i));return e[t(462)](Br,i,r,0),r}else return QTvxnE[t(645)](_0x443af3,_0x2ba7b2[t(1714)](QTvxnE[t(1066)](_0xe2bf90,this),_0x4ec6ee));return e[t(537)](i,ArrayBuffer)?new Uint8Array(i):new Uint8Array(i.buffer,i[t(803)+"et"],i.byteLength)}function s0(i){let t=n;if(e[t(1485)](e[t(1720)],e.tAgtV))return _0x7d51f7.resolve();try{return e[t(1821)](e[t(1106)],typeof i)&&(e[t(673)](i,ArrayBuffer)||i[t(540)]&&e.ueqII(i[t(540)],ArrayBuffer))||e.EVnQC(e[t(1106)],typeof i)?"":(JSON[t(1656)](i),t(1011)+"ion/json")}catch{if(e[t(831)](e[t(1413)],e[t(596)])){let r=this[t(718)][t(1005)](this._prefix),c=_0x2a8074[t(1656)](e[t(1574)](r,"{}"));return _0x270ed0[t(1563)](c)}else return e[t(1231)](e[t(1106)],typeof i)?t(1627)+"in;chars"+t(1182):""}}let o0=(i,t)=>{let r=n;switch(i){case e.wHPcH:case e.XRxyc:return{[r(1116)+i]:1,"x-tt-env":t};default:return{}}};class a0{constructor(t){let r=n;this["maxLossC"+r(764)]=t,this[r(419)]=0}[n(668)](){this.count++}[n(665)+n(1323)+"nt"](){let t=n;return e.llsJu(this[t(419)],this[t(1596)+"ount"])}[n(473)+n(453)](t=0){let r=n;this[r(1596)+r(764)]=t,this[r(419)]=0}}async function c0(i){let t=n,r={BnlDU:function(c,x){return c|x},WJKOh:function(c,x){return e.IZWxY(c,x)}};if(e[t(1677)](t(1892),e[t(1044)]))_0x2ac726[_0x13542c++]=DhQHHG.BnlDU(DhQHHG[t(892)](_0x42e651,6),192),_0x5cc09c[_0x44c09f++]=63&_0x27cfc8|128;else return new Promise(c=>{let x=t,g={DhSxq:function(m,_){return e[M(1744)](m,_)},yLQHU:e[x(1815)],xgWzU:function(m,_){return e[x(1745)](m,_)}};if(e[x(1621)]===e[x(1621)]){if(!St)return c(e[x(1815)]);try{if(e[x(985)](e.SkZEd,x(1635))){let m=this["_message"+x(685)][x(1308)]((_,l)=>(_+=l&&l[x(823)+"th"]||0,_),0);return g[x(937)](m,this._ws?this[x(1093)]["buffered"+x(1083)]:0)}else{let m=document[x(998)+"ement"]("script");window[x(1735)+x(1064)]=_=>{let l=x;document[l(731)][l(1002)+l(1519)](m),window[l(1735)+l(1064)]=void 0,c(_&&_[l(1081)]||g[l(1157)])},m.type=e.VxerG,m.src=e[x(874)](i[x(430)](/^ws/,e[x(1844)]),e[x(1009)]);try{document.body[x(845)+"ild"](m)}catch{document[x(731)][x(1002)+x(1519)](m)}}}catch{if(e.oyDdy!==e[x(1260)])return this[x(1093)]?this._ws.url:this[x(912)];window[x(1735)+x(1064)]=void 0,c(e[x(1815)])}}else return!!(this[x(982)+x(717)]>=this[x(1851)+"s"][x(509)]||syeXXH.xgWzU(this[x(982)+x(717)],this[x(1851)+"s"][x(509)]-1)&&this["currentE"+x(758)+"riesCount"]===this[x(938)+"es"])})}function rt(i,t,r){let c=n;return!!i?.[c(1576)](x=>x[c(1183)]===t&&x[c(1651)]===r)}function Et(i,t){let r=n;return i?.[r(1576)](c=>c[r(1183)]===t)?.[r(1651)]}let zr=null;async function x0(){let i=n;return zr||(zr=Promise[i(1431)]()[i(498)](qe[i(935)](qe,e[i(877)]))),zr}class d0 extends Mr{constructor(t,r){let c=n;super(),this[c(1659)]=t,this[c(739)]=r,this[c(718)]=void 0,this[c(1452)+c(1791)]=null}async[n(1989)](){await this[n(1450)]()}async _init(){let t=n,r={GkixZ:function(c,x,g,m){return e.gtHio(c,x,g,m)}};if(e.nOTPy(e[t(1010)],e.RzjOT)){if(this[t(718)])return;if(this[t(1452)+t(1791)])return this[t(1452)+"mise"];try{let c=this[t(1659)],x=this[t(739)];this[t(1452)+t(1791)]=(async()=>{let g=t,{openDB:m}=await x0();this._qosDB=await r[g(592)](m,g(1735)+"_"+c,1,{upgrade(_){let l=g;_[l(1148)+l(1770)+"e"](c,{keyPath:x})}})})(),await this[t(1452)+t(1791)]}catch(c){console[t(881)](c)}finally{this[t(1452)+t(1791)]=null}}else return new _0x2dc603(_0x893fed,{data:_0x1f6977,message:_0x13122d})}async[n(791)](t){let r=n;if(e[r(1485)](e[r(1127)],e[r(1127)]))try{return await this[r(1450)](),this[r(718)]?.[r(791)](this[r(1659)],t)}catch(c){console[r(881)](c)}else this[r(773)]=_0x5cf05b,this[r(775)]=null}async[n(1593)](t,r){let c=n;return await this._init(),this._qosDB?.[c(1348)](this._dbName,t)}async[n(1118)](t){let r=n;try{return await this._init(),this[r(718)]?.[r(1280)](this._dbName,t)}catch(c){console[r(881)](c)}}async[n(1724)](){let t=n;try{return await this[t(1450)](),this[t(718)]?.[t(1724)](this[t(1659)])}catch(r){console.log(r)}}async[n(790)](){let t=n;return await this._init(),this[t(718)]?.getAllKeys(this[t(1659)])}async[n(1207)](){let t=n;return await this[t(1450)](),this._qosDB?.[t(1207)](this[t(1659)])}async[n(900)](){let t=n;try{this[t(718)]?.close(),this._qosDB=void 0}catch(r){console.log(r)}}get[n(819)](){let t=n;try{return!!this[t(718)]}catch(r){return console[t(881)](r),!1}}}class u0{constructor(t,r){let c=n;this[c(566)]=t,this[c(1940)]=r,this[c(718)]=localStorage}async openDB(){}get[n(1753)](){return"frontier_"+this[n(566)]}async[n(791)](t){let r=n,c=this._qosDB[r(1005)](this[r(1753)]);return JSON[r(1656)](e.oNoLV(c,"{}"))[t]}async[n(1593)](t,r){let c=n,x=this[c(718)].getItem(this[c(1753)]),g=JSON.parse(e[c(1898)](x,"{}"));return g[r||t[this[c(1940)]]]=t,this[c(718)][c(902)](this[c(1753)],JSON.stringify(g)),r||t[this[c(1940)]]}async[n(1118)](t){let r=n,c=this[r(718)][r(1005)](this[r(1753)]),x=JSON[r(1656)](e.IgLWh(c,"{}"));return x[t]=void 0,this[r(718)][r(902)](this[r(1753)],JSON[r(1419)+"y"](x))}async clear(){let t=n;return this[t(718)][t(1724)]()}async[n(790)](){let t=n,r=this[t(718)][t(1005)](this[t(1753)]),c=JSON[t(1656)](r||"{}");return Object[t(790)](c)}async[n(1207)](){let t=n,r=this._qosDB[t(1005)](this[t(1753)]),c=JSON[t(1656)](e[t(1898)](r,"{}"));return Object[t(1563)](c)}[n(900)](){return Promise[n(1431)]()}get[n(819)](){return!!this[n(718)]}}class f0{constructor(t,r){let c=n;this[c(566)]=t,this._pathKey=r,this._qosDB=ft?tt:$t?wx:null}async[n(1989)](){}get _prefix(){let t=n;return t(1735)+"_"+this[t(566)]}async[n(791)](t){let r=n,c=this[r(718)].getStorageSync(this[r(1753)]);return JSON[r(1656)](e[r(1645)](c,"{}"))[t]}async[n(1593)](t,r){let c=n,x=this[c(718)][c(529)+"geSync"](this._prefix),g=JSON[c(1656)](e.aqIqZ(x,"{}"));return g[r||t[this._pathKey]]=t,this._qosDB["setStora"+c(1326)](this[c(1753)],JSON[c(1419)+"y"](g)),r||t[this[c(1940)]]}async[n(1118)](t){let r=n,c=this._qosDB[r(529)+r(1326)](this[r(1753)]),x=JSON[r(1656)](c||"{}");return x[t]=void 0,this[r(718)][r(966)+r(1326)](this._prefix,JSON[r(1419)+"y"](x))}async[n(1724)](){let t=n;return this._qosDB[t(1910)+t(878)]()}async[n(790)](){let t=n,r=this._qosDB["getStora"+t(1786)+"nc"](this[t(1753)]),c=JSON[t(1656)](e[t(1574)](r,"{}"));return Object[t(790)](c)}async[n(1207)](){let t=n,r=this._qosDB[t(529)+t(1786)+"nc"](this[t(1753)]),c=JSON.parse(e[t(1028)](r,"{}"));return Object[t(1563)](c)}[n(900)](){return Promise[n(1431)]()}get[n(819)](){let t=n,r={VJWdK:e.qMJNr,AWzDV:function(c,x){return e[M(1622)](c,x)},FeQPo:function(c,x,g,m){return e[M(462)](c,x,g,m)},BiTBb:function(c,x){return e[M(1601)](c,x)}};if(e.qSjJy(e[t(616)],"aBwYT"))return!!this[t(718)];if(jhYagw.VJWdK==typeof _0x5f1c61){let c=new _0x40e58f(jhYagw[t(630)](_0x5f2153,_0x31b991));return jhYagw[t(676)](_0xc81143,_0x49229b,c,0),c}return jhYagw[t(427)](_0x1fb723,_0xe800e5)?new _0x47315d(_0x3ca08c):new _0x3ba38c(_0x3ea072[t(540)],_0x2e09a2[t(803)+"et"],_0x46bf22.byteLength)}}function fs(i,t){let r=n;if(ft||ft)return new f0(i,t);if((St||Jt)&&e[r(489)](e.XnJMd,typeof indexedDB))return new d0(i,t);if(e[r(1898)](St,Jt)&&e[r(1440)](r(1881)+"d",typeof localStorage))return new u0(i,t);throw new Error(e[r(1926)])}class l0{constructor(){let t=n;if(e[t(1216)]===e.OapiG)this[t(1584)+t(1335)+"Id"]=null,this._interval=36e5,this[t(718)]=e[t(598)](fs,t(1181),e[t(1174)]);else return _0x281039||(_0x4b519f=[_0x396018,_0x34f305,_0x4251fd,_0x188954,_0x3668a3])}async["_interva"+n(1496)](){let t=n;if(e[t(1478)]===e.fVwoc)return!0;e[t(756)](clearInterval,this._intervalTimeoutId),this[t(1584)+t(1335)+"Id"]=setInterval(()=>{this[t(1251)+"ired"]()},this[t(1584)+"l"])}async[n(1989)](){let t=n;await this[t(718)][t(1989)]()[t(498)](()=>{let r=t;this[r(1584)+r(1496)]()})}async[n(1251)+n(1355)](){let t=n;if(e[t(1598)]!==e[t(1547)])(await this[t(718)]?.[t(1207)]()||[])[t(1524)](({timestamp:x})=>x<Date[t(1128)]())[t(1644)](x=>{let g=t;this._qosDB?.[g(1118)](x[g(1313)+"id"])});else return 0}async[n(1118)](t){let r=n,c={BHluS:function(x,g){return e.SAcTp(x,g)},HtDRF:r(1650)};if(r(832)===e[r(1021)]){let{url:x}=_0x3996da||{},g=_0x1e8044[r(1784)](x)?x:c[r(429)](c[r(697)],typeof x)?[x]:[];_0x4769ac&&_0x23c37f[r(1625)](this[r(918)],_0x50d923),g&&g[r(509)]?this[r(1008)+"tManager"]=new _0x305df3(g,this[r(918)].maxRetries):this[r(1008)+r(1426)]?.[r(1971)+r(1618)+r(893)](),this._pingLossCounter?.[r(473)+r(453)](this[r(918)][r(1331)+r(534)]),this["_readyCl"+r(1566)]=!1,this[r(1093)]&&this[r(1093)][r(788)+"te"]!==this[r(924)]?this[r(1685)+r(1795)](1e3,r(1042)+r(1782)+r(940),!0):(this[r(1682)]=!0,this._connect())}else return this[r(718)]?.del(t)}async[n(1593)](t,r){let c=n;return this[c(718)]?.[c(1593)]({message_id:t,timestamp:r})}async[n(791)](t){return this[n(718)]?.get(t)}async[n(900)](){let t=n;e[t(1993)](clearInterval,this[t(1584)+t(1335)+"Id"]),await this[t(718)]?.[t(900)]()}get[n(819)](){let t=n;return this._qosDB?.[t(819)]}}function Fr(i){let t=n,r=!!this._options.enableQoS;if(!r)return{enabled:r,isQoSMessage:!1,isQoSAck:!1,isAckCleanupMessage:!1,ackMsgIds:[]};let c=rt(i[t(866)][t(1495)],e[t(440)],"2"),x=c&&e.PmFfJ(rt,i.message[t(1495)],e[t(1600)],"1"),g=c&&e[t(1789)](rt,i[t(866)].headers,t(417)+t(1648)+"k","1"),m=g?e.dRNmd(Et,i[t(866)][t(1495)],e[t(1276)])?.[t(1771)](",")[t(1524)](Boolean)||[]:[];return{enabled:r,isQoSMessage:c,isQoSAck:x,isAckCleanupMessage:g,ackMsgIds:m}}async function ls(){let i=n;return this[i(698)+"ger"]||(this[i(698)+i(1681)]=new l0),this[i(698)+i(1681)][i(819)]||await this[i(698)+"ger"][i(1989)](),this[i(698)+i(1681)]}async function g0(i,t){let r=n,{enableAutoAck:c}=this[r(918)],x=e.XnIhz(rt,i[r(866)].headers,e[r(1437)],"1"),g=e[r(1789)](rt,i[r(866)][r(1495)],e[r(1388)],"1"),m=Fr.call(this,i);if(e[r(1825)](c,x)){let{SeqID:_,LogID:l,service:S,LogIDNew:v,method:P}=i[r(866)];this._sendAck({SeqID:_,LogID:l,LogIDNew:v,service:S,method:P,headers:[{key:e[r(1388)],value:"1"},{key:e[r(1256)],value:v||""},{key:e[r(1988)],value:"0"}]})}g&&!m[r(1597)]&&this["_dispatchAckMess"+r(909)](i),t()}async function p0(i,t){let r=n;this[r(1020)](e[r(1492)],i[r(866)]),e[r(1084)](t)}async function h0(i,t){let r=n,c=e[r(564)](_t,await e.IFgxo(us,i[r(1909)]));try{if(e.YrZrh!==e.NyTZi)if(e.KosGs(c.payload,Uint8Array)){let x=e[r(1601)](this[r(918)][r(712)+r(1258)],Object)?{force:!!this[r(918)][r(712)+r(1258)].force,encoding:this[r(918)][r(712)+r(1258)][r(1830)]?this[r(918)][r(712)+r(1258)][r(1830)][r(430)](/\s/g,"")[r(944)+r(421)]():""}:{force:!1,encoding:this._options[r(712)+r(1258)]?this._options[r(712)+r(1258)].replace(/\s/g,"")[r(944)+"ase"]():""},g=c["payloadE"+r(1258)]?c[r(712)+r(1258)][r(430)](/\s/g,"")["toLowerC"+r(421)]():"",m=e.RbmDC(this[r(918)][r(1994)+r(875)],Object)?{force:!!this[r(918)]["payloadT"+r(875)][r(1708)],type:this[r(918)][r(1994)+r(875)].type?this[r(918)][r(1994)+r(875)][r(773)].replace(/\s/g,"")[r(944)+r(421)]():""}:{force:!1,type:this[r(918)][r(1994)+r(875)]?this[r(918)].payloadType.replace(/\s/g,"")["toLowerC"+r(421)]():""},_=c[r(1994)+r(875)]?c[r(1994)+r(875)][r(430)](/\s/g,"")[r(944)+r(421)]():"",l=m[r(1708)]?m[r(773)]:_||m[r(773)],S=x[r(1708)]?x[r(1830)]:g||x[r(1830)],v=[e[r(783)],"applicat"+r(824),e[r(1759)],r(1650)],P=["none_none",r(825)];this[r(918)][r(1532)+r(1929)+r(1317)+"ad"]&&v[r(1610)](l)&&(!S||P.includes(S))?c[r(439)+r(1946)]=e[r(521)](ds,c[r(426)],0,c[r(426)][r(823)+"th"]):c[r(439)+r(1946)]=""}else c.textPayload="";else _0x27cca0&&_0x41db9e[r(1614)+r(1955)](QTvxnE.rVsIU,()=>_0x20bff4()),_0x147353&&_0x3b6385[r(1614)+r(1955)](QTvxnE[r(1884)],()=>_0x2ed0a7())}catch(x){c[r(439)+r(1946)]="",console[r(881)](x)}i[r(866)]=c,e[r(1390)](t)}function m0(i,t,r){let c=n,x={CbVGr:function(S,v){return e[M(1848)](S,v)},TIuPw:function(S,v){return e[M(1226)](S,v)},YBGzA:function(S,v){return e.GKICS(S,v)},jcccA:function(S,v){return S+v},SbtEN:function(S,v){return e[M(1749)](S,v)},EmpQa:function(S,v){return S|v}},g=r||8192,m=e[c(770)](g,1),_=null,l=g;return function(S){let v=c;if(x[v(1718)](S,1)||S>m)return x[v(1676)](i,S);if(x[v(507)](x[v(1098)](l,S),g))if(v(1425)!=="pILqU")_=x.TIuPw(i,g),l=0;else{let R=this[v(1731)+"rs"][_0x4f87c6];if(R)for(let B=0;B<R[v(509)];)R[B].fn===_0x4f4274?R[v(559)](B,1):++B}let P=t[v(1352)](_,l,l+=S);return x.SbtEN(7,l)&&(l=x[v(1302)](7,l)+1),P}}let w0=4294967295;function _0(i,t,r){let c=n;return RangeError(e[c(1744)](e[c(1925)](e[c(1736)](e.uRzlG(e[c(1502)](e[c(1935)],i)," + "),e[c(883)](t,1)),c(1140)),r))}function y0(i,t,r){let c=n;if(e.JQAIw(r,w0))throw new Error(e[c(1268)]);let x=3;for(;e[c(504)](x,0);){let g=e.dciJv(255,r);e.IDgLM(qr,g,i,e[c(1347)](t,x)),r>>>=8,x--}return t+4}function b0(i,t){let r=n,c={ZuKzq:e[r(915)]};if(e[r(1808)](e[r(683)],r(544))){let x=0,g=t,m=t+4;for(;e.CVZoK(g,m);){let{value:_,offset:l}=e.mPXhI(Ur,i,g);g=l,x=e[r(1007)](x,8)>>>0,x+=_}return{value:x,offset:m}}else this[r(1033)](r(538),_0xe5a77a(ttaOrS.ZuKzq,{..._0x1d248b}))}function v0(i,t,r){let c=n,x=e.XSeZX[c(1771)]("|"),g=0;for(;;){switch(x[g++]){case"0":if(t.utf8Write)return e.AvdFc(t[c(1536)+"e"](i,r),r);continue;case"1":return e[c(1799)](Br,i,t,r)+r;case"2":if(e[c(1790)](i[c(509)],40))return e[c(1802)](e[c(1360)](Br,i,t,r),r);continue;case"3":if(!i)return r;continue;case"4":if(t.write)return e.XOdBn(t[c(1351)](i,r),r);continue}break}}function S0(i,t){let r=n,c={YQtrz:"ping_onc"+r(1170)+"s",uTVSx:function(x,g,m){return x(g,m)}};if(e[r(1745)](r(1117),e[r(695)])){let x={Tbnkq:function(g,m){return g(m)},diVtl:c[r(445)],XvuMm:r(1374)+r(620)+"t",faEeP:function(g,m,_){return c[r(693)](g,m,_)}};return new _0x9a3b3b((g,m)=>{let _=r,l={yjRhf:function(P,R){return x[M(1694)](P,R)},OUQbD:x[_(1274)],udGOg:x[_(891)],RGAbl:"timeout"};this["_clearPi"+_(633)](),this[_(615)+_(1982)+"Id"]=x[_(1921)](_0x8a707e,this._ping[_(935)](this),this[_(918)][_(1012)+"rval"]);let S=()=>{let P=_;l[P(1632)](g,P(1761)),this[P(1895)](l[P(482)],S),this[P(1895)](l[P(1023)],v)},v=()=>{let P=_;m(l[P(700)]),this[P(1895)](l[P(482)],S),this[P(1895)](l.udGOg,v)};this.on(x.diVtl,S),this.on(x[_(891)],v),this[_(539)]()})}else{let x=new K(e[r(662)](e[r(1055)](e[r(1300)](e[r(1499)](i[e[r(1925)](t,4)],24),e[r(1591)](i[e[r(1736)](t,5)],16)),e[r(1733)](i[e[r(1191)](t,6)],8)),i[e.EloHU(t,7)]),e[r(1553)](e.WAXHe(e[r(1654)](i[e.bBhtM(t,0)]<<24,e[r(491)](i[e[r(1925)](t,1)],16)),e[r(1177)](i[e[r(649)](t,2)],8)),i[e[r(1277)](t,3)]),!0);return t+=8,{value:x,offset:e[r(1389)](t,8)}}}function E0(i,t,r){let c=n,x=i[c(1700)],g=i[c(1244)];return t[r]=e[c(1639)](g,24),t[e[c(827)](r,1)]=e[c(1368)](e.mgWZd(g,16),255),t[e[c(1022)](r,2)]=e[c(1698)](e.BCjdc(g,8),255),t[r+3]=e.cxUUs(255,g),t[e[c(625)](r,4)]=e[c(621)](x,24),t[r+5]=e[c(677)](e[c(1564)](x,16),255),t[e[c(1736)](r,6)]=e.aZOhP(e.ZPNyb(x,8),255),t[r+7]=e[c(639)](255,x),r+=8,r}function Ur(i,t){let r=n;return i[r(1194)+"8"]?{value:i[r(1194)+"8"](t),offset:e[r(734)](t,1)}:{value:e[r(1549)](255,i[t]),offset:t+1}}function qr(i,t,r){let c=n;return t[c(992)+"t8"]?t.writeUint8(i,r):t[r]=e[c(488)](255,i),e[c(1709)](r,1)}let A0=function(i){return new Uint8Array(i)},I0=e.Kfmqs("undefined",typeof Buffer)?Buffer["allocUns"+n(449)]:e[n(686)](m0,A0,Uint8Array[n(575)+"e"][n(1456)]);(()=>{let i=n,t={ILDVR:"3|0|5|2|"+i(688)+i(921)+"8",TrlAP:function(c,x){return e[i(861)](c,x)},MskoH:function(c,x){return e[i(1717)](c,x)},NGppv:function(c,x){return c|x},FdJpi:function(c,x){return e[i(1582)](c,x)},sTNXM:function(c,x){return e[i(470)](c,x)},PbNOf:function(c,x){return c<x},qkYAu:function(c,x){return e[i(506)](c,x)},JdBaF:function(c,x){return e[i(1896)](c,x)},omILf:function(c,x){return e[i(1029)](c,x)},pKxkm:function(c,x){return e[i(1544)](c,x)}},r=4294967295;return function(c,x,g=!0){let m=i,_=t[m(749)][m(1771)]("|"),l=0;for(;;){switch(_[l++]){case"0":if(t[m(939)](c[x++],128))return{value:g?r:0|r,offset:x};continue;case"1":r=t.MskoH(t[m(1746)](r,t[m(1792)](t[m(1879)](15,c[x]),28)),0);continue;case"2":if(t[m(600)](c[x++],128))return{value:g?r:t[m(1018)](0,r),offset:x};continue;case"3":r=t[m(1357)](127&c[x],0);continue;case"4":if(c[x++]<128)return{value:g?r:t[m(1746)](0,r),offset:x};continue;case"5":r=t[m(1041)](t.omILf(r,t[m(558)](127&c[x],7)),0);continue;case"6":if(c[x++]<128)return{value:g?r:t[m(1746)](0,r),offset:x};continue;case"7":r=t[m(1357)](r|t[m(1879)](127,c[x])<<21,0);continue;case"8":return{value:g?r:t[m(1908)](0,r),offset:x};case"9":if((x+=5)>c[m(509)])throw x=c[m(509)],_0(x,10,c[m(509)]);continue;case"10":if(c[x++]<128)return{value:g?r:t[m(1018)](0,r),offset:x};continue;case"11":r=t[m(1357)](t[m(1908)](r,t.sTNXM(127,c[x])<<14),0);continue}break}}})();let T0=16,Gr=32;function P0(i){let t=n,r=0,c={};for(let x=0;x<i[t(509)];x++)c[i[x][t(1873)+t(597)]]=xs(i[x][t(1873)+t(597)]),r+=e[t(1385)](14,c[i[x]["cursor_n"+t(597)]]);return[r,c]}function gs(i,t,r){let c=n,x={pHUkh:function(S,v,P,R){return e[M(1411)](S,v,P,R)},uJovm:e.fYPHQ,OZGeP:"curvalue",kQMBH:function(S,v,P,R){return e[M(1799)](S,v,P,R)},omQkq:e[c(1218)],dKAAe:c(1928)+"name"},[g,m]=e[c(1333)](P0,i),_=e.oxdoA(I0,g),l=0;return i[c(1644)](S=>{let v=c,P=(v(747)+v(487)+v(1702))[v(1771)]("|"),R=0;for(;;){switch(P[R++]){case"0":l=v0(S[v(1873)+v(597)],_,l);continue;case"1":l=x[v(1115)](E0,K[v(1198)+"er"](S.cursor||t),_,l);continue;case"2":l=x.pHUkh(qr,0,_,l);continue;case"3":console[v(881)](x[v(1831)],l);continue;case"4":console[v(881)](x[v(1503)],l);continue;case"5":l=x[v(816)](qr,m[S["cursor_n"+v(597)]],_,l);continue;case"6":console.log("service",l);continue;case"7":console.log("cursor.s"+v(1611),S,S[v(1367)]);continue;case"8":console[v(881)](x[v(1545)],l);continue;case"9":l=y0(_,l,S[v(1367)]||0);continue;case"10":console[v(881)](x[v(1501)],l);continue}break}}),{frameType:Gr,headers:[{key:e[c(1728)],value:r}],payload:_}}function C0(i){let t=n,r=0,c=[];for(;r<i[t(823)+"th"];){let{offset:x}=e[t(1594)](Ur,i,r);r=x;let g={cursor_name:"",cursor:0,service:0},{value:m,offset:_}=e.WjjCg(b0,i,r);g[t(1367)]=m,r=_;let{value:l,offset:S}=e[t(1840)](Ur,i,r);r=S,g.cursor_name=e[t(1662)](ds,i,r,r+l),r+=l;let{value:v,offset:P}=e[t(1521)](S0,i,r);g[t(1641)]=v.toNumber(),r=P,c[t(946)](g)}return c}function k0(){let i=n;return{frameType:Gr,headers:[{key:e[i(1728)],value:e[i(568)]}],payload:void 0}}class D0{constructor(t,r,c){let x=n;e[x(1963)]!==e[x(586)]?(this[x(1254)+"ameSpace"]=t,this[x(1907)+"ileName"]=r,this[x(1415)+x(524)]=c,this[x(718)]=fs(this[x(1254)+x(431)],x(1873)+x(597))):(_0x20e2c3+=_0x384abf(_0x8d74a4),_0x146b6c++)}async[n(1989)](){let t=n;if(e[t(436)]===e[t(436)])await this[t(718)][t(1989)]();else{let r=e[t(1512)][t(1771)]("|"),c=0;for(;;){switch(r[c++]){case"0":_0x59c76c=e[t(1789)](_0x4f52c5,_0x4ce080[t(1873)+t(597)],_0x325d0a,_0x48bdcc);continue;case"1":_0x145733=_0x5009f1(_0x14738a,_0x3b7c12,_0x43f050[t(1367)]||0);continue;case"2":_0x3f6d5a[t(881)](e[t(1980)],_0x379881);continue;case"3":_0x29f1e0.log(t(1367),_0x149834);continue;case"4":_0x1c75fa[t(881)](e[t(1243)],_0x2364e6);continue;case"5":_0x46c46b=_0x4b83c8(_0x447949[_0x516ab3[t(1873)+t(597)]],_0x3d2eb6,_0x7adf34);continue;case"6":_0x5e3e23.log(t(978),_0x5990ff);continue;case"7":_0x2140ef[t(881)](e[t(1133)],_0x56c592);continue;case"8":_0x257e2f[t(881)](e[t(2004)],_0xca2c5,_0x2ab5f7[t(1367)]);continue;case"9":_0x46653e=e.ILeEQ(_0x982794,0,_0x12b7ec,_0x558aba);continue;case"10":_0x23b823=_0x5d1bae(_0x579db3[t(1198)+"er"](_0x43a5bd[t(1641)]||_0x36e194),_0x430aef,_0x172b41);continue}break}}}async[n(1580)+"rs"](){let t=n;if(e.uVbmi(e[t(587)],t(882))){if(!this[t(718)][t(819)])return;let r=this[t(1415)+t(524)],c=await this._qosDB[t(1207)]();switch(console[t(881)](e[t(1221)],c),r){case e[t(841)]:return c&&c[t(509)]?e[t(565)](gs,c,0,this[t(1907)+t(444)]):void 0;case"INSTANT":return;case e[t(981)]:return c&&c[t(509)]?gs(c,0,this[t(1907)+t(444)]):e[t(754)](k0)}}else _0x5d63ed[_0xdb7450++]=e[t(1690)](_0x3beab4,12)|224,_0x185ce8[_0x2756b0++]=e[t(1429)](e[t(1653)](e[t(1785)](_0x63313f,6),63),128),_0x307a29[_0x5e152b++]=e[t(1716)](e[t(1379)](63,_0xea2f1),128)}async[n(1593)](t,r,c){let x=n;if(e[x(1342)](e[x(1886)],x(1151))){if(this["_clearPi"+x(633)](),this[x(1422)+x(428)](),this[x(1078)+x(1265)+"rs"](),this[x(1706)+x(554)](1e3,_0x31a64e),this["_connect"+x(557)]=!1,_0x11dfe1&&this[x(837)+x(1966)]()&&!this[x(1757)+x(1566)]){if(this[x(1008)+x(1426)]?.[x(665)+"chMaxTries"]()){let m=this._endpointManager?.[x(1329)+"ntEndpoint"]();this["_dispatchCloseEv"+x(590)](_0x39a124(e[x(915)],{code:1006,reason:x(995)+m+(x(552)+", max re"+x(1507)+x(1969)),wasClean:!0}))}else{let m=this[x(918)][x(1778)+x(910)+x(1845)](_0x13ad34,_0x4a19de);this[x(1942)+x(804)+x(590)](e[x(987)](_0x2d04a8,e.rVsIU,{code:_0x15e502,reason:_0x5898a2,wasClean:!0,willReconnect:m})),m&&this[x(1399)]()}return}this[x(837)+x(1966)]()||this[x(1757)+x(1566)]?this["_dispatc"+x(804)+x(590)](e[x(416)](_0x3289d6,x(538),{code:_0x34f3ef,reason:e.tIguC})):this[x(1942)+"hCloseEv"+x(590)](e[x(925)](_0x38d2c7,e[x(915)],{code:1006,reason:e[x(735)]})),this[x(1093)]=null,this[x(1008)+x(1426)]?.[x(1971)+x(1618)+x(893)](),this[x(1142)+x(1539)]?.[x(473)+x(453)]()}else return console[x(881)](e[x(1072)],t,r,c),this._qosDB[x(1593)]({cursor_name:t,cursor:r,service:c})}async[n(1557)+"rs"](t){let r=n,c=e[r(1500)](C0,t);for(let x of c)console[r(881)](r(1546)+"r",c),await this._qosDB[r(1593)](x)}async[n(791)](t){let r=n,c={ZTDPb:e[r(1525)],agpIN:"abort"};if(e[r(1340)](r(1109),e[r(1074)]))return(await this._qosDB[r(791)](t))?.cursor;_0x59a676[r(1210)+r(607)+r(622)](xculSr[r(772)],_0x364589),_0x1883b4["removeEv"+r(607)+r(622)](r(654),_0x1ed4e0),_0x482c4b[r(1210)+r(607)+r(622)](xculSr[r(1414)],_0x1b95d0)}async[n(900)](){let t=n;await this[t(718)][t(900)]()}[n(1616)+n(853)+n(1489)](t){let r=n;if(e[r(562)](e[r(1727)],e[r(1727)]))this[r(1907)+r(444)]=t;else return{frameType:_0x37bfa2,headers:[{key:e[r(1728)],value:e[r(568)]}],payload:void 0}}get[n(819)](){let t=n;return this[t(718)][t(819)]}}let R0=e[n(1320)];async function ps(i){let t=n;if(!this[t(918)].enableQoS)return null;let{aID:r,fpID:c,messageStrategy:x}=this[t(918)],g=e[t(1199)](i,R0);try{return this[t(999)+t(1155)]?i&&this[t(999)+t(1155)][t(1616)+"rsorFile"+t(1489)](i):this[t(999)+t(1155)]=new D0(c+"_"+r+"_"+g,g,x),this[t(999)+t(1155)][t(819)]||await this._cursorManager[t(1989)](),this["_cursorM"+t(1155)]}catch{return null}}async function O0(i,t){let r=n,c={pqHfX:function(x,g){return e.uwLrf(x,g)},QVQXx:function(x,g){return e[M(1421)](x,g)},vfvrd:r(672)+r(672)+r(672)+r(672)};if(e[r(1363)](e[r(582)],r(424))){let x=/(25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?)(\.(25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?)){3}/[r(1257)](_0x122b11),g=/(([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]))/[r(1257)](_0x80ea0c);return x?GsZcRf[r(1754)](_0x4b173b,_0x1db28e):g?GsZcRf[r(829)](_0x3598ed,_0x1d9350):GsZcRf[r(1201)]}else{let x=rt(i[r(866)][r(1495)],e[r(1213)],"-1"),g=rt(i[r(866)][r(1495)],r(1219),"1"),m=e.lJDar(Et,i[r(866)][r(1495)],e[r(551)]),_=e[r(1794)](Number,e.jcBjX(Et,i[r(866)][r(1495)],r(417)+r(435)))||0,l=Fr[r(1352)](this,i),S=rt(i[r(866)].headers,"x-msg-qos","2"),v=e[r(725)](Et,i.message.headers,e[r(1937)]),P=e[r(732)](Number,e[r(1961)](Et,i[r(866)][r(1495)],e[r(1972)]));if(l[r(1597)])return e[r(692)](t);let R=l[r(1579)+r(1190)]?await ls.call(this):null;if(e[r(628)](i.message.service,0)&&g&&!x||e[r(1275)](i.message.service,0)){if(m&&l[r(1579)+r(1190)]&&R)return!!!await R.get(m)&&(this[r(1942)+r(989)+r(1941)](i),await R[r(1593)](m,e[r(1141)](Date[r(1128)](),_))),t();if(S)if(e[r(1951)](e[r(805)],e.ZpgAn)){let B=_0x20c6b1[r(1527)],z=_0x5bff01[r(682)],ee=_0x551fda[r(1252)],Z=e[r(1744)](z,_0x351dd8);if(e[r(628)](Z,B[r(509)])){let At=new _0xda3f59(e.vityt(2,Z));At.set(B),_0x3d91a8.bytes=At}return _0x3449ac[r(682)]=Z,e[r(815)](Z,ee)&&(_0x575199[r(1252)]=Z),z}else{let B=await ps[r(1352)](this);if(!B)if(e[r(1679)](e[r(1082)],r(1285))){let ee=_0x181c21[r(1183)];e[r(1679)](void 0,ee)&&(e.Cztip(_0x2e0f92,_0x3fa4cb,10),e[r(1484)](_0x1ff0a1,_0x159ae4,ee));let Z=_0x9d5cd3[r(1651)];e[r(1583)](void 0,Z)&&(e[r(514)](_0xf3a0c6,_0x458b62,18),e[r(1290)](_0x52548e,_0x2cf315,Z))}else return this[r(1942)+r(989)+r(1941)](i),e[r(594)](t);let z=await B.get(v)??-1;if(e[r(1224)](z,P))if(e.DuWsj!==r(1556))this["_dispatc"+r(989)+r(1941)](i),B[r(1593)](v,P,i[r(866)][r(1367)]);else return _0x4ff261+=_0x56d367&&_0xdfac07[r(823)+"th"]||0,_0x145612;else throw new Error(r(876)+r(1432)+" cursor "+P+(r(986)+r(1719)+r(1016)+"r ")+z);return t()}return this._dispatchMessageEvent(i),e[r(754)](t)}}}async function N0(i,t){let r=n;if(e[r(1657)](e.PAjUs,e[r(1608)])){let c=_0x15e536[_0x3b8bab++];if(e[r(1914)](c,127))_0xb9ff53+=_0x5f3ed9[r(1710)+r(1382)](c);else if(e.llsJu(c,192)&&e[r(1261)](c,224))_0x49e6c6+=_0x52b61f[r(1710)+r(1382)](e.WyQXA(e[r(1025)](31,c),6)|e[r(1200)](63,_0x5df746[_0x36ef19++]));else if(e[r(898)](c,224)&&e[r(576)](c,240))_0x2dae3f+=_0x2ebc03[r(1710)+"Code"](e[r(784)](e[r(1915)](15,c)<<12|e[r(730)](63,_0x496068[_0x24e5c6++])<<6,e.uCbcZ(63,_0x5e2e3b[_0x14e64e++])));else if(e[r(690)](c,240)){let x=e.CNpwS(e[r(1255)](e.IKvLo(e.oread(e.cWJaY(e[r(1470)](7,c),18),e[r(1944)](63&_0x3281fc[_0x589f1d++],12)),e.ZQHFg(63,_0x43a138[_0xc0dcfe++])<<6),e[r(1461)](63,_0x53f7e3[_0x50d442++])),65536);_0xda471c+=_0x1a73e1[r(1710)+r(1382)](55296+e.cVtSM(x,10)),_0x4e4d59+=_0x7871c0[r(1710)+r(1382)](e[r(1589)](56320,e[r(1292)](1023,x)))}}else{let c=Fr[r(1352)](this,i);if(!c.isQoSMessage)return e[r(1455)](t);let x=await ls[r(1352)](this);if(c[r(1870)+r(1230)+r(1541)]&&c[r(1047)+"s"][r(509)])for(let g of c[r(1047)+"s"])await x[r(1118)](g);e[r(604)](t)}}async function L0(i,t){let r=n,c=e[r(1427)](i[r(866)][r(1775)+"e"],T0),x=e.VzCDO(i[r(866)][r(1775)+"e"],Gr);if(!c&&!x)return t();let g=e[r(1590)](Et,i[r(866)][r(1495)],r(1841)+"ile_name");if(!g)return e[r(1571)](t);let m=await ps[r(1352)](this,g);if(!m)return t();if(c){let _=await m[r(1580)+"rs"](),l={frameType:_?.[r(1775)+"e"],SeqID:K[r(1198)+"er"](this[r(1619)]++),LogID:K[r(1198)+"er"](this._options[r(602)+r(879)]()),service:9e3,method:5,headers:_?.headers,payload:_?.payload},S=A(l);this[r(1093)]&&this[r(1093)][r(788)+"te"]&&this[r(1093)][r(569)](S)}if(x){let _=i[r(866)][r(426)];_&&m[r(1557)+"rs"](_)}}let M0=async function(i,t){let r=n;this[r(1682)]=!1,e.ihyak(clearTimeout,this["_connect"+r(1336)+r(1121)]),e[r(1528)](t)},B0=async function(i,t){let r=n;if(e[r(1119)](r(1003),e[r(1001)])){if(!this[r(1093)]||e[r(593)](this._ws[r(788)+"te"],this[r(1248)]))return e[r(441)](t);let{pingInterval:c}=this._options;this[r(1008)+r(1426)]?.["resetEnd"+r(1618)+r(893)]();for(let g=0;e[r(1977)](g,this[r(1415)+r(685)][r(509)]);g++){let m=this[r(1415)+"Queue"][g];if(e.WxOxJ(this._ws.readyState,this[r(1248)])&&m!==null)if(e[r(1479)](e[r(726)],e.LVDsK)){if(QTvxnE[r(1677)](_0x1cb12c,QTvxnE[r(1454)]))return _0x5a41d6[r(791)](_0x212a2a);if(_0x2f05a1===QTvxnE[r(545)])return _0x1cc260["objectSt"+r(1267)]||_0x36b436.get(_0x4a2045);if(QTvxnE[r(555)](_0x284f9f,"store"))return _0x9ad871[r(660)+r(1267)][1]?void 0:_0x1962d7["objectSt"+r(1520)](_0x453836[r(660)+r(1267)][0])}else this[r(1093)]&&this[r(1093)][r(569)](m),this[r(1415)+r(685)][g]=null;else break}this[r(1415)+r(685)]=this[r(1415)+r(685)].filter(g=>!!g),this[r(615)+"gTimeoutId"]=setTimeout(()=>this[r(539)](),c),this[r(1942)+"hOpenEvent"](i),this[r(614)+"er"]&&this[r(1093)]&&(this[r(1093)].binaryType=this[r(722)+"ype"]);let x=this[r(1008)+"tManager"]?.[r(1329)+r(997)+"nt"]();this[r(1020)](r(1443)+x+r(1476)),e[r(785)](t)}else{let c=e.BIMuq[r(1771)]("|"),x=0;for(;;){switch(c[x++]){case"0":_0x44e255[_0x1bac26[e[r(1122)]]=5004]=e.SDIUT;continue;case"1":return _0x3b57e6;case"2":_0x56f73f[_0x13956b[e[r(830)]]=5001]=e[r(830)];continue;case"3":_0x3fc032[_0x25f57f[e[r(1325)]]=5003]=e[r(1325)];continue;case"4":_0x4724d5[_0x1d8881[r(1874)+"NG_ERROR"]=5002]=e.nxKKF;continue;case"5":_0x142a52[_0x4be520[e[r(643)]]=5005]=r(1417)+"OR";continue}break}}},z0=async function(i,t){let r=n,c=this[r(1008)+r(1426)]?.[r(1329)+r(997)+"nt"]();this._debug("open "+c),e[r(1057)](t)};class F0 extends Mr{constructor(t){let r=n,c={IOJcF:function(_,l,S,v){return e.XnIhz(_,l,S,v)},EpGbi:function(_,l){return _!==l},KixUw:e[r(1321)],QpwFB:e.SYKiM,GfxLx:function(_,l,S){return e[r(1050)](_,l,S)},pKEEm:e[r(1617)],RlxfP:function(_,l,S){return e.dRNmd(_,l,S)},isyyN:function(_,l){return _===l},sDcUr:r(1146),WCsxm:function(_,l){return e[r(952)](_,l)},EYIVI:e[r(1154)],ATBpD:e.nxTLQ,eZdHO:r(1374)+r(1170)+"s",egQnl:e[r(836)],qHihM:function(_,l){return e[r(1677)](_,l)},mOifR:function(_,l,S){return _(l,S)},TqvEI:function(_,l){return e[r(1467)](_,l)},KVNEL:function(_,l,S){return _(l,S)},WfjJX:function(_,l){return _(l)},mEpKl:function(_,l){return e[r(1385)](_,l)},PWGXG:"Reeuy",UAuUx:e.BrsDT,PShZI:function(_,l,S){return _(l,S)},xalfY:e.rVsIU,ObIJi:r(1381),gXhWj:function(_,l){return e[r(1282)](_,l)},cUtyZ:function(_,l,S){return e[r(1293)](_,l,S)}};super(),this[r(807)+"igatorOn"+r(1678)]=!0,this[r(614)+"er"]=St,this[r(479)]=t0,this[r(814)+"T"]=ft,this[r(1979)+"X"]=$t,this[r(1334)+"r"]=Jt,this[r(1415)+"Queue"]=[],this[r(1008)+r(1426)]=null,this[r(1757)+r(1566)]=!1,this[r(722)+r(875)]=e[r(1756)],this["_connect"+r(557)]=!1,this[r(1399)+r(1336)+r(1121)]=null,this[r(1559)+"ctTimeoutId"]=null,this[r(615)+r(1982)+"Id"]=null,this._seqId=0,this._isInit=!1,this[r(912)]="",this[r(698)+r(1681)]=null,this[r(999)+r(1155)]=null,this["_pingLos"+r(1539)]=null,this[r(1750)+"ls"]=e[r(671)],this[r(924)]=3,this[r(1874)+"NG"]=0,this[r(1248)]=1,this[r(1796)]=2,this[r(455)]=_=>{let l=r;try{c.IOJcF(cs,this,_,[M0,B0,z0])}catch(S){if(c[l(1978)](c[l(1640)],c.QpwFB)){let v=c[l(642)](Ie,c.pKEEm,{message:S.message,code:nt[l(1417)+"OR"],error:S});this["_dispatc"+l(1822)+l(590)](v)}else _0x3fa32b.log(_0x5f30b2)}},this._onMessage=async _=>{let l=r,{pingInterval:S,pingFrequency:v}=this[l(918)];if(_.data==="hi"&&c[l(1240)](c[l(779)],v)||c[l(1451)](c[l(1529)],v))if(c[l(1131)]!=="fMXTb")this[l(687)+l(633)](),this[l(1033)](c[l(1763)],c.egQnl),this["_pingPon"+l(1982)+"Id"]=c[l(1353)](setTimeout,this[l(539)][l(935)](this),S);else{let P=this[l(1008)+l(1426)]?.["getCurre"+l(997)+"nt"]();this[l(1942)+"hCloseEvent"](c[l(1353)](_0x51863a,l(538),{code:1006,reason:l(995)+P+(" timeout, max re"+l(1507)+l(1969)),wasClean:!0}))}if(!c[l(720)]("hi",_[l(1909)]))try{c[l(646)](cs,this,_,[h0,g0,N0,L0,O0,p0])}catch(P){let R=c.GfxLx(Ie,c[l(1558)],{message:P.message,code:nt.MESSAGE_ERROR,error:P});this[l(1942)+l(1822)+"ent"](R)}},this[r(1675)]=_=>{let l=r,S=this[l(1008)+l(1426)]?.[l(665)+"chMaxTries"](),v=this[l(1008)+"tManager"]?.[l(1329)+l(997)+"nt"]();if(S&&!_[l(866)]){let P="connect "+v+(l(1315)+l(1833)+l(670)+"ed");this[l(1942)+l(1822)+l(590)](c[l(1372)](Ie,l(654),{message:P,code:nt[l(516)+l(974)+"R"],error:_}));return}this[l(1093)]&&c[l(1195)](this[l(1093)][l(788)+"te"],this[l(1248)])&&this[l(1685)+l(1795)](),this[l(1942)+l(1822)+"ent"](c[l(631)](Ie,c[l(1558)],{message:_.message,code:nt[l(1595)+l(855)],error:_}))},this[r(423)]=async _=>{let l=r;if(c[l(1240)](c[l(1165)],c[l(1603)])){let v=""+_0x4cb007[l(1128)](),P=_0x9eed01||(_0x3d0447=BtEpcL[l(1273)](_0x3e9cf2,_0x195a45)),R=_0x675329.random().toString(16)[l(806)](-6);return BtEpcL[l(838)](BtEpcL[l(838)](BtEpcL[l(838)]("02",v),P),R)}else{this[l(1422)+"mer"](),this["_clearPi"+l(633)](),this[l(1078)+l(1265)+"rs"](),this[l(1093)]=null,this[l(1399)+l(557)]=!1;let S=this["_endpoin"+l(1426)]?.checkReachMaxTries();if(!S&&this._navigatorOnline()&&!this[l(1757)+l(1566)]){let v=this["_endpoin"+l(1426)]?.[l(1329)+l(997)+"nt"](),P=this[l(918)][l(1778)+l(910)+"ptor"](_.code,_[l(1171)]);this["_dispatchCloseEv"+l(590)](De(l(538),{code:1006,reason:_[l(1171)]||l(1854)+l(510)+l(813)+"wn reaso"+l(1712)+l(561)+v,willReconnect:P})),P&&this[l(1399)]();return}if(c[l(1978)](1e3,_[l(767)])&&this[l(1757)+"osed"]){this[l(1942)+l(804)+l(590)](c[l(459)](De,c.xalfY,{code:1e3,reason:c.ObIJi})),this[l(1008)+"tManager"]?.[l(1971)+"pointCon"+l(893)](),this[l(1142)+l(1539)]?.[l(473)+l(453)]();return}if(c[l(1978)](1e3,_[l(767)])&&S){let v=this[l(1008)+l(1426)]?.[l(1329)+l(997)+"nt"](),P=_[l(1171)];P||(P=await c.gXhWj(c0,this[l(912)])),P=l(1854)+"ng failed, "+P+(", hostna"+l(1019))+v+(l(1652)+l(1507)+l(1969)),this[l(1942)+"hCloseEvent"](c[l(1902)](De,l(538),{code:_.code,reason:P}));let R=l(995)+v+(l(1315)+l(1833)+l(670)+"ed");this[l(1942)+l(1822)+l(590)](Ie(c[l(1558)],{message:R,code:nt[l(516)+l(974)+"R"]})),this[l(1008)+l(1426)]?.[l(1971)+l(1618)+l(893)](),this[l(1142)+l(1539)]?.["resetCou"+l(453)]();return}if(_[l(767)]!==1e3&&!_[l(1171)]){let v=this["_endpoin"+l(1426)]?.[l(1329)+"ntEndpoint"]();this[l(1942)+l(804)+l(590)](c[l(1372)](De,c.xalfY,{code:_[l(767)],reason:"connecti"+l(510)+l(813)+l(1371)+l(1712)+l(561)+v})),this[l(1008)+l(1426)]?.[l(1971)+"pointCon"+l(893)](),this[l(1142)+"sCounter"]?.[l(473)+l(453)]();return}this[l(1942)+l(804)+l(590)](_),this[l(1008)+"tManager"]?.[l(1971)+l(1618)+l(893)](),this[l(1142)+"sCounter"]?.[l(473)+l(453)]()}},this[r(951)]=null,this[r(1760)]=null,this[r(659)+"e"]=null,this[r(1139)]=null,this[r(1208)+r(1782)]=null,this[r(1723)+"eAck"]=null,this[r(1665)+r(1038)+r(1356)+"ct"]=null,this._handleOnLine=this[r(848)+"nLine"][r(935)](this),this["_handleO"+r(464)]=this[r(848)+"ffLine"].bind(this),this[r(1952)+r(1343)]=this[r(1952)+"ageHide"][r(935)](this),this[r(1952)+"ageShow"]=this[r(1952)+r(1024)][r(935)](this),this._options={url:"",automaticOpen:!0,initReconnectInterval:1e3,maxReconnectInterval:1e4,reconnectIntervalGrowFactor:2,timeoutInterval:5e3,maxRetries:5,debug:!1,maxMessageQueueLength:e[r(961)](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(1184),pingLossCount:2,enableTransformTextPayload:!1,logIDNewConfig:{enableAutoGenerateLogIDNew:!1,userIp:""},miniProgramParams:{customHttpHeader:{}},enableAutoAck:!1,reconnectInterceptor:()=>!0,enableQoS:!1,QoSLevel:2,messageStrategy:e[r(981)],env:{xTTEnv:"",xUseEnv:""},listenNetworkChanged:!0};let{url:x,ws:g}=t,m=Array[r(1784)](x)?x:e.USyfF(e.qMJNr,typeof x)?[x]:[];if(!m||e.BoAeR(0,m[r(509)]))throw new Error(e[r(1112)]);if(!e.wpjJd(i0,g))throw new Error(e[r(433)]);Object[r(1625)](this._options,t),this["_endpoin"+r(1426)]=new as(m,this[r(918)][r(938)+"es"]),this[r(1142)+r(1539)]=new a0(this._options[r(1331)+r(534)]),this[r(918)][r(1307)+r(1400)]&&(this[r(1682)]=!0,this._connect()),this[r(918)]["listenNetworkCha"+r(1504)]&&(this[r(814)+"T"]||this._isMiniWX?this[r(1531)+r(1767)+r(1132)]():this._isBrowser&&this[r(1059)+r(1446)+r(1955)]())}[n(848)+"nLine"](){let t=n;this[t(918)][t(1327)+t(1816)+t(964)]||this[t(1757)+t(1566)]||this[t(1498)+"econnect"]()}[n(848)+n(464)](){let t=n;this["_destroy"+t(1043)+"t"]();let r=e[t(942)](Lr,e.ixoIz,{message:e[t(412)]});this[t(1665)+"mediatel"+t(1356)+"ct"]&&this[t(1665)+t(1038)+t(1356)+"ct"](r)}[n(1059)+"balEvent"+n(1955)](){let t=n;this[t(614)+"er"]&&window[t(1614)+t(1955)](e[t(408)],this._handleOnLine),this._isBrowser&&window[t(1614)+"Listener"](t(1159),this[t(848)+t(464)]),this[t(614)+"er"]&&window[t(1614)+t(1955)]("pagehide",this[t(1952)+"ageHide"]),this._isBrowser&&window[t(1614)+t(1955)](e[t(528)],this[t(1952)+t(1024)])}[n(1962)+"balEvent"+n(1955)](){let t=n;this[t(614)+"er"]&&window[t(1210)+t(607)+t(622)](e[t(408)],this[t(848)+t(1561)]),this[t(614)+"er"]&&window[t(1210)+t(607)+"ner"](e[t(1672)],this[t(848)+t(464)]),this[t(614)+"er"]&&window["removeEv"+t(607)+t(622)](t(1408),this[t(1952)+t(1343)]),this._isBrowser&&window[t(1210)+t(607)+t(622)](t(991),this[t(1952)+t(1024)])}[n(1952)+n(1343)](t){let r=n;!t[r(728)+"d"]&&(this[r(614)+"er"]&&window["removeEv"+r(607)+r(622)](e[r(1865)],this[r(1952)+r(1343)]),this[r(614)+"er"]&&window[r(1210)+"entListe"+r(622)]("pageshow",this._handlePageShow),this[r(538)]()),this[r(614)+"er"]&&window["removeEventListe"+r(622)](e[r(408)],this[r(848)+r(1561)]),this[r(614)+"er"]&&window[r(1210)+r(607)+r(622)](e[r(1672)],this[r(848)+r(464)])}[n(1952)+n(1024)](t){let r=n;t[r(728)+"d"]&&(this["_navigat"+r(1966)]()&&(!this[r(1093)]||e[r(1951)](this[r(1093)][r(788)+"te"],this[r(1248)])||this._ws[r(788)+"te"]!==this[r(1874)+"NG"])&&this._handleOnLine(),this._isBrowser&&window["addEvent"+r(1955)](r(1386),this[r(848)+r(1561)]),this[r(614)+"er"]&&window.addEventListener(e[r(1672)],this[r(848)+r(464)]))}async["_generat"+n(1068)](t){let r=n,c={knPAF:function(x,g,m){return x(g,m)}};if(e[r(1686)]===e.yAaSf)psiXSf[r(443)](_0x2757a9,_0x3c789e,66),psiXSf[r(443)](_0x224da8,_0x107739,_0x317ec1.length),psiXSf.knPAF(_0x5a5f29,_0x5cbe06,_0x202a1f);else{let{fpID:x,deviceID:g,bddID:m,ttwID:_,accessKey:l,aID:S,customParams:v={},enableAutoAck:P,enableQoS:R,QoSLevel:B,env:z}=this[r(918)],ee,Z,At;this._isBrowser||this[r(1979)+"X"]||this[r(814)+"T"]?(ee=location&&e[r(1776)](e[r(1661)],location[r(715)])?r(1477):e[r(1612)],Z=t[r(430)](/((^ws)|(^http))((?:[s]*:\/\/))/,""),At=/^wss(.*:\/\/)/[r(1257)](t)?t:""+ee+Z):(ee=e[r(1509)],Z=t[r(430)](/(^http)((?:[s]*:\/\/))/,""),At=/(^ws)((?:[s]*:\/\/))/[r(1257)](Z)?Z:""+ee+Z);let hs=m?"bd_did":_?e[r(890)]:e[r(613)],ms=m||_||g;if(e[r(1061)](!ms,!hs))throw new Error("please p"+r(963)+r(457)+r(1664)+r(1464));let U0=e.DoMCz(e[r(679)],typeof v)?await e[r(858)](v):v,q0=z?e.pGvFA(o0,z[r(972)],z[r(571)]):{},jr=Object[r(1625)]({device_platform:e.pLRDh,version_code:e[r(1806)],access_key:l,fpid:x,aid:S,[hs]:ms,xsack:P?1:0,xaack:P?1:0,xsqos:R?1:0,qos_level:R?B:void 0,qos_sdk_version:2,...q0},U0),G0=Object[r(790)](jr)[r(1308)]((Hr,Kr)=>jr[Kr]!==void 0?""+Hr+(Hr?"&":"?")+Kr+"="+jr[Kr]:Hr,"");return At+r(1180)+G0}}async[n(1399)](){let t=n;if(!(this[t(1399)+t(557)]||this[t(1757)+t(1566)])){this["_connect"+t(557)]=!0;try{let r=this["_endpoin"+t(1426)]?.[t(1882)+"rentEndpointReachedMaxRe"+t(1562)](),{timeoutInterval:c}=this[t(918)];if(r)if(e.juxiF(e[t(933)],t(1123)))_0x213638=e[t(1684)](e.DSubS(e[t(1843)](e[t(1134)](15,_0x1c825c),12),e.NXKzt(63,_0x33045b)<<6),e[t(1505)](63,_0x3bdb9d)),e[t(723)](_0x1db797,2048)||e[t(690)](_0x227b47,55296)&&e[t(1533)](_0x182e7b,57343)?_0x53746e+=_0x2eeb4b:(_0x50664c+=e[t(1341)](_0x2daf17,_0x2666b5),_0x512976+=2);else{let g=this[t(1008)+t(1426)]?.[t(1329)+t(997)+"nt"](),m=this[t(1008)+t(1426)]?.[t(624)+t(1986)+t(1466)+t(969)+t(1048)](),_=this[t(1008)+t(1426)]?.[t(1329)+t(997)+"ntTriesCount"]();if(m){let l="connect "+g+(t(552)+t(1652)+t(1507)+"ached, w"+t(1156)+t(941)+t(1136))+m+(t(1900)+"y"),S=e[t(1565)](Ie,e.fKVAW,{message:l,code:nt["MAX_RETR"+t(974)+"R"]});this[t(1020)](l),this[t(1942)+t(1822)+t(590)](S),this[t(912)]=await this["_generat"+t(1068)](m),this._debug(t(995)+m+" "+_+t(651)),this._removeWsListeners()}else{let l=t(995)+g+(t(552)+t(1652)+"tries re"+t(1969));this[t(1020)](l),this["_dispatc"+t(1822)+t(590)](e[t(1304)](Ie,e[t(1617)],{message:l,code:nt["MAX_RETR"+t(974)+"R"]}));return}}else{let g=this[t(1008)+"tManager"]?.[t(1329)+"ntEndpoi"+t(1113)+t(1655)](),m=this["_endpoin"+t(1426)]?.[t(1329)+t(997)+t(1403)+"ount"]();this._url=await this._generateUrl(e[t(1645)](g,"")),this._debug(t(995)+g+" "+m+t(651)),this[t(1078)+t(1265)+"rs"]()}if(this[t(1682)])this[t(1682)]=!1;else{let g=e[t(1880)](Lr,e[t(1383)],{message:t(478)});this[t(1208)+t(1782)]&&this["onStartR"+t(1782)](g)}let x=this[t(1008)+t(1426)]?.[t(1329)+t(997)+t(1403)+"ount"]()||0;e.TsCkM(x,1)&&await this[t(1346)](e[t(1633)](x,1)),this._debug(t(1854)+t(1220)+this[t(912)]+" protocols: "+this._protocols),this[t(1093)]=e[t(581)](r0,{url:this[t(912)],protocols:[this._protocols],headers:this[t(918)]["miniProg"+t(496)+"s"].customHttpHeader},this._options.ws),(this._isBrowser||this[t(1334)+"r"])&&this[t(1093)]&&(this[t(1093)][t(1049)+"pe"]=this["_binaryT"+t(875)]),this[t(556)+t(472)](),this[t(1399)+t(1336)+"utId"]=e.lJDar(setTimeout,this[t(2e3)+"ut"].bind(this),c)}catch(r){throw this["_connect"+t(557)]=!1,r}}}_clearTimer(){let t=n;e.EgUsp(clearTimeout,this[t(1399)+"ionTimeoutId"]),this[t(1399)+t(1336)+"utId"]=null}[n(687)+n(633)](){let t=n;e.zqZiY(clearTimeout,this[t(615)+"gTimeoutId"]),clearTimeout(this[t(1559)+t(1361)+t(2003)]),this[t(615)+"gTimeoutId"]=null,this[t(1559)+t(1361)+"tId"]=null}[n(1020)](...t){let r=n;this[r(918)][r(484)]&&console[r(881)][r(1714)](console,[e[r(432)],...t])}[n(1092)+n(1318)+"e"](t){let r=n;if(e.piaff("MKxGE",r(1973))){let{initReconnectInterval:c,maxReconnectInterval:x,reconnectIntervalGrowFactor:g}=this[r(918)],m=e[r(1229)](c,Math[r(1032)](g,e[r(579)](t,1)));return m>x?x:m}else _0x28e0b2+=e.RNZxQ(_0x384a35,_0x23b68e),_0x3a03fd+=2}[n(539)](){let t=n;if(this[t(1093)]&&e.jsiQo(this._ws[t(788)+"te"],this[t(1874)+"NG"])){this[t(687)+"ngTimer"](),this[t(615)+"gTimeoutId"]=setTimeout(this._ping[t(935)](this),this[t(918)][t(1012)+t(746)]);return}if(!this._ws||e[t(1298)](this[t(1093)][t(788)+"te"],this[t(1248)]))return void this[t(1498)+t(1782)]();this[t(1093)]&&this[t(1093)][t(569)]("hi"),this[t(1559)+t(1361)+"tId"]=e[t(725)](setTimeout,this["_handleReconnect"+t(1166)][t(935)](this),this[t(918)]["pingTimeoutInter"+t(497)])}[n(1498)+n(1782)+n(1166)](){let t=n;this[t(1142)+t(1539)]?.[t(668)](),this[t(1033)](e[t(899)],e.Gbckm),this[t(1142)+t(1539)]?.["checkRea"+t(1323)+"nt"]()?this["_handleR"+t(1782)]():this[t(539)]()}_navigatorOnline(){let t=n;return this[t(814)+"T"]||this[t(1979)+"X"]?this[t(807)+t(851)+t(1678)]:(this[t(614)+"er"]||this[t(1334)+"r"])&&this._options[t(610)+t(768)+"nged"]?navigator[t(1587)]:!0}[n(1498)+n(1782)](){let t=n;!this[t(837)+"orOnline"]()||this[t(1757)+t(1566)]||(this[t(1008)+t(1426)]?.["resetEnd"+t(1618)+t(893)](),this["_pingLos"+t(1539)]?.[t(473)+"nter"](),this[t(1093)]?this[t(1685)+t(1795)](1001,e[t(475)],!0):this[t(1399)]())}[n(1531)+"etWorkCh"+n(1132)](){let t=n,r={OIwGu:function(c,x){return e[M(1889)](c,x)},NkdqJ:e[t(1705)]};this[t(814)+"T"]?tt[t(1534)+t(1824)+t(856)](({isConnected:c})=>{let x=t;this["_miniNavigatorOn"+x(1678)]=c,c?this[x(848)+"nLine"]():this[x(848)+"ffLine"]()}):this[t(1979)+"X"]&&wx["onNetwor"+t(1824)+t(856)](({isConnected:c})=>{let x=t;r[x(744)]("CMlEd",r[x(1350)])?(this[x(807)+x(851)+x(1678)]=c,c?this[x(848)+x(1561)]():this[x(848)+"ffLine"]()):_0x59a64d[x(881)](_0x406170)})}[n(1346)](t){let r={ivtuv:function(c,x,g){return c(x,g)}};return new Promise(c=>{let x=M;r[x(1058)](setTimeout,c,this[x(1092)+"rvalValue"](t))})}[n(1685)+"ect"](t=1e3,r="",c=!1){let x=n,g={WmGhh:function(m,_){return m>=_}};if(e[x(562)](e[x(1570)],e.hKYDv)){if(!this[x(1093)])return;this[x(1137)+x(1043)+"t"](t,r,c)}else if(MyQToz.WmGhh(_0x11ffeb,_0x27cf62))return _0x5bb579}[n(2e3)+"ut"](){let t=n,r=this[t(1008)+"tManager"]?.[t(1329)+t(997)+"nt"]();this._debug(t(995)+r+t(552)),this["_disconn"+t(1795)](1001,e[t(1514)],!0)}_sendAck(t){let r=n,c=e.SrDMT(se,t);this[r(1093)]&&e[r(1473)](this._ws.readyState,this[r(1248)])&&(e[r(593)](e[r(741)],e[r(702)])?(this[r(1093)]&&this._ws[r(569)](c),this[r(1020)](e.NRtPt,t)):this[r(1731)+"rs"]={})}[n(1078)+"sListeners"](){let t=n,r=e[t(1407)][t(1771)]("|"),c=0;for(;;){switch(r[c++]){case"0":if(!this[t(1093)])return;continue;case"1":this[t(1093)][t(1210)+t(607)+"ner"](e[t(1617)],this[t(1675)]);continue;case"2":this[t(1093)][t(1210)+t(607)+t(622)](e[t(481)],this[t(455)]);continue;case"3":this[t(1093)]["removeEv"+t(607)+t(622)](e.JbPng,this[t(1472)+"ge"]);continue;case"4":this[t(1093)]["removeEv"+t(607)+"ner"](e[t(915)],this._onClose);continue}break}}[n(556)+"steners"](){let t=n,r=e[t(1630)][t(1771)]("|"),c=0;for(;;){switch(r[c++]){case"0":if(!this[t(1093)])return;continue;case"1":this._ws[t(1614)+t(1955)](e[t(1424)],this[t(1472)+"ge"]);continue;case"2":this[t(1093)]["addEvent"+t(1955)](e[t(915)],this[t(423)]);continue;case"3":this[t(1093)][t(1614)+t(1955)](e[t(1617)],this[t(1675)]);continue;case"4":this[t(1093)][t(1614)+t(1955)](e.zXGMW,this[t(455)]);continue}break}}[n(1706)+n(554)](t=1e3,r=""){let c=n;try{this[c(1093)]&&this[c(1093)][c(538)](t,r)}catch{}}[n(1137)+"WebSocket"](t=1e3,r="",c=!1){let x=n;if(this[x(687)+"ngTimer"](),this[x(1422)+x(428)](),this[x(1078)+x(1265)+"rs"](),this[x(1706)+x(554)](1e3,r),this[x(1399)+x(557)]=!1,c&&this["_navigat"+x(1966)]()&&!this[x(1757)+x(1566)]){if(this[x(1008)+"tManager"]?.[x(665)+x(1606)+"es"]()){let m=this[x(1008)+x(1426)]?.[x(1329)+"ntEndpoint"]();this[x(1942)+x(804)+x(590)](e[x(1264)](De,e[x(915)],{code:1006,reason:"connect "+m+(x(552)+", max retries re"+x(1969)),wasClean:!0}))}else{let m=this[x(918)][x(1778)+x(910)+"ptor"](t,r);this._dispatchCloseEvent(e[x(1869)](De,e.rVsIU,{code:t,reason:r,wasClean:!0,willReconnect:m})),m&&this._connect()}return}this[x(837)+"orOnline"]()||this[x(1757)+x(1566)]?this[x(1942)+x(804)+"ent"](e[x(1430)](De,e[x(915)],{code:t,reason:e[x(780)]})):this[x(1942)+"hCloseEv"+x(590)](De(e[x(915)],{code:1006,reason:"going aw"+x(1809)+x(719)+x(1605)})),this[x(1093)]=null,this._endpointManager?.[x(1971)+x(1618)+x(893)](),this[x(1142)+x(1539)]?.[x(473)+x(453)]()}[n(1942)+n(1291)+"nt"](t){let r=n;this[r(1033)](e[r(481)],t),this.onopen&&this[r(1139)](t)}[n(1942)+n(989)+n(1941)](t){let r=n;this[r(1033)](e[r(1424)],t),this[r(659)+"e"]&&this.onmessage(t)}[n(1942)+n(1412)+n(909)](t){let r=n,c={LhZjA:function(x,g){return e.kJNfm(x,g)},XOxMG:function(x,g){return e[M(1839)](x,g)},XFYQP:function(x,g){return e[M(1855)](x,g)},EXNwP:function(x,g){return x<<g}};e.JCYcV===e[r(548)]?(_0x16ca18=_0x37dbdd(_0x29f9b7),_0x1650ef|=aMGykP.LhZjA(aMGykP[r(1950)](127,_0x311ad3),21),aMGykP[r(1471)](128,_0x5cac53)&&(_0x278081=_0x54b2d0(_0x2625e8),_0x3d1aee=127&_0xcd1403,128&_0x48eb76&&(_0x10b1be=_0x4ccc87(_0x54cd16),_0x2b047c|=aMGykP[r(1380)](127&_0x36bde6,7)))):(this.emit(e[r(502)],t),this[r(1723)+r(1319)]&&this["onReceiv"+r(1319)](t))}[n(1942)+n(1822)+n(590)](t){let r=n;this[r(1033)](e[r(1617)],t),this[r(1760)]&&this.onerror(t)}[n(1942)+n(804)+n(590)](t){let r=n;this[r(1033)]("close",t),this[r(951)]&&this[r(951)](t)}get[n(1049)+"pe"](){let t=n;if(e[t(1741)](e.yquCC,e[t(550)]))return this._ws?this._ws[t(1049)+"pe"]:this[t(722)+"ype"];{let r=0,c=0;for(let x=0;e.wzjPz(x,_0x459873[t(509)]);++x)c=_0x42b200[t(1752)+"At"](x),e[t(1266)](c,128)?r+=1:e[t(1920)](c,2048)?r+=2:e.bKQrb(64512&c,55296)&&e[t(1473)](64512&_0x24ecae.charCodeAt(e[t(1453)](x,1)),56320)?(++x,r+=4):r+=3;return r}}set binaryType(t){let r=n;this[r(722)+r(875)]=t,this[r(1093)]&&(this[r(1093)][r(1049)+"pe"]=t)}get retryCount(){let t=n;return this[t(1008)+t(1426)]?.["getCurre"+t(997)+t(1403)+t(764)]()||0}get["buffered"+n(1083)](){let t=n;if(t(1673)==="XcTZh")return this[t(718)]?.isReady;{let r=this[t(1415)+t(685)][t(1308)]((c,x)=>(c+=x&&x[t(823)+"th"]||0,c),0);return e.szUMO(r,this[t(1093)]?this[t(1093)][t(1516)+t(1083)]:0)}}get[n(1089)+"ns"](){let t=n;return e.pWZGh(t(1262),e[t(1526)])?this[t(1093)]?this._ws.extensions:"":(this[t(871)+"ndpointT"+t(1511)+"t"]=1,this["currentI"+t(717)]++,this[t(1851)+"s"][this[t(982)+t(717)]])}get protocol(){let t=n;return this._ws?this[t(1093)][t(715)]:""}get[n(788)+"te"](){let t=n;return this[t(1093)]?this[t(1093)].readyState:this._options[t(1307)+t(1400)]?this[t(1874)+"NG"]:this[t(924)]}get[n(1420)](){let t=n;return this[t(1093)]?this[t(1093)][t(1420)]:this._url}[n(538)](t=1e3,r){let c=n,x=e[c(1780)].split("|"),g=0;for(;;){switch(x[g++]){case"0":this[c(698)+c(1681)]?.[c(900)]();continue;case"1":this[c(687)+"ngTimer"]();continue;case"2":this["_dropGlobalEvent"+c(1955)]();continue;case"3":this[c(1757)+c(1566)]=!0;continue;case"4":this[c(1422)+"mer"]();continue;case"5":if(e.tuHWf(this[c(1093)][c(788)+"te"],this[c(924)])||this[c(1093)][c(788)+"te"]===this[c(1796)])return void this._debug(e[c(953)]);continue;case"6":if(!this[c(1093)])return void this[c(1020)](e[c(574)]);continue;case"7":this[c(1137)+c(1043)+"t"](t,r);continue}break}}async[n(569)](t,r){let c=n;if(t==null)throw new Error(e[c(1957)]);e[c(1888)](e.eugmK,typeof t)&&(t=JSON[c(1419)+"y"](t)),e[c(1578)](c(1650),typeof t)&&!e[c(1395)](t,ArrayBuffer)&&!(t.buffer&&e.lWLTI(t[c(540)],ArrayBuffer))&&(t=JSON[c(1419)+"y"](t));let x=await e.jOOpJ(us,t),g=e.TcYcb(s0,t),{method:m=0,service:_=this[c(918)][c(1367)],logID:l=this[c(918)][c(602)+c(879)](),headers:S=this[c(918)][c(1495)],payloadEncoding:v=this._options[c(712)+"ncoding"],payloadType:P=this[c(918)][c(1994)+c(875)],logIDNew:R=this._options[c(716)+c(1037)]["enableAu"+c(1405)+c(1469)+"ew"]?e.oOeZn(o,this._options[c(716)+c(1037)].userIp):""}=e[c(681)](r,{});if(!_)throw new Error(e[c(854)]);let B={SeqID:K[c(1198)+"er"](this[c(1619)]++),LogID:K[c(1198)+"er"](l),service:_,method:m,headers:S,payloadEncoding:e.RbmDC(v,Object)?v[c(1830)]?v[c(1830)]:"":v,payloadType:e.Ocyhr(P,Object)?P[c(773)]?P.type:g:P||g,payload:x,LogIDNew:R},z=e[c(759)](se,B);return this._ws&&e[c(1807)](this[c(1093)][c(788)+"te"],this[c(1248)])?(this._ws&&this._ws[c(569)](z),this[c(1020)](c(1303),B)):e.eKfeU(this[c(1415)+c(685)].length,this[c(918)][c(1366)+c(1436)+c(976)])?(this[c(1415)+"Queue"][c(946)](z),this[c(1020)](e.tEeWX,B)):(this["_message"+c(685)].shift(),this[c(1415)+c(685)][c(946)](z)),{seqID:this[c(1619)],logID:l,logIDNew:R}}async[n(1778)+"t"](t){let r=n;if(r(468)!==r(468)){let c=new _0x497faf(e[r(515)](_0x102ab5,_0x33c5ff));return e[r(1239)](_0x58d89f,_0x1844bc,c,0),c}else{let{url:c}=e[r(681)](t,{}),x=Array.isArray(c)?c:e[r(1106)]==typeof c?[c]:[];t&&Object[r(1625)](this._options,t),x&&x.length?this[r(1008)+r(1426)]=new as(x,this[r(918)][r(938)+"es"]):this[r(1008)+r(1426)]?.["resetEnd"+r(1618)+r(893)](),this[r(1142)+r(1539)]?.[r(473)+r(453)](this[r(918)][r(1331)+r(534)]),this[r(1757)+r(1566)]=!1,this[r(1093)]&&e[r(532)](this._ws.readyState,this[r(924)])?this[r(1685)+r(1795)](1e3,e[r(1737)],!0):(this[r(1682)]=!0,this[r(1399)]())}}async connect(){let t=n;if(e[t(1787)](e[t(1103)],e.tojus))this.emit(e[t(481)],_0x1a5024),this[t(1139)]&&this[t(1139)](_0x106181);else if(!this[t(1399)+t(557)]){let r=e.TXHzV[t(1771)]("|"),c=0;for(;;){switch(r[c++]){case"0":this[t(1142)+t(1539)]?.[t(473)+t(453)]();continue;case"1":this._isInit=!0;continue;case"2":this["_endpoin"+t(1426)]?.[t(1971)+t(1618)+"fig"]();continue;case"3":this._connect();continue;case"4":this[t(1757)+t(1566)]=!1;continue}break}}}addEventListener(t,r){let c=n,x={LrbDi:function(g,m,_){return g(m,_)},fuHxd:e.zXGMW};e.derwt===e[c(1269)]?this.emit(c(699),TUMeZz[c(886)](_0x5e1d29,TUMeZz[c(1310)],{..._0x1dfc63,data:_0x2f7eb4.errMsg||""})):this.on(t,r)}[n(1045)+"Event"](t){let{type:r}=t;this.emit(r,t)}[n(1210)+n(607)+n(622)](t,r){this[n(1895)](t,r)}[n(601)](){let t=n,r={zyhUl:function(c,x){return c(x)},JqncD:e[t(836)],vYGms:e.uWZPZ,lEInh:function(c,x){return c(x)},fPZga:e[t(2002)],RKgwu:function(c,x,g){return c(x,g)}};return new Promise((c,x)=>{let g=t;this[g(687)+"ngTimer"](),this._pingPongTimeoutId=r[g(1959)](setTimeout,this[g(539)][g(935)](this),this[g(918)][g(1012)+g(746)]);let m=()=>{let l=g;r[l(1999)](c,r.JqncD),this.off(l(1374)+l(1170)+"s",m),this[l(1895)](r.vYGms,_)},_=()=>{let l=g;r.lEInh(x,"timeout"),this[l(1895)](r.fPZga,m),this[l(1895)](r[l(1777)],_)};this.on("ping_onc"+g(1170)+"s",m),this.on(r[g(1777)],_),this[g(539)]()})}}})(),Y[C(1475)+C(1179)]=re[C(1475)+C(1179)],Y[C(638)+C(802)]=re[C(638)+C(802)],Y[C(906)+"e"]=re[C(906)+"e"],Y[C(1941)]=re.Event,Y[C(796)]=re.FWS,Y[C(920)+"MessageE"+C(2006)]=re[C(920)+C(1354)+C(2006)],Y[C(1354)+C(2006)]=re[C(1354)+C(2006)],Y[C(1040)+"t"]=re[C(1040)+"t"],Y["Reconnec"+C(950)]=re.ReconnectEvent,Y[C(701)+"oseEvent"]=re[C(701)+C(1179)],Y[C(1100)+C(802)]=re[C(1100)+C(802)],Y[C(499)+C(822)+"nt"]=re[C(499)+"ssageEvent"],Y[C(1899)+C(1701)]=re["createOp"+C(1701)],Y[C(465)+C(1835)+"vent"]=re[C(465)+C(1835)+"vent"],Y[C(1384)+C(753)]=re[C(1384)+"rame"],Y["encodeFr"+C(597)]=re[C(525)+C(597)];for(Qn in re)[C(1475)+"oseEvent",C(638)+C(802),"ErrorCode",C(1941),C(796),"Frontier"+C(1354)+C(2006),"MessageE"+C(2006),C(1040)+"t","Reconnec"+C(950),C(701)+C(1179),"createEr"+C(802),C(499)+"ssageEvent",C(1899)+C(1701),C(465)+C(1835)+C(2006),C(1384)+"rame","encodeFrame"].indexOf(Qn)===-1&&(Y[Qn]=re[Qn]);var Qn;Object[C(1990)+"operty"](Y,C(513)+"le",{value:!0})});var Ve=ve((S_,ua)=>{"use strict";var xa=["nodebuffer","arraybuffer","fragments"],da=typeof Blob<"u";da&&xa.push("blob");ua.exports={BINARY_TYPES:xa,CLOSE_TIMEOUT:3e4,EMPTY_BUFFER:Buffer.alloc(0),GUID:"258EAFA5-E914-47DA-95CA-C5AB0DC85B11",hasBlob:da,kForOnEventAttribute:Symbol("kIsForOnEventAttribute"),kListener:Symbol("kListener"),kStatusCode:Symbol("status-code"),kWebSocket:Symbol("websocket"),NOOP:()=>{}}});var dn=ve((E_,or)=>{"use strict";var{EMPTY_BUFFER:bf}=Ve(),gi=Buffer[Symbol.species];function vf(n,e){if(n.length===0)return bf;if(n.length===1)return n[0];let s=Buffer.allocUnsafe(e),o=0;for(let a=0;a<n.length;a++){let d=n[a];s.set(d,o),o+=d.length}return o<e?new gi(s.buffer,s.byteOffset,o):s}function fa(n,e,s,o,a){for(let d=0;d<a;d++)s[o+d]=n[d]^e[d&3]}function la(n,e){for(let s=0;s<n.length;s++)n[s]^=e[s&3]}function Sf(n){return n.length===n.buffer.byteLength?n.buffer:n.buffer.slice(n.byteOffset,n.byteOffset+n.length)}function pi(n){if(pi.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),pi.readOnly=!1),e}or.exports={concat:vf,mask:fa,toArrayBuffer:Sf,toBuffer:pi,unmask:la};if(!process.env.WS_NO_BUFFER_UTIL)try{let n=ne("bufferutil");or.exports.mask=function(e,s,o,a,d){d<48?fa(e,s,o,a,d):n.mask(e,s,o,a,d)},or.exports.unmask=function(e,s){e.length<32?la(e,s):n.unmask(e,s)}}catch{}});var ha=ve((A_,pa)=>{"use strict";var ga=Symbol("kDone"),hi=Symbol("kRun"),mi=class{constructor(e){this[ga]=()=>{this.pending--,this[hi]()},this.concurrency=e||1/0,this.jobs=[],this.pending=0}add(e){this.jobs.push(e),this[hi]()}[hi](){if(this.pending!==this.concurrency&&this.jobs.length){let e=this.jobs.shift();this.pending++,e(this[ga])}}};pa.exports=mi});var Ut=ve((I_,ya)=>{"use strict";var un=ne("zlib"),ma=dn(),Ef=ha(),{kStatusCode:wa}=Ve(),Af=Buffer[Symbol.species],If=Buffer.from([0,0,255,255]),cr=Symbol("permessage-deflate"),Xe=Symbol("total-length"),zt=Symbol("callback"),xt=Symbol("buffers"),Ft=Symbol("error"),ar,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,!ar){let s=this._options.concurrencyLimit!==void 0?this._options.concurrencyLimit:10;ar=new Ef(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[zt];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 d=+a;if(!Number.isInteger(d)||d<8||d>15)throw new TypeError(`Invalid value for parameter "${o}": ${a}`);a=d}else if(!this._isServer)throw new TypeError(`Invalid value for parameter "${o}": ${a}`)}else if(o==="server_max_window_bits"){let d=+a;if(!Number.isInteger(d)||d<8||d>15)throw new TypeError(`Invalid value for parameter "${o}": ${a}`);a=d}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){ar.add(a=>{this._decompress(e,s,(d,u)=>{a(),o(d,u)})})}compress(e,s,o){ar.add(a=>{this._compress(e,s,(d,u)=>{a(),o(d,u)})})}_decompress(e,s,o){let a=this._isServer?"client":"server";if(!this._inflate){let d=`${a}_max_window_bits`,u=typeof this.params[d]!="number"?un.Z_DEFAULT_WINDOWBITS:this.params[d];this._inflate=un.createInflateRaw({...this._options.zlibInflateOptions,windowBits:u}),this._inflate[cr]=this,this._inflate[Xe]=0,this._inflate[xt]=[],this._inflate.on("error",Pf),this._inflate.on("data",_a)}this._inflate[zt]=o,this._inflate.write(e),s&&this._inflate.write(If),this._inflate.flush(()=>{let d=this._inflate[Ft];if(d){this._inflate.close(),this._inflate=null,o(d);return}let u=ma.concat(this._inflate[xt],this._inflate[Xe]);this._inflate._readableState.endEmitted?(this._inflate.close(),this._inflate=null):(this._inflate[Xe]=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 d=`${a}_max_window_bits`,u=typeof this.params[d]!="number"?un.Z_DEFAULT_WINDOWBITS:this.params[d];this._deflate=un.createDeflateRaw({...this._options.zlibDeflateOptions,windowBits:u}),this._deflate[Xe]=0,this._deflate[xt]=[],this._deflate.on("data",Tf)}this._deflate[zt]=o,this._deflate.write(e),this._deflate.flush(un.Z_SYNC_FLUSH,()=>{if(!this._deflate)return;let d=ma.concat(this._deflate[xt],this._deflate[Xe]);s&&(d=new Af(d.buffer,d.byteOffset,d.length-4)),this._deflate[zt]=null,this._deflate[Xe]=0,this._deflate[xt]=[],s&&this.params[`${a}_no_context_takeover`]&&this._deflate.reset(),o(null,d)})}};ya.exports=wi;function Tf(n){this[xt].push(n),this[Xe]+=n.length}function _a(n){if(this[Xe]+=n.length,this[cr]._maxPayload<1||this[Xe]<=this[cr]._maxPayload){this[xt].push(n);return}this[Ft]=new RangeError("Max payload size exceeded"),this[Ft].code="WS_ERR_UNSUPPORTED_MESSAGE_LENGTH",this[Ft][wa]=1009,this.removeListener("data",_a),this.reset()}function Pf(n){if(this[cr]._inflate=null,this[Ft]){this[zt](this[Ft]);return}n[wa]=1007,this[zt](n)}});var qt=ve((T_,xr)=>{"use strict";var{isUtf8:ba}=ne("buffer"),{hasBlob:Cf}=Ve(),kf=[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 Df(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 Rf(n){return Cf&&typeof n=="object"&&typeof n.arrayBuffer=="function"&&typeof n.type=="string"&&typeof n.stream=="function"&&(n[Symbol.toStringTag]==="Blob"||n[Symbol.toStringTag]==="File")}xr.exports={isBlob:Rf,isValidStatusCode:Df,isValidUTF8:_i,tokenChars:kf};if(ba)xr.exports.isValidUTF8=function(n){return n.length<24?_i(n):ba(n)};else if(!process.env.WS_NO_UTF_8_VALIDATE)try{let n=ne("utf-8-validate");xr.exports.isValidUTF8=function(e){return e.length<32?_i(e):n(e)}}catch{}});var Ei=ve((P_,Pa)=>{"use strict";var{Writable:Of}=ne("stream"),va=Ut(),{BINARY_TYPES:Nf,EMPTY_BUFFER:Sa,kStatusCode:Lf,kWebSocket:Mf}=Ve(),{concat:yi,toArrayBuffer:Bf,unmask:zf}=dn(),{isValidStatusCode:Ff,isValidUTF8:Ea}=qt(),dr=Buffer[Symbol.species],Pe=0,Aa=1,Ia=2,Ta=3,bi=4,vi=5,ur=6,Si=class extends Of{constructor(e={}){super(),this._allowSynchronousEvents=e.allowSynchronousEvents!==void 0?e.allowSynchronousEvents:!0,this._binaryType=e.binaryType||Nf[0],this._extensions=e.extensions||{},this._isServer=!!e.isServer,this._maxPayload=e.maxPayload|0,this._skipUTF8Validation=!!e.skipUTF8Validation,this[Mf]=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 dr(o.buffer,o.byteOffset+e,o.length-e),new dr(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 dr(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 Aa:this.getPayloadLength16(e);break;case Ia:this.getPayloadLength64(e);break;case Ta:this.getMask();break;case bi:this.getData(e);break;case vi:case ur:this._loop=!1;return}while(this._loop);this._errored||e()}getInfo(e){if(this._bufferedBytes<2){this._loop=!1;return}let s=this.consume(2);if((s[0]&48)!==0){let 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[va.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=Aa:this._payloadLength===127?this._state=Ia: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=Ta:this._state=bi}getMask(){if(this._bufferedBytes<4){this._loop=!1;return}this._mask=this.consume(4),this._state=bi}getData(e){let s=Sa;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&&zf(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[va.extensionName].decompress(e,this._fin,(a,d)=>{if(a)return s(a);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 a;this._binaryType==="nodebuffer"?a=yi(o,s):this._binaryType==="arraybuffer"?a=Bf(yi(o,s)):this._binaryType==="blob"?a=new Blob(o):a=o,this._allowSynchronousEvents?(this.emit("message",a,!0),this._state=Pe):(this._state=ur,setImmediate(()=>{this.emit("message",a,!0),this._state=Pe,this.startLoop(e)}))}else{let a=yi(o,s);if(!this._skipUTF8Validation&&!Ea(a)){let d=this.createError(Error,"invalid UTF-8 sequence",!0,1007,"WS_ERR_INVALID_UTF8");e(d);return}this._state===vi||this._allowSynchronousEvents?(this.emit("message",a,!1),this._state=Pe):(this._state=ur,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,Sa),this.end();else{let o=e.readUInt16BE(0);if(!Ff(o)){let d=this.createError(RangeError,`invalid status code ${o}`,!0,1002,"WS_ERR_INVALID_CLOSE_CODE");s(d);return}let a=new dr(e.buffer,e.byteOffset+2,e.length-2);if(!this._skipUTF8Validation&&!Ea(a)){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,a),this.end()}this._state=Pe;return}this._allowSynchronousEvents?(this.emit(this._opcode===9?"ping":"pong",e),this._state=Pe):(this._state=ur,setImmediate(()=>{this.emit(this._opcode===9?"ping":"pong",e),this._state=Pe,this.startLoop(s)}))}createError(e,s,o,a,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[Lf]=a,u}};Pa.exports=Si});var Ti=ve((k_,Da)=>{"use strict";var{Duplex:C_}=ne("stream"),{randomFillSync:Uf}=ne("crypto"),Ca=Ut(),{EMPTY_BUFFER:qf,kWebSocket:Gf,NOOP:jf}=Ve(),{isBlob:Gt,isValidStatusCode:Hf}=qt(),{mask:ka,toBuffer:gt}=dn(),Ce=Symbol("kByteLength"),Kf=Buffer.alloc(4),fr=8*1024,pt,jt=fr,Re=0,Wf=1,$f=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=jf,this[Gf]=void 0}static frame(e,s){let o,a=!1,d=2,u=!1;s.mask&&(o=s.maskBuffer||Kf,s.generateMask?s.generateMask(o):(jt===fr&&(pt===void 0&&(pt=Buffer.alloc(fr)),Uf(pt,0,fr),jt=0),o[0]=pt[jt++],o[1]=pt[jt++],o[2]=pt[jt++],o[3]=pt[jt++]),u=(o[0]|o[1]|o[2]|o[3])===0,d=6);let f;typeof e=="string"?(!s.mask||u)&&s[Ce]!==void 0?f=s[Ce]:(e=Buffer.from(e),f=e.length):(f=e.length,a=s.mask&&s.readOnly&&!u);let p=f;f>=65536?(d+=8,p=127):f>125&&(d+=2,p=126);let h=Buffer.allocUnsafe(a?f+d:d);return h[0]=s.fin?s.opcode|128:s.opcode,s.rsv1&&(h[0]|=64),h[1]=p,p===126?h.writeUInt16BE(f,2):p===127&&(h[2]=h[3]=0,h.writeUIntBE(f,4,6)),s.mask?(h[1]|=128,h[d-4]=o[0],h[d-3]=o[1],h[d-2]=o[2],h[d-1]=o[3],u?[h,e]:a?(ka(e,o,h,d,f),[h]):(ka(e,o,e,0,f),[h,e])):[h,e]}close(e,s,o,a){let d;if(e===void 0)d=qf;else{if(typeof e!="number"||!Hf(e))throw new TypeError("First argument must be a valid error code number");if(s===void 0||!s.length)d=Buffer.allocUnsafe(2),d.writeUInt16BE(e,0);else{let f=Buffer.byteLength(s);if(f>123)throw new RangeError("The message must not be greater than 123 bytes");d=Buffer.allocUnsafe(2+f),d.writeUInt16BE(e,0),typeof s=="string"?d.write(s,2):d.set(s,2)}}let u={[Ce]:d.length,fin:!0,generateMask:this._generateMask,mask:o,maskBuffer:this._maskBuffer,opcode:8,readOnly:!1,rsv1:!1};this._state!==Re?this.enqueue([this.dispatch,d,!1,u,a]):this.sendFrame(n.frame(d,u),a)}ping(e,s,o){let a,d;if(typeof e=="string"?(a=Buffer.byteLength(e),d=!1):Gt(e)?(a=e.size,d=!1):(e=gt(e),a=e.length,d=gt.readOnly),a>125)throw new RangeError("The data size must not be greater than 125 bytes");let u={[Ce]:a,fin:!0,generateMask:this._generateMask,mask:s,maskBuffer:this._maskBuffer,opcode:9,readOnly:d,rsv1:!1};Gt(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,d;if(typeof e=="string"?(a=Buffer.byteLength(e),d=!1):Gt(e)?(a=e.size,d=!1):(e=gt(e),a=e.length,d=gt.readOnly),a>125)throw new RangeError("The data size must not be greater than 125 bytes");let u={[Ce]:a,fin:!0,generateMask:this._generateMask,mask:s,maskBuffer:this._maskBuffer,opcode:10,readOnly:d,rsv1:!1};Gt(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[Ca.extensionName],d=s.binary?2:1,u=s.compress,f,p;typeof e=="string"?(f=Buffer.byteLength(e),p=!1):Gt(e)?(f=e.size,p=!1):(e=gt(e),f=e.length,p=gt.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,d=0),s.fin&&(this._firstFragment=!0);let h={[Ce]:f,fin:s.fin,generateMask:this._generateMask,mask:s.mask,maskBuffer:this._maskBuffer,opcode:d,readOnly:p,rsv1:u};Gt(e)?this._state!==Re?this.enqueue([this.getBlobData,e,this._compress,h,o]):this.getBlobData(e,this._compress,h,o):this._state!==Re?this.enqueue([this.dispatch,e,this._compress,h,o]):this.dispatch(e,this._compress,h,o)}getBlobData(e,s,o,a){this._bufferedBytes+=o[Ce],this._state=$f,e.arrayBuffer().then(d=>{if(this._socket.destroyed){let f=new Error("The socket was closed while the blob was being read");process.nextTick(Ii,this,f,a);return}this._bufferedBytes-=o[Ce];let u=gt(d);s?this.dispatch(u,s,o,a):(this._state=Re,this.sendFrame(n.frame(u,o),a),this.dequeue())}).catch(d=>{process.nextTick(Jf,this,d,a)})}dispatch(e,s,o,a){if(!s){this.sendFrame(n.frame(e,o),a);return}let d=this._extensions[Ca.extensionName];this._bufferedBytes+=o[Ce],this._state=Wf,d.compress(e,o.fin,(u,f)=>{if(this._socket.destroyed){let p=new Error("The socket was closed while data was being compressed");Ii(this,p,a);return}this._bufferedBytes-=o[Ce],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][Ce],Reflect.apply(e[0],this,e.slice(1))}}enqueue(e){this._bufferedBytes+=e[3][Ce],this._queue.push(e)}sendFrame(e,s){e.length===2?(this._socket.cork(),this._socket.write(e[0]),this._socket.write(e[1],s),this._socket.uncork()):this._socket.write(e[0],s)}};Da.exports=Ai;function Ii(n,e,s){typeof s=="function"&&s(e);for(let o=0;o<n._queue.length;o++){let a=n._queue[o],d=a[a.length-1];typeof d=="function"&&d(e)}}function Jf(n,e,s){Ii(n,e,s),n.onerror(e)}});var Ua=ve((D_,Fa)=>{"use strict";var{kForOnEventAttribute:fn,kListener:Pi}=Ve(),Ra=Symbol("kCode"),Oa=Symbol("kData"),Na=Symbol("kError"),La=Symbol("kMessage"),Ma=Symbol("kReason"),Ht=Symbol("kTarget"),Ba=Symbol("kType"),za=Symbol("kWasClean"),Ye=class{constructor(e){this[Ht]=null,this[Ba]=e}get target(){return this[Ht]}get type(){return this[Ba]}};Object.defineProperty(Ye.prototype,"target",{enumerable:!0});Object.defineProperty(Ye.prototype,"type",{enumerable:!0});var ht=class extends Ye{constructor(e,s={}){super(e),this[Ra]=s.code===void 0?0:s.code,this[Ma]=s.reason===void 0?"":s.reason,this[za]=s.wasClean===void 0?!1:s.wasClean}get code(){return this[Ra]}get reason(){return this[Ma]}get wasClean(){return this[za]}};Object.defineProperty(ht.prototype,"code",{enumerable:!0});Object.defineProperty(ht.prototype,"reason",{enumerable:!0});Object.defineProperty(ht.prototype,"wasClean",{enumerable:!0});var Kt=class extends Ye{constructor(e,s={}){super(e),this[Na]=s.error===void 0?null:s.error,this[La]=s.message===void 0?"":s.message}get error(){return this[Na]}get message(){return this[La]}};Object.defineProperty(Kt.prototype,"error",{enumerable:!0});Object.defineProperty(Kt.prototype,"message",{enumerable:!0});var ln=class extends Ye{constructor(e,s={}){super(e),this[Oa]=s.data===void 0?null:s.data}get data(){return this[Oa]}};Object.defineProperty(ln.prototype,"data",{enumerable:!0});var Vf={addEventListener(n,e,s={}){for(let a of this.listeners(n))if(!s[fn]&&a[Pi]===e&&!a[fn])return;let o;if(n==="message")o=function(d,u){let f=new ln("message",{data:u?d:d.toString()});f[Ht]=this,lr(e,this,f)};else if(n==="close")o=function(d,u){let f=new ht("close",{code:d,reason:u.toString(),wasClean:this._closeFrameReceived&&this._closeFrameSent});f[Ht]=this,lr(e,this,f)};else if(n==="error")o=function(d){let u=new Kt("error",{error:d,message:d.message});u[Ht]=this,lr(e,this,u)};else if(n==="open")o=function(){let d=new Ye("open");d[Ht]=this,lr(e,this,d)};else return;o[fn]=!!s[fn],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[fn]){this.removeListener(n,s);break}}};Fa.exports={CloseEvent:ht,ErrorEvent:Kt,Event:Ye,EventTarget:Vf,MessageEvent:ln};function lr(n,e,s){typeof n=="object"&&n.handleEvent?n.handleEvent.call(n,s):n.call(e,s)}});var gr=ve((R_,qa)=>{"use strict";var{tokenChars:gn}=qt();function je(n,e,s){n[e]===void 0?n[e]=[s]:n[e].push(s)}function Xf(n){let e=Object.create(null),s=Object.create(null),o=!1,a=!1,d=!1,u,f,p=-1,h=-1,y=-1,w=0;for(;w<n.length;w++)if(h=n.charCodeAt(w),u===void 0)if(y===-1&&gn[h]===1)p===-1&&(p=w);else if(w!==0&&(h===32||h===9))y===-1&&p!==-1&&(y=w);else if(h===59||h===44){if(p===-1)throw new SyntaxError(`Unexpected character at index ${w}`);y===-1&&(y=w);let I=n.slice(p,y);h===44?(je(e,I,s),s=Object.create(null)):u=I,p=y=-1}else throw new SyntaxError(`Unexpected character at index ${w}`);else if(f===void 0)if(y===-1&&gn[h]===1)p===-1&&(p=w);else if(h===32||h===9)y===-1&&p!==-1&&(y=w);else if(h===59||h===44){if(p===-1)throw new SyntaxError(`Unexpected character at index ${w}`);y===-1&&(y=w),je(s,n.slice(p,y),!0),h===44&&(je(e,u,s),s=Object.create(null),u=void 0),p=y=-1}else if(h===61&&p!==-1&&y===-1)f=n.slice(p,w),p=y=-1;else throw new SyntaxError(`Unexpected character at index ${w}`);else if(a){if(gn[h]!==1)throw new SyntaxError(`Unexpected character at index ${w}`);p===-1?p=w:o||(o=!0),a=!1}else if(d)if(gn[h]===1)p===-1&&(p=w);else if(h===34&&p!==-1)d=!1,y=w;else if(h===92)a=!0;else throw new SyntaxError(`Unexpected character at index ${w}`);else if(h===34&&n.charCodeAt(w-1)===61)d=!0;else if(y===-1&&gn[h]===1)p===-1&&(p=w);else if(p!==-1&&(h===32||h===9))y===-1&&(y=w);else if(h===59||h===44){if(p===-1)throw new SyntaxError(`Unexpected character at index ${w}`);y===-1&&(y=w);let I=n.slice(p,y);o&&(I=I.replace(/\\/g,""),o=!1),je(s,f,I),h===44&&(je(e,u,s),s=Object.create(null),u=void 0),f=void 0,p=y=-1}else throw new SyntaxError(`Unexpected character at index ${w}`);if(p===-1||d||h===32||h===9)throw new SyntaxError("Unexpected end of input");y===-1&&(y=w);let A=n.slice(p,y);return u===void 0?je(e,A,s):(f===void 0?je(s,A,!0):o?je(s,f,A.replace(/\\/g,"")):je(s,f,A),je(e,u,s)),e}function Yf(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 d=o[a];return Array.isArray(d)||(d=[d]),d.map(u=>u===!0?a:`${a}=${u}`).join("; ")})).join("; ")).join(", ")}).join(", ")}qa.exports={format:Yf,parse:Xf}});var wr=ve((L_,Qa)=>{"use strict";var Zf=ne("events"),Qf=ne("https"),el=ne("http"),Ha=ne("net"),tl=ne("tls"),{randomBytes:nl,createHash:rl}=ne("crypto"),{Duplex:O_,Readable:N_}=ne("stream"),{URL:Ci}=ne("url"),dt=Ut(),il=Ei(),sl=Ti(),{isBlob:ol}=qt(),{BINARY_TYPES:Ga,CLOSE_TIMEOUT:al,EMPTY_BUFFER:pr,GUID:cl,kForOnEventAttribute:ki,kListener:xl,kStatusCode:dl,kWebSocket:xe,NOOP:Ka}=Ve(),{EventTarget:{addEventListener:ul,removeEventListener:fl}}=Ua(),{format:ll,parse:gl}=gr(),{toBuffer:pl}=dn(),Wa=Symbol("kAborted"),Di=[8,13],Ze=["CONNECTING","OPEN","CLOSING","CLOSED"],hl=/^[!#$%&'*+\-.0-9A-Z^_`|a-z~]+$/,V=class n extends Zf{constructor(e,s,o){super(),this._binaryType=Ga[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]),$a(this,e,s,o)):(this._autoPong=o.autoPong,this._closeTimeout=o.closeTimeout,this._isServer=!0)}get binaryType(){return this._binaryType}set binaryType(e){Ga.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 il({allowSynchronousEvents:o.allowSynchronousEvents,binaryType:this.binaryType,extensions:this._extensions,isServer:this._isServer,maxPayload:o.maxPayload,skipUTF8Validation:o.skipUTF8Validation}),d=new sl(e,this._extensions,o.generateMask);this._receiver=a,this._sender=d,this._socket=e,a[xe]=this,d[xe]=this,e[xe]=this,a.on("conclude",_l),a.on("drain",yl),a.on("error",bl),a.on("message",vl),a.on("ping",Sl),a.on("pong",El),d.onerror=Al,e.setTimeout&&e.setTimeout(0),e.setNoDelay&&e.setNoDelay(),s.length>0&&e.unshift(s),e.on("close",Xa),e.on("data",mr),e.on("end",Ya),e.on("error",Za),this._readyState=n.OPEN,this.emit("open")}emitClose(){if(!this._socket){this._readyState=n.CLOSED,this.emit("close",this._closeCode,this._closeMessage);return}this._extensions[dt.extensionName]&&this._extensions[dt.extensionName].cleanup(),this._receiver.removeAllListeners(),this._readyState=n.CLOSED,this.emit("close",this._closeCode,this._closeMessage)}close(e,s){if(this.readyState!==n.CLOSED){if(this.readyState===n.CONNECTING){Ae(this,this._req,"WebSocket was closed before the connection was established");return}if(this.readyState===n.CLOSING){this._closeFrameSent&&(this._closeFrameReceived||this._receiver._writableState.errorEmitted)&&this._socket.end();return}this._readyState=n.CLOSING,this._sender.close(e,s,!this._isServer,o=>{o||(this._closeFrameSent=!0,(this._closeFrameReceived||this._receiver._writableState.errorEmitted)&&this._socket.end())}),Va(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){Ae(this,this._req,"WebSocket was closed before the connection was established");return}this._socket&&(this._readyState=n.CLOSING,this._socket.destroy())}}};Object.defineProperty(V,"CONNECTING",{enumerable:!0,value:Ze.indexOf("CONNECTING")});Object.defineProperty(V.prototype,"CONNECTING",{enumerable:!0,value:Ze.indexOf("CONNECTING")});Object.defineProperty(V,"OPEN",{enumerable:!0,value:Ze.indexOf("OPEN")});Object.defineProperty(V.prototype,"OPEN",{enumerable:!0,value:Ze.indexOf("OPEN")});Object.defineProperty(V,"CLOSING",{enumerable:!0,value:Ze.indexOf("CLOSING")});Object.defineProperty(V.prototype,"CLOSING",{enumerable:!0,value:Ze.indexOf("CLOSING")});Object.defineProperty(V,"CLOSED",{enumerable:!0,value:Ze.indexOf("CLOSED")});Object.defineProperty(V.prototype,"CLOSED",{enumerable:!0,value:Ze.indexOf("CLOSED")});["binaryType","bufferedAmount","extensions","isPaused","protocol","readyState","url"].forEach(n=>{Object.defineProperty(V.prototype,n,{enumerable:!0})});["open","error","close","message"].forEach(n=>{Object.defineProperty(V.prototype,`on${n}`,{enumerable:!0,get(){for(let e of this.listeners(n))if(e[ki])return e[xl];return null},set(e){for(let s of this.listeners(n))if(s[ki]){this.removeListener(n,s);break}typeof e=="function"&&this.addEventListener(n,e,{[ki]:!0})}})});V.prototype.addEventListener=ul;V.prototype.removeEventListener=fl;Qa.exports=V;function $a(n,e,s,o){let a={allowSynchronousEvents:!0,autoPong:!0,closeTimeout:al,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 d;if(e instanceof Ci)d=e;else try{d=new Ci(e)}catch{throw new SyntaxError(`Invalid URL: ${e}`)}d.protocol==="http:"?d.protocol="ws:":d.protocol==="https:"&&(d.protocol="wss:"),n._url=d.href;let u=d.protocol==="wss:",f=d.protocol==="ws+unix:",p;if(d.protocol!=="ws:"&&!u&&!f?p=`The URL's protocol must be one of "ws:", "wss:", "http:", "https:", or "ws+unix:"`:f&&!d.pathname?p="The URL's pathname is empty":d.hash&&(p="The URL contains a fragment identifier"),p){let k=new SyntaxError(p);if(n._redirects===0)throw k;hr(n,k);return}let h=u?443:80,y=nl(16).toString("base64"),w=u?Qf.request:el.request,A=new Set,I;if(a.createConnection=a.createConnection||(u?wl:ml),a.defaultPort=a.defaultPort||h,a.port=d.port||h,a.host=d.hostname.startsWith("[")?d.hostname.slice(1,-1):d.hostname,a.headers={...a.headers,"Sec-WebSocket-Version":a.protocolVersion,"Sec-WebSocket-Key":y,Connection:"Upgrade",Upgrade:"websocket"},a.path=d.pathname+d.search,a.timeout=a.handshakeTimeout,a.perMessageDeflate&&(I=new dt({...a.perMessageDeflate,isServer:!1,maxPayload:a.maxPayload}),a.headers["Sec-WebSocket-Extensions"]=ll({[dt.extensionName]:I.offer()})),s.length){for(let k of s){if(typeof k!="string"||!hl.test(k)||A.has(k))throw new SyntaxError("An invalid or duplicated subprotocol was specified");A.add(k)}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),(d.username||d.password)&&(a.auth=`${d.username}:${d.password}`),f){let k=a.path.split(":");a.socketPath=k[0],a.path=k[1]}let E;if(a.followRedirects){if(n._redirects===0){n._originalIpc=f,n._originalSecure=u,n._originalHostOrSocketPath=f?a.socketPath:d.host;let k=o&&o.headers;if(o={...o,headers:{}},k)for(let[L,$]of Object.entries(k))o.headers[L.toLowerCase()]=$}else if(n.listenerCount("redirect")===0){let k=f?n._originalIpc?a.socketPath===n._originalHostOrSocketPath:!1:n._originalIpc?!1:d.host===n._originalHostOrSocketPath;(!k||n._originalSecure&&!u)&&(delete a.headers.authorization,delete a.headers.cookie,k||delete a.headers.host,a.auth=void 0)}a.auth&&!o.headers.authorization&&(o.headers.authorization="Basic "+Buffer.from(a.auth).toString("base64")),E=n._req=w(a),n._redirects&&n.emit("redirect",n.url,E)}else E=n._req=w(a);a.timeout&&E.on("timeout",()=>{Ae(n,E,"Opening handshake has timed out")}),E.on("error",k=>{E===null||E[Wa]||(E=n._req=null,hr(n,k))}),E.on("response",k=>{let L=k.headers.location,$=k.statusCode;if(L&&a.followRedirects&&$>=300&&$<400){if(++n._redirects>a.maxRedirects){Ae(n,E,"Maximum redirects exceeded");return}E.abort();let H;try{H=new Ci(L,e)}catch{let W=new SyntaxError(`Invalid URL: ${L}`);hr(n,W);return}$a(n,H,s,o)}else n.emit("unexpected-response",E,k)||Ae(n,E,`Unexpected server response: ${k.statusCode}`)}),E.on("upgrade",(k,L,$)=>{if(n.emit("upgrade",k),n.readyState!==V.CONNECTING)return;E=n._req=null;let H=k.headers.upgrade;if(H===void 0||H.toLowerCase()!=="websocket"){Ae(n,L,"Invalid Upgrade header");return}let ae=rl("sha1").update(y+cl).digest("base64");if(k.headers["sec-websocket-accept"]!==ae){Ae(n,L,"Invalid Sec-WebSocket-Accept header");return}let W=k.headers["sec-websocket-protocol"],ge;if(W!==void 0?A.size?A.has(W)||(ge="Server sent an invalid subprotocol"):ge="Server sent a subprotocol but none was requested":A.size&&(ge="Server sent no subprotocol"),ge){Ae(n,L,ge);return}W&&(n._protocol=W);let _e=k.headers["sec-websocket-extensions"];if(_e!==void 0){if(!I){Ae(n,L,"Server sent a Sec-WebSocket-Extensions header but no extension was requested");return}let ke;try{ke=gl(_e)}catch{Ae(n,L,"Invalid Sec-WebSocket-Extensions header");return}let de=Object.keys(ke);if(de.length!==1||de[0]!==dt.extensionName){Ae(n,L,"Server indicated an extension that was not requested");return}try{I.accept(ke[dt.extensionName])}catch{Ae(n,L,"Invalid Sec-WebSocket-Extensions header");return}n._extensions[dt.extensionName]=I}n.setSocket(L,$,{allowSynchronousEvents:a.allowSynchronousEvents,generateMask:a.generateMask,maxPayload:a.maxPayload,skipUTF8Validation:a.skipUTF8Validation})}),a.finishRequest?a.finishRequest(E,n):E.end()}function hr(n,e){n._readyState=V.CLOSING,n._errorEmitted=!0,n.emit("error",e),n.emitClose()}function ml(n){return n.path=n.socketPath,Ha.connect(n)}function wl(n){return n.path=void 0,!n.servername&&n.servername!==""&&(n.servername=Ha.isIP(n.host)?"":n.host),tl.connect(n)}function Ae(n,e,s){n._readyState=V.CLOSING;let o=new Error(s);Error.captureStackTrace(o,Ae),e.setHeader?(e[Wa]=!0,e.abort(),e.socket&&!e.socket.destroyed&&e.socket.destroy(),process.nextTick(hr,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=ol(e)?e.size:pl(e).length;n._socket?n._sender._bufferedBytes+=o:n._bufferedAmount+=o}if(s){let o=new Error(`WebSocket is not open: readyState ${n.readyState} (${Ze[n.readyState]})`);process.nextTick(s,o)}}function _l(n,e){let s=this[xe];s._closeFrameReceived=!0,s._closeMessage=e,s._closeCode=n,s._socket[xe]!==void 0&&(s._socket.removeListener("data",mr),process.nextTick(Ja,s._socket),n===1005?s.close():s.close(n,e))}function yl(){let n=this[xe];n.isPaused||n._socket.resume()}function bl(n){let e=this[xe];e._socket[xe]!==void 0&&(e._socket.removeListener("data",mr),process.nextTick(Ja,e._socket),e.close(n[dl])),e._errorEmitted||(e._errorEmitted=!0,e.emit("error",n))}function ja(){this[xe].emitClose()}function vl(n,e){this[xe].emit("message",n,e)}function Sl(n){let e=this[xe];e._autoPong&&e.pong(n,!this._isServer,Ka),e.emit("ping",n)}function El(n){this[xe].emit("pong",n)}function Ja(n){n.resume()}function Al(n){let e=this[xe];e.readyState!==V.CLOSED&&(e.readyState===V.OPEN&&(e._readyState=V.CLOSING,Va(e)),this._socket.end(),e._errorEmitted||(e._errorEmitted=!0,e.emit("error",n)))}function Va(n){n._closeTimer=setTimeout(n._socket.destroy.bind(n._socket),n._closeTimeout)}function Xa(){let n=this[xe];if(this.removeListener("close",Xa),this.removeListener("data",mr),this.removeListener("end",Ya),n._readyState=V.CLOSING,!this._readableState.endEmitted&&!n._closeFrameReceived&&!n._receiver._writableState.errorEmitted&&this._readableState.length!==0){let e=this.read(this._readableState.length);n._receiver.write(e)}n._receiver.end(),this[xe]=void 0,clearTimeout(n._closeTimer),n._receiver._writableState.finished||n._receiver._writableState.errorEmitted?n.emitClose():(n._receiver.on("error",ja),n._receiver.on("finish",ja))}function mr(n){this[xe]._receiver.write(n)||this.pause()}function Ya(){let n=this[xe];n._readyState=V.CLOSING,n._receiver.end(),this.end()}function Za(){let n=this[xe];this.removeListener("error",Za),this.on("error",Ka),n&&(n._readyState=V.CLOSING,this.destroy())}});var rc=ve((B_,nc)=>{"use strict";var M_=wr(),{Duplex:Il}=ne("stream");function ec(n){n.emit("close")}function Tl(){!this.destroyed&&this._writableState.finished&&this.destroy()}function tc(n){this.removeListener("error",tc),this.destroy(),this.listenerCount("error")===0&&this.emit("error",n)}function Pl(n,e){let s=!0,o=new Il({...e,autoDestroy:!1,emitClose:!1,objectMode:!1,writableObjectMode:!1});return n.on("message",function(d,u){let f=!u&&o._readableState.objectMode?d.toString():d;o.push(f)||n.pause()}),n.once("error",function(d){o.destroyed||(s=!1,o.destroy(d))}),n.once("close",function(){o.destroyed||o.push(null)}),o._destroy=function(a,d){if(n.readyState===n.CLOSED){d(a),process.nextTick(ec,o);return}let u=!1;n.once("error",function(p){u=!0,d(p)}),n.once("close",function(){u||d(a),process.nextTick(ec,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,d,u){if(n.readyState===n.CONNECTING){n.once("open",function(){o._write(a,d,u)});return}n.send(a,u)},o.on("end",Tl),o.on("error",tc),o}nc.exports=Pl});var Oi=ve((z_,ic)=>{"use strict";var{tokenChars:Cl}=qt();function kl(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&&Cl[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 d=n.slice(s,a);if(e.has(d))throw new SyntaxError(`The "${d}" subprotocol is duplicated`);return e.add(d),e}ic.exports={parse:kl}});var uc=ve((U_,dc)=>{"use strict";var Dl=ne("events"),_r=ne("http"),{Duplex:F_}=ne("stream"),{createHash:Rl}=ne("crypto"),sc=gr(),mt=Ut(),Ol=Oi(),Nl=wr(),{CLOSE_TIMEOUT:Ll,GUID:Ml,kWebSocket:Bl}=Ve(),zl=/^[+/0-9A-Za-z]{22}==$/,oc=0,ac=1,xc=2,Ni=class extends Dl{constructor(e,s){if(super(),e={allowSynchronousEvents:!0,autoPong:!0,maxPayload:100*1024*1024,skipUTF8Validation:!1,perMessageDeflate:!1,handleProtocols:null,clientTracking:!0,closeTimeout:Ll,verifyClient:null,noServer:!1,backlog:null,server:null,host:null,path:null,port:null,WebSocket:Nl,...e},e.port==null&&!e.server&&!e.noServer||e.port!=null&&(e.server||e.noServer)||e.server&&e.noServer)throw new TypeError('One and only one of the "port", "server", or "noServer" options must be specified');if(e.port!=null?(this._server=_r.createServer((o,a)=>{let d=_r.STATUS_CODES[426];a.writeHead(426,{"Content-Length":d.length,"Content-Type":"text/plain"}),a.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=Fl(this._server,{listening:this.emit.bind(this,"listening"),error:this.emit.bind(this,"error"),upgrade:(a,d,u)=>{this.handleUpgrade(a,d,u,o)}})}e.perMessageDeflate===!0&&(e.perMessageDeflate={}),e.clientTracking&&(this.clients=new Set,this._shouldEmitClose=!1),this.options=e,this._state=oc}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===xc){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!==ac)if(this._state=ac,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",cc);let d=e.headers["sec-websocket-key"],u=e.headers.upgrade,f=+e.headers["sec-websocket-version"];if(e.method!=="GET"){wt(this,e,s,405,"Invalid HTTP method");return}if(u===void 0||u.toLowerCase()!=="websocket"){wt(this,e,s,400,"Invalid Upgrade header");return}if(d===void 0||!zl.test(d)){wt(this,e,s,400,"Missing or invalid Sec-WebSocket-Key header");return}if(f!==13&&f!==8){wt(this,e,s,400,"Missing or invalid Sec-WebSocket-Version header",{"Sec-WebSocket-Version":"13, 8"});return}if(!this.shouldHandle(e)){hn(s,400);return}let p=e.headers["sec-websocket-protocol"],h=new Set;if(p!==void 0)try{h=Ol.parse(p)}catch{wt(this,e,s,400,"Invalid Sec-WebSocket-Protocol header");return}let y=e.headers["sec-websocket-extensions"],w={};if(this.options.perMessageDeflate&&y!==void 0){let A=new mt({...this.options.perMessageDeflate,isServer:!0,maxPayload:this.options.maxPayload});try{let I=sc.parse(y);I[mt.extensionName]&&(A.accept(I[mt.extensionName]),w[mt.extensionName]=A)}catch{wt(this,e,s,400,"Invalid or unacceptable Sec-WebSocket-Extensions header");return}}if(this.options.verifyClient){let A={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(A,(I,E,k,L)=>{if(!I)return hn(s,E||401,k,L);this.completeUpgrade(w,d,h,e,s,o,a)});return}if(!this.options.verifyClient(A))return hn(s,401)}this.completeUpgrade(w,d,h,e,s,o,a)}completeUpgrade(e,s,o,a,d,u,f){if(!d.readable||!d.writable)return d.destroy();if(d[Bl])throw new Error("server.handleUpgrade() was called more than once with the same socket, possibly due to a misconfiguration");if(this._state>oc)return hn(d,503);let h=["HTTP/1.1 101 Switching Protocols","Upgrade: websocket","Connection: Upgrade",`Sec-WebSocket-Accept: ${Rl("sha1").update(s+Ml).digest("base64")}`],y=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&&(h.push(`Sec-WebSocket-Protocol: ${w}`),y._protocol=w)}if(e[mt.extensionName]){let w=e[mt.extensionName].params,A=sc.format({[mt.extensionName]:[w]});h.push(`Sec-WebSocket-Extensions: ${A}`),y._extensions=e}this.emit("headers",h,a),d.write(h.concat(`\r
8
+ var Vd=Object.create;var gi=Object.defineProperty;var Zd=Object.getOwnPropertyDescriptor;var Yd=Object.getOwnPropertyNames;var Xd=Object.getPrototypeOf,Qd=Object.prototype.hasOwnProperty;var re=(n=>typeof require<"u"?require:typeof Proxy<"u"?new Proxy(n,{get:(e,i)=>(typeof require<"u"?require:e)[i]}):n)(function(n){if(typeof require<"u")return require.apply(this,arguments);throw Error('Dynamic require of "'+n+'" is not supported')});var Be=(n,e)=>()=>(n&&(e=n(n=0)),e);var Q=(n,e)=>()=>(e||n((e={exports:{}}).exports,e),e.exports),hi=(n,e)=>{for(var i in e)gi(n,i,{get:e[i],enumerable:!0})},eu=(n,e,i,o)=>{if(e&&typeof e=="object"||typeof e=="function")for(let a of Yd(e))!Qd.call(n,a)&&a!==i&&gi(n,a,{get:()=>e[a],enumerable:!(o=Zd(e,a))||o.enumerable});return n};var Ge=(n,e,i)=>(i=n!=null?Vd(Xd(n)):{},eu(e||!n||!n.__esModule?gi(i,"default",{value:n,enumerable:!0}):i,n));function Vs(n){return zn[$s]<=zn[n]}function Fn(n){Js={...n}}function ru(n){let e=(x,l=2)=>String(x).padStart(l,"0"),i=-n.getTimezoneOffset(),o=i>=0?"+":"-",a=Math.abs(i),c=e(Math.floor(a/60)),u=e(a%60);return`${n.getFullYear()}-${e(n.getMonth()+1)}-${e(n.getDate())}T${e(n.getHours())}:${e(n.getMinutes())}:${e(n.getSeconds())}.${e(n.getMilliseconds(),3)}${o}${c}:${u}`}function Bn(n,e,i,o){if(zn[n]<zn[$s])return;let a=JSON.stringify({ts:ru(new Date),level:n,module:e,msg:i,...Js,...o});n==="error"||n==="warn"?nu.write(`${a}
9
+ `):tu.write(`${a}
10
+ `)}function q(n){return{debug:(e,i)=>Bn("debug",n,e,i),info:(e,i)=>Bn("info",n,e,i),warn:(e,i)=>Bn("warn",n,e,i),error:(e,i)=>Bn("error",n,e,i),child:e=>q(`${n}.${e}`)}}var zn,$s,tu,nu,Js,Z=Be(()=>{"use strict";zn={debug:10,info:20,warn:30,error:40},$s=(()=>{let n=process.env.COZE_BRIDGE_LOG_LEVEL;return n==="debug"||n==="info"||n==="warn"||n==="error"?n:"info"})(),tu=process.stdout,nu=process.stderr,Js={}});import{chmod as mu,mkdir as wu,readFile as _u,rename as to,writeFile as no}from"node:fs/promises";import{dirname as yu}from"node:path";async function Ft(n){try{let e=await _u(n,"utf8");return JSON.parse(e)}catch(e){if(e.code==="ENOENT")return null;throw e}}async function Gn(n,e,i){await wu(yu(n),{recursive:!0});let o=`${JSON.stringify(e,null,2)}
11
+ `,a=`${n}.tmp-${process.pid}-${Math.random().toString(36).slice(2,10)}`;try{i?.mode!==void 0?await no(a,o,{encoding:"utf8",mode:i.mode}):await no(a,o,"utf8"),await to(a,n),i?.mode!==void 0&&await mu(n,i.mode)}catch(c){await to(a,a).catch(()=>{});let{rm:u}=await import("node:fs/promises");throw await u(a,{force:!0}).catch(()=>{}),c}}var jn=Be(()=>{"use strict"});import{promises as ro}from"node:fs";import{homedir as Eu}from"node:os";import{sep as bu,join as Ie,resolve as io}from"node:path";function Y(n){let e=n??Eu(),i=Ie(e,".coze"),o=Ie(i,"bridge"),a=Ie(o,"lib");return{cozeRoot:i,bridgeRoot:o,libDir:a,libEntry:Ie(a,"index.js"),binDir:Ie(o,"bin"),pidFile:Ie(o,"bridge.pid"),portFile:Ie(o,"bridge.port"),tokenFile:Ie(o,"bridge.token"),patTokenFile:Ie(o,"pat-token"),logFile:Ie(o,"bridge.log"),installLock:Ie(o,"install.lock"),configFile:Ie(o,"config.json"),agentsRoot:Ie(i,"agents")}}function rt(n,e=Y()){let i=Ie(e.agentsRoot,n);return{root:i,config:Ie(i,"config.json"),workspace:Ie(i,"workspace"),logs:Ie(i,"logs")}}async function so(n,e){let i=await ro.realpath(io(n)).catch(()=>null);if(!i)return!1;let o=await ro.realpath(io(e)).catch(()=>null);if(!o)return!1;let a=process.platform==="win32"?i.toLowerCase():i,c=process.platform==="win32"?o.toLowerCase():o;return a===c||a.startsWith(c+bu)}var ye=Be(()=>{"use strict"});var $n={};hi($n,{AGENT_CONFIG_FILE_MODE:()=>Kn,enforceAgentConfigMode:()=>Iu,loadAgentConfig:()=>Te,persistAgentSessions:()=>pi,persistAgentSkills:()=>Wn,saveAgentConfig:()=>Ne});import{chmod as vu,stat as Su}from"node:fs/promises";function Te(n,e){return Ft(rt(n,e).config)}function Ne(n,e){return Gn(rt(n.agentId,e).config,n,{mode:Kn})}async function Iu(n,e){if(process.platform==="win32")return;let i=rt(n,e).config;try{let o=await Su(i);if(!o.isFile())return;let a=o.mode&511;a!==Kn&&(await vu(i,Kn),oo.warn("agent config mode auto-corrected to 0600",{path:i,from:a.toString(8)}))}catch(o){if(o.code==="ENOENT")return;oo.warn("enforceAgentConfigMode: chmod failed (ignored)",{path:i,err:String(o)})}}async function pi(n,e,i){let o=await Te(n,i);o&&(o.sessions=Object.fromEntries(e),await Ne(o,i))}async function Wn(n,e,i){let o=await Te(n,i);o&&(o.skills=e,await Ne(o,i))}var oo,Kn,lt=Be(()=>{"use strict";jn();Z();ye();oo=q("agent-config"),Kn=384});var wi=Q((bm,fo)=>{fo.exports={LOCHDR:30,LOCSIG:67324752,LOCVER:4,LOCFLG:6,LOCHOW:8,LOCTIM:10,LOCCRC:14,LOCSIZ:18,LOCLEN:22,LOCNAM:26,LOCEXT:28,EXTSIG:134695760,EXTHDR:16,EXTCRC:4,EXTSIZ:8,EXTLEN:12,CENHDR:46,CENSIG:33639248,CENVEM:4,CENVER:6,CENFLG:8,CENHOW:10,CENTIM:12,CENCRC:16,CENSIZ:20,CENLEN:24,CENNAM:28,CENEXT:30,CENCOM:32,CENDSK:34,CENATT:36,CENATX:38,CENOFF:42,ENDHDR:22,ENDSIG:101010256,ENDSUB:8,ENDTOT:10,ENDSIZ:12,ENDOFF:16,ENDCOM:20,END64HDR:20,END64SIG:117853008,END64START:4,END64OFF:8,END64NUMDISKS:16,ZIP64SIG:101075792,ZIP64HDR:56,ZIP64LEAD:12,ZIP64SIZE:4,ZIP64VEM:12,ZIP64VER:14,ZIP64DSK:16,ZIP64DSKDIR:20,ZIP64SUB:24,ZIP64TOT:32,ZIP64SIZB:40,ZIP64OFF:48,ZIP64EXTRA:56,STORED:0,SHRUNK:1,REDUCED1:2,REDUCED2:3,REDUCED3:4,REDUCED4:5,IMPLODED:6,DEFLATED:8,ENHANCED_DEFLATED:9,PKWARE:10,BZIP2:12,LZMA:14,IBM_TERSE:18,IBM_LZ77:19,AES_ENCRYPT:99,FLG_ENC:1,FLG_COMP1:2,FLG_COMP2:4,FLG_DESC:8,FLG_ENH:16,FLG_PATCH:32,FLG_STR:64,FLG_EFS:2048,FLG_MSK:4096,FILE:2,BUFFER:1,NONE:0,EF_ID:0,EF_SIZE:2,ID_ZIP64:1,ID_AVINFO:7,ID_PFS:8,ID_OS2:9,ID_NTFS:10,ID_OPENVMS:12,ID_UNIX:13,ID_FORK:14,ID_PATCH:15,ID_X509_PKCS7:20,ID_X509_CERTID_F:21,ID_X509_CERTID_C:22,ID_STRONGENC:23,ID_RECORD_MGT:24,ID_X509_PKCS7_RL:25,ID_IBM1:101,ID_IBM2:102,ID_POSZIP:18064,EF_ZIP64_OR_32:4294967295,EF_ZIP64_OR_16:65535,EF_ZIP64_SUNCOMP:0,EF_ZIP64_SCOMP:8,EF_ZIP64_RHO:16,EF_ZIP64_DSN:24}});var Vn=Q(lo=>{var xo={INVALID_LOC:"Invalid LOC header (bad signature)",INVALID_CEN:"Invalid CEN header (bad signature)",INVALID_END:"Invalid END header (bad signature)",DESCRIPTOR_NOT_EXIST:"No descriptor present",DESCRIPTOR_UNKNOWN:"Unknown descriptor format",DESCRIPTOR_FAULTY:"Descriptor data is malformed",NO_DATA:"Nothing to decompress",BAD_CRC:"CRC32 checksum failed {0}",FILE_IN_THE_WAY:"There is a file in the way: {0}",UNKNOWN_METHOD:"Invalid/unsupported compression method",AVAIL_DATA:"inflate::Available inflate data did not terminate",INVALID_DISTANCE:"inflate::Invalid literal/length or distance code in fixed or dynamic block",TO_MANY_CODES:"inflate::Dynamic block code description: too many length or distance codes",INVALID_REPEAT_LEN:"inflate::Dynamic block code description: repeat more than specified lengths",INVALID_REPEAT_FIRST:"inflate::Dynamic block code description: repeat lengths with no first length",INCOMPLETE_CODES:"inflate::Dynamic block code description: code lengths codes incomplete",INVALID_DYN_DISTANCE:"inflate::Dynamic block code description: invalid distance code lengths",INVALID_CODES_LEN:"inflate::Dynamic block code description: invalid literal/length code lengths",INVALID_STORE_BLOCK:"inflate::Stored block length did not match one's complement",INVALID_BLOCK_TYPE:"inflate::Invalid block type (type == 3)",CANT_EXTRACT_FILE:"Could not extract the file",CANT_OVERRIDE:"Target file already exists",DISK_ENTRY_TOO_LARGE:"Number of disk entries is too large",NO_ZIP:"No zip file was loaded",NO_ENTRY:"Entry doesn't exist",DIRECTORY_CONTENT_ERROR:"A directory cannot have content",FILE_NOT_FOUND:'File not found: "{0}"',NOT_IMPLEMENTED:"Not implemented",INVALID_FILENAME:"Invalid filename",INVALID_FORMAT:"Invalid or unsupported zip format. No END header found",INVALID_PASS_PARAM:"Incompatible password parameter",WRONG_PASSWORD:"Wrong Password",COMMENT_TOO_LONG:"Comment is too long",EXTRA_FIELD_PARSE_ERROR:"Extra field parsing error"};function Ru(n){return function(...e){return e.length&&(n=n.replace(/\{(\d)\}/g,(i,o)=>e[o]||"")),new Error("ADM-ZIP: "+n)}}for(let n of Object.keys(xo))lo[n]=Ru(xo[n])});var wo=Q((Sm,mo)=>{var Nu=re("fs"),Ee=re("path"),go=wi(),Lu=Vn(),Ou=typeof process=="object"&&process.platform==="win32",ho=n=>typeof n=="object"&&n!==null,po=new Uint32Array(256).map((n,e)=>{for(let i=0;i<8;i++)(e&1)!==0?e=3988292384^e>>>1:e>>>=1;return e>>>0});function le(n){this.sep=Ee.sep,this.fs=Nu,ho(n)&&ho(n.fs)&&typeof n.fs.statSync=="function"&&(this.fs=n.fs)}mo.exports=le;le.prototype.makeDir=function(n){let e=this;function i(o){let a=o.split(e.sep)[0];o.split(e.sep).forEach(function(c){if(!(!c||c.substr(-1,1)===":")){a+=e.sep+c;var u;try{u=e.fs.statSync(a)}catch(x){if(x.message&&x.message.startsWith("ENOENT"))e.fs.mkdirSync(a);else throw x}if(u&&u.isFile())throw Lu.FILE_IN_THE_WAY(`"${a}"`)}})}i(n)};le.prototype.writeFileTo=function(n,e,i,o){let a=this;if(a.fs.existsSync(n)){if(!i)return!1;var c=a.fs.statSync(n);if(c.isDirectory())return!1}var u=Ee.dirname(n);a.fs.existsSync(u)||a.makeDir(u);var x;try{x=a.fs.openSync(n,"w",438)}catch{a.fs.chmodSync(n,438),x=a.fs.openSync(n,"w",438)}if(x)try{a.fs.writeSync(x,e,0,e.length,0)}finally{a.fs.closeSync(x)}return a.fs.chmodSync(n,o||438),!0};le.prototype.writeFileToAsync=function(n,e,i,o,a){typeof o=="function"&&(a=o,o=void 0);let c=this;c.fs.exists(n,function(u){if(u&&!i)return a(!1);c.fs.stat(n,function(x,l){if(u&&l.isDirectory())return a(!1);var g=Ee.dirname(n);c.fs.exists(g,function(E){E||c.makeDir(g),c.fs.open(n,"w",438,function(w,A){w?c.fs.chmod(n,438,function(){c.fs.open(n,"w",438,function(_,b){c.fs.write(b,e,0,e.length,0,function(){c.fs.close(b,function(){c.fs.chmod(n,o||438,function(){a(!0)})})})})}):A?c.fs.write(A,e,0,e.length,0,function(){c.fs.close(A,function(){c.fs.chmod(n,o||438,function(){a(!0)})})}):c.fs.chmod(n,o||438,function(){a(!0)})})})})})};le.prototype.findFiles=function(n){let e=this;function i(o,a,c){typeof a=="boolean"&&(c=a,a=void 0);let u=[];return e.fs.readdirSync(o).forEach(function(x){let l=Ee.join(o,x),g=e.fs.statSync(l);(!a||a.test(l))&&u.push(Ee.normalize(l)+(g.isDirectory()?e.sep:"")),g.isDirectory()&&c&&(u=u.concat(i(l,a,c)))}),u}return i(n,void 0,!0)};le.prototype.findFilesAsync=function(n,e){let i=this,o=[];i.fs.readdir(n,function(a,c){if(a)return e(a);let u=c.length;if(!u)return e(null,o);c.forEach(function(x){x=Ee.join(n,x),i.fs.stat(x,function(l,g){if(l)return e(l);g&&(o.push(Ee.normalize(x)+(g.isDirectory()?i.sep:"")),g.isDirectory()?i.findFilesAsync(x,function(E,w){if(E)return e(E);o=o.concat(w),--u||e(null,o)}):--u||e(null,o))})})})};le.prototype.getAttributes=function(){};le.prototype.setAttributes=function(){};le.crc32update=function(n,e){return po[(n^e)&255]^n>>>8};le.crc32=function(n){typeof n=="string"&&(n=Buffer.from(n,"utf8"));let e=n.length,i=-1;for(let o=0;o<e;)i=le.crc32update(i,n[o++]);return~i>>>0};le.methodToString=function(n){switch(n){case go.STORED:return"STORED ("+n+")";case go.DEFLATED:return"DEFLATED ("+n+")";default:return"UNSUPPORTED ("+n+")"}};le.canonical=function(n){if(!n)return"";let e=Ee.posix.normalize("/"+n.split("\\").join("/"));return Ee.join(".",e)};le.zipnamefix=function(n){if(!n)return"";let e=Ee.posix.normalize("/"+n.split("\\").join("/"));return Ee.posix.join(".",e)};le.findLast=function(n,e){if(!Array.isArray(n))throw new TypeError("arr is not array");let i=n.length>>>0;for(let o=i-1;o>=0;o--)if(e(n[o],o,n))return n[o]};le.sanitize=function(n,e){n=Ee.resolve(Ee.normalize(n));for(var i=e.split("/"),o=0,a=i.length;o<a;o++){var c=Ee.normalize(Ee.join(n,i.slice(o,a).join(Ee.sep)));if(c.indexOf(n)===0)return c}return Ee.normalize(Ee.join(n,Ee.basename(e)))};le.toBuffer=function(e,i){return Buffer.isBuffer(e)?e:e instanceof Uint8Array?Buffer.from(e):typeof e=="string"?i(e):Buffer.alloc(0)};le.readBigUInt64LE=function(n,e){let i=n.readUInt32LE(e);return n.readUInt32LE(e+4)*4294967296+i};le.fromDOS2Date=function(n){return new Date((n>>25&127)+1980,Math.max((n>>21&15)-1,0),Math.max(n>>16&31,1),n>>11&31,n>>5&63,(n&31)<<1)};le.fromDate2DOS=function(n){let e=0,i=0;return n.getFullYear()>1979&&(e=(n.getFullYear()-1980&127)<<9|n.getMonth()+1<<5|n.getDate(),i=n.getHours()<<11|n.getMinutes()<<5|n.getSeconds()>>1),e<<16|i};le.isWin=Ou;le.crcTable=po});var yo=Q((Im,_o)=>{var Mu=re("path");_o.exports=function(n,{fs:e}){var i=n||"",o=c(),a=null;function c(){return{directory:!1,readonly:!1,hidden:!1,executable:!1,mtime:0,atime:0}}return i&&e.existsSync(i)?(a=e.statSync(i),o.directory=a.isDirectory(),o.mtime=a.mtime,o.atime=a.atime,o.executable=(73&a.mode)!==0,o.readonly=(128&a.mode)===0,o.hidden=Mu.basename(i)[0]==="."):console.warn("Invalid path: "+i),{get directory(){return o.directory},get readOnly(){return o.readonly},get hidden(){return o.hidden},get mtime(){return o.mtime},get atime(){return o.atime},get executable(){return o.executable},decodeAttributes:function(){},encodeAttributes:function(){},toJSON:function(){return{path:i,isDirectory:o.directory,isReadOnly:o.readonly,isHidden:o.hidden,isExecutable:o.executable,mTime:o.mtime,aTime:o.atime}},toString:function(){return JSON.stringify(this.toJSON(),null," ")}}}});var bo=Q((Am,Eo)=>{Eo.exports={efs:!0,encode:n=>Buffer.from(n,"utf8"),decode:n=>n.toString("utf8")}});var Ht=Q((Cm,qt)=>{qt.exports=wo();qt.exports.Constants=wi();qt.exports.Errors=Vn();qt.exports.FileAttr=yo();qt.exports.decoder=bo()});var So=Q((Tm,vo)=>{var gt=Ht(),U=gt.Constants;vo.exports=function(){var n=20,e=10,i=0,o=0,a=0,c=0,u=0,x=0,l=0,g=0,E=0,w=0,A=0,_=0,b=0;n|=gt.isWin?2560:768,i|=U.FLG_EFS;let S={extraLen:0},I=m=>Math.max(0,m)>>>0,k=m=>Math.max(0,m)&65535,L=m=>Math.max(0,m)&255;return a=gt.fromDate2DOS(new Date),{get made(){return n},set made(m){n=m},get version(){return e},set version(m){e=m},get flags(){return i},set flags(m){i=m},get flags_efs(){return(i&U.FLG_EFS)>0},set flags_efs(m){m?i|=U.FLG_EFS:i&=~U.FLG_EFS},get flags_desc(){return(i&U.FLG_DESC)>0},set flags_desc(m){m?i|=U.FLG_DESC:i&=~U.FLG_DESC},get method(){return o},set method(m){switch(m){case U.STORED:this.version=10;case U.DEFLATED:default:this.version=20}o=m},get time(){return gt.fromDOS2Date(this.timeval)},set time(m){m=new Date(m),this.timeval=gt.fromDate2DOS(m)},get timeval(){return a},set timeval(m){a=I(m)},get timeHighByte(){return L(a>>>8)},get crc(){return c},set crc(m){c=I(m)},get compressedSize(){return u},set compressedSize(m){u=I(m)},get size(){return x},set size(m){x=I(m)},get fileNameLength(){return l},set fileNameLength(m){l=m},get extraLength(){return g},set extraLength(m){g=m},get extraLocalLength(){return S.extraLen},set extraLocalLength(m){S.extraLen=m},get commentLength(){return E},set commentLength(m){E=m},get diskNumStart(){return w},set diskNumStart(m){w=I(m)},get inAttr(){return A},set inAttr(m){A=I(m)},get attr(){return _},set attr(m){_=I(m)},get fileAttr(){return(_||0)>>16&4095},get offset(){return b},set offset(m){b=I(m)},get encrypted(){return(i&U.FLG_ENC)===U.FLG_ENC},get centralHeaderSize(){return U.CENHDR+l+g+E},get realDataOffset(){return b+U.LOCHDR+S.fnameLen+S.extraLen},get localHeader(){return S},loadLocalHeaderFromBinary:function(m){var C=m.slice(b,b+U.LOCHDR);if(C.readUInt32LE(0)!==U.LOCSIG)throw gt.Errors.INVALID_LOC();S.version=C.readUInt16LE(U.LOCVER),S.flags=C.readUInt16LE(U.LOCFLG),S.flags_desc=(S.flags&U.FLG_DESC)>0,S.method=C.readUInt16LE(U.LOCHOW),S.time=C.readUInt32LE(U.LOCTIM),S.crc=C.readUInt32LE(U.LOCCRC),S.compressedSize=C.readUInt32LE(U.LOCSIZ),S.size=C.readUInt32LE(U.LOCLEN),S.fnameLen=C.readUInt16LE(U.LOCNAM),S.extraLen=C.readUInt16LE(U.LOCEXT);let R=b+U.LOCHDR+S.fnameLen,F=R+S.extraLen;return m.slice(R,F)},loadFromBinary:function(m){if(m.length!==U.CENHDR||m.readUInt32LE(0)!==U.CENSIG)throw gt.Errors.INVALID_CEN();n=m.readUInt16LE(U.CENVEM),e=m.readUInt16LE(U.CENVER),i=m.readUInt16LE(U.CENFLG),o=m.readUInt16LE(U.CENHOW),a=m.readUInt32LE(U.CENTIM),c=m.readUInt32LE(U.CENCRC),u=m.readUInt32LE(U.CENSIZ),x=m.readUInt32LE(U.CENLEN),l=m.readUInt16LE(U.CENNAM),g=m.readUInt16LE(U.CENEXT),E=m.readUInt16LE(U.CENCOM),w=m.readUInt16LE(U.CENDSK),A=m.readUInt16LE(U.CENATT),_=m.readUInt32LE(U.CENATX),b=m.readUInt32LE(U.CENOFF)},localHeaderToBinary:function(){var m=Buffer.alloc(U.LOCHDR);return m.writeUInt32LE(U.LOCSIG,0),m.writeUInt16LE(e,U.LOCVER),m.writeUInt16LE(i,U.LOCFLG),m.writeUInt16LE(o,U.LOCHOW),m.writeUInt32LE(a,U.LOCTIM),m.writeUInt32LE(c,U.LOCCRC),m.writeUInt32LE(u,U.LOCSIZ),m.writeUInt32LE(x,U.LOCLEN),m.writeUInt16LE(l,U.LOCNAM),m.writeUInt16LE(S.extraLen,U.LOCEXT),m},centralHeaderToBinary:function(){var m=Buffer.alloc(U.CENHDR+l+g+E);return m.writeUInt32LE(U.CENSIG,0),m.writeUInt16LE(n,U.CENVEM),m.writeUInt16LE(e,U.CENVER),m.writeUInt16LE(i,U.CENFLG),m.writeUInt16LE(o,U.CENHOW),m.writeUInt32LE(a,U.CENTIM),m.writeUInt32LE(c,U.CENCRC),m.writeUInt32LE(u,U.CENSIZ),m.writeUInt32LE(x,U.CENLEN),m.writeUInt16LE(l,U.CENNAM),m.writeUInt16LE(g,U.CENEXT),m.writeUInt16LE(E,U.CENCOM),m.writeUInt16LE(w,U.CENDSK),m.writeUInt16LE(A,U.CENATT),m.writeUInt32LE(_,U.CENATX),m.writeUInt32LE(b,U.CENOFF),m},toJSON:function(){let m=function(C){return C+" bytes"};return{made:n,version:e,flags:i,method:gt.methodToString(o),time:this.time,crc:"0x"+c.toString(16).toUpperCase(),compressedSize:m(u),size:m(x),fileNameLength:m(l),extraLength:m(g),commentLength:m(E),diskNumStart:w,inAttr:A,attr:_,offset:b,centralHeaderSize:m(U.CENHDR+l+g+E)}},toString:function(){return JSON.stringify(this.toJSON(),null," ")}}}});var Ao=Q((Dm,Io)=>{var Gt=Ht(),ce=Gt.Constants;Io.exports=function(){var n=0,e=0,i=0,o=0,a=0;return{get diskEntries(){return n},set diskEntries(c){n=e=c},get totalEntries(){return e},set totalEntries(c){e=n=c},get size(){return i},set size(c){i=c},get offset(){return o},set offset(c){o=c},get commentLength(){return a},set commentLength(c){a=c},get mainHeaderSize(){return ce.ENDHDR+a},loadFromBinary:function(c){if((c.length!==ce.ENDHDR||c.readUInt32LE(0)!==ce.ENDSIG)&&(c.length<ce.ZIP64HDR||c.readUInt32LE(0)!==ce.ZIP64SIG))throw Gt.Errors.INVALID_END();c.readUInt32LE(0)===ce.ENDSIG?(n=c.readUInt16LE(ce.ENDSUB),e=c.readUInt16LE(ce.ENDTOT),i=c.readUInt32LE(ce.ENDSIZ),o=c.readUInt32LE(ce.ENDOFF),a=c.readUInt16LE(ce.ENDCOM)):(n=Gt.readBigUInt64LE(c,ce.ZIP64SUB),e=Gt.readBigUInt64LE(c,ce.ZIP64TOT),i=Gt.readBigUInt64LE(c,ce.ZIP64SIZE),o=Gt.readBigUInt64LE(c,ce.ZIP64OFF),a=0)},toBinary:function(){var c=Buffer.alloc(ce.ENDHDR+a);return c.writeUInt32LE(ce.ENDSIG,0),c.writeUInt32LE(0,4),c.writeUInt16LE(n,ce.ENDSUB),c.writeUInt16LE(e,ce.ENDTOT),c.writeUInt32LE(i,ce.ENDSIZ),c.writeUInt32LE(o,ce.ENDOFF),c.writeUInt16LE(a,ce.ENDCOM),c.fill(" ",ce.ENDHDR),c},toJSON:function(){let c=function(u,x){let l=u.toString(16).toUpperCase();for(;l.length<x;)l="0"+l;return"0x"+l};return{diskEntries:n,totalEntries:e,size:i+" bytes",offset:c(o,4),commentLength:a}},toString:function(){return JSON.stringify(this.toJSON(),null," ")}}}});var yi=Q(_i=>{_i.EntryHeader=So();_i.MainHeader=Ao()});var To=Q((km,Co)=>{Co.exports=function(n){var e=re("zlib"),i={chunkSize:(parseInt(n.length/1024)+1)*1024};return{deflate:function(){return e.deflateRawSync(n,i)},deflateAsync:function(o){var a=e.createDeflateRaw(i),c=[],u=0;a.on("data",function(x){c.push(x),u+=x.length}),a.on("end",function(){var x=Buffer.alloc(u),l=0;x.fill(0);for(var g=0;g<c.length;g++){var E=c[g];E.copy(x,l),l+=E.length}o&&o(x)}),a.end(n)}}}});var Po=Q((Rm,Do)=>{var Bu=+(process.versions?process.versions.node:"").split(".")[0]||0;Do.exports=function(n,e){var i=re("zlib");let o=Bu>=15&&e>0?{maxOutputLength:e}:{};return{inflate:function(){return i.inflateRawSync(n,o)},inflateAsync:function(a){var c=i.createInflateRaw(o),u=[],x=0;c.on("data",function(l){u.push(l),x+=l.length}),c.on("end",function(){var l=Buffer.alloc(x),g=0;l.fill(0);for(var E=0;E<u.length;E++){var w=u[E];w.copy(l,g),g+=w.length}a&&a(l)}),c.end(n)}}}});var Oo=Q((Nm,Lo)=>{"use strict";var{randomFillSync:ko}=re("crypto"),zu=Vn(),Fu=new Uint32Array(256).map((n,e)=>{for(let i=0;i<8;i++)(e&1)!==0?e=e>>>1^3988292384:e>>>=1;return e>>>0}),No=(n,e)=>Math.imul(n,e)>>>0,Ro=(n,e)=>Fu[(n^e)&255]^n>>>8,fn=()=>typeof ko=="function"?ko(Buffer.alloc(12)):fn.node();fn.node=()=>{let n=Buffer.alloc(12),e=n.length;for(let i=0;i<e;i++)n[i]=Math.random()*256&255;return n};var Zn={genSalt:fn};function Yn(n){let e=Buffer.isBuffer(n)?n:Buffer.from(n);this.keys=new Uint32Array([305419896,591751049,878082192]);for(let i=0;i<e.length;i++)this.updateKeys(e[i])}Yn.prototype.updateKeys=function(n){let e=this.keys;return e[0]=Ro(e[0],n),e[1]+=e[0]&255,e[1]=No(e[1],134775813)+1,e[2]=Ro(e[2],e[1]>>>24),n};Yn.prototype.next=function(){let n=(this.keys[2]|2)>>>0;return No(n,n^1)>>8&255};function Uu(n){let e=new Yn(n);return function(i){let o=Buffer.alloc(i.length),a=0;for(let c of i)o[a++]=e.updateKeys(c^e.next());return o}}function qu(n){let e=new Yn(n);return function(i,o,a=0){o||(o=Buffer.alloc(i.length));for(let c of i){let u=e.next();o[a++]=c^u,e.updateKeys(c)}return o}}function Hu(n,e,i){if(!n||!Buffer.isBuffer(n)||n.length<12)return Buffer.alloc(0);let o=Uu(i),a=o(n.slice(0,12)),c=(e.flags&8)===8?e.timeHighByte:e.crc>>>24;if(a[11]!==c)throw zu.WRONG_PASSWORD();return o(n.slice(12))}function Gu(n){Buffer.isBuffer(n)&&n.length>=12?Zn.genSalt=function(){return n.slice(0,12)}:n==="node"?Zn.genSalt=fn.node:Zn.genSalt=fn}function ju(n,e,i,o=!1){n==null&&(n=Buffer.alloc(0)),Buffer.isBuffer(n)||(n=Buffer.from(n.toString()));let a=qu(i),c=Zn.genSalt();c[11]=e.crc>>>24&255,o&&(c[10]=e.crc>>>16&255);let u=Buffer.alloc(n.length+12);return a(c,u),a(n,u,12)}Lo.exports={decrypt:Hu,encrypt:ju,_salter:Gu}});var Mo=Q(Xn=>{Xn.Deflater=To();Xn.Inflater=Po();Xn.ZipCrypto=Oo()});var bi=Q((Om,Bo)=>{var ee=Ht(),Ku=yi(),ge=ee.Constants,Ei=Mo();Bo.exports=function(n,e){var i=new Ku.EntryHeader,o=Buffer.alloc(0),a=Buffer.alloc(0),c=!1,u=null,x=Buffer.alloc(0),l=Buffer.alloc(0),g=!0;let E=n,w=typeof E.decoder=="object"?E.decoder:ee.decoder;g=w.hasOwnProperty("efs")?w.efs:!1;function A(){return!e||!(e instanceof Uint8Array)?Buffer.alloc(0):(l=i.loadLocalHeaderFromBinary(e),e.slice(i.realDataOffset,i.realDataOffset+i.compressedSize))}function _(m){if(!i.flags_desc&&!i.localHeader.flags_desc){if(ee.crc32(m)!==i.localHeader.crc)return!1}else{let C={},R=i.realDataOffset+i.compressedSize;if(e.readUInt32LE(R)==ge.LOCSIG||e.readUInt32LE(R)==ge.CENSIG)throw ee.Errors.DESCRIPTOR_NOT_EXIST();if(e.readUInt32LE(R)==ge.EXTSIG)C.crc=e.readUInt32LE(R+ge.EXTCRC),C.compressedSize=e.readUInt32LE(R+ge.EXTSIZ),C.size=e.readUInt32LE(R+ge.EXTLEN);else if(e.readUInt16LE(R+12)===19280)C.crc=e.readUInt32LE(R+ge.EXTCRC-4),C.compressedSize=e.readUInt32LE(R+ge.EXTSIZ-4),C.size=e.readUInt32LE(R+ge.EXTLEN-4);else throw ee.Errors.DESCRIPTOR_UNKNOWN();if(C.compressedSize!==i.compressedSize||C.size!==i.size||C.crc!==i.crc)throw ee.Errors.DESCRIPTOR_FAULTY();if(ee.crc32(m)!==C.crc)return!1}return!0}function b(m,C,R){if(typeof C>"u"&&typeof m=="string"&&(R=m,m=void 0),c)return m&&C&&C(Buffer.alloc(0),ee.Errors.DIRECTORY_CONTENT_ERROR()),Buffer.alloc(0);var F=A();if(F.length===0)return m&&C&&C(F),F;if(i.encrypted){if(typeof R!="string"&&!Buffer.isBuffer(R))throw ee.Errors.INVALID_PASS_PARAM();F=Ei.ZipCrypto.decrypt(F,i,R)}var z=Buffer.alloc(i.size);switch(i.method){case ee.Constants.STORED:if(F.copy(z),_(z))return m&&C&&C(z),z;throw m&&C&&C(z,ee.Errors.BAD_CRC()),ee.Errors.BAD_CRC();case ee.Constants.DEFLATED:var $=new Ei.Inflater(F,i.size);if(m)$.inflateAsync(function(J){J.copy(J,0),C&&(_(J)?C(J):C(J,ee.Errors.BAD_CRC()))});else{if($.inflate(z).copy(z,0),!_(z))throw ee.Errors.BAD_CRC(`"${w.decode(o)}"`);return z}break;default:throw m&&C&&C(Buffer.alloc(0),ee.Errors.UNKNOWN_METHOD()),ee.Errors.UNKNOWN_METHOD()}}function S(m,C){if((!u||!u.length)&&Buffer.isBuffer(e))return m&&C&&C(A()),A();if(u.length&&!c){var R;switch(i.method){case ee.Constants.STORED:return i.compressedSize=i.size,R=Buffer.alloc(u.length),u.copy(R),m&&C&&C(R),R;default:case ee.Constants.DEFLATED:var F=new Ei.Deflater(u);if(m)F.deflateAsync(function($){R=Buffer.alloc($.length),i.compressedSize=$.length,$.copy(R),C&&C(R)});else{var z=F.deflate();return i.compressedSize=z.length,z}F=null;break}}else if(m&&C)C(Buffer.alloc(0));else return Buffer.alloc(0)}function I(m,C){return ee.readBigUInt64LE(m,C)}function k(m){try{for(var C=0,R,F,z;C+4<m.length;)R=m.readUInt16LE(C),C+=2,F=m.readUInt16LE(C),C+=2,z=m.slice(C,C+F),C+=F,ge.ID_ZIP64===R&&L(z)}catch{throw ee.Errors.EXTRA_FIELD_PARSE_ERROR()}}function L(m){var C,R,F,z;m.length>=ge.EF_ZIP64_SCOMP&&(C=I(m,ge.EF_ZIP64_SUNCOMP),i.size===ge.EF_ZIP64_OR_32&&(i.size=C)),m.length>=ge.EF_ZIP64_RHO&&(R=I(m,ge.EF_ZIP64_SCOMP),i.compressedSize===ge.EF_ZIP64_OR_32&&(i.compressedSize=R)),m.length>=ge.EF_ZIP64_DSN&&(F=I(m,ge.EF_ZIP64_RHO),i.offset===ge.EF_ZIP64_OR_32&&(i.offset=F)),m.length>=ge.EF_ZIP64_DSN+4&&(z=m.readUInt32LE(ge.EF_ZIP64_DSN),i.diskNumStart===ge.EF_ZIP64_OR_16&&(i.diskNumStart=z))}return{get entryName(){return w.decode(o)},get rawEntryName(){return o},set entryName(m){o=ee.toBuffer(m,w.encode);var C=o[o.length-1];c=C===47||C===92,i.fileNameLength=o.length},get efs(){return typeof g=="function"?g(this.entryName):g},get extra(){return x},set extra(m){x=m,i.extraLength=m.length,k(m)},get comment(){return w.decode(a)},set comment(m){if(a=ee.toBuffer(m,w.encode),i.commentLength=a.length,a.length>65535)throw ee.Errors.COMMENT_TOO_LONG()},get name(){var m=w.decode(o);return c?m.substr(m.length-1).split("/").pop():m.split("/").pop()},get isDirectory(){return c},getCompressedData:function(){return S(!1,null)},getCompressedDataAsync:function(m){S(!0,m)},setData:function(m){u=ee.toBuffer(m,ee.decoder.encode),!c&&u.length?(i.size=u.length,i.method=ee.Constants.DEFLATED,i.crc=ee.crc32(m),i.changed=!0):i.method=ee.Constants.STORED},getData:function(m){return i.changed?u:b(!1,null,m)},getDataAsync:function(m,C){i.changed?m(u):b(!0,m,C)},set attr(m){i.attr=m},get attr(){return i.attr},set header(m){i.loadFromBinary(m)},get header(){return i},packCentralHeader:function(){i.flags_efs=this.efs,i.extraLength=x.length;var m=i.centralHeaderToBinary(),C=ee.Constants.CENHDR;return o.copy(m,C),C+=o.length,x.copy(m,C),C+=i.extraLength,a.copy(m,C),m},packLocalHeader:function(){let m=0;i.flags_efs=this.efs,i.extraLocalLength=l.length;let C=i.localHeaderToBinary(),R=Buffer.alloc(C.length+o.length+i.extraLocalLength);return C.copy(R,m),m+=C.length,o.copy(R,m),m+=o.length,l.copy(R,m),m+=l.length,R},toJSON:function(){let m=function(C){return"<"+(C&&C.length+" bytes buffer"||"null")+">"};return{entryName:this.entryName,name:this.name,comment:this.comment,isDirectory:this.isDirectory,header:i.toJSON(),compressedData:m(e),data:m(u)}},toString:function(){return JSON.stringify(this.toJSON(),null," ")}}}});var Uo=Q((Mm,Fo)=>{var zo=bi(),Wu=yi(),Ae=Ht();Fo.exports=function(n,e){var i=[],o={},a=Buffer.alloc(0),c=new Wu.MainHeader,u=!1,x=null;let l=new Set,g=e,{noSort:E,decoder:w}=g;n?b(g.readEntries):u=!0;function A(){let I=new Set;for(let k of Object.keys(o)){let L=k.split("/");if(L.pop(),!!L.length)for(let m=0;m<L.length;m++){let C=L.slice(0,m+1).join("/")+"/";I.add(C)}}for(let k of I)if(!(k in o)){let L=new zo(g);L.entryName=k,L.attr=16,L.temporary=!0,i.push(L),o[L.entryName]=L,l.add(L)}}function _(){if(u=!0,o={},c.diskEntries>(n.length-c.offset)/Ae.Constants.CENHDR)throw Ae.Errors.DISK_ENTRY_TOO_LARGE();i=new Array(c.diskEntries);for(var I=c.offset,k=0;k<i.length;k++){var L=I,m=new zo(g,n);m.header=n.slice(L,L+=Ae.Constants.CENHDR),m.entryName=n.slice(L,L+=m.header.fileNameLength),m.header.extraLength&&(m.extra=n.slice(L,L+=m.header.extraLength)),m.header.commentLength&&(m.comment=n.slice(L,L+m.header.commentLength)),I+=m.header.centralHeaderSize,i[k]=m,o[m.entryName]=m}l.clear(),A()}function b(I){var k=n.length-Ae.Constants.ENDHDR,L=Math.max(0,k-65535),m=L,C=n.length,R=-1,F=0;for(typeof g.trailingSpace=="boolean"&&g.trailingSpace&&(L=0),k;k>=m;k--)if(n[k]===80){if(n.readUInt32LE(k)===Ae.Constants.ENDSIG){R=k,F=k,C=k+Ae.Constants.ENDHDR,m=k-Ae.Constants.END64HDR;continue}if(n.readUInt32LE(k)===Ae.Constants.END64SIG){m=L;continue}if(n.readUInt32LE(k)===Ae.Constants.ZIP64SIG){R=k,C=k+Ae.readBigUInt64LE(n,k+Ae.Constants.ZIP64SIZE)+Ae.Constants.ZIP64LEAD;break}}if(R==-1)throw Ae.Errors.INVALID_FORMAT();c.loadFromBinary(n.slice(R,C)),c.commentLength&&(a=n.slice(F+Ae.Constants.ENDHDR)),I&&_()}function S(){i.length>1&&!E&&i.sort((I,k)=>I.entryName.toLowerCase().localeCompare(k.entryName.toLowerCase()))}return{get entries(){return u||_(),i.filter(I=>!l.has(I))},get comment(){return w.decode(a)},set comment(I){a=Ae.toBuffer(I,w.encode),c.commentLength=a.length},getEntryCount:function(){return u?i.length:c.diskEntries},forEach:function(I){this.entries.forEach(I)},getEntry:function(I){return u||_(),o[I]||null},setEntry:function(I){u||_(),i.push(I),o[I.entryName]=I,c.totalEntries=i.length},deleteFile:function(I,k=!0){u||_();let L=o[I];this.getEntryChildren(L,k).map(C=>C.entryName).forEach(this.deleteEntry)},deleteEntry:function(I){u||_();let k=o[I],L=i.indexOf(k);L>=0&&(i.splice(L,1),delete o[I],c.totalEntries=i.length)},getEntryChildren:function(I,k=!0){if(u||_(),typeof I=="object")if(I.isDirectory&&k){let L=[],m=I.entryName;for(let C of i)C.entryName.startsWith(m)&&L.push(C);return L}else return[I];return[]},getChildCount:function(I){if(I&&I.isDirectory){let k=this.getEntryChildren(I);return k.includes(I)?k.length-1:k.length}return 0},compressToBuffer:function(){u||_(),S();let I=[],k=[],L=0,m=0;c.size=0,c.offset=0;let C=0;for(let z of this.entries){let $=z.getCompressedData();z.header.offset=m;let J=z.packLocalHeader(),N=J.length+$.length;m+=N,I.push(J),I.push($);let B=z.packCentralHeader();k.push(B),c.size+=B.length,L+=N+B.length,C++}L+=c.mainHeaderSize,c.offset=m,c.totalEntries=C,m=0;let R=Buffer.alloc(L);for(let z of I)z.copy(R,m),m+=z.length;for(let z of k)z.copy(R,m),m+=z.length;let F=c.toBinary();return a&&a.copy(F,Ae.Constants.ENDHDR),F.copy(R,m),n=R,u=!1,R},toAsyncBuffer:function(I,k,L,m){try{u||_(),S();let C=[],R=[],F=0,z=0,$=0;c.size=0,c.offset=0;let J=function(N){if(N.length>0){let B=N.shift(),j=B.entryName+B.extra.toString();L&&L(j),B.getCompressedDataAsync(function(te){m&&m(j),B.header.offset=z;let ie=B.packLocalHeader(),me=ie.length+te.length;z+=me,C.push(ie),C.push(te);let Re=B.packCentralHeader();R.push(Re),c.size+=Re.length,F+=me+Re.length,$++,J(N)})}else{F+=c.mainHeaderSize,c.offset=z,c.totalEntries=$,z=0;let B=Buffer.alloc(F);C.forEach(function(te){te.copy(B,z),z+=te.length}),R.forEach(function(te){te.copy(B,z),z+=te.length});let j=c.toBinary();a&&a.copy(j,Ae.Constants.ENDHDR),j.copy(B,z),n=B,u=!1,I(B)}};J(Array.from(this.entries))}catch(C){k(C)}}}}});var Go=Q((Bm,Ho)=>{var ue=Ht(),de=re("path"),$u=bi(),Ju=Uo(),St=(...n)=>ue.findLast(n,e=>typeof e=="boolean"),qo=(...n)=>ue.findLast(n,e=>typeof e=="string"),Vu=(...n)=>ue.findLast(n,e=>typeof e=="function"),Zu={noSort:!1,readEntries:!1,method:ue.Constants.NONE,fs:null};Ho.exports=function(n,e){let i=null,o=Object.assign(Object.create(null),Zu);n&&typeof n=="object"&&(n instanceof Uint8Array||(Object.assign(o,n),n=o.input?o.input:void 0,o.input&&delete o.input),Buffer.isBuffer(n)&&(i=n,o.method=ue.Constants.BUFFER,n=void 0)),Object.assign(o,e);let a=new ue(o);if((typeof o.decoder!="object"||typeof o.decoder.encode!="function"||typeof o.decoder.decode!="function")&&(o.decoder=ue.decoder),n&&typeof n=="string")if(a.fs.existsSync(n))o.method=ue.Constants.FILE,o.filename=n,i=a.fs.readFileSync(n);else throw ue.Errors.INVALID_FILENAME();let c=new Ju(i,o),{canonical:u,sanitize:x,zipnamefix:l}=ue;function g(_){if(_&&c){var b;if(typeof _=="string"&&(b=c.getEntry(de.posix.normalize(_))),typeof _=="object"&&typeof _.entryName<"u"&&typeof _.header<"u"&&(b=c.getEntry(_.entryName)),b)return b}return null}function E(_){let{join:b,normalize:S,sep:I}=de.posix;return b(de.isAbsolute(_)?"/":".",S(I+_.split("\\").join(I)+I))}function w(_){return _ instanceof RegExp?(function(b){return function(S){return b.test(S)}})(_):typeof _!="function"?()=>!0:_}let A=(_,b)=>{let S=b.slice(-1);return S=S===a.sep?a.sep:"",de.relative(_,b)+S};return{readFile:function(_,b){var S=g(_);return S&&S.getData(b)||null},childCount:function(_){let b=g(_);if(b)return c.getChildCount(b)},readFileAsync:function(_,b){var S=g(_);S?S.getDataAsync(b):b(null,"getEntry failed for:"+_)},readAsText:function(_,b){var S=g(_);if(S){var I=S.getData();if(I&&I.length)return I.toString(b||"utf8")}return""},readAsTextAsync:function(_,b,S){var I=g(_);I?I.getDataAsync(function(k,L){if(L){b(k,L);return}k&&k.length?b(k.toString(S||"utf8")):b("")}):b("")},deleteFile:function(_,b=!0){var S=g(_);S&&c.deleteFile(S.entryName,b)},deleteEntry:function(_){var b=g(_);b&&c.deleteEntry(b.entryName)},addZipComment:function(_){c.comment=_},getZipComment:function(){return c.comment||""},addZipEntryComment:function(_,b){var S=g(_);S&&(S.comment=b)},getZipEntryComment:function(_){var b=g(_);return b&&b.comment||""},updateFile:function(_,b){var S=g(_);S&&S.setData(b)},addLocalFile:function(_,b,S,I){if(a.fs.existsSync(_)){b=b?E(b):"";let k=de.win32.basename(de.win32.normalize(_));b+=S||k;let L=a.fs.statSync(_),m=L.isFile()?a.fs.readFileSync(_):Buffer.alloc(0);L.isDirectory()&&(b+=a.sep),this.addFile(b,m,I,L)}else throw ue.Errors.FILE_NOT_FOUND(_)},addLocalFileAsync:function(_,b){_=typeof _=="object"?_:{localPath:_};let S=de.resolve(_.localPath),{comment:I}=_,{zipPath:k,zipName:L}=_,m=this;a.fs.stat(S,function(C,R){if(C)return b(C,!1);k=k?E(k):"";let F=de.win32.basename(de.win32.normalize(S));if(k+=L||F,R.isFile())a.fs.readFile(S,function(z,$){return z?b(z,!1):(m.addFile(k,$,I,R),setImmediate(b,void 0,!0))});else if(R.isDirectory())return k+=a.sep,m.addFile(k,Buffer.alloc(0),I,R),setImmediate(b,void 0,!0)})},addLocalFolder:function(_,b,S){if(S=w(S),b=b?E(b):"",_=de.normalize(_),a.fs.existsSync(_)){let I=a.findFiles(_),k=this;if(I.length)for(let L of I){let m=de.join(b,A(_,L));S(m)&&k.addLocalFile(L,de.dirname(m))}}else throw ue.Errors.FILE_NOT_FOUND(_)},addLocalFolderAsync:function(_,b,S,I){I=w(I),S=S?E(S):"",_=de.normalize(_);var k=this;a.fs.open(_,"r",function(L){if(L&&L.code==="ENOENT")b(void 0,ue.Errors.FILE_NOT_FOUND(_));else if(L)b(void 0,L);else{var m=a.findFiles(_),C=-1,R=function(){if(C+=1,C<m.length){var F=m[C],z=A(_,F).split("\\").join("/");z=z.normalize("NFD").replace(/[\u0300-\u036f]/g,"").replace(/[^\x20-\x7E]/g,""),I(z)?a.fs.stat(F,function($,J){$&&b(void 0,$),J.isFile()?a.fs.readFile(F,function(N,B){N?b(void 0,N):(k.addFile(S+z,B,"",J),R())}):(k.addFile(S+z+"/",Buffer.alloc(0),"",J),R())}):process.nextTick(()=>{R()})}else b(!0,void 0)};R()}})},addLocalFolderAsync2:function(_,b){let S=this;_=typeof _=="object"?_:{localPath:_},localPath=de.resolve(E(_.localPath));let{zipPath:I,filter:k,namefix:L}=_;k instanceof RegExp?k=(function(R){return function(F){return R.test(F)}})(k):typeof k!="function"&&(k=function(){return!0}),I=I?E(I):"",L=="latin1"&&(L=R=>R.normalize("NFD").replace(/[\u0300-\u036f]/g,"").replace(/[^\x20-\x7E]/g,"")),typeof L!="function"&&(L=R=>R);let m=R=>de.join(I,L(A(localPath,R))),C=R=>de.win32.basename(de.win32.normalize(L(R)));a.fs.open(localPath,"r",function(R){R&&R.code==="ENOENT"?b(void 0,ue.Errors.FILE_NOT_FOUND(localPath)):R?b(void 0,R):a.findFilesAsync(localPath,function(F,z){if(F)return b(F);z=z.filter($=>k(m($))),z.length||b(void 0,!1),setImmediate(z.reverse().reduce(function($,J){return function(N,B){if(N||B===!1)return setImmediate($,N,!1);S.addLocalFileAsync({localPath:J,zipPath:de.dirname(m(J)),zipName:C(J)},$)}},b))})})},addLocalFolderPromise:function(_,b){return new Promise((S,I)=>{this.addLocalFolderAsync2(Object.assign({localPath:_},b),(k,L)=>{k&&I(k),L&&S(this)})})},addFile:function(_,b,S,I){_=l(_);let k=g(_),L=k!=null;L||(k=new $u(o),k.entryName=_),k.comment=S||"";let m=typeof I=="object"&&I instanceof a.fs.Stats;m&&(k.header.time=I.mtime);var C=k.isDirectory?16:0;let R=k.isDirectory?16384:32768;return m?R|=4095&I.mode:typeof I=="number"?R|=4095&I:R|=k.isDirectory?493:420,C=(C|R<<16)>>>0,k.attr=C,k.setData(b),L||c.setEntry(k),k},getEntries:function(_){return c.password=_,c?c.entries:[]},getEntry:function(_){return g(_)},getEntryCount:function(){return c.getEntryCount()},forEach:function(_){return c.forEach(_)},extractEntryTo:function(_,b,S,I,k,L){I=St(!1,I),k=St(!1,k),S=St(!0,S),L=qo(k,L);var m=g(_);if(!m)throw ue.Errors.NO_ENTRY();var C=u(m.entryName),R=x(b,L&&!m.isDirectory?L:S?C:de.basename(C));if(m.isDirectory){var F=c.getEntryChildren(m);return F.forEach(function(J){if(J.isDirectory)return;var N=J.getData();if(!N)throw ue.Errors.CANT_EXTRACT_FILE();var B=u(J.entryName),j=x(b,S?B:de.basename(B));let te=k?J.header.fileAttr:void 0;a.writeFileTo(j,N,I,te)}),!0}var z=m.getData(c.password);if(!z)throw ue.Errors.CANT_EXTRACT_FILE();if(a.fs.existsSync(R)&&!I)throw ue.Errors.CANT_OVERRIDE();let $=k?_.header.fileAttr:void 0;return a.writeFileTo(R,z,I,$),!0},test:function(_){if(!c)return!1;for(var b in c.entries)try{if(b.isDirectory)continue;var S=c.entries[b].getData(_);if(!S)return!1}catch{return!1}return!0},extractAllTo:function(_,b,S,I){if(S=St(!1,S),I=qo(S,I),b=St(!1,b),!c)throw ue.Errors.NO_ZIP();c.entries.forEach(function(k){var L=x(_,u(k.entryName));if(k.isDirectory){a.makeDir(L);return}var m=k.getData(I);if(!m)throw ue.Errors.CANT_EXTRACT_FILE();let C=S?k.header.fileAttr:void 0;a.writeFileTo(L,m,b,C);try{a.fs.utimesSync(L,k.header.time,k.header.time)}catch{throw ue.Errors.CANT_EXTRACT_FILE()}})},extractAllToAsync:function(_,b,S,I){if(I=Vu(b,S,I),S=St(!1,S),b=St(!1,b),!I)return new Promise((R,F)=>{this.extractAllToAsync(_,b,S,function(z){z?F(z):R(this)})});if(!c){I(ue.Errors.NO_ZIP());return}_=de.resolve(_);let k=R=>x(_,de.normalize(u(R.entryName))),L=(R,F)=>new Error(R+': "'+F+'"'),m=[],C=[];c.entries.forEach(R=>{R.isDirectory?m.push(R):C.push(R)});for(let R of m){let F=k(R),z=S?R.header.fileAttr:void 0;try{a.makeDir(F),z&&a.fs.chmodSync(F,z),a.fs.utimesSync(F,R.header.time,R.header.time)}catch{I(L("Unable to create folder",F))}}C.reverse().reduce(function(R,F){return function(z){if(z)R(z);else{let $=de.normalize(u(F.entryName)),J=x(_,$);F.getDataAsync(function(N,B){if(B)R(B);else if(!N)R(ue.Errors.CANT_EXTRACT_FILE());else{let j=S?F.header.fileAttr:void 0;a.writeFileToAsync(J,N,b,j,function(te){te||R(L("Unable to write file",J)),a.fs.utimes(J,F.header.time,F.header.time,function(ie){ie?R(L("Unable to set times",J)):R()})})}})}}},I)()},writeZip:function(_,b){if(arguments.length===1&&typeof _=="function"&&(b=_,_=""),!_&&o.filename&&(_=o.filename),!!_){var S=c.compressToBuffer();if(S){var I=a.writeFileTo(_,S,!0);typeof b=="function"&&b(I?null:new Error("failed"),"")}}},writeZipPromise:function(_,b){let{overwrite:S,perm:I}=Object.assign({overwrite:!0},b);return new Promise((k,L)=>{!_&&o.filename&&(_=o.filename),_||L("ADM-ZIP: ZIP File Name Missing"),this.toBufferPromise().then(m=>{let C=R=>R?k(R):L("ADM-ZIP: Wasn't able to write zip file");a.writeFileToAsync(_,m,S,I,C)},L)})},toBufferPromise:function(){return new Promise((_,b)=>{c.toAsyncBuffer(_,b)})},toBuffer:function(_,b,S,I){return typeof _=="function"?(c.toAsyncBuffer(_,b,S,I),null):c.compressToBuffer()}}}});function qa(n){let e=n?.sessionIdleTimeoutMs;return typeof e!="number"||!Number.isFinite(e)||e<=0?Ox:e}function wt(n){return Ft(n??Y().configFile)}function Ze(n,e){return Gn(e??Y().configFile,n)}var Ox,Yt=Be(()=>{"use strict";jn();ye();Ox=10*6e4});var gc=Q(fe=>{"use strict";var O=K;(function(n,e){let i=K,o=n();for(;;)try{if(-parseInt(i(966))/1+-parseInt(i(979))/2*(-parseInt(i(294))/3)+parseInt(i(1519))/4*(-parseInt(i(862))/5)+-parseInt(i(522))/6+-parseInt(i(1602))/7+parseInt(i(1461))/8*(parseInt(i(960))/9)+parseInt(i(1123))/10*(parseInt(i(1704))/11)===e)break;o.push(o.shift())}catch{o.push(o.shift())}})(vr,949487);var Ll=Object[O(704)+O(708)],Ol=Object["getOwnPr"+O(1682)+"mes"],dc=(n,e)=>function(){return n&&(e=(0,n[Ol(n)[0]])(n=0)),e},Ml=(n,e)=>{let i={GAmPS:function(a,c,u,x){return a(c,u,x)}};for(var o in e)i.GAmPS(Ll,n,o,{get:e[o],enumerable:!0})};function Bl(){return ic||(ic=[IDBDatabase,IDBObjectStore,IDBIndex,IDBCursor,IDBTransaction])}function zl(){let n=O;return sc||(sc=[IDBCursor[n(533)+"e"].advance,IDBCursor[n(533)+"e"][n(1506)],IDBCursor[n(533)+"e"][n(1506)+"PrimaryKey"]])}function Fl(n){let e=O,i={oYrQF:function(a,c){return a(c)},UTsLt:function(a,c){return a(c)},noDjD:function(a){return a()},VVJWs:e(526),SViRs:e(1223)+e(214),DOFfk:function(a,c){return a===c},XYLqp:e(1443),MRmTN:e(1426),liwwp:function(a,c){return a<<c},YdwCu:function(a,c){return a&c},FWrpw:function(a,c){return a<c},UAEci:e(856),gYUng:function(a,c){return a instanceof c}},o=new Promise((a,c)=>{let u=e,x={ksxaH:i.VVJWs,eGpWC:i[u(265)],ornVC:function(w,A){return i[u(1714)](w,A)},DhEXB:i[u(829)],GTlqt:i[u(1368)],kzoBO:function(w,A){return i[u(638)](w,A)},yQrUQ:function(w,A){return i[u(1159)](w,A)},NVqPe:function(w,A){return i[u(1008)](w,A)},xXHvU:function(w,A){return i[u(613)](w,A)},iEJfF:function(w,A){return i[u(1714)](w,A)},JUZkN:u(667),ntMJe:function(w,A){return w(A)}},l=()=>{let w=u;x[w(604)](x[w(252)],"AZnXv")?(_0x210295&&_0x171580[w(524)+w(203)](x[w(1503)],()=>_0x3fa7e5()),_0x37aa97&&_0x49de1f["addEvent"+w(203)](x[w(651)],()=>_0xb40774())):(n["removeEv"+w(696)+"ner"](x[w(298)],g),n["removeEv"+w(696)+w(1562)](w(856),E))},g=()=>{i[u(613)](a,i.UTsLt(Xe,n.result)),i.noDjD(l)},E=()=>{let w=u;x[w(241)](w(841),x.JUZkN)?(_0x163c0b=x.kzoBO(x[w(1319)](31,_0x481236),6)|x.yQrUQ(63,_0x372aae),x[w(1445)](_0x3cac38,128)?_0x2ecb8f+=_0x1f1b0a:(_0x5405d8+=x[w(1497)](_0x47fae9,_0xaa4962),_0x47734a++)):(x[w(1340)](c,n[w(856)]),l())};n[u(524)+u(203)](i[u(1368)],g),n[u(524)+"Listener"](i[u(481)],E)});return o[e(1099)](a=>{let c=e;i[c(1629)](a,IDBCursor)&&ji[c(695)](a,n)}).catch(()=>{}),Ir[e(695)](o,n),o}function vr(){let n=["EvrKAwe","vgzKEwm","BMj5ENG","Ag1cDfu","x3jLywr5q2W","BLHLEvG","D3jPDgvvAw4","tuzqAKm","zxjFywnRx20","CNrbDK0","r0Lct1y","tffZqvm","wujbCeC","A01vwxm","zhPuz0e","uMDlqNu","CxDAwLa","DhjPBq","tvjTve4","AwzkDNu","CMvZzxruCMK","z1rPBwvVDxq","x2TLEvbHDgG","wwvdA0G","svbfBum","zNzIt0m","s3vSvLu","A2v5","zfjsrKu","C3vIC3rYAw4","yMfSrxzLBNq","uNfbuMe","B3vmAKy","BMDuAw1LCG","DgvmB2Djre4","ywnRDxbfBMq","wLfNueS","tLvxse8","BwvY","ELncreW","AgnVBhu","CM5dAw0","EhfzCwC","Ae5Iq0q","uvPdshi","Ae56qMy","z2ruvvO","yM9KEq","DgHHBIbSB2m","ugTqrue","Chv0","C3Huyvu","DgLLCKPtt04","zv90Aw1LB3u","Ehz6CuG","r2X4rNy","wgLmtMq","y3jLyxrLtwu","C3nHz2vfDMu","EMXhyuS","D0z5v1C","AxnrB1nnzxm","uMvJB25Uzwm","BgLTAxq","x2LZv29YA2u","v2fer3i","EsbJBg9Zzwq","zxjYtxnN","ihn1y2nLC3m","v1rlvfa","y29UBMvJDfm","x1fVu01HBMe","u0f3Age","CuzIqNm","zw5XDwv1zq","AgLNAa","C3vJy2vZCW","s2XnDw8","Efrurw52","x2rPC3bHDgm","CfHwsui","ANnbu2O","Cu1Asve","D2vI","ywLpELO","BNDqB1i","DuDAtK8","AwrI","y2XLyxjtDg8","ihrYEsbYzwm","y2f0y2G","CfHLtxC","rxviwuW","ywfPtKm","C3rMCfK","tLzXugu","zLnqvgG","wu91zMW","rKLmrv9ot1q","C3bSAxq","AKr4vvm","CMTLCKDSB2i","Dg9oDw1Izxi","B2LUDfjLywm","x2LZqNjVD3m","suvire4","sNfKDM0","C2vUza","ELPyy0i","werbt3C","t2vOwum","mtuYt0TRwenI","CKHzA20","x2HHBMrSzu8","q0jdt0O","x2LZsw5PDa","Aw1LCYbPBIa","uhffs0G","zKLYvKS","AwnXrKm","wePLy2O","CgLUz0LUDgu","BM9Uzv9UB24","B2nRzxrgywK","tvv2Beq","Eg9PreK","v2XqAK8","B3jpBMXPBMu","zgvJB2rLzey","AuL2vNK","y2PYBem","yw1LoIa","x29UugfNzu4","C2XPy2u","B2Pfrge","A3vYsui","wMDLsgy","yNvMzMvY","zgLZCgf0y2G","u3jlwgy","ELjdree","vvb0CLC","C3LRAe8","ywDL","rxzSv3u","wvr2r20","sxbrquK","EfHiDLu","CgfYC2u","CgfNzwHPzgu","quz6y1q","B0vdC1e","D2D5t1u","A3n4yuG","t0LmEwm","DgfYz2v0","y29UDgLUDwu","AvHpANO","tLjnEM0","DLzKCLO","id4G","q0vLrxO","AgvHzgvYCW","ruvowuy","ALHhs3O","zfbAsK8","ywrK","zw5JB2rPBMC","qNjJsem","nZC2nJi4yLDcD0Pg","BvHsEhK","C3jqsvm","wxDnA3G","q0fmAhO","B2zqv0S","Ce9PveC","s3bvrwK","vw5Oyw5KBgu","uMH5A08","x3bPBMDqB24","Aw47y2HHCNm","yxbWBgLJyxq","rxHgvuu","ihzHBgLKihm","AffLwgC","AwXLtMfTzq","rg1huLG","CM92AwrLihC","tMjwse8","CMvHC29U","ruTUtwe","B29JCee","r0HYvvm","BwfW","s0LIrg0","EwnJuve","svL5qve","DurVrxe","Aw9Ul2PZB24","rLbMrvi","zxjFDhrS","BvLrsKG","wNPZu3i","uxnhrfa","EefPve8","txzdvvC","tgrUyMu","B2TSB0m","ywzLzvC","sg11AvK","BwHMBLq","ufjjENe","BMvY","B25nzxnZywC","y3vYCMvUDeu","yxv0B21HDgK","v0D6u00","DcbVzIbYyw4","x2rPC2nVBM4","Dgnbquy","ywXS","qu9RsLy","zwn0","m3WWFdr8mNW","qNrZzvu","CwDpC2e","z2v0qwXS","r1f1zKe","BNrfBMrWB2K","Dgv4Dc9WBge","t1bftL9fuLi","yKXnuxq","AM5ss1u","veT1t0i","BeHHBMrSzxi","D2fZq2XLyw4","CKv1ugS","C2v0sxrLBq","s1PLswu","Ahbkufi","AwTvANK","C2P0EM0","DMvYC2LVBG","r1njCNm","DeXIrwG","CeLoEMq","CvfPANq","shbOt0q","qKjhr0G","Ae1YyvO","DeLUDgvYy2u","EfD4CgK","mte3mJe4otLmqMTwuhK","uNzrs1u","EM1wA0O","C2v0q3vYC28","q3H4rwi","D1nSB0i","ChjVDg9JB2W","Dgv4Dc9Qyxy","A1zVBNy","y2HnyxHdB3u","wxzWs1O","DgLTzw91DcW","BNrLCG","tNDOtMG","BKnkrue","z3v2Dee","zw5HyMXLqxu","rvzrEg0","x2zVCM1HDeu","yw5Hz2vY","yvvTBfm","yxbWBhK","sKzcuvi","DLnZyxi","s3nTCLm","x29WDgLVBNm","yxnL","z1LvBMC","y3ftr3i","yMf0q0e","vLvct24","zgvSzxrL","C21ssui","igfYCMf5yNu","y2vZC0HHBMq","z2v0s2v5","EfPgDgW","s0HXrfq","DhvvA00","yMLUza","C0TyCMe","Bg9ZCuK","EfvZzuvUDG","x21PBMLoyxy","DNbby3C","AefJA01LC3m","uxvLDwu","vxbKyxrLq28","wKLisKC","zgnss0S","AxjLza","q09Sruy","CgPhyLO","EuvnDg4","s0H2y3i","ihbYB3rVy28","DMP0Cfm","y1H4qxq","vgLTzw91Da","sNv4v1K","Dg9cExrLC0i","s1fczxO","yNDNB2m","zgv2AwnLx2K","B25pCgvU","Dg9tDhjPBMC","D1rZEKq","A3HdD1m","CNnVCKzPBgu","swjrAMi","yxKSig5LDhC","zxH0zw5ZAw8","zvvYBa","qNDHqLm","t21Ju0S","y29UBMvJDa","zM9Yy2u","vLHgA1K","B1vsrNu","D3jPDgu","B3bLCNr5tMe","CMvWBgfJzui","Cgu6ia","CMfrr00","B3vUDa","AM9PBG","zhHyqu0","D3LTBhq","B25LCNjVCG","Eer3suK","tuLgEMi","rM9Xzg0","ywnRx2LK","y29TCgXLDgu","svHXve8","CMHuwuq","q1f3AKu","tw1AqMO","CM9YrxzLBNq","D1bZz0q","AevYCM9Yrxy","s0nTveS","nteXnxfNzMLIrW","Cg9W","uLn2u3C","tez6vgK","weXoDMm","y2ngzeG","swX0uLO","mNWXFdb8m3W","B1ryB2W","CNnVCL9Uyw0","re9gzMS","Cfnkv3K","zNjVBNrPzxi","zLHIr1O","wujADuK","x2nYzwf0zvm","Cg9PBNrdB24","wwH1Bge","y3vYC29YlNm","BNruCMLLC0m","y3ruAw1LB3u","DhDVCMTdAge","Dgn6z28","ywX3yxLZ","BwvKAwf0zwW","rw9VwNq","uurlAgq","v1jYENK","qK5czha","ywnOzwq","rfzAufq","BMvLzf9Hy2S","yNL0zu9MzNm","l3DZl3yY","rerlEeG","tgLZDgvUzxi","s0vdreC","zhLqqMW","Aw5L","zvnbv1O","twL3we4","zsbHihn0CMK","Cw9Z","qw1VDw50","C25gt1i","DMTiwfK","AgfUz2u","ueLIrhG","t2r5wxC","DePyCgG","DMfSDwvZ","yNL0zxm","Axnby2TdBgu","A1n0yxr1C0m","ywrKq291BNq","zMLUza","zgf0yq","mhW0Fdj8m3W","BML0AwfSAxO","CgLUz0XVC3m","BMCGB3iGyw4","y0DMEvK","Aw5KzxG","A0DAuMO","tMfTzq","zw5KCg9PBNq","BgnTB0W","BNzXr1y","z1D3wxq","ChrVCG","DwvMsK8","CIb0DhDjra","qNnXvMm","AuvkzKy","A2TNr3G","zgLZywjSzue","sMrvBvK","EuPZsgC","v0n5Ew8","z1PJCxq","B1LYr3m","x2fKzfDZtgK","ywnOzwqSihC","uezYqwC","rgHfwei","svfJuLi","yxv0BW","BNPJvKq","ywjVCNq","DMvY","rLDt","D1z1tgi","wLLPteS","ywLIyMi","zfrwAKK","DuvyEKi","zxj2AwnL","u1zPuNm","B2zMC2v0","B2zM","zw5JB2rLrNi","CMvHzfvjBNq","rNjVBNrPzxi","yxnJCMLWDa","uefJDu4","uKTtvNG","revlwMu","vKjHy20","zMLN","CMvKDwnL","AMvJDfn0B3i","Cg1Wqwm","BxfIBey","x3fVC0rc","ufjmv3G","x2nVBM5Ly3q","rxzLBNq","vLjjr20","D1PhAhq","zNjHBwvuExa","CgXLyxnLiha","AKn2q1K","q3fLv00","Ee5UrfG","sur0ELK","A2v0ignVBNm","nJK3oeTsEeTfCq","zMzmAw5L","x2rLC3rYB3K","yMLUyxj5vhK","r1rSCxq","CMLYr1C","s1byBfG","C3rLBMvYCW","zMzMzG","ywXty29Wzq","wMzru3G","BNrbBMrvCgq","weL5zLa","DLrlBMO","DMLJzuLeig8","Dhr3Awq","u3rYyxrLz3K","wND2EM4","zNjVBuj5Dgu","sw5KA2S","v1vvz1m","BMrWB2LUDca","x3jLBw92zvC","BvjuEMO","BgH4uLG","AhPkvwq","vgDxwfu","z2vjBMzVu3K","vhHvwe4","q1DyAxy","ANLtEuy","vNjvCeq","u0rPveu","BwLZzq","z2v0sxrLBq","A2rfwwO","tg9NsurozxC","C2HPzNq","x29Ut3bLBG","B2zMBgLUzq","A1LdExG","BgLUzw5V","wMvsse0","ywzL","r1bQBvi","DhjPzxm","CMvJzwL2zwq","Du52Bfe","EMXNAfK","t0vWtxO","Ce1Azge","twLZC2LUzYa","yKTPAMm","C3rHCNq","BMnVzgLUzW","y2XVC2veqG","tKDFrvjst1i","DNDMq0K","Dgv4DfbHEwW","ywXSq3vYC28","C3rYAw5NAwy","tg1vufi","uhDOA0W","qNPrqLe","tNLtB3u","y2XLyxi","y1PkAKO","wfHlre0","ENnnBuy","Bw1jCvq","BMrWB2LUDfq","sNHss1K","rurXAgW","B3bLBG","AxnmB25N","BxPeAhq","yw5Nzq","nhWW","lcbOB3n0BMe","qwjVCNrfCNi","zePrsva","BMP1EKW","BLPptMi","wgH4DM4","zM9YrwfJAa","A3vstwO","sev1zKm","q2DKrMG","ugDqqMq","ChvZAa","CgLUz1rPBwu","DxrMofDYAxq","ueXTq1O","ufLzBwq","u3jLruG","z2v0q3vYCMu","vLLpDuG","DwrLugO","u1zIBKq","tfDUtM8","igXHCMDLCIa","x3nVy2TLDa","x2LZtwLUAvC","AwnSv08","y3jLyxrLq2W","x2n1CNnVCK4","wgjczNi","yxrLq291BNq","AenSB3nLrxy","AKLvBNO","Aw5KzxGGB3u","yxnZAwDU","y1n5swW","DfzrAxO","r3D3vg4","qKzRBKS","DMfSDwu","vK9rtvi","B29isKS","ChnwCvC","sNbgqwe","thLUqNq","u2fPEum","BMCGDxjSoIa","y29UBMvJDeu","x3bPBMDmB3m","CvH6zgi","BgLUzq","CLjjyvC","vMT2zuO","x29Uq2XVC2u","quj4Bum","se1lr3i","uhjWuva","C29Tzq","EKTeu1e","Avr5AgG","yw1Lu3bHy2u","vgfN","rKjyvNm","DxPHBuK","zgvS","thfptNe","EMH3u2y","yMfSu2nVCgu","zNvTyLm","rgn0zu4","zMTVA00","x2rItMfTzq","yMjIv2i","ywDLu2HVDW","zMzLCG","B0nyA3q","yxKSihrYEsa","rLLqA1q","y2jhCgO","vhPSA0K","vMLZBKC","Cg9PBNrbBMq","D09OreC","B2nRzxq","x2vUzhbVAw4","sw50CeK","q29UzMLN","z2flDfi","Bg93","zw5HyMXLuw8","sKnsAeS","Ag1ABLy","Ec1TC2CTy3u","zgvIDwC","sLH5qKu","CMnorvC","ChvWwKy","Aw5JBhvKzxm","Chrjs1C","BerqChK","q0D6Dg0","AeDiELe","EuPWANe","BK9nDxC","suvtx0vsuK8","rfzkEKi","Ae9Wzw5fDMu","z2Tzywi","t0LTELG","AxnrB1nby2S","vuffy2K","vvjxB3q","se9ptwy","DLDVBuS","ywnRtxnNswq","x0vysvnu","B3bPqvC","s3bkB2S","u3PRrve","x2jPBMfYEvq","tw95EKO","uwPTCMG","yxrHlcbKyxq","EvD5u2u","x3bHDgHlzxK","qxv1EhG","vuPhywy","wNDTCeO","uNrkDLO","zcWGDw5RBM8","B25Uzwn0Aw4","Eg12suO","BMrLEa","ig1LC3nHz2u","zNPoy0u","vw5PBxbSzw0","u2HHCMvKv28","wLvUr2W","C2niDxq","BMfTzq","zNjVBunOyxi","DhjPzxmGCMu","vgPkBve","zxH0ugf5Bg8","ANnpvxu","Dgv6qKW","AgfZ","AgvKtwf4uMu","s2nZrgi","sNPqsMq","B0rJBKy","mJu2mtmWnhLksM5nua","C01dEMy","ywrKrxzLBNq","rg9prKe","y2XVC2u","r3vYwKe","v2vPEgLUsLm","C2vYDMLJzq","B3v0sw50zxi","CNrTt1q","x3DZ","ChjVDg90Exa","BM5Ly3q","x3bPBMC","wLvktfe","Evvbz0m","tLzyC2i","jMPZy2fSBgi","DwDmzxq","wurPu3e","EKDMtLy","AwXK","zNLMEwW","zNjVBujPDhm","mdaWma","Dg9cExrLCW","z2nvsMS","A1bPve4","y3jLyxrLt2i","BfHcELm","Dxrjza","EvjLy29UBMu","vwLiqxC","o2nOyxjZzxq","yMLUyxj5","ug9orNy","ELfYwgq","tM5iCwm","ufvQEfu","uMvHzcbWyxm","rezHB3u","zMDHwvK","zvPmDfG","Bg9IywXty28","uwzMu0K","wMvMvKO","uLnAwfy","ueH5DgC","y29UDgv4Da","ysbTDxn0igi","rwvvvfK","Bwf4twvZC2e","ruDOCgu","y1DvzNa","EejbC2O","vMrjEha","Dg9cExrLC0W","vwTsue8","x3DZsw5ZDge","r3jrEMy","BLjqCxO","zg9Uzq","rfjeDLO","BNvTyMvY","z2v0q3vYC28","EuPetwy","sMnTDuK","ze9Wz2i","DfLOzw8","CePXvey","z2v0","rw50wxe","uK5TqvK","rhDVz3m","sxjhrxG","CLzHBhvLCW","Ef9MCM9UDgK","CMvTB3zLq2G","ExbL","B1fIBw0","y29Kzq","mxW1Fdn8nhW","B3jUvKm","rLjptLrjrvi","rfD1wwm","DxDzAgG","rNjdEvi","DK1vqvK","BxnNsuq","DefAywm","B25ozxr3B3i","B1LYuuy","Bwu6ia","DxbKyxrLq3u","zxr5A0W","ywLPzKe","y2HLy2Tszwe","CuvKDvy","ywXPzcb1CMW","uKv5wKu","DhLWzq","CxjIs3C","AwDyyNi","zNPby1K","x2n1CNnVCK0","u0LuCKW","CMvXDwLYzwq","u0ryDKS","tLLishu","CKjeww0","y3jLyxrLrxi","pxv0zI04","AMDhzNG","q1HgAfq","zKTXEee","DxrfAMK","BgL3D3a","rhjvrMG","CgfhrMW","A1fVruy","B3jLtMfTzxm","C0Lby28","rMPSrMO","Aw5PDcbrB1m","uhPPr0y","CvzxyxC","B3jRig9MzMW","t21UD3e","tvHhz3a","zuDWv0m","q0zszMG","zxHWB3j0CW","rKPIsLO","uNnhu0G","uvDvBfy","B3bLBIa","yuXYDwm","tfj5u0C","u3D4C1O","yNLL","B25tDg9Wsw0","qNrXD0i","sKn3DgG","B25SAw5L","rLzhyxm","Cvz6ENC","uhDmvvO","uvHsvNG","sNjOBwm","BMDkuvK","DhfWCeK","DMvUDa","wNHUyve","DvvAzNK","DfbkuxK","y2fSBa","tg9JAW","C2jPDvK","rvjst1i","qvHArfq","qKvvD2K","Cgf5Bg9Hza","Bhm6ia","AwDHDg9Yt24","y0DHreu","B2znAxy","tvrZCui","ugn0txm","rwjmAue","BezSDxnO","txjsEMe","uurgz3e","CMvHzhDYAxq","C2v0","zw50tgLZDgu","B1bACLO","v2vIu29JA2u","BMDLza","EMLPALm","Dxrzwxi","CMXZBxm","rhHjEhu","zgvMAw5Luhi","C2fNzq","BwfUDwfSihi","uxHfsgW","B3bLCNr5","wwv4wMC","z2u6ia","seDOELK","igzPzwXKoIa","EvjVAfa","EvbNshK","zw50","zLPiwee","zMLSzw5HBwu","rujtsMi","y3vYCMvUDeK","B3nLza","CYbPBNn0yw4","z21Vy1G","q09oveLovuu","DgLTzw91Da","u3ffquK","x0rctMfTzq","vMHLvLm","BfrPBwvVDxq","C29YDa","zwrPyxrLBhK","CgLUz19VBMm","DKzVuKy","BfriDuO","rvHezu4","uxLPwMi","ywWGy3vYC28","A0fQwKe","rK1Hr3q","u2TPCcbWyxm","uMLVzKC","sgDLwNy","BMv4DcGPigm","Dw5KzwzPBMu","thvqDMy","D1ftC04","Dg9mB3DLCKm","zw5fDMvUDa","vfrMthu","v1n0B2K","mhWZFdr8n3W","ENHlvLK","x3bYzwzPEa","ANzQv1C","ChbNCwO","Bg5Wz1y","tKLtuxu","qLLSBNm","BhrPCgXLihq","thvkEK0","rKnpCwS","vKDvtu0","Ehbbu3y","EMT1Efa","z2jJDMy","ExbVtLi","BeDRr0G","tKfusvzfx0u","B2jQzwn0u3q","DgHAA1q","EKXhEKS","Bg9oAgi","ruPev0O","rLfkBui","r3LLugm","CMvTB3zLrxy","sKnMBNe","m3WYFda","Bfz6y0O","rMfPwMq","Aw9U","sxfoyuC","sLvqAgu","CNzHBa","x2HHBMrSzvi","AxnFywnR","CMfTzq","AhD5C2W","C0jf","Eevkr2G","m3W0FdL8mhW","u1fpAvy","ELPJqNy","x21LC3nHz2u","DhPQt1C","BfvjvhG","tgLusfy","BLnAqxi","suvIu0u","AxnszwfKEq","CMvZDwX0","CMvZzxrfBMq","z2vY","y29UBMvJDgK","uxHnDLq","y09Wzw4","CgfNzxnOB3C","vxzYvKm","AxnZuxe","BgjtAfa","uKPUquK","ugTRDvC","AuX0A0C","y29Uy2f0","uhf3CLG","y3jLyxrLrwW","A2DlquS","zw50zwqGDhK","ELv0vhG","z2v0u3rVCMe","BgvY","uK9ZrMW","x29UrxjYB3i","igzHAwWSig0","Cw9Zx18","BwvZC2fNzv8","A0HSseK","z29PBMCGyxC","wwDXveS","wfLmCxa","B25JBg9Zzq","t2jQzwn0","CMvWBgfJzq","wvPtA08","Dhnpq2K","z3DUqKC","vMrfueK","BwvZC2fNztO","DgrOtMu","q3DKwfa","qLvZEeW","q1P6vKG","z2v0qwXSs2u","yNzQDxK","CMvUuwu","D1byv0C","vfnOy3K","x2rLyNvN","vuzlzwW","AfnTsvK","zNjVBuHHC2G","DM9dAKS","Dxrouge","ugDxr3G","ywnRpwzYB24","wxfWvgu","zxjYB3i","x3bYB3rVy28","C3LsEfq","Ee1Xywu","CNf4s1m","BvbOrgi","mZbvze14sNO","B3nLrxzLBNq","wwjcCwW","yMDUDxq","CMvZzxrdB3u","tMXxwxm","zfbPseS","wxjgz2i","qufwrxq","uLnmtMe","vxjMzvq","CgvYC2LZDgu","BwvZC2fNzq","qxn6uvK","y1jyvvO","q2fMBxG","runRuem","z2vtEw5J","AMDizgS","Cgr1EMi","r1Huwgy","tMXpu1e","zxjHDg9Y","yMXVy2TLza","DxjS","wgXPBfe","BwLUzW","BMv3vMvYC2K","lcbTyxGGCMu","ALj1t3e","ALrNz0W","r2Hpug8","CLDxv1O","t2Pfvw4","C0nVDw50zxi","uM94sLO","rK1rC0y","Axnmuw0","B25mAw5L","wu1OAuy","BvPQEvO","DKTwBMu","DxHOuhq","BNLICMe","C3rVCMu","DNv4u2C","qunItMW","qMrtyNq","Ae5uCgO","D2v1z1G","zxjFBxnNAwq","yNjvCNy","Cgf5Bg9Hzeu","ChbL","Cgf5Bg9Hzfq","s0zOyLC","zKP1ue8","sg1dt04","EwjzAfG","DxbNCMfKzw4","x2n1CNnVCKy","z2vrDwv1zuW","zxvUvgW","Dw50","zgrjrcWGzgu","yNvMzMvYzwq","q3jivey","DfPwB0q","C3nTsNm","DKnevKu","zMLSDgvY","DgDpq1m","uMfUshC","BKXPBMu","D1PjDvq","sMzOD0m","Ae1dqNO","tgXLvKW","ywDLsgLKzq","mNWW","C3vIyxjYyxK","CM92AwrLihy","ENrPAM8","CenxD1m","x3vYBa","BvHetgW","u2vXsuq","DNfxDha","ueX3ww4","rgvKAwnHDgu","r2fusxe","yLDyqNe","zfDVCMTLCKC","yKDUCfu","x2LZtM9Kzq","yMLSA2m","BIWGAg9ZDg4","CLPgENi","nJC0ntvUCe1Qvwm","y2HHCKnVzgu","D3HJthe","sfD5CKG","A0HxDgC","yxGGCMv0CMK","odaYmdG2EuPcz0D6","u2TXAMG","sxrLuMq","quzbDeq","tw9KDwXL","sgDcDue","ywXSzwqGBxu","q291BNq","uuryufi","C3bSAwnL","C3rVCcbPBw0","x29UtwvZC2e","DMfS","ntjozNLuuhy","wxPKrLu","B3bLBKrc","whPizgK","B25TzxnZywC","y291BNq","AgfZt3DUuhi","yM1NzfG","qM5Rv28","t1bftG","BLbVC0i","Bg9N","ELHgq24","zNvUy3rPB24","y29UC3rYDwm","A0TwCfu","DhrPAuO","BgLZDgvUtMu","CvLiq2q","D3vjB0W","shb4B3m","AhjUEwe","r0TOu3K","t3rAu0m","vhb3EMW","tMTHtgi","zKntteC","zNjVBu51Bwi","z2DJCeS","rLDYChC","EwrtDMu","CwfTzK0","zvzIvhy","vfL3sNC","vhzsueq","uuDRBwe","zcbLCNjVCI4","BKP5yMO","AxnbCNjHEq","B0DTquy","r0r4seS","y29SBM8","Dev2zw50","Dg9Y","EwPRwNK","yxr1vKO","x2LUDgvYDMe","ywnRx2nVzgu","wM1Ht0G","s2ztr0C","Bwf4tg9ZC0m","zxf1ywXZ","CgTSz0m","q0Xpu0LorW","yw51Ce1LC3m","x2HHBMrSzva","vMrly24","zwnkreO","rgnxqvm","DhjHBNnHy3q","y3jLyxrLt3a","C2DPza","BMztrwG","zMzjrgG","zMX1C2HfEha","x2nSzwfYugK","yM9L","x2DLDeLUDgu","wLL3sxe","tMDkDKy","CMLLC0nVDw4","u3rqwfO","zxjYtM8","s0v6uhm","y3vYC29Y","ve50Dhe","q3LLCLa","uMXvu1C","C2nYAxb0","uxbWtLK","sLnptLa","BfDtv1m","B25szwnLAxy","sgLSCNe","DKLIufm","DwjizxK","qMnOqNK","DLrLtLq","ihjLy29UBMu","Dg9iyxnO","x2LUAxrqCM8","y3r4","C3jJ","seHZwwu","DvDcD1K","vLPzB2u","reTRuNO","ANjwqMG","yw5ZzM9YBvq","suXLB2e","vgj1vwu","tMzkBKS","Dg5uAKS","nxW2Fdj8mq","uvLkBgS","q3DAEKS","x3nLCuLK","zxmGCMvHy2G","yuXeAKi","rNvfqu0","Aw5Lza","suDuy0q","C3rYAw5N","EgjYAhm","sKPbu3a","wMHXwe8","C1jKqwm","CfD3ugq","teHAyLi","zunQwMW","DgHLBG","ruPrEK4","wejgsvO","CMPHDhe","BwzSEhy","Dg9VigXHCMC","EfzwEKe","AxnAzxjV","tg9Nsuq","Bwv0Ag9K","CMfNzvn5BMm","zgvSzxrLrge","zufJAW","u3jmAxu","wvLrtfe","mdaWmdaWmda","B3ryr2i","tKrMB2O","ywnR","CMXmzeu","yMPLCMy","u09ZuLe","C2vUzf9Hy2S","Bg9NsurozxC","mtaZntuWr0jWwwzu","yMrFzgLK","yNL0zuXLBMC","BM93","A2z5z3C","CMfUzg9T","x2nSzwfYvgK","reiGzMfPBgu","v1j6Cxi","CLDrrKq","Ec11C2uT","AKjqChm","DxrVuMvJB24","zLLzrNC","zv9ZDwnJzxm","r2LvtNy","B2LZsxa","ugXwA3m","AezuwKe","ywXSB2nvBNm","DNrXu0K","D1PxCxm","qwz4wKC","yuzPAeC","x3jLy29UBMu","rxjYB3jdB2q","Aw5N","B3jL","u2vYDMLJzvC","qNjPzgDL","q0Xpu0ve","y29UBMvJDca","rfr0Efm","rNjPDeG","B25tDgfYDfi","ihrPBwvVDxq","wwr3q3u","DvDizxe","B2fK","tufyx1jfvfi","q3vZDg9Trxi","Eg9XDu0","y3jLyxrLuMu","q09otKvdveK","Ahr0Ca","FdD8ohWX","DxnLCKLW","Bw9Qwg8","Aw9UvgLTzw8","uMHHtwi","BvvHAfy","wvDgvey","sKTOB3m","CNzHBfzHBhu","CgTurve","DefUBLq","y2DhBfy","DgvZDa","B1D6qwm","y3vYDMfSDwu","zMXVB3i","qxfougq","D3HYswC","CgLQyM8","Aw5KzxHpzG","uMj2thi","icSG","twvRv2S","q0vzD00","wwniuuu","nNW0Fdf8nxW","s213AuS","AgvHzgvY","C2vUDa","uxvLzg4","B25VCgvU","DcbSAw1PDa","CMfTugfYyw0","yxbWzw5Kq2G","D0XfwMC","Dg9nChO","y2HLy2TdDxi","BvPYyLK","CMvZB2X2zq","rhDQqwu","D24GCMvHC28","DxPZyu8","DgHqwLO","CMvQzwn0","vwzyAhe","EKHJq1a","A2PWtwS","BwLUAvbYB2C","CNjVCK1LC3m","q0v0Beu","D0Xuzeu","twvZC2fNzuu","DNv3CKG","vMPpEvu","AgDzvee","DMvYC2LVBMm","B0HeEe8","Au1SvxK","De1HBMfNzxi","DLf6BMm","Dw5RBM93BIa","D2zYv0u","zNDZxZeUmc4","x2LZtwLUAvq","u2PHvMy","Bg9Nsurhzw4","u2nIBvG","mxW1Fdj8m3W","Dhj1y3rVCIa","u2DqCuG","EvLqtwe","tuvtu0fhrv8","v1v3zMK","BgvUz3rO","ugXHz0q","v1fjs0m","zw1PDa","DNvgwuC","CMvUDevUzha","u2fXsha","Bwf4uMv0CMK","v2LUzg93","C0Xf","DhHuCLm","uNHvB0e","CMvJzxzPzwq","DKTmyKu","uhnmCuq","rw1mshq","rgXLwKG","BxnN","x2DLBMvYyxq","wgvsCem","sezkAKK","C2v0u3rVCMe","B2XKvMvYC2K","suHnsxi","BgXprwu","zxrxB3jRq2G","q29Kzq","rKnjC0O","u3P0DM8","tKnRu0S","q3vZDg9Tq2W","Bwzzr0u","x3DHAxq","sgHkquu","rM96wey","AwXLx25HBwu","CMvJB25Uzwm","DhnSBvO","vwf1BKK","D2LSBfjLy28","zNrNwhm","uLjpuG","s0TjD1O","sgz2tvC","v2Hhzfu","y3bstxu","x194x21Zz18","C2vYDMLJzs0","vgDRAeK","ELbysMi","zxjFAxnFywm","ww5kyMi","qvnqs2O","Dw5ZAwDUzwq","q0vUBuu","twDPweC","DvHWseS","uMXyvue","wgrqyva","A2v5CW","CMvHzhLtDge","Cu11AfO","wgXKy2O","x2XPC3rLBMu","sK1ewee","x2LUAxrhBg8","B2nRzxrtDwm","weHwDfi","z2vLq0u","ywDLrxzLBNq","C2v0zgi","Ae1LC3nHz2u","v2THsuG","CgjxBK8","D2nSBgG","x3nLBMrby2S","vKLmrLq","DeLK","EvfYvve","yw1L","Cg93","AK9mAKW","wMH5CLa","ywrKt25L","y3vYC29Yx24","A2vvzfa","CxfSCxm","ENjfBKe","ihrPBwvZ","C2v0y3vYC28","x25HDMLNyxq","x2LUAxq","s0Hpv0O","DwnQCwi","seHVBxu","y2HnyxHuCMK","C0XPC3rLBMu","B0HTv1a","zw5HyMXLvhi","BNrnsMu","zwnVBM5Ly3q","uwjUEuu","yKPdAeO","D3m6lY8","EeDUsLe","CYbHBhjLywq","t3bLBKv2zw4","BMnLq2XVC2u","BfL5DuC"];return vr=function(){return n},vr()}function Ul(n){let e=O,i={WaDGr:e(856),ziijS:"abort",CsFDa:function(a){return a()},PIbDx:"complete"};if(Sr[e(517)](n))return;let o=new Promise((a,c)=>{let u=e,x={BahUL:u(1695),uHiNu:i[u(1415)],yUAgC:i[u(700)],KcsDb:function(w){return i.CsFDa(w)},KcScp:function(w,A){return w(A)},zSBDL:u(373)+"or"},l=()=>{let w=u;n[w(775)+w(696)+w(1562)](x.BahUL,g),n[w(775)+"entListe"+w(1562)](x.uHiNu,E),n["removeEv"+w(696)+"ner"](x[w(537)],E)},g=()=>{x[u(519)](a),l()},E=()=>{let w=u;x.KcScp(c,n[w(856)]||new DOMException(x.zSBDL,x[w(1389)])),x[w(519)](l)};n[u(524)+u(203)](i[u(215)],g),n[u(524)+u(203)](i.WaDGr,E),n[u(524)+"Listener"](i[u(700)],E)});Sr[e(695)](n,o)}function ql(n){Ar=n(Ar)}function Hl(n){let e=O,i={UvrVC:function(o,a){return o(a)},VGUMM:function(o,a){return o(a)},SrKXf:function(o,a){return o<=a},QtwYM:e(742)+e(972)+e(758)+e(1466)+"process",zBwZE:function(o,a){return o===a},Dwogs:function(o,a){return o!==a},XtPAB:e(1134),rRIaW:function(o,a){return o(a)},rEuPk:function(o,a){return o in a},thPZZ:e(768)+"oreNames",UwzVi:function(o,a){return o!==a},ypoNR:e(1063),syRxT:function(o){return o()}};return n===IDBDatabase[e(533)+"e"][e(1038)+e(780)]&&!i[e(1586)](i[e(1210)],IDBTransaction[e(533)+"e"])?i.UwzVi(e(1063),i[e(765)])?_0xab2594?_0x9b5bc4[e(312)+"sLE"](_0x59b071,_0x3a06b6):_0x5ccdb4[e(312)+"sBE"](_0x136924,_0x4cedf1):function(o,...a){let c=e,u=n[c(677)](In(this),o,...a);return Gi[c(695)](u,o.sort?o[c(729)]():[o]),Xe(u)}:i[e(858)](zl)[e(468)](n)?function(...o){let a=e;return n[a(1623)](i[a(807)](In,this),o),i[a(761)](Xe,ji[a(592)](this))}:function(...o){let a=e,c={aYklF:function(u,x){return i[K(1489)](u,x)},RvQKU:i.QtwYM,bPPjl:function(u,x){return i.zBwZE(u,x)}};return i[a(595)]("cucWV",i.XtPAB)?i.VGUMM(Xe,n[a(1623)](i[a(422)](In,this),o)):c.aYklF(_0x19324a,_0x346ae9)?_0x1a1498[a(1211)](new _0x49694c(c[a(1603)])):(_0x190e98=_0x2dfb10,c.bPPjl(_0x2f813b,_0x316138[a(1241)])?_0x5acea1[a(1206)]():_0x276489[_0x1d3b2c][a(1641)](_0x3ca3a8)(_0x15dd98,_0x50ba78.bind(null,_0x2d098f+1)))}}function Gl(n){let e=O,i={tLbEh:function(o,a){return o===a},jgHdk:function(o,a){return o(a)},atuVJ:function(o,a){return o instanceof a},XiLNd:function(o,a,c){return o(a,c)},oTXol:function(o){return o()}};return i[e(1594)](typeof n,"function")?i[e(880)](Hl,n):(i[e(1024)](n,IDBTransaction)&&i.jgHdk(Ul,n),i[e(1406)](uc,n,i[e(1712)](Bl))?new Proxy(n,Ar):n)}function Xe(n){let e=O,i={yWySe:function(a,c){return a instanceof c},bZEcc:function(a,c){return a(c)},ztijo:function(a,c){return a(c)}};if(i[e(494)](n,IDBRequest))return i.bZEcc(Fl,n);if(Er[e(517)](n))return Er[e(592)](n);let o=i[e(944)](Gl,n);return o!==n&&(Er[e(695)](n,o),Ir[e(695)](o,n)),o}var uc,ic,sc,ji,Sr,Gi,Er,Ir,Ar,In,oc=dc({"node_modules/idb/build/wrap-idb-value.js"(){let n=O,e={CEeEz:function(i,o){return i instanceof o},txTrS:function(i,o){return i===o},Yhula:"done",bvjuy:function(i,o){return i===o},kAjZA:function(i,o){return i(o)},mTaaO:function(i,o){return i(o)},QGkma:function(i,o){return i===o},tAnnT:n(947),pINzd:"store",zyoGp:function(i,o){return i in o}};uc=(i,o)=>o[n(428)](a=>i instanceof a),ji=new WeakMap,Sr=new WeakMap,Gi=new WeakMap,Er=new WeakMap,Ir=new WeakMap,Ar={get(i,o,a){let c=n;if(e[c(1511)](i,IDBTransaction)){if(e[c(1251)](o,e[c(185)]))return Sr[c(592)](i);if(e[c(843)](o,c(768)+c(642)))return i[c(768)+c(642)]||Gi[c(592)](i);if(o===c(906))return a[c(768)+"oreNames"][1]?void 0:a[c(768)+c(1150)](a[c(768)+c(642)][0])}return e[c(737)](Xe,i[o])},set(i,o,a){return i[o]=a,!0},has(i,o){let a=n,c={LFzTi:function(u,x,l,g,E){return u(x,l,g,E)},uwYhh:function(u,x){return e.kAjZA(u,x)},JJASp:function(u,x){return e.mTaaO(u,x)}};if(e[a(1014)](a(412),e[a(1178)]))c[a(1707)](_0x21a35e,c[a(607)](_0x33b24e,_0x47e82a[a(800)]),_0x3bd802[a(1263)+"on"],_0x447141[a(889)+"on"],c[a(1093)](_0x5341f6,_0x1f53c1[a(1038)+a(780)]));else return e[a(1511)](i,IDBTransaction)&&(e[a(1251)](o,e.Yhula)||e[a(843)](o,e[a(1595)]))?!0:e.zyoGp(o,i)}},In=i=>Ir[n(592)](i)}}),fc={};Ml(fc,{deleteDB:()=>Kl,openDB:()=>jl,unwrap:()=>In,wrap:()=>Xe});function jl(n,e,{blocked:i,upgrade:o,blocking:a,terminated:c}={}){let u=O,x={qPiiP:function(E,w,A,_,b){return E(w,A,_,b)},uXpHK:function(E,w){return E(w)},kzPFG:function(E,w){return E(w)},TxUXN:u(199),lnpgV:function(E,w,A,_){return E(w,A,_)},tgOCS:function(E,w){return E&&w},mUahV:u(785),lpMmf:"ack_id",YexZg:function(E){return E()},xBAsj:function(E,w){return E!==w},kHWtg:u(443),IHMIr:u(526),Hpxos:u(921)+"eeded"},l=indexedDB[u(367)](n,e),g=Xe(l);return o&&l["addEvent"+u(203)](x[u(999)],E=>{let w=u;x.qPiiP(o,x[w(1297)](Xe,l[w(800)]),E[w(1263)+"on"],E[w(889)+"on"],x.kzPFG(Xe,l["transact"+w(780)]))}),i&&l[u(524)+u(203)]("blocked",()=>i()),g.then(E=>{let w=u;if(x[w(576)](w(513),x[w(964)]))c&&E["addEvent"+w(203)](x[w(1264)],()=>c()),a&&E["addEvent"+w(203)]("versionc"+w(214),()=>a());else{let{enableAutoAck:A}=this[w(1627)],_=_0x44d0ca(_0x2c8c9a[w(874)][w(1512)],x[w(322)],"1"),b=x[w(755)](_0x31549b,_0x3d1d1a[w(874)][w(1512)],w(785),"1"),S=_0x5cf869[w(677)](this,_0x27d9e6);if(x[w(933)](A,_)){let{SeqID:I,LogID:k,service:L,LogIDNew:m,method:C}=_0x1e2882[w(874)];this._sendAck({SeqID:I,LogID:k,LogIDNew:m,service:L,method:C,headers:[{key:x[w(1173)],value:"1"},{key:x.lpMmf,value:m||""},{key:w(1026),value:"0"}]})}b&&!S[w(480)]&&this[w(1429)+w(1647)+"ageEvent"](_0x3c91ea),x[w(709)](_0x3db78a)}})[u(1440)](()=>{}),g}function Kl(n,{blocked:e}={}){let i=O,o={VwemX:i(885),NISQu:function(c,u){return c(u)}},a=indexedDB[i(1110)+"tabase"](n);return e&&a[i(524)+i(203)](o.VwemX,()=>e()),o[i(756)](Xe,a)[i(1099)](()=>{})}function ac(n,e){let i=O,o={aLDjB:i(694)+"e",DEKZe:"readonly",uEJSC:function(l,g){return l instanceof g},ZwmpJ:function(l,g){return l in g},dRRFE:function(l,g){return l!==g},pkTEQ:function(l,g){return l!==g},SOsRQ:"iTxZr",pXeMw:i(601)};if(!(o.uEJSC(n,IDBDatabase)&&!o[i(498)](e,n)&&typeof e===i(1091)))return;if(br[i(592)](e))return br[i(592)](e);let a=e[i(832)](/FromIndex$/,""),c=o[i(1378)](e,a),u=lc[i(468)](a);if(!o[i(498)](a,(c?IDBIndex:IDBObjectStore)[i(533)+"e"])||!(u||xc.includes(a))){if(o[i(1177)](o[i(1120)],o[i(1441)]))return;this.endpoints=_0x21e44f,this[i(1248)+"es"]=_0x27357d,this[i(719)+i(503)]=0,this[i(1564)+i(364)+i(1049)+"t"]=0}let x=async function(l,...g){let E=i,w=this[E(1038)+E(780)](l,u?o[E(1087)]:o[E(274)]),A=w[E(906)];return c&&(A=A[E(230)](g[E(331)]())),(await Promise[E(1570)]([A[a](...g),u&&w[E(583)]]))[0]};return br.set(e,x),x}var xc,lc,br,Wl=dc({"node_modules/idb/build/index.js"(){let n=O,e={bLMQt:n(1235)+n(371),IQcRR:function(a,c){return a(c)},ExFUE:n(592),AFzcT:n(842)+"ys",tezBL:n(984),tPJQy:n(1400),qqlqs:n(1516),otXGb:n(1633),ouLjF:n(359),RSvSw:function(a){return a()}},i=e[n(1581)][n(1449)]("|"),o=0;for(;;){switch(i[o++]){case"0":e[n(253)](ql,a=>({...a,get:(c,u,x)=>ac(c,u)||a.get(c,u,x),has:(c,u)=>!!ac(c,u)||a.has(c,u)}));continue;case"1":oc();continue;case"2":xc=[e[n(1532)],n(1637),n(1576),e[n(1500)],e[n(516)]];continue;case"3":lc=[e[n(676)],e[n(1327)],e[n(1115)],e[n(1382)]];continue;case"4":br=new Map;continue;case"5":e[n(1706)](oc);continue}break}}}),$l={idb:function(n){let e=O,i={QXRVx:function(o,a){return o>=a},mmVeq:e(1390)};n[e(653)]=Promise[e(1206)]().then(()=>(Wl(),fc))[e(1099)](function(o){let a=e,c={QDFgq:function(u,x){return i[K(669)](u,x)}};return a(646)!==i.mmVeq?o:c[a(693)](_0xc67686[a(266)],_0x43ceba[a(1413)])})}},cc={};function Ye(n){let e=O,i={KlMuo:function(x,l){return x!==l}},o=(e(225)+"1").split("|"),a=0;for(;;){switch(o[a++]){case"0":var c=cc[n];continue;case"1":return u[e(653)];case"2":var u=cc[n]={exports:{}};continue;case"3":$l[n](u,u[e(653)],Ye);continue;case"4":if(i[e(1427)](void 0,c))return c[e(653)];continue}break}}(()=>{let n=O,e={pCWwS:function(i,o){return i+o},KpJok:n(1001)};Ye.d=(i,o)=>{let a=n,c={cXxAt:function(x,l){return e[K(945)](x,l)},qMuhZ:function(x,l){return x>l}};if(e[a(488)]==="GKhSy")for(var u in o)Ye.o(o,u)&&!Ye.o(i,u)&&Object[a(704)+a(708)](i,u,{enumerable:!0,get:o[u]});else{let x=_0x3491b5[a(219)],l=_0x4b70f5[a(266)],g=_0x49568a[a(1413)],E=c[a(1659)](l,_0x36de4c);if(c[a(1302)](E,x[a(1241)])){let w=new _0x1fba89(2*E);w[a(695)](x),_0x468b33.bytes=w}return _0x4cb8d2[a(266)]=E,E>g&&(_0x44428c.limit=E),l}}})(),(()=>{let n=O;Ye.o=(e,i)=>Object[n(533)+"e"][n(985)+"operty"].call(e,i)})(),(()=>{let n=O,e={mQSxu:function(i,o){return i!=o},MIFzb:n(743)+"d",DTtxS:n(970),ssmJs:"__esModule"};Ye.r=i=>{let o=n;e.mQSxu(e[o(1692)],typeof Symbol)&&Symbol[o(1667)+o(432)]&&Object[o(704)+o(708)](i,Symbol[o(1667)+o(432)],{value:e[o(1155)]}),Object[o(704)+o(708)](i,e[o(930)],{value:!0})}})();var pe={};function K(n,e){n=n-180;let i=vr(),o=i[n];if(K.UwZmxD===void 0){var a=function(l){let g="abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789+/=",E="",w="";for(let A=0,_,b,S=0;b=l.charAt(S++);~b&&(_=A%4?_*64+b:b,A++%4)?E+=String.fromCharCode(255&_>>(-2*A&6)):0)b=g.indexOf(b);for(let A=0,_=E.length;A<_;A++)w+="%"+("00"+E.charCodeAt(A).toString(16)).slice(-2);return decodeURIComponent(w)};K.tznSlX=a,K.SXssbb={},K.UwZmxD=!0}let c=i[0],u=n+c,x=K.SXssbb[u];return x?o=x:(o=K.tznSlX(o),K.SXssbb[u]=o),o}(()=>{let n=O,e={BtqwB:function(s,t){return s(t)},DWuYc:function(s,t){return s+t},CWXiv:function(s,t){return s+t},TYwJw:function(s,t){return s*t},VILFT:function(s,t){return s(t)},iIvVy:function(s,t){return s+t},uxhPt:function(s,t){return s(t)},KPXlX:function(s,t,r){return s(t,r)},DleZH:n(546),ckXwA:n(302),EUDkz:n(1114)+"00000000"+n(1114)+n(1114),RqARa:n(665),zlghY:n(333),rlsms:n(1499),ofPWK:n(806),LmUPR:function(s,t){return s>t},hmBtU:function(s,t){return s-t},hzJUd:function(s,t){return s!==t},IdFdn:function(s,t){return s-t},YYQLQ:function(s,t){return s<t},BuwFJ:function(s,t){return s-t},toMpz:function(s,t){return s<t},SgPqH:function(s,t){return s===t},ojEDa:"WSLNH",MekWk:function(s,t){return s!==t},PlagD:n(980),TgkhI:function(s,t){return s!==t},mZjyZ:function(s,t){return s-t},tVQiz:function(s,t){return s!==t},rBDYm:function(s,t){return s(t)},HmCON:function(s,t){return s>>>t},wOhDG:function(s,t){return s(t)},uUZfy:function(s,t){return s&t},ogsoR:n(345)+n(628)+n(712)+"key",WCyyo:function(s,t){return s===t},Ldnbe:n(345)+n(628)+n(712)+n(410),ZYwIq:function(s){return s()},kVonv:"wss://",dxXAM:function(s,t){return s(t)},renQe:function(s,t){return s+t},EBSJb:function(s,t){return s===t},LMtNQ:n(810),EbLiA:n(1293),iTyhh:function(s,t,r){return s(t,r)},EuHYL:function(s,t){return s!==t},mfYGE:function(s,t,r){return s(t,r)},uWHeq:function(s,t,r){return s(t,r)},YBZuI:function(s,t){return s!==t},tJXph:function(s,t,r){return s(t,r)},TNttq:function(s,t,r){return s(t,r)},utNPa:function(s,t,r){return s(t,r)},ZmaOH:function(s,t){return s(t)},QbnyE:function(s,t){return s!==t},HHsYe:function(s,t,r){return s(t,r)},fqEHy:function(s,t){return s!==t},RhaMb:n(456),IrGEx:function(s,t,r){return s(t,r)},BtseU:function(s,t,r){return s(t,r)},GPjmR:function(s,t,r){return s(t,r)},BNBdp:function(s,t,r){return s(t,r)},YrFgb:function(s,t,r){return s(t,r)},kkgGx:function(s,t){return s(t)},IXqTO:function(s,t){return s(t)},LuJzM:function(s,t,r){return s(t,r)},ZIEHl:function(s,t){return s(t)},xGnJQ:function(s,t){return s(t)},ttiiJ:function(s,t){return s(t)},IYyAQ:function(s,t){return s(t)},KmwiK:function(s,t,r){return s(t,r)},NwhNh:function(s,t){return s(t)},VisnG:function(s,t,r){return s(t,r)},OILyc:n(345)+"required field: LogID",GSIrs:function(s,t){return s===t},GaTIq:"Missing "+n(628)+n(712)+n(529),qvoVK:function(s,t){return s+t},FCOqk:function(s,t){return s&t},tzjOW:function(s,t,r){return s(t,r)},llOEe:function(s,t){return s(t)},yYPMa:function(s,t,r){return s(t,r)},eunTl:function(s,t){return s>>t},wcllh:function(s,t){return s>=t},EvlWu:function(s,t){return s===t},UkRPO:n(739)+n(1199),Quedn:function(s,t){return s+t},losqI:function(s,t){return s>t},ZUJLQ:n(561)+n(1199),ROsFl:function(s,t){return s+t},ucjqb:function(s,t,r){return s(t,r)},bWXBq:function(s,t){return s<t},HFJjI:function(s,t){return s&t},nCJEA:function(s,t){return s+t},nAWyS:function(s,t){return s+t},SDXvK:function(s,t){return s&t},DcWAS:function(s,t){return s|t},sRdAc:function(s,t){return s<<t},rWWWZ:function(s,t){return s&t},dOpgb:function(s,t){return s<t},qEduV:function(s,t){return s(t)},MXGgp:function(s,t){return s==t},dPZJO:function(s,t){return s>=t},TgWXU:function(s,t){return s+t},OtZSC:function(s,t){return s&t},zUtTx:function(s,t){return s|t},YeCkH:function(s,t){return s|t},QppNY:function(s,t){return s&t},lGkGH:function(s,t){return s&t},zQrXd:function(s,t){return s&t},chzKt:function(s,t){return s>=t},BYlns:function(s,t){return s<=t},JcmuI:function(s,t){return s+t},kPiTN:function(s,t){return s+t},zLGzK:function(s,t){return s+t},Jqdvm:function(s,t){return s|t},ZhyrP:function(s,t){return s|t},IbQjb:function(s,t){return s<<t},xmvIJ:function(s,t){return s&t},cSyIl:function(s,t){return s<<t},UrfeT:function(s,t){return s>t},GHrUS:function(s,t){return s+t},pduzb:"error",TTfLu:function(s,t){return s<t},issQq:function(s,t){return s<=t},fGiVg:function(s,t){return s<t},aibbb:function(s,t){return s-t},BFknK:function(s,t){return s+t},PLwYn:function(s,t){return s<<t},NdYXO:function(s,t){return s<t},wxrIg:function(s,t){return s<t},jRuOq:function(s,t,r){return s(t,r)},zhwSf:function(s,t){return s<t},nybra:function(s,t){return s>=t},ZfQSx:function(s,t){return s<=t},ACkjx:function(s,t){return s<t},YcHQE:function(s,t){return s-t},VjOyU:function(s,t){return s&t},VXFkY:function(s,t){return s>>t},BEpVr:function(s,t){return s>>t},LynBt:n(439),JFBQR:function(s,t){return s&t},jDxUS:function(s,t){return s>>t},scHut:function(s,t){return s|t},QhTbi:function(s,t,r){return s(t,r)},NrzFQ:function(s,t){return s*t},zRCDA:function(s,t){return s*t},mmIqT:function(s,t){return s!==t},YZSkO:n(656),BwaBS:function(s,t){return s(t)},CcjYF:function(s,t){return s<t},SITrL:function(s,t){return s<<t},fZHXA:function(s,t){return s&t},RbvLr:function(s,t){return s|t},fkokM:function(s,t){return s&t},OurSR:function(s,t){return s+t},EVQxm:function(s,t){return s+t},gbcvf:function(s,t){return s(t)},yPgHy:function(s,t){return s<<t},EJQzN:function(s,t){return s&t},NUWHO:function(s,t){return s(t)},lDPpy:function(s,t){return s<<t},jnRKU:function(s,t){return s(t)},pWwPd:function(s,t){return s(t)},udePj:function(s,t){return s(t)},wZGht:function(s,t){return s<<t},MFPjC:function(s,t){return s(t)},YguEK:function(s,t){return s(t)},REyZE:function(s,t){return s&t},Auuxx:function(s,t){return s!==t},CxxEb:"RrGJR",kKHmJ:n(1625),iLtkG:function(s,t){return s(t)},ZQgPK:function(s,t){return s<<t},bQqEa:function(s,t){return s<<t},kHlHI:function(s,t){return s>>>t},YvpKZ:function(s,t){return s>>>t},IGTcD:function(s,t){return s|t},xpASv:function(s,t){return s<t},wymlt:function(s,t){return s<t},lhxRX:function(s,t){return s<t},xuEUo:function(s,t){return s<t},JuxWY:function(s,t){return s<t},NRMzm:function(s,t){return s<t},LHZbR:function(s,t){return s+t},qXzdb:function(s,t){return s!==t},dRHDI:function(s,t){return s|t},SzkEQ:function(s,t){return s>>>t},xvzqH:function(s,t){return s|t},dPiHK:function(s,t){return s&t},SQOiV:function(s,t){return s|t},qwZZP:function(s,t){return s>>>t},rirGW:function(s,t){return s&t},jIUnz:function(s,t){return s>>>t},fvbOC:function(s,t){return s+t},dvdeQ:function(s,t){return s!==t},hMCBz:function(s,t){return s|t},utEji:function(s,t){return s>>>t},BdSbt:function(s,t){return s|t},uGZNO:function(s,t){return s!==t},HOOMf:function(s,t){return s|t},KEzPs:function(s,t){return s!==t},ugLet:function(s,t){return s&t},ecJDJ:function(s,t){return s(t)},MiwXN:function(s,t){return s|t},sIAco:function(s,t){return s===t},EJDWJ:n(623),dcRKK:function(s,t){return s|t},yJDMf:function(s,t){return s<<t},MvCUW:function(s,t){return s|t},hMraZ:function(s,t){return s|t},IPEmC:function(s,t){return s|t},Brpaf:function(s,t){return s<<t},JCfnq:function(s,t){return s<<t},FjlFj:function(s,t){return s<<t},tczgo:function(s,t){return s|t},yTztw:function(s,t){return s<<t},pklgC:function(s,t){return s<<t},PoNFv:function(s,t){return s<<t},MgiXG:function(s,t){return s<<t},oPZrZ:function(s,t){return s<<t},CgdFh:function(s,t){return s|t},vuFYG:function(s,t){return s<<t},aiOzZ:function(s,t){return s<<t},cWUfp:function(s,t){return s<<t},cssFE:function(s,t){return s>>>t},jsASj:function(s,t){return s|t},HEufC:function(s,t){return s|t},Foqdm:function(s,t){return s<<t},PWOFw:function(s,t){return s&t},GagHD:function(s,t){return s&t},utYYr:function(s,t){return s>>>t},oHmWP:function(s,t){return s&t},iclWO:function(s,t){return s&t},brUrv:function(s,t){return s>>>t},dHaqs:function(s,t){return s(t)},QHkXq:function(s,t){return s>=t},bwgoc:function(s,t){return s!==t},Sztvo:n(449),NnHqc:"nRwan",jOLjL:function(s,t){return s<=t},SreEH:function(s,t){return s|t},FozXF:function(s,t){return s|t},OjEUn:function(s,t){return s/t},fzNcE:function(s,t){return s+t},smTtf:function(s,t){return s*t},sjtzm:function(s,t){return s+t},rlLdE:function(s,t){return s*t},NgJvF:function(s,t){return s===t},raQGM:function(s,t){return s!==t},guvtA:n(865),rhTYD:n(1083),QQnAN:function(s,t){return s>>>t},IqNaG:function(s,t){return s&t},ZzsSr:function(s,t){return s+t},SAwha:function(s,t){return s|t},XlilQ:function(s,t){return s<<t},YqpTe:function(s,t){return s!==t},WhGdU:function(s,t){return s>>>t},yJpjq:function(s,t){return s>>>t},pijbo:function(s,t){return s===t},DKkRz:n(974),wQSsN:function(s,t){return s===t},ppgqj:function(s,t){return s===t},RanHw:"UzfUY",VYOuH:n(279),nwPoR:n(1175),wSloB:function(s,t){return s&t},BtQOP:function(s,t){return s>>>t},uDoEq:function(s,t){return s&t},SqEAI:function(s,t){return s>>>t},hpaJT:function(s,t){return s&t},gWwYt:function(s,t){return s&t},aIIUw:n(603)+n(941),kKVpU:n(767)+n(1282),QZCHr:n(1162)+n(475)+"R",vTKnj:n(1239)+n(680),BDKCN:"CONNECTI"+n(350),oECsQ:n(376),fyfyl:"lRzJz",GwwTn:"2|0|1|4|3",zkuxP:"fBgOi",JCRhK:n(263),lbShP:function(s,t){return s===t},KCmTK:function(s,t){return s>>>t},xWxpi:function(s,t){return s|t},ubHey:function(s,t){return s<<t},DVZPT:function(s,t){return s>>>t},FYPkT:function(s,t){return s|t},cpRMu:function(s,t){return s<<t},yccQQ:function(s,t){return s<<t},PLmCZ:"ZCCju",oHaWk:n(682),rqxKS:function(s,t){return s==t},sKXra:function(s,t){return s instanceof t},GXTXf:function(s,t){return s===t},xbrhs:n(1650),UiHAw:function(s,t){return s>t},VkveJ:function(s,t){return s||t},dYdko:function(s,t){return s===t},uXXHi:n(344),GrQzf:n(1117),qgOsa:function(s,t){return s===t},cZJjJ:n(928),oisIp:function(s,t){return s!=t},ACbNl:n(743)+"d",xEJGh:"__esModule",PRLWx:n(1350),PWsKu:n(1254),FaiZd:function(s,t){return s instanceof t},nPosB:function(s,t){return s+t},cGaDE:n(1527)+n(1015),RSLNa:function(s,t){return s+t},QDgfY:function(s,t){return s===t},PkkuW:function(s,t){return s!==t},YBApG:n(713),aFihG:function(s,t){return s<t},nJybj:function(s,t){return s===t},QyiZb:function(s,t){return s&t},WUUgS:function(s,t,r,d){return s(t,r,d)},NQahX:function(s,t){return s+t},PlVks:function(s,t){return s===t},AszQY:"GlBNa",wadpD:n(1432),dTVjI:n(526),XeRpC:function(s,t){return s===t},PFrAg:n(1041),IDtzY:n(367),GIBOV:function(s,t){return s===t},OZWQg:"qInGb",CqeWM:n(1004),JCwth:function(s,t,r){return s(t,r)},KulVU:n(874),PkPEA:function(s,t,r){return s(t,r)},FPfER:function(s,t,r){return s(t,r)},HWyrH:function(s,t,r){return s(t,r)},CPZbT:function(s,t){return s+t},oocpA:function(s,t){return s!==t},jkznA:"WgkSB",YgqTK:n(630),RiofG:function(s,t){return s<=t},WQIKC:function(s,t){return s(t)},HjJrD:function(s,t){return s<t},gcUJk:function(s,t){return s===t},Skqjh:function(s,t){return s<t},RxUoA:function(s,t){return s<t},KECDG:function(s,t){return s>=t},xoquM:function(s,t){return s|t},YAfpQ:function(s,t){return s>=t},lTHuJ:function(s,t){return s<<t},HMKGr:function(s,t){return s&t},EXDeN:function(s,t){return s-t},IltRZ:function(s,t){return s|t},vTeNT:function(s,t){return s|t},wPsgD:function(s,t){return s<<t},nZAos:function(s,t){return s+t},OdoVi:function(s,t){return s>>t},CwdXP:function(s,t){return s+t},aLruc:function(s,t){return s<t},LLGMQ:n(1143),NbVHO:function(s,t){return s&t},nzcVD:function(s,t){return s|t},JpFAa:function(s,t){return s|t},DwjAe:function(s,t){return s&t},VRIGm:function(s,t){return s>>t},tcAAF:function(s,t){return s>>t},zKDSQ:function(s,t){return s|t},mqblF:n(1091),IbyLg:n(1290),vFoRF:function(s,t){return s instanceof t},nRPqz:function(s,t){return s instanceof t},FCIsJ:n(1531)+"ion/json",zfUmT:function(s,t){return s==t},fSPTh:n(1579)+n(1530)+"et=utf-8",Omnwq:function(s,t){return s===t},hgYTA:n(861),vjtpS:n(876),PrpQP:n(1045),xqYqg:n(915),QkyrF:n(883),RSZXV:n(1228)+n(1539),GlxFv:n(256),MTsqB:function(s,t){return s(t)},tdhNe:n(373)+"or",wxcLq:function(s,t){return s===t},nXeyX:n(229),WStoi:function(s,t){return s!==t},MIGsC:"wgyOU",tYheo:n(1437),dzTgA:function(s){return s()},keUdP:n(343),jrVBh:function(s,t){return s===t},ffIDh:"ThZAB",zZXcB:n(976)+n(730)+n(1067)+"ct",ILeoa:function(s,t){return s===t},HfvMW:n(238),pupZF:n(903),mYQJH:n(816),GvQvf:function(s,t){return s(t)},HgeZv:function(s,t){return s<<t},rjatq:function(s,t){return s&t},GurZA:n(1638),srPIS:function(s,t){return s||t},FritH:n(679),bjerf:"script",TKuOB:n(1609)+n(271),BUsxL:n(1167),OehYC:n(539)+n(854)+n(1402)+"P",GyePc:function(s,t){return s!==t},KHvcr:n(1055),duqaH:function(s,t){return s!==t},CEnmE:n(361),CXFhT:function(s,t){return s||t},RgKBu:function(s,t){return s(t)},rHYkm:function(s,t){return s===t},oLIPD:n(1596),EkJBq:n(1349),IEHDN:function(s,t){return s||t},LqONq:n(346),WRrzy:function(s,t){return s||t},JUPhe:function(s,t){return s(t)},eBqJf:n(660),Tfdyc:"hKqUp",WWvGl:function(s,t){return s||t},kYCyx:n(212),hQeXg:n(1391),cqSGr:function(s,t){return s||t},XzHdi:function(s,t){return s||t},vqWtp:function(s,t){return s!=t},DRDvZ:function(s,t){return s!=t},FBXVs:n(645)+n(1130)+"d",FVGas:n(210),gkYab:"message_id",KpUEi:function(s,t){return s(t)},rtAvM:function(s,t){return s&t},RhykO:function(s,t){return s<<t},zxKVY:function(s,t){return s===t},CEtlE:n(1557),kGZRj:n(572),Indkk:function(s,t,r){return s(t,r)},qamfM:n(647),DFaou:n(795),jySyF:function(s,t){return s(t)},njuzL:n(598)+"er_qos",zszRe:function(s,t,r,d){return s(t,r,d)},hGHzQ:n(598)+"er_qos_ack",XLNvc:n(598)+n(1291)+"k",Tpwzl:n(598)+n(1358)+n(1040),zGfNV:function(s,t){return s&t},PVyKM:function(s,t){return s===t},VUBOn:"JiiXt",jsOUu:function(s,t,r,d){return s(t,r,d)},KFhbW:n(199),KfSGG:function(s,t,r,d){return s(t,r,d)},hNzBf:function(s,t){return s&&t},QsGDP:function(s,t){return s===t},AOkJV:n(1278),kyWrE:n(785),ECkPC:n(1694),SaqHp:function(s,t){return s||t},StPXZ:n(340),bilkc:function(s){return s()},eZLtX:function(s,t){return s(t)},UWpRP:function(s,t){return s instanceof t},oGmAF:n(1472)+"e",GxwBR:n(556),vwfCI:function(s,t){return s(t)},PqwrX:function(s,t){return s>t},NlWYs:function(s,t){return s+t},SLutz:function(s,t){return s|t},AfxZG:function(s,t){return s||t},pNGYK:function(s,t){return s>>>t},gaKtR:function(s,t){return s(t)},wZIuT:function(s,t){return s+t},MUvlD:n(1393),RsGSH:function(s,t){return s+t},cgGlV:function(s,t){return s+t},CQwjE:n(404)+n(1567)+n(710),pjGbZ:function(s,t){return s||t},lVzcJ:n(1510),GDxHK:function(s,t){return s>=t},ZeRHM:function(s,t,r,d){return s(t,r,d)},Zwvzn:function(s,t){return s+t},geeCE:function(s,t){return s<t},AFAtD:function(s,t,r,d){return s(t,r,d)},ABxmC:function(s,t){return s+t},LiTHV:function(s,t){return s+t},AXZDT:function(s,t,r,d){return s(t,r,d)},lXBzS:function(s,t){return s|t},GiUNv:function(s,t){return s|t},VdEPI:function(s,t){return s+t},HgBuA:function(s,t){return s+t},HHomu:function(s,t){return s|t},estzd:function(s,t){return s<<t},ofMiv:function(s,t){return s+t},PqEKH:function(s,t){return s+t},AAVEt:function(s,t){return s>>>t},nbyzx:function(s,t){return s&t},VheVS:function(s,t){return s>>>t},Onkcc:function(s,t){return s&t},hNTpj:function(s,t){return s>>>t},SDiTE:function(s,t){return s+t},aiifA:function(s,t){return s+t},RoxJZ:function(s,t){return s+t},fJuPO:function(s,t){return s|t},TzlkI:function(s,t){return s&t},YWFTF:function(s,t){return s>>>t},fgaYY:function(s,t){return s<<t},ikUjy:function(s,t){return s&t},bVVLN:function(s,t){return s|t},VdIxp:function(s,t){return s|t},mklVd:function(s,t){return s|t},ZgeHf:function(s,t){return s<<t},xNnDX:function(s,t){return s>t},vuxSg:"qKbGf",ftgXs:function(s,t,r,d){return s(t,r,d)},PctMs:function(s,t){return s|t},DcteN:function(s,t){return s(t)},NVXsb:function(s,t){return s+t},jROXA:n(790)+"6|5|2|10"+n(1168),BBGGH:n(1182),FJbJZ:n(186)+"ervice",RtJvZ:function(s,t,r,d){return s(t,r,d)},CGztm:function(s,t,r,d){return s(t,r,d)},AqNPd:n(529),XaFBk:n(510),DDKxH:function(s,t,r,d){return s(t,r,d)},FonRl:n(1195),vVdrZ:n(462),XIyfP:function(s,t){return s(t)},JZiLz:function(s,t,r){return s(t,r)},oCXkt:function(s,t,r,d){return s(t,r,d)},vACde:function(s,t,r){return s(t,r)},ccFdH:"cursor_f"+n(1276),kQoEF:n(1448)+n(486),oHDxO:function(s,t){return s||t},oYrGs:function(s,t){return s||t},BnkWo:function(s,t){return s!=t},MqJhN:function(s,t){return s===t},AHFHl:"WhQcF",VTJDo:n(353)+n(597),XBFIZ:"ALL",lWSWS:"INSTANT",zmVkJ:"CONTINUE",RlXUA:function(s,t,r,d){return s(t,r,d)},NHaQx:function(s,t){return s>>>t},oDcnF:function(s,t){return s>>>t},hrnya:n(400),shIZh:n(1213),TShcy:n(1311),bGnpU:function(s,t){return s(t)},pSJWy:n(1330)+"r",OImzX:function(s,t){return s>=t},fzAcY:n(1255),Jrhmc:n(1227),SrLiu:function(s,t){return s||t},UPtrW:function(s,t){return s(t)},yEMtn:function(s,t){return s+t},wVuLb:n(602),isLQm:function(s,t,r,d){return s(t,r,d)},KZeIe:function(s,t,r){return s(t,r)},iXOjz:n(598)+n(912),EENYF:function(s,t,r){return s(t,r)},CwZzK:n(598)+n(1550),NfJnK:function(s,t,r,d){return s(t,r,d)},Xhxvn:"x-msg-qos",EGhpe:function(s,t,r){return s(t,r)},SsRTg:"x-msg-cu"+n(1713)+"e",zZcBv:function(s,t){return s(t)},uzsaO:n(463)+"rsor_value",fCSLG:n(1170),PgPBd:function(s){return s()},xVVzA:function(s){return s()},jrPtD:function(s,t){return s!==t},wFyWW:n(1663),YnJbb:n(652),nSZAr:function(s){return s()},KIbDm:function(s){return s()},zlGaK:function(s){return s()},jCvCY:function(s,t){return s===t},KKIwZ:function(s,t){return s(t)},rZFzr:function(s){return s()},NvUcE:function(s,t){return s===t},WGzSM:n(254),eCjZl:n(1426),rJWDq:function(s,t,r,d){return s(t,r,d)},sMCzf:function(s,t,r){return s(t,r)},ScbmX:function(s,t){return s!==t},eSAWZ:function(s,t){return s<t},VrUpD:n(851),FKEQi:function(s,t,r){return s(t,r)},jTggL:function(s,t){return s+t},uzamI:n(1520),WUwfi:n(901),oVgoQ:function(s,t){return s===t},WlPjO:n(191),afefV:function(s,t){return s===t},lcmoL:n(731)+n(1137)+"s",KHOWJ:function(s,t){return s===t},PUjxU:function(s,t){return s!==t},URWot:n(1013),UJGaf:function(s,t,r,d){return s(t,r,d)},kxCwS:function(s,t){return s!==t},VBacm:n(661),PYYmd:function(s,t,r){return s(t,r)},etykL:function(s,t){return s!==t},yjkZy:"arraybuffer",FMQsF:"pbbp2",SVbnD:function(s,t){return s/t},FrCyR:n(288)+n(943)+n(620),DrUFh:function(s,t){return s(t)},kfygw:n(1277)+"t",ybYhX:function(s,t){return s!==t},WRzqr:function(s,t){return s==t},yDGdG:n(1344),BzQBQ:n(1124),kuRMj:n(309),PRIzq:n(1665)+"d",tXnnv:function(s,t){return s||t},dovjw:n(992),wLTdE:function(s){return s()},NZhvi:n(1433),iYXYN:function(s,t){return s!==t},TObHJ:"OZOyd",LleVL:n(520),LJMNC:function(s,t){return s>t},gNtRg:function(s,t){return s-t},ptIKW:function(s,t,r){return s(t,r)},fIrVK:function(s,t,r){return s(t,r)},VZYoe:function(s,t){return s(t)},Xldcj:function(s,t){return s!==t},OmcSK:"sTQYQ",uWBwY:n(605)+">",LWnNo:function(s,t,r){return s(t,r)},DxIxu:n(724),kMUYs:n(827)+n(447)+n(1277)+"ting ser"+n(257),UsLdv:function(s,t){return s!==t},HphOD:n(1540),wLEZg:function(s,t){return s!==t},YwMkx:n(484),DmGRX:function(s,t){return s(t)},wfrWE:function(s,t){return s===t},OdyYw:n(1711)+"4",iMlUy:"4|0|2|1|3",ZYiLK:function(s,t,r){return s(t,r)},loNhb:function(s,t,r){return s(t,r)},xoiDI:n(827)+n(1672)+n(648)+n(206),Qjmrh:n(744),zXFCn:function(s,t){return s+t},aiBDA:n(1214),EmLHt:"taZgF",QmcpD:function(s,t){return s!==t},wPXWG:n(567),QDKhd:n(1121),XHVtR:function(s,t){return s!==t},xMqae:n(1699),LRySG:function(s,t){return s!==t},tqppI:"ShkAr",MrRza:n(997),NCkSK:function(s,t){return s!==t},FMaGt:"close, w"+n(1346)+n(1416),CILJz:"close, w"+n(721)+"ce not i"+n(226)+"ed",KsmrS:function(s,t){return s+t},BsqVc:function(s,t){return s+t},VgCPz:function(s,t){return s+t},bmgdX:function(s,t){return s!==t},fKqxA:function(s,t){return s|t},pXVIB:function(s,t){return s&t},GQufA:function(s,t){return s&t},fYYFw:function(s,t){return s(t)},icqFC:function(s,t){return s==t},Cafmx:function(s,t){return s==t},UFKel:n(585),vMUAY:function(s,t){return s instanceof t},ZxnaQ:function(s,t){return s(t)},hwysl:function(s,t){return s(t)},HmuiY:function(s,t){return s||t},FQJmB:"please provide a"+n(1533)+n(264),qhwMO:function(s,t){return s instanceof t},qUVRJ:n(1141),gFADA:n(362),oUDNb:n(1196),eVbTv:n(566),yOVHH:n(1424),IpQAI:function(s,t){return s!==t},cjrlC:n(706)+n(1341)+n(1149),Hilrq:n(1573)+"1",jXGKz:function(s,t){return s<<t},BrcHC:function(s,t){return s===t},RlUSW:n(929),dILMS:n(541),TbuUe:n(1361),ZxPYm:n(731)+"e_timeout",TXJBT:"\0\0\0\0\0\0\0\0",tnTjK:function(s,t){return s*t},VTLWZ:function(s,t){return s/t},opiAW:function(s,t){return s!=t},PwhkL:n(1249),mflxv:n(831),tuUkM:n(951)+n(954)+n(565)+"pe",CEYwM:function(s,t){return s!=t},MMpQn:n(507)+n(1451)+n(303),DDYcp:function(s,t){return s!=t},YOufl:function(s,t){return s!=t},dIawX:function(s,t,r){return s(t,r)}};Ye.r(pe),Ye.d(pe,{FWS:()=>Kd,CustomErrorEvent:()=>ks,createCloseEvent:()=>Ue,ReconnectEvent:()=>Ps,createErrorEvent:()=>Me,decodedFrame:()=>kt,createOpenEvent:()=>Bs,CustomCloseEvent:()=>Rs,createReconnectEvent:()=>ni,FrontierMessageEvent:()=>Ls,encodeFrame:()=>_e,createMessageEvent:()=>Ms,OpenEvent:()=>Os,ErrorCode:()=>ft,Event:()=>Lt,MessageEvent:()=>Ns});let i="";function o(s=""){let t=n,r="02",d=""+Date[t(1126)](),f=i||(i=e[t(663)](l,s)),p=Math[t(1128)]()[t(1667)](16)[t(1483)](-6);return e[t(606)](e[t(606)](e[t(323)](r,d),f),p)}function a(){let s=n;return e[s(323)](e[s(1012)](1e4,Date[s(1126)]()),Math[s(1183)](e[s(1012)](1e4,Math[s(1128)]())))}function c(s){let t=n;return e[t(323)](e[t(1317)](Array,8).join("0"),parseInt(s,10)[t(1667)](2)).slice(-8)}function u(s){let t=n;return e[t(1479)](e.uxhPt(Array,4).join("0"),e[t(300)](parseInt,s,2).toString(16)).slice(-4)}function x(s){let t=n,r=s[t(1449)](/\./)[t(1543)](p=>c(p)),d=[];return d[0]=e.BtqwB(u,r[0]+r[1]),d[1]=e[t(904)](u,e[t(323)](r[2],r[3])),[e[t(1257)],e[t(1257)],t(546),e[t(1257)],e[t(1257)],e.ckXwA,d[0],d[1]][t(1687)]("")}function l(s){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(1180)](s),d=/(([0-9a-fA-F]{1,4}:){7,7}[0-9a-fA-F]{1,4}|([0-9a-fA-F]{1,4}:){1,7}:|([0-9a-fA-F]{1,4}:){1,6}:[0-9a-fA-F]{1,4}|([0-9a-fA-F]{1,4}:){1,5}(:[0-9a-fA-F]{1,4}){1,2}|([0-9a-fA-F]{1,4}:){1,4}(:[0-9a-fA-F]{1,4}){1,3}|([0-9a-fA-F]{1,4}:){1,3}(:[0-9a-fA-F]{1,4}){1,4}|([0-9a-fA-F]{1,4}:){1,2}(:[0-9a-fA-F]{1,4}){1,5}|[0-9a-fA-F]{1,4}:((:[0-9a-fA-F]{1,4}){1,6})|:((:[0-9a-fA-F]{1,4}){1,7}|:)|fe80:(:[0-9a-fA-F]{0,4}){0,4}%[0-9a-zA-Z]{1,}|::(ffff(:0{1,4}){0,1}:){0,1}((25[0-5]|(2[0-4]|1{0,1}[0-9]){0,1}[0-9])\.){3,3}(25[0-5]|(2[0-4]|1{0,1}[0-9]){0,1}[0-9])|([0-9a-fA-F]{1,4}:){1,4}:((25[0-5]|(2[0-4]|1{0,1}[0-9]){0,1}[0-9])\.){3,3}(25[0-5]|(2[0-4]|1{0,1}[0-9]){0,1}[0-9]))/[t(1180)](s);return r?e[t(904)](x,s):d?e[t(904)](g,s):e.EUDkz}function g(s){let t=n,r="",d=[],f=0,p=0,v=!0,y=e[t(1257)];if(s.indexOf("::")>-1){let h=s.split("::");for(let D=0;D<h[t(1241)];D++){let M=h[D];if(e.LmUPR(M.indexOf(":"),0)){let G=M[t(1449)](":");v&&(f=G[t(1241)]),p+=G[t(1241)];for(let H=0;H<G[t(1241)];H++)if(G[H][t(1241)]!==4){let xe=y.substring(0,e[t(1353)](4,G[H][t(1241)])),Pe=xe.concat(G[H]);d[t(383)](Pe)}else d[t(383)](G[H]);v=!1}else{if(e.hzJUd(4,M.length)){let G=y[t(1379)+"g"](0,e.IdFdn(4,M[t(1241)])),H=G[t(813)](M);d[t(383)](H)}else d[t(383)](M);v&&(f+=1),p+=1,v=!1}}let P="";for(let D=0;e[t(1113)](D,e.BuwFJ(8,p));D++)P=P[t(813)](y);for(let D=0;e[t(1203)](D,d[t(1241)]);D++)e.SgPqH(D,f)?e[t(1484)]===e[t(1484)]?(r=r[t(813)](P),r=r[t(813)](d[D])):(this[t(1454)+"er"]&&_0x38be06[t(775)+"entListener"](e[t(1381)],this[t(1463)+t(935)]),this[t(1454)+"er"]&&_0x531347[t(775)+"entListe"+t(1562)](e[t(342)],this[t(1463)+t(295)]),this[t(1454)+"er"]&&_0x4de855[t(775)+t(696)+t(1562)](e[t(702)],this["_handleP"+t(940)]),this._isBrowser&&_0x8e6be4[t(775)+t(696)+"ner"](e[t(1524)],this[t(1034)+t(444)])):r=r[t(813)](d[D]);return r}{let h=s[t(1449)](":");for(let P=0;e[t(1203)](P,h[t(1241)]);P++)if(e[t(1190)](e[t(1242)],e[t(1242)]))++_0x382ea9,_0x30a80b+=4;else{let D=h[P];if(e[t(1289)](4,h[P][t(1241)])){let M=y.substring(0,e[t(902)](4,h[P][t(1241)])),G=M.concat(D);r=r[t(813)](G)}else r=r[t(813)](D)}return r}}function E(s,t){let r=n,d=s[r(1377)];e[r(407)](void 0,d)&&(e[r(300)](ae,t,10),e[r(300)](me,t,d));let f=s[r(410)];e.TgkhI(void 0,f)&&(e[r(300)](ae,t,18),e[r(300)](me,t,f))}function w(s){let t=n,r={};e:for(;!e[t(631)](J,s);){let d=he(s);switch(e[t(919)](d,3)){case 0:break e;case 1:r[t(1377)]=ie(s,e[t(904)](he,s));break;case 2:r[t(410)]=e[t(300)](ie,s,e[t(453)](he,s));break;default:k(s,e[t(675)](7,d))}}if(r.key===void 0)throw new Error(e.ogsoR);if(e[t(246)](void 0,r[t(410)]))throw new Error(e[t(1556)]);return r}function A(s){let t=n,r=e[t(1047)](C);return _(s,r),e.rBDYm(z,r)}function _(s,t){let r=n,d={DdHZO:function(f,p){return e[K(1688)](f,p)},SjaVf:function(f,p){return e[K(844)](f,p)}};if(e.EBSJb(e.LMtNQ,e[r(690)])){let p=""+_0x1aeff4.now(),v=_0x5665a1||(_0x5ccb27=mpOjMV.DdHZO(_0x1a778d,_0x2f2f58)),y=_0x5ab88e.random()[r(1667)](16)[r(1483)](-6);return mpOjMV[r(1232)](mpOjMV.SjaVf("02"+p,v),y)}else{let f=s.SeqID;f!==void 0&&(e[r(300)](ae,t,8),e.iTyhh(se,t,f));let p=s[r(1107)];e[r(1442)](void 0,p)&&(e[r(300)](ae,t,16),se(t,p));let v=s.service;v!==void 0&&(e[r(300)](ae,t,24),se(t,e[r(631)](L,v)));let y=s[r(1108)];e[r(1190)](void 0,y)&&(e[r(1272)](ae,t,32),e[r(1160)](se,t,L(y)));let h=s[r(1512)];if(e[r(182)](void 0,h))for(let vt of h){e[r(217)](ae,t,42);let nt=e[r(1047)](C);E(vt,nt),e[r(1054)](ae,t,nt[r(1413)]),e[r(852)](Re,t,nt),e[r(1027)](R,nt)}let P=s[r(914)+r(348)];e[r(1342)](void 0,P)&&(e.HHsYe(ae,t,50),e.iTyhh(me,t,P));let D=s["payloadT"+r(600)];e.fqEHy(void 0,D)&&(e[r(1342)](e[r(1172)],e[r(1172)])?(_0x3cd3f6=e.kVonv,_0x2fa463=_0x341e8f.replace(/(^http)((?:[s]*:\/\/))/,""),_0x59bcd5=/(^ws)((?:[s]*:\/\/))/.test(_0x3354e1)?_0x5fbda9:""+_0x7ece7e+_0x1cf90e):(e.iTyhh(ae,t,58),e[r(300)](me,t,D)));let M=s[r(683)];e[r(1289)](void 0,M)&&(e[r(596)](ae,t,66),e[r(1574)](ae,t,M[r(1241)]),e[r(1072)](te,t,M));let G=s[r(330)];G!==void 0&&(ae(t,74),e[r(338)](me,t,G));let H=s["serverTi"+r(888)];H!==void 0&&(e[r(196)](ae,t,82),me(t,H));let xe=s[r(610)];e.hzJUd(void 0,xe)&&(ae(t,90),e.YrFgb(me,t,xe));let Pe=s[r(287)+"e"];Pe!==void 0&&(ae(t,96),se(t,e[r(242)](L,Pe)))}}function b(s){return e[n(631)](S,F(s))}function S(s){let t=n,r={};e:for(;!e[t(1696)](J,s);){let d=e.IXqTO(he,s);switch(d>>>3){case 0:break e;case 1:r[t(948)]=e[t(759)](Et,s,!0);break;case 2:r[t(1107)]=Et(s,!0);break;case 3:r[t(529)]=e.ZIEHl(he,s);break;case 4:r[t(1108)]=e[t(1345)](he,s);break;case 5:{let f=e.VILFT(I,s);(r[t(1512)]||(r[t(1512)]=[]))[t(383)](w(s)),s.limit=f;break}case 6:r[t(914)+"ncoding"]=ie(s,e.ttiiJ(he,s));break;case 7:r[t(916)+t(600)]=e[t(869)](ie,s,e[t(1546)](he,s));break;case 8:r.payload=e[t(1194)](j,s,e[t(631)](he,s));break;case 9:r.LogIDNew=e[t(430)](ie,s,he(s));break;case 10:r["serverTi"+t(888)]=ie(s,he(s));break;case 11:r[t(610)]=e[t(1574)](ie,s,e[t(1027)](he,s));break;case 12:r[t(287)+"e"]=e.NwhNh(he,s);break;default:e[t(451)](k,s,e[t(675)](7,d))}}if(e[t(246)](void 0,r.SeqID))throw new Error(t(345)+t(628)+t(712)+t(948));if(e.WCyyo(void 0,r[t(1107)]))throw new Error(e[t(1504)]);if(e[t(1593)](void 0,r[t(529)]))throw new Error(e[t(952)]);if(e[t(718)](void 0,r[t(1108)]))throw new Error(t(345)+t(628)+" field: "+t(1108));return r}function I(s){let t=n,r=he(s),d=s.limit;return s[t(1413)]=e.qvoVK(s[t(266)],r),d}function k(s,t){let r=n;switch(t){case 0:for(;e[r(760)](128,e[r(995)](we,s)););break;case 2:e.tzjOW($,s,e[r(1265)](he,s));break;case 5:$(s,4);break;case 1:e[r(1238)]($,s,8);break;default:throw new Error(e.qvoVK(r(506)+r(817)+r(1684),t))}}function L(s){return s|=0,{low:s,high:e.eunTl(s,31),unsigned:e.wcllh(s,0)}}let m=[];function C(){let s=n,t=m[s(1705)]();return t?(t[s(266)]=t.limit=0,t):{bytes:new Uint8Array(64),offset:0,limit:0}}function R(s){m[n(383)](s)}function F(s){return{bytes:s,offset:0,limit:s[n(1241)]}}function z(s){let t=n,r=s[t(219)],d=s[t(1413)];return e[t(1494)](r[t(1241)],d)?r:r[t(942)](0,d)}function $(s,t){let r=n;if(e[r(355)](e[r(606)](s[r(266)],t),s[r(1413)]))throw new Error(e[r(579)]);s[r(266)]+=t}function J(s){let t=n;return s[t(266)]>=s[t(1413)]}function N(s,t){let r=n,d=s[r(219)],f=s[r(266)],p=s.limit,v=e[r(1197)](f,t);if(v>d[r(1241)]){let y=new Uint8Array(e[r(1012)](2,v));y[r(695)](d),s[r(219)]=y}return s.offset=v,e.LmUPR(v,p)&&(s[r(1413)]=v),f}function B(s,t){let r=n,d=s[r(266)];if(e[r(1643)](d+t,s[r(1413)]))throw new Error(e[r(536)]);return s[r(266)]+=t,d}function j(s,t){let r=n,d=e.utNPa(B,s,t);return s.bytes[r(942)](d,e[r(821)](d,t))}function te(s,t){let r=n,d=e.ucjqb(N,s,t.length);s[r(219)][r(695)](t,d)}function ie(s,t){let r=n,d=e[r(196)](B,s,t),f=String[r(511)+"Code"],p=s[r(219)],v="\uFFFD",y="";for(let h=0;e[r(953)](h,t);h++){let P=p[e.iIvVy(h,d)],D,M,G,H;e.SgPqH(e[r(1261)](128,P),0)?y+=e[r(663)](f,P):e[r(718)](e.FCOqk(224,P),192)?e[r(1315)](e[r(1616)](h,1),t)?y+=v:(D=p[e[r(1197)](e.nAWyS(h,d),1)],e[r(1442)](e[r(629)](192,D),128)?y+=v:(H=e[r(1037)](e.sRdAc(31&P,6),e[r(894)](63,D)),e[r(589)](H,128)?y+=v:(y+=e[r(619)](f,H),h++))):e[r(650)](240&P,224)?e[r(1515)](h+2,t)?y+=v:(D=p[e[r(323)](e[r(320)](h,d),1)],M=p[e[r(1479)](e[r(1197)](h,d),2)],e[r(182)](e[r(1002)](e[r(1037)](D,M<<8),49344),32896)?y+=v:(H=e[r(818)](e[r(1373)](e[r(1095)](e.QppNY(15,P),12),e[r(1095)](e[r(766)](63,D),6)),e[r(558)](63,M)),H<2048||e.chzKt(H,55296)&&e[r(757)](H,57343)?y+=v:(y+=e[r(1317)](f,H),h+=2))):e.HFJjI(248,P)==240?e[r(588)](h,3)>=t?y+=v:(D=p[e[r(323)](h,d)+1],M=p[e[r(549)](e[r(323)](h,d),2)],G=p[e[r(770)](h,d)+3],e[r(182)](e[r(766)](e.Jqdvm(e[r(1323)](D,e[r(1095)](M,8)),e.IbQjb(G,16)),12632256),8421504)?y+=v:(H=e[r(1323)](e[r(1037)](e[r(1671)](7&P,18),e[r(1671)](e[r(502)](63,D),12)),e[r(406)](e[r(894)](63,M),6))|e[r(1002)](63,G),H<65536||e[r(872)](H,1114111)?y+=v:(H-=65536,y+=f(e.JcmuI(e[r(924)](H,10),55296),e[r(1542)](1023&H,56320)),h+=3))):y+=v}return y}function me(s,t){let r=n,d=t[r(1241)],f=0;for(let y=0;e[r(748)](y,d);y++){let h=t[r(961)+"At"](y);e[r(1315)](h,55296)&&e[r(808)](h,56319)&&e.fGiVg(e[r(1542)](y,1),d)&&(h=e[r(261)](e[r(409)](e[r(950)](h,10),t.charCodeAt(++y)),56613888)),f+=e.NdYXO(h,128)?1:h<2048?2:e[r(1185)](h,65536)?3:4}e[r(217)](ae,s,f);let p=e[r(891)](N,s,f),v=s[r(219)];for(let y=0;e[r(437)](y,d);y++){let h=t.charCodeAt(y);if(e.nybra(h,55296)&&e[r(304)](h,56319)&&e.ACkjx(e[r(320)](y,1),d)&&(h=e[r(1192)](e.TgWXU(e.IbQjb(h,10),t[r(961)+"At"](++y)),56613888)),e[r(1113)](h,128))v[p++]=h;else{if(e[r(1185)](h,2048))v[p++]=e.VjOyU(e[r(1679)](h,6),31)|192;else{if(e[r(1185)](h,65536))v[p++]=e.QppNY(e.BEpVr(h,12),15)|224;else if(e[r(1190)](e.LynBt,e[r(415)])){let P={ngJQY:e[r(881)]},D=_0x4b2071[r(1487)][r(1483)](_0x1c62f1.byteOffset,e[r(1197)](_0x1dd3ad[r(1125)+"th"],_0x5ab1b3[r(200)+"et"]));this[r(395)]&&this[r(395)][r(1457)]({data:D,fail:M=>{let G=r;this[G(1244)](P[G(671)],_0x345166(P[G(671)],{message:this[G(1620)+G(1216)+G(1493)](M)}))}})}else v[p++]=e[r(1373)](e[r(1624)](h>>18,7),240),v[p++]=e[r(1450)](h,12)&63|128;v[p++]=e.JFBQR(h>>6,63)|128}v[p++]=e.scHut(63&h,128)}}}function Re(s,t){let r=n,d=e.QhTbi(N,s,t[r(1413)]),f=s[r(219)],p=t[r(219)];for(let v=0,y=t.limit;e[r(1113)](v,y);v++)f[v+d]=p[v]}function we(s){let t=n;return s[t(219)][e[t(451)](B,s,1)]}function dt(s,t){let r=n,d=N(s,1);s[r(219)][d]=t}function he(s){let t=n,r=0,d=0,f;do{if(e[t(363)](e[t(833)],e[t(833)]))return e[t(1197)](e.NrzFQ(1e4,_0x5f23d6[t(1126)]()),_0x2ed793[t(1183)](e[t(1490)](1e4,_0x385b5a.random())));f=e[t(1675)](we,s),e.CcjYF(r,32)&&(d|=e[t(627)](e[t(716)](127,f),r)),r+=7}while(e[t(629)](128,f));return d}function ae(s,t){let r=n;for(t>>>=0;t>=128;)dt(s,e[r(1188)](e[r(441)](127,t),128)),t>>>=7;e[r(338)](dt,s,t)}function Et(s,t){let r=n,d={RKSVx:function(h,P){return e.OurSR(h,P)},psVqW:function(h,P){return e[K(1619)](h,P)}},f=0,p=0,v=0,y;if(y=e[r(764)](we,s),f=e[r(502)](127,y),e.SDXvK(128,y)&&(y=e[r(1696)](we,s),f|=e[r(714)](e[r(1100)](127,y),7),e[r(1624)](128,y)&&(y=e[r(1387)](we,s),f|=e[r(470)](e[r(1002)](127,y),14),e[r(1002)](128,y)&&(y=e[r(1582)](we,s),f|=e.SITrL(e.OtZSC(127,y),21),128&y&&(y=e[r(1096)](we,s),p=127&y,e[r(1221)](128,y)&&(y=e[r(391)](we,s),p|=e[r(286)](127&y,7),e[r(1261)](128,y)&&(y=e[r(1357)](we,s),p|=e[r(1671)](127&y,14),e.JFBQR(128,y)&&(y=e.YguEK(we,s),p|=e[r(950)](127&y,21),e.REyZE(128,y)&&(y=e.BtqwB(we,s),v=127&y,128&y)))))))))if(e[r(496)](e[r(1606)],e.kKHmJ))y=e.iLtkG(we,s),v|=e[r(1386)](e.lGkGH(127,y),7);else{let h=_0x4de612[r(1241)]&&_0x28fa95[0];if(h instanceof _0xbaeb3a)throw h;let P=new _0x3e29c6(d[r(273)](r(1527)+"d error.",h?d[r(413)](d[r(413)](" (",h[r(874)]),")"):""));throw P[r(570)]=h,h}return{low:e[r(1037)](f,e.bQqEa(p,28)),high:e.RbvLr(p>>>4,e.IbQjb(v,24)),unsigned:t}}function se(s,t){let r=n,d=e.kHlHI(t[r(459)],0),f=e[r(1612)](e[r(1090)](e.kHlHI(t.low,28),e[r(470)](t[r(1425)],4)),0),p=e[r(919)](t[r(1425)],24),v=p===0?f===0?e[r(762)](d,16384)?e[r(1689)](d,128)?1:2:e[r(318)](d,2097152)?3:4:e.xuEUo(f,16384)?e[r(1661)](f,128)?5:6:f<2097152?7:8:e[r(1508)](p,128)?9:10,y=e.tJXph(N,s,v),h=s[r(219)];switch(v){case 10:h[e[r(1097)](y,9)]=e[r(894)](e.YvpKZ(p,7),1);case 9:h[e[r(844)](y,8)]=e[r(420)](9,v)?e.IGTcD(128,p):e.VjOyU(127,p);case 8:h[y+7]=e[r(1442)](8,v)?e.dRHDI(e[r(489)](f,21),128):e[r(675)](f>>>21,127);case 7:h[e[r(1097)](y,6)]=e.tVQiz(7,v)?e[r(1404)](e.SzkEQ(f,14),128):e[r(868)](f>>>14,127);case 6:h[e[r(821)](y,5)]=e[r(420)](6,v)?e[r(791)](e.qwZZP(f,7),128):e[r(299)](e[r(403)](f,7),127);case 5:h[e[r(1375)](y,4)]=e.dvdeQ(5,v)?e[r(1404)](128,f):e.rWWWZ(127,f);case 4:h[y+3]=e[r(420)](4,v)?e.hMCBz(e[r(637)](d,21),128):e[r(1366)](d,21)&127;case 3:h[e[r(821)](y,2)]=e[r(319)](3,v)?e[r(909)](d>>>14,128):e.fkokM(d>>>14,127);case 2:h[y+1]=e[r(1436)](2,v)?e[r(483)](e.YvpKZ(d,7),128):e[r(826)](d,7)&127;case 1:h[y]=e[r(1052)](1,v)?e[r(1090)](128,d):e[r(540)](127,d)}}function kt(s){return e[n(995)](b,s)}function _e(s){return e[n(1036)](A,s)}let Rt=65536,ke=e.TXJBT,Nt=e[n(1081)](Rt,Rt),Cs=Nt*Nt,Ts=e.VTLWZ(Cs,2),ut=String[n(533)+"e"][n(961)+"At"];class ne{constructor(t,r,d){let f=n;this[f(368)]=!0,this[f(459)]=e[f(208)](0,t),this[f(1425)]=0|r,this[f(1294)]=!!d}static[n(368)](t){let r=n;return t&&e[r(643)](!0,t[r(368)])}static[n(545)](t,r,d){return new ne(t,r,d)}static fromBytes(t,r,d){let f=n;if(e[f(772)]!=="RjNga")return d?ne[f(312)+f(1250)](t,r):ne[f(312)+f(788)](t,r);this.on(_0x5c2fab,_0x4abc49)}static[n(312)+n(1250)](t,r){let d=n;return new ne(e[d(938)](e.dcRKK(t[0],e[d(587)](t[1],8)),e.yPgHy(t[2],16))|t[3]<<24,e[d(1555)](e[d(1599)](e.IPEmC(t[4],e.Brpaf(t[5],8)),e[d(776)](t[6],16)),e[d(644)](t[7],24)),r)}static[n(312)+"sBE"](t,r){let d=n;return new ne(e[d(190)](e[d(1651)](e.yTztw(t[4],24)|e[d(1031)](t[5],16),t[6]<<8),t[7]),e[d(1404)](e[d(557)](t[0],24),e[d(1296)](t[1],16))|e[d(697)](t[2],8)|t[3],r)}static[n(850)](t){let r=n;return e[r(246)](t,ke)?Ds:new ne(e.qwZZP(e[r(381)](ut.call(t,0)|e[r(1245)](ut[r(677)](t,1),8),e[r(1434)](ut[r(677)](t,2),16))|e[r(575)](ut[r(677)](t,3),24),0),e.cssFE(e[r(1431)](e[r(380)](ut[r(677)](t,4)|e[r(1693)](ut[r(677)](t,5),8),ut[r(677)](t,6)<<16),e.Foqdm(ut[r(677)](t,7),24)),0),!0)}[n(1068)](){let t=n;return String[t(511)+t(1267)](e[t(299)](255,this[t(459)]),e.PWOFw(e[t(1612)](this[t(459)],8),255),e.GagHD(e[t(489)](this[t(459)],16),255),e.utYYr(this[t(459)],24),e[t(1338)](255,this[t(1425)]),e[t(397)](e[t(913)](this[t(1425)],8),255),e[t(1002)](e[t(826)](this[t(1425)],16),255),e[t(1612)](this.high,24))}static[n(1006)+"er"](t,r=!0){let d=n,f={rKfAE:function(p,v){return e[K(812)](p,v)},yJsHg:function(p){return p()}};if(e.dHaqs(isNaN,t))return r?rd:Ds;if(r){if(e.QHkXq(t,Cs))return sd}else if(e[d(1664)](e[d(1269)],e[d(559)])){if(e[d(1322)](t,-Ts))return od;if(e[d(905)](t+1,Ts))return id}else XuUjUw.rKfAE(_0x3467d8,_0x3ea646(_0x129af0[d(800)])),XuUjUw[d(245)](_0x6e00ff);return ne[d(545)](e[d(388)](t%Nt,0),e.FozXF(e[d(895)](t,Nt),0),r)}[n(1452)](){let t=n;return this[t(1294)]?e[t(505)](e.smTtf(e.brUrv(this.high,0),Nt),this[t(459)]>>>0):e[t(1591)](e[t(1118)](this[t(1425)],Nt),e[t(701)](this[t(459)],0))}[n(1106)](){let t=n;return e[t(1494)](0,this[t(1425)])&&e.NgJvF(0,this[t(459)])}add(t){let r=n;if(e[r(1685)](e[r(1617)],e[r(1697)])){ne.isLong(t)||(t=ne[r(1006)+"er"](t));let d=e.QQnAN(this[r(1425)],16),f=e.IqNaG(65535,this[r(1425)]),p=e[r(826)](this[r(459)],16),v=e[r(629)](65535,this.low),y=e[r(403)](t.high,16),h=65535&t[r(1425)],P=e[r(403)](t.low,16),D=65535&t[r(459)],M=0,G=0,H=0,xe=0;return xe+=e[r(1097)](v,D),H+=xe>>>16,xe&=65535,H+=e[r(409)](p,P),G+=H>>>16,H&=65535,G+=e.ZzsSr(f,h),M+=G>>>16,G&=65535,M+=e[r(1619)](d,y),M&=65535,ne[r(545)](e[r(1422)](e[r(887)](H,16),xe),M<<16|G,this.unsigned)}else _0x3fdc26 instanceof _0x527c46&&_0x2a8897.set(_0x134503,_0x423a7a)}[n(1030)](t){let r=n;return ne[r(368)](t)||(t=ne.fromNumber(t)),e.YqpTe(this[r(1294)],t[r(1294)])&&e[r(1285)](this.high,31)===1&&e[r(1593)](e[r(473)](t[r(1425)],31),1)?!1:this[r(1425)]===t[r(1425)]&&this[r(459)]===t[r(459)]}[n(1324)](){let t=n;if(e[t(1186)](e.DKkRz,e[t(1075)]))return e[t(745)](-1,this[t(459)])&&this.high===-1?ne[t(545)](0,0,this[t(1294)]):this[t(459)]===-1?ne[t(545)](0,e[t(505)](this.high,1),this.unsigned):ne.fromBits(e.JcmuI(this[t(459)],1),this[t(1425)],this[t(1294)]);this[t(1029)+t(1686)]=_0x488187,this[t(984)]=0}[n(547)](t){let r=n;return e[r(754)](e[r(934)],e[r(390)])?pzzgXL[r(1096)](_0x4ca317,_0x4fa0a7[r(1623)](_0x5ed173(this),_0x2763ed)):t?this.toBytesLE():this[r(1662)+"E"]()}[n(578)+"E"](){let t=n;if(e[t(643)](e[t(1435)],e[t(1435)])){let r=this[t(1425)],d=this.low;return[255&d,e[t(1607)](d>>>8,255),d>>>16&255,d>>>24,e[t(1261)](255,r),e[t(716)](e.BtQOP(r,8),255),e[t(1547)](e[t(725)](r,16),255),e.yJpjq(r,24)]}else!_0x20f2d4[t(873)+"d"]&&(this[t(1454)+"er"]&&_0x39c48d[t(775)+t(696)+t(1562)](t(1499),this[t(1034)+t(940)]),this[t(1454)+"er"]&&_0x2c3692[t(775)+t(696)+t(1562)](e[t(1524)],this["_handleP"+t(444)]),this[t(526)]()),this._isBrowser&&_0x238f1a[t(775)+"entListener"](e[t(1381)],this[t(1463)+t(935)]),this[t(1454)+"er"]&&_0x37bea5[t(775)+t(696)+"ner"](e[t(342)],this[t(1463)+t(295)])}[n(1662)+"E"](){let t=n,r=this.high,d=this[t(459)];return[r>>>24,e.hpaJT(r>>>16,255),e[t(760)](r>>>8,255),255&r,e[t(826)](d,24),e[t(1261)](e[t(919)](d,16),255),e[t(716)](d>>>8,255),e[t(236)](255,d)]}}let Ds=new ne(0,0,!1),rd=new ne(0,0,!0),id=ne.fromBits(-1,2147483647,!1),sd=ne.fromBits(-1,-1,!0),od=ne[n(545)](0,-2147483648,!1);var ft=(function(s){let t=n,r=e.aIIUw.split("|"),d=0;for(;;){switch(r[d++]){case"0":return s;case"1":s[s[e[t(994)]]=5001]=t(767)+t(1282);continue;case"2":s[s[t(1580)+"OR"]=5005]=t(1580)+"OR";continue;case"3":s[s[e[t(1394)]]=5003]=e[t(1394)];continue;case"4":s[s[e[t(307)]]=5004]=e.vTKnj;continue;case"5":s[s[e.BDKCN]=5002]=e.BDKCN;continue}break}})({});class Lt{constructor(t){let r=n;this[r(622)]=t,this[r(1505)]=null}}class Ps extends Lt{constructor(t,r){let d=n;super(t),this[d(874)]=r&&r[d(874)]||null}}class ks extends Lt{constructor(t,r){let d=n;if(e[d(496)](e[d(1501)],e[d(1501)]))return _0x5c6478||(_0x3c09ce=[_0x43e67a[d(533)+"e"].advance,_0x1c1c70[d(533)+"e"][d(1506)],_0x2e1aa1.prototype.continuePrimaryKey]);{let f=(d(1193)+d(777))[d(1449)]("|"),p=0;for(;;){switch(f[p++]){case"0":this[d(602)]=r&&r.code||5001;continue;case"1":this[d(1020)]=r&&r[d(1020)]||0;continue;case"2":this.message=r&&r[d(874)]||"";continue;case"3":this[d(335)]=r&&r[d(335)]||0;continue;case"4":this[d(856)]=r&&r[d(856)]||null;continue;case"5":this[d(717)]=r&&r[d(717)]||"";continue;case"6":super(t);continue}break}}}}class Rs extends Lt{constructor(t,r){let d=n;if(e[d(1342)](e[d(544)],d(1144))){let f=e[d(408)].split("|"),p=0;for(;;){switch(f[p++]){case"0":this.code=r&&r[d(602)]||0;continue;case"1":this[d(1539)]=r&&r[d(1539)]||"";continue;case"2":super(t);continue;case"3":this[d(1280)+"nnect"]=r&&r[d(1280)+d(534)]||!1;continue;case"4":this[d(1585)]=r&&r[d(1585)]||!1;continue}break}}else _0x25e9a2[d(550)+"jectStore"](_0x142491,{keyPath:_0x229adb})}}class Ns extends Lt{constructor(t,r){let d=n;super(t),this[d(224)]=r&&r[d(224)]||null}}class Ls extends Ns{constructor(t,r){let d=n;super(t),this[d(224)]=r&&r[d(224)]||null,this.message=r&&r[d(874)]||null}}class Os extends Lt{constructor(t,r){let d=n;super(t),this[d(224)]=r&&r.data||null}}function Me(s,{message:t,code:r,error:d}){return new ks(s,{message:t,code:r,error:d})}function Ue(s,{code:t,reason:r,wasClean:d,willReconnect:f}){return new Rs(s,{code:t,reason:r,wasClean:d,willReconnect:f})}function Ms(s,{data:t,message:r}){return new Ls(s,{data:t,message:r})}function Bs(s,{data:t}){return new Os(s,{data:t})}function ni(s,{message:t}){return new Ps(s,{message:t})}class zs{constructor(t,r){let d=n;e.TgkhI(e[d(763)],e[d(763)])?this["flushExp"+d(1652)]():(this[d(233)+"s"]=t,this[d(1248)+"es"]=r,this["currentI"+d(503)]=0,this["currentE"+d(364)+"riesCount"]=0)}[n(801)+n(184)+n(276)](){let t=n;this[t(719)+t(503)]=0,this[t(1564)+t(364)+t(1049)+"t"]=0}[n(1370)+"es"](){let t=n;this[t(1564)+t(364)+t(1049)+"t"]=0}[n(389)+n(1578)+"nt"](){let t=n;if(e[t(718)](e.JCRhK,e[t(461)]))return this[t(233)+"s"][this[t(719)+t(503)]];this._intervalFlush()}[n(389)+n(1578)+n(187)+n(1686)](){let t=n;return e[t(1593)](e[t(386)],e.oHaWk)?e[t(809)](_0x1426aa,_0x497c9f)?_0xd8534c:new _0x4d2963(e[t(1703)](e[t(1373)](e[t(1601)](_0x25020e[t(677)](_0x4d3131,0),e[t(1064)](_0x359ae5.call(_0x15feda,1),8)),e.cSyIl(_0x453485[t(677)](_0x43f70a,2),16))|e[t(644)](_0x1affd3.call(_0x39de3e,3),24),0),e[t(198)](e[t(448)](e[t(1404)](_0x2a6a98[t(677)](_0x3c3d1c,4)|_0x44c8ef[t(677)](_0xc1c60d,5)<<8,e[t(1286)](_0x5b5bdb[t(677)](_0x572445,6),16)),e[t(1545)](_0x5665ab[t(677)](_0x5ea3dc,7),24)),0),!0):this["currentE"+t(364)+"riesCount"]}["checkRea"+n(1336)+"es"](){let t=n,r={thZkT:function(d,f){return e[K(860)](d,f)},ZUnGl:"string",Okgfy:function(d,f,p,v){return d(f,p,v)},gwnBG:function(d,f){return e[K(1642)](d,f)}};if(e[t(882)](e[t(1092)],t(1650)))return!!(e[t(905)](this[t(719)+"ndex"],this.endpoints[t(1241)])||this[t(719)+t(503)]===e[t(1192)](this[t(233)+"s"][t(1241)],1)&&e[t(1494)](this[t(1564)+t(364)+t(1049)+"t"],this[t(1248)+"es"]));if(r[t(769)](r[t(508)],typeof _0x4a945e)){let d=new _0x21b6d7(_0x204832(_0x2a0715));return r.Okgfy(_0x12d6c2,_0x3093dd,d,0),d}return r[t(835)](_0x19b571,_0x5c6f91)?new _0x198da7(_0x4223d5):new _0x2e7ed5(_0x29e23b[t(1487)],_0x3933f1[t(200)+"et"],_0x569829[t(1125)+"th"])}[n(1204)+n(1246)+n(1453)+n(518)+"tries"](){let t=n;return e[t(860)](this[t(719)+t(503)],this[t(233)+"s"][t(1241)])?!0:e[t(554)](this[t(1564)+t(364)+t(1049)+"t"],this[t(1248)+"es"])}["replaceB"+n(1385)+n(452)+n(1649)+n(925)](){let t=n,r={igXbr:function(d,f){return e[K(423)](d,f)}};if(e.dYdko(e.uXXHi,"pMZda"))return this["currentE"+t(364)+t(1049)+"t"]=1,this[t(719)+t(503)]++,this.endpoints[this[t(719)+t(503)]];{let d=this._qosDB[t(819)+t(879)](this._prefix);return _0x11f5a3[t(1498)](r[t(624)](d,"{}"))[_0x341397]}}[n(389)+"ntEndpoi"+n(305)+n(401)](){let t=n;return e[t(1048)](t(244),t(244))?(this[t(1564)+t(364)+t(1049)+"t"]++,this[t(389)+t(1578)+"nt"]()):(_0x26fc2e+=_0x4ac6c4&&_0xe33b0f[t(1125)+"th"]||0,_0x17bb34)}}let Ot=(e[n(487)](n(743)+"d",typeof globalThis)&&e[n(1553)](e.PwhkL,globalThis[n(993)+n(1022)].name)||e.DRDvZ(n(743)+"d",typeof window)&&e[n(356)]===window[n(993)+"tor"][n(510)])&&e.vqWtp(n(743)+"d",typeof document),bt=e.oisIp(e[n(908)],typeof globalThis)&&(e[n(1103)]===globalThis[n(993)+n(1022)][n(510)]||e[n(1640)]===globalThis[n(993)+n(1022)][n(510)])&&e[n(908)]!=typeof tt,cn=(e[n(949)](n(743)+"d",typeof globalThis)&&e[n(1360)](e[n(1103)],globalThis["construc"+n(1022)][n(510)])||e.MXGgp(e[n(908)],typeof globalThis)||e[n(487)](e.ACbNl,typeof globalThis)&&!!globalThis[n(528)+n(1152)])&&e[n(1191)](e[n(908)],typeof wx),dn=e[n(949)](e[n(908)],typeof globalThis)&&(n(951)+n(954)+n(565)+"pe"===globalThis[n(993)+n(1022)][n(510)]||e[n(809)](e.MMpQn,globalThis[n(993)+n(1022)][n(510)])||n(1151)+"orkerGlo"+n(438)===globalThis[n(993)+n(1022)].name)&&e[n(949)](n(743)+"d",typeof self),ad=e[n(584)](e[n(908)],typeof globalThis)&&e[n(1229)](e.mflxv,globalThis[n(993)+n(1022)][n(510)])&&e.DDYcp(n(743)+"d",typeof global)&&e[n(1103)]===global["construc"+n(1022)][n(510)]&&e[n(1447)](e[n(908)],typeof process)&&!!process[n(1592)];class ri{constructor(){let t=n;e[t(1575)](e[t(360)],e[t(360)])?this._listeners={}:(this[t(1244)](e[t(581)],_0x5e4f05),this[t(1061)+"eAck"]&&this["onReceiv"+t(1111)](_0x17eeee))}emit(t,...r){let d=n,f=this[d(1304)+"rs"][t];if(f)f.slice()[d(378)](p=>p.fn[d(1623)](p[d(1070)],r));else if(d(856)===t&&!this[d(1690)])if(e.SgPqH(e[d(282)],e.PWsKu))pzzgXL.oisIp(pzzgXL[d(908)],typeof _0x348408)&&_0x444604["toString"+d(432)]&&_0x409706[d(704)+d(708)](_0x1aa01b,_0x263696[d(1667)+d(432)],{value:d(970)}),_0x56b61f[d(704)+d(708)](_0x1937d2,pzzgXL[d(789)],{value:!0});else{let p=r.length&&r[0];if(e.FaiZd(p,Error))throw p;let v=new Error(e[d(989)](e[d(686)],p?e.RSLNa(" (",p[d(874)])+")":""));throw v[d(570)]=p,p}return this}off(t,r){let d=n;if(e.QDgfY(void 0,t))this[d(1304)+"rs"]={};else if(r===void 0)this[d(1304)+"rs"][t]=null;else if(e[d(811)](e[d(1362)],e[d(1362)]))_0x155156[d(352)+d(1161)]="",_0x1fe548[d(990)](_0xdc2231);else{let f=this._listeners[t];if(f)for(let p=0;e[d(1146)](p,f[d(1241)]);)e[d(1016)](f[p].fn,r)?f.splice(p,1):++p}return this}on(t,r,d){let f=n;if(e[f(1140)](e[f(875)],e.wadpD)){let p=e[f(735)](255,_0x47ff55);e.WUUgS(_0x16db93,p,_0x469078,e.NQahX(_0x335bc6,_0x1e4cb3)),_0x7949c8>>>=8,_0x395fc9--}else return(this._listeners[t]||(this[f(1304)+"rs"][t]=[]))[f(383)]({fn:r,ctx:d||this}),this}}class cd extends ri{[n(1620)+"rrorMess"+n(1493)](t){let r=n;return t[r(1417)]||t[r(1051)]?(r(837)+" "+(t[r(1417)]||"")+" code: "+(t.errNo||""))[r(1367)]():JSON.stringify(t)}constructor(t,r,d){let f=n;super(),this[f(395)]=null,cn&&wx[f(1420)+f(454)]&&(this[f(395)]=wx[f(1420)+f(454)]({url:t,protocols:r,header:d,fail:this["_createS"+f(1473)+f(1584)][f(1641)](this),success:this[f(183)+f(1307)+f(1636)+f(820)].bind(this)})),bt&&tt[f(1420)+f(454)]&&(this[f(395)]=tt["connectS"+f(454)]({url:t,protocols:r,header:d,fail:this[f(183)+"ocketFailHandler"][f(1641)](this),success:this[f(183)+"ocketSuc"+f(1636)+"ler"].bind(this)}))}[n(183)+n(1307)+n(1636)+n(820)](){let t=n;Promise[t(1206)]()[t(1099)](()=>{let r=t;this[r(249)+r(301)]()})}["_createS"+n(1473)+n(1584)](t){let r=n;if(e[r(1260)](e[r(251)],e.PFrAg))Promise.resolve()[r(1099)](()=>{let d=r,f=Me(e[d(881)],{message:this[d(1620)+"rrorMess"+d(1493)](t)});this[d(1244)](e.pduzb,f);let p=e[d(1238)](Ue,e.dTVjI,{reason:this[d(1620)+"rrorMess"+d(1493)](t)});this[d(1244)](e.dTVjI,p)});else return this["_endpoin"+r(1226)]?.[r(389)+r(1578)+"ntTriesC"+r(1686)]()||0}[n(249)+n(301)](){let t=n,r={nOMuw:"error",IJjBE:function(d,f,p){return e[K(1399)](d,f,p)}};this[t(395)][t(1666)](d=>{let f=t;this.emit(e.IDtzY,Bs(f(367),{...d,data:d[f(1417)]||""}))}),this[t(395)].onClose(d=>{let f=t,p={XDAOw:function(v,y){return e[K(619)](v,y)}};e[f(1360)](e.OZWQg,e[f(290)])?(p[f(1459)](_0x3a84bb,this[f(1529)+f(1371)+"Id"]),p[f(1459)](_0x3a9062,this[f(1147)+f(188)+"tId"]),this[f(1529)+f(1371)+"Id"]=null,this["_reconnectTimeou"+f(1318)]=null):this[f(1244)](e[f(262)],e[f(664)](Ue,f(526),{...d}))}),this[t(395)][t(1563)+"e"](d=>{let f=t;this[f(1244)](e.KulVU,Ms(e[f(1376)],{...d}))}),this[t(395)].onError(d=>{let f=t;this[f(1244)](r[f(474)],r.IJjBE(Me,f(856),{...d,message:d[f(1417)]||""}))})}send(t){let r=n,d={rWQFD:e.pduzb,FuEAM:function(f,p,v){return e[K(963)](f,p,v)}};if(e[r(1642)](t,Uint8Array)){let f=t.buffer[r(1483)](t[r(200)+"et"],e.CPZbT(t[r(1125)+"th"],t[r(200)+"et"]));this[r(395)]&&this[r(395)].send({data:f,fail:p=>{let v=r;this[v(1244)](e[v(881)],e[v(1549)](Me,e[v(881)],{message:this[v(1620)+"rrorMessage"](p)}))}})}else this[r(395)]&&this[r(395)].send({data:t,fail:f=>{let p=r;this.emit(d[p(1132)],d[p(1088)](Me,p(856),{message:this[p(1620)+p(1216)+p(1493)](f)}))}})}[n(526)](t,r){let d=n;this._socket&&this._socket[d(526)]({code:t,reason:r})}[n(524)+n(203)](t,r){this.on(t,r)}[n(775)+n(696)+n(1562)](t,r){this[n(267)](t,r)}get readyState(){let t=n;return this[t(395)][t(1301)+"te"]}get[n(297)+"pe"](){let t=n;return e[t(1541)](e.jkznA,"rdGAz")?this[t(395)][t(297)+"pe"]:new _0x51e956(_0x5a6522,{data:_0x18451a,message:_0x166cae})}set[n(297)+"pe"](t){}get url(){let t=n;return this[t(395)][t(886)]}get[n(1608)](){let t=n;return this[t(395)][t(1608)]}get[n(1673)+"ns"](){let t=n;return this[t(395)][t(1673)+"ns"]}get["buffered"+n(211)](){let t=n;if(e[t(1016)]("NYHHu",e[t(828)]))return 0;this[t(1454)+"er"]&&_0x1a918e[t(775)+t(696)+"ner"]("pagehide",this["_handleP"+t(940)]),this[t(1454)+"er"]&&_0xa1144f[t(775)+"entListe"+t(1562)](e[t(1524)],this[t(1034)+t(444)]),this[t(526)]()}}function dd(s,t){let r=n;if(t)return new t(s[r(886)],s[r(1608)]);if(e[r(423)](cn,bt))return new cd(s[r(886)],s.protocol,s[r(1512)]);if((Ot||dn)&&e.ACbNl!=typeof WebSocket&&WebSocket)return new WebSocket(s[r(886)],s[r(1608)+"s"])}function ud(s){let t=n;return!!(s||cn&&wx["connectS"+t(454)]||bt&&tt[t(1420)+t(454)]||e[t(423)](Ot,dn)&&e[t(1139)](e.ACbNl,typeof WebSocket)&&WebSocket)}function Fs(s,t,r){let d=n,f=-1;async function p(v){let y=K;return e[y(740)](v,f)?Promise[y(1211)](new Error(y(742)+y(972)+y(758)+y(1466)+"process")):(f=v,e[y(745)](v,r[y(1241)])?Promise[y(1206)]():r[v][y(1641)](s)(t,p[y(1641)](null,e[y(1552)](v,1))))}e[d(1243)](p,0)}function Us(s){let t=n,r=0,d=0;for(let f=0;f<s[t(1241)];++f)d=s.charCodeAt(f),e.HjJrD(d,128)?r+=1:e[t(1661)](d,2048)?r+=2:e[t(1575)](e[t(621)](64512,d),55296)&&e[t(548)](e.fkokM(64512,s[t(961)+"At"](f+1)),56320)?(++f,r+=4):r+=3;return r}function qs(s,t,r){let d=n;if(e[d(967)](e.mZjyZ(r,t),1))return"";let f="";for(let p=t;e[d(1252)](p,r);){let v=s[p++];if(v<=127)f+=String["fromChar"+d(1267)](v);else if(e[d(204)](v,192)&&e[d(1252)](v,224))f+=String[d(511)+d(1267)](e[d(1164)]((31&v)<<6,e.VjOyU(63,s[p++])));else if(e.YAfpQ(v,224)&&v<240)f+=String[d(511)+d(1267)](e.IPEmC(e[d(1374)]((15&v)<<12,e[d(733)](63&s[p++],6)),e[d(426)](63,s[p++])));else if(e[d(1315)](v,240)){let y=e[d(734)](e[d(1456)](e[d(1710)](e[d(1066)](e[d(1386)](e.wSloB(7,v),18),e[d(776)](e[d(1002)](63,s[p++]),12)),e[d(1701)](e[d(781)](63,s[p++]),6)),e.FCOqk(63,s[p++])),65536);f+=String["fromChar"+d(1267)](e.nZAos(55296,e.OdoVi(y,10))),f+=String[d(511)+d(1267)](e[d(839)](56320,1023&y))}}return f}function ii(s,t,r){let d=n,f=r,p,v;for(let h=0;e[d(658)](h,s.length);++h)if(e[d(1442)](d(1143),e.LLGMQ))for(var y in _0x2d9d83)pzzgXL[d(314)](_0x12d4a1,_0x6f2f04,y,{get:_0x239daa[y],enumerable:!0});else p=s.charCodeAt(h),e.fGiVg(p,128)?t[r++]=p:e[d(589)](p,2048)?(t[r++]=e.SAwha(e[d(924)](p,6),192),t[r++]=e[d(1066)](e.xmvIJ(63,p),128)):e[d(1593)](e.SDXvK(64512,p),55296)&&e[d(760)](64512,v=s[d(961)+"At"](e.NQahX(h,1)))===56320?(p=e.renQe(e[d(871)](65536,e.REyZE(1023,p)<<10),e[d(1538)](1023,v)),++h,t[r++]=e[d(255)](p>>18,240),t[r++]=e[d(414)](e[d(1207)](e[d(285)](p,12),63),128),t[r++]=e[d(1221)](e.BEpVr(p,6),63)|128,t[r++]=e.BdSbt(e[d(502)](63,p),128)):(t[r++]=e[d(1569)](p,12)|224,t[r++]=e.HEufC(e[d(441)](e.jDxUS(p,6),63),128),t[r++]=e[d(429)](e[d(1058)](63,p),128));return r-f}async function Hs(s){let t=n;if(e.rqxKS(e[t(280)],typeof s))if(e.IbyLg===t(1290)){let r=new Uint8Array(Us(s));return e.WUUgS(ii,s,r,0),r}else{let r=_0x124783(t(856),{message:_0x58b8c8[t(874)],code:_0x36d271[t(1239)+t(680)],error:_0x3410c9});this[t(1429)+"hErrorEv"+t(715)](r)}return e[t(732)](s,ArrayBuffer)?new Uint8Array(s):new Uint8Array(s.buffer,s.byteOffset,s.byteLength)}function fd(s){let t=n;try{return e[t(1139)](e[t(280)],typeof s)&&(s instanceof ArrayBuffer||s[t(1487)]&&e[t(582)](s[t(1487)],ArrayBuffer))||e.oisIp(e.mqblF,typeof s)?"":(JSON[t(1498)](s),e[t(1268)])}catch{return e.zfUmT("string",typeof s)?e[t(1446)]:""}}let xd=(s,t)=>{let r=n;if(e[r(649)](e[r(1222)],e[r(1658)]))return(fe[r(1304)+"rs"][_0x44f004]||(fe._listeners[_0x6a24ba]=[]))[r(383)]({fn:_0x206ba4,ctx:_0x191a09||fe}),fe;switch(s){case e[r(427)]:case e[r(1392)]:return{[r(1133)+s]:1,"x-tt-env":t};default:return{}}};class ld{constructor(t){let r=n;this[r(1029)+r(1686)]=t,this[r(984)]=0}addCount(){let t=n;this[t(984)]++}[n(618)+n(1611)+"nt"](){let t=n;return e.YAfpQ(this.count,this[t(1029)+t(1686)])}[n(866)+"nter"](t=0){let r=n;this[r(1029)+"ount"]=t,this.count=0}}async function gd(s){let t=n,r={IteRd:e[t(1405)],vuwrH:function(d,f){return e[t(688)](d,f)},uNvlQ:e[t(838)],rcNEW:function(d,f){return e[t(962)](d,f)},YnMUL:t(1485),DVJzB:e[t(1355)],dyPBl:function(d,f){return e[t(1615)](d,f)}};return new Promise(d=>{let f=t;if(e.QkyrF===f(1523))return this._qosDB[f(1438)+f(1109)]();if(!Ot)return e[f(764)](d,e[f(568)]);try{let p=document[f(815)+"ement"](f(1057));window["frontier"+f(1059)]=v=>{let y=f,h={wDtgw:y(1695),mZrbY:r[y(968)],EntYq:function(P,D){return r[y(1220)](P,D)},JXyBE:r[y(341)],nvqGV:function(P){return P()}};if(r[y(466)](r.YnMUL,r[y(476)])){let P={QxMvT:function(H){let xe=y;return ZRpqjC[xe(235)](H)}},D=()=>{let H=y;_0x487a15[H(775)+H(696)+H(1562)](ZRpqjC.wDtgw,M),_0x1743b3[H(775)+H(696)+H(1562)](H(856),G),_0x23b0f9["removeEv"+H(696)+H(1562)](ZRpqjC.mZrbY,G)},M=()=>{let H=y;P[H(804)](_0x26b391),P[H(804)](D)},G=()=>{let H=y;ZRpqjC[H(593)](_0xf665b4,_0x5650fd[H(856)]||new _0x3b6e8d(ZRpqjC[H(465)],ZRpqjC[H(465)])),D()};_0x5d355a[y(524)+y(203)](y(1695),M),_0x3dbe5e[y(524)+y(203)](y(856),G),_0x23949c[y(524)+y(203)](ZRpqjC[y(1205)],G)}else document[y(1397)][y(599)+y(543)](p),window["frontier"+y(1059)]=void 0,r[y(205)](d,v&&v[y(1258)]||y(1228)+y(1539))},p.type=f(1609)+f(271),p[f(1071)]=s[f(832)](/^ws/,"http")+(f(539)+"ack=fron"+f(1402)+"P");try{document.body[f(1201)+f(543)](p)}catch{document[f(1397)][f(599)+"ild"](p)}}catch{window[f(180)+"JSONP"]=void 0,e[f(663)](d,e[f(568)])}})}function xt(s,t,r){let d=n;return e[d(749)](d(1502),e.MIGsC)?_0x37290e[d(768)+d(642)]||_0x5122c0[d(592)](_0x3a9af2):!!s?.[d(223)](f=>f[d(1377)]===t&&f[d(410)]===r)}function Mt(s,t){let r=n;return s?.[r(223)](d=>d[r(1377)]===t)?.[r(410)]}let si=null;async function hd(){let s=n;return si||(si=Promise[s(1206)]()[s(1099)](Ye[s(1641)](Ye,e[s(590)]))),si}class pd extends ri{constructor(t,r){let d=n;super(),this._dbName=t,this._keyPath=r,this[d(281)]=void 0,this[d(1069)+d(327)]=null}async[n(981)](){await this[n(1332)]()}async _init(){let t=n,r={XJecj:function(d){return e[K(1364)](d)},NySou:function(d,f,p,v){return e[K(314)](d,f,p,v)}};if(e[t(809)](e.keUdP,e[t(1326)])){if(this[t(281)])return;if(this[t(1069)+"mise"])return this[t(1069)+t(327)];try{let d=this._dbName,f=this[t(1372)];this._initPromise=(async()=>{let p=t,{openDB:v}=await r[p(1470)](hd);this[p(281)]=await r[p(358)](v,p(180)+"_"+d,1,{upgrade(y){let h=p;y[h(550)+h(278)+"e"](d,{keyPath:f})}})})(),await this[t(1069)+t(327)]}catch(d){console[t(990)](d)}finally{this._initPromise=null}}else e[t(1317)](_0x53927c,this[t(1025)+t(728)+"Id"]),this["_interva"+t(728)+"Id"]=e[t(1054)](_0x3d9e32,()=>{let d=t;this[d(1043)+d(1652)]()},this[t(1025)+"l"])}async[n(592)](t){let r=n;try{return await this._init(),this[r(281)]?.[r(592)](this._dbName,t)}catch(d){console.log(d)}}async[n(695)](t,r){let d=n;return await this[d(1332)](),this._qosDB?.[d(1400)](this[d(442)],t)}async del(t){let r=n;try{return await this._init(),this[r(281)]?.[r(1633)](this[r(442)],t)}catch(d){console[r(990)](d)}}async[n(359)](){let t=n;try{return await this[t(1332)](),this[t(281)]?.[t(359)](this[t(442)])}catch(r){console[t(990)](r)}}async[n(1300)](){let t=n;if(e[t(1260)](e[t(1042)],e[t(1042)]))return await this._init(),this[t(281)]?.[t(842)+"ys"](this[t(442)]);if(e[t(1076)](void 0,_0x3274d4))this[t(1304)+"rs"]={};else if(_0x2895fd===void 0)this[t(1304)+"rs"][_0x3f5cb1]=null;else{let r=this[t(1304)+"rs"][_0x15153f];if(r)for(let d=0;e[t(967)](d,r[t(1241)]);)r[d].fn===_0x26d526?r[t(975)](d,1):++d}return this}async[n(1576)](){return await this._init(),this._qosDB?.getAll(this._dbName)}async[n(349)](){let t=n;if(e[t(1078)](t(329),e[t(1284)]))this[t(490)+"ype"]=_0x26af23,this[t(532)]&&(this[t(532)][t(297)+"pe"]=_0x295922);else try{if(e.Auuxx(e[t(467)],e[t(1551)]))this[t(281)]?.[t(526)](),this[t(281)]=void 0;else{this[t(296)+"WebSocket"]();let r=_0x13d9a1(t(1277)+"t",{message:e.zZXcB});this[t(662)+"mediatelyReconnect"]&&this[t(662)+t(192)+t(553)+"ct"](r)}}catch(r){console[t(990)](r)}}get[n(799)](){let t=n;try{return!!this._qosDB}catch(r){return console[t(990)](r),!1}}}class md{constructor(t,r){let d=n;this[d(726)]=t,this[d(495)]=r,this[d(281)]=localStorage}async[n(981)](){}get[n(752)](){return n(180)+"_"+this._DBName}async get(t){let r=n;if(e[r(363)](r(1638),e[r(527)]))_0x4a35b3=e.GvQvf(_0x43fbc8,_0x29365c),_0x4bbc0a|=e[r(741)](e[r(1102)](127,_0x2c78d5),7);else{let d=this[r(281)].getItem(this[r(752)]);return JSON.parse(e[r(1521)](d,"{}"))[t]}}async[n(695)](t,r){let d=n,f=this[d(281)][d(328)](this[d(752)]),p=JSON[d(1498)](e[d(423)](f,"{}"));return p[r||t[this._pathKey]]=t,this._qosDB.setItem(this._prefix,JSON.stringify(p)),r||t[this[d(495)]]}async[n(435)](t){let r=n,d=this[r(281)][r(328)](this._prefix),f=JSON[r(1498)](e[r(1521)](d,"{}"));return f[t]=void 0,this[r(281)][r(1587)](this[r(752)],JSON[r(354)+"y"](f))}async[n(359)](){let t=n;return e.jrVBh(e[t(1156)],e[t(1156)])?this[t(281)][t(359)]():(_0x68bbc6||(_0x225cbf=_0x4767b6[t(1206)]().then(_0x433592.bind(_0x1ab431,e.tYheo))),_0xd6e93e)}async[n(1300)](){let t=n,r=this[t(281)][t(328)](this[t(752)]),d=JSON[t(1498)](e[t(423)](r,"{}"));return Object[t(1300)](d)}async[n(1576)](){let t=n,r=this._qosDB.getItem(this[t(752)]),d=JSON[t(1498)](e[t(423)](r,"{}"));return Object.values(d)}[n(349)](){return Promise.resolve()}get[n(799)](){let t=n,r={wTszD:function(d,f){return e[K(1696)](d,f)},VOQMR:e[t(568)]};if(e[t(774)](e[t(1656)],t(491)))return!!this[t(281)];{let d=_0x2ffa13[t(815)+"ement"](e[t(1119)]);_0x3b65d2[t(180)+t(1059)]=f=>{let p=t;_0x36e43c[p(1397)][p(599)+p(543)](d),_0x1fbea5[p(180)+p(1059)]=void 0,qUEqks[p(1668)](_0x49a310,f&&f.msg||qUEqks[p(411)])},d[t(622)]=e[t(1583)],d[t(1071)]=e[t(606)](_0x738b2d[t(832)](/^ws/,e[t(840)]),e[t(1460)]);try{_0x4aa341[t(1397)][t(1201)+t(543)](d)}catch{_0x1ead7b.body[t(599)+t(543)](d)}}}}class wd{constructor(t,r){let d=n;this[d(726)]=t,this[d(495)]=r,this[d(281)]=bt?tt:cn?wx:null}async[n(981)](){}get[n(752)](){let t=n;if(e.duqaH(e[t(1295)],t(361)))throw this[t(283)+t(678)]=!1,_0x4faeb1;return"frontier_"+this._DBName}async get(t){let r=n,d=this._qosDB["getStora"+r(879)](this[r(752)]);return JSON.parse(d||"{}")[t]}async[n(695)](t,r){let d=n,f=this._qosDB["getStora"+d(879)](this[d(752)]),p=JSON[d(1498)](e[d(635)](f,"{}"));return p[r||t[this[d(495)]]]=t,this[d(281)][d(1262)+d(879)](this[d(752)],JSON[d(354)+"y"](p)),r||t[this[d(495)]]}async[n(435)](t){let r=n;if(e[r(1462)](e.oLIPD,e.EkJBq))return e[r(1582)](_0x1abf40,e[r(1365)](_0x4a437c,_0x444c59));{let d=this[r(281)][r(819)+"geSync"](this[r(752)]),f=JSON[r(1498)](e[r(1455)](d,"{}"));return f[t]=void 0,this[r(281)][r(1262)+r(879)](this[r(752)],JSON.stringify(f))}}async[n(359)](){let t=n;return e.EBSJb(t(1622),e[t(436)])?this._isMiniTT||this[t(396)+"X"]?this["_miniNav"+t(685)+t(421)]:(this[t(1454)+"er"]||this._isWorker)&&this[t(1627)][t(996)+t(189)+"nged"]?_0x3f73bf.onLine:!0:this._qosDB[t(1438)+"rageSync"]()}async[n(1300)](){let t=n,r=this[t(281)][t(819)+t(321)+"nc"](this._prefix),d=JSON.parse(e[t(195)](r,"{}"));return Object[t(1300)](d)}async[n(1576)](){let t=n,r={mAjJw:function(d,f,p){return e[K(1549)](d,f,p)},gmocX:function(d,f){return e[K(782)](d,f)}};if(e.eBqJf!==e[t(1351)]){let d=this[t(281)]["getStora"+t(321)+"nc"](this[t(752)]),f=JSON.parse(e.WWvGl(d,"{}"));return Object[t(218)](f)}else DiMsnh.mAjJw(_0xb6bb3d,_0x55aec8,96),_0x33b20d(_0x5160c9,DiMsnh[t(722)](_0x2fd1a6,_0x548c67))}[n(349)](){let t=n;return e[t(334)]===e.kYCyx?Promise[t(1206)]():!!this[t(281)]}get[n(799)](){let t=n;if(e[t(1436)](e.hQeXg,e[t(1534)]))this[t(368)]=!0,this.low=0|_0x46fc9d,this.high=0|_0x358919,this[t(1294)]=!!_0x156457;else return!!this._qosDB}}function Gs(s,t){let r=n;if(e[r(1630)](bt,bt))return new wd(s,t);if(e[r(982)](Ot,dn)&&e[r(949)](e[r(908)],typeof indexedDB))return new pd(s,t);if((Ot||dn)&&e.DRDvZ(e.ACbNl,typeof localStorage))return new md(s,t);throw new Error(e[r(433)])}class _d{constructor(){let t=n;this[t(1025)+t(728)+"Id"]=null,this[t(1025)+"l"]=36e5,this[t(281)]=e[t(1399)](Gs,e[t(666)],e[t(478)])}async[n(1025)+n(691)](){let t=n;e[t(751)](e[t(1217)],e[t(231)])?(_0xc6eec7=e[t(1526)](_0x5b0c44,_0x5f620e),_0x150565|=e[t(697)](e[t(1624)](127,_0x2c464a),21),128&_0x2b1d93&&(_0x128dec=_0x3aaf47(_0x3574d7),_0x23d863=127&_0x18c559,e[t(1359)](128,_0x3d639a)&&(_0x544b7f=e[t(619)](_0x35686e,_0xda5818),_0x43b3b2|=e[t(1528)](e.xmvIJ(127,_0xfb5e5),7)))):(e[t(242)](clearInterval,this["_interva"+t(728)+"Id"]),this[t(1025)+t(728)+"Id"]=e[t(313)](setInterval,()=>{this[t(1043)+"ired"]()},this[t(1025)+"l"]))}async openDB(){let t=n;await this[t(281)][t(981)]()[t(1099)](()=>{this[t(1025)+"lFlush"]()})}async[n(1043)+n(1652)](){let t=n;(await this[t(281)]?.[t(1576)]()||[]).filter(({timestamp:f})=>f<Date.now()).forEach(f=>{let p=t;this._qosDB?.[p(435)](f[p(825)+"id"])})}async[n(435)](t){let r=n;return this[r(281)]?.[r(435)](t)}async[n(695)](t,r){let d=n,f={mMAlN:e.RqARa,GhOPo:d(333)};if(e[d(745)]("qVWaw",e[d(1010)]))return this[d(281)]?.set({message_id:t,timestamp:r});this[d(1331)+d(1477)]()&&(!this._ws||this[d(532)][d(1301)+"te"]!==this[d(988)]||this[d(532)][d(1301)+"te"]!==this[d(1166)+"NG"])&&this[d(1463)+d(935)](),this._isBrowser&&_0x4ded93["addEvent"+d(203)](f.mMAlN,this["_handleO"+d(935)]),this[d(1454)+"er"]&&_0x51fc77["addEvent"+d(203)](f[d(893)],this["_handleO"+d(295)])}async[n(592)](t){let r=n;return this[r(281)]?.[r(592)](t)}async closeDB(){let t=n;if(e[t(809)](e[t(562)],"GduVY")){let r=this._qosDB[t(328)](this[t(752)]),d=_0x224f4a[t(1498)](r||"{}");return d[_0x1ca4a7]=void 0,this[t(281)][t(1587)](this[t(752)],_0x1594ff[t(354)+"y"](d))}else e[t(324)](clearInterval,this[t(1025)+t(728)+"Id"]),await this[t(281)]?.[t(349)]()}get[n(799)](){let t=n;return this[t(281)]?.[t(799)]}}function oi(s){let t=n,r=!!this[t(1627)][t(460)+"S"];if(!r)return{enabled:r,isQoSMessage:!1,isQoSAck:!1,isAckCleanupMessage:!1,ackMsgIds:[]};let d=e[t(314)](xt,s[t(874)].headers,e[t(375)],"2"),f=d&&e.zszRe(xt,s.message.headers,e[t(472)],"1"),p=d&&xt(s[t(874)].headers,e[t(1708)],"1"),v=p?Mt(s[t(874)][t(1512)],e[t(1003)])?.split(",").filter(Boolean)||[]:[];return{enabled:r,isQoSMessage:d,isQoSAck:f,isAckCleanupMessage:p,ackMsgIds:v}}async function js(){let s=n,t={vjdyK:function(r,d){return r>=d},EooZt:function(r,d,f){return r(d,f)},oURFu:function(r,d){return r|d},ArbQr:function(r,d){return e[K(542)](r,d)}};if(e.PVyKM(e[s(1632)],e[s(1632)]))return this["_QoSMana"+s(802)]||(this[s(1421)+"ger"]=new _d),this._QoSManager.isReady||await this[s(1421)+s(802)].openDB(),this[s(1421)+s(802)];for(_0x510846>>>=0;FjjeMW.vjdyK(_0x47d95f,128);)FjjeMW[s(193)](_0x11f181,_0x15185a,FjjeMW[s(1680)](FjjeMW.ArbQr(127,_0xd0c731),128)),_0x389e63>>>=7;_0xe7c122(_0x3680a4,_0x96ab7c)}async function yd(s,t){let r=n,{enableAutoAck:d}=this[r(1627)],f=e[r(515)](xt,s[r(874)].headers,e[r(917)],"1"),p=e[r(1028)](xt,s[r(874)][r(1512)],"is_ack","1"),v=oi[r(677)](this,s);if(e[r(1395)](d,f))if(e[r(1553)](r(798),e[r(1571)]))this.count++;else{let{SeqID:y,LogID:h,service:P,LogIDNew:D,method:M}=s[r(874)];this[r(1316)]({SeqID:y,LogID:h,LogIDNew:D,service:P,method:M,headers:[{key:e.kyWrE,value:"1"},{key:e[r(878)],value:e[r(1247)](D,"")},{key:r(1026),value:"0"}]})}p&&!v.isQoSAck&&this[r(1429)+r(1647)+r(1310)](s),t()}async function Ed(s,t){let r=n;this[r(847)](e[r(1050)],s[r(874)]),e[r(957)](t)}async function bd(s,t){let r=n,d=e[r(1365)](kt,await e[r(564)](Hs,s[r(224)]));try{if(e.UWpRP(d[r(683)],Uint8Array)){let f=this[r(1627)][r(914)+r(348)]instanceof Object?{force:!!this[r(1627)][r(914)+r(348)][r(1678)],encoding:this[r(1627)]["payloadE"+r(348)][r(1517)]?this[r(1627)].payloadEncoding.encoding[r(832)](/\s/g,"")["toLowerC"+r(1628)]():""}:{force:!1,encoding:this._options[r(914)+r(348)]?this[r(1627)][r(914)+r(348)].replace(/\s/g,"")[r(746)+"ase"]():""},p=d[r(914)+r(348)]?d[r(914)+r(348)][r(832)](/\s/g,"")[r(746)+"ase"]():"",v=e[r(582)](this[r(1627)]["payloadT"+r(600)],Object)?{force:!!this[r(1627)][r(916)+"ype"][r(1678)],type:this[r(1627)][r(916)+"ype"][r(622)]?this._options[r(916)+r(600)][r(622)][r(832)](/\s/g,"")[r(746)+r(1628)]():""}:{force:!1,type:this[r(1627)][r(916)+"ype"]?this[r(1627)][r(916)+r(600)].replace(/\s/g,"")[r(746)+"ase"]():""},y=d[r(916)+r(600)]?d[r(916)+r(600)].replace(/\s/g,"")[r(746)+r(1628)]():"",h=v.force?v[r(622)]:y||v.type,P=f.force?f[r(1517)]:p||f[r(1517)],D=[e[r(1446)],e[r(1268)],r(1531)+r(1548)+r(555)+r(633),e.mqblF],M=[e[r(1018)],e.GxwBR];this._options[r(1339)+r(1077)+r(514)+"ad"]&&D[r(468)](h)&&(!P||M[r(468)](P))?d[r(352)+r(1161)]=qs(d[r(683)],0,d[r(683)][r(1125)+"th"]):d[r(352)+r(1161)]=""}else d[r(352)+r(1161)]=""}catch(f){d[r(352)+r(1161)]="",console.log(f)}s.message=d,e[r(957)](t)}function vd(s,t,r){let d=n,f={tsOCi:function(P,D){return P<D},oWzAc:function(P,D){return e[K(351)](P,D)},UfXhq:function(P,D){return e[K(814)](P,D)},wuIoL:function(P,D){return e[K(867)](P,D)},wMfMG:function(P,D){return e.gbcvf(P,D)},PgWGx:function(P,D){return P&D},XdPaP:function(P,D){return e.SLutz(P,D)}},p=e[d(1145)](r,8192),v=e.pNGYK(p,1),y=null,h=p;return function(P){let D=d;if(f[D(834)](P,1)||P>v)return f[D(1181)](s,P);f[D(1212)](f[D(998)](h,P),p)&&(y=f.wMfMG(s,p),h=0);let M=t[D(677)](y,h,h+=P);return f[D(853)](7,h)&&(h=f[D(1299)](7,h)+1),M}}let Sd=4294967295;function Id(s,t,r){let d=n,f={VdKcn:function(p,v){return e[K(458)](p,v)},dIzih:function(p,v){return e[K(936)](p,v)}};if(e[d(855)](e.MUvlD,e[d(1474)])){let p=0,v={};for(let y=0;y<_0x1fc1ca[d(1241)];y++)v[_0x278fe2[y][d(1325)+d(1320)]]=f[d(1035)](_0x4d7f90,_0x30c527[y][d(1325)+d(1320)]),p+=f.dIzih(14,v[_0x4170ef[y][d(1325)+d(1320)]]);return[p,v]}else return RangeError(e[d(655)](e[d(1179)](e[d(1698)]+s,d(1189))+e[d(1654)](t,1),e[d(778)])+r)}function Ad(s,t,r){let d=n;if(e[d(814)](r,Sd))throw new Error("integer "+d(1104)+"e");let f=3;for(;e[d(1019)](f,0);){let p=255&r;e[d(336)](ci,p,s,t+f),r>>>=8,f--}return t+4}function Cd(s,t){let r=n,d=0,f=t,p=e[r(311)](t,4);for(;e[r(1309)](f,p);){let{value:v,offset:y}=ai(s,f);f=y,d=e.YvpKZ(d<<8,0),d+=v}return{value:d,offset:p}}function Td(s,t,r){let d=n;return s?e[d(437)](s[d(1241)],40)?e[d(969)](ii,s,t,r)+r:t[d(385)+"e"]?t[d(385)+"e"](s,r)+r:t[d(1681)]?e[d(425)](t[d(1681)](s,r),r):e[d(796)](e[d(681)](ii,s,t,r),r):r}function Dd(s,t){let r=n,d=new ne(e[r(551)](e[r(1138)](s[e[r(836)](t,4)]<<24,e[r(1434)](s[e[r(971)](t,5)],16)),s[t+6]<<8)|s[e[r(989)](t,7)],e[r(388)](e[r(1335)](e[r(1528)](s[e.NlWYs(t,0)],24),e.estzd(s[e[r(1479)](t,1)],16)),e[r(776)](s[e[r(687)](t,2)],8))|s[e[r(844)](t,3)],!0);return t+=8,{value:d,offset:e[r(1467)](t,8)}}function Pd(s,t,r){let d=n,f=s[d(459)],p=s.high;return t[r]=e[d(870)](p,24),t[e[d(1479)](r,1)]=p>>>16&255,t[e[d(796)](r,2)]=e[d(1352)](e[d(727)](p,8),255),t[r+3]=255&p,t[r+4]=e[d(826)](f,24),t[e[d(323)](r,5)]=e.Onkcc(e[d(910)](f,16),255),t[r+6]=e.rirGW(e[d(910)](f,8),255),t[e[d(326)](r,7)]=e[d(441)](255,f),r+=8,r}function ai(s,t){let r=n;return s[r(269)+"8"]?{value:s.readUInt8(t),offset:e[r(617)](t,1)}:{value:255&s[t],offset:e[r(897)](t,1)}}function ci(s,t,r){let d=n;return t[d(1356)+"t8"]?t[d(1356)+"t8"](s,r):t[r]=e[d(1547)](255,s),e.JcmuI(r,1)}let kd=function(s){return new Uint8Array(s)},Rd=e[n(949)](e.ACbNl,typeof Buffer)?Buffer[n(1142)+n(337)]:e.dIawX(vd,kd,Uint8Array[n(533)+"e"].subarray),Nd=16,di=32;function Ld(s){let t=n,r=0,d={};for(let f=0;f<s.length;f++)d[s[f][t(1325)+"ame"]]=e[t(440)](Us,s[f][t(1325)+t(1320)]),r+=e[t(538)](14,d[s[f][t(1325)+"ame"]]);return[r,d]}function Ks(s,t,r){let d=n,f={HhJAE:function(p){return p()}};if(e.fqEHy(e[d(1509)],e[d(1509)])){let p=this[d(455)+d(1226)]?.[d(389)+d(1578)+"nt"]();this._debug("open "+p),f[d(1274)](_0x42dc35)}else{let[p,v]=Ld(s),y=e[d(306)](Rd,p),h=0;return s.forEach(P=>{let D=d,M=e.jROXA[D(1449)]("|"),G=0;for(;;){switch(M[G++]){case"0":h=e.AXZDT(Ad,y,h,P.service||0);continue;case"1":console[D(990)](e[D(1598)],h);continue;case"2":console[D(990)](D(1288)+"name",h);continue;case"3":console[D(990)](e[D(654)],P,P[D(529)]);continue;case"4":h=e[D(499)](ci,0,y,h);continue;case"5":h=e[D(471)](ci,v[P["cursor_n"+D(1320)]],y,h);continue;case"6":console[D(990)](e[D(1184)],h);continue;case"7":console[D(990)](e.XaFBk,h);continue;case"8":h=e[D(202)](Pd,ne[D(1006)+"er"](P[D(1053)]||t),y,h);continue;case"9":console[D(990)](e.FonRl,h);continue;case"10":h=e[D(515)](Td,P[D(1325)+D(1320)],y,h);continue}break}}),{frameType:di,headers:[{key:"cursor_file_name",value:r}],payload:y}}}function Od(s){let t=n,r=0,d=[];for(;r<s[t(1125)+"th"];){let{offset:f}=ai(s,r);r=f;let p={cursor_name:"",cursor:0,service:0},{value:v,offset:y}=e.JZiLz(Cd,s,r);p.service=v,r=y;let{value:h,offset:P}=e.QhTbi(ai,s,r);r=P,p[t(1325)+t(1320)]=e[t(446)](qs,s,r,e[t(1467)](r,h)),r+=h;let{value:D,offset:M}=e.vACde(Dd,s,r);p[t(1053)]=D.toNumber(),r=M,d[t(383)](p)}return d}function Md(){let s=n;return{frameType:di,headers:[{key:e[s(1709)],value:e[s(641)]}],payload:void 0}}class Bd{constructor(t,r,d){let f=n;this[f(399)+"ameSpace"]=t,this[f(922)+f(1535)]=r,this["_message"+f(310)]=d,this[f(281)]=Gs(this[f(399)+f(431)],"cursor_n"+f(1320))}async[n(981)](){let t=n;if(e.MqJhN(e.AHFHl,t(1343))){if(e[t(1455)](_0x2339fe,_0x244a7f))return new _0x191453(_0x864d16,_0x29b6b9);if(e[t(1224)](_0x35d0b2,_0xde2141)&&e.ACbNl!=typeof _0x42c94f)return new _0x21a187(_0x567428,_0x56a0de);if(e[t(248)](_0x5e5843,_0x133230)&&e[t(987)](e[t(908)],typeof _0x55ff97))return new _0x2e9a96(_0x18d733,_0x24b166);throw new _0x255930(e[t(433)])}else await this[t(281)][t(981)]()}async getCursors(){let t=n;if(!this[t(281)][t(799)])return;let r=this[t(793)+t(310)],d=await this._qosDB[t(1576)]();switch(console[t(990)](e.VTJDo,d),r){case e[t(1101)]:return d&&d.length?Ks(d,0,this[t(922)+t(1535)]):void 0;case e[t(1060)]:return;case e[t(1604)]:return d&&d[t(1241)]?e[t(1298)](Ks,d,0,this[t(922)+"ileName"]):e[t(957)](Md)}}async set(t,r,d){let f=n,p={mRTzj:function(v,y){return e.NHaQx(v,y)},YbBql:function(v,y){return e[K(489)](v,y)},tfHeJ:function(v,y){return e[K(521)](v,y)},WkaIH:function(v,y){return v&y}};if(e.fqEHy(e[f(1e3)],e.shIZh))return console[f(990)](e[f(846)],t,r,d),this[f(281)][f(695)]({cursor_name:t,cursor:r,service:d});{let v=this[f(1425)],y=this[f(459)];return[sjUaWB[f(317)](v,24),sjUaWB[f(864)](v,16)&255,sjUaWB.tfHeJ(v,8)&255,sjUaWB[f(1313)](255,v),y>>>24,sjUaWB[f(1313)](sjUaWB.tfHeJ(y,16),255),sjUaWB.WkaIH(sjUaWB[f(317)](y,8),255),255&y]}}async[n(1605)+"rs"](t){let r=n,d=e[r(955)](Od,t);for(let f of d)console[r(990)](e[r(1715)],d),await this[r(281)][r(695)](f)}async get(t){let r=n;return(await this[r(281)][r(592)](t))?.[r(1053)]}async closeDB(){let t=n;await this._qosDB[t(349)]()}[n(615)+n(1670)+"Name"](t){let r=n,d={vkHXY:function(f,p){return f(p)},ggcpK:function(f,p){return e[K(479)](f,p)},JfhwC:function(f,p){return e[K(936)](f,p)},pbWnO:function(f,p){return f%p},JxRKY:function(f,p){return e[K(895)](f,p)}};if(e[r(625)]===e[r(670)]){if(jPjeZx[r(213)](_0x988456,_0x2d827f))return _0x3f4463?_0x31558b:_0x5790f9;if(_0x2e41dd){if(jPjeZx[r(1007)](_0xa7a36d,_0xde0977))return _0x15e315}else{if(_0x1066ae<=-_0x5dc6f8)return _0x5af343;if(jPjeZx[r(937)](_0x32b56f,1)>=_0x2af8f9)return _0x54e3d5}return _0x520bad[r(545)](jPjeZx[r(1314)](_0x4e15d1,_0x59fedd)|0,jPjeZx[r(365)](_0x1e9642,_0x440d30)|0,_0x1f0b2f)}else this[r(922)+"ileName"]=t}get[n(799)](){let t=n;return this[t(281)][t(799)]}}let zd=n(1287)+n(824);async function Ws(s){let t=n;if(!this[t(1627)][t(460)+"S"])return null;let{aID:r,fpID:d,messageStrategy:f}=this[t(1627)],p=e[t(1112)](s,zd);try{return this[t(626)+"anager"]?s&&this[t(626)+t(1621)]["updateCu"+t(1670)+t(232)](s):this[t(626)+t(1621)]=new Bd(d+"_"+r+"_"+p,p,f),this._cursorManager[t(799)]||await this[t(626)+t(1621)][t(981)](),this[t(626)+t(1621)]}catch{return null}}async function Fd(s,t){let r=n,d=xt(s[r(874)][r(1512)],e[r(259)],"-1"),f=e[r(899)](xt,s[r(874)].headers,r(785),"1"),p=e[r(1588)](Mt,s[r(874)][r(1512)],e[r(1507)]),v=e[r(955)](Number,e.EENYF(Mt,s[r(874)][r(1512)],e[r(1084)]))||0,y=oi[r(677)](this,s),h=e[r(1080)](xt,s[r(874)][r(1512)],e[r(377)],"2"),P=e[r(574)](Mt,s[r(874)][r(1512)],e.SsRTg),D=e[r(792)](Number,Mt(s[r(874)][r(1512)],e[r(1209)]));if(y[r(480)])return e.bilkc(t);let M=y["isQoSMes"+r(705)]?await js[r(677)](this):null;if(e[r(554)](s[r(874)].service,0)&&f&&!d||s[r(874)][r(529)]>0)if(e[r(1005)]!==r(1116)){if(p&&y[r(1411)+r(705)]&&M)return!!!await M[r(592)](p)&&(this[r(1429)+r(1312)+r(284)](s),await M[r(695)](p,e[r(311)](Date[r(1126)](),v))),e.PgPBd(t);if(h){let G=await Ws[r(677)](this);if(!G)return this[r(1429)+r(1312)+"Event"](s),e[r(1105)](t);let H=await G[r(592)](P)??-1;if(H<D)if(e.jrPtD(e[r(1410)],e[r(1292)]))this[r(1429)+r(1312)+"Event"](s),G[r(695)](P,D,s[r(874)][r(529)]);else try{this._qosDB?.[r(526)](),this[r(281)]=void 0}catch(xe){_0x362919.log(xe)}else throw new Error(r(1253)+r(504)+" cursor "+D+(r(394)+r(1398)+r(736)+"r ")+H);return e.PgPBd(t)}return this["_dispatc"+r(1312)+"Event"](s),e[r(797)](t)}else{let G=e[r(1491)](_0x3b11a3,_0x5b24ea),H=_0x11c674[r(1413)];return _0x31bdcb[r(1413)]=e[r(1655)](_0x9482fb[r(266)],G),H}}async function Ud(s,t){let r=n,d=oi[r(677)](this,s);if(!d["isQoSMes"+r(705)])return e[r(1544)](t);let f=await js[r(677)](this);if(d[r(220)+r(1033)+"age"]&&d[r(485)+"s"][r(1241)])for(let p of d[r(485)+"s"])await f[r(435)](p);e[r(1409)](t)}async function qd(s,t){let r=n,d=e.dYdko(s[r(874)][r(287)+"e"],Nd),f=e[r(289)](s[r(874)][r(287)+"e"],di);if(!d&&!f)return e.dzTgA(t);let p=e[r(1054)](Mt,s.message[r(1512)],e.ccFdH);if(!p)return e[r(382)](t);let v=await Ws.call(this,p);if(!v)return e[r(957)](t);if(d){let y=await v[r(586)+"rs"](),h={frameType:y?.["frameType"],SeqID:ne[r(1006)+"er"](this[r(1085)]++),LogID:ne[r(1006)+"er"](this._options[r(1233)+r(884)]()),service:9e3,method:5,headers:y?.[r(1512)],payload:y?.payload},P=e[r(1546)](A,h);this[r(532)]&&this[r(532)].readyState&&this._ws[r(1457)](P)}if(f){let y=s[r(874)][r(683)];y&&v.setCursors(y)}}let Hd=async function(s,t){let r=n;this[r(1465)]=!1,e[r(1283)](clearTimeout,this["_connect"+r(1171)+r(552)]),e[r(959)](t)},Gd=async function(s,t){let r=n,d={UfSsv:function(v,y){return e.NvUcE(v,y)},GUPpq:e[r(1566)],BchBy:e[r(1098)],VLwMZ:function(v,y,h){return v(y,h)},LYgkW:function(v,y){return e[r(643)](v,y)},stfpY:function(v,y,h,P){return e.rJWDq(v,y,h,P)},xAiTO:function(v,y,h){return e[r(523)](v,y,h)}};if(!this._ws||e[r(1234)](this[r(532)].readyState,this.OPEN))return e.bilkc(t);let{pingInterval:f}=this[r(1627)];this[r(455)+r(1226)]?.[r(801)+r(184)+r(276)]();for(let v=0;e[r(207)](v,this[r(793)+r(1648)][r(1241)]);v++){let y=this["_message"+r(1648)][v];if(this._ws[r(1301)+"te"]===this[r(988)]&&e[r(182)](null,y))if(e[r(1575)](e[r(325)],r(1646))){let{pingInterval:h,pingFrequency:P}=this[r(1627)];if((_0x2e1b13.data==="hi"&&d.UfSsv("always",P)||d.GUPpq===P)&&(this["_clearPi"+r(1383)](),this[r(1244)](r(731)+r(1137)+"s",d[r(1065)]),this[r(1529)+r(1371)+"Id"]=d.VLwMZ(_0x513f72,this._ping[r(1641)](this),h)),d.LYgkW("hi",_0x19e467.data))return;try{d[r(1444)](_0x3a5c20,this,_0x485a19,[_0x269116,_0x455a4a,_0x7ba532,_0x2db1e9,_0x2eaf2b,_0x586ddb])}catch(D){let M=d[r(1554)](_0x3ab5ee,r(856),{message:D[r(874)],code:_0x4ba0df[r(1239)+r(680)],error:D});this[r(1429)+"hErrorEvent"](M)}}else this[r(532)]&&this[r(532)][r(1457)](y),this[r(793)+"Queue"][v]=null;else break}this[r(793)+r(1648)]=this["_message"+r(1648)][r(932)](v=>!!v),this[r(1529)+r(1371)+"Id"]=e.FKEQi(setTimeout,()=>this[r(535)](),f),this["_dispatc"+r(477)+"nt"](s),this[r(1454)+"er"]&&this[r(532)]&&(this._ws[r(297)+"pe"]=this[r(490)+"ype"]);let p=this._endpointManager?.["getCurre"+r(1578)+"nt"]();this[r(847)]("open "+p+r(1418)),e[r(1364)](t)},jd=async function(s,t){let r=n,d=this["_endpoin"+r(1226)]?.[r(389)+"ntEndpoint"]();this[r(847)](r(657)+d),e[r(1105)](t)};class Kd extends ri{constructor(t){let r=n,d={jgGfx:e.pduzb,dnivR:function(y,h){return y===h},GiPdE:function(y,h,P){return y(h,P)}};super(),this["_miniNav"+r(685)+r(421)]=!0,this[r(1454)+"er"]=Ot,this[r(956)]=ad,this._isMiniTT=bt,this[r(396)+"X"]=cn,this._isWorker=dn,this["_message"+r(1648)]=[],this[r(455)+r(1226)]=null,this[r(1354)+"osed"]=!1,this[r(490)+r(600)]=e[r(1023)],this[r(283)+r(678)]=!1,this[r(283)+"ionTimeo"+r(552)]=null,this[r(1147)+r(188)+"tId"]=null,this[r(1529)+r(1371)+"Id"]=null,this._seqId=0,this[r(1465)]=!1,this._url="",this["_QoSMana"+r(802)]=null,this["_cursorM"+r(1621)]=null,this[r(419)+"sCounter"]=null,this[r(857)+"ls"]=e[r(898)],this[r(1153)]=3,this.CONNECTING=0,this[r(988)]=1,this[r(1032)]=2,this._onOpen=y=>{let h=r,P={jvjWW:function(D,M){return D<M},sykhO:function(D,M){return e[K(554)](D,M)},JCOPX:function(D,M){return e[K(892)](D,M)},ifJvu:function(D,M){return D(M)},ifvgb:function(D,M){return e[K(426)](D,M)},NJdrg:function(D,M){return e[K(1619)](D,M)},weugX:function(D,M){return e[K(551)](D,M)}};try{if(e[h(1494)](e[h(434)],e[h(1240)])){if(xTDmAt[h(753)](_0x28464f,1)||xTDmAt[h(1492)](_0x405375,_0x1e5a48))return _0x57a1a3(_0x4eecb2);xTDmAt.JCOPX(_0x4c53e4,_0x5a5cab)>_0x4786eb&&(_0x3c6713=xTDmAt[h(1369)](_0x3b5519,_0x41a411),_0x34562f=0);let D=_0x832187[h(677)](_0x27735a,_0x12ea61,_0x288589+=_0x103156);return xTDmAt.ifvgb(7,_0x53995e)&&(_0x1bffc0=xTDmAt.NJdrg(xTDmAt[h(911)](7,_0x1068a0),1)),D}else Fs(this,y,[Hd,Gd,jd])}catch(D){let M=e.KPXlX(Me,e[h(881)],{message:D[h(874)],code:ft[h(1580)+"OR"],error:D});this[h(1429)+"hErrorEv"+h(715)](M)}},this[r(977)+"ge"]=async y=>{let h=r,{pingInterval:P,pingFrequency:D}=this[h(1627)];if((y[h(224)]==="hi"&&e.oVgoQ(e[h(1476)],D)||e.afefV(e[h(1566)],D))&&(this[h(1044)+"ngTimer"](),this[h(1244)](e[h(234)],h(1426)),this["_pingPon"+h(1371)+"Id"]=e[h(574)](setTimeout,this._ping[h(1641)](this),P)),!e[h(1333)]("hi",y[h(224)]))try{e[h(560)](e.URWot,e[h(482)])?(this[h(1244)]("error",_0x1d2261),this.onerror&&this[h(1690)](_0x21784e)):e[h(497)](Fs,this,y,[bd,yd,Ud,qd,Fd,Ed])}catch(M){let G=Me(e[h(881)],{message:M[h(874)],code:ft[h(1239)+h(680)],error:M});this[h(1429)+h(1702)+"ent"](G)}},this._onError=y=>{let h=r,P=this[h(455)+h(1226)]?.[h(618)+"chMaxTries"](),D=this[h(455)+h(1226)]?.[h(389)+h(1578)+"nt"]();if(P&&!y.message){let M=h(1154)+D+(h(823)+h(965)+h(1086)+"ed");this[h(1429)+h(1702)+"ent"](Me(d[h(634)],{message:M,code:ft["MAX_RETR"+h(475)+"R"],error:y}));return}this[h(532)]&&d.dnivR(this[h(532)][h(1301)+"te"],this[h(988)])&&this[h(1568)+"ect"](),this["_dispatchErrorEv"+h(715)](d.GiPdE(Me,d[h(634)],{message:y[h(874)],code:ft["NATIVE_E"+h(1282)],error:y}))},this[r(424)]=async y=>{let h=r;this[h(1129)+h(1388)](),this[h(1044)+"ngTimer"](),this[h(316)+h(1337)+"rs"](),this[h(532)]=null,this["_connect"+h(678)]=!1;let P=this[h(455)+h(1226)]?.["checkRea"+h(1336)+"es"]();if(!P&&this[h(1331)+h(1477)]()&&!this["_readyCl"+h(720)]){let D=this[h(455)+h(1226)]?.[h(389)+"ntEndpoint"](),M=this[h(1627)][h(1277)+h(1600)+h(237)](y.code,y[h(1539)]);this["_dispatc"+h(402)+h(715)](e[h(759)](Ue,e.dTVjI,{code:1006,reason:y[h(1539)]||h(803)+"ng faile"+h(500)+h(1208)+h(958)+h(1481)+D,willReconnect:M})),M&&this[h(283)]();return}if(e[h(1669)](1e3,y[h(602)])&&this["_readyCl"+h(720)]){this["_dispatc"+h(402)+h(715)](e.HWyrH(Ue,e[h(262)],{code:1e3,reason:e[h(275)]})),this["_endpoin"+h(1226)]?.["resetEnd"+h(184)+h(276)](),this["_pingLos"+h(896)]?.[h(866)+h(1614)]();return}if(y.code!==1e3&&P){let D=this[h(455)+h(1226)]?.[h(389)+"ntEndpoint"](),M=y[h(1539)];M||(M=await e.IXqTO(gd,this[h(946)])),M=h(803)+"ng failed, "+M+(h(372)+h(614))+D+(h(890)+h(512)+"ached"),this["_dispatc"+h(402)+h(715)](e[h(387)](Ue,e.dTVjI,{code:y[h(602)],reason:M}));let G=h(1154)+D+(h(823)+"ax retri"+h(1086)+"ed");this[h(1429)+h(1702)+h(715)](e[h(794)](Me,e[h(881)],{message:G,code:ft[h(1162)+"IES_ERROR"]})),this[h(455)+h(1226)]?.[h(801)+"pointCon"+h(276)](),this[h(419)+h(896)]?.[h(866)+h(1614)]();return}if(e[h(616)](1e3,y[h(602)])&&!y[h(1539)]){let D=this[h(455)+"tManager"]?.["getCurre"+h(1578)+"nt"]();this[h(1429)+h(402)+h(715)](e.EENYF(Ue,e.dTVjI,{code:y[h(602)],reason:"connecting faile"+h(500)+h(1208)+h(958)+h(1481)+D})),this[h(455)+"tManager"]?.[h(801)+"pointConfig"](),this["_pingLos"+h(896)]?.["resetCou"+h(1614)]();return}this["_dispatc"+h(402)+h(715)](y),this["_endpoin"+h(1226)]?.[h(801)+h(184)+h(276)](),this._pingLossCounter?.["resetCou"+h(1614)]()},this[r(830)]=null,this[r(1690)]=null,this[r(983)+"e"]=null,this[r(1198)]=null,this[r(1157)+"econnect"]=null,this[r(1061)+r(1111)]=null,this[r(662)+r(192)+r(553)+"ct"]=null,this["_handleO"+r(935)]=this[r(1463)+r(935)][r(1641)](this),this[r(1463)+"ffLine"]=this[r(1463)+r(295)][r(1641)](this),this[r(1034)+r(940)]=this[r(1034)+r(940)][r(1641)](this),this[r(1034)+r(444)]=this[r(1034)+r(444)].bind(this),this[r(1627)]={url:"",automaticOpen:!0,initReconnectInterval:1e3,maxReconnectInterval:1e4,reconnectIntervalGrowFactor:2,timeoutInterval:5e3,maxRetries:5,debug:!1,maxMessageQueueLength:e[r(392)](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(254),pingLossCount:2,enableTransformTextPayload:!1,logIDNewConfig:{enableAutoGenerateLogIDNew:!1,userIp:""},miniProgramParams:{customHttpHeader:{}},enableAutoAck:!1,reconnectInterceptor:()=>!0,enableQoS:!1,QoSLevel:2,messageStrategy:r(723),env:{xTTEnv:"",xUseEnv:""},listenNetworkChanged:!0};let{url:f,ws:p}=t,v=Array[r(1017)](f)?f:e[r(280)]==typeof f?[f]:[];if(!v||e[r(643)](0,v[r(1241)]))throw new Error(e[r(608)]);if(!e.DrUFh(ud,p))throw new Error(r(288)+r(1537)+"s params, WebSoc"+r(293)+r(1236)+"is undef"+r(1089));Object.assign(this[r(1627)],t),this["_endpoin"+r(1226)]=new zs(v,this[r(1627)][r(1248)+"es"]),this[r(419)+r(896)]=new ld(this[r(1627)]["pingLoss"+r(973)]),this[r(1627)]["automati"+r(805)]&&(this[r(1465)]=!0,this[r(283)]()),this[r(1627)][r(996)+r(189)+r(699)]&&(this[r(1231)+"T"]||this[r(396)+"X"]?this[r(1482)+r(1266)+r(370)]():this._isBrowser&&this[r(1306)+r(1380)+r(203)]())}[n(1463)+"nLine"](){let t=n;this._options[t(243)+t(1135)+"nect"]||this[t(1354)+t(720)]||this[t(784)+t(1341)]()}[n(1463)+n(295)](){let t=n;this._destroyWebSocket();let r=e[t(794)](ni,e[t(1127)],{message:e[t(1458)]});this[t(662)+t(192)+t(553)+"ct"]&&this["onStopIm"+t(192)+t(553)+"ct"](r)}[n(1306)+n(1380)+n(203)](){let t=n;this[t(1454)+"er"]&&window[t(524)+t(203)](e.RqARa,this[t(1463)+t(935)]),this[t(1454)+"er"]&&window.addEventListener(e[t(342)],this[t(1463)+"ffLine"]),this[t(1454)+"er"]&&window[t(524)+t(203)](e[t(702)],this._handlePageHide),this[t(1454)+"er"]&&window["addEvent"+t(203)](e[t(1524)],this._handlePageShow)}["_dropGlo"+n(1380)+n(203)](){let t=n;e[t(1237)](t(1396),t(1396))?(this._isBrowser&&window["removeEv"+t(696)+"ner"](e.RqARa,this[t(1463)+"nLine"]),this._isBrowser&&window[t(775)+t(696)+t(1562)](e[t(342)],this["_handleO"+t(295)]),this[t(1454)+"er"]&&window[t(775)+t(696)+"ner"](e.rlsms,this[t(1034)+t(940)]),this[t(1454)+"er"]&&window[t(775)+t(696)+t(1562)](e[t(1524)],this["_handleP"+t(444)])):(_0x32b09e.body[t(599)+"ild"](_0xeffc2f),_0x144056[t(180)+t(1059)]=void 0,e[t(639)](_0x679d98,_0x1953bb&&_0x15b204.msg||t(1228)+t(1539)))}["_handleP"+n(940)](t){let r=n;!t[r(873)+"d"]&&(this[r(1454)+"er"]&&window[r(775)+r(696)+r(1562)](e[r(702)],this["_handleP"+r(940)]),this[r(1454)+"er"]&&window[r(775)+r(696)+r(1562)](r(806),this["_handleP"+r(444)]),this[r(526)]()),this[r(1454)+"er"]&&window.removeEventListener(e.RqARa,this[r(1463)+"nLine"]),this._isBrowser&&window["removeEv"+r(696)+r(1562)](e.zlghY,this[r(1463)+"ffLine"])}[n(1034)+n(444)](t){let r=n;t[r(873)+"d"]&&(this._navigatorOnline()&&(!this[r(532)]||this._ws[r(1301)+"te"]!==this[r(988)]||e[r(920)](this._ws[r(1301)+"te"],this[r(1166)+"NG"]))&&this[r(1463)+"nLine"](),this._isBrowser&&window["addEvent"+r(203)](e[r(1381)],this[r(1463)+r(935)]),this[r(1454)+"er"]&&window[r(524)+r(203)](e[r(342)],this[r(1463)+"ffLine"]))}async[n(1259)+n(1674)](t){let r=n,{fpID:d,deviceID:f,bddID:p,ttwID:v,accessKey:y,aID:h,customParams:P={},enableAutoAck:D,enableQoS:M,QoSLevel:G,env:H}=this[r(1627)],xe,Pe,vt;this._isBrowser||this[r(396)+"X"]||this[r(1231)+"T"]?(xe=location&&e[r(1131)]("https:",location[r(1608)])?e.kVonv:e.yDGdG,Pe=t[r(832)](/((^ws)|(^http))((?:[s]*:\/\/))/,""),vt=/^wss(.*:\/\/)/[r(1180)](t)?t:""+xe+Pe):(xe=e[r(1610)],Pe=t[r(832)](/(^http)((?:[s]*:\/\/))/,""),vt=/(^ws)((?:[s]*:\/\/))/[r(1180)](Pe)?Pe:""+xe+Pe);let nt=p?e[r(357)]:v?e[r(379)]:e[r(1561)],ui=p||v||f;if(e.tXnnv(!ui,!nt))throw new Error(r(288)+"rovide b"+r(926)+r(308)+r(239));let Wd=e.dovjw==typeof P?await e[r(1218)](P):P,$d=H?xd(H[r(1644)],H[r(1428)]):{},fi=Object[r(405)]({device_platform:e.NZhvi,version_code:r(1230)+"0",access_key:y,fpid:d,aid:h,[nt]:ui,xsack:D?1:0,xaack:D?1:0,xsqos:M?1:0,qos_level:M?G:void 0,qos_sdk_version:2,...$d},Wd),Jd=Object[r(1300)](fi)[r(277)]((xi,li)=>fi[li]!==void 0?""+xi+(xi?"&":"?")+li+"="+fi[li]:xi,"");return vt+r(201)+Jd}async[n(283)](){let t=n;if(!(this[t(283)+"Lock"]||this[t(1354)+t(720)])){this[t(283)+t(678)]=!0;try{if(e.iYXYN(e.TObHJ,e[t(939)])){let r=this[t(455)+t(1226)]?.["checkCur"+t(1246)+t(1453)+t(518)+t(339)](),{timeoutInterval:d}=this[t(1627)];if(r){let p=this[t(455)+t(1226)]?.[t(389)+t(1578)+"nt"](),v=this[t(455)+t(1226)]?.[t(1683)+t(1385)+t(452)+t(1649)+"unt"](),y=this[t(455)+"tManager"]?.["getCurre"+t(1578)+"ntTriesCount"]();if(v){let h="connect "+p+(" timeout, max re"+t(512)+t(250)+"ill use backup e"+t(315))+v+" to retry",P=Me(t(856),{message:h,code:ft[t(1162)+t(475)+"R"]});this[t(847)](h),this["_dispatc"+t(1702)+t(715)](P),this[t(946)]=await this[t(1259)+t(1674)](v),this[t(847)](t(1154)+v+" "+y+" times"),this[t(316)+t(1337)+"rs"]()}else{let h="connect "+p+(t(1158)+t(890)+"tries re"+t(197));this._debug(h),this[t(1429)+"hErrorEv"+t(715)](e[t(1513)](Me,e[t(881)],{message:h,code:ft[t(1162)+t(475)+"R"]}));return}}else{let p=this[t(455)+t(1226)]?.["getCurrentEndpointAndUpd"+t(401)](),v=this["_endpoin"+t(1226)]?.[t(389)+t(1578)+t(187)+t(1686)]();this[t(946)]=await this[t(1259)+t(1674)](e[t(423)](p,"")),this._debug(t(1154)+p+" "+v+t(1329)),this[t(316)+"sListeners"]()}if(this[t(1465)])this[t(1465)]=!1;else{let p=ni(t(1277)+"t",{message:t(347)});this[t(1157)+t(1341)]&&this[t(1157)+t(1341)](p)}let f=this[t(455)+"tManager"]?.[t(389)+t(1578)+t(187)+"ount"]()||0;e.LJMNC(f,1)&&await this._wait(e.gNtRg(f,1)),this[t(847)](t(803)+t(417)+this[t(946)]+(t(1657)+t(684))+this[t(857)+"ls"]),this[t(532)]=e[t(469)](dd,{url:this._url,protocols:[this[t(857)+"ls"]],headers:this[t(1627)][t(1215)+t(1200)+"s"].customHttpHeader},this[t(1627)].ws),(this._isBrowser||this._isWorker)&&this[t(532)]&&(this[t(532)][t(297)+"pe"]=this[t(490)+t(600)]),this[t(249)+t(301)](),this["_connect"+t(1171)+"utId"]=e[t(1468)](setTimeout,this._onTimeout.bind(this),d)}else return}catch(r){throw this._connectLock=!1,r}}}["_clearTi"+n(1388)](){let t=n;e.ZIEHl(clearTimeout,this["_connect"+t(1171)+"utId"]),this["_connect"+t(1171)+"utId"]=null}[n(1044)+n(1383)](){let t=n;e[t(1074)](clearTimeout,this[t(1529)+t(1371)+"Id"]),e[t(391)](clearTimeout,this[t(1147)+"ctTimeou"+t(1318)]),this[t(1529)+t(1371)+"Id"]=null,this[t(1147)+t(188)+"tId"]=null}[n(847)](...t){let r=n,d={CBCOJ:r(1196)};e[r(1303)](e[r(1676)],r(640))?this._options[r(464)]&&console.log[r(1623)](console,[e[r(1073)],...t]):(this[r(532)]&&this[r(532)].send(_0x43df7f),this._debug(d[r(1464)],_0x47189b))}[n(1046)+n(1176)+"e"](t){let r=n,{initReconnectInterval:d,maxReconnectInterval:f,reconnectIntervalGrowFactor:p}=this[r(1627)],v=d*Math[r(1321)](p,t-1);return v>f?f:v}[n(535)](){let t=n;if(this[t(532)]&&this[t(532)][t(1301)+"te"]===this[t(1166)+"NG"]){this[t(1044)+"ngTimer"](),this[t(1529)+t(1371)+"Id"]=setTimeout(this._ping[t(1641)](this),this[t(1627)][t(1471)+t(783)]);return}if(!this._ws||this[t(532)][t(1301)+"te"]!==this[t(988)])return void this[t(784)+t(1341)]();this[t(532)]&&this[t(532)][t(1457)]("hi"),this[t(1147)+"ctTimeou"+t(1318)]=e[t(393)](setTimeout,this[t(784)+"econnect"+t(1660)].bind(this),this[t(1627)][t(384)+t(530)+t(978)])}[n(784)+n(1341)+n(1660)](){let t=n;this[t(419)+t(896)]?.[t(222)](),this.emit(t(731)+t(1403)+"t",e[t(703)]),this[t(419)+t(896)]?.checkReachMaxCount()?this[t(784)+t(1341)]():this._ping()}_navigatorOnline(){let t=n;return this[t(1231)+"T"]||this[t(396)+"X"]?this[t(1645)+"igatorOn"+t(421)]:(this[t(1454)+"er"]||this[t(1414)+"r"])&&this[t(1627)]["listenNe"+t(189)+t(699)]?navigator[t(900)]:!0}[n(784)+"econnect"](){let t=n;!this._navigatorOnline()||this["_readyCl"+t(720)]||(this["_endpoin"+t(1226)]?.[t(801)+t(184)+"fig"](),this[t(419)+t(896)]?.["resetCou"+t(1614)](),this[t(532)]?this[t(1568)+"ect"](1001,e[t(1363)],!0):this[t(283)]())}[n(1482)+n(1266)+n(370)](){let t=n,r={WTKTP:function(d,f){return e.UsLdv(d,f)},mhfnT:e[t(1597)]};this._isMiniTT?tt[t(612)+t(221)+"hange"](({isConnected:d})=>{let f=t;this[f(1645)+"igatorOnline"]=d,d?this["_handleO"+f(935)]():this[f(1463)+"ffLine"]()}):this[t(396)+"X"]&&wx[t(612)+t(221)+"hange"](({isConnected:d})=>{let f=t;if(r[f(1419)](r[f(1560)],r[f(1560)]))return f(180)+"_"+this[f(726)];this[f(1645)+"igatorOn"+f(421)]=d,d?this["_handleO"+f(935)]():this[f(1463)+f(295)]()})}[n(1273)](t){return new Promise(r=>{let d=K;setTimeout(r,this[d(1046)+d(1176)+"e"](t))})}[n(1568)+"ect"](t=1e3,r="",d=!1){let f=n;if(e[f(1202)]("ISZLo",e[f(1522)])){if(!this[f(532)])return;this[f(296)+f(698)+"t"](t,r,d)}else return this[f(395)][f(886)]}_onTimeout(){let t=n,r=this["_endpoin"+t(1226)]?.["getCurre"+t(1578)+"nt"]();this[t(847)](t(1154)+r+t(1158)),this[t(1568)+t(1572)](1001,t(1613)+t(1439)+t(501)+"g",!0)}[n(1316)](t){let r=n,d=e[r(1536)](_e,t);this._ws&&e[r(1229)](this._ws.readyState,this.OPEN)&&(this._ws&&this[r(532)].send(d),this[r(847)]("send_ack",t))}[n(316)+n(1337)+"rs"](){let t=n,r=e[t(216)][t(1449)]("|"),d=0;for(;;){switch(r[d++]){case"0":this[t(532)][t(775)+"entListe"+t(1562)](e[t(262)],this._onClose);continue;case"1":this._ws[t(775)+t(696)+t(1562)](e[t(292)],this[t(332)]);continue;case"2":if(!this[t(532)])return;continue;case"3":this[t(532)][t(775)+t(696)+t(1562)](e[t(1376)],this._onMessage);continue;case"4":this._ws[t(775)+t(696)+"ner"](e[t(881)],this[t(822)]);continue}break}}_addWsListeners(){let t=n,r=e[t(1225)][t(1449)]("|"),d=0;for(;;){switch(r[d++]){case"0":this[t(532)][t(524)+t(203)](t(367),this[t(332)]);continue;case"1":this[t(532)][t(524)+t(203)](e[t(1376)],this._onMessage);continue;case"2":this[t(532)][t(524)+t(203)](e[t(262)],this._onClose);continue;case"3":this[t(532)][t(524)+t(203)](e.pduzb,this._onError);continue;case"4":if(!this._ws)return;continue}break}}[n(580)+"nceClose"](t=1e3,r=""){let d=n;try{this[d(532)]&&this._ws[d(526)](t,r)}catch{}}["_destroy"+n(698)+"t"](t=1e3,r="",d=!1){let f=n;if(this["_clearPi"+f(1383)](),this[f(1129)+"mer"](),this[f(316)+f(1337)+"rs"](),this[f(580)+f(1348)](1e3,r),this[f(283)+f(678)]=!1,d&&this["_navigat"+f(1477)]()&&!this[f(1354)+f(720)]){if(this[f(455)+f(1226)]?.[f(618)+f(1336)+"es"]()){let v=this[f(455)+f(1226)]?.[f(389)+f(1578)+"nt"]();this["_dispatc"+f(402)+f(715)](Ue(e[f(262)],{code:1006,reason:f(1154)+v+(f(1158)+f(890)+"tries re"+f(197)),wasClean:!0}))}else{let v=this[f(1627)][f(1277)+f(1600)+"ptor"](t,r);this["_dispatc"+f(402)+f(715)](e[f(260)](Ue,e[f(262)],{code:t,reason:r,wasClean:!0,willReconnect:v})),v&&this[f(283)]()}return}this[f(1331)+f(1477)]()||this[f(1354)+f(720)]?this["_dispatc"+f(402)+f(715)](e.sMCzf(Ue,e[f(262)],{code:t,reason:e[f(275)]})):this[f(1429)+f(402)+f(715)](e[f(771)](Ue,e[f(262)],{code:1006,reason:e[f(1475)]})),this[f(532)]=null,this[f(455)+"tManager"]?.[f(801)+"pointCon"+f(276)](),this[f(419)+"sCounter"]?.[f(866)+f(1614)]()}["_dispatc"+n(477)+"nt"](t){let r=n;if(e[r(548)](r(247),e[r(492)])){let d=_0xa9d7d1[r(874)][r(683)];d&&_0x1cd48c[r(1605)+"rs"](d)}else this.emit(e.IDtzY,t),this[r(1198)]&&this[r(1198)](t)}[n(1429)+n(1312)+n(284)](t){let r=n;this.emit(r(874),t),this[r(983)+"e"]&&this.onmessage(t)}[n(1429)+n(1647)+n(1310)](t){let r=n;this[r(1244)](e[r(581)],t),this.onReceiveAck&&this[r(1061)+"eAck"](t)}[n(1429)+"hErrorEv"+n(715)](t){let r=n,d={sxTaU:function(f,p){return e[K(991)](f,p)},hSmIY:function(f,p){return f<p},SaiyC:function(f,p,v){return f(p,v)},COlEF:function(f,p){return f>>>p}};if(e.aiBDA!==e[r(1256)])this[r(1244)](r(856),t),this[r(1690)]&&this[r(1690)](t);else{let f=0,p=_0x226d85,v=wLMGwZ[r(1401)](_0x5748b4,4);for(;wLMGwZ[r(849)](p,v);){let{value:y,offset:h}=wLMGwZ[r(416)](_0x14981a,_0xb87589,p);p=h,f=wLMGwZ[r(1653)](f<<8,0),f+=y}return{value:f,offset:v}}}["_dispatc"+n(402)+n(715)](t){let r=n;this.emit(e[r(262)],t),this[r(830)]&&this[r(830)](t)}get[n(297)+"pe"](){let t=n;return this._ws?this[t(532)][t(297)+"pe"]:this[t(490)+t(600)]}set[n(297)+"pe"](t){let r=n;this["_binaryT"+r(600)]=t,this[r(532)]&&(this[r(532)][r(297)+"pe"]=t)}get retryCount(){let t=n;if(e.QmcpD(t(1525),e[t(845)]))return this["_endpoin"+t(1226)]?.[t(389)+t(1578)+t(187)+t(1686)]()||0;_0x2876ba=e[t(764)](_0x3a7624,_0x49820b),_0x15a644=0}get[n(927)+n(211)](){let t=n,r={UaunI:e[t(194)]};if(e[t(1308)](e[t(859)],e[t(859)]))this[t(532)]&&this[t(532)][t(1457)](_0x2980e8),this[t(847)](uChsMg[t(1279)],_0xab5856);else return this["_message"+t(1648)][t(277)]((f,p)=>(f+=p&&p.byteLength||0,f),0)+(this[t(532)]?this._ws[t(927)+"Amount"]:0)}get[n(1673)+"ns"](){let t=n;return this._ws?this[t(532)][t(1673)+"ns"]:""}get[n(1608)](){return this[n(532)]?this._ws.protocol:""}get[n(1301)+"te"](){let t=n;return e[t(659)](t(1589),t(594))?this._ws?this._ws[t(1301)+"te"]:this._options["automati"+t(805)]?this[t(1166)+"NG"]:this.CLOSED:this[t(395)].readyState}get[n(886)](){let t=n,r={QxEHl:function(d,f,p){return e[K(1334)](d,f,p)},HGhzY:e.dTVjI,YTvGm:t(661)};if(e[t(811)](e[t(672)],e[t(692)]))return this[t(532)]?this[t(532)][t(886)]:this._url;if(this[t(1044)+t(1383)](),this[t(1129)+t(1388)](),this[t(316)+t(1337)+"rs"](),this[t(580)+"nceClose"](1e3,_0x4e020b),this[t(283)+t(678)]=!1,_0x4a493f&&this[t(1331)+t(1477)]()&&!this[t(1354)+t(720)]){if(this["_endpoin"+t(1226)]?.[t(618)+t(1336)+"es"]()){let f=this[t(455)+"tManager"]?.[t(389)+t(1578)+"nt"]();this[t(1429)+t(402)+"ent"](qMAKel[t(707)](_0x29b2b2,qMAKel[t(711)],{code:1006,reason:t(1154)+f+(t(1158)+t(890)+t(512)+t(197)),wasClean:!0}))}else{let f=this._options[t(1277)+t(1600)+t(237)](_0x5918f9,_0x5fb21d);this[t(1429)+t(402)+t(715)](qMAKel.QxEHl(_0x3d66d5,qMAKel.HGhzY,{code:_0x1df2c7,reason:_0xec93ae,wasClean:!0,willReconnect:f})),f&&this[t(283)]()}return}this[t(1331)+"orOnline"]()||this[t(1354)+t(720)]?this[t(1429)+t(402)+t(715)](qMAKel[t(707)](_0x26afcf,qMAKel.HGhzY,{code:_0x4462a0,reason:qMAKel[t(1495)]})):this[t(1429)+t(402)+"ent"](qMAKel[t(707)](_0x5a8639,"close",{code:1006,reason:t(827)+t(1672)+t(648)+t(206)})),this[t(532)]=null,this["_endpoin"+t(1226)]?.[t(801)+t(184)+t(276)](),this[t(419)+t(896)]?.[t(866)+t(1614)]()}[n(526)](t=1e3,r){let d=n;if(e[d(1270)]("ZhqXO",d(1094)))_0x2566a5+=_0x5c3e57(_0x2d608f),_0x45b942++;else{let f=(d(750)+d(1082)).split("|"),p=0;for(;;){switch(f[p++]){case"0":this[d(1354)+"osed"]=!0;continue;case"1":this[d(296)+d(698)+"t"](t,r);continue;case"2":if(this[d(532)][d(1301)+"te"]===this[d(1153)]||e.wfrWE(this[d(532)][d(1301)+"te"],this[d(1032)]))return void this[d(847)](e[d(738)]);continue;case"3":this[d(1129)+d(1388)]();continue;case"4":this["_clearPi"+d(1383)]();continue;case"5":this[d(1421)+d(802)]?.[d(349)]();continue;case"6":if(!this._ws)return void this[d(847)](e.CILJz);continue;case"7":this["_dropGlo"+d(1380)+d(203)]();continue}break}}}async[n(1457)](t,r){let d=n,f={Mkjzb:function(vt,nt){return e[K(1136)](vt,nt)}};if(e[d(1469)](null,t))throw new Error("please provide a valid d"+d(493)+d(571)+d(209)+d(228)+d(1635)+d(445));e.Cafmx(e[d(848)],typeof t)&&(t=JSON[d(354)+"y"](t)),e[d(949)](e[d(280)],typeof t)&&!e[d(609)](t,ArrayBuffer)&&!(t[d(1487)]&&t.buffer instanceof ArrayBuffer)&&(t=JSON[d(354)+"y"](t));let p=await Hs(t),v=e[d(674)](fd,t),{method:y=0,service:h=this[d(1627)][d(529)],logID:P=this[d(1627)].logIDGenerator(),headers:D=this._options[d(1512)],payloadEncoding:M=this[d(1627)][d(914)+"ncoding"],payloadType:G=this[d(1627)]["payloadT"+d(600)],logIDNew:H=this[d(1627)][d(1122)+d(457)][d(1618)+"toGenera"+d(1384)+"ew"]?e[d(787)](o,this[d(1627)][d(1122)+"Config"][d(1169)]):""}=e[d(1559)](r,{});if(!h)throw new Error(e[d(773)]);let xe={SeqID:ne[d(1006)+"er"](this[d(1085)]++),LogID:ne[d(1006)+"er"](P),service:h,method:y,headers:D,payloadEncoding:e[d(779)](M,Object)?M[d(1517)]?M.encoding:"":M,payloadType:e.qhwMO(G,Object)?G[d(622)]?G[d(622)]:v:G||v,payload:p,LogIDNew:H},Pe=e[d(351)](_e,xe);if(this[d(532)]&&e[d(1260)](this[d(532)][d(1301)+"te"],this.OPEN))if(e.qUVRJ!==e.gFADA)this[d(532)]&&this[d(532)][d(1457)](Pe),this._debug(e.oUDNb,xe);else return _0x374961&&(_0x5a51c6=(0,_0x31db64[UJZXkB.Mkjzb(_0x169851,_0x413957)[0]])(_0x5e1200=0)),_0x265b75;else e.JuxWY(this[d(793)+d(1648)].length,this[d(1627)][d(573)+d(923)+"ength"])?d(566)===e[d(1011)]?(this["_message"+d(1648)][d(383)](Pe),this[d(847)](e.yOVHH,xe)):(_0x155b31=_0x57124a[e[d(1626)](_0x14696b+_0x21876f,1)],_0x5eff4e=_0x5359c2[e[d(240)](e.VgCPz(_0xe16cf3,_0x2d9325),2)],e[d(986)](e.QppNY(e[d(1164)](_0x1d761e,_0x10908b<<8),49344),32896)?_0x4c2486+=_0x4081f0:(_0x1a8a74=e[d(636)](e[d(1430)](15,_0x1fa000)<<12,(63&_0x290353)<<6)|e[d(1577)](63,_0x35a476),e[d(967)](_0x58ca3b,2048)||_0x5e8119>=55296&&_0x284683<=57343?_0xb1362b+=_0x31f83a:(_0x28a546+=_0xbad205(_0x46c524),_0x5b1399+=2))):(this[d(793)+"Queue"][d(331)](),this["_message"+d(1648)][d(383)](Pe));return{seqID:this[d(1085)],logID:P,logIDNew:H}}async[n(1277)+"t"](t){let r=n,{url:d}=e.CXFhT(t,{}),f=Array.isArray(d)?d:e[r(877)](e[r(280)],typeof d)?[d]:[];t&&Object[r(405)](this._options,t),f&&f[r(1241)]?this["_endpoin"+r(1226)]=new zs(f,this._options[r(1248)+"es"]):this[r(455)+r(1226)]?.["resetEndpointCon"+r(276)](),this[r(419)+"sCounter"]?.[r(866)+r(1614)](this[r(1627)][r(227)+"Count"]),this[r(1354)+"osed"]=!1,this[r(532)]&&e[r(1496)](this[r(532)][r(1301)+"te"],this[r(1153)])?this[r(1568)+r(1572)](1e3,e[r(1480)],!0):(this[r(1465)]=!0,this._connect())}async[n(1677)](){let t=n;if(!this[t(283)+t(678)]){let r=e[t(1062)][t(1449)]("|"),d=0;for(;;){switch(r[d++]){case"0":this[t(419)+t(896)]?.[t(866)+"nter"]();continue;case"1":this[t(283)]();continue;case"2":this[t(1465)]=!0;continue;case"3":this[t(455)+t(1226)]?.[t(801)+t(184)+t(276)]();continue;case"4":this[t(1354)+t(720)]=!1;continue}break}}}[n(524)+n(203)](t,r){this.on(t,r)}[n(1488)+"Event"](t){let r=n,d={DoOFA:function(f,p){return f|p},fXbGZ:function(f,p){return e[K(1095)](f,p)},GOrUH:function(f,p){return e[K(1514)](f,p)},QRGaB:function(f,p){return e[K(509)](f,p)},aPbUY:function(f,p){return e[K(1296)](f,p)}};if(e[r(1518)](e[r(1056)],r(929))){let{type:f}=t;this.emit(f,t)}else return new _0x4ffcf6(aWiCCI[r(525)](_0x3e037e[0]|_0x2a7342[1]<<8,aWiCCI[r(181)](_0x32f19e[2],16))|aWiCCI.GOrUH(_0x1879ea[3],24),aWiCCI.QRGaB(_0x1e8940[4]|_0x470db3[5]<<8,_0x5c2ec8[6]<<16)|aWiCCI.aPbUY(_0x5c1717[7],24),_0x2f735b)}[n(775)+n(696)+n(1562)](t,r){this.off(t,r)}pingOnce(){let t=n,r={KHqDT:function(d,f){return e[K(986)](d,f)},pJqTF:e.dILMS,xDwII:"Iwawl",tAZac:e[t(234)],rtmOT:e.pduzb,EDqhl:function(d,f){return d===f},ydSve:e[t(1079)],PwLUZ:e.eCjZl,batCA:e.ZxPYm,qFbBs:function(d,f,p){return d(f,p)}};return new Promise((d,f)=>{let p=t,v={vCDVE:r[p(531)],zrEnA:function(P,D){return r[p(366)](P,D)},smRIB:p(1305),dJQIP:r[p(1009)],mzDht:r[p(668)],PHytg:r[p(611)],PAcuN:r[p(1631)]};this[p(1044)+p(1383)](),this[p(1529)+p(1371)+"Id"]=r[p(1423)](setTimeout,this[p(535)][p(1641)](this),this[p(1627)].pingInterval);let y=()=>{let P=p;if(v[P(1328)](v[P(1634)],v[P(374)])){let D=P(1154)+_0x1cc578+(P(1158)+P(890)+P(512)+P(197));this[P(847)](D),this[P(1429)+P(1702)+P(715)](_0x2a4d31(GpVvPp[P(931)],{message:D,code:_0x231ee8[P(1162)+P(475)+"R"]}));return}else d(v[P(369)]),this[P(267)](v[P(569)],y),this.off(v[P(272)],h)},h=()=>{let P=p,D={afeeW:P(526)};r[P(1639)](r[P(591)],r[P(1691)])?(f(P(724)),this.off(r[P(611)],y),this[P(267)]("ping_onc"+P(1403)+"t",h)):this[P(1244)](gfoOCn[P(1558)],_0x1708d6(gfoOCn.afeeW,{..._0x57157c}))};this.on(r.tAZac,y),this.on(p(731)+p(1403)+"t",h),this[p(535)]()})}}})(),fe["CustomCl"+O(863)]=pe[O(1271)+O(863)],fe[O(1163)+"rorEvent"]=pe[O(1163)+O(1700)],fe[O(1148)+"e"]=pe.ErrorCode,fe[O(284)]=pe[O(284)],fe[O(258)]=pe.FWS,fe[O(270)+O(1219)+O(673)]=pe[O(270)+O(1219)+O(673)],fe[O(1219)+O(673)]=pe[O(1219)+O(673)],fe[O(1347)+"t"]=pe[O(1347)+"t"],fe[O(1412)+O(1021)]=pe["Reconnec"+O(1021)],fe[O(398)+O(863)]=pe[O(398)+"oseEvent"],fe[O(632)+O(1700)]=pe[O(632)+O(1700)],fe[O(1407)+O(1408)+"nt"]=pe[O(1407)+"ssageEvent"],fe[O(1039)+"enEvent"]=pe[O(1039)+O(747)],fe[O(1165)+O(418)+O(673)]=pe["createRe"+O(418)+O(673)],fe[O(1478)+O(786)]=pe["decodedF"+O(786)],fe[O(268)+O(1320)]=pe[O(268)+"ame"];for(yr in pe)[O(1271)+O(863),O(1163)+"rorEvent",O(1148)+"e",O(284),O(258),"Frontier"+O(1219)+"vent",O(1219)+O(673),O(1347)+"t","Reconnec"+O(1021),O(398)+O(863),O(632)+O(1700),O(1407)+O(1408)+"nt",O(1039)+O(747),"createRe"+O(418)+O(673),O(1478)+O(786),"encodeFr"+O(1320)][O(1187)](yr)===-1&&(fe[yr]=pe[yr]);var yr;Object.defineProperty(fe,"__esModule",{value:!0})});var st=Q((xy,mc)=>{"use strict";var hc=["nodebuffer","arraybuffer","fragments"],pc=typeof Blob<"u";pc&&hc.push("blob");mc.exports={BINARY_TYPES:hc,CLOSE_TIMEOUT:3e4,EMPTY_BUFFER:Buffer.alloc(0),GUID:"258EAFA5-E914-47DA-95CA-C5AB0DC85B11",hasBlob:pc,kForOnEventAttribute:Symbol("kIsForOnEventAttribute"),kListener:Symbol("kListener"),kStatusCode:Symbol("status-code"),kWebSocket:Symbol("websocket"),NOOP:()=>{}}});var An=Q((ly,Cr)=>{"use strict";var{EMPTY_BUFFER:Jl}=st(),Ki=Buffer[Symbol.species];function Vl(n,e){if(n.length===0)return Jl;if(n.length===1)return n[0];let i=Buffer.allocUnsafe(e),o=0;for(let a=0;a<n.length;a++){let c=n[a];i.set(c,o),o+=c.length}return o<e?new Ki(i.buffer,i.byteOffset,o):i}function wc(n,e,i,o,a){for(let c=0;c<a;c++)i[o+c]=n[c]^e[c&3]}function _c(n,e){for(let i=0;i<n.length;i++)n[i]^=e[i&3]}function Zl(n){return n.length===n.buffer.byteLength?n.buffer:n.buffer.slice(n.byteOffset,n.byteOffset+n.length)}function Wi(n){if(Wi.readOnly=!0,Buffer.isBuffer(n))return n;let e;return n instanceof ArrayBuffer?e=new Ki(n):ArrayBuffer.isView(n)?e=new Ki(n.buffer,n.byteOffset,n.byteLength):(e=Buffer.from(n),Wi.readOnly=!1),e}Cr.exports={concat:Vl,mask:wc,toArrayBuffer:Zl,toBuffer:Wi,unmask:_c};if(!process.env.WS_NO_BUFFER_UTIL)try{let n=re("bufferutil");Cr.exports.mask=function(e,i,o,a,c){c<48?wc(e,i,o,a,c):n.mask(e,i,o,a,c)},Cr.exports.unmask=function(e,i){e.length<32?_c(e,i):n.unmask(e,i)}}catch{}});var bc=Q((gy,Ec)=>{"use strict";var yc=Symbol("kDone"),$i=Symbol("kRun"),Ji=class{constructor(e){this[yc]=()=>{this.pending--,this[$i]()},this.concurrency=e||1/0,this.jobs=[],this.pending=0}add(e){this.jobs.push(e),this[$i]()}[$i](){if(this.pending!==this.concurrency&&this.jobs.length){let e=this.jobs.shift();this.pending++,e(this[yc])}}};Ec.exports=Ji});var en=Q((hy,Ac)=>{"use strict";var Cn=re("zlib"),vc=An(),Yl=bc(),{kStatusCode:Sc}=st(),Xl=Buffer[Symbol.species],Ql=Buffer.from([0,0,255,255]),Dr=Symbol("permessage-deflate"),ot=Symbol("total-length"),Xt=Symbol("callback"),_t=Symbol("buffers"),Qt=Symbol("error"),Tr,Vi=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,!Tr){let i=this._options.concurrencyLimit!==void 0?this._options.concurrencyLimit:10;Tr=new Yl(i)}}static get extensionName(){return"permessage-deflate"}offer(){let e={};return this._options.serverNoContextTakeover&&(e.server_no_context_takeover=!0),this._options.clientNoContextTakeover&&(e.client_no_context_takeover=!0),this._options.serverMaxWindowBits&&(e.server_max_window_bits=this._options.serverMaxWindowBits),this._options.clientMaxWindowBits?e.client_max_window_bits=this._options.clientMaxWindowBits:this._options.clientMaxWindowBits==null&&(e.client_max_window_bits=!0),e}accept(e){return e=this.normalizeParams(e),this.params=this._isServer?this.acceptAsServer(e):this.acceptAsClient(e),this.params}cleanup(){if(this._inflate&&(this._inflate.close(),this._inflate=null),this._deflate){let e=this._deflate[Xt];this._deflate.close(),this._deflate=null,e&&e(new Error("The deflate stream was closed while data was being processed"))}}acceptAsServer(e){let i=this._options,o=e.find(a=>!(i.serverNoContextTakeover===!1&&a.server_no_context_takeover||a.server_max_window_bits&&(i.serverMaxWindowBits===!1||typeof i.serverMaxWindowBits=="number"&&i.serverMaxWindowBits>a.server_max_window_bits)||typeof i.clientMaxWindowBits=="number"&&!a.client_max_window_bits));if(!o)throw new Error("None of the extension offers can be accepted");return i.serverNoContextTakeover&&(o.server_no_context_takeover=!0),i.clientNoContextTakeover&&(o.client_no_context_takeover=!0),typeof i.serverMaxWindowBits=="number"&&(o.server_max_window_bits=i.serverMaxWindowBits),typeof i.clientMaxWindowBits=="number"?o.client_max_window_bits=i.clientMaxWindowBits:(o.client_max_window_bits===!0||i.clientMaxWindowBits===!1)&&delete o.client_max_window_bits,o}acceptAsClient(e){let i=e[0];if(this._options.clientNoContextTakeover===!1&&i.client_no_context_takeover)throw new Error('Unexpected parameter "client_no_context_takeover"');if(!i.client_max_window_bits)typeof this._options.clientMaxWindowBits=="number"&&(i.client_max_window_bits=this._options.clientMaxWindowBits);else if(this._options.clientMaxWindowBits===!1||typeof this._options.clientMaxWindowBits=="number"&&i.client_max_window_bits>this._options.clientMaxWindowBits)throw new Error('Unexpected or invalid parameter "client_max_window_bits"');return i}normalizeParams(e){return e.forEach(i=>{Object.keys(i).forEach(o=>{let a=i[o];if(a.length>1)throw new Error(`Parameter "${o}" must have only a single value`);if(a=a[0],o==="client_max_window_bits"){if(a!==!0){let c=+a;if(!Number.isInteger(c)||c<8||c>15)throw new TypeError(`Invalid value for parameter "${o}": ${a}`);a=c}else if(!this._isServer)throw new TypeError(`Invalid value for parameter "${o}": ${a}`)}else if(o==="server_max_window_bits"){let c=+a;if(!Number.isInteger(c)||c<8||c>15)throw new TypeError(`Invalid value for parameter "${o}": ${a}`);a=c}else if(o==="client_no_context_takeover"||o==="server_no_context_takeover"){if(a!==!0)throw new TypeError(`Invalid value for parameter "${o}": ${a}`)}else throw new Error(`Unknown parameter "${o}"`);i[o]=a})}),e}decompress(e,i,o){Tr.add(a=>{this._decompress(e,i,(c,u)=>{a(),o(c,u)})})}compress(e,i,o){Tr.add(a=>{this._compress(e,i,(c,u)=>{a(),o(c,u)})})}_decompress(e,i,o){let a=this._isServer?"client":"server";if(!this._inflate){let c=`${a}_max_window_bits`,u=typeof this.params[c]!="number"?Cn.Z_DEFAULT_WINDOWBITS:this.params[c];this._inflate=Cn.createInflateRaw({...this._options.zlibInflateOptions,windowBits:u}),this._inflate[Dr]=this,this._inflate[ot]=0,this._inflate[_t]=[],this._inflate.on("error",tg),this._inflate.on("data",Ic)}this._inflate[Xt]=o,this._inflate.write(e),i&&this._inflate.write(Ql),this._inflate.flush(()=>{let c=this._inflate[Qt];if(c){this._inflate.close(),this._inflate=null,o(c);return}let u=vc.concat(this._inflate[_t],this._inflate[ot]);this._inflate._readableState.endEmitted?(this._inflate.close(),this._inflate=null):(this._inflate[ot]=0,this._inflate[_t]=[],i&&this.params[`${a}_no_context_takeover`]&&this._inflate.reset()),o(null,u)})}_compress(e,i,o){let a=this._isServer?"server":"client";if(!this._deflate){let c=`${a}_max_window_bits`,u=typeof this.params[c]!="number"?Cn.Z_DEFAULT_WINDOWBITS:this.params[c];this._deflate=Cn.createDeflateRaw({...this._options.zlibDeflateOptions,windowBits:u}),this._deflate[ot]=0,this._deflate[_t]=[],this._deflate.on("data",eg)}this._deflate[Xt]=o,this._deflate.write(e),this._deflate.flush(Cn.Z_SYNC_FLUSH,()=>{if(!this._deflate)return;let c=vc.concat(this._deflate[_t],this._deflate[ot]);i&&(c=new Xl(c.buffer,c.byteOffset,c.length-4)),this._deflate[Xt]=null,this._deflate[ot]=0,this._deflate[_t]=[],i&&this.params[`${a}_no_context_takeover`]&&this._deflate.reset(),o(null,c)})}};Ac.exports=Vi;function eg(n){this[_t].push(n),this[ot]+=n.length}function Ic(n){if(this[ot]+=n.length,this[Dr]._maxPayload<1||this[ot]<=this[Dr]._maxPayload){this[_t].push(n);return}this[Qt]=new RangeError("Max payload size exceeded"),this[Qt].code="WS_ERR_UNSUPPORTED_MESSAGE_LENGTH",this[Qt][Sc]=1009,this.removeListener("data",Ic),this.reset()}function tg(n){if(this[Dr]._inflate=null,this[Qt]){this[Xt](this[Qt]);return}n[Sc]=1007,this[Xt](n)}});var tn=Q((py,Pr)=>{"use strict";var{isUtf8:Cc}=re("buffer"),{hasBlob:ng}=st(),rg=[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 ig(n){return n>=1e3&&n<=1014&&n!==1004&&n!==1005&&n!==1006||n>=3e3&&n<=4999}function Zi(n){let e=n.length,i=0;for(;i<e;)if((n[i]&128)===0)i++;else if((n[i]&224)===192){if(i+1===e||(n[i+1]&192)!==128||(n[i]&254)===192)return!1;i+=2}else if((n[i]&240)===224){if(i+2>=e||(n[i+1]&192)!==128||(n[i+2]&192)!==128||n[i]===224&&(n[i+1]&224)===128||n[i]===237&&(n[i+1]&224)===160)return!1;i+=3}else if((n[i]&248)===240){if(i+3>=e||(n[i+1]&192)!==128||(n[i+2]&192)!==128||(n[i+3]&192)!==128||n[i]===240&&(n[i+1]&240)===128||n[i]===244&&n[i+1]>143||n[i]>244)return!1;i+=4}else return!1;return!0}function sg(n){return ng&&typeof n=="object"&&typeof n.arrayBuffer=="function"&&typeof n.type=="string"&&typeof n.stream=="function"&&(n[Symbol.toStringTag]==="Blob"||n[Symbol.toStringTag]==="File")}Pr.exports={isBlob:sg,isValidStatusCode:ig,isValidUTF8:Zi,tokenChars:rg};if(Cc)Pr.exports.isValidUTF8=function(n){return n.length<24?Zi(n):Cc(n)};else if(!process.env.WS_NO_UTF_8_VALIDATE)try{let n=re("utf-8-validate");Pr.exports.isValidUTF8=function(e){return e.length<32?Zi(e):n(e)}}catch{}});var ts=Q((my,Lc)=>{"use strict";var{Writable:og}=re("stream"),Tc=en(),{BINARY_TYPES:ag,EMPTY_BUFFER:Dc,kStatusCode:cg,kWebSocket:dg}=st(),{concat:Yi,toArrayBuffer:ug,unmask:fg}=An(),{isValidStatusCode:xg,isValidUTF8:Pc}=tn(),kr=Buffer[Symbol.species],ze=0,kc=1,Rc=2,Nc=3,Xi=4,Qi=5,Rr=6,es=class extends og{constructor(e={}){super(),this._allowSynchronousEvents=e.allowSynchronousEvents!==void 0?e.allowSynchronousEvents:!0,this._binaryType=e.binaryType||ag[0],this._extensions=e.extensions||{},this._isServer=!!e.isServer,this._maxPayload=e.maxPayload|0,this._skipUTF8Validation=!!e.skipUTF8Validation,this[dg]=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=ze}_write(e,i,o){if(this._opcode===8&&this._state==ze)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 kr(o.buffer,o.byteOffset+e,o.length-e),new kr(o.buffer,o.byteOffset,e)}let i=Buffer.allocUnsafe(e);do{let o=this._buffers[0],a=i.length-e;e>=o.length?i.set(this._buffers.shift(),a):(i.set(new Uint8Array(o.buffer,o.byteOffset,e),a),this._buffers[0]=new kr(o.buffer,o.byteOffset+e,o.length-e)),e-=o.length}while(e>0);return i}startLoop(e){this._loop=!0;do switch(this._state){case ze:this.getInfo(e);break;case kc:this.getPayloadLength16(e);break;case Rc:this.getPayloadLength64(e);break;case Nc:this.getMask();break;case Xi:this.getData(e);break;case Qi:case Rr:this._loop=!1;return}while(this._loop);this._errored||e()}getInfo(e){if(this._bufferedBytes<2){this._loop=!1;return}let i=this.consume(2);if((i[0]&48)!==0){let a=this.createError(RangeError,"RSV2 and RSV3 must be clear",!0,1002,"WS_ERR_UNEXPECTED_RSV_2_3");e(a);return}let o=(i[0]&64)===64;if(o&&!this._extensions[Tc.extensionName]){let a=this.createError(RangeError,"RSV1 must be clear",!0,1002,"WS_ERR_UNEXPECTED_RSV_1");e(a);return}if(this._fin=(i[0]&128)===128,this._opcode=i[0]&15,this._payloadLength=i[1]&127,this._opcode===0){if(o){let a=this.createError(RangeError,"RSV1 must be clear",!0,1002,"WS_ERR_UNEXPECTED_RSV_1");e(a);return}if(!this._fragmented){let a=this.createError(RangeError,"invalid opcode 0",!0,1002,"WS_ERR_INVALID_OPCODE");e(a);return}this._opcode=this._fragmented}else if(this._opcode===1||this._opcode===2){if(this._fragmented){let a=this.createError(RangeError,`invalid opcode ${this._opcode}`,!0,1002,"WS_ERR_INVALID_OPCODE");e(a);return}this._compressed=o}else if(this._opcode>7&&this._opcode<11){if(!this._fin){let a=this.createError(RangeError,"FIN must be set",!0,1002,"WS_ERR_EXPECTED_FIN");e(a);return}if(o){let a=this.createError(RangeError,"RSV1 must be clear",!0,1002,"WS_ERR_UNEXPECTED_RSV_1");e(a);return}if(this._payloadLength>125||this._opcode===8&&this._payloadLength===1){let a=this.createError(RangeError,`invalid payload length ${this._payloadLength}`,!0,1002,"WS_ERR_INVALID_CONTROL_PAYLOAD_LENGTH");e(a);return}}else{let a=this.createError(RangeError,`invalid opcode ${this._opcode}`,!0,1002,"WS_ERR_INVALID_OPCODE");e(a);return}if(!this._fin&&!this._fragmented&&(this._fragmented=this._opcode),this._masked=(i[1]&128)===128,this._isServer){if(!this._masked){let a=this.createError(RangeError,"MASK must be set",!0,1002,"WS_ERR_EXPECTED_MASK");e(a);return}}else if(this._masked){let a=this.createError(RangeError,"MASK must be clear",!0,1002,"WS_ERR_UNEXPECTED_MASK");e(a);return}this._payloadLength===126?this._state=kc:this._payloadLength===127?this._state=Rc:this.haveLength(e)}getPayloadLength16(e){if(this._bufferedBytes<2){this._loop=!1;return}this._payloadLength=this.consume(2).readUInt16BE(0),this.haveLength(e)}getPayloadLength64(e){if(this._bufferedBytes<8){this._loop=!1;return}let i=this.consume(8),o=i.readUInt32BE(0);if(o>Math.pow(2,21)-1){let a=this.createError(RangeError,"Unsupported WebSocket frame: payload length > 2^53 - 1",!1,1009,"WS_ERR_UNSUPPORTED_DATA_PAYLOAD_LENGTH");e(a);return}this._payloadLength=o*Math.pow(2,32)+i.readUInt32BE(4),this.haveLength(e)}haveLength(e){if(this._payloadLength&&this._opcode<8&&(this._totalPayloadLength+=this._payloadLength,this._totalPayloadLength>this._maxPayload&&this._maxPayload>0)){let i=this.createError(RangeError,"Max payload size exceeded",!1,1009,"WS_ERR_UNSUPPORTED_MESSAGE_LENGTH");e(i);return}this._masked?this._state=Nc:this._state=Xi}getMask(){if(this._bufferedBytes<4){this._loop=!1;return}this._mask=this.consume(4),this._state=Xi}getData(e){let i=Dc;if(this._payloadLength){if(this._bufferedBytes<this._payloadLength){this._loop=!1;return}i=this.consume(this._payloadLength),this._masked&&(this._mask[0]|this._mask[1]|this._mask[2]|this._mask[3])!==0&&fg(i,this._mask)}if(this._opcode>7){this.controlMessage(i,e);return}if(this._compressed){this._state=Qi,this.decompress(i,e);return}i.length&&(this._messageLength=this._totalPayloadLength,this._fragments.push(i)),this.dataMessage(e)}decompress(e,i){this._extensions[Tc.extensionName].decompress(e,this._fin,(a,c)=>{if(a)return i(a);if(c.length){if(this._messageLength+=c.length,this._messageLength>this._maxPayload&&this._maxPayload>0){let u=this.createError(RangeError,"Max payload size exceeded",!1,1009,"WS_ERR_UNSUPPORTED_MESSAGE_LENGTH");i(u);return}this._fragments.push(c)}this.dataMessage(i),this._state===ze&&this.startLoop(i)})}dataMessage(e){if(!this._fin){this._state=ze;return}let i=this._messageLength,o=this._fragments;if(this._totalPayloadLength=0,this._messageLength=0,this._fragmented=0,this._fragments=[],this._opcode===2){let a;this._binaryType==="nodebuffer"?a=Yi(o,i):this._binaryType==="arraybuffer"?a=ug(Yi(o,i)):this._binaryType==="blob"?a=new Blob(o):a=o,this._allowSynchronousEvents?(this.emit("message",a,!0),this._state=ze):(this._state=Rr,setImmediate(()=>{this.emit("message",a,!0),this._state=ze,this.startLoop(e)}))}else{let a=Yi(o,i);if(!this._skipUTF8Validation&&!Pc(a)){let c=this.createError(Error,"invalid UTF-8 sequence",!0,1007,"WS_ERR_INVALID_UTF8");e(c);return}this._state===Qi||this._allowSynchronousEvents?(this.emit("message",a,!1),this._state=ze):(this._state=Rr,setImmediate(()=>{this.emit("message",a,!1),this._state=ze,this.startLoop(e)}))}}controlMessage(e,i){if(this._opcode===8){if(e.length===0)this._loop=!1,this.emit("conclude",1005,Dc),this.end();else{let o=e.readUInt16BE(0);if(!xg(o)){let c=this.createError(RangeError,`invalid status code ${o}`,!0,1002,"WS_ERR_INVALID_CLOSE_CODE");i(c);return}let a=new kr(e.buffer,e.byteOffset+2,e.length-2);if(!this._skipUTF8Validation&&!Pc(a)){let c=this.createError(Error,"invalid UTF-8 sequence",!0,1007,"WS_ERR_INVALID_UTF8");i(c);return}this._loop=!1,this.emit("conclude",o,a),this.end()}this._state=ze;return}this._allowSynchronousEvents?(this.emit(this._opcode===9?"ping":"pong",e),this._state=ze):(this._state=Rr,setImmediate(()=>{this.emit(this._opcode===9?"ping":"pong",e),this._state=ze,this.startLoop(i)}))}createError(e,i,o,a,c){this._loop=!1,this._errored=!0;let u=new e(o?`Invalid WebSocket frame: ${i}`:i);return Error.captureStackTrace(u,this.createError),u.code=c,u[cg]=a,u}};Lc.exports=es});var is=Q((_y,Bc)=>{"use strict";var{Duplex:wy}=re("stream"),{randomFillSync:lg}=re("crypto"),Oc=en(),{EMPTY_BUFFER:gg,kWebSocket:hg,NOOP:pg}=st(),{isBlob:nn,isValidStatusCode:mg}=tn(),{mask:Mc,toBuffer:At}=An(),Fe=Symbol("kByteLength"),wg=Buffer.alloc(4),Nr=8*1024,Ct,rn=Nr,qe=0,_g=1,yg=2,ns=class n{constructor(e,i,o){this._extensions=i||{},o&&(this._generateMask=o,this._maskBuffer=Buffer.alloc(4)),this._socket=e,this._firstFragment=!0,this._compress=!1,this._bufferedBytes=0,this._queue=[],this._state=qe,this.onerror=pg,this[hg]=void 0}static frame(e,i){let o,a=!1,c=2,u=!1;i.mask&&(o=i.maskBuffer||wg,i.generateMask?i.generateMask(o):(rn===Nr&&(Ct===void 0&&(Ct=Buffer.alloc(Nr)),lg(Ct,0,Nr),rn=0),o[0]=Ct[rn++],o[1]=Ct[rn++],o[2]=Ct[rn++],o[3]=Ct[rn++]),u=(o[0]|o[1]|o[2]|o[3])===0,c=6);let x;typeof e=="string"?(!i.mask||u)&&i[Fe]!==void 0?x=i[Fe]:(e=Buffer.from(e),x=e.length):(x=e.length,a=i.mask&&i.readOnly&&!u);let l=x;x>=65536?(c+=8,l=127):x>125&&(c+=2,l=126);let g=Buffer.allocUnsafe(a?x+c:c);return g[0]=i.fin?i.opcode|128:i.opcode,i.rsv1&&(g[0]|=64),g[1]=l,l===126?g.writeUInt16BE(x,2):l===127&&(g[2]=g[3]=0,g.writeUIntBE(x,4,6)),i.mask?(g[1]|=128,g[c-4]=o[0],g[c-3]=o[1],g[c-2]=o[2],g[c-1]=o[3],u?[g,e]:a?(Mc(e,o,g,c,x),[g]):(Mc(e,o,e,0,x),[g,e])):[g,e]}close(e,i,o,a){let c;if(e===void 0)c=gg;else{if(typeof e!="number"||!mg(e))throw new TypeError("First argument must be a valid error code number");if(i===void 0||!i.length)c=Buffer.allocUnsafe(2),c.writeUInt16BE(e,0);else{let x=Buffer.byteLength(i);if(x>123)throw new RangeError("The message must not be greater than 123 bytes");c=Buffer.allocUnsafe(2+x),c.writeUInt16BE(e,0),typeof i=="string"?c.write(i,2):c.set(i,2)}}let u={[Fe]:c.length,fin:!0,generateMask:this._generateMask,mask:o,maskBuffer:this._maskBuffer,opcode:8,readOnly:!1,rsv1:!1};this._state!==qe?this.enqueue([this.dispatch,c,!1,u,a]):this.sendFrame(n.frame(c,u),a)}ping(e,i,o){let a,c;if(typeof e=="string"?(a=Buffer.byteLength(e),c=!1):nn(e)?(a=e.size,c=!1):(e=At(e),a=e.length,c=At.readOnly),a>125)throw new RangeError("The data size must not be greater than 125 bytes");let u={[Fe]:a,fin:!0,generateMask:this._generateMask,mask:i,maskBuffer:this._maskBuffer,opcode:9,readOnly:c,rsv1:!1};nn(e)?this._state!==qe?this.enqueue([this.getBlobData,e,!1,u,o]):this.getBlobData(e,!1,u,o):this._state!==qe?this.enqueue([this.dispatch,e,!1,u,o]):this.sendFrame(n.frame(e,u),o)}pong(e,i,o){let a,c;if(typeof e=="string"?(a=Buffer.byteLength(e),c=!1):nn(e)?(a=e.size,c=!1):(e=At(e),a=e.length,c=At.readOnly),a>125)throw new RangeError("The data size must not be greater than 125 bytes");let u={[Fe]:a,fin:!0,generateMask:this._generateMask,mask:i,maskBuffer:this._maskBuffer,opcode:10,readOnly:c,rsv1:!1};nn(e)?this._state!==qe?this.enqueue([this.getBlobData,e,!1,u,o]):this.getBlobData(e,!1,u,o):this._state!==qe?this.enqueue([this.dispatch,e,!1,u,o]):this.sendFrame(n.frame(e,u),o)}send(e,i,o){let a=this._extensions[Oc.extensionName],c=i.binary?2:1,u=i.compress,x,l;typeof e=="string"?(x=Buffer.byteLength(e),l=!1):nn(e)?(x=e.size,l=!1):(e=At(e),x=e.length,l=At.readOnly),this._firstFragment?(this._firstFragment=!1,u&&a&&a.params[a._isServer?"server_no_context_takeover":"client_no_context_takeover"]&&(u=x>=a._threshold),this._compress=u):(u=!1,c=0),i.fin&&(this._firstFragment=!0);let g={[Fe]:x,fin:i.fin,generateMask:this._generateMask,mask:i.mask,maskBuffer:this._maskBuffer,opcode:c,readOnly:l,rsv1:u};nn(e)?this._state!==qe?this.enqueue([this.getBlobData,e,this._compress,g,o]):this.getBlobData(e,this._compress,g,o):this._state!==qe?this.enqueue([this.dispatch,e,this._compress,g,o]):this.dispatch(e,this._compress,g,o)}getBlobData(e,i,o,a){this._bufferedBytes+=o[Fe],this._state=yg,e.arrayBuffer().then(c=>{if(this._socket.destroyed){let x=new Error("The socket was closed while the blob was being read");process.nextTick(rs,this,x,a);return}this._bufferedBytes-=o[Fe];let u=At(c);i?this.dispatch(u,i,o,a):(this._state=qe,this.sendFrame(n.frame(u,o),a),this.dequeue())}).catch(c=>{process.nextTick(Eg,this,c,a)})}dispatch(e,i,o,a){if(!i){this.sendFrame(n.frame(e,o),a);return}let c=this._extensions[Oc.extensionName];this._bufferedBytes+=o[Fe],this._state=_g,c.compress(e,o.fin,(u,x)=>{if(this._socket.destroyed){let l=new Error("The socket was closed while data was being compressed");rs(this,l,a);return}this._bufferedBytes-=o[Fe],this._state=qe,o.readOnly=!1,this.sendFrame(n.frame(x,o),a),this.dequeue()})}dequeue(){for(;this._state===qe&&this._queue.length;){let e=this._queue.shift();this._bufferedBytes-=e[3][Fe],Reflect.apply(e[0],this,e.slice(1))}}enqueue(e){this._bufferedBytes+=e[3][Fe],this._queue.push(e)}sendFrame(e,i){e.length===2?(this._socket.cork(),this._socket.write(e[0]),this._socket.write(e[1],i),this._socket.uncork()):this._socket.write(e[0],i)}};Bc.exports=ns;function rs(n,e,i){typeof i=="function"&&i(e);for(let o=0;o<n._queue.length;o++){let a=n._queue[o],c=a[a.length-1];typeof c=="function"&&c(e)}}function Eg(n,e,i){rs(n,e,i),n.onerror(e)}});var Wc=Q((yy,Kc)=>{"use strict";var{kForOnEventAttribute:Tn,kListener:ss}=st(),zc=Symbol("kCode"),Fc=Symbol("kData"),Uc=Symbol("kError"),qc=Symbol("kMessage"),Hc=Symbol("kReason"),sn=Symbol("kTarget"),Gc=Symbol("kType"),jc=Symbol("kWasClean"),at=class{constructor(e){this[sn]=null,this[Gc]=e}get target(){return this[sn]}get type(){return this[Gc]}};Object.defineProperty(at.prototype,"target",{enumerable:!0});Object.defineProperty(at.prototype,"type",{enumerable:!0});var Tt=class extends at{constructor(e,i={}){super(e),this[zc]=i.code===void 0?0:i.code,this[Hc]=i.reason===void 0?"":i.reason,this[jc]=i.wasClean===void 0?!1:i.wasClean}get code(){return this[zc]}get reason(){return this[Hc]}get wasClean(){return this[jc]}};Object.defineProperty(Tt.prototype,"code",{enumerable:!0});Object.defineProperty(Tt.prototype,"reason",{enumerable:!0});Object.defineProperty(Tt.prototype,"wasClean",{enumerable:!0});var on=class extends at{constructor(e,i={}){super(e),this[Uc]=i.error===void 0?null:i.error,this[qc]=i.message===void 0?"":i.message}get error(){return this[Uc]}get message(){return this[qc]}};Object.defineProperty(on.prototype,"error",{enumerable:!0});Object.defineProperty(on.prototype,"message",{enumerable:!0});var Dn=class extends at{constructor(e,i={}){super(e),this[Fc]=i.data===void 0?null:i.data}get data(){return this[Fc]}};Object.defineProperty(Dn.prototype,"data",{enumerable:!0});var bg={addEventListener(n,e,i={}){for(let a of this.listeners(n))if(!i[Tn]&&a[ss]===e&&!a[Tn])return;let o;if(n==="message")o=function(c,u){let x=new Dn("message",{data:u?c:c.toString()});x[sn]=this,Lr(e,this,x)};else if(n==="close")o=function(c,u){let x=new Tt("close",{code:c,reason:u.toString(),wasClean:this._closeFrameReceived&&this._closeFrameSent});x[sn]=this,Lr(e,this,x)};else if(n==="error")o=function(c){let u=new on("error",{error:c,message:c.message});u[sn]=this,Lr(e,this,u)};else if(n==="open")o=function(){let c=new at("open");c[sn]=this,Lr(e,this,c)};else return;o[Tn]=!!i[Tn],o[ss]=e,i.once?this.once(n,o):this.on(n,o)},removeEventListener(n,e){for(let i of this.listeners(n))if(i[ss]===e&&!i[Tn]){this.removeListener(n,i);break}}};Kc.exports={CloseEvent:Tt,ErrorEvent:on,Event:at,EventTarget:bg,MessageEvent:Dn};function Lr(n,e,i){typeof n=="object"&&n.handleEvent?n.handleEvent.call(n,i):n.call(e,i)}});var Or=Q((Ey,$c)=>{"use strict";var{tokenChars:Pn}=tn();function Qe(n,e,i){n[e]===void 0?n[e]=[i]:n[e].push(i)}function vg(n){let e=Object.create(null),i=Object.create(null),o=!1,a=!1,c=!1,u,x,l=-1,g=-1,E=-1,w=0;for(;w<n.length;w++)if(g=n.charCodeAt(w),u===void 0)if(E===-1&&Pn[g]===1)l===-1&&(l=w);else if(w!==0&&(g===32||g===9))E===-1&&l!==-1&&(E=w);else if(g===59||g===44){if(l===-1)throw new SyntaxError(`Unexpected character at index ${w}`);E===-1&&(E=w);let _=n.slice(l,E);g===44?(Qe(e,_,i),i=Object.create(null)):u=_,l=E=-1}else throw new SyntaxError(`Unexpected character at index ${w}`);else if(x===void 0)if(E===-1&&Pn[g]===1)l===-1&&(l=w);else if(g===32||g===9)E===-1&&l!==-1&&(E=w);else if(g===59||g===44){if(l===-1)throw new SyntaxError(`Unexpected character at index ${w}`);E===-1&&(E=w),Qe(i,n.slice(l,E),!0),g===44&&(Qe(e,u,i),i=Object.create(null),u=void 0),l=E=-1}else if(g===61&&l!==-1&&E===-1)x=n.slice(l,w),l=E=-1;else throw new SyntaxError(`Unexpected character at index ${w}`);else if(a){if(Pn[g]!==1)throw new SyntaxError(`Unexpected character at index ${w}`);l===-1?l=w:o||(o=!0),a=!1}else if(c)if(Pn[g]===1)l===-1&&(l=w);else if(g===34&&l!==-1)c=!1,E=w;else if(g===92)a=!0;else throw new SyntaxError(`Unexpected character at index ${w}`);else if(g===34&&n.charCodeAt(w-1)===61)c=!0;else if(E===-1&&Pn[g]===1)l===-1&&(l=w);else if(l!==-1&&(g===32||g===9))E===-1&&(E=w);else if(g===59||g===44){if(l===-1)throw new SyntaxError(`Unexpected character at index ${w}`);E===-1&&(E=w);let _=n.slice(l,E);o&&(_=_.replace(/\\/g,""),o=!1),Qe(i,x,_),g===44&&(Qe(e,u,i),i=Object.create(null),u=void 0),x=void 0,l=E=-1}else throw new SyntaxError(`Unexpected character at index ${w}`);if(l===-1||c||g===32||g===9)throw new SyntaxError("Unexpected end of input");E===-1&&(E=w);let A=n.slice(l,E);return u===void 0?Qe(e,A,i):(x===void 0?Qe(i,A,!0):o?Qe(i,x,A.replace(/\\/g,"")):Qe(i,x,A),Qe(e,u,i)),e}function Sg(n){return Object.keys(n).map(e=>{let i=n[e];return Array.isArray(i)||(i=[i]),i.map(o=>[e].concat(Object.keys(o).map(a=>{let c=o[a];return Array.isArray(c)||(c=[c]),c.map(u=>u===!0?a:`${a}=${u}`).join("; ")})).join("; ")).join(", ")}).join(", ")}$c.exports={format:Sg,parse:vg}});var Fr=Q((Sy,s0)=>{"use strict";var Ig=re("events"),Ag=re("https"),Cg=re("http"),Zc=re("net"),Tg=re("tls"),{randomBytes:Dg,createHash:Pg}=re("crypto"),{Duplex:by,Readable:vy}=re("stream"),{URL:os}=re("url"),yt=en(),kg=ts(),Rg=is(),{isBlob:Ng}=tn(),{BINARY_TYPES:Jc,CLOSE_TIMEOUT:Lg,EMPTY_BUFFER:Mr,GUID:Og,kForOnEventAttribute:as,kListener:Mg,kStatusCode:Bg,kWebSocket:Se,NOOP:Yc}=st(),{EventTarget:{addEventListener:zg,removeEventListener:Fg}}=Wc(),{format:Ug,parse:qg}=Or(),{toBuffer:Hg}=An(),Xc=Symbol("kAborted"),cs=[8,13],ct=["CONNECTING","OPEN","CLOSING","CLOSED"],Gg=/^[!#$%&'*+\-.0-9A-Z^_`|a-z~]+$/,oe=class n extends Ig{constructor(e,i,o){super(),this._binaryType=Jc[0],this._closeCode=1006,this._closeFrameReceived=!1,this._closeFrameSent=!1,this._closeMessage=Mr,this._closeTimer=null,this._errorEmitted=!1,this._extensions={},this._paused=!1,this._protocol="",this._readyState=n.CONNECTING,this._receiver=null,this._sender=null,this._socket=null,e!==null?(this._bufferedAmount=0,this._isServer=!1,this._redirects=0,i===void 0?i=[]:Array.isArray(i)||(typeof i=="object"&&i!==null?(o=i,i=[]):i=[i]),Qc(this,e,i,o)):(this._autoPong=o.autoPong,this._closeTimeout=o.closeTimeout,this._isServer=!0)}get binaryType(){return this._binaryType}set binaryType(e){Jc.includes(e)&&(this._binaryType=e,this._receiver&&(this._receiver._binaryType=e))}get bufferedAmount(){return this._socket?this._socket._writableState.length+this._sender._bufferedBytes:this._bufferedAmount}get extensions(){return Object.keys(this._extensions).join()}get isPaused(){return this._paused}get onclose(){return null}get onerror(){return null}get onopen(){return null}get onmessage(){return null}get protocol(){return this._protocol}get readyState(){return this._readyState}get url(){return this._url}setSocket(e,i,o){let a=new kg({allowSynchronousEvents:o.allowSynchronousEvents,binaryType:this.binaryType,extensions:this._extensions,isServer:this._isServer,maxPayload:o.maxPayload,skipUTF8Validation:o.skipUTF8Validation}),c=new Rg(e,this._extensions,o.generateMask);this._receiver=a,this._sender=c,this._socket=e,a[Se]=this,c[Se]=this,e[Se]=this,a.on("conclude",Wg),a.on("drain",$g),a.on("error",Jg),a.on("message",Vg),a.on("ping",Zg),a.on("pong",Yg),c.onerror=Xg,e.setTimeout&&e.setTimeout(0),e.setNoDelay&&e.setNoDelay(),i.length>0&&e.unshift(i),e.on("close",n0),e.on("data",zr),e.on("end",r0),e.on("error",i0),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[yt.extensionName]&&this._extensions[yt.extensionName].cleanup(),this._receiver.removeAllListeners(),this._readyState=n.CLOSED,this.emit("close",this._closeCode,this._closeMessage)}close(e,i){if(this.readyState!==n.CLOSED){if(this.readyState===n.CONNECTING){Oe(this,this._req,"WebSocket was closed before the connection was established");return}if(this.readyState===n.CLOSING){this._closeFrameSent&&(this._closeFrameReceived||this._receiver._writableState.errorEmitted)&&this._socket.end();return}this._readyState=n.CLOSING,this._sender.close(e,i,!this._isServer,o=>{o||(this._closeFrameSent=!0,(this._closeFrameReceived||this._receiver._writableState.errorEmitted)&&this._socket.end())}),t0(this)}}pause(){this.readyState===n.CONNECTING||this.readyState===n.CLOSED||(this._paused=!0,this._socket.pause())}ping(e,i,o){if(this.readyState===n.CONNECTING)throw new Error("WebSocket is not open: readyState 0 (CONNECTING)");if(typeof e=="function"?(o=e,e=i=void 0):typeof i=="function"&&(o=i,i=void 0),typeof e=="number"&&(e=e.toString()),this.readyState!==n.OPEN){ds(this,e,o);return}i===void 0&&(i=!this._isServer),this._sender.ping(e||Mr,i,o)}pong(e,i,o){if(this.readyState===n.CONNECTING)throw new Error("WebSocket is not open: readyState 0 (CONNECTING)");if(typeof e=="function"?(o=e,e=i=void 0):typeof i=="function"&&(o=i,i=void 0),typeof e=="number"&&(e=e.toString()),this.readyState!==n.OPEN){ds(this,e,o);return}i===void 0&&(i=!this._isServer),this._sender.pong(e||Mr,i,o)}resume(){this.readyState===n.CONNECTING||this.readyState===n.CLOSED||(this._paused=!1,this._receiver._writableState.needDrain||this._socket.resume())}send(e,i,o){if(this.readyState===n.CONNECTING)throw new Error("WebSocket is not open: readyState 0 (CONNECTING)");if(typeof i=="function"&&(o=i,i={}),typeof e=="number"&&(e=e.toString()),this.readyState!==n.OPEN){ds(this,e,o);return}let a={binary:typeof e!="string",mask:!this._isServer,compress:!0,fin:!0,...i};this._extensions[yt.extensionName]||(a.compress=!1),this._sender.send(e||Mr,a,o)}terminate(){if(this.readyState!==n.CLOSED){if(this.readyState===n.CONNECTING){Oe(this,this._req,"WebSocket was closed before the connection was established");return}this._socket&&(this._readyState=n.CLOSING,this._socket.destroy())}}};Object.defineProperty(oe,"CONNECTING",{enumerable:!0,value:ct.indexOf("CONNECTING")});Object.defineProperty(oe.prototype,"CONNECTING",{enumerable:!0,value:ct.indexOf("CONNECTING")});Object.defineProperty(oe,"OPEN",{enumerable:!0,value:ct.indexOf("OPEN")});Object.defineProperty(oe.prototype,"OPEN",{enumerable:!0,value:ct.indexOf("OPEN")});Object.defineProperty(oe,"CLOSING",{enumerable:!0,value:ct.indexOf("CLOSING")});Object.defineProperty(oe.prototype,"CLOSING",{enumerable:!0,value:ct.indexOf("CLOSING")});Object.defineProperty(oe,"CLOSED",{enumerable:!0,value:ct.indexOf("CLOSED")});Object.defineProperty(oe.prototype,"CLOSED",{enumerable:!0,value:ct.indexOf("CLOSED")});["binaryType","bufferedAmount","extensions","isPaused","protocol","readyState","url"].forEach(n=>{Object.defineProperty(oe.prototype,n,{enumerable:!0})});["open","error","close","message"].forEach(n=>{Object.defineProperty(oe.prototype,`on${n}`,{enumerable:!0,get(){for(let e of this.listeners(n))if(e[as])return e[Mg];return null},set(e){for(let i of this.listeners(n))if(i[as]){this.removeListener(n,i);break}typeof e=="function"&&this.addEventListener(n,e,{[as]:!0})}})});oe.prototype.addEventListener=zg;oe.prototype.removeEventListener=Fg;s0.exports=oe;function Qc(n,e,i,o){let a={allowSynchronousEvents:!0,autoPong:!0,closeTimeout:Lg,protocolVersion:cs[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,!cs.includes(a.protocolVersion))throw new RangeError(`Unsupported protocol version: ${a.protocolVersion} (supported versions: ${cs.join(", ")})`);let c;if(e instanceof os)c=e;else try{c=new os(e)}catch{throw new SyntaxError(`Invalid URL: ${e}`)}c.protocol==="http:"?c.protocol="ws:":c.protocol==="https:"&&(c.protocol="wss:"),n._url=c.href;let u=c.protocol==="wss:",x=c.protocol==="ws+unix:",l;if(c.protocol!=="ws:"&&!u&&!x?l=`The URL's protocol must be one of "ws:", "wss:", "http:", "https:", or "ws+unix:"`:x&&!c.pathname?l="The URL's pathname is empty":c.hash&&(l="The URL contains a fragment identifier"),l){let S=new SyntaxError(l);if(n._redirects===0)throw S;Br(n,S);return}let g=u?443:80,E=Dg(16).toString("base64"),w=u?Ag.request:Cg.request,A=new Set,_;if(a.createConnection=a.createConnection||(u?Kg:jg),a.defaultPort=a.defaultPort||g,a.port=c.port||g,a.host=c.hostname.startsWith("[")?c.hostname.slice(1,-1):c.hostname,a.headers={...a.headers,"Sec-WebSocket-Version":a.protocolVersion,"Sec-WebSocket-Key":E,Connection:"Upgrade",Upgrade:"websocket"},a.path=c.pathname+c.search,a.timeout=a.handshakeTimeout,a.perMessageDeflate&&(_=new yt({...a.perMessageDeflate,isServer:!1,maxPayload:a.maxPayload}),a.headers["Sec-WebSocket-Extensions"]=Ug({[yt.extensionName]:_.offer()})),i.length){for(let S of i){if(typeof S!="string"||!Gg.test(S)||A.has(S))throw new SyntaxError("An invalid or duplicated subprotocol was specified");A.add(S)}a.headers["Sec-WebSocket-Protocol"]=i.join(",")}if(a.origin&&(a.protocolVersion<13?a.headers["Sec-WebSocket-Origin"]=a.origin:a.headers.Origin=a.origin),(c.username||c.password)&&(a.auth=`${c.username}:${c.password}`),x){let S=a.path.split(":");a.socketPath=S[0],a.path=S[1]}let b;if(a.followRedirects){if(n._redirects===0){n._originalIpc=x,n._originalSecure=u,n._originalHostOrSocketPath=x?a.socketPath:c.host;let S=o&&o.headers;if(o={...o,headers:{}},S)for(let[I,k]of Object.entries(S))o.headers[I.toLowerCase()]=k}else if(n.listenerCount("redirect")===0){let S=x?n._originalIpc?a.socketPath===n._originalHostOrSocketPath:!1:n._originalIpc?!1:c.host===n._originalHostOrSocketPath;(!S||n._originalSecure&&!u)&&(delete a.headers.authorization,delete a.headers.cookie,S||delete a.headers.host,a.auth=void 0)}a.auth&&!o.headers.authorization&&(o.headers.authorization="Basic "+Buffer.from(a.auth).toString("base64")),b=n._req=w(a),n._redirects&&n.emit("redirect",n.url,b)}else b=n._req=w(a);a.timeout&&b.on("timeout",()=>{Oe(n,b,"Opening handshake has timed out")}),b.on("error",S=>{b===null||b[Xc]||(b=n._req=null,Br(n,S))}),b.on("response",S=>{let I=S.headers.location,k=S.statusCode;if(I&&a.followRedirects&&k>=300&&k<400){if(++n._redirects>a.maxRedirects){Oe(n,b,"Maximum redirects exceeded");return}b.abort();let L;try{L=new os(I,e)}catch{let C=new SyntaxError(`Invalid URL: ${I}`);Br(n,C);return}Qc(n,L,i,o)}else n.emit("unexpected-response",b,S)||Oe(n,b,`Unexpected server response: ${S.statusCode}`)}),b.on("upgrade",(S,I,k)=>{if(n.emit("upgrade",S),n.readyState!==oe.CONNECTING)return;b=n._req=null;let L=S.headers.upgrade;if(L===void 0||L.toLowerCase()!=="websocket"){Oe(n,I,"Invalid Upgrade header");return}let m=Pg("sha1").update(E+Og).digest("base64");if(S.headers["sec-websocket-accept"]!==m){Oe(n,I,"Invalid Sec-WebSocket-Accept header");return}let C=S.headers["sec-websocket-protocol"],R;if(C!==void 0?A.size?A.has(C)||(R="Server sent an invalid subprotocol"):R="Server sent a subprotocol but none was requested":A.size&&(R="Server sent no subprotocol"),R){Oe(n,I,R);return}C&&(n._protocol=C);let F=S.headers["sec-websocket-extensions"];if(F!==void 0){if(!_){Oe(n,I,"Server sent a Sec-WebSocket-Extensions header but no extension was requested");return}let z;try{z=qg(F)}catch{Oe(n,I,"Invalid Sec-WebSocket-Extensions header");return}let $=Object.keys(z);if($.length!==1||$[0]!==yt.extensionName){Oe(n,I,"Server indicated an extension that was not requested");return}try{_.accept(z[yt.extensionName])}catch{Oe(n,I,"Invalid Sec-WebSocket-Extensions header");return}n._extensions[yt.extensionName]=_}n.setSocket(I,k,{allowSynchronousEvents:a.allowSynchronousEvents,generateMask:a.generateMask,maxPayload:a.maxPayload,skipUTF8Validation:a.skipUTF8Validation})}),a.finishRequest?a.finishRequest(b,n):b.end()}function Br(n,e){n._readyState=oe.CLOSING,n._errorEmitted=!0,n.emit("error",e),n.emitClose()}function jg(n){return n.path=n.socketPath,Zc.connect(n)}function Kg(n){return n.path=void 0,!n.servername&&n.servername!==""&&(n.servername=Zc.isIP(n.host)?"":n.host),Tg.connect(n)}function Oe(n,e,i){n._readyState=oe.CLOSING;let o=new Error(i);Error.captureStackTrace(o,Oe),e.setHeader?(e[Xc]=!0,e.abort(),e.socket&&!e.socket.destroyed&&e.socket.destroy(),process.nextTick(Br,n,o)):(e.destroy(o),e.once("error",n.emit.bind(n,"error")),e.once("close",n.emitClose.bind(n)))}function ds(n,e,i){if(e){let o=Ng(e)?e.size:Hg(e).length;n._socket?n._sender._bufferedBytes+=o:n._bufferedAmount+=o}if(i){let o=new Error(`WebSocket is not open: readyState ${n.readyState} (${ct[n.readyState]})`);process.nextTick(i,o)}}function Wg(n,e){let i=this[Se];i._closeFrameReceived=!0,i._closeMessage=e,i._closeCode=n,i._socket[Se]!==void 0&&(i._socket.removeListener("data",zr),process.nextTick(e0,i._socket),n===1005?i.close():i.close(n,e))}function $g(){let n=this[Se];n.isPaused||n._socket.resume()}function Jg(n){let e=this[Se];e._socket[Se]!==void 0&&(e._socket.removeListener("data",zr),process.nextTick(e0,e._socket),e.close(n[Bg])),e._errorEmitted||(e._errorEmitted=!0,e.emit("error",n))}function Vc(){this[Se].emitClose()}function Vg(n,e){this[Se].emit("message",n,e)}function Zg(n){let e=this[Se];e._autoPong&&e.pong(n,!this._isServer,Yc),e.emit("ping",n)}function Yg(n){this[Se].emit("pong",n)}function e0(n){n.resume()}function Xg(n){let e=this[Se];e.readyState!==oe.CLOSED&&(e.readyState===oe.OPEN&&(e._readyState=oe.CLOSING,t0(e)),this._socket.end(),e._errorEmitted||(e._errorEmitted=!0,e.emit("error",n)))}function t0(n){n._closeTimer=setTimeout(n._socket.destroy.bind(n._socket),n._closeTimeout)}function n0(){let n=this[Se];if(this.removeListener("close",n0),this.removeListener("data",zr),this.removeListener("end",r0),n._readyState=oe.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[Se]=void 0,clearTimeout(n._closeTimer),n._receiver._writableState.finished||n._receiver._writableState.errorEmitted?n.emitClose():(n._receiver.on("error",Vc),n._receiver.on("finish",Vc))}function zr(n){this[Se]._receiver.write(n)||this.pause()}function r0(){let n=this[Se];n._readyState=oe.CLOSING,n._receiver.end(),this.end()}function i0(){let n=this[Se];this.removeListener("error",i0),this.on("error",Yc),n&&(n._readyState=oe.CLOSING,this.destroy())}});var d0=Q((Ay,c0)=>{"use strict";var Iy=Fr(),{Duplex:Qg}=re("stream");function o0(n){n.emit("close")}function eh(){!this.destroyed&&this._writableState.finished&&this.destroy()}function a0(n){this.removeListener("error",a0),this.destroy(),this.listenerCount("error")===0&&this.emit("error",n)}function th(n,e){let i=!0,o=new Qg({...e,autoDestroy:!1,emitClose:!1,objectMode:!1,writableObjectMode:!1});return n.on("message",function(c,u){let x=!u&&o._readableState.objectMode?c.toString():c;o.push(x)||n.pause()}),n.once("error",function(c){o.destroyed||(i=!1,o.destroy(c))}),n.once("close",function(){o.destroyed||o.push(null)}),o._destroy=function(a,c){if(n.readyState===n.CLOSED){c(a),process.nextTick(o0,o);return}let u=!1;n.once("error",function(l){u=!0,c(l)}),n.once("close",function(){u||c(a),process.nextTick(o0,o)}),i&&n.terminate()},o._final=function(a){if(n.readyState===n.CONNECTING){n.once("open",function(){o._final(a)});return}n._socket!==null&&(n._socket._writableState.finished?(a(),o._readableState.endEmitted&&o.destroy()):(n._socket.once("finish",function(){a()}),n.close()))},o._read=function(){n.isPaused&&n.resume()},o._write=function(a,c,u){if(n.readyState===n.CONNECTING){n.once("open",function(){o._write(a,c,u)});return}n.send(a,u)},o.on("end",eh),o.on("error",a0),o}c0.exports=th});var us=Q((Cy,u0)=>{"use strict";var{tokenChars:nh}=tn();function rh(n){let e=new Set,i=-1,o=-1,a=0;for(a;a<n.length;a++){let u=n.charCodeAt(a);if(o===-1&&nh[u]===1)i===-1&&(i=a);else if(a!==0&&(u===32||u===9))o===-1&&i!==-1&&(o=a);else if(u===44){if(i===-1)throw new SyntaxError(`Unexpected character at index ${a}`);o===-1&&(o=a);let x=n.slice(i,o);if(e.has(x))throw new SyntaxError(`The "${x}" subprotocol is duplicated`);e.add(x),i=o=-1}else throw new SyntaxError(`Unexpected character at index ${a}`)}if(i===-1||o!==-1)throw new SyntaxError("Unexpected end of input");let c=n.slice(i,a);if(e.has(c))throw new SyntaxError(`The "${c}" subprotocol is duplicated`);return e.add(c),e}u0.exports={parse:rh}});var m0=Q((Dy,p0)=>{"use strict";var ih=re("events"),Ur=re("http"),{Duplex:Ty}=re("stream"),{createHash:sh}=re("crypto"),f0=Or(),Dt=en(),oh=us(),ah=Fr(),{CLOSE_TIMEOUT:ch,GUID:dh,kWebSocket:uh}=st(),fh=/^[+/0-9A-Za-z]{22}==$/,x0=0,l0=1,h0=2,fs=class extends ih{constructor(e,i){if(super(),e={allowSynchronousEvents:!0,autoPong:!0,maxPayload:100*1024*1024,skipUTF8Validation:!1,perMessageDeflate:!1,handleProtocols:null,clientTracking:!0,closeTimeout:ch,verifyClient:null,noServer:!1,backlog:null,server:null,host:null,path:null,port:null,WebSocket:ah,...e},e.port==null&&!e.server&&!e.noServer||e.port!=null&&(e.server||e.noServer)||e.server&&e.noServer)throw new TypeError('One and only one of the "port", "server", or "noServer" options must be specified');if(e.port!=null?(this._server=Ur.createServer((o,a)=>{let c=Ur.STATUS_CODES[426];a.writeHead(426,{"Content-Length":c.length,"Content-Type":"text/plain"}),a.end(c)}),this._server.listen(e.port,e.host,e.backlog,i)):e.server&&(this._server=e.server),this._server){let o=this.emit.bind(this,"connection");this._removeListeners=xh(this._server,{listening:this.emit.bind(this,"listening"),error:this.emit.bind(this,"error"),upgrade:(a,c,u)=>{this.handleUpgrade(a,c,u,o)}})}e.perMessageDeflate===!0&&(e.perMessageDeflate={}),e.clientTracking&&(this.clients=new Set,this._shouldEmitClose=!1),this.options=e,this._state=x0}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===h0){e&&this.once("close",()=>{e(new Error("The server is not running"))}),process.nextTick(kn,this);return}if(e&&this.once("close",e),this._state!==l0)if(this._state=l0,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(kn,this):process.nextTick(kn,this);else{let i=this._server;this._removeListeners(),this._removeListeners=this._server=null,i.close(()=>{kn(this)})}}shouldHandle(e){if(this.options.path){let i=e.url.indexOf("?");if((i!==-1?e.url.slice(0,i):e.url)!==this.options.path)return!1}return!0}handleUpgrade(e,i,o,a){i.on("error",g0);let c=e.headers["sec-websocket-key"],u=e.headers.upgrade,x=+e.headers["sec-websocket-version"];if(e.method!=="GET"){Pt(this,e,i,405,"Invalid HTTP method");return}if(u===void 0||u.toLowerCase()!=="websocket"){Pt(this,e,i,400,"Invalid Upgrade header");return}if(c===void 0||!fh.test(c)){Pt(this,e,i,400,"Missing or invalid Sec-WebSocket-Key header");return}if(x!==13&&x!==8){Pt(this,e,i,400,"Missing or invalid Sec-WebSocket-Version header",{"Sec-WebSocket-Version":"13, 8"});return}if(!this.shouldHandle(e)){Rn(i,400);return}let l=e.headers["sec-websocket-protocol"],g=new Set;if(l!==void 0)try{g=oh.parse(l)}catch{Pt(this,e,i,400,"Invalid Sec-WebSocket-Protocol header");return}let E=e.headers["sec-websocket-extensions"],w={};if(this.options.perMessageDeflate&&E!==void 0){let A=new Dt({...this.options.perMessageDeflate,isServer:!0,maxPayload:this.options.maxPayload});try{let _=f0.parse(E);_[Dt.extensionName]&&(A.accept(_[Dt.extensionName]),w[Dt.extensionName]=A)}catch{Pt(this,e,i,400,"Invalid or unacceptable Sec-WebSocket-Extensions header");return}}if(this.options.verifyClient){let A={origin:e.headers[`${x===8?"sec-websocket-origin":"origin"}`],secure:!!(e.socket.authorized||e.socket.encrypted),req:e};if(this.options.verifyClient.length===2){this.options.verifyClient(A,(_,b,S,I)=>{if(!_)return Rn(i,b||401,S,I);this.completeUpgrade(w,c,g,e,i,o,a)});return}if(!this.options.verifyClient(A))return Rn(i,401)}this.completeUpgrade(w,c,g,e,i,o,a)}completeUpgrade(e,i,o,a,c,u,x){if(!c.readable||!c.writable)return c.destroy();if(c[uh])throw new Error("server.handleUpgrade() was called more than once with the same socket, possibly due to a misconfiguration");if(this._state>x0)return Rn(c,503);let g=["HTTP/1.1 101 Switching Protocols","Upgrade: websocket","Connection: Upgrade",`Sec-WebSocket-Accept: ${sh("sha1").update(i+dh).digest("base64")}`],E=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&&(g.push(`Sec-WebSocket-Protocol: ${w}`),E._protocol=w)}if(e[Dt.extensionName]){let w=e[Dt.extensionName].params,A=f0.format({[Dt.extensionName]:[w]});g.push(`Sec-WebSocket-Extensions: ${A}`),E._extensions=e}this.emit("headers",g,a),c.write(g.concat(`\r
12
12
  `).join(`\r
13
- `)),d.removeListener("error",cc),y.setSocket(d,u,{allowSynchronousEvents:this.options.allowSynchronousEvents,maxPayload:this.options.maxPayload,skipUTF8Validation:this.options.skipUTF8Validation}),this.clients&&(this.clients.add(y),y.on("close",()=>{this.clients.delete(y),this._shouldEmitClose&&!this.clients.size&&process.nextTick(pn,this)})),f(y,a)}};dc.exports=Ni;function Fl(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=xc,n.emit("close")}function cc(){this.destroy()}function hn(n,e,s,o){s=s||_r.STATUS_CODES[e],o={Connection:"close","Content-Type":"text/html","Content-Length":Buffer.byteLength(s),...o},n.once("finish",n.destroy),n.end(`HTTP/1.1 ${e} ${_r.STATUS_CODES[e]}\r
13
+ `)),c.removeListener("error",g0),E.setSocket(c,u,{allowSynchronousEvents:this.options.allowSynchronousEvents,maxPayload:this.options.maxPayload,skipUTF8Validation:this.options.skipUTF8Validation}),this.clients&&(this.clients.add(E),E.on("close",()=>{this.clients.delete(E),this._shouldEmitClose&&!this.clients.size&&process.nextTick(kn,this)})),x(E,a)}};p0.exports=fs;function xh(n,e){for(let i of Object.keys(e))n.on(i,e[i]);return function(){for(let o of Object.keys(e))n.removeListener(o,e[o])}}function kn(n){n._state=h0,n.emit("close")}function g0(){this.destroy()}function Rn(n,e,i,o){i=i||Ur.STATUS_CODES[e],o={Connection:"close","Content-Type":"text/html","Content-Length":Buffer.byteLength(i),...o},n.once("finish",n.destroy),n.end(`HTTP/1.1 ${e} ${Ur.STATUS_CODES[e]}\r
14
14
  `+Object.keys(o).map(a=>`${a}: ${o[a]}`).join(`\r
15
15
  `)+`\r
16
16
  \r
17
- `+s)}function wt(n,e,s,o,a,d){if(n.listenerCount("wsClientError")){let u=new Error(a);Error.captureStackTrace(u,wt),n.emit("wsClientError",u,s,e)}else hn(s,o,a,d)}});import{spawn as gg}from"node:child_process";import{existsSync as pg,openSync as hg}from"node:fs";import{mkdir as mg}from"node:fs/promises";import{dirname as wg}from"node:path";import{fileURLToPath as _g}from"node:url";function zi(n=G()){return pg(n.libEntry)?n.libEntry:_g(new URL("../index.ts",import.meta.url))}async function _n(n={}){let e=n.paths??G(),s=n.entryOverride??zi(e);await mg(wg(e.logFile),{recursive:!0});let o=hg(e.logFile,"a"),d=s.endsWith(".ts")?["--import","tsx/esm",s,"--daemon"]:[s,"--daemon"],u=gg(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 yg.info("daemon spawned",{pid:u.pid,entry:s}),{pid:u.pid,entry:s}}var yg,Ar=Te(()=>{"use strict";q();oe();yg=D("spawn-daemon")});import{readFile as Cc}from"node:fs/promises";async function Ir(n){try{let[e,s]=await Promise.all([Cc(n.portFile,"utf8"),Cc(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 bg(n){if(!n)return null;try{return JSON.parse(n)}catch{return n}}function vg(n){return n instanceof Error?n.message:String(n)}var Oe,Tr=Te(()=>{"use strict";oe();Oe=class{paths;constructor(e){this.paths=e??G()}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:vg(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 d=new AbortController,u=setTimeout(()=>d.abort(),s.timeoutMs??5e3);try{let f=await fetch(`http://127.0.0.1:${e.port}${s.path}`,{method:s.method,headers:a,body:o?JSON.stringify(s.body):void 0,signal:d.signal}),p=await f.text();return{status:f.status,body:bg(p)}}finally{clearTimeout(u)}}}});var Bc={};$r(Bc,{DEFAULT_PROBE_TIMEOUT_MS:()=>Mc,DEFAULT_WAIT_PID_EXIT_MS:()=>Lc,runUpgradeHelper:()=>Ug});import{copyFile as Lg,rename as Gi,unlink as ji}from"node:fs/promises";async function Ug(n){let e=n.paths??G(),s=n.spawnDaemon??_n,o=n.probeDaemon??jg,a=n.sleep??Hg,d=n.waitPidExitMs??Lc,u=n.probeTimeoutMs??Mc,f=n.killPid??((k,L)=>process.kill(k,L)),{targetVersion:p,oldPid:h}=n;He.info("upgrade-helper start",{targetVersion:p,oldPid:h}),await qg(h,d,a,f);let y=e.libEntry,w=`${y}.bak`,A=`${y}.next`;try{await Lg(y,w)}catch(k){return He.error("backup failed, abort",{err:String(k)}),1}try{await Gi(A,y)}catch(k){return He.error("rename .next \u2192 live failed, abort + rollback",{err:String(k)}),await Gi(w,y).catch(()=>{}),1}let I,E=!1;try{await s({paths:e}),E=await Gg(()=>o(e),u,a),E||(I="new daemon failed to come up within probeTimeout")}catch(k){I=`spawn new daemon failed: ${String(k)}`,He.warn(I)}return E?(await Oc(e,p,{ok:!0,setLibVersion:!0}),await ji(w).catch(()=>{}),await ji(A).catch(()=>{}),He.info("upgrade succeeded",{targetVersion:p}),0):(He.warn("upgrade failed, rolling back",{lastError:I}),await Gi(w,y).catch(k=>He.error("rollback rename failed",{err:String(k)})),await s({paths:e}).catch(k=>He.error("spawn old daemon after rollback failed",{err:String(k)})),await Oc(e,p,{ok:!1,lastError:I}),await ji(A).catch(()=>{}),1)}async function Oc(n,e,s){let o=await ct(n.configFile)??{};s.setLibVersion&&(o.libVersion=e),o.upgradeAttempts=o.upgradeAttempts??{},o.upgradeAttempts[e]={count:(o.upgradeAttempts[e]?.count??0)+1,lastAt:Date.now(),ok:s.ok,...s.lastError?{lastError:s.lastError}:{}},await Ue(o,n.configFile)}async function qg(n,e,s,o){let a=Date.now()+e;for(;Date.now()<a;){if(!Nc(n,o))return;await s(zg)}He.warn("oldPid did not exit in time, sending SIGTERM",{pid:n});try{o(n,"SIGTERM")}catch{}if(await s(Mg),!!Nc(n,o)){He.warn("SIGTERM ineffective, sending SIGKILL",{pid:n});try{o(n,"SIGKILL")}catch{}await s(Bg)}}function Nc(n,e){try{return e(n,0),!0}catch{return!1}}async function Gg(n,e,s){let o=Date.now()+e;for(;Date.now()<o;){if(await n().catch(()=>!1))return!0;await s(Fg)}return!1}async function jg(n){return(await new Oe(n).probe(1e3).catch(()=>null))?.kind==="connected"}function Hg(n){return new Promise(e=>setTimeout(e,n))}var He,Lc,Mc,Mg,Bg,zg,Fg,zc=Te(()=>{"use strict";Bt();Ar();Tr();q();oe();He=D("upgrade-helper"),Lc=3e4,Mc=3e4,Mg=5e3,Bg=2e3,zg=200,Fg=500});import{spawn as Kg}from"node:child_process";import{mkdir as Wg,unlink as $g,writeFile as Jg}from"node:fs/promises";import{dirname as Vg,join as Xg}from"node:path";function kr(n){return n.replace(/&/g,"&amp;").replace(/</g,"&lt;").replace(/>/g,"&gt;").replace(/"/g,"&quot;")}function Fc(n,e){return new Promise((s,o)=>{let a=Kg(n,e,{stdio:["ignore","pipe","pipe"]}),d="";a.stderr?.on("data",u=>{d+=u.toString("utf8")}),a.on("error",o),a.on("close",u=>{u===0?s():o(new Error(`${n} ${e.join(" ")} exited ${u}: ${d.trim()}`))})})}var Cr,Hi,Ki,Uc=Te(()=>{"use strict";q();Cr=D("supervisor.launchd"),Hi="ai.coze.bridge",Ki={platform:"darwin",renderConfig(n){return`<?xml version="1.0" encoding="UTF-8"?>
17
+ `+i)}function Pt(n,e,i,o,a,c){if(n.listenerCount("wsClientError")){let u=new Error(a);Error.captureStackTrace(u,Pt),n.emit("wsClientError",u,i,e)}else Rn(i,o,a,c)}});import{spawn as qh}from"node:child_process";import{existsSync as Hh,openSync as Gh}from"node:fs";import{mkdir as jh}from"node:fs/promises";import{dirname as Kh}from"node:path";import{fileURLToPath as Wh}from"node:url";function hs(n=Y()){return Hh(n.libEntry)?n.libEntry:Wh(new URL("../index.ts",import.meta.url))}async function On(n={}){let e=n.paths??Y(),i=n.entryOverride??hs(e);await jh(Kh(e.logFile),{recursive:!0});let o=Gh(e.logFile,"a"),c=i.endsWith(".ts")?["--import","tsx/esm",i,"--daemon"]:[i,"--daemon"],u=qh(process.execPath,c,{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 $h.info("daemon spawned",{pid:u.pid,entry:i}),{pid:u.pid,entry:i}}var $h,Wr=Be(()=>{"use strict";Z();ye();$h=q("spawn-daemon")});import{readFile as O0}from"node:fs/promises";async function $r(n){try{let[e,i]=await Promise.all([O0(n.portFile,"utf8"),O0(n.tokenFile,"utf8")]),o=Number.parseInt(e.trim(),10),a=i.trim();return!Number.isFinite(o)||o<=0||!a?null:{port:o,token:a}}catch(e){if(e.code==="ENOENT")return null;throw e}}function Jh(n){if(!n)return null;try{return JSON.parse(n)}catch{return n}}function Vh(n){return n instanceof Error?n.message:String(n)}var He,Jr=Be(()=>{"use strict";ye();He=class{paths;constructor(e){this.paths=e??Y()}async probe(e=1e3){let i=await $r(this.paths);if(!i)return{kind:"not-running"};try{let o=await this.fetch(i,{method:"GET",path:"/status",timeoutMs:e});return o.status===200?{kind:"connected",...i}:{kind:"stale",reason:`unexpected status ${o.status}`}}catch(o){return{kind:"stale",reason:Vh(o)}}}async request(e){let i=await $r(this.paths);if(!i)throw new Error("coze-bridge daemon not running (no port/token files)");return this.fetch(i,e)}async fetch(e,i){let o=i.body!==void 0,a={Authorization:`Bearer ${e.token}`};o&&(a["content-type"]="application/json");let c=new AbortController,u=setTimeout(()=>c.abort(),i.timeoutMs??5e3);try{let x=await fetch(`http://127.0.0.1:${e.port}${i.path}`,{method:i.method,headers:a,body:o?JSON.stringify(i.body):void 0,signal:c.signal}),l=await x.text();return{status:x.status,body:Jh(l)}}finally{clearTimeout(u)}}}});var G0={};hi(G0,{DEFAULT_PROBE_TIMEOUT_MS:()=>H0,DEFAULT_WAIT_PID_EXIT_MS:()=>q0,runUpgradeHelper:()=>lp});import{copyFile as cp,rename as _s,unlink as ys}from"node:fs/promises";async function lp(n){let e=n.paths??Y(),i=n.spawnDaemon??On,o=n.probeDaemon??pp,a=n.sleep??mp,c=n.waitPidExitMs??q0,u=n.probeTimeoutMs??H0,x=n.killPid??((S,I)=>process.kill(S,I)),{targetVersion:l,oldPid:g}=n;et.info("upgrade-helper start",{targetVersion:l,oldPid:g}),await gp(g,c,a,x);let E=e.libEntry,w=`${E}.bak`,A=`${E}.next`;try{await cp(E,w)}catch(S){return et.error("backup failed, abort",{err:String(S)}),1}try{await _s(A,E)}catch(S){return et.error("rename .next \u2192 live failed, abort + rollback",{err:String(S)}),await _s(w,E).catch(()=>{}),1}let _,b=!1;try{await i({paths:e}),b=await hp(()=>o(e),u,a),b||(_="new daemon failed to come up within probeTimeout")}catch(S){_=`spawn new daemon failed: ${String(S)}`,et.warn(_)}return b?(await F0(e,l,{ok:!0,setLibVersion:!0}),await ys(w).catch(()=>{}),await ys(A).catch(()=>{}),et.info("upgrade succeeded",{targetVersion:l}),0):(et.warn("upgrade failed, rolling back",{lastError:_}),await _s(w,E).catch(S=>et.error("rollback rename failed",{err:String(S)})),await i({paths:e}).catch(S=>et.error("spawn old daemon after rollback failed",{err:String(S)})),await F0(e,l,{ok:!1,lastError:_}),await ys(A).catch(()=>{}),1)}async function F0(n,e,i){let o=await wt(n.configFile)??{};i.setLibVersion&&(o.libVersion=e),o.upgradeAttempts=o.upgradeAttempts??{},o.upgradeAttempts[e]={count:(o.upgradeAttempts[e]?.count??0)+1,lastAt:Date.now(),ok:i.ok,...i.lastError?{lastError:i.lastError}:{}},await Ze(o,n.configFile)}async function gp(n,e,i,o){let a=Date.now()+e;for(;Date.now()<a;){if(!U0(n,o))return;await i(fp)}et.warn("oldPid did not exit in time, sending SIGTERM",{pid:n});try{o(n,"SIGTERM")}catch{}if(await i(dp),!!U0(n,o)){et.warn("SIGTERM ineffective, sending SIGKILL",{pid:n});try{o(n,"SIGKILL")}catch{}await i(up)}}function U0(n,e){try{return e(n,0),!0}catch{return!1}}async function hp(n,e,i){let o=Date.now()+e;for(;Date.now()<o;){if(await n().catch(()=>!1))return!0;await i(xp)}return!1}async function pp(n){return(await new He(n).probe(1e3).catch(()=>null))?.kind==="connected"}function mp(n){return new Promise(e=>setTimeout(e,n))}var et,q0,H0,dp,up,fp,xp,j0=Be(()=>{"use strict";Yt();Wr();Jr();Z();ye();et=q("upgrade-helper"),q0=3e4,H0=3e4,dp=5e3,up=2e3,fp=200,xp=500});import{spawn as wp}from"node:child_process";import{mkdir as _p,unlink as yp,writeFile as Ep}from"node:fs/promises";import{dirname as bp,join as vp}from"node:path";function Yr(n){return n.replace(/&/g,"&amp;").replace(/</g,"&lt;").replace(/>/g,"&gt;").replace(/"/g,"&quot;")}function K0(n,e){return new Promise((i,o)=>{let a=wp(n,e,{stdio:["ignore","pipe","pipe"]}),c="";a.stderr?.on("data",u=>{c+=u.toString("utf8")}),a.on("error",o),a.on("close",u=>{u===0?i():o(new Error(`${n} ${e.join(" ")} exited ${u}: ${c.trim()}`))})})}var Zr,Es,bs,W0=Be(()=>{"use strict";Z();Zr=q("supervisor.launchd"),Es="ai.coze.bridge",bs={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>${Hi}</string>
22
+ <string>${Es}</string>
23
23
  <key>ProgramArguments</key>
24
24
  <array>
25
- <string>${kr(n.nodeBin)}</string>
26
- <string>${kr(n.entry)}</string>
25
+ <string>${Yr(n.nodeBin)}</string>
26
+ <string>${Yr(n.entry)}</string>
27
27
  <string>--daemon</string>
28
28
  </array>
29
29
  <key>RunAtLoad</key>
@@ -33,12 +33,12 @@ var j0=Object.create;var Wr=Object.defineProperty;var H0=Object.getOwnPropertyDe
33
33
  <key>ThrottleInterval</key>
34
34
  <integer>10</integer>
35
35
  <key>StandardOutPath</key>
36
- <string>${kr(n.logFile)}</string>
36
+ <string>${Yr(n.logFile)}</string>
37
37
  <key>StandardErrorPath</key>
38
- <string>${kr(n.logFile)}</string>
38
+ <string>${Yr(n.logFile)}</string>
39
39
  </dict>
40
40
  </plist>
41
- `},configPath(n){return Xg(n.homeDir,"Library","LaunchAgents",`${Hi}.plist`)},async install(n){let e=this.configPath(n);await Wg(Vg(e),{recursive:!0}),await Jg(e,this.renderConfig(n),"utf8"),Cr.info("plist written",{plistPath:e}),await Fc("launchctl",["load","-w",e]),Cr.info("launchd job loaded",{label:Hi})},async uninstall(n){let e=this.configPath(n);await Fc("launchctl",["unload","-w",e]).catch(s=>Cr.warn("launchctl unload failed (ignored)",{err:String(s)})),await $g(e).catch(s=>{if(s.code!=="ENOENT")throw s}),Cr.info("launchd job removed",{plistPath:e})}}});import{spawn as Yg}from"node:child_process";import{mkdir as Zg,unlink as Qg,writeFile as ep}from"node:fs/promises";import{dirname as tp,join as np}from"node:path";function Or(n,e){return new Promise((s,o)=>{let a=Yg(n,e,{stdio:["ignore","pipe","pipe"]}),d="";a.stderr?.on("data",u=>{d+=u.toString("utf8")}),a.on("error",o),a.on("close",u=>{u===0?s():o(new Error(`${n} ${e.join(" ")} exited ${u}: ${d.trim()}`))})})}var Dr,Rr,Wi,qc=Te(()=>{"use strict";q();Dr=D("supervisor.systemd"),Rr="coze-bridge.service",Wi={platform:"linux",renderConfig(n){return`[Unit]
41
+ `},configPath(n){return vp(n.homeDir,"Library","LaunchAgents",`${Es}.plist`)},async install(n){let e=this.configPath(n);await _p(bp(e),{recursive:!0}),await Ep(e,this.renderConfig(n),"utf8"),Zr.info("plist written",{plistPath:e}),await K0("launchctl",["load","-w",e]),Zr.info("launchd job loaded",{label:Es})},async uninstall(n){let e=this.configPath(n);await K0("launchctl",["unload","-w",e]).catch(i=>Zr.warn("launchctl unload failed (ignored)",{err:String(i)})),await yp(e).catch(i=>{if(i.code!=="ENOENT")throw i}),Zr.info("launchd job removed",{plistPath:e})}}});import{spawn as Sp}from"node:child_process";import{mkdir as Ip,unlink as Ap,writeFile as Cp}from"node:fs/promises";import{dirname as Tp,join as Dp}from"node:path";function ei(n,e){return new Promise((i,o)=>{let a=Sp(n,e,{stdio:["ignore","pipe","pipe"]}),c="";a.stderr?.on("data",u=>{c+=u.toString("utf8")}),a.on("error",o),a.on("close",u=>{u===0?i():o(new Error(`${n} ${e.join(" ")} exited ${u}: ${c.trim()}`))})})}var Xr,Qr,vs,$0=Be(()=>{"use strict";Z();Xr=q("supervisor.systemd"),Qr="coze-bridge.service",vs={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 np(n.homeDir,".config","systemd","user",Rr)},async install(n){let e=this.configPath(n);await Zg(tp(e),{recursive:!0}),await ep(e,this.renderConfig(n),"utf8"),Dr.info("systemd unit written",{unitPath:e}),await Or("systemctl",["--user","daemon-reload"]),await Or("systemctl",["--user","enable","--now",Rr]),Dr.info("systemd unit enabled",{unitName:Rr})},async uninstall(n){let e=this.configPath(n);await Or("systemctl",["--user","disable","--now",Rr]).catch(s=>Dr.warn("systemctl disable failed (ignored)",{err:String(s)})),await Qg(e).catch(s=>{if(s.code!=="ENOENT")throw s}),await Or("systemctl",["--user","daemon-reload"]).catch(()=>{}),Dr.info("systemd unit removed",{unitPath:e})}}});import{spawn as rp}from"node:child_process";import{join as ip}from"node:path";function Gc(n,e){return new Promise((s,o)=>{let a=rp(n,e,{stdio:["ignore","pipe","pipe"],shell:!1}),d="";a.stderr?.on("data",u=>{d+=u.toString("utf8")}),a.on("error",o),a.on("close",u=>{u===0?s():o(new Error(`${n} ${e.join(" ")} exited ${u}: ${d.trim()}`))})})}var $i,Nr,Ji,jc=Te(()=>{"use strict";q();$i=D("supervisor.taskscheduler"),Nr="CozeBridge",Ji={platform:"win32",renderConfig(n){return`<?xml version="1.0" encoding="UTF-16"?>
55
+ `},configPath(n){return Dp(n.homeDir,".config","systemd","user",Qr)},async install(n){let e=this.configPath(n);await Ip(Tp(e),{recursive:!0}),await Cp(e,this.renderConfig(n),"utf8"),Xr.info("systemd unit written",{unitPath:e}),await ei("systemctl",["--user","daemon-reload"]),await ei("systemctl",["--user","enable","--now",Qr]),Xr.info("systemd unit enabled",{unitName:Qr})},async uninstall(n){let e=this.configPath(n);await ei("systemctl",["--user","disable","--now",Qr]).catch(i=>Xr.warn("systemctl disable failed (ignored)",{err:String(i)})),await Ap(e).catch(i=>{if(i.code!=="ENOENT")throw i}),await ei("systemctl",["--user","daemon-reload"]).catch(()=>{}),Xr.info("systemd unit removed",{unitPath:e})}}});import{spawn as Pp}from"node:child_process";import{join as kp}from"node:path";function J0(n,e){return new Promise((i,o)=>{let a=Pp(n,e,{stdio:["ignore","pipe","pipe"],shell:!1}),c="";a.stderr?.on("data",u=>{c+=u.toString("utf8")}),a.on("error",o),a.on("close",u=>{u===0?i():o(new Error(`${n} ${e.join(" ")} exited ${u}: ${c.trim()}`))})})}var Ss,ti,Is,V0=Be(()=>{"use strict";Z();Ss=q("supervisor.taskscheduler"),ti="CozeBridge",Is={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 ip(n.homeDir,".coze","bridge","task.xml")},async install(n){let e=`"${n.nodeBin}" "${n.entry}" --daemon`;await Gc("schtasks",["/Create","/SC","ONLOGON","/TN",Nr,"/TR",e,"/RU",n.userName,"/F"]),$i.info("task scheduler entry created",{task:Nr})},async uninstall(n){await Gc("schtasks",["/Delete","/TN",Nr,"/F"]).catch(e=>$i.warn("schtasks /Delete failed (ignored)",{err:String(e)})),$i.info("task scheduler entry removed",{task:Nr})}}});var Hc={};$r(Hc,{buildContext:()=>cp,getSupervisor:()=>ap,launchdSupervisor:()=>Ki,systemdSupervisor:()=>Wi,taskSchedulerSupervisor:()=>Ji});import{homedir as sp,userInfo as op}from"node:os";function ap(n=process.platform){switch(n){case"darwin":return Ki;case"linux":return Wi;case"win32":return Ji;default:throw new Error(`unsupported platform for OS supervisor: ${n}`)}}function cp(){let n=G();return{nodeBin:process.execPath,entry:zi(n),logFile:n.logFile,homeDir:sp(),userName:op().username}}var Kc=Te(()=>{"use strict";oe();Ar();Uc();qc();jc()});q();q();import{execFile as Z0}from"node:child_process";import{promisify as Q0}from"node:util";var vs=Q0(Z0),Vt=D("agents.acp-installer"),ex={"claude-code":{npmPackage:"@agentclientprotocol/claude-agent-acp",binary:"claude-agent-acp"},codex:{npmPackage:"@zed-industries/codex-acp",binary:"codex-acp"}},tx=5e4,nx=5e3,rx=5*6e4,ix=new Set(["ETIMEDOUT","ECONNRESET","ECONNREFUSED","ENETUNREACH","EAI_AGAIN","ERR_SOCKET_TIMEOUT","ENOTFOUND"]),sx=/\b(5\d\d|408|429)\b\s+(Bad Gateway|Service Unavailable|Gateway Timeout|Internal Server Error|Too Many Requests|Request Timeout)/i,ox=/fetch failed|request timed out|socket hang up|network timeout/i;function ax(n){let e=n?.code;if(e&&ix.has(e))return!0;let s=n instanceof Error?`${n.message}
80
- ${n.stack??""}`:String(n);return sx.test(s)||ox.test(s)}function cx(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 An=new Map,En=new Map,In=new Map;async function bs(n){let e=process.platform==="win32"?"where":"which";try{let{stdout:s}=await vs(e,[n],{timeout:nx});return s.split(`
81
- `)[0]?.trim()||void 0}catch{return}}async function xx(n,e){Vt.info("npm install -g start",{npmPackage:n}),await vs("npm",["install","-g",`${n}@latest`],{timeout:tx,maxBuffer:10*1024*1024,...e?{signal:e}:{}}),Vt.info("npm install -g done",{npmPackage:n})}async function It(n,e){let s=ex[n];if(!s)return;let o=An.get(n);if(o)return o;let a=En.get(n);if(a&&Date.now()-a<rx)return;let d=In.get(n);if(d)return d;let u=(async()=>{let f=await bs(s.binary);if(f)return An.set(n,f),Vt.info("acp wrapper found on PATH",{binary:s.binary,path:f}),f;try{await xx(s.npmPackage,e)}catch(h){let y=ax(h);Vt.warn("acp wrapper install failed (will fallback to npx)",{npmPackage:s.npmPackage,transient:y,err:cx(h)}),y||En.set(n,Date.now());return}let p=await bs(s.binary);if(!p){Vt.warn("acp wrapper installed but binary not found on PATH",{binary:s.binary}),En.set(n,Date.now());return}return An.set(n,p),En.delete(n),p})().finally(()=>{In.delete(n)});return In.set(n,u),u}function Tt(n){return An.get(n)}function Ss(n){return In.get(n)}var Es=D("acp-installer-warmup"),dx=["claude-code","codex"];async function As(n={}){let e=n.ensure??It,o=(await Promise.allSettled(dx.map(async a=>{let d=await e(a);Es.info("acp wrapper warmup ok",{framework:a,installed:!!d,path:d??""})}))).filter(a=>a.status==="rejected");o.length>0&&Es.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))})}it();q();import{readdir as Ex}from"node:fs/promises";import{mkdir as Rs,writeFile as Os}from"node:fs/promises";import{join as Vr}from"node:path";var bx={"claude-code":"CLAUDE.md",codex:"AGENTS.md",openclaw:"SOUL.md"};async function Ct(n,e,s,o){await Rs(n,{recursive:!0});let a=bx[e],d=Vr(n,a),u=vx(e,s,o);return await Os(d,u,"utf8"),d}async function Ns(n){let e=Vr(n,".claude");await Rs(e,{recursive:!0});let s=Vr(e,"settings.local.json"),o=JSON.stringify({permissions:{defaultMode:"bypassPermissions"}},null,2);return await Os(s,o,"utf8"),s}function vx(n,e,s){let o=`# Coze Agent: ${e}
79
+ `},configPath(n){return kp(n.homeDir,".coze","bridge","task.xml")},async install(n){let e=`"${n.nodeBin}" "${n.entry}" --daemon`;await J0("schtasks",["/Create","/SC","ONLOGON","/TN",ti,"/TR",e,"/RU",n.userName,"/F"]),Ss.info("task scheduler entry created",{task:ti})},async uninstall(n){await J0("schtasks",["/Delete","/TN",ti,"/F"]).catch(e=>Ss.warn("schtasks /Delete failed (ignored)",{err:String(e)})),Ss.info("task scheduler entry removed",{task:ti})}}});var Z0={};hi(Z0,{buildContext:()=>Op,getSupervisor:()=>Lp,launchdSupervisor:()=>bs,systemdSupervisor:()=>vs,taskSchedulerSupervisor:()=>Is});import{homedir as Rp,userInfo as Np}from"node:os";function Lp(n=process.platform){switch(n){case"darwin":return bs;case"linux":return vs;case"win32":return Is;default:throw new Error(`unsupported platform for OS supervisor: ${n}`)}}function Op(){let n=Y();return{nodeBin:process.execPath,entry:hs(n),logFile:n.logFile,homeDir:Rp(),userName:Np().username}}var Y0=Be(()=>{"use strict";ye();Wr();W0();$0();V0()});Z();Z();import{execFile as iu}from"node:child_process";import{promisify as su}from"node:util";var Ys=su(iu),un=q("agents.acp-installer"),ou={"claude-code":{npmPackage:"@agentclientprotocol/claude-agent-acp",binary:"claude-agent-acp"},codex:{npmPackage:"@zed-industries/codex-acp",binary:"codex-acp"}},au=5e4,cu=5e3,du=5*6e4,uu=new Set(["ETIMEDOUT","ECONNRESET","ECONNREFUSED","ENETUNREACH","EAI_AGAIN","ERR_SOCKET_TIMEOUT","ENOTFOUND"]),fu=/\b(5\d\d|408|429)\b\s+(Bad Gateway|Service Unavailable|Gateway Timeout|Internal Server Error|Too Many Requests|Request Timeout)/i,xu=/fetch failed|request timed out|socket hang up|network timeout/i;function lu(n){let e=n?.code;if(e&&uu.has(e))return!0;let i=n instanceof Error?`${n.message}
80
+ ${n.stack??""}`:String(n);return fu.test(i)||xu.test(i)}function gu(n){if(n==null||typeof n!="object")return String(n);let e=n,i=[];e.message&&i.push(e.message),e.code!==void 0&&e.code!==null&&i.push(`code=${e.code}`),e.signal&&i.push(`signal=${e.signal}`);let o=e.stderr?.toString().trim();o&&i.push(`stderr=${o.slice(0,2e3)}`);let a=e.stdout?.toString().trim();return a&&i.push(`stdout=${a.slice(0,2e3)}`),i.length>0?i.join(" | "):String(n)}var qn=new Map,Un=new Map,Hn=new Map;async function Zs(n){let e=process.platform==="win32"?"where":"which";try{let{stdout:i}=await Ys(e,[n],{timeout:cu});return i.split(`
81
+ `)[0]?.trim()||void 0}catch{return}}async function hu(n,e){un.info("npm install -g start",{npmPackage:n}),await Ys("npm",["install","-g",`${n}@latest`],{timeout:au,maxBuffer:10*1024*1024,...e?{signal:e}:{}}),un.info("npm install -g done",{npmPackage:n})}async function Bt(n,e){let i=ou[n];if(!i)return;let o=qn.get(n);if(o)return o;let a=Un.get(n);if(a&&Date.now()-a<du)return;let c=Hn.get(n);if(c)return c;let u=(async()=>{let x=await Zs(i.binary);if(x)return qn.set(n,x),un.info("acp wrapper found on PATH",{binary:i.binary,path:x}),x;try{await hu(i.npmPackage,e)}catch(g){let E=lu(g);un.warn("acp wrapper install failed (will fallback to npx)",{npmPackage:i.npmPackage,transient:E,err:gu(g)}),E||Un.set(n,Date.now());return}let l=await Zs(i.binary);if(!l){un.warn("acp wrapper installed but binary not found on PATH",{binary:i.binary}),Un.set(n,Date.now());return}return qn.set(n,l),Un.delete(n),l})().finally(()=>{Hn.delete(n)});return Hn.set(n,u),u}function zt(n){return qn.get(n)}function Xs(n){return Hn.get(n)}var Qs=q("acp-installer-warmup"),pu=["claude-code","codex"];async function eo(n={}){let e=n.ensure??Bt,o=(await Promise.allSettled(pu.map(async a=>{let c=await e(a);Qs.info("acp wrapper warmup ok",{framework:a,installed:!!c,path:c??""})}))).filter(a=>a.status==="rejected");o.length>0&&Qs.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))})}lt();Z();import{readdir as Du}from"node:fs/promises";import{mkdir as ao,writeFile as co}from"node:fs/promises";import{join as mi}from"node:path";var Au={"claude-code":"CLAUDE.md",codex:"AGENTS.md",openclaw:"SOUL.md"};async function Ut(n,e,i,o){await ao(n,{recursive:!0});let a=Au[e],c=mi(n,a),u=Cu(e,i,o);return await co(c,u,"utf8"),c}async function uo(n){let e=mi(n,".claude");await ao(e,{recursive:!0});let i=mi(e,"settings.local.json"),o=JSON.stringify({permissions:{defaultMode:"bypassPermissions"}},null,2);return await co(i,o,"utf8"),i}function Cu(n,e,i){let o=`# Coze Agent: ${e}
82
82
 
83
83
  > framework: \`${n}\`
84
84
 
85
- `,a=s?.trim()?s.endsWith(`
86
- `)?s:`${s}
85
+ `,a=i?.trim()?i.endsWith(`
86
+ `)?i:`${i}
87
87
  `:`_No instructions provided._
88
88
  `;return`${o}---
89
89
 
90
90
  ${a}
91
- ${Sx}`}var Sx=`## \u53D1\u9001\u6587\u4EF6 / \u56FE\u7247\u7ED9\u7528\u6237
91
+ ${Tu}`}var Tu=`## \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,29 +112,29 @@ ${Sx}`}var Sx=`## \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 Ee=D("agent-detail-sync"),Ax=6e4,Ix=5*6e4,Rn=class{constructor(e){this.opts=e}opts;retryQueue=new Map;async syncAll(e){let s=this.opts.paths.agentsRoot,o;try{o=await Ex(s)}catch(a){Ee.info("agents dir not found, skip detail sync",{root:s,err:String(a)});return}Ee.info("starting detail sync",{reason:e,count:o.length}),await Promise.allSettled(o.map(async a=>{let d=await he(a,this.opts.paths).catch(()=>null);if(d){if(d.disconnectedAt){Ee.debug("detail sync: skip disconnected agent",{agentId:a});return}try{await this.syncOne(a,d)}catch(u){Ee.warn("detail sync failed for agent, skipping",{agentId:a,err:String(u)})}}})),Ee.info("detail sync done",{reason:e})}async retryPending(){if(this.retryQueue.size===0)return;let e=Date.now(),s=[];for(let[o,a]of this.retryQueue)e>=a.dueAt&&s.push(o);if(s.length!==0){Ee.info("retrying pending detail syncs",{count:s.length});for(let o of s)try{await this.syncOne(o)}catch(a){Ee.debug("detail sync retry still failing, will try again",{agentId:o,err:String(a)})}}}async syncOne(e,s){let o=s??await he(e,this.opts.paths);if(!o){Ee.info("detail sync: agent config missing, skip",{agentId:e});return}let a;try{a=await this.opts.sendDetail({_meta:{cozeAgentId:e}}),this.retryQueue.delete(e)}catch(f){Ee.warn("detail RPC failed, using local data",{agentId:e,err:String(f)});let p=this.retryQueue.get(e),h=p?Math.min(p.currentDelay*2,Ix):Ax;this.retryQueue.set(e,{dueAt:Date.now()+h,currentDelay:h});return}if(a.agentId&&a.agentId!==e){Ee.warn("detail response agentId mismatch, ignoring",{agentId:e,responseAgentId:a.agentId});return}let d=!1,u=!1;if(a.agentName&&a.agentName!==o.agentName&&(o.agentName=a.agentName,d=!0),a.description!==void 0&&a.description!==o.description&&(o.description=a.description,d=!0),a.cozeIdentity&&a.cozeIdentity!==o.cozeIdentity&&(o.cozeIdentity=a.cozeIdentity,d=!0,u=!0),a.deployType&&Ee.info("detail.deployType",{agentId:e,deployType:a.deployType}),!d){Ee.debug("detail sync: no diff",{agentId:e});return}await Se(o,this.opts.paths),Ee.info("detail sync: config updated",{agentId:e,identityChanged:u,agentName:o.agentName}),u&&(await Ct(o.workspace,o.framework,e,o.cozeIdentity),this.opts.handlers.reloadAgentSessionsPublic(e,"detail-sync"))}};it();import{spawn as eo}from"node:child_process";import{lstat as ei,mkdir as Cx,readFile as to,readdir as kx,rm as Dx,stat as Rx,writeFile as Zs}from"node:fs/promises";import{join as Me,normalize as Ox,relative as no,resolve as Nx,sep as ro}from"node:path";var Ne={PAIR:"_agent/pair",CREATE:"_agent/create",HEALTH:"_agent/health",LIST_SKILLS:"_agent/listSkills",ADD_SKILLS:"_agent/addSkills",REMOVE_SKILLS:"_agent/removeSkills",GET_FILE_TREE:"_agent/getFileTree",GET_FILE_CONTENT:"_agent/getFileContent",DETAIL:"_agent/detail",UPDATE:"_agent/update",DISCONNECT:"_agent/disconnect",SWITCH_MODEL:"_agent/switchModel",GEN_MODEL_TOKEN:"_agent/genModelToken",RESET:"_agent/reset",REPAIR:"_agent/repair",DELETE:"_agent/delete"};function Xt(n){return n?.cozeDeployType==="cloud"?"cloud":"local"}function Ls(n){let e=n?.cozeAccountId?.trim();if(!(!e||e==="0"))return e}function Ms(n){let e=n?.cozeGroupId?.trim();if(!(!e||e==="0"))return e}function Bs(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 b=class extends Error{code;retriable;cause;constructor(e,s,o){super(s),this.name="BridgeError",this.code=e,this.retriable=o?.retriable??!1,o?.cause!==void 0&&(this.cause=o.cause)}};q();oe();function Je(n,e){if(Xt(n)!=="cloud")throw new b("OPERATION_NOT_ALLOWED_FOR_LOCAL",`${e} is not allowed for local agent`)}function On(n){return n.startsWith("http://")||n.startsWith("https://")}function Nn(n){return n.endsWith("/")?n.slice(0,-1):n}q();var Ln="1008033",zs="1289";var Fs="pbbp2",Us="https://www.coze.cn",qs="/api/coze_claw/resource/get_frontier_key",Tx="https://www.coze.cn",Px="wss://frontier.coze.cn";function Mn(n){return n??process.env.COZE_BRIDGE_HANDSHAKE_URL??Tx}function Gs(n){return n??process.env.COZE_BRIDGE_FRONTIER_URL??Px}function Dt(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 Yt(n){return n?n.startsWith("boe_")?{ttEnv:n}:{ttEnv:n,usePpe:"1"}:{}}var js=D("handshake");async function Xr(n){let e=Mn(n.endpoint),s=n.timeoutMs??1e4,o=`${Nn(e)}${qs}?aid=${encodeURIComponent(Ln)}`,a={Authorization:`Bearer ${n.privatecode}`,Accept:"application/json",...Dt(n.ppeOverride)},d=new AbortController,u=setTimeout(()=>d.abort(),s);js.info("frontier key handshake",{base:e});try{let f=await fetch(o,{method:"GET",headers:a,signal:d.signal}),p=f.headers.get("x-tt-logid")??"",h=f.headers.get("x-tt-trace-id")??"";if(!f.ok){let E=await f.text().catch(()=>"");throw new b("UPSTREAM_HANDSHAKE_FAILED",`handshake HTTP ${f.status} logid=${p}: ${E.slice(0,200)}`)}let y=await f.json();if(y.code!==void 0&&y.code!==0)throw new b("UPSTREAM_HANDSHAKE_FAILED",`handshake code=${y.code} msg=${y.msg??"-"} logid=${p}`);let w=y.data??{},A=typeof w.access_key=="string"&&w.access_key||typeof w.accessKey=="string"&&w.accessKey||void 0,I=typeof w.device_id=="string"&&w.device_id||typeof w.deviceId=="string"&&w.deviceId||void 0;if(!A||!I){let E=JSON.stringify(y).slice(0,500);throw new b("UPSTREAM_HANDSHAKE_FAILED",`handshake response missing access_key/device_id (also tried camelCase) logid=${p}: ${E}`)}return js.info("handshake ok",{remoteDeviceId:I,logid:p,traceId:h}),{accessKey:A,deviceId:I}}catch(f){throw f instanceof b?f:f.name==="AbortError"?new b("UPSTREAM_HANDSHAKE_FAILED",`handshake timeout (${s}ms)`):new b("UPSTREAM_HANDSHAKE_FAILED",String(f),{cause:f})}finally{clearTimeout(u)}}var Yr=process.env.COZE_BRIDGE_LLM_GATEWAY_URL?.trim()||"https://llm-gateway.coze.cn",Le="auto";function Hs(n){return{model:n.model??Le,...n.modelToken?{modelToken:n.modelToken}:{}}}function Ks(n){return!n||n===Le}function Ws(n){let e={};return n.modelToken?(e.ANTHROPIC_BASE_URL=Yr,e.ANTHROPIC_AUTH_TOKEN=n.modelToken,e.ANTHROPIC_MODEL=n.model||Le,n.modelInfo?.contextWindow&&(e.CLAUDE_CODE_MAX_CONTEXT_TOKENS=String(n.modelInfo.contextWindow))):Ks(n.model)||(e.ANTHROPIC_MODEL=n.model),e}function $s(n){let e=[];return n.modelToken?e.push("-c",`model="${n.model||Le}"`):Ks(n.model)||e.push("-c",`model="${n.model}"`),n.modelToken&&(e.push("-c",'model_providers.coze.name="coze"'),e.push("-c",`model_providers.coze.base_url="${Yr}/v1"`),e.push("-c",'model_providers.coze.env_key="OPENAI_API_KEY"'),e.push("-c",'model_providers.coze.wire_api="responses"'),e.push("-c","model_providers.coze.requires_openai_auth=false"),e.push("-c","model_providers.coze.supports_websockets=false"),e.push("-c",'model_provider="coze"'),n.modelInfo?.contextWindow&&e.push("-c",`model_context_window=${n.modelInfo.contextWindow}`)),e}function Js(n){return n.modelToken?{OPENAI_API_KEY:n.modelToken}:{}}function Zr(n){let{ttEnv:e,usePpe:s}=Yt(n),o={};return e&&(o["x-tt-env"]=e),s&&(o["x-use-ppe"]=s),o}function Vs(n,e){if(!n.modelToken)return{};let s=Zr(e);return Object.keys(s).length===0?{}:{ANTHROPIC_CUSTOM_HEADERS:Object.entries(s).map(([a,d])=>`${a}:${d}`).join(`
116
- `)}}function Qr(n){return`coze-session-${n.replace(/[^A-Za-z0-9_-]+/g,"-")}`}function Xs(n,e){if(!n.modelToken)return null;let s=n.model||Le,o=Zr(e),a=["text"];n.modelInfo?.capabilities?.image===!0&&a.push("image");let d={baseUrl:`${Yr}/v1`,api:"openai-completions",apiKey:n.modelToken,models:[{id:s,name:s,reasoning:!1,input:a,cost:{input:0,output:0,cacheRead:0,cacheWrite:0},contextWindow:n.modelInfo?.contextWindow??128e3,maxTokens:8192,api:"openai-completions"}]};return Object.keys(o).length>0&&(d.headers=o),d}function Ys(n,e){if(!n.modelToken)return[];let s=Zr(e),o=[];for(let[a,d]of Object.entries(s))o.push("-c",`model_providers.coze.http_headers.${a}="${d}"`);return o}var ce=D("agent-handlers"),Qs=5*1024*1024,Lx=1,Mx=6,Bx=new Set(["node_modules",".git",".coze","dist","build",".next"]),Bn=class{constructor(e){this.opts=e}opts;async listSkills(e){Je(e._meta,"_agent/listSkills");let s=kt(e._meta),o=await this.loadAgentCfg(s),a=o?.workspace??$e(s).workspace,d=o?.skills??[],u=[];for(let f of d){let p=Me(a,f.relPath,"SKILL.md");await Rx(p).then(y=>y.isFile()).catch(()=>!1)&&u.push(Gx(f))}return{skills:u}}async addSkills(e){Je(e._meta,"_agent/addSkills");let s=kt(e._meta),o=await this.requireAgentCfg(s),a=e.skills??[],d=[...o.skills??[]],u=new Map(d.map((p,h)=>[p.skillId,h])),f=[];for(let p of a){let h=await ti({agentId:s,workspace:o.workspace,framework:o.framework,skill:p});ni(d,u,h),f.push(p)}return await kn(s,d),this.reloadAgentSessions(s,"skills-added"),{installedSkills:f}}async removeSkills(e){Je(e._meta,"_agent/removeSkills");let s=kt(e._meta),o=await this.requireAgentCfg(s),a=new Set(e.skillIds??[]),d=o.skills??[],u=[];for(let f of d){if(!a.has(f.skillId)){u.push(f);continue}let p=Me(o.workspace,f.relPath);await Dx(p,{recursive:!0,force:!0}),ce.info("skill removed",{agentId:s,skillId:f.skillId,relPath:f.relPath})}return await kn(s,u),this.reloadAgentSessions(s,"skills-removed"),{ok:!0}}reloadAgentSessionsPublic(e,s){this.reloadAgentSessions(e,s)}reloadAgentSessions(e,s){let o=this.opts.agents.get(e);if(o)for(let[a,d]of o.sessions){if(!d.downstream)continue;let u=d.acpSessionId;if(u&&o.activeTriggers.has(u)||this.isRuntimePendingPermission(d)){d.reloadAfterTurn=!0,ce.info("downstream busy, scheduling reload after turn",{reason:s,agentId:e,framework:o.framework,cloudId:a,acpId:u});continue}let p=d.downstream;d.downstream=void 0,ce.info("killing downstream for workspace reload (idle)",{reason:s,agentId:e,framework:o.framework,cloudId:a,acpId:u}),p.stop(s).catch(h=>ce.warn("downstream stop failed during reload (ignored)",{reason:s,agentId:e,cloudId:a,err:String(h)}))}}isRuntimePendingPermission(e){let s=this.opts.isRuntimePendingPermission;return!s||!e.downstream?!1:s(e.downstream)}async updateAgent(e){if(!e.cozeIdentity?.trim())return ce.info("_agent/update: empty cozeIdentity, noop",{agentId:e.agentId}),{ok:!0};let s=e.agentId,o=await he(s);if(!o)throw new b("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 Ct(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 b("AGENT_PROTOCOL_ERROR",`failed to write instruction file for agent ${s}: ${String(a)}`,{cause:a})}return o.cozeIdentity=e.cozeIdentity,await Se(o),ce.info("_agent/update: cozeIdentity rewritten",{agentId:s,framework:o.framework}),this.reloadAgentSessions(s,"identity-changed"),{ok:!0}}async disconnectAgent(e){let s=e.agentId;if(!s)throw new b("IPC_BAD_REQUEST","_agent/disconnect: missing agentId");let o=await he(s);return o?(o.disconnectedAt=Date.now(),o.disconnectReason=e.reason??"",await Se(o),ce.info("agent disconnected",{agentId:s,reason:e.reason??"",force:e.force??!1}),this.opts.disposeAndMarkDisconnected&&await this.opts.disposeAndMarkDisconnected(s,e.reason??"disconnect"),{ok:!0}):(ce.warn("_agent/disconnect: agent not found, ignoring",{agentId:s}),{ok:!0})}async switchModel(e){if(Je(e._meta,"_agent/switchModel"),!e.agentId)throw new b("IPC_BAD_REQUEST","_agent/switchModel: missing agentId");let s=e.model?.trim()?e.model:Le,o=await he(e.agentId);if(!o)throw new b("AGENT_NOT_FOUND",`agent not found: ${e.agentId}`);o.model=s,e.modelInfo&&(o.modelInfo=e.modelInfo),await Se(o),ce.info("_agent/switchModel: model persisted",{agentId:e.agentId,model:s,reason:e.reason??""});let 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,e.modelInfo&&a.setModelInfo(e.modelInfo),this.opts.cleanupOpenclawProviders&&await this.opts.cleanupOpenclawProviders(a).catch(u=>ce.warn("cleanupOpenclawProviders before switchModel failed (ignored)",{agentId:e.agentId,err:String(u)}));let d=[];for(let[u,f]of a.allSessionQueues())d.push(f.enqueue(async()=>{let p=a.sessions.get(u);p?.downstream&&(await p.downstream.stop(`switchModel: ${s}`).catch(()=>{}),p.downstream=void 0)}));return await Promise.all(d),ce.info("_agent/switchModel: all session runtimes killed, next prompt will respawn",{agentId:e.agentId,model:s,cloudSessions:d.length}),{ok:!0}}async resetAgent(e){if(Je(e._meta,Ne.RESET),!e.agentId)throw new b("IPC_BAD_REQUEST",`${Ne.RESET}: missing agentId`);return await this.runDetailSync(e.agentId,Ne.RESET,e.reason),{ok:!0}}async repairAgent(e){if(Je(e._meta,Ne.REPAIR),!e.agentId)throw new b("IPC_BAD_REQUEST",`${Ne.REPAIR}: missing agentId`);let s=await this.loadAgentCfg(e.agentId);if(s&&s.framework!=="openclaw")throw new b("IPC_BAD_REQUEST",`${Ne.REPAIR} only allowed for openclaw, got ${s.framework}`);if(s&&this.opts.openclawRepair)try{await this.opts.openclawRepair(e.agentId,s.workspace)}catch(o){ce.warn("openclaw repair (delete+add) failed (ignored)",{agentId:e.agentId,reason:e.reason,err:String(o)})}return await this.runDetailSync(e.agentId,Ne.REPAIR,e.reason),{ok:!0}}async runDetailSync(e,s,o){if(!this.opts.detailSyncer){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){Je(e._meta,"_agent/getFileTree");let s=e._meta,o=kt(s),a=await this.resolveWorkspace(o),d=e.filePath??"",u=this.safeJoin(a,d),f=await ei(u).catch(()=>null);if(!f)throw new b("IPC_BAD_REQUEST",`path not found: ${d}`);if(f.isSymbolicLink())throw new b("IPC_BAD_REQUEST",`symlink not allowed: ${d}`);let p=Xx(e.depth);return f.isDirectory()?{tree:await Vx(a,u,d,p)}:{tree:[{name:Yx(d),path:so(d||"."),isDir:!1,size:f.size,modifiedAt:Math.floor(f.mtimeMs)}]}}async getFileContent(e){Je(e._meta,"_agent/getFileContent");let s=kt(e._meta),o=await this.resolveWorkspace(s);if(!e.filePath)throw new b("IPC_BAD_REQUEST","filePath required");let a=this.safeJoin(o,e.filePath),d=await ei(a).catch(()=>null);if(!d||!d.isFile())throw new b("IPC_BAD_REQUEST",`not a file: ${e.filePath}`);if(d.isSymbolicLink())throw new b("IPC_BAD_REQUEST",`symlink not allowed: ${e.filePath}`);if(d.size>Qs)throw new b("IPC_BAD_REQUEST",`file too large: ${d.size} bytes (max ${Qs})`);let u=await to(a);return u.includes(0)?{content:u.toString("base64"),encoding:"base64",size:d.size}:{content:u.toString("utf8"),encoding:"utf-8",size:d.size}}async resolveWorkspace(e){let s=this.opts.agents.get(e);return s?s.workspace:(await he(e).catch(()=>null))?.workspace??$e(e).workspace}safeJoin(e,s){let o=Nx(e,s||"."),a=no(e,o);if(a.startsWith("..")||a===".."||a.startsWith(`..${ro}`))throw new b("IPC_BAD_REQUEST",`path escapes workspace: ${s}`);return o}loadAgentCfg(e){return he(e)}async requireAgentCfg(e){let s=await this.loadAgentCfg(e);if(!s)throw new b("AGENT_NOT_FOUND",`no config for agent: ${e}`);return s}};function zx(n){let e=n.trim().replace(/[\x00-\x1f<>:"|?*/\\]+/g,"-").replace(/^[\s.-]+|[\s.-]+$/g,"").slice(0,64);if(!e||e==="."||e==="..")throw new b("IPC_BAD_REQUEST",`invalid skill name: ${n}`);if(/^(con|prn|aux|nul|com[1-9]|lpt[1-9])$/i.test(e))throw new b("IPC_BAD_REQUEST",`reserved windows filename: ${n}`);return e}function Fx(n){return n==="claude-code"?Me(".claude","skills"):Me(".agents","skills")}var Ux=3e4,qx=50*1024*1024,zn=3e4;async function ti(n){let{agentId:e,workspace:s,framework:o,skill:a}=n;if(!a.skillName)throw new b("IPC_BAD_REQUEST","skill missing skillName");let d=typeof a.content=="string"&&a.content.length>0,u=typeof a.downloadUrl=="string"&&a.downloadUrl.length>0;if(!d&&!u)throw new b("IPC_BAD_REQUEST",`skill ${a.skillId} missing both content and downloadUrl`);let f=zx(a.skillName),p=Fx(o),h=Me(p,f),y=Me(s,h);if(await Cx(y,{recursive:!0}),d){let A=Buffer.from(a.content,"utf8");Zt(A.length),await Zs(Me(y,"SKILL.md"),A,"utf8")}else{let A=await jx(a.downloadUrl);Kx(A)?await Wx(A,y):await Zs(Me(y,"SKILL.md"),A.toString("utf8"),"utf8")}let w={skillId:a.skillId,skillName:a.skillName,relPath:h,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:h,source:d?"content":"downloadUrl"}),w}function ni(n,e,s){let o=e.get(s.skillId);if(o!==void 0){n[o]=s;return}e.set(s.skillId,n.length),n.push(s)}function Gx(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 jx(n){if(!n)throw new b("IPC_BAD_REQUEST","skill missing downloadUrl");if(n.startsWith("data:")){let e=Math.floor(n.length*3/4);Zt(e);let s=Hx(n);return Zt(s.length),s}if(n.startsWith("file:")){let e=new URL(n).pathname,s=await to(e);return Zt(s.length),s}if(On(n)){let e=new AbortController,s=setTimeout(()=>e.abort(),Ux);try{let o=await fetch(n,{signal:e.signal});if(!o.ok)throw new b("IPC_BAD_REQUEST",`fetch skill failed HTTP ${o.status} ${n}`);let a=await o.arrayBuffer();return Zt(a.byteLength),Buffer.from(a)}finally{clearTimeout(s)}}throw new b("IPC_BAD_REQUEST",`unsupported downloadUrl scheme (\u8981 https/data/file): ${n.slice(0,80)}`)}function Zt(n){if(n>qx)throw new b("IPC_BAD_REQUEST",`skill too large: ${n} bytes`)}function Hx(n){let e=/^data:([^,;]*)(;base64)?,(.*)$/s.exec(n);if(!e)throw new b("IPC_BAD_REQUEST","bad data URL");let s=!!e[2],o=e[3]??"";return s?Buffer.from(o,"base64"):Buffer.from(decodeURIComponent(o),"utf8")}function Kx(n){return n.length>=2&&n[0]===31&&n[1]===139}async function Wx(n,e){await $x(n),await new Promise((s,o)=>{let a=eo("tar",["-xzf","-","-C",e,"--strip-components=1","--no-same-owner"],{stdio:["pipe","pipe","pipe"]}),d="";a.stderr?.on("data",f=>{d+=String(f)});let u=setTimeout(()=>{a.kill("SIGKILL"),o(new b("IPC_BAD_REQUEST",`tar extract timeout (${zn}ms)`))},zn);a.on("error",f=>{clearTimeout(u),o(new b("IPC_BAD_REQUEST",`tar spawn failed: ${f.message}`,{cause:f}))}),a.on("exit",f=>{clearTimeout(u),f===0?s():o(new b("IPC_BAD_REQUEST",`tar exit ${f}${d?`: ${d.trim().slice(0,200)}`:""}`))}),a.stdin?.end(n)})}async function $x(n){let e=await new Promise((s,o)=>{let a=eo("tar",["-tzvf","-"],{stdio:["pipe","pipe","pipe"]}),d="",u="";a.stdout?.on("data",p=>{d+=String(p)}),a.stderr?.on("data",p=>{u+=String(p)});let f=setTimeout(()=>{a.kill("SIGKILL"),o(new b("IPC_BAD_REQUEST",`tar list timeout (${zn}ms)`))},zn);a.on("error",p=>{clearTimeout(f),o(new b("IPC_BAD_REQUEST",`tar list spawn failed: ${p.message}`))}),a.on("exit",p=>{clearTimeout(f),p===0?s(d):o(new b("IPC_BAD_REQUEST",`tar list exit ${p}${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 b("IPC_BAD_REQUEST",`tar entry kind '${o[0]}' not allowed (symlink/hardlink/special): ${o.slice(0,100)}`);let u=(o.match(/\s(\S.*)$/)?.[1]??"").split(" -> ")[0]?.trim()??"";if(!u)continue;if(u.startsWith("/"))throw new b("IPC_BAD_REQUEST",`tar entry absolute path: ${u}`);if(u.split(/[/\\]/).some(p=>p===".."))throw new b("IPC_BAD_REQUEST",`tar entry contains '..': ${u}`)}}var Jx=5e3;async function Vx(n,e,s,o){return io(n,e,s,o,{count:0})}async function io(n,e,s,o,a){if(o<=0)return[];let d;try{d=await kx(e,{withFileTypes:!0})}catch{return[]}let u=[];for(let f of d){if(Bx.has(f.name)||f.isSymbolicLink())continue;if(a.count>=Jx){u.push({name:"...",path:"...",isDir:!1,size:0,modifiedAt:0,hasMore:!0});break}let p=Me(e,f.name),h=Ox(Me(s,f.name)),y=null;try{y=await ei(p)}catch{continue}if(y.isSymbolicLink())continue;a.count++;let w={name:f.name,path:so(no(n,p)),isDir:y.isDirectory(),size:y.size,modifiedAt:Math.floor(y.mtimeMs)};y.isDirectory()&&o>1&&(w.children=await io(n,p,h,o-1,a)),u.push(w)}return u.sort((f,p)=>f.isDir!==p.isDir?f.isDir?-1:1:f.name.localeCompare(p.name)),u}function Xx(n){return!n||n<=0?Lx:Math.min(n,Mx)}function Yx(n){if(!n||n==="."||n==="/")return".";let e=n.split(/[/\\]/);return e[e.length-1]||"."}function so(n){return n.split(ro).join("/")}q();import{readFileSync as Ah}from"node:fs";import{dirname as Th,join as Ph}from"node:path";import{fileURLToPath as kh}from"node:url";var st="0.1.67";var Be=D("agent-health-reporter"),Zx=1e4,Qt=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 f of this.opts.core.agents.values()){let p=Qx(f);if(!p)continue;let h={agentId:f.agentId,status:p};f.patToken&&(h.patToken=f.patToken),f.accountId&&(h.accountId=f.accountId),s.push(h)}if(s.length===0)return;let o={agents:s,bridgeVersion:st,_meta:{cozeDeviceId:e}},a;try{a=await this.opts.core.sendRequest("_agent/health",o,5e3)}catch(f){Be.warn("heartbeat batch send failed",{count:s.length,err:String(f)})}let d=a?.authFailures;if(d&&d.length>0&&(Be.warn("heartbeat received authFailures from cloud",{count:d.length,agentIds:d.map(f=>f.agentId)}),this.opts.onAuthFailures))try{await this.opts.onAuthFailures(d)}catch(f){Be.warn("onAuthFailures callback failed (ignored)",{err:String(f)})}let u=a?.minBridgeVersion;if(u&&(Be.info("heartbeat received minBridgeVersion from cloud",{minV:u}),this.opts.onMinBridgeVersion))try{await this.opts.onMinBridgeVersion(u)}catch(f){Be.warn("onMinBridgeVersion callback failed (ignored)",{err:String(f)})}}finally{this.inFlight=!1}if(this.opts.onTickEnd)try{await this.opts.onTickEnd()}catch(s){Be.warn("onTickEnd hook failed",{err:String(s)})}}};function Qx(n){return n.status==="error"?"error":n.activeTriggers.size>0?"busy":n.status==="ok"?"online":null}it();import{mkdir as si,rm as Td}from"node:fs/promises";import{spawn as ad,spawnSync as cd}from"node:child_process";function en(n,e,s){return s===void 0?{jsonrpc:"2.0",id:n,method:e}:{jsonrpc:"2.0",id:n,method:e,params:s}}function tn(n,e){return e===void 0?{jsonrpc:"2.0",method:n}:{jsonrpc:"2.0",method:n,params:e}}function Rt(n,e){return{jsonrpc:"2.0",id:n,result:e}}function ot(n,e){return{jsonrpc:"2.0",id:n,error:e}}var Fn=class extends Error{code;data;constructor(e){super(`JSON-RPC error code=${e.code} ${e.message}`),this.name="RemoteRpcError",this.code=e.code,e.data!==void 0&&(this.data=e.data)}},j={PARSE_ERROR:-32700,INVALID_REQUEST:-32600,METHOD_NOT_FOUND:-32601,INVALID_PARAMS:-32602,INTERNAL_ERROR:-32603,AGENT_NOT_FOUND:-32001,AGENT_BUSY:-32002,AGENT_TIMEOUT:-32003,AGENT_SPAWN_FAILED:-32004,OPERATION_NOT_ALLOWED_FOR_LOCAL:-32005,AGENT_DISCONNECTED:-32006,MODEL_TOKEN_GEN_FAILED:-32009,PATH_OUTSIDE_WORKSPACE:-32010,FILE_TOO_LARGE:-32011,UNSUPPORTED_MIME:-32012,UPLOAD_FAILED:-32013,UPSTREAM_NOT_READY:-32014,BRIDGE_UPGRADING:-32015,AGENT_FRAME_IDLE_TIMEOUT:-32016,MODEL_MODALITY_UNSUPPORTED:-32017};function oo(n){return"method"in n&&"id"in n&&n.id!==void 0}function ao(n){return"method"in n&&!("id"in n)}function Un(n){return!("method"in n)&&"id"in n}var ed={AGENT_NOT_FOUND:j.AGENT_NOT_FOUND,AGENT_BUSY:j.AGENT_BUSY,AGENT_DISCONNECTED:j.AGENT_DISCONNECTED,AGENT_TIMEOUT:j.AGENT_TIMEOUT,AGENT_FRAME_IDLE_TIMEOUT:j.AGENT_FRAME_IDLE_TIMEOUT,AGENT_SPAWN_FAILED:j.AGENT_SPAWN_FAILED,AGENT_PROTOCOL_ERROR:j.INTERNAL_ERROR,BRIDGE_CONFIG_INVALID:j.INTERNAL_ERROR,BRIDGE_INTERNAL:j.INTERNAL_ERROR,IPC_AUTH_FAILED:j.INTERNAL_ERROR,IPC_BAD_REQUEST:j.INVALID_REQUEST,MODEL_TOKEN_GEN_FAILED:j.MODEL_TOKEN_GEN_FAILED,MODEL_MODALITY_UNSUPPORTED:j.MODEL_MODALITY_UNSUPPORTED,OPERATION_NOT_ALLOWED_FOR_LOCAL:j.OPERATION_NOT_ALLOWED_FOR_LOCAL,UPSTREAM_DISCONNECTED:j.INTERNAL_ERROR,UPSTREAM_HANDSHAKE_FAILED:j.INTERNAL_ERROR,PATH_OUTSIDE_WORKSPACE:j.PATH_OUTSIDE_WORKSPACE,FILE_TOO_LARGE:j.FILE_TOO_LARGE,UNSUPPORTED_MIME:j.UNSUPPORTED_MIME,UPLOAD_FAILED:j.UPLOAD_FAILED,UPSTREAM_NOT_READY:j.UPSTREAM_NOT_READY,BRIDGE_UPGRADING:j.BRIDGE_UPGRADING,NPX_CACHE_CORRUPT:j.INTERNAL_ERROR};function td(n){if(n!=null)return n instanceof Error?{name:n.name,message:nn(n.message)}:typeof n=="string"?nn(n):typeof n=="object"?rd(n):n}var nd=[[/\/Users\/[^/\s'"`)]+/g,"/Users/<redacted>"],[/\/home\/[^/\s'"`)]+/g,"/home/<redacted>"],[/[A-Za-z]:\\Users\\[^\\\s'"`)]+/g,"C:\\Users\\<redacted>"],[/(Bearer|Token|Authorization:)\s+[\w._-]+/gi,"$1 <redacted>"],[/\b(sk|pat|ak)[-_][A-Za-z0-9_-]{20,}\b/g,"<redacted-key>"]];function nn(n){let e=n;for(let[s,o]of nd)e=e.replace(s,o);return e}function rd(n){let e={};for(let[s,o]of Object.entries(n))typeof o=="string"?e[s]=nn(o):e[s]=o;return e}function rn(n){if(n instanceof b){let e=td(n.cause),s={bridgeCode:n.code,retriable:n.retriable};return e!==void 0&&(s.cause=e),{code:ed[n.code]??j.INTERNAL_ERROR,message:nn(n.message),data:s}}return{code:j.INTERNAL_ERROR,message:nn(n instanceof Error?n.message:String(n))}}function co(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,d=n.data;if(o&&e){let{message:u,...f}=e;d=f}return new b(s,a,{retriable:e?.retriable??!1,cause:d})}function uo(n){return`${JSON.stringify(n)}
118
- `}var xo=10*1024*1024,qn=class{buffer="";onError;constructor(e={}){this.onError=e.onError}push(e){if(this.buffer+=typeof e=="string"?e:e.toString("utf8"),this.buffer.length>xo){let a=this.buffer.length;return this.buffer="",this.onError?.({line:`<buffer overflow: ${a} bytes, dropped>`,error:new Error(`LdjsonDecoder buffer exceeded ${xo} bytes`)}),[]}let s=this.buffer.split(`
119
- `);this.buffer=s.pop()??"";let o=[];for(let a of s){let d=a.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 lo={"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"},qh=Object.fromEntries(Object.entries(lo).map(([n,e])=>[e,n])),id={"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:[]},Ot=class{seq=0;next(e,s){this.seq+=1;let o=lo[e]??sd(e),a=id[o]??[],d=[o,String(this.seq)];if(a.length>0){let u=a.map(p=>fo(s?.[p]??"")),f=od(u).join(":");f&&d.push(f)}else s&&Object.values(s).some(u=>u)&&d.push(Object.values(s).filter(Boolean).map(u=>fo(String(u))).join(":"));return d.join("_")}reset(){this.seq=0}};function sd(n){return n.replace(/[\s/]+/g,".").replace(/_+/g,"-")}function fo(n){return n.replace(/[:_\s]+/g,"-")}function od(n){let e=n.length;for(;e>0&&!n[e-1];)e-=1;return n.slice(0,e)}function at(n,e){let s=process.env[n];if(!s)return e;let o=Number(s);return Number.isFinite(o)&&o>0?o:e}q();var xd=at("COZE_BRIDGE_INITIALIZE_TIMEOUT_MS",3e4),dd=200,ud=/(ENOTEMPTY|EEXIST).*_npx[/\\]/;function ri(n){return n.some(e=>ud.test(e))}var fd=at("COZE_BRIDGE_SESSION_PROMPT_MAX_MS",3600*1e3),ld=at("COZE_BRIDGE_SESSION_PROMPT_FRAME_IDLE_MS",600*1e3),go=500;function gd(n){try{let e=JSON.stringify(n);return e===void 0||e.length<=go?n:`${e.slice(0,go)}...<truncated, total ${e.length} chars>`}catch{return"<unserializable>"}}function po(n,e){if(!(typeof n!="number"||n<=0))try{if(process.platform==="win32"){let s=["/PID",String(n),"/T"];e==="SIGKILL"&&s.push("/F"),cd("taskkill",s,{stdio:"ignore",windowsHide:!0})}else process.kill(-n,e)}catch{}}var ze=class{constructor(e){this.opts=e;this.log=D(`downstream.${this.constructor.name}`),this.decoder=new qn({onError:s=>this.log.warn("decode line failed",{line:s.line})})}opts;child;decoder;pending=new Map;inflightAgentRequests=new Map;idAllocator=new Ot;updateHandlers=[];agentRequestHandlers=[];exitHandlers=[];log;stopped=!1;stderrRing=[];sanitizeEnv(e){return e}async start(){if(this.child)throw new b("BRIDGE_INTERNAL","Downstream already started");let e=process.platform!=="win32",s=ad(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>dd&&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]}),(this.framework==="claude-code"||this.framework==="codex")&&ri(this.stderrRing)&&(this.log.warn("npx cache corruption detected, triggering global install fallback (D93)",{framework:this.framework}),It(this.framework).catch(f=>{this.log.warn("D93 fallback install failed (will retry next spawn cycle)",{framework:this.framework,err:String(f)})})));try{for(let u of this.decoder.flush())this.dispatch(u)}catch(u){this.log.debug("decoder.flush on exit threw (ignored)",{err:String(u)})}this.failAllPending(new b("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 b("AGENT_SPAWN_FAILED",String(o),{cause:o}))}),this.log.info("downstream started",{command:this.opts.command,pid:s.pid,cwd:this.opts.cwd})}async stop(e){if(!this.child||this.stopped)return;this.stopped=!0,this.log.info("downstream stopping",{reason:e});let s=this.child,o=new Promise(d=>s.once("exit",()=>d()));po(s.pid,"SIGTERM");let a=setTimeout(()=>{s.killed||po(s.pid,"SIGKILL")},5e3);try{await o}finally{clearTimeout(a)}}pid(){return this.child?.pid}isAlive(){return!!this.child&&!this.stopped}getStderrTail(){return[...this.stderrRing]}initialize(e){return this.call("initialize",e)}sessionNew(e){return this.call("session/new",{mcpServers:[],...e})}sessionLoad(e){return this.call("session/load",{mcpServers:[],...e})}sessionPrompt(e,s=fd,o=ld){return this.call("session/prompt",e,s,o)}async sessionCancel(e){!this.child||this.stopped||this.writeFrame(tn("session/cancel",e))}onUpdate(e){this.updateHandlers.push(e)}onAgentRequest(e){this.agentRequestHandlers.push(e)}respondAgentRequest(e,s){if(this.inflightAgentRequests.delete(e),!(!this.child||this.stopped))try{this.writeFrame(Rt(e,s))}catch(o){this.log.warn("respondAgentRequest write failed",{id:e,err:String(o)})}}respondAgentRequestError(e,s){if(this.inflightAgentRequests.delete(e),!(!this.child||this.stopped))try{this.writeFrame(ot(e,s))}catch(o){this.log.warn("respondAgentRequestError write failed",{id:e,err:String(o)})}}onExit(e){this.exitHandlers.push(e)}call(e,s,o=xd,a=0){if(!this.child||this.stopped)return Promise.reject(new b("AGENT_PROTOCOL_ERROR","downstream not started"));let d=this.idAllocator.next(e),u=en(d,e,s),f=o>0&&Number.isFinite(o),p=a>0&&Number.isFinite(a);return new Promise((h,y)=>{let w={resolve:h,reject:y,timer:null,frameIdleTimer:null,armFrameIdle:null,method:e};f&&(w.timer=setTimeout(()=>{this.pending.delete(d),w.frameIdleTimer&&clearTimeout(w.frameIdleTimer),y(new b("AGENT_TIMEOUT",`${e} timed out after ${o}ms`))},o));let A=p?()=>{w.frameIdleTimer&&clearTimeout(w.frameIdleTimer),w.frameIdleTimer=setTimeout(()=>{if(this.inflightAgentRequests.size>0){this.log.debug("frame-idle fired but agent request inflight, re-arming",{id:d,method:e,inflight:this.inflightAgentRequests.size}),A?.();return}w.timer&&clearTimeout(w.timer),this.pending.delete(d),this.log.warn("frame-idle timeout, rejecting pending call",{id:d,method:e,frameIdleMs:a}),y(new b("AGENT_FRAME_IDLE_TIMEOUT",`${e} no session/update for ${a}ms (no inflight agent request)`))},a)}:null;w.armFrameIdle=A,this.pending.set(d,w),A?.();try{this.writeFrame(u)}catch(I){w.timer&&clearTimeout(w.timer),w.frameIdleTimer&&clearTimeout(w.frameIdleTimer),this.pending.delete(d),y(I)}})}writeFrame(e){if(!this.child?.stdin||this.child.stdin.destroyed)throw new b("AGENT_PROTOCOL_ERROR","downstream stdin not writable");this.child.stdin.write(uo(e),s=>{s&&this.log.warn("stdin write callback err",{err:String(s)})})}dispatch(e){if(Un(e)){let s=e.id!==null?this.pending.get(e.id):void 0;if(!s){this.log.warn("orphan response",{id:e.id});return}this.pending.delete(e.id),s.timer&&clearTimeout(s.timer),s.frameIdleTimer&&clearTimeout(s.frameIdleTimer),e.error?(this.log.warn("downstream returned error frame",{id:e.id,method:s.method,code:e.error.code,message:e.error.message,data:e.error.data}),s.reject(co(e.error))):e.result===void 0?(this.log.warn("downstream response missing both result and error",{id:e.id,method:s.method}),s.reject(new b("AGENT_PROTOCOL_ERROR",`${s.method} response missing both result and error`))):(this.log.info("downstream returned result",{id:e.id,method:s.method,result:gd(e.result)}),s.resolve(e.result));return}if(ao(e)){if(e.method==="session/update"){for(let s of this.pending.values())s.armFrameIdle?.();for(let s of this.updateHandlers)try{Promise.resolve(s(e.params)).catch(o=>this.log.warn("update handler failed (async)",{err:String(o)}))}catch(o){this.log.warn("update handler threw sync, swallowed",{err:String(o)})}}else this.log.info("unknown notification (drop, not forwarded)",{method:e.method});return}if(oo(e)){let s=e;try{this.handleAgentRequest(s).catch(o=>this.log.error("agent request handler failed (async)",{method:s.method,err:String(o)}))}catch(o){this.log.warn("handleAgentRequest threw sync, swallowed",{method:s.method,err:String(o)})}}}async handleAgentRequest(e){if(this.agentRequestHandlers.length===0){this.writeFrame(ot(e.id,{code:-32601,message:`method not handled by Bridge: ${e.method}`}));return}this.inflightAgentRequests.set(e.id,e.method);for(let s of this.agentRequestHandlers)try{await s(e)}catch(o){this.log.error("agentRequestHandler threw",{method:e.method,err:String(o)});try{this.writeFrame(ot(e.id,rn(o)))}catch{}this.inflightAgentRequests.delete(e.id)}}failAllPending(e){for(let s of this.pending.values())s.timer&&clearTimeout(s.timer),s.frameIdleTimer&&clearTimeout(s.frameIdleTimer),s.reject(e);this.pending.clear(),this.inflightAgentRequests.clear()}};var pd="@agentclientprotocol/claude-agent-acp@latest";function hd(n){let e={};for(let[s,o]of Object.entries(n))o!==void 0&&(s.startsWith("CLAUDE")||s==="AI_AGENT"||s==="BAGGAGE"||(e[s]=o));return e}var Gn=class extends ze{framework="claude-code";constructor(e){let s=Tt("claude-code"),[o,a]=s?[s,[]]:["npx",["-y",pd]],d=e.command??o,u=e.args??a,f={command:d,args:u,cwd:e.cwd,...e.env?{env:e.env}:{}};super(f)}sanitizeEnv(e){return hd(e)}};import{mkdtempSync as md,rmSync as wd}from"node:fs";import{tmpdir as _d}from"node:os";import{join as yd}from"node:path";var bd="@zed-industries/codex-acp@latest",jn=class extends ze{framework="codex";authMethodId;codexHomeDir;constructor(e){let s=Tt("codex"),[o,a]=s?[s,[]]:["npx",["-y",bd]],d=e.command??o,u=e.args??a,f=e.extraArgs?[...u,...e.extraArgs]:u,p=e.isolateCodexHome?md(yd(_d(),"coze-bridge-codex-home-")):void 0,h=p?{...e.env??{},CODEX_HOME:p}:e.env,y={command:d,args:f,cwd:e.cwd,...h?{env:h}:{}};super(y),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{wd(this.codexHomeDir,{recursive:!0,force:!0})}catch{}}};var vd=3e4,Nt=class extends ze{framework="openclaw";agentId;sessionName;slashModelOnStart;constructor(e){let s=e.sessionName??"default",o=["acp","--session",`agent:${e.agentId}:${s}`];e.gatewayToken&&o.push("--token",e.gatewayToken);let 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}`}]},vd))}get acpSessionName(){return this.sessionName}};q();oe();function ii(n){return n.replace(/[^A-Za-z0-9._-]+/g,"-")}var Lt=class{slots=[];running=!1;closed=!1;disposed=!1;enqueue(e){return this.disposed?Promise.reject(new Error("AsyncQueue disposed")):this.closed?Promise.reject(new Error("AsyncQueue closed")):new Promise((s,o)=>{this.slots.push({task:e,resolve:s,reject:o}),this.drain()})}close(){this.closed=!0}dispose(e=new Error("AsyncQueue disposed")){for(this.disposed=!0,this.closed=!0;this.slots.length>0;)this.slots.shift()?.reject(e)}get size(){return this.slots.length}get isRunning(){return this.running}get isDisposed(){return this.disposed}async drain(){if(!this.running){this.running=!0;try{for(;this.slots.length>0&&!this.disposed;){let e=this.slots.shift();if(!e)break;try{let s=await e.task();e.resolve(s)}catch(s){e.reject(s)}}}finally{this.running=!1}}}};var Hn=class{agentId;framework;workspace;deployType;accountId;patToken;modelInfo;sessions=new Map;sessionQueues=new Map;activeTriggers=new Map;activeGroupIds=new Map;status="ok";model;lastActiveAt=Date.now();constructor(e){this.agentId=e.agentId,this.framework=e.framework,this.workspace=e.workspace,this.model=e.model,this.deployType=e.deployType??"local",e.accountId&&(this.accountId=e.accountId),e.patToken&&(this.patToken=e.patToken),e.modelInfo&&(this.modelInfo=e.modelInfo)}setPatToken(e){this.patToken=e}setModelInfo(e){this.modelInfo=e}getSessionQueue(e){let s=this.sessionQueues.get(e);return(!s||s.isDisposed)&&(s=new Lt,this.sessionQueues.set(e,s)),s}allSessionQueues(){return this.sessionQueues.entries()}hasSessionQueue(e){let s=this.sessionQueues.get(e);return!!s&&!s.isDisposed}async dispose(e){this.status="stopped";let s=new Error(`AgentSession disposed${e?`: ${e}`:""}`);for(let o of this.sessionQueues.values())o.dispose(s);this.sessionQueues.clear(),await this.killAllRuntimes(e??"dispose")}async killAllRuntimes(e){let s=[];for(let[,o]of this.sessions)sn(o),o.downstream&&(s.push(o.downstream.stop(e).catch(()=>{})),o.downstream=void 0);await Promise.all(s),this.activeTriggers.clear(),this.activeGroupIds.clear()}};function sn(n){n.idleTimer&&(clearTimeout(n.idleTimer),n.idleTimer=void 0)}import{spawn as Sd}from"node:child_process";import{homedir as Ed}from"node:os";import{join as Ad}from"node:path";Pn();q();async function wo(){let n=Ad(Ed(),".openclaw/openclaw.json");return(await Pt(n))?.gateway?.auth?.token??""}var ho=D("openclaw.config"),Id=[0,5e3,5e3],mo="models.providers.",Kn="agents.defaults.models",Wn=class{command;env;retryDelaysMs;queue=new Lt;constructor(e){this.command=e.command,this.env=e.env??process.env,this.retryDelaysMs=e.retryDelaysMs??Id}async withRetry(e,s){let o;for(let a=0;a<this.retryDelaysMs.length;a++){let d=this.retryDelaysMs[a]??0;d>0&&await new Promise(u=>setTimeout(u,d));try{return await s()}catch(u){o=u,ho.warn("openclaw cli failed, will retry",{label:e,attempt:a+1,err:String(u)})}}throw new b("AGENT_SPAWN_FAILED",`openclaw cli ${e} failed after ${this.retryDelaysMs.length} attempts: ${o?.message??"unknown"}`)}runCli(e){return new Promise((s,o)=>{let a=Sd(this.command,e,{stdio:["ignore","pipe","pipe"],env:this.env}),d="";a.stderr?.on("data",u=>{d+=u.toString("utf8")}),a.on("error",o),a.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 a=String(o);if(s.some(d=>a.includes(d)))return;throw o}}async bestEffortUnset(e,s){try{await this.queue.enqueue(()=>this.withRetry(e,()=>this.runCli(["config","unset",s])))}catch(o){ho.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",`${mo}${e}`,JSON.stringify(s),"--strict-json","--merge"])))}removeProvider(e){return this.bestEffortUnset(`config unset models.providers.${e}`,`${mo}${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 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 me=D("agent-manager"),Pd=(n,e,s,o,a,d,u,f)=>{switch(n){case"claude-code":{let p={...a?{...Ws(a),...Vs(a,u)}:{},...f??{},IS_SANDBOX:"1"};return new Gn({cwd:s,env:p})}case"codex":{let h=[...a?[...$s(a),...Ys(a,u)]:[],"-c",'sandbox_mode="danger-full-access"',"-c",'approval_policy="never"'],y={...a?Js(a):{},...f??{}},w=!!a;return new jn({cwd:s,...h.length>0?{extraArgs:h}:{},...Object.keys(y).length>0?{env:y}:{},...w?{authMethodId:"openai-api-key",isolateCodexHome:!0}:{}})}case"openclaw":return new Nt({command:e,cwd:s,agentId:o,...d?{sessionName:ii(d)}:{}})}};function oi(n){return n==="claude-code"||n==="codex"}var Cd={path:"",version:"cloud-deployed"},kd={protocolVersion:1,clientCapabilities:{fs:{readTextFile:!0,writeTextFile:!0}}},Dd=6e4,Rd=at("COZE_BRIDGE_SPAWN_AWAIT_INSTALL_MS",25e3),$n=class{paths;config;registry;factory;createTimeoutMs;spawnAwaitInstallMs;openclawConfigCache;ensuredProviders=new Set;constructor(e){this.paths=e.paths,this.config=e.config,this.registry=e.registry,this.factory=e.downstreamFactory??Pd,this.createTimeoutMs=e.createTimeoutMs??Dd,this.spawnAwaitInstallMs=e.spawnAwaitInstallMs??Rd}buildBinShimPathEnv(){let e=process.platform==="win32"?";":":";return{PATH:`${this.paths.binDir}${e}${process.env.PATH??""}`}}getOpenclawConfig(){if(!this.openclawConfigCache){let e=this.config.frameworksCache?.openclaw;if(!e?.path)throw new b("AGENT_SPAWN_FAILED","openclaw binary not detected on this machine");this.openclawConfigCache=new Wn({command:e.path})}return this.openclawConfigCache}async createAgent(e){if(!e.agentId)throw new b("IPC_BAD_REQUEST","agentId required");if(!e.framework)throw new b("IPC_BAD_REQUEST","framework required");let s=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 b("AGENT_BUSY",`agent ${e.agentId} exists with different framework (${o.framework})`);if(o.status==="error")me.warn("existing agent in error state, rebuilding",{agentId:e.agentId}),await o.dispose("rebuild after error").catch(E=>me.warn("dispose stale agent failed (ignored)",{err:String(E)})),this.registry.unregister(e.agentId);else{if(e.patToken&&e.patToken!==o.patToken){me.info("updating agent patToken on re-create (reconnect with new PAT)",{agentId:e.agentId}),o.setPatToken(e.patToken);let E=await he(e.agentId,this.paths).catch(()=>null);E&&(E.patToken=e.patToken,await Se(E,this.paths))}if(o.deployType==="cloud"&&e.modelInfo){me.info("updating agent modelInfo on re-create",{agentId:e.agentId}),o.setModelInfo(e.modelInfo);let E=await he(e.agentId,this.paths).catch(()=>null);E&&(E.modelInfo=e.modelInfo,await Se(E,this.paths))}return me.info("agent already exists, return current",{agentId:e.agentId}),{ok:!0,agentId:o.agentId,workspace:o.workspace,framework:o.framework}}}if(!s&&!this.config.frameworksCache?.[e.framework])throw new b("AGENT_SPAWN_FAILED",`framework ${e.framework} not detected on this machine; rerun daemon to refresh frameworks_cache`);let d=$e(e.agentId,this.paths),u=Xt(e._meta),f=e.framework==="openclaw"&&u==="local",p=f?this.config.frameworksCache?.openclaw?.defaultAgent?.workspace:void 0,h=e.workspace??p??d.workspace,y=new AbortController,w=setTimeout(()=>y.abort(new b("AGENT_TIMEOUT",`_agent/create timed out after ${this.createTimeoutMs}ms`)),this.createTimeoutMs),A,I=!1;try{s&&oi(e.framework)&&await It(e.framework,y.signal);let E=()=>{if(y.signal.aborted)throw y.signal.reason instanceof Error?y.signal.reason:new b("AGENT_TIMEOUT","_agent/create aborted")};await si(d.root,{recursive:!0}),await si(h,{recursive:!0}),await si(d.logs,{recursive:!0}),E(),f||await Ct(h,e.framework,e.agentId,e.cozeIdentity),e.framework==="claude-code"&&await Ns(h),E();let k=await he(e.agentId,this.paths).catch(()=>null),L=Hs({model:e.model??k?.model}),$=Ls(e._meta)??k?.accountId,H=e.patToken??k?.patToken,ae=u==="cloud"?e.modelInfo??k?.modelInfo:void 0;if(A=new Hn({agentId:e.agentId,framework:e.framework,workspace:h,model:L.model??Le,deployType:u,...$?{accountId:$}:{},...H?{patToken:H}:{},...ae?{modelInfo:ae}:{}}),A.status="ok",k?.sessions){for(let[ke,de]of Object.entries(k.sessions))A.sessions.set(ke,{acpSessionId:de.acpSessionId,modelToken:de.modelToken,tokenGeneratedAt:de.tokenGeneratedAt,lastActiveAt:Date.now(),loadingSession:!1,replySeq:0});let _e=Object.keys(k.sessions).length;_e>0&&me.info("restored persisted session records (no spawn)",{agentId:e.agentId,count:_e})}this.registry.register(A),I=!0;let W={agentId:e.agentId,framework:e.framework,workspace:h,cozeIdentity:e.cozeIdentity,createdAt:k?.createdAt??Date.now(),sessions:k?.sessions??{},model:L.model};u==="cloud"&&(W.deployType="cloud"),$&&(W.accountId=$),H&&(W.patToken=H),ae&&(W.modelInfo=ae),k?.skills&&(W.skills=k.skills),k?.agentName&&(W.agentName=k.agentName),k?.description&&(W.description=k.description),e.framework==="openclaw"&&u==="cloud"&&(this.config.frameworksCache?.openclaw?.path?await this.getOpenclawConfig().ensureAgent(e.agentId,h):me.warn("openclaw binary not on this machine, skip agents add (will fail at session/prompt)",{agentId:e.agentId}));let ge=e.initialSkills??[];if(ge.length>0){let _e=[...W.skills??[]],ke=new Map(_e.map((T,O)=>[T.skillId,O])),de=await Promise.allSettled(ge.map(T=>ti({agentId:e.agentId,workspace:h,framework:e.framework,skill:T}))),we=0;for(let[T,O]of de.entries()){let F=ge[T];F&&(O.status==="fulfilled"?(ni(_e,ke,O.value),we++):me.warn("initialSkill install failed (skipping)",{agentId:e.agentId,skillId:F.skillId,skillName:F.skillName,err:String(O.reason)}))}we>0&&(W.skills=_e,me.info("initialSkills installed",{agentId:e.agentId,installed:we,requested:ge.length}))}return await Se(W,this.paths),me.info("agent created (no spawn, lazy on first prompt)",{agentId:e.agentId,framework:e.framework,deployType:u}),{ok:!0,agentId:e.agentId,workspace:h,framework:e.framework}}catch(E){throw me.error("agent create failed, rolling back",{agentId:e.agentId,err:String(E)}),I&&A&&(await A.dispose("rollback").catch(()=>{}),this.registry.unregister(e.agentId)),await Td(d.root,{recursive:!0,force:!0}).catch(k=>me.warn("rm agent dir failed (ignored)",{err:String(k)})),E instanceof b?E:new b("AGENT_SPAWN_FAILED",String(E),{cause:E})}finally{clearTimeout(w)}}async spawnSessionDownstream(e,s,o,a){let u=this.config.frameworksCache?.[e.framework];if(!u)if(e.deployType==="cloud"&&oi(e.framework))u=Cd;else throw new b("AGENT_SPAWN_FAILED",`framework ${e.framework} not detected on this machine`);if(oi(e.framework)&&!Tt(e.framework)){let h=Ss(e.framework);h&&(me.info("spawn: awaiting in-flight acp install (D92)",{agentId:e.agentId,framework:e.framework}),await Promise.race([h.catch(()=>{}),new Promise(y=>setTimeout(y,this.spawnAwaitInstallMs))]))}let f=e.deployType==="cloud"?{model:e.model,modelToken:s,...e.modelInfo?{modelInfo:e.modelInfo}:{}}:void 0,p;e.framework==="openclaw"?p=await this.buildOpenclawDownstream({session:e,modelConfig:f,cloudSessionId:o,cozeEnv:a,command:u.path}):p=this.factory(e.framework,u.path,e.workspace,e.agentId,f,o,a,this.buildBinShimPathEnv());try{return await p.start(),await p.initialize(kd),p}catch(h){let y=p instanceof ze?p.getStderrTail():[];y.length>0&&me.warn("spawnSessionDownstream failed, recent stderr (D94)",{agentId:e.agentId,framework:e.framework,method:h instanceof b?h.code:"unknown",recentStderr:y});let w=ri(y);await p.stop("spawnSessionDownstream failed").catch(()=>{});let A=w?new b("NPX_CACHE_CORRUPT","~/.npm/_npx \u76EE\u5F55\u635F\u574F (ENOTEMPTY)\u3002\u5EFA\u8BAE: rm -rf ~/.npm/_npx && npm i -g @zed-industries/codex-acp (\u6216\u5BF9\u5E94 @agentclientprotocol/claude-agent-acp)",{cause:h}):h;throw h instanceof b?new b(h.code,h.message,{retriable:h.retriable,cause:A}):new b("AGENT_SPAWN_FAILED",h instanceof Error?h.message:String(h),{cause:A})}}async buildOpenclawDownstream(e){let{session:s,modelConfig:o,cloudSessionId:a,cozeEnv:d,command:u}=e,f=ii(a);if(s.deployType==="local"){let w=this.config.frameworksCache?.openclaw?.defaultAgent;if(!w?.id||!w.workspace)throw new b("AGENT_SPAWN_FAILED","openclaw default agent \u672A\u63A2\u6D4B\u5230; \u8BF7\u5148\u8DD1 `openclaw setup` \u6216 `openclaw agents add` \u521B\u5EFA\u9ED8\u8BA4 agent");return new Nt({command:u,cwd:w.workspace,agentId:w.id,sessionName:f})}let p=await wo(),h=o?Xs(o,d):null,y;if(h){let w=Qr(a),I=h.models[0]?.id??Le,E=`${w}/${I}`;if(!this.ensuredProviders.has(E)){let k=this.getOpenclawConfig();await k.ensureProvider(w,h),await k.addModelToAllowlist(E),this.ensuredProviders.add(E)}y=E}return new Nt({command:u,cwd:s.workspace,agentId:s.agentId,sessionName:f,...p?{gatewayToken:p}:{},...y?{slashModelOnStart:y}:{}})}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=Qr(o),d=`${a}/${e.model}`,u=!0;try{await s.removeProvider(a)}catch(f){u=!1,me.warn("removeProvider failed, keeping ensuredProviders entry",{providerId:a,err:String(f)})}try{await s.removeModelFromAllowlist(d)}catch(f){u=!1,me.warn("removeModelFromAllowlist failed, keeping ensuredProviders entry",{fullModelId:d,err:String(f)})}u&&this.ensuredProviders.delete(d)}}};import{randomUUID as So}from"node:crypto";import{promises as jd}from"node:fs";import{basename as Eo}from"node:path";import{promises as Nd}from"node:fs";import{basename as Ld}from"node:path";q();var _o=D("file-upload"),Md="/api/coze_claw/file/agent_upload",Bd=6e4;async function yo(n,e={}){let o=`${Nn(Mn(e.handshakeBase))}${Md}`,a=e.timeoutMs??Bd,d=await Nd.readFile(n.path),u=new FormData;u.append("agent_id",n.agentId),u.append("session_id",n.sessionId),u.append("file_name",n.name),u.append("file_content",new Blob([d],{type:n.mimeType}),n.name);let f={Authorization:`Bearer ${n.patToken}`,Accept:"application/json","x-coze-version":"3.0",...Dt(e.ppeOverride),...n.accountId?{"x-coze-account":n.accountId}:{}},p=new AbortController,h=setTimeout(()=>p.abort(),a);_o.info("file upload start",{url:o,agentId:n.agentId,sessionId:n.sessionId,name:n.name,bytes:n.sizeBytes,mime:n.mimeType});try{let y=await fetch(o,{method:"POST",headers:f,body:u,signal:p.signal}),w=y.headers.get("x-tt-logid")??"";if(!y.ok){let E=await y.text().catch(()=>"");throw new b("UPLOAD_FAILED",`upload HTTP ${y.status} logid=${w}: ${E.slice(0,200)}`)}let A=await y.json();if(A.code!==void 0&&A.code!==0)throw new b("UPLOAD_FAILED",`upload code=${A.code} msg=${A.msg??"-"} logid=${w}`);let I=A.data?.file?.file_url;if(!I)throw new b("UPLOAD_FAILED",`upload response missing data.file.file_url logid=${w}: ${JSON.stringify(A).slice(0,200)}`);return _o.info("file upload ok",{uri:I,logid:w}),{uri:I}}catch(y){throw y instanceof b?y:y.name==="AbortError"?new b("UPLOAD_FAILED",`upload timeout (${a}ms) for ${Ld(n.path)}`):new b("UPLOAD_FAILED",String(y),{cause:y})}finally{clearTimeout(h)}}q();import{promises as zd}from"node:fs";import{extname as Fd}from"node:path";var Ud=[{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 qd(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 Gd={".txt":"text/plain",".md":"text/markdown",".svg":"image/svg+xml",".json":"application/json"};async function bo(n){let e=await zd.open(n,"r");try{let s=Buffer.alloc(16);if(await e.read(s,0,16,0),qd(s))return"image/webp";for(let o of Ud)if(o.prefix.every((a,d)=>s[d]===a))return o.mime}finally{await e.close()}return Gd[Fd(n).toLowerCase()]??"application/octet-stream"}oe();var ai=D("agent-send"),vo=50*1024*1024,Hd=new Set(["image/png","image/jpeg","image/webp","image/gif","image/svg+xml","application/pdf","application/json","text/plain","text/markdown"]);function Ao(n,e,s){let o=n.get(e);if(!o)throw new b("AGENT_NOT_FOUND",`agent=${e}`);if(n.disconnectedAgents.has(e))throw new b("AGENT_DISCONNECTED",`agent=${e} was disconnected by cloud`);let a=o.sessions.get(s);if(!a)throw new b("AGENT_NOT_FOUND",`session=${s} not active in agent=${e}`);return{session:o,runtime:a}}async function Io(n,e,s,o,a,d){let f;for(let p=0;p<=2;p++)try{await n.core.sendAgentFileUpdate(e,s,o,a);return}catch(h){f=h,p<2&&(ai.warn("sendAgentFileUpdate failed, retrying",{attempt:p+1,err:String(h)}),await new Promise(y=>setTimeout(y,5e3)))}throw new b("UPSTREAM_NOT_READY",`${d} after 3 attempts: ${String(f)}`,{cause:f})}async function To(n,e){let{session:s,runtime:o}=Ao(e.core,n.agentId,n.sessionId);if(!await ks(n.path,s.workspace))throw new b("PATH_OUTSIDE_WORKSPACE",`path=${n.path} not under workspace=${s.workspace}`);let a=await jd.stat(n.path).catch(()=>null);if(!a||!a.isFile())throw new b("IPC_BAD_REQUEST",`path is not a regular file: ${n.path}`);if(a.size>vo)throw new b("FILE_TOO_LARGE",`${a.size} bytes > limit ${vo}`);let d=await bo(n.path);if(!Hd.has(d))throw new b("UNSUPPORTED_MIME",`mime=${d} not in whitelist`);if(n.kind==="image"&&!d.startsWith("image/"))throw new b("UNSUPPORTED_MIME",`kind=image but mime=${d}`);if(!e.core.upstream.isConnected())throw new b("UPSTREAM_NOT_READY","cloud WS not connected");let u=n.name??Eo(n.path),f=await yo({patToken:s.patToken??e.patToken,agentId:n.agentId,sessionId:n.sessionId,path:n.path,mimeType:d,name:u,sizeBytes:a.size,...s.accountId?{accountId:s.accountId}:{}},{handshakeBase:e.handshakeBase,ppeOverride:e.ppeOverride}),p={sessionUpdate:"agent_file",messageId:So(),content:{type:n.kind==="image"?"image":"resource",uri:f.uri,mimeType:d,name:u,sizeBytes:a.size,...f.fileId!==void 0?{fileId:f.fileId}:{},...n.caption!==void 0?{caption:n.caption}:{}}};return await Io(e,s,o,n.sessionId,p,"agent file uploaded to cloud but sendAgentFileUpdate failed"),ai.info("agent file sent",{agentId:n.agentId,sessionId:n.sessionId,kind:n.kind,name:u,bytes:a.size,mime:d,uri:f.uri}),{ok:!0,uri:f.uri,bytes:a.size,mimeType:d,...f.fileId!==void 0?{fileId:f.fileId}:{}}}async function Po(n,e){let{session:s,runtime:o}=Ao(e.core,n.agentId,n.sessionId);if(!n.mimeType)throw new b("IPC_BAD_REQUEST","group-file requires mimeType");if(!e.core.upstream.isConnected())throw new b("UPSTREAM_NOT_READY","cloud WS not connected");let a=n.name??Eo(n.path),d={sessionUpdate:"group_file",messageId:So(),content:{uri:n.path,name:a,mimeType:n.mimeType,...n.caption!==void 0?{caption:n.caption}:{}}};return await Io(e,s,o,n.sessionId,d,"agent group file sendAgentFileUpdate failed"),ai.info("agent group file sent",{agentId:n.agentId,sessionId:n.sessionId,uri:n.path,name:a,mime:n.mimeType}),{ok:!0,uri:n.path,bytes:0,mimeType:n.mimeType}}import{execFile as Kd}from"node:child_process";import{promisify as Wd}from"node:util";function Jn(n,e){let s=n.split(".").map(Number),o=e.split(".").map(Number),a=Math.max(s.length,o.length);for(let d=0;d<a;d++){let u=s[d]??0,f=o[d]??0;if(u<f)return!0;if(u>f)return!1}return!1}q();var $d=Wd(Kd),Fe=D("coze-cli-installer"),Co="@coze/cli@latest",Jd="coze",ko="0.1.7",Vd=5e3,Xd=5e3,Yd=9e4,Do=1e4,on=null,Vn=!1;async function ci(n,e={}){if(Vn)return;if(on)return on;let s=e.exec??$d;return on=(async()=>{try{let o=await Zd(Jd,s),a=!1;if(o){let u=await Qd(s);if(u===void 0)Fe.warn("coze-cli found but version unparseable, fall through to full install",{path:o});else if(Jn(u,ko))Fe.info("coze-cli version too old, upgrade-only (preserve user config + auth)",{path:o,version:u,min:ko}),a=!0;else{Fe.info("coze-cli already on PATH with sufficient version, skip",{path:o,version:u}),Vn=!0;return}}let d=a?"upgrade-only":"full";Fe.info("coze-cli install start",{package:Co,mode:d});try{await s("npm",["i","-g","--prefer-online",Co],{timeout:Yd,maxBuffer:10*1024*1024}),Fe.info("coze-cli install ok")}catch(u){Fe.warn("coze-cli install failed (skip subsequent steps)",{err:String(u)});return}if(a){Vn=!0;return}if(n.env)try{await s("coze",["config","set","xTTEnv",n.env],{timeout:Do}),Fe.info("coze config set xTTEnv ok",{env:n.env})}catch(u){Fe.warn("coze config set failed (continue to auth login)",{err:String(u)})}try{await s("coze",["auth","login","--token",n.patToken],{timeout:Do}),Fe.info("coze auth login ok")}catch(u){Fe.warn("coze auth login failed",{err:String(u)});return}Vn=!0}finally{on=null}})(),on}async function Zd(n,e){let s=process.platform==="win32"?"where":"which";try{let{stdout:o}=await e(s,[n],{timeout:Vd});return o.split(`
120
- `)[0]?.trim()||void 0}catch{return}}async function Qd(n){try{let{stdout:e,stderr:s}=await n("coze",["--version"],{timeout:Xd});return(e||s).match(/(\d+\.\d+\.\d+)/)?.[1]}catch{return}}q();import{spawn as eu}from"node:child_process";import{constants as Ro,access as tu}from"node:fs/promises";import{delimiter as nu,join as ru}from"node:path";var Oo=D("framework-detector"),No={"claude-code":"claude",codex:"codex",openclaw:"openclaw"},iu=[".exe",".cmd",".bat",".ps1"],Mt=class{env;constructor(e={}){this.env={pathEnv:e.pathEnv??process.env.PATH??"",platform:e.platform??process.platform,spawn:e.spawn??eu,access:e.access??tu}}async detect(e){let s=No[e],o=await this.which(s);if(!o)return Oo.debug("framework binary not found",{framework:e,bin:s}),null;let a=e==="openclaw"?["--log-level","silent"]:[],[d,u]=await Promise.all([this.probeVersion(o,a),e==="openclaw"?this.probeOpenclawDefaultAgent(o):Promise.resolve(null)]),f={path:o,version:d};return u&&(f.defaultAgent=u),f}async detectAll(){let e=await Promise.all(Object.keys(No).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(nu).filter(Boolean),o=this.env.platform==="win32"?["",...iu]:[""];for(let a of s)for(let d of o){let u=ru(a,e+d);if(await this.isExecutable(u))return u}return null}async isExecutable(e){try{let s=this.env.platform==="win32"?Ro.F_OK:Ro.X_OK;return await this.env.access(e,s),!0}catch{return!1}}async probeOpenclawDefaultAgent(e){let s=await this.runProbe(e,["--log-level","silent","agents","list","--json"]);if(!s||s.code!==0)return null;let o=s.stdout.match(/\[\s*\{[\s\S]*\}\s*\]/);if(!o)return null;try{let a=JSON.parse(o[0]);if(!Array.isArray(a))return null;let d=a.find(u=>u?.isDefault===!0);return!d?.id||!d.workspace?null:{id:d.id,workspace:d.workspace}}catch(a){return Oo.warn("openclaw agents list --json parse failed",{err:String(a)}),null}}async probeVersion(e,s=[]){let o=await this.runProbe(e,[...s,"--version"]);return o&&(ou(o.stdout).split(/\r?\n/)[0]??"").trim()||"unknown"}runProbe(e,s){return new Promise(o=>{let a="",d=!1,u,f=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"),f(null)},5e3),p.stdout?.on("data",h=>{a+=h.toString("utf8")}),p.on("error",()=>f(null)),p.on("close",h=>f({code:h,stdout:a}))}catch{f(null)}})}},su=new RegExp("\x1B\\[[0-9;]*[A-Za-z]","g");function ou(n){return n.replace(su,"")}Bt();import{randomBytes as Au}from"node:crypto";import{createReadStream as cu}from"node:fs";import{mkdir as xu,readFile as du,realpath as uu,stat as fu,writeFile as lu}from"node:fs/promises";import{basename as gu,dirname as xi,join as pu,relative as hu,resolve as Mo,sep as mu}from"node:path";import{createInterface as wu}from"node:readline";q();var zo=D("fs-rpc"),an=at("COZE_BRIDGE_FS_RPC_MAX_BYTES",20*1024*1024);async function Fo(n,e){let s=Buffer.byteLength(n.content,"utf8");if(s>an)throw new b("IPC_BAD_REQUEST",`fs/write_text_file content too large: ${s} bytes > limit ${an} bytes`);let o=await qo(n.path,e);return await xu(xi(o),{recursive:!0}),await lu(o,n.content,"utf8"),zo.info("fs/write_text_file ok",{path:o,size:n.content.length}),null}async function Uo(n,e){let s=await qo(n.path,e),o=await fu(s),a=typeof n.line=="number"||typeof n.limit=="number";if(o.size>an&&!a)throw new b("IPC_BAD_REQUEST",`fs/read_text_file too large without line/limit slicing: ${o.size} bytes > ${an} bytes`);let d;if(a&&o.size>an)d=await _u(s,n.line??1,n.limit);else{let u=await du(s,"utf8");if(a){let f=u.split(`
121
- `),p=Math.max(0,(n.line??1)-1),h=typeof n.limit=="number"?p+n.limit:void 0;d=f.slice(p,h).join(`
122
- `)}else d=u}return zo.info("fs/read_text_file ok",{path:s,size:d.length}),{content:d}}async function _u(n,e,s){let o=wu({input:cu(n,{encoding:"utf8"}),crlfDelay:Number.POSITIVE_INFINITY}),a=Math.max(0,e-1),d=typeof s=="number"?a+s:Number.POSITIVE_INFINITY,u=[],f=0;try{for await(let p of o)if(f>=a&&f<d&&u.push(p),f++,f>=d)break}finally{o.close()}return u.join(`
123
- `)}async function qo(n,e){if(typeof n!="string"||n.length===0)throw new b("IPC_BAD_REQUEST","path must be a non-empty string");let[s,o]=await Promise.all([Bo(Mo(e)),Bo(Mo(n))]),a=hu(s,o);if(a.startsWith("..")||a===".."||a.startsWith(`..${mu}`))throw new b("IPC_BAD_REQUEST",`path escapes workspace: ${n}`);return o}async function Bo(n){let e=[],s=n;for(;s!==xi(s);)try{let o=await uu(s);return e.length?pu(o,...e.reverse()):o}catch{e.push(gu(s)),s=xi(s)}return n}q();var Go=D("prompt-multimodal"),jo=10*1024*1024,yu=15e3,bu=6;async function Ho(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 vu(u))}}let a=Array.from({length:Math.min(bu,n.length)},()=>o());return await Promise.all(a),e}function Ko(n){return n.some(e=>e.type==="image")}async function vu(n){if(n.type!=="image")return n;let e=n;if(e.data||!e.uri||!On(e.uri))return n;try{let{buf:s,contentType:o}=await Eu(e.uri),a=e.mimeType||Su(o)||"application/octet-stream";return Go.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 Go.warn("image fetch failed, degrading to text block",{uri:e.uri,err:String(s)}),{type:"text",text:`[image load failed: ${e.uri}]`}}}function Su(n){if(!n)return;let e=n.indexOf(";");return(e===-1?n:n.slice(0,e)).trim()||void 0}async function Eu(n){let e=new AbortController,s=setTimeout(()=>e.abort(),yu);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>jo)throw new Error(`image too large: ${a.byteLength} bytes (max ${jo})`);return{buf:Buffer.from(a),contentType:o.headers.get("content-type")??void 0}}finally{clearTimeout(s)}}it();Bt();q();var U=D("core"),Iu=3e4,Tu=/^(boe|ppe)_[A-Za-z0-9_-]+$/,Pu=3e4,Cu=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 Ot;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=Lo(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(),U.info("Core started",{extensions:Object.keys(this.extensions)})}async stop(e){U.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),U.info("agent registered",{agentId:e.agentId,framework:e.framework});for(let s of this.registerHandlers)try{s(e.agentId)}catch(o){U.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)&&U.info("agent revived from disconnect",{agentId:e})}attachRuntimeHooks(e,s,o){let a=o.downstream;a&&(a.onUpdate(d=>{o.loadingSession||this.forwardUpdate(e,d)}),a.onAgentRequest(d=>{this.handleAgentRequest(e,a,d)}),a.onExit((d,u)=>{U.info("session runtime exited",{agentId:e.agentId,cloudId:s,code:d,signal:u}),sn(o),o.downstream=void 0,o.replySeq=0,o.acpSessionId&&e.activeTriggers.delete(o.acpSessionId),this.rejectPendingForDownstream(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,d]of this.pendingUpstream)d.downstream===e&&o.push(a);if(o.length!==0){U.info("reject pendingUpstream entries (downstream gone)",{reason:s,count:o.length});for(let a of o){let d=this.pendingUpstream.get(a);if(d){this.pendingUpstream.delete(a),this.upstream.send(ot(a,{code:j.INTERNAL_ERROR,message:`bridge downstream gone: ${s}`})).catch(u=>U.debug("send error response to upstream failed (ignored)",{err:String(u)}));try{d.downstream.respondAgentRequestError(d.agentRequestId,{code:j.INTERNAL_ERROR,message:`bridge: ${s}`})}catch{}}}}}rejectAllPendingOnReconnect(){let e=this.pendingUpstream.size,s=this.pendingBridge.size;if(!(e===0&&s===0)){U.warn("upstream reconnected, rejecting stale pending requests",{pendingUpstream:e,pendingBridge:s});for(let[,o]of this.pendingUpstream)try{o.downstream.respondAgentRequestError(o.agentRequestId,{code:j.INTERNAL_ERROR,message:"upstream reconnected; please retry"})}catch{}this.pendingUpstream.clear();for(let[,o]of this.pendingBridge)clearTimeout(o.timer),o.reject(new b("UPSTREAM_DISCONNECTED",`${o.method} aborted: upstream reconnected`));this.pendingBridge.clear()}}async handleFrame(e){if(Un(e)){this.handleUpstreamResponse(e);return}if(!("method"in e)||typeof e.method!="string")return;let s="id"in e&&e.id!==void 0?e.id:null,o=e.params?._meta?.cozeEnv;o&&Tu.test(o)?this.currentCozeEnv=o:o&&U.warn("rejecting cozeEnv with invalid shape, keeping previous",{rejected:o});try{if(this.upgradeGate?.isUpgrading()&&Cu.has(e.method)){let a=this.upgradeGate.pendingTarget()??"";throw new b("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,j.METHOD_NOT_FOUND,`extension not registered: ${e.method}`):U.warn("drop notification: extension not registered",{method:e.method});return}let d=await a(e,this);s!==null&&await this.upstream.send(Rt(s,d));return}if(e.method.startsWith("session/")){let a=await this.routeSessionMethod(e);s!==null&&await this.upstream.send(Rt(s,a));return}if(e.method==="initialize"){s!==null&&await this.upstream.send(Rt(s,{protocolVersion:1,agentCapabilities:{loadSession:!0}}));return}s!==null?await this.sendError(s,j.METHOD_NOT_FOUND,`method not implemented: ${e.method}`):U.warn("drop unknown notification",{method:e.method})}catch(a){U.error("handleFrame failed",{method:e.method,err:String(a)}),s!==null&&await this.upstream.send(ot(s,rn(a)))}}async routeSessionMethod(e){if(!e.params||typeof e.params!="object")throw new b("IPC_BAD_REQUEST",`${e.method} requires params`);let s=e.params,o=s._meta?.cozeAgentId;if(!o)throw new b("IPC_BAD_REQUEST",`${e.method}: missing _meta.cozeAgentId`);let a=this.agents.get(o);if(!a)throw this.disconnectedAgents.has(o)?new b("AGENT_DISCONNECTED",`agent ${o} has been disconnected; cloud must _agent/create to revive`):new b("AGENT_NOT_FOUND",`agent not found: ${o}`);let d=typeof s.sessionId=="string"?s.sessionId:void 0;if(e.method==="session/cancel"||e.method==="session/new"||!d)return this.dispatchSessionCall(a,e.method,s);let u=Date.now(),f=!1,p=e.method==="session/prompt";p&&this.upgradeGate?.incActive();try{let h=await a.getSessionQueue(d).enqueue(()=>this.dispatchSessionCall(a,e.method,s));return f=!0,h}finally{p&&this.upgradeGate?.decActive(),U.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}=Bs(o);switch(s){case"session/new":{let d=ku();return U.info("session/new ack (lazy spawn)",{agentId:e.agentId,cloudId:d}),{sessionId:d}}case"session/load":{let d=a;return U.info("session/load ack (lazy spawn)",{agentId:e.agentId,cloudId:d.sessionId}),{}}case"session/prompt":{let d=a,u=d.sessionId;if(!u)throw new b("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 b("BRIDGE_INTERNAL","session runtime not ready after ensureDownstream");let p=o._meta?.cozeTriggerMsgId;p?e.activeTriggers.set(f.acpSessionId,p):e.activeTriggers.delete(f.acpSessionId);let h=Ms(o._meta);if(h?e.activeGroupIds.set(f.acpSessionId,h):e.activeGroupIds.delete(f.acpSessionId),e.deployType==="cloud"&&e.modelInfo?.capabilities?.image===!1&&Ko(d.prompt))throw new b("MODEL_MODALITY_UNSUPPORTED",`model=${e.modelInfo.id??e.model} does not support image input`);let y=await Ho(d.prompt);try{let w=await f.downstream.sessionPrompt({...d,sessionId:f.acpSessionId,prompt:y});return f.lastActiveAt=Date.now(),w}finally{if(e.activeTriggers.delete(f.acpSessionId),e.activeGroupIds.delete(f.acpSessionId),f.reloadAfterTurn){f.reloadAfterTurn=!1;let w=f.downstream;w&&(f.downstream=void 0,U.info("reloadAfterTurn: stopping downstream",{agentId:e.agentId,cloudId:u,acpId:f.acpSessionId}),w.stop("reload-after-turn").catch(A=>U.warn("reload-after-turn stop failed (ignored)",{agentId:e.agentId,cloudId:u,err:String(A)})))}else f.downstream?.isAlive()&&this.armIdleTimer(e,u,f)}}case"session/cancel":{let u=a.sessionId;if(!u)throw new b("IPC_BAD_REQUEST","session/cancel: missing sessionId");let f=e.sessions.get(u);if(e.hasSessionQueue(u)){let p=e.getSessionQueue(u);p.size>0&&(U.info("session/cancel: draining queued tasks",{agentId:e.agentId,cloudId:u,queuedCount:p.size}),p.dispose(new b("AGENT_PROTOCOL_ERROR",`cancelled by session/cancel on ${u}`)))}return f?.downstream?.isAlive()&&f.acpSessionId&&await f.downstream.sessionCancel({sessionId:f.acpSessionId}),{ok:!0}}default:throw new b("IPC_BAD_REQUEST",`session method not supported: ${s}`)}}async ensureRuntime(e,s){let o=e.sessions.get(s);if(o)return o;let d={modelToken:e.deployType==="cloud"?await this.requestSessionToken(e.agentId,s):"",tokenGeneratedAt:Date.now(),lastActiveAt:Date.now(),loadingSession:!1,replySeq:0};return e.sessions.set(s,d),await this.persistSessionMapping(e),d}async requestSessionToken(e,s){let o={sessionId:s,_meta:{cozeAgentId:e}};try{let a=await this.sendRequest(Ne.GEN_MODEL_TOKEN,o,Pu);if(!a?.modelToken)throw new b("MODEL_TOKEN_GEN_FAILED",`cloud returned empty modelToken (agentId=${e}, cloudSessionId=${s})`);return a.modelToken}catch(a){throw a instanceof b&&a.code==="MODEL_TOKEN_GEN_FAILED"?a:new b("MODEL_TOKEN_GEN_FAILED",a instanceof Error?a.message:String(a),{cause:a})}}async ensureDownstream(e,s,o){if(sn(o),o.downstream?.isAlive())return;if(!this.sessionSpawner)throw new b("AGENT_SPAWN_FAILED","sessionSpawner not wired (cannot spawn per-session downstream)");let a=3,d=3e4,u=o.spawnFailCount??0,f=o.spawnFailedAt??0;if(u>=a&&Date.now()-f<d)throw new b("AGENT_SPAWN_FAILED",`agent ${e.agentId} session ${s} spawn failed ${u} times in a row; please check framework binary / network and retry after ${Math.ceil((d-(Date.now()-f))/1e3)}s`);let p;try{p=await this.sessionSpawner(e,o.modelToken,s,this.currentCozeEnv)}catch(h){throw o.spawnFailCount=u+1,o.spawnFailedAt=Date.now(),o.spawnFailCount>=a&&o.acpSessionId&&(U.warn("clearing stale acpSessionId after repeated spawn failures",{agentId:e.agentId,cloudId:s,staleAcpId:o.acpSessionId}),o.acpSessionId=void 0),h}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}),U.info("session restored via session/load",{agentId:e.agentId,cloudId:s,acpId:o.acpSessionId})}catch(h){U.warn("session/load failed, fallback to session/new",{agentId:e.agentId,cloudId:s,acpId:o.acpSessionId,err:String(h)}),o.acpSessionId=void 0;let y=await p.sessionNew({cwd:e.workspace});o.acpSessionId=y.sessionId,await this.persistSessionMapping(e)}finally{o.loadingSession=!1}}else{let h=await p.sessionNew({cwd:e.workspace});o.acpSessionId=h.sessionId,await this.persistSessionMapping(e)}p.afterSessionEstablished&&o.acpSessionId&&await p.afterSessionEstablished(o.acpSessionId)}armIdleTimer(e,s,o){if(sn(o),this.isRuntimeBusy(e,o)){U.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)){U.info("idle reaper fired but runtime busy, re-arming",{agentId:e.agentId,cloudId:s}),this.armIdleTimer(e,s,o);return}U.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(d=>U.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 a of this.pendingUpstream.values())if(a.downstream===o)return!0;return!1}async sendAgentFileUpdate(e,s,o,a){let d={cozeAgentId:e.agentId,cozeReplySeqID:++s.replySeq};if(s.acpSessionId){let u=e.activeTriggers.get(s.acpSessionId);u&&(d.cozeTriggerMsgId=u);let f=e.activeGroupIds.get(s.acpSessionId);f&&(d.cozeGroupId=f)}await this.upstream.send(tn("session/update",{sessionId:o,update:a,_meta:d}))}forwardUpdate(e,s){let o=s.sessionId,a=this.reverseSessionId(e,o);if(!a){U.debug("drop update for unknown session",{agentId:e.agentId,acpId:o});return}let d=e.sessions.get(a);if(!d){U.debug("drop update: runtime gone",{agentId:e.agentId,cloudId:a});return}if(Ru(s)){U.debug("drop codex metadata-warn chunk",{agentId:e.agentId,acpId:o});return}let u={cozeAgentId:e.agentId,cozeReplySeqID:++d.replySeq},f=e.activeTriggers.get(o);f&&(u.cozeTriggerMsgId=f);let p=e.activeGroupIds.get(o);p&&(u.cozeGroupId=p),this.upstream.send(tn("session/update",{...s,sessionId:a,_meta:u})).catch(h=>U.warn("forward update failed",{agentId:e.agentId,err:String(h)}))}handleAgentRequest(e,s,o){if(o.method==="session/request_permission"){this.forwardPermissionRequest(e,s,o);return}if(o.method==="fs/write_text_file"||o.method==="fs/read_text_file"){this.handleFsRpcRequest(e,s,o);return}U.warn("unhandled agent request,returning method_not_found",{agentId:e.agentId,method:o.method}),s.respondAgentRequestError(o.id,{code:j.METHOD_NOT_FOUND,message:`method not handled by Bridge: ${o.method}`})}async handleFsRpcRequest(e,s,o){try{let a=e.workspace;if(o.method==="fs/write_text_file"){let d=o.params??{},u=await Fo(d,a);s.respondAgentRequest(o.id,u)}else{let d=o.params??{},u=await Uo(d,a);s.respondAgentRequest(o.id,u)}}catch(a){U.warn("fs rpc handler failed",{agentId:e.agentId,method:o.method,err:String(a)}),s.respondAgentRequestError(o.id,rn(a))}}forwardPermissionRequest(e,s,o){let a=this.upstreamIds.next("session/request_permission"),d=o.params??{},f=d.sessionId,p=f?e.activeTriggers.get(f):void 0,h={cozeAgentId:e.agentId};p&&(h.cozeTriggerMsgId=p);let y=f?e.activeGroupIds.get(f):void 0;y&&(h.cozeGroupId=y);let w=f?this.reverseSessionId(e,f):void 0,A={...d,...w?{sessionId:w}:{},_meta:h};this.pendingUpstream.set(a,{agentRequestId:o.id,agentId:e.agentId,downstream:s,method:o.method}),U.info("forward permission_request \u2192 upstream",{agentId:e.agentId,upstreamId:a,acpSessionId:f,cloudSessionId:w,toolCallId:d.toolCall?.toolCallId,options:d.options?.map(I=>({optionId:I.optionId,kind:I.kind,name:I.name}))}),this.upstream.send(en(a,"session/request_permission",A)).catch(I=>{this.pendingUpstream.delete(a),U.error("forward permission request failed",{agentId:e.agentId,err:String(I)}),s.respondAgentRequestError(o.id,{code:j.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 a=s.value;e.error?(U.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"&&Du(e.result,a),U.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 Fn(e.error)):o.value.resolve(e.result);return}U.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 d=String(s),u=e.get(d);if(u)return U.warn(`${o} id type mismatch: number received but Bridge expected string`,{rawId:s,normalizedId:d}),{value:u,key:d}}}sendRequest(e,s,o=Iu){let a=this.upstreamIds.next(e);return new Promise((d,u)=>{let f=setTimeout(()=>{this.pendingBridge.delete(a),u(new b("AGENT_TIMEOUT",`${e} timed out after ${o}ms`))},o);this.pendingBridge.set(a,{method:e,resolve:d,reject:u,timer:f}),this.upstream.send(en(a,e,s)).catch(p=>{let h=this.pendingBridge.get(a);h&&(clearTimeout(h.timer),this.pendingBridge.delete(a)),u(p)})})}async persistSessionMapping(e){if(this.paths)try{let s=new Map;for(let[o,a]of e.sessions){let d={modelToken:a.modelToken,tokenGeneratedAt:a.tokenGeneratedAt};a.acpSessionId&&(d.acpSessionId=a.acpSessionId),s.set(o,d)}await Jr(e.agentId,s,this.paths)}catch(s){U.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(ot(e,{code:s,message:o,data:{bridgeVersion:st}}))}};function ku(){return Au(16).toString("hex")}function Du(n,e){if(!n||typeof n!="object"){U.warn("permission response: result not an object (suspicious)",{agentId:e.agentId,result:n});return}let s=n;if("kind"in s&&!("outcome"in s)){U.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"){U.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")&&U.warn("permission response: unknown outcome discriminant",{agentId:e.agentId,outcomeValue:d,result:n})}function Ru(n){let e=n.update;if(e?.sessionUpdate!=="agent_message_chunk")return!1;let s=e.content;if(!s||typeof s!="object")return!1;let o=s;return o.type!=="text"||typeof o.text!="string"?!1:o.text.startsWith("Model metadata for `")}q();oe();import{randomBytes as Ou}from"node:crypto";import{chmod as Nu,mkdir as Lu,writeFile as Wo}from"node:fs/promises";import{createServer as Mu}from"node:http";import{dirname as Bu}from"node:path";var zu=1e6,di=D("ipc"),Yn=class{server=null;port=0;token="";routes;paths;constructor(e){this.routes=new Map(e.routes.map(s=>[`${s.method} ${s.path}`,s])),this.paths=e.paths??G()}async start(){this.token=Ou(32).toString("hex");let e=Mu((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 Lu(Bu(this.paths.portFile),{recursive:!0}),await Wo(this.paths.portFile,String(this.port),"utf8"),await Wo(this.paths.tokenFile,this.token,{encoding:"utf8",mode:384});try{await Nu(this.paths.tokenFile,384)}catch(e){di.warn("chmod token file failed (non-POSIX?)",{err:String(e)})}}async dispatch(e,s){if(e.headers.authorization!==`Bearer ${this.token}`){cn(s,401,{error:"unauthorized"});return}let a=`${e.method} ${(e.url??"").split("?")[0]}`,d=this.routes.get(a);if(!d){cn(s,404,{error:"not found"});return}let u=null;if(e.method==="POST")try{u=await Fu(e)}catch(f){cn(s,400,{error:"invalid json",detail:String(f)});return}try{let f=await d.handler(u,e);cn(s,200,f??{ok:!0})}catch(f){di.error("IPC handler failed",{key:a,err:String(f)}),cn(s,500,{error:f instanceof Error?f.message:String(f)})}}};function cn(n,e,s){n.statusCode=e,n.setHeader("content-type","application/json"),n.end(JSON.stringify(s))}async function Fu(n){let e=[],s=0;for await(let a of n){let d=a;if(s+=d.length,s>zu)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 $o}from"node:path";import{fileURLToPath as Uu}from"node:url";function Jo(){return qu(Uu(import.meta.url))}function qu(n){let e=`${$o}src${$o}`;return n.includes(e)}q();oe();import{spawn as Gu}from"node:child_process";import{existsSync as ju,mkdirSync as Hu,openSync as Ku}from"node:fs";import{dirname as Wu}from"node:path";import{fileURLToPath as $u}from"node:url";var Ju=D("spawn-helper");function Vu(n){return ju(n.libEntry)?n.libEntry:$u(new URL("../index.ts",import.meta.url))}function Xu(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 Vo(n,e,s={}){let o=s.paths??G(),a=Vu(o);Hu(Wu(o.logFile),{recursive:!0});let d=Ku(o.logFile,"a"),u=Xu(a,n,e),f=Gu(process.execPath,u,{detached:!0,stdio:["ignore",d,d],env:{...process.env,COZE_BRIDGE_UPGRADE_HELPER:"1"}});if(f.unref(),typeof f.pid!="number")throw new Error("failed to spawn upgrade helper (no pid)");Ju.info("upgrade helper spawned",{pid:f.pid,targetVersion:n,oldPid:e,entry:a})}q();import{mkdir as Yu,writeFile as Zu}from"node:fs/promises";import{dirname as Qu}from"node:path";import{gunzipSync as ef}from"node:zlib";var ui=D("tarball-downloader"),tf="https://registry.npmjs.org",Xo="package/dist/index.js";async function Yo(n,e,s={}){if(!/^[\w.\-+]+$/.test(n))throw new Error(`invalid version string: ${JSON.stringify(n)}`);let a=`${(s.registry??tf).replace(/\/+$/,"")}/coze-bridge/${n}`;ui.info("fetching tarball metadata",{metaUrl:a});let d=await fetch(a);if(!d.ok)throw new Error(`registry metadata ${a} returned ${d.status}`);let f=(await d.json())?.dist?.tarball;if(!f)throw new Error(`registry metadata missing dist.tarball for ${n}`);ui.info("downloading tarball",{tarballUrl:f});let p=await fetch(f);if(!p.ok)throw new Error(`tarball ${f} returned ${p.status}`);let h=Buffer.from(await p.arrayBuffer()),y=ef(h),w=nf(y,Xo);if(!w)throw new Error(`tarball missing entry ${Xo}`);await Yu(Qu(e),{recursive:!0}),await Zu(e,w),ui.info("dist extracted",{destPath:e,bytes:w.length})}function nf(n,e){let s=0;for(;s+512<=n.length;){let o=n.subarray(s,s+512);if(o.every(y=>y===0))return null;let a=o.subarray(0,100),d=a.indexOf(0),u=a.subarray(0,d===-1?100:d).toString("utf8"),f=o.subarray(124,136).toString("ascii").trim().replace(/\0/g,""),p=Number.parseInt(f,8)||0,h=s+512;if(u===e)return n.subarray(h,h+p);s=h+Math.ceil(p/512)*512}return null}Bt();q();import{resolve as rf}from"node:path";var lt=D("upgrade-manager"),sf=300*1e3,of=3,Zn=class{constructor(e){this.opts=e}opts;inFlightTarget=null;async requestUpgrade(e){if(this.inFlightTarget===e){lt.debug("upgrade already in-flight, skip",{targetVersion:e});return}this.inFlightTarget=e;try{let s=await ct(this.opts.paths.configFile)??{};if(s.disableAutoUpgrade){lt.info("disableAutoUpgrade=true, skip",{targetVersion:e});return}if(this.opts.isDevMode()){lt.warn("dev mode, skip auto-upgrade",{targetVersion:e});return}if(!Jn(this.opts.currentVersion,e)){lt.debug("local version >= target, skip",{local:this.opts.currentVersion,target:e});return}let o=s.upgradeAttempts?.[e];if((o?.count??0)>=of){lt.warn("upgrade attempts cap reached, skip",{targetVersion:e,count:o?.count});return}let a=rf(this.opts.paths.libDir,"index.js.next");try{await this.opts.download(e,a)}catch(u){await this.recordAttempt(s,e,String(u)),lt.warn("download failed, attempt recorded",{targetVersion:e,err:String(u)});return}this.opts.daemon.markUpgradePending(e);let d=await this.opts.daemon.waitIdle(sf);lt.info("waitIdle done",{result:d}),await this.opts.spawnHelper(e,process.pid),this.opts.daemon.exit(0)}finally{this.inFlightTarget=null}}async recordAttempt(e,s,o){e.upgradeAttempts=e.upgradeAttempts??{};let a=e.upgradeAttempts[s];e.upgradeAttempts[s]={count:(a?.count??0)+1,lastAt:Date.now(),...o?{lastError:o}:{}},await Ue(e,this.opts.paths.configFile)}};var _c=We(ca(),1);var Ul=We(rc(),1),ql=We(gr(),1),Gl=We(Ut(),1),jl=We(Ei(),1),Hl=We(Ti(),1),Kl=We(Oi(),1),fc=We(wr(),1),Wl=We(uc(),1);var lc=fc.default;q();var fe=D("upstream.frontier"),pc="application/json",hc="none",Jl=15e3,mn=class{constructor(e){this.opts=e}opts;fws=null;handler=null;connectHandlers=[];opened=!1;openCount=0;async start(){if(this.fws){fe.warn("start called on already-started FrontierUpstream; noop");return}let e={Authorization:`Bearer ${this.opts.privatecode}`,Origin:Us,...Dt(this.opts.ppeOverride)};class s extends lc{constructor(E){super(E,Fs,{headers:e})}send(E,...k){if(ys("debug"))try{let L;typeof E=="string"?L=Buffer.from(E,"utf8"):E instanceof Buffer?L=E:E instanceof ArrayBuffer?L=new Uint8Array(E):ArrayBuffer.isView(E)?L=new Uint8Array(E.buffer,E.byteOffset,E.byteLength):L=new Uint8Array(0);let $=Buffer.from(L.slice(0,128)).toString("hex");fe.debug("WS raw frame out",{bytes:L.byteLength,headHex:$})}catch(L){fe.warn("WS raw frame dump failed",{err:String(L)})}super.send(E,...k)}}let o=Gs(this.opts.urlOverride),a={url:o,ws:s,fpID:zs,aID:Ln,accessKey:this.opts.handshake.accessKey,deviceID:this.opts.handshake.deviceId,payloadType:{type:pc,force:!0},payloadEncoding:{encoding:hc,force:!0},enableTransformTextPayload:!0,enableQoS:!1,enableAutoAck:!1,automaticOpen:!1,maxRetries:Number.POSITIVE_INFINITY,debug:this.opts.debug??!1},d=new _c.FWS(a),u=!1,f=null,p,h,y=new Promise((I,E)=>{p=I,h=E}),w=I=>{u||(u=!0,f&&(clearTimeout(f),f=null),I?h(I):p())};d.onopen=()=>{this.opened=!0,this.openCount+=1;let I=this.openCount===1;fe.info("frontier opened",{url:o,remoteDeviceId:this.opts.handshake.deviceId,initial:I,openCount:this.openCount}),I&&w();for(let E of this.connectHandlers)Promise.resolve(E({initial:I})).catch(k=>fe.warn("onConnect handler threw (ignored)",{err:String(k)}))},d.onclose=I=>{this.opened=!1,fe.info("frontier closed",{code:I.code,reason:I.reason,willReconnect:I.willReconnect})},d.onerror=I=>{fe.warn("frontier error",{code:I.code,msg:I.message}),w(new b("UPSTREAM_DISCONNECTED",`frontier connect error before open: code=${I.code} msg=${I.message??""}`))},d.onmessage=I=>this.handleMessage(I),this.fws=d;let A=this.opts.openTimeoutMs??Jl;f=setTimeout(()=>{w(new b("UPSTREAM_DISCONNECTED",`frontier ws open timeout after ${A}ms (handshake or upgrade slow)`))},A),await d.connect();try{await y}catch(I){try{d.close(1e3,"open failed")}catch(E){fe.warn("fws close during start failure threw (ignored)",{err:String(E)})}throw this.fws=null,this.opened=!1,I}}async stop(e){let s=this.fws;if(s){this.fws=null,this.opened=!1;try{s.close(1e3,e??"bridge shutdown")}catch(o){fe.warn("frontier close threw (ignored)",{err:String(o)})}}}async send(e){let s=this.fws;if(!s)throw new b("UPSTREAM_DISCONNECTED","frontier upstream not started");if(!this.isConnected())throw new b("UPSTREAM_DISCONNECTED",`frontier ws not open (opened=${this.opened}, readyState=${s.readyState}); refusing to silently buffer`);this.injectAgentPatToken(e);let o=JSON.stringify(e),a=e;mc(a)||fe.info("frontier frame out",{method:a.method,jsonrpcId:a.id,size:o.length});try{await s.send(o,{service:33555712,method:1,payloadType:pc,payloadEncoding:hc})}catch(u){throw fe.warn("frontier frame send failed",{method:a.method,jsonrpcId:a.id,err:String(u)}),new b("UPSTREAM_DISCONNECTED",`frontier send failed: ${String(u)}`,{cause:u})}}onFrame(e){this.handler=e}onConnect(e){this.connectHandlers.push(e)}isConnected(){return this.opened&&this.fws?.readyState===1}injectAgentPatToken(e){let s=this.opts.getPatTokenForAgent;if(!s)return;let o=e.params?._meta;if(!o?.cozeAgentId)return;let a=s(o.cozeAgentId);a&&(o.cozePatToken=a)}handleMessage(e){let s=e.message?.service;if(s!==33555712){fe.debug("drop non-adapter frontier frame",{service:s});return}let o=Yl(e);if(!o){fe.debug("frontier message without text payload, drop",{payloadType:e.message?.payloadType});return}if(!this.handler){fe.debug("frame received but no onFrame handler",{size:o.length});return}let a;try{a=JSON.parse(o)}catch(u){fe.warn("frontier message JSON parse failed",{err:String(u),head:o.slice(0,80)});return}let d=a;mc(d)||fe.info("frontier frame in",{logid:Xl(e.message?.LogID),logidNew:e.message?.LogIDNew,msgId:e.message?.msgID,jsonrpcId:d.id,method:d.method,body:Vl(o)}),Promise.resolve(this.handler(a)).catch(u=>fe.warn("frontier frame handler threw",{err:String(u)}))}};function mc(n){return n.method==="_agent/health"?!0:typeof n.id=="string"&&n.id.startsWith("agent.health_")}var wc=2e3;function Vl(n){return n.length<=wc?n:`${n.slice(0,wc)}...<truncated, total ${n.length} chars>`}function Xl(n){return n?n.high===0?String(n.low>>>0):`${n.high.toString(16)}${(n.low>>>0).toString(16).padStart(8,"0")}`:""}function Yl(n){let e=n.message;if(e?.textPayload)return e.textPayload;let s=e?.payload;if(!s)return null;try{return Buffer.from(s).toString("utf8")}catch{return null}}q();var Li=D("upstream.switchable"),yr=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()}};q();var Mi=D("upstream"),Wt=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)}};q();q();oe();import{promises as Bi}from"node:fs";import{dirname as Zl}from"node:path";var Ql=D("pat-token-store");async function yc(n=G()){try{let s=(await Bi.readFile(n.patTokenFile,"utf8")).trim();return s.length>0?s:null}catch(e){return e?.code!=="ENOENT"&&Ql.warn("read pat-token failed (treating as missing)",{err:String(e)}),null}}async function wn(n,e=G()){if(!n)throw new Error("writePatToken: empty patToken");await Bi.mkdir(Zl(e.patTokenFile),{recursive:!0}),await Bi.writeFile(e.patTokenFile,n,{encoding:"utf8",mode:384})}oe();oe();import{promises as br}from"node:fs";import{join as eg}from"node:path";function tg(n){return`#!/bin/sh
115
+ `;var Le=q("agent-detail-sync"),Pu=6e4,ku=5*6e4,Jn=class{constructor(e){this.opts=e}opts;retryQueue=new Map;async syncAll(e){let i=this.opts.paths.agentsRoot,o;try{o=await Du(i)}catch(a){Le.info("agents dir not found, skip detail sync",{root:i,err:String(a)});return}Le.info("starting detail sync",{reason:e,count:o.length}),await Promise.allSettled(o.map(async a=>{let c=await Te(a,this.opts.paths).catch(()=>null);if(c){if(c.disconnectedAt){Le.debug("detail sync: skip disconnected agent",{agentId:a});return}try{await this.syncOne(a,c)}catch(u){Le.warn("detail sync failed for agent, skipping",{agentId:a,err:String(u)})}}})),Le.info("detail sync done",{reason:e})}async retryPending(){if(this.retryQueue.size===0)return;let e=Date.now(),i=[];for(let[o,a]of this.retryQueue)e>=a.dueAt&&i.push(o);if(i.length!==0){Le.info("retrying pending detail syncs",{count:i.length});for(let o of i)try{await this.syncOne(o)}catch(a){Le.debug("detail sync retry still failing, will try again",{agentId:o,err:String(a)})}}}async syncOne(e,i){let o=i??await Te(e,this.opts.paths);if(!o){Le.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(x){Le.warn("detail RPC failed, using local data",{agentId:e,err:String(x)});let l=this.retryQueue.get(e),g=l?Math.min(l.currentDelay*2,ku):Pu;this.retryQueue.set(e,{dueAt:Date.now()+g,currentDelay:g});return}if(a.agentId&&a.agentId!==e){Le.warn("detail response agentId mismatch, ignoring",{agentId:e,responseAgentId:a.agentId});return}let c=!1,u=!1;if(a.agentName&&a.agentName!==o.agentName&&(o.agentName=a.agentName,c=!0),a.description!==void 0&&a.description!==o.description&&(o.description=a.description,c=!0),a.cozeIdentity&&a.cozeIdentity!==o.cozeIdentity&&(o.cozeIdentity=a.cozeIdentity,c=!0,u=!0),a.deployType&&Le.info("detail.deployType",{agentId:e,deployType:a.deployType}),!c){Le.debug("detail sync: no diff",{agentId:e});return}await Ne(o,this.opts.paths),Le.info("detail sync: config updated",{agentId:e,identityChanged:u,agentName:o.agentName}),u&&(await Ut(o.workspace,o.framework,e,o.cozeIdentity),this.opts.handlers.reloadAgentSessionsPublic(e,"detail-sync"))}};var ua=Ge(Go(),1);lt();import{spawn as aa}from"node:child_process";import{lstat as Ci,mkdir as Ti,readFile as ca,readdir as Qu,rm as ef,stat as tf,writeFile as Di}from"node:fs/promises";import{dirname as nf,join as We,normalize as rf,relative as Ri,resolve as Pi,sep as da}from"node:path";var je={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 xn(n){return n?.cozeDeployType==="cloud"?"cloud":"local"}function jo(n){let e=n?.cozeAccountId?.trim();if(!(!e||e==="0"))return e}function Ko(n){let e=n?.cozeGroupId?.trim();if(!(!e||e==="0"))return e}function Wo(n){let{_meta:e,...i}=n;return{stripped:i,meta:e}}function jt(n){if(!n?.cozeAgentId)throw new Error("missing _meta.cozeAgentId");return n.cozeAgentId}var T=class extends Error{code;retriable;cause;constructor(e,i,o){super(i),this.name="BridgeError",this.code=e,this.retriable=o?.retriable??!1,o?.cause!==void 0&&(this.cause=o.cause)}};Z();ye();function it(n,e){if(xn(n)!=="cloud")throw new T("OPERATION_NOT_ALLOWED_FOR_LOCAL",`${e} is not allowed for local agent`)}function Qn(n){return n.startsWith("http://")||n.startsWith("https://")}function er(n){return n.endsWith("/")?n.slice(0,-1):n}Z();var tr="1008033",$o="1289";var Jo="pbbp2",Vo="https://www.coze.cn",Zo="/api/coze_claw/resource/get_frontier_key",Yu="https://www.coze.cn",Xu="wss://frontier.coze.cn";function nr(n){return n??process.env.COZE_BRIDGE_HANDSHAKE_URL??Yu}function Yo(n){return n??process.env.COZE_BRIDGE_FRONTIER_URL??Xu}function Kt(n){let e={},i=n?.ttEnv??process.env.COZE_BRIDGE_TT_ENV,o=n?.usePpe??process.env.COZE_BRIDGE_USE_PPE;return i&&(e["x-tt-env"]=i),o&&(e["x-use-ppe"]=o),e}function gn(n){return n?n.startsWith("boe_")?{ttEnv:n}:{ttEnv:n,usePpe:"1"}:{}}var ln=q("handshake");async function vi(n){let e=nr(n.endpoint),i=n.timeoutMs??1e4,o=`${er(e)}${Zo}?aid=${encodeURIComponent(tr)}`,a={Authorization:`Bearer ${n.privatecode}`,Accept:"application/json",...Kt(n.ppeOverride)},c=new AbortController,u=setTimeout(()=>c.abort(),i);ln.info("frontier key handshake",{base:e});try{let x=await fetch(o,{method:"GET",headers:a,signal:c.signal}),l=x.headers.get("x-tt-logid")??"",g=x.headers.get("x-tt-trace-id")??"";if(!x.ok){let b=await x.text().catch(()=>"");throw new T("UPSTREAM_HANDSHAKE_FAILED",`handshake HTTP ${x.status} logid=${l}: ${b.slice(0,200)}`)}let E=await x.json();if(E.code!==void 0&&E.code!==0)throw new T("UPSTREAM_HANDSHAKE_FAILED",`handshake code=${E.code} msg=${E.msg??"-"} logid=${l}`);let w=E.data??{},A=typeof w.access_key=="string"&&w.access_key||typeof w.accessKey=="string"&&w.accessKey||void 0,_=typeof w.device_id=="string"&&w.device_id||typeof w.deviceId=="string"&&w.deviceId||void 0;if(!A||!_){let b=JSON.stringify(E).slice(0,500);throw new T("UPSTREAM_HANDSHAKE_FAILED",`handshake response missing access_key/device_id (also tried camelCase) logid=${l}: ${b}`)}return ln.info("handshake ok",{remoteDeviceId:_,logid:l,traceId:g}),{accessKey:A,deviceId:_}}catch(x){if(x instanceof T)throw ln.error("handshake failed (bridge error)",{base:e,message:x.message,code:x.code}),x;if(x.name==="AbortError")throw ln.warn("handshake timeout",{base:e,timeoutMs:i}),new T("UPSTREAM_HANDSHAKE_FAILED",`handshake timeout (${i}ms)`,{cause:x});let l=x.cause;throw ln.error("handshake error",{base:e,message:x instanceof Error?x.message:String(x),errno:l?.code,syscall:l?.syscall,cause:String(x).slice(0,300)}),new T("UPSTREAM_HANDSHAKE_FAILED",String(x),{cause:x})}finally{clearTimeout(u)}}var Si=process.env.COZE_BRIDGE_LLM_GATEWAY_URL?.trim()||"https://llm-gateway.coze.cn",Ke="auto";function Xo(n){return{model:n.model??Ke,...n.modelToken?{modelToken:n.modelToken}:{}}}function Qo(n){return!n||n===Ke}function ea(n){let e={};return n.modelToken?(e.ANTHROPIC_BASE_URL=Si,e.ANTHROPIC_AUTH_TOKEN=n.modelToken,e.ANTHROPIC_MODEL=n.model||Ke,n.modelInfo?.contextWindow&&(e.CLAUDE_CODE_MAX_CONTEXT_TOKENS=String(n.modelInfo.contextWindow))):Qo(n.model)||(e.ANTHROPIC_MODEL=n.model),e}function ta(n){let e=[];return n.modelToken?e.push("-c",`model="${n.model||Ke}"`):Qo(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="${Si}/v1"`),e.push("-c",'model_providers.coze.env_key="OPENAI_API_KEY"'),e.push("-c",'model_providers.coze.wire_api="responses"'),e.push("-c","model_providers.coze.requires_openai_auth=false"),e.push("-c","model_providers.coze.supports_websockets=false"),e.push("-c",'model_provider="coze"'),n.modelInfo?.contextWindow&&e.push("-c",`model_context_window=${n.modelInfo.contextWindow}`)),e}function na(n){return n.modelToken?{OPENAI_API_KEY:n.modelToken}:{}}function Ii(n){let{ttEnv:e,usePpe:i}=gn(n),o={};return e&&(o["x-tt-env"]=e),i&&(o["x-use-ppe"]=i),o}function ra(n,e){if(!n.modelToken)return{};let i=Ii(e);return Object.keys(i).length===0?{}:{ANTHROPIC_CUSTOM_HEADERS:Object.entries(i).map(([a,c])=>`${a}:${c}`).join(`
116
+ `)}}function Ai(n){return`coze-session-${n.replace(/[^A-Za-z0-9_-]+/g,"-")}`}function ia(n,e){if(!n.modelToken)return null;let i=n.model||Ke,o=Ii(e),a=["text"];n.modelInfo?.capabilities?.image===!0&&a.push("image");let c={baseUrl:`${Si}/v1`,api:"openai-completions",apiKey:n.modelToken,models:[{id:i,name:i,reasoning:!1,input:a,cost:{input:0,output:0,cacheRead:0,cacheWrite:0},contextWindow:n.modelInfo?.contextWindow??128e3,maxTokens:8192,api:"openai-completions"}]};return Object.keys(o).length>0&&(c.headers=o),c}function sa(n,e){if(!n.modelToken)return[];let i=Ii(e),o=[];for(let[a,c]of Object.entries(i))o.push("-c",`model_providers.coze.http_headers.${a}="${c}"`);return o}var ve=q("agent-handlers"),oa=5*1024*1024,sf=1,of=6,af=new Set(["node_modules",".git",".coze","dist","build",".next"]),rr=class{constructor(e){this.opts=e}opts;async listSkills(e){it(e._meta,"_agent/listSkills");let i=jt(e._meta),o=await this.loadAgentCfg(i),a=o?.workspace??rt(i).workspace,c=o?.skills??[],u=[];for(let x of c){let l=We(a,x.relPath,"SKILL.md");await tf(l).then(E=>E.isFile()).catch(()=>!1)&&u.push(xf(x))}return{skills:u}}async addSkills(e){it(e._meta,"_agent/addSkills");let i=jt(e._meta),o=await this.requireAgentCfg(i),a=e.skills??[],c=[...o.skills??[]],u=new Map(c.map((l,g)=>[l.skillId,g])),x=[];for(let l of a){let g=await Ni({agentId:i,workspace:o.workspace,framework:o.framework,skill:l});Li(c,u,g),x.push(l)}return await Wn(i,c),this.reloadAgentSessions(i,"skills-added"),{installedSkills:x}}async removeSkills(e){it(e._meta,"_agent/removeSkills");let i=jt(e._meta),o=await this.requireAgentCfg(i),a=new Set(e.skillIds??[]),c=o.skills??[],u=[];for(let x of c){if(!a.has(x.skillId)){u.push(x);continue}let l=We(o.workspace,x.relPath);await ef(l,{recursive:!0,force:!0}),ve.info("skill removed",{agentId:i,skillId:x.skillId,relPath:x.relPath})}return await Wn(i,u),this.reloadAgentSessions(i,"skills-removed"),{ok:!0}}reloadAgentSessionsPublic(e,i){this.reloadAgentSessions(e,i)}reloadAgentSessions(e,i){let o=this.opts.agents.get(e);if(o)for(let[a,c]of o.sessions){if(!c.downstream)continue;let u=c.acpSessionId;if(u&&o.activeTriggers.has(u)||this.isRuntimePendingPermission(c)){c.reloadAfterTurn=!0,ve.info("downstream busy, scheduling reload after turn",{reason:i,agentId:e,framework:o.framework,cloudId:a,acpId:u});continue}let l=c.downstream;c.downstream=void 0,ve.info("killing downstream for workspace reload (idle)",{reason:i,agentId:e,framework:o.framework,cloudId:a,acpId:u}),l.stop(i).catch(g=>ve.warn("downstream stop failed during reload (ignored)",{reason:i,agentId:e,cloudId:a,err:String(g)}))}}isRuntimePendingPermission(e){let i=this.opts.isRuntimePendingPermission;return!i||!e.downstream?!1:i(e.downstream)}async updateAgent(e){if(!e.cozeIdentity?.trim())return ve.info("_agent/update: empty cozeIdentity, noop",{agentId:e.agentId}),{ok:!0};let i=e.agentId,o=await Te(i);if(!o)throw new T("AGENT_NOT_FOUND",`agent not found: ${i}`);if(o.cozeIdentity===e.cozeIdentity)return ve.info("_agent/update: cozeIdentity unchanged, noop",{agentId:i}),{ok:!0};try{await Ut(o.workspace,o.framework,i,e.cozeIdentity)}catch(a){throw ve.error("_agent/update: writeInstructionFile failed, aborting update",{agentId:i,framework:o.framework,workspace:o.workspace,err:String(a)}),new T("AGENT_PROTOCOL_ERROR",`failed to write instruction file for agent ${i}: ${String(a)}`,{cause:a})}return o.cozeIdentity=e.cozeIdentity,await Ne(o),ve.info("_agent/update: cozeIdentity rewritten",{agentId:i,framework:o.framework}),this.reloadAgentSessions(i,"identity-changed"),{ok:!0}}async disconnectAgent(e){let i=e.agentId;if(!i)throw new T("IPC_BAD_REQUEST","_agent/disconnect: missing agentId");let o=await Te(i);return o?(o.disconnectedAt=Date.now(),o.disconnectReason=e.reason??"",await Ne(o),ve.info("agent disconnected",{agentId:i,reason:e.reason??"",force:e.force??!1}),this.opts.disposeAndMarkDisconnected&&await this.opts.disposeAndMarkDisconnected(i,e.reason??"disconnect"),{ok:!0}):(ve.warn("_agent/disconnect: agent not found, ignoring",{agentId:i}),{ok:!0})}async switchModel(e){if(it(e._meta,"_agent/switchModel"),!e.agentId)throw new T("IPC_BAD_REQUEST","_agent/switchModel: missing agentId");let i=e.model?.trim()?e.model:Ke,o=await Te(e.agentId);if(!o)throw new T("AGENT_NOT_FOUND",`agent not found: ${e.agentId}`);o.model=i,e.modelInfo&&(o.modelInfo=e.modelInfo),await Ne(o),ve.info("_agent/switchModel: model persisted",{agentId:e.agentId,model:i,reason:e.reason??""});let a=this.opts.agents.get(e.agentId);if(!a)return ve.info("_agent/switchModel: agent not running, config persisted only",{agentId:e.agentId}),{ok:!0};a.model=i,e.modelInfo&&a.setModelInfo(e.modelInfo),this.opts.cleanupOpenclawProviders&&await this.opts.cleanupOpenclawProviders(a).catch(u=>ve.warn("cleanupOpenclawProviders before switchModel failed (ignored)",{agentId:e.agentId,err:String(u)}));let c=[];for(let[u,x]of a.allSessionQueues())c.push(x.enqueue(async()=>{let l=a.sessions.get(u);l?.downstream&&(await l.downstream.stop(`switchModel: ${i}`).catch(()=>{}),l.downstream=void 0)}));return await Promise.all(c),ve.info("_agent/switchModel: all session runtimes killed, next prompt will respawn",{agentId:e.agentId,model:i,cloudSessions:c.length}),{ok:!0}}async resetAgent(e){if(it(e._meta,je.RESET),!e.agentId)throw new T("IPC_BAD_REQUEST",`${je.RESET}: missing agentId`);return await this.runDetailSync(e.agentId,je.RESET,e.reason),{ok:!0}}async repairAgent(e){if(it(e._meta,je.REPAIR),!e.agentId)throw new T("IPC_BAD_REQUEST",`${je.REPAIR}: missing agentId`);let i=await this.loadAgentCfg(e.agentId);if(i&&i.framework!=="openclaw")throw new T("IPC_BAD_REQUEST",`${je.REPAIR} only allowed for openclaw, got ${i.framework}`);if(i&&this.opts.openclawRepair)try{await this.opts.openclawRepair(e.agentId,i.workspace)}catch(o){ve.warn("openclaw repair (delete+add) failed (ignored)",{agentId:e.agentId,reason:e.reason,err:String(o)})}return await this.runDetailSync(e.agentId,je.REPAIR,e.reason),{ok:!0}}async runDetailSync(e,i,o){if(!this.opts.detailSyncer){ve.warn("detailSyncer not wired, skipping sync",{method:i,agentId:e});return}try{await this.opts.detailSyncer(e)}catch(a){ve.warn("detail sync failed (ignored)",{method:i,agentId:e,reason:o,err:String(a)})}}async getFileTree(e){it(e._meta,"_agent/getFileTree");let i=e._meta,o=jt(i),a=await this.resolveWorkspace(o),c=e.filePath??"",u=this.safeJoin(a,c),x=await Ci(u).catch(()=>null);if(!x)throw new T("IPC_BAD_REQUEST",`path not found: ${c}`);if(x.isSymbolicLink())throw new T("IPC_BAD_REQUEST",`symlink not allowed: ${c}`);let l=vf(e.depth);return x.isDirectory()?{tree:await bf(a,u,c,l)}:{tree:[{name:Sf(c),path:xa(c||"."),isDir:!1,size:x.size,modifiedAt:Math.floor(x.mtimeMs)}]}}async getFileContent(e){it(e._meta,"_agent/getFileContent");let i=jt(e._meta),o=await this.resolveWorkspace(i);if(!e.filePath)throw new T("IPC_BAD_REQUEST","filePath required");let a=this.safeJoin(o,e.filePath),c=await Ci(a).catch(()=>null);if(!c||!c.isFile())throw new T("IPC_BAD_REQUEST",`not a file: ${e.filePath}`);if(c.isSymbolicLink())throw new T("IPC_BAD_REQUEST",`symlink not allowed: ${e.filePath}`);if(c.size>oa)throw new T("IPC_BAD_REQUEST",`file too large: ${c.size} bytes (max ${oa})`);let u=await ca(a);return u.includes(0)?{content:u.toString("base64"),encoding:"base64",size:c.size}:{content:u.toString("utf8"),encoding:"utf-8",size:c.size}}async resolveWorkspace(e){let i=this.opts.agents.get(e);return i?i.workspace:(await Te(e).catch(()=>null))?.workspace??rt(e).workspace}safeJoin(e,i){let o=Pi(e,i||"."),a=Ri(e,o);if(a.startsWith("..")||a===".."||a.startsWith(`..${da}`))throw new T("IPC_BAD_REQUEST",`path escapes workspace: ${i}`);return o}loadAgentCfg(e){return Te(e)}async requireAgentCfg(e){let i=await this.loadAgentCfg(e);if(!i)throw new T("AGENT_NOT_FOUND",`no config for agent: ${e}`);return i}};function cf(n){let e=n.trim().replace(/[\x00-\x1f<>:"|?*/\\]+/g,"-").replace(/^[\s.-]+|[\s.-]+$/g,"").slice(0,64);if(!e||e==="."||e==="..")throw new T("IPC_BAD_REQUEST",`invalid skill name: ${n}`);if(/^(con|prn|aux|nul|com[1-9]|lpt[1-9])$/i.test(e))throw new T("IPC_BAD_REQUEST",`reserved windows filename: ${n}`);return e}function df(n){return n==="claude-code"?We(".claude","skills"):We(".agents","skills")}var uf=3e4,ff=50*1024*1024,ir=3e4;async function Ni(n){let{agentId:e,workspace:i,framework:o,skill:a}=n;if(!a.skillName)throw new T("IPC_BAD_REQUEST","skill missing skillName");let c=typeof a.content=="string"&&a.content.length>0,u=typeof a.downloadUrl=="string"&&a.downloadUrl.length>0;if(!c&&!u)throw new T("IPC_BAD_REQUEST",`skill ${a.skillId} missing both content and downloadUrl`);let x=cf(a.skillName),l=df(o),g=We(l,x),E=We(i,g);if(await Ti(E,{recursive:!0}),c){let A=Buffer.from(a.content,"utf8");hn(A.length),await Di(We(E,"SKILL.md"),A,"utf8")}else{let A=await lf(a.downloadUrl);hf(A)?await _f(A,E):pf(A)?await mf(A,E):await Di(We(E,"SKILL.md"),A.toString("utf8"),"utf8")}let w={skillId:a.skillId,skillName:a.skillName,relPath:g,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 ve.info("skill installed",{agentId:e,skillId:a.skillId,skillName:a.skillName,relPath:g,source:c?"content":"downloadUrl"}),w}function Li(n,e,i){let o=e.get(i.skillId);if(o!==void 0){n[o]=i;return}e.set(i.skillId,n.length),n.push(i)}function xf(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 lf(n){if(!n)throw new T("IPC_BAD_REQUEST","skill missing downloadUrl");if(n.startsWith("data:")){let e=Math.floor(n.length*3/4);hn(e);let i=gf(n);return hn(i.length),i}if(n.startsWith("file:")){let e=new URL(n).pathname,i=await ca(e);return hn(i.length),i}if(Qn(n)){let e=new AbortController,i=setTimeout(()=>e.abort(),uf);try{let o=await fetch(n,{signal:e.signal});if(!o.ok)throw new T("IPC_BAD_REQUEST",`fetch skill failed HTTP ${o.status} ${n}`);let a=await o.arrayBuffer();return hn(a.byteLength),Buffer.from(a)}finally{clearTimeout(i)}}throw new T("IPC_BAD_REQUEST",`unsupported downloadUrl scheme (\u8981 https/data/file): ${n.slice(0,80)}`)}function hn(n){if(n>ff)throw new T("IPC_BAD_REQUEST",`skill too large: ${n} bytes`)}function gf(n){let e=/^data:([^,;]*)(;base64)?,(.*)$/s.exec(n);if(!e)throw new T("IPC_BAD_REQUEST","bad data URL");let i=!!e[2],o=e[3]??"";return i?Buffer.from(o,"base64"):Buffer.from(decodeURIComponent(o),"utf8")}function hf(n){return n.length>=2&&n[0]===31&&n[1]===139}function pf(n){if(n.length<4||n[0]!==80||n[1]!==75)return!1;let e=n[2],i=n[3];return e===3&&i===4||e===5&&i===6}function ki(n){return n==="__MACOSX"||n.startsWith("__MACOSX/")}async function mf(n,e){let i,o;try{i=new ua.default(n),o=i.getEntries()}catch(u){throw new T("IPC_BAD_REQUEST",`zip parse failed: ${u.message}`,{cause:u})}for(let u of o){let x=u.entryName;if(!x||ki(x))continue;if(x.startsWith("/")||/^[A-Za-z]:[\\/]/.test(x))throw new T("IPC_BAD_REQUEST",`zip entry absolute path: ${x}`);if(x.split(/[/\\]/).some(g=>g===".."))throw new T("IPC_BAD_REQUEST",`zip entry contains '..' (traversal): ${x}`);let l=u.header.attr>>>16&61440;if(l!==0&&l!==32768&&l!==16384)throw new T("IPC_BAD_REQUEST",`zip entry kind 0x${l.toString(16)} not allowed (symlink/hardlink/special): ${x}`)}let a=wf(o),c=Pi(e);for(let u of o){if(ki(u.entryName))continue;let x=u.entryName;if(a&&x.startsWith(a)&&(x=x.slice(a.length)),!x)continue;let l=Pi(e,x),g=Ri(c,l);if(g.startsWith("..")||g==="..")throw new T("IPC_BAD_REQUEST",`zip entry escapes destDir: ${x}`);if(u.isDirectory){await Ti(l,{recursive:!0});continue}await Ti(nf(l),{recursive:!0});let E;try{E=u.getData()}catch(w){throw new T("IPC_BAD_REQUEST",`zip entry getData failed (${u.entryName}): ${w.message}`,{cause:w})}await Di(l,E)}}function wf(n){let e;for(let i of n){let o=i.entryName;if(!o||ki(o))continue;let a=o.indexOf("/");if(a<=0)return;let c=o.slice(0,a+1);if(e===void 0)e=c;else if(e!==c)return}return e}async function _f(n,e){await yf(n),await new Promise((i,o)=>{let a=aa("tar",["-xzf","-","-C",e,"--strip-components=1","--no-same-owner"],{stdio:["pipe","pipe","pipe"]}),c="";a.stderr?.on("data",x=>{c+=String(x)});let u=setTimeout(()=>{a.kill("SIGKILL"),o(new T("IPC_BAD_REQUEST",`tar extract timeout (${ir}ms)`))},ir);a.on("error",x=>{clearTimeout(u),o(new T("IPC_BAD_REQUEST",`tar spawn failed: ${x.message}`,{cause:x}))}),a.on("exit",x=>{clearTimeout(u),x===0?i():o(new T("IPC_BAD_REQUEST",`tar exit ${x}${c?`: ${c.trim().slice(0,200)}`:""}`))}),a.stdin?.end(n)})}async function yf(n){let e=await new Promise((i,o)=>{let a=aa("tar",["-tzvf","-"],{stdio:["pipe","pipe","pipe"]}),c="",u="";a.stdout?.on("data",l=>{c+=String(l)}),a.stderr?.on("data",l=>{u+=String(l)});let x=setTimeout(()=>{a.kill("SIGKILL"),o(new T("IPC_BAD_REQUEST",`tar list timeout (${ir}ms)`))},ir);a.on("error",l=>{clearTimeout(x),o(new T("IPC_BAD_REQUEST",`tar list spawn failed: ${l.message}`))}),a.on("exit",l=>{clearTimeout(x),l===0?i(c):o(new T("IPC_BAD_REQUEST",`tar list exit ${l}${u?`: ${u.trim().slice(0,200)}`:""}`))}),a.stdin?.end(n)});for(let i of e.split(`
117
+ `)){let o=i.trim();if(!o)continue;let a=o.charCodeAt(0);if(a!==45&&a!==100)throw new T("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 T("IPC_BAD_REQUEST",`tar entry absolute path: ${u}`);if(u.split(/[/\\]/).some(l=>l===".."))throw new T("IPC_BAD_REQUEST",`tar entry contains '..': ${u}`)}}var Ef=5e3;async function bf(n,e,i,o){return fa(n,e,i,o,{count:0})}async function fa(n,e,i,o,a){if(o<=0)return[];let c;try{c=await Qu(e,{withFileTypes:!0})}catch{return[]}let u=[];for(let x of c){if(af.has(x.name)||x.isSymbolicLink())continue;if(a.count>=Ef){u.push({name:"...",path:"...",isDir:!1,size:0,modifiedAt:0,hasMore:!0});break}let l=We(e,x.name),g=rf(We(i,x.name)),E=null;try{E=await Ci(l)}catch{continue}if(E.isSymbolicLink())continue;a.count++;let w={name:x.name,path:xa(Ri(n,l)),isDir:E.isDirectory(),size:E.size,modifiedAt:Math.floor(E.mtimeMs)};E.isDirectory()&&o>1&&(w.children=await fa(n,l,g,o-1,a)),u.push(w)}return u.sort((x,l)=>x.isDir!==l.isDir?x.isDir?-1:1:x.name.localeCompare(l.name)),u}function vf(n){return!n||n<=0?sf:Math.min(n,of)}function Sf(n){if(!n||n==="."||n==="/")return".";let e=n.split(/[/\\]/);return e[e.length-1]||"."}function xa(n){return n.split(da).join("/")}Z();import{readFileSync as gw}from"node:fs";import{dirname as pw,join as mw}from"node:path";import{fileURLToPath as _w}from"node:url";var ht="0.1.69";var $e=q("agent-health-reporter"),If=1e4,pn=class{constructor(e){this.opts=e;this.intervalMs=e.intervalMs??If}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()}),$e.info("heartbeat started",{intervalMs:this.intervalMs}),this.tick())}stop(){this.timer&&(clearInterval(this.timer),this.timer=null,this.unsubscribeRegister&&(this.unsubscribeRegister(),this.unsubscribeRegister=null),$e.info("heartbeat stopped"))}async tick(){if(this.inFlight){$e.debug("previous tick still in-flight, skip");return}let e=this.opts.getDeviceId();if(!e){$e.debug("deviceId not available, skip tick (\u5C1A\u672A pair)");return}this.inFlight=!0;try{let i=[];for(let x of this.opts.core.agents.values()){let l=Af(x);if(!l)continue;let g={agentId:x.agentId,status:l};x.patToken&&(g.patToken=x.patToken),x.accountId&&(g.accountId=x.accountId),i.push(g)}if(i.length===0)return;let o={agents:i,bridgeVersion:ht,_meta:{cozeDeviceId:e}},a;try{a=await this.opts.core.sendRequest("_agent/health",o,5e3)}catch(x){$e.warn("heartbeat batch send failed",{count:i.length,err:String(x)})}let c=a?.authFailures;if(c&&c.length>0&&($e.warn("heartbeat received authFailures from cloud",{count:c.length,agentIds:c.map(x=>x.agentId)}),this.opts.onAuthFailures))try{await this.opts.onAuthFailures(c)}catch(x){$e.warn("onAuthFailures callback failed (ignored)",{err:String(x)})}let u=a?.minBridgeVersion;if(u&&($e.info("heartbeat received minBridgeVersion from cloud",{minV:u}),this.opts.onMinBridgeVersion))try{await this.opts.onMinBridgeVersion(u)}catch(x){$e.warn("onMinBridgeVersion callback failed (ignored)",{err:String(x)})}}finally{this.inFlight=!1}if(this.opts.onTickEnd)try{await this.opts.onTickEnd()}catch(i){$e.warn("onTickEnd hook failed",{err:String(i)})}}};function Af(n){return n.status==="error"?"error":n.activeTriggers.size>0?"busy":n.status==="ok"?"online":null}lt();import{mkdir as Bi,rm as ex}from"node:fs/promises";import{spawn as Lf,spawnSync as Of}from"node:child_process";function mn(n,e,i){return i===void 0?{jsonrpc:"2.0",id:n,method:e}:{jsonrpc:"2.0",id:n,method:e,params:i}}function wn(n,e){return e===void 0?{jsonrpc:"2.0",method:n}:{jsonrpc:"2.0",method:n,params:e}}function Wt(n,e){return{jsonrpc:"2.0",id:n,result:e}}function pt(n,e){return{jsonrpc:"2.0",id:n,error:e}}var sr=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)}},X={PARSE_ERROR:-32700,INVALID_REQUEST:-32600,METHOD_NOT_FOUND:-32601,INVALID_PARAMS:-32602,INTERNAL_ERROR:-32603,AGENT_NOT_FOUND:-32001,AGENT_BUSY:-32002,AGENT_TIMEOUT:-32003,AGENT_SPAWN_FAILED:-32004,OPERATION_NOT_ALLOWED_FOR_LOCAL:-32005,AGENT_DISCONNECTED:-32006,MODEL_TOKEN_GEN_FAILED:-32009,PATH_OUTSIDE_WORKSPACE:-32010,FILE_TOO_LARGE:-32011,UNSUPPORTED_MIME:-32012,UPLOAD_FAILED:-32013,UPSTREAM_NOT_READY:-32014,BRIDGE_UPGRADING:-32015,AGENT_FRAME_IDLE_TIMEOUT:-32016,MODEL_MODALITY_UNSUPPORTED:-32017};function la(n){return"method"in n&&"id"in n&&n.id!==void 0}function ga(n){return"method"in n&&!("id"in n)}function or(n){return!("method"in n)&&"id"in n}var Cf={AGENT_NOT_FOUND:X.AGENT_NOT_FOUND,AGENT_BUSY:X.AGENT_BUSY,AGENT_DISCONNECTED:X.AGENT_DISCONNECTED,AGENT_TIMEOUT:X.AGENT_TIMEOUT,AGENT_FRAME_IDLE_TIMEOUT:X.AGENT_FRAME_IDLE_TIMEOUT,AGENT_SPAWN_FAILED:X.AGENT_SPAWN_FAILED,AGENT_PROTOCOL_ERROR:X.INTERNAL_ERROR,BRIDGE_CONFIG_INVALID:X.INTERNAL_ERROR,BRIDGE_INTERNAL:X.INTERNAL_ERROR,IPC_AUTH_FAILED:X.INTERNAL_ERROR,IPC_BAD_REQUEST:X.INVALID_REQUEST,MODEL_TOKEN_GEN_FAILED:X.MODEL_TOKEN_GEN_FAILED,MODEL_MODALITY_UNSUPPORTED:X.MODEL_MODALITY_UNSUPPORTED,OPERATION_NOT_ALLOWED_FOR_LOCAL:X.OPERATION_NOT_ALLOWED_FOR_LOCAL,UPSTREAM_DISCONNECTED:X.INTERNAL_ERROR,UPSTREAM_HANDSHAKE_FAILED:X.INTERNAL_ERROR,PATH_OUTSIDE_WORKSPACE:X.PATH_OUTSIDE_WORKSPACE,FILE_TOO_LARGE:X.FILE_TOO_LARGE,UNSUPPORTED_MIME:X.UNSUPPORTED_MIME,UPLOAD_FAILED:X.UPLOAD_FAILED,UPSTREAM_NOT_READY:X.UPSTREAM_NOT_READY,BRIDGE_UPGRADING:X.BRIDGE_UPGRADING,NPX_CACHE_CORRUPT:X.INTERNAL_ERROR};function Tf(n){if(n!=null)return n instanceof Error?{name:n.name,message:_n(n.message)}:typeof n=="string"?_n(n):typeof n=="object"?Pf(n):n}var Df=[[/\/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 _n(n){let e=n;for(let[i,o]of Df)e=e.replace(i,o);return e}function Pf(n){let e={};for(let[i,o]of Object.entries(n))typeof o=="string"?e[i]=_n(o):e[i]=o;return e}function yn(n){if(n instanceof T){let e=Tf(n.cause),i={bridgeCode:n.code,retriable:n.retriable};return e!==void 0&&(i.cause=e),{code:Cf[n.code]??X.INTERNAL_ERROR,message:_n(n.message),data:i}}return{code:X.INTERNAL_ERROR,message:_n(n instanceof Error?n.message:String(n))}}function ha(n){let e=n.data,i=e?.bridgeCode??"AGENT_PROTOCOL_ERROR",o=!!e&&typeof e.message=="string"&&!!e.message,a=o?e?.message:n.message,c=n.data;if(o&&e){let{message:u,...x}=e;c=x}return new T(i,a,{retriable:e?.retriable??!1,cause:c})}function ma(n){return`${JSON.stringify(n)}
118
+ `}var pa=10*1024*1024,ar=class{buffer="";onError;constructor(e={}){this.onError=e.onError}push(e){if(this.buffer+=typeof e=="string"?e:e.toString("utf8"),this.buffer.length>pa){let a=this.buffer.length;return this.buffer="",this.onError?.({line:`<buffer overflow: ${a} bytes, dropped>`,error:new Error(`LdjsonDecoder buffer exceeded ${pa} bytes`)}),[]}let i=this.buffer.split(`
119
+ `);this.buffer=i.pop()??"";let o=[];for(let a of i){let c=a.replace(/\r$/,"").trim();if(c)try{o.push(JSON.parse(c))}catch(u){this.onError?.({line:c,error:u})}}return o}flush(){if(!this.buffer)return[];let e=this.buffer.replace(/\r$/,"").trim();if(this.buffer="",!e)return[];try{return[JSON.parse(e)]}catch(i){return this.onError?.({line:e,error:i}),[]}}};var _a={"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"},Pw=Object.fromEntries(Object.entries(_a).map(([n,e])=>[e,n])),kf={"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:[]},$t=class{seq=0;next(e,i){this.seq+=1;let o=_a[e]??Rf(e),a=kf[o]??[],c=[o,String(this.seq)];if(a.length>0){let u=a.map(l=>wa(i?.[l]??"")),x=Nf(u).join(":");x&&c.push(x)}else i&&Object.values(i).some(u=>u)&&c.push(Object.values(i).filter(Boolean).map(u=>wa(String(u))).join(":"));return c.join("_")}reset(){this.seq=0}};function Rf(n){return n.replace(/[\s/]+/g,".").replace(/_+/g,"-")}function wa(n){return n.replace(/[:_\s]+/g,"-")}function Nf(n){let e=n.length;for(;e>0&&!n[e-1];)e-=1;return n.slice(0,e)}function mt(n,e){let i=process.env[n];if(!i)return e;let o=Number(i);return Number.isFinite(o)&&o>0?o:e}Z();var Mf=mt("COZE_BRIDGE_INITIALIZE_TIMEOUT_MS",3e4),Bf=200,zf=/(ENOTEMPTY|EEXIST).*_npx[/\\]/;function Oi(n){return n.some(e=>zf.test(e))}var Ff=mt("COZE_BRIDGE_SESSION_PROMPT_MAX_MS",3600*1e3),Uf=mt("COZE_BRIDGE_SESSION_PROMPT_FRAME_IDLE_MS",600*1e3),ya=500;function qf(n){try{let e=JSON.stringify(n);return e===void 0||e.length<=ya?n:`${e.slice(0,ya)}...<truncated, total ${e.length} chars>`}catch{return"<unserializable>"}}function Ea(n,e){if(!(typeof n!="number"||n<=0))try{if(process.platform==="win32"){let i=["/PID",String(n),"/T"];e==="SIGKILL"&&i.push("/F"),Of("taskkill",i,{stdio:"ignore",windowsHide:!0})}else process.kill(-n,e)}catch{}}var Je=class{constructor(e){this.opts=e;this.log=q(`downstream.${this.constructor.name}`),this.decoder=new ar({onError:i=>this.log.warn("decode line failed",{line:i.line})})}opts;child;decoder;pending=new Map;inflightAgentRequests=new Map;idAllocator=new $t;updateHandlers=[];agentRequestHandlers=[];exitHandlers=[];log;stopped=!1;stderrRing=[];sanitizeEnv(e){return e}async start(){if(this.child)throw new T("BRIDGE_INTERNAL","Downstream already started");let e=process.platform!=="win32",i=Lf(this.opts.command,this.opts.args,{cwd:this.opts.cwd,env:{...this.sanitizeEnv(process.env),...this.opts.env},stdio:["pipe","pipe","pipe"],detached:e});this.child=i,i.stdout?.setEncoding("utf8"),i.stdout?.on("data",o=>{try{for(let a of this.decoder.push(o))this.dispatch(a)}catch(a){this.log.warn("stdout dispatch threw, swallowed to keep daemon alive",{err:String(a)})}}),i.stderr?.setEncoding("utf8"),i.stderr?.on("data",o=>{let a=o.trimEnd();this.stderrRing.push(a),this.stderrRing.length>Bf&&this.stderrRing.shift(),this.log.debug("stderr",{text:a})}),i.stdin?.on("error",o=>{this.log.warn("child stdin error",{err:String(o)})}),i.stdout?.on("error",o=>{this.log.warn("child stdout error",{err:String(o)})}),i.stderr?.on("error",o=>{this.log.warn("child stderr error",{err:String(o)})}),i.on("exit",(o,a)=>{this.stopped=!0,(o!==0||a!==null)&&this.stderrRing.length>0&&(this.log.warn("downstream exited abnormally, recent stderr",{code:o,signal:a,recentStderr:[...this.stderrRing]}),(this.framework==="claude-code"||this.framework==="codex")&&Oi(this.stderrRing)&&(this.log.warn("npx cache corruption detected, triggering global install fallback (D93)",{framework:this.framework}),Bt(this.framework).catch(x=>{this.log.warn("D93 fallback install failed (will retry next spawn cycle)",{framework:this.framework,err:String(x)})})));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 T("AGENT_PROTOCOL_ERROR",`agent exited (${o}/${a})`));for(let u of this.exitHandlers)u(o,a)}),i.on("error",o=>{this.log.error("child error",{err:String(o)}),this.failAllPending(new T("AGENT_SPAWN_FAILED",String(o),{cause:o}))}),this.log.info("downstream started",{command:this.opts.command,pid:i.pid,cwd:this.opts.cwd})}async stop(e){if(!this.child||this.stopped)return;this.stopped=!0,this.log.info("downstream stopping",{reason:e});let i=this.child,o=new Promise(c=>i.once("exit",()=>c()));Ea(i.pid,"SIGTERM");let a=setTimeout(()=>{i.killed||Ea(i.pid,"SIGKILL")},5e3);try{await o}finally{clearTimeout(a)}}pid(){return this.child?.pid}isAlive(){return!!this.child&&!this.stopped}getStderrTail(){return[...this.stderrRing]}initialize(e){return this.call("initialize",e)}sessionNew(e){return this.call("session/new",{mcpServers:[],...e})}sessionLoad(e){return this.call("session/load",{mcpServers:[],...e})}sessionPrompt(e,i=Ff,o=Uf){return this.call("session/prompt",e,i,o)}async sessionCancel(e){!this.child||this.stopped||this.writeFrame(wn("session/cancel",e))}onUpdate(e){this.updateHandlers.push(e)}onAgentRequest(e){this.agentRequestHandlers.push(e)}respondAgentRequest(e,i){if(this.inflightAgentRequests.delete(e),!(!this.child||this.stopped))try{this.writeFrame(Wt(e,i))}catch(o){this.log.warn("respondAgentRequest write failed",{id:e,err:String(o)})}}respondAgentRequestError(e,i){if(this.inflightAgentRequests.delete(e),!(!this.child||this.stopped))try{this.writeFrame(pt(e,i))}catch(o){this.log.warn("respondAgentRequestError write failed",{id:e,err:String(o)})}}onExit(e){this.exitHandlers.push(e)}call(e,i,o=Mf,a=0){if(!this.child||this.stopped)return Promise.reject(new T("AGENT_PROTOCOL_ERROR","downstream not started"));let c=this.idAllocator.next(e),u=mn(c,e,i),x=(()=>{if(typeof i!="object"||i===null)return;let E=i.sessionId;return typeof E=="string"?E:void 0})(),l=o>0&&Number.isFinite(o),g=a>0&&Number.isFinite(a);return new Promise((E,w)=>{let A={resolve:E,reject:w,timer:null,frameIdleTimer:null,armFrameIdle:null,method:e};l&&(A.timer=setTimeout(()=>{this.pending.delete(c),A.frameIdleTimer&&clearTimeout(A.frameIdleTimer),this.log.warn("downstream call timeout",{id:c,method:e,timeoutMs:o,...x?{sessionId:x}:{}}),w(new T("AGENT_TIMEOUT",`${e} timed out after ${o}ms`))},o));let _=g?()=>{A.frameIdleTimer&&clearTimeout(A.frameIdleTimer),A.frameIdleTimer=setTimeout(()=>{if(this.inflightAgentRequests.size>0){this.log.debug("frame-idle fired but agent request inflight, re-arming",{id:c,method:e,inflight:this.inflightAgentRequests.size,...x?{sessionId:x}:{}}),_?.();return}A.timer&&clearTimeout(A.timer),this.pending.delete(c),this.log.warn("frame-idle timeout, rejecting pending call",{id:c,method:e,frameIdleMs:a,...x?{sessionId:x}:{}}),w(new T("AGENT_FRAME_IDLE_TIMEOUT",`${e} no session/update for ${a}ms (no inflight agent request)`))},a)}:null;A.armFrameIdle=_,this.pending.set(c,A),_?.();try{this.writeFrame(u)}catch(b){A.timer&&clearTimeout(A.timer),A.frameIdleTimer&&clearTimeout(A.frameIdleTimer),this.pending.delete(c),w(b)}})}writeFrame(e){if(!this.child?.stdin||this.child.stdin.destroyed)throw new T("AGENT_PROTOCOL_ERROR","downstream stdin not writable");this.child.stdin.write(ma(e),i=>{i&&this.log.warn("stdin write callback err",{err:String(i)})})}dispatch(e){if(or(e)){let i=e.id!==null?this.pending.get(e.id):void 0;if(!i){this.log.warn("orphan response",{id:e.id});return}this.pending.delete(e.id),i.timer&&clearTimeout(i.timer),i.frameIdleTimer&&clearTimeout(i.frameIdleTimer),e.error?(this.log.warn("downstream returned error frame",{id:e.id,method:i.method,code:e.error.code,message:e.error.message,data:e.error.data}),i.reject(ha(e.error))):e.result===void 0?(this.log.warn("downstream response missing both result and error",{id:e.id,method:i.method}),i.reject(new T("AGENT_PROTOCOL_ERROR",`${i.method} response missing both result and error`))):(this.log.info("downstream returned result",{id:e.id,method:i.method,result:qf(e.result)}),i.resolve(e.result));return}if(ga(e)){if(e.method==="session/update"){for(let i of this.pending.values())i.armFrameIdle?.();for(let i of this.updateHandlers)try{Promise.resolve(i(e.params)).catch(o=>this.log.warn("update handler failed (async)",{err:String(o)}))}catch(o){this.log.warn("update handler threw sync, swallowed",{err:String(o)})}}else this.log.info("unknown notification (drop, not forwarded)",{method:e.method});return}if(la(e)){let i=e;try{this.handleAgentRequest(i).catch(o=>this.log.error("agent request handler failed (async)",{method:i.method,err:String(o)}))}catch(o){this.log.warn("handleAgentRequest threw sync, swallowed",{method:i.method,err:String(o)})}}}async handleAgentRequest(e){if(this.agentRequestHandlers.length===0){this.writeFrame(pt(e.id,{code:-32601,message:`method not handled by Bridge: ${e.method}`}));return}this.inflightAgentRequests.set(e.id,e.method);for(let i of this.agentRequestHandlers)try{await i(e)}catch(o){this.log.error("agentRequestHandler threw",{method:e.method,err:String(o)});try{this.writeFrame(pt(e.id,yn(o)))}catch{}this.inflightAgentRequests.delete(e.id)}}failAllPending(e){for(let i of this.pending.values())i.timer&&clearTimeout(i.timer),i.frameIdleTimer&&clearTimeout(i.frameIdleTimer),i.reject(e);this.pending.clear(),this.inflightAgentRequests.clear()}};var Hf="@agentclientprotocol/claude-agent-acp@latest";function Gf(n){let e={};for(let[i,o]of Object.entries(n))o!==void 0&&(i.startsWith("CLAUDE")||i==="AI_AGENT"||i==="BAGGAGE"||(e[i]=o));return e}var cr=class extends Je{framework="claude-code";constructor(e){let i=zt("claude-code"),[o,a]=i?[i,[]]:["npx",["-y",Hf]],c=e.command??o,u=e.args??a,x={command:c,args:u,cwd:e.cwd,...e.env?{env:e.env}:{}};super(x)}sanitizeEnv(e){return Gf(e)}};import{mkdtempSync as jf,rmSync as Kf}from"node:fs";import{tmpdir as Wf}from"node:os";import{join as $f}from"node:path";var Jf="@zed-industries/codex-acp@latest",dr=class extends Je{framework="codex";authMethodId;codexHomeDir;constructor(e){let i=zt("codex"),[o,a]=i?[i,[]]:["npx",["-y",Jf]],c=e.command??o,u=e.args??a,x=e.extraArgs?[...u,...e.extraArgs]:u,l=e.isolateCodexHome?jf($f(Wf(),"coze-bridge-codex-home-")):void 0,g=l?{...e.env??{},CODEX_HOME:l}:e.env,E={command:c,args:x,cwd:e.cwd,...g?{env:g}:{}};super(E),this.authMethodId=e.authMethodId,this.codexHomeDir=l}async initialize(e){let i=await super.initialize(e);return this.authMethodId&&await this.call("authenticate",{methodId:this.authMethodId}),i}async stop(e){if(await super.stop(e),this.codexHomeDir)try{Kf(this.codexHomeDir,{recursive:!0,force:!0})}catch{}}};var Vf=3e4,Jt=class extends Je{framework="openclaw";agentId;sessionName;slashModelOnStart;constructor(e){let i=e.sessionName??"default",o=["acp","--session",`agent:${e.agentId}:${i}`];e.gatewayToken&&o.push("--token",e.gatewayToken);let a={command:e.command,args:o,cwd:e.cwd,...e.env?{env:e.env}:{}};super(a),this.agentId=e.agentId,this.sessionName=i,this.slashModelOnStart=e.slashModelOnStart}async afterSessionEstablished(e){this.slashModelOnStart&&(this.log.info("switching session to per-session provider via /model",{agentId:this.agentId,sessionName:this.sessionName,slash:this.slashModelOnStart}),await this.sessionPrompt({sessionId:e,prompt:[{type:"text",text:`/model ${this.slashModelOnStart}`}]},Vf))}get acpSessionName(){return this.sessionName}};Z();ye();function Mi(n){return n.replace(/[^A-Za-z0-9._-]+/g,"-")}var Vt=class{slots=[];running=!1;closed=!1;disposed=!1;enqueue(e){return this.disposed?Promise.reject(new Error("AsyncQueue disposed")):this.closed?Promise.reject(new Error("AsyncQueue closed")):new Promise((i,o)=>{this.slots.push({task:e,resolve:i,reject:o}),this.drain()})}close(){this.closed=!0}dispose(e=new Error("AsyncQueue disposed")){for(this.disposed=!0,this.closed=!0;this.slots.length>0;)this.slots.shift()?.reject(e)}get size(){return this.slots.length}get isRunning(){return this.running}get isDisposed(){return this.disposed}async drain(){if(!this.running){this.running=!0;try{for(;this.slots.length>0&&!this.disposed;){let e=this.slots.shift();if(!e)break;try{let i=await e.task();e.resolve(i)}catch(i){e.reject(i)}}}finally{this.running=!1}}}};var ur=class{agentId;framework;workspace;deployType;accountId;patToken;modelInfo;sessions=new Map;sessionQueues=new Map;activeTriggers=new Map;activeGroupIds=new Map;status="ok";model;lastActiveAt=Date.now();constructor(e){this.agentId=e.agentId,this.framework=e.framework,this.workspace=e.workspace,this.model=e.model,this.deployType=e.deployType??"local",e.accountId&&(this.accountId=e.accountId),e.patToken&&(this.patToken=e.patToken),e.modelInfo&&(this.modelInfo=e.modelInfo)}setPatToken(e){this.patToken=e}setModelInfo(e){this.modelInfo=e}getSessionQueue(e){let i=this.sessionQueues.get(e);return(!i||i.isDisposed)&&(i=new Vt,this.sessionQueues.set(e,i)),i}allSessionQueues(){return this.sessionQueues.entries()}hasSessionQueue(e){let i=this.sessionQueues.get(e);return!!i&&!i.isDisposed}async dispose(e){this.status="stopped";let i=new Error(`AgentSession disposed${e?`: ${e}`:""}`);for(let o of this.sessionQueues.values())o.dispose(i);this.sessionQueues.clear(),await this.killAllRuntimes(e??"dispose")}async killAllRuntimes(e){let i=[];for(let[,o]of this.sessions)En(o),o.downstream&&(i.push(o.downstream.stop(e).catch(()=>{})),o.downstream=void 0);await Promise.all(i),this.activeTriggers.clear(),this.activeGroupIds.clear()}};function En(n){n.idleTimer&&(clearTimeout(n.idleTimer),n.idleTimer=void 0)}import{spawn as Zf}from"node:child_process";import{homedir as Yf}from"node:os";import{join as Xf}from"node:path";jn();Z();async function Sa(){let n=Xf(Yf(),".openclaw/openclaw.json");return(await Ft(n))?.gateway?.auth?.token??""}var ba=q("openclaw.config"),Qf=[0,5e3,5e3],va="models.providers.",fr="agents.defaults.models",xr=class{command;env;retryDelaysMs;queue=new Vt;constructor(e){this.command=e.command,this.env=e.env??process.env,this.retryDelaysMs=e.retryDelaysMs??Qf}async withRetry(e,i){let o;for(let a=0;a<this.retryDelaysMs.length;a++){let c=this.retryDelaysMs[a]??0;c>0&&await new Promise(u=>setTimeout(u,c));try{return await i()}catch(u){o=u,ba.warn("openclaw cli failed, will retry",{label:e,attempt:a+1,err:String(u)})}}throw new T("AGENT_SPAWN_FAILED",`openclaw cli ${e} failed after ${this.retryDelaysMs.length} attempts: ${o?.message??"unknown"}`)}runCli(e){return new Promise((i,o)=>{let a=Zf(this.command,e,{stdio:["ignore","pipe","pipe"],env:this.env}),c="";a.stderr?.on("data",u=>{c+=u.toString("utf8")}),a.on("error",o),a.on("close",u=>{u===0?i():o(new Error(`exit ${u}: ${c.trim().slice(0,500)}`))})})}async runCliTolerant(e,i){try{await this.runCli(e)}catch(o){let a=String(o);if(i.some(c=>a.includes(c)))return;throw o}}async bestEffortUnset(e,i){try{await this.queue.enqueue(()=>this.withRetry(e,()=>this.runCli(["config","unset",i])))}catch(o){ba.warn(`${e} failed (best-effort)`,{configPath:i,err:String(o)})}}ensureProvider(e,i){return this.queue.enqueue(()=>this.withRetry(`config set models.providers.${e}`,()=>this.runCli(["config","set",`${va}${e}`,JSON.stringify(i),"--strict-json","--merge"])))}removeProvider(e){return this.bestEffortUnset(`config unset models.providers.${e}`,`${va}${e}`)}addModelToAllowlist(e,i){let o={[e]:i?{alias:i}:{}};return this.queue.enqueue(()=>this.withRetry(`config set ${fr}[${e}]`,()=>this.runCli(["config","set",fr,JSON.stringify(o),"--strict-json","--merge"])))}removeModelFromAllowlist(e){return this.bestEffortUnset(`config unset ${fr}[${e}]`,`${fr}.${e}`)}ensureAgent(e,i,o){let a=["agents","add",e,"--workspace",i,"--non-interactive"];return o&&a.push("--model",o),this.queue.enqueue(()=>this.withRetry(`agents add ${e}`,()=>this.runCliTolerant(a,["already exists","already registered"])))}deleteAgent(e){return this.queue.enqueue(()=>this.withRetry(`agents delete ${e}`,()=>this.runCliTolerant(["agents","delete",e,"--force"],["not found","does not exist"])))}};var De=q("agent-manager"),tx=(n,e,i,o,a,c,u,x)=>{switch(n){case"claude-code":{let l={...a?{...ea(a),...ra(a,u)}:{},...x??{},IS_SANDBOX:"1"};return new cr({cwd:i,env:l})}case"codex":{let g=[...a?[...ta(a),...sa(a,u)]:[],"-c",'sandbox_mode="danger-full-access"',"-c",'approval_policy="never"'],E={...a?na(a):{},...x??{}},w=!!a;return new dr({cwd:i,...g.length>0?{extraArgs:g}:{},...Object.keys(E).length>0?{env:E}:{},...w?{authMethodId:"openai-api-key",isolateCodexHome:!0}:{}})}case"openclaw":return new Jt({command:e,cwd:i,agentId:o,...c?{sessionName:Mi(c)}:{}})}};function zi(n){return n==="claude-code"||n==="codex"}var nx={path:"",version:"cloud-deployed"},rx={protocolVersion:1,clientCapabilities:{fs:{readTextFile:!0,writeTextFile:!0}}},ix=6e4,sx=mt("COZE_BRIDGE_SPAWN_AWAIT_INSTALL_MS",25e3),lr=class{paths;config;registry;factory;createTimeoutMs;spawnAwaitInstallMs;openclawConfigCache;ensuredProviders=new Set;constructor(e){this.paths=e.paths,this.config=e.config,this.registry=e.registry,this.factory=e.downstreamFactory??tx,this.createTimeoutMs=e.createTimeoutMs??ix,this.spawnAwaitInstallMs=e.spawnAwaitInstallMs??sx}buildBinShimPathEnv(){let e=process.platform==="win32"?";":":";return{PATH:`${this.paths.binDir}${e}${process.env.PATH??""}`}}getOpenclawConfig(){if(!this.openclawConfigCache){let e=this.config.frameworksCache?.openclaw;if(!e?.path)throw new T("AGENT_SPAWN_FAILED","openclaw binary not detected on this machine");this.openclawConfigCache=new xr({command:e.path})}return this.openclawConfigCache}async createAgent(e){if(!e.agentId)throw new T("IPC_BAD_REQUEST","agentId required");if(!e.framework)throw new T("IPC_BAD_REQUEST","framework required");let i=xn(e._meta)==="cloud";this.registry.reviveIfDisconnected?.(e.agentId);let o=this.registry.get(e.agentId);if(o){if(o.framework!==e.framework)throw new T("AGENT_BUSY",`agent ${e.agentId} exists with different framework (${o.framework})`);if(o.status==="error")De.warn("existing agent in error state, rebuilding",{agentId:e.agentId}),await o.dispose("rebuild after error").catch(b=>De.warn("dispose stale agent failed (ignored)",{err:String(b)})),this.registry.unregister(e.agentId);else{if(e.patToken&&e.patToken!==o.patToken){De.info("updating agent patToken on re-create (reconnect with new PAT)",{agentId:e.agentId}),o.setPatToken(e.patToken);let b=await Te(e.agentId,this.paths).catch(()=>null);b&&(b.patToken=e.patToken,await Ne(b,this.paths))}if(o.deployType==="cloud"&&e.modelInfo){De.info("updating agent modelInfo on re-create",{agentId:e.agentId}),o.setModelInfo(e.modelInfo);let b=await Te(e.agentId,this.paths).catch(()=>null);b&&(b.modelInfo=e.modelInfo,await Ne(b,this.paths))}return De.info("agent already exists, return current",{agentId:e.agentId}),{ok:!0,agentId:o.agentId,workspace:o.workspace,framework:o.framework}}}if(!i&&!this.config.frameworksCache?.[e.framework])throw new T("AGENT_SPAWN_FAILED",`framework ${e.framework} not detected on this machine; rerun daemon to refresh frameworks_cache`);let c=rt(e.agentId,this.paths),u=xn(e._meta),x=e.framework==="openclaw"&&u==="local",l=x?this.config.frameworksCache?.openclaw?.defaultAgent?.workspace:void 0,g=e.workspace??l??c.workspace,E=new AbortController,w=setTimeout(()=>E.abort(new T("AGENT_TIMEOUT",`_agent/create timed out after ${this.createTimeoutMs}ms`)),this.createTimeoutMs),A,_=!1;try{i&&zi(e.framework)&&await Bt(e.framework,E.signal);let b=()=>{if(E.signal.aborted)throw E.signal.reason instanceof Error?E.signal.reason:new T("AGENT_TIMEOUT","_agent/create aborted")};await Bi(c.root,{recursive:!0}),await Bi(g,{recursive:!0}),await Bi(c.logs,{recursive:!0}),b(),x||await Ut(g,e.framework,e.agentId,e.cozeIdentity),e.framework==="claude-code"&&await uo(g),b();let S=await Te(e.agentId,this.paths).catch(()=>null),I=Xo({model:e.model??S?.model}),k=jo(e._meta)??S?.accountId,L=e.patToken??S?.patToken,m=u==="cloud"?e.modelInfo??S?.modelInfo:void 0;if(A=new ur({agentId:e.agentId,framework:e.framework,workspace:g,model:I.model??Ke,deployType:u,...k?{accountId:k}:{},...L?{patToken:L}:{},...m?{modelInfo:m}:{}}),A.status="ok",S?.sessions){for(let[z,$]of Object.entries(S.sessions))A.sessions.set(z,{acpSessionId:$.acpSessionId,modelToken:$.modelToken,tokenGeneratedAt:$.tokenGeneratedAt,lastActiveAt:Date.now(),loadingSession:!1,replySeq:0});let F=Object.keys(S.sessions).length;F>0&&De.info("restored persisted session records (no spawn)",{agentId:e.agentId,count:F})}this.registry.register(A),_=!0;let C={agentId:e.agentId,framework:e.framework,workspace:g,cozeIdentity:e.cozeIdentity,createdAt:S?.createdAt??Date.now(),sessions:S?.sessions??{},model:I.model};u==="cloud"&&(C.deployType="cloud"),k&&(C.accountId=k),L&&(C.patToken=L),m&&(C.modelInfo=m),S?.skills&&(C.skills=S.skills),S?.agentName&&(C.agentName=S.agentName),S?.description&&(C.description=S.description),e.framework==="openclaw"&&u==="cloud"&&(this.config.frameworksCache?.openclaw?.path?await this.getOpenclawConfig().ensureAgent(e.agentId,g):De.warn("openclaw binary not on this machine, skip agents add (will fail at session/prompt)",{agentId:e.agentId}));let R=e.initialSkills??[];if(R.length>0){let F=[...C.skills??[]],z=new Map(F.map((N,B)=>[N.skillId,B])),$=await Promise.allSettled(R.map(N=>Ni({agentId:e.agentId,workspace:g,framework:e.framework,skill:N}))),J=0;for(let[N,B]of $.entries()){let j=R[N];j&&(B.status==="fulfilled"?(Li(F,z,B.value),J++):De.warn("initialSkill install failed (skipping)",{agentId:e.agentId,skillId:j.skillId,skillName:j.skillName,err:String(B.reason)}))}J>0&&(C.skills=F,De.info("initialSkills installed",{agentId:e.agentId,installed:J,requested:R.length}))}return await Ne(C,this.paths),De.info("agent created (no spawn, lazy on first prompt)",{agentId:e.agentId,framework:e.framework,deployType:u}),{ok:!0,agentId:e.agentId,workspace:g,framework:e.framework}}catch(b){throw De.error("agent create failed, rolling back",{agentId:e.agentId,err:String(b)}),_&&A&&(await A.dispose("rollback").catch(()=>{}),this.registry.unregister(e.agentId)),await ex(c.root,{recursive:!0,force:!0}).catch(S=>De.warn("rm agent dir failed (ignored)",{err:String(S)})),b instanceof T?b:new T("AGENT_SPAWN_FAILED",String(b),{cause:b})}finally{clearTimeout(w)}}async spawnSessionDownstream(e,i,o,a){let u=this.config.frameworksCache?.[e.framework];if(!u)if(e.deployType==="cloud"&&zi(e.framework))u=nx;else throw new T("AGENT_SPAWN_FAILED",`framework ${e.framework} not detected on this machine`);if(zi(e.framework)&&!zt(e.framework)){let g=Xs(e.framework);g&&(De.info("spawn: awaiting in-flight acp install (D92)",{agentId:e.agentId,framework:e.framework}),await Promise.race([g.catch(()=>{}),new Promise(E=>setTimeout(E,this.spawnAwaitInstallMs))]))}let x=e.deployType==="cloud"?{model:e.model,modelToken:i,...e.modelInfo?{modelInfo:e.modelInfo}:{}}:void 0,l;e.framework==="openclaw"?l=await this.buildOpenclawDownstream({session:e,modelConfig:x,cloudSessionId:o,cozeEnv:a,command:u.path}):l=this.factory(e.framework,u.path,e.workspace,e.agentId,x,o,a,this.buildBinShimPathEnv());try{return await l.start(),await l.initialize(rx),l}catch(g){let E=l instanceof Je?l.getStderrTail():[];E.length>0&&De.warn("spawnSessionDownstream failed, recent stderr (D94)",{agentId:e.agentId,framework:e.framework,method:g instanceof T?g.code:"unknown",recentStderr:E});let w=Oi(E);await l.stop("spawnSessionDownstream failed").catch(()=>{});let A=w?new T("NPX_CACHE_CORRUPT","~/.npm/_npx \u76EE\u5F55\u635F\u574F (ENOTEMPTY)\u3002\u5EFA\u8BAE: rm -rf ~/.npm/_npx && npm i -g @zed-industries/codex-acp (\u6216\u5BF9\u5E94 @agentclientprotocol/claude-agent-acp)",{cause:g}):g;throw g instanceof T?new T(g.code,g.message,{retriable:g.retriable,cause:A}):new T("AGENT_SPAWN_FAILED",g instanceof Error?g.message:String(g),{cause:A})}}async buildOpenclawDownstream(e){let{session:i,modelConfig:o,cloudSessionId:a,cozeEnv:c,command:u}=e,x=Mi(a);if(i.deployType==="local"){let w=this.config.frameworksCache?.openclaw?.defaultAgent;if(!w?.id||!w.workspace)throw new T("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 Jt({command:u,cwd:w.workspace,agentId:w.id,sessionName:x})}let l=await Sa(),g=o?ia(o,c):null,E;if(g){let w=Ai(a),_=g.models[0]?.id??Ke,b=`${w}/${_}`;if(!this.ensuredProviders.has(b)){let S=this.getOpenclawConfig();await S.ensureProvider(w,g),await S.addModelToAllowlist(b),this.ensuredProviders.add(b)}E=b}return new Jt({command:u,cwd:i.workspace,agentId:i.agentId,sessionName:x,...l?{gatewayToken:l}:{},...E?{slashModelOnStart:E}:{}})}async openclawRepair(e,i){let o=this.getOpenclawConfig();await o.deleteAgent(e),await o.ensureAgent(e,i)}async cleanupOpenclawSessionProviders(e){if(e.framework!=="openclaw"||!this.openclawConfigCache)return;let i=this.openclawConfigCache;for(let o of e.sessions.keys()){let a=Ai(o),c=`${a}/${e.model}`,u=!0;try{await i.removeProvider(a)}catch(x){u=!1,De.warn("removeProvider failed, keeping ensuredProviders entry",{providerId:a,err:String(x)})}try{await i.removeModelFromAllowlist(c)}catch(x){u=!1,De.warn("removeModelFromAllowlist failed, keeping ensuredProviders entry",{fullModelId:c,err:String(x)})}u&&this.ensuredProviders.delete(c)}}};import{randomUUID as Da}from"node:crypto";import{promises as px}from"node:fs";import{basename as Pa}from"node:path";import{promises as ax}from"node:fs";import{basename as cx}from"node:path";Z();var Ia=q("file-upload"),dx="/api/coze_claw/file/agent_upload",ux=6e4;async function Aa(n,e={}){let o=`${er(nr(e.handshakeBase))}${dx}`,a=e.timeoutMs??ux,c=await ax.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([c],{type:n.mimeType}),n.name);let x={Authorization:`Bearer ${n.patToken}`,Accept:"application/json","x-coze-version":"3.0",...Kt(e.ppeOverride),...n.accountId?{"x-coze-account":n.accountId}:{}},l=new AbortController,g=setTimeout(()=>l.abort(),a);Ia.info("file upload start",{url:o,agentId:n.agentId,sessionId:n.sessionId,name:n.name,bytes:n.sizeBytes,mime:n.mimeType});try{let E=await fetch(o,{method:"POST",headers:x,body:u,signal:l.signal}),w=E.headers.get("x-tt-logid")??"";if(!E.ok){let b=await E.text().catch(()=>"");throw new T("UPLOAD_FAILED",`upload HTTP ${E.status} logid=${w}: ${b.slice(0,200)}`)}let A=await E.json();if(A.code!==void 0&&A.code!==0)throw new T("UPLOAD_FAILED",`upload code=${A.code} msg=${A.msg??"-"} logid=${w}`);let _=A.data?.file?.file_url;if(!_)throw new T("UPLOAD_FAILED",`upload response missing data.file.file_url logid=${w}: ${JSON.stringify(A).slice(0,200)}`);return Ia.info("file upload ok",{uri:_,logid:w}),{uri:_}}catch(E){throw E instanceof T?E:E.name==="AbortError"?new T("UPLOAD_FAILED",`upload timeout (${a}ms) for ${cx(n.path)}`):new T("UPLOAD_FAILED",String(E),{cause:E})}finally{clearTimeout(g)}}Z();import{promises as fx}from"node:fs";import{extname as xx}from"node:path";var lx=[{mime:"image/png",prefix:[137,80,78,71]},{mime:"image/jpeg",prefix:[255,216,255]},{mime:"image/gif",prefix:[71,73,70,56]},{mime:"application/pdf",prefix:[37,80,68,70]}];function gx(n){return n[0]===82&&n[1]===73&&n[2]===70&&n[3]===70&&n[8]===87&&n[9]===69&&n[10]===66&&n[11]===80}var hx={".txt":"text/plain",".md":"text/markdown",".svg":"image/svg+xml",".json":"application/json"};async function Ca(n){let e=await fx.open(n,"r");try{let i=Buffer.alloc(16);if(await e.read(i,0,16,0),gx(i))return"image/webp";for(let o of lx)if(o.prefix.every((a,c)=>i[c]===a))return o.mime}finally{await e.close()}return hx[xx(n).toLowerCase()]??"application/octet-stream"}ye();var gr=q("agent-send"),Ta=50*1024*1024,mx=new Set(["image/png","image/jpeg","image/webp","image/gif","image/svg+xml","application/pdf","application/json","text/plain","text/markdown"]);function ka(n,e,i){let o=n.get(e);if(!o)throw new T("AGENT_NOT_FOUND",`agent=${e}`);if(n.disconnectedAgents.has(e))throw new T("AGENT_DISCONNECTED",`agent=${e} was disconnected by cloud`);let a=o.sessions.get(i);if(!a)throw new T("AGENT_NOT_FOUND",`session=${i} not active in agent=${e}`);return{session:o,runtime:a}}async function Ra(n,e,i,o,a,c){let x;for(let l=0;l<=2;l++)try{await n.core.sendAgentFileUpdate(e,i,o,a);return}catch(g){x=g,l<2&&(gr.warn("sendAgentFileUpdate failed, retrying",{attempt:l+1,err:String(g)}),await new Promise(E=>setTimeout(E,5e3)))}throw new T("UPSTREAM_NOT_READY",`${c} after 3 attempts: ${String(x)}`,{cause:x})}async function Na(n,e){let{session:i,runtime:o}=ka(e.core,n.agentId,n.sessionId);if(!await so(n.path,i.workspace))throw new T("PATH_OUTSIDE_WORKSPACE",`path=${n.path} not under workspace=${i.workspace}`);let a=await px.stat(n.path).catch(()=>null);if(!a||!a.isFile())throw new T("IPC_BAD_REQUEST",`path is not a regular file: ${n.path}`);if(a.size>Ta)throw new T("FILE_TOO_LARGE",`${a.size} bytes > limit ${Ta}`);let c=await Ca(n.path);if(!mx.has(c))throw new T("UNSUPPORTED_MIME",`mime=${c} not in whitelist`);if(n.kind==="image"&&!c.startsWith("image/"))throw new T("UNSUPPORTED_MIME",`kind=image but mime=${c}`);if(!e.core.upstream.isConnected())throw new T("UPSTREAM_NOT_READY","cloud WS not connected");let u=n.name??Pa(n.path),x;try{x=await Aa({patToken:i.patToken??e.patToken,agentId:n.agentId,sessionId:n.sessionId,path:n.path,mimeType:c,name:u,sizeBytes:a.size,...i.accountId?{accountId:i.accountId}:{}},{handshakeBase:e.handshakeBase,ppeOverride:e.ppeOverride})}catch(g){throw gr.warn("agent file upload failed",{agentId:n.agentId,sessionId:n.sessionId,path:n.path,sizeBytes:a.size,mime:c,code:g instanceof T?g.code:"UNKNOWN",message:g instanceof Error?g.message:String(g)}),g}let l={sessionUpdate:"agent_file",messageId:Da(),content:{type:n.kind==="image"?"image":"resource",uri:x.uri,mimeType:c,name:u,sizeBytes:a.size,...x.fileId!==void 0?{fileId:x.fileId}:{},...n.caption!==void 0?{caption:n.caption}:{}}};return await Ra(e,i,o,n.sessionId,l,"agent file uploaded to cloud but sendAgentFileUpdate failed"),gr.info("agent file sent",{agentId:n.agentId,sessionId:n.sessionId,kind:n.kind,name:u,bytes:a.size,mime:c,uri:x.uri}),{ok:!0,uri:x.uri,bytes:a.size,mimeType:c,...x.fileId!==void 0?{fileId:x.fileId}:{}}}async function La(n,e){let{session:i,runtime:o}=ka(e.core,n.agentId,n.sessionId);if(!n.mimeType)throw new T("IPC_BAD_REQUEST","group-file requires mimeType");if(!e.core.upstream.isConnected())throw new T("UPSTREAM_NOT_READY","cloud WS not connected");let a=n.name??Pa(n.path),c={sessionUpdate:"group_file",messageId:Da(),content:{uri:n.path,name:a,mimeType:n.mimeType,...n.caption!==void 0?{caption:n.caption}:{}}};return await Ra(e,i,o,n.sessionId,c,"agent group file sendAgentFileUpdate failed"),gr.info("agent group file sent",{agentId:n.agentId,sessionId:n.sessionId,uri:n.path,name:a,mime:n.mimeType}),{ok:!0,uri:n.path,bytes:0,mimeType:n.mimeType}}import{execFile as _x}from"node:child_process";import{promisify as yx}from"node:util";function hr(n,e){let i=n.split(".").map(Number),o=e.split(".").map(Number),a=Math.max(i.length,o.length);for(let c=0;c<a;c++){let u=i[c]??0,x=o[c]??0;if(u<x)return!0;if(u>x)return!1}return!1}Z();var Ex=yx(_x),Ve=q("coze-cli-installer"),Oa="@coze/cli@latest",bx="coze",Ma="0.1.7",vx=5e3,Sx=5e3,Ix=9e4,Ba=1e4,bn=null,pr=!1;async function Fi(n,e={}){if(pr)return;if(bn)return bn;let i=e.exec??Ex;return bn=(async()=>{try{let o=await Ax(bx,i),a=!1;if(o){let u=await Cx(i);if(u===void 0)Ve.warn("coze-cli found but version unparseable, fall through to full install",{path:o});else if(hr(u,Ma))Ve.info("coze-cli version too old, upgrade-only (preserve user config + auth)",{path:o,version:u,min:Ma}),a=!0;else{Ve.info("coze-cli already on PATH with sufficient version, skip",{path:o,version:u}),pr=!0;return}}let c=a?"upgrade-only":"full";Ve.info("coze-cli install start",{package:Oa,mode:c});try{await i("npm",["i","-g","--prefer-online",Oa],{timeout:Ix,maxBuffer:10*1024*1024}),Ve.info("coze-cli install ok")}catch(u){Ve.warn("coze-cli install failed (skip subsequent steps)",{err:String(u)});return}if(a){pr=!0;return}if(n.env)try{await i("coze",["config","set","xTTEnv",n.env],{timeout:Ba}),Ve.info("coze config set xTTEnv ok",{env:n.env})}catch(u){Ve.warn("coze config set failed (continue to auth login)",{err:String(u)})}try{await i("coze",["auth","login","--token",n.patToken],{timeout:Ba}),Ve.info("coze auth login ok")}catch(u){Ve.warn("coze auth login failed",{err:String(u)});return}pr=!0}finally{bn=null}})(),bn}async function Ax(n,e){let i=process.platform==="win32"?"where":"which";try{let{stdout:o}=await e(i,[n],{timeout:vx});return o.split(`
120
+ `)[0]?.trim()||void 0}catch{return}}async function Cx(n){try{let{stdout:e,stderr:i}=await n("coze",["--version"],{timeout:Sx});return(e||i).match(/(\d+\.\d+\.\d+)/)?.[1]}catch{return}}Z();import{spawn as Tx}from"node:child_process";import{constants as za,access as Dx}from"node:fs/promises";import{delimiter as Px,join as kx}from"node:path";var Fa=q("framework-detector"),Ua={"claude-code":"claude",codex:"codex",openclaw:"openclaw"},Rx=[".exe",".cmd",".bat",".ps1"],Zt=class{env;constructor(e={}){this.env={pathEnv:e.pathEnv??process.env.PATH??"",platform:e.platform??process.platform,spawn:e.spawn??Tx,access:e.access??Dx}}async detect(e){let i=Ua[e],o=await this.which(i);if(!o)return Fa.debug("framework binary not found",{framework:e,bin:i}),null;let a=e==="openclaw"?["--log-level","silent"]:[],[c,u]=await Promise.all([this.probeVersion(o,a),e==="openclaw"?this.probeOpenclawDefaultAgent(o):Promise.resolve(null)]),x={path:o,version:c};return u&&(x.defaultAgent=u),x}async detectAll(){let e=await Promise.all(Object.keys(Ua).map(async o=>[o,await this.detect(o)])),i={};for(let[o,a]of e)a&&(i[o]=a);return i}async which(e){let i=this.env.pathEnv.split(Px).filter(Boolean),o=this.env.platform==="win32"?["",...Rx]:[""];for(let a of i)for(let c of o){let u=kx(a,e+c);if(await this.isExecutable(u))return u}return null}async isExecutable(e){try{let i=this.env.platform==="win32"?za.F_OK:za.X_OK;return await this.env.access(e,i),!0}catch{return!1}}async probeOpenclawDefaultAgent(e){let i=await this.runProbe(e,["--log-level","silent","agents","list","--json"]);if(!i||i.code!==0)return null;let o=i.stdout.match(/\[\s*\{[\s\S]*\}\s*\]/);if(!o)return null;try{let a=JSON.parse(o[0]);if(!Array.isArray(a))return null;let c=a.find(u=>u?.isDefault===!0);return!c?.id||!c.workspace?null:{id:c.id,workspace:c.workspace}}catch(a){return Fa.warn("openclaw agents list --json parse failed",{err:String(a)}),null}}async probeVersion(e,i=[]){let o=await this.runProbe(e,[...i,"--version"]);return o&&(Lx(o.stdout).split(/\r?\n/)[0]??"").trim()||"unknown"}runProbe(e,i){return new Promise(o=>{let a="",c=!1,u,x=l=>{c||(c=!0,u&&clearTimeout(u),o(l))};try{let l=this.env.spawn(e,i,{stdio:["ignore","pipe","pipe"]});u=setTimeout(()=>{l.kill("SIGKILL"),x(null)},5e3),l.stdout?.on("data",g=>{a+=g.toString("utf8")}),l.on("error",()=>x(null)),l.on("close",g=>x({code:g,stdout:a}))}catch{x(null)}})}},Nx=new RegExp("\x1B\\[[0-9;]*[A-Za-z]","g");function Lx(n){return n.replace(Nx,"")}Yt();import{randomBytes as Qx}from"node:crypto";import{createReadStream as Mx}from"node:fs";import{mkdir as Bx,readFile as zx,realpath as Fx,stat as Ux,writeFile as qx}from"node:fs/promises";import{basename as Hx,dirname as Ui,join as Gx,relative as jx,resolve as Ha,sep as Kx}from"node:path";import{createInterface as Wx}from"node:readline";Z();var ja=q("fs-rpc"),vn=mt("COZE_BRIDGE_FS_RPC_MAX_BYTES",20*1024*1024);async function Ka(n,e){let i=Buffer.byteLength(n.content,"utf8");if(i>vn)throw new T("IPC_BAD_REQUEST",`fs/write_text_file content too large: ${i} bytes > limit ${vn} bytes`);let o=await $a(n.path,e);return await Bx(Ui(o),{recursive:!0}),await qx(o,n.content,"utf8"),ja.info("fs/write_text_file ok",{path:o,size:n.content.length}),null}async function Wa(n,e){let i=await $a(n.path,e),o=await Ux(i),a=typeof n.line=="number"||typeof n.limit=="number";if(o.size>vn&&!a)throw new T("IPC_BAD_REQUEST",`fs/read_text_file too large without line/limit slicing: ${o.size} bytes > ${vn} bytes`);let c;if(a&&o.size>vn)c=await $x(i,n.line??1,n.limit);else{let u=await zx(i,"utf8");if(a){let x=u.split(`
121
+ `),l=Math.max(0,(n.line??1)-1),g=typeof n.limit=="number"?l+n.limit:void 0;c=x.slice(l,g).join(`
122
+ `)}else c=u}return ja.info("fs/read_text_file ok",{path:i,size:c.length}),{content:c}}async function $x(n,e,i){let o=Wx({input:Mx(n,{encoding:"utf8"}),crlfDelay:Number.POSITIVE_INFINITY}),a=Math.max(0,e-1),c=typeof i=="number"?a+i:Number.POSITIVE_INFINITY,u=[],x=0;try{for await(let l of o)if(x>=a&&x<c&&u.push(l),x++,x>=c)break}finally{o.close()}return u.join(`
123
+ `)}async function $a(n,e){if(typeof n!="string"||n.length===0)throw new T("IPC_BAD_REQUEST","path must be a non-empty string");let[i,o]=await Promise.all([Ga(Ha(e)),Ga(Ha(n))]),a=jx(i,o);if(a.startsWith("..")||a===".."||a.startsWith(`..${Kx}`))throw new T("IPC_BAD_REQUEST",`path escapes workspace: ${n}`);return o}async function Ga(n){let e=[],i=n;for(;i!==Ui(i);)try{let o=await Fx(i);return e.length?Gx(o,...e.reverse()):o}catch{e.push(Hx(i)),i=Ui(i)}return n}Z();var Ja=q("prompt-multimodal"),Va=10*1024*1024,Jx=15e3,Vx=6;async function Za(n){let e=new Array(n.length),i=0;async function o(){for(;i<n.length;){let c=i++,u=n[c];u!==void 0&&(e[c]=await Zx(u))}}let a=Array.from({length:Math.min(Vx,n.length)},()=>o());return await Promise.all(a),e}function Ya(n){return n.some(e=>e.type==="image")}async function Zx(n){if(n.type!=="image")return n;let e=n;if(e.data||!e.uri||!Qn(e.uri))return n;try{let{buf:i,contentType:o}=await Xx(e.uri),a=e.mimeType||Yx(o)||"application/octet-stream";return Ja.info("image uri fetched and inlined",{uri:e.uri,bytes:i.length,mimeType:a}),{type:"image",data:i.toString("base64"),mimeType:a}}catch(i){return Ja.warn("image fetch failed, degrading to text block",{uri:e.uri,err:String(i)}),{type:"text",text:`[image load failed: ${e.uri}]`}}}function Yx(n){if(!n)return;let e=n.indexOf(";");return(e===-1?n:n.slice(0,e)).trim()||void 0}async function Xx(n){let e=new AbortController,i=setTimeout(()=>e.abort(),Jx);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>Va)throw new Error(`image too large: ${a.byteLength} bytes (max ${Va})`);return{buf:Buffer.from(a),contentType:o.headers.get("content-type")??void 0}}finally{clearTimeout(i)}}lt();Yt();Z();var V=q("core"),el=3e4,tl=/^(boe|ppe)_[A-Za-z0-9_-]+$/,nl=3e4,rl=new Set(["_agent/create","session/new","session/load","session/prompt"]),mr=class{upstream;agents=new Map;disconnectedAgents=new Set;extensions;paths;sessionSpawner;sessionIdleTimeoutMs;upgradeGate;upstreamIds=new $t;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=qa(e.bridgeConfig),this.upgradeGate=e.upgradeGate}registerExtension(e,i){this.extensions[e]=i}getCozeEnv(){return this.currentCozeEnv}async start(){this.upstream.onFrame(e=>this.handleFrame(e)),this.upstream.onConnect?.(({initial:e})=>{e||this.rejectAllPendingOnReconnect()}),await this.upstream.start(),V.info("Core started",{extensions:Object.keys(this.extensions)})}async stop(e){V.info("Core stopping",{reason:e}),await Promise.all([...this.agents.values()].map(i=>i.dispose(e))),this.agents.clear(),await this.upstream.stop(e)}get(e){return this.agents.get(e)}register(e){this.agents.set(e.agentId,e),V.info("agent registered",{agentId:e.agentId,framework:e.framework});for(let i of this.registerHandlers)try{i(e.agentId)}catch(o){V.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)&&V.info("agent revived from disconnect",{agentId:e})}attachRuntimeHooks(e,i,o){let a=o.downstream;a&&(a.onUpdate(c=>{o.loadingSession||this.forwardUpdate(e,c)}),a.onAgentRequest(c=>{this.handleAgentRequest(e,a,c)}),a.onExit((c,u)=>{V.info("session runtime exited",{agentId:e.agentId,cloudId:i,code:c,signal:u}),En(o),o.downstream=void 0,o.replySeq=0,o.acpSessionId&&e.activeTriggers.delete(o.acpSessionId),this.rejectPendingForDownstream(a,"downstream exited")}))}hasPendingPermissionFor(e){for(let i of this.pendingUpstream.values())if(i.downstream===e)return!0;return!1}rejectPendingForDownstream(e,i){let o=[];for(let[a,c]of this.pendingUpstream)c.downstream===e&&o.push(a);if(o.length!==0){V.info("reject pendingUpstream entries (downstream gone)",{reason:i,count:o.length});for(let a of o){let c=this.pendingUpstream.get(a);if(c){this.pendingUpstream.delete(a),this.upstream.send(pt(a,{code:X.INTERNAL_ERROR,message:`bridge downstream gone: ${i}`})).catch(u=>V.debug("send error response to upstream failed (ignored)",{err:String(u)}));try{c.downstream.respondAgentRequestError(c.agentRequestId,{code:X.INTERNAL_ERROR,message:`bridge: ${i}`})}catch{}}}}}rejectAllPendingOnReconnect(){let e=this.pendingUpstream.size,i=this.pendingBridge.size;if(!(e===0&&i===0)){V.warn("upstream reconnected, rejecting stale pending requests",{pendingUpstream:e,pendingBridge:i});for(let[,o]of this.pendingUpstream)try{o.downstream.respondAgentRequestError(o.agentRequestId,{code:X.INTERNAL_ERROR,message:"upstream reconnected; please retry"})}catch{}this.pendingUpstream.clear();for(let[,o]of this.pendingBridge)clearTimeout(o.timer),o.reject(new T("UPSTREAM_DISCONNECTED",`${o.method} aborted: upstream reconnected`));this.pendingBridge.clear()}}async handleFrame(e){if(or(e)){this.handleUpstreamResponse(e);return}if(!("method"in e)||typeof e.method!="string")return;let i="id"in e&&e.id!==void 0?e.id:null,o=e.params?._meta?.cozeEnv;o&&tl.test(o)?this.currentCozeEnv=o:o&&V.warn("rejecting cozeEnv with invalid shape, keeping previous",{rejected:o});try{if(this.upgradeGate?.isUpgrading()&&rl.has(e.method)){let a=this.upgradeGate.pendingTarget()??"";throw new T("BRIDGE_UPGRADING",`bridge upgrading to ${a}, retry shortly`,{retriable:!0})}if(e.method.startsWith("_agent/")){let a=this.extensions[e.method];if(!a){i!==null?await this.sendError(i,X.METHOD_NOT_FOUND,`extension not registered: ${e.method}`):V.warn("drop notification: extension not registered",{method:e.method});return}let c=await a(e,this);i!==null&&await this.upstream.send(Wt(i,c));return}if(e.method.startsWith("session/")){let a=await this.routeSessionMethod(e);i!==null&&await this.upstream.send(Wt(i,a));return}if(e.method==="initialize"){i!==null&&await this.upstream.send(Wt(i,{protocolVersion:1,agentCapabilities:{loadSession:!0}}));return}i!==null?await this.sendError(i,X.METHOD_NOT_FOUND,`method not implemented: ${e.method}`):V.warn("drop unknown notification",{method:e.method})}catch(a){V.error("handleFrame failed",{method:e.method,err:String(a)}),i!==null&&await this.upstream.send(pt(i,yn(a)))}}async routeSessionMethod(e){if(!e.params||typeof e.params!="object")throw new T("IPC_BAD_REQUEST",`${e.method} requires params`);let i=e.params,o=i._meta?.cozeAgentId;if(!o)throw new T("IPC_BAD_REQUEST",`${e.method}: missing _meta.cozeAgentId`);let a=this.agents.get(o);if(!a)throw this.disconnectedAgents.has(o)?new T("AGENT_DISCONNECTED",`agent ${o} has been disconnected; cloud must _agent/create to revive`):new T("AGENT_NOT_FOUND",`agent not found: ${o}`);let c=typeof i.sessionId=="string"?i.sessionId:void 0;if(e.method==="session/cancel"||e.method==="session/new"||!c)return this.dispatchSessionCall(a,e.method,i);let u=Date.now(),x=!1,l=e.method==="session/prompt";l&&this.upgradeGate?.incActive();try{let g=await a.getSessionQueue(c).enqueue(()=>this.dispatchSessionCall(a,e.method,i));return x=!0,g}finally{l&&this.upgradeGate?.decActive(),V.info("session call done",{agentId:a.agentId,method:e.method,durationMs:Date.now()-u,ok:x})}}async dispatchSessionCall(e,i,o){e.lastActiveAt=Date.now();let{stripped:a}=Wo(o);switch(i){case"session/new":{let c=il();return V.info("session/new ack (lazy spawn)",{agentId:e.agentId,cloudId:c}),{sessionId:c}}case"session/load":{let c=a;return V.info("session/load ack (lazy spawn)",{agentId:e.agentId,cloudId:c.sessionId}),{}}case"session/prompt":{let c=a,u=c.sessionId;if(!u)throw new T("IPC_BAD_REQUEST","session/prompt: missing sessionId");let x=await this.ensureRuntime(e,u);if(x.replySeq=0,await this.ensureDownstream(e,u,x),!x.downstream||!x.acpSessionId)throw new T("BRIDGE_INTERNAL","session runtime not ready after ensureDownstream");let l=o._meta?.cozeTriggerMsgId;l?e.activeTriggers.set(x.acpSessionId,l):e.activeTriggers.delete(x.acpSessionId);let g=Ko(o._meta);if(g?e.activeGroupIds.set(x.acpSessionId,g):e.activeGroupIds.delete(x.acpSessionId),e.deployType==="cloud"&&e.modelInfo?.capabilities?.image===!1&&Ya(c.prompt))throw new T("MODEL_MODALITY_UNSUPPORTED",`model=${e.modelInfo.id??e.model} does not support image input`);let E=await Za(c.prompt);try{let w=await x.downstream.sessionPrompt({...c,sessionId:x.acpSessionId,prompt:E});return x.lastActiveAt=Date.now(),w}finally{if(e.activeTriggers.delete(x.acpSessionId),e.activeGroupIds.delete(x.acpSessionId),x.reloadAfterTurn){x.reloadAfterTurn=!1;let w=x.downstream;w&&(x.downstream=void 0,V.info("reloadAfterTurn: stopping downstream",{agentId:e.agentId,cloudId:u,acpId:x.acpSessionId}),w.stop("reload-after-turn").catch(A=>V.warn("reload-after-turn stop failed (ignored)",{agentId:e.agentId,cloudId:u,err:String(A)})))}else x.downstream?.isAlive()&&this.armIdleTimer(e,u,x)}}case"session/cancel":{let u=a.sessionId;if(!u)throw new T("IPC_BAD_REQUEST","session/cancel: missing sessionId");let x=e.sessions.get(u);if(e.hasSessionQueue(u)){let l=e.getSessionQueue(u);l.size>0&&(V.info("session/cancel: draining queued tasks",{agentId:e.agentId,cloudId:u,queuedCount:l.size}),l.dispose(new T("AGENT_PROTOCOL_ERROR",`cancelled by session/cancel on ${u}`)))}return x?.downstream?.isAlive()&&x.acpSessionId&&await x.downstream.sessionCancel({sessionId:x.acpSessionId}),{ok:!0}}default:throw new T("IPC_BAD_REQUEST",`session method not supported: ${i}`)}}async ensureRuntime(e,i){let o=e.sessions.get(i);if(o)return o;let c={modelToken:e.deployType==="cloud"?await this.requestSessionToken(e.agentId,i):"",tokenGeneratedAt:Date.now(),lastActiveAt:Date.now(),loadingSession:!1,replySeq:0};return e.sessions.set(i,c),await this.persistSessionMapping(e),c}async requestSessionToken(e,i){let o={sessionId:i,_meta:{cozeAgentId:e}};try{let a=await this.sendRequest(je.GEN_MODEL_TOKEN,o,nl);if(!a?.modelToken)throw new T("MODEL_TOKEN_GEN_FAILED",`cloud returned empty modelToken (agentId=${e}, cloudSessionId=${i})`);return a.modelToken}catch(a){throw a instanceof T&&a.code==="MODEL_TOKEN_GEN_FAILED"?a:new T("MODEL_TOKEN_GEN_FAILED",a instanceof Error?a.message:String(a),{cause:a})}}async ensureDownstream(e,i,o){if(En(o),o.downstream?.isAlive())return;if(!this.sessionSpawner)throw new T("AGENT_SPAWN_FAILED","sessionSpawner not wired (cannot spawn per-session downstream)");let a=3,c=3e4,u=o.spawnFailCount??0,x=o.spawnFailedAt??0;if(u>=a&&Date.now()-x<c)throw new T("AGENT_SPAWN_FAILED",`agent ${e.agentId} session ${i} spawn failed ${u} times in a row; please check framework binary / network and retry after ${Math.ceil((c-(Date.now()-x))/1e3)}s`);let l;try{l=await this.sessionSpawner(e,o.modelToken,i,this.currentCozeEnv)}catch(g){throw o.spawnFailCount=u+1,o.spawnFailedAt=Date.now(),o.spawnFailCount>=a&&o.acpSessionId&&(V.warn("clearing stale acpSessionId after repeated spawn failures",{agentId:e.agentId,cloudId:i,staleAcpId:o.acpSessionId}),o.acpSessionId=void 0),g}if(o.spawnFailCount=0,o.spawnFailedAt=void 0,o.downstream=l,this.attachRuntimeHooks(e,i,o),o.acpSessionId){o.loadingSession=!0;try{await l.sessionLoad({sessionId:o.acpSessionId,cwd:e.workspace}),V.info("session restored via session/load",{agentId:e.agentId,cloudId:i,acpId:o.acpSessionId})}catch(g){V.warn("session/load failed, fallback to session/new",{agentId:e.agentId,cloudId:i,acpId:o.acpSessionId,err:String(g)}),o.acpSessionId=void 0;let E=await l.sessionNew({cwd:e.workspace});o.acpSessionId=E.sessionId,await this.persistSessionMapping(e)}finally{o.loadingSession=!1}}else{let g=await l.sessionNew({cwd:e.workspace});o.acpSessionId=g.sessionId,await this.persistSessionMapping(e)}l.afterSessionEstablished&&o.acpSessionId&&await l.afterSessionEstablished(o.acpSessionId)}armIdleTimer(e,i,o){if(En(o),this.isRuntimeBusy(e,o)){V.debug("skip idle timer: runtime busy (in-flight turn / pending permission)",{agentId:e.agentId,cloudId:i});return}o.idleTimer=setTimeout(()=>{if(o.idleTimer=void 0,this.isRuntimeBusy(e,o)){V.info("idle reaper fired but runtime busy, re-arming",{agentId:e.agentId,cloudId:i}),this.armIdleTimer(e,i,o);return}V.info("session runtime idle timeout, killing downstream",{agentId:e.agentId,cloudId:i});let a=o.downstream;o.downstream=void 0,o.acpSessionId&&e.activeTriggers.delete(o.acpSessionId),a&&a.stop("idle timeout").catch(c=>V.warn("idle stop failed (ignored)",{agentId:e.agentId,cloudId:i,err:String(c)}))},this.sessionIdleTimeoutMs),o.idleTimer.unref?.()}isRuntimeBusy(e,i){if(i.acpSessionId&&e.activeTriggers.has(i.acpSessionId))return!0;let o=i.downstream;if(!o)return!1;for(let a of this.pendingUpstream.values())if(a.downstream===o)return!0;return!1}async sendAgentFileUpdate(e,i,o,a){let c={cozeAgentId:e.agentId,cozeReplySeqID:++i.replySeq};if(i.acpSessionId){let u=e.activeTriggers.get(i.acpSessionId);u&&(c.cozeTriggerMsgId=u);let x=e.activeGroupIds.get(i.acpSessionId);x&&(c.cozeGroupId=x)}await this.upstream.send(wn("session/update",{sessionId:o,update:a,_meta:c}))}forwardUpdate(e,i){let o=i.sessionId,a=this.reverseSessionId(e,o);if(!a){V.debug("drop update for unknown session",{agentId:e.agentId,acpId:o});return}let c=e.sessions.get(a);if(!c){V.debug("drop update: runtime gone",{agentId:e.agentId,cloudId:a});return}if(ol(i)){V.debug("drop codex metadata-warn chunk",{agentId:e.agentId,acpId:o});return}let u={cozeAgentId:e.agentId,cozeReplySeqID:++c.replySeq},x=e.activeTriggers.get(o);x&&(u.cozeTriggerMsgId=x);let l=e.activeGroupIds.get(o);l&&(u.cozeGroupId=l),this.upstream.send(wn("session/update",{...i,sessionId:a,_meta:u})).catch(g=>V.warn("forward update failed",{agentId:e.agentId,err:String(g)}))}handleAgentRequest(e,i,o){if(o.method==="session/request_permission"){this.forwardPermissionRequest(e,i,o);return}if(o.method==="fs/write_text_file"||o.method==="fs/read_text_file"){this.handleFsRpcRequest(e,i,o);return}V.warn("unhandled agent request,returning method_not_found",{agentId:e.agentId,method:o.method}),i.respondAgentRequestError(o.id,{code:X.METHOD_NOT_FOUND,message:`method not handled by Bridge: ${o.method}`})}async handleFsRpcRequest(e,i,o){try{let a=e.workspace;if(o.method==="fs/write_text_file"){let c=o.params??{},u=await Ka(c,a);i.respondAgentRequest(o.id,u)}else{let c=o.params??{},u=await Wa(c,a);i.respondAgentRequest(o.id,u)}}catch(a){V.warn("fs rpc handler failed",{agentId:e.agentId,method:o.method,err:String(a)}),i.respondAgentRequestError(o.id,yn(a))}}forwardPermissionRequest(e,i,o){let a=this.upstreamIds.next("session/request_permission"),c=o.params??{},x=c.sessionId,l=x?e.activeTriggers.get(x):void 0,g={cozeAgentId:e.agentId};l&&(g.cozeTriggerMsgId=l);let E=x?e.activeGroupIds.get(x):void 0;E&&(g.cozeGroupId=E);let w=x?this.reverseSessionId(e,x):void 0,A={...c,...w?{sessionId:w}:{},_meta:g};this.pendingUpstream.set(a,{agentRequestId:o.id,agentId:e.agentId,downstream:i,method:o.method}),V.info("forward permission_request \u2192 upstream",{agentId:e.agentId,upstreamId:a,acpSessionId:x,cloudSessionId:w,toolCallId:c.toolCall?.toolCallId,options:c.options?.map(_=>({optionId:_.optionId,kind:_.kind,name:_.name}))}),this.upstream.send(mn(a,"session/request_permission",A)).catch(_=>{this.pendingUpstream.delete(a),V.error("forward permission request failed",{agentId:e.agentId,err:String(_)}),i.respondAgentRequestError(o.id,{code:X.INTERNAL_ERROR,message:`upstream send failed: ${String(_)}`})})}handleUpstreamResponse(e){if(e.id===null)return;let i=this.lookupPending(this.pendingUpstream,e.id,"upstream");if(i){this.pendingUpstream.delete(i.key);let a=i.value;e.error?(V.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"&&sl(e.result,a),V.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 sr(e.error)):o.value.resolve(e.result);return}V.debug("orphan upstream response (no pending)",{id:e.id})}lookupPending(e,i,o){let a=e.get(i);if(a)return{value:a,key:i};if(typeof i=="number"){let c=String(i),u=e.get(c);if(u)return V.warn(`${o} id type mismatch: number received but Bridge expected string`,{rawId:i,normalizedId:c}),{value:u,key:c}}}sendRequest(e,i,o=el){let a=this.upstreamIds.next(e);return new Promise((c,u)=>{let x=setTimeout(()=>{this.pendingBridge.delete(a),u(new T("AGENT_TIMEOUT",`${e} timed out after ${o}ms`))},o);this.pendingBridge.set(a,{method:e,resolve:c,reject:u,timer:x}),this.upstream.send(mn(a,e,i)).catch(l=>{let g=this.pendingBridge.get(a);g&&(clearTimeout(g.timer),this.pendingBridge.delete(a)),u(l)})})}async persistSessionMapping(e){if(this.paths)try{let i=new Map;for(let[o,a]of e.sessions){let c={modelToken:a.modelToken,tokenGeneratedAt:a.tokenGeneratedAt};a.acpSessionId&&(c.acpSessionId=a.acpSessionId),i.set(o,c)}await pi(e.agentId,i,this.paths)}catch(i){V.warn("persist session mapping failed",{agentId:e.agentId,err:String(i)})}}reverseSessionId(e,i){for(let[o,a]of e.sessions.entries())if(a.acpSessionId===i)return o}sendError(e,i,o){return this.upstream.send(pt(e,{code:i,message:o,data:{bridgeVersion:ht}}))}};function il(){return Qx(16).toString("hex")}function sl(n,e){if(!n||typeof n!="object"){V.warn("permission response: result not an object (suspicious)",{agentId:e.agentId,result:n});return}let i=n;if("kind"in i&&!("outcome"in i)){V.warn('permission response: top-level "kind" field (D66 historical bug shape)',{agentId:e.agentId,result:n});return}let o=i.outcome;if(!o||typeof o!="object"){V.warn("permission response: missing or non-object outcome field",{agentId:e.agentId,result:n});return}let c=o.outcome;(typeof c!="string"||c!=="selected"&&c!=="cancelled")&&V.warn("permission response: unknown outcome discriminant",{agentId:e.agentId,outcomeValue:c,result:n})}function ol(n){let e=n.update;if(e?.sessionUpdate!=="agent_message_chunk")return!1;let i=e.content;if(!i||typeof i!="object")return!1;let o=i;return o.type!=="text"||typeof o.text!="string"?!1:o.text.startsWith("Model metadata for `")}Z();ye();import{randomBytes as al}from"node:crypto";import{chmod as cl,mkdir as dl,writeFile as Xa}from"node:fs/promises";import{createServer as ul}from"node:http";import{dirname as fl}from"node:path";var xl=1e6,qi=q("ipc"),wr=class{server=null;port=0;token="";routes;paths;constructor(e){this.routes=new Map(e.routes.map(i=>[`${i.method} ${i.path}`,i])),this.paths=e.paths??Y()}async start(){this.token=al(32).toString("hex");let e=ul((o,a)=>{this.dispatch(o,a)});this.server=e,await new Promise((o,a)=>{e.once("error",a),e.listen(0,"127.0.0.1",()=>o())});let i=e.address();if(!i||typeof i!="object")throw new Error("failed to obtain IPC port");return this.port=i.port,await this.persistAuthFiles(),qi.info("IPC listening",{port:this.port}),{port:this.port,token:this.token}}async stop(){let e=this.server;e&&(await new Promise((i,o)=>{e.close(a=>a?o(a):i())}),this.server=null)}async persistAuthFiles(){await dl(fl(this.paths.portFile),{recursive:!0}),await Xa(this.paths.portFile,String(this.port),"utf8"),await Xa(this.paths.tokenFile,this.token,{encoding:"utf8",mode:384});try{await cl(this.paths.tokenFile,384)}catch(e){qi.warn("chmod token file failed (non-POSIX?)",{err:String(e)})}}async dispatch(e,i){if(e.headers.authorization!==`Bearer ${this.token}`){Sn(i,401,{error:"unauthorized"});return}let a=`${e.method} ${(e.url??"").split("?")[0]}`,c=this.routes.get(a);if(!c){Sn(i,404,{error:"not found"});return}let u=null;if(e.method==="POST")try{u=await ll(e)}catch(x){Sn(i,400,{error:"invalid json",detail:String(x)});return}try{let x=await c.handler(u,e);Sn(i,200,x??{ok:!0})}catch(x){qi.error("IPC handler failed",{key:a,err:String(x)}),Sn(i,500,{error:x instanceof Error?x.message:String(x)})}}};function Sn(n,e,i){n.statusCode=e,n.setHeader("content-type","application/json"),n.end(JSON.stringify(i))}async function ll(n){let e=[],i=0;for await(let a of n){let c=a;if(i+=c.length,i>xl)throw new Error("body too large");e.push(c)}let o=Buffer.concat(e).toString("utf8");return o?JSON.parse(o):null}import{sep as Qa}from"node:path";import{fileURLToPath as gl}from"node:url";function ec(){return hl(gl(import.meta.url))}function hl(n){let e=`${Qa}src${Qa}`;return n.includes(e)}Z();ye();import{spawn as pl}from"node:child_process";import{existsSync as ml,mkdirSync as wl,openSync as _l}from"node:fs";import{dirname as yl}from"node:path";import{fileURLToPath as El}from"node:url";var bl=q("spawn-helper");function vl(n){return ml(n.libEntry)?n.libEntry:El(new URL("../index.ts",import.meta.url))}function Sl(n,e,i){let o=n.endsWith(".ts"),a=["--upgrade-helper",`--target-version=${e}`,`--old-pid=${i}`];return o?["--import","tsx/esm",n,...a]:[n,...a]}async function tc(n,e,i={}){let o=i.paths??Y(),a=vl(o);wl(yl(o.logFile),{recursive:!0});let c=_l(o.logFile,"a"),u=Sl(a,n,e),x=pl(process.execPath,u,{detached:!0,stdio:["ignore",c,c],env:{...process.env,COZE_BRIDGE_UPGRADE_HELPER:"1"}});if(x.unref(),typeof x.pid!="number")throw new Error("failed to spawn upgrade helper (no pid)");bl.info("upgrade helper spawned",{pid:x.pid,targetVersion:n,oldPid:e,entry:a})}Z();import{mkdir as Il,writeFile as Al}from"node:fs/promises";import{dirname as Cl}from"node:path";import{gunzipSync as Tl}from"node:zlib";var Hi=q("tarball-downloader"),Dl="https://registry.npmjs.org",nc="package/dist/index.js";async function rc(n,e,i={}){if(!/^[\w.\-+]+$/.test(n))throw new Error(`invalid version string: ${JSON.stringify(n)}`);let a=`${(i.registry??Dl).replace(/\/+$/,"")}/coze-bridge/${n}`;Hi.info("fetching tarball metadata",{metaUrl:a});let c=await fetch(a);if(!c.ok)throw new Error(`registry metadata ${a} returned ${c.status}`);let x=(await c.json())?.dist?.tarball;if(!x)throw new Error(`registry metadata missing dist.tarball for ${n}`);Hi.info("downloading tarball",{tarballUrl:x});let l=await fetch(x);if(!l.ok)throw new Error(`tarball ${x} returned ${l.status}`);let g=Buffer.from(await l.arrayBuffer()),E=Tl(g),w=Pl(E,nc);if(!w)throw new Error(`tarball missing entry ${nc}`);await Il(Cl(e),{recursive:!0}),await Al(e,w),Hi.info("dist extracted",{destPath:e,bytes:w.length})}function Pl(n,e){let i=0;for(;i+512<=n.length;){let o=n.subarray(i,i+512);if(o.every(E=>E===0))return null;let a=o.subarray(0,100),c=a.indexOf(0),u=a.subarray(0,c===-1?100:c).toString("utf8"),x=o.subarray(124,136).toString("ascii").trim().replace(/\0/g,""),l=Number.parseInt(x,8)||0,g=i+512;if(u===e)return n.subarray(g,g+l);i=g+Math.ceil(l/512)*512}return null}Yt();Z();import{resolve as kl}from"node:path";var It=q("upgrade-manager"),Rl=300*1e3,Nl=3,_r=class{constructor(e){this.opts=e}opts;inFlightTarget=null;async requestUpgrade(e){if(this.inFlightTarget===e){It.debug("upgrade already in-flight, skip",{targetVersion:e});return}this.inFlightTarget=e;try{let i=await wt(this.opts.paths.configFile)??{};if(i.disableAutoUpgrade){It.info("disableAutoUpgrade=true, skip",{targetVersion:e});return}if(this.opts.isDevMode()){It.warn("dev mode, skip auto-upgrade",{targetVersion:e});return}if(!hr(this.opts.currentVersion,e)){It.debug("local version >= target, skip",{local:this.opts.currentVersion,target:e});return}let o=i.upgradeAttempts?.[e];if((o?.count??0)>=Nl){It.warn("upgrade attempts cap reached, skip",{targetVersion:e,count:o?.count});return}let a=kl(this.opts.paths.libDir,"index.js.next");try{await this.opts.download(e,a)}catch(u){await this.recordAttempt(i,e,String(u)),It.warn("download failed, attempt recorded",{targetVersion:e,err:String(u)});return}this.opts.daemon.markUpgradePending(e);let c=await this.opts.daemon.waitIdle(Rl);It.info("waitIdle done",{result:c}),await this.opts.spawnHelper(e,process.pid),this.opts.daemon.exit(0)}finally{this.inFlightTarget=null}}async recordAttempt(e,i,o){e.upgradeAttempts=e.upgradeAttempts??{};let a=e.upgradeAttempts[i];e.upgradeAttempts[i]={count:(a?.count??0)+1,lastAt:Date.now(),...o?{lastError:o}:{}},await Ze(e,this.opts.paths.configFile)}};var I0=Ge(gc(),1);var lh=Ge(d0(),1),gh=Ge(Or(),1),hh=Ge(en(),1),ph=Ge(ts(),1),mh=Ge(is(),1),wh=Ge(us(),1),w0=Ge(Fr(),1),_h=Ge(m0(),1);var _0=w0.default;Z();var be=q("upstream.frontier"),E0="application/json",b0="none",Eh=15e3,Nn=class{constructor(e){this.opts=e}opts;fws=null;handler=null;connectHandlers=[];opened=!1;lastSendRefusedLogAt=0;sendRefusedSuppressed=0;openCount=0;async start(){if(this.fws){be.warn("start called on already-started FrontierUpstream; noop");return}let e={Authorization:`Bearer ${this.opts.privatecode}`,Origin:Vo,...Kt(this.opts.ppeOverride)};class i extends _0{constructor(b){super(b,Jo,{headers:e})}send(b,...S){if(Vs("debug"))try{let I;typeof b=="string"?I=Buffer.from(b,"utf8"):b instanceof Buffer?I=b:b instanceof ArrayBuffer?I=new Uint8Array(b):ArrayBuffer.isView(b)?I=new Uint8Array(b.buffer,b.byteOffset,b.byteLength):I=new Uint8Array(0);let k=Buffer.from(I.slice(0,128)).toString("hex");be.debug("WS raw frame out",{bytes:I.byteLength,headHex:k})}catch(I){be.warn("WS raw frame dump failed",{err:String(I)})}super.send(b,...S)}}let o=Yo(this.opts.urlOverride),a={url:o,ws:i,fpID:$o,aID:tr,accessKey:this.opts.handshake.accessKey,deviceID:this.opts.handshake.deviceId,payloadType:{type:E0,force:!0},payloadEncoding:{encoding:b0,force:!0},enableTransformTextPayload:!0,enableQoS:!1,enableAutoAck:!1,automaticOpen:!1,maxRetries:Number.POSITIVE_INFINITY,debug:this.opts.debug??!1},c=new I0.FWS(a),u=!1,x=null,l,g,E=new Promise((_,b)=>{l=_,g=b}),w=_=>{u||(u=!0,x&&(clearTimeout(x),x=null),_?g(_):l())};c.onopen=()=>{this.opened=!0,this.openCount+=1;let _=this.openCount===1;be.info("frontier opened",{url:o,remoteDeviceId:this.opts.handshake.deviceId,initial:_,openCount:this.openCount}),_&&w();for(let b of this.connectHandlers)Promise.resolve(b({initial:_})).catch(S=>be.warn("onConnect handler threw (ignored)",{err:String(S)}))},c.onclose=_=>{this.opened=!1,be.info("frontier closed",{code:_.code,reason:_.reason,willReconnect:_.willReconnect})},c.onerror=_=>{be.warn("frontier error",{code:_.code,msg:_.message}),w(new T("UPSTREAM_DISCONNECTED",`frontier connect error before open: code=${_.code} msg=${_.message??""}`))},c.onmessage=_=>this.handleMessage(_),this.fws=c;let A=this.opts.openTimeoutMs??Eh;x=setTimeout(()=>{w(new T("UPSTREAM_DISCONNECTED",`frontier ws open timeout after ${A}ms (handshake or upgrade slow)`))},A),await c.connect();try{await E}catch(_){try{c.close(1e3,"open failed")}catch(b){be.warn("fws close during start failure threw (ignored)",{err:String(b)})}throw this.fws=null,this.opened=!1,_}}async stop(e){let i=this.fws;if(i){this.fws=null,this.opened=!1;try{i.close(1e3,e??"bridge shutdown")}catch(o){be.warn("frontier close threw (ignored)",{err:String(o)})}}}async send(e){let i=this.fws,o=e.method;if(!i)throw be.warn("frontier send refused: upstream not started",{method:o}),new T("UPSTREAM_DISCONNECTED","frontier upstream not started");if(!this.isConnected()){let x=Date.now();throw x-this.lastSendRefusedLogAt>1e3?(be.warn("frontier send refused: ws not open",{method:o,opened:this.opened,readyState:i.readyState,...this.sendRefusedSuppressed>0?{suppressedSinceLast:this.sendRefusedSuppressed}:{}}),this.lastSendRefusedLogAt=x,this.sendRefusedSuppressed=0):this.sendRefusedSuppressed+=1,new T("UPSTREAM_DISCONNECTED",`frontier ws not open (opened=${this.opened}, readyState=${i.readyState}); refusing to silently buffer`)}this.injectAgentPatToken(e);let a=JSON.stringify(e),c=e;v0(c)||be.info("frontier frame out",{method:c.method,jsonrpcId:c.id,size:a.length});try{await i.send(a,{service:33555712,method:1,payloadType:E0,payloadEncoding:b0})}catch(x){throw be.warn("frontier frame send failed",{method:c.method,jsonrpcId:c.id,err:String(x)}),new T("UPSTREAM_DISCONNECTED",`frontier send failed: ${String(x)}`,{cause:x})}}onFrame(e){this.handler=e}onConnect(e){this.connectHandlers.push(e)}isConnected(){return this.opened&&this.fws?.readyState===1}injectAgentPatToken(e){let i=this.opts.getPatTokenForAgent;if(!i)return;let o=e.params?._meta;if(!o?.cozeAgentId)return;let a=i(o.cozeAgentId);a&&(o.cozePatToken=a)}handleMessage(e){let i=e.message?.service;if(i!==33555712){be.debug("drop non-adapter frontier frame",{service:i});return}let o=Sh(e);if(!o){be.debug("frontier message without text payload, drop",{payloadType:e.message?.payloadType});return}if(!this.handler){be.debug("frame received but no onFrame handler",{size:o.length});return}let a;try{a=JSON.parse(o)}catch(u){be.warn("frontier message JSON parse failed",{err:String(u),head:o.slice(0,80)});return}let c=a;v0(c)||be.info("frontier frame in",{logid:vh(e.message?.LogID),logidNew:e.message?.LogIDNew,msgId:e.message?.msgID,jsonrpcId:c.id,method:c.method,body:bh(o)}),Promise.resolve(this.handler(a)).catch(u=>be.warn("frontier frame handler threw",{err:String(u)}))}};function v0(n){return n.method==="_agent/health"?!0:typeof n.id=="string"&&n.id.startsWith("agent.health_")}var S0=2e3;function bh(n){return n.length<=S0?n:`${n.slice(0,S0)}...<truncated, total ${n.length} chars>`}function vh(n){return n?n.high===0?String(n.low>>>0):`${n.high.toString(16)}${(n.low>>>0).toString(16).padStart(8,"0")}`:""}function Sh(n){let e=n.message;if(e?.textPayload)return e.textPayload;let i=e?.payload;if(!i)return null;try{return Buffer.from(i).toString("utf8")}catch{return null}}Z();var xs=q("upstream.switchable"),qr=class{inner;handler=null;connectHandlers=[];constructor(e){this.inner=e}async swap(e,i){if(this.inner===e)return;xs.info("swap upstream",{reason:i});let o=this.inner;if(this.inner=e,this.handler&&e.onFrame(this.handler),e.onConnect)for(let a of this.connectHandlers)e.onConnect(a);try{await e.start()}catch(a){throw xs.error("swap target start failed, reverting",{err:String(a)}),this.inner=o,a}await o.stop(i??"swapped").catch(a=>xs.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()}};Z();var ls=q("upstream"),an=class{handler=null;async start(){ls.info("NoopUpstream started (M1 skeleton; real Frontier wired in M4)")}async stop(e){ls.info("NoopUpstream stopped",{reason:e})}async send(e){ls.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)}};Z();Z();ye();import{promises as gs}from"node:fs";import{dirname as Ih}from"node:path";var Ah=q("pat-token-store");async function A0(n=Y()){try{let i=(await gs.readFile(n.patTokenFile,"utf8")).trim();return i.length>0?i:null}catch(e){let i=e?.code;return i!=="ENOENT"&&Ah.warn("read pat-token failed (treating as missing)",{path:n.patTokenFile,code:i,message:e.message}),null}}async function Ln(n,e=Y()){if(!n)throw new Error("writePatToken: empty patToken");await gs.mkdir(Ih(e.patTokenFile),{recursive:!0}),await gs.writeFile(e.patTokenFile,n,{encoding:"utf8",mode:384})}ye();ye();import{promises as Hr}from"node:fs";import{join as Ch}from"node:path";function Th(n){return`#!/bin/sh
124
124
  exec node ${JSON.stringify(n)} "$@"
125
- `}function ng(n){return`@echo off
125
+ `}function Dh(n){return`@echo off
126
126
  node ${JSON.stringify(n)} %*
127
- `}async function bc(n,e=G()){let s=e.binDir;await br.mkdir(s,{recursive:!0});let o=eg(s,process.platform==="win32"?"coze-bridge.cmd":"coze-bridge"),a=process.platform==="win32"?ng(n):tg(n);return await br.readFile(o,"utf8").catch(()=>null)===a||(await br.writeFile(o,a,"utf8"),process.platform!=="win32"&&await br.chmod(o,493)),s}q();oe();import{execSync as Sc}from"node:child_process";import{readFileSync as Ec,unlinkSync as rg}from"node:fs";import{mkdir as ig,readFile as Ac,unlink as Ic,writeFile as sg}from"node:fs/promises";import{dirname as og}from"node:path";function vc(n){try{return process.kill(n,0),!0}catch(e){return e.code==="EPERM"}}var ag=D("single-instance"),vr=class{pidFile;acquired=!1;constructor(e={}){this.pidFile=e.pidFile??G().pidFile,e.processTitle&&(process.title=e.processTitle)}async acquire(){let e=await this.readExistingPid();return e!==null&&this.isAlive(e)?{kind:"already-running",pid:e}:(e!==null&&(ag.warn("removing stale pid file",{stalePid:e}),await Ic(this.pidFile).catch(()=>{})),await ig(og(this.pidFile),{recursive:!0}),await sg(this.pidFile,String(process.pid),"utf8"),this.acquired=!0,this.installCleanupHooks(),{kind:"acquired"})}async release(){if(this.acquired){try{(await Ac(this.pidFile,"utf8")).trim()===String(process.pid)&&await Ic(this.pidFile)}catch{}this.acquired=!1}}async readExistingPid(){try{let e=await Ac(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 vc(e)?this.matchesDaemonTitle(e):!1}matchesDaemonTitle(e){if(process.platform==="win32")return this.matchesDaemonTitleWindows(e);try{let s=Ec(`/proc/${e}/cmdline`,"utf8").replace(/\0/g," ");return!!(s.includes("coze-bridge-daemon")||s.includes("lib/index.js"))}catch{}try{let s=Sc(`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=Sc(`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{Ec(this.pidFile,"utf8").trim()===String(process.pid)&&rg(this.pidFile)}catch{}})}};function cg(){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"),xg="coze-bridge-daemon";async function Pc(){let n=new vr({processTitle:xg}),e=await n.acquire();if(e.kind==="already-running")throw new Error(`coze-bridge daemon already running (pid=${e.pid})`);let s=await ct(),o=s??{};Sn({pid:process.pid}),N.info(s?"loaded bridge config":"initialized bridge config");try{let T=new Mt;o.frameworksCache=await T.detectAll(),N.info("refreshed frameworks_cache",{detected:Object.keys(o.frameworksCache)})}catch(T){N.warn("framework detection failed",{err:String(T)})}await Ue(o);let a=new yr(new Wt),d=G(),u=cg(),f=null,p=new Xn({upstream:a,paths:d,bridgeConfig:o,upgradeGate:u,sessionSpawner:async(T,O,F,ye)=>{if(!f)throw new Error("agentManager not ready");return f.spawnSessionDownstream(T,O,F,ye)}});await ug(d,p);let h=new $n({paths:d,config:o,registry:p});f=h;let y,w,A=null,I={},E,k=null,L=null;p.registerExtension("_agent/create",async T=>h.createAgent(T.params)),p.registerExtension("_agent/health",async()=>({ok:!0}));let $={},H=new Bn({agents:p.agents,disposeAndMarkDisconnected:async(T,O)=>{let F=p.agents.get(T);if(F){await h.cleanupOpenclawSessionProviders(F).catch(te=>N.warn("cleanup openclaw providers failed (ignored)",{agentId:T,err:String(te)}));let ye=!0;try{await F.dispose(`disconnect: ${O}`)}catch(te){ye=!1,N.error("dispose during disconnect FAILED, leaving agent in error state",{agentId:T,err:String(te)}),F.status="error"}ye&&(F.status="disconnected",p.unregister(T),p.disconnectedAgents.add(T))}else p.disconnectedAgents.add(T)},detailSyncer:async T=>{if(!$.ref)throw new Error("agent-detail-sync not initialized yet");await $.ref.syncOne(T)},cleanupOpenclawProviders:async T=>{await h.cleanupOpenclawSessionProviders(T)},openclawRepair:async(T,O)=>{await h.openclawRepair(T,O)},isRuntimePendingPermission:T=>p.hasPendingPermissionFor(T)});p.registerExtension("_agent/listSkills",T=>H.listSkills(T.params)),p.registerExtension("_agent/addSkills",T=>H.addSkills(T.params)),p.registerExtension("_agent/removeSkills",T=>H.removeSkills(T.params)),p.registerExtension("_agent/getFileTree",T=>H.getFileTree(T.params)),p.registerExtension("_agent/getFileContent",T=>H.getFileContent(T.params)),p.registerExtension("_agent/update",T=>H.updateAgent(T.params)),p.registerExtension("_agent/disconnect",T=>H.disconnectAgent(T.params)),p.registerExtension("_agent/switchModel",T=>H.switchModel(T.params)),p.registerExtension("_agent/reset",T=>H.resetAgent(T.params)),p.registerExtension("_agent/repair",T=>H.repairAgent(T.params));let ae=new Rn({paths:d,handlers:H,sendDetail:T=>p.sendRequest("_agent/detail",T)});$.ref=ae;let W=async T=>{await Promise.allSettled(T.map(async O=>{try{await H.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:T})=>{N.info("frontier upstream connected, triggering detail sync",{initial:T}),ae.syncAll(T?"initial-connect":"reconnect").catch(O=>N.warn("detail sync top-level error (ignored)",{err:String(O)}))});let ge=new Yn({paths:d,routes:[{method:"GET",path:"/status",handler:async()=>({running:!0,pid:process.pid,agents:[...p.agents.keys()],deviceId:A??"",frameworksCache:o.frameworksCache??{}})},{method:"POST",path:"/pair",handler:async T=>{let O=T,F=O?.privatecode,ye=O?.pairing_code;if(!F||!ye)throw new b("IPC_BAD_REQUEST","/pair requires privatecode + pairing_code");let te=Yt(O.env),pe=O.handshake_url,Ke=O.frontier_url,ie=Tc(O.env,pe,Ke),Qe=!!y&&y!==F,Q=w!==void 0&&w!==ie,X=Qe||Q,ut=await Xr({privatecode:F,...pe?{endpoint:pe}:{},ppeOverride:te});if(X){N.warn("pair config switched, resetting agents",{pcChanged:Qe,envChanged:Q,previousPc:y?Sr(y):"",nextPc:Sr(F),previousEnvKey:w??"",nextEnvKey:ie});for(let se of[...p.agents.values()])await se.dispose("pair config switch").catch(()=>{}),p.agents.delete(se.agentId);p.disconnectedAgents.size>0&&(N.info("clearing disconnectedAgents set on pair config switch",{count:p.disconnectedAgents.size}),p.disconnectedAgents.clear()),await a.swap(new Wt,"pair switch").catch(()=>{})}A=ut.deviceId,Sn({deviceId:A,pid:process.pid}),ci({patToken:F,env:O.env}).catch(se=>N.warn("coze-cli setup error (ignored)",{err:String(se)}));let J=new mn({handshake:ut,privatecode:F,...Ke?{urlOverride:Ke}:{},ppeOverride:te,getPatTokenForAgent:se=>p.agents.get(se)?.patToken});await a.swap(J,"pair");try{let se=new Mt;o.frameworksCache=await se.detectAll(),await Ue(o),N.info("frameworks_cache refreshed before pair",{detected:Object.keys(o.frameworksCache)})}catch(se){N.warn("frameworks_cache refresh failed (ignored, using cached)",{err:String(se)})}let _t=Object.keys(o.frameworksCache??{});try{let se=await p.sendRequest("_agent/pair",{pairCode:ye,patToken:F,frameworks:_t,_meta:{cozeDeviceId:A}});N.info("_agent/pair ok",{pairResult:se}),y=F,w=ie,I=te,E=pe,wn(F,d).catch(be=>N.warn("writePatToken after /pair failed (ignored)",{err:String(be)})),k||(k=new Qt({core:p,getDeviceId:()=>A??"",onTickEnd:()=>ae.retryPending().catch(be=>N.warn("detailSync.retryPending failed (ignored)",{err:String(be)})),onAuthFailures:W,onMinBridgeVersion:be=>L?.requestUpgrade(be)})),k.start(),X&&Er(d,h).catch(be=>N.warn("post-pair-switch auto-revive error (ignored)",{err:String(be)}));let yt;return O.agent_id&&(yt=await fg(O.agent_id,d,h,be=>p.sendRequest("_agent/detail",be),F).catch(be=>(N.error("--agent-id ensureAgent failed",{agentId:O.agent_id,err:String(be)}),{ok:!1,agentId:O.agent_id??"",note:String(be)}))),{ok:!0,note:"paired with cloud",...yt?{agent:yt}:{}}}catch(se){return N.error("_agent/pair failed",{err:String(se)}),{ok:!1,note:`pair failed: ${String(se)}`}}}},{method:"POST",path:"/connect",handler:async T=>{let O=T,F=O?.privatecode;if(!F)throw new b("IPC_BAD_REQUEST","/connect requires privatecode");let ye=Yt(O.env),te=O.handshake_url,pe=O.frontier_url,Ke=Tc(O.env,te,pe);if(y===F&&w===Ke){let J=await dg(d);return p.agents.size===0&&J?(N.warn("/connect noop but core.agents empty with configs on disk; re-running auto-revive"),Er(d,h).catch(_t=>N.warn("connect-noop auto-revive error (ignored)",{err:String(_t)}))):N.info("/connect: already connected with same PAT + env, noop"),{ok:!0,note:"already connected"}}let ie=!!y&&y!==F,Qe=w!==void 0&&w!==Ke,Q=ie||Qe,X=await Xr({privatecode:F,...te?{endpoint:te}:{},ppeOverride:ye});if(Q){N.warn("connect config switched, resetting agents",{pcChanged:ie,envChanged:Qe,previousPc:y?Sr(y):"",nextPc:Sr(F)});for(let J of[...p.agents.values()])await J.dispose("connect config switch").catch(()=>{}),p.agents.delete(J.agentId);p.disconnectedAgents.size>0&&(N.info("clearing disconnectedAgents set on connect config switch",{count:p.disconnectedAgents.size}),p.disconnectedAgents.clear()),await a.swap(new Wt,"connect switch").catch(()=>{})}A=X.deviceId,Sn({deviceId:A,pid:process.pid}),ci({patToken:F,env:O.env}).catch(J=>N.warn("coze-cli setup error (ignored)",{err:String(J)}));let ut=new mn({handshake:X,privatecode:F,...pe?{urlOverride:pe}:{},ppeOverride:ye,getPatTokenForAgent:J=>p.agents.get(J)?.patToken});return await a.swap(ut,"connect"),y=F,w=Ke,I=ye,E=te,k||(k=new Qt({core:p,getDeviceId:()=>A??"",onTickEnd:()=>ae.retryPending().catch(J=>N.warn("detailSync.retryPending failed (ignored)",{err:String(J)})),onAuthFailures:W,onMinBridgeVersion:J=>L?.requestUpgrade(J)})),k.start(),Q&&Er(d,h).catch(J=>N.warn("post-connect-switch auto-revive error (ignored)",{err:String(J)})),wn(F,d).catch(J=>N.warn("writePatToken after /connect failed (ignored)",{err:String(J)})),N.info("/connect: WS established",{deviceId:A}),{ok:!0,note:"connected"}}},{method:"POST",path:"/_agent/create",handler:async T=>{let O=T;return{ok:!0,result:await h.createAgent(O)}}},{method:"POST",path:"/agent/send",handler:async T=>{let O=T;if(!O?.agentId||!O?.sessionId||!O?.kind||!O?.path)throw new b("IPC_BAD_REQUEST","/agent/send requires agentId, sessionId, kind, path");if(!y)throw new b("UPSTREAM_NOT_READY","daemon not yet paired with cloud (run --pair-code first)");try{let F=O;return await(F.groupFile?Po:To)(F,{core:p,patToken:y,handshakeBase:E,ppeOverride:I})}catch(F){if(F instanceof b)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 T=new Mt;return o.frameworksCache=await T.detectAll(),await Ue(o),{ok:!0,frameworks:o.frameworksCache}}},{method:"POST",path:"/shutdown",handler:async()=>(N.info("IPC /shutdown received"),setImmediate(()=>{we.shutdown("ipc /shutdown")}),{ok:!0})}]}),{port:_e,token:ke}=await ge.start();try{await bc(d.libEntry,d)}catch(T){N.warn("bin shim install failed (D72 send \u547D\u4EE4\u53EF\u80FD\u4E0D\u53EF\u7528)",{err:String(T)})}await p.start(),Er(d,h).catch(T=>N.warn("auto-revive top-level error (ignored)",{err:String(T)})),As().catch(T=>N.warn("acp wrapper warmup top-level error (ignored)",{err:String(T)}));let de=null,we={port:_e,token:ke,core:p,ipc:ge,shutdown(T){return de||(N.info("daemon shutdown",{reason:T}),de=(async()=>{k?.stop(),await p.stop(T),await ge.stop(),await n.release()})(),de)}};L=new Zn({paths:d,currentVersion:st,isDevMode:Jo,download:(T,O)=>Yo(T,O),spawnHelper:(T,O)=>Vo(T,O,{paths:d}),daemon:{markUpgradePending:T=>{N.warn("upgrade pending, ACP gate engaged",{target:T}),u.markUpgradePending(T)},waitIdle:T=>u.waitIdle(T),exit:T=>{we.shutdown("upgrade").then(()=>process.exit(T))}}});for(let T of["SIGTERM","SIGINT"])process.on(T,()=>{we.shutdown(T).then(()=>process.exit(0))});return N.info("daemon ready",{port:_e,pid:process.pid,nodeVersion:process.version,platform:process.platform,frameworks:Object.keys(o.frameworksCache??{}),libVersion:o.libVersion??"dev"}),we}async function dg(n){let{readdir:e}=await import("node:fs/promises");try{return(await e(n.agentsRoot)).length>0}catch{return!1}}function Sr(n){return n.length<=8?"***":`${n.slice(0,4)}***${n.slice(-4)}`}function Tc(n,e,s){return`${n??""}|${e??""}|${s??""}`}async function ug(n,e){let{readdir:s}=await import("node:fs/promises"),o;try{o=await s(n.agentsRoot)}catch{return}let{loadAgentConfig:a,enforceAgentConfigMode:d}=await Promise.resolve().then(()=>(it(),Dn));for(let u of o){await d(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 fg(n,e,s,o,a){let{loadAgentConfig:d}=await Promise.resolve().then(()=>(it(),Dn)),u=await d(n,e);if(u){N.info("--agent-id: local config found, reconnecting",{agentId:n,framework:u.framework,hadDisconnect:!!u.disconnectedAt});let y={agentId:u.agentId,framework:u.framework,...u.cozeIdentity?{cozeIdentity:u.cozeIdentity}:{},...u.model?{model:u.model}:{},...a?{patToken:a}:{}};return await s.createAgent(y),{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 b("AGENT_NOT_FOUND",`agent ${n} \u4E0D\u5728\u672C\u5730; \u4E91\u7AEF _agent/detail \u54CD\u5E94\u7F3A framework \u5B57\u6BB5 (D36 \u534F\u8BAE\u6269\u5C55\u672A\u751F\u6548), \u65E0\u6CD5\u5728\u672C\u673A\u65B0\u5EFA`);let p={agentId: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(p);let h=f.deployType==="cloud"&&f.framework==="openclaw";return{ok:!0,agentId:n,note:h?"cloud agent acknowledged":"created from cloud detail"}}async function Er(n,e){let{readdir:s}=await import("node:fs/promises"),o;try{o=await s(n.agentsRoot)}catch{return{revived:0,skipped:0,total:0}}if(o.length===0)return{revived:0,skipped:0,total:0};let{loadAgentConfig:a}=await Promise.resolve().then(()=>(it(),Dn));N.info("auto-revive: scanning local agents on startup",{count:o.length});let d=0,u=0;for(let f of o){let p;try{p=await a(f,n)}catch(h){N.warn("auto-revive: load config failed (skipping)",{agentId:f,err:String(h)}),u+=1;continue}if(!p){u+=1;continue}if(p.disconnectedAt){N.info("auto-revive: skip disconnected agent",{agentId:f,disconnectedAt:p.disconnectedAt}),u+=1;continue}try{N.info("auto-revive: re-registering agent (D44 no spawn)",{agentId:f,framework:p.framework});let h=lg(p);await e.createAgent({agentId:p.agentId,framework:p.framework,...p.cozeIdentity?{cozeIdentity:p.cozeIdentity}:{},...p.model?{model:p.model}:{},...h?{_meta:h}:{}}),d+=1}catch(h){N.warn("auto-revive: createAgent failed (skipping)",{agentId:f,framework:p.framework,err:String(h)}),u+=1}}return N.info("auto-revive: done",{revived:d,skipped:u,total:o.length}),{revived:d,skipped:u,total:o.length}}function lg(n){let e={};return n.deployType&&(e.cozeDeployType=n.deployType),n.accountId&&(e.cozeAccountId=n.accountId),Object.keys(e).length>0?e:void 0}Ar();Tr();q();oe();Bt();q();oe();import{copyFile as kc,mkdir as Sg,readFile as Fi,writeFile as Eg}from"node:fs/promises";import{dirname as Ag,resolve as Ui,sep as Pr}from"node:path";import{fileURLToPath as Ig}from"node:url";var Dc=D("dist-install");function Tg(n){let e=Ig(n),s=Ag(e),o=`${Pr}src${Pr}`;if(s.includes(o)||s.endsWith(`${Pr}src${Pr}cli`))return null;let a=Ui(s,"index.js"),d=Ui(s,"..","package.json");return{dist:a,pkgJson:d}}async function qi(n={}){let e=n.paths??G(),s=Tg(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 d;try{d=JSON.parse(await Fi(a,"utf8")).version??"unknown"}catch(w){return Dc.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===d)try{return await Fi(e.libEntry),{kind:"already-current",libVersion:d}}catch{}await Sg(e.libDir,{recursive:!0}),await kc(o,e.libEntry),await kc(`${o}.map`,`${e.libEntry}.map`).catch(()=>{});let p=Ui(e.libDir,"package.json"),h=`${JSON.stringify({type:"module"},null,2)}
128
- `;return await Fi(p,"utf8").catch(()=>null)!==h&&await Eg(p,h),u.libVersion=d,await Ue(u,e.configFile),Dc.info("dist installed",{libEntry:e.libEntry,fromVersion:f,toVersion:d}),f?{kind:"version-changed",fromVersion:f,toVersion:d,libEntry:e.libEntry}:{kind:"first-install",libVersion:d,libEntry:e.libEntry}}Tr();oe();import{basename as Pg,resolve as Cg}from"node:path";var kg=9e4,Dg={PATH_OUTSIDE_WORKSPACE:3,FILE_TOO_LARGE:3,UNSUPPORTED_MIME:3,MODEL_MODALITY_UNSUPPORTED:3,IPC_BAD_REQUEST:3,AGENT_NOT_FOUND:4,IPC_AUTH_FAILED:4,AGENT_DISCONNECTED:5,UPLOAD_FAILED:5,UPSTREAM_NOT_READY:5,UPSTREAM_DISCONNECTED:5,UPSTREAM_HANDSHAKE_FAILED:5,AGENT_BUSY:1,AGENT_SPAWN_FAILED:1,AGENT_TIMEOUT:1,AGENT_FRAME_IDLE_TIMEOUT:1,AGENT_PROTOCOL_ERROR:1,BRIDGE_CONFIG_INVALID:1,BRIDGE_INTERNAL:1,MODEL_TOKEN_GEN_FAILED:1,OPERATION_NOT_ALLOWED_FOR_LOCAL:1,BRIDGE_UPGRADING:5,NPX_CACHE_CORRUPT:1};function Rg(n){return Dg[n]??1}async function Rc(n,e={}){let s=e.paths??G();if(!n.agentId||!n.sessionId)return process.stderr.write(`Error: missing --agent-id and/or --session-id. These IDs come from the <coze-context> block injected at the top of each prompt \u2014 extract agentId and sessionId from there and pass them as flags. Example: coze-bridge send image x.png --agent-id <id> --session-id <id>
127
+ `}async function C0(n,e=Y()){let i=e.binDir;await Hr.mkdir(i,{recursive:!0});let o=Ch(i,process.platform==="win32"?"coze-bridge.cmd":"coze-bridge"),a=process.platform==="win32"?Dh(n):Th(n);return await Hr.readFile(o,"utf8").catch(()=>null)===a||(await Hr.writeFile(o,a,"utf8"),process.platform!=="win32"&&await Hr.chmod(o,493)),i}Z();ye();import{execSync as D0}from"node:child_process";import{readFileSync as P0,unlinkSync as Ph}from"node:fs";import{mkdir as kh,readFile as k0,unlink as R0,writeFile as Rh}from"node:fs/promises";import{dirname as Nh}from"node:path";function T0(n){try{return process.kill(n,0),!0}catch(e){return e.code==="EPERM"}}var Lh=q("single-instance"),Gr=class{pidFile;acquired=!1;constructor(e={}){this.pidFile=e.pidFile??Y().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&&(Lh.warn("removing stale pid file",{stalePid:e}),await R0(this.pidFile).catch(()=>{})),await kh(Nh(this.pidFile),{recursive:!0}),await Rh(this.pidFile,String(process.pid),"utf8"),this.acquired=!0,this.installCleanupHooks(),{kind:"acquired"})}async release(){if(this.acquired){try{(await k0(this.pidFile,"utf8")).trim()===String(process.pid)&&await R0(this.pidFile)}catch{}this.acquired=!1}}async readExistingPid(){try{let e=await k0(this.pidFile,"utf8"),i=Number.parseInt(e.trim(),10);return Number.isFinite(i)&&i>0?i:null}catch(e){if(e.code==="ENOENT")return null;throw e}}isAlive(e){return T0(e)?this.matchesDaemonTitle(e):!1}matchesDaemonTitle(e){if(process.platform==="win32")return this.matchesDaemonTitleWindows(e);try{let i=P0(`/proc/${e}/cmdline`,"utf8").replace(/\0/g," ");return!!(i.includes("coze-bridge-daemon")||i.includes("lib/index.js"))}catch{}try{let i=D0(`ps -o command= -p ${e}`,{stdio:["ignore","pipe","ignore"],timeout:1e3}).toString();return i.trim()?i.includes("coze-bridge-daemon")||i.includes("lib/index.js"):!1}catch{return!0}}matchesDaemonTitleWindows(e){try{let o=D0(`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{P0(this.pidFile,"utf8").trim()===String(process.pid)&&Ph(this.pidFile)}catch{}})}};function Oh(){let n=0,e=null;return{incActive(){n++},decActive(){n>0&&n--},activeCount(){return n},markUpgradePending(i){e=i},isUpgrading(){return e!==null},pendingTarget(){return e},async waitIdle(i){let o=Date.now()+i;for(;Date.now()<o;){if(n===0)return"idle";await new Promise(a=>setTimeout(a,200))}return n===0?"idle":"timeout"}}}var W=q("daemon"),Mh="coze-bridge-daemon";async function L0(){let n=new Gr({processTitle:Mh}),e=await n.acquire();if(e.kind==="already-running")throw new Error(`coze-bridge daemon already running (pid=${e.pid})`);let i=await wt(),o=i??{};Fn({pid:process.pid}),W.info(i?"loaded bridge config":"initialized bridge config");try{let N=new Zt;o.frameworksCache=await N.detectAll(),W.info("refreshed frameworks_cache",{detected:Object.keys(o.frameworksCache)})}catch(N){W.warn("framework detection failed",{err:String(N)})}await Ze(o);let a=new qr(new an),c=Y(),u=Oh(),x=null,l=new mr({upstream:a,paths:c,bridgeConfig:o,upgradeGate:u,sessionSpawner:async(N,B,j,te)=>{if(!x)throw new Error("agentManager not ready");return x.spawnSessionDownstream(N,B,j,te)}});await zh(c,l);let g=new lr({paths:c,config:o,registry:l});x=g;let E,w,A=null,_={},b,S=null,I=null;l.registerExtension("_agent/create",async N=>g.createAgent(N.params)),l.registerExtension("_agent/health",async()=>({ok:!0}));let k={},L=new rr({agents:l.agents,disposeAndMarkDisconnected:async(N,B)=>{let j=l.agents.get(N);if(j){await g.cleanupOpenclawSessionProviders(j).catch(ie=>W.warn("cleanup openclaw providers failed (ignored)",{agentId:N,err:String(ie)}));let te=!0;try{await j.dispose(`disconnect: ${B}`)}catch(ie){te=!1,W.error("dispose during disconnect FAILED, leaving agent in error state",{agentId:N,err:String(ie)}),j.status="error"}te&&(j.status="disconnected",l.unregister(N),l.disconnectedAgents.add(N))}else l.disconnectedAgents.add(N)},detailSyncer:async N=>{if(!k.ref)throw new Error("agent-detail-sync not initialized yet");await k.ref.syncOne(N)},cleanupOpenclawProviders:async N=>{await g.cleanupOpenclawSessionProviders(N)},openclawRepair:async(N,B)=>{await g.openclawRepair(N,B)},isRuntimePendingPermission:N=>l.hasPendingPermissionFor(N)});l.registerExtension("_agent/listSkills",N=>L.listSkills(N.params)),l.registerExtension("_agent/addSkills",N=>L.addSkills(N.params)),l.registerExtension("_agent/removeSkills",N=>L.removeSkills(N.params)),l.registerExtension("_agent/getFileTree",N=>L.getFileTree(N.params)),l.registerExtension("_agent/getFileContent",N=>L.getFileContent(N.params)),l.registerExtension("_agent/update",N=>L.updateAgent(N.params)),l.registerExtension("_agent/disconnect",N=>L.disconnectAgent(N.params)),l.registerExtension("_agent/switchModel",N=>L.switchModel(N.params)),l.registerExtension("_agent/reset",N=>L.resetAgent(N.params)),l.registerExtension("_agent/repair",N=>L.repairAgent(N.params));let m=new Jn({paths:c,handlers:L,sendDetail:N=>l.sendRequest("_agent/detail",N)});k.ref=m;let C=async N=>{await Promise.allSettled(N.map(async B=>{try{await L.disconnectAgent({agentId:B.agentId,reason:`auth_failure: code=${B.code} ${B.message}`}),W.info("agent disconnected due to auth failure from heartbeat response",{agentId:B.agentId,code:B.code,message:B.message})}catch(j){W.warn("disconnect during authFailure handling failed (ignored)",{agentId:B.agentId,err:String(j)})}}))};a.onConnect(({initial:N})=>{W.info("frontier upstream connected, triggering detail sync",{initial:N}),m.syncAll(N?"initial-connect":"reconnect").catch(B=>W.warn("detail sync top-level error (ignored)",{err:String(B)}))});let R=new wr({paths:c,routes:[{method:"GET",path:"/status",handler:async()=>({running:!0,pid:process.pid,agents:[...l.agents.keys()],deviceId:A??"",frameworksCache:o.frameworksCache??{}})},{method:"POST",path:"/pair",handler:async N=>{let B=N,j=B?.privatecode,te=B?.pairing_code;if(!j||!te)throw new T("IPC_BAD_REQUEST","/pair requires privatecode + pairing_code");let ie=gn(B.env),me=B.handshake_url,Re=B.frontier_url,we=N0(B.env,me,Re),dt=!!E&&E!==j,he=w!==void 0&&w!==we,ae=dt||he,Et=await vi({privatecode:j,...me?{endpoint:me}:{},ppeOverride:ie});if(ae){W.warn("pair config switched, resetting agents",{pcChanged:dt,envChanged:he,previousPc:E?jr(E):"",nextPc:jr(j),previousEnvKey:w??"",nextEnvKey:we});for(let _e of[...l.agents.values()])await _e.dispose("pair config switch").catch(()=>{}),l.agents.delete(_e.agentId);l.disconnectedAgents.size>0&&(W.info("clearing disconnectedAgents set on pair config switch",{count:l.disconnectedAgents.size}),l.disconnectedAgents.clear()),await a.swap(new an,"pair switch").catch(()=>{})}A=Et.deviceId,Fn({deviceId:A,pid:process.pid}),Fi({patToken:j,env:B.env}).catch(_e=>W.warn("coze-cli setup error (ignored)",{err:String(_e)}));let se=new Nn({handshake:Et,privatecode:j,...Re?{urlOverride:Re}:{},ppeOverride:ie,getPatTokenForAgent:_e=>l.agents.get(_e)?.patToken});await a.swap(se,"pair");try{let _e=new Zt;o.frameworksCache=await _e.detectAll(),await Ze(o),W.info("frameworks_cache refreshed before pair",{detected:Object.keys(o.frameworksCache)})}catch(_e){W.warn("frameworks_cache refresh failed (ignored, using cached)",{err:String(_e)})}let kt=Object.keys(o.frameworksCache??{});try{let _e=await l.sendRequest("_agent/pair",{pairCode:te,patToken:j,frameworks:kt,_meta:{cozeDeviceId:A}});W.info("_agent/pair ok",{pairResult:_e}),E=j,w=we,_=ie,b=me,Ln(j,c).catch(ke=>W.warn("writePatToken after /pair failed (ignored)",{err:String(ke)})),S||(S=new pn({core:l,getDeviceId:()=>A??"",onTickEnd:()=>m.retryPending().catch(ke=>W.warn("detailSync.retryPending failed (ignored)",{err:String(ke)})),onAuthFailures:C,onMinBridgeVersion:ke=>I?.requestUpgrade(ke)})),S.start(),ae&&Kr(c,g).catch(ke=>W.warn("post-pair-switch auto-revive error (ignored)",{err:String(ke)}));let Rt;return B.agent_id&&(Rt=await Fh(B.agent_id,c,g,ke=>l.sendRequest("_agent/detail",ke),j).catch(ke=>(W.error("--agent-id ensureAgent failed",{agentId:B.agent_id,err:String(ke)}),{ok:!1,agentId:B.agent_id??"",note:String(ke)}))),{ok:!0,note:"paired with cloud",...Rt?{agent:Rt}:{}}}catch(_e){return W.error("_agent/pair failed",{err:String(_e)}),{ok:!1,note:`pair failed: ${String(_e)}`}}}},{method:"POST",path:"/connect",handler:async N=>{let B=N,j=B?.privatecode;if(!j)throw new T("IPC_BAD_REQUEST","/connect requires privatecode");let te=gn(B.env),ie=B.handshake_url,me=B.frontier_url,Re=N0(B.env,ie,me);if(E===j&&w===Re){let se=await Bh(c);return l.agents.size===0&&se?(W.warn("/connect noop but core.agents empty with configs on disk; re-running auto-revive"),Kr(c,g).catch(kt=>W.warn("connect-noop auto-revive error (ignored)",{err:String(kt)}))):W.info("/connect: already connected with same PAT + env, noop"),{ok:!0,note:"already connected"}}let we=!!E&&E!==j,dt=w!==void 0&&w!==Re,he=we||dt,ae=await vi({privatecode:j,...ie?{endpoint:ie}:{},ppeOverride:te});if(he){W.warn("connect config switched, resetting agents",{pcChanged:we,envChanged:dt,previousPc:E?jr(E):"",nextPc:jr(j)});for(let se of[...l.agents.values()])await se.dispose("connect config switch").catch(()=>{}),l.agents.delete(se.agentId);l.disconnectedAgents.size>0&&(W.info("clearing disconnectedAgents set on connect config switch",{count:l.disconnectedAgents.size}),l.disconnectedAgents.clear()),await a.swap(new an,"connect switch").catch(()=>{})}A=ae.deviceId,Fn({deviceId:A,pid:process.pid}),Fi({patToken:j,env:B.env}).catch(se=>W.warn("coze-cli setup error (ignored)",{err:String(se)}));let Et=new Nn({handshake:ae,privatecode:j,...me?{urlOverride:me}:{},ppeOverride:te,getPatTokenForAgent:se=>l.agents.get(se)?.patToken});return await a.swap(Et,"connect"),E=j,w=Re,_=te,b=ie,S||(S=new pn({core:l,getDeviceId:()=>A??"",onTickEnd:()=>m.retryPending().catch(se=>W.warn("detailSync.retryPending failed (ignored)",{err:String(se)})),onAuthFailures:C,onMinBridgeVersion:se=>I?.requestUpgrade(se)})),S.start(),he&&Kr(c,g).catch(se=>W.warn("post-connect-switch auto-revive error (ignored)",{err:String(se)})),Ln(j,c).catch(se=>W.warn("writePatToken after /connect failed (ignored)",{err:String(se)})),W.info("/connect: WS established",{deviceId:A}),{ok:!0,note:"connected"}}},{method:"POST",path:"/_agent/create",handler:async N=>{let B=N;return{ok:!0,result:await g.createAgent(B)}}},{method:"POST",path:"/agent/send",handler:async N=>{let B=N;if(!B?.agentId||!B?.sessionId||!B?.kind||!B?.path)throw new T("IPC_BAD_REQUEST","/agent/send requires agentId, sessionId, kind, path");if(!E)throw new T("UPSTREAM_NOT_READY","daemon not yet paired with cloud (run --pair-code first)");try{let j=B;return await(j.groupFile?La:Na)(j,{core:l,patToken:E,handshakeBase:b,ppeOverride:_})}catch(j){if(j instanceof T)return{ok:!1,code:j.code,message:j.message};throw j}}},{method:"POST",path:"/refresh",handler:async()=>{W.info("IPC /refresh: re-detecting frameworks");let N=new Zt;return o.frameworksCache=await N.detectAll(),await Ze(o),{ok:!0,frameworks:o.frameworksCache}}},{method:"POST",path:"/shutdown",handler:async()=>(W.info("IPC /shutdown received"),setImmediate(()=>{J.shutdown("ipc /shutdown")}),{ok:!0})}]}),{port:F,token:z}=await R.start();try{await C0(c.libEntry,c)}catch(N){W.warn("bin shim install failed (D72 send \u547D\u4EE4\u53EF\u80FD\u4E0D\u53EF\u7528)",{err:String(N)})}await l.start(),Kr(c,g).catch(N=>W.warn("auto-revive top-level error (ignored)",{err:String(N)})),eo().catch(N=>W.warn("acp wrapper warmup top-level error (ignored)",{err:String(N)}));let $=null,J={port:F,token:z,core:l,ipc:R,shutdown(N){return $||(W.info("daemon shutdown",{reason:N}),$=(async()=>{S?.stop(),await l.stop(N),await R.stop(),await n.release()})(),$)}};I=new _r({paths:c,currentVersion:ht,isDevMode:ec,download:(N,B)=>rc(N,B),spawnHelper:(N,B)=>tc(N,B,{paths:c}),daemon:{markUpgradePending:N=>{W.warn("upgrade pending, ACP gate engaged",{target:N}),u.markUpgradePending(N)},waitIdle:N=>u.waitIdle(N),exit:N=>{J.shutdown("upgrade").then(()=>process.exit(N))}}});for(let N of["SIGTERM","SIGINT"])process.on(N,()=>{J.shutdown(N).then(()=>process.exit(0))});return process.on("unhandledRejection",N=>{W.error("unhandledRejection",{reason:N instanceof Error?N.message:String(N),stack:N instanceof Error?N.stack:void 0})}),process.on("uncaughtException",N=>{W.error("uncaughtException (will exit, supervisor will restart)",{message:N.message,stack:N.stack,name:N.name}),process.exit(1)}),W.info("daemon ready",{port:F,pid:process.pid,nodeVersion:process.version,platform:process.platform,frameworks:Object.keys(o.frameworksCache??{}),libVersion:o.libVersion??"dev"}),J}async function Bh(n){let{readdir:e}=await import("node:fs/promises");try{return(await e(n.agentsRoot)).length>0}catch{return!1}}function jr(n){return n.length<=8?"***":`${n.slice(0,4)}***${n.slice(-4)}`}function N0(n,e,i){return`${n??""}|${e??""}|${i??""}`}async function zh(n,e){let{readdir:i}=await import("node:fs/promises"),o;try{o=await i(n.agentsRoot)}catch{return}let{loadAgentConfig:a,enforceAgentConfigMode:c}=await Promise.resolve().then(()=>(lt(),$n));for(let u of o){await c(u,n).catch(x=>W.warn("enforceAgentConfigMode failed (ignored)",{agentId:u,err:String(x)}));try{let x=await a(u,n);x?.disconnectedAt&&(e.disconnectedAgents.add(u),W.info("agent marked disconnected on startup",{agentId:u,disconnectedAt:x.disconnectedAt,reason:x.disconnectReason??""}))}catch(x){W.warn("failed to load agent config on startup, skipping",{agentId:u,err:String(x)})}}}async function Fh(n,e,i,o,a){let{loadAgentConfig:c}=await Promise.resolve().then(()=>(lt(),$n)),u=await c(n,e);if(u){W.info("--agent-id: local config found, reconnecting",{agentId:n,framework:u.framework,hadDisconnect:!!u.disconnectedAt});let E={agentId:u.agentId,framework:u.framework,...u.cozeIdentity?{cozeIdentity:u.cozeIdentity}:{},...u.model?{model:u.model}:{},...a?{patToken:a}:{}};return await i.createAgent(E),{ok:!0,agentId:n,note:u.disconnectedAt?"revived from local config":"connected from local config"}}W.info("--agent-id: local config missing, pulling _agent/detail from cloud",{agentId:n});let x=await o({_meta:{cozeAgentId:n}});if(!x.framework)throw new T("AGENT_NOT_FOUND",`agent ${n} \u4E0D\u5728\u672C\u5730; \u4E91\u7AEF _agent/detail \u54CD\u5E94\u7F3A framework \u5B57\u6BB5 (D36 \u534F\u8BAE\u6269\u5C55\u672A\u751F\u6548), \u65E0\u6CD5\u5728\u672C\u673A\u65B0\u5EFA`);let l={agentId:x.agentId,framework:x.framework,...x.cozeIdentity?{cozeIdentity:x.cozeIdentity}:{},...x.model?{model:x.model}:{},...a?{patToken:a}:{},...x.deployType?{_meta:{cozeDeployType:x.deployType}}:{}};await i.createAgent(l);let g=x.deployType==="cloud"&&x.framework==="openclaw";return{ok:!0,agentId:n,note:g?"cloud agent acknowledged":"created from cloud detail"}}async function Kr(n,e){let{readdir:i}=await import("node:fs/promises"),o;try{o=await i(n.agentsRoot)}catch{return{revived:0,skipped:0,total:0}}if(o.length===0)return{revived:0,skipped:0,total:0};let{loadAgentConfig:a}=await Promise.resolve().then(()=>(lt(),$n));W.info("auto-revive: scanning local agents on startup",{count:o.length});let c=0,u=0;for(let x of o){let l;try{l=await a(x,n)}catch(g){W.warn("auto-revive: load config failed (skipping)",{agentId:x,err:String(g)}),u+=1;continue}if(!l){u+=1;continue}if(l.disconnectedAt){W.info("auto-revive: skip disconnected agent",{agentId:x,disconnectedAt:l.disconnectedAt}),u+=1;continue}try{W.info("auto-revive: re-registering agent (D44 no spawn)",{agentId:x,framework:l.framework});let g=Uh(l);await e.createAgent({agentId:l.agentId,framework:l.framework,...l.cozeIdentity?{cozeIdentity:l.cozeIdentity}:{},...l.model?{model:l.model}:{},...g?{_meta:g}:{}}),c+=1}catch(g){W.warn("auto-revive: createAgent failed (skipping)",{agentId:x,framework:l.framework,err:String(g)}),u+=1}}return W.info("auto-revive: done",{revived:c,skipped:u,total:o.length}),{revived:c,skipped:u,total:o.length}}function Uh(n){let e={};return n.deployType&&(e.cozeDeployType=n.deployType),n.accountId&&(e.cozeAccountId=n.accountId),Object.keys(e).length>0?e:void 0}Wr();Jr();Z();ye();Yt();Z();ye();import{copyFile as M0,mkdir as Zh,readFile as ps,writeFile as Yh}from"node:fs/promises";import{dirname as Xh,resolve as ms,sep as Vr}from"node:path";import{fileURLToPath as Qh}from"node:url";var B0=q("dist-install");function ep(n){let e=Qh(n),i=Xh(e),o=`${Vr}src${Vr}`;if(i.includes(o)||i.endsWith(`${Vr}src${Vr}cli`))return null;let a=ms(i,"index.js"),c=ms(i,"..","package.json");return{dist:a,pkgJson:c}}async function ws(n={}){let e=n.paths??Y(),i=ep(import.meta.url),o=n.sourceDist??i?.dist,a=n.sourcePackageJson??i?.pkgJson;if(!o||!a)return{kind:"dev-mode-skip",reason:"running from src/(tsx loader);no dist/ to install"};let c;try{c=JSON.parse(await ps(a,"utf8")).version??"unknown"}catch(w){return B0.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 wt(e.configFile)??{},x=u.libVersion;if(x===c)try{return await ps(e.libEntry),{kind:"already-current",libVersion:c}}catch{}await Zh(e.libDir,{recursive:!0}),await M0(o,e.libEntry),await M0(`${o}.map`,`${e.libEntry}.map`).catch(()=>{});let l=ms(e.libDir,"package.json"),g=`${JSON.stringify({type:"module"},null,2)}
128
+ `;return await ps(l,"utf8").catch(()=>null)!==g&&await Yh(l,g),u.libVersion=c,await Ze(u,e.configFile),B0.info("dist installed",{libEntry:e.libEntry,fromVersion:x,toVersion:c}),x?{kind:"version-changed",fromVersion:x,toVersion:c,libEntry:e.libEntry}:{kind:"first-install",libVersion:c,libEntry:e.libEntry}}Jr();ye();import{basename as tp,resolve as np}from"node:path";var rp=9e4,ip={PATH_OUTSIDE_WORKSPACE:3,FILE_TOO_LARGE:3,UNSUPPORTED_MIME:3,MODEL_MODALITY_UNSUPPORTED:3,IPC_BAD_REQUEST:3,AGENT_NOT_FOUND:4,IPC_AUTH_FAILED:4,AGENT_DISCONNECTED:5,UPLOAD_FAILED:5,UPSTREAM_NOT_READY:5,UPSTREAM_DISCONNECTED:5,UPSTREAM_HANDSHAKE_FAILED:5,AGENT_BUSY:1,AGENT_SPAWN_FAILED:1,AGENT_TIMEOUT:1,AGENT_FRAME_IDLE_TIMEOUT:1,AGENT_PROTOCOL_ERROR:1,BRIDGE_CONFIG_INVALID:1,BRIDGE_INTERNAL:1,MODEL_TOKEN_GEN_FAILED:1,OPERATION_NOT_ALLOWED_FOR_LOCAL:1,BRIDGE_UPGRADING:5,NPX_CACHE_CORRUPT:1};function sp(n){return ip[n]??1}async function z0(n,e={}){let i=e.paths??Y();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
129
  `),4;if(n.groupFile&&!n.mimeType)return process.stderr.write(`Error: --group-file requires --mime <mimeType> (e.g. application/pdf, image/png). No local file is read in group-file mode, mime cannot be auto-detected.
130
- `),3;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.
131
- `),4;let a={agentId:n.agentId,sessionId:n.sessionId,kind:n.kind,path:n.groupFile?n.path:Cg(process.cwd(),n.path),...n.caption?{caption:n.caption}:{},...n.name?{name:n.name}:{},...n.groupFile?{groupFile:!0}:{},...n.mimeType?{mimeType:n.mimeType}:{}},d;try{d=await Og(o,"/agent/send",a,kg)}catch(u){return process.stderr.write(`Error: daemon IPC failed: ${u instanceof Error?u.message:String(u)}
132
- `),4}if(!d.ok)return process.stderr.write(`Error: ${d.code}: ${d.message}
133
- `),Rg(d.code);if(n.json)process.stdout.write(`${JSON.stringify(d)}
134
- `);else{let u=n.name??Pg(a.path);if(n.groupFile){let f=d.uri.length>60?`${d.uri.slice(0,57)}...`:d.uri;process.stdout.write(`Sent group file ${u} (uri=${f})
135
- `)}else process.stdout.write(`Sent ${n.kind} ${u} (${Ng(d.bytes)})
136
- `)}return 0}async function Og(n,e,s,o){let a=new AbortController,d=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(),p=f?JSON.parse(f):null;return p&&typeof p=="object"&&"ok"in p?p:{ok:!1,code:"BRIDGE_INTERNAL",message:`unexpected daemon response (status=${u.status}): ${f.slice(0,200)}`}}finally{clearTimeout(d)}}function Ng(n){return n<1024?`${n}B`:n<1024*1024?`${(n/1024).toFixed(1)}KB`:`${(n/1024/1024).toFixed(1)}MB`}var Wc=D("cli");function le(n,e){let s=[],o;for(let a=0;a<n.length;a++){let d=n[a];if(d===e){o=n[a+1],a+=1;continue}if(d.startsWith(`${e}=`)){o=d.slice(e.length+1);continue}s.push(d)}return{value:o,rest:s}}function yn(n,e){process.stderr.write(`[deprecated] '${n}' will be removed in a future release, use '${e}' instead
137
- `)}function xp(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("--upgrade-helper")){let k=e.filter(W=>W!=="--upgrade-helper"),{value:L,rest:$}=le(k,"--target-version"),{value:H}=le($,"--old-pid"),ae=H?Number.parseInt(H,10):Number.NaN;return!L||!Number.isFinite(ae)?{mode:"help"}:{mode:"upgrade-helper",targetVersion:L,oldPid:ae}}if(e[0]==="status")return{mode:"status"};if(e[0]==="stop")return{mode:"stop"};if(e[0]==="refresh")return{mode:"refresh"};if(e[0]==="purge")return{mode:"purge"};if(e[0]==="service")return e[1]==="install"?{mode:"service-install"}:e[1]==="uninstall"?{mode:"service-uninstall"}:{mode:"help"};if(e[0]==="send")return dp(e.slice(1));if(e[0]==="connect")return up(e.slice(1));if(e.includes("--status"))return yn("--status","coze-bridge status"),{mode:"status"};if(e.includes("--stop"))return yn("--stop","coze-bridge stop"),{mode:"stop"};if(e.includes("--refresh"))return yn("--refresh","coze-bridge refresh"),{mode:"refresh"};if(e.includes("--uninstall"))return yn("--uninstall","coze-bridge purge"),{mode:"purge"};if(e.includes("--install-service"))return yn("--install-service","coze-bridge service install"),{mode:"service-install"};if(e.includes("--help")||e.includes("-h")||e.length===0)return{mode:"help"};let s=e,{value:o,rest:a}=le(s,"--pat-token");s=a;let{value:d,rest:u}=le(s,"--pair-code");s=u;let{value:f,rest:p}=le(s,"--env");s=p;let{value:h,rest:y}=le(s,"--handshake-url");s=y;let{value:w,rest:A}=le(s,"--frontier-url");s=A;let{value:I}=le(s,"--agent-id");if(!o||!d)return{mode:"help"};let E={mode:"pair",privatecode:o,pairingCode:d};return f&&(E.env=f),h&&(E.handshakeUrl=h),w&&(E.frontierUrl=w),I&&(E.agentId=I),E}function dp(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:d}=le(o,"--caption");o=d;let{value:u,rest:f}=le(o,"--name");o=f;let{value:p,rest:h}=le(o,"--agent-id");o=h;let{value:y,rest:w}=le(o,"--session-id");o=w;let{value:A,rest:I}=le(o,"--mime");o=I;let E=o.includes("--group-file");o=o.filter($=>$!=="--group-file");let k=o.includes("--json"),L={mode:"send",kind:e,path:s,json:k};return a&&(L.caption=a),u&&(L.name=u),p&&(L.agentId=p),y&&(L.sessionId=y),E&&(L.groupFile=!0),A&&(L.mimeType=A),L}function up(n){let e=n,{value:s,rest:o}=le(e,"--pat-token");e=o;let{value:a,rest:d}=le(e,"--env");e=d;let{value:u,rest:f}=le(e,"--handshake-url");e=f;let{value:p}=le(e,"--frontier-url"),h={mode:"connect"};return s&&(h.privatecode=s),a&&(h.env=a),u&&(h.handshakeUrl=u),p&&(h.frontierUrl=p),h}var fp=`
130
+ `),3;let o=await $r(i).catch(()=>null);if(!o)return process.stderr.write(`Error: coze-bridge daemon not running (cannot read ${i.portFile} / ${i.tokenFile}). Make sure you are inside an agent session spawned by the daemon.
131
+ `),4;let a={agentId:n.agentId,sessionId:n.sessionId,kind:n.kind,path:n.groupFile?n.path:np(process.cwd(),n.path),...n.caption?{caption:n.caption}:{},...n.name?{name:n.name}:{},...n.groupFile?{groupFile:!0}:{},...n.mimeType?{mimeType:n.mimeType}:{}},c;try{c=await op(o,"/agent/send",a,rp)}catch(u){return process.stderr.write(`Error: daemon IPC failed: ${u instanceof Error?u.message:String(u)}
132
+ `),4}if(!c.ok)return process.stderr.write(`Error: ${c.code}: ${c.message}
133
+ `),sp(c.code);if(n.json)process.stdout.write(`${JSON.stringify(c)}
134
+ `);else{let u=n.name??tp(a.path);if(n.groupFile){let x=c.uri.length>60?`${c.uri.slice(0,57)}...`:c.uri;process.stdout.write(`Sent group file ${u} (uri=${x})
135
+ `)}else process.stdout.write(`Sent ${n.kind} ${u} (${ap(c.bytes)})
136
+ `)}return 0}async function op(n,e,i,o){let a=new AbortController,c=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(i),signal:a.signal}),x=await u.text(),l=x?JSON.parse(x):null;return l&&typeof l=="object"&&"ok"in l?l:{ok:!1,code:"BRIDGE_INTERNAL",message:`unexpected daemon response (status=${u.status}): ${x.slice(0,200)}`}}finally{clearTimeout(c)}}function ap(n){return n<1024?`${n}B`:n<1024*1024?`${(n/1024).toFixed(1)}KB`:`${(n/1024/1024).toFixed(1)}MB`}var X0=q("cli");function Ce(n,e){let i=[],o;for(let a=0;a<n.length;a++){let c=n[a];if(c===e){o=n[a+1],a+=1;continue}if(c.startsWith(`${e}=`)){o=c.slice(e.length+1);continue}i.push(c)}return{value:o,rest:i}}function Mn(n,e){process.stderr.write(`[deprecated] '${n}' will be removed in a future release, use '${e}' instead
137
+ `)}function Mp(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("--upgrade-helper")){let S=e.filter(C=>C!=="--upgrade-helper"),{value:I,rest:k}=Ce(S,"--target-version"),{value:L}=Ce(k,"--old-pid"),m=L?Number.parseInt(L,10):Number.NaN;return!I||!Number.isFinite(m)?{mode:"help"}:{mode:"upgrade-helper",targetVersion:I,oldPid:m}}if(e[0]==="status")return{mode:"status"};if(e[0]==="stop")return{mode:"stop"};if(e[0]==="refresh")return{mode:"refresh"};if(e[0]==="purge")return{mode:"purge"};if(e[0]==="service")return e[1]==="install"?{mode:"service-install"}:e[1]==="uninstall"?{mode:"service-uninstall"}:{mode:"help"};if(e[0]==="send")return Bp(e.slice(1));if(e[0]==="connect")return zp(e.slice(1));if(e.includes("--status"))return Mn("--status","coze-bridge status"),{mode:"status"};if(e.includes("--stop"))return Mn("--stop","coze-bridge stop"),{mode:"stop"};if(e.includes("--refresh"))return Mn("--refresh","coze-bridge refresh"),{mode:"refresh"};if(e.includes("--uninstall"))return Mn("--uninstall","coze-bridge purge"),{mode:"purge"};if(e.includes("--install-service"))return Mn("--install-service","coze-bridge service install"),{mode:"service-install"};if(e.includes("--help")||e.includes("-h")||e.length===0)return{mode:"help"};let i=e,{value:o,rest:a}=Ce(i,"--pat-token");i=a;let{value:c,rest:u}=Ce(i,"--pair-code");i=u;let{value:x,rest:l}=Ce(i,"--env");i=l;let{value:g,rest:E}=Ce(i,"--handshake-url");i=E;let{value:w,rest:A}=Ce(i,"--frontier-url");i=A;let{value:_}=Ce(i,"--agent-id");if(!o||!c)return{mode:"help"};let b={mode:"pair",privatecode:o,pairingCode:c};return x&&(b.env=x),g&&(b.handshakeUrl=g),w&&(b.frontierUrl=w),_&&(b.agentId=_),b}function Bp(n){let e=n[0],i=n[1];if(e!=="image"&&e!=="file")return{mode:"help"};if(!i||i.startsWith("--"))return{mode:"help"};let o=n.slice(2),{value:a,rest:c}=Ce(o,"--caption");o=c;let{value:u,rest:x}=Ce(o,"--name");o=x;let{value:l,rest:g}=Ce(o,"--agent-id");o=g;let{value:E,rest:w}=Ce(o,"--session-id");o=w;let{value:A,rest:_}=Ce(o,"--mime");o=_;let b=o.includes("--group-file");o=o.filter(k=>k!=="--group-file");let S=o.includes("--json"),I={mode:"send",kind:e,path:i,json:S};return a&&(I.caption=a),u&&(I.name=u),l&&(I.agentId=l),E&&(I.sessionId=E),b&&(I.groupFile=!0),A&&(I.mimeType=A),I}function zp(n){let e=n,{value:i,rest:o}=Ce(e,"--pat-token");e=o;let{value:a,rest:c}=Ce(e,"--env");e=c;let{value:u,rest:x}=Ce(e,"--handshake-url");e=x;let{value:l}=Ce(e,"--frontier-url"),g={mode:"connect"};return i&&(g.privatecode=i),a&&(g.env=a),u&&(g.handshakeUrl=u),l&&(g.frontierUrl=l),g}var Fp=`
138
138
  coze-bridge - local bridge daemon for cloud Agent Service
139
139
 
140
140
  Pair (paste from cloud UI; start/reuse daemon and deliver pair-code):
@@ -200,45 +200,45 @@ Internal:
200
200
  <node> <entry> --upgrade-helper --target-version=<v> --old-pid=<pid>
201
201
  D82 self-update helper
202
202
  (UpgradeManager \u5185\u90E8 fork)
203
- `.trimStart();async function $c(n=process.argv,e={}){let s=xp(n);switch(s.mode){case"help":return process.stdout.write(fp),0;case"version":return process.stdout.write(`${st}
204
- `),0;case"daemon":{try{await Pc()}catch(o){return Wc.error("daemon start failed",{err:String(o)}),1}return new Promise(()=>{})}case"status":return lp(e);case"stop":return gp(e);case"refresh":return pp(e);case"purge":return hp(e);case"service-install":return mp(e);case"service-uninstall":return wp(e);case"pair":{let o={};return s.env&&(o.env=s.env),s.handshakeUrl&&(o.handshakeUrl=s.handshakeUrl),s.frontierUrl&&(o.frontierUrl=s.frontierUrl),_p(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),yp(s.privatecode,e,o)}case"upgrade-helper":{let{runUpgradeHelper:o}=await Promise.resolve().then(()=>(zc(),Bc));return await o({targetVersion:s.targetVersion,oldPid:s.oldPid,...e.paths?{paths:e.paths}:{}})}case"send":return Rc({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}:{},...s.groupFile?{groupFile:!0}:{},...s.mimeType?{mimeType:s.mimeType}:{},json:s.json},e)}}async function Jc(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 lp(n){let e=n.paths??G(),s=new Oe(e),o=await s.probe();if(o.kind==="not-running")return process.stdout.write(`coze-bridge: not running
205
- `),1;if(o.kind==="stale")return await Jc(e),process.stdout.write(`coze-bridge: not running (cleaned stale state)
206
- `),1;let a=await s.request({method:"GET",path:"/status"});return process.stdout.write(`coze-bridge: running
203
+ `.trimStart();async function Q0(n=process.argv,e={}){let i=Mp(n);switch(i.mode){case"help":return process.stdout.write(Fp),0;case"version":return process.stdout.write(`${ht}
204
+ `),0;case"daemon":{try{await L0()}catch(o){return X0.error("daemon start failed",{err:String(o)}),1}return new Promise(()=>{})}case"status":return Up(e);case"stop":return qp(e);case"refresh":return Hp(e);case"purge":return Gp(e);case"service-install":return jp(e);case"service-uninstall":return Kp(e);case"pair":{let o={};return i.env&&(o.env=i.env),i.handshakeUrl&&(o.handshakeUrl=i.handshakeUrl),i.frontierUrl&&(o.frontierUrl=i.frontierUrl),Wp(i.privatecode,i.pairingCode,e,o,i.agentId)}case"connect":{let o={};return i.env&&(o.env=i.env),i.handshakeUrl&&(o.handshakeUrl=i.handshakeUrl),i.frontierUrl&&(o.frontierUrl=i.frontierUrl),$p(i.privatecode,e,o)}case"upgrade-helper":{let{runUpgradeHelper:o}=await Promise.resolve().then(()=>(j0(),G0));return await o({targetVersion:i.targetVersion,oldPid:i.oldPid,...e.paths?{paths:e.paths}:{}})}case"send":return z0({kind:i.kind,path:i.path,...i.agentId?{agentId:i.agentId}:{},...i.sessionId?{sessionId:i.sessionId}:{},...i.caption?{caption:i.caption}:{},...i.name?{name:i.name}:{},...i.groupFile?{groupFile:!0}:{},...i.mimeType?{mimeType:i.mimeType}:{},json:i.json},e)}}async function ed(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 Up(n){let e=n.paths??Y(),i=new He(e),o=await i.probe();if(o.kind==="not-running")return process.stdout.write(`coze-bridge: not running
205
+ `),1;if(o.kind==="stale")return await ed(e),process.stdout.write(`coze-bridge: not running (cleaned stale state)
206
+ `),1;let a=await i.request({method:"GET",path:"/status"});return process.stdout.write(`coze-bridge: running
207
207
  ${JSON.stringify(a.body,null,2)}
208
- `),0}async function gp(n){let e=n.paths??G(),s=new Oe(e),o=await s.probe();if(o.kind==="not-running")return process.stdout.write(`coze-bridge: not running
209
- `),0;if(o.kind==="stale")return await Jc(e),process.stdout.write(`coze-bridge: not running (cleaned stale state)
210
- `),0;try{return await s.request({method:"POST",path:"/shutdown"}),process.stdout.write(`coze-bridge: stopped
208
+ `),0}async function qp(n){let e=n.paths??Y(),i=new He(e),o=await i.probe();if(o.kind==="not-running")return process.stdout.write(`coze-bridge: not running
209
+ `),0;if(o.kind==="stale")return await ed(e),process.stdout.write(`coze-bridge: not running (cleaned stale state)
210
+ `),0;try{return await i.request({method:"POST",path:"/shutdown"}),process.stdout.write(`coze-bridge: stopped
211
211
  `),0}catch(a){return process.stdout.write(`coze-bridge: stop failed: ${String(a)}
212
- `),1}}async function pp(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)
212
+ `),1}}async function Hp(n){let e=new He(n.paths);if((await e.probe()).kind==="not-running")return process.stdout.write(`coze-bridge: not running (start daemon first)
213
213
  `),1;try{let o=await e.request({method:"POST",path:"/refresh"});return o.status===200?(process.stdout.write(`coze-bridge: refreshed
214
214
  ${JSON.stringify(o.body,null,2)}
215
215
  `),0):(process.stderr.write(`coze-bridge: refresh failed: ${JSON.stringify(o.body)}
216
216
  `),1)}catch(o){return process.stderr.write(`coze-bridge: refresh failed: ${String(o)}
217
- `),1}}async function Vi(n){if(n.supervisor){let d=n.supervisor,u={nodeBin:"",entry:"",logFile:"",homeDir:"",userName:""};return{platform:d.platform,install:()=>d.install(u),uninstall:()=>d.uninstall(u)}}if(n.skipSupervisor)return;let{getSupervisor:e,buildContext:s}=await Promise.resolve().then(()=>(Kc(),Hc)),o=e(),a=s();return{platform:o.platform,install:()=>o.install(a),uninstall:()=>o.uninstall(a)}}async function hp(n){let e=new Oe(n.paths);if((await e.probe()).kind==="connected"){process.stdout.write(`coze-bridge: stopping daemon...
217
+ `),1}}async function As(n){if(n.supervisor){let c=n.supervisor,u={nodeBin:"",entry:"",logFile:"",homeDir:"",userName:""};return{platform:c.platform,install:()=>c.install(u),uninstall:()=>c.uninstall(u)}}if(n.skipSupervisor)return;let{getSupervisor:e,buildContext:i}=await Promise.resolve().then(()=>(Y0(),Z0)),o=e(),a=i();return{platform:o.platform,install:()=>o.install(a),uninstall:()=>o.uninstall(a)}}async function Gp(n){let e=new He(n.paths);if((await e.probe()).kind==="connected"){process.stdout.write(`coze-bridge: stopping daemon...
218
218
  `);try{await e.request({method:"POST",path:"/shutdown"})}catch(u){process.stderr.write(`coze-bridge: stop failed (continuing): ${String(u)}
219
- `)}await new Promise(u=>setTimeout(u,500))}let o=await Vi(n);if(o)try{await o.uninstall(),process.stdout.write(`coze-bridge: ${o.platform} supervisor unregistered
219
+ `)}await new Promise(u=>setTimeout(u,500))}let o=await As(n);if(o)try{await o.uninstall(),process.stdout.write(`coze-bridge: ${o.platform} supervisor unregistered
220
220
  `)}catch(u){process.stderr.write(`coze-bridge: supervisor uninstall failed (continuing): ${String(u)}
221
- `)}let a=n.paths??G(),{rm:d}=await import("node:fs/promises");try{await d(a.bridgeRoot,{recursive:!0,force:!0}),process.stdout.write(`coze-bridge: removed ${a.bridgeRoot}
221
+ `)}let a=n.paths??Y(),{rm:c}=await import("node:fs/promises");try{await c(a.bridgeRoot,{recursive:!0,force:!0}),process.stdout.write(`coze-bridge: removed ${a.bridgeRoot}
222
222
  `)}catch(u){return process.stderr.write(`coze-bridge: remove failed: ${String(u)}
223
223
  `),1}return process.stdout.write(`coze-bridge: purged (agents workspaces preserved under ~/.coze/agents)
224
- `),0}async function mp(n){let e=await Vi(n);if(!e)return 0;try{return process.stdout.write(`coze-bridge: installing ${e.platform} supervisor...
224
+ `),0}async function jp(n){let e=await As(n);if(!e)return 0;try{return process.stdout.write(`coze-bridge: installing ${e.platform} supervisor...
225
225
  `),await e.install(),process.stdout.write(`coze-bridge: supervisor installed (daemon will auto-start on login)
226
- `),0}catch(s){return process.stderr.write(`coze-bridge: service install failed: ${String(s)}
227
- `),1}}async function wp(n){let e=await Vi(n);if(!e)return 0;try{return await e.uninstall(),process.stdout.write(`coze-bridge: ${e.platform} supervisor unregistered
228
- `),0}catch(s){return process.stderr.write(`coze-bridge: service uninstall failed: ${String(s)}
229
- `),1}}async function _p(n,e,s,o={},a){let d=new Oe(s.paths),u=s.spawnDaemon??_n;if(!s.skipDistInstall){let h=await qi({paths:s.paths});h.kind==="version-changed"?(process.stdout.write(`coze-bridge: upgraded ${h.fromVersion} \u2192 ${h.toVersion}
230
- `),(await d.probe()).kind==="connected"&&(await d.request({method:"POST",path:"/shutdown"}).catch(()=>{}),await new Promise(w=>setTimeout(w,500)))):h.kind==="first-install"&&process.stdout.write(`coze-bridge: installed ${h.libVersion}
231
- `)}let f=await d.probe();if(f.kind!=="connected"&&(process.stdout.write(`coze-bridge: starting daemon...
232
- `),await u({paths:s.paths}),f=await Vc(d,s.waitTimeoutMs??1e4,s.sleep??Xc),f.kind!=="connected"))return process.stderr.write(`coze-bridge: daemon did not come up: ${f.kind}
233
- `),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),a&&(p.agent_id=a);try{let h=await d.request({method:"POST",path:"/pair",body:p,timeoutMs:35e3});return h.status===200&&h.body?.ok?(process.stdout.write(`coze-bridge: paired (${h.body.note??"ok"})
234
- `),0):(process.stderr.write(`coze-bridge: pair failed: ${JSON.stringify(h.body)}
235
- `),1)}catch(h){return process.stderr.write(`coze-bridge: pair failed: ${String(h)}
236
- `),1}}async function yp(n,e,s={}){let o=e.paths??G(),a=n??await yc(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 d=new Oe(e.paths),u=e.spawnDaemon??_n;if(!e.skipDistInstall){let h=await qi({paths:e.paths});h.kind==="version-changed"?(process.stdout.write(`coze-bridge: upgraded ${h.fromVersion} \u2192 ${h.toVersion}
237
- `),(await d.probe()).kind==="connected"&&(await d.request({method:"POST",path:"/shutdown"}).catch(()=>{}),await new Promise(w=>setTimeout(w,500)))):h.kind==="first-install"&&process.stdout.write(`coze-bridge: installed ${h.libVersion}
238
- `)}let f=await d.probe();if(f.kind!=="connected"&&(process.stdout.write(`coze-bridge: starting daemon...
239
- `),await u({paths:e.paths}),f=await Vc(d,e.waitTimeoutMs??1e4,e.sleep??Xc),f.kind!=="connected"))return process.stderr.write(`coze-bridge: daemon did not come up: ${f.kind}
240
- `),1;let p={privatecode:a};s.env&&(p.env=s.env),s.handshakeUrl&&(p.handshake_url=s.handshakeUrl),s.frontierUrl&&(p.frontier_url=s.frontierUrl);try{let h=await d.request({method:"POST",path:"/connect",body:p,timeoutMs:35e3});return h.status===200&&h.body?.ok?(process.stdout.write(`coze-bridge: connected (${h.body.note??"ok"})
241
- `),await wn(a,o).catch(y=>Wc.warn("writePatToken after connect failed (ignored)",{err:String(y)})),0):(process.stderr.write(`coze-bridge: connect failed: ${JSON.stringify(h.body)}
242
- `),1)}catch(h){return process.stderr.write(`coze-bridge: connect failed: ${String(h)}
243
- `),1}}async function Vc(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 Xc(n){return new Promise(e=>setTimeout(e,n))}$c(process.argv).then(n=>process.exit(n),n=>{process.stderr.write(`fatal: ${n instanceof Error?n.stack??n.message:String(n)}
226
+ `),0}catch(i){return process.stderr.write(`coze-bridge: service install failed: ${String(i)}
227
+ `),1}}async function Kp(n){let e=await As(n);if(!e)return 0;try{return await e.uninstall(),process.stdout.write(`coze-bridge: ${e.platform} supervisor unregistered
228
+ `),0}catch(i){return process.stderr.write(`coze-bridge: service uninstall failed: ${String(i)}
229
+ `),1}}async function Wp(n,e,i,o={},a){let c=new He(i.paths),u=i.spawnDaemon??On;if(!i.skipDistInstall){let g=await ws({paths:i.paths});g.kind==="version-changed"?(process.stdout.write(`coze-bridge: upgraded ${g.fromVersion} \u2192 ${g.toVersion}
230
+ `),(await c.probe()).kind==="connected"&&(await c.request({method:"POST",path:"/shutdown"}).catch(()=>{}),await new Promise(w=>setTimeout(w,500)))):g.kind==="first-install"&&process.stdout.write(`coze-bridge: installed ${g.libVersion}
231
+ `)}let x=await c.probe();if(x.kind!=="connected"&&(process.stdout.write(`coze-bridge: starting daemon...
232
+ `),await u({paths:i.paths}),x=await td(c,i.waitTimeoutMs??1e4,i.sleep??nd),x.kind!=="connected"))return process.stderr.write(`coze-bridge: daemon did not come up: ${x.kind}
233
+ `),1;let l={privatecode:n,pairing_code:e};o.env&&(l.env=o.env),o.handshakeUrl&&(l.handshake_url=o.handshakeUrl),o.frontierUrl&&(l.frontier_url=o.frontierUrl),a&&(l.agent_id=a);try{let g=await c.request({method:"POST",path:"/pair",body:l,timeoutMs:35e3});return g.status===200&&g.body?.ok?(process.stdout.write(`coze-bridge: paired (${g.body.note??"ok"})
234
+ `),0):(process.stderr.write(`coze-bridge: pair failed: ${JSON.stringify(g.body)}
235
+ `),1)}catch(g){return process.stderr.write(`coze-bridge: pair failed: ${String(g)}
236
+ `),1}}async function $p(n,e,i={}){let o=e.paths??Y(),a=n??await A0(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 c=new He(e.paths),u=e.spawnDaemon??On;if(!e.skipDistInstall){let g=await ws({paths:e.paths});g.kind==="version-changed"?(process.stdout.write(`coze-bridge: upgraded ${g.fromVersion} \u2192 ${g.toVersion}
237
+ `),(await c.probe()).kind==="connected"&&(await c.request({method:"POST",path:"/shutdown"}).catch(()=>{}),await new Promise(w=>setTimeout(w,500)))):g.kind==="first-install"&&process.stdout.write(`coze-bridge: installed ${g.libVersion}
238
+ `)}let x=await c.probe();if(x.kind!=="connected"&&(process.stdout.write(`coze-bridge: starting daemon...
239
+ `),await u({paths:e.paths}),x=await td(c,e.waitTimeoutMs??1e4,e.sleep??nd),x.kind!=="connected"))return process.stderr.write(`coze-bridge: daemon did not come up: ${x.kind}
240
+ `),1;let l={privatecode:a};i.env&&(l.env=i.env),i.handshakeUrl&&(l.handshake_url=i.handshakeUrl),i.frontierUrl&&(l.frontier_url=i.frontierUrl);try{let g=await c.request({method:"POST",path:"/connect",body:l,timeoutMs:35e3});return g.status===200&&g.body?.ok?(process.stdout.write(`coze-bridge: connected (${g.body.note??"ok"})
241
+ `),await Ln(a,o).catch(E=>X0.warn("writePatToken after connect failed (ignored)",{err:String(E)})),0):(process.stderr.write(`coze-bridge: connect failed: ${JSON.stringify(g.body)}
242
+ `),1)}catch(g){return process.stderr.write(`coze-bridge: connect failed: ${String(g)}
243
+ `),1}}async function td(n,e,i){let o=Date.now()+e;for(;Date.now()<o;){let a=await n.probe(500);if(a.kind==="connected")return a;await i(200)}return n.probe(500)}function nd(n){return new Promise(e=>setTimeout(e,n))}Q0(process.argv).then(n=>process.exit(n),n=>{process.stderr.write(`fatal: ${n instanceof Error?n.stack??n.message:String(n)}
244
244
  `),process.exit(1)});