coze-bridge 0.1.63 → 0.1.65

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 -59
  2. package/package.json +1 -1
package/dist/index.js CHANGED
@@ -5,21 +5,21 @@ import { dirname as __coze_dirname } from 'node:path';
5
5
  const require = __coze_createRequire(import.meta.url);
6
6
  const __filename = __coze_fileURLToPath(import.meta.url);
7
7
  const __dirname = __coze_dirname(__filename);
8
- var L0=Object.create;var Wr=Object.defineProperty;var M0=Object.getOwnPropertyDescriptor;var B0=Object.getOwnPropertyNames;var z0=Object.getPrototypeOf,F0=Object.prototype.hasOwnProperty;var ee=(n=>typeof require<"u"?require:typeof Proxy<"u"?new Proxy(n,{get:(e,s)=>(typeof require<"u"?require:e)[s]}):n)(function(n){if(typeof require<"u")return require.apply(this,arguments);throw Error('Dynamic require of "'+n+'" is not supported')});var Te=(n,e)=>()=>(n&&(e=n(n=0)),e);var be=(n,e)=>()=>(e||n((e={exports:{}}).exports,e),e.exports),Jr=(n,e)=>{for(var s in e)Wr(n,s,{get:e[s],enumerable:!0})},U0=(n,e,s,o)=>{if(e&&typeof e=="object"||typeof e=="function")for(let c of B0(e))!F0.call(n,c)&&c!==s&&Wr(n,c,{get:()=>e[c],enumerable:!(o=M0(e,c))||o.enumerable});return n};var We=(n,e,s)=>(s=n!=null?L0(z0(n)):{},U0(e||!n||!n.__esModule?Wr(s,"default",{value:n,enumerable:!0}):s,n));function _s(n){return vn[ms]<=vn[n]}function Sn(n){ws={...n}}function bn(n,e,s,o){if(vn[n]<vn[ms])return;let c=JSON.stringify({ts:new Date().toISOString(),level:n,module:e,msg:s,...ws,...o});n==="error"||n==="warn"?G0.write(`${c}
9
- `):q0.write(`${c}
10
- `)}function N(n){return{debug:(e,s)=>bn("debug",n,e,s),info:(e,s)=>bn("info",n,e,s),warn:(e,s)=>bn("warn",n,e,s),error:(e,s)=>bn("error",n,e,s),child:e=>N(`${n}.${e}`)}}var vn,ms,q0,G0,ws,q=Te(()=>{"use strict";vn={debug:10,info:20,warn:30,error:40},ms=(()=>{let n=process.env.COZE_BRIDGE_LOG_LEVEL;return n==="debug"||n==="info"||n==="warn"||n==="error"?n:"info"})(),q0=process.stdout,G0=process.stderr,ws={}});import{chmod as nd,mkdir as rd,readFile as id,rename as Is,writeFile as As}from"node:fs/promises";import{dirname as sd}from"node:path";async function Tt(n){try{let e=await id(n,"utf8");return JSON.parse(e)}catch(e){if(e.code==="ENOENT")return null;throw e}}async function Tn(n,e,s){await rd(sd(n),{recursive:!0});let o=`${JSON.stringify(e,null,2)}
11
- `,c=`${n}.tmp-${process.pid}-${Math.random().toString(36).slice(2,10)}`;try{s?.mode!==void 0?await As(c,o,{encoding:"utf8",mode:s.mode}):await As(c,o,"utf8"),await Is(c,n),s?.mode!==void 0&&await nd(n,s.mode)}catch(d){await Is(c,c).catch(()=>{});let{rm:u}=await import("node:fs/promises");throw await u(c,{force:!0}).catch(()=>{}),d}}var Pn=Te(()=>{"use strict"});import{promises as Ts}from"node:fs";import{homedir as od}from"node:os";import{sep as ad,join as ue,resolve as Ps}from"node:path";function G(n){let e=n??od(),s=ue(e,".coze"),o=ue(s,"bridge"),c=ue(o,"lib");return{cozeRoot:s,bridgeRoot:o,libDir:c,libEntry:ue(c,"index.js"),binDir:ue(o,"bin"),pidFile:ue(o,"bridge.pid"),portFile:ue(o,"bridge.port"),tokenFile:ue(o,"bridge.token"),patTokenFile:ue(o,"pat-token"),logFile:ue(o,"bridge.log"),installLock:ue(o,"install.lock"),configFile:ue(o,"config.json"),agentsRoot:ue(s,"agents")}}function Je(n,e=G()){let s=ue(e.agentsRoot,n);return{root:s,config:ue(s,"config.json"),workspace:ue(s,"workspace"),logs:ue(s,"logs")}}async function Cs(n,e){let s=await Ts.realpath(Ps(n)).catch(()=>null);if(!s)return!1;let o=await Ts.realpath(Ps(e)).catch(()=>null);if(!o)return!1;let c=process.platform==="win32"?s.toLowerCase():s,d=process.platform==="win32"?o.toLowerCase():o;return c===d||c.startsWith(d+ad)}var ie=Te(()=>{"use strict"});var Dn={};Jr(Dn,{AGENT_CONFIG_FILE_MODE:()=>Cn,enforceAgentConfigMode:()=>xd,loadAgentConfig:()=>he,persistAgentSessions:()=>$r,persistAgentSkills:()=>kn,saveAgentConfig:()=>Se});import{chmod as cd,stat as dd}from"node:fs/promises";function he(n,e){return Tt(Je(n,e).config)}function Se(n,e){return Tn(Je(n.agentId,e).config,n,{mode:Cn})}async function xd(n,e){if(process.platform==="win32")return;let s=Je(n,e).config;try{let o=await dd(s);if(!o.isFile())return;let c=o.mode&511;c!==Cn&&(await cd(s,Cn),ks.warn("agent config mode auto-corrected to 0600",{path:s,from:c.toString(8)}))}catch(o){if(o.code==="ENOENT")return;ks.warn("enforceAgentConfigMode: chmod failed (ignored)",{path:s,err:String(o)})}}async function $r(n,e,s){let o=await he(n,s);o&&(o.sessions=Object.fromEntries(e),await Se(o,s))}async function kn(n,e,s){let o=await he(n,s);o&&(o.skills=e,await Se(o,s))}var ks,Cn,it=Te(()=>{"use strict";Pn();q();ie();ks=N("agent-config"),Cn=384});function Co(n){let e=n?.sessionIdleTimeoutMs;return typeof e!="number"||!Number.isFinite(e)||e<=0?eu:e}function ct(n){return Tt(n??G().configFile)}function Ue(n,e){return Tn(e??G().configFile,n)}var eu,Mt=Te(()=>{"use strict";Pn();ie();eu=10*6e4});var na=be(se=>{"use strict";var P=R;function nr(){let n=["CMvHC29U","wg9Nsuu","qw16vK0","yxbWBhK","Eg9rAM0","C3vIC3rYAw4","uwDLrKi","twvZC2fNzuu","s2ncAxe","yM9KEq","mhWXFdj8nhW","D3jiEhK","C2vUDa","Bg9Nsurhzw4","BIWGAg9ZDg4","Ag5zrLO","DhLnyvG","yw51Ce1LC3m","x2DLDeLUDgu","DgLTzw91DcW","DhjPzxmGCMu","EKvHDey","tg9Nsuq","CMvKDwnL","mtGXmLvQBhjqAG","rgXuCvm","zhLksxG","Eg9ZAe0","DcbSAw1PDa","AuzozNa","Aw47y2HHCNm","x25HDMLNyxq","wvHdze0","zMLN","yw1LoIa","y2fSBa","BwfUDwfSihi","rLDt","BM5Ly3q","r2Pfu1O","y2HnyxHdB3u","vhv6s0O","vhzoz1K","u0XpC1q","ruXnwvO","sNnVBNi","D3PhsKq","AenSB3nLrxy","u2vXsuq","B2zQq0q","CLbrqKO","yMLUyxj5","BNvTyMvY","AxmGDw5Kzwy","x3bPBMDqB24","vM9IAeW","wgPnELu","shn1qxu","s0Tsr0W","ExbL","s0vVswG","Be1yvhu","zxH0ugf5Bg8","B2nRzxq","qwnMy0m","yw5Nzq","q0PNCM4","BgjzC1e","zxjFCw9Z","rg9JDxe","B25JBg9Zzq","A2zqrLu","BKv4t24","q3DSzgi","B2XKvMvYC2K","yM9L","B0z0wfq","tg9NsurozxC","BfDyDuu","zNjVBunOyxi","A01Yr2C","CMvTB3zLq2G","DLvWwMy","z2v0u3rVCMe","q2vfzK8","DvnRChe","A0LLBK4","x29WDgLVBNm","vLHttLe","yMTdwhO","B3bLBKrc","AevYCM9Yrxy","qvznENi","ALf2uMO","sgPKtwm","zxHWB3j0CW","CKXuuw0","zNDZxZeUmc4","tLfxtKS","uM5Pzxe","y29UC3rYDwm","DM9Vt2K","C1zTAxm","BNrfBMrWB2K","v0fhwKe","wNvhCe8","tgvxwgK","A2v5CW","zxjFCw9Zx2e","vgfwBgW","suPZweq","yuv4qxy","A0fjAxO","sLjWC1a","CMv0CNLdB3u","Evfhte8","ywDL","q0TTwfG","DhDVCMTdAge","we5dqw0","BenTuhm","q1rQCuO","t1bftG","BgvUz3rO","whrSuNC","y29Uy2f0","vuTuEuS","rxjYB3jdB2q","qw1VDw50","B1zIvKS","BMDLza","yw1L","s2LIzxu","ywrKq291BNq","r1z0Exy","rMvbuMS","rxjSr2G","y3vYC29Yx2y","z2v0sxrLBq","D0P6A3C","v1DUq04","BgLZDgvUtMu","tffuy1a","zNjVBNrPzxi","Cgf5Bg9Hza","txncsgS","qNDuBgW","ExDNr0q","ywDLu2HVDW","yMXVy2TLza","vfLgChq","y3vYDMfSDwu","x2nSzwfYvgK","u3bjru8","AwXK","Dw5RBM93BIa","t3bLBKv2zw4","De1HBMfNzxi","ExHsyxq","zNjHBwvuExa","y2LurLm","u3ndDei","vgHUrwe","v0H2uvC","zxjYtxnN","y3r4","AMPpyM4","B3jRzxjhBg8","DhjPBq","zNjVBuHHC2G","qNfXwKm","zxj2AwnL","EhbTwe0","tgLZDgvUzxi","yM5qq20","Dg9tDhjPBMC","B2fK","B25nzxnZywC","q1fQteq","B25pCgvU","sgvKBuq","svfXAgq","Ec1TC2CTy3u","C3nHz2vfDMu","s2HzwgK","rNPUC1O","zgLKvhK","B3jpBMXPBMu","BLrADeG","tLf4twS","BMrLEa","y29SBM8","CKvIvge","vKzrEwG","sxrmEuy","B2rJC0G","lcbOB3n0BMe","zuPRqxq","qu5nEK8","Eu1ACMu","r2LIsfm","zhLlELi","yu5uruO","B3LMtLe","C2XKsKq","EM1evee","uLDTBKu","CMvHzhLtDge","u01XCNe","zfDVCMTLCKC","B2nRzxrgywK","CMvHzfvjBNq","x2LZqNjVD3m","Bhm6ia","uxzAv1i","u1fssvq","z1zcDgG","y2XLyxi","EwP3sxa","ywrTCg4","vfHOwwW","EuPKAfi","BuPet1C","vwf2AMy","zNbMr0K","igfYCMf5yNu","D0TKDKC","nJuWmwL3EhnMvG","CeDMs3y","z2v0q3vYCMu","tNDtqw0","B3jL","Ae1RrK8","vvv4Bfa","Cxf4teG","sLDgrLi","Bxjpuu4","yNvOCwW","zvP3B0C","Ewjfv0m","mxW0Fdb8m3W","C2v0","BgvY","AMTQAe0","u1HhrNe","teXtwue","EMDHruK","BwvY","CLvUq2K","twLZC2LUzYa","rwT4rwS","C2v0q3vYC28","qKLpt0W","BMv4DcGPigm","zwHHu1i","pxv0zI04","DMvY","BurfuLe","B25SAw5L","qMvkvuW","z3zzAeK","DLnVzM4","vw5PBxbSzw0","mNWXFdn8mhW","CxPSENO","u3PhCgm","BfrPBwvVDxq","mtjku2zcv1a","qLzeDLe","DuP5v2W","B3jLtMfTzxm","qwPJBfm","Bhb3swq","y2XVC2u","x2LZv29YA2u","ELjTDuG","y29UBMvJDgK","x2nVBM5Ly3q","Aw50zwDLCIa","s0f6tMW","Ee1Tu3q","B3bLCNr5tMe","yNL0zu9MzNm","whrSzwi","r0zyBeq","Dhfstgu","CNnVCL9Uyw0","AxnFywnR","x2rLC3rYB3K","y29UBMvJDa","zxrMB28","ywjVCNq","z2vjBMzVu3K","sLfYDwO","ENPgvfK","rMPquM0","v1zywuW","uK5Hvxu","zg9Uzq","tKLzswy","z2Dpzfy","EKfoB3i","B3bLCNr5","AKfyDxy","senzugu","rwHyrK4","t05OEuq","AwXSihvZzsa","A2rnwNe","Cgf5Bg9Hzfq","B2zM","uhDWDu0","zxf1ywXZ","sKXMA1C","B3bLBG","x2fKzfDZtgK","Dgv4Dc9Qyxy","rLb3D2u","C2zKq3u","A2v5","BMvJDa","BeLwwuO","wwfou2O","wwHjqLy","ywnRtxnNswq","qLHLsLG","x3nLCuLK","r0vrBwS","zMX1C2HfEha","DNLgwee","AgvHzgvY","tKDFrvjst1i","yKXjru4","ywXSq3vYC28","x1fVu01HBMe","AgXLDgy","C2DPza","rvboCxu","swnmsw8","rMD0BuK","BNPYtvm","tKXpBwO","uMf5wLi","sMXvwfy","vxDNA3C","yuTgqK4","u2XLAKy","x3DZsw5ZDge","zhjhuKi","m3W1","BwLZzq","EurbDNu","A1vsrMK","Aw5N","wNvAwuK","Dunryuq","sKL5uKe","qwDOzNu","x194x21Zz18","qLrwBfe","sezvtKK","rwHiD0i","C0Xf","zxjFywnRx20","C3rYAw5N","wLLXAha","u2LdyLi","ufzXzxe","CKXYy1K","zNrUz0u","vgX6Cu0","swn3rLC","Dhr3Awq","Cg5tEhC","vvPiBvm","vvj6s0G","runfA1K","x2DLBMvYyxq","s1HYtKW","rhzQuKi","C0TiyKe","ug5ozvK","Bg9N","B25fCNjVCG","yw1Lu3bHy2u","mNW0Fdb8nxW","Cvbnwvy","x3jLy29UBMu","yMLUza","z2v0q3vYC28","Bgzsy1G","y3vYCMvUDeK","BMrWB2LUDca","uvbRugG","rNnVAwS","C3rLBMvYCW","D1LVvK8","vwzszg8","CfrVDeS","zM9Yy2u","tNnLrvC","y2XVC2uSihC","teLiEgu","zNrWExy","C3vIyxjYyxK","ExvusgG","y2XVC2veqG","tg5hvwm","Dg9cExrLC0W","ChzYqKu","BuPdEM0","tKT3wxi","vur5thy","t2PtvvG","wKjSEuq","x3bYB3rVy28","sMzwrNu","x3jLBw92zvC","BezSDxnO","tNrjqNK","y09Wzw4","y29UBMvJDeu","q3vZDg9Trxi","rvz0z0y","z2DAEu4","Ew1ttxa","BMCGzMfPBgu","DxvgsNC","zMLSzw5HBwu","C2vYDMLJzq","y2HHCKnVzgu","rfrnzuW","tKfusvzfx0u","zMzMzG","zcbLCNjVCI4","vK5AB2u","s1L1vwq","qMXfAhu","sufkBgu","uwzfzLu","D24GCMvHC28","x2HHBMrSzvi","rfvlA2e","z2v0","CKzQuNK","r0rqzvK","DLv4Bvm","DxfXDwW","nhWWFdu","DMvUDa","wffbC0S","DMfSDwu","v3jqChK","uNjAt3K","zMvY","BuzQtfy","zNjVBujPDhm","Bwf4uMv0CMK","zMPewui","z0zIBhG","y3vYC29Yx24","AxvUv0G","vgTTz3m","wwDVzvi","Dxrjza","Eenwrwe","CMfNzvn5BMm","su1pD1y","Ew1VDu0","zvzmAhq","Dhvdqve","zgvSzxrLrge","veXfseG","t0Xwtwy","u0XQwwW","B1Lxwge","Eun2uM4","zcWG","C3HcCw0","EeXXwxu","Aw9UvgLTzw8","BNvAtee","vev4r3O","zKzrqKK","rfnWAgG","uKz2zvy","C29YDa","ugnuuNi","q3zqBe4","zgvS","AhDuuvG","ihrPBwvZ","sNDUzuK","rxPys2S","ufHkAwe","zuLzvwG","y2HLy2TdDxi","BuLvEKC","CMvJzxzPzwq","BuDiwMy","AwXLx25HBwu","v1DUD2C","EMf1whK","sNzVuuS","uvDHsxG","rxPHz3e","AgfZ","ywnR","CgLUz1rPBwu","AgLNAa","x21PBMLoyxy","v0jtsLe","zw5HyMXLqxu","v1fWv2q","yKT3wxy","x2LZtwLUAvq","Aw5KzxHpzG","sxjTCMm","zxjFBxnNAwq","zgvMAw5Luhi","y3HHtg4","y29TCgXLDgu","wvPLvw8","qvvpy3u","yvnnzLG","zw1LBNq","uuTdzxq","vvDwzNe","vNPeDeK","x2LZsw5PDa","v0nJDKC","tMfTzq","x2LUAxrqCM8","yxKSig5LDhC","qKvztwu","zv9ZDwnJzxm","svLyz1m","yKDssfy","Ee9JwuC","uMvJB25Uzwm","B2zMBgLUzq","vxnuufy","uhbPq0S","qxLXz0S","sLjQBMO","rw1Jsee","zwnVBM5Ly3q","ywDLsgLKzq","D05iuuq","z0zLs3K","yLD1yum","rwz3s0C","B256zfe","yxHRs3y","CM92AwrLige","zeTXBeu","u2HHCMvKv28","u0fms3y","y3jLyxrLq2W","zvLeC20","x0rctMfTzq","zwHprge","BgLUzq","vKTSr0u","CMvUDevUzha","DKPQCNC","tvnpB3C","sxz2zM8","vNngueC","AxnmB25N","t2jMzLK","z29dqKq","r1ncCwC","x2HHBMrSzu8","zMLSDgvY","D3jPDgu","mhWZFdf8nhW","C3rYAw5NAwy","wezysgG","u2TPCcbWyxm","DeLUDgvYy2u","wgnmtuK","C3vJy2vZCW","CeHKBNq","qKnvs1y","CKX0quu","tePZt1e","AxnrB1nnzxm","r1rXsxK","C2DIzfm","zcWGDw5RBM8","BMCGB3iGyw4","yxrHlcbKyxq","rvL0v2W","rwPtAM8","AxnbCNjHEq","rvDprNe","qw9vy1K","ywrKrxzLBNq","CNPWrey","zw50tgLZDgu","ywPLAMC","De5pr1a","DMHUAxu","CgXLyxnLiha","vLfLww4","qvDxBe0","BMvY","nde3ntj1y3jJqxO","yxrLq291BNq","u0DAEwC","wxbxruK","v052uwW","zgTzrgO","x2rYB3bhBg8","DhDQC0O","zunyt2u","x3bYzwzPEa","rgjsrve","Ae1LC3nHz2u","ywXSB2nvBNm","uhz0u3u","wu16CMi","y3zmBMy","zMDAEKi","C2v0zgi","D0DVwee","u3bgEei","yxbWzw5Kq2G","y2XLyxjtDg8","uMfcrhG","uLPMwLK","DvfiBxi","q0zuBxO","qLjcq24","t095CvG","vhDewui","quXhtKq","BMjQyLK","y0zUyMm","qMD2CNK","y2f0y2G","AfHJueG","rxPQwva","x3nVy2TLDa","qK9ry0K","zw5JB2rLrNi","yxjuD3a","rKLmrv9ot1q","B3bLBIa","zMPbuhO","sLzHvum","yLjoDMC","suvtx0vsuK8","DeH4vwK","rxLcve0","x2n1CNnVCKy","zgf0yq","EeHICNq","zNjVBuj5Dgu","yNL0zuXLBMC","svPbCfK","qKHOzfG","CM92AwrLigi","BM55sKu","CNj1sMm","qxPpvgG","y2vZC0HHBMq","C0XPC3rLBMu","y29Kzq","AefJA01LC3m","tvvWtfy","sg5ru0i","ru90B2m","t3r2CK8","Cg93","ywnRpwzYB24","Bg93","DMvYrgO","ywDLrxzLBNq","zxH0zw5ZAw8","zen0wM0","DgvZDa","CK5oqwm","u213rfC","zK1Yzu4","zvnLyKO","z05VD2K","B2LUDfjLywm","uhPmv1e","z3vOD2m","Dgv4DfbHEwW","yMLUyxj5vhK","tNbAzuK","B3nLrxzLBNq","u25ZBxq","BwvZC2fNzv8","yKfIEeW","tw5nwLe","txn2v3i","EvjLy29UBMu","zMDpyNu","z2vY","zNzTBMG","DMfSDwvZ","v21lChO","B3vUDa","sfnVAu8","zv90Aw1LB3u","A3fVDva","verKEwK","rvjst1i","ihzHBgLKigq","B25TzxnZywC","zvniANm","DMvYC2LVBMm","v1LJDgG","vhPotgi","l3DZl3yY","sMrNqwy","y3ruAw1LB3u","Cu5uqLG","qxziDMC","Ef9MCM9UDgK","DxjS","v0PJAMu","EuHHq0i","CunKu3e","r3PbELy","vhPVCwC","BwfW","BKXPBMu","CM92AwrLihC","CxjcuKO","rgHdrhq","sgfRvNK","C3jJ","BLHKAeW","uuDgq00","x19LC01Vzhu","BeHHBMrSzxi","Euvrsge","q2jkq3m","EMz0B2O","uKTkrgC","zwXsy1O","BxHcruG","we5Ks1e","DxrVuMvJB24","x2rItMfTzq","CMvXDwLYzwq","uLjpuG","DeLyy0m","yxKSihrYEsa","CNnVCKzPBgu","yKLkENe","yKvZq3u","q25ms3y","q0Xpu0ve","C2jevwq","otG0mZHtB0zVu1a","qwjVCNrfCNi","DMvYC2LVBG","qNf3vwi","BwvKAwf0zwW","AgfZt3DUuhi","DffeDuK","D2LSBfjLy28","thbVveC","CM9YrxzLBNq","CMvJB25Uzwm","tNfXsMq","BNrLCG","rxPOyKe","s0Xyu1O","yNvMzMvY","Cw9Zx18","BhrPCgXLihq","Cgu6ia","B25VCgvU","r1nJBK4","Cg9PBNrdB24","DxPMyNm","re5zB1G","z0TYuKW","BMjHqKC","CgLUz0LUDgu","A1fJseW","q1Pvy0W","CgfNzwHPzgu","mta4mdH5wxjStha","s2vkz2W","z2v0qwXS","DfnxEuC","AxfvsMC","DhHNEMS","DeLK","ChjVDg9JB2W","CePdtMq","tw9KDwXL","DhjPzxm","ve5Auxm","CgLUz0XVC3m","yuDRz0m","zMzLCG","AM9PBG","DNLmCgm","y2HnyxHuCMK","Cfj2BhG","ywnRx2LK","BMCGDxjSoIa","Dw92s08","u0TJB20","r05etvK","Dvfjs00","D1bVueq","D1bNqu0","Ae9XwMm","Dev2zw50","CMvQzwn0","x3fVC0rc","uLjgy0O","B25dBg9Zzq","C1r6tuO","zgLZywjSzue","DxrMofDYAxq","CMnID0W","C3bSAwnL","DgHLBG","rvbICLO","CLDzAMu","tuvtu0fhrv8","vw1Ys1y","A1fvAKq","wg5dz0y","rg9qAwi","DgfIyxnL","y3jLyxrLtwu","zgfZD0C","t0nwsfm","ugPIvxO","rhbxD28","Cevhruy","Ec11C2uT","sezgyKW","CMzovfu","B3nLza","t2ngt0O","Ehrwzw0","DwHOweO","zgvJB2rLzey","ywzL","B3DlC2K","ywrKt25L","Aw1LCYbPBIa","yxGGCMv0CMK","v3HoD3e","y29UBMvJDfm","y1PHu1K","BMnVzgLUzW","rNbSquq","zw5XDwv1zq","Cg9PBNrbBMq","z3LvAxC","BKHzDvm","B0DXCue","sgPnrvq","AhH2yxi","tufyx1jfvfi","s2Lmv2G","Be5xz3y","DhzoCNi","ChrVCG","x29UrxjYB3i","yxnL","CMvWBgfJzq","nhWYFdD8nq","vNrRCwm","BMvLzf9Hy2S","yxjYyxLIDwy","x2jPBMfYEvq","zwrPyxrLBhK","ywnRx2nVzgu","z213EgK","lcbTyxGGCMu","rLvqD2u","z2v0s2v5","BMHrDuW","DxbNCMfKzw4","Bwv0Ag9K","zM9YrwfJAa","CNjVCK1LC3m","t3zHvve","te5KAwm","q09otKvdveK","DKTzrem","Ahf5uMS","ELDbAei","ExHLzLK","ywnOzwqSihC","CLHjDMC","quDss0e","CMTmDwu","sMPOAKG","vwz4Ahe","wwz2qvq","z2v0qwXSs2u","DgHHBIbSB2m","DxbKyxrLq3u","y3vYC29YlNm","s1zxBhq","CLb0zwO","x3jLywr5q2W","CMvHzhDYAxq","AMXcAxm","C2v0sxrLBq","q3vZDg9Tq2W","zw5JB2rPBMC","zgnls3C","ALftzMm","B3PHBLC","Cw5dz1e","tfnTwgy","yNLL","CIb0DhDjra","vNPqD1i","DLziqxa","EfzgsMW","D3m6lY8","zxbnuLG","rgLXuLa","A0LZuuu","x2XPC3rLBMu","rNjVBNrPzxi","x2vUzhbVAw4","CMvWBgfJzui","B2jQzwn0u3q","x29Uq2XVC2u","D0zoue8","tuvurLO","AffPvg0","tvzUC3C","EvP2vLu","CNnVCL92ywW","suXhCM4","Dg9cExrLC0i","EM5QCNO","r2XWsg8","CgfNzxnOB3C","y29UBMvJDca","wuTrwNm","sK94r2m","vNP0tum","wKTyAuy","DeDTsLi","DhP0y3C","Aw5JBhvKzxm","Dw5KzwzPBMu","zw50","q291BNq","nNWXFdj8m3W","suLkzuG","y1zeChC","Ahr0Ca","q25dquy","z3v3qKm","vwLuu3G","uxvLDwu","qLP3CKG","y2nQEwu","mdaWmdaWmda","tNPXswG","uwvYAfm","sM5ICfC","ELPktLm","CMvZB2X2zq","zw1PDa","sLvVAuK","D3jPDgvvAw4","DK53qvy","y3vYCMvUDeu","ve9vEMi","Bg9NsurozxC","qufIzwi","C2v0u3rVCMe","uwHoqM8","whbHC1y","z09Xu3O","x3DZ","r3PYwNu","zxq9DxrMltG","ufnLvNO","x2HHBMrSzva","jMPZy2fSBgi","ten0v0G","CMvZzxrfBMq","BvPSvvC","zgjXA2S","CYbHBhjLywq","ywXty29Wzq","x2nSzwfYugK","r29pvNO","CMHgv3q","CMfTugfYyw0","zwn0","AwDHDg9Yt24","yNL0zxm","y3DmAvi","tMTosgK","D0TNB2S","EuvQtgq","ChvZAa","CgLqvfa","y3zRB0m","wwjms3O","DhfeuwK","x29UtwvZC2e","yMfSu2nVCgu","B25ozxr3B3i","AuruuKO","x2n1CNnVCK0","vgLTr1y","ywnRDxbfBMq","Dw5ZAwDUzwq","ALD3y1y","rxnMwva","AejxveW","BgLTAxq","yvvtvwG","q29UzMLN","x2nYzwf0zvm","y3ffAfq","CMPztfC","x21LC3nHz2u","zw50zwqGDhK","yNbRy2e","vurHquK","v3zIwg4","DhLWzq","wLvkufK","CgLUz09Uy2u","x2LZtM9Kzq","thbTEM8","Aw9U","rxDJCvG","seHXzNq","u29pvNq","yuDNvgW","Bwf4tg9ZC0m","uenhAgi","mZmXmta4mhzXCND1vq","DNDeAwm","CMfTzq","DgLUzYbZzxi","swroB1y","mxWZ","D2fZq2XLyw4","u0jYuuW","x29UugfNzu4","CKLesxC","Dxv1uKm","uhjPBwfYEuS","A1bbv1m","EvjVzxa","tg9JAW","BgDuDMy","yxv0B21HDgK","EMfmDhe","A0zXrwu","vMn1Dgm","v2vPEgLUsLm","A0TPDgi","Bvberei","yxnZAwDU","vw5Oyw5KBgu","Ae9Wzw5fDMu","ywX3yxLZ","AfD4q1e","Aw9Ul2PZB24","C3rVCMu","ENfPr08","u3vkELu","yNfQq2O","v0nmrge","Aw5Lza","BwH0vfO","uMnys0y","zM1hv3u","DMLJzuLeig8","x2LZtwLUAvC","C2v0y3vYC28","sfLcrKe","EfD4BNC","A1n0yxr1C0m","CNzHBa","x2rPC2nVBM4","zvvYBa","EfDUDwi","BfbcD0G","mZa4nZiXmfjOChrtCq","sLnptLa","BMrJuva","Aw5PDcbrB1m","C3rVCcbPBw0","qKPxCuK","q1DmyKy","z1rPBwvVDxq","vgPJywi","veH0rhu","r0jWsNe","Ee5xBM8","uef1vwq","y3jLyxrLt3a","C3rHCNq","x2n1CNnVCK4","x3bHDgHlzxK","BwLUzW","AxnszwfKEq","u0nutKC","EuL1zeC","t1DUANC","Eejku0m","z3PgBNu","Efrurw52","q09oveLovuu","zLHKuhy","B2zMC2v0","Dg9mB3DLCKm","t0f3r3i","rujPELG","y1jdA08","u1Pfreu","wwLMD3i","zw5fDMvUDa","BMDuAw1LCG","mZu1oermBvfVBG","ywnOzwq","tKr1zvK","y2uGBM90igK","Ce9oy0y","x3nLBMrby2S","mdaWma","ihrPBwvVDxq","veXbsuy","yvDJAue","qxfZCfi","t2jQzwn0","su5tvefova","B2jztKi","AwXLtMfTzq","zfnLwgu","CYbPBNn0yw4","DfDTDwm","vfzyB2W","yw5ZzM9YBvq","ywrK","BwvZC2fNztO","x3vYBa","zxjYB3i","quPXBhG","suHMCKC","DgLTzw91Da","swXjuuy","BMfTzq","yuDHvuK","runkBum","zxjHDg9Y","EM1pthC","Bwzxt0G","y291BNq","zMzmAw5L","yxnJCMLWDa","Cu9tBLC","uLbKzuq","BMnLq2XVC2u","tNfhCvi","shHkB2e","vLLSzKS","v05AEMC","uhvnyw0","uuvfwKu","yvrqr3y","r1bRAM8","CNDKrfu","zxrxB3jRq2G","tgjgu1i","AxnAzxjV","u2HdB2C","vNn1zNu","ru15Be4","z2v0t3DUuhi","y3jLyxrLrxi","zMLUza","ALrjBfm","AxnrB1nby2S","zufJAW","t01rr3O","DffksMq","EhDqB1a","Aw5KzxGGB3u","ExfmDNC","zMLHEeK","yMDXzNe","Egf4BvK","B25LCNjVCG","BLvSC3O","zw5NDgG","CMfUzg9T","s1vqDMO","B0HbCwG","EhbbDMe","u3rYyxrLz3K","r3ztwfK","BwvZ","tvnMvxC","igzHAwWSig0","yMrFzgLK","B3jRig9MzMW","BNLsB1C","BKDTt2G","yMfSrxzLBNq","ysbTDxn0igi","zxjFAxnFywm","s3jPy3G","CLbzAeO","sNbVB1C","CMvHzg9UBhK","tLrHrwK","C2fNzq","uKLuB2u","DvvKAgy","zujyvMK","ywr2yw5Jzq","wxzytwO","yMfJA3vWigu","wNzwDeO","x2zVCM1HDeu","AgvHzgvYCW","zM5yuM0","CMLLC0nVDw4","Bxv4rwW","y3jLyxrLuMu","BMXHAw8","Ahbwwui","x3DHAxq","C0nsq0u","C0jf","rKTnDLi","CMvZDwX0","Eg1AsuG","DMfS","svnYtvO","vgfN","x2LUDgvYDMe","CgjICdi","sNvJCxm","zMXYzwS","ufnABKu","zxjYtM8","ChPqsNy","sfz0AgO","y29RAeC","y3vYC29Y","vvbNtg8","y3vZDg9Tshq","rgvKAwnHDgu","yw5WvgO","CLzHBhvLCW","CMvZzxrdB3u","zgvSzxrL","Dw50","ze5nDvy","u3bSr08","uhb2suy","Dur4Cxm","C2vYDMLJzs0","rK9gD2i","ANrgwgW","CNzHBfzHBhu","C1nzuhu","Au5LBeu","qw9hwMS","v0nmy3y","y1flsKy","AMvJDfn0B3i","AMTqDe0","Cgf5Bg9Hzeu","BMrWB2LUDfq","yNvMzMvYzwq","ywXYrvq","DxnLCKLW","qwDlz1u","t0P3zgG","igzPzwXKoIa","ihn1y2nLC3m","Axnby2TdBgu","zwn0v2K","y2HLy2Tszwe","swD3A2e","z29PBMCGyxC","z2vrDwv1zuW","A2v0ignVBNm","BxHKveS","v2TVAxm","igXHCMDLCIa","Ahr0Chm6","D3vfugu","C2vYDMvYvgK","EgT4DNm","DhjWwgS","icSG","Aw5L","DgLLCKPtt04","A3rhugS","B25szwnLAxy","AgfUz2u","ihzHBgLKihm","sxH5rKq","BLPtqLi","z0PkrK8","r1DkBMS","zNvUy3rPB24","Avz1zNm","yLrVAu8","ihjLy29UBMu","id4G","yK5ZCfG","D2vI","r1rmAui","EMXUr3y","A3nICNC","C3bSAxq","odq4BLfkz1bI","zNjVBu51Bwi","Dwzrrvy","AerIrKK","vxbKyxrLq28","AxjLza","EfnZsva","BgLUzw5V","x2rPC3bHDgm","x2LUAxq","y0XsuNy","rvPHCuW","Ew1HAum","zu1fCxK","BNrbBMrvCgq","rKjQu28","DNvKD08","BNruCMLLC0m","x3bPBMC","vvfoseO","C2XPy2u","BM93","DLLky0m","C0nVDw50zxi","C29Tzq","txbAwei","tevjAKi","t1bftL9fuLi","CfDUAvO","D2PQtKq","BxnN","rxzLBNq","runhEKG","z2vtEw5J","uwn1q2G","B21yCwG","zxjFDhrS","B3v0sw50zxi","v2zVqMu","s05oDgm","zw5KCg9PBNq","qLrvthy","Bu9qC0q","C1PcDva","vgLTzw91Da","BLfHrK4","B2nRzxrtDwm","BwrIvLK","yw5Hz2vY","CxLfqvG","yvbryuW","mZy3mZjRtwXdvLe","yxv0BW","thfmtfK","rMLYD1q","DcbVzIbYyw4","u2zptKi","s2fSANG","vKDtr3a","BhbKsLy","x3bPBMDmB3m","Dg9oDw1Izxi","BwPrEey","mti1mwrUvfj0ua","zu5gt1m","x2rLyNvN","Dg9Y","BwvZC2fNzq","Au5MB0m","Dgv4Dc9WBge","B25tDgfYDfi","Bg9IywXty28","y3bqqLm","x29UvgLTzw8","DhjHBNnHy3q","zgDyEMW","wKHmELe","s2Pxwha","zxmGCMvHy2G","A09ms2u","BvLcuMi","AeLdBgy","ywWGy3vYC28","CgLUz19VBMm","sMDzr3u","Dg9cExrLCW","CMvTB3zLrxy","uMXeugC","yLvMuMS","ChjVDg90Exa","BMnlqNi","q2Ddz1K","zgrjrcWGzgu","tNzSruy","wNr4u1e","DxrXCfG","yxbWBgLJyxq","uxn5yNa","x29Ut3bLBG","CgfYC2u","quXm","z2u6ia","Dg9iyxnO","BerfCMm","BuvbqvO","ENnTsuK","Chv0","B25tDg9Wsw0","rLfIswW","AgvKtwf4uMu","tvnzyLe","vg1lzLi","wu1WqLa","y29UDgLUDwu","EurHqMO","C2vUza","x2LUAxrhBg8","u09IuuW","uejcwLi","q0Xpu0LorW","Egzbrwi","zwvKzwq","v2vIu29JA2u","vKPOthC","A3POshy","r0TZq2C","q29Kzq","uMvHzcbWyxm"];return nr=function(){return n},nr()}(function(n,e){let s=R,o=n();for(;;)try{if(-parseInt(s(783))/1*(parseInt(s(290))/2)+parseInt(s(1158))/3*(-parseInt(s(1355))/4)+-parseInt(s(1122))/5+parseInt(s(1507))/6*(parseInt(s(813))/7)+-parseInt(s(631))/8*(parseInt(s(1418))/9)+parseInt(s(1073))/10+-parseInt(s(250))/11*(-parseInt(s(1406))/12)===e)break;o.push(o.shift())}catch{o.push(o.shift())}})(nr,421504);var Zu=Object[P(542)+P(325)],ef=Object[P(1213)+P(304)+P(1236)],Xo=(n,e)=>function(){return n&&(e=(0,n[ef(n)[0]])(n=0)),e},tf=(n,e)=>{let s=P,o={AUOcu:function(d,u,f,h){return d(u,f,h)}};for(var c in e)o[s(546)](Zu,n,c,{get:e[c],enumerable:!0})};function nf(){return Wo||(Wo=[IDBDatabase,IDBObjectStore,IDBIndex,IDBCursor,IDBTransaction])}function rf(){let n=P;return Jo||(Jo=[IDBCursor[n(1444)+"e"][n(1255)],IDBCursor[n(1444)+"e"][n(1468)],IDBCursor[n(1444)+"e"]["continue"+n(1084)+"ey"]])}function sf(n){let e=P,s={BEYMe:"success",XFXHh:e(1181),AoGZk:function(c,d){return c(d)},Tjcab:function(c){return c()},lIVYJ:function(c,d){return c(d)}},o=new Promise((c,d)=>{let u=e,f={wJzkw:function(b,E){return s[R(344)](b,E)},RIToe:function(b){return s[R(1130)](b)}},h=()=>{let b=R;n[b(1441)+b(623)+b(630)](s[b(557)],p),n[b(1441)+b(623)+b(630)](s.XFXHh,w)},p=()=>{let b=R;f[b(1622)](c,f[b(1622)](Ge,n[b(1271)])),f[b(1252)](h)},w=()=>{let b=R;s[b(1304)](d,n[b(1181)]),s[b(1130)](h)};n[u(621)+u(196)](s[u(557)],p),n[u(621)+u(196)](s[u(601)],w)});return o[e(851)](c=>{let d=e;c instanceof IDBCursor&&fi[d(264)](c,n)})[e(664)](()=>{}),ir[e(264)](o,n),o}function of(n){let e=P,s={pWniZ:"complete",kzhHv:e(314),ObffY:function(c){return c()},aqRSQ:e(1607),IlIQF:e(611),EkxEk:function(c,d){return c(d)},zgaEI:e(784)+"or",LbFSR:"error"};if(rr[e(529)](n))return;let o=new Promise((c,d)=>{let u=e,f=()=>{let w=R;n["removeEv"+w(623)+w(630)](s[w(1383)],h),n["removeEv"+w(623)+"ner"]("error",p),n[w(1441)+w(623)+w(630)](s[w(1479)],p)},h=()=>{let w=R;s[w(593)](c),s[w(593)](f)},p=()=>{let w=R;if(s.aqRSQ===s[w(1185)])return new _0x112018(b=>{let E=w;_0x317e41(b,this[E(1501)+E(1301)+"e"](_0x1db121))});s[w(273)](d,n.error||new DOMException(s[w(269)],s[w(269)])),f()};n[u(621)+"Listener"](u(544),h),n[u(621)+u(196)](s[u(1208)],p),n["addEvent"+u(196)](s.kzhHv,p)});rr.set(n,o)}function af(n){sr={PcTRr:function(o,c){return o(c)}}[P(510)](n,sr)}function cf(n){let e=P,s={yQGLO:function(o,c){return o(c)},pnSxw:function(o,c){return o===c},xxbDY:function(o,c){return o in c},CnZOH:"objectStoreNames"};return s[e(396)](n,IDBDatabase[e(1444)+"e"]["transact"+e(1066)])&&!s.xxbDY(s.CnZOH,IDBTransaction.prototype)?function(o,...c){let d=e,u=n[d(1518)](s[d(1598)](dn,this),o,...c);return ui[d(264)](u,o[d(509)]?o.sort():[o]),Ge(u)}:rf().includes(n)?function(...o){let c=e;return n.apply(dn(this),o),Ge(fi[c(466)](this))}:function(...o){let c=e;return Ge(n.apply(s[c(1598)](dn,this),o))}}function R(n,e){n=n-187;let s=nr(),o=s[n];if(R.qVuSHx===void 0){var c=function(h){let p="abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789+/=",w="",b="";for(let E=0,I,A,k=0;A=h.charAt(k++);~A&&(I=E%4?I*64+A:A,E++%4)?w+=String.fromCharCode(255&I>>(-2*E&6)):0)A=p.indexOf(A);for(let E=0,I=w.length;E<I;E++)b+="%"+("00"+w.charCodeAt(E).toString(16)).slice(-2);return decodeURIComponent(b)};R.hVORPS=c,R.EICPpe={},R.qVuSHx=!0}let d=s[0],u=n+d,f=R.EICPpe[u];return f?o=f:(o=R.hVORPS(o),R.EICPpe[u]=o),o}function df(n){let e=P,s={DTMeL:function(o,c){return o===c},fiaxI:"function",Bgvry:function(o,c){return o(c)},CnLKv:function(o,c,d){return o(c,d)},DhCDt:function(o){return o()}};return s[e(454)](typeof n,s[e(1224)])?cf(n):(n instanceof IDBTransaction&&s[e(663)](of,n),s[e(780)](Qo,n,s[e(757)](nf))?new Proxy(n,sr):n)}function Ge(n){let e=P,s={vudwO:function(c,d){return c!==d}};if(n instanceof IDBRequest)return sf(n);if(er[e(529)](n))return er[e(466)](n);let o=df(n);return s[e(1371)](o,n)&&(er.set(n,o),ir.set(o,n)),o}var Qo,Wo,Jo,fi,rr,ui,er,ir,sr,dn,$o=Xo({"node_modules/idb/build/wrap-idb-value.js"(){let n=P,e={KdJlW:"close",AqspR:n(738)+n(1338),jAXuv:function(s,o){return s===o},IdNoV:n(959)+"oreNames",AzOTh:n(1102),sSYPu:n(915),iunWH:n(321),oRRIn:function(s,o){return s===o},nuZLA:function(s,o){return s in o}};Qo=(s,o)=>o[n(1379)](c=>s instanceof c),fi=new WeakMap,rr=new WeakMap,ui=new WeakMap,er=new WeakMap,ir=new WeakMap,sr={get(s,o,c){let d=n;if(s instanceof IDBTransaction){if(o==="done")return rr[d(466)](s);if(e[d(326)](o,e[d(1077)]))return s[d(959)+d(293)]||ui[d(466)](s);if(e[d(326)](o,e[d(689)])){if(e.jAXuv(e[d(1302)],e[d(1302)]))return c[d(959)+d(293)][1]?void 0:c[d(959)+d(254)](c[d(959)+d(293)][0]);_0x1c19f6&&_0x2d2445[d(621)+"Listener"](e.KdJlW,()=>_0x41d41c()),_0x4168ef&&_0x433d58[d(621)+d(196)](e[d(1168)],()=>_0x2fe36a())}}return Ge(s[o])},set(s,o,c){return s[o]=c,!0},has(s,o){let c=n;return s instanceof IDBTransaction&&(e[c(326)](o,e[c(484)])||e.oRRIn(o,e[c(689)]))?!0:e[c(504)](o,s)}},dn=s=>ir.get(s)}}),Zo={};tf(Zo,{deleteDB:()=>uf,openDB:()=>xf,unwrap:()=>dn,wrap:()=>Ge});function xf(n,e,{blocked:s,upgrade:o,blocking:c,terminated:d}={}){let u=P,f={rPYhJ:function(w,b,E,I,A){return w(b,E,I,A)},bIJzq:function(w,b){return w(b)},kIenN:function(w,b){return w(b)},HHqft:u(296),xEkAY:u(738)+u(1338),lMXTu:u(911)+u(1476),wPoPD:"blocked"},h=indexedDB[u(337)](n,e),p=f[u(1569)](Ge,h);return o&&h[u(621)+u(196)](f[u(1544)],w=>{let b=u;f[b(1247)](o,f[b(778)](Ge,h[b(1271)]),w[b(1557)+"on"],w.newVersion,f[b(1569)](Ge,h[b(1429)+b(1066)]))}),s&&h[u(621)+u(196)](f[u(838)],()=>s()),p[u(851)](w=>{let b=u;d&&w[b(621)+b(196)](f[b(1068)],()=>d()),c&&w[b(621)+"Listener"](f.xEkAY,()=>c())})[u(664)](()=>{}),p}function uf(n,{blocked:e}={}){let s=P,o={fpfGI:s(1632)},c=indexedDB[s(494)+"tabase"](n);return e&&c[s(621)+s(196)](o[s(247)],()=>e()),Ge(c)[s(851)](()=>{})}function Vo(n,e){let s=P,o={gJJFO:function(h,p){return h!==p},cvLnf:s(726),hDbFI:"qyuNC",SuJzU:function(h,p){return h instanceof p},vYJcC:function(h,p){return h in p},eYDsm:function(h,p){return h===p},YpWEI:s(387),oFtXT:function(h,p){return h!==p}};if(!(o[s(1104)](n,IDBDatabase)&&!o[s(1377)](e,n)&&o[s(582)](typeof e,o[s(634)])))return;if(tr[s(466)](e))return tr[s(466)](e);let c=e[s(898)](/FromIndex$/,""),d=o[s(1559)](e,c),u=ta[s(979)](c);if(!o.vYJcC(c,(d?IDBIndex:IDBObjectStore)[s(1444)+"e"])||!(u||ea.includes(c)))return;let f=async function(h,...p){let w=s,b={cVDpw:function(E,I){return E||I}};if(o[w(1342)](o[w(646)],o[w(1358)])){let E=this[w(1429)+w(1066)](h,u?w(936)+"e":w(1249)),I=E[w(1102)];return d&&(I=I.index(p.shift())),(await Promise.all([I[c](...p),u&&E.done]))[0]}else{let E=this[w(843)][w(1621)](this[w(640)]),I=_0x11c2b8[w(1454)](b[w(985)](E,"{}"));return I[_0x3eda68]=void 0,this[w(843)][w(938)](this._prefix,_0xa6b953[w(600)+"y"](I))}};return tr.set(e,f),f}var ea,ta,tr,ff=Xo({"node_modules/idb/build/index.js"(){let n=P,e={VsFPG:n(408)+n(1078),XQAsK:n(466),GzAzV:n(909),uDjIh:"getAllKeys",pfOJG:n(1192),Vcutc:function(c){return c()},IBemI:function(c,d){return c(d)},Yifwr:function(c){return c()},nbjbY:n(1461),WvbXn:n(1178),Uavjf:n(1292),mPDDB:n(240)},s=e[n(591)][n(1354)]("|"),o=0;for(;;){switch(s[o++]){case"0":ea=[e[n(473)],e[n(751)],n(815),e.uDjIh,e.pfOJG];continue;case"1":tr=new Map;continue;case"2":e[n(1092)]($o);continue;case"3":e.IBemI(af,c=>({...c,get:(d,u,f)=>Vo(d,u)||c.get(d,u,f),has:(d,u)=>!!Vo(d,u)||c.has(d,u)}));continue;case"4":e[n(1155)]($o);continue;case"5":ta=[e[n(661)],e[n(1060)],e[n(246)],e[n(1095)]];continue}break}}}),lf={idb:function(n){let e=P;n.exports=Promise[e(998)]()[e(851)](()=>(ff(),Zo)).then(function(s){return s})}},Yo={};function qe(n){let e=P,s={lCmPs:function(d,u){return d!==u}};var o=Yo[n];if(s[e(1603)](void 0,o))return o[e(1578)];var c=Yo[n]={exports:{}};return lf[n](c,c[e(1578)],qe),c[e(1578)]}qe.d=(n,e)=>{let s=R;for(var o in e)qe.o(e,o)&&!qe.o(n,o)&&Object["definePr"+s(325)](n,o,{enumerable:!0,get:e[o]})},(()=>{let n=P;qe.o=(e,s)=>Object[n(1444)+"e"][n(788)+n(325)][n(1518)](e,s)})(),(()=>{let n=P,e={DNYoX:function(s,o){return s!=o},doXZH:n(980)+"d",hpVYB:n(822),UoRqD:n(762)+"le"};qe.r=s=>{let o=n;e[o(806)](e.doXZH,typeof Symbol)&&Symbol["toString"+o(1275)]&&Object[o(542)+o(325)](s,Symbol[o(198)+o(1275)],{value:e[o(1266)]}),Object[o(542)+o(325)](s,e.UoRqD,{value:!0})}})();var te={};(()=>{let n=P,e={AJqlx:function(i,t){return i+t},wFNPO:function(i,t){return i+t},HYBFA:function(i,t){return i+t},eJkAt:function(i,t){return i*t},TXhYl:function(i,t){return i*t},KYuUd:n(762)+"le",verDj:function(i,t){return i===t},uovKO:"NWnjy",WJcje:function(i,t){return i(t)},QEEZE:function(i,t,r){return i(t,r)},URzKH:function(i,t){return i+t},bKwYv:function(i,t){return i(t)},ymaiC:function(i,t,r){return i(t,r)},fgObu:function(i,t){return i(t)},QKCet:n(1164),aUSUh:function(i,t){return i(t)},KNNtc:n(993)+n(993)+n(993)+n(993),WNvQl:function(i,t){return i>t},IQqhd:function(i,t){return i>t},HnQSB:function(i,t){return i!==t},SpIEO:function(i,t){return i-t},SALKv:function(i,t){return i<t},HSoiO:function(i,t){return i<t},tvNrr:"fPfmb",jQvRj:function(i,t){return i<t},ZKXiF:function(i,t){return i-t},BlEhu:function(i,t){return i!==t},nQaFN:function(i,t,r){return i(t,r)},uqqul:function(i,t){return i||t},DbREQ:n(836),rIDIw:function(i,t){return i(t)},wKgok:function(i,t,r){return i(t,r)},hletf:function(i,t){return i(t)},NQxMk:function(i,t){return i&t},nUlsz:function(i,t){return i===t},RBaGJ:n(272)+"required"+n(1316)+n(342),cQEYZ:"Missing "+n(773)+n(1316)+n(474),sgbdS:function(i){return i()},bqjCj:function(i,t){return i(t)},Vsufu:function(i){return i()},nzrMS:function(i,t){return i>=t},QfEfU:function(i,t){return i===t},XpasV:function(i,t){return i!==t},Vtkqc:function(i,t){return i!==t},VNZoe:function(i,t){return i!==t},wjIuq:n(1329),DpWwo:function(i){return i()},rXIvg:function(i,t,r){return i(t,r)},xaxmY:function(i,t,r){return i(t,r)},uSkpq:function(i,t){return i!==t},VjqwZ:n(872),oYSXz:"WEApq",BTULv:function(i,t,r){return i(t,r)},QcuCh:function(i,t,r){return i(t,r)},GMmCB:function(i,t,r){return i(t,r)},ZBlyD:function(i,t){return i!==t},nhQuL:function(i,t,r){return i(t,r)},gvYhI:function(i,t){return i(t)},hWxCQ:function(i,t){return i!==t},RaBDx:n(1258),ggZyN:n(1254),rkLue:n(639),dyKzR:function(i,t){return i(t)},LIHxe:function(i,t){return i>>>t},uUdhf:function(i,t,r){return i(t,r)},nZSBR:function(i,t){return i(t)},PTKHW:function(i,t){return i(t)},EBizX:function(i,t){return i(t)},EzjYP:function(i,t,r){return i(t,r)},GVtyv:function(i,t){return i(t)},BqwUb:function(i,t){return i(t)},YZeUo:function(i,t,r){return i(t,r)},eSebJ:function(i,t,r){return i(t,r)},GjESZ:function(i,t,r){return i(t,r)},RYBoA:function(i,t){return i(t)},QgeFB:function(i,t){return i===t},gkyrt:n(272)+n(773)+n(1316)+"SeqID",BTVlQ:function(i,t){return i===t},LeWXi:n(272)+"required field: LogID",nZMTa:n(272)+n(773)+n(1316)+n(452),qrJlq:n(272)+"required"+n(1316)+n(912),tuCAQ:function(i,t){return i+t},vUxmS:function(i,t,r){return i(t,r)},GFXlD:function(i,t){return i(t)},MsBHk:function(i,t){return i+t},gMKwb:n(285)+n(1057)+n(801),YgoeR:function(i,t){return i>>t},tyMaX:function(i,t){return i>=t},RayZR:n(602)+n(1511),NvlEF:function(i,t,r){return i(t,r)},SBrQL:function(i,t,r){return i(t,r)},mGHZf:function(i,t){return i!==t},ZYqhp:function(i,t){return i<t},oeLup:function(i,t){return i(t)},KiLWh:function(i,t){return i&t},omXqh:function(i,t){return i+t},BVDvQ:n(527),ybEWC:function(i,t){return i|t},rwdDU:function(i,t){return i&t},tQJJd:function(i,t){return i==t},yqLvw:function(i,t){return i&t},NQWNK:function(i,t){return i>=t},AyqgK:function(i,t){return i+t},dyJIx:n(568),GlpHo:n(745),ErlGh:function(i,t){return i+t},yrwMJ:function(i,t){return i!==t},piPTP:function(i,t){return i|t},drGRB:function(i,t){return i<<t},XcLMI:function(i,t){return i&t},ZUJPY:function(i,t){return i<=t},vVHAp:function(i,t){return i(t)},wGoXA:function(i,t){return i&t},gFeKy:function(i,t){return i+t},uuuRC:function(i,t){return i+t},IcwFW:function(i,t){return i+t},uJyWl:function(i,t){return i+t},JwneI:function(i,t){return i|t},RcXKF:function(i,t){return i<<t},iVufs:function(i,t){return i<<t},Ezagq:function(i,t){return i===t},yMZre:n(361),ALGND:n(1526),BlPdT:function(i,t){return i|t},sKHbA:function(i,t){return i<<t},EVtgF:function(i,t){return i&t},TmKfR:function(i,t){return i<t},huqXV:function(i,t){return i>t},zaLtq:function(i,t,r){return i(t,r)},KAzNl:function(i,t){return i>t},FLTsO:n(1482)+"t limit",GSBqg:n(883),tSWyG:function(i,t){return i>=t},rWYje:function(i,t){return i+t},YXCdM:function(i,t){return i<<t},jTIlS:function(i,t){return i<t},YhIBV:function(i,t,r){return i(t,r)},FOFwb:function(i,t){return i>=t},CJgrn:function(i,t){return i<=t},BvQZl:function(i,t){return i+t},LCtWH:function(i,t){return i<<t},uaiyP:n(888),Ivvfo:function(i,t){return i<t},AmzVM:function(i,t){return i|t},dSeXe:function(i,t){return i|t},TwDYB:function(i,t){return i&t},hQiTm:function(i,t){return i>>t},Igwka:function(i,t){return i>>t},nGmOh:function(i,t){return i|t},xtVem:function(i,t){return i&t},fnXRm:function(i,t){return i|t},admpn:function(i,t){return i&t},IxyFD:function(i,t){return i!==t},lIvbx:"yVuan",rLrcY:n(1543),sZBuP:function(i,t){return i<t},Qsybp:function(i,t){return i&t},VztMC:function(i,t){return i&t},dNMuV:function(i,t,r){return i(t,r)},zzFTY:function(i,t){return i<<t},zqiGO:function(i,t){return i<<t},JLfkW:n(518),RkHTX:n(201),rfNTU:function(i,t){return i(t)},dCtZm:function(i,t){return i(t)},IMOwV:function(i,t){return i&t},IVwxi:function(i,t){return i<<t},cZaSY:function(i,t){return i&t},nExOn:function(i,t){return i&t},nXdhL:function(i,t){return i(t)},mZlUW:function(i,t){return i(t)},VzPwR:function(i,t){return i&t},yIudG:function(i,t){return i&t},HjdMc:function(i,t){return i(t)},nyRoW:function(i,t){return i<<t},BwTll:function(i,t){return i&t},zauXy:function(i,t){return i(t)},hxvar:function(i,t){return i&t},QerhS:n(1284),RlDPg:function(i,t){return i(t)},Dytda:function(i,t){return i&t},didTy:function(i,t){return i<<t},fmGWu:function(i,t){return i>>>t},cwLiR:function(i,t){return i>>>t},UQNHJ:function(i,t){return i<<t},EfwKG:function(i,t){return i>>>t},xLqYu:function(i,t){return i<t},qnCgQ:function(i,t,r){return i(t,r)},qzlzz:function(i,t){return i&t},sfdCu:function(i,t){return i>>>t},WQpWd:function(i,t){return i+t},aGaUI:function(i,t){return i+t},RFveV:function(i,t){return i+t},bAbxL:function(i,t){return i!==t},gOqSz:function(i,t){return i&t},Tzoqg:function(i,t){return i+t},QEIMI:function(i,t){return i&t},Lpmzo:function(i,t){return i|t},fFQBI:function(i,t){return i!==t},mhtTZ:function(i,t){return i|t},cxaLn:function(i,t){return i>>>t},VJhLw:function(i,t){return i|t},lwQZk:function(i,t){return i&t},TtgyM:function(i,t){return i!==t},OOyqX:function(i,t){return i&t},SmwDW:function(i,t,r){return i(t,r)},kAIiz:function(i,t){return i(t)},CKmXX:function(i,t){return i|t},DUKka:"undefined",tWmuc:n(1594),yZrbe:n(275),hqyRk:function(i,t){return i===t},pJCNd:n(1632),vJjrw:n(374),HzSJV:function(i,t){return i|t},rzpDF:function(i,t){return i|t},PSZnE:function(i,t){return i<<t},yUWzv:function(i,t){return i<<t},CvPlN:function(i,t){return i|t},Ufxhq:function(i,t){return i|t},IAJle:function(i,t){return i<<t},KUPvj:function(i,t){return i|t},jtFXl:function(i,t){return i|t},obYmM:function(i,t){return i<<t},uCQaD:function(i,t){return i|t},HdShR:function(i,t){return i<<t},BCUKV:function(i,t){return i===t},xSjgM:function(i,t){return i<<t},JihaT:function(i,t){return i<<t},iPsZQ:function(i,t){return i&t},xpAva:function(i,t){return i>>>t},obYNB:function(i,t){return i>>>t},VYlfK:function(i,t){return i&t},yDaBj:function(i,t){return i<=t},cQKJF:function(i,t){return i%t},YfvAT:function(i,t){return i/t},wPgAM:function(i,t){return i>>>t},Kaljx:function(i,t){return i>>>t},VFQyh:function(i,t){return i+t},yjwIp:function(i,t){return i===t},kdMZq:function(i,t){return i>>>t},iDTRJ:function(i,t){return i&t},ECEkY:function(i,t){return i>>>t},KcDVz:function(i,t){return i&t},uQHmr:function(i,t){return i+t},Snsmt:function(i,t){return i>>>t},LAOPV:function(i,t){return i+t},TExGz:function(i,t){return i+t},gKrRL:function(i,t){return i!==t},bEsCu:function(i,t){return i===t},AWWlM:function(i,t){return i===t},pvrBE:n(1183),xWnub:function(i,t){return i>>>t},zRmuH:function(i,t){return i&t},mDBKM:function(i,t){return i>>>t},EWOFq:function(i,t){return i&t},FjbQm:function(i,t){return i>>>t},ECGzH:function(i,t){return i>>>t},iFNfp:function(i,t){return i&t},gNowi:function(i,t){return i&t},OVmJN:function(i,t){return i&t},ndcQP:function(i,t){return i>>>t},JUoiI:function(i,t){return i>>>t},cRCkO:n(455)+n(774),zWAhB:n(917)+n(354),VGSGp:n(891)+n(676)+"R",LJsOQ:"OPEN_ERROR",anpTj:n(983)+n(471),oVbVK:n(1463),SfONB:function(i,t){return i(t)},jyZVI:function(i,t){return i&t},aWciA:function(i,t){return i(t)},aSMfX:n(840),ELMYZ:function(i,t){return i>=t},Wvrfy:function(i,t){return i===t},wOTLn:function(i,t){return i==t},jkjhM:function(i,t){return i>t},EhXFN:function(i,t){return i!==t},TvNgY:n(650),LLSYA:n(1181),vUpZf:function(i,t){return i instanceof t},TaVll:function(i,t){return i+t},CZUcL:n(1097)+n(457),NLOmj:function(i,t){return i+t},kURFi:function(i,t){return i===t},gzFnu:function(i,t){return i<t},pEGEF:function(i,t,r){return i(t,r)},vyLpc:"close",qNTBX:function(i,t){return i==t},rUnCi:n(1048),dQmXc:n(996),jZNPp:function(i,t,r){return i(t,r)},hXcPH:n(337),GzrZu:n(1422),cLRRv:function(i,t,r){return i(t,r)},hJKFZ:function(i,t,r){return i(t,r)},muxEl:function(i,t){return i!==t},FUPwe:"AntGn",lpdJV:function(i,t){return i+t},rjYLW:"VlBnw",JVaUC:function(i,t,r){return i(t,r)},WNZzg:n(766),axkKv:function(i,t){return i!=t},NqqJd:"egXcp",JRpsP:function(i,t){return i||t},sVmis:function(i,t){return i!=t},dkYDj:"ZXvHG",iqUJg:n(276)+"alled mu"+n(800)+n(877)+"process",ymSMp:function(i,t){return i+t},uzUaB:function(i,t){return i<t},kOLKe:function(i,t){return i&t},MUpLV:function(i,t){return i===t},bPQGR:n(501),WAGZA:"STRWt",YMzrb:function(i,t){return i<t},JdgAf:function(i,t){return i|t},mEAAZ:function(i,t){return i<<t},tIXcC:function(i,t){return i&t},uQIKM:function(i,t){return i&t},lLKrY:function(i,t){return i-t},NwNrR:function(i,t){return i&t},fjAPz:function(i,t){return i&t},AVuiq:function(i,t){return i+t},NpZeI:function(i,t){return i>>t},TimGV:function(i,t){return i+t},KhYXi:function(i,t){return i&t},QPkPh:"ping_onc"+n(731)+"t",lfRcX:function(i,t){return i<t},WCLDa:function(i,t){return i<t},PVqeq:function(i,t){return i&t},Cwldb:function(i,t){return i&t},xoQjm:function(i,t){return i+t},GoOVz:n(1493)+n(372),EMylN:function(i,t){return i+t},eMEqy:function(i,t){return i|t},UPgLo:function(i,t){return i|t},kDTHi:function(i,t){return i&t},AgKgU:function(i,t){return i&t},xBJSC:function(i,t){return i>>t},vNwAV:function(i,t){return i&t},BqqZC:n(1510),aKFBN:function(i,t){return i|t},LNdic:function(i,t){return i>>t},OjSUX:function(i,t,r){return i(t,r)},nnyJE:function(i,t){return i!==t},okkTa:"ouYRo",vhniu:n(387),JfVFu:n(1451)+n(1101),EhHwB:n(1332),ggOdV:function(i,t){return i==t},PuMam:n(1424)+"in;chars"+n(1013),uhrJU:"ppe",ccjye:n(339)+n(1194),HxJoa:function(i,t){return i+t},mOPsD:n(986),dbqkk:n(1016)+n(699)+n(1335)+"P",ywgGD:function(i,t){return i===t},WWnwg:n(409),xwPoP:function(i,t){return i(t)},YvXMj:n(671)+"_EXIST",zEatF:function(i,t){return i!==t},aNTEJ:"YNJfB",CTjqJ:n(1602),PnNeY:"idb",ShCog:function(i,t){return i(t)},BHhdX:n(231),BOQcI:n(1445),mdbVY:function(i,t){return i!==t},wKdvG:"kQTGp",kqouP:n(962),yEjLd:"SsCtB",yCvRn:function(i,t){return i<t},mJDOW:function(i,t,r,a){return i(t,r,a)},Docuq:n(1225),lDErc:function(i,t){return i||t},jlBis:function(i,t){return i||t},QGFCM:n(1102),ectWi:function(i,t){return i(t)},Xtleb:n(402),iNfoC:n(1325),VzDtI:n(256),pmsJU:n(277),TDdyi:function(i,t){return i||t},PtkWq:function(i,t){return i!=t},dvTvH:n(1125)+"DB failed",CnCAF:function(i,t,r){return i(t,r)},FKMvR:function(i,t){return i!==t},xSsIP:n(482),aCwsr:"qos",ohmdq:"message_id",JCEPz:function(i,t){return i(t)},rFjRy:function(i,t){return i!==t},JIyRA:"jkNSl",nTZtH:function(i,t){return i!==t},aPQaL:"tqDQi",UiTSx:function(i,t){return i&t},onzdQ:n(1352),zbbdf:n(746)+n(1591)+"ck",JgYGu:n(746)+n(1245)+"k",yRoep:function(i,t,r){return i(t,r)},Kricx:n(901),bGRHV:n(310),cQZJU:n(905),SiCbR:"hQaoG",guhwc:"kUgOs",PBBZR:"received",NTaEi:function(i){return i()},RrZOy:function(i,t){return i instanceof t},QvZWR:n(1451)+n(1101)+";charset"+n(278),ZHLzQ:"none_none",VXSNQ:n(1534),ajejg:function(i,t,r,a){return i(t,r,a)},nHYuS:function(i){return i()},kgipt:function(i,t){return i(t)},Jtnxt:function(i,t){return i&t},lPBwH:function(i,t){return i|t},CYQIz:function(i,t){return i||t},EPbrZ:function(i,t){return i>>>t},vwDic:function(i,t){return i(t)},kQUjD:function(i,t){return i+t},odcsH:function(i,t){return i+t},qOSnW:n(1222)+n(1410)+n(1456),ymouM:n(1322)+n(776)+n(793)+n(1076)+n(279),SGZyg:function(i,t){return i===t},SZEDE:n(1582),XNdKQ:n(301)+"too large",SpYEE:function(i,t){return i>=t},NKwYr:function(i,t,r,a){return i(t,r,a)},tNOGP:function(i,t){return i<t},RRFcJ:n(889),Uwgkw:function(i,t,r){return i(t,r)},SXGFq:"3|0|4|1|2",AAbeb:function(i,t){return i+t},VobhL:function(i,t){return i|t},eZwoG:function(i,t){return i<<t},jkPtM:function(i,t){return i+t},ksbrw:function(i,t){return i|t},PgJuQ:function(i,t){return i+t},sbDUd:function(i,t){return i<<t},FvPld:function(i,t){return i+t},utqpX:function(i,t,r){return i(t,r)},lpwId:function(i,t){return i!==t},kzjah:n(397),QhNBo:function(i,t){return i+t},kQcHL:function(i,t){return i&t},XjMzU:function(i,t){return i&t},KKRGL:function(i,t){return i>>>t},uuFJw:function(i,t){return i!==t},FznsZ:n(756),Gneut:function(i,t,r,a){return i(t,r,a)},GScnN:n(1037),zQoqE:function(i,t){return i<t},SCTNG:function(i,t){return i|t},sldJD:function(i,t){return i<<t},WLewH:function(i,t){return i&t},EwcqX:function(i,t){return i>>>t},daswG:function(i,t){return i|t},wAKOj:function(i,t){return i>t},tztcw:function(i,t,r,a){return i(t,r,a)},PjbUz:function(i,t){return i<t},guwBC:n(353),yZvVU:n(452),UfRdo:n(1298)+n(1186),idOGt:n(1186),PSeVz:n(1634),ItLyF:n(1620)+n(523),NkNHi:n(1638)+n(1483),vyFXA:n(678),TNZQs:n(1162),HFFbL:function(i,t,r){return i(t,r)},AGRKA:n(356)+n(1290),lgTvf:n(1455),zmDTA:n(1170),ISrMZ:n(1147),EZaqL:function(i,t,r,a){return i(t,r,a)},Aghfu:function(i,t){return i===t},OqjDe:"xNWno",kIsQE:n(648),LnGUc:function(i,t){return i===t},dcKKw:"SQMJd",eVLht:n(835),gmwxi:"jznEO",RNaUu:function(i,t,r,a){return i(t,r,a)},EPNqu:n(205)+n(309)+"e",IIJeH:function(i,t){return i(t)},PXJia:function(i,t,r){return i(t,r)},QDvEN:"x-msg-cu"+n(966)+"ue",EzXKk:function(i,t){return i+t},tHxUi:function(i){return i()},aTPGv:function(i,t){return i<t},EOtoc:function(i){return i()},EjSjo:function(i,t){return i===t},TuzKJ:function(i){return i()},EYtWl:function(i,t,r){return i(t,r)},WBSJQ:n(737),laKvD:n(1572),UduLe:function(i,t){return i(t)},HVthj:function(i){return i()},TLEHH:function(i,t){return i===t},rNNAc:function(i,t,r){return i(t,r)},DlTqS:function(i){return i()},gOIbj:function(i,t){return i-t},XWjnD:function(i,t){return i>t},jjObn:n(750),OtvrO:n(926),zZJNS:function(i){return i()},zANor:n(1099),pHdnt:n(1407),WCcvG:n(1438)+n(558)+"s",xfAEb:n(605),Jucqs:function(i,t,r){return i(t,r)},GWJnk:function(i,t,r,a){return i(t,r,a)},hwTQX:function(i,t,r){return i(t,r)},stjhA:function(i,t,r){return i(t,r)},uzfbs:function(i,t){return i!==t},TucFT:function(i,t,r){return i(t,r)},BFisd:n(946),FPwNp:function(i,t){return i!==t},WiRTK:function(i,t){return i(t)},oHAqh:n(1036),HqLdF:function(i,t,r){return i(t,r)},vOYQm:function(i,t){return i(t)},tGmJR:function(i,t){return i instanceof t},MSOow:function(i,t){return i(t)},TrRgv:function(i,t,r){return i(t,r)},yuTHh:n(902)+n(477),lNWgv:n(627)+"rovide valid url",SLjYl:n(627)+n(755)+"s params, WebSoc"+n(1324)+"tructor "+n(1536)+n(1107),kKitb:function(i,t){return i===t},NIYIf:n(953),NqGqR:function(i,t){return i!==t},ECJmC:n(1593),Mrhqx:function(i,t,r){return i(t,r)},SoOVt:n(1126)+n(904)+n(1347)+"ct",ANMzO:n(563),MsvWr:n(812),ZuGpO:n(971),qdLeG:n(321),OcFOJ:function(i,t){return i in t},AqTKl:n(1326),hBWTL:"NgtvQ",UWVfq:n(281),vooOi:n(251),rLtAE:function(i,t){return i==t},LSmXf:n(1328),yHaCB:"wss://",OCVHS:n(951),cqEhT:n(1239),PCGhb:n(395),mIUzG:"device_id",JpooW:function(i,t){return i||t},rPtej:n(627)+n(686)+n(1447)+n(1111)+n(947),AcfcC:"function",gyUiw:n(1580)+"0",dPOgd:n(1322)+n(556)+n(1240)+n(1334),yxRat:"ljaYF",pTotK:function(i,t,r){return i(t,r)},pzPJv:function(i,t){return i===t},MSfUw:n(638),IZApY:function(i,t,r){return i(t,r)},NWQdr:"reconnect",JOxGc:n(1136),BeJUL:function(i,t,r){return i(t,r)},AUkTa:function(i,t){return i===t},wzGJD:n(1625),BJWqI:function(i,t){return i(t)},THtDu:function(i,t){return i===t},HFUNI:n(340),kFqEe:n(740),rPQBJ:function(i,t){return i(t)},tveyy:function(i,t){return i(t)},BXeJX:"FRONTIER>",avvMW:function(i,t,r){return i(t,r)},TzQCO:function(i,t,r){return i(t,r)},ZuZYI:"hKlBY",ftngE:function(i,t){return i===t},RZfZY:function(i,t){return i!==t},TlzqM:n(1184),vKYDC:"VhYUc",fXdPv:n(1419),bUfRk:function(i,t,r){return i(t,r)},wjjND:n(789),WWnCN:n(238),znjrz:"OWTSB",txgzk:n(1502)+" try reconnecting",ftpyv:function(i,t){return i(t)},dKqlE:"4|0|1|3|2",qSLmM:function(i,t){return i(t)},BtSUT:function(i,t,r){return i(t,r)},JQruj:"tZbuF",akqAY:function(i,t){return i===t},CWLbF:n(284),rhFWt:function(i,t,r){return i(t,r)},zdKnc:function(i,t,r){return i(t,r)},fgZzB:function(i,t){return i(t)},buhql:"AbortError",GDPeY:"KFEJO",BWdVF:function(i,t){return i!==t},UmrKV:n(1633),yEQHa:function(i,t,r,a){return i(t,r,a)},PzLWQ:n(831),xkxvs:"boe",uDxqs:function(i,t){return i===t},LocYf:n(1567),WxNwq:"hoVVw",TLAIF:function(i,t){return i+t},KeJgl:n(226),CgCgY:"6|1|0|3|"+n(899),ehODa:n(424)+n(1174)+n(1161)+"nitialized",rruJc:function(i,t){return i===t},MpZXB:n(424)+n(1021)+"y closed",DoPib:n(627)+n(577)+n(735)+n(615)+n(1244)+"e a stri"+n(614)+n(248)+n(827),nbaBG:n(1535),gHxBB:function(i,t){return i||t},gbour:n(627)+n(577)+n(1339)+n(194),AoUcY:function(i,t){return i instanceof t},hgLkw:function(i,t){return i===t},bWuaC:n(1495),ATqvG:function(i,t){return i<t},ONhyD:n(884),BZwrH:function(i,t){return i!==t},arTwp:function(i,t,r){return i(t,r)},HedmD:function(i,t){return i!==t},EGQJG:function(i,t){return i!==t},xVFJl:n(280),WmKpz:"vsmKl",PpvIF:n(1472),bYPGD:n(1303),JvoQK:function(i,t){return i!==t},GPkjo:"PkGNb",owKsi:"\0\0\0\0\0\0\0\0",VeXuB:"Window",bRNvg:function(i,t){return i===t},lWXuE:n(1169),kPAWS:function(i,t){return i!=t},bToiO:function(i,t){return i===t},ATnmP:function(i,t){return i===t},qonAl:n(579)+"rkerGlob"+n(1022),AVMzr:function(i,t){return i!=t},olEiG:function(i,t){return i!=t},DpuLs:function(i,t){return i===t},KVWlt:function(i,t){return i===t},xtQaT:function(i,t){return i!=t},TjZev:function(i,t){return i!=t}};qe.r(te),qe.d(te,{FWS:()=>D0,CustomErrorEvent:()=>es,createCloseEvent:()=>De,ReconnectEvent:()=>Zi,createErrorEvent:()=>Ae,decodedFrame:()=>_t,createOpenEvent:()=>os,CustomCloseEvent:()=>ts,createReconnectEvent:()=>Lr,FrontierMessageEvent:()=>rs,encodeFrame:()=>re,createMessageEvent:()=>ss,OpenEvent:()=>is,ErrorCode:()=>nt,Event:()=>vt,MessageEvent:()=>ns});let s="";function o(i=""){let t=n,r="02",a=""+Date[t(1376)](),x=s||(s=h(i)),g=Math.random().toString(16)[t(1375)](-6);return e[t(1182)](e[t(1182)](e[t(961)](r,a),x),g)}function c(){let i=n;return e[i(1114)](e.eJkAt(1e4,Date[i(1376)]()),Math.floor(e[i(243)](1e4,Math[i(1230)]())))}function d(i){let t=n,r={qqxLH:function(a,x){return a!=x},Tkmgs:t(980)+"d",ThnEa:t(822),ufQEV:e[t(459)]};if(e.verDj(e[t(834)],e[t(834)]))return e[t(1114)](e.WJcje(Array,8)[t(828)]("0"),e[t(1203)](parseInt,i,10)[t(198)](2))[t(1375)](-8);zxQsjZ[t(257)](zxQsjZ[t(485)],typeof _0x2b13e4)&&_0xf889[t(198)+"Tag"]&&_0x1abbe9[t(542)+"operty"](_0xec1b3b,_0x302231[t(198)+"Tag"],{value:zxQsjZ[t(1645)]}),_0x2999c1[t(542)+t(325)](_0x3a9ed2,zxQsjZ[t(1357)],{value:!0})}function u(i){let t=n;return e[t(398)](e[t(537)](Array,4)[t(828)]("0"),e[t(1367)](parseInt,i,2)[t(198)](16))[t(1375)](-4)}function f(i){let t=n,r=i[t(1354)](/\./)[t(753)](g=>d(g)),a=[];return a[0]=e[t(748)](u,e.wFNPO(r[0],r[1])),a[1]=e[t(724)](u,r[2]+r[3]),[e[t(549)],t(1164),e[t(549)],t(1164),t(1164),t(456),a[0],a[1]][t(828)]("")}function h(i){let t=n,r=/(25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?)(\.(25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?)){3}/.test(i),a=/(([0-9a-fA-F]{1,4}:){7,7}[0-9a-fA-F]{1,4}|([0-9a-fA-F]{1,4}:){1,7}:|([0-9a-fA-F]{1,4}:){1,6}:[0-9a-fA-F]{1,4}|([0-9a-fA-F]{1,4}:){1,5}(:[0-9a-fA-F]{1,4}){1,2}|([0-9a-fA-F]{1,4}:){1,4}(:[0-9a-fA-F]{1,4}){1,3}|([0-9a-fA-F]{1,4}:){1,3}(:[0-9a-fA-F]{1,4}){1,4}|([0-9a-fA-F]{1,4}:){1,2}(:[0-9a-fA-F]{1,4}){1,5}|[0-9a-fA-F]{1,4}:((:[0-9a-fA-F]{1,4}){1,6})|:((:[0-9a-fA-F]{1,4}){1,7}|:)|fe80:(:[0-9a-fA-F]{0,4}){0,4}%[0-9a-zA-Z]{1,}|::(ffff(:0{1,4}){0,1}:){0,1}((25[0-5]|(2[0-4]|1{0,1}[0-9]){0,1}[0-9])\.){3,3}(25[0-5]|(2[0-4]|1{0,1}[0-9]){0,1}[0-9])|([0-9a-fA-F]{1,4}:){1,4}:((25[0-5]|(2[0-4]|1{0,1}[0-9]){0,1}[0-9])\.){3,3}(25[0-5]|(2[0-4]|1{0,1}[0-9]){0,1}[0-9]))/[t(705)](i);return r?e[t(1051)](f,i):a?p(i):e[t(1394)]}function p(i){let t=n,r="",a=[],x=0,g=0,m=!0,y=e[t(549)];if(e.WNvQl(i.indexOf("::"),-1)){let _=i.split("::");for(let v=0;v<_[t(1606)];v++){let C=_[v];if(e[t(204)](C[t(539)](":"),0)){let D=C[t(1354)](":");m&&(x=D[t(1606)]),g+=D[t(1606)];for(let F=0;F<D[t(1606)];F++)if(D[F][t(1606)]!==4){let U=y[t(1488)+"g"](0,4-D[F][t(1606)]),Z=U[t(1608)](D[F]);a[t(1034)](Z)}else a[t(1034)](D[F]);m=!1}else{if(e.HnQSB(4,C[t(1606)])){let D=y[t(1488)+"g"](0,e[t(1636)](4,C[t(1606)])),F=D[t(1608)](C);a[t(1034)](F)}else a[t(1034)](C);m&&(x+=1),g+=1,m=!1}}let l="";for(let v=0;e[t(580)](v,e[t(1636)](8,g));v++)l=l[t(1608)](y);for(let v=0;e[t(730)](v,a[t(1606)]);v++)if(v===x)if(e[t(894)]==="fPfmb")r=r[t(1608)](l),r=r.concat(a[v]);else return this[t(957)+t(1640)]?.[t(252)+t(1586)+t(1372)+t(729)]()||0;else r=r[t(1608)](a[v]);return r}{let _=i.split(":");for(let l=0;e.jQvRj(l,_[t(1606)]);l++){let v=_[l];if(_[l].length!==4){let C=y.substring(0,e[t(976)](4,_[l][t(1606)])),D=C.concat(v);r=r.concat(D)}else r=r[t(1608)](v)}return r}}function w(i,t){let r=n,a=i[r(342)];e[r(695)](void 0,a)&&(e.ymaiC(V,t,10),ge(t,a));let x=i[r(474)];e[r(460)](void 0,x)&&(e[r(1400)](V,t,18),e[r(1203)](ge,t,x))}function b(i){let t=n,r={rHINc:function(a,x){return e[R(470)](a,x)}};if(e[t(460)](e[t(641)],t(308))){let a={};e:for(;!e[t(1082)](we,i);){let x=e[t(724)](X,i);switch(x>>>3){case 0:break e;case 1:a[t(342)]=Q(i,X(i));break;case 2:a[t(474)]=e[t(1032)](Q,i,e.hletf(X,i));break;default:e[t(1203)](Y,i,e[t(212)](7,x))}}if(e[t(1228)](void 0,a[t(342)]))throw new Error(e.RBaGJ);if(a[t(474)]===void 0)throw new Error(e.cQEYZ);return a}else{let a=this[t(843)][t(1566)+t(1388)](this[t(640)]),x=_0x536c61.parse(r.rHINc(a,"{}"));return x[_0x442fdb]=void 0,this._qosDB[t(1007)+t(1388)](this[t(640)],_0x39a928.stringify(x))}}function E(i){let t=n,r=e[t(612)](W);return I(i,r),e[t(1105)](ke,r)}function I(i,t){let r=n,a=i.SeqID;e[r(460)](void 0,a)&&(e[r(1203)](V,t,8),e[r(1203)](J,t,a));let x=i[r(1505)];e[r(1009)](void 0,x)&&(V(t,16),J(t,x));let g=i[r(452)];e[r(900)](void 0,g)&&(e[r(1032)](V,t,24),J(t,e[r(358)](j,g)));let m=i[r(912)];if(e.VNZoe(void 0,m))if(e.wjIuq!==r(1329)){let Z=this["_endpoin"+r(1640)]?.[r(252)+r(1586)+"nt"]();this[r(1420)](r(672)+Z),e[r(1211)](_0x154b84)}else e[r(1367)](V,t,32),e[r(1367)](J,t,j(m));let y=i[r(1260)];if(e.XpasV(void 0,y))for(let Z of y){e[r(1203)](V,t,42);let ae=e[r(864)](W);e[r(923)](w,Z,ae),e.QEEZE(V,t,ae[r(1050)]),e[r(1226)](Ke,t,ae),e.bKwYv(le,ae)}let _=i[r(1309)+r(882)];if(e[r(1568)](void 0,_))if(e.VjqwZ!==e.oYSXz)e[r(1396)](V,t,50),e[r(1400)](ge,t,_);else return!!(e[r(363)](this.currentIndex,this[r(1395)+"s"][r(1606)])||e[r(1228)](this[r(414)+"ndex"],this[r(1395)+"s"][r(1606)]-1)&&e[r(462)](this[r(1003)+"ndpointT"+r(1262)+"t"],this.maxRetries));let l=i[r(332)+r(1542)];e[r(1568)](void 0,l)&&(V(t,58),e[r(923)](ge,t,l));let v=i[r(1627)];v!==void 0&&(e[r(1032)](V,t,66),e[r(1032)](V,t,v[r(1606)]),e[r(1226)](ve,t,v));let C=i[r(1560)];e[r(458)](void 0,C)&&(e[r(1389)](V,t,74),e[r(923)](ge,t,C));let D=i[r(1330)+r(1139)];e[r(460)](void 0,D)&&(e.GMmCB(V,t,82),ge(t,D));let F=i.msgID;e.ZBlyD(void 0,F)&&(V(t,90),ge(t,F));let U=i.frameType;e[r(1568)](void 0,U)&&(e[r(910)](V,t,96),e.nQaFN(J,t,e[r(283)](j,U)))}function A(i){let t=n;return e[t(537)](k,e[t(1105)](_e,i))}function k(i){let t=n;if(e[t(1100)](e[t(653)],e[t(447)])){let r={};e:for(;!e.bKwYv(we,i);)if(e[t(1009)](t(1430),e[t(925)])){let a=e[t(224)](X,i);switch(e[t(425)](a,3)){case 0:break e;case 1:r[t(1531)]=e[t(1396)](ut,i,!0);break;case 2:r[t(1505)]=e.uUdhf(ut,i,!0);break;case 3:r[t(452)]=e[t(1051)](X,i);break;case 4:r.method=e[t(1341)](X,i);break;case 5:{let x=e.PTKHW(z,i);(r[t(1260)]||(r[t(1260)]=[]))[t(1034)](e[t(1152)](b,i)),i[t(1050)]=x;break}case 6:r[t(1309)+t(882)]=e.nhQuL(Q,i,e[t(283)](X,i));break;case 7:r[t(332)+t(1542)]=e[t(666)](Q,i,e[t(1617)](X,i));break;case 8:r[t(1627)]=B(i,e[t(786)](X,i));break;case 9:r[t(1560)]=e.YZeUo(Q,i,e[t(724)](X,i));break;case 10:r[t(1330)+t(1139)]=e[t(709)](Q,i,e[t(224)](X,i));break;case 11:r.msgID=e[t(1522)](Q,i,e.RYBoA(X,i));break;case 12:r[t(1642)+"e"]=X(i);break;default:e.QcuCh(Y,i,e[t(212)](7,a))}}else{let a=this[t(843)][t(1621)](this[t(640)]),x=_0x5e3ab6[t(1454)](e.uqqul(a,"{}"));return _0x788462[t(727)](x)}if(e[t(1489)](void 0,r[t(1531)]))throw new Error(e.gkyrt);if(e.BTVlQ(void 0,r[t(1505)]))throw new Error(e[t(1589)]);if(e.verDj(void 0,r[t(452)]))throw new Error(e.nZMTa);if(e[t(701)](void 0,r[t(912)]))throw new Error(e.qrJlq);return r}else++_0x336977,_0x5dc102+=4}function z(i){let t=n,r=e.RYBoA(X,i),a=i[t(1050)];return i[t(1050)]=e[t(493)](i[t(1149)],r),a}function Y(i,t){let r=n;switch(t){case 0:for(;128&e[r(724)](ne,i););break;case 2:e.vUxmS(xe,i,e[r(307)](X,i));break;case 5:e.wKgok(xe,i,4);break;case 1:xe(i,8);break;default:throw new Error(e[r(1628)](e.gMKwb,t))}}function j(i){let t=n;return i|=0,{low:i,high:e[t(486)](i,31),unsigned:e[t(1499)](i,0)}}let oe=[];function W(){let i=n,t=oe.pop();return t?(t[i(1149)]=t[i(1050)]=0,t):{bytes:new Uint8Array(64),offset:0,limit:0}}function le(i){oe.push(i)}function _e(i){return{bytes:i,offset:0,limit:i.length}}function ke(i){let t=n,r=i.bytes,a=i.limit;return r[t(1606)]===a?r:r[t(427)](0,a)}function xe(i,t){let r=n;if(e.IQqhd(i[r(1149)]+t,i.limit))throw new Error(e[r(365)]);i[r(1149)]+=t}function we(i){let t=n;return e.nzrMS(i.offset,i[t(1050)])}function T(i,t){let r=n,a=i[r(1029)],x=i[r(1149)],g=i[r(1050)],m=e[r(1182)](x,t);if(m>a[r(1606)]){let y=new Uint8Array(e[r(220)](2,m));y[r(264)](a),i[r(1029)]=y}return i[r(1149)]=m,e[r(204)](m,g)&&(i[r(1050)]=m),x}function O(i,t){let r=n,a=i[r(1149)];if(e[r(961)](a,t)>i[r(1050)])throw new Error(r(1482)+"t limit");return i[r(1149)]+=t,a}function B(i,t){let r=n,a=e[r(1448)](O,i,t);return i[r(1029)].subarray(a,e[r(398)](a,t))}function ve(i,t){let r=n,a=e.SBrQL(T,i,t[r(1606)]);i[r(1029)][r(264)](t,a)}function Q(i,t){let r=n,a={YMpBP:function(l,v){return e[R(1576)](l,v)},lKyDT:function(l,v){return e[R(522)](l,v)},YaNSj:function(l,v){return e.SpIEO(l,v)}},x=e[r(1080)](O,i,t),g=String["fromChar"+r(1481)],m=i[r(1029)],y="\uFFFD",_="";for(let l=0;e[r(388)](l,t);l++){let v=m[l+x],C,D,F,U;if(e[r(212)](128,v)===0)_+=e.oeLup(g,v);else if(e[r(701)](e.KiLWh(224,v),192))if(l+1>=t)_+=y;else if(e[r(1228)](r(846),"XVubc"))_0x11f7c7[r(405)](_0x5a5dec);else if(C=m[e.omXqh(l+x,1)],e[r(437)](e[r(892)](192,C),128))_+=y;else{if(e[r(291)]!==e[r(291)])return _0x5b6b30?.[r(1215)](Z=>Z.key===_0x51f64c)?.value;U=e[r(262)](e[r(892)](31,v)<<6,e[r(1206)](63,C)),e[r(1576)](U,128)?_+=y:(_+=e[r(537)](g,U),l++)}else if(e[r(1220)](e[r(1223)](240,v),224))e[r(1581)](e.AyqgK(l,2),t)?_+=y:e[r(382)](e[r(1509)],e[r(970)])?this[r(679)+r(1172)]=_0x11d74c:(C=m[e.omXqh(e[r(1619)](l,x),1)],D=m[e[r(1182)](e[r(1182)](l,x),2)],e.yrwMJ(e[r(1223)](e[r(262)](C,D<<8),49344),32896)?_+=y:(U=e[r(1035)](e.ybEWC(e.drGRB(e[r(1206)](15,v),12),e[r(371)](63&C,6)),e.XcLMI(63,D)),e[r(388)](U,2048)||e[r(1581)](U,55296)&&e[r(1062)](U,57343)?_+=y:(_+=e[r(949)](g,U),l+=2)));else if(e[r(649)](248,v)==240)if(e[r(363)](e[r(572)](l,3),t))_+=y;else if(C=m[e[r(1083)](l+x,1)],D=m[e[r(566)](e[r(394)](l,x),2)],F=m[e[r(1390)](e[r(292)](l,x),3)],e[r(900)](e[r(515)](e[r(262)](C,e[r(1109)](D,8)),e[r(1345)](F,16))&12632256,8421504))_+=y;else if(e.Ezagq(e[r(222)],e[r(660)])){let Z=_0x32384f[r(1354)](":");_0x2e562a&&(_0x429186=Z[r(1606)]),_0x1cdd3d+=Z[r(1606)];for(let ae=0;yPLWvC[r(1467)](ae,Z[r(1606)]);ae++)if(yPLWvC.lKyDT(4,Z[ae][r(1606)])){let $t=_0x2f042b[r(1488)+"g"](0,yPLWvC[r(345)](4,Z[ae].length)),yn=$t[r(1608)](Z[ae]);_0xbb5167[r(1034)](yn)}else _0x2fe4a1[r(1034)](Z[ae]);_0x337d7c=!1}else U=e[r(1035)](e.BlPdT(e[r(1109)](7&v,18),e.sKHbA(e[r(446)](63,C),12)),e[r(371)](e.EVtgF(63,D),6))|63&F,e[r(1466)](U,65536)||e.huqXV(U,1114111)?_+=y:(U-=65536,_+=e.zaLtq(g,e[r(1628)](e[r(486)](U,10),55296),e[r(394)](e[r(604)](1023,U),56320)),l+=3);else _+=y}return _}function ge(i,t){let r=n;if(e.GSBqg===e[r(595)]){let a=t[r(1606)],x=0;for(let y=0;e.TmKfR(y,a);y++){let _=t[r(453)+"At"](y);e[r(816)](_,55296)&&_<=56319&&e.SALKv(e[r(853)](y,1),a)&&(_=e[r(976)](e[r(572)](e[r(1515)](_,10),t[r(453)+"At"](++y)),56613888)),x+=e.jTIlS(_,128)?1:e[r(388)](_,2048)?2:e[r(388)](_,65536)?3:4}e[r(346)](V,i,x);let g=T(i,x),m=i[r(1029)];for(let y=0;y<a;y++){let _=t[r(453)+"At"](y);if(e.FOFwb(_,55296)&&e[r(1549)](_,56319)&&e[r(388)](y+1,a)&&(_=e.BvQZl(e.LCtWH(_,10),t[r(453)+"At"](++y))-56613888),e[r(730)](_,128))m[g++]=_;else if(e[r(1100)](e.uaiyP,r(888))){let l=_0x58d90c[r(1488)+"g"](0,4-_0x5d0467[_0x1bce3d][r(1606)]),v=l[r(1608)](_0x32e763[_0x13378f]);_0x5a1932[r(1034)](v)}else e[r(590)](_,2048)?m[g++]=e[r(1485)](e[r(604)](e[r(486)](_,6),31),192):(_<65536?m[g++]=e[r(1173)](e[r(659)](e[r(963)](_,12),15),224):(m[g++]=e.JwneI(e[r(1321)](_,18)&7,240),m[g++]=e[r(1242)](e.xtVem(e.YgoeR(_,12),63),128)),m[g++]=e[r(1261)](e[r(242)](e[r(486)](_,6),63),128)),m[g++]=e.dSeXe(e[r(446)](63,_),128)}}else{let a=_0x38268e[r(1149)];if(e[r(302)](e[r(566)](a,_0x5ad931),_0x2145e5[r(1050)]))throw new _0x457555(e.FLTsO);return _0x522b89.offset+=_0x49321c,a}}function Ke(i,t){let r=n,a=e[r(923)](T,i,t[r(1050)]),x=i[r(1029)],g=t[r(1029)];for(let m=0,y=t[r(1050)];e[r(1216)](m,y);m++)x[m+a]=g[m]}function ne(i){let t=n;return i.bytes[e[t(1090)](O,i,1)]}function Ze(i,t){let r=n;if(e[r(1340)](e.lIvbx,e[r(391)])){let a=e.QcuCh(T,i,1);i[r(1029)][a]=t}else _0x5d45d4[r(1492)][r(651)+r(1637)](_0x1003b5)}function X(i){let t=n,r=0,a=0,x;do x=e.fgObu(ne,i),e[t(1398)](r,32)&&(a|=e[t(1452)](127,x)<<r),r+=7;while(e[t(975)](128,x));return a}function V(i,t){let r=n;for(t>>>=0;e[r(816)](t,128);)e[r(1294)](Ze,i,e.admpn(127,t)|128),t>>>=7;e[r(469)](Ze,i,t)}function ut(i,t){let r=n,a={nCtSh:function(x,g){return x|g},RKJDg:function(x,g){return e[R(1261)](x,g)},SplGO:function(x,g){return e[R(317)](x,g)},WfoBe:function(x,g){return e[R(1103)](x,g)},mfWOH:function(x,g){return x|g}};if(e[r(528)](e[r(336)],e.RkHTX))return _0x28d12c[r(405)](_0x198b1d),!1;{let x=0,g=0,m=0,y;if(y=e[r(868)](ne,i),x=e[r(1452)](127,y),e[r(892)](128,y)&&(y=e[r(704)](ne,i),x|=e[r(212)](127,y)<<7,e.IMOwV(128,y)&&(y=e.bqjCj(ne,i),x|=e.IVwxi(e[r(881)](127,y),14),e[r(1555)](128,y)&&(y=e[r(760)](ne,i),x|=e[r(1103)](e[r(881)](127,y),21),128&y&&(y=e[r(1019)](ne,i),g=e[r(871)](127,y),128&y))))){if(e.BTVlQ(r(244),r(769)))this[r(1011)]&&this._ws.close(_0xfe71ba,_0x36171c);else if(y=e.gvYhI(ne,i),g|=e.VzPwR(127,y)<<7,e[r(1142)](128,y)&&(y=e[r(1577)](ne,i),g|=e.nyRoW(e[r(1629)](127,y),14),e[r(659)](128,y)&&(y=e[r(525)](ne,i),g|=e[r(490)](127,y)<<21,e[r(890)](128,y)))){if(e[r(437)](e[r(995)],r(1284)))return new _0x314b12(a.nCtSh(a[r(767)](a[r(767)](_0x31713e[0],a[r(1295)](_0x59d9fe[1],8)),a[r(1393)](_0x3cb1a4[2],16)),a[r(1393)](_0x2dd1e9[3],24)),a[r(1191)](_0x1d73f3[4]|a[r(1393)](_0x3d3e46[5],8),a[r(1393)](_0xd13b67[6],16))|a[r(1295)](_0x53cc24[7],24),_0x2c1bfb);y=e.RlDPg(ne,i),m=e.Dytda(127,y),e[r(975)](128,y)&&(y=e[r(358)](ne,i),m|=e[r(1241)](127&y,7))}}return{low:e[r(1242)](x,e[r(209)](g,28)),high:e[r(1035)](e[r(1110)](g,4),e[r(371)](m,24)),unsigned:t}}}function J(i,t){let r=n,a=e[r(1030)](t[r(700)],0),x=e.AmzVM(e.LIHxe(t.low,28),e[r(1374)](t[r(532)],4))>>>0,g=e[r(574)](t[r(532)],24),m=g===0?e.BTVlQ(0,x)?e[r(730)](a,16384)?e[r(1576)](a,128)?1:2:a<2097152?3:4:e[r(388)](x,16384)?x<128?5:6:e[r(502)](x,2097152)?7:8:e[r(1466)](g,128)?9:10,y=e[r(944)](T,i,m),_=i[r(1029)];switch(m){case 10:_[e.wFNPO(y,9)]=e[r(287)](e[r(341)](g,7),1);case 9:_[e[r(536)](y,8)]=m!==9?e.JwneI(128,g):127&g;case 8:_[e[r(1187)](y,7)]=m!==8?e[r(1242)](x>>>21,128):x>>>21&127;case 7:_[e[r(508)](y,6)]=e[r(720)](7,m)?e.BlPdT(x>>>14,128):e[r(1010)](e[r(1030)](x,14),127);case 6:_[e[r(752)](y,5)]=m!==6?e[r(515)](e[r(1110)](x,7),128):e.QEIMI(e[r(341)](x,7),127);case 5:_[y+4]=m!==5?e.Lpmzo(128,x):127&x;case 4:_[e[r(1628)](y,3)]=e[r(506)](4,m)?e[r(1065)](e[r(425)](a,21),128):e.Dytda(a>>>21,127);case 3:_[e[r(1187)](y,2)]=e.bAbxL(3,m)?e[r(1108)](e[r(1110)](a,14),128):e[r(543)](a,14)&127;case 2:_[e.omXqh(y,1)]=e.ZBlyD(2,m)?e[r(1478)](e[r(341)](a,7),128):e.lwQZk(a>>>7,127);case 1:_[y]=e.TtgyM(1,m)?e[r(1065)](128,a):e[r(658)](127,a)}}function _t(i){return e[n(868)](A,i)}function re(i){let t=n;if(e[t(458)]("WHvQW",t(1646)))e.SmwDW(_0x3140fd,_0x4da438,32),e[t(1032)](_0x23ca6a,_0x23f6be,e[t(1595)](_0x3fa8e7,_0x5de8f3));else return e[t(537)](E,i)}let yt=65536,ye=e[n(875)],bt=yt*yt,Yi=bt*bt,Xi=Yi/2,et=String[n(1444)+"e"].charCodeAt;class K{constructor(t,r,a){let x=n;this[x(592)]=!0,this[x(700)]=0|t,this.high=e[x(1600)](0,r),this[x(1046)]=!!a}static[n(592)](t){let r=n,a={QADMu:function(x,g){return x!=g},GibHS:e[r(465)]};if(e[r(1175)]!==e.yZrbe)return t&&e[r(919)](!0,t.isLong);{let x={cpPBS:function(g,m){return EbMkGq.QADMu(g,m)},hMkFO:EbMkGq[r(223)],MVnsw:r(822),CFTmz:r(762)+"le"};_0x102fe6.r=g=>{let m=r;x[m(1427)](x[m(255)],typeof _0x36cddf)&&_0x3328f5[m(198)+m(1275)]&&_0x589d8e[m(542)+"operty"](g,_0x47ce66["toString"+m(1275)],{value:x[m(964)]}),_0x17a84b[m(542)+m(325)](g,x[m(656)],{value:!0})}}}static[n(479)](t,r,a){return new K(t,r,a)}static fromBytes(t,r,a){let x=n;return a?K[x(682)+x(385)](t,r):K["fromByte"+x(1269)](t,r)}static[n(682)+n(385)](t,r){let a=n,x={eLpIL:e[a(821)],rcbwL:function(g,m){return g(m)}};if(e[a(1489)](e[a(588)],"xcYDD")){let g=_0x37fa87[a(494)+a(859)](_0x589552);return _0x1bd3f1&&g[a(621)+a(196)](EFTlby.eLpIL,()=>_0x15cfe1()),EFTlby[a(849)](_0x5d616e,g).then(()=>{})}else return new K(e.HzSJV(e[a(622)](t[0]|e.drGRB(t[1],8),e[a(1280)](t[2],16)),e.yUWzv(t[3],24)),e[a(1108)](e[a(511)](e[a(927)](t[4],e[a(461)](t[5],8)),e[a(317)](t[6],16)),e[a(317)](t[7],24)),r)}static[n(682)+n(1269)](t,r){let a=n;return new K(e.Lpmzo(e[a(1231)](e[a(1300)](e[a(209)](t[4],24),e[a(1374)](t[5],16)),e.obYmM(t[6],8)),t[7]),e.jtFXl(e[a(378)](e.HdShR(t[0],24),e[a(317)](t[1],16)),t[2]<<8)|t[3],r)}static[n(192)](t){let r=n;return e.BCUKV(t,ye)?Qi:new K(e[r(425)](e[r(1485)](et[r(1518)](t,0)|e[r(371)](et[r(1518)](t,1),8),e.PSZnE(et[r(1518)](t,2),16))|e.xSjgM(et[r(1518)](t,3),24),0),e[r(378)](e.JwneI(e[r(262)](et[r(1518)](t,4),e.JihaT(et[r(1518)](t,5),8)),e[r(1241)](et[r(1518)](t,6),16)),et.call(t,7)<<24)>>>0,!0)}[n(1457)](){let t=n;return String[t(1562)+t(1481)](255&this.low,e.iPsZQ(e[t(341)](this[t(700)],8),255),e[t(1233)](this.low,16)&255,e[t(543)](this[t(700)],24),e[t(1010)](255,this[t(532)]),e[t(871)](e[t(1171)](this[t(532)],8),255),e[t(1200)](this.high>>>16,255),e[t(1110)](this.high,24))}static[n(1356)+"er"](t,r=!0){let a=n;if(e[a(949)](isNaN,t))return r?Hc:Qi;if(r){if(e[a(363)](t,Yi))return Kc}else{if(e[a(1469)](t,-Xi))return Wc;if(e[a(363)](e[a(1628)](t,1),Xi))return jc}return K[a(479)](e.rzpDF(e[a(1306)](t,bt),0),e[a(1478)](e[a(928)](t,bt),0),r)}[n(1416)](){let t=n;return this[t(1046)]?e[t(839)](this[t(532)],0)*bt+e[t(1412)](this[t(700)],0):e[t(216)](e[t(243)](this.high,bt),this[t(700)]>>>0)}[n(1209)](){let t=n;return e[t(241)](0,this.high)&&this[t(700)]===0}[n(1178)](t){let r=n;K[r(592)](t)||(t=K.fromNumber(t));let a=e[r(331)](this[r(532)],16),x=e[r(1042)](65535,this[r(532)]),g=e[r(399)](this[r(700)],16),m=e[r(892)](65535,this[r(700)]),y=e[r(574)](t.high,16),_=65535&t.high,l=t[r(700)]>>>16,v=e.KcDVz(65535,t[r(700)]),C=0,D=0,F=0,U=0;return U+=m+v,F+=e[r(331)](U,16),U&=65535,F+=e[r(655)](g,l),D+=e[r(718)](F,16),F&=65535,D+=e.LAOPV(x,_),C+=e[r(839)](D,16),D&=65535,C+=e.TExGz(a,y),C&=65535,K[r(479)](e[r(511)](e[r(403)](F,16),U),e[r(1065)](e[r(403)](C,16),D),this[r(1046)])}[n(335)](t){let r=n;return K[r(592)](t)||(t=K[r(1356)+"er"](t)),e[r(807)](this[r(1046)],t[r(1046)])&&e[r(1110)](this[r(532)],31)===1&&e[r(701)](e.sfdCu(t[r(532)],31),1)?!1:e[r(779)](this.high,t[r(532)])&&e[r(629)](this.low,t.low)}[n(876)](){let t=n;if(e[t(1228)](e[t(432)],e.pvrBE))return this[t(700)]===-1&&e.QgeFB(-1,this[t(532)])?K[t(479)](0,0,this[t(1046)]):e[t(241)](-1,this[t(700)])?K[t(479)](0,e.tuCAQ(this[t(532)],1),this.unsigned):K.fromBits(e.omXqh(this.low,1),this[t(532)],this[t(1046)]);_0x57ad34[t(1034)](_0x138d63)}[n(1440)](t){let r=n;return t?this[r(431)+"E"]():this[r(968)+"E"]()}toBytesLE(){let t=n,r=this.high,a=this[t(700)];return[255&a,e[t(718)](a,8)&255,e.qzlzz(e[t(1171)](a,16),255),e[t(1120)](a,24),255&r,e[t(298)](e.mDBKM(r,8),255),e[t(619)](e.FjbQm(r,16),255),e[t(1387)](r,24)]}[n(968)+"E"](){let t=n,r=this[t(532)],a=this[t(700)];return[r>>>24,e.iFNfp(r>>>16,255),e[t(710)](e[t(839)](r,8),255),e.OVmJN(255,r),e[t(1124)](a,24),e[t(1e3)](a,16)&255,e[t(604)](a>>>8,255),e[t(1010)](255,a)]}}let Qi=new K(0,0,!1),Hc=new K(0,0,!0),jc=K[n(479)](-1,2147483647,!1),Kc=K[n(479)](-1,-1,!0),Wc=K[n(479)](0,-2147483648,!1);var nt=(function(i){let t=n;return i[i[e[t(1153)]]=5001]=e[t(1153)],i[i[e[t(920)]]=5002]=e[t(920)],i[i[e[t(1413)]]=5003]="MAX_RETR"+t(676)+"R",i[i[t(854)+t(734)]=5004]="MESSAGE_"+t(734),i[i[e[t(609)]]=5005]=e[t(609)],i})({});class vt{constructor(t){let r=n;this[r(1061)]=t,this.target=null}}class Zi extends vt{constructor(t,r){let a=n;super(t),this[a(1422)]=r&&r[a(1422)]||null}}class es extends vt{constructor(t,r){let a=n,x=e[a(1289)].split("|"),g=0;for(;;){switch(x[g++]){case"0":this[a(1422)]=r&&r[a(1422)]||"";continue;case"1":this[a(1181)]=r&&r[a(1181)]||null;continue;case"2":this[a(214)]=r&&r.colno||0;continue;case"3":this[a(451)]=r&&r[a(451)]||"";continue;case"4":this[a(1362)]=r&&r[a(1362)]||0;continue;case"5":this[a(692)]=r&&r[a(692)]||5001;continue;case"6":super(t);continue}break}}}class ts extends vt{constructor(t,r){let a=n;super(t),this[a(692)]=r&&r.code||0,this[a(1483)]=r&&r[a(1483)]||"",this.wasClean=r&&r[a(1079)]||!1,this[a(790)+a(1521)]=r&&r["willReco"+a(1521)]||!1}}class ns extends vt{constructor(t,r){let a=n;super(t),this.data=r&&r[a(680)]||null}}class rs extends ns{constructor(t,r){let a=n;super(t),this[a(680)]=r&&r[a(680)]||null,this[a(1422)]=r&&r[a(1422)]||null}}class is extends vt{constructor(t,r){let a=n;super(t),this[a(680)]=r&&r.data||null}}function Ae(i,{message:t,code:r,error:a}){return new es(i,{message:t,code:r,error:a})}function De(i,{code:t,reason:r,wasClean:a,willReconnect:x}){return new ts(i,{code:t,reason:r,wasClean:a,willReconnect:x})}function ss(i,{data:t,message:r}){return new rs(i,{data:t,message:r})}function os(i,{data:t}){return new is(i,{data:t})}function Lr(i,{message:t}){return new Zi(i,{message:t})}class as{constructor(t,r){let a=n;this[a(1395)+"s"]=t,this.maxRetries=r,this[a(414)+a(213)]=0,this[a(1003)+a(1310)+"riesCount"]=0}[n(1018)+"pointConfig"](){let t=n;this[t(414)+"ndex"]=0,this[t(1003)+t(1310)+t(1262)+"t"]=0}resetTries(){let t=n;if(e[t(1612)]!==e[t(1612)]){let r=e[t(1389)](_0x16a5a8,_0x2f2484,1);_0x375427[t(1029)][r]=_0xbffdca}else this[t(1003)+t(1310)+"riesCount"]=0}["getCurre"+n(1586)+"nt"](){let t=n;return this.endpoints[this[t(414)+t(213)]]}[n(252)+n(1586)+n(1372)+n(729)](){let t=n;return this[t(1003)+"ndpointT"+t(1262)+"t"]}[n(1320)+"chMaxTries"](){let t=n,r={Kibeu:function(a,x){return e[R(1411)](a,x)},bLIEN:function(a,x){return a<<x},ciTFS:function(a,x){return e[R(1555)](a,x)},WrPpy:function(a,x){return e.jyZVI(a,x)},XnCgF:function(a,x){return e[R(1167)](a,x)},OJwdh:function(a,x){return e[R(1512)](a,x)}};if(e[t(460)]("hOqZc",e[t(547)]))_0x2ca34d=uKzRMY[t(1615)](_0x7bc71f,_0x3e90c1),_0x48901f|=uKzRMY[t(355)](uKzRMY[t(1643)](127,_0x47b1aa),21),uKzRMY[t(1643)](128,_0x19507a)&&(_0x312364=uKzRMY[t(1615)](_0x467ff0,_0x350fb4),_0x15b268=uKzRMY[t(475)](127,_0x71bd49),128&_0x1499e1&&(_0x3a2f89=uKzRMY[t(857)](_0x3ef5f7,_0x1d1d6e),_0x3cb0d2|=uKzRMY[t(1315)](127,_0x14bdad)<<7));else return!!(e.ELMYZ(this[t(414)+t(213)],this[t(1395)+"s"].length)||e.Wvrfy(this[t(414)+"ndex"],this[t(1395)+"s"][t(1606)]-1)&&this[t(1003)+t(1310)+"riesCount"]===this[t(480)+"es"])}[n(519)+n(587)+n(711)+n(1464)+n(823)](){let t=n;return e.wOTLn(this[t(414)+t(213)],this[t(1395)+"s"][t(1606)])?!0:e[t(266)](this[t(1003)+t(1310)+t(1262)+"t"],this[t(480)+"es"])}["replaceBackupEndpointAndUpdateCo"+n(1293)](){let t=n;return this[t(1003)+"ndpointT"+t(1262)+"t"]=1,this[t(414)+"ndex"]++,this[t(1395)+"s"][this[t(414)+t(213)]]}[n(252)+"ntEndpoi"+n(1369)+n(632)](){let t=n;return this[t(1003)+t(1310)+"riesCount"]++,this[t(252)+"ntEndpoint"]()}}let St=(e.sVmis(n(980)+"d",typeof globalThis)&&e.VeXuB===globalThis[n(1583)+n(1421)].name||e[n(1585)](n(980)+"d",typeof window)&&e[n(675)](e.VeXuB,window[n(1583)+n(1421)][n(1186)]))&&e[n(576)](e[n(465)],typeof document),ft=e[n(576)](e[n(465)],typeof globalThis)&&(e.lWXuE===globalThis[n(1583)+n(1421)].name||"Dedicate"+n(232)+n(1426)+"pe"===globalThis[n(1583)+n(1421)][n(1186)])&&e[n(576)](e[n(465)],typeof tt),Wt=(n(980)+"d"!=typeof globalThis&&e[n(779)](e[n(1561)],globalThis[n(1583)+n(1421)].name)||e.DUKka==typeof globalThis||e[n(576)](e.DUKka,typeof globalThis)&&!!globalThis[n(1093)+"Bridge"])&&e[n(1085)](e.DUKka,typeof wx),Jt=e[n(465)]!=typeof globalThis&&(e[n(1346)](n(1288)+n(232)+n(1426)+"pe",globalThis[n(1583)+n(1421)][n(1186)])||e.ATnmP(e.qonAl,globalThis["construc"+n(1421)][n(1186)])||e[n(1228)]("ServiceW"+n(190)+n(1040),globalThis[n(1583)+n(1421)][n(1186)]))&&e.AVMzr(n(980)+"d",typeof self),Jc=e.olEiG(e[n(465)],typeof globalThis)&&e.DpuLs(e[n(1561)],globalThis["construc"+n(1421)].name)&&e[n(1575)](e[n(465)],typeof global)&&e[n(933)](e.lWXuE,global[n(1583)+n(1421)][n(1186)])&&e.xtQaT(e[n(465)],typeof process)&&!!process[n(785)];class Mr{constructor(){let t=n;if(e[t(328)](e[t(1525)],e[t(1525)]))return this[t(1192)]>=this[t(1071)+t(729)];this[t(955)+"rs"]={}}emit(t,...r){let a=n,x=this[a(955)+"rs"][t];if(x)x.slice().forEach(g=>g.fn.apply(g[a(188)],r));else if(e[a(268)]===t&&!this.onerror){let g=r[a(1606)]&&r[0];if(e[a(1565)](g,Error))throw g;let m=new Error(e[a(1592)](e[a(811)],g?e[a(364)](" (",g[a(1422)])+")":""));throw m.context=g,g}return this}off(t,r){let a=n;if(e[a(241)](void 0,t))this._listeners={};else if(e[a(375)](void 0,r))this[a(955)+"rs"][t]=null;else{let x=this._listeners[t];if(x)for(let g=0;e[a(1145)](g,x[a(1606)]);)e.Wvrfy(x[g].fn,r)?x[a(850)](g,1):++g}return this}on(t,r,a){let x=n;return(this[x(955)+"rs"][t]||(this[x(955)+"rs"][t]=[]))[x(1034)]({fn:r,ctx:a||this}),this}}class $c extends Mr{["_formatE"+n(914)+n(1599)](t){let r=n;return t[r(187)]||t[r(1281)]?(r(1179)+" "+(t[r(187)]||"")+" code: "+(t.errNo||""))[r(191)]():JSON[r(600)+"y"](t)}constructor(t,r,a){let x=n;super(),this[x(667)]=null,Wt&&wx[x(880)+x(1546)]&&(this[x(667)]=wx[x(880)+x(1546)]({url:t,protocols:r,header:a,fail:this[x(1053)+x(233)+x(763)][x(411)](this),success:this[x(1053)+"ocketSuc"+x(690)+x(265)].bind(this)})),ft&&tt[x(880)+x(1546)]&&(this._socket=tt[x(880)+x(1546)]({url:t,protocols:r,header:a,fail:this[x(1053)+x(233)+x(763)][x(411)](this),success:this[x(1053)+x(1401)+x(690)+"ler"][x(411)](this)}))}["_createS"+n(1401)+n(690)+n(265)](){let t=n;Promise[t(998)]()[t(851)](()=>{this._addWsListeners()})}[n(1053)+n(233)+n(763)](t){let r=n,a={kMrGg:function(x,g,m){return e[R(545)](x,g,m)},dftPN:function(x,g,m){return e[R(865)](x,g,m)},NwSAm:e[r(829)]};Promise[r(998)]().then(()=>{let x=r,g=a[x(1563)](Ae,x(1181),{message:this[x(1259)+x(914)+x(1599)](t)});this[x(999)]("error",g);let m=a.dftPN(De,a[x(253)],{reason:this[x(1259)+x(914)+x(1599)](t)});this[x(999)](a.NwSAm,m)})}_addWsListeners(){let t=n,r={SXQby:"close",fMreN:function(a,x,g){return e.hJKFZ(a,x,g)}};this._socket[t(202)](a=>{let x=t,g={EjYEA:function(m,y){return e[R(744)](m,y)}};if(e[x(271)]===e.dQmXc)return YSahNI.EjYEA(this[x(414)+"ndex"],this[x(1395)+"s"][x(1606)])?!0:this[x(1003)+x(1310)+x(1262)+"t"]>this[x(480)+"es"];this[x(999)](x(337),e.jZNPp(os,e.hXcPH,{...a,data:a[x(187)]||""}))}),this[t(667)][t(845)](a=>{let x=t;this[x(999)](r.SXQby,r[x(708)](De,x(296),{...a}))}),this[t(667)][t(200)+"e"](a=>{let x=t;this[x(999)](e[x(1012)],ss(e[x(1012)],{...a}))}),this._socket[t(406)](a=>{let x=t;this[x(999)](e[x(268)],e[x(1365)](Ae,e.LLSYA,{...a,message:a[x(187)]||""}))})}[n(1470)](t){let r=n;if(e[r(1263)]("AntGn",e[r(908)])){if(this[r(1570)][r(847)+r(771)+"nect"]||this[r(935)+r(869)])return;this._handleReconnect()}else if(e[r(1565)](t,Uint8Array)){let a=t[r(798)].slice(t.byteOffset,e[r(1414)](t[r(683)+"th"],t[r(305)+"et"]));this._socket&&this[r(667)][r(1470)]({data:a,fail:x=>{let g=r;this[g(999)](e.LLSYA,Ae(g(1181),{message:this[g(1259)+g(914)+"age"](x)}))}})}else this._socket&&this[r(667)][r(1470)]({data:t,fail:a=>{let x=r;this.emit(e[x(268)],e[x(1448)](Ae,e[x(268)],{message:this[x(1259)+x(914)+x(1599)](a)}))}})}[n(296)](t,r){let a=n;this._socket&&this[a(667)][a(296)]({code:t,reason:r})}[n(621)+n(196)](t,r){this.on(t,r)}["removeEv"+n(623)+n(630)](t,r){this[n(333)](t,r)}get readyState(){let t=n;if(e[t(1055)]!==e[t(1055)]){let r=this[t(843)][t(1566)+t(315)+"nc"](this[t(640)]),a=_0x582bb2[t(1454)](r||"{}");return _0xb5da5e[t(727)](a)}else return this[t(667)][t(230)+"te"]}get binaryType(){let t=n,r={mjQxF:function(a,x,g){return e[R(674)](a,x,g)}};if(e[t(375)](e[t(1201)],t(433)))WTdppb.mjQxF(_0x19ac8d,_0x413a38,66),WTdppb[t(1417)](_0x5dea92,_0x1da896,_0x3af955[t(1606)]),WTdppb.mjQxF(_0x3e73e2,_0x246d64,_0x61d690);else return this[t(667)][t(715)+"pe"]}set[n(715)+"pe"](t){}get[n(747)](){let t=n;return this[t(667)][t(747)]}get[n(820)](){let t=n;return this._socket[t(820)]}get[n(703)+"ns"](){return this[n(667)].extensions}get[n(1311)+n(1611)](){let t=n;if(e[t(807)](t(586),t(586)))this[t(552)]=!0,this[t(300)]();else return 0}}function Vc(i,t){let r=n;if(t)return new t(i[r(747)],i[r(820)]);if(e[r(470)](Wt,ft))return new $c(i.url,i[r(820)],i[r(1260)]);if(e[r(470)](St,Jt)&&e[r(576)](e[r(465)],typeof WebSocket)&&WebSocket)return new WebSocket(i[r(747)],i[r(820)+"s"])}function Yc(i){let t=n;if(e[t(794)]===e[t(794)]){let r=(t(599)+"2").split("|"),a=0;for(;;){switch(r[a++]){case"0":if(i)return!0;continue;case"1":if(ft&&tt[t(880)+"ocket"])return!0;continue;case"2":return!1;case"3":if(Wt&&wx[t(880)+t(1546)])return!0;continue;case"4":if(e.JRpsP(St,Jt)&&e[t(1585)](t(980)+"d",typeof WebSocket)&&WebSocket)return!0;continue}break}}else{let r=_0x2c9db3(_0x56fa49),a=_0x5f078c[t(1050)];return _0x54b6c1[t(1050)]=e[t(752)](_0x5bfb9e[t(1149)],r),a}}function cs(i,t,r){let a=n,x={RWmnE:function(y,_){return e[R(458)](y,_)},ktGPk:e[a(636)],aIdej:function(y,_){return e.ZUJPY(y,_)},kfPFU:e[a(817)],xOcYG:function(y,_){return e[a(448)](y,_)}},g=-1;async function m(y){let _=a;if(x[_(229)]("vFSIo",x[_(1336)]))return x.aIdej(y,g)?Promise[_(842)](new Error(x[_(1554)])):(g=y,y===r[_(1606)]?Promise[_(998)]():r[y][_(411)](i)(t,m.bind(null,x[_(561)](y,1))));this[_(999)](_(1181),_0x4c3712),this[_(1227)]&&this[_(1227)](_0x12be6a)}m(0)}function ds(i){let t=n,r={tEOIF:function(g,m,y){return e[R(1226)](g,m,y)}},a=0,x=0;for(let g=0;g<i[t(1606)];++g)if(x=i[t(453)+"At"](g),x<128)a+=1;else if(e.uzUaB(x,2048))a+=2;else if(e[t(462)](e[t(1434)](64512,x),55296)&&e[t(1228)](e[t(948)](64512,i.charCodeAt(g+1)),56320)){if(e[t(694)](e.bPQGR,e[t(1587)]))return _0x501308[t(1029)][SgGYrn.tEOIF(_0x238b61,_0x497252,1)];++g,a+=4}else a+=3;return a}function xs(i,t,r){let a=n;if(r-t<1)return"";let x="";for(let g=t;e[a(645)](g,r);){let m=i[g++];if(m<=127)x+=String["fromChar"+a(1481)](m);else if(e[a(1299)](m,192)&&m<224)x+=String[a(1562)+a(1481)](e[a(742)](e[a(1459)](31&m,6),e[a(1200)](63,i[g++])));else if(m>=224&&m<240)x+=String[a(1562)+a(1481)](e[a(461)](e[a(775)](15,m),12)|e[a(317)](e[a(837)](63,i[g++]),6)|63&i[g++]);else if(e[a(1527)](m,240)){let y=e.lLKrY(e[a(1485)](e[a(1600)](e.NwNrR(7,m)<<18,e[a(1103)](e[a(1142)](63,i[g++]),12)),e[a(673)](63,i[g++])<<6)|e[a(890)](63,i[g++]),65536);x+=String[a(1562)+a(1481)](e.AVuiq(55296,e[a(716)](y,10))),x+=String[a(1562)+a(1481)](e[a(1044)](56320,e[a(207)](1023,y)))}}return x}function Br(i,t,r){let a=n,x={XogIE:e[a(829)],OAwGr:e[a(268)]};if(e[a(382)]("TJVSb",a(796)))this[a(1415)+a(1378)]?.[a(1616)](),this[a(999)](e.QPkPh,a(1184)),this[a(1415)+a(1378)]?.[a(1320)+a(1523)+"nt"]()?this._handleReconnect():this[a(1373)]();else{let g=r,m,y;for(let _=0;e[a(413)](_,i[a(1606)]);++_)if(m=i[a(453)+"At"](_),e[a(1106)](m,128))t[r++]=m;else if(m<2048)t[r++]=e[a(963)](m,6)|192,t[r++]=e[a(1600)](e[a(390)](63,m),128);else if((64512&m)===55296&&e.Ezagq(e[a(1556)](64512,y=i.charCodeAt(e.xoQjm(_,1))),56320)){let l=e[a(1024)][a(1354)]("|"),v=0;for(;;){switch(l[v++]){case"0":m=e[a(1212)](65536,e[a(1280)](e[a(892)](1023,m),10))+(1023&y);continue;case"1":++_;continue;case"2":t[r++]=e[a(1368)](e[a(963)](m,18),240);continue;case"3":t[r++]=e[a(1286)](e.kDTHi(e[a(716)](m,6),63),128);continue;case"4":t[r++]=e[a(1314)](e[a(1144)](m,12),63)|128;continue;case"5":t[r++]=e[a(1600)](e[a(1002)](63,m),128);continue}break}}else if(e[a(193)]!=="xoshM"){let l=(a(286)+"4")[a(1354)]("|"),v=0;for(;;){switch(l[v++]){case"0":this[a(1011)][a(1441)+a(623)+a(630)]("message",this[a(1039)+"ge"]);continue;case"1":this._ws[a(1441)+"entListe"+a(630)](a(337),this[a(1453)]);continue;case"2":if(!this[a(1011)])return;continue;case"3":this[a(1011)][a(1441)+a(623)+a(630)](x[a(1484)],this._onClose);continue;case"4":this[a(1011)]["removeEv"+a(623)+a(630)](x[a(1151)],this._onError);continue}break}}else t[r++]=e[a(368)](m>>12,224),t[r++]=e[a(871)](e[a(916)](m,6),63)|128,t[r++]=63&m|128;return r-g}}async function us(i){let t=n;if(t(387)==typeof i){let r=new Uint8Array(e[t(1411)](ds,i));return Br(i,r,0),r}return e.vUpZf(i,ArrayBuffer)?new Uint8Array(i):new Uint8Array(i[t(798)],i.byteOffset,i[t(683)+"th"])}function Xc(i){let t=n,r={ETlWw:function(a,x){return e[R(1499)](a,x)}};try{if(e[t(687)](e.okkTa,t(435)))return e[t(576)](e[t(626)],typeof i)&&(i instanceof ArrayBuffer||i[t(798)]&&e.vUpZf(i.buffer,ArrayBuffer))||t(387)!=typeof i?"":(JSON[t(1454)](i),e[t(439)]);{let a=t(972)+_0x4670b5+(" timeout"+t(907)+t(1503)+"ached");this[t(1420)](a),this[t(1363)+t(1574)+t(981)](e.OjSUX(_0x219ca5,e[t(268)],{message:a,code:_0x49e3eb[t(891)+t(676)+"R"]}));return}}catch{return e[t(384)]===e.EhHwB?e[t(323)](e[t(626)],typeof i)?e[t(1202)]:"":JxaFtW.ETlWw(_0x158022.offset,_0x2cbb86[t(1050)])}}let Qc=(i,t)=>{let r=n;switch(i){case r(1558):case e.uhrJU:return{[r(866)+i]:1,"x-tt-env":t};default:return{}}};class Zc{constructor(t){let r=n;this[r(1071)+"ount"]=t,this[r(1192)]=0}addCount(){let t=n;this[t(1192)]++}["checkRea"+n(1523)+"nt"](){let t=n;return this.count>=this[t(1071)+t(729)]}[n(1291)+n(795)](t=0){let r=n;this[r(1071)+r(729)]=t,this[r(1192)]=0}}async function e0(i){let t={WVXYL:e.YvXMj};return new Promise(r=>{let a=R,x={DSphh:function(g,m){return g(m)},stYjC:"unknown reason"};if(!St)return e[a(724)](r,a(1638)+a(1483));try{let g=document["createEl"+a(548)]("script");window[a(1626)+a(1123)]=m=>{let y=a;document[y(1492)][y(1564)+"ild"](g),window[y(1626)+y(1123)]=void 0,x[y(507)](r,m&&m[y(1385)]||x.stYjC)},g[a(1061)]=e[a(992)],g[a(759)]=e[a(1199)](i[a(898)](/^ws/,e[a(1397)]),e[a(1020)]);try{document.body[a(651)+a(1637)](g)}catch{if(e[a(1630)](e[a(524)],"qPMYV"))document[a(1492)][a(1564)+"ild"](g);else return{frameType:_0x3449cf,headers:[{key:a(1620)+a(523),value:t[a(319)]}],payload:void 0}}}catch{window[a(1626)+"JSONP"]=void 0,e.xwPoP(r,"unknown "+a(1483))}})}function rt(i,t,r){let a=n;return!!i?.find(x=>x[a(342)]===t&&x[a(474)]===r)}function Et(i,t){let r=n;return e[r(1504)](e[r(225)],e[r(1604)])?i?.find(a=>a[r(342)]===t)?.[r(474)]:this._socket[r(703)+"ns"]}let zr=null;async function t0(){let i=n;return zr||(zr=Promise[i(998)]()[i(851)](qe.bind(qe,e[i(404)]))),zr}class n0 extends Mr{constructor(t,r){let a=n;super(),this._dbName=t,this._keyPath=r,this[a(843)]=void 0,this[a(555)+a(373)]=null}async[n(1573)](){await this[n(1364)]()}async[n(1364)](){let t=n;if(!this[t(843)]){if(this[t(555)+t(373)])return this[t(555)+t(373)];try{let r=this._dbName,a=this._keyPath;this[t(555)+t(373)]=(async()=>{let x=t,{openDB:g}=await t0();this[x(843)]=await g(x(1626)+"_"+r,1,{upgrade(m){let y=x;if(y(797)==="cYStA"){let _=_0x50569f[y(1029)],l=_0x581626[y(1050)];return _[y(1606)]===l?_:_.subarray(0,l)}else m["createOb"+y(1307)+"e"](r,{keyPath:a})}})})(),await this[t(555)+t(373)]}catch(r){console[t(405)](r)}finally{this[t(555)+t(373)]=null}}}async[n(466)](t){let r=n,a={KcBiq:function(x,g){return e[R(1341)](x,g)},aGkgC:function(x,g){return e[R(1210)](x,g)}};try{return await this[r(1364)](),this[r(843)]?.[r(466)](this._dbName,t)}catch(x){if(e.IxyFD(e[r(685)],e[r(668)]))console[r(405)](x);else return function(...g){let m=r;return _0x1eee2a[m(1486)](GwXKnU[m(1491)](_0x1367ac,this),g),GwXKnU[m(826)](_0x4a28a3,_0x54a460[m(466)](this))}}}async[n(264)](t,r){let a=n;return await this[a(1364)](),this[a(843)]?.put(this[a(772)],t)}async[n(512)](t){let r=n;if(e[r(1402)](e[r(249)],r(1540)))try{return await this[r(1364)](),this[r(843)]?.delete(this[r(772)],t)}catch(a){console[r(405)](a)}else{if(!this[r(1011)])return;this[r(311)+r(1477)+"t"](_0x494f9d,_0x118933,_0x1fbe5d)}}async[n(240)](){let t=n;try{return await this._init(),this[t(843)]?.[t(240)](this[t(772)])}catch(r){console[t(405)](r)}}async[n(1590)](){let t=n;if(e[t(732)]!=="UfByt")return await this._init(),this[t(843)]?.[t(929)+"ys"](this._dbName);try{return!!this[t(843)]}catch(r){return _0x49bfa8.log(r),!1}}async[n(815)](){let t=n;return t(1644)!==e[t(1033)]?(_0x15453c[t(405)](t(648),_0x5dba13,_0x43318b,_0x4d65aa),this[t(843)][t(264)]({cursor_name:_0x103709,cursor:_0x6318d,service:_0x36e411})):(await this[t(1364)](),this[t(843)]?.[t(815)](this._dbName))}async[n(429)](){let t=n;try{this[t(843)]?.[t(296)](),this[t(843)]=void 0}catch(r){console[t(405)](r)}}get[n(1140)](){let t=n,r={nlaio:function(a,x){return e[R(499)](a,x)},hnYFZ:function(a,x,g){return a(x,g)},JRjnj:function(a,x,g,m){return e[R(245)](a,x,g,m)},hIClf:function(a,x){return e[R(1083)](a,x)},GBpJq:function(a,x,g){return e[R(707)](a,x,g)}};try{if(e.HnQSB(e[t(1552)],e[t(1552)])){let a=0,x=[];for(;r[t(1265)](a,_0x417cc4[t(683)+"th"]);){let{offset:g}=_0x40bf7e(_0x49b73d,a);a=g;let m={cursor_name:"",cursor:0,service:0},{value:y,offset:_}=_0x3fb0ce(_0x491fc5,a);m.service=y,a=_;let{value:l,offset:v}=r[t(1498)](_0xabc45e,_0x307d93,a);a=v,m["cursor_n"+t(1614)]=r[t(567)](_0x1678b8,_0x2dae36,a,r[t(1436)](a,l)),a+=l;let{value:C,offset:D}=r[t(1132)](_0x325f92,_0x2f0d03,a);m.cursor=C.toNumber(),a=D,x[t(1034)](m)}return x}else return!!this._qosDB}catch(a){return console[t(405)](a),!1}}}class r0{constructor(t,r){let a=n;this[a(583)]=t,this[a(1138)]=r,this[a(843)]=localStorage}async openDB(){}get _prefix(){let t=n;return t(1626)+"_"+this[t(583)]}async[n(466)](t){let r=n,a=this[r(843)][r(1621)](this[r(640)]);return JSON.parse(e[r(470)](a,"{}"))[t]}async[n(264)](t,r){let a=n,x=this[a(843)].getItem(this[a(640)]),g=JSON[a(1454)](e[a(1458)](x,"{}"));return g[r||t[this[a(1138)]]]=t,this[a(843)][a(938)](this._prefix,JSON[a(600)+"y"](g)),r||t[this[a(1138)]]}async del(t){let r=n,a=this[r(843)][r(1621)](this._prefix),x=JSON.parse(e[r(937)](a,"{}"));return x[t]=void 0,this[r(843)][r(938)](this[r(640)],JSON[r(600)+"y"](x))}async[n(240)](){let t=n,r={ksTaI:function(a,x){return e[R(1565)](a,x)},xMmSt:function(a,x){return e[R(607)](a,x)},ofjCD:e[t(761)],PpiCK:function(a,x){return e[t(1319)](a,x)}};if(e[t(306)]==="cdeja"){if(PQFuDG.ksTaI(_0x2381bf,_0xc3c878)){if(_0x51b3db===t(321))return _0x244d23[t(466)](_0x54928f);if(PQFuDG[t(303)](_0x1e01ba,t(959)+t(293)))return _0x282836[t(959)+t(293)]||_0x2bcc12[t(466)](_0x4849fc);if(_0x4b220d===PQFuDG[t(1532)])return _0x52ec5d[t(959)+t(293)][1]?void 0:_0x41e995["objectSt"+t(254)](_0x127cc8[t(959)+t(293)][0])}return PQFuDG[t(565)](_0x14e53a,_0x1371e1[_0x136058])}else return this[t(843)][t(240)]()}async[n(1590)](){let t=n;if(e[t(1423)]!==e[t(551)]){let r=this[t(843)][t(1621)](this[t(640)]),a=JSON[t(1454)](e[t(937)](r,"{}"));return Object[t(1590)](a)}else return _0x2aa86e.resolve()}async[n(815)](){let t=n,r=this[t(843)][t(1621)](this[t(640)]),a=JSON[t(1454)](e.jlBis(r,"{}"));return Object.values(a)}[n(429)](){let t=n,r={MYMvU:function(a,x){return e[R(1489)](a,x)},Fsoik:function(a,x){return e[R(399)](a,x)},etfoo:function(a,x){return e[R(511)](a,x)},CbJCs:function(a,x){return e[R(461)](a,x)},elRcZ:function(a,x){return a>>>x},flrek:function(a,x){return a|x},bpkca:function(a,x){return a|x}};return e[t(1504)](e.pmsJU,"QTViI")?Promise[t(998)]():AELyvk.MYMvU(_0x2a63f6,_0x51f170)?_0x114e77:new _0x4e0170(AELyvk[t(417)](AELyvk[t(313)](_0x3c2a5c.call(_0x547707,0),_0x14bee6[t(1518)](_0x23d6aa,1)<<8)|AELyvk[t(765)](_0x6172b5[t(1518)](_0x9d2fa2,2),16)|AELyvk[t(765)](_0x553187[t(1518)](_0x506f52,3),24),0),AELyvk[t(768)](AELyvk[t(1279)](AELyvk[t(1058)](_0x367dcf.call(_0x398ec5,4),AELyvk[t(765)](_0x496b23[t(1518)](_0x1ed0ca,5),8))|AELyvk[t(765)](_0x401296[t(1518)](_0x1b4b90,6),16),_0x2222b8.call(_0x290743,7)<<24),0),!0)}get isReady(){return!!this[n(843)]}}class i0{constructor(t,r){let a=n;this[a(583)]=t,this[a(1138)]=r,this[a(843)]=ft?tt:Wt?wx:null}async openDB(){}get[n(640)](){return n(1626)+"_"+this._DBName}async[n(466)](t){let r=n,a=this[r(843)][r(1566)+r(1388)](this[r(640)]);return JSON[r(1454)](e[r(1458)](a,"{}"))[t]}async[n(264)](t,r){let a=n,x=this[a(843)]["getStora"+a(1388)](this._prefix),g=JSON[a(1454)](e[a(470)](x,"{}"));return g[r||t[this[a(1138)]]]=t,this[a(843)]["setStora"+a(1388)](this[a(640)],JSON[a(600)+"y"](g)),r||t[this[a(1138)]]}async[n(512)](t){let r=n,a=this[r(843)]["getStora"+r(1388)](this[r(640)]),x=JSON[r(1454)](e[r(937)](a,"{}"));return x[t]=void 0,this[r(843)][r(1007)+"geSync"](this[r(640)],JSON[r(600)+"y"](x))}async clear(){let t=n;return this[t(843)][t(652)+t(489)]()}async[n(1590)](){let t=n,r=this[t(843)][t(1566)+t(315)+"nc"](this[t(640)]),a=JSON[t(1454)](e[t(1458)](r,"{}"));return Object.keys(a)}async getAll(){let t=n,r=this[t(843)][t(1566)+t(315)+"nc"](this[t(640)]),a=JSON[t(1454)](e[t(733)](r,"{}"));return Object.values(a)}[n(429)](){return Promise.resolve()}get[n(1140)](){return!!this[n(843)]}}function fs(i,t){let r=n;if(e.jlBis(ft,ft))return new i0(i,t);if(e[r(733)](St,Jt)&&e[r(576)](r(980)+"d",typeof indexedDB))return new n0(i,t);if(e[r(470)](St,Jt)&&e.PtkWq(e[r(465)],typeof localStorage))return new r0(i,t);throw new Error(e.dvTvH)}class s0{constructor(){let t=n,r={OMQGz:function(a,x,g){return e[R(987)](a,x,g)}};e[t(1270)](e[t(1361)],e[t(1361)])?(_0x86c6e8(_0x18486b,90),OJlZhX[t(1219)](_0x474367,_0x58aec3,_0x9761ac)):(this._intervalTimeoutId=null,this[t(1276)+"l"]=36e5,this[t(843)]=e[t(865)](fs,e.aCwsr,e.ohmdq))}async[n(1276)+n(441)](){let t=n;e.JCEPz(clearInterval,this[t(1276)+t(289)+"Id"]),this["_interva"+t(289)+"Id"]=setInterval(()=>{let r=t;this[r(351)+r(1360)]()},this[t(1276)+"l"])}async[n(1573)](){let t=n;await this._qosDB.openDB()[t(851)](()=>{this["_interva"+t(441)]()})}async[n(351)+n(1360)](){let t=n,r={NseEW:function(a,x){return e[R(467)](a,x)},Irmrc:e[t(379)]};if(e.nTZtH(t(1038),e[t(1405)]))return this[t(1395)+"s"][this["currentI"+t(213)]];(await this[t(843)]?.[t(815)]()||[])[t(597)](({timestamp:g})=>g<Date.now())[t(913)](g=>{let m=t;if(r[m(423)](r[m(540)],r.Irmrc))return _0x149324(_0x4020f6);this[m(843)]?.del(g[m(719)+"id"])})}async[n(512)](t){let r=n;return this[r(843)]?.[r(512)](t)}async set(t,r){return this[n(843)]?.set({message_id:t,timestamp:r})}async[n(466)](t){let r=n;return this._qosDB?.[r(466)](t)}async[n(429)](){let t=n;if(e[t(211)](e[t(575)],e.onzdQ))return _0x4108da[t(234)+"8"]?{value:_0x51ed78[t(234)+"8"](_0x5cb646),offset:_0x35aefe+1}:{value:e[t(989)](255,_0x3cc4e4[_0x3be187]),offset:e.tuCAQ(_0x26ed73,1)};e[t(1442)](clearInterval,this[t(1276)+"lTimeoutId"]),await this[t(843)]?.[t(429)]()}get[n(1140)](){let t=n;return this[t(843)]?.[t(1140)]}}function Fr(i){let t=n,r=!!this[t(1570)].enableQoS;if(!r)return{enabled:r,isQoSMessage:!1,isQoSAck:!1,isAckCleanupMessage:!1,ackMsgIds:[]};let a=e[t(245)](rt,i[t(1422)].headers,t(746)+t(1551),"2"),x=a&&rt(i[t(1422)][t(1260)],e.zbbdf,"1"),g=a&&rt(i[t(1422)][t(1260)],e[t(1439)],"1"),m=g?e[t(1086)](Et,i[t(1422)][t(1260)],t(746)+t(386)+t(359))?.[t(1354)](",")[t(597)](Boolean)||[]:[];return{enabled:r,isQoSMessage:a,isQoSAck:x,isAckCleanupMessage:g,ackMsgIds:m}}async function ls(){let i=n;return this[i(357)+i(725)]||(this[i(357)+i(725)]=new s0),this[i(357)+i(725)].isReady||await this[i(357)+i(725)].openDB(),this[i(357)+i(725)]}async function o0(i,t){let r=n,{enableAutoAck:a}=this._options,x=e[r(245)](rt,i[r(1422)][r(1260)],e[r(1246)],"1"),g=e.mJDOW(rt,i[r(1422)][r(1260)],e[r(560)],"1"),m=Fr.call(this,i);if(a&&x){let{SeqID:y,LogID:_,service:l,LogIDNew:v,method:C}=i[r(1422)];this[r(1163)]({SeqID:y,LogID:_,LogIDNew:v,service:l,method:C,headers:[{key:e[r(560)],value:"1"},{key:r(832),value:v||""},{key:e.cQZJU,value:"0"}]})}g&&!m[r(1217)]&&this[r(1363)+r(693)+r(702)](i),e[r(864)](t)}async function a0(i,t){let r=n;e[r(389)]===e[r(713)]?this._listeners={}:(this[r(1420)](e[r(1473)],i[r(1422)]),e.NTaEi(t))}async function c0(i,t){let r=n,a=_t(await e[r(1595)](us,i[r(680)]));try{if(e[r(1565)](a.payload,Uint8Array)){let x=e.RrZOy(this._options[r(1309)+r(882)],Object)?{force:!!this[r(1570)][r(1309)+"ncoding"][r(422)],encoding:this[r(1570)][r(1309)+r(882)][r(940)]?this[r(1570)][r(1309)+r(882)][r(940)].replace(/\s/g,"")[r(1150)+"ase"]():""}:{force:!1,encoding:this[r(1570)]["payloadE"+r(882)]?this[r(1570)]["payloadE"+r(882)][r(898)](/\s/g,"")[r(1150)+"ase"]():""},g=a[r(1309)+r(882)]?a.payloadEncoding[r(898)](/\s/g,"")[r(1150)+r(897)]():"",m=e[r(1565)](this[r(1570)][r(332)+"ype"],Object)?{force:!!this[r(1570)][r(332)+r(1542)][r(422)],type:this._options[r(332)+r(1542)][r(1061)]?this[r(1570)].payloadType[r(1061)][r(898)](/\s/g,"")[r(1150)+r(897)]():""}:{force:!1,type:this[r(1570)][r(332)+r(1542)]?this._options[r(332)+"ype"].replace(/\s/g,"")[r(1150)+r(897)]():""},y=a[r(332)+r(1542)]?a[r(332)+r(1542)][r(898)](/\s/g,"")[r(1150)+r(897)]():"",_=m.force?m[r(1061)]:y||m[r(1061)],l=x.force?x[r(940)]:g||x[r(940)],v=[e[r(1202)],r(1451)+r(1101),e.QvZWR,e.vhniu],C=[e[r(1431)],e[r(1571)]];this._options["enableTr"+r(1177)+r(1545)+"ad"]&&v.includes(_)&&(!l||C[r(979)](l))?a[r(714)+r(199)]=e[r(624)](xs,a[r(1627)],0,a[r(1627)][r(683)+"th"]):a[r(714)+r(199)]=""}else a[r(714)+r(199)]=""}catch(x){a[r(714)+r(199)]="",console[r(405)](x)}i[r(1422)]=a,e[r(887)](t)}function d0(i,t,r){let a=n,x={Jsonr:function(l,v){return e[R(635)](l,v)},FgtmI:function(l,v){return l>v},fjDYB:function(l,v){return e[R(505)](l,v)},qyEAX:function(l,v){return e.kgipt(l,v)},KjWXp:function(l,v){return e.Jtnxt(l,v)},rLTQm:function(l,v){return e[R(1121)](l,v)}},g=e.CYQIz(r,8192),m=e[a(852)](g,1),y=null,_=g;return function(l){let v=a;if(l<1||x[v(1528)](l,m))return i(l);x[v(362)](x[v(481)](_,l),g)&&(y=x[v(1404)](i,g),_=0);let C=t[v(1518)](y,_,_+=l);return x[v(1432)](7,_)&&(_=x[v(481)](x[v(1579)](7,_),1)),C}}let x0=4294967295;function u0(i,t,r){let a=n;return e[a(1074)](RangeError,e.URzKH(e[a(572)](e[a(856)](e[a(218)](e[a(1195)],i),a(1333)),t||1)+a(1348),r))}function f0(i,t,r){let a=n,x={IGVCr:e[a(491)]};if(e[a(633)](e[a(1154)],e[a(1154)])){if(e.KAzNl(r,x0))throw new Error(e[a(770)]);let g=3;for(;e.SpYEE(g,0);){let m=e[a(1142)](255,r);e[a(434)](qr,m,i,e[a(505)](t,g)),r>>>=8,g--}return e[a(292)](t,4)}else{if(!this[a(1514)+a(210)]()||this[a(935)+"osed"])return;this[a(957)+a(1640)]?.["resetEnd"+a(804)+a(1516)](),this[a(1415)+a(1378)]?.["resetCou"+a(795)](),this[a(1011)]?this[a(1118)+a(1027)](1001,x.IGVCr,!0):this[a(300)]()}}function l0(i,t){let r=n,a=0,x=t,g=e[r(1487)](t,4);for(;e[r(625)](x,g);)if(e.RRFcJ!==e[r(844)])e[r(245)](_0xb49ef0,this,_0x5dbd56,[_0x1164e5,_0x5d31b5,_0x5b8b3d]);else{let{value:m,offset:y}=e.Uwgkw(Ur,i,x);x=y,a=e.mEAAZ(a,8)>>>0,a+=m}return{value:a,offset:g}}function g0(i,t,r){let a=n,x=e[a(267)][a(1354)]("|"),g=0;for(;;){switch(x[g++]){case"0":if(i.length<40)return e[a(1006)](Br(i,t,r),r);continue;case"1":if(t[a(598)])return t[a(598)](i,r)+r;continue;case"2":return e[a(1212)](e.NKwYr(Br,i,t,r),r);case"3":if(!i)return r;continue;case"4":if(t[a(848)+"e"])return t[a(848)+"e"](i,r)+r;continue}break}}function h0(i,t){let r=n,a=new K(e[r(1538)](i[e[r(752)](t,4)]<<24,e[r(261)](i[e[r(292)](t,5)],16))|i[e[r(1308)](t,6)]<<8|i[t+7],e[r(1353)](e.fnXRm(e[r(1017)](i[e.PgJuQ(t,0)],24),e[r(1017)](i[t+1],16))|e[r(782)](i[e.FvPld(t,2)],8),i[t+3]),!0);return t+=8,{value:a,offset:e[r(536)](t,8)}}function p0(i,t,r){let a=n;if(e[a(295)](a(594),e.kzjah)){let x=i.low,g=i[a(532)];return t[r]=e[a(1030)](g,24),t[e.EMylN(r,1)]=e[a(574)](g,16)&255,t[e[a(1008)](r,2)]=e.yqLvw(e.wPgAM(g,8),255),t[r+3]=e[a(810)](255,g),t[e[a(1006)](r,4)]=e[a(1171)](x,24),t[r+5]=e[a(1539)](x>>>16,255),t[r+6]=e[a(1541)](x,8)&255,t[e[a(856)](r,7)]=e[a(1555)](255,x),r+=8,r}else this.emit(e[a(268)],e[a(1450)](_0x417fe8,e.LLSYA,{message:this["_formatE"+a(914)+a(1599)](_0xfde039)}))}function Ur(i,t){let r=n;return e.uuFJw(e[r(208)],e[r(208)])?(this[r(1003)+r(1310)+r(1262)+"t"]++,this[r(252)+r(1586)+"nt"]()):i[r(234)+"8"]?{value:i[r(234)+"8"](t),offset:t+1}:{value:e.EWOFq(255,i[t]),offset:t+1}}function qr(i,t,r){let a=n;return t[a(1001)+"t8"]?t[a(1001)+"t8"](i,r):t[r]=e[a(1512)](255,i),e.VFQyh(r,1)}let m0=function(i){let t=n,r={PAuUd:function(a,x,g,m){return e.Gneut(a,x,g,m)}};if(e[t(1504)](e[t(803)],t(1190)))return new Uint8Array(i);{let a=new _0x1a5215(_0x2e2c2a(_0x3dd3ac));return XMnboJ[t(1134)](_0x33eaa6,_0x42207d,a,0),a}},w0=e.TjZev(n(980)+"d",typeof Buffer)?Buffer[n(643)+n(874)]:e[n(1389)](d0,m0,Uint8Array[n(1444)+"e"][n(427)]),_0=16,Gr=32;function y0(i){let t=n,r=0,a={};for(let x=0;e.PjbUz(x,i[t(1606)]);x++)a[i[x]["cursor_n"+t(1614)]]=e[t(724)](ds,i[x]["cursor_n"+t(1614)]),r+=14+a[i[x][t(483)+t(1614)]];return[r,a]}function gs(i,t,r){let a=n,x={FBjSo:a(932)+a(194),FeARk:function(l,v,C,D){return e.NKwYr(l,v,C,D)},wrHxy:e[a(988)],xWxnw:function(l,v,C,D){return e[a(624)](l,v,C,D)},wNHQD:e[a(965)],VQeYn:function(l,v,C,D){return l(v,C,D)},JWFFR:e[a(420)],jQSfc:e.idOGt,LEIjB:e[a(1014)]},[g,m]=y0(i),y=e[a(307)](w0,g),_=0;return i[a(913)](l=>{let v=a;console[v(405)](x[v(1370)],l,l[v(452)]),_=x[v(1618)](qr,0,y,_),console[v(405)](x[v(1494)],_),_=x[v(1115)](f0,y,_,l[v(452)]||0),console.log(x[v(571)],_),_=x.VQeYn(qr,m[l.cursor_name],y,_),console[v(405)](x[v(258)],_),_=x[v(1618)](g0,l[v(483)+v(1614)],y,_),console[v(405)](x[v(942)],_),_=x[v(628)](p0,K[v(1356)+"er"](l[v(1285)]||t),y,_),console[v(405)](x[v(1381)],_)}),{frameType:Gr,headers:[{key:e[a(217)],value:r}],payload:y}}function b0(i){let t=n;if(e[t(241)](e[t(352)],e[t(824)]))_0x2481d9[t(1626)+t(1123)]=void 0,_0x2c87cd(e[t(1031)]);else{let r=0,a=[];for(;r<i.byteLength;){let{offset:x}=Ur(i,r);r=x;let g={cursor_name:"",cursor:0,service:0},{value:m,offset:y}=l0(i,r);g[t(452)]=m,r=y;let{value:_,offset:l}=e[t(867)](Ur,i,r);r=l,g[t(483)+t(1614)]=xs(i,r,e[t(1619)](r,_)),r+=_;let{value:v,offset:C}=h0(i,r);g[t(1285)]=v[t(1416)](),r=C,a[t(1034)](g)}return a}}function v0(){let i=n;return{frameType:Gr,headers:[{key:e[i(217)],value:e[i(1256)]}],payload:void 0}}class S0{constructor(t,r,a){let x=n;this._cursorNameSpace=t,this[x(679)+x(1172)]=r,this["_message"+x(1234)]=a,this._qosDB=e[x(367)](fs,this[x(1137)+x(407)],x(483)+x(1614))}async[n(1573)](){await this[n(843)].openDB()}async[n(412)+"rs"](){let t=n;if(!this[t(843)][t(1140)])return;let r=this[t(1056)+t(1234)],a=await this._qosDB[t(815)]();switch(console[t(405)](e[t(924)],a),r){case e[t(1088)]:return a&&a[t(1606)]?gs(a,0,this[t(679)+t(1172)]):void 0;case e[t(228)]:return;case e[t(1274)]:return a&&a[t(1606)]?e[t(1366)](gs,a,0,this[t(679)+"ileName"]):e[t(1250)](v0)}}async[n(264)](t,r,a){let x=n;if(e[x(380)](e.OqjDe,x(1133)))return console[x(405)](e[x(954)],t,r,a),this[x(843)][x(264)]({cursor_name:t,cursor:r,service:a});this[x(552)]=!0,this[x(300)]()}async[n(274)+"rs"](t){let r=n,a=e[r(1595)](b0,t);for(let x of a)console[r(405)](r(1113)+"r",a),await this._qosDB[r(264)](x)}async[n(466)](t){let r=n;return(await this[r(843)][r(466)](t))?.[r(1285)]}async[n(429)](){let t=n;await this[t(843)][t(429)]()}[n(931)+n(777)+n(554)](t){let r=n;this[r(679)+r(1172)]=t}get[n(1140)](){let t=n;return this[t(843)][t(1140)]}}let E0=n(381)+n(799);async function hs(i){let t=n,r={xCVEa:function(a,x){return a(x)},UKTyK:function(a,x){return a+x},HakVy:e.QKCet,UDaAI:t(456)};if(e[t(430)](e[t(941)],"SQMJd")){if(!this[t(1570)].enableQoS)return null;let{aID:a,fpID:x,messageStrategy:g}=this._options,m=i||E0;try{if(this[t(1043)+t(1403)])if(e[t(492)]===e[t(906)]){let y=_0x38a7bc[t(1354)](/\./)[t(753)](v=>_0x289202(v)),_=[];return _[0]=dSXVUL[t(488)](_0x31c076,dSXVUL[t(1609)](y[0],y[1])),_[1]=dSXVUL[t(488)](_0x33b323,dSXVUL[t(1609)](y[2],y[3])),[dSXVUL[t(758)],"0000",t(1164),dSXVUL.HakVy,t(1164),dSXVUL[t(1059)],_[0],_[1]][t(828)]("")}else i&&this["_cursorM"+t(1403)][t(931)+"rsorFile"+t(554)](i);else this["_cursorM"+t(1403)]=new S0(x+"_"+a+"_"+m,m,g);return this["_cursorM"+t(1403)][t(1140)]||await this[t(1043)+t(1403)][t(1573)](),this["_cursorM"+t(1403)]}catch{return null}}else try{this._qosDB?.[t(296)](),this._qosDB=void 0}catch(a){_0x4a1c41[t(405)](a)}}async function I0(i,t){let r=n,a=e[r(245)](rt,i.message[r(1260)],r(692),"-1"),x=e.RNaUu(rt,i[r(1422)][r(1260)],e[r(560)],"1"),g=Et(i[r(1422)][r(1260)],"x_fronti"+r(541)),m=e[r(1221)](Number,e[r(1080)](Et,i.message[r(1260)],r(746)+r(1391)))||0,y=Fr.call(this,i),_=e.Gneut(rt,i[r(1422)][r(1260)],"x-msg-qos","2"),l=e[r(707)](Et,i[r(1422)].headers,e[r(360)]),v=e[r(984)](Number,e[r(517)](Et,i[r(1422)].headers,e.QDvEN));if(y.isQoSAck)return t();let C=y[r(610)+r(1251)]?await ls[r(1518)](this):null;if(i.message[r(452)]>0&&x&&!a||i[r(1422)].service>0){if(g&&y[r(610)+r(1251)]&&C){if(!!!await C[r(466)](g)){if(e.yjwIp("yKIcX",r(791)))return!!this[r(843)];this[r(1363)+"hMessage"+r(1386)](i),await C[r(264)](g,e[r(516)](Date.now(),m))}return e[r(677)](t)}if(_){let D=await hs[r(1518)](this);if(!D)return this[r(1363)+"hMessage"+r(1386)](i),e.DpWwo(t);let F=await D[r(466)](l)??-1;if(e[r(1204)](F,v))this["_dispatc"+r(642)+r(1386)](i),D[r(264)](l,v,i.message[r(452)]);else throw new Error(r(521)+" message cursor "+v+(r(1327)+r(930)+r(1437)+"r ")+F);return e.Vsufu(t)}return this._dispatchMessageEvent(i),t()}}async function A0(i,t){let r=n,a=Fr[r(1518)](this,i);if(!a[r(610)+"sage"])return e[r(1250)](t);let x=await ls[r(1518)](this);if(a[r(1318)+r(1500)+"age"]&&a.ackMsgIds.length)for(let g of a[r(347)+"s"])await x[r(512)](g);e[r(696)](t)}async function T0(i,t){let r=n,a=e[r(617)](i[r(1422)][r(1642)+"e"],_0),x=i[r(1422)][r(1642)+"e"]===Gr;if(!a&&!x)return e[r(1524)](t);let g=e[r(616)](Et,i.message[r(1260)],r(1620)+r(523));if(!g)return e[r(1211)](t);let m=await hs.call(this,g);if(!m)return e.TuzKJ(t);if(a){let y=await m[r(412)+"rs"](),_={frameType:y?.["frameType"],SeqID:K[r(1356)+"er"](this._seqId++),LogID:K[r(1356)+"er"](this[r(1570)][r(1496)+r(1189)]()),service:9e3,method:5,headers:y?.headers,payload:y?.[r(1627)]},l=e.GVtyv(E,_);this[r(1011)]&&this[r(1011)][r(230)+"te"]&&this[r(1011)].send(l)}if(x)if(e[r(1009)](e[r(534)],e.laKvD)){let y=i[r(1422)][r(1627)];y&&m.setCursors(y)}else{let y=this[r(1570)][r(1309)+"ncoding"]instanceof _0x32ae75?{force:!!this._options[r(1309)+r(882)].force,encoding:this[r(1570)][r(1309)+r(882)][r(940)]?this[r(1570)]["payloadE"+r(882)][r(940)][r(898)](/\s/g,"")[r(1150)+r(897)]():""}:{force:!1,encoding:this[r(1570)].payloadEncoding?this[r(1570)][r(1309)+"ncoding"].replace(/\s/g,"")[r(1150)+"ase"]():""},_=_0x7326d9[r(1309)+r(882)]?_0x3e18ba[r(1309)+r(882)].replace(/\s/g,"")[r(1150)+"ase"]():"",l=e.vUpZf(this[r(1570)][r(332)+r(1542)],_0x21c926)?{force:!!this._options[r(332)+r(1542)][r(422)],type:this[r(1570)][r(332)+r(1542)][r(1061)]?this[r(1570)][r(332)+r(1542)][r(1061)][r(898)](/\s/g,"")[r(1150)+r(897)]():""}:{force:!1,type:this[r(1570)][r(332)+r(1542)]?this[r(1570)][r(332)+r(1542)][r(898)](/\s/g,"")[r(1150)+r(897)]():""},v=_0x328d33[r(332)+r(1542)]?_0x4b240a[r(332)+r(1542)][r(898)](/\s/g,"")[r(1150)+r(897)]():"",C=l.force?l.type:v||l.type,D=y.force?y[r(940)]:_||y.encoding,F=["text/pla"+r(1513)+"et=utf-8",r(1451)+r(1101),e[r(237)],e.vhniu],U=[e[r(1431)],e[r(1571)]];this[r(1570)]["enableTr"+r(1177)+r(1545)+"ad"]&&F[r(979)](C)&&(!D||U[r(979)](D))?_0x5a824a.textPayload=_0x7a65ff(_0x4a0336[r(1627)],0,_0x4fecdc.payload.byteLength):_0x1742e0["textPayl"+r(199)]=""}}let P0=async function(i,t){let r=n;this[r(552)]=!1,e.UduLe(clearTimeout,this[r(300)+r(503)+r(487)]),e[r(1283)](t)},C0=async function(i,t){let r=n,a={FirwT:e[r(1394)]};if(!this[r(1011)]||this[r(1011)][r(230)+"te"]!==this[r(1605)])return e[r(612)](t);let{pingInterval:x}=this[r(1570)];this[r(957)+r(1640)]?.[r(1018)+r(804)+r(1516)]();for(let m=0;e[r(863)](m,this[r(1056)+r(990)][r(1606)]);m++)if(e.hWxCQ("vuaJD","Tpfld")){let y=this[r(1056)+r(990)][m];if(e[r(495)](this[r(1011)][r(230)+"te"],this.OPEN)&&y!==null)this._ws&&this[r(1011)][r(1470)](y),this[r(1056)+r(990)][m]=null;else break}else{let y=/(25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?)(\.(25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?)){3}/[r(705)](_0xbe8078),_=/(([0-9a-fA-F]{1,4}:){7,7}[0-9a-fA-F]{1,4}|([0-9a-fA-F]{1,4}:){1,7}:|([0-9a-fA-F]{1,4}:){1,6}:[0-9a-fA-F]{1,4}|([0-9a-fA-F]{1,4}:){1,5}(:[0-9a-fA-F]{1,4}){1,2}|([0-9a-fA-F]{1,4}:){1,4}(:[0-9a-fA-F]{1,4}){1,3}|([0-9a-fA-F]{1,4}:){1,3}(:[0-9a-fA-F]{1,4}){1,4}|([0-9a-fA-F]{1,4}:){1,2}(:[0-9a-fA-F]{1,4}){1,5}|[0-9a-fA-F]{1,4}:((:[0-9a-fA-F]{1,4}){1,6})|:((:[0-9a-fA-F]{1,4}){1,7}|:)|fe80:(:[0-9a-fA-F]{0,4}){0,4}%[0-9a-zA-Z]{1,}|::(ffff(:0{1,4}){0,1}:){0,1}((25[0-5]|(2[0-4]|1{0,1}[0-9]){0,1}[0-9])\.){3,3}(25[0-5]|(2[0-4]|1{0,1}[0-9]){0,1}[0-9])|([0-9a-fA-F]{1,4}:){1,4}:((25[0-5]|(2[0-4]|1{0,1}[0-9]){0,1}[0-9])\.){3,3}(25[0-5]|(2[0-4]|1{0,1}[0-9]){0,1}[0-9]))/.test(_0x54d01f);return y?_0x3a8733(_0x389ab2):_?_0x3f4770(_0x3ce4bb):SGQfSw[r(1409)]}this["_message"+r(990)]=this[r(1056)+"Queue"][r(597)](m=>!!m),this[r(1537)+r(1129)+"Id"]=e[r(706)](setTimeout,()=>this[r(1373)](),x),this[r(1363)+r(1098)+"nt"](i),this[r(235)+"er"]&&this[r(1011)]&&(this._ws[r(715)+"pe"]=this[r(903)+r(1542)]);let g=this[r(957)+r(1640)]?.["getCurre"+r(1586)+"nt"]();this[r(1420)](r(672)+g+r(1317)),e[r(1508)](t)},k0=async function(i,t){let r=n,a={SlejF:function(x,g){return e.gOIbj(x,g)},epMRX:function(x,g){return e.XWjnD(x,g)}};if(e[r(189)]===e[r(697)]){let{initReconnectInterval:x,maxReconnectInterval:g,reconnectIntervalGrowFactor:m}=this[r(1570)],y=x*_0x588caf[r(698)](m,a[r(369)](_0x2b3db7,1));return a[r(952)](y,g)?g:y}else{let x=this[r(957)+"tManager"]?.[r(252)+r(1586)+"nt"]();this[r(1420)]("open "+x),e.zZJNS(t)}};class D0 extends Mr{constructor(t){let r=n,a={OBUTg:function(_,l,v,C){return e[R(624)](_,l,v,C)},WYcth:function(_,l,v){return e.HqLdF(_,l,v)},AjclS:r(1181),BRBCn:function(_,l){return e[r(1228)](_,l)},GKsCg:r(1344),ILGrn:function(_,l){return e.vOYQm(_,l)},xmZIH:function(_,l){return e[r(977)](_,l)},khVWH:function(_,l){return e[r(589)](_,l)},HCYPe:function(_,l,v){return e.TrRgv(_,l,v)},KXrNL:function(_){return _()},rEbTa:function(_,l,v,C){return _(l,v,C)}};super(),this[r(533)+r(1028)+"line"]=!0,this[r(235)+"er"]=St,this[r(1064)]=Jc,this[r(538)+"T"]=ft,this[r(1112)+"X"]=Wt,this[r(297)+"r"]=Jt,this._messageQueue=[],this[r(957)+r(1640)]=null,this[r(935)+r(869)]=!1,this["_binaryT"+r(1542)]=e[r(428)],this[r(300)+r(1087)]=!1,this[r(300)+r(503)+r(487)]=null,this[r(410)+r(743)+r(819)]=null,this[r(1537)+r(1129)+"Id"]=null,this[r(349)]=0,this._isInit=!1,this[r(1180)]="",this["_QoSMana"+r(725)]=null,this[r(1043)+r(1403)]=null,this[r(1415)+r(1378)]=null,this[r(438)+"ls"]=r(1277),this[r(781)]=3,this.CONNECTING=0,this[r(1605)]=1,this[r(1474)]=2,this[r(1453)]=_=>{let l=r;try{a.OBUTg(cs,this,_,[P0,C0,k0])}catch(v){let C=a[l(739)](Ae,a[l(294)],{message:v[l(1422)],code:nt[l(1382)+"OR"],error:v});this[l(1363)+l(1574)+l(981)](C)}},this[r(1039)+"ge"]=async _=>{let l=r,{pingInterval:v,pingFrequency:C}=this[l(1570)];if((e[l(919)]("hi",_[l(680)])&&e[l(324)]===C||e[l(629)](e[l(606)],C))&&(this[l(1023)+"ngTimer"](),this[l(999)](e[l(553)],e[l(1475)]),this[l(1537)+l(1129)+"Id"]=e[l(1278)](setTimeout,this[l(1373)].bind(this),v)),!e[l(528)]("hi",_[l(680)]))try{e[l(1343)](cs,this,_,[c0,o0,A0,T0,I0,a0])}catch(D){let F=e[l(513)](Ae,e.LLSYA,{message:D[l(1422)],code:nt[l(854)+l(734)],error:D});this[l(1363)+l(1574)+l(981)](F)}},this._onError=_=>{let l=r,v=this["_endpoin"+l(1640)]?.[l(1320)+l(830)+"es"](),C=this[l(957)+l(1640)]?.[l(252)+l(1586)+"nt"]();if(v&&!_[l(1422)]){let D=l(972)+C+(l(1238)+l(878)+l(1433)+"ed");this[l(1363)+"hErrorEv"+l(981)](e[l(545)](Ae,e[l(268)],{message:D,code:nt["MAX_RETR"+l(676)+"R"],error:_}));return}this[l(1011)]&&this[l(1011)][l(230)+"te"]===this[l(1605)]&&this[l(1118)+l(1027)](),this[l(1363)+l(1574)+l(981)](e.stjhA(Ae,e.LLSYA,{message:_[l(1422)],code:nt[l(455)+"RROR"],error:_}))},this[r(960)]=async _=>{let l=r;this[l(1635)+l(270)](),this[l(1023)+l(1157)](),this[l(440)+l(691)+"rs"](),this[l(1011)]=null,this._connectLock=!1;let v=this[l(957)+"tManager"]?.checkReachMaxTries();if(!v&&this[l(1514)+l(210)]()&&!this[l(935)+l(869)]){let C=this[l(957)+l(1640)]?.[l(252)+l(1586)+"nt"](),D=this._options["reconnec"+l(603)+l(895)](_.code,_[l(1483)]);this["_dispatc"+l(1530)+l(981)](De(l(296),{code:1006,reason:_.reason||l(299)+l(449)+"d, unkno"+l(463)+l(1497)+l(1517)+C,willReconnect:D})),D&&this[l(300)]();return}if(e[l(805)](1e3,_[l(692)])&&this["_readyCl"+l(869)]){this[l(1363)+l(1530)+"ent"](e.TucFT(De,e[l(829)],{code:1e3,reason:e.BFisd})),this[l(957)+l(1640)]?.[l(1018)+l(804)+l(1516)](),this[l(1415)+l(1378)]?.[l(1291)+l(795)]();return}if(e.FPwNp(1e3,_[l(692)])&&v){let C=this[l(957)+l(1640)]?.["getCurre"+l(1586)+"nt"](),D=_[l(1483)];D||(D=await e.WiRTK(e0,this._url)),D=l(299)+"ng faile"+l(500)+D+(l(219)+"me: ")+C+(l(907)+l(1503)+l(1159)),this["_dispatc"+l(1530)+"ent"](De(e[l(829)],{code:_[l(692)],reason:D}));let F=l(972)+C+(l(1238)+l(878)+l(1433)+"ed");this["_dispatc"+l(1574)+l(981)](Ae(e[l(268)],{message:F,code:nt["MAX_RETR"+l(676)+"R"]})),this._endpointManager?.[l(1018)+l(804)+"fig"](),this[l(1415)+l(1378)]?.[l(1291)+l(795)]();return}if(_[l(692)]!==1e3&&!_.reason){if(e.oHAqh!==e[l(1232)])return OdBwYH[l(657)](typeof _0x2dadd6,OdBwYH[l(1480)])?OdBwYH[l(967)](_0x206fad,_0x114919):(OdBwYH[l(1272)](_0x3ae48f,_0x50c7a6)&&OdBwYH.khVWH(_0x1147fb,_0x1ee078),OdBwYH[l(327)](_0x31e2b0,_0x1319f6,OdBwYH[l(401)](_0x49aff5))?new _0x1f25c6(_0x128df6,_0x27fafa):_0x3bf1b5);{let C=this[l(957)+l(1640)]?.[l(252)+l(1586)+"nt"]();this[l(1363)+l(1530)+"ent"](e[l(436)](De,e[l(829)],{code:_.code,reason:l(299)+l(449)+l(613)+l(463)+l(1497)+l(1517)+C})),this[l(957)+l(1640)]?.[l(1018)+l(804)+"fig"](),this[l(1415)+l(1378)]?.[l(1291)+l(795)]();return}}this._dispatchCloseEvent(_),this[l(957)+l(1640)]?.[l(1018)+"pointConfig"](),this[l(1415)+"sCounter"]?.[l(1291)+"nter"]()},this[r(1553)]=null,this.onerror=null,this[r(736)+"e"]=null,this[r(802)]=null,this[r(1425)+r(569)]=null,this[r(1337)+"eAck"]=null,this[r(1462)+r(787)+r(723)+"ct"]=null,this["_handleO"+r(754)]=this["_handleO"+r(754)][r(411)](this),this[r(596)+r(1193)]=this[r(596)+r(1193)][r(411)](this),this["_handleP"+r(570)]=this._handlePageHide[r(411)](this),this[r(1015)+r(1631)]=this[r(1015)+"ageShow"][r(411)](this),this._options={url:"",automaticOpen:!0,initReconnectInterval:1e3,maxReconnectInterval:1e4,reconnectIntervalGrowFactor:2,timeoutInterval:5e3,maxRetries:5,debug:!1,maxMessageQueueLength:e.YfvAT(1,0),service:0,logIDGenerator:c,headers:void 0,payloadEncoding:"",payloadType:"",fpID:"",deviceID:"",accessKey:"",ttwID:"",bddID:"",aID:"",disableAutoReconnect:!1,customParams:{},pingInterval:15e3,pingTimeoutInterval:4e3,pingFrequency:e.pHdnt,pingLossCount:2,enableTransformTextPayload:!1,logIDNewConfig:{enableAutoGenerateLogIDNew:!1,userIp:""},miniProgramParams:{customHttpHeader:{}},enableAutoAck:!1,reconnectInterceptor:()=>!0,enableQoS:!1,QoSLevel:2,messageStrategy:e[r(1274)],env:{xTTEnv:"",xUseEnv:""},listenNetworkChanged:!0};let{url:x,ws:g}=t,m=Array[r(618)](x)?x:e[r(323)](e[r(626)],typeof x)?[x]:[];if(!m||m[r(1606)]===0)throw new Error(e[r(893)]);if(!Yc(g))throw new Error(e[r(497)]);if(Object[r(1096)](this[r(1570)],t),this[r(957)+r(1640)]=new as(m,this[r(1570)][r(480)+"es"]),this[r(1415)+r(1378)]=new Zc(this._options[r(825)+r(982)]),this[r(1570)][r(1089)+r(443)])if(e[r(1094)](e[r(322)],e[r(322)]))this[r(552)]=!0,this[r(300)]();else for(var y in _0x4ed723)OdBwYH[r(215)](_0x22d4fd,_0x24770c,y,{get:_0x436d3b[y],enumerable:!0});this._options[r(1624)+r(1601)+"nged"]&&(this[r(538)+"T"]||this[r(1112)+"X"]?this[r(1081)+r(1207)+"ange"]():this[r(235)+"er"]&&this["_initGlo"+r(1243)+r(196)]())}[n(596)+n(754)](){let t=n;this[t(1570)][t(847)+t(771)+t(343)]||this[t(935)+"osed"]||this[t(464)+"econnect"]()}[n(596)+"ffLine"](){let t=n;if(e[t(1198)](e[t(1188)],"IJsXD")){let r=t(972)+_0x50f1d7+(t(1238)+t(878)+"es reached");this["_dispatc"+t(1574)+"ent"](e.eSebJ(_0x17e302,e.LLSYA,{message:r,code:_0x452e33[t(891)+t(676)+"R"],error:_0x228c06}));return}else{this[t(311)+t(1477)+"t"]();let r=e.Mrhqx(Lr,t(793)+"t",{message:e[t(1069)]});this["onStopIm"+t(787)+t(723)+"ct"]&&this[t(1462)+"mediatel"+t(723)+"ct"](r)}}[n(1471)+n(1243)+n(196)](){let t=n;this[t(235)+"er"]&&window[t(621)+t(196)](t(281),this[t(596)+t(754)]),this[t(235)+"er"]&&window[t(621)+t(196)](e[t(221)],this[t(596)+t(1193)]),this[t(235)+"er"]&&window[t(621)+t(196)](e[t(722)],this[t(1015)+t(570)]),this[t(235)+"er"]&&window[t(621)+t(196)](e[t(1588)],this[t(1015)+"ageShow"])}["_dropGlo"+n(1243)+n(196)](){let t=n;if(e.AqTKl===e[t(1049)])return _0x4eb71c instanceof _0x24f49b&&(pVJgTo[t(1228)](_0x1b81de,pVJgTo.qdLeG)||_0x1c6159===pVJgTo[t(761)])?!0:pVJgTo[t(870)](_0x571e7b,_0x25ff7d);this._isBrowser&&window[t(1441)+t(623)+t(630)](e[t(550)],this[t(596)+t(754)]),this._isBrowser&&window["removeEv"+t(623)+t(630)](e[t(221)],this[t(596)+t(1193)]),this[t(235)+"er"]&&window["removeEv"+t(623)+t(630)](e[t(722)],this[t(1015)+t(570)]),this[t(235)+"er"]&&window["removeEv"+t(623)+t(630)](e[t(1588)],this[t(1015)+t(1631)])}[n(1015)+"ageHide"](t){let r=n;!t.persisted&&(this[r(235)+"er"]&&window[r(1441)+r(623)+r(630)](e[r(722)],this[r(1015)+"ageHide"]),this[r(235)+"er"]&&window[r(1441)+r(623)+r(630)](e[r(1588)],this["_handleP"+r(1631)]),this[r(296)]()),this[r(235)+"er"]&&window[r(1441)+"entListe"+r(630)](e[r(550)],this["_handleO"+r(754)]),this._isBrowser&&window[r(1441)+r(623)+r(630)](e[r(221)],this[r(596)+r(1193)])}[n(1015)+"ageShow"](t){let r=n;t.persisted&&(this[r(1514)+"orOnline"]()&&(!this[r(1011)]||this[r(1011)][r(230)+"te"]!==this.OPEN||e[r(450)](this[r(1011)].readyState,this.CONNECTING))&&this[r(596)+r(754)](),this[r(235)+"er"]&&window[r(621)+r(196)](r(281),this._handleOnLine),this._isBrowser&&window["addEvent"+r(196)](e[r(221)],this[r(596)+r(1193)]))}async[n(400)+n(1119)](t){let r=n,a={mrOQN:function(x,g){return x||g}};if(e[r(1198)](e[r(1584)],e[r(1584)])){let x=this._qosDB[r(1621)](this[r(640)]),g=_0x1969a7[r(1454)](UdrloM[r(259)](x,"{}"));return _0x8fbab2[r(1590)](g)}else{let{fpID:x,deviceID:g,bddID:m,ttwID:y,accessKey:_,aID:l,customParams:v={},enableAutoAck:C,enableQoS:D,QoSLevel:F,env:U}=this[r(1570)],Z,ae,$t;this[r(235)+"er"]||this[r(1112)+"X"]||this[r(538)+"T"]?(Z=location&&e[r(608)](e[r(945)],location[r(820)])?e[r(749)]:e[r(862)],ae=t[r(898)](/((^ws)|(^http))((?:[s]*:\/\/))/,""),$t=/^wss(.*:\/\/)/[r(705)](t)?t:""+Z+ae):(Z=e[r(749)],ae=t.replace(/(^http)((?:[s]*:\/\/))/,""),$t=/(^ws)((?:[s]*:\/\/))/.test(ae)?ae:""+Z+ae);let yn=m?e[r(1054)]:y?e[r(1072)]:e[r(520)],ps=m||y||g;if(e[r(1248)](!ps,!yn))throw new Error(e[r(934)]);let R0=e[r(608)](e[r(1547)],typeof v)?await v():v,N0=U?e[r(865)](Qc,U.xUseEnv,U[r(1146)]):{},Hr=Object[r(1096)]({device_platform:r(1350),version_code:e[r(886)],access_key:_,fpid:x,aid:l,[yn]:ps,xsack:C?1:0,xaack:C?1:0,xsqos:D?1:0,qos_level:D?F:void 0,qos_sdk_version:2,...N0},R0),O0=Object[r(1590)](Hr)[r(1506)]((jr,Kr)=>Hr[Kr]!==void 0?""+jr+(jr?"&":"?")+Kr+"="+Hr[Kr]:jr,"");return $t+r(741)+O0}}async[n(300)](){let t=n,r={JlUXV:function(a,x,g){return e[R(545)](a,x,g)}};if(!(this["_connect"+t(1087)]||this[t(935)+"osed"])){this[t(300)+t(1087)]=!0;try{if(e.uSkpq(e[t(1641)],"FdCVO")){let a=this[t(957)+"tManager"]?.[t(519)+t(587)+t(711)+t(1464)+t(823)](),{timeoutInterval:x}=this._options;if(a){let m=this[t(957)+t(1640)]?.[t(252)+"ntEndpoint"](),y=this["_endpoin"+t(1640)]?.[t(958)+t(1045)+t(885)+t(1359)+t(1293)](),_=this[t(957)+t(1640)]?.[t(252)+t(1586)+"ntTriesCount"]();if(y){let l=t(972)+m+(t(1165)+", max re"+t(1503)+t(922)+t(330)+t(1257)+t(415))+y+" to retry",v=e[t(421)](Ae,e[t(268)],{message:l,code:nt[t(891)+t(676)+"R"]});this[t(1420)](l),this[t(1363)+"hErrorEvent"](v),this[t(1180)]=await this[t(400)+t(1119)](y),this[t(1420)](t(972)+y+" "+_+t(514)),this[t(440)+"sListeners"]()}else{let l=t(972)+m+(t(1165)+", max retries re"+t(1159));this[t(1420)](l),this[t(1363)+t(1574)+"ent"](e.BTULv(Ae,t(1181),{message:l,code:nt.MAX_RETRIES_ERROR}));return}}else if(e[t(1282)](e[t(1237)],t(1004)))ibVPoB[t(366)](_0x5237e7,_0x212025,18),_0x1874df(_0xaaa072,_0x4b1bc4);else{let m=this[t(957)+"tManager"]?.[t(252)+t(1586)+t(1369)+t(632)](),y=this[t(957)+t(1640)]?.["getCurre"+t(1586)+t(1372)+t(729)]();this[t(1180)]=await this[t(400)+"eUrl"](e[t(1596)](m,"")),this[t(1420)](t(972)+m+" "+y+" times"),this[t(440)+"sListeners"]()}if(this[t(552)])this[t(552)]=!1;else{let m=e[t(684)](Lr,e.NWQdr,{message:e[t(974)]});this[t(1425)+t(569)]&&this[t(1425)+t(569)](m)}let g=this[t(957)+"tManager"]?.[t(252)+"ntEndpointTriesC"+t(729)]()||0;g>1&&await this[t(1267)](e.gOIbj(g,1)),this[t(1420)](t(299)+t(833)+this._url+(" protoco"+t(236))+this[t(438)+"ls"]),this[t(1011)]=e.rXIvg(Vc,{url:this[t(1180)],protocols:[this[t(438)+"ls"]],headers:this[t(1570)]["miniProg"+t(1026)+"s"][t(1287)+"tpHeader"]},this[t(1570)].ws),(this[t(235)+"er"]||this._isWorker)&&this[t(1011)]&&(this[t(1011)][t(715)+"pe"]=this[t(903)+"ype"]),this[t(338)+t(418)](),this["_connect"+t(503)+"utId"]=e[t(282)](setTimeout,this._onTimeout[t(411)](this),x)}else{if(this[t(1023)+t(1157)](),this[t(1635)+t(270)](),this["_removeW"+t(691)+"rs"](),this[t(370)+t(1197)](1e3,_0x375683),this[t(300)+"Lock"]=!1,_0x9290b8&&this[t(1514)+t(210)]()&&!this[t(935)+t(869)]){if(this[t(957)+t(1640)]?.["checkRea"+t(830)+"es"]()){let x=this[t(957)+"tManager"]?.[t(252)+"ntEndpoint"]();this[t(1363)+t(1530)+t(981)](e[t(666)](_0x4e6f40,e.vyLpc,{code:1006,reason:t(972)+x+(t(1165)+", max re"+t(1503)+t(1159)),wasClean:!0}))}else{let x=this[t(1570)]["reconnectInterce"+t(895)](_0x53826a,_0x16d87a);this[t(1363)+"hCloseEvent"](e.cLRRv(_0x379f30,e.vyLpc,{code:_0x9c3edf,reason:_0x4c68ff,wasClean:!0,willReconnect:x})),x&&this[t(300)]()}return}this[t(1514)+t(210)]()||this[t(935)+t(869)]?this[t(1363)+t(1530)+t(981)](_0x2f1296(e[t(829)],{code:_0x4fb86b,reason:t(946)})):this["_dispatchCloseEv"+t(981)](e[t(1389)](_0x21e78a,t(296),{code:1006,reason:e.dPOgd})),this[t(1011)]=null,this[t(957)+"tManager"]?.[t(1018)+t(804)+t(1516)](),this["_pingLos"+t(1378)]?.[t(1291)+t(795)]()}}catch(a){throw this["_connect"+t(1087)]=!1,a}}}[n(1635)+"mer"](){let t=n;e.AUkTa(e[t(1529)],e[t(1529)])?(e[t(1127)](clearTimeout,this["_connect"+t(503)+t(487)]),this[t(300)+t(503)+t(487)]=null):_0x2c0a26[t(264)](_0x5efb41,_0x3b7560)}[n(1023)+"ngTimer"](){let t=n,r={dxgro:function(a,x){return e[R(307)](a,x)},aDjdd:function(a){return e[R(997)](a)}};e[t(1131)](e[t(383)],e[t(1091)])?(BkRxaH.dxgro(_0x2559c0,_0xe5e9a7.error),BkRxaH.aDjdd(_0x1b4fd8)):(e[t(1533)](clearTimeout,this[t(1537)+t(1129)+"Id"]),e.tveyy(clearTimeout,this[t(410)+t(743)+t(819)]),this[t(1537)+"gTimeoutId"]=null,this[t(410)+t(743)+t(819)]=null)}_debug(...t){let r=n;this._options.debug&&console[r(405)][r(1486)](console,[e[r(348)],...t])}[n(1501)+"rvalValue"](t){let r=n;if(e[r(295)](e[r(377)],"RXDXR")){let{initReconnectInterval:a,maxReconnectInterval:x,reconnectIntervalGrowFactor:g}=this[r(1570)],m=e.TXhYl(a,Math.pow(g,t-1));return e[r(635)](m,x)?x:m}else{let a=e.avvMW(_0x2307e0,e[r(268)],{message:this[r(1259)+r(914)+r(1599)](_0x4ff8a9)});this[r(999)](r(1181),a);let x=e.TzQCO(_0x209e96,r(296),{reason:this[r(1259)+r(914)+r(1599)](_0x1d118f)});this[r(999)](e[r(829)],x)}}[n(1373)](){let t=n;if(this._ws&&e[t(392)](this[t(1011)][t(230)+"te"],this[t(917)+"NG"])){this._clearPingTimer(),this["_pingPon"+t(1129)+"Id"]=e[t(1450)](setTimeout,this[t(1373)][t(411)](this),this._options[t(809)+t(1117)]);return}if(!this[t(1011)]||e[t(654)](this._ws[t(230)+"te"],this[t(1605)]))return void this[t(464)+t(569)]();this[t(1011)]&&this._ws[t(1470)]("hi"),this[t(410)+t(743)+t(819)]=e[t(1253)](setTimeout,this[t(464)+"econnect"+t(1399)][t(411)](this),this._options[t(531)+t(1392)+t(1273)])}["_handleR"+n(569)+n(1399)](){let t=n;this[t(1415)+t(1378)]?.[t(1616)](),this[t(999)](e[t(416)],e.TlzqM),this[t(1415)+t(1378)]?.[t(1320)+t(1523)+"nt"]()?this["_handleR"+t(569)]():this[t(1373)]()}[n(1514)+n(210)](){let t=n;if(e[t(918)]===t(644))throw _0x1bb906=_0x3bc290[t(1606)],e[t(320)](_0x30e25c,_0x5ad18c,10,_0x5dac76.length);return this[t(538)+"T"]||this._isMiniWX?this["_miniNav"+t(1028)+t(585)]:(this[t(235)+"er"]||this[t(297)+"r"])&&this[t(1570)][t(1624)+"tworkCha"+t(1613)]?navigator.onLine:!0}[n(464)+n(569)](){let t=n;!this[t(1514)+t(210)]()||this[t(935)+t(869)]||(this[t(957)+t(1640)]?.["resetEnd"+t(804)+"fig"](),this[t(1415)+t(1378)]?.[t(1291)+t(795)](),this[t(1011)]?this["_disconn"+t(1027)](1001,e.ymouM,!0):this._connect())}[n(1081)+n(1207)+n(1548)](){let t=n,r={yxefY:"PIYZa",CIeYj:e[t(1148)]};this[t(538)+"T"]?tt[t(1041)+t(1116)+"hange"](({isConnected:a})=>{let x=t;this["_miniNav"+x(1028)+x(585)]=a,a?this[x(596)+x(754)]():this[x(596)+x(1193)]()}):this[t(1112)+"X"]&&wx[t(1041)+t(1116)+t(1338)](({isConnected:a})=>{let x=t;r[x(921)]===r.CIeYj?_0x1cba54[x(1578)]=_0x42fcca[x(998)]()[x(851)](()=>(_0x1b35a6(),_0xae47da))[x(851)](function(g){return g}):(this[x(533)+x(1028)+x(585)]=a,a?this["_handleO"+x(754)]():this[x(596)+x(1193)]())})}[n(1267)](t){let r={LqLLY:function(a,x,g){return e[R(1443)](a,x,g)}};return new Promise(a=>{let x=R;r[x(1408)](setTimeout,a,this[x(1501)+x(1301)+"e"](t))})}[n(1118)+"ect"](t=1e3,r="",a=!1){let x=n;if(e.TtgyM(e.wjjND,e[x(1384)]))this[x(1276)+x(289)+"Id"]=null,this[x(1276)+"l"]=36e5,this[x(843)]=_0x4139d8(e.aCwsr,e.ohmdq);else{if(!this._ws)return;this[x(311)+x(1477)+"t"](t,r,a)}}[n(1428)+"ut"](){let t=n;if(e[t(1623)]!==e[t(969)]){let r=this[t(957)+t(1640)]?.getCurrentEndpoint();this._debug(t(972)+r+" timeout"),this[t(1118)+t(1027)](1001,e[t(818)],!0)}else this[t(555)+t(373)]=null}[n(1163)](t){let r=n,a=e[r(426)](re,t);this._ws&&e[r(1094)](this[r(1011)][r(230)+"te"],this[r(1605)])&&(this[r(1011)]&&this._ws[r(1470)](a),this[r(1420)]("send_ack",t))}["_removeW"+n(691)+"rs"](){let t=n,r=e[t(578)][t(1354)]("|"),a=0;for(;;){switch(r[a++]){case"0":this[t(1011)][t(1441)+t(623)+t(630)](e[t(665)],this[t(1453)]);continue;case"1":this._ws[t(1441)+t(623)+t(630)](e[t(829)],this._onClose);continue;case"2":this._ws[t(1441)+"entListe"+t(630)](e[t(268)],this[t(896)]);continue;case"3":this[t(1011)][t(1441)+t(623)+t(630)](e[t(1012)],this[t(1039)+"ge"]);continue;case"4":if(!this._ws)return;continue}break}}[n(338)+n(418)](){let t=n;this[t(1011)]&&(this[t(1011)]["addEvent"+t(196)](e[t(665)],this[t(1453)]),this[t(1011)]["addEvent"+t(196)]("close",this[t(960)]),this[t(1011)]["addEvent"+t(196)](e[t(1012)],this[t(1039)+"ge"]),this[t(1011)][t(621)+t(196)](e[t(268)],this._onError))}[n(370)+n(1197)](t=1e3,r=""){let a=n;try{this[a(1011)]&&this._ws[a(296)](t,r)}catch{}}["_destroy"+n(1477)+"t"](t=1e3,r="",a=!1){let x=n;if(e[x(807)](e[x(316)],e[x(316)])){let g={NtIBy:function(m,y){return e[x(984)](m,y)},GEQmk:e.xfAEb,OLVMf:x(1438)+"e_success",RPdeD:"ping_onc"+x(731)+"t",xpmXM:function(m,y){return e.qSLmM(m,y)},lbYsQ:e[x(393)],kOHxq:function(m,y,_){return e.BtSUT(m,y,_)}};return new _0x4c66ed((m,y)=>{let _=x,l={GTLiB:function(D,F){return g[R(195)](D,F)},FjPRm:g[_(1550)],zsmII:g[_(496)]};this[_(1023)+_(1157)](),this["_pingPon"+_(1129)+"Id"]=g.kOHxq(_0x33f5a7,this._ping.bind(this),this[_(1570)][_(809)+_(1117)]);let v=()=>{let D=_;g[D(442)](m,g[D(350)]),this[D(333)](g[D(496)],v),this.off(g[D(1196)],C)},C=()=>{let D=_;l[D(1351)](y,l[D(318)]),this.off(l[D(1460)],v),this[D(333)](D(1438)+D(731)+"t",C)};this.on(g[_(496)],v),this.on(g.RPdeD,C),this._ping()})}else{if(this._clearPingTimer(),this[x(1635)+x(270)](),this[x(440)+x(691)+"rs"](),this[x(370)+x(1197)](1e3,r),this["_connect"+x(1087)]=!1,a&&this[x(1514)+x(210)]()&&!this[x(935)+x(869)]){if(this[x(957)+x(1640)]?.checkReachMaxTries())if(e.akqAY(e.CWLbF,e[x(1128)])){let m=this._endpointManager?.[x(252)+x(1586)+"nt"]();this[x(1363)+x(1530)+x(981)](e[x(1025)](De,e[x(829)],{code:1006,reason:x(972)+m+(" timeout, max re"+x(1503)+"ached"),wasClean:!0}))}else return 0;else{let m=this._options["reconnec"+x(603)+x(895)](t,r);this[x(1363)+x(1530)+x(981)](e.zdKnc(De,x(296),{code:t,reason:r,wasClean:!0,willReconnect:m})),m&&this[x(300)]()}return}this[x(1514)+x(210)]()||this["_readyCl"+x(869)]?this[x(1363)+"hCloseEvent"](e.YZeUo(De,x(296),{code:t,reason:x(946)})):this[x(1363)+x(1530)+"ent"](De(e[x(829)],{code:1006,reason:e.dPOgd})),this[x(1011)]=null,this._endpointManager?.["resetEnd"+x(804)+x(1516)](),this[x(1415)+x(1378)]?.[x(1291)+x(795)]()}}[n(1363)+n(1098)+"nt"](t){let r=n;e[r(468)]===r(943)?(pVJgTo[r(647)](_0x857d14,_0x3d493d[r(1181)]||new _0x588bdc(pVJgTo.buhql,pVJgTo[r(260)])),pVJgTo.Vsufu(_0x8dd48f)):(this.emit(e.hXcPH,t),this.onopen&&this[r(802)](t))}[n(1363)+n(642)+n(1386)](t){let r=n;if(e.BWdVF(e[r(855)],"TYFpt"))return _0xcf32fc[r(998)]();this[r(999)]("message",t),this[r(736)+"e"]&&this.onmessage(t)}[n(1363)+"hAckMess"+n(702)](t){let r=n;this[r(999)](r(530),t),this[r(1337)+r(1218)]&&this["onReceiv"+r(1218)](t)}[n(1363)+n(1574)+"ent"](t){let r=n,a={jWwcV:function(x,g,m,y){return e[R(764)](x,g,m,y)}};e[r(375)](e[r(712)],e[r(712)])?(this[r(999)](e[r(268)],t),this[r(1227)]&&this.onerror(t)):nmSAaB[r(1047)](_0x362403,this,_0xd51eb5,[_0x262edb,_0x343269,_0x5e231e,_0x3faec2,_0x57b1f1,_0x8195ed])}[n(1363)+"hCloseEvent"](t){let r=n;this[r(999)](e[r(829)],t),this[r(1553)]&&this[r(1553)](t)}get[n(715)+"pe"](){let t=n,r={loCgs:e[t(1331)],NDueY:e.uhrJU};if(e[t(1297)](e.LocYf,e[t(879)]))switch(_0x1761f2){case UJUlrj.loCgs:case UJUlrj[t(1160)]:return{[t(866)+_0x111dea]:1,"x-tt-env":_0x2ee923};default:return{}}else return this[t(1011)]?this[t(1011)][t(715)+"pe"]:this[t(903)+t(1542)]}set binaryType(t){let r=n;this[r(903)+"ype"]=t,this[r(1011)]&&(this[r(1011)][r(715)+"pe"]=t)}get[n(1597)+"nt"](){let t=n;return this["_endpoin"+t(1640)]?.["getCurrentEndpoi"+t(1372)+t(729)]()||0}get["buffered"+n(1611)](){let t=n,r=this[t(1056)+t(990)][t(1506)]((a,x)=>(a+=x&&x.byteLength||0,a),0);return e[t(1166)](r,this._ws?this[t(1011)][t(1311)+t(1611)]:0)}get extensions(){let t=n;return this[t(1011)]?this[t(1011)].extensions:""}get[n(820)](){let t=n,r={alrET:function(a,x){return e[R(976)](a,x)}};if(t(498)===e[t(814)]){let a=_0x49d5c3[t(1488)+"g"](0,jJdEhK[t(1312)](4,_0x4ded2a[t(1606)])),x=a.concat(_0x1bcebf);_0x1e3850.push(x)}else return this._ws?this[t(1011)][t(820)]:""}get[n(230)+"te"](){let t=n;return this[t(1011)]?this[t(1011)][t(230)+"te"]:this[t(1570)]["automati"+t(443)]?this[t(917)+"NG"]:this[t(781)]}get[n(747)](){let t=n;return this._ws?this._ws[t(747)]:this._url}close(t=1e3,r){let a=n,x=e[a(1446)].split("|"),g=0;for(;;){switch(x[g++]){case"0":this[a(1023)+"ngTimer"]();continue;case"1":this._clearTimer();continue;case"2":if(!this[a(1011)])return void this[a(1420)](e[a(584)]);continue;case"3":this[a(637)+a(1243)+a(196)]();continue;case"4":this[a(357)+a(725)]?.[a(429)]();continue;case"5":this[a(311)+a(1477)+"t"](t,r);continue;case"6":this[a(935)+a(869)]=!0;continue;case"7":if(e[a(688)](this._ws[a(230)+"te"],this.CLOSED)||e[a(375)](this._ws.readyState,this[a(1474)]))return void this[a(1420)](e[a(1380)]);continue}break}}async send(t,r){let a=n;if(t==null)throw new Error(e[a(858)]);e.rLtAE(e[a(808)],typeof t)&&(t=JSON[a(600)+"y"](t)),e.vhniu!=typeof t&&!e[a(977)](t,ArrayBuffer)&&!(t[a(798)]&&e[a(476)](t[a(798)],ArrayBuffer))&&(t=JSON[a(600)+"y"](t));let x=await e[a(786)](us,t),g=e.rIDIw(Xc,t),{method:m=0,service:y=this[a(1570)][a(452)],logID:_=this._options[a(1496)+"erator"](),headers:l=this[a(1570)][a(1260)],payloadEncoding:v=this[a(1570)][a(1309)+"ncoding"],payloadType:C=this[a(1570)][a(332)+"ype"],logIDNew:D=this._options[a(1005)+"Config"][a(535)+"toGenerateLogIDNew"]?e.ftpyv(o,this[a(1570)][a(1005)+a(1052)][a(1313)]):""}=e.gHxBB(r,{});if(!y)throw new Error(e.gbour);let F={SeqID:K[a(1356)+"er"](this._seqId++),LogID:K[a(1356)+"er"](_),service:y,method:m,headers:l,payloadEncoding:e[a(620)](v,Object)?v.encoding?v[a(940)]:"":v,payloadType:C instanceof Object?C.type?C[a(1061)]:g:C||g,payload:x,LogIDNew:D},U=re(F);return this[a(1011)]&&e.hgLkw(this[a(1011)][a(230)+"te"],this[a(1605)])?(this[a(1011)]&&this[a(1011)][a(1470)](U),this[a(1420)](e[a(573)],F)):e.ATqvG(this[a(1056)+a(990)][a(1606)],this._options["maxMessa"+a(1323)+a(1229)])?(this[a(1056)+a(990)][a(1034)](U),this[a(1420)](e[a(329)],F)):(this[a(1056)+a(990)].shift(),this._messageQueue[a(1034)](U)),{seqID:this._seqId,logID:_,logIDNew:D}}async[n(793)+"t"](t){let r=n,{url:a}=e[r(1458)](t,{}),x=Array[r(618)](a)?a:typeof a=="string"?[a]:[];t&&Object[r(1096)](this[r(1570)],t),x&&x[r(1606)]?this[r(957)+"tManager"]=new as(x,this[r(1570)][r(480)+"es"]):this[r(957)+r(1640)]?.["resetEnd"+r(804)+r(1516)](),this[r(1415)+r(1378)]?.[r(1291)+r(795)](this[r(1570)]["pingLoss"+r(982)]),this[r(935)+r(869)]=!1,this[r(1011)]&&e[r(991)](this[r(1011)][r(230)+"te"],this[r(781)])?this[r(1118)+r(1027)](1e3,r(1519)+r(569)+r(376),!0):(this[r(552)]=!0,this[r(300)]())}async[n(312)](){let t=n,r={dYJsT:function(a,x,g){return e[R(670)](a,x,g)},xHbrt:function(a,x){return e[R(203)](a,x)},sCRCE:function(a,x,g){return e.IZApY(a,x,g)}};if(e.EGQJG(e[t(950)],e[t(728)])){if(!this["_connect"+t(1087)]){let a=(t(263)+"2").split("|"),x=0;for(;;){switch(a[x++]){case"0":this[t(935)+t(869)]=!1;continue;case"1":this[t(957)+t(1640)]?.[t(1018)+t(804)+t(1516)]();continue;case"2":this[t(300)]();continue;case"3":this[t(552)]=!0;continue;case"4":this["_pingLos"+t(1378)]?.["resetCou"+t(795)]();continue}break}}}else{if(this[t(1011)]&&this[t(1011)].readyState===this[t(917)+"NG"]){this[t(1023)+t(1157)](),this["_pingPon"+t(1129)+"Id"]=smSykJ.dYJsT(_0x1a3250,this[t(1373)][t(411)](this),this[t(1570)][t(809)+t(1117)]);return}if(!this[t(1011)]||smSykJ[t(681)](this[t(1011)][t(230)+"te"],this[t(1605)]))return void this[t(464)+t(569)]();this[t(1011)]&&this[t(1011)][t(1470)]("hi"),this["_reconnectTimeou"+t(819)]=smSykJ[t(1268)](_0x240960,this["_handleR"+t(569)+t(1399)].bind(this),this[t(1570)][t(531)+"outInterval"])}}["addEvent"+n(196)](t,r){this.on(t,r)}["dispatch"+n(1386)](t){let r=n;if(e[r(1296)]!==e.bYPGD){let{type:a}=t;this[r(999)](a,t)}else return!!this._qosDB}["removeEv"+n(623)+"ner"](t,r){this.off(t,r)}[n(1063)](){let t=n,r={SzGpc:t(605),GvSXY:e.QPkPh,bNspX:function(a,x){return e[t(526)](a,x)},bnPCm:e[t(1205)],WCLcv:t(1184),wYoVO:e[t(553)],ZtxSQ:function(a,x,g){return e[t(1203)](a,x,g)}};return new Promise((a,x)=>{let g=t,m={gVBth:function(l,v){return r[R(1349)](l,v)},PwpuM:r[g(197)],nXWSQ:r[g(1305)],AgHNm:r[g(419)]};this[g(1023)+g(1157)](),this[g(1537)+g(1129)+"Id"]=r[g(1449)](setTimeout,this._ping.bind(this),this._options[g(809)+g(1117)]);let y=()=>{let l=g;a(r[l(288)]),this[l(333)](l(1438)+l(558)+"s",y),this[l(333)](r[l(1235)],_)},_=()=>{let l=g;m[l(239)]("PkGNb",m[l(334)])?(this[l(903)+l(1542)]=_0x24f721,this._ws&&(this[l(1011)][l(715)+"pe"]=_0x343f3a)):(x(m.nXWSQ),this[l(333)](m.AgHNm,y),this[l(333)](l(1438)+l(731)+"t",_))};this.on(r[g(419)],y),this.on(r.GvSXY,_),this._ping()})}}})(),se[P(939)+P(717)]=te["CustomCl"+P(717)],se["CustomEr"+P(792)]=te.CustomErrorEvent,se.ErrorCode=te[P(1610)+"e"],se[P(1386)]=te.Event,se[P(1520)]=te[P(1520)],se[P(956)+"MessageE"+P(472)]=te[P(956)+P(1490)+"vent"],se[P(1490)+P(472)]=te[P(1490)+P(472)],se[P(1639)+"t"]=te[P(1639)+"t"],se[P(562)+P(841)]=te[P(562)+P(841)],se[P(581)+P(717)]=te[P(581)+"oseEvent"],se.createErrorEvent=te["createEr"+P(792)],se[P(860)+P(206)+"nt"]=te["createMe"+P(206)+"nt"],se["createOp"+P(1156)]=te[P(1135)+P(1156)],se[P(1264)+"connectE"+P(472)]=te[P(1264)+P(444)+P(472)],se[P(873)+P(1075)]=te[P(873)+P(1075)],se[P(669)+P(1614)]=te[P(669)+P(1614)];for(Zn in te)["CustomCl"+P(717),P(445)+P(792),P(1610)+"e","Event",P(1520),P(956)+"MessageEvent",P(1490)+"vent","OpenEvent",P(562)+P(841),"createCl"+P(717),P(1214)+P(792),"createMe"+P(206)+"nt",P(1135)+P(1156),"createRe"+P(444)+P(472),P(873)+P(1075),P(669)+P(1614)][P(539)](Zn)===-1&&(se[Zn]=te[Zn]);var Zn;Object[P(542)+P(325)](se,P(762)+"le",{value:!0})});var Ve=be((h_,sa)=>{"use strict";var ra=["nodebuffer","arraybuffer","fragments"],ia=typeof Blob<"u";ia&&ra.push("blob");sa.exports={BINARY_TYPES:ra,CLOSE_TIMEOUT:3e4,EMPTY_BUFFER:Buffer.alloc(0),GUID:"258EAFA5-E914-47DA-95CA-C5AB0DC85B11",hasBlob:ia,kForOnEventAttribute:Symbol("kIsForOnEventAttribute"),kListener:Symbol("kListener"),kStatusCode:Symbol("status-code"),kWebSocket:Symbol("websocket"),NOOP:()=>{}}});var xn=be((p_,or)=>{"use strict";var{EMPTY_BUFFER:gf}=Ve(),li=Buffer[Symbol.species];function hf(n,e){if(n.length===0)return gf;if(n.length===1)return n[0];let s=Buffer.allocUnsafe(e),o=0;for(let c=0;c<n.length;c++){let d=n[c];s.set(d,o),o+=d.length}return o<e?new li(s.buffer,s.byteOffset,o):s}function oa(n,e,s,o,c){for(let d=0;d<c;d++)s[o+d]=n[d]^e[d&3]}function aa(n,e){for(let s=0;s<n.length;s++)n[s]^=e[s&3]}function pf(n){return n.length===n.buffer.byteLength?n.buffer:n.buffer.slice(n.byteOffset,n.byteOffset+n.length)}function gi(n){if(gi.readOnly=!0,Buffer.isBuffer(n))return n;let e;return n instanceof ArrayBuffer?e=new li(n):ArrayBuffer.isView(n)?e=new li(n.buffer,n.byteOffset,n.byteLength):(e=Buffer.from(n),gi.readOnly=!1),e}or.exports={concat:hf,mask:oa,toArrayBuffer:pf,toBuffer:gi,unmask:aa};if(!process.env.WS_NO_BUFFER_UTIL)try{let n=ee("bufferutil");or.exports.mask=function(e,s,o,c,d){d<48?oa(e,s,o,c,d):n.mask(e,s,o,c,d)},or.exports.unmask=function(e,s){e.length<32?aa(e,s):n.unmask(e,s)}}catch{}});var xa=be((m_,da)=>{"use strict";var ca=Symbol("kDone"),hi=Symbol("kRun"),pi=class{constructor(e){this[ca]=()=>{this.pending--,this[hi]()},this.concurrency=e||1/0,this.jobs=[],this.pending=0}add(e){this.jobs.push(e),this[hi]()}[hi](){if(this.pending!==this.concurrency&&this.jobs.length){let e=this.jobs.shift();this.pending++,e(this[ca])}}};da.exports=pi});var Ft=be((w_,ga)=>{"use strict";var un=ee("zlib"),ua=xn(),mf=xa(),{kStatusCode:fa}=Ve(),wf=Buffer[Symbol.species],_f=Buffer.from([0,0,255,255]),cr=Symbol("permessage-deflate"),Ye=Symbol("total-length"),Bt=Symbol("callback"),dt=Symbol("buffers"),zt=Symbol("error"),ar,mi=class{constructor(e){if(this._options=e||{},this._threshold=this._options.threshold!==void 0?this._options.threshold:1024,this._maxPayload=this._options.maxPayload|0,this._isServer=!!this._options.isServer,this._deflate=null,this._inflate=null,this.params=null,!ar){let s=this._options.concurrencyLimit!==void 0?this._options.concurrencyLimit:10;ar=new mf(s)}}static get extensionName(){return"permessage-deflate"}offer(){let e={};return this._options.serverNoContextTakeover&&(e.server_no_context_takeover=!0),this._options.clientNoContextTakeover&&(e.client_no_context_takeover=!0),this._options.serverMaxWindowBits&&(e.server_max_window_bits=this._options.serverMaxWindowBits),this._options.clientMaxWindowBits?e.client_max_window_bits=this._options.clientMaxWindowBits:this._options.clientMaxWindowBits==null&&(e.client_max_window_bits=!0),e}accept(e){return e=this.normalizeParams(e),this.params=this._isServer?this.acceptAsServer(e):this.acceptAsClient(e),this.params}cleanup(){if(this._inflate&&(this._inflate.close(),this._inflate=null),this._deflate){let e=this._deflate[Bt];this._deflate.close(),this._deflate=null,e&&e(new Error("The deflate stream was closed while data was being processed"))}}acceptAsServer(e){let s=this._options,o=e.find(c=>!(s.serverNoContextTakeover===!1&&c.server_no_context_takeover||c.server_max_window_bits&&(s.serverMaxWindowBits===!1||typeof s.serverMaxWindowBits=="number"&&s.serverMaxWindowBits>c.server_max_window_bits)||typeof s.clientMaxWindowBits=="number"&&!c.client_max_window_bits));if(!o)throw new Error("None of the extension offers can be accepted");return s.serverNoContextTakeover&&(o.server_no_context_takeover=!0),s.clientNoContextTakeover&&(o.client_no_context_takeover=!0),typeof s.serverMaxWindowBits=="number"&&(o.server_max_window_bits=s.serverMaxWindowBits),typeof s.clientMaxWindowBits=="number"?o.client_max_window_bits=s.clientMaxWindowBits:(o.client_max_window_bits===!0||s.clientMaxWindowBits===!1)&&delete o.client_max_window_bits,o}acceptAsClient(e){let s=e[0];if(this._options.clientNoContextTakeover===!1&&s.client_no_context_takeover)throw new Error('Unexpected parameter "client_no_context_takeover"');if(!s.client_max_window_bits)typeof this._options.clientMaxWindowBits=="number"&&(s.client_max_window_bits=this._options.clientMaxWindowBits);else if(this._options.clientMaxWindowBits===!1||typeof this._options.clientMaxWindowBits=="number"&&s.client_max_window_bits>this._options.clientMaxWindowBits)throw new Error('Unexpected or invalid parameter "client_max_window_bits"');return s}normalizeParams(e){return e.forEach(s=>{Object.keys(s).forEach(o=>{let c=s[o];if(c.length>1)throw new Error(`Parameter "${o}" must have only a single value`);if(c=c[0],o==="client_max_window_bits"){if(c!==!0){let d=+c;if(!Number.isInteger(d)||d<8||d>15)throw new TypeError(`Invalid value for parameter "${o}": ${c}`);c=d}else if(!this._isServer)throw new TypeError(`Invalid value for parameter "${o}": ${c}`)}else if(o==="server_max_window_bits"){let d=+c;if(!Number.isInteger(d)||d<8||d>15)throw new TypeError(`Invalid value for parameter "${o}": ${c}`);c=d}else if(o==="client_no_context_takeover"||o==="server_no_context_takeover"){if(c!==!0)throw new TypeError(`Invalid value for parameter "${o}": ${c}`)}else throw new Error(`Unknown parameter "${o}"`);s[o]=c})}),e}decompress(e,s,o){ar.add(c=>{this._decompress(e,s,(d,u)=>{c(),o(d,u)})})}compress(e,s,o){ar.add(c=>{this._compress(e,s,(d,u)=>{c(),o(d,u)})})}_decompress(e,s,o){let c=this._isServer?"client":"server";if(!this._inflate){let d=`${c}_max_window_bits`,u=typeof this.params[d]!="number"?un.Z_DEFAULT_WINDOWBITS:this.params[d];this._inflate=un.createInflateRaw({...this._options.zlibInflateOptions,windowBits:u}),this._inflate[cr]=this,this._inflate[Ye]=0,this._inflate[dt]=[],this._inflate.on("error",bf),this._inflate.on("data",la)}this._inflate[Bt]=o,this._inflate.write(e),s&&this._inflate.write(_f),this._inflate.flush(()=>{let d=this._inflate[zt];if(d){this._inflate.close(),this._inflate=null,o(d);return}let u=ua.concat(this._inflate[dt],this._inflate[Ye]);this._inflate._readableState.endEmitted?(this._inflate.close(),this._inflate=null):(this._inflate[Ye]=0,this._inflate[dt]=[],s&&this.params[`${c}_no_context_takeover`]&&this._inflate.reset()),o(null,u)})}_compress(e,s,o){let c=this._isServer?"server":"client";if(!this._deflate){let d=`${c}_max_window_bits`,u=typeof this.params[d]!="number"?un.Z_DEFAULT_WINDOWBITS:this.params[d];this._deflate=un.createDeflateRaw({...this._options.zlibDeflateOptions,windowBits:u}),this._deflate[Ye]=0,this._deflate[dt]=[],this._deflate.on("data",yf)}this._deflate[Bt]=o,this._deflate.write(e),this._deflate.flush(un.Z_SYNC_FLUSH,()=>{if(!this._deflate)return;let d=ua.concat(this._deflate[dt],this._deflate[Ye]);s&&(d=new wf(d.buffer,d.byteOffset,d.length-4)),this._deflate[Bt]=null,this._deflate[Ye]=0,this._deflate[dt]=[],s&&this.params[`${c}_no_context_takeover`]&&this._deflate.reset(),o(null,d)})}};ga.exports=mi;function yf(n){this[dt].push(n),this[Ye]+=n.length}function la(n){if(this[Ye]+=n.length,this[cr]._maxPayload<1||this[Ye]<=this[cr]._maxPayload){this[dt].push(n);return}this[zt]=new RangeError("Max payload size exceeded"),this[zt].code="WS_ERR_UNSUPPORTED_MESSAGE_LENGTH",this[zt][fa]=1009,this.removeListener("data",la),this.reset()}function bf(n){if(this[cr]._inflate=null,this[zt]){this[Bt](this[zt]);return}n[fa]=1007,this[Bt](n)}});var Ut=be((__,dr)=>{"use strict";var{isUtf8:ha}=ee("buffer"),{hasBlob:vf}=Ve(),Sf=[0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,1,0,1,1,1,1,1,0,0,1,1,0,1,1,0,1,1,1,1,1,1,1,1,1,1,0,0,0,0,0,0,0,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,0,0,0,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,0,1,0,1,0];function Ef(n){return n>=1e3&&n<=1014&&n!==1004&&n!==1005&&n!==1006||n>=3e3&&n<=4999}function wi(n){let e=n.length,s=0;for(;s<e;)if((n[s]&128)===0)s++;else if((n[s]&224)===192){if(s+1===e||(n[s+1]&192)!==128||(n[s]&254)===192)return!1;s+=2}else if((n[s]&240)===224){if(s+2>=e||(n[s+1]&192)!==128||(n[s+2]&192)!==128||n[s]===224&&(n[s+1]&224)===128||n[s]===237&&(n[s+1]&224)===160)return!1;s+=3}else if((n[s]&248)===240){if(s+3>=e||(n[s+1]&192)!==128||(n[s+2]&192)!==128||(n[s+3]&192)!==128||n[s]===240&&(n[s+1]&240)===128||n[s]===244&&n[s+1]>143||n[s]>244)return!1;s+=4}else return!1;return!0}function If(n){return vf&&typeof n=="object"&&typeof n.arrayBuffer=="function"&&typeof n.type=="string"&&typeof n.stream=="function"&&(n[Symbol.toStringTag]==="Blob"||n[Symbol.toStringTag]==="File")}dr.exports={isBlob:If,isValidStatusCode:Ef,isValidUTF8:wi,tokenChars:Sf};if(ha)dr.exports.isValidUTF8=function(n){return n.length<24?wi(n):ha(n)};else if(!process.env.WS_NO_UTF_8_VALIDATE)try{let n=ee("utf-8-validate");dr.exports.isValidUTF8=function(e){return e.length<32?wi(e):n(e)}}catch{}});var Si=be((y_,va)=>{"use strict";var{Writable:Af}=ee("stream"),pa=Ft(),{BINARY_TYPES:Tf,EMPTY_BUFFER:ma,kStatusCode:Pf,kWebSocket:Cf}=Ve(),{concat:_i,toArrayBuffer:kf,unmask:Df}=xn(),{isValidStatusCode:Rf,isValidUTF8:wa}=Ut(),xr=Buffer[Symbol.species],Pe=0,_a=1,ya=2,ba=3,yi=4,bi=5,ur=6,vi=class extends Af{constructor(e={}){super(),this._allowSynchronousEvents=e.allowSynchronousEvents!==void 0?e.allowSynchronousEvents:!0,this._binaryType=e.binaryType||Tf[0],this._extensions=e.extensions||{},this._isServer=!!e.isServer,this._maxPayload=e.maxPayload|0,this._skipUTF8Validation=!!e.skipUTF8Validation,this[Cf]=void 0,this._bufferedBytes=0,this._buffers=[],this._compressed=!1,this._payloadLength=0,this._mask=void 0,this._fragmented=0,this._masked=!1,this._fin=!1,this._opcode=0,this._totalPayloadLength=0,this._messageLength=0,this._fragments=[],this._errored=!1,this._loop=!1,this._state=Pe}_write(e,s,o){if(this._opcode===8&&this._state==Pe)return o();this._bufferedBytes+=e.length,this._buffers.push(e),this.startLoop(o)}consume(e){if(this._bufferedBytes-=e,e===this._buffers[0].length)return this._buffers.shift();if(e<this._buffers[0].length){let o=this._buffers[0];return this._buffers[0]=new xr(o.buffer,o.byteOffset+e,o.length-e),new xr(o.buffer,o.byteOffset,e)}let s=Buffer.allocUnsafe(e);do{let o=this._buffers[0],c=s.length-e;e>=o.length?s.set(this._buffers.shift(),c):(s.set(new Uint8Array(o.buffer,o.byteOffset,e),c),this._buffers[0]=new xr(o.buffer,o.byteOffset+e,o.length-e)),e-=o.length}while(e>0);return s}startLoop(e){this._loop=!0;do switch(this._state){case Pe:this.getInfo(e);break;case _a:this.getPayloadLength16(e);break;case ya:this.getPayloadLength64(e);break;case ba:this.getMask();break;case yi:this.getData(e);break;case bi:case ur:this._loop=!1;return}while(this._loop);this._errored||e()}getInfo(e){if(this._bufferedBytes<2){this._loop=!1;return}let s=this.consume(2);if((s[0]&48)!==0){let c=this.createError(RangeError,"RSV2 and RSV3 must be clear",!0,1002,"WS_ERR_UNEXPECTED_RSV_2_3");e(c);return}let o=(s[0]&64)===64;if(o&&!this._extensions[pa.extensionName]){let c=this.createError(RangeError,"RSV1 must be clear",!0,1002,"WS_ERR_UNEXPECTED_RSV_1");e(c);return}if(this._fin=(s[0]&128)===128,this._opcode=s[0]&15,this._payloadLength=s[1]&127,this._opcode===0){if(o){let c=this.createError(RangeError,"RSV1 must be clear",!0,1002,"WS_ERR_UNEXPECTED_RSV_1");e(c);return}if(!this._fragmented){let c=this.createError(RangeError,"invalid opcode 0",!0,1002,"WS_ERR_INVALID_OPCODE");e(c);return}this._opcode=this._fragmented}else if(this._opcode===1||this._opcode===2){if(this._fragmented){let c=this.createError(RangeError,`invalid opcode ${this._opcode}`,!0,1002,"WS_ERR_INVALID_OPCODE");e(c);return}this._compressed=o}else if(this._opcode>7&&this._opcode<11){if(!this._fin){let c=this.createError(RangeError,"FIN must be set",!0,1002,"WS_ERR_EXPECTED_FIN");e(c);return}if(o){let c=this.createError(RangeError,"RSV1 must be clear",!0,1002,"WS_ERR_UNEXPECTED_RSV_1");e(c);return}if(this._payloadLength>125||this._opcode===8&&this._payloadLength===1){let c=this.createError(RangeError,`invalid payload length ${this._payloadLength}`,!0,1002,"WS_ERR_INVALID_CONTROL_PAYLOAD_LENGTH");e(c);return}}else{let c=this.createError(RangeError,`invalid opcode ${this._opcode}`,!0,1002,"WS_ERR_INVALID_OPCODE");e(c);return}if(!this._fin&&!this._fragmented&&(this._fragmented=this._opcode),this._masked=(s[1]&128)===128,this._isServer){if(!this._masked){let c=this.createError(RangeError,"MASK must be set",!0,1002,"WS_ERR_EXPECTED_MASK");e(c);return}}else if(this._masked){let c=this.createError(RangeError,"MASK must be clear",!0,1002,"WS_ERR_UNEXPECTED_MASK");e(c);return}this._payloadLength===126?this._state=_a:this._payloadLength===127?this._state=ya:this.haveLength(e)}getPayloadLength16(e){if(this._bufferedBytes<2){this._loop=!1;return}this._payloadLength=this.consume(2).readUInt16BE(0),this.haveLength(e)}getPayloadLength64(e){if(this._bufferedBytes<8){this._loop=!1;return}let s=this.consume(8),o=s.readUInt32BE(0);if(o>Math.pow(2,21)-1){let c=this.createError(RangeError,"Unsupported WebSocket frame: payload length > 2^53 - 1",!1,1009,"WS_ERR_UNSUPPORTED_DATA_PAYLOAD_LENGTH");e(c);return}this._payloadLength=o*Math.pow(2,32)+s.readUInt32BE(4),this.haveLength(e)}haveLength(e){if(this._payloadLength&&this._opcode<8&&(this._totalPayloadLength+=this._payloadLength,this._totalPayloadLength>this._maxPayload&&this._maxPayload>0)){let s=this.createError(RangeError,"Max payload size exceeded",!1,1009,"WS_ERR_UNSUPPORTED_MESSAGE_LENGTH");e(s);return}this._masked?this._state=ba:this._state=yi}getMask(){if(this._bufferedBytes<4){this._loop=!1;return}this._mask=this.consume(4),this._state=yi}getData(e){let s=ma;if(this._payloadLength){if(this._bufferedBytes<this._payloadLength){this._loop=!1;return}s=this.consume(this._payloadLength),this._masked&&(this._mask[0]|this._mask[1]|this._mask[2]|this._mask[3])!==0&&Df(s,this._mask)}if(this._opcode>7){this.controlMessage(s,e);return}if(this._compressed){this._state=bi,this.decompress(s,e);return}s.length&&(this._messageLength=this._totalPayloadLength,this._fragments.push(s)),this.dataMessage(e)}decompress(e,s){this._extensions[pa.extensionName].decompress(e,this._fin,(c,d)=>{if(c)return s(c);if(d.length){if(this._messageLength+=d.length,this._messageLength>this._maxPayload&&this._maxPayload>0){let u=this.createError(RangeError,"Max payload size exceeded",!1,1009,"WS_ERR_UNSUPPORTED_MESSAGE_LENGTH");s(u);return}this._fragments.push(d)}this.dataMessage(s),this._state===Pe&&this.startLoop(s)})}dataMessage(e){if(!this._fin){this._state=Pe;return}let s=this._messageLength,o=this._fragments;if(this._totalPayloadLength=0,this._messageLength=0,this._fragmented=0,this._fragments=[],this._opcode===2){let c;this._binaryType==="nodebuffer"?c=_i(o,s):this._binaryType==="arraybuffer"?c=kf(_i(o,s)):this._binaryType==="blob"?c=new Blob(o):c=o,this._allowSynchronousEvents?(this.emit("message",c,!0),this._state=Pe):(this._state=ur,setImmediate(()=>{this.emit("message",c,!0),this._state=Pe,this.startLoop(e)}))}else{let c=_i(o,s);if(!this._skipUTF8Validation&&!wa(c)){let d=this.createError(Error,"invalid UTF-8 sequence",!0,1007,"WS_ERR_INVALID_UTF8");e(d);return}this._state===bi||this._allowSynchronousEvents?(this.emit("message",c,!1),this._state=Pe):(this._state=ur,setImmediate(()=>{this.emit("message",c,!1),this._state=Pe,this.startLoop(e)}))}}controlMessage(e,s){if(this._opcode===8){if(e.length===0)this._loop=!1,this.emit("conclude",1005,ma),this.end();else{let o=e.readUInt16BE(0);if(!Rf(o)){let d=this.createError(RangeError,`invalid status code ${o}`,!0,1002,"WS_ERR_INVALID_CLOSE_CODE");s(d);return}let c=new xr(e.buffer,e.byteOffset+2,e.length-2);if(!this._skipUTF8Validation&&!wa(c)){let d=this.createError(Error,"invalid UTF-8 sequence",!0,1007,"WS_ERR_INVALID_UTF8");s(d);return}this._loop=!1,this.emit("conclude",o,c),this.end()}this._state=Pe;return}this._allowSynchronousEvents?(this.emit(this._opcode===9?"ping":"pong",e),this._state=Pe):(this._state=ur,setImmediate(()=>{this.emit(this._opcode===9?"ping":"pong",e),this._state=Pe,this.startLoop(s)}))}createError(e,s,o,c,d){this._loop=!1,this._errored=!0;let u=new e(o?`Invalid WebSocket frame: ${s}`:s);return Error.captureStackTrace(u,this.createError),u.code=d,u[Pf]=c,u}};va.exports=vi});var Ai=be((v_,Ia)=>{"use strict";var{Duplex:b_}=ee("stream"),{randomFillSync:Nf}=ee("crypto"),Sa=Ft(),{EMPTY_BUFFER:Of,kWebSocket:Lf,NOOP:Mf}=Ve(),{isBlob:qt,isValidStatusCode:Bf}=Ut(),{mask:Ea,toBuffer:gt}=xn(),Ce=Symbol("kByteLength"),zf=Buffer.alloc(4),fr=8*1024,ht,Gt=fr,Re=0,Ff=1,Uf=2,Ei=class n{constructor(e,s,o){this._extensions=s||{},o&&(this._generateMask=o,this._maskBuffer=Buffer.alloc(4)),this._socket=e,this._firstFragment=!0,this._compress=!1,this._bufferedBytes=0,this._queue=[],this._state=Re,this.onerror=Mf,this[Lf]=void 0}static frame(e,s){let o,c=!1,d=2,u=!1;s.mask&&(o=s.maskBuffer||zf,s.generateMask?s.generateMask(o):(Gt===fr&&(ht===void 0&&(ht=Buffer.alloc(fr)),Nf(ht,0,fr),Gt=0),o[0]=ht[Gt++],o[1]=ht[Gt++],o[2]=ht[Gt++],o[3]=ht[Gt++]),u=(o[0]|o[1]|o[2]|o[3])===0,d=6);let f;typeof e=="string"?(!s.mask||u)&&s[Ce]!==void 0?f=s[Ce]:(e=Buffer.from(e),f=e.length):(f=e.length,c=s.mask&&s.readOnly&&!u);let h=f;f>=65536?(d+=8,h=127):f>125&&(d+=2,h=126);let p=Buffer.allocUnsafe(c?f+d:d);return p[0]=s.fin?s.opcode|128:s.opcode,s.rsv1&&(p[0]|=64),p[1]=h,h===126?p.writeUInt16BE(f,2):h===127&&(p[2]=p[3]=0,p.writeUIntBE(f,4,6)),s.mask?(p[1]|=128,p[d-4]=o[0],p[d-3]=o[1],p[d-2]=o[2],p[d-1]=o[3],u?[p,e]:c?(Ea(e,o,p,d,f),[p]):(Ea(e,o,e,0,f),[p,e])):[p,e]}close(e,s,o,c){let d;if(e===void 0)d=Of;else{if(typeof e!="number"||!Bf(e))throw new TypeError("First argument must be a valid error code number");if(s===void 0||!s.length)d=Buffer.allocUnsafe(2),d.writeUInt16BE(e,0);else{let f=Buffer.byteLength(s);if(f>123)throw new RangeError("The message must not be greater than 123 bytes");d=Buffer.allocUnsafe(2+f),d.writeUInt16BE(e,0),typeof s=="string"?d.write(s,2):d.set(s,2)}}let u={[Ce]:d.length,fin:!0,generateMask:this._generateMask,mask:o,maskBuffer:this._maskBuffer,opcode:8,readOnly:!1,rsv1:!1};this._state!==Re?this.enqueue([this.dispatch,d,!1,u,c]):this.sendFrame(n.frame(d,u),c)}ping(e,s,o){let c,d;if(typeof e=="string"?(c=Buffer.byteLength(e),d=!1):qt(e)?(c=e.size,d=!1):(e=gt(e),c=e.length,d=gt.readOnly),c>125)throw new RangeError("The data size must not be greater than 125 bytes");let u={[Ce]:c,fin:!0,generateMask:this._generateMask,mask:s,maskBuffer:this._maskBuffer,opcode:9,readOnly:d,rsv1:!1};qt(e)?this._state!==Re?this.enqueue([this.getBlobData,e,!1,u,o]):this.getBlobData(e,!1,u,o):this._state!==Re?this.enqueue([this.dispatch,e,!1,u,o]):this.sendFrame(n.frame(e,u),o)}pong(e,s,o){let c,d;if(typeof e=="string"?(c=Buffer.byteLength(e),d=!1):qt(e)?(c=e.size,d=!1):(e=gt(e),c=e.length,d=gt.readOnly),c>125)throw new RangeError("The data size must not be greater than 125 bytes");let u={[Ce]:c,fin:!0,generateMask:this._generateMask,mask:s,maskBuffer:this._maskBuffer,opcode:10,readOnly:d,rsv1:!1};qt(e)?this._state!==Re?this.enqueue([this.getBlobData,e,!1,u,o]):this.getBlobData(e,!1,u,o):this._state!==Re?this.enqueue([this.dispatch,e,!1,u,o]):this.sendFrame(n.frame(e,u),o)}send(e,s,o){let c=this._extensions[Sa.extensionName],d=s.binary?2:1,u=s.compress,f,h;typeof e=="string"?(f=Buffer.byteLength(e),h=!1):qt(e)?(f=e.size,h=!1):(e=gt(e),f=e.length,h=gt.readOnly),this._firstFragment?(this._firstFragment=!1,u&&c&&c.params[c._isServer?"server_no_context_takeover":"client_no_context_takeover"]&&(u=f>=c._threshold),this._compress=u):(u=!1,d=0),s.fin&&(this._firstFragment=!0);let p={[Ce]:f,fin:s.fin,generateMask:this._generateMask,mask:s.mask,maskBuffer:this._maskBuffer,opcode:d,readOnly:h,rsv1:u};qt(e)?this._state!==Re?this.enqueue([this.getBlobData,e,this._compress,p,o]):this.getBlobData(e,this._compress,p,o):this._state!==Re?this.enqueue([this.dispatch,e,this._compress,p,o]):this.dispatch(e,this._compress,p,o)}getBlobData(e,s,o,c){this._bufferedBytes+=o[Ce],this._state=Uf,e.arrayBuffer().then(d=>{if(this._socket.destroyed){let f=new Error("The socket was closed while the blob was being read");process.nextTick(Ii,this,f,c);return}this._bufferedBytes-=o[Ce];let u=gt(d);s?this.dispatch(u,s,o,c):(this._state=Re,this.sendFrame(n.frame(u,o),c),this.dequeue())}).catch(d=>{process.nextTick(qf,this,d,c)})}dispatch(e,s,o,c){if(!s){this.sendFrame(n.frame(e,o),c);return}let d=this._extensions[Sa.extensionName];this._bufferedBytes+=o[Ce],this._state=Ff,d.compress(e,o.fin,(u,f)=>{if(this._socket.destroyed){let h=new Error("The socket was closed while data was being compressed");Ii(this,h,c);return}this._bufferedBytes-=o[Ce],this._state=Re,o.readOnly=!1,this.sendFrame(n.frame(f,o),c),this.dequeue()})}dequeue(){for(;this._state===Re&&this._queue.length;){let e=this._queue.shift();this._bufferedBytes-=e[3][Ce],Reflect.apply(e[0],this,e.slice(1))}}enqueue(e){this._bufferedBytes+=e[3][Ce],this._queue.push(e)}sendFrame(e,s){e.length===2?(this._socket.cork(),this._socket.write(e[0]),this._socket.write(e[1],s),this._socket.uncork()):this._socket.write(e[0],s)}};Ia.exports=Ei;function Ii(n,e,s){typeof s=="function"&&s(e);for(let o=0;o<n._queue.length;o++){let c=n._queue[o],d=c[c.length-1];typeof d=="function"&&d(e)}}function qf(n,e,s){Ii(n,e,s),n.onerror(e)}});var Oa=be((S_,Na)=>{"use strict";var{kForOnEventAttribute:fn,kListener:Ti}=Ve(),Aa=Symbol("kCode"),Ta=Symbol("kData"),Pa=Symbol("kError"),Ca=Symbol("kMessage"),ka=Symbol("kReason"),Ht=Symbol("kTarget"),Da=Symbol("kType"),Ra=Symbol("kWasClean"),Xe=class{constructor(e){this[Ht]=null,this[Da]=e}get target(){return this[Ht]}get type(){return this[Da]}};Object.defineProperty(Xe.prototype,"target",{enumerable:!0});Object.defineProperty(Xe.prototype,"type",{enumerable:!0});var pt=class extends Xe{constructor(e,s={}){super(e),this[Aa]=s.code===void 0?0:s.code,this[ka]=s.reason===void 0?"":s.reason,this[Ra]=s.wasClean===void 0?!1:s.wasClean}get code(){return this[Aa]}get reason(){return this[ka]}get wasClean(){return this[Ra]}};Object.defineProperty(pt.prototype,"code",{enumerable:!0});Object.defineProperty(pt.prototype,"reason",{enumerable:!0});Object.defineProperty(pt.prototype,"wasClean",{enumerable:!0});var jt=class extends Xe{constructor(e,s={}){super(e),this[Pa]=s.error===void 0?null:s.error,this[Ca]=s.message===void 0?"":s.message}get error(){return this[Pa]}get message(){return this[Ca]}};Object.defineProperty(jt.prototype,"error",{enumerable:!0});Object.defineProperty(jt.prototype,"message",{enumerable:!0});var ln=class extends Xe{constructor(e,s={}){super(e),this[Ta]=s.data===void 0?null:s.data}get data(){return this[Ta]}};Object.defineProperty(ln.prototype,"data",{enumerable:!0});var Gf={addEventListener(n,e,s={}){for(let c of this.listeners(n))if(!s[fn]&&c[Ti]===e&&!c[fn])return;let o;if(n==="message")o=function(d,u){let f=new ln("message",{data:u?d:d.toString()});f[Ht]=this,lr(e,this,f)};else if(n==="close")o=function(d,u){let f=new pt("close",{code:d,reason:u.toString(),wasClean:this._closeFrameReceived&&this._closeFrameSent});f[Ht]=this,lr(e,this,f)};else if(n==="error")o=function(d){let u=new jt("error",{error:d,message:d.message});u[Ht]=this,lr(e,this,u)};else if(n==="open")o=function(){let d=new Xe("open");d[Ht]=this,lr(e,this,d)};else return;o[fn]=!!s[fn],o[Ti]=e,s.once?this.once(n,o):this.on(n,o)},removeEventListener(n,e){for(let s of this.listeners(n))if(s[Ti]===e&&!s[fn]){this.removeListener(n,s);break}}};Na.exports={CloseEvent:pt,ErrorEvent:jt,Event:Xe,EventTarget:Gf,MessageEvent:ln};function lr(n,e,s){typeof n=="object"&&n.handleEvent?n.handleEvent.call(n,s):n.call(e,s)}});var gr=be((E_,La)=>{"use strict";var{tokenChars:gn}=Ut();function He(n,e,s){n[e]===void 0?n[e]=[s]:n[e].push(s)}function Hf(n){let e=Object.create(null),s=Object.create(null),o=!1,c=!1,d=!1,u,f,h=-1,p=-1,w=-1,b=0;for(;b<n.length;b++)if(p=n.charCodeAt(b),u===void 0)if(w===-1&&gn[p]===1)h===-1&&(h=b);else if(b!==0&&(p===32||p===9))w===-1&&h!==-1&&(w=b);else if(p===59||p===44){if(h===-1)throw new SyntaxError(`Unexpected character at index ${b}`);w===-1&&(w=b);let I=n.slice(h,w);p===44?(He(e,I,s),s=Object.create(null)):u=I,h=w=-1}else throw new SyntaxError(`Unexpected character at index ${b}`);else if(f===void 0)if(w===-1&&gn[p]===1)h===-1&&(h=b);else if(p===32||p===9)w===-1&&h!==-1&&(w=b);else if(p===59||p===44){if(h===-1)throw new SyntaxError(`Unexpected character at index ${b}`);w===-1&&(w=b),He(s,n.slice(h,w),!0),p===44&&(He(e,u,s),s=Object.create(null),u=void 0),h=w=-1}else if(p===61&&h!==-1&&w===-1)f=n.slice(h,b),h=w=-1;else throw new SyntaxError(`Unexpected character at index ${b}`);else if(c){if(gn[p]!==1)throw new SyntaxError(`Unexpected character at index ${b}`);h===-1?h=b:o||(o=!0),c=!1}else if(d)if(gn[p]===1)h===-1&&(h=b);else if(p===34&&h!==-1)d=!1,w=b;else if(p===92)c=!0;else throw new SyntaxError(`Unexpected character at index ${b}`);else if(p===34&&n.charCodeAt(b-1)===61)d=!0;else if(w===-1&&gn[p]===1)h===-1&&(h=b);else if(h!==-1&&(p===32||p===9))w===-1&&(w=b);else if(p===59||p===44){if(h===-1)throw new SyntaxError(`Unexpected character at index ${b}`);w===-1&&(w=b);let I=n.slice(h,w);o&&(I=I.replace(/\\/g,""),o=!1),He(s,f,I),p===44&&(He(e,u,s),s=Object.create(null),u=void 0),f=void 0,h=w=-1}else throw new SyntaxError(`Unexpected character at index ${b}`);if(h===-1||d||p===32||p===9)throw new SyntaxError("Unexpected end of input");w===-1&&(w=b);let E=n.slice(h,w);return u===void 0?He(e,E,s):(f===void 0?He(s,E,!0):o?He(s,f,E.replace(/\\/g,"")):He(s,f,E),He(e,u,s)),e}function jf(n){return Object.keys(n).map(e=>{let s=n[e];return Array.isArray(s)||(s=[s]),s.map(o=>[e].concat(Object.keys(o).map(c=>{let d=o[c];return Array.isArray(d)||(d=[d]),d.map(u=>u===!0?c:`${c}=${u}`).join("; ")})).join("; ")).join(", ")}).join(", ")}La.exports={format:jf,parse:Hf}});var wr=be((T_,Ja)=>{"use strict";var Kf=ee("events"),Wf=ee("https"),Jf=ee("http"),za=ee("net"),$f=ee("tls"),{randomBytes:Vf,createHash:Yf}=ee("crypto"),{Duplex:I_,Readable:A_}=ee("stream"),{URL:Pi}=ee("url"),xt=Ft(),Xf=Si(),Qf=Ai(),{isBlob:Zf}=Ut(),{BINARY_TYPES:Ma,CLOSE_TIMEOUT:el,EMPTY_BUFFER:hr,GUID:tl,kForOnEventAttribute:Ci,kListener:nl,kStatusCode:rl,kWebSocket:de,NOOP:Fa}=Ve(),{EventTarget:{addEventListener:il,removeEventListener:sl}}=Oa(),{format:ol,parse:al}=gr(),{toBuffer:cl}=xn(),Ua=Symbol("kAborted"),ki=[8,13],Qe=["CONNECTING","OPEN","CLOSING","CLOSED"],dl=/^[!#$%&'*+\-.0-9A-Z^_`|a-z~]+$/,$=class n extends Kf{constructor(e,s,o){super(),this._binaryType=Ma[0],this._closeCode=1006,this._closeFrameReceived=!1,this._closeFrameSent=!1,this._closeMessage=hr,this._closeTimer=null,this._errorEmitted=!1,this._extensions={},this._paused=!1,this._protocol="",this._readyState=n.CONNECTING,this._receiver=null,this._sender=null,this._socket=null,e!==null?(this._bufferedAmount=0,this._isServer=!1,this._redirects=0,s===void 0?s=[]:Array.isArray(s)||(typeof s=="object"&&s!==null?(o=s,s=[]):s=[s]),qa(this,e,s,o)):(this._autoPong=o.autoPong,this._closeTimeout=o.closeTimeout,this._isServer=!0)}get binaryType(){return this._binaryType}set binaryType(e){Ma.includes(e)&&(this._binaryType=e,this._receiver&&(this._receiver._binaryType=e))}get bufferedAmount(){return this._socket?this._socket._writableState.length+this._sender._bufferedBytes:this._bufferedAmount}get extensions(){return Object.keys(this._extensions).join()}get isPaused(){return this._paused}get onclose(){return null}get onerror(){return null}get onopen(){return null}get onmessage(){return null}get protocol(){return this._protocol}get readyState(){return this._readyState}get url(){return this._url}setSocket(e,s,o){let c=new Xf({allowSynchronousEvents:o.allowSynchronousEvents,binaryType:this.binaryType,extensions:this._extensions,isServer:this._isServer,maxPayload:o.maxPayload,skipUTF8Validation:o.skipUTF8Validation}),d=new Qf(e,this._extensions,o.generateMask);this._receiver=c,this._sender=d,this._socket=e,c[de]=this,d[de]=this,e[de]=this,c.on("conclude",fl),c.on("drain",ll),c.on("error",gl),c.on("message",hl),c.on("ping",pl),c.on("pong",ml),d.onerror=wl,e.setTimeout&&e.setTimeout(0),e.setNoDelay&&e.setNoDelay(),s.length>0&&e.unshift(s),e.on("close",ja),e.on("data",mr),e.on("end",Ka),e.on("error",Wa),this._readyState=n.OPEN,this.emit("open")}emitClose(){if(!this._socket){this._readyState=n.CLOSED,this.emit("close",this._closeCode,this._closeMessage);return}this._extensions[xt.extensionName]&&this._extensions[xt.extensionName].cleanup(),this._receiver.removeAllListeners(),this._readyState=n.CLOSED,this.emit("close",this._closeCode,this._closeMessage)}close(e,s){if(this.readyState!==n.CLOSED){if(this.readyState===n.CONNECTING){Ie(this,this._req,"WebSocket was closed before the connection was established");return}if(this.readyState===n.CLOSING){this._closeFrameSent&&(this._closeFrameReceived||this._receiver._writableState.errorEmitted)&&this._socket.end();return}this._readyState=n.CLOSING,this._sender.close(e,s,!this._isServer,o=>{o||(this._closeFrameSent=!0,(this._closeFrameReceived||this._receiver._writableState.errorEmitted)&&this._socket.end())}),Ha(this)}}pause(){this.readyState===n.CONNECTING||this.readyState===n.CLOSED||(this._paused=!0,this._socket.pause())}ping(e,s,o){if(this.readyState===n.CONNECTING)throw new Error("WebSocket is not open: readyState 0 (CONNECTING)");if(typeof e=="function"?(o=e,e=s=void 0):typeof s=="function"&&(o=s,s=void 0),typeof e=="number"&&(e=e.toString()),this.readyState!==n.OPEN){Di(this,e,o);return}s===void 0&&(s=!this._isServer),this._sender.ping(e||hr,s,o)}pong(e,s,o){if(this.readyState===n.CONNECTING)throw new Error("WebSocket is not open: readyState 0 (CONNECTING)");if(typeof e=="function"?(o=e,e=s=void 0):typeof s=="function"&&(o=s,s=void 0),typeof e=="number"&&(e=e.toString()),this.readyState!==n.OPEN){Di(this,e,o);return}s===void 0&&(s=!this._isServer),this._sender.pong(e||hr,s,o)}resume(){this.readyState===n.CONNECTING||this.readyState===n.CLOSED||(this._paused=!1,this._receiver._writableState.needDrain||this._socket.resume())}send(e,s,o){if(this.readyState===n.CONNECTING)throw new Error("WebSocket is not open: readyState 0 (CONNECTING)");if(typeof s=="function"&&(o=s,s={}),typeof e=="number"&&(e=e.toString()),this.readyState!==n.OPEN){Di(this,e,o);return}let c={binary:typeof e!="string",mask:!this._isServer,compress:!0,fin:!0,...s};this._extensions[xt.extensionName]||(c.compress=!1),this._sender.send(e||hr,c,o)}terminate(){if(this.readyState!==n.CLOSED){if(this.readyState===n.CONNECTING){Ie(this,this._req,"WebSocket was closed before the connection was established");return}this._socket&&(this._readyState=n.CLOSING,this._socket.destroy())}}};Object.defineProperty($,"CONNECTING",{enumerable:!0,value:Qe.indexOf("CONNECTING")});Object.defineProperty($.prototype,"CONNECTING",{enumerable:!0,value:Qe.indexOf("CONNECTING")});Object.defineProperty($,"OPEN",{enumerable:!0,value:Qe.indexOf("OPEN")});Object.defineProperty($.prototype,"OPEN",{enumerable:!0,value:Qe.indexOf("OPEN")});Object.defineProperty($,"CLOSING",{enumerable:!0,value:Qe.indexOf("CLOSING")});Object.defineProperty($.prototype,"CLOSING",{enumerable:!0,value:Qe.indexOf("CLOSING")});Object.defineProperty($,"CLOSED",{enumerable:!0,value:Qe.indexOf("CLOSED")});Object.defineProperty($.prototype,"CLOSED",{enumerable:!0,value:Qe.indexOf("CLOSED")});["binaryType","bufferedAmount","extensions","isPaused","protocol","readyState","url"].forEach(n=>{Object.defineProperty($.prototype,n,{enumerable:!0})});["open","error","close","message"].forEach(n=>{Object.defineProperty($.prototype,`on${n}`,{enumerable:!0,get(){for(let e of this.listeners(n))if(e[Ci])return e[nl];return null},set(e){for(let s of this.listeners(n))if(s[Ci]){this.removeListener(n,s);break}typeof e=="function"&&this.addEventListener(n,e,{[Ci]:!0})}})});$.prototype.addEventListener=il;$.prototype.removeEventListener=sl;Ja.exports=$;function qa(n,e,s,o){let c={allowSynchronousEvents:!0,autoPong:!0,closeTimeout:el,protocolVersion:ki[1],maxPayload:104857600,skipUTF8Validation:!1,perMessageDeflate:!0,followRedirects:!1,maxRedirects:10,...o,socketPath:void 0,hostname:void 0,protocol:void 0,timeout:void 0,method:"GET",host:void 0,path:void 0,port:void 0};if(n._autoPong=c.autoPong,n._closeTimeout=c.closeTimeout,!ki.includes(c.protocolVersion))throw new RangeError(`Unsupported protocol version: ${c.protocolVersion} (supported versions: ${ki.join(", ")})`);let d;if(e instanceof Pi)d=e;else try{d=new Pi(e)}catch{throw new SyntaxError(`Invalid URL: ${e}`)}d.protocol==="http:"?d.protocol="ws:":d.protocol==="https:"&&(d.protocol="wss:"),n._url=d.href;let u=d.protocol==="wss:",f=d.protocol==="ws+unix:",h;if(d.protocol!=="ws:"&&!u&&!f?h=`The URL's protocol must be one of "ws:", "wss:", "http:", "https:", or "ws+unix:"`:f&&!d.pathname?h="The URL's pathname is empty":d.hash&&(h="The URL contains a fragment identifier"),h){let k=new SyntaxError(h);if(n._redirects===0)throw k;pr(n,k);return}let p=u?443:80,w=Vf(16).toString("base64"),b=u?Wf.request:Jf.request,E=new Set,I;if(c.createConnection=c.createConnection||(u?ul:xl),c.defaultPort=c.defaultPort||p,c.port=d.port||p,c.host=d.hostname.startsWith("[")?d.hostname.slice(1,-1):d.hostname,c.headers={...c.headers,"Sec-WebSocket-Version":c.protocolVersion,"Sec-WebSocket-Key":w,Connection:"Upgrade",Upgrade:"websocket"},c.path=d.pathname+d.search,c.timeout=c.handshakeTimeout,c.perMessageDeflate&&(I=new xt({...c.perMessageDeflate,isServer:!1,maxPayload:c.maxPayload}),c.headers["Sec-WebSocket-Extensions"]=ol({[xt.extensionName]:I.offer()})),s.length){for(let k of s){if(typeof k!="string"||!dl.test(k)||E.has(k))throw new SyntaxError("An invalid or duplicated subprotocol was specified");E.add(k)}c.headers["Sec-WebSocket-Protocol"]=s.join(",")}if(c.origin&&(c.protocolVersion<13?c.headers["Sec-WebSocket-Origin"]=c.origin:c.headers.Origin=c.origin),(d.username||d.password)&&(c.auth=`${d.username}:${d.password}`),f){let k=c.path.split(":");c.socketPath=k[0],c.path=k[1]}let A;if(c.followRedirects){if(n._redirects===0){n._originalIpc=f,n._originalSecure=u,n._originalHostOrSocketPath=f?c.socketPath:d.host;let k=o&&o.headers;if(o={...o,headers:{}},k)for(let[z,Y]of Object.entries(k))o.headers[z.toLowerCase()]=Y}else if(n.listenerCount("redirect")===0){let k=f?n._originalIpc?c.socketPath===n._originalHostOrSocketPath:!1:n._originalIpc?!1:d.host===n._originalHostOrSocketPath;(!k||n._originalSecure&&!u)&&(delete c.headers.authorization,delete c.headers.cookie,k||delete c.headers.host,c.auth=void 0)}c.auth&&!o.headers.authorization&&(o.headers.authorization="Basic "+Buffer.from(c.auth).toString("base64")),A=n._req=b(c),n._redirects&&n.emit("redirect",n.url,A)}else A=n._req=b(c);c.timeout&&A.on("timeout",()=>{Ie(n,A,"Opening handshake has timed out")}),A.on("error",k=>{A===null||A[Ua]||(A=n._req=null,pr(n,k))}),A.on("response",k=>{let z=k.headers.location,Y=k.statusCode;if(z&&c.followRedirects&&Y>=300&&Y<400){if(++n._redirects>c.maxRedirects){Ie(n,A,"Maximum redirects exceeded");return}A.abort();let j;try{j=new Pi(z,e)}catch{let W=new SyntaxError(`Invalid URL: ${z}`);pr(n,W);return}qa(n,j,s,o)}else n.emit("unexpected-response",A,k)||Ie(n,A,`Unexpected server response: ${k.statusCode}`)}),A.on("upgrade",(k,z,Y)=>{if(n.emit("upgrade",k),n.readyState!==$.CONNECTING)return;A=n._req=null;let j=k.headers.upgrade;if(j===void 0||j.toLowerCase()!=="websocket"){Ie(n,z,"Invalid Upgrade header");return}let oe=Yf("sha1").update(w+tl).digest("base64");if(k.headers["sec-websocket-accept"]!==oe){Ie(n,z,"Invalid Sec-WebSocket-Accept header");return}let W=k.headers["sec-websocket-protocol"],le;if(W!==void 0?E.size?E.has(W)||(le="Server sent an invalid subprotocol"):le="Server sent a subprotocol but none was requested":E.size&&(le="Server sent no subprotocol"),le){Ie(n,z,le);return}W&&(n._protocol=W);let _e=k.headers["sec-websocket-extensions"];if(_e!==void 0){if(!I){Ie(n,z,"Server sent a Sec-WebSocket-Extensions header but no extension was requested");return}let ke;try{ke=al(_e)}catch{Ie(n,z,"Invalid Sec-WebSocket-Extensions header");return}let xe=Object.keys(ke);if(xe.length!==1||xe[0]!==xt.extensionName){Ie(n,z,"Server indicated an extension that was not requested");return}try{I.accept(ke[xt.extensionName])}catch{Ie(n,z,"Invalid Sec-WebSocket-Extensions header");return}n._extensions[xt.extensionName]=I}n.setSocket(z,Y,{allowSynchronousEvents:c.allowSynchronousEvents,generateMask:c.generateMask,maxPayload:c.maxPayload,skipUTF8Validation:c.skipUTF8Validation})}),c.finishRequest?c.finishRequest(A,n):A.end()}function pr(n,e){n._readyState=$.CLOSING,n._errorEmitted=!0,n.emit("error",e),n.emitClose()}function xl(n){return n.path=n.socketPath,za.connect(n)}function ul(n){return n.path=void 0,!n.servername&&n.servername!==""&&(n.servername=za.isIP(n.host)?"":n.host),$f.connect(n)}function Ie(n,e,s){n._readyState=$.CLOSING;let o=new Error(s);Error.captureStackTrace(o,Ie),e.setHeader?(e[Ua]=!0,e.abort(),e.socket&&!e.socket.destroyed&&e.socket.destroy(),process.nextTick(pr,n,o)):(e.destroy(o),e.once("error",n.emit.bind(n,"error")),e.once("close",n.emitClose.bind(n)))}function Di(n,e,s){if(e){let o=Zf(e)?e.size:cl(e).length;n._socket?n._sender._bufferedBytes+=o:n._bufferedAmount+=o}if(s){let o=new Error(`WebSocket is not open: readyState ${n.readyState} (${Qe[n.readyState]})`);process.nextTick(s,o)}}function fl(n,e){let s=this[de];s._closeFrameReceived=!0,s._closeMessage=e,s._closeCode=n,s._socket[de]!==void 0&&(s._socket.removeListener("data",mr),process.nextTick(Ga,s._socket),n===1005?s.close():s.close(n,e))}function ll(){let n=this[de];n.isPaused||n._socket.resume()}function gl(n){let e=this[de];e._socket[de]!==void 0&&(e._socket.removeListener("data",mr),process.nextTick(Ga,e._socket),e.close(n[rl])),e._errorEmitted||(e._errorEmitted=!0,e.emit("error",n))}function Ba(){this[de].emitClose()}function hl(n,e){this[de].emit("message",n,e)}function pl(n){let e=this[de];e._autoPong&&e.pong(n,!this._isServer,Fa),e.emit("ping",n)}function ml(n){this[de].emit("pong",n)}function Ga(n){n.resume()}function wl(n){let e=this[de];e.readyState!==$.CLOSED&&(e.readyState===$.OPEN&&(e._readyState=$.CLOSING,Ha(e)),this._socket.end(),e._errorEmitted||(e._errorEmitted=!0,e.emit("error",n)))}function Ha(n){n._closeTimer=setTimeout(n._socket.destroy.bind(n._socket),n._closeTimeout)}function ja(){let n=this[de];if(this.removeListener("close",ja),this.removeListener("data",mr),this.removeListener("end",Ka),n._readyState=$.CLOSING,!this._readableState.endEmitted&&!n._closeFrameReceived&&!n._receiver._writableState.errorEmitted&&this._readableState.length!==0){let e=this.read(this._readableState.length);n._receiver.write(e)}n._receiver.end(),this[de]=void 0,clearTimeout(n._closeTimer),n._receiver._writableState.finished||n._receiver._writableState.errorEmitted?n.emitClose():(n._receiver.on("error",Ba),n._receiver.on("finish",Ba))}function mr(n){this[de]._receiver.write(n)||this.pause()}function Ka(){let n=this[de];n._readyState=$.CLOSING,n._receiver.end(),this.end()}function Wa(){let n=this[de];this.removeListener("error",Wa),this.on("error",Fa),n&&(n._readyState=$.CLOSING,this.destroy())}});var Xa=be((C_,Ya)=>{"use strict";var P_=wr(),{Duplex:_l}=ee("stream");function $a(n){n.emit("close")}function yl(){!this.destroyed&&this._writableState.finished&&this.destroy()}function Va(n){this.removeListener("error",Va),this.destroy(),this.listenerCount("error")===0&&this.emit("error",n)}function bl(n,e){let s=!0,o=new _l({...e,autoDestroy:!1,emitClose:!1,objectMode:!1,writableObjectMode:!1});return n.on("message",function(d,u){let f=!u&&o._readableState.objectMode?d.toString():d;o.push(f)||n.pause()}),n.once("error",function(d){o.destroyed||(s=!1,o.destroy(d))}),n.once("close",function(){o.destroyed||o.push(null)}),o._destroy=function(c,d){if(n.readyState===n.CLOSED){d(c),process.nextTick($a,o);return}let u=!1;n.once("error",function(h){u=!0,d(h)}),n.once("close",function(){u||d(c),process.nextTick($a,o)}),s&&n.terminate()},o._final=function(c){if(n.readyState===n.CONNECTING){n.once("open",function(){o._final(c)});return}n._socket!==null&&(n._socket._writableState.finished?(c(),o._readableState.endEmitted&&o.destroy()):(n._socket.once("finish",function(){c()}),n.close()))},o._read=function(){n.isPaused&&n.resume()},o._write=function(c,d,u){if(n.readyState===n.CONNECTING){n.once("open",function(){o._write(c,d,u)});return}n.send(c,u)},o.on("end",yl),o.on("error",Va),o}Ya.exports=bl});var Ri=be((k_,Qa)=>{"use strict";var{tokenChars:vl}=Ut();function Sl(n){let e=new Set,s=-1,o=-1,c=0;for(c;c<n.length;c++){let u=n.charCodeAt(c);if(o===-1&&vl[u]===1)s===-1&&(s=c);else if(c!==0&&(u===32||u===9))o===-1&&s!==-1&&(o=c);else if(u===44){if(s===-1)throw new SyntaxError(`Unexpected character at index ${c}`);o===-1&&(o=c);let f=n.slice(s,o);if(e.has(f))throw new SyntaxError(`The "${f}" subprotocol is duplicated`);e.add(f),s=o=-1}else throw new SyntaxError(`Unexpected character at index ${c}`)}if(s===-1||o!==-1)throw new SyntaxError("Unexpected end of input");let d=n.slice(s,c);if(e.has(d))throw new SyntaxError(`The "${d}" subprotocol is duplicated`);return e.add(d),e}Qa.exports={parse:Sl}});var sc=be((R_,ic)=>{"use strict";var El=ee("events"),_r=ee("http"),{Duplex:D_}=ee("stream"),{createHash:Il}=ee("crypto"),Za=gr(),mt=Ft(),Al=Ri(),Tl=wr(),{CLOSE_TIMEOUT:Pl,GUID:Cl,kWebSocket:kl}=Ve(),Dl=/^[+/0-9A-Za-z]{22}==$/,ec=0,tc=1,rc=2,Ni=class extends El{constructor(e,s){if(super(),e={allowSynchronousEvents:!0,autoPong:!0,maxPayload:100*1024*1024,skipUTF8Validation:!1,perMessageDeflate:!1,handleProtocols:null,clientTracking:!0,closeTimeout:Pl,verifyClient:null,noServer:!1,backlog:null,server:null,host:null,path:null,port:null,WebSocket:Tl,...e},e.port==null&&!e.server&&!e.noServer||e.port!=null&&(e.server||e.noServer)||e.server&&e.noServer)throw new TypeError('One and only one of the "port", "server", or "noServer" options must be specified');if(e.port!=null?(this._server=_r.createServer((o,c)=>{let d=_r.STATUS_CODES[426];c.writeHead(426,{"Content-Length":d.length,"Content-Type":"text/plain"}),c.end(d)}),this._server.listen(e.port,e.host,e.backlog,s)):e.server&&(this._server=e.server),this._server){let o=this.emit.bind(this,"connection");this._removeListeners=Rl(this._server,{listening:this.emit.bind(this,"listening"),error:this.emit.bind(this,"error"),upgrade:(c,d,u)=>{this.handleUpgrade(c,d,u,o)}})}e.perMessageDeflate===!0&&(e.perMessageDeflate={}),e.clientTracking&&(this.clients=new Set,this._shouldEmitClose=!1),this.options=e,this._state=ec}address(){if(this.options.noServer)throw new Error('The server is operating in "noServer" mode');return this._server?this._server.address():null}close(e){if(this._state===rc){e&&this.once("close",()=>{e(new Error("The server is not running"))}),process.nextTick(hn,this);return}if(e&&this.once("close",e),this._state!==tc)if(this._state=tc,this.options.noServer||this.options.server)this._server&&(this._removeListeners(),this._removeListeners=this._server=null),this.clients?this.clients.size?this._shouldEmitClose=!0:process.nextTick(hn,this):process.nextTick(hn,this);else{let s=this._server;this._removeListeners(),this._removeListeners=this._server=null,s.close(()=>{hn(this)})}}shouldHandle(e){if(this.options.path){let s=e.url.indexOf("?");if((s!==-1?e.url.slice(0,s):e.url)!==this.options.path)return!1}return!0}handleUpgrade(e,s,o,c){s.on("error",nc);let d=e.headers["sec-websocket-key"],u=e.headers.upgrade,f=+e.headers["sec-websocket-version"];if(e.method!=="GET"){wt(this,e,s,405,"Invalid HTTP method");return}if(u===void 0||u.toLowerCase()!=="websocket"){wt(this,e,s,400,"Invalid Upgrade header");return}if(d===void 0||!Dl.test(d)){wt(this,e,s,400,"Missing or invalid Sec-WebSocket-Key header");return}if(f!==13&&f!==8){wt(this,e,s,400,"Missing or invalid Sec-WebSocket-Version header",{"Sec-WebSocket-Version":"13, 8"});return}if(!this.shouldHandle(e)){pn(s,400);return}let h=e.headers["sec-websocket-protocol"],p=new Set;if(h!==void 0)try{p=Al.parse(h)}catch{wt(this,e,s,400,"Invalid Sec-WebSocket-Protocol header");return}let w=e.headers["sec-websocket-extensions"],b={};if(this.options.perMessageDeflate&&w!==void 0){let E=new mt({...this.options.perMessageDeflate,isServer:!0,maxPayload:this.options.maxPayload});try{let I=Za.parse(w);I[mt.extensionName]&&(E.accept(I[mt.extensionName]),b[mt.extensionName]=E)}catch{wt(this,e,s,400,"Invalid or unacceptable Sec-WebSocket-Extensions header");return}}if(this.options.verifyClient){let E={origin:e.headers[`${f===8?"sec-websocket-origin":"origin"}`],secure:!!(e.socket.authorized||e.socket.encrypted),req:e};if(this.options.verifyClient.length===2){this.options.verifyClient(E,(I,A,k,z)=>{if(!I)return pn(s,A||401,k,z);this.completeUpgrade(b,d,p,e,s,o,c)});return}if(!this.options.verifyClient(E))return pn(s,401)}this.completeUpgrade(b,d,p,e,s,o,c)}completeUpgrade(e,s,o,c,d,u,f){if(!d.readable||!d.writable)return d.destroy();if(d[kl])throw new Error("server.handleUpgrade() was called more than once with the same socket, possibly due to a misconfiguration");if(this._state>ec)return pn(d,503);let p=["HTTP/1.1 101 Switching Protocols","Upgrade: websocket","Connection: Upgrade",`Sec-WebSocket-Accept: ${Il("sha1").update(s+Cl).digest("base64")}`],w=new this.options.WebSocket(null,void 0,this.options);if(o.size){let b=this.options.handleProtocols?this.options.handleProtocols(o,c):o.values().next().value;b&&(p.push(`Sec-WebSocket-Protocol: ${b}`),w._protocol=b)}if(e[mt.extensionName]){let b=e[mt.extensionName].params,E=Za.format({[mt.extensionName]:[b]});p.push(`Sec-WebSocket-Extensions: ${E}`),w._extensions=e}this.emit("headers",p,c),d.write(p.concat(`\r
8
+ var U0=Object.create;var jr=Object.defineProperty;var q0=Object.getOwnPropertyDescriptor;var G0=Object.getOwnPropertyNames;var H0=Object.getPrototypeOf,K0=Object.prototype.hasOwnProperty;var re=(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 Pe=(n,e)=>()=>(n&&(e=n(n=0)),e);var Se=(n,e)=>()=>(e||n((e={exports:{}}).exports,e),e.exports),$r=(n,e)=>{for(var s in e)jr(n,s,{get:e[s],enumerable:!0})},W0=(n,e,s,o)=>{if(e&&typeof e=="object"||typeof e=="function")for(let c of G0(e))!K0.call(n,c)&&c!==s&&jr(n,c,{get:()=>e[c],enumerable:!(o=q0(e,c))||o.enumerable});return n};var $e=(n,e,s)=>(s=n!=null?U0(H0(n)):{},W0(e||!n||!n.__esModule?jr(s,"default",{value:n,enumerable:!0}):s,n));function _s(n){return vn[ms]<=vn[n]}function Sn(n){ws={...n}}function bn(n,e,s,o){if(vn[n]<vn[ms])return;let c=JSON.stringify({ts:new Date().toISOString(),level:n,module:e,msg:s,...ws,...o});n==="error"||n==="warn"?$0.write(`${c}
9
+ `):j0.write(`${c}
10
+ `)}function R(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=>R(`${n}.${e}`)}}var vn,ms,j0,$0,ws,U=Pe(()=>{"use strict";vn={debug:10,info:20,warn:30,error:40},ms=(()=>{let n=process.env.COZE_BRIDGE_LOG_LEVEL;return n==="debug"||n==="info"||n==="warn"||n==="error"?n:"info"})(),j0=process.stdout,$0=process.stderr,ws={}});import{chmod as ax,mkdir as cx,readFile as xx,rename as Is,writeFile as As}from"node:fs/promises";import{dirname as dx}from"node:path";async function Tt(n){try{let e=await xx(n,"utf8");return JSON.parse(e)}catch(e){if(e.code==="ENOENT")return null;throw e}}async function Cn(n,e,s){await cx(dx(n),{recursive:!0});let o=`${JSON.stringify(e,null,2)}
11
+ `,c=`${n}.tmp-${process.pid}-${Math.random().toString(36).slice(2,10)}`;try{s?.mode!==void 0?await As(c,o,{encoding:"utf8",mode:s.mode}):await As(c,o,"utf8"),await Is(c,n),s?.mode!==void 0&&await ax(n,s.mode)}catch(x){await Is(c,c).catch(()=>{});let{rm:u}=await import("node:fs/promises");throw await u(c,{force:!0}).catch(()=>{}),x}}var Pn=Pe(()=>{"use strict"});import{promises as Cs}from"node:fs";import{homedir as ux}from"node:os";import{sep as fx,join as fe,resolve as Ps}from"node:path";function q(n){let e=n??ux(),s=fe(e,".coze"),o=fe(s,"bridge"),c=fe(o,"lib");return{cozeRoot:s,bridgeRoot:o,libDir:c,libEntry:fe(c,"index.js"),binDir:fe(o,"bin"),pidFile:fe(o,"bridge.pid"),portFile:fe(o,"bridge.port"),tokenFile:fe(o,"bridge.token"),patTokenFile:fe(o,"pat-token"),logFile:fe(o,"bridge.log"),installLock:fe(o,"install.lock"),configFile:fe(o,"config.json"),agentsRoot:fe(s,"agents")}}function Ve(n,e=q()){let s=fe(e.agentsRoot,n);return{root:s,config:fe(s,"config.json"),workspace:fe(s,"workspace"),logs:fe(s,"logs")}}async function Ts(n,e){let s=await Cs.realpath(Ps(n)).catch(()=>null);if(!s)return!1;let o=await Cs.realpath(Ps(e)).catch(()=>null);if(!o)return!1;let c=process.platform==="win32"?s.toLowerCase():s,x=process.platform==="win32"?o.toLowerCase():o;return c===x||c.startsWith(x+fx)}var ae=Pe(()=>{"use strict"});var Dn={};$r(Dn,{AGENT_CONFIG_FILE_MODE:()=>Tn,enforceAgentConfigMode:()=>hx,loadAgentConfig:()=>me,persistAgentSessions:()=>Vr,persistAgentSkills:()=>kn,saveAgentConfig:()=>Ee});import{chmod as lx,stat as gx}from"node:fs/promises";function me(n,e){return Tt(Ve(n,e).config)}function Ee(n,e){return Cn(Ve(n.agentId,e).config,n,{mode:Tn})}async function hx(n,e){if(process.platform==="win32")return;let s=Ve(n,e).config;try{let o=await gx(s);if(!o.isFile())return;let c=o.mode&511;c!==Tn&&(await lx(s,Tn),ks.warn("agent config mode auto-corrected to 0600",{path:s,from:c.toString(8)}))}catch(o){if(o.code==="ENOENT")return;ks.warn("enforceAgentConfigMode: chmod failed (ignored)",{path:s,err:String(o)})}}async function Vr(n,e,s){let o=await me(n,s);o&&(o.sessions=Object.fromEntries(e),await Ee(o,s))}async function kn(n,e,s){let o=await me(n,s);o&&(o.skills=e,await Ee(o,s))}var ks,Tn,st=Pe(()=>{"use strict";Pn();U();ae();ks=R("agent-config"),Tn=384});function Lo(n){let e=n?.sessionIdleTimeoutMs;return typeof e!="number"||!Number.isFinite(e)||e<=0?ru:e}function xt(n){return Tt(n??q().configFile)}function qe(n,e){return Cn(e??q().configFile,n)}var ru,zt=Pe(()=>{"use strict";Pn();ae();ru=10*6e4});var aa=Se(X=>{"use strict";var k=T;(function(n,e){let s=T,o=n();for(;;)try{if(-parseInt(s(1008))/1+parseInt(s(1293))/2+-parseInt(s(1784))/3*(-parseInt(s(1468))/4)+parseInt(s(849))/5+parseInt(s(388))/6+parseInt(s(1496))/7+-parseInt(s(996))/8*(parseInt(s(1591))/9)===e)break;o.push(o.shift())}catch{o.push(o.shift())}})(sr,889427);var nf=Object[k(551)+k(579)],rf=Object[k(1031)+"opertyNa"+k(954)],na=(n,e)=>function(){return n&&(e=(0,n[{FtvFY:function(c,x){return c(x)}}.FtvFY(rf,n)[0]])(n=0)),e},sf=(n,e)=>{let s=k,o={YxSKL:function(x,u,f,g){return x(u,f,g)}};for(var c in e)o[s(1136)](nf,n,c,{get:e[c],enumerable:!0})};function of(){return Zo||(Zo=[IDBDatabase,IDBObjectStore,IDBIndex,IDBCursor,IDBTransaction])}function af(){let n=k;return Xo||(Xo=[IDBCursor[n(544)+"e"].advance,IDBCursor[n(544)+"e"].continue,IDBCursor[n(544)+"e"][n(422)+"PrimaryKey"]])}function cf(n){let e=k,s={rJJpe:function(c,x){return c(x)},jtOlw:function(c){return c()},pCyqE:e(423),gUQhK:function(c){return c()},rLZMu:"error",sMWSs:function(c,x){return c<=x},IlXwg:function(c,x){return c<x},JpWqr:function(c,x){return c+x},WSRGW:function(c,x){return c-x},XmkTU:function(c,x){return c+x},grEEO:function(c,x){return c<<x},XOknJ:function(c,x){return c<x},EnUkk:function(c,x){return c!==x},VXqsZ:e(900),pKNCq:function(c,x){return c instanceof x}},o=new Promise((c,x)=>{let u=e,f={wLBZc:s[u(1290)],jApRE:u(1326),CmCLy:function(_,E){return s[u(1179)](_,E)},BNjBw:function(_){return s.gUQhK(_)}},g=()=>{let _=u;n[_(401)+_(1658)+_(651)](f.wLBZc,m),n[_(401)+_(1658)+"ner"](f[_(1736)],y)},m=()=>{let _=u;s[_(1179)](c,s[_(1179)](He,n[_(1872)])),s.jtOlw(g)},y=()=>{let _=u;f[_(920)](x,n[_(1326)]),f[_(1698)](g)};n[u(877)+"Listener"](s[u(1290)],m),n[u(877)+u(691)](s.rLZMu,y)});return o[e(364)](c=>{let x=e,u={NNELy:function(f,g){return f>=g},EZCsG:function(f,g){return s[T(716)](f,g)},rLHCH:function(f,g){return s[T(1078)](f,g)},ZDzLn:function(f,g){return s.JpWqr(f,g)},VSqDv:function(f,g){return s.WSRGW(f,g)},leLJZ:function(f,g){return s[T(1481)](f,g)},kxbgX:function(f,g){return s.grEEO(f,g)},afVWh:function(f,g){return s.XOknJ(f,g)}};if(s[x(1413)](s.VXqsZ,s[x(1235)])){let f=_0x14e093[x(1333)+"At"](_0x2763d9);u.NNELy(f,55296)&&u[x(431)](f,56319)&&u[x(876)](u.ZDzLn(_0x195af5,1),_0x33b1ca)&&(f=u[x(1761)](u[x(1442)](u.kxbgX(f,10),_0x452419.charCodeAt(++_0x191e22)),56613888)),_0x16a44f+=u.rLHCH(f,128)?1:u[x(961)](f,2048)?2:f<65536?3:4}else s[x(663)](c,IDBCursor)&&li[x(793)](c,n)})[e(357)](()=>{}),rr[e(793)](o,n),o}function xf(n){let e=k,s={GnYUw:function(c){return c()},tiNeP:function(c){return c()},NjDfq:e(808)+"or",FlDgj:"abort",vUlYa:e(1874),WDraJ:"error"};if(nr[e(396)](n))return;let o=new Promise((c,x)=>{let u=e,f={Swnxx:u(1874),BfyJY:s[u(1371)]},g=()=>{let _=u;n["removeEventListe"+_(651)](f.Swnxx,m),n["removeEv"+_(1658)+_(651)](_(1326),y),n[_(401)+_(1658)+_(651)](f[_(391)],y)},m=()=>{let _=u;s[_(1727)](c),s[_(951)](g)},y=()=>{let _=u;x(n.error||new DOMException(s[_(1517)],s[_(1517)])),s[_(1727)](g)};n[u(877)+u(691)](s[u(673)],m),n["addEvent"+u(691)](s.WDraJ,y),n[u(877)+u(691)](s.FlDgj,y)});nr[e(793)](n,o)}function df(n){ir=n(ir)}function uf(n){let e=k,s={aVvYs:function(o,c){return o(c)},XUtki:function(o,c){return o(c)},szfCU:function(o,c){return o(c)},gnfmC:function(o,c){return o(c)},rHDzQ:function(o,c){return o===c},Ritvq:e(1456)+e(1667),csHFB:function(o){return o()}};return s[e(1597)](n,IDBDatabase[e(544)+"e"][e(1197)+e(802)])&&!(s[e(1465)]in IDBTransaction.prototype)?function(o,...c){let x=e,u=n[x(392)](s[x(1359)](dn,this),o,...c);return fi[x(793)](u,o[x(1040)]?o.sort():[o]),s[x(1359)](He,u)}:s[e(1298)](af).includes(n)?function(...o){let c=e;return n.apply(s[c(827)](dn,this),o),s.szfCU(He,li.get(this))}:function(...o){let c=e;return s[c(710)](He,n[c(1262)](s[c(376)](dn,this),o))}}function ff(n){let e=k,s={XRkqa:function(o,c){return o===c},aOqnw:function(o,c){return o(c)},AofxV:function(o,c){return o instanceof c},gmidg:function(o,c,x){return o(c,x)},WrPNv:function(o){return o()}};return s[e(1703)](typeof n,e(580))?s[e(1403)](uf,n):(s[e(1797)](n,IDBTransaction)&&s.aOqnw(xf,n),s.gmidg(ra,n,s.WrPNv(of))?new Proxy(n,ir):n)}function He(n){let e=k,s={RLMsA:function(c,x){return c instanceof x},vpfqn:function(c,x){return c(x)},gSKuL:function(c,x){return c!==x}};if(s[e(1363)](n,IDBRequest))return s[e(1393)](cf,n);if(er[e(396)](n))return er[e(1612)](n);let o=ff(n);return s[e(1163)](o,n)&&(er[e(793)](n,o),rr.set(o,n)),o}var ra,Zo,Xo,li,nr,fi,er,rr,ir,dn,Qo=na({"node_modules/idb/build/wrap-idb-value.js"(){let n=k,e={OpNGi:n(1267),UscXi:"store",wmlPK:function(s,o){return s(o)},hWuDK:function(s,o){return s===o},RZgcx:function(s,o){return s===o},XMsYT:"objectSt"+n(1667),GNTym:function(s,o){return s!==o},NlFJA:n(1271),iHWEI:n(518),aCTMC:function(s,o){return s instanceof o},BUpMm:function(s,o){return s in o}};ra=(s,o)=>o.some(c=>s instanceof c),li=new WeakMap,nr=new WeakMap,fi=new WeakMap,er=new WeakMap,rr=new WeakMap,ir={get(s,o,c){let x=n,u={dTQlB:function(f,g){return f instanceof g},xAPCF:function(f,g){return f===g},agSdc:e[x(1495)],eqUZH:e[x(452)],JkTFM:function(f,g){return e.wmlPK(f,g)}};if(s instanceof IDBTransaction){if(e[x(1451)](o,e[x(1495)]))return nr[x(1612)](s);if(e[x(864)](o,e[x(1673)]))if(e[x(1617)](e[x(1805)],x(1271))){if(u.dTQlB(_0x21f4fb,_0x248635)){if(u.xAPCF(_0xd33027,u.agSdc))return _0x3f45fc.get(_0x4b129a);if(u[x(635)](_0x259fd3,x(1456)+x(1667)))return _0x5e4fbb[x(1456)+"oreNames"]||_0x341518[x(1612)](_0x270575);if(_0x3a9abf===u.eqUZH)return _0x4732d2[x(1456)+x(1667)][1]?void 0:_0x574492.objectStore(_0x23ab85.objectStoreNames[0])}return u.JkTFM(_0x1abae3,_0x3d3a8e[_0x14df79])}else return s["objectSt"+x(1667)]||fi[x(1612)](s);if(o===e[x(452)])return c[x(1456)+"oreNames"][1]?void 0:c[x(1456)+x(1549)](c["objectSt"+x(1667)][0])}return e[x(1053)](He,s[o])},set(s,o,c){let x=n;if(e[x(1451)](e[x(1428)],"IVQyp"))this._initPromise=null;else return s[o]=c,!0},has(s,o){let c=n;return e[c(526)](s,IDBTransaction)&&(o===c(1267)||e[c(864)](o,e.UscXi))?!0:e.BUpMm(o,s)}},dn=s=>rr[n(1612)](s)}}),ia={};function sr(){let n=["CMvHzhLtDge","twXMEha","teXiALG","x3bHDgHlzxK","BMv3vMvYC2K","ywLeBuy","DNfmCgq","vLnXrhy","yNHJC20","yu51yKO","BfPfsMG","ihrPBwvZ","Bwf4uMv0CMK","ChbL","Ec1TC2CTy3u","r3zkufO","C3PZEMS","zw5NDgG","twHmr24","BwLZzq","BMzzD2i","BfrPBwvVDxq","zfP2D0m","Bg9N","zvvYBa","rvjzue8","q2Tgzg8","qwzhv3i","zNDZxZeUmc4","rhLJugO","mJqXmdq0m0rzs1nXsq","re9LEwu","uwTttNq","ysbTDxn0igi","D0jbtw0","vgrwBNa","uMntqLm","vMLhDhm","sLnptLa","tM5lzey","B2XKvMvYC2K","DcbVzIbYyw4","CfPxtuq","qw9MEfy","ANHetNe","AuHPC1a","AwXLtMfTzq","vxn3sha","BgLTAxq","u3vmDeW","zw5HyMXLuw8","tMXgsKe","uLLxB1m","AxmGDw5Kzwy","wNjUDfa","qKT4s28","twLZC2LUzYa","ELvoC1y","CLLOzLK","qvDoq1q","lcbOB3n0BMe","z0P1C3C","qvDquhi","mhWY","CgfYC2u","wgPxtwy","A0P3teu","t2L2uvG","yxKSihrYEsa","y3jLyxrLrwW","t2PVzuG","seDvzhi","qwzYt2G","C3rVCMu","r0vyB0y","yuzbzMW","x2n1CNnVCK4","AxLRr0K","C1rnvui","yNLUwNq","CgLjy2W","ywzL","DK1sr0G","D2LkDgO","CwzMBMK","vLnfuum","zMLUza","yLDgy2W","s0f4D2e","rhv3vMm","CfLjvw8","BgLZDgvUtMu","CeHxqwi","q09oveLovuu","uwjIrLO","yM1pDu4","tKXvzMC","DKrsyKu","CMvZzxrdB3u","svLhwe8","ALHtvKu","vg54B1K","v3HPz3u","EuTIwgm","ufDjv3O","wfrOBxK","uMzJrwW","yKv0zgK","u2vrC3C","Efr6BKW","AgfUz2u","ruj4vxK","BMXnAgW","BLLVB2K","CgfNzwHPzgu","z2vY","AxrLt08","Ec11C2uT","CMvZDwX0","v0ruz1i","y29TCgXLDgu","BMDLza","DMrNsK4","yw51Ce1LC3m","CLvnq2W","tw9nuKq","wwj4zve","y2HLy2Tszwe","DvD1sKu","DenLr2G","rLDt","tK9VDgK","yvbczfe","y29UBMvJDa","q2Pct2G","y29Uy2f0","x2vUzhbVAw4","AxLNsLm","vMvovNO","z2vjBMzVu3K","t1z0qva","ywDL","B29PsNG","EunABeC","zxf1ywXZ","BwzYEhO","s0fmuMS","yLfiyMm","ENv4DhC","qvLmEhC","CMvHzfvjBNq","rgvKAwnHDgu","EujWz2m","r1blzhG","uhbWwvC","B25tDg9Wsw0","B3bLBG","BeLdzMq","EvjSChO","y2f0y2G","D1PhAvC","yMrFzgLK","BLnhCfu","thH0D2y","wgLoAhG","DMfS","DgHLBG","zw5XDwv1zq","zxHWB3j0CW","CMLLC0nVDw4","A2rku0S","zgv2AwnLx2K","yMHbrhi","x2LZsw5PDa","AhnmyNm","B2nRzxrtDwm","yxKSig5LDhC","wNfnru4","C3PMq1u","yK5tEui","Eg1bywC","DhLWzq","yw5Hz2vY","yNLL","zK5byNu","DLP3ze4","BMnLq2XVC2u","uhzXvfu","AgvHzgvYCW","B2zM","mJq0mZm5ofDKv2nzsa","yMLUza","BMPyyK0","qMz5sLK","y2fSBa","BNjiALq","CMLnu0e","Aw5KzxHpzG","AgfZ","CM92AwrLihy","BMHxzxy","rxzLBNq","sNztAwO","CMvTB3zLrxy","ruD6BMC","DKnqqKi","zuHJqKm","rxPrANq","x29UugfNzu4","zw5fDMvUDa","EhDbwhG","Efrurw52","EvbbqNC","ww5AquG","q09otKvdveK","icSG","EgH5Ewm","t2rsELK","Cg9W","vMfyv3m","CMvJB25Uzwm","uLjHwMO","CgXLyxnLiha","Aw9Ul2PZB24","y29UDgLUDwu","C3vJy2vZCW","D24GCMvHC28","C3jJ","BK9guw4","zNjVBuHHC2G","yMnJCxC","y29UBMvJDfm","DeXiEfK","rvPdC0C","tu9ey0i","BNb3s3i","zxjFCw9Zx2e","u1HSC1K","Dw5RBM93BIa","D2LiC3e","tevTueq","Ee9jyLa","DeH4u00","yMXVy2TLza","C1zvBMe","D0T4weq","EwP0t2i","D0PiA2S","B2zMC2v0","z0jKBfK","tMjVy1u","s05twMy","zsbHihn0CMK","uM92Axu","vxnJwgK","tuvtu0fhrv8","tg1WrKy","BNruCMLLC0m","y3vZDg9Tshq","t0XgshK","Ew1LtMy","Ag5mtLO","sgzHz1O","r2DerNq","x2rLC3rYB3K","rwnVvLC","Exv3DgC","rgHlt2K","q3DdBhe","BxnN","rxjYB3jdB2q","A0LKy0O","uxPuthC","A3LtEuy","t0LpEuq","uLHMAxC","tgDYr2q","y2XVC2u","sxHxzva","C0jf","DhjPzxm","zhHfquq","svfOAuq","yxrHlcbKyxq","Dgv4DfbHEwW","DMvYC2LVBG","q2n6weu","B2nRzxrgywK","y2HLy2TdDxi","zNP0A2G","x0rctMfTzq","ywnOzwqSihC","zw9jzhi","AM9PBG","zMzLCG","qNvcyNO","DefSAuO","AwXK","vwP6ufa","u2joD3e","z1rPBwvVDxq","sK9wrxu","CM92AwrLigi","B25nzxnZywC","Axnby2TdBgu","BMDuAw1LCG","yNL0zxm","BhvvALe","A2TvB3m","ywXSzwqGBxu","AezzvuO","uxjZEfy","vfffv1i","yxDlrfG","D25Rt1a","ywXNq0m","CKjUuva","BNPluMi","uxzrrxy","vwTTrLy","vhfMzgm","t2P0vvO","m3W0Fdb8mNW","rKzivM8","AxnrB1nnzxm","z1Hhwha","DxrMofDYAxq","rvjst1i","yunutum","DMvY","CgLUz1rPBwu","CMvWBgfJzui","run6AgS","y2jgB1m","CM9YrxzLBNq","A3zRsNi","EfzJtNm","z3LYs2y","tNPstNu","BgHfzgm","AevYCM9Yrxy","y3vYC29Yx24","zgLZCgf0y2G","CLrzBvi","yuLntfm","seT4A3O","ChjVDg90Exa","tK5hy0S","u3rYyxrLz3K","DwrrtwO","CeXsrum","vLrZu2W","rwP6reK","zgvMAw5Luhi","B25TzxnZywC","B0nyuMW","DxrRD3O","x2fKzfDZtgK","y2vkqK8","EvPlB2C","C2vUza","Dev2zw50","BMv4DcGPigm","ENzMwwG","wgzgrg4","BerXCg8","zuHrv3K","ywXty29Wzq","sxrUzgm","l3DZl3yY","AMfss0W","suvtx0vsuK8","CYbPBNn0yw4","EK1jBwq","mhWZFdf8nhW","y2XLyxjtDg8","vxbKyxrLq28","AwvwyNu","Dg9cExrLC0W","x2nSzwfYugK","A09hA04","B3bLCNr5","zNvUy3rPB24","s3LPy2O","tg9JAW","zfjvuvK","r3fpB1K","qw1VDw50","r2XWBfq","u3LHq1u","q29UzMLN","vhHXBK0","vgfN","v0z1qwy","z2v0qwXS","se55yNG","ihrVihjLDhi","AMLJCw8","B25tDgfYDfi","z1HPsLm","x2LZtwLUAvq","rgLcBKm","x2jPBMfYEvq","Cw1XvvC","vKH1zeS","yu9fA1O","CMvTB3zLq2G","yM9L","CNzHBa","vunxCfm","A2vVCMG","ywXSq3vYC28","ANzUvNe","wgzwrKK","Bg93","sxrAEKe","ve5Avxy","C2vUDa","EsbJBg9Zzwq","AwHVzM0","B3jRig9MzMW","C1P5wgm","CMvHzg9UBhK","Bg9NsurozxC","rw1Ire8","DgHqq1e","q1L6v0q","CgvYC2LZDgu","tND5sLa","Ahv0qMO","v2vIu29JA2u","BM93","tufyx1jfvfi","zgvJB2rLzey","yxb0y3q","CMvZzxruCMK","ELvsy1a","Eefqq0y","yLjxAfq","t3bLBKv2zw4","wKv1sei","CgfNzxnOB3C","B25szwnLAxy","ywrKq291BNq","CfHVAgm","mtb8nhWXFdu","CNjVCK1LC3m","DvLAvgm","CYbHBhjLywq","q0Xpu0LorW","CKrhs3i","C2HPzNq","BNrLCG","BMvY","x3bPBMC","BwvZC2fNzq","EvvjqKu","x2LZqNjVD3m","BuD1EuG","ExbL","Ce9ur3e","wxnJv1i","uhjPBwfYEuS","wNnqtgC","x3nLBMrby2S","CeToq3e","sun0vxq","uuX5Eu4","quP6Egu","zw1PDa","y3zvBgK","CevXu1q","A25wC3a","q3vZDg9Trxi","sMn5A2y","DLvSwwe","rLbtqwy","D01rtwW","EMjTEhi","q1ztEhm","Afzws2K","uhf2rum","tw9ktuS","tuLRA0u","DvPUEfm","EeXIC2W","yxnTrvG","y3LPv2y","twPXAhG","CMfNzvn5BMm","y1f4rvy","z3DZsLK","C2v0u3rVCMe","tgLZDgvUzxi","zgT0swe","CIb0DhDjra","zufJAW","ywrK","Cgf5Bg9Hzeu","y0HiuKi","x29WDgLVBNm","ywjZCwK","zxH0zw5ZAw8","rxPzsge","yNL0zuXLBMC","BMrWB2LUDca","EgPnu2K","rK9REM4","v1Hxv2i","tuj2zKm","tensC0q","tg9Nsuq","z25MBum","m3WWFdv8mNW","CMfTzq","C0XPC3rLBMu","DgLUzYbZzxi","zMzmAw5L","C01xu3m","DgDvvwG","Bg9IywXty28","Dg9tDhjPBMC","vxrRC3G","yxLOugu","AwrLz28","vvDztuq","jMPZy2fSBgi","t09zvg0","AhfZwvK","z2u6ia","AxnmB25N","vNDXCwC","CYbWyxjHBxm","C0Xczxi","CgD5uNu","ELr6u2u","uMnWvLC","DKrVrNa","DeLUDgvYy2u","y2uGBM90igK","ywXSB2nvBNm","BxnNsuq","x3jLy29UBMu","zNjVBunOyxi","zwn0","swDKA0i","vKvoBKO","Ae9Wzw5fDMu","vhnmtvG","BMrWB2LUDfq","nxWZFdr8mNW","zKTMtKW","uuXStw8","m3WXFdr8mhW","s2DRCLm","qvbhvg8","B3nLrxzLBNq","C0Xf","vgLttgu","vhfftvq","t0LUDxq","tvzAvNy","C2v0y3vYC28","lcbxzwjtB2m","ChjVy2vZCW","zv90Aw1LB3u","r2TcwxC","v3bHuge","Ef9MCM9UDgK","CMvHC29U","yxnAB04","z2v0q3vYC28","Cg5Ly1K","sfvczvO","uLzsCvm","zffcu1m","uhjeB3u","zNjVBujPDhm","qMTRqxK","Cg93","wNvVAuC","DxbNCMfKzw4","C3rYAw5N","qKHcyxC","ugfuvuS","x2nVBM5Ly3q","zfPwze4","BLHizM0","y29UBMvJDgK","zMTrswO","A2v5CW","vw5PBxbSzw0","zw50","mhWXFdr8m3W","Cg9PBNrbBMq","C2v0","zw5KCg9PBNq","Cgf5Bg9Hzfq","tg9NsurozxC","DMfSDwu","z1LjBg0","y0DcqMu","CMvKDwnL","CMvZzxrfBMq","Aw9U","sxLpDwq","A1n0yxr1C0m","wKTrEu4","su5tvefova","y29UBMvJDca","qwjVCNrfCNi","sgHrsuC","AMzYs3e","vvrqrwu","vgPLtNG","DvP6uhq","zw1LBNq","tuTbvgS","rfrNz1G","D255Cxe","DgfIyxnL","yxGGCMv0CMK","ywnRtxnNswq","tu9UAM0","BhHlDgW","yMrsD00","r0X5tMy","reXPEKK","CeDfC3a","wfv0A2K","CMvZB2X2zq","AePlqKO","AM1ruum","CvD0Dfi","Dg9oDw1Izxi","y0Pft2G","rwvVsMG","x21PBMLoyxy","rxjbD24","reT3v1e","DNLfrwW","DKPPweG","y0vyC04","A2v5","Efr1wNu","DNPhq1m","Dg9hzw5LCMe","tfvWsMi","yNH3De8","B2LUDfjLywm","Fdb8mNW3","mZC0mZuYmhfMvwzora","CwrMChC","BKP0D0W","rxnNBem","BKnlB3u","ihrPBwvVDxq","tw9KDwXL","zw5JB2rPBMC","y0fbyKi","z0fTwwi","BezSDxnO","ANHWCuK","EePKwuO","y2HnyxHuCMK","BKfUDgq","uLPNy3G","wvHPEKq","qNjPzgDL","svn6zgS","zMX1C2HfEha","u2vvzwS","yMnttMy","A1Ppu2e","vuvPuwq","EwXpuMW","AxjLza","x2rItMfTzq","CKXiq0G","ywrKrxzLBNq","sLztD3e","nhW1Fdb8mxW","yMLUyxj5","BK9IEvq","Dhnduxa","CgLUz0XVC3m","uuj4she","EM1LyKy","quTovuW","x2HHBMrSzva","yvDzsMq","z3DIueu","BLzyrMe","whjVz3K","D3bArLO","B25dBg9Zzq","Ewn6y24","wLbxrxq","zhD6Cxu","B25JBg9Zzq","BfzWwum","x21LC3nHz2u","uKjksfq","zLfUqKq","x2rPC3bHDgm","rgLgvLe","ywDLu2HVDW","sw1vC2G","yLLLtfu","tgvLAwG","y291BNq","z1z4q2G","Bwf4tg9ZC0m","x2rYB3bhBg8","ignVzgu6ia","vhLAAuC","sw9yrfm","txzVteO","vvniuLy","rKfJu04","qur5qNC","quXm","q21dthK","DhjPzxmGCMu","DuXkwwm","y29UBMvJDeu","DLLTq3a","CMv0CNLdB3u","y0nUwKi","v1nyrLe","zxrXEee","BMT6DNq","AuL5u08","Dxblz0y","DfH6weu","ze9vyM4","AgjczKK","AwXSihvZzsa","u0HyExK","qNPUsNq","r2veEKK","AK5uDgG","yNvMzMvYzwq","wevNyMq","D1HUzgC","zu9zy3K","DgvZDa","z2zwtMS","CMvUDevUzha","t0TqrLm","DgrutM0","ChvSBgq","zgvS","DgLozva","Bwf4twvZC2e","zM9Yy2u","BwvZ","tu9iAhu","CNzHBfzHBhu","x2LZtM9Kzq","BNrbBMrvCgq","ExfvrNm","A0n1ChG","ywzwv2G","x29UtwvZC2e","uK1MBNG","AwPNqKK","AvrfzK0","r3PIsvi","DcbSAw1PDa","zMHzt2m","ChjhufO","zKPzrM4","zKzuwfq","BMnVzgLUzW","zMvY","rM1XzNq","x2zVCM1HDeu","ywnRx2LK","mhW0Fdf8m3W","yxnZAwDU","yu5JBLe","B2nRzxq","EhPoDhi","m3W0Fdj8mhW","CMvHzhDYAxq","z1H6tKC","Aw50zwDLCIa","sgvlvLK","Ehb5rLm","z3foqNO","DNbhEgW","zNjVBNrPzxi","r0jjANK","uwPsEhu","AxnbCNjHEq","vwr2tw0","y3vYCMvUDeu","mtzouND2sLO","AwDnve0","C2vUzf9Hy2S","yLzxs0e","Dg9Y","C3fjBgq","tNLWt3a","EMziCK0","x2LUAxq","Dgv4Dc9Qyxy","BwLUAvbYB2C","z29mrLO","nZm3otCZsMjfy0DJ","t2Xws1G","uxfVtui","B2zMBgLUzq","EwH6A3a","q21yDuK","x3vYBa","z29PBMCGyxC","qLvoCLu","s2DsugS","ALbRzLO","yKvswvO","A1vMy28","zwveuNi","qwDxtwO","qw9SAgC","y2XLyxi","uwDiDwq","x29UvgLTzw8","zhrStLG","yxrLq291BNq","ENnptxG","B3bLBIa","z2v0t3DUuhi","qK13rvK","DxbKyxrLq3u","twvZC2fNzuu","rhPVqNO","uMTkAuu","Aw5KzxGGB3u","D2LSBfjLy28","Cw9Z","C29YDa","nhWX","zhjwAe8","wvLuEve","BNnly1O","EgPtu1a","AenSB3nLrxy","shH6wuS","x3DHAxq","yNL0zu9MzNm","Ae1LC3nHz2u","DxrVuMvJB24","B25fCNjVCG","D21SueS","rLHNte4","Ee11uvG","yNvMzMvY","ChHTvKu","CfPtvwm","zxH0ugf5Bg8","Cuz3Efm","C2vlqva","vvntzuO","BMrLEa","Aw5PDcbrB1m","x2TLEvbHDgG","uLvoCNa","Bw5YuxC","Aw5JBhvKzxm","zeLnrfa","veL2A0S","yLL2EMq","zxrxB3jRq2G","q0Xpu0ve","vuvQzKe","D3jPDgvvAw4","uu5Sz1m","yxDRDNO","swXyD2C","x2LUAxrhBg8","r3rIug8","igzHAwWSig0","BMf4EfO","tKfusvzfx0u","DgLLCKPtt04","vwHiy0y","BgXzqwy","s2jVyu0","x3bPBMDmB3m","zcWGDw5RBM8","yMfSrxzLBNq","z3jPr1e","CMvWBgfJzq","x2LUAxrqCM8","tLP2Deq","Egv2D1m","rxP5teO","qK1It04","yw9LD3O","r1v6yMu","CNnVCKzPBgu","t2jQzwn0","rwXPshq","D3fZteG","uNbUChy","C3nHz2vfDMu","r3DSvLm","z2v0u3rVCMe","s3nuB1e","zgn4Cve","tg9Vs1u","CxLOsxK","wLLVr24","ENP4ueK","thbeBhi","x2n1CNnVCKy","zgLcA0u","senWt3m","EKv2yNO","ELrtrLy","uxvLDwu","t2Tpu0q","A1D6Bfy","BKjSqKe","veznqLC","rKLmrv9ot1q","ze5WCva","sLrUv04","A0L1wMK","ChjVDg9JB2W","ELHhqvO","CMTLCKDSB2i","zwrPyxrLBhK","r2H4zxi","svbcC28","q3f4r2C","wxHts0W","q0HKrhC","zgrfDMO","tu10Eei","swLbvwq","yxnJCMLWDa","x2LZv29YA2u","AMv6Afa","zgf0yq","CM92AwrLige","AvbIt3C","t0T3vxC","B3jpBMXPBMu","AfPLwMS","zMLSzw5HBwu","svHOALq","vgrVuNe","rfzdrvK","wNfwv0W","rLDUD1C","Aw5Lza","BwvZC2fNzv8","CvzAAKi","u2HHCMvKv28","sw9yy1a","B3bbrfi","v0DpBgi","z1nlDuW","t0n6Dxm","BxnhChK","yw1LoIa","vhnSz0S","BuHUEhi","C3vIyxjYyxK","whjkvwm","EhrAq0W","C2vYDMLJzq","ywrKt25L","ywr2yw5Jzq","uM5yt2u","sLzku2e","zMn3tM4","zhLQque","CKPkCgu","Dw50","yMLUyxj5vhK","tNrMz00","m3WY","Eg5zA1y","C1vprg8","ihbYB3rVy28","CgPLzKG","zffKCfe","s1bbEgO","z2v0sxrLBq","D0zNqxy","yw5Nzq","Chv0","Bg9bBxK","zNjHBwvuExa","Cu5rv0q","DhjHBNnHy3q","yKjjuLO","zxjFBxnNAwq","uefSq3G","x2DLBMvYyxq","A0XNueS","C2vYDMvYvgK","x3nVy2TLDa","tKfVDeW","mdaWma","BwfW","zw5JB2rLrNi","uuDTDMm","u0T4Cwm","AMT3why","DLLKB2q","u3fmA0K","BMvJDa","zNjVBu51Bwi","zMLSDgvY","wNLAwgm","zNjVBuj5Dgu","seLiwve","x2LZtwLUAvC","ihrYEsbYzwm","x3nLCuLK","suDdExO","CLrruuW","zfrvzuu","DhzlAeq","wejwwMG","DxbSDvm","C3rVCcbPBw0","zwvKzwq","Ee5tse8","EvHvsgu","B3zmBKG","CwrSC0y","vLHXC1O","DeLK","AgnyvvO","x2rLyNvN","D0fVAwm","rLjptLrjrvi","tKDFrvjst1i","DwTRAKu","BwvKAwf0zwW","AKn1uLe","vKLvvuC","Dg9VigXHCMC","vhr2zfm","t0zKBuK","q2H1yuK","yxzwtxi","Ahr0Chm6","rgHWy0G","s1fHA3y","we9wz28","yNPSu3u","BwP1Dgi","BIWGAg9ZDg4","ChvZAa","Dg9cExrLCW","wgfdBxG","De1HBMfNzxi","yxbWBhK","zgjVC2i","DMLJzuLeig8","zw5HyMXLvhi","uMrhy2q","zg9Uzq","wLjJBMe","C3vIC3rYAw4","werMCue","B3DUC2m","AujZr0W","C2v0q3vYC28","yuvdrxu","ANzIEwu","quzOsKe","A1nKue0","zM9YrwfJAa","EffsBgm","CgDmsey","DgLTzw91DcW","x3bPBMDqB24","Bwv0Ag9K","s3vSru4","C2vYDMLJzs0","ywnOzwq","vMPpD1q","EM9eEvq","ANzHBgi","Cen5Cuu","uMvJB25Uzwm","DgLTzw91Da","mJq2mtuWmfHPweXHtq","t3vrtNe","y3vYC29Y","tNPSq0y","x2n1CNnVCK0","y3nirKi","s1z5Eg0","AgfZt3DUuhi","B3v0sw50zxi","B25LCNjVCG","zgLZywjSzue","EKnlA1y","wMrREfG","B2fK","C2v0sxrLBq","x2nYzwf0zvm","uwvIz0e","C3rLBMvYCW","nxWWFdf8mW","v2vPEgLUsLm","z0jPzNK","rgLjwvq","DgzdAKO","AgT0txK","CNnVCL9Uyw0","CMzkDe4","CNrZALK","zwfnAM0","AM1Kugq","CMvXDwLYzwq","D0jNtgC","sfHRzhe","DKjUyNy","zxjYB3i","BNHpwxG","rvPguNi","AuHWEKC","v2LUzg93","txz3qMG","BNnAELm","y2HHCKnVzgu","y2LKy0S","BM5Ly3q","zxjHDg9Y","r2nIq1m","BgLUzw5V","rLnUCfa","r2DQq3m","CgHMsu8","x194x21Zz18","y2vZC0HHBMq","DMvUDa","sLrJy2y","Dw93uMK","CfP1yKe","AwDHDg9Yt24","ru9OC2G","y3jLyxrLuMu","ywnR","tvr0wNq","x3fVC0rc","ugP4D0K","r0L6BKi","zw5HyMXLqxu","sujNCue","rhLgv1i","yvz2wxm","yNDvBvG","zxjFAxnFywm","y3jLyxrLt2i","uKXnC0e","CLncwhy","Bwu6ia","Dw5ZAwDUzwq","Aw47y2HHCNm","s2LzwvG","BM5Vtxq","wM9Mwfa","rMXez2O","z0DmwMG","zxj2AwnL","r2v1r2K","EfDZCvC","y3jLyxrLrxi","y2LKAxO","v25nquO","Dg9mB3DLCKm","x3jLywr5q2W","CNn6vuG","uK1SzfO","AwveAuK","svjsz1G","u3vir2G","CejPs1G","rKDwr08","tMLRDgu","Exfhu0e","B3nLza","EMTvr1G","C0nVDw50zxi","DNbMCw4","uhjYCNi","Bhr4uxu","ywnRx2nVzgu","BgvUz3rO","vgreuxu","DhDVCMTdAge","ywnRpwzYB24","zcbLCNjVCI4","uM1zve8","yu9XBNC","BxLWA2K","D1Pqvvi","wvrLD2C","ywjzs04","quLAs1O","vurwqwW","lcbTyxGGCMu","BhrPCgXLihq","Ahr0Ca","rw5vA2S","yNrHqMG","tKLfBe0","igzPzwXKoIa","t2ftq2e","t0j0weK","wMHSt0W","BeHHBMrSzxi","C1PPDLC","BML0AwfSAxO","r3z4y0i","x2HHBMrSzu8","Aw9UvgLTzw8","ihzHBgLKigq","q3bJCgq","AuHxruK","ALflAeK","sKfnENm","Aw5L","qxDdrgy","yxnL","zfDVCMTLCKC","uxrbyu4","wezIAhe","CNfRtKW","ywXS","wNLgs3G","CLz4txG","A0DsD0u","BgvmsLO","Aur6y3u","C3rYAw5NAwy","Aw5N","z2v0q3vYCMu","mdaWmdaWmda","zw50zwqGDhK","B3b5yM0","rg56BMe","AfD1reS","x3bYB3rVy28","ywDLsgLKzq","yw1Lu3bHy2u","y3jLyxrLt3a","B2jQzwn0u3q","zvbhBhO","r25fuKm","zNrAzeW","AKHiwge","zvDvuhu","Ec1TC2CTCw8","zxmGCMvHy2G","wK5SuNa","uML0DNe","B25VCgvU","tKXAvMK","nhHpEfLSsa","y3vYC29YlNm","ign1CNnVCIa","vw9kCxC","B25Uzwn0Aw4","A2v0ignVBNm","ze10zNy","CMfTugfYyw0","DhfmsMu","ruToC3m","yxv0BW","x1fVu01HBMe","wfHqquq","wg1Rvfu","x2XPC3rLBMu","tMDpswW","C3bSAxq","BMvLzf9Hy2S","q3HJwe8","q0vHuxq","CMvJzxzPzwq","Aw5vuM8","y3jLyxrLtwu","tgfjr0q","C2fNzq","yxPHzhi","r2TWzKe","t3bor2K","mtuXotu2tKr0q0nb","x2DLDeLUDgu","EvjLy29UBMu","ref1wve","zMzMzG","v01cBhm","y29UC3rYDwm","ENDhww0","u2TPCcbWyxm","A2HREwW","AK1xwKO","ywWGy3vYC28","C0ndBLO","yw1yrMm","x19LC01Vzhu","DLPACLy","CMrYChK","uMLnuve","tgHdy2S","BMCGB3iGyw4","q2nJzgG","tMPezNe","tMfTzq","DxjS","C2nkDLi","tKzYC0W","C2XPy2u","B25SAw5L","B25ozxr3B3i","uKrQzeq","CMfUzg9T","y3vYC29Yx2y","m3WW","C3rdCu4","vuL6ywe","z1DOuwC","s2z1AgG","CenXqvi","AKz5yKS","BgrNDgG","uhvrALm","Dw5KzwzPBMu","rMrjqMK","q3vZDg9Tq2W","q291BNq","BgLUzq","sLzNqwW","qwPZCfy","Dhr3Awq","sgTbyM8","x25HDMLNyxq","D09qy2S","Dxrjza","B3jL","x3DZ","yK1IEhe","tuPSBgG","Bvfly08","x29Uq2XVC2u","B3vUDa","sgXJvfi","u2nKAfe","Dg9cExrLC0i","x3bYzwzPEa","vgLTzw91Da","uLjpuG","wurItvO","tvrmvgW","zgvSzxrL","AKHAqNq","EhHKy0W","DxvZDg0","vhnrrg4","ELjwy1K","Cw9Zx18","vKDIEwW","AeL2yxa","yw5ZzM9YBvq","rezwv28","x29UrxjYB3i","BwLUzW","vwr5wxG","yKf4wNq","CgLUz0LUDgu","x2HHBMrSzvi","EKHLwKW","Cg9PBNrdB24","A3rwBKC","zKDPBgK","z2v0s2v5","suHsyLe","vNfcuKe","v21svLC","AefJA01LC3m","AgToqNy","nZeZmde0mKLOsLzlrG","EwL6Agm","sNjSreS","x2LUDgvYDMe","zv9ZDwnJzxm","BMCGzMfPBgu","CKHeELe","wKr4EM4","y29Kzq","tLrLuwS","EwruCxa","x2nSzwfYvgK","D3m6lY8","CM92AwrLihC","y2XVC2veqG","EMXgEvG","AejyqMi","ig1LC3nHz2u","x0vysvnu","AxnFywnR","Eef4EKK","z2v0","vwj3Awe","CLzHBhvLCW","s3PhyuS","y2XVC2uSihC","r05uEw0","zcWG","r0fTDKy","y3ruAw1LB3u","zMvuD2m","AwXLx25HBwu","vgjuA1q","qNr3txK","Duf5s1K","AgLNAa","ChrVCG","DNDREwm","DunWvve","zxjFDhrS","wg5xD0u","yvLptxi","AwrI","yw1L","Aw1LCYbPBIa","x3jLBw92zvC","EwzvD1a","qMPZEgO","DgnRu0u","zwv3y2W","EgfnCKi","z2rsvvy","q29Kzq","BM9Uzv9UB24","CgjICdi","uMryq28","yvHnDu0","rwHhCgC","CuDZrMu","DxnLCKLW","ww15rwS","yNn5t3a","D2f4v3i","CMn2tMO","ExLfy0G","AKPSzwK","AgvHzgvY","zw50tgLZDgu","BgvY","x29Ut3bLBG","rufwDKm","z2vtEw5J","rgPrBKC","ihzHBgLKihm","rM1KsKS","CLPlrwG","B3jLtMfTzxm","vhDptK8","x2rPC2nVBM4","revUrvy","C2v0zgi","D3jPDgu","we1Zwvq","Ewzcq2O","t1bftG","AxnszwfKEq","zwnVBM5Ly3q","yxbWzw5Kq2G","rwHOrxO","zMLN","ywnRDxbfBMq","zuLwtLC","rK9ZsLa","tKz6wvK","CMvJzwL2zwq","CMvQzwn0","BMfTzq","zxq9DxrMltG","C2Dpy2e","z2nusgS","uhrWCuW","wKnZqKC","igfYCMf5yNu","weT0t0G","tNrQy1y","ENLHtwe","ywDLrxzLBNq","qK5QqNC","uev0BhG","tMHIEgW","mNW1Fdr8mxW","CNnVCL92ywW","wfjRCwe","y09Wzw4","yM9KEq","zxjYtxnN","CgLUz19VBMm","y3vYCMvUDeK","A1LqtgK","zM92Euy","v0HIvLa","BMHgCva","z1zcsK8","AMvJDfn0B3i","Aw5KzxG","u2vXsuq","t0LkuhC","v2XhAgS","zxjFywnRx20","vg9rDhG","x3DZsw5ZDge","rNjVBNrPzxi","B2rLu1G","zgvSzxrLrge","BNrfBMrWB2K","Be5VBuy","r25zvxC","Dgv4Dc9WBge","rNDiruW","AM1ru3O","BKXPBMu","wxPHBha","ihn1y2nLC3m","A2nnDM4","BNvTyMvY","AKfWuKu","senMugm","y3jLyxrLq2W","zufdA1m","ufzYqMG","B1zHEey","qKHnv2y","CuDVD2u","C3rHCNq","vu9NsM0","DeD5thC","AgvKtwf4uMu","BwvY","ELHxyNi","B3bLBKrc","Cgf5Bg9Hza","DKTpug8","B0LwwMK"];return sr=function(){return n},sr()}sf(ia,{deleteDB:()=>gf,openDB:()=>lf,unwrap:()=>dn,wrap:()=>He});function lf(n,e,{blocked:s,upgrade:o,blocking:c,terminated:x}={}){let u=k,f={bERYZ:function(y,_){return y===_},Roviu:u(370),bxwtO:function(y,_,E,C,I){return y(_,E,C,I)},vpGxl:function(y,_){return y(_)},aXMuM:u(475),fNAbu:"versionchange",GeuGi:u(779)+u(1230),rVxMx:u(441)},g=indexedDB[u(354)](n,e),m=f.vpGxl(He,g);return o&&g[u(877)+u(691)](f[u(1374)],y=>{let _=u;f[_(1019)](f[_(451)],_(679))?_0x29f314[_(1777)](_0x4fc9e1):f[_(846)](o,f.vpGxl(He,g.result),y[_(1794)+"on"],y.newVersion,f[_(989)](He,g[_(1197)+_(802)]))}),s&&g[u(877)+u(691)](f[u(1440)],()=>s()),m[u(364)](y=>{let _=u;x&&y[_(877)+_(691)](f[_(1647)],()=>x()),c&&y[_(877)+_(691)](f[_(382)],()=>c())})[u(357)](()=>{}),m}function gf(n,{blocked:e}={}){let s=k,o={ghskH:"blocked",TDLVD:function(x,u){return x(u)}},c=indexedDB[s(1724)+s(818)](n);return e&&c[s(877)+s(691)](o.ghskH,()=>e()),o.TDLVD(He,c)[s(364)](()=>{})}function ea(n,e){let s=k,o={yUIBE:s(983)+"e",gAmYb:s(620),sVUna:function(g,m){return g instanceof m},dZvwC:function(g,m){return g in m},nxOYx:function(g,m){return g===m},GLyNf:function(g,m){return g!==m}};if(!(o[s(442)](n,IDBDatabase)&&!o[s(1776)](e,n)&&o[s(1327)](typeof e,"string")))return;if(tr[s(1612)](e))return tr[s(1612)](e);let c=e[s(1092)](/FromIndex$/,""),x=o[s(824)](e,c),u=oa.includes(c);if(!(c in(x?IDBIndex:IDBObjectStore).prototype)||!(u||sa[s(1068)](c)))return;let f=async function(g,...m){let y=s,_=this[y(1197)+y(802)](g,u?o[y(654)]:o[y(858)]),E=_[y(1827)];return x&&(E=E[y(1715)](m[y(649)]())),(await Promise[y(1438)]([E[c](...m),u&&_[y(1267)]]))[0]};return tr.set(e,f),f}var sa,oa,tr,hf=na({"node_modules/idb/build/index.js"(){let n=k,e={WFuAf:n(748)+"0|1",bsyOp:function(c,x){return c(x)},wBgLg:n(1193),wqsLH:n(1564),lkSVS:n(1024),QqoMB:function(c){return c()},gVxCh:"get",Utluj:n(1585),APGTo:"getAll",RChID:"getAllKeys",keorh:n(908)},s=e[n(591)].split("|"),o=0;for(;;){switch(s[o++]){case"0":tr=new Map;continue;case"1":e[n(1652)](df,c=>({...c,get:(x,u,f)=>ea(x,u)||c[n(1612)](x,u,f),has:(x,u)=>!!ea(x,u)||c[n(396)](x,u)}));continue;case"2":oa=[e[n(1323)],n(695),e[n(1103)],e.lkSVS];continue;case"3":e[n(1010)](Qo);continue;case"4":sa=[e[n(909)],e.Utluj,e[n(753)],e.RChID,e[n(608)]];continue;case"5":e[n(1010)](Qo);continue}break}}}),pf={idb:function(n){let e=k;n[e(366)]=Promise[e(828)]()[e(364)](()=>(hf(),ia)).then(function(s){return s})}},ta={};function Ge(n){let e=k,s={ItZzA:e(977)+"2",cNXVQ:function(f,g){return f!==g}},o=s[e(613)].split("|"),c=0;for(;;){switch(o[c++]){case"0":var x=ta[n];continue;case"1":var u=ta[n]={exports:{}};continue;case"2":return u.exports;case"3":pf[n](u,u.exports,Ge);continue;case"4":if(s.cNXVQ(void 0,x))return x[e(366)];continue}break}}(()=>{let n=k,e={EAVvC:function(s,o){return s===o},ejrgx:n(1027),WHbVP:n(358)};Ge.d=(s,o)=>{let c=n;if(e[c(1661)](e.ejrgx,e[c(1711)]))X[c(899)+c(1120)][c(649)](),X[c(899)+c(1120)][c(1258)](_0x13c2fb);else for(var x in o)Ge.o(o,x)&&!Ge.o(s,x)&&Object[c(551)+c(579)](s,x,{enumerable:!0,get:o[x]})}})(),(()=>{let n=k;Ge.o=(e,s)=>Object[n(544)+"e"][n(1300)+"operty"].call(e,s)})(),(()=>{let n=k,e={LaIGD:function(s,o){return s===o},xQRlc:"rYPAD",YnZAH:n(743),MoJMK:n(1537)+"d",FFHVo:"__esModule"};Ge.r=s=>{let o=n;if(e[o(1491)](e[o(1279)],e[o(411)]))return X[o(1204)][o(1181)+"pe"];e[o(680)]!=typeof Symbol&&Symbol[o(719)+o(590)]&&Object[o(551)+o(579)](s,Symbol[o(719)+"Tag"],{value:o(855)}),Object[o(551)+o(579)](s,e[o(521)],{value:!0})}})();var ie={};(()=>{let n=k,e={ZofXP:function(i,t){return i(t)},UhHcF:function(i,t){return i+t},pEqST:function(i,t){return i*t},QAjiQ:function(i,t){return i*t},nCKou:function(i,t){return i(t)},OaSCa:function(i,t){return i+t},ZuoiG:function(i,t,r){return i(t,r)},MVZVv:function(i,t){return i!==t},cCnZB:function(i,t){return i+t},PVrBh:function(i,t){return i(t)},yPABw:function(i,t){return i+t},yBpgc:function(i,t){return i(t)},qNQWD:"0000",aoewz:function(i,t){return i===t},vCPBB:function(i,t){return i===t},upKgF:function(i,t,r){return i(t,r)},ToQtx:function(i,t){return i>t},KgkrS:function(i,t){return i<t},aOEkZ:function(i,t){return i<t},ceJBO:n(726),awkvz:function(i,t){return i-t},WMBls:function(i,t){return i<t},kcMvn:function(i,t){return i-t},hbBfI:function(i,t){return i<t},wnkOP:function(i,t){return i!==t},YDbMZ:n(731),Gcoqy:function(i,t){return i-t},fFTXT:function(i,t){return i!==t},RfcEl:function(i,t,r){return i(t,r)},GUzbe:function(i,t){return i!==t},dcxqQ:function(i,t){return i>>>t},QzTLw:function(i,t,r){return i(t,r)},Prrrr:function(i,t){return i&t},opADR:function(i,t){return i===t},CGJIF:"Missing "+n(1322)+n(1416)+"key",RQviq:function(i,t){return i===t},Yzalp:n(1810)+n(1322)+" field: value",aNubJ:function(i){return i()},UOgJm:function(i,t){return i-t},opybm:function(i,t,r){return i(t,r)},MvoLJ:function(i,t){return i!==t},upluS:function(i,t){return i===t},stCqN:n(683),FXgLN:function(i,t){return i!==t},EZFRr:function(i,t,r){return i(t,r)},XOVgo:function(i,t){return i(t)},fhYOc:function(i,t,r){return i(t,r)},kvkJr:function(i,t,r){return i(t,r)},gBdlY:function(i,t){return i!==t},EKNss:function(i,t,r){return i(t,r)},TtvdS:function(i,t,r){return i(t,r)},RVRqS:function(i,t,r){return i(t,r)},UkmFV:function(i,t,r){return i(t,r)},qdlsF:function(i,t,r){return i(t,r)},DOeye:"EmXNH",rZSBv:n(821),zwGYm:function(i,t,r){return i(t,r)},ZKQyN:function(i,t){return i!==t},kIuZi:function(i,t){return i(t)},LUpJb:n(1226),IPBso:function(i,t,r){return i(t,r)},xhyyc:function(i,t,r){return i(t,r)},vWBSF:function(i,t){return i(t)},WGOlb:function(i,t,r){return i(t,r)},CkFdo:function(i,t){return i(t)},zzxPI:function(i,t,r){return i(t,r)},YySYo:function(i,t){return i(t)},pgyRu:function(i,t,r){return i(t,r)},pxmVE:function(i,t){return i(t)},FWnwW:function(i,t,r){return i(t,r)},DiFVQ:function(i,t){return i(t)},hkNBv:function(i,t){return i===t},vKOPo:n(1810)+n(1322)+n(1416)+n(1716),kOGkN:n(1810)+n(1322)+n(1416)+n(709),OdRzY:function(i,t){return i===t},PvtWi:n(1810)+n(1322)+n(1416)+"service",griGQ:n(1029),FwHEL:function(i,t){return i+t},uliqy:function(i,t){return i(t)},rZKEh:n(789)+n(1448)+"pe: ",JqZRN:function(i,t){return i>>t},ayhPe:function(i,t){return i>=t},jkwXv:n(1385),GgDFt:function(i,t){return i===t},dQdpQ:function(i,t){return i+t},CHhkT:n(1504)+n(967),HCpOs:function(i,t){return i>>>t},ymbeb:function(i,t){return i&t},PjxwI:function(i,t){return i+t},Kyicj:function(i,t){return i+t},RMfnx:function(i,t){return i>>>t},tAliJ:function(i,t){return i===t},pXohc:"uWOLl",fKfNL:function(i,t){return i>=t},USSeJ:function(i,t){return i*t},SXlsY:function(i,t){return i>t},lZEJh:"Read pas"+n(967),LooKU:n(1016),pGEsp:function(i,t,r){return i(t,r)},nBlBA:function(i,t,r){return i(t,r)},zXGAZ:function(i,t){return i<t},EBxUy:function(i,t){return i(t)},RlScY:function(i,t){return i+t},aiDmF:function(i,t){return i<<t},dwzqu:function(i,t){return i&t},mQKcO:function(i,t){return i==t},ZrntP:function(i,t){return i>=t},Ruoqi:function(i,t){return i+t},bdRwM:function(i,t){return i+t},XfFDn:function(i,t){return i!==t},ECzhk:function(i,t){return i|t},iBsGL:function(i,t){return i<<t},kkUos:function(i,t){return i|t},IoXDS:function(i,t){return i&t},bxcsm:function(i,t){return i&t},DiIYT:function(i,t){return i<=t},diBkE:n(942),dOUbn:function(i,t){return i(t)},DiBnC:function(i,t){return i&t},rszUH:function(i,t){return i>=t},BMwEY:function(i,t){return i+t},Leeih:function(i,t){return i+t},UTPEe:function(i,t){return i+t},DyFWR:function(i,t){return i+t},CEaQt:function(i,t){return i+t},jxpqI:function(i,t){return i|t},gVBJO:function(i,t){return i<<t},NzlCF:function(i,t){return i|t},HNybx:function(i,t){return i<<t},hutBj:function(i,t){return i<<t},MvwBh:function(i,t){return i&t},cAAbB:function(i,t){return i<t},EGzng:function(i,t){return i>t},QNlgS:function(i,t){return i>>t},ZRcna:function(i,t){return i+t},kdJSK:function(i,t){return i<=t},ZiYOn:function(i,t){return i<t},etqxA:function(i,t){return i+t},zyaMa:function(i,t){return i<<t},Wxigu:function(i,t){return i<t},kWzlV:n(1427),AFhJA:function(i,t){return i+t},XXPAD:function(i,t){return i+t},NOoti:function(i,t){return i<t},sVfFZ:function(i,t){return i<t},jicqo:function(i,t){return i|t},ltxQu:function(i,t){return i>>t},uCpUQ:function(i,t){return i|t},Utksx:function(i,t){return i>>t},yfUwP:function(i,t){return i|t},NTeQk:function(i,t){return i&t},knVsp:n(1707)+n(763)+"t",lxKtl:"timeout",WlGhk:"UiRNI",Fmqft:n(1202),njXbM:function(i,t,r){return i(t,r)},HFNBA:function(i,t){return i<=t},uustm:function(i,t){return i>=t},hZeZk:function(i,t){return i===t},jFybK:"yvrxV",SbNwq:function(i,t){return i<t},ukkjE:function(i,t){return i&t},dMtfv:function(i,t){return i>=t},QkSNt:function(i,t,r){return i(t,r)},kySyF:n(1633),BMbON:function(i,t){return i(t)},ieVbu:function(i,t){return i&t},cyiWf:function(i,t){return i===t},HlcTR:"RMADQ",OKwUw:function(i,t){return i(t)},MMtxB:function(i,t){return i<<t},VTsSl:function(i,t){return i(t)},YelkJ:function(i,t){return i<<t},rdrpy:function(i,t){return i&t},vJiXH:function(i,t){return i&t},CwClq:function(i,t){return i!==t},Mlfxp:n(1689),dbosb:function(i,t){return i(t)},FGVGO:function(i,t){return i<<t},PppYW:function(i,t){return i&t},AWNCT:function(i,t){return i(t)},HCfPc:function(i,t){return i&t},TdVnp:function(i,t){return i&t},XDfqA:function(i,t){return i|t},QLlMo:function(i,t){return i|t},GgjCs:function(i,t){return i>>>t},JOVEu:function(i,t){return i<<t},CczXE:function(i,t){return i>>>t},RUNrp:function(i,t){return i===t},ZyZXc:function(i,t){return i<t},msGpy:function(i,t){return i<t},IYGXO:function(i,t){return i&t},RcpVW:function(i,t){return i>>>t},bRWhT:function(i,t){return i+t},Cccdh:function(i,t){return i!==t},DhpcH:function(i,t){return i&t},FdIBi:function(i,t){return i>>>t},VENnJ:function(i,t){return i&t},szszk:function(i,t){return i+t},kYPLi:function(i,t){return i!==t},jklVJ:function(i,t){return i|t},vDoFp:function(i,t){return i>>>t},luUjQ:function(i,t){return i&t},bzlSu:function(i,t){return i>>>t},qdfpw:function(i,t){return i+t},RYWoS:function(i,t){return i!==t},wpZFZ:function(i,t){return i>>>t},TsQDn:function(i,t){return i&t},NtfgM:function(i,t){return i+t},BuBbz:function(i,t){return i!==t},NnKdF:function(i,t){return i>>>t},jJlei:function(i,t){return i>>>t},amXFc:function(i,t){return i>>>t},pBiKX:function(i,t){return i+t},rUMCl:function(i,t){return i|t},Jcykf:function(i,t){return i!=t},azadr:n(1537)+"d",cHHRB:n(855),YbxeQ:n(1510)+"le",nsZzS:n(1532),gYIlm:function(i,t){return i|t},QBxHq:function(i,t){return i|t},DjQnG:function(i,t){return i|t},TQEWR:function(i,t){return i|t},Ubwia:function(i,t){return i<<t},AYLxw:function(i,t){return i<<t},FPSAf:function(i,t){return i|t},gCfnS:function(i,t){return i|t},iygJS:function(i,t){return i|t},IQhiD:function(i,t){return i|t},ZPWEt:function(i,t){return i|t},ArhTa:function(i,t){return i|t},cJEOh:function(i,t){return i<<t},UdvMm:function(i,t){return i<<t},mobFi:function(i,t){return i>>>t},xjMSi:function(i,t){return i<<t},MaksK:function(i,t){return i<<t},pZWMD:function(i,t){return i&t},jvalb:function(i,t){return i&t},qWttR:function(i,t){return i>>>t},VSEQC:function(i,t){return i&t},nhWev:function(i,t){return i&t},UjzPP:function(i,t){return i%t},sUODo:function(i,t){return i|t},oyvbt:function(i,t){return i&t},sZivW:function(i,t){return i>>t},ECbtq:"UHsGP",MBvfC:n(1695),ViGts:function(i,t){return i+t},Yxlma:function(i,t){return i>>>t},XYnet:function(i,t){return i>>>t},WmRVW:function(i,t){return i===t},XBVZh:function(i,t){return i>>>t},KulEN:function(i,t){return i&t},NFrsL:function(i,t){return i&t},ElHXq:function(i,t){return i&t},DLizI:function(i,t){return i>>>t},HkAbo:function(i,t){return i>>>t},jXSVE:function(i,t){return i>>>t},xMuQX:function(i,t){return i+t},mGuyH:function(i,t){return i|t},fGili:function(i,t){return i<<t},xJdYJ:function(i,t){return i===t},mHnxr:function(i,t){return i>>>t},BbOtg:function(i,t){return i===t},nrXva:function(i,t){return i+t},jNTth:function(i,t){return i&t},ovLnH:function(i,t){return i>>>t},XnWwE:function(i,t){return i>>>t},cbAEi:function(i,t){return i>>>t},jezhP:function(i,t){return i&t},oWwXF:function(i,t){return i&t},TqEMT:function(i,t){return i>>>t},PuQjS:"quskv",wAoic:function(i,t){return i>>>t},nnoMt:function(i,t){return i>>>t},waxWr:function(i,t){return i>>>t},vZZrV:function(i,t){return i&t},RvWRw:function(i,t){return i&t},nkzvt:function(i,t,r){return i(t,r)},BtDbh:"bQHbc",jvnVq:"OPEN_ERROR",fovyF:"CONNECTI"+n(1241),UdyYx:n(453)+n(525),zCKkV:"MAX_RETRIES_ERROR",QgHud:"NATIVE_E"+n(1561),seKAP:function(i,t){return i>=t},yRlpz:function(i,t){return i>t},xOAwj:n(454),ICtUt:function(i,t){return i instanceof t},bmOuN:"Unhandle"+n(1401),XiNhx:function(i,t){return i+t},iLJGk:function(i,t){return i+t},rtsjY:"aIMLS",FOkzn:function(i,t){return i===t},xzNtr:n(475),GvJPZ:n(354),ftZdL:n(653),UWYMD:function(i,t,r){return i(t,r)},nJtwL:function(i,t){return i&t},QxUsA:function(i,t){return i>>t},aECEu:"error",ADyBw:function(i,t){return i===t},RDjdD:n(1844),TbTkT:n(645),oIVZi:function(i,t,r){return i(t,r)},VqBRA:"vijLY",LLHjX:function(i,t,r){return i(t,r)},fQnBD:function(i,t){return i===t},DzoBz:n(686),RRaZj:function(i,t){return i+t},rqkNL:n(1500),ZCsBG:n(1388),iHisP:n(947),bwUmX:function(i,t,r,a){return i(t,r,a)},RILRY:n(1619),GlplT:function(i,t){return i||t},NzRNu:function(i,t){return i!=t},zHeZL:function(i,t){return i||t},rlZQy:n(560)+n(507)+n(1411)+n(1635)+n(762),hVVKi:function(i,t){return i===t},gwbPE:function(i,t){return i<t},GtbPo:n(1245),BkkAy:function(i,t){return i&t},FOsJP:function(i,t){return i===t},OInut:function(i,t){return i+t},HIHYQ:n(1760),hBXBb:function(i,t){return i!==t},lICfd:n(1530),ZDxzn:n(1324),oVaxF:function(i,t){return i<t},TFMBW:function(i,t){return i|t},NypOp:function(i,t){return i&t},TIvkK:function(i,t){return i&t},nYooi:function(i,t){return i-t},hJKBJ:function(i,t){return i|t},qGsFe:function(i,t){return i|t},cDySw:function(i,t){return i&t},loAmy:function(i,t){return i<<t},lDqpo:function(i,t){return i&t},DdVTt:function(i,t){return i&t},EeoJh:function(i,t){return i&t},tckSE:function(i,t){return i<t},KALRk:function(i,t){return i|t},KgRPk:function(i,t){return i|t},ZhlOL:function(i,t){return i&t},PNrrm:function(i,t){return i===t},kUfco:n(879)+n(1183),dTUeE:function(i,t){return i|t},AwCDf:function(i,t){return i>>t},KzGaK:function(i,t){return i&t},JVgAl:function(i,t){return i|t},ZyFKx:function(i,t){return i>>t},CxcXO:function(i,t){return i|t},wKxXD:function(i,t){return i-t},ERYPO:function(i,t){return i instanceof t},SKxqc:function(i,t,r){return i(t,r)},pVJou:"VllRl",qhCxJ:n(1398),nAntd:function(i,t){return i!=t},hcXUZ:n(780),goLFZ:"applicat"+n(421),DhKOi:n(843),nfYwb:n(605),KsToQ:n(1767),zTSFV:"script",zMImd:n(1005)+n(1141),yQYwX:n(1412),AWPPr:function(i,t){return i>>t},KNIpp:function(i,t){return i&t},Ikmbu:function(i,t){return i&t},cQxEV:function(i,t){return i>>t},RiMQQ:function(i,t){return i===t},UCWpS:"irEJL",BHMWf:function(i,t,r){return i(t,r)},mfrxz:n(1042),yqGSA:n(692),JVSwq:function(i,t,r,a){return i(t,r,a)},phfIO:function(i,t,r){return i(t,r)},gwsJY:function(i,t){return i!==t},xpyFS:n(519),hvhob:n(448),QjRxu:n(1267),nclLP:n(1827),SSUkQ:n(1096),KQakv:function(i,t){return i(t)},EzQjt:"unknown "+n(767),SgupU:n(724)+n(1400)+"tierJSONP",zEvbz:n(360),zZnga:n(809),UWJyC:n(1375),OFdmI:function(i,t){return i===t},JeTnA:n(1095),xxdcL:n(372),jCuRQ:n(1826),IyOud:n(773),piIcl:function(i,t){return i||t},MKATk:function(i,t){return i!==t},HKxkz:n(943),tdTNm:"UAtLh",nVXFa:n(666),hktMy:function(i,t){return i||t},udQMj:function(i,t){return i||t},xTuZu:"online",yuwtg:n(1011),KiYYX:n(639),IxWeP:function(i,t){return i!==t},ZdjIb:n(1857),VHudK:function(i,t){return i||t},dyjAA:function(i,t){return i||t},DFVWo:function(i,t){return i||t},BtwMy:function(i,t){return i||t},gJusw:function(i,t){return i!=t},OCzus:n(1064)+"DB failed",VGbyl:function(i,t){return i<t},IhIIC:function(i,t){return i|t},jQKhI:function(i,t){return i&t},ddEvj:function(i,t){return i&t},pulld:function(i,t){return i+t},DVCEY:n(1701)+n(1528),RnXOe:function(i,t){return i|t},khkyl:function(i,t){return i+t},rfJtN:function(i,t){return i<<t},QGmvc:function(i,t){return i>>t},GeDzI:function(i,t){return i!==t},qFwxS:function(i,t){return i!==t},gcTHk:"TfVrw",Dnzna:function(i,t,r){return i(t,r)},ZNlRp:function(i,t){return i+t},SfjOu:n(1256),qffni:n(766)+"er_qos",rcvNj:"x_fronti"+n(434)+"ck",CHdDw:n(766)+n(1361)+"k",vRwxQ:n(766)+n(1719)+"sgid",vBnbv:function(i,t,r,a){return i(t,r,a)},WnMAJ:function(i,t,r,a){return i(t,r,a)},dxEAD:n(1610),AIZKZ:function(i,t){return i&&t},csoui:n(1396),gXiJS:n(1685),BuZlF:function(i,t){return i(t)},GPKdx:function(i,t){return i(t)},RFITC:n(1430),EAnJc:n(1644)+"e",yQzjV:n(880),Bjsxj:function(i,t,r,a){return i(t,r,a)},DVoLU:function(i,t){return i<t},xVcNs:function(i,t){return i(t)},nOFQn:function(i,t){return i(t)},qVZjB:function(i,t){return i+t},VaXWs:function(i,t){return i|t},QvQEv:function(i,t){return i(t)},EsglC:function(i,t){return i+t},cEXsN:function(i,t){return i+t},HGUdr:function(i,t){return i+t},vYdod:n(1037)+n(1795)+n(727),eACkS:" > ",sZyXc:function(i,t){return i&t},guosx:function(i,t){return i&t},SqLkI:function(i,t){return i>>>t},QbbFZ:function(i,t){return i>t},Rpnpv:function(i,t){return i&t},jHHXa:n(867),DTggX:"aZvzO",SfYUW:function(i,t){return i+t},jMWZJ:function(i,t){return i<t},JVJSa:function(i,t){return i<<t},xNSHO:n(572)+"2",kZehq:function(i,t){return i+t},yWYYO:function(i,t){return i|t},lHThr:function(i,t){return i<<t},tgUUh:function(i,t){return i<<t},uWuJE:function(i,t){return i+t},TwONO:function(i,t){return i<<t},thPCQ:function(i,t){return i+t},ZsPLg:function(i,t){return i|t},xTznL:function(i,t){return i+t},zoDyT:function(i,t){return i<<t},YmyEk:function(i,t){return i<t},bBIRZ:function(i,t){return i!==t},ZqVWL:n(1824),lhZtw:function(i,t){return i+t},dRrpz:function(i,t){return i+t},gXzNG:function(i,t){return i+t},idego:function(i,t){return i+t},bccqw:function(i,t){return i&t},pLREC:function(i,t){return i>>>t},Lxtwf:function(i,t){return i&t},JvSij:function(i,t){return i&t},ErAwn:function(i,t){return i&t},iIySO:function(i,t){return i+t},pgLHF:function(i,t){return i&t},RmYTO:function(i,t){return i>>>t},wBAMm:function(i,t){return i|t},zuxtw:function(i,t){return i<t},gGLZh:n(873),iHpzG:function(i,t){return i===t},NNGcK:"EePNa",TxqnM:n(520)+"1",bYeLU:function(i,t){return i||t},ImUsh:function(i,t){return i!==t},zlFyX:n(1870),DbcIB:n(1249),jmQQC:function(i,t){return i(t)},gyrKf:function(i,t){return i+t},TtXec:n(1657),gfVNk:function(i,t,r,a){return i(t,r,a)},wXcHc:function(i,t,r,a){return i(t,r,a)},nsKcZ:n(1285)+n(1687),mbEjz:"curvalue",prGPZ:n(1172),RMldZ:function(i,t){return i(t)},WTLJJ:function(i,t){return i(t)},kSdPM:n(1527)+n(1622),KboaM:function(i,t,r){return i(t,r)},WXWWb:n(1125)+n(1609),nlMhl:"UoJqw",asZoN:"cursor_name",yyEcH:function(i,t){return i===t},fztkh:n(1862),bWFcl:n(609)+n(1614),tHxSM:n(919),KPAxj:n(806),wiHsq:n(1847),DycPj:n(1671),naxxZ:function(i,t){return i(t)},GkpfA:n(760)+"r",tnTWq:function(i,t){return i||t},GEKRT:"code",UTNFz:"x_fronti"+n(1199),riMSA:n(766)+n(1630),YXizD:function(i,t,r){return i(t,r)},VjOwT:n(1768)+n(1317)+"e",pOTGq:function(i,t){return i(t)},NKTar:n(1768)+n(1702)+"ue",Aolhg:function(i){return i()},Vwqqg:function(i,t){return i+t},kZOSa:function(i){return i()},SwCSY:function(i,t){return i===t},rHmpN:n(1177),zQouT:n(1127),CjBOh:function(i){return i()},wJHkk:function(i,t){return i===t},avVMr:function(i,t){return i===t},iykGI:function(i,t){return i(t)},GwlVS:function(i,t){return i(t)},aFAfl:function(i){return i()},inURo:function(i,t){return i!==t},QLyyN:function(i){return i()},bynZt:function(i){return i()},HfagZ:n(1746),pZSUc:function(i,t,r){return i(t,r)},ZMZMF:"uegoW",tfCjJ:n(1749),cidcK:function(i,t,r){return i(t,r)},QtAaN:n(817),DEnEV:function(i,t){return i!==t},EliHt:function(i,t){return i(t)},Nhbxl:function(i,t,r){return i(t,r)},EUXUD:"always",jmQSz:function(i,t){return i===t},QebgA:n(1478),mnrQw:n(1707)+"e_success",MODcB:n(423),AfGWr:function(i,t,r){return i(t,r)},jvbye:"arraybuf"+n(973),wDCds:n(1645),eewcl:function(i,t){return i/t},MTLTl:"please p"+n(397)+"alid url",lNLNI:n(420)+n(1604)+n(730)+n(761)+n(1473)+"tructor "+n(1807)+n(1156),tCeGh:n(1345),GIznB:function(i,t,r){return i(t,r)},nzKRb:n(1229)+n(1132)+" reconnect",LCRsD:function(i,t){return i&t},tLHxY:function(i,t){return i&t},lROVC:function(i,t){return i&t},CaKSw:function(i,t){return i>>>t},iPiah:n(1069),wiJtj:n(881),xtZCL:n(1868),SgyOv:function(i,t,r){return i(t,r)},dZVdN:function(i,t){return i!==t},FGJTS:function(i,t){return i!==t},Eoylv:n(1251),odeSX:"wss://",KVyxm:n(1603),YNhNC:n(359),bbdMc:n(1544),UEiQd:n(369)+"d",USHRV:function(i,t){return i||t},zvfYh:"please p"+n(500)+"ddID, de"+n(1264)+n(693),OIJPw:n(580),ZvRIN:function(i){return i()},FAcSN:function(i,t,r){return i(t,r)},iDzcu:n(1782)+"0",bVWKA:function(i,t){return i>>>t},AyBcV:function(i,t){return i&t},TvdoF:function(i,t){return i+t},zmebF:function(i,t){return i|t},ZzCuC:function(i,t,r){return i(t,r)},bMbxq:function(i,t){return i!==t},OIOyD:n(1842),uPpSh:function(i,t,r){return i(t,r)},rTQQL:"reconnect",pHWAb:n(1744),GqOoY:function(i,t){return i===t},hnLNZ:n(338),XfVFI:function(i,t){return i(t)},LpDlr:function(i,t){return i(t)},SeUek:n(1240)+">",TsLMX:function(i,t){return i-t},TjeNx:function(i,t){return i!==t},EjzDI:n(473),MJllh:n(682),WSXFQ:n(1015)+n(1822)+"reconnec"+n(714)+"ver",UwdLy:function(i,t,r){return i(t,r)},MhLGn:n(490),igMTM:n(1281)+n(1221)+n(1472)+"g",TsKjY:n(998),VeNVz:n(982)+"1",cGBBe:function(i,t){return i(t)},IWJLM:function(i,t){return i<<t},dRUQY:n(564),zfHrM:function(i,t,r){return i(t,r)},GvxcB:function(i,t,r){return i(t,r)},vdgJN:n(1351),absqi:n(1586),xOgyb:n(1357),FlCvz:n(511),YUcUU:n(1616)+n(570)+n(737)+n(1422)+"ed",MOHhu:function(i,t){return i===t},TNZUv:function(i,t){return i===t},BKxKo:"close, w"+n(646)+n(616),ktVnG:function(i,t){return i||t},bEtdi:function(i,t){return i!=t},yZKog:function(i,t){return i==t},jaRKL:n(420)+n(1145)+n(1426)+n(481)+n(1787)+n(450)+n(1515)+n(1693)+n(492),aPBdQ:function(i,t){return i==t},PWIWz:n(1735),kCupx:function(i,t){return i instanceof t},ymeNf:function(i,t){return i(t)},XEgbd:function(i,t){return i||t},rSBXv:n(420)+n(1145)+n(1664)+n(1373),nFzKU:function(i,t){return i(t)},CqxGg:"VmZam",EzYHa:n(615),asmEX:n(365),gBify:n(1593),NLUfg:function(i,t){return i||t},QrsxV:n(1621),pjefH:n(1407),yZkey:function(i,t){return i!==t},jfrKq:function(i,t){return i!==t},PtpqL:function(i,t,r){return i(t,r)},Xrogy:function(i,t){return i!==t},JPgUj:n(1499),vyEEl:n(1330),EcoVW:function(i,t){return i===t},ScdhQ:n(1101),AjspV:n(349)+n(1434)+n(718)+"pe",bYvzd:function(i,t){return i===t},rXchv:function(i,t){return i!=t},lNomF:function(i,t){return i!=t},OlVKX:function(i,t){return i===t},DKwWQ:"ServiceWorkerGlobalScope",TnxoY:function(i,t){return i!=t},zRVcY:function(i,t){return i===t},OuQNq:function(i,t){return i===t},xAxzI:function(i,t){return i!=t},gXGXp:function(i,t){return i!=t},fJYFn:function(i,t,r){return i(t,r)},rBnQP:n(1342)+n(1570)};Ge.r(ie),Ge.d(ie,{FWS:()=>M0,CustomErrorEvent:()=>ts,createCloseEvent:()=>Re,ReconnectEvent:()=>es,createErrorEvent:()=>Ce,decodedFrame:()=>yt,createOpenEvent:()=>as,CustomCloseEvent:()=>ns,createReconnectEvent:()=>Or,FrontierMessageEvent:()=>is,encodeFrame:()=>oe,createMessageEvent:()=>os,OpenEvent:()=>ss,ErrorCode:()=>rt,Event:()=>St,MessageEvent:()=>rs});let s="";function o(i=""){let t=n,r="02",a=""+Date[t(629)](),d=s||(s=e.ZofXP(g,i)),l=Math[t(1526)]().toString(16)[t(1522)](-6);return e[t(1085)](e[t(1085)](r+a,d),l)}function c(){let i=n;return e[i(1085)](e[i(669)](1e4,Date[i(629)]()),Math.floor(e.QAjiQ(1e4,Math.random())))}function x(i){let t=n;if(t(375)===t(375))return e[t(1417)](Array(8)[t(491)]("0"),e[t(778)](parseInt,i,10).toString(2))[t(1522)](-8);{let r={scJvR:function(a,d){let l=t;return WrpgGZ[l(853)](a,d)}};_0x1d9924[t(877)+t(691)](t(779)+"eeded",a=>{let d=t;_0x1182dd(r[d(1520)](_0xe8f481,_0x3400ae[d(1872)]),a[d(1794)+"on"],a[d(1758)+"on"],_0x179f3a(_0x444963["transact"+d(802)]))})}}function u(i){let t=n;if(e[t(759)](t(513),"algCC"))++_0x7dc407,_0x1ecfd1+=4;else return e[t(926)](e.PVrBh(Array,4)[t(491)]("0"),e[t(778)](parseInt,i,2)[t(719)](16))[t(1522)](-4)}function f(i){let t=n,r=i[t(1484)](/\./)[t(1207)](l=>x(l)),a=[];return a[0]=e[t(853)](u,e[t(410)](r[0],r[1])),a[1]=e.yBpgc(u,e[t(1417)](r[2],r[3])),[e[t(1196)],"0000",e[t(1196)],e.qNQWD,t(1206),t(1500),a[0],a[1]][t(491)]("")}function g(i){let t=n;if(e[t(1098)]("hDgJK",t(1743))){let r=this[t(1353)][t(1190)](this[t(1559)]),a=_0x590f97[t(1818)](r||"{}");return _0x5aec24[t(788)](a)}else{let r=/(25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?)(\.(25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?)){3}/[t(944)](i),a=/(([0-9a-fA-F]{1,4}:){7,7}[0-9a-fA-F]{1,4}|([0-9a-fA-F]{1,4}:){1,7}:|([0-9a-fA-F]{1,4}:){1,6}:[0-9a-fA-F]{1,4}|([0-9a-fA-F]{1,4}:){1,5}(:[0-9a-fA-F]{1,4}){1,2}|([0-9a-fA-F]{1,4}:){1,4}(:[0-9a-fA-F]{1,4}){1,3}|([0-9a-fA-F]{1,4}:){1,3}(:[0-9a-fA-F]{1,4}){1,4}|([0-9a-fA-F]{1,4}:){1,2}(:[0-9a-fA-F]{1,4}){1,5}|[0-9a-fA-F]{1,4}:((:[0-9a-fA-F]{1,4}){1,6})|:((:[0-9a-fA-F]{1,4}){1,7}|:)|fe80:(:[0-9a-fA-F]{0,4}){0,4}%[0-9a-zA-Z]{1,}|::(ffff(:0{1,4}){0,1}:){0,1}((25[0-5]|(2[0-4]|1{0,1}[0-9]){0,1}[0-9])\.){3,3}(25[0-5]|(2[0-4]|1{0,1}[0-9]){0,1}[0-9])|([0-9a-fA-F]{1,4}:){1,4}:((25[0-5]|(2[0-4]|1{0,1}[0-9]){0,1}[0-9])\.){3,3}(25[0-5]|(2[0-4]|1{0,1}[0-9]){0,1}[0-9]))/[t(944)](i);return r?e.nCKou(f,i):a?e[t(1370)](m,i):t(1447)+t(1447)+t(1447)+t(1447)}}function m(i){let t=n,r="",a=[],d=0,l=0,p=!0,w="0000";if(e[t(1720)](i[t(395)]("::"),-1)){let h=i[t(1484)]("::");for(let v=0;e.KgkrS(v,h[t(1397)]);v++){let D=h[v];if(D[t(395)](":")>0){let N=D[t(1484)](":");p&&(d=N[t(1397)]),l+=N[t(1397)];for(let O=0;e[t(603)](O,N[t(1397)]);O++)if(e.MVZVv(4,N[O][t(1397)])){let Y=w[t(1269)+"g"](0,4-N[O].length),ee=Y.concat(N[O]);a[t(1258)](ee)}else a[t(1258)](N[O]);p=!1}else if(e[t(403)](e[t(556)],t(991))){let N=_0xe6ea82.bytes,O=_0x63798b.limit;return e.vCPBB(N[t(1397)],O)?N:N[t(1169)](0,O)}else{if(D[t(1397)]!==4){let N=w[t(1269)+"g"](0,e[t(1077)](4,D.length)),O=N.concat(D);a[t(1258)](O)}else a.push(D);p&&(d+=1),l+=1,p=!1}}let S="";for(let v=0;e[t(1501)](v,e[t(1734)](8,l));v++)S=S[t(1889)](w);for(let v=0;v<a[t(1397)];v++)e[t(1098)](v,d)?(r=r[t(1889)](S),r=r[t(1889)](a[v])):r=r.concat(a[v]);return r}{let h=i.split(":");for(let S=0;e[t(934)](S,h[t(1397)]);S++){let v=h[S];if(e[t(512)](4,h[S][t(1397)]))if(e[t(1562)]!==e[t(1562)])e.ZuoiG(_0x319ff1,_0x54ee9b,58),e[t(931)](_0x49c7c6,_0x301f39,_0x10f134);else{let D=w[t(1269)+"g"](0,e.Gcoqy(4,h[S][t(1397)])),N=D[t(1889)](v);r=r[t(1889)](N)}else r=r.concat(v)}return r}}function y(i,t){let r=n,a=i.key;e[r(971)](void 0,a)&&(J(t,10),e[r(1860)](pe,t,a));let d=i[r(797)];e[r(1099)](void 0,d)&&(e[r(778)](J,t,18),e.upKgF(pe,t,d))}function _(i){let t=n,r={};e:for(;!_e(i);){let a=e[t(350)](Q,i);switch(e[t(1109)](a,3)){case 0:break e;case 1:r[t(841)]=ne(i,e.yBpgc(Q,i));break;case 2:r[t(797)]=ne(i,Q(i));break;default:e[t(470)](j,i,e[t(1394)](7,a))}}if(e[t(1161)](void 0,r[t(841)]))throw new Error(e.CGJIF);if(e.RQviq(void 0,r[t(797)]))throw new Error(e[t(1732)]);return r}function E(i){let t=n,r=e[t(1763)](W);return e[t(470)](C,i,r),e[t(1740)](De,r)}function C(i,t){let r=n,a={rDGKr:function(te,Z){return e[T(1745)](te,Z)}},d=i[r(1716)];d!==void 0&&(e[r(1449)](J,t,8),e[r(778)]($,t,d));let l=i.LogID;e.MVZVv(void 0,l)&&(e[r(778)](J,t,16),$(t,l));let p=i.service;if(e[r(915)](void 0,p))if(e[r(1228)](r(438),e[r(1529)])){let te=_0x5cbd95.substring(0,SHRMRv[r(648)](4,_0x38f824[r(1397)])),Z=te[r(1889)](_0x201d49);_0xc7c45[r(1258)](Z)}else e[r(1860)](J,t,24),$(t,H(p));let w=i[r(1283)];e[r(1054)](void 0,w)&&(e[r(1328)](J,t,32),e.upKgF($,t,e[r(1254)](H,w)));let h=i.headers;if(h!==void 0)for(let te of h){e[r(968)](J,t,42);let Z=e[r(1763)](W);y(te,Z),e.opybm(J,t,Z.limit),je(t,Z),he(Z)}let S=i.payloadEncoding;e[r(1054)](void 0,S)&&(e[r(1449)](J,t,50),e[r(1449)](pe,t,S));let v=i[r(795)+r(657)];e[r(1099)](void 0,v)&&(J(t,58),e[r(533)](pe,t,v));let D=i[r(1751)];e[r(447)](void 0,D)&&(e.EKNss(J,t,66),e.TtvdS(J,t,D[r(1397)]),e[r(772)](be,t,D));let N=i[r(796)];N!==void 0&&(e[r(517)](J,t,74),pe(t,N));let O=i.serverTiming;e[r(1099)](void 0,O)&&(e[r(1234)](J,t,82),e[r(1247)](pe,t,O));let Y=i[r(739)];Y!==void 0&&(e[r(1161)](e[r(1785)],e.rZSBv)?this["currentE"+r(747)+r(367)+"t"]=0:(J(t,90),e[r(1503)](pe,t,Y)));let ee=i[r(1195)+"e"];e[r(805)](void 0,ee)&&(e.ZuoiG(J,t,96),e[r(1503)]($,t,e[r(853)](H,ee)))}function I(i){let t=n;return e[t(1128)](P,e[t(853)](ye,i))}function P(i){let t=n,r={};e:for(;!e[t(350)](_e,i);)if(e[t(845)]!==t(1803)){let a=e[t(1370)](Q,i);switch(e.dcxqQ(a,3)){case 0:break e;case 1:r[t(1716)]=e[t(1134)](ft,i,!0);break;case 2:r[t(709)]=e[t(414)](ft,i,!0);break;case 3:r[t(1172)]=Q(i);break;case 4:r[t(1283)]=e.vWBSF(Q,i);break;case 5:{let d=e.nCKou(B,i);(r.headers||(r.headers=[]))[t(1258)](_(i)),i.limit=d;break}case 6:r[t(696)+t(972)]=e[t(1162)](ne,i,e[t(1780)](Q,i));break;case 7:r[t(795)+t(657)]=e[t(1113)](ne,i,e.YySYo(Q,i));break;case 8:r[t(1751)]=e[t(931)](z,i,Q(i));break;case 9:r[t(796)]=e[t(732)](ne,i,e[t(1057)](Q,i));break;case 10:r[t(1203)+t(1576)]=e[t(1155)](ne,i,e.ZofXP(Q,i));break;case 11:r.msgID=ne(i,e.YySYo(Q,i));break;case 12:r.frameType=e[t(903)](Q,i);break;default:e[t(470)](j,i,e.Prrrr(7,a))}}else WrpgGZ.nCKou(_0x167f20,_0x2bf18e[t(1326)]),WrpgGZ[t(1763)](_0x383d13);if(e[t(1590)](void 0,r[t(1716)]))throw new Error(e[t(1752)]);if(e[t(1228)](void 0,r.LogID))throw new Error(e[t(578)]);if(e[t(415)](void 0,r.service))throw new Error(e.PvtWi);if(e[t(1098)](void 0,r[t(1283)]))throw new Error(t(1810)+t(1322)+t(1416)+t(1283));return r}function B(i){let t=n;if(t(1029)===e[t(1091)]){let r=e[t(350)](Q,i),a=i[t(1802)];return i[t(1802)]=e[t(1729)](i[t(446)],r),a}else this[t(835)+t(1348)+"line"]=_0x5dfc12,_0x30851c?this[t(1424)+t(1731)]():this[t(1424)+t(715)]()}function j(i,t){let r=n;switch(t){case 0:for(;e[r(1394)](128,e.uliqy(se,i)););break;case 2:e[r(1134)](ue,i,e[r(1254)](Q,i));break;case 5:e[r(968)](ue,i,4);break;case 1:ue(i,8);break;default:throw new Error(e[r(410)](e[r(1666)],t))}}function H(i){let t=n;return i|=0,{low:i,high:e.JqZRN(i,31),unsigned:e[t(721)](i,0)}}let ce=[];function W(){let i=n,t=ce[i(416)]();return t?(t[i(446)]=t.limit=0,t):{bytes:new Uint8Array(64),offset:0,limit:0}}function he(i){let t=n;e.GUzbe(e[t(1211)],e[t(1211)])?(WrpgGZ[t(1763)](_0x5790a9),_0xfaf224()):ce[t(1258)](i)}function ye(i){return{bytes:i,offset:0,limit:i.length}}function De(i){let t=n,r=i[t(504)],a=i[t(1802)];return e[t(461)](r[t(1397)],a)?r:r.subarray(0,a)}function ue(i,t){let r=n;if(e[r(1188)](i[r(446)],t)>i[r(1802)])throw new Error(e.CHhkT);i[r(446)]+=t}function _e(i){let t=n,r={Itndc:function(a,d){return e.HCpOs(a,d)},dNpqP:function(a,d){return a+d},uZzPt:function(a,d){return e.ymbeb(a,d)},OBtXI:function(a,d){return e[T(1354)](a,d)},NgOIl:function(a,d){return e[T(581)](a,d)},IoXcP:function(a,d){return e[T(963)](a,d)},eaMjm:function(a,d){return e[T(1117)](a,d)},EIYJS:function(a,d){return e.dcxqQ(a,d)}};if(e[t(494)](e[t(642)],e.pXohc))return e[t(749)](i[t(446)],i.limit);{let a=_0x1867a0[t(612)],d=_0x1b8a7c[t(1626)];return _0x2ff5ce[_0x498f15]=r[t(566)](d,24),_0x221172[r[t(1126)](_0x30a128,1)]=r[t(813)](d>>>16,255),_0x4338e9[r[t(1418)](_0x110a84,2)]=d>>>8&255,_0x346b1a[r[t(1483)](_0x41a828,3)]=r[t(813)](255,d),_0x3a775a[r[t(1126)](_0x1276b1,4)]=r[t(1160)](a,24),_0x547587[_0x11856d+5]=r[t(813)](r[t(1320)](a,16),255),_0x58ce47[r[t(1418)](_0x2919b6,6)]=r.uZzPt(r.EIYJS(a,8),255),_0xbe6c9c[_0x522f75+7]=255&a,_0x149083+=8,_0x10c6dd}}function A(i,t){let r=n,a=i[r(504)],d=i[r(446)],l=i.limit,p=e[r(1354)](d,t);if(e[r(1720)](p,a[r(1397)])){let w=new Uint8Array(e.USSeJ(2,p));w.set(a),i[r(504)]=w}return i[r(446)]=p,p>l&&(i[r(1802)]=p),d}function L(i,t){let r=n,a=i[r(446)];if(e[r(435)](e[r(581)](a,t),i.limit))throw new Error(e[r(1764)]);return i[r(446)]+=t,a}function z(i,t){let r=n;if(e[r(1110)]!==e[r(1110)]){if(!this[r(783)+r(582)]){let a=(r(751)+"2")[r(1484)]("|"),d=0;for(;;){switch(a[d++]){case"0":this[r(371)]=!0;continue;case"1":this[r(1088)+"sCounter"]?.[r(1852)+"nter"]();continue;case"2":this._connect();continue;case"3":this[r(334)+"tManager"]?.[r(801)+r(1582)+r(1680)]();continue;case"4":this["_readyCl"+r(1390)]=!1;continue}break}}}else{let a=e[r(826)](L,i,t);return i[r(504)][r(1169)](a,a+t)}}function be(i,t){let r=n,a=A(i,t[r(1397)]);i.bytes.set(t,a)}function ne(i,t){let r=n,a=e[r(1123)](L,i,t),d=String[r(741)+r(1643)],l=i[r(504)],p="\uFFFD",w="";for(let h=0;e[r(1130)](h,t);h++){let S=l[h+a],v,D,N,O;e[r(1098)](128&S,0)?w+=e.EBxUy(d,S):e[r(1228)](224&S,192)?e[r(721)](e[r(581)](h,1),t)?w+=p:(v=l[e[r(1354)](e.RlScY(h,a),1)],e.Prrrr(192,v)!==128?w+=p:(O=e[r(1759)](e.dwzqu(31,S),6)|e[r(1394)](63,v),O<128?w+=p:(w+=d(O),h++))):e.mQKcO(240&S,224)?e[r(1808)](e[r(1417)](h,2),t)?w+=p:(v=l[e.Ruoqi(h,a)+1],D=l[e[r(1729)](e[r(823)](h,a),2)],e[r(562)](e[r(530)](v,e[r(1272)](D,8))&49344,32896)?w+=p:(O=e.ECzhk(e[r(506)](e[r(896)](15,S)<<12,e[r(914)](63,v)<<6),e[r(1762)](63,D)),O<2048||O>=55296&&e[r(1314)](O,57343)?w+=p:e[r(915)](e[r(1116)],e[r(1116)])?_0x3a1411.log(_0x3c0a79):(w+=e[r(933)](d,O),h+=2))):e[r(1553)](e[r(599)](248,S),240)?e[r(1381)](e[r(1032)](h,3),t)?w+=p:(v=l[e[r(1417)](h+a,1)],D=l[e[r(907)](e[r(811)](h,a),2)],N=l[e[r(1358)](e[r(1487)](h,a),3)],e.fFTXT(e[r(1762)](e[r(860)](v,e[r(1713)](D,8))|e[r(1272)](N,16),12632256),8421504)?w+=p:(O=e[r(506)](e[r(1296)](e[r(593)](e.bxcsm(7,S),18)|e[r(627)](e[r(1762)](63,v),12),e[r(1272)](63&D,6)),e[r(1331)](63,N)),e[r(857)](O,65536)||e[r(402)](O,1114111)?w+=p:(O-=65536,w+=e.nBlBA(d,e[r(1076)](O,10)+55296,e[r(1268)](e[r(1394)](1023,O),56320)),h+=3))):w+=p}return w}function pe(i,t){let r=n,a=t.length,d=0;for(let w=0;e[r(603)](w,a);w++){let h=t[r(1333)+"At"](w);e[r(1808)](h,55296)&&e[r(368)](h,56319)&&e.ZiYOn(w+1,a)&&(h=e[r(1734)](e[r(928)](e[r(1696)](h,10),t[r(1333)+"At"](++w)),56613888)),d+=e[r(1130)](h,128)?1:e.Wxigu(h,2048)?2:e[r(603)](h,65536)?3:4}J(i,d);let l=A(i,d),p=i.bytes;for(let w=0;w<a;w++)if(e[r(1122)]==="Cpcpd"){let h=t[r(1333)+"At"](w);e[r(1808)](h,55296)&&e.kdJSK(h,56319)&&e.AFhJA(w,1)<a&&(h=e[r(1734)](e.XXPAD(e[r(1272)](h,10),t.charCodeAt(++w)),56613888)),e[r(1885)](h,128)?p[l++]=h:(e.sVfFZ(h,2048)?p[l++]=e[r(595)](e[r(914)](e.ltxQu(h,6),31),192):(h<65536?p[l++]=e.NzlCF(e[r(896)](h>>12,15),224):(p[l++]=e.uCpUQ(e[r(720)](h,18)&7,240),p[l++]=e[r(595)](e[r(914)](e[r(1395)](h,12),63),128)),p[l++]=e[r(1395)](h,6)&63|128),p[l++]=e[r(1637)](e[r(1600)](63,h),128))}else e.fhYOc(_0x37c909,_0x5259e6,82),_0xc67a61(_0x343847,_0x4e3511)}function je(i,t){let r=n,a=e[r(470)](A,i,t[r(1802)]),d=i[r(504)],l=t[r(504)];for(let p=0,w=t.limit;e[r(1856)](p,w);p++)d[p+a]=l[p]}function se(i){let t=n;if(e.MVZVv(e[t(1718)],e[t(974)]))return i[t(504)][e[t(390)](L,i,1)];this["_pingLos"+t(1392)]?.addCount(),this[t(667)](e[t(670)],e[t(822)]),this[t(1088)+t(1392)]?.[t(1881)+"chMaxCount"]()?this[t(1580)+"econnect"]():this[t(652)]()}function et(i,t){let r=n;if(e[r(1149)]("uuDkz",e[r(1534)])){if(e.HFNBA(_0x48833e,-_0x4201b4))return _0x57158d;if(e[r(1567)](e[r(1276)](_0x251353,1),_0x37b639))return _0x1847a0}else{let a=e[r(968)](A,i,1);i.bytes[a]=t}}function Q(i){let t=n,r=0,a=0,d;do d=e[t(903)](se,i),e[t(497)](r,32)&&(a|=e.dwzqu(127,d)<<r),r+=7;while(e.ukkjE(128,d));return a}function J(i,t){let r=n;if(e[r(805)](r(870),r(870))){let a=this[r(334)+"tManager"]?.["getCurre"+r(1725)+"nt"]();this[r(902)+r(1046)+r(790)](e.kvkJr(_0x1970d4,r(475),{code:_0x1339e5[r(1599)],reason:"connecti"+r(1596)+r(1089)+r(424)+"n, hostname: "+a})),this[r(334)+r(1261)]?.resetEndpointConfig(),this[r(1088)+r(1392)]?.[r(1852)+"nter"]();return}else{for(t>>>=0;e[r(1474)](t,128);)e[r(1786)](et,i,e[r(1629)](e[r(896)](127,t),128)),t>>>=7;et(i,t)}}function ft(i,t){let r=n,a=0,d=0,l=0,p;if(p=e[r(1097)](se,i),a=127&p,e[r(575)](128,p))if(e[r(685)](e[r(1556)],e.HlcTR)){if(p=e[r(1147)](se,i),a|=e[r(1759)](e[r(1242)](127,p),7),128&p&&(p=se(i),a|=e[r(1139)](127&p,14),128&p&&(p=e.VTsSl(se,i),a|=e.YelkJ(e[r(1512)](127,p),21),128&p&&(p=se(i),d=e[r(839)](127,p),e[r(1331)](128,p))))){if(e[r(466)](e[r(1755)],r(1689)))return _0x3d30b8||(_0x970b76=_0x3d02e5[r(828)]().then(_0x463d9c[r(389)](_0x200818,e.kySyF))),_0x26d224;p=e[r(1263)](se,i),d|=e[r(593)](127&p,7),e[r(1394)](128,p)&&(p=e[r(549)](se,i),d|=e.FGVGO(e[r(352)](127,p),14),e[r(1242)](128,p)&&(p=e[r(1813)](se,i),d|=e[r(1713)](e[r(1737)](127,p),21),e[r(914)](128,p)&&(p=se(i),l=e[r(1512)](127,p),128&p&&(p=e.BMbON(se,i),l|=e[r(1139)](e.TdVnp(127,p),7)))))}}else return _0x38effe[r(348)+"8"]?{value:_0x541ecf[r(348)+"8"](_0x536647),offset:_0xbbbfd4+1}:{value:255&_0x144f7a[_0x308846],offset:_0x2882fb+1};return{low:e[r(1270)](a,e.hutBj(d,28)),high:e[r(506)](e[r(1109)](d,4),e[r(1139)](l,24)),unsigned:t}}function $(i,t){let r=n,a=e[r(1109)](t.low,0),d=e[r(1117)](e[r(750)](e[r(1340)](t.low,28),e[r(499)](t[r(1626)],4)),0),l=e[r(484)](t[r(1626)],24),p=e.RUNrp(0,l)?e[r(403)](0,d)?e[r(934)](a,16384)?a<128?1:2:a<2097152?3:4:e.sVfFZ(d,16384)?e[r(1217)](d,128)?5:6:e[r(752)](d,2097152)?7:8:e[r(1165)](l,128)?9:10,w=e[r(1477)](A,i,p),h=i[r(504)];switch(p){case 10:h[w+9]=e.IYGXO(e.RcpVW(l,7),1);case 9:h[e[r(636)](w,8)]=e[r(1516)](9,p)?e[r(1629)](128,l):e[r(1252)](127,l);case 8:h[w+7]=p!==8?e[r(506)](e.FdIBi(d,21),128):e.VENnJ(d>>>21,127);case 7:h[e[r(1770)](w,6)]=e[r(1709)](7,p)?e.jklVJ(e[r(735)](d,14),128):e[r(505)](e.bzlSu(d,14),127);case 6:h[e[r(850)](w,5)]=e[r(1806)](6,p)?e[r(892)](d,7)|128:e.TsQDn(e.bzlSu(d,7),127);case 5:h[e[r(926)](w,4)]=e[r(915)](5,p)?e[r(1270)](128,d):127&d;case 4:h[e[r(1182)](w,3)]=e[r(493)](4,p)?e[r(892)](a,21)|128:e[r(1512)](e[r(1793)](a,21),127);case 3:h[e[r(1417)](w,2)]=e[r(915)](3,p)?e[r(1270)](e[r(1656)](a,14),128):e[r(1853)](e[r(1509)](a,14),127);case 2:h[e[r(1386)](w,1)]=e[r(805)](2,p)?e[r(1878)](a>>>7,128):e[r(575)](e[r(1340)](a,7),127);case 1:h[w]=p!==1?128|a:127&a}}function yt(i){return e[n(1128)](I,i)}function oe(i){let t=n;if(e[t(805)](e[t(1332)],"Kfuhh"))WrpgGZ.Jcykf(WrpgGZ.azadr,typeof _0x1586d1)&&_0x5cd08d["toString"+t(590)]&&_0x5f7772["definePr"+t(579)](_0x4ebc21,_0x212310[t(719)+t(590)],{value:WrpgGZ[t(697)]}),_0x8f7be5[t(551)+t(579)](_0x2717dd,WrpgGZ[t(1880)],{value:!0});else return E(i)}let bt=65536,ve="\0\0\0\0\0\0\0\0",vt=e[n(1062)](bt,bt),Zi=e[n(1062)](vt,vt),Xi=Zi/2,nt=String[n(544)+"e"][n(1333)+"At"];class K{constructor(t,r,a){let d=n;this[d(728)]=!0,this.low=e[d(798)](0,t),this.high=e[d(884)](0,r),this[d(1366)]=!!a}static[n(728)](t){return t&&e[n(1149)](!0,t.isLong)}static[n(775)](t,r,a){return new K(t,r,a)}static fromBytes(t,r,a){let d=n;return a?K.fromBytesLE(t,r):K[d(1218)+d(477)](t,r)}static[n(1218)+n(755)](t,r){let a=n;return new K(e[a(1663)](e[a(510)](t[0]|e[a(1613)](t[1],8),e[a(347)](t[2],16)),t[3]<<24),e.FPSAf(e.gCfnS(e[a(335)](t[4],t[5]<<8),e[a(1387)](t[6],16)),e[a(1387)](t[7],24)),r)}static[n(1218)+"sBE"](t,r){let a=n;return new K(e[a(480)](t[4]<<24|t[5]<<16,e.zyaMa(t[6],8))|t[7],e.ZPWEt(e.ArhTa(e[a(833)](t[0],24)|e.UdvMm(t[1],16),e[a(1713)](t[2],8)),t[3]),r)}static[n(427)](t){let r=n;return t===ve?Qi:new K(e.mobFi(e[r(798)](e.FPSAf(nt.call(t,0),e[r(704)](nt.call(t,1),8))|e.MaksK(nt[r(392)](t,2),16),nt[r(392)](t,3)<<24),0),e[r(1509)](e[r(1270)](e[r(506)](nt[r(392)](t,4)|e[r(994)](nt[r(392)](t,5),8),e[r(347)](nt[r(392)](t,6),16)),e[r(833)](nt[r(392)](t,7),24)),0),!0)}toHash(){let t=n;return String["fromChar"+t(1643)](e[t(1796)](255,this[t(612)]),e[t(1289)](this[t(612)]>>>8,255),e[t(1789)](e[t(831)](this[t(612)],16),255),e[t(1255)](this.low,24),e.bxcsm(255,this.high),e[t(1839)](e[t(1656)](this.high,8),255),e[t(398)](this.high>>>16,255),this[t(1626)]>>>24)}static fromNumber(t,r=!0){let a=n;if(e[a(1097)](isNaN,t))return r?Vc:Qi;if(r){if(t>=Zi)return Yc}else{if(t<=-Xi)return Zc;if(e[a(1567)](t+1,Xi))return Jc}return K[a(775)](e[a(496)](t,vt)|0,t/vt|0,r)}toNumber(){let t=n;if(e[t(685)](e.ECbtq,e[t(707)])){let r=(t(711)+t(1041)).split("|"),a=0;for(;;){switch(r[a++]){case"0":++_0x240df4;continue;case"1":_0x542fcb[_0x59b524++]=e[t(1185)](e[t(896)](63,_0x2d85b7),128);continue;case"2":_0x141285[_0xbb85a2++]=e[t(1762)](_0x202f18>>12,63)|128;continue;case"3":_0x2a1c14=e[t(926)](65536+((1023&_0x595a14)<<10),e.oyvbt(1023,_0x3847ed));continue;case"4":_0x3373cd[_0x1731cb++]=e[t(1394)](e[t(1421)](_0x290079,6),63)|128;continue;case"5":_0xc35526[_0x602e63++]=e[t(674)](_0x3cd1ab>>18,240);continue}break}}else return this[t(1366)]?e[t(1791)](e.Yxlma(this[t(1626)],0)*vt,e.XYnet(this[t(612)],0)):e[t(581)](this[t(1626)]*vt,this[t(612)]>>>0)}isZero(){let t=n;return e[t(466)](t(1684),t(439))?e[t(494)](0,this.high)&&e[t(1588)](0,this[t(612)]):this[t(1204)][t(1519)]}[n(695)](t){let r=n;K[r(728)](t)||(t=K[r(1215)+"er"](t));let a=e[r(1227)](this.high,16),d=e[r(1568)](65535,this.high),l=this[r(612)]>>>16,p=e[r(1284)](65535,this[r(612)]),w=t[r(1626)]>>>16,h=e[r(1521)](65535,t[r(1626)]),S=e.jJlei(t[r(612)],16),v=e.ElHXq(65535,t[r(612)]),D=0,N=0,O=0,Y=0;return Y+=e[r(926)](p,v),O+=e[r(825)](Y,16),Y&=65535,O+=l+S,N+=e[r(1545)](O,16),O&=65535,N+=d+h,D+=e[r(1854)](N,16),N&=65535,D+=e[r(1055)](a,w),D&=65535,K[r(775)](e[r(656)](e[r(1584)](O,16),Y),e[r(656)](e[r(1713)](D,16),N),this[r(1366)])}[n(342)](t){let r=n;return K[r(728)](t)||(t=K[r(1215)+"er"](t)),e[r(512)](this[r(1366)],t[r(1366)])&&e[r(861)](this[r(1626)]>>>31,1)&&e[r(1168)](t[r(1626)],31)===1?!1:e[r(1590)](this[r(1626)],t[r(1626)])&&e.BbOtg(this.low,t[r(612)])}[n(1173)](){let t=n;return this.low===-1&&e[t(1590)](-1,this.high)?K[t(775)](0,0,this[t(1366)]):this[t(612)]===-1?K[t(775)](0,e.nrXva(this[t(1626)],1),this.unsigned):K[t(775)](e[t(1791)](this[t(612)],1),this[t(1626)],this[t(1366)])}[n(1259)](t){let r=n;return t?this[r(576)+"E"]():this[r(1558)+"E"]()}toBytesLE(){let t=n,r=this[t(1626)],a=this[t(612)];return[e[t(896)](255,a),e[t(939)](e.ovLnH(a,8),255),e[t(1631)](a,16)&255,e.cbAEi(a,24),e[t(1143)](255,r),e.oWwXF(e[t(734)](r,8),255),e[t(398)](e[t(1233)](r,16),255),e[t(757)](r,24)]}toBytesBE(){let t=n;if(e.PuQjS===e[t(1536)]){let r=this.high,a=this[t(612)];return[e[t(1239)](r,24),e[t(1369)](r,16)&255,e[t(1854)](r,8)&255,255&r,e[t(1255)](a,24),e[t(1653)](a,16)&255,e[t(1511)](e[t(1168)](a,8),255),e.RvWRw(255,a)]}else return this._ws?this._ws.binaryType:this[t(600)+t(657)]}}let Qi=new K(0,0,!1),Vc=new K(0,0,!0),Jc=K.fromBits(-1,2147483647,!1),Yc=K.fromBits(-1,-1,!0),Zc=K[n(775)](0,-2147483648,!1);var rt=(function(i){let t=n,r={sCCnZ:function(a,d,l){return e[T(929)](a,d,l)}};if(e[t(415)](e.BtDbh,t(345))){let a=("5|1|4|3|"+t(1817)).split("|"),d=0;for(;;){switch(a[d++]){case"0":i[i.OPEN_ERROR=5005]=e[t(610)];continue;case"1":i[i[e[t(1710)]]=5002]="CONNECTI"+t(1241);continue;case"2":return i;case"3":i[i[e.UdyYx]=5004]=e[t(1577)];continue;case"4":i[i[t(630)+t(569)+"R"]=5003]=e[t(1304)];continue;case"5":i[i[e[t(1025)]]=5001]=e.QgHud;continue}break}}else lUhlgc[t(1508)](_0x5148da,_0x3734ba,18),lUhlgc[t(1508)](_0x4c2cdf,_0x1ee411,_0x28e0ac)})({});class St{constructor(t){let r=n;this[r(379)]=t,this.target=null}}class es extends St{constructor(t,r){let a=n;super(t),this[a(653)]=r&&r[a(653)]||null}}class ts extends St{constructor(t,r){let a=n;super(t),this.error=r&&r[a(1326)]||null,this.colno=r&&r.colno||0,this[a(1150)]=r&&r[a(1150)]||"",this[a(1338)]=r&&r[a(1338)]||0,this[a(653)]=r&&r.message||"",this[a(1599)]=r&&r[a(1599)]||5001}}class ns extends St{constructor(t,r){let a=n,d=(a(791)+"2")[a(1484)]("|"),l=0;for(;;){switch(d[l++]){case"0":super(t);continue;case"1":this[a(1599)]=r&&r.code||0;continue;case"2":this[a(1038)+a(1335)]=r&&r[a(1038)+"nnect"]||!1;continue;case"3":this.wasClean=r&&r.wasClean||!1;continue;case"4":this[a(767)]=r&&r[a(767)]||"";continue}break}}}class rs extends St{constructor(t,r){let a=n;super(t),this.data=r&&r[a(1144)]||null}}class is extends rs{constructor(t,r){let a=n;super(t),this[a(1144)]=r&&r[a(1144)]||null,this[a(653)]=r&&r[a(653)]||null}}class ss extends St{constructor(t,r){let a=n;super(t),this.data=r&&r[a(1144)]||null}}function Ce(i,{message:t,code:r,error:a}){return new ts(i,{message:t,code:r,error:a})}function Re(i,{code:t,reason:r,wasClean:a,willReconnect:d}){return new ns(i,{code:t,reason:r,wasClean:a,willReconnect:d})}function os(i,{data:t,message:r}){return new is(i,{data:t,message:r})}function as(i,{data:t}){return new ss(i,{data:t})}function Or(i,{message:t}){return new es(i,{message:t})}class cs{constructor(t,r){let a=n;this[a(794)+"s"]=t,this[a(1766)+"es"]=r,this[a(1708)+a(1063)]=0,this[a(995)+a(747)+a(367)+"t"]=0}[n(801)+"pointCon"+n(1680)](){let t=n;this[t(1708)+t(1063)]=0,this[t(995)+t(747)+t(367)+"t"]=0}[n(633)+"es"](){let t=n;this[t(995)+"ndpointT"+t(367)+"t"]=0}[n(1446)+n(1725)+"nt"](){let t=n;return this[t(794)+"s"][this[t(1708)+t(1063)]]}["getCurre"+n(1725)+n(455)+n(1555)](){let t=n;return this[t(995)+t(747)+t(367)+"t"]}[n(1881)+n(862)+"es"](){let t=n;return!!(e[t(1061)](this["currentI"+t(1063)],this[t(794)+"s"].length)||e[t(1590)](this[t(1708)+t(1063)],e[t(1745)](this[t(794)+"s"][t(1397)],1))&&this[t(995)+t(747)+t(367)+"t"]===this[t(1766)+"es"])}[n(486)+n(946)+n(847)+n(1747)+n(478)](){let t=n;return e.mQKcO(this[t(1708)+t(1063)],this[t(794)+"s"][t(1397)])?!0:e[t(356)](this[t(995)+t(747)+"riesCount"],this.maxRetries)}[n(529)+n(1681)+n(792)+n(574)+n(1180)](){let t=n;return this[t(995)+t(747)+"riesCount"]=1,this[t(1708)+t(1063)]++,this[t(794)+"s"][this["currentI"+t(1063)]]}[n(1446)+n(1725)+"ntAndUpd"+n(1028)](){let t=n;return this[t(995)+t(747)+t(367)+"t"]++,this[t(1446)+"ntEndpoint"]()}}let Et=(e[n(1493)]!=typeof globalThis&&e[n(614)](e[n(838)],globalThis[n(1502)+n(1e3)].name)||e.azadr!=typeof window&&e.GqOoY(e[n(838)],window[n(1502)+"tor"][n(1687)]))&&e[n(1815)](e[n(1493)],typeof document),lt=e[n(1861)](n(1537)+"d",typeof globalThis)&&(e[n(463)](e[n(1557)],globalThis[n(1502)+n(1e3)][n(1687)])||e[n(461)](e[n(1543)],globalThis[n(1502)+n(1e3)].name))&&e[n(672)](e[n(1493)],typeof tt),Vt=(e[n(536)](e.azadr,typeof globalThis)&&e[n(1071)](e[n(1557)],globalThis["construc"+n(1e3)][n(1687)])||e.mQKcO(e[n(1493)],typeof globalThis)||e[n(1815)](e[n(1493)],typeof globalThis)&&!!globalThis[n(1312)+n(866)])&&e.rXchv(e[n(1493)],typeof wx),Jt=e[n(1726)]("undefined",typeof globalThis)&&(n(349)+n(1434)+n(718)+"pe"===globalThis[n(1502)+"tor"].name||e[n(1009)](n(1159)+n(1131)+n(565),globalThis[n(1502)+"tor"][n(1687)])||e[n(837)]===globalThis[n(1502)+n(1e3)][n(1687)])&&e[n(1855)](e[n(1493)],typeof self),Xc=e[n(863)]("undefined",typeof globalThis)&&e[n(1569)](e[n(1557)],globalThis["construc"+n(1e3)].name)&&e[n(1815)](e.azadr,typeof global)&&e[n(1294)](e.ScdhQ,global[n(1502)+"tor"][n(1687)])&&e[n(1611)](e[n(1493)],typeof process)&&!!process[n(483)];class Mr{constructor(){let t=n;this[t(1482)+"rs"]={}}[n(667)](t,...r){let a=n,d=this[a(1482)+"rs"][t];if(d)d.slice()[a(1278)](l=>l.fn[a(1262)](l.ctx,r));else if(e[a(1590)](a(1326),t)&&!this.onerror)if(e.xOAwj==="LmpFF"){let l=r.length&&r[0];if(e.ICtUt(l,Error))throw l;let p=new Error(e[a(1182)](e[a(1849)],l?e.XiNhx(e.iLJGk(" (",l[a(653)]),")"):""));throw p.context=l,l}else this[a(1594)+a(859)]();return this}[n(387)](t,r){let a=n,d={sseqt:function(l,p){return l!==p},FmdJK:a(1523)};if(e.BbOtg(e[a(1319)],a(542))){if(e[a(1161)](void 0,t))this[a(1482)+"rs"]={};else if(e[a(1066)](void 0,r))this[a(1482)+"rs"][t]=null;else{let l=this[a(1482)+"rs"][t];if(l)for(let p=0;e[a(857)](p,l[a(1397)]);)e[a(705)](l[p].fn,r)?l.splice(p,1):++p}return this}else this[a(1546)+a(1148)]()&&(!this[a(1550)]||d.sseqt(this[a(1550)].readyState,this[a(1675)])||d.sseqt(this._ws[a(1754)+"te"],this[a(412)+"NG"]))&&this["_handleO"+a(1731)](),this._isBrowser&&_0x2edfd3["addEvent"+a(691)](d[a(1665)],this[a(1424)+"nLine"]),this[a(655)+"er"]&&_0x810fbf[a(877)+a(691)](a(1011),this._handleOffLine)}on(t,r,a){let d=n;return(this[d(1482)+"rs"][t]||(this._listeners[t]=[]))[d(1258)]({fn:r,ctx:a||this}),this}}class Qc extends Mr{[n(975)+"rrorMess"+n(339)](t){let r=n;return t[r(1706)]||t.errNo?("message: "+(t[r(1706)]||"")+r(912)+(t.errNo||"")).trim():JSON[r(1444)+"y"](t)}constructor(t,r,a){let d=n;super(),this[d(1204)]=null,Vt&&wx[d(429)+d(980)]&&(this[d(1204)]=wx[d(429)+d(980)]({url:t,protocols:r,header:a,fail:this[d(1308)+d(485)+d(1420)].bind(this),success:this[d(1308)+d(373)+d(1343)+"ler"][d(389)](this)})),lt&&tt["connectS"+d(980)]&&(this._socket=tt[d(429)+d(980)]({url:t,protocols:r,header:a,fail:this[d(1308)+d(485)+d(1420)][d(389)](this),success:this[d(1308)+d(373)+d(1343)+d(1659)][d(389)](this)}))}[n(1308)+n(373)+"cessHand"+n(1659)](){let t=n;Promise[t(828)]().then(()=>{this["_addWsLi"+t(1310)]()})}[n(1308)+n(485)+n(1420)](t){let r=n;Promise.resolve()[r(364)](()=>{let a=r,d=e.pgyRu(Ce,"error",{message:this[a(975)+a(644)+a(339)](t)});this[a(667)]("error",d);let l=e.upKgF(Re,e[a(981)],{reason:this[a(975)+a(644)+a(339)](t)});this[a(667)](a(475),l)})}[n(555)+"steners"](){let t=n,r={sqIld:function(a,d){return e[T(497)](a,d)},XjWMf:function(a,d){return e[T(851)](a,d)},AKNUL:function(a,d){return e.QxUsA(a,d)},jHZBt:function(a,d){return e[T(884)](a,d)},fkQIj:function(a,d){return e[T(744)](a,d)},RkJiE:function(a,d){return e.jicqo(a,d)},hFYUJ:e[t(981)],EhhEz:function(a,d,l){return a(d,l)},ooiJx:e[t(1274)]};e[t(918)](e[t(1525)],e[t(1623)])?(VNYVxQ[t(1001)](_0x63ee7c,65536)?_0x4ce268[_0x3265d7++]=VNYVxQ[t(1819)](VNYVxQ[t(886)](_0x86c301,12),15)|224:(_0x26806d[_0x4dea46++]=VNYVxQ[t(1565)](VNYVxQ[t(787)](VNYVxQ.AKNUL(_0x192753,18),7),240),_0x4ec073[_0x1e5507++]=VNYVxQ[t(1036)](VNYVxQ.XjWMf(_0x19b935>>12,63),128)),_0x3528b8[_0x55c520++]=VNYVxQ[t(787)](_0x56b4f6>>6,63)|128):(this[t(1204)].onOpen(a=>{let d=t;this[d(667)](e[d(1769)],e[d(414)](as,e[d(1769)],{...a,data:a[d(1706)]||""}))}),this._socket[t(893)](a=>{let d=t;this[d(667)](r[d(508)],r[d(1679)](Re,r.hFYUJ,{...a}))}),this[t(1204)][t(501)+"e"](a=>{let d=t;this[d(667)](e[d(1459)],e[d(723)](os,d(653),{...a}))}),this[t(1204)][t(1052)](a=>{let d=t;this[d(667)](r[d(340)],r[d(1679)](Ce,r.ooiJx,{...a,message:a[d(1706)]||""}))}))}[n(558)](t){let r=n;if(e.ICtUt(t,Uint8Array)){let a=t.buffer.slice(t[r(1049)+"et"],e.PjxwI(t[r(702)+"th"],t[r(1049)+"et"]));this[r(1204)]&&this._socket.send({data:a,fail:d=>{let l=r;this[l(667)](l(1326),e[l(1753)](Ce,e[l(1274)],{message:this[l(975)+"rrorMess"+l(339)](d)}))}})}else this._socket&&this[r(1204)].send({data:t,fail:a=>{let d=r;this[d(667)](e[d(1274)],Ce(d(1326),{message:this[d(975)+d(644)+d(339)](a)}))}})}close(t,r){let a=n;this[a(1204)]&&this[a(1204)][a(475)]({code:t,reason:r})}[n(877)+"Listener"](t,r){let a=n;if(a(553)===e[a(1587)])return"frontier_"+this._DBName;this.on(t,r)}[n(401)+n(1658)+n(651)](t,r){let a=n,d={NIElM:function(l,p,w){return e[T(1756)](l,p,w)},cbFoS:function(l,p,w){return e[T(1123)](l,p,w)},UvwML:function(l,p){return e.PVrBh(l,p)}};e[a(901)](e[a(1035)],a(537))?(ouMgkH[a(1415)](_0x5ef53a,_0x17622b,24),ouMgkH[a(531)](_0x46bcc9,_0x46e936,ouMgkH.UvwML(_0x3a30cd,_0x5165cc))):this[a(387)](t,r)}get readyState(){let t=n;return this._socket[t(1754)+"te"]}get[n(1181)+"pe"](){let t=n;return this[t(1204)][t(1181)+"pe"]}set[n(1181)+"pe"](t){}get url(){let t=n;return this[t(1204)][t(1519)]}get protocol(){let t=n,r={ZJNjt:function(a,d){return a(d)},PvqTU:function(a,d){return e[T(419)](a,d)},YTewg:e[t(1196)],PaTUK:e[t(1437)]};if(e.ZKQyN(e[t(1692)],e[t(1799)]))return this._socket[t(1129)];{let a=_0x27d7c5[t(1484)](/\./)[t(1207)](p=>_0x34ee66(p)),d=[];return d[0]=_0x3e769e(a[0]+a[1]),d[1]=RKHXHO.ZJNjt(_0x23759c,RKHXHO[t(385)](a[2],a[3])),[RKHXHO[t(1406)],RKHXHO.YTewg,RKHXHO[t(1406)],RKHXHO[t(1406)],RKHXHO[t(1406)],RKHXHO[t(782)],d[0],d[1]][t(491)]("")}}get[n(700)+"ns"](){let t=n;return this[t(1204)][t(700)+"ns"]}get[n(940)+n(585)](){return 0}}function e0(i,t){let r=n,a={nrHjT:function(l,p,w,h){return e[T(1360)](l,p,w,h)}};if(e[r(1054)](r(622),e.RILRY)){if(t)return new t(i[r(1519)],i[r(1129)]);if(e.GlplT(Vt,lt))return new Qc(i[r(1519)],i[r(1129)],i[r(386)]);if(e[r(586)](Et,Jt)&&e[r(536)](r(1537)+"d",typeof WebSocket)&&WebSocket)return new WebSocket(i[r(1519)],i.protocols)}else for(var d in _0x2472eb)aMSmJd[r(393)](_0xf3327e,_0x27068d,d,{get:_0x290790[d],enumerable:!0})}function t0(i){let t=n;return!!(i||Vt&&wx[t(429)+t(980)]||lt&&tt[t(429)+t(980)]||e[t(1581)](Et,Jt)&&e[t(1493)]!=typeof WebSocket&&WebSocket)}function xs(i,t,r){let a={EhGpg:e.rlZQy,ZYoGn:function(p,w){return e[T(678)](p,w)},hIvap:function(p,w){return e.DyFWR(p,w)}},d=-1;async function l(p){let w=T;return p<=d?Promise[w(1686)](new Error(a[w(1648)])):(d=p,a[w(1112)](p,r.length)?Promise.resolve():r[p][w(389)](i)(t,l[w(389)](null,a[w(1572)](p,1))))}l(0)}function ds(i){let t=n,r={UXYGN:function(l,p,w){return e[T(533)](l,p,w)},jCoRZ:e[t(1274)]},a=0,d=0;for(let l=0;e[t(889)](l,i[t(1397)]);++l)if(e[t(1161)](e[t(1080)],"VIUUG"))if(d=i[t(1333)+"At"](l),e.KgkrS(d,128))a+=1;else if(e[t(934)](d,2048))a+=2;else if(e[t(1588)](e[t(776)](64512,d),55296)&&e[t(1683)](e.IYGXO(64512,i[t(1333)+"At"](e[t(758)](l,1))),56320))if(e[t(918)](t(770),e[t(1219)])){let p=r.UXYGN(_0x465e1b,r.jCoRZ,{message:_0x2adca4.message,code:_0x1703cf["MESSAGE_"+t(525)],error:_0xab87ee});this[t(902)+t(538)+t(790)](p)}else++l,a+=4;else a+=3;else{let p=_0x249f5c[t(416)]();return p?(p.offset=p[t(1802)]=0,p):{bytes:new _0x28c5fc(64),offset:0,limit:0}}return a}function us(i,t,r){let a=n;if(e[a(1607)](e[a(355)],e[a(1598)])){if(e[a(1077)](r,t)<1)return"";let d="";for(let l=t;e[a(1741)](l,r);){let p=i[l++];if(p<=127)d+=String[a(741)+"Code"](p);else if(p>=192&&e.ZiYOn(p,224))d+=String[a(741)+a(1643)](e[a(1124)](e[a(1613)](e[a(1002)](31,p),6),e[a(1242)](63,i[l++])));else if(e[a(1808)](p,224)&&e[a(1130)](p,240))d+=String[a(741)+a(1643)](e[a(1387)](e[a(1070)](15,p),12)|e[a(1568)](63,i[l++])<<6|63&i[l++]);else if(e.rszUH(p,240)){let w=e[a(1867)](e[a(829)](e[a(895)](e[a(1649)](e.cDySw(7,p)<<18,e[a(1194)](e[a(398)](63,i[l++]),12)),e[a(1759)](e.lDqpo(63,i[l++]),6)),e.DdVTt(63,i[l++])),65536);d+=String[a(741)+a(1643)](e[a(1480)](55296,e.JqZRN(w,10))),d+=String[a(741)+a(1643)](e[a(1770)](56320,e[a(834)](1023,w)))}}return d}else return new _0x206621(_0x1e9419,{data:_0xfd2640,message:_0x547bb3})}function Br(i,t,r){let a=n,d=r,l,p;for(let w=0;e[a(1639)](w,i[a(1397)]);++w)if(l=i[a(1333)+"At"](w),e[a(497)](l,128))t[r++]=l;else if(l<2048)t[r++]=e[a(344)](e.QxUsA(l,6),192),t[r++]=e[a(1017)](e[a(599)](63,l),128);else if(e[a(1419)](64512,l)===55296&&e.PNrrm(64512&(p=i.charCodeAt(w+1)),56320)){let h=e[a(1020)].split("|"),S=0;for(;;){switch(h[S++]){case"0":t[r++]=e[a(1225)](e[a(1432)](l,18),240);continue;case"1":t[r++]=e.kkUos(e[a(1615)](l>>12,63),128);continue;case"2":t[r++]=e[a(1542)](e.VSEQC(63,l),128);continue;case"3":t[r++]=e.QxUsA(l,6)&63|128;continue;case"4":l=e[a(823)](65536,e.aiDmF(e[a(939)](1023,l),10))+(1023&p);continue;case"5":++w;continue}break}}else t[r++]=e.gCfnS(e[a(1439)](l,12),224),t[r++]=e.kkUos(e.DiBnC(e.sZivW(l,6),63),128),t[r++]=e[a(1486)](e[a(1070)](63,l),128);return e[a(443)](r,d)}async function fs(i){let t=n;if(e[t(1553)](t(780),typeof i)){let r=new Uint8Array(e[t(1370)](ds,i));return e[t(1360)](Br,i,r,0),r}return e.ERYPO(i,ArrayBuffer)?new Uint8Array(i):new Uint8Array(i[t(1056)],i[t(1049)+"et"],i[t(702)+"th"])}function n0(i){let t=n,r={SfSON:function(a,d){return e[T(1066)](a,d)},OivQX:function(a,d){return e.Cccdh(a,d)},AgWMj:function(a,d,l){return e[T(1210)](a,d,l)}};try{if(e[t(971)](e.pVJou,e.qhCxJ))return e[t(536)]("string",typeof i)&&(e.ICtUt(i,ArrayBuffer)||i[t(1056)]&&i[t(1056)]instanceof ArrayBuffer)||e[t(863)](e[t(1237)],typeof i)?"":(JSON.parse(i),e[t(1007)]);if(this._ws&&r.SfSON(this[t(1550)][t(1754)+"te"],this[t(412)+"NG"])){this[t(577)+t(503)](),this[t(1282)+"gTimeoutId"]=_0x1acbb7(this[t(652)][t(389)](this),this[t(698)][t(1579)+t(606)]);return}if(!this[t(1550)]||r[t(1821)](this[t(1550)][t(1754)+"te"],this[t(1675)]))return void this[t(1580)+t(1677)]();this[t(1550)]&&this[t(1550)][t(558)]("hi"),this[t(740)+t(1620)+t(1236)]=r[t(1022)](_0x420292,this[t(1580)+t(1677)+"Timeout"].bind(this),this[t(698)][t(528)+t(1301)+t(363)])}catch{if(e[t(1149)](t(843),e[t(465)]))return e[t(1553)](t(780),typeof i)?t(1728)+"in;charset=utf-8":"";this[t(667)]("ack",_0x3bb5a1),this[t(640)+t(694)]&&this["onReceiv"+t(694)](_0x3f4964)}}let r0=(i,t)=>{let r=n;switch(i){case e[r(1774)]:case e[r(1108)]:return{[r(1871)+i]:1,"x-tt-env":t};default:return{}}};class i0{constructor(t){let r=n;this[r(910)+r(1555)]=t,this.count=0}[n(641)](){this.count++}checkReachMaxCount(){let t=n;return e[t(1567)](this[t(908)],this[t(910)+t(1555)])}[n(1852)+n(650)](t=0){let r=n;this[r(910)+"ount"]=t,this[r(908)]=0}}async function s0(i){let t=n,r={fijDC:function(a,d){return e[T(1865)](a,d)},XFbhq:t(436)+t(767),GnERC:e[t(1119)],BHBaw:e[t(571)],DuwVc:function(a,d){return a+d},zTzSe:e.yQYwX,NAotL:t(724)+t(1400)+t(1084)+"P",QghLA:function(a,d){return a(d)}};return new Promise(a=>{let d=t;if(!Et)return r.fijDC(a,r[d(1436)]);try{let l=document.createElement(r[d(1458)]);window[d(990)+"JSONP"]=p=>{let w=d;document.body[w(604)+"ild"](l),window[w(990)+w(1792)]=void 0,r.fijDC(a,p&&p[w(467)]||r.XFbhq)},l[d(379)]=r[d(781)],l[d(425)]=r[d(1843)](i[d(1092)](/^ws/,r[d(733)]),r[d(1205)]);try{document[d(1705)][d(1678)+d(495)](l)}catch{document[d(1705)]["removeCh"+d(495)](l)}}catch{window[d(990)+"JSONP"]=void 0,r.QghLA(a,"unknown "+d(767))}})}function it(i,t,r){let a=n,d={kIdcJ:function(l,p){return l|p},NLZVi:function(l,p){return e[T(563)](l,p)},IRRgX:function(l,p){return e.AWPPr(l,p)},yqUFs:function(l,p){return e[T(497)](l,p)},QZhJu:function(l,p){return e.KNIpp(l,p)},ydTqp:function(l,p){return e.Ikmbu(l,p)},zbmxr:function(l,p){return e[T(688)](l,p)}};if(e[a(1513)](e[a(607)],a(677)))_0xbb6a8d<2048?_0x533cbe[_0x1ad7cf++]=vCNLSe[a(469)](vCNLSe[a(1467)](vCNLSe[a(1384)](_0x598e5e,6),31),192):(vCNLSe[a(959)](_0x53ce20,65536)?_0x4b80b8[_0x1782d8++]=vCNLSe.QZhJu(vCNLSe[a(1384)](_0x2cd383,12),15)|224:(_0x35b989[_0x59287e++]=vCNLSe[a(469)](vCNLSe[a(1601)](vCNLSe[a(676)](_0x28a11e,18),7),240),_0xa30994[_0x377a97++]=vCNLSe.kIdcJ(vCNLSe.NLZVi(vCNLSe[a(676)](_0x51c6e3,12),63),128)),_0x58b990[_0x15540a++]=vCNLSe[a(469)](vCNLSe[a(676)](_0x4ca937,6)&63,128)),_0x37867a[_0x309397++]=vCNLSe[a(1467)](63,_0x58f62d)|128;else return!!i?.[a(1840)](l=>l[a(841)]===t&&l.value===r)}function It(i,t){let r=n;return i?.[r(1840)](a=>a[r(841)]===t)?.[r(797)]}let zr=null;async function o0(){let i=n;return zr||(zr=Promise[i(828)]()[i(364)](Ge.bind(Ge,e[i(471)]))),zr}class a0 extends Mr{constructor(t,r){let a=n,d={UFYUb:function(l,p,w){return l(p,w)},GEXoF:function(l,p,w){return e[T(1742)](l,p,w)}};e[a(1161)](e[a(343)],e[a(1389)])?(FafGcc.UFYUb(_0x38941b,_0x2f2a44,50),FafGcc[a(1828)](_0x4f5fed,_0x4ee973,_0x419f3d)):(super(),this[a(875)]=t,this[a(1065)]=r,this[a(1353)]=void 0,this[a(1093)+a(1773)]=null)}async[n(1750)](){await this._init()}async[n(1004)](){let t=n,r={MoMRD:t(1326),yCZlG:function(a,d,l){return e[t(1341)](a,d,l)}};if(!this[t(1353)]){if(this[t(1093)+t(1773)])return this[t(1093)+t(1773)];try{let a=this._dbName,d=this[t(1065)];this[t(1093)+"mise"]=(async()=>{let l=t,{openDB:p}=await e.aNubJ(o0);this[l(1353)]=await e.JVSwq(p,l(990)+"_"+a,1,{upgrade(w){let h=l;w[h(1362)+h(1714)+"e"](a,{keyPath:d})}})})(),await this[t(1093)+t(1773)]}catch(a){console.log(a)}finally{e[t(689)](e[t(987)],e.hvhob)?this[t(1093)+t(1773)]=null:this[t(667)](jApLKC.MoMRD,jApLKC[t(341)](_0x5a1270,jApLKC[t(1879)],{message:this["_formatE"+t(644)+t(339)](_0x74a2ba)}))}}}async[n(1612)](t){let r=n;try{return await this[r(1004)](),this._qosDB?.[r(1612)](this[r(875)],t)}catch(a){console[r(1777)](a)}}async[n(793)](t,r){let a=n;return await this._init(),this[a(1353)]?.[a(1193)](this._dbName,t)}async[n(950)](t){let r=n;try{if(e.SSUkQ===e.SSUkQ)return await this[r(1004)](),this[r(1353)]?.[r(1564)](this[r(875)],t);if(WrpgGZ[r(678)](_0x5ef70f,WrpgGZ[r(992)]))return _0x17525b[r(1612)](_0x3dddfb);if(WrpgGZ.BbOtg(_0x1b6ab1,r(1456)+r(1667)))return _0x220c57["objectSt"+r(1667)]||_0x216a9e[r(1612)](_0x47aa50);if(WrpgGZ[r(1228)](_0x5d23e7,WrpgGZ.nclLP))return _0x5040f3[r(1456)+r(1667)][1]?void 0:_0x334c8e[r(1456)+r(1549)](_0x82d11a[r(1456)+r(1667)][0])}catch(a){console[r(1777)](a)}}async[n(1024)](){let t=n,r={SHXyy:function(a,d){return e[T(1253)](a,d)},YPIRM:e[t(405)],BznJt:e.zTSFV,gzPSc:t(1412),RdGcd:e.SgupU};try{return t(1441)===e[t(1118)]?PUQbWa.SHXyy(_0x14414b,_0x412861):(await this[t(1004)](),this[t(1353)]?.clear(this[t(875)]))}catch(a){if(e.OdRzY(e.zZnga,e.UWJyC)){let d={UswHp:function(p,w){let h=t;return PUQbWa[h(936)](p,w)},IiAUd:PUQbWa.YPIRM},l=_0x2d19fc[t(1823)+t(814)](PUQbWa[t(937)]);_0x3ced6e[t(990)+t(1792)]=p=>{let w=t;_0x17ad38[w(1705)][w(604)+w(495)](l),_0x2bbcb9["frontier"+w(1792)]=void 0,d[w(1801)](_0x440c05,p&&p[w(467)]||d[w(1140)])},l[t(379)]=t(1005)+t(1141),l.src=_0x2862aa[t(1092)](/^ws/,PUQbWa.gzPSc)+PUQbWa[t(1266)];try{_0x2a317d[t(1705)]["appendCh"+t(495)](l)}catch{_0x145c17[t(1705)][t(604)+t(495)](l)}}else console.log(a)}}async[n(788)](){let t=n;return await this[t(1004)](),this[t(1353)]?.getAllKeys(this[t(875)])}async[n(592)](){let t=n,r={TdoRq:function(a,d){return a-d}};if(e[t(1248)](e.JeTnA,e[t(1566)])){let a=_0x393e83[t(1269)+"g"](0,tODSEi[t(1152)](4,_0x175d30[_0x38728e][t(1397)])),d=a[t(1889)](_0x4b5b7e[_0x1662b8]);_0x11e2d4[t(1258)](d)}else return await this[t(1004)](),this[t(1353)]?.getAll(this[t(875)])}async[n(1605)](){let t=n;try{this._qosDB?.close(),this[t(1353)]=void 0}catch(r){console.log(r)}}get[n(1676)](){let t=n;try{if(e[t(1516)](e.jCuRQ,e[t(1244)]))switch(_0x38d0fc){case t(605):case e[t(1108)]:return{[t(1871)+_0x4a32e3]:1,"x-tt-env":_0x39b762};default:return{}}else return!!this._qosDB}catch(r){return console.log(r),!1}}}class c0{constructor(t,r){let a=n;if(e[a(685)](e[a(803)],e[a(803)]))this[a(488)]=t,this[a(1757)]=r,this[a(1353)]=localStorage;else{this["_destroy"+a(628)+"t"]();let d=_0x2fc109(a(418)+"t",{message:a(1229)+a(1132)+" reconnect"});this["onStopIm"+a(1243)+a(1498)+"ct"]&&this[a(353)+a(1243)+a(1498)+"ct"](d)}}async[n(1750)](){}get _prefix(){return n(990)+"_"+this._DBName}async[n(1612)](t){let r=n,a=this[r(1353)].getItem(this._prefix);return JSON.parse(e.zHeZL(a,"{}"))[t]}async[n(793)](t,r){let a=n,d=this[a(1353)][a(1190)](this._prefix),l=JSON[a(1818)](e[a(1834)](d,"{}"));return l[r||t[this._pathKey]]=t,this[a(1353)][a(1307)](this[a(1559)],JSON[a(1444)+"y"](l)),r||t[this[a(1757)]]}async[n(950)](t){let r=n;if(e[r(815)](e[r(543)],e[r(948)])){let a=this[r(1353)].getItem(this._prefix),d=JSON[r(1818)](e[r(1834)](a,"{}"));return d[t]=void 0,this[r(1353)][r(1307)](this[r(1559)],JSON[r(1444)+"y"](d))}else return this[r(334)+"tManager"]?.[r(1446)+"ntEndpoi"+r(455)+r(1555)]()||0}async[n(1024)](){let t=n;if(e[t(1513)](t(666),e[t(890)]))return this[t(1353)][t(1024)]()}async[n(788)](){let t=n,r=this[t(1353)].getItem(this[t(1559)]),a=JSON[t(1818)](e[t(1316)](r,"{}"));return Object[t(788)](a)}async[n(592)](){let t=n,r=this[t(1353)][t(1190)](this[t(1559)]),a=JSON.parse(e[t(547)](r,"{}"));return Object.values(a)}[n(1605)](){return Promise[n(828)]()}get[n(1676)](){return!!this._qosDB}}class x0{constructor(t,r){let a=n;e.IxWeP(e.ZdjIb,"YxvBe")?(this[a(488)]=t,this[a(1757)]=r,this[a(1353)]=lt?tt:Vt?wx:null):(this[a(655)+"er"]&&_0x1243c0["removeEv"+a(1658)+a(651)](e[a(842)],this["_handleO"+a(1731)]),this[a(655)+"er"]&&_0x473de3[a(401)+"entListe"+a(651)](e[a(464)],this[a(1424)+a(715)]),this._isBrowser&&_0x3e99fc[a(401)+a(1658)+a(651)](a(1868),this._handlePageHide),this[a(655)+"er"]&&_0x2f8f43[a(401)+a(1658)+"ner"](e.KiYYX,this[a(887)+"ageShow"]))}async openDB(){}get[n(1559)](){return n(990)+"_"+this._DBName}async[n(1612)](t){let r=n,a=this[r(1353)]["getStora"+r(1662)](this[r(1559)]);return JSON[r(1818)](a||"{}")[t]}async set(t,r){let a=n,d=this[a(1353)][a(1107)+a(1662)](this[a(1559)]),l=JSON[a(1818)](d||"{}");return l[r||t[this[a(1757)]]]=t,this[a(1353)][a(690)+"geSync"](this[a(1559)],JSON[a(1444)+"y"](l)),r||t[this[a(1757)]]}async del(t){let r=n,a=this[r(1353)][r(1107)+"geSync"](this._prefix),d=JSON.parse(e[r(602)](a,"{}"));return d[t]=void 0,this[r(1353)][r(690)+r(1662)](this[r(1559)],JSON[r(1444)+"y"](d))}async[n(1024)](){let t=n;return this[t(1353)][t(573)+t(687)]()}async keys(){let t=n,r=this[t(1353)][t(1107)+t(337)+"nc"](this[t(1559)]),a=JSON.parse(e.GlplT(r,"{}"));return Object[t(788)](a)}async[n(592)](){let t=n,r=this[t(1353)][t(1107)+t(337)+"nc"](this._prefix),a=JSON[t(1818)](e.dyjAA(r,"{}"));return Object.values(a)}[n(1605)](){return Promise.resolve()}get[n(1676)](){return!!this._qosDB}}function ls(i,t){let r=n;if(e[r(1834)](lt,lt))return new x0(i,t);if(e[r(1574)](Et,Jt)&&e[r(863)]("undefined",typeof indexedDB))return new a0(i,t);if(e[r(1624)](Et,Jt)&&e[r(1815)](e.azadr,typeof localStorage))return new c0(i,t);throw new Error(e[r(1164)])}class d0{constructor(){let t=n;this[t(1594)+t(1775)+"Id"]=null,this[t(1594)+"l"]=36e5,this[t(1353)]=ls(t(1039),t(1157)+"id")}async[n(1594)+n(859)](){let t=n,r={tsCQp:function(a,d){return e[T(1571)](a,d)},vZwdN:function(a,d){return e.IhIIC(a,d)},OLFHy:function(a,d){return e[T(1816)](a,d)},ZEuHB:function(a,d){return e[T(1429)](a,d)},sTMUB:function(a,d){return e[T(415)](a,d)},VkUPu:function(a,d){return e[T(1138)](a,d)},MIkkE:function(a,d){return e[T(949)](a,d)},uKqoK:e[t(1153)],xjSSP:function(a,d){return e[t(1175)](a,d)},mypki:function(a,d){return e[t(720)](a,d)},TslgK:function(a,d){return e[t(1505)](a,d)},SyaCU:function(a,d){return e[t(1318)](a,d)},yhzkp:function(a,d){return e[t(1185)](a,d)},CjqKp:function(a,d){return e.yfUwP(a,d)},eIVNW:function(a,d){return e[t(895)](a,d)},gdRUV:function(a,d){return e[t(1209)](a,d)},tbEJT:function(a,d){return e[t(1839)](a,d)},uLJYc:function(a,d){return e[t(938)](a,d)},yjtOb:"Ghxer"};e[t(1057)](clearInterval,this["_interva"+t(1775)+"Id"]),this._intervalTimeoutId=setInterval(()=>{let a=t;if(r[a(922)](r[a(444)],a(1133)))if(_0x2f3b53=_0x2d7793[a(1333)+"At"](_0x463586),MGCDeM[a(882)](_0xfb6983,128))_0x1db143[_0x11f088++]=_0xab1c10;else if(MGCDeM[a(882)](_0x560e9a,2048))_0xd697d4[_0x448f98++]=MGCDeM[a(383)](MGCDeM.OLFHy(_0x4f74b3,6),192),_0xee9d3f[_0x20c543++]=MGCDeM[a(383)](MGCDeM.ZEuHB(63,_0x172eeb),128);else if(MGCDeM[a(638)](64512,_0x4d2325)===55296&&MGCDeM[a(1832)](MGCDeM.VkUPu(64512,_0x1fa9c5=_0x3f9ab1[a(1333)+"At"](MGCDeM[a(681)](_0x43311a,1))),56320)){let d=MGCDeM.uKqoK.split("|"),l=0;for(;;){switch(d[l++]){case"0":_0x283c17[_0x9403f8++]=MGCDeM[a(1045)](MGCDeM[a(638)](63,_0x515cf4),128);continue;case"1":_0x1a8ad2[_0xae3545++]=MGCDeM[a(638)](MGCDeM.mypki(_0x314373,12),63)|128;continue;case"2":_0x4a9f04=MGCDeM[a(1167)](65536,MGCDeM[a(587)](1023&_0x2b3708,10))+(1023&_0x12216a);continue;case"3":_0x293e56[_0x2dfc9f++]=MGCDeM[a(1012)](MGCDeM[a(457)](_0x212e03,6)&63,128);continue;case"4":_0x1e96ba[_0x195579++]=MGCDeM[a(1012)](MGCDeM[a(1404)](_0x31ffe8,18),240);continue;case"5":++_0x37fd0a;continue}break}}else _0x1178e2[_0x2f08ca++]=MGCDeM.CjqKp(MGCDeM[a(1404)](_0xd0706f,12),224),_0x2814dc[_0x2e7099++]=MGCDeM[a(1682)](MGCDeM.ZEuHB(MGCDeM[a(1642)](_0x29ee1e,6),63),128),_0x114983[_0x53d8ae++]=MGCDeM.tbEJT(63,_0x364f8b)|128;else this[a(868)+a(874)]()},this[t(1594)+"l"])}async openDB(){let t=n;await this[t(1353)][t(1750)]().then(()=>{this["_interva"+t(859)]()})}async[n(868)+n(874)](){let t=n;(await this._qosDB?.getAll()||[]).filter(({timestamp:d})=>d<Date.now())[t(1278)](d=>{let l=t;if(e[l(1060)]("fzznA",l(377)))this[l(1353)]?.[l(950)](d[l(1157)+"id"]);else{let p=_0x3cc9b3(_0x3e3aec,1);_0x18d813[l(504)][p]=_0x476ea2}})}async[n(950)](t){let r=n;return this._qosDB?.[r(950)](t)}async[n(793)](t,r){let a=n;return this[a(1353)]?.[a(793)]({message_id:t,timestamp:r})}async[n(1612)](t){let r=n;return this[r(1353)]?.[r(1612)](t)}async closeDB(){let t=n,r={PutSY:t(1015)+"ay, try "+t(418)+"ting ser"+t(527)};if(e.hBXBb(e[t(1690)],e[t(1690)])){if(!this[t(1546)+"orOnline"]()||this["_readyCl"+t(1390)])return;this["_endpoin"+t(1261)]?.["resetEnd"+t(1582)+"fig"](),this[t(1088)+t(1392)]?.[t(1852)+t(650)](),this[t(1550)]?this["_disconn"+t(742)](1001,r.PutSY,!0):this[t(783)]()}else e[t(1253)](clearInterval,this[t(1594)+t(1775)+"Id"]),await this._qosDB?.[t(1605)]()}get[n(1676)](){return this._qosDB?.isReady}}function Fr(i){let t=n,r={yXUHe:e.aECEu,TyZiG:function(a,d,l){return e[T(1450)](a,d,l)},yczcn:function(a,d){return e[T(1464)](a,d)}};if(e[t(815)](t(1170),e.SfjOu)){let a=!!this[t(698)][t(1804)+"S"];if(!a)return{enabled:a,isQoSMessage:!1,isQoSAck:!1,isAckCleanupMessage:!1,ackMsgIds:[]};let d=it(i[t(653)].headers,e[t(1838)],"2"),l=d&&it(i[t(653)].headers,e[t(1654)],"1"),p=d&&e[t(878)](it,i[t(653)][t(386)],e[t(1137)],"1"),w=p?It(i[t(653)][t(386)],e.vRwxQ)?.[t(1484)](",")[t(1216)](Boolean)||[]:[];return{enabled:a,isQoSMessage:d,isQoSAck:l,isAckCleanupMessage:p,ackMsgIds:w}}else{let a=_0x30b6be[t(1056)][t(1522)](_0x4f1980[t(1049)+"et"],BPXbpW[t(894)](_0x4b5b19[t(702)+"th"],_0x1c1bc5[t(1049)+"et"]));this[t(1204)]&&this[t(1204)][t(558)]({data:a,fail:d=>{let l=t;this[l(667)](BPXbpW[l(1232)],BPXbpW[l(913)](_0x308ea3,BPXbpW[l(1232)],{message:this[l(975)+l(644)+l(339)](d)}))}})}}async function gs(){let i=n;return this[i(1479)+i(1869)]||(this[i(1479)+i(1869)]=new d0),this[i(1479)+i(1869)][i(1676)]||await this[i(1479)+i(1869)][i(1750)](),this["_QoSMana"+i(1869)]}async function u0(i,t){let r=n,{enableAutoAck:a}=this[r(698)],d=e[r(1325)](it,i[r(653)][r(386)],r(1485),"1"),l=e[r(1378)](it,i[r(653)][r(386)],e.dxEAD,"1"),p=Fr.call(this,i);if(e[r(1408)](a,d)){let{SeqID:w,LogID:h,service:S,LogIDNew:v,method:D}=i[r(653)];this[r(662)]({SeqID:w,LogID:h,LogIDNew:v,service:S,method:D,headers:[{key:e[r(479)],value:"1"},{key:r(976),value:v||""},{key:e.csoui,value:"0"}]})}l&&!p.isQoSAck&&this["_dispatc"+r(1589)+r(1697)](i),e[r(1763)](t)}async function f0(i,t){let r=n;this[r(1238)](e[r(597)],i[r(653)]),t()}async function l0(i,t){let r=n,a=e.BuZlF(yt,await e[r(351)](fs,i[r(1144)]));try{if(r(1200)!==e.RFITC)if(e[r(664)](a[r(1751)],Uint8Array)){let d=this._options[r(696)+r(972)]instanceof Object?{force:!!this[r(698)][r(696)+r(972)][r(953)],encoding:this[r(698)]["payloadE"+r(972)][r(856)]?this[r(698)][r(696)+"ncoding"][r(856)][r(1092)](/\s/g,"")[r(1379)+r(1433)]():""}:{force:!1,encoding:this[r(698)][r(696)+r(972)]?this._options[r(696)+"ncoding"][r(1092)](/\s/g,"")[r(1379)+r(1433)]():""},l=a["payloadE"+r(972)]?a[r(696)+r(972)].replace(/\s/g,"")[r(1379)+r(1433)]():"",p=this[r(698)]["payloadT"+r(657)]instanceof Object?{force:!!this._options["payloadT"+r(657)][r(953)],type:this[r(698)][r(795)+r(657)][r(379)]?this[r(698)][r(795)+r(657)][r(379)][r(1092)](/\s/g,"")[r(1379)+r(1433)]():""}:{force:!1,type:this[r(698)][r(795)+r(657)]?this[r(698)][r(795)+"ype"][r(1092)](/\s/g,"")[r(1379)+"ase"]():""},w=a[r(795)+"ype"]?a[r(795)+r(657)][r(1092)](/\s/g,"")[r(1379)+r(1433)]():"",h=p.force?p.type:w||p.type,S=d[r(953)]?d.encoding:l||d[r(856)],v=[r(1728)+r(1367)+r(1688),e[r(1007)],"applicat"+r(421)+";charset=utf-8",e[r(1237)]],D=[e.EAnJc,e.yQzjV];this[r(698)][r(1265)+r(1573)+r(1059)+"ad"]&&v.includes(h)&&(!S||D[r(1068)](S))?a[r(482)+r(1306)]=e.Bjsxj(us,a[r(1751)],0,a.payload[r(702)+"th"]):a[r(482)+r(1306)]=""}else a["textPayl"+r(1306)]="";else return _0x1dea81[r(1777)](_0x1250ea),!1}catch(d){a["textPayl"+r(1306)]="",console[r(1777)](d)}i[r(653)]=a,e.aNubJ(t)}function g0(i,t,r){let a=r||8192,d=a>>>1,l=null,p=a;return function(w){let h=T;if(e.DVoLU(w,1)||w>d)return e[h(534)](i,w);e[h(402)](p+w,a)&&(e[h(1149)](h(1383),h(1349))?_0x116239&&this[h(1297)+h(380)][h(1033)+h(1100)+h(1518)](_0x6d8f84):(l=e.nOFQn(i,a),p=0));let S=t[h(392)](l,p,p+=w);return 7&p&&(p=e.qVZjB(e[h(417)](7,p),1)),S}}let h0=4294967295;function p0(i,t,r){let a=n;return e[a(516)](RangeError,e.ZNlRp(e[a(852)](e[a(840)](e[a(1825)](e.XXPAD(e[a(1212)],i),a(413)),e[a(1624)](t,1)),e[a(1739)]),r))}function m0(i,t,r){let a=n,d={WDTgR:function(p,w){return p>>>w},ZdkxX:function(p,w){return e[T(619)](p,w)},XaCmx:function(p,w){return e.guosx(p,w)},nXHfm:function(p,w){return p+w},RdXCo:function(p,w){return e[T(1213)](p,w)},OOYTm:function(p,w){return e[T(1085)](p,w)},ijgBI:function(p,w){return e[T(1538)](p,w)},UiCwp:function(p,w){return e[T(1584)](p,w)},THnlx:function(p,w){return e.KALRk(p,w)}};if(e[a(1848)](r,h0))throw new Error(a(985)+a(1246)+"e");let l=3;for(;e.dMtfv(l,0);)if(e[a(476)](a(624),"LRVNS")){let p=e[a(1104)](255,r);qr(p,i,e[a(1791)](t,l)),r>>>=8,l--}else{_0x11f041[a(728)](_0x36859b)||(_0xff31a9=_0x289ec9[a(1215)+"er"](_0xc068ff));let p=SWjMZq[a(1873)](this[a(1626)],16),w=SWjMZq[a(1305)](65535,this[a(1626)]),h=SWjMZq.WDTgR(this[a(612)],16),S=SWjMZq.ZdkxX(65535,this[a(612)]),v=SWjMZq.WDTgR(_0x58cb88[a(1626)],16),D=SWjMZq[a(1260)](65535,_0x5331e0[a(1626)]),N=SWjMZq[a(1873)](_0x32c29e[a(612)],16),O=65535&_0x589f34.low,Y=0,ee=0,te=0,Z=0;return Z+=SWjMZq.nXHfm(S,O),te+=SWjMZq[a(1646)](Z,16),Z&=65535,te+=h+N,ee+=SWjMZq[a(1646)](te,16),te&=65535,ee+=SWjMZq[a(725)](w,D),Y+=SWjMZq[a(964)](ee,16),ee&=65535,Y+=SWjMZq[a(785)](p,v),Y&=65535,_0x2305ae[a(775)](SWjMZq.UiCwp(te,16)|Z,SWjMZq.THnlx(Y<<16,ee),this.unsigned)}return e[a(581)](t,4)}function w0(i,t){let r=n;if(e[r(678)](e[r(1460)],e[r(816)]))return _0x39f26e||(_0x2070e0=[_0x43615e[r(544)+"e"][r(1174)],_0x4ea333.prototype[r(422)],_0x4971a9[r(544)+"e"][r(422)+r(660)+"ey"]]);{let a=0,d=t,l=e.SfYUW(t,4);for(;e[r(1506)](d,l);){let{value:p,offset:w}=e[r(533)](Ur,i,d);d=w,a=e[r(1176)](a,8)>>>0,a+=p}return{value:a,offset:l}}}function _0(i,t,r){let a=n,d=e[a(1231)][a(1484)]("|"),l=0;for(;;){switch(d[l++]){case"0":if(!i)return r;continue;case"1":if(t[a(524)+"e"])return t.utf8Write(i,r)+r;continue;case"2":return e.yPABw(Br(i,t,r),r);case"3":if(e[a(752)](i.length,40))return e[a(410)](e[a(878)](Br,i,t,r),r);continue;case"4":if(t[a(1672)])return e.kZehq(t[a(1672)](i,r),r);continue}break}}function y0(i,t){let r=n,a=new K(e.yWYYO(e[r(510)](e.lHThr(i[e[r(1505)](t,4)],24),e[r(717)](i[e[r(1882)](t,5)],16)),e[r(1668)](i[t+6],8))|i[e[r(623)](t,7)],e[r(1270)](e[r(661)](e[r(1584)](i[e.Leeih(t,0)],24),e[r(1176)](i[e[r(1863)](t,1)],16)),e[r(1288)](i[t+2],8))|i[e[r(362)](t,3)],!0);return t+=8,{value:a,offset:e[r(623)](t,8)}}function b0(i,t,r){let a=n,d={YYTyQ:function(l,p){return e[T(1651)](l,p)},XLPGj:function(l,p){return e.XOVgo(l,p)}};if(e[a(1198)](a(1013),e[a(1154)])){let l=i[a(612)],p=i[a(1626)];return t[r]=p>>>24,t[e.lhZtw(r,1)]=e[a(939)](p>>>16,255),t[e.dRrpz(r,2)]=e[a(1340)](p,8)&255,t[e[a(984)](r,3)]=e[a(1762)](255,p),t[e[a(758)](r,4)]=e[a(757)](l,24),t[e[a(722)](r,5)]=e[a(428)](e[a(548)](l,16),255),t[e[a(1487)](r,6)]=e[a(361)](e[a(1545)](l,8),255),t[e.EsglC(r,7)]=e[a(400)](255,l),r+=8,r}else{let l=0,p={};for(let w=0;d[a(1043)](w,_0x2fb30f[a(1397)]);w++)p[_0x4125c1[w][a(539)+a(1634)]]=d.XLPGj(_0x2f4b37,_0x14cb31[w][a(539)+"ame"]),l+=14+p[_0x1d222c[w]["cursor_n"+a(1634)]];return[l,p]}}function Ur(i,t){let r=n;return i[r(348)+"8"]?{value:i[r(348)+"8"](t),offset:e[r(1729)](t,1)}:{value:255&i[t],offset:e[r(1085)](t,1)}}function qr(i,t,r){let a=n;return t[a(1075)+"t8"]?t.writeUint8(i,r):t[r]=e[a(836)](255,i),e[a(930)](r,1)}let v0=function(i){return new Uint8Array(i)},S0=e[n(523)](e[n(1493)],typeof Buffer)?Buffer[n(738)+n(1835)]:e[n(970)](g0,v0,Uint8Array[n(544)+"e"].subarray);(()=>{let i=n,t={ICHJb:function(r,a){return e[T(1501)](r,a)},RcSBS:function(r,a){return r|a},YscWR:function(r,a){return r>>>a},HUBeZ:function(r,a){return e[T(1613)](r,a)},aptct:function(r,a){return e[T(1280)](r,a)},xaMrB:function(r,a){return e[T(1639)](r,a)},NZvtD:function(r,a){return e[T(1402)](r,a)},TiSLe:function(r,a){return e[T(1788)](r,a)},gqNBz:function(r,a){return e[T(717)](r,a)},UDVAl:function(r,a){return e[T(1789)](r,a)},KNSZf:function(r,a){return e[T(603)](r,a)},aCoVT:function(r,a){return e[T(1369)](r,a)},rYhfY:function(r,a){return e.VaXWs(r,a)},KUIcA:function(r,a){return e[T(704)](r,a)},YWyNw:function(r,a){return r&a},wFgAv:function(r,a){return e.JVgAl(r,a)},FSnpP:function(r,a){return r&a},GcbCS:function(r,a){return e[T(346)](r,a)},IGCyz:function(r,a){return e.yRlpz(r,a)},CXFYC:e[i(1372)],HeKVY:function(r,a,d,l){return r(a,d,l)}};if(e[i(1329)](e[i(545)],i(924)))throw _0x362438=_0x57b1f9.length,e.JVSwq(_0xe59e20,_0x4bdf96,10,_0x42d845[i(1397)]);{let r=4294967295;return function(a,d,l=!0){let p=i;if(r=(127&a[d])>>>0,t.ICHJb(a[d++],128))return{value:l?r:t.RcSBS(0,r),offset:d};if(r=t[p(659)](r|t[p(771)](t[p(632)](127,a[d]),7),0),t[p(1641)](a[d++],128))return{value:l?r:t[p(1790)](0,r),offset:d};if(r=t[p(1094)](t[p(756)](r,t[p(988)](t[p(1409)](127,a[d]),14)),0),t[p(449)](a[d++],128))return{value:l?r:0|r,offset:d};if(r=t.aCoVT(t[p(1812)](r,t.KUIcA(t.YWyNw(127,a[d]),21)),0),a[d++]<128)return{value:l?r:0|r,offset:d};if(r=t[p(1094)](t[p(1191)](r,t[p(1339)](15,a[d])<<28),0),t[p(1337)](a[d++],128))return{value:l?r:t[p(1812)](0,r),offset:d};if(t[p(1223)](d+=5,a[p(1397)])){if(t.CXFYC!=="ylORl")return(this[p(1482)+"rs"][_0x40b7d6]||(this[p(1482)+"rs"][_0x2a34db]=[])).push({fn:_0x1cac01,ctx:_0xc7cef7||this}),this;throw d=a[p(1397)],t[p(986)](p0,d,10,a[p(1397)])}return{value:l?r:t[p(1790)](0,r),offset:d}}}})();let E0=16,Gr=32;function I0(i){let t=n,r={qFusn:e[t(589)],PrDou:function(a,d){return a+d},qyhIy:function(a,d){return e[t(1158)](a,d)},bAxZt:function(a,d,l,p){return e[t(1638)](a,d,l,p)},gVYhf:function(a,d,l,p){return a(d,l,p)},zUNsV:function(a,d){return e[t(906)](a,d)},tXzXE:"undefined"};if(e[t(905)](e.zlFyX,e[t(1606)])){let a=r.qFusn[t(1484)]("|"),d=0;for(;;){switch(a[d++]){case"0":if(_0x1730e3.utf8Write)return FVbHfh.PrDou(_0x1500ac.utf8Write(_0x1b27bb,_0x334d7d),_0x1c788a);continue;case"1":return FVbHfh[t(1111)](FVbHfh[t(1578)](_0x33a18b,_0x14d237,_0x4ea266,_0x3d6a16),_0x101516);case"2":if(_0x50fe2d[t(1672)])return FVbHfh[t(774)](_0x5e724e[t(1672)](_0x4c13a3,_0x4a2397),_0xea412f);continue;case"3":if(!_0x290ae2)return _0xcefa91;continue;case"4":if(_0x38fb48.length<40)return FVbHfh.qyhIy(FVbHfh.gVYhf(_0x26032e,_0x5165f0,_0x186eb8,_0x56b303),_0x1b4a18);continue}break}}else{let a=0,d={};for(let l=0;e.tckSE(l,i.length);l++)if(e[t(461)](e.DbcIB,t(1249)))d[i[l][t(539)+"ame"]]=e[t(830)](ds,i[l][t(539)+"ame"]),a+=e[t(535)](14,d[i[l][t(539)+t(1634)]]);else{if(_0x5b5c3e)return new _0x4070a4(_0x4b285f[t(1519)],_0x27b3a5[t(1129)]);if(FVbHfh[t(1811)](_0x50e3fc,_0x51705b))return new _0x356ab0(_0x488353.url,_0x30ecc7[t(1129)],_0x4dc320[t(386)]);if(FVbHfh[t(1811)](_0xd5a6a,_0x49067e)&&FVbHfh[t(932)]!=typeof _0x38888e&&_0x24ec93)return new _0x28e4ae(_0x59780d[t(1519)],_0x9a9111[t(1129)+"s"])}return[a,d]}}function hs(i,t,r){let a=n,d={WpaPa:"name",wMQMl:e.TtXec,npwKr:function(S,v,D,N){return e[T(878)](S,v,D,N)},zkUGX:function(S,v,D,N){return e[T(945)](S,v,D,N)},GkBYw:function(S,v,D,N){return e.wXcHc(S,v,D,N)},LhCck:e[a(1044)],PEtlx:e.mbEjz,ihofm:e[a(969)]},[l,p]=e[a(1382)](I0,i),w=e.WTLJJ(S0,l),h=0;return i[a(1278)](S=>{let v=a,D=(v(643)+"|8|3|6|9"+v(848))[v(1484)]("|"),N=0;for(;;){switch(D[N++]){case"0":console[v(1777)](d[v(765)],h);continue;case"1":console.log(d[v(675)],h);continue;case"2":h=b0(K[v(1215)+"er"](S[v(1295)]||t),w,h);continue;case"3":h=d[v(433)](qr,p[S["cursor_n"+v(1634)]],w,h);continue;case"4":h=d[v(1391)](qr,0,w,h);continue;case"5":h=d[v(764)](m0,w,h,S.service||0);continue;case"6":console[v(1777)](d[v(1514)],h);continue;case"7":console[v(1777)](d[v(1699)],h);continue;case"8":console.log(d[v(617)],h);continue;case"9":h=d[v(1391)](_0,S[v(539)+v(1634)],w,h);continue;case"10":console[v(1777)](v(1469)+v(1373),S,S[v(1172)]);continue}break}}),{frameType:Gr,headers:[{key:e[a(1277)],value:r}],payload:w}}function A0(i){let t=n,r=0,a=[];for(;e[t(346)](r,i[t(702)+"th"]);){let{offset:d}=e[t(1162)](Ur,i,r);r=d;let l={cursor_name:"",cursor:0,service:0},{value:p,offset:w}=w0(i,r);l.service=p,r=w;let{value:h,offset:S}=e.KboaM(Ur,i,r);r=S,l[t(539)+t(1634)]=us(i,r,r+h),r+=h;let{value:v,offset:D}=y0(i,r);l.cursor=v[t(832)](),r=D,a.push(l)}return a}function C0(){let i=n;return{frameType:Gr,headers:[{key:e[i(1277)],value:e[i(706)]}],payload:void 0}}class P0{constructor(t,r,a){let d=n;d(1471)===e[d(1866)]?(this[d(1830)+d(1454)]=t,this[d(1115)+d(1800)]=r,this[d(899)+"Strategy"]=a,this[d(1353)]=e[d(1162)](ls,this[d(1830)+"ameSpace"],e[d(768)])):(this.emit(e[d(981)],_0x120cd3),this[d(897)]&&this[d(897)](_0x2cfd79))}async openDB(){let t=n;e[t(1655)](t(1405),"wZPUR")?await this._qosDB[t(1750)]():this[t(868)+t(874)]()}async[n(769)+"rs"](){let t=n;if(t(1018)!==e[t(487)]){if(!this[t(1353)].isReady)return;let r=this["_message"+t(546)],a=await this._qosDB[t(592)]();switch(console[t(1777)](e[t(1841)],a),r){case e[t(440)]:return a&&a[t(1397)]?hs(a,0,this[t(1115)+t(1800)]):void 0;case e[t(1189)]:return;case e[t(437)]:return a&&a.length?hs(a,0,this[t(1115)+t(1800)]):e[t(1763)](C0)}}else{let r="4|2|1|0|3"[t(1484)]("|"),a=0;for(;;){switch(r[a++]){case"0":this[t(371)]=!0;continue;case"1":this["_readyCl"+t(1390)]=!1;continue;case"2":this["_pingLos"+t(1392)]?.[t(1852)+"nter"]();continue;case"3":this[t(783)]();continue;case"4":this[t(334)+t(1261)]?.[t(801)+t(1582)+t(1680)]();continue}break}}}async[n(793)](t,r,a){let d=n;return console[d(1777)](e[d(1783)],t,r,a),this._qosDB.set({cursor_name:t,cursor:r,service:a})}async setCursors(t){let r=n,a=e[r(1082)](A0,t);for(let d of a)console.log(e[r(1494)],a),await this[r(1353)][r(793)](d)}async[n(1612)](t){let r=n;return(await this[r(1353)].get(t))?.[r(1295)]}async closeDB(){let t=n;await this._qosDB[t(1605)]()}[n(1033)+n(1100)+n(1518)](t){this._cursorFileName=t}get[n(1676)](){return this[n(1353)].isReady}}let T0=e[n(514)];async function ps(i){let t=n;if(!this[t(698)][t(1804)+"S"])return null;let{aID:r,fpID:a,messageStrategy:d}=this._options,l=e.tnTWq(i,T0);try{return this[t(1297)+"anager"]?i&&this[t(1297)+t(380)][t(1033)+t(1100)+"Name"](i):this[t(1297)+t(380)]=new P0(a+"_"+r+"_"+l,l,d),this[t(1297)+t(380)][t(1676)]||await this[t(1297)+"anager"][t(1750)](),this[t(1297)+t(380)]}catch{return null}}async function k0(i,t){let r=n,a=e[r(1638)](it,i[r(653)].headers,e.GEKRT,"-1"),d=it(i[r(653)].headers,e[r(479)],"1"),l=It(i[r(653)][r(386)],e.UTNFz),p=Number(It(i[r(653)].headers,e[r(394)]))||0,w=Fr[r(392)](this,i),h=e[r(878)](it,i.message.headers,r(1462)+"s","2"),S=e[r(865)](It,i.message[r(386)],e[r(1287)]),v=e[r(658)](Number,e[r(732)](It,i.message.headers,e.NKTar));if(w.isQoSAck)return e.Aolhg(t);let D=w["isQoSMes"+r(1492)]?await gs[r(392)](this):null;if(i[r(653)][r(1172)]>0&&d&&!a||e[r(402)](i[r(653)].service,0)){if(l&&w[r(522)+"sage"]&&D)return!!!await D[r(1612)](l)&&(this[r(902)+"hMessageEvent"](i),await D[r(793)](l,e[r(729)](Date[r(629)](),p))),e[r(871)](t);if(h)if(e.SwCSY(e.rHmpN,e.zQouT))this.emit(e[r(981)],_0x1d4693(e[r(981)],{..._0x18d6b5}));else{let N=await ps[r(392)](this);if(!N)return this[r(902)+"hMessage"+r(399)](i),e[r(1023)](t);let O=await N[r(1612)](S)??-1;if(O<v)this["_dispatc"+r(1050)+r(399)](i),N[r(793)](S,v,i[r(653)][r(1172)]);else throw new Error(r(1488)+r(1608)+r(1470)+v+(" larger than loc"+r(1507)+"r ")+O);return t()}return this[r(902)+r(1050)+"Event"](i),e[r(871)](t)}}async function D0(i,t){let r=n,a=Fr[r(392)](this,i);if(!a[r(522)+r(1492)])return t();let d=await gs[r(392)](this);if(a[r(502)+r(1877)+r(339)]&&a.ackMsgIds.length)for(let l of a[r(820)+"s"])await d[r(950)](l);e.CjBOh(t)}async function R0(i,t){let r=n,a=e.wJHkk(i.message[r(1195)+"e"],E0),d=e[r(1250)](i[r(653)][r(1195)+"e"],Gr);if(!a&&!d)return t();let l=e[r(826)](It,i[r(653)][r(386)],e.kSdPM);if(!l)return e[r(1888)](t);let p=await ps[r(392)](this,l);if(!p)return e[r(1763)](t);if(a){let w=await p[r(769)+"rs"](),h={frameType:w?.[r(1195)+"e"],SeqID:K[r(1215)+"er"](this[r(1222)]++),LogID:K[r(1215)+"er"](this[r(698)]["logIDGen"+r(1336)]()),service:9e3,method:5,headers:w?.[r(386)],payload:w?.[r(1751)]},S=e[r(1831)](E,h);this[r(1550)]&&this[r(1550)][r(1754)+"te"]&&this[r(1550)][r(558)](S)}if(d){let w=i[r(653)][r(1751)];w&&p[r(1273)+"rs"](w)}}let N0=async function(i,t){let r=n;this._isInit=!1,e[r(1106)](clearTimeout,this[r(783)+r(1425)+r(1548)]),e[r(1829)](t)},L0=async function(i,t){let r=n;if(!this[r(1550)]||e[r(1489)](this[r(1550)].readyState,this[r(1675)]))return e[r(1763)](t);let{pingInterval:a}=this[r(698)];this["_endpoin"+r(1261)]?.["resetEnd"+r(1582)+r(1680)]();for(let l=0;e.VGbyl(l,this[r(899)+r(1120)].length);l++){let p=this["_message"+r(1120)][l];if(this._ws[r(1754)+"te"]===this.OPEN&&e[r(805)](null,p))this[r(1550)]&&this[r(1550)][r(558)](p),this[r(899)+r(1120)][l]=null;else break}this[r(899)+"Queue"]=this[r(899)+"Queue"][r(1216)](l=>!!l),this[r(1282)+r(498)+"Id"]=setTimeout(()=>this[r(652)](),a),this[r(902)+r(745)+"nt"](i),this[r(655)+"er"]&&this[r(1550)]&&(this._ws[r(1181)+"pe"]=this[r(600)+r(657)]);let d=this[r(334)+"tManager"]?.[r(1446)+"ntEndpoint"]();this[r(1238)](r(1030)+d+r(1733)),e[r(665)](t)},O0=async function(i,t){let r=n,a=this[r(334)+r(1261)]?.[r(1446)+r(1725)+"nt"]();this._debug(r(1030)+a),e[r(1833)](t)};class M0 extends Mr{constructor(t){let r=n,a={rTYmR:function(w,h){return e.RUNrp(w,h)},eWUPu:e.EUXUD,iTEfM:function(w,h){return e[T(1730)](w,h)},GkEOa:e[r(1309)],utkwz:e[r(1067)],gWhQg:e[r(432)],uAyKY:function(w,h,S){return e[r(1781)](w,h,S)},IXhjT:function(w,h,S,v){return e.bwUmX(w,h,S,v)},iPbOw:function(w,h){return e[r(426)](w,h)}};super(),this[r(835)+r(1348)+r(1541)]=!0,this[r(655)+"er"]=Et,this[r(957)]=Xc,this._isMiniTT=lt,this[r(1220)+"X"]=Vt,this._isWorker=Jt,this["_message"+r(1120)]=[],this[r(334)+"tManager"]=null,this[r(1380)+r(1390)]=!1,this._binaryType=e[r(1275)],this["_connect"+r(582)]=!1,this[r(783)+r(1425)+r(1548)]=null,this[r(740)+r(1620)+r(1236)]=null,this[r(1282)+r(498)+"Id"]=null,this._seqId=0,this[r(371)]=!1,this[r(1014)]="",this[r(1479)+r(1869)]=null,this[r(1297)+"anager"]=null,this[r(1088)+r(1392)]=null,this._protocols=e.wDCds,this[r(1073)]=3,this[r(412)+"NG"]=0,this[r(1675)]=1,this.CLOSING=2,this[r(1660)]=w=>{let h=r,S={HxzYK:function(v,D,N){return e.EZFRr(v,D,N)}};try{e[h(460)]==="tGyLw"?e[h(945)](xs,this,w,[N0,L0,O0]):(gyhRWY.HxzYK(_0x6553ed,_0x608dae,66),_0x2283c2(_0x449a47,_0x410881.length),gyhRWY[h(1047)](_0xff715a,_0x444b56,_0x5e7e69))}catch(v){let D=e[h(929)](Ce,e[h(1274)],{message:v.message,code:rt.OPEN_ERROR,error:v});this[h(902)+h(538)+h(790)](D)}},this[r(962)+"ge"]=async w=>{let h=r,{pingInterval:S,pingFrequency:v}=this[h(698)];if((a[h(541)]("hi",w[h(1144)])&&a[h(541)](a[h(1461)],v)||a[h(965)](a.GkEOa,v))&&(this[h(577)+"ngTimer"](),this[h(667)](a[h(554)],a[h(1531)]),this["_pingPon"+h(498)+"Id"]=a[h(1625)](setTimeout,this[h(652)][h(389)](this),S)),w.data!=="hi")try{a[h(1151)](xs,this,w,[l0,u0,D0,R0,k0,f0])}catch(D){let N=Ce(h(1326),{message:D.message,code:rt["MESSAGE_"+h(525)],error:D});this[h(902)+h(538)+h(790)](N)}},this[r(1575)]=w=>{let h=r,S=this[h(334)+h(1261)]?.checkReachMaxTries(),v=this[h(334)+h(1261)]?.[h(1446)+"ntEndpoint"]();if(S&&!w[h(653)]){let D="connect "+v+(h(1081)+"ax retri"+h(1463)+"ed");this[h(902)+h(538)+h(790)](Ce(e[h(1274)],{message:D,code:rt[h(630)+"IES_ERROR"],error:w}));return}this._ws&&e[h(1228)](this[h(1550)][h(1754)+"te"],this[h(1675)])&&this[h(1669)+h(742)](),this["_dispatc"+h(538)+h(790)](e[h(1058)](Ce,e[h(1274)],{message:w.message,code:rt[h(1083)+h(1561)],error:w}))},this[r(1554)]=async w=>{let h=r;this[h(1602)+"mer"](),this["_clearPi"+h(503)](),this[h(1636)+"sListeners"](),this[h(1550)]=null,this["_connect"+h(582)]=!1;let S=this[h(334)+h(1261)]?.[h(1881)+h(862)+"es"]();if(!S&&this[h(1546)+h(1148)]()&&!this[h(1380)+h(1390)])if(e[h(1489)](e.ZMZMF,e[h(1315)])){let v=this[h(334)+h(1261)]?.[h(1446)+h(1725)+"nt"](),D=this[h(698)][h(418)+h(736)+"ptor"](w[h(1599)],w[h(767)]);this[h(902)+h(1046)+h(790)](e[h(1334)](Re,e[h(981)],{code:1006,reason:w[h(767)]||h(786)+h(1596)+h(1089)+h(424)+h(1257)+h(1166)+v,willReconnect:D})),D&&this._connect();return}else _0x496a76[h(1777)](_0x355299);if(e[h(1054)](1e3,w[h(1599)])&&this._readyClosed)if(h(817)!==e[h(1435)])a[h(1146)](_0x2b81c2,this[h(783)+"ionTimeo"+h(1548)]),this["_connectionTimeo"+h(1548)]=null;else{this[h(902)+h(1046)+h(790)](e[h(732)](Re,e[h(981)],{code:1e3,reason:h(381)})),this["_endpoin"+h(1261)]?.[h(801)+"pointConfig"](),this[h(1088)+h(1392)]?.["resetCou"+h(650)]();return}if(e[h(1670)](1e3,w.code)&&S){let v=this["_endpoin"+h(1261)]?.["getCurre"+h(1725)+"nt"](),D=w[h(767)];D||(D=await e[h(1102)](s0,this[h(1014)])),D=h(786)+h(1596)+h(1618)+D+(h(1814)+h(1365))+v+(", max re"+h(921)+"ached"),this[h(902)+h(1046)+h(790)](e[h(1700)](Re,e.xzNtr,{code:w.code,reason:D}));let N=h(807)+v+(h(1081)+h(819)+"es reached");this["_dispatc"+h(538)+"ent"](Ce(e[h(1274)],{message:N,code:rt["MAX_RETR"+h(569)+"R"]})),this[h(334)+"tManager"]?.[h(801)+h(1582)+h(1680)](),this[h(1088)+h(1392)]?.["resetCou"+h(650)]();return}if(e[h(476)](1e3,w[h(1599)])&&!w[h(767)]){let v=this[h(334)+"tManager"]?.[h(1446)+h(1725)+"nt"]();this["_dispatc"+h(1046)+"ent"](Re(e[h(981)],{code:w.code,reason:h(786)+h(1596)+h(1089)+h(424)+"n, hostn"+h(1166)+v})),this[h(334)+h(1261)]?.[h(801)+h(1582)+h(1680)](),this[h(1088)+h(1392)]?.[h(1852)+h(650)]();return}this[h(902)+h(1046)+h(790)](w),this["_endpoin"+h(1261)]?.[h(801)+h(1582)+"fig"](),this["_pingLos"+h(1392)]?.[h(1852)+h(650)]()},this[r(897)]=null,this[r(1302)]=null,this[r(552)+"e"]=null,this[r(1466)]=null,this["onStartR"+r(1677)]=null,this[r(640)+r(694)]=null,this[r(353)+r(1243)+r(1498)+"ct"]=null,this[r(1424)+r(1731)]=this[r(1424)+r(1731)][r(389)](this),this[r(1424)+r(715)]=this[r(1424)+r(715)][r(389)](this),this[r(887)+r(1453)]=this[r(887)+r(1453)][r(389)](this),this["_handleP"+r(904)]=this["_handleP"+r(904)].bind(this),this._options={url:"",automaticOpen:!0,initReconnectInterval:1e3,maxReconnectInterval:1e4,reconnectIntervalGrowFactor:2,timeoutInterval:5e3,maxRetries:5,debug:!1,maxMessageQueueLength:e[r(1640)](1,0),service:0,logIDGenerator:c,headers:void 0,payloadEncoding:"",payloadType:"",fpID:"",deviceID:"",accessKey:"",ttwID:"",bddID:"",aID:"",disableAutoReconnect:!1,customParams:{},pingInterval:15e3,pingTimeoutInterval:4e3,pingFrequency:e.QebgA,pingLossCount:2,enableTransformTextPayload:!1,logIDNewConfig:{enableAutoGenerateLogIDNew:!1,userIp:""},miniProgramParams:{customHttpHeader:{}},enableAutoAck:!1,reconnectInterceptor:()=>!0,enableQoS:!1,QoSLevel:2,messageStrategy:e[r(437)],env:{xTTEnv:"",xUseEnv:""},listenNetworkChanged:!0};let{url:d,ws:l}=t,p=Array.isArray(d)?d:e.mQKcO(e[r(1237)],typeof d)?[d]:[];if(!p||e[r(1161)](0,p.length))throw new Error(e[r(1563)]);if(!e[r(658)](t0,l))throw new Error(e.lNLNI);if(Object[r(978)](this[r(698)],t),this["_endpoin"+r(1261)]=new cs(p,this[r(698)].maxRetries),this[r(1088)+"sCounter"]=new i0(this._options[r(883)+r(1540)]),this[r(698)]["automati"+r(1704)]&&(this[r(371)]=!0,this._connect()),this[r(698)][r(1845)+"tworkCha"+r(1875)])if(e[r(1098)](r(1345),e[r(1883)]))this[r(598)+"T"]||this[r(1220)+"X"]?this["_onPageN"+r(1072)+r(1192)]():this._isBrowser&&this[r(1079)+r(1090)+r(691)]();else{let{type:w}=_0x65fd29;this.emit(w,_0x150734)}}[n(1424)+"nLine"](){let t=n;this._options[t(1303)+t(1051)+t(1214)]||this[t(1380)+t(1390)]||this[t(1580)+t(1677)]()}[n(1424)+n(715)](){let t=n;this["_destroy"+t(628)+"t"]();let r=e[t(1355)](Or,"reconnect",{message:e[t(515)]});this["onStopIm"+t(1243)+"yReconnect"]&&this[t(353)+t(1243)+t(1498)+"ct"](r)}[n(1079)+"balEventListener"](){let t=n,r={lVpYC:function(a,d){return e[T(708)](a,d)},NwyJP:function(a,d){return e[T(430)](a,d)},eHcBC:function(a,d){return a>>>d},ePGlz:function(a,d){return e.lROVC(a,d)},llYAf:function(a,d){return e[T(428)](a,d)},qNOSM:function(a,d){return e[T(1255)](a,d)},pCqAR:function(a,d){return e[T(1284)](a,d)},xmAag:function(a,d){return e.CaKSw(a,d)}};if(e[t(1098)](e.iPiah,e[t(1837)]))return _0x55e815[t(741)+t(1643)](LEkaTG[t(898)](255,this.low),LEkaTG[t(626)](LEkaTG[t(404)](this.low,8),255),LEkaTG.lVpYC(this[t(612)]>>>16,255),this.low>>>24,LEkaTG[t(1457)](255,this[t(1626)]),LEkaTG[t(1086)](LEkaTG.qNOSM(this[t(1626)],8),255),LEkaTG[t(1533)](LEkaTG[t(378)](this[t(1626)],16),255),LEkaTG.eHcBC(this[t(1626)],24));this[t(655)+"er"]&&window[t(877)+t(691)](e.xTuZu,this[t(1424)+"nLine"]),this[t(655)+"er"]&&window.addEventListener(e[t(464)],this[t(1424)+"ffLine"]),this[t(655)+"er"]&&window[t(877)+t(691)](t(1868),this[t(887)+t(1453)]),this._isBrowser&&window["addEvent"+t(691)](e[t(1368)],this[t(887)+t(904)])}[n(911)+n(1090)+n(691)](){let t=n;this[t(655)+"er"]&&window[t(401)+"entListe"+t(651)](e[t(842)],this[t(1424)+t(1731)]),this._isBrowser&&window["removeEv"+t(1658)+"ner"](e[t(464)],this["_handleO"+t(715)]),this[t(655)+"er"]&&window[t(401)+"entListener"](e[t(1171)],this[t(887)+t(1453)]),this[t(655)+"er"]&&window[t(401)+t(1658)+t(651)](e[t(1368)],this[t(887)+"ageShow"])}[n(887)+"ageHide"](t){let r=n,a={xnYkV:function(d,l,p){return e.SgyOv(d,l,p)}};if(e[r(1098)](r(1121),r(1121)))!t[r(625)+"d"]&&(this[r(655)+"er"]&&window[r(401)+"entListener"](e.xtZCL,this[r(887)+"ageHide"]),this._isBrowser&&window[r(401)+"entListe"+r(651)](e.KiYYX,this[r(887)+r(904)]),this.close()),this[r(655)+"er"]&&window[r(401)+r(1658)+r(651)](e[r(842)],this[r(1424)+r(1731)]),this._isBrowser&&window["removeEv"+r(1658)+"ner"](e[r(464)],this[r(1424)+r(715)]);else{this[r(577)+"ngTimer"](),this[r(1282)+r(498)+"Id"]=a[r(1184)](_0x479ef6,this[r(652)].bind(this),this._options[r(1579)+r(606)]);return}}["_handleP"+n(904)](t){let r=n;t[r(625)+"d"]&&(this["_navigat"+r(1148)]()&&(!this[r(1550)]||e[r(784)](this[r(1550)][r(1754)+"te"],this.OPEN)||e.FGJTS(this[r(1550)][r(1754)+"te"],this.CONNECTING))&&this[r(1424)+"nLine"](),this[r(655)+"er"]&&window[r(877)+r(691)](e.xTuZu,this[r(1424)+"nLine"]),this[r(655)+"er"]&&window[r(877)+"Listener"](e[r(464)],this["_handleO"+r(715)]))}async[n(1201)+n(1778)](t){let r=n,{fpID:a,deviceID:d,bddID:l,ttwID:p,accessKey:w,aID:h,customParams:S={},enableAutoAck:v,enableQoS:D,QoSLevel:N,env:O}=this[r(698)],Y,ee,te;this._isBrowser||this[r(1220)+"X"]||this._isMiniTT?(Y=location&&e.mQKcO(e.Eoylv,location[r(1129)])?e[r(1723)]:e[r(1299)],ee=t[r(1092)](/((^ws)|(^http))((?:[s]*:\/\/))/,""),te=/^wss(.*:\/\/)/.test(t)?t:""+Y+ee):(Y=e[r(1723)],ee=t[r(1092)](/(^http)((?:[s]*:\/\/))/,""),te=/(^ws)((?:[s]*:\/\/))/[r(944)](ee)?ee:""+Y+ee);let Z=l?e.YNhNC:p?e.bbdMc:e[r(872)],At=l||p||d;if(e[r(916)](!At,!Z))throw new Error(e[r(561)]);let B0=e[r(1553)](e[r(1717)],typeof S)?await e.ZvRIN(S):S,z0=O?e[r(917)](r0,O.xUseEnv,O[r(409)]):{},Hr=Object.assign({device_platform:"web",version_code:e[r(1443)],access_key:w,fpid:a,aid:h,[Z]:At,xsack:v?1:0,xaack:v?1:0,xsqos:D?1:0,qos_level:D?N:void 0,qos_sdk_version:2,...z0},B0),F0=Object[r(788)](Hr)[r(800)]((Kr,Wr)=>Hr[Wr]!==void 0?""+Kr+(Kr?"&":"?")+Wr+"="+Hr[Wr]:Kr,"");return te+r(567)+F0}async[n(783)](){let t=n,r={xwAXx:function(a,d){return e[T(356)](a,d)},XKtOH:function(a,d){return a>d},KfsQp:function(a,d){return e.AyBcV(a,d)},XThmy:function(a,d){return e.TvdoF(a,d)},cvUli:function(a,d){return e[T(885)](a,d)}};if(!(this[t(783)+t(582)]||this[t(1380)+"osed"])){this[t(783)+t(582)]=!0;try{let a=this[t(334)+"tManager"]?.[t(486)+t(946)+t(847)+t(1747)+t(478)](),{timeoutInterval:d}=this[t(698)];if(a){let p=this[t(334)+t(1261)]?.getCurrentEndpoint(),w=this[t(334)+"tManager"]?.[t(529)+t(1681)+t(792)+"UpdateCount"](),h=this[t(334)+t(1261)]?.["getCurre"+t(1725)+t(455)+t(1555)]();if(w){let S=t(807)+p+(t(854)+t(1410)+t(921)+t(489)+t(935)+"backup e"+t(703))+w+(t(594)+"y"),v=e[t(1328)](Ce,e.aECEu,{message:S,code:rt["MAX_RETR"+t(569)+"R"]});this[t(1238)](S),this[t(902)+t(538)+"ent"](v),this[t(1014)]=await this[t(1201)+t(1778)](w),this[t(1238)]("connect "+w+" "+h+t(1765)),this[t(1636)+t(713)+"rs"]()}else{let S=t(807)+p+(t(854)+t(1410)+t(921)+"ached");this._debug(S),this[t(902)+t(538)+"ent"](e.ZzCuC(Ce,t(1326),{message:S,code:rt[t(630)+t(569)+"R"]}));return}}else if(e[t(1551)](e[t(472)],t(1074))){let p=this[t(334)+t(1261)]?.[t(1446)+t(1725)+t(958)+t(1028)](),w=this["_endpoin"+t(1261)]?.[t(1446)+t(1725)+t(455)+t(1555)]();this[t(1014)]=await this[t(1201)+t(1778)](e.BtwMy(p,"")),this[t(1238)](t(807)+p+" "+w+" times"),this[t(1636)+t(713)+"rs"]()}else{let p=e[t(1178)](_0x52fd32,8192),w=e[t(999)](p,1),h=null,S=p;return function(v){let D=t;if(v<1||shbpqo[D(408)](v,w))return _0x4ca896(v);shbpqo[D(1694)](S+v,p)&&(h=_0x36e655(p),S=0);let N=_0x5b4736.call(h,S,S+=v);return shbpqo.KfsQp(7,S)&&(S=shbpqo[D(1859)](shbpqo[D(668)](7,S),1)),N}}if(this[t(371)])this[t(371)]=!1;else{let p=e.uPpSh(Or,e[t(1224)],{message:e[t(1846)]});this[t(596)+t(1677)]&&this["onStartR"+t(1677)](p)}let l=this[t(334)+t(1261)]?.["getCurre"+t(1725)+t(455)+t(1555)]()||0;e[t(1720)](l,1)&&await this[t(1048)](l-1),this[t(1238)](t(786)+"ng url: "+this._url+(t(1186)+"ls: ")+this._protocols),this._ws=e0({url:this[t(1014)],protocols:[this[t(1452)+"ls"]],headers:this._options[t(1006)+t(1475)+"s"][t(456)+"tpHeader"]},this[t(698)].ws),(this._isBrowser||this[t(1142)+"r"])&&this[t(1550)]&&(this._ws[t(1181)+"pe"]=this[t(600)+t(657)]),this[t(555)+"steners"](),this._connectionTimeoutId=e[t(1781)](setTimeout,this[t(1026)+"ut"].bind(this),d)}catch(a){if(e[t(584)](e[t(459)],e[t(459)]))throw this._connectLock=!1,a;try{this[t(1550)]&&this[t(1550)].close(_0x2c1d31,_0x3e2dac)}catch{}}}}[n(1602)+n(1748)](){let t=n;clearTimeout(this[t(783)+t(1425)+"utId"]),this[t(783)+t(1425)+t(1548)]=null}[n(577)+n(503)](){let t=n;e[t(611)](clearTimeout,this["_pingPon"+t(498)+"Id"]),e[t(1114)](clearTimeout,this[t(740)+"ctTimeoutId"]),this[t(1282)+"gTimeoutId"]=null,this["_reconnectTimeou"+t(1236)]=null}[n(1238)](...t){let r=n;this[r(698)].debug&&console[r(1777)].apply(console,[e[r(869)],...t])}[n(1497)+n(956)+"e"](t){let r=n,{initReconnectInterval:a,maxReconnectInterval:d,reconnectIntervalGrowFactor:l}=this._options,p=e.QAjiQ(a,Math[r(777)](l,e[r(746)](t,1)));return e[r(435)](p,d)?d:p}[n(652)](){let t=n;if(this[t(1550)]&&e[t(1683)](this[t(1550)][t(1754)+"te"],this[t(412)+"NG"])){this[t(577)+t(503)](),this[t(1282)+t(498)+"Id"]=e[t(533)](setTimeout,this[t(652)].bind(this),this[t(698)][t(1579)+"rval"]);return}if(!this[t(1550)]||e[t(812)](this[t(1550)][t(1754)+"te"],this[t(1675)]))return void this[t(1580)+"econnect"]();this[t(1550)]&&this[t(1550)].send("hi"),this[t(740)+t(1620)+t(1236)]=e[t(1087)](setTimeout,this[t(1580)+t(1677)+t(1560)][t(389)](this),this[t(698)][t(528)+"outInter"+t(363)])}[n(1580)+n(1677)+n(1560)](){let t=n;if(e.vCPBB(e[t(550)],e[t(1552)]))return WrpgGZ[t(1114)](_0x24f86d,_0x3cb73c[t(1262)](_0x4a98a0(this),_0x4310b8));this[t(1088)+"sCounter"]?.[t(641)](),this[t(667)](t(1707)+t(763)+"t","timeout"),this[t(1088)+t(1392)]?.checkReachMaxCount()?this[t(1580)+"econnect"]():this[t(652)]()}[n(1546)+"orOnline"](){let t=n;return this[t(598)+"T"]||this[t(1220)+"X"]?this["_miniNavigatorOn"+t(1541)]:(this[t(655)+"er"]||this._isWorker)&&this[t(698)][t(1845)+t(1399)+t(1875)]?navigator.onLine:!0}[n(1580)+n(1677)](){let t=n;!this[t(1546)+t(1148)]()||this["_readyCl"+t(1390)]||(this[t(334)+t(1261)]?.[t(801)+t(1582)+"fig"](),this[t(1088)+t(1392)]?.[t(1852)+t(650)](),this[t(1550)]?this[t(1669)+t(742)](1001,e[t(927)],!0):this._connect())}[n(406)+n(1072)+"ange"](){let t=n;this[t(598)+"T"]?tt["onNetwor"+t(804)+t(1864)](({isConnected:r})=>{let a=t;this[a(835)+"igatorOn"+a(1541)]=r,r?this[a(1424)+a(1731)]():this[a(1424)+a(715)]()}):this[t(1220)+"X"]&&wx[t(1524)+t(804)+"hange"](({isConnected:r})=>{let a=t;this[a(835)+"igatorOnline"]=r,r?this[a(1424)+"nLine"]():this._handleOffLine()})}[n(1048)](t){return new Promise(r=>{let a=T,d={nhFqP:function(l,p){return e[T(658)](l,p)},zURcP:"success",wOPck:a(1707)+a(1595)+"s",GzbIR:e[a(670)],SFwWI:function(l,p,w){return e.UwdLy(l,p,w)}};if(e[a(461)](e[a(1772)],e[a(1772)]))e[a(1341)](setTimeout,r,this["_getInte"+a(956)+"e"](t));else{this[a(577)+a(503)](),this[a(1282)+a(498)+"Id"]=d.SFwWI(_0x1baf98,this[a(652)].bind(this),this[a(698)]["pingInte"+a(606)]);let l=()=>{let w=a;d.nhFqP(_0x21027f,d[w(634)]),this[w(387)](d[w(1547)],l),this[w(387)](w(1707)+w(763)+"t",p)},p=()=>{let w=a;d[w(1712)](_0xf13705,w(1292)),this[w(387)](d.wOPck,l),this[w(387)](d[w(966)],p)};this.on(d[a(1547)],l),this.on(d.GzbIR,p),this[a(652)]()}})}[n(1669)+n(742)](t=1e3,r="",a=!1){let d=n;this._ws&&this[d(462)+d(628)+"t"](t,r,a)}[n(1026)+"ut"](){let t=n,r=this[t(334)+t(1261)]?.[t(1446)+t(1725)+"nt"]();this[t(1238)](t(807)+r+t(854)),this[t(1669)+t(742)](1001,e[t(997)],!0)}[n(662)](t){let r=n,a=e[r(1813)](oe,t);this._ws&&this[r(1550)][r(1754)+"te"]===this[r(1675)]&&(this[r(1550)]&&this[r(1550)][r(558)](a),this._debug(e.TsKjY,t))}[n(1636)+"sListeners"](){let t=n,r=e[t(336)][t(1484)]("|"),a=0;for(;;){switch(r[a++]){case"0":this._ws.removeEventListener(e[t(1459)],this[t(962)+"ge"]);continue;case"1":this[t(1550)][t(401)+t(1658)+"ner"](t(1326),this._onError);continue;case"2":this._ws[t(401)+t(1658)+"ner"](e[t(981)],this[t(1554)]);continue;case"3":if(!this._ws)return;continue;case"4":this[t(1550)][t(401)+t(1658)+"ner"](e.GvJPZ,this[t(1660)]);continue}break}}_addWsListeners(){let t=n;this._ws&&(this[t(1550)][t(877)+t(691)](e[t(1769)],this[t(1660)]),this[t(1550)][t(877)+t(691)](e[t(981)],this[t(1554)]),this[t(1550)][t(877)+t(691)](e[t(1459)],this[t(962)+"ge"]),this[t(1550)][t(877)+t(691)](e[t(1274)],this._onError))}["_wsInsta"+n(384)](t=1e3,r=""){let a=n;try{this[a(1550)]&&this[a(1550)][a(475)](t,r)}catch{}}[n(462)+"WebSocket"](t=1e3,r="",a=!1){let d=n;if(e[d(1248)](e[d(583)],"eHQWy")){if(this[d(577)+d(503)](),this[d(1602)+d(1748)](),this[d(1636)+d(713)+"rs"](),this[d(1721)+d(384)](1e3,r),this[d(783)+d(582)]=!1,a&&this["_navigat"+d(1148)]()&&!this[d(1380)+d(1390)]){if(this[d(334)+d(1261)]?.[d(1881)+d(862)+"es"]()){let p=this._endpointManager?.[d(1446)+d(1725)+"nt"]();this[d(902)+d(1046)+d(790)](e[d(1003)](Re,d(475),{code:1006,reason:d(807)+p+(d(854)+", max re"+d(921)+d(1286)),wasClean:!0}))}else{let p=this._options[d(418)+d(736)+d(1627)](t,r);this[d(902)+"hCloseEv"+d(790)](e.FAcSN(Re,d(475),{code:t,reason:r,wasClean:!0,willReconnect:p})),p&&this[d(783)]()}return}this._navigatorOnline()||this["_readyCl"+d(1390)]?this["_dispatc"+d(1046)+"ent"](e[d(1423)](Re,e[d(981)],{code:t,reason:d(381)})):this[d(902)+d(1046)+d(790)](e[d(1134)](Re,e[d(981)],{code:1006,reason:"going aw"+d(374)+d(618)+d(1431)})),this._ws=null,this[d(334)+"tManager"]?.["resetEnd"+d(1582)+d(1680)](),this[d(1088)+d(1392)]?.[d(1852)+d(650)]()}else{let l=0,p=0,w;do w=e[d(799)](_0x5c5b50,_0x1b362b),l<32&&(p|=e.IWJLM(127&w,l)),l+=7;while(e[d(505)](128,w));return p}}[n(902)+"hOpenEvent"](t){let r=n;this[r(667)](e[r(1769)],t),this[r(1466)]&&this[r(1466)](t)}[n(902)+n(1050)+n(399)](t){let r=n;this[r(667)](e[r(1459)],t),this[r(552)+"e"]&&this[r(552)+"e"](t)}[n(902)+n(1589)+"ageEvent"](t){let r=n;this[r(667)](e[r(1876)],t),this[r(640)+r(694)]&&this[r(640)+r(694)](t)}[n(902)+n(538)+n(790)](t){let r=n,a={vwkyc:r(1326)};e[r(415)](e.absqi,e[r(699)])?(this[r(667)](e[r(1274)],t),this.onerror&&this[r(1302)](t)):(this[r(667)](a[r(1628)],_0x5bb5f7),this[r(1302)]&&this[r(1302)](_0x16562e))}[n(902)+n(1046)+n(790)](t){let r=n;this[r(667)](e[r(981)],t),this[r(897)]&&this[r(897)](t)}get[n(1181)+"pe"](){let t=n;return this._ws?this._ws[t(1181)+"pe"]:this[t(600)+"ype"]}set binaryType(t){let r=n;this[r(600)+r(657)]=t,this._ws&&(this[r(1550)].binaryType=t)}get[n(925)+"nt"](){let t=n;return this["_endpoin"+t(1261)]?.[t(1446)+t(1725)+t(455)+t(1555)]()||0}get[n(940)+n(585)](){let t=n;return this[t(899)+t(1120)][t(800)]((a,d)=>(a+=d&&d[t(702)+"th"]||0,a),0)+(this[t(1550)]?this[t(1550)][t(940)+t(585)]:0)}get[n(700)+"ns"](){let t=n;return this[t(1550)]?this[t(1550)].extensions:""}get protocol(){let t=n;if(e.xOgyb!==e.FlCvz)return this[t(1550)]?this[t(1550)][t(1129)]:"";{let r={aYOMr:e[t(1274)],eeDRr:e.xzNtr};_0x5f1681[t(828)]()[t(364)](()=>{let a=t,d=_0x29ca0f(r[a(1632)],{message:this["_formatE"+a(644)+a(339)](_0x360d43)});this[a(667)](a(1326),d);let l=_0x24c5a4(a(475),{reason:this[a(975)+a(644)+a(339)](_0x2747ae)});this[a(667)](r[a(1021)],l)})}}get[n(1754)+"te"](){let t=n;return this[t(1550)]?this[t(1550)][t(1754)+"te"]:this[t(698)].automaticOpen?this.CONNECTING:this[t(1073)]}get[n(1519)](){let t=n;return this[t(1550)]?this[t(1550)][t(1519)]:this._url}[n(475)](t=1e3,r){let a=n,d=("2|6|7|4|"+a(1311))[a(1484)]("|"),l=0;for(;;){switch(d[l++]){case"0":if(!this[a(1550)])return void this._debug(e.YUcUU);continue;case"1":if(e[a(955)](this._ws[a(1754)+"te"],this[a(1073)])||e[a(614)](this[a(1550)].readyState,this[a(647)]))return void this[a(1238)](e[a(1809)]);continue;case"2":this[a(1380)+"osed"]=!0;continue;case"3":this["_destroy"+a(628)+"t"](t,r);continue;case"4":this[a(911)+a(1090)+a(691)]();continue;case"5":this[a(1479)+"ger"]?.closeDB();continue;case"6":this[a(1602)+a(1748)]();continue;case"7":this[a(577)+a(503)]();continue}break}}async send(t,r){let a=n,d={vABts:function(te,Z){return e[T(1583)](te,Z)},yizhc:function(te,Z){return e[T(1861)](te,Z)},btaBh:function(te,Z){return e[T(916)](te,Z)},aWYJd:e.OCzus,kJwLE:e.GvJPZ,QkxXp:e.xzNtr,jxDNq:e.ftZdL,LgrGd:e[a(1274)]};if(e[a(557)](null,t))throw new Error(e[a(568)]);e[a(1886)](e[a(1858)],typeof t)&&(t=JSON.stringify(t)),e.hcXUZ!=typeof t&&!(t instanceof ArrayBuffer)&&!(t[a(1056)]&&e.kCupx(t[a(1056)],ArrayBuffer))&&(t=JSON[a(1444)+"y"](t));let l=await e[a(458)](fs,t),p=e.KQakv(n0,t),{method:w=0,service:h=this[a(698)][a(1172)],logID:S=this[a(698)]["logIDGen"+a(1336)](),headers:v=this[a(698)][a(386)],payloadEncoding:D=this[a(698)]["payloadE"+a(972)],payloadType:N=this._options[a(795)+"ype"],logIDNew:O=this._options[a(621)+a(588)][a(1356)+a(844)+"teLogIDNew"]?e[a(351)](o,this[a(698)].logIDNewConfig[a(1650)]):""}=e[a(941)](r,{});if(!h)throw new Error(e[a(1364)]);let Y={SeqID:K[a(1215)+"er"](this[a(1222)]++),LogID:K[a(1215)+"er"](S),service:h,method:w,headers:v,payloadEncoding:e[a(960)](D,Object)?D[a(856)]?D.encoding:"":D,payloadType:e[a(1779)](N,Object)?N[a(379)]?N.type:p:N||p,payload:l,LogIDNew:O},ee=e.nFzKU(oe,Y);if(this[a(1550)]&&e[a(415)](this._ws[a(1754)+"te"],this[a(1675)]))if(e[a(1135)]!==e[a(1135)]){if(_0x4fbb59||_0x3486ad)return new _0x1f8f64(_0x1368b8,_0x57042f);if(nNfFch.vABts(_0x55ed6b,_0x428250)&&nNfFch.yizhc(a(1537)+"d",typeof _0x3691f4))return new _0x5a1089(_0x32943f,_0x3a71a6);if(nNfFch[a(1414)](_0x4826e8,_0x12a5e1)&&nNfFch[a(1592)](a(1537)+"d",typeof _0xd8a177))return new _0x30aad8(_0x4b24e6,_0x3c1042);throw new _0x845a78(nNfFch[a(888)])}else this._ws&&this[a(1550)][a(558)](ee),this._debug(e[a(701)],Y);else if(e[a(1506)](this[a(899)+a(1120)][a(1397)],this._options[a(952)+"geQueueL"+a(1771)]))this[a(899)+"Queue"][a(1258)](ee),this[a(1238)](e[a(684)],Y);else if(e[a(445)](a(1535),e[a(1313)])){if(!this._ws)return;this[a(1550)][a(401)+a(1658)+a(651)](nNfFch[a(1820)],this._onOpen),this._ws[a(401)+"entListener"](nNfFch.QkxXp,this[a(1554)]),this[a(1550)][a(401)+a(1658)+"ner"](nNfFch[a(1798)],this[a(962)+"ge"]),this[a(1550)][a(401)+"entListe"+a(651)](nNfFch[a(474)],this._onError)}else this[a(899)+a(1120)][a(649)](),this[a(899)+a(1120)][a(1258)](ee);return{seqID:this[a(1222)],logID:S,logIDNew:O}}async reconnect(t){let r=n,{url:a}=e[r(1850)](t,{}),d=Array[r(993)](a)?a:e[r(557)](e[r(1237)],typeof a)?[a]:[];t&&Object[r(978)](this[r(698)],t),d&&d[r(1397)]?this._endpointManager=new cs(d,this[r(698)][r(1766)+"es"]):this[r(334)+r(1261)]?.[r(801)+r(1582)+r(1680)](),this[r(1088)+r(1392)]?.[r(1852)+r(650)](this[r(698)][r(883)+"Count"]),this._readyClosed=!1,this[r(1550)]&&e.kYPLi(this[r(1550)][r(1754)+"te"],this[r(1073)])?this["_disconn"+r(742)](1e3,"manual reconnect"+r(1445),!0):(this[r(371)]=!0,this._connect())}async[n(1887)](){let t=n;!this._connectLock&&(this[t(334)+t(1261)]?.[t(801)+"pointCon"+t(1680)](),this._pingLossCounter?.[t(1852)+t(650)](),this[t(1380)+t(1390)]=!1,this._isInit=!0,this[t(783)]())}[n(877)+"Listener"](t,r){let a=n,d={uowRi:function(l,p){return e[T(749)](l,p)}};if(e[a(509)]!==e[a(1187)])this.on(t,r);else if(HJdpLq[a(1346)](_0xfe87c6,_0x586e43))return _0x1b0142}[n(540)+n(399)](t){let r=n,{type:a}=t;this[r(667)](a,t)}[n(401)+"entListe"+n(651)](t,r){let a=n;if(e[a(891)](a(1499),e.JPgUj)){let d=_0x52a527[a(841)];e.yZkey(void 0,d)&&(e[a(1786)](_0x2992f2,_0x2cc9f0,10),e.fhYOc(_0x1f5d73,_0x45be23,d));let l=_0x111844[a(797)];e[a(810)](void 0,l)&&(e[a(1691)](_0x55b10f,_0x5a1440,18),_0x2bd68d(_0x2d432c,l))}else this.off(t,r)}pingOnce(){let t=n,r={vDRbE:function(a,d){return e[T(426)](a,d)},qmqUW:e[t(432)],vMRGH:t(1707)+t(1595)+"s",prQem:e[t(822)],cidiz:function(a,d){return a===d},aNcnQ:t(1347),tqLJe:function(a,d,l){return a(d,l)},MTtZt:e[t(670)]};return new Promise((a,d)=>{let l=t,p={RUkve:function(w,h){return r[T(1851)](w,h)},jmdPd:r.prQem,yfBCj:l(1707)+l(763)+"t"};if(r[l(1377)]("pZubA",r[l(979)])){this[l(577)+l(503)](),this[l(1282)+l(498)+"Id"]=r[l(1476)](setTimeout,this[l(652)].bind(this),this._options.pingInterval);let w=()=>{let S=l;r[S(1851)](a,r[S(601)]),this.off(r[S(1836)],w),this[S(387)](S(1707)+S(763)+"t",h)},h=()=>{let S=l;p.RUkve(d,p[S(1321)]),this[S(387)](S(1707)+"e_success",w),this[S(387)](p[S(1674)],h)};this.on(r.vMRGH,w),this.on(r[l(1352)],h),this[l(652)]()}else this[l(899)+l(1120)][l(1258)](_0x47c738),this._debug(l(365),_0x1f891d)})}}})(),X["CustomCl"+k(754)]=ie[k(1539)+k(754)],X[k(671)+k(532)]=ie[k(671)+k(532)],X[k(468)+"e"]=ie[k(468)+"e"],X[k(399)]=ie[k(399)],X[k(1884)]=ie.FWS,X[k(1722)+k(1034)+k(1344)]=ie["Frontier"+k(1034)+"vent"],X[k(1034)+"vent"]=ie[k(1034)+k(1344)],X[k(637)+"t"]=ie[k(637)+"t"],X[k(1291)+k(559)]=ie[k(1291)+k(559)],X[k(1738)+k(754)]=ie[k(1738)+"oseEvent"],X["createEr"+k(532)]=ie[k(1376)+k(532)],X[k(1490)+"ssageEvent"]=ie["createMe"+k(1105)+"nt"],X[k(1455)+k(407)]=ie[k(1455)+k(407)],X[k(1350)+k(923)+"vent"]=ie[k(1350)+"connectEvent"],X.decodedFrame=ie[k(631)+"rame"],X.encodeFrame=ie[k(1208)+k(1634)];for(Qn in ie)["CustomCl"+k(754),k(671)+"rorEvent",k(468)+"e",k(399),k(1884),"FrontierMessageE"+k(1344),"MessageEvent",k(637)+"t",k(1291)+k(559),"createCloseEvent","createEr"+k(532),"createMessageEvent","createOpenEvent","createReconnectEvent","decodedF"+k(712),k(1208)+"ame"][k(395)](Qn)===-1&&(X[Qn]=ie[Qn]);function T(n,e){n=n-334;let s=sr(),o=s[n];if(T.NDuNUY===void 0){var c=function(g){let m="abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789+/=",y="",_="";for(let E=0,C,I,P=0;I=g.charAt(P++);~I&&(C=E%4?C*64+I:I,E++%4)?y+=String.fromCharCode(255&C>>(-2*E&6)):0)I=m.indexOf(I);for(let E=0,C=y.length;E<C;E++)_+="%"+("00"+y.charCodeAt(E).toString(16)).slice(-2);return decodeURIComponent(_)};T.JWGSGC=c,T.fnqZEe={},T.NDuNUY=!0}let x=s[0],u=n+x,f=T.fnqZEe[u];return f?o=f:(o=T.JWGSGC(o),T.fnqZEe[u]=o),o}var Qn;Object["definePr"+k(579)](X,k(1510)+"le",{value:!0})});var Ye=Se((w_,da)=>{"use strict";var ca=["nodebuffer","arraybuffer","fragments"],xa=typeof Blob<"u";xa&&ca.push("blob");da.exports={BINARY_TYPES:ca,CLOSE_TIMEOUT:3e4,EMPTY_BUFFER:Buffer.alloc(0),GUID:"258EAFA5-E914-47DA-95CA-C5AB0DC85B11",hasBlob:xa,kForOnEventAttribute:Symbol("kIsForOnEventAttribute"),kListener:Symbol("kListener"),kStatusCode:Symbol("status-code"),kWebSocket:Symbol("websocket"),NOOP:()=>{}}});var un=Se((__,or)=>{"use strict";var{EMPTY_BUFFER:mf}=Ye(),gi=Buffer[Symbol.species];function wf(n,e){if(n.length===0)return mf;if(n.length===1)return n[0];let s=Buffer.allocUnsafe(e),o=0;for(let c=0;c<n.length;c++){let x=n[c];s.set(x,o),o+=x.length}return o<e?new gi(s.buffer,s.byteOffset,o):s}function ua(n,e,s,o,c){for(let x=0;x<c;x++)s[o+x]=n[x]^e[x&3]}function fa(n,e){for(let s=0;s<n.length;s++)n[s]^=e[s&3]}function _f(n){return n.length===n.buffer.byteLength?n.buffer:n.buffer.slice(n.byteOffset,n.byteOffset+n.length)}function hi(n){if(hi.readOnly=!0,Buffer.isBuffer(n))return n;let e;return n instanceof ArrayBuffer?e=new gi(n):ArrayBuffer.isView(n)?e=new gi(n.buffer,n.byteOffset,n.byteLength):(e=Buffer.from(n),hi.readOnly=!1),e}or.exports={concat:wf,mask:ua,toArrayBuffer:_f,toBuffer:hi,unmask:fa};if(!process.env.WS_NO_BUFFER_UTIL)try{let n=re("bufferutil");or.exports.mask=function(e,s,o,c,x){x<48?ua(e,s,o,c,x):n.mask(e,s,o,c,x)},or.exports.unmask=function(e,s){e.length<32?fa(e,s):n.unmask(e,s)}}catch{}});var ha=Se((y_,ga)=>{"use strict";var la=Symbol("kDone"),pi=Symbol("kRun"),mi=class{constructor(e){this[la]=()=>{this.pending--,this[pi]()},this.concurrency=e||1/0,this.jobs=[],this.pending=0}add(e){this.jobs.push(e),this[pi]()}[pi](){if(this.pending!==this.concurrency&&this.jobs.length){let e=this.jobs.shift();this.pending++,e(this[la])}}};ga.exports=mi});var qt=Se((b_,_a)=>{"use strict";var fn=re("zlib"),pa=un(),yf=ha(),{kStatusCode:ma}=Ye(),bf=Buffer[Symbol.species],vf=Buffer.from([0,0,255,255]),cr=Symbol("permessage-deflate"),Ze=Symbol("total-length"),Ft=Symbol("callback"),dt=Symbol("buffers"),Ut=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 yf(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[Ft];this._deflate.close(),this._deflate=null,e&&e(new Error("The deflate stream was closed while data was being processed"))}}acceptAsServer(e){let s=this._options,o=e.find(c=>!(s.serverNoContextTakeover===!1&&c.server_no_context_takeover||c.server_max_window_bits&&(s.serverMaxWindowBits===!1||typeof s.serverMaxWindowBits=="number"&&s.serverMaxWindowBits>c.server_max_window_bits)||typeof s.clientMaxWindowBits=="number"&&!c.client_max_window_bits));if(!o)throw new Error("None of the extension offers can be accepted");return s.serverNoContextTakeover&&(o.server_no_context_takeover=!0),s.clientNoContextTakeover&&(o.client_no_context_takeover=!0),typeof s.serverMaxWindowBits=="number"&&(o.server_max_window_bits=s.serverMaxWindowBits),typeof s.clientMaxWindowBits=="number"?o.client_max_window_bits=s.clientMaxWindowBits:(o.client_max_window_bits===!0||s.clientMaxWindowBits===!1)&&delete o.client_max_window_bits,o}acceptAsClient(e){let s=e[0];if(this._options.clientNoContextTakeover===!1&&s.client_no_context_takeover)throw new Error('Unexpected parameter "client_no_context_takeover"');if(!s.client_max_window_bits)typeof this._options.clientMaxWindowBits=="number"&&(s.client_max_window_bits=this._options.clientMaxWindowBits);else if(this._options.clientMaxWindowBits===!1||typeof this._options.clientMaxWindowBits=="number"&&s.client_max_window_bits>this._options.clientMaxWindowBits)throw new Error('Unexpected or invalid parameter "client_max_window_bits"');return s}normalizeParams(e){return e.forEach(s=>{Object.keys(s).forEach(o=>{let c=s[o];if(c.length>1)throw new Error(`Parameter "${o}" must have only a single value`);if(c=c[0],o==="client_max_window_bits"){if(c!==!0){let x=+c;if(!Number.isInteger(x)||x<8||x>15)throw new TypeError(`Invalid value for parameter "${o}": ${c}`);c=x}else if(!this._isServer)throw new TypeError(`Invalid value for parameter "${o}": ${c}`)}else if(o==="server_max_window_bits"){let x=+c;if(!Number.isInteger(x)||x<8||x>15)throw new TypeError(`Invalid value for parameter "${o}": ${c}`);c=x}else if(o==="client_no_context_takeover"||o==="server_no_context_takeover"){if(c!==!0)throw new TypeError(`Invalid value for parameter "${o}": ${c}`)}else throw new Error(`Unknown parameter "${o}"`);s[o]=c})}),e}decompress(e,s,o){ar.add(c=>{this._decompress(e,s,(x,u)=>{c(),o(x,u)})})}compress(e,s,o){ar.add(c=>{this._compress(e,s,(x,u)=>{c(),o(x,u)})})}_decompress(e,s,o){let c=this._isServer?"client":"server";if(!this._inflate){let x=`${c}_max_window_bits`,u=typeof this.params[x]!="number"?fn.Z_DEFAULT_WINDOWBITS:this.params[x];this._inflate=fn.createInflateRaw({...this._options.zlibInflateOptions,windowBits:u}),this._inflate[cr]=this,this._inflate[Ze]=0,this._inflate[dt]=[],this._inflate.on("error",Ef),this._inflate.on("data",wa)}this._inflate[Ft]=o,this._inflate.write(e),s&&this._inflate.write(vf),this._inflate.flush(()=>{let x=this._inflate[Ut];if(x){this._inflate.close(),this._inflate=null,o(x);return}let u=pa.concat(this._inflate[dt],this._inflate[Ze]);this._inflate._readableState.endEmitted?(this._inflate.close(),this._inflate=null):(this._inflate[Ze]=0,this._inflate[dt]=[],s&&this.params[`${c}_no_context_takeover`]&&this._inflate.reset()),o(null,u)})}_compress(e,s,o){let c=this._isServer?"server":"client";if(!this._deflate){let x=`${c}_max_window_bits`,u=typeof this.params[x]!="number"?fn.Z_DEFAULT_WINDOWBITS:this.params[x];this._deflate=fn.createDeflateRaw({...this._options.zlibDeflateOptions,windowBits:u}),this._deflate[Ze]=0,this._deflate[dt]=[],this._deflate.on("data",Sf)}this._deflate[Ft]=o,this._deflate.write(e),this._deflate.flush(fn.Z_SYNC_FLUSH,()=>{if(!this._deflate)return;let x=pa.concat(this._deflate[dt],this._deflate[Ze]);s&&(x=new bf(x.buffer,x.byteOffset,x.length-4)),this._deflate[Ft]=null,this._deflate[Ze]=0,this._deflate[dt]=[],s&&this.params[`${c}_no_context_takeover`]&&this._deflate.reset(),o(null,x)})}};_a.exports=wi;function Sf(n){this[dt].push(n),this[Ze]+=n.length}function wa(n){if(this[Ze]+=n.length,this[cr]._maxPayload<1||this[Ze]<=this[cr]._maxPayload){this[dt].push(n);return}this[Ut]=new RangeError("Max payload size exceeded"),this[Ut].code="WS_ERR_UNSUPPORTED_MESSAGE_LENGTH",this[Ut][ma]=1009,this.removeListener("data",wa),this.reset()}function Ef(n){if(this[cr]._inflate=null,this[Ut]){this[Ft](this[Ut]);return}n[ma]=1007,this[Ft](n)}});var Gt=Se((v_,xr)=>{"use strict";var{isUtf8:ya}=re("buffer"),{hasBlob:If}=Ye(),Af=[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 Cf(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 Pf(n){return If&&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:Pf,isValidStatusCode:Cf,isValidUTF8:_i,tokenChars:Af};if(ya)xr.exports.isValidUTF8=function(n){return n.length<24?_i(n):ya(n)};else if(!process.env.WS_NO_UTF_8_VALIDATE)try{let n=re("utf-8-validate");xr.exports.isValidUTF8=function(e){return e.length<32?_i(e):n(e)}}catch{}});var Ei=Se((S_,Ca)=>{"use strict";var{Writable:Tf}=re("stream"),ba=qt(),{BINARY_TYPES:kf,EMPTY_BUFFER:va,kStatusCode:Df,kWebSocket:Rf}=Ye(),{concat:yi,toArrayBuffer:Nf,unmask:Lf}=un(),{isValidStatusCode:Of,isValidUTF8:Sa}=Gt(),dr=Buffer[Symbol.species],Te=0,Ea=1,Ia=2,Aa=3,bi=4,vi=5,ur=6,Si=class extends Tf{constructor(e={}){super(),this._allowSynchronousEvents=e.allowSynchronousEvents!==void 0?e.allowSynchronousEvents:!0,this._binaryType=e.binaryType||kf[0],this._extensions=e.extensions||{},this._isServer=!!e.isServer,this._maxPayload=e.maxPayload|0,this._skipUTF8Validation=!!e.skipUTF8Validation,this[Rf]=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=Te}_write(e,s,o){if(this._opcode===8&&this._state==Te)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],c=s.length-e;e>=o.length?s.set(this._buffers.shift(),c):(s.set(new Uint8Array(o.buffer,o.byteOffset,e),c),this._buffers[0]=new 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 Te:this.getInfo(e);break;case Ea:this.getPayloadLength16(e);break;case Ia:this.getPayloadLength64(e);break;case Aa: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 c=this.createError(RangeError,"RSV2 and RSV3 must be clear",!0,1002,"WS_ERR_UNEXPECTED_RSV_2_3");e(c);return}let o=(s[0]&64)===64;if(o&&!this._extensions[ba.extensionName]){let c=this.createError(RangeError,"RSV1 must be clear",!0,1002,"WS_ERR_UNEXPECTED_RSV_1");e(c);return}if(this._fin=(s[0]&128)===128,this._opcode=s[0]&15,this._payloadLength=s[1]&127,this._opcode===0){if(o){let c=this.createError(RangeError,"RSV1 must be clear",!0,1002,"WS_ERR_UNEXPECTED_RSV_1");e(c);return}if(!this._fragmented){let c=this.createError(RangeError,"invalid opcode 0",!0,1002,"WS_ERR_INVALID_OPCODE");e(c);return}this._opcode=this._fragmented}else if(this._opcode===1||this._opcode===2){if(this._fragmented){let c=this.createError(RangeError,`invalid opcode ${this._opcode}`,!0,1002,"WS_ERR_INVALID_OPCODE");e(c);return}this._compressed=o}else if(this._opcode>7&&this._opcode<11){if(!this._fin){let c=this.createError(RangeError,"FIN must be set",!0,1002,"WS_ERR_EXPECTED_FIN");e(c);return}if(o){let c=this.createError(RangeError,"RSV1 must be clear",!0,1002,"WS_ERR_UNEXPECTED_RSV_1");e(c);return}if(this._payloadLength>125||this._opcode===8&&this._payloadLength===1){let c=this.createError(RangeError,`invalid payload length ${this._payloadLength}`,!0,1002,"WS_ERR_INVALID_CONTROL_PAYLOAD_LENGTH");e(c);return}}else{let c=this.createError(RangeError,`invalid opcode ${this._opcode}`,!0,1002,"WS_ERR_INVALID_OPCODE");e(c);return}if(!this._fin&&!this._fragmented&&(this._fragmented=this._opcode),this._masked=(s[1]&128)===128,this._isServer){if(!this._masked){let c=this.createError(RangeError,"MASK must be set",!0,1002,"WS_ERR_EXPECTED_MASK");e(c);return}}else if(this._masked){let c=this.createError(RangeError,"MASK must be clear",!0,1002,"WS_ERR_UNEXPECTED_MASK");e(c);return}this._payloadLength===126?this._state=Ea: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 c=this.createError(RangeError,"Unsupported WebSocket frame: payload length > 2^53 - 1",!1,1009,"WS_ERR_UNSUPPORTED_DATA_PAYLOAD_LENGTH");e(c);return}this._payloadLength=o*Math.pow(2,32)+s.readUInt32BE(4),this.haveLength(e)}haveLength(e){if(this._payloadLength&&this._opcode<8&&(this._totalPayloadLength+=this._payloadLength,this._totalPayloadLength>this._maxPayload&&this._maxPayload>0)){let s=this.createError(RangeError,"Max payload size exceeded",!1,1009,"WS_ERR_UNSUPPORTED_MESSAGE_LENGTH");e(s);return}this._masked?this._state=Aa:this._state=bi}getMask(){if(this._bufferedBytes<4){this._loop=!1;return}this._mask=this.consume(4),this._state=bi}getData(e){let s=va;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&&Lf(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[ba.extensionName].decompress(e,this._fin,(c,x)=>{if(c)return s(c);if(x.length){if(this._messageLength+=x.length,this._messageLength>this._maxPayload&&this._maxPayload>0){let u=this.createError(RangeError,"Max payload size exceeded",!1,1009,"WS_ERR_UNSUPPORTED_MESSAGE_LENGTH");s(u);return}this._fragments.push(x)}this.dataMessage(s),this._state===Te&&this.startLoop(s)})}dataMessage(e){if(!this._fin){this._state=Te;return}let s=this._messageLength,o=this._fragments;if(this._totalPayloadLength=0,this._messageLength=0,this._fragmented=0,this._fragments=[],this._opcode===2){let c;this._binaryType==="nodebuffer"?c=yi(o,s):this._binaryType==="arraybuffer"?c=Nf(yi(o,s)):this._binaryType==="blob"?c=new Blob(o):c=o,this._allowSynchronousEvents?(this.emit("message",c,!0),this._state=Te):(this._state=ur,setImmediate(()=>{this.emit("message",c,!0),this._state=Te,this.startLoop(e)}))}else{let c=yi(o,s);if(!this._skipUTF8Validation&&!Sa(c)){let x=this.createError(Error,"invalid UTF-8 sequence",!0,1007,"WS_ERR_INVALID_UTF8");e(x);return}this._state===vi||this._allowSynchronousEvents?(this.emit("message",c,!1),this._state=Te):(this._state=ur,setImmediate(()=>{this.emit("message",c,!1),this._state=Te,this.startLoop(e)}))}}controlMessage(e,s){if(this._opcode===8){if(e.length===0)this._loop=!1,this.emit("conclude",1005,va),this.end();else{let o=e.readUInt16BE(0);if(!Of(o)){let x=this.createError(RangeError,`invalid status code ${o}`,!0,1002,"WS_ERR_INVALID_CLOSE_CODE");s(x);return}let c=new dr(e.buffer,e.byteOffset+2,e.length-2);if(!this._skipUTF8Validation&&!Sa(c)){let x=this.createError(Error,"invalid UTF-8 sequence",!0,1007,"WS_ERR_INVALID_UTF8");s(x);return}this._loop=!1,this.emit("conclude",o,c),this.end()}this._state=Te;return}this._allowSynchronousEvents?(this.emit(this._opcode===9?"ping":"pong",e),this._state=Te):(this._state=ur,setImmediate(()=>{this.emit(this._opcode===9?"ping":"pong",e),this._state=Te,this.startLoop(s)}))}createError(e,s,o,c,x){this._loop=!1,this._errored=!0;let u=new e(o?`Invalid WebSocket frame: ${s}`:s);return Error.captureStackTrace(u,this.createError),u.code=x,u[Df]=c,u}};Ca.exports=Si});var Ci=Se((I_,ka)=>{"use strict";var{Duplex:E_}=re("stream"),{randomFillSync:Mf}=re("crypto"),Pa=qt(),{EMPTY_BUFFER:Bf,kWebSocket:zf,NOOP:Ff}=Ye(),{isBlob:Ht,isValidStatusCode:Uf}=Gt(),{mask:Ta,toBuffer:ht}=un(),ke=Symbol("kByteLength"),qf=Buffer.alloc(4),fr=8*1024,pt,Kt=fr,Ne=0,Gf=1,Hf=2,Ii=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=Ne,this.onerror=Ff,this[zf]=void 0}static frame(e,s){let o,c=!1,x=2,u=!1;s.mask&&(o=s.maskBuffer||qf,s.generateMask?s.generateMask(o):(Kt===fr&&(pt===void 0&&(pt=Buffer.alloc(fr)),Mf(pt,0,fr),Kt=0),o[0]=pt[Kt++],o[1]=pt[Kt++],o[2]=pt[Kt++],o[3]=pt[Kt++]),u=(o[0]|o[1]|o[2]|o[3])===0,x=6);let f;typeof e=="string"?(!s.mask||u)&&s[ke]!==void 0?f=s[ke]:(e=Buffer.from(e),f=e.length):(f=e.length,c=s.mask&&s.readOnly&&!u);let g=f;f>=65536?(x+=8,g=127):f>125&&(x+=2,g=126);let m=Buffer.allocUnsafe(c?f+x:x);return m[0]=s.fin?s.opcode|128:s.opcode,s.rsv1&&(m[0]|=64),m[1]=g,g===126?m.writeUInt16BE(f,2):g===127&&(m[2]=m[3]=0,m.writeUIntBE(f,4,6)),s.mask?(m[1]|=128,m[x-4]=o[0],m[x-3]=o[1],m[x-2]=o[2],m[x-1]=o[3],u?[m,e]:c?(Ta(e,o,m,x,f),[m]):(Ta(e,o,e,0,f),[m,e])):[m,e]}close(e,s,o,c){let x;if(e===void 0)x=Bf;else{if(typeof e!="number"||!Uf(e))throw new TypeError("First argument must be a valid error code number");if(s===void 0||!s.length)x=Buffer.allocUnsafe(2),x.writeUInt16BE(e,0);else{let f=Buffer.byteLength(s);if(f>123)throw new RangeError("The message must not be greater than 123 bytes");x=Buffer.allocUnsafe(2+f),x.writeUInt16BE(e,0),typeof s=="string"?x.write(s,2):x.set(s,2)}}let u={[ke]:x.length,fin:!0,generateMask:this._generateMask,mask:o,maskBuffer:this._maskBuffer,opcode:8,readOnly:!1,rsv1:!1};this._state!==Ne?this.enqueue([this.dispatch,x,!1,u,c]):this.sendFrame(n.frame(x,u),c)}ping(e,s,o){let c,x;if(typeof e=="string"?(c=Buffer.byteLength(e),x=!1):Ht(e)?(c=e.size,x=!1):(e=ht(e),c=e.length,x=ht.readOnly),c>125)throw new RangeError("The data size must not be greater than 125 bytes");let u={[ke]:c,fin:!0,generateMask:this._generateMask,mask:s,maskBuffer:this._maskBuffer,opcode:9,readOnly:x,rsv1:!1};Ht(e)?this._state!==Ne?this.enqueue([this.getBlobData,e,!1,u,o]):this.getBlobData(e,!1,u,o):this._state!==Ne?this.enqueue([this.dispatch,e,!1,u,o]):this.sendFrame(n.frame(e,u),o)}pong(e,s,o){let c,x;if(typeof e=="string"?(c=Buffer.byteLength(e),x=!1):Ht(e)?(c=e.size,x=!1):(e=ht(e),c=e.length,x=ht.readOnly),c>125)throw new RangeError("The data size must not be greater than 125 bytes");let u={[ke]:c,fin:!0,generateMask:this._generateMask,mask:s,maskBuffer:this._maskBuffer,opcode:10,readOnly:x,rsv1:!1};Ht(e)?this._state!==Ne?this.enqueue([this.getBlobData,e,!1,u,o]):this.getBlobData(e,!1,u,o):this._state!==Ne?this.enqueue([this.dispatch,e,!1,u,o]):this.sendFrame(n.frame(e,u),o)}send(e,s,o){let c=this._extensions[Pa.extensionName],x=s.binary?2:1,u=s.compress,f,g;typeof e=="string"?(f=Buffer.byteLength(e),g=!1):Ht(e)?(f=e.size,g=!1):(e=ht(e),f=e.length,g=ht.readOnly),this._firstFragment?(this._firstFragment=!1,u&&c&&c.params[c._isServer?"server_no_context_takeover":"client_no_context_takeover"]&&(u=f>=c._threshold),this._compress=u):(u=!1,x=0),s.fin&&(this._firstFragment=!0);let m={[ke]:f,fin:s.fin,generateMask:this._generateMask,mask:s.mask,maskBuffer:this._maskBuffer,opcode:x,readOnly:g,rsv1:u};Ht(e)?this._state!==Ne?this.enqueue([this.getBlobData,e,this._compress,m,o]):this.getBlobData(e,this._compress,m,o):this._state!==Ne?this.enqueue([this.dispatch,e,this._compress,m,o]):this.dispatch(e,this._compress,m,o)}getBlobData(e,s,o,c){this._bufferedBytes+=o[ke],this._state=Hf,e.arrayBuffer().then(x=>{if(this._socket.destroyed){let f=new Error("The socket was closed while the blob was being read");process.nextTick(Ai,this,f,c);return}this._bufferedBytes-=o[ke];let u=ht(x);s?this.dispatch(u,s,o,c):(this._state=Ne,this.sendFrame(n.frame(u,o),c),this.dequeue())}).catch(x=>{process.nextTick(Kf,this,x,c)})}dispatch(e,s,o,c){if(!s){this.sendFrame(n.frame(e,o),c);return}let x=this._extensions[Pa.extensionName];this._bufferedBytes+=o[ke],this._state=Gf,x.compress(e,o.fin,(u,f)=>{if(this._socket.destroyed){let g=new Error("The socket was closed while data was being compressed");Ai(this,g,c);return}this._bufferedBytes-=o[ke],this._state=Ne,o.readOnly=!1,this.sendFrame(n.frame(f,o),c),this.dequeue()})}dequeue(){for(;this._state===Ne&&this._queue.length;){let e=this._queue.shift();this._bufferedBytes-=e[3][ke],Reflect.apply(e[0],this,e.slice(1))}}enqueue(e){this._bufferedBytes+=e[3][ke],this._queue.push(e)}sendFrame(e,s){e.length===2?(this._socket.cork(),this._socket.write(e[0]),this._socket.write(e[1],s),this._socket.uncork()):this._socket.write(e[0],s)}};ka.exports=Ii;function Ai(n,e,s){typeof s=="function"&&s(e);for(let o=0;o<n._queue.length;o++){let c=n._queue[o],x=c[c.length-1];typeof x=="function"&&x(e)}}function Kf(n,e,s){Ai(n,e,s),n.onerror(e)}});var Fa=Se((A_,za)=>{"use strict";var{kForOnEventAttribute:ln,kListener:Pi}=Ye(),Da=Symbol("kCode"),Ra=Symbol("kData"),Na=Symbol("kError"),La=Symbol("kMessage"),Oa=Symbol("kReason"),Wt=Symbol("kTarget"),Ma=Symbol("kType"),Ba=Symbol("kWasClean"),Xe=class{constructor(e){this[Wt]=null,this[Ma]=e}get target(){return this[Wt]}get type(){return this[Ma]}};Object.defineProperty(Xe.prototype,"target",{enumerable:!0});Object.defineProperty(Xe.prototype,"type",{enumerable:!0});var mt=class extends Xe{constructor(e,s={}){super(e),this[Da]=s.code===void 0?0:s.code,this[Oa]=s.reason===void 0?"":s.reason,this[Ba]=s.wasClean===void 0?!1:s.wasClean}get code(){return this[Da]}get reason(){return this[Oa]}get wasClean(){return this[Ba]}};Object.defineProperty(mt.prototype,"code",{enumerable:!0});Object.defineProperty(mt.prototype,"reason",{enumerable:!0});Object.defineProperty(mt.prototype,"wasClean",{enumerable:!0});var jt=class extends Xe{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(jt.prototype,"error",{enumerable:!0});Object.defineProperty(jt.prototype,"message",{enumerable:!0});var gn=class extends Xe{constructor(e,s={}){super(e),this[Ra]=s.data===void 0?null:s.data}get data(){return this[Ra]}};Object.defineProperty(gn.prototype,"data",{enumerable:!0});var Wf={addEventListener(n,e,s={}){for(let c of this.listeners(n))if(!s[ln]&&c[Pi]===e&&!c[ln])return;let o;if(n==="message")o=function(x,u){let f=new gn("message",{data:u?x:x.toString()});f[Wt]=this,lr(e,this,f)};else if(n==="close")o=function(x,u){let f=new mt("close",{code:x,reason:u.toString(),wasClean:this._closeFrameReceived&&this._closeFrameSent});f[Wt]=this,lr(e,this,f)};else if(n==="error")o=function(x){let u=new jt("error",{error:x,message:x.message});u[Wt]=this,lr(e,this,u)};else if(n==="open")o=function(){let x=new Xe("open");x[Wt]=this,lr(e,this,x)};else return;o[ln]=!!s[ln],o[Pi]=e,s.once?this.once(n,o):this.on(n,o)},removeEventListener(n,e){for(let s of this.listeners(n))if(s[Pi]===e&&!s[ln]){this.removeListener(n,s);break}}};za.exports={CloseEvent:mt,ErrorEvent:jt,Event:Xe,EventTarget:Wf,MessageEvent:gn};function lr(n,e,s){typeof n=="object"&&n.handleEvent?n.handleEvent.call(n,s):n.call(e,s)}});var gr=Se((C_,Ua)=>{"use strict";var{tokenChars:hn}=Gt();function Ke(n,e,s){n[e]===void 0?n[e]=[s]:n[e].push(s)}function jf(n){let e=Object.create(null),s=Object.create(null),o=!1,c=!1,x=!1,u,f,g=-1,m=-1,y=-1,_=0;for(;_<n.length;_++)if(m=n.charCodeAt(_),u===void 0)if(y===-1&&hn[m]===1)g===-1&&(g=_);else if(_!==0&&(m===32||m===9))y===-1&&g!==-1&&(y=_);else if(m===59||m===44){if(g===-1)throw new SyntaxError(`Unexpected character at index ${_}`);y===-1&&(y=_);let C=n.slice(g,y);m===44?(Ke(e,C,s),s=Object.create(null)):u=C,g=y=-1}else throw new SyntaxError(`Unexpected character at index ${_}`);else if(f===void 0)if(y===-1&&hn[m]===1)g===-1&&(g=_);else if(m===32||m===9)y===-1&&g!==-1&&(y=_);else if(m===59||m===44){if(g===-1)throw new SyntaxError(`Unexpected character at index ${_}`);y===-1&&(y=_),Ke(s,n.slice(g,y),!0),m===44&&(Ke(e,u,s),s=Object.create(null),u=void 0),g=y=-1}else if(m===61&&g!==-1&&y===-1)f=n.slice(g,_),g=y=-1;else throw new SyntaxError(`Unexpected character at index ${_}`);else if(c){if(hn[m]!==1)throw new SyntaxError(`Unexpected character at index ${_}`);g===-1?g=_:o||(o=!0),c=!1}else if(x)if(hn[m]===1)g===-1&&(g=_);else if(m===34&&g!==-1)x=!1,y=_;else if(m===92)c=!0;else throw new SyntaxError(`Unexpected character at index ${_}`);else if(m===34&&n.charCodeAt(_-1)===61)x=!0;else if(y===-1&&hn[m]===1)g===-1&&(g=_);else if(g!==-1&&(m===32||m===9))y===-1&&(y=_);else if(m===59||m===44){if(g===-1)throw new SyntaxError(`Unexpected character at index ${_}`);y===-1&&(y=_);let C=n.slice(g,y);o&&(C=C.replace(/\\/g,""),o=!1),Ke(s,f,C),m===44&&(Ke(e,u,s),s=Object.create(null),u=void 0),f=void 0,g=y=-1}else throw new SyntaxError(`Unexpected character at index ${_}`);if(g===-1||x||m===32||m===9)throw new SyntaxError("Unexpected end of input");y===-1&&(y=_);let E=n.slice(g,y);return u===void 0?Ke(e,E,s):(f===void 0?Ke(s,E,!0):o?Ke(s,f,E.replace(/\\/g,"")):Ke(s,f,E),Ke(e,u,s)),e}function $f(n){return Object.keys(n).map(e=>{let s=n[e];return Array.isArray(s)||(s=[s]),s.map(o=>[e].concat(Object.keys(o).map(c=>{let x=o[c];return Array.isArray(x)||(x=[x]),x.map(u=>u===!0?c:`${c}=${u}`).join("; ")})).join("; ")).join(", ")}).join(", ")}Ua.exports={format:$f,parse:jf}});var wr=Se((k_,Xa)=>{"use strict";var Vf=re("events"),Jf=re("https"),Yf=re("http"),Ha=re("net"),Zf=re("tls"),{randomBytes:Xf,createHash:Qf}=re("crypto"),{Duplex:P_,Readable:T_}=re("stream"),{URL:Ti}=re("url"),ut=qt(),el=Ei(),tl=Ci(),{isBlob:nl}=Gt(),{BINARY_TYPES:qa,CLOSE_TIMEOUT:rl,EMPTY_BUFFER:hr,GUID:il,kForOnEventAttribute:ki,kListener:sl,kStatusCode:ol,kWebSocket:de,NOOP:Ka}=Ye(),{EventTarget:{addEventListener:al,removeEventListener:cl}}=Fa(),{format:xl,parse:dl}=gr(),{toBuffer:ul}=un(),Wa=Symbol("kAborted"),Di=[8,13],Qe=["CONNECTING","OPEN","CLOSING","CLOSED"],fl=/^[!#$%&'*+\-.0-9A-Z^_`|a-z~]+$/,V=class n extends Vf{constructor(e,s,o){super(),this._binaryType=qa[0],this._closeCode=1006,this._closeFrameReceived=!1,this._closeFrameSent=!1,this._closeMessage=hr,this._closeTimer=null,this._errorEmitted=!1,this._extensions={},this._paused=!1,this._protocol="",this._readyState=n.CONNECTING,this._receiver=null,this._sender=null,this._socket=null,e!==null?(this._bufferedAmount=0,this._isServer=!1,this._redirects=0,s===void 0?s=[]:Array.isArray(s)||(typeof s=="object"&&s!==null?(o=s,s=[]):s=[s]),ja(this,e,s,o)):(this._autoPong=o.autoPong,this._closeTimeout=o.closeTimeout,this._isServer=!0)}get binaryType(){return this._binaryType}set binaryType(e){qa.includes(e)&&(this._binaryType=e,this._receiver&&(this._receiver._binaryType=e))}get bufferedAmount(){return this._socket?this._socket._writableState.length+this._sender._bufferedBytes:this._bufferedAmount}get extensions(){return Object.keys(this._extensions).join()}get isPaused(){return this._paused}get onclose(){return null}get onerror(){return null}get onopen(){return null}get onmessage(){return null}get protocol(){return this._protocol}get readyState(){return this._readyState}get url(){return this._url}setSocket(e,s,o){let c=new el({allowSynchronousEvents:o.allowSynchronousEvents,binaryType:this.binaryType,extensions:this._extensions,isServer:this._isServer,maxPayload:o.maxPayload,skipUTF8Validation:o.skipUTF8Validation}),x=new tl(e,this._extensions,o.generateMask);this._receiver=c,this._sender=x,this._socket=e,c[de]=this,x[de]=this,e[de]=this,c.on("conclude",hl),c.on("drain",pl),c.on("error",ml),c.on("message",wl),c.on("ping",_l),c.on("pong",yl),x.onerror=bl,e.setTimeout&&e.setTimeout(0),e.setNoDelay&&e.setNoDelay(),s.length>0&&e.unshift(s),e.on("close",Ja),e.on("data",mr),e.on("end",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[ut.extensionName]&&this._extensions[ut.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||hr,s,o)}pong(e,s,o){if(this.readyState===n.CONNECTING)throw new Error("WebSocket is not open: readyState 0 (CONNECTING)");if(typeof e=="function"?(o=e,e=s=void 0):typeof s=="function"&&(o=s,s=void 0),typeof e=="number"&&(e=e.toString()),this.readyState!==n.OPEN){Ri(this,e,o);return}s===void 0&&(s=!this._isServer),this._sender.pong(e||hr,s,o)}resume(){this.readyState===n.CONNECTING||this.readyState===n.CLOSED||(this._paused=!1,this._receiver._writableState.needDrain||this._socket.resume())}send(e,s,o){if(this.readyState===n.CONNECTING)throw new Error("WebSocket is not open: readyState 0 (CONNECTING)");if(typeof s=="function"&&(o=s,s={}),typeof e=="number"&&(e=e.toString()),this.readyState!==n.OPEN){Ri(this,e,o);return}let c={binary:typeof e!="string",mask:!this._isServer,compress:!0,fin:!0,...s};this._extensions[ut.extensionName]||(c.compress=!1),this._sender.send(e||hr,c,o)}terminate(){if(this.readyState!==n.CLOSED){if(this.readyState===n.CONNECTING){Ae(this,this._req,"WebSocket was closed before the connection was established");return}this._socket&&(this._readyState=n.CLOSING,this._socket.destroy())}}};Object.defineProperty(V,"CONNECTING",{enumerable:!0,value:Qe.indexOf("CONNECTING")});Object.defineProperty(V.prototype,"CONNECTING",{enumerable:!0,value:Qe.indexOf("CONNECTING")});Object.defineProperty(V,"OPEN",{enumerable:!0,value:Qe.indexOf("OPEN")});Object.defineProperty(V.prototype,"OPEN",{enumerable:!0,value:Qe.indexOf("OPEN")});Object.defineProperty(V,"CLOSING",{enumerable:!0,value:Qe.indexOf("CLOSING")});Object.defineProperty(V.prototype,"CLOSING",{enumerable:!0,value:Qe.indexOf("CLOSING")});Object.defineProperty(V,"CLOSED",{enumerable:!0,value:Qe.indexOf("CLOSED")});Object.defineProperty(V.prototype,"CLOSED",{enumerable:!0,value:Qe.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[sl];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=al;V.prototype.removeEventListener=cl;Xa.exports=V;function ja(n,e,s,o){let c={allowSynchronousEvents:!0,autoPong:!0,closeTimeout:rl,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=c.autoPong,n._closeTimeout=c.closeTimeout,!Di.includes(c.protocolVersion))throw new RangeError(`Unsupported protocol version: ${c.protocolVersion} (supported versions: ${Di.join(", ")})`);let x;if(e instanceof Ti)x=e;else try{x=new Ti(e)}catch{throw new SyntaxError(`Invalid URL: ${e}`)}x.protocol==="http:"?x.protocol="ws:":x.protocol==="https:"&&(x.protocol="wss:"),n._url=x.href;let u=x.protocol==="wss:",f=x.protocol==="ws+unix:",g;if(x.protocol!=="ws:"&&!u&&!f?g=`The URL's protocol must be one of "ws:", "wss:", "http:", "https:", or "ws+unix:"`:f&&!x.pathname?g="The URL's pathname is empty":x.hash&&(g="The URL contains a fragment identifier"),g){let P=new SyntaxError(g);if(n._redirects===0)throw P;pr(n,P);return}let m=u?443:80,y=Xf(16).toString("base64"),_=u?Jf.request:Yf.request,E=new Set,C;if(c.createConnection=c.createConnection||(u?gl:ll),c.defaultPort=c.defaultPort||m,c.port=x.port||m,c.host=x.hostname.startsWith("[")?x.hostname.slice(1,-1):x.hostname,c.headers={...c.headers,"Sec-WebSocket-Version":c.protocolVersion,"Sec-WebSocket-Key":y,Connection:"Upgrade",Upgrade:"websocket"},c.path=x.pathname+x.search,c.timeout=c.handshakeTimeout,c.perMessageDeflate&&(C=new ut({...c.perMessageDeflate,isServer:!1,maxPayload:c.maxPayload}),c.headers["Sec-WebSocket-Extensions"]=xl({[ut.extensionName]:C.offer()})),s.length){for(let P of s){if(typeof P!="string"||!fl.test(P)||E.has(P))throw new SyntaxError("An invalid or duplicated subprotocol was specified");E.add(P)}c.headers["Sec-WebSocket-Protocol"]=s.join(",")}if(c.origin&&(c.protocolVersion<13?c.headers["Sec-WebSocket-Origin"]=c.origin:c.headers.Origin=c.origin),(x.username||x.password)&&(c.auth=`${x.username}:${x.password}`),f){let P=c.path.split(":");c.socketPath=P[0],c.path=P[1]}let I;if(c.followRedirects){if(n._redirects===0){n._originalIpc=f,n._originalSecure=u,n._originalHostOrSocketPath=f?c.socketPath:x.host;let P=o&&o.headers;if(o={...o,headers:{}},P)for(let[B,j]of Object.entries(P))o.headers[B.toLowerCase()]=j}else if(n.listenerCount("redirect")===0){let P=f?n._originalIpc?c.socketPath===n._originalHostOrSocketPath:!1:n._originalIpc?!1:x.host===n._originalHostOrSocketPath;(!P||n._originalSecure&&!u)&&(delete c.headers.authorization,delete c.headers.cookie,P||delete c.headers.host,c.auth=void 0)}c.auth&&!o.headers.authorization&&(o.headers.authorization="Basic "+Buffer.from(c.auth).toString("base64")),I=n._req=_(c),n._redirects&&n.emit("redirect",n.url,I)}else I=n._req=_(c);c.timeout&&I.on("timeout",()=>{Ae(n,I,"Opening handshake has timed out")}),I.on("error",P=>{I===null||I[Wa]||(I=n._req=null,pr(n,P))}),I.on("response",P=>{let B=P.headers.location,j=P.statusCode;if(B&&c.followRedirects&&j>=300&&j<400){if(++n._redirects>c.maxRedirects){Ae(n,I,"Maximum redirects exceeded");return}I.abort();let H;try{H=new Ti(B,e)}catch{let W=new SyntaxError(`Invalid URL: ${B}`);pr(n,W);return}ja(n,H,s,o)}else n.emit("unexpected-response",I,P)||Ae(n,I,`Unexpected server response: ${P.statusCode}`)}),I.on("upgrade",(P,B,j)=>{if(n.emit("upgrade",P),n.readyState!==V.CONNECTING)return;I=n._req=null;let H=P.headers.upgrade;if(H===void 0||H.toLowerCase()!=="websocket"){Ae(n,B,"Invalid Upgrade header");return}let ce=Qf("sha1").update(y+il).digest("base64");if(P.headers["sec-websocket-accept"]!==ce){Ae(n,B,"Invalid Sec-WebSocket-Accept header");return}let W=P.headers["sec-websocket-protocol"],he;if(W!==void 0?E.size?E.has(W)||(he="Server sent an invalid subprotocol"):he="Server sent a subprotocol but none was requested":E.size&&(he="Server sent no subprotocol"),he){Ae(n,B,he);return}W&&(n._protocol=W);let ye=P.headers["sec-websocket-extensions"];if(ye!==void 0){if(!C){Ae(n,B,"Server sent a Sec-WebSocket-Extensions header but no extension was requested");return}let De;try{De=dl(ye)}catch{Ae(n,B,"Invalid Sec-WebSocket-Extensions header");return}let ue=Object.keys(De);if(ue.length!==1||ue[0]!==ut.extensionName){Ae(n,B,"Server indicated an extension that was not requested");return}try{C.accept(De[ut.extensionName])}catch{Ae(n,B,"Invalid Sec-WebSocket-Extensions header");return}n._extensions[ut.extensionName]=C}n.setSocket(B,j,{allowSynchronousEvents:c.allowSynchronousEvents,generateMask:c.generateMask,maxPayload:c.maxPayload,skipUTF8Validation:c.skipUTF8Validation})}),c.finishRequest?c.finishRequest(I,n):I.end()}function pr(n,e){n._readyState=V.CLOSING,n._errorEmitted=!0,n.emit("error",e),n.emitClose()}function ll(n){return n.path=n.socketPath,Ha.connect(n)}function gl(n){return n.path=void 0,!n.servername&&n.servername!==""&&(n.servername=Ha.isIP(n.host)?"":n.host),Zf.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(pr,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=nl(e)?e.size:ul(e).length;n._socket?n._sender._bufferedBytes+=o:n._bufferedAmount+=o}if(s){let o=new Error(`WebSocket is not open: readyState ${n.readyState} (${Qe[n.readyState]})`);process.nextTick(s,o)}}function hl(n,e){let s=this[de];s._closeFrameReceived=!0,s._closeMessage=e,s._closeCode=n,s._socket[de]!==void 0&&(s._socket.removeListener("data",mr),process.nextTick($a,s._socket),n===1005?s.close():s.close(n,e))}function pl(){let n=this[de];n.isPaused||n._socket.resume()}function ml(n){let e=this[de];e._socket[de]!==void 0&&(e._socket.removeListener("data",mr),process.nextTick($a,e._socket),e.close(n[ol])),e._errorEmitted||(e._errorEmitted=!0,e.emit("error",n))}function Ga(){this[de].emitClose()}function wl(n,e){this[de].emit("message",n,e)}function _l(n){let e=this[de];e._autoPong&&e.pong(n,!this._isServer,Ka),e.emit("ping",n)}function yl(n){this[de].emit("pong",n)}function $a(n){n.resume()}function bl(n){let e=this[de];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 Ja(){let n=this[de];if(this.removeListener("close",Ja),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[de]=void 0,clearTimeout(n._closeTimer),n._receiver._writableState.finished||n._receiver._writableState.errorEmitted?n.emitClose():(n._receiver.on("error",Ga),n._receiver.on("finish",Ga))}function mr(n){this[de]._receiver.write(n)||this.pause()}function Ya(){let n=this[de];n._readyState=V.CLOSING,n._receiver.end(),this.end()}function Za(){let n=this[de];this.removeListener("error",Za),this.on("error",Ka),n&&(n._readyState=V.CLOSING,this.destroy())}});var nc=Se((R_,tc)=>{"use strict";var D_=wr(),{Duplex:vl}=re("stream");function Qa(n){n.emit("close")}function Sl(){!this.destroyed&&this._writableState.finished&&this.destroy()}function ec(n){this.removeListener("error",ec),this.destroy(),this.listenerCount("error")===0&&this.emit("error",n)}function El(n,e){let s=!0,o=new vl({...e,autoDestroy:!1,emitClose:!1,objectMode:!1,writableObjectMode:!1});return n.on("message",function(x,u){let f=!u&&o._readableState.objectMode?x.toString():x;o.push(f)||n.pause()}),n.once("error",function(x){o.destroyed||(s=!1,o.destroy(x))}),n.once("close",function(){o.destroyed||o.push(null)}),o._destroy=function(c,x){if(n.readyState===n.CLOSED){x(c),process.nextTick(Qa,o);return}let u=!1;n.once("error",function(g){u=!0,x(g)}),n.once("close",function(){u||x(c),process.nextTick(Qa,o)}),s&&n.terminate()},o._final=function(c){if(n.readyState===n.CONNECTING){n.once("open",function(){o._final(c)});return}n._socket!==null&&(n._socket._writableState.finished?(c(),o._readableState.endEmitted&&o.destroy()):(n._socket.once("finish",function(){c()}),n.close()))},o._read=function(){n.isPaused&&n.resume()},o._write=function(c,x,u){if(n.readyState===n.CONNECTING){n.once("open",function(){o._write(c,x,u)});return}n.send(c,u)},o.on("end",Sl),o.on("error",ec),o}tc.exports=El});var Ni=Se((N_,rc)=>{"use strict";var{tokenChars:Il}=Gt();function Al(n){let e=new Set,s=-1,o=-1,c=0;for(c;c<n.length;c++){let u=n.charCodeAt(c);if(o===-1&&Il[u]===1)s===-1&&(s=c);else if(c!==0&&(u===32||u===9))o===-1&&s!==-1&&(o=c);else if(u===44){if(s===-1)throw new SyntaxError(`Unexpected character at index ${c}`);o===-1&&(o=c);let f=n.slice(s,o);if(e.has(f))throw new SyntaxError(`The "${f}" subprotocol is duplicated`);e.add(f),s=o=-1}else throw new SyntaxError(`Unexpected character at index ${c}`)}if(s===-1||o!==-1)throw new SyntaxError("Unexpected end of input");let x=n.slice(s,c);if(e.has(x))throw new SyntaxError(`The "${x}" subprotocol is duplicated`);return e.add(x),e}rc.exports={parse:Al}});var dc=Se((O_,xc)=>{"use strict";var Cl=re("events"),_r=re("http"),{Duplex:L_}=re("stream"),{createHash:Pl}=re("crypto"),ic=gr(),wt=qt(),Tl=Ni(),kl=wr(),{CLOSE_TIMEOUT:Dl,GUID:Rl,kWebSocket:Nl}=Ye(),Ll=/^[+/0-9A-Za-z]{22}==$/,sc=0,oc=1,cc=2,Li=class extends Cl{constructor(e,s){if(super(),e={allowSynchronousEvents:!0,autoPong:!0,maxPayload:100*1024*1024,skipUTF8Validation:!1,perMessageDeflate:!1,handleProtocols:null,clientTracking:!0,closeTimeout:Dl,verifyClient:null,noServer:!1,backlog:null,server:null,host:null,path:null,port:null,WebSocket:kl,...e},e.port==null&&!e.server&&!e.noServer||e.port!=null&&(e.server||e.noServer)||e.server&&e.noServer)throw new TypeError('One and only one of the "port", "server", or "noServer" options must be specified');if(e.port!=null?(this._server=_r.createServer((o,c)=>{let x=_r.STATUS_CODES[426];c.writeHead(426,{"Content-Length":x.length,"Content-Type":"text/plain"}),c.end(x)}),this._server.listen(e.port,e.host,e.backlog,s)):e.server&&(this._server=e.server),this._server){let o=this.emit.bind(this,"connection");this._removeListeners=Ol(this._server,{listening:this.emit.bind(this,"listening"),error:this.emit.bind(this,"error"),upgrade:(c,x,u)=>{this.handleUpgrade(c,x,u,o)}})}e.perMessageDeflate===!0&&(e.perMessageDeflate={}),e.clientTracking&&(this.clients=new Set,this._shouldEmitClose=!1),this.options=e,this._state=sc}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===cc){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!==oc)if(this._state=oc,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,c){s.on("error",ac);let x=e.headers["sec-websocket-key"],u=e.headers.upgrade,f=+e.headers["sec-websocket-version"];if(e.method!=="GET"){_t(this,e,s,405,"Invalid HTTP method");return}if(u===void 0||u.toLowerCase()!=="websocket"){_t(this,e,s,400,"Invalid Upgrade header");return}if(x===void 0||!Ll.test(x)){_t(this,e,s,400,"Missing or invalid Sec-WebSocket-Key header");return}if(f!==13&&f!==8){_t(this,e,s,400,"Missing or invalid Sec-WebSocket-Version header",{"Sec-WebSocket-Version":"13, 8"});return}if(!this.shouldHandle(e)){mn(s,400);return}let g=e.headers["sec-websocket-protocol"],m=new Set;if(g!==void 0)try{m=Tl.parse(g)}catch{_t(this,e,s,400,"Invalid Sec-WebSocket-Protocol header");return}let y=e.headers["sec-websocket-extensions"],_={};if(this.options.perMessageDeflate&&y!==void 0){let E=new wt({...this.options.perMessageDeflate,isServer:!0,maxPayload:this.options.maxPayload});try{let C=ic.parse(y);C[wt.extensionName]&&(E.accept(C[wt.extensionName]),_[wt.extensionName]=E)}catch{_t(this,e,s,400,"Invalid or unacceptable Sec-WebSocket-Extensions header");return}}if(this.options.verifyClient){let E={origin:e.headers[`${f===8?"sec-websocket-origin":"origin"}`],secure:!!(e.socket.authorized||e.socket.encrypted),req:e};if(this.options.verifyClient.length===2){this.options.verifyClient(E,(C,I,P,B)=>{if(!C)return mn(s,I||401,P,B);this.completeUpgrade(_,x,m,e,s,o,c)});return}if(!this.options.verifyClient(E))return mn(s,401)}this.completeUpgrade(_,x,m,e,s,o,c)}completeUpgrade(e,s,o,c,x,u,f){if(!x.readable||!x.writable)return x.destroy();if(x[Nl])throw new Error("server.handleUpgrade() was called more than once with the same socket, possibly due to a misconfiguration");if(this._state>sc)return mn(x,503);let m=["HTTP/1.1 101 Switching Protocols","Upgrade: websocket","Connection: Upgrade",`Sec-WebSocket-Accept: ${Pl("sha1").update(s+Rl).digest("base64")}`],y=new this.options.WebSocket(null,void 0,this.options);if(o.size){let _=this.options.handleProtocols?this.options.handleProtocols(o,c):o.values().next().value;_&&(m.push(`Sec-WebSocket-Protocol: ${_}`),y._protocol=_)}if(e[wt.extensionName]){let _=e[wt.extensionName].params,E=ic.format({[wt.extensionName]:[_]});m.push(`Sec-WebSocket-Extensions: ${E}`),y._extensions=e}this.emit("headers",m,c),x.write(m.concat(`\r
12
12
  `).join(`\r
13
- `)),d.removeListener("error",nc),w.setSocket(d,u,{allowSynchronousEvents:this.options.allowSynchronousEvents,maxPayload:this.options.maxPayload,skipUTF8Validation:this.options.skipUTF8Validation}),this.clients&&(this.clients.add(w),w.on("close",()=>{this.clients.delete(w),this._shouldEmitClose&&!this.clients.size&&process.nextTick(hn,this)})),f(w,c)}};ic.exports=Ni;function Rl(n,e){for(let s of Object.keys(e))n.on(s,e[s]);return function(){for(let o of Object.keys(e))n.removeListener(o,e[o])}}function hn(n){n._state=rc,n.emit("close")}function nc(){this.destroy()}function pn(n,e,s,o){s=s||_r.STATUS_CODES[e],o={Connection:"close","Content-Type":"text/html","Content-Length":Buffer.byteLength(s),...o},n.once("finish",n.destroy),n.end(`HTTP/1.1 ${e} ${_r.STATUS_CODES[e]}\r
13
+ `)),x.removeListener("error",ac),y.setSocket(x,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,c)}};xc.exports=Li;function Ol(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=cc,n.emit("close")}function ac(){this.destroy()}function mn(n,e,s,o){s=s||_r.STATUS_CODES[e],o={Connection:"close","Content-Type":"text/html","Content-Length":Buffer.byteLength(s),...o},n.once("finish",n.destroy),n.end(`HTTP/1.1 ${e} ${_r.STATUS_CODES[e]}\r
14
14
  `+Object.keys(o).map(c=>`${c}: ${o[c]}`).join(`\r
15
15
  `)+`\r
16
16
  \r
17
- `+s)}function wt(n,e,s,o,c,d){if(n.listenerCount("wsClientError")){let u=new Error(c);Error.captureStackTrace(u,wt),n.emit("wsClientError",u,s,e)}else pn(s,o,c,d)}});import{spawn as ag}from"node:child_process";import{existsSync as cg,openSync as dg}from"node:fs";import{mkdir as xg}from"node:fs/promises";import{dirname as ug}from"node:path";import{fileURLToPath as fg}from"node:url";function Bi(n=G()){return cg(n.libEntry)?n.libEntry:fg(new URL("../index.ts",import.meta.url))}async function _n(n={}){let e=n.paths??G(),s=n.entryOverride??Bi(e);await xg(ug(e.logFile),{recursive:!0});let o=dg(e.logFile,"a"),d=s.endsWith(".ts")?["--import","tsx/esm",s,"--daemon"]:[s,"--daemon"],u=ag(process.execPath,d,{detached:!0,stdio:["ignore",o,o],env:{...process.env,COZE_BRIDGE_DAEMON:"1"}});if(u.unref(),typeof u.pid!="number")throw new Error("failed to spawn daemon (no pid)");return lg.info("daemon spawned",{pid:u.pid,entry:s}),{pid:u.pid,entry:s}}var lg,Ir=Te(()=>{"use strict";q();ie();lg=N("spawn-daemon")});import{readFile as Sc}from"node:fs/promises";async function Ar(n){try{let[e,s]=await Promise.all([Sc(n.portFile,"utf8"),Sc(n.tokenFile,"utf8")]),o=Number.parseInt(e.trim(),10),c=s.trim();return!Number.isFinite(o)||o<=0||!c?null:{port:o,token:c}}catch(e){if(e.code==="ENOENT")return null;throw e}}function gg(n){if(!n)return null;try{return JSON.parse(n)}catch{return n}}function hg(n){return n instanceof Error?n.message:String(n)}var Ne,Tr=Te(()=>{"use strict";ie();Ne=class{paths;constructor(e){this.paths=e??G()}async probe(e=1e3){let s=await Ar(this.paths);if(!s)return{kind:"not-running"};try{let o=await this.fetch(s,{method:"GET",path:"/status",timeoutMs:e});return o.status===200?{kind:"connected",...s}:{kind:"stale",reason:`unexpected status ${o.status}`}}catch(o){return{kind:"stale",reason:hg(o)}}}async request(e){let s=await Ar(this.paths);if(!s)throw new Error("coze-bridge daemon not running (no port/token files)");return this.fetch(s,e)}async fetch(e,s){let o=s.body!==void 0,c={Authorization:`Bearer ${e.token}`};o&&(c["content-type"]="application/json");let d=new AbortController,u=setTimeout(()=>d.abort(),s.timeoutMs??5e3);try{let f=await fetch(`http://127.0.0.1:${e.port}${s.path}`,{method:s.method,headers:c,body:o?JSON.stringify(s.body):void 0,signal:d.signal}),h=await f.text();return{status:f.status,body:gg(h)}}finally{clearTimeout(u)}}}});var Dc={};Jr(Dc,{DEFAULT_PROBE_TIMEOUT_MS:()=>kc,DEFAULT_WAIT_PID_EXIT_MS:()=>Cc,runUpgradeHelper:()=>Ng});import{copyFile as Pg,rename as qi,unlink as Gi}from"node:fs/promises";async function Ng(n){let e=n.paths??G(),s=n.spawnDaemon??_n,o=n.probeDaemon??Mg,c=n.sleep??Bg,d=n.waitPidExitMs??Cc,u=n.probeTimeoutMs??kc,f=n.killPid??((k,z)=>process.kill(k,z)),{targetVersion:h,oldPid:p}=n;je.info("upgrade-helper start",{targetVersion:h,oldPid:p}),await Og(p,d,c,f);let w=e.libEntry,b=`${w}.bak`,E=`${w}.next`;try{await Pg(w,b)}catch(k){return je.error("backup failed, abort",{err:String(k)}),1}try{await qi(E,w)}catch(k){return je.error("rename .next \u2192 live failed, abort + rollback",{err:String(k)}),await qi(b,w).catch(()=>{}),1}let I,A=!1;try{await s({paths:e}),A=await Lg(()=>o(e),u,c),A||(I="new daemon failed to come up within probeTimeout")}catch(k){I=`spawn new daemon failed: ${String(k)}`,je.warn(I)}return A?(await Tc(e,h,{ok:!0,setLibVersion:!0}),await Gi(b).catch(()=>{}),await Gi(E).catch(()=>{}),je.info("upgrade succeeded",{targetVersion:h}),0):(je.warn("upgrade failed, rolling back",{lastError:I}),await qi(b,w).catch(k=>je.error("rollback rename failed",{err:String(k)})),await s({paths:e}).catch(k=>je.error("spawn old daemon after rollback failed",{err:String(k)})),await Tc(e,h,{ok:!1,lastError:I}),await Gi(E).catch(()=>{}),1)}async function Tc(n,e,s){let o=await ct(n.configFile)??{};s.setLibVersion&&(o.libVersion=e),o.upgradeAttempts=o.upgradeAttempts??{},o.upgradeAttempts[e]={count:(o.upgradeAttempts[e]?.count??0)+1,lastAt:Date.now(),ok:s.ok,...s.lastError?{lastError:s.lastError}:{}},await Ue(o,n.configFile)}async function Og(n,e,s,o){let c=Date.now()+e;for(;Date.now()<c;){if(!Pc(n,o))return;await s(Dg)}je.warn("oldPid did not exit in time, sending SIGTERM",{pid:n});try{o(n,"SIGTERM")}catch{}if(await s(Cg),!!Pc(n,o)){je.warn("SIGTERM ineffective, sending SIGKILL",{pid:n});try{o(n,"SIGKILL")}catch{}await s(kg)}}function Pc(n,e){try{return e(n,0),!0}catch{return!1}}async function Lg(n,e,s){let o=Date.now()+e;for(;Date.now()<o;){if(await n().catch(()=>!1))return!0;await s(Rg)}return!1}async function Mg(n){return(await new Ne(n).probe(1e3).catch(()=>null))?.kind==="connected"}function Bg(n){return new Promise(e=>setTimeout(e,n))}var je,Cc,kc,Cg,kg,Dg,Rg,Rc=Te(()=>{"use strict";Mt();Ir();Tr();q();ie();je=N("upgrade-helper"),Cc=3e4,kc=3e4,Cg=5e3,kg=2e3,Dg=200,Rg=500});import{spawn as zg}from"node:child_process";import{mkdir as Fg,unlink as Ug,writeFile as qg}from"node:fs/promises";import{dirname as Gg,join as Hg}from"node:path";function kr(n){return n.replace(/&/g,"&amp;").replace(/</g,"&lt;").replace(/>/g,"&gt;").replace(/"/g,"&quot;")}function Nc(n,e){return new Promise((s,o)=>{let c=zg(n,e,{stdio:["ignore","pipe","pipe"]}),d="";c.stderr?.on("data",u=>{d+=u.toString("utf8")}),c.on("error",o),c.on("close",u=>{u===0?s():o(new Error(`${n} ${e.join(" ")} exited ${u}: ${d.trim()}`))})})}var Cr,Hi,ji,Oc=Te(()=>{"use strict";q();Cr=N("supervisor.launchd"),Hi="ai.coze.bridge",ji={platform:"darwin",renderConfig(n){return`<?xml version="1.0" encoding="UTF-8"?>
17
+ `+s)}function _t(n,e,s,o,c,x){if(n.listenerCount("wsClientError")){let u=new Error(c);Error.captureStackTrace(u,_t),n.emit("wsClientError",u,s,e)}else mn(s,o,c,x)}});import{spawn as dg}from"node:child_process";import{existsSync as ug,openSync as fg}from"node:fs";import{mkdir as lg}from"node:fs/promises";import{dirname as gg}from"node:path";import{fileURLToPath as hg}from"node:url";function zi(n=q()){return ug(n.libEntry)?n.libEntry:hg(new URL("../index.ts",import.meta.url))}async function yn(n={}){let e=n.paths??q(),s=n.entryOverride??zi(e);await lg(gg(e.logFile),{recursive:!0});let o=fg(e.logFile,"a"),x=s.endsWith(".ts")?["--import","tsx/esm",s,"--daemon"]:[s,"--daemon"],u=dg(process.execPath,x,{detached:!0,stdio:["ignore",o,o],env:{...process.env,COZE_BRIDGE_DAEMON:"1"}});if(u.unref(),typeof u.pid!="number")throw new Error("failed to spawn daemon (no pid)");return pg.info("daemon spawned",{pid:u.pid,entry:s}),{pid:u.pid,entry:s}}var pg,Ir=Pe(()=>{"use strict";U();ae();pg=R("spawn-daemon")});import{readFile as Pc}from"node:fs/promises";async function Ar(n){try{let[e,s]=await Promise.all([Pc(n.portFile,"utf8"),Pc(n.tokenFile,"utf8")]),o=Number.parseInt(e.trim(),10),c=s.trim();return!Number.isFinite(o)||o<=0||!c?null:{port:o,token:c}}catch(e){if(e.code==="ENOENT")return null;throw e}}function mg(n){if(!n)return null;try{return JSON.parse(n)}catch{return n}}function wg(n){return n instanceof Error?n.message:String(n)}var Le,Cr=Pe(()=>{"use strict";ae();Le=class{paths;constructor(e){this.paths=e??q()}async probe(e=1e3){let s=await Ar(this.paths);if(!s)return{kind:"not-running"};try{let o=await this.fetch(s,{method:"GET",path:"/status",timeoutMs:e});return o.status===200?{kind:"connected",...s}:{kind:"stale",reason:`unexpected status ${o.status}`}}catch(o){return{kind:"stale",reason:wg(o)}}}async request(e){let s=await Ar(this.paths);if(!s)throw new Error("coze-bridge daemon not running (no port/token files)");return this.fetch(s,e)}async fetch(e,s){let o=s.body!==void 0,c={Authorization:`Bearer ${e.token}`};o&&(c["content-type"]="application/json");let x=new AbortController,u=setTimeout(()=>x.abort(),s.timeoutMs??5e3);try{let f=await fetch(`http://127.0.0.1:${e.port}${s.path}`,{method:s.method,headers:c,body:o?JSON.stringify(s.body):void 0,signal:x.signal}),g=await f.text();return{status:f.status,body:mg(g)}}finally{clearTimeout(u)}}}});var Mc={};$r(Mc,{DEFAULT_PROBE_TIMEOUT_MS:()=>Oc,DEFAULT_WAIT_PID_EXIT_MS:()=>Lc,runUpgradeHelper:()=>Mg});import{copyFile as Dg,rename as Gi,unlink as Hi}from"node:fs/promises";async function Mg(n){let e=n.paths??q(),s=n.spawnDaemon??yn,o=n.probeDaemon??Fg,c=n.sleep??Ug,x=n.waitPidExitMs??Lc,u=n.probeTimeoutMs??Oc,f=n.killPid??((P,B)=>process.kill(P,B)),{targetVersion:g,oldPid:m}=n;We.info("upgrade-helper start",{targetVersion:g,oldPid:m}),await Bg(m,x,c,f);let y=e.libEntry,_=`${y}.bak`,E=`${y}.next`;try{await Dg(y,_)}catch(P){return We.error("backup failed, abort",{err:String(P)}),1}try{await Gi(E,y)}catch(P){return We.error("rename .next \u2192 live failed, abort + rollback",{err:String(P)}),await Gi(_,y).catch(()=>{}),1}let C,I=!1;try{await s({paths:e}),I=await zg(()=>o(e),u,c),I||(C="new daemon failed to come up within probeTimeout")}catch(P){C=`spawn new daemon failed: ${String(P)}`,We.warn(C)}return I?(await Rc(e,g,{ok:!0,setLibVersion:!0}),await Hi(_).catch(()=>{}),await Hi(E).catch(()=>{}),We.info("upgrade succeeded",{targetVersion:g}),0):(We.warn("upgrade failed, rolling back",{lastError:C}),await Gi(_,y).catch(P=>We.error("rollback rename failed",{err:String(P)})),await s({paths:e}).catch(P=>We.error("spawn old daemon after rollback failed",{err:String(P)})),await Rc(e,g,{ok:!1,lastError:C}),await Hi(E).catch(()=>{}),1)}async function Rc(n,e,s){let o=await xt(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 qe(o,n.configFile)}async function Bg(n,e,s,o){let c=Date.now()+e;for(;Date.now()<c;){if(!Nc(n,o))return;await s(Lg)}We.warn("oldPid did not exit in time, sending SIGTERM",{pid:n});try{o(n,"SIGTERM")}catch{}if(await s(Rg),!!Nc(n,o)){We.warn("SIGTERM ineffective, sending SIGKILL",{pid:n});try{o(n,"SIGKILL")}catch{}await s(Ng)}}function Nc(n,e){try{return e(n,0),!0}catch{return!1}}async function zg(n,e,s){let o=Date.now()+e;for(;Date.now()<o;){if(await n().catch(()=>!1))return!0;await s(Og)}return!1}async function Fg(n){return(await new Le(n).probe(1e3).catch(()=>null))?.kind==="connected"}function Ug(n){return new Promise(e=>setTimeout(e,n))}var We,Lc,Oc,Rg,Ng,Lg,Og,Bc=Pe(()=>{"use strict";zt();Ir();Cr();U();ae();We=R("upgrade-helper"),Lc=3e4,Oc=3e4,Rg=5e3,Ng=2e3,Lg=200,Og=500});import{spawn as qg}from"node:child_process";import{mkdir as Gg,unlink as Hg,writeFile as Kg}from"node:fs/promises";import{dirname as Wg,join as jg}from"node:path";function kr(n){return n.replace(/&/g,"&amp;").replace(/</g,"&lt;").replace(/>/g,"&gt;").replace(/"/g,"&quot;")}function zc(n,e){return new Promise((s,o)=>{let c=qg(n,e,{stdio:["ignore","pipe","pipe"]}),x="";c.stderr?.on("data",u=>{x+=u.toString("utf8")}),c.on("error",o),c.on("close",u=>{u===0?s():o(new Error(`${n} ${e.join(" ")} exited ${u}: ${x.trim()}`))})})}var Tr,Ki,Wi,Fc=Pe(()=>{"use strict";U();Tr=R("supervisor.launchd"),Ki="ai.coze.bridge",Wi={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>${Ki}</string>
23
23
  <key>ProgramArguments</key>
24
24
  <array>
25
25
  <string>${kr(n.nodeBin)}</string>
@@ -38,7 +38,7 @@ var L0=Object.create;var Wr=Object.defineProperty;var M0=Object.getOwnPropertyDe
38
38
  <string>${kr(n.logFile)}</string>
39
39
  </dict>
40
40
  </plist>
41
- `},configPath(n){return Hg(n.homeDir,"Library","LaunchAgents",`${Hi}.plist`)},async install(n){let e=this.configPath(n);await Fg(Gg(e),{recursive:!0}),await qg(e,this.renderConfig(n),"utf8"),Cr.info("plist written",{plistPath:e}),await Nc("launchctl",["load","-w",e]),Cr.info("launchd job loaded",{label:Hi})},async uninstall(n){let e=this.configPath(n);await Nc("launchctl",["unload","-w",e]).catch(s=>Cr.warn("launchctl unload failed (ignored)",{err:String(s)})),await Ug(e).catch(s=>{if(s.code!=="ENOENT")throw s}),Cr.info("launchd job removed",{plistPath:e})}}});import{spawn as jg}from"node:child_process";import{mkdir as Kg,unlink as Wg,writeFile as Jg}from"node:fs/promises";import{dirname as $g,join as Vg}from"node:path";function Nr(n,e){return new Promise((s,o)=>{let c=jg(n,e,{stdio:["ignore","pipe","pipe"]}),d="";c.stderr?.on("data",u=>{d+=u.toString("utf8")}),c.on("error",o),c.on("close",u=>{u===0?s():o(new Error(`${n} ${e.join(" ")} exited ${u}: ${d.trim()}`))})})}var Dr,Rr,Ki,Lc=Te(()=>{"use strict";q();Dr=N("supervisor.systemd"),Rr="coze-bridge.service",Ki={platform:"linux",renderConfig(n){return`[Unit]
41
+ `},configPath(n){return jg(n.homeDir,"Library","LaunchAgents",`${Ki}.plist`)},async install(n){let e=this.configPath(n);await Gg(Wg(e),{recursive:!0}),await Kg(e,this.renderConfig(n),"utf8"),Tr.info("plist written",{plistPath:e}),await zc("launchctl",["load","-w",e]),Tr.info("launchd job loaded",{label:Ki})},async uninstall(n){let e=this.configPath(n);await zc("launchctl",["unload","-w",e]).catch(s=>Tr.warn("launchctl unload failed (ignored)",{err:String(s)})),await Hg(e).catch(s=>{if(s.code!=="ENOENT")throw s}),Tr.info("launchd job removed",{plistPath:e})}}});import{spawn as $g}from"node:child_process";import{mkdir as Vg,unlink as Jg,writeFile as Yg}from"node:fs/promises";import{dirname as Zg,join as Xg}from"node:path";function Nr(n,e){return new Promise((s,o)=>{let c=$g(n,e,{stdio:["ignore","pipe","pipe"]}),x="";c.stderr?.on("data",u=>{x+=u.toString("utf8")}),c.on("error",o),c.on("close",u=>{u===0?s():o(new Error(`${n} ${e.join(" ")} exited ${u}: ${x.trim()}`))})})}var Dr,Rr,ji,Uc=Pe(()=>{"use strict";U();Dr=R("supervisor.systemd"),Rr="coze-bridge.service",ji={platform:"linux",renderConfig(n){return`[Unit]
42
42
  Description=Coze Bridge daemon
43
43
  After=network.target
44
44
 
@@ -52,7 +52,7 @@ StandardError=append:${n.logFile}
52
52
 
53
53
  [Install]
54
54
  WantedBy=default.target
55
- `},configPath(n){return Vg(n.homeDir,".config","systemd","user",Rr)},async install(n){let e=this.configPath(n);await Kg($g(e),{recursive:!0}),await Jg(e,this.renderConfig(n),"utf8"),Dr.info("systemd unit written",{unitPath:e}),await Nr("systemctl",["--user","daemon-reload"]),await Nr("systemctl",["--user","enable","--now",Rr]),Dr.info("systemd unit enabled",{unitName:Rr})},async uninstall(n){let e=this.configPath(n);await Nr("systemctl",["--user","disable","--now",Rr]).catch(s=>Dr.warn("systemctl disable failed (ignored)",{err:String(s)})),await Wg(e).catch(s=>{if(s.code!=="ENOENT")throw s}),await Nr("systemctl",["--user","daemon-reload"]).catch(()=>{}),Dr.info("systemd unit removed",{unitPath:e})}}});import{spawn as Yg}from"node:child_process";import{join as Xg}from"node:path";function Mc(n,e){return new Promise((s,o)=>{let c=Yg(n,e,{stdio:["ignore","pipe","pipe"],shell:!1}),d="";c.stderr?.on("data",u=>{d+=u.toString("utf8")}),c.on("error",o),c.on("close",u=>{u===0?s():o(new Error(`${n} ${e.join(" ")} exited ${u}: ${d.trim()}`))})})}var Wi,Or,Ji,Bc=Te(()=>{"use strict";q();Wi=N("supervisor.taskscheduler"),Or="CozeBridge",Ji={platform:"win32",renderConfig(n){return`<?xml version="1.0" encoding="UTF-16"?>
55
+ `},configPath(n){return Xg(n.homeDir,".config","systemd","user",Rr)},async install(n){let e=this.configPath(n);await Vg(Zg(e),{recursive:!0}),await Yg(e,this.renderConfig(n),"utf8"),Dr.info("systemd unit written",{unitPath:e}),await Nr("systemctl",["--user","daemon-reload"]),await Nr("systemctl",["--user","enable","--now",Rr]),Dr.info("systemd unit enabled",{unitName:Rr})},async uninstall(n){let e=this.configPath(n);await Nr("systemctl",["--user","disable","--now",Rr]).catch(s=>Dr.warn("systemctl disable failed (ignored)",{err:String(s)})),await Jg(e).catch(s=>{if(s.code!=="ENOENT")throw s}),await Nr("systemctl",["--user","daemon-reload"]).catch(()=>{}),Dr.info("systemd unit removed",{unitPath:e})}}});import{spawn as Qg}from"node:child_process";import{join as eh}from"node:path";function qc(n,e){return new Promise((s,o)=>{let c=Qg(n,e,{stdio:["ignore","pipe","pipe"],shell:!1}),x="";c.stderr?.on("data",u=>{x+=u.toString("utf8")}),c.on("error",o),c.on("close",u=>{u===0?s():o(new Error(`${n} ${e.join(" ")} exited ${u}: ${x.trim()}`))})})}var $i,Lr,Vi,Gc=Pe(()=>{"use strict";U();$i=R("supervisor.taskscheduler"),Lr="CozeBridge",Vi={platform:"win32",renderConfig(n){return`<?xml version="1.0" encoding="UTF-16"?>
56
56
  <Task version="1.2" xmlns="http://schemas.microsoft.com/windows/2004/02/mit/task">
57
57
  <RegistrationInfo>
58
58
  <Description>Coze Bridge daemon</Description>
@@ -76,9 +76,9 @@ WantedBy=default.target
76
76
  </Exec>
77
77
  </Actions>
78
78
  </Task>
79
- `},configPath(n){return Xg(n.homeDir,".coze","bridge","task.xml")},async install(n){let e=`"${n.nodeBin}" "${n.entry}" --daemon`;await Mc("schtasks",["/Create","/SC","ONLOGON","/TN",Or,"/TR",e,"/RU",n.userName,"/F"]),Wi.info("task scheduler entry created",{task:Or})},async uninstall(n){await Mc("schtasks",["/Delete","/TN",Or,"/F"]).catch(e=>Wi.warn("schtasks /Delete failed (ignored)",{err:String(e)})),Wi.info("task scheduler entry removed",{task:Or})}}});var $i={};Jr($i,{buildContext:()=>th,getSupervisor:()=>eh,launchdSupervisor:()=>ji,systemdSupervisor:()=>Ki,taskSchedulerSupervisor:()=>Ji});import{homedir as Qg,userInfo as Zg}from"node:os";function eh(n=process.platform){switch(n){case"darwin":return ji;case"linux":return Ki;case"win32":return Ji;default:throw new Error(`unsupported platform for OS supervisor: ${n}`)}}function th(){let n=G();return{nodeBin:process.execPath,entry:Bi(n),logFile:n.logFile,homeDir:Qg(),userName:Zg().username}}var Vi=Te(()=>{"use strict";ie();Ir();Oc();Lc();Bc()});q();q();import{execFile as H0}from"node:child_process";import{promisify as j0}from"node:util";var bs=j0(H0),Vt=N("agents.acp-installer"),K0={"claude-code":{npmPackage:"@agentclientprotocol/claude-agent-acp",binary:"claude-agent-acp"},codex:{npmPackage:"@zed-industries/codex-acp",binary:"codex-acp"}},W0=5e4,J0=5e3,$0=5*6e4,V0=new Set(["ETIMEDOUT","ECONNRESET","ECONNREFUSED","ENETUNREACH","EAI_AGAIN","ERR_SOCKET_TIMEOUT","ENOTFOUND"]),Y0=/\b(5\d\d|408|429)\b\s+(Bad Gateway|Service Unavailable|Gateway Timeout|Internal Server Error|Too Many Requests|Request Timeout)/i,X0=/fetch failed|request timed out|socket hang up|network timeout/i;function Q0(n){let e=n?.code;if(e&&V0.has(e))return!0;let s=n instanceof Error?`${n.message}
80
- ${n.stack??""}`:String(n);return Y0.test(s)||X0.test(s)}function Z0(n){if(n==null||typeof n!="object")return String(n);let e=n,s=[];e.message&&s.push(e.message),e.code!==void 0&&e.code!==null&&s.push(`code=${e.code}`),e.signal&&s.push(`signal=${e.signal}`);let o=e.stderr?.toString().trim();o&&s.push(`stderr=${o.slice(0,2e3)}`);let c=e.stdout?.toString().trim();return c&&s.push(`stdout=${c.slice(0,2e3)}`),s.length>0?s.join(" | "):String(n)}var In=new Map,En=new Map,An=new Map;async function ys(n){let e=process.platform==="win32"?"where":"which";try{let{stdout:s}=await bs(e,[n],{timeout:J0});return s.split(`
81
- `)[0]?.trim()||void 0}catch{return}}async function ed(n,e){Vt.info("npm install -g start",{npmPackage:n}),await bs("npm",["install","-g",`${n}@latest`],{timeout:W0,maxBuffer:10*1024*1024,...e?{signal:e}:{}}),Vt.info("npm install -g done",{npmPackage:n})}async function It(n,e){let s=K0[n];if(!s)return;let o=In.get(n);if(o)return o;let c=En.get(n);if(c&&Date.now()-c<$0)return;let d=An.get(n);if(d)return d;let u=(async()=>{let f=await ys(s.binary);if(f)return In.set(n,f),Vt.info("acp wrapper found on PATH",{binary:s.binary,path:f}),f;try{await ed(s.npmPackage,e)}catch(p){let w=Q0(p);Vt.warn("acp wrapper install failed (will fallback to npx)",{npmPackage:s.npmPackage,transient:w,err:Z0(p)}),w||En.set(n,Date.now());return}let h=await ys(s.binary);if(!h){Vt.warn("acp wrapper installed but binary not found on PATH",{binary:s.binary}),En.set(n,Date.now());return}return In.set(n,h),En.delete(n),h})().finally(()=>{An.delete(n)});return An.set(n,u),u}function At(n){return In.get(n)}function vs(n){return An.get(n)}var Ss=N("acp-installer-warmup"),td=["claude-code","codex"];async function Es(n={}){let e=n.ensure??It,o=(await Promise.allSettled(td.map(async c=>{let d=await e(c);Ss.info("acp wrapper warmup ok",{framework:c,installed:!!d,path:d??""})}))).filter(c=>c.status==="rejected");o.length>0&&Ss.warn("acp wrapper warmup partial failure (acp-installer negative cache 5min \u5185\u4E0D\u91CD\u8BD5)",{failedCount:o.length,reasons:o.map(c=>String(c.reason))})}it();q();import{readdir as gd}from"node:fs/promises";import{mkdir as Ds,writeFile as Rs}from"node:fs/promises";import{join as Vr}from"node:path";var ud={"claude-code":"CLAUDE.md",codex:"AGENTS.md",openclaw:"SOUL.md"};async function Pt(n,e,s,o){await Ds(n,{recursive:!0});let c=ud[e],d=Vr(n,c),u=fd(e,s,o);return await Rs(d,u,"utf8"),d}async function Ns(n){let e=Vr(n,".claude");await Ds(e,{recursive:!0});let s=Vr(e,"settings.local.json"),o=JSON.stringify({permissions:{defaultMode:"bypassPermissions"}},null,2);return await Rs(s,o,"utf8"),s}function fd(n,e,s){let o=`# Coze Agent: ${e}
79
+ `},configPath(n){return eh(n.homeDir,".coze","bridge","task.xml")},async install(n){let e=`"${n.nodeBin}" "${n.entry}" --daemon`;await qc("schtasks",["/Create","/SC","ONLOGON","/TN",Lr,"/TR",e,"/RU",n.userName,"/F"]),$i.info("task scheduler entry created",{task:Lr})},async uninstall(n){await qc("schtasks",["/Delete","/TN",Lr,"/F"]).catch(e=>$i.warn("schtasks /Delete failed (ignored)",{err:String(e)})),$i.info("task scheduler entry removed",{task:Lr})}}});var Ji={};$r(Ji,{buildContext:()=>ih,getSupervisor:()=>rh,launchdSupervisor:()=>Wi,systemdSupervisor:()=>ji,taskSchedulerSupervisor:()=>Vi});import{homedir as th,userInfo as nh}from"node:os";function rh(n=process.platform){switch(n){case"darwin":return Wi;case"linux":return ji;case"win32":return Vi;default:throw new Error(`unsupported platform for OS supervisor: ${n}`)}}function ih(){let n=q();return{nodeBin:process.execPath,entry:zi(n),logFile:n.logFile,homeDir:th(),userName:nh().username}}var Yi=Pe(()=>{"use strict";ae();Ir();Fc();Uc();Gc()});U();U();import{execFile as V0}from"node:child_process";import{promisify as J0}from"node:util";var bs=J0(V0),Yt=R("agents.acp-installer"),Y0={"claude-code":{npmPackage:"@agentclientprotocol/claude-agent-acp",binary:"claude-agent-acp"},codex:{npmPackage:"@zed-industries/codex-acp",binary:"codex-acp"}},Z0=5e4,X0=5e3,Q0=5*6e4,ex=new Set(["ETIMEDOUT","ECONNRESET","ECONNREFUSED","ENETUNREACH","EAI_AGAIN","ERR_SOCKET_TIMEOUT","ENOTFOUND"]),tx=/\b(5\d\d|408|429)\b\s+(Bad Gateway|Service Unavailable|Gateway Timeout|Internal Server Error|Too Many Requests|Request Timeout)/i,nx=/fetch failed|request timed out|socket hang up|network timeout/i;function rx(n){let e=n?.code;if(e&&ex.has(e))return!0;let s=n instanceof Error?`${n.message}
80
+ ${n.stack??""}`:String(n);return tx.test(s)||nx.test(s)}function ix(n){if(n==null||typeof n!="object")return String(n);let e=n,s=[];e.message&&s.push(e.message),e.code!==void 0&&e.code!==null&&s.push(`code=${e.code}`),e.signal&&s.push(`signal=${e.signal}`);let o=e.stderr?.toString().trim();o&&s.push(`stderr=${o.slice(0,2e3)}`);let c=e.stdout?.toString().trim();return c&&s.push(`stdout=${c.slice(0,2e3)}`),s.length>0?s.join(" | "):String(n)}var In=new Map,En=new Map,An=new Map;async function ys(n){let e=process.platform==="win32"?"where":"which";try{let{stdout:s}=await bs(e,[n],{timeout:X0});return s.split(`
81
+ `)[0]?.trim()||void 0}catch{return}}async function sx(n,e){Yt.info("npm install -g start",{npmPackage:n}),await bs("npm",["install","-g",`${n}@latest`],{timeout:Z0,maxBuffer:10*1024*1024,...e?{signal:e}:{}}),Yt.info("npm install -g done",{npmPackage:n})}async function Ct(n,e){let s=Y0[n];if(!s)return;let o=In.get(n);if(o)return o;let c=En.get(n);if(c&&Date.now()-c<Q0)return;let x=An.get(n);if(x)return x;let u=(async()=>{let f=await ys(s.binary);if(f)return In.set(n,f),Yt.info("acp wrapper found on PATH",{binary:s.binary,path:f}),f;try{await sx(s.npmPackage,e)}catch(m){let y=rx(m);Yt.warn("acp wrapper install failed (will fallback to npx)",{npmPackage:s.npmPackage,transient:y,err:ix(m)}),y||En.set(n,Date.now());return}let g=await ys(s.binary);if(!g){Yt.warn("acp wrapper installed but binary not found on PATH",{binary:s.binary}),En.set(n,Date.now());return}return In.set(n,g),En.delete(n),g})().finally(()=>{An.delete(n)});return An.set(n,u),u}function Pt(n){return In.get(n)}function vs(n){return An.get(n)}var Ss=R("acp-installer-warmup"),ox=["claude-code","codex"];async function Es(n={}){let e=n.ensure??Ct,o=(await Promise.allSettled(ox.map(async c=>{let x=await e(c);Ss.info("acp wrapper warmup ok",{framework:c,installed:!!x,path:x??""})}))).filter(c=>c.status==="rejected");o.length>0&&Ss.warn("acp wrapper warmup partial failure (acp-installer negative cache 5min \u5185\u4E0D\u91CD\u8BD5)",{failedCount:o.length,reasons:o.map(c=>String(c.reason))})}st();U();import{readdir as yx}from"node:fs/promises";import{mkdir as Ds,writeFile as Rs}from"node:fs/promises";import{join as Jr}from"node:path";var px={"claude-code":"CLAUDE.md",codex:"AGENTS.md",openclaw:"SOUL.md"};async function kt(n,e,s,o){await Ds(n,{recursive:!0});let c=px[e],x=Jr(n,c),u=mx(e,s,o);return await Rs(x,u,"utf8"),x}async function Ns(n){let e=Jr(n,".claude");await Ds(e,{recursive:!0});let s=Jr(e,"settings.local.json"),o=JSON.stringify({permissions:{defaultMode:"bypassPermissions"}},null,2);return await Rs(s,o,"utf8"),s}function mx(n,e,s){let o=`# Coze Agent: ${e}
82
82
 
83
83
  > framework: \`${n}\`
84
84
 
@@ -88,7 +88,7 @@ ${n.stack??""}`:String(n);return Y0.test(s)||X0.test(s)}function Z0(n){if(n==nul
88
88
  `;return`${o}---
89
89
 
90
90
  ${c}
91
- ${ld}`}var ld=`## \u53D1\u9001\u6587\u4EF6 / \u56FE\u7247\u7ED9\u7528\u6237
91
+ ${_x}`}var _x=`## \u53D1\u9001\u6587\u4EF6 / \u56FE\u7247\u7ED9\u7528\u6237
92
92
 
93
93
  \u6BCF\u6761\u7528\u6237\u6D88\u606F\u5F00\u5934\u4F1A\u6709\u4E91\u7AEF\u6CE8\u5165\u7684 \`<coze-context>\` \u5757, \u5F62\u5982:
94
94
 
@@ -112,26 +112,28 @@ ${ld}`}var ld=`## \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=N("agent-detail-sync"),hd=6e4,pd=5*6e4,Rn=class{constructor(e){this.opts=e}opts;retryQueue=new Map;async syncAll(e){let s=this.opts.paths.agentsRoot,o;try{o=await gd(s)}catch(c){Ee.info("agents dir not found, skip detail sync",{root:s,err:String(c)});return}Ee.info("starting detail sync",{reason:e,count:o.length}),await Promise.allSettled(o.map(async c=>{let d=await he(c,this.opts.paths).catch(()=>null);if(d){if(d.disconnectedAt){Ee.debug("detail sync: skip disconnected agent",{agentId:c});return}try{await this.syncOne(c,d)}catch(u){Ee.warn("detail sync failed for agent, skipping",{agentId:c,err:String(u)})}}})),Ee.info("detail sync done",{reason:e})}async retryPending(){if(this.retryQueue.size===0)return;let e=Date.now(),s=[];for(let[o,c]of this.retryQueue)e>=c.dueAt&&s.push(o);if(s.length!==0){Ee.info("retrying pending detail syncs",{count:s.length});for(let o of s)try{await this.syncOne(o)}catch(c){Ee.debug("detail sync retry still failing, will try again",{agentId:o,err:String(c)})}}}async syncOne(e,s){let o=s??await he(e,this.opts.paths);if(!o){Ee.info("detail sync: agent config missing, skip",{agentId:e});return}let c;try{c=await this.opts.sendDetail({_meta:{cozeAgentId:e}}),this.retryQueue.delete(e)}catch(f){Ee.warn("detail RPC failed, using local data",{agentId:e,err:String(f)});let h=this.retryQueue.get(e),p=h?Math.min(h.currentDelay*2,pd):hd;this.retryQueue.set(e,{dueAt:Date.now()+p,currentDelay:p});return}if(c.agentId&&c.agentId!==e){Ee.warn("detail response agentId mismatch, ignoring",{agentId:e,responseAgentId:c.agentId});return}let d=!1,u=!1;if(c.agentName&&c.agentName!==o.agentName&&(o.agentName=c.agentName,d=!0),c.description!==void 0&&c.description!==o.description&&(o.description=c.description,d=!0),c.cozeIdentity&&c.cozeIdentity!==o.cozeIdentity&&(o.cozeIdentity=c.cozeIdentity,d=!0,u=!0),c.deployType&&Ee.info("detail.deployType",{agentId:e,deployType:c.deployType}),!d){Ee.debug("detail sync: no diff",{agentId:e});return}await Se(o,this.opts.paths),Ee.info("detail sync: config updated",{agentId:e,identityChanged:u,agentName:o.agentName}),u&&(await Pt(o.workspace,o.framework,e,o.cozeIdentity),this.opts.handlers.reloadAgentSessionsPublic(e,"detail-sync"))}};it();import{spawn as Qs}from"node:child_process";import{lstat as ei,mkdir as _d,readFile as Zs,readdir as yd,rm as bd,stat as vd,writeFile as Ys}from"node:fs/promises";import{join as Me,normalize as Sd,relative as eo,resolve as Ed,sep as to}from"node:path";var Oe={PAIR:"_agent/pair",CREATE:"_agent/create",HEALTH:"_agent/health",LIST_SKILLS:"_agent/listSkills",ADD_SKILLS:"_agent/addSkills",REMOVE_SKILLS:"_agent/removeSkills",GET_FILE_TREE:"_agent/getFileTree",GET_FILE_CONTENT:"_agent/getFileContent",DETAIL:"_agent/detail",UPDATE:"_agent/update",DISCONNECT:"_agent/disconnect",SWITCH_MODEL:"_agent/switchModel",GEN_MODEL_TOKEN:"_agent/genModelToken",RESET:"_agent/reset",REPAIR:"_agent/repair",DELETE:"_agent/delete"};function Yt(n){return n?.cozeDeployType==="cloud"?"cloud":"local"}function Os(n){let e=n?.cozeAccountId?.trim();if(!(!e||e==="0"))return e}function Ls(n){let{_meta:e,...s}=n;return{stripped:s,meta:e}}function Ct(n){if(!n?.cozeAgentId)throw new Error("missing _meta.cozeAgentId");return n.cozeAgentId}var S=class extends Error{code;retriable;cause;constructor(e,s,o){super(s),this.name="BridgeError",this.code=e,this.retriable=o?.retriable??!1,o?.cause!==void 0&&(this.cause=o.cause)}};q();ie();function $e(n,e){if(Yt(n)!=="cloud")throw new S("OPERATION_NOT_ALLOWED_FOR_LOCAL",`${e} is not allowed for local agent`)}function Nn(n){return n.startsWith("http://")||n.startsWith("https://")}function On(n){return n.endsWith("/")?n.slice(0,-1):n}q();var Ln="1008033",Ms="1289";var Bs="pbbp2",zs="https://www.coze.cn",Fs="/api/coze_claw/resource/get_frontier_key",md="https://www.coze.cn",wd="wss://frontier.coze.cn";function Mn(n){return n??process.env.COZE_BRIDGE_HANDSHAKE_URL??md}function Us(n){return n??process.env.COZE_BRIDGE_FRONTIER_URL??wd}function kt(n){let e={},s=n?.ttEnv??process.env.COZE_BRIDGE_TT_ENV,o=n?.usePpe??process.env.COZE_BRIDGE_USE_PPE;return s&&(e["x-tt-env"]=s),o&&(e["x-use-ppe"]=o),e}function Xt(n){return n?n.startsWith("boe_")?{ttEnv:n}:{ttEnv:n,usePpe:"1"}:{}}var qs=N("handshake");async function Yr(n){let e=Mn(n.endpoint),s=n.timeoutMs??1e4,o=`${On(e)}${Fs}?aid=${encodeURIComponent(Ln)}`,c={Authorization:`Bearer ${n.privatecode}`,Accept:"application/json",...kt(n.ppeOverride)},d=new AbortController,u=setTimeout(()=>d.abort(),s);qs.info("frontier key handshake",{base:e});try{let f=await fetch(o,{method:"GET",headers:c,signal:d.signal}),h=f.headers.get("x-tt-logid")??"",p=f.headers.get("x-tt-trace-id")??"";if(!f.ok){let A=await f.text().catch(()=>"");throw new S("UPSTREAM_HANDSHAKE_FAILED",`handshake HTTP ${f.status} logid=${h}: ${A.slice(0,200)}`)}let w=await f.json();if(w.code!==void 0&&w.code!==0)throw new S("UPSTREAM_HANDSHAKE_FAILED",`handshake code=${w.code} msg=${w.msg??"-"} logid=${h}`);let b=w.data??{},E=typeof b.access_key=="string"&&b.access_key||typeof b.accessKey=="string"&&b.accessKey||void 0,I=typeof b.device_id=="string"&&b.device_id||typeof b.deviceId=="string"&&b.deviceId||void 0;if(!E||!I){let A=JSON.stringify(w).slice(0,500);throw new S("UPSTREAM_HANDSHAKE_FAILED",`handshake response missing access_key/device_id (also tried camelCase) logid=${h}: ${A}`)}return qs.info("handshake ok",{remoteDeviceId:I,logid:h,traceId:p}),{accessKey:E,deviceId:I}}catch(f){throw f instanceof S?f:f.name==="AbortError"?new S("UPSTREAM_HANDSHAKE_FAILED",`handshake timeout (${s}ms)`):new S("UPSTREAM_HANDSHAKE_FAILED",String(f),{cause:f})}finally{clearTimeout(u)}}var Xr=process.env.COZE_BRIDGE_LLM_GATEWAY_URL?.trim()||"https://llm-gateway.coze.cn",Le="auto";function Gs(n){return{model:n.model??Le,...n.modelToken?{modelToken:n.modelToken}:{}}}function Hs(n){return!n||n===Le}function js(n){let e={};return n.modelToken?(e.ANTHROPIC_BASE_URL=Xr,e.ANTHROPIC_AUTH_TOKEN=n.modelToken,e.ANTHROPIC_MODEL=n.model||Le,n.modelInfo?.contextWindow&&(e.CLAUDE_CODE_MAX_CONTEXT_TOKENS=String(n.modelInfo.contextWindow))):Hs(n.model)||(e.ANTHROPIC_MODEL=n.model),e}function Ks(n){let e=[];return n.modelToken?e.push("-c",`model="${n.model||Le}"`):Hs(n.model)||e.push("-c",`model="${n.model}"`),n.modelToken&&(e.push("-c",'model_providers.coze.name="coze"'),e.push("-c",`model_providers.coze.base_url="${Xr}/v1"`),e.push("-c",'model_providers.coze.env_key="OPENAI_API_KEY"'),e.push("-c",'model_providers.coze.wire_api="responses"'),e.push("-c","model_providers.coze.requires_openai_auth=false"),e.push("-c","model_providers.coze.supports_websockets=false"),e.push("-c",'model_provider="coze"'),n.modelInfo?.contextWindow&&e.push("-c",`model_context_window=${n.modelInfo.contextWindow}`)),e}function Ws(n){return n.modelToken?{OPENAI_API_KEY:n.modelToken}:{}}function Qr(n){let{ttEnv:e,usePpe:s}=Xt(n),o={};return e&&(o["x-tt-env"]=e),s&&(o["x-use-ppe"]=s),o}function Js(n,e){if(!n.modelToken)return{};let s=Qr(e);return Object.keys(s).length===0?{}:{ANTHROPIC_CUSTOM_HEADERS:Object.entries(s).map(([c,d])=>`${c}:${d}`).join(`
116
- `)}}function Zr(n){return`coze-session-${n.replace(/[^A-Za-z0-9_-]+/g,"-")}`}function $s(n,e){if(!n.modelToken)return null;let s=n.model||Le,o=Qr(e),c=["text"];n.modelInfo?.capabilities?.image===!0&&c.push("image");let d={baseUrl:`${Xr}/v1`,api:"openai-completions",apiKey:n.modelToken,models:[{id:s,name:s,reasoning:!1,input:c,cost:{input:0,output:0,cacheRead:0,cacheWrite:0},contextWindow:n.modelInfo?.contextWindow??128e3,maxTokens:8192,api:"openai-completions"}]};return Object.keys(o).length>0&&(d.headers=o),d}function Vs(n,e){if(!n.modelToken)return[];let s=Qr(e),o=[];for(let[c,d]of Object.entries(s))o.push("-c",`model_providers.coze.http_headers.${c}="${d}"`);return o}var ce=N("agent-handlers"),Xs=5*1024*1024,Id=1,Ad=6,Td=new Set(["node_modules",".git",".coze","dist","build",".next"]),Bn=class{constructor(e){this.opts=e}opts;async listSkills(e){$e(e._meta,"_agent/listSkills");let s=Ct(e._meta),o=await this.loadAgentCfg(s),c=o?.workspace??Je(s).workspace,d=o?.skills??[],u=[];for(let f of d){let h=Me(c,f.relPath,"SKILL.md");await vd(h).then(w=>w.isFile()).catch(()=>!1)&&u.push(Rd(f))}return{skills:u}}async addSkills(e){$e(e._meta,"_agent/addSkills");let s=Ct(e._meta),o=await this.requireAgentCfg(s),c=e.skills??[],d=[...o.skills??[]],u=new Map(d.map((h,p)=>[h.skillId,p])),f=[];for(let h of c){let p=await ti({agentId:s,workspace:o.workspace,framework:o.framework,skill:h});ni(d,u,p),f.push(h)}return await kn(s,d),this.reloadAgentSessions(s,"skills-added"),{installedSkills:f}}async removeSkills(e){$e(e._meta,"_agent/removeSkills");let s=Ct(e._meta),o=await this.requireAgentCfg(s),c=new Set(e.skillIds??[]),d=o.skills??[],u=[];for(let f of d){if(!c.has(f.skillId)){u.push(f);continue}let h=Me(o.workspace,f.relPath);await bd(h,{recursive:!0,force:!0}),ce.info("skill removed",{agentId:s,skillId:f.skillId,relPath:f.relPath})}return await kn(s,u),this.reloadAgentSessions(s,"skills-removed"),{ok:!0}}reloadAgentSessionsPublic(e,s){this.reloadAgentSessions(e,s)}reloadAgentSessions(e,s){let o=this.opts.agents.get(e);if(o)for(let[c,d]of o.sessions){if(!d.downstream)continue;let u=d.acpSessionId;if(u&&o.activeTriggers.has(u)||this.isRuntimePendingPermission(d)){d.reloadAfterTurn=!0,ce.info("downstream busy, scheduling reload after turn",{reason:s,agentId:e,framework:o.framework,cloudId:c,acpId:u});continue}let h=d.downstream;d.downstream=void 0,ce.info("killing downstream for workspace reload (idle)",{reason:s,agentId:e,framework:o.framework,cloudId:c,acpId:u}),h.stop(s).catch(p=>ce.warn("downstream stop failed during reload (ignored)",{reason:s,agentId:e,cloudId:c,err:String(p)}))}}isRuntimePendingPermission(e){let s=this.opts.isRuntimePendingPermission;return!s||!e.downstream?!1:s(e.downstream)}async updateAgent(e){if(!e.cozeIdentity?.trim())return ce.info("_agent/update: empty cozeIdentity, noop",{agentId:e.agentId}),{ok:!0};let s=e.agentId,o=await he(s);if(!o)throw new S("AGENT_NOT_FOUND",`agent not found: ${s}`);if(o.cozeIdentity===e.cozeIdentity)return ce.info("_agent/update: cozeIdentity unchanged, noop",{agentId:s}),{ok:!0};try{await Pt(o.workspace,o.framework,s,e.cozeIdentity)}catch(c){throw ce.error("_agent/update: writeInstructionFile failed, aborting update",{agentId:s,framework:o.framework,workspace:o.workspace,err:String(c)}),new S("AGENT_PROTOCOL_ERROR",`failed to write instruction file for agent ${s}: ${String(c)}`,{cause:c})}return o.cozeIdentity=e.cozeIdentity,await Se(o),ce.info("_agent/update: cozeIdentity rewritten",{agentId:s,framework:o.framework}),this.reloadAgentSessions(s,"identity-changed"),{ok:!0}}async disconnectAgent(e){let s=e.agentId;if(!s)throw new S("IPC_BAD_REQUEST","_agent/disconnect: missing agentId");let o=await he(s);return o?(o.disconnectedAt=Date.now(),o.disconnectReason=e.reason??"",await Se(o),ce.info("agent disconnected",{agentId:s,reason:e.reason??"",force:e.force??!1}),this.opts.disposeAndMarkDisconnected&&await this.opts.disposeAndMarkDisconnected(s,e.reason??"disconnect"),{ok:!0}):(ce.warn("_agent/disconnect: agent not found, ignoring",{agentId:s}),{ok:!0})}async switchModel(e){if($e(e._meta,"_agent/switchModel"),!e.agentId)throw new S("IPC_BAD_REQUEST","_agent/switchModel: missing agentId");let s=e.model?.trim()?e.model:Le,o=await he(e.agentId);if(!o)throw new S("AGENT_NOT_FOUND",`agent not found: ${e.agentId}`);o.model=s,e.modelInfo&&(o.modelInfo=e.modelInfo),await Se(o),ce.info("_agent/switchModel: model persisted",{agentId:e.agentId,model:s,reason:e.reason??""});let c=this.opts.agents.get(e.agentId);if(!c)return ce.info("_agent/switchModel: agent not running, config persisted only",{agentId:e.agentId}),{ok:!0};c.model=s,e.modelInfo&&c.setModelInfo(e.modelInfo),this.opts.cleanupOpenclawProviders&&await this.opts.cleanupOpenclawProviders(c).catch(u=>ce.warn("cleanupOpenclawProviders before switchModel failed (ignored)",{agentId:e.agentId,err:String(u)}));let d=[];for(let[u,f]of c.allSessionQueues())d.push(f.enqueue(async()=>{let h=c.sessions.get(u);h?.downstream&&(await h.downstream.stop(`switchModel: ${s}`).catch(()=>{}),h.downstream=void 0)}));return await Promise.all(d),ce.info("_agent/switchModel: all session runtimes killed, next prompt will respawn",{agentId:e.agentId,model:s,cloudSessions:d.length}),{ok:!0}}async resetAgent(e){if($e(e._meta,Oe.RESET),!e.agentId)throw new S("IPC_BAD_REQUEST",`${Oe.RESET}: missing agentId`);return await this.runDetailSync(e.agentId,Oe.RESET,e.reason),{ok:!0}}async repairAgent(e){if($e(e._meta,Oe.REPAIR),!e.agentId)throw new S("IPC_BAD_REQUEST",`${Oe.REPAIR}: missing agentId`);let s=await this.loadAgentCfg(e.agentId);if(s&&s.framework!=="openclaw")throw new S("IPC_BAD_REQUEST",`${Oe.REPAIR} only allowed for openclaw, got ${s.framework}`);if(s&&this.opts.openclawRepair)try{await this.opts.openclawRepair(e.agentId,s.workspace)}catch(o){ce.warn("openclaw repair (delete+add) failed (ignored)",{agentId:e.agentId,reason:e.reason,err:String(o)})}return await this.runDetailSync(e.agentId,Oe.REPAIR,e.reason),{ok:!0}}async runDetailSync(e,s,o){if(!this.opts.detailSyncer){ce.warn("detailSyncer not wired, skipping sync",{method:s,agentId:e});return}try{await this.opts.detailSyncer(e)}catch(c){ce.warn("detail sync failed (ignored)",{method:s,agentId:e,reason:o,err:String(c)})}}async getFileTree(e){$e(e._meta,"_agent/getFileTree");let s=e._meta,o=Ct(s),c=await this.resolveWorkspace(o),d=e.filePath??"",u=this.safeJoin(c,d),f=await ei(u).catch(()=>null);if(!f)throw new S("IPC_BAD_REQUEST",`path not found: ${d}`);if(f.isSymbolicLink())throw new S("IPC_BAD_REQUEST",`symlink not allowed: ${d}`);let h=Ud(e.depth);return f.isDirectory()?{tree:await Fd(c,u,d,h)}:{tree:[{name:qd(d),path:ro(d||"."),isDir:!1,size:f.size,modifiedAt:Math.floor(f.mtimeMs)}]}}async getFileContent(e){$e(e._meta,"_agent/getFileContent");let s=Ct(e._meta),o=await this.resolveWorkspace(s);if(!e.filePath)throw new S("IPC_BAD_REQUEST","filePath required");let c=this.safeJoin(o,e.filePath),d=await ei(c).catch(()=>null);if(!d||!d.isFile())throw new S("IPC_BAD_REQUEST",`not a file: ${e.filePath}`);if(d.isSymbolicLink())throw new S("IPC_BAD_REQUEST",`symlink not allowed: ${e.filePath}`);if(d.size>Xs)throw new S("IPC_BAD_REQUEST",`file too large: ${d.size} bytes (max ${Xs})`);let u=await Zs(c);return u.includes(0)?{content:u.toString("base64"),encoding:"base64",size:d.size}:{content:u.toString("utf8"),encoding:"utf-8",size:d.size}}async resolveWorkspace(e){let s=this.opts.agents.get(e);return s?s.workspace:(await he(e).catch(()=>null))?.workspace??Je(e).workspace}safeJoin(e,s){let o=Ed(e,s||"."),c=eo(e,o);if(c.startsWith("..")||c===".."||c.startsWith(`..${to}`))throw new S("IPC_BAD_REQUEST",`path escapes workspace: ${s}`);return o}loadAgentCfg(e){return he(e)}async requireAgentCfg(e){let s=await this.loadAgentCfg(e);if(!s)throw new S("AGENT_NOT_FOUND",`no config for agent: ${e}`);return s}};function Pd(n){let e=n.trim().replace(/[\x00-\x1f<>:"|?*/\\]+/g,"-").replace(/^[\s.-]+|[\s.-]+$/g,"").slice(0,64);if(!e||e==="."||e==="..")throw new S("IPC_BAD_REQUEST",`invalid skill name: ${n}`);if(/^(con|prn|aux|nul|com[1-9]|lpt[1-9])$/i.test(e))throw new S("IPC_BAD_REQUEST",`reserved windows filename: ${n}`);return e}function Cd(n){return n==="claude-code"?Me(".claude","skills"):Me(".agents","skills")}var kd=3e4,Dd=50*1024*1024,zn=3e4;async function ti(n){let{agentId:e,workspace:s,framework:o,skill:c}=n;if(!c.skillName)throw new S("IPC_BAD_REQUEST","skill missing skillName");let d=typeof c.content=="string"&&c.content.length>0,u=typeof c.downloadUrl=="string"&&c.downloadUrl.length>0;if(!d&&!u)throw new S("IPC_BAD_REQUEST",`skill ${c.skillId} missing both content and downloadUrl`);let f=Pd(c.skillName),h=Cd(o),p=Me(h,f),w=Me(s,p);if(await _d(w,{recursive:!0}),d){let E=Buffer.from(c.content,"utf8");Qt(E.length),await Ys(Me(w,"SKILL.md"),E,"utf8")}else{let E=await Nd(c.downloadUrl);Ld(E)?await Md(E,w):await Ys(Me(w,"SKILL.md"),E.toString("utf8"),"utf8")}let b={skillId:c.skillId,skillName:c.skillName,relPath:p,installedAt:Date.now(),...c.description?{description:c.description}:{},...c.icon?{icon:c.icon}:{},...c.version?{version:c.version}:{},...c.downloadUrl?{downloadUrl:c.downloadUrl}:{},...c.config?{config:c.config}:{},...c.builtin?{builtin:c.builtin}:{}};return ce.info("skill installed",{agentId:e,skillId:c.skillId,skillName:c.skillName,relPath:p,source:d?"content":"downloadUrl"}),b}function ni(n,e,s){let o=e.get(s.skillId);if(o!==void 0){n[o]=s;return}e.set(s.skillId,n.length),n.push(s)}function Rd(n){return{skillId:n.skillId,skillName:n.skillName,...n.description?{description:n.description}:{},...n.icon?{icon:n.icon}:{},...n.version?{version:n.version}:{},...n.config?{config:n.config}:{},...n.builtin?{builtin:n.builtin}:{}}}async function Nd(n){if(!n)throw new S("IPC_BAD_REQUEST","skill missing downloadUrl");if(n.startsWith("data:")){let e=Math.floor(n.length*3/4);Qt(e);let s=Od(n);return Qt(s.length),s}if(n.startsWith("file:")){let e=new URL(n).pathname,s=await Zs(e);return Qt(s.length),s}if(Nn(n)){let e=new AbortController,s=setTimeout(()=>e.abort(),kd);try{let o=await fetch(n,{signal:e.signal});if(!o.ok)throw new S("IPC_BAD_REQUEST",`fetch skill failed HTTP ${o.status} ${n}`);let c=await o.arrayBuffer();return Qt(c.byteLength),Buffer.from(c)}finally{clearTimeout(s)}}throw new S("IPC_BAD_REQUEST",`unsupported downloadUrl scheme (\u8981 https/data/file): ${n.slice(0,80)}`)}function Qt(n){if(n>Dd)throw new S("IPC_BAD_REQUEST",`skill too large: ${n} bytes`)}function Od(n){let e=/^data:([^,;]*)(;base64)?,(.*)$/s.exec(n);if(!e)throw new S("IPC_BAD_REQUEST","bad data URL");let s=!!e[2],o=e[3]??"";return s?Buffer.from(o,"base64"):Buffer.from(decodeURIComponent(o),"utf8")}function Ld(n){return n.length>=2&&n[0]===31&&n[1]===139}async function Md(n,e){await Bd(n),await new Promise((s,o)=>{let c=Qs("tar",["-xzf","-","-C",e,"--strip-components=1","--no-same-owner"],{stdio:["pipe","pipe","pipe"]}),d="";c.stderr?.on("data",f=>{d+=String(f)});let u=setTimeout(()=>{c.kill("SIGKILL"),o(new S("IPC_BAD_REQUEST",`tar extract timeout (${zn}ms)`))},zn);c.on("error",f=>{clearTimeout(u),o(new S("IPC_BAD_REQUEST",`tar spawn failed: ${f.message}`,{cause:f}))}),c.on("exit",f=>{clearTimeout(u),f===0?s():o(new S("IPC_BAD_REQUEST",`tar exit ${f}${d?`: ${d.trim().slice(0,200)}`:""}`))}),c.stdin?.end(n)})}async function Bd(n){let e=await new Promise((s,o)=>{let c=Qs("tar",["-tzvf","-"],{stdio:["pipe","pipe","pipe"]}),d="",u="";c.stdout?.on("data",h=>{d+=String(h)}),c.stderr?.on("data",h=>{u+=String(h)});let f=setTimeout(()=>{c.kill("SIGKILL"),o(new S("IPC_BAD_REQUEST",`tar list timeout (${zn}ms)`))},zn);c.on("error",h=>{clearTimeout(f),o(new S("IPC_BAD_REQUEST",`tar list spawn failed: ${h.message}`))}),c.on("exit",h=>{clearTimeout(f),h===0?s(d):o(new S("IPC_BAD_REQUEST",`tar list exit ${h}${u?`: ${u.trim().slice(0,200)}`:""}`))}),c.stdin?.end(n)});for(let s of e.split(`
117
- `)){let o=s.trim();if(!o)continue;let c=o.charCodeAt(0);if(c!==45&&c!==100)throw new S("IPC_BAD_REQUEST",`tar entry kind '${o[0]}' not allowed (symlink/hardlink/special): ${o.slice(0,100)}`);let u=(o.match(/\s(\S.*)$/)?.[1]??"").split(" -> ")[0]?.trim()??"";if(!u)continue;if(u.startsWith("/"))throw new S("IPC_BAD_REQUEST",`tar entry absolute path: ${u}`);if(u.split(/[/\\]/).some(h=>h===".."))throw new S("IPC_BAD_REQUEST",`tar entry contains '..': ${u}`)}}var zd=5e3;async function Fd(n,e,s,o){return no(n,e,s,o,{count:0})}async function no(n,e,s,o,c){if(o<=0)return[];let d;try{d=await yd(e,{withFileTypes:!0})}catch{return[]}let u=[];for(let f of d){if(Td.has(f.name)||f.isSymbolicLink())continue;if(c.count>=zd){u.push({name:"...",path:"...",isDir:!1,size:0,modifiedAt:0,hasMore:!0});break}let h=Me(e,f.name),p=Sd(Me(s,f.name)),w=null;try{w=await ei(h)}catch{continue}if(w.isSymbolicLink())continue;c.count++;let b={name:f.name,path:ro(eo(n,h)),isDir:w.isDirectory(),size:w.size,modifiedAt:Math.floor(w.mtimeMs)};w.isDirectory()&&o>1&&(b.children=await no(n,h,p,o-1,c)),u.push(b)}return u.sort((f,h)=>f.isDir!==h.isDir?f.isDir?-1:1:f.name.localeCompare(h.name)),u}function Ud(n){return!n||n<=0?Id:Math.min(n,Ad)}function qd(n){if(!n||n==="."||n==="/")return".";let e=n.split(/[/\\]/);return e[e.length-1]||"."}function ro(n){return n.split(to).join("/")}q();import{readFileSync as mp}from"node:fs";import{dirname as _p,join as yp}from"node:path";import{fileURLToPath as vp}from"node:url";var st="0.1.63";var Be=N("agent-health-reporter"),Gd=1e4,Zt=class{constructor(e){this.opts=e;this.intervalMs=e.intervalMs??Gd}opts;timer=null;inFlight=!1;unsubscribeRegister=null;intervalMs;start(){this.timer||(this.timer=setInterval(()=>{this.tick()},this.intervalMs),this.timer.unref?.(),this.unsubscribeRegister=this.opts.core.onAgentRegister(()=>{this.tick()}),Be.info("heartbeat started",{intervalMs:this.intervalMs}),this.tick())}stop(){this.timer&&(clearInterval(this.timer),this.timer=null,this.unsubscribeRegister&&(this.unsubscribeRegister(),this.unsubscribeRegister=null),Be.info("heartbeat stopped"))}async tick(){if(this.inFlight){Be.debug("previous tick still in-flight, skip");return}let e=this.opts.getDeviceId();if(!e){Be.debug("deviceId not available, skip tick (\u5C1A\u672A pair)");return}this.inFlight=!0;try{let s=[];for(let f of this.opts.core.agents.values()){let h=Hd(f);if(!h)continue;let p={agentId:f.agentId,status:h};f.patToken&&(p.patToken=f.patToken),f.accountId&&(p.accountId=f.accountId),s.push(p)}if(s.length===0)return;let o={agents:s,bridgeVersion:st,_meta:{cozeDeviceId:e}},c;try{c=await this.opts.core.sendRequest("_agent/health",o,5e3)}catch(f){Be.warn("heartbeat batch send failed",{count:s.length,err:String(f)})}let d=c?.authFailures;if(d&&d.length>0&&(Be.warn("heartbeat received authFailures from cloud",{count:d.length,agentIds:d.map(f=>f.agentId)}),this.opts.onAuthFailures))try{await this.opts.onAuthFailures(d)}catch(f){Be.warn("onAuthFailures callback failed (ignored)",{err:String(f)})}let u=c?.minBridgeVersion;if(u&&(Be.info("heartbeat received minBridgeVersion from cloud",{minV:u}),this.opts.onMinBridgeVersion))try{await this.opts.onMinBridgeVersion(u)}catch(f){Be.warn("onMinBridgeVersion callback failed (ignored)",{err:String(f)})}}finally{this.inFlight=!1}if(this.opts.onTickEnd)try{await this.opts.onTickEnd()}catch(s){Be.warn("onTickEnd hook failed",{err:String(s)})}}};function Hd(n){return n.status==="error"?"error":n.activeTriggers.size>0?"busy":n.status==="ok"?"online":null}it();import{mkdir as si,rm as mx}from"node:fs/promises";import{spawn as Xd,spawnSync as Qd}from"node:child_process";function en(n,e,s){return s===void 0?{jsonrpc:"2.0",id:n,method:e}:{jsonrpc:"2.0",id:n,method:e,params:s}}function tn(n,e){return e===void 0?{jsonrpc:"2.0",method:n}:{jsonrpc:"2.0",method:n,params:e}}function Dt(n,e){return{jsonrpc:"2.0",id:n,result:e}}function ot(n,e){return{jsonrpc:"2.0",id:n,error:e}}var Fn=class extends Error{code;data;constructor(e){super(`JSON-RPC error code=${e.code} ${e.message}`),this.name="RemoteRpcError",this.code=e.code,e.data!==void 0&&(this.data=e.data)}},H={PARSE_ERROR:-32700,INVALID_REQUEST:-32600,METHOD_NOT_FOUND:-32601,INVALID_PARAMS:-32602,INTERNAL_ERROR:-32603,AGENT_NOT_FOUND:-32001,AGENT_BUSY:-32002,AGENT_TIMEOUT:-32003,AGENT_SPAWN_FAILED:-32004,OPERATION_NOT_ALLOWED_FOR_LOCAL:-32005,AGENT_DISCONNECTED:-32006,MODEL_TOKEN_GEN_FAILED:-32009,PATH_OUTSIDE_WORKSPACE:-32010,FILE_TOO_LARGE:-32011,UNSUPPORTED_MIME:-32012,UPLOAD_FAILED:-32013,UPSTREAM_NOT_READY:-32014,BRIDGE_UPGRADING:-32015,AGENT_FRAME_IDLE_TIMEOUT:-32016,MODEL_MODALITY_UNSUPPORTED:-32017};function io(n){return"method"in n&&"id"in n&&n.id!==void 0}function so(n){return"method"in n&&!("id"in n)}function Un(n){return!("method"in n)&&"id"in n}var jd={AGENT_NOT_FOUND:H.AGENT_NOT_FOUND,AGENT_BUSY:H.AGENT_BUSY,AGENT_DISCONNECTED:H.AGENT_DISCONNECTED,AGENT_TIMEOUT:H.AGENT_TIMEOUT,AGENT_FRAME_IDLE_TIMEOUT:H.AGENT_FRAME_IDLE_TIMEOUT,AGENT_SPAWN_FAILED:H.AGENT_SPAWN_FAILED,AGENT_PROTOCOL_ERROR:H.INTERNAL_ERROR,BRIDGE_CONFIG_INVALID:H.INTERNAL_ERROR,BRIDGE_INTERNAL:H.INTERNAL_ERROR,IPC_AUTH_FAILED:H.INTERNAL_ERROR,IPC_BAD_REQUEST:H.INVALID_REQUEST,MODEL_TOKEN_GEN_FAILED:H.MODEL_TOKEN_GEN_FAILED,MODEL_MODALITY_UNSUPPORTED:H.MODEL_MODALITY_UNSUPPORTED,OPERATION_NOT_ALLOWED_FOR_LOCAL:H.OPERATION_NOT_ALLOWED_FOR_LOCAL,UPSTREAM_DISCONNECTED:H.INTERNAL_ERROR,UPSTREAM_HANDSHAKE_FAILED:H.INTERNAL_ERROR,PATH_OUTSIDE_WORKSPACE:H.PATH_OUTSIDE_WORKSPACE,FILE_TOO_LARGE:H.FILE_TOO_LARGE,UNSUPPORTED_MIME:H.UNSUPPORTED_MIME,UPLOAD_FAILED:H.UPLOAD_FAILED,UPSTREAM_NOT_READY:H.UPSTREAM_NOT_READY,BRIDGE_UPGRADING:H.BRIDGE_UPGRADING,NPX_CACHE_CORRUPT:H.INTERNAL_ERROR};function Kd(n){if(n!=null)return n instanceof Error?{name:n.name,message:nn(n.message)}:typeof n=="string"?nn(n):typeof n=="object"?Jd(n):n}var Wd=[[/\/Users\/[^/\s'"`)]+/g,"/Users/<redacted>"],[/\/home\/[^/\s'"`)]+/g,"/home/<redacted>"],[/[A-Za-z]:\\Users\\[^\\\s'"`)]+/g,"C:\\Users\\<redacted>"],[/(Bearer|Token|Authorization:)\s+[\w._-]+/gi,"$1 <redacted>"],[/\b(sk|pat|ak)[-_][A-Za-z0-9_-]{20,}\b/g,"<redacted-key>"]];function nn(n){let e=n;for(let[s,o]of Wd)e=e.replace(s,o);return e}function Jd(n){let e={};for(let[s,o]of Object.entries(n))typeof o=="string"?e[s]=nn(o):e[s]=o;return e}function rn(n){if(n instanceof S){let e=Kd(n.cause),s={bridgeCode:n.code,retriable:n.retriable};return e!==void 0&&(s.cause=e),{code:jd[n.code]??H.INTERNAL_ERROR,message:nn(n.message),data:s}}return{code:H.INTERNAL_ERROR,message:nn(n instanceof Error?n.message:String(n))}}function oo(n){let e=n.data,s=e?.bridgeCode??"AGENT_PROTOCOL_ERROR",o=!!e&&typeof e.message=="string"&&!!e.message,c=o?e?.message:n.message,d=n.data;if(o&&e){let{message:u,...f}=e;d=f}return new S(s,c,{retriable:e?.retriable??!1,cause:d})}function co(n){return`${JSON.stringify(n)}
118
- `}var ao=10*1024*1024,qn=class{buffer="";onError;constructor(e={}){this.onError=e.onError}push(e){if(this.buffer+=typeof e=="string"?e:e.toString("utf8"),this.buffer.length>ao){let c=this.buffer.length;return this.buffer="",this.onError?.({line:`<buffer overflow: ${c} bytes, dropped>`,error:new Error(`LdjsonDecoder buffer exceeded ${ao} bytes`)}),[]}let s=this.buffer.split(`
119
- `);this.buffer=s.pop()??"";let o=[];for(let c of s){let d=c.replace(/\r$/,"").trim();if(d)try{o.push(JSON.parse(d))}catch(u){this.onError?.({line:d,error:u})}}return o}flush(){if(!this.buffer)return[];let e=this.buffer.replace(/\r$/,"").trim();if(this.buffer="",!e)return[];try{return[JSON.parse(e)]}catch(s){return this.onError?.({line:e,error:s}),[]}}};var uo={"session/prompt":"session.prompt","session/cancel":"session.cancel","session/new":"session.new","session/load":"session.load","_agent/create":"agent.create","_agent/health":"agent.health","_agent/pair":"agent.pair","_agent/listSkills":"agent.listSkills","_agent/addSkills":"agent.addSkills","_agent/removeSkills":"agent.removeSkills","_agent/getFileTree":"agent.getFileTree","_agent/getFileContent":"agent.getFileContent","_agent/detail":"agent.detail","_agent/update":"agent.update","_agent/disconnect":"agent.disconnect","_agent/switchModel":"agent.switchModel","_agent/genModelToken":"agent.genModelToken","_agent/reset":"agent.reset","_agent/repair":"agent.repair","session/request_permission":"session.requestPermission",initialize:"initialize"},Np=Object.fromEntries(Object.entries(uo).map(([n,e])=>[e,n])),$d={"session.prompt":["agentId","triggerMsgId","sessionId"],"session.cancel":["agentId","triggerMsgId","sessionId"],"session.new":["agentId"],"session.load":["agentId"],"agent.create":["agentId"],"agent.health":[],"agent.listSkills":["agentId"],"agent.addSkills":["agentId"],"agent.removeSkills":["agentId"],"agent.getFileTree":["agentId"],"agent.getFileContent":["agentId"],"agent.detail":["agentId"],"agent.update":["agentId"],"agent.disconnect":["agentId"],"agent.switchModel":["agentId"],"agent.genModelToken":["agentId","sessionId"],"agent.reset":["agentId"],"agent.repair":["agentId"],"session.requestPermission":["agentId","sessionId"],"agent.pair":[],initialize:[]},Rt=class{seq=0;next(e,s){this.seq+=1;let o=uo[e]??Vd(e),c=$d[o]??[],d=[o,String(this.seq)];if(c.length>0){let u=c.map(h=>xo(s?.[h]??"")),f=Yd(u).join(":");f&&d.push(f)}else s&&Object.values(s).some(u=>u)&&d.push(Object.values(s).filter(Boolean).map(u=>xo(String(u))).join(":"));return d.join("_")}reset(){this.seq=0}};function Vd(n){return n.replace(/[\s/]+/g,".").replace(/_+/g,"-")}function xo(n){return n.replace(/[:_\s]+/g,"-")}function Yd(n){let e=n.length;for(;e>0&&!n[e-1];)e-=1;return n.slice(0,e)}function at(n,e){let s=process.env[n];if(!s)return e;let o=Number(s);return Number.isFinite(o)&&o>0?o:e}q();var Zd=at("COZE_BRIDGE_INITIALIZE_TIMEOUT_MS",3e4),ex=200,tx=/(ENOTEMPTY|EEXIST).*_npx[/\\]/;function ri(n){return n.some(e=>tx.test(e))}var nx=at("COZE_BRIDGE_SESSION_PROMPT_MAX_MS",3600*1e3),rx=at("COZE_BRIDGE_SESSION_PROMPT_FRAME_IDLE_MS",600*1e3),fo=500;function ix(n){try{let e=JSON.stringify(n);return e===void 0||e.length<=fo?n:`${e.slice(0,fo)}...<truncated, total ${e.length} chars>`}catch{return"<unserializable>"}}function lo(n,e){if(!(typeof n!="number"||n<=0))try{if(process.platform==="win32"){let s=["/PID",String(n),"/T"];e==="SIGKILL"&&s.push("/F"),Qd("taskkill",s,{stdio:"ignore",windowsHide:!0})}else process.kill(-n,e)}catch{}}var ze=class{constructor(e){this.opts=e;this.log=N(`downstream.${this.constructor.name}`),this.decoder=new qn({onError:s=>this.log.warn("decode line failed",{line:s.line})})}opts;child;decoder;pending=new Map;inflightAgentRequests=new Map;idAllocator=new Rt;updateHandlers=[];agentRequestHandlers=[];exitHandlers=[];log;stopped=!1;stderrRing=[];sanitizeEnv(e){return e}async start(){if(this.child)throw new S("BRIDGE_INTERNAL","Downstream already started");let e=process.platform!=="win32",s=Xd(this.opts.command,this.opts.args,{cwd:this.opts.cwd,env:{...this.sanitizeEnv(process.env),...this.opts.env},stdio:["pipe","pipe","pipe"],detached:e});this.child=s,s.stdout?.setEncoding("utf8"),s.stdout?.on("data",o=>{try{for(let c of this.decoder.push(o))this.dispatch(c)}catch(c){this.log.warn("stdout dispatch threw, swallowed to keep daemon alive",{err:String(c)})}}),s.stderr?.setEncoding("utf8"),s.stderr?.on("data",o=>{let c=o.trimEnd();this.stderrRing.push(c),this.stderrRing.length>ex&&this.stderrRing.shift(),this.log.debug("stderr",{text:c})}),s.stdin?.on("error",o=>{this.log.warn("child stdin error",{err:String(o)})}),s.stdout?.on("error",o=>{this.log.warn("child stdout error",{err:String(o)})}),s.stderr?.on("error",o=>{this.log.warn("child stderr error",{err:String(o)})}),s.on("exit",(o,c)=>{this.stopped=!0,(o!==0||c!==null)&&this.stderrRing.length>0&&(this.log.warn("downstream exited abnormally, recent stderr",{code:o,signal:c,recentStderr:[...this.stderrRing]}),(this.framework==="claude-code"||this.framework==="codex")&&ri(this.stderrRing)&&(this.log.warn("npx cache corruption detected, triggering global install fallback (D93)",{framework:this.framework}),It(this.framework).catch(f=>{this.log.warn("D93 fallback install failed (will retry next spawn cycle)",{framework:this.framework,err:String(f)})})));try{for(let u of this.decoder.flush())this.dispatch(u)}catch(u){this.log.debug("decoder.flush on exit threw (ignored)",{err:String(u)})}this.failAllPending(new S("AGENT_PROTOCOL_ERROR",`agent exited (${o}/${c})`));for(let u of this.exitHandlers)u(o,c)}),s.on("error",o=>{this.log.error("child error",{err:String(o)}),this.failAllPending(new S("AGENT_SPAWN_FAILED",String(o),{cause:o}))}),this.log.info("downstream started",{command:this.opts.command,pid:s.pid,cwd:this.opts.cwd})}async stop(e){if(!this.child||this.stopped)return;this.stopped=!0,this.log.info("downstream stopping",{reason:e});let s=this.child,o=new Promise(d=>s.once("exit",()=>d()));lo(s.pid,"SIGTERM");let c=setTimeout(()=>{s.killed||lo(s.pid,"SIGKILL")},5e3);try{await o}finally{clearTimeout(c)}}pid(){return this.child?.pid}isAlive(){return!!this.child&&!this.stopped}getStderrTail(){return[...this.stderrRing]}initialize(e){return this.call("initialize",e)}sessionNew(e){return this.call("session/new",{mcpServers:[],...e})}sessionLoad(e){return this.call("session/load",{mcpServers:[],...e})}sessionPrompt(e,s=nx,o=rx){return this.call("session/prompt",e,s,o)}async sessionCancel(e){!this.child||this.stopped||this.writeFrame(tn("session/cancel",e))}onUpdate(e){this.updateHandlers.push(e)}onAgentRequest(e){this.agentRequestHandlers.push(e)}respondAgentRequest(e,s){if(this.inflightAgentRequests.delete(e),!(!this.child||this.stopped))try{this.writeFrame(Dt(e,s))}catch(o){this.log.warn("respondAgentRequest write failed",{id:e,err:String(o)})}}respondAgentRequestError(e,s){if(this.inflightAgentRequests.delete(e),!(!this.child||this.stopped))try{this.writeFrame(ot(e,s))}catch(o){this.log.warn("respondAgentRequestError write failed",{id:e,err:String(o)})}}onExit(e){this.exitHandlers.push(e)}call(e,s,o=Zd,c=0){if(!this.child||this.stopped)return Promise.reject(new S("AGENT_PROTOCOL_ERROR","downstream not started"));let d=this.idAllocator.next(e),u=en(d,e,s),f=o>0&&Number.isFinite(o),h=c>0&&Number.isFinite(c);return new Promise((p,w)=>{let b={resolve:p,reject:w,timer:null,frameIdleTimer:null,armFrameIdle:null,method:e};f&&(b.timer=setTimeout(()=>{this.pending.delete(d),b.frameIdleTimer&&clearTimeout(b.frameIdleTimer),w(new S("AGENT_TIMEOUT",`${e} timed out after ${o}ms`))},o));let E=h?()=>{b.frameIdleTimer&&clearTimeout(b.frameIdleTimer),b.frameIdleTimer=setTimeout(()=>{if(this.inflightAgentRequests.size>0){this.log.debug("frame-idle fired but agent request inflight, re-arming",{id:d,method:e,inflight:this.inflightAgentRequests.size}),E?.();return}b.timer&&clearTimeout(b.timer),this.pending.delete(d),this.log.warn("frame-idle timeout, rejecting pending call",{id:d,method:e,frameIdleMs:c}),w(new S("AGENT_FRAME_IDLE_TIMEOUT",`${e} no session/update for ${c}ms (no inflight agent request)`))},c)}:null;b.armFrameIdle=E,this.pending.set(d,b),E?.();try{this.writeFrame(u)}catch(I){b.timer&&clearTimeout(b.timer),b.frameIdleTimer&&clearTimeout(b.frameIdleTimer),this.pending.delete(d),w(I)}})}writeFrame(e){if(!this.child?.stdin||this.child.stdin.destroyed)throw new S("AGENT_PROTOCOL_ERROR","downstream stdin not writable");this.child.stdin.write(co(e),s=>{s&&this.log.warn("stdin write callback err",{err:String(s)})})}dispatch(e){if(Un(e)){let s=e.id!==null?this.pending.get(e.id):void 0;if(!s){this.log.warn("orphan response",{id:e.id});return}this.pending.delete(e.id),s.timer&&clearTimeout(s.timer),s.frameIdleTimer&&clearTimeout(s.frameIdleTimer),e.error?(this.log.warn("downstream returned error frame",{id:e.id,method:s.method,code:e.error.code,message:e.error.message,data:e.error.data}),s.reject(oo(e.error))):e.result===void 0?(this.log.warn("downstream response missing both result and error",{id:e.id,method:s.method}),s.reject(new S("AGENT_PROTOCOL_ERROR",`${s.method} response missing both result and error`))):(this.log.info("downstream returned result",{id:e.id,method:s.method,result:ix(e.result)}),s.resolve(e.result));return}if(so(e)){if(e.method==="session/update"){for(let s of this.pending.values())s.armFrameIdle?.();for(let s of this.updateHandlers)try{Promise.resolve(s(e.params)).catch(o=>this.log.warn("update handler failed (async)",{err:String(o)}))}catch(o){this.log.warn("update handler threw sync, swallowed",{err:String(o)})}}else this.log.info("unknown notification (drop, not forwarded)",{method:e.method});return}if(io(e)){let s=e;try{this.handleAgentRequest(s).catch(o=>this.log.error("agent request handler failed (async)",{method:s.method,err:String(o)}))}catch(o){this.log.warn("handleAgentRequest threw sync, swallowed",{method:s.method,err:String(o)})}}}async handleAgentRequest(e){if(this.agentRequestHandlers.length===0){this.writeFrame(ot(e.id,{code:-32601,message:`method not handled by Bridge: ${e.method}`}));return}this.inflightAgentRequests.set(e.id,e.method);for(let s of this.agentRequestHandlers)try{await s(e)}catch(o){this.log.error("agentRequestHandler threw",{method:e.method,err:String(o)});try{this.writeFrame(ot(e.id,rn(o)))}catch{}this.inflightAgentRequests.delete(e.id)}}failAllPending(e){for(let s of this.pending.values())s.timer&&clearTimeout(s.timer),s.frameIdleTimer&&clearTimeout(s.frameIdleTimer),s.reject(e);this.pending.clear(),this.inflightAgentRequests.clear()}};var sx="@agentclientprotocol/claude-agent-acp@latest";function ox(n){let e={};for(let[s,o]of Object.entries(n))o!==void 0&&(s.startsWith("CLAUDE")||s==="AI_AGENT"||s==="BAGGAGE"||(e[s]=o));return e}var Gn=class extends ze{framework="claude-code";constructor(e){let s=At("claude-code"),[o,c]=s?[s,[]]:["npx",["-y",sx]],d=e.command??o,u=e.args??c,f={command:d,args:u,cwd:e.cwd,...e.env?{env:e.env}:{}};super(f)}sanitizeEnv(e){return ox(e)}};import{mkdtempSync as ax,rmSync as cx}from"node:fs";import{tmpdir as dx}from"node:os";import{join as xx}from"node:path";var ux="@zed-industries/codex-acp@latest",Hn=class extends ze{framework="codex";authMethodId;codexHomeDir;constructor(e){let s=At("codex"),[o,c]=s?[s,[]]:["npx",["-y",ux]],d=e.command??o,u=e.args??c,f=e.extraArgs?[...u,...e.extraArgs]:u,h=e.isolateCodexHome?ax(xx(dx(),"coze-bridge-codex-home-")):void 0,p=h?{...e.env??{},CODEX_HOME:h}:e.env,w={command:d,args:f,cwd:e.cwd,...p?{env:p}:{}};super(w),this.authMethodId=e.authMethodId,this.codexHomeDir=h}async initialize(e){let s=await super.initialize(e);return this.authMethodId&&await this.call("authenticate",{methodId:this.authMethodId}),s}async stop(e){if(await super.stop(e),this.codexHomeDir)try{cx(this.codexHomeDir,{recursive:!0,force:!0})}catch{}}};var fx=3e4,Nt=class extends ze{framework="openclaw";agentId;sessionName;slashModelOnStart;constructor(e){let s=e.sessionName??"default",o=["acp","--session",`agent:${e.agentId}:${s}`];e.gatewayToken&&o.push("--token",e.gatewayToken);let c={command:e.command,args:o,cwd:e.cwd,...e.env?{env:e.env}:{}};super(c),this.agentId=e.agentId,this.sessionName=s,this.slashModelOnStart=e.slashModelOnStart}async afterSessionEstablished(e){this.slashModelOnStart&&(this.log.info("switching session to per-session provider via /model",{agentId:this.agentId,sessionName:this.sessionName,slash:this.slashModelOnStart}),await this.sessionPrompt({sessionId:e,prompt:[{type:"text",text:`/model ${this.slashModelOnStart}`}]},fx))}get acpSessionName(){return this.sessionName}};q();ie();function ii(n){return n.replace(/[^A-Za-z0-9._-]+/g,"-")}var Ot=class{slots=[];running=!1;closed=!1;disposed=!1;enqueue(e){return this.disposed?Promise.reject(new Error("AsyncQueue disposed")):this.closed?Promise.reject(new Error("AsyncQueue closed")):new Promise((s,o)=>{this.slots.push({task:e,resolve:s,reject:o}),this.drain()})}close(){this.closed=!0}dispose(e=new Error("AsyncQueue disposed")){for(this.disposed=!0,this.closed=!0;this.slots.length>0;)this.slots.shift()?.reject(e)}get size(){return this.slots.length}get isRunning(){return this.running}get isDisposed(){return this.disposed}async drain(){if(!this.running){this.running=!0;try{for(;this.slots.length>0&&!this.disposed;){let e=this.slots.shift();if(!e)break;try{let s=await e.task();e.resolve(s)}catch(s){e.reject(s)}}}finally{this.running=!1}}}};var jn=class{agentId;framework;workspace;deployType;accountId;patToken;modelInfo;sessions=new Map;sessionQueues=new Map;activeTriggers=new Map;status="ok";model;lastActiveAt=Date.now();constructor(e){this.agentId=e.agentId,this.framework=e.framework,this.workspace=e.workspace,this.model=e.model,this.deployType=e.deployType??"local",e.accountId&&(this.accountId=e.accountId),e.patToken&&(this.patToken=e.patToken),e.modelInfo&&(this.modelInfo=e.modelInfo)}setPatToken(e){this.patToken=e}setModelInfo(e){this.modelInfo=e}getSessionQueue(e){let s=this.sessionQueues.get(e);return(!s||s.isDisposed)&&(s=new Ot,this.sessionQueues.set(e,s)),s}allSessionQueues(){return this.sessionQueues.entries()}hasSessionQueue(e){let s=this.sessionQueues.get(e);return!!s&&!s.isDisposed}async dispose(e){this.status="stopped";let s=new Error(`AgentSession disposed${e?`: ${e}`:""}`);for(let o of this.sessionQueues.values())o.dispose(s);this.sessionQueues.clear(),await this.killAllRuntimes(e??"dispose")}async killAllRuntimes(e){let s=[];for(let[,o]of this.sessions)sn(o),o.downstream&&(s.push(o.downstream.stop(e).catch(()=>{})),o.downstream=void 0);await Promise.all(s),this.activeTriggers.clear()}};function sn(n){n.idleTimer&&(clearTimeout(n.idleTimer),n.idleTimer=void 0)}import{spawn as lx}from"node:child_process";import{homedir as gx}from"node:os";import{join as hx}from"node:path";Pn();q();async function po(){let n=hx(gx(),".openclaw/openclaw.json");return(await Tt(n))?.gateway?.auth?.token??""}var go=N("openclaw.config"),px=[0,5e3,5e3],ho="models.providers.",Kn="agents.defaults.models",Wn=class{command;env;retryDelaysMs;queue=new Ot;constructor(e){this.command=e.command,this.env=e.env??process.env,this.retryDelaysMs=e.retryDelaysMs??px}async withRetry(e,s){let o;for(let c=0;c<this.retryDelaysMs.length;c++){let d=this.retryDelaysMs[c]??0;d>0&&await new Promise(u=>setTimeout(u,d));try{return await s()}catch(u){o=u,go.warn("openclaw cli failed, will retry",{label:e,attempt:c+1,err:String(u)})}}throw new S("AGENT_SPAWN_FAILED",`openclaw cli ${e} failed after ${this.retryDelaysMs.length} attempts: ${o?.message??"unknown"}`)}runCli(e){return new Promise((s,o)=>{let c=lx(this.command,e,{stdio:["ignore","pipe","pipe"],env:this.env}),d="";c.stderr?.on("data",u=>{d+=u.toString("utf8")}),c.on("error",o),c.on("close",u=>{u===0?s():o(new Error(`exit ${u}: ${d.trim().slice(0,500)}`))})})}async runCliTolerant(e,s){try{await this.runCli(e)}catch(o){let c=String(o);if(s.some(d=>c.includes(d)))return;throw o}}async bestEffortUnset(e,s){try{await this.queue.enqueue(()=>this.withRetry(e,()=>this.runCli(["config","unset",s])))}catch(o){go.warn(`${e} failed (best-effort)`,{configPath:s,err:String(o)})}}ensureProvider(e,s){return this.queue.enqueue(()=>this.withRetry(`config set models.providers.${e}`,()=>this.runCli(["config","set",`${ho}${e}`,JSON.stringify(s),"--strict-json","--merge"])))}removeProvider(e){return this.bestEffortUnset(`config unset models.providers.${e}`,`${ho}${e}`)}addModelToAllowlist(e,s){let o={[e]:s?{alias:s}:{}};return this.queue.enqueue(()=>this.withRetry(`config set ${Kn}[${e}]`,()=>this.runCli(["config","set",Kn,JSON.stringify(o),"--strict-json","--merge"])))}removeModelFromAllowlist(e){return this.bestEffortUnset(`config unset ${Kn}[${e}]`,`${Kn}.${e}`)}ensureAgent(e,s,o){let c=["agents","add",e,"--workspace",s,"--non-interactive"];return o&&c.push("--model",o),this.queue.enqueue(()=>this.withRetry(`agents add ${e}`,()=>this.runCliTolerant(c,["already exists","already registered"])))}deleteAgent(e){return this.queue.enqueue(()=>this.withRetry(`agents delete ${e}`,()=>this.runCliTolerant(["agents","delete",e,"--force"],["not found","does not exist"])))}};var pe=N("agent-manager"),_x=(n,e,s,o,c,d,u,f)=>{switch(n){case"claude-code":{let h={...c?{...js(c),...Js(c,u)}:{},...f??{},IS_SANDBOX:"1"};return new Gn({cwd:s,env:h})}case"codex":{let p=[...c?[...Ks(c),...Vs(c,u)]:[],"-c",'sandbox_mode="danger-full-access"',"-c",'approval_policy="never"'],w={...c?Ws(c):{},...f??{}},b=!!c;return new Hn({cwd:s,...p.length>0?{extraArgs:p}:{},...Object.keys(w).length>0?{env:w}:{},...b?{authMethodId:"openai-api-key",isolateCodexHome:!0}:{}})}case"openclaw":return new Nt({command:e,cwd:s,agentId:o,...d?{sessionName:ii(d)}:{}})}};function oi(n){return n==="claude-code"||n==="codex"}var yx={path:"",version:"cloud-deployed"},bx={protocolVersion:1,clientCapabilities:{fs:{readTextFile:!0,writeTextFile:!0}}},vx=6e4,Sx=at("COZE_BRIDGE_SPAWN_AWAIT_INSTALL_MS",25e3),Jn=class{paths;config;registry;factory;createTimeoutMs;spawnAwaitInstallMs;openclawConfigCache;ensuredProviders=new Set;constructor(e){this.paths=e.paths,this.config=e.config,this.registry=e.registry,this.factory=e.downstreamFactory??_x,this.createTimeoutMs=e.createTimeoutMs??vx,this.spawnAwaitInstallMs=e.spawnAwaitInstallMs??Sx}buildBinShimPathEnv(){let e=process.platform==="win32"?";":":";return{PATH:`${this.paths.binDir}${e}${process.env.PATH??""}`}}getOpenclawConfig(){if(!this.openclawConfigCache){let e=this.config.frameworksCache?.openclaw;if(!e?.path)throw new S("AGENT_SPAWN_FAILED","openclaw binary not detected on this machine");this.openclawConfigCache=new Wn({command:e.path})}return this.openclawConfigCache}async createAgent(e){if(!e.agentId)throw new S("IPC_BAD_REQUEST","agentId required");if(!e.framework)throw new S("IPC_BAD_REQUEST","framework required");let s=Yt(e._meta)==="cloud";this.registry.reviveIfDisconnected?.(e.agentId);let o=this.registry.get(e.agentId);if(o){if(o.framework!==e.framework)throw new S("AGENT_BUSY",`agent ${e.agentId} exists with different framework (${o.framework})`);if(o.status==="error")pe.warn("existing agent in error state, rebuilding",{agentId:e.agentId}),await o.dispose("rebuild after error").catch(A=>pe.warn("dispose stale agent failed (ignored)",{err:String(A)})),this.registry.unregister(e.agentId);else{if(e.patToken&&e.patToken!==o.patToken){pe.info("updating agent patToken on re-create (reconnect with new PAT)",{agentId:e.agentId}),o.setPatToken(e.patToken);let A=await he(e.agentId,this.paths).catch(()=>null);A&&(A.patToken=e.patToken,await Se(A,this.paths))}if(o.deployType==="cloud"&&e.modelInfo){pe.info("updating agent modelInfo on re-create",{agentId:e.agentId}),o.setModelInfo(e.modelInfo);let A=await he(e.agentId,this.paths).catch(()=>null);A&&(A.modelInfo=e.modelInfo,await Se(A,this.paths))}return pe.info("agent already exists, return current",{agentId:e.agentId}),{ok:!0,agentId:o.agentId,workspace:o.workspace,framework:o.framework}}}if(!s&&!this.config.frameworksCache?.[e.framework])throw new S("AGENT_SPAWN_FAILED",`framework ${e.framework} not detected on this machine; rerun daemon to refresh frameworks_cache`);let d=Je(e.agentId,this.paths),u=Yt(e._meta),f=e.framework==="openclaw"&&u==="local",h=f?this.config.frameworksCache?.openclaw?.defaultAgent?.workspace:void 0,p=e.workspace??h??d.workspace,w=new AbortController,b=setTimeout(()=>w.abort(new S("AGENT_TIMEOUT",`_agent/create timed out after ${this.createTimeoutMs}ms`)),this.createTimeoutMs),E,I=!1;try{s&&oi(e.framework)&&await It(e.framework,w.signal);let A=()=>{if(w.signal.aborted)throw w.signal.reason instanceof Error?w.signal.reason:new S("AGENT_TIMEOUT","_agent/create aborted")};await si(d.root,{recursive:!0}),await si(p,{recursive:!0}),await si(d.logs,{recursive:!0}),A(),f||await Pt(p,e.framework,e.agentId,e.cozeIdentity),e.framework==="claude-code"&&await Ns(p),A();let k=await he(e.agentId,this.paths).catch(()=>null),z=Gs({model:e.model??k?.model}),Y=Os(e._meta)??k?.accountId,j=e.patToken??k?.patToken,oe=u==="cloud"?e.modelInfo??k?.modelInfo:void 0;if(E=new jn({agentId:e.agentId,framework:e.framework,workspace:p,model:z.model??Le,deployType:u,...Y?{accountId:Y}:{},...j?{patToken:j}:{},...oe?{modelInfo:oe}:{}}),E.status="ok",k?.sessions){for(let[ke,xe]of Object.entries(k.sessions))E.sessions.set(ke,{acpSessionId:xe.acpSessionId,modelToken:xe.modelToken,tokenGeneratedAt:xe.tokenGeneratedAt,lastActiveAt:Date.now(),loadingSession:!1,replySeq:0});let _e=Object.keys(k.sessions).length;_e>0&&pe.info("restored persisted session records (no spawn)",{agentId:e.agentId,count:_e})}this.registry.register(E),I=!0;let W={agentId:e.agentId,framework:e.framework,workspace:p,cozeIdentity:e.cozeIdentity,createdAt:k?.createdAt??Date.now(),sessions:k?.sessions??{},model:z.model};u==="cloud"&&(W.deployType="cloud"),Y&&(W.accountId=Y),j&&(W.patToken=j),oe&&(W.modelInfo=oe),k?.skills&&(W.skills=k.skills),k?.agentName&&(W.agentName=k.agentName),k?.description&&(W.description=k.description),e.framework==="openclaw"&&u==="cloud"&&(this.config.frameworksCache?.openclaw?.path?await this.getOpenclawConfig().ensureAgent(e.agentId,p):pe.warn("openclaw binary not on this machine, skip agents add (will fail at session/prompt)",{agentId:e.agentId}));let le=e.initialSkills??[];if(le.length>0){let _e=[...W.skills??[]],ke=new Map(_e.map((T,O)=>[T.skillId,O])),xe=await Promise.allSettled(le.map(T=>ti({agentId:e.agentId,workspace:p,framework:e.framework,skill:T}))),we=0;for(let[T,O]of xe.entries()){let B=le[T];B&&(O.status==="fulfilled"?(ni(_e,ke,O.value),we++):pe.warn("initialSkill install failed (skipping)",{agentId:e.agentId,skillId:B.skillId,skillName:B.skillName,err:String(O.reason)}))}we>0&&(W.skills=_e,pe.info("initialSkills installed",{agentId:e.agentId,installed:we,requested:le.length}))}return await Se(W,this.paths),pe.info("agent created (no spawn, lazy on first prompt)",{agentId:e.agentId,framework:e.framework,deployType:u}),{ok:!0,agentId:e.agentId,workspace:p,framework:e.framework}}catch(A){throw pe.error("agent create failed, rolling back",{agentId:e.agentId,err:String(A)}),I&&E&&(await E.dispose("rollback").catch(()=>{}),this.registry.unregister(e.agentId)),await mx(d.root,{recursive:!0,force:!0}).catch(k=>pe.warn("rm agent dir failed (ignored)",{err:String(k)})),A instanceof S?A:new S("AGENT_SPAWN_FAILED",String(A),{cause:A})}finally{clearTimeout(b)}}async spawnSessionDownstream(e,s,o,c){let u=this.config.frameworksCache?.[e.framework];if(!u)if(e.deployType==="cloud"&&oi(e.framework))u=yx;else throw new S("AGENT_SPAWN_FAILED",`framework ${e.framework} not detected on this machine`);if(oi(e.framework)&&!At(e.framework)){let p=vs(e.framework);p&&(pe.info("spawn: awaiting in-flight acp install (D92)",{agentId:e.agentId,framework:e.framework}),await Promise.race([p.catch(()=>{}),new Promise(w=>setTimeout(w,this.spawnAwaitInstallMs))]))}let f=e.deployType==="cloud"?{model:e.model,modelToken:s,...e.modelInfo?{modelInfo:e.modelInfo}:{}}:void 0,h;e.framework==="openclaw"?h=await this.buildOpenclawDownstream({session:e,modelConfig:f,cloudSessionId:o,cozeEnv:c,command:u.path}):h=this.factory(e.framework,u.path,e.workspace,e.agentId,f,o,c,this.buildBinShimPathEnv());try{return await h.start(),await h.initialize(bx),h}catch(p){let w=h instanceof ze?h.getStderrTail():[];w.length>0&&pe.warn("spawnSessionDownstream failed, recent stderr (D94)",{agentId:e.agentId,framework:e.framework,method:p instanceof S?p.code:"unknown",recentStderr:w});let b=ri(w);await h.stop("spawnSessionDownstream failed").catch(()=>{});let E=b?new S("NPX_CACHE_CORRUPT","~/.npm/_npx \u76EE\u5F55\u635F\u574F (ENOTEMPTY)\u3002\u5EFA\u8BAE: rm -rf ~/.npm/_npx && npm i -g @zed-industries/codex-acp (\u6216\u5BF9\u5E94 @agentclientprotocol/claude-agent-acp)",{cause:p}):p;throw p instanceof S?new S(p.code,p.message,{retriable:p.retriable,cause:E}):new S("AGENT_SPAWN_FAILED",p instanceof Error?p.message:String(p),{cause:E})}}async buildOpenclawDownstream(e){let{session:s,modelConfig:o,cloudSessionId:c,cozeEnv:d,command:u}=e,f=ii(c);if(s.deployType==="local"){let b=this.config.frameworksCache?.openclaw?.defaultAgent;if(!b?.id||!b.workspace)throw new S("AGENT_SPAWN_FAILED","openclaw default agent \u672A\u63A2\u6D4B\u5230; \u8BF7\u5148\u8DD1 `openclaw setup` \u6216 `openclaw agents add` \u521B\u5EFA\u9ED8\u8BA4 agent");return new Nt({command:u,cwd:b.workspace,agentId:b.id,sessionName:f})}let h=await po(),p=o?$s(o,d):null,w;if(p){let b=Zr(c),I=p.models[0]?.id??Le,A=`${b}/${I}`;if(!this.ensuredProviders.has(A)){let k=this.getOpenclawConfig();await k.ensureProvider(b,p),await k.addModelToAllowlist(A),this.ensuredProviders.add(A)}w=A}return new Nt({command:u,cwd:s.workspace,agentId:s.agentId,sessionName:f,...h?{gatewayToken:h}:{},...w?{slashModelOnStart:w}:{}})}async openclawRepair(e,s){let o=this.getOpenclawConfig();await o.deleteAgent(e),await o.ensureAgent(e,s)}async cleanupOpenclawSessionProviders(e){if(e.framework!=="openclaw"||!this.openclawConfigCache)return;let s=this.openclawConfigCache;for(let o of e.sessions.keys()){let c=Zr(o),d=`${c}/${e.model}`,u=!0;try{await s.removeProvider(c)}catch(f){u=!1,pe.warn("removeProvider failed, keeping ensuredProviders entry",{providerId:c,err:String(f)})}try{await s.removeModelFromAllowlist(d)}catch(f){u=!1,pe.warn("removeModelFromAllowlist failed, keeping ensuredProviders entry",{fullModelId:d,err:String(f)})}u&&this.ensuredProviders.delete(d)}}};import{randomUUID as Ox}from"node:crypto";import{promises as Lx}from"node:fs";import{basename as Mx}from"node:path";import{promises as Ix}from"node:fs";import{basename as Ax}from"node:path";q();var mo=N("file-upload"),Tx="/api/coze_claw/file/agent_upload",Px=6e4;async function wo(n,e={}){let o=`${On(Mn(e.handshakeBase))}${Tx}`,c=e.timeoutMs??Px,d=await Ix.readFile(n.path),u=new FormData;u.append("agent_id",n.agentId),u.append("session_id",n.sessionId),u.append("file_name",n.name),u.append("file_content",new Blob([d],{type:n.mimeType}),n.name);let f={Authorization:`Bearer ${n.patToken}`,Accept:"application/json","x-coze-version":"3.0",...kt(e.ppeOverride),...n.accountId?{"x-coze-account":n.accountId}:{}},h=new AbortController,p=setTimeout(()=>h.abort(),c);mo.info("file upload start",{url:o,agentId:n.agentId,sessionId:n.sessionId,name:n.name,bytes:n.sizeBytes,mime:n.mimeType});try{let w=await fetch(o,{method:"POST",headers:f,body:u,signal:h.signal}),b=w.headers.get("x-tt-logid")??"";if(!w.ok){let A=await w.text().catch(()=>"");throw new S("UPLOAD_FAILED",`upload HTTP ${w.status} logid=${b}: ${A.slice(0,200)}`)}let E=await w.json();if(E.code!==void 0&&E.code!==0)throw new S("UPLOAD_FAILED",`upload code=${E.code} msg=${E.msg??"-"} logid=${b}`);let I=E.data?.file?.file_url;if(!I)throw new S("UPLOAD_FAILED",`upload response missing data.file.file_url logid=${b}: ${JSON.stringify(E).slice(0,200)}`);return mo.info("file upload ok",{uri:I,logid:b}),{uri:I}}catch(w){throw w instanceof S?w:w.name==="AbortError"?new S("UPLOAD_FAILED",`upload timeout (${c}ms) for ${Ax(n.path)}`):new S("UPLOAD_FAILED",String(w),{cause:w})}finally{clearTimeout(p)}}q();import{promises as Cx}from"node:fs";import{extname as kx}from"node:path";var Dx=[{mime:"image/png",prefix:[137,80,78,71]},{mime:"image/jpeg",prefix:[255,216,255]},{mime:"image/gif",prefix:[71,73,70,56]},{mime:"application/pdf",prefix:[37,80,68,70]}];function Rx(n){return n[0]===82&&n[1]===73&&n[2]===70&&n[3]===70&&n[8]===87&&n[9]===69&&n[10]===66&&n[11]===80}var Nx={".txt":"text/plain",".md":"text/markdown",".svg":"image/svg+xml",".json":"application/json"};async function _o(n){let e=await Cx.open(n,"r");try{let s=Buffer.alloc(16);if(await e.read(s,0,16,0),Rx(s))return"image/webp";for(let o of Dx)if(o.prefix.every((c,d)=>s[d]===c))return o.mime}finally{await e.close()}return Nx[kx(n).toLowerCase()]??"application/octet-stream"}ie();var yo=N("agent-send"),bo=50*1024*1024,Bx=new Set(["image/png","image/jpeg","image/webp","image/gif","image/svg+xml","application/pdf","application/json","text/plain","text/markdown"]);async function vo(n,e){let s=e.core.get(n.agentId);if(!s)throw new S("AGENT_NOT_FOUND",`agent=${n.agentId}`);if(e.core.disconnectedAgents.has(n.agentId))throw new S("AGENT_DISCONNECTED",`agent=${n.agentId} was disconnected by cloud`);let o=s.sessions.get(n.sessionId);if(!o)throw new S("AGENT_NOT_FOUND",`session=${n.sessionId} not active in agent=${n.agentId}`);if(!await Cs(n.path,s.workspace))throw new S("PATH_OUTSIDE_WORKSPACE",`path=${n.path} not under workspace=${s.workspace}`);let c=await Lx.stat(n.path).catch(()=>null);if(!c||!c.isFile())throw new S("IPC_BAD_REQUEST",`path is not a regular file: ${n.path}`);if(c.size>bo)throw new S("FILE_TOO_LARGE",`${c.size} bytes > limit ${bo}`);let d=await _o(n.path);if(!Bx.has(d))throw new S("UNSUPPORTED_MIME",`mime=${d} not in whitelist`);if(n.kind==="image"&&!d.startsWith("image/"))throw new S("UNSUPPORTED_MIME",`kind=image but mime=${d}`);if(!e.core.upstream.isConnected())throw new S("UPSTREAM_NOT_READY","cloud WS not connected");let u=n.name??Mx(n.path),f=await wo({patToken:s.patToken??e.patToken,agentId:n.agentId,sessionId:n.sessionId,path:n.path,mimeType:d,name:u,sizeBytes:c.size,...s.accountId?{accountId:s.accountId}:{}},{handshakeBase:e.handshakeBase,ppeOverride:e.ppeOverride}),h={sessionUpdate:"agent_file",messageId:Ox(),content:{type:n.kind==="image"?"image":"resource",uri:f.uri,mimeType:d,name:u,sizeBytes:c.size,...f.fileId!==void 0?{fileId:f.fileId}:{},...n.caption!==void 0?{caption:n.caption}:{}}},p=2,w;for(let b=0;b<=p;b++)try{await e.core.sendAgentFileUpdate(s,o,n.sessionId,h),w=void 0;break}catch(E){w=E,b<p&&(yo.warn("sendAgentFileUpdate failed, retrying",{attempt:b+1,err:String(E)}),await new Promise(I=>setTimeout(I,5e3)))}if(w)throw new S("UPSTREAM_NOT_READY",`agent file uploaded to cloud but sendAgentFileUpdate failed after ${p+1} attempts: ${String(w)}`,{cause:w});return yo.info("agent file sent",{agentId:n.agentId,sessionId:n.sessionId,kind:n.kind,name:u,bytes:c.size,mime:d,uri:f.uri}),{ok:!0,uri:f.uri,bytes:c.size,mimeType:d,...f.fileId!==void 0?{fileId:f.fileId}:{}}}import{execFile as zx}from"node:child_process";import{promisify as Fx}from"node:util";function $n(n,e){let s=n.split(".").map(Number),o=e.split(".").map(Number),c=Math.max(s.length,o.length);for(let d=0;d<c;d++){let u=s[d]??0,f=o[d]??0;if(u<f)return!0;if(u>f)return!1}return!1}q();var Ux=Fx(zx),Fe=N("coze-cli-installer"),So="@coze/cli@latest",qx="coze",Eo="0.1.7",Gx=5e3,Hx=5e3,jx=9e4,Io=1e4,on=null,Vn=!1;async function ai(n,e={}){if(Vn)return;if(on)return on;let s=e.exec??Ux;return on=(async()=>{try{let o=await Kx(qx,s),c=!1;if(o){let u=await Wx(s);if(u===void 0)Fe.warn("coze-cli found but version unparseable, fall through to full install",{path:o});else if($n(u,Eo))Fe.info("coze-cli version too old, upgrade-only (preserve user config + auth)",{path:o,version:u,min:Eo}),c=!0;else{Fe.info("coze-cli already on PATH with sufficient version, skip",{path:o,version:u}),Vn=!0;return}}let d=c?"upgrade-only":"full";Fe.info("coze-cli install start",{package:So,mode:d});try{await s("npm",["i","-g","--prefer-online",So],{timeout:jx,maxBuffer:10*1024*1024}),Fe.info("coze-cli install ok")}catch(u){Fe.warn("coze-cli install failed (skip subsequent steps)",{err:String(u)});return}if(c){Vn=!0;return}if(n.env)try{await s("coze",["config","set","xTTEnv",n.env],{timeout:Io}),Fe.info("coze config set xTTEnv ok",{env:n.env})}catch(u){Fe.warn("coze config set failed (continue to auth login)",{err:String(u)})}try{await s("coze",["auth","login","--token",n.patToken],{timeout:Io}),Fe.info("coze auth login ok")}catch(u){Fe.warn("coze auth login failed",{err:String(u)});return}Vn=!0}finally{on=null}})(),on}async function Kx(n,e){let s=process.platform==="win32"?"where":"which";try{let{stdout:o}=await e(s,[n],{timeout:Gx});return o.split(`
120
- `)[0]?.trim()||void 0}catch{return}}async function Wx(n){try{let{stdout:e,stderr:s}=await n("coze",["--version"],{timeout:Hx});return(e||s).match(/(\d+\.\d+\.\d+)/)?.[1]}catch{return}}q();import{spawn as Jx}from"node:child_process";import{constants as Ao,access as $x}from"node:fs/promises";import{delimiter as Vx,join as Yx}from"node:path";var To=N("framework-detector"),Po={"claude-code":"claude",codex:"codex",openclaw:"openclaw"},Xx=[".exe",".cmd",".bat",".ps1"],Lt=class{env;constructor(e={}){this.env={pathEnv:e.pathEnv??process.env.PATH??"",platform:e.platform??process.platform,spawn:e.spawn??Jx,access:e.access??$x}}async detect(e){let s=Po[e],o=await this.which(s);if(!o)return To.debug("framework binary not found",{framework:e,bin:s}),null;let c=e==="openclaw"?["--log-level","silent"]:[],[d,u]=await Promise.all([this.probeVersion(o,c),e==="openclaw"?this.probeOpenclawDefaultAgent(o):Promise.resolve(null)]),f={path:o,version:d};return u&&(f.defaultAgent=u),f}async detectAll(){let e=await Promise.all(Object.keys(Po).map(async o=>[o,await this.detect(o)])),s={};for(let[o,c]of e)c&&(s[o]=c);return s}async which(e){let s=this.env.pathEnv.split(Vx).filter(Boolean),o=this.env.platform==="win32"?["",...Xx]:[""];for(let c of s)for(let d of o){let u=Yx(c,e+d);if(await this.isExecutable(u))return u}return null}async isExecutable(e){try{let s=this.env.platform==="win32"?Ao.F_OK:Ao.X_OK;return await this.env.access(e,s),!0}catch{return!1}}async probeOpenclawDefaultAgent(e){let s=await this.runProbe(e,["--log-level","silent","agents","list","--json"]);if(!s||s.code!==0)return null;let o=s.stdout.match(/\[\s*\{[\s\S]*\}\s*\]/);if(!o)return null;try{let c=JSON.parse(o[0]);if(!Array.isArray(c))return null;let d=c.find(u=>u?.isDefault===!0);return!d?.id||!d.workspace?null:{id:d.id,workspace:d.workspace}}catch(c){return To.warn("openclaw agents list --json parse failed",{err:String(c)}),null}}async probeVersion(e,s=[]){let o=await this.runProbe(e,[...s,"--version"]);return o&&(Zx(o.stdout).split(/\r?\n/)[0]??"").trim()||"unknown"}runProbe(e,s){return new Promise(o=>{let c="",d=!1,u,f=h=>{d||(d=!0,u&&clearTimeout(u),o(h))};try{let h=this.env.spawn(e,s,{stdio:["ignore","pipe","pipe"]});u=setTimeout(()=>{h.kill("SIGKILL"),f(null)},5e3),h.stdout?.on("data",p=>{c+=p.toString("utf8")}),h.on("error",()=>f(null)),h.on("close",p=>f({code:p,stdout:c}))}catch{f(null)}})}},Qx=new RegExp("\x1B\\[[0-9;]*[A-Za-z]","g");function Zx(n){return n.replace(Qx,"")}Mt();import{randomBytes as wu}from"node:crypto";import{createReadStream as tu}from"node:fs";import{mkdir as nu,readFile as ru,realpath as iu,stat as su,writeFile as ou}from"node:fs/promises";import{basename as au,dirname as ci,join as cu,relative as du,resolve as ko,sep as xu}from"node:path";import{createInterface as uu}from"node:readline";q();var Ro=N("fs-rpc"),an=at("COZE_BRIDGE_FS_RPC_MAX_BYTES",20*1024*1024);async function No(n,e){let s=Buffer.byteLength(n.content,"utf8");if(s>an)throw new S("IPC_BAD_REQUEST",`fs/write_text_file content too large: ${s} bytes > limit ${an} bytes`);let o=await Lo(n.path,e);return await nu(ci(o),{recursive:!0}),await ou(o,n.content,"utf8"),Ro.info("fs/write_text_file ok",{path:o,size:n.content.length}),null}async function Oo(n,e){let s=await Lo(n.path,e),o=await su(s),c=typeof n.line=="number"||typeof n.limit=="number";if(o.size>an&&!c)throw new S("IPC_BAD_REQUEST",`fs/read_text_file too large without line/limit slicing: ${o.size} bytes > ${an} bytes`);let d;if(c&&o.size>an)d=await fu(s,n.line??1,n.limit);else{let u=await ru(s,"utf8");if(c){let f=u.split(`
121
- `),h=Math.max(0,(n.line??1)-1),p=typeof n.limit=="number"?h+n.limit:void 0;d=f.slice(h,p).join(`
122
- `)}else d=u}return Ro.info("fs/read_text_file ok",{path:s,size:d.length}),{content:d}}async function fu(n,e,s){let o=uu({input:tu(n,{encoding:"utf8"}),crlfDelay:Number.POSITIVE_INFINITY}),c=Math.max(0,e-1),d=typeof s=="number"?c+s:Number.POSITIVE_INFINITY,u=[],f=0;try{for await(let h of o)if(f>=c&&f<d&&u.push(h),f++,f>=d)break}finally{o.close()}return u.join(`
123
- `)}async function Lo(n,e){if(typeof n!="string"||n.length===0)throw new S("IPC_BAD_REQUEST","path must be a non-empty string");let[s,o]=await Promise.all([Do(ko(e)),Do(ko(n))]),c=du(s,o);if(c.startsWith("..")||c===".."||c.startsWith(`..${xu}`))throw new S("IPC_BAD_REQUEST",`path escapes workspace: ${n}`);return o}async function Do(n){let e=[],s=n;for(;s!==ci(s);)try{let o=await iu(s);return e.length?cu(o,...e.reverse()):o}catch{e.push(au(s)),s=ci(s)}return n}q();var Mo=N("prompt-multimodal"),Bo=10*1024*1024,lu=15e3,gu=6;async function zo(n){let e=new Array(n.length),s=0;async function o(){for(;s<n.length;){let d=s++,u=n[d];u!==void 0&&(e[d]=await hu(u))}}let c=Array.from({length:Math.min(gu,n.length)},()=>o());return await Promise.all(c),e}function Fo(n){return n.some(e=>e.type==="image")}async function hu(n){if(n.type!=="image")return n;let e=n;if(e.data||!e.uri||!Nn(e.uri))return n;try{let{buf:s,contentType:o}=await mu(e.uri),c=e.mimeType||pu(o)||"application/octet-stream";return Mo.info("image uri fetched and inlined",{uri:e.uri,bytes:s.length,mimeType:c}),{type:"image",data:s.toString("base64"),mimeType:c}}catch(s){return Mo.warn("image fetch failed, degrading to text block",{uri:e.uri,err:String(s)}),{type:"text",text:`[image load failed: ${e.uri}]`}}}function pu(n){if(!n)return;let e=n.indexOf(";");return(e===-1?n:n.slice(0,e)).trim()||void 0}async function mu(n){let e=new AbortController,s=setTimeout(()=>e.abort(),lu);try{let o=await fetch(n,{signal:e.signal});if(!o.ok)throw new Error(`HTTP ${o.status} ${o.statusText}`);let c=await o.arrayBuffer();if(c.byteLength>Bo)throw new Error(`image too large: ${c.byteLength} bytes (max ${Bo})`);return{buf:Buffer.from(c),contentType:o.headers.get("content-type")??void 0}}finally{clearTimeout(s)}}it();Mt();q();var M=N("core"),_u=3e4,yu=/^(boe|ppe)_[A-Za-z0-9_-]+$/,bu=3e4,vu=new Set(["_agent/create","session/new","session/load","session/prompt"]),Yn=class{upstream;agents=new Map;disconnectedAgents=new Set;extensions;paths;sessionSpawner;sessionIdleTimeoutMs;upgradeGate;upstreamIds=new Rt;pendingUpstream=new Map;pendingBridge=new Map;currentCozeEnv;constructor(e){this.upstream=e.upstream,this.extensions=e.extensions??{},this.paths=e.paths,this.sessionSpawner=e.sessionSpawner,this.sessionIdleTimeoutMs=Co(e.bridgeConfig),this.upgradeGate=e.upgradeGate}registerExtension(e,s){this.extensions[e]=s}getCozeEnv(){return this.currentCozeEnv}async start(){this.upstream.onFrame(e=>this.handleFrame(e)),this.upstream.onConnect?.(({initial:e})=>{e||this.rejectAllPendingOnReconnect()}),await this.upstream.start(),M.info("Core started",{extensions:Object.keys(this.extensions)})}async stop(e){M.info("Core stopping",{reason:e}),await Promise.all([...this.agents.values()].map(s=>s.dispose(e))),this.agents.clear(),await this.upstream.stop(e)}get(e){return this.agents.get(e)}register(e){this.agents.set(e.agentId,e),M.info("agent registered",{agentId:e.agentId,framework:e.framework});for(let s of this.registerHandlers)try{s(e.agentId)}catch(o){M.warn("onAgentRegister handler threw (ignored)",{agentId:e.agentId,err:String(o)})}}onAgentRegister(e){return this.registerHandlers.add(e),()=>this.registerHandlers.delete(e)}registerHandlers=new Set;unregister(e){this.agents.delete(e)}reviveIfDisconnected(e){this.disconnectedAgents.delete(e)&&M.info("agent revived from disconnect",{agentId:e})}attachRuntimeHooks(e,s,o){let c=o.downstream;c&&(c.onUpdate(d=>{o.loadingSession||this.forwardUpdate(e,d)}),c.onAgentRequest(d=>{this.handleAgentRequest(e,c,d)}),c.onExit((d,u)=>{M.info("session runtime exited",{agentId:e.agentId,cloudId:s,code:d,signal:u}),sn(o),o.downstream=void 0,o.replySeq=0,o.acpSessionId&&e.activeTriggers.delete(o.acpSessionId),this.rejectPendingForDownstream(c,"downstream exited")}))}hasPendingPermissionFor(e){for(let s of this.pendingUpstream.values())if(s.downstream===e)return!0;return!1}rejectPendingForDownstream(e,s){let o=[];for(let[c,d]of this.pendingUpstream)d.downstream===e&&o.push(c);if(o.length!==0){M.info("reject pendingUpstream entries (downstream gone)",{reason:s,count:o.length});for(let c of o){let d=this.pendingUpstream.get(c);if(d){this.pendingUpstream.delete(c),this.upstream.send(ot(c,{code:H.INTERNAL_ERROR,message:`bridge downstream gone: ${s}`})).catch(u=>M.debug("send error response to upstream failed (ignored)",{err:String(u)}));try{d.downstream.respondAgentRequestError(d.agentRequestId,{code:H.INTERNAL_ERROR,message:`bridge: ${s}`})}catch{}}}}}rejectAllPendingOnReconnect(){let e=this.pendingUpstream.size,s=this.pendingBridge.size;if(!(e===0&&s===0)){M.warn("upstream reconnected, rejecting stale pending requests",{pendingUpstream:e,pendingBridge:s});for(let[,o]of this.pendingUpstream)try{o.downstream.respondAgentRequestError(o.agentRequestId,{code:H.INTERNAL_ERROR,message:"upstream reconnected; please retry"})}catch{}this.pendingUpstream.clear();for(let[,o]of this.pendingBridge)clearTimeout(o.timer),o.reject(new S("UPSTREAM_DISCONNECTED",`${o.method} aborted: upstream reconnected`));this.pendingBridge.clear()}}async handleFrame(e){if(Un(e)){this.handleUpstreamResponse(e);return}if(!("method"in e)||typeof e.method!="string")return;let s="id"in e&&e.id!==void 0?e.id:null,o=e.params?._meta?.cozeEnv;o&&yu.test(o)?this.currentCozeEnv=o:o&&M.warn("rejecting cozeEnv with invalid shape, keeping previous",{rejected:o});try{if(this.upgradeGate?.isUpgrading()&&vu.has(e.method)){let c=this.upgradeGate.pendingTarget()??"";throw new S("BRIDGE_UPGRADING",`bridge upgrading to ${c}, retry shortly`,{retriable:!0})}if(e.method.startsWith("_agent/")){let c=this.extensions[e.method];if(!c){s!==null?await this.sendError(s,H.METHOD_NOT_FOUND,`extension not registered: ${e.method}`):M.warn("drop notification: extension not registered",{method:e.method});return}let d=await c(e,this);s!==null&&await this.upstream.send(Dt(s,d));return}if(e.method.startsWith("session/")){let c=await this.routeSessionMethod(e);s!==null&&await this.upstream.send(Dt(s,c));return}if(e.method==="initialize"){s!==null&&await this.upstream.send(Dt(s,{protocolVersion:1,agentCapabilities:{loadSession:!0}}));return}s!==null?await this.sendError(s,H.METHOD_NOT_FOUND,`method not implemented: ${e.method}`):M.warn("drop unknown notification",{method:e.method})}catch(c){M.error("handleFrame failed",{method:e.method,err:String(c)}),s!==null&&await this.upstream.send(ot(s,rn(c)))}}async routeSessionMethod(e){if(!e.params||typeof e.params!="object")throw new S("IPC_BAD_REQUEST",`${e.method} requires params`);let s=e.params,o=s._meta?.cozeAgentId;if(!o)throw new S("IPC_BAD_REQUEST",`${e.method}: missing _meta.cozeAgentId`);let c=this.agents.get(o);if(!c)throw this.disconnectedAgents.has(o)?new S("AGENT_DISCONNECTED",`agent ${o} has been disconnected; cloud must _agent/create to revive`):new S("AGENT_NOT_FOUND",`agent not found: ${o}`);let d=typeof s.sessionId=="string"?s.sessionId:void 0;if(e.method==="session/cancel"||e.method==="session/new"||!d)return this.dispatchSessionCall(c,e.method,s);let u=Date.now(),f=!1,h=e.method==="session/prompt";h&&this.upgradeGate?.incActive();try{let p=await c.getSessionQueue(d).enqueue(()=>this.dispatchSessionCall(c,e.method,s));return f=!0,p}finally{h&&this.upgradeGate?.decActive(),M.info("session call done",{agentId:c.agentId,method:e.method,durationMs:Date.now()-u,ok:f})}}async dispatchSessionCall(e,s,o){e.lastActiveAt=Date.now();let{stripped:c}=Ls(o);switch(s){case"session/new":{let d=Su();return M.info("session/new ack (lazy spawn)",{agentId:e.agentId,cloudId:d}),{sessionId:d}}case"session/load":{let d=c;return M.info("session/load ack (lazy spawn)",{agentId:e.agentId,cloudId:d.sessionId}),{}}case"session/prompt":{let d=c,u=d.sessionId;if(!u)throw new S("IPC_BAD_REQUEST","session/prompt: missing sessionId");let f=await this.ensureRuntime(e,u);if(f.replySeq=0,await this.ensureDownstream(e,u,f),!f.downstream||!f.acpSessionId)throw new S("BRIDGE_INTERNAL","session runtime not ready after ensureDownstream");let h=o._meta?.cozeTriggerMsgId;if(h?e.activeTriggers.set(f.acpSessionId,h):e.activeTriggers.delete(f.acpSessionId),e.deployType==="cloud"&&e.modelInfo?.capabilities?.image===!1&&Fo(d.prompt))throw new S("MODEL_MODALITY_UNSUPPORTED",`model=${e.modelInfo.id??e.model} does not support image input`);let p=await zo(d.prompt);try{let w=await f.downstream.sessionPrompt({...d,sessionId:f.acpSessionId,prompt:p});return f.lastActiveAt=Date.now(),w}finally{if(e.activeTriggers.delete(f.acpSessionId),f.reloadAfterTurn){f.reloadAfterTurn=!1;let w=f.downstream;w&&(f.downstream=void 0,M.info("reloadAfterTurn: stopping downstream",{agentId:e.agentId,cloudId:u,acpId:f.acpSessionId}),w.stop("reload-after-turn").catch(b=>M.warn("reload-after-turn stop failed (ignored)",{agentId:e.agentId,cloudId:u,err:String(b)})))}else f.downstream?.isAlive()&&this.armIdleTimer(e,u,f)}}case"session/cancel":{let u=c.sessionId;if(!u)throw new S("IPC_BAD_REQUEST","session/cancel: missing sessionId");let f=e.sessions.get(u);if(e.hasSessionQueue(u)){let h=e.getSessionQueue(u);h.size>0&&(M.info("session/cancel: draining queued tasks",{agentId:e.agentId,cloudId:u,queuedCount:h.size}),h.dispose(new S("AGENT_PROTOCOL_ERROR",`cancelled by session/cancel on ${u}`)))}return f?.downstream?.isAlive()&&f.acpSessionId&&await f.downstream.sessionCancel({sessionId:f.acpSessionId}),{ok:!0}}default:throw new S("IPC_BAD_REQUEST",`session method not supported: ${s}`)}}async ensureRuntime(e,s){let o=e.sessions.get(s);if(o)return o;let d={modelToken:e.deployType==="cloud"?await this.requestSessionToken(e.agentId,s):"",tokenGeneratedAt:Date.now(),lastActiveAt:Date.now(),loadingSession:!1,replySeq:0};return e.sessions.set(s,d),await this.persistSessionMapping(e),d}async requestSessionToken(e,s){let o={sessionId:s,_meta:{cozeAgentId:e}};try{let c=await this.sendRequest(Oe.GEN_MODEL_TOKEN,o,bu);if(!c?.modelToken)throw new S("MODEL_TOKEN_GEN_FAILED",`cloud returned empty modelToken (agentId=${e}, cloudSessionId=${s})`);return c.modelToken}catch(c){throw c instanceof S&&c.code==="MODEL_TOKEN_GEN_FAILED"?c:new S("MODEL_TOKEN_GEN_FAILED",c instanceof Error?c.message:String(c),{cause:c})}}async ensureDownstream(e,s,o){if(sn(o),o.downstream?.isAlive())return;if(!this.sessionSpawner)throw new S("AGENT_SPAWN_FAILED","sessionSpawner not wired (cannot spawn per-session downstream)");let c=3,d=3e4,u=o.spawnFailCount??0,f=o.spawnFailedAt??0;if(u>=c&&Date.now()-f<d)throw new S("AGENT_SPAWN_FAILED",`agent ${e.agentId} session ${s} spawn failed ${u} times in a row; please check framework binary / network and retry after ${Math.ceil((d-(Date.now()-f))/1e3)}s`);let h;try{h=await this.sessionSpawner(e,o.modelToken,s,this.currentCozeEnv)}catch(p){throw o.spawnFailCount=u+1,o.spawnFailedAt=Date.now(),o.spawnFailCount>=c&&o.acpSessionId&&(M.warn("clearing stale acpSessionId after repeated spawn failures",{agentId:e.agentId,cloudId:s,staleAcpId:o.acpSessionId}),o.acpSessionId=void 0),p}if(o.spawnFailCount=0,o.spawnFailedAt=void 0,o.downstream=h,this.attachRuntimeHooks(e,s,o),o.acpSessionId){o.loadingSession=!0;try{await h.sessionLoad({sessionId:o.acpSessionId,cwd:e.workspace}),M.info("session restored via session/load",{agentId:e.agentId,cloudId:s,acpId:o.acpSessionId})}catch(p){M.warn("session/load failed, fallback to session/new",{agentId:e.agentId,cloudId:s,acpId:o.acpSessionId,err:String(p)}),o.acpSessionId=void 0;let w=await h.sessionNew({cwd:e.workspace});o.acpSessionId=w.sessionId,await this.persistSessionMapping(e)}finally{o.loadingSession=!1}}else{let p=await h.sessionNew({cwd:e.workspace});o.acpSessionId=p.sessionId,await this.persistSessionMapping(e)}h.afterSessionEstablished&&o.acpSessionId&&await h.afterSessionEstablished(o.acpSessionId)}armIdleTimer(e,s,o){if(sn(o),this.isRuntimeBusy(e,o)){M.debug("skip idle timer: runtime busy (in-flight turn / pending permission)",{agentId:e.agentId,cloudId:s});return}o.idleTimer=setTimeout(()=>{if(o.idleTimer=void 0,this.isRuntimeBusy(e,o)){M.info("idle reaper fired but runtime busy, re-arming",{agentId:e.agentId,cloudId:s}),this.armIdleTimer(e,s,o);return}M.info("session runtime idle timeout, killing downstream",{agentId:e.agentId,cloudId:s});let c=o.downstream;o.downstream=void 0,o.acpSessionId&&e.activeTriggers.delete(o.acpSessionId),c&&c.stop("idle timeout").catch(d=>M.warn("idle stop failed (ignored)",{agentId:e.agentId,cloudId:s,err:String(d)}))},this.sessionIdleTimeoutMs),o.idleTimer.unref?.()}isRuntimeBusy(e,s){if(s.acpSessionId&&e.activeTriggers.has(s.acpSessionId))return!0;let o=s.downstream;if(!o)return!1;for(let c of this.pendingUpstream.values())if(c.downstream===o)return!0;return!1}async sendAgentFileUpdate(e,s,o,c){let d={cozeAgentId:e.agentId,cozeReplySeqID:++s.replySeq};if(s.acpSessionId){let u=e.activeTriggers.get(s.acpSessionId);u&&(d.cozeTriggerMsgId=u)}await this.upstream.send(tn("session/update",{sessionId:o,update:c,_meta:d}))}forwardUpdate(e,s){let o=s.sessionId,c=this.reverseSessionId(e,o);if(!c){M.debug("drop update for unknown session",{agentId:e.agentId,acpId:o});return}let d=e.sessions.get(c);if(!d){M.debug("drop update: runtime gone",{agentId:e.agentId,cloudId:c});return}if(Iu(s)){M.debug("drop codex metadata-warn chunk",{agentId:e.agentId,acpId:o});return}let u={cozeAgentId:e.agentId,cozeReplySeqID:++d.replySeq},f=e.activeTriggers.get(o);f&&(u.cozeTriggerMsgId=f),this.upstream.send(tn("session/update",{...s,sessionId:c,_meta:u})).catch(h=>M.warn("forward update failed",{agentId:e.agentId,err:String(h)}))}handleAgentRequest(e,s,o){if(o.method==="session/request_permission"){this.forwardPermissionRequest(e,s,o);return}if(o.method==="fs/write_text_file"||o.method==="fs/read_text_file"){this.handleFsRpcRequest(e,s,o);return}M.warn("unhandled agent request,returning method_not_found",{agentId:e.agentId,method:o.method}),s.respondAgentRequestError(o.id,{code:H.METHOD_NOT_FOUND,message:`method not handled by Bridge: ${o.method}`})}async handleFsRpcRequest(e,s,o){try{let c=e.workspace;if(o.method==="fs/write_text_file"){let d=o.params??{},u=await No(d,c);s.respondAgentRequest(o.id,u)}else{let d=o.params??{},u=await Oo(d,c);s.respondAgentRequest(o.id,u)}}catch(c){M.warn("fs rpc handler failed",{agentId:e.agentId,method:o.method,err:String(c)}),s.respondAgentRequestError(o.id,rn(c))}}forwardPermissionRequest(e,s,o){let c=this.upstreamIds.next("session/request_permission"),d=o.params??{},f=d.sessionId,h=f?e.activeTriggers.get(f):void 0,p={cozeAgentId:e.agentId};h&&(p.cozeTriggerMsgId=h);let w=f?this.reverseSessionId(e,f):void 0,b={...d,...w?{sessionId:w}:{},_meta:p};this.pendingUpstream.set(c,{agentRequestId:o.id,agentId:e.agentId,downstream:s,method:o.method}),M.info("forward permission_request \u2192 upstream",{agentId:e.agentId,upstreamId:c,acpSessionId:f,cloudSessionId:w,toolCallId:d.toolCall?.toolCallId,options:d.options?.map(E=>({optionId:E.optionId,kind:E.kind,name:E.name}))}),this.upstream.send(en(c,"session/request_permission",b)).catch(E=>{this.pendingUpstream.delete(c),M.error("forward permission request failed",{agentId:e.agentId,err:String(E)}),s.respondAgentRequestError(o.id,{code:H.INTERNAL_ERROR,message:`upstream send failed: ${String(E)}`})})}handleUpstreamResponse(e){if(e.id===null)return;let s=this.lookupPending(this.pendingUpstream,e.id,"upstream");if(s){this.pendingUpstream.delete(s.key);let c=s.value;e.error?(M.info("upstream \u2192 permission response (error)",{agentId:c.agentId,upstreamId:e.id,method:c.method,error:e.error}),c.downstream.respondAgentRequestError(c.agentRequestId,e.error)):(c.method==="session/request_permission"&&Eu(e.result,c),M.info("upstream \u2192 permission response (result)",{agentId:c.agentId,upstreamId:e.id,method:c.method,result:e.result}),c.downstream.respondAgentRequest(c.agentRequestId,e.result));return}let o=this.lookupPending(this.pendingBridge,e.id,"bridge");if(o){this.pendingBridge.delete(o.key),clearTimeout(o.value.timer),e.error?o.value.reject(new Fn(e.error)):o.value.resolve(e.result);return}M.debug("orphan upstream response (no pending)",{id:e.id})}lookupPending(e,s,o){let c=e.get(s);if(c)return{value:c,key:s};if(typeof s=="number"){let d=String(s),u=e.get(d);if(u)return M.warn(`${o} id type mismatch: number received but Bridge expected string`,{rawId:s,normalizedId:d}),{value:u,key:d}}}sendRequest(e,s,o=_u){let c=this.upstreamIds.next(e);return new Promise((d,u)=>{let f=setTimeout(()=>{this.pendingBridge.delete(c),u(new S("AGENT_TIMEOUT",`${e} timed out after ${o}ms`))},o);this.pendingBridge.set(c,{method:e,resolve:d,reject:u,timer:f}),this.upstream.send(en(c,e,s)).catch(h=>{let p=this.pendingBridge.get(c);p&&(clearTimeout(p.timer),this.pendingBridge.delete(c)),u(h)})})}async persistSessionMapping(e){if(this.paths)try{let s=new Map;for(let[o,c]of e.sessions){let d={modelToken:c.modelToken,tokenGeneratedAt:c.tokenGeneratedAt};c.acpSessionId&&(d.acpSessionId=c.acpSessionId),s.set(o,d)}await $r(e.agentId,s,this.paths)}catch(s){M.warn("persist session mapping failed",{agentId:e.agentId,err:String(s)})}}reverseSessionId(e,s){for(let[o,c]of e.sessions.entries())if(c.acpSessionId===s)return o}sendError(e,s,o){return this.upstream.send(ot(e,{code:s,message:o,data:{bridgeVersion:st}}))}};function Su(){return wu(16).toString("hex")}function Eu(n,e){if(!n||typeof n!="object"){M.warn("permission response: result not an object (suspicious)",{agentId:e.agentId,result:n});return}let s=n;if("kind"in s&&!("outcome"in s)){M.warn('permission response: top-level "kind" field (D66 historical bug shape)',{agentId:e.agentId,result:n});return}let o=s.outcome;if(!o||typeof o!="object"){M.warn("permission response: missing or non-object outcome field",{agentId:e.agentId,result:n});return}let d=o.outcome;(typeof d!="string"||d!=="selected"&&d!=="cancelled")&&M.warn("permission response: unknown outcome discriminant",{agentId:e.agentId,outcomeValue:d,result:n})}function Iu(n){let e=n.update;if(e?.sessionUpdate!=="agent_message_chunk")return!1;let s=e.content;if(!s||typeof s!="object")return!1;let o=s;return o.type!=="text"||typeof o.text!="string"?!1:o.text.startsWith("Model metadata for `")}q();ie();import{randomBytes as Au}from"node:crypto";import{chmod as Tu,mkdir as Pu,writeFile as Uo}from"node:fs/promises";import{createServer as Cu}from"node:http";import{dirname as ku}from"node:path";var Du=1e6,di=N("ipc"),Xn=class{server=null;port=0;token="";routes;paths;constructor(e){this.routes=new Map(e.routes.map(s=>[`${s.method} ${s.path}`,s])),this.paths=e.paths??G()}async start(){this.token=Au(32).toString("hex");let e=Cu((o,c)=>{this.dispatch(o,c)});this.server=e,await new Promise((o,c)=>{e.once("error",c),e.listen(0,"127.0.0.1",()=>o())});let s=e.address();if(!s||typeof s!="object")throw new Error("failed to obtain IPC port");return this.port=s.port,await this.persistAuthFiles(),di.info("IPC listening",{port:this.port}),{port:this.port,token:this.token}}async stop(){let e=this.server;e&&(await new Promise((s,o)=>{e.close(c=>c?o(c):s())}),this.server=null)}async persistAuthFiles(){await Pu(ku(this.paths.portFile),{recursive:!0}),await Uo(this.paths.portFile,String(this.port),"utf8"),await Uo(this.paths.tokenFile,this.token,{encoding:"utf8",mode:384});try{await Tu(this.paths.tokenFile,384)}catch(e){di.warn("chmod token file failed (non-POSIX?)",{err:String(e)})}}async dispatch(e,s){if(e.headers.authorization!==`Bearer ${this.token}`){cn(s,401,{error:"unauthorized"});return}let c=`${e.method} ${(e.url??"").split("?")[0]}`,d=this.routes.get(c);if(!d){cn(s,404,{error:"not found"});return}let u=null;if(e.method==="POST")try{u=await Ru(e)}catch(f){cn(s,400,{error:"invalid json",detail:String(f)});return}try{let f=await d.handler(u,e);cn(s,200,f??{ok:!0})}catch(f){di.error("IPC handler failed",{key:c,err:String(f)}),cn(s,500,{error:f instanceof Error?f.message:String(f)})}}};function cn(n,e,s){n.statusCode=e,n.setHeader("content-type","application/json"),n.end(JSON.stringify(s))}async function Ru(n){let e=[],s=0;for await(let c of n){let d=c;if(s+=d.length,s>Du)throw new Error("body too large");e.push(d)}let o=Buffer.concat(e).toString("utf8");return o?JSON.parse(o):null}import{sep as qo}from"node:path";import{fileURLToPath as Nu}from"node:url";function Go(){return Ou(Nu(import.meta.url))}function Ou(n){let e=`${qo}src${qo}`;return n.includes(e)}q();ie();import{spawn as Lu}from"node:child_process";import{existsSync as Mu,mkdirSync as Bu,openSync as zu}from"node:fs";import{dirname as Fu}from"node:path";import{fileURLToPath as Uu}from"node:url";var qu=N("spawn-helper");function Gu(n){return Mu(n.libEntry)?n.libEntry:Uu(new URL("../index.ts",import.meta.url))}function Hu(n,e,s){let o=n.endsWith(".ts"),c=["--upgrade-helper",`--target-version=${e}`,`--old-pid=${s}`];return o?["--import","tsx/esm",n,...c]:[n,...c]}async function Ho(n,e,s={}){let o=s.paths??G(),c=Gu(o);Bu(Fu(o.logFile),{recursive:!0});let d=zu(o.logFile,"a"),u=Hu(c,n,e),f=Lu(process.execPath,u,{detached:!0,stdio:["ignore",d,d],env:{...process.env,COZE_BRIDGE_UPGRADE_HELPER:"1"}});if(f.unref(),typeof f.pid!="number")throw new Error("failed to spawn upgrade helper (no pid)");qu.info("upgrade helper spawned",{pid:f.pid,targetVersion:n,oldPid:e,entry:c})}q();import{mkdir as ju,writeFile as Ku}from"node:fs/promises";import{dirname as Wu}from"node:path";import{gunzipSync as Ju}from"node:zlib";var xi=N("tarball-downloader"),$u="https://registry.npmjs.org",jo="package/dist/index.js";async function Ko(n,e,s={}){if(!/^[\w.\-+]+$/.test(n))throw new Error(`invalid version string: ${JSON.stringify(n)}`);let c=`${(s.registry??$u).replace(/\/+$/,"")}/coze-bridge/${n}`;xi.info("fetching tarball metadata",{metaUrl:c});let d=await fetch(c);if(!d.ok)throw new Error(`registry metadata ${c} returned ${d.status}`);let f=(await d.json())?.dist?.tarball;if(!f)throw new Error(`registry metadata missing dist.tarball for ${n}`);xi.info("downloading tarball",{tarballUrl:f});let h=await fetch(f);if(!h.ok)throw new Error(`tarball ${f} returned ${h.status}`);let p=Buffer.from(await h.arrayBuffer()),w=Ju(p),b=Vu(w,jo);if(!b)throw new Error(`tarball missing entry ${jo}`);await ju(Wu(e),{recursive:!0}),await Ku(e,b),xi.info("dist extracted",{destPath:e,bytes:b.length})}function Vu(n,e){let s=0;for(;s+512<=n.length;){let o=n.subarray(s,s+512);if(o.every(w=>w===0))return null;let c=o.subarray(0,100),d=c.indexOf(0),u=c.subarray(0,d===-1?100:d).toString("utf8"),f=o.subarray(124,136).toString("ascii").trim().replace(/\0/g,""),h=Number.parseInt(f,8)||0,p=s+512;if(u===e)return n.subarray(p,p+h);s=p+Math.ceil(h/512)*512}return null}Mt();q();import{resolve as Yu}from"node:path";var lt=N("upgrade-manager"),Xu=300*1e3,Qu=3,Qn=class{constructor(e){this.opts=e}opts;inFlightTarget=null;async requestUpgrade(e){if(this.inFlightTarget===e){lt.debug("upgrade already in-flight, skip",{targetVersion:e});return}this.inFlightTarget=e;try{let s=await ct(this.opts.paths.configFile)??{};if(s.disableAutoUpgrade){lt.info("disableAutoUpgrade=true, skip",{targetVersion:e});return}if(this.opts.isDevMode()){lt.warn("dev mode, skip auto-upgrade",{targetVersion:e});return}if(!$n(this.opts.currentVersion,e)){lt.debug("local version >= target, skip",{local:this.opts.currentVersion,target:e});return}let o=s.upgradeAttempts?.[e];if((o?.count??0)>=Qu){lt.warn("upgrade attempts cap reached, skip",{targetVersion:e,count:o?.count});return}let c=Yu(this.opts.paths.libDir,"index.js.next");try{await this.opts.download(e,c)}catch(u){await this.recordAttempt(s,e,String(u)),lt.warn("download failed, attempt recorded",{targetVersion:e,err:String(u)});return}this.opts.daemon.markUpgradePending(e);let d=await this.opts.daemon.waitIdle(Xu);lt.info("waitIdle done",{result:d}),await this.opts.spawnHelper(e,process.pid),this.opts.daemon.exit(0)}finally{this.inFlightTarget=null}}async recordAttempt(e,s,o){e.upgradeAttempts=e.upgradeAttempts??{};let c=e.upgradeAttempts[s];e.upgradeAttempts[s]={count:(c?.count??0)+1,lastAt:Date.now(),...o?{lastError:o}:{}},await Ue(e,this.opts.paths.configFile)}};var lc=We(na(),1);var Nl=We(Xa(),1),Ol=We(gr(),1),Ll=We(Ft(),1),Ml=We(Si(),1),Bl=We(Ai(),1),zl=We(Ri(),1),oc=We(wr(),1),Fl=We(sc(),1);var ac=oc.default;q();var fe=N("upstream.frontier"),dc="application/json",xc="none",ql=15e3,mn=class{constructor(e){this.opts=e}opts;fws=null;handler=null;connectHandlers=[];opened=!1;openCount=0;async start(){if(this.fws){fe.warn("start called on already-started FrontierUpstream; noop");return}let e={Authorization:`Bearer ${this.opts.privatecode}`,Origin:zs,...kt(this.opts.ppeOverride)};class s extends ac{constructor(A){super(A,Bs,{headers:e})}send(A,...k){if(_s("debug"))try{let z;typeof A=="string"?z=Buffer.from(A,"utf8"):A instanceof Buffer?z=A:A instanceof ArrayBuffer?z=new Uint8Array(A):ArrayBuffer.isView(A)?z=new Uint8Array(A.buffer,A.byteOffset,A.byteLength):z=new Uint8Array(0);let Y=Buffer.from(z.slice(0,128)).toString("hex");fe.debug("WS raw frame out",{bytes:z.byteLength,headHex:Y})}catch(z){fe.warn("WS raw frame dump failed",{err:String(z)})}super.send(A,...k)}}let o=Us(this.opts.urlOverride),c={url:o,ws:s,fpID:Ms,aID:Ln,accessKey:this.opts.handshake.accessKey,deviceID:this.opts.handshake.deviceId,payloadType:{type:dc,force:!0},payloadEncoding:{encoding:xc,force:!0},enableTransformTextPayload:!0,enableQoS:!1,enableAutoAck:!1,automaticOpen:!1,maxRetries:Number.POSITIVE_INFINITY,debug:this.opts.debug??!1},d=new lc.FWS(c),u=!1,f=null,h,p,w=new Promise((I,A)=>{h=I,p=A}),b=I=>{u||(u=!0,f&&(clearTimeout(f),f=null),I?p(I):h())};d.onopen=()=>{this.opened=!0,this.openCount+=1;let I=this.openCount===1;fe.info("frontier opened",{url:o,remoteDeviceId:this.opts.handshake.deviceId,initial:I,openCount:this.openCount}),I&&b();for(let A of this.connectHandlers)Promise.resolve(A({initial:I})).catch(k=>fe.warn("onConnect handler threw (ignored)",{err:String(k)}))},d.onclose=I=>{this.opened=!1,fe.info("frontier closed",{code:I.code,reason:I.reason,willReconnect:I.willReconnect})},d.onerror=I=>{fe.warn("frontier error",{code:I.code,msg:I.message}),b(new S("UPSTREAM_DISCONNECTED",`frontier connect error before open: code=${I.code} msg=${I.message??""}`))},d.onmessage=I=>this.handleMessage(I),this.fws=d;let E=this.opts.openTimeoutMs??ql;f=setTimeout(()=>{b(new S("UPSTREAM_DISCONNECTED",`frontier ws open timeout after ${E}ms (handshake or upgrade slow)`))},E),await d.connect();try{await w}catch(I){try{d.close(1e3,"open failed")}catch(A){fe.warn("fws close during start failure threw (ignored)",{err:String(A)})}throw this.fws=null,this.opened=!1,I}}async stop(e){let s=this.fws;if(s){this.fws=null,this.opened=!1;try{s.close(1e3,e??"bridge shutdown")}catch(o){fe.warn("frontier close threw (ignored)",{err:String(o)})}}}async send(e){let s=this.fws;if(!s)throw new S("UPSTREAM_DISCONNECTED","frontier upstream not started");if(!this.isConnected())throw new S("UPSTREAM_DISCONNECTED",`frontier ws not open (opened=${this.opened}, readyState=${s.readyState}); refusing to silently buffer`);this.injectAgentPatToken(e);let o=JSON.stringify(e),c=e;uc(c)||fe.info("frontier frame out",{method:c.method,jsonrpcId:c.id,size:o.length});try{await s.send(o,{service:33555712,method:1,payloadType:dc,payloadEncoding:xc})}catch(u){throw fe.warn("frontier frame send failed",{method:c.method,jsonrpcId:c.id,err:String(u)}),new S("UPSTREAM_DISCONNECTED",`frontier send failed: ${String(u)}`,{cause:u})}}onFrame(e){this.handler=e}onConnect(e){this.connectHandlers.push(e)}isConnected(){return this.opened&&this.fws?.readyState===1}injectAgentPatToken(e){let s=this.opts.getPatTokenForAgent;if(!s)return;let o=e.params?._meta;if(!o?.cozeAgentId)return;let c=s(o.cozeAgentId);c&&(o.cozePatToken=c)}handleMessage(e){let s=e.message?.service;if(s!==33555712){fe.debug("drop non-adapter frontier frame",{service:s});return}let o=jl(e);if(!o){fe.debug("frontier message without text payload, drop",{payloadType:e.message?.payloadType});return}if(!this.handler){fe.debug("frame received but no onFrame handler",{size:o.length});return}let c;try{c=JSON.parse(o)}catch(u){fe.warn("frontier message JSON parse failed",{err:String(u),head:o.slice(0,80)});return}let d=c;uc(d)||fe.info("frontier frame in",{logid:Hl(e.message?.LogID),logidNew:e.message?.LogIDNew,msgId:e.message?.msgID,jsonrpcId:d.id,method:d.method,body:Gl(o)}),Promise.resolve(this.handler(c)).catch(u=>fe.warn("frontier frame handler threw",{err:String(u)}))}};function uc(n){return n.method==="_agent/health"?!0:typeof n.id=="string"&&n.id.startsWith("agent.health_")}var fc=2e3;function Gl(n){return n.length<=fc?n:`${n.slice(0,fc)}...<truncated, total ${n.length} chars>`}function Hl(n){return n?n.high===0?String(n.low>>>0):`${n.high.toString(16)}${(n.low>>>0).toString(16).padStart(8,"0")}`:""}function jl(n){let e=n.message;if(e?.textPayload)return e.textPayload;let s=e?.payload;if(!s)return null;try{return Buffer.from(s).toString("utf8")}catch{return null}}q();var Oi=N("upstream.switchable"),yr=class{inner;handler=null;connectHandlers=[];constructor(e){this.inner=e}async swap(e,s){if(this.inner===e)return;Oi.info("swap upstream",{reason:s});let o=this.inner;if(this.inner=e,this.handler&&e.onFrame(this.handler),e.onConnect)for(let c of this.connectHandlers)e.onConnect(c);try{await e.start()}catch(c){throw Oi.error("swap target start failed, reverting",{err:String(c)}),this.inner=o,c}await o.stop(s??"swapped").catch(c=>Oi.warn("previous upstream stop threw (ignored)",{err:String(c)}))}current(){return this.inner}start(){return this.inner.start()}stop(e){return this.inner.stop(e)}send(e){return this.inner.send(e)}onFrame(e){this.handler=e,this.inner.onFrame(e)}onConnect(e){this.connectHandlers.push(e),this.inner.onConnect?.(e)}isConnected(){return this.inner.isConnected()}};q();var Li=N("upstream"),Kt=class{handler=null;async start(){Li.info("NoopUpstream started (M1 skeleton; real Frontier wired in M4)")}async stop(e){Li.info("NoopUpstream stopped",{reason:e})}async send(e){Li.debug("NoopUpstream.send (dropped)",{method:"method"in e?e.method:void 0})}onFrame(e){this.handler=e}isConnected(){return!1}async injectFrame(e){this.handler&&await this.handler(e)}};q();q();ie();import{promises as Mi}from"node:fs";import{dirname as Kl}from"node:path";var Wl=N("pat-token-store");async function gc(n=G()){try{let s=(await Mi.readFile(n.patTokenFile,"utf8")).trim();return s.length>0?s:null}catch(e){return e?.code!=="ENOENT"&&Wl.warn("read pat-token failed (treating as missing)",{err:String(e)}),null}}async function wn(n,e=G()){if(!n)throw new Error("writePatToken: empty patToken");await Mi.mkdir(Kl(e.patTokenFile),{recursive:!0}),await Mi.writeFile(e.patTokenFile,n,{encoding:"utf8",mode:384})}ie();ie();import{promises as br}from"node:fs";import{join as Jl}from"node:path";function $l(n){return`#!/bin/sh
115
+ `;var Ie=R("agent-detail-sync"),bx=6e4,vx=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 yx(s)}catch(c){Ie.info("agents dir not found, skip detail sync",{root:s,err:String(c)});return}Ie.info("starting detail sync",{reason:e,count:o.length}),await Promise.allSettled(o.map(async c=>{let x=await me(c,this.opts.paths).catch(()=>null);if(x){if(x.disconnectedAt){Ie.debug("detail sync: skip disconnected agent",{agentId:c});return}try{await this.syncOne(c,x)}catch(u){Ie.warn("detail sync failed for agent, skipping",{agentId:c,err:String(u)})}}})),Ie.info("detail sync done",{reason:e})}async retryPending(){if(this.retryQueue.size===0)return;let e=Date.now(),s=[];for(let[o,c]of this.retryQueue)e>=c.dueAt&&s.push(o);if(s.length!==0){Ie.info("retrying pending detail syncs",{count:s.length});for(let o of s)try{await this.syncOne(o)}catch(c){Ie.debug("detail sync retry still failing, will try again",{agentId:o,err:String(c)})}}}async syncOne(e,s){let o=s??await me(e,this.opts.paths);if(!o){Ie.info("detail sync: agent config missing, skip",{agentId:e});return}let c;try{c=await this.opts.sendDetail({_meta:{cozeAgentId:e}}),this.retryQueue.delete(e)}catch(f){Ie.warn("detail RPC failed, using local data",{agentId:e,err:String(f)});let g=this.retryQueue.get(e),m=g?Math.min(g.currentDelay*2,vx):bx;this.retryQueue.set(e,{dueAt:Date.now()+m,currentDelay:m});return}if(c.agentId&&c.agentId!==e){Ie.warn("detail response agentId mismatch, ignoring",{agentId:e,responseAgentId:c.agentId});return}let x=!1,u=!1;if(c.agentName&&c.agentName!==o.agentName&&(o.agentName=c.agentName,x=!0),c.description!==void 0&&c.description!==o.description&&(o.description=c.description,x=!0),c.cozeIdentity&&c.cozeIdentity!==o.cozeIdentity&&(o.cozeIdentity=c.cozeIdentity,x=!0,u=!0),c.deployType&&Ie.info("detail.deployType",{agentId:e,deployType:c.deployType}),!x){Ie.debug("detail sync: no diff",{agentId:e});return}await Ee(o,this.opts.paths),Ie.info("detail sync: config updated",{agentId:e,identityChanged:u,agentName:o.agentName}),u&&(await kt(o.workspace,o.framework,e,o.cozeIdentity),this.opts.handlers.reloadAgentSessionsPublic(e,"detail-sync"))}};st();import{spawn as Qs}from"node:child_process";import{lstat as ei,mkdir as Ix,readFile as eo,readdir as Ax,rm as Cx,stat as Px,writeFile as Zs}from"node:fs/promises";import{join as Be,normalize as Tx,relative as to,resolve as kx,sep as no}from"node:path";var Oe={PAIR:"_agent/pair",CREATE:"_agent/create",HEALTH:"_agent/health",LIST_SKILLS:"_agent/listSkills",ADD_SKILLS:"_agent/addSkills",REMOVE_SKILLS:"_agent/removeSkills",GET_FILE_TREE:"_agent/getFileTree",GET_FILE_CONTENT:"_agent/getFileContent",DETAIL:"_agent/detail",UPDATE:"_agent/update",DISCONNECT:"_agent/disconnect",SWITCH_MODEL:"_agent/switchModel",GEN_MODEL_TOKEN:"_agent/genModelToken",RESET:"_agent/reset",REPAIR:"_agent/repair",DELETE:"_agent/delete"};function Zt(n){return n?.cozeDeployType==="cloud"?"cloud":"local"}function Ls(n){let e=n?.cozeAccountId?.trim();if(!(!e||e==="0"))return e}function Os(n){let e=n?.cozeGroupId?.trim();if(!(!e||e==="0"))return e}function Ms(n){let{_meta:e,...s}=n;return{stripped:s,meta:e}}function Dt(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)}};U();ae();function Je(n,e){if(Zt(n)!=="cloud")throw new b("OPERATION_NOT_ALLOWED_FOR_LOCAL",`${e} is not allowed for local agent`)}function Nn(n){return n.startsWith("http://")||n.startsWith("https://")}function Ln(n){return n.endsWith("/")?n.slice(0,-1):n}U();var On="1008033",Bs="1289";var zs="pbbp2",Fs="https://www.coze.cn",Us="/api/coze_claw/resource/get_frontier_key",Sx="https://www.coze.cn",Ex="wss://frontier.coze.cn";function Mn(n){return n??process.env.COZE_BRIDGE_HANDSHAKE_URL??Sx}function qs(n){return n??process.env.COZE_BRIDGE_FRONTIER_URL??Ex}function Rt(n){let e={},s=n?.ttEnv??process.env.COZE_BRIDGE_TT_ENV,o=n?.usePpe??process.env.COZE_BRIDGE_USE_PPE;return s&&(e["x-tt-env"]=s),o&&(e["x-use-ppe"]=o),e}function Xt(n){return n?n.startsWith("boe_")?{ttEnv:n}:{ttEnv:n,usePpe:"1"}:{}}var Gs=R("handshake");async function Yr(n){let e=Mn(n.endpoint),s=n.timeoutMs??1e4,o=`${Ln(e)}${Us}?aid=${encodeURIComponent(On)}`,c={Authorization:`Bearer ${n.privatecode}`,Accept:"application/json",...Rt(n.ppeOverride)},x=new AbortController,u=setTimeout(()=>x.abort(),s);Gs.info("frontier key handshake",{base:e});try{let f=await fetch(o,{method:"GET",headers:c,signal:x.signal}),g=f.headers.get("x-tt-logid")??"",m=f.headers.get("x-tt-trace-id")??"";if(!f.ok){let I=await f.text().catch(()=>"");throw new b("UPSTREAM_HANDSHAKE_FAILED",`handshake HTTP ${f.status} logid=${g}: ${I.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=${g}`);let _=y.data??{},E=typeof _.access_key=="string"&&_.access_key||typeof _.accessKey=="string"&&_.accessKey||void 0,C=typeof _.device_id=="string"&&_.device_id||typeof _.deviceId=="string"&&_.deviceId||void 0;if(!E||!C){let I=JSON.stringify(y).slice(0,500);throw new b("UPSTREAM_HANDSHAKE_FAILED",`handshake response missing access_key/device_id (also tried camelCase) logid=${g}: ${I}`)}return Gs.info("handshake ok",{remoteDeviceId:C,logid:g,traceId:m}),{accessKey:E,deviceId:C}}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 Zr=process.env.COZE_BRIDGE_LLM_GATEWAY_URL?.trim()||"https://llm-gateway.coze.cn",Me="auto";function Hs(n){return{model:n.model??Me,...n.modelToken?{modelToken:n.modelToken}:{}}}function Ks(n){return!n||n===Me}function Ws(n){let e={};return n.modelToken?(e.ANTHROPIC_BASE_URL=Zr,e.ANTHROPIC_AUTH_TOKEN=n.modelToken,e.ANTHROPIC_MODEL=n.model||Me,n.modelInfo?.contextWindow&&(e.CLAUDE_CODE_MAX_CONTEXT_TOKENS=String(n.modelInfo.contextWindow))):Ks(n.model)||(e.ANTHROPIC_MODEL=n.model),e}function js(n){let e=[];return n.modelToken?e.push("-c",`model="${n.model||Me}"`):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="${Zr}/v1"`),e.push("-c",'model_providers.coze.env_key="OPENAI_API_KEY"'),e.push("-c",'model_providers.coze.wire_api="responses"'),e.push("-c","model_providers.coze.requires_openai_auth=false"),e.push("-c","model_providers.coze.supports_websockets=false"),e.push("-c",'model_provider="coze"'),n.modelInfo?.contextWindow&&e.push("-c",`model_context_window=${n.modelInfo.contextWindow}`)),e}function $s(n){return n.modelToken?{OPENAI_API_KEY:n.modelToken}:{}}function Xr(n){let{ttEnv:e,usePpe:s}=Xt(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=Xr(e);return Object.keys(s).length===0?{}:{ANTHROPIC_CUSTOM_HEADERS:Object.entries(s).map(([c,x])=>`${c}:${x}`).join(`
116
+ `)}}function Qr(n){return`coze-session-${n.replace(/[^A-Za-z0-9_-]+/g,"-")}`}function Js(n,e){if(!n.modelToken)return null;let s=n.model||Me,o=Xr(e),c=["text"];n.modelInfo?.capabilities?.image===!0&&c.push("image");let x={baseUrl:`${Zr}/v1`,api:"openai-completions",apiKey:n.modelToken,models:[{id:s,name:s,reasoning:!1,input:c,cost:{input:0,output:0,cacheRead:0,cacheWrite:0},contextWindow:n.modelInfo?.contextWindow??128e3,maxTokens:8192,api:"openai-completions"}]};return Object.keys(o).length>0&&(x.headers=o),x}function Ys(n,e){if(!n.modelToken)return[];let s=Xr(e),o=[];for(let[c,x]of Object.entries(s))o.push("-c",`model_providers.coze.http_headers.${c}="${x}"`);return o}var xe=R("agent-handlers"),Xs=5*1024*1024,Dx=1,Rx=6,Nx=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=Dt(e._meta),o=await this.loadAgentCfg(s),c=o?.workspace??Ve(s).workspace,x=o?.skills??[],u=[];for(let f of x){let g=Be(c,f.relPath,"SKILL.md");await Px(g).then(y=>y.isFile()).catch(()=>!1)&&u.push(zx(f))}return{skills:u}}async addSkills(e){Je(e._meta,"_agent/addSkills");let s=Dt(e._meta),o=await this.requireAgentCfg(s),c=e.skills??[],x=[...o.skills??[]],u=new Map(x.map((g,m)=>[g.skillId,m])),f=[];for(let g of c){let m=await ti({agentId:s,workspace:o.workspace,framework:o.framework,skill:g});ni(x,u,m),f.push(g)}return await kn(s,x),this.reloadAgentSessions(s,"skills-added"),{installedSkills:f}}async removeSkills(e){Je(e._meta,"_agent/removeSkills");let s=Dt(e._meta),o=await this.requireAgentCfg(s),c=new Set(e.skillIds??[]),x=o.skills??[],u=[];for(let f of x){if(!c.has(f.skillId)){u.push(f);continue}let g=Be(o.workspace,f.relPath);await Cx(g,{recursive:!0,force:!0}),xe.info("skill removed",{agentId:s,skillId:f.skillId,relPath:f.relPath})}return await kn(s,u),this.reloadAgentSessions(s,"skills-removed"),{ok:!0}}reloadAgentSessionsPublic(e,s){this.reloadAgentSessions(e,s)}reloadAgentSessions(e,s){let o=this.opts.agents.get(e);if(o)for(let[c,x]of o.sessions){if(!x.downstream)continue;let u=x.acpSessionId;if(u&&o.activeTriggers.has(u)||this.isRuntimePendingPermission(x)){x.reloadAfterTurn=!0,xe.info("downstream busy, scheduling reload after turn",{reason:s,agentId:e,framework:o.framework,cloudId:c,acpId:u});continue}let g=x.downstream;x.downstream=void 0,xe.info("killing downstream for workspace reload (idle)",{reason:s,agentId:e,framework:o.framework,cloudId:c,acpId:u}),g.stop(s).catch(m=>xe.warn("downstream stop failed during reload (ignored)",{reason:s,agentId:e,cloudId:c,err:String(m)}))}}isRuntimePendingPermission(e){let s=this.opts.isRuntimePendingPermission;return!s||!e.downstream?!1:s(e.downstream)}async updateAgent(e){if(!e.cozeIdentity?.trim())return xe.info("_agent/update: empty cozeIdentity, noop",{agentId:e.agentId}),{ok:!0};let s=e.agentId,o=await me(s);if(!o)throw new b("AGENT_NOT_FOUND",`agent not found: ${s}`);if(o.cozeIdentity===e.cozeIdentity)return xe.info("_agent/update: cozeIdentity unchanged, noop",{agentId:s}),{ok:!0};try{await kt(o.workspace,o.framework,s,e.cozeIdentity)}catch(c){throw xe.error("_agent/update: writeInstructionFile failed, aborting update",{agentId:s,framework:o.framework,workspace:o.workspace,err:String(c)}),new b("AGENT_PROTOCOL_ERROR",`failed to write instruction file for agent ${s}: ${String(c)}`,{cause:c})}return o.cozeIdentity=e.cozeIdentity,await Ee(o),xe.info("_agent/update: cozeIdentity rewritten",{agentId:s,framework:o.framework}),this.reloadAgentSessions(s,"identity-changed"),{ok:!0}}async disconnectAgent(e){let s=e.agentId;if(!s)throw new b("IPC_BAD_REQUEST","_agent/disconnect: missing agentId");let o=await me(s);return o?(o.disconnectedAt=Date.now(),o.disconnectReason=e.reason??"",await Ee(o),xe.info("agent disconnected",{agentId:s,reason:e.reason??"",force:e.force??!1}),this.opts.disposeAndMarkDisconnected&&await this.opts.disposeAndMarkDisconnected(s,e.reason??"disconnect"),{ok:!0}):(xe.warn("_agent/disconnect: agent not found, ignoring",{agentId:s}),{ok:!0})}async switchModel(e){if(Je(e._meta,"_agent/switchModel"),!e.agentId)throw new b("IPC_BAD_REQUEST","_agent/switchModel: missing agentId");let s=e.model?.trim()?e.model:Me,o=await me(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 Ee(o),xe.info("_agent/switchModel: model persisted",{agentId:e.agentId,model:s,reason:e.reason??""});let c=this.opts.agents.get(e.agentId);if(!c)return xe.info("_agent/switchModel: agent not running, config persisted only",{agentId:e.agentId}),{ok:!0};c.model=s,e.modelInfo&&c.setModelInfo(e.modelInfo),this.opts.cleanupOpenclawProviders&&await this.opts.cleanupOpenclawProviders(c).catch(u=>xe.warn("cleanupOpenclawProviders before switchModel failed (ignored)",{agentId:e.agentId,err:String(u)}));let x=[];for(let[u,f]of c.allSessionQueues())x.push(f.enqueue(async()=>{let g=c.sessions.get(u);g?.downstream&&(await g.downstream.stop(`switchModel: ${s}`).catch(()=>{}),g.downstream=void 0)}));return await Promise.all(x),xe.info("_agent/switchModel: all session runtimes killed, next prompt will respawn",{agentId:e.agentId,model:s,cloudSessions:x.length}),{ok:!0}}async resetAgent(e){if(Je(e._meta,Oe.RESET),!e.agentId)throw new b("IPC_BAD_REQUEST",`${Oe.RESET}: missing agentId`);return await this.runDetailSync(e.agentId,Oe.RESET,e.reason),{ok:!0}}async repairAgent(e){if(Je(e._meta,Oe.REPAIR),!e.agentId)throw new b("IPC_BAD_REQUEST",`${Oe.REPAIR}: missing agentId`);let s=await this.loadAgentCfg(e.agentId);if(s&&s.framework!=="openclaw")throw new b("IPC_BAD_REQUEST",`${Oe.REPAIR} only allowed for openclaw, got ${s.framework}`);if(s&&this.opts.openclawRepair)try{await this.opts.openclawRepair(e.agentId,s.workspace)}catch(o){xe.warn("openclaw repair (delete+add) failed (ignored)",{agentId:e.agentId,reason:e.reason,err:String(o)})}return await this.runDetailSync(e.agentId,Oe.REPAIR,e.reason),{ok:!0}}async runDetailSync(e,s,o){if(!this.opts.detailSyncer){xe.warn("detailSyncer not wired, skipping sync",{method:s,agentId:e});return}try{await this.opts.detailSyncer(e)}catch(c){xe.warn("detail sync failed (ignored)",{method:s,agentId:e,reason:o,err:String(c)})}}async getFileTree(e){Je(e._meta,"_agent/getFileTree");let s=e._meta,o=Dt(s),c=await this.resolveWorkspace(o),x=e.filePath??"",u=this.safeJoin(c,x),f=await ei(u).catch(()=>null);if(!f)throw new b("IPC_BAD_REQUEST",`path not found: ${x}`);if(f.isSymbolicLink())throw new b("IPC_BAD_REQUEST",`symlink not allowed: ${x}`);let g=jx(e.depth);return f.isDirectory()?{tree:await Wx(c,u,x,g)}:{tree:[{name:$x(x),path:io(x||"."),isDir:!1,size:f.size,modifiedAt:Math.floor(f.mtimeMs)}]}}async getFileContent(e){Je(e._meta,"_agent/getFileContent");let s=Dt(e._meta),o=await this.resolveWorkspace(s);if(!e.filePath)throw new b("IPC_BAD_REQUEST","filePath required");let c=this.safeJoin(o,e.filePath),x=await ei(c).catch(()=>null);if(!x||!x.isFile())throw new b("IPC_BAD_REQUEST",`not a file: ${e.filePath}`);if(x.isSymbolicLink())throw new b("IPC_BAD_REQUEST",`symlink not allowed: ${e.filePath}`);if(x.size>Xs)throw new b("IPC_BAD_REQUEST",`file too large: ${x.size} bytes (max ${Xs})`);let u=await eo(c);return u.includes(0)?{content:u.toString("base64"),encoding:"base64",size:x.size}:{content:u.toString("utf8"),encoding:"utf-8",size:x.size}}async resolveWorkspace(e){let s=this.opts.agents.get(e);return s?s.workspace:(await me(e).catch(()=>null))?.workspace??Ve(e).workspace}safeJoin(e,s){let o=kx(e,s||"."),c=to(e,o);if(c.startsWith("..")||c===".."||c.startsWith(`..${no}`))throw new b("IPC_BAD_REQUEST",`path escapes workspace: ${s}`);return o}loadAgentCfg(e){return me(e)}async requireAgentCfg(e){let s=await this.loadAgentCfg(e);if(!s)throw new b("AGENT_NOT_FOUND",`no config for agent: ${e}`);return s}};function Lx(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 Ox(n){return n==="claude-code"?Be(".claude","skills"):Be(".agents","skills")}var Mx=3e4,Bx=50*1024*1024,zn=3e4;async function ti(n){let{agentId:e,workspace:s,framework:o,skill:c}=n;if(!c.skillName)throw new b("IPC_BAD_REQUEST","skill missing skillName");let x=typeof c.content=="string"&&c.content.length>0,u=typeof c.downloadUrl=="string"&&c.downloadUrl.length>0;if(!x&&!u)throw new b("IPC_BAD_REQUEST",`skill ${c.skillId} missing both content and downloadUrl`);let f=Lx(c.skillName),g=Ox(o),m=Be(g,f),y=Be(s,m);if(await Ix(y,{recursive:!0}),x){let E=Buffer.from(c.content,"utf8");Qt(E.length),await Zs(Be(y,"SKILL.md"),E,"utf8")}else{let E=await Fx(c.downloadUrl);qx(E)?await Gx(E,y):await Zs(Be(y,"SKILL.md"),E.toString("utf8"),"utf8")}let _={skillId:c.skillId,skillName:c.skillName,relPath:m,installedAt:Date.now(),...c.description?{description:c.description}:{},...c.icon?{icon:c.icon}:{},...c.version?{version:c.version}:{},...c.downloadUrl?{downloadUrl:c.downloadUrl}:{},...c.config?{config:c.config}:{},...c.builtin?{builtin:c.builtin}:{}};return xe.info("skill installed",{agentId:e,skillId:c.skillId,skillName:c.skillName,relPath:m,source:x?"content":"downloadUrl"}),_}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 zx(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 Fx(n){if(!n)throw new b("IPC_BAD_REQUEST","skill missing downloadUrl");if(n.startsWith("data:")){let e=Math.floor(n.length*3/4);Qt(e);let s=Ux(n);return Qt(s.length),s}if(n.startsWith("file:")){let e=new URL(n).pathname,s=await eo(e);return Qt(s.length),s}if(Nn(n)){let e=new AbortController,s=setTimeout(()=>e.abort(),Mx);try{let o=await fetch(n,{signal:e.signal});if(!o.ok)throw new b("IPC_BAD_REQUEST",`fetch skill failed HTTP ${o.status} ${n}`);let c=await o.arrayBuffer();return Qt(c.byteLength),Buffer.from(c)}finally{clearTimeout(s)}}throw new b("IPC_BAD_REQUEST",`unsupported downloadUrl scheme (\u8981 https/data/file): ${n.slice(0,80)}`)}function Qt(n){if(n>Bx)throw new b("IPC_BAD_REQUEST",`skill too large: ${n} bytes`)}function Ux(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 qx(n){return n.length>=2&&n[0]===31&&n[1]===139}async function Gx(n,e){await Hx(n),await new Promise((s,o)=>{let c=Qs("tar",["-xzf","-","-C",e,"--strip-components=1","--no-same-owner"],{stdio:["pipe","pipe","pipe"]}),x="";c.stderr?.on("data",f=>{x+=String(f)});let u=setTimeout(()=>{c.kill("SIGKILL"),o(new b("IPC_BAD_REQUEST",`tar extract timeout (${zn}ms)`))},zn);c.on("error",f=>{clearTimeout(u),o(new b("IPC_BAD_REQUEST",`tar spawn failed: ${f.message}`,{cause:f}))}),c.on("exit",f=>{clearTimeout(u),f===0?s():o(new b("IPC_BAD_REQUEST",`tar exit ${f}${x?`: ${x.trim().slice(0,200)}`:""}`))}),c.stdin?.end(n)})}async function Hx(n){let e=await new Promise((s,o)=>{let c=Qs("tar",["-tzvf","-"],{stdio:["pipe","pipe","pipe"]}),x="",u="";c.stdout?.on("data",g=>{x+=String(g)}),c.stderr?.on("data",g=>{u+=String(g)});let f=setTimeout(()=>{c.kill("SIGKILL"),o(new b("IPC_BAD_REQUEST",`tar list timeout (${zn}ms)`))},zn);c.on("error",g=>{clearTimeout(f),o(new b("IPC_BAD_REQUEST",`tar list spawn failed: ${g.message}`))}),c.on("exit",g=>{clearTimeout(f),g===0?s(x):o(new b("IPC_BAD_REQUEST",`tar list exit ${g}${u?`: ${u.trim().slice(0,200)}`:""}`))}),c.stdin?.end(n)});for(let s of e.split(`
117
+ `)){let o=s.trim();if(!o)continue;let c=o.charCodeAt(0);if(c!==45&&c!==100)throw new b("IPC_BAD_REQUEST",`tar entry kind '${o[0]}' not allowed (symlink/hardlink/special): ${o.slice(0,100)}`);let u=(o.match(/\s(\S.*)$/)?.[1]??"").split(" -> ")[0]?.trim()??"";if(!u)continue;if(u.startsWith("/"))throw new b("IPC_BAD_REQUEST",`tar entry absolute path: ${u}`);if(u.split(/[/\\]/).some(g=>g===".."))throw new b("IPC_BAD_REQUEST",`tar entry contains '..': ${u}`)}}var Kx=5e3;async function Wx(n,e,s,o){return ro(n,e,s,o,{count:0})}async function ro(n,e,s,o,c){if(o<=0)return[];let x;try{x=await Ax(e,{withFileTypes:!0})}catch{return[]}let u=[];for(let f of x){if(Nx.has(f.name)||f.isSymbolicLink())continue;if(c.count>=Kx){u.push({name:"...",path:"...",isDir:!1,size:0,modifiedAt:0,hasMore:!0});break}let g=Be(e,f.name),m=Tx(Be(s,f.name)),y=null;try{y=await ei(g)}catch{continue}if(y.isSymbolicLink())continue;c.count++;let _={name:f.name,path:io(to(n,g)),isDir:y.isDirectory(),size:y.size,modifiedAt:Math.floor(y.mtimeMs)};y.isDirectory()&&o>1&&(_.children=await ro(n,g,m,o-1,c)),u.push(_)}return u.sort((f,g)=>f.isDir!==g.isDir?f.isDir?-1:1:f.name.localeCompare(g.name)),u}function jx(n){return!n||n<=0?Dx:Math.min(n,Rx)}function $x(n){if(!n||n==="."||n==="/")return".";let e=n.split(/[/\\]/);return e[e.length-1]||"."}function io(n){return n.split(no).join("/")}U();import{readFileSync as yp}from"node:fs";import{dirname as vp,join as Sp}from"node:path";import{fileURLToPath as Ip}from"node:url";var ot="0.1.65";var ze=R("agent-health-reporter"),Vx=1e4,en=class{constructor(e){this.opts=e;this.intervalMs=e.intervalMs??Vx}opts;timer=null;inFlight=!1;unsubscribeRegister=null;intervalMs;start(){this.timer||(this.timer=setInterval(()=>{this.tick()},this.intervalMs),this.timer.unref?.(),this.unsubscribeRegister=this.opts.core.onAgentRegister(()=>{this.tick()}),ze.info("heartbeat started",{intervalMs:this.intervalMs}),this.tick())}stop(){this.timer&&(clearInterval(this.timer),this.timer=null,this.unsubscribeRegister&&(this.unsubscribeRegister(),this.unsubscribeRegister=null),ze.info("heartbeat stopped"))}async tick(){if(this.inFlight){ze.debug("previous tick still in-flight, skip");return}let e=this.opts.getDeviceId();if(!e){ze.debug("deviceId not available, skip tick (\u5C1A\u672A pair)");return}this.inFlight=!0;try{let s=[];for(let f of this.opts.core.agents.values()){let g=Jx(f);if(!g)continue;let m={agentId:f.agentId,status:g};f.patToken&&(m.patToken=f.patToken),f.accountId&&(m.accountId=f.accountId),s.push(m)}if(s.length===0)return;let o={agents:s,bridgeVersion:ot,_meta:{cozeDeviceId:e}},c;try{c=await this.opts.core.sendRequest("_agent/health",o,5e3)}catch(f){ze.warn("heartbeat batch send failed",{count:s.length,err:String(f)})}let x=c?.authFailures;if(x&&x.length>0&&(ze.warn("heartbeat received authFailures from cloud",{count:x.length,agentIds:x.map(f=>f.agentId)}),this.opts.onAuthFailures))try{await this.opts.onAuthFailures(x)}catch(f){ze.warn("onAuthFailures callback failed (ignored)",{err:String(f)})}let u=c?.minBridgeVersion;if(u&&(ze.info("heartbeat received minBridgeVersion from cloud",{minV:u}),this.opts.onMinBridgeVersion))try{await this.opts.onMinBridgeVersion(u)}catch(f){ze.warn("onMinBridgeVersion callback failed (ignored)",{err:String(f)})}}finally{this.inFlight=!1}if(this.opts.onTickEnd)try{await this.opts.onTickEnd()}catch(s){ze.warn("onTickEnd hook failed",{err:String(s)})}}};function Jx(n){return n.status==="error"?"error":n.activeTriggers.size>0?"busy":n.status==="ok"?"online":null}st();import{mkdir as si,rm as Sd}from"node:fs/promises";import{spawn as rd,spawnSync as id}from"node:child_process";function tn(n,e,s){return s===void 0?{jsonrpc:"2.0",id:n,method:e}:{jsonrpc:"2.0",id:n,method:e,params:s}}function nn(n,e){return e===void 0?{jsonrpc:"2.0",method:n}:{jsonrpc:"2.0",method:n,params:e}}function Nt(n,e){return{jsonrpc:"2.0",id:n,result:e}}function at(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)}},G={PARSE_ERROR:-32700,INVALID_REQUEST:-32600,METHOD_NOT_FOUND:-32601,INVALID_PARAMS:-32602,INTERNAL_ERROR:-32603,AGENT_NOT_FOUND:-32001,AGENT_BUSY:-32002,AGENT_TIMEOUT:-32003,AGENT_SPAWN_FAILED:-32004,OPERATION_NOT_ALLOWED_FOR_LOCAL:-32005,AGENT_DISCONNECTED:-32006,MODEL_TOKEN_GEN_FAILED:-32009,PATH_OUTSIDE_WORKSPACE:-32010,FILE_TOO_LARGE:-32011,UNSUPPORTED_MIME:-32012,UPLOAD_FAILED:-32013,UPSTREAM_NOT_READY:-32014,BRIDGE_UPGRADING:-32015,AGENT_FRAME_IDLE_TIMEOUT:-32016,MODEL_MODALITY_UNSUPPORTED:-32017};function so(n){return"method"in n&&"id"in n&&n.id!==void 0}function oo(n){return"method"in n&&!("id"in n)}function Un(n){return!("method"in n)&&"id"in n}var Yx={AGENT_NOT_FOUND:G.AGENT_NOT_FOUND,AGENT_BUSY:G.AGENT_BUSY,AGENT_DISCONNECTED:G.AGENT_DISCONNECTED,AGENT_TIMEOUT:G.AGENT_TIMEOUT,AGENT_FRAME_IDLE_TIMEOUT:G.AGENT_FRAME_IDLE_TIMEOUT,AGENT_SPAWN_FAILED:G.AGENT_SPAWN_FAILED,AGENT_PROTOCOL_ERROR:G.INTERNAL_ERROR,BRIDGE_CONFIG_INVALID:G.INTERNAL_ERROR,BRIDGE_INTERNAL:G.INTERNAL_ERROR,IPC_AUTH_FAILED:G.INTERNAL_ERROR,IPC_BAD_REQUEST:G.INVALID_REQUEST,MODEL_TOKEN_GEN_FAILED:G.MODEL_TOKEN_GEN_FAILED,MODEL_MODALITY_UNSUPPORTED:G.MODEL_MODALITY_UNSUPPORTED,OPERATION_NOT_ALLOWED_FOR_LOCAL:G.OPERATION_NOT_ALLOWED_FOR_LOCAL,UPSTREAM_DISCONNECTED:G.INTERNAL_ERROR,UPSTREAM_HANDSHAKE_FAILED:G.INTERNAL_ERROR,PATH_OUTSIDE_WORKSPACE:G.PATH_OUTSIDE_WORKSPACE,FILE_TOO_LARGE:G.FILE_TOO_LARGE,UNSUPPORTED_MIME:G.UNSUPPORTED_MIME,UPLOAD_FAILED:G.UPLOAD_FAILED,UPSTREAM_NOT_READY:G.UPSTREAM_NOT_READY,BRIDGE_UPGRADING:G.BRIDGE_UPGRADING,NPX_CACHE_CORRUPT:G.INTERNAL_ERROR};function Zx(n){if(n!=null)return n instanceof Error?{name:n.name,message:rn(n.message)}:typeof n=="string"?rn(n):typeof n=="object"?Qx(n):n}var Xx=[[/\/Users\/[^/\s'"`)]+/g,"/Users/<redacted>"],[/\/home\/[^/\s'"`)]+/g,"/home/<redacted>"],[/[A-Za-z]:\\Users\\[^\\\s'"`)]+/g,"C:\\Users\\<redacted>"],[/(Bearer|Token|Authorization:)\s+[\w._-]+/gi,"$1 <redacted>"],[/\b(sk|pat|ak)[-_][A-Za-z0-9_-]{20,}\b/g,"<redacted-key>"]];function rn(n){let e=n;for(let[s,o]of Xx)e=e.replace(s,o);return e}function Qx(n){let e={};for(let[s,o]of Object.entries(n))typeof o=="string"?e[s]=rn(o):e[s]=o;return e}function sn(n){if(n instanceof b){let e=Zx(n.cause),s={bridgeCode:n.code,retriable:n.retriable};return e!==void 0&&(s.cause=e),{code:Yx[n.code]??G.INTERNAL_ERROR,message:rn(n.message),data:s}}return{code:G.INTERNAL_ERROR,message:rn(n instanceof Error?n.message:String(n))}}function ao(n){let e=n.data,s=e?.bridgeCode??"AGENT_PROTOCOL_ERROR",o=!!e&&typeof e.message=="string"&&!!e.message,c=o?e?.message:n.message,x=n.data;if(o&&e){let{message:u,...f}=e;x=f}return new b(s,c,{retriable:e?.retriable??!1,cause:x})}function xo(n){return`${JSON.stringify(n)}
118
+ `}var co=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>co){let c=this.buffer.length;return this.buffer="",this.onError?.({line:`<buffer overflow: ${c} bytes, dropped>`,error:new Error(`LdjsonDecoder buffer exceeded ${co} bytes`)}),[]}let s=this.buffer.split(`
119
+ `);this.buffer=s.pop()??"";let o=[];for(let c of s){let x=c.replace(/\r$/,"").trim();if(x)try{o.push(JSON.parse(x))}catch(u){this.onError?.({line:x,error:u})}}return o}flush(){if(!this.buffer)return[];let e=this.buffer.replace(/\r$/,"").trim();if(this.buffer="",!e)return[];try{return[JSON.parse(e)]}catch(s){return this.onError?.({line:e,error:s}),[]}}};var fo={"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"},Mp=Object.fromEntries(Object.entries(fo).map(([n,e])=>[e,n])),ed={"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:[]},Lt=class{seq=0;next(e,s){this.seq+=1;let o=fo[e]??td(e),c=ed[o]??[],x=[o,String(this.seq)];if(c.length>0){let u=c.map(g=>uo(s?.[g]??"")),f=nd(u).join(":");f&&x.push(f)}else s&&Object.values(s).some(u=>u)&&x.push(Object.values(s).filter(Boolean).map(u=>uo(String(u))).join(":"));return x.join("_")}reset(){this.seq=0}};function td(n){return n.replace(/[\s/]+/g,".").replace(/_+/g,"-")}function uo(n){return n.replace(/[:_\s]+/g,"-")}function nd(n){let e=n.length;for(;e>0&&!n[e-1];)e-=1;return n.slice(0,e)}function ct(n,e){let s=process.env[n];if(!s)return e;let o=Number(s);return Number.isFinite(o)&&o>0?o:e}U();var sd=ct("COZE_BRIDGE_INITIALIZE_TIMEOUT_MS",3e4),od=200,ad=/(ENOTEMPTY|EEXIST).*_npx[/\\]/;function ri(n){return n.some(e=>ad.test(e))}var cd=ct("COZE_BRIDGE_SESSION_PROMPT_MAX_MS",3600*1e3),xd=ct("COZE_BRIDGE_SESSION_PROMPT_FRAME_IDLE_MS",600*1e3),lo=500;function dd(n){try{let e=JSON.stringify(n);return e===void 0||e.length<=lo?n:`${e.slice(0,lo)}...<truncated, total ${e.length} chars>`}catch{return"<unserializable>"}}function go(n,e){if(!(typeof n!="number"||n<=0))try{if(process.platform==="win32"){let s=["/PID",String(n),"/T"];e==="SIGKILL"&&s.push("/F"),id("taskkill",s,{stdio:"ignore",windowsHide:!0})}else process.kill(-n,e)}catch{}}var Fe=class{constructor(e){this.opts=e;this.log=R(`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 Lt;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=rd(this.opts.command,this.opts.args,{cwd:this.opts.cwd,env:{...this.sanitizeEnv(process.env),...this.opts.env},stdio:["pipe","pipe","pipe"],detached:e});this.child=s,s.stdout?.setEncoding("utf8"),s.stdout?.on("data",o=>{try{for(let c of this.decoder.push(o))this.dispatch(c)}catch(c){this.log.warn("stdout dispatch threw, swallowed to keep daemon alive",{err:String(c)})}}),s.stderr?.setEncoding("utf8"),s.stderr?.on("data",o=>{let c=o.trimEnd();this.stderrRing.push(c),this.stderrRing.length>od&&this.stderrRing.shift(),this.log.debug("stderr",{text:c})}),s.stdin?.on("error",o=>{this.log.warn("child stdin error",{err:String(o)})}),s.stdout?.on("error",o=>{this.log.warn("child stdout error",{err:String(o)})}),s.stderr?.on("error",o=>{this.log.warn("child stderr error",{err:String(o)})}),s.on("exit",(o,c)=>{this.stopped=!0,(o!==0||c!==null)&&this.stderrRing.length>0&&(this.log.warn("downstream exited abnormally, recent stderr",{code:o,signal:c,recentStderr:[...this.stderrRing]}),(this.framework==="claude-code"||this.framework==="codex")&&ri(this.stderrRing)&&(this.log.warn("npx cache corruption detected, triggering global install fallback (D93)",{framework:this.framework}),Ct(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}/${c})`));for(let u of this.exitHandlers)u(o,c)}),s.on("error",o=>{this.log.error("child error",{err:String(o)}),this.failAllPending(new b("AGENT_SPAWN_FAILED",String(o),{cause:o}))}),this.log.info("downstream started",{command:this.opts.command,pid:s.pid,cwd:this.opts.cwd})}async stop(e){if(!this.child||this.stopped)return;this.stopped=!0,this.log.info("downstream stopping",{reason:e});let s=this.child,o=new Promise(x=>s.once("exit",()=>x()));go(s.pid,"SIGTERM");let c=setTimeout(()=>{s.killed||go(s.pid,"SIGKILL")},5e3);try{await o}finally{clearTimeout(c)}}pid(){return this.child?.pid}isAlive(){return!!this.child&&!this.stopped}getStderrTail(){return[...this.stderrRing]}initialize(e){return this.call("initialize",e)}sessionNew(e){return this.call("session/new",{mcpServers:[],...e})}sessionLoad(e){return this.call("session/load",{mcpServers:[],...e})}sessionPrompt(e,s=cd,o=xd){return this.call("session/prompt",e,s,o)}async sessionCancel(e){!this.child||this.stopped||this.writeFrame(nn("session/cancel",e))}onUpdate(e){this.updateHandlers.push(e)}onAgentRequest(e){this.agentRequestHandlers.push(e)}respondAgentRequest(e,s){if(this.inflightAgentRequests.delete(e),!(!this.child||this.stopped))try{this.writeFrame(Nt(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(at(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=sd,c=0){if(!this.child||this.stopped)return Promise.reject(new b("AGENT_PROTOCOL_ERROR","downstream not started"));let x=this.idAllocator.next(e),u=tn(x,e,s),f=o>0&&Number.isFinite(o),g=c>0&&Number.isFinite(c);return new Promise((m,y)=>{let _={resolve:m,reject:y,timer:null,frameIdleTimer:null,armFrameIdle:null,method:e};f&&(_.timer=setTimeout(()=>{this.pending.delete(x),_.frameIdleTimer&&clearTimeout(_.frameIdleTimer),y(new b("AGENT_TIMEOUT",`${e} timed out after ${o}ms`))},o));let E=g?()=>{_.frameIdleTimer&&clearTimeout(_.frameIdleTimer),_.frameIdleTimer=setTimeout(()=>{if(this.inflightAgentRequests.size>0){this.log.debug("frame-idle fired but agent request inflight, re-arming",{id:x,method:e,inflight:this.inflightAgentRequests.size}),E?.();return}_.timer&&clearTimeout(_.timer),this.pending.delete(x),this.log.warn("frame-idle timeout, rejecting pending call",{id:x,method:e,frameIdleMs:c}),y(new b("AGENT_FRAME_IDLE_TIMEOUT",`${e} no session/update for ${c}ms (no inflight agent request)`))},c)}:null;_.armFrameIdle=E,this.pending.set(x,_),E?.();try{this.writeFrame(u)}catch(C){_.timer&&clearTimeout(_.timer),_.frameIdleTimer&&clearTimeout(_.frameIdleTimer),this.pending.delete(x),y(C)}})}writeFrame(e){if(!this.child?.stdin||this.child.stdin.destroyed)throw new b("AGENT_PROTOCOL_ERROR","downstream stdin not writable");this.child.stdin.write(xo(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(ao(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:dd(e.result)}),s.resolve(e.result));return}if(oo(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(so(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(at(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(at(e.id,sn(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 ud="@agentclientprotocol/claude-agent-acp@latest";function fd(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 Fe{framework="claude-code";constructor(e){let s=Pt("claude-code"),[o,c]=s?[s,[]]:["npx",["-y",ud]],x=e.command??o,u=e.args??c,f={command:x,args:u,cwd:e.cwd,...e.env?{env:e.env}:{}};super(f)}sanitizeEnv(e){return fd(e)}};import{mkdtempSync as ld,rmSync as gd}from"node:fs";import{tmpdir as hd}from"node:os";import{join as pd}from"node:path";var md="@zed-industries/codex-acp@latest",Hn=class extends Fe{framework="codex";authMethodId;codexHomeDir;constructor(e){let s=Pt("codex"),[o,c]=s?[s,[]]:["npx",["-y",md]],x=e.command??o,u=e.args??c,f=e.extraArgs?[...u,...e.extraArgs]:u,g=e.isolateCodexHome?ld(pd(hd(),"coze-bridge-codex-home-")):void 0,m=g?{...e.env??{},CODEX_HOME:g}:e.env,y={command:x,args:f,cwd:e.cwd,...m?{env:m}:{}};super(y),this.authMethodId=e.authMethodId,this.codexHomeDir=g}async initialize(e){let 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{gd(this.codexHomeDir,{recursive:!0,force:!0})}catch{}}};var wd=3e4,Ot=class extends Fe{framework="openclaw";agentId;sessionName;slashModelOnStart;constructor(e){let s=e.sessionName??"default",o=["acp","--session",`agent:${e.agentId}:${s}`];e.gatewayToken&&o.push("--token",e.gatewayToken);let c={command:e.command,args:o,cwd:e.cwd,...e.env?{env:e.env}:{}};super(c),this.agentId=e.agentId,this.sessionName=s,this.slashModelOnStart=e.slashModelOnStart}async afterSessionEstablished(e){this.slashModelOnStart&&(this.log.info("switching session to per-session provider via /model",{agentId:this.agentId,sessionName:this.sessionName,slash:this.slashModelOnStart}),await this.sessionPrompt({sessionId:e,prompt:[{type:"text",text:`/model ${this.slashModelOnStart}`}]},wd))}get acpSessionName(){return this.sessionName}};U();ae();function ii(n){return n.replace(/[^A-Za-z0-9._-]+/g,"-")}var Mt=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 Kn=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 Mt,this.sessionQueues.set(e,s)),s}allSessionQueues(){return this.sessionQueues.entries()}hasSessionQueue(e){let s=this.sessionQueues.get(e);return!!s&&!s.isDisposed}async dispose(e){this.status="stopped";let s=new Error(`AgentSession disposed${e?`: ${e}`:""}`);for(let o of this.sessionQueues.values())o.dispose(s);this.sessionQueues.clear(),await this.killAllRuntimes(e??"dispose")}async killAllRuntimes(e){let s=[];for(let[,o]of this.sessions)on(o),o.downstream&&(s.push(o.downstream.stop(e).catch(()=>{})),o.downstream=void 0);await Promise.all(s),this.activeTriggers.clear(),this.activeGroupIds.clear()}};function on(n){n.idleTimer&&(clearTimeout(n.idleTimer),n.idleTimer=void 0)}import{spawn as _d}from"node:child_process";import{homedir as yd}from"node:os";import{join as bd}from"node:path";Pn();U();async function mo(){let n=bd(yd(),".openclaw/openclaw.json");return(await Tt(n))?.gateway?.auth?.token??""}var ho=R("openclaw.config"),vd=[0,5e3,5e3],po="models.providers.",Wn="agents.defaults.models",jn=class{command;env;retryDelaysMs;queue=new Mt;constructor(e){this.command=e.command,this.env=e.env??process.env,this.retryDelaysMs=e.retryDelaysMs??vd}async withRetry(e,s){let o;for(let c=0;c<this.retryDelaysMs.length;c++){let x=this.retryDelaysMs[c]??0;x>0&&await new Promise(u=>setTimeout(u,x));try{return await s()}catch(u){o=u,ho.warn("openclaw cli failed, will retry",{label:e,attempt:c+1,err:String(u)})}}throw new b("AGENT_SPAWN_FAILED",`openclaw cli ${e} failed after ${this.retryDelaysMs.length} attempts: ${o?.message??"unknown"}`)}runCli(e){return new Promise((s,o)=>{let c=_d(this.command,e,{stdio:["ignore","pipe","pipe"],env:this.env}),x="";c.stderr?.on("data",u=>{x+=u.toString("utf8")}),c.on("error",o),c.on("close",u=>{u===0?s():o(new Error(`exit ${u}: ${x.trim().slice(0,500)}`))})})}async runCliTolerant(e,s){try{await this.runCli(e)}catch(o){let c=String(o);if(s.some(x=>c.includes(x)))return;throw o}}async bestEffortUnset(e,s){try{await this.queue.enqueue(()=>this.withRetry(e,()=>this.runCli(["config","unset",s])))}catch(o){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",`${po}${e}`,JSON.stringify(s),"--strict-json","--merge"])))}removeProvider(e){return this.bestEffortUnset(`config unset models.providers.${e}`,`${po}${e}`)}addModelToAllowlist(e,s){let o={[e]:s?{alias:s}:{}};return this.queue.enqueue(()=>this.withRetry(`config set ${Wn}[${e}]`,()=>this.runCli(["config","set",Wn,JSON.stringify(o),"--strict-json","--merge"])))}removeModelFromAllowlist(e){return this.bestEffortUnset(`config unset ${Wn}[${e}]`,`${Wn}.${e}`)}ensureAgent(e,s,o){let c=["agents","add",e,"--workspace",s,"--non-interactive"];return o&&c.push("--model",o),this.queue.enqueue(()=>this.withRetry(`agents add ${e}`,()=>this.runCliTolerant(c,["already exists","already registered"])))}deleteAgent(e){return this.queue.enqueue(()=>this.withRetry(`agents delete ${e}`,()=>this.runCliTolerant(["agents","delete",e,"--force"],["not found","does not exist"])))}};var we=R("agent-manager"),Ed=(n,e,s,o,c,x,u,f)=>{switch(n){case"claude-code":{let g={...c?{...Ws(c),...Vs(c,u)}:{},...f??{},IS_SANDBOX:"1"};return new Gn({cwd:s,env:g})}case"codex":{let m=[...c?[...js(c),...Ys(c,u)]:[],"-c",'sandbox_mode="danger-full-access"',"-c",'approval_policy="never"'],y={...c?$s(c):{},...f??{}},_=!!c;return new Hn({cwd:s,...m.length>0?{extraArgs:m}:{},...Object.keys(y).length>0?{env:y}:{},..._?{authMethodId:"openai-api-key",isolateCodexHome:!0}:{}})}case"openclaw":return new Ot({command:e,cwd:s,agentId:o,...x?{sessionName:ii(x)}:{}})}};function oi(n){return n==="claude-code"||n==="codex"}var Id={path:"",version:"cloud-deployed"},Ad={protocolVersion:1,clientCapabilities:{fs:{readTextFile:!0,writeTextFile:!0}}},Cd=6e4,Pd=ct("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??Ed,this.createTimeoutMs=e.createTimeoutMs??Cd,this.spawnAwaitInstallMs=e.spawnAwaitInstallMs??Pd}buildBinShimPathEnv(){let e=process.platform==="win32"?";":":";return{PATH:`${this.paths.binDir}${e}${process.env.PATH??""}`}}getOpenclawConfig(){if(!this.openclawConfigCache){let e=this.config.frameworksCache?.openclaw;if(!e?.path)throw new b("AGENT_SPAWN_FAILED","openclaw binary not detected on this machine");this.openclawConfigCache=new jn({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=Zt(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")we.warn("existing agent in error state, rebuilding",{agentId:e.agentId}),await o.dispose("rebuild after error").catch(I=>we.warn("dispose stale agent failed (ignored)",{err:String(I)})),this.registry.unregister(e.agentId);else{if(e.patToken&&e.patToken!==o.patToken){we.info("updating agent patToken on re-create (reconnect with new PAT)",{agentId:e.agentId}),o.setPatToken(e.patToken);let I=await me(e.agentId,this.paths).catch(()=>null);I&&(I.patToken=e.patToken,await Ee(I,this.paths))}if(o.deployType==="cloud"&&e.modelInfo){we.info("updating agent modelInfo on re-create",{agentId:e.agentId}),o.setModelInfo(e.modelInfo);let I=await me(e.agentId,this.paths).catch(()=>null);I&&(I.modelInfo=e.modelInfo,await Ee(I,this.paths))}return we.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 x=Ve(e.agentId,this.paths),u=Zt(e._meta),f=e.framework==="openclaw"&&u==="local",g=f?this.config.frameworksCache?.openclaw?.defaultAgent?.workspace:void 0,m=e.workspace??g??x.workspace,y=new AbortController,_=setTimeout(()=>y.abort(new b("AGENT_TIMEOUT",`_agent/create timed out after ${this.createTimeoutMs}ms`)),this.createTimeoutMs),E,C=!1;try{s&&oi(e.framework)&&await Ct(e.framework,y.signal);let I=()=>{if(y.signal.aborted)throw y.signal.reason instanceof Error?y.signal.reason:new b("AGENT_TIMEOUT","_agent/create aborted")};await si(x.root,{recursive:!0}),await si(m,{recursive:!0}),await si(x.logs,{recursive:!0}),I(),f||await kt(m,e.framework,e.agentId,e.cozeIdentity),e.framework==="claude-code"&&await Ns(m),I();let P=await me(e.agentId,this.paths).catch(()=>null),B=Hs({model:e.model??P?.model}),j=Ls(e._meta)??P?.accountId,H=e.patToken??P?.patToken,ce=u==="cloud"?e.modelInfo??P?.modelInfo:void 0;if(E=new Kn({agentId:e.agentId,framework:e.framework,workspace:m,model:B.model??Me,deployType:u,...j?{accountId:j}:{},...H?{patToken:H}:{},...ce?{modelInfo:ce}:{}}),E.status="ok",P?.sessions){for(let[De,ue]of Object.entries(P.sessions))E.sessions.set(De,{acpSessionId:ue.acpSessionId,modelToken:ue.modelToken,tokenGeneratedAt:ue.tokenGeneratedAt,lastActiveAt:Date.now(),loadingSession:!1,replySeq:0});let ye=Object.keys(P.sessions).length;ye>0&&we.info("restored persisted session records (no spawn)",{agentId:e.agentId,count:ye})}this.registry.register(E),C=!0;let W={agentId:e.agentId,framework:e.framework,workspace:m,cozeIdentity:e.cozeIdentity,createdAt:P?.createdAt??Date.now(),sessions:P?.sessions??{},model:B.model};u==="cloud"&&(W.deployType="cloud"),j&&(W.accountId=j),H&&(W.patToken=H),ce&&(W.modelInfo=ce),P?.skills&&(W.skills=P.skills),P?.agentName&&(W.agentName=P.agentName),P?.description&&(W.description=P.description),e.framework==="openclaw"&&u==="cloud"&&(this.config.frameworksCache?.openclaw?.path?await this.getOpenclawConfig().ensureAgent(e.agentId,m):we.warn("openclaw binary not on this machine, skip agents add (will fail at session/prompt)",{agentId:e.agentId}));let he=e.initialSkills??[];if(he.length>0){let ye=[...W.skills??[]],De=new Map(ye.map((A,L)=>[A.skillId,L])),ue=await Promise.allSettled(he.map(A=>ti({agentId:e.agentId,workspace:m,framework:e.framework,skill:A}))),_e=0;for(let[A,L]of ue.entries()){let z=he[A];z&&(L.status==="fulfilled"?(ni(ye,De,L.value),_e++):we.warn("initialSkill install failed (skipping)",{agentId:e.agentId,skillId:z.skillId,skillName:z.skillName,err:String(L.reason)}))}_e>0&&(W.skills=ye,we.info("initialSkills installed",{agentId:e.agentId,installed:_e,requested:he.length}))}return await Ee(W,this.paths),we.info("agent created (no spawn, lazy on first prompt)",{agentId:e.agentId,framework:e.framework,deployType:u}),{ok:!0,agentId:e.agentId,workspace:m,framework:e.framework}}catch(I){throw we.error("agent create failed, rolling back",{agentId:e.agentId,err:String(I)}),C&&E&&(await E.dispose("rollback").catch(()=>{}),this.registry.unregister(e.agentId)),await Sd(x.root,{recursive:!0,force:!0}).catch(P=>we.warn("rm agent dir failed (ignored)",{err:String(P)})),I instanceof b?I:new b("AGENT_SPAWN_FAILED",String(I),{cause:I})}finally{clearTimeout(_)}}async spawnSessionDownstream(e,s,o,c){let u=this.config.frameworksCache?.[e.framework];if(!u)if(e.deployType==="cloud"&&oi(e.framework))u=Id;else throw new b("AGENT_SPAWN_FAILED",`framework ${e.framework} not detected on this machine`);if(oi(e.framework)&&!Pt(e.framework)){let m=vs(e.framework);m&&(we.info("spawn: awaiting in-flight acp install (D92)",{agentId:e.agentId,framework:e.framework}),await Promise.race([m.catch(()=>{}),new Promise(y=>setTimeout(y,this.spawnAwaitInstallMs))]))}let f=e.deployType==="cloud"?{model:e.model,modelToken:s,...e.modelInfo?{modelInfo:e.modelInfo}:{}}:void 0,g;e.framework==="openclaw"?g=await this.buildOpenclawDownstream({session:e,modelConfig:f,cloudSessionId:o,cozeEnv:c,command:u.path}):g=this.factory(e.framework,u.path,e.workspace,e.agentId,f,o,c,this.buildBinShimPathEnv());try{return await g.start(),await g.initialize(Ad),g}catch(m){let y=g instanceof Fe?g.getStderrTail():[];y.length>0&&we.warn("spawnSessionDownstream failed, recent stderr (D94)",{agentId:e.agentId,framework:e.framework,method:m instanceof b?m.code:"unknown",recentStderr:y});let _=ri(y);await g.stop("spawnSessionDownstream failed").catch(()=>{});let E=_?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:m}):m;throw m instanceof b?new b(m.code,m.message,{retriable:m.retriable,cause:E}):new b("AGENT_SPAWN_FAILED",m instanceof Error?m.message:String(m),{cause:E})}}async buildOpenclawDownstream(e){let{session:s,modelConfig:o,cloudSessionId:c,cozeEnv:x,command:u}=e,f=ii(c);if(s.deployType==="local"){let _=this.config.frameworksCache?.openclaw?.defaultAgent;if(!_?.id||!_.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 Ot({command:u,cwd:_.workspace,agentId:_.id,sessionName:f})}let g=await mo(),m=o?Js(o,x):null,y;if(m){let _=Qr(c),C=m.models[0]?.id??Me,I=`${_}/${C}`;if(!this.ensuredProviders.has(I)){let P=this.getOpenclawConfig();await P.ensureProvider(_,m),await P.addModelToAllowlist(I),this.ensuredProviders.add(I)}y=I}return new Ot({command:u,cwd:s.workspace,agentId:s.agentId,sessionName:f,...g?{gatewayToken:g}:{},...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 c=Qr(o),x=`${c}/${e.model}`,u=!0;try{await s.removeProvider(c)}catch(f){u=!1,we.warn("removeProvider failed, keeping ensuredProviders entry",{providerId:c,err:String(f)})}try{await s.removeModelFromAllowlist(x)}catch(f){u=!1,we.warn("removeModelFromAllowlist failed, keeping ensuredProviders entry",{fullModelId:x,err:String(f)})}u&&this.ensuredProviders.delete(x)}}};import{randomUUID as vo}from"node:crypto";import{promises as Fd}from"node:fs";import{basename as So}from"node:path";import{promises as kd}from"node:fs";import{basename as Dd}from"node:path";U();var wo=R("file-upload"),Rd="/api/coze_claw/file/agent_upload",Nd=6e4;async function _o(n,e={}){let o=`${Ln(Mn(e.handshakeBase))}${Rd}`,c=e.timeoutMs??Nd,x=await kd.readFile(n.path),u=new FormData;u.append("agent_id",n.agentId),u.append("session_id",n.sessionId),u.append("file_name",n.name),u.append("file_content",new Blob([x],{type:n.mimeType}),n.name);let f={Authorization:`Bearer ${n.patToken}`,Accept:"application/json","x-coze-version":"3.0",...Rt(e.ppeOverride),...n.accountId?{"x-coze-account":n.accountId}:{}},g=new AbortController,m=setTimeout(()=>g.abort(),c);wo.info("file upload start",{url:o,agentId:n.agentId,sessionId:n.sessionId,name:n.name,bytes:n.sizeBytes,mime:n.mimeType});try{let y=await fetch(o,{method:"POST",headers:f,body:u,signal:g.signal}),_=y.headers.get("x-tt-logid")??"";if(!y.ok){let I=await y.text().catch(()=>"");throw new b("UPLOAD_FAILED",`upload HTTP ${y.status} logid=${_}: ${I.slice(0,200)}`)}let E=await y.json();if(E.code!==void 0&&E.code!==0)throw new b("UPLOAD_FAILED",`upload code=${E.code} msg=${E.msg??"-"} logid=${_}`);let C=E.data?.file?.file_url;if(!C)throw new b("UPLOAD_FAILED",`upload response missing data.file.file_url logid=${_}: ${JSON.stringify(E).slice(0,200)}`);return wo.info("file upload ok",{uri:C,logid:_}),{uri:C}}catch(y){throw y instanceof b?y:y.name==="AbortError"?new b("UPLOAD_FAILED",`upload timeout (${c}ms) for ${Dd(n.path)}`):new b("UPLOAD_FAILED",String(y),{cause:y})}finally{clearTimeout(m)}}U();import{promises as Ld}from"node:fs";import{extname as Od}from"node:path";var Md=[{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 Bd(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 zd={".txt":"text/plain",".md":"text/markdown",".svg":"image/svg+xml",".json":"application/json"};async function yo(n){let e=await Ld.open(n,"r");try{let s=Buffer.alloc(16);if(await e.read(s,0,16,0),Bd(s))return"image/webp";for(let o of Md)if(o.prefix.every((c,x)=>s[x]===c))return o.mime}finally{await e.close()}return zd[Od(n).toLowerCase()]??"application/octet-stream"}ae();var ai=R("agent-send"),bo=50*1024*1024,Ud=new Set(["image/png","image/jpeg","image/webp","image/gif","image/svg+xml","application/pdf","application/json","text/plain","text/markdown"]);function Eo(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 c=o.sessions.get(s);if(!c)throw new b("AGENT_NOT_FOUND",`session=${s} not active in agent=${e}`);return{session:o,runtime:c}}async function Io(n,e,s,o,c,x){let f;for(let g=0;g<=2;g++)try{await n.core.sendAgentFileUpdate(e,s,o,c);return}catch(m){f=m,g<2&&(ai.warn("sendAgentFileUpdate failed, retrying",{attempt:g+1,err:String(m)}),await new Promise(y=>setTimeout(y,5e3)))}throw new b("UPSTREAM_NOT_READY",`${x} after 3 attempts: ${String(f)}`,{cause:f})}async function Ao(n,e){let{session:s,runtime:o}=Eo(e.core,n.agentId,n.sessionId);if(!await Ts(n.path,s.workspace))throw new b("PATH_OUTSIDE_WORKSPACE",`path=${n.path} not under workspace=${s.workspace}`);let c=await Fd.stat(n.path).catch(()=>null);if(!c||!c.isFile())throw new b("IPC_BAD_REQUEST",`path is not a regular file: ${n.path}`);if(c.size>bo)throw new b("FILE_TOO_LARGE",`${c.size} bytes > limit ${bo}`);let x=await yo(n.path);if(!Ud.has(x))throw new b("UNSUPPORTED_MIME",`mime=${x} not in whitelist`);if(n.kind==="image"&&!x.startsWith("image/"))throw new b("UNSUPPORTED_MIME",`kind=image but mime=${x}`);if(!e.core.upstream.isConnected())throw new b("UPSTREAM_NOT_READY","cloud WS not connected");let u=n.name??So(n.path),f=await _o({patToken:s.patToken??e.patToken,agentId:n.agentId,sessionId:n.sessionId,path:n.path,mimeType:x,name:u,sizeBytes:c.size,...s.accountId?{accountId:s.accountId}:{}},{handshakeBase:e.handshakeBase,ppeOverride:e.ppeOverride}),g={sessionUpdate:"agent_file",messageId:vo(),content:{type:n.kind==="image"?"image":"resource",uri:f.uri,mimeType:x,name:u,sizeBytes:c.size,...f.fileId!==void 0?{fileId:f.fileId}:{},...n.caption!==void 0?{caption:n.caption}:{}}};return await Io(e,s,o,n.sessionId,g,"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:c.size,mime:x,uri:f.uri}),{ok:!0,uri:f.uri,bytes:c.size,mimeType:x,...f.fileId!==void 0?{fileId:f.fileId}:{}}}async function Co(n,e){let{session:s,runtime:o}=Eo(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 c=n.name??So(n.path),x={sessionUpdate:"group_file",messageId:vo(),content:{uri:n.path,name:c,mimeType:n.mimeType,...n.caption!==void 0?{caption:n.caption}:{}}};return await Io(e,s,o,n.sessionId,x,"agent group file sendAgentFileUpdate failed"),ai.info("agent group file sent",{agentId:n.agentId,sessionId:n.sessionId,uri:n.path,name:c,mime:n.mimeType}),{ok:!0,uri:n.path,bytes:0,mimeType:n.mimeType}}import{execFile as qd}from"node:child_process";import{promisify as Gd}from"node:util";function Vn(n,e){let s=n.split(".").map(Number),o=e.split(".").map(Number),c=Math.max(s.length,o.length);for(let x=0;x<c;x++){let u=s[x]??0,f=o[x]??0;if(u<f)return!0;if(u>f)return!1}return!1}U();var Hd=Gd(qd),Ue=R("coze-cli-installer"),Po="@coze/cli@latest",Kd="coze",To="0.1.7",Wd=5e3,jd=5e3,$d=9e4,ko=1e4,an=null,Jn=!1;async function ci(n,e={}){if(Jn)return;if(an)return an;let s=e.exec??Hd;return an=(async()=>{try{let o=await Vd(Kd,s),c=!1;if(o){let u=await Jd(s);if(u===void 0)Ue.warn("coze-cli found but version unparseable, fall through to full install",{path:o});else if(Vn(u,To))Ue.info("coze-cli version too old, upgrade-only (preserve user config + auth)",{path:o,version:u,min:To}),c=!0;else{Ue.info("coze-cli already on PATH with sufficient version, skip",{path:o,version:u}),Jn=!0;return}}let x=c?"upgrade-only":"full";Ue.info("coze-cli install start",{package:Po,mode:x});try{await s("npm",["i","-g","--prefer-online",Po],{timeout:$d,maxBuffer:10*1024*1024}),Ue.info("coze-cli install ok")}catch(u){Ue.warn("coze-cli install failed (skip subsequent steps)",{err:String(u)});return}if(c){Jn=!0;return}if(n.env)try{await s("coze",["config","set","xTTEnv",n.env],{timeout:ko}),Ue.info("coze config set xTTEnv ok",{env:n.env})}catch(u){Ue.warn("coze config set failed (continue to auth login)",{err:String(u)})}try{await s("coze",["auth","login","--token",n.patToken],{timeout:ko}),Ue.info("coze auth login ok")}catch(u){Ue.warn("coze auth login failed",{err:String(u)});return}Jn=!0}finally{an=null}})(),an}async function Vd(n,e){let s=process.platform==="win32"?"where":"which";try{let{stdout:o}=await e(s,[n],{timeout:Wd});return o.split(`
120
+ `)[0]?.trim()||void 0}catch{return}}async function Jd(n){try{let{stdout:e,stderr:s}=await n("coze",["--version"],{timeout:jd});return(e||s).match(/(\d+\.\d+\.\d+)/)?.[1]}catch{return}}U();import{spawn as Yd}from"node:child_process";import{constants as Do,access as Zd}from"node:fs/promises";import{delimiter as Xd,join as Qd}from"node:path";var Ro=R("framework-detector"),No={"claude-code":"claude",codex:"codex",openclaw:"openclaw"},eu=[".exe",".cmd",".bat",".ps1"],Bt=class{env;constructor(e={}){this.env={pathEnv:e.pathEnv??process.env.PATH??"",platform:e.platform??process.platform,spawn:e.spawn??Yd,access:e.access??Zd}}async detect(e){let s=No[e],o=await this.which(s);if(!o)return Ro.debug("framework binary not found",{framework:e,bin:s}),null;let c=e==="openclaw"?["--log-level","silent"]:[],[x,u]=await Promise.all([this.probeVersion(o,c),e==="openclaw"?this.probeOpenclawDefaultAgent(o):Promise.resolve(null)]),f={path:o,version:x};return u&&(f.defaultAgent=u),f}async detectAll(){let e=await Promise.all(Object.keys(No).map(async o=>[o,await this.detect(o)])),s={};for(let[o,c]of e)c&&(s[o]=c);return s}async which(e){let s=this.env.pathEnv.split(Xd).filter(Boolean),o=this.env.platform==="win32"?["",...eu]:[""];for(let c of s)for(let x of o){let u=Qd(c,e+x);if(await this.isExecutable(u))return u}return null}async isExecutable(e){try{let s=this.env.platform==="win32"?Do.F_OK:Do.X_OK;return await this.env.access(e,s),!0}catch{return!1}}async probeOpenclawDefaultAgent(e){let s=await this.runProbe(e,["--log-level","silent","agents","list","--json"]);if(!s||s.code!==0)return null;let o=s.stdout.match(/\[\s*\{[\s\S]*\}\s*\]/);if(!o)return null;try{let c=JSON.parse(o[0]);if(!Array.isArray(c))return null;let x=c.find(u=>u?.isDefault===!0);return!x?.id||!x.workspace?null:{id:x.id,workspace:x.workspace}}catch(c){return Ro.warn("openclaw agents list --json parse failed",{err:String(c)}),null}}async probeVersion(e,s=[]){let o=await this.runProbe(e,[...s,"--version"]);return o&&(nu(o.stdout).split(/\r?\n/)[0]??"").trim()||"unknown"}runProbe(e,s){return new Promise(o=>{let c="",x=!1,u,f=g=>{x||(x=!0,u&&clearTimeout(u),o(g))};try{let g=this.env.spawn(e,s,{stdio:["ignore","pipe","pipe"]});u=setTimeout(()=>{g.kill("SIGKILL"),f(null)},5e3),g.stdout?.on("data",m=>{c+=m.toString("utf8")}),g.on("error",()=>f(null)),g.on("close",m=>f({code:m,stdout:c}))}catch{f(null)}})}},tu=new RegExp("\x1B\\[[0-9;]*[A-Za-z]","g");function nu(n){return n.replace(tu,"")}zt();import{randomBytes as bu}from"node:crypto";import{createReadStream as iu}from"node:fs";import{mkdir as su,readFile as ou,realpath as au,stat as cu,writeFile as xu}from"node:fs/promises";import{basename as du,dirname as xi,join as uu,relative as fu,resolve as Oo,sep as lu}from"node:path";import{createInterface as gu}from"node:readline";U();var Bo=R("fs-rpc"),cn=ct("COZE_BRIDGE_FS_RPC_MAX_BYTES",20*1024*1024);async function zo(n,e){let s=Buffer.byteLength(n.content,"utf8");if(s>cn)throw new b("IPC_BAD_REQUEST",`fs/write_text_file content too large: ${s} bytes > limit ${cn} bytes`);let o=await Uo(n.path,e);return await su(xi(o),{recursive:!0}),await xu(o,n.content,"utf8"),Bo.info("fs/write_text_file ok",{path:o,size:n.content.length}),null}async function Fo(n,e){let s=await Uo(n.path,e),o=await cu(s),c=typeof n.line=="number"||typeof n.limit=="number";if(o.size>cn&&!c)throw new b("IPC_BAD_REQUEST",`fs/read_text_file too large without line/limit slicing: ${o.size} bytes > ${cn} bytes`);let x;if(c&&o.size>cn)x=await hu(s,n.line??1,n.limit);else{let u=await ou(s,"utf8");if(c){let f=u.split(`
121
+ `),g=Math.max(0,(n.line??1)-1),m=typeof n.limit=="number"?g+n.limit:void 0;x=f.slice(g,m).join(`
122
+ `)}else x=u}return Bo.info("fs/read_text_file ok",{path:s,size:x.length}),{content:x}}async function hu(n,e,s){let o=gu({input:iu(n,{encoding:"utf8"}),crlfDelay:Number.POSITIVE_INFINITY}),c=Math.max(0,e-1),x=typeof s=="number"?c+s:Number.POSITIVE_INFINITY,u=[],f=0;try{for await(let g of o)if(f>=c&&f<x&&u.push(g),f++,f>=x)break}finally{o.close()}return u.join(`
123
+ `)}async function Uo(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([Mo(Oo(e)),Mo(Oo(n))]),c=fu(s,o);if(c.startsWith("..")||c===".."||c.startsWith(`..${lu}`))throw new b("IPC_BAD_REQUEST",`path escapes workspace: ${n}`);return o}async function Mo(n){let e=[],s=n;for(;s!==xi(s);)try{let o=await au(s);return e.length?uu(o,...e.reverse()):o}catch{e.push(du(s)),s=xi(s)}return n}U();var qo=R("prompt-multimodal"),Go=10*1024*1024,pu=15e3,mu=6;async function Ho(n){let e=new Array(n.length),s=0;async function o(){for(;s<n.length;){let x=s++,u=n[x];u!==void 0&&(e[x]=await wu(u))}}let c=Array.from({length:Math.min(mu,n.length)},()=>o());return await Promise.all(c),e}function Ko(n){return n.some(e=>e.type==="image")}async function wu(n){if(n.type!=="image")return n;let e=n;if(e.data||!e.uri||!Nn(e.uri))return n;try{let{buf:s,contentType:o}=await yu(e.uri),c=e.mimeType||_u(o)||"application/octet-stream";return qo.info("image uri fetched and inlined",{uri:e.uri,bytes:s.length,mimeType:c}),{type:"image",data:s.toString("base64"),mimeType:c}}catch(s){return qo.warn("image fetch failed, degrading to text block",{uri:e.uri,err:String(s)}),{type:"text",text:`[image load failed: ${e.uri}]`}}}function _u(n){if(!n)return;let e=n.indexOf(";");return(e===-1?n:n.slice(0,e)).trim()||void 0}async function yu(n){let e=new AbortController,s=setTimeout(()=>e.abort(),pu);try{let o=await fetch(n,{signal:e.signal});if(!o.ok)throw new Error(`HTTP ${o.status} ${o.statusText}`);let c=await o.arrayBuffer();if(c.byteLength>Go)throw new Error(`image too large: ${c.byteLength} bytes (max ${Go})`);return{buf:Buffer.from(c),contentType:o.headers.get("content-type")??void 0}}finally{clearTimeout(s)}}st();zt();U();var F=R("core"),vu=3e4,Su=/^(boe|ppe)_[A-Za-z0-9_-]+$/,Eu=3e4,Iu=new Set(["_agent/create","session/new","session/load","session/prompt"]),Yn=class{upstream;agents=new Map;disconnectedAgents=new Set;extensions;paths;sessionSpawner;sessionIdleTimeoutMs;upgradeGate;upstreamIds=new Lt;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(),F.info("Core started",{extensions:Object.keys(this.extensions)})}async stop(e){F.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),F.info("agent registered",{agentId:e.agentId,framework:e.framework});for(let s of this.registerHandlers)try{s(e.agentId)}catch(o){F.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)&&F.info("agent revived from disconnect",{agentId:e})}attachRuntimeHooks(e,s,o){let c=o.downstream;c&&(c.onUpdate(x=>{o.loadingSession||this.forwardUpdate(e,x)}),c.onAgentRequest(x=>{this.handleAgentRequest(e,c,x)}),c.onExit((x,u)=>{F.info("session runtime exited",{agentId:e.agentId,cloudId:s,code:x,signal:u}),on(o),o.downstream=void 0,o.replySeq=0,o.acpSessionId&&e.activeTriggers.delete(o.acpSessionId),this.rejectPendingForDownstream(c,"downstream exited")}))}hasPendingPermissionFor(e){for(let s of this.pendingUpstream.values())if(s.downstream===e)return!0;return!1}rejectPendingForDownstream(e,s){let o=[];for(let[c,x]of this.pendingUpstream)x.downstream===e&&o.push(c);if(o.length!==0){F.info("reject pendingUpstream entries (downstream gone)",{reason:s,count:o.length});for(let c of o){let x=this.pendingUpstream.get(c);if(x){this.pendingUpstream.delete(c),this.upstream.send(at(c,{code:G.INTERNAL_ERROR,message:`bridge downstream gone: ${s}`})).catch(u=>F.debug("send error response to upstream failed (ignored)",{err:String(u)}));try{x.downstream.respondAgentRequestError(x.agentRequestId,{code:G.INTERNAL_ERROR,message:`bridge: ${s}`})}catch{}}}}}rejectAllPendingOnReconnect(){let e=this.pendingUpstream.size,s=this.pendingBridge.size;if(!(e===0&&s===0)){F.warn("upstream reconnected, rejecting stale pending requests",{pendingUpstream:e,pendingBridge:s});for(let[,o]of this.pendingUpstream)try{o.downstream.respondAgentRequestError(o.agentRequestId,{code:G.INTERNAL_ERROR,message:"upstream reconnected; please retry"})}catch{}this.pendingUpstream.clear();for(let[,o]of this.pendingBridge)clearTimeout(o.timer),o.reject(new b("UPSTREAM_DISCONNECTED",`${o.method} aborted: upstream reconnected`));this.pendingBridge.clear()}}async handleFrame(e){if(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&&Su.test(o)?this.currentCozeEnv=o:o&&F.warn("rejecting cozeEnv with invalid shape, keeping previous",{rejected:o});try{if(this.upgradeGate?.isUpgrading()&&Iu.has(e.method)){let c=this.upgradeGate.pendingTarget()??"";throw new b("BRIDGE_UPGRADING",`bridge upgrading to ${c}, retry shortly`,{retriable:!0})}if(e.method.startsWith("_agent/")){let c=this.extensions[e.method];if(!c){s!==null?await this.sendError(s,G.METHOD_NOT_FOUND,`extension not registered: ${e.method}`):F.warn("drop notification: extension not registered",{method:e.method});return}let x=await c(e,this);s!==null&&await this.upstream.send(Nt(s,x));return}if(e.method.startsWith("session/")){let c=await this.routeSessionMethod(e);s!==null&&await this.upstream.send(Nt(s,c));return}if(e.method==="initialize"){s!==null&&await this.upstream.send(Nt(s,{protocolVersion:1,agentCapabilities:{loadSession:!0}}));return}s!==null?await this.sendError(s,G.METHOD_NOT_FOUND,`method not implemented: ${e.method}`):F.warn("drop unknown notification",{method:e.method})}catch(c){F.error("handleFrame failed",{method:e.method,err:String(c)}),s!==null&&await this.upstream.send(at(s,sn(c)))}}async routeSessionMethod(e){if(!e.params||typeof e.params!="object")throw new b("IPC_BAD_REQUEST",`${e.method} requires params`);let s=e.params,o=s._meta?.cozeAgentId;if(!o)throw new b("IPC_BAD_REQUEST",`${e.method}: missing _meta.cozeAgentId`);let c=this.agents.get(o);if(!c)throw this.disconnectedAgents.has(o)?new b("AGENT_DISCONNECTED",`agent ${o} has been disconnected; cloud must _agent/create to revive`):new b("AGENT_NOT_FOUND",`agent not found: ${o}`);let x=typeof s.sessionId=="string"?s.sessionId:void 0;if(e.method==="session/cancel"||e.method==="session/new"||!x)return this.dispatchSessionCall(c,e.method,s);let u=Date.now(),f=!1,g=e.method==="session/prompt";g&&this.upgradeGate?.incActive();try{let m=await c.getSessionQueue(x).enqueue(()=>this.dispatchSessionCall(c,e.method,s));return f=!0,m}finally{g&&this.upgradeGate?.decActive(),F.info("session call done",{agentId:c.agentId,method:e.method,durationMs:Date.now()-u,ok:f})}}async dispatchSessionCall(e,s,o){e.lastActiveAt=Date.now();let{stripped:c}=Ms(o);switch(s){case"session/new":{let x=Au();return F.info("session/new ack (lazy spawn)",{agentId:e.agentId,cloudId:x}),{sessionId:x}}case"session/load":{let x=c;return F.info("session/load ack (lazy spawn)",{agentId:e.agentId,cloudId:x.sessionId}),{}}case"session/prompt":{let x=c,u=x.sessionId;if(!u)throw new 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 g=o._meta?.cozeTriggerMsgId;g?e.activeTriggers.set(f.acpSessionId,g):e.activeTriggers.delete(f.acpSessionId);let m=Os(o._meta);if(m?e.activeGroupIds.set(f.acpSessionId,m):e.activeGroupIds.delete(f.acpSessionId),e.deployType==="cloud"&&e.modelInfo?.capabilities?.image===!1&&Ko(x.prompt))throw new b("MODEL_MODALITY_UNSUPPORTED",`model=${e.modelInfo.id??e.model} does not support image input`);let y=await Ho(x.prompt);try{let _=await f.downstream.sessionPrompt({...x,sessionId:f.acpSessionId,prompt:y});return f.lastActiveAt=Date.now(),_}finally{if(e.activeTriggers.delete(f.acpSessionId),e.activeGroupIds.delete(f.acpSessionId),f.reloadAfterTurn){f.reloadAfterTurn=!1;let _=f.downstream;_&&(f.downstream=void 0,F.info("reloadAfterTurn: stopping downstream",{agentId:e.agentId,cloudId:u,acpId:f.acpSessionId}),_.stop("reload-after-turn").catch(E=>F.warn("reload-after-turn stop failed (ignored)",{agentId:e.agentId,cloudId:u,err:String(E)})))}else f.downstream?.isAlive()&&this.armIdleTimer(e,u,f)}}case"session/cancel":{let u=c.sessionId;if(!u)throw new b("IPC_BAD_REQUEST","session/cancel: missing sessionId");let f=e.sessions.get(u);if(e.hasSessionQueue(u)){let g=e.getSessionQueue(u);g.size>0&&(F.info("session/cancel: draining queued tasks",{agentId:e.agentId,cloudId:u,queuedCount:g.size}),g.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 x={modelToken:e.deployType==="cloud"?await this.requestSessionToken(e.agentId,s):"",tokenGeneratedAt:Date.now(),lastActiveAt:Date.now(),loadingSession:!1,replySeq:0};return e.sessions.set(s,x),await this.persistSessionMapping(e),x}async requestSessionToken(e,s){let o={sessionId:s,_meta:{cozeAgentId:e}};try{let c=await this.sendRequest(Oe.GEN_MODEL_TOKEN,o,Eu);if(!c?.modelToken)throw new b("MODEL_TOKEN_GEN_FAILED",`cloud returned empty modelToken (agentId=${e}, cloudSessionId=${s})`);return c.modelToken}catch(c){throw c instanceof b&&c.code==="MODEL_TOKEN_GEN_FAILED"?c:new b("MODEL_TOKEN_GEN_FAILED",c instanceof Error?c.message:String(c),{cause:c})}}async ensureDownstream(e,s,o){if(on(o),o.downstream?.isAlive())return;if(!this.sessionSpawner)throw new b("AGENT_SPAWN_FAILED","sessionSpawner not wired (cannot spawn per-session downstream)");let c=3,x=3e4,u=o.spawnFailCount??0,f=o.spawnFailedAt??0;if(u>=c&&Date.now()-f<x)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((x-(Date.now()-f))/1e3)}s`);let g;try{g=await this.sessionSpawner(e,o.modelToken,s,this.currentCozeEnv)}catch(m){throw o.spawnFailCount=u+1,o.spawnFailedAt=Date.now(),o.spawnFailCount>=c&&o.acpSessionId&&(F.warn("clearing stale acpSessionId after repeated spawn failures",{agentId:e.agentId,cloudId:s,staleAcpId:o.acpSessionId}),o.acpSessionId=void 0),m}if(o.spawnFailCount=0,o.spawnFailedAt=void 0,o.downstream=g,this.attachRuntimeHooks(e,s,o),o.acpSessionId){o.loadingSession=!0;try{await g.sessionLoad({sessionId:o.acpSessionId,cwd:e.workspace}),F.info("session restored via session/load",{agentId:e.agentId,cloudId:s,acpId:o.acpSessionId})}catch(m){F.warn("session/load failed, fallback to session/new",{agentId:e.agentId,cloudId:s,acpId:o.acpSessionId,err:String(m)}),o.acpSessionId=void 0;let y=await g.sessionNew({cwd:e.workspace});o.acpSessionId=y.sessionId,await this.persistSessionMapping(e)}finally{o.loadingSession=!1}}else{let m=await g.sessionNew({cwd:e.workspace});o.acpSessionId=m.sessionId,await this.persistSessionMapping(e)}g.afterSessionEstablished&&o.acpSessionId&&await g.afterSessionEstablished(o.acpSessionId)}armIdleTimer(e,s,o){if(on(o),this.isRuntimeBusy(e,o)){F.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)){F.info("idle reaper fired but runtime busy, re-arming",{agentId:e.agentId,cloudId:s}),this.armIdleTimer(e,s,o);return}F.info("session runtime idle timeout, killing downstream",{agentId:e.agentId,cloudId:s});let c=o.downstream;o.downstream=void 0,o.acpSessionId&&e.activeTriggers.delete(o.acpSessionId),c&&c.stop("idle timeout").catch(x=>F.warn("idle stop failed (ignored)",{agentId:e.agentId,cloudId:s,err:String(x)}))},this.sessionIdleTimeoutMs),o.idleTimer.unref?.()}isRuntimeBusy(e,s){if(s.acpSessionId&&e.activeTriggers.has(s.acpSessionId))return!0;let o=s.downstream;if(!o)return!1;for(let c of this.pendingUpstream.values())if(c.downstream===o)return!0;return!1}async sendAgentFileUpdate(e,s,o,c){let x={cozeAgentId:e.agentId,cozeReplySeqID:++s.replySeq};if(s.acpSessionId){let u=e.activeTriggers.get(s.acpSessionId);u&&(x.cozeTriggerMsgId=u);let f=e.activeGroupIds.get(s.acpSessionId);f&&(x.cozeGroupId=f)}await this.upstream.send(nn("session/update",{sessionId:o,update:c,_meta:x}))}forwardUpdate(e,s){let o=s.sessionId,c=this.reverseSessionId(e,o);if(!c){F.debug("drop update for unknown session",{agentId:e.agentId,acpId:o});return}let x=e.sessions.get(c);if(!x){F.debug("drop update: runtime gone",{agentId:e.agentId,cloudId:c});return}if(Pu(s)){F.debug("drop codex metadata-warn chunk",{agentId:e.agentId,acpId:o});return}let u={cozeAgentId:e.agentId,cozeReplySeqID:++x.replySeq},f=e.activeTriggers.get(o);f&&(u.cozeTriggerMsgId=f);let g=e.activeGroupIds.get(o);g&&(u.cozeGroupId=g),this.upstream.send(nn("session/update",{...s,sessionId:c,_meta:u})).catch(m=>F.warn("forward update failed",{agentId:e.agentId,err:String(m)}))}handleAgentRequest(e,s,o){if(o.method==="session/request_permission"){this.forwardPermissionRequest(e,s,o);return}if(o.method==="fs/write_text_file"||o.method==="fs/read_text_file"){this.handleFsRpcRequest(e,s,o);return}F.warn("unhandled agent request,returning method_not_found",{agentId:e.agentId,method:o.method}),s.respondAgentRequestError(o.id,{code:G.METHOD_NOT_FOUND,message:`method not handled by Bridge: ${o.method}`})}async handleFsRpcRequest(e,s,o){try{let c=e.workspace;if(o.method==="fs/write_text_file"){let x=o.params??{},u=await zo(x,c);s.respondAgentRequest(o.id,u)}else{let x=o.params??{},u=await Fo(x,c);s.respondAgentRequest(o.id,u)}}catch(c){F.warn("fs rpc handler failed",{agentId:e.agentId,method:o.method,err:String(c)}),s.respondAgentRequestError(o.id,sn(c))}}forwardPermissionRequest(e,s,o){let c=this.upstreamIds.next("session/request_permission"),x=o.params??{},f=x.sessionId,g=f?e.activeTriggers.get(f):void 0,m={cozeAgentId:e.agentId};g&&(m.cozeTriggerMsgId=g);let y=f?e.activeGroupIds.get(f):void 0;y&&(m.cozeGroupId=y);let _=f?this.reverseSessionId(e,f):void 0,E={...x,..._?{sessionId:_}:{},_meta:m};this.pendingUpstream.set(c,{agentRequestId:o.id,agentId:e.agentId,downstream:s,method:o.method}),F.info("forward permission_request \u2192 upstream",{agentId:e.agentId,upstreamId:c,acpSessionId:f,cloudSessionId:_,toolCallId:x.toolCall?.toolCallId,options:x.options?.map(C=>({optionId:C.optionId,kind:C.kind,name:C.name}))}),this.upstream.send(tn(c,"session/request_permission",E)).catch(C=>{this.pendingUpstream.delete(c),F.error("forward permission request failed",{agentId:e.agentId,err:String(C)}),s.respondAgentRequestError(o.id,{code:G.INTERNAL_ERROR,message:`upstream send failed: ${String(C)}`})})}handleUpstreamResponse(e){if(e.id===null)return;let s=this.lookupPending(this.pendingUpstream,e.id,"upstream");if(s){this.pendingUpstream.delete(s.key);let c=s.value;e.error?(F.info("upstream \u2192 permission response (error)",{agentId:c.agentId,upstreamId:e.id,method:c.method,error:e.error}),c.downstream.respondAgentRequestError(c.agentRequestId,e.error)):(c.method==="session/request_permission"&&Cu(e.result,c),F.info("upstream \u2192 permission response (result)",{agentId:c.agentId,upstreamId:e.id,method:c.method,result:e.result}),c.downstream.respondAgentRequest(c.agentRequestId,e.result));return}let o=this.lookupPending(this.pendingBridge,e.id,"bridge");if(o){this.pendingBridge.delete(o.key),clearTimeout(o.value.timer),e.error?o.value.reject(new Fn(e.error)):o.value.resolve(e.result);return}F.debug("orphan upstream response (no pending)",{id:e.id})}lookupPending(e,s,o){let c=e.get(s);if(c)return{value:c,key:s};if(typeof s=="number"){let x=String(s),u=e.get(x);if(u)return F.warn(`${o} id type mismatch: number received but Bridge expected string`,{rawId:s,normalizedId:x}),{value:u,key:x}}}sendRequest(e,s,o=vu){let c=this.upstreamIds.next(e);return new Promise((x,u)=>{let f=setTimeout(()=>{this.pendingBridge.delete(c),u(new b("AGENT_TIMEOUT",`${e} timed out after ${o}ms`))},o);this.pendingBridge.set(c,{method:e,resolve:x,reject:u,timer:f}),this.upstream.send(tn(c,e,s)).catch(g=>{let m=this.pendingBridge.get(c);m&&(clearTimeout(m.timer),this.pendingBridge.delete(c)),u(g)})})}async persistSessionMapping(e){if(this.paths)try{let s=new Map;for(let[o,c]of e.sessions){let x={modelToken:c.modelToken,tokenGeneratedAt:c.tokenGeneratedAt};c.acpSessionId&&(x.acpSessionId=c.acpSessionId),s.set(o,x)}await Vr(e.agentId,s,this.paths)}catch(s){F.warn("persist session mapping failed",{agentId:e.agentId,err:String(s)})}}reverseSessionId(e,s){for(let[o,c]of e.sessions.entries())if(c.acpSessionId===s)return o}sendError(e,s,o){return this.upstream.send(at(e,{code:s,message:o,data:{bridgeVersion:ot}}))}};function Au(){return bu(16).toString("hex")}function Cu(n,e){if(!n||typeof n!="object"){F.warn("permission response: result not an object (suspicious)",{agentId:e.agentId,result:n});return}let s=n;if("kind"in s&&!("outcome"in s)){F.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"){F.warn("permission response: missing or non-object outcome field",{agentId:e.agentId,result:n});return}let x=o.outcome;(typeof x!="string"||x!=="selected"&&x!=="cancelled")&&F.warn("permission response: unknown outcome discriminant",{agentId:e.agentId,outcomeValue:x,result:n})}function Pu(n){let e=n.update;if(e?.sessionUpdate!=="agent_message_chunk")return!1;let s=e.content;if(!s||typeof s!="object")return!1;let o=s;return o.type!=="text"||typeof o.text!="string"?!1:o.text.startsWith("Model metadata for `")}U();ae();import{randomBytes as Tu}from"node:crypto";import{chmod as ku,mkdir as Du,writeFile as Wo}from"node:fs/promises";import{createServer as Ru}from"node:http";import{dirname as Nu}from"node:path";var Lu=1e6,di=R("ipc"),Zn=class{server=null;port=0;token="";routes;paths;constructor(e){this.routes=new Map(e.routes.map(s=>[`${s.method} ${s.path}`,s])),this.paths=e.paths??q()}async start(){this.token=Tu(32).toString("hex");let e=Ru((o,c)=>{this.dispatch(o,c)});this.server=e,await new Promise((o,c)=>{e.once("error",c),e.listen(0,"127.0.0.1",()=>o())});let s=e.address();if(!s||typeof s!="object")throw new Error("failed to obtain IPC port");return this.port=s.port,await this.persistAuthFiles(),di.info("IPC listening",{port:this.port}),{port:this.port,token:this.token}}async stop(){let e=this.server;e&&(await new Promise((s,o)=>{e.close(c=>c?o(c):s())}),this.server=null)}async persistAuthFiles(){await Du(Nu(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 ku(this.paths.tokenFile,384)}catch(e){di.warn("chmod token file failed (non-POSIX?)",{err:String(e)})}}async dispatch(e,s){if(e.headers.authorization!==`Bearer ${this.token}`){xn(s,401,{error:"unauthorized"});return}let c=`${e.method} ${(e.url??"").split("?")[0]}`,x=this.routes.get(c);if(!x){xn(s,404,{error:"not found"});return}let u=null;if(e.method==="POST")try{u=await Ou(e)}catch(f){xn(s,400,{error:"invalid json",detail:String(f)});return}try{let f=await x.handler(u,e);xn(s,200,f??{ok:!0})}catch(f){di.error("IPC handler failed",{key:c,err:String(f)}),xn(s,500,{error:f instanceof Error?f.message:String(f)})}}};function xn(n,e,s){n.statusCode=e,n.setHeader("content-type","application/json"),n.end(JSON.stringify(s))}async function Ou(n){let e=[],s=0;for await(let c of n){let x=c;if(s+=x.length,s>Lu)throw new Error("body too large");e.push(x)}let o=Buffer.concat(e).toString("utf8");return o?JSON.parse(o):null}import{sep as jo}from"node:path";import{fileURLToPath as Mu}from"node:url";function $o(){return Bu(Mu(import.meta.url))}function Bu(n){let e=`${jo}src${jo}`;return n.includes(e)}U();ae();import{spawn as zu}from"node:child_process";import{existsSync as Fu,mkdirSync as Uu,openSync as qu}from"node:fs";import{dirname as Gu}from"node:path";import{fileURLToPath as Hu}from"node:url";var Ku=R("spawn-helper");function Wu(n){return Fu(n.libEntry)?n.libEntry:Hu(new URL("../index.ts",import.meta.url))}function ju(n,e,s){let o=n.endsWith(".ts"),c=["--upgrade-helper",`--target-version=${e}`,`--old-pid=${s}`];return o?["--import","tsx/esm",n,...c]:[n,...c]}async function Vo(n,e,s={}){let o=s.paths??q(),c=Wu(o);Uu(Gu(o.logFile),{recursive:!0});let x=qu(o.logFile,"a"),u=ju(c,n,e),f=zu(process.execPath,u,{detached:!0,stdio:["ignore",x,x],env:{...process.env,COZE_BRIDGE_UPGRADE_HELPER:"1"}});if(f.unref(),typeof f.pid!="number")throw new Error("failed to spawn upgrade helper (no pid)");Ku.info("upgrade helper spawned",{pid:f.pid,targetVersion:n,oldPid:e,entry:c})}U();import{mkdir as $u,writeFile as Vu}from"node:fs/promises";import{dirname as Ju}from"node:path";import{gunzipSync as Yu}from"node:zlib";var ui=R("tarball-downloader"),Zu="https://registry.npmjs.org",Jo="package/dist/index.js";async function Yo(n,e,s={}){if(!/^[\w.\-+]+$/.test(n))throw new Error(`invalid version string: ${JSON.stringify(n)}`);let c=`${(s.registry??Zu).replace(/\/+$/,"")}/coze-bridge/${n}`;ui.info("fetching tarball metadata",{metaUrl:c});let x=await fetch(c);if(!x.ok)throw new Error(`registry metadata ${c} returned ${x.status}`);let f=(await x.json())?.dist?.tarball;if(!f)throw new Error(`registry metadata missing dist.tarball for ${n}`);ui.info("downloading tarball",{tarballUrl:f});let g=await fetch(f);if(!g.ok)throw new Error(`tarball ${f} returned ${g.status}`);let m=Buffer.from(await g.arrayBuffer()),y=Yu(m),_=Xu(y,Jo);if(!_)throw new Error(`tarball missing entry ${Jo}`);await $u(Ju(e),{recursive:!0}),await Vu(e,_),ui.info("dist extracted",{destPath:e,bytes:_.length})}function Xu(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 c=o.subarray(0,100),x=c.indexOf(0),u=c.subarray(0,x===-1?100:x).toString("utf8"),f=o.subarray(124,136).toString("ascii").trim().replace(/\0/g,""),g=Number.parseInt(f,8)||0,m=s+512;if(u===e)return n.subarray(m,m+g);s=m+Math.ceil(g/512)*512}return null}zt();U();import{resolve as Qu}from"node:path";var gt=R("upgrade-manager"),ef=300*1e3,tf=3,Xn=class{constructor(e){this.opts=e}opts;inFlightTarget=null;async requestUpgrade(e){if(this.inFlightTarget===e){gt.debug("upgrade already in-flight, skip",{targetVersion:e});return}this.inFlightTarget=e;try{let s=await xt(this.opts.paths.configFile)??{};if(s.disableAutoUpgrade){gt.info("disableAutoUpgrade=true, skip",{targetVersion:e});return}if(this.opts.isDevMode()){gt.warn("dev mode, skip auto-upgrade",{targetVersion:e});return}if(!Vn(this.opts.currentVersion,e)){gt.debug("local version >= target, skip",{local:this.opts.currentVersion,target:e});return}let o=s.upgradeAttempts?.[e];if((o?.count??0)>=tf){gt.warn("upgrade attempts cap reached, skip",{targetVersion:e,count:o?.count});return}let c=Qu(this.opts.paths.libDir,"index.js.next");try{await this.opts.download(e,c)}catch(u){await this.recordAttempt(s,e,String(u)),gt.warn("download failed, attempt recorded",{targetVersion:e,err:String(u)});return}this.opts.daemon.markUpgradePending(e);let x=await this.opts.daemon.waitIdle(ef);gt.info("waitIdle done",{result:x}),await this.opts.spawnHelper(e,process.pid),this.opts.daemon.exit(0)}finally{this.inFlightTarget=null}}async recordAttempt(e,s,o){e.upgradeAttempts=e.upgradeAttempts??{};let c=e.upgradeAttempts[s];e.upgradeAttempts[s]={count:(c?.count??0)+1,lastAt:Date.now(),...o?{lastError:o}:{}},await qe(e,this.opts.paths.configFile)}};var wc=$e(aa(),1);var Ml=$e(nc(),1),Bl=$e(gr(),1),zl=$e(qt(),1),Fl=$e(Ei(),1),Ul=$e(Ci(),1),ql=$e(Ni(),1),uc=$e(wr(),1),Gl=$e(dc(),1);var fc=uc.default;U();var le=R("upstream.frontier"),gc="application/json",hc="none",Kl=15e3,wn=class{constructor(e){this.opts=e}opts;fws=null;handler=null;connectHandlers=[];opened=!1;openCount=0;async start(){if(this.fws){le.warn("start called on already-started FrontierUpstream; noop");return}let e={Authorization:`Bearer ${this.opts.privatecode}`,Origin:Fs,...Rt(this.opts.ppeOverride)};class s extends fc{constructor(I){super(I,zs,{headers:e})}send(I,...P){if(_s("debug"))try{let B;typeof I=="string"?B=Buffer.from(I,"utf8"):I instanceof Buffer?B=I:I instanceof ArrayBuffer?B=new Uint8Array(I):ArrayBuffer.isView(I)?B=new Uint8Array(I.buffer,I.byteOffset,I.byteLength):B=new Uint8Array(0);let j=Buffer.from(B.slice(0,128)).toString("hex");le.debug("WS raw frame out",{bytes:B.byteLength,headHex:j})}catch(B){le.warn("WS raw frame dump failed",{err:String(B)})}super.send(I,...P)}}let o=qs(this.opts.urlOverride),c={url:o,ws:s,fpID:Bs,aID:On,accessKey:this.opts.handshake.accessKey,deviceID:this.opts.handshake.deviceId,payloadType:{type:gc,force:!0},payloadEncoding:{encoding:hc,force:!0},enableTransformTextPayload:!0,enableQoS:!1,enableAutoAck:!1,automaticOpen:!1,maxRetries:Number.POSITIVE_INFINITY,debug:this.opts.debug??!1},x=new wc.FWS(c),u=!1,f=null,g,m,y=new Promise((C,I)=>{g=C,m=I}),_=C=>{u||(u=!0,f&&(clearTimeout(f),f=null),C?m(C):g())};x.onopen=()=>{this.opened=!0,this.openCount+=1;let C=this.openCount===1;le.info("frontier opened",{url:o,remoteDeviceId:this.opts.handshake.deviceId,initial:C,openCount:this.openCount}),C&&_();for(let I of this.connectHandlers)Promise.resolve(I({initial:C})).catch(P=>le.warn("onConnect handler threw (ignored)",{err:String(P)}))},x.onclose=C=>{this.opened=!1,le.info("frontier closed",{code:C.code,reason:C.reason,willReconnect:C.willReconnect})},x.onerror=C=>{le.warn("frontier error",{code:C.code,msg:C.message}),_(new b("UPSTREAM_DISCONNECTED",`frontier connect error before open: code=${C.code} msg=${C.message??""}`))},x.onmessage=C=>this.handleMessage(C),this.fws=x;let E=this.opts.openTimeoutMs??Kl;f=setTimeout(()=>{_(new b("UPSTREAM_DISCONNECTED",`frontier ws open timeout after ${E}ms (handshake or upgrade slow)`))},E),await x.connect();try{await y}catch(C){try{x.close(1e3,"open failed")}catch(I){le.warn("fws close during start failure threw (ignored)",{err:String(I)})}throw this.fws=null,this.opened=!1,C}}async stop(e){let s=this.fws;if(s){this.fws=null,this.opened=!1;try{s.close(1e3,e??"bridge shutdown")}catch(o){le.warn("frontier close threw (ignored)",{err:String(o)})}}}async send(e){let s=this.fws;if(!s)throw new b("UPSTREAM_DISCONNECTED","frontier upstream not started");if(!this.isConnected())throw new b("UPSTREAM_DISCONNECTED",`frontier ws not open (opened=${this.opened}, readyState=${s.readyState}); refusing to silently buffer`);this.injectAgentPatToken(e);let o=JSON.stringify(e),c=e;pc(c)||le.info("frontier frame out",{method:c.method,jsonrpcId:c.id,size:o.length});try{await s.send(o,{service:33555712,method:1,payloadType:gc,payloadEncoding:hc})}catch(u){throw le.warn("frontier frame send failed",{method:c.method,jsonrpcId:c.id,err:String(u)}),new b("UPSTREAM_DISCONNECTED",`frontier send failed: ${String(u)}`,{cause:u})}}onFrame(e){this.handler=e}onConnect(e){this.connectHandlers.push(e)}isConnected(){return this.opened&&this.fws?.readyState===1}injectAgentPatToken(e){let s=this.opts.getPatTokenForAgent;if(!s)return;let o=e.params?._meta;if(!o?.cozeAgentId)return;let c=s(o.cozeAgentId);c&&(o.cozePatToken=c)}handleMessage(e){let s=e.message?.service;if(s!==33555712){le.debug("drop non-adapter frontier frame",{service:s});return}let o=$l(e);if(!o){le.debug("frontier message without text payload, drop",{payloadType:e.message?.payloadType});return}if(!this.handler){le.debug("frame received but no onFrame handler",{size:o.length});return}let c;try{c=JSON.parse(o)}catch(u){le.warn("frontier message JSON parse failed",{err:String(u),head:o.slice(0,80)});return}let x=c;pc(x)||le.info("frontier frame in",{logid:jl(e.message?.LogID),logidNew:e.message?.LogIDNew,msgId:e.message?.msgID,jsonrpcId:x.id,method:x.method,body:Wl(o)}),Promise.resolve(this.handler(c)).catch(u=>le.warn("frontier frame handler threw",{err:String(u)}))}};function pc(n){return n.method==="_agent/health"?!0:typeof n.id=="string"&&n.id.startsWith("agent.health_")}var mc=2e3;function Wl(n){return n.length<=mc?n:`${n.slice(0,mc)}...<truncated, total ${n.length} chars>`}function jl(n){return n?n.high===0?String(n.low>>>0):`${n.high.toString(16)}${(n.low>>>0).toString(16).padStart(8,"0")}`:""}function $l(n){let e=n.message;if(e?.textPayload)return e.textPayload;let s=e?.payload;if(!s)return null;try{return Buffer.from(s).toString("utf8")}catch{return null}}U();var Oi=R("upstream.switchable"),yr=class{inner;handler=null;connectHandlers=[];constructor(e){this.inner=e}async swap(e,s){if(this.inner===e)return;Oi.info("swap upstream",{reason:s});let o=this.inner;if(this.inner=e,this.handler&&e.onFrame(this.handler),e.onConnect)for(let c of this.connectHandlers)e.onConnect(c);try{await e.start()}catch(c){throw Oi.error("swap target start failed, reverting",{err:String(c)}),this.inner=o,c}await o.stop(s??"swapped").catch(c=>Oi.warn("previous upstream stop threw (ignored)",{err:String(c)}))}current(){return this.inner}start(){return this.inner.start()}stop(e){return this.inner.stop(e)}send(e){return this.inner.send(e)}onFrame(e){this.handler=e,this.inner.onFrame(e)}onConnect(e){this.connectHandlers.push(e),this.inner.onConnect?.(e)}isConnected(){return this.inner.isConnected()}};U();var Mi=R("upstream"),$t=class{handler=null;async start(){Mi.info("NoopUpstream started (M1 skeleton; real Frontier wired in M4)")}async stop(e){Mi.info("NoopUpstream stopped",{reason:e})}async send(e){Mi.debug("NoopUpstream.send (dropped)",{method:"method"in e?e.method:void 0})}onFrame(e){this.handler=e}isConnected(){return!1}async injectFrame(e){this.handler&&await this.handler(e)}};U();U();ae();import{promises as Bi}from"node:fs";import{dirname as Vl}from"node:path";var Jl=R("pat-token-store");async function _c(n=q()){try{let s=(await Bi.readFile(n.patTokenFile,"utf8")).trim();return s.length>0?s:null}catch(e){return e?.code!=="ENOENT"&&Jl.warn("read pat-token failed (treating as missing)",{err:String(e)}),null}}async function _n(n,e=q()){if(!n)throw new Error("writePatToken: empty patToken");await Bi.mkdir(Vl(e.patTokenFile),{recursive:!0}),await Bi.writeFile(e.patTokenFile,n,{encoding:"utf8",mode:384})}ae();ae();import{promises as br}from"node:fs";import{join as Yl}from"node:path";function Zl(n){return`#!/bin/sh
124
124
  exec node ${JSON.stringify(n)} "$@"
125
- `}function Vl(n){return`@echo off
125
+ `}function Xl(n){return`@echo off
126
126
  node ${JSON.stringify(n)} %*
127
- `}async function hc(n,e=G()){let s=e.binDir;await br.mkdir(s,{recursive:!0});let o=Jl(s,process.platform==="win32"?"coze-bridge.cmd":"coze-bridge"),c=process.platform==="win32"?Vl(n):$l(n);return await br.readFile(o,"utf8").catch(()=>null)===c||(await br.writeFile(o,c,"utf8"),process.platform!=="win32"&&await br.chmod(o,493)),s}q();ie();import{execSync as mc}from"node:child_process";import{readFileSync as wc,unlinkSync as Yl}from"node:fs";import{mkdir as Xl,readFile as _c,unlink as yc,writeFile as Ql}from"node:fs/promises";import{dirname as Zl}from"node:path";function pc(n){try{return process.kill(n,0),!0}catch(e){return e.code==="EPERM"}}var eg=N("single-instance"),vr=class{pidFile;acquired=!1;constructor(e={}){this.pidFile=e.pidFile??G().pidFile,e.processTitle&&(process.title=e.processTitle)}async acquire(){let e=await this.readExistingPid();return e!==null&&this.isAlive(e)?{kind:"already-running",pid:e}:(e!==null&&(eg.warn("removing stale pid file",{stalePid:e}),await yc(this.pidFile).catch(()=>{})),await Xl(Zl(this.pidFile),{recursive:!0}),await Ql(this.pidFile,String(process.pid),"utf8"),this.acquired=!0,this.installCleanupHooks(),{kind:"acquired"})}async release(){if(this.acquired){try{(await _c(this.pidFile,"utf8")).trim()===String(process.pid)&&await yc(this.pidFile)}catch{}this.acquired=!1}}async readExistingPid(){try{let e=await _c(this.pidFile,"utf8"),s=Number.parseInt(e.trim(),10);return Number.isFinite(s)&&s>0?s:null}catch(e){if(e.code==="ENOENT")return null;throw e}}isAlive(e){return pc(e)?this.matchesDaemonTitle(e):!1}matchesDaemonTitle(e){if(process.platform==="win32")return this.matchesDaemonTitleWindows(e);try{let s=wc(`/proc/${e}/cmdline`,"utf8").replace(/\0/g," ");return!!(s.includes("coze-bridge-daemon")||s.includes("lib/index.js"))}catch{}try{let s=mc(`ps -o command= -p ${e}`,{stdio:["ignore","pipe","ignore"],timeout:1e3}).toString();return s.trim()?s.includes("coze-bridge-daemon")||s.includes("lib/index.js"):!1}catch{return!0}}matchesDaemonTitleWindows(e){try{let o=mc(`tasklist /FI "PID eq ${e}" /FO CSV /NH`,{stdio:["ignore","pipe","ignore"],timeout:2e3}).toString().trim();if(!o||o.startsWith("INFO:"))return!1;let c=o.split(",",1)[0]?.replace(/^"|"$/g,"").toLowerCase()??"";return c.includes("node")||c.includes("coze-bridge")}catch{return!0}}installCleanupHooks(){process.once("exit",()=>{if(this.acquired)try{wc(this.pidFile,"utf8").trim()===String(process.pid)&&Yl(this.pidFile)}catch{}})}};function tg(){let n=0,e=null;return{incActive(){n++},decActive(){n>0&&n--},activeCount(){return n},markUpgradePending(s){e=s},isUpgrading(){return e!==null},pendingTarget(){return e},async waitIdle(s){let o=Date.now()+s;for(;Date.now()<o;){if(n===0)return"idle";await new Promise(c=>setTimeout(c,200))}return n===0?"idle":"timeout"}}}var L=N("daemon"),ng="coze-bridge-daemon";async function vc(){let n=new vr({processTitle:ng}),e=await n.acquire();if(e.kind==="already-running")throw new Error(`coze-bridge daemon already running (pid=${e.pid})`);let s=await ct(),o=s??{};Sn({pid:process.pid}),L.info(s?"loaded bridge config":"initialized bridge config");try{let T=new Lt;o.frameworksCache=await T.detectAll(),L.info("refreshed frameworks_cache",{detected:Object.keys(o.frameworksCache)})}catch(T){L.warn("framework detection failed",{err:String(T)})}await Ue(o);let c=new yr(new Kt),d=G(),u=tg(),f=null,h=new Yn({upstream:c,paths:d,bridgeConfig:o,upgradeGate:u,sessionSpawner:async(T,O,B,ve)=>{if(!f)throw new Error("agentManager not ready");return f.spawnSessionDownstream(T,O,B,ve)}});await ig(d,h);let p=new Jn({paths:d,config:o,registry:h});f=p;let w,b,E=null,I={},A,k=null,z=null;h.registerExtension("_agent/create",async T=>p.createAgent(T.params)),h.registerExtension("_agent/health",async()=>({ok:!0}));let Y={},j=new Bn({agents:h.agents,disposeAndMarkDisconnected:async(T,O)=>{let B=h.agents.get(T);if(B){await p.cleanupOpenclawSessionProviders(B).catch(Q=>L.warn("cleanup openclaw providers failed (ignored)",{agentId:T,err:String(Q)}));let ve=!0;try{await B.dispose(`disconnect: ${O}`)}catch(Q){ve=!1,L.error("dispose during disconnect FAILED, leaving agent in error state",{agentId:T,err:String(Q)}),B.status="error"}ve&&(B.status="disconnected",h.unregister(T),h.disconnectedAgents.add(T))}else h.disconnectedAgents.add(T)},detailSyncer:async T=>{if(!Y.ref)throw new Error("agent-detail-sync not initialized yet");await Y.ref.syncOne(T)},cleanupOpenclawProviders:async T=>{await p.cleanupOpenclawSessionProviders(T)},openclawRepair:async(T,O)=>{await p.openclawRepair(T,O)},isRuntimePendingPermission:T=>h.hasPendingPermissionFor(T)});h.registerExtension("_agent/listSkills",T=>j.listSkills(T.params)),h.registerExtension("_agent/addSkills",T=>j.addSkills(T.params)),h.registerExtension("_agent/removeSkills",T=>j.removeSkills(T.params)),h.registerExtension("_agent/getFileTree",T=>j.getFileTree(T.params)),h.registerExtension("_agent/getFileContent",T=>j.getFileContent(T.params)),h.registerExtension("_agent/update",T=>j.updateAgent(T.params)),h.registerExtension("_agent/disconnect",T=>j.disconnectAgent(T.params)),h.registerExtension("_agent/switchModel",T=>j.switchModel(T.params)),h.registerExtension("_agent/reset",T=>j.resetAgent(T.params)),h.registerExtension("_agent/repair",T=>j.repairAgent(T.params));let oe=new Rn({paths:d,handlers:j,sendDetail:T=>h.sendRequest("_agent/detail",T)});Y.ref=oe;let W=async T=>{await Promise.allSettled(T.map(async O=>{try{await j.disconnectAgent({agentId:O.agentId,reason:`auth_failure: code=${O.code} ${O.message}`}),L.info("agent disconnected due to auth failure from heartbeat response",{agentId:O.agentId,code:O.code,message:O.message})}catch(B){L.warn("disconnect during authFailure handling failed (ignored)",{agentId:O.agentId,err:String(B)})}}))};c.onConnect(({initial:T})=>{L.info("frontier upstream connected, triggering detail sync",{initial:T}),oe.syncAll(T?"initial-connect":"reconnect").catch(O=>L.warn("detail sync top-level error (ignored)",{err:String(O)}))});let le=new Xn({paths:d,routes:[{method:"GET",path:"/status",handler:async()=>({running:!0,pid:process.pid,agents:[...h.agents.keys()],deviceId:E??"",frameworksCache:o.frameworksCache??{}})},{method:"POST",path:"/pair",handler:async T=>{let O=T,B=O?.privatecode,ve=O?.pairing_code;if(!B||!ve)throw new S("IPC_BAD_REQUEST","/pair requires privatecode + pairing_code");let Q=Xt(O.env),ge=O.handshake_url,Ke=O.frontier_url,ne=bc(O.env,ge,Ke),Ze=!!w&&w!==B,X=b!==void 0&&b!==ne,V=Ze||X,ut=await Yr({privatecode:B,...ge?{endpoint:ge}:{},ppeOverride:Q});if(V){L.warn("pair config switched, resetting agents",{pcChanged:Ze,envChanged:X,previousPc:w?Sr(w):"",nextPc:Sr(B),previousEnvKey:b??"",nextEnvKey:ne});for(let re of[...h.agents.values()])await re.dispose("pair config switch").catch(()=>{}),h.agents.delete(re.agentId);h.disconnectedAgents.size>0&&(L.info("clearing disconnectedAgents set on pair config switch",{count:h.disconnectedAgents.size}),h.disconnectedAgents.clear()),await c.swap(new Kt,"pair switch").catch(()=>{})}E=ut.deviceId,Sn({deviceId:E,pid:process.pid}),ai({patToken:B,env:O.env}).catch(re=>L.warn("coze-cli setup error (ignored)",{err:String(re)}));let J=new mn({handshake:ut,privatecode:B,...Ke?{urlOverride:Ke}:{},ppeOverride:Q,getPatTokenForAgent:re=>h.agents.get(re)?.patToken});await c.swap(J,"pair");try{let re=new Lt;o.frameworksCache=await re.detectAll(),await Ue(o),L.info("frameworks_cache refreshed before pair",{detected:Object.keys(o.frameworksCache)})}catch(re){L.warn("frameworks_cache refresh failed (ignored, using cached)",{err:String(re)})}let _t=Object.keys(o.frameworksCache??{});try{let re=await h.sendRequest("_agent/pair",{pairCode:ve,patToken:B,frameworks:_t,_meta:{cozeDeviceId:E}});L.info("_agent/pair ok",{pairResult:re}),w=B,b=ne,I=Q,A=ge,wn(B,d).catch(ye=>L.warn("writePatToken after /pair failed (ignored)",{err:String(ye)})),k||(k=new Zt({core:h,getDeviceId:()=>E??"",onTickEnd:()=>oe.retryPending().catch(ye=>L.warn("detailSync.retryPending failed (ignored)",{err:String(ye)})),onAuthFailures:W,onMinBridgeVersion:ye=>z?.requestUpgrade(ye)})),k.start(),V&&Er(d,p).catch(ye=>L.warn("post-pair-switch auto-revive error (ignored)",{err:String(ye)}));let yt;return O.agent_id&&(yt=await sg(O.agent_id,d,p,ye=>h.sendRequest("_agent/detail",ye),B).catch(ye=>(L.error("--agent-id ensureAgent failed",{agentId:O.agent_id,err:String(ye)}),{ok:!1,agentId:O.agent_id??"",note:String(ye)}))),{ok:!0,note:"paired with cloud",...yt?{agent:yt}:{}}}catch(re){return L.error("_agent/pair failed",{err:String(re)}),{ok:!1,note:`pair failed: ${String(re)}`}}}},{method:"POST",path:"/connect",handler:async T=>{let O=T,B=O?.privatecode;if(!B)throw new S("IPC_BAD_REQUEST","/connect requires privatecode");let ve=Xt(O.env),Q=O.handshake_url,ge=O.frontier_url,Ke=bc(O.env,Q,ge);if(w===B&&b===Ke){let J=await rg(d);return h.agents.size===0&&J?(L.warn("/connect noop but core.agents empty with configs on disk; re-running auto-revive"),Er(d,p).catch(_t=>L.warn("connect-noop auto-revive error (ignored)",{err:String(_t)}))):L.info("/connect: already connected with same PAT + env, noop"),{ok:!0,note:"already connected"}}let ne=!!w&&w!==B,Ze=b!==void 0&&b!==Ke,X=ne||Ze,V=await Yr({privatecode:B,...Q?{endpoint:Q}:{},ppeOverride:ve});if(X){L.warn("connect config switched, resetting agents",{pcChanged:ne,envChanged:Ze,previousPc:w?Sr(w):"",nextPc:Sr(B)});for(let J of[...h.agents.values()])await J.dispose("connect config switch").catch(()=>{}),h.agents.delete(J.agentId);h.disconnectedAgents.size>0&&(L.info("clearing disconnectedAgents set on connect config switch",{count:h.disconnectedAgents.size}),h.disconnectedAgents.clear()),await c.swap(new Kt,"connect switch").catch(()=>{})}E=V.deviceId,Sn({deviceId:E,pid:process.pid}),ai({patToken:B,env:O.env}).catch(J=>L.warn("coze-cli setup error (ignored)",{err:String(J)}));let ut=new mn({handshake:V,privatecode:B,...ge?{urlOverride:ge}:{},ppeOverride:ve,getPatTokenForAgent:J=>h.agents.get(J)?.patToken});return await c.swap(ut,"connect"),w=B,b=Ke,I=ve,A=Q,k||(k=new Zt({core:h,getDeviceId:()=>E??"",onTickEnd:()=>oe.retryPending().catch(J=>L.warn("detailSync.retryPending failed (ignored)",{err:String(J)})),onAuthFailures:W,onMinBridgeVersion:J=>z?.requestUpgrade(J)})),k.start(),X&&Er(d,p).catch(J=>L.warn("post-connect-switch auto-revive error (ignored)",{err:String(J)})),wn(B,d).catch(J=>L.warn("writePatToken after /connect failed (ignored)",{err:String(J)})),L.info("/connect: WS established",{deviceId:E}),{ok:!0,note:"connected"}}},{method:"POST",path:"/_agent/create",handler:async T=>{let O=T;return{ok:!0,result:await p.createAgent(O)}}},{method:"POST",path:"/agent/send",handler:async T=>{let O=T;if(!O?.agentId||!O?.sessionId||!O?.kind||!O?.path)throw new S("IPC_BAD_REQUEST","/agent/send requires agentId, sessionId, kind, path");if(!w)throw new S("UPSTREAM_NOT_READY","daemon not yet paired with cloud (run --pair-code first)");try{return await vo(O,{core:h,patToken:w,handshakeBase:A,ppeOverride:I})}catch(B){if(B instanceof S)return{ok:!1,code:B.code,message:B.message};throw B}}},{method:"POST",path:"/refresh",handler:async()=>{L.info("IPC /refresh: re-detecting frameworks");let T=new Lt;return o.frameworksCache=await T.detectAll(),await Ue(o),{ok:!0,frameworks:o.frameworksCache}}},{method:"POST",path:"/shutdown",handler:async()=>(L.info("IPC /shutdown received"),setImmediate(()=>{we.shutdown("ipc /shutdown")}),{ok:!0})}]}),{port:_e,token:ke}=await le.start();try{await hc(d.libEntry,d)}catch(T){L.warn("bin shim install failed (D72 send \u547D\u4EE4\u53EF\u80FD\u4E0D\u53EF\u7528)",{err:String(T)})}await h.start(),Er(d,p).catch(T=>L.warn("auto-revive top-level error (ignored)",{err:String(T)})),Es().catch(T=>L.warn("acp wrapper warmup top-level error (ignored)",{err:String(T)}));let xe=null,we={port:_e,token:ke,core:h,ipc:le,shutdown(T){return xe||(L.info("daemon shutdown",{reason:T}),xe=(async()=>{k?.stop(),await h.stop(T),await le.stop(),await n.release()})(),xe)}};z=new Qn({paths:d,currentVersion:st,isDevMode:Go,download:(T,O)=>Ko(T,O),spawnHelper:(T,O)=>Ho(T,O,{paths:d}),daemon:{markUpgradePending:T=>{L.warn("upgrade pending, ACP gate engaged",{target:T}),u.markUpgradePending(T)},waitIdle:T=>u.waitIdle(T),exit:T=>{we.shutdown("upgrade").then(()=>process.exit(T))}}});for(let T of["SIGTERM","SIGINT"])process.on(T,()=>{we.shutdown(T).then(()=>process.exit(0))});return L.info("daemon ready",{port:_e,pid:process.pid,nodeVersion:process.version,platform:process.platform,frameworks:Object.keys(o.frameworksCache??{}),libVersion:o.libVersion??"dev"}),we}async function rg(n){let{readdir:e}=await import("node:fs/promises");try{return(await e(n.agentsRoot)).length>0}catch{return!1}}function Sr(n){return n.length<=8?"***":`${n.slice(0,4)}***${n.slice(-4)}`}function bc(n,e,s){return`${n??""}|${e??""}|${s??""}`}async function ig(n,e){let{readdir:s}=await import("node:fs/promises"),o;try{o=await s(n.agentsRoot)}catch{return}let{loadAgentConfig:c,enforceAgentConfigMode:d}=await Promise.resolve().then(()=>(it(),Dn));for(let u of o){await d(u,n).catch(f=>L.warn("enforceAgentConfigMode failed (ignored)",{agentId:u,err:String(f)}));try{let f=await c(u,n);f?.disconnectedAt&&(e.disconnectedAgents.add(u),L.info("agent marked disconnected on startup",{agentId:u,disconnectedAt:f.disconnectedAt,reason:f.disconnectReason??""}))}catch(f){L.warn("failed to load agent config on startup, skipping",{agentId:u,err:String(f)})}}}async function sg(n,e,s,o,c){let{loadAgentConfig:d}=await Promise.resolve().then(()=>(it(),Dn)),u=await d(n,e);if(u){L.info("--agent-id: local config found, reconnecting",{agentId:n,framework:u.framework,hadDisconnect:!!u.disconnectedAt});let w={agentId:u.agentId,framework:u.framework,...u.cozeIdentity?{cozeIdentity:u.cozeIdentity}:{},...u.model?{model:u.model}:{},...c?{patToken:c}:{}};return await s.createAgent(w),{ok:!0,agentId:n,note:u.disconnectedAt?"revived from local config":"connected from local config"}}L.info("--agent-id: local config missing, pulling _agent/detail from cloud",{agentId:n});let f=await o({_meta:{cozeAgentId:n}});if(!f.framework)throw new S("AGENT_NOT_FOUND",`agent ${n} \u4E0D\u5728\u672C\u5730; \u4E91\u7AEF _agent/detail \u54CD\u5E94\u7F3A framework \u5B57\u6BB5 (D36 \u534F\u8BAE\u6269\u5C55\u672A\u751F\u6548), \u65E0\u6CD5\u5728\u672C\u673A\u65B0\u5EFA`);let h={agentId:f.agentId,framework:f.framework,...f.cozeIdentity?{cozeIdentity:f.cozeIdentity}:{},...f.model?{model:f.model}:{},...c?{patToken:c}:{},...f.deployType?{_meta:{cozeDeployType:f.deployType}}:{}};await s.createAgent(h);let p=f.deployType==="cloud"&&f.framework==="openclaw";return{ok:!0,agentId:n,note:p?"cloud agent acknowledged":"created from cloud detail"}}async function Er(n,e){let{readdir:s}=await import("node:fs/promises"),o;try{o=await s(n.agentsRoot)}catch{return{revived:0,skipped:0,total:0}}if(o.length===0)return{revived:0,skipped:0,total:0};let{loadAgentConfig:c}=await Promise.resolve().then(()=>(it(),Dn));L.info("auto-revive: scanning local agents on startup",{count:o.length});let d=0,u=0;for(let f of o){let h;try{h=await c(f,n)}catch(p){L.warn("auto-revive: load config failed (skipping)",{agentId:f,err:String(p)}),u+=1;continue}if(!h){u+=1;continue}if(h.disconnectedAt){L.info("auto-revive: skip disconnected agent",{agentId:f,disconnectedAt:h.disconnectedAt}),u+=1;continue}try{L.info("auto-revive: re-registering agent (D44 no spawn)",{agentId:f,framework:h.framework});let p=og(h);await e.createAgent({agentId:h.agentId,framework:h.framework,...h.cozeIdentity?{cozeIdentity:h.cozeIdentity}:{},...h.model?{model:h.model}:{},...p?{_meta:p}:{}}),d+=1}catch(p){L.warn("auto-revive: createAgent failed (skipping)",{agentId:f,framework:h.framework,err:String(p)}),u+=1}}return L.info("auto-revive: done",{revived:d,skipped:u,total:o.length}),{revived:d,skipped:u,total:o.length}}function og(n){let e={};return n.deployType&&(e.cozeDeployType=n.deployType),n.accountId&&(e.cozeAccountId=n.accountId),Object.keys(e).length>0?e:void 0}Ir();Tr();q();ie();Mt();q();ie();import{copyFile as Ec,mkdir as pg,readFile as zi,writeFile as mg}from"node:fs/promises";import{dirname as wg,resolve as Fi,sep as Pr}from"node:path";import{fileURLToPath as _g}from"node:url";var Ic=N("dist-install");function yg(n){let e=_g(n),s=wg(e),o=`${Pr}src${Pr}`;if(s.includes(o)||s.endsWith(`${Pr}src${Pr}cli`))return null;let c=Fi(s,"index.js"),d=Fi(s,"..","package.json");return{dist:c,pkgJson:d}}async function Ui(n={}){let e=n.paths??G(),s=yg(import.meta.url),o=n.sourceDist??s?.dist,c=n.sourcePackageJson??s?.pkgJson;if(!o||!c)return{kind:"dev-mode-skip",reason:"running from src/(tsx loader);no dist/ to install"};let d;try{d=JSON.parse(await zi(c,"utf8")).version??"unknown"}catch(b){return Ic.warn("cannot read source package.json,skip dist install",{err:String(b)}),{kind:"dev-mode-skip",reason:`package.json read failed: ${String(b)}`}}let u=await ct(e.configFile)??{},f=u.libVersion;if(f===d)try{return await zi(e.libEntry),{kind:"already-current",libVersion:d}}catch{}await pg(e.libDir,{recursive:!0}),await Ec(o,e.libEntry),await Ec(`${o}.map`,`${e.libEntry}.map`).catch(()=>{});let h=Fi(e.libDir,"package.json"),p=`${JSON.stringify({type:"module"},null,2)}
128
- `;return await zi(h,"utf8").catch(()=>null)!==p&&await mg(h,p),u.libVersion=d,await Ue(u,e.configFile),Ic.info("dist installed",{libEntry:e.libEntry,fromVersion:f,toVersion:d}),f?{kind:"version-changed",fromVersion:f,toVersion:d,libEntry:e.libEntry}:{kind:"first-install",libVersion:d,libEntry:e.libEntry}}Tr();ie();import{basename as bg,resolve as vg}from"node:path";var Sg=9e4,Eg={PATH_OUTSIDE_WORKSPACE:3,FILE_TOO_LARGE:3,UNSUPPORTED_MIME:3,MODEL_MODALITY_UNSUPPORTED:3,IPC_BAD_REQUEST:3,AGENT_NOT_FOUND:4,IPC_AUTH_FAILED:4,AGENT_DISCONNECTED:5,UPLOAD_FAILED:5,UPSTREAM_NOT_READY:5,UPSTREAM_DISCONNECTED:5,UPSTREAM_HANDSHAKE_FAILED:5,AGENT_BUSY:1,AGENT_SPAWN_FAILED:1,AGENT_TIMEOUT:1,AGENT_FRAME_IDLE_TIMEOUT:1,AGENT_PROTOCOL_ERROR:1,BRIDGE_CONFIG_INVALID:1,BRIDGE_INTERNAL:1,MODEL_TOKEN_GEN_FAILED:1,OPERATION_NOT_ALLOWED_FOR_LOCAL:1,BRIDGE_UPGRADING:5,NPX_CACHE_CORRUPT:1};function Ig(n){return Eg[n]??1}async function Ac(n,e={}){let s=e.paths??G();if(!n.agentId||!n.sessionId)return process.stderr.write(`Error: missing --agent-id and/or --session-id. These IDs come from the <coze-context> block injected at the top of each prompt \u2014 extract agentId and sessionId from there and pass them as flags. Example: coze-bridge send image x.png --agent-id <id> --session-id <id>
129
- `),4;let o=await Ar(s).catch(()=>null);if(!o)return process.stderr.write(`Error: coze-bridge daemon not running (cannot read ${s.portFile} / ${s.tokenFile}). Make sure you are inside an agent session spawned by the daemon.
130
- `),4;let c={agentId:n.agentId,sessionId:n.sessionId,kind:n.kind,path:vg(process.cwd(),n.path),...n.caption?{caption:n.caption}:{},...n.name?{name:n.name}:{}},d;try{d=await Ag(o,"/agent/send",c,Sg)}catch(u){return process.stderr.write(`Error: daemon IPC failed: ${u instanceof Error?u.message:String(u)}
131
- `),4}if(!d.ok)return process.stderr.write(`Error: ${d.code}: ${d.message}
132
- `),Ig(d.code);if(n.json)process.stdout.write(`${JSON.stringify(d)}
133
- `);else{let u=n.name??bg(c.path);process.stdout.write(`Sent ${n.kind} ${u} (${Tg(d.bytes)})
134
- `)}return 0}async function Ag(n,e,s,o){let c=new AbortController,d=setTimeout(()=>c.abort(),o);try{let u=await fetch(`http://127.0.0.1:${n.port}${e}`,{method:"POST",headers:{Authorization:`Bearer ${n.token}`,"content-type":"application/json"},body:JSON.stringify(s),signal:c.signal}),f=await u.text(),h=f?JSON.parse(f):null;return h&&typeof h=="object"&&"ok"in h?h:{ok:!1,code:"BRIDGE_INTERNAL",message:`unexpected daemon response (status=${u.status}): ${f.slice(0,200)}`}}finally{clearTimeout(d)}}function Tg(n){return n<1024?`${n}B`:n<1024*1024?`${(n/1024).toFixed(1)}KB`:`${(n/1024/1024).toFixed(1)}MB`}var zc=N("cli");function me(n,e){let s=[],o;for(let c=0;c<n.length;c++){let d=n[c];if(d===e){o=n[c+1],c+=1;continue}if(d.startsWith(`${e}=`)){o=d.slice(e.length+1);continue}s.push(d)}return{value:o,rest:s}}function nh(n){let e=n.slice(2);if(e.includes("--version")||e.includes("-v"))return{mode:"version"};if(e.includes("--daemon"))return{mode:"daemon"};if(e.includes("--status"))return{mode:"status"};if(e.includes("--stop"))return{mode:"stop"};if(e.includes("--refresh"))return{mode:"refresh"};if(e.includes("--uninstall"))return{mode:"uninstall"};if(e.includes("--install-service"))return{mode:"install-service"};if(e.includes("--upgrade-helper")){let k=e.filter(W=>W!=="--upgrade-helper"),{value:z,rest:Y}=me(k,"--target-version"),{value:j}=me(Y,"--old-pid"),oe=j?Number.parseInt(j,10):Number.NaN;return!z||!Number.isFinite(oe)?{mode:"help"}:{mode:"upgrade-helper",targetVersion:z,oldPid:oe}}if(e[0]==="send")return rh(e.slice(1));if(e[0]==="connect")return ih(e.slice(1));if(e.includes("--help")||e.includes("-h")||e.length===0)return{mode:"help"};let s=e,{value:o,rest:c}=me(s,"--pat-token");s=c;let{value:d,rest:u}=me(s,"--pair-code");s=u;let{value:f,rest:h}=me(s,"--env");s=h;let{value:p,rest:w}=me(s,"--handshake-url");s=w;let{value:b,rest:E}=me(s,"--frontier-url");s=E;let{value:I}=me(s,"--agent-id");if(!o||!d)return{mode:"help"};let A={mode:"pair",privatecode:o,pairingCode:d};return f&&(A.env=f),p&&(A.handshakeUrl=p),b&&(A.frontierUrl=b),I&&(A.agentId=I),A}function rh(n){let e=n[0],s=n[1];if(e!=="image"&&e!=="file")return{mode:"help"};if(!s||s.startsWith("--"))return{mode:"help"};let o=n.slice(2),{value:c,rest:d}=me(o,"--caption");o=d;let{value:u,rest:f}=me(o,"--name");o=f;let{value:h,rest:p}=me(o,"--agent-id");o=p;let{value:w,rest:b}=me(o,"--session-id");o=b;let E=o.includes("--json"),I={mode:"send",kind:e,path:s,json:E};return c&&(I.caption=c),u&&(I.name=u),h&&(I.agentId=h),w&&(I.sessionId=w),I}function ih(n){let e=n,{value:s,rest:o}=me(e,"--pat-token");e=o;let{value:c,rest:d}=me(e,"--env");e=d;let{value:u,rest:f}=me(e,"--handshake-url");e=f;let{value:h}=me(e,"--frontier-url"),p={mode:"connect"};return s&&(p.privatecode=s),c&&(p.env=c),u&&(p.handshakeUrl=u),h&&(p.frontierUrl=h),p}var sh=`
127
+ `}async function yc(n,e=q()){let s=e.binDir;await br.mkdir(s,{recursive:!0});let o=Yl(s,process.platform==="win32"?"coze-bridge.cmd":"coze-bridge"),c=process.platform==="win32"?Xl(n):Zl(n);return await br.readFile(o,"utf8").catch(()=>null)===c||(await br.writeFile(o,c,"utf8"),process.platform!=="win32"&&await br.chmod(o,493)),s}U();ae();import{execSync as vc}from"node:child_process";import{readFileSync as Sc,unlinkSync as Ql}from"node:fs";import{mkdir as eg,readFile as Ec,unlink as Ic,writeFile as tg}from"node:fs/promises";import{dirname as ng}from"node:path";function bc(n){try{return process.kill(n,0),!0}catch(e){return e.code==="EPERM"}}var rg=R("single-instance"),vr=class{pidFile;acquired=!1;constructor(e={}){this.pidFile=e.pidFile??q().pidFile,e.processTitle&&(process.title=e.processTitle)}async acquire(){let e=await this.readExistingPid();return e!==null&&this.isAlive(e)?{kind:"already-running",pid:e}:(e!==null&&(rg.warn("removing stale pid file",{stalePid:e}),await Ic(this.pidFile).catch(()=>{})),await eg(ng(this.pidFile),{recursive:!0}),await tg(this.pidFile,String(process.pid),"utf8"),this.acquired=!0,this.installCleanupHooks(),{kind:"acquired"})}async release(){if(this.acquired){try{(await Ec(this.pidFile,"utf8")).trim()===String(process.pid)&&await Ic(this.pidFile)}catch{}this.acquired=!1}}async readExistingPid(){try{let e=await Ec(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 bc(e)?this.matchesDaemonTitle(e):!1}matchesDaemonTitle(e){if(process.platform==="win32")return this.matchesDaemonTitleWindows(e);try{let s=Sc(`/proc/${e}/cmdline`,"utf8").replace(/\0/g," ");return!!(s.includes("coze-bridge-daemon")||s.includes("lib/index.js"))}catch{}try{let s=vc(`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=vc(`tasklist /FI "PID eq ${e}" /FO CSV /NH`,{stdio:["ignore","pipe","ignore"],timeout:2e3}).toString().trim();if(!o||o.startsWith("INFO:"))return!1;let c=o.split(",",1)[0]?.replace(/^"|"$/g,"").toLowerCase()??"";return c.includes("node")||c.includes("coze-bridge")}catch{return!0}}installCleanupHooks(){process.once("exit",()=>{if(this.acquired)try{Sc(this.pidFile,"utf8").trim()===String(process.pid)&&Ql(this.pidFile)}catch{}})}};function ig(){let n=0,e=null;return{incActive(){n++},decActive(){n>0&&n--},activeCount(){return n},markUpgradePending(s){e=s},isUpgrading(){return e!==null},pendingTarget(){return e},async waitIdle(s){let o=Date.now()+s;for(;Date.now()<o;){if(n===0)return"idle";await new Promise(c=>setTimeout(c,200))}return n===0?"idle":"timeout"}}}var M=R("daemon"),sg="coze-bridge-daemon";async function Cc(){let n=new vr({processTitle:sg}),e=await n.acquire();if(e.kind==="already-running")throw new Error(`coze-bridge daemon already running (pid=${e.pid})`);let s=await xt(),o=s??{};Sn({pid:process.pid}),M.info(s?"loaded bridge config":"initialized bridge config");try{let A=new Bt;o.frameworksCache=await A.detectAll(),M.info("refreshed frameworks_cache",{detected:Object.keys(o.frameworksCache)})}catch(A){M.warn("framework detection failed",{err:String(A)})}await qe(o);let c=new yr(new $t),x=q(),u=ig(),f=null,g=new Yn({upstream:c,paths:x,bridgeConfig:o,upgradeGate:u,sessionSpawner:async(A,L,z,be)=>{if(!f)throw new Error("agentManager not ready");return f.spawnSessionDownstream(A,L,z,be)}});await ag(x,g);let m=new $n({paths:x,config:o,registry:g});f=m;let y,_,E=null,C={},I,P=null,B=null;g.registerExtension("_agent/create",async A=>m.createAgent(A.params)),g.registerExtension("_agent/health",async()=>({ok:!0}));let j={},H=new Bn({agents:g.agents,disposeAndMarkDisconnected:async(A,L)=>{let z=g.agents.get(A);if(z){await m.cleanupOpenclawSessionProviders(z).catch(ne=>M.warn("cleanup openclaw providers failed (ignored)",{agentId:A,err:String(ne)}));let be=!0;try{await z.dispose(`disconnect: ${L}`)}catch(ne){be=!1,M.error("dispose during disconnect FAILED, leaving agent in error state",{agentId:A,err:String(ne)}),z.status="error"}be&&(z.status="disconnected",g.unregister(A),g.disconnectedAgents.add(A))}else g.disconnectedAgents.add(A)},detailSyncer:async A=>{if(!j.ref)throw new Error("agent-detail-sync not initialized yet");await j.ref.syncOne(A)},cleanupOpenclawProviders:async A=>{await m.cleanupOpenclawSessionProviders(A)},openclawRepair:async(A,L)=>{await m.openclawRepair(A,L)},isRuntimePendingPermission:A=>g.hasPendingPermissionFor(A)});g.registerExtension("_agent/listSkills",A=>H.listSkills(A.params)),g.registerExtension("_agent/addSkills",A=>H.addSkills(A.params)),g.registerExtension("_agent/removeSkills",A=>H.removeSkills(A.params)),g.registerExtension("_agent/getFileTree",A=>H.getFileTree(A.params)),g.registerExtension("_agent/getFileContent",A=>H.getFileContent(A.params)),g.registerExtension("_agent/update",A=>H.updateAgent(A.params)),g.registerExtension("_agent/disconnect",A=>H.disconnectAgent(A.params)),g.registerExtension("_agent/switchModel",A=>H.switchModel(A.params)),g.registerExtension("_agent/reset",A=>H.resetAgent(A.params)),g.registerExtension("_agent/repair",A=>H.repairAgent(A.params));let ce=new Rn({paths:x,handlers:H,sendDetail:A=>g.sendRequest("_agent/detail",A)});j.ref=ce;let W=async A=>{await Promise.allSettled(A.map(async L=>{try{await H.disconnectAgent({agentId:L.agentId,reason:`auth_failure: code=${L.code} ${L.message}`}),M.info("agent disconnected due to auth failure from heartbeat response",{agentId:L.agentId,code:L.code,message:L.message})}catch(z){M.warn("disconnect during authFailure handling failed (ignored)",{agentId:L.agentId,err:String(z)})}}))};c.onConnect(({initial:A})=>{M.info("frontier upstream connected, triggering detail sync",{initial:A}),ce.syncAll(A?"initial-connect":"reconnect").catch(L=>M.warn("detail sync top-level error (ignored)",{err:String(L)}))});let he=new Zn({paths:x,routes:[{method:"GET",path:"/status",handler:async()=>({running:!0,pid:process.pid,agents:[...g.agents.keys()],deviceId:E??"",frameworksCache:o.frameworksCache??{}})},{method:"POST",path:"/pair",handler:async A=>{let L=A,z=L?.privatecode,be=L?.pairing_code;if(!z||!be)throw new b("IPC_BAD_REQUEST","/pair requires privatecode + pairing_code");let ne=Xt(L.env),pe=L.handshake_url,je=L.frontier_url,se=Ac(L.env,pe,je),et=!!y&&y!==z,Q=_!==void 0&&_!==se,J=et||Q,ft=await Yr({privatecode:z,...pe?{endpoint:pe}:{},ppeOverride:ne});if(J){M.warn("pair config switched, resetting agents",{pcChanged:et,envChanged:Q,previousPc:y?Sr(y):"",nextPc:Sr(z),previousEnvKey:_??"",nextEnvKey:se});for(let oe of[...g.agents.values()])await oe.dispose("pair config switch").catch(()=>{}),g.agents.delete(oe.agentId);g.disconnectedAgents.size>0&&(M.info("clearing disconnectedAgents set on pair config switch",{count:g.disconnectedAgents.size}),g.disconnectedAgents.clear()),await c.swap(new $t,"pair switch").catch(()=>{})}E=ft.deviceId,Sn({deviceId:E,pid:process.pid}),ci({patToken:z,env:L.env}).catch(oe=>M.warn("coze-cli setup error (ignored)",{err:String(oe)}));let $=new wn({handshake:ft,privatecode:z,...je?{urlOverride:je}:{},ppeOverride:ne,getPatTokenForAgent:oe=>g.agents.get(oe)?.patToken});await c.swap($,"pair");try{let oe=new Bt;o.frameworksCache=await oe.detectAll(),await qe(o),M.info("frameworks_cache refreshed before pair",{detected:Object.keys(o.frameworksCache)})}catch(oe){M.warn("frameworks_cache refresh failed (ignored, using cached)",{err:String(oe)})}let yt=Object.keys(o.frameworksCache??{});try{let oe=await g.sendRequest("_agent/pair",{pairCode:be,patToken:z,frameworks:yt,_meta:{cozeDeviceId:E}});M.info("_agent/pair ok",{pairResult:oe}),y=z,_=se,C=ne,I=pe,_n(z,x).catch(ve=>M.warn("writePatToken after /pair failed (ignored)",{err:String(ve)})),P||(P=new en({core:g,getDeviceId:()=>E??"",onTickEnd:()=>ce.retryPending().catch(ve=>M.warn("detailSync.retryPending failed (ignored)",{err:String(ve)})),onAuthFailures:W,onMinBridgeVersion:ve=>B?.requestUpgrade(ve)})),P.start(),J&&Er(x,m).catch(ve=>M.warn("post-pair-switch auto-revive error (ignored)",{err:String(ve)}));let bt;return L.agent_id&&(bt=await cg(L.agent_id,x,m,ve=>g.sendRequest("_agent/detail",ve),z).catch(ve=>(M.error("--agent-id ensureAgent failed",{agentId:L.agent_id,err:String(ve)}),{ok:!1,agentId:L.agent_id??"",note:String(ve)}))),{ok:!0,note:"paired with cloud",...bt?{agent:bt}:{}}}catch(oe){return M.error("_agent/pair failed",{err:String(oe)}),{ok:!1,note:`pair failed: ${String(oe)}`}}}},{method:"POST",path:"/connect",handler:async A=>{let L=A,z=L?.privatecode;if(!z)throw new b("IPC_BAD_REQUEST","/connect requires privatecode");let be=Xt(L.env),ne=L.handshake_url,pe=L.frontier_url,je=Ac(L.env,ne,pe);if(y===z&&_===je){let $=await og(x);return g.agents.size===0&&$?(M.warn("/connect noop but core.agents empty with configs on disk; re-running auto-revive"),Er(x,m).catch(yt=>M.warn("connect-noop auto-revive error (ignored)",{err:String(yt)}))):M.info("/connect: already connected with same PAT + env, noop"),{ok:!0,note:"already connected"}}let se=!!y&&y!==z,et=_!==void 0&&_!==je,Q=se||et,J=await Yr({privatecode:z,...ne?{endpoint:ne}:{},ppeOverride:be});if(Q){M.warn("connect config switched, resetting agents",{pcChanged:se,envChanged:et,previousPc:y?Sr(y):"",nextPc:Sr(z)});for(let $ of[...g.agents.values()])await $.dispose("connect config switch").catch(()=>{}),g.agents.delete($.agentId);g.disconnectedAgents.size>0&&(M.info("clearing disconnectedAgents set on connect config switch",{count:g.disconnectedAgents.size}),g.disconnectedAgents.clear()),await c.swap(new $t,"connect switch").catch(()=>{})}E=J.deviceId,Sn({deviceId:E,pid:process.pid}),ci({patToken:z,env:L.env}).catch($=>M.warn("coze-cli setup error (ignored)",{err:String($)}));let ft=new wn({handshake:J,privatecode:z,...pe?{urlOverride:pe}:{},ppeOverride:be,getPatTokenForAgent:$=>g.agents.get($)?.patToken});return await c.swap(ft,"connect"),y=z,_=je,C=be,I=ne,P||(P=new en({core:g,getDeviceId:()=>E??"",onTickEnd:()=>ce.retryPending().catch($=>M.warn("detailSync.retryPending failed (ignored)",{err:String($)})),onAuthFailures:W,onMinBridgeVersion:$=>B?.requestUpgrade($)})),P.start(),Q&&Er(x,m).catch($=>M.warn("post-connect-switch auto-revive error (ignored)",{err:String($)})),_n(z,x).catch($=>M.warn("writePatToken after /connect failed (ignored)",{err:String($)})),M.info("/connect: WS established",{deviceId:E}),{ok:!0,note:"connected"}}},{method:"POST",path:"/_agent/create",handler:async A=>{let L=A;return{ok:!0,result:await m.createAgent(L)}}},{method:"POST",path:"/agent/send",handler:async A=>{let L=A;if(!L?.agentId||!L?.sessionId||!L?.kind||!L?.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 z=L;return await(z.groupFile?Co:Ao)(z,{core:g,patToken:y,handshakeBase:I,ppeOverride:C})}catch(z){if(z instanceof b)return{ok:!1,code:z.code,message:z.message};throw z}}},{method:"POST",path:"/refresh",handler:async()=>{M.info("IPC /refresh: re-detecting frameworks");let A=new Bt;return o.frameworksCache=await A.detectAll(),await qe(o),{ok:!0,frameworks:o.frameworksCache}}},{method:"POST",path:"/shutdown",handler:async()=>(M.info("IPC /shutdown received"),setImmediate(()=>{_e.shutdown("ipc /shutdown")}),{ok:!0})}]}),{port:ye,token:De}=await he.start();try{await yc(x.libEntry,x)}catch(A){M.warn("bin shim install failed (D72 send \u547D\u4EE4\u53EF\u80FD\u4E0D\u53EF\u7528)",{err:String(A)})}await g.start(),Er(x,m).catch(A=>M.warn("auto-revive top-level error (ignored)",{err:String(A)})),Es().catch(A=>M.warn("acp wrapper warmup top-level error (ignored)",{err:String(A)}));let ue=null,_e={port:ye,token:De,core:g,ipc:he,shutdown(A){return ue||(M.info("daemon shutdown",{reason:A}),ue=(async()=>{P?.stop(),await g.stop(A),await he.stop(),await n.release()})(),ue)}};B=new Xn({paths:x,currentVersion:ot,isDevMode:$o,download:(A,L)=>Yo(A,L),spawnHelper:(A,L)=>Vo(A,L,{paths:x}),daemon:{markUpgradePending:A=>{M.warn("upgrade pending, ACP gate engaged",{target:A}),u.markUpgradePending(A)},waitIdle:A=>u.waitIdle(A),exit:A=>{_e.shutdown("upgrade").then(()=>process.exit(A))}}});for(let A of["SIGTERM","SIGINT"])process.on(A,()=>{_e.shutdown(A).then(()=>process.exit(0))});return M.info("daemon ready",{port:ye,pid:process.pid,nodeVersion:process.version,platform:process.platform,frameworks:Object.keys(o.frameworksCache??{}),libVersion:o.libVersion??"dev"}),_e}async function og(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 Ac(n,e,s){return`${n??""}|${e??""}|${s??""}`}async function ag(n,e){let{readdir:s}=await import("node:fs/promises"),o;try{o=await s(n.agentsRoot)}catch{return}let{loadAgentConfig:c,enforceAgentConfigMode:x}=await Promise.resolve().then(()=>(st(),Dn));for(let u of o){await x(u,n).catch(f=>M.warn("enforceAgentConfigMode failed (ignored)",{agentId:u,err:String(f)}));try{let f=await c(u,n);f?.disconnectedAt&&(e.disconnectedAgents.add(u),M.info("agent marked disconnected on startup",{agentId:u,disconnectedAt:f.disconnectedAt,reason:f.disconnectReason??""}))}catch(f){M.warn("failed to load agent config on startup, skipping",{agentId:u,err:String(f)})}}}async function cg(n,e,s,o,c){let{loadAgentConfig:x}=await Promise.resolve().then(()=>(st(),Dn)),u=await x(n,e);if(u){M.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}:{},...c?{patToken:c}:{}};return await s.createAgent(y),{ok:!0,agentId:n,note:u.disconnectedAt?"revived from local config":"connected from local config"}}M.info("--agent-id: local config missing, pulling _agent/detail from cloud",{agentId:n});let 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 g={agentId:f.agentId,framework:f.framework,...f.cozeIdentity?{cozeIdentity:f.cozeIdentity}:{},...f.model?{model:f.model}:{},...c?{patToken:c}:{},...f.deployType?{_meta:{cozeDeployType:f.deployType}}:{}};await s.createAgent(g);let m=f.deployType==="cloud"&&f.framework==="openclaw";return{ok:!0,agentId:n,note:m?"cloud agent acknowledged":"created from cloud detail"}}async function Er(n,e){let{readdir:s}=await import("node:fs/promises"),o;try{o=await s(n.agentsRoot)}catch{return{revived:0,skipped:0,total:0}}if(o.length===0)return{revived:0,skipped:0,total:0};let{loadAgentConfig:c}=await Promise.resolve().then(()=>(st(),Dn));M.info("auto-revive: scanning local agents on startup",{count:o.length});let x=0,u=0;for(let f of o){let g;try{g=await c(f,n)}catch(m){M.warn("auto-revive: load config failed (skipping)",{agentId:f,err:String(m)}),u+=1;continue}if(!g){u+=1;continue}if(g.disconnectedAt){M.info("auto-revive: skip disconnected agent",{agentId:f,disconnectedAt:g.disconnectedAt}),u+=1;continue}try{M.info("auto-revive: re-registering agent (D44 no spawn)",{agentId:f,framework:g.framework});let m=xg(g);await e.createAgent({agentId:g.agentId,framework:g.framework,...g.cozeIdentity?{cozeIdentity:g.cozeIdentity}:{},...g.model?{model:g.model}:{},...m?{_meta:m}:{}}),x+=1}catch(m){M.warn("auto-revive: createAgent failed (skipping)",{agentId:f,framework:g.framework,err:String(m)}),u+=1}}return M.info("auto-revive: done",{revived:x,skipped:u,total:o.length}),{revived:x,skipped:u,total:o.length}}function xg(n){let e={};return n.deployType&&(e.cozeDeployType=n.deployType),n.accountId&&(e.cozeAccountId=n.accountId),Object.keys(e).length>0?e:void 0}Ir();Cr();U();ae();zt();U();ae();import{copyFile as Tc,mkdir as _g,readFile as Fi,writeFile as yg}from"node:fs/promises";import{dirname as bg,resolve as Ui,sep as Pr}from"node:path";import{fileURLToPath as vg}from"node:url";var kc=R("dist-install");function Sg(n){let e=vg(n),s=bg(e),o=`${Pr}src${Pr}`;if(s.includes(o)||s.endsWith(`${Pr}src${Pr}cli`))return null;let c=Ui(s,"index.js"),x=Ui(s,"..","package.json");return{dist:c,pkgJson:x}}async function qi(n={}){let e=n.paths??q(),s=Sg(import.meta.url),o=n.sourceDist??s?.dist,c=n.sourcePackageJson??s?.pkgJson;if(!o||!c)return{kind:"dev-mode-skip",reason:"running from src/(tsx loader);no dist/ to install"};let x;try{x=JSON.parse(await Fi(c,"utf8")).version??"unknown"}catch(_){return kc.warn("cannot read source package.json,skip dist install",{err:String(_)}),{kind:"dev-mode-skip",reason:`package.json read failed: ${String(_)}`}}let u=await xt(e.configFile)??{},f=u.libVersion;if(f===x)try{return await Fi(e.libEntry),{kind:"already-current",libVersion:x}}catch{}await _g(e.libDir,{recursive:!0}),await Tc(o,e.libEntry),await Tc(`${o}.map`,`${e.libEntry}.map`).catch(()=>{});let g=Ui(e.libDir,"package.json"),m=`${JSON.stringify({type:"module"},null,2)}
128
+ `;return await Fi(g,"utf8").catch(()=>null)!==m&&await yg(g,m),u.libVersion=x,await qe(u,e.configFile),kc.info("dist installed",{libEntry:e.libEntry,fromVersion:f,toVersion:x}),f?{kind:"version-changed",fromVersion:f,toVersion:x,libEntry:e.libEntry}:{kind:"first-install",libVersion:x,libEntry:e.libEntry}}Cr();ae();import{basename as Eg,resolve as Ig}from"node:path";var Ag=9e4,Cg={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 Pg(n){return Cg[n]??1}async function Dc(n,e={}){let s=e.paths??q();if(!n.agentId||!n.sessionId)return process.stderr.write(`Error: missing --agent-id and/or --session-id. These IDs come from the <coze-context> block injected at the top of each prompt \u2014 extract agentId and sessionId from there and pass them as flags. Example: coze-bridge send image x.png --agent-id <id> --session-id <id>
129
+ `),4;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 Ar(s).catch(()=>null);if(!o)return process.stderr.write(`Error: coze-bridge daemon not running (cannot read ${s.portFile} / ${s.tokenFile}). Make sure you are inside an agent session spawned by the daemon.
131
+ `),4;let c={agentId:n.agentId,sessionId:n.sessionId,kind:n.kind,path:n.groupFile?n.path:Ig(process.cwd(),n.path),...n.caption?{caption:n.caption}:{},...n.name?{name:n.name}:{},...n.groupFile?{groupFile:!0}:{},...n.mimeType?{mimeType:n.mimeType}:{}},x;try{x=await Tg(o,"/agent/send",c,Ag)}catch(u){return process.stderr.write(`Error: daemon IPC failed: ${u instanceof Error?u.message:String(u)}
132
+ `),4}if(!x.ok)return process.stderr.write(`Error: ${x.code}: ${x.message}
133
+ `),Pg(x.code);if(n.json)process.stdout.write(`${JSON.stringify(x)}
134
+ `);else{let u=n.name??Eg(c.path);if(n.groupFile){let f=x.uri.length>60?`${x.uri.slice(0,57)}...`:x.uri;process.stdout.write(`Sent group file ${u} (uri=${f})
135
+ `)}else process.stdout.write(`Sent ${n.kind} ${u} (${kg(x.bytes)})
136
+ `)}return 0}async function Tg(n,e,s,o){let c=new AbortController,x=setTimeout(()=>c.abort(),o);try{let u=await fetch(`http://127.0.0.1:${n.port}${e}`,{method:"POST",headers:{Authorization:`Bearer ${n.token}`,"content-type":"application/json"},body:JSON.stringify(s),signal:c.signal}),f=await u.text(),g=f?JSON.parse(f):null;return g&&typeof g=="object"&&"ok"in g?g:{ok:!1,code:"BRIDGE_INTERNAL",message:`unexpected daemon response (status=${u.status}): ${f.slice(0,200)}`}}finally{clearTimeout(x)}}function kg(n){return n<1024?`${n}B`:n<1024*1024?`${(n/1024).toFixed(1)}KB`:`${(n/1024/1024).toFixed(1)}MB`}var Hc=R("cli");function ge(n,e){let s=[],o;for(let c=0;c<n.length;c++){let x=n[c];if(x===e){o=n[c+1],c+=1;continue}if(x.startsWith(`${e}=`)){o=x.slice(e.length+1);continue}s.push(x)}return{value:o,rest:s}}function sh(n){let e=n.slice(2);if(e.includes("--version")||e.includes("-v"))return{mode:"version"};if(e.includes("--daemon"))return{mode:"daemon"};if(e.includes("--status"))return{mode:"status"};if(e.includes("--stop"))return{mode:"stop"};if(e.includes("--refresh"))return{mode:"refresh"};if(e.includes("--uninstall"))return{mode:"uninstall"};if(e.includes("--install-service"))return{mode:"install-service"};if(e.includes("--upgrade-helper")){let P=e.filter(W=>W!=="--upgrade-helper"),{value:B,rest:j}=ge(P,"--target-version"),{value:H}=ge(j,"--old-pid"),ce=H?Number.parseInt(H,10):Number.NaN;return!B||!Number.isFinite(ce)?{mode:"help"}:{mode:"upgrade-helper",targetVersion:B,oldPid:ce}}if(e[0]==="send")return oh(e.slice(1));if(e[0]==="connect")return ah(e.slice(1));if(e.includes("--help")||e.includes("-h")||e.length===0)return{mode:"help"};let s=e,{value:o,rest:c}=ge(s,"--pat-token");s=c;let{value:x,rest:u}=ge(s,"--pair-code");s=u;let{value:f,rest:g}=ge(s,"--env");s=g;let{value:m,rest:y}=ge(s,"--handshake-url");s=y;let{value:_,rest:E}=ge(s,"--frontier-url");s=E;let{value:C}=ge(s,"--agent-id");if(!o||!x)return{mode:"help"};let I={mode:"pair",privatecode:o,pairingCode:x};return f&&(I.env=f),m&&(I.handshakeUrl=m),_&&(I.frontierUrl=_),C&&(I.agentId=C),I}function oh(n){let e=n[0],s=n[1];if(e!=="image"&&e!=="file")return{mode:"help"};if(!s||s.startsWith("--"))return{mode:"help"};let o=n.slice(2),{value:c,rest:x}=ge(o,"--caption");o=x;let{value:u,rest:f}=ge(o,"--name");o=f;let{value:g,rest:m}=ge(o,"--agent-id");o=m;let{value:y,rest:_}=ge(o,"--session-id");o=_;let{value:E,rest:C}=ge(o,"--mime");o=C;let I=o.includes("--group-file");o=o.filter(j=>j!=="--group-file");let P=o.includes("--json"),B={mode:"send",kind:e,path:s,json:P};return c&&(B.caption=c),u&&(B.name=u),g&&(B.agentId=g),y&&(B.sessionId=y),I&&(B.groupFile=!0),E&&(B.mimeType=E),B}function ah(n){let e=n,{value:s,rest:o}=ge(e,"--pat-token");e=o;let{value:c,rest:x}=ge(e,"--env");e=x;let{value:u,rest:f}=ge(e,"--handshake-url");e=f;let{value:g}=ge(e,"--frontier-url"),m={mode:"connect"};return s&&(m.privatecode=s),c&&(m.env=c),u&&(m.handshakeUrl=u),g&&(m.frontierUrl=g),m}var ch=`
135
137
  coze-bridge - local bridge daemon for cloud Agent Service
136
138
 
137
139
  Usage:
@@ -170,48 +172,56 @@ Send file / image (D72; intended to be called by LLM inside agent bash tool):
170
172
  \u6284\u5165; daemon IPC \u51ED\u8BC1 CLI \u81EA\u5DF1\u4ECE
171
173
  ~/.coze/bridge/{bridge.port,bridge.token} \u8BFB
172
174
 
175
+ Send group file (D99; path \u662F\u4E91\u7AEF\u53EF\u8BC6\u522B\u7684\u7FA4\u6587\u4EF6 uri/id, \u8DF3\u8FC7\u4E0A\u4F20\u76F4\u63A5\u4E0A\u884C):
176
+ coze-bridge send file <uri> --agent-id <id> --session-id <id> --group-file --mime <mimeType> [--name "..."] [--caption "..."]
177
+ \u4E0D\u4E0A\u4F20, uri \u539F\u6837\u900F\u4F20\u7ED9\u4E91\u7AEF, sessionUpdate
178
+ \u7C7B\u578B = group_file; --mime \u5FC5\u586B\u3002
179
+ \u6CE8: image/file \u5728\u7FA4\u6587\u4EF6\u6A21\u5F0F\u4E0B\u884C\u4E3A\u76F8\u540C,
180
+ \u4E91\u7AEF\u6309 group_file \u7EDF\u4E00\u6E32\u67D3, \u5EFA\u8BAE
181
+ \u56FA\u5B9A\u7528 'file'\u3002
182
+
173
183
  Internal:
174
184
  <node> <entry> --daemon daemon mode (OS supervisor only)
175
185
  <node> <entry> --upgrade-helper --target-version=<v> --old-pid=<pid>
176
186
  D82 self-update helper
177
187
  (UpgradeManager \u5185\u90E8 fork)
178
- `.trimStart();async function Fc(n=process.argv,e={}){let s=nh(n);switch(s.mode){case"help":return process.stdout.write(sh),0;case"version":return process.stdout.write(`${st}
179
- `),0;case"daemon":{try{await vc()}catch(o){return zc.error("daemon start failed",{err:String(o)}),1}return new Promise(()=>{})}case"status":return oh(e);case"stop":return ah(e);case"refresh":return ch(e);case"uninstall":return dh(e);case"install-service":return xh();case"pair":{let o={};return s.env&&(o.env=s.env),s.handshakeUrl&&(o.handshakeUrl=s.handshakeUrl),s.frontierUrl&&(o.frontierUrl=s.frontierUrl),uh(s.privatecode,s.pairingCode,e,o,s.agentId)}case"connect":{let o={};return s.env&&(o.env=s.env),s.handshakeUrl&&(o.handshakeUrl=s.handshakeUrl),s.frontierUrl&&(o.frontierUrl=s.frontierUrl),fh(s.privatecode,e,o)}case"upgrade-helper":{let{runUpgradeHelper:o}=await Promise.resolve().then(()=>(Rc(),Dc));return await o({targetVersion:s.targetVersion,oldPid:s.oldPid,...e.paths?{paths:e.paths}:{}})}case"send":return Ac({kind:s.kind,path:s.path,...s.agentId?{agentId:s.agentId}:{},...s.sessionId?{sessionId:s.sessionId}:{},...s.caption?{caption:s.caption}:{},...s.name?{name:s.name}:{},json:s.json},e)}}async function Uc(n){let{unlink:e}=await import("node:fs/promises");await Promise.all([e(n.pidFile).catch(()=>{}),e(n.portFile).catch(()=>{}),e(n.tokenFile).catch(()=>{})])}async function oh(n){let e=n.paths??G(),s=new Ne(e),o=await s.probe();if(o.kind==="not-running")return process.stdout.write(`coze-bridge: not running
180
- `),1;if(o.kind==="stale")return await Uc(e),process.stdout.write(`coze-bridge: not running (cleaned stale state)
188
+ `.trimStart();async function Kc(n=process.argv,e={}){let s=sh(n);switch(s.mode){case"help":return process.stdout.write(ch),0;case"version":return process.stdout.write(`${ot}
189
+ `),0;case"daemon":{try{await Cc()}catch(o){return Hc.error("daemon start failed",{err:String(o)}),1}return new Promise(()=>{})}case"status":return xh(e);case"stop":return dh(e);case"refresh":return uh(e);case"uninstall":return fh(e);case"install-service":return lh();case"pair":{let o={};return s.env&&(o.env=s.env),s.handshakeUrl&&(o.handshakeUrl=s.handshakeUrl),s.frontierUrl&&(o.frontierUrl=s.frontierUrl),gh(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),hh(s.privatecode,e,o)}case"upgrade-helper":{let{runUpgradeHelper:o}=await Promise.resolve().then(()=>(Bc(),Mc));return await o({targetVersion:s.targetVersion,oldPid:s.oldPid,...e.paths?{paths:e.paths}:{}})}case"send":return Dc({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 Wc(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 xh(n){let e=n.paths??q(),s=new Le(e),o=await s.probe();if(o.kind==="not-running")return process.stdout.write(`coze-bridge: not running
190
+ `),1;if(o.kind==="stale")return await Wc(e),process.stdout.write(`coze-bridge: not running (cleaned stale state)
181
191
  `),1;let c=await s.request({method:"GET",path:"/status"});return process.stdout.write(`coze-bridge: running
182
192
  ${JSON.stringify(c.body,null,2)}
183
- `),0}async function ah(n){let e=n.paths??G(),s=new Ne(e),o=await s.probe();if(o.kind==="not-running")return process.stdout.write(`coze-bridge: not running
184
- `),0;if(o.kind==="stale")return await Uc(e),process.stdout.write(`coze-bridge: not running (cleaned stale state)
193
+ `),0}async function dh(n){let e=n.paths??q(),s=new Le(e),o=await s.probe();if(o.kind==="not-running")return process.stdout.write(`coze-bridge: not running
194
+ `),0;if(o.kind==="stale")return await Wc(e),process.stdout.write(`coze-bridge: not running (cleaned stale state)
185
195
  `),0;try{return await s.request({method:"POST",path:"/shutdown"}),process.stdout.write(`coze-bridge: stopped
186
196
  `),0}catch(c){return process.stdout.write(`coze-bridge: stop failed: ${String(c)}
187
- `),1}}async function ch(n){let e=new Ne(n.paths);if((await e.probe()).kind==="not-running")return process.stdout.write(`coze-bridge: not running (start daemon first)
197
+ `),1}}async function uh(n){let e=new Le(n.paths);if((await e.probe()).kind==="not-running")return process.stdout.write(`coze-bridge: not running (start daemon first)
188
198
  `),1;try{let o=await e.request({method:"POST",path:"/refresh"});return o.status===200?(process.stdout.write(`coze-bridge: refreshed
189
199
  ${JSON.stringify(o.body,null,2)}
190
200
  `),0):(process.stderr.write(`coze-bridge: refresh failed: ${JSON.stringify(o.body)}
191
201
  `),1)}catch(o){return process.stderr.write(`coze-bridge: refresh failed: ${String(o)}
192
- `),1}}async function dh(n){let e=new Ne(n.paths);if((await e.probe()).kind==="connected"){process.stdout.write(`coze-bridge: stopping daemon...
193
- `);try{await e.request({method:"POST",path:"/shutdown"})}catch(d){process.stderr.write(`coze-bridge: stop failed (continuing): ${String(d)}
194
- `)}await new Promise(d=>setTimeout(d,500))}if(!n.skipSupervisor)try{let{getSupervisor:d,buildContext:u}=await Promise.resolve().then(()=>(Vi(),$i)),f=d();await f.uninstall(u()),process.stdout.write(`coze-bridge: ${f.platform} supervisor unregistered
195
- `)}catch(d){process.stderr.write(`coze-bridge: supervisor uninstall failed (continuing): ${String(d)}
196
- `)}let o=n.paths??G(),{rm:c}=await import("node:fs/promises");try{await c(o.cozeRoot,{recursive:!0,force:!0}),process.stdout.write(`coze-bridge: removed ${o.cozeRoot}
197
- `)}catch(d){return process.stderr.write(`coze-bridge: remove failed: ${String(d)}
202
+ `),1}}async function fh(n){let e=new Le(n.paths);if((await e.probe()).kind==="connected"){process.stdout.write(`coze-bridge: stopping daemon...
203
+ `);try{await e.request({method:"POST",path:"/shutdown"})}catch(x){process.stderr.write(`coze-bridge: stop failed (continuing): ${String(x)}
204
+ `)}await new Promise(x=>setTimeout(x,500))}if(!n.skipSupervisor)try{let{getSupervisor:x,buildContext:u}=await Promise.resolve().then(()=>(Yi(),Ji)),f=x();await f.uninstall(u()),process.stdout.write(`coze-bridge: ${f.platform} supervisor unregistered
205
+ `)}catch(x){process.stderr.write(`coze-bridge: supervisor uninstall failed (continuing): ${String(x)}
206
+ `)}let o=n.paths??q(),{rm:c}=await import("node:fs/promises");try{await c(o.cozeRoot,{recursive:!0,force:!0}),process.stdout.write(`coze-bridge: removed ${o.cozeRoot}
207
+ `)}catch(x){return process.stderr.write(`coze-bridge: remove failed: ${String(x)}
198
208
  `),1}return process.stdout.write(`coze-bridge: uninstalled
199
- `),0}async function xh(){try{let{getSupervisor:n,buildContext:e}=await Promise.resolve().then(()=>(Vi(),$i)),s=n(),o=e();return process.stdout.write(`coze-bridge: installing ${s.platform} supervisor...
209
+ `),0}async function lh(){try{let{getSupervisor:n,buildContext:e}=await Promise.resolve().then(()=>(Yi(),Ji)),s=n(),o=e();return process.stdout.write(`coze-bridge: installing ${s.platform} supervisor...
200
210
  `),await s.install(o),process.stdout.write(`coze-bridge: supervisor installed (daemon will auto-start on login)
201
211
  `),0}catch(n){return process.stderr.write(`coze-bridge: --install-service failed: ${String(n)}
202
- `),1}}async function uh(n,e,s,o={},c){let d=new Ne(s.paths),u=s.spawnDaemon??_n;if(!s.skipDistInstall){let p=await Ui({paths:s.paths});p.kind==="version-changed"?(process.stdout.write(`coze-bridge: upgraded ${p.fromVersion} \u2192 ${p.toVersion}
203
- `),(await d.probe()).kind==="connected"&&(await d.request({method:"POST",path:"/shutdown"}).catch(()=>{}),await new Promise(b=>setTimeout(b,500)))):p.kind==="first-install"&&process.stdout.write(`coze-bridge: installed ${p.libVersion}
204
- `)}let f=await d.probe();if(f.kind!=="connected"&&(process.stdout.write(`coze-bridge: starting daemon...
205
- `),await u({paths:s.paths}),f=await qc(d,s.waitTimeoutMs??1e4,s.sleep??Gc),f.kind!=="connected"))return process.stderr.write(`coze-bridge: daemon did not come up: ${f.kind}
206
- `),1;let h={privatecode:n,pairing_code:e};o.env&&(h.env=o.env),o.handshakeUrl&&(h.handshake_url=o.handshakeUrl),o.frontierUrl&&(h.frontier_url=o.frontierUrl),c&&(h.agent_id=c);try{let p=await d.request({method:"POST",path:"/pair",body:h,timeoutMs:35e3});return p.status===200&&p.body?.ok?(process.stdout.write(`coze-bridge: paired (${p.body.note??"ok"})
207
- `),0):(process.stderr.write(`coze-bridge: pair failed: ${JSON.stringify(p.body)}
208
- `),1)}catch(p){return process.stderr.write(`coze-bridge: pair failed: ${String(p)}
209
- `),1}}async function fh(n,e,s={}){let o=e.paths??G(),c=n??await gc(o);if(!c)return process.stderr.write("coze-bridge: \u627E\u4E0D\u5230 patToken \u2014 \u5148\u8DD1\u4E00\u6B21 `coze-bridge --pat-token=<sat_xxx> --pair-code=<xxx>` \u914D\u5BF9, \u6216\u672C\u6B21\u7528 `--pat-token` \u6307\u5B9A\n"),1;let d=new Ne(e.paths),u=e.spawnDaemon??_n;if(!e.skipDistInstall){let p=await Ui({paths:e.paths});p.kind==="version-changed"?(process.stdout.write(`coze-bridge: upgraded ${p.fromVersion} \u2192 ${p.toVersion}
210
- `),(await d.probe()).kind==="connected"&&(await d.request({method:"POST",path:"/shutdown"}).catch(()=>{}),await new Promise(b=>setTimeout(b,500)))):p.kind==="first-install"&&process.stdout.write(`coze-bridge: installed ${p.libVersion}
211
- `)}let f=await d.probe();if(f.kind!=="connected"&&(process.stdout.write(`coze-bridge: starting daemon...
212
- `),await u({paths:e.paths}),f=await qc(d,e.waitTimeoutMs??1e4,e.sleep??Gc),f.kind!=="connected"))return process.stderr.write(`coze-bridge: daemon did not come up: ${f.kind}
213
- `),1;let h={privatecode:c};s.env&&(h.env=s.env),s.handshakeUrl&&(h.handshake_url=s.handshakeUrl),s.frontierUrl&&(h.frontier_url=s.frontierUrl);try{let p=await d.request({method:"POST",path:"/connect",body:h,timeoutMs:35e3});return p.status===200&&p.body?.ok?(process.stdout.write(`coze-bridge: connected (${p.body.note??"ok"})
214
- `),await wn(c,o).catch(w=>zc.warn("writePatToken after connect failed (ignored)",{err:String(w)})),0):(process.stderr.write(`coze-bridge: connect failed: ${JSON.stringify(p.body)}
215
- `),1)}catch(p){return process.stderr.write(`coze-bridge: connect failed: ${String(p)}
216
- `),1}}async function qc(n,e,s){let o=Date.now()+e;for(;Date.now()<o;){let c=await n.probe(500);if(c.kind==="connected")return c;await s(200)}return n.probe(500)}function Gc(n){return new Promise(e=>setTimeout(e,n))}Fc(process.argv).then(n=>process.exit(n),n=>{process.stderr.write(`fatal: ${n instanceof Error?n.stack??n.message:String(n)}
212
+ `),1}}async function gh(n,e,s,o={},c){let x=new Le(s.paths),u=s.spawnDaemon??yn;if(!s.skipDistInstall){let m=await qi({paths:s.paths});m.kind==="version-changed"?(process.stdout.write(`coze-bridge: upgraded ${m.fromVersion} \u2192 ${m.toVersion}
213
+ `),(await x.probe()).kind==="connected"&&(await x.request({method:"POST",path:"/shutdown"}).catch(()=>{}),await new Promise(_=>setTimeout(_,500)))):m.kind==="first-install"&&process.stdout.write(`coze-bridge: installed ${m.libVersion}
214
+ `)}let f=await x.probe();if(f.kind!=="connected"&&(process.stdout.write(`coze-bridge: starting daemon...
215
+ `),await u({paths:s.paths}),f=await jc(x,s.waitTimeoutMs??1e4,s.sleep??$c),f.kind!=="connected"))return process.stderr.write(`coze-bridge: daemon did not come up: ${f.kind}
216
+ `),1;let g={privatecode:n,pairing_code:e};o.env&&(g.env=o.env),o.handshakeUrl&&(g.handshake_url=o.handshakeUrl),o.frontierUrl&&(g.frontier_url=o.frontierUrl),c&&(g.agent_id=c);try{let m=await x.request({method:"POST",path:"/pair",body:g,timeoutMs:35e3});return m.status===200&&m.body?.ok?(process.stdout.write(`coze-bridge: paired (${m.body.note??"ok"})
217
+ `),0):(process.stderr.write(`coze-bridge: pair failed: ${JSON.stringify(m.body)}
218
+ `),1)}catch(m){return process.stderr.write(`coze-bridge: pair failed: ${String(m)}
219
+ `),1}}async function hh(n,e,s={}){let o=e.paths??q(),c=n??await _c(o);if(!c)return process.stderr.write("coze-bridge: \u627E\u4E0D\u5230 patToken \u2014 \u5148\u8DD1\u4E00\u6B21 `coze-bridge --pat-token=<sat_xxx> --pair-code=<xxx>` \u914D\u5BF9, \u6216\u672C\u6B21\u7528 `--pat-token` \u6307\u5B9A\n"),1;let x=new Le(e.paths),u=e.spawnDaemon??yn;if(!e.skipDistInstall){let m=await qi({paths:e.paths});m.kind==="version-changed"?(process.stdout.write(`coze-bridge: upgraded ${m.fromVersion} \u2192 ${m.toVersion}
220
+ `),(await x.probe()).kind==="connected"&&(await x.request({method:"POST",path:"/shutdown"}).catch(()=>{}),await new Promise(_=>setTimeout(_,500)))):m.kind==="first-install"&&process.stdout.write(`coze-bridge: installed ${m.libVersion}
221
+ `)}let f=await x.probe();if(f.kind!=="connected"&&(process.stdout.write(`coze-bridge: starting daemon...
222
+ `),await u({paths:e.paths}),f=await jc(x,e.waitTimeoutMs??1e4,e.sleep??$c),f.kind!=="connected"))return process.stderr.write(`coze-bridge: daemon did not come up: ${f.kind}
223
+ `),1;let g={privatecode:c};s.env&&(g.env=s.env),s.handshakeUrl&&(g.handshake_url=s.handshakeUrl),s.frontierUrl&&(g.frontier_url=s.frontierUrl);try{let m=await x.request({method:"POST",path:"/connect",body:g,timeoutMs:35e3});return m.status===200&&m.body?.ok?(process.stdout.write(`coze-bridge: connected (${m.body.note??"ok"})
224
+ `),await _n(c,o).catch(y=>Hc.warn("writePatToken after connect failed (ignored)",{err:String(y)})),0):(process.stderr.write(`coze-bridge: connect failed: ${JSON.stringify(m.body)}
225
+ `),1)}catch(m){return process.stderr.write(`coze-bridge: connect failed: ${String(m)}
226
+ `),1}}async function jc(n,e,s){let o=Date.now()+e;for(;Date.now()<o;){let c=await n.probe(500);if(c.kind==="connected")return c;await s(200)}return n.probe(500)}function $c(n){return new Promise(e=>setTimeout(e,n))}Kc(process.argv).then(n=>process.exit(n),n=>{process.stderr.write(`fatal: ${n instanceof Error?n.stack??n.message:String(n)}
217
227
  `),process.exit(1)});