coze-bridge 0.1.41 → 0.1.42

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 +63 -62
  2. package/package.json +1 -1
package/dist/index.js CHANGED
@@ -5,25 +5,25 @@ import { dirname as __coze_dirname } from 'node:path';
5
5
  const require = __coze_createRequire(import.meta.url);
6
6
  const __filename = __coze_fileURLToPath(import.meta.url);
7
7
  const __dirname = __coze_dirname(__filename);
8
- var e0=Object.create;var Pr=Object.defineProperty;var t0=Object.getOwnPropertyDescriptor;var n0=Object.getOwnPropertyNames;var r0=Object.getPrototypeOf,i0=Object.prototype.hasOwnProperty;var V=(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 ze=(n,e)=>()=>(n&&(e=n(n=0)),e);var fe=(n,e)=>()=>(e||n((e={exports:{}}).exports,e),e.exports),Zi=(n,e)=>{for(var s in e)Pr(n,s,{get:e[s],enumerable:!0})},s0=(n,e,s,o)=>{if(e&&typeof e=="object"||typeof e=="function")for(let c of n0(e))!i0.call(n,c)&&c!==s&&Pr(n,c,{get:()=>e[c],enumerable:!(o=t0(e,c))||o.enumerable});return n};var Fe=(n,e,s)=>(s=n!=null?e0(r0(n)):{},s0(e||!n||!n.__esModule?Pr(s,"default",{value:n,enumerable:!0}):s,n));import{chmod as o0,mkdir as a0,readFile as c0,rename as Qi,writeFile as es}from"node:fs/promises";import{dirname as x0}from"node:path";async function pt(n){try{let e=await c0(n,"utf8");return JSON.parse(e)}catch(e){if(e.code==="ENOENT")return null;throw e}}async function on(n,e,s){await a0(x0(n),{recursive:!0});let o=`${JSON.stringify(e,null,2)}
9
- `,c=`${n}.tmp-${process.pid}-${Math.random().toString(36).slice(2,10)}`;try{s?.mode!==void 0?await es(c,o,{encoding:"utf8",mode:s.mode}):await es(c,o,"utf8"),await Qi(c,n),s?.mode!==void 0&&await o0(n,s.mode)}catch(d){await Qi(c,c).catch(()=>{});let{rm:f}=await import("node:fs/promises");throw await f(c,{force:!0}).catch(()=>{}),d}}var an=ze(()=>{"use strict"});function rs(n){return xn[ts]<=xn[n]}function dn(n){ns={...n}}function cn(n,e,s,o){if(xn[n]<xn[ts])return;let c=JSON.stringify({ts:new Date().toISOString(),level:n,module:e,msg:s,...ns,...o});n==="error"||n==="warn"?u0.write(`${c}
10
- `):d0.write(`${c}
11
- `)}function D(n){return{debug:(e,s)=>cn("debug",n,e,s),info:(e,s)=>cn("info",n,e,s),warn:(e,s)=>cn("warn",n,e,s),error:(e,s)=>cn("error",n,e,s),child:e=>D(`${n}.${e}`)}}var xn,ts,d0,u0,ns,U=ze(()=>{"use strict";xn={debug:10,info:20,warn:30,error:40},ts=(()=>{let n=process.env.COZE_BRIDGE_LOG_LEVEL;return n==="debug"||n==="info"||n==="warn"||n==="error"?n:"info"})(),d0=process.stdout,u0=process.stderr,ns={}});import{promises as is}from"node:fs";import{homedir as f0}from"node:os";import{sep as l0,join as re,resolve as ss}from"node:path";function F(n){let e=n??f0(),s=re(e,".coze"),o=re(s,"bridge"),c=re(o,"lib");return{cozeRoot:s,bridgeRoot:o,libDir:c,libEntry:re(c,"index.js"),binDir:re(o,"bin"),pidFile:re(o,"bridge.pid"),portFile:re(o,"bridge.port"),tokenFile:re(o,"bridge.token"),patTokenFile:re(o,"pat-token"),logFile:re(o,"bridge.log"),installLock:re(o,"install.lock"),configFile:re(o,"config.json"),agentsRoot:re(s,"agents")}}function Ue(n,e=F()){let s=re(e.agentsRoot,n);return{root:s,config:re(s,"config.json"),workspace:re(s,"workspace"),logs:re(s,"logs")}}async function os(n,e){let s=await is.realpath(ss(n)).catch(()=>null);if(!s)return!1;let o=await is.realpath(ss(e)).catch(()=>null);if(!o)return!1;let c=process.platform==="win32"?s.toLowerCase():s,d=process.platform==="win32"?o.toLowerCase():o;return c===d||c.startsWith(d+l0)}var ie=ze(()=>{"use strict"});var ln={};Zi(ln,{AGENT_CONFIG_FILE_MODE:()=>un,enforceAgentConfigMode:()=>p0,loadAgentConfig:()=>he,persistAgentSessions:()=>kr,persistAgentSkills:()=>fn,saveAgentConfig:()=>Ae});import{chmod as g0,stat as h0}from"node:fs/promises";function he(n,e){return pt(Ue(n,e).config)}function Ae(n,e){return on(Ue(n.agentId,e).config,n,{mode:un})}async function p0(n,e){if(process.platform==="win32")return;let s=Ue(n,e).config;try{let o=await h0(s);if(!o.isFile())return;let c=o.mode&511;c!==un&&(await g0(s,un),as.warn("agent config mode auto-corrected to 0600",{path:s,from:c.toString(8)}))}catch(o){if(o.code==="ENOENT")return;as.warn("enforceAgentConfigMode: chmod failed (ignored)",{path:s,err:String(o)})}}async function kr(n,e,s){let o=await he(n,s);o&&(o.sessions=Object.fromEntries(e),await Ae(o,s))}async function fn(n,e,s){let o=await he(n,s);o&&(o.skills=e,await Ae(o,s))}var as,un,Ye=ze(()=>{"use strict";an();U();ie();as=D("agent-config"),un=384});var Co=fe(X=>{"use strict";var A=I;(function(n,e){let s=I,o=n();for(;;)try{if(parseInt(s(1720))/1+-parseInt(s(1694))/2+parseInt(s(971))/3+parseInt(s(1778))/4+parseInt(s(991))/5*(-parseInt(s(1823))/6)+-parseInt(s(1674))/7*(parseInt(s(485))/8)+parseInt(s(1812))/9===e)break;o.push(o.shift())}catch{o.push(o.shift())}})(Kn,708082);var kd=Object.defineProperty,Td=Object[A(970)+A(1692)+A(1791)],vo=(n,e)=>function(){return n&&(e=(0,n[{trSjr:function(d,f){return d(f)}}[A(1474)](Td,n)[0]])(n=0)),e},Dd=(n,e)=>{for(var s in e)kd(n,s,{get:e[s],enumerable:!0})};function Rd(){return po||(po=[IDBDatabase,IDBObjectStore,IDBIndex,IDBCursor,IDBTransaction])}function Nd(){let n=A;return mo||(mo=[IDBCursor[n(417)+"e"][n(650)],IDBCursor.prototype[n(1145)],IDBCursor[n(417)+"e"][n(1145)+n(1390)+"ey"]])}function Ld(n){let e=A,s={grRwk:"success",qxgro:e(1154),CTDHP:e(1453),bnzdT:e(1219),WBaeb:function(c,d){return c(d)},yNbVU:function(c,d){return c(d)},MNYHH:function(c){return c()},xQpNJ:function(c,d){return c(d)},Cwgnu:function(c){return c()},zwdDY:function(c,d){return c&d},CUsqN:function(c,d){return c<<d},UOoth:function(c,d){return c>=d},PgOvc:function(c,d){return c<=d},UGusa:function(c,d){return c instanceof d}},o=new Promise((c,d)=>{let f=e,l={lwrxF:function(_,E){return _|E},GgGTE:function(_,E){return s[I(1775)](_,E)},dTejG:function(_,E){return s[I(506)](_,E)},aTKws:function(_,E){return s[I(1775)](_,E)},wRnkt:function(_,E){return s[I(1537)](_,E)},LAoVj:function(_,E){return s.PgOvc(_,E)},BxQrY:function(_,E){return _(E)}},m=()=>{let _=I;n[_(1626)+_(603)+_(1242)](s[_(1594)],w),n[_(1626)+_(603)+_(1242)](s.qxgro,v)},w=()=>{let _=I;s[_(1784)]===s.bnzdT?(_0x48147e=l.lwrxF(l[_(1433)](15,_0x2af361)<<12,l[_(978)](l[_(459)](63,_0x3cd098),6))|l.GgGTE(63,_0x551768),_0x3b3ea3<2048||l[_(541)](_0x408ac3,55296)&&l[_(618)](_0x463af7,57343)?_0x422d50+=_0xc9c4dd:(_0x3c1b7c+=l[_(1049)](_0x3f912e,_0x4599ea),_0x44b2f9+=2)):(s[_(965)](c,s[_(694)](Le,n[_(1446)])),s[_(575)](m))},v=()=>{let _=I;s[_(1583)](d,n.error),s[_(1260)](m)};n[f(1016)+"Listener"](s[f(1594)],w),n[f(1016)+f(880)]("error",v)});return o[e(949)](c=>{s.UGusa(c,IDBCursor)&&Wr.set(c,n)})[e(1555)](()=>{}),qn[e(936)](o,n),o}function Od(n){let e=A,s={WpFgR:e(1154),SEZYG:e(1004),EgOPF:function(c){return c()},rzVqv:function(c,d){return c(d)},hevHv:e(643)+"or",ryWZf:e(774)};if(Un.has(n))return;let o=new Promise((c,d)=>{let f=e,l={bJdZq:function(_){return s.EgOPF(_)},QFwOM:function(_,E){return s[I(751)](_,E)},IMCkQ:s[f(609)]},m=()=>{let _=f;n[_(1626)+_(603)+_(1242)]("complete",w),n.removeEventListener(s[_(1499)],v),n[_(1626)+_(603)+_(1242)](s[_(1160)],v)},w=()=>{let _=f;c(),l[_(1734)](m)},v=()=>{let _=f;l[_(467)](d,n[_(1154)]||new DOMException(_(643)+"or",l[_(1546)])),l[_(1734)](m)};n[f(1016)+f(880)](s[f(1492)],w),n[f(1016)+f(880)](f(1154),v),n.addEventListener(s.SEZYG,v)});Un[e(936)](n,o)}function Bd(n){Hn={UjabM:function(o,c){return o(c)}}[A(1188)](n,Hn)}function Md(n){let e=A,s={JvgbG:function(o,c){return o(c)},tjDMn:function(o,c){return o(c)},qsFNg:function(o,c){return o(c)},Nxhen:function(o,c){return o(c)},iqaFl:function(o,c){return o===c},SoKIm:"objectSt"+e(1191)};if(s.iqaFl(n,IDBDatabase[e(417)+"e"][e(670)+e(425)])&&!(s[e(1544)]in IDBTransaction[e(417)+"e"]))return function(o,...c){let d=e,f=n[d(1297)](s[d(1070)]($t,this),o,...c);return Gr[d(936)](f,o[d(466)]?o[d(466)]():[o]),s[d(1763)](Le,f)};if(Nd().includes(n))if(s[e(493)](e(1618),e(903)))++_0x498e5f,_0x5069df+=4;else return function(...o){let c=e;return n[c(1564)](s[c(1070)]($t,this),o),s[c(1763)](Le,Wr[c(1330)](this))};return function(...o){let c=e;return s[c(1324)](Le,n[c(1564)](s.Nxhen($t,this),o))}}function zd(n){let e=A,s={itQuk:function(o,c){return o===c},Slzqu:function(o,c){return o(c)},Qjpec:function(o,c){return o instanceof c},GAslT:function(o){return o()}};return s[e(664)](typeof n,"function")?s.Slzqu(Md,n):(s[e(1707)](n,IDBTransaction)&&Od(n),bo(n,s[e(910)](Rd))?new Proxy(n,Hn):n)}function Le(n){let e=A,s={zmtKm:function(c,d){return c instanceof d},qsqqB:function(c,d){return c(d)},RwtTj:function(c,d){return c!==d}};if(s[e(1712)](n,IDBRequest))return s[e(724)](Ld,n);if(zn[e(1231)](n))return zn[e(1330)](n);let o=s[e(724)](zd,n);return s[e(1347)](o,n)&&(zn[e(936)](n,o),qn[e(936)](o,n)),o}var bo,po,mo,Wr,Un,Gr,zn,qn,Hn,$t,wo=vo({"node_modules/idb/build/wrap-idb-value.js"(){let n=A,e={bpQSU:function(s,o,c){return s(o,c)},IVDjN:n(1235)+n(1682)+"s",ugTHN:n(1235)+n(908)+"t",QvFfj:n(1268),LzAhS:function(s,o){return s instanceof o},ElTJj:function(s,o){return s===o},WIpUL:"done",MlhNI:n(1041)+n(1191),IaxHX:function(s,o){return s===o},GfLFK:n(1110),QjPfu:function(s,o){return s(o)},VzAga:function(s,o){return s===o},Wkdtf:function(s,o){return s in o}};bo=(s,o)=>o.some(c=>s instanceof c),Wr=new WeakMap,Un=new WeakMap,Gr=new WeakMap,zn=new WeakMap,qn=new WeakMap,Hn={get(s,o,c){let d=n,f={ZXnRp:d(1189),IairL:function(l,m,w){return e[d(1367)](l,m,w)},zlWBa:e[d(1713)],FVzMj:e[d(1251)]};if(e[d(1383)]===d(675)){let l={yjxsv:f[d(981)],VuWnI:f.FVzMj};return new _0x19d84f((m,w)=>{let v=d,_={FOpKQ:f[v(1611)]};this[v(933)+v(1222)](),this[v(1337)+v(1658)+"Id"]=f[v(1656)](_0x2489ff,this[v(1657)].bind(this),this[v(1111)]["pingInte"+v(748)]);let E=()=>{let P=v;m(_[P(610)]),this.off(P(1235)+P(1682)+"s",E),this[P(1578)]("ping_onc"+P(908)+"t",T)},T=()=>{let P=v;w(P(1117)),this[P(1578)](l[P(638)],E),this.off(l[P(788)],T)};this.on(f.zlWBa,E),this.on(f[v(1860)],T),this[v(1657)]()})}else{if(e[d(1257)](s,IDBTransaction)){if(e.ElTJj(o,e[d(1200)]))return Un[d(1330)](s);if(o===e[d(414)])return s[d(1041)+d(1191)]||Gr[d(1330)](s);if(e.IaxHX(o,e[d(1503)]))return c.objectStoreNames[1]?void 0:c[d(1041)+"ore"](c[d(1041)+"oreNames"][0])}return e[d(857)](Le,s[o])}},set(s,o,c){return s[o]=c,!0},has(s,o){let c=n;return e.LzAhS(s,IDBTransaction)&&(e[c(1727)](o,e.WIpUL)||e[c(612)](o,e[c(1503)]))?!0:e[c(707)](o,s)}},$t=s=>qn[n(1330)](s)}}),So={};Dd(So,{deleteDB:()=>Ud,openDB:()=>Fd,unwrap:()=>$t,wrap:()=>Le});function Fd(n,e,{blocked:s,upgrade:o,blocking:c,terminated:d}={}){let f=A,l={yMtGN:function(v,_,E,T,P){return v(_,E,T,P)},lVOtQ:function(v,_){return v(_)},MOrmj:function(v,_){return v(_)},apVqc:f(1348),zyJDQ:"versionc"+f(1169),EPXPM:function(v,_){return v(_)},IuUMu:f(495)+"eeded",MyOuf:f(671)},m=indexedDB[f(879)](n,e),w=l[f(1855)](Le,m);return o&&m[f(1016)+f(880)](l[f(1477)],v=>{let _=f;l[_(550)](o,l.lVOtQ(Le,m[_(1446)]),v.oldVersion,v[_(1745)+"on"],l[_(1085)](Le,m[_(670)+"ion"]))}),s&&m[f(1016)+f(880)](l[f(405)],()=>s()),w[f(949)](v=>{let _=f;d&&v[_(1016)+_(880)](l[_(1009)],()=>d()),c&&v[_(1016)+_(880)](l[_(606)],()=>c())})[f(1555)](()=>{}),w}function Ud(n,{blocked:e}={}){let s=A,o={ujKph:"blocked",VmVWv:function(d,f){return d(f)}},c=indexedDB[s(1818)+s(1547)](n);return e&&c[s(1016)+s(880)](o[s(1501)],()=>e()),o.VmVWv(Le,c)[s(949)](()=>{})}function I(n,e){n=n-374;let s=Kn(),o=s[n];if(I.vXFGWJ===void 0){var c=function(m){let w="abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789+/=",v="",_="";for(let E=0,T,P,R=0;P=m.charAt(R++);~P&&(T=E%4?T*64+P:P,E++%4)?v+=String.fromCharCode(255&T>>(-2*E&6)):0)P=w.indexOf(P);for(let E=0,T=v.length;E<T;E++)_+="%"+("00"+v.charCodeAt(E).toString(16)).slice(-2);return decodeURIComponent(_)};I.YOyGnA=c,I.WfTXKW={},I.vXFGWJ=!0}let d=s[0],f=n+d,l=I.WfTXKW[f];return l?o=l:(o=I.YOyGnA(o),I.WfTXKW[f]=o),o}function _o(n,e){let s=A,o={FRYpd:"readonly",TSonv:function(m,w){return m instanceof w},kAABD:function(m,w){return m in w},mXrfy:function(m,w){return m===w},ltexy:function(m,w){return m!==w}};if(!(o[s(1847)](n,IDBDatabase)&&!o[s(733)](e,n)&&o.mXrfy(typeof e,s(1639))))return;if(Fn.get(e))return Fn[s(1330)](e);let c=e[s(1533)](/FromIndex$/,""),d=o[s(678)](e,c),f=Ao[s(1196)](c);if(!o[s(733)](c,(d?IDBIndex:IDBObjectStore)[s(417)+"e"])||!(f||Eo[s(1196)](c)))return;let l=async function(m,...w){let v=s,_=this[v(670)+v(425)](m,f?v(1756)+"e":o[v(1007)]),E=_[v(1110)];return d&&(E=E[v(579)](w.shift())),(await Promise[v(864)]([E[c](...w),f&&_[v(1511)]]))[0]};return Fn[s(936)](e,l),l}var Eo,Ao,Fn,qd=vo({"node_modules/idb/build/index.js"(){let n=A,e={EWvuT:function(c,d){return c(d)},prnkf:function(c){return c()},QsBMn:n(1330),aFkmb:n(1524),eTOSn:"getAll",PCWWA:n(598)+"ys",UMiyf:"count",FxudZ:n(752),UqVFx:n(1273),ilCeN:n(1114),MFPIM:n(473),tAeZN:function(c){return c()}},s=(n(754)+n(944))[n(582)]("|"),o=0;for(;;){switch(s[o++]){case"0":e[n(997)](Bd,c=>({...c,get:(d,f,l)=>_o(d,f)||c[n(1330)](d,f,l),has:(d,f)=>!!_o(d,f)||c[n(1231)](d,f)}));continue;case"1":e[n(1101)](wo);continue;case"2":Eo=[e.QsBMn,e.aFkmb,e.eTOSn,e.PCWWA,e[n(1634)]];continue;case"3":Fn=new Map;continue;case"4":Ao=[e.FxudZ,e[n(1803)],e[n(1603)],e[n(768)]];continue;case"5":e[n(958)](wo);continue}break}}}),Hd={idb:function(n){let e=A;n[e(904)]=Promise[e(705)]()[e(949)](()=>(qd(),So))[e(949)](function(s){return s})}},yo={};function Ne(n){let e=A,s={UGDIx:function(l,m){return l!==m}},o="0|1|3|2|4".split("|"),c=0;for(;;){switch(o[c++]){case"0":var d=yo[n];continue;case"1":if(s[e(1620)](void 0,d))return d.exports;continue;case"2":Hd[n](f,f[e(904)],Ne);continue;case"3":var f=yo[n]={exports:{}};continue;case"4":return f[e(904)]}break}}Ne.d=(n,e)=>{let s=I;for(var o in e)Ne.o(e,o)&&!Ne.o(n,o)&&Object[s(673)+s(1306)](n,o,{enumerable:!0,get:e[o]})},(()=>{let n=A;Ne.o=(e,s)=>Object[n(417)+"e"][n(1293)+n(1306)][n(1297)](e,s)})(),(()=>{let n=A,e={qxOIy:function(s,o){return s!=o},afyeH:"undefined",ftYqy:n(1552)+"le"};Ne.r=s=>{let o=n;e[o(1666)](e[o(847)],typeof Symbol)&&Symbol[o(1604)+o(647)]&&Object.defineProperty(s,Symbol["toString"+o(647)],{value:o(1375)}),Object[o(673)+o(1306)](s,e.ftYqy,{value:!0})}})();var $={};(()=>{let n=A,e={gquhe:function(i,t,r){return i(t,r)},JkNFQ:function(i,t){return i>>>t},KKZhU:function(i,t){return i<<t},kxcSs:n(1352),xMBWe:function(i,t){return i(t)},PGoRd:function(i,t){return i+t},pPHlV:function(i,t){return i+t},udykD:function(i,t){return i+t},OHaTF:function(i,t){return i+t},EafrD:function(i,t){return i*t},bLVKf:function(i,t){return i*t},lZxZm:n(1650),qEHxc:n(1642),QAGys:function(i,t){return i+t},HUINs:function(i,t,r){return i(t,r)},MMspS:function(i,t){return i+t},AxtlS:function(i,t){return i+t},XxKzw:function(i,t){return i(t)},kMHPy:n(617),EfvAz:"ffff",tRdlc:function(i,t){return i(t)},xIpjT:function(i,t){return i(t)},yLfzV:function(i,t){return i>t},ffREg:function(i,t){return i<t},XtZgm:function(i,t){return i-t},kUrlF:function(i,t){return i!==t},bJWLZ:function(i,t){return i-t},xeulk:function(i,t){return i<t},VBVes:function(i,t){return i-t},TdcCb:function(i,t){return i<t},gXxjj:function(i,t){return i===t},caxwW:function(i,t){return i<t},qKVxG:function(i,t){return i!==t},kjUBw:function(i,t){return i!==t},eWVpQ:n(1309),SCPox:n(646),kjMeu:function(i,t,r){return i(t,r)},xTsso:n(1235)+n(908)+"t",ZmxfE:function(i,t){return i(t)},eWzIg:n(1189),TAfxp:function(i,t){return i(t)},NiYra:n(1127),AGebz:n(1099),vyZar:function(i,t){return i(t)},rssLg:function(i,t){return i(t)},pNSfa:function(i,t){return i(t)},WEttl:function(i,t){return i&t},HmDGl:function(i,t){return i===t},ubCdt:n(902)+n(1835)+" field: "+n(1182),jUZQE:function(i,t){return i===t},Kbtdx:function(i,t,r,a){return i(t,r,a)},QZwYI:function(i,t,r){return i(t,r)},aLVPD:n(563),sFrjG:n(1697),yMBGP:function(i){return i()},EQRHa:function(i,t,r){return i(t,r)},yqSWR:function(i,t){return i(t)},xQnUV:function(i,t){return i(t)},TANBn:function(i,t){return i!==t},WgLEm:function(i,t,r){return i(t,r)},CpnLT:function(i,t){return i!==t},rBNkf:n(407),XENih:n(1079),FuAIa:function(i,t,r){return i(t,r)},HkCZm:function(i,t){return i!==t},mBNxZ:function(i,t,r){return i(t,r)},JyEvk:function(i){return i()},cgLVZ:function(i,t,r){return i(t,r)},FLDtK:function(i,t,r){return i(t,r)},gCDxR:function(i,t){return i(t)},xntIY:function(i,t){return i!==t},QeExa:function(i,t,r){return i(t,r)},zrfiD:function(i,t,r){return i(t,r)},losHe:function(i,t,r){return i(t,r)},bEXGE:function(i,t,r){return i(t,r)},bbXnD:function(i,t,r){return i(t,r)},gcUuS:function(i,t){return i!==t},vXoFU:function(i,t,r){return i(t,r)},NVZIB:function(i,t,r){return i(t,r)},oXTVN:function(i,t,r){return i(t,r)},Fjytr:n(1154),zwTbu:function(i,t){return i(t)},pTJxs:function(i,t){return i(t)},riMDk:function(i,t){return i(t)},uKnqC:function(i,t){return i(t)},UsciG:function(i,t,r){return i(t,r)},wUcZe:function(i,t,r){return i(t,r)},zpiNh:n(902)+"required"+n(1206)+n(852),jGJYJ:function(i,t){return i===t},NAKkE:"Missing "+n(1835)+" field: "+n(1423),MCFdZ:n(902)+n(1835)+" field: method",NhNkD:function(i,t){return i(t)},LUCeB:function(i,t,r){return i(t,r)},TThRT:function(i,t,r){return i(t,r)},PlLLy:n(1519)+n(1519)+n(1519)+"00000000",MqYFy:function(i,t){return i===t},SjgxP:n(1736),ZSLFp:n(526),aXOUF:function(i,t){return i>>t},YVfMy:function(i,t){return i>=t},NLyNp:function(i,t){return i===t},nKEpB:function(i,t){return i>t},cmALL:function(i,t){return i*t},IldpJ:function(i,t){return i>t},NrCSl:function(i,t){return i!==t},vbUwU:n(1042),FnyVZ:function(i,t){return i>t},NInuu:"Skip past limit",PxzpR:function(i,t){return i>=t},CaboQ:function(i,t){return i>t},BaAUV:function(i,t){return i+t},UHXWI:n(562)+n(469),PIBDG:n(1400),YxuiM:"exTXx",xoZSK:function(i,t,r){return i(t,r)},gKURC:function(i,t){return i&t},PHOKk:function(i,t){return i(t)},PVLjw:function(i,t){return i&t},nDRJz:function(i,t){return i>=t},BMFPd:function(i,t){return i&t},wgTRO:n(689),wyBCn:function(i,t){return i|t},mKREL:function(i,t){return i<<t},mUqAL:function(i,t){return i&t},tqWBl:function(i,t){return i==t},AaHji:function(i,t){return i&t},dfDRM:function(i,t){return i>=t},AezkC:function(i,t){return i+t},GiBDy:function(i,t){return i+t},zkpSD:function(i,t){return i+t},lhvDW:function(i,t){return i&t},aOTqT:function(i,t){return i<<t},SFccm:function(i,t){return i|t},nyNLI:function(i,t){return i|t},kYIyR:function(i,t){return i<<t},wRHPl:function(i,t){return i<<t},AWmsd:function(i,t){return i>=t},uwCEt:function(i,t){return i<=t},cBoHA:function(i,t){return i==t},CWvwA:function(i,t){return i&t},FZbhy:function(i,t){return i+t},FeCqG:function(i,t){return i!==t},CJLrE:function(i,t){return i|t},lvlSe:function(i,t){return i<<t},FfiHc:function(i,t){return i<<t},FZkOo:function(i,t){return i<<t},iiqTh:function(i,t){return i<<t},tbcAr:function(i,t){return i>t},qBZWx:function(i,t){return i<t},BnLlE:function(i,t){return i!==t},yKPQD:n(1185),rkXsu:function(i,t){return i>=t},pYwRm:function(i,t){return i<t},tIEbm:function(i,t){return i<t},zxKKO:function(i,t){return i>=t},ywOJd:function(i,t){return i<=t},fKhkn:function(i,t){return i<t},nzQNm:function(i,t){return i-t},yldCJ:function(i,t){return i<t},rjVHm:function(i,t){return i<t},wJrpD:function(i,t){return i>>t},QmLTf:function(i,t){return i&t},iaezv:function(i,t){return i|t},RraWj:function(i,t){return i&t},VZnmb:function(i,t){return i>>t},GJkvv:function(i,t){return i&t},yOLWX:function(i,t,r){return i(t,r)},KfIpJ:function(i,t){return i*t},EbKcL:function(i,t){return i>>>t},MgYdE:function(i,t){return i+t},ETZEA:function(i,t){return i*t},jRsyg:function(i,t){return i>>>t},iNLZw:function(i,t){return i===t},fhJpR:"LHpab",KOSTc:n(1590),vlsfk:function(i,t){return i<t},LGSHk:function(i,t){return i>=t},Aotcl:function(i,t,r){return i(t,r)},wkOxp:function(i,t){return i|t},XzQam:function(i,t){return i&t},MOMXA:function(i,t){return i&t},wvbDu:function(i,t){return i(t)},jmrvc:function(i,t){return i<<t},oYJrw:function(i,t){return i&t},TdwOj:function(i,t){return i&t},GLfTx:function(i,t){return i&t},vxSJI:function(i,t){return i(t)},fDqyK:function(i,t){return i(t)},LsyrI:function(i,t){return i&t},lnRya:function(i,t){return i&t},oGLpW:function(i,t){return i&t},AhGLX:function(i,t){return i&t},DAdYW:function(i,t){return i(t)},ARzHS:function(i,t){return i&t},mUWlV:function(i,t){return i|t},JgtYF:function(i,t){return i<<t},RPRGA:function(i,t){return i===t},TKBtJ:function(i,t){return i<t},GzaRf:function(i,t){return i>>>t},qcDNv:function(i,t){return i|t},sPtAt:function(i,t){return i&t},EPbPi:function(i,t){return i!==t},XllAX:function(i,t){return i|t},hfkul:function(i,t){return i>>>t},CMVUT:function(i,t){return i|t},dLTmv:function(i,t){return i>>>t},flZfX:function(i,t){return i&t},bcEPq:function(i,t){return i!==t},UFGDO:function(i,t){return i+t},mJOhv:function(i,t){return i+t},TeOEd:function(i,t){return i!==t},icLqK:function(i,t){return i&t},dnkCF:function(i,t){return i(t)},rAWWh:function(i,t){return i===t},NxExP:n(642),GCQbJ:n(987),avqPr:n(1750),YbUXP:function(i,t){return i|t},HNeqI:function(i,t){return i|t},rThJY:function(i,t){return i|t},rucEH:function(i,t){return i<<t},MxfUo:function(i,t){return i|t},dCbdV:function(i,t){return i|t},FJkVC:function(i,t){return i<<t},lkScX:n(1505),rCNUI:function(i,t){return i===t},DCYXY:function(i,t){return i|t},FPoUB:function(i,t){return i|t},Zzwsr:function(i,t){return i|t},eqAHJ:function(i,t){return i|t},FTJxP:function(i,t){return i<<t},oErLY:function(i,t){return i&t},AEHdN:function(i,t){return i&t},REsxF:function(i,t){return i>>>t},bwiAG:function(i,t){return i>>>t},byJME:function(i,t){return i&t},kKgwW:function(i,t){return i>>>t},zsVru:function(i,t){return i>>>t},XOfAv:function(i,t){return i||t},exJWU:function(i,t){return i(t)},IgKBa:function(i,t){return i+t},RKCGp:function(i,t){return i|t},CWBLI:"DacEo",gfRMI:n(632),PHxVw:function(i,t){return i+t},pzoZw:function(i,t){return i%t},LIEGA:function(i,t){return i/t},ElrFF:function(i,t){return i+t},QhVqH:function(i,t){return i*t},Dlzoy:function(i,t){return i>>>t},ZJXlN:function(i,t){return i>>>t},QhXfm:function(i,t){return i===t},JnUzt:function(i,t){return i>>>t},poooq:function(i,t){return i>>>t},nGJeA:function(i,t){return i>>>t},JtNho:function(i,t){return i+t},bvODO:function(i,t){return i+t},ERCsu:function(i,t){return i>>>t},xwfpn:function(i,t){return i+t},aoVZd:function(i,t){return i<<t},hBxgX:function(i,t){return i|t},UddHj:function(i,t){return i<<t},IvjPL:function(i,t){return i===t},nlFVH:function(i,t){return i===t},qnYSS:function(i,t){return i===t},YMkbc:function(i,t){return i>>>t},FOUba:function(i,t){return i>>>t},HtvQo:function(i,t){return i>>>t},CrcjV:n(778),ERgsP:"tGcoQ",HNbre:function(i,t){return i>>>t},aXpYo:function(i,t){return i>>>t},lRiJq:function(i,t){return i>>>t},YUjdB:function(i,t){return i>>>t},iSQFA:function(i,t){return i>>>t},mWqVH:function(i,t){return i!==t},lLEsu:n(804),bvPyO:"2|5|3|1|0|4",ZDneI:n(1093)+"OR",psPkF:n(1670)+n(1029),ZjFAj:n(1138)+n(1800),wVbLQ:"MAX_RETR"+n(412)+"R",yWhJg:"CONNECTI"+n(1066),kdNuG:n(401)+n(737),heEom:n(510)+"1",TZgiK:function(i,t){return i===t},PXRfu:n(1277),vkBEc:n(1272)+n(1838)+n(823)+"8",lneTY:function(i,t){return i>>>t},dZOGr:function(i,t){return i&t},VWCYg:function(i,t){return i<<t},wbkBA:function(i,t,r,a){return i(t,r,a)},upSIX:function(i,t){return i<t},jEMNJ:function(i,t){return i|t},JODQF:function(i,t){return i===t},OhiyK:n(870),GxSDT:n(948),Pkdny:"close",hGcqb:"YkSyL",rBmiD:n(1357),UUMjE:n(1690),DaTul:function(i,t,r){return i(t,r)},vvRJW:function(i,t){return i<t},UxdCK:function(i,t){return i&t},ArviJ:function(i,t){return i===t},IFBRP:function(i,t){return i&t},qmgNG:n(1141)+"3|1",ejyLS:function(i,t){return i&t},JoFSD:function(i,t){return i>>t},ngGNp:function(i,t){return i|t},ozUUf:function(i,t){return i===t},uxCJZ:n(1323),sTowI:function(i,t){return i instanceof t},cSooN:function(i,t){return i+t},PXjcG:function(i,t){return i||t},vCzgo:function(i,t){return i||t},dsgIP:n(1398)+"d",QIBzl:function(i,t){return i!==t},CZHKf:n(391),yRYKE:"0|1|3|4|2",ERoJV:function(i,t){return i!=t},kWmsS:function(i,t){return i===t},sIkmE:n(1493),jHGFp:n(934),tFEug:function(i,t){return i<t},LbjuK:function(i,t){return i===t},RxLlE:function(i,t){return i&t},wqPRY:function(i,t){return i+t},fqnXn:function(i,t){return i<=t},WUHDT:function(i,t){return i>=t},odwZk:function(i,t){return i|t},jDpUn:function(i,t){return i&t},Pnxgc:function(i,t){return i&t},lOBNJ:function(i,t){return i>=t},FlQUv:function(i,t){return i<t},Vvgzu:function(i,t){return i|t},VZKki:function(i,t){return i|t},XFaQn:function(i,t){return i<<t},FzWld:function(i,t){return i&t},lXMDg:function(i,t){return i<<t},JMgCu:function(i,t){return i|t},AqmqP:function(i,t){return i&t},yeFxd:function(i,t){return i<<t},jlYPE:function(i,t){return i<<t},ejWWA:function(i,t){return i&t},ghgyv:function(i,t){return i+t},ANUcw:function(i,t){return i&t},EaKgf:function(i,t){return i<t},Aiedt:function(i,t){return i|t},ozezR:function(i,t){return i&t},Jzipa:function(i,t){return i>>t},NLqgo:function(i,t){return i|t},hNaVP:function(i,t){return i&t},QgKte:function(i,t){return i===t},sHrPC:"Argst",JbvII:"cqbyS",jRFiC:function(i,t){return i>>t},pdNaV:function(i,t){return i|t},MNozI:function(i,t){return i&t},CyiJh:function(i,t){return i&t},hiahO:function(i,t){return i-t},gyJDh:n(1639),jQQhU:function(i,t,r,a){return i(t,r,a)},HLwuZ:n(1171)+"ion/json",oNRIh:n(734),kKjXt:"ppe",JeRQg:n(745),zAIig:function(i,t){return i!==t},vQDZW:n(872),CsKZg:function(i,t){return i<t},UMSWD:function(i,t){return i|t},nXauP:function(i,t){return i&t},lrGLj:function(i,t){return i!==t},Fobky:n(1605),PqicJ:n(920)+n(611),exYUl:n(516),uWjzT:n(392)+n(623),YTaVJ:n(1376),DTYdp:n(1303)+"ack=fron"+n(1591)+"P",cGdCU:function(i,t){return i===t},mRfOy:n(1267),cHkrx:n(448),PDRCY:function(i,t){return i(t)},WkUrP:function(i,t){return i>>>t},RuGWC:function(i,t){return i>>>t},mEsoq:function(i,t){return i!==t},KbccM:"haajk",GQSvX:n(1401),wuPXi:"idb",jrkoP:function(i,t){return i&t},icowd:n(571),eOfos:n(1298),vlXcB:n(1102),yMeMX:n(1152),NeIRd:function(i,t){return i!==t},CAwwL:n(1245),gfCdx:n(930),ggFrA:"Unhandle"+n(1050),DOjen:function(i,t){return i!==t},weJpK:n(1300),KlANV:n(655),oyuzW:"kOWQs",ERkdd:n(795),GIIcT:function(i,t){return i||t},lmWIK:function(i,t){return i||t},cKnDl:function(i,t){return i||t},VWVip:function(i,t){return i||t},qZBHv:function(i,t){return i||t},iZdQy:function(i,t){return i===t},ZfYUp:"qxAXr",daazS:n(1215),VzUTS:function(i,t){return i||t},NMWcZ:n(477)+n(1349)+"d",wMPsA:"qos",tPmYp:function(i,t){return i(t)},iCzHj:n(1703),QegRr:function(i,t){return i||t},ytECp:n(1377),YLMGY:n(846),gCFVm:n(1465),YhiQE:n(387),zqqbM:n(1028),AvOWF:"SGsUq",iqAkg:function(i,t){return i(t)},mddBZ:"x_fronti"+n(434),GFBDj:n(1214)+n(845)+"ck",kYUnH:n(1214)+n(1779)+"k",fyvhr:n(1214)+n(1133)+n(1083),fBIGV:function(i,t,r){return i(t,r)},dlHXW:function(i,t,r,a){return i(t,r,a)},bCHfm:"need_ack",cBwjg:function(i,t){return i&&t},cNszP:n(1248),tJuwe:function(i){return i()},KBXUb:"received",SRMfl:function(i,t){return i(t)},jeQRQ:n(1434),IXuHj:"UReQX",xtEbi:function(i,t){return i instanceof t},sjvnx:function(i,t){return i instanceof t},SOrOt:n(816)+n(1290)+n(537),HFIKk:n(1171)+n(497)+";charset=utf-8",XKmcg:n(1116)+"e",QtQJO:function(i,t){return i<t},bskcB:function(i,t){return i(t)},jOYSZ:function(i,t){return i(t)},crEbC:function(i,t){return i&t},isMVd:function(i,t){return i|t},xYGiV:function(i,t){return i(t)},MmozE:function(i,t){return i+t},ZNlEN:function(i,t){return i+t},odcOK:function(i,t){return i+t},bKRRk:n(995)+n(484)+n(482),wRaxm:n(375),ZLkfP:function(i,t){return i||t},zxtSE:" > ",gUbFu:function(i,t){return i>t},JGsEr:"integer "+n(770)+"e",aAwSj:function(i,t){return i>=t},FvpKF:function(i,t,r,a){return i(t,r,a)},sQepp:function(i,t){return i+t},eNQpo:function(i,t){return i<t},uNPXy:function(i,t){return i>>>t},nYYiq:function(i,t){return i+t},IkNAX:function(i,t){return i|t},sgmpK:function(i,t){return i<<t},RyKKC:function(i,t){return i+t},NINLT:function(i,t){return i+t},EYZRQ:function(i,t){return i|t},GQTAY:function(i,t){return i<<t},wINmQ:function(i,t){return i<<t},mXtra:function(i,t){return i>>>t},Gmjxr:function(i,t){return i&t},xCOgG:function(i,t){return i>>>t},QxCXR:function(i,t){return i+t},BFsqz:function(i,t){return i+t},HlTrd:function(i,t){return i+t},rbVFm:function(i,t){return i&t},LpMcU:function(i,t){return i+t},HLdXo:function(i,t){return i&t},adQZB:function(i,t){return i+t},vdbZW:function(i,t){return i&t},fpwHG:function(i,t){return i+t},ocCyI:function(i,t){return i|t},wCvIZ:function(i,t){return i|t},xOaOR:function(i,t){return i<<t},ehJcj:function(i,t){return i>>>t},YuYPb:function(i,t){return i&t},OFcEi:function(i,t){return i<t},HtZwz:function(i,t){return i<<t},IGpMx:function(i,t){return i<t},aUPyW:n(1136),zSGPl:function(i,t){return i|t},HFtbH:n(1072),ysjfZ:"FCgdc",eyukM:n(456),aqKMh:n(1723),AueIT:n(924)+n(1584)+n(1023),EGajr:function(i,t,r,a){return i(t,r,a)},SOKji:n(580)+n(421),nMhYP:n(1654),tLVdu:n(421),Hhijw:n(1397),zXDRW:function(i,t){return i(t)},XdkTs:function(i,t){return i(t)},IFQhQ:n(1399)+n(1263),PsOQP:"Module",ZqYVL:function(i,t){return i<t},wDdsh:function(i,t){return i===t},NRAaf:n(1115),dkjGW:function(i,t){return i+t},JWHlp:function(i,t,r){return i(t,r)},sXvFF:n(1444)+"rValues",YPFTc:n(1192),MwDLO:function(i,t,r,a){return i(t,r,a)},YTzgV:n(1638),vUIsH:function(i){return i()},emVQj:n(1315),HenPK:n(1788),XcAEI:function(i,t){return i(t)},RsKtG:function(i,t,r,a){return i(t,r,a)},XLrad:function(i,t){return i+t},jwKJF:"CfXnv",YlDGY:n(1770),TBuLL:n(1067),sqpTP:function(i,t,r,a){return i(t,r,a)},dmuPZ:n(1496),uzxfC:function(i,t,r,a){return i(t,r,a)},qxfjb:"x_fronti"+n(1259),LxENq:n(1214)+n(1038),FuMDS:function(i,t,r,a){return i(t,r,a)},SJfQw:function(i,t,r){return i(t,r)},NgyrA:"x-msg-cu"+n(841)+"e",EUqHw:"x-msg-cursor_value",jwkzD:function(i,t){return i>t},VXFeP:"uBJRP",NCWLg:n(628),fDLnA:function(i,t){return i+t},BhevP:function(i){return i()},lIczG:function(i){return i()},wqZDS:function(i){return i()},vvzey:function(i){return i()},WWWDi:function(i){return i()},bNqcn:function(i,t,r){return i(t,r)},jPsvy:function(i,t){return i!==t},oxbAZ:function(i,t){return i===t},NFXmV:function(i,t){return i===t},bCCKG:n(1181),UXgvZ:function(i){return i()},RndPh:function(i){return i()},aoims:function(i,t){return i===t},UuKWW:n(1827),TESrA:function(i,t){return i===t},mpKQY:n(741),jGEzb:"ping_onc"+n(1682)+"s",RNoUf:n(543),EZjdV:function(i,t,r,a){return i(t,r,a)},Pmsmx:function(i,t,r){return i(t,r)},pGDbi:function(i,t,r,a){return i(t,r,a)},dxVsc:function(i,t){return i!==t},DZWUB:function(i,t){return i!==t},lnUcg:n(1410),aGvoH:n(790),herng:function(i,t){return i==t},lnMWh:n(492)+n(1846)+n(1e3),iQQTc:function(i,t,r){return i(t,r)},RUQdm:n(644)+"ediately"+n(744)+"ct",Ltjli:n(1174),JTVir:n(1045),ODAli:n(1291),vSXYv:n(1460),DpUPy:function(i,t,r){return i(t,r)},XKJCf:"iUkcQ",oPiYp:function(i,t){return i!==t},rRumt:function(i,t){return i!==t},FCIgn:function(i,t){return i==t},oeyZh:n(726),OiSgE:"wss://",hCsLK:"ws://",YyAEC:n(894),olHrx:"device_id",OFVEM:function(i,t){return i||t},qOOMQ:n(492)+n(633)+n(1232)+n(1507)+n(461),fFzYJ:"function",xkHqd:function(i,t,r){return i(t,r)},AXuab:"web",ithyJ:function(i,t,r){return i(t,r)},vUDkl:"start",gBaSm:function(i,t){return i>t},egLFg:function(i,t){return i-t},uFfdM:function(i,t){return i(t)},btBYs:n(1117),AAXnX:function(i,t){return i|t},JqEwU:function(i,t,r){return i(t,r)},MfNfs:n(1356),qpowH:"going aw"+n(1467)+n(1109)+n(1458)+"ver",TEkkC:function(i,t){return i>t},aSUqa:function(i,t){return i+t},ZpNkm:n(1308),BvVHG:function(i,t,r){return i(t,r)},BAppe:n(1535)+n(1534)+n(1665)+"g",SLolY:function(i,t){return i(t)},pOlmQ:function(i,t){return i===t},gUnGi:"3|4|2|1|0",tmhol:"open",fdYmb:n(1359),IyyyT:n(1230),hWqny:function(i,t,r){return i(t,r)},owKlI:n(1532),vnXJk:function(i,t,r){return i(t,r)},aQBPo:n(921)+n(1851)+n(977)+n(561),ZcYLI:function(i,t){return i===t},GLtJo:n(1328),UGlTN:function(i,t){return i instanceof t},jisza:function(i,t){return i(t)},yBPSC:n(1256),hGtQH:function(i,t){return i+t},egcPF:n(1475),xWviR:n(1716),BwFJM:n(1292)+"s instan"+n(1645)+n(843)+"ed",PokAI:function(i,t){return i===t},uwjvj:n(1292)+n(1150)+n(832),GuDRl:n(492)+n(1346)+n(585)+n(1033)+n(607)+"e a stri"+n(1211)+" arraybu"+n(756),KJRjc:n(1288),Stgyr:function(i,t){return i!=t},jWFKn:function(i,t){return i instanceof t},jQftp:function(i,t){return i instanceof t},IYYlI:function(i,t){return i(t)},dtiqX:n(492)+"rovide a"+n(1843)+n(1210),ZpYQJ:function(i,t){return i===t},SxaXq:n(863),Sewio:n(722),GcWhh:"DHIIc",oXasS:function(i,t){return i!==t},OImzt:n(1037),pafOg:n(1525),iEqBB:function(i,t){return i||t},nAwZV:function(i,t){return i==t},XeaVV:n(663)+n(1636)+n(1046),yAAJS:n(1623)+"0",SBRhm:function(i,t){return i===t},tiqIP:n(560),dEHAs:n(1147),SofhY:function(i,t){return i===t},pgDoO:n(1097),nPGKX:n(855),sIKJZ:function(i,t,r){return i(t,r)},vmxVU:n(1392),MPzVA:function(i,t){return i!=t},uOFyk:function(i,t){return i!=t},yXXZp:function(i,t){return i===t},yJTeA:n(1686),RxNzj:function(i,t){return i===t},yohtP:n(413)+n(390)+n(708)+"pe",mhsSe:function(i,t){return i==t},vSnbA:function(i,t){return i===t},UMPSR:n(1607)+n(911)+"alScope",ApNIK:n(1065)+n(1676)+"balScope",dIogc:function(i,t){return i!=t},oIhhl:function(i,t){return i!=t},DIOPr:n(961)+n(898)};Ne.r($),Ne.d($,{FWS:()=>Yc,CustomErrorEvent:()=>Oi,createCloseEvent:()=>Ee,ReconnectEvent:()=>Li,createErrorEvent:()=>_e,decodedFrame:()=>Se,createOpenEvent:()=>qi,CustomCloseEvent:()=>Bi,createReconnectEvent:()=>mr,FrontierMessageEvent:()=>zi,encodeFrame:()=>pr,createMessageEvent:()=>Ui,OpenEvent:()=>Fi,ErrorCode:()=>Ve,Event:()=>ft,MessageEvent:()=>Mi});let s="";function o(i=""){let t=n,r={FFZjX:function(a,x,u){return e[I(625)](a,x,u)},edcPy:function(a,x){return e[I(914)](a,x)},mNHCO:function(a,x){return e[I(1813)](a,x)}};if(e[t(1059)]!==t(1857)){let x=""+Date[t(600)](),u=s||(s=e[t(1080)](m,i)),h=Math[t(808)]()[t(1604)](16)[t(986)](-6);return e[t(1036)](e[t(812)](e[t(1280)]("02",x),u),h)}else{let a=0,x=_0x306c64,u=_0x543b58+4;for(;x<u;){let{value:h,offset:p}=r[t(810)](_0x579c0c,_0x2c0586,x);x=p,a=r.edcPy(r[t(866)](a,8),0),a+=h}return{value:a,offset:u}}}function c(){let i=n;return e[i(1035)](e.EafrD(1e4,Date.now()),Math[i(1364)](e.bLVKf(1e4,Math[i(808)]())))}function d(i){let t=n;return e.lZxZm===e[t(676)]?this._ws?this._ws[t(1350)]:this[t(1336)]:e.QAGys(Array(8)[t(943)]("0"),e[t(1680)](parseInt,i,10).toString(2))[t(986)](-8)}function f(i){let t=n;return e.MMspS(e[t(1080)](Array,4)[t(943)]("0"),e[t(1680)](parseInt,i,2).toString(16)).slice(-4)}function l(i){let t=n,r=i[t(582)](/\./)[t(588)](u=>d(u)),a=[];return a[0]=f(e.AxtlS(r[0],r[1])),a[1]=e.XxKzw(f,e[t(1035)](r[2],r[3])),[e[t(1615)],e[t(1615)],t(617),"0000",e[t(1615)],e[t(1625)],a[0],a[1]][t(943)]("")}function m(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(1266)](i);return r?e[t(1360)](l,i):a?e[t(1521)](w,i):t(1519)+t(1519)+t(1519)+t(1519)}function w(i){let t=n,r="",a=[],x=0,u=0,h=!0,p=e.kMHPy;if(e[t(698)](i[t(760)]("::"),-1)){let g=i[t(582)]("::");for(let b=0;e[t(1740)](b,g[t(453)]);b++){let C=g[b];if(e.yLfzV(C[t(760)](":"),0)){let N=C.split(":");h&&(x=N[t(453)]),u+=N.length;for(let O=0;O<N[t(453)];O++)if(N[O][t(453)]!==4){let ee=p[t(1541)+"g"](0,e[t(1518)](4,N[O][t(453)])),ce=ee[t(973)](N[O]);a[t(884)](ce)}else a[t(884)](N[O]);h=!1}else{if(e[t(1124)](4,C[t(453)])){let N=p[t(1541)+"g"](0,e[t(645)](4,C.length)),O=N[t(973)](C);a[t(884)](O)}else a[t(884)](C);h&&(x+=1),u+=1,h=!1}}let y="";for(let b=0;e[t(1234)](b,e.VBVes(8,u));b++)y=y[t(973)](p);for(let b=0;e.TdcCb(b,a[t(453)]);b++)e.gXxjj(b,x)&&(r=r[t(973)](y)),r=r[t(973)](a[b]);return r}{let g=i[t(582)](":");for(let y=0;e[t(946)](y,g[t(453)]);y++){let b=g[y];if(g[y][t(453)]!==4){let C=p[t(1541)+"g"](0,e[t(1335)](4,g[y][t(453)])),N=C[t(973)](b);r=r[t(973)](N)}else r=r[t(973)](b)}return r}}function v(i,t){let r=n,a=i[r(1182)];e[r(446)](void 0,a)&&(e[r(625)](Y,t,10),e[r(625)](ge,t,a));let x=i[r(821)];x!==void 0&&(e[r(1283)](e[r(1833)],e[r(1426)])?(e[r(873)](Y,t,18),e[r(625)](ge,t,x)):!this[r(797)+r(1327)]&&(this._endpointManager?.["resetEnd"+r(688)+r(1207)](),this[r(1685)+r(542)]?.[r(994)+"nter"](),this[r(1820)+r(757)]=!1,this[r(888)]=!0,this[r(797)]()))}function _(i){let t=n,r={yeeIG:function(a,x){return e[I(1602)](a,x)},yKPHN:e.eWzIg,UzTLf:"ping_once_success",gdzse:function(a,x){return e[I(386)](a,x)},rndeO:t(1117),wkPQK:e.xTsso};if(e[t(1790)]===e.AGebz){this[t(933)+"ngTimer"](),this["_pingPon"+t(1658)+"Id"]=e[t(625)](_0xdb511,this[t(1657)][t(1165)](this),this[t(1111)][t(989)+t(748)]);let a=()=>{let u=t;r[u(586)](_0x571fea,r[u(964)]),this[u(1578)](r[u(1644)],a),this[u(1578)](u(1235)+u(908)+"t",x)},x=()=>{let u=t;r.gdzse(_0x792be6,r.rndeO),this[u(1578)](u(1235)+u(1682)+"s",a),this[u(1578)](r.wkPQK,x)};this.on(t(1235)+"e_success",a),this.on(e[t(648)],x),this._ping()}else{let a={};e:for(;!e[t(931)](B,i);){let x=e.rssLg(G,i);switch(e.JkNFQ(x,3)){case 0:break e;case 1:a[t(1182)]=e[t(1680)](ue,i,e[t(1521)](G,i));break;case 2:a[t(821)]=ue(i,e[t(538)](G,i));break;default:e[t(625)](ne,i,e[t(1672)](7,x))}}if(e[t(1538)](void 0,a[t(1182)]))throw new Error(e[t(1732)]);if(e[t(472)](void 0,a[t(821)]))throw new Error("Missing "+t(1835)+t(1206)+t(821));return a}}function E(i){let t=n,r={ycwog:function(a,x,u,h){return e[I(960)](a,x,u,h)},EGoIx:function(a,x,u){return e[I(1483)](a,x,u)}};if(e[t(446)](e[t(1710)],e[t(895)])){let a=e.yMBGP(Z);return e[t(1278)](T,i,a),e[t(393)](k,a)}else try{r.ycwog(_0x3502e5,this,_0x5bf4f7,[_0x4468e4,_0x43f43b,_0x1a1295])}catch(a){let x=r[t(1673)](_0x4caf29,t(1154),{message:a[t(1357)],code:_0x67c7eb[t(1093)+"OR"],error:a});this["_dispatchErrorEv"+t(811)](x)}}function T(i,t){let r=n,a=i.SeqID;e[r(384)](void 0,a)&&(e[r(873)](Y,t,8),e[r(1270)](Me,t,a));let x=i.LogID;if(e[r(446)](void 0,x))if(e[r(1353)](e[r(959)],e[r(464)]))e.QZwYI(Y,t,16),e[r(1157)](Me,t,x);else{if(_0x43fa8d<1||e[r(698)](_0x6ddecb,_0x80b238))return e[r(1489)](_0x597051,_0x33d2b0);e[r(698)](_0x354100+_0x2ce551,_0x218ae6)&&(_0x33051e=_0x30387a(_0x562bd2),_0x131c8=0);let ce=_0x1822e2[r(1297)](_0x2b22c4,_0x8fb549,_0x1de78f+=_0x4c3dde);return e.WEttl(7,_0x2b096b)&&(_0x548e9d=(7|_0x3a0c7a)+1),ce}let u=i[r(1355)];e[r(1326)](void 0,u)&&(Y(t,24),e.mBNxZ(Me,t,e[r(1602)](j,u)));let h=i[r(839)];e.TANBn(void 0,h)&&(e[r(552)](Y,t,32),e[r(873)](Me,t,e[r(1031)](j,h)));let p=i[r(1566)];if(e.kjUBw(void 0,p))for(let ce of p){e[r(1157)](Y,t,42);let ye=e[r(1164)](Z);e[r(662)](v,ce,ye),e.cgLVZ(Y,t,ye[r(1416)]),e[r(1319)](nt,t,ye),e[r(1443)](se,ye)}let g=i[r(1391)+r(428)];e[r(524)](void 0,g)&&(e.QeExa(Y,t,50),e[r(1442)](ge,t,g));let y=i[r(703)+r(684)];y!==void 0&&(e[r(1569)](Y,t,58),ge(t,y));let b=i.payload;e.HkCZm(void 0,b)&&(e[r(1517)](Y,t,66),e.bbXnD(Y,t,b[r(453)]),Be(t,b));let C=i[r(1826)];C!==void 0&&(e[r(662)](Y,t,74),e[r(1442)](ge,t,C));let N=i[r(1393)+"ming"];N!==void 0&&(e[r(1157)](Y,t,82),e[r(1157)](ge,t,N));let O=i[r(711)];e[r(803)](void 0,O)&&(e[r(1744)](Y,t,90),e.NVZIB(ge,t,O));let ee=i.frameType;ee!==void 0&&(e[r(558)](Y,t,96),Me(t,j(ee)))}function P(i){return e[n(1031)](R,oe(i))}function R(i){let t=n;if(e[t(1283)]("KGPYX",t(1430))){let r={};e:for(;!e.xMBWe(B,i);){let a=e[t(1540)](G,i);switch(a>>>3){case 0:break e;case 1:r.SeqID=ae(i,!0);break;case 2:r[t(1423)]=e[t(1278)](ae,i,!0);break;case 3:r[t(1355)]=G(i);break;case 4:r[t(839)]=e[t(761)](G,i);break;case 5:{let x=e[t(1853)](z,i);(r.headers||(r.headers=[]))[t(884)](_(i)),i[t(1416)]=x;break}case 6:r[t(1391)+"ncoding"]=ue(i,e[t(1299)](G,i));break;case 7:r[t(703)+"ype"]=ue(i,e.xMBWe(G,i));break;case 8:r[t(1441)]=e.UsciG(Ie,i,e.pNSfa(G,i));break;case 9:r[t(1826)]=e[t(1157)](ue,i,G(i));break;case 10:r[t(1393)+t(652)]=ue(i,e.xMBWe(G,i));break;case 11:r[t(711)]=e[t(1040)](ue,i,G(i));break;case 12:r[t(736)+"e"]=e.xIpjT(G,i);break;default:ne(i,7&a)}}if(r[t(852)]===void 0)throw new Error(e[t(455)]);if(e[t(786)](void 0,r.LogID))throw new Error(e.NAKkE);if(e[t(1773)](void 0,r[t(1355)]))throw new Error(t(902)+t(1835)+t(1206)+t(1355));if(e[t(1538)](void 0,r[t(839)]))throw new Error(e.MCFdZ);return r}else this[t(1485)](e[t(1729)],_0x8263bd(e[t(1729)],{message:this[t(1369)+t(1822)+t(1731)](_0x250293)}))}function z(i){let t=n,r=e[t(1299)](G,i),a=i[t(1416)];return i.limit=e.AxtlS(i.offset,r),a}function ne(i,t){let r=n;switch(t){case 0:for(;128&e[r(1113)](Q,i););break;case 2:e[r(1224)](L,i,G(i));break;case 5:e[r(1527)](L,i,4);break;case 1:e[r(1176)](L,i,8);break;default:throw new Error(e[r(440)](r(1374)+r(627)+r(551),t))}}function j(i){let t=n,r={RIcaO:e[t(1621)]};if(e[t(1809)](e[t(1792)],e[t(1354)])){let a=/(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(_0x36de94),x=/(([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(1266)](_0xe5920d);return a?_0x2faddd(_0x36f6c0):x?_0x286da3(_0xd26b4a):oJSXLC[t(685)]}else return i|=0,{low:i,high:e[t(1063)](i,31),unsigned:e.YVfMy(i,0)}}let me=[];function Z(){let i=n,t=me[i(546)]();return t?(t[i(927)]=t.limit=0,t):{bytes:new Uint8Array(64),offset:0,limit:0}}function se(i){me[n(884)](i)}function oe(i){return{bytes:i,offset:0,limit:i[n(453)]}}function k(i){let t=n,r=i.bytes,a=i[t(1416)];return e[t(1412)](r[t(453)],a)?r:r.subarray(0,a)}function L(i,t){let r=n,a={QsPEU:function(x,u){return e[I(1035)](x,u)},krKME:function(x,u){return e[I(1780)](x,u)},UBlYJ:function(x,u){return e[I(1125)](x,u)},aewXE:function(x,u){return e[I(1577)](x,u)}};if(e[r(499)](e[r(836)],e[r(836)])){let x=_0x50446.bytes,u=_0x547d58[r(927)],h=_0x3b402c[r(1416)],p=a[r(854)](u,_0x384279);if(a[r(891)](p,x[r(453)])){let g=new _0x51add8(a.UBlYJ(2,p));g[r(936)](x),_0x1b56fa[r(818)]=g}return _0x30ad48.offset=p,a.aewXE(p,h)&&(_0x4e9718[r(1416)]=p),u}else{if(e[r(1156)](e[r(440)](i[r(927)],t),i.limit))throw new Error(e.NInuu);i[r(927)]+=t}}function B(i){let t=n;return e.PxzpR(i[t(927)],i[t(1416)])}function J(i,t){let r=n,a=i.bytes,x=i[r(927)],u=i.limit,h=e[r(812)](x,t);if(e[r(1108)](h,a.length)){let p=new Uint8Array(e[r(1003)](2,h));p[r(936)](a),i[r(818)]=p}return i.offset=h,h>u&&(i.limit=h),x}function we(i,t){let r=n,a=i[r(927)];if(e[r(918)](a,t)>i[r(1416)])throw new Error(e[r(1318)]);return i.offset+=t,a}function Ie(i,t){let r=n;if(e[r(567)]===e[r(389)])return _0x3f80ca+=_0x3a1f8a&&_0x3bc372[r(1737)+"th"]||0,_0xfcd3a5;{let a=e.HUINs(we,i,t);return i[r(818)][r(474)](a,e.OHaTF(a,t))}}function Be(i,t){let r=n,a=J(i,t.length);i[r(818)][r(936)](t,a)}function ue(i,t){let r=n,a=e[r(1040)](we,i,t),x=String["fromChar"+r(604)],u=i[r(818)],h="\uFFFD",p="";for(let g=0;e[r(1740)](g,t);g++){let y=u[e[r(1036)](g,a)],b,C,N,O;e[r(1809)](e[r(794)](128,y),0)?p+=e[r(553)](x,y):e.jUZQE(e[r(1597)](224,y),192)?e[r(759)](g+1,t)?p+=h:(b=u[e.PGoRd(g,a)+1],e[r(1124)](e.BMFPd(192,b),128)?p+=h:e[r(1208)]==="pgtVX"?(e[r(614)](_0x19896b,_0x37b7f0,90),e.losHe(_0x195c07,_0x947388,_0x28f9ef)):(O=e[r(695)](e[r(1561)](e[r(424)](31,y),6),63&b),O<128?p+=h:(p+=e[r(761)](x,O),g++))):e[r(1279)](e[r(376)](240,y),224)?e.dfDRM(e[r(651)](g,2),t)?p+=h:(b=u[e[r(440)](e[r(1249)](g,a),1)],C=u[e[r(440)](e[r(1865)](g,a),2)],e[r(1124)](e[r(1739)](e[r(695)](b,e[r(1807)](C,8)),49344),32896)?p+=h:(O=e[r(1244)](e.nyNLI(e[r(1741)](15&y,12),e.wRHPl(e.AaHji(63,b),6)),e.AaHji(63,C)),O<2048||e.AWmsd(O,55296)&&e.uwCEt(O,57343)?p+=h:(p+=x(O),g+=2))):e.cBoHA(e[r(858)](248,y),240)?e[r(1466)](e.udykD(g,3),t)?p+=h:(b=u[e[r(440)](e[r(1035)](g,a),1)],C=u[e[r(996)](e[r(918)](g,a),2)],N=u[g+a+3],e[r(1836)](e[r(1597)](e.CJLrE(b,e.lvlSe(C,8))|N<<16,12632256),8421504)?p+=h:(O=e.nyNLI(e.CJLrE(e[r(1856)](7&y,18),e[r(1631)](63&b,12))|e[r(1498)](63&C,6),e.CWvwA(63,N)),O<65536||e.tbcAr(O,1114111)?p+=h:(O-=65536,p+=e.zrfiD(x,e.pPHlV(O>>10,55296),e.zkpSD(e.WEttl(1023,O),56320)),g+=3))):p+=h}return p}function ge(i,t){let r=n,a=t[r(453)],x=0;for(let p=0;e[r(577)](p,a);p++){if(e[r(1120)](e[r(1696)],e[r(1696)]))return this[r(1233)].readyState;{let g=t[r(1172)+"At"](p);e[r(1808)](g,55296)&&e[r(992)](g,56319)&&e[r(577)](e[r(996)](p,1),a)&&(g=e[r(1249)](e[r(1715)](g,10),t[r(1172)+"At"](++p))-56613888),x+=e.pYwRm(g,128)?1:e.pYwRm(g,2048)?2:e[r(624)](g,65536)?3:4}}e[r(1517)](Y,i,x);let u=e.TThRT(J,i,x),h=i.bytes;for(let p=0;e[r(577)](p,a);p++){let g=t[r(1172)+"At"](p);e[r(1748)](g,55296)&&e.ywOJd(g,56319)&&e.fKhkn(e[r(1036)](p,1),a)&&(g=e[r(1722)](e[r(1482)](e[r(1498)](g,10),t[r(1172)+"At"](++p)),56613888)),e[r(1261)](g,128)?h[u++]=g:(e[r(1345)](g,2048)?h[u++]=e.SFccm(e[r(1739)](e[r(1095)](g,6),31),192):(e[r(624)](g,65536)?h[u++]=e[r(1739)](e[r(1095)](g,12),15)|224:(h[u++]=e[r(1229)](e.QmLTf(e[r(1063)](g,18),7),240),h[u++]=e.iaezv(g>>12&63,128)),h[u++]=e[r(1229)](e.RraWj(e[r(1183)](g,6),63),128)),h[u++]=e[r(661)](63,g)|128)}}function nt(i,t){let r=n,a=e[r(1040)](J,i,t[r(1416)]),x=i[r(818)],u=t[r(818)];for(let h=0,p=t[r(1416)];e[r(1740)](h,p);h++)x[e[r(812)](h,a)]=u[h]}function Q(i){let t=n;return i[t(818)][e[t(886)](we,i,1)]}function rt(i,t){let r=n,a=e[r(625)](J,i,1);i[r(818)][a]=t}function G(i){let t=n;if(e[t(1008)](e[t(1047)],e[t(1601)]))return this[t(593)]?e[t(1249)](e.KfIpJ(e[t(1090)](this[t(1321)],0),_0x3be151),this[t(1026)]>>>0):e[t(952)](e[t(1151)](this.high,_0x2fbcb2),e[t(500)](this[t(1026)],0));{let r=0,a=0,x;do x=e.xIpjT(Q,i),e[t(824)](r,32)&&(a|=e[t(424)](127,x)<<r),r+=7;while(e[t(1672)](128,x));return a}}function Y(i,t){let r=n;for(t>>>=0;e[r(1480)](t,128);)e.Aotcl(rt,i,e[r(595)](e.RraWj(127,t),128)),t>>>=7;e[r(886)](rt,i,t)}function ae(i,t){let r=n,a=0,x=0,u=0,h;return h=Q(i),a=e[r(858)](127,h),e[r(376)](128,h)&&(h=Q(i),a|=e[r(1807)](e[r(1622)](127,h),7),e.MOMXA(128,h)&&(h=e[r(1002)](Q,i),a|=e[r(753)](e[r(1688)](127,h),14),e.oYJrw(128,h)&&(h=e[r(1668)](Q,i),a|=e[r(1856)](e[r(424)](127,h),21),e[r(1484)](128,h)&&(h=e[r(1002)](Q,i),x=e[r(1201)](127,h),e[r(465)](128,h)&&(h=e.vxSJI(Q,i),x|=e[r(1715)](e[r(465)](127,h),7),128&h&&(h=e[r(777)](Q,i),x|=e.aOTqT(e.LsyrI(127,h),14),e[r(1726)](128,h)&&(h=e.rssLg(Q,i),x|=e.kYIyR(e[r(424)](127,h),21),e[r(1484)](128,h)&&(h=Q(i),u=e.oGLpW(127,h),e[r(1295)](128,h)&&(h=e[r(1019)](Q,i),u|=e.ARzHS(127,h)<<7))))))))),{low:e[r(695)](a,e[r(1715)](x,28)),high:e[r(1187)](x>>>4,e.JgtYF(u,24)),unsigned:t}}function Me(i,t){let r=n,a=t[r(1026)]>>>0,x=(e.jRsyg(t.low,28)|e[r(1741)](t.high,4))>>>0,u=e.jRsyg(t.high,24),h=e[r(1809)](0,u)?e[r(556)](0,x)?e.TKBtJ(a,16384)?a<128?1:2:e.caxwW(a,2097152)?3:4:e.pYwRm(x,16384)?e[r(1261)](x,128)?5:6:e[r(1261)](x,2097152)?7:8:e[r(636)](u,128)?9:10,p=e[r(1040)](J,i,h),g=i.bytes;switch(h){case 10:g[e[r(918)](p,9)]=e[r(1622)](e.GzaRf(u,7),1);case 9:g[e.AezkC(p,8)]=h!==9?e.wyBCn(128,u):127&u;case 8:g[e.GiBDy(p,7)]=e[r(1120)](8,h)?e[r(422)](e[r(1850)](x,21),128):e.sPtAt(e[r(914)](x,21),127);case 7:g[p+6]=e[r(532)](7,h)?e[r(1322)](x>>>14,128):e[r(1201)](e[r(1709)](x,14),127);case 6:g[p+5]=e.BnLlE(6,h)?e[r(835)](e[r(515)](x,7),128):e.flZfX(e.JkNFQ(x,7),127);case 5:g[p+4]=e[r(590)](5,h)?128|x:127&x;case 4:g[e[r(1646)](p,3)]=e.EPbPi(4,h)?e[r(1709)](a,21)|128:e.GLfTx(e[r(1850)](a,21),127);case 3:g[e[r(1194)](p,2)]=e[r(937)](3,h)?e[r(1244)](e[r(1709)](a,14),128):e[r(914)](a,14)&127;case 2:g[p+1]=h!==2?e.GzaRf(a,7)|128:e.icLqK(a>>>7,127);case 1:g[p]=e.gcUuS(1,h)?128|a:127&a}}function Se(i){return e.dnkCF(P,i)}function pr(i){return e[n(1113)](E,i)}let Ti=65536,ac=n(479),ut=e[n(1582)](Ti,Ti),Di=e.ETZEA(ut,ut),Ri=e[n(1341)](Di,2),Je=String[n(417)+"e"][n(1172)+"At"];class H{constructor(t,r,a){let x=n;this[x(1237)]=!0,this[x(1026)]=0|t,this[x(1321)]=e[x(695)](0,r),this.unsigned=!!a}static[n(1237)](t){let r=n;return t&&e[r(1592)](!0,t[r(1237)])}static[n(1609)](t,r,a){let x=n;return e[x(556)](e[x(1700)],x(1718))?_0x26bcd6||(_0x66f5d6=[_0x3a3c9b,_0x11cb08,_0x18b705,_0x5ce26f,_0x2aff58]):new H(t,r,a)}static fromBytes(t,r,a){let x=n;return a?H["fromByte"+x(480)](t,r):H[x(1598)+"sBE"](t,r)}static[n(1598)+n(480)](t,r){let a=n;return e[a(556)](e[a(905)],e[a(418)])?this[a(665)+a(749)+a(817)+"t"]:new H(e.mUWlV(e[a(1229)](e.XllAX(t[0],t[1]<<8),t[2]<<16),e[a(1498)](t[3],24)),e[a(787)](e.YbUXP(e[a(1078)](t[4],e[a(1498)](t[5],8)),t[6]<<16),t[7]<<24),r)}static[n(1598)+"sBE"](t,r){let a=n;return new H(e.rThJY(e[a(820)](t[4],24)|t[5]<<16,t[6]<<8)|t[7],e[a(1340)](e[a(679)](e[a(1856)](t[0],24)|e[a(1758)](t[1],16),t[2]<<8),t[3]),r)}static fromHash(t){let r=n;return e.BnLlE("JnRFL",e.lkScX)?null:e[r(782)](t,ac)?Ni:new H(e[r(500)](e[r(1229)](e[r(1512)](e[r(1187)](Je[r(1297)](t,0),Je[r(1297)](t,1)<<8),e[r(385)](Je.call(t,2),16)),e[r(1498)](Je.call(t,3),24)),0),e.FPoUB(e[r(1203)](e[r(545)](Je.call(t,4),e[r(753)](Je[r(1297)](t,5),8)),e[r(779)](Je.call(t,6),16)),Je[r(1297)](t,7)<<24)>>>0,!0)}[n(1186)](){let t=n;return String[t(1379)+t(604)](e[t(1487)](255,this[t(1026)]),e[t(1252)](e[t(1325)](this[t(1026)],8),255),e[t(661)](this[t(1026)]>>>16,255),e.bwiAG(this[t(1026)],24),e[t(1342)](255,this[t(1321)]),e[t(1757)](e[t(954)](this[t(1321)],8),255),e[t(376)](e[t(1119)](this[t(1321)],16),255),e[t(1119)](this[t(1321)],24))}static fromNumber(t,r=!0){let a=n,x={nAkAH:function(u,h){return e[I(1261)](u,h)},rXHcN:function(u,h){return e[I(1751)](u,h)},PgoGi:function(u,h){return e[I(1408)](u,h)},UrIYI:function(u,h){return e[I(859)](u,h)},lECMr:function(u,h){return u&h},fyKmo:function(u,h){return e[I(1006)](u,h)},xUdJr:function(u,h){return e[I(500)](u,h)}};if(e[a(782)](e[a(896)],a(758))){let u=this[a(1568)]["getStora"+a(980)+"nc"](this[a(622)]),h=_0xab6901[a(1554)](e.XOfAv(u,"{}"));return _0x141ee7[a(565)](h)}else{if(e[a(553)](isNaN,t))return r?cc:Ni;if(r){if(e.qKVxG(e[a(889)],e[a(889)])){let u={rzDYq:function(b,C){return x.nAkAH(b,C)},REcsp:function(b,C){return x.rXHcN(b,C)},Jcdoc:function(b,C){return x.PgoGi(b,C)},dvkEl:function(b,C){return x[a(1520)](b,C)},dRMEn:function(b,C){return x[a(906)](b,C)},sHefD:function(b,C){return x[a(540)](b,C)}},h=_0x15e9e1||8192,p=x[a(1387)](h,1),g=null,y=h;return function(b){let C=a;if(u[C(1481)](b,1)||b>p)return u[C(1691)](_0x571979,b);u[C(1698)](u.dvkEl(y,b),h)&&(g=u[C(1691)](_0x5ca0a4,h),y=0);let N=_0x2b274b[C(1297)](g,y,y+=b);return u[C(720)](7,y)&&(y=u[C(377)](u.sHefD(7,y),1)),N}}else if(e.AWmsd(t,Di))return dc}else{if(t<=-Ri)return uc;if(e.PHxVw(t,1)>=Ri)return xc}return H[a(1609)](e[a(533)](t,ut)|0,e.dCbdV(e[a(1341)](t,ut),0),r)}}toNumber(){let t=n;return this[t(593)]?e[t(826)](e[t(1246)](e.Dlzoy(this[t(1321)],0),ut),e.ZJXlN(this[t(1026)],0)):e.bLVKf(this[t(1321)],ut)+e[t(1325)](this[t(1026)],0)}[n(1777)](){let t=n;return e[t(919)](0,this.high)&&this[t(1026)]===0}[n(1273)](t){let r=n;H[r(1237)](t)||(t=H[r(1785)+"er"](t));let a=e[r(1180)](this[r(1321)],16),x=e[r(1711)](65535,this[r(1321)]),u=e[r(1312)](this[r(1026)],16),h=65535&this.low,p=t[r(1321)]>>>16,g=e[r(858)](65535,t[r(1321)]),y=e[r(395)](t[r(1026)],16),b=e.ARzHS(65535,t[r(1026)]),C=0,N=0,O=0,ee=0;return ee+=e.IgKBa(h,b),O+=e[r(1664)](ee,16),ee&=65535,O+=e[r(1462)](u,y),N+=e[r(1664)](O,16),O&=65535,N+=e[r(1199)](x,g),C+=e[r(1088)](N,16),N&=65535,C+=e[r(834)](a,p),C&=65535,H[r(1609)](e[r(1229)](e[r(1596)](O,16),ee),e[r(1338)](e.UddHj(C,16),N),this[r(593)])}[n(1599)](t){let r=n;return H[r(1237)](t)||(t=H[r(1785)+"er"](t)),this.unsigned!==t[r(593)]&&e[r(1773)](e[r(500)](this[r(1321)],31),1)&&e.IvjPL(e.EbKcL(t[r(1321)],31),1)?!1:e[r(1649)](this.high,t.high)&&e.qnYSS(this[r(1026)],t[r(1026)])}addOne(){let t=n;return e[t(1412)](-1,this[t(1026)])&&e[t(1538)](-1,this[t(1321)])?H.fromBits(0,0,this[t(593)]):e[t(1754)](-1,this.low)?H[t(1609)](0,e.mJOhv(this[t(1321)],1),this.unsigned):H[t(1609)](this[t(1026)]+1,this[t(1321)],this.unsigned)}[n(851)](t){return t?this[n(639)+"E"]():this.toBytesBE()}toBytesLE(){let t=n,r=this[t(1321)],a=this[t(1026)];return[255&a,e[t(376)](e.Dlzoy(a,8),255),a>>>16&255,e[t(928)](a,24),255&r,e.BMFPd(e.nGJeA(r,8),255),e.GLfTx(e[t(1862)](r,16),255),e[t(791)](r,24)]}[n(1344)+"E"](){let t=n;if(e[t(1326)](e[t(1158)],e[t(862)])){let r=this[t(1321)],a=this[t(1026)];return[e[t(1236)](r,24),e[t(1096)](e[t(1706)](r,16),255),e[t(1757)](e.lRiJq(r,8),255),e[t(1597)](255,r),e[t(1271)](a,24),e[t(1484)](e[t(395)](a,16),255),e[t(1201)](e.iSQFA(a,8),255),e[t(1622)](255,a)]}else return _0x277d73&&_0x202486[t(1237)]===!0}}let Ni=new H(0,0,!1),cc=new H(0,0,!0),xc=H[n(1609)](-1,2147483647,!1),dc=H[n(1609)](-1,-1,!0),uc=H[n(1609)](0,-2147483648,!1);var Ve=(function(i){let t=n;if(e.mWqVH(e[t(641)],e[t(641)]))e[t(1751)](_0x4c76b5,this[t(797)+"ionTimeoutId"]),this[t(797)+t(1274)+t(1384)]=null;else{let r=e[t(1170)].split("|"),a=0;for(;;){switch(r[a++]){case"0":i[i[e[t(1371)]]=5005]=t(1093)+"OR";continue;case"1":i[i[e[t(755)]]=5004]="MESSAGE_"+t(1029);continue;case"2":i[i[e[t(1551)]]=5001]=e[t(1551)];continue;case"3":i[i[t(1559)+t(412)+"R"]=5003]=e[t(374)];continue;case"4":return i;case"5":i[i[e.yWhJg]=5002]=e[t(1495)];continue}break}}})({});class ft{constructor(t){let r=n;this.type=t,this[r(1542)]=null}}class Li extends ft{constructor(t,r){let a=n;super(t),this[a(1357)]=r&&r[a(1357)]||null}}class Oi extends ft{constructor(t,r){let a=n,x=e[a(476)][a(582)]("|"),u=0;for(;;){switch(x[u++]){case"0":this[a(1496)]=r&&r[a(1496)]||5001;continue;case"1":this.colno=r&&r[a(1733)]||0;continue;case"2":this[a(746)]=r&&r[a(746)]||"";continue;case"3":this[a(1154)]=r&&r[a(1154)]||null;continue;case"4":this[a(1357)]=r&&r[a(1357)]||"";continue;case"5":this[a(1553)]=r&&r[a(1553)]||0;continue;case"6":super(t);continue}break}}}class Bi extends ft{constructor(t,r){let a=n,x=e[a(1153)][a(582)]("|"),u=0;for(;;){switch(x[u++]){case"0":super(t);continue;case"1":this["willReco"+a(1304)]=r&&r.willReconnect||!1;continue;case"2":this.reason=r&&r.reason||"";continue;case"3":this.code=r&&r[a(1496)]||0;continue;case"4":this[a(608)]=r&&r.wasClean||!1;continue}break}}}class Mi extends ft{constructor(t,r){super(t),this.data=r&&r.data||null}}class zi extends Mi{constructor(t,r){let a=n;if(e[a(1289)](e.PXRfu,e[a(975)]))super(t),this[a(378)]=r&&r.data||null,this[a(1357)]=r&&r[a(1357)]||null;else{let x=this._qosDB[a(1015)+a(602)](this[a(622)]);return _0x34d02c[a(1554)](e.XOfAv(x,"{}"))[_0x3bb212]}}}class Fi extends ft{constructor(t,r){super(t),this.data=r&&r.data||null}}function _e(i,{message:t,code:r,error:a}){return new Oi(i,{message:t,code:r,error:a})}function Ee(i,{code:t,reason:r,wasClean:a,willReconnect:x}){return new Bi(i,{code:t,reason:r,wasClean:a,willReconnect:x})}function Ui(i,{data:t,message:r}){return new zi(i,{data:t,message:r})}function qi(i,{data:t}){return new Fi(i,{data:t})}function mr(i,{message:t}){return new Li(i,{message:t})}class Hi{constructor(t,r){let a=n;this[a(913)+"s"]=t,this[a(681)+"es"]=r,this[a(1593)+"ndex"]=0,this[a(665)+a(749)+a(817)+"t"]=0}[n(1178)+n(688)+n(1207)](){let t=n;this[t(1593)+t(1586)]=0,this[t(665)+t(749)+t(817)+"t"]=0}[n(1767)+"es"](){let t=n;this[t(665)+t(749)+"riesCount"]=0}[n(1724)+n(591)+"nt"](){let t=n;return this[t(913)+"s"][this[t(1593)+t(1586)]]}["getCurre"+n(591)+"ntTriesC"+n(1841)](){let t=n;return this[t(665)+t(749)+t(817)+"t"]}[n(1450)+n(463)+"es"](){let t=n;return!!(e.rkXsu(this[t(1593)+t(1586)],this[t(913)+"s"][t(453)])||e[t(1809)](this[t(1593)+t(1586)],e[t(1722)](this[t(913)+"s"][t(453)],1))&&e[t(1008)](this[t(665)+"ndpointTriesCount"],this[t(681)+"es"]))}["checkCur"+n(1478)+n(868)+n(584)+n(1403)](){let t=n;return e[t(1279)](this["currentI"+t(1586)],this[t(913)+"s"].length)?!0:e[t(1156)](this[t(665)+t(749)+"riesCount"],this[t(681)+"es"])}["replaceBackupEnd"+n(1753)+n(1213)+n(620)](){let t=n;return this[t(665)+"ndpointT"+t(817)+"t"]=1,this[t(1593)+"ndex"]++,this[t(913)+"s"][this["currentI"+t(1586)]]}[n(1724)+n(591)+n(1382)+n(1652)](){let t=n;if(e.JODQF(t(983),e[t(1606)])){let r={UOIyl:e[t(454)],LkrIo:function(x,u){return e[t(1143)](x,u)},TRIka:function(x,u){return e[t(1244)](x,u)},hqkFd:function(x,u){return e[t(946)](x,u)},QYYqL:function(x,u){return e.nGJeA(x,u)},gpMsc:function(x,u){return x<<u},jxgAT:function(x,u){return e[t(1424)](x,u)},mjiuT:function(x,u){return e.VWCYg(x,u)},ddhJA:function(x,u){return e[t(698)](x,u)},wDYFP:function(x,u,h,p){return e[t(508)](x,u,h,p)},NrlpQ:function(x,u){return e[t(835)](x,u)},MvMBz:function(x,u){return e[t(1014)](x,u)},IWVgr:function(x,u){return e[t(727)](x,u)},hcmZi:function(x,u){return e[t(791)](x,u)},QUkCq:function(x,u){return e.fKhkn(x,u)}},a=4294967295;return function(x,u,h=!0){let p=t,g=r[p(1828)][p(582)]("|"),y=0;for(;;){switch(g[y++]){case"0":a=r[p(613)](127&x[u],0);continue;case"1":if(x[u++]<128)return{value:h?a:r[p(1139)](0,a),offset:u};continue;case"2":if(r.hqkFd(x[u++],128))return{value:h?a:0|a,offset:u};continue;case"3":a=r.QYYqL(r[p(1139)](a,r.gpMsc(r[p(942)](127,x[u]),7)),0);continue;case"4":a=(a|r[p(785)](r[p(942)](127,x[u]),14))>>>0;continue;case"5":if(r[p(1810)](u+=5,x[p(453)]))throw u=x[p(453)],r[p(1461)](_0x153fc3,u,10,x[p(453)]);continue;case"6":if(x[u++]<128)return{value:h?a:r[p(559)](0,a),offset:u};continue;case"7":a=r[p(498)](r[p(1139)](a,r.jxgAT(127,x[u])<<21),0);continue;case"8":return{value:h?a:0|a,offset:u};case"9":if(r[p(470)](x[u++],128))return{value:h?a:r[p(990)](0,a),offset:u};continue;case"10":a=r[p(382)](a|r[p(942)](15,x[u])<<28,0);continue;case"11":if(r[p(398)](x[u++],128))return{value:h?a:r[p(1139)](0,a),offset:u};continue}break}}}else return this[t(665)+t(749)+t(817)+"t"]++,this[t(1724)+t(591)+"nt"]()}}let lt=(e[n(1161)](e.dsgIP,typeof globalThis)&&e[n(782)](e.vmxVU,globalThis[n(1011)+n(1858)][n(421)])||n(1398)+"d"!=typeof window&&e.vmxVU===window[n(1011)+n(1858)][n(421)])&&e.MPzVA("undefined",typeof document),it=e[n(1281)](n(1398)+"d",typeof globalThis)&&(e[n(557)](e.yJTeA,globalThis.constructor[n(421)])||e.RxNzj(e[n(657)],globalThis["construc"+n(1858)][n(421)]))&&e[n(1486)]!=typeof tt,Ot=(e[n(881)](e[n(1486)],typeof globalThis)&&e[n(1754)](e[n(718)],globalThis["construc"+n(1858)][n(421)])||e[n(1087)](e[n(1486)],typeof globalThis)||e[n(881)](e[n(1486)],typeof globalThis)&&!!globalThis[n(955)+n(1445)])&&e[n(1486)]!=typeof wx,Bt=e[n(1281)](e[n(1486)],typeof globalThis)&&(e[n(1579)](e[n(657)],globalThis["construc"+n(1858)][n(421)])||e[n(529)](e[n(1557)],globalThis[n(1011)+n(1858)].name)||e[n(1565)](e.ApNIK,globalThis[n(1011)+n(1858)][n(421)]))&&e[n(1849)](n(1398)+"d",typeof self),fc=e[n(1161)](e.dsgIP,typeof globalThis)&&e[n(1289)](e.yJTeA,globalThis[n(1011)+"tor"][n(421)])&&e[n(1486)]!=typeof global&&e[n(782)](e[n(718)],global[n(1011)+n(1858)][n(421)])&&e[n(489)](e.dsgIP,typeof process)&&!!process.version;class wr{constructor(){this._listeners={}}[n(1485)](t,...r){let a=n,x=this[a(747)+"rs"][t];if(x)x[a(986)]()[a(819)](u=>u.fn.apply(u.ctx,r));else if(e[a(1729)]===t&&!this[a(1832)]){let u=r[a(453)]&&r[0];if(u instanceof Error)throw u;let h=new Error(e[a(918)]("Unhandle"+a(1050),u?e[a(1249)](e[a(1249)](" (",u.message),")"):""));throw h[a(534)]=u,u}return this}[n(1578)](t,r){let a=n;if(e[a(786)](void 0,t))this[a(747)+"rs"]={};else if(e.rCNUI(void 0,r))this[a(747)+"rs"][t]=null;else if(e[a(499)](a(1783),e[a(1135)])){let x=this[a(747)+"rs"][t];if(x)for(let u=0;e.qBZWx(u,x[a(453)]);)e.jGJYJ(x[u].fn,r)?x[a(1202)](u,1):++u}else return this[a(665)+a(749)+a(817)+"t"]++,this["getCurre"+a(591)+"nt"]();return this}on(t,r,a){let x=n;return(this[x(747)+"rs"][t]||(this[x(747)+"rs"][t]=[]))[x(884)]({fn:r,ctx:a||this}),this}}class lc extends wr{[n(1369)+n(1822)+n(1731)](t){let r=n;return t.errMsg||t[r(1452)]?(r(1689)+" "+(t[r(704)]||"")+" code: "+(t.errNo||""))[r(1414)]():JSON[r(1440)+"y"](t)}constructor(t,r,a){let x=n;super(),this[x(1233)]=null,Ot&&wx[x(1361)+"ocket"]&&(this[x(1233)]=wx["connectS"+x(1464)]({url:t,protocols:r,header:a,fail:this[x(957)+"ocketFai"+x(1437)][x(1165)](this),success:this[x(957)+"ocketSuc"+x(1811)+"ler"][x(1165)](this)})),it&&tt[x(1361)+x(1464)]&&(this[x(1233)]=tt["connectS"+x(1464)]({url:t,protocols:r,header:a,fail:this["_createS"+x(1854)+x(1437)][x(1165)](this),success:this[x(957)+x(1679)+x(1811)+"ler"][x(1165)](this)}))}[n(957)+"ocketSuccessHand"+n(1842)](){let t=n;e[t(532)](e[t(951)],e[t(951)])?(this.emit(e[t(1253)],_0x4e835c),this[t(1333)]&&this.onclose(_0x3c8583)):Promise[t(705)]()[t(949)](()=>{let r=t;this[r(629)+r(527)]()})}_createSocketFailHandler(t){Promise.resolve().then(()=>{let r=I,a=e.NVZIB(_e,"error",{message:this[r(1369)+r(1822)+"age"](t)});this[r(1485)](e[r(1729)],a);let x=e.WgLEm(Ee,e[r(1253)],{reason:this[r(1369)+r(1822)+r(1731)](t)});this[r(1485)](e[r(1253)],x)})}[n(629)+n(527)](){let t=n,r={HPooM:t(879),lwmoe:e[t(1632)]};t(441)!==e.UUMjE?(this[t(1233)][t(1413)](a=>{let x=t;this.emit(r[x(1522)],qi(r.HPooM,{...a,data:a[x(704)]||""}))}),this[t(1233)][t(1269)](a=>{let x=t;this[x(1485)](e[x(1253)],Ee(e[x(1253)],{...a}))}),this._socket[t(471)+"e"](a=>{this.emit(r.lwmoe,Ui(r.lwmoe,{...a}))}),this[t(1233)][t(444)](a=>{this[t(1485)](e.Fjytr,e.gquhe(_e,"error",{...a,message:a.errMsg||""}))})):(_0x3fa4e5+=_0x505722(_0x17467f),_0x3a3cc4+=2)}[n(805)](t){let r=n,a={gndiu:function(x,u){return e[I(693)](x,u)},hxtkP:function(x,u){return x<u},HGJLZ:function(x,u){return e.qcDNv(x,u)},OFxlv:function(x,u){return e[I(1228)](x,u)},HnwLu:function(x,u){return e[I(1447)](x,u)},SSwkb:function(x,u){return e[I(1798)](x,u)},inYoR:function(x,u){return e[I(440)](x,u)},AyTEs:e.qmgNG,JjzUc:function(x,u){return e[I(1063)](x,u)},porVu:function(x,u){return e[I(409)](x,u)},tXKZh:function(x,u){return e[I(1295)](x,u)},kFHZP:function(x,u){return e[I(1830)](x,u)},JTQcZ:function(x,u){return e.ngGNp(x,u)},fOOdq:function(x,u){return x|u},LvMNh:function(x,u){return e[I(1322)](x,u)},Ypfwt:function(x,u){return e[I(1565)](x,u)},sQxcf:e[r(408)],PzBqP:e[r(1729)]};if(e.sTowI(t,Uint8Array)){let x=t[r(1861)][r(986)](t[r(1372)+"et"],e[r(513)](t[r(1737)+"th"],t[r(1372)+"et"]));this._socket&&this[r(1233)][r(805)]({data:x,fail:u=>{let h=r;this[h(1485)](h(1154),e.DaTul(_e,"error",{message:this[h(1369)+"rrorMess"+h(1731)](u)}))}})}else this[r(1233)]&&this[r(1233)].send({data:t,fail:x=>{let u=r;if(a[u(893)](u(1220),a[u(525)]))if(_0x225da3=_0x4a18db[u(1172)+"At"](_0x1d7ea2),a[u(1429)](_0x23e41e,128))_0x12d791[_0x38974a++]=_0x4f7347;else if(a[u(1395)](_0x5522b1,2048))_0x169147[_0x2e69e0++]=a[u(1155)](_0x5245ee>>6,192),_0x2ea9e7[_0x2c4779++]=a[u(1155)](63&_0x4f51cf,128);else if(a[u(574)](64512,_0x12a812)===55296&&a[u(1241)](a[u(1558)](64512,_0x3fa2ae=_0x5d2bcf[u(1172)+"At"](a.inYoR(_0x4d9028,1))),56320)){let h=a.AyTEs.split("|"),p=0;for(;;){switch(h[p++]){case"0":_0x693314[_0x5b852e++]=a[u(1681)](_0x354c45,18)|240;continue;case"1":_0x2e466a[_0x52b011++]=a.HGJLZ(63&_0x403744,128);continue;case"2":_0x53bad5=a[u(1421)](a.inYoR(65536,a[u(574)](1023,_0x5ce695)<<10),a[u(564)](1023,_0x2ebc6c));continue;case"3":_0x2a1ed8[_0x25ac87++]=a[u(1155)](a.tXKZh(_0x214153>>6,63),128);continue;case"4":++_0xd0642a;continue;case"5":_0x23f075[_0x404b4b++]=a[u(1155)](a[u(564)](a[u(1195)](_0x32efd6,12),63),128);continue}break}}else _0xbfa10a[_0xd6a18d++]=a[u(491)](a[u(1681)](_0x4d2947,12),224),_0x2f3239[_0x42f3ec++]=a[u(721)](a.tXKZh(a[u(1681)](_0x3df615,6),63),128),_0xe72ed7[_0x5ba2ac++]=a[u(956)](63&_0x20705f,128);else this[u(1485)](a.PzBqP,_e(a[u(1043)],{message:this[u(1369)+u(1822)+"age"](x)}))}})}[n(1348)](t,r){let a=n;this[a(1233)]&&this[a(1233)][a(1348)]({code:t,reason:r})}[n(1016)+n(880)](t,r){this.on(t,r)}[n(1626)+n(603)+n(1242)](t,r){this[n(1578)](t,r)}get[n(1831)+"te"](){let t=n;return this._socket[t(1831)+"te"]}get[n(1409)+"pe"](){let t=n;return this[t(1233)][t(1409)+"pe"]}set[n(1409)+"pe"](t){}get[n(1350)](){return this[n(1233)].url}get[n(969)](){return this[n(1233)].protocol}get extensions(){let t=n;return this._socket[t(1545)+"ns"]}get["buffered"+n(640)](){return 0}}function gc(i,t){let r=n;if(t)return new t(i[r(1350)],i[r(969)]);if(e[r(1351)](Ot,it))return new lc(i[r(1350)],i[r(969)],i[r(1566)]);if(e[r(802)](lt,Bt)&&e.dsgIP!=typeof WebSocket&&WebSocket)return new WebSocket(i[r(1350)],i.protocols)}function hc(i){let t=n;if(e[t(1463)]("lLkva",e.CZHKf)){let a=""+_0x2b7c9e[t(600)](),x=_0x2aea2c||(_0x1de110=e.uKnqC(_0x40891b,_0x4e454b)),u=_0x1bed7d[t(808)]().toString(16)[t(986)](-6);return"02"+a+x+u}else{let r=e[t(1061)].split("|"),a=0;for(;;){switch(r[a++]){case"0":if(i)return!0;continue;case"1":if(Ot&&wx[t(1361)+t(1464)])return!0;continue;case"2":return!1;case"3":if(it&&tt[t(1361)+t(1464)])return!0;continue;case"4":if((lt||Bt)&&e[t(881)]("undefined",typeof WebSocket)&&WebSocket)return!0;continue}break}}}function Ki(i,t,r){let a=n,x={yNWgH:function(u,h){return e.kWmsS(u,h)}};if(e[a(1795)]!==e[a(635)]){let u=-1;async function h(p){let g=a;return p<=u?Promise[g(1573)](new Error("next() called mu"+g(427)+g(1845)+"process")):(u=p,x.yNWgH(p,r[g(453)])?Promise.resolve():r[p][g(1165)](i)(t,h.bind(null,p+1)))}e[a(1113)](h,0)}else this[a(1530)+"mise"]=null}function Gi(i){let t=n,r=0,a=0;for(let x=0;e[t(1345)](x,i[t(453)]);++x)a=i[t(1172)+"At"](x),e.xeulk(a,128)?r+=1:e[t(504)](a,2048)?r+=2:e[t(1250)](64512&a,55296)&&e[t(472)](e[t(941)](64512,i[t(1172)+"At"](e[t(1264)](x,1))),56320)?(++x,r+=4):r+=3;return r}function Wi(i,t,r){let a=n;if(e[a(1518)](r,t)<1)return"";let x="";for(let u=t;e.fKhkn(u,r);){let h=i[u++];if(e[a(462)](h,127))x+=String[a(1379)+a(604)](h);else if(e[a(517)](h,192)&&h<224)x+=String[a(1379)+a(604)](e[a(716)](e[a(1498)](e[a(793)](31,h),6),e[a(1370)](63,i[u++])));else if(e[a(732)](h,224)&&e[a(1053)](h,240))x+=String["fromChar"+a(604)](e.Vvgzu(e.VZKki(e.XFaQn(e[a(1806)](15,h),12),e.lXMDg(63&i[u++],6)),e.flZfX(63,i[u++])));else if(e[a(732)](h,240)){let p=(e.Zzwsr(e.JMgCu(e[a(1596)](e[a(1728)](7,h),18),e[a(1420)](e.oGLpW(63,i[u++]),12)),e[a(1276)](63&i[u++],6))|e[a(1531)](63,i[u++]))-65536;x+=String[a(1379)+a(604)](e.ghgyv(55296,e[a(1095)](p,10))),x+=String[a(1379)+a(604)](e[a(1249)](56320,e[a(451)](1023,p)))}}return x}function _r(i,t,r){let a=n,x={DiROe:e[a(1253)]},u=r,h,p;for(let g=0;e[a(490)](g,i[a(453)]);++g)h=i[a(1172)+"At"](g),e.rjVHm(h,128)?t[r++]=h:e[a(1234)](h,2048)?(t[r++]=e.Aiedt(h>>6,192),t[r++]=e[a(1512)](e[a(794)](63,h),128)):(64512&h)===55296&&e.NLyNp(e[a(1449)](64512,p=i[a(1172)+"At"](e[a(513)](g,1))),56320)?(h=e.ghgyv(e[a(1035)](65536,(1023&h)<<10),1023&p),++g,t[r++]=e.HNeqI(h>>18,240),t[r++]=e[a(419)](e[a(511)](h,12),63)|128,t[r++]=e.NLqgo(e.hNaVP(h>>6,63),128),t[r++]=63&h|128):e[a(1225)](e[a(660)],e.JbvII)?this[a(1485)](hGmTMY[a(514)],_0x31d422(hGmTMY[a(514)],{..._0x2b1f66})):(t[r++]=e[a(1338)](e[a(702)](h,12),224),t[r++]=e[a(780)](e[a(929)](h>>6,63),128),t[r++]=e.CyiJh(63,h)|128);return e.hiahO(r,u)}async function ji(i){let t=n;if(e[t(399)](e.gyJDh,typeof i)){let r=new Uint8Array(e[t(966)](Gi,i));return e[t(1316)](_r,i,r,0),r}return e[t(1684)](i,ArrayBuffer)?new Uint8Array(i):new Uint8Array(i[t(1861)],i[t(1372)+"et"],i[t(1737)+"th"])}function pc(i){let t=n;try{return e[t(1510)]!=typeof i&&(i instanceof ArrayBuffer||i[t(1861)]&&i.buffer instanceof ArrayBuffer)||e.ERoJV(e[t(1510)],typeof i)?"":(JSON[t(1554)](i),e[t(1543)])}catch{return e[t(1510)]==typeof i?"text/pla"+t(1290)+t(537):""}}let mc=(i,t)=>{let r=n;switch(i){case e[r(1840)]:case e[r(1422)]:return{["x-use-"+i]:1,"x-tt-env":t};default:return{}}};class wc{constructor(t){let r=n;this[r(1506)+r(1841)]=t,this[r(947)]=0}[n(1052)](){let t=n;e[t(630)]===e.JeRQg?this[t(947)]++:(this[t(1782)+t(976)]?.["resetEndpointCon"+t(1207)](),this["_pingLos"+t(542)]?.[t(994)+t(566)](),this[t(1820)+t(757)]=!1,this._isInit=!0,this._connect())}[n(1450)+n(962)+"nt"](){let t=n,r={mjGuv:function(a,x){return a(x)}};return e[t(883)]("vCTBW",e[t(1550)])?this.count>=this["maxLossC"+t(1841)]:wEOBPI[t(1126)](_0x178026,_0x3d8016)}[n(994)+"nter"](t=0){let r=n;this[r(1506)+r(1841)]=t,this[r(947)]=0}}async function _c(i){let t={GZvYN:function(r,a){return e[I(931)](r,a)}};return new Promise(r=>{let a=I,x={GmAyC:function(u,h){return e.CsKZg(u,h)},FEFMG:function(u,h){return e.UMSWD(u,h)},tzbKq:function(u,h){return u<<h},iAizG:function(u,h){return e[I(1022)](u,h)},IrAvs:function(u,h){return e[I(530)](u,h)},iiqoI:function(u,h){return u<<h},eVhVj:function(u,h){return e[I(1504)](u,h)},bsfVj:function(u,h){return u>>h},BdbWA:function(u,h){return e.lrGLj(u,h)},OuNug:e.Fobky,VUFRT:function(u,h){return u(h)},wxYVF:e[a(789)]};if(!lt)return r("unknown "+a(611));try{let u=document["createEl"+a(1548)](e[a(783)]);window[a(431)+a(1655)]=h=>{let p=a,g={xIGJx:function(y,b){return x[I(1743)](y,b)},cihxA:function(y,b){return x[I(1663)](y,b)},UbXxZ:function(y,b){return x[I(1388)](y,b)},AZEWU:function(y,b){return x.iAizG(y,b)},VjceR:function(y,b){return y>=b},HqHjK:function(y,b){return y|b},JHaRz:function(y,b){return y<<b},WZmYZ:function(y,b){return y-b},QtokW:function(y,b){return x.IrAvs(y,b)},eSSwQ:function(y,b){return x[I(1388)](y,b)},XYBWq:function(y,b){return x.iiqoI(y,b)},tRPdB:function(y,b){return x[I(1769)](y,b)},mkfzD:function(y,b){return x.eVhVj(y,b)},mklff:function(y,b){return x[I(979)](y,b)},frmkU:function(y,b){return y+b},kxaPl:function(y,b){return y&b}};if(x[p(776)](x[p(876)],p(1605))){let y=_0x1935f9[_0x9d79c++];if(y<=127)_0x5e4d2f+=_0x14daa7[p(1379)+p(604)](y);else if(y>=192&&gLWmBa[p(619)](y,224))_0x10992a+=_0x336641[p(1379)+p(604)](gLWmBa[p(988)](gLWmBa.UbXxZ(gLWmBa.AZEWU(31,y),6),63&_0x217159[_0x378622++]));else if(gLWmBa[p(865)](y,224)&&gLWmBa[p(619)](y,240))_0x429a35+=_0x177f12[p(1379)+"Code"](gLWmBa[p(988)](gLWmBa[p(1513)](gLWmBa[p(1768)](gLWmBa[p(1044)](15,y),12),gLWmBa[p(1768)](63&_0x12fb83[_0x588c7c++],6)),63&_0x2ce48a[_0x492cc0++]));else if(gLWmBa.VjceR(y,240)){let b=gLWmBa[p(849)](gLWmBa.cihxA(gLWmBa[p(988)](gLWmBa[p(953)](gLWmBa[p(458)](gLWmBa[p(1044)](7,y),18),gLWmBa[p(1044)](63,_0xec08e4[_0x1ef919++])<<12),gLWmBa[p(1243)](gLWmBa[p(1427)](63,_0x3cfb42[_0x29c694++]),6)),gLWmBa.mkfzD(63,_0x2971e5[_0x4d7df0++])),65536);_0x3e92e7+=_0x3f8489[p(1379)+p(604)](55296+gLWmBa.mklff(b,10)),_0x62d7c+=_0x3bdbfa[p(1379)+p(604)](gLWmBa[p(626)](56320,gLWmBa[p(404)](1023,b)))}}else document[p(548)][p(1759)+p(1738)](u),window[p(431)+"JSONP"]=void 0,x.VUFRT(r,h&&h[p(481)]||x.wxYVF)},u[a(433)]=e.uWjzT,u[a(1456)]=e[a(1614)](i[a(1533)](/^ws/,e.YTaVJ),e[a(1311)]);try{document[a(548)][a(840)+a(1738)](u)}catch{e[a(1240)](e.mRfOy,e[a(1071)])?(_0x5cfe4d+=uaoGOC[a(522)](_0x5841b8,_0x4f5511),_0x26be2b++):document[a(548)][a(1759)+a(1738)](u)}}catch{window.frontierJSONP=void 0,e[a(501)](r,e[a(789)])}})}function $e(i,t,r){let a=n;return!!i?.find(x=>x.key===t&&x[a(821)]===r)}function gt(i,t){let r=n,a={azpOE:function(x,u){return e[I(513)](x,u)},rnLIg:function(x,u){return e[I(1755)](x,u)},WYHkQ:function(x,u){return e.nGJeA(x,u)},cZzoA:function(x,u){return e[I(1865)](x,u)},PZJTJ:function(x,u){return e.ghgyv(x,u)},eNaen:function(x,u){return x&u},qwwLf:function(x,u){return e.bvODO(x,u)},NtIAL:function(x,u){return e[I(1092)](x,u)},KqKBc:function(x,u){return x&u}};if(e.mEsoq(e.KbccM,e[r(1396)]))return i?.[r(1702)](x=>x[r(1182)]===t)?.value;{let x=_0x326f36[r(1026)],u=_0x4f0e79[r(1321)];return _0x4475cb[_0x11ff9c]=u>>>24,_0x4b58d9[a.azpOE(_0x3ca33d,1)]=a[r(714)](u,16)&255,_0xf4ee93[a[r(1730)](_0x4be07c,2)]=a[r(381)](u,8)&255,_0x33a9d1[a.cZzoA(_0x3703ad,3)]=255&u,_0x22039e[a[r(1730)](_0x3b2e35,4)]=a[r(714)](x,24),_0x36bc24[a[r(1212)](_0x3a3a41,5)]=a[r(1824)](a.rnLIg(x,16),255),_0x1f97df[a[r(892)](_0x10c4d6,6)]=a.eNaen(a.NtIAL(x,8),255),_0x1f6cc7[a[r(397)](_0xa35483,7)]=a[r(1747)](255,x),_0xd95820+=8,_0x105a25}}let yr=null;async function yc(){let i=n;return yr||(yr=Promise[i(705)]()[i(949)](Ne[i(1165)](Ne,e.wuPXi))),yr}class vc extends wr{constructor(t,r){let a=n;super(),this[a(882)]=t,this[a(1343)]=r,this._qosDB=void 0,this["_initPro"+a(1471)]=null}async[n(1852)](){await this[n(1122)]()}async[n(1122)](){let t=n,r={kudzp:function(a){return e.JyEvk(a)},fhCKq:function(a,x){return a(x)},kDbau:function(a,x){return a<<x},OEcVP:function(a,x){return e[I(1378)](a,x)}};if(!this[t(1568)]){if(this[t(1530)+t(1471)])return this[t(1530)+t(1471)];try{if(e[t(524)](e[t(1677)],e[t(587)])){let a=this[t(882)],x=this[t(1343)];this["_initPro"+t(1471)]=(async()=>{let u=t,{openDB:h}=await r[u(1708)](yc);this[u(1568)]=await h(u(431)+"_"+a,1,{upgrade(p){p[u(452)+"jectStore"](a,{keyPath:x})}})})(),await this[t(1530)+t(1471)]}else _0xd2a1a1=CvcLGo[t(935)](_0x57ac27,_0x50be7f),_0x5cbb60|=CvcLGo[t(801)](CvcLGo.OEcVP(127,_0x4d7c08),7)}catch(a){console[t(1556)](a)}finally{this[t(1530)+t(1471)]=null}}}async get(t){let r=n;try{if(e[r(556)](e[r(674)],e.vlXcB))return await this[r(1122)](),this[r(1568)]?.get(this[r(882)],t);e[r(1040)](_0x2dec2f,_0x35a5e1,58),e[r(725)](_0x1e1655,_0x48faa2,_0x5875e4)}catch(a){console[r(1556)](a)}}async[n(936)](t,r){let a=n;return await this._init(),this._qosDB?.[a(752)](this[a(882)],t)}async[n(1742)](t){let r=n;try{return await this._init(),this[r(1568)]?.delete(this[r(882)],t)}catch(a){if(e[r(784)]!==r(1152)){let x=this[r(1568)].getItem(this[r(622)]),u=_0x242346[r(1554)](e.PXjcG(x,"{}"));return u[_0x4e034f||_0xd142e1[this[r(1834)]]]=_0x259fb5,this._qosDB.setItem(this[r(622)],_0x319d3f[r(1440)+"y"](u)),_0x1e9930||_0x49dd2d[this._pathKey]}else console[r(1556)](a)}}async[n(473)](){let t=n,r={nKUnB:function(a,x){return a==x},UecTV:e[t(1510)],ViLgr:function(a,x){return e.NeIRd(a,x)}};try{return await this[t(1122)](),this[t(1568)]?.clear(this._dbName)}catch(a){if(e[t(445)](e.CAwwL,e[t(668)])){let{url:x}=_0x3ce4f6||{},u=_0x349c5b.isArray(x)?x:r[t(1805)](r[t(1012)],typeof x)?[x]:[];_0x20d4a1&&_0x2faf66[t(875)](this[t(1111)],_0x57039b),u&&u[t(453)]?this[t(1782)+t(976)]=new _0x5a6ba6(u,this[t(1111)][t(681)+"es"]):this[t(1782)+"tManager"]?.["resetEnd"+t(688)+t(1207)](),this["_pingLos"+t(542)]?.[t(994)+t(566)](this[t(1111)]["pingLoss"+t(1017)]),this[t(1820)+t(757)]=!1,this[t(423)]&&r.ViLgr(this._ws.readyState,this[t(402)])?this[t(1329)+t(388)](1e3,t(663)+t(1636)+"ing",!0):(this[t(888)]=!0,this._connect())}else console[t(1556)](a)}}async[n(1717)](){let t=n;if(e[t(680)](e.weJpK,t(1300))){let r=_0x2e08ea[t(453)]&&_0x2ee862[0];if(e[t(1684)](r,_0x3ea605))throw r;let a=new _0xae2c71(e[t(513)](e[t(531)],r?e[t(826)](e[t(1194)](" (",r[t(1357)]),")"):""));throw a.context=r,r}else return await this._init(),this[t(1568)]?.getAllKeys(this._dbName)}async[n(706)](){let t=n;return await this._init(),this[t(1568)]?.[t(706)](this[t(882)])}async closeDB(){let t=n;if(e.rAWWh(t(1013),e[t(939)]))this[t(1485)](e[t(1529)],_0x5badf3),this[t(1074)+t(682)]&&this[t(1074)+"eAck"](_0x2a2c76);else try{this._qosDB?.[t(1348)](),this[t(1568)]=void 0}catch(r){if(e[t(1240)](e[t(890)],t(1817)))return _0x248b9e||(_0xe0d823=[_0x401e75[t(417)+"e"][t(650)],_0x3cedcd[t(417)+"e"][t(1145)],_0x5bfee3[t(417)+"e"]["continue"+t(1390)+"ey"]]);console[t(1556)](r)}}get[n(1619)](){let t=n;try{return!!this[t(1568)]}catch(r){return console[t(1556)](r),!1}}}class bc{constructor(t,r){let a=n;this[a(1112)]=t,this[a(1834)]=r,this._qosDB=localStorage}async[n(1852)](){}get _prefix(){return n(431)+"_"+this._DBName}async[n(1330)](t){let r=n,a=this[r(1568)][r(426)](this._prefix);return JSON[r(1554)](e[r(1752)](a,"{}"))[t]}async set(t,r){let a=n,x=this[a(1568)][a(426)](this[a(622)]),u=JSON[a(1554)](e[a(822)](x,"{}"));return u[r||t[this._pathKey]]=t,this[a(1568)][a(1425)](this._prefix,JSON.stringify(u)),r||t[this[a(1834)]]}async[n(1742)](t){let r=n,a=this[r(1568)][r(426)](this[r(622)]),x=JSON[r(1554)](e[r(1667)](a,"{}"));return x[t]=void 0,this._qosDB[r(1425)](this[r(622)],JSON[r(1440)+"y"](x))}async[n(473)](){let t=n;return this[t(1568)][t(473)]()}async keys(){let t=n,r=this[t(1568)][t(426)](this[t(622)]),a=JSON[t(1554)](e[t(1351)](r,"{}"));return Object[t(1717)](a)}async getAll(){let t=n,r=this._qosDB[t(426)](this[t(622)]),a=JSON[t(1554)](r||"{}");return Object[t(565)](a)}[n(488)](){return Promise[n(705)]()}get[n(1619)](){return!!this[n(1568)]}}class Sc{constructor(t,r){let a=n;this[a(1112)]=t,this[a(1834)]=r,this[a(1568)]=it?tt:Ot?wx:null}async[n(1852)](){}get[n(622)](){return n(431)+"_"+this._DBName}async get(t){let r=n,a=this[r(1568)][r(1015)+"geSync"](this[r(622)]);return JSON[r(1554)](a||"{}")[t]}async[n(936)](t,r){let a=n,x=this._qosDB[a(1015)+a(602)](this._prefix),u=JSON[a(1554)](e[a(435)](x,"{}"));return u[r||t[this[a(1834)]]]=t,this[a(1568)][a(1762)+a(602)](this._prefix,JSON.stringify(u)),r||t[this._pathKey]}async[n(1742)](t){let r=n,a=this[r(1568)][r(1015)+r(602)](this[r(622)]),x=JSON[r(1554)](e[r(396)](a,"{}"));return x[t]=void 0,this._qosDB[r(1762)+"geSync"](this[r(622)],JSON[r(1440)+"y"](x))}async[n(473)](){let t=n;return this._qosDB["clearSto"+t(967)]()}async keys(){let t=n,r=this[t(1568)][t(1015)+t(980)+"nc"](this[t(622)]),a=JSON[t(1554)](e[t(1667)](r,"{}"));return Object[t(1717)](a)}async[n(706)](){let t=n;if(e[t(1671)]!=="sPhfV"){let r=this[t(1568)]["getStora"+t(980)+"nc"](this[t(622)]),a=JSON[t(1554)](e.cKnDl(r,"{}"));return Object[t(565)](a)}else return _0x1df285[t(1237)](_0x2855a6)||(_0x442a2c=_0x1dcfe4[t(1785)+"er"](_0x1d4699)),this[t(593)]!==_0x41cd78[t(593)]&&this.high>>>31===1&&e[t(1863)](e[t(1706)](_0x59d810[t(1321)],31),1)?!1:e[t(1592)](this[t(1321)],_0x1fc947[t(1321)])&&e[t(1649)](this[t(1026)],_0x4f2d14[t(1026)])}[n(488)](){return Promise[n(705)]()}get[n(1619)](){let t=n;if(e[t(1412)](t(867),e[t(1373)]))this[t(1593)+t(1586)]=0,this[t(665)+"ndpointT"+t(817)+"t"]=0;else return!!this[t(1568)]}}function Ji(i,t){let r=n;if(it||it)return new Sc(i,t);if(e[r(1351)](lt,Bt)&&e[r(881)](e.dsgIP,typeof indexedDB))return new vc(i,t);if(e[r(1175)](lt,Bt)&&e[r(881)](e[r(1486)],typeof localStorage))return new bc(i,t);throw new Error(e.NMWcZ)}class Ec{constructor(){let t=n;this[t(570)+"lTimeoutId"]=null,this[t(570)+"l"]=36e5,this[t(1568)]=e[t(625)](Ji,e[t(860)],t(411)+"id")}async[n(570)+n(410)](){let t=n;e.tPmYp(clearInterval,this[t(570)+"lTimeoutId"]),this[t(570)+"lTimeoutId"]=e[t(1527)](setInterval,()=>{let r=t;this[r(1640)+r(400)]()},this[t(570)+"l"])}async openDB(){let t=n,r={xPezw:t(1248),Rlojp:e[t(848)],lFYCf:function(a,x){return e[t(742)](a,x)},kQpBh:e[t(972)]};if(e.gXxjj(e[t(772)],"CpjVC"))await this._qosDB.openDB()[t(949)](()=>{let a=t;this[a(570)+a(410)]()});else{let{SeqID:a,LogID:x,service:u,LogIDNew:h,method:p}=_0x4669f7[t(1357)];this[t(1076)]({SeqID:a,LogID:x,LogIDNew:h,service:u,method:p,headers:[{key:r[t(656)],value:"1"},{key:r[t(1612)],value:r.lFYCf(h,"")},{key:r.kQpBh,value:"0"}]})}}async flushExpired(){let t=n,r={yUvAS:function(u,h){return e[I(1175)](u,h)},iybKy:function(u,h){return e.ERoJV(u,h)},gaTrv:e[t(1486)],bDJyp:function(u,h){return u||h},psHFU:function(u,h){return u!=h}};(await this[t(1568)]?.[t(706)]()||[])[t(1313)](({timestamp:u})=>u<Date.now())[t(819)](u=>{let h=t;if(e[h(472)](e[h(1647)],e[h(1509)])){if(iEKOcO.yUvAS(_0x569cd0,_0x1b39f5))return new _0x1cecdf(_0x4f23ec,_0x3dffcb);if(iEKOcO[h(1285)](_0xd0bb15,_0x43caa6)&&iEKOcO.iybKy(iEKOcO[h(1528)],typeof _0x130536))return new _0x309287(_0x10c7fc,_0x3199af);if(iEKOcO[h(554)](_0x2c0394,_0x1ad9d3)&&iEKOcO.psHFU(h(1398)+"d",typeof _0x57d3af))return new _0x1926bd(_0x15eae9,_0x2b9304);throw new _0x1a1811(h(477)+h(1349)+"d")}else this[h(1568)]?.[h(1742)](u.message_id)})}async[n(1742)](t){let r=n;return this[r(1568)]?.[r(1742)](t)}async[n(936)](t,r){let a=n;return this[a(1568)]?.[a(936)]({message_id:t,timestamp:r})}async[n(1330)](t){let r=n;return this._qosDB?.[r(1330)](t)}async[n(488)](){let t=n;if(e[t(1368)]!==e[t(1476)])e.iqAkg(clearInterval,this["_interva"+t(1459)+"Id"]),await this[t(1568)]?.[t(488)]();else return _0x443a23[_0x171b21]=_0x1fb674,!0}get[n(1619)](){let t=n;return this[t(1568)]?.[t(1619)]}}function vr(i){let t=n,r=!!this._options[t(1162)+"S"];if(!r)return{enabled:r,isQoSMessage:!1,isQoSAck:!1,isAckCleanupMessage:!1,ackMsgIds:[]};let a=$e(i[t(1357)].headers,e.mddBZ,"2"),x=a&&e.jQQhU($e,i[t(1357)][t(1566)],e[t(871)],"1"),u=a&&e[t(1316)]($e,i.message[t(1566)],e[t(1635)],"1"),h=u?e.HUINs(gt,i[t(1357)][t(1566)],e[t(1405)])?.split(",")[t(1313)](Boolean)||[]:[];return{enabled:r,isQoSMessage:a,isQoSAck:x,isAckCleanupMessage:u,ackMsgIds:h}}async function Vi(){let i=n;if(i(1134)==="UEFuS"){let t=this[i(1782)+"tManager"]?.[i(1724)+i(591)+"nt"](),r=this[i(1111)][i(1109)+i(631)+i(1749)](_0x10bb80[i(1496)],_0x9a1ec1[i(611)]);this["_dispatc"+i(450)+i(811)](e[i(1057)](_0x229c5a,e[i(1253)],{code:1006,reason:_0x4d6851[i(611)]||i(1490)+i(1094)+i(1864)+i(1760)+i(1296)+i(1197)+t,willReconnect:r})),r&&this[i(797)]();return}else return this[i(719)+i(926)]||(this[i(719)+"ger"]=new Ec),this[i(719)+i(926)][i(1619)]||await this["_QoSMana"+i(926)].openDB(),this[i(719)+i(926)]}async function Ac(i,t){let r=n,{enableAutoAck:a}=this[r(1111)],x=e.dlHXW($e,i.message[r(1566)],e[r(1781)],"1"),u=e[r(960)]($e,i[r(1357)][r(1566)],"is_ack","1"),h=vr[r(1297)](this,i);if(e[r(437)](a,x)){let{SeqID:p,LogID:g,service:y,LogIDNew:b,method:C}=i[r(1357)];this._sendAck({SeqID:p,LogID:g,LogIDNew:b,service:y,method:C,headers:[{key:e[r(1648)],value:"1"},{key:e[r(848)],value:e[r(1175)](b,"")},{key:r(1377),value:"0"}]})}u&&!h[r(1025)]&&this["_dispatc"+r(1653)+r(439)](i),e[r(1660)](t)}async function Cc(i,t){let r=n;this._debug(e.KBXUb,i[r(1357)]),e[r(483)](t)}async function Ic(i,t){let r=n,a=e[r(1494)](Se,await e[r(1360)](ji,i[r(378)]));try{if(e.nlFVH(e.jeQRQ,e[r(1608)]))this[r(423)]&&this[r(423)][r(1348)](_0x4cee36,_0x4ae2a7);else if(e[r(519)](a[r(1441)],Uint8Array)){let x=e[r(1363)](this[r(1111)][r(1391)+"ncoding"],Object)?{force:!!this[r(1111)]["payloadE"+r(428)][r(1439)],encoding:this[r(1111)][r(1391)+"ncoding"][r(653)]?this[r(1111)]["payloadE"+r(428)][r(653)].replace(/\s/g,"")[r(1159)+r(583)]():""}:{force:!1,encoding:this[r(1111)][r(1391)+r(428)]?this[r(1111)][r(1391)+r(428)][r(1533)](/\s/g,"")[r(1159)+"ase"]():""},u=a[r(1391)+r(428)]?a[r(1391)+r(428)][r(1533)](/\s/g,"").toLowerCase():"",h=e.sTowI(this[r(1111)][r(703)+r(684)],Object)?{force:!!this[r(1111)][r(703)+r(684)][r(1439)],type:this[r(1111)][r(703)+"ype"][r(433)]?this[r(1111)][r(703)+"ype"][r(433)][r(1533)](/\s/g,"")[r(1159)+"ase"]():""}:{force:!1,type:this[r(1111)][r(703)+r(684)]?this._options[r(703)+"ype"].replace(/\s/g,"")[r(1159)+r(583)]():""},p=a[r(703)+r(684)]?a["payloadT"+r(684)][r(1533)](/\s/g,"")["toLowerC"+r(583)]():"",g=h[r(1439)]?h[r(433)]:p||h[r(433)],y=x[r(1439)]?x.encoding:u||x[r(653)],b=[e[r(555)],e.HLwuZ,e[r(523)],e.gyJDh],C=[e[r(578)],"binary"];this[r(1111)]["enableTr"+r(1305)+r(1411)+"ad"]&&b.includes(g)&&(!y||C[r(1196)](y))?a[r(594)+r(1140)]=e[r(960)](Wi,a[r(1441)],0,a.payload[r(1737)+"th"]):a[r(594)+r(1140)]=""}else a[r(594)+r(1140)]=""}catch(x){a[r(594)+r(1140)]="",console[r(1556)](x)}i[r(1357)]=a,e[r(483)](t)}function Pc(i,t,r){let a=n,x=e[a(742)](r,8192),u=e[a(1850)](x,1),h=null,p=x;return function(g){let y=a;if(e[y(1001)](g,1)||g>u)return e[y(885)](i,g);e.AxtlS(p,g)>x&&(h=e[y(1177)](i,x),p=0);let b=t[y(1297)](h,p,p+=g);return e.crEbC(7,p)&&(p=e.isMVd(7,p)+1),b}}let kc=4294967295;function Tc(i,t,r){let a=n;return e.xYGiV(RangeError,e.ghgyv(e.MmozE(e[a(1796)](e.odcOK(e[a(1249)](e[a(897)],i),e[a(1380)]),e.ZLkfP(t,1)),e[a(672)]),r))}function Dc(i,t,r){let a=n;if(e[a(1560)](r,kc))throw new Error(e[a(1100)]);let x=3;for(;e.aAwSj(x,0);){let u=e[a(1622)](255,r);e[a(1086)](Sr,u,i,e[a(1035)](t,x)),r>>>=8,x--}return e[a(1027)](t,4)}function Rc(i,t){let r=n,a=0,x=t,u=e[r(830)](t,4);for(;e[r(796)](x,u);){let{value:h,offset:p}=br(i,x);x=p,a=e[r(1167)](a<<8,0),a+=h}return{value:a,offset:u}}function Nc(i,t,r){let a=n;return i?i[a(453)]<40?e[a(1086)](_r,i,t,r)+r:t[a(1600)+"e"]?t[a(1600)+"e"](i,r)+r:t[a(1432)]?e[a(952)](t[a(1432)](i,r),r):e.nYYiq(_r(i,t,r),r):r}function Lc(i,t){let r=n,a=new H(e[r(916)](e[r(700)](e[r(753)](i[e[r(826)](t,4)],24)|e[r(798)](i[e.RyKKC(t,5)],16),i[e[r(1659)](t,6)]<<8),i[e.ElrFF(t,7)]),e.EYZRQ(e[r(589)](e[r(1629)](i[t+0],24)|i[t+1]<<16,e.wINmQ(i[e[r(1280)](t,2)],8)),i[t+3]),!0);return t+=8,{value:a,offset:e.NINLT(t,8)}}function Oc(i,t,r){let a=n,x=i[a(1026)],u=i[a(1321)];return t[r]=e.mXtra(u,24),t[e[a(1280)](r,1)]=e[a(1479)](e[a(1862)](u,16),255),t[e[a(1035)](r,2)]=e.xCOgG(u,8)&255,t[e.RyKKC(r,3)]=e[a(409)](255,u),t[e[a(900)](r,4)]=e[a(1236)](x,24),t[e[a(1406)](r,5)]=x>>>16&255,t[e[a(1314)](r,6)]=e[a(1787)](x>>>8,255),t[e[a(1166)](r,7)]=e[a(1144)](255,x),r+=8,r}function br(i,t){let r=n;return i[r(1815)+"8"]?{value:i[r(1815)+"8"](t),offset:e[r(739)](t,1)}:{value:e.ejyLS(255,i[t]),offset:e[r(1249)](t,1)}}function Sr(i,t,r){let a=n;return t[a(615)+"t8"]?t[a(615)+"t8"](i,r):t[r]=e[a(1282)](255,i),e[a(1567)](r,1)}let Bc=function(i){return new Uint8Array(i)},Mc=e[n(489)](e[n(1486)],typeof Buffer)?Buffer["allocUns"+n(1331)]:e[n(1218)](Pc,Bc,Uint8Array[n(417)+"e"][n(474)]),zc=16,Er=32;function Fc(i){let t=n,r=0,a={};for(let x=0;x<i[t(453)];x++)e[t(680)](e.HFtbH,e[t(1051)])?(a[i[x][t(1223)+t(1771)]]=e.ZmxfE(Gi,i[x][t(1223)+t(1771)]),r+=e.BFsqz(14,a[i[x][t(1223)+t(1771)]])):(_0x417442(_0x4c8577,82),_0x3bff13(_0x5354ff,_0x3770a8));return[r,a]}function $i(i,t,r){let a=n,[x,u]=e[a(728)](Fc,i),h=e[a(729)](Mc,x),p=0;return i.forEach(g=>{let y=a,b={oQXPA:function(C,N){return e[I(386)](C,N)}};if(e[y(621)]===e.aqKMh){let C=nFhcjG[y(1048)](_0x27a290,_0x470e06),N=_0x26f1b[y(1416)];return _0x34481e[y(1416)]=_0x4c0cb6[y(927)]+C,N}else{let C=e.AueIT.split("|"),N=0;for(;;){switch(C[N++]){case"0":p=e[y(494)](Sr,0,h,p);continue;case"1":console[y(1556)](e.SOKji,p);continue;case"2":p=Oc(H[y(1785)+"er"](g[y(502)]||t),h,p);continue;case"3":console[y(1556)]("service",p);continue;case"4":p=Dc(h,p,g[y(1355)]||0);continue;case"5":p=e[y(1339)](Nc,g[y(1223)+y(1771)],h,p);continue;case"6":console.log(e.nMhYP,p);continue;case"7":console[y(1556)](e[y(1146)],p);continue;case"8":p=e[y(494)](Sr,u[g[y(1223)+y(1771)]],h,p);continue;case"9":console[y(1556)](e[y(1435)],p);continue;case"10":console[y(1556)](y(1793)+y(1210),g,g.service);continue}break}}}),{frameType:Er,headers:[{key:e[a(420)],value:r}],payload:h}}function Uc(i){let t=n,r=0,a=[];for(;e[t(512)](r,i[t(1737)+"th"]);)if(e.wDdsh(t(457),e[t(601)]))soSraa[t(881)](soSraa[t(1486)],typeof _0x2e8ce5)&&_0x30fbec[t(1604)+t(647)]&&_0x30744d[t(673)+"operty"](_0x22330b,_0x27cc0a[t(1604)+t(647)],{value:soSraa[t(1595)]}),_0x465458[t(673)+t(1306)](_0x39bc4c,t(1552)+"le",{value:!0});else{let{offset:x}=e[t(1680)](br,i,r);r=x;let u={cursor_name:"",cursor:0,service:0},{value:h,offset:p}=Rc(i,r);u[t(1355)]=h,r=p;let{value:g,offset:y}=e.WgLEm(br,i,r);r=y,u[t(1223)+t(1771)]=Wi(i,r,e.dkjGW(r,g)),r+=g;let{value:b,offset:C}=e[t(505)](Lc,i,r);u[t(502)]=b[t(605)](),r=C,a[t(884)](u)}return a}function qc(){let i=n;return{frameType:Er,headers:[{key:"cursor_f"+i(1263),value:"FILE_NOT"+i(572)}],payload:void 0}}class Hc{constructor(t,r,a){let x=n;this[x(1030)+x(1039)]=t,this._cursorFileName=r,this["_message"+x(1725)]=a,this[x(1568)]=e[x(1176)](Ji,this[x(1030)+x(1039)],x(1223)+x(1771))}async[n(1852)](){let t=n;await this[t(1568)][t(1852)]()}async[n(856)+"rs"](){let t=n;if(!this[t(1568)][t(1619)])return;let r=this[t(496)+"Strategy"],a=await this[t(1568)][t(706)]();switch(console.log(e.sXvFF,a),r){case e[t(1018)]:return a&&a[t(453)]?e.MwDLO($i,a,0,this[t(1470)+t(844)]):void 0;case t(486):return;case e.YTzgV:return a&&a[t(453)]?e.wbkBA($i,a,0,this["_cursorF"+t(844)]):e[t(487)](qc)}}async[n(936)](t,r,a){let x=n;if(e[x(1105)]==="XgzOM")return console[x(1556)](e[x(547)],t,r,a),this[x(1568)][x(936)]({cursor_name:t,cursor:r,service:a});this[x(570)+x(410)]()}async setCursors(t){let r=n,a=e[r(1358)](Uc,t);for(let x of a)console[r(1556)](r(1816)+"r",a),await this._qosDB[r(936)](x)}async[n(1330)](t){let r=n;return(await this._qosDB[r(1330)](t))?.[r(502)]}async[n(488)](){let t=n;await this[t(1568)][t(488)]()}[n(1695)+n(1362)+n(792)](t){let r=n;this[r(1470)+r(844)]=t}get[n(1619)](){let t=n;return e[t(1463)](e.jwKJF,e[t(1669)])?_0x17f753?_0xd54022.length<40?e[t(1436)](_0x1a6e03,_0x5054c3,_0x3deade,_0x5430c1)+_0x1ce9ed:_0x30e5a1.utf8Write?e.XLrad(_0x2a97fb[t(1600)+"e"](_0x3262f8,_0x4486ab),_0x1ff1f8):_0x3a820b[t(1432)]?e[t(1036)](_0x17ef46[t(1432)](_0x59d9a6,_0x3da5fa),_0x34c6a8):e[t(1796)](e[t(1064)](_0x457842,_0x1c85a3,_0x5b7cea,_0x1a62de),_0x334b2d):_0x279f2f:this._qosDB[t(1619)]}}let Kc=e.DIOPr;async function Yi(i){let t=n;if(e[t(853)](e.YlDGY,e[t(528)]))_0x19bb86&&this["_cursorM"+t(1588)][t(1695)+"rsorFile"+t(792)](_0x5a39db);else{if(!this._options.enableQoS)return null;let{aID:r,fpID:a,messageStrategy:x}=this[t(1111)],u=e.ZLkfP(i,Kc);try{return this["_cursorM"+t(1588)]?i&&this[t(1585)+t(1588)]["updateCu"+t(1362)+t(792)](i):this[t(1585)+t(1588)]=new Hc(a+"_"+r+"_"+u,u,x),this["_cursorM"+t(1588)][t(1619)]||await this[t(1585)+t(1588)][t(1852)](),this[t(1585)+"anager"]}catch{return null}}}async function Gc(i,t){let r=n,a=e[r(1610)]($e,i[r(1357)].headers,e[r(735)],"-1"),x=e.uzxfC($e,i[r(1357)][r(1566)],e.cNszP,"1"),u=gt(i[r(1357)][r(1566)],e[r(1020)]),h=Number(gt(i[r(1357)][r(1566)],e.LxENq))||0,p=vr.call(this,i),g=e[r(877)]($e,i[r(1357)].headers,r(1081)+"s","2"),y=e[r(1385)](gt,i[r(1357)].headers,e[r(1255)]),b=Number(gt(i.message[r(1566)],e[r(1193)]));if(p.isQoSAck)return t();let C=p[r(1802)+r(576)]?await Vi.call(this):null;if(e.FnyVZ(i.message[r(1355)],0)&&x&&!a||e[r(1287)](i[r(1357)][r(1355)],0)){if(u&&p[r(1802)+r(576)]&&C)return!!!await C[r(1330)](u)&&(e.rAWWh(e.VXFeP,e.NCWLg)?_0x2a537f(soSraa[r(1540)](_0x273182,_0x19453b[r(1446)]),_0x5bc41d[r(1089)+"on"],_0x3aa1ff.newVersion,_0x1cae42(_0x1b167d["transact"+r(425)])):(this[r(809)+r(813)+r(807)](i),await C.set(u,e.fDLnA(Date.now(),h)))),e[r(1294)](t);if(g){let N=await Yi.call(this);if(!N)return this[r(809)+r(813)+r(807)](i),e[r(899)](t);let O=await N[r(1330)](y)??-1;if(O<b)this[r(809)+r(813)+r(807)](i),N.set(y,b,i.message[r(1355)]);else throw new Error(r(1721)+r(800)+r(1699)+b+(" larger "+r(468)+r(740)+"r ")+O);return e[r(743)](t)}return this[r(809)+"hMessage"+r(807)](i),t()}}async function Wc(i,t){let r=n,a=vr.call(this,i);if(!a[r(1802)+"sage"])return e.vvzey(t);let x=await Vi.call(this);if(a[r(1438)+"anupMess"+r(1731)]&&a[r(1523)+"s"].length)for(let u of a[r(1523)+"s"])await x[r(1742)](u);e[r(1660)](t)}async function jc(i,t){let r=n,a=i[r(1357)][r(736)+"e"]===zc,x=i[r(1357)][r(736)+"e"]===Er;if(e[r(437)](!a,!x))return e.WWWDi(t);let u=e[r(1137)](gt,i.message[r(1566)],e[r(420)]);if(!u)return t();let h=await Yi.call(this,u);if(!h)return e.yMBGP(t);if(a){let p=await h.getCursors(),g={frameType:p?.[r(736)+"e"],SeqID:H[r(1785)+"er"](this[r(1107)]++),LogID:H[r(1785)+"er"](this[r(1111)]["logIDGen"+r(1142)]()),service:9e3,method:5,headers:p?.[r(1566)],payload:p?.[r(1441)]},y=E(g);this[r(423)]&&this[r(423)][r(1831)+"te"]&&this[r(423)][r(805)](y)}if(x){let p=i[r(1357)][r(1441)];p&&h[r(815)+"rs"](p)}}let Jc=async function(i,t){let r=n;this[r(888)]=!1,e.exJWU(clearTimeout,this[r(797)+"ionTimeo"+r(1384)]),e[r(1294)](t)},Vc=async function(i,t){let r=n;if(!this[r(423)]||e[r(775)](this[r(423)][r(1831)+"te"],this[r(581)]))return e[r(1660)](t);let{pingInterval:a}=this[r(1111)];this["_endpoin"+r(976)]?.[r(1178)+r(688)+r(1207)]();for(let u=0;e.EaKgf(u,this["_message"+r(1563)][r(453)]);u++){let h=this[r(496)+"Queue"][u];if(e.oxbAZ(this._ws[r(1831)+"te"],this.OPEN)&&e[r(1283)](null,h))e[r(1539)](r(1181),e[r(1630)])?(this[r(423)]&&this._ws[r(805)](h),this["_message"+r(1563)][u]=null):(this[r(888)]=!0,this._connect());else break}this[r(496)+r(1563)]=this[r(496)+r(1563)][r(1313)](u=>!!u),this[r(1337)+r(1658)+"Id"]=e[r(1385)](setTimeout,()=>this[r(1657)](),a),this[r(809)+r(1069)+"nt"](i),this[r(1386)+"er"]&&this[r(423)]&&(this._ws[r(1409)+"pe"]=this[r(1404)+r(684)]);let x=this[r(1782)+r(976)]?.[r(1724)+r(591)+"nt"]();this[r(549)](r(974)+x+r(1526)),e[r(669)](t)},$c=async function(i,t){let r=n,a=this["_endpoin"+r(976)]?.[r(1724)+r(591)+"nt"]();this._debug(r(974)+a),e[r(950)](t)};class Yc extends wr{constructor(t){let r=n,a={uDuxt:function(p,g,y,b){return e[I(1704)](p,g,y,b)},MQvaL:function(p,g,y){return e.LUCeB(p,g,y)},nFQAd:function(p,g,y,b){return e[I(1704)](p,g,y,b)},RYOnJ:function(p,g){return p===g},wVEwp:function(p,g,y){return e[I(1137)](p,g,y)},sISwt:r(1154),ohDnU:e.Pkdny,ADmMT:function(p,g){return e[r(1275)](p,g)},hWpGc:function(p,g){return e.DZWUB(p,g)},HqcaC:e[r(738)],EtAfo:"tvypg",caEpS:function(p,g,y){return e[r(1176)](p,g,y)},gMIzW:r(1532),dfsdS:function(p,g){return e.mWqVH(p,g)},rMAuj:function(p,g){return p(g)},aqffp:function(p,g,y){return p(g,y)},DtBPf:function(p,g){return e.NLyNp(p,g)}};super(),this[r(1005)+r(383)+r(829)]=!0,this[r(1386)+"er"]=lt,this[r(1468)]=fc,this[r(1103)+"T"]=it,this[r(1317)+"X"]=Ot,this._isWorker=Bt,this[r(496)+"Queue"]=[],this["_endpoin"+r(976)]=null,this[r(1820)+r(757)]=!1,this["_binaryT"+r(684)]=r(1515)+r(781),this[r(797)+r(1327)]=!1,this._connectionTimeoutId=null,this[r(1675)+r(432)+r(1301)]=null,this[r(1337)+r(1658)+"Id"]=null,this[r(1107)]=0,this._isInit=!1,this._url="",this[r(719)+"ger"]=null,this[r(1585)+"anager"]=null,this[r(1685)+"sCounter"]=null,this[r(1576)+"ls"]=e[r(699)],this.CLOSED=3,this[r(1394)+"NG"]=0,this.OPEN=1,this[r(1389)]=2,this[r(1104)]=p=>{let g=r;try{a.uDuxt(Ki,this,p,[Jc,Vc,$c])}catch(y){let b=a[g(521)](_e,g(1154),{message:y[g(1357)],code:Ve[g(1093)+"OR"],error:y});this[g(809)+g(677)+g(811)](b)}},this[r(429)+"ge"]=async p=>{let g=r,{pingInterval:y,pingFrequency:b}=this[g(1111)];if((e[g(1514)]("hi",p[g(378)])&&e[g(922)](e[g(1746)],b)||e[g(1428)](e[g(1454)],b))&&(this["_clearPi"+g(1222)](),this[g(1485)](e[g(1491)],e[g(1628)]),this[g(1337)+"gTimeoutId"]=e[g(1137)](setTimeout,this[g(1657)][g(1165)](this),y)),p.data!=="hi")try{if(e[g(539)]===e.RNoUf)e[g(1024)](Ki,this,p,[Ic,Ac,Wc,jc,Gc,Cc]);else for(var C in _0x52d504)KQmCOm[g(938)](_0x1911ac,_0x111add,C,{get:_0x3fa9d1[C],enumerable:!0})}catch(N){let O=e[g(1637)](_e,e[g(1729)],{message:N[g(1357)],code:Ve["MESSAGE_"+g(1029)],error:N});this["_dispatc"+g(677)+g(811)](O)}},this._onError=p=>{let g=r,y=this[g(1782)+g(976)]?.[g(1450)+g(463)+"es"](),b=this[g(1782)+g(976)]?.[g(1724)+g(591)+"nt"]();if(y&&!p[g(1357)]){let C="connect "+b+" fail, max retries reached";this["_dispatchErrorEv"+g(811)](a[g(521)](_e,g(1154),{message:C,code:Ve["MAX_RETR"+g(412)+"R"],error:p}));return}this[g(423)]&&a[g(1473)](this[g(423)][g(1831)+"te"],this[g(581)])&&this[g(1329)+g(388)](),this[g(809)+g(677)+g(811)](a[g(1844)](_e,a.sISwt,{message:p[g(1357)],code:Ve[g(1138)+g(1800)],error:p}))},this[r(1497)]=async p=>{let g=r;this[g(1661)+"mer"](),this["_clearPi"+g(1222)](),this[g(837)+g(861)+"rs"](),this[g(423)]=null,this[g(797)+g(1327)]=!1;let y=this[g(1782)+g(976)]?.[g(1450)+g(463)+"es"]();if(!y&&this[g(1320)+g(1488)]()&&!this[g(1820)+"osed"]){let b=this[g(1782)+g(976)]?.["getCurre"+g(591)+"nt"](),C=this[g(1111)][g(1109)+g(631)+"ptor"](p[g(1496)],p[g(611)]);this[g(809)+"hCloseEv"+g(811)](Ee(a[g(1307)],{code:1006,reason:p[g(611)]||g(1490)+g(1094)+g(1864)+g(1760)+g(1296)+g(1197)+b,willReconnect:C})),C&&this[g(797)]();return}if(a[g(917)](1e3,p[g(1496)])&&this[g(1820)+g(757)])if(a.hWpGc(a.HqcaC,a[g(573)])){this[g(809)+"hCloseEvent"](a[g(1500)](Ee,a[g(1307)],{code:1e3,reason:a[g(1205)]})),this[g(1782)+g(976)]?.["resetEndpointCon"+g(1207)](),this[g(1685)+g(542)]?.[g(994)+g(566)]();return}else return new _0x4062b8(_0x47a82c,{message:_0x4f8b82});if(a.dfsdS(1e3,p[g(1496)])&&y){let b=this[g(1782)+g(976)]?.[g(1724)+g(591)+"nt"](),C=p[g(611)];C||(C=await a[g(1216)](_c,this[g(1336)])),C=g(1490)+g(1094)+g(998)+C+(g(478)+"me: ")+b+(g(763)+g(415)+g(907)),this["_dispatc"+g(450)+g(811)](a.aqffp(Ee,g(1348),{code:p.code,reason:C}));let N=g(1589)+b+(" fail, m"+g(406)+g(1839)+"ed");this[g(809)+g(677)+"ent"](a[g(1844)](_e,a[g(697)],{message:N,code:Ve["MAX_RETR"+g(412)+"R"]})),this[g(1782)+"tManager"]?.[g(1178)+"pointCon"+g(1207)](),this["_pingLos"+g(542)]?.[g(994)+g(566)]();return}if(a.hWpGc(1e3,p[g(1496)])&&!p.reason)if(a[g(1624)]("wZtdM",g(1821))){let b=this[g(1782)+g(976)]?.["getCurre"+g(591)+"nt"]();this[g(809)+g(450)+g(811)](a[g(1859)](Ee,a[g(1307)],{code:p[g(1496)],reason:g(1490)+g(1094)+g(1864)+g(1760)+g(1296)+g(1197)+b})),this[g(1782)+g(976)]?.["resetEnd"+g(688)+g(1207)](),this["_pingLos"+g(542)]?.[g(994)+g(566)]();return}else this[g(1005)+g(383)+g(829)]=_0x52c10c,_0x3eacb1?this[g(1056)+g(1227)]():this[g(1056)+g(764)]();this[g(809)+g(450)+g(811)](p),this[g(1782)+g(976)]?.["resetEnd"+g(688)+"fig"](),this[g(1685)+g(542)]?.[g(994)+"nter"]()},this[r(1333)]=null,this[r(1832)]=null,this.onmessage=null,this[r(1613)]=null,this[r(1163)+r(1636)]=null,this[r(1074)+r(682)]=null,this[r(1837)+r(1764)+"yReconnect"]=null,this[r(1056)+r(1227)]=this[r(1056)+"nLine"].bind(this),this[r(1056)+r(764)]=this[r(1056)+r(764)][r(1165)](this),this._handlePageHide=this[r(842)+r(984)][r(1165)](this),this[r(842)+r(762)]=this[r(842)+r(762)].bind(this),this[r(1111)]={url:"",automaticOpen:!0,initReconnectInterval:1e3,maxReconnectInterval:1e4,reconnectIntervalGrowFactor:2,timeoutInterval:5e3,maxRetries:5,debug:!1,maxMessageQueueLength:e[r(1341)](1,0),service:0,logIDGenerator:c,headers:void 0,payloadEncoding:"",payloadType:"",fpID:"",deviceID:"",accessKey:"",ttwID:"",bddID:"",aID:"",disableAutoReconnect:!1,customParams:{},pingInterval:15e3,pingTimeoutInterval:4e3,pingFrequency:r(741),pingLossCount:2,enableTransformTextPayload:!1,logIDNewConfig:{enableAutoGenerateLogIDNew:!1,userIp:""},miniProgramParams:{customHttpHeader:{}},enableAutoAck:!1,reconnectInterceptor:()=>!0,enableQoS:!1,QoSLevel:2,messageStrategy:e.YTzgV,env:{xTTEnv:"",xUseEnv:""},listenNetworkChanged:!0};let{url:x,ws:u}=t,h=Array[r(1055)](x)?x:e[r(878)](e[r(1510)],typeof x)?[x]:[];if(!h||h[r(453)]===0)throw new Error(e.lnMWh);if(!e.XcAEI(hc,u))throw new Error(r(492)+r(449)+r(1581)+r(771)+r(1407)+"tructor "+r(1179)+r(1571));Object[r(875)](this._options,t),this["_endpoin"+r(976)]=new Hi(h,this[r(1111)][r(681)+"es"]),this["_pingLos"+r(542)]=new wc(this[r(1111)]["pingLoss"+r(1017)]),this[r(1111)][r(993)+"cOpen"]&&(this[r(888)]=!0,this[r(797)]()),this[r(1111)]["listenNe"+r(379)+"nged"]&&(this[r(1103)+"T"]||this[r(1317)+"X"]?this[r(773)+r(1073)+r(1572)]():this[r(1386)+"er"]&&this[r(1106)+"balEvent"+r(880)]())}[n(1056)+n(1227)](){let t=n;this[t(1111)][t(1021)+t(1068)+t(1794)]||this[t(1820)+t(757)]||this[t(1848)+"econnect"]()}[n(1056)+"ffLine"](){let t=n;this[t(416)+t(806)+"t"]();let r=e[t(1516)](mr,t(1109)+"t",{message:e[t(1334)]});this[t(1837)+t(1764)+t(1502)+"ct"]&&this[t(1837)+t(1764)+t(1502)+"ct"](r)}[n(1106)+n(912)+"Listener"](){let t=n;this._isBrowser&&window[t(1016)+t(880)](e[t(963)],this[t(1056)+"nLine"]),this[t(1386)+"er"]&&window[t(1016)+"Listener"](e[t(712)],this["_handleO"+t(764)]),this[t(1386)+"er"]&&window[t(1016)+"Listener"](e[t(649)],this[t(842)+t(984)]),this[t(1386)+"er"]&&window[t(1016)+"Listener"](t(1460),this._handlePageShow)}[n(597)+"balEvent"+n(880)](){let t=n;this[t(1386)+"er"]&&window[t(1626)+t(603)+t(1242)](e[t(963)],this[t(1056)+"nLine"]),this[t(1386)+"er"]&&window[t(1626)+t(603)+"ner"](e.JTVir,this[t(1056)+t(764)]),this[t(1386)+"er"]&&window[t(1626)+t(603)+t(1242)](e[t(649)],this[t(842)+"ageHide"]),this[t(1386)+"er"]&&window["removeEv"+t(603)+t(1242)](e[t(765)],this._handlePageShow)}[n(842)+n(984)](t){let r=n;!t.persisted&&(this[r(1386)+"er"]&&window[r(1626)+"entListe"+r(1242)](e[r(649)],this[r(842)+r(984)]),this[r(1386)+"er"]&&window[r(1626)+"entListener"](e.vSXYv,this["_handleP"+r(762)]),this[r(1348)]()),this[r(1386)+"er"]&&window["removeEv"+r(603)+r(1242)](e[r(963)],this[r(1056)+r(1227)]),this[r(1386)+"er"]&&window[r(1626)+r(603)+"ner"](r(1045),this["_handleO"+r(764)])}[n(842)+n(762)](t){let r=n,a={wbChu:function(x,u,h){return e.vXoFU(x,u,h)},WEsaK:e[r(1729)],gArRe:function(x,u,h){return e[r(1082)](x,u,h)},KUnjT:r(1348)};if(t[r(1239)+"d"])if(e[r(1627)]===e[r(1627)])this[r(1320)+"orOnline"]()&&(!this._ws||e.oPiYp(this[r(423)][r(1831)+"te"],this[r(581)])||e[r(723)](this[r(423)][r(1831)+"te"],this.CONNECTING))&&this[r(1056)+r(1227)](),this._isBrowser&&window[r(1016)+r(880)](e[r(963)],this[r(1056)+r(1227)]),this._isBrowser&&window[r(1016)+r(880)](e[r(712)],this[r(1056)+r(764)]);else{let x=auzPeQ[r(520)](_0x38a4ce,auzPeQ[r(507)],{message:this[r(1369)+r(1822)+r(1731)](_0x2dad9e)});this.emit(r(1154),x);let u=auzPeQ[r(1735)](_0x3bbb33,auzPeQ.KUnjT,{reason:this[r(1369)+r(1822)+r(1731)](_0xc70d49)});this[r(1485)](auzPeQ.KUnjT,u)}}async["_generat"+n(1575)](t){let r=n,{fpID:a,deviceID:x,bddID:u,ttwID:h,accessKey:p,aID:g,customParams:y={},enableAutoAck:b,enableQoS:C,QoSLevel:N,env:O}=this[r(1111)],ee,ce,ye;this._isBrowser||this._isMiniWX||this[r(1103)+"T"]?(ee=location&&e.FCIgn(e[r(690)],location[r(969)])?e[r(1472)]:e[r(1132)],ce=t.replace(/((^ws)|(^http))((?:[s]*:\/\/))/,""),ye=/^wss(.*:\/\/)/[r(1266)](t)?t:""+ee+ce):(ee=e.OiSgE,ce=t.replace(/(^http)((?:[s]*:\/\/))/,""),ye=/(^ws)((?:[s]*:\/\/))/[r(1266)](ce)?ce:""+ee+ce);let ht=u?r(850):h?e[r(1801)]:e[r(1365)],Xi=u||h||x;if(e[r(1332)](!Xi,!ht))throw new Error(e[r(1469)]);let Xc=e.fFzYJ==typeof y?await e.yMBGP(y):y,Zc=O?e[r(1204)](mc,O[r(1766)],O[r(968)]):{},Ar=Object[r(875)]({device_platform:e[r(1238)],version_code:r(1705)+"0",access_key:p,fpid:a,aid:g,[ht]:Xi,xsack:b?1:0,xaack:b?1:0,xsqos:C?1:0,qos_level:C?N:void 0,qos_sdk_version:2,...Zc},Xc),Qc=Object[r(1717)](Ar).reduce((Cr,Ir)=>Ar[Ir]!==void 0?""+Cr+(Cr?"&":"?")+Ir+"="+Ar[Ir]:Cr,"");return ye+r(1549)+Qc}async[n(797)](){let t=n;if(!(this[t(797)+t(1327)]||this._readyClosed)){this[t(797)+t(1327)]=!0;try{let r=this[t(1782)+t(976)]?.[t(710)+"rentEndpointReac"+t(584)+"tries"](),{timeoutInterval:a}=this._options;if(r){let u=this[t(1782)+"tManager"]?.[t(1724)+"ntEndpoint"](),h=this[t(1782)+"tManager"]?.[t(715)+"ackupEndpointAndUpdateCo"+t(620)](),p=this["_endpoin"+t(976)]?.[t(1724)+t(591)+t(925)+"ount"]();if(h){let g=t(1589)+u+(t(945)+", max retries reached, will use "+t(1819)+t(1010))+h+" to retry",y=_e(e[t(1729)],{message:g,code:Ve[t(1559)+t(412)+"R"]});this._debug(g),this["_dispatc"+t(677)+t(811)](y),this._url=await this[t(536)+t(1575)](h),this[t(549)](t(1589)+h+" "+p+" times"),this._removeWsListeners()}else{let g=t(1589)+u+(t(945)+t(763)+"tries reached");this[t(549)](g),this[t(809)+t(677)+"ent"](e.ithyJ(_e,e.Fjytr,{message:g,code:Ve[t(1559)+t(412)+"R"]}));return}}else{let u=this["_endpoin"+t(976)]?.[t(1724)+"ntEndpoi"+t(1382)+t(1652)](),h=this[t(1782)+t(976)]?.["getCurre"+t(591)+"ntTriesC"+t(1841)]();this[t(1336)]=await this[t(536)+t(1575)](e[t(1351)](u,"")),this[t(549)](t(1589)+u+" "+h+t(1789)),this[t(837)+t(861)+"rs"]()}if(this._isInit)this[t(888)]=!1;else{let u=mr("reconnect",{message:e[t(1774)]});this[t(1163)+t(1636)]&&this[t(1163)+t(1636)](u)}let x=this[t(1782)+"tManager"]?.[t(1724)+t(591)+t(925)+t(1841)]()||0;e.gBaSm(x,1)&&await this[t(1701)](e[t(430)](x,1)),this[t(549)]("connecting url: "+this[t(1336)]+(" protoco"+t(1060))+this[t(1576)+"ls"]),this[t(423)]=e.vXoFU(gc,{url:this[t(1336)],protocols:[this[t(1576)+"ls"]],headers:this[t(1111)][t(1580)+"ramParams"][t(686)+t(1562)]},this._options.ws),(this._isBrowser||this[t(1284)+"r"])&&this[t(423)]&&(this[t(423)][t(1409)+"pe"]=this[t(1404)+t(684)]),this[t(629)+t(527)](),this["_connect"+t(1274)+"utId"]=setTimeout(this._onTimeout[t(1165)](this),a)}catch(r){throw this[t(797)+t(1327)]=!1,r}}}[n(1661)+n(1804)](){let t=n;clearTimeout(this[t(797)+t(1274)+t(1384)]),this[t(797)+"ionTimeo"+t(1384)]=null}["_clearPi"+n(1222)](){let t=n;e[t(825)](clearTimeout,this[t(1337)+t(1658)+"Id"]),e[t(553)](clearTimeout,this[t(1675)+t(432)+t(1301)]),this[t(1337)+"gTimeoutId"]=null,this["_reconne"+t(432)+t(1301)]=null}[n(549)](...t){let r=n;this[r(1111)][r(1034)]&&console[r(1556)].apply(console,[r(915)+">",...t])}[n(568)+n(436)+"e"](t){let r=n,{initReconnectInterval:a,maxReconnectInterval:x,reconnectIntervalGrowFactor:u}=this[r(1111)],h=a*Math[r(1570)](u,e[r(1722)](t,1));return e[r(1287)](h,x)?x:h}[n(1657)](){let t=n;if(this[t(423)]&&this[t(423)][t(1831)+"te"]===this[t(1394)+"NG"]){this[t(933)+t(1222)](),this._pingPongTimeoutId=e.xoZSK(setTimeout,this[t(1657)][t(1165)](this),this[t(1111)][t(989)+t(748)]);return}if(!this[t(423)]||e[t(1120)](this[t(423)].readyState,this[t(581)]))return void this[t(1848)+t(1636)]();this[t(423)]&&this._ws[t(805)]("hi"),this["_reconne"+t(432)+t(1301)]=e.yOLWX(setTimeout,this["_handleR"+t(1636)+t(535)][t(1165)](this),this[t(1111)]["pingTime"+t(599)+t(1683)])}[n(1848)+n(1636)+n(535)](){let t=n;this[t(1685)+t(542)]?.addCount(),this.emit(e[t(648)],e.btBYs),this[t(1685)+t(542)]?.[t(1450)+t(962)+"nt"]()?this[t(1848)+"econnect"]():this[t(1657)]()}[n(1320)+n(1488)](){let t=n,r={dNuwr:function(a,x){return e[I(1480)](a,x)},sGVrR:function(a,x,u){return e.HUINs(a,x,u)},QnhzV:function(a,x){return e[I(1402)](a,x)},rjWmu:function(a,x){return e[I(1484)](a,x)},EOPGJ:function(a,x,u){return e[I(1419)](a,x,u)}};if(e[t(1809)](t(1356),e[t(1536)]))return this[t(1103)+"T"]||this._isMiniWX?this["_miniNav"+t(383)+t(829)]:(this[t(1386)+"er"]||this[t(1284)+"r"])&&this._options[t(1616)+"tworkCha"+t(901)]?navigator[t(1643)]:!0;for(_0x3ceca8>>>=0;NVTNBn[t(713)](_0x37df5c,128);)NVTNBn.sGVrR(_0x30c6ff,_0x897824,NVTNBn[t(634)](NVTNBn[t(833)](127,_0x230f59),128)),_0x38c75b>>>=7;NVTNBn[t(1209)](_0x5a692c,_0x5a8779,_0x58f83a)}["_handleR"+n(1636)](){let t=n;!this[t(1320)+t(1488)]()||this[t(1820)+t(757)]||(this[t(1782)+"tManager"]?.["resetEnd"+t(688)+t(1207)](),this[t(1685)+t(542)]?.[t(994)+t(566)](),this._ws?this[t(1329)+t(388)](1001,e.qpowH,!0):this[t(797)]())}[n(773)+n(1073)+n(1572)](){let t=n,r={csKzW:function(a,x){return e[I(1693)](a,x)},ZRrmw:function(a,x){return e[I(596)](a,x)}};if(t(1308)!==e[t(503)]){if(BHCOnS[t(750)](BHCOnS[t(518)](_0x361699.offset,_0x25e6f1),_0x19bcd2.limit))throw new _0x3d3213("Skip pas"+t(469));_0x16730b.offset+=_0x3dcde5}else this[t(1103)+"T"]?tt[t(1254)+t(701)+t(1169)](({isConnected:a})=>{let x=t;this[x(1005)+x(383)+x(829)]=a,a?this[x(1056)+x(1227)]():this[x(1056)+x(764)]()}):this[t(1317)+"X"]&&wx[t(1254)+t(701)+"hange"](({isConnected:a})=>{let x=t;this["_miniNav"+x(383)+x(829)]=a,a?this["_handleO"+x(1227)]():this[x(1056)+"ffLine"]()})}_wait(t){let r={ehCOd:function(a,x,u){return e.BvVHG(a,x,u)}};return new Promise(a=>{let x=I;r[x(1075)](setTimeout,a,this["_getInte"+x(436)+"e"](t))})}[n(1329)+n(388)](t=1e3,r="",a=!1){let x=n;this[x(423)]&&this[x(416)+"WebSocket"](t,r,a)}[n(769)+"ut"](){let t=n,r=this[t(1782)+"tManager"]?.[t(1724)+"ntEndpoint"]();this[t(549)](t(1589)+r+" timeout"),this[t(1329)+t(388)](1001,e[t(1265)],!0)}[n(1076)](t){let r=n,a=e[r(1765)](pr,t);this[r(423)]&&e[r(1579)](this[r(423)][r(1831)+"te"],this[r(581)])&&(this[r(423)]&&this[r(423)][r(805)](a),this[r(549)](r(442),t))}["_removeW"+n(861)+"rs"](){let t=n,r=e[t(814)].split("|"),a=0;for(;;){switch(r[a++]){case"0":this[t(423)][t(1626)+t(603)+t(1242)](e[t(1729)],this._onError);continue;case"1":this[t(423)]["removeEv"+t(603)+t(1242)](e[t(1632)],this._onMessage);continue;case"2":this[t(423)][t(1626)+t(603)+t(1242)](e.Pkdny,this[t(1497)]);continue;case"3":if(!this[t(423)])return;continue;case"4":this[t(423)][t(1626)+t(603)+t(1242)](t(879),this[t(1104)]);continue}break}}[n(629)+n(527)](){let t=n,r=(t(1062)+"3").split("|"),a=0;for(;;){switch(r[a++]){case"0":this[t(423)][t(1016)+"Listener"](e[t(1253)],this._onClose);continue;case"1":this[t(423)]["addEvent"+t(880)](e.rBmiD,this[t(429)+"ge"]);continue;case"2":this[t(423)][t(1016)+"Listener"](e[t(1123)],this[t(1104)]);continue;case"3":this._ws.addEventListener(t(1154),this[t(874)]);continue;case"4":if(!this[t(423)])return;continue}break}}[n(1431)+"nceClose"](t=1e3,r=""){let a=n,x={CDRSc:function(u,h){return u===h},FFJul:e[a(1258)],eWayZ:function(u,h){return u(h)}};if(e[a(654)]===e.IyyyT)return eQcZmo[a(1797)](typeof _0xd8f3c,eQcZmo.FFJul)?eQcZmo[a(394)](_0xc03d74,_0x3eeb6d):(_0x2926a3 instanceof _0x52467a&&eQcZmo.eWayZ(_0x39b641,_0x1b481b),_0x9d6ac8(_0x47771f,_0xbe0827())?new _0x258027(_0x1d8ae5,_0x21bd58):_0x5c7a55);try{this._ws&&this[a(423)][a(1348)](t,r)}catch{}}[n(416)+n(806)+"t"](t=1e3,r="",a=!1){let x=n;if(this[x(933)+x(1222)](),this[x(1661)+x(1804)](),this[x(837)+x(861)+"rs"](),this[x(1431)+x(1168)](1e3,r),this[x(797)+"Lock"]=!1,a&&this["_navigat"+x(1488)]()&&!this[x(1820)+"osed"]){if(this[x(1782)+x(976)]?.[x(1450)+x(463)+"es"]()){let h=this["_endpoin"+x(976)]?.getCurrentEndpoint();this["_dispatc"+x(450)+x(811)](e[x(1190)](Ee,e[x(1253)],{code:1006,reason:x(1589)+h+(x(945)+x(763)+x(415)+"ached"),wasClean:!0}))}else{let h=this[x(1111)][x(1109)+x(631)+x(1749)](t,r);this["_dispatc"+x(450)+x(811)](e[x(1744)](Ee,e.Pkdny,{code:t,reason:r,wasClean:!0,willReconnect:h})),h&&this[x(797)]()}return}this[x(1320)+x(1488)]()||this[x(1820)+x(757)]?this[x(809)+x(450)+x(811)](Ee(e[x(1253)],{code:t,reason:e[x(447)]})):this[x(809)+x(450)+x(811)](e.vnXJk(Ee,e[x(1253)],{code:1006,reason:e[x(1829)]})),this[x(423)]=null,this[x(1782)+x(976)]?.[x(1178)+x(688)+x(1207)](),this[x(1685)+x(542)]?.[x(994)+x(566)]()}[n(809)+n(1069)+"nt"](t){let r=n;e.ZcYLI(e.GLtJo,e[r(1217)])?(this[r(1485)](e.tmhol,t),this.onopen&&this[r(1613)](t)):(this._isInit=!0,this[r(797)]())}[n(809)+n(813)+"Event"](t){let r=n,a={iYBfj:function(x,u){return e[I(1302)](x,u)},wwIbj:function(x,u){return e[I(475)](x,u)},nXOyx:function(x,u){return e.TANBn(x,u)}};if(e[r(1131)]!==r(1256)){if(WuJMBj[r(1149)](_0x5e6693,_0xf6fc7f))return WuJMBj.wwIbj(_0x44ecaf,_0x395720);if(_0x1709c4[r(1231)](_0x1a11df))return _0x54743f.get(_0x3fd3d0);let x=WuJMBj[r(1617)](_0xfae58,_0xee58fa);return WuJMBj.nXOyx(x,_0x3ab95d)&&(_0x573b74[r(936)](_0xfa2d7a,x),_0x36d163[r(936)](x,_0x1f4dea)),x}else this[r(1485)](e.rBmiD,t),this[r(869)+"e"]&&this[r(869)+"e"](t)}[n(809)+"hAckMess"+n(439)](t){let r=n;this[r(1485)](e[r(1529)],t),this[r(1074)+"eAck"]&&this[r(1074)+r(682)](t)}["_dispatc"+n(677)+n(811)](t){let r=n;if(e[r(683)](e.egcPF,r(544)))this[r(1485)](e[r(1729)],t),this[r(1832)]&&this[r(1832)](t);else return e[r(1633)](_0x42ee5c(4).join("0"),_0x943c49(_0xd63cc9,2)[r(1604)](16))[r(986)](-4)}[n(809)+n(450)+"ent"](t){let r=n;this[r(1485)](e[r(1253)],t),this[r(1333)]&&this.onclose(t)}get[n(1409)+"pe"](){let t=n;return this[t(423)]?this._ws.binaryType:this[t(1404)+t(684)]}set[n(1409)+"pe"](t){let r=n;this["_binaryT"+r(684)]=t,this._ws&&(this[r(423)].binaryType=t)}get[n(592)+"nt"](){let t=n;return this[t(1782)+"tManager"]?.[t(1724)+t(591)+t(925)+t(1841)]()||0}get[n(1772)+n(640)](){let t=n,r=this[t(496)+t(1563)][t(1366)]((a,x)=>(a+=x&&x[t(1737)+"th"]||0,a),0);return e[t(513)](r,this[t(423)]?this._ws[t(1772)+"Amount"]:0)}get[n(1545)+"ns"](){let t=n;return this[t(423)]?this._ws[t(1545)+"ns"]:""}get[n(969)](){let t=n;if(t(1716)===e[t(731)])return this[t(423)]?this._ws[t(969)]:"";_0x1fbc30[t(705)]().then(()=>{this["_addWsLi"+t(527)]()})}get[n(1831)+"te"](){let t=n;return this[t(423)]?this._ws[t(1831)+"te"]:this[t(1111)][t(993)+t(696)]?this.CONNECTING:this[t(402)]}get url(){let t=n;return this[t(423)]?this._ws[t(1350)]:this[t(1336)]}[n(1348)](t=1e3,r){let a=n;if(this[a(1820)+a(757)]=!0,this[a(1661)+a(1804)](),this[a(933)+a(1222)](),this[a(597)+a(912)+a(880)](),this[a(719)+a(926)]?.[a(488)](),!this._ws)return void this._debug(e.BwFJM);if(e[a(828)](this[a(423)][a(1831)+"te"],this.CLOSED)||e[a(887)](this[a(423)][a(1831)+"te"],this[a(1389)]))return void this[a(549)](e.uwjvj);this["_destroy"+a(806)+"t"](t,r)}async[n(805)](t,r){let a=n,x={XxHfF:function(ye,ht){return ye!==ht}};if(e[a(399)](null,t))throw new Error(e.GuDRl);e[a(460)]==typeof t&&(t=JSON[a(1440)+"y"](t)),e[a(1161)](e.gyJDh,typeof t)&&!e.jWFKn(t,ArrayBuffer)&&!(t[a(1861)]&&e[a(1455)](t[a(1861)],ArrayBuffer))&&(t=JSON[a(1440)+"y"](t));let u=await ji(t),h=e.XcAEI(pc,t),{method:p=0,service:g=this[a(1111)][a(1355)],logID:y=this._options[a(1825)+"erator"](),headers:b=this[a(1111)][a(1566)],payloadEncoding:C=this[a(1111)][a(1391)+"ncoding"],payloadType:N=this._options[a(703)+"ype"],logIDNew:O=this[a(1111)][a(1867)+a(1687)]["enableAu"+a(1128)+a(831)+"ew"]?e[a(1574)](o,this[a(1111)]["logIDNew"+a(1687)][a(1415)]):""}=e[a(1332)](r,{});if(!g)throw new Error(e[a(687)]);let ee={SeqID:H[a(1785)+"er"](this[a(1107)]++),LogID:H.fromNumber(y),service:g,method:p,headers:b,payloadEncoding:e[a(519)](C,Object)?C[a(653)]?C.encoding:"":C,payloadType:N instanceof Object?N[a(433)]?N.type:h:N||h,payload:u,LogIDNew:O},ce=pr(ee);if(this._ws&&e.ZpYQJ(this[a(423)].readyState,this.OPEN))this[a(423)]&&this[a(423)][a(805)](ce),this[a(549)](e.SxaXq,ee);else if(e[a(1740)](this["_message"+a(1563)][a(453)],this._options[a(666)+a(982)+a(1448)]))if(e[a(1587)]===e[a(1098)]){if(kUJtDw[a(443)](4,_0x2dee6b[a(453)])){let ye=_0x3e38a0[a(1541)+"g"](0,4-_0x4cc9a7[a(453)]),ht=ye.concat(_0x689efe);_0x5b5acc.push(ht)}else _0x3eff99[a(884)](_0x7865f9);_0x8c7b9d&&(_0x1e0e18+=1),_0x3d40fb+=1,_0x5f07e6=!1}else this[a(496)+a(1563)].push(ce),this[a(549)](a(1077),ee);else e[a(1226)](e[a(1129)],e[a(403)])?(this["_message"+a(1563)].shift(),this[a(496)+a(1563)][a(884)](ce)):(_0x20b40e(_0x367239,8),_0x375788(_0x3addac,_0x18e1fc));return{seqID:this[a(1107)],logID:y,logIDNew:O}}async reconnect(t){let r=n,{url:a}=e[r(1118)](t,{}),x=Array[r(1055)](a)?a:e[r(569)](r(1639),typeof a)?[a]:[];t&&Object[r(875)](this[r(1111)],t),x&&x[r(453)]?this[r(1782)+r(976)]=new Hi(x,this[r(1111)][r(681)+"es"]):this["_endpoin"+r(976)]?.[r(1178)+r(688)+r(1207)](),this[r(1685)+r(542)]?.[r(994)+r(566)](this[r(1111)][r(1451)+r(1017)]),this["_readyCl"+r(757)]=!1,this[r(423)]&&e[r(883)](this[r(423)].readyState,this[r(402)])?this[r(1329)+r(388)](1e3,e[r(1457)],!0):(this._isInit=!0,this[r(797)]())}async[n(1262)](){let t=n;if(!this[t(797)+"Lock"]){let r=e[t(1776)][t(582)]("|"),a=0;for(;;){switch(r[a++]){case"0":this[t(797)]();continue;case"1":this[t(888)]=!0;continue;case"2":this["_endpoin"+t(976)]?.[t(1178)+t(688)+t(1207)]();continue;case"3":this[t(1820)+t(757)]=!1;continue;case"4":this[t(1685)+t(542)]?.[t(994)+"nter"]();continue}break}}}["addEvent"+n(880)](t,r){this.on(t,r)}[n(1310)+n(807)](t){let{type:r}=t;this.emit(r,t)}[n(1626)+n(603)+n(1242)](t,r){let a=n,x={aJLdT:function(u,h){return e[I(1198)](u,h)}};if(e[a(1714)](e[a(691)],e[a(709)])){let u=this[a(1568)][a(426)](this[a(622)]),h=_0x5c4203[a(1554)](wnxDEU.aJLdT(u,"{}"));return _0x1cad41[a(565)](h)}else this[a(1578)](t,r)}[n(838)](){let t=n,r={sMjCC:function(a,x){return e[I(1418)](a,x)},oGKEg:e.pgDoO,bQKnD:e[t(827)],kOOJe:e[t(1491)],WTlyA:e[t(648)],KLKpW:e[t(1628)],KhgIf:function(a,x){return a!==x},DjgDd:e[t(1786)],ekgKx:function(a,x,u){return e[t(1662)](a,x,u)}};return new Promise((a,x)=>{let u=t,h={oWjds:r.KLKpW,QQxAH:r[u(1091)],YWrsY:r[u(659)]};if(r[u(692)](u(667),r[u(1221)])){this[u(933)+u(1222)](),this[u(1337)+u(1658)+"Id"]=r[u(1641)](setTimeout,this._ping[u(1165)](this),this._options[u(989)+u(748)]);let p=()=>{let y=u;a(h[y(985)]),this[y(1578)](h[y(1130)],p),this[y(1578)](h[y(717)],g)},g=()=>{let y=u,b={xUncX:function(C,N){return C>=N}};if(r[y(999)](r[y(1148)],r[y(1148)]))x(r[y(1032)]),this[y(1578)](r[y(1091)],p),this[y(1578)](r[y(659)],g);else return lNDajr[y(799)](_0x69da51[y(927)],_0x458c7c[y(1416)])};this.on(r[u(1091)],p),this.on("ping_onc"+u(908)+"t",g),this[u(1657)]()}else this[u(947)]++})}}})(),X[A(1381)+A(1173)]=$[A(1381)+"oseEvent"],X[A(1121)+A(1719)]=$[A(1121)+A(1719)],X[A(1184)+"e"]=$[A(1184)+"e"],X[A(807)]=$[A(807)],X[A(1286)]=$[A(1286)],X[A(1761)+A(767)+A(637)]=$["FrontierMessageE"+A(637)],X[A(767)+A(637)]=$[A(767)+A(637)],X[A(923)+"t"]=$.OpenEvent,X[A(766)+A(1247)]=$[A(766)+A(1247)],X[A(1084)+A(1173)]=$[A(1084)+A(1173)],X.createErrorEvent=$["createEr"+A(1719)],X[A(616)+A(1508)+"nt"]=$[A(616)+A(1508)+"nt"],X[A(909)+"enEvent"]=$[A(909)+"enEvent"],X[A(940)+"connectE"+A(637)]=$[A(940)+A(1678)+A(637)],X[A(1799)+A(1814)]=$[A(1799)+A(1814)],X[A(1651)+A(1771)]=$[A(1651)+"ame"];for(Mn in $)[A(1381)+A(1173),A(1121)+A(1719),A(1184)+"e","Event",A(1286),A(1761)+A(767)+A(637),A(767)+A(637),A(923)+"t",A(766)+A(1247),"createCl"+A(1173),A(658)+A(1719),"createMessageEvent",A(909)+A(932),"createRe"+A(1678)+"vent",A(1799)+A(1814),"encodeFr"+A(1771)][A(760)](Mn)===-1&&(X[Mn]=$[Mn]);function Kn(){let n=["yxjYyxLIDwy","Avfrvgm","yKvyr0u","whrAz20","mdaWmdaWmda","vxjjwuK","EeLWALq","sfbVB00","ywnRtxnNswq","z2v0s2v5","tLDNAfG","ihn1y2nLC3m","tfvdzui","z2fuCNy","s2XbtLy","x2LUAxrqCM8","zwPxv0e","yNLL","CMvWBgfJzq","ihrYEsbYzwm","DgLTzw91DcW","twzozNm","vu9VDgG","sg1er2W","tKzyBvy","ENDuyNu","C3vIC3rYAw4","DgfYz2v0","seX3DvO","u29lsw0","zxH0zw5ZAw8","su1dA1e","DgfIyxnL","zw1LBNq","l3DZl3yY","DLfewLC","wMPgqwO","x19LC01Vzhu","BgLUzw5V","CgfYC2u","y2f0y2G","Bg9N","vu1qu1i","u1n3A2i","tufyx1jfvfi","z1vIrNu","BuTsruW","DhbizwfKzxi","uxvLDwu","yxbWBhK","B3Pvvwy","AgvHzgvYCW","zNb3seC","x3fVC0rc","Bg9Zsgu","Cg93","Aw5Lza","yw5Nzq","CMvQzwn0","svLzBeK","zvvYBa","x3bYB3rVy28","swXKCeO","B2zM","Ce9SBve","BwLUAvbYB2C","CYbWyxjHBxm","yKXws2y","EffWtKO","Fdn8ohWXFdu","x2n1CNnVCK0","BMrLEa","u2v3Aw8","yw5Hz2vY","y29UBMvJDca","wfv6Dvm","DgLLCKPtt04","CKfxv2G","y3vYCMvUDeK","z3jsD2S","uhnpuva","yw9wwMq","ufzmANC","zNjVBuj5Dgu","zxf1ywXZ","DxrMofDYAxq","s09tvgm","wM14zKu","AwXdzu4","Dg9tDhjPBMC","D3LMCMq","t2HPEuS","u2HHCMvKv28","svH1sgO","zNjVBujPDhm","C3fWvfa","wLHUuNa","uMXVANa","B25VCgvU","tu1ZCfm","A01iuhK","BgLZDgvUtMu","D3DjyMO","y0Xkrui","AxnszwfKEq","vuDesxG","ugXmthK","whPryw0","mNW0Fdn8mxW","rhrcugy","rwz2qxO","CMvTB3zLrxy","weTkq2y","zvD6swC","r1fuqvK","yKnds0C","rLPRt28","CKjTAuq","AeD0uuG","vu1PEwy","A1LvBKG","zwnVBM5Ly3q","ug1ZBxG","q09oveLovuu","C3rYAw5N","zMX1C2HfEha","zwTNs3G","Evj2BNK","B25mAw5L","vxPutgy","y2uGBM90igK","vuzhre8","z0ngvM0","y05ZELa","BMXgvKG","wg9ssgC","zw5JB2rLrNi","yxrLq291BNq","AefJA01LC3m","AgvHzgvY","sLnptLa","swfPCKW","x3bPBMC","z1rPBwvVDxq","tKLotfq","DeP1D2u","x2nSzwfYvgK","C0LlsLO","rKvgtuC","rgX6B3K","B25Uzwn0Aw4","CxHpsxK","y0TUrgW","CNnZtgC","ANDlsKy","tuvtu0fhrv8","wMzzvxa","v0v0DgW","ruDVsxG","nJn2Awnwt0m","x3jLy29UBMu","B3jRzxjhBg8","AwnVD2q","y29UBMvJDeu","B2nRzxrtDwm","sfvjtNm","sMP6vwm","zv9ZDwnJzxm","DMfS","C1rVD0K","x3bPBMDmB3m","t2jQzwn0","q29UzMLN","B1LkCNC","BwvZC2fNztO","zhDTBgu","uKvJC3a","B3bLCNr5tMe","vevRA0m","mtG2mJCWmNrvAxLbwa","DxbKyxrLq3u","EuTquuq","vgXLyMW","sMnKB2m","ign1CNnVCIa","tNHfEfa","x3DHAxq","zMLUza","ywnRx2LK","CeDeyMK","zNDZxZeUmc4","yvHWww8","uwPWzwm","A3vKENa","AgzRDwW","yuXwueq","zMXAzLG","EM10s20","svzeAK4","u0jsAg0","BhzSu2u","rNzyrLC","A2v5CW","tgfwAeO","CM9YrxzLBNq","otmZntaYEM1MqNzT","CMvJzxzPzwq","BNPrtM0","z1vNsfq","z2v0q3vYCMu","u3rYyxrLz3K","Bg5sEwe","rwXusMO","qxfTCva","rMP5Dhi","yxPWt0u","ywDL","Dwjdzhq","y29SBM8","yKPKwNe","z0fYuMu","EvH6AMO","yNL0zuXLBMC","AwXK","BgH2rfC","zMzsrwC","A1LjEvi","zgvS","r21bEum","DLHVrLu","BMv3vMvYC2K","vxvlv1C","s3flqMm","ENHls08","ChrVCG","v2PZu1a","zxHkv1u","r0Ljy1q","Cg9PBNrbBMq","Cw5zu1m","v2TvCLa","CMvHzhDYAxq","yNLktuu","rKPRvKm","CMvTB3zLq2G","D24GCMvHC28","rNjVBNrPzxi","C2v0u3rVCMe","DgPetw4","BwvKAwf0zwW","u0XVBfK","EfvZzuvUDG","CMvZzxruCMK","sKHHuNO","AufPEKC","u2XTrxu","yw1L","yNvMzMvYzwq","z1H4AMO","DLveA2W","ENDKrfK","EufbsLm","AxnAzxjV","nta4ntK2nev5yKL2vq","zxjFAxnFywm","BKTfCei","yKnizM0","x2vUzhbVAw4","EerMzvi","q1resfa","zNjVBu51Bwi","BLbhs1G","CMjwrM0","C2v0zgi","ihrPBwvZ","tMLzCMe","BwvZ","u2PNEfa","y3vYC29YlNm","BMvJDa","C0LRBuu","wK5Sru4","q0rsu2m","suzcuLa","zgvJB2rLzey","uLjpuG","wxLbrum","AxnrB1nnzxm","vxfwrNG","BwvY","BKTvBKi","rNPxBgq","yu9uCvq","CMTyC3u","txfzrNK","zgrOsKe","y2vZC0HHBMq","mJq4otGZmLjYyM1xza","s0TAAfu","CMfTzq","CMvHzfvjBNq","C2v0y3vYC28","B1fUyuG","zgvSzxrLrge","yMfJA3vWigu","x3jLywr5q2W","D1P0ze0","CNjVCK1LC3m","nKH1C2r2za","zu5Hzw4","Bg9Nsurhzw4","tg9NsurozxC","ywX3yxLZ","vu9jEwW","yvfcug8","sM9gu0q","CMvHzhLtDge","B25LCNjVCG","zvDwCfe","x3bHDgHlzxK","CMvXDwLYzwq","rMvdCuC","B25tDg9Wsw0","Fdr8oxW3Fdi","zxmGCMvHy2G","B05sswG","B3vUDa","BgvY","ihzHBgLKihm","D1zfD3a","Aw1LCYbPBIa","CM92AwrLihy","vfnVBNy","x2HHBMrSzvi","zeLVz2m","r3PHuMy","yxKSig5LDhC","B3bLBKrc","CMLnrgS","B2nRzxrgywK","rvbyue0","rMzPsgm","AhzhsNa","Dg9Y","yxfMzNa","rLz6twO","yNvMzMvY","rK9vyMe","AvPKuxK","zcWGDw5RBM8","EMTWu0q","suDWtxG","Bg9NsurozxC","D1zItfe","icSG","qwfiAMK","zhzRrwW","zgf0yq","DhDVCMTdAge","zwHky2O","v1LiA1e","AgnTwMK","AwDHDg9Yt24","vefoqM4","D1jiugW","vefMEha","vwvyvLq","zwn0","wxH1Au0","zfDVCMTLCKC","BeXRDMe","Dgv4Dc9Qyxy","Exftv1i","zvDHEvO","BKDkzue","CvPcshy","y1P6B0e","uvvRq3e","y0jVsee","AxjLza","nNWZFdf8mNW","q0Xpu0ve","CgfMt2C","A3HHugW","txLpDwy","yxGGCMv0CMK","vhnxD2S","DxHdsLO","zwP5tfm","BezSDxnO","BwvZC2fNzv8","suvtx0vsuK8","rgvKAwnHDgu","twXOtKK","DhjPzxmGCMu","x2rLC3rYB3K","ChjVDg90Exa","yxzXuhi","B3PLELi","suzrAfe","BMfTzq","CwnetNy","x3DZ","BvvXquW","Aw9U","z2v0sxrLBq","BhrPCgXLihq","BMnVzgLUzW","x29UtwvZC2e","zwDmrMC","zNjVBNrPzxi","y3ruAw1LB3u","DhLWzq","zxjFCw9Z","vLDwAxa","CNzHBfzHBhu","y0j3AMC","ELnhugW","ywDLrxzLBNq","qxH0Bfm","DKH1yui","C2vUzf9Hy2S","whHizKy","B25fCNjVCG","sK9euuy","CuTwEeC","B3DlBeK","vePbvfy","CM92AwrLihC","AenSB3nLrxy","qu5vy3C","y3jLyxrLt2i","BgvUz3rO","DMTcrwm","ENbPtMG","r0TiBMi","t2LLrfG","zvntD1e","yvrlD3m","s0PsAMm","CIb0DhDjra","zNfUwg4","y2HnyxHuCMK","wevoAwG","r0XMvhG","C29YDa","uuz3t00","DgHHBIbSB2m","DcbSAw1PDa","txznqNO","B25nzxnZywC","ALvAuuu","y2XLyxi","C3vIyxjYyxK","AMLZEMe","A2roDuC","Aw5PDcbrB1m","lcbOB3n0BMe","aaaaaaaaaaa","C0Xf","BxnN","z2u6ia","Eu1cr1a","DcbVzIbYyw4","mtq4mteYtfbzCvrQ","su5tvefova","DLvjC0G","y2XVC2veqG","B0LOAgW","rwflz2y","sLrry1O","CgXLyxnLiha","AxfHrMW","ruDHANi","DxbNCMfKzw4","x21LC3nHz2u","Aw9Ul2PZB24","uvLzCuW","tNjdu2W","ALjZEwC","uersq1K","y3vYC29Y","wNboA20","DezfDwC","sLDiBha","q1vZCu4","v0vZyuS","D2jRqKe","t0zJrwK","mhWZFdj8nhW","sNPPCge","wNfzvKW","y1nVB04","rgLst2u","zeXuBxy","C2nYAxb0","v1virfq","wLjYBxC","EhrfyMK","D2jdAhu","tvf2yuW","r1P2wu4","sezjs2S","Eg50svK","C1f4y2y","thLwDK8","C3rLBMvYCW","vej1teW","DLnUyKe","wwjvwfa","z2DgCKe","rvbIugK","ChPVwNC","y29UDgv4Da","vgLTzw91Da","x2DLBMvYyxq","zxq9DxrMltG","Ce5tzMe","uK5Vvwy","zNLlBw8","D1jUA3q","C0nVDw50zxi","CNziyw0","s3LJAum","zxfbseO","Cg9W","sgvUueS","yM9KEq","x2rLyNvN","Eu10r04","Cgu6ia","BujoEfO","ueHps2S","yKrkExa","u09Yt3q","uLbsr0e","EvHywNa","B1HuvK4","tNjSCfe","s3zvsuq","Aw5L","uMvHzcbWyxm","wfnXuxG","Cg9YvNu","DMfSDwvZ","BNrLCG","ueLcreC","x2DLDeLUDgu","BKf3wLy","x2LUDgvYDMe","tMv2rhC","x0vysvnu","rxrbzM8","t0z4Bhy","tu5zseG","C2fNzq","CujAv3G","weTTy2C","Aw5KzxG","C2vYDMLJzs0","t1bftG","C3bSAxq","yxnL","AgvKtwf4uMu","ihzHBgLKigq","EwvLsuC","zu9MB3m","BwfW","CLrOsLK","yMnfuhe","BNrfBMrWB2K","CMv0CNLdB3u","Dw5ZAwDUzwq","Dgv4DfbHEwW","D2TpEha","yvnvCwe","x2rYB3bhBg8","z2v0qwXSs2u","B3v0sw50zxi","BM93","tLjbywy","z2vtEw5J","zw50tgLZDgu","q29Kzq","Dg9oDw1Izxi","ENLkrfe","ysbTDxn0igi","D2fZq2XLyw4","Agv2shy","rK9Ws1e","CMvHC29U","vNPbz2e","tgTYsw8","Eg9Au0S","D3jPDgvvAw4","y3jLyxrLtwu","mdaWma","tefVvMO","EeLhsNG","Dw50","zxL1A00","x3bYzwzPEa","yxnJCMLWDa","DeLfyM0","z3f1Agu","zNjTA1u","zw50zwqGDhK","tenqyMS","x2fKzfDZtgK","sMvsuwC","DeLUDgvYy2u","Eej5sgO","CM92AwrLigi","uw5OELy","AKHhrNa","CfL3uM0","DMvUDa","EwP4C3y","Dg9cExrLC0W","qw1VDw50","BeXfC3u","y0jsv0K","qwjVCNrfCNi","C3rVCcbPBw0","yKPxtfO","vvj3Ew8","vgfN","EfrZC28","t0rbBgK","ywr2yw5Jzq","qwv6A0m","BwLUzW","zw5JB2rPBMC","zMrzBwi","ywnR","EfbLENC","Ew9ODfa","y3jLyxrLrxi","v1rSEue","C0HYuem","r0PRDNy","y2DmvLO","BwfUDwfSihi","AxrrDwS","y3vYCMvUDeu","Bwf4twvZC2e","wfrVELG","z2zdzhG","vvHNDLO","DhjHBNnHy3q","yMXVy2TLza","ENH0u0u","zgvMAw5Luhi","DMXyy0i","EuTUzxu","CuviEgm","AevYCM9Yrxy","BhrLEhK","zenIzfy","re9Qzw4","Bwf4uMv0CMK","zufJAW","BvDXvKG","ExbL","uKLJyu8","y3vZDg9Tshq","zhrPCvG","Cg9PBNrdB24","y0LlAhK","B2v5wMG","DgLXsva","s2HNswy","DNzssLC","Eu5IvLu","D3Lcq24","y09Wzw4","C0LtD3q","EuXMELy","yuD2B0G","swToqvG","A1n0yxr1C0m","ALjgAum","Cgf5Bg9Hzfq","zxjYtxnN","CMvZB2X2zq","z2v0qwXS","v2TKDgy","Bg9IywXty28","zeviqxm","y2HLy2TdDxi","BxnNsuq","sLrwAxi","ze51D3i","CM5mswC","CMvWBgfJzui","B2r3wMS","wvDYC1K","EuPuzue","x1fVu01HBMe","zfjnrw4","zK9pzhe","q0TbyxK","CLj1Bxq","CxnXCui","uwvfEge","Ahr0Chm6","AKvntKO","ELHeuLC","wgrRvhm","wxvzugi","EfD2Avi","Be9ctKO","A0fbqKq","yM9L","zg11ufO","zNjHBwvuExa","nxW0Fda","Bg5vy2C","ywrrwKi","ywWGy3vYC28","yxv0BW","uwvNuNi","D3fArfm","ihjLy29UBMu","CKnpDNC","zMLSzw5HBwu","x2XPC3rLBMu","CNzHBa","BMrWB2LUDfq","y3nlELC","CNPwCxy","Chv0","AM1YDMm","nxWXFdj8nhW","ChnqA0y","zMzLCG","B3nLza","suf1z2S","BKrssNO","Aw5KzxHpzG","CfrkEhm","ywDLu2HVDW","lcbTyxGGCMu","zMzmAw5L","DLnywxy","uMvJB25Uzwm","twvZC2fNzuu","tuzqsu0","x29UvgLTzw8","Dg9VigXHCMC","lcbxzwjtB2m","wuXnr1K","x29UugfNzu4","y29TCgXLDgu","ALbZDNK","qMrIv0e","zKrXEuS","z3zXuva","rLrkEfa","Cgroyvy","zMvY","CKnovuK","zxHzvwW","Eu1LtvG","BwPPDvq","AKDkwuO","AwfLENy","vNvxBKK","uhfPy0O","CgjICdi","shr2uw8","tMfTzq","AKrWvw4","z0TvuKm","DKfvshu","zu5rCg8","x2nVBM5Ly3q","C2DTCeS","EfvUy1G","ig1LC3nHz2u","A0rIyxu","DKn6z28","z2nvDvm","CezAt3q","C2vUza","v2vIu29JA2u","rxzLBNq","CMfUzg9T","x2rPC3bHDgm","rKzAALG","zw50","CfbiBfy","Ae1LC3nHz2u","z1vUr2K","C2v0q3vYC28","Dgv4Dc9WBge","CMLLC0nVDw4","yNL0zxm","zM9YrwfJAa","CNvJruG","DMfSDwu","Bg1xsuS","FdeWFdz8nxW","DMXZzMS","DuzMze0","rwXYrKy","yNrcwxm","wMnzteK","BgLUzq","C1fLCha","DgvmB2Djre4","EsbJBg9Zzwq","CMPxBxu","EhDMCg4","q01wvvq","DMjvD1u","x3jLBw92zvC","CgLUz09Uy2u","Bwv0Ag9K","yxbWzw5Kq2G","CNnVCL9Uyw0","x2HHBMrSzva","BML0AwfSAxO","AwXLtMfTzq","zxjFCw9Zx2e","q3bQvKm","ywz5zuG","Aun6sgO","v1PTwvO","yMrFzgLK","Dg9cExrLCW","u2vXsuq","sxzQueW","uxnqrvu","shDIEvi","z2v0q3vYC28","uwPqzNu","q1D2D0e","swDlqMe","D01qC0e","C0XPC3rLBMu","rvjNC1a","C2vUDa","ywXS","vMPJzvi","Bu5iq08","C1DOALy","B2LUDfjLywm","B25TzxnZywC","yKTSAfC","r0zcrgO","yKHuq00","A2Pnzxu","x29UrxjYB3i","yxnZAwDU","t3voDwC","rNvnrfm","AgvYBMC","B3bLBG","tgLZDgvUzxi","rvjVsLy","x2rItMfTzq","EKfjAwC","ChvZAa","yNnRy0i","Eu9mv1G","ug9RquK","x2LZsw5PDa","z2zstuK","rvjRzgq","A3jltuu","CxD3tgy","wxbMD3q","Dhr3Awq","C0zYAKC","q1DcteK","yKTsuMS","Cw9Zx18","BeLJEKC","uxHdwfi","BMDLza","twLZC2LUzYa","zhrJA0C","zxHWB3j0CW","r0nryKO","Bevdtxi","ywnOzwq","zv90Aw1LB3u","y3jLyxrLt3a","r0fZBfq","CMTLCKDSB2i","yMfSrxzLBNq","zw5KCg9PBNq","sMTorLe","rLjptLrjrvi","vLPlA2K","qurTtvq","qMfbvvy","uwHyzM0","Dw5RBM93BIa","z29PBMCGyxC","D0rKC2G","t3bLBKv2zw4","mtb8mhW2Fdq","BNruCMLLC0m","z2vY","B2zMC2v0","wu1RyMm","tu5VEKK","tLnOChm","DNLAyxi","zw5fDMvUDa","x2nSzwfYugK","reTvzuC","zMHds3e","C2v0","vgvprwq","BKzrqwq","B3L1ELC","y3jLyxrLuMu","uNHmBeu","ANHNqvq","AM9PBG","m3WW","ihrPBwvVDxq","y2f4D1C","y291BNq","BgnSrMu","DgHLBG","uM5KugG","AeDJCwi","twDzzeu","uxrVA1C","A0TND1C","v2vPEgLUsLm","thzntMG","x2nYzwf0zvm","DefLwK4","CKjoA2y","s2j0zhG","x194x21Zz18","y2HnyxHdB3u","thrQBgK","EuTqse4","v0jHzwi","zg5Rq0y","CMfNzvn5BMm","Efrurw52","ChjVDg9JB2W","z2v0t3DUuhi","mte4mZG2m29QseDgAa","Exrfq3a","y29Uy2f0","B3bLBIa","ufHszNu","De1HBMfNzxi","B3jRig9MzMW","zfrLAKC","yNnMvMO","z2vjBMzVu3K","EMXxqMe","z2vrDwv1zuW","v2nzt2G","ywDLsgLKzq","B1DQzhm","C2XPy2u","BeT3Bxe","y2LOEee","CgLUz0LUDgu","svDwz3i","ntm1mtaXnxzuuuryBq","DxDdrxq","yxv0B21HDgK","CMvZzxrdB3u","Aw5KzxGGB3u","rLPIAhK","rvD2Dvq","zcWG","C01Qq0m","ywXPzcb1CMW","uxrrsK8","D3zIrhu","rwfMCKq","ywjVCNq","x21PBMLoyxy","uKTdr3a","rLjzCgq","Au5mwNC","yxbwCwm","BMrWB2LUDca","y29UC3rYDwm","vwvJvfy","tKLqyxq","DxbtsvG","z2v0u3rVCMe","ywrKrxzLBNq","q291BNq","wvbgvgm","refKwvC","CxHMAMi","zgLZywjSzue","BLHHDva","FdD8mNW5","rvPQzfy","AxnrB1nby2S","Bg93","ueH4vNC","v2P0A08","rvjst1i","x2n1CNnVCK4","whHlENC","yLflBKq","yxrHlcbKyxq","zgvIDwC","t0HHvey","ueDVuMq","refVCeG","zxjFDhrS","yw1Lu3bHy2u","D1vJwMu","B2jQzwn0u3q","EunUC2u","uhPcCva","qvPfv1u","B2zMBgLUzq","Aw5N","zMHkCfi","B1fyuee","qNHrCLK","zcbLCNjVCI4","ExnQzLO","ywrKq291BNq","rMXrvxy","yvvqEvC","AxnbCNjHEq","x2HHBMrSzu8","zKjjr1y","D0n2svO","A3HJu3m","Bhm6ia","Evjzs0u","nhWYFdb8mxW","yvHpvuy","txDete8","u2vYDMLJzvC","tKDFrvjst1i","re1oBu4","DxrVuMvJB24","Ae9Wzw5fDMu","sNzNyKC","y0HRCNG","quvdt2K","zxrxB3jRq2G","B25szwnLAxy","zwHdt2q","x3nLBMrby2S","zw5XDwv1zq","se5LCuK","DMDyyMy","Ee1cv2u","Ec1TC2CTCw8","rhbvuhK","C2DPza","y3jLyxrLq2W","tu9YBwO","rNzWs0y","BwHZu2u","rvjdC3u","B2XKvMvYC2K","rwjly0W","A09psMu","uNvhv0m","t1bftL9fuLi","BMCGzMfPBgu","D0PYCeq","uNjHv2O","tez6Bg8","r2nxAgG","wfLyBgi","sKDZrxi","ChjUA2y","Dhnoz1e","x2LZtwLUAvq","x29Ut3bLBG","zw1wuwO","x2LUAxrhBg8","x3nLCuLK","q2fIB1e","CMvJB25Uzwm","C3rVCMu","x29WDgLVBNm","x0rctMfTzq","tMHoA0q","zgvSzxrL","Au12EfC","BM9Uzv9UB24","DgLTzw91Da","AuvXqKi","ENnwCNu","qM5mBeu","q3vZDg9Trxi","x2LUAxq","Dg1OB2W","A1vYBey","y21bteW","BwPhDxy","t09Ytee","Dg9hzw5LCMe","t0LTENq","uvf4quG","Eujqu0m","AenZteS","zxjFywnRx20","AKvJrxa","r3Htrfq","v0DJEu4","yK5Xy24","tKfusvzfx0u","vfjjA2e","B2fK","mNW0Fdb8nxW","zxjHDg9Y","Bg5LvfK","seXKwg8","y29UDgLUDwu","DeXwzhu","zfnSy1i","B0DlrwC","AvLczMO","CYbHBhjLywq","rvrArue","qwvZD2e","AgvfB20","zxjYB3i","seDktfO","rM55vLO","rNvbswe","q3jJALy","Dg9mB3DLCKm","u0vAwuC","u3rNExi","zw5HyMXLuw8","B25tDgfYDfi","sNLfDMS","yMLUza","thbny1u","Du5qwhK","BMnLq2XVC2u","AgfUz2u","yNzqEu8","yxbWBgLJyxq","y2HHCKnVzgu","B3nLrxzLBNq","B25SAw5L","vNPvvfm","vfrOuLq","AK9zu1O","CMvZzxrfBMq","AxmGDw5Kzwy","sM5vENq","s0TNCeS","A2v5","vLPUBwi","rxjYB3jdB2q","uMzkD3m","Dg9iyxnO","BvvxBfy","vwPHyK0","C3vJy2vZCW","AfDXBNK","B3jLtMfTzxm","quXm","rvvXshC","BuPpAhy","A0ziwLa","Aw5JBhvKzxm","yw1LoIa","we9Mqxy","yNzpre8","v0LWvuW","qK1gugq","C3bSAwnL","wNP3C3i","EgTiCwq","z01jELC","igzPzwXKoIa","zMLN","D2DuuK8","ru9qr0O","zxj2AwnL","BMCGB3iGyw4","ufPkveO","vxbKyxrLq28","Ef9MCM9UDgK","DxDuquW","CK1bDwO","r0X0sM8","tLzAsui","vgL6Bfu","z2frrvG","rgPNrgq","BMDuAw1LCG","y3vYC29Yx24","vxnJAuC","uwDlDgu","B1HHC1m","BKXPBMu","vxHKq0S","BNLoteK","Exnov1O","AgfZ","zgrjrcWGzgu","x3nVy2TLDa","Egv1BgS","CgLUz19VBMm","se5ICMu","AxnmB25N","qvH1ywi","CgvYC2LZDgu","y0DKq1u","sg53thu","BMvY","wfLcv3e","u0zJy20","zMPrwKK","uwHwCuG","Dev2zw50","AxnFywnR","r2LcrhK","tgjQDuS","DwDuse4","quvize4","ugTKBNK","B25ozxr3B3i","tMD5CKe","EvDNq0C","thPbAfm","zKz6wuO","zxjFBxnNAwq","q3DNBNu","EwXKq0O","y29UBMvJDa","AwXLx25HBwu","D3fquLK","qKfWCgu","DgvZDa","uhPRBhi","wLbvve0","B25dBg9Zzq","v2Dmrw0","wvvQzei","mhWXFdn8mte","ywrK","Aw9UvgLTzw8","zhHwC2m","AMXzueu","yuT4tM0","rvfssge","DhfxqMW","Dwr5A0q","Du9gEwS","DMrIwLC","A2PvqNC","x2LZv29YA2u","Evv2qvm","rLDt","ANDREKq","BNvTyMvY","vfPNAuS","Aw47y2HHCNm","CgfNzwHPzgu","y2XVC2uSihC","AgfZt3DUuhi","qMHLDLa","qwHhtfG","BIWGAg9ZDg4","y2fSBa","zNDjrMW","DuTUCum","D3zpC2W","DeLK","vuDSve4","jMPZy2fSBgi","BM5Ly3q","yw5ZzM9YBvq","B3bLCNr5","B2HeBLu","AMXrr1O","Agr6C0W","zgLZCgf0y2G","rfrzzha","Cg9VB3e","zMLSDgvY","sgXuCMq","wgD6t00","ALfrAfu","x2LZtwLUAvC","vuHyv0K","rKXeDeS","x25HDMLNyxq","AgLNAa","wgXSqvG","BgzMq0q","CxngtMC","uKvZEey","sgTdwM0","tg9JAW","tvHwsMC","x2rPC2nVBM4","z2v0","ywzL","t0zwru0","B25JBg9Zzq","uLvrzg0","vKjwzxm","x3vYBa","x3bPBMDqB24","Aej4z1G","zgXiwfC","txHMvw8","teLfr0e","AwnmCuS","x2TLEvbHDgG","Dg9cExrLC0i","CMPwsg0","CM92AwrLige","uND0vgO","y2XVC2u","reiGzMfPBgu","DxjS","ufHQy0C","y0fQug8","q3bUtfq","wLnmrNa","C2vYDMLJzq","D2nRD2q","BwvZC2fNzq","wgnbruK","ENLmBKC","DfjKBgm","y29UBMvJDfm","CNnVCKzPBgu","C2P2BNG","zMXVB3i","B2XiCNG","CMvKDwnL","yNbru1u","ENfXyK0","x2zVCM1HDeu","ug54z2m","wKrUzuK","yNL0zu9MzNm","zgfHELm","vw5PBxbSzw0","tw9KDwXL","Ahr0Ca","ywnRx2nVzgu","ANjRB1a","zNjVBunOyxi","D1jHEg0","q3vZDg9Tq2W","BNrbBMrvCgq","uxzgzMO","Dxrjza","u0PMuxC","x2LZqNjVD3m","EfvKsNi","DhPIs3e","q0Xpu0LorW","uhjPBwfYEuS","Cgf5Bg9Hzeu","v2LUzg93","C2vYDMvYvgK","q09otKvdveK","AhH0A1a","r1ftDLG","y3vYDMfSDwu","Dw5KzwzPBMu","y3vYC29Yx2y","DxvMr0S","qwzRu2W","qufyBLG","DhjPzxm","x2jPBMfYEvq","zNL2Ahi","qKzZCxO","A2v0ignVBNm","DgjJqxi","yMLUyxj5vhK","sen1sNu","zxH0ugf5Bg8","tKX5tNa","B25pCgvU","DhjPBq","DxnLCKLW","BgLTAxq","DwrQse8","u29MAfK","sNffD1u","EwvgEgq","Aw5zB1i","A0TQwhq","tg9Nsuq","zfPpr3i","C2v0sxrLBq","u0nqB3G","Dfjqzei","vevtCKe","z25KAxu","z2nQuuG","x3DZsw5ZDge","D3jPDgu","r2Dhveu","r1LRsvK","sgHPANC","uNnlDeC","BeHHBMrSzxi","Axnby2TdBgu","zM9Yy2u","C3rYAw5NAwy","Cgf5Bg9Hza","ENjMAuq","z0neEfi","ywXSq3vYC28","qNjPzgDL","CMvZDwX0","qxj2AuO","zw5NDgG","B0DmCfC","y2HLy2Tszwe","CgLUz0XVC3m","zxjYtM8","q2HOsK0","BxbluvK","ALfMDha","C3jJ","wgvHvLy","DgLUzYbZzxi","BfrPBwvVDxq","CgfNzxnOB3C","D0rzrLa","sNroAg8","uuLcEMW","B2nRzxq","D2PAD2m","qvDTC2q","yxKSihrYEsa","x2LZtM9Kzq","Cu9ptve","x2n1CNnVCKy","BwLZzq","t2Ltz0u","uLLpBKO","DhjtANi","B3nYzwW","qxzpv0y","sxvvtxu","CMvUDevUzha","r21QEhi","teDtsgS","CNPewxe","uufhExm","uvP3wuK","vgr3t2O","zw1PDa","zhnNsva","B0vYtfK","B3jpBMXPBMu","EffUvvy","y29UBMvJDgK","AKDfEMi","CNLxwMy","B09yzK0","u1jnzMW","EvDOsMC","y29Kzq","x29Uq2XVC2u","AwLXvgG","v3bgz1i","y2ffCfm","DwPlCgG","EvjLy29UBMu","r2zmrKS","thn5CKK","sM5srKW","Bwf4tg9ZC0m","DMLJzuLeig8","C3nHz2vfDMu","wwHPuuu","z3LkrgG","zg9Uzq","renzwfK","shfiAKS","yw9PBxm"];return Kn=function(){return n},Kn()}var Mn;Object[A(673)+A(1306)](X,A(1552)+"le",{value:!0})});var He=fe((Zp,ko)=>{"use strict";var Io=["nodebuffer","arraybuffer","fragments"],Po=typeof Blob<"u";Po&&Io.push("blob");ko.exports={BINARY_TYPES:Io,CLOSE_TIMEOUT:3e4,EMPTY_BUFFER:Buffer.alloc(0),GUID:"258EAFA5-E914-47DA-95CA-C5AB0DC85B11",hasBlob:Po,kForOnEventAttribute:Symbol("kIsForOnEventAttribute"),kListener:Symbol("kListener"),kStatusCode:Symbol("status-code"),kWebSocket:Symbol("websocket"),NOOP:()=>{}}});var Yt=fe((Qp,Gn)=>{"use strict";var{EMPTY_BUFFER:Kd}=He(),jr=Buffer[Symbol.species];function Gd(n,e){if(n.length===0)return Kd;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 jr(s.buffer,s.byteOffset,o):s}function To(n,e,s,o,c){for(let d=0;d<c;d++)s[o+d]=n[d]^e[d&3]}function Do(n,e){for(let s=0;s<n.length;s++)n[s]^=e[s&3]}function Wd(n){return n.length===n.buffer.byteLength?n.buffer:n.buffer.slice(n.byteOffset,n.byteOffset+n.length)}function Jr(n){if(Jr.readOnly=!0,Buffer.isBuffer(n))return n;let e;return n instanceof ArrayBuffer?e=new jr(n):ArrayBuffer.isView(n)?e=new jr(n.buffer,n.byteOffset,n.byteLength):(e=Buffer.from(n),Jr.readOnly=!1),e}Gn.exports={concat:Gd,mask:To,toArrayBuffer:Wd,toBuffer:Jr,unmask:Do};if(!process.env.WS_NO_BUFFER_UTIL)try{let n=V("bufferutil");Gn.exports.mask=function(e,s,o,c,d){d<48?To(e,s,o,c,d):n.mask(e,s,o,c,d)},Gn.exports.unmask=function(e,s){e.length<32?Do(e,s):n.unmask(e,s)}}catch{}});var Lo=fe((em,No)=>{"use strict";var Ro=Symbol("kDone"),Vr=Symbol("kRun"),$r=class{constructor(e){this[Ro]=()=>{this.pending--,this[Vr]()},this.concurrency=e||1/0,this.jobs=[],this.pending=0}add(e){this.jobs.push(e),this[Vr]()}[Vr](){if(this.pending!==this.concurrency&&this.jobs.length){let e=this.jobs.shift();this.pending++,e(this[Ro])}}};No.exports=$r});var Pt=fe((tm,zo)=>{"use strict";var Xt=V("zlib"),Oo=Yt(),jd=Lo(),{kStatusCode:Bo}=He(),Jd=Buffer[Symbol.species],Vd=Buffer.from([0,0,255,255]),jn=Symbol("permessage-deflate"),Ke=Symbol("total-length"),Ct=Symbol("callback"),Qe=Symbol("buffers"),It=Symbol("error"),Wn,Yr=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,!Wn){let s=this._options.concurrencyLimit!==void 0?this._options.concurrencyLimit:10;Wn=new jd(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[Ct];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){Wn.add(c=>{this._decompress(e,s,(d,f)=>{c(),o(d,f)})})}compress(e,s,o){Wn.add(c=>{this._compress(e,s,(d,f)=>{c(),o(d,f)})})}_decompress(e,s,o){let c=this._isServer?"client":"server";if(!this._inflate){let d=`${c}_max_window_bits`,f=typeof this.params[d]!="number"?Xt.Z_DEFAULT_WINDOWBITS:this.params[d];this._inflate=Xt.createInflateRaw({...this._options.zlibInflateOptions,windowBits:f}),this._inflate[jn]=this,this._inflate[Ke]=0,this._inflate[Qe]=[],this._inflate.on("error",Yd),this._inflate.on("data",Mo)}this._inflate[Ct]=o,this._inflate.write(e),s&&this._inflate.write(Vd),this._inflate.flush(()=>{let d=this._inflate[It];if(d){this._inflate.close(),this._inflate=null,o(d);return}let f=Oo.concat(this._inflate[Qe],this._inflate[Ke]);this._inflate._readableState.endEmitted?(this._inflate.close(),this._inflate=null):(this._inflate[Ke]=0,this._inflate[Qe]=[],s&&this.params[`${c}_no_context_takeover`]&&this._inflate.reset()),o(null,f)})}_compress(e,s,o){let c=this._isServer?"server":"client";if(!this._deflate){let d=`${c}_max_window_bits`,f=typeof this.params[d]!="number"?Xt.Z_DEFAULT_WINDOWBITS:this.params[d];this._deflate=Xt.createDeflateRaw({...this._options.zlibDeflateOptions,windowBits:f}),this._deflate[Ke]=0,this._deflate[Qe]=[],this._deflate.on("data",$d)}this._deflate[Ct]=o,this._deflate.write(e),this._deflate.flush(Xt.Z_SYNC_FLUSH,()=>{if(!this._deflate)return;let d=Oo.concat(this._deflate[Qe],this._deflate[Ke]);s&&(d=new Jd(d.buffer,d.byteOffset,d.length-4)),this._deflate[Ct]=null,this._deflate[Ke]=0,this._deflate[Qe]=[],s&&this.params[`${c}_no_context_takeover`]&&this._deflate.reset(),o(null,d)})}};zo.exports=Yr;function $d(n){this[Qe].push(n),this[Ke]+=n.length}function Mo(n){if(this[Ke]+=n.length,this[jn]._maxPayload<1||this[Ke]<=this[jn]._maxPayload){this[Qe].push(n);return}this[It]=new RangeError("Max payload size exceeded"),this[It].code="WS_ERR_UNSUPPORTED_MESSAGE_LENGTH",this[It][Bo]=1009,this.removeListener("data",Mo),this.reset()}function Yd(n){if(this[jn]._inflate=null,this[It]){this[Ct](this[It]);return}n[Bo]=1007,this[Ct](n)}});var kt=fe((nm,Jn)=>{"use strict";var{isUtf8:Fo}=V("buffer"),{hasBlob:Xd}=He(),Zd=[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 Qd(n){return n>=1e3&&n<=1014&&n!==1004&&n!==1005&&n!==1006||n>=3e3&&n<=4999}function Xr(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 eu(n){return Xd&&typeof n=="object"&&typeof n.arrayBuffer=="function"&&typeof n.type=="string"&&typeof n.stream=="function"&&(n[Symbol.toStringTag]==="Blob"||n[Symbol.toStringTag]==="File")}Jn.exports={isBlob:eu,isValidStatusCode:Qd,isValidUTF8:Xr,tokenChars:Zd};if(Fo)Jn.exports.isValidUTF8=function(n){return n.length<24?Xr(n):Fo(n)};else if(!process.env.WS_NO_UTF_8_VALIDATE)try{let n=V("utf-8-validate");Jn.exports.isValidUTF8=function(e){return e.length<32?Xr(e):n(e)}}catch{}});var ni=fe((rm,jo)=>{"use strict";var{Writable:tu}=V("stream"),Uo=Pt(),{BINARY_TYPES:nu,EMPTY_BUFFER:qo,kStatusCode:ru,kWebSocket:iu}=He(),{concat:Zr,toArrayBuffer:su,unmask:ou}=Yt(),{isValidStatusCode:au,isValidUTF8:Ho}=kt(),Vn=Buffer[Symbol.species],ve=0,Ko=1,Go=2,Wo=3,Qr=4,ei=5,$n=6,ti=class extends tu{constructor(e={}){super(),this._allowSynchronousEvents=e.allowSynchronousEvents!==void 0?e.allowSynchronousEvents:!0,this._binaryType=e.binaryType||nu[0],this._extensions=e.extensions||{},this._isServer=!!e.isServer,this._maxPayload=e.maxPayload|0,this._skipUTF8Validation=!!e.skipUTF8Validation,this[iu]=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=ve}_write(e,s,o){if(this._opcode===8&&this._state==ve)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 Vn(o.buffer,o.byteOffset+e,o.length-e),new Vn(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 Vn(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 ve:this.getInfo(e);break;case Ko:this.getPayloadLength16(e);break;case Go:this.getPayloadLength64(e);break;case Wo:this.getMask();break;case Qr:this.getData(e);break;case ei:case $n: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[Uo.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=Ko:this._payloadLength===127?this._state=Go: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=Wo:this._state=Qr}getMask(){if(this._bufferedBytes<4){this._loop=!1;return}this._mask=this.consume(4),this._state=Qr}getData(e){let s=qo;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&&ou(s,this._mask)}if(this._opcode>7){this.controlMessage(s,e);return}if(this._compressed){this._state=ei,this.decompress(s,e);return}s.length&&(this._messageLength=this._totalPayloadLength,this._fragments.push(s)),this.dataMessage(e)}decompress(e,s){this._extensions[Uo.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 f=this.createError(RangeError,"Max payload size exceeded",!1,1009,"WS_ERR_UNSUPPORTED_MESSAGE_LENGTH");s(f);return}this._fragments.push(d)}this.dataMessage(s),this._state===ve&&this.startLoop(s)})}dataMessage(e){if(!this._fin){this._state=ve;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=Zr(o,s):this._binaryType==="arraybuffer"?c=su(Zr(o,s)):this._binaryType==="blob"?c=new Blob(o):c=o,this._allowSynchronousEvents?(this.emit("message",c,!0),this._state=ve):(this._state=$n,setImmediate(()=>{this.emit("message",c,!0),this._state=ve,this.startLoop(e)}))}else{let c=Zr(o,s);if(!this._skipUTF8Validation&&!Ho(c)){let d=this.createError(Error,"invalid UTF-8 sequence",!0,1007,"WS_ERR_INVALID_UTF8");e(d);return}this._state===ei||this._allowSynchronousEvents?(this.emit("message",c,!1),this._state=ve):(this._state=$n,setImmediate(()=>{this.emit("message",c,!1),this._state=ve,this.startLoop(e)}))}}controlMessage(e,s){if(this._opcode===8){if(e.length===0)this._loop=!1,this.emit("conclude",1005,qo),this.end();else{let o=e.readUInt16BE(0);if(!au(o)){let d=this.createError(RangeError,`invalid status code ${o}`,!0,1002,"WS_ERR_INVALID_CLOSE_CODE");s(d);return}let c=new Vn(e.buffer,e.byteOffset+2,e.length-2);if(!this._skipUTF8Validation&&!Ho(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=ve;return}this._allowSynchronousEvents?(this.emit(this._opcode===9?"ping":"pong",e),this._state=ve):(this._state=$n,setImmediate(()=>{this.emit(this._opcode===9?"ping":"pong",e),this._state=ve,this.startLoop(s)}))}createError(e,s,o,c,d){this._loop=!1,this._errored=!0;let f=new e(o?`Invalid WebSocket frame: ${s}`:s);return Error.captureStackTrace(f,this.createError),f.code=d,f[ru]=c,f}};jo.exports=ti});var si=fe((sm,$o)=>{"use strict";var{Duplex:im}=V("stream"),{randomFillSync:cu}=V("crypto"),Jo=Pt(),{EMPTY_BUFFER:xu,kWebSocket:du,NOOP:uu}=He(),{isBlob:Tt,isValidStatusCode:fu}=kt(),{mask:Vo,toBuffer:ot}=Yt(),be=Symbol("kByteLength"),lu=Buffer.alloc(4),Yn=8*1024,at,Dt=Yn,Ce=0,gu=1,hu=2,ri=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=Ce,this.onerror=uu,this[du]=void 0}static frame(e,s){let o,c=!1,d=2,f=!1;s.mask&&(o=s.maskBuffer||lu,s.generateMask?s.generateMask(o):(Dt===Yn&&(at===void 0&&(at=Buffer.alloc(Yn)),cu(at,0,Yn),Dt=0),o[0]=at[Dt++],o[1]=at[Dt++],o[2]=at[Dt++],o[3]=at[Dt++]),f=(o[0]|o[1]|o[2]|o[3])===0,d=6);let l;typeof e=="string"?(!s.mask||f)&&s[be]!==void 0?l=s[be]:(e=Buffer.from(e),l=e.length):(l=e.length,c=s.mask&&s.readOnly&&!f);let m=l;l>=65536?(d+=8,m=127):l>125&&(d+=2,m=126);let w=Buffer.allocUnsafe(c?l+d:d);return w[0]=s.fin?s.opcode|128:s.opcode,s.rsv1&&(w[0]|=64),w[1]=m,m===126?w.writeUInt16BE(l,2):m===127&&(w[2]=w[3]=0,w.writeUIntBE(l,4,6)),s.mask?(w[1]|=128,w[d-4]=o[0],w[d-3]=o[1],w[d-2]=o[2],w[d-1]=o[3],f?[w,e]:c?(Vo(e,o,w,d,l),[w]):(Vo(e,o,e,0,l),[w,e])):[w,e]}close(e,s,o,c){let d;if(e===void 0)d=xu;else{if(typeof e!="number"||!fu(e))throw new TypeError("First argument must be a valid error code number");if(s===void 0||!s.length)d=Buffer.allocUnsafe(2),d.writeUInt16BE(e,0);else{let l=Buffer.byteLength(s);if(l>123)throw new RangeError("The message must not be greater than 123 bytes");d=Buffer.allocUnsafe(2+l),d.writeUInt16BE(e,0),typeof s=="string"?d.write(s,2):d.set(s,2)}}let f={[be]:d.length,fin:!0,generateMask:this._generateMask,mask:o,maskBuffer:this._maskBuffer,opcode:8,readOnly:!1,rsv1:!1};this._state!==Ce?this.enqueue([this.dispatch,d,!1,f,c]):this.sendFrame(n.frame(d,f),c)}ping(e,s,o){let c,d;if(typeof e=="string"?(c=Buffer.byteLength(e),d=!1):Tt(e)?(c=e.size,d=!1):(e=ot(e),c=e.length,d=ot.readOnly),c>125)throw new RangeError("The data size must not be greater than 125 bytes");let f={[be]:c,fin:!0,generateMask:this._generateMask,mask:s,maskBuffer:this._maskBuffer,opcode:9,readOnly:d,rsv1:!1};Tt(e)?this._state!==Ce?this.enqueue([this.getBlobData,e,!1,f,o]):this.getBlobData(e,!1,f,o):this._state!==Ce?this.enqueue([this.dispatch,e,!1,f,o]):this.sendFrame(n.frame(e,f),o)}pong(e,s,o){let c,d;if(typeof e=="string"?(c=Buffer.byteLength(e),d=!1):Tt(e)?(c=e.size,d=!1):(e=ot(e),c=e.length,d=ot.readOnly),c>125)throw new RangeError("The data size must not be greater than 125 bytes");let f={[be]:c,fin:!0,generateMask:this._generateMask,mask:s,maskBuffer:this._maskBuffer,opcode:10,readOnly:d,rsv1:!1};Tt(e)?this._state!==Ce?this.enqueue([this.getBlobData,e,!1,f,o]):this.getBlobData(e,!1,f,o):this._state!==Ce?this.enqueue([this.dispatch,e,!1,f,o]):this.sendFrame(n.frame(e,f),o)}send(e,s,o){let c=this._extensions[Jo.extensionName],d=s.binary?2:1,f=s.compress,l,m;typeof e=="string"?(l=Buffer.byteLength(e),m=!1):Tt(e)?(l=e.size,m=!1):(e=ot(e),l=e.length,m=ot.readOnly),this._firstFragment?(this._firstFragment=!1,f&&c&&c.params[c._isServer?"server_no_context_takeover":"client_no_context_takeover"]&&(f=l>=c._threshold),this._compress=f):(f=!1,d=0),s.fin&&(this._firstFragment=!0);let w={[be]:l,fin:s.fin,generateMask:this._generateMask,mask:s.mask,maskBuffer:this._maskBuffer,opcode:d,readOnly:m,rsv1:f};Tt(e)?this._state!==Ce?this.enqueue([this.getBlobData,e,this._compress,w,o]):this.getBlobData(e,this._compress,w,o):this._state!==Ce?this.enqueue([this.dispatch,e,this._compress,w,o]):this.dispatch(e,this._compress,w,o)}getBlobData(e,s,o,c){this._bufferedBytes+=o[be],this._state=hu,e.arrayBuffer().then(d=>{if(this._socket.destroyed){let l=new Error("The socket was closed while the blob was being read");process.nextTick(ii,this,l,c);return}this._bufferedBytes-=o[be];let f=ot(d);s?this.dispatch(f,s,o,c):(this._state=Ce,this.sendFrame(n.frame(f,o),c),this.dequeue())}).catch(d=>{process.nextTick(pu,this,d,c)})}dispatch(e,s,o,c){if(!s){this.sendFrame(n.frame(e,o),c);return}let d=this._extensions[Jo.extensionName];this._bufferedBytes+=o[be],this._state=gu,d.compress(e,o.fin,(f,l)=>{if(this._socket.destroyed){let m=new Error("The socket was closed while data was being compressed");ii(this,m,c);return}this._bufferedBytes-=o[be],this._state=Ce,o.readOnly=!1,this.sendFrame(n.frame(l,o),c),this.dequeue()})}dequeue(){for(;this._state===Ce&&this._queue.length;){let e=this._queue.shift();this._bufferedBytes-=e[3][be],Reflect.apply(e[0],this,e.slice(1))}}enqueue(e){this._bufferedBytes+=e[3][be],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)}};$o.exports=ri;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 pu(n,e,s){ii(n,e,s),n.onerror(e)}});var ia=fe((om,ra)=>{"use strict";var{kForOnEventAttribute:Zt,kListener:oi}=He(),Yo=Symbol("kCode"),Xo=Symbol("kData"),Zo=Symbol("kError"),Qo=Symbol("kMessage"),ea=Symbol("kReason"),Rt=Symbol("kTarget"),ta=Symbol("kType"),na=Symbol("kWasClean"),Ge=class{constructor(e){this[Rt]=null,this[ta]=e}get target(){return this[Rt]}get type(){return this[ta]}};Object.defineProperty(Ge.prototype,"target",{enumerable:!0});Object.defineProperty(Ge.prototype,"type",{enumerable:!0});var ct=class extends Ge{constructor(e,s={}){super(e),this[Yo]=s.code===void 0?0:s.code,this[ea]=s.reason===void 0?"":s.reason,this[na]=s.wasClean===void 0?!1:s.wasClean}get code(){return this[Yo]}get reason(){return this[ea]}get wasClean(){return this[na]}};Object.defineProperty(ct.prototype,"code",{enumerable:!0});Object.defineProperty(ct.prototype,"reason",{enumerable:!0});Object.defineProperty(ct.prototype,"wasClean",{enumerable:!0});var Nt=class extends Ge{constructor(e,s={}){super(e),this[Zo]=s.error===void 0?null:s.error,this[Qo]=s.message===void 0?"":s.message}get error(){return this[Zo]}get message(){return this[Qo]}};Object.defineProperty(Nt.prototype,"error",{enumerable:!0});Object.defineProperty(Nt.prototype,"message",{enumerable:!0});var Qt=class extends Ge{constructor(e,s={}){super(e),this[Xo]=s.data===void 0?null:s.data}get data(){return this[Xo]}};Object.defineProperty(Qt.prototype,"data",{enumerable:!0});var mu={addEventListener(n,e,s={}){for(let c of this.listeners(n))if(!s[Zt]&&c[oi]===e&&!c[Zt])return;let o;if(n==="message")o=function(d,f){let l=new Qt("message",{data:f?d:d.toString()});l[Rt]=this,Xn(e,this,l)};else if(n==="close")o=function(d,f){let l=new ct("close",{code:d,reason:f.toString(),wasClean:this._closeFrameReceived&&this._closeFrameSent});l[Rt]=this,Xn(e,this,l)};else if(n==="error")o=function(d){let f=new Nt("error",{error:d,message:d.message});f[Rt]=this,Xn(e,this,f)};else if(n==="open")o=function(){let d=new Ge("open");d[Rt]=this,Xn(e,this,d)};else return;o[Zt]=!!s[Zt],o[oi]=e,s.once?this.once(n,o):this.on(n,o)},removeEventListener(n,e){for(let s of this.listeners(n))if(s[oi]===e&&!s[Zt]){this.removeListener(n,s);break}}};ra.exports={CloseEvent:ct,ErrorEvent:Nt,Event:Ge,EventTarget:mu,MessageEvent:Qt};function Xn(n,e,s){typeof n=="object"&&n.handleEvent?n.handleEvent.call(n,s):n.call(e,s)}});var Zn=fe((am,sa)=>{"use strict";var{tokenChars:en}=kt();function Oe(n,e,s){n[e]===void 0?n[e]=[s]:n[e].push(s)}function wu(n){let e=Object.create(null),s=Object.create(null),o=!1,c=!1,d=!1,f,l,m=-1,w=-1,v=-1,_=0;for(;_<n.length;_++)if(w=n.charCodeAt(_),f===void 0)if(v===-1&&en[w]===1)m===-1&&(m=_);else if(_!==0&&(w===32||w===9))v===-1&&m!==-1&&(v=_);else if(w===59||w===44){if(m===-1)throw new SyntaxError(`Unexpected character at index ${_}`);v===-1&&(v=_);let T=n.slice(m,v);w===44?(Oe(e,T,s),s=Object.create(null)):f=T,m=v=-1}else throw new SyntaxError(`Unexpected character at index ${_}`);else if(l===void 0)if(v===-1&&en[w]===1)m===-1&&(m=_);else if(w===32||w===9)v===-1&&m!==-1&&(v=_);else if(w===59||w===44){if(m===-1)throw new SyntaxError(`Unexpected character at index ${_}`);v===-1&&(v=_),Oe(s,n.slice(m,v),!0),w===44&&(Oe(e,f,s),s=Object.create(null),f=void 0),m=v=-1}else if(w===61&&m!==-1&&v===-1)l=n.slice(m,_),m=v=-1;else throw new SyntaxError(`Unexpected character at index ${_}`);else if(c){if(en[w]!==1)throw new SyntaxError(`Unexpected character at index ${_}`);m===-1?m=_:o||(o=!0),c=!1}else if(d)if(en[w]===1)m===-1&&(m=_);else if(w===34&&m!==-1)d=!1,v=_;else if(w===92)c=!0;else throw new SyntaxError(`Unexpected character at index ${_}`);else if(w===34&&n.charCodeAt(_-1)===61)d=!0;else if(v===-1&&en[w]===1)m===-1&&(m=_);else if(m!==-1&&(w===32||w===9))v===-1&&(v=_);else if(w===59||w===44){if(m===-1)throw new SyntaxError(`Unexpected character at index ${_}`);v===-1&&(v=_);let T=n.slice(m,v);o&&(T=T.replace(/\\/g,""),o=!1),Oe(s,l,T),w===44&&(Oe(e,f,s),s=Object.create(null),f=void 0),l=void 0,m=v=-1}else throw new SyntaxError(`Unexpected character at index ${_}`);if(m===-1||d||w===32||w===9)throw new SyntaxError("Unexpected end of input");v===-1&&(v=_);let E=n.slice(m,v);return f===void 0?Oe(e,E,s):(l===void 0?Oe(s,E,!0):o?Oe(s,l,E.replace(/\\/g,"")):Oe(s,l,E),Oe(e,f,s)),e}function _u(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(f=>f===!0?c:`${c}=${f}`).join("; ")})).join("; ")).join(", ")}).join(", ")}sa.exports={format:_u,parse:wu}});var nr=fe((dm,ma)=>{"use strict";var yu=V("events"),vu=V("https"),bu=V("http"),ca=V("net"),Su=V("tls"),{randomBytes:Eu,createHash:Au}=V("crypto"),{Duplex:cm,Readable:xm}=V("stream"),{URL:ai}=V("url"),et=Pt(),Cu=ni(),Iu=si(),{isBlob:Pu}=kt(),{BINARY_TYPES:oa,CLOSE_TIMEOUT:ku,EMPTY_BUFFER:Qn,GUID:Tu,kForOnEventAttribute:ci,kListener:Du,kStatusCode:Ru,kWebSocket:te,NOOP:xa}=He(),{EventTarget:{addEventListener:Nu,removeEventListener:Lu}}=ia(),{format:Ou,parse:Bu}=Zn(),{toBuffer:Mu}=Yt(),da=Symbol("kAborted"),xi=[8,13],We=["CONNECTING","OPEN","CLOSING","CLOSED"],zu=/^[!#$%&'*+\-.0-9A-Z^_`|a-z~]+$/,W=class n extends yu{constructor(e,s,o){super(),this._binaryType=oa[0],this._closeCode=1006,this._closeFrameReceived=!1,this._closeFrameSent=!1,this._closeMessage=Qn,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]),ua(this,e,s,o)):(this._autoPong=o.autoPong,this._closeTimeout=o.closeTimeout,this._isServer=!0)}get binaryType(){return this._binaryType}set binaryType(e){oa.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 Cu({allowSynchronousEvents:o.allowSynchronousEvents,binaryType:this.binaryType,extensions:this._extensions,isServer:this._isServer,maxPayload:o.maxPayload,skipUTF8Validation:o.skipUTF8Validation}),d=new Iu(e,this._extensions,o.generateMask);this._receiver=c,this._sender=d,this._socket=e,c[te]=this,d[te]=this,e[te]=this,c.on("conclude",qu),c.on("drain",Hu),c.on("error",Ku),c.on("message",Gu),c.on("ping",Wu),c.on("pong",ju),d.onerror=Ju,e.setTimeout&&e.setTimeout(0),e.setNoDelay&&e.setNoDelay(),s.length>0&&e.unshift(s),e.on("close",ga),e.on("data",tr),e.on("end",ha),e.on("error",pa),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[et.extensionName]&&this._extensions[et.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){pe(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())}),la(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||Qn,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||Qn,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[et.extensionName]||(c.compress=!1),this._sender.send(e||Qn,c,o)}terminate(){if(this.readyState!==n.CLOSED){if(this.readyState===n.CONNECTING){pe(this,this._req,"WebSocket was closed before the connection was established");return}this._socket&&(this._readyState=n.CLOSING,this._socket.destroy())}}};Object.defineProperty(W,"CONNECTING",{enumerable:!0,value:We.indexOf("CONNECTING")});Object.defineProperty(W.prototype,"CONNECTING",{enumerable:!0,value:We.indexOf("CONNECTING")});Object.defineProperty(W,"OPEN",{enumerable:!0,value:We.indexOf("OPEN")});Object.defineProperty(W.prototype,"OPEN",{enumerable:!0,value:We.indexOf("OPEN")});Object.defineProperty(W,"CLOSING",{enumerable:!0,value:We.indexOf("CLOSING")});Object.defineProperty(W.prototype,"CLOSING",{enumerable:!0,value:We.indexOf("CLOSING")});Object.defineProperty(W,"CLOSED",{enumerable:!0,value:We.indexOf("CLOSED")});Object.defineProperty(W.prototype,"CLOSED",{enumerable:!0,value:We.indexOf("CLOSED")});["binaryType","bufferedAmount","extensions","isPaused","protocol","readyState","url"].forEach(n=>{Object.defineProperty(W.prototype,n,{enumerable:!0})});["open","error","close","message"].forEach(n=>{Object.defineProperty(W.prototype,`on${n}`,{enumerable:!0,get(){for(let e of this.listeners(n))if(e[ci])return e[Du];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})}})});W.prototype.addEventListener=Nu;W.prototype.removeEventListener=Lu;ma.exports=W;function ua(n,e,s,o){let c={allowSynchronousEvents:!0,autoPong:!0,closeTimeout:ku,protocolVersion:xi[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,!xi.includes(c.protocolVersion))throw new RangeError(`Unsupported protocol version: ${c.protocolVersion} (supported versions: ${xi.join(", ")})`);let d;if(e instanceof ai)d=e;else try{d=new ai(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 f=d.protocol==="wss:",l=d.protocol==="ws+unix:",m;if(d.protocol!=="ws:"&&!f&&!l?m=`The URL's protocol must be one of "ws:", "wss:", "http:", "https:", or "ws+unix:"`:l&&!d.pathname?m="The URL's pathname is empty":d.hash&&(m="The URL contains a fragment identifier"),m){let R=new SyntaxError(m);if(n._redirects===0)throw R;er(n,R);return}let w=f?443:80,v=Eu(16).toString("base64"),_=f?vu.request:bu.request,E=new Set,T;if(c.createConnection=c.createConnection||(f?Uu:Fu),c.defaultPort=c.defaultPort||w,c.port=d.port||w,c.host=d.hostname.startsWith("[")?d.hostname.slice(1,-1):d.hostname,c.headers={...c.headers,"Sec-WebSocket-Version":c.protocolVersion,"Sec-WebSocket-Key":v,Connection:"Upgrade",Upgrade:"websocket"},c.path=d.pathname+d.search,c.timeout=c.handshakeTimeout,c.perMessageDeflate&&(T=new et({...c.perMessageDeflate,isServer:!1,maxPayload:c.maxPayload}),c.headers["Sec-WebSocket-Extensions"]=Ou({[et.extensionName]:T.offer()})),s.length){for(let R of s){if(typeof R!="string"||!zu.test(R)||E.has(R))throw new SyntaxError("An invalid or duplicated subprotocol was specified");E.add(R)}c.headers["Sec-WebSocket-Protocol"]=s.join(",")}if(c.origin&&(c.protocolVersion<13?c.headers["Sec-WebSocket-Origin"]=c.origin:c.headers.Origin=c.origin),(d.username||d.password)&&(c.auth=`${d.username}:${d.password}`),l){let R=c.path.split(":");c.socketPath=R[0],c.path=R[1]}let P;if(c.followRedirects){if(n._redirects===0){n._originalIpc=l,n._originalSecure=f,n._originalHostOrSocketPath=l?c.socketPath:d.host;let R=o&&o.headers;if(o={...o,headers:{}},R)for(let[z,ne]of Object.entries(R))o.headers[z.toLowerCase()]=ne}else if(n.listenerCount("redirect")===0){let R=l?n._originalIpc?c.socketPath===n._originalHostOrSocketPath:!1:n._originalIpc?!1:d.host===n._originalHostOrSocketPath;(!R||n._originalSecure&&!f)&&(delete c.headers.authorization,delete c.headers.cookie,R||delete c.headers.host,c.auth=void 0)}c.auth&&!o.headers.authorization&&(o.headers.authorization="Basic "+Buffer.from(c.auth).toString("base64")),P=n._req=_(c),n._redirects&&n.emit("redirect",n.url,P)}else P=n._req=_(c);c.timeout&&P.on("timeout",()=>{pe(n,P,"Opening handshake has timed out")}),P.on("error",R=>{P===null||P[da]||(P=n._req=null,er(n,R))}),P.on("response",R=>{let z=R.headers.location,ne=R.statusCode;if(z&&c.followRedirects&&ne>=300&&ne<400){if(++n._redirects>c.maxRedirects){pe(n,P,"Maximum redirects exceeded");return}P.abort();let j;try{j=new ai(z,e)}catch{let Z=new SyntaxError(`Invalid URL: ${z}`);er(n,Z);return}ua(n,j,s,o)}else n.emit("unexpected-response",P,R)||pe(n,P,`Unexpected server response: ${R.statusCode}`)}),P.on("upgrade",(R,z,ne)=>{if(n.emit("upgrade",R),n.readyState!==W.CONNECTING)return;P=n._req=null;let j=R.headers.upgrade;if(j===void 0||j.toLowerCase()!=="websocket"){pe(n,z,"Invalid Upgrade header");return}let me=Au("sha1").update(v+Tu).digest("base64");if(R.headers["sec-websocket-accept"]!==me){pe(n,z,"Invalid Sec-WebSocket-Accept header");return}let Z=R.headers["sec-websocket-protocol"],se;if(Z!==void 0?E.size?E.has(Z)||(se="Server sent an invalid subprotocol"):se="Server sent a subprotocol but none was requested":E.size&&(se="Server sent no subprotocol"),se){pe(n,z,se);return}Z&&(n._protocol=Z);let oe=R.headers["sec-websocket-extensions"];if(oe!==void 0){if(!T){pe(n,z,"Server sent a Sec-WebSocket-Extensions header but no extension was requested");return}let k;try{k=Bu(oe)}catch{pe(n,z,"Invalid Sec-WebSocket-Extensions header");return}let L=Object.keys(k);if(L.length!==1||L[0]!==et.extensionName){pe(n,z,"Server indicated an extension that was not requested");return}try{T.accept(k[et.extensionName])}catch{pe(n,z,"Invalid Sec-WebSocket-Extensions header");return}n._extensions[et.extensionName]=T}n.setSocket(z,ne,{allowSynchronousEvents:c.allowSynchronousEvents,generateMask:c.generateMask,maxPayload:c.maxPayload,skipUTF8Validation:c.skipUTF8Validation})}),c.finishRequest?c.finishRequest(P,n):P.end()}function er(n,e){n._readyState=W.CLOSING,n._errorEmitted=!0,n.emit("error",e),n.emitClose()}function Fu(n){return n.path=n.socketPath,ca.connect(n)}function Uu(n){return n.path=void 0,!n.servername&&n.servername!==""&&(n.servername=ca.isIP(n.host)?"":n.host),Su.connect(n)}function pe(n,e,s){n._readyState=W.CLOSING;let o=new Error(s);Error.captureStackTrace(o,pe),e.setHeader?(e[da]=!0,e.abort(),e.socket&&!e.socket.destroyed&&e.socket.destroy(),process.nextTick(er,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=Pu(e)?e.size:Mu(e).length;n._socket?n._sender._bufferedBytes+=o:n._bufferedAmount+=o}if(s){let o=new Error(`WebSocket is not open: readyState ${n.readyState} (${We[n.readyState]})`);process.nextTick(s,o)}}function qu(n,e){let s=this[te];s._closeFrameReceived=!0,s._closeMessage=e,s._closeCode=n,s._socket[te]!==void 0&&(s._socket.removeListener("data",tr),process.nextTick(fa,s._socket),n===1005?s.close():s.close(n,e))}function Hu(){let n=this[te];n.isPaused||n._socket.resume()}function Ku(n){let e=this[te];e._socket[te]!==void 0&&(e._socket.removeListener("data",tr),process.nextTick(fa,e._socket),e.close(n[Ru])),e._errorEmitted||(e._errorEmitted=!0,e.emit("error",n))}function aa(){this[te].emitClose()}function Gu(n,e){this[te].emit("message",n,e)}function Wu(n){let e=this[te];e._autoPong&&e.pong(n,!this._isServer,xa),e.emit("ping",n)}function ju(n){this[te].emit("pong",n)}function fa(n){n.resume()}function Ju(n){let e=this[te];e.readyState!==W.CLOSED&&(e.readyState===W.OPEN&&(e._readyState=W.CLOSING,la(e)),this._socket.end(),e._errorEmitted||(e._errorEmitted=!0,e.emit("error",n)))}function la(n){n._closeTimer=setTimeout(n._socket.destroy.bind(n._socket),n._closeTimeout)}function ga(){let n=this[te];if(this.removeListener("close",ga),this.removeListener("data",tr),this.removeListener("end",ha),n._readyState=W.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[te]=void 0,clearTimeout(n._closeTimer),n._receiver._writableState.finished||n._receiver._writableState.errorEmitted?n.emitClose():(n._receiver.on("error",aa),n._receiver.on("finish",aa))}function tr(n){this[te]._receiver.write(n)||this.pause()}function ha(){let n=this[te];n._readyState=W.CLOSING,n._receiver.end(),this.end()}function pa(){let n=this[te];this.removeListener("error",pa),this.on("error",xa),n&&(n._readyState=W.CLOSING,this.destroy())}});var va=fe((fm,ya)=>{"use strict";var um=nr(),{Duplex:Vu}=V("stream");function wa(n){n.emit("close")}function $u(){!this.destroyed&&this._writableState.finished&&this.destroy()}function _a(n){this.removeListener("error",_a),this.destroy(),this.listenerCount("error")===0&&this.emit("error",n)}function Yu(n,e){let s=!0,o=new Vu({...e,autoDestroy:!1,emitClose:!1,objectMode:!1,writableObjectMode:!1});return n.on("message",function(d,f){let l=!f&&o._readableState.objectMode?d.toString():d;o.push(l)||n.pause()}),n.once("error",function(d){o.destroyed||(s=!1,o.destroy(d))}),n.once("close",function(){o.destroyed||o.push(null)}),o._destroy=function(c,d){if(n.readyState===n.CLOSED){d(c),process.nextTick(wa,o);return}let f=!1;n.once("error",function(m){f=!0,d(m)}),n.once("close",function(){f||d(c),process.nextTick(wa,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,f){if(n.readyState===n.CONNECTING){n.once("open",function(){o._write(c,d,f)});return}n.send(c,f)},o.on("end",$u),o.on("error",_a),o}ya.exports=Yu});var ui=fe((lm,ba)=>{"use strict";var{tokenChars:Xu}=kt();function Zu(n){let e=new Set,s=-1,o=-1,c=0;for(c;c<n.length;c++){let f=n.charCodeAt(c);if(o===-1&&Xu[f]===1)s===-1&&(s=c);else if(c!==0&&(f===32||f===9))o===-1&&s!==-1&&(o=c);else if(f===44){if(s===-1)throw new SyntaxError(`Unexpected character at index ${c}`);o===-1&&(o=c);let l=n.slice(s,o);if(e.has(l))throw new SyntaxError(`The "${l}" subprotocol is duplicated`);e.add(l),s=o=-1}else throw new SyntaxError(`Unexpected character at index ${c}`)}if(s===-1||o!==-1)throw new SyntaxError("Unexpected end of input");let d=n.slice(s,c);if(e.has(d))throw new SyntaxError(`The "${d}" subprotocol is duplicated`);return e.add(d),e}ba.exports={parse:Zu}});var ka=fe((hm,Pa)=>{"use strict";var Qu=V("events"),rr=V("http"),{Duplex:gm}=V("stream"),{createHash:ef}=V("crypto"),Sa=Zn(),xt=Pt(),tf=ui(),nf=nr(),{CLOSE_TIMEOUT:rf,GUID:sf,kWebSocket:of}=He(),af=/^[+/0-9A-Za-z]{22}==$/,Ea=0,Aa=1,Ia=2,fi=class extends Qu{constructor(e,s){if(super(),e={allowSynchronousEvents:!0,autoPong:!0,maxPayload:100*1024*1024,skipUTF8Validation:!1,perMessageDeflate:!1,handleProtocols:null,clientTracking:!0,closeTimeout:rf,verifyClient:null,noServer:!1,backlog:null,server:null,host:null,path:null,port:null,WebSocket:nf,...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=rr.createServer((o,c)=>{let d=rr.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=cf(this._server,{listening:this.emit.bind(this,"listening"),error:this.emit.bind(this,"error"),upgrade:(c,d,f)=>{this.handleUpgrade(c,d,f,o)}})}e.perMessageDeflate===!0&&(e.perMessageDeflate={}),e.clientTracking&&(this.clients=new Set,this._shouldEmitClose=!1),this.options=e,this._state=Ea}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===Ia){e&&this.once("close",()=>{e(new Error("The server is not running"))}),process.nextTick(tn,this);return}if(e&&this.once("close",e),this._state!==Aa)if(this._state=Aa,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(tn,this):process.nextTick(tn,this);else{let s=this._server;this._removeListeners(),this._removeListeners=this._server=null,s.close(()=>{tn(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",Ca);let d=e.headers["sec-websocket-key"],f=e.headers.upgrade,l=+e.headers["sec-websocket-version"];if(e.method!=="GET"){dt(this,e,s,405,"Invalid HTTP method");return}if(f===void 0||f.toLowerCase()!=="websocket"){dt(this,e,s,400,"Invalid Upgrade header");return}if(d===void 0||!af.test(d)){dt(this,e,s,400,"Missing or invalid Sec-WebSocket-Key header");return}if(l!==13&&l!==8){dt(this,e,s,400,"Missing or invalid Sec-WebSocket-Version header",{"Sec-WebSocket-Version":"13, 8"});return}if(!this.shouldHandle(e)){nn(s,400);return}let m=e.headers["sec-websocket-protocol"],w=new Set;if(m!==void 0)try{w=tf.parse(m)}catch{dt(this,e,s,400,"Invalid Sec-WebSocket-Protocol header");return}let v=e.headers["sec-websocket-extensions"],_={};if(this.options.perMessageDeflate&&v!==void 0){let E=new xt({...this.options.perMessageDeflate,isServer:!0,maxPayload:this.options.maxPayload});try{let T=Sa.parse(v);T[xt.extensionName]&&(E.accept(T[xt.extensionName]),_[xt.extensionName]=E)}catch{dt(this,e,s,400,"Invalid or unacceptable Sec-WebSocket-Extensions header");return}}if(this.options.verifyClient){let E={origin:e.headers[`${l===8?"sec-websocket-origin":"origin"}`],secure:!!(e.socket.authorized||e.socket.encrypted),req:e};if(this.options.verifyClient.length===2){this.options.verifyClient(E,(T,P,R,z)=>{if(!T)return nn(s,P||401,R,z);this.completeUpgrade(_,d,w,e,s,o,c)});return}if(!this.options.verifyClient(E))return nn(s,401)}this.completeUpgrade(_,d,w,e,s,o,c)}completeUpgrade(e,s,o,c,d,f,l){if(!d.readable||!d.writable)return d.destroy();if(d[of])throw new Error("server.handleUpgrade() was called more than once with the same socket, possibly due to a misconfiguration");if(this._state>Ea)return nn(d,503);let w=["HTTP/1.1 101 Switching Protocols","Upgrade: websocket","Connection: Upgrade",`Sec-WebSocket-Accept: ${ef("sha1").update(s+sf).digest("base64")}`],v=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;_&&(w.push(`Sec-WebSocket-Protocol: ${_}`),v._protocol=_)}if(e[xt.extensionName]){let _=e[xt.extensionName].params,E=Sa.format({[xt.extensionName]:[_]});w.push(`Sec-WebSocket-Extensions: ${E}`),v._extensions=e}this.emit("headers",w,c),d.write(w.concat(`\r
8
+ var ec=Object.create;var Pr=Object.defineProperty;var tc=Object.getOwnPropertyDescriptor;var nc=Object.getOwnPropertyNames;var rc=Object.getPrototypeOf,ic=Object.prototype.hasOwnProperty;var X=(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 ze=(n,e)=>()=>(n&&(e=n(n=0)),e);var le=(n,e)=>()=>(e||n((e={exports:{}}).exports,e),e.exports),Zi=(n,e)=>{for(var s in e)Pr(n,s,{get:e[s],enumerable:!0})},sc=(n,e,s,o)=>{if(e&&typeof e=="object"||typeof e=="function")for(let c of nc(e))!ic.call(n,c)&&c!==s&&Pr(n,c,{get:()=>e[c],enumerable:!(o=tc(e,c))||o.enumerable});return n};var Fe=(n,e,s)=>(s=n!=null?ec(rc(n)):{},sc(e||!n||!n.__esModule?Pr(s,"default",{value:n,enumerable:!0}):s,n));import{chmod as oc,mkdir as ac,readFile as cc,rename as Qi,writeFile as es}from"node:fs/promises";import{dirname as xc}from"node:path";async function pt(n){try{let e=await cc(n,"utf8");return JSON.parse(e)}catch(e){if(e.code==="ENOENT")return null;throw e}}async function on(n,e,s){await ac(xc(n),{recursive:!0});let o=`${JSON.stringify(e,null,2)}
9
+ `,c=`${n}.tmp-${process.pid}-${Math.random().toString(36).slice(2,10)}`;try{s?.mode!==void 0?await es(c,o,{encoding:"utf8",mode:s.mode}):await es(c,o,"utf8"),await Qi(c,n),s?.mode!==void 0&&await oc(n,s.mode)}catch(x){await Qi(c,c).catch(()=>{});let{rm:f}=await import("node:fs/promises");throw await f(c,{force:!0}).catch(()=>{}),x}}var an=ze(()=>{"use strict"});function rs(n){return xn[ts]<=xn[n]}function dn(n){ns={...n}}function cn(n,e,s,o){if(xn[n]<xn[ts])return;let c=JSON.stringify({ts:new Date().toISOString(),level:n,module:e,msg:s,...ns,...o});n==="error"||n==="warn"?fc.write(`${c}
10
+ `):dc.write(`${c}
11
+ `)}function R(n){return{debug:(e,s)=>cn("debug",n,e,s),info:(e,s)=>cn("info",n,e,s),warn:(e,s)=>cn("warn",n,e,s),error:(e,s)=>cn("error",n,e,s),child:e=>R(`${n}.${e}`)}}var xn,ts,dc,fc,ns,q=ze(()=>{"use strict";xn={debug:10,info:20,warn:30,error:40},ts=(()=>{let n=process.env.COZE_BRIDGE_LOG_LEVEL;return n==="debug"||n==="info"||n==="warn"||n==="error"?n:"info"})(),dc=process.stdout,fc=process.stderr,ns={}});import{promises as is}from"node:fs";import{homedir as uc}from"node:os";import{sep as lc,join as se,resolve as ss}from"node:path";function U(n){let e=n??uc(),s=se(e,".coze"),o=se(s,"bridge"),c=se(o,"lib");return{cozeRoot:s,bridgeRoot:o,libDir:c,libEntry:se(c,"index.js"),binDir:se(o,"bin"),pidFile:se(o,"bridge.pid"),portFile:se(o,"bridge.port"),tokenFile:se(o,"bridge.token"),patTokenFile:se(o,"pat-token"),logFile:se(o,"bridge.log"),installLock:se(o,"install.lock"),configFile:se(o,"config.json"),agentsRoot:se(s,"agents")}}function Ue(n,e=U()){let s=se(e.agentsRoot,n);return{root:s,config:se(s,"config.json"),workspace:se(s,"workspace"),logs:se(s,"logs")}}async function os(n,e){let s=await is.realpath(ss(n)).catch(()=>null);if(!s)return!1;let o=await is.realpath(ss(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+lc)}var oe=ze(()=>{"use strict"});var ln={};Zi(ln,{AGENT_CONFIG_FILE_MODE:()=>fn,enforceAgentConfigMode:()=>pc,loadAgentConfig:()=>pe,persistAgentSessions:()=>Tr,persistAgentSkills:()=>un,saveAgentConfig:()=>Ce});import{chmod as hc,stat as gc}from"node:fs/promises";function pe(n,e){return pt(Ue(n,e).config)}function Ce(n,e){return on(Ue(n.agentId,e).config,n,{mode:fn})}async function pc(n,e){if(process.platform==="win32")return;let s=Ue(n,e).config;try{let o=await gc(s);if(!o.isFile())return;let c=o.mode&511;c!==fn&&(await hc(s,fn),as.warn("agent config mode auto-corrected to 0600",{path:s,from:c.toString(8)}))}catch(o){if(o.code==="ENOENT")return;as.warn("enforceAgentConfigMode: chmod failed (ignored)",{path:s,err:String(o)})}}async function Tr(n,e,s){let o=await pe(n,s);o&&(o.sessions=Object.fromEntries(e),await Ce(o,s))}async function un(n,e,s){let o=await pe(n,s);o&&(o.skills=e,await Ce(o,s))}var as,fn,Xe=ze(()=>{"use strict";an();q();oe();as=R("agent-config"),fn=384});var Ao=le(Z=>{"use strict";var C=I;(function(n,e){let s=I,o=n();for(;;)try{if(-parseInt(s(984))/1*(-parseInt(s(1303))/2)+parseInt(s(1407))/3+-parseInt(s(646))/4*(-parseInt(s(629))/5)+-parseInt(s(311))/6+parseInt(s(840))/7+parseInt(s(636))/8*(parseInt(s(1171))/9)+-parseInt(s(1409))/10===e)break;o.push(o.shift())}catch{o.push(o.shift())}})(Un,612063);var Pd=Object.defineProperty,Td=Object["getOwnPr"+C(870)+C(734)],bo=(n,e)=>function(){return n&&(e=(0,n[{ETmSa:function(x,f){return x(f)}}[C(1453)](Td,n)[0]])(n=0)),e},Dd=(n,e)=>{let s=C,o={xEPHp:function(x,f,u,p){return x(f,u,p)}};for(var c in e)o[s(760)](Pd,n,c,{get:e[c],enumerable:!0})};function Rd(){return po||(po=[IDBDatabase,IDBObjectStore,IDBIndex,IDBCursor,IDBTransaction])}function Ld(){let n=C;return mo||(mo=[IDBCursor[n(1321)+"e"][n(1197)],IDBCursor.prototype[n(690)],IDBCursor.prototype["continue"+n(917)+"ey"]])}function Nd(n){let e=C,s={GVwis:function(c,x){return c!==x},LUgXa:function(c,x){return c(x)},swHfe:function(c){return c()},TDCjD:e(1665),ZnYjA:e(1602),ZfCIv:"error",DKFJI:function(c,x){return c(x)},JcerG:function(c,x){return c(x)},PIhro:function(c){return c()},jAAky:function(c,x){return c instanceof x}},o=new Promise((c,x)=>{let f=e,u={fgvaV:s[f(1544)],QJqAg:s[f(540)],NFZRf:s[f(1580)],DBwnJ:function(_,E){return s[f(1260)](_,E)},honSh:function(_,E){return s[f(1363)](_,E)},Kmkht:function(_){return s[f(1324)](_)}},p=()=>{let _=f;u[_(1433)]===u.fgvaV?(n[_(1136)+_(1630)+_(1558)](u.QJqAg,m),n[_(1136)+"entListe"+_(1558)](u[_(476)],b)):(this._isInit=!0,this[_(1605)]())},m=()=>{let _=f;u[_(1648)](c,u[_(1189)](Ne,n[_(579)])),u[_(949)](p)},b=()=>{let _=f;s[_(1108)](_(1614),_(236))?(s[_(367)](x,n.error),s[_(1443)](p)):(this["_binaryT"+_(716)]=_0x3c352e,this._ws&&(this[_(1305)].binaryType=_0x56f640))};n["addEvent"+f(1579)](s[f(540)],m),n[f(805)+f(1579)](s[f(1580)],b)});return o.then(c=>{let x=e;s[x(1286)](c,IDBCursor)&&Wr[x(853)](c,n)})[e(541)](()=>{}),Hn[e(853)](o,n),o}function Od(n){let e=C,s={eHMZs:function(c){return c()},UZsbV:function(c,x){return c===x},FgmUY:function(c,x){return c(x)},yuzOb:function(c,x,f){return c(x,f)},lDVDQ:e(893),spkdI:"bvkLC",BZDby:e(679),oJhxV:e(1702),AmvSB:e(769)+"or",tDjSD:e(500)};if(qn.has(n))return;let o=new Promise((c,x)=>{let f=e,u={CtNkM:function(_,E){return s[I(1274)](_,E)},oXyhC:function(_,E){return s[I(460)](_,E)},KvKPv:function(_,E,T){return s[I(1074)](_,E,T)},LCpvc:function(_,E){return _!==E},wusoI:s.lDVDQ,XCFWF:s[f(987)],HTLNT:s[f(1535)],FVqCZ:s[f(395)],jkFXk:s[f(1748)],UMELm:function(_){return s.eHMZs(_)}},p=()=>{let _=f,E={SOMTj:function(T,k){return u[I(847)](T,k)},rgbUM:function(T,k){return u[I(521)](T,k)},tvJjI:function(T,k,D){return u[I(921)](T,k,D)},YaSDr:function(T){return T()}};if(u.LCpvc(u.wusoI,u[_(1417)]))n[_(1136)+_(1630)+_(1558)](u[_(647)],m),n[_(1136)+_(1630)+_(1558)](_(500),b),n["removeEventListe"+_(1558)](u.FVqCZ,b);else return E[_(289)](typeof _0xf94f67,_(415))?E[_(1441)](_0x9f03e,_0x28fca5):(_0x22718c instanceof _0x110b56&&_0x1e1b62(_0x1fef07),E[_(346)](_0x1d5053,_0x16270b,E.YaSDr(_0x71bc2f))?new _0x59b4fe(_0x44d604,_0x5bbfab):_0x21da60)},m=()=>{let _=f;c(),s[_(738)](p)},b=()=>{let _=f;x(n.error||new DOMException(u[_(1042)],u.jkFXk)),u.UMELm(p)};n[f(805)+f(1579)](s.BZDby,m),n.addEventListener(s[f(339)],b),n[f(805)+f(1579)]("abort",b)});qn.set(n,o)}function Md(n){Kn={wyjkH:function(s,o){return s(o)}}.wyjkH(n,Kn)}function Un(){let n=["CeH0s1K","B2zMC2v0","De5gyMG","B25tDg9Wsw0","EMDrs3e","yK10Auq","Ahjls0m","CNHtCuq","Aw5L","BwvZC2fNztO","wfjsvLG","AKvPqNy","Bff0AMO","D2rvueu","AgvHzgvY","BgvUz3rO","AezlDg4","wMHKvMm","x2LZtwLUAvC","zcWGDw5RBM8","serWCg8","re9qrKK","sefnAKu","uxvLDwu","DhD0Awy","y29SBM8","wufYzKO","odiZmZGWrevUuLfw","ANjnrwy","mtqYnJa1ntbeq2fZr3u","Cerku2G","zgLeruK","C2vUDa","zcbLCNjVCI4","z2v0","DeX2rwq","wKzvDuW","wengv0y","wgDwrLG","y2XLyxi","AxnFywnR","x2rPC3bHDgm","zwXQA0W","vurMA20","Dg9mB3DLCKm","DMfSDwu","x3bPBMDmB3m","DMvUDa","yw5ZzM9YBvq","mdaWmdaWmda","x2LZqNjVD3m","x2fKzfDZtgK","rNDYwNC","zMD2yvy","ALzHs1C","t3zXvgi","y1vQvLa","CxbfBey","BM5lve0","z2v0qwXS","id4G","CMDIvu0","BM93","C3DizMu","sxz4tuG","y1nvBue","DhLWzq","yxPrsMW","BxnNsuq","whbzvNC","B3bLBKrc","ugnzy2C","veXVEhG","rvrTu2e","A2v5","CNnVCL9Uyw0","wwvNrxG","wwTmzxq","yMLUyxj5","rvH3EwC","D2f2t2W","uLjpuG","CgfYC2u","DxHbEKe","D3LTwKG","z3b2D2i","zMLN","CMvZzxrfBMq","zwn0","icSG","sKXzvKu","tfrRCuK","B3jRig9MzMW","ywrKq291BNq","qu5Ruw8","seD6txm","vLPcvgC","AwLAzwq","z3nVA0e","Cw9Z","AgfUz2u","uvb1v2K","CMvKDwnL","z01Ize8","BgLUzq","vhjvsgu","zNfvtKy","vu5gtgS","A0PxBe8","AhrVy0S","sxnICxC","Ef9MCM9UDgK","zNrOD0O","re1bA0K","ww9cEfa","AMX6CNi","DgLXCwG","A0XorNK","BfjoreC","B3bLBG","tKTOCeC","ALrkwee","Aw47y2HHCNm","r0rOzKC","s1zcELO","wKPQy3C","y0PWEhu","rvjZs0y","BM5Ly3q","EfjRwvy","CvjHve0","A2v5CW","uxP0wK0","zwvKzwq","Aw5dzLC","uxz5y1m","vhfIv3u","DgXtwK0","serjwNG","A0jzAMu","AvPSq3O","ywnOzwq","BhLHz3u","wfnNELi","x29Ut3bLBG","A0XuqxG","BezSDxnO","vgTfAhu","EM1gDvi","zw50","sNjQwwC","ywnR","Buf4DuS","tLrxuK4","yvvSt2S","qLPeyNK","C1Pfsfe","CYbHBhjLywq","zgvJB2rLzey","AxmGDw5Kzwy","C2v0q3vYC28","z2v0u3rVCMe","BfHqs3C","zgLZywjSzue","verdAKq","q016Efe","AM9PBG","sxHzELu","D1HjtMy","zMHUy2K","u0LdwMi","B0nqyLi","B2fcEgO","svzHzva","vgLTzw91Da","txHjsvi","CgLUz0LUDgu","yLD3tve","BMvY","qKTfyLK","B3bLBIa","CM9ruMW","Cg9PBNrdB24","wu5pEg0","lcbxzwjtB2m","t2nZDhK","ugHmrK4","DgvZDa","mxW0FdD8nq","vK5fyNK","v2LUzg93","B0D3s04","DxnyCvu","zxjYtM8","B25Uzwn0Aw4","qKvZA0K","z1rPBwvVDxq","uKTKy3e","x2rPC2nVBM4","tgLZDgvUzxi","wMzdsxy","DK9ZyMC","x3nLCuLK","AgvHzgvYCW","s211sLu","txjACNu","qNbWELe","x2nSzwfYugK","BMP3Buu","zKXYquq","AuP4BeC","y2HnyxHdB3u","AMvJDfn0B3i","DuH3yNC","q09oveLovuu","vfH6s2q","y2XVC2uSihC","zgvSzxrLrge","m3WYFdb8nNW","BMPOquK","zgv2AwnLx2K","v3HAseq","C3vJy2vZCW","C2vUzf9Hy2S","x2n1CNnVCK4","x2nVBM5Ly3q","CM92AwrLigi","D1DrC3K","B2flquW","BMfnvhu","zMLJyxO","z1r1vgu","wxHyq1G","u2vYDMLJzvC","CwDsqu0","zLHqsgW","zw5HyMXLqxu","AwXLtMfTzq","zeX6Ehu","sMTlwhG","v2TSve0","AxnbCNjHEq","z253wM4","Evbfuvi","CgjICdi","igzPzwXKoIa","sMvcu2e","C3bSAxq","s2POrgC","x3bHDgHlzxK","zw50tgLZDgu","yMrFzgLK","DNLNAva","x29UugfNzu4","wffzBvy","Bwf4twvZC2e","sfL0v0W","DxjS","zMLSzw5HBwu","EK5Ks3G","vgfN","Dg9oAu4","ig1LC3nHz2u","Ehbxs2i","CMvHzhLtDge","y2XVC2u","x2LUAxrqCM8","ihzHBgLKihm","rej3BKO","x0vysvnu","q2jRsxi","t3nlvNK","vvPxzM4","BvzyD1O","BMCGDxjSoIa","C3rVCMu","Ew9RwuG","vevprLm","z0PxEfK","s2fYze4","DKDOuvG","vM9hu2q","ywDL","q3rmr2y","yvjkqNa","EwHmtfG","uwPbAuq","txHMA28","x2rLyNvN","yLPVCwq","zfPxweW","v2vIu29JA2u","qMzpzNm","rgvKAwnHDgu","AxjLza","qxfOCLm","zxH0ugf5Bg8","rNjVBNrPzxi","ug5VAxy","AufgwKS","ANjXDwC","vK9kuKK","vgnStgG","zLnMDNC","sM9sDKW","x194x21Zz18","CMvZB2X2zq","t0T6u0u","uhnkA2W","uhD5AhO","DgLTzw91Da","rKXyDNu","Dg9cExrLCW","vLLoufy","AfPKzu0","wgHUBMW","x3DHAxq","zNfPsMm","CM94zfa","x2rYB3bhBg8","zv90Aw1LB3u","x2HHBMrSzva","ywjVCNq","DePrz0m","CgLUz0XVC3m","yxbWBgLJyxq","vhv0wgu","zKfKAeW","ugXQzg4","rLHzveG","u2r2wMi","C3Hwy2C","C2vYDMLJzq","Dg9tDhjPBMC","ufbND3G","DfrcEKe","y3vZDg9Tshq","z2PSDKi","AhPOBKS","sMvrtwK","sM1ds0m","ywnRtxnNswq","wvDZt1O","ChzgEeG","qu1XCLy","y2HLy2TdDxi","CgXLyxnLiha","x2jPBMfYEvq","BxLcrgG","yKTLtNy","yKnSwfy","zNjVBujPDhm","CYbWyxjHBxm","B2zMBgLUzq","Cfzirwm","wMD2Ag4","B3ffCvm","B25mAw5L","EKPUvfe","t1HXuei","AwDHDg9Yt24","suXQALe","DhnJsuq","B3jLtMfTzxm","y29Kzq","x2XPC3rLBMu","ELHdu0K","D2LSBfjLy28","qw12u0i","t2XoCK0","u1vMuKS","mNW1","x1fVu01HBMe","BwvKAwf0zwW","AND4r2q","vKPfEgu","q0Xpu0ve","CMvWBgfJzq","wMTst2S","ignVzgu6ia","BerWshy","yxnL","mhWXFdn8mNW","B3vUDa","teXNCKq","DMLUA08","BML0AwfSAxO","D052qMq","A1bqD1C","ENvKz0W","CMTLCKDSB2i","werXC2q","qNfQuxu","DMftq24","zM9Yy2u","rfvACxO","Cg9qrMm","sgPMB2m","wenAuuq","Bg9N","y3vYCMvUDeK","B2XKvMvYC2K","vMjsrLG","rMXwCwy","suDPDgi","zg1Mtfi","zvjfBxe","v2vPEgLUsLm","DhDVCMTdAge","Dgv4Dc9Qyxy","x2LUAxrhBg8","ufnWAfy","yw1LoIa","B25dBg9Zzq","C0L6sxa","tenoyKW","CMvHC29U","su9MrhO","rwXqA3e","BgLZDgvUtMu","twvmEeS","wNfbugm","CMfNzvn5BMm","BMDuAw1LCG","Agfcu3C","reT3sNy","ihjLy29UBMu","vMvlyNK","zxH0zw5ZAw8","v1fbwfu","CfLSBMS","Bg9Nsurhzw4","D0PSy1y","su5tvefova","CMvJzwL2zwq","EvjLy29UBMu","Ae1LC3nHz2u","txLqqwG","qw54uhC","EgrnugW","ywDLu2HVDW","CuTIyKy","tu53sNC","ufLfD08","rxzbAu8","s0DmD24","u09nvgO","yvjtEMq","CMvJzxzPzwq","B2HxEu8","x2DLBMvYyxq","B3bLCNr5","v3rIEhq","u2vWA3u","EKXsB20","CKzSqK0","tufyx1jfvfi","rLjptLrjrvi","DhbizwfKzxi","vgnKwxu","Aw9UvgLTzw8","DMfSDwvZ","DKf2z04","ALLHqw4","sNLitK4","x2LUDgvYDMe","vff3DK0","wLHts0e","ntaZmJq3nMjdBff0sG","B0v2r3e","ugr4BLK","zLjty0m","zfHYCMy","v1HbywG","Bwf4uMv0CMK","sM5ervC","yw5Hz2vY","Aw5rBuO","DxrMofDYAxq","zujlyxC","DMztzva","vKvbq28","AxvRugy","yxnLAuS","wMr3BeO","rhnLt0u","tg9Nsuq","ANbnBMG","x3fVC0rc","wLzLy3y","o2nOyxjZzxq","ELvOrvu","zwf4Exq","CeXct2m","B3nLrxzLBNq","AMHQrfm","DerQu0q","t2rnExG","zeXIyLa","zxf4quS","BIWGAg9ZDg4","u2vXsuq","x21LC3nHz2u","DhzkAKK","ExzjDxm","t1nYtKO","vMLet2y","s1fks2G","z0fJwgS","q29Kzq","EeL5uuK","zw5JB2rPBMC","seLSrMi","suPvtLe","BMrLEa","mNW1Fdr8nNW","rwT1wui","CLzHBhvLCW","yxbWBhK","vhPfu0O","zxLZvMm","BNLQD2K","rNvxz2i","C2XPy2u","tfvNwge","B3nLza","qvPkweG","tNriruG","vu9SBvq","yxrHlcbKyxq","q1Phrw8","rMTcvKC","rLzswxu","ChjVDg9JB2W","uNrnwLq","rvzVrhq","rNfIzgy","u0zYsKG","AxnszwfKEq","BfnoyNi","Dg9hzw5LCMe","s2ruA2u","yM5WEK0","B25Srwe","BMnLq2XVC2u","AwXSihvZzsa","zMX1C2HfEha","y2HnyxHuCMK","u0nZChi","EhjzvhO","rfDbquS","zxHWB3j0CW","B0POEfy","wuLyANi","BMf2wKe","BMr4ANq","rNb1Duu","m3W0Fdj8mxW","y2HLy2Tszwe","r3HqtuO","yxLHAfa","ywXSq3vYC28","ALngBfi","qNHUvhG","x29WDgLVBNm","ww5YyKG","zvrQD2i","B25tDgfYDfi","zxDLAuq","DgrIwgG","D2DxAKS","veXnsgG","zNvUy3rPB24","CM1nzKS","zNLuqva","tK9Lze0","zMzmAw5L","yxrAyMW","BwHdu3a","rLHiv1C","zw1PDa","x3DZsw5ZDge","EhfNA3e","Eefeseq","vxnOChK","ywnOzwqSihC","yM9KEq","Cgf5Bg9Hzfq","wgT5wem","ChjOC24","CMvZzxrdB3u","y1jKC1K","x3jLywr5q2W","CMvHzhDYAxq","q2j6rLu","zwnPsvG","x0rctMfTzq","x2rItMfTzq","AezKshi","C2Tpswe","BM1equS","x2LZv29YA2u","EeXUB0K","ywrK","wxHXzfG","tefYEvu","DwT4u24","EvDfDhy","AgfZ","CgfNzwHPzgu","uLnABe4","yMXVy2TLza","BuPkwuy","BMrWB2LUDfq","vxbKyxrLq28","DefSAhi","Aw9Ul2PZB24","rMDTvvK","yxnJCMLWDa","B2nRzxrtDwm","uLDzv3a","D3rrBMi","Dev2zw50","u055qLi","wuTxDMe","tKryDe0","vLDUveS","CgjuDNa","CujND20","y3jLyxrLt3a","BLzAvwK","DLPQDgu","tNnwDfK","tKzAuMy","D24GCMvHC28","ugXsz0i","EurXs3m","ALP4qwC","DMTdC2i","BerSC2m","sgHou1q","D3m6lY8","DMvYC2LVBMm","zMDiwfG","qwXpuxm","yLDOuLO","y0PTCee","wvDOBwm","x29UrxjYB3i","y0LPs1u","C3vIC3rYAw4","wuv0Agi","Aw5KzxHpzG","B2nRzxq","Dgv4DfbHEwW","CMfTzq","CK51vuW","zxjYB3i","DNnfsKe","wvvkyKG","rKP1DhG","sxnqDuW","ruvly1y","u0zMrK0","CMvUDevUzha","rvrgDMy","A2z0Dwe","rvjVwxy","uKv5D2m","reiGzMfPBgu","DMLrChG","t2rhwKm","qvrTvgK","Au5xruC","tvfVr04","ALnpt0W","t0XNzxy","BLnctgO","B1H5Aem","z2v0qwXSs2u","vLH1CM0","tKDFrvjst1i","zwzfwwG","yu12vMi","sfPfD2K","ign1CNnVCIa","t3vIqLq","z2v0sxrLBq","r09LDgS","BuXitK8","CMvHzfvjBNq","DvnUBey","ChrVCG","D3nZoI8V","u0TsAg8","Bgnivxi","vwfQAxe","wM5zAKe","y2f0y2G","mhWYFdf8m3W","x2rLC3rYB3K","DLnUAei","q291BNq","qunuvei","BevIB3y","ze1Hrwy","zLPHD3i","vuvRtw0","x2LUAxq","EwLosfq","CM9YrxzLBNq","EMvryNu","EwHlq3i","q2fbCfu","yxHkB1C","t0DZsgW","AxDUDKK","uuvlvvG","DgHLBG","B25fCNjVCG","wfjJwNy","qwDdruO","ihn1y2nLC3m","u3rYyxrLz3K","CwPRANu","uLrot0K","zgTJsu4","rKLmrv9ot1q","zvvYBa","C0LIwu0","DeLUDgvYy2u","z3Hgs28","A01wqum","yNL0zuXLBMC","zwnVBM5Ly3q","DgLKyuG","CMvZDwX0","yNjotuC","C2vYDMvYvgK","t1bftG","Bw1ezxC","yxv0B21HDgK","zgvIDwC","zNrICfq","zurqweq","sgHICum","ihzHBgLKigq","zcWG","werbvK8","ywDLrxzLBNq","BuTrugS","yNrUAKO","swffEu8","AgLNAa","twnVDuK","zgLYrxm","DuTUvfq","sMnezvG","zufJAW","vxrZv1C","tgPnA20","BNrLCG","zsbHihn0CMK","wMTwBe4","DNH6uK0","uNPKvLe","tKfusvzfx0u","CMfUzg9T","x2nYzwf0zvm","zw5JB2rLrNi","zwXTwwm","zhrPu2e","yw1L","C0jf","BhDXB0W","rhLvsNe","veLIz24","y29UC3rYDwm","Cgf5Bg9Hza","zMXVB3i","txLmChG","B1zzuKe","B3jpBMXPBMu","wLDuy1q","uNPuswW","x2zVCM1HDeu","mJaWmfbcBwPHEG","vezzEuK","vgToq0C","BM9Uzv9UB24","s0rLDw4","C2nYAxb0","Ec11C2uT","mtu5ntm3nK5nu1jdAa","EsbJBg9Zzwq","zNr2Eeq","z2v0q3vYC28","uLf2su8","zMTJtLO","vK9nq1K","EKHJsNu","wKrXv2i","ywvvAfa","nty0ohLIqNPHqq","sfrmtLq","A0nbBMC","twLZC2LUzYa","y29UBMvJDca","Dg9Y","B25LCNjVCG","BhrPCgXLihq","t0HtvLO","sgDIANe","DvzQBeq","zNjVBNrPzxi","AwX1t20","z3PIq1C","C3rYAw5N","DKLUq1K","thrPvM8","B2zM","B3Peuey","DxnLCKLW","zw50zwqGDhK","DvLRu0m","x2HHBMrSzvi","s2P6y2i","qKPcAgC","ALPWsK0","sgHxzM4","DLDAEfy","sgLqqMu","zMzLCG","DKnbyxe","AxnUCLi","uxDxDve","y29TCgXLDgu","zv9ZDwnJzxm","ExL1Dgu","y3vYDMfSDwu","AevYCM9Yrxy","zMvY","BfrPBwvVDxq","Dvjrruy","wMvhqLq","BvDwBLq","x29UtwvZC2e","y29UDgLUDwu","BLPJvfG","DK9rz3G","z0fxzNq","x3jLy29UBMu","s0DWDgO","Ee5LyuS","DhjPBq","ywP2Bxu","C2fNzq","zNjHBwvuExa","zMLUza","zxjFCw9Z","D2vWAuq","rhfjvMy","rKf5wK4","q1jNrfa","whbcwLC","BMfTzq","CgfNzxnOB3C","rM5pAMq","Cuj3tgO","qxL1t0i","vLLYsuS","zxf1ywXZ","uK5UvMC","ExbL","vMzcyuq","CM92AwrLihC","vfr3D2C","Bg9NsurozxC","u1b1AM8","q0Xpu0LorW","zgf0yq","ChjZzem","vfDov0W","t2jQzwn0","C2vUza","B0Lor3O","x3vYBa","q2fvB2u","t2rwDLe","B25nzxnZywC","u0Xeteq","BwvZ","Ahr0Ca","DxnUEhK","y09Wzw4","zuHnwNm","x3bPBMDqB24","BMCGzMfPBgu","u2zLwxG","C2DPza","wwPNsNm","t3bLBKv2zw4","x3bPBMC","x29Uq2XVC2u","Duzfuhu","x2LZtwLUAvq","z2HnveG","zxjHDg9Y","A1H1BM8","t1nYrKK","Efrurw52","zw5fDMvUDa","t0XoyvG","D2PlBeK","CxP4uwO","veDOsvy","y3rVq2S","Eevqsha","zw5KCg9PBNq","AujkteS","C0XPC3rLBMu","BwLUAvbYB2C","EgDrBhu","BMf6AxG","y29Uy2f0","Eufuswe","qwjVCNrfCNi","ru14t1q","B3fyvuC","uxPvrKy","Egnuthy","x3nLBMrby2S","wujWEgq","uNPbt1u","Aw1LCYbPBIa","rhLlqK8","x19LC01Vzhu","vgrdwwi","C2HtC0i","q0nssgO","rKjtvLi","DhjPzxm","sMPzCxa","BwvZC2fNzv8","zgHJq1G","ihrPBwvZ","CKTlDM4","yxKSihrYEsa","CMvXDwLYzwq","Aw9U","wKXUqva","D25gCgW","rNDxEgO","Dg9cExrLC0W","CgvYC2LZDgu","AxnmB25N","DgLTzw91DcW","yxrLq291BNq","u3L4q2C","A3L6r0O","yxv0BW","y01rvNu","ywrKrxzLBNq","zNjVBunOyxi","z2vjBMzVu3K","CeLqrxi","z1LWyLm","CMvHzg9UBhK","rfflwxi","y2HHCKnVzgu","wfDkD1i","ufjMD1C","vMXJCKO","DgvmB2Djre4","C3bSAwnL","tg9NsurozxC","DvnkBKm","tMfTzq","vwX5EMe","BgvY","Dw5RBM93BIa","sffHuNu","Bgn6wKO","zKvxBuW","suDctLK","tgvnv0C","rxvcyNq","qwL0D2y","yMLsrNC","DKHvyvm","Bwf4tg9ZC0m","x2LZsw5PDa","qNjPzgDL","A2TsAxm","sNLhEgK","CNnVCKzPBgu","wfbiBNC","nduYnZmWnKPPCgLsva","Bwv0Ag9K","tK5HA0S","AxnrB1nby2S","Dhj1y3rVCIa","rffgqK8","zxfpDKC","q3roA00","B25TzxnZywC","z2v0q3vYCMu","tNboBhK","y3vYC29YlNm","CMLLC0nVDw4","C2v0","CM1kvuq","q2Tdrg8","C3rYAw5NAwy","BwfUDwfSihi","t3zsEgK","yMHOzK0","r2jkEMO","DcbSAw1PDa","D2jRs2O","zw5Hu2S","Dg9oDw1Izxi","x3jLBw92zvC","z0jvr2S","vhzsDK8","yNHVAuu","u0vNvLq","B3bLCNr5tMe","z0LoveW","ihrYEsbYzwm","D3jzqxi","rxjYB3jdB2q","A2v0ignVBNm","zNjVBu51Bwi","C3z3t3i","CMv0CNLdB3u","wwvjC3G","sNvRvxO","suv5t3y","v3rUrxq","BwPsCu0","wfDMDxe","BuT4uMG","x29UvgLTzw8","DgDxv0O","CNzHBfzHBhu","CvHZBM4","y3r4","BeHqueC","BKXPBMu","AMDAwuu","q3HXvw4","sKrmwhC","yLLXteC","Bfz0ANu","wMDsu2W","CK5Yqxe","D05Ju3C","BKvAv1C","CNjVCK1LC3m","B2LUDfjLywm","D0vut1G","zw1LBNq","tKrQD2S","DxbKyxrLq3u","BMvLzf9Hy2S","BMvJDa","uxDxCgG","CwLutxO","ANDzAwS","C29Tzq","y3vYC29Y","t2XUq3G","rKjXs3G","uhjPBwfYEuS","wfbSrhO","vhrTve8","C2v0sxrLBq","s3zluhy","AwLJv0m","u2HHCMvKv28","CMvTB3zLq2G","ywXS","BvrZAvq","y29UDgv4Da","x2DLDeLUDgu","Ec1TC2CTy3u","wvDtBNC","BM9Vq1y","Aw5Lza","y1HxCxq","quXm","y2fSBa","C2v0u3rVCMe","zNjVBuj5Dgu","qKfrq2e","rxzLBNq","rxPqwe4","qMP2qMS","zw5HyMXLuw8","r1Puyuq","zeHsDuS","whj4r0y","vxnTDvO","ChbL","y25Vzgy","s21RAhq","CYbPBNn0yw4","q0ndv2K","x21PBMLoyxy","zwznDxe","x2n1CNnVCK0","B2XwzNe","qxzntxC","wMjMAfO","ug1KDwu","yMLUyxj5vhK","ywnRx2nVzgu","rvjxy2O","yMfJA3vWigu","A1Hjs1y","DMfvvw8","u3n5sNi","y3vYC29Yx24","rKPHyMm","B25szwnLAxy","wfzTAvq","EhDHzgq","BNruCMLLC0m","ELnoDMW","Dw5KzwzPBMu","ywrKt25L","Bg9IywXty28","B3jQAgm","sLfNwuW","BNvTyMvY","qu1bDxa","C0PrseO","AvrhsKS","yLHevfC","BMv6zNC","odmYDvHRDePJ","yuTdt08","Aw5JBhvKzxm","C3bRzeK","z1zeA3e","B2jQzwn0u3q","ruziDuS","igzHAwWSig0","y3nRALe","zfLLDhy","rvjst1i","q3vZDg9Trxi","A0fTzw0","y29UBMvJDgK","rwf4zu0","x2HHBMrSzu8","D3jPDgvvAw4","uKL2ALm","zxjFDhrS","wMT0u1C","uMr3Awu","y3jLyxrLrxi","sLnptLa","AePxAva","wKr1Cwy","v0zpuM8","C2HPzNq","ywzL","vMvvDNC","rhbduLy","A1n0yxr1C0m","yNvMzMvYzwq","A21juuq","qNjgC28","ihrPBwvVDxq","nhW1Fdf8mNW","zg9Uzq","BMv3vMvYC2K","s1zhsg4","Dg9cExrLC0i","AMDhqxi","quPVuxC","BMDtrMy","zwrPyxrLBhK","sNn2r1G","yNL0zxm","BgLTAxq","wxHwDMi","qw1VDw50","tg9JAW","x2vUzhbVAw4","yxGGCMv0CMK","zwLgzeC","reDKEhq","AenSB3nLrxy","z1HAzeq","BwLZzq","AK11rxy","AMTgwgS","BMT2u08","z2flDLq","wwzIANe","CgTerui","C29YDa","sgn3tui","Cgf5Bg9Hzeu","AhfgC20","rxn2tNO","EuTSrNG","Ee5hEK4","rhnRqxK","rLPev2K","BwfW","wgTZq0m","Exfwz0W","B25VCgvU","teHlBMS","Be1oseC","BNP0uMC","u2v6uM4","BwLUzW","A0f5EK8","CM92AwrLihy","r2L5qKm","q3PxzeG","s1bJzwO","DhrpruO","u2TPCcbWyxm","C2npAu0","y0jmEvK","Exv6t2i","zxrxB3jRq2G","tw9KDwXL","Aw5PDcbrB1m","CgLUz09Uy2u","sxjfs3e","B2fyB0y","wwvTs0C","uxv3AwW","AgvKtwf4uMu","vfrPwLy","z1LhDuK","ywXSzwqGBxu","x2n1CNnVCKy","z2v0s2v5","y21kue0","yM9yA3O","zxmGCMvHy2G","ywnRx2LK","C0DIB0q","DK1sqLG","AwXK","BeHHBMrSzxi","uuzVzMO","BNrfBMrWB2K","DhLmzey","y3jLyxrLt2i","y3ruAw1LB3u","DgfIyxnL","C3vIyxjYyxK","q1j0vwK","uMvJB25Uzwm","ihbYB3rVy28","EK5hCK8","r1z3Axm","y29UBMvJDfm","CKnusxe","y3jLyxrLtwu","Aw5KzxG","EuftqMu","DvrIDfK","AuTdr3G","A0XkCLi","rMTPwKW","Dgv4Dc9WBge","x3bYzwzPEa","q09otKvdveK","uwDctuG","zenNzfe","EhbPEeC","B25fuMK","AefJA01LC3m","qLPOyKq","z0DbuKy","ve9Os24","EfbNEKG","uMLgCfi","z3viCgm","zgvMAw5Luhi","DeLK","zvjVvNu","B3LTANC","CMvTB3zLrxy","igXHCMDLCIa","ELbWBxm","zfjhwgC","uwHrt0u","B25yvwq","rfbqzgS","CM1oA2W","yvv2EK4","zhzxA1e","zgLZCgf0y2G","Aw5KzxGGB3u","zNHKBue","zMTqv1a","ChjVy2vZCW","ywnRDxbfBMq","yMLUza","AM9fzva","BMnlDeu","Cg9PBNrbBMq","Ew14z1u","rK13q3i","tMzeuLC","sMHoEee","vw1ZtLy","DLDIANG","BwrdzhO","z2vtEw5J","x3bYB3rVy28","qxvOvgy","D2fZq2XLyw4","zfDVCMTLCKC","CwDOyM0","B3jL","tvDuD3e","oxLoyMr0vG","yxDNDve","zw5HyMXLvhi","wePgzM0","qxrTzeu","BwzpBKK","lcbTyxGGCMu","zeDLEhy","DMfRr2m","C3nHz2vfDMu","AeHwvxC","yNL0zu9MzNm","AMTlrwu","v05jzha","CM92AwrLige","zNzKr3e","yNLL","ywXSB2nvBNm","Ag9Uu2G","vw5Oyw5KBgu","Aez3D1i","ywX3yxLZ","zM9YrwfJAa","yKPpvhe","wgvpww8","y291BNq","ywr2yw5Jzq","yu1Msvi","DcbVzIbYyw4","Dg9VigXHCMC","zMvuALq","BMDLza","rLDt","suvtx0vsuK8","zgvSzxrL","B25SAw5L","x3nVy2TLDa","BwvY","ChvZAa","tuvtu0fhrv8","yNvMzMvY","y3vYCMvUDeu","CIb0DhDjra","B2nRzxrgywK","C0nVDw50zxi","EKHuEfK","vgDXCem","C1jiqKy","vhvlrK4","Eu1uveq","mhWZ","BuDhwKi","zMLSDgvY","twD6uNO","wgLeAfa","Dw5ZAwDUzwq","sK1vqMO","rxrQDhe","Axnby2TdBgu","vLH4wgi","q29UzMLN","v3nPzLK","v3zZz2G","BNrbBMrvCgq","CgLUz1rPBwu","CNnVCL92ywW","Bg93","y29UBMvJDeu","yxnZAwDU","B2XMs1e","t1bftL9fuLi","ihrVihjLDhi","rw1KteK","BwvZC2fNzq","whbqEvG","teXvC3G","CfzMrw0","y2XVC2veqG","B2fK","q2nqufe","C0Xf","yw51Ce1LC3m","CNzHBa","BMCGB3iGyw4","B25JBg9Zzq","Aw5N","DhjPzxmGCMu","zxjYtxnN","twvZC2fNzuu","reTgsKK","ywTuCLe","z2DVtuC","Aw50zwDLCIa","vMn5sgK","t1rVtNi","ywDLsgLKzq","yM9L","zgvS","uu9JCxO","vNfcyue","AxnrB1nnzxm","Dxrjza","x2nSzwfYvgK","vvPZyLy","q2PmAK8","txjWrfe","DKP5D3O","y3jLyxrLuMu","uwvMCuu","yw1Lu3bHy2u","ysbTDxn0igi","z29PBMCGyxC","AvnosLG","vMfxshC","C2vYDMLJzs0","AKfbA3K","vuX5B0i","ywXty29Wzq","D1vZrg4","zhbmu08","BxnrDNy","Dw50","y1fYwhK","DxLYCem","uhrpzge","ExbIsxu","DxbNCMfKzw4","EMPqvfm","yu10q1C","zNDZxZeUmc4","uw9nD3a","D3jPDgu","mJG2nhvWze9tAG","uxLdDvK","x3DZ","AgfVqKu","yMfSrxzLBNq","CwnPvNC","s2zdwgC","zhbiBLe","jMPZy2fSBgi","t1zsq2K","BMnVzgLUzW","r0HMzey","DNvNA3q","C3rLBMvYCW","s0Ley0G","s0LsCKC","qMj5tgm","tePcvvC","ChjVDg90Exa","wMvXBxy","sLDdufi","ueLOCM8","BLLQyKC","sKX3wfe","CMvJB25Uzwm","uhjeCgC","yLHLEvm","ywvtwNG","y29UBMvJDa","DMLJzuLeig8","AvDVqNq","ywXPzcb1CMW","AKDxvxy","yu9RANm","yMfSu2nVCgu","r2HMzNa","CgLUz19VBMm","vNrQywq","x25HDMLNyxq","Ec1TC2CTCw8","rhnAyM0","s25cCLC","EeLuAge","y3jLyxrLq2W","z0DMD1y","AgfZt3DUuhi","AfHcAgi","q3vZDg9Tq2W","z2n1Cwq","z2vY","De1HBMfNzxi","zKfYtvy","DKrPs3y","q3fTyLq","D2LtyMu","tfzIuMW","zxq9DxrMltG","Cw9Zx18","ExjOAfO","y2vZC0HHBMq","sMnLCKC","seXfvwG","zxjFBxnNAwq","z3DeAg0","svrQq2G","Chv0","EMPmBNK","ruvbC2u","C1jHALu","wKLtA1C","vxL4zgy","y3vYC29Yx2y","DgHHBIbSB2m","yxjHCui","vgfptgG","sxLwENi","tfz5tgq"];return Un=function(){return n},Un()}function Bd(n){let e=C,s={zDkVC:function(o,c){return o(c)},yqVgL:function(o,c){return o(c)},lHPPG:function(o,c){return o(c)},oSEoj:function(o,c){return o===c},eqOvG:function(o,c){return o in c},dhpym:function(o){return o()}};return s.oSEoj(n,IDBDatabase.prototype.transaction)&&!s[e(846)]("objectSt"+e(1743),IDBTransaction[e(1321)+"e"])?function(o,...c){let x=e,f=n.call(Vt(this),o,...c);return Gr.set(f,o.sort?o[x(1047)]():[o]),s.zDkVC(Ne,f)}:s.dhpym(Ld).includes(n)?function(...o){let c=e;return n.apply(s[c(1058)](Vt,this),o),Ne(Wr[c(1414)](this))}:function(...o){let c=e;return s[c(1058)](Ne,n[c(361)](s[c(891)](Vt,this),o))}}function zd(n){let e=C,s={lRNDG:function(o,c){return o===c},ULyoB:"function",JDLXw:function(o,c){return o(c)},EQpDU:function(o,c){return o instanceof c},uxAzA:function(o,c){return o(c)},yASBe:function(o,c,x){return o(c,x)},hFdHr:function(o){return o()}};return s[e(1498)](typeof n,s[e(1287)])?s[e(895)](Bd,n):(s.EQpDU(n,IDBTransaction)&&s[e(1463)](Od,n),s[e(1113)](vo,n,s[e(441)](Rd))?new Proxy(n,Kn):n)}function Ne(n){let e=C,s={yvIus:function(c,x){return c instanceof x},eciIX:function(c,x){return c(x)},sIzIp:function(c,x){return c!==x}};if(s[e(347)](n,IDBRequest))return s[e(438)](Nd,n);if(zn[e(451)](n))return zn[e(1414)](n);let o=s.eciIX(zd,n);return s[e(257)](o,n)&&(zn[e(853)](n,o),Hn[e(853)](o,n)),o}var vo,po,mo,Wr,qn,Gr,zn,Hn,Kn,Vt,wo=bo({"node_modules/idb/build/wrap-idb-value.js"(){let n=C,e={FXYTH:function(s,o,c){return s(o,c)},LeMWG:n(1645),VZBTg:function(s,o){return s instanceof o},iZlCz:function(s,o){return s===o},bnpzM:"jCdzI",OnWzk:function(s,o){return s===o},FBSVR:n(1020),HDIZx:function(s,o){return s===o},oqXUG:n(1655),gpvwb:function(s,o){return s(o)},IEyOv:function(s,o){return s+o},lyagu:n(1377),oINGz:"AMasq",bWwMQ:function(s,o){return s&o},OlnCx:function(s,o){return s>>o},Quwil:function(s,o){return s>>o},FMJsL:"pRaeg",gzbCW:"GoLBd",kAmem:function(s,o){return s===o},BuvmN:function(s,o){return s in o}};vo=(s,o)=>o[n(913)](c=>s instanceof c),Wr=new WeakMap,qn=new WeakMap,Gr=new WeakMap,zn=new WeakMap,Hn=new WeakMap,Kn={get(s,o,c){let x=n;if(e[x(1476)](s,IDBTransaction))if(e[x(1520)](x(696),e[x(385)])){let f=this[x(1034)+x(1353)]?.[x(849)+x(1098)+"nt"]();this[x(1421)+x(1038)+x(1529)](e[x(1709)](_0xb2cf01,e[x(828)],{code:_0x29e6a6[x(1744)],reason:x(997)+x(740)+x(1399)+x(477)+"n, hostn"+x(255)+f})),this[x(1034)+x(1353)]?.[x(1467)+x(1562)+x(1466)](),this[x(1426)+x(1215)]?.[x(433)+x(604)]();return}else{if(e.OnWzk(o,e[x(783)]))return qn.get(s);if(e[x(1518)](o,x(989)+x(1743)))return s["objectSt"+x(1743)]||Gr[x(1414)](s);if(e[x(1518)](o,e[x(771)]))return c[x(989)+x(1743)][1]?void 0:c[x(989)+x(1169)](c[x(989)+x(1743)][0])}return e[x(1465)](Ne,s[o])},set(s,o,c){let x=n;if(e[x(1522)]===e[x(728)]){let u=""+_0x10d844[x(1442)](),p=_0x1f8a32||(_0x5510d4=e[x(1465)](_0x45a113,_0x3a4afb)),m=_0x2aad0c[x(610)]()[x(1713)](16)[x(366)](-6);return e[x(881)](e[x(881)](e.IEyOv("02",u),p),m)}else return s[o]=c,!0},has(s,o){let c=n,x={uYkSC:function(f,u){return f|u},Sepku:function(f,u){return f|u},QhQOE:function(f,u){return e[I(1557)](f,u)},KnBrW:function(f,u){return f|u},SsyJr:function(f,u){return e[I(915)](f,u)},vsEJA:function(f,u){return e[I(1082)](f,u)}};if(e.FMJsL!==e[c(659)])return e[c(1476)](s,IDBTransaction)&&(o===e[c(783)]||e[c(996)](o,e[c(771)]))?!0:e.BuvmN(o,s);_0x5ca025<65536?_0x297989[_0x4253b5++]=x[c(667)](_0x567435>>12&15,224):(_0x34b50b[_0x4739d7++]=x[c(296)](x.QhQOE(_0x214000>>18,7),240),_0x2f0b80[_0xf997c3++]=x[c(1344)](x[c(1140)](x[c(965)](_0x513067,12),63),128)),_0x54d96e[_0x2d5568++]=x[c(1140)](x[c(501)](_0x4e07c8,6),63)|128}},Vt=s=>Hn.get(s)}}),So={};Dd(So,{deleteDB:()=>Ud,openDB:()=>Fd,unwrap:()=>Vt,wrap:()=>Ne});function Fd(n,e,{blocked:s,upgrade:o,blocking:c,terminated:x}={}){let f=C,u={ftbpT:function(b,_){return b instanceof _},VqBaA:function(b,_){return b===_},HYtWL:function(b,_){return b===_},kLTAx:f(1655),ATmTi:function(b,_,E,T,k){return b(_,E,T,k)},WsifY:function(b,_){return b(_)},zHTxY:function(b,_){return b(_)},ZbfhZ:f(485)+f(1480),HLEUh:function(b,_){return b===_},CbkIr:"nBTUj",QwWuQ:f(1297)+f(1513),VXxXb:f(454)},p=indexedDB.open(n,e),m=u[f(1216)](Ne,p);if(o)if(u[f(1364)](u[f(1650)],f(1496))){if(fuaRmS[f(586)](_0x1f0764,_0x27c35d)){if(fuaRmS[f(1270)](_0x50d0b3,f(1020)))return _0x425622[f(1414)](_0x2b718e);if(fuaRmS.HYtWL(_0x308c4b,f(989)+f(1743)))return _0x20cb8c[f(989)+"oreNames"]||_0x384c06[f(1414)](_0x3ad35c);if(fuaRmS[f(1636)](_0x4353f5,fuaRmS[f(1525)]))return _0x58ee07.objectStoreNames[1]?void 0:_0x55a990[f(989)+f(1169)](_0x945657[f(989)+f(1743)][0])}return _0x260963(_0x162a3c[_0x38d19a])}else p[f(805)+f(1579)](u[f(678)],b=>{let _=f;u[_(515)](o,u[_(1232)](Ne,p[_(579)]),b[_(244)+"on"],b[_(1021)+"on"],u[_(1216)](Ne,p["transact"+_(792)]))});return s&&p[f(805)+"Listener"](u[f(1230)],()=>s()),m[f(561)](b=>{let _=f;x&&b[_(805)+_(1579)](_(1645),()=>x()),c&&b[_(805)+_(1579)](u[_(957)],()=>c())})[f(541)](()=>{}),m}function Ud(n,{blocked:e}={}){let s=C,o={HhNST:s(454),iiZed:function(x,f){return x(f)}},c=indexedDB[s(1597)+s(1102)](n);return e&&c[s(805)+s(1579)](o[s(483)],()=>e()),o[s(1477)](Ne,c)[s(561)](()=>{})}function _o(n,e){let s=C,o={JeBSa:s(436)+"e",wtQnb:function(p,m){return p instanceof m},jrqug:function(p,m){return p in m},wJwIl:function(p,m){return p===m},zeQbu:"string",dpHnQ:function(p,m){return p!==m},uTbtY:s(373)};if(!(o[s(464)](n,IDBDatabase)&&!o[s(1680)](e,n)&&o.wJwIl(typeof e,o[s(554)])))return;if(Fn.get(e))return Fn.get(e);let c=e[s(1757)](/FromIndex$/,""),x=o[s(1310)](e,c),f=Co[s(986)](c);if(!o[s(1680)](c,(x?IDBIndex:IDBObjectStore)[s(1321)+"e"])||!(f||Eo[s(986)](c)))return o.dpHnQ(o[s(1114)],o[s(1114)])?!!_0x4507e1?.find(p=>p[s(1454)]===_0x4436eb&&p[s(1425)]===_0x5bf56b):void 0;let u=async function(p,...m){let b=s,_=this["transact"+b(792)](p,f?o[b(1626)]:b(810)),E=_.store;return x&&(E=E[b(1112)](m[b(1010)]())),(await Promise[b(925)]([E[c](...m),f&&_[b(1020)]]))[0]};return Fn[s(853)](e,u),u}var Eo,Co,Fn,qd=bo({"node_modules/idb/build/index.js"(){let n=C,e={ZDqWb:function(s){return s()},EmdLI:n(1414),jkKEe:n(1088),wjKlI:n(1439),RzTIl:"count",LtiVo:n(1368),ELFIO:n(1205),OLgev:"clear"};e.ZDqWb(wo),e[n(644)](wo),Eo=[e[n(1243)],e[n(1183)],e[n(756)],n(522)+"ys",e[n(627)]],Co=[e[n(662)],"add",e.ELFIO,e[n(519)]],Fn=new Map,Md(s=>({...s,get:(o,c,x)=>_o(o,c)||s[n(1414)](o,c,x),has:(o,c)=>!!_o(o,c)||s[n(451)](o,c)}))}}),Hd={idb:function(n){let e=C;n[e(394)]=Promise[e(1686)]().then(()=>(qd(),So))[e(561)](function(s){return s})}},yo={};function Le(n){let e=C,s={fvdGq:function(x,f){return x!==f}};var o=yo[n];if(s[e(1186)](void 0,o))return o[e(394)];var c=yo[n]={exports:{}};return Hd[n](c,c[e(394)],Le),c.exports}(()=>{let n=C,e={LHKnk:function(s,o){return s===o},HAMjE:n(1758),nEZWW:n(638)};Le.d=(s,o)=>{let c=n;if(e[c(1060)](e[c(1402)],e[c(901)]))return!!Z[c(331)];for(var x in o)Le.o(o,x)&&!Le.o(s,x)&&Object[c(1132)+"operty"](s,x,{enumerable:!0,get:o[x]})}})(),(()=>{let n=C;Le.o=(e,s)=>Object[n(1321)+"e"][n(1348)+n(294)].call(e,s)})(),(()=>{let n=C,e={cskjQ:function(s,o){return s!=o},aMvVb:n(973)+"d",YxVvb:n(1076),VYNPV:n(779)+"le"};Le.r=s=>{let o=n;e[o(992)](e[o(526)],typeof Symbol)&&Symbol[o(1713)+"Tag"]&&Object[o(1132)+"operty"](s,Symbol[o(1713)+o(1640)],{value:e[o(1031)]}),Object[o(1132)+o(294)](s,e[o(1693)],{value:!0})}})();var Y={};function I(n,e){n=n-234;let s=Un(),o=s[n];if(I.dNfmmi===void 0){var c=function(p){let m="abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789+/=",b="",_="";for(let E=0,T,k,D=0;k=p.charAt(D++);~k&&(T=E%4?T*64+k:k,E++%4)?b+=String.fromCharCode(255&T>>(-2*E&6)):0)k=m.indexOf(k);for(let E=0,T=b.length;E<T;E++)_+="%"+("00"+b.charCodeAt(E).toString(16)).slice(-2);return decodeURIComponent(_)};I.TFbUGr=c,I.HwzoVx={},I.dNfmmi=!0}let x=s[0],f=n+x,u=I.HwzoVx[f];return u?o=u:(o=I.TFbUGr(o),I.HwzoVx[f]=o),o}(()=>{let n=C,e={ukxSn:function(i,t){return i(t)},XpPyX:function(i,t){return i+t},OvqTb:function(i,t){return i*t},JsvGX:function(i,t,r){return i(t,r)},tgWWJ:n(1379),xwadd:function(i,t){return i(t)},EuBbt:function(i,t){return i+t},LCNbL:"0000",ZXEUq:"ffff",vWbjx:function(i,t){return i(t)},KGLwn:"0000000000000000"+n(1429)+"00000000",DGdxt:function(i,t){return i|t},RKdcq:function(i,t){return i>>t},fqiJc:function(i,t){return i&t},qBgwm:function(i,t){return i>>t},jMuEv:function(i,t){return i|t},RTNOI:function(i,t){return i&t},gINTL:function(i,t){return i<t},MNwJw:function(i,t){return i!==t},RzAOU:function(i,t){return i>t},SdvZb:function(i,t){return i===t},GZTaD:"jSFlR",wepiD:function(i,t){return i===t},ALHMn:n(1507),cJpxu:n(1121),ttOEJ:function(i,t){return i!==t},UEkMm:function(i,t){return i-t},lEbov:function(i,t){return i-t},KIRrG:function(i,t){return i<t},oaBxj:function(i,t){return i<t},ERWcj:function(i,t){return i!==t},rmMfK:function(i,t){return i===t},qciVw:function(i,t){return i-t},ITjCh:function(i,t){return i!==t},hZdeM:function(i,t,r){return i(t,r)},enaSk:function(i,t){return i>=t},FpuuE:"UzdJQ",CBzph:function(i,t){return i(t)},rCTIq:function(i,t){return i(t)},vGhQX:function(i,t){return i>>>t},nyjwi:function(i,t){return i(t)},mdCdz:function(i,t,r){return i(t,r)},dmfLR:function(i,t){return i(t)},Ushpy:n(649)+"required"+n(1625)+n(1454),IJUNQ:"Missing "+n(791)+n(1625)+n(1425),roQRl:function(i){return i()},iJxlG:function(i,t,r){return i(t,r)},KIDcH:function(i,t){return i&t},XSgzR:function(i,t){return i&t},OdGZC:function(i,t){return i&t},uAFiR:function(i,t){return i&t},kLNFy:function(i,t){return i>>>t},REywc:function(i,t,r){return i(t,r)},nooCV:function(i,t){return i!==t},HhbqC:n(1054),GOetk:function(i,t,r){return i(t,r)},wavOl:function(i,t){return i!==t},QPuWi:function(i,t,r){return i(t,r)},NsVtY:function(i,t,r){return i(t,r)},OXqPB:function(i,t,r){return i(t,r)},skOIa:function(i,t,r){return i(t,r)},rxSqD:function(i,t,r){return i(t,r)},lVtju:function(i,t,r){return i(t,r)},poPFc:function(i,t,r){return i(t,r)},AuhTf:function(i,t,r){return i(t,r)},YegEx:function(i,t){return i!==t},ZWTcT:function(i,t,r){return i(t,r)},fSfvw:n(1220),TOhKn:function(i,t,r){return i(t,r)},uSJnC:function(i,t){return i(t)},OSrFI:function(i,t){return i(t)},araqB:function(i,t){return i>>>t},LTkqI:function(i,t){return i(t)},BjvBk:function(i,t){return i(t)},KardN:function(i,t,r){return i(t,r)},SUfRK:function(i,t){return i(t)},rNuUL:function(i,t,r){return i(t,r)},htocK:function(i,t,r){return i(t,r)},fXPHl:function(i,t){return i(t)},PsJkl:function(i,t,r){return i(t,r)},QwWph:"Missing "+n(791)+" field: "+n(344),ficaz:function(i,t){return i===t},BfOfs:n(649)+n(791)+n(1625)+n(329),iTGJK:"Missing "+n(791)+n(1625)+n(1712),msQvv:function(i,t){return i||t},FZDWi:function(i,t){return i||t},YWSnw:function(i,t){return i!=t},kXuno:n(973)+"d",YWhmc:n(1593),jSOOL:function(i,t){return i(t)},mhCSp:function(i,t){return i(t)},KBkdH:function(i,t,r){return i(t,r)},MrpDQ:function(i,t){return i+t},ygmiT:"Unimplem"+n(666)+"pe: ",qzxQj:function(i,t){return i>>t},FMwCr:function(i,t){return i<t},jGWUv:function(i,t){return i|t},jVaKW:function(i,t){return i===t},CjLjO:function(i,t){return i&t},dGexv:function(i,t){return i&t},mAxuK:function(i,t){return i|t},TzESJ:function(i,t){return i&t},dsKuC:function(i,t){return i&t},fxdmA:function(i,t){return i>>t},SFfFM:"iNbfB",FkBVG:function(i,t){return i===t},orjhc:function(i,t){return i+t},AyuOB:n(1071)+"t limit",iluOm:function(i,t){return i>=t},ZJjcw:function(i,t){return i>t},kEWDO:function(i,t){return i*t},TIbgn:function(i,t){return i>t},IRIul:function(i,t){return i>t},jKDbH:"Read pas"+n(861),oqEqS:function(i,t){return i+t},jxjtb:n(277),VJExe:n(1382),olfKQ:function(i,t,r){return i(t,r)},BrFso:function(i,t){return i+t},Rdwie:function(i,t){return i&t},fAZyL:function(i,t){return i(t)},mmDew:function(i,t){return i>=t},efMuq:function(i,t){return i!==t},AZJXH:function(i,t){return i|t},ZqAPc:function(i,t){return i(t)},KPcej:function(i,t){return i==t},JQgYL:function(i,t){return i+t},SNyBR:function(i,t){return i+t},Aitwf:function(i,t){return i+t},GHZuA:function(i,t){return i+t},BJBhg:function(i,t){return i<<t},gYGuI:function(i,t){return i|t},BqjQu:function(i,t){return i<<t},roxdP:function(i,t){return i>=t},joEeP:function(i,t){return i<=t},jEiBv:function(i,t){return i(t)},xRkYV:function(i,t){return i&t},VoGSd:function(i,t){return i>=t},eysVc:function(i,t){return i+t},bWhRZ:function(i,t){return i+t},hqFsm:function(i,t){return i+t},pHtKY:function(i,t){return i<<t},dZWXL:function(i,t){return i&t},CRtUi:function(i,t){return i&t},TFYyI:function(i,t){return i&t},HIlFb:function(i,t){return i<t},pbTvp:function(i,t){return i>t},TgqpC:function(i,t){return i>>t},yiNHT:function(i,t){return i&t},XUgKs:function(i,t){return i<t},vInCY:function(i,t){return i>=t},TWNWL:function(i,t){return i+t},CtLGf:function(i,t){return i<t},SICZb:function(i,t){return i<t},QEKUX:function(i,t,r){return i(t,r)},NTWRN:function(i,t,r){return i(t,r)},OVRCi:function(i,t){return i<=t},ymxgU:function(i,t){return i-t},diDEI:function(i,t){return i<<t},JjYqp:function(i,t){return i&t},HUsTp:function(i,t){return i<t},tnEfG:function(i,t){return i>>t},lcHUr:function(i,t){return i|t},YNOxm:function(i,t){return i&t},Pwyhz:function(i,t){return i>>t},DMAkI:function(i,t){return i|t},PhDLE:function(i,t){return i&t},oEvGq:function(i,t,r){return i(t,r)},Etjtq:function(i,t){return i<t},jZpJM:function(i,t,r){return i(t,r)},QOcqz:function(i,t){return i&t},nnKTM:function(i,t){return i&t},CCRHj:function(i,t){return i<<t},DwgAI:function(i,t){return i(t)},OsKVy:function(i,t){return i&t},vygiP:function(i,t){return i(t)},dRGXg:function(i,t){return i&t},lXPKw:function(i,t){return i&t},NfDRW:function(i,t){return i(t)},VxEuS:function(i,t){return i(t)},ETFvf:function(i,t){return i<<t},NdTGW:function(i,t){return i(t)},McouI:function(i,t){return i&t},IGitb:function(i,t){return i&t},KLUiX:function(i,t){return i(t)},EzPXN:function(i,t){return i<<t},EFHuK:function(i,t){return i>>>t},hJWiP:function(i,t){return i===t},VcyHi:function(i,t){return i===t},WtnEt:function(i,t){return i<t},UDfkm:function(i,t){return i<t},ZVecv:function(i,t){return i<t},Hjfoc:function(i,t,r){return i(t,r)},nmDAK:function(i,t){return i+t},qiTMz:function(i,t){return i>>>t},mVXwZ:function(i,t){return i|t},eREmq:function(i,t){return i&t},TQwvM:function(i,t){return i+t},PlRgB:function(i,t){return i>>>t},lgWyG:function(i,t){return i&t},oGwKN:function(i,t){return i+t},nVZUi:function(i,t){return i|t},XksCC:function(i,t){return i>>>t},KQJKh:function(i,t){return i!==t},JcDeX:function(i,t){return i>>>t},LjMkm:function(i,t){return i+t},yPEQR:function(i,t){return i!==t},Xhnnl:function(i,t){return i&t},Zeqmv:function(i,t){return i+t},rKKvn:function(i,t){return i!==t},FwrZw:function(i,t){return i>>>t},eRoVu:function(i,t){return i>>>t},IVaeP:function(i,t){return i&t},ggoMG:function(i,t){return i(t)},yhKCr:function(i,t){return i(t)},CaApU:function(i,t){return i|t},dpLSO:function(i,t){return i<<t},TkEhu:function(i,t){return i<<t},uatuB:function(i,t){return i|t},eaxyt:function(i,t){return i|t},UKzCX:function(i,t){return i<<t},iPAaL:function(i,t){return i===t},gMfki:function(i,t){return i>>>t},QzUFF:function(i,t){return i|t},IxYzU:function(i,t){return i|t},xITha:function(i,t){return i<<t},YnrbH:function(i,t){return i|t},OPnYU:function(i,t){return i|t},FXErQ:function(i,t){return i<<t},VEACo:function(i,t){return i<<t},Kjzcb:function(i,t){return i&t},FnOjd:function(i,t){return i>>>t},DQKYr:function(i,t){return i>>>t},dvWkQ:n(1602),CRgDP:function(i,t){return i===t},MQoGN:n(334),aeSZx:function(i,t){return i>=t},WxZHD:function(i,t){return i%t},TclLh:function(i,t){return i/t},yDqKs:function(i,t){return i+t},zmFuR:function(i,t){return i*t},vfSeP:function(i,t){return i>>>t},VeKby:function(i,t){return i>>>t},ZISkW:function(i,t){return i===t},bClXV:function(i,t){return i&t},iSNJX:function(i,t){return i>>>t},HZEwi:function(i,t){return i+t},AlOQs:function(i,t){return i+t},gwDhm:function(i,t){return i+t},SPujo:function(i,t){return i|t},gBUGk:function(i,t){return i===t},TuKFN:function(i,t){return i===t},TTiZV:function(i,t){return i&t},VaWHw:function(i,t){return i>>>t},ayahP:function(i,t){return i&t},VfBaD:function(i,t){return i>>>t},EvAiO:function(i,t){return i&t},OvRxi:function(i,t){return i&t},mJJYF:function(i,t){return i>>>t},gYpbS:function(i,t){return i&t},LSwLp:n(1019)+n(1221),vaUUo:n(1241)+"OR",tlSZM:n(299)+"IES_ERROR",nazix:n(1210)+"ERROR",eTjwb:n(609)+n(1461),xPgzH:n(1120)+"NG_ERROR",AtmdE:n(1645),eqxAK:n(1393),MgzRz:function(i,t){return i==t},vMRBX:n(1620),GHfdF:"sIRwq",eBKaw:"bUAyl",XgVFX:n(1565),inCfW:n(1655),TtmTO:function(i,t){return i===t},rmNkl:n(238),kPPwW:function(i,t){return i-t},UtsWW:function(i,t){return i===t},lMNHG:n(831),tjjMD:n(885),HiOBS:function(i,t){return i>t},hzhnK:function(i,t,r,a){return i(t,r,a)},TdCYb:n(1491)+n(702),hFKtn:n(1491)+"er_qos_ack",YxqdX:n(1491)+"er_is_ack",RtMZT:function(i,t,r){return i(t,r)},VOJRI:n(1491)+"er_ack_m"+n(742),AvMMw:function(i,t){return i!==t},cSUmA:n(884),Flecn:n(1746),shSsB:"Fwsxd",cKQsm:function(i,t){return i===t},RWYWp:"error",YxXCX:function(i,t){return i instanceof t},XuTdj:function(i,t){return i+t},vOQgx:function(i,t){return i===t},ElPkq:function(i,t){return i===t},onlEa:function(i,t){return i!==t},iBJLK:n(1326),PcYcg:"mdQZK",ViDOf:n(563),aRSzd:function(i,t,r){return i(t,r)},YWsOZ:n(1244),HDppo:"open",XPHnw:function(i,t,r){return i(t,r)},AYUzq:function(i,t){return i<t},gaKvT:function(i,t){return i instanceof t},LLgrD:n(489),bOHAs:n(859),kCAng:n(452),wXINf:n(709),xpixG:n(1141),Wvsgh:n(1690),zSNvl:n(1339)+"e_timeout",JoRvL:n(1339)+n(680)+"s",XfPWE:n(1201),DPPdk:n(705),usXqU:function(i,t){return i||t},wfhye:function(i,t){return i!=t},SezRn:"next() c"+n(1086)+n(653)+n(777)+n(1150),CzWdH:function(i,t){return i===t},oaXoF:function(i,t){return i<t},sRajU:function(i,t){return i&t},LJBUW:function(i,t){return i===t},BEskI:n(1247),YkLet:function(i,t){return i<t},haoBE:n(1769),IVsht:function(i,t){return i<t},zLRom:function(i,t){return i&t},OKzSE:function(i,t){return i>=t},EEWwM:function(i,t){return i<t},Pnoiv:function(i,t){return i<<t},PtOda:function(i,t){return i<<t},iNWEG:function(i,t){return i>=t},BppzQ:function(i,t){return i-t},uVjlD:function(i,t){return i|t},DKwJv:function(i,t){return i|t},XDAVO:function(i,t){return i<<t},qjkju:function(i,t){return i&t},ndxjt:n(1374)+"ile_name",tdbXh:n(570)+n(1649),bXeyS:n(1738),eljkL:"CWpRu",KGptj:function(i,t){return i<t},QjAiD:function(i,t){return i<t},Mxfko:function(i,t){return i+t},ZLnAP:"1|4|2|5|"+n(1221),uSnlF:function(i,t){return i>>t},twtif:function(i,t){return i+t},FLXvu:function(i,t){return i<<t},pNxMJ:function(i,t){return i&t},cmJPM:function(i,t){return i|t},xADHD:function(i,t){return i>>t},SyxCg:function(i,t){return i|t},jZxAg:function(i,t){return i&t},aMfIR:function(i,t){return i|t},njwmE:function(i,t){return i|t},gMbdO:function(i,t){return i&t},EVoDt:n(660),FuWgb:function(i,t){return i(t)},ypbIu:function(i,t,r,a){return i(t,r,a)},XofDs:function(i,t){return i instanceof t},gJWxY:n(980),lDlsc:function(i,t){return i instanceof t},OToNr:n(1705)+n(459),zHcJu:function(i,t){return i==t},Yfbjq:n(1118)+n(1502)+n(1359),EaxeM:n(1267),RNnVg:function(i,t){return i(t)},RIvjS:n(823)+n(259),JnDEW:n(1416),FXHWW:function(i,t){return i(t)},cxROZ:n(768),AMqrV:n(883),TcdYu:n(252)+n(461),gXZdD:function(i,t){return i+t},YUJbH:n(735),MrZru:n(1311)+"ack=frontierJSONP",ohWyO:n(413),PsAgI:"idb",nezfw:function(i,t){return i!==t},KVBzZ:n(707),JukUz:"QTdmh",RiFpR:function(i){return i()},CUOSg:function(i,t,r,a){return i(t,r,a)},rKfFf:n(1702),inQmJ:n(295),boXkz:n(1369),TqbWu:function(i,t){return i(t)},fkPWP:function(i,t){return i(t)},NOedM:function(i,t){return i!==t},fkcNZ:n(513),xLnoI:n(1420),Vtjad:n(1092),IbMXS:n(674),SCspr:n(1628),lDpHv:function(i,t){return i(t)},vSnhB:function(i,t){return i!==t},yrhhZ:n(1131),dXrrf:"qumRG",iNBkJ:function(i,t){return i|t},iukPf:function(i,t){return i|t},HhWfn:function(i,t){return i<<t},qXsnn:function(i,t){return i|t},VlcrJ:function(i,t){return i!==t},TTwwg:n(1067),dirEs:n(417),tJQgC:function(i,t){return i||t},NtHEH:function(i,t){return i||t},yyute:function(i,t){return i||t},VWnTK:function(i,t){return i||t},kXIKV:function(i,t){return i&t},gjlvB:function(i,t){return i|t},tscID:function(i,t){return i&t},pQdEO:function(i,t){return i&t},gVDkq:function(i,t){return i>=t},XDqsd:n(1657),fArMV:function(i,t){return i||t},NpNly:function(i,t){return i!=t},aheUA:function(i,t){return i||t},FlVqf:n(1077)+n(512)+"d",bZoqd:n(1479),OGsHl:n(786)+"id",atZbl:"ack",qpElF:n(578),JWCPR:function(i,t){return i(t)},Vkxsy:function(i,t,r){return i(t,r)},bYqLG:"KSqnV",gnwZn:function(i,t){return i(t)},CkCDo:function(i,t){return i!==t},svwOr:function(i,t){return i!==t},UsmuZ:n(1138),mZiJU:n(313),WCvwe:function(i,t,r,a){return i(t,r,a)},ybMck:n(960),eDPXD:function(i,t){return i>=t},DlJYi:function(i,t){return i<=t},IvxMH:function(i,t){return i>=t},eweiD:function(i,t){return i|t},uKnTT:n(1357),cUjVP:function(i,t){return i instanceof t},vakGc:n(1705)+n(459)+n(333)+"=utf-8",cQrXy:n(632)+"e",fhnci:n(1458),toNiN:function(i,t,r,a){return i(t,r,a)},DWAAK:function(i,t){return i<t},DQFBO:function(i,t){return i|t},vDiKv:function(i,t){return i>>>t},TauNb:function(i,t){return i+t},JyHNN:n(1440),lbPLr:n(1263)+n(1200)+"e",RQvIO:function(i,t){return i>=t},gcuqd:function(i,t){return i&t},IPNbq:function(i,t,r,a){return i(t,r,a)},VeUvw:function(i,t){return i+t},UOlmT:n(1723),xIyQI:n(617),xrYTz:n(400)+"0",dCgdQ:function(i,t,r,a){return i(t,r,a)},NOzEH:function(i,t){return i+t},dHRuK:function(i,t,r,a){return i(t,r,a)},DyKBO:function(i,t){return i|t},CqmbT:function(i,t){return i+t},XiDhP:function(i,t){return i+t},OSrNJ:function(i,t){return i+t},hFwwR:function(i,t){return i<<t},XCZQD:function(i,t){return i<<t},jpMnh:function(i,t){return i+t},TutXe:function(i,t){return i+t},wUsDn:function(i,t){return i&t},FRizk:function(i,t){return i+t},kAyzO:function(i,t){return i&t},JtsSC:function(i,t){return i&t},YjgJs:function(i,t){return i+t},nZcTX:function(i,t){return i>>>t},yjsZh:function(i,t){return i&t},AMAup:function(i,t,r){return i(t,r)},tAlhr:n(758),Pljdn:function(i,t){return i&t},nztRg:function(i,t){return i>>>t},bJOTq:function(i,t){return i<<t},Ulyza:function(i,t){return i<<t},EMxOT:function(i,t){return i&t},aRJBp:n(741),EsvNz:function(i,t,r){return i(t,r)},BWIiP:n(358)+"9|3|10|1|0|7|8",gGARF:n(851)+"ervice",OLNaX:n(1394),kJWlO:n(682),WnfuR:n(1712),ZktSW:n(1285)+"name",tyLdF:function(i,t){return i+t},YemKG:function(i,t,r){return i(t,r)},rJOuS:n(404)+n(360),MWTwq:n(934),lczZJ:function(i,t,r,a){return i(t,r,a)},xqgkq:n(276),wnFpl:"setcursor",FJutx:n(673),EEKcV:"KUBIW",tNppc:function(i,t){return i|t},aMtCW:function(i,t){return i<t},LLUsx:function(i,t){return i|t},ynxwg:function(i,t){return i<<t},kftua:function(i,t){return i&t},cTtth:function(i,t){return i<t},nJBqa:function(i,t){return i<<t},JyGxi:function(i,t){return i&t},yKlFx:function(i,t){return i&t},FJabc:function(i,t){return i|t},CcPPQ:function(i,t){return i<<t},dtiSa:function(i,t){return i&t},UVIgy:function(i,t){return i&t},ERoYv:function(i,t){return i&t},zjPTS:function(i,t){return i+t},PPgwx:function(i,t){return i+t},cZdNw:function(i,t,r,a){return i(t,r,a)},KmuJU:n(1744),GbJzj:function(i,t,r){return i(t,r)},qKbbF:"x_fronti"+n(1365),OlNrM:function(i,t){return i(t)},rFlBM:function(i,t,r){return i(t,r)},aOkjs:"x_fronti"+n(1002),FPFJb:function(i,t,r,a){return i(t,r,a)},pYlnk:function(i,t,r){return i(t,r)},bMtiD:function(i,t){return i(t)},akTrQ:function(i,t,r){return i(t,r)},IaEyO:n(929)+n(1236)+"ue",aeUhP:function(i,t){return i>t},qghbm:n(747),YArfJ:function(i){return i()},xwqoH:function(i,t){return i<t},kBYje:n(916),CaUoe:function(i){return i()},QefqE:function(i){return i()},isnrR:n(1277),fRScC:n(938),MeLxK:function(i,t){return i===t},ZDuqf:function(i,t){return i&&t},ajvmu:function(i,t){return i(t)},wwfPQ:function(i,t){return i(t)},Zgvhn:function(i){return i()},NNakK:function(i,t){return i+t},xcTLv:n(922),YKWva:function(i,t){return i!==t},SLDLD:function(i,t,r){return i(t,r)},otusy:function(i,t){return i===t},gxFKo:n(1192),efEYh:function(i,t,r,a){return i(t,r,a)},dILwQ:n(539),mHNtv:function(i,t){return i===t},jlzrr:function(i,t,r){return i(t,r)},lSNbr:function(i,t){return i===t},YEthb:n(431),CmiLX:n(523),WNIdp:n(607),bxoiE:n(1187),JhNxA:function(i,t){return i!==t},xdMPl:function(i,t){return i!==t},HcwMB:"pLRRj",KXqCm:n(1415),hXBhb:function(i,t,r){return i(t,r)},CZMsm:n(1160),btnjJ:n(969),JkKXx:n(1594),ghMTH:n(1726)+n(1066)+n(1334),oxQtx:"please p"+n(718)+n(1732)+n(1564)+n(875)+n(844)+n(1539)+n(932),cnodf:function(i,t){return i(t)},eiFdG:function(i,t){return i===t},MDIzU:n(275),pkDEB:n(631),ncKtE:function(i,t,r){return i(t,r)},YIXjr:n(1327)+"t",ZeGBT:function(i,t,r){return i(t,r)},VYrIK:n(286),oRRdB:n(437),gTuTe:"online",oymjw:n(1733),TrUHe:function(i,t){return i(t)},dLzxu:"xgQlu",DDDYW:function(i,t,r){return i(t,r)},zgQKq:function(i,t){return i!==t},WXAah:function(i,t){return i<<t},RzdVQ:function(i,t){return i>>t},TvRvO:function(i,t){return i|t},rNrAq:function(i,t){return i>>t},DoFMy:function(i,t){return i|t},INEXv:function(i,t){return i===t},kLJrR:n(537),kyzGJ:"https:",PhLFN:n(536),myBDh:n(484),DyUJq:n(1631),fsRsC:"ttwid",mLHNO:function(i,t){return i||t},nSnSs:"please p"+n(1606)+"ddID, de"+n(1332)+n(1213),zNdKx:"function",wTNah:function(i){return i()},onERi:"web",dMaEf:n(1300)+"0",YBpxd:function(i,t){return i===t},zNGrO:n(1711),ECxsA:n(328),PRfwW:function(i,t){return i||t},fgHXX:"start",xpWKb:function(i,t){return i-t},fZawr:function(i,t){return i(t)},wETOX:function(i,t){return i-t},XRRVX:n(1282)+n(790)+n(1327)+"ting server",XrxGF:function(i,t,r){return i(t,r)},fLrAD:"XnvoZ",pLBOc:n(280),scOiM:function(i,t){return i(t)},mTsiT:function(i,t){return i===t},LAryU:n(1762)+"4",RSZlN:function(i,t){return i(t)},HLnSB:function(i,t){return i!==t},AJoQw:n(686),CxqUn:n(338),aKCOO:function(i,t,r){return i(t,r)},TLoxx:function(i,t,r){return i(t,r)},bofzp:n(1282)+"ay, netw"+n(1472)+n(1388),VOMCY:n(359),vCAaq:n(375),azQJl:n(300)+">",ZhdVc:function(i,t,r){return i(t,r)},paHRZ:"hteRZ",vHUaS:function(i){return i()},fEWmL:n(1490),DqAho:function(i,t){return i+t},ATElW:n(1598)+n(1568),jgGAr:n(1596)+n(950)+"ce not i"+n(1766)+"ed",sZEHQ:function(i,t){return i===t},SFrJH:n(1596)+n(1537)+n(637),XeOYo:n(1726)+n(1185)+n(589)+n(372)+n(1281)+n(605)+n(1254)+" arraybu"+n(675),wbkKj:function(i,t){return i==t},oCPbR:n(978),HWucP:function(i,t){return i!=t},cBElC:function(i,t){return i instanceof t},naMTu:function(i,t){return i(t)},haBSw:function(i,t){return i(t)},gAcXk:function(i,t){return i instanceof t},jYaAn:function(i,t){return i instanceof t},QZmme:function(i,t){return i(t)},XWJwR:function(i,t){return i===t},sZjtg:n(1412),sIbYM:n(1079),mJsxk:"enqueue",JLYVE:n(397),BDUJm:function(i,t){return i!==t},qxaAV:n(857)+n(577)+n(1256),hHVUw:n(542)+"4",gdOfj:function(i,t){return i|t},pZhkF:function(i,t){return i&t},gGfwV:function(i,t){return i>t},foSBH:function(i,t){return i>>t},ozDPF:"xzNBH",lQtjj:function(i,t){return i(t)},sRHBF:"\0\0\0\0\0\0\0\0",TLMHh:function(i,t){return i*t},cRdsY:n(1570),IyVzr:function(i,t){return i!=t},jrMEf:function(i,t){return i===t},iwnvI:function(i,t){return i!=t},CCCWi:n(726),pDJSh:n(1673)+n(1167)+n(975)+"pe",OdVvQ:function(i,t){return i!=t},JmCKC:function(i,t){return i===t},XpYVw:function(i,t){return i!=t},fAdhL:function(i,t){return i!=t},AnxPw:function(i,t){return i===t},NyTLN:n(923)+n(1770)+n(1288),jTJXA:function(i,t){return i===t},DsZbm:n(1613)+"orkerGlo"+n(1337),KdTke:function(i,t){return i!=t},NDXtM:function(i,t){return i!=t},LWMbF:function(i,t){return i===t},dYetv:function(i,t){return i!=t},YXOCA:n(1685)+n(1360)};Le.r(Y),Le.d(Y,{FWS:()=>X0,CustomErrorEvent:()=>Mi,createCloseEvent:()=>Ee,ReconnectEvent:()=>Oi,createErrorEvent:()=>ye,decodedFrame:()=>Se,createOpenEvent:()=>Hi,CustomCloseEvent:()=>Bi,createReconnectEvent:()=>mr,FrontierMessageEvent:()=>Fi,encodeFrame:()=>pr,createMessageEvent:()=>qi,OpenEvent:()=>Ui,ErrorCode:()=>$e,Event:()=>ut,MessageEvent:()=>zi});let s="";function o(i=""){let t=n,r="02",a=""+Date[t(1442)](),d=s||(s=e[t(449)](p,i)),l=Math[t(610)]()[t(1713)](16)[t(366)](-6);return e[t(1245)](e[t(1245)](r,a),d)+l}function c(){let i=n;return e[i(1435)](1e4,Date[i(1442)]())+Math[i(622)](1e4*Math[i(610)]())}function x(i){let t=n;return(Array(8)[t(1546)]("0")+e[t(1028)](parseInt,i,10)[t(1713)](2))[t(366)](-8)}function f(i){let t=n;if(e[t(887)]===e[t(887)])return e[t(1245)](Array(4)[t(1546)]("0"),parseInt(i,2)[t(1713)](16))[t(366)](-4);_0x58d3ce="wss://",_0x51e0c8=_0x3bcb95[t(1757)](/(^http)((?:[s]*:\/\/))/,""),_0x360014=/(^ws)((?:[s]*:\/\/))/[t(1567)](_0x3466d5)?_0x16b263:""+_0x1a75b7+_0x3ce934}function u(i){let t=n,r=i[t(1627)](/\./)[t(1056)](l=>x(l)),a=[];return a[0]=e[t(970)](f,e[t(1245)](r[0],r[1])),a[1]=e[t(970)](f,e.EuBbt(r[2],r[3])),[e[t(258)],e[t(258)],e[t(258)],e[t(258)],e.LCNbL,e.ZXEUq,a[0],a[1]].join("")}function p(i){let t=n,r=/(25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?)(\.(25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?)){3}/[t(1567)](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(1567)](i);return r?u(i):a?e[t(1161)](m,i):e[t(288)]}function m(i){let t=n,r={FRpdt:function(y,S){return e[I(871)](y,S)},EEAse:function(y,S){return e.MNwJw(y,S)}},a="",d=[],l=0,g=0,w=!0,h=e[t(258)];if(e[t(776)](i[t(495)]("::"),-1)){let y=i.split("::");for(let P=0;P<y[t(1395)];P++){let O=y[P];if(O[t(495)](":")>0)if(e[t(1710)](e[t(943)],t(405))){let L=O[t(1627)](":");w&&(l=L[t(1395)]),g+=L[t(1395)];for(let z=0;e[t(871)](z,L.length);z++)if(e[t(285)](4,L[z][t(1395)])){let W=h[t(493)+"g"](0,4-L[z][t(1395)]),ee=W[t(767)](L[z]);d[t(1209)](ee)}else d[t(1209)](L[z]);w=!1}else _0x42cd1c[_0x3b6b71++]=e[t(1037)](e[t(1577)](_0x16bfc3,12),224),_0x2f2f74[_0xd969ac++]=e.DGdxt(e[t(1697)](e.qBgwm(_0x36c0ba,6),63),128),_0x37d69c[_0x58d49c++]=e[t(1041)](e[t(568)](63,_0x570f0b),128);else{if(e[t(703)](e.ALHMn,e[t(1506)]))return this[t(331)]?.[t(1268)](_0x55661e);if(e[t(1070)](4,O[t(1395)])){let L=h[t(493)+"g"](0,e[t(550)](4,O[t(1395)])),z=L.concat(O);d.push(z)}else d[t(1209)](O);w&&(l+=1),g+=1,w=!1}}let S="";for(let P=0;e[t(871)](P,e[t(547)](8,g));P++)S=S.concat(h);for(let P=0;e[t(1318)](P,d[t(1395)]);P++)e.wepiD(P,l)&&(a=a[t(767)](S)),a=a[t(767)](d[P]);return a}{let y=i.split(":");for(let S=0;e[t(1552)](S,y.length);S++){let P=y[S];if(e.ERWcj(4,y[S].length))if(e[t(416)](t(1599),t(1599))){let O=h[t(493)+"g"](0,e[t(1308)](4,y[S][t(1395)])),L=O[t(767)](P);a=a[t(767)](L)}else{let O=_0x506e5d[t(1627)](":");_0x417fbd&&(_0x129931=O.length),_0x5aa0e2+=O[t(1395)];for(let L=0;r.FRpdt(L,O.length);L++)if(r[t(1370)](4,O[L][t(1395)])){let z=_0x28eeec[t(493)+"g"](0,4-O[L].length),W=z[t(767)](O[L]);_0x1f776a.push(W)}else _0x3fd98a[t(1209)](O[L]);_0x48a530=!1}else a=a.concat(P)}return a}}function b(i,t){let r=n,a=i[r(1454)];e[r(285)](void 0,a)&&(e[r(1028)](Q,t,10),e[r(1028)](ge,t,a));let d=i.value;e.ITjCh(void 0,d)&&(e[r(1694)](Q,t,18),e.hZdeM(ge,t,d))}function _(i){let t=n,r={wWQsy:function(a,d){return e.enaSk(a,d)}};if(e[t(703)](e[t(399)],e.FpuuE)){let a={};e:for(;!e.CBzph(M,i);){let d=e[t(1110)](G,i);switch(e.vGhQX(d,3)){case 0:break e;case 1:a.key=e.hZdeM(ue,i,e[t(364)](G,i));break;case 2:a[t(1425)]=e[t(1162)](ue,i,e[t(248)](G,i));break;default:ie(i,e[t(568)](7,d))}}if(a[t(1454)]===void 0)throw new Error(e[t(427)]);if(a[t(1425)]===void 0)throw new Error(e[t(356)]);return a}else if(r[t(1607)](_0x5d672a,_0x3d4dcd))return _0x8ef93}function E(i){let t=n,r=e[t(1561)](te);return e[t(1590)](T,i,r),e[t(1161)](A,r)}function T(i,t){let r=n,a=i[r(344)];e[r(1367)](void 0,a)&&(e[r(511)](Q,t,8),Be(t,a));let d=i[r(329)];d!==void 0&&(e.REywc(Q,t,16),Be(t,d));let l=i.service;e[r(931)](void 0,l)&&(e[r(588)]!==e[r(588)]?this._initPromise=null:(e.GOetk(Q,t,24),e[r(1694)](Be,t,e.nyjwi($,l))));let g=i[r(841)];e[r(1460)](void 0,g)&&(e[r(1481)](Q,t,32),e[r(1162)](Be,t,e[r(449)]($,g)));let w=i[r(1583)];if(e[r(1460)](void 0,w))for(let W of w){Q(t,42);let ee=te();e[r(475)](b,W,ee),e[r(1739)](Q,t,ee[r(1030)]),e.REywc(nt,t,ee),e.rCTIq(ae,ee)}let h=i[r(1049)+"ncoding"];e[r(1460)](void 0,h)&&(e[r(1694)](Q,t,50),e.JsvGX(ge,t,h));let y=i[r(430)+r(716)];y!==void 0&&(Q(t,58),e[r(442)](ge,t,y));let S=i[r(621)];e[r(285)](void 0,S)&&(e.QPuWi(Q,t,66),e[r(1387)](Q,t,S[r(1395)]),e[r(897)](Me,t,S));let P=i[r(818)];e[r(1460)](void 0,P)&&(e[r(239)](Q,t,74),e[r(1165)](ge,t,P));let O=i[r(581)+r(1064)];e.YegEx(void 0,O)&&(e[r(626)](Q,t,82),e.hZdeM(ge,t,O));let L=i.msgID;if(L!==void 0)if(e[r(703)](e.fSfvw,e[r(1683)]))e[r(897)](Q,t,90),e[r(1128)](ge,t,L);else{let W=this[r(596)],ee=this[r(1237)];return[e[r(1317)](255,ee),e[r(1523)](e[r(1660)](ee,8),255),e[r(514)](ee>>>16,255),e[r(1660)](ee,24),255&W,e.uAFiR(e[r(1660)](W,8),255),e[r(1317)](e[r(1497)](W,16),255),e.vGhQX(W,24)]}let z=i.frameType;e.nooCV(void 0,z)&&(e.NsVtY(Q,t,96),e[r(626)](Be,t,e[r(819)]($,z)))}function k(i){return e[n(819)](D,e.OSrFI(ce,i))}function D(i){let t=n,r={};e:for(;!e[t(364)](M,i);){let a=e[t(752)](G,i);switch(e[t(1376)](a,3)){case 0:break e;case 1:r.SeqID=e[t(1162)](xe,i,!0);break;case 2:r[t(329)]=e[t(1590)](xe,i,!0);break;case 3:r[t(1712)]=G(i);break;case 4:r[t(841)]=e[t(1110)](G,i);break;case 5:{let d=e.LTkqI(F,i);(r.headers||(r[t(1583)]=[]))[t(1209)](e.vWbjx(_,i)),i[t(1030)]=d;break}case 6:r["payloadE"+t(1313)]=e[t(897)](ue,i,e[t(941)](G,i));break;case 7:r["payloadT"+t(716)]=e[t(1659)](ue,i,e[t(1750)](G,i));break;case 8:r[t(621)]=e.GOetk(Ie,i,G(i));break;case 9:r.LogIDNew=e[t(499)](ue,i,e[t(248)](G,i));break;case 10:r[t(581)+t(1064)]=e[t(1489)](ue,i,e.fXPHl(G,i));break;case 11:r[t(1448)]=e[t(1688)](ue,i,G(i));break;case 12:r.frameType=e[t(1615)](G,i);break;default:ie(i,e[t(514)](7,a))}}if(r[t(344)]===void 0)throw new Error(e[t(910)]);if(e.ficaz(void 0,r[t(329)]))throw new Error(e[t(1672)]);if(r.service===void 0)throw new Error(e[t(981)]);if(r[t(841)]===void 0)throw new Error(t(649)+"required"+t(1625)+"method");return r}function F(i){let t=n;if(e[t(703)](e[t(490)],e[t(490)])){let r=e.jSOOL(G,i),a=i[t(1030)];return i[t(1030)]=i.offset+r,a}else{if(_0x33a3c1)return new _0x29c37e(_0x39f09d[t(1637)],_0x2580e7[t(376)]);if(e[t(1291)](_0x5de8ab,_0x3f418a))return new _0x109e18(_0x3d9767[t(1637)],_0x1829aa[t(376)],_0x276d86.headers);if(e[t(1055)](_0xb40d74,_0x36ec2b)&&e[t(930)](e[t(751)],typeof _0x8c59c4)&&_0x22960e)return new _0x1a48d9(_0x5c2714[t(1637)],_0x90a6d6[t(376)+"s"])}}function ie(i,t){let r=n;switch(t){case 0:for(;e.fqiJc(128,e[r(421)](ne,i)););break;case 2:e[r(1165)](N,i,G(i));break;case 5:e[r(1128)](N,i,4);break;case 1:e.KBkdH(N,i,8);break;default:throw new Error(e[r(1276)](e.ygmiT,t))}}function $(i){let t=n;return i|=0,{low:i,high:e[t(757)](i,31),unsigned:e[t(863)](i,0)}}let we=[];function te(){let i=n,t=we.pop();return t?(t[i(1381)]=t.limit=0,t):{bytes:new Uint8Array(64),offset:0,limit:0}}function ae(i){we[n(1209)](i)}function ce(i){return{bytes:i,offset:0,limit:i[n(1395)]}}function A(i){let t=n,r={iAFZK:function(a,d){return e[I(1157)](a,d)},BbyLc:function(a,d){return e[I(1335)](a,d)},BxnTx:function(a,d){return e.jVaKW(a,d)},ngSFf:function(a,d){return e[I(1275)](a,d)},ctoCk:function(a,d){return e[I(1245)](a,d)},wNcSw:function(a,d){return e[I(1037)](a,d)},QztZM:function(a,d){return e[I(568)](a,d)},cMQVu:function(a,d){return e[I(1178)](a,d)},ZXSKA:function(a,d){return e[I(471)](a,d)},mKQPk:function(a,d){return e[I(1532)](a,d)},OubBT:function(a,d){return e[I(829)](a,d)},NKhpG:function(a,d){return e[I(829)](a,d)},BYMMr:function(a,d){return e[I(362)](a,d)},dhcCX:function(a,d){return a|d},awguQ:function(a,d){return a&d},aUlOk:function(a,d){return e.dsKuC(a,d)},jwYik:function(a,d){return e[I(1148)](a,d)},nXSxw:function(a,d){return a&d}};if(e[t(931)](e[t(506)],e[t(506)]))if(_0x56893f=_0x598d00[t(812)+"At"](_0x248192),r.iAFZK(_0x23263b,128))_0x24f98d[_0x329f3e++]=_0x5906d5;else if(r[t(1679)](_0x21b8d8,2048))_0x34a34c[_0x515a9b++]=r[t(1319)](_0xb98162>>6,192),_0x5f5416[_0x56949d++]=r.BbyLc(63&_0x11f62a,128);else if(r[t(406)](r[t(1026)](64512,_0x1daad0),55296)&&r.BxnTx(r.ngSFf(64512,_0x3706e9=_0x5d67fb[t(812)+"At"](r[t(759)](_0x16d659,1))),56320)){let a=("4|0|3|1|"+t(1751))[t(1627)]("|"),d=0;for(;;){switch(a[d++]){case"0":++_0x28744a;continue;case"1":_0x3032ca[_0x3ecda0++]=r[t(900)](r[t(1512)](_0x1619ee>>12,63),128);continue;case"2":_0x29805a[_0x226f15++]=r[t(1319)](r[t(804)](r[t(310)](_0xf55b6e,6),63),128);continue;case"3":_0x2d8429[_0x1433f7++]=r[t(593)](r[t(310)](_0x6dac07,18),240);continue;case"4":_0xbd09d4=r[t(529)](r[t(1500)](65536,r[t(1512)](1023,_0x40031f)<<10),r.BYMMr(1023,_0x129ab0));continue;case"5":_0x1bac4f[_0xef1902++]=r[t(787)](r[t(1172)](63,_0x5692d5),128);continue}break}}else _0x2c9e1a[_0x5e1491++]=r[t(787)](r[t(310)](_0x2d3fcb,12),224),_0x5dd4b3[_0x4d253b++]=r[t(1534)](r[t(912)](_0x3746c7,6),63)|128,_0x37f1cb[_0x5a79af++]=r.wNcSw(r.nXSxw(63,_0x1dddea),128);else{let a=i.bytes,d=i[t(1030)];return e.FkBVG(a[t(1395)],d)?a:a[t(1103)](0,d)}}function N(i,t){let r=n;if(e.RzAOU(e[r(976)](i.offset,t),i.limit))throw new Error(e[r(712)]);i[r(1381)]+=t}function M(i){let t=n;return e[t(658)](i[t(1381)],i.limit)}function V(i,t){let r=n,a=i.bytes,d=i.offset,l=i.limit,g=d+t;if(e[r(1505)](g,a[r(1395)])){let w=new Uint8Array(e.kEWDO(2,g));w[r(853)](a),i.bytes=w}return i[r(1381)]=g,e[r(619)](g,l)&&(i[r(1030)]=g),d}function _e(i,t){let r=n,a=i[r(1381)];if(e.IRIul(e[r(1245)](a,t),i.limit))throw new Error(e.jKDbH);return i[r(1381)]+=t,a}function Ie(i,t){let r=n,a=e[r(897)](_e,i,t);return i.bytes[r(1103)](a,e[r(1736)](a,t))}function Me(i,t){let r=n,a={pVHEc:e.jxjtb,CVhev:function(d){return d()}};if(e[r(374)](e[r(1755)],e[r(1755)])){let d=e[r(1240)](V,i,t[r(1395)]);i[r(1029)][r(853)](t,d)}else this[r(1668)](a[r(1734)],_0x1f8896[r(1244)]),a.CVhev(_0x1f5ff8)}function ue(i,t){let r=n,a=_e(i,t),d=String[r(806)+r(352)],l=i[r(1029)],g="\uFFFD",w="";for(let h=0;h<t;h++){let y=l[e[r(1017)](h,a)],S,P,O,L;e[r(1004)](128,y)===0?w+=e.fAZyL(d,y):e[r(374)](e[r(514)](224,y),192)?e[r(583)](e[r(1245)](h,1),t)?w+=g:(S=l[e.BrFso(h+a,1)],e[r(953)](e[r(1178)](192,S),128)?w+=g:(L=e[r(369)](e.fqiJc(31,y)<<6,63&S),e[r(1318)](L,128)?w+=g:(w+=e[r(264)](d,L),h++))):e[r(1069)](240&y,224)?e[r(977)](h,2)>=t?w+=g:(S=l[e[r(466)](e[r(1276)](h,a),1)],P=l[e[r(830)](e.GHZuA(h,a),2)],e.ERWcj(e[r(362)](e.AZJXH(S,e.BJBhg(P,8)),49344),32896)?w+=g:(L=e[r(1037)](e[r(1085)](e.BqjQu(e[r(514)](15,y),12),e.BJBhg(63&S,6)),e[r(1523)](63,P)),e[r(871)](L,2048)||e[r(1698)](L,55296)&&e[r(1153)](L,57343)?w+=g:(w+=e[r(1391)](d,L),h+=2))):e[r(1069)](e[r(1509)](248,y),240)?e[r(1661)](e[r(363)](h,3),t)?w+=g:(S=l[e[r(1276)](h,a)+1],P=l[e[r(488)](e.JQgYL(h,a),2)],O=l[e[r(1050)](h,a)+3],e[r(1367)](e.AZJXH(S|e[r(1380)](P,8),e[r(235)](O,16))&12632256,8421504)?w+=g:(L=e[r(1532)](e[r(1037)](e.pHtKY(e.dGexv(7,y),18)|e[r(1670)](63,S)<<12,e[r(1104)](63,P)<<6),e[r(630)](63,O)),e[r(355)](L,65536)||e[r(470)](L,1114111)?w+=g:(L-=65536,w+=e[r(499)](d,e[r(1217)](L,10)+55296,e.yiNHT(1023,L)+56320),h+=3))):w+=g}return w}function ge(i,t){let r=n,a=t[r(1395)],d=0;for(let w=0;e.XUgKs(w,a);w++){let h=t[r(812)+"At"](w);e[r(661)](h,55296)&&h<=56319&&e[r(1157)](e[r(977)](w,1),a)&&(h=e[r(547)](e[r(725)](h<<10,t[r(812)+"At"](++w)),56613888)),d+=e[r(1663)](h,128)?1:e[r(1550)](h,2048)?2:h<65536?3:4}e[r(560)](Q,i,d);let l=e[r(1533)](V,i,d),g=i[r(1029)];for(let w=0;w<a;w++){let h=t[r(812)+"At"](w);e.vInCY(h,55296)&&e[r(1312)](h,56319)&&e.gINTL(w+1,a)&&(h=e[r(1156)](e[r(725)](e.diDEI(h,10),t[r(812)+"At"](++w)),56613888)),h<128?g[l++]=h:(e[r(1550)](h,2048)?g[l++]=e[r(1037)](e[r(785)](e[r(1148)](h,6),31),192):(e.HUsTp(h,65536)?g[l++]=e[r(785)](e.TgqpC(h,12),15)|224:(g[l++]=e[r(369)](e[r(1275)](e.tnEfG(h,18),7),240),g[l++]=e.lcHUr(e[r(1563)](e[r(1689)](h,12),63),128)),g[l++]=e[r(1493)](e.PhDLE(h>>6,63),128)),g[l++]=e[r(1335)](63&h,128))}}function nt(i,t){let r=n,a=e[r(312)](V,i,t[r(1030)]),d=i[r(1029)],l=t[r(1029)];for(let g=0,w=t.limit;e.Etjtq(g,w);g++)d[e[r(830)](g,a)]=l[g]}function ne(i){return i[n(1029)][e.htocK(_e,i,1)]}function rt(i,t){let r=n,a=e[r(671)](V,i,1);i[r(1029)][a]=t}function G(i){let t=n,r=0,a=0,d;do d=e[t(941)](ne,i),e[t(1157)](r,32)&&(a|=e[t(1411)](e[t(1269)](127,d),r)),r+=7;while(e[t(1317)](128,d));return a}function Q(i,t){let r=n;for(t>>>=0;e[r(1698)](t,128);)e[r(475)](rt,i,e[r(1085)](e[r(1438)](127,t),128)),t>>>=7;e.htocK(rt,i,t)}function xe(i,t){let r=n,a=0,d=0,l=0,g;return g=e[r(752)](ne,i),a=127&g,e[r(1275)](128,g)&&(g=e.BjvBk(ne,i),a|=e[r(782)](127&g,7),e[r(1670)](128,g)&&(g=e.DwgAI(ne,i),a|=e.BqjQu(127&g,14),e[r(1651)](128,g)&&(g=e[r(941)](ne,i),a|=e[r(1380)](e[r(552)](127,g),21),e.fqiJc(128,g)&&(g=e[r(1632)](ne,i),d=e[r(1139)](127,g),e[r(1542)](128,g)&&(g=ne(i),d|=e[r(630)](127,g)<<7,128&g&&(g=e[r(1158)](ne,i),d|=e[r(1004)](127,g)<<14,e.yiNHT(128,g)&&(g=e.VxEuS(ne,i),d|=e[r(508)](e[r(1275)](127,g),21),128&g&&(g=e.NdTGW(ne,i),l=e[r(597)](127,g),e.IGitb(128,g)&&(g=e.KLUiX(ne,i),l|=e.XSgzR(127,g)<<7))))))))),{low:e[r(538)](a,d<<28),high:e[r(538)](e.araqB(d,4),e[r(940)](l,24)),unsigned:t}}function Be(i,t){let r=n,a=t.low>>>0,d=e.kLNFy(e[r(1532)](t.low>>>28,t[r(596)]<<4),0),l=e[r(990)](t[r(596)],24),g=e[r(1007)](0,l)?e.VcyHi(0,d)?e[r(1228)](a,16384)?e.CtLGf(a,128)?1:2:e[r(882)](a,2097152)?3:4:e[r(355)](d,16384)?e[r(1423)](d,128)?5:6:e[r(332)](d,2097152)?7:8:e[r(1157)](l,128)?9:10,w=e[r(240)](V,i,g),h=i.bytes;switch(g){case 10:h[e[r(443)](w,9)]=e[r(1509)](e[r(911)](l,7),1);case 9:h[e[r(830)](w,8)]=e[r(931)](9,g)?e[r(1653)](128,l):e[r(249)](127,l);case 8:h[e[r(309)](w,7)]=e[r(953)](8,g)?e[r(478)](d,21)|128:e.lgWyG(e.kLNFy(d,21),127);case 7:h[e[r(1571)](w,6)]=e[r(1456)](7,g)?e[r(473)](e[r(911)](d,14),128):e.KIDcH(e[r(1057)](d,14),127);case 6:h[w+5]=e[r(350)](6,g)?e[r(1660)](d,7)|128:e[r(785)](e.JcDeX(d,7),127);case 5:h[e[r(603)](w,4)]=e.yPEQR(5,g)?128|d:127&d;case 4:h[w+3]=e[r(1367)](4,g)?e[r(1653)](e[r(990)](a,21),128):e[r(1695)](a>>>21,127);case 3:h[e[r(1322)](w,2)]=g!==3?e.XksCC(a,14)|128:e[r(1275)](e[r(1376)](a,14),127);case 2:h[w+1]=e[r(789)](2,g)?e[r(369)](e[r(1432)](a,7),128):e.eRoVu(a,7)&127;case 1:h[w]=e[r(350)](1,g)?128|a:e[r(1553)](127,a)}}function Se(i){return e[n(1262)](k,i)}function pr(i){return e[n(555)](E,i)}let Di=65536,a0=e[n(1218)],ft=e[n(414)](Di,Di),Ri=ft*ft,Li=e[n(1682)](Ri,2),Je=String[n(1321)+"e"][n(812)+"At"];class K{constructor(t,r,a){let d=n;this[d(798)]=!0,this.low=e[d(556)](0,t),this[d(596)]=e.DMAkI(0,r),this[d(1226)]=!!a}static isLong(t){let r=n;return t&&e[r(1264)](!0,t[r(798)])}static fromBits(t,r,a){return new K(t,r,a)}static[n(937)+"s"](t,r,a){let d=n;return a?K[d(937)+"sLE"](t,r):K[d(937)+d(616)](t,r)}static["fromByte"+n(1251)](t,r){let a=n;return new K(e.jMuEv(t[0],e[a(1290)](t[1],8))|e.dpLSO(t[2],16)|e[a(1527)](t[3],24),e[a(369)](e[a(1493)](e.uatuB(t[4],t[5]<<8),t[6]<<16),e[a(1527)](t[7],24)),r)}static[n(937)+n(616)](t,r){let a=n;return new K(e.eaxyt(e.eaxyt(e[a(1085)](e[a(1527)](t[4],24),e[a(508)](t[5],16)),e[a(940)](t[6],8)),t[7]),e[a(473)](e[a(556)](e[a(1411)](t[0],24),t[1]<<16)|e.UKzCX(t[2],8),t[3]),r)}static fromHash(t){let r=n;return e.iPAaL(t,a0)?Ni:new K(e.gMfki(e[r(1041)](e[r(772)](e[r(1547)](Je[r(935)](t,0),e[r(1345)](Je.call(t,1),8)),e[r(508)](Je[r(935)](t,2),16)),Je.call(t,3)<<24),0),e[r(408)](e.OPnYU(e.jGWUv(Je[r(935)](t,4),Je.call(t,5)<<8),e.FXErQ(Je[r(935)](t,6),16)),e.VEACo(Je[r(935)](t,7),24))>>>0,!0)}toHash(){let t=n;return String[t(806)+t(352)](e[t(630)](255,this[t(1237)]),e[t(1134)](this[t(1237)],8)&255,e[t(669)](e.araqB(this[t(1237)],16),255),e[t(710)](this[t(1237)],24),e.yiNHT(255,this.high),e[t(811)](this[t(596)],8)&255,e[t(1697)](e[t(1497)](this.high,16),255),e[t(1432)](this.high,24))}static[n(876)+"er"](t,r=!0){let a=n,d={DOPFI:e[a(1145)],KVGHn:a(500)};if(e[a(518)](isNaN,t))return r?c0:Ni;if(r)if(e.CRgDP(e[a(517)],e.MQoGN)){if(e[a(1330)](t,Ri))return d0}else _0x302a54[a(1136)+a(1630)+a(1558)](AloPBz[a(1401)],_0x382225),_0xb43f49[a(1136)+a(1630)+a(1558)](AloPBz[a(1022)],_0x37af78);else{if(t<=-Li)return f0;if(t+1>=Li)return x0}return K[a(1731)](e[a(408)](e.WxZHD(t,ft),0),e[a(1682)](t,ft)|0,r)}[n(864)](){let t=n;return this[t(1226)]?e.yDqKs(e[t(1528)](e[t(323)](this[t(596)],0),ft),this[t(1237)]>>>0):e.zmFuR(this[t(596)],ft)+e[t(270)](this[t(1237)],0)}isZero(){let t=n;return this[t(596)]===0&&e.ZISkW(0,this[t(1237)])}[n(446)](t){let r=n;K[r(798)](t)||(t=K[r(876)+"er"](t));let a=e[r(1057)](this.high,16),d=65535&this[r(596)],l=this[r(1237)]>>>16,g=e[r(362)](65535,this.low),w=t.high>>>16,h=e[r(1730)](65535,t[r(596)]),y=e[r(1283)](t.low,16),S=65535&t.low,P=0,O=0,L=0,z=0;return z+=e[r(527)](g,S),L+=e[r(1283)](z,16),z&=65535,L+=e[r(487)](l,y),O+=e[r(270)](L,16),L&=65535,O+=e[r(1366)](d,h),P+=e[r(1057)](O,16),O&=65535,P+=e[r(309)](a,w),P&=65535,K[r(1731)](e[r(721)](L<<16,z),e[r(1037)](P<<16,O),this.unsigned)}[n(714)](t){let r=n;return K[r(798)](t)||(t=K[r(876)+"er"](t)),e.ttOEJ(this[r(1226)],t.unsigned)&&e[r(1710)](this[r(596)]>>>31,1)&&e[r(1007)](e[r(1376)](t[r(596)],31),1)?!1:e.iPAaL(this[r(596)],t[r(596)])&&e[r(866)](this[r(1237)],t.low)}[n(974)](){let t=n;return this[t(1237)]===-1&&e[t(1264)](-1,this[t(596)])?K[t(1731)](0,0,this[t(1226)]):e[t(1219)](-1,this.low)?K[t(1731)](0,e.TQwvM(this[t(596)],1),this[t(1226)]):K[t(1731)](e[t(527)](this[t(1237)],1),this[t(596)],this[t(1226)])}[n(1692)](t){return t?this[n(796)+"E"]():this.toBytesBE()}toBytesLE(){let t=n,r=this[t(596)],a=this.low;return[e[t(1084)](255,a),a>>>8&255,e[t(1651)](e[t(1284)](a,16),255),e[t(911)](a,24),e[t(1651)](255,r),e[t(990)](r,8)&255,e[t(1509)](e.qiTMz(r,16),255),e[t(600)](r,24)]}[n(1023)+"E"](){let t=n,r=this.high,a=this[t(1237)];return[e.FnOjd(r,24),e.dRGXg(r>>>16,255),e[t(403)](e[t(717)](r,8),255),e[t(287)](255,r),e[t(1057)](a,24),e[t(858)](e[t(455)](a,16),255),e[t(809)](e.EFHuK(a,8),255),255&a]}}let Ni=new K(0,0,!1),c0=new K(0,0,!0),x0=K[n(1731)](-1,2147483647,!1),d0=K[n(1731)](-1,-1,!0),f0=K[n(1731)](0,-2147483648,!1);var $e=(function(i){let t=n,r=e.LSwLp[t(1627)]("|"),a=0;for(;;){switch(r[a++]){case"0":i[i[e[t(964)]]=5005]=e[t(964)];continue;case"1":i[i[e.tlSZM]=5003]=e[t(1517)];continue;case"2":i[i[e[t(766)]]=5004]=t(1210)+t(994);continue;case"3":return i;case"4":i[i[e[t(409)]]=5001]=e[t(409)];continue;case"5":i[i[e[t(1129)]]=5002]="CONNECTI"+t(524);continue}break}})({});class ut{constructor(t){let r=n,a={JMUBj:e[r(1175)],MxIIR:function(d,l,g){return d(l,g)}};e.eqxAK===e[r(342)]?(this[r(1446)]=t,this.target=null):this[r(423)](a[r(1227)],a[r(1555)](_0x42777f,a.JMUBj,{..._0xf7e8e5}))}}class Oi extends ut{constructor(t,r){let a=n;super(t),this[a(1244)]=r&&r.message||null}}class Mi extends ut{constructor(t,r){let a=n;super(t),this.error=r&&r[a(500)]||null,this.colno=r&&r[a(1405)]||0,this[a(1638)]=r&&r[a(1638)]||"",this.lineno=r&&r.lineno||0,this[a(1244)]=r&&r[a(1244)]||"",this[a(1744)]=r&&r[a(1744)]||5001}}class Bi extends ut{constructor(t,r){let a=n;if(e[a(789)](e[a(1094)],e[a(1094)])){let{url:d}=e[a(1055)](_0x4ae5d6,{}),l=_0x2a5fdf.isArray(d)?d:e[a(1224)](a(660),typeof d)?[d]:[];_0x3ebbde&&_0x1f9079[a(1239)](this[a(407)],_0x45d436),l&&l[a(1395)]?this["_endpoin"+a(1353)]=new _0x2224d2(l,this[a(407)][a(317)+"es"]):this[a(1034)+a(1353)]?.[a(1467)+a(1562)+a(1466)](),this["_pingLos"+a(1215)]?.["resetCou"+a(604)](this[a(407)]["pingLoss"+a(545)]),this[a(435)+a(368)]=!1,this[a(1305)]&&e[a(961)](this[a(1305)][a(1644)+"te"],this[a(1756)])?this[a(1578)+"ect"](1e3,a(857)+"econnect"+a(1256),!0):(this[a(834)]=!0,this[a(1605)]())}else super(t),this[a(1744)]=r&&r.code||0,this[a(259)]=r&&r[a(259)]||"",this[a(1166)]=r&&r[a(1166)]||!1,this[a(1747)+a(1508)]=r&&r[a(1747)+a(1508)]||!1}}class zi extends ut{constructor(t,r){let a=n;super(t),this[a(723)]=r&&r[a(723)]||null}}class Fi extends zi{constructor(t,r){let a=n;super(t),this[a(723)]=r&&r[a(723)]||null,this[a(1244)]=r&&r.message||null}}class Ui extends ut{constructor(t,r){let a=n;super(t),this.data=r&&r[a(723)]||null}}function ye(i,{message:t,code:r,error:a}){return new Mi(i,{message:t,code:r,error:a})}function Ee(i,{code:t,reason:r,wasClean:a,willReconnect:d}){return new Bi(i,{code:t,reason:r,wasClean:a,willReconnect:d})}function qi(i,{data:t,message:r}){return new Fi(i,{data:t,message:r})}function Hi(i,{data:t}){return new Ui(i,{data:t})}function mr(i,{message:t}){let r=n;return e[r(1070)](e[r(1314)],e[r(322)])?new Oi(i,{message:t}):(this[r(1421)+r(279)+r(939)](_0x4449f0),_0xd5c9dd())}class Ki{constructor(t,r){let a=n,d={jwxGd:function(l,g){return e[I(583)](l,g)},SLrQw:function(l,g){return l+g}};if(a(688)===e[a(1418)]){if(_0xb62ee8<=-_0x562df7)return _0x450c57;if(TvOkLY[a(1754)](TvOkLY.SLrQw(_0x504022,1),_0x31789a))return _0x398bc8}else this[a(761)+"s"]=t,this.maxRetries=r,this.currentIndex=0,this[a(1212)+"ndpointTriesCount"]=0}[n(1467)+n(1562)+n(1466)](){let t=n;this[t(243)+"ndex"]=0,this[t(1212)+"ndpointT"+t(852)+"t"]=0}resetTries(){let t=n;this["currentE"+t(456)+t(852)+"t"]=0}[n(849)+n(1098)+"nt"](){let t=n;if(e.TtmTO(e.rmNkl,e[t(1143)]))return this.endpoints[this["currentI"+t(357)]];if(xaWEzb[t(706)](_0x336dad,t(1020)))return _0x9f7397[t(1414)](_0x13b8f5);if(xaWEzb[t(1219)](_0xb9e76a,t(989)+"oreNames"))return _0x57fcd8[t(989)+t(1743)]||_0x258ca9[t(1414)](_0x294191);if(_0x20cc5c===xaWEzb[t(1514)])return _0x579f05[t(989)+t(1743)][1]?void 0:_0xc6390d[t(989)+t(1169)](_0x14fdb9[t(989)+t(1743)][0])}[n(849)+"ntEndpoi"+n(971)+n(1763)](){let t=n;return this[t(1212)+t(456)+"riesCount"]}[n(401)+n(390)+"es"](){let t=n;return!!(e.roxdP(this[t(243)+t(357)],this[t(761)+"s"].length)||e[t(1710)](this[t(243)+t(357)],e[t(1768)](this[t(761)+"s"][t(1395)],1))&&this["currentE"+t(456)+"riesCount"]===this[t(317)+"es"])}[n(1725)+n(507)+n(903)+n(1083)+"tries"](){let t=n;return e[t(602)](e[t(1061)],e.tjjMD)?this[t(1305)]?this[t(1305)][t(271)+"ns"]:"":this["currentI"+t(357)]==this[t(761)+"s"][t(1395)]?!0:e.HiOBS(this[t(1212)+t(456)+"riesCount"],this[t(317)+"es"])}["replaceB"+n(1151)+n(1155)+n(457)+n(1292)](){let t=n;return this[t(1212)+t(456)+t(852)+"t"]=1,this["currentI"+t(357)]++,this[t(761)+"s"][this[t(243)+t(357)]]}["getCurre"+n(1098)+n(1234)+n(800)](){let t=n;if(e[t(956)](t(808),e[t(1445)]))return this[t(1212)+t(456)+t(852)+"t"]++,this[t(849)+t(1098)+"nt"]();{let r=!!this[t(407)][t(942)+"S"];if(!r)return{enabled:r,isQoSMessage:!1,isQoSAck:!1,isAckCleanupMessage:!1,ackMsgIds:[]};let a=e[t(1718)](_0x22ed2d,_0x19e81e[t(1244)][t(1583)],e[t(780)],"2"),d=a&&_0x556481(_0x12dc33[t(1244)][t(1583)],e[t(1396)],"1"),l=a&&_0x2baa10(_0x3750ab[t(1244)][t(1583)],e.YxqdX,"1"),g=l?e[t(377)](_0x4e88c6,_0x51fcb2[t(1244)][t(1583)],e[t(1681)])?.split(",")[t(1223)](_0x44a53a)||[]:[];return{enabled:r,isQoSMessage:a,isQoSAck:d,isAckCleanupMessage:l,ackMsgIds:g}}}}let lt=(e[n(850)](e.kXuno,typeof globalThis)&&e[n(434)]===globalThis[n(620)+n(651)][n(708)]||e.IyVzr(e[n(751)],typeof window)&&e[n(1408)]("Window",window[n(620)+n(651)][n(708)]))&&e[n(559)](e.kXuno,typeof document),it=e[n(1378)](e.kXuno,typeof globalThis)&&(e[n(951)]===globalThis["construc"+n(651)][n(708)]||e[n(1410)]===globalThis["construc"+n(651)].name)&&e[n(731)](n(973)+"d",typeof tt),Ot=(e.kXuno!=typeof globalThis&&e[n(1720)](e[n(951)],globalThis[n(620)+n(651)][n(708)])||e[n(862)](e[n(751)],typeof globalThis)||e.kXuno!=typeof globalThis&&!!globalThis[n(250)+n(835)])&&e[n(1449)](e[n(751)],typeof wx),Mt=e[n(1707)]("undefined",typeof globalThis)&&(e.hJWiP(e[n(1410)],globalThis[n(620)+n(651)][n(708)])||e[n(281)](e.NyTLN,globalThis[n(620)+"tor"][n(708)])||e[n(1501)](e[n(1343)],globalThis[n(620)+n(651)][n(708)]))&&e[n(384)](e[n(751)],typeof self),u0=e.HWucP(n(973)+"d",typeof globalThis)&&n(726)===globalThis[n(620)+n(651)][n(708)]&&e[n(468)](n(973)+"d",typeof global)&&e.LWMbF(e[n(951)],global[n(620)+"tor"][n(708)])&&e[n(993)](n(973)+"d",typeof process)&&!!process.version;class wr{constructor(){this._listeners={}}[n(423)](t,...r){let a=n,d={kkRis:function(l,g,w){return l(g,w)},hrKKC:function(l,g){return l>>>g},GxXiu:function(l,g){return l<<g}};if(e.TuKFN(e.Flecn,e[a(781)])){let{value:l,offset:g}=d[a(836)](_0x323989,_0x22c8e2,_0xfdaadc);_0xf792d2=g,_0x53594d=d[a(1386)](d.GxXiu(_0x3864e2,8),0),_0x2cc85d+=l}else{let l=this._listeners[t];if(l)l[a(366)]().forEach(g=>g.fn[a(361)](g[a(890)],r));else if(e.cKQsm(e.RWYWp,t)&&!this.onerror){let g=r[a(1395)]&&r[0];if(e[a(1612)](g,Error))throw g;let w=new Error(e.orjhc(a(1190)+a(1413),g?e.XuTdj(" (",g[a(1244)])+")":""));throw w[a(927)]=g,g}return this}}[n(663)](t,r){let a=n;if(e[a(1264)](void 0,t))this[a(1745)+"rs"]={};else if(e[a(692)](void 0,r))this[a(1745)+"rs"][t]=null;else{let d=this._listeners[t];if(d)for(let l=0;l<d[a(1395)];)e[a(1007)](d[l].fn,r)?d[a(817)](l,1):++l}return this}on(t,r,a){let d=n;return(this[d(1745)+"rs"][t]||(this[d(1745)+"rs"][t]=[]))[d(1209)]({fn:r,ctx:a||this}),this}}class l0 extends wr{_formatErrorMessage(t){let r=n;return e[r(386)](e[r(762)],e.iBJLK)?e[r(261)](0,this[r(596)])&&e.cKQsm(0,this[r(1237)]):t[r(1258)]||t[r(1573)]?(r(1389)+" "+(t[r(1258)]||"")+r(1759)+(t[r(1573)]||""))[r(697)]():JSON[r(856)+"y"](t)}constructor(t,r,a){let d=n;e[d(866)](e[d(1451)],e[d(349)])?(this[d(1305)]&&this._ws.send(_0x42fb63),this[d(1668)]("send_ack",_0x2fade5)):(super(),this[d(1207)]=null,Ot&&wx[d(1109)+d(496)]&&(this[d(1207)]=wx[d(1109)+d(496)]({url:t,protocols:r,header:a,fail:this[d(611)+d(1214)+"lHandler"][d(1152)](this),success:this._createSocketSuccessHandler[d(1152)](this)})),it&&tt[d(1109)+d(496)]&&(this._socket=tt[d(1109)+d(496)]({url:t,protocols:r,header:a,fail:this[d(611)+d(1214)+d(1096)][d(1152)](this),success:this[d(611)+d(462)+d(1362)+d(822)][d(1152)](this)})))}["_createS"+n(462)+n(1362)+"ler"](){Promise.resolve().then(()=>{this["_addWsLi"+I(1316)]()})}[n(611)+n(1214)+n(1096)](t){let r=n,a={brNMG:e[r(463)],ZlNBM:function(d,l,g){return e[r(1387)](d,l,g)}};Promise[r(1686)]()[r(561)](()=>{let d=r,l=ye(d(500),{message:this[d(628)+d(902)+d(1662)](t)});this[d(423)](a[d(580)],l);let g=a.ZlNBM(Ee,d(1645),{reason:this[d(628)+"rrorMess"+d(1662)](t)});this[d(423)]("close",g)})}[n(1431)+n(1316)](){let t=n,r={yokYH:e[t(1400)],yRiLf:function(a,d,l){return e[t(839)](a,d,l)},bKeNv:"error"};this._socket.onOpen(a=>{let d=t;this[d(423)](r.yokYH,r.yRiLf(Hi,r[d(1656)],{...a,data:a[d(1258)]||""}))}),this[t(1207)][t(256)](a=>{let d=t;this[d(423)](e[d(1175)],Ee(e[d(1175)],{...a}))}),this[t(1207)][t(732)+"e"](a=>{let d=t;this.emit(d(1244),e.aRSzd(qi,e.YWsOZ,{...a}))}),this[t(1207)][t(562)](a=>{let d=t;this.emit(r[d(1729)],ye("error",{...a,message:a[d(1258)]||""}))})}[n(727)](t){let r=n,a={nYjbG:function(d,l,g){return d(l,g)},EXwyg:function(d,l){return e.AYUzq(d,l)},rPXxX:function(d,l){return e.oqEqS(d,l)},UZWfn:function(d,l,g){return e[I(897)](d,l,g)},elmYc:e.RWYWp,Hgbjq:function(d,l,g){return e.skOIa(d,l,g)}};if(e[r(1044)](t,Uint8Array))if(e.SdvZb(e[r(1764)],e.bOHAs)){let d=uGDuMB[r(1325)](_0x408da3,_0x245445,_0x48ca68[r(1030)]),l=_0x38943d[r(1029)],g=_0x53804c.bytes;for(let w=0,h=_0x34c2d5.limit;uGDuMB[r(1459)](w,h);w++)l[uGDuMB.rPXxX(w,d)]=g[w]}else{let d=t[r(1211)].slice(t[r(1182)+"et"],e[r(487)](t.byteLength,t.byteOffset));this[r(1207)]&&this._socket[r(727)]({data:d,fail:l=>{let g=r;this[g(423)]("error",a[g(1652)](ye,"error",{message:this[g(628)+g(902)+"age"](l)}))}})}else this._socket&&this[r(1207)][r(727)]({data:t,fail:d=>{let l=r;this[l(423)](a[l(613)],a[l(655)](ye,a[l(613)],{message:this[l(628)+l(902)+l(1662)](d)}))}})}[n(1645)](t,r){let a=n;this[a(1207)]&&this._socket[a(1645)]({code:t,reason:r})}[n(805)+n(1579)](t,r){this.on(t,r)}[n(1136)+"entListe"+n(1558)](t,r){this[n(663)](t,r)}get[n(1644)+"te"](){let t=n;return this[t(1207)][t(1644)+"te"]}get binaryType(){return this._socket.binaryType}set[n(959)+"pe"](t){}get url(){let t=n,r={Ghffp:t(1206),IOfDz:e[t(648)],YoBxP:e[t(1548)]};if(e[t(1123)]!==e[t(1123)])this[t(1430)+"er"]&&_0x2fb574["addEvent"+t(1579)](r[t(1338)],this[t(999)+t(892)]),this[t(1430)+"er"]&&_0x48fd02["addEvent"+t(1579)](t(1733),this["_handleO"+t(419)]),this[t(1430)+"er"]&&_0x3fea61[t(805)+"Listener"](r[t(260)],this[t(1701)+t(1266)]),this[t(1430)+"er"]&&_0x1a626d[t(805)+"Listener"](r[t(1494)],this[t(1701)+t(283)]);else return this[t(1207)][t(1637)]}get[n(376)](){return this[n(1207)].protocol}get[n(271)+"ns"](){let t=n,r={prsdC:"ping_onc"+t(680)+"s"};if(e.XfPWE!==e[t(1142)])return this._socket[t(271)+"ns"];{let a={QyCuY:function(g,w){return e[t(1161)](g,w)},cXWqt:e[t(1233)],RQfKO:t(1339)+t(680)+"s",WQAXU:e[t(972)]};this[t(1587)+"ngTimer"](),this[t(739)+t(1576)+"Id"]=e[t(442)](_0x25b972,this[t(745)].bind(this),this[t(407)]["pingInte"+t(1253)]);let d=()=>{let g=t;_0x2f1e50(g(1602)),this.off(r[g(724)],d),this[g(663)](g(1339)+g(1700)+"t",l)},l=()=>{let g=t;a[g(1304)](_0x1f9897,a[g(933)]),this.off(a.RQfKO,d),this[g(663)](a[g(272)],l)};this.on(e[t(1684)],d),this.on(e[t(972)],l),this[t(745)]()}}get bufferedAmount(){return 0}}function h0(i,t){let r=n;if(t)return new t(i[r(1637)],i[r(376)]);if(e[r(1291)](Ot,it))return new l0(i.url,i.protocol,i[r(1583)]);if(e[r(1291)](lt,Mt)&&e[r(930)](e[r(751)],typeof WebSocket)&&WebSocket)return new WebSocket(i[r(1637)],i[r(376)+"s"])}function g0(i){let t=n;return!!(i||Ot&&wx["connectS"+t(496)]||it&&tt.connectSocket||e[t(1572)](lt,Mt)&&e.wfhye(e.kXuno,typeof WebSocket)&&WebSocket)}function ji(i,t,r){let a=n,d={fQJui:e[a(1063)],bXDTW:function(w,h){return e[a(1068)](w,h)},vinkO:function(w,h){return w+h}},l=-1;async function g(w){let h=a;return w<=l?Promise.reject(new Error(d.fQJui)):(l=w,d[h(982)](w,r.length)?Promise[h(1686)]():r[w][h(1152)](i)(t,g.bind(null,d[h(1765)](w,1))))}g(0)}function Gi(i){let t=n,r=0,a=0;for(let d=0;e[t(871)](d,i.length);++d)a=i[t(812)+"At"](d),a<128?r+=1:e[t(1080)](a,2048)?r+=2:e[t(1434)](e[t(669)](64512,a),55296)&&e[t(1610)](e[t(1371)](64512,i[t(812)+"At"](e[t(976)](d,1))),56320)?(++d,r+=4):r+=3;return r}function Wi(i,t,r){let a=n;if(e[a(1320)](e[a(1575)],a(1515)))return this[a(1207)][a(959)+"pe"];{if(e[a(1080)](e.UEkMm(r,t),1))return"";let d="";for(let l=t;e[a(1457)](l,r);)if(e[a(1264)](a(654),e[a(1306)])){let g=/(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(_0x2548c1),w=/(([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(_0x90b511);return g?e[a(364)](_0x34e470,_0x4d073c):w?_0x185e6f(_0x44a07d):e[a(288)]}else{let g=i[l++];if(g<=127)d+=String[a(806)+"Code"](g);else if(g>=192&&e.IVsht(g,224))d+=String[a(806)+a(352)](e[a(508)](e.zLRom(31,g),6)|63&i[l++]);else if(e[a(1687)](g,224)&&e.EEWwM(g,240))d+=String[a(806)+a(352)](e[a(1493)](e[a(335)](e[a(1678)](e.dGexv(15,g),12),e[a(1295)](e[a(297)](63,i[l++]),6)),63&i[l++]));else if(e[a(516)](g,240)){let w=e[a(1586)](e[a(656)](e[a(268)](e[a(670)](7&g,18),e[a(568)](63,i[l++])<<12),e[a(591)](63&i[l++],6))|e[a(1275)](63,i[l++]),65536);d+=String[a(806)+a(352)](e[a(725)](55296,e[a(757)](w,10))),d+=String[a(806)+"Code"](e.oGwKN(56320,e.qjkju(1023,w)))}}return d}}function _r(i,t,r){let a=n;if(e[a(919)](e[a(1329)],e[a(1422)]))return{frameType:_0x5e2f3d,headers:[{key:e[a(398)],value:e.tdbXh}],payload:void 0};{let d=r,l,g;for(let w=0;e[a(695)](w,i[a(1395)]);++w)if(l=i[a(812)+"At"](w),e[a(1666)](l,128))t[r++]=l;else if(e[a(355)](l,2048))t[r++]=l>>6|192,t[r++]=e[a(1139)](63,l)|128;else if(e[a(1219)](64512&l,55296)&&e[a(602)](e[a(287)](64512,g=i[a(812)+"At"](e[a(1667)](w,1))),56320)){let h=e[a(793)][a(1627)]("|"),y=0;for(;;){switch(h[y++]){case"0":t[r++]=e[a(534)](l,6)&63|128;continue;case"1":l=e[a(479)](e[a(1404)](65536,e.FLXvu(e[a(1139)](1023,l),10)),e.pNxMJ(1023,g));continue;case"2":t[r++]=e[a(1089)](e[a(426)](l,18),240);continue;case"3":t[r++]=e[a(247)](63,l)|128;continue;case"4":++w;continue;case"5":t[r++]=e[a(801)](e[a(480)](l>>12,63),128);continue}break}}else t[r++]=e[a(1198)](e.RKdcq(l,12),224),t[r++]=e[a(1588)](e[a(567)](e[a(1577)](l,6),63),128),t[r++]=e[a(1483)](63,l)|128;return r-d}}async function Ji(i){let t=n;if(e[t(378)]==typeof i){let r=new Uint8Array(e[t(365)](Gi,i));return e.ypbIu(_r,i,r,0),r}return e.XofDs(i,ArrayBuffer)?new Uint8Array(i):new Uint8Array(i[t(1211)],i.byteOffset,i.byteLength)}function p0(i){let t=n,r={HQaRu:function(a,d){return e[I(1550)](a,d)},gAWft:function(a,d){return a===d}};try{if(e[t(703)](e[t(1658)],e[t(1658)]))return e[t(378)]!=typeof i&&(e[t(482)](i,ArrayBuffer)||i[t(1211)]&&e[t(1612)](i.buffer,ArrayBuffer))||t(660)!=typeof i?"":(JSON[t(1462)](i),e[t(1265)]);{let a=this[t(1745)+"rs"][_0x2d0b36];if(a)for(let d=0;fdpZmZ[t(824)](d,a.length);)fdpZmZ[t(693)](a[d].fn,_0x4d40d6)?a[t(817)](d,1):++d}}catch{return e[t(643)](t(660),typeof i)?e.Yfbjq:""}}let m0=(i,t)=>{let r=n;switch(i){case e[r(998)]:case r(947):return{[r(635)+i]:1,"x-tt-env":t};default:return{}}};class w0{constructor(t){let r=n;this[r(833)+r(1763)]=t,this[r(1196)]=0}[n(1473)](){let t=n;this[t(1196)]++}[n(401)+n(1591)+"nt"](){let t=n;return this[t(1196)]>=this[t(833)+t(1763)]}["resetCou"+n(604)](t=0){let r=n;this[r(833)+r(1763)]=t,this[r(1196)]=0}}async function _0(i){let t=n,r={wNvBd:function(a,d){return e.RNnVg(a,d)},XPlDz:e[t(1001)],bRbxy:function(a,d){return e[t(692)](a,d)},bBOaL:e[t(318)],qSJnd:function(a,d){return e[t(422)](a,d)},cBLyY:function(a,d){return a!==d},siYuq:e.cxROZ,OdMyx:e[t(1724)],KDeun:e[t(302)],VNEby:function(a,d){return e.gXZdD(a,d)},aseiK:e[t(502)],xNGzN:e[t(1585)]};return new Promise(a=>{let d=t,l={PkfOr:d(1339)+d(680)+"s",tTBzA:"success"};if(r.bRbxy(r.bBOaL,d(1294)))this[d(1587)+d(266)](),this.emit(l.PkfOr,l[d(1715)]),this[d(739)+d(1576)+"Id"]=_0x117cdd(this._ping.bind(this),_0x4ae91c);else{if(!lt)return r.qSJnd(a,d(823)+d(259));try{if(r[d(1073)](r.siYuq,r[d(340)])){let g=document["createEl"+d(905)](d(634));window[d(657)+d(1006)]=w=>{let h=d;document[h(429)][h(924)+"ild"](g),window[h(657)+"JSONP"]=void 0,r[h(1767)](a,w&&w.msg||r[h(918)])},g.type=r[d(633)],g.src=r[d(1569)](i.replace(/^ws/,r[d(326)]),r[d(1053)]);try{document[d(429)]["appendCh"+d(1095)](g)}catch{document[d(429)][d(924)+d(1095)](g)}}else return this[d(1305)]?this[d(1305)][d(1637)]:this[d(729)]}catch{window["frontier"+d(1006)]=void 0,a(d(823)+d(259))}}})}function Ve(i,t,r){let a=n;return!!i?.[a(701)](d=>d[a(1454)]===t&&d[a(1425)]===r)}function ht(i,t){let r=n;return e.ohWyO!==e[r(292)]?((this[r(1745)+"rs"][_0x2d46ef]||(this._listeners[_0x506f8e]=[])).push({fn:_0x51e808,ctx:_0x3814cd||this}),this):i?.[r(701)](a=>a[r(1454)]===t)?.[r(1425)]}let yr=null;async function y0(){let i=n;return yr||(yr=Promise.resolve().then(Le[i(1152)](Le,e.PsAgI))),yr}class b0 extends wr{constructor(t,r){let a=n;super(),this[a(440)]=t,this._keyPath=r,this[a(331)]=void 0,this[a(1646)+a(1040)]=null}async openDB(){let t=n;if(e[t(983)](e[t(1504)],e[t(880)]))await this[t(551)]();else return _0x1e5302.writeUint8?_0x2c74af[t(1e3)+"t8"](_0x945b10,_0x38ea62):_0xab9081[_0x18f723]=255&_0xed8199,_0x21ef34+1}async[n(551)](){let t=n,r={LVbRl:t(679),iWoBt:e[t(463)],mGGZB:e.rKfFf};if(e[t(320)]!==e[t(320)])_0x4eba76["removeEv"+t(1630)+"ner"](fsRtVF[t(1358)],_0x288c91),_0xdbd5a4[t(1136)+t(1630)+"ner"](fsRtVF[t(1333)],_0x2c970a),_0x16e6fe[t(1136)+t(1630)+"ner"](fsRtVF[t(1222)],_0x522b95);else{if(this[t(331)])return;if(this["_initPro"+t(1040)])return this[t(1646)+t(1040)];try{let a=this[t(440)],d=this._keyPath;this["_initPro"+t(1040)]=(async()=>{let l=t,{openDB:g}=await e[l(1130)](y0);this[l(331)]=await e.CUOSg(g,l(657)+"_"+a,1,{upgrade(w){let h=l;w[h(1100)+h(1592)+"e"](a,{keyPath:d})}})})(),await this[t(1646)+t(1040)]}catch(a){console[t(242)](a)}finally{this[t(1646)+t(1040)]=null}}}async[n(1414)](t){let r=n;try{return await this._init(),this[r(331)]?.[r(1414)](this[r(440)],t)}catch(a){console.log(a)}}async[n(853)](t,r){let a=n;return await this[a(551)](),this[a(331)]?.[a(1368)](this._dbName,t)}async[n(1268)](t){let r=n;try{return await this[r(551)](),this._qosDB?.[r(1205)](this[r(440)],t)}catch(a){if(e[r(961)](e[r(1090)],"zjLny"))return _0xd30804[r(989)+r(1743)]||_0x2f6253.get(_0x54d5fd);console.log(a)}}async[n(1419)](){let t=n,r={VrCHU:function(a,d){return a instanceof d},kMVAC:function(a,d){return e[I(1516)](a,d)},IsPuL:function(a,d){return e[I(1149)](a,d)},GJuhL:function(a,d){return e[I(418)](a,d)}};try{if(e[t(1007)]("viQpx",e[t(641)]))return await this._init(),this._qosDB?.[t(1419)](this[t(440)]);{if(mrRmsn.VrCHU(_0x3e66ad,_0x35bb7a))return mrRmsn[t(575)](_0x5b16f0,_0x5c7e9a);if(_0x4cfc0e.has(_0x3897a3))return _0x24c491.get(_0x28730d);let a=mrRmsn[t(504)](_0x6a9d73,_0x1018de);return mrRmsn.GJuhL(a,_0x4a6377)&&(_0x5f0d0e[t(853)](_0x2bcad7,a),_0x3bc56a[t(853)](a,_0x460d88)),a}}catch(a){console[t(242)](a)}}async[n(1511)](){let t=n;return await this[t(551)](),this[t(331)]?.[t(522)+"ys"](this[t(440)])}async[n(1439)](){let t=n;if(e[t(602)](e.IbMXS,e[t(391)])){let{SeqID:r,LogID:a,service:d,LogIDNew:l,method:g}=_0x3eb531[t(1244)];this[t(774)]({SeqID:r,LogID:a,LogIDNew:l,service:d,method:g,headers:[{key:e.xLnoI,value:"1"},{key:e[t(1340)],value:e[t(1291)](l,"")},{key:"ack_code",value:"0"}]})}else return await this[t(551)](),this[t(331)]?.[t(1439)](this[t(440)])}async[n(1248)](){let t=n;if(e[t(544)](t(1545),e[t(1361)]))try{e[t(1623)](e[t(315)],e[t(315)])?(_0x1bccaa+=e[t(1760)](_0x2d3eff,_0x2d04ec),_0x1be71d++):(this[t(331)]?.[t(1645)](),this._qosDB=void 0)}catch(r){console[t(242)](r)}else return this._qosDB[t(1419)]()}get[n(381)](){let t=n;try{return!!this[t(331)]}catch(r){return console[t(242)](r),!1}}}class v0{constructor(t,r){let a=n,d={DqIVf:function(l,g){return e.iNBkJ(l,g)},oaKAL:function(l,g){return e[I(325)](l,g)},VbRFX:function(l,g){return e[I(672)](l,g)},cegLj:function(l,g){return e[I(889)](l,g)},UNFLk:function(l,g){return e[I(538)](l,g)}};if(e[a(815)](e[a(719)],"GiyBC"))return new _0xe045e2(usyRYh[a(704)](usyRYh[a(1608)](_0x564c38[0]|usyRYh[a(245)](_0x42c7a7[1],8),usyRYh[a(245)](_0x1dc4d5[2],16)),_0x53ba77[3]<<24),usyRYh.cegLj(usyRYh[a(1487)](_0x2417f1[4],_0x3c186a[5]<<8)|usyRYh[a(245)](_0x35e62c[6],16),usyRYh[a(245)](_0x1cd031[7],24)),_0x242930);this[a(439)]=t,this[a(1629)]=r,this._qosDB=localStorage}async[n(1450)](){}get[n(1119)](){return"frontier_"+this._DBName}async[n(1414)](t){let r=n;if(e[r(350)](e[r(598)],e.dirEs))this[r(308)+r(1526)]();else{let a=this._qosDB.getItem(this[r(1119)]);return JSON.parse(e[r(1703)](a,"{}"))[t]}}async set(t,r){let a=n,d=this[a(331)].getItem(this[a(1119)]),l=JSON[a(1462)](e[a(370)](d,"{}"));return l[r||t[this[a(1629)]]]=t,this[a(331)][a(920)](this[a(1119)],JSON[a(856)+"y"](l)),r||t[this[a(1629)]]}async[n(1268)](t){let r=n,a=this._qosDB.getItem(this[r(1119)]),d=JSON[r(1462)](e[r(681)](a,"{}"));return d[t]=void 0,this[r(331)][r(920)](this[r(1119)],JSON[r(856)+"y"](d))}async[n(1419)](){return this[n(331)].clear()}async[n(1511)](){let t=n,r=this[t(331)][t(530)](this[t(1119)]),a=JSON[t(1462)](e[t(1703)](r,"{}"));return Object.keys(a)}async getAll(){let t=n,r=this._qosDB[t(530)](this[t(1119)]),a=JSON[t(1462)](e[t(1055)](r,"{}"));return Object.values(a)}[n(1248)](){return Promise[n(1686)]()}get[n(381)](){return!!this[n(331)]}}class S0{constructor(t,r){let a=n;this[a(439)]=t,this[a(1629)]=r,this._qosDB=it?tt:Ot?wx:null}async[n(1450)](){}get _prefix(){let t=n;return t(657)+"_"+this[t(439)]}async[n(1414)](t){let r=n,a=this[r(331)][r(1541)+r(1163)](this[r(1119)]);return JSON[r(1462)](e.msQvv(a,"{}"))[t]}async[n(853)](t,r){let a=n,d=this[a(331)][a(1541)+a(1163)](this[a(1119)]),l=JSON[a(1462)](e[a(469)](d,"{}"));return l[r||t[this[a(1629)]]]=t,this._qosDB[a(936)+a(1163)](this[a(1119)],JSON[a(856)+"y"](l)),r||t[this[a(1629)]]}async[n(1268)](t){let r=n,a=this[r(331)][r(1541)+r(1163)](this[r(1119)]),d=JSON.parse(a||"{}");return d[t]=void 0,this[r(331)][r(936)+"geSync"](this[r(1119)],JSON[r(856)+"y"](d))}async clear(){let t=n,r={TXzKd:function(a,d){return e[I(603)](a,d)},rcCQq:function(a,d){return e[I(527)](a,d)},vOsbg:function(a,d){return e[I(350)](a,d)},oVYRA:function(a,d){return e[I(963)](a,d)},Fqbdf:function(a,d){return e[I(1691)](a,d)},KfCXg:function(a,d){return e[I(1717)](a,d)},BZhbD:function(a,d){return e[I(1742)](a,d)},kNdEv:function(a,d){return e.CCRHj(a,d)},dkcIN:function(a,d){return e.pQdEO(a,d)},gsokA:function(a,d){return e[I(988)](a,d)},ZdwlJ:function(a,d){return e[I(1153)](a,d)},Zryie:function(a,d){return a(d)}};if(e.cKQsm(t(879),e[t(234)]))_0x51b142=_0x442e84[uJTISz[t(1595)](uJTISz[t(1595)](_0x48196e,_0x5f412d),1)],_0x285025=_0x480b8f[uJTISz.TXzKd(uJTISz.rcCQq(_0x25bc3d,_0x544f0b),2)],uJTISz[t(1581)](uJTISz[t(624)](_0x16bd33|uJTISz[t(379)](_0x58cc3e,8),49344),32896)?_0x52343d+=_0x55d1b0:(_0x24f865=uJTISz[t(1309)](uJTISz[t(1126)](15,_0xb32e9f)<<12|uJTISz.kNdEv(uJTISz[t(569)](63,_0xf1372e),6),63&_0x318d1b),_0x3a649e<2048||uJTISz[t(1478)](_0x2b08ba,55296)&&uJTISz[t(327)](_0x5868af,57343)?_0x382249+=_0x2fa0e8:(_0x55c179+=uJTISz.Zryie(_0x1c9bc3,_0x39c57a),_0x18d37d+=2));else return this[t(331)]["clearSto"+t(265)]()}async[n(1511)](){let t=n,r=this[t(331)][t(1541)+t(807)+"nc"](this[t(1119)]),a=JSON.parse(r||"{}");return Object.keys(a)}async[n(1439)](){let t=n,r=this._qosDB[t(1541)+t(807)+"nc"](this[t(1119)]),a=JSON[t(1462)](e[t(1354)](r,"{}"));return Object[t(304)](a)}[n(1248)](){return Promise[n(1686)]()}get[n(381)](){return!!this[n(331)]}}function $i(i,t){let r=n;if(e[r(1354)](it,it))return new S0(i,t);if(e.yyute(lt,Mt)&&e.NpNly(r(973)+"d",typeof indexedDB))return new b0(i,t);if(e.aheUA(lt,Mt)&&e.kXuno!=typeof localStorage)return new v0(i,t);throw new Error(e[r(246)])}class E0{constructor(){let t=n;this[t(308)+"lTimeoutId"]=null,this[t(308)+"l"]=36e5,this[t(331)]=$i(e[t(1669)],e[t(558)])}async[n(308)+"lFlush"](){let t=n,r={rmJUD:e[t(420)],cIiKU:function(a,d){return a===d},Plets:t(1503),Uyxdf:e[t(1437)]};e[t(1323)](clearInterval,this._intervalTimeoutId),this[t(308)+t(685)+"Id"]=e.Vkxsy(setInterval,()=>{let a=t;r[a(492)](r.Plets,r[a(1373)])?(this[a(423)](r[a(854)],_0x4d14fd),this[a(968)+a(601)]&&this[a(968)+a(601)](_0x591c50)):this[a(389)+a(1674)]()},this[t(308)+"l"])}async[n(1450)](){let t=n;await this[t(331)][t(1450)]()[t(561)](()=>{this._intervalFlush()})}async[n(389)+n(1674)](){let t=n;(await this[t(331)]?.getAll()||[]).filter(({timestamp:d})=>d<Date[t(1442)]())[t(1193)](d=>{let l=t;this[l(331)]?.[l(1268)](d.message_id)})}async[n(1268)](t){let r=n;return this._qosDB?.[r(1268)](t)}async[n(853)](t,r){let a=n;return this[a(331)]?.[a(853)]({message_id:t,timestamp:r})}async[n(1414)](t){let r=n;return this[r(331)]?.[r(1414)](t)}async[n(1248)](){let t=n;e[t(416)](e[t(896)],t(827))?(this[t(833)+t(1763)]=_0x232907,this[t(1196)]=0):(e[t(1622)](clearInterval,this[t(308)+t(685)+"Id"]),await this[t(331)]?.closeDB())}get[n(381)](){let t=n;return this[t(331)]?.[t(381)]}}function br(i){let t=n;if(e[t(1068)](e[t(946)],e.mZiJU)){let r=_0x55e8c8.key;e[t(855)](void 0,r)&&(e[t(312)](_0x1af550,_0x5b4586,10),_0x363a1b(_0x5504b4,r));let a=_0x4f1d9e[t(1425)];e[t(877)](void 0,a)&&(e[t(560)](_0x6163d7,_0xf0331,18),_0x34574e(_0x55508d,a))}else{let r=!!this[t(407)][t(942)+"S"];if(!r)return{enabled:r,isQoSMessage:!1,isQoSAck:!1,isAckCleanupMessage:!1,ackMsgIds:[]};let a=e.WCvwe(Ve,i.message[t(1583)],e.TdCYb,"2"),d=a&&Ve(i.message[t(1583)],e[t(1396)],"1"),l=a&&Ve(i[t(1244)][t(1583)],e[t(447)],"1"),g=l?e[t(1659)](ht,i[t(1244)][t(1583)],e[t(1681)])?.[t(1627)](",")[t(1223)](Boolean)||[]:[];return{enabled:r,isQoSMessage:a,isQoSAck:d,isAckCleanupMessage:l,ackMsgIds:g}}}async function Vi(){let i=n;return this[i(1752)+i(1352)]||(this[i(1752)+i(1352)]=new E0),this["_QoSMana"+i(1352)][i(381)]||await this[i(1752)+i(1352)][i(1450)](),this["_QoSMana"+i(1352)]}async function C0(i,t){let r=n,{enableAutoAck:a}=this[r(407)],d=Ve(i[r(1244)][r(1583)],r(908),"1"),l=e[r(1296)](Ve,i[r(1244)][r(1583)],e[r(445)],"1"),g=br.call(this,i);if(a&&d){let{SeqID:w,LogID:h,service:y,LogIDNew:S,method:P}=i[r(1244)];this[r(774)]({SeqID:w,LogID:h,LogIDNew:S,service:y,method:P,headers:[{key:r(1420),value:"1"},{key:e[r(1340)],value:S||""},{key:e.ybMck,value:"0"}]})}l&&!g[r(843)]&&this["_dispatc"+r(1125)+r(592)](i),t()}async function A0(i,t){let r=n;this[r(1668)](r(277),i.message),t()}async function I0(i,t){let r=n;if(e.uKnTT===e[r(599)]){let a=e[r(715)](Se,await Ji(i[r(723)]));try{if(e[r(1612)](a[r(621)],Uint8Array)){let d=e[r(1436)](this[r(407)][r(1049)+"ncoding"],Object)?{force:!!this[r(407)][r(1049)+"ncoding"][r(237)],encoding:this[r(407)]["payloadE"+r(1313)].encoding?this[r(407)][r(1049)+r(1313)][r(354)].replace(/\s/g,"")[r(1424)+r(1761)]():""}:{force:!1,encoding:this._options["payloadE"+r(1313)]?this._options[r(1049)+"ncoding"].replace(/\s/g,"")[r(1424)+r(1761)]():""},l=a[r(1049)+r(1313)]?a["payloadE"+r(1313)][r(1757)](/\s/g,"")[r(1424)+r(1761)]():"",g=this._options[r(430)+r(716)]instanceof Object?{force:!!this._options[r(430)+r(716)][r(237)],type:this._options[r(430)+r(716)].type?this[r(407)]["payloadT"+r(716)].type[r(1757)](/\s/g,"")["toLowerC"+r(1761)]():""}:{force:!1,type:this[r(407)][r(430)+r(716)]?this[r(407)]["payloadT"+r(716)][r(1757)](/\s/g,"")["toLowerC"+r(1761)]():""},w=a[r(430)+"ype"]?a[r(430)+r(716)][r(1757)](/\s/g,"")["toLowerC"+r(1761)]():"",h=g[r(237)]?g.type:w||g[r(1446)],y=d[r(237)]?d[r(354)]:l||d[r(354)],S=[e[r(1045)],e.OToNr,e[r(1179)],e[r(378)]],P=[e[r(1293)],e[r(1549)]];this[r(407)][r(1173)+r(1428)+r(1676)+"ad"]&&S[r(986)](h)&&(!y||P[r(986)](y))?a["textPayl"+r(1249)]=e[r(1641)](Wi,a.payload,0,a[r(621)][r(576)+"th"]):a.textPayload=""}else a["textPayl"+r(1249)]=""}catch(d){a[r(497)+"oad"]="",console[r(242)](d)}i.message=a,e[r(1130)](t)}else{if(_0x15cb17(_0x587047))return _0x9d1959?_0x2f0dcd:_0x4163be;if(_0x291fd5){if(e[r(587)](_0x292494,_0x215c6e))return _0x38ff5d}else{if(e.DlJYi(_0x844e2,-_0x8e00af))return _0x4c5307;if(e[r(1444)](_0x1b5ec3+1,_0x43ca55))return _0x1e0085}return _0x55b809[r(1731)](e[r(1653)](e[r(1601)](_0x22765b,_0x5b0ede),0),e[r(411)](e[r(1682)](_0x16c991,_0x581435),0),_0x1c6fcf)}}function k0(i,t,r){let a=n,d=e[a(1572)](r,8192),l=e.vDiKv(d,1),g=null,w=d;return function(h){let y=a;if(e[y(393)](h,1)||h>l)return e.lDpHv(i,h);e.RzAOU(e[y(977)](w,h),d)&&(g=e[y(1262)](i,d),w=0);let S=t.call(g,w,w+=h);return e[y(568)](7,w)&&(w=e[y(309)](e[y(845)](7,w),1)),S}}let P0=4294967295;function T0(i,t,r){let a=n;return e[a(1471)](RangeError,e.TauNb(e[a(479)](e[a(1667)](e[a(1050)](a(1147)+a(1199)+"ge: ",i),a(1469))+(t||1),e[a(307)]),r))}function D0(i,t,r){let a=n;if(e[a(776)](r,P0))throw new Error(e.lbPLr);let d=3;for(;e.RQvIO(d,0);){let l=e[a(1351)](255,r);e.IPNbq(Sr,l,i,e[a(977)](t,d)),r>>>=8,d--}return e[a(1012)](t,4)}function R0(i,t){let r=n;if(e[r(1610)](e[r(371)],e[r(353)]))return this[r(331)]?.isReady;{let a=0,d=t,l=e[r(363)](t,4);for(;d<l;){let{value:g,offset:w}=vr(i,d);d=w,a=a<<8>>>0,a+=g}return{value:a,offset:l}}}function L0(i,t,r){let a=n,d=e[a(392)][a(1627)]("|"),l=0;for(;;){switch(d[l++]){case"0":return e.nmDAK(e[a(1122)](_r,i,t,r),r);case"1":if(t[a(1302)])return e[a(1012)](t[a(1302)](i,r),r);continue;case"2":if(t.utf8Write)return t[a(321)+"e"](i,r)+r;continue;case"3":if(!i)return r;continue;case"4":if(i.length<40)return e.NOzEH(e[a(944)](_r,i,t,r),r);continue}break}}function N0(i,t){let r=n,a=new K(e[r(778)](e[r(889)](e[r(324)](i[e[r(1356)](t,4)],24),i[e[r(1039)](t,5)]<<16)|i[e[r(1225)](t,6)]<<8,i[e[r(348)](t,7)]),e[r(1493)](e[r(1191)](i[e[r(488)](t,0)],24),e.FXErQ(i[t+1],16))|e[r(241)](i[e.jpMnh(t,2)],8)|i[e[r(1706)](t,3)],!0);return t+=8,{value:a,offset:t+8}}function O0(i,t,r){let a=n,d=i[a(1237)],l=i[a(596)];return t[r]=e.DQKYr(l,24),t[e[a(830)](r,1)]=e[a(403)](l>>>16,255),t[r+2]=e[a(1289)](l>>>8,255),t[e.FRizk(r,3)]=e[a(1065)](255,l),t[e[a(443)](r,4)]=e[a(1355)](d,24),t[e.eysVc(r,5)]=e.JtsSC(d>>>16,255),t[e[a(743)](r,6)]=e[a(1084)](e[a(691)](d,8),255),t[e.LjMkm(r,7)]=e[a(297)](255,d),r+=8,r}function vr(i,t){let r=n;return i[r(533)+"8"]?{value:i[r(533)+"8"](t),offset:e[r(488)](t,1)}:{value:e[r(568)](255,i[t]),offset:e[r(1356)](t,1)}}function Sr(i,t,r){let a=n;return t[a(1e3)+"t8"]?t[a(1e3)+"t8"](i,r):t[r]=e.yjsZh(255,i),e[a(330)](r,1)}let M0=function(i){return new Uint8Array(i)},B0=e[n(384)](n(973)+"d",typeof Buffer)?Buffer[n(1188)+n(1011)]:e.lVtju(k0,M0,Uint8Array.prototype[n(1103)]),z0=16,Er=32;function F0(i){let t=n,r=0,a={};for(let d=0;e[t(1457)](d,i[t(1395)]);d++)a[i[d][t(966)+"ame"]]=e.yhKCr(Gi,i[d][t(966)+t(615)]),r+=e[t(309)](14,a[i[d][t(966)+"ame"]]);return[r,a]}function Xi(i,t,r){let a=n,[d,l]=e[a(1158)](F0,i),g=e[a(1149)](B0,d),w=0;return i[a(1193)](h=>{let y=a,S=e.BWIiP.split("|"),P=0;for(;;){switch(S[P++]){case"0":console.log(y(708),w);continue;case"1":w=L0(h[y(966)+y(615)],g,w);continue;case"2":console[y(242)](e[y(1127)],h,h[y(1712)]);continue;case"3":w=Sr(l[h[y(966)+y(615)]],g,w);continue;case"4":console[y(242)](e[y(755)],w);continue;case"5":w=e.dCgdQ(Sr,0,g,w);continue;case"6":w=D0(g,w,h.service||0);continue;case"7":w=e[y(1296)](O0,K.fromNumber(h[y(914)]||t),g,w);continue;case"8":console[y(242)](e[y(1488)],w);continue;case"9":console[y(242)](e.WnfuR,w);continue;case"10":console.log(e[y(1003)],w);continue}break}}),{frameType:Er,headers:[{key:e[a(398)],value:r}],payload:g}}function U0(i){let t=n,r=0,a=[];for(;r<i[t(576)+"th"];){let{offset:d}=e.RtMZT(vr,i,r);r=d;let l={cursor_name:"",cursor:0,service:0},{value:g,offset:w}=R0(i,r);l[t(1712)]=g,r=w;let{value:h,offset:y}=e[t(531)](vr,i,r);r=y,l[t(966)+t(615)]=e[t(1122)](Wi,i,r,e[t(1099)](r,h)),r+=h;let{value:S,offset:P}=N0(i,r);l[t(914)]=S[t(864)](),r=P,a[t(1209)](l)}return a}function q0(){let i=n;return{frameType:Er,headers:[{key:e[i(398)],value:e[i(412)]}],payload:void 0}}class H0{constructor(t,r,a){let d=n;this[d(1604)+d(1280)]=t,this[d(1087)+"ileName"]=r,this[d(345)+d(566)]=a,this[d(331)]=e[d(1081)]($i,this[d(1604)+"ameSpace"],d(966)+d(615))}async[n(1450)](){let t=n;await this[t(331)][t(1450)]()}async[n(639)+"rs"](){let t=n;if(!this[t(331)][t(381)])return;let r=this[t(345)+t(566)],a=await this[t(331)][t(1439)]();switch(console[t(242)](e.rJOuS,a),r){case e[t(1170)]:return a&&a[t(1395)]?e.lczZJ(Xi,a,0,this[t(1087)+t(1617)]):void 0;case e[t(425)]:return;case t(1594):return a&&a[t(1395)]?Xi(a,0,this["_cursorF"+t(1617)]):e[t(1130)](q0)}}async[n(853)](t,r,a){let d=n;return console.log("setdb",t,r,a),this[d(331)].set({cursor_name:t,cursor:r,service:a})}async[n(1540)+"rs"](t){let r=n,a=U0(t);for(let d of a)console[r(242)](e[r(794)],a),await this[r(331)][r(853)](d)}async[n(1414)](t){let r=n;return(await this[r(331)][r(1414)](t))?.[r(914)]}async[n(1248)](){let t=n;await this[t(331)][t(1248)]()}[n(907)+n(838)+n(820)](t){let r=n;this[r(1087)+"ileName"]=t}get[n(381)](){let t=n;return this[t(331)][t(381)]}}let K0=e.YXOCA;async function Yi(i){let t=n;if(!this[t(407)].enableQoS)return null;let{aID:r,fpID:a,messageStrategy:d}=this._options,l=i||K0;try{if(e[t(503)]!==e[t(505)])return this[t(954)+t(319)]?i&&this._cursorManager["updateCu"+t(838)+t(820)](i):this["_cursorM"+t(319)]=new H0(a+"_"+r+"_"+l,l,d),this[t(954)+t(319)][t(381)]||await this[t(954)+"anager"][t(1450)](),this[t(954)+t(319)];this[t(389)+"ired"]()}catch{return null}}async function j0(i,t){let r=n,a=e.cZdNw(Ve,i[r(1244)][r(1583)],e[r(1584)],"-1"),d=Ve(i[r(1244)][r(1583)],e[r(445)],"1"),l=e[r(860)](ht,i[r(1244)][r(1583)],e[r(284)]),g=e[r(1749)](Number,e[r(298)](ht,i[r(1244)][r(1583)],e[r(1336)]))||0,w=br[r(935)](this,i),h=e.FPFJb(Ve,i.message[r(1583)],r(1342)+"s","2"),y=e[r(273)](ht,i[r(1244)][r(1583)],r(929)+r(1455)+"e"),S=e[r(1385)](Number,e[r(1261)](ht,i[r(1244)][r(1583)],e[r(595)]));if(w[r(843)])return e[r(1130)](t);let P=w[r(1271)+r(699)]?await Vi[r(935)](this):null;if(e[r(470)](i[r(1244)][r(1712)],0)&&d&&!a||e[r(645)](i.message.service,0)){if(l&&w[r(1271)+"sage"]&&P)return!!!await P[r(1414)](l)&&(e[r(602)](e[r(1168)],e[r(1168)])?(this[r(1421)+r(279)+"Event"](i),await P[r(853)](l,e.TWNWL(Date.now(),g))):(_0xf8e598[_0x1d296c++]=e.KIDcH(e[r(1577)](_0x1f0419,18),7)|240,_0xdc8de4[_0x593ccd++]=e.tNppc(e.qBgwm(_0x45e1fc,12)&63,128))),t();if(h){let O=await Yi.call(this);if(!O)return this["_dispatc"+r(279)+r(939)](i),e[r(1406)](t);let L=await O.get(y)??-1;if(e.xwqoH(L,S))if(e[r(983)]("eKdJA",e[r(1519)]))this["_dispatc"+r(279)+r(939)](i),O[r(853)](y,S,i[r(1244)].service);else{let z=_0x19c126[_0x1f04d7++];if(e.DlJYi(z,127))_0x3b046b+=_0xe7dd87[r(806)+r(352)](z);else if(e[r(1698)](z,192)&&e[r(1299)](z,224))_0x236ad1+=_0x1ee244[r(806)+"Code"](e[r(1246)](e.ynxwg(e[r(509)](31,z),6),e[r(1289)](63,_0xb1e2ef[_0x1cf258++])));else if(z>=224&&e.cTtth(z,240))_0x13cadc+=_0x2a9bce[r(806)+r(352)](e[r(1085)](e.nJBqa(e[r(837)](15,z),12),e[r(1411)](e[r(809)](63,_0x41fa3b[_0x1ac8c1++]),6))|e[r(1052)](63,_0x2828e3[_0x38a50d++]));else if(z>=240){let W=e.UEkMm(e[r(967)](e.DyKBO(e[r(1194)](7&z,18),e[r(1250)](e[r(614)](63,_0x5aa04f[_0x1a1983++]),12)),e[r(1527)](e.UVIgy(63,_0x56dc37[_0x1251cd++]),6))|e[r(510)](63,_0x5de87e[_0x4a5608++]),65536);_0x5f35b8+=_0x2d8a84[r(806)+r(352)](e[r(1298)](55296,e.xADHD(W,10))),_0x2e385e+=_0x3ac922["fromChar"+r(352)](e[r(1714)](56320,e.PhDLE(1023,W)))}}else throw new Error(r(291)+r(1642)+r(528)+S+(r(1137)+r(1375)+"al cursor ")+L);return e[r(730)](t)}return this[r(1421)+r(279)+r(939)](i),e[r(1279)](t)}}async function G0(i,t){let r=n,a=br[r(935)](this,i);if(!a[r(1271)+r(699)])return e[r(1130)](t);let d=await Vi.call(this);if(a[r(1229)+r(1252)+r(1662)]&&a[r(1721)+"s"][r(1395)])for(let l of a.ackMsgIds)await d.del(l);t()}async function W0(i,t){let r=n,a={wrYAr:function(d,l,g){return e.NTWRN(d,l,g)}};if(e[r(1367)](e[r(677)],e[r(314)])){let d=i.message[r(700)+"e"]===z0,l=e[r(263)](i[r(1244)][r(700)+"e"],Er);if(e[r(1008)](!d,!l))return e[r(1406)](t);let g=e.jZpJM(ht,i[r(1244)][r(1583)],r(1374)+"ile_name");if(!g)return e[r(1561)](t);let w=await Yi.call(this,g);if(!w)return t();if(d){let h=await w[r(639)+"rs"](),y={frameType:h?.["frameType"],SeqID:K[r(876)+"er"](this[r(1582)]++),LogID:K.fromNumber(this[r(407)][r(274)+r(750)]()),service:9e3,method:5,headers:h?.[r(1583)],payload:h?.[r(621)]},S=e[r(698)](E,y);this._ws&&this[r(1305)][r(1644)+"te"]&&this[r(1305)][r(727)](S)}if(l){let h=i[r(1244)].payload;h&&w[r(1540)+"rs"](h)}}else _0x1c42a7(_0x1b81e9,58),fHqUsr[r(873)](_0x3692fc,_0x35ad64,_0x3f4620)}let J0=async function(i,t){let r=n;this[r(834)]=!1,e.wwfPQ(clearTimeout,this[r(1605)+"ionTimeo"+r(1272)]),e[r(1735)](t)},$0=async function(i,t){let r=n,a={frofE:function(d,l){return e[I(842)](d,l)},FkiZL:function(d,l){return e.zmFuR(d,l)}};if(e[r(1320)](e[r(773)],e[r(773)])){if(!this[r(1305)]||e[r(467)](this._ws[r(1644)+"te"],this[r(582)]))return e.QefqE(t);let{pingInterval:d}=this[r(407)];this[r(1034)+r(1353)]?.[r(1467)+r(1562)+"fig"]();for(let g=0;g<this[r(345)+r(1403)][r(1395)];g++){let w=this[r(345)+r(1403)][g];if(e[r(1007)](this[r(1305)].readyState,this.OPEN)&&w!==null)this._ws&&this._ws[r(727)](w),this["_message"+r(1403)][g]=null;else break}this[r(345)+r(1403)]=this[r(345)+"Queue"][r(1223)](g=>!!g),this[r(739)+r(1576)+"Id"]=e[r(733)](setTimeout,()=>this[r(745)](),d),this[r(1421)+"hOpenEvent"](i),this[r(1430)+"er"]&&this[r(1305)]&&(this._ws[r(959)+"pe"]=this[r(1727)+r(716)]);let l=this[r(1034)+r(1353)]?.[r(849)+r(1098)+"nt"]();this[r(1668)](r(1560)+l+r(565)),e[r(1279)](t)}else return DiCtIt.frofE(DiCtIt.FkiZL(1e4,_0x2c6b08[r(1442)]()),_0x52d280.floor(DiCtIt[r(1117)](1e4,_0x5c2edf.random())))},V0=async function(i,t){let r=n,a=this[r(1034)+r(1353)]?.[r(849)+"ntEndpoint"]();this._debug("open "+a),t()};class X0 extends wr{constructor(t){let r=n,a={olVfq:function(w,h){return e[I(386)](w,h)},dLbbP:e.CZMsm,AqhrS:e[r(594)],Pmdue:function(w,h,y,S){return w(h,y,S)},yWEtv:function(w,h,y){return e[r(1165)](w,h,y)},XQYmV:e[r(463)],ZkVlN:function(w,h){return e[r(482)](w,h)}};super(),this[r(952)+r(1740)+r(1484)]=!0,this[r(1430)+"er"]=lt,this._isNode=u0,this[r(748)+"T"]=it,this[r(1398)+"X"]=Ot,this[r(444)+"r"]=Mt,this["_message"+r(1403)]=[],this[r(1034)+r(1353)]=null,this[r(435)+r(368)]=!1,this[r(1727)+r(716)]="arraybuf"+r(684),this._connectLock=!1,this[r(1605)+r(303)+r(1272)]=null,this["_reconne"+r(1101)+r(1133)]=null,this[r(739)+r(1576)+"Id"]=null,this._seqId=0,this[r(834)]=!1,this[r(729)]="",this[r(1752)+r(1352)]=null,this[r(954)+r(319)]=null,this[r(1426)+r(1215)]=null,this[r(1164)+"ls"]=r(1624),this[r(1756)]=3,this[r(1120)+"NG"]=0,this[r(582)]=1,this.CLOSING=2,this[r(1524)]=w=>{let h=r;try{a[h(955)](a[h(341)],a[h(1675)])?a[h(958)](ji,this,w,[J0,$0,V0]):!this[h(1605)+h(1033)]&&(this[h(1034)+h(1353)]?.["resetEnd"+h(1562)+h(1466)](),this["_pingLos"+h(1215)]?.[h(433)+h(604)](),this["_readyCl"+h(368)]=!1,this[h(834)]=!0,this[h(1605)]())}catch(y){let S=a[h(450)](ye,a[h(1634)],{message:y.message,code:$e[h(1241)+"OR"],error:y});this[h(1421)+h(683)+h(1529)](S)}},this[r(689)+"ge"]=async w=>{let h=r,{pingInterval:y,pingFrequency:S}=this._options;if((e.otusy("hi",w[h(723)])&&e[h(574)]===S||e[h(706)](h(803),S))&&(this[h(1587)+h(266)](),this[h(423)](e[h(1684)],h(1602)),this[h(739)+"gTimeoutId"]=e[h(1659)](setTimeout,this[h(745)][h(1152)](this),y)),w[h(723)]!=="hi")try{e[h(525)](ji,this,w,[I0,C0,G0,W0,j0,A0])}catch(P){if(e.dILwQ!==h(539))_0x22ec30[h(242)](_0x5e50de);else{let O=e[h(626)](ye,e[h(463)],{message:P.message,code:$e[h(1210)+h(994)],error:P});this[h(1421)+h(683)+h(1529)](O)}}},this[r(491)]=w=>{let h=r,y=this[h(1034)+h(1353)]?.[h(401)+h(390)+"es"](),S=this[h(1034)+"tManager"]?.[h(849)+h(1098)+"nt"]();if(y&&!w.message){let P="connect "+S+(h(991)+h(1035)+h(1091)+"ed");this["_dispatc"+h(683)+h(1529)](e.aRSzd(ye,h(500),{message:P,code:$e[h(299)+"IES_ERROR"],error:w}));return}this._ws&&e.mHNtv(this[h(1305)][h(1644)+"te"],this.OPEN)&&this[h(1578)+h(1468)](),this[h(1421)+h(683)+h(1529)](e[h(1495)](ye,e[h(463)],{message:w[h(1244)],code:$e[h(609)+"RROR"],error:w}))},this[r(746)]=async w=>{let h=r;if(e[h(382)](e[h(494)],e.CmiLX))LevNqP[h(606)](_0x1c5f36,_0x4d3c4f)&&_0x283cfc.set(_0x42bcf0,_0x46d400);else{this["_clearTi"+h(1208)](),this["_clearPi"+h(266)](),this[h(865)+h(763)+"rs"](),this[h(1305)]=null,this[h(1605)+h(1033)]=!1;let y=this[h(1034)+h(1353)]?.[h(401)+h(390)+"es"]();if(!y&&this[h(1341)+h(625)]()&&!this[h(435)+"osed"])if(e[h(706)](h(564),e[h(1184)]))this[h(423)](h(1244),_0x165a9d),this[h(848)+"e"]&&this[h(848)+"e"](_0x25cb37);else{let S=this[h(1034)+h(1353)]?.[h(849)+h(1098)+"nt"](),P=this[h(407)][h(1327)+"tInterceptor"](w[h(1744)],w.reason);this[h(1421)+h(1038)+h(1529)](Ee(e[h(1175)],{code:1006,reason:w[h(259)]||h(997)+h(740)+h(1399)+h(477)+h(343)+"ame: "+S,willReconnect:P})),P&&this[h(1605)]();return}if(e[h(1623)](1e3,w.code)&&this["_readyCl"+h(368)]){this[h(1421)+h(1038)+"ent"](Ee(e.AtmdE,{code:1e3,reason:e[h(868)]})),this[h(1034)+"tManager"]?.[h(1467)+h(1562)+"fig"](),this[h(1426)+"sCounter"]?.[h(433)+"nter"]();return}if(e[h(1159)](1e3,w[h(1744)])&&y)if(e[h(282)](e[h(1048)],e.KXqCm)){let S=this[h(1034)+h(1353)]?.[h(849)+h(1098)+"nt"](),P=w[h(259)];P||(P=await e.JWCPR(_0,this[h(729)])),P=h(997)+"ng faile"+h(590)+P+", hostname: "+S+(h(1177)+h(1257)+h(1521)),this[h(1421)+"hCloseEv"+h(1529)](e[h(1162)](Ee,"close",{code:w[h(1744)],reason:P}));let O=h(650)+S+(h(991)+h(1035)+h(1091)+"ed");this[h(1421)+"hErrorEvent"](e[h(377)](ye,e.RWYWp,{message:O,code:$e[h(299)+"IES_ERROR"]})),this[h(1034)+h(1353)]?.[h(1467)+"pointCon"+h(1466)](),this[h(1426)+h(1215)]?.["resetCou"+h(604)]();return}else return new _0x4465bb(S=>{let P=h;_0x37a384(S,this[P(928)+P(888)+"e"](_0x2f2b88))});if(e[h(855)](1e3,w.code)&&!w[h(259)]){let S=this["_endpoin"+h(1353)]?.[h(849)+h(1098)+"nt"]();this[h(1421)+"hCloseEv"+h(1529)](e[h(1349)](Ee,e[h(1175)],{code:w.code,reason:h(997)+h(740)+"d, unknown reaso"+h(343)+h(255)+S})),this[h(1034)+"tManager"]?.[h(1467)+h(1562)+h(1466)](),this[h(1426)+"sCounter"]?.["resetCou"+h(604)]();return}this[h(1421)+h(1038)+"ent"](w),this[h(1034)+h(1353)]?.[h(1467)+h(1562)+h(1466)](),this[h(1426)+"sCounter"]?.[h(433)+h(604)]()}},this[r(1255)]=null,this.onerror=null,this[r(848)+"e"]=null,this[r(1059)]=null,this[r(410)+"econnect"]=null,this[r(968)+r(601)]=null,this["onStopIm"+r(1753)+r(278)+"ct"]=null,this[r(999)+r(892)]=this[r(999)+r(892)].bind(this),this[r(999)+"ffLine"]=this[r(999)+r(419)][r(1152)](this),this["_handleP"+r(1266)]=this[r(1701)+r(1266)][r(1152)](this),this[r(1701)+r(283)]=this[r(1701)+r(283)][r(1152)](this),this._options={url:"",automaticOpen:!0,initReconnectInterval:1e3,maxReconnectInterval:1e4,reconnectIntervalGrowFactor:2,timeoutInterval:5e3,maxRetries:5,debug:!1,maxMessageQueueLength:e.TclLh(1,0),service:0,logIDGenerator:c,headers:void 0,payloadEncoding:"",payloadType:"",fpID:"",deviceID:"",accessKey:"",ttwID:"",bddID:"",aID:"",disableAutoReconnect:!1,customParams:{},pingInterval:15e3,pingTimeoutInterval:4e3,pingFrequency:r(803),pingLossCount:2,enableTransformTextPayload:!1,logIDNewConfig:{enableAutoGenerateLogIDNew:!1,userIp:""},miniProgramParams:{customHttpHeader:{}},enableAutoAck:!1,reconnectInterceptor:()=>!0,enableQoS:!1,QoSLevel:2,messageStrategy:e[r(1619)],env:{xTTEnv:"",xUseEnv:""},listenNetworkChanged:!0};let{url:d,ws:l}=t,g=Array[r(1621)](d)?d:e[r(1224)](e.EVoDt,typeof d)?[d]:[];if(!g||e[r(1372)](0,g.length))throw new Error(e[r(749)]);if(!e.JWCPR(g0,l))throw new Error(e.oxQtx);Object[r(1239)](this[r(407)],t),this[r(1034)+"tManager"]=new Ki(g,this[r(407)][r(317)+"es"]),this._pingLossCounter=new w0(this[r(407)][r(1704)+r(545)]),this._options[r(584)+r(737)]&&(this[r(834)]=!0,this[r(1605)]()),this[r(407)][r(262)+r(251)+r(1202)]&&(this[r(748)+"T"]||this[r(1398)+"X"]?this[r(1633)+r(1075)+"ange"]():this[r(1430)+"er"]&&this[r(253)+r(1307)+r(1579)]())}[n(999)+n(892)](){let t=n;this[t(407)][t(1543)+"utoRecon"+t(909)]||this[t(435)+t(368)]||this[t(668)+t(577)]()}["_handleO"+n(419)](){let t=n,r={kxpXH:function(a,d){return e[I(948)](a,d)},PrDpg:function(a,d){return e[I(1622)](a,d)}};if(e[t(1036)](e.MDIzU,e[t(1046)]))r.kxpXH(_0x2e1b42,this["_pingPon"+t(1576)+"Id"]),r[t(1328)](_0x1d8a74,this["_reconne"+t(1101)+t(1133)]),this[t(739)+"gTimeoutId"]=null,this[t(694)+t(1101)+"tId"]=null;else{this["_destroy"+t(1671)+"t"]();let a=e[t(1154)](mr,e[t(396)],{message:"stop imm"+t(1027)+t(269)+"ct"});this[t(1383)+"mediatel"+t(278)+"ct"]&&this[t(1383)+t(1753)+"yReconnect"](a)}}[n(253)+n(1307)+n(1579)](){let t=n,r={usnxy:function(a,d,l){return e[I(687)](a,d,l)},jvmma:function(a,d){return a(d)}};e[t(713)]!==e.oRRdB?(this[t(1430)+"er"]&&window[t(805)+"Listener"](e[t(1611)],this[t(999)+t(892)]),this[t(1430)+"er"]&&window[t(805)+t(1579)](e[t(1135)],this["_handleO"+t(419)]),this[t(1430)+"er"]&&window.addEventListener(t(452),this[t(1701)+t(1266)]),this._isBrowser&&window["addEvent"+t(1579)](e[t(1548)],this[t(1701)+t(283)])):(RKxwlG[t(736)](_0x2afd13,_0x4f55ce,96),_0xe37495(_0x423121,RKxwlG.jvmma(_0x293ad2,_0x160cab)))}[n(1699)+n(1307)+n(1579)](){let t=n;if(e.TtmTO(e[t(1618)],t(765)))this[t(1430)+"er"]&&window["removeEv"+t(1630)+"ner"](e.gTuTe,this[t(999)+"nLine"]),this._isBrowser&&window[t(1136)+"entListe"+t(1558)](e[t(1135)],this[t(999)+"ffLine"]),this[t(1430)+"er"]&&window[t(1136)+t(1630)+t(1558)](e[t(648)],this[t(1701)+t(1266)]),this._isBrowser&&window["removeEv"+t(1630)+t(1558)](e.wXINf,this[t(1701)+t(283)]);else return _0x1099ca&&(_0x36fefd=(0,_0xf59197[xaWEzb[t(1485)](_0x29b453,_0x865261)[0]])(_0x25cb00=0)),_0x21c7b3}["_handleP"+n(1266)](t){let r=n,a={ILjjQ:function(d,l,g){return e.DDDYW(d,l,g)},XJFfm:r(1645)};if(e[r(1384)]("iKCGx",r(1115))){if(this._endpointManager?.[r(401)+"chMaxTries"]()){let l=this["_endpoin"+r(1353)]?.getCurrentEndpoint();this[r(1421)+"hCloseEv"+r(1529)](a[r(1741)](_0x2cb86f,a[r(1174)],{code:1006,reason:r(650)+l+(r(1018)+r(1177)+r(1257)+r(1521)),wasClean:!0}))}else{let l=this[r(407)][r(1327)+r(573)+"ptor"](_0x202852,_0x2c0f68);this[r(1421)+r(1038)+r(1529)](a[r(1741)](_0x221ebe,r(1645),{code:_0x565f4d,reason:_0x9649c1,wasClean:!0,willReconnect:l})),l&&this[r(1605)]()}return}else!t.persisted&&(this[r(1430)+"er"]&&window[r(1136)+r(1630)+"ner"](e[r(648)],this[r(1701)+r(1266)]),this[r(1430)+"er"]&&window["removeEventListe"+r(1558)](e[r(1548)],this["_handleP"+r(283)]),this.close()),this[r(1430)+"er"]&&window[r(1136)+r(1630)+r(1558)](e.gTuTe,this._handleOnLine),this[r(1430)+"er"]&&window["removeEv"+r(1630)+"ner"](e.oymjw,this[r(999)+"ffLine"])}[n(1701)+n(283)](t){let r=n;t[r(797)+"d"]&&(this[r(1341)+r(625)]()&&(!this[r(1305)]||e.vSnhB(this[r(1305)][r(1644)+"te"],this[r(582)])||e[r(953)](this[r(1305)][r(1644)+"te"],this[r(1120)+"NG"]))&&this[r(999)+r(892)](),this[r(1430)+"er"]&&window[r(805)+r(1579)](e[r(1611)],this[r(999)+r(892)]),this[r(1430)+"er"]&&window[r(805)+"Listener"](e.oymjw,this[r(999)+"ffLine"]))}async[n(293)+"eUrl"](t){let r=n,{fpID:a,deviceID:d,bddID:l,ttwID:g,accessKey:w,aID:h,customParams:y={},enableAutoAck:S,enableQoS:P,QoSLevel:O,env:L}=this._options,z,W,ee;this[r(1430)+"er"]||this[r(1398)+"X"]||this[r(748)+"T"]?e.INEXv(e[r(1116)],e[r(1116)])?(z=location&&e[r(1069)](e[r(802)],location[r(376)])?e[r(1566)]:e[r(1728)],W=t[r(1757)](/((^ws)|(^http))((?:[s]*:\/\/))/,""),ee=/^wss(.*:\/\/)/.test(t)?t:""+z+W):(_0x29cb1f=e.EuBbt(e[r(1099)](65536,e[r(316)](1023&_0x1efc5a,10)),1023&_0x3bd36b),++_0x90a282,_0x5a0a6b[_0x407e9++]=e[r(1532)](e[r(608)](_0x5b7767,18),240),_0x311eed[_0x9c02f8++]=e[r(335)](e[r(858)](e.tnEfG(_0x512316,12),63),128),_0x261601[_0xb78953++]=e[r(867)](e[r(514)](e[r(899)](_0x1c6959,6),63),128),_0x2fbab8[_0x1a98f9++]=e.DoFMy(e[r(669)](63,_0x7b8b35),128)):(z=e[r(1566)],W=t[r(1757)](/(^http)((?:[s]*:\/\/))/,""),ee=/(^ws)((?:[s]*:\/\/))/.test(W)?W:""+z+W);let gt=l?e[r(618)]:g?e.fsRsC:r(1600)+"d",Cr=l||g||d;if(e[r(532)](!Cr,!gt))throw new Error(e.nSnSs);let Y0=e.MgzRz(e[r(1639)],typeof y)?await e.wTNah(y):y,Z0=L?e[r(290)](m0,L.xUseEnv,L[r(753)]):{},Ar=Object.assign({device_platform:e[r(1124)],version_code:e[r(548)],access_key:w,fpid:a,aid:h,[gt]:Cr,xsack:S?1:0,xaack:S?1:0,xsqos:P?1:0,qos_level:P?O:void 0,qos_sdk_version:2,...Z0},Y0),Q0=Object.keys(Ar)[r(1482)]((Ir,kr)=>Ar[kr]!==void 0?""+Ir+(Ir?"&":"?")+kr+"="+Ar[kr]:Ir,"");return ee+"/ws/v2"+Q0}async[n(1605)](){let t=n,r={FwWxj:function(a,d,l,g){return e[I(825)](a,d,l,g)},nHofF:function(a,d,l){return e[I(1533)](a,d,l)},WFORo:t(500)};if(!(this._connectLock||this[t(435)+t(368)])){this[t(1605)+t(1033)]=!0;try{let a=this[t(1034)+t(1353)]?.[t(1725)+t(507)+"ointReac"+t(1083)+t(784)](),{timeoutInterval:d}=this._options;if(a){let g=this._endpointManager?.[t(849)+"ntEndpoint"](),w=this["_endpoin"+t(1353)]?.["replaceB"+t(1151)+t(1155)+t(457)+t(1292)](),h=this[t(1034)+t(1353)]?.[t(849)+t(1098)+t(971)+t(1763)]();if(w)if(e[t(775)](e[t(1107)],e.ECxsA))try{EJmZpo[t(795)](_0x53d9a0,this,_0x314ff2,[_0xee7cdb,_0x69dad,_0x10d8ed])}catch(y){let S=EJmZpo.nHofF(_0x465636,EJmZpo[t(1009)],{message:y[t(1244)],code:_0x1b81b7[t(1241)+"OR"],error:y});this[t(1421)+"hErrorEv"+t(1529)](S)}else{let y="connect "+g+(t(1018)+t(1177)+t(1257)+t(428)+t(388)+t(962)+"ndpoint ")+w+(t(1242)+"y"),S=e[t(1387)](ye,e[t(463)],{message:y,code:$e[t(299)+t(1204)+"R"]});this._debug(y),this["_dispatchErrorEv"+t(1529)](S),this[t(729)]=await this["_generat"+t(571)](w),this[t(1668)](t(650)+w+" "+h+t(788)),this[t(865)+"sListeners"]()}else{let y=t(650)+g+(t(1018)+t(1177)+t(1257)+"ached");this[t(1668)](y),this["_dispatchErrorEv"+t(1529)](e[t(897)](ye,t(500),{message:y,code:$e["MAX_RETR"+t(1204)+"R"]}));return}}else{let g=this[t(1034)+t(1353)]?.[t(849)+t(1098)+t(1234)+"ateCount"](),w=this[t(1034)+t(1353)]?.[t(849)+t(1098)+t(971)+"ount"]();this[t(729)]=await this["_generat"+t(571)](e[t(814)](g,"")),this[t(1668)](t(650)+g+" "+w+t(788)),this[t(865)+t(763)+"rs"]()}if(this[t(834)])this[t(834)]=!1;else{let g=mr(t(1327)+"t",{message:e[t(486)]});this[t(410)+t(577)]&&this[t(410)+t(577)](g)}let l=this[t(1034)+t(1353)]?.[t(849)+t(1098)+t(971)+"ount"]()||0;e[t(470)](l,1)&&await this[t(1696)](e[t(1643)](l,1)),this._debug("connecti"+t(1654)+this[t(729)]+(t(1106)+"ls: ")+this[t(1164)+"ls"]),this[t(1305)]=h0({url:this[t(729)],protocols:[this[t(1164)+"ls"]],headers:this[t(407)][t(764)+"ramParams"][t(1716)+t(301)]},this[t(407)].ws),(this._isBrowser||this[t(444)+"r"])&&this[t(1305)]&&(this[t(1305)][t(959)+"pe"]=this["_binaryT"+t(716)]),this._addWsListeners(),this[t(1605)+t(303)+"utId"]=setTimeout(this._onTimeout[t(1152)](this),d)}catch(a){throw this[t(1605)+t(1033)]=!1,a}}}["_clearTi"+n(1208)](){let t=n;e[t(549)](clearTimeout,this[t(1605)+"ionTimeo"+t(1272)]),this["_connect"+t(303)+t(1272)]=null}[n(1587)+n(266)](){let t=n;e[t(549)](clearTimeout,this["_pingPon"+t(1576)+"Id"]),e[t(1749)](clearTimeout,this[t(694)+t(1101)+"tId"]),this[t(739)+t(1576)+"Id"]=null,this["_reconne"+t(1101)+t(1133)]=null}_debug(...t){let r=n;this[r(407)][r(585)]&&console.log[r(361)](console,[r(300)+">",...t])}["_getInte"+n(888)+"e"](t){let r=n,{initReconnectInterval:a,maxReconnectInterval:d,reconnectIntervalGrowFactor:l}=this[r(407)],g=e.OvqTb(a,Math.pow(l,e[r(904)](t,1)));return g>d?d:g}[n(745)](){let t=n;if(this[t(1305)]&&this[t(1305)].readyState===this[t(1120)+"NG"]){this[t(1587)+t(266)](),this._pingPongTimeoutId=setTimeout(this[t(745)].bind(this),this._options[t(1556)+t(1253)]);return}if(!this[t(1305)]||e[t(350)](this[t(1305)][t(1644)+"te"],this[t(582)]))return void this[t(668)+t(577)]();this[t(1305)]&&this[t(1305)][t(727)]("hi"),this[t(694)+t(1101)+t(1133)]=e.htocK(setTimeout,this[t(668)+t(577)+t(1554)][t(1152)](this),this[t(407)][t(1235)+"outInterval"])}["_handleR"+n(577)+n(1554)](){let t=n;this[t(1426)+t(1215)]?.[t(1473)](),this.emit(e[t(972)],e[t(1233)]),this[t(1426)+t(1215)]?.[t(401)+t(1591)+"nt"]()?this._handleReconnect():this._ping()}[n(1341)+"orOnline"](){let t=n;return this[t(748)+"T"]||this._isMiniWX?this[t(952)+t(1740)+t(1484)]:(this[t(1430)+"er"]||this[t(444)+"r"])&&this[t(407)][t(262)+t(251)+t(1202)]?navigator[t(1737)]:!0}["_handleR"+n(577)](){let t=n;!this[t(1341)+t(625)]()||this[t(435)+t(368)]||(this[t(1034)+t(1353)]?.[t(1467)+t(1562)+t(1466)](),this[t(1426)+t(1215)]?.[t(433)+t(604)](),this[t(1305)]?this[t(1578)+t(1468)](1001,e[t(1390)],!0):this[t(1605)]())}[n(1633)+"etWorkChange"](){let t=n;this[t(748)+"T"]?tt["onNetwor"+t(1014)+t(1480)](({isConnected:r})=>{let a=t;this[a(952)+"igatorOn"+a(1484)]=r,r?this["_handleO"+a(892)]():this[a(999)+a(419)]()}):this[t(1398)+"X"]&&wx["onNetwor"+t(1014)+t(1480)](({isConnected:r})=>{let a=t;this["_miniNav"+a(1740)+a(1484)]=r,r?this[a(999)+a(892)]():this[a(999)+"ffLine"]()})}_wait(t){let r={pFNGN:function(a,d,l){return e[I(945)](a,d,l)}};return new Promise(a=>{let d=I;r.pFNGN(setTimeout,a,this[d(928)+d(888)+"e"](t))})}["_disconn"+n(1468)](t=1e3,r="",a=!1){let d=n;this[d(1305)]&&this["_destroy"+d(1671)+"t"](t,r,a)}[n(886)+"ut"](){let t=n;if(e[t(1264)](e[t(1589)],e[t(336)]))return null;{let r=this[t(1034)+t(1353)]?.[t(849)+t(1098)+"nt"]();this[t(1668)](t(650)+r+t(1018)),this[t(1578)+t(1468)](1001,t(799)+t(872)+t(1574)+"g",!0)}}_sendAck(t){let r=n,a=e[r(1072)](pr,t);this[r(1305)]&&e.mTsiT(this[r(1305)][r(1644)+"te"],this[r(582)])&&(this[r(1305)]&&this[r(1305)][r(727)](a),this[r(1668)](r(1603),t))}[n(865)+n(763)+"rs"](){let t=n,r=e[t(448)][t(1627)]("|"),a=0;for(;;){switch(r[a++]){case"0":if(!this[t(1305)])return;continue;case"1":this[t(1305)]["removeEv"+t(1630)+t(1558)](t(1499),this[t(1524)]);continue;case"2":this._ws.removeEventListener(e[t(1722)],this[t(689)+"ge"]);continue;case"3":this[t(1305)]["removeEv"+t(1630)+t(1558)](e[t(1175)],this._onClose);continue;case"4":this[t(1305)][t(1136)+t(1630)+t(1558)](e[t(463)],this._onError);continue}break}}["_addWsLi"+n(1316)](){let t=n;this[t(1305)]&&(this[t(1305)][t(805)+"Listener"](t(1499),this[t(1524)]),this[t(1305)][t(805)+t(1579)](e[t(1175)],this[t(746)]),this[t(1305)]["addEvent"+t(1579)](e[t(1722)],this[t(689)+"ge"]),this[t(1305)]["addEvent"+t(1579)](e.RWYWp,this[t(491)]))}[n(424)+"nceClose"](t=1e3,r=""){let a=n;try{this[a(1305)]&&this[a(1305)][a(1645)](t,r)}catch{}}[n(543)+"WebSocket"](t=1e3,r="",a=!1){let d=n,l={DpCRV:function(g,w){return e[I(453)](g,w)},qRaTM:function(g){return e.QefqE(g)}};if(e.HLnSB(e[d(1025)],d(1719))){if(this[d(1587)+d(266)](),this["_clearTi"+d(1208)](),this[d(865)+"sListeners"](),this["_wsInsta"+d(387)](1e3,r),this[d(1605)+d(1033)]=!1,a&&this[d(1341)+d(625)]()&&!this[d(435)+d(368)]){if(this["_endpoin"+d(1353)]?.[d(401)+d(390)+"es"]()){let w=this["_endpoin"+d(1353)]?.["getCurre"+d(1098)+"nt"]();this[d(1421)+d(1038)+d(1529)](Ee(d(1645),{code:1006,reason:d(650)+w+(" timeout"+d(1177)+d(1257)+d(1521)),wasClean:!0}))}else if(e[d(1219)](e.CxqUn,e[d(894)])){let w=this[d(407)][d(1327)+d(573)+d(535)](t,r);this[d(1421)+d(1038)+d(1529)](e[d(985)](Ee,e[d(1175)],{code:t,reason:r,wasClean:!0,willReconnect:w})),w&&this._connect()}else this[d(834)]=!1,SBkkEf[d(1013)](_0x29c3d5,this[d(1605)+d(303)+d(1272)]),SBkkEf[d(1510)](_0x5054a0);return}this[d(1341)+"orOnline"]()||this[d(435)+d(368)]?this[d(1421)+d(1038)+d(1529)](Ee(e.AtmdE,{code:t,reason:e.bxoiE})):this[d(1421)+"hCloseEv"+d(1529)](e[d(1452)](Ee,e[d(1175)],{code:1006,reason:e.bofzp})),this._ws=null,this["_endpoin"+d(1353)]?.[d(1467)+d(1562)+d(1466)](),this[d(1426)+d(1215)]?.[d(433)+d(604)]()}else return!0}[n(1421)+"hOpenEvent"](t){let r=n;this[r(423)](e.HDppo,t),this.onopen&&this[r(1059)](t)}[n(1421)+n(279)+n(939)](t){let r=n;if(e.rKKvn(e[r(642)],e[r(676)]))this.emit(e[r(1722)],t),this[r(848)+"e"]&&this[r(848)+"e"](t);else return this[r(331)][r(381)]}[n(1421)+"hAckMess"+n(592)](t){let r=n;this[r(423)](r(1531),t),this[r(968)+r(601)]&&this[r(968)+r(601)](t)}["_dispatc"+n(683)+n(1529)](t){let r=n;this[r(423)](r(500),t),this[r(652)]&&this[r(652)](t)}[n(1421)+"hCloseEvent"](t){let r=n;this[r(423)](e[r(1175)],t),this[r(1255)]&&this.onclose(t)}get[n(959)+"pe"](){let t=n;if(t(402)!=="hcMjW")return this[t(1305)]?this[t(1305)][t(959)+"pe"]:this[t(1727)+t(716)];this[t(407)][t(585)]&&_0x2fc89c[t(242)][t(361)](_0x4981da,[e[t(1447)],..._0x20fe1f])}set[n(959)+"pe"](t){let r=n;e.paHRZ!==e.paHRZ?(_0x46bb9d(_0x342f0c,82),e[r(1397)](_0x23bbae,_0x6bdff5,_0x2143f5)):(this[r(1727)+r(716)]=t,this[r(1305)]&&(this._ws.binaryType=t))}get[n(878)+"nt"](){let t=n;return this[t(1034)+t(1353)]?.[t(849)+"ntEndpoi"+t(971)+t(1763)]()||0}get[n(1015)+"Amount"](){let t=n,r={HGzMs:function(a){return e[I(832)](a)},DwrfF:function(a,d){return a(d)}};if(t(1486)===e[t(826)]){let a=ZUDQyV[t(1475)](_0xb725a3);return _0x5d9e36(_0x3a3bac,a),ZUDQyV.DwrfF(_0xcc31e8,a)}else{let a=this[t(345)+t(1403)][t(1482)]((d,l)=>(d+=l&&l[t(576)+"th"]||0,d),0);return e.DqAho(a,this[t(1305)]?this[t(1305)][t(1015)+t(1032)]:0)}}get[n(271)+"ns"](){let t=n;return this._ws?this[t(1305)].extensions:""}get[n(376)](){let t=n;return this[t(1305)]?this[t(1305)][t(376)]:""}get[n(1644)+"te"](){let t=n;return this[t(1305)]?this._ws[t(1644)+"te"]:this[t(407)][t(584)+t(737)]?this[t(1120)+"NG"]:this[t(1756)]}get[n(1637)](){let t=n;return this[t(1305)]?this[t(1305)][t(1637)]:this[t(729)]}[n(1645)](t=1e3,r){let a=n,d=e.ATElW[a(1627)]("|"),l=0;for(;;){switch(d[l++]){case"0":this["_clearPi"+a(266)]();continue;case"1":this[a(1752)+a(1352)]?.[a(1248)]();continue;case"2":this[a(1273)+a(1208)]();continue;case"3":this[a(435)+a(368)]=!0;continue;case"4":if(!this._ws)return void this[a(1668)](e[a(1024)]);continue;case"5":this[a(543)+"WebSocket"](t,r);continue;case"6":this[a(1699)+a(1307)+"Listener"]();continue;case"7":if(e[a(926)](this[a(1305)].readyState,this.CLOSED)||e[a(1536)](this._ws.readyState,this[a(722)]))return void this[a(1668)](e[a(380)]);continue}break}}async send(t,r){let a=n,d={QoMwp:function(ee,gt){return e.TgqpC(ee,gt)},vugkt:function(ee,gt){return e[I(640)](ee,gt)}};if(e[a(643)](null,t))throw new Error(e[a(1195)]);e.wbkKj(e[a(1551)],typeof t)&&(t=JSON[a(856)+"y"](t)),e.HWucP(e[a(378)],typeof t)&&!e.cBElC(t,ArrayBuffer)&&!(t.buffer&&e.gaKvT(t[a(1211)],ArrayBuffer))&&(t=JSON[a(856)+"y"](t));let l=await e[a(1609)](Ji,t),g=e[a(1323)](p0,t),{method:w=0,service:h=this[a(407)].service,logID:y=this[a(407)][a(274)+a(750)](),headers:S=this[a(407)][a(1583)],payloadEncoding:P=this._options[a(1049)+"ncoding"],payloadType:O=this._options[a(430)+a(716)],logIDNew:L=this[a(407)].logIDNewConfig[a(1616)+a(383)+a(816)+"ew"]?e[a(267)](o,this[a(407)][a(720)+a(1231)][a(665)]):""}=e[a(681)](r,{});if(!h)throw new Error(a(1726)+a(1185)+a(1647)+"ervice");let z={SeqID:K[a(876)+"er"](this[a(1582)]++),LogID:K[a(876)+"er"](y),service:h,method:w,headers:S,payloadEncoding:e[a(351)](P,Object)?P[a(354)]?P[a(354)]:"":P,payloadType:e[a(306)](O,Object)?O[a(1446)]?O[a(1446)]:g:O||g,payload:l,LogIDNew:L},W=e.QZmme(pr,z);if(this[a(1305)]&&e.ficaz(this[a(1305)].readyState,this.OPEN))e[a(813)](a(1492),"fthwJ")?(this[a(1305)]&&this[a(1305)][a(727)](W),this[a(1668)](e.sZjtg,z)):(_0x391483.set(_0x10d122,_0x47fc81),_0x3e5db2[a(853)](_0x4b48ae,_0x248a6b));else if(this[a(345)+a(1403)].length<this[a(407)][a(1635)+"geQueueLength"]){if(e[a(572)]===a(1530))throw _0x5e2d60=_0x5b7dbf[a(1395)],_0x14baf0(_0x547132,10,_0x499f70[a(1395)]);this[a(345)+a(1403)][a(1209)](W),this[a(1668)](e.mJsxk,z)}else{if(a(397)!==e[a(1470)])return _0xc11966|=0,{low:_0x270ce1,high:OBCyhd[a(1301)](_0x195146,31),unsigned:OBCyhd[a(1315)](_0x19051d,0)};this[a(345)+a(1403)][a(1010)](),this[a(345)+a(1403)][a(1209)](W)}return{seqID:this[a(1582)],logID:y,logIDNew:L}}async reconnect(t){let r=n,{url:a}=e[r(532)](t,{}),d=Array[r(1621)](a)?a:e[r(378)]==typeof a?[a]:[];t&&Object[r(1239)](this[r(407)],t),d&&d[r(1395)]?this[r(1034)+r(1353)]=new Ki(d,this._options[r(317)+"es"]):this["_endpoin"+r(1353)]?.["resetEnd"+r(1562)+r(1466)](),this["_pingLos"+r(1215)]?.[r(433)+r(604)](this[r(407)][r(1704)+r(545)]),this[r(435)+r(368)]=!1,this._ws&&e.BDUJm(this[r(1305)].readyState,this[r(1756)])?this[r(1578)+r(1468)](1e3,e.qxaAV,!0):(this[r(834)]=!0,this._connect())}async[n(1331)](){let t=n;if(!this[t(1605)+"Lock"]){let r=e[t(1181)].split("|"),a=0;for(;;){switch(r[a++]){case"0":this[t(1034)+t(1353)]?.[t(1467)+t(1562)+t(1466)]();continue;case"1":this[t(435)+t(368)]=!1;continue;case"2":this[t(1426)+"sCounter"]?.[t(433)+t(604)]();continue;case"3":this[t(834)]=!0;continue;case"4":this[t(1605)]();continue}break}}}[n(805)+n(1579)](t,r){this.on(t,r)}[n(1146)+n(939)](t){let r=n,{type:a}=t;this[r(423)](a,t)}[n(1136)+n(1630)+n(1558)](t,r){this.off(t,r)}[n(1078)](){let t=n,r={kmIQD:function(a,d){return e[I(1392)](a,d)},NDjwk:e[t(1233)],ZgRSl:e[t(972)]};return new Promise((a,d)=>{let l=t,g={qBwLj:function(y,S){return y|S},AxhGo:function(y,S){return e.FJabc(y,S)},ACTTB:function(y,S){return e.gdOfj(y,S)},aUvzN:function(y,S){return e[I(1250)](y,S)},mfOnI:function(y,S){return e[I(567)](y,S)},nkvSO:function(y,S){return e.pZhkF(y,S)},PSphV:function(y,S){return e.YkLet(y,S)},SEgVT:function(y,S){return e[I(1347)](y,S)},vAvgN:function(y,S){return y+S},bTfYH:function(y,S){return e.foSBH(y,S)},QFofj:function(y,S){return y+S},nSBLj:function(y,S){return e[I(1710)](y,S)},ANkQo:l(623),wymZH:e[l(664)],vkCsb:function(y,S){return y(S)},prhsn:e[l(1145)],BKEbY:e[l(1684)],mhhwS:l(1339)+l(1700)+"t"};this[l(1587)+"ngTimer"](),this[l(739)+l(1576)+"Id"]=e[l(1495)](setTimeout,this[l(745)][l(1152)](this),this[l(407)][l(1556)+l(1253)]);let w=()=>{let y=l;g[y(520)](g[y(1474)],g[y(1464)])?(_0x532d33=FMCfuZ[y(711)](FMCfuZ.AxhGo(FMCfuZ[y(546)](FMCfuZ[y(1144)](7&_0x23ef32,18),FMCfuZ[y(1144)](FMCfuZ[y(1176)](63,_0x18a06f),12)),FMCfuZ[y(1144)](FMCfuZ[y(1043)](63,_0x1808e0),6)),FMCfuZ[y(1176)](63,_0x71ee5b)),FMCfuZ[y(254)](_0x29e5bc,65536)||FMCfuZ[y(869)](_0x33940f,1114111)?_0x4eb74e+=_0x2c1d4b:(_0x3c2553-=65536,_0x47323a+=_0x1b28b4(FMCfuZ[y(305)](FMCfuZ.bTfYH(_0x347b48,10),55296),FMCfuZ[y(1097)](1023&_0x103f40,56320)),_0x5c9a35+=3)):(g[y(481)](a,g[y(432)]),this[y(663)](g[y(1559)],w),this[y(663)](g.mhhwS,h))},h=()=>{let y=l;r[y(1016)](d,r[y(906)]),this[y(663)](y(1339)+y(680)+"s",w),this[y(663)](r[y(898)],h)};this.on(e[l(1684)],w),this.on(l(1339)+l(1700)+"t",h),this._ping()})}}})(),Z["CustomCl"+C(337)]=Y[C(1350)+"oseEvent"],Z[C(995)+C(553)]=Y["CustomEr"+C(553)],Z[C(874)+"e"]=Y[C(874)+"e"],Z[C(939)]=Y.Event,Z.FWS=Y[C(1203)],Z[C(1677)+"MessageEvent"]=Y[C(1677)+C(1259)+C(1427)],Z.MessageEvent=Y[C(1259)+C(1427)],Z[C(744)+"t"]=Y.OpenEvent,Z[C(1105)+C(465)]=Y["Reconnec"+C(465)],Z[C(1346)+C(337)]=Y[C(1346)+C(337)],Z["createEr"+C(553)]=Y["createEr"+C(553)],Z["createMe"+C(1180)+"nt"]=Y[C(1111)+C(1180)+"nt"],Z[C(472)+C(754)]=Y[C(472)+C(754)],Z["createRe"+C(1238)+C(1427)]=Y["createRe"+C(1238)+"vent"],Z[C(1538)+C(498)]=Y[C(1538)+C(498)],Z["encodeFr"+C(615)]=Y[C(612)+C(615)];for(Bn in Y)["CustomCl"+C(337),C(995)+C(553),C(874)+"e",C(939),C(1203),C(1677)+C(1259)+C(1427),C(1259)+C(1427),"OpenEvent",C(1105)+C(465),"createCloseEvent",C(1005)+C(553),C(1111)+"ssageEvent",C(472)+"enEvent",C(1278)+"connectEvent","decodedF"+C(498),C(612)+"ame"].indexOf(Bn)===-1&&(Z[Bn]=Y[Bn]);var Bn;Object["definePr"+C(294)](Z,C(779)+"le",{value:!0})});var He=le((Zp,Po)=>{"use strict";var Io=["nodebuffer","arraybuffer","fragments"],ko=typeof Blob<"u";ko&&Io.push("blob");Po.exports={BINARY_TYPES:Io,CLOSE_TIMEOUT:3e4,EMPTY_BUFFER:Buffer.alloc(0),GUID:"258EAFA5-E914-47DA-95CA-C5AB0DC85B11",hasBlob:ko,kForOnEventAttribute:Symbol("kIsForOnEventAttribute"),kListener:Symbol("kListener"),kStatusCode:Symbol("status-code"),kWebSocket:Symbol("websocket"),NOOP:()=>{}}});var Xt=le((Qp,jn)=>{"use strict";var{EMPTY_BUFFER:Kd}=He(),Jr=Buffer[Symbol.species];function jd(n,e){if(n.length===0)return Kd;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 Jr(s.buffer,s.byteOffset,o):s}function To(n,e,s,o,c){for(let x=0;x<c;x++)s[o+x]=n[x]^e[x&3]}function Do(n,e){for(let s=0;s<n.length;s++)n[s]^=e[s&3]}function Gd(n){return n.length===n.buffer.byteLength?n.buffer:n.buffer.slice(n.byteOffset,n.byteOffset+n.length)}function $r(n){if($r.readOnly=!0,Buffer.isBuffer(n))return n;let e;return n instanceof ArrayBuffer?e=new Jr(n):ArrayBuffer.isView(n)?e=new Jr(n.buffer,n.byteOffset,n.byteLength):(e=Buffer.from(n),$r.readOnly=!1),e}jn.exports={concat:jd,mask:To,toArrayBuffer:Gd,toBuffer:$r,unmask:Do};if(!process.env.WS_NO_BUFFER_UTIL)try{let n=X("bufferutil");jn.exports.mask=function(e,s,o,c,x){x<48?To(e,s,o,c,x):n.mask(e,s,o,c,x)},jn.exports.unmask=function(e,s){e.length<32?Do(e,s):n.unmask(e,s)}}catch{}});var No=le((em,Lo)=>{"use strict";var Ro=Symbol("kDone"),Vr=Symbol("kRun"),Xr=class{constructor(e){this[Ro]=()=>{this.pending--,this[Vr]()},this.concurrency=e||1/0,this.jobs=[],this.pending=0}add(e){this.jobs.push(e),this[Vr]()}[Vr](){if(this.pending!==this.concurrency&&this.jobs.length){let e=this.jobs.shift();this.pending++,e(this[Ro])}}};Lo.exports=Xr});var kt=le((tm,zo)=>{"use strict";var Yt=X("zlib"),Oo=Xt(),Wd=No(),{kStatusCode:Mo}=He(),Jd=Buffer[Symbol.species],$d=Buffer.from([0,0,255,255]),Wn=Symbol("permessage-deflate"),Ke=Symbol("total-length"),At=Symbol("callback"),Qe=Symbol("buffers"),It=Symbol("error"),Gn,Yr=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,!Gn){let s=this._options.concurrencyLimit!==void 0?this._options.concurrencyLimit:10;Gn=new Wd(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[At];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){Gn.add(c=>{this._decompress(e,s,(x,f)=>{c(),o(x,f)})})}compress(e,s,o){Gn.add(c=>{this._compress(e,s,(x,f)=>{c(),o(x,f)})})}_decompress(e,s,o){let c=this._isServer?"client":"server";if(!this._inflate){let x=`${c}_max_window_bits`,f=typeof this.params[x]!="number"?Yt.Z_DEFAULT_WINDOWBITS:this.params[x];this._inflate=Yt.createInflateRaw({...this._options.zlibInflateOptions,windowBits:f}),this._inflate[Wn]=this,this._inflate[Ke]=0,this._inflate[Qe]=[],this._inflate.on("error",Xd),this._inflate.on("data",Bo)}this._inflate[At]=o,this._inflate.write(e),s&&this._inflate.write($d),this._inflate.flush(()=>{let x=this._inflate[It];if(x){this._inflate.close(),this._inflate=null,o(x);return}let f=Oo.concat(this._inflate[Qe],this._inflate[Ke]);this._inflate._readableState.endEmitted?(this._inflate.close(),this._inflate=null):(this._inflate[Ke]=0,this._inflate[Qe]=[],s&&this.params[`${c}_no_context_takeover`]&&this._inflate.reset()),o(null,f)})}_compress(e,s,o){let c=this._isServer?"server":"client";if(!this._deflate){let x=`${c}_max_window_bits`,f=typeof this.params[x]!="number"?Yt.Z_DEFAULT_WINDOWBITS:this.params[x];this._deflate=Yt.createDeflateRaw({...this._options.zlibDeflateOptions,windowBits:f}),this._deflate[Ke]=0,this._deflate[Qe]=[],this._deflate.on("data",Vd)}this._deflate[At]=o,this._deflate.write(e),this._deflate.flush(Yt.Z_SYNC_FLUSH,()=>{if(!this._deflate)return;let x=Oo.concat(this._deflate[Qe],this._deflate[Ke]);s&&(x=new Jd(x.buffer,x.byteOffset,x.length-4)),this._deflate[At]=null,this._deflate[Ke]=0,this._deflate[Qe]=[],s&&this.params[`${c}_no_context_takeover`]&&this._deflate.reset(),o(null,x)})}};zo.exports=Yr;function Vd(n){this[Qe].push(n),this[Ke]+=n.length}function Bo(n){if(this[Ke]+=n.length,this[Wn]._maxPayload<1||this[Ke]<=this[Wn]._maxPayload){this[Qe].push(n);return}this[It]=new RangeError("Max payload size exceeded"),this[It].code="WS_ERR_UNSUPPORTED_MESSAGE_LENGTH",this[It][Mo]=1009,this.removeListener("data",Bo),this.reset()}function Xd(n){if(this[Wn]._inflate=null,this[It]){this[At](this[It]);return}n[Mo]=1007,this[At](n)}});var Pt=le((nm,Jn)=>{"use strict";var{isUtf8:Fo}=X("buffer"),{hasBlob:Yd}=He(),Zd=[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 Qd(n){return n>=1e3&&n<=1014&&n!==1004&&n!==1005&&n!==1006||n>=3e3&&n<=4999}function Zr(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 ef(n){return Yd&&typeof n=="object"&&typeof n.arrayBuffer=="function"&&typeof n.type=="string"&&typeof n.stream=="function"&&(n[Symbol.toStringTag]==="Blob"||n[Symbol.toStringTag]==="File")}Jn.exports={isBlob:ef,isValidStatusCode:Qd,isValidUTF8:Zr,tokenChars:Zd};if(Fo)Jn.exports.isValidUTF8=function(n){return n.length<24?Zr(n):Fo(n)};else if(!process.env.WS_NO_UTF_8_VALIDATE)try{let n=X("utf-8-validate");Jn.exports.isValidUTF8=function(e){return e.length<32?Zr(e):n(e)}}catch{}});var ri=le((rm,Wo)=>{"use strict";var{Writable:tf}=X("stream"),Uo=kt(),{BINARY_TYPES:nf,EMPTY_BUFFER:qo,kStatusCode:rf,kWebSocket:sf}=He(),{concat:Qr,toArrayBuffer:of,unmask:af}=Xt(),{isValidStatusCode:cf,isValidUTF8:Ho}=Pt(),$n=Buffer[Symbol.species],be=0,Ko=1,jo=2,Go=3,ei=4,ti=5,Vn=6,ni=class extends tf{constructor(e={}){super(),this._allowSynchronousEvents=e.allowSynchronousEvents!==void 0?e.allowSynchronousEvents:!0,this._binaryType=e.binaryType||nf[0],this._extensions=e.extensions||{},this._isServer=!!e.isServer,this._maxPayload=e.maxPayload|0,this._skipUTF8Validation=!!e.skipUTF8Validation,this[sf]=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=be}_write(e,s,o){if(this._opcode===8&&this._state==be)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 $n(o.buffer,o.byteOffset+e,o.length-e),new $n(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 $n(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 be:this.getInfo(e);break;case Ko:this.getPayloadLength16(e);break;case jo:this.getPayloadLength64(e);break;case Go:this.getMask();break;case ei:this.getData(e);break;case ti:case Vn: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[Uo.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=Ko:this._payloadLength===127?this._state=jo: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=Go:this._state=ei}getMask(){if(this._bufferedBytes<4){this._loop=!1;return}this._mask=this.consume(4),this._state=ei}getData(e){let s=qo;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&&af(s,this._mask)}if(this._opcode>7){this.controlMessage(s,e);return}if(this._compressed){this._state=ti,this.decompress(s,e);return}s.length&&(this._messageLength=this._totalPayloadLength,this._fragments.push(s)),this.dataMessage(e)}decompress(e,s){this._extensions[Uo.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 f=this.createError(RangeError,"Max payload size exceeded",!1,1009,"WS_ERR_UNSUPPORTED_MESSAGE_LENGTH");s(f);return}this._fragments.push(x)}this.dataMessage(s),this._state===be&&this.startLoop(s)})}dataMessage(e){if(!this._fin){this._state=be;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=Qr(o,s):this._binaryType==="arraybuffer"?c=of(Qr(o,s)):this._binaryType==="blob"?c=new Blob(o):c=o,this._allowSynchronousEvents?(this.emit("message",c,!0),this._state=be):(this._state=Vn,setImmediate(()=>{this.emit("message",c,!0),this._state=be,this.startLoop(e)}))}else{let c=Qr(o,s);if(!this._skipUTF8Validation&&!Ho(c)){let x=this.createError(Error,"invalid UTF-8 sequence",!0,1007,"WS_ERR_INVALID_UTF8");e(x);return}this._state===ti||this._allowSynchronousEvents?(this.emit("message",c,!1),this._state=be):(this._state=Vn,setImmediate(()=>{this.emit("message",c,!1),this._state=be,this.startLoop(e)}))}}controlMessage(e,s){if(this._opcode===8){if(e.length===0)this._loop=!1,this.emit("conclude",1005,qo),this.end();else{let o=e.readUInt16BE(0);if(!cf(o)){let x=this.createError(RangeError,`invalid status code ${o}`,!0,1002,"WS_ERR_INVALID_CLOSE_CODE");s(x);return}let c=new $n(e.buffer,e.byteOffset+2,e.length-2);if(!this._skipUTF8Validation&&!Ho(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=be;return}this._allowSynchronousEvents?(this.emit(this._opcode===9?"ping":"pong",e),this._state=be):(this._state=Vn,setImmediate(()=>{this.emit(this._opcode===9?"ping":"pong",e),this._state=be,this.startLoop(s)}))}createError(e,s,o,c,x){this._loop=!1,this._errored=!0;let f=new e(o?`Invalid WebSocket frame: ${s}`:s);return Error.captureStackTrace(f,this.createError),f.code=x,f[rf]=c,f}};Wo.exports=ni});var oi=le((sm,Vo)=>{"use strict";var{Duplex:im}=X("stream"),{randomFillSync:xf}=X("crypto"),Jo=kt(),{EMPTY_BUFFER:df,kWebSocket:ff,NOOP:uf}=He(),{isBlob:Tt,isValidStatusCode:lf}=Pt(),{mask:$o,toBuffer:ot}=Xt(),ve=Symbol("kByteLength"),hf=Buffer.alloc(4),Xn=8*1024,at,Dt=Xn,Ae=0,gf=1,pf=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=Ae,this.onerror=uf,this[ff]=void 0}static frame(e,s){let o,c=!1,x=2,f=!1;s.mask&&(o=s.maskBuffer||hf,s.generateMask?s.generateMask(o):(Dt===Xn&&(at===void 0&&(at=Buffer.alloc(Xn)),xf(at,0,Xn),Dt=0),o[0]=at[Dt++],o[1]=at[Dt++],o[2]=at[Dt++],o[3]=at[Dt++]),f=(o[0]|o[1]|o[2]|o[3])===0,x=6);let u;typeof e=="string"?(!s.mask||f)&&s[ve]!==void 0?u=s[ve]:(e=Buffer.from(e),u=e.length):(u=e.length,c=s.mask&&s.readOnly&&!f);let p=u;u>=65536?(x+=8,p=127):u>125&&(x+=2,p=126);let m=Buffer.allocUnsafe(c?u+x:x);return m[0]=s.fin?s.opcode|128:s.opcode,s.rsv1&&(m[0]|=64),m[1]=p,p===126?m.writeUInt16BE(u,2):p===127&&(m[2]=m[3]=0,m.writeUIntBE(u,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],f?[m,e]:c?($o(e,o,m,x,u),[m]):($o(e,o,e,0,u),[m,e])):[m,e]}close(e,s,o,c){let x;if(e===void 0)x=df;else{if(typeof e!="number"||!lf(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 u=Buffer.byteLength(s);if(u>123)throw new RangeError("The message must not be greater than 123 bytes");x=Buffer.allocUnsafe(2+u),x.writeUInt16BE(e,0),typeof s=="string"?x.write(s,2):x.set(s,2)}}let f={[ve]:x.length,fin:!0,generateMask:this._generateMask,mask:o,maskBuffer:this._maskBuffer,opcode:8,readOnly:!1,rsv1:!1};this._state!==Ae?this.enqueue([this.dispatch,x,!1,f,c]):this.sendFrame(n.frame(x,f),c)}ping(e,s,o){let c,x;if(typeof e=="string"?(c=Buffer.byteLength(e),x=!1):Tt(e)?(c=e.size,x=!1):(e=ot(e),c=e.length,x=ot.readOnly),c>125)throw new RangeError("The data size must not be greater than 125 bytes");let f={[ve]:c,fin:!0,generateMask:this._generateMask,mask:s,maskBuffer:this._maskBuffer,opcode:9,readOnly:x,rsv1:!1};Tt(e)?this._state!==Ae?this.enqueue([this.getBlobData,e,!1,f,o]):this.getBlobData(e,!1,f,o):this._state!==Ae?this.enqueue([this.dispatch,e,!1,f,o]):this.sendFrame(n.frame(e,f),o)}pong(e,s,o){let c,x;if(typeof e=="string"?(c=Buffer.byteLength(e),x=!1):Tt(e)?(c=e.size,x=!1):(e=ot(e),c=e.length,x=ot.readOnly),c>125)throw new RangeError("The data size must not be greater than 125 bytes");let f={[ve]:c,fin:!0,generateMask:this._generateMask,mask:s,maskBuffer:this._maskBuffer,opcode:10,readOnly:x,rsv1:!1};Tt(e)?this._state!==Ae?this.enqueue([this.getBlobData,e,!1,f,o]):this.getBlobData(e,!1,f,o):this._state!==Ae?this.enqueue([this.dispatch,e,!1,f,o]):this.sendFrame(n.frame(e,f),o)}send(e,s,o){let c=this._extensions[Jo.extensionName],x=s.binary?2:1,f=s.compress,u,p;typeof e=="string"?(u=Buffer.byteLength(e),p=!1):Tt(e)?(u=e.size,p=!1):(e=ot(e),u=e.length,p=ot.readOnly),this._firstFragment?(this._firstFragment=!1,f&&c&&c.params[c._isServer?"server_no_context_takeover":"client_no_context_takeover"]&&(f=u>=c._threshold),this._compress=f):(f=!1,x=0),s.fin&&(this._firstFragment=!0);let m={[ve]:u,fin:s.fin,generateMask:this._generateMask,mask:s.mask,maskBuffer:this._maskBuffer,opcode:x,readOnly:p,rsv1:f};Tt(e)?this._state!==Ae?this.enqueue([this.getBlobData,e,this._compress,m,o]):this.getBlobData(e,this._compress,m,o):this._state!==Ae?this.enqueue([this.dispatch,e,this._compress,m,o]):this.dispatch(e,this._compress,m,o)}getBlobData(e,s,o,c){this._bufferedBytes+=o[ve],this._state=pf,e.arrayBuffer().then(x=>{if(this._socket.destroyed){let u=new Error("The socket was closed while the blob was being read");process.nextTick(si,this,u,c);return}this._bufferedBytes-=o[ve];let f=ot(x);s?this.dispatch(f,s,o,c):(this._state=Ae,this.sendFrame(n.frame(f,o),c),this.dequeue())}).catch(x=>{process.nextTick(mf,this,x,c)})}dispatch(e,s,o,c){if(!s){this.sendFrame(n.frame(e,o),c);return}let x=this._extensions[Jo.extensionName];this._bufferedBytes+=o[ve],this._state=gf,x.compress(e,o.fin,(f,u)=>{if(this._socket.destroyed){let p=new Error("The socket was closed while data was being compressed");si(this,p,c);return}this._bufferedBytes-=o[ve],this._state=Ae,o.readOnly=!1,this.sendFrame(n.frame(u,o),c),this.dequeue()})}dequeue(){for(;this._state===Ae&&this._queue.length;){let e=this._queue.shift();this._bufferedBytes-=e[3][ve],Reflect.apply(e[0],this,e.slice(1))}}enqueue(e){this._bufferedBytes+=e[3][ve],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)}};Vo.exports=ii;function si(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 mf(n,e,s){si(n,e,s),n.onerror(e)}});var ia=le((om,ra)=>{"use strict";var{kForOnEventAttribute:Zt,kListener:ai}=He(),Xo=Symbol("kCode"),Yo=Symbol("kData"),Zo=Symbol("kError"),Qo=Symbol("kMessage"),ea=Symbol("kReason"),Rt=Symbol("kTarget"),ta=Symbol("kType"),na=Symbol("kWasClean"),je=class{constructor(e){this[Rt]=null,this[ta]=e}get target(){return this[Rt]}get type(){return this[ta]}};Object.defineProperty(je.prototype,"target",{enumerable:!0});Object.defineProperty(je.prototype,"type",{enumerable:!0});var ct=class extends je{constructor(e,s={}){super(e),this[Xo]=s.code===void 0?0:s.code,this[ea]=s.reason===void 0?"":s.reason,this[na]=s.wasClean===void 0?!1:s.wasClean}get code(){return this[Xo]}get reason(){return this[ea]}get wasClean(){return this[na]}};Object.defineProperty(ct.prototype,"code",{enumerable:!0});Object.defineProperty(ct.prototype,"reason",{enumerable:!0});Object.defineProperty(ct.prototype,"wasClean",{enumerable:!0});var Lt=class extends je{constructor(e,s={}){super(e),this[Zo]=s.error===void 0?null:s.error,this[Qo]=s.message===void 0?"":s.message}get error(){return this[Zo]}get message(){return this[Qo]}};Object.defineProperty(Lt.prototype,"error",{enumerable:!0});Object.defineProperty(Lt.prototype,"message",{enumerable:!0});var Qt=class extends je{constructor(e,s={}){super(e),this[Yo]=s.data===void 0?null:s.data}get data(){return this[Yo]}};Object.defineProperty(Qt.prototype,"data",{enumerable:!0});var wf={addEventListener(n,e,s={}){for(let c of this.listeners(n))if(!s[Zt]&&c[ai]===e&&!c[Zt])return;let o;if(n==="message")o=function(x,f){let u=new Qt("message",{data:f?x:x.toString()});u[Rt]=this,Yn(e,this,u)};else if(n==="close")o=function(x,f){let u=new ct("close",{code:x,reason:f.toString(),wasClean:this._closeFrameReceived&&this._closeFrameSent});u[Rt]=this,Yn(e,this,u)};else if(n==="error")o=function(x){let f=new Lt("error",{error:x,message:x.message});f[Rt]=this,Yn(e,this,f)};else if(n==="open")o=function(){let x=new je("open");x[Rt]=this,Yn(e,this,x)};else return;o[Zt]=!!s[Zt],o[ai]=e,s.once?this.once(n,o):this.on(n,o)},removeEventListener(n,e){for(let s of this.listeners(n))if(s[ai]===e&&!s[Zt]){this.removeListener(n,s);break}}};ra.exports={CloseEvent:ct,ErrorEvent:Lt,Event:je,EventTarget:wf,MessageEvent:Qt};function Yn(n,e,s){typeof n=="object"&&n.handleEvent?n.handleEvent.call(n,s):n.call(e,s)}});var Zn=le((am,sa)=>{"use strict";var{tokenChars:en}=Pt();function Oe(n,e,s){n[e]===void 0?n[e]=[s]:n[e].push(s)}function _f(n){let e=Object.create(null),s=Object.create(null),o=!1,c=!1,x=!1,f,u,p=-1,m=-1,b=-1,_=0;for(;_<n.length;_++)if(m=n.charCodeAt(_),f===void 0)if(b===-1&&en[m]===1)p===-1&&(p=_);else if(_!==0&&(m===32||m===9))b===-1&&p!==-1&&(b=_);else if(m===59||m===44){if(p===-1)throw new SyntaxError(`Unexpected character at index ${_}`);b===-1&&(b=_);let T=n.slice(p,b);m===44?(Oe(e,T,s),s=Object.create(null)):f=T,p=b=-1}else throw new SyntaxError(`Unexpected character at index ${_}`);else if(u===void 0)if(b===-1&&en[m]===1)p===-1&&(p=_);else if(m===32||m===9)b===-1&&p!==-1&&(b=_);else if(m===59||m===44){if(p===-1)throw new SyntaxError(`Unexpected character at index ${_}`);b===-1&&(b=_),Oe(s,n.slice(p,b),!0),m===44&&(Oe(e,f,s),s=Object.create(null),f=void 0),p=b=-1}else if(m===61&&p!==-1&&b===-1)u=n.slice(p,_),p=b=-1;else throw new SyntaxError(`Unexpected character at index ${_}`);else if(c){if(en[m]!==1)throw new SyntaxError(`Unexpected character at index ${_}`);p===-1?p=_:o||(o=!0),c=!1}else if(x)if(en[m]===1)p===-1&&(p=_);else if(m===34&&p!==-1)x=!1,b=_;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(b===-1&&en[m]===1)p===-1&&(p=_);else if(p!==-1&&(m===32||m===9))b===-1&&(b=_);else if(m===59||m===44){if(p===-1)throw new SyntaxError(`Unexpected character at index ${_}`);b===-1&&(b=_);let T=n.slice(p,b);o&&(T=T.replace(/\\/g,""),o=!1),Oe(s,u,T),m===44&&(Oe(e,f,s),s=Object.create(null),f=void 0),u=void 0,p=b=-1}else throw new SyntaxError(`Unexpected character at index ${_}`);if(p===-1||x||m===32||m===9)throw new SyntaxError("Unexpected end of input");b===-1&&(b=_);let E=n.slice(p,b);return f===void 0?Oe(e,E,s):(u===void 0?Oe(s,E,!0):o?Oe(s,u,E.replace(/\\/g,"")):Oe(s,u,E),Oe(e,f,s)),e}function yf(n){return Object.keys(n).map(e=>{let s=n[e];return Array.isArray(s)||(s=[s]),s.map(o=>[e].concat(Object.keys(o).map(c=>{let x=o[c];return Array.isArray(x)||(x=[x]),x.map(f=>f===!0?c:`${c}=${f}`).join("; ")})).join("; ")).join(", ")}).join(", ")}sa.exports={format:yf,parse:_f}});var nr=le((dm,ma)=>{"use strict";var bf=X("events"),vf=X("https"),Sf=X("http"),ca=X("net"),Ef=X("tls"),{randomBytes:Cf,createHash:Af}=X("crypto"),{Duplex:cm,Readable:xm}=X("stream"),{URL:ci}=X("url"),et=kt(),If=ri(),kf=oi(),{isBlob:Pf}=Pt(),{BINARY_TYPES:oa,CLOSE_TIMEOUT:Tf,EMPTY_BUFFER:Qn,GUID:Df,kForOnEventAttribute:xi,kListener:Rf,kStatusCode:Lf,kWebSocket:re,NOOP:xa}=He(),{EventTarget:{addEventListener:Nf,removeEventListener:Of}}=ia(),{format:Mf,parse:Bf}=Zn(),{toBuffer:zf}=Xt(),da=Symbol("kAborted"),di=[8,13],Ge=["CONNECTING","OPEN","CLOSING","CLOSED"],Ff=/^[!#$%&'*+\-.0-9A-Z^_`|a-z~]+$/,J=class n extends bf{constructor(e,s,o){super(),this._binaryType=oa[0],this._closeCode=1006,this._closeFrameReceived=!1,this._closeFrameSent=!1,this._closeMessage=Qn,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]),fa(this,e,s,o)):(this._autoPong=o.autoPong,this._closeTimeout=o.closeTimeout,this._isServer=!0)}get binaryType(){return this._binaryType}set binaryType(e){oa.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 If({allowSynchronousEvents:o.allowSynchronousEvents,binaryType:this.binaryType,extensions:this._extensions,isServer:this._isServer,maxPayload:o.maxPayload,skipUTF8Validation:o.skipUTF8Validation}),x=new kf(e,this._extensions,o.generateMask);this._receiver=c,this._sender=x,this._socket=e,c[re]=this,x[re]=this,e[re]=this,c.on("conclude",Hf),c.on("drain",Kf),c.on("error",jf),c.on("message",Gf),c.on("ping",Wf),c.on("pong",Jf),x.onerror=$f,e.setTimeout&&e.setTimeout(0),e.setNoDelay&&e.setNoDelay(),s.length>0&&e.unshift(s),e.on("close",ha),e.on("data",tr),e.on("end",ga),e.on("error",pa),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[et.extensionName]&&this._extensions[et.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){me(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())}),la(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){fi(this,e,o);return}s===void 0&&(s=!this._isServer),this._sender.ping(e||Qn,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){fi(this,e,o);return}s===void 0&&(s=!this._isServer),this._sender.pong(e||Qn,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){fi(this,e,o);return}let c={binary:typeof e!="string",mask:!this._isServer,compress:!0,fin:!0,...s};this._extensions[et.extensionName]||(c.compress=!1),this._sender.send(e||Qn,c,o)}terminate(){if(this.readyState!==n.CLOSED){if(this.readyState===n.CONNECTING){me(this,this._req,"WebSocket was closed before the connection was established");return}this._socket&&(this._readyState=n.CLOSING,this._socket.destroy())}}};Object.defineProperty(J,"CONNECTING",{enumerable:!0,value:Ge.indexOf("CONNECTING")});Object.defineProperty(J.prototype,"CONNECTING",{enumerable:!0,value:Ge.indexOf("CONNECTING")});Object.defineProperty(J,"OPEN",{enumerable:!0,value:Ge.indexOf("OPEN")});Object.defineProperty(J.prototype,"OPEN",{enumerable:!0,value:Ge.indexOf("OPEN")});Object.defineProperty(J,"CLOSING",{enumerable:!0,value:Ge.indexOf("CLOSING")});Object.defineProperty(J.prototype,"CLOSING",{enumerable:!0,value:Ge.indexOf("CLOSING")});Object.defineProperty(J,"CLOSED",{enumerable:!0,value:Ge.indexOf("CLOSED")});Object.defineProperty(J.prototype,"CLOSED",{enumerable:!0,value:Ge.indexOf("CLOSED")});["binaryType","bufferedAmount","extensions","isPaused","protocol","readyState","url"].forEach(n=>{Object.defineProperty(J.prototype,n,{enumerable:!0})});["open","error","close","message"].forEach(n=>{Object.defineProperty(J.prototype,`on${n}`,{enumerable:!0,get(){for(let e of this.listeners(n))if(e[xi])return e[Rf];return null},set(e){for(let s of this.listeners(n))if(s[xi]){this.removeListener(n,s);break}typeof e=="function"&&this.addEventListener(n,e,{[xi]:!0})}})});J.prototype.addEventListener=Nf;J.prototype.removeEventListener=Of;ma.exports=J;function fa(n,e,s,o){let c={allowSynchronousEvents:!0,autoPong:!0,closeTimeout:Tf,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 ci)x=e;else try{x=new ci(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 f=x.protocol==="wss:",u=x.protocol==="ws+unix:",p;if(x.protocol!=="ws:"&&!f&&!u?p=`The URL's protocol must be one of "ws:", "wss:", "http:", "https:", or "ws+unix:"`:u&&!x.pathname?p="The URL's pathname is empty":x.hash&&(p="The URL contains a fragment identifier"),p){let D=new SyntaxError(p);if(n._redirects===0)throw D;er(n,D);return}let m=f?443:80,b=Cf(16).toString("base64"),_=f?vf.request:Sf.request,E=new Set,T;if(c.createConnection=c.createConnection||(f?qf:Uf),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":b,Connection:"Upgrade",Upgrade:"websocket"},c.path=x.pathname+x.search,c.timeout=c.handshakeTimeout,c.perMessageDeflate&&(T=new et({...c.perMessageDeflate,isServer:!1,maxPayload:c.maxPayload}),c.headers["Sec-WebSocket-Extensions"]=Mf({[et.extensionName]:T.offer()})),s.length){for(let D of s){if(typeof D!="string"||!Ff.test(D)||E.has(D))throw new SyntaxError("An invalid or duplicated subprotocol was specified");E.add(D)}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}`),u){let D=c.path.split(":");c.socketPath=D[0],c.path=D[1]}let k;if(c.followRedirects){if(n._redirects===0){n._originalIpc=u,n._originalSecure=f,n._originalHostOrSocketPath=u?c.socketPath:x.host;let D=o&&o.headers;if(o={...o,headers:{}},D)for(let[F,ie]of Object.entries(D))o.headers[F.toLowerCase()]=ie}else if(n.listenerCount("redirect")===0){let D=u?n._originalIpc?c.socketPath===n._originalHostOrSocketPath:!1:n._originalIpc?!1:x.host===n._originalHostOrSocketPath;(!D||n._originalSecure&&!f)&&(delete c.headers.authorization,delete c.headers.cookie,D||delete c.headers.host,c.auth=void 0)}c.auth&&!o.headers.authorization&&(o.headers.authorization="Basic "+Buffer.from(c.auth).toString("base64")),k=n._req=_(c),n._redirects&&n.emit("redirect",n.url,k)}else k=n._req=_(c);c.timeout&&k.on("timeout",()=>{me(n,k,"Opening handshake has timed out")}),k.on("error",D=>{k===null||k[da]||(k=n._req=null,er(n,D))}),k.on("response",D=>{let F=D.headers.location,ie=D.statusCode;if(F&&c.followRedirects&&ie>=300&&ie<400){if(++n._redirects>c.maxRedirects){me(n,k,"Maximum redirects exceeded");return}k.abort();let $;try{$=new ci(F,e)}catch{let te=new SyntaxError(`Invalid URL: ${F}`);er(n,te);return}fa(n,$,s,o)}else n.emit("unexpected-response",k,D)||me(n,k,`Unexpected server response: ${D.statusCode}`)}),k.on("upgrade",(D,F,ie)=>{if(n.emit("upgrade",D),n.readyState!==J.CONNECTING)return;k=n._req=null;let $=D.headers.upgrade;if($===void 0||$.toLowerCase()!=="websocket"){me(n,F,"Invalid Upgrade header");return}let we=Af("sha1").update(b+Df).digest("base64");if(D.headers["sec-websocket-accept"]!==we){me(n,F,"Invalid Sec-WebSocket-Accept header");return}let te=D.headers["sec-websocket-protocol"],ae;if(te!==void 0?E.size?E.has(te)||(ae="Server sent an invalid subprotocol"):ae="Server sent a subprotocol but none was requested":E.size&&(ae="Server sent no subprotocol"),ae){me(n,F,ae);return}te&&(n._protocol=te);let ce=D.headers["sec-websocket-extensions"];if(ce!==void 0){if(!T){me(n,F,"Server sent a Sec-WebSocket-Extensions header but no extension was requested");return}let A;try{A=Bf(ce)}catch{me(n,F,"Invalid Sec-WebSocket-Extensions header");return}let N=Object.keys(A);if(N.length!==1||N[0]!==et.extensionName){me(n,F,"Server indicated an extension that was not requested");return}try{T.accept(A[et.extensionName])}catch{me(n,F,"Invalid Sec-WebSocket-Extensions header");return}n._extensions[et.extensionName]=T}n.setSocket(F,ie,{allowSynchronousEvents:c.allowSynchronousEvents,generateMask:c.generateMask,maxPayload:c.maxPayload,skipUTF8Validation:c.skipUTF8Validation})}),c.finishRequest?c.finishRequest(k,n):k.end()}function er(n,e){n._readyState=J.CLOSING,n._errorEmitted=!0,n.emit("error",e),n.emitClose()}function Uf(n){return n.path=n.socketPath,ca.connect(n)}function qf(n){return n.path=void 0,!n.servername&&n.servername!==""&&(n.servername=ca.isIP(n.host)?"":n.host),Ef.connect(n)}function me(n,e,s){n._readyState=J.CLOSING;let o=new Error(s);Error.captureStackTrace(o,me),e.setHeader?(e[da]=!0,e.abort(),e.socket&&!e.socket.destroyed&&e.socket.destroy(),process.nextTick(er,n,o)):(e.destroy(o),e.once("error",n.emit.bind(n,"error")),e.once("close",n.emitClose.bind(n)))}function fi(n,e,s){if(e){let o=Pf(e)?e.size:zf(e).length;n._socket?n._sender._bufferedBytes+=o:n._bufferedAmount+=o}if(s){let o=new Error(`WebSocket is not open: readyState ${n.readyState} (${Ge[n.readyState]})`);process.nextTick(s,o)}}function Hf(n,e){let s=this[re];s._closeFrameReceived=!0,s._closeMessage=e,s._closeCode=n,s._socket[re]!==void 0&&(s._socket.removeListener("data",tr),process.nextTick(ua,s._socket),n===1005?s.close():s.close(n,e))}function Kf(){let n=this[re];n.isPaused||n._socket.resume()}function jf(n){let e=this[re];e._socket[re]!==void 0&&(e._socket.removeListener("data",tr),process.nextTick(ua,e._socket),e.close(n[Lf])),e._errorEmitted||(e._errorEmitted=!0,e.emit("error",n))}function aa(){this[re].emitClose()}function Gf(n,e){this[re].emit("message",n,e)}function Wf(n){let e=this[re];e._autoPong&&e.pong(n,!this._isServer,xa),e.emit("ping",n)}function Jf(n){this[re].emit("pong",n)}function ua(n){n.resume()}function $f(n){let e=this[re];e.readyState!==J.CLOSED&&(e.readyState===J.OPEN&&(e._readyState=J.CLOSING,la(e)),this._socket.end(),e._errorEmitted||(e._errorEmitted=!0,e.emit("error",n)))}function la(n){n._closeTimer=setTimeout(n._socket.destroy.bind(n._socket),n._closeTimeout)}function ha(){let n=this[re];if(this.removeListener("close",ha),this.removeListener("data",tr),this.removeListener("end",ga),n._readyState=J.CLOSING,!this._readableState.endEmitted&&!n._closeFrameReceived&&!n._receiver._writableState.errorEmitted&&this._readableState.length!==0){let e=this.read(this._readableState.length);n._receiver.write(e)}n._receiver.end(),this[re]=void 0,clearTimeout(n._closeTimer),n._receiver._writableState.finished||n._receiver._writableState.errorEmitted?n.emitClose():(n._receiver.on("error",aa),n._receiver.on("finish",aa))}function tr(n){this[re]._receiver.write(n)||this.pause()}function ga(){let n=this[re];n._readyState=J.CLOSING,n._receiver.end(),this.end()}function pa(){let n=this[re];this.removeListener("error",pa),this.on("error",xa),n&&(n._readyState=J.CLOSING,this.destroy())}});var ba=le((um,ya)=>{"use strict";var fm=nr(),{Duplex:Vf}=X("stream");function wa(n){n.emit("close")}function Xf(){!this.destroyed&&this._writableState.finished&&this.destroy()}function _a(n){this.removeListener("error",_a),this.destroy(),this.listenerCount("error")===0&&this.emit("error",n)}function Yf(n,e){let s=!0,o=new Vf({...e,autoDestroy:!1,emitClose:!1,objectMode:!1,writableObjectMode:!1});return n.on("message",function(x,f){let u=!f&&o._readableState.objectMode?x.toString():x;o.push(u)||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(wa,o);return}let f=!1;n.once("error",function(p){f=!0,x(p)}),n.once("close",function(){f||x(c),process.nextTick(wa,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,f){if(n.readyState===n.CONNECTING){n.once("open",function(){o._write(c,x,f)});return}n.send(c,f)},o.on("end",Xf),o.on("error",_a),o}ya.exports=Yf});var ui=le((lm,va)=>{"use strict";var{tokenChars:Zf}=Pt();function Qf(n){let e=new Set,s=-1,o=-1,c=0;for(c;c<n.length;c++){let f=n.charCodeAt(c);if(o===-1&&Zf[f]===1)s===-1&&(s=c);else if(c!==0&&(f===32||f===9))o===-1&&s!==-1&&(o=c);else if(f===44){if(s===-1)throw new SyntaxError(`Unexpected character at index ${c}`);o===-1&&(o=c);let u=n.slice(s,o);if(e.has(u))throw new SyntaxError(`The "${u}" subprotocol is duplicated`);e.add(u),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}va.exports={parse:Qf}});var Pa=le((gm,ka)=>{"use strict";var eu=X("events"),rr=X("http"),{Duplex:hm}=X("stream"),{createHash:tu}=X("crypto"),Sa=Zn(),xt=kt(),nu=ui(),ru=nr(),{CLOSE_TIMEOUT:iu,GUID:su,kWebSocket:ou}=He(),au=/^[+/0-9A-Za-z]{22}==$/,Ea=0,Ca=1,Ia=2,li=class extends eu{constructor(e,s){if(super(),e={allowSynchronousEvents:!0,autoPong:!0,maxPayload:100*1024*1024,skipUTF8Validation:!1,perMessageDeflate:!1,handleProtocols:null,clientTracking:!0,closeTimeout:iu,verifyClient:null,noServer:!1,backlog:null,server:null,host:null,path:null,port:null,WebSocket:ru,...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=rr.createServer((o,c)=>{let x=rr.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=cu(this._server,{listening:this.emit.bind(this,"listening"),error:this.emit.bind(this,"error"),upgrade:(c,x,f)=>{this.handleUpgrade(c,x,f,o)}})}e.perMessageDeflate===!0&&(e.perMessageDeflate={}),e.clientTracking&&(this.clients=new Set,this._shouldEmitClose=!1),this.options=e,this._state=Ea}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===Ia){e&&this.once("close",()=>{e(new Error("The server is not running"))}),process.nextTick(tn,this);return}if(e&&this.once("close",e),this._state!==Ca)if(this._state=Ca,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(tn,this):process.nextTick(tn,this);else{let s=this._server;this._removeListeners(),this._removeListeners=this._server=null,s.close(()=>{tn(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",Aa);let x=e.headers["sec-websocket-key"],f=e.headers.upgrade,u=+e.headers["sec-websocket-version"];if(e.method!=="GET"){dt(this,e,s,405,"Invalid HTTP method");return}if(f===void 0||f.toLowerCase()!=="websocket"){dt(this,e,s,400,"Invalid Upgrade header");return}if(x===void 0||!au.test(x)){dt(this,e,s,400,"Missing or invalid Sec-WebSocket-Key header");return}if(u!==13&&u!==8){dt(this,e,s,400,"Missing or invalid Sec-WebSocket-Version header",{"Sec-WebSocket-Version":"13, 8"});return}if(!this.shouldHandle(e)){nn(s,400);return}let p=e.headers["sec-websocket-protocol"],m=new Set;if(p!==void 0)try{m=nu.parse(p)}catch{dt(this,e,s,400,"Invalid Sec-WebSocket-Protocol header");return}let b=e.headers["sec-websocket-extensions"],_={};if(this.options.perMessageDeflate&&b!==void 0){let E=new xt({...this.options.perMessageDeflate,isServer:!0,maxPayload:this.options.maxPayload});try{let T=Sa.parse(b);T[xt.extensionName]&&(E.accept(T[xt.extensionName]),_[xt.extensionName]=E)}catch{dt(this,e,s,400,"Invalid or unacceptable Sec-WebSocket-Extensions header");return}}if(this.options.verifyClient){let E={origin:e.headers[`${u===8?"sec-websocket-origin":"origin"}`],secure:!!(e.socket.authorized||e.socket.encrypted),req:e};if(this.options.verifyClient.length===2){this.options.verifyClient(E,(T,k,D,F)=>{if(!T)return nn(s,k||401,D,F);this.completeUpgrade(_,x,m,e,s,o,c)});return}if(!this.options.verifyClient(E))return nn(s,401)}this.completeUpgrade(_,x,m,e,s,o,c)}completeUpgrade(e,s,o,c,x,f,u){if(!x.readable||!x.writable)return x.destroy();if(x[ou])throw new Error("server.handleUpgrade() was called more than once with the same socket, possibly due to a misconfiguration");if(this._state>Ea)return nn(x,503);let m=["HTTP/1.1 101 Switching Protocols","Upgrade: websocket","Connection: Upgrade",`Sec-WebSocket-Accept: ${tu("sha1").update(s+su).digest("base64")}`],b=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: ${_}`),b._protocol=_)}if(e[xt.extensionName]){let _=e[xt.extensionName].params,E=Sa.format({[xt.extensionName]:[_]});m.push(`Sec-WebSocket-Extensions: ${E}`),b._extensions=e}this.emit("headers",m,c),x.write(m.concat(`\r
12
12
  `).join(`\r
13
- `)),d.removeListener("error",Ca),v.setSocket(d,f,{allowSynchronousEvents:this.options.allowSynchronousEvents,maxPayload:this.options.maxPayload,skipUTF8Validation:this.options.skipUTF8Validation}),this.clients&&(this.clients.add(v),v.on("close",()=>{this.clients.delete(v),this._shouldEmitClose&&!this.clients.size&&process.nextTick(tn,this)})),l(v,c)}};Pa.exports=fi;function cf(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 tn(n){n._state=Ia,n.emit("close")}function Ca(){this.destroy()}function nn(n,e,s,o){s=s||rr.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} ${rr.STATUS_CODES[e]}\r
13
+ `)),x.removeListener("error",Aa),b.setSocket(x,f,{allowSynchronousEvents:this.options.allowSynchronousEvents,maxPayload:this.options.maxPayload,skipUTF8Validation:this.options.skipUTF8Validation}),this.clients&&(this.clients.add(b),b.on("close",()=>{this.clients.delete(b),this._shouldEmitClose&&!this.clients.size&&process.nextTick(tn,this)})),u(b,c)}};ka.exports=li;function cu(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 tn(n){n._state=Ia,n.emit("close")}function Aa(){this.destroy()}function nn(n,e,s,o){s=s||rr.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} ${rr.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 dt(n,e,s,o,c,d){if(n.listenerCount("wsClientError")){let f=new Error(c);Error.captureStackTrace(f,dt),n.emit("wsClientError",f,s,e)}else nn(s,o,c,d)}});import{spawn as Lf}from"node:child_process";import{existsSync as Of,openSync as Bf}from"node:fs";import{mkdir as Mf}from"node:fs/promises";import{dirname as zf}from"node:path";import{fileURLToPath as Ff}from"node:url";function mi(n=F()){return Of(n.libEntry)?n.libEntry:Ff(new URL("../index.ts",import.meta.url))}async function wi(n={}){let e=n.paths??F(),s=n.entryOverride??mi(e);await Mf(zf(e.logFile),{recursive:!0});let o=Bf(e.logFile,"a"),d=s.endsWith(".ts")?["--import","tsx/esm",s,"--daemon"]:[s,"--daemon"],f=Lf(process.execPath,d,{detached:!0,stdio:["ignore",o,o],env:{...process.env,COZE_BRIDGE_DAEMON:"1"}});if(f.unref(),typeof f.pid!="number")throw new Error("failed to spawn daemon (no pid)");return Uf.info("daemon spawned",{pid:f.pid,entry:s}),{pid:f.pid,entry:s}}var Uf,_i=ze(()=>{"use strict";U();ie();Uf=D("spawn-daemon")});import{spawn as tl}from"node:child_process";import{mkdir as nl,unlink as rl,writeFile as il}from"node:fs/promises";import{dirname as sl,join as ol}from"node:path";function ur(n){return n.replace(/&/g,"&amp;").replace(/</g,"&lt;").replace(/>/g,"&gt;").replace(/"/g,"&quot;")}function Xa(n,e){return new Promise((s,o)=>{let c=tl(n,e,{stdio:["ignore","pipe","pipe"]}),d="";c.stderr?.on("data",f=>{d+=f.toString("utf8")}),c.on("error",o),c.on("close",f=>{f===0?s():o(new Error(`${n} ${e.join(" ")} exited ${f}: ${d.trim()}`))})})}var dr,Si,Ei,Za=ze(()=>{"use strict";U();dr=D("supervisor.launchd"),Si="ai.coze.bridge",Ei={platform:"darwin",renderConfig(n){return`<?xml version="1.0" encoding="UTF-8"?>
17
+ `+s)}function dt(n,e,s,o,c,x){if(n.listenerCount("wsClientError")){let f=new Error(c);Error.captureStackTrace(f,dt),n.emit("wsClientError",f,s,e)}else nn(s,o,c,x)}});import{spawn as Nu}from"node:child_process";import{existsSync as Ou,openSync as Mu}from"node:fs";import{mkdir as Bu}from"node:fs/promises";import{dirname as zu}from"node:path";import{fileURLToPath as Fu}from"node:url";function wi(n=U()){return Ou(n.libEntry)?n.libEntry:Fu(new URL("../index.ts",import.meta.url))}async function _i(n={}){let e=n.paths??U(),s=n.entryOverride??wi(e);await Bu(zu(e.logFile),{recursive:!0});let o=Mu(e.logFile,"a"),x=s.endsWith(".ts")?["--import","tsx/esm",s,"--daemon"]:[s,"--daemon"],f=Nu(process.execPath,x,{detached:!0,stdio:["ignore",o,o],env:{...process.env,COZE_BRIDGE_DAEMON:"1"}});if(f.unref(),typeof f.pid!="number")throw new Error("failed to spawn daemon (no pid)");return Uu.info("daemon spawned",{pid:f.pid,entry:s}),{pid:f.pid,entry:s}}var Uu,yi=ze(()=>{"use strict";q();oe();Uu=R("spawn-daemon")});import{spawn as tl}from"node:child_process";import{mkdir as nl,unlink as rl,writeFile as il}from"node:fs/promises";import{dirname as sl,join as ol}from"node:path";function fr(n){return n.replace(/&/g,"&amp;").replace(/</g,"&lt;").replace(/>/g,"&gt;").replace(/"/g,"&quot;")}function Ya(n,e){return new Promise((s,o)=>{let c=tl(n,e,{stdio:["ignore","pipe","pipe"]}),x="";c.stderr?.on("data",f=>{x+=f.toString("utf8")}),c.on("error",o),c.on("close",f=>{f===0?s():o(new Error(`${n} ${e.join(" ")} exited ${f}: ${x.trim()}`))})})}var dr,Ei,Ci,Za=ze(()=>{"use strict";q();dr=R("supervisor.launchd"),Ei="ai.coze.bridge",Ci={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>${Si}</string>
22
+ <string>${Ei}</string>
23
23
  <key>ProgramArguments</key>
24
24
  <array>
25
- <string>${ur(n.nodeBin)}</string>
26
- <string>${ur(n.entry)}</string>
25
+ <string>${fr(n.nodeBin)}</string>
26
+ <string>${fr(n.entry)}</string>
27
27
  <string>--daemon</string>
28
28
  </array>
29
29
  <key>RunAtLoad</key>
@@ -33,12 +33,12 @@ var e0=Object.create;var Pr=Object.defineProperty;var t0=Object.getOwnPropertyDe
33
33
  <key>ThrottleInterval</key>
34
34
  <integer>10</integer>
35
35
  <key>StandardOutPath</key>
36
- <string>${ur(n.logFile)}</string>
36
+ <string>${fr(n.logFile)}</string>
37
37
  <key>StandardErrorPath</key>
38
- <string>${ur(n.logFile)}</string>
38
+ <string>${fr(n.logFile)}</string>
39
39
  </dict>
40
40
  </plist>
41
- `},configPath(n){return ol(n.homeDir,"Library","LaunchAgents",`${Si}.plist`)},async install(n){let e=this.configPath(n);await nl(sl(e),{recursive:!0}),await il(e,this.renderConfig(n),"utf8"),dr.info("plist written",{plistPath:e}),await Xa("launchctl",["load","-w",e]),dr.info("launchd job loaded",{label:Si})},async uninstall(n){let e=this.configPath(n);await Xa("launchctl",["unload","-w",e]).catch(s=>dr.warn("launchctl unload failed (ignored)",{err:String(s)})),await rl(e).catch(s=>{if(s.code!=="ENOENT")throw s}),dr.info("launchd job removed",{plistPath:e})}}});import{spawn as al}from"node:child_process";import{mkdir as cl,unlink as xl,writeFile as dl}from"node:fs/promises";import{dirname as ul,join as fl}from"node:path";function gr(n,e){return new Promise((s,o)=>{let c=al(n,e,{stdio:["ignore","pipe","pipe"]}),d="";c.stderr?.on("data",f=>{d+=f.toString("utf8")}),c.on("error",o),c.on("close",f=>{f===0?s():o(new Error(`${n} ${e.join(" ")} exited ${f}: ${d.trim()}`))})})}var fr,lr,Ai,Qa=ze(()=>{"use strict";U();fr=D("supervisor.systemd"),lr="coze-bridge.service",Ai={platform:"linux",renderConfig(n){return`[Unit]
41
+ `},configPath(n){return ol(n.homeDir,"Library","LaunchAgents",`${Ei}.plist`)},async install(n){let e=this.configPath(n);await nl(sl(e),{recursive:!0}),await il(e,this.renderConfig(n),"utf8"),dr.info("plist written",{plistPath:e}),await Ya("launchctl",["load","-w",e]),dr.info("launchd job loaded",{label:Ei})},async uninstall(n){let e=this.configPath(n);await Ya("launchctl",["unload","-w",e]).catch(s=>dr.warn("launchctl unload failed (ignored)",{err:String(s)})),await rl(e).catch(s=>{if(s.code!=="ENOENT")throw s}),dr.info("launchd job removed",{plistPath:e})}}});import{spawn as al}from"node:child_process";import{mkdir as cl,unlink as xl,writeFile as dl}from"node:fs/promises";import{dirname as fl,join as ul}from"node:path";function hr(n,e){return new Promise((s,o)=>{let c=al(n,e,{stdio:["ignore","pipe","pipe"]}),x="";c.stderr?.on("data",f=>{x+=f.toString("utf8")}),c.on("error",o),c.on("close",f=>{f===0?s():o(new Error(`${n} ${e.join(" ")} exited ${f}: ${x.trim()}`))})})}var ur,lr,Ai,Qa=ze(()=>{"use strict";q();ur=R("supervisor.systemd"),lr="coze-bridge.service",Ai={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 fl(n.homeDir,".config","systemd","user",lr)},async install(n){let e=this.configPath(n);await cl(ul(e),{recursive:!0}),await dl(e,this.renderConfig(n),"utf8"),fr.info("systemd unit written",{unitPath:e}),await gr("systemctl",["--user","daemon-reload"]),await gr("systemctl",["--user","enable","--now",lr]),fr.info("systemd unit enabled",{unitName:lr})},async uninstall(n){let e=this.configPath(n);await gr("systemctl",["--user","disable","--now",lr]).catch(s=>fr.warn("systemctl disable failed (ignored)",{err:String(s)})),await xl(e).catch(s=>{if(s.code!=="ENOENT")throw s}),await gr("systemctl",["--user","daemon-reload"]).catch(()=>{}),fr.info("systemd unit removed",{unitPath:e})}}});import{spawn as ll}from"node:child_process";import{join as gl}from"node:path";function ec(n,e){return new Promise((s,o)=>{let c=ll(n,e,{stdio:["ignore","pipe","pipe"],shell:!1}),d="";c.stderr?.on("data",f=>{d+=f.toString("utf8")}),c.on("error",o),c.on("close",f=>{f===0?s():o(new Error(`${n} ${e.join(" ")} exited ${f}: ${d.trim()}`))})})}var Ci,hr,Ii,tc=ze(()=>{"use strict";U();Ci=D("supervisor.taskscheduler"),hr="CozeBridge",Ii={platform:"win32",renderConfig(n){return`<?xml version="1.0" encoding="UTF-16"?>
55
+ `},configPath(n){return ul(n.homeDir,".config","systemd","user",lr)},async install(n){let e=this.configPath(n);await cl(fl(e),{recursive:!0}),await dl(e,this.renderConfig(n),"utf8"),ur.info("systemd unit written",{unitPath:e}),await hr("systemctl",["--user","daemon-reload"]),await hr("systemctl",["--user","enable","--now",lr]),ur.info("systemd unit enabled",{unitName:lr})},async uninstall(n){let e=this.configPath(n);await hr("systemctl",["--user","disable","--now",lr]).catch(s=>ur.warn("systemctl disable failed (ignored)",{err:String(s)})),await xl(e).catch(s=>{if(s.code!=="ENOENT")throw s}),await hr("systemctl",["--user","daemon-reload"]).catch(()=>{}),ur.info("systemd unit removed",{unitPath:e})}}});import{spawn as ll}from"node:child_process";import{join as hl}from"node:path";function e0(n,e){return new Promise((s,o)=>{let c=ll(n,e,{stdio:["ignore","pipe","pipe"],shell:!1}),x="";c.stderr?.on("data",f=>{x+=f.toString("utf8")}),c.on("error",o),c.on("close",f=>{f===0?s():o(new Error(`${n} ${e.join(" ")} exited ${f}: ${x.trim()}`))})})}var Ii,gr,ki,t0=ze(()=>{"use strict";q();Ii=R("supervisor.taskscheduler"),gr="CozeBridge",ki={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,7 +76,7 @@ WantedBy=default.target
76
76
  </Exec>
77
77
  </Actions>
78
78
  </Task>
79
- `},configPath(n){return gl(n.homeDir,".coze","bridge","task.xml")},async install(n){let e=`"${n.nodeBin}" "${n.entry}" --daemon`;await ec("schtasks",["/Create","/SC","ONLOGON","/TN",hr,"/TR",e,"/RU",n.userName,"/F"]),Ci.info("task scheduler entry created",{task:hr})},async uninstall(n){await ec("schtasks",["/Delete","/TN",hr,"/F"]).catch(e=>Ci.warn("schtasks /Delete failed (ignored)",{err:String(e)})),Ci.info("task scheduler entry removed",{task:hr})}}});var Pi={};Zi(Pi,{buildContext:()=>wl,getSupervisor:()=>ml,launchdSupervisor:()=>Ei,systemdSupervisor:()=>Ai,taskSchedulerSupervisor:()=>Ii});import{homedir as hl,userInfo as pl}from"node:os";function ml(n=process.platform){switch(n){case"darwin":return Ei;case"linux":return Ai;case"win32":return Ii;default:throw new Error(`unsupported platform for OS supervisor: ${n}`)}}function wl(){let n=F();return{nodeBin:process.execPath,entry:mi(n),logFile:n.logFile,homeDir:hl(),userName:pl().username}}var ki=ze(()=>{"use strict";ie();_i();Za();Qa();tc()});Ye();U();import{readdir as S0}from"node:fs/promises";import{mkdir as m0,writeFile as w0}from"node:fs/promises";import{join as _0}from"node:path";var y0={"claude-code":"CLAUDE.md",codex:"AGENTS.md",openclaw:"SOUL.md"};async function mt(n,e,s,o){await m0(n,{recursive:!0});let c=y0[e],d=_0(n,c),f=v0(e,s,o);return await w0(d,f,"utf8"),d}function v0(n,e,s){let o=`# Coze Agent: ${e}
79
+ `},configPath(n){return hl(n.homeDir,".coze","bridge","task.xml")},async install(n){let e=`"${n.nodeBin}" "${n.entry}" --daemon`;await e0("schtasks",["/Create","/SC","ONLOGON","/TN",gr,"/TR",e,"/RU",n.userName,"/F"]),Ii.info("task scheduler entry created",{task:gr})},async uninstall(n){await e0("schtasks",["/Delete","/TN",gr,"/F"]).catch(e=>Ii.warn("schtasks /Delete failed (ignored)",{err:String(e)})),Ii.info("task scheduler entry removed",{task:gr})}}});var Pi={};Zi(Pi,{buildContext:()=>wl,getSupervisor:()=>ml,launchdSupervisor:()=>Ci,systemdSupervisor:()=>Ai,taskSchedulerSupervisor:()=>ki});import{homedir as gl,userInfo as pl}from"node:os";function ml(n=process.platform){switch(n){case"darwin":return Ci;case"linux":return Ai;case"win32":return ki;default:throw new Error(`unsupported platform for OS supervisor: ${n}`)}}function wl(){let n=U();return{nodeBin:process.execPath,entry:wi(n),logFile:n.logFile,homeDir:gl(),userName:pl().username}}var Ti=ze(()=>{"use strict";oe();yi();Za();Qa();t0()});Xe();q();import{readdir as Sc}from"node:fs/promises";import{mkdir as mc,writeFile as wc}from"node:fs/promises";import{join as _c}from"node:path";var yc={"claude-code":"CLAUDE.md",codex:"AGENTS.md",openclaw:"SOUL.md"};async function mt(n,e,s,o){await mc(n,{recursive:!0});let c=yc[e],x=_c(n,c),f=bc(e,s,o);return await wc(x,f,"utf8"),x}function bc(n,e,s){let o=`# Coze Agent: ${e}
80
80
 
81
81
  > framework: \`${n}\`
82
82
 
@@ -86,7 +86,7 @@ WantedBy=default.target
86
86
  `;return`${o}---
87
87
 
88
88
  ${c}
89
- ${b0}`}var b0=`## \u53D1\u9001\u6587\u4EF6 / \u56FE\u7247\u7ED9\u7528\u6237
89
+ ${vc}`}var vc=`## \u53D1\u9001\u6587\u4EF6 / \u56FE\u7247\u7ED9\u7528\u6237
90
90
 
91
91
  \u6BCF\u6761\u7528\u6237\u6D88\u606F\u5F00\u5934\u4F1A\u6709\u4E91\u7AEF\u6CE8\u5165\u7684 \`<coze-context>\` \u5757, \u5F62\u5982:
92
92
 
@@ -95,10 +95,11 @@ ${b0}`}var b0=`## \u53D1\u9001\u6587\u4EF6 / \u56FE\u7247\u7ED9\u7528\u6237
95
95
  sessionId: <\u5F53\u524D\u5BF9\u8BDD sessionId>
96
96
  </coze-context>
97
97
 
98
- \u4ECE\u4E2D\u63D0\u53D6\u4E24\u4E2A ID, \u7528 bash tool \u8C03:
98
+ \u4ECE\u4E2D\u63D0\u53D6\u4E24\u4E2A ID, \u7528 bash tool \u8C03 (**\u7528\u7EDD\u5BF9\u8DEF\u5F84**, \u4E0D\u540C framework \u7684 bash tool PATH
99
+ \u4E0D\u4E00\u81F4, \u88F8 \`coze-bridge\` \u4E0D\u4E00\u5B9A\u80FD\u89E3\u6790; \u4E0B\u9762\u8FD9\u4E2A\u7EDD\u5BF9\u8DEF\u5F84 daemon \u542F\u52A8\u65F6\u5FC5\u5199):
99
100
 
100
- coze-bridge send image <path> --agent-id <agentId> --session-id <sessionId> [--caption "\u8BF4\u660E\u6587\u5B57"]
101
- coze-bridge send file <path> --agent-id <agentId> --session-id <sessionId> [--caption "..."] [--name "report.pdf"]
101
+ ~/.coze/bridge/bin/coze-bridge send image <path> --agent-id <agentId> --session-id <sessionId> [--caption "\u8BF4\u660E\u6587\u5B57"]
102
+ ~/.coze/bridge/bin/coze-bridge send file <path> --agent-id <agentId> --session-id <sessionId> [--caption "..."] [--name "report.pdf"]
102
103
 
103
104
  \u7EA6\u675F:
104
105
  - path \u5FC5\u987B\u5728\u5F53\u524D workspace \u5B50\u6811\u4E0B (\u7EDD\u5BF9\u6216\u76F8\u5BF9\u7686\u53EF)
@@ -109,26 +110,26 @@ ${b0}`}var b0=`## \u53D1\u9001\u6587\u4EF6 / \u56FE\u7247\u7ED9\u7528\u6237
109
110
  - \`sessionId\` \u5FC5\u987B\u7528\u4E91\u7AEF \`<coze-context>\` \u7ED9\u7684 ID, **\u4E0D\u8981**\u81EA\u5DF1\u7F16\u6216\u8005\u7528\u5176\u5B83\u6765\u6E90
110
111
 
111
112
  \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
112
- `;var Pe=D("agent-detail-sync"),gn=class{constructor(e){this.opts=e}opts;async syncAll(e){let s=this.opts.paths.agentsRoot,o;try{o=await S0(s)}catch(c){Pe.info("agents dir not found, skip detail sync",{root:s,err:String(c)});return}Pe.info("starting detail sync",{reason:e,count:o.length});for(let c of o)try{await this.syncOne(c)}catch(d){Pe.warn("detail sync failed for agent, skipping",{agentId:c,err:String(d)})}Pe.info("detail sync done",{reason:e})}async syncOne(e){let s=await he(e,this.opts.paths);if(!s){Pe.info("detail sync: agent config missing, skip",{agentId:e});return}let o;try{o=await this.opts.sendDetail({_meta:{cozeAgentId:e}})}catch(f){Pe.warn("detail RPC failed, using local data",{agentId:e,err:String(f)});return}if(o.agentId&&o.agentId!==e){Pe.warn("detail response agentId mismatch, ignoring",{agentId:e,responseAgentId:o.agentId});return}let c=!1,d=!1;if(o.agentName&&o.agentName!==s.agentName&&(s.agentName=o.agentName,c=!0),o.description!==void 0&&o.description!==s.description&&(s.description=o.description,c=!0),o.cozeIdentity&&o.cozeIdentity!==s.cozeIdentity&&(s.cozeIdentity=o.cozeIdentity,c=!0,d=!0),o.deployType&&Pe.info("detail.deployType",{agentId:e,deployType:o.deployType}),!c){Pe.debug("detail sync: no diff",{agentId:e});return}await Ae(s,this.opts.paths),Pe.info("detail sync: config updated",{agentId:e,identityChanged:d,agentName:s.agentName}),d&&(await mt(s.workspace,s.framework,e,s.cozeIdentity),await this.opts.handlers.reloadAgentSessionsPublic(e,"detail-sync"))}};Ye();import{spawn as Cs}from"node:child_process";import{lstat as Lr,mkdir as C0,readFile as Is,readdir as I0,rm as P0,stat as k0,writeFile as Es}from"node:fs/promises";import{join as De,normalize as T0,relative as Ps,resolve as D0,sep as ks}from"node:path";var ke={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 Mt(n){return n?.cozeDeployType==="cloud"?"cloud":"local"}function cs(n){let e=n?.cozeAccountId?.trim();if(!(!e||e==="0"))return e}function xs(n){let{_meta:e,...s}=n;return{stripped:s,meta:e}}function wt(n){if(!n?.cozeAgentId)throw new Error("missing _meta.cozeAgentId");return n.cozeAgentId}var S=class extends Error{code;retriable;cause;constructor(e,s,o){super(s),this.name="BridgeError",this.code=e,this.retriable=o?.retriable??!1,o?.cause!==void 0&&(this.cause=o.cause)}};U();ie();function qe(n,e){if(Mt(n)!=="cloud")throw new S("OPERATION_NOT_ALLOWED_FOR_LOCAL",`${e} is not allowed for local agent`)}function hn(n){return n.startsWith("http://")||n.startsWith("https://")}function pn(n){return n.endsWith("/")?n.slice(0,-1):n}U();var mn="1008033",ds="1289";var us="pbbp2",fs="https://www.coze.cn",ls="/api/coze_claw/resource/get_frontier_key",E0="https://www.coze.cn",A0="wss://frontier.coze.cn";function wn(n){return n??process.env.COZE_BRIDGE_HANDSHAKE_URL??E0}function gs(n){return n??process.env.COZE_BRIDGE_FRONTIER_URL??A0}function _t(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 zt(n){return n?n.startsWith("boe_")?{ttEnv:n}:{ttEnv:n,usePpe:"1"}:{}}var hs=D("handshake");async function Tr(n){let e=wn(n.endpoint),s=n.timeoutMs??1e4,o=`${pn(e)}${ls}?aid=${encodeURIComponent(mn)}`,c={Authorization:`Bearer ${n.privatecode}`,Accept:"application/json",..._t(n.ppeOverride)},d=new AbortController,f=setTimeout(()=>d.abort(),s);hs.info("frontier key handshake",{base:e});try{let l=await fetch(o,{method:"GET",headers:c,signal:d.signal}),m=l.headers.get("x-tt-logid")??"",w=l.headers.get("x-tt-trace-id")??"";if(!l.ok){let T=await l.text().catch(()=>"");throw new S("UPSTREAM_HANDSHAKE_FAILED",`handshake HTTP ${l.status} logid=${m}: ${T.slice(0,200)}`)}let v=await l.json();if(v.code!==void 0&&v.code!==0)throw new S("UPSTREAM_HANDSHAKE_FAILED",`handshake code=${v.code} msg=${v.msg??"-"} logid=${m}`);let _=v.data?.access_key,E=v.data?.device_id;if(!_||!E)throw new S("UPSTREAM_HANDSHAKE_FAILED",`handshake response missing access_key/device_id logid=${m}: ${JSON.stringify(v)}`);return hs.info("handshake ok",{remoteDeviceId:E,logid:m,traceId:w}),{accessKey:_,deviceId:E}}catch(l){throw l instanceof S?l:l.name==="AbortError"?new S("UPSTREAM_HANDSHAKE_FAILED",`handshake timeout (${s}ms)`):new S("UPSTREAM_HANDSHAKE_FAILED",String(l),{cause:l})}finally{clearTimeout(f)}}var Dr="https://llm-gateway.coze.cn",Te="auto";function ps(n){return{model:n.model??Te,...n.modelToken?{modelToken:n.modelToken}:{}}}function ms(n){return!n||n===Te}function ws(n){let e={};return n.modelToken?(e.ANTHROPIC_BASE_URL=Dr,e.ANTHROPIC_AUTH_TOKEN=n.modelToken,e.ANTHROPIC_MODEL=n.model||Te):ms(n.model)||(e.ANTHROPIC_MODEL=n.model),e}function _s(n){let e=[];return n.modelToken?e.push("-c",`model="${n.model||Te}"`):ms(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="${Dr}/v1"`),e.push("-c",'model_providers.coze.env_key="OPENAI_API_KEY"'),e.push("-c",'model_providers.coze.wire_api="responses"'),e.push("-c","model_providers.coze.requires_openai_auth=false"),e.push("-c","model_providers.coze.supports_websockets=false"),e.push("-c",'model_provider="coze"')),e}function ys(n){return n.modelToken?{OPENAI_API_KEY:n.modelToken}:{}}function Rr(n){let{ttEnv:e,usePpe:s}=zt(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=Rr(e);return Object.keys(s).length===0?{}:{ANTHROPIC_CUSTOM_HEADERS:Object.entries(s).map(([c,d])=>`${c}:${d}`).join(`
113
- `)}}function Nr(n){return`coze-session-${n.replace(/[^A-Za-z0-9_-]+/g,"-")}`}function bs(n,e){if(!n.modelToken)return null;let s=n.model||Te,o=Rr(e),c={baseUrl:`${Dr}/v1`,api:"openai-completions",apiKey:n.modelToken,models:[{id:s,name:s,reasoning:!1,input:["text"],cost:{input:0,output:0,cacheRead:0,cacheWrite:0},contextWindow:128e3,maxTokens:8192,api:"openai-completions"}]};return Object.keys(o).length>0&&(c.headers=o),c}function Ss(n,e){if(!n.modelToken)return[];let s=Rr(e),o=[];for(let[c,d]of Object.entries(s))o.push("-c",`model_providers.coze.http_headers.${c}="${d}"`);return o}var de=D("agent-handlers"),As=5*1024*1024,R0=1,N0=6,L0=new Set(["node_modules",".git",".coze","dist","build",".next"]),_n=class{constructor(e){this.opts=e}opts;async listSkills(e){qe(e._meta,"_agent/listSkills");let s=wt(e._meta),o=await this.loadAgentCfg(s),c=o?.workspace??Ue(s).workspace,d=o?.skills??[],f=[];for(let l of d){let m=De(c,l.relPath,"SKILL.md");await k0(m).then(v=>v.isFile()).catch(()=>!1)&&f.push(F0(l))}return{skills:f}}async addSkills(e){qe(e._meta,"_agent/addSkills");let s=wt(e._meta),o=await this.requireAgentCfg(s),c=e.skills??[],d=[...o.skills??[]],f=new Map(d.map((m,w)=>[m.skillId,w])),l=[];for(let m of c){let w=await Or({agentId:s,workspace:o.workspace,framework:o.framework,skill:m});Br(d,f,w),l.push(m)}return await fn(s,d),await this.reloadAgentSessions(s,"skills-added"),{installedSkills:l}}async removeSkills(e){qe(e._meta,"_agent/removeSkills");let s=wt(e._meta),o=await this.requireAgentCfg(s),c=new Set(e.skillIds??[]),d=o.skills??[],f=[];for(let l of d){if(!c.has(l.skillId)){f.push(l);continue}let m=De(o.workspace,l.relPath);await P0(m,{recursive:!0,force:!0}),de.info("skill removed",{agentId:s,skillId:l.skillId,relPath:l.relPath})}return await fn(s,f),await this.reloadAgentSessions(s,"skills-removed"),{ok:!0}}reloadAgentSessionsPublic(e,s){return this.reloadAgentSessions(e,s)}async reloadAgentSessions(e,s){let o=this.opts.agents.get(e);if(o&&o.framework!=="codex"){for(let[c,d]of o.sessions)if(!(!d.downstream||!d.acpSessionId)){d.loadingSession=!0;try{await d.downstream.sessionLoad({sessionId:d.acpSessionId,cwd:o.workspace}),de.info("session reloaded",{reason:s,agentId:e,framework:o.framework,cloudId:c,acpId:d.acpSessionId})}catch(f){de.warn("session reload failed",{reason:s,agentId:e,framework:o.framework,cloudId:c,acpId:d.acpSessionId,err:String(f)})}finally{d.loadingSession=!1}}}}async updateAgent(e){if(!e.cozeIdentity?.trim())return de.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}`);return o.cozeIdentity===e.cozeIdentity?(de.info("_agent/update: cozeIdentity unchanged, noop",{agentId:s}),{ok:!0}):(o.cozeIdentity=e.cozeIdentity,await Ae(o),await mt(o.workspace,o.framework,s,e.cozeIdentity),de.info("_agent/update: cozeIdentity rewritten",{agentId:s,framework:o.framework}),await 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 Ae(o),de.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}):(de.warn("_agent/disconnect: agent not found, ignoring",{agentId:s}),{ok:!0})}async switchModel(e){if(qe(e._meta,"_agent/switchModel"),!e.agentId)throw new S("IPC_BAD_REQUEST","_agent/switchModel: missing agentId");let s=e.model?.trim()?e.model:Te,o=await he(e.agentId);if(!o)throw new S("AGENT_NOT_FOUND",`agent not found: ${e.agentId}`);o.model=s,await Ae(o),de.info("_agent/switchModel: model persisted",{agentId:e.agentId,model:s,reason:e.reason??""});let c=this.opts.agents.get(e.agentId);if(!c)return de.info("_agent/switchModel: agent not running, config persisted only",{agentId:e.agentId}),{ok:!0};c.model=s;let d=[];for(let[f,l]of c.allSessionQueues())d.push(l.enqueue(async()=>{let m=c.sessions.get(f);m?.downstream&&(await m.downstream.stop(`switchModel: ${s}`).catch(()=>{}),m.downstream=void 0)}));return await Promise.all(d),de.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(qe(e._meta,ke.RESET),!e.agentId)throw new S("IPC_BAD_REQUEST",`${ke.RESET}: missing agentId`);return await this.runDetailSync(e.agentId,ke.RESET,e.reason),{ok:!0}}async repairAgent(e){if(qe(e._meta,ke.REPAIR),!e.agentId)throw new S("IPC_BAD_REQUEST",`${ke.REPAIR}: missing agentId`);let s=await this.loadAgentCfg(e.agentId);if(s&&s.framework!=="openclaw")throw new S("IPC_BAD_REQUEST",`${ke.REPAIR} only allowed for openclaw, got ${s.framework}`);if(s&&this.opts.openclawRepair)try{await this.opts.openclawRepair(e.agentId,s.workspace)}catch(o){de.warn("openclaw repair (delete+add) failed (ignored)",{agentId:e.agentId,reason:e.reason,err:String(o)})}return await this.runDetailSync(e.agentId,ke.REPAIR,e.reason),{ok:!0}}async runDetailSync(e,s,o){if(!this.opts.detailSyncer){de.warn("detailSyncer not wired, skipping sync",{method:s,agentId:e});return}try{await this.opts.detailSyncer(e)}catch(c){de.warn("detail sync failed (ignored)",{method:s,agentId:e,reason:o,err:String(c)})}}async getFileTree(e){qe(e._meta,"_agent/getFileTree");let s=e._meta,o=wt(s),c=await this.resolveWorkspace(o),d=e.filePath??"",f=this.safeJoin(c,d),l=await Lr(f).catch(()=>null);if(!l)throw new S("IPC_BAD_REQUEST",`path not found: ${d}`);if(l.isSymbolicLink())throw new S("IPC_BAD_REQUEST",`symlink not allowed: ${d}`);let m=W0(e.depth);return l.isDirectory()?{tree:await Ts(c,f,d,m)}:{tree:[{name:j0(d),path:Ds(d||"."),isDir:!1,size:l.size,modifiedAt:Math.floor(l.mtimeMs)}]}}async getFileContent(e){qe(e._meta,"_agent/getFileContent");let s=wt(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 Lr(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>As)throw new S("IPC_BAD_REQUEST",`file too large: ${d.size} bytes (max ${As})`);let f=await Is(c);return f.includes(0)?{content:f.toString("base64"),encoding:"base64",size:d.size}:{content:f.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??Ue(e).workspace}safeJoin(e,s){let o=D0(e,s||"."),c=Ps(e,o);if(c.startsWith("..")||c===".."||c.startsWith(`..${ks}`))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 O0(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 B0(n){return n==="claude-code"?De(".claude","skills"):De(".agents","skills")}var M0=3e4,z0=50*1024*1024,yn=3e4;async function Or(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,f=typeof c.downloadUrl=="string"&&c.downloadUrl.length>0;if(!d&&!f)throw new S("IPC_BAD_REQUEST",`skill ${c.skillId} missing both content and downloadUrl`);let l=O0(c.skillName),m=B0(o),w=De(m,l),v=De(s,w);if(await C0(v,{recursive:!0}),d){let E=Buffer.from(c.content,"utf8");Ft(E.length),await Es(De(v,"SKILL.md"),E,"utf8")}else{let E=await U0(c.downloadUrl);H0(E)?await K0(E,v):await Es(De(v,"SKILL.md"),E.toString("utf8"),"utf8")}let _={skillId:c.skillId,skillName:c.skillName,relPath:w,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 de.info("skill installed",{agentId:e,skillId:c.skillId,skillName:c.skillName,relPath:w,source:d?"content":"downloadUrl"}),_}function Br(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 F0(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 U0(n){if(!n)throw new S("IPC_BAD_REQUEST","skill missing downloadUrl");if(n.startsWith("data:")){let e=Math.floor(n.length*3/4);Ft(e);let s=q0(n);return Ft(s.length),s}if(n.startsWith("file:")){let e=new URL(n).pathname,s=await Is(e);return Ft(s.length),s}if(hn(n)){let e=new AbortController,s=setTimeout(()=>e.abort(),M0);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 Ft(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 Ft(n){if(n>z0)throw new S("IPC_BAD_REQUEST",`skill too large: ${n} bytes`)}function q0(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 H0(n){return n.length>=2&&n[0]===31&&n[1]===139}async function K0(n,e){await G0(n),await new Promise((s,o)=>{let c=Cs("tar",["-xzf","-","-C",e,"--strip-components=1","--no-same-owner"],{stdio:["pipe","pipe","pipe"]}),d="";c.stderr?.on("data",l=>{d+=String(l)});let f=setTimeout(()=>{c.kill("SIGKILL"),o(new S("IPC_BAD_REQUEST",`tar extract timeout (${yn}ms)`))},yn);c.on("error",l=>{clearTimeout(f),o(new S("IPC_BAD_REQUEST",`tar spawn failed: ${l.message}`,{cause:l}))}),c.on("exit",l=>{clearTimeout(f),l===0?s():o(new S("IPC_BAD_REQUEST",`tar exit ${l}${d?`: ${d.trim().slice(0,200)}`:""}`))}),c.stdin?.end(n)})}async function G0(n){let e=await new Promise((s,o)=>{let c=Cs("tar",["-tzvf","-"],{stdio:["pipe","pipe","pipe"]}),d="",f="";c.stdout?.on("data",m=>{d+=String(m)}),c.stderr?.on("data",m=>{f+=String(m)});let l=setTimeout(()=>{c.kill("SIGKILL"),o(new S("IPC_BAD_REQUEST",`tar list timeout (${yn}ms)`))},yn);c.on("error",m=>{clearTimeout(l),o(new S("IPC_BAD_REQUEST",`tar list spawn failed: ${m.message}`))}),c.on("exit",m=>{clearTimeout(l),m===0?s(d):o(new S("IPC_BAD_REQUEST",`tar list exit ${m}${f?`: ${f.trim().slice(0,200)}`:""}`))}),c.stdin?.end(n)});for(let s of e.split(`
114
- `)){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 f=(o.match(/\s(\S.*)$/)?.[1]??"").split(" -> ")[0]?.trim()??"";if(!f)continue;if(f.startsWith("/"))throw new S("IPC_BAD_REQUEST",`tar entry absolute path: ${f}`);if(f.split(/[/\\]/).some(m=>m===".."))throw new S("IPC_BAD_REQUEST",`tar entry contains '..': ${f}`)}}async function Ts(n,e,s,o){if(o<=0)return[];let c;try{c=await I0(e,{withFileTypes:!0})}catch{return[]}let d=[];for(let f of c){if(L0.has(f.name)||f.isSymbolicLink())continue;let l=De(e,f.name),m=T0(De(s,f.name)),w=null;try{w=await Lr(l)}catch{continue}if(w.isSymbolicLink())continue;let v={name:f.name,path:Ds(Ps(n,l)),isDir:w.isDirectory(),size:w.size,modifiedAt:Math.floor(w.mtimeMs)};w.isDirectory()&&o>1&&(v.children=await Ts(n,l,m,o-1)),d.push(v)}return d.sort((f,l)=>f.isDir!==l.isDir?f.isDir?-1:1:f.name.localeCompare(l.name)),d}function W0(n){return!n||n<=0?R0:Math.min(n,N0)}function j0(n){if(!n||n==="."||n==="/")return".";let e=n.split(/[/\\]/);return e[e.length-1]||"."}function Ds(n){return n.split(ks).join("/")}U();import{readFileSync as Ig}from"node:fs";import{dirname as kg,join as Tg}from"node:path";import{fileURLToPath as Rg}from"node:url";var vn="0.1.41";var Ut=D("agent-health-reporter"),J0=1e4,qt=class{constructor(e){this.opts=e;this.intervalMs=e.intervalMs??J0}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()}),Ut.info("heartbeat started",{intervalMs:this.intervalMs}),this.tick())}stop(){this.timer&&(clearInterval(this.timer),this.timer=null,this.unsubscribeRegister&&(this.unsubscribeRegister(),this.unsubscribeRegister=null),Ut.info("heartbeat stopped"))}async tick(){if(this.inFlight){Ut.debug("previous tick still in-flight, skip");return}let e=this.opts.getDeviceId();if(!e){Ut.debug("deviceId not available, skip tick (\u5C1A\u672A pair)");return}this.inFlight=!0;try{let s=[];for(let c of this.opts.core.agents.values()){let d=V0(c);d&&s.push({agentId:c.agentId,status:d})}if(s.length===0)return;let o={agents:s,bridgeVersion:vn,_meta:{cozeDeviceId:e}};try{await this.opts.core.sendRequest("_agent/health",o)}catch(c){Ut.warn("heartbeat batch send failed",{count:s.length,err:String(c)})}}finally{this.inFlight=!1}}};function V0(n){return n.status==="error"?"error":n.activeTriggers.size>0?"busy":n.status==="ok"?"online":null}Ye();import{mkdir as Fr,rm as Ex}from"node:fs/promises";U();import{execFile as $0}from"node:child_process";import{promisify as Y0}from"node:util";var Ns=Y0($0),Ht=D("agents.acp-installer"),X0={"claude-code":{npmPackage:"@agentclientprotocol/claude-agent-acp",binary:"claude-agent-acp"},codex:{npmPackage:"@zed-industries/codex-acp",binary:"codex-acp"}},Z0=5e4,Q0=5e3,ex=5*6e4,Sn=new Map,bn=new Map,Mr=new Map;async function Rs(n){let e=process.platform==="win32"?"where":"which";try{let{stdout:s}=await Ns(e,[n],{timeout:Q0});return s.split(`
115
- `)[0]?.trim()||void 0}catch{return}}async function tx(n){Ht.info("npm install -g start",{npmPackage:n}),await Ns("npm",["install","-g",`${n}@latest`],{timeout:Z0,maxBuffer:10*1024*1024}),Ht.info("npm install -g done",{npmPackage:n})}async function Ls(n){let e=X0[n];if(!e)return;let s=Sn.get(n);if(s)return s;let o=bn.get(n);if(o&&Date.now()-o<ex)return;let c=Mr.get(n);if(c)return c;let d=(async()=>{let f=await Rs(e.binary);if(f)return Sn.set(n,f),Ht.info("acp wrapper found on PATH",{binary:e.binary,path:f}),f;try{await tx(e.npmPackage)}catch(m){Ht.warn("acp wrapper install failed (will fallback to npx)",{npmPackage:e.npmPackage,err:String(m)}),bn.set(n,Date.now());return}let l=await Rs(e.binary);if(!l){Ht.warn("acp wrapper installed but binary not found on PATH",{binary:e.binary}),bn.set(n,Date.now());return}return Sn.set(n,l),bn.delete(n),l})().finally(()=>{Mr.delete(n)});return Mr.set(n,d),d}function En(n){return Sn.get(n)}import{spawn as ox,spawnSync as ax}from"node:child_process";function Kt(n,e,s){return s===void 0?{jsonrpc:"2.0",id:n,method:e}:{jsonrpc:"2.0",id:n,method:e,params:s}}function Gt(n,e){return e===void 0?{jsonrpc:"2.0",method:n}:{jsonrpc:"2.0",method:n,params:e}}function yt(n,e){return{jsonrpc:"2.0",id:n,result:e}}function st(n,e){return{jsonrpc:"2.0",id:n,error:e}}var An=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)}},K={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};function Os(n){return"method"in n&&"id"in n&&n.id!==void 0}function Bs(n){return"method"in n&&!("id"in n)}function Cn(n){return!("method"in n)&&"id"in n}var nx={AGENT_NOT_FOUND:K.AGENT_NOT_FOUND,AGENT_BUSY:K.AGENT_BUSY,AGENT_DISCONNECTED:K.AGENT_DISCONNECTED,AGENT_TIMEOUT:K.AGENT_TIMEOUT,AGENT_SPAWN_FAILED:K.AGENT_SPAWN_FAILED,AGENT_PROTOCOL_ERROR:K.INTERNAL_ERROR,BRIDGE_CONFIG_INVALID:K.INTERNAL_ERROR,BRIDGE_INTERNAL:K.INTERNAL_ERROR,IPC_AUTH_FAILED:K.INTERNAL_ERROR,IPC_BAD_REQUEST:K.INVALID_REQUEST,MODEL_TOKEN_GEN_FAILED:K.MODEL_TOKEN_GEN_FAILED,OPERATION_NOT_ALLOWED_FOR_LOCAL:K.OPERATION_NOT_ALLOWED_FOR_LOCAL,UPSTREAM_DISCONNECTED:K.INTERNAL_ERROR,UPSTREAM_HANDSHAKE_FAILED:K.INTERNAL_ERROR,PATH_OUTSIDE_WORKSPACE:K.PATH_OUTSIDE_WORKSPACE,FILE_TOO_LARGE:K.FILE_TOO_LARGE,UNSUPPORTED_MIME:K.UNSUPPORTED_MIME,UPLOAD_FAILED:K.UPLOAD_FAILED,UPSTREAM_NOT_READY:K.UPSTREAM_NOT_READY};function Wt(n){return n instanceof S?{code:nx[n.code]??K.INTERNAL_ERROR,message:n.message,data:{bridgeCode:n.code,retriable:n.retriable}}:{code:K.INTERNAL_ERROR,message:n instanceof Error?n.message:String(n)}}function Ms(n){let e=n.data,s=e?.bridgeCode??"AGENT_PROTOCOL_ERROR";return new S(s,n.message,{retriable:e?.retriable??!1,cause:n.data})}function zs(n){return`${JSON.stringify(n)}
113
+ `;var ke=R("agent-detail-sync"),hn=class{constructor(e){this.opts=e}opts;async syncAll(e){let s=this.opts.paths.agentsRoot,o;try{o=await Sc(s)}catch(c){ke.info("agents dir not found, skip detail sync",{root:s,err:String(c)});return}ke.info("starting detail sync",{reason:e,count:o.length});for(let c of o)try{await this.syncOne(c)}catch(x){ke.warn("detail sync failed for agent, skipping",{agentId:c,err:String(x)})}ke.info("detail sync done",{reason:e})}async syncOne(e){let s=await pe(e,this.opts.paths);if(!s){ke.info("detail sync: agent config missing, skip",{agentId:e});return}let o;try{o=await this.opts.sendDetail({_meta:{cozeAgentId:e}})}catch(f){ke.warn("detail RPC failed, using local data",{agentId:e,err:String(f)});return}if(o.agentId&&o.agentId!==e){ke.warn("detail response agentId mismatch, ignoring",{agentId:e,responseAgentId:o.agentId});return}let c=!1,x=!1;if(o.agentName&&o.agentName!==s.agentName&&(s.agentName=o.agentName,c=!0),o.description!==void 0&&o.description!==s.description&&(s.description=o.description,c=!0),o.cozeIdentity&&o.cozeIdentity!==s.cozeIdentity&&(s.cozeIdentity=o.cozeIdentity,c=!0,x=!0),o.deployType&&ke.info("detail.deployType",{agentId:e,deployType:o.deployType}),!c){ke.debug("detail sync: no diff",{agentId:e});return}await Ce(s,this.opts.paths),ke.info("detail sync: config updated",{agentId:e,identityChanged:x,agentName:s.agentName}),x&&(await mt(s.workspace,s.framework,e,s.cozeIdentity),await this.opts.handlers.reloadAgentSessionsPublic(e,"detail-sync"))}};Xe();import{spawn as As}from"node:child_process";import{lstat as Or,mkdir as Ac,readFile as Is,readdir as Ic,rm as kc,stat as Pc,writeFile as Es}from"node:fs/promises";import{join as De,normalize as Tc,relative as ks,resolve as Dc,sep as Ps}from"node:path";var Pe={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 Bt(n){return n?.cozeDeployType==="cloud"?"cloud":"local"}function cs(n){let e=n?.cozeAccountId?.trim();if(!(!e||e==="0"))return e}function xs(n){let{_meta:e,...s}=n;return{stripped:s,meta:e}}function wt(n){if(!n?.cozeAgentId)throw new Error("missing _meta.cozeAgentId");return n.cozeAgentId}var v=class extends Error{code;retriable;cause;constructor(e,s,o){super(s),this.name="BridgeError",this.code=e,this.retriable=o?.retriable??!1,o?.cause!==void 0&&(this.cause=o.cause)}};q();oe();function qe(n,e){if(Bt(n)!=="cloud")throw new v("OPERATION_NOT_ALLOWED_FOR_LOCAL",`${e} is not allowed for local agent`)}function gn(n){return n.startsWith("http://")||n.startsWith("https://")}function pn(n){return n.endsWith("/")?n.slice(0,-1):n}q();var mn="1008033",ds="1289";var fs="pbbp2",us="https://www.coze.cn",ls="/api/coze_claw/resource/get_frontier_key",Ec="https://www.coze.cn",Cc="wss://frontier.coze.cn";function wn(n){return n??process.env.COZE_BRIDGE_HANDSHAKE_URL??Ec}function hs(n){return n??process.env.COZE_BRIDGE_FRONTIER_URL??Cc}function _t(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 zt(n){return n?n.startsWith("boe_")?{ttEnv:n}:{ttEnv:n,usePpe:"1"}:{}}var gs=R("handshake");async function Dr(n){let e=wn(n.endpoint),s=n.timeoutMs??1e4,o=`${pn(e)}${ls}?aid=${encodeURIComponent(mn)}`,c={Authorization:`Bearer ${n.privatecode}`,Accept:"application/json",..._t(n.ppeOverride)},x=new AbortController,f=setTimeout(()=>x.abort(),s);gs.info("frontier key handshake",{base:e});try{let u=await fetch(o,{method:"GET",headers:c,signal:x.signal}),p=u.headers.get("x-tt-logid")??"",m=u.headers.get("x-tt-trace-id")??"";if(!u.ok){let T=await u.text().catch(()=>"");throw new v("UPSTREAM_HANDSHAKE_FAILED",`handshake HTTP ${u.status} logid=${p}: ${T.slice(0,200)}`)}let b=await u.json();if(b.code!==void 0&&b.code!==0)throw new v("UPSTREAM_HANDSHAKE_FAILED",`handshake code=${b.code} msg=${b.msg??"-"} logid=${p}`);let _=b.data?.access_key,E=b.data?.device_id;if(!_||!E)throw new v("UPSTREAM_HANDSHAKE_FAILED",`handshake response missing access_key/device_id logid=${p}: ${JSON.stringify(b)}`);return gs.info("handshake ok",{remoteDeviceId:E,logid:p,traceId:m}),{accessKey:_,deviceId:E}}catch(u){throw u instanceof v?u:u.name==="AbortError"?new v("UPSTREAM_HANDSHAKE_FAILED",`handshake timeout (${s}ms)`):new v("UPSTREAM_HANDSHAKE_FAILED",String(u),{cause:u})}finally{clearTimeout(f)}}var Rr="https://llm-gateway.coze.cn",Te="auto";function ps(n){return{model:n.model??Te,...n.modelToken?{modelToken:n.modelToken}:{}}}function ms(n){return!n||n===Te}function ws(n){let e={};return n.modelToken?(e.ANTHROPIC_BASE_URL=Rr,e.ANTHROPIC_AUTH_TOKEN=n.modelToken,e.ANTHROPIC_MODEL=n.model||Te):ms(n.model)||(e.ANTHROPIC_MODEL=n.model),e}function _s(n){let e=[];return n.modelToken?e.push("-c",`model="${n.model||Te}"`):ms(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="${Rr}/v1"`),e.push("-c",'model_providers.coze.env_key="OPENAI_API_KEY"'),e.push("-c",'model_providers.coze.wire_api="responses"'),e.push("-c","model_providers.coze.requires_openai_auth=false"),e.push("-c","model_providers.coze.supports_websockets=false"),e.push("-c",'model_provider="coze"')),e}function ys(n){return n.modelToken?{OPENAI_API_KEY:n.modelToken}:{}}function Lr(n){let{ttEnv:e,usePpe:s}=zt(n),o={};return e&&(o["x-tt-env"]=e),s&&(o["x-use-ppe"]=s),o}function bs(n,e){if(!n.modelToken)return{};let s=Lr(e);return Object.keys(s).length===0?{}:{ANTHROPIC_CUSTOM_HEADERS:Object.entries(s).map(([c,x])=>`${c}:${x}`).join(`
114
+ `)}}function Nr(n){return`coze-session-${n.replace(/[^A-Za-z0-9_-]+/g,"-")}`}function vs(n,e){if(!n.modelToken)return null;let s=n.model||Te,o=Lr(e),c={baseUrl:`${Rr}/v1`,api:"openai-completions",apiKey:n.modelToken,models:[{id:s,name:s,reasoning:!1,input:["text"],cost:{input:0,output:0,cacheRead:0,cacheWrite:0},contextWindow:128e3,maxTokens:8192,api:"openai-completions"}]};return Object.keys(o).length>0&&(c.headers=o),c}function Ss(n,e){if(!n.modelToken)return[];let s=Lr(e),o=[];for(let[c,x]of Object.entries(s))o.push("-c",`model_providers.coze.http_headers.${c}="${x}"`);return o}var fe=R("agent-handlers"),Cs=5*1024*1024,Rc=1,Lc=6,Nc=new Set(["node_modules",".git",".coze","dist","build",".next"]),_n=class{constructor(e){this.opts=e}opts;async listSkills(e){qe(e._meta,"_agent/listSkills");let s=wt(e._meta),o=await this.loadAgentCfg(s),c=o?.workspace??Ue(s).workspace,x=o?.skills??[],f=[];for(let u of x){let p=De(c,u.relPath,"SKILL.md");await Pc(p).then(b=>b.isFile()).catch(()=>!1)&&f.push(Fc(u))}return{skills:f}}async addSkills(e){qe(e._meta,"_agent/addSkills");let s=wt(e._meta),o=await this.requireAgentCfg(s),c=e.skills??[],x=[...o.skills??[]],f=new Map(x.map((p,m)=>[p.skillId,m])),u=[];for(let p of c){let m=await Mr({agentId:s,workspace:o.workspace,framework:o.framework,skill:p});Br(x,f,m),u.push(p)}return await un(s,x),await this.reloadAgentSessions(s,"skills-added"),{installedSkills:u}}async removeSkills(e){qe(e._meta,"_agent/removeSkills");let s=wt(e._meta),o=await this.requireAgentCfg(s),c=new Set(e.skillIds??[]),x=o.skills??[],f=[];for(let u of x){if(!c.has(u.skillId)){f.push(u);continue}let p=De(o.workspace,u.relPath);await kc(p,{recursive:!0,force:!0}),fe.info("skill removed",{agentId:s,skillId:u.skillId,relPath:u.relPath})}return await un(s,f),await this.reloadAgentSessions(s,"skills-removed"),{ok:!0}}reloadAgentSessionsPublic(e,s){return this.reloadAgentSessions(e,s)}async reloadAgentSessions(e,s){let o=this.opts.agents.get(e);if(o&&o.framework!=="codex"){for(let[c,x]of o.sessions)if(!(!x.downstream||!x.acpSessionId)){x.loadingSession=!0;try{await x.downstream.sessionLoad({sessionId:x.acpSessionId,cwd:o.workspace}),fe.info("session reloaded",{reason:s,agentId:e,framework:o.framework,cloudId:c,acpId:x.acpSessionId})}catch(f){fe.warn("session reload failed",{reason:s,agentId:e,framework:o.framework,cloudId:c,acpId:x.acpSessionId,err:String(f)})}finally{x.loadingSession=!1}}}}async updateAgent(e){if(!e.cozeIdentity?.trim())return fe.info("_agent/update: empty cozeIdentity, noop",{agentId:e.agentId}),{ok:!0};let s=e.agentId,o=await pe(s);if(!o)throw new v("AGENT_NOT_FOUND",`agent not found: ${s}`);return o.cozeIdentity===e.cozeIdentity?(fe.info("_agent/update: cozeIdentity unchanged, noop",{agentId:s}),{ok:!0}):(o.cozeIdentity=e.cozeIdentity,await Ce(o),await mt(o.workspace,o.framework,s,e.cozeIdentity),fe.info("_agent/update: cozeIdentity rewritten",{agentId:s,framework:o.framework}),await this.reloadAgentSessions(s,"identity-changed"),{ok:!0})}async disconnectAgent(e){let s=e.agentId;if(!s)throw new v("IPC_BAD_REQUEST","_agent/disconnect: missing agentId");let o=await pe(s);return o?(o.disconnectedAt=Date.now(),o.disconnectReason=e.reason??"",await Ce(o),fe.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}):(fe.warn("_agent/disconnect: agent not found, ignoring",{agentId:s}),{ok:!0})}async switchModel(e){if(qe(e._meta,"_agent/switchModel"),!e.agentId)throw new v("IPC_BAD_REQUEST","_agent/switchModel: missing agentId");let s=e.model?.trim()?e.model:Te,o=await pe(e.agentId);if(!o)throw new v("AGENT_NOT_FOUND",`agent not found: ${e.agentId}`);o.model=s,await Ce(o),fe.info("_agent/switchModel: model persisted",{agentId:e.agentId,model:s,reason:e.reason??""});let c=this.opts.agents.get(e.agentId);if(!c)return fe.info("_agent/switchModel: agent not running, config persisted only",{agentId:e.agentId}),{ok:!0};c.model=s;let x=[];for(let[f,u]of c.allSessionQueues())x.push(u.enqueue(async()=>{let p=c.sessions.get(f);p?.downstream&&(await p.downstream.stop(`switchModel: ${s}`).catch(()=>{}),p.downstream=void 0)}));return await Promise.all(x),fe.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(qe(e._meta,Pe.RESET),!e.agentId)throw new v("IPC_BAD_REQUEST",`${Pe.RESET}: missing agentId`);return await this.runDetailSync(e.agentId,Pe.RESET,e.reason),{ok:!0}}async repairAgent(e){if(qe(e._meta,Pe.REPAIR),!e.agentId)throw new v("IPC_BAD_REQUEST",`${Pe.REPAIR}: missing agentId`);let s=await this.loadAgentCfg(e.agentId);if(s&&s.framework!=="openclaw")throw new v("IPC_BAD_REQUEST",`${Pe.REPAIR} only allowed for openclaw, got ${s.framework}`);if(s&&this.opts.openclawRepair)try{await this.opts.openclawRepair(e.agentId,s.workspace)}catch(o){fe.warn("openclaw repair (delete+add) failed (ignored)",{agentId:e.agentId,reason:e.reason,err:String(o)})}return await this.runDetailSync(e.agentId,Pe.REPAIR,e.reason),{ok:!0}}async runDetailSync(e,s,o){if(!this.opts.detailSyncer){fe.warn("detailSyncer not wired, skipping sync",{method:s,agentId:e});return}try{await this.opts.detailSyncer(e)}catch(c){fe.warn("detail sync failed (ignored)",{method:s,agentId:e,reason:o,err:String(c)})}}async getFileTree(e){qe(e._meta,"_agent/getFileTree");let s=e._meta,o=wt(s),c=await this.resolveWorkspace(o),x=e.filePath??"",f=this.safeJoin(c,x),u=await Or(f).catch(()=>null);if(!u)throw new v("IPC_BAD_REQUEST",`path not found: ${x}`);if(u.isSymbolicLink())throw new v("IPC_BAD_REQUEST",`symlink not allowed: ${x}`);let p=Gc(e.depth);return u.isDirectory()?{tree:await Ts(c,f,x,p)}:{tree:[{name:Wc(x),path:Ds(x||"."),isDir:!1,size:u.size,modifiedAt:Math.floor(u.mtimeMs)}]}}async getFileContent(e){qe(e._meta,"_agent/getFileContent");let s=wt(e._meta),o=await this.resolveWorkspace(s);if(!e.filePath)throw new v("IPC_BAD_REQUEST","filePath required");let c=this.safeJoin(o,e.filePath),x=await Or(c).catch(()=>null);if(!x||!x.isFile())throw new v("IPC_BAD_REQUEST",`not a file: ${e.filePath}`);if(x.isSymbolicLink())throw new v("IPC_BAD_REQUEST",`symlink not allowed: ${e.filePath}`);if(x.size>Cs)throw new v("IPC_BAD_REQUEST",`file too large: ${x.size} bytes (max ${Cs})`);let f=await Is(c);return f.includes(0)?{content:f.toString("base64"),encoding:"base64",size:x.size}:{content:f.toString("utf8"),encoding:"utf-8",size:x.size}}async resolveWorkspace(e){let s=this.opts.agents.get(e);return s?s.workspace:(await pe(e).catch(()=>null))?.workspace??Ue(e).workspace}safeJoin(e,s){let o=Dc(e,s||"."),c=ks(e,o);if(c.startsWith("..")||c===".."||c.startsWith(`..${Ps}`))throw new v("IPC_BAD_REQUEST",`path escapes workspace: ${s}`);return o}loadAgentCfg(e){return pe(e)}async requireAgentCfg(e){let s=await this.loadAgentCfg(e);if(!s)throw new v("AGENT_NOT_FOUND",`no config for agent: ${e}`);return s}};function Oc(n){let e=n.trim().replace(/[\x00-\x1f<>:"|?*/\\]+/g,"-").replace(/^[\s.-]+|[\s.-]+$/g,"").slice(0,64);if(!e||e==="."||e==="..")throw new v("IPC_BAD_REQUEST",`invalid skill name: ${n}`);if(/^(con|prn|aux|nul|com[1-9]|lpt[1-9])$/i.test(e))throw new v("IPC_BAD_REQUEST",`reserved windows filename: ${n}`);return e}function Mc(n){return n==="claude-code"?De(".claude","skills"):De(".agents","skills")}var Bc=3e4,zc=50*1024*1024,yn=3e4;async function Mr(n){let{agentId:e,workspace:s,framework:o,skill:c}=n;if(!c.skillName)throw new v("IPC_BAD_REQUEST","skill missing skillName");let x=typeof c.content=="string"&&c.content.length>0,f=typeof c.downloadUrl=="string"&&c.downloadUrl.length>0;if(!x&&!f)throw new v("IPC_BAD_REQUEST",`skill ${c.skillId} missing both content and downloadUrl`);let u=Oc(c.skillName),p=Mc(o),m=De(p,u),b=De(s,m);if(await Ac(b,{recursive:!0}),x){let E=Buffer.from(c.content,"utf8");Ft(E.length),await Es(De(b,"SKILL.md"),E,"utf8")}else{let E=await Uc(c.downloadUrl);Hc(E)?await Kc(E,b):await Es(De(b,"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 fe.info("skill installed",{agentId:e,skillId:c.skillId,skillName:c.skillName,relPath:m,source:x?"content":"downloadUrl"}),_}function Br(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 Fc(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 Uc(n){if(!n)throw new v("IPC_BAD_REQUEST","skill missing downloadUrl");if(n.startsWith("data:")){let e=Math.floor(n.length*3/4);Ft(e);let s=qc(n);return Ft(s.length),s}if(n.startsWith("file:")){let e=new URL(n).pathname,s=await Is(e);return Ft(s.length),s}if(gn(n)){let e=new AbortController,s=setTimeout(()=>e.abort(),Bc);try{let o=await fetch(n,{signal:e.signal});if(!o.ok)throw new v("IPC_BAD_REQUEST",`fetch skill failed HTTP ${o.status} ${n}`);let c=await o.arrayBuffer();return Ft(c.byteLength),Buffer.from(c)}finally{clearTimeout(s)}}throw new v("IPC_BAD_REQUEST",`unsupported downloadUrl scheme (\u8981 https/data/file): ${n.slice(0,80)}`)}function Ft(n){if(n>zc)throw new v("IPC_BAD_REQUEST",`skill too large: ${n} bytes`)}function qc(n){let e=/^data:([^,;]*)(;base64)?,(.*)$/s.exec(n);if(!e)throw new v("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 Hc(n){return n.length>=2&&n[0]===31&&n[1]===139}async function Kc(n,e){await jc(n),await new Promise((s,o)=>{let c=As("tar",["-xzf","-","-C",e,"--strip-components=1","--no-same-owner"],{stdio:["pipe","pipe","pipe"]}),x="";c.stderr?.on("data",u=>{x+=String(u)});let f=setTimeout(()=>{c.kill("SIGKILL"),o(new v("IPC_BAD_REQUEST",`tar extract timeout (${yn}ms)`))},yn);c.on("error",u=>{clearTimeout(f),o(new v("IPC_BAD_REQUEST",`tar spawn failed: ${u.message}`,{cause:u}))}),c.on("exit",u=>{clearTimeout(f),u===0?s():o(new v("IPC_BAD_REQUEST",`tar exit ${u}${x?`: ${x.trim().slice(0,200)}`:""}`))}),c.stdin?.end(n)})}async function jc(n){let e=await new Promise((s,o)=>{let c=As("tar",["-tzvf","-"],{stdio:["pipe","pipe","pipe"]}),x="",f="";c.stdout?.on("data",p=>{x+=String(p)}),c.stderr?.on("data",p=>{f+=String(p)});let u=setTimeout(()=>{c.kill("SIGKILL"),o(new v("IPC_BAD_REQUEST",`tar list timeout (${yn}ms)`))},yn);c.on("error",p=>{clearTimeout(u),o(new v("IPC_BAD_REQUEST",`tar list spawn failed: ${p.message}`))}),c.on("exit",p=>{clearTimeout(u),p===0?s(x):o(new v("IPC_BAD_REQUEST",`tar list exit ${p}${f?`: ${f.trim().slice(0,200)}`:""}`))}),c.stdin?.end(n)});for(let s of e.split(`
115
+ `)){let o=s.trim();if(!o)continue;let c=o.charCodeAt(0);if(c!==45&&c!==100)throw new v("IPC_BAD_REQUEST",`tar entry kind '${o[0]}' not allowed (symlink/hardlink/special): ${o.slice(0,100)}`);let f=(o.match(/\s(\S.*)$/)?.[1]??"").split(" -> ")[0]?.trim()??"";if(!f)continue;if(f.startsWith("/"))throw new v("IPC_BAD_REQUEST",`tar entry absolute path: ${f}`);if(f.split(/[/\\]/).some(p=>p===".."))throw new v("IPC_BAD_REQUEST",`tar entry contains '..': ${f}`)}}async function Ts(n,e,s,o){if(o<=0)return[];let c;try{c=await Ic(e,{withFileTypes:!0})}catch{return[]}let x=[];for(let f of c){if(Nc.has(f.name)||f.isSymbolicLink())continue;let u=De(e,f.name),p=Tc(De(s,f.name)),m=null;try{m=await Or(u)}catch{continue}if(m.isSymbolicLink())continue;let b={name:f.name,path:Ds(ks(n,u)),isDir:m.isDirectory(),size:m.size,modifiedAt:Math.floor(m.mtimeMs)};m.isDirectory()&&o>1&&(b.children=await Ts(n,u,p,o-1)),x.push(b)}return x.sort((f,u)=>f.isDir!==u.isDir?f.isDir?-1:1:f.name.localeCompare(u.name)),x}function Gc(n){return!n||n<=0?Rc:Math.min(n,Lc)}function Wc(n){if(!n||n==="."||n==="/")return".";let e=n.split(/[/\\]/);return e[e.length-1]||"."}function Ds(n){return n.split(Ps).join("/")}q();import{readFileSync as Ih}from"node:fs";import{dirname as Ph,join as Th}from"node:path";import{fileURLToPath as Rh}from"node:url";var bn="0.1.42";var Ut=R("agent-health-reporter"),Jc=1e4,qt=class{constructor(e){this.opts=e;this.intervalMs=e.intervalMs??Jc}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()}),Ut.info("heartbeat started",{intervalMs:this.intervalMs}),this.tick())}stop(){this.timer&&(clearInterval(this.timer),this.timer=null,this.unsubscribeRegister&&(this.unsubscribeRegister(),this.unsubscribeRegister=null),Ut.info("heartbeat stopped"))}async tick(){if(this.inFlight){Ut.debug("previous tick still in-flight, skip");return}let e=this.opts.getDeviceId();if(!e){Ut.debug("deviceId not available, skip tick (\u5C1A\u672A pair)");return}this.inFlight=!0;try{let s=[];for(let c of this.opts.core.agents.values()){let x=$c(c);x&&s.push({agentId:c.agentId,status:x})}if(s.length===0)return;let o={agents:s,bridgeVersion:bn,_meta:{cozeDeviceId:e}};try{await this.opts.core.sendRequest("_agent/health",o)}catch(c){Ut.warn("heartbeat batch send failed",{count:s.length,err:String(c)})}}finally{this.inFlight=!1}}};function $c(n){return n.status==="error"?"error":n.activeTriggers.size>0?"busy":n.status==="ok"?"online":null}Xe();import{mkdir as Ur,rm as Ex}from"node:fs/promises";q();import{execFile as Vc}from"node:child_process";import{promisify as Xc}from"node:util";var Ls=Xc(Vc),Ht=R("agents.acp-installer"),Yc={"claude-code":{npmPackage:"@agentclientprotocol/claude-agent-acp",binary:"claude-agent-acp"},codex:{npmPackage:"@zed-industries/codex-acp",binary:"codex-acp"}},Zc=5e4,Qc=5e3,ex=5*6e4,Sn=new Map,vn=new Map,zr=new Map;async function Rs(n){let e=process.platform==="win32"?"where":"which";try{let{stdout:s}=await Ls(e,[n],{timeout:Qc});return s.split(`
116
+ `)[0]?.trim()||void 0}catch{return}}async function tx(n){Ht.info("npm install -g start",{npmPackage:n}),await Ls("npm",["install","-g",`${n}@latest`],{timeout:Zc,maxBuffer:10*1024*1024}),Ht.info("npm install -g done",{npmPackage:n})}async function Ns(n){let e=Yc[n];if(!e)return;let s=Sn.get(n);if(s)return s;let o=vn.get(n);if(o&&Date.now()-o<ex)return;let c=zr.get(n);if(c)return c;let x=(async()=>{let f=await Rs(e.binary);if(f)return Sn.set(n,f),Ht.info("acp wrapper found on PATH",{binary:e.binary,path:f}),f;try{await tx(e.npmPackage)}catch(p){Ht.warn("acp wrapper install failed (will fallback to npx)",{npmPackage:e.npmPackage,err:String(p)}),vn.set(n,Date.now());return}let u=await Rs(e.binary);if(!u){Ht.warn("acp wrapper installed but binary not found on PATH",{binary:e.binary}),vn.set(n,Date.now());return}return Sn.set(n,u),vn.delete(n),u})().finally(()=>{zr.delete(n)});return zr.set(n,x),x}function En(n){return Sn.get(n)}import{spawn as ox,spawnSync as ax}from"node:child_process";function Kt(n,e,s){return s===void 0?{jsonrpc:"2.0",id:n,method:e}:{jsonrpc:"2.0",id:n,method:e,params:s}}function jt(n,e){return e===void 0?{jsonrpc:"2.0",method:n}:{jsonrpc:"2.0",method:n,params:e}}function yt(n,e){return{jsonrpc:"2.0",id:n,result:e}}function st(n,e){return{jsonrpc:"2.0",id:n,error:e}}var Cn=class extends Error{code;data;constructor(e){super(`JSON-RPC error code=${e.code} ${e.message}`),this.name="RemoteRpcError",this.code=e.code,e.data!==void 0&&(this.data=e.data)}},j={PARSE_ERROR:-32700,INVALID_REQUEST:-32600,METHOD_NOT_FOUND:-32601,INVALID_PARAMS:-32602,INTERNAL_ERROR:-32603,AGENT_NOT_FOUND:-32001,AGENT_BUSY:-32002,AGENT_TIMEOUT:-32003,AGENT_SPAWN_FAILED:-32004,OPERATION_NOT_ALLOWED_FOR_LOCAL:-32005,AGENT_DISCONNECTED:-32006,MODEL_TOKEN_GEN_FAILED:-32009,PATH_OUTSIDE_WORKSPACE:-32010,FILE_TOO_LARGE:-32011,UNSUPPORTED_MIME:-32012,UPLOAD_FAILED:-32013,UPSTREAM_NOT_READY:-32014};function Os(n){return"method"in n&&"id"in n&&n.id!==void 0}function Ms(n){return"method"in n&&!("id"in n)}function An(n){return!("method"in n)&&"id"in n}var nx={AGENT_NOT_FOUND:j.AGENT_NOT_FOUND,AGENT_BUSY:j.AGENT_BUSY,AGENT_DISCONNECTED:j.AGENT_DISCONNECTED,AGENT_TIMEOUT:j.AGENT_TIMEOUT,AGENT_SPAWN_FAILED:j.AGENT_SPAWN_FAILED,AGENT_PROTOCOL_ERROR:j.INTERNAL_ERROR,BRIDGE_CONFIG_INVALID:j.INTERNAL_ERROR,BRIDGE_INTERNAL:j.INTERNAL_ERROR,IPC_AUTH_FAILED:j.INTERNAL_ERROR,IPC_BAD_REQUEST:j.INVALID_REQUEST,MODEL_TOKEN_GEN_FAILED:j.MODEL_TOKEN_GEN_FAILED,OPERATION_NOT_ALLOWED_FOR_LOCAL:j.OPERATION_NOT_ALLOWED_FOR_LOCAL,UPSTREAM_DISCONNECTED:j.INTERNAL_ERROR,UPSTREAM_HANDSHAKE_FAILED:j.INTERNAL_ERROR,PATH_OUTSIDE_WORKSPACE:j.PATH_OUTSIDE_WORKSPACE,FILE_TOO_LARGE:j.FILE_TOO_LARGE,UNSUPPORTED_MIME:j.UNSUPPORTED_MIME,UPLOAD_FAILED:j.UPLOAD_FAILED,UPSTREAM_NOT_READY:j.UPSTREAM_NOT_READY};function Gt(n){return n instanceof v?{code:nx[n.code]??j.INTERNAL_ERROR,message:n.message,data:{bridgeCode:n.code,retriable:n.retriable}}:{code:j.INTERNAL_ERROR,message:n instanceof Error?n.message:String(n)}}function Bs(n){let e=n.data,s=e?.bridgeCode??"AGENT_PROTOCOL_ERROR";return new v(s,n.message,{retriable:e?.retriable??!1,cause:n.data})}function zs(n){return`${JSON.stringify(n)}
116
117
  `}var In=class{buffer="";onError;constructor(e={}){this.onError=e.onError}push(e){this.buffer+=typeof e=="string"?e:e.toString("utf8");let s=this.buffer.split(`
117
- `);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(f){this.onError?.({line:d,error:f})}}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 Us={"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"},Jg=Object.fromEntries(Object.entries(Us).map(([n,e])=>[e,n])),rx={"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:[]},vt=class{seq=0;next(e,s){this.seq+=1;let o=Us[e]??ix(e),c=rx[o]??[],d=[o,String(this.seq)];if(c.length>0){let f=c.map(m=>Fs(s?.[m]??"")),l=sx(f).join(":");l&&d.push(l)}else s&&Object.values(s).some(f=>f)&&d.push(Object.values(s).filter(Boolean).map(f=>Fs(String(f))).join(":"));return d.join("_")}reset(){this.seq=0}};function ix(n){return n.replace(/[\s/]+/g,".").replace(/_+/g,"-")}function Fs(n){return n.replace(/[:_\s]+/g,"-")}function sx(n){let e=n.length;for(;e>0&&!n[e-1];)e-=1;return n.slice(0,e)}U();var cx=3e4,xx=50,dx=20,qs=500;function ux(n){try{let e=JSON.stringify(n);return e===void 0||e.length<=qs?n:`${e.slice(0,qs)}...<truncated, total ${e.length} chars>`}catch{return"<unserializable>"}}function Hs(n,e){if(!(typeof n!="number"||n<=0))try{if(process.platform==="win32"){let s=["/PID",String(n),"/T"];e==="SIGKILL"&&s.push("/F"),ax("taskkill",s,{stdio:"ignore",windowsHide:!0})}else process.kill(-n,e)}catch{}}var Xe=class{constructor(e){this.opts=e;this.log=D(`downstream.${this.constructor.name}`),this.decoder=new In({onError:s=>this.log.warn("decode line failed",{line:s.line})})}opts;child;decoder;pending=new Map;idAllocator=new vt;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=ox(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=>{for(let c of this.decoder.push(o))this.dispatch(c)}),s.stderr?.setEncoding("utf8"),s.stderr?.on("data",o=>{let c=o.trimEnd();this.stderrRing.push(c),this.stderrRing.length>xx&&this.stderrRing.shift(),this.log.debug("stderr",{text:c})}),s.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.slice(-dx)}),this.failAllPending(new S("AGENT_PROTOCOL_ERROR",`agent exited (${o}/${c})`));for(let f of this.exitHandlers)f(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()));Hs(s.pid,"SIGTERM");let c=setTimeout(()=>{s.killed||Hs(s.pid,"SIGKILL")},5e3);try{await o}finally{clearTimeout(c)}}pid(){return this.child?.pid}isAlive(){return!!this.child&&!this.stopped}initialize(e){return this.call("initialize",e)}sessionNew(e){return this.call("session/new",{mcpServers:[],...e})}sessionLoad(e){return this.call("session/load",{mcpServers:[],...e})}sessionPrompt(e){return this.call("session/prompt",e,0)}async sessionCancel(e){!this.child||this.stopped||this.writeFrame(Gt("session/cancel",e))}onUpdate(e){this.updateHandlers.push(e)}onAgentRequest(e){this.agentRequestHandlers.push(e)}respondAgentRequest(e,s){if(!(!this.child||this.stopped))try{this.writeFrame(yt(e,s))}catch(o){this.log.warn("respondAgentRequest write failed",{id:e,err:String(o)})}}respondAgentRequestError(e,s){if(!(!this.child||this.stopped))try{this.writeFrame(st(e,s))}catch(o){this.log.warn("respondAgentRequestError write failed",{id:e,err:String(o)})}}onExit(e){this.exitHandlers.push(e)}call(e,s,o=cx){if(!this.child||this.stopped)return Promise.reject(new S("AGENT_PROTOCOL_ERROR","downstream not started"));let c=this.idAllocator.next(e),d=Kt(c,e,s),f=o>0&&Number.isFinite(o);return new Promise((l,m)=>{let w=f?setTimeout(()=>{this.pending.delete(c),m(new S("AGENT_TIMEOUT",`${e} timed out after ${o}ms`))},o):null;this.pending.set(c,{resolve:l,reject:m,timer:w,method:e});try{this.writeFrame(d)}catch(v){w&&clearTimeout(w),this.pending.delete(c),m(v)}})}writeFrame(e){if(!this.child?.stdin||this.child.stdin.destroyed)throw new S("AGENT_PROTOCOL_ERROR","downstream stdin not writable");this.child.stdin.write(zs(e))}dispatch(e){if(Cn(e)){let s=e.id!==null?this.pending.get(e.id):void 0;if(!s){this.log.warn("orphan response",{id:e.id});return}this.pending.delete(e.id),s.timer&&clearTimeout(s.timer),e.error?(this.log.warn("downstream returned error frame",{id:e.id,method:s.method,code:e.error.code,message:e.error.message,data:e.error.data}),s.reject(Ms(e.error))):(this.log.info("downstream returned result",{id:e.id,method:s.method,result:ux(e.result)}),s.resolve(e.result));return}if(Bs(e)){if(e.method==="session/update")for(let s of this.updateHandlers)Promise.resolve(s(e.params)).catch(o=>this.log.warn("update handler failed",{err:String(o)}));else this.log.debug("unknown notification",{method:e.method});return}if(Os(e)){let s=e;this.handleAgentRequest(s).catch(o=>this.log.error("agent request handler failed",{method:s.method,err:String(o)}))}}async handleAgentRequest(e){if(this.agentRequestHandlers.length===0){this.writeFrame(st(e.id,{code:-32601,message:`method not handled by Bridge: ${e.method}`}));return}for(let s of this.agentRequestHandlers)try{await s(e)}catch(o){this.log.error("agentRequestHandler threw",{method:e.method,err:String(o)});try{this.writeFrame(st(e.id,Wt(o)))}catch{}}}failAllPending(e){for(let s of this.pending.values())s.timer&&clearTimeout(s.timer),s.reject(e);this.pending.clear()}};var fx="@agentclientprotocol/claude-agent-acp@latest";function lx(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 Pn=class extends Xe{framework="claude-code";constructor(e){let s=En("claude-code"),[o,c]=s?[s,[]]:["npx",["-y",fx]],d=e.command??o,f=e.args??c,l={command:d,args:f,cwd:e.cwd,...e.env?{env:e.env}:{}};super(l)}sanitizeEnv(e){return lx(e)}};import{mkdtempSync as gx,rmSync as hx}from"node:fs";import{tmpdir as px}from"node:os";import{join as mx}from"node:path";var _x="@zed-industries/codex-acp@latest",kn=class extends Xe{framework="codex";authMethodId;codexHomeDir;constructor(e){let s=En("codex"),[o,c]=s?[s,[]]:["npx",["-y",_x]],d=e.command??o,f=e.args??c,l=e.extraArgs?[...f,...e.extraArgs]:f,m=e.isolateCodexHome?gx(mx(px(),"coze-bridge-codex-home-")):void 0,w=m?{...e.env??{},CODEX_HOME:m}:e.env,v={command:d,args:l,cwd:e.cwd,...w?{env:w}:{}};super(v),this.authMethodId=e.authMethodId,this.codexHomeDir=m}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{hx(this.codexHomeDir,{recursive:!0,force:!0})}catch{}}};var bt=class extends Xe{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}`}]}))}get acpSessionName(){return this.sessionName}};U();ie();function zr(n){return n.replace(/[^A-Za-z0-9._-]+/g,"-")}var St=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}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 Tn=class{agentId;framework;workspace;deployType;accountId;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)}getSessionQueue(e){let s=this.sessionQueues.get(e);return s||(s=new St,this.sessionQueues.set(e,s)),s}allSessionQueues(){return this.sessionQueues.entries()}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)jt(o),o.downstream&&(s.push(o.downstream.stop(e).catch(()=>{})),o.downstream=void 0);await Promise.all(s),this.activeTriggers.clear()}};function jt(n){n.idleTimer&&(clearTimeout(n.idleTimer),n.idleTimer=void 0)}import{spawn as yx}from"node:child_process";import{homedir as vx}from"node:os";import{join as bx}from"node:path";an();U();async function Ws(){let n=bx(vx(),".openclaw/openclaw.json");return(await pt(n))?.gateway?.auth?.token??""}var Ks=D("openclaw.config"),Sx=[0,5e3,5e3],Gs="models.providers.",Dn="agents.defaults.models",Rn=class{command;env;retryDelaysMs;queue=new St;constructor(e){this.command=e.command,this.env=e.env??process.env,this.retryDelaysMs=e.retryDelaysMs??Sx}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(f=>setTimeout(f,d));try{return await s()}catch(f){o=f,Ks.warn("openclaw cli failed, will retry",{label:e,attempt:c+1,err:String(f)})}}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=yx(this.command,e,{stdio:["ignore","pipe","pipe"],env:this.env}),d="";c.stderr?.on("data",f=>{d+=f.toString("utf8")}),c.on("error",o),c.on("close",f=>{f===0?s():o(new Error(`exit ${f}: ${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){Ks.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",`${Gs}${e}`,JSON.stringify(s),"--strict-json","--merge"])))}removeProvider(e){return this.bestEffortUnset(`config unset models.providers.${e}`,`${Gs}${e}`)}addModelToAllowlist(e,s){let o={[e]:s?{alias:s}:{}};return this.queue.enqueue(()=>this.withRetry(`config set ${Dn}[${e}]`,()=>this.runCli(["config","set",Dn,JSON.stringify(o),"--strict-json","--merge"])))}removeModelFromAllowlist(e){return this.bestEffortUnset(`config unset ${Dn}[${e}]`,`${Dn}.${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 Re=D("agent-manager"),Ax=(n,e,s,o,c,d,f,l)=>{switch(n){case"claude-code":{let m={...c?{...ws(c),...vs(c,f)}:{},...l??{}};return new Pn({cwd:s,...Object.keys(m).length>0?{env:m}:{}})}case"codex":{let m=c?[..._s(c),...Ss(c,f)]:[],w={...c?ys(c):{},...l??{}},v=!!c;return new kn({cwd:s,...m.length>0?{extraArgs:m}:{},...Object.keys(w).length>0?{env:w}:{},...v?{authMethodId:"openai-api-key",isolateCodexHome:!0}:{}})}case"openclaw":return new bt({command:e,cwd:s,agentId:o,...d?{sessionName:zr(d)}:{}})}};function js(n){return n==="claude-code"||n==="codex"}var Cx={path:"",version:"cloud-deployed"},Ix={protocolVersion:1,clientCapabilities:{fs:{readTextFile:!0,writeTextFile:!0}}},Px=6e4,Nn=class{paths;config;registry;factory;createTimeoutMs;openclawConfigCache;ensuredProviders=new Set;constructor(e){this.paths=e.paths,this.config=e.config,this.registry=e.registry,this.factory=e.downstreamFactory??Ax,this.createTimeoutMs=e.createTimeoutMs??Px}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 Rn({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=Mt(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")Re.warn("existing agent in error state, rebuilding",{agentId:e.agentId}),await o.dispose("rebuild after error").catch(P=>Re.warn("dispose stale agent failed (ignored)",{err:String(P)})),this.registry.unregister(e.agentId);else return Re.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`);s&&js(e.framework)&&await Ls(e.framework);let d=Ue(e.agentId,this.paths),f=Mt(e._meta),l=e.framework==="openclaw"&&f==="local",m=l?this.config.frameworksCache?.openclaw?.defaultAgent?.workspace:void 0,w=e.workspace??m??d.workspace,v=new AbortController,_=setTimeout(()=>v.abort(new S("AGENT_TIMEOUT",`_agent/create timed out after ${this.createTimeoutMs}ms`)),this.createTimeoutMs),E,T=!1;try{let P=()=>{if(v.signal.aborted)throw v.signal.reason instanceof Error?v.signal.reason:new S("AGENT_TIMEOUT","_agent/create aborted")};await Fr(d.root,{recursive:!0}),await Fr(w,{recursive:!0}),await Fr(d.logs,{recursive:!0}),P(),l||await mt(w,e.framework,e.agentId,e.cozeIdentity),P();let R=await he(e.agentId,this.paths).catch(()=>null),z=ps({model:e.model??R?.model}),ne=cs(e._meta)??R?.accountId;if(E=new Tn({agentId:e.agentId,framework:e.framework,workspace:w,model:z.model??Te,deployType:f,...ne?{accountId:ne}:{}}),E.status="ok",R?.sessions){for(let[se,oe]of Object.entries(R.sessions))E.sessions.set(se,{acpSessionId:oe.acpSessionId,modelToken:oe.modelToken,tokenGeneratedAt:oe.tokenGeneratedAt,lastActiveAt:Date.now(),loadingSession:!1,replySeq:0});let Z=Object.keys(R.sessions).length;Z>0&&Re.info("restored persisted session records (no spawn)",{agentId:e.agentId,count:Z})}this.registry.register(E),T=!0;let j={agentId:e.agentId,framework:e.framework,workspace:w,cozeIdentity:e.cozeIdentity,createdAt:R?.createdAt??Date.now(),sessions:R?.sessions??{},model:z.model};f==="cloud"&&(j.deployType="cloud"),ne&&(j.accountId=ne),R?.skills&&(j.skills=R.skills),R?.agentName&&(j.agentName=R.agentName),R?.description&&(j.description=R.description),e.framework==="openclaw"&&f==="cloud"&&(this.config.frameworksCache?.openclaw?.path?await this.getOpenclawConfig().ensureAgent(e.agentId,w):Re.warn("openclaw binary not on this machine, skip agents add (will fail at session/prompt)",{agentId:e.agentId}));let me=e.initialSkills??[];if(me.length>0){let Z=[...j.skills??[]],se=new Map(Z.map((k,L)=>[k.skillId,L])),oe=0;for(let k of me)try{let L=await Or({agentId:e.agentId,workspace:w,framework:e.framework,skill:k});Br(Z,se,L),oe++}catch(L){Re.warn("initialSkill install failed (skipping)",{agentId:e.agentId,skillId:k.skillId,skillName:k.skillName,err:String(L)})}oe>0&&(j.skills=Z,Re.info("initialSkills installed",{agentId:e.agentId,installed:oe,requested:me.length}))}return await Ae(j,this.paths),Re.info("agent created (no spawn, lazy on first prompt)",{agentId:e.agentId,framework:e.framework,deployType:f}),{ok:!0,agentId:e.agentId,workspace:w,framework:e.framework}}catch(P){throw Re.error("agent create failed, rolling back",{agentId:e.agentId,err:String(P)}),T&&E&&(await E.dispose("rollback").catch(()=>{}),this.registry.unregister(e.agentId)),await Ex(d.root,{recursive:!0,force:!0}).catch(R=>Re.warn("rm agent dir failed (ignored)",{err:String(R)})),P instanceof S?P:new S("AGENT_SPAWN_FAILED",String(P),{cause:P})}finally{clearTimeout(_)}}async spawnSessionDownstream(e,s,o,c){let f=this.config.frameworksCache?.[e.framework];if(!f)if(e.deployType==="cloud"&&js(e.framework))f=Cx;else throw new S("AGENT_SPAWN_FAILED",`framework ${e.framework} not detected on this machine`);let l=e.deployType==="cloud"?{model:e.model,modelToken:s}:void 0,m;e.framework==="openclaw"?m=await this.buildOpenclawDownstream({session:e,modelConfig:l,cloudSessionId:o,cozeEnv:c,command:f.path}):m=this.factory(e.framework,f.path,e.workspace,e.agentId,l,o,c,this.buildBinShimPathEnv());try{return await m.start(),await m.initialize(Ix),m}catch(w){throw await m.stop("spawnSessionDownstream failed").catch(()=>{}),w instanceof S?w:new S("AGENT_SPAWN_FAILED",w instanceof Error?w.message:String(w),{cause:w})}}async buildOpenclawDownstream(e){let{session:s,modelConfig:o,cloudSessionId:c,cozeEnv:d,command:f}=e,l=zr(c);if(s.deployType==="local"){let _=this.config.frameworksCache?.openclaw?.defaultAgent;if(!_?.id||!_.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 bt({command:f,cwd:_.workspace,agentId:_.id,sessionName:l})}let m=await Ws(),w=o?bs(o,d):null,v;if(w){let _=Nr(c),T=w.models[0]?.id??Te,P=`${_}/${T}`;if(!this.ensuredProviders.has(P)){let R=this.getOpenclawConfig();await R.ensureProvider(_,w),await R.addModelToAllowlist(P),this.ensuredProviders.add(P)}v=P}return new bt({command:f,cwd:s.workspace,agentId:s.agentId,sessionName:l,...m?{gatewayToken:m}:{},...v?{slashModelOnStart:v}:{}})}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=Nr(o),d=`${c}/${e.model}`;this.ensuredProviders.delete(d),await s.removeProvider(c),await s.removeModelFromAllowlist(d)}}};import{randomUUID as Fx}from"node:crypto";import{promises as Ux}from"node:fs";import{basename as qx}from"node:path";import{promises as Tx}from"node:fs";import{basename as Dx}from"node:path";U();var Js=D("file-upload"),Rx="/api/coze_claw/file/agent_upload",Nx=6e4;async function Vs(n,e={}){let o=`${pn(wn(e.handshakeBase))}${Rx}`,c=e.timeoutMs??Nx,d=await Tx.readFile(n.path),f=new FormData;f.append("agent_id",n.agentId),f.append("session_id",n.sessionId),f.append("file_name",n.name),f.append("file_content",new Blob([d],{type:n.mimeType}),n.name);let l={Authorization:`Bearer ${n.patToken}`,Accept:"application/json","x-coze-version":"3.0",..._t(e.ppeOverride),...n.accountId?{"x-coze-account":n.accountId}:{}},m=new AbortController,w=setTimeout(()=>m.abort(),c);Js.info("file upload start",{url:o,agentId:n.agentId,sessionId:n.sessionId,name:n.name,bytes:n.sizeBytes,mime:n.mimeType});try{let v=await fetch(o,{method:"POST",headers:l,body:f,signal:m.signal}),_=v.headers.get("x-tt-logid")??"";if(!v.ok){let P=await v.text().catch(()=>"");throw new S("UPLOAD_FAILED",`upload HTTP ${v.status} logid=${_}: ${P.slice(0,200)}`)}let E=await v.json();if(E.code!==void 0&&E.code!==0)throw new S("UPLOAD_FAILED",`upload code=${E.code} msg=${E.msg??"-"} logid=${_}`);let T=E.data?.file?.file_url;if(!T)throw new S("UPLOAD_FAILED",`upload response missing data.file.file_url logid=${_}: ${JSON.stringify(E).slice(0,200)}`);return Js.info("file upload ok",{uri:T,logid:_}),{uri:T}}catch(v){throw v instanceof S?v:v.name==="AbortError"?new S("UPLOAD_FAILED",`upload timeout (${c}ms) for ${Dx(n.path)}`):new S("UPLOAD_FAILED",String(v),{cause:v})}finally{clearTimeout(w)}}U();import{promises as Lx}from"node:fs";import{extname as Ox}from"node:path";var Bx=[{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 Mx(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 zx={".txt":"text/plain",".md":"text/markdown"};async function $s(n){let e=await Lx.open(n,"r");try{let s=Buffer.alloc(16);if(await e.read(s,0,16,0),Mx(s))return"image/webp";for(let o of Bx)if(o.prefix.every((c,d)=>s[d]===c))return o.mime}finally{await e.close()}return zx[Ox(n).toLowerCase()]??"application/octet-stream"}ie();var Hx=D("agent-send"),Ys=50*1024*1024,Kx=new Set(["image/png","image/jpeg","image/webp","image/gif","application/pdf","text/plain","text/markdown"]);async function Xs(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 os(n.path,s.workspace))throw new S("PATH_OUTSIDE_WORKSPACE",`path=${n.path} not under workspace=${s.workspace}`);let c=await Ux.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>Ys)throw new S("FILE_TOO_LARGE",`${c.size} bytes > limit ${Ys}`);let d=await $s(n.path);if(!Kx.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 f=n.name??qx(n.path),l=await Vs({patToken:e.patToken,agentId:n.agentId,sessionId:n.sessionId,path:n.path,mimeType:d,name:f,sizeBytes:c.size,...s.accountId?{accountId:s.accountId}:{}},{handshakeBase:e.handshakeBase,ppeOverride:e.ppeOverride}),m={sessionUpdate:"agent_file",messageId:Fx(),content:{type:n.kind==="image"?"image":"resource",uri:l.uri,mimeType:d,name:f,sizeBytes:c.size,...l.fileId!==void 0?{fileId:l.fileId}:{},...n.caption!==void 0?{caption:n.caption}:{}}};return await e.core.sendAgentFileUpdate(s,o,n.sessionId,m),Hx.info("agent file sent",{agentId:n.agentId,sessionId:n.sessionId,kind:n.kind,name:f,bytes:c.size,mime:d,uri:l.uri}),{ok:!0,uri:l.uri,bytes:c.size,mimeType:d,...l.fileId!==void 0?{fileId:l.fileId}:{}}}U();import{execFile as Gx}from"node:child_process";import{promisify as Wx}from"node:util";var jx=Wx(Gx),Ze=D("coze-cli-installer"),Zs="@coze/cli@0.1.3-alpha.89c42a",Qs="https://bnpm.byted.org",Jx="coze",Vx=5e3,$x=9e4,eo=1e4,Jt=null,Ur=!1;async function qr(n,e={}){if(Ur)return;if(Jt)return Jt;let s=e.exec??jx;return Jt=(async()=>{try{let o=await Yx(Jx,s);if(o){Ze.info("coze-cli already on PATH, skip install + config + auth",{path:o}),Ur=!0;return}Ze.info("coze-cli install start",{package:Zs,registry:Qs});try{await s("npm",["i","-g",Zs,"--registry",Qs],{timeout:$x,maxBuffer:10*1024*1024}),Ze.info("coze-cli install ok")}catch(c){Ze.warn("coze-cli install failed (skip subsequent steps)",{err:String(c)});return}if(n.env)try{await s("coze",["config","set","xTTEnv",n.env],{timeout:eo}),Ze.info("coze config set xTTEnv ok",{env:n.env})}catch(c){Ze.warn("coze config set failed (continue to auth login)",{err:String(c)})}try{await s("coze",["auth","login","--token",n.patToken],{timeout:eo}),Ze.info("coze auth login ok")}catch(c){Ze.warn("coze auth login failed",{err:String(c)});return}Ur=!0}finally{Jt=null}})(),Jt}async function Yx(n,e){let s=process.platform==="win32"?"where":"which";try{let{stdout:o}=await e(s,[n],{timeout:Vx});return o.split(`
118
- `)[0]?.trim()||void 0}catch{return}}U();import{spawn as Xx}from"node:child_process";import{constants as to,access as Zx}from"node:fs/promises";import{delimiter as Qx,join as ed}from"node:path";var no=D("framework-detector"),ro={"claude-code":"claude",codex:"codex",openclaw:"openclaw"},td=[".exe",".cmd",".bat",".ps1"],Et=class{env;constructor(e={}){this.env={pathEnv:e.pathEnv??process.env.PATH??"",platform:e.platform??process.platform,spawn:e.spawn??Xx,access:e.access??Zx}}async detect(e){let s=ro[e],o=await this.which(s);if(!o)return no.debug("framework binary not found",{framework:e,bin:s}),null;let[c,d]=await Promise.all([this.probeVersion(o),e==="openclaw"?this.probeOpenclawDefaultAgent(o):Promise.resolve(null)]),f={path:o,version:c};return d&&(f.defaultAgent=d),f}async detectAll(){let e=await Promise.all(Object.keys(ro).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(Qx).filter(Boolean),o=this.env.platform==="win32"?["",...td]:[""];for(let c of s)for(let d of o){let f=ed(c,e+d);if(await this.isExecutable(f))return f}return null}async isExecutable(e){try{let s=this.env.platform==="win32"?to.F_OK:to.X_OK;return await this.env.access(e,s),!0}catch{return!1}}async probeOpenclawDefaultAgent(e){let s=await this.runProbe(e,["agents","list","--json"]);if(!s||s.code!==0)return null;try{let o=JSON.parse(s.stdout);if(!Array.isArray(o))return null;let c=o.find(d=>d?.isDefault===!0);return!c?.id||!c.workspace?null:{id:c.id,workspace:c.workspace}}catch(o){return no.warn("openclaw agents list --json parse failed",{err:String(o)}),null}}async probeVersion(e){let s=await this.runProbe(e,["--version"]);return s&&(rd(s.stdout).split(/\r?\n/)[0]??"").trim()||"unknown"}runProbe(e,s){return new Promise(o=>{let c="",d=!1,f,l=m=>{d||(d=!0,f&&clearTimeout(f),o(m))};try{let m=this.env.spawn(e,s,{stdio:["ignore","pipe","pipe"]});f=setTimeout(()=>{m.kill("SIGKILL"),l(null)},5e3),m.stdout?.on("data",w=>{c+=w.toString("utf8")}),m.on("error",()=>l(null)),m.on("close",w=>l({code:w,stdout:c}))}catch{l(null)}})}},nd=new RegExp("\x1B\\[[0-9;]*[A-Za-z]","g");function rd(n){return n.replace(nd,"")}an();ie();var id=10*6e4;function io(n){let e=n?.sessionIdleTimeoutMs;return typeof e!="number"||!Number.isFinite(e)||e<=0?id:e}function Ln(n){return pt(n??F().configFile)}function At(n,e){return on(e??F().configFile,n)}import{randomBytes as md}from"node:crypto";import{mkdir as sd,readFile as od,realpath as ad,writeFile as cd}from"node:fs/promises";import{basename as xd,dirname as Hr,join as dd,relative as ud,resolve as so,sep as fd}from"node:path";U();var ao=D("fs-rpc");async function co(n,e){let s=await uo(n.path,e);return await sd(Hr(s),{recursive:!0}),await cd(s,n.content,"utf8"),ao.info("fs/write_text_file ok",{path:s,size:n.content.length}),null}async function xo(n,e){let s=await uo(n.path,e),o=await od(s,"utf8"),c=o;if(typeof n.line=="number"||typeof n.limit=="number"){let d=o.split(`
119
- `),f=Math.max(0,(n.line??1)-1),l=typeof n.limit=="number"?f+n.limit:void 0;c=d.slice(f,l).join(`
120
- `)}return ao.info("fs/read_text_file ok",{path:s,size:c.length}),{content:c}}async function uo(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([oo(so(e)),oo(so(n))]),c=ud(s,o);if(c.startsWith("..")||c===".."||c.startsWith(`..${fd}`))throw new S("IPC_BAD_REQUEST",`path escapes workspace: ${n}`);return o}async function oo(n){let e=[],s=n;for(;s!==Hr(s);)try{let o=await ad(s);return e.length?dd(o,...e.reverse()):o}catch{e.push(xd(s)),s=Hr(s)}return n}U();var fo=D("prompt-multimodal"),lo=10*1024*1024,ld=15e3;async function go(n){return Promise.all(n.map(gd))}async function gd(n){if(n.type!=="image")return n;let e=n;if(e.data||!e.uri||!hn(e.uri))return n;try{let{buf:s,contentType:o}=await pd(e.uri),c=e.mimeType||hd(o)||"application/octet-stream";return fo.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 fo.warn("image fetch failed, degrading to text block",{uri:e.uri,err:String(s)}),{type:"text",text:`[image load failed: ${e.uri}]`}}}function hd(n){if(!n)return;let e=n.indexOf(";");return(e===-1?n:n.slice(0,e)).trim()||void 0}async function pd(n){let e=new AbortController,s=setTimeout(()=>e.abort(),ld);try{let o=await fetch(n,{signal:e.signal});if(!o.ok)throw new Error(`HTTP ${o.status} ${o.statusText}`);let c=await o.arrayBuffer();if(c.byteLength>lo)throw new Error(`image too large: ${c.byteLength} bytes (max ${lo})`);return{buf:Buffer.from(c),contentType:o.headers.get("content-type")??void 0}}finally{clearTimeout(s)}}Ye();U();var q=D("core"),wd=3e4,_d=3e4,On=class{upstream;agents=new Map;disconnectedAgents=new Set;extensions;paths;sessionSpawner;sessionIdleTimeoutMs;upstreamIds=new vt;pendingUpstream=new Map;pendingBridge=new Map;currentCozeEnv;constructor(e){this.upstream=e.upstream,this.extensions=e.extensions??{},this.paths=e.paths,this.sessionSpawner=e.sessionSpawner,this.sessionIdleTimeoutMs=io(e.bridgeConfig)}registerExtension(e,s){this.extensions[e]=s}getCozeEnv(){return this.currentCozeEnv}async start(){this.upstream.onFrame(e=>this.handleFrame(e)),await this.upstream.start(),q.info("Core started",{extensions:Object.keys(this.extensions)})}async stop(e){q.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),q.info("agent registered",{agentId:e.agentId,framework:e.framework});for(let s of this.registerHandlers)try{s(e.agentId)}catch(o){q.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)&&q.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,f)=>{q.info("session runtime exited",{agentId:e.agentId,cloudId:s,code:d,signal:f}),jt(o),o.downstream=void 0,o.acpSessionId&&e.activeTriggers.delete(o.acpSessionId)}))}async handleFrame(e){if(Cn(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&&(this.currentCozeEnv=o);try{if(e.method.startsWith("_agent/")){let c=this.extensions[e.method];if(!c){s!==null?await this.sendError(s,K.METHOD_NOT_FOUND,`extension not registered: ${e.method}`):q.warn("drop notification: extension not registered",{method:e.method});return}let d=await c(e,this);s!==null&&await this.upstream.send(yt(s,d));return}if(e.method.startsWith("session/")){let c=await this.routeSessionMethod(e);s!==null&&await this.upstream.send(yt(s,c));return}if(e.method==="initialize"){s!==null&&await this.upstream.send(yt(s,{protocolVersion:1,agentCapabilities:{loadSession:!0}}));return}s!==null?await this.sendError(s,K.METHOD_NOT_FOUND,`method not implemented: ${e.method}`):q.warn("drop unknown notification",{method:e.method})}catch(c){q.error("handleFrame failed",{method:e.method,err:String(c)}),s!==null&&await this.upstream.send(st(s,Wt(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 f=Date.now(),l=!1;try{let m=await c.getSessionQueue(d).enqueue(()=>this.dispatchSessionCall(c,e.method,s));return l=!0,m}finally{q.info("session call done",{agentId:c.agentId,method:e.method,durationMs:Date.now()-f,ok:l})}}async dispatchSessionCall(e,s,o){e.lastActiveAt=Date.now();let{stripped:c}=xs(o);switch(s){case"session/new":{let d=yd();return q.info("session/new ack (lazy spawn)",{agentId:e.agentId,cloudId:d}),{sessionId:d}}case"session/load":{let d=c;return q.info("session/load ack (lazy spawn)",{agentId:e.agentId,cloudId:d.sessionId}),{}}case"session/prompt":{let d=c,f=d.sessionId;if(!f)throw new S("IPC_BAD_REQUEST","session/prompt: missing sessionId");let l=await this.ensureRuntime(e,f);if(l.replySeq=0,await this.ensureDownstream(e,f,l),!l.downstream||!l.acpSessionId)throw new S("BRIDGE_INTERNAL","session runtime not ready after ensureDownstream");let m=o._meta?.cozeTriggerMsgId;m?e.activeTriggers.set(l.acpSessionId,m):e.activeTriggers.delete(l.acpSessionId);let w=await go(d.prompt);try{let v=await l.downstream.sessionPrompt({...d,sessionId:l.acpSessionId,prompt:w});return l.lastActiveAt=Date.now(),v}finally{e.activeTriggers.delete(l.acpSessionId),l.downstream?.isAlive()&&this.armIdleTimer(e,f,l)}}case"session/cancel":{let f=c.sessionId;if(!f)throw new S("IPC_BAD_REQUEST","session/cancel: missing sessionId");let l=e.sessions.get(f);return l?.downstream?.isAlive()&&l.acpSessionId&&await l.downstream.sessionCancel({sessionId:l.acpSessionId}),{ok:!0}}default:throw new S("IPC_BAD_REQUEST",`session method not supported: ${s}`)}}async ensureRuntime(e,s){let o=e.sessions.get(s);if(o)return o;let d={modelToken:e.deployType==="cloud"?await this.requestSessionToken(e.agentId,s):"",tokenGeneratedAt:Date.now(),lastActiveAt:Date.now(),loadingSession:!1,replySeq:0};return e.sessions.set(s,d),await this.persistSessionMapping(e),d}async requestSessionToken(e,s){let o={sessionId:s,_meta:{cozeAgentId:e}};try{let c=await this.sendRequest(ke.GEN_MODEL_TOKEN,o,_d);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(jt(o),o.downstream?.isAlive())return;if(!this.sessionSpawner)throw new S("AGENT_SPAWN_FAILED","sessionSpawner not wired (cannot spawn per-session downstream)");let c=await this.sessionSpawner(e,o.modelToken,s,this.currentCozeEnv);if(o.downstream=c,this.attachRuntimeHooks(e,s,o),o.acpSessionId){o.loadingSession=!0;try{await c.sessionLoad({sessionId:o.acpSessionId,cwd:e.workspace}),q.info("session restored via session/load",{agentId:e.agentId,cloudId:s,acpId:o.acpSessionId})}catch(d){q.warn("session/load failed, fallback to session/new",{agentId:e.agentId,cloudId:s,acpId:o.acpSessionId,err:String(d)}),o.acpSessionId=void 0;let f=await c.sessionNew({cwd:e.workspace});o.acpSessionId=f.sessionId,await this.persistSessionMapping(e)}finally{o.loadingSession=!1}}else{let d=await c.sessionNew({cwd:e.workspace});o.acpSessionId=d.sessionId,await this.persistSessionMapping(e)}c.afterSessionEstablished&&o.acpSessionId&&await c.afterSessionEstablished(o.acpSessionId)}armIdleTimer(e,s,o){if(jt(o),this.isRuntimeBusy(e,o)){q.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)){q.info("idle reaper fired but runtime busy, re-arming",{agentId:e.agentId,cloudId:s}),this.armIdleTimer(e,s,o);return}q.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=>q.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 f=e.activeTriggers.get(s.acpSessionId);f&&(d.cozeTriggerMsgId=f)}await this.upstream.send(Gt("session/update",{sessionId:o,update:c,_meta:d}))}forwardUpdate(e,s){let o=s.sessionId,c=this.reverseSessionId(e,o);if(!c){q.debug("drop update for unknown session",{agentId:e.agentId,acpId:o});return}let d=e.sessions.get(c);if(!d){q.debug("drop update: runtime gone",{agentId:e.agentId,cloudId:c});return}if(vd(s)){q.debug("drop codex metadata-warn chunk",{agentId:e.agentId,acpId:o});return}let f={cozeAgentId:e.agentId,cozeReplySeqID:++d.replySeq},l=e.activeTriggers.get(o);l&&(f.cozeTriggerMsgId=l),this.upstream.send(Gt("session/update",{...s,sessionId:c,_meta:f})).catch(m=>q.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}q.warn("unhandled agent request,returning method_not_found",{agentId:e.agentId,method:o.method}),s.respondAgentRequestError(o.id,{code:K.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??{},f=await co(d,c);s.respondAgentRequest(o.id,f)}else{let d=o.params??{},f=await xo(d,c);s.respondAgentRequest(o.id,f)}}catch(c){q.warn("fs rpc handler failed",{agentId:e.agentId,method:o.method,err:String(c)}),s.respondAgentRequestError(o.id,Wt(c))}}forwardPermissionRequest(e,s,o){let c=this.upstreamIds.next("session/request_permission"),d=o.params??{},l=d.sessionId,m=l?e.activeTriggers.get(l):void 0,w={cozeAgentId:e.agentId};m&&(w.cozeTriggerMsgId=m);let v=l?this.reverseSessionId(e,l):void 0,_={...d,...v?{sessionId:v}:{},_meta:w};this.pendingUpstream.set(c,{agentRequestId:o.id,agentId:e.agentId,downstream:s,method:o.method}),q.info("forward permission_request \u2192 upstream",{agentId:e.agentId,upstreamId:c,acpSessionId:l,cloudSessionId:v,toolCallId:d.toolCall?.toolCallId,options:d.options?.map(E=>({optionId:E.optionId,kind:E.kind,name:E.name}))}),this.upstream.send(Kt(c,"session/request_permission",_)).catch(E=>{this.pendingUpstream.delete(c),q.error("forward permission request failed",{agentId:e.agentId,err:String(E)}),s.respondAgentRequestError(o.id,{code:K.INTERNAL_ERROR,message:`upstream send failed: ${String(E)}`})})}handleUpstreamResponse(e){if(e.id===null)return;let s=this.pendingUpstream.get(e.id);if(s){this.pendingUpstream.delete(e.id),e.error?(q.info("upstream \u2192 permission response (error)",{agentId:s.agentId,upstreamId:e.id,method:s.method,error:e.error}),s.downstream.respondAgentRequestError(s.agentRequestId,e.error)):(q.info("upstream \u2192 permission response (result)",{agentId:s.agentId,upstreamId:e.id,method:s.method,result:e.result}),s.downstream.respondAgentRequest(s.agentRequestId,e.result));return}let o=this.pendingBridge.get(e.id);if(o){this.pendingBridge.delete(e.id),clearTimeout(o.timer),e.error?o.reject(new An(e.error)):o.resolve(e.result);return}q.debug("orphan upstream response (no pending)",{id:e.id})}sendRequest(e,s,o=wd){let c=this.upstreamIds.next(e);return new Promise((d,f)=>{let l=setTimeout(()=>{this.pendingBridge.delete(c),f(new S("AGENT_TIMEOUT",`${e} timed out after ${o}ms`))},o);this.pendingBridge.set(c,{method:e,resolve:d,reject:f,timer:l}),this.upstream.send(Kt(c,e,s)).catch(m=>{let w=this.pendingBridge.get(c);w&&(clearTimeout(w.timer),this.pendingBridge.delete(c)),f(m)})})}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 kr(e.agentId,s,this.paths)}catch(s){q.warn("persist session mapping failed",{agentId:e.agentId,err:String(s)})}}reverseSessionId(e,s){for(let[o,c]of e.sessions.entries())if(c.acpSessionId===s)return o}sendError(e,s,o){return this.upstream.send(st(e,{code:s,message:o}))}};function yd(){return md(16).toString("hex")}function vd(n){let e=n.update;if(e?.sessionUpdate!=="agent_message_chunk")return!1;let s=e.content;if(!s||typeof s!="object")return!1;let o=s;return o.type!=="text"||typeof o.text!="string"?!1:o.text.startsWith("Model metadata for `")}U();ie();import{randomBytes as bd}from"node:crypto";import{chmod as Sd,mkdir as Ed,writeFile as ho}from"node:fs/promises";import{createServer as Ad}from"node:http";import{dirname as Cd}from"node:path";var Id=1e6,Kr=D("ipc"),Bn=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??F()}async start(){this.token=bd(32).toString("hex");let e=Ad((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(),Kr.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 Ed(Cd(this.paths.portFile),{recursive:!0}),await ho(this.paths.portFile,String(this.port),"utf8"),await ho(this.paths.tokenFile,this.token,{encoding:"utf8",mode:384});try{await Sd(this.paths.tokenFile,384)}catch(e){Kr.warn("chmod token file failed (non-POSIX?)",{err:String(e)})}}async dispatch(e,s){if(e.headers.authorization!==`Bearer ${this.token}`){Vt(s,401,{error:"unauthorized"});return}let c=`${e.method} ${(e.url??"").split("?")[0]}`,d=this.routes.get(c);if(!d){Vt(s,404,{error:"not found"});return}let f=null;if(e.method==="POST")try{f=await Pd(e)}catch(l){Vt(s,400,{error:"invalid json",detail:String(l)});return}try{let l=await d.handler(f,e);Vt(s,200,l??{ok:!0})}catch(l){Kr.error("IPC handler failed",{key:c,err:String(l)}),Vt(s,500,{error:l instanceof Error?l.message:String(l)})}}};function Vt(n,e,s){n.statusCode=e,n.setHeader("content-type","application/json"),n.end(JSON.stringify(s))}async function Pd(n){let e=[],s=0;for await(let c of n){let d=c;if(s+=d.length,s>Id)throw new Error("body too large");e.push(d)}let o=Buffer.concat(e).toString("utf8");return o?JSON.parse(o):null}var Ma=Fe(Co(),1);var xf=Fe(va(),1),df=Fe(Zn(),1),uf=Fe(Pt(),1),ff=Fe(ni(),1),lf=Fe(si(),1),gf=Fe(ui(),1),Ta=Fe(nr(),1),hf=Fe(ka(),1);var Da=Ta.default;U();var xe=D("upstream.frontier"),Na="application/json",La="none",rn=class{constructor(e){this.opts=e}opts;fws=null;handler=null;connectHandler=null;opened=!1;openCount=0;async start(){if(this.fws){xe.warn("start called on already-started FrontierUpstream; noop");return}let e={Authorization:`Bearer ${this.opts.privatecode}`,Origin:fs,..._t(this.opts.ppeOverride)};class s extends Da{constructor(l){super(l,us,{headers:e})}send(l,...m){if(rs("debug"))try{let w;typeof l=="string"?w=Buffer.from(l,"utf8"):l instanceof Buffer?w=l:l instanceof ArrayBuffer?w=new Uint8Array(l):ArrayBuffer.isView(l)?w=new Uint8Array(l.buffer,l.byteOffset,l.byteLength):w=new Uint8Array(0);let v=Buffer.from(w.slice(0,128)).toString("hex");xe.debug("WS raw frame out",{bytes:w.byteLength,headHex:v})}catch(w){xe.warn("WS raw frame dump failed",{err:String(w)})}super.send(l,...m)}}let o=gs(this.opts.urlOverride),c={url:o,ws:s,fpID:ds,aID:mn,accessKey:this.opts.handshake.accessKey,deviceID:this.opts.handshake.deviceId,payloadType:{type:Na,force:!0},payloadEncoding:{encoding:La,force:!0},enableTransformTextPayload:!0,enableQoS:!1,enableAutoAck:!1,automaticOpen:!1,debug:this.opts.debug??!1},d=new Ma.FWS(c);d.onopen=()=>{this.opened=!0,this.openCount+=1;let f=this.openCount===1;xe.info("frontier opened",{url:o,remoteDeviceId:this.opts.handshake.deviceId,initial:f,openCount:this.openCount}),this.connectHandler&&Promise.resolve(this.connectHandler({initial:f})).catch(l=>xe.warn("onConnect handler threw (ignored)",{err:String(l)}))},d.onclose=f=>{this.opened=!1,xe.info("frontier closed",{code:f.code,reason:f.reason,willReconnect:f.willReconnect})},d.onerror=f=>{xe.warn("frontier error",{code:f.code,msg:f.message})},d.onmessage=f=>this.handleMessage(f),this.fws=d,await d.connect()}async stop(e){let s=this.fws;if(s){this.fws=null,this.opened=!1;try{s.close(1e3,e??"bridge shutdown")}catch(o){xe.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");let o=JSON.stringify(e),c=e;Oa(c)||xe.info("frontier frame out",{method:c.method,jsonrpcId:c.id,size:o.length});try{await s.send(o,{service:33555712,method:1,payloadType:Na,payloadEncoding:La})}catch(f){throw xe.warn("frontier frame send failed",{method:c.method,jsonrpcId:c.id,err:String(f)}),new S("UPSTREAM_DISCONNECTED",`frontier send failed: ${String(f)}`,{cause:f})}}onFrame(e){this.handler=e}onConnect(e){this.connectHandler=e}isConnected(){return this.opened&&this.fws?.readyState===1}handleMessage(e){let s=e.message?.service;if(s!==33555712){xe.debug("drop non-adapter frontier frame",{service:s});return}let o=_f(e);if(!o){xe.debug("frontier message without text payload, drop",{payloadType:e.message?.payloadType});return}if(!this.handler){xe.debug("frame received but no onFrame handler",{size:o.length});return}let c;try{c=JSON.parse(o)}catch(f){xe.warn("frontier message JSON parse failed",{err:String(f),head:o.slice(0,80)});return}let d=c;Oa(d)||xe.info("frontier frame in",{logid:wf(e.message?.LogID),logidNew:e.message?.LogIDNew,msgId:e.message?.msgID,jsonrpcId:d.id,method:d.method,body:mf(o)}),Promise.resolve(this.handler(c)).catch(f=>xe.warn("frontier frame handler threw",{err:String(f)}))}};function Oa(n){return n.method==="_agent/health"?!0:typeof n.id=="string"&&n.id.startsWith("agent.health_")}var Ba=2e3;function mf(n){return n.length<=Ba?n:`${n.slice(0,Ba)}...<truncated, total ${n.length} chars>`}function wf(n){return n?n.high===0?String(n.low>>>0):`${n.high.toString(16)}${(n.low>>>0).toString(16).padStart(8,"0")}`:""}function _f(n){let e=n.message;if(e?.textPayload)return e.textPayload;let s=e?.payload;if(!s)return null;try{return Buffer.from(s).toString("utf8")}catch{return null}}U();var li=D("upstream.switchable"),ir=class{inner;handler=null;connectHandler=null;constructor(e){this.inner=e}async swap(e,s){if(this.inner===e)return;li.info("swap upstream",{reason:s});let o=this.inner;this.inner=e,this.handler&&e.onFrame(this.handler),this.connectHandler&&e.onConnect&&e.onConnect(this.connectHandler);try{await e.start()}catch(c){throw li.error("swap target start failed, reverting",{err:String(c)}),this.inner=o,c}await o.stop(s??"swapped").catch(c=>li.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.connectHandler=e,this.inner.onConnect?.(e)}isConnected(){return this.inner.isConnected()}};U();var gi=D("upstream"),Lt=class{handler=null;async start(){gi.info("NoopUpstream started (M1 skeleton; real Frontier wired in M4)")}async stop(e){gi.info("NoopUpstream stopped",{reason:e})}async send(e){gi.debug("NoopUpstream.send (dropped)",{method:"method"in e?e.method:void 0})}onFrame(e){this.handler=e}isConnected(){return!1}async injectFrame(e){this.handler&&await this.handler(e)}};U();U();ie();import{promises as hi}from"node:fs";import{dirname as yf}from"node:path";var vf=D("pat-token-store");async function za(n=F()){try{let s=(await hi.readFile(n.patTokenFile,"utf8")).trim();return s.length>0?s:null}catch(e){return e?.code!=="ENOENT"&&vf.warn("read pat-token failed (treating as missing)",{err:String(e)}),null}}async function sn(n,e=F()){if(!n)throw new Error("writePatToken: empty patToken");await hi.mkdir(yf(e.patTokenFile),{recursive:!0}),await hi.writeFile(e.patTokenFile,n,{encoding:"utf8",mode:384})}ie();ie();import{promises as sr}from"node:fs";import{join as bf}from"node:path";function Sf(n){return`#!/bin/sh
118
+ `);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(f){this.onError?.({line:x,error:f})}}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 Us={"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"},Jh=Object.fromEntries(Object.entries(Us).map(([n,e])=>[e,n])),rx={"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:[]},bt=class{seq=0;next(e,s){this.seq+=1;let o=Us[e]??ix(e),c=rx[o]??[],x=[o,String(this.seq)];if(c.length>0){let f=c.map(p=>Fs(s?.[p]??"")),u=sx(f).join(":");u&&x.push(u)}else s&&Object.values(s).some(f=>f)&&x.push(Object.values(s).filter(Boolean).map(f=>Fs(String(f))).join(":"));return x.join("_")}reset(){this.seq=0}};function ix(n){return n.replace(/[\s/]+/g,".").replace(/_+/g,"-")}function Fs(n){return n.replace(/[:_\s]+/g,"-")}function sx(n){let e=n.length;for(;e>0&&!n[e-1];)e-=1;return n.slice(0,e)}q();var cx=3e4,xx=50,dx=20,qs=500;function fx(n){try{let e=JSON.stringify(n);return e===void 0||e.length<=qs?n:`${e.slice(0,qs)}...<truncated, total ${e.length} chars>`}catch{return"<unserializable>"}}function Hs(n,e){if(!(typeof n!="number"||n<=0))try{if(process.platform==="win32"){let s=["/PID",String(n),"/T"];e==="SIGKILL"&&s.push("/F"),ax("taskkill",s,{stdio:"ignore",windowsHide:!0})}else process.kill(-n,e)}catch{}}var Ye=class{constructor(e){this.opts=e;this.log=R(`downstream.${this.constructor.name}`),this.decoder=new In({onError:s=>this.log.warn("decode line failed",{line:s.line})})}opts;child;decoder;pending=new Map;idAllocator=new bt;updateHandlers=[];agentRequestHandlers=[];exitHandlers=[];log;stopped=!1;stderrRing=[];sanitizeEnv(e){return e}async start(){if(this.child)throw new v("BRIDGE_INTERNAL","Downstream already started");let e=process.platform!=="win32",s=ox(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=>{for(let c of this.decoder.push(o))this.dispatch(c)}),s.stderr?.setEncoding("utf8"),s.stderr?.on("data",o=>{let c=o.trimEnd();this.stderrRing.push(c),this.stderrRing.length>xx&&this.stderrRing.shift(),this.log.debug("stderr",{text:c})}),s.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.slice(-dx)}),this.failAllPending(new v("AGENT_PROTOCOL_ERROR",`agent exited (${o}/${c})`));for(let f of this.exitHandlers)f(o,c)}),s.on("error",o=>{this.log.error("child error",{err:String(o)}),this.failAllPending(new v("AGENT_SPAWN_FAILED",String(o),{cause:o}))}),this.log.info("downstream started",{command:this.opts.command,pid: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()));Hs(s.pid,"SIGTERM");let c=setTimeout(()=>{s.killed||Hs(s.pid,"SIGKILL")},5e3);try{await o}finally{clearTimeout(c)}}pid(){return this.child?.pid}isAlive(){return!!this.child&&!this.stopped}initialize(e){return this.call("initialize",e)}sessionNew(e){return this.call("session/new",{mcpServers:[],...e})}sessionLoad(e){return this.call("session/load",{mcpServers:[],...e})}sessionPrompt(e){return this.call("session/prompt",e,0)}async sessionCancel(e){!this.child||this.stopped||this.writeFrame(jt("session/cancel",e))}onUpdate(e){this.updateHandlers.push(e)}onAgentRequest(e){this.agentRequestHandlers.push(e)}respondAgentRequest(e,s){if(!(!this.child||this.stopped))try{this.writeFrame(yt(e,s))}catch(o){this.log.warn("respondAgentRequest write failed",{id:e,err:String(o)})}}respondAgentRequestError(e,s){if(!(!this.child||this.stopped))try{this.writeFrame(st(e,s))}catch(o){this.log.warn("respondAgentRequestError write failed",{id:e,err:String(o)})}}onExit(e){this.exitHandlers.push(e)}call(e,s,o=cx){if(!this.child||this.stopped)return Promise.reject(new v("AGENT_PROTOCOL_ERROR","downstream not started"));let c=this.idAllocator.next(e),x=Kt(c,e,s),f=o>0&&Number.isFinite(o);return new Promise((u,p)=>{let m=f?setTimeout(()=>{this.pending.delete(c),p(new v("AGENT_TIMEOUT",`${e} timed out after ${o}ms`))},o):null;this.pending.set(c,{resolve:u,reject:p,timer:m,method:e});try{this.writeFrame(x)}catch(b){m&&clearTimeout(m),this.pending.delete(c),p(b)}})}writeFrame(e){if(!this.child?.stdin||this.child.stdin.destroyed)throw new v("AGENT_PROTOCOL_ERROR","downstream stdin not writable");this.child.stdin.write(zs(e))}dispatch(e){if(An(e)){let s=e.id!==null?this.pending.get(e.id):void 0;if(!s){this.log.warn("orphan response",{id:e.id});return}this.pending.delete(e.id),s.timer&&clearTimeout(s.timer),e.error?(this.log.warn("downstream returned error frame",{id:e.id,method:s.method,code:e.error.code,message:e.error.message,data:e.error.data}),s.reject(Bs(e.error))):(this.log.info("downstream returned result",{id:e.id,method:s.method,result:fx(e.result)}),s.resolve(e.result));return}if(Ms(e)){if(e.method==="session/update")for(let s of this.updateHandlers)Promise.resolve(s(e.params)).catch(o=>this.log.warn("update handler failed",{err:String(o)}));else this.log.debug("unknown notification",{method:e.method});return}if(Os(e)){let s=e;this.handleAgentRequest(s).catch(o=>this.log.error("agent request handler failed",{method:s.method,err:String(o)}))}}async handleAgentRequest(e){if(this.agentRequestHandlers.length===0){this.writeFrame(st(e.id,{code:-32601,message:`method not handled by Bridge: ${e.method}`}));return}for(let s of this.agentRequestHandlers)try{await s(e)}catch(o){this.log.error("agentRequestHandler threw",{method:e.method,err:String(o)});try{this.writeFrame(st(e.id,Gt(o)))}catch{}}}failAllPending(e){for(let s of this.pending.values())s.timer&&clearTimeout(s.timer),s.reject(e);this.pending.clear()}};var ux="@agentclientprotocol/claude-agent-acp@latest";function lx(n){let e={};for(let[s,o]of Object.entries(n))o!==void 0&&(s.startsWith("CLAUDE")||s==="AI_AGENT"||s==="BAGGAGE"||(e[s]=o));return e}var kn=class extends Ye{framework="claude-code";constructor(e){let s=En("claude-code"),[o,c]=s?[s,[]]:["npx",["-y",ux]],x=e.command??o,f=e.args??c,u={command:x,args:f,cwd:e.cwd,...e.env?{env:e.env}:{}};super(u)}sanitizeEnv(e){return lx(e)}};import{mkdtempSync as hx,rmSync as gx}from"node:fs";import{tmpdir as px}from"node:os";import{join as mx}from"node:path";var _x="@zed-industries/codex-acp@latest",Pn=class extends Ye{framework="codex";authMethodId;codexHomeDir;constructor(e){let s=En("codex"),[o,c]=s?[s,[]]:["npx",["-y",_x]],x=e.command??o,f=e.args??c,u=e.extraArgs?[...f,...e.extraArgs]:f,p=e.isolateCodexHome?hx(mx(px(),"coze-bridge-codex-home-")):void 0,m=p?{...e.env??{},CODEX_HOME:p}:e.env,b={command:x,args:u,cwd:e.cwd,...m?{env:m}:{}};super(b),this.authMethodId=e.authMethodId,this.codexHomeDir=p}async initialize(e){let s=await super.initialize(e);return this.authMethodId&&await this.call("authenticate",{methodId:this.authMethodId}),s}async stop(e){if(await super.stop(e),this.codexHomeDir)try{gx(this.codexHomeDir,{recursive:!0,force:!0})}catch{}}};var vt=class extends Ye{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}`}]}))}get acpSessionName(){return this.sessionName}};q();oe();function Fr(n){return n.replace(/[^A-Za-z0-9._-]+/g,"-")}var St=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}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 Tn=class{agentId;framework;workspace;deployType;accountId;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)}getSessionQueue(e){let s=this.sessionQueues.get(e);return s||(s=new St,this.sessionQueues.set(e,s)),s}allSessionQueues(){return this.sessionQueues.entries()}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)Wt(o),o.downstream&&(s.push(o.downstream.stop(e).catch(()=>{})),o.downstream=void 0);await Promise.all(s),this.activeTriggers.clear()}};function Wt(n){n.idleTimer&&(clearTimeout(n.idleTimer),n.idleTimer=void 0)}import{spawn as yx}from"node:child_process";import{homedir as bx}from"node:os";import{join as vx}from"node:path";an();q();async function Gs(){let n=vx(bx(),".openclaw/openclaw.json");return(await pt(n))?.gateway?.auth?.token??""}var Ks=R("openclaw.config"),Sx=[0,5e3,5e3],js="models.providers.",Dn="agents.defaults.models",Rn=class{command;env;retryDelaysMs;queue=new St;constructor(e){this.command=e.command,this.env=e.env??process.env,this.retryDelaysMs=e.retryDelaysMs??Sx}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(f=>setTimeout(f,x));try{return await s()}catch(f){o=f,Ks.warn("openclaw cli failed, will retry",{label:e,attempt:c+1,err:String(f)})}}throw new v("AGENT_SPAWN_FAILED",`openclaw cli ${e} failed after ${this.retryDelaysMs.length} attempts: ${o?.message??"unknown"}`)}runCli(e){return new Promise((s,o)=>{let c=yx(this.command,e,{stdio:["ignore","pipe","pipe"],env:this.env}),x="";c.stderr?.on("data",f=>{x+=f.toString("utf8")}),c.on("error",o),c.on("close",f=>{f===0?s():o(new Error(`exit ${f}: ${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){Ks.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",`${js}${e}`,JSON.stringify(s),"--strict-json","--merge"])))}removeProvider(e){return this.bestEffortUnset(`config unset models.providers.${e}`,`${js}${e}`)}addModelToAllowlist(e,s){let o={[e]:s?{alias:s}:{}};return this.queue.enqueue(()=>this.withRetry(`config set ${Dn}[${e}]`,()=>this.runCli(["config","set",Dn,JSON.stringify(o),"--strict-json","--merge"])))}removeModelFromAllowlist(e){return this.bestEffortUnset(`config unset ${Dn}[${e}]`,`${Dn}.${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 Re=R("agent-manager"),Cx=(n,e,s,o,c,x,f,u)=>{switch(n){case"claude-code":{let p={...c?{...ws(c),...bs(c,f)}:{},...u??{}};return new kn({cwd:s,...Object.keys(p).length>0?{env:p}:{}})}case"codex":{let p=c?[..._s(c),...Ss(c,f)]:[],m={...c?ys(c):{},...u??{}},b=!!c;return new Pn({cwd:s,...p.length>0?{extraArgs:p}:{},...Object.keys(m).length>0?{env:m}:{},...b?{authMethodId:"openai-api-key",isolateCodexHome:!0}:{}})}case"openclaw":return new vt({command:e,cwd:s,agentId:o,...x?{sessionName:Fr(x)}:{}})}};function Ws(n){return n==="claude-code"||n==="codex"}var Ax={path:"",version:"cloud-deployed"},Ix={protocolVersion:1,clientCapabilities:{fs:{readTextFile:!0,writeTextFile:!0}}},kx=6e4,Ln=class{paths;config;registry;factory;createTimeoutMs;openclawConfigCache;ensuredProviders=new Set;constructor(e){this.paths=e.paths,this.config=e.config,this.registry=e.registry,this.factory=e.downstreamFactory??Cx,this.createTimeoutMs=e.createTimeoutMs??kx}buildBinShimPathEnv(){let e=process.platform==="win32"?";":":";return{PATH:`${this.paths.binDir}${e}${process.env.PATH??""}`}}getOpenclawConfig(){if(!this.openclawConfigCache){let e=this.config.frameworksCache?.openclaw;if(!e?.path)throw new v("AGENT_SPAWN_FAILED","openclaw binary not detected on this machine");this.openclawConfigCache=new Rn({command:e.path})}return this.openclawConfigCache}async createAgent(e){if(!e.agentId)throw new v("IPC_BAD_REQUEST","agentId required");if(!e.framework)throw new v("IPC_BAD_REQUEST","framework required");let s=Bt(e._meta)==="cloud";this.registry.reviveIfDisconnected?.(e.agentId);let o=this.registry.get(e.agentId);if(o){if(o.framework!==e.framework)throw new v("AGENT_BUSY",`agent ${e.agentId} exists with different framework (${o.framework})`);if(o.status==="error")Re.warn("existing agent in error state, rebuilding",{agentId:e.agentId}),await o.dispose("rebuild after error").catch(k=>Re.warn("dispose stale agent failed (ignored)",{err:String(k)})),this.registry.unregister(e.agentId);else return Re.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 v("AGENT_SPAWN_FAILED",`framework ${e.framework} not detected on this machine; rerun daemon to refresh frameworks_cache`);s&&Ws(e.framework)&&await Ns(e.framework);let x=Ue(e.agentId,this.paths),f=Bt(e._meta),u=e.framework==="openclaw"&&f==="local",p=u?this.config.frameworksCache?.openclaw?.defaultAgent?.workspace:void 0,m=e.workspace??p??x.workspace,b=new AbortController,_=setTimeout(()=>b.abort(new v("AGENT_TIMEOUT",`_agent/create timed out after ${this.createTimeoutMs}ms`)),this.createTimeoutMs),E,T=!1;try{let k=()=>{if(b.signal.aborted)throw b.signal.reason instanceof Error?b.signal.reason:new v("AGENT_TIMEOUT","_agent/create aborted")};await Ur(x.root,{recursive:!0}),await Ur(m,{recursive:!0}),await Ur(x.logs,{recursive:!0}),k(),u||await mt(m,e.framework,e.agentId,e.cozeIdentity),k();let D=await pe(e.agentId,this.paths).catch(()=>null),F=ps({model:e.model??D?.model}),ie=cs(e._meta)??D?.accountId;if(E=new Tn({agentId:e.agentId,framework:e.framework,workspace:m,model:F.model??Te,deployType:f,...ie?{accountId:ie}:{}}),E.status="ok",D?.sessions){for(let[ae,ce]of Object.entries(D.sessions))E.sessions.set(ae,{acpSessionId:ce.acpSessionId,modelToken:ce.modelToken,tokenGeneratedAt:ce.tokenGeneratedAt,lastActiveAt:Date.now(),loadingSession:!1,replySeq:0});let te=Object.keys(D.sessions).length;te>0&&Re.info("restored persisted session records (no spawn)",{agentId:e.agentId,count:te})}this.registry.register(E),T=!0;let $={agentId:e.agentId,framework:e.framework,workspace:m,cozeIdentity:e.cozeIdentity,createdAt:D?.createdAt??Date.now(),sessions:D?.sessions??{},model:F.model};f==="cloud"&&($.deployType="cloud"),ie&&($.accountId=ie),D?.skills&&($.skills=D.skills),D?.agentName&&($.agentName=D.agentName),D?.description&&($.description=D.description),e.framework==="openclaw"&&f==="cloud"&&(this.config.frameworksCache?.openclaw?.path?await this.getOpenclawConfig().ensureAgent(e.agentId,m):Re.warn("openclaw binary not on this machine, skip agents add (will fail at session/prompt)",{agentId:e.agentId}));let we=e.initialSkills??[];if(we.length>0){let te=[...$.skills??[]],ae=new Map(te.map((A,N)=>[A.skillId,N])),ce=0;for(let A of we)try{let N=await Mr({agentId:e.agentId,workspace:m,framework:e.framework,skill:A});Br(te,ae,N),ce++}catch(N){Re.warn("initialSkill install failed (skipping)",{agentId:e.agentId,skillId:A.skillId,skillName:A.skillName,err:String(N)})}ce>0&&($.skills=te,Re.info("initialSkills installed",{agentId:e.agentId,installed:ce,requested:we.length}))}return await Ce($,this.paths),Re.info("agent created (no spawn, lazy on first prompt)",{agentId:e.agentId,framework:e.framework,deployType:f}),{ok:!0,agentId:e.agentId,workspace:m,framework:e.framework}}catch(k){throw Re.error("agent create failed, rolling back",{agentId:e.agentId,err:String(k)}),T&&E&&(await E.dispose("rollback").catch(()=>{}),this.registry.unregister(e.agentId)),await Ex(x.root,{recursive:!0,force:!0}).catch(D=>Re.warn("rm agent dir failed (ignored)",{err:String(D)})),k instanceof v?k:new v("AGENT_SPAWN_FAILED",String(k),{cause:k})}finally{clearTimeout(_)}}async spawnSessionDownstream(e,s,o,c){let f=this.config.frameworksCache?.[e.framework];if(!f)if(e.deployType==="cloud"&&Ws(e.framework))f=Ax;else throw new v("AGENT_SPAWN_FAILED",`framework ${e.framework} not detected on this machine`);let u=e.deployType==="cloud"?{model:e.model,modelToken:s}:void 0,p;e.framework==="openclaw"?p=await this.buildOpenclawDownstream({session:e,modelConfig:u,cloudSessionId:o,cozeEnv:c,command:f.path}):p=this.factory(e.framework,f.path,e.workspace,e.agentId,u,o,c,this.buildBinShimPathEnv());try{return await p.start(),await p.initialize(Ix),p}catch(m){throw await p.stop("spawnSessionDownstream failed").catch(()=>{}),m instanceof v?m:new v("AGENT_SPAWN_FAILED",m instanceof Error?m.message:String(m),{cause:m})}}async buildOpenclawDownstream(e){let{session:s,modelConfig:o,cloudSessionId:c,cozeEnv:x,command:f}=e,u=Fr(c);if(s.deployType==="local"){let _=this.config.frameworksCache?.openclaw?.defaultAgent;if(!_?.id||!_.workspace)throw new v("AGENT_SPAWN_FAILED","openclaw default agent \u672A\u63A2\u6D4B\u5230; \u8BF7\u5148\u8DD1 `openclaw setup` \u6216 `openclaw agents add` \u521B\u5EFA\u9ED8\u8BA4 agent");return new vt({command:f,cwd:_.workspace,agentId:_.id,sessionName:u})}let p=await Gs(),m=o?vs(o,x):null,b;if(m){let _=Nr(c),T=m.models[0]?.id??Te,k=`${_}/${T}`;if(!this.ensuredProviders.has(k)){let D=this.getOpenclawConfig();await D.ensureProvider(_,m),await D.addModelToAllowlist(k),this.ensuredProviders.add(k)}b=k}return new vt({command:f,cwd:s.workspace,agentId:s.agentId,sessionName:u,...p?{gatewayToken:p}:{},...b?{slashModelOnStart:b}:{}})}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=Nr(o),x=`${c}/${e.model}`;this.ensuredProviders.delete(x),await s.removeProvider(c),await s.removeModelFromAllowlist(x)}}};import{randomUUID as Fx}from"node:crypto";import{promises as Ux}from"node:fs";import{basename as qx}from"node:path";import{promises as Tx}from"node:fs";import{basename as Dx}from"node:path";q();var Js=R("file-upload"),Rx="/api/coze_claw/file/agent_upload",Lx=6e4;async function $s(n,e={}){let o=`${pn(wn(e.handshakeBase))}${Rx}`,c=e.timeoutMs??Lx,x=await Tx.readFile(n.path),f=new FormData;f.append("agent_id",n.agentId),f.append("session_id",n.sessionId),f.append("file_name",n.name),f.append("file_content",new Blob([x],{type:n.mimeType}),n.name);let u={Authorization:`Bearer ${n.patToken}`,Accept:"application/json","x-coze-version":"3.0",..._t(e.ppeOverride),...n.accountId?{"x-coze-account":n.accountId}:{}},p=new AbortController,m=setTimeout(()=>p.abort(),c);Js.info("file upload start",{url:o,agentId:n.agentId,sessionId:n.sessionId,name:n.name,bytes:n.sizeBytes,mime:n.mimeType});try{let b=await fetch(o,{method:"POST",headers:u,body:f,signal:p.signal}),_=b.headers.get("x-tt-logid")??"";if(!b.ok){let k=await b.text().catch(()=>"");throw new v("UPLOAD_FAILED",`upload HTTP ${b.status} logid=${_}: ${k.slice(0,200)}`)}let E=await b.json();if(E.code!==void 0&&E.code!==0)throw new v("UPLOAD_FAILED",`upload code=${E.code} msg=${E.msg??"-"} logid=${_}`);let T=E.data?.file?.file_url;if(!T)throw new v("UPLOAD_FAILED",`upload response missing data.file.file_url logid=${_}: ${JSON.stringify(E).slice(0,200)}`);return Js.info("file upload ok",{uri:T,logid:_}),{uri:T}}catch(b){throw b instanceof v?b:b.name==="AbortError"?new v("UPLOAD_FAILED",`upload timeout (${c}ms) for ${Dx(n.path)}`):new v("UPLOAD_FAILED",String(b),{cause:b})}finally{clearTimeout(m)}}q();import{promises as Nx}from"node:fs";import{extname as Ox}from"node:path";var Mx=[{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 Bx(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 zx={".txt":"text/plain",".md":"text/markdown"};async function Vs(n){let e=await Nx.open(n,"r");try{let s=Buffer.alloc(16);if(await e.read(s,0,16,0),Bx(s))return"image/webp";for(let o of Mx)if(o.prefix.every((c,x)=>s[x]===c))return o.mime}finally{await e.close()}return zx[Ox(n).toLowerCase()]??"application/octet-stream"}oe();var Hx=R("agent-send"),Xs=50*1024*1024,Kx=new Set(["image/png","image/jpeg","image/webp","image/gif","application/pdf","text/plain","text/markdown"]);async function Ys(n,e){let s=e.core.get(n.agentId);if(!s)throw new v("AGENT_NOT_FOUND",`agent=${n.agentId}`);if(e.core.disconnectedAgents.has(n.agentId))throw new v("AGENT_DISCONNECTED",`agent=${n.agentId} was disconnected by cloud`);let o=s.sessions.get(n.sessionId);if(!o)throw new v("AGENT_NOT_FOUND",`session=${n.sessionId} not active in agent=${n.agentId}`);if(!await os(n.path,s.workspace))throw new v("PATH_OUTSIDE_WORKSPACE",`path=${n.path} not under workspace=${s.workspace}`);let c=await Ux.stat(n.path).catch(()=>null);if(!c||!c.isFile())throw new v("IPC_BAD_REQUEST",`path is not a regular file: ${n.path}`);if(c.size>Xs)throw new v("FILE_TOO_LARGE",`${c.size} bytes > limit ${Xs}`);let x=await Vs(n.path);if(!Kx.has(x))throw new v("UNSUPPORTED_MIME",`mime=${x} not in whitelist`);if(n.kind==="image"&&!x.startsWith("image/"))throw new v("UNSUPPORTED_MIME",`kind=image but mime=${x}`);if(!e.core.upstream.isConnected())throw new v("UPSTREAM_NOT_READY","cloud WS not connected");let f=n.name??qx(n.path),u=await $s({patToken:e.patToken,agentId:n.agentId,sessionId:n.sessionId,path:n.path,mimeType:x,name:f,sizeBytes:c.size,...s.accountId?{accountId:s.accountId}:{}},{handshakeBase:e.handshakeBase,ppeOverride:e.ppeOverride}),p={sessionUpdate:"agent_file",messageId:Fx(),content:{type:n.kind==="image"?"image":"resource",uri:u.uri,mimeType:x,name:f,sizeBytes:c.size,...u.fileId!==void 0?{fileId:u.fileId}:{},...n.caption!==void 0?{caption:n.caption}:{}}};return await e.core.sendAgentFileUpdate(s,o,n.sessionId,p),Hx.info("agent file sent",{agentId:n.agentId,sessionId:n.sessionId,kind:n.kind,name:f,bytes:c.size,mime:x,uri:u.uri}),{ok:!0,uri:u.uri,bytes:c.size,mimeType:x,...u.fileId!==void 0?{fileId:u.fileId}:{}}}q();import{execFile as jx}from"node:child_process";import{promisify as Gx}from"node:util";var Wx=Gx(jx),Ze=R("coze-cli-installer"),Zs="@coze/cli@0.1.3-alpha.89c42a",Qs="https://bnpm.byted.org",Jx="coze",$x=5e3,Vx=9e4,eo=1e4,Jt=null,qr=!1;async function Hr(n,e={}){if(qr)return;if(Jt)return Jt;let s=e.exec??Wx;return Jt=(async()=>{try{let o=await Xx(Jx,s);if(o){Ze.info("coze-cli already on PATH, skip install + config + auth",{path:o}),qr=!0;return}Ze.info("coze-cli install start",{package:Zs,registry:Qs});try{await s("npm",["i","-g",Zs,"--registry",Qs],{timeout:Vx,maxBuffer:10*1024*1024}),Ze.info("coze-cli install ok")}catch(c){Ze.warn("coze-cli install failed (skip subsequent steps)",{err:String(c)});return}if(n.env)try{await s("coze",["config","set","xTTEnv",n.env],{timeout:eo}),Ze.info("coze config set xTTEnv ok",{env:n.env})}catch(c){Ze.warn("coze config set failed (continue to auth login)",{err:String(c)})}try{await s("coze",["auth","login","--token",n.patToken],{timeout:eo}),Ze.info("coze auth login ok")}catch(c){Ze.warn("coze auth login failed",{err:String(c)});return}qr=!0}finally{Jt=null}})(),Jt}async function Xx(n,e){let s=process.platform==="win32"?"where":"which";try{let{stdout:o}=await e(s,[n],{timeout:$x});return o.split(`
119
+ `)[0]?.trim()||void 0}catch{return}}q();import{spawn as Yx}from"node:child_process";import{constants as to,access as Zx}from"node:fs/promises";import{delimiter as Qx,join as ed}from"node:path";var no=R("framework-detector"),ro={"claude-code":"claude",codex:"codex",openclaw:"openclaw"},td=[".exe",".cmd",".bat",".ps1"],Et=class{env;constructor(e={}){this.env={pathEnv:e.pathEnv??process.env.PATH??"",platform:e.platform??process.platform,spawn:e.spawn??Yx,access:e.access??Zx}}async detect(e){let s=ro[e],o=await this.which(s);if(!o)return no.debug("framework binary not found",{framework:e,bin:s}),null;let[c,x]=await Promise.all([this.probeVersion(o),e==="openclaw"?this.probeOpenclawDefaultAgent(o):Promise.resolve(null)]),f={path:o,version:c};return x&&(f.defaultAgent=x),f}async detectAll(){let e=await Promise.all(Object.keys(ro).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(Qx).filter(Boolean),o=this.env.platform==="win32"?["",...td]:[""];for(let c of s)for(let x of o){let f=ed(c,e+x);if(await this.isExecutable(f))return f}return null}async isExecutable(e){try{let s=this.env.platform==="win32"?to.F_OK:to.X_OK;return await this.env.access(e,s),!0}catch{return!1}}async probeOpenclawDefaultAgent(e){let s=await this.runProbe(e,["agents","list","--json"]);if(!s||s.code!==0)return null;try{let o=JSON.parse(s.stdout);if(!Array.isArray(o))return null;let c=o.find(x=>x?.isDefault===!0);return!c?.id||!c.workspace?null:{id:c.id,workspace:c.workspace}}catch(o){return no.warn("openclaw agents list --json parse failed",{err:String(o)}),null}}async probeVersion(e){let s=await this.runProbe(e,["--version"]);return s&&(rd(s.stdout).split(/\r?\n/)[0]??"").trim()||"unknown"}runProbe(e,s){return new Promise(o=>{let c="",x=!1,f,u=p=>{x||(x=!0,f&&clearTimeout(f),o(p))};try{let p=this.env.spawn(e,s,{stdio:["ignore","pipe","pipe"]});f=setTimeout(()=>{p.kill("SIGKILL"),u(null)},5e3),p.stdout?.on("data",m=>{c+=m.toString("utf8")}),p.on("error",()=>u(null)),p.on("close",m=>u({code:m,stdout:c}))}catch{u(null)}})}},nd=new RegExp("\x1B\\[[0-9;]*[A-Za-z]","g");function rd(n){return n.replace(nd,"")}an();oe();var id=10*6e4;function io(n){let e=n?.sessionIdleTimeoutMs;return typeof e!="number"||!Number.isFinite(e)||e<=0?id:e}function Nn(n){return pt(n??U().configFile)}function Ct(n,e){return on(e??U().configFile,n)}import{randomBytes as md}from"node:crypto";import{mkdir as sd,readFile as od,realpath as ad,writeFile as cd}from"node:fs/promises";import{basename as xd,dirname as Kr,join as dd,relative as fd,resolve as so,sep as ud}from"node:path";q();var ao=R("fs-rpc");async function co(n,e){let s=await fo(n.path,e);return await sd(Kr(s),{recursive:!0}),await cd(s,n.content,"utf8"),ao.info("fs/write_text_file ok",{path:s,size:n.content.length}),null}async function xo(n,e){let s=await fo(n.path,e),o=await od(s,"utf8"),c=o;if(typeof n.line=="number"||typeof n.limit=="number"){let x=o.split(`
120
+ `),f=Math.max(0,(n.line??1)-1),u=typeof n.limit=="number"?f+n.limit:void 0;c=x.slice(f,u).join(`
121
+ `)}return ao.info("fs/read_text_file ok",{path:s,size:c.length}),{content:c}}async function fo(n,e){if(typeof n!="string"||n.length===0)throw new v("IPC_BAD_REQUEST","path must be a non-empty string");let[s,o]=await Promise.all([oo(so(e)),oo(so(n))]),c=fd(s,o);if(c.startsWith("..")||c===".."||c.startsWith(`..${ud}`))throw new v("IPC_BAD_REQUEST",`path escapes workspace: ${n}`);return o}async function oo(n){let e=[],s=n;for(;s!==Kr(s);)try{let o=await ad(s);return e.length?dd(o,...e.reverse()):o}catch{e.push(xd(s)),s=Kr(s)}return n}q();var uo=R("prompt-multimodal"),lo=10*1024*1024,ld=15e3;async function ho(n){return Promise.all(n.map(hd))}async function hd(n){if(n.type!=="image")return n;let e=n;if(e.data||!e.uri||!gn(e.uri))return n;try{let{buf:s,contentType:o}=await pd(e.uri),c=e.mimeType||gd(o)||"application/octet-stream";return uo.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 uo.warn("image fetch failed, degrading to text block",{uri:e.uri,err:String(s)}),{type:"text",text:`[image load failed: ${e.uri}]`}}}function gd(n){if(!n)return;let e=n.indexOf(";");return(e===-1?n:n.slice(0,e)).trim()||void 0}async function pd(n){let e=new AbortController,s=setTimeout(()=>e.abort(),ld);try{let o=await fetch(n,{signal:e.signal});if(!o.ok)throw new Error(`HTTP ${o.status} ${o.statusText}`);let c=await o.arrayBuffer();if(c.byteLength>lo)throw new Error(`image too large: ${c.byteLength} bytes (max ${lo})`);return{buf:Buffer.from(c),contentType:o.headers.get("content-type")??void 0}}finally{clearTimeout(s)}}Xe();q();var H=R("core"),wd=3e4,_d=3e4,On=class{upstream;agents=new Map;disconnectedAgents=new Set;extensions;paths;sessionSpawner;sessionIdleTimeoutMs;upstreamIds=new bt;pendingUpstream=new Map;pendingBridge=new Map;currentCozeEnv;constructor(e){this.upstream=e.upstream,this.extensions=e.extensions??{},this.paths=e.paths,this.sessionSpawner=e.sessionSpawner,this.sessionIdleTimeoutMs=io(e.bridgeConfig)}registerExtension(e,s){this.extensions[e]=s}getCozeEnv(){return this.currentCozeEnv}async start(){this.upstream.onFrame(e=>this.handleFrame(e)),await this.upstream.start(),H.info("Core started",{extensions:Object.keys(this.extensions)})}async stop(e){H.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),H.info("agent registered",{agentId:e.agentId,framework:e.framework});for(let s of this.registerHandlers)try{s(e.agentId)}catch(o){H.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)&&H.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,f)=>{H.info("session runtime exited",{agentId:e.agentId,cloudId:s,code:x,signal:f}),Wt(o),o.downstream=void 0,o.acpSessionId&&e.activeTriggers.delete(o.acpSessionId)}))}async handleFrame(e){if(An(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&&(this.currentCozeEnv=o);try{if(e.method.startsWith("_agent/")){let c=this.extensions[e.method];if(!c){s!==null?await this.sendError(s,j.METHOD_NOT_FOUND,`extension not registered: ${e.method}`):H.warn("drop notification: extension not registered",{method:e.method});return}let x=await c(e,this);s!==null&&await this.upstream.send(yt(s,x));return}if(e.method.startsWith("session/")){let c=await this.routeSessionMethod(e);s!==null&&await this.upstream.send(yt(s,c));return}if(e.method==="initialize"){s!==null&&await this.upstream.send(yt(s,{protocolVersion:1,agentCapabilities:{loadSession:!0}}));return}s!==null?await this.sendError(s,j.METHOD_NOT_FOUND,`method not implemented: ${e.method}`):H.warn("drop unknown notification",{method:e.method})}catch(c){H.error("handleFrame failed",{method:e.method,err:String(c)}),s!==null&&await this.upstream.send(st(s,Gt(c)))}}async routeSessionMethod(e){if(!e.params||typeof e.params!="object")throw new v("IPC_BAD_REQUEST",`${e.method} requires params`);let s=e.params,o=s._meta?.cozeAgentId;if(!o)throw new v("IPC_BAD_REQUEST",`${e.method}: missing _meta.cozeAgentId`);let c=this.agents.get(o);if(!c)throw this.disconnectedAgents.has(o)?new v("AGENT_DISCONNECTED",`agent ${o} has been disconnected; cloud must _agent/create to revive`):new v("AGENT_NOT_FOUND",`agent not found: ${o}`);let x=typeof 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 f=Date.now(),u=!1;try{let p=await c.getSessionQueue(x).enqueue(()=>this.dispatchSessionCall(c,e.method,s));return u=!0,p}finally{H.info("session call done",{agentId:c.agentId,method:e.method,durationMs:Date.now()-f,ok:u})}}async dispatchSessionCall(e,s,o){e.lastActiveAt=Date.now();let{stripped:c}=xs(o);switch(s){case"session/new":{let x=yd();return H.info("session/new ack (lazy spawn)",{agentId:e.agentId,cloudId:x}),{sessionId:x}}case"session/load":{let x=c;return H.info("session/load ack (lazy spawn)",{agentId:e.agentId,cloudId:x.sessionId}),{}}case"session/prompt":{let x=c,f=x.sessionId;if(!f)throw new v("IPC_BAD_REQUEST","session/prompt: missing sessionId");let u=await this.ensureRuntime(e,f);if(u.replySeq=0,await this.ensureDownstream(e,f,u),!u.downstream||!u.acpSessionId)throw new v("BRIDGE_INTERNAL","session runtime not ready after ensureDownstream");let p=o._meta?.cozeTriggerMsgId;p?e.activeTriggers.set(u.acpSessionId,p):e.activeTriggers.delete(u.acpSessionId);let m=await ho(x.prompt);try{let b=await u.downstream.sessionPrompt({...x,sessionId:u.acpSessionId,prompt:m});return u.lastActiveAt=Date.now(),b}finally{e.activeTriggers.delete(u.acpSessionId),u.downstream?.isAlive()&&this.armIdleTimer(e,f,u)}}case"session/cancel":{let f=c.sessionId;if(!f)throw new v("IPC_BAD_REQUEST","session/cancel: missing sessionId");let u=e.sessions.get(f);return u?.downstream?.isAlive()&&u.acpSessionId&&await u.downstream.sessionCancel({sessionId:u.acpSessionId}),{ok:!0}}default:throw new v("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(Pe.GEN_MODEL_TOKEN,o,_d);if(!c?.modelToken)throw new v("MODEL_TOKEN_GEN_FAILED",`cloud returned empty modelToken (agentId=${e}, cloudSessionId=${s})`);return c.modelToken}catch(c){throw c instanceof v&&c.code==="MODEL_TOKEN_GEN_FAILED"?c:new v("MODEL_TOKEN_GEN_FAILED",c instanceof Error?c.message:String(c),{cause:c})}}async ensureDownstream(e,s,o){if(Wt(o),o.downstream?.isAlive())return;if(!this.sessionSpawner)throw new v("AGENT_SPAWN_FAILED","sessionSpawner not wired (cannot spawn per-session downstream)");let c=await this.sessionSpawner(e,o.modelToken,s,this.currentCozeEnv);if(o.downstream=c,this.attachRuntimeHooks(e,s,o),o.acpSessionId){o.loadingSession=!0;try{await c.sessionLoad({sessionId:o.acpSessionId,cwd:e.workspace}),H.info("session restored via session/load",{agentId:e.agentId,cloudId:s,acpId:o.acpSessionId})}catch(x){H.warn("session/load failed, fallback to session/new",{agentId:e.agentId,cloudId:s,acpId:o.acpSessionId,err:String(x)}),o.acpSessionId=void 0;let f=await c.sessionNew({cwd:e.workspace});o.acpSessionId=f.sessionId,await this.persistSessionMapping(e)}finally{o.loadingSession=!1}}else{let x=await c.sessionNew({cwd:e.workspace});o.acpSessionId=x.sessionId,await this.persistSessionMapping(e)}c.afterSessionEstablished&&o.acpSessionId&&await c.afterSessionEstablished(o.acpSessionId)}armIdleTimer(e,s,o){if(Wt(o),this.isRuntimeBusy(e,o)){H.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)){H.info("idle reaper fired but runtime busy, re-arming",{agentId:e.agentId,cloudId:s}),this.armIdleTimer(e,s,o);return}H.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=>H.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 f=e.activeTriggers.get(s.acpSessionId);f&&(x.cozeTriggerMsgId=f)}await this.upstream.send(jt("session/update",{sessionId:o,update:c,_meta:x}))}forwardUpdate(e,s){let o=s.sessionId,c=this.reverseSessionId(e,o);if(!c){H.debug("drop update for unknown session",{agentId:e.agentId,acpId:o});return}let x=e.sessions.get(c);if(!x){H.debug("drop update: runtime gone",{agentId:e.agentId,cloudId:c});return}if(bd(s)){H.debug("drop codex metadata-warn chunk",{agentId:e.agentId,acpId:o});return}let f={cozeAgentId:e.agentId,cozeReplySeqID:++x.replySeq},u=e.activeTriggers.get(o);u&&(f.cozeTriggerMsgId=u),this.upstream.send(jt("session/update",{...s,sessionId:c,_meta:f})).catch(p=>H.warn("forward update failed",{agentId:e.agentId,err:String(p)}))}handleAgentRequest(e,s,o){if(o.method==="session/request_permission"){this.forwardPermissionRequest(e,s,o);return}if(o.method==="fs/write_text_file"||o.method==="fs/read_text_file"){this.handleFsRpcRequest(e,s,o);return}H.warn("unhandled agent request,returning method_not_found",{agentId:e.agentId,method:o.method}),s.respondAgentRequestError(o.id,{code:j.METHOD_NOT_FOUND,message:`method not handled by Bridge: ${o.method}`})}async handleFsRpcRequest(e,s,o){try{let c=e.workspace;if(o.method==="fs/write_text_file"){let x=o.params??{},f=await co(x,c);s.respondAgentRequest(o.id,f)}else{let x=o.params??{},f=await xo(x,c);s.respondAgentRequest(o.id,f)}}catch(c){H.warn("fs rpc handler failed",{agentId:e.agentId,method:o.method,err:String(c)}),s.respondAgentRequestError(o.id,Gt(c))}}forwardPermissionRequest(e,s,o){let c=this.upstreamIds.next("session/request_permission"),x=o.params??{},u=x.sessionId,p=u?e.activeTriggers.get(u):void 0,m={cozeAgentId:e.agentId};p&&(m.cozeTriggerMsgId=p);let b=u?this.reverseSessionId(e,u):void 0,_={...x,...b?{sessionId:b}:{},_meta:m};this.pendingUpstream.set(c,{agentRequestId:o.id,agentId:e.agentId,downstream:s,method:o.method}),H.info("forward permission_request \u2192 upstream",{agentId:e.agentId,upstreamId:c,acpSessionId:u,cloudSessionId:b,toolCallId:x.toolCall?.toolCallId,options:x.options?.map(E=>({optionId:E.optionId,kind:E.kind,name:E.name}))}),this.upstream.send(Kt(c,"session/request_permission",_)).catch(E=>{this.pendingUpstream.delete(c),H.error("forward permission request failed",{agentId:e.agentId,err:String(E)}),s.respondAgentRequestError(o.id,{code:j.INTERNAL_ERROR,message:`upstream send failed: ${String(E)}`})})}handleUpstreamResponse(e){if(e.id===null)return;let s=this.pendingUpstream.get(e.id);if(s){this.pendingUpstream.delete(e.id),e.error?(H.info("upstream \u2192 permission response (error)",{agentId:s.agentId,upstreamId:e.id,method:s.method,error:e.error}),s.downstream.respondAgentRequestError(s.agentRequestId,e.error)):(H.info("upstream \u2192 permission response (result)",{agentId:s.agentId,upstreamId:e.id,method:s.method,result:e.result}),s.downstream.respondAgentRequest(s.agentRequestId,e.result));return}let o=this.pendingBridge.get(e.id);if(o){this.pendingBridge.delete(e.id),clearTimeout(o.timer),e.error?o.reject(new Cn(e.error)):o.resolve(e.result);return}H.debug("orphan upstream response (no pending)",{id:e.id})}sendRequest(e,s,o=wd){let c=this.upstreamIds.next(e);return new Promise((x,f)=>{let u=setTimeout(()=>{this.pendingBridge.delete(c),f(new v("AGENT_TIMEOUT",`${e} timed out after ${o}ms`))},o);this.pendingBridge.set(c,{method:e,resolve:x,reject:f,timer:u}),this.upstream.send(Kt(c,e,s)).catch(p=>{let m=this.pendingBridge.get(c);m&&(clearTimeout(m.timer),this.pendingBridge.delete(c)),f(p)})})}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 Tr(e.agentId,s,this.paths)}catch(s){H.warn("persist session mapping failed",{agentId:e.agentId,err:String(s)})}}reverseSessionId(e,s){for(let[o,c]of e.sessions.entries())if(c.acpSessionId===s)return o}sendError(e,s,o){return this.upstream.send(st(e,{code:s,message:o}))}};function yd(){return md(16).toString("hex")}function bd(n){let e=n.update;if(e?.sessionUpdate!=="agent_message_chunk")return!1;let s=e.content;if(!s||typeof s!="object")return!1;let o=s;return o.type!=="text"||typeof o.text!="string"?!1:o.text.startsWith("Model metadata for `")}q();oe();import{randomBytes as vd}from"node:crypto";import{chmod as Sd,mkdir as Ed,writeFile as go}from"node:fs/promises";import{createServer as Cd}from"node:http";import{dirname as Ad}from"node:path";var Id=1e6,jr=R("ipc"),Mn=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??U()}async start(){this.token=vd(32).toString("hex");let e=Cd((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(),jr.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 Ed(Ad(this.paths.portFile),{recursive:!0}),await go(this.paths.portFile,String(this.port),"utf8"),await go(this.paths.tokenFile,this.token,{encoding:"utf8",mode:384});try{await Sd(this.paths.tokenFile,384)}catch(e){jr.warn("chmod token file failed (non-POSIX?)",{err:String(e)})}}async dispatch(e,s){if(e.headers.authorization!==`Bearer ${this.token}`){$t(s,401,{error:"unauthorized"});return}let c=`${e.method} ${(e.url??"").split("?")[0]}`,x=this.routes.get(c);if(!x){$t(s,404,{error:"not found"});return}let f=null;if(e.method==="POST")try{f=await kd(e)}catch(u){$t(s,400,{error:"invalid json",detail:String(u)});return}try{let u=await x.handler(f,e);$t(s,200,u??{ok:!0})}catch(u){jr.error("IPC handler failed",{key:c,err:String(u)}),$t(s,500,{error:u instanceof Error?u.message:String(u)})}}};function $t(n,e,s){n.statusCode=e,n.setHeader("content-type","application/json"),n.end(JSON.stringify(s))}async function kd(n){let e=[],s=0;for await(let c of n){let x=c;if(s+=x.length,s>Id)throw new Error("body too large");e.push(x)}let o=Buffer.concat(e).toString("utf8");return o?JSON.parse(o):null}var Ba=Fe(Ao(),1);var xu=Fe(ba(),1),du=Fe(Zn(),1),fu=Fe(kt(),1),uu=Fe(ri(),1),lu=Fe(oi(),1),hu=Fe(ui(),1),Ta=Fe(nr(),1),gu=Fe(Pa(),1);var Da=Ta.default;q();var de=R("upstream.frontier"),La="application/json",Na="none",rn=class{constructor(e){this.opts=e}opts;fws=null;handler=null;connectHandler=null;opened=!1;openCount=0;async start(){if(this.fws){de.warn("start called on already-started FrontierUpstream; noop");return}let e={Authorization:`Bearer ${this.opts.privatecode}`,Origin:us,..._t(this.opts.ppeOverride)};class s extends Da{constructor(u){super(u,fs,{headers:e})}send(u,...p){if(rs("debug"))try{let m;typeof u=="string"?m=Buffer.from(u,"utf8"):u instanceof Buffer?m=u:u instanceof ArrayBuffer?m=new Uint8Array(u):ArrayBuffer.isView(u)?m=new Uint8Array(u.buffer,u.byteOffset,u.byteLength):m=new Uint8Array(0);let b=Buffer.from(m.slice(0,128)).toString("hex");de.debug("WS raw frame out",{bytes:m.byteLength,headHex:b})}catch(m){de.warn("WS raw frame dump failed",{err:String(m)})}super.send(u,...p)}}let o=hs(this.opts.urlOverride),c={url:o,ws:s,fpID:ds,aID:mn,accessKey:this.opts.handshake.accessKey,deviceID:this.opts.handshake.deviceId,payloadType:{type:La,force:!0},payloadEncoding:{encoding:Na,force:!0},enableTransformTextPayload:!0,enableQoS:!1,enableAutoAck:!1,automaticOpen:!1,debug:this.opts.debug??!1},x=new Ba.FWS(c);x.onopen=()=>{this.opened=!0,this.openCount+=1;let f=this.openCount===1;de.info("frontier opened",{url:o,remoteDeviceId:this.opts.handshake.deviceId,initial:f,openCount:this.openCount}),this.connectHandler&&Promise.resolve(this.connectHandler({initial:f})).catch(u=>de.warn("onConnect handler threw (ignored)",{err:String(u)}))},x.onclose=f=>{this.opened=!1,de.info("frontier closed",{code:f.code,reason:f.reason,willReconnect:f.willReconnect})},x.onerror=f=>{de.warn("frontier error",{code:f.code,msg:f.message})},x.onmessage=f=>this.handleMessage(f),this.fws=x,await x.connect()}async stop(e){let s=this.fws;if(s){this.fws=null,this.opened=!1;try{s.close(1e3,e??"bridge shutdown")}catch(o){de.warn("frontier close threw (ignored)",{err:String(o)})}}}async send(e){let s=this.fws;if(!s)throw new v("UPSTREAM_DISCONNECTED","frontier upstream not started");let o=JSON.stringify(e),c=e;Oa(c)||de.info("frontier frame out",{method:c.method,jsonrpcId:c.id,size:o.length});try{await s.send(o,{service:33555712,method:1,payloadType:La,payloadEncoding:Na})}catch(f){throw de.warn("frontier frame send failed",{method:c.method,jsonrpcId:c.id,err:String(f)}),new v("UPSTREAM_DISCONNECTED",`frontier send failed: ${String(f)}`,{cause:f})}}onFrame(e){this.handler=e}onConnect(e){this.connectHandler=e}isConnected(){return this.opened&&this.fws?.readyState===1}handleMessage(e){let s=e.message?.service;if(s!==33555712){de.debug("drop non-adapter frontier frame",{service:s});return}let o=_u(e);if(!o){de.debug("frontier message without text payload, drop",{payloadType:e.message?.payloadType});return}if(!this.handler){de.debug("frame received but no onFrame handler",{size:o.length});return}let c;try{c=JSON.parse(o)}catch(f){de.warn("frontier message JSON parse failed",{err:String(f),head:o.slice(0,80)});return}let x=c;Oa(x)||de.info("frontier frame in",{logid:wu(e.message?.LogID),logidNew:e.message?.LogIDNew,msgId:e.message?.msgID,jsonrpcId:x.id,method:x.method,body:mu(o)}),Promise.resolve(this.handler(c)).catch(f=>de.warn("frontier frame handler threw",{err:String(f)}))}};function Oa(n){return n.method==="_agent/health"?!0:typeof n.id=="string"&&n.id.startsWith("agent.health_")}var Ma=2e3;function mu(n){return n.length<=Ma?n:`${n.slice(0,Ma)}...<truncated, total ${n.length} chars>`}function wu(n){return n?n.high===0?String(n.low>>>0):`${n.high.toString(16)}${(n.low>>>0).toString(16).padStart(8,"0")}`:""}function _u(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 hi=R("upstream.switchable"),ir=class{inner;handler=null;connectHandler=null;constructor(e){this.inner=e}async swap(e,s){if(this.inner===e)return;hi.info("swap upstream",{reason:s});let o=this.inner;this.inner=e,this.handler&&e.onFrame(this.handler),this.connectHandler&&e.onConnect&&e.onConnect(this.connectHandler);try{await e.start()}catch(c){throw hi.error("swap target start failed, reverting",{err:String(c)}),this.inner=o,c}await o.stop(s??"swapped").catch(c=>hi.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.connectHandler=e,this.inner.onConnect?.(e)}isConnected(){return this.inner.isConnected()}};q();var gi=R("upstream"),Nt=class{handler=null;async start(){gi.info("NoopUpstream started (M1 skeleton; real Frontier wired in M4)")}async stop(e){gi.info("NoopUpstream stopped",{reason:e})}async send(e){gi.debug("NoopUpstream.send (dropped)",{method:"method"in e?e.method:void 0})}onFrame(e){this.handler=e}isConnected(){return!1}async injectFrame(e){this.handler&&await this.handler(e)}};q();q();oe();import{promises as pi}from"node:fs";import{dirname as yu}from"node:path";var bu=R("pat-token-store");async function za(n=U()){try{let s=(await pi.readFile(n.patTokenFile,"utf8")).trim();return s.length>0?s:null}catch(e){return e?.code!=="ENOENT"&&bu.warn("read pat-token failed (treating as missing)",{err:String(e)}),null}}async function sn(n,e=U()){if(!n)throw new Error("writePatToken: empty patToken");await pi.mkdir(yu(e.patTokenFile),{recursive:!0}),await pi.writeFile(e.patTokenFile,n,{encoding:"utf8",mode:384})}oe();oe();import{promises as sr}from"node:fs";import{join as vu}from"node:path";function Su(n){return`#!/bin/sh
121
122
  exec node ${JSON.stringify(n)} "$@"
122
- `}function Ef(n){return`@echo off
123
+ `}function Eu(n){return`@echo off
123
124
  node ${JSON.stringify(n)} %*
124
- `}async function Fa(n,e=F()){let s=e.binDir;await sr.mkdir(s,{recursive:!0});let o=bf(s,process.platform==="win32"?"coze-bridge.cmd":"coze-bridge"),c=process.platform==="win32"?Ef(n):Sf(n);return await sr.readFile(o,"utf8").catch(()=>null)===c||(await sr.writeFile(o,c,"utf8"),process.platform!=="win32"&&await sr.chmod(o,493)),s}U();ie();import{execSync as qa}from"node:child_process";import{readFileSync as Ha,unlinkSync as Af}from"node:fs";import{mkdir as Cf,readFile as Ka,unlink as Ga,writeFile as If}from"node:fs/promises";import{dirname as Pf}from"node:path";function Ua(n){try{return process.kill(n,0),!0}catch(e){return e.code==="EPERM"}}var kf=D("single-instance"),or=class{pidFile;acquired=!1;constructor(e={}){this.pidFile=e.pidFile??F().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&&(kf.warn("removing stale pid file",{stalePid:e}),await Ga(this.pidFile).catch(()=>{})),await Cf(Pf(this.pidFile),{recursive:!0}),await If(this.pidFile,String(process.pid),"utf8"),this.acquired=!0,this.installCleanupHooks(),{kind:"acquired"})}async release(){if(this.acquired){try{(await Ka(this.pidFile,"utf8")).trim()===String(process.pid)&&await Ga(this.pidFile)}catch{}this.acquired=!1}}async readExistingPid(){try{let e=await Ka(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 Ua(e)?this.matchesDaemonTitle(e):!1}matchesDaemonTitle(e){if(process.platform==="win32")return this.matchesDaemonTitleWindows(e);try{let s=Ha(`/proc/${e}/cmdline`,"utf8").replace(/\0/g," ");return!!(s.includes("coze-bridge-daemon")||s.includes("lib/index.js"))}catch{}try{let s=qa(`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=qa(`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{Ha(this.pidFile,"utf8").trim()===String(process.pid)&&Af(this.pidFile)}catch{}})}};var M=D("daemon"),Tf="coze-bridge-daemon";async function ja(){let n=new or({processTitle:Tf}),e=await n.acquire();if(e.kind==="already-running")throw new Error(`coze-bridge daemon already running (pid=${e.pid})`);let s=await Ln(),o=s??{};dn({pid:process.pid}),M.info(s?"loaded bridge config":"initialized bridge config");try{let k=new Et;o.frameworksCache=await k.detectAll(),M.info("refreshed frameworks_cache",{detected:Object.keys(o.frameworksCache)})}catch(k){M.warn("framework detection failed",{err:String(k)})}await At(o);let c=new ir(new Lt),d=F(),f=null,l=new On({upstream:c,paths:d,bridgeConfig:o,sessionSpawner:async(k,L,B,J)=>{if(!f)throw new Error("agentManager not ready");return f.spawnSessionDownstream(k,L,B,J)}});await Df(d,l);let m=new Nn({paths:d,config:o,registry:l});f=m;let w,v,_=null,E={},T,P=null;l.registerExtension("_agent/create",async k=>m.createAgent(k.params)),l.registerExtension("_agent/health",async()=>({ok:!0}));let R={},z=new _n({agents:l.agents,disposeAndMarkDisconnected:async(k,L)=>{let B=l.agents.get(k);B&&(await m.cleanupOpenclawSessionProviders(B).catch(J=>M.warn("cleanup openclaw providers failed (ignored)",{agentId:k,err:String(J)})),await B.dispose(`disconnect: ${L}`).catch(J=>M.warn("dispose during disconnect failed (ignored)",{agentId:k,err:String(J)})),B.status="disconnected",l.unregister(k)),l.disconnectedAgents.add(k)},detailSyncer:async k=>{if(!R.ref)throw new Error("agent-detail-sync not initialized yet");await R.ref.syncOne(k)},openclawRepair:async(k,L)=>{await m.openclawRepair(k,L)}});l.registerExtension("_agent/listSkills",k=>z.listSkills(k.params)),l.registerExtension("_agent/addSkills",k=>z.addSkills(k.params)),l.registerExtension("_agent/removeSkills",k=>z.removeSkills(k.params)),l.registerExtension("_agent/getFileTree",k=>z.getFileTree(k.params)),l.registerExtension("_agent/getFileContent",k=>z.getFileContent(k.params)),l.registerExtension("_agent/update",k=>z.updateAgent(k.params)),l.registerExtension("_agent/disconnect",k=>z.disconnectAgent(k.params)),l.registerExtension("_agent/switchModel",k=>z.switchModel(k.params)),l.registerExtension("_agent/reset",k=>z.resetAgent(k.params)),l.registerExtension("_agent/repair",k=>z.repairAgent(k.params));let ne=new gn({paths:d,handlers:z,sendDetail:k=>l.sendRequest("_agent/detail",k)});R.ref=ne,c.onConnect(({initial:k})=>{M.info("frontier upstream connected, triggering detail sync",{initial:k}),ne.syncAll(k?"initial-connect":"reconnect").catch(L=>M.warn("detail sync top-level error (ignored)",{err:String(L)}))});let j=new Bn({paths:d,routes:[{method:"GET",path:"/status",handler:async()=>({running:!0,pid:process.pid,agents:[...l.agents.keys()],deviceId:_??"",frameworksCache:o.frameworksCache??{}})},{method:"POST",path:"/pair",handler:async k=>{let L=k,B=L?.privatecode,J=L?.pairing_code;if(!B||!J)throw new S("IPC_BAD_REQUEST","/pair requires privatecode + pairing_code");let we=zt(L.env),Ie=L.handshake_url,Be=L.frontier_url,ue=Wa(L.env,Ie,Be),ge=!!w&&w!==B,nt=v!==void 0&&v!==ue,Q=ge||nt;if(Q){M.warn("pair config switched, resetting agents",{pcChanged:ge,envChanged:nt,previousPc:w?ar(w):"",nextPc:ar(B),previousEnvKey:v??"",nextEnvKey:ue});for(let ae of[...l.agents.values()])await ae.dispose("pair config switch").catch(()=>{}),l.agents.delete(ae.agentId);await c.swap(new Lt,"pair switch").catch(()=>{})}let rt=await Tr({privatecode:B,...Ie?{endpoint:Ie}:{},ppeOverride:we});_=rt.deviceId,dn({deviceId:_,pid:process.pid}),qr({patToken:B,env:L.env}).catch(ae=>M.warn("coze-cli setup error (ignored)",{err:String(ae)}));let G=new rn({handshake:rt,privatecode:B,...Be?{urlOverride:Be}:{},ppeOverride:we});await c.swap(G,"pair");try{let ae=new Et;o.frameworksCache=await ae.detectAll(),await At(o),M.info("frameworks_cache refreshed before pair",{detected:Object.keys(o.frameworksCache)})}catch(ae){M.warn("frameworks_cache refresh failed (ignored, using cached)",{err:String(ae)})}let Y=Object.keys(o.frameworksCache??{});try{let ae=await l.sendRequest("_agent/pair",{pairCode:J,patToken:B,frameworks:Y,_meta:{cozeDeviceId:_}});M.info("_agent/pair ok",{pairResult:ae}),w=B,v=ue,E=we,T=Ie,sn(B,d).catch(Se=>M.warn("writePatToken after /pair failed (ignored)",{err:String(Se)})),P||(P=new qt({core:l,getDeviceId:()=>_??""})),P.start(),Q&&pi(d,m).catch(Se=>M.warn("post-pair-switch auto-revive error (ignored)",{err:String(Se)}));let Me;return L.agent_id&&(Me=await Rf(L.agent_id,d,m,Se=>l.sendRequest("_agent/detail",Se)).catch(Se=>(M.error("--agent-id ensureAgent failed",{agentId:L.agent_id,err:String(Se)}),{ok:!1,agentId:L.agent_id??"",note:String(Se)}))),{ok:!0,note:"paired with cloud",...Me?{agent:Me}:{}}}catch(ae){return M.error("_agent/pair failed",{err:String(ae)}),{ok:!1,note:`pair failed: ${String(ae)}`}}}},{method:"POST",path:"/connect",handler:async k=>{let L=k,B=L?.privatecode;if(!B)throw new S("IPC_BAD_REQUEST","/connect requires privatecode");let J=zt(L.env),we=L.handshake_url,Ie=L.frontier_url,Be=Wa(L.env,we,Ie);if(w===B&&v===Be)return M.info("/connect: already connected with same PAT + env, noop"),{ok:!0,note:"already connected"};let ue=!!w&&w!==B,ge=v!==void 0&&v!==Be,nt=ue||ge;if(nt){M.warn("connect config switched, resetting agents",{pcChanged:ue,envChanged:ge,previousPc:w?ar(w):"",nextPc:ar(B)});for(let G of[...l.agents.values()])await G.dispose("connect config switch").catch(()=>{}),l.agents.delete(G.agentId);await c.swap(new Lt,"connect switch").catch(()=>{})}let Q=await Tr({privatecode:B,...we?{endpoint:we}:{},ppeOverride:J});_=Q.deviceId,dn({deviceId:_,pid:process.pid}),qr({patToken:B,env:L.env}).catch(G=>M.warn("coze-cli setup error (ignored)",{err:String(G)}));let rt=new rn({handshake:Q,privatecode:B,...Ie?{urlOverride:Ie}:{},ppeOverride:J});return await c.swap(rt,"connect"),w=B,v=Be,E=J,T=we,P||(P=new qt({core:l,getDeviceId:()=>_??""})),P.start(),nt&&pi(d,m).catch(G=>M.warn("post-connect-switch auto-revive error (ignored)",{err:String(G)})),sn(B,d).catch(G=>M.warn("writePatToken after /connect failed (ignored)",{err:String(G)})),M.info("/connect: WS established",{deviceId:_}),{ok:!0,note:"connected"}}},{method:"POST",path:"/_agent/create",handler:async k=>{let L=k;return{ok:!0,result:await m.createAgent(L)}}},{method:"POST",path:"/agent/send",handler:async k=>{let L=k;if(!L?.agentId||!L?.sessionId||!L?.kind||!L?.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 Xs(L,{core:l,patToken:w,handshakeBase:T,ppeOverride:E})}catch(B){if(B instanceof S)return{ok:!1,code:B.code,message:B.message};throw B}}},{method:"POST",path:"/refresh",handler:async()=>{M.info("IPC /refresh: re-detecting frameworks");let k=new Et;return o.frameworksCache=await k.detectAll(),await At(o),{ok:!0,frameworks:o.frameworksCache}}},{method:"POST",path:"/shutdown",handler:async()=>(M.info("IPC /shutdown received"),setImmediate(()=>{oe.shutdown("ipc /shutdown")}),{ok:!0})}]}),{port:me,token:Z}=await j.start();try{await Fa(d.libEntry,d)}catch(k){M.warn("bin shim install failed (D72 send \u547D\u4EE4\u53EF\u80FD\u4E0D\u53EF\u7528)",{err:String(k)})}await l.start(),pi(d,m).catch(k=>M.warn("auto-revive top-level error (ignored)",{err:String(k)}));let se=null,oe={port:me,token:Z,core:l,ipc:j,shutdown(k){return se||(M.info("daemon shutdown",{reason:k}),se=(async()=>{P?.stop(),await l.stop(k),await j.stop(),await n.release()})(),se)}};for(let k of["SIGTERM","SIGINT"])process.on(k,()=>{oe.shutdown(k).then(()=>process.exit(0))});return M.info("daemon ready",{port:me,pid:process.pid,nodeVersion:process.version,platform:process.platform,frameworks:Object.keys(o.frameworksCache??{}),libVersion:o.libVersion??"dev"}),oe}function ar(n){return n.length<=8?"***":`${n.slice(0,4)}***${n.slice(-4)}`}function Wa(n,e,s){return`${n??""}|${e??""}|${s??""}`}async function Df(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(()=>(Ye(),ln));for(let f of o){await d(f,n).catch(l=>M.warn("enforceAgentConfigMode failed (ignored)",{agentId:f,err:String(l)}));try{let l=await c(f,n);l?.disconnectedAt&&(e.disconnectedAgents.add(f),M.info("agent marked disconnected on startup",{agentId:f,disconnectedAt:l.disconnectedAt,reason:l.disconnectReason??""}))}catch(l){M.warn("failed to load agent config on startup, skipping",{agentId:f,err:String(l)})}}}async function Rf(n,e,s,o){let{loadAgentConfig:c}=await Promise.resolve().then(()=>(Ye(),ln)),d=await c(n,e);if(d){M.info("--agent-id: local config found, reconnecting",{agentId:n,framework:d.framework,hadDisconnect:!!d.disconnectedAt});let w={agentId:d.agentId,framework:d.framework,...d.cozeIdentity?{cozeIdentity:d.cozeIdentity}:{},...d.model?{model:d.model}:{}};return await s.createAgent(w),{ok:!0,agentId:n,note:d.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 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 l={agentId:f.agentId,framework:f.framework,...f.cozeIdentity?{cozeIdentity:f.cozeIdentity}:{},...f.model?{model:f.model}:{},...f.deployType?{_meta:{cozeDeployType:f.deployType}}:{}};await s.createAgent(l);let m=f.deployType==="cloud"&&f.framework==="openclaw";return{ok:!0,agentId:n,note:m?"cloud agent acknowledged":"created from cloud detail"}}async function pi(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(()=>(Ye(),ln));M.info("auto-revive: scanning local agents on startup",{count:o.length});let d=0,f=0;for(let l of o){let m;try{m=await c(l,n)}catch(w){M.warn("auto-revive: load config failed (skipping)",{agentId:l,err:String(w)}),f+=1;continue}if(!m){f+=1;continue}if(m.disconnectedAt){M.info("auto-revive: skip disconnected agent",{agentId:l,disconnectedAt:m.disconnectedAt}),f+=1;continue}try{M.info("auto-revive: re-registering agent (D44 no spawn)",{agentId:l,framework:m.framework});let w=Nf(m);await e.createAgent({agentId:m.agentId,framework:m.framework,...m.cozeIdentity?{cozeIdentity:m.cozeIdentity}:{},...m.model?{model:m.model}:{},...w?{_meta:w}:{}}),d+=1}catch(w){M.warn("auto-revive: createAgent failed (skipping)",{agentId:l,framework:m.framework,err:String(w)}),f+=1}}return M.info("auto-revive: done",{revived:d,skipped:f,total:o.length}),{revived:d,skipped:f,total:o.length}}function Nf(n){let e={};return n.deployType&&(e.cozeDeployType=n.deployType),n.accountId&&(e.cozeAccountId=n.accountId),Object.keys(e).length>0?e:void 0}_i();ie();import{readFile as Ja}from"node:fs/promises";var je=class{paths;constructor(e){this.paths=e??F()}async probe(e=1e3){let s=await cr(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:Hf(o)}}}async request(e){let s=await cr(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,f=setTimeout(()=>d.abort(),s.timeoutMs??5e3);try{let l=await fetch(`http://127.0.0.1:${e.port}${s.path}`,{method:s.method,headers:c,body:o?JSON.stringify(s.body):void 0,signal:d.signal}),m=await l.text();return{status:l.status,body:qf(m)}}finally{clearTimeout(f)}}};async function cr(n){try{let[e,s]=await Promise.all([Ja(n.portFile,"utf8"),Ja(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 qf(n){if(!n)return null;try{return JSON.parse(n)}catch{return n}}function Hf(n){return n instanceof Error?n.message:String(n)}U();ie();import{copyFile as Va,mkdir as Kf,readFile as yi,writeFile as Gf}from"node:fs/promises";import{dirname as Wf,resolve as vi,sep as xr}from"node:path";import{fileURLToPath as jf}from"node:url";U();ie();var $a=D("dist-install");function Jf(n){let e=jf(n),s=Wf(e),o=`${xr}src${xr}`;if(s.includes(o)||s.endsWith(`${xr}src${xr}cli`))return null;let c=vi(s,"index.js"),d=vi(s,"..","package.json");return{dist:c,pkgJson:d}}async function bi(n={}){let e=n.paths??F(),s=Jf(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 yi(c,"utf8")).version??"unknown"}catch(_){return $a.warn("cannot read source package.json,skip dist install",{err:String(_)}),{kind:"dev-mode-skip",reason:`package.json read failed: ${String(_)}`}}let f=await Ln(e.configFile)??{},l=f.libVersion;if(l===d)try{return await yi(e.libEntry),{kind:"already-current",libVersion:d}}catch{}await Kf(e.libDir,{recursive:!0}),await Va(o,e.libEntry),await Va(`${o}.map`,`${e.libEntry}.map`).catch(()=>{});let m=vi(e.libDir,"package.json"),w=`${JSON.stringify({type:"module"},null,2)}
125
- `;return await yi(m,"utf8").catch(()=>null)!==w&&await Gf(m,w),f.libVersion=d,await At(f,e.configFile),$a.info("dist installed",{libEntry:e.libEntry,fromVersion:l,toVersion:d}),l?{kind:"version-changed",fromVersion:l,toVersion:d,libEntry:e.libEntry}:{kind:"first-install",libVersion:d,libEntry:e.libEntry}}import{basename as Vf,resolve as $f}from"node:path";ie();var Yf=9e4,Xf={PATH_OUTSIDE_WORKSPACE:3,FILE_TOO_LARGE:3,UNSUPPORTED_MIME:3,IPC_BAD_REQUEST:3,AGENT_NOT_FOUND:4,IPC_AUTH_FAILED:4,AGENT_DISCONNECTED:5,UPLOAD_FAILED:5,UPSTREAM_NOT_READY:5,UPSTREAM_DISCONNECTED:5,UPSTREAM_HANDSHAKE_FAILED:5,AGENT_BUSY:1,AGENT_SPAWN_FAILED:1,AGENT_TIMEOUT:1,AGENT_PROTOCOL_ERROR:1,BRIDGE_CONFIG_INVALID:1,BRIDGE_INTERNAL:1,MODEL_TOKEN_GEN_FAILED:1,OPERATION_NOT_ALLOWED_FOR_LOCAL:1};function Zf(n){return Xf[n]??1}async function Ya(n,e={}){let s=e.paths??F();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>
125
+ `}async function Fa(n,e=U()){let s=e.binDir;await sr.mkdir(s,{recursive:!0});let o=vu(s,process.platform==="win32"?"coze-bridge.cmd":"coze-bridge"),c=process.platform==="win32"?Eu(n):Su(n);return await sr.readFile(o,"utf8").catch(()=>null)===c||(await sr.writeFile(o,c,"utf8"),process.platform!=="win32"&&await sr.chmod(o,493)),s}q();oe();import{execSync as qa}from"node:child_process";import{readFileSync as Ha,unlinkSync as Cu}from"node:fs";import{mkdir as Au,readFile as Ka,unlink as ja,writeFile as Iu}from"node:fs/promises";import{dirname as ku}from"node:path";function Ua(n){try{return process.kill(n,0),!0}catch(e){return e.code==="EPERM"}}var Pu=R("single-instance"),or=class{pidFile;acquired=!1;constructor(e={}){this.pidFile=e.pidFile??U().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&&(Pu.warn("removing stale pid file",{stalePid:e}),await ja(this.pidFile).catch(()=>{})),await Au(ku(this.pidFile),{recursive:!0}),await Iu(this.pidFile,String(process.pid),"utf8"),this.acquired=!0,this.installCleanupHooks(),{kind:"acquired"})}async release(){if(this.acquired){try{(await Ka(this.pidFile,"utf8")).trim()===String(process.pid)&&await ja(this.pidFile)}catch{}this.acquired=!1}}async readExistingPid(){try{let e=await Ka(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 Ua(e)?this.matchesDaemonTitle(e):!1}matchesDaemonTitle(e){if(process.platform==="win32")return this.matchesDaemonTitleWindows(e);try{let s=Ha(`/proc/${e}/cmdline`,"utf8").replace(/\0/g," ");return!!(s.includes("coze-bridge-daemon")||s.includes("lib/index.js"))}catch{}try{let s=qa(`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=qa(`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{Ha(this.pidFile,"utf8").trim()===String(process.pid)&&Cu(this.pidFile)}catch{}})}};var B=R("daemon"),Tu="coze-bridge-daemon";async function Wa(){let n=new or({processTitle:Tu}),e=await n.acquire();if(e.kind==="already-running")throw new Error(`coze-bridge daemon already running (pid=${e.pid})`);let s=await Nn(),o=s??{};dn({pid:process.pid}),B.info(s?"loaded bridge config":"initialized bridge config");try{let A=new Et;o.frameworksCache=await A.detectAll(),B.info("refreshed frameworks_cache",{detected:Object.keys(o.frameworksCache)})}catch(A){B.warn("framework detection failed",{err:String(A)})}await Ct(o);let c=new ir(new Nt),x=U(),f=null,u=new On({upstream:c,paths:x,bridgeConfig:o,sessionSpawner:async(A,N,M,V)=>{if(!f)throw new Error("agentManager not ready");return f.spawnSessionDownstream(A,N,M,V)}});await Du(x,u);let p=new Ln({paths:x,config:o,registry:u});f=p;let m,b,_=null,E={},T,k=null;u.registerExtension("_agent/create",async A=>p.createAgent(A.params)),u.registerExtension("_agent/health",async()=>({ok:!0}));let D={},F=new _n({agents:u.agents,disposeAndMarkDisconnected:async(A,N)=>{let M=u.agents.get(A);M&&(await p.cleanupOpenclawSessionProviders(M).catch(V=>B.warn("cleanup openclaw providers failed (ignored)",{agentId:A,err:String(V)})),await M.dispose(`disconnect: ${N}`).catch(V=>B.warn("dispose during disconnect failed (ignored)",{agentId:A,err:String(V)})),M.status="disconnected",u.unregister(A)),u.disconnectedAgents.add(A)},detailSyncer:async A=>{if(!D.ref)throw new Error("agent-detail-sync not initialized yet");await D.ref.syncOne(A)},openclawRepair:async(A,N)=>{await p.openclawRepair(A,N)}});u.registerExtension("_agent/listSkills",A=>F.listSkills(A.params)),u.registerExtension("_agent/addSkills",A=>F.addSkills(A.params)),u.registerExtension("_agent/removeSkills",A=>F.removeSkills(A.params)),u.registerExtension("_agent/getFileTree",A=>F.getFileTree(A.params)),u.registerExtension("_agent/getFileContent",A=>F.getFileContent(A.params)),u.registerExtension("_agent/update",A=>F.updateAgent(A.params)),u.registerExtension("_agent/disconnect",A=>F.disconnectAgent(A.params)),u.registerExtension("_agent/switchModel",A=>F.switchModel(A.params)),u.registerExtension("_agent/reset",A=>F.resetAgent(A.params)),u.registerExtension("_agent/repair",A=>F.repairAgent(A.params));let ie=new hn({paths:x,handlers:F,sendDetail:A=>u.sendRequest("_agent/detail",A)});D.ref=ie,c.onConnect(({initial:A})=>{B.info("frontier upstream connected, triggering detail sync",{initial:A}),ie.syncAll(A?"initial-connect":"reconnect").catch(N=>B.warn("detail sync top-level error (ignored)",{err:String(N)}))});let $=new Mn({paths:x,routes:[{method:"GET",path:"/status",handler:async()=>({running:!0,pid:process.pid,agents:[...u.agents.keys()],deviceId:_??"",frameworksCache:o.frameworksCache??{}})},{method:"POST",path:"/pair",handler:async A=>{let N=A,M=N?.privatecode,V=N?.pairing_code;if(!M||!V)throw new v("IPC_BAD_REQUEST","/pair requires privatecode + pairing_code");let _e=zt(N.env),Ie=N.handshake_url,Me=N.frontier_url,ue=Ga(N.env,Ie,Me),ge=!!m&&m!==M,nt=b!==void 0&&b!==ue,ne=ge||nt;if(ne){B.warn("pair config switched, resetting agents",{pcChanged:ge,envChanged:nt,previousPc:m?ar(m):"",nextPc:ar(M),previousEnvKey:b??"",nextEnvKey:ue});for(let xe of[...u.agents.values()])await xe.dispose("pair config switch").catch(()=>{}),u.agents.delete(xe.agentId);await c.swap(new Nt,"pair switch").catch(()=>{})}let rt=await Dr({privatecode:M,...Ie?{endpoint:Ie}:{},ppeOverride:_e});_=rt.deviceId,dn({deviceId:_,pid:process.pid}),Hr({patToken:M,env:N.env}).catch(xe=>B.warn("coze-cli setup error (ignored)",{err:String(xe)}));let G=new rn({handshake:rt,privatecode:M,...Me?{urlOverride:Me}:{},ppeOverride:_e});await c.swap(G,"pair");try{let xe=new Et;o.frameworksCache=await xe.detectAll(),await Ct(o),B.info("frameworks_cache refreshed before pair",{detected:Object.keys(o.frameworksCache)})}catch(xe){B.warn("frameworks_cache refresh failed (ignored, using cached)",{err:String(xe)})}let Q=Object.keys(o.frameworksCache??{});try{let xe=await u.sendRequest("_agent/pair",{pairCode:V,patToken:M,frameworks:Q,_meta:{cozeDeviceId:_}});B.info("_agent/pair ok",{pairResult:xe}),m=M,b=ue,E=_e,T=Ie,sn(M,x).catch(Se=>B.warn("writePatToken after /pair failed (ignored)",{err:String(Se)})),k||(k=new qt({core:u,getDeviceId:()=>_??""})),k.start(),ne&&mi(x,p).catch(Se=>B.warn("post-pair-switch auto-revive error (ignored)",{err:String(Se)}));let Be;return N.agent_id&&(Be=await Ru(N.agent_id,x,p,Se=>u.sendRequest("_agent/detail",Se)).catch(Se=>(B.error("--agent-id ensureAgent failed",{agentId:N.agent_id,err:String(Se)}),{ok:!1,agentId:N.agent_id??"",note:String(Se)}))),{ok:!0,note:"paired with cloud",...Be?{agent:Be}:{}}}catch(xe){return B.error("_agent/pair failed",{err:String(xe)}),{ok:!1,note:`pair failed: ${String(xe)}`}}}},{method:"POST",path:"/connect",handler:async A=>{let N=A,M=N?.privatecode;if(!M)throw new v("IPC_BAD_REQUEST","/connect requires privatecode");let V=zt(N.env),_e=N.handshake_url,Ie=N.frontier_url,Me=Ga(N.env,_e,Ie);if(m===M&&b===Me)return B.info("/connect: already connected with same PAT + env, noop"),{ok:!0,note:"already connected"};let ue=!!m&&m!==M,ge=b!==void 0&&b!==Me,nt=ue||ge;if(nt){B.warn("connect config switched, resetting agents",{pcChanged:ue,envChanged:ge,previousPc:m?ar(m):"",nextPc:ar(M)});for(let G of[...u.agents.values()])await G.dispose("connect config switch").catch(()=>{}),u.agents.delete(G.agentId);await c.swap(new Nt,"connect switch").catch(()=>{})}let ne=await Dr({privatecode:M,..._e?{endpoint:_e}:{},ppeOverride:V});_=ne.deviceId,dn({deviceId:_,pid:process.pid}),Hr({patToken:M,env:N.env}).catch(G=>B.warn("coze-cli setup error (ignored)",{err:String(G)}));let rt=new rn({handshake:ne,privatecode:M,...Ie?{urlOverride:Ie}:{},ppeOverride:V});return await c.swap(rt,"connect"),m=M,b=Me,E=V,T=_e,k||(k=new qt({core:u,getDeviceId:()=>_??""})),k.start(),nt&&mi(x,p).catch(G=>B.warn("post-connect-switch auto-revive error (ignored)",{err:String(G)})),sn(M,x).catch(G=>B.warn("writePatToken after /connect failed (ignored)",{err:String(G)})),B.info("/connect: WS established",{deviceId:_}),{ok:!0,note:"connected"}}},{method:"POST",path:"/_agent/create",handler:async A=>{let N=A;return{ok:!0,result:await p.createAgent(N)}}},{method:"POST",path:"/agent/send",handler:async A=>{let N=A;if(!N?.agentId||!N?.sessionId||!N?.kind||!N?.path)throw new v("IPC_BAD_REQUEST","/agent/send requires agentId, sessionId, kind, path");if(!m)throw new v("UPSTREAM_NOT_READY","daemon not yet paired with cloud (run --pair-code first)");try{return await Ys(N,{core:u,patToken:m,handshakeBase:T,ppeOverride:E})}catch(M){if(M instanceof v)return{ok:!1,code:M.code,message:M.message};throw M}}},{method:"POST",path:"/refresh",handler:async()=>{B.info("IPC /refresh: re-detecting frameworks");let A=new Et;return o.frameworksCache=await A.detectAll(),await Ct(o),{ok:!0,frameworks:o.frameworksCache}}},{method:"POST",path:"/shutdown",handler:async()=>(B.info("IPC /shutdown received"),setImmediate(()=>{ce.shutdown("ipc /shutdown")}),{ok:!0})}]}),{port:we,token:te}=await $.start();try{await Fa(x.libEntry,x)}catch(A){B.warn("bin shim install failed (D72 send \u547D\u4EE4\u53EF\u80FD\u4E0D\u53EF\u7528)",{err:String(A)})}await u.start(),mi(x,p).catch(A=>B.warn("auto-revive top-level error (ignored)",{err:String(A)}));let ae=null,ce={port:we,token:te,core:u,ipc:$,shutdown(A){return ae||(B.info("daemon shutdown",{reason:A}),ae=(async()=>{k?.stop(),await u.stop(A),await $.stop(),await n.release()})(),ae)}};for(let A of["SIGTERM","SIGINT"])process.on(A,()=>{ce.shutdown(A).then(()=>process.exit(0))});return B.info("daemon ready",{port:we,pid:process.pid,nodeVersion:process.version,platform:process.platform,frameworks:Object.keys(o.frameworksCache??{}),libVersion:o.libVersion??"dev"}),ce}function ar(n){return n.length<=8?"***":`${n.slice(0,4)}***${n.slice(-4)}`}function Ga(n,e,s){return`${n??""}|${e??""}|${s??""}`}async function Du(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(()=>(Xe(),ln));for(let f of o){await x(f,n).catch(u=>B.warn("enforceAgentConfigMode failed (ignored)",{agentId:f,err:String(u)}));try{let u=await c(f,n);u?.disconnectedAt&&(e.disconnectedAgents.add(f),B.info("agent marked disconnected on startup",{agentId:f,disconnectedAt:u.disconnectedAt,reason:u.disconnectReason??""}))}catch(u){B.warn("failed to load agent config on startup, skipping",{agentId:f,err:String(u)})}}}async function Ru(n,e,s,o){let{loadAgentConfig:c}=await Promise.resolve().then(()=>(Xe(),ln)),x=await c(n,e);if(x){B.info("--agent-id: local config found, reconnecting",{agentId:n,framework:x.framework,hadDisconnect:!!x.disconnectedAt});let m={agentId:x.agentId,framework:x.framework,...x.cozeIdentity?{cozeIdentity:x.cozeIdentity}:{},...x.model?{model:x.model}:{}};return await s.createAgent(m),{ok:!0,agentId:n,note:x.disconnectedAt?"revived from local config":"connected from local config"}}B.info("--agent-id: local config missing, pulling _agent/detail from cloud",{agentId:n});let f=await o({_meta:{cozeAgentId:n}});if(!f.framework)throw new v("AGENT_NOT_FOUND",`agent ${n} \u4E0D\u5728\u672C\u5730; \u4E91\u7AEF _agent/detail \u54CD\u5E94\u7F3A framework \u5B57\u6BB5 (D36 \u534F\u8BAE\u6269\u5C55\u672A\u751F\u6548), \u65E0\u6CD5\u5728\u672C\u673A\u65B0\u5EFA`);let u={agentId:f.agentId,framework:f.framework,...f.cozeIdentity?{cozeIdentity:f.cozeIdentity}:{},...f.model?{model:f.model}:{},...f.deployType?{_meta:{cozeDeployType:f.deployType}}:{}};await s.createAgent(u);let p=f.deployType==="cloud"&&f.framework==="openclaw";return{ok:!0,agentId:n,note:p?"cloud agent acknowledged":"created from cloud detail"}}async function mi(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(()=>(Xe(),ln));B.info("auto-revive: scanning local agents on startup",{count:o.length});let x=0,f=0;for(let u of o){let p;try{p=await c(u,n)}catch(m){B.warn("auto-revive: load config failed (skipping)",{agentId:u,err:String(m)}),f+=1;continue}if(!p){f+=1;continue}if(p.disconnectedAt){B.info("auto-revive: skip disconnected agent",{agentId:u,disconnectedAt:p.disconnectedAt}),f+=1;continue}try{B.info("auto-revive: re-registering agent (D44 no spawn)",{agentId:u,framework:p.framework});let m=Lu(p);await e.createAgent({agentId:p.agentId,framework:p.framework,...p.cozeIdentity?{cozeIdentity:p.cozeIdentity}:{},...p.model?{model:p.model}:{},...m?{_meta:m}:{}}),x+=1}catch(m){B.warn("auto-revive: createAgent failed (skipping)",{agentId:u,framework:p.framework,err:String(m)}),f+=1}}return B.info("auto-revive: done",{revived:x,skipped:f,total:o.length}),{revived:x,skipped:f,total:o.length}}function Lu(n){let e={};return n.deployType&&(e.cozeDeployType=n.deployType),n.accountId&&(e.cozeAccountId=n.accountId),Object.keys(e).length>0?e:void 0}yi();oe();import{readFile as Ja}from"node:fs/promises";var We=class{paths;constructor(e){this.paths=e??U()}async probe(e=1e3){let s=await cr(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:Hu(o)}}}async request(e){let s=await cr(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,f=setTimeout(()=>x.abort(),s.timeoutMs??5e3);try{let u=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}),p=await u.text();return{status:u.status,body:qu(p)}}finally{clearTimeout(f)}}};async function cr(n){try{let[e,s]=await Promise.all([Ja(n.portFile,"utf8"),Ja(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 qu(n){if(!n)return null;try{return JSON.parse(n)}catch{return n}}function Hu(n){return n instanceof Error?n.message:String(n)}q();oe();import{copyFile as $a,mkdir as Ku,readFile as bi,writeFile as ju}from"node:fs/promises";import{dirname as Gu,resolve as vi,sep as xr}from"node:path";import{fileURLToPath as Wu}from"node:url";q();oe();var Va=R("dist-install");function Ju(n){let e=Wu(n),s=Gu(e),o=`${xr}src${xr}`;if(s.includes(o)||s.endsWith(`${xr}src${xr}cli`))return null;let c=vi(s,"index.js"),x=vi(s,"..","package.json");return{dist:c,pkgJson:x}}async function Si(n={}){let e=n.paths??U(),s=Ju(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 bi(c,"utf8")).version??"unknown"}catch(_){return Va.warn("cannot read source package.json,skip dist install",{err:String(_)}),{kind:"dev-mode-skip",reason:`package.json read failed: ${String(_)}`}}let f=await Nn(e.configFile)??{},u=f.libVersion;if(u===x)try{return await bi(e.libEntry),{kind:"already-current",libVersion:x}}catch{}await Ku(e.libDir,{recursive:!0}),await $a(o,e.libEntry),await $a(`${o}.map`,`${e.libEntry}.map`).catch(()=>{});let p=vi(e.libDir,"package.json"),m=`${JSON.stringify({type:"module"},null,2)}
126
+ `;return await bi(p,"utf8").catch(()=>null)!==m&&await ju(p,m),f.libVersion=x,await Ct(f,e.configFile),Va.info("dist installed",{libEntry:e.libEntry,fromVersion:u,toVersion:x}),u?{kind:"version-changed",fromVersion:u,toVersion:x,libEntry:e.libEntry}:{kind:"first-install",libVersion:x,libEntry:e.libEntry}}import{basename as $u,resolve as Vu}from"node:path";oe();var Xu=9e4,Yu={PATH_OUTSIDE_WORKSPACE:3,FILE_TOO_LARGE:3,UNSUPPORTED_MIME:3,IPC_BAD_REQUEST:3,AGENT_NOT_FOUND:4,IPC_AUTH_FAILED:4,AGENT_DISCONNECTED:5,UPLOAD_FAILED:5,UPSTREAM_NOT_READY:5,UPSTREAM_DISCONNECTED:5,UPSTREAM_HANDSHAKE_FAILED:5,AGENT_BUSY:1,AGENT_SPAWN_FAILED:1,AGENT_TIMEOUT:1,AGENT_PROTOCOL_ERROR:1,BRIDGE_CONFIG_INVALID:1,BRIDGE_INTERNAL:1,MODEL_TOKEN_GEN_FAILED:1,OPERATION_NOT_ALLOWED_FOR_LOCAL:1};function Zu(n){return Yu[n]??1}async function Xa(n,e={}){let s=e.paths??U();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>
126
127
  `),4;let o=await cr(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.
127
- `),4;let c={agentId:n.agentId,sessionId:n.sessionId,kind:n.kind,path:$f(process.cwd(),n.path),...n.caption?{caption:n.caption}:{},...n.name?{name:n.name}:{}},d;try{d=await Qf(o,"/agent/send",c,Yf)}catch(f){return process.stderr.write(`Error: daemon IPC failed: ${f instanceof Error?f.message:String(f)}
128
- `),4}if(!d.ok)return process.stderr.write(`Error: ${d.code}: ${d.message}
129
- `),Zf(d.code);if(n.json)process.stdout.write(`${JSON.stringify(d)}
130
- `);else{let f=n.name??Vf(c.path);process.stdout.write(`Sent ${n.kind} ${f} (${el(d.bytes)})
131
- `)}return 0}async function Qf(n,e,s,o){let c=new AbortController,d=setTimeout(()=>c.abort(),o);try{let f=await fetch(`http://127.0.0.1:${n.port}${e}`,{method:"POST",headers:{Authorization:`Bearer ${n.token}`,"content-type":"application/json"},body:JSON.stringify(s),signal:c.signal}),l=await f.text(),m=l?JSON.parse(l):null;return m&&typeof m=="object"&&"ok"in m?m:{ok:!1,code:"BRIDGE_INTERNAL",message:`unexpected daemon response (status=${f.status}): ${l.slice(0,200)}`}}finally{clearTimeout(d)}}function el(n){return n<1024?`${n}B`:n<1024*1024?`${(n/1024).toFixed(1)}KB`:`${(n/1024/1024).toFixed(1)}MB`}var nc=D("cli");function le(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 _l(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[0]==="send")return yl(e.slice(1));if(e[0]==="connect")return vl(e.slice(1));if(e.includes("--help")||e.includes("-h")||e.length===0)return{mode:"help"};let s=e,{value:o,rest:c}=le(s,"--pat-token");s=c;let{value:d,rest:f}=le(s,"--pair-code");s=f;let{value:l,rest:m}=le(s,"--env");s=m;let{value:w,rest:v}=le(s,"--handshake-url");s=v;let{value:_,rest:E}=le(s,"--frontier-url");s=E;let{value:T}=le(s,"--agent-id");if(!o||!d)return{mode:"help"};let P={mode:"pair",privatecode:o,pairingCode:d};return l&&(P.env=l),w&&(P.handshakeUrl=w),_&&(P.frontierUrl=_),T&&(P.agentId=T),P}function yl(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}=le(o,"--caption");o=d;let{value:f,rest:l}=le(o,"--name");o=l;let{value:m,rest:w}=le(o,"--agent-id");o=w;let{value:v,rest:_}=le(o,"--session-id");o=_;let E=o.includes("--json"),T={mode:"send",kind:e,path:s,json:E};return c&&(T.caption=c),f&&(T.name=f),m&&(T.agentId=m),v&&(T.sessionId=v),T}function vl(n){let e=n,{value:s,rest:o}=le(e,"--pat-token");e=o;let{value:c,rest:d}=le(e,"--env");e=d;let{value:f,rest:l}=le(e,"--handshake-url");e=l;let{value:m}=le(e,"--frontier-url"),w={mode:"connect"};return s&&(w.privatecode=s),c&&(w.env=c),f&&(w.handshakeUrl=f),m&&(w.frontierUrl=m),w}var bl=`
128
+ `),4;let c={agentId:n.agentId,sessionId:n.sessionId,kind:n.kind,path:Vu(process.cwd(),n.path),...n.caption?{caption:n.caption}:{},...n.name?{name:n.name}:{}},x;try{x=await Qu(o,"/agent/send",c,Xu)}catch(f){return process.stderr.write(`Error: daemon IPC failed: ${f instanceof Error?f.message:String(f)}
129
+ `),4}if(!x.ok)return process.stderr.write(`Error: ${x.code}: ${x.message}
130
+ `),Zu(x.code);if(n.json)process.stdout.write(`${JSON.stringify(x)}
131
+ `);else{let f=n.name??$u(c.path);process.stdout.write(`Sent ${n.kind} ${f} (${el(x.bytes)})
132
+ `)}return 0}async function Qu(n,e,s,o){let c=new AbortController,x=setTimeout(()=>c.abort(),o);try{let f=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}),u=await f.text(),p=u?JSON.parse(u):null;return p&&typeof p=="object"&&"ok"in p?p:{ok:!1,code:"BRIDGE_INTERNAL",message:`unexpected daemon response (status=${f.status}): ${u.slice(0,200)}`}}finally{clearTimeout(x)}}function el(n){return n<1024?`${n}B`:n<1024*1024?`${(n/1024).toFixed(1)}KB`:`${(n/1024/1024).toFixed(1)}MB`}var n0=R("cli");function he(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 _l(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[0]==="send")return yl(e.slice(1));if(e[0]==="connect")return bl(e.slice(1));if(e.includes("--help")||e.includes("-h")||e.length===0)return{mode:"help"};let s=e,{value:o,rest:c}=he(s,"--pat-token");s=c;let{value:x,rest:f}=he(s,"--pair-code");s=f;let{value:u,rest:p}=he(s,"--env");s=p;let{value:m,rest:b}=he(s,"--handshake-url");s=b;let{value:_,rest:E}=he(s,"--frontier-url");s=E;let{value:T}=he(s,"--agent-id");if(!o||!x)return{mode:"help"};let k={mode:"pair",privatecode:o,pairingCode:x};return u&&(k.env=u),m&&(k.handshakeUrl=m),_&&(k.frontierUrl=_),T&&(k.agentId=T),k}function yl(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}=he(o,"--caption");o=x;let{value:f,rest:u}=he(o,"--name");o=u;let{value:p,rest:m}=he(o,"--agent-id");o=m;let{value:b,rest:_}=he(o,"--session-id");o=_;let E=o.includes("--json"),T={mode:"send",kind:e,path:s,json:E};return c&&(T.caption=c),f&&(T.name=f),p&&(T.agentId=p),b&&(T.sessionId=b),T}function bl(n){let e=n,{value:s,rest:o}=he(e,"--pat-token");e=o;let{value:c,rest:x}=he(e,"--env");e=x;let{value:f,rest:u}=he(e,"--handshake-url");e=u;let{value:p}=he(e,"--frontier-url"),m={mode:"connect"};return s&&(m.privatecode=s),c&&(m.env=c),f&&(m.handshakeUrl=f),p&&(m.frontierUrl=p),m}var vl=`
132
133
  coze-bridge - local bridge daemon for cloud Agent Service
133
134
 
134
135
  Usage:
@@ -169,43 +170,43 @@ Send file / image (D72; intended to be called by LLM inside agent bash tool):
169
170
 
170
171
  Internal:
171
172
  <node> <entry> --daemon daemon mode (OS supervisor only)
172
- `.trimStart();async function rc(n=process.argv,e={}){let s=_l(n);switch(s.mode){case"help":return process.stdout.write(bl),0;case"version":return process.stdout.write(`${vn}
173
- `),0;case"daemon":{try{await ja()}catch(o){return nc.error("daemon start failed",{err:String(o)}),1}return new Promise(()=>{})}case"status":return Sl(e);case"stop":return El(e);case"refresh":return Al(e);case"uninstall":return Cl(e);case"install-service":return Il();case"pair":{let o={};return s.env&&(o.env=s.env),s.handshakeUrl&&(o.handshakeUrl=s.handshakeUrl),s.frontierUrl&&(o.frontierUrl=s.frontierUrl),Pl(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),kl(s.privatecode,e,o)}case"send":return Ya({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 ic(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 Sl(n){let e=n.paths??F(),s=new je(e),o=await s.probe();if(o.kind==="not-running")return process.stdout.write(`coze-bridge: not running
174
- `),1;if(o.kind==="stale")return await ic(e),process.stdout.write(`coze-bridge: not running (cleaned stale state)
173
+ `.trimStart();async function r0(n=process.argv,e={}){let s=_l(n);switch(s.mode){case"help":return process.stdout.write(vl),0;case"version":return process.stdout.write(`${bn}
174
+ `),0;case"daemon":{try{await Wa()}catch(o){return n0.error("daemon start failed",{err:String(o)}),1}return new Promise(()=>{})}case"status":return Sl(e);case"stop":return El(e);case"refresh":return Cl(e);case"uninstall":return Al(e);case"install-service":return Il();case"pair":{let o={};return s.env&&(o.env=s.env),s.handshakeUrl&&(o.handshakeUrl=s.handshakeUrl),s.frontierUrl&&(o.frontierUrl=s.frontierUrl),kl(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),Pl(s.privatecode,e,o)}case"send":return Xa({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 i0(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 Sl(n){let e=n.paths??U(),s=new We(e),o=await s.probe();if(o.kind==="not-running")return process.stdout.write(`coze-bridge: not running
175
+ `),1;if(o.kind==="stale")return await i0(e),process.stdout.write(`coze-bridge: not running (cleaned stale state)
175
176
  `),1;let c=await s.request({method:"GET",path:"/status"});return process.stdout.write(`coze-bridge: running
176
177
  ${JSON.stringify(c.body,null,2)}
177
- `),0}async function El(n){let e=n.paths??F(),s=new je(e),o=await s.probe();if(o.kind==="not-running")return process.stdout.write(`coze-bridge: not running
178
- `),0;if(o.kind==="stale")return await ic(e),process.stdout.write(`coze-bridge: not running (cleaned stale state)
178
+ `),0}async function El(n){let e=n.paths??U(),s=new We(e),o=await s.probe();if(o.kind==="not-running")return process.stdout.write(`coze-bridge: not running
179
+ `),0;if(o.kind==="stale")return await i0(e),process.stdout.write(`coze-bridge: not running (cleaned stale state)
179
180
  `),0;try{return await s.request({method:"POST",path:"/shutdown"}),process.stdout.write(`coze-bridge: stopped
180
181
  `),0}catch(c){return process.stdout.write(`coze-bridge: stop failed: ${String(c)}
181
- `),1}}async function Al(n){let e=new je(n.paths);if((await e.probe()).kind==="not-running")return process.stdout.write(`coze-bridge: not running (start daemon first)
182
+ `),1}}async function Cl(n){let e=new We(n.paths);if((await e.probe()).kind==="not-running")return process.stdout.write(`coze-bridge: not running (start daemon first)
182
183
  `),1;try{let o=await e.request({method:"POST",path:"/refresh"});return o.status===200?(process.stdout.write(`coze-bridge: refreshed
183
184
  ${JSON.stringify(o.body,null,2)}
184
185
  `),0):(process.stderr.write(`coze-bridge: refresh failed: ${JSON.stringify(o.body)}
185
186
  `),1)}catch(o){return process.stderr.write(`coze-bridge: refresh failed: ${String(o)}
186
- `),1}}async function Cl(n){let e=new je(n.paths);if((await e.probe()).kind==="connected"){process.stdout.write(`coze-bridge: stopping daemon...
187
- `);try{await e.request({method:"POST",path:"/shutdown"})}catch(d){process.stderr.write(`coze-bridge: stop failed (continuing): ${String(d)}
188
- `)}await new Promise(d=>setTimeout(d,500))}if(!n.skipSupervisor)try{let{getSupervisor:d,buildContext:f}=await Promise.resolve().then(()=>(ki(),Pi)),l=d();await l.uninstall(f()),process.stdout.write(`coze-bridge: ${l.platform} supervisor unregistered
189
- `)}catch(d){process.stderr.write(`coze-bridge: supervisor uninstall failed (continuing): ${String(d)}
190
- `)}let o=n.paths??F(),{rm:c}=await import("node:fs/promises");try{await c(o.cozeRoot,{recursive:!0,force:!0}),process.stdout.write(`coze-bridge: removed ${o.cozeRoot}
191
- `)}catch(d){return process.stderr.write(`coze-bridge: remove failed: ${String(d)}
187
+ `),1}}async function Al(n){let e=new We(n.paths);if((await e.probe()).kind==="connected"){process.stdout.write(`coze-bridge: stopping daemon...
188
+ `);try{await e.request({method:"POST",path:"/shutdown"})}catch(x){process.stderr.write(`coze-bridge: stop failed (continuing): ${String(x)}
189
+ `)}await new Promise(x=>setTimeout(x,500))}if(!n.skipSupervisor)try{let{getSupervisor:x,buildContext:f}=await Promise.resolve().then(()=>(Ti(),Pi)),u=x();await u.uninstall(f()),process.stdout.write(`coze-bridge: ${u.platform} supervisor unregistered
190
+ `)}catch(x){process.stderr.write(`coze-bridge: supervisor uninstall failed (continuing): ${String(x)}
191
+ `)}let o=n.paths??U(),{rm:c}=await import("node:fs/promises");try{await c(o.cozeRoot,{recursive:!0,force:!0}),process.stdout.write(`coze-bridge: removed ${o.cozeRoot}
192
+ `)}catch(x){return process.stderr.write(`coze-bridge: remove failed: ${String(x)}
192
193
  `),1}return process.stdout.write(`coze-bridge: uninstalled
193
- `),0}async function Il(){try{let{getSupervisor:n,buildContext:e}=await Promise.resolve().then(()=>(ki(),Pi)),s=n(),o=e();return process.stdout.write(`coze-bridge: installing ${s.platform} supervisor...
194
+ `),0}async function Il(){try{let{getSupervisor:n,buildContext:e}=await Promise.resolve().then(()=>(Ti(),Pi)),s=n(),o=e();return process.stdout.write(`coze-bridge: installing ${s.platform} supervisor...
194
195
  `),await s.install(o),process.stdout.write(`coze-bridge: supervisor installed (daemon will auto-start on login)
195
196
  `),0}catch(n){return process.stderr.write(`coze-bridge: --install-service failed: ${String(n)}
196
- `),1}}async function Pl(n,e,s,o={},c){let d=new je(s.paths),f=s.spawnDaemon??wi;if(!s.skipDistInstall){let w=await bi({paths:s.paths});w.kind==="version-changed"?(process.stdout.write(`coze-bridge: upgraded ${w.fromVersion} \u2192 ${w.toVersion}
197
- `),(await d.probe()).kind==="connected"&&(await d.request({method:"POST",path:"/shutdown"}).catch(()=>{}),await new Promise(_=>setTimeout(_,500)))):w.kind==="first-install"&&process.stdout.write(`coze-bridge: installed ${w.libVersion}
198
- `)}let l=await d.probe();if(l.kind!=="connected"&&(process.stdout.write(`coze-bridge: starting daemon...
199
- `),await f({paths:s.paths}),l=await sc(d,s.waitTimeoutMs??1e4,s.sleep??oc),l.kind!=="connected"))return process.stderr.write(`coze-bridge: daemon did not come up: ${l.kind}
200
- `),1;let m={privatecode:n,pairing_code:e};o.env&&(m.env=o.env),o.handshakeUrl&&(m.handshake_url=o.handshakeUrl),o.frontierUrl&&(m.frontier_url=o.frontierUrl),c&&(m.agent_id=c);try{let w=await d.request({method:"POST",path:"/pair",body:m,timeoutMs:35e3});return w.status===200&&w.body?.ok?(process.stdout.write(`coze-bridge: paired (${w.body.note??"ok"})
201
- `),0):(process.stderr.write(`coze-bridge: pair failed: ${JSON.stringify(w.body)}
202
- `),1)}catch(w){return process.stderr.write(`coze-bridge: pair failed: ${String(w)}
203
- `),1}}async function kl(n,e,s={}){let o=e.paths??F(),c=n??await za(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 je(e.paths),f=e.spawnDaemon??wi;if(!e.skipDistInstall){let w=await bi({paths:e.paths});w.kind==="version-changed"?(process.stdout.write(`coze-bridge: upgraded ${w.fromVersion} \u2192 ${w.toVersion}
204
- `),(await d.probe()).kind==="connected"&&(await d.request({method:"POST",path:"/shutdown"}).catch(()=>{}),await new Promise(_=>setTimeout(_,500)))):w.kind==="first-install"&&process.stdout.write(`coze-bridge: installed ${w.libVersion}
205
- `)}let l=await d.probe();if(l.kind!=="connected"&&(process.stdout.write(`coze-bridge: starting daemon...
206
- `),await f({paths:e.paths}),l=await sc(d,e.waitTimeoutMs??1e4,e.sleep??oc),l.kind!=="connected"))return process.stderr.write(`coze-bridge: daemon did not come up: ${l.kind}
207
- `),1;let m={privatecode:c};s.env&&(m.env=s.env),s.handshakeUrl&&(m.handshake_url=s.handshakeUrl),s.frontierUrl&&(m.frontier_url=s.frontierUrl);try{let w=await d.request({method:"POST",path:"/connect",body:m,timeoutMs:35e3});return w.status===200&&w.body?.ok?(process.stdout.write(`coze-bridge: connected (${w.body.note??"ok"})
208
- `),await sn(c,o).catch(v=>nc.warn("writePatToken after connect failed (ignored)",{err:String(v)})),0):(process.stderr.write(`coze-bridge: connect failed: ${JSON.stringify(w.body)}
209
- `),1)}catch(w){return process.stderr.write(`coze-bridge: connect failed: ${String(w)}
210
- `),1}}async function sc(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 oc(n){return new Promise(e=>setTimeout(e,n))}rc(process.argv).then(n=>process.exit(n),n=>{process.stderr.write(`fatal: ${n instanceof Error?n.stack??n.message:String(n)}
197
+ `),1}}async function kl(n,e,s,o={},c){let x=new We(s.paths),f=s.spawnDaemon??_i;if(!s.skipDistInstall){let m=await Si({paths:s.paths});m.kind==="version-changed"?(process.stdout.write(`coze-bridge: upgraded ${m.fromVersion} \u2192 ${m.toVersion}
198
+ `),(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}
199
+ `)}let u=await x.probe();if(u.kind!=="connected"&&(process.stdout.write(`coze-bridge: starting daemon...
200
+ `),await f({paths:s.paths}),u=await s0(x,s.waitTimeoutMs??1e4,s.sleep??o0),u.kind!=="connected"))return process.stderr.write(`coze-bridge: daemon did not come up: ${u.kind}
201
+ `),1;let p={privatecode:n,pairing_code:e};o.env&&(p.env=o.env),o.handshakeUrl&&(p.handshake_url=o.handshakeUrl),o.frontierUrl&&(p.frontier_url=o.frontierUrl),c&&(p.agent_id=c);try{let m=await x.request({method:"POST",path:"/pair",body:p,timeoutMs:35e3});return m.status===200&&m.body?.ok?(process.stdout.write(`coze-bridge: paired (${m.body.note??"ok"})
202
+ `),0):(process.stderr.write(`coze-bridge: pair failed: ${JSON.stringify(m.body)}
203
+ `),1)}catch(m){return process.stderr.write(`coze-bridge: pair failed: ${String(m)}
204
+ `),1}}async function Pl(n,e,s={}){let o=e.paths??U(),c=n??await za(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 We(e.paths),f=e.spawnDaemon??_i;if(!e.skipDistInstall){let m=await Si({paths:e.paths});m.kind==="version-changed"?(process.stdout.write(`coze-bridge: upgraded ${m.fromVersion} \u2192 ${m.toVersion}
205
+ `),(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}
206
+ `)}let u=await x.probe();if(u.kind!=="connected"&&(process.stdout.write(`coze-bridge: starting daemon...
207
+ `),await f({paths:e.paths}),u=await s0(x,e.waitTimeoutMs??1e4,e.sleep??o0),u.kind!=="connected"))return process.stderr.write(`coze-bridge: daemon did not come up: ${u.kind}
208
+ `),1;let p={privatecode:c};s.env&&(p.env=s.env),s.handshakeUrl&&(p.handshake_url=s.handshakeUrl),s.frontierUrl&&(p.frontier_url=s.frontierUrl);try{let m=await x.request({method:"POST",path:"/connect",body:p,timeoutMs:35e3});return m.status===200&&m.body?.ok?(process.stdout.write(`coze-bridge: connected (${m.body.note??"ok"})
209
+ `),await sn(c,o).catch(b=>n0.warn("writePatToken after connect failed (ignored)",{err:String(b)})),0):(process.stderr.write(`coze-bridge: connect failed: ${JSON.stringify(m.body)}
210
+ `),1)}catch(m){return process.stderr.write(`coze-bridge: connect failed: ${String(m)}
211
+ `),1}}async function s0(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 o0(n){return new Promise(e=>setTimeout(e,n))}r0(process.argv).then(n=>process.exit(n),n=>{process.stderr.write(`fatal: ${n instanceof Error?n.stack??n.message:String(n)}
211
212
  `),process.exit(1)});