coze-bridge 0.1.82 → 0.1.83-alpha.0

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 +65 -65
  2. package/package.json +1 -1
package/dist/index.js CHANGED
@@ -5,26 +5,26 @@ 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 Hh=Object.create;var Go=Object.defineProperty;var jh=Object.getOwnPropertyDescriptor;var Gh=Object.getOwnPropertyNames;var Kh=Object.getPrototypeOf,Wh=Object.prototype.hasOwnProperty;var ae=(t=>typeof require<"u"?require:typeof Proxy<"u"?new Proxy(t,{get:(e,r)=>(typeof require<"u"?require:e)[r]}):t)(function(t){if(typeof require<"u")return require.apply(this,arguments);throw Error('Dynamic require of "'+t+'" is not supported')});var dt=(t,e)=>()=>(t&&(e=t(t=0)),e);var ne=(t,e)=>()=>(e||t((e={exports:{}}).exports,e),e.exports),Ko=(t,e)=>{for(var r in e)Go(t,r,{get:e[r],enumerable:!0})},$h=(t,e,r,s)=>{if(e&&typeof e=="object"||typeof e=="function")for(let a of Gh(e))!Wh.call(t,a)&&a!==r&&Go(t,a,{get:()=>e[a],enumerable:!(s=jh(e,a))||s.enumerable});return t};var gt=(t,e,r)=>(r=t!=null?Hh(Kh(t)):{},$h(e||!t||!t.__esModule?Go(r,"default",{value:t,enumerable:!0}):r,t));function O0(t){Wo=t}function P0(t){return Pi[Wo]<=Pi[t]}function Li(t){k0={...t}}function Zh(t){let e=(l,x=2)=>String(l).padStart(x,"0"),r=-t.getTimezoneOffset(),s=r>=0?"+":"-",a=Math.abs(r),c=e(Math.floor(a/60)),f=e(a%60);return`${t.getFullYear()}-${e(t.getMonth()+1)}-${e(t.getDate())}T${e(t.getHours())}:${e(t.getMinutes())}:${e(t.getSeconds())}.${e(t.getMilliseconds(),3)}${s}${c}:${f}`}function Oi(t,e,r,s){if(Pi[t]<Pi[Wo])return;let a=JSON.stringify({ts:Zh(new Date),level:t,module:e,msg:r,...k0,...s});t==="error"||t==="warn"?Jh.write(`${a}
9
- `):Vh.write(`${a}
10
- `)}function H(t){return{debug:(e,r)=>Oi("debug",t,e,r),info:(e,r)=>Oi("info",t,e,r),warn:(e,r)=>Oi("warn",t,e,r),error:(e,r)=>Oi("error",t,e,r),child:e=>H(`${t}.${e}`)}}var Pi,Wo,Vh,Jh,k0,ee=dt(()=>{"use strict";Pi={debug:10,info:20,warn:30,error:40},Wo=(()=>{let t=process.env.COZE_BRIDGE_LOG_LEVEL;return t==="debug"||t==="info"||t==="warn"||t==="error"?t:"info"})(),Vh=process.stdout,Jh=process.stderr,k0={}});import{execFile as Yh,spawn as Xh,spawnSync as g2}from"node:child_process";import{promisify as Qh}from"node:util";function tp(t){if(process.platform!=="win32")return!1;if(L0.test(t))return!0;let r=(t.split(/[/\\]/).pop()??t).replace(L0,"").toLowerCase();return ep.has(r)}function N0(t,e){if(process.platform!=="win32")return e??{};let r={...e??{}};return tp(t)&&r.shell===void 0&&(r.shell=!0),r.windowsHide===void 0&&(r.windowsHide=!0),r}function Vt(t,e=[],r={}){return Xh(t,e,N0(t,r))}function Ni(t,e=[],r={}){return np(t,e,N0(t,r))}var ep,L0,np,Wn=dt(()=>{"use strict";ep=new Set(["npm","npx","yarn","pnpm","coze","tsx","claude-agent-acp","codex-acp"]),L0=/\.(cmd|bat|ps1)$/i;np=Qh(Yh)});var U0={};Ko(U0,{_resetAcpInstallerForTests:()=>gp,_resetInstallTimeoutsForTests:()=>dp,_setBinaryPathCacheForTests:()=>wp,_setInFlightForTests:()=>mp,_setInstallTimeoutsForTests:()=>cp,ensureAcpInstalled:()=>yn,formatExecError:()=>z0,getAcpBinaryPath:()=>Jt,getAcpPackageSpec:()=>Lr,getInFlightInstall:()=>Jo,npmInstallGlobal:()=>F0,pickWhichLine:()=>zi,probeAcpVersion:()=>pp});import{readFile as rp,realpath as ip,stat as sp}from"node:fs/promises";import{dirname as $o,join as op}from"node:path";function Lr(t){let e=Vo[t];if(e)return`${e.npmPackage}@${e.versionSpec}`}function cp(t,e){Mi=t,Bi=e}function dp(){Mi=5e4,Bi=5e3}function hp(t){let e=t?.code;if(e&&lp.has(e))return!0;let r=t instanceof Error?`${t.message}
11
- ${t.stack??""}`:String(t);return up.test(r)||xp.test(r)}function z0(t){if(t==null||typeof t!="object")return String(t);let e=t,r=[];e.message&&r.push(e.message),e.code!==void 0&&e.code!==null&&r.push(`code=${e.code}`),e.signal&&r.push(`signal=${e.signal}`);let s=e.stderr?.toString().trim();s&&r.push(`stderr=${s.slice(0,2e3)}`);let a=e.stdout?.toString().trim();return a&&r.push(`stdout=${a.slice(0,2e3)}`),r.length>0?r.join(" | "):String(t)}async function M0(t){let e=process.platform==="win32"?"where":"which";try{let{stdout:r}=await Ni(e,[t],{timeout:ap});return zi(r)}catch{return}}function zi(t){let e=t.split(/\r?\n/).map(s=>s.trim()).filter(Boolean);if(e.length===0)return;if(process.platform!=="win32")return e[0];let r=s=>e.find(a=>a.toLowerCase().endsWith(s));return r(".cmd")??r(".exe")??r(".bat")??r(".ps1")??e[0]}async function pp(t){let e=Vo[t];if(!e)return;let r=Jt(t);if(!r){Fe.warn("acp wrapper probe: binary path cache empty",{framework:t,binary:e.binary,hint:"ensureAcpInstalled \u6CA1\u8DD1\u8FC7 / \u88C5\u5931\u8D25 / \u4E4B\u524D negative cache 5min \u5185"});return}let s;try{s=await ip(r)}catch(c){Fe.warn("acp wrapper probe: realpath failed (symlink target \u4E0D\u5B58\u5728?)",{framework:t,binaryPath:r,err:String(c)});return}let a=$o(s);for(let c=0;c<B0;c++){let f=op(a,"package.json");try{if(!(await sp(f)).isFile()){a=$o(a);continue}let h=await rp(f,"utf8"),m=JSON.parse(h);if(m.name===e.npmPackage){if(typeof m.version=="string"&&m.version.length>0)return m.version;Fe.warn("acp wrapper probe: package.json \u627E\u5230\u4F46 version \u5B57\u6BB5\u7F3A",{framework:t,packageJsonPath:f});return}}catch(x){let h=x;h.code!=="ENOENT"&&Fe.warn("acp wrapper probe: package.json \u8BFB\u53D6\u5F02\u5E38",{framework:t,candidate:f,errCode:h?.code,err:String(x)})}let l=$o(a);if(l===a)break;a=l}Fe.warn("acp wrapper probe: \u627E\u4E0D\u5230\u5339\u914D name \u7684 package.json (\u4E0A\u6EAF\u5230 max depth)",{framework:t,binaryPath:r,realBinary:s,expectedName:e.npmPackage,maxDepth:B0})}async function F0(t,e,r){let s=`${t}@${e}`;Fe.info("npm install -g start",{npmPackage:t,versionSpec:e});let a=Date.now(),c=process.platform==="win32";return new Promise((f,l)=>{let x=Vt("npm",["install","-g",s],{stdio:["ignore","pipe","pipe"],...c?{}:{detached:!0}});if(!x.pid){l(new Error(`failed to spawn npm: no pid (npmPackage=${t})`));return}let h=x.pid,m=10*1024*1024,E=[],C=[],_=0,y=0;x.stdout?.on("data",A=>{_+=A.length,_<m&&E.push(A)}),x.stderr?.on("data",A=>{y+=A.length,y<m&&C.push(A)});let v="running",I,R=A=>{try{return c?x.kill(A):process.kill(-h,A),!0}catch(k){return Fe.warn("npm install: kill failed (process already dead?)",{npmPackage:t,pid:h,sig:A,err:String(k)}),!1}},L=setTimeout(()=>{v="terminating",Fe.warn("npm install timeout, sending SIGTERM to process group",{npmPackage:t,versionSpec:e,pid:h,elapsedMs:Date.now()-a,timeoutMs:Mi,graceMs:Bi,stdoutBytes:_,stderrBytes:y}),R("SIGTERM"),I=setTimeout(()=>{v="killing",Fe.warn("npm install SIGTERM grace expired, escalating to SIGKILL",{npmPackage:t,versionSpec:e,pid:h,elapsedMs:Date.now()-a,stdoutBytes:_,stderrBytes:y}),R("SIGKILL")},Bi)},Mi),w=()=>{v="aborted",Fe.warn("npm install externally aborted, sending SIGKILL to process group",{npmPackage:t,versionSpec:e,pid:h,elapsedMs:Date.now()-a}),R("SIGKILL")};r&&(r.aborted?w():r.addEventListener("abort",w,{once:!0})),x.on("error",A=>{clearTimeout(L),I&&clearTimeout(I),r?.removeEventListener("abort",w),Fe.warn("npm install spawn error",{npmPackage:t,versionSpec:e,pid:h,err:String(A)}),l(new Error(`spawn npm failed: ${String(A)}`))}),x.on("close",(A,k)=>{clearTimeout(L),I&&clearTimeout(I),r?.removeEventListener("abort",w);let F=Buffer.concat(E).toString("utf8"),z=Buffer.concat(C).toString("utf8"),O=Date.now()-a;if(A===0&&v==="running"){Fe.info("npm install -g done",{npmPackage:t,versionSpec:e,elapsedMs:O}),f();return}Fe.warn("npm install -g exited non-success",{npmPackage:t,versionSpec:e,pid:h,phase:v,exitCode:A,signal:k,elapsedMs:O,stdoutBytes:_,stderrBytes:y});let N=Object.assign(new Error(`Command failed: npm install -g ${s}`+(k?` (killed by ${k})`:"")+(A!==null?` (exit ${A})`:"")+(v!=="running"?` (phase=${v})`:"")),{code:A,signal:k,stderr:z,stdout:F});l(N)})})}async function yn(t,e){let r=Vo[t];if(!r)return;let s=$n.get(t);if(s)return s;let a=Pr.get(t);if(a&&Date.now()-a<fp)return;let c=Vn.get(t);if(c)return c;let f=(async()=>{let l=await M0(r.binary);if(l)return $n.set(t,l),Fe.info("acp wrapper found on PATH",{binary:r.binary,path:l}),l;try{await F0(r.npmPackage,r.versionSpec,e)}catch(h){let m=hp(h);Fe.warn("acp wrapper install failed (will fallback to npx)",{framework:t,npmPackage:r.npmPackage,versionSpec:r.versionSpec,binary:r.binary,transient:m,err:z0(h)}),m||Pr.set(t,Date.now());return}let x=await M0(r.binary);if(!x){Fe.warn("acp wrapper installed but binary not found on PATH",{framework:t,npmPackage:r.npmPackage,versionSpec:r.versionSpec,binary:r.binary}),Pr.set(t,Date.now());return}return $n.set(t,x),Pr.delete(t),x})().finally(()=>{Vn.delete(t)});return Vn.set(t,f),f}function Jt(t){return $n.get(t)}function Jo(t){return Vn.get(t)}function gp(){$n.clear(),Pr.clear(),Vn.clear()}function mp(t,e){Vn.set(t,e)}function wp(t,e){$n.set(t,e)}var Fe,Vo,Mi,Bi,ap,fp,lp,up,xp,$n,Pr,Vn,B0,Zt=dt(()=>{"use strict";Wn();ee();Fe=H("agents.acp-installer"),Vo={"claude-code":{npmPackage:"@agentclientprotocol/claude-agent-acp",binary:"claude-agent-acp",versionSpec:"^0.37"},codex:{npmPackage:"@zed-industries/codex-acp",binary:"codex-acp",versionSpec:"^0.15"}};Mi=5e4,Bi=5e3,ap=5e3;fp=5*6e4,lp=new Set(["ETIMEDOUT","ECONNRESET","ECONNREFUSED","ENETUNREACH","EAI_AGAIN","ERR_SOCKET_TIMEOUT","ENOTFOUND"]),up=/\b(5\d\d|408|429)\b\s+(Bad Gateway|Service Unavailable|Gateway Timeout|Internal Server Error|Too Many Requests|Request Timeout)/i,xp=/fetch failed|request timed out|socket hang up|network timeout/i;$n=new Map,Pr=new Map,Vn=new Map;B0=6});import{chmod as yp,mkdir as Ep,readFile as bp,rename as j0,writeFile as G0}from"node:fs/promises";import{dirname as Sp}from"node:path";async function Jn(t){try{let e=await bp(t,"utf8");return JSON.parse(e)}catch(e){if(e.code==="ENOENT")return null;throw e}}async function Fi(t,e,r){await Ep(Sp(t),{recursive:!0});let s=`${JSON.stringify(e,null,2)}
12
- `,a=`${t}.tmp-${process.pid}-${Math.random().toString(36).slice(2,10)}`;try{r?.mode!==void 0?await G0(a,s,{encoding:"utf8",mode:r.mode}):await G0(a,s,"utf8"),await j0(a,t),r?.mode!==void 0&&await yp(t,r.mode)}catch(c){await j0(a,a).catch(()=>{});let{rm:f}=await import("node:fs/promises");throw await f(a,{force:!0}).catch(()=>{}),c}}var Ui=dt(()=>{"use strict"});import{promises as K0}from"node:fs";import{homedir as vp}from"node:os";import{sep as Ip,join as Ne,resolve as W0}from"node:path";function te(t){let e=t??vp(),r=Ne(e,".coze"),s=Ne(r,"bridge"),a=Ne(s,"lib");return{cozeRoot:r,bridgeRoot:s,libDir:a,libEntry:Ne(a,"index.js"),binDir:Ne(s,"bin"),pidFile:Ne(s,"bridge.pid"),portFile:Ne(s,"bridge.port"),tokenFile:Ne(s,"bridge.token"),patTokenFile:Ne(s,"pat-token"),logFile:Ne(s,"bridge.log"),installLock:Ne(s,"install.lock"),configFile:Ne(s,"config.json"),agentsRoot:Ne(r,"agents")}}function kt(t,e=te()){let r=Ne(e.agentsRoot,t);return{root:r,config:Ne(r,"config.json"),workspace:Ne(r,"workspace"),logs:Ne(r,"logs")}}async function Nr(t,e){let r=await K0.realpath(W0(t)).catch(()=>null);if(!r)return!1;let s=await K0.realpath(W0(e)).catch(()=>null);if(!s)return!1;let a=process.platform==="win32"?r.toLowerCase():r,c=process.platform==="win32"?s.toLowerCase():s;return a===c||a.startsWith(c+Ip)}var Me=dt(()=>{"use strict"});var ji={};Ko(ji,{AGENT_CONFIG_FILE_MODE:()=>qi,enforceAgentConfigMode:()=>Tp,loadAgentConfig:()=>Ue,persistAgentSessions:()=>Zo,persistAgentSkills:()=>Hi,saveAgentConfig:()=>Ve});import{chmod as Ap,stat as Cp}from"node:fs/promises";function Ue(t,e){return Jn(kt(t,e).config)}function Ve(t,e){return Fi(kt(t.agentId,e).config,t,{mode:qi})}async function Tp(t,e){if(process.platform==="win32")return;let r=kt(t,e).config;try{let s=await Cp(r);if(!s.isFile())return;let a=s.mode&511;a!==qi&&(await Ap(r,qi),$0.warn("agent config mode auto-corrected to 0600",{path:r,from:a.toString(8)}))}catch(s){if(s.code==="ENOENT")return;$0.warn("enforceAgentConfigMode: chmod failed (ignored)",{path:r,err:String(s)})}}async function Zo(t,e,r){let s=await Ue(t,r);s&&(s.sessions=Object.fromEntries(e),await Ve(s,r))}async function Hi(t,e,r){let s=await Ue(t,r);s&&(s.skills=e,await Ve(s,r))}var $0,qi,Yt=dt(()=>{"use strict";Ui();ee();Me();$0=H("agent-config"),qi=384});var Xo=ne((K2,Y0)=>{Y0.exports={LOCHDR:30,LOCSIG:67324752,LOCVER:4,LOCFLG:6,LOCHOW:8,LOCTIM:10,LOCCRC:14,LOCSIZ:18,LOCLEN:22,LOCNAM:26,LOCEXT:28,EXTSIG:134695760,EXTHDR:16,EXTCRC:4,EXTSIZ:8,EXTLEN:12,CENHDR:46,CENSIG:33639248,CENVEM:4,CENVER:6,CENFLG:8,CENHOW:10,CENTIM:12,CENCRC:16,CENSIZ:20,CENLEN:24,CENNAM:28,CENEXT:30,CENCOM:32,CENDSK:34,CENATT:36,CENATX:38,CENOFF:42,ENDHDR:22,ENDSIG:101010256,ENDSUB:8,ENDTOT:10,ENDSIZ:12,ENDOFF:16,ENDCOM:20,END64HDR:20,END64SIG:117853008,END64START:4,END64OFF:8,END64NUMDISKS:16,ZIP64SIG:101075792,ZIP64HDR:56,ZIP64LEAD:12,ZIP64SIZE:4,ZIP64VEM:12,ZIP64VER:14,ZIP64DSK:16,ZIP64DSKDIR:20,ZIP64SUB:24,ZIP64TOT:32,ZIP64SIZB:40,ZIP64OFF:48,ZIP64EXTRA:56,STORED:0,SHRUNK:1,REDUCED1:2,REDUCED2:3,REDUCED3:4,REDUCED4:5,IMPLODED:6,DEFLATED:8,ENHANCED_DEFLATED:9,PKWARE:10,BZIP2:12,LZMA:14,IBM_TERSE:18,IBM_LZ77:19,AES_ENCRYPT:99,FLG_ENC:1,FLG_COMP1:2,FLG_COMP2:4,FLG_DESC:8,FLG_ENH:16,FLG_PATCH:32,FLG_STR:64,FLG_EFS:2048,FLG_MSK:4096,FILE:2,BUFFER:1,NONE:0,EF_ID:0,EF_SIZE:2,ID_ZIP64:1,ID_AVINFO:7,ID_PFS:8,ID_OS2:9,ID_NTFS:10,ID_OPENVMS:12,ID_UNIX:13,ID_FORK:14,ID_PATCH:15,ID_X509_PKCS7:20,ID_X509_CERTID_F:21,ID_X509_CERTID_C:22,ID_STRONGENC:23,ID_RECORD_MGT:24,ID_X509_PKCS7_RL:25,ID_IBM1:101,ID_IBM2:102,ID_POSZIP:18064,EF_ZIP64_OR_32:4294967295,EF_ZIP64_OR_16:65535,EF_ZIP64_SUNCOMP:0,EF_ZIP64_SCOMP:8,EF_ZIP64_RHO:16,EF_ZIP64_DSN:24}});var Ki=ne(Q0=>{var X0={INVALID_LOC:"Invalid LOC header (bad signature)",INVALID_CEN:"Invalid CEN header (bad signature)",INVALID_END:"Invalid END header (bad signature)",DESCRIPTOR_NOT_EXIST:"No descriptor present",DESCRIPTOR_UNKNOWN:"Unknown descriptor format",DESCRIPTOR_FAULTY:"Descriptor data is malformed",NO_DATA:"Nothing to decompress",BAD_CRC:"CRC32 checksum failed {0}",FILE_IN_THE_WAY:"There is a file in the way: {0}",UNKNOWN_METHOD:"Invalid/unsupported compression method",AVAIL_DATA:"inflate::Available inflate data did not terminate",INVALID_DISTANCE:"inflate::Invalid literal/length or distance code in fixed or dynamic block",TO_MANY_CODES:"inflate::Dynamic block code description: too many length or distance codes",INVALID_REPEAT_LEN:"inflate::Dynamic block code description: repeat more than specified lengths",INVALID_REPEAT_FIRST:"inflate::Dynamic block code description: repeat lengths with no first length",INCOMPLETE_CODES:"inflate::Dynamic block code description: code lengths codes incomplete",INVALID_DYN_DISTANCE:"inflate::Dynamic block code description: invalid distance code lengths",INVALID_CODES_LEN:"inflate::Dynamic block code description: invalid literal/length code lengths",INVALID_STORE_BLOCK:"inflate::Stored block length did not match one's complement",INVALID_BLOCK_TYPE:"inflate::Invalid block type (type == 3)",CANT_EXTRACT_FILE:"Could not extract the file",CANT_OVERRIDE:"Target file already exists",DISK_ENTRY_TOO_LARGE:"Number of disk entries is too large",NO_ZIP:"No zip file was loaded",NO_ENTRY:"Entry doesn't exist",DIRECTORY_CONTENT_ERROR:"A directory cannot have content",FILE_NOT_FOUND:'File not found: "{0}"',NOT_IMPLEMENTED:"Not implemented",INVALID_FILENAME:"Invalid filename",INVALID_FORMAT:"Invalid or unsupported zip format. No END header found",INVALID_PASS_PARAM:"Incompatible password parameter",WRONG_PASSWORD:"Wrong Password",COMMENT_TOO_LONG:"Comment is too long",EXTRA_FIELD_PARSE_ERROR:"Extra field parsing error"};function Pp(t){return function(...e){return e.length&&(t=t.replace(/\{(\d)\}/g,(r,s)=>e[s]||"")),new Error("ADM-ZIP: "+t)}}for(let t of Object.keys(X0))Q0[t]=Pp(X0[t])});var id=ne(($2,rd)=>{var Lp=ae("fs"),be=ae("path"),ed=Xo(),Np=Ki(),Mp=typeof process=="object"&&process.platform==="win32",td=t=>typeof t=="object"&&t!==null,nd=new Uint32Array(256).map((t,e)=>{for(let r=0;r<8;r++)(e&1)!==0?e=3988292384^e>>>1:e>>>=1;return e>>>0});function he(t){this.sep=be.sep,this.fs=Lp,td(t)&&td(t.fs)&&typeof t.fs.statSync=="function"&&(this.fs=t.fs)}rd.exports=he;he.prototype.makeDir=function(t){let e=this;function r(s){let a=s.split(e.sep)[0];s.split(e.sep).forEach(function(c){if(!(!c||c.substr(-1,1)===":")){a+=e.sep+c;var f;try{f=e.fs.statSync(a)}catch(l){if(l.message&&l.message.startsWith("ENOENT"))e.fs.mkdirSync(a);else throw l}if(f&&f.isFile())throw Np.FILE_IN_THE_WAY(`"${a}"`)}})}r(t)};he.prototype.writeFileTo=function(t,e,r,s){let a=this;if(a.fs.existsSync(t)){if(!r)return!1;var c=a.fs.statSync(t);if(c.isDirectory())return!1}var f=be.dirname(t);a.fs.existsSync(f)||a.makeDir(f);var l;try{l=a.fs.openSync(t,"w",438)}catch{a.fs.chmodSync(t,438),l=a.fs.openSync(t,"w",438)}if(l)try{a.fs.writeSync(l,e,0,e.length,0)}finally{a.fs.closeSync(l)}return a.fs.chmodSync(t,s||438),!0};he.prototype.writeFileToAsync=function(t,e,r,s,a){typeof s=="function"&&(a=s,s=void 0);let c=this;c.fs.exists(t,function(f){if(f&&!r)return a(!1);c.fs.stat(t,function(l,x){if(f&&x.isDirectory())return a(!1);var h=be.dirname(t);c.fs.exists(h,function(m){m||c.makeDir(h),c.fs.open(t,"w",438,function(E,C){E?c.fs.chmod(t,438,function(){c.fs.open(t,"w",438,function(_,y){c.fs.write(y,e,0,e.length,0,function(){c.fs.close(y,function(){c.fs.chmod(t,s||438,function(){a(!0)})})})})}):C?c.fs.write(C,e,0,e.length,0,function(){c.fs.close(C,function(){c.fs.chmod(t,s||438,function(){a(!0)})})}):c.fs.chmod(t,s||438,function(){a(!0)})})})})})};he.prototype.findFiles=function(t){let e=this;function r(s,a,c){typeof a=="boolean"&&(c=a,a=void 0);let f=[];return e.fs.readdirSync(s).forEach(function(l){let x=be.join(s,l),h=e.fs.statSync(x);(!a||a.test(x))&&f.push(be.normalize(x)+(h.isDirectory()?e.sep:"")),h.isDirectory()&&c&&(f=f.concat(r(x,a,c)))}),f}return r(t,void 0,!0)};he.prototype.findFilesAsync=function(t,e){let r=this,s=[];r.fs.readdir(t,function(a,c){if(a)return e(a);let f=c.length;if(!f)return e(null,s);c.forEach(function(l){l=be.join(t,l),r.fs.stat(l,function(x,h){if(x)return e(x);h&&(s.push(be.normalize(l)+(h.isDirectory()?r.sep:"")),h.isDirectory()?r.findFilesAsync(l,function(m,E){if(m)return e(m);s=s.concat(E),--f||e(null,s)}):--f||e(null,s))})})})};he.prototype.getAttributes=function(){};he.prototype.setAttributes=function(){};he.crc32update=function(t,e){return nd[(t^e)&255]^t>>>8};he.crc32=function(t){typeof t=="string"&&(t=Buffer.from(t,"utf8"));let e=t.length,r=-1;for(let s=0;s<e;)r=he.crc32update(r,t[s++]);return~r>>>0};he.methodToString=function(t){switch(t){case ed.STORED:return"STORED ("+t+")";case ed.DEFLATED:return"DEFLATED ("+t+")";default:return"UNSUPPORTED ("+t+")"}};he.canonical=function(t){if(!t)return"";let e=be.posix.normalize("/"+t.split("\\").join("/"));return be.join(".",e)};he.zipnamefix=function(t){if(!t)return"";let e=be.posix.normalize("/"+t.split("\\").join("/"));return be.posix.join(".",e)};he.findLast=function(t,e){if(!Array.isArray(t))throw new TypeError("arr is not array");let r=t.length>>>0;for(let s=r-1;s>=0;s--)if(e(t[s],s,t))return t[s]};he.sanitize=function(t,e){t=be.resolve(be.normalize(t));for(var r=e.split("/"),s=0,a=r.length;s<a;s++){var c=be.normalize(be.join(t,r.slice(s,a).join(be.sep)));if(c.indexOf(t)===0)return c}return be.normalize(be.join(t,be.basename(e)))};he.toBuffer=function(e,r){return Buffer.isBuffer(e)?e:e instanceof Uint8Array?Buffer.from(e):typeof e=="string"?r(e):Buffer.alloc(0)};he.readBigUInt64LE=function(t,e){let r=t.readUInt32LE(e);return t.readUInt32LE(e+4)*4294967296+r};he.fromDOS2Date=function(t){return new Date((t>>25&127)+1980,Math.max((t>>21&15)-1,0),Math.max(t>>16&31,1),t>>11&31,t>>5&63,(t&31)<<1)};he.fromDate2DOS=function(t){let e=0,r=0;return t.getFullYear()>1979&&(e=(t.getFullYear()-1980&127)<<9|t.getMonth()+1<<5|t.getDate(),r=t.getHours()<<11|t.getMinutes()<<5|t.getSeconds()>>1),e<<16|r};he.isWin=Mp;he.crcTable=nd});var od=ne((V2,sd)=>{var Bp=ae("path");sd.exports=function(t,{fs:e}){var r=t||"",s=c(),a=null;function c(){return{directory:!1,readonly:!1,hidden:!1,executable:!1,mtime:0,atime:0}}return r&&e.existsSync(r)?(a=e.statSync(r),s.directory=a.isDirectory(),s.mtime=a.mtime,s.atime=a.atime,s.executable=(73&a.mode)!==0,s.readonly=(128&a.mode)===0,s.hidden=Bp.basename(r)[0]==="."):console.warn("Invalid path: "+r),{get directory(){return s.directory},get readOnly(){return s.readonly},get hidden(){return s.hidden},get mtime(){return s.mtime},get atime(){return s.atime},get executable(){return s.executable},decodeAttributes:function(){},encodeAttributes:function(){},toJSON:function(){return{path:r,isDirectory:s.directory,isReadOnly:s.readonly,isHidden:s.hidden,isExecutable:s.executable,mTime:s.mtime,aTime:s.atime}},toString:function(){return JSON.stringify(this.toJSON(),null," ")}}}});var cd=ne((J2,ad)=>{ad.exports={efs:!0,encode:t=>Buffer.from(t,"utf8"),decode:t=>t.toString("utf8")}});var Xn=ne((Z2,Yn)=>{Yn.exports=id();Yn.exports.Constants=Xo();Yn.exports.Errors=Ki();Yn.exports.FileAttr=od();Yn.exports.decoder=cd()});var fd=ne((Y2,dd)=>{var Xt=Xn(),q=Xt.Constants;dd.exports=function(){var t=20,e=10,r=0,s=0,a=0,c=0,f=0,l=0,x=0,h=0,m=0,E=0,C=0,_=0,y=0;t|=Xt.isWin?2560:768,r|=q.FLG_EFS;let v={extraLen:0},I=w=>Math.max(0,w)>>>0,R=w=>Math.max(0,w)&65535,L=w=>Math.max(0,w)&255;return a=Xt.fromDate2DOS(new Date),{get made(){return t},set made(w){t=w},get version(){return e},set version(w){e=w},get flags(){return r},set flags(w){r=w},get flags_efs(){return(r&q.FLG_EFS)>0},set flags_efs(w){w?r|=q.FLG_EFS:r&=~q.FLG_EFS},get flags_desc(){return(r&q.FLG_DESC)>0},set flags_desc(w){w?r|=q.FLG_DESC:r&=~q.FLG_DESC},get method(){return s},set method(w){switch(w){case q.STORED:this.version=10;case q.DEFLATED:default:this.version=20}s=w},get time(){return Xt.fromDOS2Date(this.timeval)},set time(w){w=new Date(w),this.timeval=Xt.fromDate2DOS(w)},get timeval(){return a},set timeval(w){a=I(w)},get timeHighByte(){return L(a>>>8)},get crc(){return c},set crc(w){c=I(w)},get compressedSize(){return f},set compressedSize(w){f=I(w)},get size(){return l},set size(w){l=I(w)},get fileNameLength(){return x},set fileNameLength(w){x=w},get extraLength(){return h},set extraLength(w){h=w},get extraLocalLength(){return v.extraLen},set extraLocalLength(w){v.extraLen=w},get commentLength(){return m},set commentLength(w){m=w},get diskNumStart(){return E},set diskNumStart(w){E=I(w)},get inAttr(){return C},set inAttr(w){C=I(w)},get attr(){return _},set attr(w){_=I(w)},get fileAttr(){return(_||0)>>16&4095},get offset(){return y},set offset(w){y=I(w)},get encrypted(){return(r&q.FLG_ENC)===q.FLG_ENC},get centralHeaderSize(){return q.CENHDR+x+h+m},get realDataOffset(){return y+q.LOCHDR+v.fnameLen+v.extraLen},get localHeader(){return v},loadLocalHeaderFromBinary:function(w){var A=w.slice(y,y+q.LOCHDR);if(A.readUInt32LE(0)!==q.LOCSIG)throw Xt.Errors.INVALID_LOC();v.version=A.readUInt16LE(q.LOCVER),v.flags=A.readUInt16LE(q.LOCFLG),v.flags_desc=(v.flags&q.FLG_DESC)>0,v.method=A.readUInt16LE(q.LOCHOW),v.time=A.readUInt32LE(q.LOCTIM),v.crc=A.readUInt32LE(q.LOCCRC),v.compressedSize=A.readUInt32LE(q.LOCSIZ),v.size=A.readUInt32LE(q.LOCLEN),v.fnameLen=A.readUInt16LE(q.LOCNAM),v.extraLen=A.readUInt16LE(q.LOCEXT);let k=y+q.LOCHDR+v.fnameLen,F=k+v.extraLen;return w.slice(k,F)},loadFromBinary:function(w){if(w.length!==q.CENHDR||w.readUInt32LE(0)!==q.CENSIG)throw Xt.Errors.INVALID_CEN();t=w.readUInt16LE(q.CENVEM),e=w.readUInt16LE(q.CENVER),r=w.readUInt16LE(q.CENFLG),s=w.readUInt16LE(q.CENHOW),a=w.readUInt32LE(q.CENTIM),c=w.readUInt32LE(q.CENCRC),f=w.readUInt32LE(q.CENSIZ),l=w.readUInt32LE(q.CENLEN),x=w.readUInt16LE(q.CENNAM),h=w.readUInt16LE(q.CENEXT),m=w.readUInt16LE(q.CENCOM),E=w.readUInt16LE(q.CENDSK),C=w.readUInt16LE(q.CENATT),_=w.readUInt32LE(q.CENATX),y=w.readUInt32LE(q.CENOFF)},localHeaderToBinary:function(){var w=Buffer.alloc(q.LOCHDR);return w.writeUInt32LE(q.LOCSIG,0),w.writeUInt16LE(e,q.LOCVER),w.writeUInt16LE(r,q.LOCFLG),w.writeUInt16LE(s,q.LOCHOW),w.writeUInt32LE(a,q.LOCTIM),w.writeUInt32LE(c,q.LOCCRC),w.writeUInt32LE(f,q.LOCSIZ),w.writeUInt32LE(l,q.LOCLEN),w.writeUInt16LE(x,q.LOCNAM),w.writeUInt16LE(v.extraLen,q.LOCEXT),w},centralHeaderToBinary:function(){var w=Buffer.alloc(q.CENHDR+x+h+m);return w.writeUInt32LE(q.CENSIG,0),w.writeUInt16LE(t,q.CENVEM),w.writeUInt16LE(e,q.CENVER),w.writeUInt16LE(r,q.CENFLG),w.writeUInt16LE(s,q.CENHOW),w.writeUInt32LE(a,q.CENTIM),w.writeUInt32LE(c,q.CENCRC),w.writeUInt32LE(f,q.CENSIZ),w.writeUInt32LE(l,q.CENLEN),w.writeUInt16LE(x,q.CENNAM),w.writeUInt16LE(h,q.CENEXT),w.writeUInt16LE(m,q.CENCOM),w.writeUInt16LE(E,q.CENDSK),w.writeUInt16LE(C,q.CENATT),w.writeUInt32LE(_,q.CENATX),w.writeUInt32LE(y,q.CENOFF),w},toJSON:function(){let w=function(A){return A+" bytes"};return{made:t,version:e,flags:r,method:Xt.methodToString(s),time:this.time,crc:"0x"+c.toString(16).toUpperCase(),compressedSize:w(f),size:w(l),fileNameLength:w(x),extraLength:w(h),commentLength:w(m),diskNumStart:E,inAttr:C,attr:_,offset:y,centralHeaderSize:w(q.CENHDR+x+h+m)}},toString:function(){return JSON.stringify(this.toJSON(),null," ")}}}});var ud=ne((X2,ld)=>{var Qn=Xn(),le=Qn.Constants;ld.exports=function(){var t=0,e=0,r=0,s=0,a=0;return{get diskEntries(){return t},set diskEntries(c){t=e=c},get totalEntries(){return e},set totalEntries(c){e=t=c},get size(){return r},set size(c){r=c},get offset(){return s},set offset(c){s=c},get commentLength(){return a},set commentLength(c){a=c},get mainHeaderSize(){return le.ENDHDR+a},loadFromBinary:function(c){if((c.length!==le.ENDHDR||c.readUInt32LE(0)!==le.ENDSIG)&&(c.length<le.ZIP64HDR||c.readUInt32LE(0)!==le.ZIP64SIG))throw Qn.Errors.INVALID_END();c.readUInt32LE(0)===le.ENDSIG?(t=c.readUInt16LE(le.ENDSUB),e=c.readUInt16LE(le.ENDTOT),r=c.readUInt32LE(le.ENDSIZ),s=c.readUInt32LE(le.ENDOFF),a=c.readUInt16LE(le.ENDCOM)):(t=Qn.readBigUInt64LE(c,le.ZIP64SUB),e=Qn.readBigUInt64LE(c,le.ZIP64TOT),r=Qn.readBigUInt64LE(c,le.ZIP64SIZE),s=Qn.readBigUInt64LE(c,le.ZIP64OFF),a=0)},toBinary:function(){var c=Buffer.alloc(le.ENDHDR+a);return c.writeUInt32LE(le.ENDSIG,0),c.writeUInt32LE(0,4),c.writeUInt16LE(t,le.ENDSUB),c.writeUInt16LE(e,le.ENDTOT),c.writeUInt32LE(r,le.ENDSIZ),c.writeUInt32LE(s,le.ENDOFF),c.writeUInt16LE(a,le.ENDCOM),c.fill(" ",le.ENDHDR),c},toJSON:function(){let c=function(f,l){let x=f.toString(16).toUpperCase();for(;x.length<l;)x="0"+x;return"0x"+x};return{diskEntries:t,totalEntries:e,size:r+" bytes",offset:c(s,4),commentLength:a}},toString:function(){return JSON.stringify(this.toJSON(),null," ")}}}});var ea=ne(Qo=>{Qo.EntryHeader=fd();Qo.MainHeader=ud()});var hd=ne((eS,xd)=>{xd.exports=function(t){var e=ae("zlib"),r={chunkSize:(parseInt(t.length/1024)+1)*1024};return{deflate:function(){return e.deflateRawSync(t,r)},deflateAsync:function(s){var a=e.createDeflateRaw(r),c=[],f=0;a.on("data",function(l){c.push(l),f+=l.length}),a.on("end",function(){var l=Buffer.alloc(f),x=0;l.fill(0);for(var h=0;h<c.length;h++){var m=c[h];m.copy(l,x),x+=m.length}s&&s(l)}),a.end(t)}}}});var gd=ne((tS,pd)=>{var zp=+(process.versions?process.versions.node:"").split(".")[0]||0;pd.exports=function(t,e){var r=ae("zlib");let s=zp>=15&&e>0?{maxOutputLength:e}:{};return{inflate:function(){return r.inflateRawSync(t,s)},inflateAsync:function(a){var c=r.createInflateRaw(s),f=[],l=0;c.on("data",function(x){f.push(x),l+=x.length}),c.on("end",function(){var x=Buffer.alloc(l),h=0;x.fill(0);for(var m=0;m<f.length;m++){var E=f[m];E.copy(x,h),h+=E.length}a&&a(x)}),c.end(t)}}}});var Ed=ne((nS,yd)=>{"use strict";var{randomFillSync:md}=ae("crypto"),Fp=Ki(),Up=new Uint32Array(256).map((t,e)=>{for(let r=0;r<8;r++)(e&1)!==0?e=e>>>1^3988292384:e>>>=1;return e>>>0}),_d=(t,e)=>Math.imul(t,e)>>>0,wd=(t,e)=>Up[(t^e)&255]^t>>>8,Mr=()=>typeof md=="function"?md(Buffer.alloc(12)):Mr.node();Mr.node=()=>{let t=Buffer.alloc(12),e=t.length;for(let r=0;r<e;r++)t[r]=Math.random()*256&255;return t};var Wi={genSalt:Mr};function $i(t){let e=Buffer.isBuffer(t)?t:Buffer.from(t);this.keys=new Uint32Array([305419896,591751049,878082192]);for(let r=0;r<e.length;r++)this.updateKeys(e[r])}$i.prototype.updateKeys=function(t){let e=this.keys;return e[0]=wd(e[0],t),e[1]+=e[0]&255,e[1]=_d(e[1],134775813)+1,e[2]=wd(e[2],e[1]>>>24),t};$i.prototype.next=function(){let t=(this.keys[2]|2)>>>0;return _d(t,t^1)>>8&255};function qp(t){let e=new $i(t);return function(r){let s=Buffer.alloc(r.length),a=0;for(let c of r)s[a++]=e.updateKeys(c^e.next());return s}}function Hp(t){let e=new $i(t);return function(r,s,a=0){s||(s=Buffer.alloc(r.length));for(let c of r){let f=e.next();s[a++]=c^f,e.updateKeys(c)}return s}}function jp(t,e,r){if(!t||!Buffer.isBuffer(t)||t.length<12)return Buffer.alloc(0);let s=qp(r),a=s(t.slice(0,12)),c=(e.flags&8)===8?e.timeHighByte:e.crc>>>24;if(a[11]!==c)throw Fp.WRONG_PASSWORD();return s(t.slice(12))}function Gp(t){Buffer.isBuffer(t)&&t.length>=12?Wi.genSalt=function(){return t.slice(0,12)}:t==="node"?Wi.genSalt=Mr.node:Wi.genSalt=Mr}function Kp(t,e,r,s=!1){t==null&&(t=Buffer.alloc(0)),Buffer.isBuffer(t)||(t=Buffer.from(t.toString()));let a=Hp(r),c=Wi.genSalt();c[11]=e.crc>>>24&255,s&&(c[10]=e.crc>>>16&255);let f=Buffer.alloc(t.length+12);return a(c,f),a(t,f,12)}yd.exports={decrypt:jp,encrypt:Kp,_salter:Gp}});var bd=ne(Vi=>{Vi.Deflater=hd();Vi.Inflater=gd();Vi.ZipCrypto=Ed()});var na=ne((iS,Sd)=>{var re=Xn(),Wp=ea(),pe=re.Constants,ta=bd();Sd.exports=function(t,e){var r=new Wp.EntryHeader,s=Buffer.alloc(0),a=Buffer.alloc(0),c=!1,f=null,l=Buffer.alloc(0),x=Buffer.alloc(0),h=!0;let m=t,E=typeof m.decoder=="object"?m.decoder:re.decoder;h=E.hasOwnProperty("efs")?E.efs:!1;function C(){return!e||!(e instanceof Uint8Array)?Buffer.alloc(0):(x=r.loadLocalHeaderFromBinary(e),e.slice(r.realDataOffset,r.realDataOffset+r.compressedSize))}function _(w){if(!r.flags_desc&&!r.localHeader.flags_desc){if(re.crc32(w)!==r.localHeader.crc)return!1}else{let A={},k=r.realDataOffset+r.compressedSize;if(e.readUInt32LE(k)==pe.LOCSIG||e.readUInt32LE(k)==pe.CENSIG)throw re.Errors.DESCRIPTOR_NOT_EXIST();if(e.readUInt32LE(k)==pe.EXTSIG)A.crc=e.readUInt32LE(k+pe.EXTCRC),A.compressedSize=e.readUInt32LE(k+pe.EXTSIZ),A.size=e.readUInt32LE(k+pe.EXTLEN);else if(e.readUInt16LE(k+12)===19280)A.crc=e.readUInt32LE(k+pe.EXTCRC-4),A.compressedSize=e.readUInt32LE(k+pe.EXTSIZ-4),A.size=e.readUInt32LE(k+pe.EXTLEN-4);else throw re.Errors.DESCRIPTOR_UNKNOWN();if(A.compressedSize!==r.compressedSize||A.size!==r.size||A.crc!==r.crc)throw re.Errors.DESCRIPTOR_FAULTY();if(re.crc32(w)!==A.crc)return!1}return!0}function y(w,A,k){if(typeof A>"u"&&typeof w=="string"&&(k=w,w=void 0),c)return w&&A&&A(Buffer.alloc(0),re.Errors.DIRECTORY_CONTENT_ERROR()),Buffer.alloc(0);var F=C();if(F.length===0)return w&&A&&A(F),F;if(r.encrypted){if(typeof k!="string"&&!Buffer.isBuffer(k))throw re.Errors.INVALID_PASS_PARAM();F=ta.ZipCrypto.decrypt(F,r,k)}var z=Buffer.alloc(r.size);switch(r.method){case re.Constants.STORED:if(F.copy(z),_(z))return w&&A&&A(z),z;throw w&&A&&A(z,re.Errors.BAD_CRC()),re.Errors.BAD_CRC();case re.Constants.DEFLATED:var O=new ta.Inflater(F,r.size);if(w)O.inflateAsync(function(N){N.copy(N,0),A&&(_(N)?A(N):A(N,re.Errors.BAD_CRC()))});else{if(O.inflate(z).copy(z,0),!_(z))throw re.Errors.BAD_CRC(`"${E.decode(s)}"`);return z}break;default:throw w&&A&&A(Buffer.alloc(0),re.Errors.UNKNOWN_METHOD()),re.Errors.UNKNOWN_METHOD()}}function v(w,A){if((!f||!f.length)&&Buffer.isBuffer(e))return w&&A&&A(C()),C();if(f.length&&!c){var k;switch(r.method){case re.Constants.STORED:return r.compressedSize=r.size,k=Buffer.alloc(f.length),f.copy(k),w&&A&&A(k),k;default:case re.Constants.DEFLATED:var F=new ta.Deflater(f);if(w)F.deflateAsync(function(O){k=Buffer.alloc(O.length),r.compressedSize=O.length,O.copy(k),A&&A(k)});else{var z=F.deflate();return r.compressedSize=z.length,z}F=null;break}}else if(w&&A)A(Buffer.alloc(0));else return Buffer.alloc(0)}function I(w,A){return re.readBigUInt64LE(w,A)}function R(w){try{for(var A=0,k,F,z;A+4<w.length;)k=w.readUInt16LE(A),A+=2,F=w.readUInt16LE(A),A+=2,z=w.slice(A,A+F),A+=F,pe.ID_ZIP64===k&&L(z)}catch{throw re.Errors.EXTRA_FIELD_PARSE_ERROR()}}function L(w){var A,k,F,z;w.length>=pe.EF_ZIP64_SCOMP&&(A=I(w,pe.EF_ZIP64_SUNCOMP),r.size===pe.EF_ZIP64_OR_32&&(r.size=A)),w.length>=pe.EF_ZIP64_RHO&&(k=I(w,pe.EF_ZIP64_SCOMP),r.compressedSize===pe.EF_ZIP64_OR_32&&(r.compressedSize=k)),w.length>=pe.EF_ZIP64_DSN&&(F=I(w,pe.EF_ZIP64_RHO),r.offset===pe.EF_ZIP64_OR_32&&(r.offset=F)),w.length>=pe.EF_ZIP64_DSN+4&&(z=w.readUInt32LE(pe.EF_ZIP64_DSN),r.diskNumStart===pe.EF_ZIP64_OR_16&&(r.diskNumStart=z))}return{get entryName(){return E.decode(s)},get rawEntryName(){return s},set entryName(w){s=re.toBuffer(w,E.encode);var A=s[s.length-1];c=A===47||A===92,r.fileNameLength=s.length},get efs(){return typeof h=="function"?h(this.entryName):h},get extra(){return l},set extra(w){l=w,r.extraLength=w.length,R(w)},get comment(){return E.decode(a)},set comment(w){if(a=re.toBuffer(w,E.encode),r.commentLength=a.length,a.length>65535)throw re.Errors.COMMENT_TOO_LONG()},get name(){var w=E.decode(s);return c?w.substr(w.length-1).split("/").pop():w.split("/").pop()},get isDirectory(){return c},getCompressedData:function(){return v(!1,null)},getCompressedDataAsync:function(w){v(!0,w)},setData:function(w){f=re.toBuffer(w,re.decoder.encode),!c&&f.length?(r.size=f.length,r.method=re.Constants.DEFLATED,r.crc=re.crc32(w),r.changed=!0):r.method=re.Constants.STORED},getData:function(w){return r.changed?f:y(!1,null,w)},getDataAsync:function(w,A){r.changed?w(f):y(!0,w,A)},set attr(w){r.attr=w},get attr(){return r.attr},set header(w){r.loadFromBinary(w)},get header(){return r},packCentralHeader:function(){r.flags_efs=this.efs,r.extraLength=l.length;var w=r.centralHeaderToBinary(),A=re.Constants.CENHDR;return s.copy(w,A),A+=s.length,l.copy(w,A),A+=r.extraLength,a.copy(w,A),w},packLocalHeader:function(){let w=0;r.flags_efs=this.efs,r.extraLocalLength=x.length;let A=r.localHeaderToBinary(),k=Buffer.alloc(A.length+s.length+r.extraLocalLength);return A.copy(k,w),w+=A.length,s.copy(k,w),w+=s.length,x.copy(k,w),w+=x.length,k},toJSON:function(){let w=function(A){return"<"+(A&&A.length+" bytes buffer"||"null")+">"};return{entryName:this.entryName,name:this.name,comment:this.comment,isDirectory:this.isDirectory,header:r.toJSON(),compressedData:w(e),data:w(f)}},toString:function(){return JSON.stringify(this.toJSON(),null," ")}}}});var Ad=ne((sS,Id)=>{var vd=na(),$p=ea(),Be=Xn();Id.exports=function(t,e){var r=[],s={},a=Buffer.alloc(0),c=new $p.MainHeader,f=!1,l=null;let x=new Set,h=e,{noSort:m,decoder:E}=h;t?y(h.readEntries):f=!0;function C(){let I=new Set;for(let R of Object.keys(s)){let L=R.split("/");if(L.pop(),!!L.length)for(let w=0;w<L.length;w++){let A=L.slice(0,w+1).join("/")+"/";I.add(A)}}for(let R of I)if(!(R in s)){let L=new vd(h);L.entryName=R,L.attr=16,L.temporary=!0,r.push(L),s[L.entryName]=L,x.add(L)}}function _(){if(f=!0,s={},c.diskEntries>(t.length-c.offset)/Be.Constants.CENHDR)throw Be.Errors.DISK_ENTRY_TOO_LARGE();r=new Array(c.diskEntries);for(var I=c.offset,R=0;R<r.length;R++){var L=I,w=new vd(h,t);w.header=t.slice(L,L+=Be.Constants.CENHDR),w.entryName=t.slice(L,L+=w.header.fileNameLength),w.header.extraLength&&(w.extra=t.slice(L,L+=w.header.extraLength)),w.header.commentLength&&(w.comment=t.slice(L,L+w.header.commentLength)),I+=w.header.centralHeaderSize,r[R]=w,s[w.entryName]=w}x.clear(),C()}function y(I){var R=t.length-Be.Constants.ENDHDR,L=Math.max(0,R-65535),w=L,A=t.length,k=-1,F=0;for(typeof h.trailingSpace=="boolean"&&h.trailingSpace&&(L=0),R;R>=w;R--)if(t[R]===80){if(t.readUInt32LE(R)===Be.Constants.ENDSIG){k=R,F=R,A=R+Be.Constants.ENDHDR,w=R-Be.Constants.END64HDR;continue}if(t.readUInt32LE(R)===Be.Constants.END64SIG){w=L;continue}if(t.readUInt32LE(R)===Be.Constants.ZIP64SIG){k=R,A=R+Be.readBigUInt64LE(t,R+Be.Constants.ZIP64SIZE)+Be.Constants.ZIP64LEAD;break}}if(k==-1)throw Be.Errors.INVALID_FORMAT();c.loadFromBinary(t.slice(k,A)),c.commentLength&&(a=t.slice(F+Be.Constants.ENDHDR)),I&&_()}function v(){r.length>1&&!m&&r.sort((I,R)=>I.entryName.toLowerCase().localeCompare(R.entryName.toLowerCase()))}return{get entries(){return f||_(),r.filter(I=>!x.has(I))},get comment(){return E.decode(a)},set comment(I){a=Be.toBuffer(I,E.encode),c.commentLength=a.length},getEntryCount:function(){return f?r.length:c.diskEntries},forEach:function(I){this.entries.forEach(I)},getEntry:function(I){return f||_(),s[I]||null},setEntry:function(I){f||_(),r.push(I),s[I.entryName]=I,c.totalEntries=r.length},deleteFile:function(I,R=!0){f||_();let L=s[I];this.getEntryChildren(L,R).map(A=>A.entryName).forEach(this.deleteEntry)},deleteEntry:function(I){f||_();let R=s[I],L=r.indexOf(R);L>=0&&(r.splice(L,1),delete s[I],c.totalEntries=r.length)},getEntryChildren:function(I,R=!0){if(f||_(),typeof I=="object")if(I.isDirectory&&R){let L=[],w=I.entryName;for(let A of r)A.entryName.startsWith(w)&&L.push(A);return L}else return[I];return[]},getChildCount:function(I){if(I&&I.isDirectory){let R=this.getEntryChildren(I);return R.includes(I)?R.length-1:R.length}return 0},compressToBuffer:function(){f||_(),v();let I=[],R=[],L=0,w=0;c.size=0,c.offset=0;let A=0;for(let z of this.entries){let O=z.getCompressedData();z.header.offset=w;let N=z.packLocalHeader(),U=N.length+O.length;w+=U,I.push(N),I.push(O);let W=z.packCentralHeader();R.push(W),c.size+=W.length,L+=U+W.length,A++}L+=c.mainHeaderSize,c.offset=w,c.totalEntries=A,w=0;let k=Buffer.alloc(L);for(let z of I)z.copy(k,w),w+=z.length;for(let z of R)z.copy(k,w),w+=z.length;let F=c.toBinary();return a&&a.copy(F,Be.Constants.ENDHDR),F.copy(k,w),t=k,f=!1,k},toAsyncBuffer:function(I,R,L,w){try{f||_(),v();let A=[],k=[],F=0,z=0,O=0;c.size=0,c.offset=0;let N=function(U){if(U.length>0){let W=U.shift(),se=W.entryName+W.extra.toString();L&&L(se),W.getCompressedDataAsync(function(fe){w&&w(se),W.header.offset=z;let we=W.packLocalHeader(),Le=we.length+fe.length;z+=Le,A.push(we),A.push(fe);let ot=W.packCentralHeader();k.push(ot),c.size+=ot.length,F+=Le+ot.length,O++,N(U)})}else{F+=c.mainHeaderSize,c.offset=z,c.totalEntries=O,z=0;let W=Buffer.alloc(F);A.forEach(function(fe){fe.copy(W,z),z+=fe.length}),k.forEach(function(fe){fe.copy(W,z),z+=fe.length});let se=c.toBinary();a&&a.copy(se,Be.Constants.ENDHDR),se.copy(W,z),t=W,f=!1,I(W)}};N(Array.from(this.entries))}catch(A){R(A)}}}}});var Dd=ne((oS,Td)=>{var xe=Xn(),ue=ae("path"),Vp=na(),Jp=Ad(),En=(...t)=>xe.findLast(t,e=>typeof e=="boolean"),Cd=(...t)=>xe.findLast(t,e=>typeof e=="string"),Zp=(...t)=>xe.findLast(t,e=>typeof e=="function"),Yp={noSort:!1,readEntries:!1,method:xe.Constants.NONE,fs:null};Td.exports=function(t,e){let r=null,s=Object.assign(Object.create(null),Yp);t&&typeof t=="object"&&(t instanceof Uint8Array||(Object.assign(s,t),t=s.input?s.input:void 0,s.input&&delete s.input),Buffer.isBuffer(t)&&(r=t,s.method=xe.Constants.BUFFER,t=void 0)),Object.assign(s,e);let a=new xe(s);if((typeof s.decoder!="object"||typeof s.decoder.encode!="function"||typeof s.decoder.decode!="function")&&(s.decoder=xe.decoder),t&&typeof t=="string")if(a.fs.existsSync(t))s.method=xe.Constants.FILE,s.filename=t,r=a.fs.readFileSync(t);else throw xe.Errors.INVALID_FILENAME();let c=new Jp(r,s),{canonical:f,sanitize:l,zipnamefix:x}=xe;function h(_){if(_&&c){var y;if(typeof _=="string"&&(y=c.getEntry(ue.posix.normalize(_))),typeof _=="object"&&typeof _.entryName<"u"&&typeof _.header<"u"&&(y=c.getEntry(_.entryName)),y)return y}return null}function m(_){let{join:y,normalize:v,sep:I}=ue.posix;return y(ue.isAbsolute(_)?"/":".",v(I+_.split("\\").join(I)+I))}function E(_){return _ instanceof RegExp?(function(y){return function(v){return y.test(v)}})(_):typeof _!="function"?()=>!0:_}let C=(_,y)=>{let v=y.slice(-1);return v=v===a.sep?a.sep:"",ue.relative(_,y)+v};return{readFile:function(_,y){var v=h(_);return v&&v.getData(y)||null},childCount:function(_){let y=h(_);if(y)return c.getChildCount(y)},readFileAsync:function(_,y){var v=h(_);v?v.getDataAsync(y):y(null,"getEntry failed for:"+_)},readAsText:function(_,y){var v=h(_);if(v){var I=v.getData();if(I&&I.length)return I.toString(y||"utf8")}return""},readAsTextAsync:function(_,y,v){var I=h(_);I?I.getDataAsync(function(R,L){if(L){y(R,L);return}R&&R.length?y(R.toString(v||"utf8")):y("")}):y("")},deleteFile:function(_,y=!0){var v=h(_);v&&c.deleteFile(v.entryName,y)},deleteEntry:function(_){var y=h(_);y&&c.deleteEntry(y.entryName)},addZipComment:function(_){c.comment=_},getZipComment:function(){return c.comment||""},addZipEntryComment:function(_,y){var v=h(_);v&&(v.comment=y)},getZipEntryComment:function(_){var y=h(_);return y&&y.comment||""},updateFile:function(_,y){var v=h(_);v&&v.setData(y)},addLocalFile:function(_,y,v,I){if(a.fs.existsSync(_)){y=y?m(y):"";let R=ue.win32.basename(ue.win32.normalize(_));y+=v||R;let L=a.fs.statSync(_),w=L.isFile()?a.fs.readFileSync(_):Buffer.alloc(0);L.isDirectory()&&(y+=a.sep),this.addFile(y,w,I,L)}else throw xe.Errors.FILE_NOT_FOUND(_)},addLocalFileAsync:function(_,y){_=typeof _=="object"?_:{localPath:_};let v=ue.resolve(_.localPath),{comment:I}=_,{zipPath:R,zipName:L}=_,w=this;a.fs.stat(v,function(A,k){if(A)return y(A,!1);R=R?m(R):"";let F=ue.win32.basename(ue.win32.normalize(v));if(R+=L||F,k.isFile())a.fs.readFile(v,function(z,O){return z?y(z,!1):(w.addFile(R,O,I,k),setImmediate(y,void 0,!0))});else if(k.isDirectory())return R+=a.sep,w.addFile(R,Buffer.alloc(0),I,k),setImmediate(y,void 0,!0)})},addLocalFolder:function(_,y,v){if(v=E(v),y=y?m(y):"",_=ue.normalize(_),a.fs.existsSync(_)){let I=a.findFiles(_),R=this;if(I.length)for(let L of I){let w=ue.join(y,C(_,L));v(w)&&R.addLocalFile(L,ue.dirname(w))}}else throw xe.Errors.FILE_NOT_FOUND(_)},addLocalFolderAsync:function(_,y,v,I){I=E(I),v=v?m(v):"",_=ue.normalize(_);var R=this;a.fs.open(_,"r",function(L){if(L&&L.code==="ENOENT")y(void 0,xe.Errors.FILE_NOT_FOUND(_));else if(L)y(void 0,L);else{var w=a.findFiles(_),A=-1,k=function(){if(A+=1,A<w.length){var F=w[A],z=C(_,F).split("\\").join("/");z=z.normalize("NFD").replace(/[\u0300-\u036f]/g,"").replace(/[^\x20-\x7E]/g,""),I(z)?a.fs.stat(F,function(O,N){O&&y(void 0,O),N.isFile()?a.fs.readFile(F,function(U,W){U?y(void 0,U):(R.addFile(v+z,W,"",N),k())}):(R.addFile(v+z+"/",Buffer.alloc(0),"",N),k())}):process.nextTick(()=>{k()})}else y(!0,void 0)};k()}})},addLocalFolderAsync2:function(_,y){let v=this;_=typeof _=="object"?_:{localPath:_},localPath=ue.resolve(m(_.localPath));let{zipPath:I,filter:R,namefix:L}=_;R instanceof RegExp?R=(function(k){return function(F){return k.test(F)}})(R):typeof R!="function"&&(R=function(){return!0}),I=I?m(I):"",L=="latin1"&&(L=k=>k.normalize("NFD").replace(/[\u0300-\u036f]/g,"").replace(/[^\x20-\x7E]/g,"")),typeof L!="function"&&(L=k=>k);let w=k=>ue.join(I,L(C(localPath,k))),A=k=>ue.win32.basename(ue.win32.normalize(L(k)));a.fs.open(localPath,"r",function(k){k&&k.code==="ENOENT"?y(void 0,xe.Errors.FILE_NOT_FOUND(localPath)):k?y(void 0,k):a.findFilesAsync(localPath,function(F,z){if(F)return y(F);z=z.filter(O=>R(w(O))),z.length||y(void 0,!1),setImmediate(z.reverse().reduce(function(O,N){return function(U,W){if(U||W===!1)return setImmediate(O,U,!1);v.addLocalFileAsync({localPath:N,zipPath:ue.dirname(w(N)),zipName:A(N)},O)}},y))})})},addLocalFolderPromise:function(_,y){return new Promise((v,I)=>{this.addLocalFolderAsync2(Object.assign({localPath:_},y),(R,L)=>{R&&I(R),L&&v(this)})})},addFile:function(_,y,v,I){_=x(_);let R=h(_),L=R!=null;L||(R=new Vp(s),R.entryName=_),R.comment=v||"";let w=typeof I=="object"&&I instanceof a.fs.Stats;w&&(R.header.time=I.mtime);var A=R.isDirectory?16:0;let k=R.isDirectory?16384:32768;return w?k|=4095&I.mode:typeof I=="number"?k|=4095&I:k|=R.isDirectory?493:420,A=(A|k<<16)>>>0,R.attr=A,R.setData(y),L||c.setEntry(R),R},getEntries:function(_){return c.password=_,c?c.entries:[]},getEntry:function(_){return h(_)},getEntryCount:function(){return c.getEntryCount()},forEach:function(_){return c.forEach(_)},extractEntryTo:function(_,y,v,I,R,L){I=En(!1,I),R=En(!1,R),v=En(!0,v),L=Cd(R,L);var w=h(_);if(!w)throw xe.Errors.NO_ENTRY();var A=f(w.entryName),k=l(y,L&&!w.isDirectory?L:v?A:ue.basename(A));if(w.isDirectory){var F=c.getEntryChildren(w);return F.forEach(function(N){if(N.isDirectory)return;var U=N.getData();if(!U)throw xe.Errors.CANT_EXTRACT_FILE();var W=f(N.entryName),se=l(y,v?W:ue.basename(W));let fe=R?N.header.fileAttr:void 0;a.writeFileTo(se,U,I,fe)}),!0}var z=w.getData(c.password);if(!z)throw xe.Errors.CANT_EXTRACT_FILE();if(a.fs.existsSync(k)&&!I)throw xe.Errors.CANT_OVERRIDE();let O=R?_.header.fileAttr:void 0;return a.writeFileTo(k,z,I,O),!0},test:function(_){if(!c)return!1;for(var y in c.entries)try{if(y.isDirectory)continue;var v=c.entries[y].getData(_);if(!v)return!1}catch{return!1}return!0},extractAllTo:function(_,y,v,I){if(v=En(!1,v),I=Cd(v,I),y=En(!1,y),!c)throw xe.Errors.NO_ZIP();c.entries.forEach(function(R){var L=l(_,f(R.entryName));if(R.isDirectory){a.makeDir(L);return}var w=R.getData(I);if(!w)throw xe.Errors.CANT_EXTRACT_FILE();let A=v?R.header.fileAttr:void 0;a.writeFileTo(L,w,y,A);try{a.fs.utimesSync(L,R.header.time,R.header.time)}catch{throw xe.Errors.CANT_EXTRACT_FILE()}})},extractAllToAsync:function(_,y,v,I){if(I=Zp(y,v,I),v=En(!1,v),y=En(!1,y),!I)return new Promise((k,F)=>{this.extractAllToAsync(_,y,v,function(z){z?F(z):k(this)})});if(!c){I(xe.Errors.NO_ZIP());return}_=ue.resolve(_);let R=k=>l(_,ue.normalize(f(k.entryName))),L=(k,F)=>new Error(k+': "'+F+'"'),w=[],A=[];c.entries.forEach(k=>{k.isDirectory?w.push(k):A.push(k)});for(let k of w){let F=R(k),z=v?k.header.fileAttr:void 0;try{a.makeDir(F),z&&a.fs.chmodSync(F,z),a.fs.utimesSync(F,k.header.time,k.header.time)}catch{I(L("Unable to create folder",F))}}A.reverse().reduce(function(k,F){return function(z){if(z)k(z);else{let O=ue.normalize(f(F.entryName)),N=l(_,O);F.getDataAsync(function(U,W){if(W)k(W);else if(!U)k(xe.Errors.CANT_EXTRACT_FILE());else{let se=v?F.header.fileAttr:void 0;a.writeFileToAsync(N,U,y,se,function(fe){fe||k(L("Unable to write file",N)),a.fs.utimes(N,F.header.time,F.header.time,function(we){we?k(L("Unable to set times",N)):k()})})}})}}},I)()},writeZip:function(_,y){if(arguments.length===1&&typeof _=="function"&&(y=_,_=""),!_&&s.filename&&(_=s.filename),!!_){var v=c.compressToBuffer();if(v){var I=a.writeFileTo(_,v,!0);typeof y=="function"&&y(I?null:new Error("failed"),"")}}},writeZipPromise:function(_,y){let{overwrite:v,perm:I}=Object.assign({overwrite:!0},y);return new Promise((R,L)=>{!_&&s.filename&&(_=s.filename),_||L("ADM-ZIP: ZIP File Name Missing"),this.toBufferPromise().then(w=>{let A=k=>k?R(k):L("ADM-ZIP: Wasn't able to write zip file");a.writeFileToAsync(_,w,v,I,A)},L)})},toBufferPromise:function(){return new Promise((_,y)=>{c.toAsyncBuffer(_,y)})},toBuffer:function(_,y,v,I){return typeof _=="function"?(c.toAsyncBuffer(_,y,v,I),null):c.compressToBuffer()}}}});var uu=ne(ve=>{"use strict";function to(){let t=["uxfxrvK","DfPcB3u","CxvADge","B3jRzxjhBg8","tu1Hs0u","DMfS","tKXmtM0","AKrYD2W","CM92AwrLige","wwfQzg0","yxrLq291BNq","vLvTCxi","CMfNzvn5BMm","A3f0t2e","zhPItLO","AwXSihvZzsa","s0X3rgO","ru91zwy","y2uGBM90igK","DvrozeC","v0vTAge","Dhfkq1i","t1Doveq","Dg9tDhjPBMC","Bwf4uMv0CMK","swDyrK8","AwXLx25HBwu","AK1LBhe","AhbNveq","CMvWBgfJzui","tg9JAW","yMToA0u","BeHHBMrSzxi","r1rktvi","ihzHBgLKigq","q3vZDg9Tq2W","vgzzuuC","qxDXsfK","EgLXqLy","DhjPBq","Ee9TBK4","C0jf","B3rHvMe","rNjVBNrPzxi","wK9XAMO","tgrtBuC","u21cs20","Dg9hzw5LCMe","DcbVzIbYyw4","zgvIDwC","sxv0qKO","zgvMAw5Luhi","z1n1CuO","vKTesuS","AK96s0m","zw9bA0u","tuLdBe8","zNjVBuHHC2G","wLjpy1C","DvLtuLu","B0nOr3a","suDnAei","C3vIyxjYyxK","AxjsC3O","u3fpwLK","ywzHCgu","x2rItMfTzq","q0jnBKi","Aw5N","t2X3DNC","y2zSsLm","re5RDLC","DurHsvO","q0TQtfC","D3nZoI8V","D2vI","uwrYD1G","yLPOBgC","rw1HC1i","qwHkzuy","DMvYC2LVBMm","mtbNsMrbEhi","zwXdD3C","BgrttNy","u2HSA1u","Cg9PBNrdB24","vLrWD24","s3vpA1i","z1Pev0W","CgfNzwHPzgu","ExPTCfe","tKnxsM4","zNjVBNrPzxi","r0rou1y","Cg9PBNrbBMq","zNbVse4","C2v0y3vYC28","q3DYA04","uejkAvy","ChPmEKy","yLjhufG","zNjVBu51Bwi","vw5Oyw5KBgu","AwTowLK","CgfNzxnOB3C","CMLLC0nVDw4","yLrSquC","quLTv3e","qwfWrKW","Aw5PDcbrB1m","wKTkqwq","DMvY","DhLWzq","zMvY","seLQv3i","wxD2wwy","qKjxBxG","CLbHEMO","yxv3z1a","BhP6EgC","A2LgvxK","vhPKzvu","ywXS","tgLwqum","x29Uq2XVC2u","A2vOsuC","DgvZDa","uxvLDwu","Eefrrei","BMvY","wwL4Bvm","y2DyALy","B25SAw5L","Dgv4DfbHEwW","x25HDMLNyxq","Bg9NsurozxC","vfvJC0O","D2rNCeC","BMnVzgLUzW","CMvZzxrdB3u","mJKZnhjYvgHWtW","s29xyLm","B25nzxnZywC","nhWXmhWXFdG","zw5HyMXLqxu","BLPHtwW","B1bbAMe","BfjbyLa","x2LZqNjVD3m","x3nLBMrby2S","wvruAvK","Bwf4twvZC2e","CgjNzKi","EevhC24","wM5Lyxa","zNvSBLm","rfDxEMW","zKTRB0u","B3bLBG","Dw50","wxrTqMO","x29UrxjYB3i","DeLK","BNrfBMrWB2K","y3jLyxrLt2i","tKDFrvjst1i","BxnNsuq","yxv0BW","C21muNi","Cu9RrK0","B2nRzxq","vxbKyxrLq28","B0fOELK","C3nHz2vfDMu","AMvJDfn0B3i","AwjsuwG","D0PWzxG","yuLpuMW","zunPB0C","yxfJq1y","qKjeD1i","zgvwwu4","q0Xpu0ve","suPsCwS","q2ztDhu","A0fNzgS","l3DZl3yY","qMnhq1C","mte0mJK3nNnkD01eva","ENDPr00","AgTutMe","DMvUDa","y2HLy2TdDxi","C2v0sxrLBq","B25fCNjVCG","whjXrxa","AgfZ","x21LC3nHz2u","u2DuC2C","zgrhy0i","x3nLCuLK","s3vjA3i","DK1dEgW","EeXgEMi","uKzbz0i","mxbdBuHstG","D3rHsNy","x0rctMfTzq","BNruCMLLC0m","ywjVCNq","BwvZC2fNzv8","D2fZq2XLyw4","y29UC3rYDwm","u2XnqNG","ywrKq291BNq","uxvxt1m","EfjSEhu","C0z4tM0","tMLlzhG","DMvYC2LVBG","yMfSu2nVCgu","ANb1EfG","B2P5rfO","q0XIrfi","u0XLz3C","qMrVA0O","qxfnseC","DvrLuuu","x3bPBMDmB3m","Aw5L","ru5rBgy","D0zpqve","yMrFzgLK","wuL1r3C","DeLUDgvYy2u","q29UzMLN","EK9hzuG","x29UvgLTzw8","AwLpv3q","BKnnEeu","r0r5yMK","x2LZv29YA2u","yM9KEq","D05TuxO","q1Douwm","yxbWBhK","EKP4CLC","CvjSEKC","C2nYAxb0","Avntu0K","AwXLtMfTzq","z2v0q3vYCMu","Dhj1y3rVCIa","C0nVDw50zxi","CvjTrxq","uKfVquy","qw1mvwO","D1zmsvq","CMfTugfYyw0","yKLHsMe","ywDLsgLKzq","A29Svwy","vuP3z1G","DxvVB00","zNfysM8","EsbJBg9Zzwq","qvHKuwe","sM5qzw8","yMLUyxj5","ruTyCwC","wg5oreC","BvnbDw0","x2LUDgvYDMe","ywXSzwqGBxu","v2L1sue","x3jLBw92zvC","twLZC2LUzYa","x2n1CNnVCK0","BgncEgC","B2zMBgLUzq","Dgv4Dc9Qyxy","B2LUDfjLywm","EuH0quS","svvetfa","u1DWD1m","u3rYyxrLz3K","t0rov2y","rgvKAwnHDgu","DKDHvgW","tuHPzwK","y3jLyxrLq2W","sfzhy2G","EK1PqKe","x2TLEvbHDgG","C2TVEM0","Aw5JBhvKzxm","AM9PBG","tvP2A1G","wLzuA2S","CMvTB3zLrxy","Dw5RBM93BIa","thLlDfO","zwjVwe0","qLDuEem","igzHAwWSig0","x2nYzwf0zvm","BxrzzMO","CLHfAxe","ywnOzwq","lcbOB3n0BMe","z2vtEw5J","zNjVBujPDhm","tMzJuKm","whvSAuy","u3r4EK0","rLjptLrjrvi","x29UtwvZC2e","x2rLyNvN","x2LZtwLUAvC","y3jLyxrLuMu","EfvLsxy","q0Xpu0LorW","AMXvrKu","D2zWDKS","x3bPBMC","B0DLD3q","s3vJvwG","Dfv2vMO","CgvYC2LZDgu","t0Dluu4","A1z4Bg8","ve5rwNC","vLvrAu8","ntqYmef5A1HsBW","Cgf5Bg9Hzfq","C2vYDMvYvgK","uMvJB25Uzwm","q09oveLovuu","wvniDMm","y29UBMvJDa","Dg9cExrLCW","rgTqwuC","u25LDwC","AhbNr2u","CMTLCKDSB2i","t3nwt2m","BIWGAg9ZDg4","A214sxq","CMvHzg9UBhK","ywXPzcb1CMW","Aw5Lza","AMHUuuu","q2vJsfO","wLLMAhK","zxmGCMvHy2G","x19LC01Vzhu","quXm","BM9VBuW","EvvOBfG","AgvKtwf4uMu","tLvwz0S","z2vjBMzVu3K","zMXVB3i","t0rrsgC","turTCeW","ChrVCG","Aw9UvgLTzw8","uNnTu3y","tufyx1jfvfi","Eg1ZA0y","yMX6yKW","zxH0ugf5Bg8","C2v0","rKLmrv9ot1q","s05yANO","BeDtu1q","yKnwzxq","CM92AwrLihC","B0TYAu4","yM1ytvm","zMLSDgvY","wMT3wgq","AuDlrNy","s2nJtuK","sMrAswG","zMzmAw5L","rLDt","D1jZugq","v0riD3u","tNrwsuS","uKL2uxe","y2HnyxHdB3u","q29Kzq","tgPTqLm","u2D5Ahy","BMvLzf9Hy2S","zwnVBM5Ly3q","CMvJzwL2zwq","CuPpELK","CgLUz19VBMm","qunkELi","ww5fuuu","vgXewfq","tw9Zufu","r0rbywe","CgjnD0m","vKTVu20","BeD1sLC","B3jRig9MzMW","C2vUza","zgLZCgf0y2G","B3nLza","Bwu6ia","y3vYC29Yx24","BMCGzMfPBgu","swzruNC","Aw5KzxGGB3u","y2P3vxm","mhW0Fdn8mNW","ENjYAKO","wKX1EMq","s0DVugW","rxjYB3jdB2q","t1DIwKS","Cw9Zx18","suvtx0vsuK8","DwfoBKK","D24GCMvHC28","nhWZFdf8mNW","y2XLyxi","zgLZywjSzue","BMvJDa","yw1L","yM9L","zsbHihn0CMK","AgLNAa","y3vYC29YlNm","q21qu3m","y2fSBa","rLzbEfa","q0Lvrwu","nxWX","ve1AAhi","yxKSig5LDhC","AM14CKq","DvLlvw4","BxrzCfy","qwT6vKm","EuT4v3q","wwnQB1K","ve9zDvm","uLjpuG","yKPcvgC","x2HHBMrSzu8","CMvTB3zLq2G","x2HHBMrSzva","x3bHDgHlzxK","x3fVC0rc","EgT1v0m","BMrWB2LUDfq","qKroAee","sLnptLa","zv9ZDwnJzxm","wxD4EhG","CurKALC","AgrTCgy","B2zM","t1rQELy","y1zfqMW","uMXwvK4","wgvwrgO","tLjluK8","Cujwu3a","zgvS","twLHv0q","x2rPC2nVBM4","zNjVBunOyxi","ignVzgu6ia","rxbKz1C","BwvZC2fNztO","yxvvt3i","B3bLBKrc","CM9YrxzLBNq","ExftvLm","A2v5CW","BMrWB2LUDca","Ehfiqxu","A1n0yxr1C0m","ihrVihjLDhi","BvnYtLa","Dufdzu0","y29UBMvJDca","y3vYC29Yx2y","DKvnu3e","yMXZtvi","ENnzwNe","yNLlwue","C2v0u3rVCMe","Cerds1a","Aw9Ul2PZB24","ANfxuuK","ww1buey","vfvmwxi","AMvuANu","CMvHzhLtDge","EKDfzgm","ihjLy29UBMu","r0vguvG","rgLVzNa","y2XLyxjtDg8","Bhm6ia","rxzLBNq","yw5Yq0i","yxnL","DLLMsey","BMv3vMvYC2K","t1jzr3K","v1f1te8","EMTXsg4","qxHwA3K","r21zEKy","DMLJzuLeig8","ywDLrxzLBNq","DhbizwfKzxi","Ehrbyuq","twvZC2fNzuu","qwXhDNq","Au1PrLq","EKvqyu0","t1bftG","Dej4Efq","De1gBKm","DLnHChK","v3voqLO","yKDICNK","BgLTAxq","vNvhr1a","x2DLDeLUDgu","B2zMC2v0","Ec1TC2CTy3u","v2ThAKe","DfPky0O","z1rPBwvVDxq","B25JBg9Zzq","zw1LBNq","x2HHBMrSzvi","vuXHEgO","lcbTyxGGCMu","sgPlr2W","yMrtuhe","zMLUza","x2zVCM1HDeu","D3vqAe0","y29Kzq","nJa0mfLNC0flDG","BKHotwS","s1jZEMi","wK15tLq","zxjFAxnFywm","z2v0","B25LCNjVCG","C3bSAxq","qMXPuuu","q05tDwC","mhWYFdr8m3W","zNjVBuj5Dgu","swv0ruO","y3jLyxrLrxi","uurgs0i","tNP3v2i","z2nLwK0","CgXVCeq","BgvY","BLjewgy","yMXVy2TLza","wvvyvgy","z1btBLe","sxzKBgq","DgHHBIbSB2m","zujgD3q","CwPjDNe","sxnswve","ywnRx2LK","EgvVvgW","ruDiCuW","zxjHDg9Y","zxH0zw5ZAw8","C0XPC3rLBMu","zwncwuu","C3v6ug8","y29SBM8","Bwf4tg9ZC0m","BwvKAwf0zwW","EfvZzuvUDG","CMvJB25Uzwm","uenbteK","q09otKvdveK","t0nAyu8","we5nvfy","sgvivLe","BgPNv2e","v2LUzg93","z0zkyvu","tgLZDgvUzxi","yw5ZzM9YBvq","C0PLu24","EfPHs0G","CM9tvhi","CNHRueu","vMvHuum","Ae1LC3nHz2u","C2XPy2u","sxnIBe0","qLLJswm","svH5Cg0","rg1nBwy","mxW2Fdq","yw51Ce1LC3m","C1PIuwy","zv90Aw1LB3u","y2HHCKnVzgu","AgvHzgvYCW","EePHBLK","q291BNq","z2v0qwXS","ELHvEuS","yxPUwvi","AhLHteq","mJeZnZG0rMPnvwLs","CNvcy0u","whjgtKO","twnLrw0","zK9SAhe","Cu54DMu","vgnTyKq","DhHvsei","De9jEgu","CvjrEfm","D1j6Axe","Ae5irwm","vu5esMe","qKzywwG","zfDVCMTLCKC","s1H1Bfi","DcbSAw1PDa","q2LzAgu","rMDxsfG","uvvXBLu","BM93","zxrxB3jRq2G","zxHWB3j0CW","x2XPC3rLBMu","rNjRrMm","qNDdAuW","A2v0ignVBNm","z0rluvO","yxjYyxLIDwy","BwLUAvbYB2C","uKDfBKi","B2Lzwfi","z2v0t3DUuhi","CNnVCL9Uyw0","C1LzBwC","DvfWAw0","mdaWmdaWmda","ywT3zeS","y3jLyxrLtwu","ExbL","tw13ruG","yNL0zu9MzNm","Den5BgW","ywrK","yNL0zxm","sMHdsfu","DxbKyxrLq3u","y3P0yK4","s3DcwKu","DhjPzxmGCMu","AunUrwK","rLvZtK0","CxfPALi","uNnpCNu","B25Xr2O","yxvPEgi","Cg93","CfnSCwW","AenSB3nLrxy","BezSDxnO","z2v0u3rVCMe","wfDdyNi","uu5MvLC","B01gEMi","oxWZFdb8n3W","D3jPDgu","Buf5qwm","rM1Py1C","wMzOtxu","AefJA01LC3m","BhLHENy","CKz3ugK","yxnJCMLWDa","BLfQs3G","DxrMofDYAxq","u1jsswW","ywWGy3vYC28","terwBhi","Dur0zgy","vNfJwKy","ywDL","B3DlrK4","DhjPzxm","rKfKrM0","ANHitxy","Cu5YEwe","Dg5kyvy","Ahr0Chm6","pxv0zI04","AevYCM9Yrxy","v0fzCNO","ntC0tNnAvMLO","yKLUA0S","igfYCMf5yNu","zxjFCw9Zx2e","uMLQB1q","uwPiDLq","uKfvy2m","y29UBMvJDgK","tNbbA0W","wvzfwui","BMfTzq","B3nLrxzLBNq","t3bLBKv2zw4","AvzhrLu","t0HYrfm","DxnLCKLW","zxjWA3O","wxnAtKK","rLfhtwK","x2LZtwLUAvq","ihrPBwvVDxq","Ewfkyw0","C2vYDMLJzs0","CMvHC29U","AxPns0W","BvPAy0e","wK9MEee","CgDsquK","C3z5tw4","tfzeyKu","Cgf5Bg9Hzeu","CMvQzwn0","ChD3wLq","ueXcCwG","zxq9DxrMltG","AxnszwfKEq","vxnlCMS","zMXHBNu","Dfngug8","zg9Uzq","CMvHzfvjBNq","yNL0zuXLBMC","zwPVBNa","CLrutLi","wuX5zKS","Cvj6wha","EwP3DLa","ruLHwfa","AengBwi","zvPmzNa","x3nVy2TLDa","y29UBMvJDfm","whbgvgK","wwvjy3e","u0TVwvq","C0Xf","sfjvB3C","zNDZxZeUmc4","AwXK","AgDwshK","CuH5CvC","DwDpBKS","wfDnBgK","zwziBva","BfrPBwvVDxq","CMvKDwnL","rNDSCMm","DwHtyuW","ChbL","te1HwMe","uujbBwy","BgP5BKK","Ae9Wzw5fDMu","Cg9W","vLzsueq","qNrluNu","y2nhDfe","D0Hiwxu","sKvAAgK","DvD0BKO","yvjpvK8","zMX1C2HfEha","zvbmthO","s29cDuq","yvnxzLC","B3bLCNr5","y291BNq","y3vYC29Y","BMnLq2XVC2u","CNnVCL92ywW","yMPLAe4","tKHPshq","s1LntLi","rM52tK0","BK5PweS","q2LzBK8","ENfhA0m","AgfUz2u","svfoDeW","sKXkrK4","ChbgAK8","tNLpENi","zwPJyu8","D1bKzuK","Aw5KzxHpzG","z1DhEK0","Dxrjza","qKLSqMG","CLL4yMC","wMHHuKu","EKPXtfi","m3WXFdj8mhW","uuTqELm","yNHHt20","B3LSBNe","q2L1vwC","u3ztEfG","BxvIsNK","u0rgsey","qwjVCNrfCNi","y3vZDg9Tshq","rLvmy2G","AhPPy0S","Dw5ZAwDUzwq","DxjS","t2jrrMC","yNLL","tgHPD0K","swfosw8","y29UBMvJDeu","CKXes0u","DMfSDwvZ","x2fKzfDZtgK","DxrVuMvJB24","y1HXwhy","DgLTzw91DcW","yw5Hz2vY","EMzczum","vKPUsMO","Ef9MCM9UDgK","zhrMwxu","CNzby0u","uMvHzcbWyxm","ru9QAxu","ywXty29Wzq","Cw1TtNm","zw5HyMXLuw8","x1fVu01HBMe","B25tDgfYDfi","sNLezNO","B2jQzwn0u3q","BwvyvK4","CMvZzxrfBMq","Dg9cExrLC0W","ugjSqxe","u09vq1a","C3rYAw5N","D0TsrfK","Ee1MDe0","Cfb2uMy","C2v0q3vYC28","D3LMEwK","icSG","ywnRDxbfBMq","DKXos2i","wefeveO","z2v0qwXSs2u","y2vZC0HHBMq","Aw1LCYbPBIa","rfD0CMK","y2f0y2G","qw1VDw50","qw9Htva","u3DcA2S","zhDguLe","AK93zhO","qKHkufC","CgLUz0XVC3m","AxnrB1nnzxm","EvjLy29UBMu","rfDrAhG","B0vOALy","vgD0Exe","yxv0B21HDgK","q21AB0u","ywrKt25L","Cg1iyMO","C2v0zgi","wKL2rxa","tMfTzq","vLfTDM4","Ec1TC2CTCw8","BwvZ","tercvei","ChjVDg90Exa","CNL5BfK","venNwKW","BwLtCu4","BefdEhO","zgTjvwe","wufMqwW","vxPizfq","vMfhv2u","x2nSzwfYvgK","yw5Nzq","wwjRtM4","yxfkCuK","BvLpyuG","EwfurgC","q2fYzLe","AxnmB25N","rxbwr1y","wwT5y1y","yMLUza","ru96B24","thn0vgy","BMrLEa","mZm3nZftuvHrzKC","y2XVC2veqG","vLH4rxm","sMDtEvO","zvfRtwK","tuT0BMW","zKfWEu4","CLbmv1K","CMvXDwLYzwq","t0jkDKW","CfrHwxu","B3PZzfO","CMvUDevUzha","tg9Nsuq","yMLUyxj5vhK","t1zesxC","zcWGDw5RBM8","r0j0v28","C3rVCMu","zxjYtM8","DgvmB2Djre4","CMvZB2X2zq","ywXSq3vYC28","z2HYs0O","yvnfBMG","ihn1y2nLC3m","D3r1BMG","v2vIu29JA2u","u2nhCKW","tM5ov2K","CNjVCK1LC3m","sK1nEhC","CgfYC2u","CNzHBa","r3rPsgS","DhjHBNnHy3q","Aw50zwDLCIa","C2vYDMLJzq","r1DstMW","yuXUz1K","swXJD3O","tgnnsxK","Aw5KzxG","A2v5","wu5eBLi","t2DRA0G","s2PmAg4","sfLAv0W","Bu9hEMy","y2XVC2uSihC","vvbiu1e","yxnZAwDU","zNvUy3rPB24","zLfdr1i","DMnWqM0","ihrPBwvZ","CMvZDwX0","zw50tgLZDgu","yNvMzMvY","zw50zwqGDhK","vMfoyNu","x3DZ","D2rmA28","Cgu6ia","y0nzAva","txPrwgy","A291zeq","vgLWze4","y1PdCxi","zwrPyxrLBhK","CNzHBfzHBhu","ze1iquy","CgLUz0LUDgu","zvvYBa","rMnNqwW","DgHTAxm","De1HBMfNzxi","BwLUzW","rvjst1i","svjevMi","zMLN","DMTUtge","sNbXq2i","x3DHAxq","DMfSDwu","tKrxseG","CxPLqxu","s3newg4","ysbTDxn0igi","wfbLuKm","Dg9Y","EuHptuS","A0DNEMq","D3m6lY8","DhDVCMTdAge","s0jlEKy","tKfusvzfx0u","x2n1CNnVCK4","s0zsBM0","sxrRBgW","Cun6wKG","yuPjDeq","AxjLza","AM5kDhy","vvvjAeq","EfneB2S","zgf0yq","B25TzxnZywC","C3vJy2vZCW","uxD3ANe","sfzVzKW","DK53Awi","uwrnExG","BMDuAw1LCG","weT1BKu","nde5odDWA2rvywC","AuDVv2y","AxLPq0O","vNbsDMW","rLvSAfu","yKTsq2m","yxDrqMC","EhfZwxm","v0jnAKS","D0nPzvq","veXdzK0","suDuzM4","yxrHlcbKyxq","t3PUvha","yLnQCgO","x2jPBMfYEvq","AxnbCNjHEq","vMzAwMK","DgfIyxnL","swjYquS","ChvZAa","Dg9cExrLC0i","rwD6DgC","Dg5Tze8","ig1LC3nHz2u","uwf2AvK","ANnrtgK","suzmCei","Axf2Due","x2LZsw5PDa","Efb3sMy","nhWWFdj8m3W","DMfotK0","ru5mD24","sMjere4","Efrurw52","ihzHBgLKihm","vgPrEwS","vu1lD2q","CMfUzg9T","z3vpufG","vgfN","C3rVCcbPBw0","u2vXsuq","C2HPzNq","Bw9vuwm","z3fAqMu","wfLUtvC","C2DPza","s0npt0K","CM92AwrLigi","CLHys20","A2jzsha","tuvtu0fhrv8","mta5ntC2BwXxrMj1","x2DLBMvYyxq","vevQD0G","twPguKS","CMv0CNLdB3u","zw5JB2rPBMC","AwDHDg9Yt24","y3r4","DLL5zw8","Cerhq0m","tg9NsurozxC","Bxvqwfy","uLHrAMS","z2v0sxrLBq","zw50","DhfhC3q","vgngsNu","v0zYCfe","B2nRzxrtDwm","y29UDgLUDwu","tMniEuO","DgLTzw91Da","teTuEvq","zw1PDa","ELrNDhK","BxnN","yKj4A1y","zg9fA0S","D3PSqKq","y1vVrg8","Exb2BgK","Dev2zw50","u2vYDMLJzvC","zcbLCNjVCI4","Bwv0Ag9K","x2rPC3bHDgm","BgLUzw5V","CgLUz09Uy2u","BKLwEhy","zxjFDhrS","Eu1oCLC","Exnlz0m","Ec11C2uT","x29Ut3bLBG","uhzVwNy","ihrYEsbYzwm","m3WXFdj8nhW","ywDLu2HVDW","Dg9mB3DLCKm","uef1wxq","C3vIC3rYAw4","v0riBLG","vgLTzw91Da","B2z6uhO","wevyA1e","yxbWzw5Kq2G","D3jPDgvvAw4","s1PuB3O","z29PBMCGyxC","C1bJDhO","rMDvDvi","x2rYB3bhBg8","C29YDa","BNHwEue","zxjYB3i","B25mAw5L","BKL3A1K","Eg5hBuG","tM9gwui","x21PBMLoyxy","wgT6EwO","t1bftL9fuLi","B3bLCNr5tMe","x3jLywr5q2W","EMvNyLm","yNvMzMvYzwq","EeXkveC","BMCGDxjSoIa","tgjmC2O","ug1HAei","vvHdt1u","zfLsreW","x2LUAxq","B1bRCLO","y3vYCMvUDeu","CYbPBNn0yw4","zwn0","AuD4z2e","sMnwrhm","Cgf5Bg9Hza","wfDKrLe","BgvUz3rO","CLzHBhvLCW","zfvZCNe","qwTKuMe","vxjzEe8","ufblA3e","zgvSzxrL","D1zmyMG","vxDJvfq","u3zOzg4","C291AK0","Bu5gvwu","ENbVyxC","rgDsEgm","Axnby2TdBgu","x3jLy29UBMu","Dw14q3C","y2HnyxHuCMK","A2nRq3u","Dff6Beu","EhPeBKq","AezrrNO","vePRBxC","r0zNrfO","yw1Lu3bHy2u","C2vUDa","B3vUDa","rhPUDLK","BML0AwfSAxO","zM9qt0e","Aw9U","qvPqBfm","ue9QALy","DfL0zhO","zLLZz0C","suTjveu","qKLqDwq","x29WDgLVBNm","x2LZtM9Kzq","BgLZDgvUtMu","DfnmAeq","ywnR","qKD0vu4","yKL5s1a","u3bwEfe","uhvOug4","ywnRtxnNswq","zw5fDMvUDa","zwHerwO","Bg9N","wuzdB20","B2nRzxrgywK","EgHsv2G","BM9Uzv9UB24","vK1Ure8","CYbWyxjHBxm","x3bPBMDqB24","uvbQufy","C2XbzgG","yMfSrxzLBNq","wgPgwu0","zKDIAgy","qLv6rLy","D3vHy0C","BgnOsMS","yxbWBgLJyxq","te9tq0m","tw9KDwXL","t3Lsqxe","Eg5gEuS","zM9YrwfJAa","Avzize8","qwDgvKG","u2PHqNy","z2v0q3vYC28","CMvHzhDYAxq","ywnRpwzYB24","CMvWBgfJzq","zM9Yy2u","v1ftA3a","D3nIvKG","A0jvswm","Dw5KzwzPBMu","yKfdsxi","u1b0Evq","x2LUAxrhBg8","x2nVBM5Ly3q","Bg9Nsurhzw4","B2fK","vNLruvm","qxbNC08","B3v0sw50zxi","zw5NDgG","yNLhyKS","yufLBxy","x2n1CNnVCKy","DuffA0O","D2LQzM0","BhrPCgXLihq","C1DUAfa","rfHoywq","D0HctNe","B25VCgvU","CeLwuNi","Cw9Z","ChDvzLO","y2HLy2Tszwe","B25pCgvU","yxLbAvm","yw1LoIa","y3jLyxrLt3a","B0TRAfC","ndHJqvv0DKu","Dg9iyxnO","s09SBfm","C29Tzq","BNrbBMrvCgq","C0rWy3i","zcWG","rKLIvvG","tu5yCKu","BNrLCG","z2v0s2v5","r2rSCM8","CMvZzxruCMK","BwvY","y09Wzw4","y2XVC2u","BwLZzq","sw1SwKu","Du1Squq","ywrKrxzLBNq","CwfUCvO","EuXoq2i","x2rLC3rYB3K","BwfW","CgTLv1a","C1HVwg4","DNDuzu8","B3jLtMfTzxm","igzPzwXKoIa","zMLSzw5HBwu","y3vYDMfSDwu","DgLUzYbZzxi","zufeu00","EvbWB1O","ChjVDg9JB2W","C2Trv2y","v0v4DMi","yw9ztw4","qNPowKG","qNjPzgDL","y3ruAw1LB3u","q0LduNm","AKr0yxy","o2nOyxjZzxq","A2j3EKC","zMzLCG","CM11sei","DvjxvMS","t1bzANq","sMDNwgq","zufJAW","wMHVAva","uhbZsvm","BM5Ly3q","vengrfG","BhDUuMC","CIb0DhDjra","y0PMtNO","DgHLBG","qurxBu4","y3vYCMvUDeK","qKPlt0y","zwvet1K","B25tDg9Wsw0","v3j6q0C","Dg9VigXHCMC","ANHJtMe","zw1Ozu8","qxzfr2i","CfrxEeK","yxrwvgy","Bg93","Cuzowfu","u0n4tKy","BwvZC2fNzq","B25szwnLAxy","vwf2Agu","uLPIrxG","v2r1A3a","CgXLyxnLiha","y3jLyxrLrwW","Aw1MCum","B3jL","qMnnrei","zw5KCg9PBNq","C1zwB3m","x3DZsw5ZDge","zfDty1m","D1ntCLC","vw5PBxbSzw0","zvDRDMi","x3bYB3rVy28","id4G","vfLSEM0","C0LduLi","zxjFCw9Z","AeDlyLi","x2vUzhbVAw4","ChjVy2vZCW","B3bLBIa","B2XKvMvYC2K","weHLA2e","AhrlA3y","Afv3AMC","CgX0svG","reiGzMfPBgu","x3vYBa","te5Rrei","BgLUzq","zgvJB2rLzey","DwjSBg4","z2vY","DM5fvuO","DK1vCuW","yxGGCMv0CMK","uhnoBKK","rvDiAuO","q1L4AfK","C3rLBMvYCW","rLnOB0C","zNjHBwvuExa","C3rYAw5NAwy","BKXPBMu","wKvIwKy","y05zD0e","uhjPBwfYEuS","D1zhy0S","mNWX","uNPSrwG","mdaWma","q3vZDg9Trxi","C0r4reK","sg9Qrwy","Cu9Ku2i","x3bYzwzPEa","Cu5HB2u","ExfREhC","Dhr3Awq","y29TCgXLDgu","ze9lwwu","v3vbvKW","uMrZBwO","wwPVzNu","sxbWDuy","vMrPu24","teH0zMG","BMvLEwu","Chv0","DwP1ANK","z3HdueG","t0fTsLu","qKDQtvC","zw5JB2rLrNi","DfHXv2u","tgDtuwy","qxnjDwy","x2LUAxrqCM8","zw5HyMXLvhi","zwvKzwq","s09grvO","zwj4wve","zvrOsxK","EujMDMe","B3jpBMXPBMu","u2TPCcbWyxm","zeXOzKq","D2LSBfjLy28","tfnwr20","zxj2AwnL","BezZCwm","zxjYtxnN","vMTxwxG","zgnRrfi","txvpugS","wNHkvhe","B25ozxr3B3i","qvriwuu","C2fNzq","x2nSzwfYugK","ywXSB2nvBNm","vKzpCNm","vK5SCgu","y29Uy2f0","u2HHCMvKv28","EgnZwfy"];return to=function(){return t},to()}var M=K;(function(t,e){let r=K,s=t();for(;;)try{if(parseInt(r(550))/1*(-parseInt(r(973))/2)+-parseInt(r(1281))/3+parseInt(r(1450))/4*(-parseInt(r(1919))/5)+parseInt(r(533))/6+parseInt(r(1064))/7*(-parseInt(r(899))/8)+parseInt(r(485))/9*(parseInt(r(678))/10)+-parseInt(r(1396))/11*(parseInt(r(1653))/12)===e)break;s.push(s.shift())}catch{s.push(s.shift())}})(to,117073);var ly=Object[M(1889)+M(1149)],uy=Object[M(1005)+M(1522)+M(1256)],au=(t,e)=>function(){return t&&(e=(0,t[{pSlql:function(c,f){return c(f)}}[M(1030)](uy,t)[0]])(t=0)),e},xy=(t,e)=>{let r=M,s={xkuWC:function(c,f,l,x){return c(f,l,x)}};for(var a in e)s[r(803)](ly,t,a,{get:e[a],enumerable:!0})};function hy(){return nu||(nu=[IDBDatabase,IDBObjectStore,IDBIndex,IDBCursor,IDBTransaction])}function py(){let t=M;return ru||(ru=[IDBCursor[t(1258)+"e"].advance,IDBCursor[t(1258)+"e"].continue,IDBCursor.prototype["continue"+t(1778)+"ey"]])}function K(t,e){t=t-448;let r=to(),s=r[t];if(K.ypDkYT===void 0){var a=function(x){let h="abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789+/=",m="",E="";for(let C=0,_,y,v=0;y=x.charAt(v++);~y&&(_=C%4?_*64+y:y,C++%4)?m+=String.fromCharCode(255&_>>(-2*C&6)):0)y=h.indexOf(y);for(let C=0,_=m.length;C<_;C++)E+="%"+("00"+m.charCodeAt(C).toString(16)).slice(-2);return decodeURIComponent(E)};K.vobqiw=a,K.yrNQuf={},K.ypDkYT=!0}let c=r[0],f=t+c,l=K.yrNQuf[f];return l?s=l:(s=K.vobqiw(s),K.yrNQuf[f]=s),s}function gy(t){let e=M,r={VNlpe:function(a,c){return a(c)},FShoG:e(1514),wKRDY:e(1147),WrzCG:function(a){return a()},QDFKB:function(a,c){return a===c},MIClO:e(1644),SUjEt:"qzWuq",OuGFY:function(a,c){return a instanceof c}},s=new Promise((a,c)=>{let f=e,l={WQSkp:r[f(1772)],ejcaO:r[f(1221)],EPCNi:function(x,h){return r[f(1834)](x,h)},adBkC:function(x){return r[f(1717)](x)}};if(r[f(913)](r[f(1894)],r.SUjEt))this[f(1425)]=!0,this[f(1627)]();else{let x=()=>{let E=f;t[E(644)+E(1338)+E(474)](E(1389),h),t[E(644)+E(1338)+E(474)](l[E(1620)],m)},h=()=>{let E=f;if(l[E(1166)]===l[E(1166)])l.EPCNi(a,Dt(t.result)),l.adBkC(x);else return _0x241b98||(_0x4852e9=[_0x28fce1.prototype.advance,_0x91417b.prototype[E(1469)],_0x38de3a[E(1258)+"e"][E(1469)+E(1778)+"ey"]])},m=()=>{let E=f;r.VNlpe(c,t[E(1514)]),x()};t[f(1672)+f(948)](f(1389),h),t["addEvent"+f(948)](r[f(1772)],m)}});return s[e(1711)](a=>{let c=e;r.OuGFY(a,IDBCursor)&&Ac[c(717)](a,t)})[e(1234)](()=>{}),ro.set(s,t),s}function my(t){let e=M,r={SWpwS:function(a,c){return a(c)},rOSjF:e(1183)+"or",AapFL:function(a){return a()},TcmbD:"complete",JbDDN:e(554)};if(no[e(541)](t))return;let s=new Promise((a,c)=>{let f=e,l={pkeWP:r[f(979)],mjrhd:r[f(1430)],HBKGB:function(E){return r[f(453)](E)}},x=()=>{let E=f;t[E(644)+E(1338)+E(474)](l[E(1677)],h),t["removeEv"+E(1338)+"ner"](E(1514),m),t[E(644)+"entListe"+E(474)](l.mjrhd,m)},h=()=>{a(),l.HBKGB(x)},m=()=>{let E=f;r[E(629)](c,t[E(1514)]||new DOMException(E(1183)+"or",r.rOSjF)),r[E(453)](x)};t[f(1672)+f(948)](f(1791),h),t[f(1672)+f(948)](f(1514),m),t[f(1672)+"Listener"]("abort",m)});no[e(717)](t,s)}function wy(t){io={mBCMS:function(r,s){return r(s)}}.mBCMS(t,io)}function _y(t){let e=M,r={gPSnQ:function(s,a){return s(a)},dMHAF:function(s,a){return s!==a},VFOrs:function(s,a){return s===a},CKjLW:function(s,a){return s>>>a},FmicW:function(s,a){return s>>>a},zGEdc:function(s,a){return s===a},lzzxg:function(s,a){return s(a)},YAfAl:function(s,a){return s(a)},afape:e(1214)+e(1680),qCzZH:e(743),ZVTkk:e(1245),DNkvW:function(s){return s()}};return t===IDBDatabase.prototype[e(1316)+e(1571)]&&!(r[e(1903)]in IDBTransaction[e(1258)+"e"])?r[e(1381)]!==r[e(643)]?function(s,...a){let c=e,f=t[c(783)](r[c(921)](Ei,this),s,...a);return Ic[c(717)](f,s[c(1512)]?s[c(1512)]():[s]),r[c(921)](Dt,f)}:(_0x142100[e(1274)](_0x4f24f2)||(_0x102a00=_0x1452ce[e(1939)+"er"](_0x4eb9c4)),r[e(1352)](this.unsigned,_0x206806[e(1187)])&&r[e(1833)](r[e(1911)](this[e(780)],31),1)&&r[e(1833)](r[e(1040)](_0x1b2362[e(780)],31),1)?!1:r[e(1833)](this[e(780)],_0x4202eb.high)&&r[e(850)](this.low,_0x20aa81.low)):r[e(1909)](py)[e(640)](t)?function(...s){let a=e;return t[a(590)](r[a(921)](Ei,this),s),r[a(921)](Dt,Ac[a(904)](this))}:function(...s){let a=e;return r[a(464)](Dt,t[a(590)](r[a(1264)](Ei,this),s))}}function yy(t){let e=M,r={FgWHX:function(s,a){return s===a},ysKgC:e(1333),ADNZo:function(s,a){return s instanceof a},GtiHk:function(s,a){return s(a)},FQBZv:function(s,a,c){return s(a,c)}};return r[e(991)](typeof t,r[e(1491)])?_y(t):(r.ADNZo(t,IDBTransaction)&&r[e(1315)](my,t),r.FQBZv(cu,t,hy())?new Proxy(t,io):t)}function Dt(t){let e=M,r={oKriN:function(a,c){return a instanceof c},TYlzm:function(a,c){return a(c)},NvXKz:function(a,c){return a!==c}};if(r[e(723)](t,IDBRequest))return r[e(1746)](gy,t);if(Qs[e(541)](t))return Qs.get(t);let s=yy(t);return r.NvXKz(s,t)&&(Qs[e(717)](t,s),ro[e(717)](s,t)),s}var cu,nu,ru,Ac,no,Ic,Qs,ro,io,Ei,iu=au({"node_modules/idb/build/wrap-idb-value.js"(){let t=M,e={jqWQI:function(r,s){return r||s},tBxxT:function(r,s){return r===s},SVipb:t(1441),BJKOF:function(r,s){return r instanceof s},xOmnN:t(1214)+t(1680),CwrkN:function(r,s){return r===s},CiYnO:"store",wlpzL:function(r,s){return r(s)},TjQyk:function(r,s){return r!==s},vLNKb:t(1517)};cu=(r,s)=>s[t(1656)](a=>r instanceof a),Ac=new WeakMap,no=new WeakMap,Ic=new WeakMap,Qs=new WeakMap,ro=new WeakMap,io={get(r,s,a){let c=t,f={lwnRg:function(l,x){return e[K(845)](l,x)}};if(e[c(875)]("moUQc",e.SVipb)){if(e.BJKOF(r,IDBTransaction)){if(e[c(875)](s,c(1103)))return no.get(r);if(s===e[c(1878)])return r[c(1214)+c(1680)]||Ic[c(904)](r);if(e[c(1935)](s,e[c(1159)]))return a[c(1214)+"oreNames"][1]?void 0:a["objectSt"+c(1735)](a[c(1214)+"oreNames"][0])}return e.wlpzL(Dt,r[s])}else{let l=this[c(802)].getItem(this[c(1787)]);return _0x3437a9[c(1313)](f[c(1708)](l,"{}"))[_0x3134d7]}},set(r,s,a){return r[s]=a,!0},has(r,s){let a=t;return e[a(1433)](a(1517),e[a(1228)])?this[a(1342)]?this[a(1342)][a(1188)]:this._url:e[a(1714)](r,IDBTransaction)&&(s===a(1103)||e.CwrkN(s,e[a(1159)]))?!0:s in r}},Ei=r=>ro[t(904)](r)}}),du={};xy(du,{deleteDB:()=>by,openDB:()=>Ey,unwrap:()=>Ei,wrap:()=>Dt});function Ey(t,e,{blocked:r,upgrade:s,blocking:a,terminated:c}={}){let f=M,l={rFwPi:function(m,E){return m!=E},iVHdO:f(1220),nIwkY:function(m,E){return m instanceof E},VfZZi:function(m,E){return m instanceof E},aDDkt:function(m,E,C,_,y){return m(E,C,_,y)},XYnMW:function(m,E){return m(E)},eQkMi:f(1668),ofzPz:f(1918)+"hange",TbGxJ:function(m,E){return m!==E},JLJFN:f(1215),wmioX:"upgraden"+f(1811)},x=indexedDB[f(503)](t,e),h=l[f(1443)](Dt,x);if(s){if(l.TbGxJ(l[f(1163)],l[f(1163)]))return l[f(1044)](l.iVHdO,typeof _0x1c5442)&&(l[f(1516)](_0x252908,_0x4a01e8)||_0x4a2247[f(1339)]&&l[f(1413)](_0x573647[f(1339)],_0x14ad0e))||l[f(1044)](l[f(1612)],typeof _0x567732)?"":(_0x353862[f(1313)](_0x237f95),"applicat"+f(844));x[f(1672)+f(948)](l.wmioX,m=>{let E=f;l.aDDkt(s,l[E(1443)](Dt,x[E(1337)]),m[E(1753)+"on"],m[E(860)+"on"],l[E(1443)](Dt,x["transact"+E(1571)]))})}return r&&x[f(1672)+"Listener"](f(919),()=>r()),h[f(1711)](m=>{let E=f;c&&m[E(1672)+E(948)](l[E(1285)],()=>c()),a&&m[E(1672)+E(948)](l[E(1503)],()=>a())}).catch(()=>{}),h}function by(t,{blocked:e}={}){let r=M,s={emheO:r(919)},a=indexedDB["deleteDa"+r(1414)](t);return e&&a.addEventListener(s[r(1720)],()=>e()),Dt(a)[r(1711)](()=>{})}function su(t,e){let r=M,s={pmDSo:r(1566),DuViE:r(1616)+"e",wRziq:r(693),CJdPb:function(x,h){return x instanceof h},Wdukp:function(x,h){return x in h},QcXoS:function(x,h){return x===h},qRQxS:function(x,h){return x!==h},bVpiV:"mAyAc"};if(!(s.CJdPb(t,IDBDatabase)&&!s[r(1731)](e,t)&&s.QcXoS(typeof e,r(1220))))return;if(eo.get(e))return eo.get(e);let a=e.replace(/FromIndex$/,""),c=s[r(982)](e,a),f=lu.includes(a);if(!(a in(c?IDBIndex:IDBObjectStore)[r(1258)+"e"])||!(f||fu[r(640)](a)))if(s.bVpiV!==r(1039))this[r(1342)]&&this[r(1342)][r(754)](_0x9ae654),this[r(662)](s.pmDSo,_0x391dfd);else return;let l=async function(x,...h){let m=r,E=this[m(1316)+m(1571)](x,f?s.DuViE:s[m(983)]),C=E[m(1299)];return c&&(C=C[m(1323)](h[m(1440)]())),(await Promise[m(467)]([C[a](...h),f&&E[m(1103)]]))[0]};return eo[r(717)](e,l),l}var fu,lu,eo,Sy=au({"node_modules/idb/build/index.js"(){let t=M,e={rTTNR:"getAll",UJwgX:t(1230)+"ys",jDtav:t(1150),lGuJW:function(a){return a()},SvSxX:t(1800),ahiyf:t(1547),VTpwn:t(774),qqijR:function(a,c){return a(c)}},r="4|1|0|2|5|3"[t(906)]("|"),s=0;for(;;){switch(r[s++]){case"0":fu=[t(904),t(1663),e[t(1107)],e[t(607)],e[t(1695)]];continue;case"1":e[t(752)](iu);continue;case"2":lu=[e[t(1180)],"add",e.ahiyf,e[t(1924)]];continue;case"3":e[t(1025)](wy,a=>({...a,get:(c,f,l)=>su(c,f)||a.get(c,f,l),has:(c,f)=>!!su(c,f)||a[t(541)](c,f)}));continue;case"4":e.lGuJW(iu);continue;case"5":eo=new Map;continue}break}}}),vy={idb:function(t){let e=M;t[e(995)]=Promise[e(1302)]()[e(1711)](()=>(Sy(),du))[e(1711)](function(r){return r})}},ou={};function Tt(t){let e=M,r={ODQHg:e(763)+"1"},s=r[e(708)][e(906)]("|"),a=0;for(;;){switch(s[a++]){case"0":var c=ou[t];continue;case"1":return f[e(995)];case"2":vy[t](f,f.exports,Tt);continue;case"3":var f=ou[t]={exports:{}};continue;case"4":if(c!==void 0)return c[e(995)];continue}break}}Tt.d=(t,e)=>{let r=K;for(var s in e)Tt.o(e,s)&&!Tt.o(t,s)&&Object["definePr"+r(1149)](t,s,{enumerable:!0,get:e[s]})},(()=>{let t=M;Tt.o=(e,r)=>Object.prototype["hasOwnPr"+t(1149)].call(e,r)})(),(()=>{let t=M,e={MMOoq:function(r,s){return r!=s},dtfYu:t(1623)+"d",SmBKm:t(700)+"le"};Tt.r=r=>{let s=t;e.MMOoq(e[s(1204)],typeof Symbol)&&Symbol[s(1861)+s(1437)]&&Object[s(1889)+s(1149)](r,Symbol[s(1861)+s(1437)],{value:s(1608)}),Object[s(1889)+s(1149)](r,e[s(1884)],{value:!0})}})();var Ee={};(()=>{let t=M,e={hkTNa:function(o,n){return o(n)},smLRr:function(o,n){return o+n},ShlkU:function(o,n){return o*n},Uavhe:function(o,n){return o===n},quZta:t(724),erpkz:t(1328),skQWf:function(o,n){return o(n)},rmuHB:function(o,n,i){return o(n,i)},uaNnI:t(797),Fwlrc:function(o,n){return o+n},dUsrq:t(1782),pESpz:"ffff",AkdRa:function(o,n){return o||n},CmPSs:t(1623)+"d",zrrjJ:function(o,n){return o===n},JhCHU:"eBFwt",VsnoM:t(1009)+t(1009)+t(1009)+t(1009),TUcsJ:function(o,n){return o||n},WiuIA:function(o,n){return o>=n},byGbK:function(o,n){return o===n},TCFDX:function(o,n){return o-n},YNDnR:function(o,n){return o>n},BzNZH:"hdgav",IXypm:function(o,n){return o<n},uQpim:function(o,n){return o!==n},hNHEc:t(1916),JnPeo:function(o,n){return o!==n},RlVVN:function(o,n){return o===n},oMFzb:function(o,n){return o-n},BcGCW:function(o,n){return o!==n},jeTju:function(o,n,i){return o(n,i)},ZOfxA:function(o,n){return o!==n},zegbS:function(o,n,i){return o(n,i)},VXxEs:function(o,n){return o(n)},YkycV:function(o,n,i){return o(n,i)},FAdFm:function(o,n,i){return o(n,i)},SOUCP:function(o,n){return o&n},gSuqJ:t(621)+t(1289)+t(1681)+t(1365),BIlBh:function(o){return o()},AwqHY:function(o,n){return o(n)},cJfNz:function(o,n){return o+n},tnJaV:t(1514),BBDwR:function(o,n,i){return o(n,i)},NLLNm:function(o,n,i){return o(n,i)},wdLko:function(o,n,i){return o(n,i)},OTjzV:function(o,n){return o!==n},otaVa:function(o,n,i){return o(n,i)},TcFJu:function(o,n,i){return o(n,i)},SjaBv:function(o,n){return o(n)},AXdQa:function(o,n,i){return o(n,i)},MMaKE:function(o,n,i){return o(n,i)},yUhlX:function(o,n){return o!==n},vwTeO:function(o,n,i){return o(n,i)},KjLhn:function(o,n){return o!==n},uZiOq:"laorI",qRlzG:function(o,n,i){return o(n,i)},wVGcK:function(o,n,i){return o(n,i)},awQBg:function(o,n){return o!==n},zJqLR:t(600),WBMjK:function(o,n,i){return o(n,i)},uRWVk:function(o,n,i){return o(n,i)},vNwib:function(o,n){return o(n)},AsIuf:t(1389),xAQDB:"ping_once_timeout",Yajdm:function(o,n,i){return o(n,i)},MNXrE:t(744)+t(807)+"s",xRlxu:function(o,n){return o(n)},aJItD:t(1405),VaNbu:function(o,n){return o>>>n},SUQiM:function(o,n,i){return o(n,i)},mtYfj:function(o,n){return o(n)},pgRAI:function(o,n){return o(n)},NDWHH:function(o,n){return o(n)},uuooM:function(o,n,i){return o(n,i)},xcsXV:function(o,n){return o(n)},suzPo:function(o,n,i){return o(n,i)},dYRDL:function(o,n,i){return o(n,i)},qNaoe:function(o,n){return o(n)},ZIvEp:t(621)+t(1289)+t(1681)+t(1294),DWtri:function(o,n,i){return o(n,i)},UXCOU:t(1742)+t(1340)+t(1344),ZxJTq:function(o,n){return o!==n},bACIr:t(1548),sFxNm:t(1156),fKkoE:function(o,n){return o>>n},LDVlr:function(o,n){return o>=n},aznYR:t(1052),VKDIK:"qpjDG",bkNkE:function(o,n){return o===n},ezlgA:t(1817)+t(989),Yjofu:function(o,n){return o+n},pltIX:function(o,n){return o>n},IztIf:t(1206)+t(989),vcpBm:function(o,n){return o*n},pwwZT:function(o,n){return o>n},ZkwXd:function(o,n,i){return o(n,i)},hdmpf:t(1179),CecHZ:function(o,n){return o===n},AvEGb:function(o,n){return o&n},mSrNP:function(o,n){return o(n)},RijoT:function(o,n){return o===n},bCVet:function(o,n){return o&n},deVYN:function(o,n){return o+n},QNfVW:function(o,n){return o+n},auUOr:function(o,n){return o|n},DkPYG:function(o,n){return o<<n},bSjpj:function(o,n){return o&n},guOPX:function(o,n){return o&n},WEmha:function(o,n){return o==n},TfYQG:function(o,n){return o+n},HIjWr:"owKFN",ZYfhy:function(o,n){return o+n},mtYpV:function(o,n){return o!==n},yMNrW:function(o,n){return o&n},XWdFQ:function(o,n){return o|n},sICRR:function(o,n){return o<<n},htKkv:function(o,n){return o|n},AoaMP:function(o,n){return o<<n},Zneap:function(o,n){return o<n},hgVHy:function(o,n){return o<=n},ApgsO:function(o,n){return o&n},BwCiL:function(o,n){return o+n},PAuYt:function(o,n){return o+n},PsGLr:function(o,n){return o+n},efHmP:function(o,n){return o+n},NfcRC:function(o,n){return o!==n},oChGp:function(o,n){return o&n},KBKzF:function(o,n){return o|n},xUeIv:function(o,n){return o<<n},CWNQc:function(o,n){return o|n},sDpcr:function(o,n){return o<<n},SCxNF:function(o,n){return o&n},kBUIc:function(o,n){return o<<n},LVDbE:function(o,n){return o&n},aROVO:function(o,n){return o&n},efDCY:function(o,n){return o>n},ENLwn:function(o,n,i){return o(n,i)},Xkzyj:function(o,n){return o>>n},KucUh:function(o,n){return o+n},OPYjt:function(o,n){return o&n},TULYr:function(o,n,i,d){return o(n,i,d)},qanqZ:function(o,n){return o<n},ZLuzd:function(o,n){return o>=n},yjwvP:function(o,n){return o<=n},sXoXn:function(o,n){return o<n},neeye:function(o,n){return o<<n},NLfnF:function(o,n){return o<n},ycNgR:function(o,n){return o<n},DznvY:function(o,n,i){return o(n,i)},jxcNa:function(o,n){return o+n},QPjPV:function(o,n){return o+n},WmoDp:function(o,n){return o<<n},nCMxE:function(o,n){return o<n},rYxbg:function(o,n){return o|n},dmtff:"wCwtq",eADSM:function(o,n){return o>>n},TEjwH:function(o,n){return o>>n},bjehN:function(o,n){return o&n},SKoYT:function(o,n){return o|n},SlMBx:function(o,n){return o>>n},EKXqg:function(o,n){return o&n},POjjV:function(o,n){return o(n)},iiOWt:function(o,n,i){return o(n,i)},IRDVb:"XxUOZ",YixmS:function(o,n,i){return o(n,i)},syAVu:"YLyfK",gFJaU:function(o,n){return o&n},gZDWL:function(o,n){return o<<n},eZLfp:function(o,n){return o&n},imfqC:function(o,n){return o&n},qOdSb:function(o,n){return o&n},AkzVC:function(o,n){return o&n},wJpex:function(o,n){return o|n},QehWH:function(o,n,i){return o(n,i)},WmJbU:function(o,n){return o(n)},yBfva:function(o,n){return o&n},XADTJ:function(o,n){return o<<n},KeAFt:function(o,n){return o<<n},JJKeN:function(o,n){return o&n},vMCxl:function(o,n){return o(n)},YyNeh:function(o,n){return o&n},aDSZS:"penMt",AZPlS:t(497),nHNMk:function(o,n){return o(n)},IFLpB:t(1380),dckDR:function(o,n){return o(n)},fOlhq:function(o,n){return o&n},zJxrW:function(o,n){return o&n},FULch:function(o,n){return o&n},XrqEp:function(o,n){return o&n},tOIxe:function(o,n){return o|n},wPdeI:function(o,n){return o<<n},FIbUX:function(o,n){return o>>>n},anrCB:function(o,n){return o<<n},GWRNl:function(o,n){return o<n},RGEnB:function(o,n){return o<n},cXqXv:function(o,n){return o<n},vMUqL:function(o,n){return o<n},zWhOu:function(o,n){return o&n},cgXjV:function(o,n){return o>>>n},iGxga:function(o,n){return o+n},wuacG:function(o,n){return o|n},TzdeU:function(o,n){return o>>>n},yPpoZ:function(o,n){return o>>>n},VVRPD:function(o,n){return o+n},QjHvT:function(o,n){return o!==n},MmwEH:function(o,n){return o&n},cVEBl:function(o,n){return o+n},JyDfz:function(o,n){return o!==n},plopD:function(o,n){return o&n},eeDOY:function(o,n){return o+n},aqJqI:function(o,n){return o!==n},doEkK:function(o,n){return o&n},RsmSv:function(o,n){return o>>>n},tSLhD:function(o,n){return o|n},GEFQX:function(o,n){return o>>>n},hwqXp:function(o,n){return o+n},VKoSm:function(o,n){return o!==n},JdZIh:function(o,n){return o(n)},OgkkH:function(o,n){return o|n},WuNBZ:function(o,n){return o|n},ATHYE:function(o,n){return o===n},YSHvc:function(o,n){return o<<n},uAEkJ:function(o,n){return o<<n},LFame:function(o,n){return o<<n},wtaJv:function(o,n){return o|n},YNQyA:function(o,n){return o|n},xZaKH:function(o,n){return o|n},wSvPs:function(o,n){return o<<n},BbVgM:function(o,n){return o<<n},VMnDO:function(o,n){return o|n},XDlMH:function(o,n){return o|n},KYGht:function(o,n){return o<<n},Tgtyq:t(1146),BWTxC:function(o,n){return o>>>n},gceZM:function(o,n){return o|n},CNKoZ:function(o,n){return o|n},BtKRu:function(o,n){return o>>>n},NcHyJ:function(o,n){return o|n},oPAja:function(o,n){return o|n},oGewt:function(o,n){return o&n},bTlAG:function(o,n){return o>>>n},UMKwd:function(o,n){return o&n},elCww:function(o,n){return o>>>n},OsVOc:function(o,n){return o>>>n},liQzW:function(o,n){return o>>>n},kbYHp:function(o,n){return o<=n},cjwUs:function(o,n){return o%n},AImWq:function(o,n){return o/n},KLwDj:function(o,n){return o>>>n},FrkFc:function(o,n){return o&n},SPtyT:function(o,n){return o>>>n},OfFRt:function(o,n){return o>>>n},PFQKh:function(o,n){return o+n},BHJPW:function(o,n){return o>>>n},blzbL:function(o,n){return o+n},BDNhA:function(o,n){return o|n},GDybi:function(o,n){return o!==n},HVofL:function(o,n){return o===n},wSSrW:function(o,n){return o>>>n},vEMSq:function(o,n){return o===n},NUTXs:function(o,n){return o&n},LcMIy:function(o,n){return o&n},IsRYQ:function(o,n){return o&n},Yoobm:function(o,n){return o>>>n},QqWEY:function(o,n){return o===n},TJkmw:t(548),NRKRO:"KfNCO",HMjPf:function(o,n){return o&n},ypvli:function(o,n){return o&n},VaGWe:function(o,n){return o>>>n},kehIG:function(o,n){return o&n},wfpvK:function(o,n){return o>>>n},BBWmx:"NATIVE_E"+t(796),NzwWb:t(941)+t(510),jOzKC:"MAX_RETR"+t(770)+"R",XWMli:t(1449)+t(1359),rXEiq:t(1521)+"OR",DbEVc:"0|2|5|3|"+t(961),BYcIc:function(o,n){return o<n},UPHSQ:function(o,n){return o<<n},irRsz:function(o,n){return o===n},ghrKJ:function(o,n){return o===n},NnNWi:t(990),Diofp:"opUYK",TipdN:function(o,n){return o+n},Uiyjn:function(o,n){return o(n)},VFitz:function(o,n,i){return o(n,i)},bIaJa:function(o,n){return o===n},qfMmd:"UoCmx",IUDLP:t(1609),AqMHG:"Kfmoj",Sgyhv:function(o,n){return o===n},xSDok:function(o,n){return o===n},CfStu:function(o,n){return o==n},pPvRf:function(o,n){return o===n},QUqnU:t(1309),nZaMl:function(o,n,i){return o(n,i)},oKkhW:function(o,n,i){return o(n,i)},iMiFT:function(o,n){return o!==n},LKTyT:t(1839),aARwL:function(o,n){return o===n},xzDnD:function(o,n){return o instanceof n},ZMwNk:function(o,n){return o+n},sDxDI:t(1940)+t(1483),mYOaH:function(o,n){return o+n},oWKrC:function(o,n){return o===n},CNSug:function(o,n){return o===n},cDAkc:function(o,n){return o<n},YUXTf:function(o,n){return o|n},LhiwI:t(1427)+t(786),vYyeo:function(o,n){return o&n},HQPuq:function(o,n){return o|n},MzRUL:function(o,n){return o>>n},kolUf:function(o,n){return o&n},xtAaD:function(o,n){return o+n},XEXkQ:function(o,n){return o+n},WFrpQ:function(o,n){return o>>n},KGoPl:function(o,n){return o|n},VUmqr:function(o,n){return o&n},FUlhU:function(o,n){return o|n},qHyqW:function(o,n){return o===n},zTgty:"vrdEK",ZYSij:t(482),soujM:"Qkmcz",Gdlro:t(1668),bInkK:function(o,n){return o(n)},VUQiO:t(503),OZkvX:function(o,n,i){return o(n,i)},MiaWD:function(o,n){return o!==n},LNkDB:"tiFaJ",tHZnk:function(o,n,i){return o(n,i)},fpoHN:function(o,n){return o+n},Egztg:function(o,n,i){return o(n,i)},ORYGy:t(963),GidnM:t(1845),hzicK:function(o,n){return o===n},NpAkL:t(1574),RBwqi:function(o,n){return o||n},IKITE:function(o,n){return o!=n},zqGkC:function(o,n){return o!=n},LyKtZ:"next() c"+t(618)+t(1639)+t(1232)+t(1751),oDYyR:function(o,n){return o(n)},BZeKj:function(o,n){return o<n},wyAmG:function(o,n){return o&n},LOSCC:function(o,n,i){return o(n,i)},YuoEP:function(o,n){return o===n},KUASB:"GVFjb",gDKQZ:function(o,n){return o-n},AmLUj:t(1141),DWWzl:t(1372),LMaZa:function(o,n){return o>=n},IgXFO:function(o,n){return o<<n},OGKQN:function(o,n){return o&n},rPLWY:function(o,n){return o<n},IQNtL:function(o,n){return o|n},jaFhx:function(o,n){return o<<n},ecBYE:function(o,n){return o&n},gbzHS:function(o,n){return o>=n},eoAkE:function(o,n){return o-n},UrYxO:function(o,n){return o<<n},Ilcwz:function(o,n){return o&n},gfLsu:function(o,n){return o<<n},haImq:function(o,n){return o<<n},Olwvw:function(o,n){return o&n},CICRs:function(o,n){return o>>n},lchJk:function(o,n){return o|n},ublln:function(o,n){return o|n},AoAJL:function(o,n){return o&n},HJAFy:function(o,n){return o+n},RXQjk:"4|5|3|0|"+t(1780),NyOzr:function(o,n){return o|n},ibRQh:function(o,n){return o&n},yzmpQ:function(o,n){return o>>n},wFOAQ:function(o,n){return o+n},PblAq:function(o,n){return o+n},jOqeG:function(o,n){return o&n},MceEm:function(o,n){return o|n},gqZBe:function(o,n){return o>>n},NxHNu:function(o,n){return o|n},XrFNJ:function(o,n){return o|n},tnmdO:t(1220),SLegw:function(o,n){return o(n)},IbrAK:function(o,n,i,d){return o(n,i,d)},tqJCR:function(o,n){return o instanceof n},iqvuA:function(o,n){return o instanceof n},PLBqh:t(1606)+"ion/json",VyQQS:"text/plain;chars"+t(1098),GmYzF:t(778),LDBTB:t(593),ljynI:t(625)+t(1045),hyaLD:"&jscallb"+t(1617)+"tierJSONP",ljgWa:function(o,n){return o!==n},RIvQq:t(1478),XWKoY:t(568),ojyDZ:t(455),pmHbj:function(o,n){return o+n},BliQE:"http",dzbNZ:function(o,n){return o(n)},aIORl:t(645)+t(1087),FcgAl:t(1275),XuliF:t(1203)+t(1748),PvoZv:function(o,n,i,d){return o(n,i,d)},uYSRU:t(1203)+"er_ack_m"+t(1444),IaNIo:function(o,n){return o!==n},JEZhi:t(1826),NoFYB:function(o,n){return o||n},wsbVH:t(1261),ozsdZ:function(o,n){return o||n},jOwdz:t(835),tSFPo:function(o,n){return o||n},FQGMi:function(o,n,i,d){return o(n,i,d)},oAhzY:t(1789),CBMnB:function(o,n){return o||n},Rdsmj:"pagehide",ddGcB:t(449),pYFVt:t(687),OHrDS:t(1865),lkuKv:function(o,n){return o||n},eWkvb:t(463),xqHAu:function(o,n){return o||n},CarfQ:function(o,n){return o||n},tXqWe:t(454)+t(1758)+"d",yLNCb:t(1251),fGbhf:t(787),kGgzd:function(o,n,i){return o(n,i)},ruBcE:t(1645),zEPaM:t(555)+"id",YMiJT:function(o,n,i){return o(n,i)},DWQhx:function(o,n){return o===n},dOKYe:t(1177),EWHiJ:function(o,n,i){return o(n,i)},YIoVz:function(o,n,i){return o(n,i)},XjFYM:t(1034),IGMhB:function(o,n){return o(n)},LbLsj:function(o,n,i,d){return o(n,i,d)},HeHVQ:t(1203)+"er_qos_ack",uTNdG:"x_fronti"+t(903)+"k",XNMTV:function(o,n,i){return o(n,i)},KoWbS:t(918),ehDEj:t(740),hUwjg:function(o,n,i,d){return o(n,i,d)},KsDXn:"is_ack",xJanY:function(o,n){return o&&n},WYtxM:"ack_code",NzvWa:function(o,n){return o(n)},SDFHF:function(o,n){return o<n},CYxhY:function(o,n){return o!==n},ULIcK:"EsYTj",aSHcQ:t(1131),xhfwD:t(742),aSEnh:function(o,n,i){return o(n,i)},nIVxv:t(758)+t(777),cZCqr:t(748),xMftM:function(o,n){return o(n)},ayAiS:function(o,n){return o(n)},iRcVr:function(o,n){return o===n},biwvC:t(581),onqGj:"aDWXj",fulnS:function(o,n){return o instanceof n},thmis:t(1606)+"ion/json"+t(1696)+t(1061),Ahpnl:t(1594)+"e",mSAum:t(613),IutBJ:function(o,n){return o<n},YFCom:function(o,n){return o>n},KWNDc:function(o,n){return o||n},JMMxw:function(o,n){return o>>>n},lRAbP:function(o,n){return o+n},KuOkR:function(o,n){return o+n},jmxrD:function(o,n){return o+n},ODNWf:t(761)+t(1886)+"ge: ",mubJy:t(1226),prMyg:t(1317)+t(1718)+"e",nflcG:function(o,n){return o>=n},PcgCc:function(o,n){return o&n},QuWOS:function(o,n){return o+n},CIUEe:"aVcUk",YTTiY:"aFrFf",wVLIT:function(o,n){return o<n},iyiCJ:function(o,n){return o>>>n},UwcTT:function(o,n){return o<<n},NHiHt:t(1175)+"4",vSapy:function(o,n){return o+n},ZEbZF:function(o,n,i,d){return o(n,i,d)},OCZaO:function(o,n,i,d){return o(n,i,d)},sALBB:function(o,n){return o|n},RzlEh:function(o,n){return o|n},kqtOa:function(o,n){return o<<n},cCYiP:function(o,n){return o<<n},CmZoE:function(o,n){return o+n},rxkPE:function(o,n){return o|n},KwBZE:function(o,n){return o<<n},RdPyJ:function(o,n){return o>>>n},MzQXf:function(o,n){return o&n},nngwV:function(o,n){return o+n},vnEUJ:function(o,n){return o>>>n},qmmNs:function(o,n){return o+n},IfQRw:function(o,n){return o&n},AxVky:function(o,n){return o&n},pDGCC:function(o,n){return o+n},HRUow:function(o,n){return o+n},fGJQM:function(o,n){return o===n},JcVDs:"uYkZH",mbpBb:function(o,n){return o<n},mNFUe:function(o,n){return o&n},JgSyZ:function(o,n){return o<<n},EOjiu:function(o,n){return o>>>n},RAUcc:function(o,n){return o(n)},CFYfm:"header",iCnEi:t(1683),nnLtw:function(o,n,i,d){return o(n,i,d)},rLDKE:t(781)+"ervice",iGKFv:function(o,n){return o(n)},ZhaRE:function(o,n,i,d){return o(n,i,d)},VQmvn:function(o,n){return o+n},HjKGl:function(o,n,i){return o(n,i)},vYfHF:t(837)+t(1864),GFgDZ:t(718)+"_EXIST",LgSQf:t(1582),hCFmb:t(1189),MXFxP:function(o,n){return o!==n},OWNTD:"wHNfk",rmAZk:"NamzD",mOGzf:t(1303)+t(1542),atVTf:t(701),svyMn:t(682),NtVIK:function(o,n,i,d){return o(n,i,d)},ZOqjj:function(o,n,i){return o(n,i)},BcXRc:function(o,n){return o<n},BBSXh:function(o,n){return o||n},VkWYx:t(623),xnFyK:"reconnect",WuAVL:"start",TOYuS:function(o,n,i,d){return o(n,i,d)},iqWeF:t(1203)+"er_msgid",slAdh:function(o,n){return o(n)},yKxWt:function(o,n,i){return o(n,i)},MDmpL:t(1203)+t(1489),KZToz:t(1255)+"s",PuhPn:t(884)+t(1006)+"e",tqGst:function(o,n){return o(n)},IetEJ:t(884)+t(1153)+"ue",Qwwjq:function(o,n){return o>n},LjmBS:t(1426),StxzM:t(747),SqOZY:function(o){return o()},BdokJ:t(1020),sWnhP:function(o){return o()},YVEYB:function(o){return o()},PPKkq:function(o){return o()},OVDIw:function(o){return o()},yVBYt:function(o){return o()},UTpCh:function(o,n){return o&&n},jlUFE:function(o){return o()},EGHqL:function(o,n,i){return o(n,i)},Arrti:function(o){return o()},XKunE:function(o,n){return o(n)},EIaXP:function(o,n){return o(n)},ejonp:function(o){return o()},wtunh:function(o,n){return o>=n},PTOzA:function(o,n){return o>=n},kVxlo:function(o,n){return o|n},OznTp:function(o,n){return o%n},ZMyNT:function(o,n){return o/n},OWbZK:function(o){return o()},aUMVE:function(o,n){return o<n},cNYwA:t(1164),ZhoiP:t(1272),tgEvw:function(o,n){return o===n},FVAxP:function(o,n){return o!==n},skozm:function(o,n){return o!==n},jpuxX:"Hmfig",kDzjB:t(1642),hGKbR:function(o,n){return o!==n},pTaYu:"HqGeJ",XPeRC:function(o,n,i){return o(n,i)},pwUfZ:function(o,n,i){return o(n,i)},IGTfn:t(1190),wijfm:function(o,n){return o(n)},tUvVj:function(o,n,i){return o(n,i)},fDcAx:function(o,n){return o!==n},GwIXF:t(1134),bKRCc:function(o,n,i,d){return o(n,i,d)},qOkFM:function(o,n,i){return o(n,i)},Ivdld:function(o,n){return o===n},RWgAa:"always",UUIhD:function(o,n,i,d){return o(n,i,d)},qDdjW:function(o,n){return o!==n},NiKdx:t(1001)+t(458),VpRvl:t(512),ccGtQ:t(1732)+"rovide v"+t(694),LrKoz:function(o,n){return o===n},WAYrz:t(1725),khEeF:t(1438)+t(1350)+t(851)+"ct",tMFnC:function(o,n){return o===n},vaNNM:function(o,n){return o===n},wNmQz:function(o,n,i){return o(n,i)},KRszb:t(462),fYsgG:"UnPQi",rvAcE:t(477),kiFUy:"offline",cUoDo:function(o,n){return o===n},BmKyD:t(1798),KCOOI:"WbXRK",kHkxK:function(o,n){return o!==n},sVVos:t(1060),QaviY:"wss://",JggXd:t(577),DgRxc:t(1790),bRGPX:t(1732)+t(1446)+"ddID, de"+t(866)+t(1709),kultL:function(o,n){return o==n},VuGGP:function(o,n,i){return o(n,i)},YxtWf:t(1913),WExvb:t(1121)+"0",hFQFz:"xlEnX",ujujy:function(o,n){return o===n},OCKFx:t(660)+">",UsKrk:function(o,n){return o-n},RRkOO:function(o,n){return o+n},EpdgW:function(o,n){return o(n)},YcjoY:function(o,n){return o!==n},VRsjd:t(523),yHtAK:t(749),jsQLi:function(o,n,i){return o(n,i)},KXulR:"timeout",ENQlf:function(o,n){return o>>n},muPXV:t(1508)+"ay, try reconnec"+t(1684)+t(456),jxHMv:t(1199)+t(1495)+"onnecting",WkGjA:function(o,n){return o||n},YeIcq:function(o,n){return o==n},ULaxj:function(o,n){return o!==n},DcCdL:t(815),ZROcW:t(1237),DmHcF:"send_ack",auixb:"1|0|2|4|3",tZJcJ:"message",qNrya:t(909)+"1",YbkNn:t(1278),Ywxxx:function(o,n){return o===n},nQjKx:function(o,n){return o===n},sPctz:t(1158),FnvNM:function(o,n){return o===n},bBxkV:t(1403),ACJzR:function(o,n,i){return o(n,i)},uYKUn:t(1508)+t(788)+t(753)+t(574),wRsPd:function(o,n){return o===n},OBJvL:t(1085),tftpo:function(o,n){return o+n},YtmBj:function(o,n){return o>>>n},kmxIt:function(o,n){return o>>>n},YnEQE:function(o,n){return o>>>n},gdGhG:function(o,n){return o&n},NvgkF:function(o,n){return o&n},fkxpP:function(o,n){return o>>>n},mZZcA:function(o,n){return o===n},YIuGw:t(1533),uMlAD:function(o,n){return o===n},hpgTD:function(o,n){return o===n},zpoaw:t(1330)+"s alread"+t(610),XabYa:t(1026),yTjqd:t(1363),byKYA:"please provide a"+t(1872)+t(1408)+t(1369)+t(779)+"ng or an"+t(1066)+t(1698),YsZNI:function(o,n){return o==n},ZfhMu:"number",tQzlE:function(o,n){return o!=n},MjFRK:function(o,n){return o instanceof n},Svpfh:function(o,n){return o instanceof n},wuPhM:function(o,n){return o||n},VeaQC:t(1732)+t(1846)+t(1432)+t(1821),akwdK:function(o,n){return o instanceof n},TCgZL:"enqueue",xhRWh:function(o,n){return o==n},WDHnX:"eRvtg",jnJtv:t(1550),YwvYf:function(o,n){return o+n},gWGzM:function(o,n){return o&n},WDHwu:function(o,n){return o+n},umxCw:function(o,n){return o>>>n},pTWxI:function(o,n){return o&n},aAemv:function(o,n){return o===n},iSSSI:t(720),LstTf:function(o,n){return o!==n},xmskF:t(696),eThIy:"\0\0\0\0\0\0\0\0",VJnJj:function(o,n){return o/n},ugOnK:function(o,n){return o===n},XJwSJ:t(946),oiYXR:function(o,n){return o!=n},HVGch:function(o,n){return o===n},AhJeF:function(o,n){return o!=n},PmahB:function(o,n){return o!=n},BIPud:"Object",qjIvq:function(o,n){return o===n},ImlZE:t(632)+t(987)+"lobalScope",ZUOmI:function(o,n){return o==n},KIZMt:function(o,n){return o!=n},noomL:t(1836)+t(689)+t(1208),GDNSV:function(o,n){return o!=n},aLngY:function(o,n){return o!=n}};Tt.r(Ee),Tt.d(Ee,{FWS:()=>Fh,CustomErrorEvent:()=>h0,createCloseEvent:()=>at,ReconnectEvent:()=>x0,createErrorEvent:()=>et,decodedFrame:()=>qn,createOpenEvent:()=>y0,CustomCloseEvent:()=>p0,createReconnectEvent:()=>Po,FrontierMessageEvent:()=>m0,encodeFrame:()=>Ke,createMessageEvent:()=>_0,OpenEvent:()=>w0,ErrorCode:()=>Wt,Event:()=>jn,MessageEvent:()=>g0});let r="";function s(o=""){let n=t,i="02",d=""+Date[n(993)](),u=r||(r=e[n(535)](x,o)),p=Math[n(1435)]()[n(1861)](16).slice(-6);return e[n(513)](e.smLRr(e[n(513)](i,d),u),p)}function a(){let o=t;return e[o(513)](e[o(1922)](1e4,Date[o(993)]()),Math[o(707)](e[o(1922)](1e4,Math[o(1435)]())))}function c(o){let n=t,i={MgmPj:"blocked"};if(e[n(1729)](e[n(1840)],e[n(1080)])){let d=_0x32b944["deleteDa"+n(1414)](_0x56e3e5);return _0x571e60&&d.addEventListener(xceowS.MgmPj,()=>_0x37952f()),_0x2cf25c(d)[n(1711)](()=>{})}else return e[n(513)](e[n(1688)](Array,8)[n(641)]("0"),e[n(1699)](parseInt,o,10)[n(1861)](2)).slice(-8)}function f(o){let n=t,i={eboXM:function(d,u,p){return e[K(1699)](d,u,p)}};if(e[n(1729)](e[n(771)],e.uaNnI))return e.Fwlrc(Array(4)[n(641)]("0"),parseInt(o,2).toString(16))[n(956)](-4);{let d=i[n(647)](_0x2f9e8a,"error",{message:_0x1c35b1.message,code:_0x4d91fa[n(1449)+n(1359)],error:_0x1c666b});this[n(1485)+n(1062)+"ent"](d)}}function l(o){let n=t,i=o[n(906)](/\./)[n(1676)](p=>c(p)),d=[];return d[0]=e[n(535)](f,i[0]+i[1]),d[1]=f(e[n(1130)](i[2],i[3])),[e[n(1543)],e[n(1543)],e[n(1543)],n(1782),e[n(1543)],e.pESpz,d[0],d[1]][n(641)]("")}function x(o){let n=t;if(e[n(764)](e[n(1018)],n(924))){let i=/(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}/[n(471)](o),d=/(([0-9a-fA-F]{1,4}:){7,7}[0-9a-fA-F]{1,4}|([0-9a-fA-F]{1,4}:){1,7}:|([0-9a-fA-F]{1,4}:){1,6}:[0-9a-fA-F]{1,4}|([0-9a-fA-F]{1,4}:){1,5}(:[0-9a-fA-F]{1,4}){1,2}|([0-9a-fA-F]{1,4}:){1,4}(:[0-9a-fA-F]{1,4}){1,3}|([0-9a-fA-F]{1,4}:){1,3}(:[0-9a-fA-F]{1,4}){1,4}|([0-9a-fA-F]{1,4}:){1,2}(:[0-9a-fA-F]{1,4}){1,5}|[0-9a-fA-F]{1,4}:((:[0-9a-fA-F]{1,4}){1,6})|:((:[0-9a-fA-F]{1,4}){1,7}|:)|fe80:(:[0-9a-fA-F]{0,4}){0,4}%[0-9a-zA-Z]{1,}|::(ffff(:0{1,4}){0,1}:){0,1}((25[0-5]|(2[0-4]|1{0,1}[0-9]){0,1}[0-9])\.){3,3}(25[0-5]|(2[0-4]|1{0,1}[0-9]){0,1}[0-9])|([0-9a-fA-F]{1,4}:){1,4}:((25[0-5]|(2[0-4]|1{0,1}[0-9]){0,1}[0-9])\.){3,3}(25[0-5]|(2[0-4]|1{0,1}[0-9]){0,1}[0-9]))/[n(471)](o);return i?e[n(535)](l,o):d?h(o):e.VsnoM}else{if(_0xc18fde)return new _0x8dca22(_0xe5a02d[n(1188)],_0x350cec[n(1687)]);if(_0xc6b8f3||_0x179b7f)return new _0x4bd497(_0x3164e0[n(1188)],_0x5ee63d.protocol,_0xef69e5[n(966)]);if(e[n(1544)](_0x514764,_0x57779d)&&e[n(782)]!=typeof _0x257270&&_0x57292e)return new _0x1281b8(_0x50f8a7.url,_0x3829f9[n(1687)+"s"])}}function h(o){let n=t,i="",d=[],u=0,p=0,S=!0,b="0000";if(e.YNDnR(o[n(1168)]("::"),-1))if(e[n(1691)]!==e[n(1691)]){let g=this._qosDB[n(1033)+n(706)+"nc"](this[n(1787)]),T=_0x9c1555[n(1313)](e[n(481)](g,"{}"));return _0x33a02a[n(829)](T)}else{let g=o[n(906)]("::");for(let P=0;e[n(959)](P,g.length);P++){if(e[n(1008)](e[n(984)],e.hNHEc))return!!(e[n(619)](this[n(1713)+n(1280)],this.endpoints[n(1541)])||e[n(1634)](this[n(1713)+n(1280)],e[n(1707)](this[n(1737)+"s"][n(1541)],1))&&e[n(764)](this[n(1534)+n(804)+"riesCount"],this[n(1862)+"es"]));{let B=g[P];if(B.indexOf(":")>0){let j=B[n(906)](":");S&&(u=j[n(1541)]),p+=j.length;for(let V=0;V<j.length;V++)if(e[n(612)](4,j[V][n(1541)])){let J=b[n(1500)+"g"](0,e[n(1707)](4,j[V].length)),He=J[n(1835)](j[V]);d[n(1416)](He)}else d.push(j[V]);S=!1}else{if(e[n(1008)](4,B[n(1541)])){let j=b.substring(0,e[n(1707)](4,B[n(1541)])),V=j.concat(B);d[n(1416)](V)}else d[n(1416)](B);S&&(u+=1),p+=1,S=!1}}}let T="";for(let P=0;e.IXypm(P,e.TCFDX(8,p));P++)T=T[n(1835)](b);for(let P=0;P<d[n(1541)];P++)e[n(814)](P,u)&&(i=i[n(1835)](T)),i=i[n(1835)](d[P]);return i}{let g=o[n(906)](":");for(let T=0;e[n(959)](T,g.length);T++){let P=g[T];if(e[n(1008)](4,g[T][n(1541)])){let B=b.substring(0,e[n(1036)](4,g[T][n(1541)])),j=B[n(1835)](P);i=i[n(1835)](j)}else i=i.concat(P)}return i}}function m(o,n){let i=t,d=o[i(1324)];e[i(532)](void 0,d)&&(e.rmuHB(Y,n,10),e[i(848)](Le,n,d));let u=o.value;e[i(1090)](void 0,u)&&(e.zegbS(Y,n,18),e[i(1699)](Le,n,u))}function E(o){let n=t,i={};e:for(;!e[n(1283)](N,o);){let d=e[n(535)](_e,o);switch(d>>>3){case 0:break e;case 1:i[n(1324)]=e[n(1276)](we,o,_e(o));break;case 2:i.value=e[n(1056)](we,o,e[n(1688)](_e,o));break;default:e[n(848)](R,o,e.SOUCP(7,d))}}if(e[n(1634)](void 0,i[n(1324)]))throw new Error(n(621)+n(1289)+n(1681)+"key");if(e[n(764)](void 0,i[n(1365)]))throw new Error(e[n(1890)]);return i}function C(o){let n=t,i=e.BIlBh(A);return e.zegbS(_,o,i),e[n(1875)](z,i)}function _(o,n){let i=t,d={bdSPq:e.tnJaV,DmMmf:function($e,je,ct){return e[K(1056)]($e,je,ct)},DNAFI:function($e,je){return $e-je}},u=o[i(1439)];u!==void 0&&(e[i(525)](Y,n,8),e[i(1844)](ge,n,u));let p=o.LogID;e[i(1090)](void 0,p)&&(e.FAdFm(Y,n,16),e[i(1343)](ge,n,p));let S=o.service;S!==void 0&&(e[i(1343)](Y,n,24),ge(n,L(S)));let b=o.method;e[i(812)](void 0,b)&&(e[i(1880)](Y,n,32),e[i(1343)](ge,n,e[i(1283)](L,b)));let g=o[i(966)];if(g!==void 0)for(let $e of g){e.TcFJu(Y,n,42);let je=e[i(1171)](A);m($e,je),e[i(848)](Y,n,je[i(880)]),e[i(1844)](ot,n,je),e.SjaBv(k,je)}let T=o["payloadE"+i(483)];e.JnPeo(void 0,T)&&(e[i(611)](Y,n,50),e.jeTju(Le,n,T));let P=o[i(679)+i(1012)];e[i(612)](void 0,P)&&(Y(n,58),e[i(1842)](Le,n,P));let B=o[i(1539)];e[i(703)](void 0,B)&&(Y(n,66),e[i(1679)](Y,n,B.length),fe(n,B));let j=o[i(1460)];if(e[i(1327)](void 0,j))if(e[i(764)](i(637),e.uZiOq)){let $e=_0x54a457[i(1339)][i(956)](_0x5022a8[i(1014)+"et"],e[i(1710)](_0x1a71b3.byteLength,_0x3a6ce8.byteOffset));this[i(1114)]&&this[i(1114)][i(754)]({data:$e,fail:je=>{let ct=i;this[ct(1473)](d[ct(894)],d[ct(960)](_0x10dccc,d[ct(894)],{message:this["_formatE"+ct(1311)+ct(1053)](je)}))}})}else e[i(592)](Y,n,74),e[i(1844)](Le,n,j);let V=o["serverTi"+i(1358)];e.BcGCW(void 0,V)&&(Y(n,82),e[i(1779)](Le,n,V));let J=o[i(511)];J!==void 0&&(Y(n,90),e.jeTju(Le,n,J));let He=o[i(1773)+"e"];if(e[i(1402)](void 0,He))if(e[i(1174)]===i(600))e[i(1404)](Y,n,96),e[i(1700)](ge,n,e[i(1392)](L,He));else{let $e=_0x120859[i(1500)+"g"](0,ZsoUVf.DNAFI(4,_0x43e30.length)),je=$e[i(1835)](_0x31f209);_0x1328f4[i(1416)](je)}}function y(o){return e[t(1614)](v,e.hkTNa(F,o))}function v(o){let n=t,i={izMKL:function(d,u){return e[K(561)](d,u)},HojEf:"timeout",BcMDB:e.MNXrE,hVSWf:e.xAQDB};if(e[n(1729)](e[n(1382)],n(1405))){let d={};e:for(;!e[n(1283)](N,o);){let u=e[n(1688)](_e,o);switch(e[n(1341)](u,3)){case 0:break e;case 1:d[n(1439)]=Un(o,!0);break;case 2:d[n(1294)]=e.SUQiM(Un,o,!0);break;case 3:d[n(1318)]=e[n(651)](_e,o);break;case 4:d[n(1484)]=_e(o);break;case 5:{let p=e[n(1091)](I,o);(d[n(966)]||(d[n(966)]=[]))[n(1416)](e.NDWHH(E,o)),o[n(880)]=p;break}case 6:d[n(1094)+n(483)]=e[n(608)](we,o,e[n(1837)](_e,o));break;case 7:d[n(679)+n(1012)]=e[n(1466)](we,o,e[n(651)](_e,o));break;case 8:d.payload=e[n(934)](se,o,_e(o));break;case 9:d.LogIDNew=e[n(1531)](we,o,_e(o));break;case 10:d[n(680)+n(1358)]=e[n(1779)](we,o,e.vNwib(_e,o));break;case 11:d.msgID=we(o,e[n(561)](_e,o));break;case 12:d[n(1773)+"e"]=e[n(1788)](_e,o);break;default:e.AXdQa(R,o,e.SOUCP(7,u))}}if(e[n(1634)](void 0,d[n(1439)]))throw new Error(n(621)+n(1289)+n(1681)+n(1439));if(e.RlVVN(void 0,d[n(1294)]))throw new Error(e[n(1252)]);if(e[n(1729)](void 0,d[n(1318)]))throw new Error(n(621)+n(1289)+n(1681)+n(1318));if(e[n(764)](void 0,d[n(1484)]))throw new Error(n(621)+n(1289)+n(1681)+n(1484));return d}else{let d={oylnq:function(S,b){return S(b)},bdrjb:e[n(1808)],AgFVH:n(744)+n(807)+"s",flanu:e[n(473)]};this[n(1831)+n(1394)](),this[n(1597)+n(887)+"Id"]=e.Yajdm(_0x4d0754,this[n(669)][n(1277)](this),this[n(1578)][n(1353)+n(1314)]);let u=()=>{let S=n;d[S(1178)](_0x248951,d.bdrjb),this[S(811)](d[S(1613)],u),this[S(811)](d[S(1101)],p)},p=()=>{let S=n;i[S(1088)](_0x273ae8,i[S(1785)]),this[S(811)](i[S(1736)],u),this[S(811)](i.hVSWf,p)};this.on(e[n(1661)],u),this.on(e[n(473)],p),this[n(669)]()}}function I(o){let n=t,i=e.xRlxu(_e,o),d=o[n(880)];return o[n(880)]=e[n(513)](o[n(883)],i),d}function R(o,n){let i=t;switch(n){case 0:for(;e[i(1219)](128,Ae(o)););break;case 2:O(o,e[i(1392)](_e,o));break;case 5:e[i(1233)](O,o,4);break;case 1:e[i(848)](O,o,8);break;default:throw new Error(e[i(1530)]+n)}}function L(o){let n=t;return e[n(1827)](e[n(1624)],e[n(562)])?(o|=0,{low:o,high:e[n(502)](o,31),unsigned:e[n(1050)](o,0)}):this._ws?this[n(1342)][n(931)+"ns"]:""}let w=[];function A(){let o=t,n=w[o(1137)]();return n?(n[o(883)]=n[o(880)]=0,n):{bytes:new Uint8Array(64),offset:0,limit:0}}function k(o){w.push(o)}function F(o){let n=t;return e.byGbK(e[n(971)],e[n(1891)])?!!this[n(802)]:{bytes:o,offset:0,limit:o[n(1541)]}}function z(o){let n=t,i=o[n(1017)],d=o.limit;return e[n(1869)](i[n(1541)],d)?i:i.subarray(0,d)}function O(o,n){let i=t;if(e[i(1325)](o.offset+n,o[i(880)]))throw new Error(e.ezlgA);o.offset+=n}function N(o){let n=t;return e[n(619)](o[n(883)],o.limit)}function U(o,n){let i=t,d=o[i(1017)],u=o[i(883)],p=o[i(880)],S=e[i(1795)](u,n);if(e[i(1757)](S,d[i(1541)])){let b=new Uint8Array(e[i(1922)](2,S));b.set(d),o[i(1017)]=b}return o[i(883)]=S,e[i(1325)](S,p)&&(o[i(880)]=S),u}function W(o,n){let i=t,d=o[i(883)];if(e[i(1757)](e.cJfNz(d,n),o[i(880)]))throw new Error(e.IztIf);return o[i(883)]+=n,d}function se(o,n){let i=t,d=W(o,n);return o[i(1017)].subarray(d,e[i(1795)](d,n))}function fe(o,n){let i=t,d=e[i(934)](U,o,n[i(1541)]);o[i(1017)].set(n,d)}function we(o,n){let i=t,d={MHiei:function(T,P){return e[K(513)](T,P)},KccMI:function(T,P){return T>P},KOllS:function(T,P){return e[K(1335)](T,P)},fJlbs:function(T,P){return e[K(1096)](T,P)}},u=e[i(726)](W,o,n),p=String[i(821)+i(737)],S=o[i(1017)],b="\uFFFD",g="";for(let T=0;e[i(959)](T,n);T++)if(e[i(1402)](i(1179),e[i(810)])){let P=_0x5442c4[i(1017)],B=_0x3ed492[i(883)],j=_0x3e235e.limit,V=uPrErn[i(634)](B,_0x329d64);if(uPrErn[i(728)](V,P.length)){let J=new _0x5c59ea(uPrErn[i(1655)](2,V));J[i(717)](P),_0x45581b[i(1017)]=J}return _0x123f14[i(883)]=V,uPrErn.fJlbs(V,j)&&(_0x5ef2cf[i(880)]=V),B}else{let P=S[e.cJfNz(T,u)],B,j,V,J;e[i(697)](e[i(1721)](128,P),0)?g+=e[i(834)](p,P):e[i(1068)](e[i(721)](224,P),192)?e[i(526)](T,1)>=n?g+=b:(B=S[e[i(1035)](e[i(526)](T,u),1)],e[i(1721)](192,B)!==128?g+=b:(J=e[i(825)](e[i(686)](e.bSjpj(31,P),6),e[i(1436)](63,B)),e[i(959)](J,128)?g+=b:(g+=p(J),T++))):e.WEmha(e[i(1436)](240,P),224)?e.LDVlr(e[i(1874)](T,2),n)?g+=b:i(1054)===e[i(459)]?(B=S[e[i(1795)](T,u)+1],j=S[e[i(1035)](e[i(698)](T,u),2)],e[i(791)](e[i(1490)](e[i(1540)](B,e[i(1747)](j,8)),49344),32896)?g+=b:(J=e.XWdFQ(e[i(1755)](e[i(1747)](15&P,12),e[i(1236)](63&B,6)),e[i(1219)](63,j)),e[i(499)](J,2048)||e[i(619)](J,55296)&&e.hgVHy(J,57343)?g+=b:(g+=p(J),T+=2))):this["currentE"+i(804)+"riesCount"]=0:e[i(1858)](e[i(1631)](248,P),240)?e[i(1050)](e[i(1710)](T,3),n)?g+=b:(B=S[e[i(998)](e[i(998)](T,u),1)],j=S[e[i(1499)](T,u)+2],V=S[e.PsGLr(e[i(1127)](T,u),3)],e[i(657)](e[i(1898)](e[i(1376)](B,e.xUeIv(j,8))|V<<16,12632256),8421504)?g+=b:(J=e[i(825)](e[i(589)](e.sDpcr(e[i(1726)](7,P),18),e[i(1622)](e[i(1093)](63,B),12)),e[i(686)](e[i(1144)](63,j),6))|63&V,J<65536||e.efDCY(J,1114111)?g+=b:(J-=65536,g+=e[i(1429)](p,e[i(1520)](J,10)+55296,e.KucUh(e[i(1701)](1023,J),56320)),T+=3))):g+=b}return g}function Le(o,n){let i=t,d={EOuef:function(g,T,P,B){return e[K(847)](g,T,P,B)},dLhfD:function(g,T,P){return e[K(1276)](g,T,P)},uDtdf:e[i(1059)]},u=n[i(1541)],p=0;for(let g=0;e[i(1673)](g,u);g++){let T=n[i(965)+"At"](g);e[i(765)](T,55296)&&e[i(1110)](T,56319)&&e[i(1678)](g+1,u)&&(T=e[i(1499)](e[i(1799)](T,10),n[i(965)+"At"](++g))-56613888),p+=e.NLfnF(T,128)?1:e[i(499)](T,2048)?2:e.ycNgR(T,65536)?3:4}Y(o,p);let S=e[i(1568)](U,o,p),b=o.bytes;for(let g=0;e.sXoXn(g,u);g++){let T=n.charCodeAt(g);if(e[i(619)](T,55296)&&e.yjwvP(T,56319)&&e[i(1673)](e[i(1719)](g,1),u)&&(T=e[i(1598)](e.WmoDp(T,10),n[i(965)+"At"](++g))-56613888),e.IXypm(T,128))b[S++]=T;else{if(e[i(584)](T,2048))b[S++]=e.rYxbg(e[i(1436)](e[i(1520)](T,6),31),192);else if(e[i(1008)](e.dmtff,e.dmtff))try{d[i(1855)](_0xf21916,this,_0x25b3b3,[_0x554eb3,_0xc9388c,_0x244c2e])}catch(P){let B=d[i(1818)](_0x1458fa,d[i(1051)],{message:P[i(1727)],code:_0x15ec3b.OPEN_ERROR,error:P});this[i(1485)+i(1062)+i(1464)](B)}else e.NLfnF(T,65536)?b[S++]=e.XWdFQ(e[i(1685)](T,12)&15,224):(b[S++]=e[i(1376)](e[i(1452)](T,18)&7,240),b[S++]=e.auUOr(e.bjehN(T>>12,63),128)),b[S++]=e[i(1118)](e[i(1410)](e[i(558)](T,6),63),128);b[S++]=e[i(614)](63,T)|128}}}function ot(o,n){let i=t,d=e[i(848)](U,o,n[i(880)]),u=o.bytes,p=n[i(1017)];for(let S=0,b=n.limit;e[i(1678)](S,b);S++)u[e[i(1035)](S,d)]=p[S]}function Ae(o){return o[t(1017)][e.MMaKE(W,o,1)]}function Gt(o,n){let i=t,d={FUsNM:function(u,p){return u===p},TJndd:i(1333),xEGsn:function(u,p){return u(p)},BGtUN:function(u,p){return e[i(1573)](u,p)},uWtnJ:function(u,p,S){return e[i(583)](u,p,S)},LdSmG:function(u){return u()}};if(e.awQBg(e[i(1360)],e.IRDVb))return ECijnD[i(1024)](typeof _0x16c1ad,ECijnD.TJndd)?ECijnD[i(498)](_0x43333c,_0x2f1029):(_0x42b90c instanceof _0x5e8c06&&ECijnD[i(1583)](_0x2b03b7,_0x5b6e15),ECijnD[i(1143)](_0x58df4f,_0x4a7af6,ECijnD[i(1883)](_0x5ec025))?new _0x5e5d87(_0x230036,_0x179208):_0x281d2a);{let u=e.YixmS(U,o,1);o.bytes[u]=n}}function _e(o){let n=t,i=0,d=0,u;do if(e[n(814)](n(1108),e.syAVu))u=e.xRlxu(Ae,o),e.nCMxE(i,32)&&(d|=e[n(1747)](e[n(947)](127,u),i)),i+=7;else return this[n(802)]?.[n(1099)];while(e[n(1721)](128,u));return d}function Y(o,n){let i=t;if(e[i(1729)](i(1813),"HWWLh")){let d=e[i(1707)](e[i(1755)](e.gZDWL(e[i(1113)](7,_0x2b1f95),18)|e.WmoDp(e[i(1113)](63,_0x5b941d[_0x513917++]),12),e.imfqC(63,_0x27e7ce[_0x3c7e1a++])<<6)|e[i(1786)](63,_0x1d13ec[_0x1757d4++]),65536);_0x3c2731+=_0x22cbd0["fromChar"+i(737)](e[i(671)](55296,e[i(1452)](d,10))),_0x274b9f+=_0x3b6104["fromChar"+i(737)](e[i(526)](56320,e[i(792)](1023,d)))}else{for(n>>>=0;n>=128;)Gt(o,e.wJpex(127&n,128)),n>>>=7;e.QehWH(Gt,o,n)}}function Un(o,n){let i=t,d={PCALI:function(g,T){return e.hkTNa(g,T)}},u=0,p=0,S=0,b;return b=e.WmJbU(Ae,o),u=e.SOUCP(127,b),e[i(1815)](128,b)&&(b=e[i(1091)](Ae,o),u|=e[i(1229)](127&b,7),e[i(1734)](128,b)&&(b=Ae(o),u|=e.KeAFt(127&b,14),e.JJKeN(128,b)&&(b=e[i(547)](Ae,o),u|=e.YyNeh(127,b)<<21,e.AvEGb(128,b)&&(e.aDSZS!==e[i(1572)]?(b=e[i(900)](Ae,o),p=e.AkzVC(127,b),128&b&&(e[i(764)](e[i(1423)],e[i(1423)])?(b=e[i(1825)](Ae,o),p|=e[i(977)](127,b)<<7,e.zJxrW(128,b)&&(b=Ae(o),p|=e[i(1185)](127,b)<<14,e[i(540)](128,b)&&(b=e[i(561)](Ae,o),p|=e[i(686)](127&b,21),128&b&&(b=Ae(o),S=e.SOUCP(127,b),e[i(614)](128,b)&&(b=e[i(1366)](Ae,o),S|=e[i(1786)](127,b)<<7))))):(this[i(936)+i(1567)]=_0x47a13f,this[i(1150)]=0))):_0x36868b(_0xd2cd5(_0xb3350b[i(1337)]),_0x42e88f[i(1753)+"on"],_0xf1a10d.newVersion,vsjSLt[i(940)](_0x39bf29,_0x35c9c1[i(1316)+i(1571)])))))),{low:e.tOIxe(u,e[i(1926)](p,28)),high:e[i(589)](p>>>4,e[i(1167)](S,24)),unsigned:n}}function ge(o,n){let i=t,d=e[i(1341)](n.low,0),u=e[i(1660)](e[i(1376)](n.low>>>28,e[i(857)](n.high,4)),0),p=n[i(780)]>>>24,S=e.CecHZ(0,p)?u===0?e[i(959)](d,16384)?e[i(1319)](d,128)?1:2:e[i(1003)](d,2097152)?3:4:u<16384?e[i(584)](u,128)?5:6:e[i(1198)](u,2097152)?7:8:e[i(1766)](p,128)?9:10,b=U(o,S),g=o[i(1017)];switch(S){case 10:g[e[i(671)](b,9)]=e.zWhOu(e[i(476)](p,7),1);case 9:g[e[i(1537)](b,8)]=e[i(1008)](9,S)?e[i(1604)](128,p):127&p;case 8:g[e.QPjPV(b,7)]=S!==8?e[i(1540)](e[i(466)](u,21),128):e[i(614)](e[i(1686)](u,21),127);case 7:g[e[i(1138)](b,6)]=e[i(1069)](7,S)?e.VaNbu(u,14)|128:e[i(1013)](e.VaNbu(u,14),127);case 6:g[e[i(813)](b,5)]=e.QjHvT(6,S)?e.wJpex(e[i(1341)](u,7),128):e[i(1410)](u>>>7,127);case 5:g[e.cVEBl(b,4)]=e.JyDfz(5,S)?128|u:e[i(916)](127,u);case 4:g[e[i(1715)](b,3)]=e[i(1270)](4,S)?e[i(1540)](e[i(476)](d,21),128):e[i(1477)](e.RsmSv(d,21),127);case 3:g[e[i(1537)](b,2)]=S!==3?e[i(1581)](e[i(852)](d,14),128):e[i(1219)](d>>>14,127);case 2:g[e.hwqXp(b,1)]=S!==2?e[i(1581)](e[i(1341)](d,7),128):e[i(1898)](e[i(466)](d,7),127);case 1:g[b]=e[i(751)](1,S)?e[i(1755)](128,d):e[i(1477)](127,d)}}function qn(o){return e.xcsXV(y,o)}function Ke(o){return e[t(729)](C,o)}let d0=65536,Zx=e[t(1814)],Hn=e[t(1335)](d0,d0),f0=Hn*Hn,l0=e[t(1202)](f0,2),Kt=String.prototype[t(965)+"At"];class oe{constructor(n,i,d){let u=t;this[u(1274)]=!0,this[u(1724)]=e[u(1326)](0,n),this[u(780)]=e.WuNBZ(0,i),this[u(1187)]=!!d}static[t(1274)](n){return n&&e.ATHYE(!0,n.isLong)}static[t(656)](n,i,d){return new oe(n,i,d)}static fromBytes(n,i,d){let u=t;return d?oe[u(910)+u(1119)](n,i):oe[u(910)+u(1879)](n,i)}static[t(910)+t(1119)](n,i){let d=t;return new oe(e[d(521)](e[d(981)](n[0],e[d(683)](n[1],8))|e[d(1637)](n[2],16),e[d(665)](n[3],24)),n[4]|e.LFame(n[5],8)|e[d(1229)](n[6],16)|e[d(857)](n[7],24),i)}static[t(910)+"sBE"](n,i){let d=t;return new oe(e[d(551)](e.YNQyA(e[d(951)](e.wSvPs(n[4],24),n[5]<<16),e.BbVgM(n[6],8)),n[7]),e[d(1595)](e.XDlMH(e[d(1540)](n[0]<<24,n[1]<<16),e.KYGht(n[2],8)),n[3]),i)}static[t(1895)](n){let i=t;return e[i(791)]("BbzNl",e[i(1246)])?e[i(1729)](n,Zx)?u0:new oe(e[i(648)](e[i(1581)](e[i(915)](e.CNKoZ(Kt[i(783)](n,0),Kt.call(n,1)<<8),e[i(665)](Kt[i(783)](n,2),16)),e[i(1658)](Kt[i(783)](n,3),24)),0),e[i(1139)](e[i(1470)](e[i(491)](Kt[i(783)](n,4),Kt[i(783)](n,5)<<8)|e[i(1236)](Kt[i(783)](n,6),16),e.KYGht(Kt[i(783)](n,7),24)),0),!0):new _0x206070(d=>{let u=i;_0x3cd1de(d,this["_getInte"+u(1351)+"e"](_0x2f4a28))})}[t(1654)](){let n=t;return String["fromChar"+n(737)](e.LVDbE(255,this[n(1724)]),e[n(1093)](e[n(1341)](this[n(1724)],8),255),e[n(670)](e.bTlAG(this[n(1724)],16),255),e.cgXjV(this[n(1724)],24),e[n(1434)](255,this.high),e[n(1154)](e[n(1920)](this[n(780)],8),255),e[n(1093)](e[n(690)](this[n(780)],16),255),e.liQzW(this[n(780)],24))}static[t(1939)+"er"](n,i=!0){let d=t;if(e[d(561)](isNaN,n))return i?Yx:u0;if(i){if(e[d(619)](n,f0))return Qx}else{if(e[d(1448)](n,-l0))return eh;if(e.efHmP(n,1)>=l0)return Xx}return oe[d(656)](e[d(1470)](e[d(762)](n,Hn),0),e[d(878)](e.AImWq(n,Hn),0),i)}toNumber(){let n=t;return this[n(1187)]?e.PsGLr(e[n(1922)](e[n(451)](this.high,0),Hn),this.low>>>0):e[n(1795)](e[n(1335)](this.high,Hn),e[n(712)](this[n(1724)],0))}isZero(){let n=t;return this[n(780)]===0&&this[n(1724)]===0}[t(1016)](n){let i=t;oe.isLong(n)||(n=oe.fromNumber(n));let d=e[i(1854)](this.high,16),u=65535&this.high,p=e.BWTxC(this[i(1724)],16),S=e[i(721)](65535,this.low),b=n.high>>>16,g=e[i(997)](65535,n[i(780)]),T=e[i(1625)](n[i(1724)],16),P=65535&n[i(1724)],B=0,j=0,V=0,J=0;return J+=S+P,V+=J>>>16,J&=65535,V+=e[i(1598)](p,T),j+=e.OfFRt(V,16),V&=65535,j+=e.PFQKh(u,g),B+=e[i(1240)](j,16),j&=65535,B+=e[i(715)](d,b),B&=65535,oe.fromBits(e[i(1172)](e[i(686)](V,16),J),e[i(805)](e.wPdeI(B,16),j),this[i(1187)])}equals(n){let i=t;return oe[i(1274)](n)||(n=oe.fromNumber(n)),e[i(585)](this.unsigned,n[i(1187)])&&e[i(1391)](e[i(852)](this[i(780)],31),1)&&e[i(814)](e[i(1741)](n[i(780)],31),1)?!1:this.high===n.high&&this[i(1724)]===n.low}[t(1249)](){let n=t;return this[n(1724)]===-1&&e[n(1869)](-1,this[n(780)])?oe[n(656)](0,0,this.unsigned):e[n(838)](-1,this[n(1724)])?oe[n(656)](0,this[n(780)]+1,this.unsigned):oe.fromBits(e[n(1710)](this[n(1724)],1),this[n(780)],this[n(1187)])}[t(685)](n){let i=t;return n?this[i(1217)+"E"]():this[i(1417)+"E"]()}[t(1217)+"E"](){let n=t,i=this[n(780)],d=this[n(1724)];return[e.NUTXs(255,d),e[n(1322)](e[n(451)](d,8),255),e[n(977)](e.BtKRu(d,16),255),e[n(466)](d,24),e[n(926)](255,i),e[n(1240)](i,8)&255,e.Yoobm(i,16)&255,e[n(1625)](i,24)]}toBytesBE(){let n=t;if(e[n(1838)](e[n(1563)],e[n(816)]))this._listeners={};else{let i=this[n(780)],d=this.low;return[e[n(1920)](i,24),e.HMjPf(e[n(712)](i,16),255),e[n(1480)](i>>>8,255),e[n(947)](255,i),e[n(1625)](d,24),e[n(1266)](d,16)&255,e[n(470)](e[n(668)](d,8),255),e[n(1185)](255,d)]}}}let u0=new oe(0,0,!1),Yx=new oe(0,0,!0),Xx=oe[t(656)](-1,2147483647,!1),Qx=oe[t(656)](-1,-1,!0),eh=oe.fromBits(0,-2147483648,!1);var Wt=(function(o){let n=t;return o[o[e[n(461)]]=5001]=e[n(461)],o[o[e[n(914)]]=5002]=e[n(914)],o[o[e[n(1892)]]=5003]=e[n(1892)],o[o["MESSAGE_"+n(1359)]=5004]=e[n(1126)],o[o[e[n(652)]]=5005]="OPEN_ERROR",o})({});class jn{constructor(n){this.type=n,this.target=null}}class x0 extends jn{constructor(n,i){let d=t;super(n),this[d(1727)]=i&&i.message||null}}class h0 extends jn{constructor(n,i){let d=t,u=e.DbEVc[d(906)]("|"),p=0;for(;;){switch(u[p++]){case"0":super(n);continue;case"1":this[d(1486)]=i&&i[d(1486)]||0;continue;case"2":this[d(1514)]=i&&i[d(1514)]||null;continue;case"3":this[d(1682)]=i&&i.filename||"";continue;case"4":this[d(898)]=i&&i[d(898)]||5001;continue;case"5":this[d(935)]=i&&i[d(935)]||0;continue;case"6":this[d(1727)]=i&&i[d(1727)]||"";continue}break}}}class p0 extends jn{constructor(n,i){let d=t;super(n),this[d(898)]=i&&i[d(898)]||0,this[d(1087)]=i&&i[d(1087)]||"",this[d(556)]=i&&i[d(556)]||!1,this[d(1819)+d(1706)]=i&&i["willReco"+d(1706)]||!1}}class g0 extends jn{constructor(n,i){let d=t;super(n),this[d(1387)]=i&&i[d(1387)]||null}}class m0 extends g0{constructor(n,i){let d=t;super(n),this[d(1387)]=i&&i.data||null,this[d(1727)]=i&&i[d(1727)]||null}}class w0 extends jn{constructor(n,i){let d=t;super(n),this[d(1387)]=i&&i.data||null}}function et(o,{message:n,code:i,error:d}){return new h0(o,{message:n,code:i,error:d})}function at(o,{code:n,reason:i,wasClean:d,willReconnect:u}){return new p0(o,{code:n,reason:i,wasClean:d,willReconnect:u})}function _0(o,{data:n,message:i}){let d=t,u={vknLa:function(p,S){return e[K(1123)](p,S)},FgUuR:function(p,S){return e[K(958)](p,S)},nxVyA:function(p,S){return p+S},vGaTl:function(p,S){return p-S},qBVSp:function(p,S){return e[K(1331)](p,S)}};if(e[d(1901)]("NCWJn",d(1929)))return new m0(o,{data:n,message:i});{let p=_0x3717f3[d(965)+"At"](_0x43a373);p>=55296&&BTkDKA[d(1362)](p,56319)&&BTkDKA[d(1510)](BTkDKA[d(1513)](_0x4c31f,1),_0x564409)&&(p=BTkDKA[d(633)](BTkDKA[d(1513)](BTkDKA[d(817)](p,10),_0x68f0da[d(965)+"At"](++_0x4672d6)),56613888)),_0x4f1dac+=p<128?1:BTkDKA[d(1510)](p,2048)?2:p<65536?3:4}}function y0(o,{data:n}){return new w0(o,{data:n})}function Po(o,{message:n}){return new x0(o,{message:n})}class E0{constructor(n,i){let d=t;this[d(1737)+"s"]=n,this[d(1862)+"es"]=i,this[d(1713)+d(1280)]=0,this[d(1534)+"ndpointT"+d(450)+"t"]=0}[t(1216)+"pointConfig"](){let n=t;this[n(1713)+"ndex"]=0,this[n(1534)+n(804)+n(450)+"t"]=0}[t(1665)+"es"](){let n=t;if(e[n(1304)](e[n(1310)],e[n(853)])){if(this[n(1578)]["disableA"+n(1197)+n(776)]||this[n(1523)+n(756)])return;this[n(890)+n(741)]()}else this["currentE"+n(804)+n(450)+"t"]=0}["getCurre"+t(508)+"nt"](){let n=t,i={qRmEt:function(d,u){return e[K(1348)](d,u)},SgTsg:function(d,u){return e.Uiyjn(d,u)},AqARN:function(d,u,p){return e.VFitz(d,u,p)}};return e[n(604)](e.qfMmd,e[n(628)])?LoPBWP[n(599)](LoPBWP[n(543)](_0x63bb13,8).join("0"),LoPBWP.AqARN(_0x30c8c8,_0x3f3f59,10)[n(1861)](2))[n(956)](-8):this[n(1737)+"s"][this["currentI"+n(1280)]]}[t(596)+t(508)+t(553)+t(1567)](){let n=t,i={lACxz:n(1668)};if(e[n(571)]!==n(1225))return this[n(1534)+n(804)+"riesCount"];if(this[n(1750)+n(1357)]?.[n(1647)+n(1558)+"es"]()){let u=this["_endpoin"+n(1357)]?.["getCurre"+n(508)+"nt"]();this[n(1485)+"hCloseEv"+n(1464)](_0x41f3ab("close",{code:1006,reason:n(836)+u+(" timeout"+n(892)+n(1022)+n(653)),wasClean:!0}))}else{let u=this[n(1578)][n(939)+n(579)+n(710)](_0x20e5f7,_0x15ccb0);this[n(1485)+n(1031)+n(1464)](_0x7b04ef(i[n(1262)],{code:_0x48aeec,reason:_0x35a4e4,wasClean:!0,willReconnect:u})),u&&this[n(1627)]()}}[t(1647)+"chMaxTries"](){let n=t;return!!(this["currentI"+n(1280)]>=this[n(1737)+"s"][n(1541)]||e[n(739)](this["currentI"+n(1280)],e[n(1707)](this[n(1737)+"s"][n(1541)],1))&&e[n(1386)](this["currentE"+n(804)+n(450)+"t"],this[n(1862)+"es"]))}[t(537)+t(1293)+t(626)+t(704)+"tries"](){let n=t;return e.CfStu(this[n(1713)+n(1280)],this[n(1737)+"s"][n(1541)])?!0:e[n(1096)](this[n(1534)+n(804)+"riesCount"],this[n(1862)+"es"])}["replaceB"+t(1227)+"pointAnd"+t(516)+t(504)](){let n=t;return this[n(1534)+n(804)+n(450)+"t"]=1,this[n(1713)+n(1280)]++,this[n(1737)+"s"][this.currentIndex]}[t(596)+t(508)+t(1657)+t(1848)](){let n=t;if(e[n(1223)](e[n(992)],e[n(992)]))return this[n(1534)+n(804)+n(450)+"t"]++,this[n(596)+n(508)+"nt"]();this["_miniNav"+n(1456)+n(1761)]=_0x5f3413,_0x3eaa0b?this["_handleO"+n(1775)]():this[n(798)+n(730)]()}}let Gn=(e[t(1160)](e[t(782)],typeof globalThis)&&e[t(1125)](e.XJwSJ,globalThis[t(557)+t(1371)][t(1074)])||e[t(1004)](e[t(782)],typeof window)&&e[t(636)](t(946),window[t(557)+t(1371)][t(1074)]))&&e[t(1917)](e.CmPSs,typeof document),_n=e[t(1529)](e.CmPSs,typeof globalThis)&&(e[t(1577)]===globalThis[t(557)+t(1371)][t(1074)]||e[t(925)](e[t(1670)],globalThis[t(557)+t(1371)][t(1074)]))&&e[t(1576)](e[t(782)],typeof tt),kr=(t(1623)+"d"!=typeof globalThis&&e[t(1577)]===globalThis[t(557)+t(1371)][t(1074)]||e.ZUOmI(e[t(782)],typeof globalThis)||e.KIZMt(e[t(782)],typeof globalThis)&&!!globalThis["WeixinJS"+t(1692)])&&e[t(1004)](e[t(782)],typeof wx),Or=typeof globalThis<"u"&&(e.ImlZE===globalThis["construc"+t(1371)][t(1074)]||e[t(702)]===globalThis[t(557)+"tor"][t(1074)]||e[t(1671)](t(1482)+t(1841)+t(565),globalThis[t(557)+"tor"][t(1074)]))&&e[t(1931)](e[t(782)],typeof self),th=e[t(782)]!=typeof globalThis&&e[t(1386)](e[t(1577)],globalThis[t(557)+t(1371)][t(1074)])&&e[t(782)]!=typeof global&&e[t(764)](e[t(1577)],global[t(557)+"tor"].name)&&e.CmPSs!=typeof process&&!!process[t(564)];class Lo{constructor(){let n=t;if(e[n(872)]("tZBou",e[n(1472)])){e[n(490)](_0x1f02da,_0x113e99,42);let i=e[n(1171)](_0x54c081);_0x2b16e1(_0x506b0c,i),e[n(1652)](_0x1050dd,_0x4aad30,i.limit),e[n(1844)](_0x4e68e1,_0x543257,i),_0x1beae6(i)}else this[n(996)+"rs"]={}}[t(1473)](n,...i){let d=t,u=this[d(996)+"rs"][n];if(u)u[d(956)]()[d(1611)](p=>p.fn[d(590)](p[d(1457)],i));else if(e.aARwL(e[d(1059)],n)&&!this.onerror){let p=i[d(1541)]&&i[0];if(e[d(1561)](p,Error))throw p;let S=new Error(e.ZMwNk(e[d(1784)],p?e[d(1271)](" ("+p[d(1727)],")"):""));throw S.context=p,p}return this}off(n,i){let d=t;if(e.oWKrC(void 0,n))this._listeners={};else if(e[d(908)](void 0,i))this._listeners[n]=null;else{let u=this[d(996)+"rs"][n];if(u)for(let p=0;e.nCMxE(p,u[d(1541)]);)u[p].fn===i?u.splice(p,1):++p}return this}on(n,i,d){let u=t;return(this._listeners[n]||(this[u(996)+"rs"][n]=[]))[u(1416)]({fn:i,ctx:d||this}),this}}class nh extends Lo{["_formatErrorMess"+t(1053)](n){let i=t;if(e[i(1124)](e[i(1474)],"vrdEK"))return n[i(1823)]||n[i(1300)]?(i(824)+" "+(n.errMsg||"")+i(822)+(n[i(1300)]||""))[i(1877)]():JSON.stringify(n);if(_0x5d9bdd=_0x23d787[i(965)+"At"](_0x830aaf),e.cDAkc(_0x4df9e8,128))_0x4d4293[_0x98f504++]=_0x31d2d8;else if(e.cXqXv(_0x35e65b,2048))_0x465dac[_0x16b0fb++]=e[i(981)](e.TEjwH(_0x2e64a2,6),192),_0x312548[_0x5c907d++]=e[i(920)](63&_0x1624e3,128);else if(e[i(1869)](e.fOlhq(64512,_0x29cd15),55296)&&e[i(838)](e.OPYjt(64512,_0x550787=_0xc41d28.charCodeAt(e.VVRPD(_0x53adfc,1))),56320)){let d=e[i(1191)][i(906)]("|"),u=0;for(;;){switch(d[u++]){case"0":++_0x5915c6;continue;case"1":_0x566fe8[_0x23ca52++]=e[i(1172)](e[i(1458)](63,_0x1e6489),128);continue;case"2":_0x3dcb3d[_0x1005ca++]=e.HQPuq(e.MzRUL(_0x5358ca,18),240);continue;case"3":_0x789bf8[_0xa86d13++]=e[i(551)](e[i(606)](_0x3f4f5d>>12,63),128);continue;case"4":_0x4d1261=e[i(869)](e[i(1504)](65536,(1023&_0x3f23b1)<<10),e.vYyeo(1023,_0x22ffa6));continue;case"5":_0x2e81d0[_0xdb2f3c++]=e.IsRYQ(e[i(1467)](_0x55a12f,6),63)|128;continue}break}}else _0x2bb314[_0x1ee605++]=e[i(502)](_0x550865,12)|224,_0xb7d8e[_0x5caceb++]=e[i(766)](e[i(1849)](_0x39ef4a>>6,63),128),_0x14521b[_0x257449++]=e[i(1400)](63&_0x3d7c6b,128)}constructor(n,i,d){let u=t;super(),this[u(1114)]=null,kr&&wx[u(1115)+u(515)]&&(this[u(1114)]=wx.connectSocket({url:n,protocols:i,header:d,fail:this[u(650)+u(1592)+u(1870)][u(1277)](this),success:this[u(650)+u(1468)+u(1231)+u(917)][u(1277)](this)})),_n&&tt["connectS"+u(515)]&&(this[u(1114)]=tt[u(1115)+u(515)]({url:n,protocols:i,header:d,fail:this[u(650)+u(1592)+u(1870)][u(1277)](this),success:this[u(650)+u(1468)+u(1231)+u(917)][u(1277)](this)}))}[t(650)+t(1468)+t(1231)+t(917)](){let n=t;Promise[n(1302)]().then(()=>{this["_addWsLi"+n(1771)]()})}[t(650)+t(1592)+t(1870)](n){let i=t,d={MKtnl:function(u,p){return u<<p},SZsex:function(u,p){return u<p},txUHB:function(u,p){return e[K(1065)](u,p)}};Promise[i(1302)]().then(()=>{let u=i;if(e[u(764)](e.ZYSij,e[u(1551)]))_0x848f1d=EVMSOm[u(1286)](31&_0x3d0d21,6)|63&_0x560db1,EVMSOm.SZsex(_0x3ade50,128)?_0x5945b1+=_0x38b315:(_0x2eec67+=EVMSOm[u(980)](_0x1fffa6,_0x593334),_0x1a0225++);else{let p=e[u(1699)](et,e[u(1059)],{message:this[u(896)+u(1311)+u(1053)](n)});this[u(1473)]("error",p);let S=at(e[u(1664)],{reason:this[u(896)+u(1311)+"age"](n)});this[u(1473)](e.Gdlro,S)}})}[t(1196)+t(1771)](){let n=t,i={WQuLO:function(d,u,p){return d(u,p)}};this[n(1114)][n(1648)](d=>{let u=n;this.emit(e.VUQiO,e.OZkvX(y0,e.VUQiO,{...d,data:d[u(1823)]||""}))}),this._socket.onClose(d=>{let u=n;e[u(819)](e.LNkDB,e[u(1760)])?(this[u(1713)+u(1280)]=0,this[u(1534)+"ndpointT"+u(450)+"t"]=0):this[u(1473)](e[u(1664)],e[u(1652)](at,e.Gdlro,{...d}))}),this[n(1114)][n(487)+"e"](d=>{let u=n;this[u(1473)](u(1727),i[u(862)](_0,u(1727),{...d}))}),this[n(1114)][n(539)](d=>{let u=n;this[u(1473)](e[u(1059)],et(e[u(1059)],{...d,message:d[u(1823)]||""}))})}[t(754)](n){let i=t,d={aoYMn:e.tnJaV};if(e[i(1561)](n,Uint8Array)){let u=n[i(1339)][i(956)](n.byteOffset,e.fpoHN(n[i(1105)+"th"],n[i(1014)+"et"]));this[i(1114)]&&this[i(1114)][i(754)]({data:u,fail:p=>{let S=i;this[S(1473)](e[S(1059)],e.tHZnk(et,e[S(1059)],{message:this[S(896)+"rrorMess"+S(1053)](p)}))}})}else this[i(1114)]&&this[i(1114)][i(754)]({data:n,fail:u=>{let p=i;this[p(1473)](d[p(1690)],et(d[p(1690)],{message:this["_formatE"+p(1311)+p(1053)](u)}))}})}[t(1668)](n,i){this[t(1114)]&&this._socket.close({code:n,reason:i})}[t(1672)+t(948)](n,i){this.on(n,i)}[t(644)+t(1338)+t(474)](n,i){this[t(811)](n,i)}get[t(849)+"te"](){let n=t,i={bZhlg:e[n(1661)],aqcCV:e[n(1808)],TNGFP:function(d,u,p){return e[n(1418)](d,u,p)}};if(e[n(1223)](n(963),e[n(861)]))return this[n(1114)][n(849)+"te"];this[n(1831)+n(1394)](),this.emit(i[n(1915)],i[n(524)]),this[n(1597)+n(887)+"Id"]=i.TNGFP(_0x264fdc,this[n(669)][n(1277)](this),_0x11d47e)}get[t(1295)+"pe"](){let n=t;return e.GidnM!==n(1845)?{bytes:_0x21b85d,offset:0,limit:_0x3ab7e0[n(1541)]}:this[n(1114)][n(1295)+"pe"]}set[t(1295)+"pe"](n){}get[t(1188)](){let n=t;return this[n(1114)][n(1188)]}get[t(1687)](){return this[t(1114)].protocol}get extensions(){let n=t;return this[n(1114)][n(931)+"ns"]}get[t(1525)+t(1235)](){let n=t;return e[n(1186)](n(978),e[n(1072)])?this[n(1114)][n(931)+"ns"]:0}}function rh(o,n){let i=t;if(n)return new n(o.url,o[i(1687)]);if(kr||_n)return new nh(o[i(1188)],o[i(1687)],o.headers);if(e.RBwqi(Gn,Or)&&e.IKITE(e[i(782)],typeof WebSocket)&&WebSocket)return new WebSocket(o[i(1188)],o[i(1687)+"s"])}function ih(o){let n=t,i=(n(1496)+"0")[n(906)]("|"),d=0;for(;;){switch(i[d++]){case"0":return!1;case"1":if(kr&&wx["connectS"+n(515)])return!0;continue;case"2":if(_n&&tt[n(1115)+n(515)])return!0;continue;case"3":if(o)return!0;continue;case"4":if(e.RBwqi(Gn,Or)&&e[n(1160)](e[n(782)],typeof WebSocket)&&WebSocket)return!0;continue}break}}function b0(o,n,i){let d=t,u={zsYZq:function(b,g){return b<=g},dkIUa:e[d(646)],KNXjz:function(b,g){return e[d(1869)](b,g)}},p=-1;async function S(b){let g=d;return u[g(840)](b,p)?Promise[g(1095)](new Error(u[g(1263)])):(p=b,u[g(719)](b,i[g(1541)])?Promise[g(1302)]():i[b][g(1277)](o)(n,S.bind(null,b+1)))}e.oDYyR(S,0)}function S0(o){let n=t,i=0,d=0;for(let u=0;e[n(959)](u,o[n(1541)]);++u)d=o[n(965)+"At"](u),e[n(959)](d,128)?i+=1:e.BZeKj(d,2048)?i+=2:(64512&d)===55296&&e.wyAmG(64512,o[n(965)+"At"](e[n(671)](u,1)))===56320?(++u,i+=4):i+=3;return i}function v0(o,n,i){let d=t;if(e.YuoEP(e.KUASB,d(1298))){let u=e[d(1607)](_0x29d5d9,_0x2ca510,1);_0x162051[d(1017)][u]=_0x377a3c}else{if(e[d(1673)](e[d(1e3)](i,n),1))return"";let u="";for(let p=n;p<i;)if(e[d(601)]===e[d(501)])_0x4d8baf(_0x387456,82),_0x1e4535(_0x265fdb,_0x273578);else{let S=o[p++];if(S<=127)u+=String.fromCharCode(S);else if(e[d(1133)](S,192)&&e[d(1003)](S,224))u+=String[d(821)+d(737)](e.NcHyJ(e[d(1863)](e[d(1734)](31,S),6),e[d(674)](63,o[p++])));else if(e[d(1133)](S,224)&&e[d(1288)](S,240))u+=String[d(821)+d(737)](e[d(1162)](e[d(1540)](e.jaFhx(e[d(933)](15,S),12),e[d(1631)](63,o[p++])<<6),e[d(591)](63,o[p++])));else if(e.gbzHS(S,240)){let b=e[d(1893)](e[d(825)](e[d(1470)](e[d(1545)](e[d(1321)](7,S),18),e.gfLsu(e[d(1113)](63,o[p++]),12)),e.haImq(e[d(1907)](63,o[p++]),6))|e[d(1721)](63,o[p++]),65536);u+=String[d(821)+d(737)](e.ZYfhy(55296,e[d(1694)](b,10))),u+=String[d(821)+"Code"](e.QPjPV(56320,e[d(1786)](1023,b)))}}return u}}function No(o,n,i){let d=t,u=i,p,S;for(let b=0;e[d(958)](b,o[d(1541)]);++b)if(p=o[d(965)+"At"](b),e[d(959)](p,128))n[i++]=p;else if(e[d(584)](p,2048))n[i++]=e[d(1605)](e[d(1467)](p,6),192),n[i++]=e[d(1763)](e[d(1898)](63,p),128);else if((64512&p)===55296&&e.vEMSq(e.AoAJL(64512,S=o.charCodeAt(e.HJAFy(b,1))),56320)){let g=e[d(1462)][d(906)]("|"),T=0;for(;;){switch(g[T++]){case"0":n[i++]=e[d(1165)](e[d(520)](p>>12,63),128);continue;case"1":n[i++]=e[d(589)](63&p,128);continue;case"2":n[i++]=e[d(1726)](e[d(1928)](p,6),63)|128;continue;case"3":n[i++]=p>>18|240;continue;case"4":p=e[d(576)](e[d(1218)](65536,e.IgXFO(e.jOqeG(1023,p),10)),1023&S);continue;case"5":++b;continue}break}}else n[i++]=e[d(976)](e[d(1442)](p,12),224),n[i++]=e.NxHNu(e.AvEGb(p>>6,63),128),n[i++]=e[d(975)](e[d(1815)](63,p),128);return e[d(1707)](i,u)}async function I0(o){let n=t;if(e[n(1858)](e[n(1419)],typeof o)){let i=new Uint8Array(e.SLegw(S0,o));return e[n(1415)](No,o,i,0),i}return e.tqJCR(o,ArrayBuffer)?new Uint8Array(o):new Uint8Array(o[n(1339)],o[n(1014)+"et"],o.byteLength)}function sh(o){let n=t;try{return e[n(1419)]!=typeof o&&(e[n(1859)](o,ArrayBuffer)||o[n(1339)]&&e[n(1424)](o[n(1339)],ArrayBuffer))||n(1220)!=typeof o?"":(JSON.parse(o),e[n(1097)])}catch{return e.CfStu(e[n(1419)],typeof o)?e[n(1630)]:""}}let oh=(o,n)=>{let i=t;switch(o){case e[i(865)]:case i(1132):return{[i(1492)+o]:1,"x-tt-env":n};default:return{}}};class ah{constructor(n){let i=t;this["maxLossC"+i(1567)]=n,this.count=0}addCount(){let n=t;this[n(1150)]++}[t(1647)+t(736)+"nt"](){let n=t;return e[n(765)](this[n(1150)],this[n(936)+n(1567)])}[t(484)+t(1662)](n=0){let i=t;this[i(936)+"ount"]=n,this.count=0}}async function ch(o){let n=t,i={koudD:function(d,u){return e[K(651)](d,u)},bIyKP:n(645)+n(1087),XHeka:e[n(1257)],sJeSn:e.ljynI,RWMFQ:function(d,u){return e[n(1933)](d,u)},pzLzF:e[n(972)],FACFk:function(d,u){return e[n(945)](d,u)},BUzFV:e[n(735)],ADWmN:n(1803),zwiGM:function(d,u){return e[n(569)](d,u)}};return new Promise(d=>{let u=n;if(!Gn)return d(i[u(1584)]);try{let p=document[u(1733)+u(889)](i[u(1754)]);window[u(1930)+u(806)]=S=>{let b=u;document[b(587)][b(799)+b(1122)](p),window[b(1930)+"JSONP"]=void 0,i[b(1347)](d,S&&S[b(1475)]||i[b(1584)])},p[u(457)]=i[u(950)],p.src=i.RWMFQ(o.replace(/^ws/,"http"),i[u(1937)]);try{if(i.FACFk(i[u(1603)],i[u(1712)]))document[u(587)][u(1505)+u(1122)](p);else{let S=(u(773)+"0")[u(906)]("|"),b=0;for(;;){switch(S[b++]){case"0":this[u(1627)]();continue;case"1":this[u(1523)+"osed"]=!1;continue;case"2":this[u(1425)]=!0;continue;case"3":this[u(573)+u(598)]?.[u(484)+u(1662)]();continue;case"4":this[u(1750)+u(1357)]?.[u(1216)+u(1923)+u(1361)]();continue}break}}}catch{document[u(587)][u(799)+u(1122)](p)}}catch{window["frontier"+u(806)]=void 0,i[u(534)](d,i[u(1584)])}})}function $t(o,n,i){let d=t;return!!o?.[d(895)](u=>u.key===n&&u[d(1365)]===i)}function Kn(o,n){let i=t;if(e[i(1223)](e.XWKoY,e[i(567)])){let d=_0x1c3189[i(1500)+"g"](0,4-_0x1b67be[_0x36a995][i(1541)]),u=d[i(1835)](_0x4507ab[_0x24ae02]);_0x21fbcc[i(1416)](u)}else return o?.[i(895)](d=>d[i(1324)]===n)?.[i(1365)]}let Mo=null;async function dh(){let o=t;return Mo||(Mo=Promise[o(1302)]()[o(1711)](Tt[o(1277)](Tt,"idb"))),Mo}class fh extends Lo{constructor(n,i){let d=t;super(),this[d(1904)]=n,this[d(638)]=i,this[d(802)]=void 0,this._initPromise=null}async openDB(){await this[t(1532)]()}async[t(1532)](){let n=t,i={qRzXp:function(d){return e[K(1171)](d)},iGoWf:function(d,u,p,S){return e[K(847)](d,u,p,S)}};if(!this[n(802)]){if(this[n(1809)+n(1669)])return this[n(1809)+n(1669)];try{let d=this[n(1904)],u=this._keyPath;this[n(1809)+n(1669)]=(async()=>{let p=n,{openDB:S}=await i[p(1109)](dh);this._qosDB=await i[p(1397)](S,"frontier_"+d,1,{upgrade(b){let g=p;b[g(509)+g(519)+"e"](d,{keyPath:u})}})})(),await this[n(1809)+"mise"]}catch(d){console[n(1590)](d)}finally{this["_initPro"+n(1669)]=null}}}async[t(904)](n){let i=t,d={yqSVS:function(u,p){return e[K(1852)](u,p)},fqXJo:e[i(522)]};try{return await this[i(1532)](),this[i(802)]?.get(this[i(1904)],n)}catch(u){if(e.pPvRf(e[i(1355)],"EpVGV"))console[i(1590)](u);else{let p=_0x551eb0[i(1733)+i(889)](e[i(1257)]);_0x3c474c[i(1930)+i(806)]=S=>{let b=i;_0x22ab97[b(587)].removeChild(p),_0x13086e[b(1930)+b(806)]=void 0,ZrDjCn[b(828)](_0x757dd,S&&S.msg||ZrDjCn[b(609)])},p.type=e[i(1135)],p.src=e[i(1250)](_0x138152.replace(/^ws/,e[i(907)]),e[i(972)]);try{_0x37e0dd.body["appendCh"+i(1122)](p)}catch{_0x16152d.body[i(799)+"ild"](p)}}}}async[t(717)](n,i){return await this._init(),this._qosDB?.put(this._dbName,n)}async[t(818)](n){let i=t;try{return await this[i(1532)](),this[i(802)]?.[i(1547)](this._dbName,n)}catch(d){console[i(1590)](d)}}async[t(774)](){let n=t,i={LSVGm:e[n(658)],rXXKm:"x_fronti"+n(1067)+"ck",zfBeC:function(d,u,p,S){return e[n(1494)](d,u,p,S)},foPOA:e[n(1897)]};if(e[n(1192)](n(1826),e[n(1142)])){let d=!!this[n(1578)][n(1210)+"S"];if(!d)return{enabled:d,isQoSMessage:!1,isQoSAck:!1,isAckCleanupMessage:!1,ackMsgIds:[]};let u=_0x5de3db(_0x44bf0f[n(1727)][n(966)],i[n(1820)],"2"),p=u&&_0x7b1b7(_0x1e27bf[n(1727)][n(966)],i[n(1447)],"1"),S=u&&i[n(1201)](_0x468f39,_0x309276[n(1727)][n(966)],n(1203)+n(903)+"k","1"),b=S?_0xe98eb4(_0x55e8be.message[n(966)],i[n(1570)])?.split(",").filter(_0x497ce1)||[]:[];return{enabled:d,isQoSMessage:u,isQoSAck:p,isAckCleanupMessage:S,ackMsgIds:b}}else try{return await this._init(),this._qosDB?.clear(this._dbName)}catch(d){console[n(1590)](d)}}async[t(829)](){let n=t;return await this[n(1532)](),this._qosDB?.getAllKeys(this[n(1904)])}async[t(969)](){let n=t;return await this[n(1532)](),this[n(802)]?.[n(969)](this[n(1904)])}async closeDB(){let n=t;try{if(n(1740)===e[n(1621)]){let i=this._qosDB[n(1463)](this[n(1787)]),d=_0x45b72a.parse(e[n(1518)](i,"{}"));return _0x14f109.values(d)}else this[n(802)]?.[n(1668)](),this[n(802)]=void 0}catch(i){console[n(1590)](i)}}get isReady(){try{return!!this._qosDB}catch(n){return console.log(n),!1}}}class lh{constructor(n,i){let d=t;this._DBName=n,this._pathKey=i,this[d(802)]=localStorage}async[t(826)](){}get[t(1787)](){return t(1930)+"_"+this._DBName}async[t(904)](n){let i=t,d=this[i(802)][i(1463)](this._prefix);return JSON[i(1313)](e[i(1292)](d,"{}"))[n]}async[t(717)](n,i){let d=t;if(d(835)===e[d(1239)]){let u=this._qosDB[d(1463)](this[d(1787)]),p=JSON[d(1313)](e.tSFPo(u,"{}"));return p[i||n[this._pathKey]]=n,this[d(802)][d(538)](this[d(1787)],JSON[d(1774)+"y"](p)),i||n[this[d(801)]]}else this[d(1473)](d(503),e[d(1847)](_0x5523be,d(503),{..._0x1b704d,data:_0x2cefd9[d(1823)]||""}))}async[t(818)](n){let i=t;if(e[i(697)](e[i(517)],e[i(517)])){let d=this[i(802)][i(1463)](this[i(1787)]),u=JSON[i(1313)](e[i(1905)](d,"{}"));return u[n]=void 0,this[i(802)][i(538)](this._prefix,JSON[i(1774)+"y"](u))}else e[i(1082)](_0x3392d4,this,_0x4c6a8c,[_0x2dd927,_0x126581,_0x114cf7])}async[t(774)](){return this[t(802)].clear()}async[t(829)](){let n=t,i=this._qosDB.getItem(this._prefix),d=JSON[n(1313)](i||"{}");return Object[n(829)](d)}async[t(969)](){let n=t,i=this[n(802)][n(1463)](this._prefix),d=JSON[n(1313)](e[n(1102)](i,"{}"));return Object[n(1195)](d)}[t(1282)](){return Promise[t(1302)]()}get isReady(){return!!this[t(802)]}}class uh{constructor(n,i){let d=t;e[d(1386)](e.pYFVt,"Sneug")?(this[d(552)]=n,this._pathKey=i,this._qosDB=_n?tt:kr?wx:null):(this[d(493)+"er"]&&_0x3108a6[d(644)+"entListe"+d(474)](e[d(1794)],this[d(800)+d(605)]),this[d(493)+"er"]&&_0x14a0ae[d(644)+d(1338)+d(474)](e[d(544)],this["_handleP"+d(1497)]),this[d(1668)]())}async[t(826)](){}get[t(1787)](){let n=t;return n(1930)+"_"+this[n(552)]}async[t(904)](n){let i=t;if(e[i(1078)]===e[i(1078)]){let d=this[i(802)].getStorageSync(this[i(1787)]);return JSON[i(1313)](d||"{}")[n]}else return _0x358ba5[i(1302)]()}async set(n,i){let d=t,u=this[d(802)][d(1033)+d(655)](this[d(1787)]),p=JSON[d(1313)](e.RBwqi(u,"{}"));return p[i||n[this[d(801)]]]=n,this._qosDB[d(842)+d(655)](this[d(1787)],JSON[d(1774)+"y"](p)),i||n[this[d(801)]]}async[t(818)](n){let i=t,d=this._qosDB[i(1033)+i(655)](this._prefix),u=JSON.parse(d||"{}");return u[n]=void 0,this[i(802)][i(842)+i(655)](this[i(1787)],JSON.stringify(u))}async[t(774)](){let n=t;return this._qosDB[n(854)+n(1850)]()}async keys(){let n=t,i=this[n(802)]["getStora"+n(706)+"nc"](this[n(1787)]),d=JSON[n(1313)](e.lkuKv(i,"{}"));return Object[n(829)](d)}async[t(969)](){let n=t;if(e[n(1213)]("auwgP",e[n(1743)]))this._qosDB?.[n(818)](_0x5bb160.message_id);else{let i=this[n(802)]["getStora"+n(706)+"nc"](this[n(1787)]),d=JSON.parse(i||"{}");return Object[n(1195)](d)}}closeDB(){return Promise[t(1302)]()}get[t(1099)](){return!!this[t(802)]}}function A0(o,n){let i=t;if(e[i(481)](_n,_n))return new uh(o,n);if(e[i(831)](Gn,Or)&&typeof indexedDB<"u")return new fh(o,n);if(e.CarfQ(Gn,Or)&&e[i(1576)]("undefined",typeof localStorage))return new lh(o,n);throw new Error(e[i(1806)])}class xh{constructor(){let n=t;if(n(1871)!==e[n(1602)])this[n(617)+n(1128)+"Id"]=null,this._interval=36e5,this[n(802)]=e[n(1373)](A0,e[n(974)],e[n(873)]);else return _0xa12055[n(1590)](e[n(1674)],_0x387b85,_0x20ed28,_0xabe5f7),this[n(802)][n(717)]({cursor_name:_0x1f3bc4,cursor:_0x304eb0,service:_0x597173})}async[t(617)+t(1032)](){let n=t;clearInterval(this[n(617)+n(1128)+"Id"]),this[n(617)+"lTimeoutId"]=e.YMiJT(setInterval,()=>{this["flushExp"+n(1383)]()},this._interval)}async[t(826)](){let n=t,i={fCZLA:n(530)};await this[n(802)][n(826)]()[n(1711)](()=>{let d=n;if(d(530)!==i.fCZLA){let{type:u}=_0x55c255;this[d(1473)](u,_0x4e8155)}else this[d(617)+d(1032)]()})}async[t(1145)+t(1383)](){let n=t;(await this._qosDB?.getAll()||[]).filter(({timestamp:u})=>u<Date[n(993)]()).forEach(u=>{let p=n,S={lyazv:function(b,g){return b||g}};if(e[p(1244)](e[p(1792)],"NuNDs")){let b=this[p(802)][p(1463)](this[p(1787)]),g=_0x5655e5[p(1313)](LmQzpm[p(1043)](b,"{}"));return g[_0x32b273||_0x4b15fc[this[p(801)]]]=_0x50665b,this[p(802)][p(538)](this._prefix,_0x365677[p(1774)+"y"](g)),_0x575158||_0x257883[this[p(801)]]}else this[p(802)]?.[p(818)](u[p(555)+"id"])})}async[t(818)](n){let i=t;return this[i(802)]?.[i(818)](n)}async[t(717)](n,i){let d=t;if(e.XjFYM!==e[d(1601)]){if(this[d(1831)+d(1394)](),this[d(1267)+"mer"](),this[d(620)+d(932)+"rs"](),this[d(1739)+"nceClose"](1e3,_0x2e11b7),this[d(1627)+d(1868)]=!1,_0x17018b&&this[d(479)+"orOnline"]()&&!this[d(1523)+d(756)]){if(this[d(1750)+d(1357)]?.[d(1647)+d(1558)+"es"]()){let p=this["_endpoin"+d(1357)]?.[d(596)+d(508)+"nt"]();this["_dispatc"+d(1031)+d(1464)](e[d(1769)](_0x1eacc5,e.Gdlro,{code:1006,reason:d(836)+p+(d(1084)+d(892)+d(1022)+d(653)),wasClean:!0}))}else{let p=this[d(1578)][d(939)+d(579)+d(710)](_0x11adc6,_0x8e3c75);this["_dispatc"+d(1031)+"ent"](e.YIoVz(_0x5b9113,e[d(1664)],{code:_0x5c2dc5,reason:_0xaa0dbf,wasClean:!0,willReconnect:p})),p&&this[d(1627)]()}return}this[d(479)+d(1816)]()||this[d(1523)+d(756)]?this[d(1485)+d(1031)+d(1464)](e[d(525)](_0x47f4a4,d(1668),{code:_0x221431,reason:"bye"})):this[d(1485)+"hCloseEv"+d(1464)](e.dYRDL(_0x95fd73,d(1668),{code:1006,reason:d(1508)+d(788)+d(753)+d(574)})),this._ws=null,this[d(1750)+d(1357)]?.[d(1216)+d(1923)+d(1361)](),this[d(573)+"sCounter"]?.[d(484)+d(1662)]()}else return this[d(802)]?.[d(717)]({message_id:n,timestamp:i})}async[t(904)](n){return this[t(802)]?.get(n)}async[t(1282)](){let n=t;e[n(1899)](clearInterval,this["_interva"+n(1128)+"Id"]),await this[n(802)]?.[n(1282)]()}get isReady(){let n=t;return this._qosDB?.[n(1099)]}}function Bo(o){let n=t,i=!!this[n(1578)][n(1210)+"S"];if(!i)return{enabled:i,isQoSMessage:!1,isQoSAck:!1,isAckCleanupMessage:!1,ackMsgIds:[]};let d=e[n(1082)]($t,o[n(1727)].headers,e[n(658)],"2"),u=d&&e[n(1528)]($t,o[n(1727)].headers,e[n(944)],"1"),p=d&&e[n(847)]($t,o.message[n(966)],e[n(1857)],"1"),S=p?e[n(943)](Kn,o[n(1727)][n(966)],e.uYSRU)?.[n(906)](",")[n(725)](Boolean)||[]:[];return{enabled:i,isQoSMessage:d,isQoSAck:u,isAckCleanupMessage:p,ackMsgIds:S}}async function C0(){let o=t;return this[o(1211)+o(1764)]||(this[o(1211)+o(1764)]=new xh),this[o(1211)+o(1764)].isReady||await this["_QoSMana"+o(1764)][o(826)](),this[o(1211)+"ger"]}async function hh(o,n){let i=t;if(e[i(1838)](i(918),e[i(486)])){let{enableAutoAck:d}=this._options,u=e[i(847)]($t,o[i(1727)].headers,e[i(1589)],"1"),p=e[i(1756)]($t,o[i(1727)][i(966)],e[i(1368)],"1"),S=Bo[i(783)](this,o);if(e[i(967)](d,u)){let{SeqID:b,LogID:g,service:T,LogIDNew:P,method:B}=o[i(1727)];this[i(494)]({SeqID:b,LogID:g,LogIDNew:P,service:T,method:B,headers:[{key:e[i(1368)],value:"1"},{key:i(927),value:P||""},{key:e.WYtxM,value:"0"}]})}p&&!S.isQoSAck&&this["_dispatc"+i(1042)+i(867)](o),e[i(1171)](n)}else return _0x42a20e?.find(d=>d[i(1324)]===_0x96d614)?.[i(1365)]}async function ph(o,n){let i=t;if(e[i(1770)](e.ULIcK,e.aSHcQ))this._debug(e.xhfwD,o.message),e[i(1171)](n);else{let d=0,u=0,p;do p=e.NzvWa(_0x451087,_0x31957b),e[i(1182)](d,32)&&(u|=(127&p)<<d),d+=7;while(128&p);return u}}async function gh(o,n){let i=t;if(e.ghrKJ(e[i(1349)],e[i(1349)])){let d=e[i(1222)](qn,await e[i(1649)](I0,o[i(1387)]));try{if(e.iRcVr(e.biwvC,e[i(1027)]))this[i(1378)+"ameSpace"]=_0x3a97e1,this[i(1636)+i(595)]=_0x1217b1,this[i(542)+i(630)]=_0x2af883,this._qosDB=e[i(1305)](_0x1fa512,this[i(1378)+i(1565)],e[i(1488)]);else if(e[i(500)](d[i(1539)],Uint8Array)){let u=this[i(1578)][i(1094)+i(483)]instanceof Object?{force:!!this._options[i(1094)+i(483)][i(1619)],encoding:this[i(1578)][i(1094)+i(483)][i(1455)]?this[i(1578)]["payloadE"+i(483)][i(1455)][i(1618)](/\s/g,"")[i(1498)+"ase"]():""}:{force:!1,encoding:this[i(1578)][i(1094)+"ncoding"]?this[i(1578)].payloadEncoding[i(1618)](/\s/g,"")["toLowerC"+i(858)]():""},p=d["payloadE"+i(483)]?d[i(1094)+i(483)][i(1618)](/\s/g,"")["toLowerC"+i(858)]():"",S=e[i(1561)](this[i(1578)]["payloadT"+i(1012)],Object)?{force:!!this[i(1578)]["payloadT"+i(1012)][i(1619)],type:this[i(1578)][i(679)+i(1012)][i(457)]?this._options[i(679)+i(1012)][i(457)][i(1618)](/\s/g,"")[i(1498)+i(858)]():""}:{force:!1,type:this[i(1578)]["payloadT"+i(1012)]?this[i(1578)][i(679)+i(1012)].replace(/\s/g,"")[i(1498)+i(858)]():""},b=d[i(679)+i(1012)]?d["payloadT"+i(1012)][i(1618)](/\s/g,"")["toLowerC"+i(858)]():"",g=S[i(1619)]?S[i(457)]:b||S[i(457)],T=u[i(1619)]?u[i(1455)]:p||u.encoding,P=[e.VyQQS,e.PLBqh,e[i(1356)],i(1220)],B=[e.Ahpnl,e[i(616)]];this[i(1578)][i(1810)+i(949)+i(716)+"ad"]&&P[i(640)](g)&&(!T||B[i(640)](T))?d[i(478)+i(1629)]=e.IbrAK(v0,d.payload,0,d[i(1539)].byteLength):d[i(478)+i(1629)]=""}else d[i(478)+i(1629)]=""}catch(u){d[i(478)+"oad"]="",console[i(1590)](u)}o[i(1727)]=d,n()}else _0x1743e=e[i(1788)](_0x5008a3,_0xc10e73),_0x54492f=0}function mh(o,n,i){let d=t,u={KOFEZ:function(T,P){return e[K(1888)](T,P)},JJygr:function(T,P){return e[K(1591)](T,P)},LiVAC:function(T,P){return e[K(526)](T,P)},vsLRn:function(T,P){return T(P)},cflJS:function(T,P){return T&P}},p=e.KWNDc(i,8192),S=e[d(1312)](p,1),b=null,g=p;return function(T){let P=d;if(u[P(1812)](T,1)||u.JJygr(T,S))return o(T);u.JJygr(u[P(468)](g,T),p)&&(b=u.vsLRn(o,p),g=0);let B=n.call(b,g,g+=T);return u[P(1908)](7,g)&&(g=(7|g)+1),B}}let wh=4294967295;function _h(o,n,i){let d=t,u={KuIkr:function(p,S){return e[K(492)](p,S)}};return e[d(1222)](RangeError,e[d(1348)](e[d(869)](e.KuOkR(e[d(1348)](e[d(789)](e[d(631)],o),e[d(1181)]),e.RBwqi(n,1)),d(1745)),i))}function yh(o,n,i){let d=t;if(e[d(1757)](i,wh))throw new Error(e.prMyg);let u=3;for(;e.nflcG(u,0);){let p=e.PcgCc(255,i);e[d(847)](Fo,p,o,e[d(560)](n,u)),i>>>=8,u--}return n+4}function Eh(o,n){let i=t,d={UzHdT:function(u,p,S){return u(p,S)}};if(e[i(612)](e[i(785)],e[i(495)])){let u=0,p=n,S=n+4;for(;e[i(602)](p,S);){let{value:b,offset:g}=e.WBMjK(zo,o,p);p=g,u=e[i(1398)](e[i(1549)](u,8),0),u+=b}return{value:u,offset:S}}else{let u=this[i(1750)+i(1357)]?.[i(596)+i(508)+"nt"]();this[i(1485)+i(1031)+i(1464)](d[i(1265)](_0x45a2f6,i(1668),{code:_0xa64268[i(898)],reason:i(1071)+i(759)+"d, unknown reason, hostn"+i(1650)+u})),this[i(1750)+i(1357)]?.["resetEnd"+i(1923)+i(1361)](),this[i(573)+i(598)]?.["resetCou"+i(1662)]();return}}function bh(o,n,i){let d=t,u=e[d(1155)][d(906)]("|"),p=0;for(;;){switch(u[p++]){case"0":if(n[d(1038)])return e[d(492)](n[d(1038)](o,i),i);continue;case"1":if(e[d(1319)](o[d(1541)],40))return e[d(877)](e[d(1776)](No,o,n,i),i);continue;case"2":if(n[d(1047)+"e"])return e.jmxrD(n[d(1047)+"e"](o,i),i);continue;case"3":if(!o)return i;continue;case"4":return e[d(942)](No,o,n,i)+i}break}}function Sh(o,n){let i=t,d=new oe(e.sALBB(e[i(1781)](e.gceZM(o[e[i(1499)](n,4)]<<24,e.kqtOa(o[n+5],16)),e[i(1345)](o[n+6],8)),o[e[i(1248)](n,7)]),e[i(953)](e[i(1021)](o[e[i(1925)](n,0)],24),o[n+1]<<16)|e[i(1851)](o[n+2],8)|o[e[i(1504)](n,3)],!0);return n+=8,{value:d,offset:n+8}}function vh(o,n,i){let d=t,u=o[d(1724)],p=o[d(780)];return n[i]=e.RdPyJ(p,24),n[e[d(526)](i,1)]=e[d(1346)](p>>>16,255),n[i+2]=e[d(916)](e[d(712)](p,8),255),n[i+3]=e[d(1113)](255,p),n[e.nngwV(i,4)]=e.vnEUJ(u,24),n[e[d(1209)](i,5)]=e[d(760)](e.BHJPW(u,16),255),n[i+6]=e[d(1765)](u,8)&255,n[i+7]=e[d(864)](255,u),i+=8,i}function zo(o,n){let i=t;return o[i(1104)+"8"]?{value:o[i(1104)+"8"](n),offset:e[i(1459)](n,1)}:{value:e[i(540)](255,o[n]),offset:e[i(1120)](n,1)}}function Fo(o,n,i){let d=t;return n.writeUint8?n[d(1506)+"t8"](o,i):n[i]=255&o,i+1}let Ih=function(o){let n=t;return e.fGJQM(e[n(1538)],"uYkZH")?new Uint8Array(o):new _0x3a5ad3(_0x502af1,_0x4ba9a5,_0x44249b)},Ah=e[t(1320)](e[t(782)],typeof Buffer)?Buffer[t(1832)+"afe"]:e.vwTeO(mh,Ih,Uint8Array[t(1258)+"e"][t(1900)]),Ch=16,Uo=32;function Th(o){let n=t,i=0,d={};for(let u=0;u<o[n(1541)];u++)d[o[u]["cursor_n"+n(777)]]=e[n(1070)](S0,o[u].cursor_name),i+=14+d[o[u]["cursor_n"+n(777)]];return[i,d]}function T0(o,n,i){let d=t,u={xeJOm:d(1037)+d(488)+"|5|2|6",Ysesq:e.CFYfm,kbwzG:function(T,P,B,j){return e.FQGMi(T,P,B,j)},lFsqc:d(1074),kckCu:e[d(1023)],gxCPH:function(T,P,B,j){return e.nnLtw(T,P,B,j)},dwFRQ:function(T,P,B,j){return T(P,B,j)},NUVgK:e[d(1194)],xeoTl:function(T,P,B,j){return e.FQGMi(T,P,B,j)}},[p,S]=Th(o),b=e[d(727)](Ah,p),g=0;return o[d(1611)](T=>{let P=d,B=u.xeJOm.split("|"),j=0;for(;;){switch(B[j++]){case"0":console[P(1590)](u.Ysesq,g);continue;case"1":console[P(1590)](P(1086)+P(1074),g);continue;case"2":g=u[P(1697)](vh,oe[P(1939)+"er"](T[P(1151)]||n),b,g);continue;case"3":g=u[P(1697)](Fo,0,b,g);continue;case"4":console[P(1590)](P(1318),g);continue;case"5":console[P(1590)](u[P(1822)],g);continue;case"6":console[P(1590)](u[P(1559)],g);continue;case"7":g=u[P(1802)](yh,b,g,T.service||0);continue;case"8":g=u[P(1238)](bh,T[P(758)+P(777)],b,g);continue;case"9":console.log(u[P(705)],T,T[P(1318)]);continue;case"10":g=u[P(928)](Fo,S[T[P(758)+P(777)]],b,g);continue}break}}),{frameType:Uo,headers:[{key:"cursor_f"+d(1864),value:i}],payload:b}}function Dh(o){let n=t,i=0,d=[];for(;i<o[n(1105)+"th"];){let{offset:u}=e.nZaMl(zo,o,i);i=u;let p={cursor_name:"",cursor:0,service:0},{value:S,offset:b}=e.MMaKE(Eh,o,i);p.service=S,i=b;let{value:g,offset:T}=e.MMaKE(zo,o,i);i=T,p[n(758)+n(777)]=e[n(1173)](v0,o,i,e[n(1254)](i,g)),i+=g;let{value:P,offset:B}=e[n(893)](Sh,o,i);p.cursor=P.toNumber(),i=B,d[n(1416)](p)}return d}function Rh(){let o=t;return{frameType:Uo,headers:[{key:e[o(859)],value:e[o(1564)]}],payload:void 0}}class kh{constructor(n,i,d){let u=t,p={RFAgB:e[u(1807)]};e[u(1112)]!==e.hCFmb?(this[u(1473)](p[u(549)],_0x31bcfc),this[u(1728)+"eAck"]&&this[u(1728)+u(1703)](_0x5832f1)):(this[u(1378)+u(1565)]=n,this[u(1636)+u(595)]=i,this[u(542)+u(630)]=d,this[u(802)]=e[u(1679)](A0,this[u(1378)+u(1565)],"cursor_name"))}async[t(826)](){let n=t;if(e.MXFxP(e.OWNTD,e[n(1860)]))return this[n(1114)][n(1188)];await this[n(802)][n(826)]()}async getCursors(){let n=t;if(e.zrrjJ("hQdfq",e.rmAZk))this[n(552)]=_0x3c8600,this._pathKey=_0x5ae70e,this[n(802)]=_0x364f70;else{if(!this[n(802)].isReady)return;let i=this["_message"+n(630)],d=await this._qosDB[n(969)]();switch(console[n(1590)](e[n(1329)],d),i){case e[n(1723)]:return d&&d.length?e[n(1494)](T0,d,0,this[n(1636)+n(595)]):void 0;case"INSTANT":return;case e[n(1092)]:return d&&d[n(1541)]?e[n(734)](T0,d,0,this[n(1636)+n(595)]):e[n(1171)](Rh)}}}async[t(717)](n,i,d){let u=t;return console[u(1590)](e[u(1674)],n,i,d),this[u(802)][u(717)]({cursor_name:n,cursor:i,service:d})}async[t(1224)+"rs"](n){let i=t,d=Dh(n);for(let u of d)console[i(1590)](i(1934)+"r",d),await this[i(802)].set(u)}async get(n){let i=t;return(await this[i(802)][i(904)](n))?.[i(1151)]}async[t(1282)](){let n=t;await this[n(802)][n(1282)]()}updateCursorFileName(n){let i=t;this[i(1636)+"ileName"]=n}get[t(1099)](){let n=t;return this[n(802)][n(1099)]}}let Oh="__x_msg_"+t(769);async function D0(o){let n=t,i={BGjMW:function(b,g,T){return e[K(1882)](b,g,T)},VdiSn:function(b,g){return e.BcXRc(b,g)},diXNq:function(b,g){return b+g}};if(!this[n(1578)][n(1210)+"S"])return null;let{aID:d,fpID:u,messageStrategy:p}=this._options,S=e.BBSXh(o,Oh);try{if(e[n(532)](e[n(1824)],e[n(1824)])){let b=gWQzow[n(1804)](_0x406ecc,_0xf5f422,_0x547717.limit),g=_0x4d07b6[n(1017)],T=_0x535c65[n(1017)];for(let P=0,B=_0x221881[n(880)];gWQzow[n(1797)](P,B);P++)g[gWQzow.diXNq(P,b)]=T[P]}else return this["_cursorM"+n(1200)]?o&&this[n(622)+n(1200)][n(1019)+"rsorFile"+n(1253)](o):this[n(622)+n(1200)]=new kh(u+"_"+d+"_"+S,S,p),this[n(622)+n(1200)][n(1099)]||await this[n(622)+n(1200)][n(826)](),this[n(622)+"anager"]}catch{return null}}async function Ph(o,n){let i=t,d=e[i(847)]($t,o[i(1727)].headers,i(898),"-1"),u=e[i(795)]($t,o[i(1727)][i(966)],e[i(1368)],"1"),p=e.YkycV(Kn,o[i(1727)][i(966)],e.iqWeF),S=e.slAdh(Number,e[i(793)](Kn,o[i(1727)][i(966)],e[i(709)]))||0,b=Bo[i(783)](this,o),g=$t(o[i(1727)][i(966)],e[i(1507)],"2"),T=Kn(o[i(1727)][i(966)],e[i(1586)]),P=e[i(1465)](Number,Kn(o[i(1727)][i(966)],e[i(911)]));if(b.isQoSAck)return e[i(1171)](n);let B=b.isQoSMessage?await C0[i(783)](this):null;if(e[i(1325)](o[i(1727)][i(1318)],0)&&u&&!d||e[i(1390)](o[i(1727)].service,0)){if(p&&b["isQoSMes"+i(1830)]&&B)if(e[i(738)]===e[i(659)]){let j=_0x217be2(e[i(1610)],{message:e[i(1793)]});this[i(1212)+"econnect"]&&this[i(1212)+i(741)](j)}else return!!!await B[i(904)](p)&&(this["_dispatc"+i(955)+"Event"](o),await B[i(717)](p,Date[i(993)]()+S)),e.SqOZY(n);if(g){let j=await D0[i(783)](this);if(!j)return e[i(570)]!==e[i(570)]?!!_0x53b0e4?.[i(895)](J=>J[i(1324)]===_0x38dff2&&J[i(1365)]===_0x3679e4):(this[i(1485)+"hMessage"+i(856)](o),e[i(1640)](n));let V=await j[i(904)](T)??-1;if(e[i(1678)](V,P))this[i(1485)+"hMessage"+i(856)](o),j[i(717)](T,P,o[i(1727)][i(1318)]);else throw new Error("recevied"+i(1420)+" cursor "+P+(" larger "+i(923)+i(1049)+"r ")+V);return e[i(1073)](n)}return this[i(1485)+i(955)+i(856)](o),e[i(1546)](n)}}async function Lh(o,n){let i=t,d=Bo[i(783)](this,o);if(!d[i(1242)+"sage"])return e[i(1296)](n);let u=await C0[i(783)](this);if(d[i(1555)+i(962)+"age"]&&d[i(1587)+"s"][i(1541)])for(let p of d.ackMsgIds)await u[i(818)](p);e.yVBYt(n)}async function Nh(o,n){let i=t,d=o[i(1727)][i(1773)+"e"]===Ch,u=e.zrrjJ(o[i(1727)][i(1773)+"e"],Uo);if(e.UTpCh(!d,!u))return e[i(667)](n);let p=e[i(929)](Kn,o[i(1727)][i(966)],e.vYfHF);if(!p)return e.Arrti(n);let S=await D0[i(783)](this,p);if(!S)return n();if(d){let b=await S[i(1615)+"rs"](),g={frameType:b?.["frameType"],SeqID:oe[i(1939)+"er"](this[i(545)]++),LogID:oe[i(1939)+"er"](this[i(1578)][i(1628)+i(930)]()),service:9e3,method:5,headers:b?.headers,payload:b?.[i(1539)]},T=e[i(1395)](C,g);this[i(1342)]&&this[i(1342)][i(849)+"te"]&&this._ws[i(754)](T)}if(u){let b=o[i(1727)][i(1539)];b&&S[i(1224)+"rs"](b)}}let Mh=async function(o,n){let i=t;this[i(1425)]=!1,e[i(1111)](clearTimeout,this["_connect"+i(711)+i(1170)]),e[i(1106)](n)},Bh=async function(o,n){let i=t;if(!this[i(1342)]||this[i(1342)][i(849)+"te"]!==this[i(874)])return e[i(768)](n);let{pingInterval:d}=this[i(1578)];this[i(1750)+i(1357)]?.[i(1216)+"pointCon"+i(1361)]();for(let p=0;e.aUMVE(p,this[i(542)+i(472)][i(1541)]);p++){if(e[i(1777)]===e[i(1704)])return this[i(802)]?.[i(818)](_0x5f47ca);{let S=this["_message"+i(472)][p];if(e.tgEvw(this._ws.readyState,this[i(874)])&&e[i(784)](null,S))if(e[i(639)](e[i(566)],e.kDzjB))this[i(1342)]&&this[i(1342)][i(754)](S),this[i(542)+i(472)][p]=null;else{if(e.iGKFv(_0x336678,_0x146a1e))return _0x7ed275?_0x5267dc:_0x10c16b;if(_0x4ed83c){if(e[i(1307)](_0x3f7901,_0x374ae0))return _0x3e3bfb}else{if(e[i(1123)](_0x3c92ff,-_0x29cba3))return _0xf8f0a4;if(e.PTOzA(_0x93cb0d+1,_0x44bc62))return _0x1bb7b7}return _0x5e8ffd[i(656)](e[i(675)](e[i(1409)](_0x52e66a,_0x1503ca),0),e[i(976)](e[i(902)](_0x39b79c,_0x435712),0),_0x403291)}else break}}this[i(542)+i(472)]=this[i(542)+i(472)][i(725)](p=>!!p),this[i(1597)+i(887)+"Id"]=setTimeout(()=>this[i(669)](),d),this[i(1485)+i(1136)+"nt"](o),this[i(493)+"er"]&&this[i(1342)]&&(this._ws[i(1295)+"pe"]=this["_binaryT"+i(1012)]);let u=this["_endpoin"+i(1357)]?.[i(596)+"ntEndpoint"]();this[i(662)](i(1752)+u+i(1306)),e[i(667)](n)},zh=async function(o,n){let i=t,d=this["_endpoin"+i(1357)]?.[i(596)+"ntEndpoint"]();this[i(662)](i(1752)+d),e[i(1902)](n)};class Fh extends Lo{constructor(n){let i=t,d={pmnVD:function(u,p,S,b){return e[K(1401)](u,p,S,b)},fApyN:function(u,p,S){return e[K(514)](u,p,S)},roSTr:e[i(1059)],vIMct:e[i(1664)],YKTlc:"versionc"+i(1161),xLJTG:function(u,p){return e[i(922)](u,p)},ekOQJ:e.RWgAa,CZXUn:i(512),zkqHn:function(u,p,S){return u(p,S)},xiqBV:function(u,p,S,b){return e[i(1385)](u,p,S,b)}};if(e[i(809)]("qzeAu",i(1367)))return _0x561524||(_0x1fa538=[_0x247215,_0x46c648,_0x4b7c10,_0x3838d9,_0x51c2c0]);{super(),this[i(1519)+i(1456)+i(1761)]=!0,this[i(493)+"er"]=Gn,this[i(1579)]=th,this[i(1083)+"T"]=_n,this[i(663)+"X"]=kr,this[i(586)+"r"]=Or,this[i(542)+i(472)]=[],this[i(1750)+"tManager"]=null,this["_readyCl"+i(756)]=!1,this["_binaryT"+i(1012)]=e[i(563)],this[i(1627)+"Lock"]=!1,this._connectionTimeoutId=null,this["_reconne"+i(1693)+i(507)]=null,this["_pingPon"+i(887)+"Id"]=null,this[i(545)]=0,this[i(1425)]=!1,this[i(1759)]="",this[i(1211)+"ger"]=null,this[i(622)+i(1200)]=null,this[i(573)+i(598)]=null,this[i(1744)+"ls"]="pbbp2",this[i(527)]=3,this[i(941)+"NG"]=0,this[i(874)]=1,this[i(666)]=2,this[i(1493)]=b=>{let g=i;try{d.pmnVD(b0,this,b,[Mh,Bh,zh])}catch(T){let P=d[g(1287)](et,d[g(952)],{message:T[g(1727)],code:Wt[g(1521)+"OR"],error:T});this["_dispatc"+g(1062)+"ent"](P)}},this[i(661)+"ge"]=async b=>{let g=i,T={ldSNv:d.vIMct,pbMwC:d.YKTlc},{pingInterval:P,pingFrequency:B}=this[g(1578)];if((b[g(1387)]==="hi"&&d.xLJTG(d.ekOQJ,B)||d[g(1526)](d.CZXUn,B))&&(this[g(1831)+"ngTimer"](),this[g(1473)](g(744)+"e_success",g(1389)),this[g(1597)+g(887)+"Id"]=d.zkqHn(setTimeout,this[g(669)][g(1277)](this),P)),b[g(1387)]!=="hi")try{d.xLJTG("tRxir",g(1705))?(_0x261624&&_0x4315a0[g(1672)+"Listener"](mGEkEo[g(1921)],()=>_0x214512()),_0x319f6b&&_0x13b53e[g(1672)+g(948)](mGEkEo[g(750)],()=>_0xa43e7f())):d[g(1876)](b0,this,b,[gh,hh,Lh,Nh,Ph,ph])}catch(j){let V=d[g(863)](et,d[g(952)],{message:j[g(1727)],code:Wt[g(1449)+g(1359)],error:j});this[g(1485)+g(1062)+g(1464)](V)}},this[i(506)]=b=>{let g=i,T=this[g(1750)+g(1357)]?.["checkRea"+g(1558)+"es"](),P=this[g(1750)+g(1357)]?.[g(596)+"ntEndpoint"]();if(T&&!b[g(1727)])if(e[g(1749)](e.pTaYu,e[g(1291)]))_0x58f32e[g(1302)]()[g(1711)](()=>{this._addWsListeners()});else{let B=g(836)+P+(g(649)+g(1767)+g(699)+"ed");this[g(1485)+g(1062)+g(1464)](e[g(1370)](et,e[g(1059)],{message:B,code:Wt[g(713)+g(770)+"R"],error:b}));return}this._ws&&this[g(1342)][g(849)+"te"]===this.OPEN&&this["_disconn"+g(1536)](),this[g(1485)+g(1062)+g(1464)](et(e[g(1059)],{message:b[g(1727)],code:Wt[g(1377)+g(796)],error:b}))},this[i(469)]=async b=>{let g=i;this[g(1267)+g(1666)](),this[g(1831)+g(1394)](),this["_removeW"+g(932)+"rs"](),this[g(1342)]=null,this[g(1627)+g(1868)]=!1;let T=this["_endpoin"+g(1357)]?.[g(1647)+g(1558)+"es"]();if(!T&&this[g(479)+"orOnline"]()&&!this[g(1523)+g(756)]){let P=this["_endpoin"+g(1357)]?.[g(596)+g(508)+"nt"](),B=this[g(1578)][g(939)+g(579)+"ptor"](b[g(898)],b.reason);this._dispatchCloseEvent(e[g(1652)](at,"close",{code:1006,reason:b[g(1087)]||g(1071)+g(759)+g(1297)+g(772)+g(691)+"ame: "+P,willReconnect:B})),B&&this[g(1627)]();return}if(b.code!==1e3&&this[g(1523)+g(756)]){this[g(1485)+g(1031)+g(1464)](e[g(1646)](at,e[g(1664)],{code:1e3,reason:e[g(1407)]})),this["_endpoin"+g(1357)]?.[g(1216)+g(1923)+g(1361)](),this["_pingLos"+g(598)]?.[g(484)+"nter"]();return}if(b[g(898)]!==1e3&&T){let P=this[g(1750)+g(1357)]?.[g(596)+g(508)+"nt"](),B=b.reason;B||(B=await e[g(1638)](ch,this[g(1759)])),B=g(1071)+g(759)+g(1659)+B+(g(654)+g(757))+P+(", max re"+g(1022)+g(653)),this[g(1485)+g(1031)+g(1464)](e.tUvVj(at,e[g(1664)],{code:b[g(898)],reason:B}));let j=g(836)+P+(g(649)+"ax retries reached");this[g(1485)+"hErrorEv"+g(1464)](et(e[g(1059)],{message:j,code:Wt[g(713)+g(770)+"R"]})),this[g(1750)+g(1357)]?.[g(1216)+g(1923)+g(1361)](),this[g(573)+"sCounter"]?.[g(484)+g(1662)]();return}if(e.uQpim(1e3,b.code)&&!b.reason)if(e.fDcAx(g(1134),e.GwIXF))this._initPromise=null;else{let P=this[g(1750)+"tManager"]?.[g(596)+"ntEndpoint"]();this[g(1485)+g(1031)+g(1464)](at(g(1668),{code:b[g(898)],reason:g(1071)+g(759)+"d, unkno"+g(772)+"n, hostn"+g(1650)+P})),this[g(1750)+g(1357)]?.[g(1216)+g(1923)+"fig"](),this[g(573)+g(598)]?.[g(484)+g(1662)]();return}this[g(1485)+g(1031)+g(1464)](b),this["_endpoin"+g(1357)]?.[g(1216)+"pointConfig"](),this[g(573)+g(598)]?.resetCounter()},this[i(888)]=null,this[i(905)]=null,this[i(1388)+"e"]=null,this[i(1643)]=null,this[i(1212)+i(741)]=null,this[i(1728)+i(1703)]=null,this[i(1716)+"mediatel"+i(1243)+"ct"]=null,this[i(798)+i(1775)]=this[i(798)+i(1775)].bind(this),this[i(798)+"ffLine"]=this[i(798)+i(730)][i(1277)](this),this[i(800)+i(605)]=this[i(800)+i(605)][i(1277)](this),this[i(800)+"ageShow"]=this[i(800)+i(1497)][i(1277)](this),this[i(1578)]={url:"",automaticOpen:!0,initReconnectInterval:1e3,maxReconnectInterval:1e4,reconnectIntervalGrowFactor:2,timeoutInterval:5e3,maxRetries:5,debug:!1,maxMessageQueueLength:e[i(452)](1,0),service:0,logIDGenerator:a,headers:void 0,payloadEncoding:"",payloadType:"",fpID:"",deviceID:"",accessKey:"",ttwID:"",bddID:"",aID:"",disableAutoReconnect:!1,customParams:{},pingInterval:15e3,pingTimeoutInterval:4e3,pingFrequency:e[i(1399)],pingLossCount:2,enableTransformTextPayload:!1,logIDNewConfig:{enableAutoGenerateLogIDNew:!1,userIp:""},miniProgramParams:{customHttpHeader:{}},enableAutoAck:!1,reconnectInterceptor:()=>!0,enableQoS:!1,QoSLevel:2,messageStrategy:e[i(1092)],env:{xTTEnv:"",xUseEnv:""},listenNetworkChanged:!0};let{url:u,ws:p}=n,S=Array[i(1412)](u)?u:e[i(529)](e.tnmdO,typeof u)?[u]:[];if(!S||S[i(1541)]===0)throw new Error(e[i(1140)]);if(!e[i(1599)](ih,p))throw new Error(i(1732)+i(722)+i(1596)+", WebSoc"+i(999)+i(597)+"is undef"+i(695));Object[i(1332)](this[i(1578)],n),this[i(1750)+"tManager"]=new E0(S,this[i(1578)][i(1862)+"es"]),this[i(573)+i(598)]=new ah(this[i(1578)][i(1241)+i(968)]),this[i(1578)][i(1247)+"cOpen"]&&(this[i(1425)]=!0,this[i(1627)]()),this[i(1578)][i(1580)+i(1375)+"nged"]&&(this[i(1083)+"T"]||this[i(663)+"X"]?this["_onPageN"+i(994)+i(1268)]():this[i(493)+"er"]&&this["_initGlo"+i(1600)+i(948)]())}}["_handleO"+t(1775)](){let n=t;this[n(1578)][n(775)+n(1197)+n(776)]||this[n(1523)+"osed"]||this[n(890)+n(741)]()}[t(798)+t(730)](){let n=t;if(e.LrKoz(e.WAYrz,e[n(1063)])){this[n(1675)+"WebSocket"]();let i=Po(e[n(1610)],{message:e.khEeF});this[n(1716)+n(937)+n(1243)+"ct"]&&this[n(1716)+"mediatel"+n(1243)+"ct"](i)}else return this[n(1342)]?this[n(1342)].binaryType:this[n(1411)+n(1012)]}[t(1626)+t(1600)+t(948)](){let n=t,i={bGbry:function(d,u){return e[K(1729)](d,u)},gyoLc:function(d,u){return e[K(876)](d,u)},XnNDG:"always",TLCfM:function(d,u){return e[K(1428)](d,u)},PsNnI:e[n(1661)],TNQZw:e[n(1808)],ikNZY:function(d,u,p){return e[n(588)](d,u,p)},QKPzS:function(d,u){return d===u},WnOEk:function(d,u,p,S){return e[n(847)](d,u,p,S)},IOaCg:e[n(1059)]};if(e.KjLhn(e[n(901)],e[n(1575)]))this._isBrowser&&window[n(1672)+n(948)](e[n(1205)],this[n(798)+n(1775)]),this[n(493)+"er"]&&window[n(1672)+n(948)](e[n(465)],this[n(798)+n(730)]),this[n(493)+"er"]&&window[n(1672)+n(948)](n(1927),this["_handleP"+n(605)]),this[n(493)+"er"]&&window[n(1672)+n(948)](n(449),this[n(800)+n(1497)]);else{let{pingInterval:d,pingFrequency:u}=this._options;if((JQBzcA[n(879)]("hi",_0x4a156[n(1387)])&&JQBzcA.gyoLc(JQBzcA[n(615)],u)||JQBzcA[n(1406)](n(512),u))&&(this[n(1831)+"ngTimer"](),this[n(1473)](JQBzcA[n(1768)],JQBzcA[n(676)]),this[n(1597)+n(887)+"Id"]=JQBzcA[n(448)](_0x2a1f61,this[n(669)][n(1277)](this),d)),JQBzcA[n(1176)]("hi",_0x426663[n(1387)]))return;try{JQBzcA.WnOEk(_0x5c5016,this,_0x2dc108,[_0x5c9e72,_0x3994f9,_0x1c3ffc,_0x2e935e,_0x461b8e,_0xf077b4])}catch(p){let S=_0x126a21(JQBzcA.IOaCg,{message:p[n(1727)],code:_0x11d1a6["MESSAGE_"+n(1359)],error:p});this[n(1485)+n(1062)+"ent"](S)}}}[t(1511)+t(1600)+t(948)](){let n=t;this._isBrowser&&window[n(644)+n(1338)+n(474)](e[n(1205)],this[n(798)+n(1775)]),this._isBrowser&&window[n(644)+n(1338)+"ner"](n(624),this[n(798)+n(730)]),this[n(493)+"er"]&&window["removeEv"+n(1338)+"ner"](e[n(1794)],this["_handleP"+n(605)]),this[n(493)+"er"]&&window["removeEv"+n(1338)+n(474)](e[n(544)],this[n(800)+n(1497)])}[t(800)+t(605)](n){let i=t;if(!n[i(673)+"d"]){if(e[i(1479)](e.BmKyD,e[i(1445)]))return;this[i(493)+"er"]&&window[i(644)+i(1338)+"ner"](e[i(1794)],this[i(800)+"ageHide"]),this[i(493)+"er"]&&window[i(644)+i(1338)+i(474)](e.ddGcB,this[i(800)+i(1497)]),this[i(1668)]()}this._isBrowser&&window[i(644)+"entListener"](e[i(1205)],this[i(798)+i(1775)]),this[i(493)+"er"]&&window["removeEv"+i(1338)+"ner"](i(624),this[i(798)+"ffLine"])}[t(800)+t(1497)](n){let i=t;n[i(673)+"d"]&&(this[i(479)+i(1816)]()&&(!this[i(1342)]||this[i(1342)][i(849)+"te"]!==this.OPEN||e.kHkxK(this[i(1342)][i(849)+"te"],this[i(941)+"NG"]))&&this[i(798)+i(1775)](),this[i(493)+"er"]&&window[i(1672)+i(948)](e.rvAcE,this[i(798)+i(1775)]),this[i(493)+"er"]&&window[i(1672)+i(948)](e[i(465)],this[i(798)+i(730)]))}async["_generat"+t(1354)](n){let i=t,{fpID:d,deviceID:u,bddID:p,ttwID:S,accessKey:b,aID:g,customParams:T={},enableAutoAck:P,enableQoS:B,QoSLevel:j,env:V}=this[i(1578)],J,He,$e;this[i(493)+"er"]||this[i(663)+"X"]||this[i(1083)+"T"]?(J=location&&e.WEmha(e[i(1738)],location.protocol)?i(1912):i(1374),He=n.replace(/((^ws)|(^http))((?:[s]*:\/\/))/,""),$e=/^wss(.*:\/\/)/[i(471)](n)?n:""+J+He):(J=e[i(1421)],He=n.replace(/(^http)((?:[s]*:\/\/))/,""),$e=/(^ws)((?:[s]*:\/\/))/[i(471)](He)?He:""+J+He);let je=p?e[i(1702)]:S?e[i(1554)]:"device_id",ct=p||S||u;if(e[i(831)](!ct,!je))throw new Error(e[i(1938)]);let R0=e.kultL(i(1333),typeof T)?await T():T,Uh=V?e[i(881)](oh,V[i(938)],V[i(1431)]):{},qo=Object.assign({device_platform:e.YxtWf,version_code:e[i(1689)],access_key:b,fpid:d,aid:g,[je]:ct,xsack:P?1:0,xaack:P?1:0,xsqos:B?1:0,qos_level:B?j:void 0,qos_sdk_version:2,...Uh},R0),qh=Object[i(829)](qo).reduce((Ho,jo)=>qo[jo]!==void 0?""+Ho+(Ho?"&":"?")+jo+"="+qo[jo]:Ho,"");return $e+i(531)+qh}async[t(1627)](){let n=t;if(!(this[n(1627)+n(1868)]||this[n(1523)+n(756)])){this["_connect"+n(1868)]=!0;try{let i=this[n(1750)+n(1357)]?.["checkCur"+n(1293)+n(626)+n(704)+n(1055)](),{timeoutInterval:d}=this._options;if(i){let p=this[n(1750)+n(1357)]?.[n(596)+n(508)+"nt"](),S=this[n(1750)+n(1357)]?.[n(1867)+n(1227)+n(1932)+"UpdateCo"+n(504)](),b=this[n(1750)+"tManager"]?.["getCurre"+n(508)+n(553)+"ount"]();if(S)if(e[n(1634)](n(1730),e[n(1562)])){let g=this[n(802)][n(1463)](this[n(1787)]),T=_0x39fe4a[n(1313)](e[n(1905)](g,"{}"));return _0x175be5[n(829)](T)}else{let g="connect "+p+(n(1084)+n(892)+n(1022)+"ached, w"+n(1853)+"backup e"+n(830))+S+(n(833)+"y"),T=e[n(608)](et,"error",{message:g,code:Wt[n(713)+n(770)+"R"]});this[n(662)](g),this[n(1485)+n(1062)+"ent"](T),this[n(1759)]=await this[n(1451)+n(1354)](S),this[n(662)]("connect "+S+" "+b+n(1336)),this[n(620)+"sListeners"]()}else if(e[n(1801)](n(1259),"ryylY")){let g=n(836)+p+(n(1084)+n(892)+n(1022)+"ached");this[n(662)](g),this[n(1485)+n(1062)+n(1464)](et(e[n(1059)],{message:g,code:Wt[n(713)+n(770)+"R"]}));return}else return this[n(1114)][n(1295)+"pe"]}else{let p=this["_endpoin"+n(1357)]?.[n(596)+n(508)+"ntAndUpdateCount"](),S=this[n(1750)+n(1357)]?.["getCurrentEndpoi"+n(553)+n(1567)]();this[n(1759)]=await this[n(1451)+n(1354)](e[n(1273)](p,"")),this[n(662)](n(836)+p+" "+S+n(1336)),this[n(620)+n(932)+"rs"]()}if(this._isInit)this[n(1425)]=!1;else{let p=e[n(1524)](Po,e[n(1610)],{message:e.WuAVL});this["onStartR"+n(741)]&&this.onStartReconnect(p)}let u=this["_endpoin"+n(1357)]?.[n(596)+n(508)+n(553)+n(1567)]()||0;u>1&&await this[n(1364)](e[n(1707)](u,1)),this[n(662)](n(1071)+n(1527)+this[n(1759)]+(" protoco"+n(855))+this._protocols),this._ws=e[n(881)](rh,{url:this._url,protocols:[this._protocols],headers:this._options[n(1002)+n(603)+"s"][n(1184)+n(868)]},this[n(1578)].ws),(this[n(493)+"er"]||this._isWorker)&&this._ws&&(this[n(1342)][n(1295)+"pe"]=this[n(1411)+n(1012)]),this["_addWsLi"+n(1771)](),this[n(1627)+"ionTimeo"+n(1170)]=e.SUQiM(setTimeout,this._onTimeout[n(1277)](this),d)}catch(i){throw this[n(1627)+"Lock"]=!1,i}}}[t(1267)+"mer"](){let n=t;e[n(1465)](clearTimeout,this["_connect"+n(711)+"utId"]),this[n(1627)+n(711)+n(1170)]=null}[t(1831)+t(1394)](){let n=t;e[n(727)](clearTimeout,this._pingPongTimeoutId),clearTimeout(this[n(1556)+"ctTimeoutId"]),this[n(1597)+n(887)+"Id"]=null,this[n(1556)+n(1693)+n(507)]=null}[t(662)](...n){let i=t;this[i(1578)][i(1887)]&&console[i(1590)][i(590)](console,[e.OCKFx,...n])}[t(882)+t(1351)+"e"](n){let i=t,{initReconnectInterval:d,maxReconnectInterval:u,reconnectIntervalGrowFactor:p}=this[i(1578)],S=d*Math[i(1029)](p,e[i(1100)](n,1));return e[i(1757)](S,u)?u:S}[t(669)](){let n=t;if(e[n(794)](e.VRsjd,"eCioG")){let i=_0x2e337f(_0x1ffc32),d=_0x32c287[n(880)];return _0x282bc2[n(880)]=e.RRkOO(_0x4c128b[n(883)],i),d}else{if(this[n(1342)]&&e.tgEvw(this[n(1342)].readyState,this[n(941)+"NG"]))if(e[n(627)]===n(749)){this[n(1831)+n(1394)](),this["_pingPon"+n(887)+"Id"]=e[n(475)](setTimeout,this._ping[n(1277)](this),this[n(1578)]["pingInte"+n(1314)]);return}else e[n(823)](_0x123378,this[n(1627)+"ionTimeo"+n(1170)]),this[n(1627)+n(711)+n(1170)]=null;if(!this[n(1342)]||e[n(657)](this[n(1342)][n(849)+"te"],this.OPEN))return void this[n(890)+n(741)]();this[n(1342)]&&this[n(1342)][n(754)]("hi"),this["_reconne"+n(1693)+n(507)]=e[n(1422)](setTimeout,this[n(890)+n(741)+n(1502)][n(1277)](this),this[n(1578)]["pingTime"+n(1632)+n(1843)])}}["_handleR"+t(741)+"Timeout"](){let n=t;this[n(573)+n(598)]?.[n(559)](),this.emit(n(744)+n(964)+"t",e[n(988)]),this[n(573)+n(598)]?.["checkRea"+n(736)+"nt"]()?this[n(890)+"econnect"]():this[n(669)]()}[t(479)+"orOnline"](){let n=t,i={UMhAN:function(d,u){return e[K(575)](d,u)},blsMR:function(d,u){return d>=u}};return e[n(1090)](n(528),n(985))?this[n(1083)+"T"]||this[n(663)+"X"]?this[n(1519)+n(1456)+n(1761)]:(this._isBrowser||this[n(586)+"r"])&&this._options[n(1580)+n(1375)+"nged"]?navigator[n(1515)]:!0:(_0xa3bd89|=0,{low:_0x54edf3,high:XRFjAJ.UMhAN(_0x2c2232,31),unsigned:XRFjAJ[n(839)](_0x12327b,0)})}[t(890)+t(741)](){let n=t;!this[n(479)+n(1816)]()||this[n(1523)+n(756)]||(this["_endpoin"+n(1357)]?.[n(1216)+n(1923)+n(1361)](),this[n(573)+n(598)]?.[n(484)+n(1662)](),this._ws?this[n(820)+n(1536)](1001,e[n(1461)],!0):this[n(1627)]())}["_onPageN"+t(994)+t(1268)](){let n=t;this[n(1083)+"T"]?tt["onNetwor"+n(832)+n(1161)](({isConnected:i})=>{let d=n;this[d(1519)+"igatorOn"+d(1761)]=i,i?this[d(798)+d(1775)]():this["_handleO"+d(730)]()}):this._isMiniWX&&wx[n(1828)+n(832)+n(1161)](({isConnected:i})=>{let d=n;this[d(1519)+d(1456)+d(1761)]=i,i?this[d(798)+d(1775)]():this[d(798)+d(730)]()})}[t(1364)](n){return new Promise(i=>{setTimeout(i,this[K(882)+"rvalValue"](n))})}[t(820)+t(1536)](n=1e3,i="",d=!1){let u=t;this[u(1342)]&&this[u(1675)+u(1308)+"t"](n,i,d)}[t(582)+"ut"](){let n=t,i=this[n(1750)+"tManager"]?.[n(596)+n(508)+"nt"]();this._debug("connect "+i+n(1084)),this["_disconn"+n(1536)](1001,e[n(1057)],!0)}[t(494)](n){let i=t,d={QdMyx:function(p,S){return e[K(885)](p,S)},sBneB:function(p,S){return e[K(1117)](p,S)},hpgGe:function(p,S){return e.ULaxj(p,S)}},u=Ke(n);if(this[i(1342)]&&this[i(1342)][i(849)+"te"]===this[i(874)])if(e.DcCdL!==e[i(1896)])this[i(1342)]&&this[i(1342)][i(754)](u),this._debug(e.DmHcF,n);else{let{url:p}=d[i(1393)](_0x40f4c5,{}),S=_0x342ff4[i(1412)](p)?p:d.sBneB(i(1220),typeof p)?[p]:[];_0xe48250&&_0x4dd1aa[i(1332)](this[i(1578)],_0x2aae33),S&&S[i(1541)]?this[i(1750)+"tManager"]=new _0x14e4d7(S,this._options.maxRetries):this[i(1750)+i(1357)]?.[i(1216)+i(1923)+i(1361)](),this[i(573)+i(598)]?.resetCounter(this[i(1578)][i(1241)+i(968)]),this[i(1523)+i(756)]=!1,this._ws&&d[i(688)](this[i(1342)][i(849)+"te"],this.CLOSED)?this[i(820)+"ect"](1e3,"manual r"+i(741)+i(1906),!0):(this[i(1425)]=!0,this[i(1627)]())}}["_removeW"+t(932)+"rs"](){let n=t,i=e[n(1028)].split("|"),d=0;for(;;){switch(i[d++]){case"0":this[n(1342)][n(644)+"entListe"+n(474)](e.VUQiO,this._onOpen);continue;case"1":if(!this[n(1342)])return;continue;case"2":this._ws[n(644)+"entListe"+n(474)](e.Gdlro,this[n(469)]);continue;case"3":this._ws[n(644)+n(1338)+n(474)](e.tnJaV,this._onError);continue;case"4":this[n(1342)][n(644)+n(1338)+n(474)](e[n(886)],this._onMessage);continue}break}}[t(1196)+t(1771)](){let n=t,i=e[n(1058)][n(906)]("|"),d=0;for(;;){switch(i[d++]){case"0":if(!this[n(1342)])return;continue;case"1":this[n(1342)]["addEvent"+n(948)](e[n(1059)],this[n(506)]);continue;case"2":this[n(1342)][n(1672)+"Listener"](e[n(677)],this[n(1493)]);continue;case"3":this._ws[n(1672)+n(948)](e[n(886)],this[n(661)+"ge"]);continue;case"4":this[n(1342)][n(1672)+n(948)](e[n(1664)],this._onClose);continue}break}}["_wsInsta"+t(1152)](n=1e3,i=""){let d=t;if(e[d(1269)]!==e[d(1269)])this[d(1150)]++;else try{if(e[d(808)](d(846),"fiDtR"))return this[d(1114)].protocol;this[d(1342)]&&this[d(1342)][d(1668)](n,i)}catch{}}[t(1675)+"WebSocket"](n=1e3,i="",d=!1){let u=t,p={KRdrX:function(S,b){return e[K(891)](S,b)},QdrwX:function(S,b){return S-b}};if(e[u(1046)](e[u(1509)],e[u(1509)])){if(this["_clearPi"+u(1394)](),this[u(1267)+u(1666)](),this[u(620)+u(932)+"rs"](),this[u(1739)+u(1152)](1e3,i),this["_connect"+u(1868)]=!1,d&&this[u(479)+u(1816)]()&&!this[u(1523)+u(756)])if(e[u(1157)](e[u(1476)],e[u(1476)])){if(this["_endpoin"+u(1357)]?.[u(1647)+u(1558)+"es"]()){let b=this["_endpoin"+u(1357)]?.[u(596)+"ntEndpoint"]();this[u(1485)+u(1031)+u(1464)](e[u(672)](at,e.Gdlro,{code:1006,reason:u(836)+b+(u(1084)+u(892)+u(1022)+u(653)),wasClean:!0}))}else{let b=this[u(1578)][u(939)+"tInterce"+u(710)](n,i);this["_dispatc"+u(1031)+u(1464)](e[u(745)](at,u(1668),{code:n,reason:i,wasClean:!0,willReconnect:b})),b&&this[u(1627)]()}return}else this.emit(e[u(1664)],_0xb94019(e[u(1664)],{..._0x581450}));this[u(479)+u(1816)]()||this[u(1523)+u(756)]?this[u(1485)+u(1031)+u(1464)](at(e[u(1664)],{code:n,reason:e[u(1407)]})):this[u(1485)+u(1031)+"ent"](e[u(1305)](at,e[u(1664)],{code:1006,reason:e[u(790)]})),this._ws=null,this._endpointManager?.[u(1216)+u(1923)+u(1361)](),this[u(573)+u(598)]?.[u(484)+"nter"]()}else{if(jMULre.KRdrX(4,_0x263b4f[u(1541)])){let S=_0x2a45c3[u(1500)+"g"](0,jMULre[u(1914)](4,_0x1a3824[u(1541)])),b=S[u(1835)](_0x1714fb);_0x3926df[u(1416)](b)}else _0x2253e9[u(1416)](_0x441c07);_0xcc9be9&&(_0x2e77f0+=1),_0x3abcce+=1,_0x494d8c=!1}}[t(1485)+"hOpenEvent"](n){let i=t;this[i(1473)](e[i(677)],n),this[i(1643)]&&this.onopen(n)}[t(1485)+t(955)+t(856)](n){let i=t;this[i(1473)](i(1727),n),this[i(1388)+"e"]&&this[i(1388)+"e"](n)}[t(1485)+t(1042)+t(867)](n){let i=t;if(e[i(732)](e[i(1290)],"yaJam"))this[i(1473)](e[i(1807)],n),this[i(1728)+i(1703)]&&this[i(1728)+i(1703)](n);else return this[i(1737)+"s"][this[i(1713)+i(1280)]]}[t(1485)+t(1062)+t(1464)](n){let i=t;this.emit(e[i(1059)],n),this[i(905)]&&this[i(905)](n)}[t(1485)+"hCloseEv"+t(1464)](n){let i=t;this[i(1473)](e[i(1664)],n),this[i(888)]&&this.onclose(n)}get[t(1295)+"pe"](){let n=t;return this[n(1342)]?this[n(1342)][n(1295)+"pe"]:this[n(1411)+n(1012)]}set[t(1295)+"pe"](n){let i=t;this["_binaryT"+i(1012)]=n,this[i(1342)]&&(this._ws[i(1295)+"pe"]=n)}get[t(1454)+"nt"](){let n=t;return this[n(1750)+n(1357)]?.[n(596)+n(508)+"ntTriesC"+n(1567)]()||0}get["buffered"+t(1235)](){let n=t;return this[n(542)+"Queue"].reduce((d,u)=>(d+=u&&u[n(1105)+"th"]||0,d),0)+(this._ws?this._ws[n(1525)+n(1235)]:0)}get extensions(){let n=t;return e.ULaxj(n(1048),n(1910))?this[n(1342)]?this[n(1342)][n(931)+"ns"]:"":this[n(1187)]?e.tftpo(e[n(1922)](e[n(505)](this.high,0),_0x239245),e[n(451)](this.low,0)):e.vcpBm(this[n(780)],_0x564c53)+e[n(692)](this.low,0)}get[t(1687)](){let n=t;return this._ws?this[n(1342)][n(1687)]:""}get readyState(){let n=t;return this[n(1342)]?this[n(1342)][n(849)+"te"]:this[n(1578)]["automati"+n(1667)]?this[n(941)+"NG"]:this[n(527)]}get[t(1188)](){let n=t;return this._ws?this[n(1342)][n(1188)]:this[n(1759)]}[t(1668)](n=1e3,i){let d=t;if(e[d(1089)](d(1007),e[d(578)])){let u=this[d(780)],p=this.low;return[255&p,e[d(746)](p,8)&255,e.gdGhG(e.JMMxw(p,16),255),p>>>24,e.NvgkF(255,u),e[d(1477)](e[d(712)](u,8),255),e.fkxpP(u,16)&255,e[d(712)](u,24)]}else{if(this[d(1523)+"osed"]=!0,this[d(1267)+d(1666)](),this["_clearPi"+d(1394)](),this["_dropGlo"+d(1600)+d(948)](),this[d(1211)+d(1764)]?.closeDB(),!this._ws)return void this._debug(d(1330)+d(1535)+d(1856)+d(1569)+"ed");if(e.uMlAD(this[d(1342)][d(849)+"te"],this[d(527)])||e[d(1866)](this[d(1342)].readyState,this.CLOSING))return void this[d(662)](e[d(1553)]);this[d(1675)+"WebSocket"](n,i)}}async[t(754)](n,i){let d=t,u={XpFTi:e.AsIuf,JkCZC:d(1514)};if(e[d(1829)](e.XabYa,e.yTjqd))_0x2b57b7[d(644)+d(1338)+"ner"](PyTOKT[d(1116)],_0x25985b),_0x2d56d4["removeEventListe"+d(474)](PyTOKT.JkCZC,_0x3375fd);else{if(n==null)throw new Error(e[d(841)]);e[d(1081)](e[d(1041)],typeof n)&&(n=JSON[d(1774)+"y"](n)),e[d(1560)](e[d(1419)],typeof n)&&!e[d(1453)](n,ArrayBuffer)&&!(n[d(1339)]&&e.Svpfh(n.buffer,ArrayBuffer))&&(n=JSON.stringify(n));let p=await I0(n),S=sh(n),{method:b=0,service:g=this._options[d(1318)],logID:T=this[d(1578)][d(1628)+d(930)](),headers:P=this._options[d(966)],payloadEncoding:B=this[d(1578)][d(1094)+"ncoding"],payloadType:j=this._options[d(679)+d(1012)],logIDNew:V=this[d(1578)].logIDNewConfig[d(489)+d(1885)+d(1301)+"ew"]?e.mSrNP(s,this[d(1578)][d(480)+d(580)][d(1079)]):""}=e[d(897)](i,{});if(!g)throw new Error(e[d(954)]);let J={SeqID:oe[d(1939)+"er"](this[d(545)]++),LogID:oe[d(1939)+"er"](T),service:g,method:b,headers:P,payloadEncoding:e[d(1010)](B,Object)?B[d(1455)]?B[d(1455)]:"":B,payloadType:j instanceof Object?j[d(457)]?j.type:S:j||S,payload:p,LogIDNew:V},He=Ke(J);return this[d(1342)]&&e[d(604)](this._ws.readyState,this[d(874)])?(this[d(1342)]&&this[d(1342)][d(754)](He),this[d(662)]("sent",J)):e[d(1182)](this._messageQueue.length,this[d(1578)][d(496)+"geQueueL"+d(1633)])?(this["_message"+d(472)][d(1416)](He),this[d(662)](e[d(1260)],J)):(this[d(542)+d(472)][d(1440)](),this[d(542)+d(472)][d(1416)](He)),{seqID:this[d(545)],logID:T,logIDNew:V}}}async[t(939)+"t"](n){let i=t,{url:d}=e[i(1292)](n,{}),u=Array.isArray(d)?d:e[i(1593)](e.tnmdO,typeof d)?[d]:[];n&&Object[i(1332)](this._options,n),u&&u[i(1541)]?this[i(1750)+i(1357)]=new E0(u,this[i(1578)][i(1862)+"es"]):this[i(1750)+i(1357)]?.[i(1216)+i(1923)+i(1361)](),this[i(573)+"sCounter"]?.[i(484)+i(1662)](this[i(1578)][i(1241)+i(968)]),this[i(1523)+i(756)]=!1,this[i(1342)]&&this[i(1342)].readyState!==this[i(527)]?this[i(820)+i(1536)](1e3,"manual r"+i(741)+i(1906),!0):e[i(1501)]===e[i(1384)]?_0x3bfb00.o=(p,S)=>_0x349d9e[i(1258)+"e"]["hasOwnPr"+i(1149)][i(783)](p,S):(this._isInit=!0,this._connect())}async[t(684)](){let n=t;!this["_connect"+n(1868)]&&(this["_endpoin"+n(1357)]?.[n(1216)+n(1923)+n(1361)](),this[n(573)+n(598)]?.[n(484)+n(1662)](),this[n(1523)+n(756)]=!1,this[n(1425)]=!0,this[n(1627)]())}[t(1672)+t(948)](n,i){let d=t;if(e[d(1635)](d(720),e[d(594)]))this.on(n,i);else{let u=_0x2f4f24[d(1724)],p=_0xedb2e7[d(780)];return _0x9b7d3e[_0xdf360e]=e[d(712)](p,24),_0x1a2b05[e[d(460)](_0x5de187,1)]=e[d(1169)](e.RsmSv(p,16),255),_0x507d2d[e[d(733)](_0x5bd5dc,2)]=e[d(1557)](p,8)&255,_0x2ccd24[_0x16860a+3]=255&p,_0xa6c626[e.CmZoE(_0x4a4d19,4)]=u>>>24,_0x2ad15b[e[d(1499)](_0x59688c,5)]=e[d(1722)](e[d(1686)](u,16),255),_0x38c4f6[_0x40a903+6]=e[d(947)](e[d(668)](u,8),255),_0x591328[_0x55f1f0+7]=e[d(1477)](255,u),_0x17e930+=8,_0x4a14e0}}[t(755)+t(856)](n){let i=t,{type:d}=n;this[i(1473)](d,n)}[t(644)+"entListe"+t(474)](n,i){this[t(811)](n,i)}[t(1487)](){let n=t,i={tdDze:e[n(1661)],uTeQE:e[n(473)]};return new Promise((d,u)=>{let p=n,S={uKwyt:function(b,g){return e[K(500)](b,g)},AlGvt:function(b,g){return e[K(729)](b,g)},IppuF:function(b,g){return b!==g},iVGFU:p(1389),IsblM:p(744)+p(807)+"s",SpVxQ:p(744)+p(964)+"t"};if(e[p(1279)](e.xmskF,e[p(714)])){if(XLksxp.uKwyt(_0x41d93a,_0x35b3c8))return _0x23b0cd(_0xc3fe1c);if(_0x1162e1[p(541)](_0x439b88))return _0x33f935[p(904)](_0x1fcd49);let b=XLksxp[p(871)](_0x2f3f03,_0xc7dc55);return XLksxp[p(1796)](b,_0x180fa1)&&(_0x29c26d[p(717)](_0x1101b9,b),_0x33a891[p(717)](b,_0x2da1c1)),b}else{this[p(1831)+p(1394)](),this[p(1597)+p(887)+"Id"]=setTimeout(this._ping[p(1277)](this),this._options.pingInterval);let b=()=>{let T=p;d(S[T(1077)]),this[T(811)](S[T(957)],b),this.off(S[T(1585)],g)},g=()=>{let T=p;u(T(1471)),this[T(811)](i.tdDze,b),this.off(i[T(572)],g)};this.on(p(744)+p(807)+"s",b),this.on(e.xAQDB,g),this[p(669)]()}})}}})(),ve[M(1873)+"oseEvent"]=Ee["CustomCl"+M(1075)],ve["CustomEr"+M(827)]=Ee[M(1783)+M(827)],ve.ErrorCode=Ee[M(767)+"e"],ve[M(856)]=Ee[M(856)],ve[M(731)]=Ee[M(731)],ve.FrontierMessageEvent=Ee[M(1881)+"MessageE"+M(536)],ve[M(870)+M(536)]=Ee[M(870)+"vent"],ve[M(1076)+"t"]=Ee[M(1076)+"t"],ve[M(681)+"tEvent"]=Ee[M(681)+M(1481)],ve[M(635)+"oseEvent"]=Ee[M(635)+M(1075)],ve[M(912)+"rorEvent"]=Ee["createEr"+M(827)],ve[M(1011)+M(518)+"nt"]=Ee["createMe"+M(518)+"nt"],ve[M(1651)+M(1588)]=Ee[M(1651)+M(1588)],ve["createRe"+M(1193)+M(536)]=Ee[M(664)+M(1193)+M(536)],ve[M(1762)+"rame"]=Ee[M(1762)+"rame"],ve[M(1805)+"ame"]=Ee[M(1805)+M(777)];for(Xs in Ee)[M(1873)+M(1075),M(1783)+M(827),M(767)+"e",M(856),M(731),M(1881)+M(870)+M(536),M(870)+M(536),M(1076)+"t",M(681)+M(1481),"createCl"+M(1075),M(912)+M(827),"createMessageEvent",M(1651)+M(1588),M(664)+M(1193)+M(536),"decodedFrame",M(1805)+M(777)][M(1168)](Xs)===-1&&(ve[Xs]=Ee[Xs]);var Xs;Object[M(1889)+M(1149)](ve,M(700)+"le",{value:!0})});var Ft=ne((OI,pu)=>{"use strict";var xu=["nodebuffer","arraybuffer","fragments"],hu=typeof Blob<"u";hu&&xu.push("blob");pu.exports={BINARY_TYPES:xu,CLOSE_TIMEOUT:3e4,EMPTY_BUFFER:Buffer.alloc(0),GUID:"258EAFA5-E914-47DA-95CA-C5AB0DC85B11",hasBlob:hu,kForOnEventAttribute:Symbol("kIsForOnEventAttribute"),kListener:Symbol("kListener"),kStatusCode:Symbol("status-code"),kWebSocket:Symbol("websocket"),NOOP:()=>{}}});var bi=ne((PI,so)=>{"use strict";var{EMPTY_BUFFER:Iy}=Ft(),Cc=Buffer[Symbol.species];function Ay(t,e){if(t.length===0)return Iy;if(t.length===1)return t[0];let r=Buffer.allocUnsafe(e),s=0;for(let a=0;a<t.length;a++){let c=t[a];r.set(c,s),s+=c.length}return s<e?new Cc(r.buffer,r.byteOffset,s):r}function gu(t,e,r,s,a){for(let c=0;c<a;c++)r[s+c]=t[c]^e[c&3]}function mu(t,e){for(let r=0;r<t.length;r++)t[r]^=e[r&3]}function Cy(t){return t.length===t.buffer.byteLength?t.buffer:t.buffer.slice(t.byteOffset,t.byteOffset+t.length)}function Tc(t){if(Tc.readOnly=!0,Buffer.isBuffer(t))return t;let e;return t instanceof ArrayBuffer?e=new Cc(t):ArrayBuffer.isView(t)?e=new Cc(t.buffer,t.byteOffset,t.byteLength):(e=Buffer.from(t),Tc.readOnly=!1),e}so.exports={concat:Ay,mask:gu,toArrayBuffer:Cy,toBuffer:Tc,unmask:mu};if(!process.env.WS_NO_BUFFER_UTIL)try{let t=ae("bufferutil");so.exports.mask=function(e,r,s,a,c){c<48?gu(e,r,s,a,c):t.mask(e,r,s,a,c)},so.exports.unmask=function(e,r){e.length<32?mu(e,r):t.unmask(e,r)}}catch{}});var yu=ne((LI,_u)=>{"use strict";var wu=Symbol("kDone"),Dc=Symbol("kRun"),Rc=class{constructor(e){this[wu]=()=>{this.pending--,this[Dc]()},this.concurrency=e||1/0,this.jobs=[],this.pending=0}add(e){this.jobs.push(e),this[Dc]()}[Dc](){if(this.pending!==this.concurrency&&this.jobs.length){let e=this.jobs.shift();this.pending++,e(this[wu])}}};_u.exports=Rc});var vr=ne((NI,vu)=>{"use strict";var Si=ae("zlib"),Eu=bi(),Ty=yu(),{kStatusCode:bu}=Ft(),Dy=Buffer[Symbol.species],Ry=Buffer.from([0,0,255,255]),ao=Symbol("permessage-deflate"),Ut=Symbol("total-length"),br=Symbol("callback"),mn=Symbol("buffers"),Sr=Symbol("error"),oo,kc=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,!oo){let r=this._options.concurrencyLimit!==void 0?this._options.concurrencyLimit:10;oo=new Ty(r)}}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[br];this._deflate.close(),this._deflate=null,e&&e(new Error("The deflate stream was closed while data was being processed"))}}acceptAsServer(e){let r=this._options,s=e.find(a=>!(r.serverNoContextTakeover===!1&&a.server_no_context_takeover||a.server_max_window_bits&&(r.serverMaxWindowBits===!1||typeof r.serverMaxWindowBits=="number"&&r.serverMaxWindowBits>a.server_max_window_bits)||typeof r.clientMaxWindowBits=="number"&&!a.client_max_window_bits));if(!s)throw new Error("None of the extension offers can be accepted");return r.serverNoContextTakeover&&(s.server_no_context_takeover=!0),r.clientNoContextTakeover&&(s.client_no_context_takeover=!0),typeof r.serverMaxWindowBits=="number"&&(s.server_max_window_bits=r.serverMaxWindowBits),typeof r.clientMaxWindowBits=="number"?s.client_max_window_bits=r.clientMaxWindowBits:(s.client_max_window_bits===!0||r.clientMaxWindowBits===!1)&&delete s.client_max_window_bits,s}acceptAsClient(e){let r=e[0];if(this._options.clientNoContextTakeover===!1&&r.client_no_context_takeover)throw new Error('Unexpected parameter "client_no_context_takeover"');if(!r.client_max_window_bits)typeof this._options.clientMaxWindowBits=="number"&&(r.client_max_window_bits=this._options.clientMaxWindowBits);else if(this._options.clientMaxWindowBits===!1||typeof this._options.clientMaxWindowBits=="number"&&r.client_max_window_bits>this._options.clientMaxWindowBits)throw new Error('Unexpected or invalid parameter "client_max_window_bits"');return r}normalizeParams(e){return e.forEach(r=>{Object.keys(r).forEach(s=>{let a=r[s];if(a.length>1)throw new Error(`Parameter "${s}" must have only a single value`);if(a=a[0],s==="client_max_window_bits"){if(a!==!0){let c=+a;if(!Number.isInteger(c)||c<8||c>15)throw new TypeError(`Invalid value for parameter "${s}": ${a}`);a=c}else if(!this._isServer)throw new TypeError(`Invalid value for parameter "${s}": ${a}`)}else if(s==="server_max_window_bits"){let c=+a;if(!Number.isInteger(c)||c<8||c>15)throw new TypeError(`Invalid value for parameter "${s}": ${a}`);a=c}else if(s==="client_no_context_takeover"||s==="server_no_context_takeover"){if(a!==!0)throw new TypeError(`Invalid value for parameter "${s}": ${a}`)}else throw new Error(`Unknown parameter "${s}"`);r[s]=a})}),e}decompress(e,r,s){oo.add(a=>{this._decompress(e,r,(c,f)=>{a(),s(c,f)})})}compress(e,r,s){oo.add(a=>{this._compress(e,r,(c,f)=>{a(),s(c,f)})})}_decompress(e,r,s){let a=this._isServer?"client":"server";if(!this._inflate){let c=`${a}_max_window_bits`,f=typeof this.params[c]!="number"?Si.Z_DEFAULT_WINDOWBITS:this.params[c];this._inflate=Si.createInflateRaw({...this._options.zlibInflateOptions,windowBits:f}),this._inflate[ao]=this,this._inflate[Ut]=0,this._inflate[mn]=[],this._inflate.on("error",Oy),this._inflate.on("data",Su)}this._inflate[br]=s,this._inflate.write(e),r&&this._inflate.write(Ry),this._inflate.flush(()=>{let c=this._inflate[Sr];if(c){this._inflate.close(),this._inflate=null,s(c);return}let f=Eu.concat(this._inflate[mn],this._inflate[Ut]);this._inflate._readableState.endEmitted?(this._inflate.close(),this._inflate=null):(this._inflate[Ut]=0,this._inflate[mn]=[],r&&this.params[`${a}_no_context_takeover`]&&this._inflate.reset()),s(null,f)})}_compress(e,r,s){let a=this._isServer?"server":"client";if(!this._deflate){let c=`${a}_max_window_bits`,f=typeof this.params[c]!="number"?Si.Z_DEFAULT_WINDOWBITS:this.params[c];this._deflate=Si.createDeflateRaw({...this._options.zlibDeflateOptions,windowBits:f}),this._deflate[Ut]=0,this._deflate[mn]=[],this._deflate.on("data",ky)}this._deflate[br]=s,this._deflate.write(e),this._deflate.flush(Si.Z_SYNC_FLUSH,()=>{if(!this._deflate)return;let c=Eu.concat(this._deflate[mn],this._deflate[Ut]);r&&(c=new Dy(c.buffer,c.byteOffset,c.length-4)),this._deflate[br]=null,this._deflate[Ut]=0,this._deflate[mn]=[],r&&this.params[`${a}_no_context_takeover`]&&this._deflate.reset(),s(null,c)})}};vu.exports=kc;function ky(t){this[mn].push(t),this[Ut]+=t.length}function Su(t){if(this[Ut]+=t.length,this[ao]._maxPayload<1||this[Ut]<=this[ao]._maxPayload){this[mn].push(t);return}this[Sr]=new RangeError("Max payload size exceeded"),this[Sr].code="WS_ERR_UNSUPPORTED_MESSAGE_LENGTH",this[Sr][bu]=1009,this.removeListener("data",Su),this.reset()}function Oy(t){if(this[ao]._inflate=null,this[Sr]){this[br](this[Sr]);return}t[bu]=1007,this[br](t)}});var Ir=ne((MI,co)=>{"use strict";var{isUtf8:Iu}=ae("buffer"),{hasBlob:Py}=Ft(),Ly=[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 Ny(t){return t>=1e3&&t<=1014&&t!==1004&&t!==1005&&t!==1006||t>=3e3&&t<=4999}function Oc(t){let e=t.length,r=0;for(;r<e;)if((t[r]&128)===0)r++;else if((t[r]&224)===192){if(r+1===e||(t[r+1]&192)!==128||(t[r]&254)===192)return!1;r+=2}else if((t[r]&240)===224){if(r+2>=e||(t[r+1]&192)!==128||(t[r+2]&192)!==128||t[r]===224&&(t[r+1]&224)===128||t[r]===237&&(t[r+1]&224)===160)return!1;r+=3}else if((t[r]&248)===240){if(r+3>=e||(t[r+1]&192)!==128||(t[r+2]&192)!==128||(t[r+3]&192)!==128||t[r]===240&&(t[r+1]&240)===128||t[r]===244&&t[r+1]>143||t[r]>244)return!1;r+=4}else return!1;return!0}function My(t){return Py&&typeof t=="object"&&typeof t.arrayBuffer=="function"&&typeof t.type=="string"&&typeof t.stream=="function"&&(t[Symbol.toStringTag]==="Blob"||t[Symbol.toStringTag]==="File")}co.exports={isBlob:My,isValidStatusCode:Ny,isValidUTF8:Oc,tokenChars:Ly};if(Iu)co.exports.isValidUTF8=function(t){return t.length<24?Oc(t):Iu(t)};else if(!process.env.WS_NO_UTF_8_VALIDATE)try{let t=ae("utf-8-validate");co.exports.isValidUTF8=function(e){return e.length<32?Oc(e):t(e)}}catch{}});var Bc=ne((BI,Ou)=>{"use strict";var{Writable:By}=ae("stream"),Au=vr(),{BINARY_TYPES:zy,EMPTY_BUFFER:Cu,kStatusCode:Fy,kWebSocket:Uy}=Ft(),{concat:Pc,toArrayBuffer:qy,unmask:Hy}=bi(),{isValidStatusCode:jy,isValidUTF8:Tu}=Ir(),fo=Buffer[Symbol.species],it=0,Du=1,Ru=2,ku=3,Lc=4,Nc=5,lo=6,Mc=class extends By{constructor(e={}){super(),this._allowSynchronousEvents=e.allowSynchronousEvents!==void 0?e.allowSynchronousEvents:!0,this._binaryType=e.binaryType||zy[0],this._extensions=e.extensions||{},this._isServer=!!e.isServer,this._maxPayload=e.maxPayload|0,this._skipUTF8Validation=!!e.skipUTF8Validation,this[Uy]=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=it}_write(e,r,s){if(this._opcode===8&&this._state==it)return s();this._bufferedBytes+=e.length,this._buffers.push(e),this.startLoop(s)}consume(e){if(this._bufferedBytes-=e,e===this._buffers[0].length)return this._buffers.shift();if(e<this._buffers[0].length){let s=this._buffers[0];return this._buffers[0]=new fo(s.buffer,s.byteOffset+e,s.length-e),new fo(s.buffer,s.byteOffset,e)}let r=Buffer.allocUnsafe(e);do{let s=this._buffers[0],a=r.length-e;e>=s.length?r.set(this._buffers.shift(),a):(r.set(new Uint8Array(s.buffer,s.byteOffset,e),a),this._buffers[0]=new fo(s.buffer,s.byteOffset+e,s.length-e)),e-=s.length}while(e>0);return r}startLoop(e){this._loop=!0;do switch(this._state){case it:this.getInfo(e);break;case Du:this.getPayloadLength16(e);break;case Ru:this.getPayloadLength64(e);break;case ku:this.getMask();break;case Lc:this.getData(e);break;case Nc:case lo:this._loop=!1;return}while(this._loop);this._errored||e()}getInfo(e){if(this._bufferedBytes<2){this._loop=!1;return}let r=this.consume(2);if((r[0]&48)!==0){let a=this.createError(RangeError,"RSV2 and RSV3 must be clear",!0,1002,"WS_ERR_UNEXPECTED_RSV_2_3");e(a);return}let s=(r[0]&64)===64;if(s&&!this._extensions[Au.extensionName]){let a=this.createError(RangeError,"RSV1 must be clear",!0,1002,"WS_ERR_UNEXPECTED_RSV_1");e(a);return}if(this._fin=(r[0]&128)===128,this._opcode=r[0]&15,this._payloadLength=r[1]&127,this._opcode===0){if(s){let a=this.createError(RangeError,"RSV1 must be clear",!0,1002,"WS_ERR_UNEXPECTED_RSV_1");e(a);return}if(!this._fragmented){let a=this.createError(RangeError,"invalid opcode 0",!0,1002,"WS_ERR_INVALID_OPCODE");e(a);return}this._opcode=this._fragmented}else if(this._opcode===1||this._opcode===2){if(this._fragmented){let a=this.createError(RangeError,`invalid opcode ${this._opcode}`,!0,1002,"WS_ERR_INVALID_OPCODE");e(a);return}this._compressed=s}else if(this._opcode>7&&this._opcode<11){if(!this._fin){let a=this.createError(RangeError,"FIN must be set",!0,1002,"WS_ERR_EXPECTED_FIN");e(a);return}if(s){let a=this.createError(RangeError,"RSV1 must be clear",!0,1002,"WS_ERR_UNEXPECTED_RSV_1");e(a);return}if(this._payloadLength>125||this._opcode===8&&this._payloadLength===1){let a=this.createError(RangeError,`invalid payload length ${this._payloadLength}`,!0,1002,"WS_ERR_INVALID_CONTROL_PAYLOAD_LENGTH");e(a);return}}else{let a=this.createError(RangeError,`invalid opcode ${this._opcode}`,!0,1002,"WS_ERR_INVALID_OPCODE");e(a);return}if(!this._fin&&!this._fragmented&&(this._fragmented=this._opcode),this._masked=(r[1]&128)===128,this._isServer){if(!this._masked){let a=this.createError(RangeError,"MASK must be set",!0,1002,"WS_ERR_EXPECTED_MASK");e(a);return}}else if(this._masked){let a=this.createError(RangeError,"MASK must be clear",!0,1002,"WS_ERR_UNEXPECTED_MASK");e(a);return}this._payloadLength===126?this._state=Du:this._payloadLength===127?this._state=Ru: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 r=this.consume(8),s=r.readUInt32BE(0);if(s>Math.pow(2,21)-1){let a=this.createError(RangeError,"Unsupported WebSocket frame: payload length > 2^53 - 1",!1,1009,"WS_ERR_UNSUPPORTED_DATA_PAYLOAD_LENGTH");e(a);return}this._payloadLength=s*Math.pow(2,32)+r.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 r=this.createError(RangeError,"Max payload size exceeded",!1,1009,"WS_ERR_UNSUPPORTED_MESSAGE_LENGTH");e(r);return}this._masked?this._state=ku:this._state=Lc}getMask(){if(this._bufferedBytes<4){this._loop=!1;return}this._mask=this.consume(4),this._state=Lc}getData(e){let r=Cu;if(this._payloadLength){if(this._bufferedBytes<this._payloadLength){this._loop=!1;return}r=this.consume(this._payloadLength),this._masked&&(this._mask[0]|this._mask[1]|this._mask[2]|this._mask[3])!==0&&Hy(r,this._mask)}if(this._opcode>7){this.controlMessage(r,e);return}if(this._compressed){this._state=Nc,this.decompress(r,e);return}r.length&&(this._messageLength=this._totalPayloadLength,this._fragments.push(r)),this.dataMessage(e)}decompress(e,r){this._extensions[Au.extensionName].decompress(e,this._fin,(a,c)=>{if(a)return r(a);if(c.length){if(this._messageLength+=c.length,this._messageLength>this._maxPayload&&this._maxPayload>0){let f=this.createError(RangeError,"Max payload size exceeded",!1,1009,"WS_ERR_UNSUPPORTED_MESSAGE_LENGTH");r(f);return}this._fragments.push(c)}this.dataMessage(r),this._state===it&&this.startLoop(r)})}dataMessage(e){if(!this._fin){this._state=it;return}let r=this._messageLength,s=this._fragments;if(this._totalPayloadLength=0,this._messageLength=0,this._fragmented=0,this._fragments=[],this._opcode===2){let a;this._binaryType==="nodebuffer"?a=Pc(s,r):this._binaryType==="arraybuffer"?a=qy(Pc(s,r)):this._binaryType==="blob"?a=new Blob(s):a=s,this._allowSynchronousEvents?(this.emit("message",a,!0),this._state=it):(this._state=lo,setImmediate(()=>{this.emit("message",a,!0),this._state=it,this.startLoop(e)}))}else{let a=Pc(s,r);if(!this._skipUTF8Validation&&!Tu(a)){let c=this.createError(Error,"invalid UTF-8 sequence",!0,1007,"WS_ERR_INVALID_UTF8");e(c);return}this._state===Nc||this._allowSynchronousEvents?(this.emit("message",a,!1),this._state=it):(this._state=lo,setImmediate(()=>{this.emit("message",a,!1),this._state=it,this.startLoop(e)}))}}controlMessage(e,r){if(this._opcode===8){if(e.length===0)this._loop=!1,this.emit("conclude",1005,Cu),this.end();else{let s=e.readUInt16BE(0);if(!jy(s)){let c=this.createError(RangeError,`invalid status code ${s}`,!0,1002,"WS_ERR_INVALID_CLOSE_CODE");r(c);return}let a=new fo(e.buffer,e.byteOffset+2,e.length-2);if(!this._skipUTF8Validation&&!Tu(a)){let c=this.createError(Error,"invalid UTF-8 sequence",!0,1007,"WS_ERR_INVALID_UTF8");r(c);return}this._loop=!1,this.emit("conclude",s,a),this.end()}this._state=it;return}this._allowSynchronousEvents?(this.emit(this._opcode===9?"ping":"pong",e),this._state=it):(this._state=lo,setImmediate(()=>{this.emit(this._opcode===9?"ping":"pong",e),this._state=it,this.startLoop(r)}))}createError(e,r,s,a,c){this._loop=!1,this._errored=!0;let f=new e(s?`Invalid WebSocket frame: ${r}`:r);return Error.captureStackTrace(f,this.createError),f.code=c,f[Fy]=a,f}};Ou.exports=Mc});var Uc=ne((FI,Nu)=>{"use strict";var{Duplex:zI}=ae("stream"),{randomFillSync:Gy}=ae("crypto"),Pu=vr(),{EMPTY_BUFFER:Ky,kWebSocket:Wy,NOOP:$y}=Ft(),{isBlob:Ar,isValidStatusCode:Vy}=Ir(),{mask:Lu,toBuffer:Nn}=bi(),st=Symbol("kByteLength"),Jy=Buffer.alloc(4),uo=8*1024,Mn,Cr=uo,pt=0,Zy=1,Yy=2,zc=class t{constructor(e,r,s){this._extensions=r||{},s&&(this._generateMask=s,this._maskBuffer=Buffer.alloc(4)),this._socket=e,this._firstFragment=!0,this._compress=!1,this._bufferedBytes=0,this._queue=[],this._state=pt,this.onerror=$y,this[Wy]=void 0}static frame(e,r){let s,a=!1,c=2,f=!1;r.mask&&(s=r.maskBuffer||Jy,r.generateMask?r.generateMask(s):(Cr===uo&&(Mn===void 0&&(Mn=Buffer.alloc(uo)),Gy(Mn,0,uo),Cr=0),s[0]=Mn[Cr++],s[1]=Mn[Cr++],s[2]=Mn[Cr++],s[3]=Mn[Cr++]),f=(s[0]|s[1]|s[2]|s[3])===0,c=6);let l;typeof e=="string"?(!r.mask||f)&&r[st]!==void 0?l=r[st]:(e=Buffer.from(e),l=e.length):(l=e.length,a=r.mask&&r.readOnly&&!f);let x=l;l>=65536?(c+=8,x=127):l>125&&(c+=2,x=126);let h=Buffer.allocUnsafe(a?l+c:c);return h[0]=r.fin?r.opcode|128:r.opcode,r.rsv1&&(h[0]|=64),h[1]=x,x===126?h.writeUInt16BE(l,2):x===127&&(h[2]=h[3]=0,h.writeUIntBE(l,4,6)),r.mask?(h[1]|=128,h[c-4]=s[0],h[c-3]=s[1],h[c-2]=s[2],h[c-1]=s[3],f?[h,e]:a?(Lu(e,s,h,c,l),[h]):(Lu(e,s,e,0,l),[h,e])):[h,e]}close(e,r,s,a){let c;if(e===void 0)c=Ky;else{if(typeof e!="number"||!Vy(e))throw new TypeError("First argument must be a valid error code number");if(r===void 0||!r.length)c=Buffer.allocUnsafe(2),c.writeUInt16BE(e,0);else{let l=Buffer.byteLength(r);if(l>123)throw new RangeError("The message must not be greater than 123 bytes");c=Buffer.allocUnsafe(2+l),c.writeUInt16BE(e,0),typeof r=="string"?c.write(r,2):c.set(r,2)}}let f={[st]:c.length,fin:!0,generateMask:this._generateMask,mask:s,maskBuffer:this._maskBuffer,opcode:8,readOnly:!1,rsv1:!1};this._state!==pt?this.enqueue([this.dispatch,c,!1,f,a]):this.sendFrame(t.frame(c,f),a)}ping(e,r,s){let a,c;if(typeof e=="string"?(a=Buffer.byteLength(e),c=!1):Ar(e)?(a=e.size,c=!1):(e=Nn(e),a=e.length,c=Nn.readOnly),a>125)throw new RangeError("The data size must not be greater than 125 bytes");let f={[st]:a,fin:!0,generateMask:this._generateMask,mask:r,maskBuffer:this._maskBuffer,opcode:9,readOnly:c,rsv1:!1};Ar(e)?this._state!==pt?this.enqueue([this.getBlobData,e,!1,f,s]):this.getBlobData(e,!1,f,s):this._state!==pt?this.enqueue([this.dispatch,e,!1,f,s]):this.sendFrame(t.frame(e,f),s)}pong(e,r,s){let a,c;if(typeof e=="string"?(a=Buffer.byteLength(e),c=!1):Ar(e)?(a=e.size,c=!1):(e=Nn(e),a=e.length,c=Nn.readOnly),a>125)throw new RangeError("The data size must not be greater than 125 bytes");let f={[st]:a,fin:!0,generateMask:this._generateMask,mask:r,maskBuffer:this._maskBuffer,opcode:10,readOnly:c,rsv1:!1};Ar(e)?this._state!==pt?this.enqueue([this.getBlobData,e,!1,f,s]):this.getBlobData(e,!1,f,s):this._state!==pt?this.enqueue([this.dispatch,e,!1,f,s]):this.sendFrame(t.frame(e,f),s)}send(e,r,s){let a=this._extensions[Pu.extensionName],c=r.binary?2:1,f=r.compress,l,x;typeof e=="string"?(l=Buffer.byteLength(e),x=!1):Ar(e)?(l=e.size,x=!1):(e=Nn(e),l=e.length,x=Nn.readOnly),this._firstFragment?(this._firstFragment=!1,f&&a&&a.params[a._isServer?"server_no_context_takeover":"client_no_context_takeover"]&&(f=l>=a._threshold),this._compress=f):(f=!1,c=0),r.fin&&(this._firstFragment=!0);let h={[st]:l,fin:r.fin,generateMask:this._generateMask,mask:r.mask,maskBuffer:this._maskBuffer,opcode:c,readOnly:x,rsv1:f};Ar(e)?this._state!==pt?this.enqueue([this.getBlobData,e,this._compress,h,s]):this.getBlobData(e,this._compress,h,s):this._state!==pt?this.enqueue([this.dispatch,e,this._compress,h,s]):this.dispatch(e,this._compress,h,s)}getBlobData(e,r,s,a){this._bufferedBytes+=s[st],this._state=Yy,e.arrayBuffer().then(c=>{if(this._socket.destroyed){let l=new Error("The socket was closed while the blob was being read");process.nextTick(Fc,this,l,a);return}this._bufferedBytes-=s[st];let f=Nn(c);r?this.dispatch(f,r,s,a):(this._state=pt,this.sendFrame(t.frame(f,s),a),this.dequeue())}).catch(c=>{process.nextTick(Xy,this,c,a)})}dispatch(e,r,s,a){if(!r){this.sendFrame(t.frame(e,s),a);return}let c=this._extensions[Pu.extensionName];this._bufferedBytes+=s[st],this._state=Zy,c.compress(e,s.fin,(f,l)=>{if(this._socket.destroyed){let x=new Error("The socket was closed while data was being compressed");Fc(this,x,a);return}this._bufferedBytes-=s[st],this._state=pt,s.readOnly=!1,this.sendFrame(t.frame(l,s),a),this.dequeue()})}dequeue(){for(;this._state===pt&&this._queue.length;){let e=this._queue.shift();this._bufferedBytes-=e[3][st],Reflect.apply(e[0],this,e.slice(1))}}enqueue(e){this._bufferedBytes+=e[3][st],this._queue.push(e)}sendFrame(e,r){e.length===2?(this._socket.cork(),this._socket.write(e[0]),this._socket.write(e[1],r),this._socket.uncork()):this._socket.write(e[0],r)}};Nu.exports=zc;function Fc(t,e,r){typeof r=="function"&&r(e);for(let s=0;s<t._queue.length;s++){let a=t._queue[s],c=a[a.length-1];typeof c=="function"&&c(e)}}function Xy(t,e,r){Fc(t,e,r),t.onerror(e)}});var Gu=ne((UI,ju)=>{"use strict";var{kForOnEventAttribute:vi,kListener:qc}=Ft(),Mu=Symbol("kCode"),Bu=Symbol("kData"),zu=Symbol("kError"),Fu=Symbol("kMessage"),Uu=Symbol("kReason"),Tr=Symbol("kTarget"),qu=Symbol("kType"),Hu=Symbol("kWasClean"),qt=class{constructor(e){this[Tr]=null,this[qu]=e}get target(){return this[Tr]}get type(){return this[qu]}};Object.defineProperty(qt.prototype,"target",{enumerable:!0});Object.defineProperty(qt.prototype,"type",{enumerable:!0});var Bn=class extends qt{constructor(e,r={}){super(e),this[Mu]=r.code===void 0?0:r.code,this[Uu]=r.reason===void 0?"":r.reason,this[Hu]=r.wasClean===void 0?!1:r.wasClean}get code(){return this[Mu]}get reason(){return this[Uu]}get wasClean(){return this[Hu]}};Object.defineProperty(Bn.prototype,"code",{enumerable:!0});Object.defineProperty(Bn.prototype,"reason",{enumerable:!0});Object.defineProperty(Bn.prototype,"wasClean",{enumerable:!0});var Dr=class extends qt{constructor(e,r={}){super(e),this[zu]=r.error===void 0?null:r.error,this[Fu]=r.message===void 0?"":r.message}get error(){return this[zu]}get message(){return this[Fu]}};Object.defineProperty(Dr.prototype,"error",{enumerable:!0});Object.defineProperty(Dr.prototype,"message",{enumerable:!0});var Ii=class extends qt{constructor(e,r={}){super(e),this[Bu]=r.data===void 0?null:r.data}get data(){return this[Bu]}};Object.defineProperty(Ii.prototype,"data",{enumerable:!0});var Qy={addEventListener(t,e,r={}){for(let a of this.listeners(t))if(!r[vi]&&a[qc]===e&&!a[vi])return;let s;if(t==="message")s=function(c,f){let l=new Ii("message",{data:f?c:c.toString()});l[Tr]=this,xo(e,this,l)};else if(t==="close")s=function(c,f){let l=new Bn("close",{code:c,reason:f.toString(),wasClean:this._closeFrameReceived&&this._closeFrameSent});l[Tr]=this,xo(e,this,l)};else if(t==="error")s=function(c){let f=new Dr("error",{error:c,message:c.message});f[Tr]=this,xo(e,this,f)};else if(t==="open")s=function(){let c=new qt("open");c[Tr]=this,xo(e,this,c)};else return;s[vi]=!!r[vi],s[qc]=e,r.once?this.once(t,s):this.on(t,s)},removeEventListener(t,e){for(let r of this.listeners(t))if(r[qc]===e&&!r[vi]){this.removeListener(t,r);break}}};ju.exports={CloseEvent:Bn,ErrorEvent:Dr,Event:qt,EventTarget:Qy,MessageEvent:Ii};function xo(t,e,r){typeof t=="object"&&t.handleEvent?t.handleEvent.call(t,r):t.call(e,r)}});var ho=ne((qI,Ku)=>{"use strict";var{tokenChars:Ai}=Ir();function Rt(t,e,r){t[e]===void 0?t[e]=[r]:t[e].push(r)}function eE(t){let e=Object.create(null),r=Object.create(null),s=!1,a=!1,c=!1,f,l,x=-1,h=-1,m=-1,E=0;for(;E<t.length;E++)if(h=t.charCodeAt(E),f===void 0)if(m===-1&&Ai[h]===1)x===-1&&(x=E);else if(E!==0&&(h===32||h===9))m===-1&&x!==-1&&(m=E);else if(h===59||h===44){if(x===-1)throw new SyntaxError(`Unexpected character at index ${E}`);m===-1&&(m=E);let _=t.slice(x,m);h===44?(Rt(e,_,r),r=Object.create(null)):f=_,x=m=-1}else throw new SyntaxError(`Unexpected character at index ${E}`);else if(l===void 0)if(m===-1&&Ai[h]===1)x===-1&&(x=E);else if(h===32||h===9)m===-1&&x!==-1&&(m=E);else if(h===59||h===44){if(x===-1)throw new SyntaxError(`Unexpected character at index ${E}`);m===-1&&(m=E),Rt(r,t.slice(x,m),!0),h===44&&(Rt(e,f,r),r=Object.create(null),f=void 0),x=m=-1}else if(h===61&&x!==-1&&m===-1)l=t.slice(x,E),x=m=-1;else throw new SyntaxError(`Unexpected character at index ${E}`);else if(a){if(Ai[h]!==1)throw new SyntaxError(`Unexpected character at index ${E}`);x===-1?x=E:s||(s=!0),a=!1}else if(c)if(Ai[h]===1)x===-1&&(x=E);else if(h===34&&x!==-1)c=!1,m=E;else if(h===92)a=!0;else throw new SyntaxError(`Unexpected character at index ${E}`);else if(h===34&&t.charCodeAt(E-1)===61)c=!0;else if(m===-1&&Ai[h]===1)x===-1&&(x=E);else if(x!==-1&&(h===32||h===9))m===-1&&(m=E);else if(h===59||h===44){if(x===-1)throw new SyntaxError(`Unexpected character at index ${E}`);m===-1&&(m=E);let _=t.slice(x,m);s&&(_=_.replace(/\\/g,""),s=!1),Rt(r,l,_),h===44&&(Rt(e,f,r),r=Object.create(null),f=void 0),l=void 0,x=m=-1}else throw new SyntaxError(`Unexpected character at index ${E}`);if(x===-1||c||h===32||h===9)throw new SyntaxError("Unexpected end of input");m===-1&&(m=E);let C=t.slice(x,m);return f===void 0?Rt(e,C,r):(l===void 0?Rt(r,C,!0):s?Rt(r,l,C.replace(/\\/g,"")):Rt(r,l,C),Rt(e,f,r)),e}function tE(t){return Object.keys(t).map(e=>{let r=t[e];return Array.isArray(r)||(r=[r]),r.map(s=>[e].concat(Object.keys(s).map(a=>{let c=s[a];return Array.isArray(c)||(c=[c]),c.map(f=>f===!0?a:`${a}=${f}`).join("; ")})).join("; ")).join(", ")}).join(", ")}Ku.exports={format:tE,parse:eE}});var wo=ne((GI,rx)=>{"use strict";var nE=ae("events"),rE=ae("https"),iE=ae("http"),Vu=ae("net"),sE=ae("tls"),{randomBytes:oE,createHash:aE}=ae("crypto"),{Duplex:HI,Readable:jI}=ae("stream"),{URL:Hc}=ae("url"),wn=vr(),cE=Bc(),dE=Uc(),{isBlob:fE}=Ir(),{BINARY_TYPES:Wu,CLOSE_TIMEOUT:lE,EMPTY_BUFFER:po,GUID:uE,kForOnEventAttribute:jc,kListener:xE,kStatusCode:hE,kWebSocket:Pe,NOOP:Ju}=Ft(),{EventTarget:{addEventListener:pE,removeEventListener:gE}}=Gu(),{format:mE,parse:wE}=ho(),{toBuffer:_E}=bi(),Zu=Symbol("kAborted"),Gc=[8,13],Ht=["CONNECTING","OPEN","CLOSING","CLOSED"],yE=/^[!#$%&'*+\-.0-9A-Z^_`|a-z~]+$/,de=class t extends nE{constructor(e,r,s){super(),this._binaryType=Wu[0],this._closeCode=1006,this._closeFrameReceived=!1,this._closeFrameSent=!1,this._closeMessage=po,this._closeTimer=null,this._errorEmitted=!1,this._extensions={},this._paused=!1,this._protocol="",this._readyState=t.CONNECTING,this._receiver=null,this._sender=null,this._socket=null,e!==null?(this._bufferedAmount=0,this._isServer=!1,this._redirects=0,r===void 0?r=[]:Array.isArray(r)||(typeof r=="object"&&r!==null?(s=r,r=[]):r=[r]),Yu(this,e,r,s)):(this._autoPong=s.autoPong,this._closeTimeout=s.closeTimeout,this._isServer=!0)}get binaryType(){return this._binaryType}set binaryType(e){Wu.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,r,s){let a=new cE({allowSynchronousEvents:s.allowSynchronousEvents,binaryType:this.binaryType,extensions:this._extensions,isServer:this._isServer,maxPayload:s.maxPayload,skipUTF8Validation:s.skipUTF8Validation}),c=new dE(e,this._extensions,s.generateMask);this._receiver=a,this._sender=c,this._socket=e,a[Pe]=this,c[Pe]=this,e[Pe]=this,a.on("conclude",SE),a.on("drain",vE),a.on("error",IE),a.on("message",AE),a.on("ping",CE),a.on("pong",TE),c.onerror=DE,e.setTimeout&&e.setTimeout(0),e.setNoDelay&&e.setNoDelay(),r.length>0&&e.unshift(r),e.on("close",ex),e.on("data",mo),e.on("end",tx),e.on("error",nx),this._readyState=t.OPEN,this.emit("open")}emitClose(){if(!this._socket){this._readyState=t.CLOSED,this.emit("close",this._closeCode,this._closeMessage);return}this._extensions[wn.extensionName]&&this._extensions[wn.extensionName].cleanup(),this._receiver.removeAllListeners(),this._readyState=t.CLOSED,this.emit("close",this._closeCode,this._closeMessage)}close(e,r){if(this.readyState!==t.CLOSED){if(this.readyState===t.CONNECTING){Qe(this,this._req,"WebSocket was closed before the connection was established");return}if(this.readyState===t.CLOSING){this._closeFrameSent&&(this._closeFrameReceived||this._receiver._writableState.errorEmitted)&&this._socket.end();return}this._readyState=t.CLOSING,this._sender.close(e,r,!this._isServer,s=>{s||(this._closeFrameSent=!0,(this._closeFrameReceived||this._receiver._writableState.errorEmitted)&&this._socket.end())}),Qu(this)}}pause(){this.readyState===t.CONNECTING||this.readyState===t.CLOSED||(this._paused=!0,this._socket.pause())}ping(e,r,s){if(this.readyState===t.CONNECTING)throw new Error("WebSocket is not open: readyState 0 (CONNECTING)");if(typeof e=="function"?(s=e,e=r=void 0):typeof r=="function"&&(s=r,r=void 0),typeof e=="number"&&(e=e.toString()),this.readyState!==t.OPEN){Kc(this,e,s);return}r===void 0&&(r=!this._isServer),this._sender.ping(e||po,r,s)}pong(e,r,s){if(this.readyState===t.CONNECTING)throw new Error("WebSocket is not open: readyState 0 (CONNECTING)");if(typeof e=="function"?(s=e,e=r=void 0):typeof r=="function"&&(s=r,r=void 0),typeof e=="number"&&(e=e.toString()),this.readyState!==t.OPEN){Kc(this,e,s);return}r===void 0&&(r=!this._isServer),this._sender.pong(e||po,r,s)}resume(){this.readyState===t.CONNECTING||this.readyState===t.CLOSED||(this._paused=!1,this._receiver._writableState.needDrain||this._socket.resume())}send(e,r,s){if(this.readyState===t.CONNECTING)throw new Error("WebSocket is not open: readyState 0 (CONNECTING)");if(typeof r=="function"&&(s=r,r={}),typeof e=="number"&&(e=e.toString()),this.readyState!==t.OPEN){Kc(this,e,s);return}let a={binary:typeof e!="string",mask:!this._isServer,compress:!0,fin:!0,...r};this._extensions[wn.extensionName]||(a.compress=!1),this._sender.send(e||po,a,s)}terminate(){if(this.readyState!==t.CLOSED){if(this.readyState===t.CONNECTING){Qe(this,this._req,"WebSocket was closed before the connection was established");return}this._socket&&(this._readyState=t.CLOSING,this._socket.destroy())}}};Object.defineProperty(de,"CONNECTING",{enumerable:!0,value:Ht.indexOf("CONNECTING")});Object.defineProperty(de.prototype,"CONNECTING",{enumerable:!0,value:Ht.indexOf("CONNECTING")});Object.defineProperty(de,"OPEN",{enumerable:!0,value:Ht.indexOf("OPEN")});Object.defineProperty(de.prototype,"OPEN",{enumerable:!0,value:Ht.indexOf("OPEN")});Object.defineProperty(de,"CLOSING",{enumerable:!0,value:Ht.indexOf("CLOSING")});Object.defineProperty(de.prototype,"CLOSING",{enumerable:!0,value:Ht.indexOf("CLOSING")});Object.defineProperty(de,"CLOSED",{enumerable:!0,value:Ht.indexOf("CLOSED")});Object.defineProperty(de.prototype,"CLOSED",{enumerable:!0,value:Ht.indexOf("CLOSED")});["binaryType","bufferedAmount","extensions","isPaused","protocol","readyState","url"].forEach(t=>{Object.defineProperty(de.prototype,t,{enumerable:!0})});["open","error","close","message"].forEach(t=>{Object.defineProperty(de.prototype,`on${t}`,{enumerable:!0,get(){for(let e of this.listeners(t))if(e[jc])return e[xE];return null},set(e){for(let r of this.listeners(t))if(r[jc]){this.removeListener(t,r);break}typeof e=="function"&&this.addEventListener(t,e,{[jc]:!0})}})});de.prototype.addEventListener=pE;de.prototype.removeEventListener=gE;rx.exports=de;function Yu(t,e,r,s){let a={allowSynchronousEvents:!0,autoPong:!0,closeTimeout:lE,protocolVersion:Gc[1],maxPayload:104857600,skipUTF8Validation:!1,perMessageDeflate:!0,followRedirects:!1,maxRedirects:10,...s,socketPath:void 0,hostname:void 0,protocol:void 0,timeout:void 0,method:"GET",host:void 0,path:void 0,port:void 0};if(t._autoPong=a.autoPong,t._closeTimeout=a.closeTimeout,!Gc.includes(a.protocolVersion))throw new RangeError(`Unsupported protocol version: ${a.protocolVersion} (supported versions: ${Gc.join(", ")})`);let c;if(e instanceof Hc)c=e;else try{c=new Hc(e)}catch{throw new SyntaxError(`Invalid URL: ${e}`)}c.protocol==="http:"?c.protocol="ws:":c.protocol==="https:"&&(c.protocol="wss:"),t._url=c.href;let f=c.protocol==="wss:",l=c.protocol==="ws+unix:",x;if(c.protocol!=="ws:"&&!f&&!l?x=`The URL's protocol must be one of "ws:", "wss:", "http:", "https:", or "ws+unix:"`:l&&!c.pathname?x="The URL's pathname is empty":c.hash&&(x="The URL contains a fragment identifier"),x){let v=new SyntaxError(x);if(t._redirects===0)throw v;go(t,v);return}let h=f?443:80,m=oE(16).toString("base64"),E=f?rE.request:iE.request,C=new Set,_;if(a.createConnection=a.createConnection||(f?bE:EE),a.defaultPort=a.defaultPort||h,a.port=c.port||h,a.host=c.hostname.startsWith("[")?c.hostname.slice(1,-1):c.hostname,a.headers={...a.headers,"Sec-WebSocket-Version":a.protocolVersion,"Sec-WebSocket-Key":m,Connection:"Upgrade",Upgrade:"websocket"},a.path=c.pathname+c.search,a.timeout=a.handshakeTimeout,a.perMessageDeflate&&(_=new wn({...a.perMessageDeflate,isServer:!1,maxPayload:a.maxPayload}),a.headers["Sec-WebSocket-Extensions"]=mE({[wn.extensionName]:_.offer()})),r.length){for(let v of r){if(typeof v!="string"||!yE.test(v)||C.has(v))throw new SyntaxError("An invalid or duplicated subprotocol was specified");C.add(v)}a.headers["Sec-WebSocket-Protocol"]=r.join(",")}if(a.origin&&(a.protocolVersion<13?a.headers["Sec-WebSocket-Origin"]=a.origin:a.headers.Origin=a.origin),(c.username||c.password)&&(a.auth=`${c.username}:${c.password}`),l){let v=a.path.split(":");a.socketPath=v[0],a.path=v[1]}let y;if(a.followRedirects){if(t._redirects===0){t._originalIpc=l,t._originalSecure=f,t._originalHostOrSocketPath=l?a.socketPath:c.host;let v=s&&s.headers;if(s={...s,headers:{}},v)for(let[I,R]of Object.entries(v))s.headers[I.toLowerCase()]=R}else if(t.listenerCount("redirect")===0){let v=l?t._originalIpc?a.socketPath===t._originalHostOrSocketPath:!1:t._originalIpc?!1:c.host===t._originalHostOrSocketPath;(!v||t._originalSecure&&!f)&&(delete a.headers.authorization,delete a.headers.cookie,v||delete a.headers.host,a.auth=void 0)}a.auth&&!s.headers.authorization&&(s.headers.authorization="Basic "+Buffer.from(a.auth).toString("base64")),y=t._req=E(a),t._redirects&&t.emit("redirect",t.url,y)}else y=t._req=E(a);a.timeout&&y.on("timeout",()=>{Qe(t,y,"Opening handshake has timed out")}),y.on("error",v=>{y===null||y[Zu]||(y=t._req=null,go(t,v))}),y.on("response",v=>{let I=v.headers.location,R=v.statusCode;if(I&&a.followRedirects&&R>=300&&R<400){if(++t._redirects>a.maxRedirects){Qe(t,y,"Maximum redirects exceeded");return}y.abort();let L;try{L=new Hc(I,e)}catch{let A=new SyntaxError(`Invalid URL: ${I}`);go(t,A);return}Yu(t,L,r,s)}else t.emit("unexpected-response",y,v)||Qe(t,y,`Unexpected server response: ${v.statusCode}`)}),y.on("upgrade",(v,I,R)=>{if(t.emit("upgrade",v),t.readyState!==de.CONNECTING)return;y=t._req=null;let L=v.headers.upgrade;if(L===void 0||L.toLowerCase()!=="websocket"){Qe(t,I,"Invalid Upgrade header");return}let w=aE("sha1").update(m+uE).digest("base64");if(v.headers["sec-websocket-accept"]!==w){Qe(t,I,"Invalid Sec-WebSocket-Accept header");return}let A=v.headers["sec-websocket-protocol"],k;if(A!==void 0?C.size?C.has(A)||(k="Server sent an invalid subprotocol"):k="Server sent a subprotocol but none was requested":C.size&&(k="Server sent no subprotocol"),k){Qe(t,I,k);return}A&&(t._protocol=A);let F=v.headers["sec-websocket-extensions"];if(F!==void 0){if(!_){Qe(t,I,"Server sent a Sec-WebSocket-Extensions header but no extension was requested");return}let z;try{z=wE(F)}catch{Qe(t,I,"Invalid Sec-WebSocket-Extensions header");return}let O=Object.keys(z);if(O.length!==1||O[0]!==wn.extensionName){Qe(t,I,"Server indicated an extension that was not requested");return}try{_.accept(z[wn.extensionName])}catch{Qe(t,I,"Invalid Sec-WebSocket-Extensions header");return}t._extensions[wn.extensionName]=_}t.setSocket(I,R,{allowSynchronousEvents:a.allowSynchronousEvents,generateMask:a.generateMask,maxPayload:a.maxPayload,skipUTF8Validation:a.skipUTF8Validation})}),a.finishRequest?a.finishRequest(y,t):y.end()}function go(t,e){t._readyState=de.CLOSING,t._errorEmitted=!0,t.emit("error",e),t.emitClose()}function EE(t){return t.path=t.socketPath,Vu.connect(t)}function bE(t){return t.path=void 0,!t.servername&&t.servername!==""&&(t.servername=Vu.isIP(t.host)?"":t.host),sE.connect(t)}function Qe(t,e,r){t._readyState=de.CLOSING;let s=new Error(r);Error.captureStackTrace(s,Qe),e.setHeader?(e[Zu]=!0,e.abort(),e.socket&&!e.socket.destroyed&&e.socket.destroy(),process.nextTick(go,t,s)):(e.destroy(s),e.once("error",t.emit.bind(t,"error")),e.once("close",t.emitClose.bind(t)))}function Kc(t,e,r){if(e){let s=fE(e)?e.size:_E(e).length;t._socket?t._sender._bufferedBytes+=s:t._bufferedAmount+=s}if(r){let s=new Error(`WebSocket is not open: readyState ${t.readyState} (${Ht[t.readyState]})`);process.nextTick(r,s)}}function SE(t,e){let r=this[Pe];r._closeFrameReceived=!0,r._closeMessage=e,r._closeCode=t,r._socket[Pe]!==void 0&&(r._socket.removeListener("data",mo),process.nextTick(Xu,r._socket),t===1005?r.close():r.close(t,e))}function vE(){let t=this[Pe];t.isPaused||t._socket.resume()}function IE(t){let e=this[Pe];e._socket[Pe]!==void 0&&(e._socket.removeListener("data",mo),process.nextTick(Xu,e._socket),e.close(t[hE])),e._errorEmitted||(e._errorEmitted=!0,e.emit("error",t))}function $u(){this[Pe].emitClose()}function AE(t,e){this[Pe].emit("message",t,e)}function CE(t){let e=this[Pe];e._autoPong&&e.pong(t,!this._isServer,Ju),e.emit("ping",t)}function TE(t){this[Pe].emit("pong",t)}function Xu(t){t.resume()}function DE(t){let e=this[Pe];e.readyState!==de.CLOSED&&(e.readyState===de.OPEN&&(e._readyState=de.CLOSING,Qu(e)),this._socket.end(),e._errorEmitted||(e._errorEmitted=!0,e.emit("error",t)))}function Qu(t){t._closeTimer=setTimeout(t._socket.destroy.bind(t._socket),t._closeTimeout)}function ex(){let t=this[Pe];if(this.removeListener("close",ex),this.removeListener("data",mo),this.removeListener("end",tx),t._readyState=de.CLOSING,!this._readableState.endEmitted&&!t._closeFrameReceived&&!t._receiver._writableState.errorEmitted&&this._readableState.length!==0){let e=this.read(this._readableState.length);t._receiver.write(e)}t._receiver.end(),this[Pe]=void 0,clearTimeout(t._closeTimer),t._receiver._writableState.finished||t._receiver._writableState.errorEmitted?t.emitClose():(t._receiver.on("error",$u),t._receiver.on("finish",$u))}function mo(t){this[Pe]._receiver.write(t)||this.pause()}function tx(){let t=this[Pe];t._readyState=de.CLOSING,t._receiver.end(),this.end()}function nx(){let t=this[Pe];this.removeListener("error",nx),this.on("error",Ju),t&&(t._readyState=de.CLOSING,this.destroy())}});var ax=ne((WI,ox)=>{"use strict";var KI=wo(),{Duplex:RE}=ae("stream");function ix(t){t.emit("close")}function kE(){!this.destroyed&&this._writableState.finished&&this.destroy()}function sx(t){this.removeListener("error",sx),this.destroy(),this.listenerCount("error")===0&&this.emit("error",t)}function OE(t,e){let r=!0,s=new RE({...e,autoDestroy:!1,emitClose:!1,objectMode:!1,writableObjectMode:!1});return t.on("message",function(c,f){let l=!f&&s._readableState.objectMode?c.toString():c;s.push(l)||t.pause()}),t.once("error",function(c){s.destroyed||(r=!1,s.destroy(c))}),t.once("close",function(){s.destroyed||s.push(null)}),s._destroy=function(a,c){if(t.readyState===t.CLOSED){c(a),process.nextTick(ix,s);return}let f=!1;t.once("error",function(x){f=!0,c(x)}),t.once("close",function(){f||c(a),process.nextTick(ix,s)}),r&&t.terminate()},s._final=function(a){if(t.readyState===t.CONNECTING){t.once("open",function(){s._final(a)});return}t._socket!==null&&(t._socket._writableState.finished?(a(),s._readableState.endEmitted&&s.destroy()):(t._socket.once("finish",function(){a()}),t.close()))},s._read=function(){t.isPaused&&t.resume()},s._write=function(a,c,f){if(t.readyState===t.CONNECTING){t.once("open",function(){s._write(a,c,f)});return}t.send(a,f)},s.on("end",kE),s.on("error",sx),s}ox.exports=OE});var Wc=ne(($I,cx)=>{"use strict";var{tokenChars:PE}=Ir();function LE(t){let e=new Set,r=-1,s=-1,a=0;for(a;a<t.length;a++){let f=t.charCodeAt(a);if(s===-1&&PE[f]===1)r===-1&&(r=a);else if(a!==0&&(f===32||f===9))s===-1&&r!==-1&&(s=a);else if(f===44){if(r===-1)throw new SyntaxError(`Unexpected character at index ${a}`);s===-1&&(s=a);let l=t.slice(r,s);if(e.has(l))throw new SyntaxError(`The "${l}" subprotocol is duplicated`);e.add(l),r=s=-1}else throw new SyntaxError(`Unexpected character at index ${a}`)}if(r===-1||s!==-1)throw new SyntaxError("Unexpected end of input");let c=t.slice(r,a);if(e.has(c))throw new SyntaxError(`The "${c}" subprotocol is duplicated`);return e.add(c),e}cx.exports={parse:LE}});var px=ne((JI,hx)=>{"use strict";var NE=ae("events"),_o=ae("http"),{Duplex:VI}=ae("stream"),{createHash:ME}=ae("crypto"),dx=ho(),zn=vr(),BE=Wc(),zE=wo(),{CLOSE_TIMEOUT:FE,GUID:UE,kWebSocket:qE}=Ft(),HE=/^[+/0-9A-Za-z]{22}==$/,fx=0,lx=1,xx=2,$c=class extends NE{constructor(e,r){if(super(),e={allowSynchronousEvents:!0,autoPong:!0,maxPayload:100*1024*1024,skipUTF8Validation:!1,perMessageDeflate:!1,handleProtocols:null,clientTracking:!0,closeTimeout:FE,verifyClient:null,noServer:!1,backlog:null,server:null,host:null,path:null,port:null,WebSocket:zE,...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=_o.createServer((s,a)=>{let c=_o.STATUS_CODES[426];a.writeHead(426,{"Content-Length":c.length,"Content-Type":"text/plain"}),a.end(c)}),this._server.listen(e.port,e.host,e.backlog,r)):e.server&&(this._server=e.server),this._server){let s=this.emit.bind(this,"connection");this._removeListeners=jE(this._server,{listening:this.emit.bind(this,"listening"),error:this.emit.bind(this,"error"),upgrade:(a,c,f)=>{this.handleUpgrade(a,c,f,s)}})}e.perMessageDeflate===!0&&(e.perMessageDeflate={}),e.clientTracking&&(this.clients=new Set,this._shouldEmitClose=!1),this.options=e,this._state=fx}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===xx){e&&this.once("close",()=>{e(new Error("The server is not running"))}),process.nextTick(Ci,this);return}if(e&&this.once("close",e),this._state!==lx)if(this._state=lx,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(Ci,this):process.nextTick(Ci,this);else{let r=this._server;this._removeListeners(),this._removeListeners=this._server=null,r.close(()=>{Ci(this)})}}shouldHandle(e){if(this.options.path){let r=e.url.indexOf("?");if((r!==-1?e.url.slice(0,r):e.url)!==this.options.path)return!1}return!0}handleUpgrade(e,r,s,a){r.on("error",ux);let c=e.headers["sec-websocket-key"],f=e.headers.upgrade,l=+e.headers["sec-websocket-version"];if(e.method!=="GET"){Fn(this,e,r,405,"Invalid HTTP method");return}if(f===void 0||f.toLowerCase()!=="websocket"){Fn(this,e,r,400,"Invalid Upgrade header");return}if(c===void 0||!HE.test(c)){Fn(this,e,r,400,"Missing or invalid Sec-WebSocket-Key header");return}if(l!==13&&l!==8){Fn(this,e,r,400,"Missing or invalid Sec-WebSocket-Version header",{"Sec-WebSocket-Version":"13, 8"});return}if(!this.shouldHandle(e)){Ti(r,400);return}let x=e.headers["sec-websocket-protocol"],h=new Set;if(x!==void 0)try{h=BE.parse(x)}catch{Fn(this,e,r,400,"Invalid Sec-WebSocket-Protocol header");return}let m=e.headers["sec-websocket-extensions"],E={};if(this.options.perMessageDeflate&&m!==void 0){let C=new zn({...this.options.perMessageDeflate,isServer:!0,maxPayload:this.options.maxPayload});try{let _=dx.parse(m);_[zn.extensionName]&&(C.accept(_[zn.extensionName]),E[zn.extensionName]=C)}catch{Fn(this,e,r,400,"Invalid or unacceptable Sec-WebSocket-Extensions header");return}}if(this.options.verifyClient){let C={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(C,(_,y,v,I)=>{if(!_)return Ti(r,y||401,v,I);this.completeUpgrade(E,c,h,e,r,s,a)});return}if(!this.options.verifyClient(C))return Ti(r,401)}this.completeUpgrade(E,c,h,e,r,s,a)}completeUpgrade(e,r,s,a,c,f,l){if(!c.readable||!c.writable)return c.destroy();if(c[qE])throw new Error("server.handleUpgrade() was called more than once with the same socket, possibly due to a misconfiguration");if(this._state>fx)return Ti(c,503);let h=["HTTP/1.1 101 Switching Protocols","Upgrade: websocket","Connection: Upgrade",`Sec-WebSocket-Accept: ${ME("sha1").update(r+UE).digest("base64")}`],m=new this.options.WebSocket(null,void 0,this.options);if(s.size){let E=this.options.handleProtocols?this.options.handleProtocols(s,a):s.values().next().value;E&&(h.push(`Sec-WebSocket-Protocol: ${E}`),m._protocol=E)}if(e[zn.extensionName]){let E=e[zn.extensionName].params,C=dx.format({[zn.extensionName]:[E]});h.push(`Sec-WebSocket-Extensions: ${C}`),m._extensions=e}this.emit("headers",h,a),c.write(h.concat(`\r
8
+ var Hh=Object.create;var jo=Object.defineProperty;var Gh=Object.getOwnPropertyDescriptor;var jh=Object.getOwnPropertyNames;var Kh=Object.getPrototypeOf,Wh=Object.prototype.hasOwnProperty;var ae=(t=>typeof require<"u"?require:typeof Proxy<"u"?new Proxy(t,{get:(e,r)=>(typeof require<"u"?require:e)[r]}):t)(function(t){if(typeof require<"u")return require.apply(this,arguments);throw Error('Dynamic require of "'+t+'" is not supported')});var nt=(t,e)=>()=>(t&&(e=t(t=0)),e);var ne=(t,e)=>()=>(e||t((e={exports:{}}).exports,e),e.exports),Ko=(t,e)=>{for(var r in e)jo(t,r,{get:e[r],enumerable:!0})},Vh=(t,e,r,i)=>{if(e&&typeof e=="object"||typeof e=="function")for(let o of jh(e))!Wh.call(t,o)&&o!==r&&jo(t,o,{get:()=>e[o],enumerable:!(i=Gh(e,o))||i.enumerable});return t};var pt=(t,e,r)=>(r=t!=null?Hh(Kh(t)):{},Vh(e||!t||!t.__esModule?jo(r,"default",{value:t,enumerable:!0}):r,t));function D0(t){Wo=t}function k0(t){return Pi[Wo]<=Pi[t]}function Oi(t){R0={...t}}function Yh(t){let e=(l,x=2)=>String(l).padStart(x,"0"),r=-t.getTimezoneOffset(),i=r>=0?"+":"-",o=Math.abs(r),c=e(Math.floor(o/60)),f=e(o%60);return`${t.getFullYear()}-${e(t.getMonth()+1)}-${e(t.getDate())}T${e(t.getHours())}:${e(t.getMinutes())}:${e(t.getSeconds())}.${e(t.getMilliseconds(),3)}${i}${c}:${f}`}function Li(t,e,r,i){if(Pi[t]<Pi[Wo])return;let o=JSON.stringify({ts:Yh(new Date),level:t,module:e,msg:r,...R0,...i});t==="error"||t==="warn"?Jh.write(`${o}
9
+ `):$h.write(`${o}
10
+ `)}function G(t){return{debug:(e,r)=>Li("debug",t,e,r),info:(e,r)=>Li("info",t,e,r),warn:(e,r)=>Li("warn",t,e,r),error:(e,r)=>Li("error",t,e,r),child:e=>G(`${t}.${e}`)}}var Pi,Wo,$h,Jh,R0,ee=nt(()=>{"use strict";Pi={debug:10,info:20,warn:30,error:40},Wo=(()=>{let t=process.env.COZE_BRIDGE_LOG_LEVEL;return t==="debug"||t==="info"||t==="warn"||t==="error"?t:"info"})(),$h=process.stdout,Jh=process.stderr,R0={}});import{execFile as Zh,spawn as Xh,spawnSync as iE}from"node:child_process";import{promisify as Qh}from"node:util";function tp(t){if(process.platform!=="win32")return!1;if(L0.test(t))return!0;let r=(t.split(/[/\\]/).pop()??t).replace(L0,"").toLowerCase();return ep.has(r)}function P0(t,e){if(process.platform!=="win32")return e??{};let r={...e??{}};return tp(t)&&r.shell===void 0&&(r.shell=!0),r.windowsHide===void 0&&(r.windowsHide=!0),r}function Vt(t,e=[],r={}){return Xh(t,e,P0(t,r))}function Ni(t,e=[],r={}){return np(t,e,P0(t,r))}var ep,L0,np,Hn=nt(()=>{"use strict";ep=new Set(["npm","npx","yarn","pnpm","coze","tsx","claude-agent-acp","codex-acp"]),L0=/\.(cmd|bat|ps1)$/i;np=Qh(Zh)});var D,He=nt(()=>{"use strict";D=class extends Error{code;retriable;cause;constructor(e,r,i){super(r),this.name="BridgeError",this.code=e,this.retriable=i?.retriable??!1,i?.cause!==void 0&&(this.cause=i.cause)}}});var F0={};Ko(F0,{_resetAcpInstallerForTests:()=>lp,_resetInstallTimeoutsForTests:()=>fp,_setBinaryPathCacheForTests:()=>hp,_setInFlightForTests:()=>xp,_setInstallTimeoutsForTests:()=>dp,buildInstallFailureMessage:()=>z0,ensureAcpInstalled:()=>Kn,formatExecError:()=>M0,getAcpBinaryPath:()=>kr,getAcpPackageSpec:()=>ap,getInFlightInstall:()=>Jo,npmInstallGlobal:()=>B0,pickWhichLine:()=>zi,probeAcpVersion:()=>up,resolveAcpCommand:()=>Lr});import{readFile as rp,realpath as ip,stat as sp}from"node:fs/promises";import{dirname as Vo,join as op}from"node:path";function ap(t){let e=$o[t];if(e)return`${e.npmPackage}@${e.versionSpec}`}function dp(t,e){Mi=t,Bi=e}function fp(){Mi=5e4,Bi=5e3}function M0(t){if(t==null||typeof t!="object")return String(t);let e=t,r=[];e.message&&r.push(e.message),e.code!==void 0&&e.code!==null&&r.push(`code=${e.code}`),e.signal&&r.push(`signal=${e.signal}`);let i=e.stderr?.toString().trim();i&&r.push(`stderr=${i.slice(0,2e3)}`);let o=e.stdout?.toString().trim();return o&&r.push(`stdout=${o.slice(0,2e3)}`),r.length>0?r.join(" | "):String(t)}async function O0(t){let e=process.platform==="win32"?"where":"which";try{let{stdout:r}=await Ni(e,[t],{timeout:cp});return zi(r)}catch{return}}function zi(t){let e=t.split(/\r?\n/).map(i=>i.trim()).filter(Boolean);if(e.length===0)return;if(process.platform!=="win32")return e[0];let r=i=>e.find(o=>o.toLowerCase().endsWith(i));return r(".cmd")??r(".exe")??r(".bat")??r(".ps1")??e[0]}async function up(t){let e=$o[t];if(!e)return;let r=kr(t);if(!r){Fe.warn("acp wrapper probe: binary path cache empty",{framework:t,binary:e.binary,hint:"ensureAcpInstalled \u6CA1\u8DD1\u8FC7 / \u88C5\u5931\u8D25 / \u4E4B\u524D negative cache 5min \u5185"});return}let i;try{i=await ip(r)}catch(c){Fe.warn("acp wrapper probe: realpath failed (symlink target \u4E0D\u5B58\u5728?)",{framework:t,binaryPath:r,err:String(c)});return}let o=Vo(i);for(let c=0;c<N0;c++){let f=op(o,"package.json");try{if(!(await sp(f)).isFile()){o=Vo(o);continue}let p=await rp(f,"utf8"),w=JSON.parse(p);if(w.name===e.npmPackage){if(typeof w.version=="string"&&w.version.length>0)return w.version;Fe.warn("acp wrapper probe: package.json \u627E\u5230\u4F46 version \u5B57\u6BB5\u7F3A",{framework:t,packageJsonPath:f});return}}catch(x){let p=x;p.code!=="ENOENT"&&Fe.warn("acp wrapper probe: package.json \u8BFB\u53D6\u5F02\u5E38",{framework:t,candidate:f,errCode:p?.code,err:String(x)})}let l=Vo(o);if(l===o)break;o=l}Fe.warn("acp wrapper probe: \u627E\u4E0D\u5230\u5339\u914D name \u7684 package.json (\u4E0A\u6EAF\u5230 max depth)",{framework:t,binaryPath:r,realBinary:i,expectedName:e.npmPackage,maxDepth:N0})}async function B0(t,e,r){let i=`${t}@${e}`;Fe.info("npm install -g start",{npmPackage:t,versionSpec:e});let o=Date.now(),c=process.platform==="win32";return new Promise((f,l)=>{let x=Vt("npm",["install","-g",i],{stdio:["ignore","pipe","pipe"],...c?{}:{detached:!0}});if(!x.pid){l(new Error(`failed to spawn npm: no pid (npmPackage=${t})`));return}let p=x.pid,w=10*1024*1024,b=[],T=[],E=0,v=0;x.stdout?.on("data",C=>{E+=C.length,E<w&&b.push(C)}),x.stderr?.on("data",C=>{v+=C.length,v<w&&T.push(C)});let I="running",A,k=C=>{try{return c?x.kill(C):process.kill(-p,C),!0}catch(L){return Fe.warn("npm install: kill failed (process already dead?)",{npmPackage:t,pid:p,sig:C,err:String(L)}),!1}},O=setTimeout(()=>{I="terminating",Fe.warn("npm install timeout, sending SIGTERM to process group",{npmPackage:t,versionSpec:e,pid:p,elapsedMs:Date.now()-o,timeoutMs:Mi,graceMs:Bi,stdoutBytes:E,stderrBytes:v}),k("SIGTERM"),A=setTimeout(()=>{I="killing",Fe.warn("npm install SIGTERM grace expired, escalating to SIGKILL",{npmPackage:t,versionSpec:e,pid:p,elapsedMs:Date.now()-o,stdoutBytes:E,stderrBytes:v}),k("SIGKILL")},Bi)},Mi),y=()=>{I="aborted",Fe.warn("npm install externally aborted, sending SIGKILL to process group",{npmPackage:t,versionSpec:e,pid:p,elapsedMs:Date.now()-o}),k("SIGKILL")};r&&(r.aborted?y():r.addEventListener("abort",y,{once:!0})),x.on("error",C=>{clearTimeout(O),A&&clearTimeout(A),r?.removeEventListener("abort",y),Fe.warn("npm install spawn error",{npmPackage:t,versionSpec:e,pid:p,err:String(C)}),l(new Error(`spawn npm failed: ${String(C)}`))}),x.on("close",(C,L)=>{clearTimeout(O),A&&clearTimeout(A),r?.removeEventListener("abort",y);let F=Buffer.concat(b).toString("utf8"),z=Buffer.concat(T).toString("utf8"),P=Date.now()-o;if(C===0&&I==="running"){Fe.info("npm install -g done",{npmPackage:t,versionSpec:e,elapsedMs:P}),f();return}Fe.warn("npm install -g exited non-success",{npmPackage:t,versionSpec:e,pid:p,phase:I,exitCode:C,signal:L,elapsedMs:P,stdoutBytes:E,stderrBytes:v});let N=Object.assign(new Error(`Command failed: npm install -g ${i}`+(L?` (killed by ${L})`:"")+(C!==null?` (exit ${C})`:"")+(I!=="running"?` (phase=${I})`:"")),{code:C,signal:L,stderr:z,stdout:F});l(N)})})}function z0(t){let{framework:e,npmPackage:r,versionSpec:i,command:o,reason:c,elapsedMs:f}=t;return["ACP wrapper \u5B89\u88C5\u5931\u8D25",`Framework: ${e}`,`Package: ${r}@${i}`,`\u6267\u884C\u547D\u4EE4: ${o}`,`\u5931\u8D25\u539F\u56E0: ${c}`,`\u8017\u65F6: ${f}ms`,"","\u6392\u67E5\u5EFA\u8BAE:"," 1. \u68C0\u67E5\u7F51\u7EDC: curl -v https://registry.npmjs.org"," 2. \u67E5\u770B\u5F53\u524D npm \u6E90: npm config get registry"," 3. \u56FD\u5185\u7F51\u7EDC\u5EFA\u8BAE\u5207\u955C\u50CF\u6E90:"," npm config set registry https://registry.npmmirror.com/"].join(`
11
+ `)}async function Kn(t,e){let r=$o[t];if(!r)throw new D("BRIDGE_INTERNAL",`ensureAcpInstalled called for non-npm framework: ${t}`);let i=Gn.get(t);if(i)return i;let o=jn.get(t);if(o)return o;let c=`npm install -g ${r.npmPackage}@${r.versionSpec}`,f=(x,p,w)=>new D("AGENT_DEPENDENCY_INSTALL_FAILED",z0({framework:t,npmPackage:r.npmPackage,versionSpec:r.versionSpec,command:c,reason:x,elapsedMs:p}),w!==void 0?{cause:w}:{}),l=(async()=>{let x=await O0(r.binary);if(x)return Gn.set(t,x),Fe.info("acp wrapper found on PATH",{binary:r.binary,path:x}),x;let p=Date.now();try{await B0(r.npmPackage,r.versionSpec,e)}catch(b){let T=M0(b);throw Fe.warn("acp wrapper install failed",{framework:t,npmPackage:r.npmPackage,versionSpec:r.versionSpec,binary:r.binary,err:T}),f(T,Date.now()-p,b)}let w=await O0(r.binary);if(!w)throw Fe.warn("acp wrapper installed but binary not found on PATH",{framework:t,npmPackage:r.npmPackage,versionSpec:r.versionSpec,binary:r.binary}),f(`npm install \u6210\u529F\u4F46 \`${process.platform==="win32"?"where":"which"} ${r.binary}\` \u627E\u4E0D\u5230 binary (npm prefix \u53EF\u80FD\u672A\u52A0\u5165 PATH, \u6216\u88AB\u88C5\u5230\u4E86 nvm/asdf \u522B\u7684\u7248\u672C\u4E0B)`,Date.now()-p);return Gn.set(t,w),w})().finally(()=>{jn.delete(t)});return jn.set(t,l),l}function kr(t){return Gn.get(t)}function Lr(t,e){if(e)return e;let r=kr(t);if(!r)throw new D("BRIDGE_INTERNAL",`${t} ACP wrapper binary path cache miss (ensureAcpInstalled \u672A\u5728\u6784\u9020\u524D\u8DD1\u901A)`);return r}function Jo(t){return jn.get(t)}function lp(){Gn.clear(),jn.clear()}function xp(t,e){jn.set(t,e)}function hp(t,e){Gn.set(t,e)}var Fe,$o,Mi,Bi,cp,Gn,jn,N0,gn=nt(()=>{"use strict";Hn();He();ee();Fe=G("agents.acp-installer"),$o={"claude-code":{npmPackage:"@agentclientprotocol/claude-agent-acp",binary:"claude-agent-acp",versionSpec:"^0.37"},codex:{npmPackage:"@zed-industries/codex-acp",binary:"codex-acp",versionSpec:"^0.15"}};Mi=5e4,Bi=5e3,cp=5e3;Gn=new Map,jn=new Map;N0=6});import{chmod as gp,mkdir as mp,readFile as wp,rename as H0,writeFile as G0}from"node:fs/promises";import{dirname as _p}from"node:path";async function Wn(t){try{let e=await wp(t,"utf8");return JSON.parse(e)}catch(e){if(e.code==="ENOENT")return null;throw e}}async function Fi(t,e,r){await mp(_p(t),{recursive:!0});let i=`${JSON.stringify(e,null,2)}
12
+ `,o=`${t}.tmp-${process.pid}-${Math.random().toString(36).slice(2,10)}`;try{r?.mode!==void 0?await G0(o,i,{encoding:"utf8",mode:r.mode}):await G0(o,i,"utf8"),await H0(o,t),r?.mode!==void 0&&await gp(t,r.mode)}catch(c){await H0(o,o).catch(()=>{});let{rm:f}=await import("node:fs/promises");throw await f(o,{force:!0}).catch(()=>{}),c}}var Ui=nt(()=>{"use strict"});import{promises as j0}from"node:fs";import{homedir as yp}from"node:os";import{sep as bp,join as Ne,resolve as K0}from"node:path";function te(t){let e=t??yp(),r=Ne(e,".coze"),i=Ne(r,"bridge"),o=Ne(i,"lib");return{cozeRoot:r,bridgeRoot:i,libDir:o,libEntry:Ne(o,"index.js"),binDir:Ne(i,"bin"),pidFile:Ne(i,"bridge.pid"),portFile:Ne(i,"bridge.port"),tokenFile:Ne(i,"bridge.token"),patTokenFile:Ne(i,"pat-token"),logFile:Ne(i,"bridge.log"),installLock:Ne(i,"install.lock"),configFile:Ne(i,"config.json"),agentsRoot:Ne(r,"agents")}}function Dt(t,e=te()){let r=Ne(e.agentsRoot,t);return{root:r,config:Ne(r,"config.json"),workspace:Ne(r,"workspace"),logs:Ne(r,"logs")}}async function Pr(t,e){let r=await j0.realpath(K0(t)).catch(()=>null);if(!r)return!1;let i=await j0.realpath(K0(e)).catch(()=>null);if(!i)return!1;let o=process.platform==="win32"?r.toLowerCase():r,c=process.platform==="win32"?i.toLowerCase():i;return o===c||o.startsWith(c+bp)}var Me=nt(()=>{"use strict"});var Gi={};Ko(Gi,{AGENT_CONFIG_FILE_MODE:()=>qi,enforceAgentConfigMode:()=>Sp,loadAgentConfig:()=>Ue,persistAgentSessions:()=>Yo,persistAgentSkills:()=>Hi,saveAgentConfig:()=>Ve});import{chmod as Ep,stat as vp}from"node:fs/promises";function Ue(t,e){return Wn(Dt(t,e).config)}function Ve(t,e){return Fi(Dt(t.agentId,e).config,t,{mode:qi})}async function Sp(t,e){if(process.platform==="win32")return;let r=Dt(t,e).config;try{let i=await vp(r);if(!i.isFile())return;let o=i.mode&511;o!==qi&&(await Ep(r,qi),W0.warn("agent config mode auto-corrected to 0600",{path:r,from:o.toString(8)}))}catch(i){if(i.code==="ENOENT")return;W0.warn("enforceAgentConfigMode: chmod failed (ignored)",{path:r,err:String(i)})}}async function Yo(t,e,r){let i=await Ue(t,r);i&&(i.sessions=Object.fromEntries(e),await Ve(i,r))}async function Hi(t,e,r){let i=await Ue(t,r);i&&(i.skills=e,await Ve(i,r))}var W0,qi,$t=nt(()=>{"use strict";Ui();ee();Me();W0=G("agent-config"),qi=384});var Xo=ne((NE,Y0)=>{Y0.exports={LOCHDR:30,LOCSIG:67324752,LOCVER:4,LOCFLG:6,LOCHOW:8,LOCTIM:10,LOCCRC:14,LOCSIZ:18,LOCLEN:22,LOCNAM:26,LOCEXT:28,EXTSIG:134695760,EXTHDR:16,EXTCRC:4,EXTSIZ:8,EXTLEN:12,CENHDR:46,CENSIG:33639248,CENVEM:4,CENVER:6,CENFLG:8,CENHOW:10,CENTIM:12,CENCRC:16,CENSIZ:20,CENLEN:24,CENNAM:28,CENEXT:30,CENCOM:32,CENDSK:34,CENATT:36,CENATX:38,CENOFF:42,ENDHDR:22,ENDSIG:101010256,ENDSUB:8,ENDTOT:10,ENDSIZ:12,ENDOFF:16,ENDCOM:20,END64HDR:20,END64SIG:117853008,END64START:4,END64OFF:8,END64NUMDISKS:16,ZIP64SIG:101075792,ZIP64HDR:56,ZIP64LEAD:12,ZIP64SIZE:4,ZIP64VEM:12,ZIP64VER:14,ZIP64DSK:16,ZIP64DSKDIR:20,ZIP64SUB:24,ZIP64TOT:32,ZIP64SIZB:40,ZIP64OFF:48,ZIP64EXTRA:56,STORED:0,SHRUNK:1,REDUCED1:2,REDUCED2:3,REDUCED3:4,REDUCED4:5,IMPLODED:6,DEFLATED:8,ENHANCED_DEFLATED:9,PKWARE:10,BZIP2:12,LZMA:14,IBM_TERSE:18,IBM_LZ77:19,AES_ENCRYPT:99,FLG_ENC:1,FLG_COMP1:2,FLG_COMP2:4,FLG_DESC:8,FLG_ENH:16,FLG_PATCH:32,FLG_STR:64,FLG_EFS:2048,FLG_MSK:4096,FILE:2,BUFFER:1,NONE:0,EF_ID:0,EF_SIZE:2,ID_ZIP64:1,ID_AVINFO:7,ID_PFS:8,ID_OS2:9,ID_NTFS:10,ID_OPENVMS:12,ID_UNIX:13,ID_FORK:14,ID_PATCH:15,ID_X509_PKCS7:20,ID_X509_CERTID_F:21,ID_X509_CERTID_C:22,ID_STRONGENC:23,ID_RECORD_MGT:24,ID_X509_PKCS7_RL:25,ID_IBM1:101,ID_IBM2:102,ID_POSZIP:18064,EF_ZIP64_OR_32:4294967295,EF_ZIP64_OR_16:65535,EF_ZIP64_SUNCOMP:0,EF_ZIP64_SCOMP:8,EF_ZIP64_RHO:16,EF_ZIP64_DSN:24}});var Ki=ne(X0=>{var Z0={INVALID_LOC:"Invalid LOC header (bad signature)",INVALID_CEN:"Invalid CEN header (bad signature)",INVALID_END:"Invalid END header (bad signature)",DESCRIPTOR_NOT_EXIST:"No descriptor present",DESCRIPTOR_UNKNOWN:"Unknown descriptor format",DESCRIPTOR_FAULTY:"Descriptor data is malformed",NO_DATA:"Nothing to decompress",BAD_CRC:"CRC32 checksum failed {0}",FILE_IN_THE_WAY:"There is a file in the way: {0}",UNKNOWN_METHOD:"Invalid/unsupported compression method",AVAIL_DATA:"inflate::Available inflate data did not terminate",INVALID_DISTANCE:"inflate::Invalid literal/length or distance code in fixed or dynamic block",TO_MANY_CODES:"inflate::Dynamic block code description: too many length or distance codes",INVALID_REPEAT_LEN:"inflate::Dynamic block code description: repeat more than specified lengths",INVALID_REPEAT_FIRST:"inflate::Dynamic block code description: repeat lengths with no first length",INCOMPLETE_CODES:"inflate::Dynamic block code description: code lengths codes incomplete",INVALID_DYN_DISTANCE:"inflate::Dynamic block code description: invalid distance code lengths",INVALID_CODES_LEN:"inflate::Dynamic block code description: invalid literal/length code lengths",INVALID_STORE_BLOCK:"inflate::Stored block length did not match one's complement",INVALID_BLOCK_TYPE:"inflate::Invalid block type (type == 3)",CANT_EXTRACT_FILE:"Could not extract the file",CANT_OVERRIDE:"Target file already exists",DISK_ENTRY_TOO_LARGE:"Number of disk entries is too large",NO_ZIP:"No zip file was loaded",NO_ENTRY:"Entry doesn't exist",DIRECTORY_CONTENT_ERROR:"A directory cannot have content",FILE_NOT_FOUND:'File not found: "{0}"',NOT_IMPLEMENTED:"Not implemented",INVALID_FILENAME:"Invalid filename",INVALID_FORMAT:"Invalid or unsupported zip format. No END header found",INVALID_PASS_PARAM:"Incompatible password parameter",WRONG_PASSWORD:"Wrong Password",COMMENT_TOO_LONG:"Comment is too long",EXTRA_FIELD_PARSE_ERROR:"Extra field parsing error"};function Rp(t){return function(...e){return e.length&&(t=t.replace(/\{(\d)\}/g,(r,i)=>e[i]||"")),new Error("ADM-ZIP: "+t)}}for(let t of Object.keys(Z0))X0[t]=Rp(Z0[t])});var rd=ne((BE,nd)=>{var Dp=ae("fs"),Ee=ae("path"),Q0=Xo(),kp=Ki(),Lp=typeof process=="object"&&process.platform==="win32",ed=t=>typeof t=="object"&&t!==null,td=new Uint32Array(256).map((t,e)=>{for(let r=0;r<8;r++)(e&1)!==0?e=3988292384^e>>>1:e>>>=1;return e>>>0});function he(t){this.sep=Ee.sep,this.fs=Dp,ed(t)&&ed(t.fs)&&typeof t.fs.statSync=="function"&&(this.fs=t.fs)}nd.exports=he;he.prototype.makeDir=function(t){let e=this;function r(i){let o=i.split(e.sep)[0];i.split(e.sep).forEach(function(c){if(!(!c||c.substr(-1,1)===":")){o+=e.sep+c;var f;try{f=e.fs.statSync(o)}catch(l){if(l.message&&l.message.startsWith("ENOENT"))e.fs.mkdirSync(o);else throw l}if(f&&f.isFile())throw kp.FILE_IN_THE_WAY(`"${o}"`)}})}r(t)};he.prototype.writeFileTo=function(t,e,r,i){let o=this;if(o.fs.existsSync(t)){if(!r)return!1;var c=o.fs.statSync(t);if(c.isDirectory())return!1}var f=Ee.dirname(t);o.fs.existsSync(f)||o.makeDir(f);var l;try{l=o.fs.openSync(t,"w",438)}catch{o.fs.chmodSync(t,438),l=o.fs.openSync(t,"w",438)}if(l)try{o.fs.writeSync(l,e,0,e.length,0)}finally{o.fs.closeSync(l)}return o.fs.chmodSync(t,i||438),!0};he.prototype.writeFileToAsync=function(t,e,r,i,o){typeof i=="function"&&(o=i,i=void 0);let c=this;c.fs.exists(t,function(f){if(f&&!r)return o(!1);c.fs.stat(t,function(l,x){if(f&&x.isDirectory())return o(!1);var p=Ee.dirname(t);c.fs.exists(p,function(w){w||c.makeDir(p),c.fs.open(t,"w",438,function(b,T){b?c.fs.chmod(t,438,function(){c.fs.open(t,"w",438,function(E,v){c.fs.write(v,e,0,e.length,0,function(){c.fs.close(v,function(){c.fs.chmod(t,i||438,function(){o(!0)})})})})}):T?c.fs.write(T,e,0,e.length,0,function(){c.fs.close(T,function(){c.fs.chmod(t,i||438,function(){o(!0)})})}):c.fs.chmod(t,i||438,function(){o(!0)})})})})})};he.prototype.findFiles=function(t){let e=this;function r(i,o,c){typeof o=="boolean"&&(c=o,o=void 0);let f=[];return e.fs.readdirSync(i).forEach(function(l){let x=Ee.join(i,l),p=e.fs.statSync(x);(!o||o.test(x))&&f.push(Ee.normalize(x)+(p.isDirectory()?e.sep:"")),p.isDirectory()&&c&&(f=f.concat(r(x,o,c)))}),f}return r(t,void 0,!0)};he.prototype.findFilesAsync=function(t,e){let r=this,i=[];r.fs.readdir(t,function(o,c){if(o)return e(o);let f=c.length;if(!f)return e(null,i);c.forEach(function(l){l=Ee.join(t,l),r.fs.stat(l,function(x,p){if(x)return e(x);p&&(i.push(Ee.normalize(l)+(p.isDirectory()?r.sep:"")),p.isDirectory()?r.findFilesAsync(l,function(w,b){if(w)return e(w);i=i.concat(b),--f||e(null,i)}):--f||e(null,i))})})})};he.prototype.getAttributes=function(){};he.prototype.setAttributes=function(){};he.crc32update=function(t,e){return td[(t^e)&255]^t>>>8};he.crc32=function(t){typeof t=="string"&&(t=Buffer.from(t,"utf8"));let e=t.length,r=-1;for(let i=0;i<e;)r=he.crc32update(r,t[i++]);return~r>>>0};he.methodToString=function(t){switch(t){case Q0.STORED:return"STORED ("+t+")";case Q0.DEFLATED:return"DEFLATED ("+t+")";default:return"UNSUPPORTED ("+t+")"}};he.canonical=function(t){if(!t)return"";let e=Ee.posix.normalize("/"+t.split("\\").join("/"));return Ee.join(".",e)};he.zipnamefix=function(t){if(!t)return"";let e=Ee.posix.normalize("/"+t.split("\\").join("/"));return Ee.posix.join(".",e)};he.findLast=function(t,e){if(!Array.isArray(t))throw new TypeError("arr is not array");let r=t.length>>>0;for(let i=r-1;i>=0;i--)if(e(t[i],i,t))return t[i]};he.sanitize=function(t,e){t=Ee.resolve(Ee.normalize(t));for(var r=e.split("/"),i=0,o=r.length;i<o;i++){var c=Ee.normalize(Ee.join(t,r.slice(i,o).join(Ee.sep)));if(c.indexOf(t)===0)return c}return Ee.normalize(Ee.join(t,Ee.basename(e)))};he.toBuffer=function(e,r){return Buffer.isBuffer(e)?e:e instanceof Uint8Array?Buffer.from(e):typeof e=="string"?r(e):Buffer.alloc(0)};he.readBigUInt64LE=function(t,e){let r=t.readUInt32LE(e);return t.readUInt32LE(e+4)*4294967296+r};he.fromDOS2Date=function(t){return new Date((t>>25&127)+1980,Math.max((t>>21&15)-1,0),Math.max(t>>16&31,1),t>>11&31,t>>5&63,(t&31)<<1)};he.fromDate2DOS=function(t){let e=0,r=0;return t.getFullYear()>1979&&(e=(t.getFullYear()-1980&127)<<9|t.getMonth()+1<<5|t.getDate(),r=t.getHours()<<11|t.getMinutes()<<5|t.getSeconds()>>1),e<<16|r};he.isWin=Lp;he.crcTable=td});var sd=ne((zE,id)=>{var Pp=ae("path");id.exports=function(t,{fs:e}){var r=t||"",i=c(),o=null;function c(){return{directory:!1,readonly:!1,hidden:!1,executable:!1,mtime:0,atime:0}}return r&&e.existsSync(r)?(o=e.statSync(r),i.directory=o.isDirectory(),i.mtime=o.mtime,i.atime=o.atime,i.executable=(73&o.mode)!==0,i.readonly=(128&o.mode)===0,i.hidden=Pp.basename(r)[0]==="."):console.warn("Invalid path: "+r),{get directory(){return i.directory},get readOnly(){return i.readonly},get hidden(){return i.hidden},get mtime(){return i.mtime},get atime(){return i.atime},get executable(){return i.executable},decodeAttributes:function(){},encodeAttributes:function(){},toJSON:function(){return{path:r,isDirectory:i.directory,isReadOnly:i.readonly,isHidden:i.hidden,isExecutable:i.executable,mTime:i.mtime,aTime:i.atime}},toString:function(){return JSON.stringify(this.toJSON(),null," ")}}}});var ad=ne((FE,od)=>{od.exports={efs:!0,encode:t=>Buffer.from(t,"utf8"),decode:t=>t.toString("utf8")}});var Jn=ne((UE,$n)=>{$n.exports=rd();$n.exports.Constants=Xo();$n.exports.Errors=Ki();$n.exports.FileAttr=sd();$n.exports.decoder=ad()});var dd=ne((qE,cd)=>{var Jt=Jn(),q=Jt.Constants;cd.exports=function(){var t=20,e=10,r=0,i=0,o=0,c=0,f=0,l=0,x=0,p=0,w=0,b=0,T=0,E=0,v=0;t|=Jt.isWin?2560:768,r|=q.FLG_EFS;let I={extraLen:0},A=y=>Math.max(0,y)>>>0,k=y=>Math.max(0,y)&65535,O=y=>Math.max(0,y)&255;return o=Jt.fromDate2DOS(new Date),{get made(){return t},set made(y){t=y},get version(){return e},set version(y){e=y},get flags(){return r},set flags(y){r=y},get flags_efs(){return(r&q.FLG_EFS)>0},set flags_efs(y){y?r|=q.FLG_EFS:r&=~q.FLG_EFS},get flags_desc(){return(r&q.FLG_DESC)>0},set flags_desc(y){y?r|=q.FLG_DESC:r&=~q.FLG_DESC},get method(){return i},set method(y){switch(y){case q.STORED:this.version=10;case q.DEFLATED:default:this.version=20}i=y},get time(){return Jt.fromDOS2Date(this.timeval)},set time(y){y=new Date(y),this.timeval=Jt.fromDate2DOS(y)},get timeval(){return o},set timeval(y){o=A(y)},get timeHighByte(){return O(o>>>8)},get crc(){return c},set crc(y){c=A(y)},get compressedSize(){return f},set compressedSize(y){f=A(y)},get size(){return l},set size(y){l=A(y)},get fileNameLength(){return x},set fileNameLength(y){x=y},get extraLength(){return p},set extraLength(y){p=y},get extraLocalLength(){return I.extraLen},set extraLocalLength(y){I.extraLen=y},get commentLength(){return w},set commentLength(y){w=y},get diskNumStart(){return b},set diskNumStart(y){b=A(y)},get inAttr(){return T},set inAttr(y){T=A(y)},get attr(){return E},set attr(y){E=A(y)},get fileAttr(){return(E||0)>>16&4095},get offset(){return v},set offset(y){v=A(y)},get encrypted(){return(r&q.FLG_ENC)===q.FLG_ENC},get centralHeaderSize(){return q.CENHDR+x+p+w},get realDataOffset(){return v+q.LOCHDR+I.fnameLen+I.extraLen},get localHeader(){return I},loadLocalHeaderFromBinary:function(y){var C=y.slice(v,v+q.LOCHDR);if(C.readUInt32LE(0)!==q.LOCSIG)throw Jt.Errors.INVALID_LOC();I.version=C.readUInt16LE(q.LOCVER),I.flags=C.readUInt16LE(q.LOCFLG),I.flags_desc=(I.flags&q.FLG_DESC)>0,I.method=C.readUInt16LE(q.LOCHOW),I.time=C.readUInt32LE(q.LOCTIM),I.crc=C.readUInt32LE(q.LOCCRC),I.compressedSize=C.readUInt32LE(q.LOCSIZ),I.size=C.readUInt32LE(q.LOCLEN),I.fnameLen=C.readUInt16LE(q.LOCNAM),I.extraLen=C.readUInt16LE(q.LOCEXT);let L=v+q.LOCHDR+I.fnameLen,F=L+I.extraLen;return y.slice(L,F)},loadFromBinary:function(y){if(y.length!==q.CENHDR||y.readUInt32LE(0)!==q.CENSIG)throw Jt.Errors.INVALID_CEN();t=y.readUInt16LE(q.CENVEM),e=y.readUInt16LE(q.CENVER),r=y.readUInt16LE(q.CENFLG),i=y.readUInt16LE(q.CENHOW),o=y.readUInt32LE(q.CENTIM),c=y.readUInt32LE(q.CENCRC),f=y.readUInt32LE(q.CENSIZ),l=y.readUInt32LE(q.CENLEN),x=y.readUInt16LE(q.CENNAM),p=y.readUInt16LE(q.CENEXT),w=y.readUInt16LE(q.CENCOM),b=y.readUInt16LE(q.CENDSK),T=y.readUInt16LE(q.CENATT),E=y.readUInt32LE(q.CENATX),v=y.readUInt32LE(q.CENOFF)},localHeaderToBinary:function(){var y=Buffer.alloc(q.LOCHDR);return y.writeUInt32LE(q.LOCSIG,0),y.writeUInt16LE(e,q.LOCVER),y.writeUInt16LE(r,q.LOCFLG),y.writeUInt16LE(i,q.LOCHOW),y.writeUInt32LE(o,q.LOCTIM),y.writeUInt32LE(c,q.LOCCRC),y.writeUInt32LE(f,q.LOCSIZ),y.writeUInt32LE(l,q.LOCLEN),y.writeUInt16LE(x,q.LOCNAM),y.writeUInt16LE(I.extraLen,q.LOCEXT),y},centralHeaderToBinary:function(){var y=Buffer.alloc(q.CENHDR+x+p+w);return y.writeUInt32LE(q.CENSIG,0),y.writeUInt16LE(t,q.CENVEM),y.writeUInt16LE(e,q.CENVER),y.writeUInt16LE(r,q.CENFLG),y.writeUInt16LE(i,q.CENHOW),y.writeUInt32LE(o,q.CENTIM),y.writeUInt32LE(c,q.CENCRC),y.writeUInt32LE(f,q.CENSIZ),y.writeUInt32LE(l,q.CENLEN),y.writeUInt16LE(x,q.CENNAM),y.writeUInt16LE(p,q.CENEXT),y.writeUInt16LE(w,q.CENCOM),y.writeUInt16LE(b,q.CENDSK),y.writeUInt16LE(T,q.CENATT),y.writeUInt32LE(E,q.CENATX),y.writeUInt32LE(v,q.CENOFF),y},toJSON:function(){let y=function(C){return C+" bytes"};return{made:t,version:e,flags:r,method:Jt.methodToString(i),time:this.time,crc:"0x"+c.toString(16).toUpperCase(),compressedSize:y(f),size:y(l),fileNameLength:y(x),extraLength:y(p),commentLength:y(w),diskNumStart:b,inAttr:T,attr:E,offset:v,centralHeaderSize:y(q.CENHDR+x+p+w)}},toString:function(){return JSON.stringify(this.toJSON(),null," ")}}}});var ud=ne((HE,fd)=>{var Yn=Jn(),ue=Yn.Constants;fd.exports=function(){var t=0,e=0,r=0,i=0,o=0;return{get diskEntries(){return t},set diskEntries(c){t=e=c},get totalEntries(){return e},set totalEntries(c){e=t=c},get size(){return r},set size(c){r=c},get offset(){return i},set offset(c){i=c},get commentLength(){return o},set commentLength(c){o=c},get mainHeaderSize(){return ue.ENDHDR+o},loadFromBinary:function(c){if((c.length!==ue.ENDHDR||c.readUInt32LE(0)!==ue.ENDSIG)&&(c.length<ue.ZIP64HDR||c.readUInt32LE(0)!==ue.ZIP64SIG))throw Yn.Errors.INVALID_END();c.readUInt32LE(0)===ue.ENDSIG?(t=c.readUInt16LE(ue.ENDSUB),e=c.readUInt16LE(ue.ENDTOT),r=c.readUInt32LE(ue.ENDSIZ),i=c.readUInt32LE(ue.ENDOFF),o=c.readUInt16LE(ue.ENDCOM)):(t=Yn.readBigUInt64LE(c,ue.ZIP64SUB),e=Yn.readBigUInt64LE(c,ue.ZIP64TOT),r=Yn.readBigUInt64LE(c,ue.ZIP64SIZE),i=Yn.readBigUInt64LE(c,ue.ZIP64OFF),o=0)},toBinary:function(){var c=Buffer.alloc(ue.ENDHDR+o);return c.writeUInt32LE(ue.ENDSIG,0),c.writeUInt32LE(0,4),c.writeUInt16LE(t,ue.ENDSUB),c.writeUInt16LE(e,ue.ENDTOT),c.writeUInt32LE(r,ue.ENDSIZ),c.writeUInt32LE(i,ue.ENDOFF),c.writeUInt16LE(o,ue.ENDCOM),c.fill(" ",ue.ENDHDR),c},toJSON:function(){let c=function(f,l){let x=f.toString(16).toUpperCase();for(;x.length<l;)x="0"+x;return"0x"+x};return{diskEntries:t,totalEntries:e,size:r+" bytes",offset:c(i,4),commentLength:o}},toString:function(){return JSON.stringify(this.toJSON(),null," ")}}}});var ea=ne(Qo=>{Qo.EntryHeader=dd();Qo.MainHeader=ud()});var xd=ne((jE,ld)=>{ld.exports=function(t){var e=ae("zlib"),r={chunkSize:(parseInt(t.length/1024)+1)*1024};return{deflate:function(){return e.deflateRawSync(t,r)},deflateAsync:function(i){var o=e.createDeflateRaw(r),c=[],f=0;o.on("data",function(l){c.push(l),f+=l.length}),o.on("end",function(){var l=Buffer.alloc(f),x=0;l.fill(0);for(var p=0;p<c.length;p++){var w=c[p];w.copy(l,x),x+=w.length}i&&i(l)}),o.end(t)}}}});var pd=ne((KE,hd)=>{var Op=+(process.versions?process.versions.node:"").split(".")[0]||0;hd.exports=function(t,e){var r=ae("zlib");let i=Op>=15&&e>0?{maxOutputLength:e}:{};return{inflate:function(){return r.inflateRawSync(t,i)},inflateAsync:function(o){var c=r.createInflateRaw(i),f=[],l=0;c.on("data",function(x){f.push(x),l+=x.length}),c.on("end",function(){var x=Buffer.alloc(l),p=0;x.fill(0);for(var w=0;w<f.length;w++){var b=f[w];b.copy(x,p),p+=b.length}o&&o(x)}),c.end(t)}}}});var yd=ne((WE,_d)=>{"use strict";var{randomFillSync:gd}=ae("crypto"),Np=Ki(),Mp=new Uint32Array(256).map((t,e)=>{for(let r=0;r<8;r++)(e&1)!==0?e=e>>>1^3988292384:e>>>=1;return e>>>0}),wd=(t,e)=>Math.imul(t,e)>>>0,md=(t,e)=>Mp[(t^e)&255]^t>>>8,Or=()=>typeof gd=="function"?gd(Buffer.alloc(12)):Or.node();Or.node=()=>{let t=Buffer.alloc(12),e=t.length;for(let r=0;r<e;r++)t[r]=Math.random()*256&255;return t};var Wi={genSalt:Or};function Vi(t){let e=Buffer.isBuffer(t)?t:Buffer.from(t);this.keys=new Uint32Array([305419896,591751049,878082192]);for(let r=0;r<e.length;r++)this.updateKeys(e[r])}Vi.prototype.updateKeys=function(t){let e=this.keys;return e[0]=md(e[0],t),e[1]+=e[0]&255,e[1]=wd(e[1],134775813)+1,e[2]=md(e[2],e[1]>>>24),t};Vi.prototype.next=function(){let t=(this.keys[2]|2)>>>0;return wd(t,t^1)>>8&255};function Bp(t){let e=new Vi(t);return function(r){let i=Buffer.alloc(r.length),o=0;for(let c of r)i[o++]=e.updateKeys(c^e.next());return i}}function zp(t){let e=new Vi(t);return function(r,i,o=0){i||(i=Buffer.alloc(r.length));for(let c of r){let f=e.next();i[o++]=c^f,e.updateKeys(c)}return i}}function Fp(t,e,r){if(!t||!Buffer.isBuffer(t)||t.length<12)return Buffer.alloc(0);let i=Bp(r),o=i(t.slice(0,12)),c=(e.flags&8)===8?e.timeHighByte:e.crc>>>24;if(o[11]!==c)throw Np.WRONG_PASSWORD();return i(t.slice(12))}function Up(t){Buffer.isBuffer(t)&&t.length>=12?Wi.genSalt=function(){return t.slice(0,12)}:t==="node"?Wi.genSalt=Or.node:Wi.genSalt=Or}function qp(t,e,r,i=!1){t==null&&(t=Buffer.alloc(0)),Buffer.isBuffer(t)||(t=Buffer.from(t.toString()));let o=zp(r),c=Wi.genSalt();c[11]=e.crc>>>24&255,i&&(c[10]=e.crc>>>16&255);let f=Buffer.alloc(t.length+12);return o(c,f),o(t,f,12)}_d.exports={decrypt:Fp,encrypt:qp,_salter:Up}});var bd=ne($i=>{$i.Deflater=xd();$i.Inflater=pd();$i.ZipCrypto=yd()});var na=ne(($E,Ed)=>{var re=Jn(),Hp=ea(),pe=re.Constants,ta=bd();Ed.exports=function(t,e){var r=new Hp.EntryHeader,i=Buffer.alloc(0),o=Buffer.alloc(0),c=!1,f=null,l=Buffer.alloc(0),x=Buffer.alloc(0),p=!0;let w=t,b=typeof w.decoder=="object"?w.decoder:re.decoder;p=b.hasOwnProperty("efs")?b.efs:!1;function T(){return!e||!(e instanceof Uint8Array)?Buffer.alloc(0):(x=r.loadLocalHeaderFromBinary(e),e.slice(r.realDataOffset,r.realDataOffset+r.compressedSize))}function E(y){if(!r.flags_desc&&!r.localHeader.flags_desc){if(re.crc32(y)!==r.localHeader.crc)return!1}else{let C={},L=r.realDataOffset+r.compressedSize;if(e.readUInt32LE(L)==pe.LOCSIG||e.readUInt32LE(L)==pe.CENSIG)throw re.Errors.DESCRIPTOR_NOT_EXIST();if(e.readUInt32LE(L)==pe.EXTSIG)C.crc=e.readUInt32LE(L+pe.EXTCRC),C.compressedSize=e.readUInt32LE(L+pe.EXTSIZ),C.size=e.readUInt32LE(L+pe.EXTLEN);else if(e.readUInt16LE(L+12)===19280)C.crc=e.readUInt32LE(L+pe.EXTCRC-4),C.compressedSize=e.readUInt32LE(L+pe.EXTSIZ-4),C.size=e.readUInt32LE(L+pe.EXTLEN-4);else throw re.Errors.DESCRIPTOR_UNKNOWN();if(C.compressedSize!==r.compressedSize||C.size!==r.size||C.crc!==r.crc)throw re.Errors.DESCRIPTOR_FAULTY();if(re.crc32(y)!==C.crc)return!1}return!0}function v(y,C,L){if(typeof C>"u"&&typeof y=="string"&&(L=y,y=void 0),c)return y&&C&&C(Buffer.alloc(0),re.Errors.DIRECTORY_CONTENT_ERROR()),Buffer.alloc(0);var F=T();if(F.length===0)return y&&C&&C(F),F;if(r.encrypted){if(typeof L!="string"&&!Buffer.isBuffer(L))throw re.Errors.INVALID_PASS_PARAM();F=ta.ZipCrypto.decrypt(F,r,L)}var z=Buffer.alloc(r.size);switch(r.method){case re.Constants.STORED:if(F.copy(z),E(z))return y&&C&&C(z),z;throw y&&C&&C(z,re.Errors.BAD_CRC()),re.Errors.BAD_CRC();case re.Constants.DEFLATED:var P=new ta.Inflater(F,r.size);if(y)P.inflateAsync(function(N){N.copy(N,0),C&&(E(N)?C(N):C(N,re.Errors.BAD_CRC()))});else{if(P.inflate(z).copy(z,0),!E(z))throw re.Errors.BAD_CRC(`"${b.decode(i)}"`);return z}break;default:throw y&&C&&C(Buffer.alloc(0),re.Errors.UNKNOWN_METHOD()),re.Errors.UNKNOWN_METHOD()}}function I(y,C){if((!f||!f.length)&&Buffer.isBuffer(e))return y&&C&&C(T()),T();if(f.length&&!c){var L;switch(r.method){case re.Constants.STORED:return r.compressedSize=r.size,L=Buffer.alloc(f.length),f.copy(L),y&&C&&C(L),L;default:case re.Constants.DEFLATED:var F=new ta.Deflater(f);if(y)F.deflateAsync(function(P){L=Buffer.alloc(P.length),r.compressedSize=P.length,P.copy(L),C&&C(L)});else{var z=F.deflate();return r.compressedSize=z.length,z}F=null;break}}else if(y&&C)C(Buffer.alloc(0));else return Buffer.alloc(0)}function A(y,C){return re.readBigUInt64LE(y,C)}function k(y){try{for(var C=0,L,F,z;C+4<y.length;)L=y.readUInt16LE(C),C+=2,F=y.readUInt16LE(C),C+=2,z=y.slice(C,C+F),C+=F,pe.ID_ZIP64===L&&O(z)}catch{throw re.Errors.EXTRA_FIELD_PARSE_ERROR()}}function O(y){var C,L,F,z;y.length>=pe.EF_ZIP64_SCOMP&&(C=A(y,pe.EF_ZIP64_SUNCOMP),r.size===pe.EF_ZIP64_OR_32&&(r.size=C)),y.length>=pe.EF_ZIP64_RHO&&(L=A(y,pe.EF_ZIP64_SCOMP),r.compressedSize===pe.EF_ZIP64_OR_32&&(r.compressedSize=L)),y.length>=pe.EF_ZIP64_DSN&&(F=A(y,pe.EF_ZIP64_RHO),r.offset===pe.EF_ZIP64_OR_32&&(r.offset=F)),y.length>=pe.EF_ZIP64_DSN+4&&(z=y.readUInt32LE(pe.EF_ZIP64_DSN),r.diskNumStart===pe.EF_ZIP64_OR_16&&(r.diskNumStart=z))}return{get entryName(){return b.decode(i)},get rawEntryName(){return i},set entryName(y){i=re.toBuffer(y,b.encode);var C=i[i.length-1];c=C===47||C===92,r.fileNameLength=i.length},get efs(){return typeof p=="function"?p(this.entryName):p},get extra(){return l},set extra(y){l=y,r.extraLength=y.length,k(y)},get comment(){return b.decode(o)},set comment(y){if(o=re.toBuffer(y,b.encode),r.commentLength=o.length,o.length>65535)throw re.Errors.COMMENT_TOO_LONG()},get name(){var y=b.decode(i);return c?y.substr(y.length-1).split("/").pop():y.split("/").pop()},get isDirectory(){return c},getCompressedData:function(){return I(!1,null)},getCompressedDataAsync:function(y){I(!0,y)},setData:function(y){f=re.toBuffer(y,re.decoder.encode),!c&&f.length?(r.size=f.length,r.method=re.Constants.DEFLATED,r.crc=re.crc32(y),r.changed=!0):r.method=re.Constants.STORED},getData:function(y){return r.changed?f:v(!1,null,y)},getDataAsync:function(y,C){r.changed?y(f):v(!0,y,C)},set attr(y){r.attr=y},get attr(){return r.attr},set header(y){r.loadFromBinary(y)},get header(){return r},packCentralHeader:function(){r.flags_efs=this.efs,r.extraLength=l.length;var y=r.centralHeaderToBinary(),C=re.Constants.CENHDR;return i.copy(y,C),C+=i.length,l.copy(y,C),C+=r.extraLength,o.copy(y,C),y},packLocalHeader:function(){let y=0;r.flags_efs=this.efs,r.extraLocalLength=x.length;let C=r.localHeaderToBinary(),L=Buffer.alloc(C.length+i.length+r.extraLocalLength);return C.copy(L,y),y+=C.length,i.copy(L,y),y+=i.length,x.copy(L,y),y+=x.length,L},toJSON:function(){let y=function(C){return"<"+(C&&C.length+" bytes buffer"||"null")+">"};return{entryName:this.entryName,name:this.name,comment:this.comment,isDirectory:this.isDirectory,header:r.toJSON(),compressedData:y(e),data:y(f)}},toString:function(){return JSON.stringify(this.toJSON(),null," ")}}}});var Id=ne((JE,Sd)=>{var vd=na(),Gp=ea(),Be=Jn();Sd.exports=function(t,e){var r=[],i={},o=Buffer.alloc(0),c=new Gp.MainHeader,f=!1,l=null;let x=new Set,p=e,{noSort:w,decoder:b}=p;t?v(p.readEntries):f=!0;function T(){let A=new Set;for(let k of Object.keys(i)){let O=k.split("/");if(O.pop(),!!O.length)for(let y=0;y<O.length;y++){let C=O.slice(0,y+1).join("/")+"/";A.add(C)}}for(let k of A)if(!(k in i)){let O=new vd(p);O.entryName=k,O.attr=16,O.temporary=!0,r.push(O),i[O.entryName]=O,x.add(O)}}function E(){if(f=!0,i={},c.diskEntries>(t.length-c.offset)/Be.Constants.CENHDR)throw Be.Errors.DISK_ENTRY_TOO_LARGE();r=new Array(c.diskEntries);for(var A=c.offset,k=0;k<r.length;k++){var O=A,y=new vd(p,t);y.header=t.slice(O,O+=Be.Constants.CENHDR),y.entryName=t.slice(O,O+=y.header.fileNameLength),y.header.extraLength&&(y.extra=t.slice(O,O+=y.header.extraLength)),y.header.commentLength&&(y.comment=t.slice(O,O+y.header.commentLength)),A+=y.header.centralHeaderSize,r[k]=y,i[y.entryName]=y}x.clear(),T()}function v(A){var k=t.length-Be.Constants.ENDHDR,O=Math.max(0,k-65535),y=O,C=t.length,L=-1,F=0;for(typeof p.trailingSpace=="boolean"&&p.trailingSpace&&(O=0),k;k>=y;k--)if(t[k]===80){if(t.readUInt32LE(k)===Be.Constants.ENDSIG){L=k,F=k,C=k+Be.Constants.ENDHDR,y=k-Be.Constants.END64HDR;continue}if(t.readUInt32LE(k)===Be.Constants.END64SIG){y=O;continue}if(t.readUInt32LE(k)===Be.Constants.ZIP64SIG){L=k,C=k+Be.readBigUInt64LE(t,k+Be.Constants.ZIP64SIZE)+Be.Constants.ZIP64LEAD;break}}if(L==-1)throw Be.Errors.INVALID_FORMAT();c.loadFromBinary(t.slice(L,C)),c.commentLength&&(o=t.slice(F+Be.Constants.ENDHDR)),A&&E()}function I(){r.length>1&&!w&&r.sort((A,k)=>A.entryName.toLowerCase().localeCompare(k.entryName.toLowerCase()))}return{get entries(){return f||E(),r.filter(A=>!x.has(A))},get comment(){return b.decode(o)},set comment(A){o=Be.toBuffer(A,b.encode),c.commentLength=o.length},getEntryCount:function(){return f?r.length:c.diskEntries},forEach:function(A){this.entries.forEach(A)},getEntry:function(A){return f||E(),i[A]||null},setEntry:function(A){f||E(),r.push(A),i[A.entryName]=A,c.totalEntries=r.length},deleteFile:function(A,k=!0){f||E();let O=i[A];this.getEntryChildren(O,k).map(C=>C.entryName).forEach(this.deleteEntry)},deleteEntry:function(A){f||E();let k=i[A],O=r.indexOf(k);O>=0&&(r.splice(O,1),delete i[A],c.totalEntries=r.length)},getEntryChildren:function(A,k=!0){if(f||E(),typeof A=="object")if(A.isDirectory&&k){let O=[],y=A.entryName;for(let C of r)C.entryName.startsWith(y)&&O.push(C);return O}else return[A];return[]},getChildCount:function(A){if(A&&A.isDirectory){let k=this.getEntryChildren(A);return k.includes(A)?k.length-1:k.length}return 0},compressToBuffer:function(){f||E(),I();let A=[],k=[],O=0,y=0;c.size=0,c.offset=0;let C=0;for(let z of this.entries){let P=z.getCompressedData();z.header.offset=y;let N=z.packLocalHeader(),U=N.length+P.length;y+=U,A.push(N),A.push(P);let $=z.packCentralHeader();k.push($),c.size+=$.length,O+=U+$.length,C++}O+=c.mainHeaderSize,c.offset=y,c.totalEntries=C,y=0;let L=Buffer.alloc(O);for(let z of A)z.copy(L,y),y+=z.length;for(let z of k)z.copy(L,y),y+=z.length;let F=c.toBinary();return o&&o.copy(F,Be.Constants.ENDHDR),F.copy(L,y),t=L,f=!1,L},toAsyncBuffer:function(A,k,O,y){try{f||E(),I();let C=[],L=[],F=0,z=0,P=0;c.size=0,c.offset=0;let N=function(U){if(U.length>0){let $=U.shift(),se=$.entryName+$.extra.toString();O&&O(se),$.getCompressedDataAsync(function(fe){y&&y(se),$.header.offset=z;let we=$.packLocalHeader(),Oe=we.length+fe.length;z+=Oe,C.push(we),C.push(fe);let at=$.packCentralHeader();L.push(at),c.size+=at.length,F+=Oe+at.length,P++,N(U)})}else{F+=c.mainHeaderSize,c.offset=z,c.totalEntries=P,z=0;let $=Buffer.alloc(F);C.forEach(function(fe){fe.copy($,z),z+=fe.length}),L.forEach(function(fe){fe.copy($,z),z+=fe.length});let se=c.toBinary();o&&o.copy(se,Be.Constants.ENDHDR),se.copy($,z),t=$,f=!1,A($)}};N(Array.from(this.entries))}catch(C){k(C)}}}}});var Cd=ne((YE,Td)=>{var xe=Jn(),le=ae("path"),jp=na(),Kp=Id(),mn=(...t)=>xe.findLast(t,e=>typeof e=="boolean"),Ad=(...t)=>xe.findLast(t,e=>typeof e=="string"),Wp=(...t)=>xe.findLast(t,e=>typeof e=="function"),Vp={noSort:!1,readEntries:!1,method:xe.Constants.NONE,fs:null};Td.exports=function(t,e){let r=null,i=Object.assign(Object.create(null),Vp);t&&typeof t=="object"&&(t instanceof Uint8Array||(Object.assign(i,t),t=i.input?i.input:void 0,i.input&&delete i.input),Buffer.isBuffer(t)&&(r=t,i.method=xe.Constants.BUFFER,t=void 0)),Object.assign(i,e);let o=new xe(i);if((typeof i.decoder!="object"||typeof i.decoder.encode!="function"||typeof i.decoder.decode!="function")&&(i.decoder=xe.decoder),t&&typeof t=="string")if(o.fs.existsSync(t))i.method=xe.Constants.FILE,i.filename=t,r=o.fs.readFileSync(t);else throw xe.Errors.INVALID_FILENAME();let c=new Kp(r,i),{canonical:f,sanitize:l,zipnamefix:x}=xe;function p(E){if(E&&c){var v;if(typeof E=="string"&&(v=c.getEntry(le.posix.normalize(E))),typeof E=="object"&&typeof E.entryName<"u"&&typeof E.header<"u"&&(v=c.getEntry(E.entryName)),v)return v}return null}function w(E){let{join:v,normalize:I,sep:A}=le.posix;return v(le.isAbsolute(E)?"/":".",I(A+E.split("\\").join(A)+A))}function b(E){return E instanceof RegExp?(function(v){return function(I){return v.test(I)}})(E):typeof E!="function"?()=>!0:E}let T=(E,v)=>{let I=v.slice(-1);return I=I===o.sep?o.sep:"",le.relative(E,v)+I};return{readFile:function(E,v){var I=p(E);return I&&I.getData(v)||null},childCount:function(E){let v=p(E);if(v)return c.getChildCount(v)},readFileAsync:function(E,v){var I=p(E);I?I.getDataAsync(v):v(null,"getEntry failed for:"+E)},readAsText:function(E,v){var I=p(E);if(I){var A=I.getData();if(A&&A.length)return A.toString(v||"utf8")}return""},readAsTextAsync:function(E,v,I){var A=p(E);A?A.getDataAsync(function(k,O){if(O){v(k,O);return}k&&k.length?v(k.toString(I||"utf8")):v("")}):v("")},deleteFile:function(E,v=!0){var I=p(E);I&&c.deleteFile(I.entryName,v)},deleteEntry:function(E){var v=p(E);v&&c.deleteEntry(v.entryName)},addZipComment:function(E){c.comment=E},getZipComment:function(){return c.comment||""},addZipEntryComment:function(E,v){var I=p(E);I&&(I.comment=v)},getZipEntryComment:function(E){var v=p(E);return v&&v.comment||""},updateFile:function(E,v){var I=p(E);I&&I.setData(v)},addLocalFile:function(E,v,I,A){if(o.fs.existsSync(E)){v=v?w(v):"";let k=le.win32.basename(le.win32.normalize(E));v+=I||k;let O=o.fs.statSync(E),y=O.isFile()?o.fs.readFileSync(E):Buffer.alloc(0);O.isDirectory()&&(v+=o.sep),this.addFile(v,y,A,O)}else throw xe.Errors.FILE_NOT_FOUND(E)},addLocalFileAsync:function(E,v){E=typeof E=="object"?E:{localPath:E};let I=le.resolve(E.localPath),{comment:A}=E,{zipPath:k,zipName:O}=E,y=this;o.fs.stat(I,function(C,L){if(C)return v(C,!1);k=k?w(k):"";let F=le.win32.basename(le.win32.normalize(I));if(k+=O||F,L.isFile())o.fs.readFile(I,function(z,P){return z?v(z,!1):(y.addFile(k,P,A,L),setImmediate(v,void 0,!0))});else if(L.isDirectory())return k+=o.sep,y.addFile(k,Buffer.alloc(0),A,L),setImmediate(v,void 0,!0)})},addLocalFolder:function(E,v,I){if(I=b(I),v=v?w(v):"",E=le.normalize(E),o.fs.existsSync(E)){let A=o.findFiles(E),k=this;if(A.length)for(let O of A){let y=le.join(v,T(E,O));I(y)&&k.addLocalFile(O,le.dirname(y))}}else throw xe.Errors.FILE_NOT_FOUND(E)},addLocalFolderAsync:function(E,v,I,A){A=b(A),I=I?w(I):"",E=le.normalize(E);var k=this;o.fs.open(E,"r",function(O){if(O&&O.code==="ENOENT")v(void 0,xe.Errors.FILE_NOT_FOUND(E));else if(O)v(void 0,O);else{var y=o.findFiles(E),C=-1,L=function(){if(C+=1,C<y.length){var F=y[C],z=T(E,F).split("\\").join("/");z=z.normalize("NFD").replace(/[\u0300-\u036f]/g,"").replace(/[^\x20-\x7E]/g,""),A(z)?o.fs.stat(F,function(P,N){P&&v(void 0,P),N.isFile()?o.fs.readFile(F,function(U,$){U?v(void 0,U):(k.addFile(I+z,$,"",N),L())}):(k.addFile(I+z+"/",Buffer.alloc(0),"",N),L())}):process.nextTick(()=>{L()})}else v(!0,void 0)};L()}})},addLocalFolderAsync2:function(E,v){let I=this;E=typeof E=="object"?E:{localPath:E},localPath=le.resolve(w(E.localPath));let{zipPath:A,filter:k,namefix:O}=E;k instanceof RegExp?k=(function(L){return function(F){return L.test(F)}})(k):typeof k!="function"&&(k=function(){return!0}),A=A?w(A):"",O=="latin1"&&(O=L=>L.normalize("NFD").replace(/[\u0300-\u036f]/g,"").replace(/[^\x20-\x7E]/g,"")),typeof O!="function"&&(O=L=>L);let y=L=>le.join(A,O(T(localPath,L))),C=L=>le.win32.basename(le.win32.normalize(O(L)));o.fs.open(localPath,"r",function(L){L&&L.code==="ENOENT"?v(void 0,xe.Errors.FILE_NOT_FOUND(localPath)):L?v(void 0,L):o.findFilesAsync(localPath,function(F,z){if(F)return v(F);z=z.filter(P=>k(y(P))),z.length||v(void 0,!1),setImmediate(z.reverse().reduce(function(P,N){return function(U,$){if(U||$===!1)return setImmediate(P,U,!1);I.addLocalFileAsync({localPath:N,zipPath:le.dirname(y(N)),zipName:C(N)},P)}},v))})})},addLocalFolderPromise:function(E,v){return new Promise((I,A)=>{this.addLocalFolderAsync2(Object.assign({localPath:E},v),(k,O)=>{k&&A(k),O&&I(this)})})},addFile:function(E,v,I,A){E=x(E);let k=p(E),O=k!=null;O||(k=new jp(i),k.entryName=E),k.comment=I||"";let y=typeof A=="object"&&A instanceof o.fs.Stats;y&&(k.header.time=A.mtime);var C=k.isDirectory?16:0;let L=k.isDirectory?16384:32768;return y?L|=4095&A.mode:typeof A=="number"?L|=4095&A:L|=k.isDirectory?493:420,C=(C|L<<16)>>>0,k.attr=C,k.setData(v),O||c.setEntry(k),k},getEntries:function(E){return c.password=E,c?c.entries:[]},getEntry:function(E){return p(E)},getEntryCount:function(){return c.getEntryCount()},forEach:function(E){return c.forEach(E)},extractEntryTo:function(E,v,I,A,k,O){A=mn(!1,A),k=mn(!1,k),I=mn(!0,I),O=Ad(k,O);var y=p(E);if(!y)throw xe.Errors.NO_ENTRY();var C=f(y.entryName),L=l(v,O&&!y.isDirectory?O:I?C:le.basename(C));if(y.isDirectory){var F=c.getEntryChildren(y);return F.forEach(function(N){if(N.isDirectory)return;var U=N.getData();if(!U)throw xe.Errors.CANT_EXTRACT_FILE();var $=f(N.entryName),se=l(v,I?$:le.basename($));let fe=k?N.header.fileAttr:void 0;o.writeFileTo(se,U,A,fe)}),!0}var z=y.getData(c.password);if(!z)throw xe.Errors.CANT_EXTRACT_FILE();if(o.fs.existsSync(L)&&!A)throw xe.Errors.CANT_OVERRIDE();let P=k?E.header.fileAttr:void 0;return o.writeFileTo(L,z,A,P),!0},test:function(E){if(!c)return!1;for(var v in c.entries)try{if(v.isDirectory)continue;var I=c.entries[v].getData(E);if(!I)return!1}catch{return!1}return!0},extractAllTo:function(E,v,I,A){if(I=mn(!1,I),A=Ad(I,A),v=mn(!1,v),!c)throw xe.Errors.NO_ZIP();c.entries.forEach(function(k){var O=l(E,f(k.entryName));if(k.isDirectory){o.makeDir(O);return}var y=k.getData(A);if(!y)throw xe.Errors.CANT_EXTRACT_FILE();let C=I?k.header.fileAttr:void 0;o.writeFileTo(O,y,v,C);try{o.fs.utimesSync(O,k.header.time,k.header.time)}catch{throw xe.Errors.CANT_EXTRACT_FILE()}})},extractAllToAsync:function(E,v,I,A){if(A=Wp(v,I,A),I=mn(!1,I),v=mn(!1,v),!A)return new Promise((L,F)=>{this.extractAllToAsync(E,v,I,function(z){z?F(z):L(this)})});if(!c){A(xe.Errors.NO_ZIP());return}E=le.resolve(E);let k=L=>l(E,le.normalize(f(L.entryName))),O=(L,F)=>new Error(L+': "'+F+'"'),y=[],C=[];c.entries.forEach(L=>{L.isDirectory?y.push(L):C.push(L)});for(let L of y){let F=k(L),z=I?L.header.fileAttr:void 0;try{o.makeDir(F),z&&o.fs.chmodSync(F,z),o.fs.utimesSync(F,L.header.time,L.header.time)}catch{A(O("Unable to create folder",F))}}C.reverse().reduce(function(L,F){return function(z){if(z)L(z);else{let P=le.normalize(f(F.entryName)),N=l(E,P);F.getDataAsync(function(U,$){if($)L($);else if(!U)L(xe.Errors.CANT_EXTRACT_FILE());else{let se=I?F.header.fileAttr:void 0;o.writeFileToAsync(N,U,v,se,function(fe){fe||L(O("Unable to write file",N)),o.fs.utimes(N,F.header.time,F.header.time,function(we){we?L(O("Unable to set times",N)):L()})})}})}}},A)()},writeZip:function(E,v){if(arguments.length===1&&typeof E=="function"&&(v=E,E=""),!E&&i.filename&&(E=i.filename),!!E){var I=c.compressToBuffer();if(I){var A=o.writeFileTo(E,I,!0);typeof v=="function"&&v(A?null:new Error("failed"),"")}}},writeZipPromise:function(E,v){let{overwrite:I,perm:A}=Object.assign({overwrite:!0},v);return new Promise((k,O)=>{!E&&i.filename&&(E=i.filename),E||O("ADM-ZIP: ZIP File Name Missing"),this.toBufferPromise().then(y=>{let C=L=>L?k(L):O("ADM-ZIP: Wasn't able to write zip file");o.writeFileToAsync(E,y,I,A,C)},O)})},toBufferPromise:function(){return new Promise((E,v)=>{c.toAsyncBuffer(E,v)})},toBuffer:function(E,v,I,A){return typeof E=="function"?(c.toAsyncBuffer(E,v,I,A),null):c.compressToBuffer()}}}});var ul=ne(Se=>{"use strict";var M=K;(function(t,e){let r=K,i=t();for(;;)try{if(-parseInt(r(942))/1*(-parseInt(r(1741))/2)+parseInt(r(1515))/3*(-parseInt(r(722))/4)+parseInt(r(1648))/5+parseInt(r(1030))/6+-parseInt(r(1259))/7*(parseInt(r(1532))/8)+parseInt(r(927))/9*(parseInt(r(1245))/10)+-parseInt(r(1449))/11*(parseInt(r(243))/12)===e)break;i.push(i.shift())}catch{i.push(i.shift())}})(io,753581);var Q_=Object[M(1751)+M(507)],ey=Object[M(1561)+M(1629)+M(700)],ol=(t,e)=>function(){return t&&(e=(0,t[{HfBKr:function(c,f){return c(f)}}[M(867)](ey,t)[0]])(t=0)),e},ty=(t,e)=>{let r=M,i={ljaAT:function(c,f,l,x){return c(f,l,x)}};for(var o in e)i[r(1399)](Q_,t,o,{get:e[o],enumerable:!0})};function ny(){return tl||(tl=[IDBDatabase,IDBObjectStore,IDBIndex,IDBCursor,IDBTransaction])}function ry(){let t=M;return nl||(nl=[IDBCursor[t(910)+"e"][t(1046)],IDBCursor.prototype[t(968)],IDBCursor[t(910)+"e"][t(968)+t(493)+"ey"]])}function iy(t){let e=M,r={yFVqe:function(o,c){return o(c)},GuNiQ:function(o,c){return o(c)},uAYqy:function(o){return o()},Blato:e(414),OJDHz:"error",lDdWM:function(o,c,f){return o(c,f)},RvqwV:e(1297),PtWuo:function(o,c){return o===c},FygdP:e(390),uPOoN:function(o,c){return o(c)},PjDtD:function(o){return o()},PryNe:function(o,c){return o!==c},cJhqd:e(823),JZXKZ:function(o,c){return o instanceof c}},i=new Promise((o,c)=>{let f=e,l={ZwVhW:r[f(765)],BdAPA:r[f(1209)],uUafF:function(x,p,w){return r.lDdWM(x,p,w)},gnwTx:r[f(1153)],WfeQb:function(x,p){return r[f(1005)](x,p)},iiIYB:r.FygdP,hoyhq:function(x,p){return r[f(1774)](x,p)},qjukR:function(x){return r[f(1796)](x)}};if(r[f(576)](r.cJhqd,r.cJhqd))this[f(1181)+f(326)]=_0x53b652,this[f(307)]&&(this[f(307)].binaryType=_0x18516d);else{let x=()=>{let b=f;t["removeEv"+b(313)+b(1269)](l[b(625)],p),t["removeEv"+b(313)+b(1269)](l.BdAPA,w)},p=()=>{let b=f;r[b(1305)](o,r[b(1027)](Ct,t.result)),r[b(543)](x)},w=()=>{let b=f,T={TqLrT:function(E,v,I){return l.uUafF(E,v,I)},ducAw:l[b(275)]};if(l.WfeQb(l.iiIYB,b(390)))l[b(915)](c,t[b(1178)]),l[b(1539)](x);else{let E=this[b(1008)+b(533)]?.[b(244)+b(1025)+"nt"]();this[b(376)+b(424)+b(1020)](T.TqLrT(_0xd297c,T.ducAw,{code:_0x3299d5[b(396)],reason:b(1422)+b(1224)+b(636)+b(1678)+b(934)+"ame: "+E})),this[b(1008)+b(533)]?.[b(1585)+"pointCon"+b(1502)](),this[b(641)+b(1392)]?.[b(279)+b(828)]();return}};t[f(1655)+"Listener"]("success",p),t.addEventListener(r[f(1209)],w)}});return i[e(901)](o=>{let c=e;r[c(1333)](o,IDBCursor)&&Ic[c(363)](o,t)})[e(1567)](()=>{}),no[e(363)](i,t),i}function sy(t){let e=M,r={JLbym:"abort",zLJVC:function(o){return o()},nJLer:function(o,c){return o===c},eIFPU:e(1624),LmaRO:"RXVfD",TSdlV:"AbortError",gsmne:"complete",Bliko:e(1178)};if(to.has(t))return;let i=new Promise((o,c)=>{let f=e,l={uByqi:r[f(1034)],KFHYQ:function(b){return r[f(1782)](b)},zYqlc:function(b,T){return r[f(879)](b,T)},ksLFd:r[f(1196)],cYnSL:r[f(1698)],ysXmE:r[f(995)]},x=()=>{let b=f;t[b(432)+"entListe"+b(1269)](b(724),p),t[b(432)+b(313)+"ner"](b(1178),w),t[b(432)+b(313)+b(1269)](l[b(423)],w)},p=()=>{let b=f;o(),l[b(1691)](x)},w=()=>{let b=f;l[b(574)](l[b(1613)],l[b(433)])?(_0x55fd03.set(_0x4d1ce2,_0x58c394),_0x15201b[b(363)](_0x44d29d,_0x5a7b60)):(c(t[b(1178)]||new DOMException(l[b(1637)],b(249)+"or")),l[b(1691)](x))};t["addEvent"+f(1612)](r.gsmne,p),t[f(1655)+f(1612)](r[f(1503)],w),t[f(1655)+f(1612)](r[f(1034)],w)});to.set(t,i)}function oy(t){ro={rlLoh:function(i,o){return i(o)}}[M(829)](t,ro)}function ay(t){let e=M,r={GTBrE:function(i,o){return i(o)},RpZmK:function(i,o){return i>=o},khLHT:function(i,o){return i===o},acHph:function(i,o){return i in o},rxVjg:e(1739)+e(563),euwRG:function(i,o){return i===o},MlOBj:e(1351),vnluX:function(i){return i()}};if(r[e(1438)](t,IDBDatabase[e(910)+"e"][e(1748)+e(1744)])&&!r.acHph(r[e(729)],IDBTransaction[e(910)+"e"])){if(r.euwRG(r.MlOBj,r.MlOBj))return function(i,...o){let c=e,f=t.call(r[c(1451)](_i,this),i,...o);return Sc[c(363)](f,i[c(1640)]?i[c(1640)]():[i]),r.GTBrE(Ct,f)};if(r[e(438)](_0x37f96a,_0x12ea5f))return _0x4d007d}return r.vnluX(ry).includes(t)?function(...i){let o=e;return t[o(680)](r.GTBrE(_i,this),i),r[o(1451)](Ct,Ic[o(930)](this))}:function(...i){let o=e;return r[o(1451)](Ct,t[o(680)](r[o(1451)](_i,this),i))}}function K(t,e){t=t-222;let r=io(),i=r[t];if(K.vqpQQH===void 0){var o=function(x){let p="abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789+/=",w="",b="";for(let T=0,E,v,I=0;v=x.charAt(I++);~v&&(E=T%4?E*64+v:v,T++%4)?w+=String.fromCharCode(255&E>>(-2*T&6)):0)v=p.indexOf(v);for(let T=0,E=w.length;T<E;T++)b+="%"+("00"+w.charCodeAt(T).toString(16)).slice(-2);return decodeURIComponent(b)};K.Fpyvbj=o,K.zqAfzk={},K.vqpQQH=!0}let c=r[0],f=t+c,l=K.zqAfzk[f];return l?i=l:(i=K.Fpyvbj(i),K.zqAfzk[f]=i),i}function cy(t){let e=M,r={PYzYM:function(i,o){return i===o},HngfK:e(395),qaunW:function(i,o){return i(o)},Slgts:function(i,o){return i instanceof o},VXsvo:function(i){return i()}};return r[e(456)](typeof t,r[e(479)])?r[e(902)](ay,t):(r[e(1371)](t,IDBTransaction)&&sy(t),al(t,r.VXsvo(ny))?new Proxy(t,ro):t)}function Ct(t){let e=M,r={qNjIz:function(o,c){return o instanceof c},MXWJT:function(o,c){return o(c)},SGxBY:function(o,c){return o!==c}};if(r[e(1733)](t,IDBRequest))return r[e(1737)](iy,t);if(Qs[e(731)](t))return Qs.get(t);let i=r[e(1737)](cy,t);return r[e(1525)](i,t)&&(Qs.set(t,i),no[e(363)](i,t)),i}var al,tl,nl,Ic,to,Sc,Qs,no,ro,_i,rl=ol({"node_modules/idb/build/wrap-idb-value.js"(){let t=M,e={mPjBB:function(r,i){return r instanceof i},MOTaA:t(254),ChmYa:function(r,i){return r===i},RjCnQ:t(1668),hdBWu:function(r,i){return r===i},RpiCz:"objectSt"+t(563),pDyuJ:t(1770),NaVui:function(r,i){return r(i)},cwDvT:function(r,i){return r+i},qpsEg:t(620),XrbNu:t(613),WrUZn:function(r,i){return r in i}};al=(r,i)=>i[t(1472)](o=>r instanceof o),Ic=new WeakMap,to=new WeakMap,Sc=new WeakMap,Qs=new WeakMap,no=new WeakMap,ro={get(r,i,o){let c=t;if(e[c(228)](r,IDBTransaction))if(c(254)!==e[c(1274)])this[c(378)]=!0,this[c(718)]();else{if(e[c(1041)](i,e[c(679)]))return to[c(930)](r);if(e[c(1621)](i,e[c(1255)]))return r[c(1739)+c(563)]||Sc[c(930)](r);if(i===e.pDyuJ)return o[c(1739)+c(563)][1]?void 0:o[c(1739)+"ore"](o["objectSt"+c(563)][0])}return e.NaVui(Ct,r[i])},set(r,i,o){let c=t,f={UQxad:function(l,x){return e.NaVui(l,x)},aGDtM:function(l,x){return e.cwDvT(l,x)}};if(e.qpsEg!==e[c(530)])return r[i]=o,!0;{let x=""+_0x37f376.now(),p=_0x16e2db||(_0x322a46=f.UQxad(_0x433809,_0x59e6ad)),w=_0x42bd14.random().toString(16)[c(744)](-6);return f[c(926)]("02",x)+p+w}},has(r,i){let o=t;return e[o(228)](r,IDBTransaction)&&(i===e.RjCnQ||e[o(1621)](i,e[o(1543)]))?!0:e[o(1370)](i,r)}},_i=r=>no[t(930)](r)}}),cl={};ty(cl,{deleteDB:()=>fy,openDB:()=>dy,unwrap:()=>_i,wrap:()=>Ct});function io(){let t=["D3z0B3K","Efrurw52","DeLK","uvj0qKG","v2DVvwG","rNvYr3G","y0XUEvq","y2XVC2veqG","qKzYtxu","x3DZsw5ZDge","C0XPC3rLBMu","uMHgrNm","z0PgEgC","u3bes04","zMLN","qMXPA28","DxveBKi","tvzStw8","ExriCNe","DgLUzYbZzxi","C3nHz2vfDMu","zxjFCw9Zx2e","sKPwsKe","q0Xpu0ve","z2PnweO","CvfJtuu","BeDvzfO","otCZntC4B3H0r0zf","uuDsCem","zxjHDg9Y","BgLUzw5V","Axryqxy","zNPkuey","Cw9Zx18","ChrVCG","Dg9tDhjPBMC","B05Qrw0","u0D4qLK","CMPlyLy","BwvY","wLjWBLq","uLjpuG","uw5bAwi","A1H4Dwi","oenjCMzesq","tvftEeu","sfL0zfO","Aw9UvgLTzw8","BhrPCgXLihq","CMfNzvn5BMm","y09Wzw4","CwP1A1i","qNPjtvC","sM5dz08","Dgv4DfbHEwW","Cer5DuO","ChzUtwS","CMLLC0nVDw4","mdaWma","Afrytvi","AgLNAa","u2LAq3e","suPzue4","txjpuue","x3nLBMrby2S","Ehr6z04","uMjNyKO","Aw1LCYbPBIa","zwvKzwq","x29Uq2XVC2u","zLzAEMq","Aw50zwDLCIa","Dhv1wuS","z2v0t3DUuhi","r1L6AwO","qxnHrNm","AvvPq1K","wLHhyNC","twv2q1y","y2f0y2G","ywnOzwq","vvfWC2S","BMrWB2LUDfq","AK92yKu","y1zpwwC","y0rPtwi","qvPpEw0","uxrvq0y","q0Lyy0q","uvbgEgK","D2fJALm","Cw91r08","AgfUz2u","ywzYww0","wNHNtvK","EuvVAeS","rvbmBhi","CMvZzxrfBMq","t3nPDNu","x2rItMfTzq","zgvIDwC","D1nXAeq","D2jtC0O","CK9stxa","C2vUzf9Hy2S","r09gr3m","wufcEhm","zM9Yy2u","rfD5r0S","D2j3rfi","y2XLyxi","B216rLO","zxj2AwnL","qNDwBuu","tuDcCuy","mhWZFdr8mNW","sgvnqw0","z2vY","A3vgAva","yM5JEeW","veDbDMe","ywDLsgLKzq","C0z5s08","zvvYBa","tgLZDgvUzxi","A3nmrMq","AuPft3e","vgXhCxG","sxPhrvq","C2nYAxb0","tvrwufi","B25JBg9Zzq","CYbWyxjHBxm","Agrcv3u","z2LMu1y","B2zM","AMLOBeu","BLzXtuy","y2HLy2Tszwe","rujIB1m","ywXSB2nvBNm","B3bLCNr5tMe","z2vtEw5J","DhrSCuu","B3bLBG","y1PKqKC","CKDozLG","ywrKt25L","wxrpquG","ExnyBuu","AfrSAfq","yMfSu2nVCgu","C29YDa","rLjkt2y","zgnmBMG","ywDLu2HVDW","C2r2rey","x2rYB3bhBg8","A2H4BKm","Cg9W","nJq0nZi1mhfLyMHVvq","DxbKyxrLq3u","uKjnzue","Aw5PDcbrB1m","ALHbt3q","zw5KCg9PBNq","AwTztgm","ywrKrxzLBNq","wKDsCw8","vLvcrvi","CM92AwrLige","rvjst1i","B2zMBgLUzq","CgLUz19VBMm","yxv0BW","zNjVBujPDhm","tuzhCeC","z3DKCg0","qKz2Ceu","ENbOsvO","zg9Uzq","qNLjD1e","t1bftG","C3vIyxjYyxK","EgfoCvu","Eun1EKq","DxDStNu","AenIAfm","ru9xDKm","uePMt2S","D24GCMvHC28","zLbHweG","A3LVBvq","y2fSBa","x29Ut3bLBG","D1DWq2K","ywrqtva","BgjUzhm","qxrvsLG","DMztrem","EwH3yum","DxjS","C3jJ","s0ziwve","C2vYDMLJzs0","BMrWB2LUDca","BvPmvuS","BhnODMG","tgjSAuG","sMLMu3m","tg1HuK8","EKPjAMC","x29UtwvZC2e","A0L6yuK","BezSDxnO","C0jf","zMLnse4","pxv0zI04","Ef9MCM9UDgK","EefLve4","t1fouwy","rxzLBNq","yM9L","uLrvz1K","tuPqrNO","D1zqEhO","EfPTuhK","AfzLtMu","y3jLyxrLrwW","vMLnDLa","zgrTuwe","C0Xf","tg9Nsuq","mhW0Fdf8m3W","t0nczeC","uKznv0m","rMn1z2K","x0rctMfTzq","yunKCgS","ExLAsuW","AgHzwNK","x2zVCM1HDeu","AxPLq0m","zcbLCNjVCI4","C3rLBMvYCW","Cu5QsxO","zNvLAha","B3fyq1G","C2vYDMLJzq","tvHxsLq","EgXlCNu","B2jQzwn0u3q","CgfYC2u","mtjfsu9PC2y","t1bftL9fuLi","vNnqAK8","Aw9U","B25pCgvU","Bg9NsurozxC","D2PYzNm","DhjHBNnHy3q","B0fUq0S","zhnXuhq","zgvMAw5Luhi","B25Uzwn0Aw4","EhrMBfi","AgPRsuy","ywnRtxnNswq","zxjYtM8","tef2t1y","ENHsu1i","uxfsD1u","C2v0q3vYC28","y0X2A1m","B25VCgvU","q3jfCNO","BgvUz3rO","tw9urwi","u0nYq1O","sNjmEue","wgzjBwi","DgLTzw91Da","C3rVCMu","BxLktxO","B25ozxr3B3i","qvjVv3e","DvbpB04","DhbqD3q","v1vuEfq","nNW0Fdi","ihn1y2nLC3m","z2TLyMq","sfHnthO","v3nLBgq","EKXkvKm","tw9KDwXL","ywnRx2nVzgu","BwXRr2W","zxPwv3i","suTpCwi","vw9PAge","CMvJzwL2zwq","CNzHBa","x3jLBw92zvC","rhbTsKO","zwTJu0W","zxq9DxrMltG","r01oA2W","ugPeDeq","zfPJrNi","ywnR","qw9tyMe","x194x21Zz18","EunfCKq","BwfUDwfSihi","Dgv4Dc9Qyxy","AMLWDLy","zufJAW","BvbQqKi","zMLSDgvY","Dxrjza","vxbKyxrLq28","ENHurM4","Dxfqs2e","AMP1rhu","wKfxEha","tKvdyM0","y29SBM8","tMvKu2W","vgjdB1i","y29UBMvJDca","uhrxBhi","z1fYqLu","otCXmtzrz0P6sva","z2v0q3vYCMu","DvfgyLu","BeXvExy","q3HvCMu","q3bRwwq","qwjVCNrfCNi","jMPZy2fSBgi","AKXiz0e","D1fKEey","BhP2qLa","B1D2rgW","CNjVCK1LC3m","y3LcEvO","C2zcAhm","y29UBMvJDeu","Bw1qree","t094r0S","suvtx0vsuK8","B2zMC2v0","A21ku2K","x3fVC0rc","y2nkrwe","tfHlEuG","Dg9VigXHCMC","tu10qKW","Aw5N","D3Hzu1m","AwrJuu4","vefKr0y","y3r4","z2v0u3rVCMe","z253vhG","B3jRzxjhBg8","uuf3v3a","zw5NDgG","CMvZzxrdB3u","nxW5Fdb8mta","BeDruwe","CM92AwrLigi","ufzZuNm","Ae5euKe","zxjFBxnNAwq","x3bYB3rVy28","ihrPBwvZ","y2vNrxm","A0Hnrxq","CMvZB2X2zq","rxnoq20","r01utNK","Dw50","q1vLA0K","ihjLy29UBMu","BhrVB1K","twvZC2fNzuu","s3PnseC","AhbXzgC","Cgf5Bg9Hza","ihbYB3rVy28","CMvHzhLtDge","BMrLEa","D1bMyLm","Ec11C2uT","zNjVBNrPzxi","x3DZ","Ahrewe0","x2LZv29YA2u","zhbAAg0","CgXLyxnLiha","AwLuDge","zw50tgLZDgu","r2vjr1u","rgLuAgC","rLDiENa","z2Hlr28","y2rJDKC","m3WYFdz8mhW","AxnAzxjV","B25nzxnZywC","x3jLy29UBMu","sgfIAfy","nhW5Fdb8mte","yxzpvue","ExbL","zgrjrcWGzgu","CMvXDwLYzwq","zgvSzxrL","CgvYC2LZDgu","zuDKweq","zNHKv28","yvbpALe","Ec1TC2CTy3u","zgLZywjSzue","B25tDg9Wsw0","BuXcAeW","yNrSB1i","BMnZDxq","C2vXvxC","y2HnyxHuCMK","CgznCMm","x2HHBMrSzva","BMfTzq","BM5nD0G","x21LC3nHz2u","z0rVuNm","CKn4CLi","zvrhDhq","vM5zyNK","vgfN","Bwf4tg9ZC0m","veL0twS","r1Dtthi","DfnPzMq","vw1otfm","DgHHBIbSB2m","Bvriv2S","CMvTB3zLq2G","zvD6qvO","rxnOAuu","EM9yzgm","C2v0","D1H1Dw0","yxv0B21HDgK","ignVzgu6ia","AhvqrMS","tKfusvzfx0u","weTJEwm","Be5hC28","B0TLs2O","Aw5KzxG","ysbTDxn0igi","tLDbqLC","q09otKvdveK","x2rPC3bHDgm","x2nSzwfYugK","x2LZsw5PDa","BNrbBMrvCgq","thLpqwC","DxrVuMvJB24","tujYt3G","tuvtu0fhrv8","vMDXzha","x2rLC3rYB3K","DgLLCKPtt04","veXTrNC","BhDZrgO","B1flteq","CLfKz1G","tenczMm","zw5XDwv1zq","BLLIBhK","C2vUDa","zNvUy3rPB24","y29Kzq","qxPdBuu","tg9JAW","sLfWAge","AMzHDvO","vhrMufi","DMvUDa","B25szwnLAxy","weL0Bhy","ChvZAa","wMfTv2m","C3rHCNq","thDMz2i","B09sDgq","BK16yxu","x3nLCuLK","zw1PDa","u3nyA3O","C3vJy2vZCW","yMXVy2TLza","AuHpueG","vKvlwuG","EfjUDwi","ufbhrMG","r0rSsei","sgf3vee","B2LUDfjLywm","Duj5CwK","AenSB3nLrxy","zNjVBuj5Dgu","x3jLywr5q2W","Cgf5Bg9Hzeu","C3bSAxq","DgTpA0S","DMfSDwvZ","y3jLyxrLuMu","CMvTB3zLrxy","y1LUu0W","zKD0thy","q2DosLy","BwLUAvbYB2C","igzPzwXKoIa","uNbABuS","yKXrwg8","q1brEMW","Dg9cExrLCW","BgjbENi","q21Zr1i","ywXty29Wzq","tfnRtwq","yNvMzMvYzwq","y29UC3rYDwm","uKnRtve","Aw5JBhvKzxm","tMj2v0K","wMTUt0S","B25TzxnZywC","vxb3ufK","Dg9oDw1Izxi","C3HSrvq","ufL6wu0","B3jL","Bwf4twvZC2e","BMnLq2XVC2u","BMv4DcGPigm","Du55rhC","BM93","DfzOy0i","BwLZzq","DhjPzxmGCMu","svv2CNq","wwvNrKu","zw1LBNq","y2jqEey","EunSAg4","C2v0sxrLBq","A2v5CW","AwDIBgG","BgvbqK4","wgzwBfy","ohW1Fdj8m3W","rMHWAKG","ugnJCwW","sg5NzKS","yNL0zu9MzNm","ueLMs0O","q2fPs0C","B0r1vLK","rMzrAK0","rwTHrKq","rLDt","qujMuvO","rhzuyLe","C2HPzNq","v3vyugm","B2nRzxq","Cevbs0u","uhjPBwfYEuS","sLj3EhK","sgTvsKi","uKfcvxG","t3bLBKv2zw4","Cw9Z","BxbZDKO","ruHuy1y","ufv0Eui","CLzHBhvLCW","CMvWBgfJzq","x2n1CNnVCK4","CgLUz0LUDgu","t2LYAgC","B3bLCNr5","swf6s1e","t1nuDNK","x2rLyNvN","sMDZrLi","Ehn4u1y","qNnuB3C","t2LRuxe","AurMt1q","CNnVCKzPBgu","rLn3Cwy","B2H1tLu","s0PLELK","u3Hhru0","vgffEMG","Axnby2TdBgu","AwXLtMfTzq","q1vXz2m","sLv6u28","zwDxB3K","DvzYvMK","thbgzLm","DKfktLC","whjItNu","CMvWBgfJzui","Cg5JuMy","De1HBMfNzxi","A2v0ignVBNm","t2DAv3G","C2fNzq","s3Hirxu","yNLL","D3jPDgu","EsbJBg9Zzwq","ywrK","B25tDgfYDfi","DufzCxK","z3njEuO","v2vIu29JA2u","x25HDMLNyxq","wNvNChi","v2fMu3C","uK1SENu","CMfTzq","tMf6tfK","v0PcDue","CgfNzxnOB3C","B25mAw5L","re5vuuW","qLnrt0G","y3jLyxrLq2W","C2DPza","tNvyzNm","vgngEfa","AevYCM9Yrxy","CMvHzfvjBNq","B3jLtMfTzxm","rwzis1K","Dgf1qNq","yxKSihrYEsa","vNrnv1q","CMfUzg9T","DhjPBq","zxjHvMS","qMHVDw8","BgzTsg4","AhnHELq","ELLXBgm","r2L5Dhm","uhj5tMu","AKHbseC","yw1LoIa","mhWXFdr8m3W","u2nOBgG","q3LvuLK","suX5Cee","wKTXrMK","zM9YrwfJAa","DLvkqwG","B25SAw5L","y3vYCMvUDeu","DgvZDa","z2v0sxrLBq","rLzQtMC","DxrMofDYAxq","z21Mzfm","zKLNsNO","ywXSq3vYC28","BMCGDxjSoIa","Cg9Ptuq","zxjFywnRx20","EwPWsLK","zMz6v2y","ohWXFdj8n3W","CvvVzw8","qw9wC1C","Bg9N","aaaaaaaaaaa","uhDYDMC","ywrKq291BNq","Dgv4Dc9WBge","CurKBfK","wwTOtNG","AM9PBG","Bvb1twG","vKTpqxG","sgr1wxK","lcbTyxGGCMu","DhrsDwu","y1jUDuS","AwXK","x2LUAxrqCM8","AgvHzgvYCW","vuvUswO","qNrIz3y","AgvKtwf4uMu","CYbHBhjLywq","twfzwLG","wNDwAfC","x2LUDgvYDMe","sg1RBfm","igXHCMDLCIa","z1L2B1y","CgLUz0XVC3m","DMzsywS","vvLks0q","Cg9PBNrbBMq","qM1jshm","DgvmB2Djre4","zcWGDw5RBM8","AgjVteu","shf0uM0","t1f3Duu","quX3txm","x3bPBMDmB3m","r3fJyxi","t1jxuvi","x2DLBMvYyxq","x3DHAxq","nxW0Fdf8nW","DMLJzuLeig8","DKH3uMK","q291BNq","rxvov24","l3DZl3yY","veXXsxi","BNvTyMvY","vMXTtLy","y0LtB04","A2vNrfu","B1v3DNG","x29UugfNzu4","t2HeEw8","yuzoCgy","wxnLuuq","CMvJB25Uzwm","uLjeD08","rePYAwi","C2v0u3rVCMe","yxzKEeu","A3PLvw0","vhf5rgm","EKDPu2u","B25dBg9Zzq","wg9tEgi","v0jPAgC","vw5PBxbSzw0","qLrkqKW","rMrVEMi","qw1VDw50","CM92AwrLihy","tKPsrwS","uMPdBLe","yxbWBhK","v09nvfm","Aw5Mz00","qvvmzem","CM92AwrLihC","yw5Hz2vY","s0Dhruq","DKTyqKm","DxnLCKLW","C1zLAwe","qMHPuLu","zw5fDMvUDa","x2fKzfDZtgK","AxzUCfu","yxbWzw5Kq2G","DhLWzq","wuDtr1O","DwXhy3K","x2LZtwLUAvq","EM1iz1i","BwvZ","DLnrBfO","v1HhChi","s0zeCNi","uwfuu3q","AxjLza","yNL0zuXLBMC","rKrXre4","AxnbCNjHEq","DgjUB0y","sfvXCwm","CePlv24","zfDVCMTLCKC","zNvetwu","sLLAse0","yxGGCMv0CMK","DuPJvuG","zv90Aw1LB3u","x2nVBM5Ly3q","AxbWEuy","r0nRyNK","sursuxG","ofvlEgXitG","CxPNuha","y29TCgXLDgu","q2LxwuW","C2TVB0C","z2jsrw8","y2uGBM90igK","CNHwAMC","EwLuy1u","AgfZ","z2zvy2O","y29UDgv4Da","thnYBNm","y3jLyxrLtwu","tuTpDgu","zMvY","u0zbz0q","tLHYD2y","nhWXFdj8mhW","zwDQz1K","sxPju2G","yuDXBNq","C2XPy2u","tuDUCNm","r1ncEwS","y3vZDg9Tshq","qLnZsvy","ihrVihjLDhi","qxjpCLO","mNW1Fdb8m3W","r2HKzee","qxvfC0C","txjtsui","rvfnBhm","yM9KEq","A3DcDKW","zevOC0y","Dhb6B04","EerztwC","vejQze4","ywDL","t3HPvwK","Dw5KzwzPBMu","qMXHDg8","r3nZruS","EfvZzuvUDG","Euv6D00","z2v0s2v5","uenjugS","DMTkt0G","tufyx1jfvfi","yxnZAwDU","zNf0Cw4","C0vfuuO","AeXyzMe","y2vZC0HHBMq","runxqvK","su5tvefova","mxW0","EMPKBgi","zxrxB3jRq2G","D2LSBfjLy28","EgXpr04","vg9Jz3i","y2XVC2uSihC","yLjiz04","ywjVCNq","DcbVzIbYyw4","DgPNEgy","zMzLCG","y3jLyxrLt3a","C0rTDKu","vNvXyw4","EeLxwM8","CKn4rfu","CKXJshe","vvvRtue","B0Lvvhe","vNLxD1i","AxnrB1nnzxm","Aw9Ul2PZB24","yKv0u3y","zvH0Cfy","x2n1CNnVCKy","B3vUDa","yMLUyxj5","qvrcvxi","Exjszva","AxnrB1nby2S","BgLUzq","yw5Nzq","zxHWB3j0CW","zgf0yq","C3nqrgm","svjxywO","z1ruve4","z3Ldt0u","C2v0vMS","CxH2wwW","Dw5ZAwDUzwq","tvHlBMq","AxjvAxu","v2LYAeC","x3bHDgHlzxK","AeXRCMC","z0LABNO","BNrLCG","CMXmB2G","zw5JB2rPBMC","y29UBMvJDfm","yxrLq291BNq","DxHMzva","BwvZC2fNztO","EuzjwwO","ExHUt3y","BhrbsxC","y3vYDMfSDwu","CM9YrxzLBNq","DwXJuLa","zNzmrgm","DgfIyxnL","EgvTrMe","z3fOr1q","x3vYBa","C0TiuMm","BfzsBhK","C1PTwKq","Bu9Hwfa","y2HLy2TdDxi","q2jhANa","EMjTwgu","uhz1yKy","x3nVy2TLDa","Cg9PBNrdB24","wxzqr3C","DgHVzee","Dgjisw0","vfzur3G","mhWZFdj8nhW","tvLeuNu","C0PdrLq","yxbWBgLJyxq","ihrPBwvVDxq","ywDLrxzLBNq","svLZsKq","sgzcs3i","C2vUza","uNLhAvu","CYbPBNn0yw4","rM5dyKG","txrxvLG","vK5iuuu","v1zNzMm","wM1Oz2O","uMvHzcbWyxm","B2nRzxrtDwm","Bwf4uMv0CMK","BKPmzxi","yKLYu3q","zgD3BNa","rwj1Dgu","Ahjkz28","y3nrrKC","ywTVDue","Bg9IywXty28","BMv3vMvYC2K","sM50BNi","tgHnq0e","Fdr8nNWZ","zwnVBM5Ly3q","u3jXqMy","y1fMvem","zxLiwMS","AfvXz3e","C3bSAwnL","uLHXA0W","wKPrB20","A1ruvfe","thfKr04","DgHLBG","Cwf1BLC","CMvZzxruCMK","sKvxvMW","A3zPyLy","q29Kzq","svflvxm","rfvPEMq","wMfqwKK","ChjVDg90Exa","qLjKv0m","q3vZDg9Trxi","zv9ZDwnJzxm","yxnL","Ag95Ahe","vhjgww0","zgLZCgf0y2G","BLnrCfi","sxzjvw4","AxnszwfKEq","CKrgq0G","r3retMm","C3rYAw5NAwy","B3bLBIa","r3HoA3i","yuDeDe0","mtm1EgrAugDl","sMrTtwC","B3nLza","z2v0","y291BNq","ug1tv2m","C2vQyvO","BIWGAg9ZDg4","D3fNy2m","o2nOyxjZzxq","uhPnEMC","s0HRChK","ywXS","vhzirxC","AwXSihvZzsa","ody4oxPLAK9sDq","sMXwrgG","t3LbrfK","BeHHBMrSzxi","BxDrDhq","r0zTAue","qMXMsNa","tg9NsurozxC","BgfhrKC","D21mC1a","Bwv0Ag9K","EwTjy1G","DcbSAw1PDa","AMvqA3C","EvHPu3q","CMvHzg9UBhK","Cgu6ia","EwzfugO","DhviExO","x1fVu01HBMe","CIb0DhDjra","vgn4BwS","vhPmAe0","C3vIC3rYAw4","AfLJzuC","zKv5Dhu","y29UDgLUDwu","t25kuei","x3bYzwzPEa","DMvYC2LVBMm","AgvHzgvY","CfD6Bva","DhbizwfKzxi","Dev2zw50","wLHyqMu","s3DMBwi","D1LwD3e","z2v0qwXSs2u","twLZC2LUzYa","zePMrvm","EMzPteW","zuLVww4","q1rYzfy","x3bPBMC","CNjRuLi","uMvgwwq","ywzL","BLbHtu4","zxjFCw9Z","qu1Ut3e","u3rot1q","x29WDgLVBNm","uMruzwC","vfnKBfy","wfLMvKC","rKnADLi","rgTADvi","FdH8mxWZ","wvfeALe","zgvS","ihzHBgLKigq","C0rVBhK","BwfW","uhrxDw8","uM1LAvG","CNzHBfzHBhu","x2vUzhbVAw4","wufcs3K","EgTVCfy","z2XWuui","BMvJDa","z2v0q3vYC28","reiGzMfPBgu","CMvQzwn0","tgrbBvi","yMfSrxzLBNq","AwfVA0u","DwzezM0","zw50","zNjVBuHHC2G","BwXUrgm","z3f2uxq","mxW1","BNrfBMrWB2K","x2rPC2nVBM4","r3voAve","y2HHCKnVzgu","BeLXt3C","nti3nduZnfHKvwLMsa","r1blruW","A2vTDeS","u2HHCMvKv28","sKXIEw0","rM5YyvO","zw5HyMXLuw8","zwHqBgy","BM9Uzv9UB24","u3rYyxrLz3K","yKX3AKS","q2HTwwe","wNDvvMq","DMvY","C0LKEgC","wKf6u0G","ywr2yw5Jzq","ww1VuNa","tKLxqxa","CMv0CNLdB3u","zNbRrMm","yNvMzMvY","sK1RAuq","vLLMz2e","v2LUzg93","rxfdBhK","sfLwuLC","rNjVBNrPzxi","x2LZtwLUAvC","AMvJDfn0B3i","vwjHCgq","yKrtzMu","BgvY","serushu","B0DpBMK","wgHXz3i","wvvzAhi","qxb2vuC","qMnLquG","s0Plrfi","D3Lsq1G","DvDxzfa","u2TPCcbWyxm","ig1LC3nHz2u","B3PNtLK","CMfTugfYyw0","sLv0seS","C1PNuLu","yw1Lu3bHy2u","z0nyzxq","u0PgzxK","zKDWuwK","tLbquwe","r1vyvhO","DhzwBwm","qNjPzgDL","CwXnsha","CxHJzvy","ExHKAgG","rNDAyuq","Aw5KzxGGB3u","A2v5","EMfwshe","DNjwqMm","A3bYtha","x21PBMLoyxy","CNrkse4","r2XZDwy","yKLwuLK","yxnJCMLWDa","A3bODK8","yMfJA3vWigu","BMDuAw1LCG","v2vPEgLUsLm","CwLgtMW","CfPIDge","B2XKvMvYC2K","zLntq04","zvLnBwq","Bhm6ia","vef1wwW","q3vZDg9Tq2W","rKLmrv9ot1q","BNruCMLLC0m","zcWG","BuDPqvy","zw5Xy3G","z0H1rxe","C1Dzu0y","rfPvAvi","ve1rBwK","EeHJrMu","AwDHDg9Yt24","rgzMAeO","q29dy1K","yw1L","vNjgBfu","EfHTtNa","Dgjvwvy","DwL6B2m","x2TLEvbHDgG","r2PHALq","x29UvgLTzw8","Bg93","v2jgquS","Dg9cExrLC0W","ChjVDg9JB2W","zML0uuS","wLH2teC","z3HwAxa","EvfoENe","x2n1CNnVCK0","qLHKsM0","wvnvBva","BMnVzgLUzW","sg9AzeS","B3nLrxzLBNq","DfzjrKe","tvzdA0C","qMrfuxa","y2XLyxjtDg8","qwPxEgG","wMTyy28","uNzXD1y","x2XPC3rLBMu","v2TAAge","rg1yD2i","yxKSig5LDhC","x2nYzwf0zvm","tgX2yuu","AxnFywnR","DgfjEwC","ign1CNnVCIa","DhDVCMTdAge","v293BKW","ENrPDgy","yw5ZzM9YBvq","BfrPBwvVDxq","tKDFrvjst1i","sLzYqui","sND5see","y29Uy2f0","BM5Ly3q","tvb3tMW","CMvZDwX0","ufrQChO","C0H4qNO","tMTQC2C","zxjYB3i","vLvIBwO","icSG","x2jPBMfYEvq","Cevqr0u","uvrjChK","Aw47y2HHCNm","Cgf5Bg9Hzfq","Cw1zrwq","B1jis1m","B2DVsfq","wNHIBLG","x2LUAxq","veT3AK0","CMv5BKC","y3vYC29Yx2y","mdaWmdaWmda","C0Hos1e","zuLgufu","CMfkzM4","z1z2Eg0","q1f5BfK","zxH0ugf5Bg8","z1rPBwvVDxq","EgPIsxq","AefJA01LC3m","C3n5vK4","ENrotMW","zfDmDxO","AMT6rLy","seTUug4","t0PeshO","y3jLyxrLt2i","x19LC01Vzhu","DxbNCMfKzw4","wvzurKm","Dhj1y3rVCIa","x2LUAxrhBg8","v0fStLq","Cu9zuwq","Eg1Isgm","B25LCNjVCG","Dg1Rsue","uvbUsuK","yMLUza","zwn0","BMCGzMfPBgu","D3jPDgvvAw4","rM9NCLq","vNPXrem","BwvZC2fNzv8","zw5HyMXLvhi","v1nysM4","rKjqzLe","ANHdy2S","zxfYqwq","rePyzw0","rvbOsNe","zMzmAw5L","q29UzMLN","DuPlvKu","wwLfs04","ywfwve4","tw5gvuu","vwHXBwO","AhvUBuC","z2vrDwv1zuW","nJq4mdyWCxjZCgLk","x2DLDeLUDgu","x2LZtM9Kzq","B3bLBKrc","sMXxuKe","B3jpBMXPBMu","BhvcyKG","igfYCMf5yNu","zw5JB2rLrNi","BMLdrg8","uNbPq3O","BufXAg0","q1r1DLe","vhLMuK0","mJKWmdi0meDxvxPUta","u2vXsuq","zLfgEe4","DNbcBMO","zvDwzwO","Dg9mB3DLCKm","D2XdB0W","Ae1LC3nHz2u","CMvHzhDYAxq","C2v0zgi","BMvY","Dg9cExrLC0i","wvPZzxC","y3vYC29Yx24","y2HnyxHdB3u","tu9uyue","CMvUDevUzha","y0TfC2O","B3jRig9MzMW","wgjiBvq","Dhr3Awq","CLf5DLu","s29RDwS","zg9Nyu4","Exjqtwi","CenjEvu","CMvJzxzPzwq","CM54y0G","sKPbrNm","BKXPBMu","A1rHrei","zejksK0","yMLUyxj5vhK","y3jLyxrLrxi","sNDTz2O","reX6reS","A3jcBeC","CMvHC29U","y2XVC2u","yK5gAKO","AMzRzvy","Benfswu","Ew9QA3C","BwvZC2fNzq","runjzxy","zNPdruG","EuzwCwu","A0zlD0m","yxjYyxLIDwy","vwPcBKK","BLDctLa","Bg5Itxu","ihzHBgLKihm","tMXxCNe","BLf1uNC","BMDLza","Dg9Y","AgHuBum","Dg9iyxnO","EvjLy29UBMu","sujlvu0","C3bZyKe","AuDdzxe","zxH0zw5ZAw8","BvHAC0G","zNDZxZeUmc4","s3HKANy","B2fK","t2LSAfm","t3rhueK","yvHcCM4","Ewfwue0","uwLhuKq","z29OAhi","sLPys1O","zfHkr2S","q0Xpu0LorW","x29UrxjYB3i","BxrXy2O","y2Tpq1G","zxf1ywXZ","zwTcv0G","z2v0qwXS","x2LZqNjVD3m","Ae9Wzw5fDMu","uevJAe8","qKjLtha","CKv2sfu","yMrrt2G","BxnNsuq","z2XxExK","yLj1BLi","wg9Xr0C","Dg9hzw5LCMe","rMrLwxG","rfjXDxe","uMTguKq","qKvRwfO","A3bLBKi","rLHhEeq","x3bPBMDqB24","zuX4swi","t0LuvwK","thDnve4","igzHAwWSig0","CgLUz09Uy2u","AuzHq1K","vufsu2C","q1n4tM4","uxvLDwu","A25Ls3C","v3jvwM4","u2XNDhm","y3vYCMvUDeK","z29PBMCGyxC","CgjICdi","De5Kwgi","tMfTzq","tMvsueC","BwvKAwf0zwW","u2vYDMLJzvC","x2HHBMrSzvi","BhzmDxq","ywWGy3vYC28","zgvSzxrLrge","rvHNsKG","FdeWFdD8nNW","DMfSDwu","t2jQzwn0","DwrwAwe","sxjnwvy","uLf1uNq","x2nSzwfYvgK","C0nVDw50zxi","Bg9Nsurhzw4","y3ruAw1LB3u","zNjVBu51Bwi","C0DPsue","Bw5gwe8","yNL0zxm","BgPHqvq","zNjHBwvuExa","DhjPzxm","zNnctLC","yvjJAhi","Chv0","qKDIvvy","EffuDhe","wKrmAfK","BfLlquG","B3v0sw50zxi","sLnptLa","CMvKDwnL","wgL6wMm","C2LKBxa","B01NB0S","D1zeyue","ChbL","zxjFAxnFywm","veftDfG","Dw5XvNC","uxDTC0O","ywnRx2LK","y29UBMvJDgK","rgzqzxC","CNf3sfi","EgTHuMu","AxnmB25N","zgvJB2rLzey","x2HHBMrSzu8","DLzvt2S","yMrFzgLK","wLzWyNa","BxnN","zNHQBM8","v0rfDNa","tKjtvee","Au9bwwK","uhPOyMe","A2Hmsfq","s2Het3u","D3nZoI8V","BML0AwfSAxO","ywnRDxbfBMq","s2Xnvue","zNjVBunOyxi","twzABgW","DKfhAgq","y3vYC29Y","y3vYC29YlNm","mtG3mgLhDwn3zW","Ahr0Ca","r1rcCKu","q09oveLovuu","zhDrs0y","Efzcq3K","AxmGDw5Kzwy","BgLTAxq","tvLoBfC","yxHmuNC","wKDbu08","Du9SBgy","z2vjBMzVu3K","CMTLCKDSB2i","C2vYDMvYvgK","wMHyze4","zxjYtxnN","wfvlvMu","DeLUDgvYy2u","qw1Ku3C","z1PhwMi","ugPSy2O","zwDYue4","C29Tzq","sKjcvvC","DfrNzuW","zMLSzw5HBwu","BND6r24","wvbzv1e","y0HXs2e","tvjuEK8","zMLUza","r1LLB0y","AvzvCeC","t3j1wLG","uMvJB25Uzwm","vw5Oyw5KBgu","A1n0yxr1C0m","z2u6ia"];return io=function(){return t},io()}function dy(t,e,{blocked:r,upgrade:i,blocking:o,terminated:c}={}){let f=M,l={TAdGF:function(w,b,T,E,v){return w(b,T,E,v)},fGpQi:function(w,b){return w(b)},hLXfa:function(w,b){return w(b)},xlKru:f(1212)+f(1556),XizZc:f(415)},x=indexedDB.open(t,e),p=l[f(776)](Ct,x);return i&&x[f(1655)+f(1612)](l[f(1738)],w=>{let b=f;l[b(272)](i,Ct(x[b(1174)]),w[b(1106)+"on"],w[b(887)+"on"],l[b(1081)](Ct,x[b(1748)+b(1744)]))}),r&&x["addEvent"+f(1612)](l[f(1412)],()=>r()),p[f(901)](w=>{let b=f;c&&w[b(1655)+b(1612)](b(1297),()=>c()),o&&w[b(1655)+"Listener"](b(971)+b(1580),()=>o())}).catch(()=>{}),p}function fy(t,{blocked:e}={}){let r=M,i={AZOym:r(415),yxceF:function(c,f){return c(f)}},o=indexedDB[r(1383)+r(842)](t);return e&&o[r(1655)+r(1612)](i[r(1574)],()=>e()),i.yxceF(Ct,o)[r(901)](()=>{})}function il(t,e){let r=M,i={KgZUS:function(x,p){return x<=p},pJKWn:function(x,p){return x>=p},WkZha:function(x,p){return x+p},eLxIb:r(1178),jXAOt:r(1406),tpzoN:r(1267)+"e",mAOPw:r(957),EsNCm:function(x,p){return x instanceof p},IzGET:function(x,p){return x in p},CxUre:"string",QBbmS:function(x,p){return x===p},EPLlr:"MYDRu",TLqIr:function(x,p){return x!==p},kTTTQ:function(x,p){return x in p}};if(!(i[r(291)](t,IDBDatabase)&&!i[r(1616)](e,t)&&typeof e===i[r(247)])){if(i.QBbmS(i[r(1584)],r(861)))return;if(i.KgZUS(_0x328f04,-_0x1c956e))return _0x104932;if(i[r(711)](i[r(1155)](_0x2a3846,1),_0x13842c))return _0x58c60e}if(eo[r(930)](e))return eo.get(e);let o=e[r(503)](/FromIndex$/,""),c=i[r(652)](e,o),f=fl.includes(o);if(!i[r(899)](o,(c?IDBIndex:IDBObjectStore).prototype)||!(f||dl[r(449)](o)))return;let l=async function(x,...p){let w=r,b={ndUPB:i[w(1360)]};if(w(355)===i[w(1652)]){let T={HKnPn:b.ndUPB},E=_0x1ab9b9.buffer[w(744)](_0x5c1e58[w(480)+"et"],_0x3274df[w(706)+"th"]+_0x435945.byteOffset);this[w(854)]&&this._socket[w(868)]({data:E,fail:v=>{let I=w;this[I(412)](T.HKnPn,_0x40b246(T[I(1208)],{message:this[I(1729)+I(255)+"age"](v)}))}})}else{let T=this[w(1748)+w(1744)](x,f?i[w(759)]:i.mAOPw),E=T[w(1770)];return c&&(E=E[w(372)](p.shift())),(await Promise[w(939)]([E[o](...p),f&&T.done]))[0]}};return eo[r(363)](e,l),l}var dl,fl,eo,uy=ol({"node_modules/idb/build/index.js"(){let t=M,e={eWVej:function(r){return r()},HeMAm:function(r){return r()},hLGnl:t(769),MaYZX:t(1341),IHjpP:t(979)+"ys",OgZWx:t(931),eraVk:t(1404),rLcHq:t(329),qQcME:function(r,i){return r(i)}};e[t(1263)](rl),e[t(1604)](rl),dl=["get",e.hLGnl,e[t(624)],e.IHjpP,e[t(535)]],fl=[e[t(570)],t(541),e[t(797)],"clear"],eo=new Map,e[t(1513)](oy,r=>({...r,get:(i,o,c)=>il(i,o)||r[t(930)](i,o,c),has:(i,o)=>!!il(i,o)||r[t(731)](i,o)}))}}),ly={idb:function(t){let e=M,r={RMlzu:function(i,o){return i===o},zoXdc:e(786)+e(623)+e(540),mPaDp:function(i,o){return i!==o},idcQN:e(1519)};t[e(813)]=Promise[e(290)]()[e(901)](()=>(uy(),cl))[e(901)](function(i){let o=e,c={JcZIR:o(319)+o(646),khxnC:function(f,l){return r[o(549)](f,l)},EXgJH:r[o(362)],LpFfS:"close, w"+o(870)+o(728)+o(1441)+"ed"};if(r.mPaDp(r[o(271)],o(1519))){let f=c.JcZIR[o(428)]("|"),l=0;for(;;){switch(f[l++]){case"0":this[o(1645)+o(1017)+o(1612)]();continue;case"1":if(c[o(1646)](this._ws[o(302)+"te"],this[o(1511)])||c.khxnC(this[o(307)][o(302)+"te"],this[o(1335)]))return void this[o(510)](c[o(1384)]);continue;case"2":this[o(1391)+"mer"]();continue;case"3":this._readyClosed=!0;continue;case"4":if(!this._ws)return void this._debug(c[o(528)]);continue;case"5":this[o(961)+"ger"]?.closeDB();continue;case"6":this[o(377)+"ngTimer"]();continue;case"7":this[o(385)+o(545)+"t"](_0x4c7b70,_0x2fad85);continue}break}}else return i})}},sl={};function Tt(t){let e=M,r=(e(1603)+"1")[e(428)]("|"),i=0;for(;;){switch(r[i++]){case"0":var o=sl[t];continue;case"1":return c[e(813)];case"2":ly[t](c,c[e(813)],Tt);continue;case"3":if(o!==void 0)return o[e(813)];continue;case"4":var c=sl[t]={exports:{}};continue}break}}Tt.d=(t,e)=>{let r=K;for(var i in e)Tt.o(e,i)&&!Tt.o(t,i)&&Object["definePr"+r(507)](t,i,{enumerable:!0,get:e[i]})},(()=>{let t=M;Tt.o=(e,r)=>Object.prototype["hasOwnPr"+t(507)][t(1681)](e,r)})(),(()=>{let t=M,e={wWpCi:function(r,i){return r!=i},GeUsk:t(764)+"d",gkebd:t(1783)};Tt.r=r=>{let i=t;e[i(1683)](e.GeUsk,typeof Symbol)&&Symbol[i(1523)+i(351)]&&Object[i(1751)+"operty"](r,Symbol[i(1523)+"Tag"],{value:e[i(1779)]}),Object["definePr"+i(507)](r,i(1211)+"le",{value:!0})}})();var be={};(()=>{let t=M,e={BRdWC:function(a,n){return a(n)},pCIyU:function(a,n){return a+n},KGGED:function(a,n){return a+n},xaNqU:function(a,n){return a+n},xtzgN:function(a,n){return a===n},FFgJU:t(1282),wvtoy:t(1775),NBSTA:function(a,n){return a*n},JJAFs:function(a,n){return a===n},ZamWc:t(907),wmLsP:function(a,n){return a+n},pncRf:function(a,n,s){return a(n,s)},YvPGw:t(1546),MrSIB:"ffff",RRDwO:"timeout, try rec"+t(1752)+"g",JECVI:t(1148),uVrVi:function(a,n){return a(n)},sdvDF:t(1194)+"00000000"+t(1194)+t(1194),Fcugi:function(a,n){return a|n},akouA:function(a,n){return a===n},WJBuA:"jLHgA",hCbhS:function(a,n){return a>n},rCxDU:function(a,n){return a>n},DmXwb:function(a,n){return a!==n},cyByZ:"tKYSd",cKEsj:function(a,n){return a-n},gIZnz:function(a,n){return a<n},hpqdg:function(a,n){return a-n},DvTbQ:function(a,n){return a!==n},iDfOT:function(a,n){return a!==n},zjdlb:function(a,n){return a(n)},iaokE:function(a,n){return a>>>n},ZkXco:function(a,n,s){return a(n,s)},rORMp:function(a,n){return a&n},aaVTN:"Missing "+t(328)+t(437)+"value",vpBnj:function(a){return a()},RbgbJ:function(a,n,s){return a(n,s)},ZXGbw:function(a,n){return a(n)},GWSLr:t(1661)+t(717)+"t",VEKYH:"timeout",gsIyJ:function(a,n,s){return a(n,s)},MfZll:function(a,n){return a!==n},fuDMe:function(a,n,s){return a(n,s)},RXqkL:function(a,n){return a(n)},BmIHs:function(a,n,s){return a(n,s)},gifSV:function(a,n,s){return a(n,s)},oUwvx:function(a,n){return a!==n},bRunR:function(a,n,s){return a(n,s)},tbnoF:function(a,n){return a!==n},hunmG:function(a,n,s){return a(n,s)},XKcyc:function(a,n,s){return a(n,s)},Uoiha:function(a,n){return a!==n},gmfdS:function(a,n,s){return a(n,s)},uNyDw:function(a,n){return a!==n},ikYLc:"WWVEi",OnJPB:function(a,n,s){return a(n,s)},bIrSt:function(a,n,s){return a(n,s)},StNOT:function(a,n){return a(n)},lGQQa:function(a,n){return a(n)},YGSGZ:function(a,n){return a(n)},aYprl:function(a,n,s){return a(n,s)},RCkMQ:function(a,n){return a(n)},bdQOh:function(a,n){return a(n)},gbREo:function(a,n,s){return a(n,s)},qOYQd:function(a,n){return a(n)},dpZhm:function(a,n){return a(n)},diNzQ:function(a,n,s){return a(n,s)},ezVWr:function(a,n,s){return a(n,s)},spsbA:function(a,n,s){return a(n,s)},ECIev:"Missing "+t(328)+t(437)+t(1260),kzeUm:t(980)+t(328)+t(437)+"method",CTrdV:function(a,n,s){return a(n,s)},pvnMk:t(1178),poiMD:function(a,n){return a===n},ssPDc:t(953),KjwVI:t(277),cLnyT:function(a,n){return a&n},GFmiA:function(a,n){return a(n)},oORtd:function(a,n){return a+n},qmYEd:function(a,n){return a-n},PVsRs:function(a,n){return a|n},zJIjg:function(a,n){return a|n},LhMCA:function(a,n){return a<<n},TvHEw:function(a,n){return a&n},wPfbS:function(a,n){return a>>n},rqwHR:t(1055),ekBWH:function(a,n){return a===n},DKILX:function(a,n){return a(n)},DkZuR:"unknown "+t(1296),YPYWQ:function(a,n){return a===n},aXBrn:t(1072)+t(954),iFaCY:function(a,n){return a>=n},HYVRW:function(a,n){return a>n},BGbUV:function(a,n){return a>n},BXdJm:function(a,n){return a>n},RdTeg:t(876)+"t limit",sxlET:function(a,n,s){return a(n,s)},AULdC:function(a,n){return a+n},HYtdZ:function(a,n,s){return a(n,s)},JnCgO:function(a,n){return a+n},xsxSV:function(a,n){return a!==n},uuOCs:function(a,n){return a<<n},xXmNp:function(a,n){return a==n},tmkIA:function(a,n){return a>=n},afrYm:function(a,n){return a&n},ArOrZ:function(a,n){return a<<n},TzLhM:function(a,n){return a|n},SiZCq:function(a,n){return a<<n},qlMHp:function(a,n){return a<<n},fuehp:function(a,n){return a&n},VNHQE:function(a,n){return a<n},fxdWo:function(a,n){return a==n},wbSsJ:function(a,n){return a&n},QRtBH:function(a,n){return a>=n},WSXJn:function(a,n){return a+n},fitQK:function(a,n){return a+n},Ubapd:function(a,n){return a+n},rEvHU:function(a,n){return a&n},pWzmP:function(a,n){return a|n},FRJOf:function(a,n){return a|n},uwlNu:function(a,n){return a|n},JBBUW:function(a,n){return a|n},ctcax:function(a,n){return a|n},MYNlW:function(a,n){return a&n},EkaFD:function(a,n){return a<<n},unqVw:"gbyBC",wacjS:function(a,n){return a>>n},PCIPk:function(a,n,s){return a(n,s)},nPaMN:function(a,n,s){return a(n,s)},TBjdN:function(a,n,s,d){return a(n,s,d)},tuuYK:function(a,n){return a+n},BSsIV:function(a,n){return a(n)},XfVlV:function(a,n){return a!==n},ebvCv:t(760),hTXMR:t(602),oAnCK:function(a,n){return a>=n},wbwDR:function(a,n){return a<=n},taIyg:function(a,n){return a<n},AmdSw:function(a,n){return a+n},GUXTz:function(a,n){return a<n},jfkeV:function(a,n){return a<n},ulcRP:function(a,n,s){return a(n,s)},tVIFA:function(a,n){return a<n},iuBWs:function(a,n){return a>=n},PvubF:function(a,n){return a-n},sFyKO:function(a,n){return a<<n},TrFYm:function(a,n){return a<n},ogoHT:function(a,n){return a>>n},GMGFg:"istvH",Lsrns:function(a,n){return a|n},cISoN:function(a,n){return a&n},MoTEb:function(a,n){return a>>n},FDqDN:function(a,n){return a!==n},FWHzp:t(1116),pBGKW:"Rzskv",QiGRD:function(a,n){return a|n},EBboS:function(a,n){return a&n},lbAzr:function(a,n){return a>>n},ltAIw:function(a,n){return a&n},ZRpnT:function(a,n){return a|n},yXiSt:function(a,n){return a&n},agYgW:function(a,n,s){return a(n,s)},eOPMc:function(a,n){return a(n)},nVqMF:function(a,n){return a<n},glpQB:function(a,n){return a<<n},oDuVY:function(a,n){return a&n},VnYby:function(a,n){return a!==n},wxYSS:t(526),kprLp:function(a,n,s){return a(n,s)},WOMTS:function(a,n){return a(n)},zeHYq:function(a,n){return a&n},Tnmuj:function(a,n){return a&n},huPFk:function(a,n){return a&n},WUTxT:function(a,n){return a&n},rDFCH:function(a,n){return a<<n},OOxGK:function(a,n){return a&n},oMgoK:function(a,n){return a<<n},OxiUi:function(a,n){return a&n},fiMHN:function(a,n){return a<<n},uizoc:function(a,n){return a&n},ltooY:function(a,n){return a(n)},zGiSe:function(a,n){return a&n},rjKbV:function(a,n){return a&n},nnMwH:function(a,n){return a&n},KJezY:function(a,n){return a<<n},tTgeL:function(a,n){return a|n},HgJsb:function(a,n){return a>>>n},ulGcy:function(a,n){return a>>>n},EuNWn:function(a,n){return a>>>n},zphIZ:function(a,n){return a===n},cHqKa:function(a,n){return a<n},QLwTr:function(a,n,s){return a(n,s)},GCkby:function(a,n){return a+n},niCDo:function(a,n){return a+n},Bhouo:function(a,n){return a|n},DJrib:function(a,n){return a&n},Kokuk:function(a,n){return a>>>n},DZUiR:function(a,n){return a>>>n},ttlqE:function(a,n){return a>>>n},MrOQA:function(a,n){return a|n},mWVjy:function(a,n){return a>>>n},ZAzSH:function(a,n){return a!==n},vAJNW:function(a,n){return a&n},IKOqb:function(a,n){return a>>>n},wYVwq:function(a,n){return a>>>n},nYbly:function(a,n){return a!==n},mpsvJ:function(a,n){return a|n},yQNzq:function(a,n){return a(n)},hTlhT:t(716),toGST:t(419),OITUi:function(a,n){return a(n)},FBPfQ:function(a,n){return a|n},ByIwQ:function(a,n){return a(n)},mOaXP:t(1564),TbCoR:t(724),NWABW:t(788),Fdozb:t(420),DXrER:function(a,n){return a<<n},gVvxm:function(a,n){return a<<n},lbnds:function(a,n){return a===n},aogey:function(a,n){return a|n},CaikW:function(a,n){return a>>>n},gwdpm:function(a,n){return a|n},ccJEa:function(a,n){return a|n},lIqOw:function(a,n){return a<<n},MRTzO:function(a,n){return a&n},OikQq:function(a,n){return a>>>n},yxnOv:function(a,n){return a&n},oQKLD:function(a,n){return a>>>n},PUtyB:function(a,n){return a&n},twlbF:function(a,n){return a&n},vrVBc:function(a,n){return a>>>n},MnFUE:function(a,n){return a!==n},BzIMW:"AtUJX",DpmJJ:function(a,n){return a%n},HXMLz:function(a,n){return a|n},hboLE:function(a,n){return a/n},WbFAK:"bEJta",NedSl:t(1599),xHcFe:function(a,n){return a>>>n},uuDnB:function(a,n){return a*n},cQfTC:function(a,n){return a&n},yrPMb:function(a,n){return a>>>n},CyURY:function(a,n){return a+n},CQylY:function(a,n){return a>>>n},iGCeq:function(a,n){return a|n},HDTHu:function(a,n){return a===n},vUJAh:function(a,n){return a===n},WirhG:function(a,n){return a===n},QaTSt:function(a,n){return a===n},kFKwC:function(a,n){return a===n},sJCFT:function(a,n){return a+n},CpkYd:function(a,n){return a+n},aCdpk:function(a,n){return a&n},Zugpr:function(a,n){return a>>>n},bskXJ:function(a,n){return a>>>n},Xfpvi:function(a,n){return a&n},WgCdk:function(a,n){return a>>>n},PTjpz:function(a,n){return a>>>n},GMTNy:"close",qUoeo:"HVZKA",GiqAr:function(a,n){return a>>>n},jOvbE:function(a,n){return a>>>n},qouGO:function(a,n){return a&n},dWLuz:function(a,n){return a>>>n},ATBUr:t(368)+t(1529),ehPlf:t(375)+t(1168),ILypA:t(772)+t(261)+"R",myJMz:t(383)+t(1659),ttRue:t(1742)+"OR",YVTFC:"0|5|1|3|"+t(1777),VYfga:t(1617),mPuMh:t(225)+"ascript",hNDRA:t(250)+"ack=fron"+t(386)+"P",MXKnd:t(833),ReFYd:t(1149),NIWAp:t(1721)+"2",MAmqy:function(a,n){return a>>n},RrLtb:t(846),oKeKj:t(474),iOAYi:function(a,n){return a||n},Pzhba:function(a,n){return a!=n},BBeLp:t(764)+"d",Pwrvg:function(a,n){return a===n},dFEbN:t(1189),mxOiY:t(742),ETjNT:t(318),JUzSo:function(a,n){return a-n},wlCoL:function(a,n){return a>n},Schlh:function(a,n){return a+n},NMQbN:"NTORH",zmHgR:function(a,n){return a!==n},yhwaC:t(904),sHxBz:function(a,n){return a instanceof n},wwwcb:t(1485)+t(1731),jePkw:"UZUAm",gHuEq:function(a,n){return a!==n},YABxs:"aKJai",aRchr:t(1e3),mVrRi:function(a,n){return a(n)},LSkMd:function(a,n){return a===n},RmeiX:t(1757),rrkRR:t(1632),ssyVN:function(a,n){return a+n},lzvBP:function(a,n){return a===n},JgsFR:t(1673),YABKy:t(1302),PEchO:function(a,n,s){return a(n,s)},kIzaI:"ZXvLG",PDkOc:function(a,n){return a<n},VyWwR:t(640),eYMmd:t(858),gvxzX:"CbaVW",lshvh:t(787),IvIUn:function(a,n){return a||n},dsqPt:t(460)+"alled mu"+t(1536)+t(1555)+"process",bIVRY:function(a,n){return a<n},pdbuN:function(a,n){return a+n},WownL:function(a,n){return a!==n},WAlNT:function(a,n){return a<n},RTUgY:function(a,n){return a<n},YkhNx:function(a,n){return a===n},kvibV:function(a,n){return a&n},sIdxg:function(a,n){return a<n},YiEKN:function(a,n){return a>>n},CNuFm:function(a,n){return a<n},dBJJM:function(a,n){return a>>n},WPVfL:function(a,n){return a<n},GxNkr:t(494),EPhJq:function(a,n){return a>=n},qzgPp:function(a,n){return a<n},WBihg:function(a,n){return a|n},mnFXO:function(a,n){return a<<n},wqgcc:function(a,n){return a&n},LyOAg:function(a,n){return a&n},GYzij:function(a,n){return a>=n},XFKGm:function(a,n){return a<<n},JdmMg:function(a,n){return a>=n},BIoVl:function(a,n){return a-n},jxCck:function(a,n){return a|n},xkaRe:function(a,n){return a<<n},tuHyz:function(a,n){return a<<n},ZhXdN:function(a,n){return a&n},dEhsF:function(a,n){return a<<n},Xhqgr:function(a,n){return a+n},FCZvR:function(a,n){return a+n},fGtLv:function(a,n){return a<n},CUekI:function(a,n){return a<n},ghKGo:function(a,n){return a|n},NeRPG:function(a,n){return a>>n},Kwfmb:function(a,n){return a===n},BCjSK:function(a,n){return a&n},cbPxF:function(a,n){return a+n},dcLnh:function(a,n){return a+n},KFDrr:function(a,n){return a&n},XYfVG:function(a,n){return a|n},GTcfX:function(a,n){return a&n},gJFxg:function(a,n){return a&n},Zmhgj:function(a,n){return a==n},XfImb:"string",PEvIh:"blocked",ffzWf:function(a,n){return a!=n},TqyDc:function(a,n){return a instanceof n},kHMEt:function(a,n){return a instanceof n},EQMls:t(443),sGiIA:t(607)+t(1184)+t(1794),sejaZ:t(1710),mlnDc:t(1416),IazKQ:function(a,n){return a(n)},JrLyA:t(1450),yfEPj:function(a,n){return a(n)},ViMvP:function(a,n){return a(n)},TMQmi:"pkiui",hvBTm:"idb",jipvV:function(a){return a()},ckOCX:function(a,n,s,d){return a(n,s,d)},FwZaD:"mCjrz",SgitK:t(559),CoCcY:t(1666),oGOni:"offline",yEzwM:t(565),FnraZ:function(a,n,s,d){return a(n,s,d)},VsPjO:t(1706)+t(1509)+"ck",izeCC:function(a,n,s,d){return a(n,s,d)},ORWQR:function(a,n){return a===n},VUbmj:t(1079),JQpha:function(a,n){return a===n},btloR:"LUzkC",XoSxb:t(1040),eGdXD:t(932),ivnpU:"fDFaL",pEAKE:t(1415),PIDtu:"EHbjy",vhPXI:t(725),gDoRs:t(1408),OCBdG:function(a,n){return a||n},VtMWT:function(a,n){return a||n},yClhn:function(a,n,s){return a(n,s)},Ebute:function(a,n,s){return a(n,s)},VzqDC:t(909),pfMrc:function(a,n){return a+n},NazLY:function(a,n){return a+n},yrReP:t(1090)+t(789)+t(1487),fpkFc:" > ",MtWVX:t(1390),ZVpbp:function(a,n){return a||n},wyRCX:t(1651)+t(1014)+"d",rtVqa:t(498),SfjwP:t(1228)+"id",cRnuK:t(793),TaEzh:t(1446),AMnOq:function(a,n){return a===n},jUoGR:t(1366),cjsrp:function(a,n){return a(n)},HnlZX:"hVeNe",fSgYe:"jAygu",EshiE:function(a,n){return a===n},JxfKj:t(1739)+t(563),asMfQ:function(a,n){return a(n)},Oirhg:t(1169),TAStX:function(a,n,s,d){return a(n,s,d)},dwQKF:t(1706)+t(990),oNjEm:function(a,n,s,d){return a(n,s,d)},hsazT:t(1706)+"er_is_ack",sHNKQ:"x_fronti"+t(597)+t(558),YZlvM:function(a,n){return a===n},bLQXo:t(1349),RkFRD:function(a,n,s,d){return a(n,s,d)},VUBER:"need_ack",MevCV:t(1160),UaESz:function(a,n){return a&&n},OilhS:t(1421),LdAmR:t(1784),hjkIF:function(a){return a()},yCErD:"xaaQY",ZJQom:function(a,n){return a instanceof n},ZKqFi:t(863)+t(802),RBMeA:"application/json"+t(936)+t(1705),wQdxF:t(1038)+"e",htDXM:function(a){return a()},jIzGu:function(a,n){return a<n},cegEs:function(a,n){return a&n},rnxcH:"CfdZb",sVeia:t(1694),Tcxmk:function(a,n){return a(n)},KGmKc:function(a,n){return a+n},jQduX:function(a,n){return a(n)},KlMUA:function(a,n){return a|n},nwzGn:function(a,n){return a>>>n},kegDU:function(a,n){return a(n)},OMQIi:function(a,n){return a+n},GtDNc:function(a,n){return a+n},QtUCF:function(a,n){return a||n},cZdBG:t(1559)+t(267)+"e",TGAva:function(a,n){return a>=n},fvLDc:t(741),CrErz:function(a,n){return a+n},UUkMA:function(a,n){return a>>n},gQrBU:function(a,n){return a+n},fDVxb:function(a,n){return a|n},nMzau:function(a,n){return a&n},fQFxN:function(a,n){return a|n},vkJOH:function(a,n){return a&n},yaVPM:function(a,n){return a|n},kemtK:function(a,n){return a!==n},fEytu:"VcYno",kpenB:"FkiGU",mtqcj:function(a,n,s){return a(n,s)},thodA:function(a,n){return a(n)},xemFa:t(1193)+"ile_name",ABfQZ:t(1736),wSqhD:t(344),uIQrf:t(1692)+t(344),lLUyv:t(1221),CAWsn:t(740)+"3",evwCx:function(a,n){return a+n},iVUpG:function(a,n){return a+n},AzCmE:function(a,n,s,d){return a(n,s,d)},YtOAH:function(a,n){return a+n},OruZX:function(a,n){return a|n},ekcSL:function(a,n){return a<<n},GMNkl:function(a,n){return a<<n},RyGiU:function(a,n){return a+n},YSUmP:function(a,n){return a+n},NbvWI:function(a,n){return a|n},GjajT:function(a,n){return a<<n},PIfKJ:function(a,n){return a+n},yxdhh:function(a,n){return a>>>n},Vuqan:function(a,n){return a&n},afofL:function(a,n){return a>>>n},ZGRqo:function(a,n){return a+n},eqrAd:function(a,n){return a&n},hrJgo:function(a,n){return a+n},Pccql:function(a,n){return a>>>n},LwMTN:function(a,n){return a+n},sfBhs:function(a,n){return a+n},ASeAS:function(a,n){return a!==n},gZGZb:t(348),Vgqdp:t(1010),YZsew:function(a,n){return a&n},dLARY:function(a,n){return a+n},ECWAY:function(a,n){return a&n},SLHKD:function(a,n){return a|n},vKXBC:function(a,n){return a<n},CaiKG:function(a,n){return a<<n},ItqrS:t(600)+t(280)+t(890),BEkXZ:t(972),pYbsw:"curvalue",nRDwg:function(a,n,s,d){return a(n,s,d)},CIXcD:function(a,n,s,d){return a(n,s,d)},CPQzl:function(a,n,s,d){return a(n,s,d)},JlVDh:function(a,n){return a(n)},yXNbp:function(a,n){return a(n)},VlmNV:function(a,n,s){return a(n,s)},HmklS:function(a,n,s){return a(n,s)},LMdVt:function(a,n,s,d){return a(n,s,d)},DYGbo:function(a,n){return a+n},kwBvL:t(1112)+"_EXIST",OSTvy:t(1272)+"ame",AsaFs:function(a,n){return a>=n},uIqiv:t(844),kneKw:t(594)+t(502),yjpJY:"ALL",lnbMu:function(a,n,s,d){return a(n,s,d)},MMtBL:t(779),yyZIL:"CONTINUE",UmNLS:function(a,n){return a===n},TtfPR:t(1664),eXtpV:"oiwdA",IJYPN:"setcursor",EfHKY:t(1080),SsXkz:t(1661)+t(913)+"s",kyomT:function(a,n){return a||n},zfiLL:t(1071),Wseld:t(659),QbXmW:function(a,n,s,d){return a(n,s,d)},adPMP:t(1706)+t(285),MGBqF:function(a,n,s){return a(n,s)},gauXb:t(1706)+"er_ttl",DRquq:function(a,n,s,d){return a(n,s,d)},tJmIL:t(334)+"rsor_name",wVPxz:function(a,n){return a(n)},AyHXI:t(334)+"rsor_value",GhddA:function(a){return a()},tkOkK:function(a,n){return a<n},ssAbm:function(a){return a()},Nkjsg:function(a){return a()},XUKVe:function(a,n){return a===n},BhiRU:function(a,n){return a&&n},LlvaE:function(a){return a()},csQFG:function(a){return a()},wjrfs:function(a,n){return a(n)},Pjlcj:function(a,n){return a+n},fIgJz:"TLmFw",zxRSR:function(a,n){return a===n},wXuum:function(a,n){return a!==n},gjMXJ:t(1202),mTHWk:t(555),TAuYl:function(a,n,s){return a(n,s)},xAeTN:t(1187),DfPew:t(719),vSQlZ:function(a,n){return a+n},xVBCy:function(a,n){return a+n},NXaqw:"always",zhllq:t(1662),LbliH:function(a,n,s){return a(n,s)},pZbta:function(a,n){return a===n},NPPQa:t(538),GYeoF:t(1307)+t(737),zaVHq:function(a,n){return a===n},uJKVE:t(311)+t(677)+"alid url",mLBhL:function(a,n,s){return a(n,s)},JMkiD:t(662)+"t",lpfdk:"stop immediately"+t(295)+"ct",krBlG:"online",fzCEH:"pagehide",WVgfc:t(408),zxyBy:t(553),CTuvQ:function(a,n,s){return a(n,s)},YegFE:"GfBZM",lfmHn:function(a,n){return a!==n},hhTmC:t(1440),KZiKx:"ws://",iTufC:function(a,n){return a!==n},TcFxP:"mSUmf",jfauZ:t(1430),GPKEL:t(1279),FKtyX:"device_id",MPwNl:function(a,n){return a||n},LqdGN:t(311)+t(282)+t(327)+t(647)+t(962),IDRQx:function(a,n){return a==n},NECbm:"function",GSByk:function(a,n,s){return a(n,s)},ZwUVd:"web",AMTNJ:t(1324)+"0",OQNQf:function(a,n){return a<<n},Ghfjg:function(a,n){return a(n)},BSQOH:function(a,n){return a&n},KzMHG:function(a,n){return a&n},Uhqmj:function(a,n){return a!==n},RFMWC:function(a,n,s,d){return a(n,s,d)},QPFxi:t(1128),yFIYj:t(790),mGiAV:t(339),Gqcar:function(a,n,s){return a(n,s)},FnCbH:function(a,n){return a||n},OQwuE:t(407),gxVip:function(a,n){return a-n},QYHnR:function(a,n,s){return a(n,s)},uOllf:function(a,n){return a(n)},CUqgc:"FRONTIER>",gTTTN:function(a,n){return a+n},cDiMb:function(a,n){return a!==n},jjuDu:t(1251),bncxL:function(a,n){return a>n},RdhDt:function(a,n,s){return a(n,s)},XaOOD:function(a,n){return a!==n},bqbUz:t(414),MVlMo:function(a,n){return a!==n},mwQtt:function(a,n){return a===n},TyfRM:t(1170),mMvWQ:"lgNIG",iJEOq:t(1592),jkzFV:t(1797),MKOte:"2|3|1|4|0",AjWxh:function(a,n,s){return a(n,s)},IBKUM:t(1420),xlOGN:"VrzJb",eTGtt:t(1798),GWxWv:t(1211)+"le",PJfOk:t(325),MWgeM:"LyOLS",ZknOK:function(a,n){return a+n},ztCjM:function(a,n){return a===n},qgwpJ:t(786)+t(623)+t(540),dgwnp:function(a,n,s){return a(n,s)},SrqBf:t(548),TItMk:function(a,n){return a==n},pEPGE:"please p"+t(1658)+t(1002)+"ata, dat"+t(373)+"e a string or an"+t(1252)+t(791),yojkw:function(a,n){return a instanceof n},iHOPH:function(a,n){return a(n)},OkHEM:function(a,n){return a(n)},PzMzg:function(a,n){return a(n)},sWYSF:function(a,n){return a||n},dXJGk:t(311)+"rovide a"+t(1311)+"ervice",WmEPv:t(394),TlGqx:function(a,n){return a<n},RABUx:t(392),BceAH:"CsJoK",OyADY:function(a,n){return a||n},HabhV:t(579)+"2",hhYZy:"phrCu",fALNl:function(a,n){return a(n)},JUtHK:function(a,n,s){return a(n,s)},YmoRp:t(604),vHwRi:function(a,n){return a!=n},gqvQt:function(a,n){return a===n},zxTFn:t(1054),rQyvU:function(a,n){return a===n},sidmp:function(a,n){return a!=n},SxGEM:function(a,n){return a!=n},zbmXe:"Dedicate"+t(712)+t(886)+"pe",mmPDA:function(a,n){return a===n},tQXDt:function(a,n){return a==n},qDdlY:function(a,n){return a!=n},fVZzd:function(a,n){return a===n},HUqqc:function(a,n){return a===n},SpDKN:t(1033)+t(1462)+t(444),BsTow:t(1379)+t(276)+t(1639),reTwL:function(a,n){return a!=n},WgoUh:t(1387),qiFNl:function(a,n){return a!=n},Jntnr:t(222)+t(1521)};Tt.r(be),Tt.d(be,{FWS:()=>zh,CustomErrorEvent:()=>x0,createCloseEvent:()=>ct,ReconnectEvent:()=>l0,createErrorEvent:()=>Qe,decodedFrame:()=>Bn,createOpenEvent:()=>_0,CustomCloseEvent:()=>h0,createReconnectEvent:()=>Po,FrontierMessageEvent:()=>g0,encodeFrame:()=>je,createMessageEvent:()=>w0,OpenEvent:()=>m0,ErrorCode:()=>Kt,Event:()=>Fn,MessageEvent:()=>p0});let r="";function i(a=""){let n=t,s="02",d=""+Date[n(462)](),u=r||(r=e.BRdWC(x,a)),g=Math[n(568)]()[n(1523)](16)[n(744)](-6);return e.pCIyU(e.KGGED(e[n(1672)](s,d),u),g)}function o(){let a=t;return e.xtzgN(e.FFgJU,e[a(1488)])?{bytes:_0x23d0e5,offset:0,limit:_0x226898[a(1764)]}:e[a(1672)](e[a(1435)](1e4,Date[a(462)]()),Math.floor(e[a(1435)](1e4,Math[a(568)]())))}function c(a){let n=t;return e[n(1287)](e.ZamWc,e[n(406)])?e.KGGED(e[n(911)](Array,8)[n(610)]("0"),parseInt(a,10)[n(1523)](2)).slice(-8):_0x1de661||(_0x1f6615=[_0xd19de.prototype[n(1046)],_0x1d2ec0.prototype.continue,_0xa51755[n(910)+"e"]["continue"+n(493)+"ey"]])}function f(a){let n=t;return e[n(951)](Array(4)[n(610)]("0"),e[n(532)](parseInt,a,2)[n(1523)](16))[n(744)](-4)}function l(a){let n=t,s=a[n(428)](/\./)[n(1004)](g=>c(g)),d=[];return d[0]=f(e[n(686)](s[0],s[1])),d[1]=f(e.pCIyU(s[2],s[3])),["0000",e.YvPGw,e[n(856)],e[n(856)],e[n(856)],e[n(754)],d[0],d[1]].join("")}function x(a){let n=t;if(e.JECVI!=="nhhhT"){let s=/(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}/[n(588)](a),d=/(([0-9a-fA-F]{1,4}:){7,7}[0-9a-fA-F]{1,4}|([0-9a-fA-F]{1,4}:){1,7}:|([0-9a-fA-F]{1,4}:){1,6}:[0-9a-fA-F]{1,4}|([0-9a-fA-F]{1,4}:){1,5}(:[0-9a-fA-F]{1,4}){1,2}|([0-9a-fA-F]{1,4}:){1,4}(:[0-9a-fA-F]{1,4}){1,3}|([0-9a-fA-F]{1,4}:){1,3}(:[0-9a-fA-F]{1,4}){1,4}|([0-9a-fA-F]{1,4}:){1,2}(:[0-9a-fA-F]{1,4}){1,5}|[0-9a-fA-F]{1,4}:((:[0-9a-fA-F]{1,4}){1,6})|:((:[0-9a-fA-F]{1,4}){1,7}|:)|fe80:(:[0-9a-fA-F]{0,4}){0,4}%[0-9a-zA-Z]{1,}|::(ffff(:0{1,4}){0,1}:){0,1}((25[0-5]|(2[0-4]|1{0,1}[0-9]){0,1}[0-9])\.){3,3}(25[0-5]|(2[0-4]|1{0,1}[0-9]){0,1}[0-9])|([0-9a-fA-F]{1,4}:){1,4}:((25[0-5]|(2[0-4]|1{0,1}[0-9]){0,1}[0-9])\.){3,3}(25[0-5]|(2[0-4]|1{0,1}[0-9]){0,1}[0-9]))/[n(588)](a);return s?e[n(527)](l,a):d?p(a):e[n(1644)]}else{let s=this["_endpoin"+n(533)]?.[n(244)+n(1025)+"nt"]();this[n(510)](n(240)+s+n(864)),this[n(1026)+n(1223)](1001,e[n(663)],!0)}}function p(a){let n=t,s={bNFjJ:function(d,u){return d|u},igblh:function(d,u){return d>>u}};if(e[n(885)](n(251),e[n(552)])){let d="",u=[],g=0,_=0,m=!0,h=n(1546);if(e[n(1675)](a.indexOf("::"),-1)){let S=a[n(428)]("::");for(let B=0;B<S[n(1764)];B++){let H=S[B];if(e.rCxDU(H.indexOf(":"),0)){let j=H[n(428)](":");m&&(g=j[n(1764)]),_+=j[n(1764)];for(let V=0;V<j[n(1764)];V++)if(e[n(1156)](4,j[V][n(1764)])){let We=h[n(965)+"g"](0,4-j[V].length),et=We[n(1171)](j[V]);u.push(et)}else u[n(405)](j[V]);m=!1}else{if(e[n(1156)](4,H[n(1764)]))if(e[n(1156)](e[n(256)],e[n(256)]))_0x23fc13[_0x528582++]=s[n(1298)](s[n(473)](_0x1da250,18)&7,240),_0x595151[_0x2b3111++]=_0x11968d>>12&63|128;else{let j=h.substring(0,e[n(1276)](4,H[n(1764)])),V=j[n(1171)](H);u[n(405)](V)}else u[n(405)](H);m&&(g+=1),_+=1,m=!1}}let R="";for(let B=0;e[n(827)](B,8-_);B++)R=R[n(1171)](h);for(let B=0;e[n(827)](B,u[n(1764)]);B++)e[n(1553)](B,g)?(d=d.concat(R),d=d.concat(u[B])):d=d[n(1171)](u[B]);return d}{let S=a[n(428)](":");for(let R=0;R<S.length;R++){let B=S[R];if(S[R][n(1764)]!==4){let H=h[n(965)+"g"](0,e[n(299)](4,S[R].length)),j=H[n(1171)](B);d=d[n(1171)](j)}else d=d.concat(B)}return d}}else this[n(1426)]=!0,this[n(1133)]=e[n(1724)](0,_0x4f4c5f),this[n(1548)]=0|_0x4cd624,this.unsigned=!!_0x222260}function w(a,n){let s=t,d=a.key;e[s(488)](void 0,d)&&(e.pncRf(Z,n,10),e.pncRf(Oe,n,d));let u=a[s(1386)];e[s(515)](void 0,u)&&(e[s(532)](Z,n,18),e.pncRf(Oe,n,u))}function b(a){let n=t,s={};e:for(;!e.zjdlb(N,a);){let d=_e(a);switch(e.iaokE(d,3)){case 0:break e;case 1:s.key=e[n(532)](we,a,e[n(911)](_e,a));break;case 2:s[n(1386)]=e[n(1152)](we,a,e[n(781)](_e,a));break;default:k(a,e.rORMp(7,d))}}if(s[n(1091)]===void 0)throw new Error(n(980)+n(328)+n(437)+n(1091));if(e[n(1553)](void 0,s[n(1386)]))throw new Error(e[n(1240)]);return s}function T(a){let n=t,s=e[n(1262)](C);return e[n(1554)](E,a,s),e[n(1565)](z,s)}function E(a,n){let s=t,d=a[s(1260)];d!==void 0&&(Z(n,8),e[s(1152)](ge,n,d));let u=a[s(1720)];e[s(488)](void 0,u)&&(e[s(544)](Z,n,16),ge(n,u));let g=a[s(1736)];e.MfZll(void 0,g)&&(e[s(532)](Z,n,24),e[s(1152)](ge,n,e.zjdlb(O,g)));let _=a[s(952)];e[s(1156)](void 0,_)&&(e[s(713)](Z,n,32),ge(n,e[s(897)](O,_)));let m=a[s(619)];if(m!==void 0)for(let We of m){e[s(634)](Z,n,42);let et=C();e[s(1554)](w,We,et),e[s(1622)](Z,n,et[s(1456)]),at(n,et),e[s(897)](L,et)}let h=a[s(427)+s(1144)];e.oUwvx(void 0,h)&&(e.bRunR(Z,n,50),Oe(n,h));let S=a[s(1185)+s(326)];e.tbnoF(void 0,S)&&(e[s(1243)](Z,n,58),e[s(369)](Oe,n,S));let R=a[s(300)];e[s(1788)](void 0,R)&&(e[s(592)](Z,n,66),Z(n,R[s(1764)]),e[s(1622)](fe,n,R));let B=a[s(949)];e[s(515)](void 0,B)&&(e[s(461)](e[s(1654)],e.ikYLc)?(this[s(641)+s(1392)]?.[s(606)](),this[s(412)](e[s(354)],e.VEKYH),this[s(641)+s(1392)]?.[s(1626)+s(1273)+"nt"]()?this[s(1380)+s(891)]():this._ping()):(Z(n,74),e[s(969)](Oe,n,B)));let H=a[s(1463)+"ming"];e.DvTbQ(void 0,H)&&(e.bRunR(Z,n,82),Oe(n,H));let j=a[s(1348)];e[s(1788)](void 0,j)&&(e.fuDMe(Z,n,90),e[s(544)](Oe,n,j));let V=a.frameType;V!==void 0&&(e[s(880)](Z,n,96),ge(n,e[s(527)](O,V)))}function v(a){let n=t;return e[n(992)](I,e[n(281)](F,a))}function I(a){let n=t,s={};e:for(;!N(a);){let d=e[n(696)](_e,a);switch(d>>>3){case 0:break e;case 1:s[n(1260)]=e.aYprl(Mn,a,!0);break;case 2:s[n(1720)]=Mn(a,!0);break;case 3:s[n(1736)]=e.RCkMQ(_e,a);break;case 4:s[n(952)]=_e(a);break;case 5:{let u=e[n(1347)](A,a);(s[n(619)]||(s[n(619)]=[]))[n(405)](e.zjdlb(b,a)),a[n(1456)]=u;break}case 6:s[n(427)+n(1144)]=e[n(727)](we,a,e[n(1217)](_e,a));break;case 7:s[n(1185)+n(326)]=e[n(634)](we,a,e[n(310)](_e,a));break;case 8:s.payload=e.diNzQ(se,a,e[n(696)](_e,a));break;case 9:s[n(949)]=e[n(1243)](we,a,_e(a));break;case 10:s.serverTiming=e.bIrSt(we,a,e[n(696)](_e,a));break;case 11:s[n(1348)]=e.ezVWr(we,a,e[n(781)](_e,a));break;case 12:s[n(1400)+"e"]=e[n(781)](_e,a);break;default:e[n(1320)](k,a,7&d)}}if(e[n(1287)](void 0,s[n(1260)]))throw new Error(e[n(1303)]);if(e[n(1553)](void 0,s[n(1720)]))throw new Error(n(980)+n(328)+n(437)+"LogID");if(e.akouA(void 0,s[n(1736)]))throw new Error(n(980)+n(328)+" field: "+n(1736));if(s[n(952)]===void 0)throw new Error(e[n(667)]);return s}function A(a){let n=t,s=_e(a),d=a[n(1456)];return a[n(1456)]=a[n(262)]+s,d}function k(a,n){let s=t,d={noPXO:function(u,g,_){return e[K(984)](u,g,_)},xZmPy:e[s(1544)],JJVJA:s(1297)};if(e.poiMD(e[s(815)],e.KjwVI))_0x399aba[s(290)]()[s(901)](()=>{let u=s,g=d.noPXO(_0x2245bb,u(1178),{message:this[u(1729)+u(255)+u(762)](_0x5b65af)});this[u(412)](d[u(1714)],g);let _=d.noPXO(_0x53abc8,d.JJVJA,{reason:this[u(1729)+u(255)+"age"](_0x4b49cb)});this.emit(d[u(1510)],_)});else switch(n){case 0:for(;e.cLnyT(128,e[s(947)](Ae,a)););break;case 2:e[s(727)](P,a,_e(a));break;case 5:e[s(727)](P,a,4);break;case 1:P(a,8);break;default:throw new Error(e[s(409)](s(673)+"ented ty"+s(958),n))}}function O(a){return a|=0,{low:a,high:a>>31,unsigned:a>=0}}let y=[];function C(){let a=t,n=y[a(1647)]();return n?(n[a(262)]=n[a(1456)]=0,n):{bytes:new Uint8Array(64),offset:0,limit:0}}function L(a){y[t(405)](a)}function F(a){return{bytes:a,offset:0,limit:a[t(1764)]}}function z(a){let n=t;if(e[n(657)](e[n(1424)],e.rqwHR)){let s=e[n(1186)](e[n(283)](e[n(1699)](e[n(1699)](e.cLnyT(7,_0x5af5db)<<18,e[n(1494)](63,_0x2861e4[_0x3861c4++])<<12),e[n(889)](e[n(1591)](63,_0x32110a[_0x2c00ed++]),6)),e[n(940)](63,_0x3ce8fc[_0x5e8d1a++])),65536);_0xe1bdc4+=_0x15249e[n(1444)+n(906)](e[n(1672)](55296,e[n(304)](s,10))),_0x38b30f+=_0x2cfa3b[n(1444)+n(906)](e[n(686)](56320,1023&s))}else{let s=a[n(1398)],d=a.limit;return e[n(1340)](s.length,d)?s:s[n(1671)](0,d)}}function P(a,n){let s=t,d={uQFbU:function(u,g){return e.DKILX(u,g)},DWyGK:e[s(998)]};if(e[s(1477)](s(631),s(631))){if(a.offset+n>a[s(1456)])throw new Error(e[s(1329)]);a[s(262)]+=n}else _0x5eb6fe[s(756)][s(359)+s(617)](_0xdcf46e),_0x418314[s(306)+s(1410)]=void 0,d[s(245)](_0x143ee0,_0x2ad8b4&&_0x19b330.msg||d[s(1596)])}function N(a){let n=t;return e[n(1365)](a.offset,a[n(1456)])}function U(a,n){let s=t,d=a[s(1398)],u=a.offset,g=a[s(1456)],_=e.oORtd(u,n);if(e[s(1056)](_,d[s(1764)])){let m=new Uint8Array(e[s(1435)](2,_));m.set(d),a[s(1398)]=m}return a.offset=_,e[s(1405)](_,g)&&(a[s(1456)]=_),u}function $(a,n){let s=t,d=a.offset;if(e[s(1142)](d+n,a[s(1456)]))throw new Error(e[s(994)]);return a[s(262)]+=n,d}function se(a,n){let s=t,d=e[s(455)]($,a,n);return a.bytes[s(1671)](d,e[s(683)](d,n))}function fe(a,n){let s=t,d=e[s(880)](U,a,n.length);a.bytes[s(363)](n,d)}function we(a,n){let s=t,d={ICMWB:function(S,R){return e.Uoiha(S,R)}},u=e.HYtdZ($,a,n),g=String[s(1444)+s(906)],_=a[s(1398)],m="\uFFFD",h="";for(let S=0;e[s(827)](S,n);S++){let R=_[S+u],B,H,j,V;e.poiMD(e[s(1591)](128,R),0)?h+=e[s(911)](g,R):e.cLnyT(224,R)===192?e.iFaCY(e[s(1541)](S,1),n)?h+=m:(B=_[e[s(683)](S+u,1)],e[s(512)](e[s(940)](192,B),128)?h+=m:(V=e.uuOCs(31&R,6)|e[s(1494)](63,B),V<128?h+=m:(h+=e[s(1565)](g,V),S++))):e[s(1127)](e[s(1591)](240,R),224)?e.tmkIA(S+2,n)?h+=m:(B=_[e.pCIyU(S+u,1)],H=_[e[s(409)](S+u,2)],e[s(657)](e[s(1581)](e[s(283)](B,e[s(750)](H,8)),49344),32896)?h+=m:(V=e.TzLhM(e[s(283)](e[s(1549)](15&R,12),e[s(1086)](e[s(1734)](63,B),6)),e[s(1591)](63,H)),e[s(873)](V,2048)||e[s(1365)](V,55296)&&V<=57343?h+=m:(h+=e[s(1217)](g,V),S+=2))):e[s(332)](e[s(1590)](248,R),240)?e[s(1491)](S+3,n)?h+=m:(B=_[e[s(686)](e[s(1672)](S,u),1)],H=_[e[s(1230)](S,u)+2],j=_[e[s(1137)](e.Ubapd(S,u),3)],e[s(1346)](e[s(973)](e[s(1641)](B,H<<8),j<<16),12632256)!==8421504?h+=m:(V=e.uwlNu(e[s(1473)](e.ctcax(e.cLnyT(7,R)<<18,e[s(1549)](e.MYNlW(63,B),12)),e[s(485)](63&H,6)),63&j),V<65536||e.BXdJm(V,1114111)?h+=m:e[s(1419)]===e.unqVw?(V-=65536,h+=g(e[s(1578)](V,10)+55296,e[s(951)](e[s(1590)](1023,V),56320)),S+=3):_0x4328f6[s(330)+"d"]&&(this["_navigat"+s(1250)]()&&(!this._ws||this[s(307)][s(302)+"te"]!==this.OPEN||d.ICMWB(this[s(307)].readyState,this[s(375)+"NG"]))&&this["_handleO"+s(1288)](),this._isBrowser&&_0x3d8d31[s(1655)+s(1612)]("online",this[s(1428)+s(1288)]),this[s(1342)+"er"]&&_0x32fefd[s(1655)+s(1612)]("offline",this["_handleO"+s(1236)])))):h+=m}return h}function Oe(a,n){let s=t,d={MTVPR:function(u,g){return e.VNHQE(u,g)},mXZsH:function(u,g){return e[K(796)](u,g)},HHCCo:function(u,g){return e[K(748)](u,g)},nZxnh:function(u,g){return e.HYVRW(u,g)},reynG:function(u,g){return e[K(1060)](u,g)},lGUdZ:function(u,g){return e[K(1591)](u,g)},ARoWq:function(u,g){return e[K(1674)](u,g)}};if(e[s(475)](e.ebvCv,"xDYMg"))this._isMiniTT?_0x2db410["onNetwor"+s(1486)+s(1580)](({isConnected:u})=>{let g=s;this[g(1095)+g(1122)+g(811)]=u,u?this[g(1428)+g(1288)]():this["_handleO"+g(1236)]()}):this[s(1058)+"X"]&&_0x1470f6["onNetwor"+s(1486)+s(1580)](({isConnected:u})=>{let g=s;this[g(1095)+"igatorOn"+g(811)]=u,u?this[g(1428)+g(1288)]():this["_handleO"+g(1236)]()});else{let u=n[s(1764)],g=0;for(let h=0;e[s(873)](h,u);h++)if(e[s(885)](e[s(1547)],s(1145))){let S=0,R=[];for(;e[s(827)](S,_0x4a06e4.byteLength);){let{offset:B}=e[s(634)](_0x2a8af9,_0x413ab3,S);S=B;let H={cursor_name:"",cursor:0,service:0},{value:j,offset:V}=e[s(770)](_0x459661,_0x5f3c9a,S);H.service=j,S=V;let{value:We,offset:et}=e.nPaMN(_0xa89773,_0x691e82,S);S=et,H[s(1272)+"ame"]=e[s(761)](_0x36d059,_0x4ce075,S,e[s(1560)](S,We)),S+=We;let{value:Di,offset:ki}=e[s(1152)](_0x3fdd0d,_0x1eaeb1,S);H[s(1447)]=Di.toNumber(),S=ki,R[s(405)](H)}return R}else{let S=n.charCodeAt(h);e[s(1749)](S,55296)&&e[s(1597)](S,56319)&&e[s(1161)](e[s(1560)](h,1),u)&&(S=e[s(1468)](e[s(1086)](S,10),n[s(1028)+"At"](++h))-56613888),g+=e.GUXTz(S,128)?1:e[s(1299)](S,2048)?2:S<65536?3:4}e[s(840)](Z,a,g);let _=e[s(1534)](U,a,g),m=a[s(1398)];for(let h=0;e[s(1147)](h,u);h++){let S=n[s(1028)+"At"](h);if(e.iuBWs(S,55296)&&S<=56319&&e.AULdC(h,1)<u&&(S=e[s(853)](e[s(1610)](S,10)+n[s(1028)+"At"](++h),56613888)),e.TrFYm(S,128))m[_++]=S;else{if(e[s(916)](S,2048))m[_++]=e[s(964)](e.rEvHU(e[s(1188)](S,6),31),192);else if(e.GMGFg!=="TcqGV"){if(e[s(1299)](S,65536))m[_++]=e[s(734)](e[s(655)](e[s(1765)](S,12),15),224);else if(e[s(707)](e[s(316)],e.pBGKW))m[_++]=e.QiGRD(e[s(1627)](e[s(442)](S,18),7),240),m[_++]=e[s(1674)](e[s(837)](e[s(1188)](S,12),63),128);else return new _0x4e056a(_0x6a2902,_0x3c64ae,_0x2b67e3);m[_++]=e[s(1528)](e[s(1590)](S>>6,63),128)}else{if(d[s(1618)](_0x4b5c57,1)||d[s(1323)](_0x21327a,_0x1b2ff8))return d.HHCCo(_0xeb4d1d,_0x8ac0bc);d.nZxnh(d[s(1192)](_0x320529,_0x431f05),_0x43f34d)&&(_0x53d375=_0x529de7(_0x5302e1),_0x49d49a=0);let R=_0x259317[s(1681)](_0x3d5bbc,_0x2a58f8,_0x2872ba+=_0xcf42f3);return d[s(1514)](7,_0x1173f5)&&(_0xc1c04=d[s(1773)](7,_0x3bf4c5)+1),R}m[_++]=e[s(1473)](e[s(956)](63,S),128)}}}}function at(a,n){let s=t,d=e.ulcRP(U,a,n.limit),u=a[s(1398)],g=n[s(1398)];for(let _=0,m=n[s(1456)];e.jfkeV(_,m);_++)u[e[s(1541)](_,d)]=g[_]}function Ae(a){let n=t;return a[n(1398)][e[n(713)]($,a,1)]}function Gt(a,n){let s=t,d=e.agYgW(U,a,1);a[s(1398)][d]=n}function _e(a){let n=t,s=0,d=0,u;do u=e.eOPMc(Ae,a),e[n(1625)](s,32)&&(d|=e[n(1011)](e[n(1457)](127,u),s)),s+=7;while(e[n(483)](128,u));return d}function Z(a,n){let s=t;for(n>>>=0;e[s(1220)](n,128);){if(e.VnYby(e.wxYSS,e[s(270)]))return this[s(1008)+"tManager"]?.["getCurre"+s(1025)+s(1113)+s(806)]()||0;e[s(1350)](Gt,a,e[s(1457)](127,n)|128),n>>>=7}e[s(1094)](Gt,a,n)}function Mn(a,n){let s=t,d=0,u=0,g=0,_;return _=e.WOMTS(Ae,a),d=e[s(956)](127,_),e[s(1346)](128,_)&&(_=Ae(a),d|=e[s(1610)](e.zeHYq(127,_),7),e.Tnmuj(128,_)&&(_=e.eOPMc(Ae,a),d|=e[s(1549)](e.huPFk(127,_),14),e[s(1776)](128,_)&&(_=Ae(a),d|=e[s(921)](e[s(260)](127,_),21),e.rEvHU(128,_)&&(_=e[s(947)](Ae,a),u=e.Tnmuj(127,_),e.rORMp(128,_)&&(_=Ae(a),u|=e[s(1414)](e[s(1590)](127,_),7),e.OxiUi(128,_)&&(_=e[s(448)](Ae,a),u|=e[s(1704)](e[s(1129)](127,_),14),128&_&&(_=e[s(296)](Ae,a),u|=e[s(1086)](e[s(669)](127,_),21),e[s(669)](128,_)&&(_=Ae(a),g=e[s(1526)](127,_),128&_&&(_=e.RXqkL(Ae,a),g|=e[s(1414)](e.nnMwH(127,_),7)))))))))),{low:d|e[s(519)](u,28),high:e.tTgeL(e.HgJsb(u,4),e[s(921)](g,24)),unsigned:n}}function ge(a,n){let s=t,d=e[s(697)](n[s(1133)],0),u=e.PVsRs(e[s(650)](n[s(1133)],28),n[s(1548)]<<4)>>>0,g=e[s(697)](n[s(1548)],24),_=g===0?e[s(1667)](0,u)?d<16384?e[s(1083)](d,128)?1:2:e[s(873)](d,2097152)?3:4:u<16384?e[s(1478)](u,128)?5:6:u<2097152?7:8:g<128?9:10,m=e.QLwTr(U,a,_),h=a.bytes;switch(_){case 10:h[e[s(683)](m,9)]=e[s(1776)](e[s(697)](g,7),1);case 9:h[e.GCkby(m,8)]=e[s(1788)](9,_)?128|g:127&g;case 8:h[e[s(1254)](m,7)]=e[s(1156)](8,_)?e[s(571)](u>>>21,128):e[s(664)](e[s(1281)](u,21),127);case 7:h[e[s(1254)](m,6)]=e.MfZll(7,_)?e[s(1119)](u,14)|128:e.ttlqE(u,14)&127;case 6:h[e.Ubapd(m,5)]=_!==6?e[s(1551)](e.mWVjy(u,7),128):u>>>7&127;case 5:h[e[s(1541)](m,4)]=e.ZAzSH(5,_)?128|u:127&u;case 4:h[m+3]=e[s(1445)](4,_)?e[s(1724)](e[s(1281)](d,21),128):e[s(529)](e.EuNWn(d,21),127);case 3:h[m+2]=_!==3?e[s(1787)](d,14)|128:d>>>14&127;case 2:h[e[s(686)](m,1)]=e[s(1156)](2,_)?e[s(571)](d>>>7,128):e[s(978)](d,7)&127;case 1:h[m]=e[s(393)](1,_)?e[s(499)](128,d):127&d}}function Bn(a){let n=t;if(e.DvTbQ(e[n(1638)],e.toGST))return v(a);_0x37b41["frontier"+n(1410)]=void 0,e[n(1140)](_0x3454bf,e[n(998)])}function je(a){return e[t(1361)](T,a)}let c0=65536,Jx=e[t(1047)],zn=e[t(1504)](c0,c0),d0=zn*zn,f0=d0/2,jt=String.prototype[t(1028)+"At"];class oe{constructor(n,s,d){let u=t;this[u(1426)]=!0,this.low=e[u(1231)](0,n),this.high=e[u(1641)](0,s),this[u(821)]=!!d}static isLong(n){let s=t;return n&&e[s(1477)](!0,n[s(1426)])}static[t(1663)](n,s,d){let u=t;if(e[u(461)](e[u(849)],"iUiCY"))e[u(880)](_0x2b6d38,_0x5be918,96),_0xe50a7c(_0x2b4f16,e[u(1669)](_0x23cda7,_0x37a950));else return new oe(n,s,d)}static[t(425)+"s"](n,s,d){let u=t;return d?oe[u(425)+u(1719)](n,s):oe.fromBytesBE(n,s)}static[t(425)+t(1719)](n,s){let d=t;if(e[d(1045)](e[d(675)],e[d(675)]))_0x1d00c0[d(432)+d(313)+d(1269)](pLVPti[d(239)],_0x108a68),_0x4b2311[d(432)+d(313)+"ner"](pLVPti[d(1544)],_0x49b64e),_0x2f6624["removeEv"+d(313)+d(1269)](pLVPti[d(374)],_0x5d1d4d);else return new oe(e[d(1699)](e.TzLhM(n[0],e[d(1414)](n[1],8))|e[d(519)](n[2],16),n[3]<<24),e[d(734)](n[4],e.DXrER(n[5],8))|n[6]<<16|e.rDFCH(n[7],24),s)}static[t(425)+t(1703)](n,s){let d=t;return new oe(e[d(973)](e[d(1551)](e[d(1086)](n[4],24),e[d(1549)](n[5],16))|n[6]<<8,n[7]),e.FRJOf(n[0]<<24|e[d(1198)](n[1],16)|n[2]<<8,n[3]),s)}static[t(1021)](n){let s=t;return e[s(1685)](n,Jx)?u0:new oe(e[s(978)](e.aogey(jt[s(1681)](n,0)|jt[s(1681)](n,1)<<8,e[s(1704)](jt[s(1681)](n,2),16))|e.LhMCA(jt.call(n,3),24),0),e.CaikW(e[s(734)](e[s(1665)](e[s(265)](jt[s(1681)](n,4),e[s(1029)](jt.call(n,5),8)),jt[s(1681)](n,6)<<16),e.LhMCA(jt[s(1681)](n,7),24)),0),!0)}[t(1317)](){let n=t;return String.fromCharCode(e[n(1479)](255,this.low),e[n(514)](this[n(1133)],8)&255,e[n(836)](e.oQKLD(this[n(1133)],16),255),this.low>>>24,e[n(501)](255,this[n(1548)]),e[n(1627)](e[n(514)](this[n(1548)],8),255),e.twlbF(e[n(1093)](this[n(1548)],16),255),e[n(1787)](this[n(1548)],24))}static[t(1395)+"er"](n,s=!0){let d=t,u={lvLut:e[d(1544)],lCEIe:function(g,_,m){return e[d(1094)](g,_,m)}};if(isNaN(n))return s?Yx:u0;if(s){if(e.oAnCK(n,d0))return Xx}else if(e[d(1241)](d(1686),e[d(1540)]))this.emit(u[d(1381)],u[d(1300)](_0x5aa5a3,u[d(1381)],{message:this[d(1729)+d(255)+d(762)](_0x2bead1)}));else{if(e[d(1597)](n,-f0))return Qx;if(n+1>=f0)return Zx}return oe[d(1663)](e.MrOQA(e[d(1792)](n,zn),0),e[d(1780)](e.hboLE(n,zn),0),s)}[t(454)](){let n=t;if(e[n(1134)]===e[n(238)])throw this[n(718)+n(398)]=!1,_0x4144b3;return this[n(821)]?e[n(1468)](e[n(1121)](this[n(1548)],0)*zn,this[n(1133)]>>>0):e[n(1541)](e.uuDnB(this[n(1548)],zn),e[n(1281)](this.low,0))}[t(320)](){let n=t;return e[n(885)](0,this.high)&&e.YPYWQ(0,this[n(1133)])}add(n){let s=t;oe[s(1426)](n)||(n=oe[s(1395)+"er"](n));let d=e.vrVBc(this[s(1548)],16),u=e[s(893)](65535,this.high),g=this[s(1133)]>>>16,_=65535&this[s(1133)],m=e[s(1283)](n[s(1548)],16),h=e[s(664)](65535,n[s(1548)]),S=e.ttlqE(n[s(1133)],16),R=65535&n[s(1133)],B=0,H=0,j=0,V=0;return V+=e[s(581)](_,R),j+=e[s(514)](V,16),V&=65535,j+=e[s(1541)](g,S),H+=e[s(697)](j,16),j&=65535,H+=e[s(1137)](u,h),B+=e[s(1199)](H,16),H&=65535,B+=e.fitQK(d,m),B&=65535,oe.fromBits(e.DXrER(j,16)|V,e[s(1321)](B<<16,H),this[s(821)])}[t(1339)](n){let s=t;return oe[s(1426)](n)||(n=oe.fromNumber(n)),this[s(821)]!==n[s(821)]&&e[s(1063)](e[s(650)](this[s(1548)],31),1)&&e[s(1477)](e[s(1631)](n[s(1548)],31),1)?!1:e[s(1553)](this[s(1548)],n[s(1548)])&&e.vUJAh(this[s(1133)],n[s(1133)])}[t(1635)](){let n=t;return e[n(824)](-1,this[n(1133)])&&e[n(704)](-1,this[n(1548)])?oe[n(1663)](0,0,this[n(821)]):e[n(1306)](-1,this[n(1133)])?oe[n(1663)](0,e[n(862)](this.high,1),this[n(821)]):oe.fromBits(e[n(248)](this[n(1133)],1),this.high,this[n(821)])}[t(441)](n){let s=t;return n?this[s(1135)+"E"]():this[s(1270)+"E"]()}[t(1135)+"E"](){let n=t,s=this[n(1548)],d=this[n(1133)];return[e[n(1494)](255,d),e[n(1726)](e[n(1121)](d,8),255),e[n(547)](d,16)&255,e.bskXJ(d,24),255&s,e.Xfpvi(e.WgCdk(s,8),255),e.xHcFe(s,16)&255,e[n(1175)](s,24)]}[t(1270)+"E"](){let n=t;if(e[n(393)](e[n(601)],e[n(601)]))this.emit(e[n(292)],_0x36a560),this[n(1619)]&&this[n(1619)](_0x4f26ac);else{let s=this[n(1548)],d=this.low;return[e[n(1281)](s,24),e[n(1590)](e.GiqAr(s,16),255),e[n(367)](e[n(1571)](s,8),255),255&s,d>>>24,e[n(389)](d,16)&255,e[n(1579)](e[n(1206)](d,8),255),255&d]}}}let u0=new oe(0,0,!1),Yx=new oe(0,0,!0),Zx=oe[t(1663)](-1,2147483647,!1),Xx=oe.fromBits(-1,-1,!0),Qx=oe[t(1663)](0,-2147483648,!1);var Kt=(function(a){let n=t;return a[a[e[n(808)]]=5001]=e[n(808)],a[a[e[n(1037)]]=5002]=e[n(1037)],a[a[e[n(582)]]=5003]=e[n(582)],a[a[e[n(1771)]]=5004]=n(383)+n(1659),a[a[e[n(615)]]=5005]=e[n(615)],a})({});class Fn{constructor(n){let s=t;this[s(695)]=n,this.target=null}}class l0 extends Fn{constructor(n,s){let d=t;super(n),this[d(1302)]=s&&s[d(1302)]||null}}class x0 extends Fn{constructor(n,s){let d=t,u=e[d(1213)].split("|"),g=0;for(;;){switch(u[g++]){case"0":super(n);continue;case"1":this[d(237)]=s&&s[d(237)]||0;continue;case"2":this.code=s&&s[d(396)]||5001;continue;case"3":this.filename=s&&s[d(1475)]||"";continue;case"4":this[d(1302)]=s&&s[d(1302)]||"";continue;case"5":this[d(1178)]=s&&s[d(1178)]||null;continue;case"6":this.lineno=s&&s[d(1518)]||0;continue}break}}}class h0 extends Fn{constructor(n,s){let d=t,u={lVRly:function(g,_){return e.qOYQd(g,_)},tvVmc:e[d(998)]};if(e[d(824)](e[d(822)],e[d(987)])){let g=_0x33a516["createEl"+d(468)](e[d(1053)]);_0x269507["frontier"+d(1410)]=_=>{let m=d;_0x5d6484.body[m(359)+m(617)](g),_0x124405["frontier"+m(1410)]=void 0,u[m(847)](_0x484f37,_&&_[m(1432)]||u[m(1084)])},g[d(695)]=e[d(611)],g.src=_0x21b9a8[d(503)](/^ws/,"http")+e[d(284)];try{_0x3c3ee4[d(756)].appendChild(g)}catch{_0x22c972[d(756)][d(359)+d(617)](g)}}else{let g=e[d(1048)][d(428)]("|"),_=0;for(;;){switch(g[_++]){case"0":super(n);continue;case"1":this[d(1296)]=s&&s[d(1296)]||"";continue;case"2":this[d(783)+"nnect"]=s&&s[d(783)+d(1172)]||!1;continue;case"3":this.wasClean=s&&s.wasClean||!1;continue;case"4":this[d(396)]=s&&s[d(396)]||0;continue}break}}}}class p0 extends Fn{constructor(n,s){let d=t;super(n),this[d(814)]=s&&s[d(814)]||null}}class g0 extends p0{constructor(n,s){let d=t;super(n),this[d(814)]=s&&s[d(814)]||null,this.message=s&&s[d(1302)]||null}}class m0 extends Fn{constructor(n,s){let d=t;super(n),this[d(814)]=s&&s[d(814)]||null}}function Qe(a,{message:n,code:s,error:d}){let u=t,g={raJfn:function(_,m){return e[K(1331)](_,m)},sDoly:function(_,m){return _&m},ufDfm:function(_,m){return e.MAmqy(_,m)},JlChb:function(_,m){return e.wbSsJ(_,m)}};if(e[u(1156)](e.RrLtb,"sKHRc"))_0x52fd49<65536?_0x551210[_0x947312++]=JPoeDO[u(1197)](JPoeDO.sDoly(JPoeDO[u(1019)](_0x5e59a4,12),15),224):(_0x48febf[_0x2e9e93++]=JPoeDO.raJfn(JPoeDO[u(1003)](_0x1e2d55>>18,7),240),_0x121a0b[_0xed0a98++]=JPoeDO[u(1003)](JPoeDO[u(1019)](_0x4b12ca,12),63)|128),_0xc45726[_0x2bb209++]=JPoeDO.JlChb(JPoeDO[u(1019)](_0x2da61b,6),63)|128;else return new x0(a,{message:n,code:s,error:d})}function ct(a,{code:n,reason:s,wasClean:d,willReconnect:u}){return new h0(a,{code:n,reason:s,wasClean:d,willReconnect:u})}function w0(a,{data:n,message:s}){return new g0(a,{data:n,message:s})}function _0(a,{data:n}){return new m0(a,{data:n})}function Po(a,{message:n}){let s=t;if(s(490)===e[s(371)]){let d=e[s(1786)](_0x447d25,_0x33584b,_0x586027);return _0x32c933[s(1398)][s(1671)](d,e[s(686)](d,_0x14dfa9))}else return new l0(a,{message:n})}class y0{constructor(n,s){let d=t,u={gyCOE:function(g,_){return e.iOAYi(g,_)},MGnrs:function(g,_){return e[K(1437)](g,_)},Giyts:e.BBeLp,rtJHN:"init QoS"+d(1014)+"d"};if(e[d(605)](e.dFEbN,e.mxOiY)){if(u.gyCOE(_0x3a7bd5,_0x34b5a6))return new _0x47a31d(_0x33a5c4,_0x3c1f84);if(u[d(818)](_0x50ee46,_0x21b180)&&d(764)+"d"!=typeof _0x41f390)return new _0x3f8e78(_0x227d8a,_0x2de5cb);if((_0x3ef0e5||_0x531453)&&u[d(745)](u[d(575)],typeof _0xd87ad0))return new _0x812c72(_0x4b3433,_0x4a9815);throw new _0x374016(u[d(1096)])}else this[d(1653)+"s"]=n,this[d(878)+"es"]=s,this[d(1372)+d(303)]=0,this[d(587)+d(1570)+d(1545)+"t"]=0}[t(1585)+t(855)+"fig"](){let n=t;e.XfVlV(n(318),e.ETjNT)?this[n(307)]&&this[n(307)][n(1297)](_0x363810,_0x35b1f2):(this[n(1372)+n(303)]=0,this[n(587)+"ndpointT"+n(1545)+"t"]=0)}[t(903)+"es"](){let n=t;this[n(587)+n(1570)+n(1545)+"t"]=0}["getCurre"+t(1025)+"nt"](){let n=t;return this.endpoints[this[n(1372)+n(303)]]}[t(244)+"ntEndpoi"+t(1113)+"ount"](){let n=t;return this[n(587)+"ndpointT"+n(1545)+"t"]}[t(1626)+t(341)+"es"](){let n=t;return!!(this[n(1372)+n(303)]>=this[n(1653)+"s"].length||e.lbnds(this.currentIndex,e[n(525)](this.endpoints[n(1764)],1))&&this[n(587)+n(1570)+n(1545)+"t"]===this[n(878)+"es"])}[t(850)+"rentEndp"+t(422)+t(622)+t(1401)](){let n=t;return e[n(332)](this[n(1372)+"ndex"],this[n(1653)+"s"][n(1764)])?!0:e[n(1265)](this[n(587)+n(1570)+n(1545)+"t"],this[n(878)+"es"])}[t(531)+t(1442)+t(633)+t(231)+t(293)](){let n=t;return this[n(587)+"ndpointT"+n(1545)+"t"]=1,this["currentI"+n(303)]++,this.endpoints[this[n(1372)+n(303)]]}[t(244)+t(1025)+t(379)+"ateCount"](){let n=t;return this["currentE"+n(1570)+n(1545)+"t"]++,this[n(244)+"ntEndpoint"]()}}let Un=(e.vHwRi(t(764)+"d",typeof globalThis)&&e[t(1023)](e[t(232)],globalThis[t(447)+t(1315)][t(344)])||e.vHwRi(e[t(1345)],typeof window)&&e[t(1280)](t(1054),window[t(447)+"tor"][t(344)]))&&e[t(1413)](e[t(1345)],typeof document),pn=e[t(520)](e[t(1345)],typeof globalThis)&&(e[t(824)](t(1387),globalThis[t(447)+t(1315)][t(344)])||e[t(1340)](e[t(852)],globalThis[t(447)+t(1315)][t(344)]))&&e[t(1345)]!=typeof tt,Rr=(e[t(648)]("undefined",typeof globalThis)&&e[t(259)](t(1387),globalThis.constructor[t(344)])||e.tQXDt(t(764)+"d",typeof globalThis)||e.Pzhba(e[t(1345)],typeof globalThis)&&!!globalThis[t(1103)+t(1085)])&&e[t(1437)](e.BBeLp,typeof wx),Dr=e[t(608)](e[t(1345)],typeof globalThis)&&(e[t(1558)](e.zbmXe,globalThis[t(447)+"tor"][t(344)])||e[t(710)](e[t(1501)],globalThis[t(447)+t(1315)][t(344)])||e[t(1685)](e[t(513)],globalThis.constructor[t(344)]))&&e[t(1437)](t(764)+"d",typeof self),eh=e.reTwL(e[t(1345)],typeof globalThis)&&e[t(710)](e[t(1492)],globalThis["construc"+t(1315)][t(344)])&&e.SxGEM(e[t(1345)],typeof global)&&t(1387)===global[t(447)+t(1315)].name&&e[t(648)]("undefined",typeof process)&&!!process.version;class Oo{constructor(){let n=t,s={eIoYn:n(1178),CmQdH:function(d,u){return d instanceof u},dJfES:function(d,u){return e[n(580)](d,u)}};if(e[n(709)](n(1533),e.NMQbN))this[n(1154)+"rs"]={};else{let d={ytHrq:s[n(983)]};if(s.CmQdH(_0x3d4b7b,_0x438f08)){let u=_0xacc8d4[n(1051)][n(744)](_0x2f71ac[n(480)+"et"],s[n(981)](_0xe9b8c8[n(706)+"th"],_0x13504f[n(480)+"et"]));this[n(854)]&&this[n(854)][n(868)]({data:u,fail:g=>{let _=n;this.emit(s[_(983)],_0x4111fc(s[_(983)],{message:this["_formatE"+_(255)+_(762)](g)}))}})}else this[n(854)]&&this[n(854)][n(868)]({data:_0x412013,fail:u=>{let g=n;this[g(412)](d[g(1506)],_0x13b5a5(d[g(1506)],{message:this["_formatErrorMess"+g(762)](u)}))}})}}[t(412)](n,...s){let d=t,u=this[d(1154)+"rs"][n];if(u)u[d(744)]().forEach(g=>g.fn[d(680)](g[d(273)],s));else if(e[d(704)](d(1178),n)&&!this[d(1219)])if(e[d(699)](d(904),e[d(1688)])){let{type:g}=_0x31a18c;this[d(412)](g,_0x14c36b)}else{let g=s.length&&s[0];if(e[d(1176)](g,Error))throw g;let _=new Error(e.wwwcb+(g?" ("+g[d(1302)]+")":""));throw _[d(733)]=g,g}return this}[t(1623)](n,s){let d=t,u={yEohK:d(1302)};if(e[d(1063)](void 0,n))this[d(1154)+"rs"]={};else if(e[d(824)](void 0,s))this[d(1154)+"rs"][n]=null;else if(e.ekBWH(e[d(955)],e[d(955)])){let g=this[d(1154)+"rs"][n];if(g)for(let _=0;_<g[d(1764)];)g[_].fn===s?g[d(896)](_,1):++_}else this[d(412)](u[d(1583)],_0x4e2248(u.yEohK,{..._0xaea6e0}));return this}on(n,s,d){let u=t;return(this[u(1154)+"rs"][n]||(this[u(1154)+"rs"][n]=[]))[u(405)]({fn:s,ctx:d||this}),this}}class th extends Oo{[t(1729)+t(255)+t(762)](n){let s=t;if(e[s(1117)](e[s(1594)],e[s(1403)]))return n[s(1465)]||n.errNo?(s(834)+" "+(n.errMsg||"")+s(366)+(n.errNo||""))[s(569)]():JSON[s(923)+"y"](n);_0x8fe2a1&&this[s(1141)+"anager"][s(1649)+s(516)+s(1376)](_0x3e1bfa)}constructor(n,s,d){let u=t;super(),this._socket=null,Rr&&wx[u(831)+u(491)]&&(this._socket=wx["connectS"+u(491)]({url:n,protocols:s,header:d,fail:this[u(1158)+"ocketFai"+u(945)][u(1222)](this),success:this[u(1158)+"ocketSuc"+u(777)+u(1062)][u(1222)](this)})),pn&&tt[u(831)+u(491)]&&(this[u(854)]=tt[u(831)+u(491)]({url:n,protocols:s,header:d,fail:this["_createSocketFai"+u(945)][u(1222)](this),success:this[u(1158)+"ocketSuccessHand"+u(1062)][u(1222)](this)}))}["_createS"+t(877)+t(777)+t(1062)](){let n=t;Promise[n(290)]()[n(901)](()=>{let s=n;this[s(692)+s(1732)]()})}[t(1158)+"ocketFai"+t(945)](n){let s=t,d={eyHZk:e[s(1544)],HqtRm:function(u,g,_){return u(g,_)},LXKyH:e[s(292)],MBrOx:function(u,g){return e.mVrRi(u,g)}};if(e.LSkMd(e[s(1006)],e.RmeiX))Promise[s(290)]().then(()=>{let u=s,g=Qe(d[u(894)],{message:this[u(1729)+u(255)+"age"](n)});this.emit(u(1178),g);let _=d[u(638)](ct,d[u(266)],{reason:this[u(1729)+u(255)+u(762)](n)});this[u(412)](d[u(266)],_)});else return _0x5f4cf2&&(_0x523fd4=(0,_0x3a657f[NQresN[s(382)](_0x3b5a8e,_0x35f69b)[0]])(_0x12796d=0)),_0x51040b}[t(692)+t(1732)](){let n=t,s={SFAgD:function(d,u,g){return e.XKcyc(d,u,g)},BTJBL:e[n(292)],Kxdjv:function(d,u){return e[n(1204)](d,u)},kmJSi:function(d,u){return d*u},fSSCN:function(d,u){return e[n(796)](d,u)},MJPFz:function(d,u){return e.lzvBP(d,u)},setVk:e[n(511)],nidDz:e.YABKy,EOWvC:function(d,u,g){return e.bRunR(d,u,g)},laGFG:e[n(1544)]};this[n(854)][n(1745)](d=>{let u=n;this.emit(e[u(986)],e[u(1622)](_0,e[u(986)],{...d,data:d[u(1465)]||""}))}),this[n(854)][n(670)](d=>{let u=n;this.emit(u(1297),s[u(738)](ct,s[u(674)],{...d}))}),this._socket[n(321)+"e"](d=>{let u=n;if(s[u(1712)](u(1439),s[u(819)])){let g=_0x30c63c.bytes,_=_0x449ccd[u(262)],m=_0x5bb09d[u(1456)],h=SxsZQv[u(1325)](_,_0x558e15);if(h>g[u(1764)]){let S=new _0x74f88b(SxsZQv[u(263)](2,h));S.set(g),_0x18ab6f.bytes=S}return _0x137e92.offset=h,SxsZQv[u(1107)](h,m)&&(_0x3f64e3.limit=h),_}else this[u(412)](s.nidDz,w0(u(1302),{...d}))}),this[n(854)].onError(d=>{let u=n;this[u(412)](u(1178),s[u(1676)](Qe,s[u(950)],{...d,message:d.errMsg||""}))})}send(n){let s=t,d={BFrMu:function(u,g){return e[K(253)](u,g)},infgM:e[s(1701)],EHTcV:s(1178),UQpsk:function(u,g,_){return u(g,_)},BpGGG:function(u,g){return e.PDkOc(u,g)},JlWRA:function(u,g){return u+g},PDrVf:e[s(800)]};if(e[s(1108)]!=="tbHIm"){let u=e[s(1344)](_0x48a05b,e[s(1544)],{message:_0x2e88de[s(1302)],code:_0x54a634[s(1742)+"OR"],error:_0x1c2aa0});this[s(376)+s(561)+s(1020)](u)}else if(e[s(1176)](n,Uint8Array)){let u=n.buffer.slice(n[s(480)+"et"],n[s(706)+"th"]+n.byteOffset);this._socket&&this[s(854)][s(868)]({data:u,fail:g=>{let _=s;if(d.BFrMu(d[_(682)],_(1138)))this[_(412)](d.EHTcV,d[_(1569)](Qe,d[_(500)],{message:this[_(1729)+_(255)+_(762)](g)}));else return this[_(307)]?this[_(307)].binaryType:this._binaryType}})}else this[s(854)]&&this[s(854)][s(868)]({data:n,fail:u=>{let g=s,_={dyGIU:function(m,h,S){return m(h,S)},nvHTd:function(m,h){return d.BpGGG(m,h)},LnuBu:function(m,h){return d[K(1249)](m,h)}};if(d[g(1496)](g(1499),d.PDrVf)){let m=FjKLmr.dyGIU(_0x53135a,_0xfb918c,_0x1618b3[g(1456)]),h=_0x5301de.bytes,S=_0x16ea35[g(1398)];for(let R=0,B=_0x563582[g(1456)];FjKLmr.nvHTd(R,B);R++)h[FjKLmr.LnuBu(R,m)]=S[R]}else this[g(412)](d[g(500)],d[g(1569)](Qe,d[g(500)],{message:this[g(1729)+g(255)+g(762)](u)}))}})}close(n,s){this[t(854)]&&this._socket.close({code:n,reason:s})}[t(1655)+t(1612)](n,s){this.on(n,s)}["removeEv"+t(313)+t(1269)](n,s){this[t(1623)](n,s)}get[t(302)+"te"](){return this[t(854)].readyState}get binaryType(){let n=t;return this[n(854)][n(1291)+"pe"]}set binaryType(n){}get[t(1689)](){let n=t;return this[n(854)][n(1689)]}get protocol(){return this[t(854)].protocol}get extensions(){return this._socket.extensions}get[t(446)+t(676)](){return 0}}function nh(a,n){let s=t;if(e.ZAzSH(e.gvxzX,e[s(1695)])){if(n)return new n(a.url,a.protocol);if(e[s(1436)](Rr,pn))return new th(a[s(1689)],a[s(1136)],a.headers);if(e[s(919)](Un,Dr)&&e[s(1345)]!=typeof WebSocket&&WebSocket)return new WebSocket(a[s(1689)],a[s(1136)+"s"])}else this._isMiniTT||this[s(1058)+"X"]?this[s(658)+s(782)+"ange"]():this[s(1342)+"er"]&&this["_initGlo"+s(1017)+s(1612)]()}function rh(a){let n=t;return!!(a||Rr&&wx[n(831)+n(491)]||pn&&tt[n(831)+n(491)]||e[n(919)](Un,Dr)&&e[n(1345)]!=typeof WebSocket&&WebSocket)}function b0(a,n,s){let d=t,u={NemuM:function(m,h){return e[K(1597)](m,h)},OgeyY:e[d(1750)],hLkrg:function(m,h){return e.JnCgO(m,h)}},g=-1;async function _(m){let h=d;return u.NemuM(m,g)?Promise[h(1015)](new Error(u.OgeyY)):(g=m,m===s[h(1764)]?Promise[h(290)]():s[m].bind(a)(n,_[h(1222)](null,u[h(826)](m,1))))}e.qOYQd(_,0)}function E0(a){let n=t,s={NXrwf:function(d,u){return e[K(1098)](d,u)},mLOAa:function(d,u){return e.TrFYm(d,u)},sEEQJ:function(d,u){return d===u},mAqhm:function(d,u){return e[K(664)](d,u)},KHkpy:function(d,u){return e.pdbuN(d,u)}};if(e[n(1164)](n(463),n(463)))_0x3f16af=_0x1e27e6[n(1028)+"At"](_0xce717b),s[n(739)](_0x5c17b1,128)?_0x46bf4a+=1:s.mLOAa(_0x200c8a,2048)?_0x36beea+=2:s[n(775)](s[n(1256)](64512,_0x20be6d),55296)&&s[n(775)](s.mAqhm(64512,_0x30bea6[n(1028)+"At"](s[n(938)](_0x44da8b,1))),56320)?(++_0x1de685,_0x86c13e+=4):_0x1527d5+=3;else{let d=0,u=0;for(let g=0;e[n(1216)](g,a[n(1764)]);++g)u=a[n(1028)+"At"](g),u<128?d+=1:e[n(1711)](u,2048)?d+=2:e[n(609)](e[n(905)](64512,u),55296)&&(64512&a[n(1028)+"At"](g+1))===56320?(++g,d+=4):d+=3;return d}}function v0(a,n,s){let d=t;if(e.WPVfL(e[d(299)](s,n),1))return"";let u="";for(let g=n;g<s;)if(e[d(1241)]("JRwxy",e[d(925)]))e[d(1044)](_0x5b0504,2048)?_0x25c108[_0x6f7137++]=e[d(1474)](e[d(1129)](e[d(1239)](_0x15fa50,6),31),192):(e.CNuFm(_0x4fced0,65536)?_0x2eff4d[_0x18e2c2++]=e[d(1780)](e[d(501)](e[d(1239)](_0x56c619,12),15),224):(_0x582df6[_0x4b5bfa++]=e[d(1290)](_0x377ee5,18)&7|240,_0x5a0268[_0x5d049c++]=e[d(1590)](_0x53aeed>>12,63)|128),_0x21ea9e[_0x13047e++]=e.MAmqy(_0x1b206d,6)&63|128),_0x39ed97[_0x575436++]=e.ccJEa(e[d(529)](63,_0x53c5cd),128);else{let _=a[g++];if(_<=127)u+=String[d(1444)+d(906)](_);else if(e[d(1235)](_,192)&&e[d(723)](_,224))u+=String[d(1444)+"Code"](e[d(672)](e[d(1397)](e[d(935)](31,_),6),e[d(380)](63,a[g++])));else if(e[d(1562)](_,224)&&_<240)u+=String[d(1444)+d(906)](e[d(1473)](e.XFKGm(e.nnMwH(15,_),12)|e.ArOrZ(63&a[g++],6),63&a[g++]));else if(e[d(928)](_,240)){let m=e.BIoVl(e[d(1641)](e[d(1232)](e[d(1425)](7&_,18),e[d(960)](e[d(1464)](63,a[g++]),12))|e[d(758)](63&a[g++],6),e[d(669)](63,a[g++])),65536);u+=String[d(1444)+"Code"](e[d(1065)](55296,m>>10)),u+=String[d(1444)+d(906)](e[d(997)](56320,e.fuehp(1023,m)))}}return u}function No(a,n,s){let d=t,u=s,g,_;for(let m=0;e.sIdxg(m,a[d(1764)]);++m)if(g=a[d(1028)+"At"](m),e.fGtLv(g,128))n[s++]=g;else if(e[d(294)](g,2048))n[s++]=e[d(317)](e.NeRPG(g,6),192),n[s++]=e[d(345)](63,g)|128;else if(e[d(1063)](e[d(1776)](64512,g),55296)&&e[d(977)](e.BCjSK(64512,_=a[d(1028)+"At"](m+1)),56320)){let h=(d(860)+d(1024))[d(428)]("|"),S=0;for(;;){switch(h[S++]){case"0":g=e[d(469)](e[d(1642)](65536,e[d(703)](1023,g)<<10),1023&_);continue;case"1":n[s++]=e[d(1674)](e[d(1290)](g,6)&63,128);continue;case"2":n[s++]=g>>18|240;continue;case"3":++m;continue;case"4":n[s++]=e[d(996)](e[d(669)](e[d(304)](g,12),63),128);continue;case"5":n[s++]=e[d(1494)](63,g)|128;continue}break}}else n[s++]=e[d(1724)](g>>12,224),n[s++]=e.GTcfX(g>>6,63)|128,n[s++]=e[d(317)](e[d(1500)](63,g),128);return e[d(1276)](s,u)}async function S0(a){let n=t;if(e[n(875)](e[n(1768)],typeof a)){let s=new Uint8Array(E0(a));return e[n(761)](No,a,s,0),s}return e[n(1176)](a,ArrayBuffer)?new Uint8Array(a):new Uint8Array(a[n(1051)],a.byteOffset,a[n(706)+"th"])}function ih(a){let n=t,s={MBRTF:e.PEvIh,rFEiP:function(d,u){return e[K(1140)](d,u)}};try{return e[n(599)](e[n(1768)],typeof a)&&(e[n(668)](a,ArrayBuffer)||a[n(1051)]&&e[n(289)](a[n(1051)],ArrayBuffer))||e[n(1437)](e.XfImb,typeof a)?"":(JSON.parse(a),n(863)+"ion/json")}catch{if(e.zmHgR(e[n(755)],e[n(755)])){let d=_0x3dba00[n(1383)+n(842)](_0x326651);return _0x40cf0a&&d[n(1655)+n(1612)](GDBJZr.MBRTF,()=>_0x25958c()),GDBJZr.rFEiP(_0x225784,d)[n(901)](()=>{})}else return e[n(1127)](e[n(1768)],typeof a)?e[n(1396)]:""}}let sh=(a,n)=>{let s=t;switch(a){case e[s(933)]:case e[s(1022)]:return{[s(305)+a]:1,"x-tt-env":n};default:return{}}};class oh{constructor(n){let s=t;this[s(352)+s(806)]=n,this.count=0}[t(606)](){let n=t;this[n(931)]++}checkReachMaxCount(){let n=t;return this[n(931)]>=this[n(352)+n(806)]}[t(279)+t(828)](n=0){let s=t;this[s(352)+s(806)]=n,this[s(931)]=0}}async function ah(a){let n=t,s={UjBnI:function(d,u){return e[K(1717)](d,u)},uqPKa:"unknown "+n(1296)};return new Promise(d=>{let u=n;if(!Un)return e.IazKQ(d,e[u(998)]);try{let g=document[u(1716)+u(468)](e.VYfga);window[u(306)+u(1410)]=_=>{let m=u;document[m(756)]["removeCh"+m(617)](g),window[m(306)+m(1410)]=void 0,s[m(1308)](d,_&&_.msg||s[m(233)])},g[u(695)]=u(225)+u(1099),g[u(1690)]=a[u(503)](/^ws/,e[u(1767)])+e.hNDRA;try{document.body[u(694)+u(617)](g)}catch{document[u(756)].removeChild(g)}}catch{window[u(306)+u(1410)]=void 0,e[u(959)](d,e[u(998)])}})}function Wt(a,n,s){let d=t;return!!a?.find(u=>u[d(1091)]===n&&u.value===s)}function qn(a,n){let s=t;return a?.[s(1480)](d=>d[s(1091)]===n)?.[s(1386)]}let Mo=null;async function ch(){let a=t;return e[a(512)](e[a(1120)],e[a(1120)])?this[a(307)]?this[a(307)].extensions:"":(Mo||(Mo=Promise[a(290)]()[a(901)](Tt[a(1222)](Tt,e.hvBTm))),Mo)}class dh extends Oo{constructor(n,s){let d=t;super(),this._dbName=n,this[d(1130)]=s,this._qosDB=void 0,this[d(618)+d(464)]=null}async openDB(){await this[t(1190)]()}async[t(1190)](){let n=t,s={IYsJD:e[n(1089)],fzJPF:e.SgitK};if(!this[n(264)]){if(this[n(618)+n(464)])return this[n(618)+n(464)];try{let d=this._dbName,u=this[n(1130)];this[n(618)+"mise"]=(async()=>{let g=n,{openDB:_}=await e[g(226)](ch);this[g(264)]=await e.ckOCX(_,g(306)+"_"+d,1,{upgrade(m){let h=g;s[h(866)]===s[h(1520)]?this[h(264)]?.[h(1001)](_0xfbbd2b.message_id):m[h(1210)+h(1059)+"e"](d,{keyPath:u})}})})(),await this[n(618)+"mise"]}catch(d){console[n(603)](d)}finally{this[n(618)+n(464)]=null}}}async[t(930)](n){let s=t;try{return await this[s(1190)](),this[s(264)]?.[s(930)](this[s(1587)],n)}catch(d){if(e[s(1124)]!==e[s(1124)])return _0x29a182[s(262)]>=_0x38f246.limit;console[s(603)](d)}}async[t(363)](n,s){let d=t;return await this[d(1190)](),this._qosDB?.[d(1404)](this[d(1587)],n)}async[t(1001)](n){let s=t,d={sZgRU:e[s(1064)],JifSs:"pagehide",xmbHc:"pageshow"};try{return await this[s(1190)](),this._qosDB?.[s(329)](this._dbName,n)}catch(u){e[s(768)]===e[s(768)]?console[s(603)](u):(this[s(1342)+"er"]&&_0x1dc945[s(1655)+"Listener"](s(586),this[s(1428)+s(1288)]),this[s(1342)+"er"]&&_0x4762a9[s(1655)+s(1612)](d[s(1077)],this["_handleO"+s(1236)]),this._isBrowser&&_0x592687[s(1655)+"Listener"](d[s(1697)],this[s(343)+s(1609)]),this._isBrowser&&_0x599847[s(1655)+s(1612)](d[s(1218)],this["_handleP"+s(1643)]))}}async[t(1598)](){let n=t;if(e[n(643)]("tEvxJ",e[n(1179)])){let s=!!this[n(993)].enableQoS;if(!s)return{enabled:s,isQoSMessage:!1,isQoSAck:!1,isAckCleanupMessage:!1,ackMsgIds:[]};let d=e[n(1338)](_0x52f458,_0x23f587[n(1302)][n(619)],n(1706)+"er_qos","2"),u=d&&e[n(1035)](_0x3d7758,_0x2cd6b9[n(1302)][n(619)],e.VsPjO,"1"),g=d&&e[n(1730)](_0x5aa2fe,_0x1e9ceb[n(1302)][n(619)],n(1706)+n(1417)+"k","1"),_=g?_0x59127d(_0x398758[n(1302)][n(619)],n(1706)+n(597)+n(558))?.[n(428)](",")[n(229)](_0x54e288)||[]:[];return{enabled:s,isQoSMessage:d,isQoSAck:u,isAckCleanupMessage:g,ackMsgIds:_}}else try{return await this[n(1190)](),this[n(264)]?.[n(1598)](this[n(1587)])}catch(s){if(e[n(399)](e[n(338)],e[n(671)]))try{_0x5bc8ee(this,_0xc749e9,[_0xeff9e7,_0x30c0d5,_0x5b994d])}catch(d){let u=e[n(1152)](_0x250311,e[n(1544)],{message:d[n(1302)],code:_0x31dc62[n(1742)+"OR"],error:d});this[n(376)+n(561)+n(1020)](u)}else console[n(603)](s)}}async keys(){let n=t;return await this[n(1190)](),this[n(264)]?.[n(979)+"ys"](this._dbName)}async getAll(){let n=t;return await this._init(),this._qosDB?.[n(1341)](this[n(1587)])}async[t(1495)](){let n=t;try{this[n(264)]?.[n(1297)](),this[n(264)]=void 0}catch(s){console[n(603)](s)}}get[t(920)](){let n=t;if(n(1434)===e[n(331)])return this[n(1653)+"s"][this[n(1372)+n(303)]];try{return!!this._qosDB}catch(s){return console[n(603)](s),!1}}}class fh{constructor(n,s){let d=t;this[d(1725)]=n,this[d(825)]=s,this[d(264)]=localStorage}async[t(1248)](){}get _prefix(){return t(306)+"_"+this._DBName}async get(n){let s=t;if(e[s(824)](e[s(693)],e[s(492)]))for(var d in _0xc30e6)_0x3e7f9d.o(_0xb026df,d)&&!_0x12580f.o(_0x289209,d)&&_0x34672c[s(1751)+"operty"](_0x489d16,d,{enumerable:!0,get:_0x57e8e0[d]});else{let u=this._qosDB[s(589)](this[s(970)]);return JSON[s(1740)](e[s(919)](u,"{}"))[n]}}async[t(363)](n,s){let d=t,u=this[d(264)].getItem(this[d(970)]),g=JSON[d(1740)](e[d(919)](u,"{}"));return g[s||n[this[d(825)]]]=n,this[d(264)][d(471)](this[d(970)],JSON[d(923)+"y"](g)),s||n[this[d(825)]]}async[t(1001)](n){let s=t;if(s(632)===s(632)){let d=this[s(264)][s(589)](this[s(970)]),u=JSON[s(1740)](d||"{}");return u[n]=void 0,this[s(264)].setItem(this[s(970)],JSON[s(923)+"y"](u))}else this[s(412)](s(1302),_0xf7829),this[s(452)+"e"]&&this.onmessage(_0x13f129)}async clear(){let n=t;return this[n(264)][n(1598)]()}async[t(472)](){let n=t,s=this._qosDB[n(589)](this[n(970)]),d=JSON.parse(e[n(919)](s,"{}"));return Object[n(472)](d)}async getAll(){let n=t;if(e.Pwrvg(n(732),e.PIDtu))return this._qosDB[n(920)];{let s=this[n(264)][n(589)](this[n(970)]),d=JSON.parse(e[n(919)](s,"{}"));return Object[n(430)](d)}}closeDB(){let n=t,s={jzPMe:function(d,u){return e[K(1436)](d,u)}};if(e.vhPXI!==e[n(347)])return Promise[n(290)]();{let d=this[n(264)]["getStora"+n(1630)](this[n(970)]),u=_0x15edd3[n(1740)](s.jzPMe(d,"{}"));return u[_0x91e48b]=void 0,this[n(264)][n(665)+n(1630)](this[n(970)],_0x161d1d.stringify(u))}}get[t(920)](){return!!this._qosDB}}class uh{constructor(n,s){let d=t;this._DBName=n,this[d(825)]=s,this[d(264)]=pn?tt:Rr?wx:null}async[t(1248)](){}get[t(970)](){return"frontier_"+this[t(1725)]}async[t(930)](n){let s=t,d=this[s(264)][s(274)+"geSync"](this._prefix);return JSON[s(1740)](e[s(1722)](d,"{}"))[n]}async set(n,s){let d=t,u=this[d(264)][d(274)+d(1630)](this[d(970)]),g=JSON[d(1740)](e[d(567)](u,"{}"));return g[s||n[this[d(825)]]]=n,this[d(264)][d(665)+d(1630)](this[d(970)],JSON[d(923)+"y"](g)),s||n[this[d(825)]]}async[t(1001)](n){let s=t,d=this[s(264)][s(274)+s(1630)](this[s(970)]),u=JSON[s(1740)](e[s(567)](d,"{}"));return u[n]=void 0,this._qosDB["setStora"+s(1630)](this[s(970)],JSON.stringify(u))}async clear(){let n=t;return this._qosDB[n(1150)+n(1537)]()}async[t(472)](){let n=t,s=this._qosDB.getStorageInfoSync(this[n(970)]),d=JSON.parse(e.OCBdG(s,"{}"));return Object[n(472)](d)}async[t(1341)](){let n=t,s=this._qosDB["getStora"+n(1461)+"nc"](this[n(970)]),d=JSON[n(1740)](s||"{}");return Object[n(430)](d)}[t(1495)](){let n=t,s={fwquq:function(d,u,g){return e[K(470)](d,u,g)},QGRpC:e[n(1544)],GeIGU:function(d,u,g){return e[n(882)](d,u,g)},fPaXH:e[n(292)]};if(e[n(1227)]!==e[n(1227)]){let d=hWnLKs.fwquq(_0x363b3e,hWnLKs[n(1516)],{message:this[n(1729)+"rrorMess"+n(762)](_0x59e03a)});this.emit(hWnLKs[n(1516)],d);let u=hWnLKs[n(314)](_0x521481,hWnLKs[n(1679)],{reason:this["_formatE"+n(255)+n(762)](_0x5ce4c3)});this.emit(hWnLKs[n(1679)],u)}else return Promise[n(290)]()}get[t(920)](){return!!this._qosDB}}function I0(a,n){let s=t;if(s(1402)===e[s(872)])return e[s(1565)](_0x38dfce,e[s(342)](e.fitQK(e[s(551)](e[s(248)](e[s(809)]+_0x4f997b,s(1180)),_0x19a4d7||1),e.fpkFc),_0x3a15da));if(e[s(567)](pn,pn))return new uh(a,n);if(e[s(1436)](Un,Dr)&&e[s(1345)]!=typeof indexedDB)return new dh(a,n);if(e[s(1431)](Un,Dr)&&e[s(1345)]!=typeof localStorage)return new fh(a,n);throw new Error(e[s(1070)])}class lh{constructor(){let n=t;this[n(626)+n(1167)+"Id"]=null,this._interval=36e5,this[n(264)]=I0(e.rtVqa,e.SfjwP)}async[t(626)+t(1702)](){let n=t;e[n(448)](clearInterval,this[n(626)+n(1167)+"Id"]),this["_interva"+n(1167)+"Id"]=setInterval(()=>{this["flushExp"+n(705)]()},this[n(626)+"l"])}async[t(1248)](){let n=t;await this._qosDB.openDB()[n(901)](()=>{let s=n;e.gHuEq(e[s(616)],e[s(521)])?this[s(626)+"lFlush"]():this[s(1154)+"rs"]={}})}async["flushExp"+t(705)](){let n=t;if(e[n(991)]("UARSg",e.jUoGR))(await this[n(264)]?.[n(1341)]()||[])[n(229)](({timestamp:u})=>u<Date[n(462)]())[n(584)](u=>{let g=n;this[g(264)]?.[g(1001)](u[g(1228)+"id"])});else return _0x55b176[_0x540a24]=_0x4e8be1,!0}async[t(1001)](n){let s=t;if(e[s(1164)](s(1715),e.HnlZX)){let d={DLzDK:function(u,g){let _=s;return pLVPti[_(1140)](u,g)},FVjNg:function(u,g){return pLVPti.cjsrp(u,g)}};return function(u,...g){let _=s,m=_0x5daa84.call(d[_(1294)](_0x2359a7,this),u,...g);return _0x16c809.set(m,u.sort?u[_(1640)]():[u]),d[_(590)](_0x20f561,m)}}else return this[s(264)]?.del(n)}async[t(363)](n,s){let d=t;return this[d(264)]?.[d(363)]({message_id:n,timestamp:s})}async[t(930)](n){let s=t;return this._qosDB?.[s(930)](n)}async closeDB(){let n=t;if(e.fSgYe===n(1328))return _0x3cd688+=_0x1348a8&&_0x43ef85[n(706)+"th"]||0,_0x56413d;e.bdQOh(clearInterval,this._intervalTimeoutId),await this[n(264)]?.closeDB()}get[t(920)](){let n=t;return this[n(264)]?.[n(920)]}}function Bo(a){let n=t,s={oqXCX:function(d,u){return e[K(361)](d,u)},aFNpf:n(1668),YUYhr:function(d,u){return e[n(1306)](d,u)},VzUIz:e.JxfKj,Osivu:function(d,u){return e[n(1306)](d,u)},ztNNl:function(d,u){return e.asMfQ(d,u)}};if(e[n(506)]==="pcPzJ"){if(_0x25404e instanceof _0x4ef7ce){if(wFLceB[n(1735)](_0x6c3cd6,wFLceB[n(660)]))return _0x1667c1[n(930)](_0x4d83dd);if(wFLceB[n(1066)](_0x5a2019,wFLceB.VzUIz))return _0x174230["objectSt"+n(563)]||_0x366da1.get(_0x48d0bc);if(wFLceB[n(1586)](_0x28cdad,"store"))return _0x55b9f5["objectSt"+n(563)][1]?void 0:_0xbda035["objectSt"+n(457)](_0x309f43["objectSt"+n(563)][0])}return wFLceB[n(1205)](_0x12169b,_0x5273f3[_0xcca115])}else{let d=!!this[n(993)].enableQoS;if(!d)return{enabled:d,isQoSMessage:!1,isQoSAck:!1,isAckCleanupMessage:!1,ackMsgIds:[]};let u=e[n(1418)](Wt,a[n(1302)][n(619)],e[n(1453)],"2"),g=u&&e[n(1730)](Wt,a[n(1302)][n(619)],e[n(1743)],"1"),_=u&&e[n(1524)](Wt,a[n(1302)][n(619)],e[n(573)],"1"),m=_?e[n(544)](qn,a.message[n(619)],e[n(1195)])?.[n(428)](",")[n(229)](Boolean)||[]:[];return{enabled:d,isQoSMessage:u,isQoSAck:g,isAckCleanupMessage:_,ackMsgIds:m}}}async function A0(){let a=t,n={FdeYx:function(s,d){return e[K(508)](s,d)},qxceV:function(s){return s()}};if(e.YZlvM(e[a(439)],"glWyy"))return this._QoSManager||(this[a(961)+"ger"]=new lh),this["_QoSMana"+a(1605)][a(920)]||await this["_QoSMana"+a(1605)][a(1248)](),this[a(961)+a(1605)];ZdwFXJ[a(1353)](_0x3f2b65,ZdwFXJ[a(1353)](_0x257610,_0xd4ecbf.result)),ZdwFXJ[a(1087)](_0x16f07b)}async function xh(a,n){let s=t,{enableAutoAck:d}=this._options,u=e[s(1355)](Wt,a[s(1302)][s(619)],e[s(1657)],"1"),g=Wt(a[s(1302)].headers,e[s(1566)],"1"),_=Bo[s(1681)](this,a);if(e.UaESz(d,u)){let{SeqID:m,LogID:h,service:S,LogIDNew:R,method:B}=a[s(1302)];this[s(1552)]({SeqID:m,LogID:h,LogIDNew:R,service:S,method:B,headers:[{key:e[s(1566)],value:"1"},{key:e[s(1327)],value:R||""},{key:e[s(1016)],value:"0"}]})}g&&!_[s(810)]&&this["_dispatc"+s(1203)+"ageEvent"](a),e[s(1754)](n)}async function hh(a,n){let s=t;if(e[s(445)](e[s(223)],e[s(223)]))this[s(510)](s(1789),a[s(1302)]),e[s(226)](n);else return new _0x2c9b17(_0x4f772c,{message:_0x3f11ab,code:_0x4cea39,error:_0xcd614e})}async function ph(a,n){let s=t,d=e[s(1669)](Bn,await e[s(947)](S0,a[s(814)]));try{if(d[s(300)]instanceof Uint8Array){let u=e[s(898)](this[s(993)][s(427)+s(1144)],Object)?{force:!!this[s(993)][s(427)+s(1144)][s(1595)],encoding:this._options["payloadE"+s(1144)][s(830)]?this[s(993)][s(427)+"ncoding"][s(830)][s(503)](/\s/g,"")["toLowerC"+s(914)]():""}:{force:!1,encoding:this[s(993)][s(427)+"ncoding"]?this[s(993)][s(427)+s(1144)][s(503)](/\s/g,"")[s(1264)+s(914)]():""},g=d[s(427)+s(1144)]?d[s(427)+"ncoding"][s(503)](/\s/g,"")[s(1264)+s(914)]():"",_=e[s(1176)](this._options[s(1185)+s(326)],Object)?{force:!!this[s(993)][s(1185)+"ype"].force,type:this[s(993)][s(1185)+s(326)].type?this._options.payloadType[s(695)][s(503)](/\s/g,"")[s(1264)+"ase"]():""}:{force:!1,type:this._options.payloadType?this[s(993)][s(1185)+s(326)][s(503)](/\s/g,"")[s(1264)+s(914)]():""},m=d[s(1185)+s(326)]?d[s(1185)+s(326)][s(503)](/\s/g,"")["toLowerC"+s(914)]():"",h=_[s(1595)]?_[s(695)]:m||_[s(695)],S=u.force?u[s(830)]:g||u.encoding,R=[e[s(1396)],e[s(583)],e[s(1650)],e.XfImb],B=[e[s(252)],s(807)];this._options[s(1229)+s(1166)+s(1200)+"ad"]&&R[s(449)](h)&&(!S||B.includes(S))?d[s(1542)+s(1326)]=e[s(1035)](v0,d[s(300)],0,d.payload[s(706)+"th"]):d[s(1542)+s(1326)]=""}else d[s(1542)+s(1326)]=""}catch(u){d[s(1542)+s(1326)]="",console[s(603)](u)}a[s(1302)]=d,e[s(308)](n)}function gh(a,n,s){let d=t,u={jJplr:function(S,R){return e.jIzGu(S,R)},LCBfc:function(S,R){return S<R},aGqnt:function(S,R){return e[K(288)](S,R)},ZxgMY:function(S,R){return S===R},iiTta:function(S,R){return S+R},hUqgq:function(S,R){return e[K(1117)](S,R)},vIbRp:e[d(1286)],IUvrt:e[d(689)],JYZHM:function(S,R){return e[d(796)](S,R)},HkUJB:function(S,R){return e[d(963)](S,R)},Jwmgj:function(S,R){return e[d(796)](S,R)},XItlv:function(S,R){return e.KGmKc(S,R)},ohuNU:function(S,R){return e.jQduX(S,R)},BwVmE:function(S,R){return e[d(720)](S,R)},cVOYg:function(S,R){return e[d(1443)](S,R)}},g=e.OCBdG(s,8192),_=e[d(1476)](g,1),m=null,h=g;return function(S){let R=d,B={RAuAA:function(H,j){return H<j},lwsDj:function(H,j){return u.jJplr(H,j)},bEtSv:function(H,j){return u[K(391)](H,j)},xtflR:function(H,j){return H===j},qxvYl:function(H,j){return u[K(743)](H,j)},fqtqn:function(H,j){return u[K(1582)](H,j)},bDSfe:function(H,j){return u[K(312)](H,j)}};if(u[R(895)](u.vIbRp,u[R(466)])){if(u[R(391)](S,1)||u[R(714)](S,_))return u[R(495)](a,S);u[R(1293)](u[R(404)](h,S),g)&&(m=u[R(518)](a,g),h=0);let H=n[R(1681)](m,h,h+=S);return u[R(743)](7,h)&&(h=u[R(1601)](u[R(1572)](7,h),1)),H}else{let H=0,j=0;for(let V=0;dpsbZY.RAuAA(V,_0x5553e1.length);++V)j=_0x1eb9d1[R(1028)+"At"](V),dpsbZY[R(388)](j,128)?H+=1:dpsbZY[R(803)](j,2048)?H+=2:dpsbZY[R(1753)](dpsbZY[R(820)](64512,j),55296)&&dpsbZY[R(774)](dpsbZY[R(820)](64512,_0x4fddaf[R(1028)+"At"](dpsbZY[R(1061)](V,1))),56320)?(++V,H+=4):H+=3;return H}}}let mh=4294967295;function wh(a,n,s){let d=t;return e[d(656)](RangeError,e.OMQIi(e[d(1468)](e[d(922)](e[d(809)]+a,d(1180))+e[d(1575)](n,1),e[d(1050)]),s))}function _h(a,n,s){let d=t,u={VKOAx:e[d(986)]};if(e[d(1405)](s,mh))throw new Error(e[d(1633)]);let g=3;for(;e[d(1608)](g,0);)if(e[d(704)](d(741),e[d(841)])){let _=e[d(763)](255,s);Fo(_,a,e[d(1468)](n,g)),s>>>=8,g--}else this[d(412)](oyZOiq.VKOAx,_0x3df69a(oyZOiq[d(612)],{..._0x253f0d,data:_0x3766ed[d(1465)]||""}));return e[d(1763)](n,4)}function yh(a,n){let s=t,d={XbHmT:function(m,h){return e[K(434)](m,h)},CgNJV:function(m,h){return m<h},TVTGx:function(m,h){return e[K(1474)](m,h)},FSwqf:function(m,h){return e.dBJJM(m,h)},aKXDY:function(m,h){return m|h},lNGso:function(m,h){return m&h},OdZYj:function(m,h){return m&h},PtWlr:function(m,h){return e[K(361)](m,h)},LHewb:function(m,h){return e[K(720)](m,h)},yiTcU:function(m,h){return e[K(1377)](m,h)},nQuRw:function(m,h){return e[K(798)](m,h)},KJKDR:function(m,h){return e[K(1284)](m,h)},tNdXb:function(m,h){return e[K(242)](m,h)},FhpjH:function(m,h){return e.Xfpvi(m,h)},vtqNM:function(m,h){return e.fDVxb(m,h)},xRnub:function(m,h){return e[K(410)](m,h)},mlkGl:function(m,h){return e[K(1346)](m,h)},KyakR:function(m,h){return e[K(1261)](m,h)},nzivI:function(m,h){return e[K(771)](m,h)},DffhJ:function(m,h){return e[K(1330)](m,h)}},u=0,g=n,_=e[s(1541)](n,4);for(;g<_;)if(e[s(1032)](e[s(967)],e[s(1357)])){let{value:m,offset:h}=e[s(1337)](zo,a,g);g=h,u=e[s(1119)](u<<8,0),u+=m}else if(_0x173b46=_0x4ab8e5[s(1028)+"At"](_0x421ecc),VfowAu[s(1278)](_0x51e236,128))_0x1deba4[_0x16d967++]=_0x27ff7;else if(VfowAu[s(435)](_0x37d0c0,2048))_0x187398[_0x59692d++]=VfowAu[s(859)](VfowAu.FSwqf(_0x4eb780,6),192),_0x31b18c[_0x159aaa++]=VfowAu.aKXDY(VfowAu[s(370)](63,_0x4bcc21),128);else if(VfowAu.OdZYj(64512,_0x182fc1)===55296&&VfowAu[s(241)](64512&(_0x1fea3f=_0x30bda3[s(1028)+"At"](VfowAu.LHewb(_0x35ddea,1))),56320)){let m=(s(751)+s(780))[s(428)]("|"),h=0;for(;;){switch(m[h++]){case"0":_0x509f86[_0x4ae8dc++]=VfowAu[s(859)](VfowAu[s(730)](_0x5c2b4b,18),240);continue;case"1":_0x487d62[_0x2e77df++]=VfowAu.aKXDY(VfowAu[s(1313)](_0x1b7441,6)&63,128);continue;case"2":_0x1ca215=VfowAu[s(1069)](VfowAu[s(1375)](65536,VfowAu[s(477)](1023,_0x3cf9bf)<<10),1023&_0x579bd2);continue;case"3":_0x5c9bec[_0x75d21c++]=VfowAu.vtqNM(VfowAu[s(418)](VfowAu[s(730)](_0x12fef2,12),63),128);continue;case"4":_0x1bbcda[_0x591775++]=VfowAu[s(859)](VfowAu[s(1785)](63,_0x4f830c),128);continue;case"5":++_0x54652a;continue}break}}else _0x3cfd05[_0x176b21++]=VfowAu[s(517)](_0x38127d,12)|224,_0x436fa6[_0x508651++]=VfowAu.KyakR(VfowAu.nzivI(VfowAu[s(1313)](_0xa8ad07,6),63),128),_0x4520e0[_0x1bd00a++]=VfowAu[s(1123)](VfowAu.xRnub(63,_0x5094ea),128);return{value:u,offset:_}}function bh(a,n,s){let d=t,u={GOFGs:"7|9|6|0|2|5|10|4"+d(999),HawTA:function(g,_,m,h){return e[d(1524)](g,_,m,h)},hkDzD:e[d(487)],kXxub:d(838),egrPN:"header",XmdsQ:e[d(1589)],cxYna:function(g,_,m,h){return e[d(1730)](g,_,m,h)},WYyFL:e.uIQrf};if(e[d(1156)]("QPnII",e[d(246)])){let[g,_]=e[d(857)](_0x100726,_0x5e6406),m=e[d(947)](_0x5a653c,g),h=0;return _0x223daa[d(584)](S=>{let R=d,B=u[R(1593)][R(428)]("|"),H=0;for(;;){switch(B[H++]){case"0":h=u[R(421)](_0x57fc38,m,h,S[R(1736)]||0);continue;case"1":h=u.HawTA(_0x168ad5,_0x4abcf9.fromNumber(S[R(1447)]||_0x3a552f),m,h);continue;case"2":_0x202bc8[R(603)](u.hkDzD,h);continue;case"3":_0x5bfdef[R(603)](u[R(1531)],h);continue;case"4":h=_0x197bb4(S[R(1272)+"ame"],m,h);continue;case"5":h=u[R(421)](_0x5d5176,_[S["cursor_n"+R(1125)]],m,h);continue;case"6":_0x5723a0.log(u[R(1471)],h);continue;case"7":_0x43ffdb[R(603)](R(1448)+"ervice",S,S[R(1736)]);continue;case"8":_0x1326de.log(u.XmdsQ,h);continue;case"9":h=u.cxYna(_0x227f13,0,m,h);continue;case"10":_0x114181.log(u.WYyFL,h);continue}break}}),{frameType:_0x337fc3,headers:[{key:e[d(843)],value:_0x206222}],payload:m}}else{let g=e.CAWsn[d(428)]("|"),_=0;for(;;){switch(g[_++]){case"0":if(n[d(539)])return e.evwCx(n[d(539)](a,s),s);continue;case"1":if(a[d(1764)]<40)return e[d(1482)](e[d(397)](No,a,n,s),s);continue;case"2":if(n[d(591)+"e"])return e[d(1636)](n[d(591)+"e"](a,s),s);continue;case"3":return No(a,n,s)+s;case"4":if(!a)return s;continue}break}}}function Eh(a,n){let s=t,d=new oe(e[s(1483)](e[s(1641)](e[s(1793)](a[e[s(1482)](n,4)],24)|e[s(1793)](a[n+5],16),e[s(1795)](a[e[s(869)](n,6)],8)),a[e[s(1143)](n,7)]),e[s(450)](e[s(1131)](a[e[s(720)](n,0)],24)|a[e[s(481)](n,1)]<<16|e.lIqOw(a[n+2],8),a[e[s(481)](n,3)]),!0);return n+=8,{value:d,offset:n+8}}function vh(a,n,s){let d=t,u=a[d(1133)],g=a[d(1548)];return n[s]=e[d(1088)](g,24),n[e[d(409)](s,1)]=e[d(794)](e.afofL(g,16),255),n[e[d(1656)](s,2)]=e[d(1233)](e[d(1631)](g,8),255),n[e[d(883)](s,3)]=e[d(345)](255,g),n[e[d(409)](s,4)]=e[d(1018)](u,24),n[s+5]=e[d(478)](u,16)&255,n[e[d(1362)](s,6)]=u>>>8&255,n[e[d(257)](s,7)]=255&u,s+=8,s}function zo(a,n){let s=t;if(e.ASeAS(e[s(1469)],e[s(384)]))return a[s(562)+"8"]?{value:a[s(562)+"8"](n),offset:e[s(469)](n,1)}:{value:e[s(1271)](255,a[n]),offset:e[s(1137)](n,1)};this._isInit=!0,this[s(718)]()}function Fo(a,n,s){let d=t;return n[d(1225)+"t8"]?n[d(1225)+"t8"](a,s):n[s]=e[d(703)](255,a),e.dLARY(s,1)}let Sh=function(a){return new Uint8Array(a)},Ih=e[t(1104)](t(764)+"d",typeof Buffer)?Buffer[t(1628)+t(988)]:gh(Sh,Uint8Array[t(910)+"e"][t(1671)]);(()=>{let a=t,n={Hwqlb:a(476)+a(324)+a(1385)+"1",IrMYV:function(d,u){return e[a(478)](d,u)},nSQpR:function(d,u){return d|u},sZmZD:function(d,u){return d<<u},AoSba:function(d,u){return e.LyOAg(d,u)},hYceG:function(d,u){return e.QiGRD(d,u)},YseQD:function(d,u){return e[a(778)](d,u)},fxjno:function(d,u){return d<u},Tocgr:function(d,u){return e.SLHKD(d,u)},UbFIv:function(d,u){return d<<u},AuEsG:function(d,u){return d|u},udVia:function(d,u){return e.rCxDU(d,u)},BerIQ:function(d,u,g,_){return e.izeCC(d,u,g,_)},vfSDC:function(d,u){return e.ekcSL(d,u)},ThHvK:function(d,u){return e[a(687)](d,u)}},s=4294967295;return function(d,u,g=!0){let _=a,m=n.Hwqlb.split("|"),h=0;for(;;){switch(m[h++]){case"0":s=n.IrMYV(n[_(918)](s,n[_(848)](n[_(1799)](127,d[u]),21)),0);continue;case"1":return{value:g?s:n.hYceG(0,s),offset:u};case"2":s=n[_(1389)](n[_(966)](s,n[_(848)](n[_(661)](127,d[u]),7)),0);continue;case"3":if(n.fxjno(d[u++],128))return{value:g?s:0|s,offset:u};continue;case"4":s=n[_(785)](s,n.UbFIv(n[_(661)](127,d[u]),14))>>>0;continue;case"5":if(n[_(1433)](d[u++],128))return{value:g?s:n[_(753)](0,s),offset:u};continue;case"6":if(n[_(1388)](u+=5,d[_(1764)]))throw u=d[_(1764)],n.BerIQ(wh,u,10,d.length);continue;case"7":if(n[_(1433)](d[u++],128))return{value:g?s:0|s,offset:u};continue;case"8":s=n.IrMYV(n[_(661)](127,d[u]),0);continue;case"9":if(n[_(1433)](d[u++],128))return{value:g?s:n[_(966)](0,s),offset:u};continue;case"10":s=n[_(1389)](s|n[_(1687)](n.AoSba(15,d[u]),28),0);continue;case"11":if(n.ThHvK(d[u++],128))return{value:g?s:n.AuEsG(0,s),offset:u};continue}break}}})();let Ah=16,Uo=32;function Th(a){let n=t,s=0,d={};for(let u=0;u<a[n(1764)];u++)d[a[u][n(1272)+n(1125)]]=E0(a[u][n(1272)+n(1125)]),s+=14+d[a[u]["cursor_n"+n(1125)]];return[s,d]}function T0(a,n,s){let d=t;{let[u,g]=e[d(943)](Th,a),_=e.yXNbp(Ih,u),m=0;return a.forEach(h=>{let S=d,R=e.ItqrS[S(428)]("|"),B=0;for(;;){switch(R[B++]){case"0":console.log("service-"+S(344),m);continue;case"1":m=e[S(1338)](Fo,0,_,m);continue;case"2":console[S(603)](e[S(1356)],m);continue;case"3":console.log(e.pYbsw,m);continue;case"4":console[S(603)](e[S(1589)],m);continue;case"5":console[S(603)](e[S(487)],m);continue;case"6":m=e[S(1355)](vh,oe[S(1395)+"er"](h.cursor||n),_,m);continue;case"7":m=e.nRDwg(_h,_,m,h[S(1736)]||0);continue;case"8":console[S(603)](S(1448)+S(1600),h,h[S(1736)]);continue;case"9":m=e[S(1576)](Fo,g[h["cursor_n"+S(1125)]],_,m);continue;case"10":m=e[S(440)](bh,h[S(1272)+S(1125)],_,m);continue}break}}),{frameType:Uo,headers:[{key:e[d(843)],value:s}],payload:_}}}function Ch(a){let n=t,s=0,d=[];for(;e[n(1098)](s,a[n(706)+"th"]);){let{offset:u}=zo(a,s);s=u;let g={cursor_name:"",cursor:0,service:0},{value:_,offset:m}=e[n(654)](yh,a,s);g[n(1736)]=_,s=m;let{value:h,offset:S}=e.HmklS(zo,a,s);s=S,g[n(1272)+"ame"]=e.LMdVt(v0,a,s,e.DYGbo(s,h)),s+=h;let{value:R,offset:B}=e[n(727)](Eh,a,s);g[n(1447)]=R[n(454)](),s=B,d[n(405)](g)}return d}function Rh(){let a=t;return{frameType:Uo,headers:[{key:e[a(843)],value:e[a(757)]}],payload:void 0}}class Dh{constructor(n,s,d){let u=t;this[u(504)+u(1078)]=n,this[u(805)+u(523)]=s,this[u(346)+u(1039)]=d,this._qosDB=e.gbREo(I0,this[u(504)+"ameSpace"],e[u(509)])}async[t(1248)](){let n=t;await this._qosDB[n(1248)]()}async getCursors(){let n=t;if(e.uIqiv!==n(1234)){if(!this[n(264)][n(920)])return;let s=this["_message"+n(1039)],d=await this[n(264)].getAll();switch(console[n(603)](e[n(1369)],d),s){case e[n(598)]:return d&&d[n(1764)]?e[n(1310)](T0,d,0,this["_cursorF"+n(523)]):void 0;case e[n(268)]:return;case e[n(1727)]:return d&&d[n(1764)]?T0(d,0,this[n(805)+"ileName"]):e[n(1262)](Rh)}}else return _0x2245fc|=0,{low:_0x1a5eff,high:e[n(1765)](_0x367aaf,31),unsigned:e[n(1563)](_0xc7facc,0)}}async[t(363)](n,s,d){let u=t;return e[u(356)](e[u(401)],e[u(804)])?_0x37ac58[u(1465)]||_0x2ebf94[u(1756)]?(u(834)+" "+(_0x27357d.errMsg||"")+u(366)+(_0x1aee26.errNo||""))[u(569)]():_0x97cc16.stringify(_0x5027a6):(console[u(603)](u(1268),n,s,d),this[u(264)].set({cursor_name:n,cursor:s,service:d}))}async[t(1760)+"rs"](n){let s=t,d=Ch(n);for(let u of d)console[s(603)](e[s(1550)],d),await this[s(264)].set(u)}async[t(930)](n){let s=t;return(await this[s(264)][s(930)](n))?.[s(1447)]}async[t(1495)](){await this._qosDB.closeDB()}[t(1649)+t(516)+t(1376)](n){let s=t;e[s(512)](e[s(564)],s(453))?this["_cursorF"+s(523)]=n:_0x446b85[s(603)](_0x42c5ae)}get[t(920)](){let n=t;return this[n(264)][n(920)]}}let kh=e[t(888)];async function C0(a){let n=t,s={nczKY:e[n(417)],cLvkS:e[n(413)],rGNfX:e[n(354)]};if(e[n(1045)](n(333),n(1289))){if(!this._options[n(1036)+"S"])return null;let{aID:d,fpID:u,messageStrategy:g}=this[n(993)],_=e[n(1680)](a,kh);try{if(e[n(991)](n(1071),e[n(982)]))return this["_cursorM"+n(685)]?a&&this["_cursorM"+n(685)][n(1649)+n(516)+n(1376)](a):this[n(1141)+n(685)]=new Dh(u+"_"+d+"_"+_,_,g),this[n(1141)+"anager"][n(920)]||await this[n(1141)+"anager"][n(1248)](),this[n(1141)+n(685)];_0x4d70ab(s.nczKY),this[n(1623)](s[n(1761)],_0x5c0bb4),this[n(1623)](s[n(1634)],_0x31c250)}catch{return null}}else return this[n(264)]?.[n(363)]({message_id:_0x32d19c,timestamp:_0x32cdd1})}async function Lh(a,n){let s=t;if(e[s(512)]("OhDyo",e[s(1781)]))switch(_0x565cad){case s(1710):case"ppe":return{["x-use-"+_0xa7490e]:1,"x-tt-env":_0x274d2d};default:return{}}else{let d=e.QbXmW(Wt,a[s(1302)][s(619)],"code","-1"),u=Wt(a[s(1302)].headers,e[s(1566)],"1"),g=e[s(989)](qn,a[s(1302)][s(619)],e[s(1684)]),_=e[s(1361)](Number,e[s(1602)](qn,a[s(1302)][s(619)],e.gauXb))||0,m=Bo[s(1681)](this,a),h=e[s(1354)](Wt,a.message[s(619)],"x-msg-qos","2"),S=qn(a[s(1302)].headers,e.tJmIL),R=e[s(1713)](Number,e[s(1243)](qn,a[s(1302)][s(619)],e.AyHXI));if(m.isQoSAck)return e[s(1262)](n);let B=m[s(801)+s(536)]?await A0[s(1681)](this):null;if(e[s(1142)](a[s(1302)][s(1736)],0)&&u&&!d||a[s(1302)].service>0){if(g&&m["isQoSMes"+s(536)]&&B)return!!!await B.get(g)&&(this[s(376)+s(1266)+s(1709)](a),await B[s(363)](g,Date[s(462)]()+_)),e[s(752)](n);if(h){let H=await C0[s(1681)](this);if(!H)return this[s(376)+s(1266)+s(1709)](a),n();let j=await H[s(930)](S)??-1;if(e[s(429)](j,R))this["_dispatc"+s(1266)+"Event"](a),H[s(363)](S,R,a.message.service);else throw new Error(s(1285)+s(1073)+s(1162)+R+(s(628)+s(357)+s(1382)+"r ")+j);return e.ssAbm(n)}return this["_dispatc"+s(1266)+"Event"](a),e[s(1177)](n)}}}async function Ph(a,n){let s=t,d=Bo[s(1681)](this,a);if(!d[s(801)+s(536)])return n();let u=await A0[s(1681)](this);if(d[s(522)+"anupMessage"]&&d.ackMsgIds[s(1764)])for(let g of d[s(1755)+"s"])await u[s(1001)](g);e.vpBnj(n)}async function Oh(a,n){let s=t,d=e[s(1466)](a[s(1302)][s(1400)+"e"],Ah),u=e[s(596)](a[s(1302)][s(1400)+"e"],Uo);if(e[s(690)](!d,!u))return n();let g=qn(a[s(1302)][s(619)],e[s(843)]);if(!g)return e[s(1159)](n);let _=await C0[s(1681)](this,g);if(!_)return e[s(884)](n);if(d){let m=await _[s(1013)+"rs"](),h={frameType:m?.[s(1400)+"e"],SeqID:oe.fromNumber(this[s(411)]++),LogID:oe[s(1395)+"er"](this[s(993)].logIDGenerator()),service:9e3,method:5,headers:m?.headers,payload:m?.[s(300)]},S=e[s(1361)](T,h);this[s(307)]&&this[s(307)][s(302)+"te"]&&this[s(307)][s(868)](S)}if(u){let m=a.message[s(300)];m&&_[s(1760)+"rs"](m)}}let Nh=async function(a,n){let s=t;this[s(378)]=!1,e[s(1747)](clearTimeout,this[s(718)+s(1535)+s(230)]),e[s(226)](n)},Mh=async function(a,n){let s=t;if(!this._ws||e.nYbly(this[s(307)][s(302)+"te"],this[s(1670)]))return n();let{pingInterval:d}=this[s(993)];this[s(1008)+s(533)]?.["resetEnd"+s(855)+s(1502)]();for(let g=0;e[s(827)](g,this._messageQueue[s(1764)]);g++){if(e.xsxSV(s(387),e[s(593)]))return e[s(1470)](_0x101731(8).join("0"),e.yClhn(_0x3652bf,_0x58361b,10)[s(1523)](2))[s(744)](-8);{let _=this["_message"+s(1368)][g];if(e[s(1758)](this[s(307)][s(302)+"te"],this[s(1670)])&&e[s(364)](null,_))e[s(1287)](e[s(1512)],e[s(358)])?_0x523c7f=_0x1db6d6(_0x40c5c6):(this[s(307)]&&this[s(307)][s(868)](_),this[s(346)+s(1368)][g]=null);else break}}this["_message"+s(1368)]=this[s(346)+s(1368)][s(229)](g=>!!g),this[s(1359)+s(1201)+"Id"]=e[s(1110)](setTimeout,()=>this[s(985)](),d),this["_dispatc"+s(1343)+"nt"](a),this[s(1342)+"er"]&&this._ws&&(this[s(307)][s(1291)+"pe"]=this["_binaryT"+s(326)]);let u=this[s(1008)+s(533)]?.[s(244)+"ntEndpoint"]();this[s(510)](s(924)+u+s(1778)),e.Nkjsg(n)},Bh=async function(a,n){let s=t,d=this[s(1008)+"tManager"]?.["getCurre"+s(1025)+"nt"]();this[s(510)]("open "+d),n()};class zh extends Oo{constructor(n){let s=t,d={ztitf:function(m,h){return m===h},kphvO:e[s(1544)],BlfJp:function(m,h){return m instanceof h},gYvoV:function(m,h){return e[s(701)](m,h)},gohhr:s(1485)+"d error.",ZXXBe:function(m,h){return e[s(1454)](m,h)},UyiRB:e.NXaqw,oIUTq:e.zhllq,CbGjp:s(414),CSxNn:function(m,h,S){return e[s(1696)](m,h,S)},SCrCZ:function(m,h){return e[s(1105)](m,h)},ZGASO:function(m,h,S,R){return m(h,S,R)},FXGxD:s(1297),NJREk:function(m,h){return m!==h},FogrT:e[s(1082)],jHAHG:function(m,h){return m!==h},ZDLhY:s(315),meGrE:function(m,h){return e[s(696)](m,h)},DUizd:function(m,h,S){return m(h,S)},seqUw:function(m,h){return e[s(399)](m,h)},QnAib:function(m,h){return e[s(361)](m,h)},axLRw:function(m,h){return m===h}};super(),this[s(1095)+"igatorOn"+s(811)]=!0,this._isBrowser=Un,this[s(1247)]=eh,this[s(698)+"T"]=pn,this._isMiniWX=Rr,this[s(309)+"r"]=Dr,this[s(346)+s(1368)]=[],this._endpointManager=null,this["_readyCl"+s(929)]=!1,this[s(1181)+"ype"]=e[s(1481)],this[s(718)+s(398)]=!1,this[s(718)+s(1535)+"utId"]=null,this[s(322)+s(1394)+"tId"]=null,this[s(1359)+s(1201)+"Id"]=null,this[s(411)]=0,this._isInit=!1,this[s(845)]="",this[s(961)+s(1605)]=null,this[s(1141)+s(685)]=null,this._pingLossCounter=null,this[s(286)+"ls"]=s(1374),this.CLOSED=3,this[s(375)+"NG"]=0,this.OPEN=1,this[s(1335)]=2,this[s(1682)]=m=>{let h=s;if(e[h(1707)]!==e[h(1707)]){let S=_0x28a304[h(1647)]();return S?(S.offset=S[h(1456)]=0,S):{bytes:new _0x1308c3(64),offset:0,limit:0}}else try{if(e[h(1423)]!==e[h(1423)]){let S=this._listeners[_0x30f031];if(S)S[h(744)]()[h(584)](R=>R.fn[h(680)](R[h(273)],_0x223da3));else if(jYbIpj.ztitf(jYbIpj[h(1100)],_0x3237fa)&&!this[h(1219)]){let R=_0x51140c.length&&_0x3d4d30[0];if(jYbIpj[h(948)](R,_0x46be48))throw R;let B=new _0x53d81e(jYbIpj[h(629)](jYbIpj[h(1332)],R?jYbIpj[h(976)](jYbIpj[h(976)](" (",R.message),")"):""));throw B.context=R,R}return this}else e[h(440)](b0,this,m,[Nh,Mh,Bh])}catch(S){let R=e.CTrdV(Qe,e[h(1544)],{message:S[h(1302)],code:Kt.OPEN_ERROR,error:S});this[h(376)+"hErrorEvent"](R)}},this[s(1700)+"ge"]=async m=>{let h=s,{pingInterval:S,pingFrequency:R}=this[h(993)];if((m[h(814)]==="hi"&&d[h(1165)](d.UyiRB,R)||d[h(799)]===R)&&(this[h(377)+h(1102)](),this.emit("ping_onc"+h(913)+"s",d[h(851)]),this[h(1359)+h(1201)+"Id"]=d.CSxNn(setTimeout,this[h(985)][h(1222)](this),S)),!d[h(1766)]("hi",m.data))try{d[h(1459)](b0,this,m,[ph,xh,Ph,Oh,Lh,hh])}catch(B){let H=d[h(1367)](Qe,h(1178),{message:B[h(1302)],code:Kt["MESSAGE_"+h(1659)],error:B});this[h(376)+h(561)+h(1020)](H)}},this._onError=m=>{let h=s,S=this[h(1008)+h(533)]?.[h(1626)+"chMaxTries"](),R=this[h(1008)+"tManager"]?.[h(244)+h(1025)+"nt"]();if(S&&!m[h(1302)]){let B=h(240)+R+(h(1363)+h(715)+"es reached");this[h(376)+"hErrorEv"+h(1020)](Qe(h(1178),{message:B,code:Kt[h(772)+h(261)+"R"],error:m}));return}this._ws&&d[h(1165)](this[h(307)].readyState,this.OPEN)&&this[h(1026)+h(1223)](),this[h(376)+h(561)+"ent"](d[h(1367)](Qe,d[h(1100)],{message:m[h(1302)],code:Kt[h(368)+h(1529)],error:m}))},this[s(1557)]=async m=>{let h=s;this[h(1391)+h(1527)](),this[h(377)+h(1102)](),this._removeWsListeners(),this[h(307)]=null,this[h(718)+"Lock"]=!1;let S=this["_endpoin"+h(533)]?.[h(1626)+h(341)+"es"]();if(!S&&this[h(546)+h(1250)]()&&!this[h(426)+h(929)]){let R=this[h(1008)+h(533)]?.["getCurre"+h(1025)+"nt"](),B=this._options[h(662)+h(1467)+h(1522)](m[h(396)],m[h(1296)]);this[h(376)+h(424)+h(1020)](d[h(1367)](ct,d[h(1358)],{code:1006,reason:m[h(1296)]||"connecting faile"+h(636)+h(1678)+h(934)+h(578)+R,willReconnect:B})),B&&this[h(718)]();return}if(d[h(678)](1e3,m.code)&&this["_readyCl"+h(929)]){this[h(376)+h(424)+"ent"](d.CSxNn(ct,d[h(1358)],{code:1e3,reason:d[h(1226)]})),this[h(1008)+h(533)]?.["resetEndpointCon"+h(1502)](),this["_pingLos"+h(1392)]?.[h(279)+"nter"]();return}if(m[h(396)]!==1e3&&S)if(d[h(577)](d[h(1407)],h(315)))!this[h(718)+h(398)]&&(this[h(1008)+h(533)]?.[h(1585)+h(855)+h(1502)](),this[h(641)+h(1392)]?.[h(279)+h(828)](),this[h(426)+h(929)]=!1,this._isInit=!0,this[h(718)]());else{let R=this[h(1008)+h(533)]?.[h(244)+h(1025)+"nt"](),B=m[h(1296)];B||(B=await d.meGrE(ah,this[h(845)])),B="connecti"+h(1224)+h(1114)+B+", hostname: "+R+(h(614)+h(465)+h(1568)),this["_dispatc"+h(424)+h(1020)](ct(d[h(1358)],{code:m.code,reason:B}));let H="connect "+R+(h(1363)+h(715)+"es reached");this[h(376)+h(561)+h(1020)](Qe(h(1178),{message:H,code:Kt[h(772)+"IES_ERROR"]})),this[h(1008)+h(533)]?.[h(1585)+h(855)+h(1502)](),this[h(641)+h(1392)]?.["resetCou"+h(828)]();return}if(d[h(678)](1e3,m[h(396)])&&!m[h(1296)]){let R=this[h(1008)+"tManager"]?.[h(244)+h(1025)+"nt"]();this["_dispatchCloseEv"+h(1020)](d[h(908)](ct,d[h(1358)],{code:m[h(396)],reason:h(1422)+"ng failed, unkno"+h(1678)+h(934)+h(578)+R})),this[h(1008)+h(533)]?.["resetEnd"+h(855)+h(1502)](),this[h(641)+h(1392)]?.[h(279)+"nter"]();return}this[h(376)+"hCloseEvent"](m),this[h(1008)+h(533)]?.["resetEnd"+h(855)+h(1502)](),this[h(641)+h(1392)]?.["resetCou"+h(828)]()},this.onclose=null,this[s(1219)]=null,this[s(452)+"e"]=null,this[s(1762)]=null,this["onStartR"+s(891)]=null,this[s(403)+s(227)]=null,this[s(336)+s(1378)+s(1318)+"ct"]=null,this[s(1428)+s(1288)]=this[s(1428)+s(1288)][s(1222)](this),this["_handleO"+s(1236)]=this[s(1428)+"ffLine"].bind(this),this[s(343)+s(1609)]=this[s(343)+s(1609)][s(1222)](this),this._handlePageShow=this[s(343)+s(1643)][s(1222)](this),this._options={url:"",automaticOpen:!0,initReconnectInterval:1e3,maxReconnectInterval:1e4,reconnectIntervalGrowFactor:2,timeoutInterval:5e3,maxRetries:5,debug:!1,maxMessageQueueLength:e[s(637)](1,0),service:0,logIDGenerator:o,headers:void 0,payloadEncoding:"",payloadType:"",fpID:"",deviceID:"",accessKey:"",ttwID:"",bddID:"",aID:"",disableAutoReconnect:!1,customParams:{},pingInterval:15e3,pingTimeoutInterval:4e3,pingFrequency:"auto",pingLossCount:2,enableTransformTextPayload:!1,logIDNewConfig:{enableAutoGenerateLogIDNew:!1,userIp:""},miniProgramParams:{customHttpHeader:{}},enableAutoAck:!1,reconnectInterceptor:()=>!0,enableQoS:!1,QoSLevel:2,messageStrategy:s(1452),env:{xTTEnv:"",xUseEnv:""},listenNetworkChanged:!0};let{url:u,ws:g}=n,_=Array[s(708)](u)?u:e[s(875)](e[s(1768)],typeof u)?[u]:[];if(!_||e[s(1092)](0,_[s(1764)]))throw new Error(e[s(1238)]);if(!rh(g))throw new Error("please p"+s(684)+s(1620)+", WebSoc"+s(534)+s(1214)+s(1455)+"ined");if(Object.assign(this[s(993)],n),this[s(1008)+s(533)]=new y0(_,this[s(993)][s(878)+"es"]),this["_pingLos"+s(1392)]=new oh(this._options[s(630)+s(649)]),this[s(993)]["automati"+s(1538)])if(s(816)==="IRWaj")this._isInit=!0,this._connect();else return jYbIpj[s(340)](-1,this[s(1133)])&&jYbIpj[s(1530)](-1,this[s(1548)])?_0x107134[s(1663)](0,0,this.unsigned):jYbIpj[s(1458)](-1,this[s(1133)])?_0x2b7723[s(1663)](0,this[s(1548)]+1,this[s(821)]):_0x11cb6d.fromBits(this[s(1133)]+1,this.high,this[s(821)]);this[s(993)]["listenNe"+s(1163)+s(1314)]&&(this[s(698)+"T"]||this._isMiniWX?this[s(658)+"etWorkCh"+s(812)]():this._isBrowser&&this[s(1215)+s(1017)+s(1612)]())}["_handleO"+t(1288)](){let n=t;this[n(993)][n(335)+n(381)+n(1012)]||this[n(426)+n(929)]||this[n(1380)+n(891)]()}_handleOffLine(){let n=t;this[n(385)+n(545)+"t"]();let s=e[n(337)](Po,e[n(1052)],{message:e.lpfdk});this[n(336)+"mediatel"+n(1318)+"ct"]&&this[n(336)+n(1378)+n(1318)+"ct"](s)}[t(1215)+"balEventListener"](){let n=t;this[n(1342)+"er"]&&window[n(1655)+"Listener"](e[n(1295)],this[n(1428)+n(1288)]),this[n(1342)+"er"]&&window[n(1655)+n(1612)](n(1660),this[n(1428)+n(1236)]),this[n(1342)+"er"]&&window[n(1655)+"Listener"](e[n(1304)],this[n(343)+n(1609)]),this[n(1342)+"er"]&&window[n(1655)+n(1612)](n(553),this[n(343)+"ageShow"])}[t(1645)+t(1017)+t(1612)](){let n=t;e[n(350)](n(408),e[n(874)])?this[n(626)+n(1702)]():(this[n(1342)+"er"]&&window[n(432)+n(313)+"ner"](e[n(1295)],this[n(1428)+n(1288)]),this._isBrowser&&window[n(432)+"entListe"+n(1269)](e[n(1064)],this[n(1428)+"ffLine"]),this[n(1342)+"er"]&&window["removeEv"+n(313)+n(1269)](e[n(1304)],this[n(343)+"ageHide"]),this[n(1342)+"er"]&&window[n(432)+"entListe"+n(1269)](e.zxyBy,this._handlePageShow))}[t(343)+"ageHide"](n){let s=t;!n[s(330)+"d"]&&(this[s(1342)+"er"]&&window[s(432)+s(313)+s(1269)](e[s(1304)],this["_handleP"+s(1609)]),this._isBrowser&&window[s(432)+s(313)+"ner"](e.zxyBy,this[s(343)+s(1643)]),this[s(1297)]()),this[s(1342)+"er"]&&window[s(432)+s(313)+s(1269)](e[s(1295)],this[s(1428)+s(1288)]),this[s(1342)+"er"]&&window[s(432)+s(313)+"ner"](e[s(1064)],this[s(1428)+s(1236)])}[t(343)+t(1643)](n){let s=t;n[s(330)+"d"]&&(e[s(1105)](e[s(467)],e[s(467)])?(this[s(546)+"orOnline"]()&&(!this[s(307)]||e[s(572)](this[s(307)][s(302)+"te"],this[s(1670)])||e[s(488)](this[s(307)][s(302)+"te"],this[s(375)+"NG"]))&&this["_handleO"+s(1288)](),this[s(1342)+"er"]&&window[s(1655)+s(1612)](e.krBlG,this["_handleO"+s(1288)]),this[s(1342)+"er"]&&window[s(1655)+"Listener"](e[s(1064)],this["_handleO"+s(1236)])):(_0x1f94ef(_0x47257d,18),e[s(1257)](_0x46853e,_0x55471f,_0x139364)))}async[t(644)+t(1611)](n){let s=t,{fpID:d,deviceID:u,bddID:g,ttwID:_,accessKey:m,aID:h,customParams:S={},enableAutoAck:R,enableQoS:B,QoSLevel:H,env:j}=this[s(993)],V,We,et;this._isBrowser||this[s(1058)+"X"]||this._isMiniTT?(V=location&&e.fxdWo("https:",location[s(1136)])?e[s(1316)]:e.KZiKx,We=n[s(503)](/((^ws)|(^http))((?:[s]*:\/\/))/,""),et=/^wss(.*:\/\/)/[s(588)](n)?n:""+V+We):e.iTufC(e[s(560)],e[s(560)])?_0x55a895[s(603)](_0x270c43):(V=e[s(1316)],We=n[s(503)](/(^http)((?:[s]*:\/\/))/,""),et=/(^ws)((?:[s]*:\/\/))/[s(588)](We)?We:""+V+We);let Di=g?e[s(400)]:_?e[s(1031)]:e.FKtyX,ki=g||_||u;if(e[s(1173)](!ki,!Di))throw new Error(e[s(900)]);let Fh=e[s(721)](e[s(236)],typeof S)?await S():S,Uh=j?e[s(746)](sh,j[s(767)],j[s(1489)]):{},qo=Object[s(773)]({device_platform:e[s(1042)],version_code:e.AMTNJ,access_key:m,fpid:d,aid:h,[Di]:ki,xsack:R?1:0,xaack:R?1:0,xsqos:B?1:0,qos_level:B?H:void 0,qos_sdk_version:2,...Uh},Fh),qh=Object[s(472)](qo)[s(1411)]((Ho,Go)=>qo[Go]!==void 0?""+Ho+(Ho?"&":"?")+Go+"="+qo[Go]:Ho,"");return et+s(651)+qh}async _connect(){let n=t,s={vVUOk:function(d,u){return e[K(1242)](d,u)},QTIpy:function(d,u,g){return e[K(969)](d,u,g)},kuFiP:function(d,u,g){return e[K(1622)](d,u,g)},ddmQa:function(d,u,g,_){return e[K(1723)](d,u,g,_)}};if(e[n(1577)]===e.QPFxi){if(this._connectLock||this[n(426)+n(929)])return;this[n(718)+n(398)]=!0;try{let d=this[n(1008)+n(533)]?.[n(850)+n(1275)+n(422)+n(622)+n(1401)](),{timeoutInterval:u}=this[n(993)];if(d)if(e[n(835)]!==n(537)){let _=this[n(1008)+"tManager"]?.[n(244)+"ntEndpoint"](),m=this["_endpoin"+n(533)]?.["replaceB"+n(1442)+n(633)+"UpdateCount"](),h=this["_endpoin"+n(533)]?.[n(244)+n(1025)+"ntTriesC"+n(806)]();if(m)if(n(339)===e[n(1115)]){let S=n(240)+_+(n(864)+n(614)+n(465)+"ached, w"+n(941)+n(1101)+n(1693))+m+(n(749)+"y"),R=e[n(642)](Qe,e[n(1544)],{message:S,code:Kt[n(772)+n(261)+"R"]});this[n(510)](S),this["_dispatc"+n(561)+n(1020)](R),this[n(845)]=await this[n(644)+n(1611)](m),this[n(510)]("connect "+m+" "+h+n(287)),this[n(1791)+n(1498)+"rs"]()}else _0x148afd=_0x54c8e9(_0x2c526c),_0x55ae3a|=e[n(1708)](127&_0xbf36ce,21),e[n(771)](128,_0x3a7218)&&(_0xc76eaa=e.Ghfjg(_0x3e16bc,_0x521bbd),_0x454b25=e[n(556)](127,_0x3557a7),e[n(1726)](128,_0x425200)&&(_0x25a0d7=e.mVrRi(_0x17e537,_0x373940),_0x24e316|=e[n(298)](127,_0x4afeba)<<7));else{let S=n(240)+_+(n(864)+n(614)+n(465)+n(1568));this._debug(S),this[n(376)+n(561)+n(1020)](e[n(627)](Qe,e[n(1544)],{message:S,code:Kt["MAX_RETR"+n(261)+"R"]}));return}}else{let _=_0x1f7426[n(1091)];zeeWZZ[n(1429)](void 0,_)&&(zeeWZZ.QTIpy(_0x14c6a1,_0x3de699,10),zeeWZZ[n(1183)](_0x2314ea,_0x3af578,_));let m=_0x3c2f39.value;zeeWZZ[n(1429)](void 0,m)&&(_0x3d8a40(_0x1ecd4e,18),zeeWZZ[n(1606)](_0x1fbb88,_0x1dcfd1,m))}else{let _=this[n(1008)+n(533)]?.[n(244)+n(1025)+n(379)+n(832)](),m=this[n(1008)+n(533)]?.[n(244)+n(1025)+"ntTriesC"+n(806)]();this._url=await this["_generat"+n(1611)](e[n(871)](_,"")),this._debug(n(240)+_+" "+m+n(287)),this[n(1791)+n(1498)+"rs"]()}if(this._isInit)this[n(378)]=!1;else{let _=e[n(882)](Po,e.JMkiD,{message:e[n(639)]});this[n(542)+n(891)]&&this[n(542)+"econnect"](_)}let g=this["_endpoin"+n(533)]?.["getCurrentEndpoi"+n(1113)+"ount"]()||0;g>1&&await this[n(645)](e[n(1139)](g,1)),this[n(510)](n(1422)+n(595)+this[n(845)]+(n(301)+n(1109))+this[n(286)+"ls"]),this[n(307)]=e.QYHnR(nh,{url:this._url,protocols:[this[n(286)+"ls"]],headers:this[n(993)][n(436)+n(1075)+"s"][n(747)+n(974)]},this[n(993)].ws),(this[n(1342)+"er"]||this[n(309)+"r"])&&this[n(307)]&&(this[n(307)][n(1291)+"pe"]=this[n(1181)+n(326)]),this["_addWsLi"+n(1732)](),this._connectionTimeoutId=setTimeout(this[n(1132)+"ut"][n(1222)](this),u)}catch(d){throw this[n(718)+"Lock"]=!1,d}}else throw _0x5124ff=_0x386412[n(1764)],zeeWZZ[n(1718)](_0x40be32,_0x3367f3,10,_0x1e4fe6[n(1764)])}[t(1391)+"mer"](){let n=t;clearTimeout(this[n(718)+"ionTimeo"+n(230)]),this[n(718)+n(1535)+n(230)]=null}[t(377)+t(1102)](){let n=t;e[n(1361)](clearTimeout,this["_pingPon"+n(1201)+"Id"]),e[n(1460)](clearTimeout,this[n(322)+n(1394)+n(1490)]),this[n(1359)+n(1201)+"Id"]=null,this[n(322)+n(1394)+n(1490)]=null}[t(510)](...n){let s=t;this._options[s(1588)]&&console.log[s(680)](console,[e[s(524)],...n])}["_getInte"+t(1007)+"e"](n){let s=t;if(e[s(1573)](e[s(234)],e[s(234)]))_0x79e5ef-=65536,_0x5adc10+=_0x121971(e[s(817)](e[s(304)](_0x33d957,10),55296),e[s(817)](e.nnMwH(1023,_0x3761a8),56320)),_0xb2eb3f+=3;else{let{initReconnectInterval:d,maxReconnectInterval:u,reconnectIntervalGrowFactor:g}=this._options,_=e.uuDnB(d,Math.pow(g,n-1));return e[s(1607)](_,u)?u:_}}[t(985)](){let n=t;if(this[n(307)]&&e[n(609)](this[n(307)][n(302)+"te"],this[n(375)+"NG"])){this[n(377)+n(1102)](),this[n(1359)+n(1201)+"Id"]=e.RdhDt(setTimeout,this._ping.bind(this),this[n(993)][n(505)+n(1790)]);return}if(!this._ws||e.XaOOD(this[n(307)][n(302)+"te"],this.OPEN))return void this[n(1380)+n(891)]();this[n(307)]&&this[n(307)].send("hi"),this[n(322)+n(1394)+"tId"]=e[n(1094)](setTimeout,this["_handleR"+n(891)+"Timeout"][n(1222)](this),this._options["pingTime"+n(1409)+"val"])}[t(1380)+t(891)+"Timeout"](){let n=t,s={YhiBL:e[n(1544)],ZAWxp:function(d,u){return d(u)},VrFlU:function(d){return d()}};if(e[n(1505)](n(726),n(484)))this["_pingLos"+n(1392)]?.[n(606)](),this[n(412)](n(1661)+n(717)+"t",n(1769)),this[n(641)+"sCounter"]?.["checkRea"+n(1273)+"nt"]()?this[n(1380)+n(891)]():this[n(985)]();else{let d={ApvUG:function(m,h){return m(h)},GssEK:function(m){let h=n;return pLVPti[h(226)](m)}},u=()=>{let m=n;_0x56cd36[m(432)+m(313)+m(1269)](m(414),g),_0x19f23a[m(432)+m(313)+m(1269)](XWFOre.YhiBL,_)},g=()=>{let m=n;XWFOre[m(235)](_0x15068f,XWFOre[m(235)](_0x5c80b2,_0xd72865.result)),XWFOre[m(1126)](u)},_=()=>{let m=n;d[m(1067)](_0x1d231f,_0x223b02[m(1178)]),d[m(766)](u)};_0x4c7baf[n(1655)+n(1612)](pLVPti.bqbUz,g),_0x214aab[n(1655)+"Listener"](pLVPti[n(1544)],_)}}[t(546)+t(1250)](){let n=t;return this[n(698)+"T"]||this[n(1058)+"X"]?this[n(1095)+n(1122)+n(811)]:(this._isBrowser||this[n(309)+"r"])&&this._options["listenNe"+n(1163)+n(1314)]?navigator[n(554)]:!0}[t(1380)+t(891)](){let n=t;!this[n(546)+n(1250)]()||this[n(426)+n(929)]||(this[n(1008)+n(533)]?.[n(1585)+n(855)+n(1502)](),this[n(641)+n(1392)]?.[n(279)+n(828)](),this[n(307)]?this[n(1026)+n(1223)](1001,n(1373)+n(566)+n(662)+n(1507)+n(1043),!0):this._connect())}[t(658)+t(782)+"ange"](){let n=t;if(e[n(946)](e[n(1258)],e.mMvWQ)){let s=this[n(264)][n(589)](this[n(970)]),d=_0x495026[n(1740)](e[n(1173)](s,"{}"));return d[_0x1a55b7]=void 0,this[n(264)][n(471)](this[n(970)],_0x31be00.stringify(d))}else this[n(698)+"T"]?tt["onNetwor"+n(1486)+"hange"](({isConnected:s})=>{let d=n;this[d(1095)+d(1122)+d(811)]=s,s?this[d(1428)+"nLine"]():this[d(1428)+"ffLine"]()}):this._isMiniWX&&wx[n(1772)+n(1486)+n(1580)](({isConnected:s})=>{let d=n;d(1309)==="nWBNP"?(this["_miniNav"+d(1122)+d(811)]=s,s?this[d(1428)+d(1288)]():this["_handleO"+d(1236)]()):_0x3b84ee[d(813)]=_0xbf59b9.resolve()[d(901)](()=>(_0x5558d2(),_0x1d0831))[d(901)](function(u){return u})})}[t(645)](n){return new Promise(s=>{let d=K;setTimeout(s,this[d(1246)+d(1007)+"e"](n))})}[t(1026)+"ect"](n=1e3,s="",d=!1){let u=t;this._ws&&this[u(385)+"WebSocket"](n,s,d)}[t(1132)+"ut"](){let n=t,s=this[n(1008)+n(533)]?.[n(244)+n(1025)+"nt"]();this[n(510)](n(240)+s+n(864)),this["_disconn"+n(1223)](1001,e[n(663)],!0)}[t(1552)](n){let s=t,d=e.eOPMc(je,n);this._ws&&e[s(605)](this._ws[s(302)+"te"],this[s(1670)])&&(this[s(307)]&&this[s(307)].send(d),this[s(510)](e[s(1614)],n))}_removeWsListeners(){let n=t;if(e[n(1207)]!==n(1074)){let s="2|4|0|1|3"[n(428)]("|"),d=0;for(;;){switch(s[d++]){case"0":this[n(307)][n(432)+"entListe"+n(1269)](e[n(292)],this._onClose);continue;case"1":this[n(307)]["removeEv"+n(313)+n(1269)](e.YABKy,this._onMessage);continue;case"2":if(!this[n(307)])return;continue;case"3":this[n(307)][n(432)+n(313)+n(1269)]("error",this[n(1336)]);continue;case"4":this[n(307)][n(432)+n(313)+n(1269)](e[n(986)],this._onOpen);continue}break}}else return _0x2e4ed5?this[n(1135)+"E"]():this.toBytesBE()}[t(692)+t(1732)](){let n=t,s=e[n(736)][n(428)]("|"),d=0;for(;;){switch(s[d++]){case"0":this[n(307)]["addEvent"+n(1612)](e.pvnMk,this._onError);continue;case"1":this._ws["addEvent"+n(1612)](n(1297),this[n(1557)]);continue;case"2":if(!this._ws)return;continue;case"3":this[n(307)][n(1655)+n(1612)](e.rrkRR,this[n(1682)]);continue;case"4":this[n(307)][n(1655)+n(1612)](e.YABKy,this[n(1700)+"ge"]);continue}break}}[t(1497)+t(459)](n=1e3,s=""){let d=t,u={gAWpx:function(g,_,m){return e[K(1151)](g,_,m)},QqRwU:e[d(1052)],WXGpr:e[d(639)]};if(e[d(1319)]==="QwmsJ")try{this[d(307)]&&this[d(307)][d(1297)](n,s)}catch{}else{let g=twVsVL.gAWpx(_0x2c9812,twVsVL[d(1759)],{message:twVsVL[d(702)]});this.onStartReconnect&&this.onStartReconnect(g)}}[t(385)+t(545)+"t"](n=1e3,s="",d=!1){let u=t;if(e[u(585)](e[u(784)],e[u(784)])){if(this[u(377)+"ngTimer"](),this["_clearTi"+u(1527)](),this["_removeW"+u(1498)+"rs"](),this[u(1497)+u(459)](1e3,s),this[u(718)+u(398)]=!1,d&&this["_navigat"+u(1250)]()&&!this[u(426)+"osed"]){if(this[u(1008)+u(533)]?.["checkRea"+u(341)+"es"]()){let _=this[u(1008)+"tManager"]?.getCurrentEndpoint();this[u(376)+u(424)+u(1020)](e[u(1602)](ct,e.GMTNy,{code:1006,reason:"connect "+_+(u(864)+u(614)+u(465)+u(1568)),wasClean:!0}))}else{let _=this[u(993)][u(662)+"tInterce"+u(1522)](n,s);this[u(376)+u(424)+u(1020)](ct(u(1297),{code:n,reason:s,wasClean:!0,willReconnect:_})),_&&this[u(718)]()}return}this._navigatorOnline()||this[u(426)+u(929)]?this[u(376)+"hCloseEv"+u(1020)](e.hunmG(ct,e[u(292)],{code:n,reason:"bye"})):this[u(376)+u(424)+u(1020)](ct(e.GMTNy,{code:1006,reason:"going aw"+u(1157)+u(1277)+"ine"})),this._ws=null,this._endpointManager?.["resetEnd"+u(855)+u(1502)](),this["_pingLos"+u(1392)]?.[u(279)+u(828)]()}else return this[u(854)][u(1322)+"ns"]}[t(376)+t(1343)+"nt"](n){let s=t;this[s(412)](e[s(986)],n),this[s(1762)]&&this[s(1762)](n)}[t(376)+t(1266)+t(1709)](n){let s=t;this[s(412)](e[s(1009)],n),this[s(452)+"e"]&&this[s(452)+"e"](n)}[t(376)+t(1203)+t(865)](n){let s=t;this[s(412)](e[s(349)],n),this[s(403)+s(227)]&&this[s(403)+"eAck"](n)}[t(376)+t(561)+t(1020)](n){let s=t;this[s(412)](e.pvnMk,n),this[s(1219)]&&this[s(1219)](n)}[t(376)+t(424)+t(1020)](n){let s=t;this[s(412)](e[s(292)],n),this[s(1619)]&&this[s(1619)](n)}get[t(1291)+"pe"](){let n=t;return this[n(307)]?this[n(307)][n(1291)+"pe"]:this[n(1181)+n(326)]}set[t(1291)+"pe"](n){let s=t;this["_binaryT"+s(326)]=n,this[s(307)]&&(this._ws.binaryType=n)}get[t(1049)+"nt"](){let n=t;return this["_endpoin"+n(533)]?.[n(244)+n(1025)+n(1113)+"ount"]()||0}get[t(446)+t(676)](){let n=t,s={Btbgv:n(764)+"d",xIWZo:e.GWxWv};if(e[n(1677)]===e.MWgeM)_0x33b01.r=d=>{let u=n;pxyUhq[u(621)]!=typeof _0x418e11&&_0x387760[u(1523)+u(351)]&&_0x2b53ea["definePr"+u(507)](d,_0x2efd09[u(1523)+u(351)],{value:u(1783)}),_0x15cda5[u(1751)+u(507)](d,pxyUhq[u(795)],{value:!0})};else{let d=this["_message"+n(1368)][n(1411)]((u,g)=>(u+=g&&g.byteLength||0,u),0);return e[n(451)](d,this._ws?this[n(307)]["buffered"+n(676)]:0)}}get[t(1322)+"ns"](){let n=t;return this._ws?this[n(307)].extensions:""}get[t(1136)](){let n=t;return this._ws?this[n(307)][n(1136)]:""}get[t(302)+"te"](){let n=t;return this._ws?this[n(307)][n(302)+"te"]:this._options[n(365)+n(1538)]?this[n(375)+"NG"]:this[n(1511)]}get url(){let n=t;return this._ws?this[n(307)][n(1689)]:this[n(845)]}[t(1297)](n=1e3,s){let d=t;if(this[d(426)+d(929)]=!0,this[d(1391)+d(1527)](),this[d(377)+d(1102)](),this["_dropGlo"+d(1017)+d(1612)](),this[d(961)+d(1605)]?.[d(1495)](),!this[d(307)])return void this._debug(d(786)+"s instan"+d(728)+d(1441)+"ed");if(e.ztCjM(this[d(307)][d(302)+"te"],this[d(1511)])||this[d(307)][d(302)+"te"]===this[d(1335)])return void this._debug(e.qgwpJ);this[d(385)+d(545)+"t"](n,s)}async[t(868)](n,s){let d=t;if(e[d(1505)](e[d(892)],e.SrqBf))return(this[d(1154)+"rs"][_0x1c1c3c]||(this[d(1154)+"rs"][_0x165576]=[]))[d(405)]({fn:_0x51db74,ctx:_0x12a8d2||this}),this;{if(e[d(353)](null,n))throw new Error(e[d(1182)]);e[d(353)](d(653),typeof n)&&(n=JSON[d(923)+"y"](n)),e.Pzhba(e[d(1768)],typeof n)&&!e[d(1301)](n,ArrayBuffer)&&!(n[d(1051)]&&n.buffer instanceof ArrayBuffer)&&(n=JSON.stringify(n));let u=await e[d(416)](S0,n),g=e.OkHEM(ih,n),{method:_=0,service:m=this[d(993)].service,logID:h=this[d(993)][d(1393)+d(1517)](),headers:S=this[d(993)].headers,payloadEncoding:R=this[d(993)][d(427)+d(1144)],payloadType:B=this[d(993)][d(1185)+d(326)],logIDNew:H=this[d(993)][d(1746)+d(1237)]["enableAu"+d(1352)+d(635)+"ew"]?e[d(937)](i,this._options["logIDNew"+d(1237)][d(688)]):""}=e[d(1118)](s,{});if(!m)throw new Error(e[d(1334)]);let j={SeqID:oe[d(1395)+"er"](this[d(411)]++),LogID:oe[d(1395)+"er"](h),service:m,method:_,headers:S,payloadEncoding:R instanceof Object?R.encoding?R[d(830)]:"":R,payloadType:e.kHMEt(B,Object)?B[d(695)]?B[d(695)]:g:B||g,payload:u,LogIDNew:H},V=je(j);return this._ws&&this[d(307)][d(302)+"te"]===this.OPEN?(this._ws&&this[d(307)][d(868)](V),this[d(510)](e.WmEPv,j)):e[d(1615)](this[d(346)+d(1368)][d(1764)],this._options[d(458)+d(1244)+d(278)])?(this[d(346)+d(1368)][d(405)](V),this[d(510)](e[d(496)],j)):e[d(657)](e[d(1068)],e.BceAH)?(e.VlmNV(_0x3d8cf2,_0x31371a,90),e[d(881)](_0x1dde93,_0x5f5ceb,_0x38eec2)):(this[d(346)+"Queue"][d(489)](),this._messageQueue[d(405)](V)),{seqID:this[d(411)],logID:h,logIDNew:H}}}async[t(662)+"t"](n){let s=t,{url:d}=e[s(944)](n,{}),u=Array[s(708)](d)?d:e.XfImb==typeof d?[d]:[];n&&Object.assign(this[s(993)],n),u&&u[s(1764)]?this["_endpoin"+s(533)]=new y0(u,this._options.maxRetries):this["_endpoin"+s(533)]?.[s(1585)+s(855)+s(1502)](),this["_pingLos"+s(1392)]?.[s(279)+"nter"](this._options[s(630)+s(649)]),this[s(426)+s(929)]=!1,this[s(307)]&&e.Uoiha(this[s(307)][s(302)+"te"],this.CLOSED)?this[s(1026)+"ect"](1e3,s(224)+s(891)+s(269),!0):(this[s(378)]=!0,this[s(718)]())}async connect(){let n=t;if(!this[n(718)+n(398)]){let s=e[n(323)][n(428)]("|"),d=0;for(;;){switch(s[d++]){case"0":this[n(1008)+"tManager"]?.["resetEnd"+n(855)+n(1502)]();continue;case"1":this[n(641)+n(1392)]?.["resetCou"+n(828)]();continue;case"2":this._connect();continue;case"3":this[n(378)]=!0;continue;case"4":this[n(426)+n(929)]=!1;continue}break}}}[t(1655)+"Listener"](n,s){this.on(n,s)}[t(917)+"Event"](n){let{type:s}=n;this.emit(s,n)}[t(432)+t(313)+t(1269)](n,s){let d=t;if(e[d(1032)](e[d(1728)],"jiacj"))this.off(n,s);else return this[d(376)+"hMessage"+d(1709)](_0x55005e),e[d(1159)](_0x26acd0)}[t(1364)](){return new Promise((n,s)=>{let d=K,u={eWzAZ:function(m,h){return m(h)},NlWrq:d(414),avdxE:e[d(413)],Glsuf:e.GWSLr,FurGx:function(m,h){return e.fALNl(m,h)},TKwjM:e[d(417)]};this[d(377)+d(1102)](),this[d(1359)+d(1201)+"Id"]=e[d(1076)](setTimeout,this._ping[d(1222)](this),this._options[d(505)+"rval"]);let g=()=>{let m=d;u[m(360)](n,u[m(1312)]),this[m(1623)](u.avdxE,g),this[m(1623)](u[m(1097)],_)},_=()=>{let m=d;u[m(1493)](s,u[m(1191)]),this[m(1623)](u[m(666)],g),this.off(m(1661)+"e_timeout",_)};this.on(e[d(413)],g),this.on(e[d(354)],_),this[d(985)]()})}}})(),Se[M(1111)+"oseEvent"]=be[M(1111)+"oseEvent"],Se[M(912)+M(839)]=be[M(912)+M(839)],Se.ErrorCode=be.ErrorCode,Se.Event=be[M(1709)],Se.FWS=be[M(486)],Se[M(1057)+M(297)+M(402)]=be[M(1057)+"MessageE"+M(402)],Se[M(297)+M(402)]=be[M(297)+M(402)],Se.OpenEvent=be[M(497)+"t"],Se["Reconnec"+M(975)]=be[M(1484)+"tEvent"],Se[M(557)+"oseEvent"]=be[M(557)+"oseEvent"],Se[M(1292)+M(839)]=be[M(1292)+"rorEvent"],Se[M(735)+M(1508)+"nt"]=be[M(735)+M(1508)+"nt"],Se[M(792)+M(691)]=be[M(792)+M(691)],Se.createReconnectEvent=be[M(431)+M(258)+M(402)],Se[M(1427)+M(550)]=be[M(1427)+M(550)],Se[M(1253)+M(1125)]=be[M(1253)+M(1125)];for(Xs in be)["CustomCl"+M(1146),M(912)+M(839),"ErrorCode",M(1709),M(486),M(1057)+"MessageE"+M(402),M(297)+"vent","OpenEvent",M(1484)+M(975),M(557)+"oseEvent","createEr"+M(839),"createMe"+M(1508)+"nt",M(792)+M(691),M(431)+M(258)+M(402),"decodedF"+M(550),"encodeFr"+M(1125)].indexOf(Xs)===-1&&(Se[Xs]=be[Xs]);var Xs;Object["definePr"+M(507)](Se,M(1211)+"le",{value:!0})});var zt=ne((wI,hl)=>{"use strict";var ll=["nodebuffer","arraybuffer","fragments"],xl=typeof Blob<"u";xl&&ll.push("blob");hl.exports={BINARY_TYPES:ll,CLOSE_TIMEOUT:3e4,EMPTY_BUFFER:Buffer.alloc(0),GUID:"258EAFA5-E914-47DA-95CA-C5AB0DC85B11",hasBlob:xl,kForOnEventAttribute:Symbol("kIsForOnEventAttribute"),kListener:Symbol("kListener"),kStatusCode:Symbol("status-code"),kWebSocket:Symbol("websocket"),NOOP:()=>{}}});var yi=ne((_I,so)=>{"use strict";var{EMPTY_BUFFER:xy}=zt(),Ac=Buffer[Symbol.species];function hy(t,e){if(t.length===0)return xy;if(t.length===1)return t[0];let r=Buffer.allocUnsafe(e),i=0;for(let o=0;o<t.length;o++){let c=t[o];r.set(c,i),i+=c.length}return i<e?new Ac(r.buffer,r.byteOffset,i):r}function pl(t,e,r,i,o){for(let c=0;c<o;c++)r[i+c]=t[c]^e[c&3]}function gl(t,e){for(let r=0;r<t.length;r++)t[r]^=e[r&3]}function py(t){return t.length===t.buffer.byteLength?t.buffer:t.buffer.slice(t.byteOffset,t.byteOffset+t.length)}function Tc(t){if(Tc.readOnly=!0,Buffer.isBuffer(t))return t;let e;return t instanceof ArrayBuffer?e=new Ac(t):ArrayBuffer.isView(t)?e=new Ac(t.buffer,t.byteOffset,t.byteLength):(e=Buffer.from(t),Tc.readOnly=!1),e}so.exports={concat:hy,mask:pl,toArrayBuffer:py,toBuffer:Tc,unmask:gl};if(!process.env.WS_NO_BUFFER_UTIL)try{let t=ae("bufferutil");so.exports.mask=function(e,r,i,o,c){c<48?pl(e,r,i,o,c):t.mask(e,r,i,o,c)},so.exports.unmask=function(e,r){e.length<32?gl(e,r):t.unmask(e,r)}}catch{}});var _l=ne((yI,wl)=>{"use strict";var ml=Symbol("kDone"),Cc=Symbol("kRun"),Rc=class{constructor(e){this[ml]=()=>{this.pending--,this[Cc]()},this.concurrency=e||1/0,this.jobs=[],this.pending=0}add(e){this.jobs.push(e),this[Cc]()}[Cc](){if(this.pending!==this.concurrency&&this.jobs.length){let e=this.jobs.shift();this.pending++,e(this[ml])}}};wl.exports=Rc});var Er=ne((bI,vl)=>{"use strict";var bi=ae("zlib"),yl=yi(),gy=_l(),{kStatusCode:bl}=zt(),my=Buffer[Symbol.species],wy=Buffer.from([0,0,255,255]),ao=Symbol("permessage-deflate"),Ft=Symbol("total-length"),yr=Symbol("callback"),xn=Symbol("buffers"),br=Symbol("error"),oo,Dc=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,!oo){let r=this._options.concurrencyLimit!==void 0?this._options.concurrencyLimit:10;oo=new gy(r)}}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[yr];this._deflate.close(),this._deflate=null,e&&e(new Error("The deflate stream was closed while data was being processed"))}}acceptAsServer(e){let r=this._options,i=e.find(o=>!(r.serverNoContextTakeover===!1&&o.server_no_context_takeover||o.server_max_window_bits&&(r.serverMaxWindowBits===!1||typeof r.serverMaxWindowBits=="number"&&r.serverMaxWindowBits>o.server_max_window_bits)||typeof r.clientMaxWindowBits=="number"&&!o.client_max_window_bits));if(!i)throw new Error("None of the extension offers can be accepted");return r.serverNoContextTakeover&&(i.server_no_context_takeover=!0),r.clientNoContextTakeover&&(i.client_no_context_takeover=!0),typeof r.serverMaxWindowBits=="number"&&(i.server_max_window_bits=r.serverMaxWindowBits),typeof r.clientMaxWindowBits=="number"?i.client_max_window_bits=r.clientMaxWindowBits:(i.client_max_window_bits===!0||r.clientMaxWindowBits===!1)&&delete i.client_max_window_bits,i}acceptAsClient(e){let r=e[0];if(this._options.clientNoContextTakeover===!1&&r.client_no_context_takeover)throw new Error('Unexpected parameter "client_no_context_takeover"');if(!r.client_max_window_bits)typeof this._options.clientMaxWindowBits=="number"&&(r.client_max_window_bits=this._options.clientMaxWindowBits);else if(this._options.clientMaxWindowBits===!1||typeof this._options.clientMaxWindowBits=="number"&&r.client_max_window_bits>this._options.clientMaxWindowBits)throw new Error('Unexpected or invalid parameter "client_max_window_bits"');return r}normalizeParams(e){return e.forEach(r=>{Object.keys(r).forEach(i=>{let o=r[i];if(o.length>1)throw new Error(`Parameter "${i}" must have only a single value`);if(o=o[0],i==="client_max_window_bits"){if(o!==!0){let c=+o;if(!Number.isInteger(c)||c<8||c>15)throw new TypeError(`Invalid value for parameter "${i}": ${o}`);o=c}else if(!this._isServer)throw new TypeError(`Invalid value for parameter "${i}": ${o}`)}else if(i==="server_max_window_bits"){let c=+o;if(!Number.isInteger(c)||c<8||c>15)throw new TypeError(`Invalid value for parameter "${i}": ${o}`);o=c}else if(i==="client_no_context_takeover"||i==="server_no_context_takeover"){if(o!==!0)throw new TypeError(`Invalid value for parameter "${i}": ${o}`)}else throw new Error(`Unknown parameter "${i}"`);r[i]=o})}),e}decompress(e,r,i){oo.add(o=>{this._decompress(e,r,(c,f)=>{o(),i(c,f)})})}compress(e,r,i){oo.add(o=>{this._compress(e,r,(c,f)=>{o(),i(c,f)})})}_decompress(e,r,i){let o=this._isServer?"client":"server";if(!this._inflate){let c=`${o}_max_window_bits`,f=typeof this.params[c]!="number"?bi.Z_DEFAULT_WINDOWBITS:this.params[c];this._inflate=bi.createInflateRaw({...this._options.zlibInflateOptions,windowBits:f}),this._inflate[ao]=this,this._inflate[Ft]=0,this._inflate[xn]=[],this._inflate.on("error",yy),this._inflate.on("data",El)}this._inflate[yr]=i,this._inflate.write(e),r&&this._inflate.write(wy),this._inflate.flush(()=>{let c=this._inflate[br];if(c){this._inflate.close(),this._inflate=null,i(c);return}let f=yl.concat(this._inflate[xn],this._inflate[Ft]);this._inflate._readableState.endEmitted?(this._inflate.close(),this._inflate=null):(this._inflate[Ft]=0,this._inflate[xn]=[],r&&this.params[`${o}_no_context_takeover`]&&this._inflate.reset()),i(null,f)})}_compress(e,r,i){let o=this._isServer?"server":"client";if(!this._deflate){let c=`${o}_max_window_bits`,f=typeof this.params[c]!="number"?bi.Z_DEFAULT_WINDOWBITS:this.params[c];this._deflate=bi.createDeflateRaw({...this._options.zlibDeflateOptions,windowBits:f}),this._deflate[Ft]=0,this._deflate[xn]=[],this._deflate.on("data",_y)}this._deflate[yr]=i,this._deflate.write(e),this._deflate.flush(bi.Z_SYNC_FLUSH,()=>{if(!this._deflate)return;let c=yl.concat(this._deflate[xn],this._deflate[Ft]);r&&(c=new my(c.buffer,c.byteOffset,c.length-4)),this._deflate[yr]=null,this._deflate[Ft]=0,this._deflate[xn]=[],r&&this.params[`${o}_no_context_takeover`]&&this._deflate.reset(),i(null,c)})}};vl.exports=Dc;function _y(t){this[xn].push(t),this[Ft]+=t.length}function El(t){if(this[Ft]+=t.length,this[ao]._maxPayload<1||this[Ft]<=this[ao]._maxPayload){this[xn].push(t);return}this[br]=new RangeError("Max payload size exceeded"),this[br].code="WS_ERR_UNSUPPORTED_MESSAGE_LENGTH",this[br][bl]=1009,this.removeListener("data",El),this.reset()}function yy(t){if(this[ao]._inflate=null,this[br]){this[yr](this[br]);return}t[bl]=1007,this[yr](t)}});var vr=ne((EI,co)=>{"use strict";var{isUtf8:Sl}=ae("buffer"),{hasBlob:by}=zt(),Ey=[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 vy(t){return t>=1e3&&t<=1014&&t!==1004&&t!==1005&&t!==1006||t>=3e3&&t<=4999}function kc(t){let e=t.length,r=0;for(;r<e;)if((t[r]&128)===0)r++;else if((t[r]&224)===192){if(r+1===e||(t[r+1]&192)!==128||(t[r]&254)===192)return!1;r+=2}else if((t[r]&240)===224){if(r+2>=e||(t[r+1]&192)!==128||(t[r+2]&192)!==128||t[r]===224&&(t[r+1]&224)===128||t[r]===237&&(t[r+1]&224)===160)return!1;r+=3}else if((t[r]&248)===240){if(r+3>=e||(t[r+1]&192)!==128||(t[r+2]&192)!==128||(t[r+3]&192)!==128||t[r]===240&&(t[r+1]&240)===128||t[r]===244&&t[r+1]>143||t[r]>244)return!1;r+=4}else return!1;return!0}function Sy(t){return by&&typeof t=="object"&&typeof t.arrayBuffer=="function"&&typeof t.type=="string"&&typeof t.stream=="function"&&(t[Symbol.toStringTag]==="Blob"||t[Symbol.toStringTag]==="File")}co.exports={isBlob:Sy,isValidStatusCode:vy,isValidUTF8:kc,tokenChars:Ey};if(Sl)co.exports.isValidUTF8=function(t){return t.length<24?kc(t):Sl(t)};else if(!process.env.WS_NO_UTF_8_VALIDATE)try{let t=ae("utf-8-validate");co.exports.isValidUTF8=function(e){return e.length<32?kc(e):t(e)}}catch{}});var Mc=ne((vI,kl)=>{"use strict";var{Writable:Iy}=ae("stream"),Il=Er(),{BINARY_TYPES:Ay,EMPTY_BUFFER:Al,kStatusCode:Ty,kWebSocket:Cy}=zt(),{concat:Lc,toArrayBuffer:Ry,unmask:Dy}=yi(),{isValidStatusCode:ky,isValidUTF8:Tl}=vr(),fo=Buffer[Symbol.species],st=0,Cl=1,Rl=2,Dl=3,Pc=4,Oc=5,uo=6,Nc=class extends Iy{constructor(e={}){super(),this._allowSynchronousEvents=e.allowSynchronousEvents!==void 0?e.allowSynchronousEvents:!0,this._binaryType=e.binaryType||Ay[0],this._extensions=e.extensions||{},this._isServer=!!e.isServer,this._maxPayload=e.maxPayload|0,this._skipUTF8Validation=!!e.skipUTF8Validation,this[Cy]=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=st}_write(e,r,i){if(this._opcode===8&&this._state==st)return i();this._bufferedBytes+=e.length,this._buffers.push(e),this.startLoop(i)}consume(e){if(this._bufferedBytes-=e,e===this._buffers[0].length)return this._buffers.shift();if(e<this._buffers[0].length){let i=this._buffers[0];return this._buffers[0]=new fo(i.buffer,i.byteOffset+e,i.length-e),new fo(i.buffer,i.byteOffset,e)}let r=Buffer.allocUnsafe(e);do{let i=this._buffers[0],o=r.length-e;e>=i.length?r.set(this._buffers.shift(),o):(r.set(new Uint8Array(i.buffer,i.byteOffset,e),o),this._buffers[0]=new fo(i.buffer,i.byteOffset+e,i.length-e)),e-=i.length}while(e>0);return r}startLoop(e){this._loop=!0;do switch(this._state){case st:this.getInfo(e);break;case Cl:this.getPayloadLength16(e);break;case Rl:this.getPayloadLength64(e);break;case Dl:this.getMask();break;case Pc:this.getData(e);break;case Oc:case uo:this._loop=!1;return}while(this._loop);this._errored||e()}getInfo(e){if(this._bufferedBytes<2){this._loop=!1;return}let r=this.consume(2);if((r[0]&48)!==0){let o=this.createError(RangeError,"RSV2 and RSV3 must be clear",!0,1002,"WS_ERR_UNEXPECTED_RSV_2_3");e(o);return}let i=(r[0]&64)===64;if(i&&!this._extensions[Il.extensionName]){let o=this.createError(RangeError,"RSV1 must be clear",!0,1002,"WS_ERR_UNEXPECTED_RSV_1");e(o);return}if(this._fin=(r[0]&128)===128,this._opcode=r[0]&15,this._payloadLength=r[1]&127,this._opcode===0){if(i){let o=this.createError(RangeError,"RSV1 must be clear",!0,1002,"WS_ERR_UNEXPECTED_RSV_1");e(o);return}if(!this._fragmented){let o=this.createError(RangeError,"invalid opcode 0",!0,1002,"WS_ERR_INVALID_OPCODE");e(o);return}this._opcode=this._fragmented}else if(this._opcode===1||this._opcode===2){if(this._fragmented){let o=this.createError(RangeError,`invalid opcode ${this._opcode}`,!0,1002,"WS_ERR_INVALID_OPCODE");e(o);return}this._compressed=i}else if(this._opcode>7&&this._opcode<11){if(!this._fin){let o=this.createError(RangeError,"FIN must be set",!0,1002,"WS_ERR_EXPECTED_FIN");e(o);return}if(i){let o=this.createError(RangeError,"RSV1 must be clear",!0,1002,"WS_ERR_UNEXPECTED_RSV_1");e(o);return}if(this._payloadLength>125||this._opcode===8&&this._payloadLength===1){let o=this.createError(RangeError,`invalid payload length ${this._payloadLength}`,!0,1002,"WS_ERR_INVALID_CONTROL_PAYLOAD_LENGTH");e(o);return}}else{let o=this.createError(RangeError,`invalid opcode ${this._opcode}`,!0,1002,"WS_ERR_INVALID_OPCODE");e(o);return}if(!this._fin&&!this._fragmented&&(this._fragmented=this._opcode),this._masked=(r[1]&128)===128,this._isServer){if(!this._masked){let o=this.createError(RangeError,"MASK must be set",!0,1002,"WS_ERR_EXPECTED_MASK");e(o);return}}else if(this._masked){let o=this.createError(RangeError,"MASK must be clear",!0,1002,"WS_ERR_UNEXPECTED_MASK");e(o);return}this._payloadLength===126?this._state=Cl:this._payloadLength===127?this._state=Rl: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 r=this.consume(8),i=r.readUInt32BE(0);if(i>Math.pow(2,21)-1){let o=this.createError(RangeError,"Unsupported WebSocket frame: payload length > 2^53 - 1",!1,1009,"WS_ERR_UNSUPPORTED_DATA_PAYLOAD_LENGTH");e(o);return}this._payloadLength=i*Math.pow(2,32)+r.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 r=this.createError(RangeError,"Max payload size exceeded",!1,1009,"WS_ERR_UNSUPPORTED_MESSAGE_LENGTH");e(r);return}this._masked?this._state=Dl:this._state=Pc}getMask(){if(this._bufferedBytes<4){this._loop=!1;return}this._mask=this.consume(4),this._state=Pc}getData(e){let r=Al;if(this._payloadLength){if(this._bufferedBytes<this._payloadLength){this._loop=!1;return}r=this.consume(this._payloadLength),this._masked&&(this._mask[0]|this._mask[1]|this._mask[2]|this._mask[3])!==0&&Dy(r,this._mask)}if(this._opcode>7){this.controlMessage(r,e);return}if(this._compressed){this._state=Oc,this.decompress(r,e);return}r.length&&(this._messageLength=this._totalPayloadLength,this._fragments.push(r)),this.dataMessage(e)}decompress(e,r){this._extensions[Il.extensionName].decompress(e,this._fin,(o,c)=>{if(o)return r(o);if(c.length){if(this._messageLength+=c.length,this._messageLength>this._maxPayload&&this._maxPayload>0){let f=this.createError(RangeError,"Max payload size exceeded",!1,1009,"WS_ERR_UNSUPPORTED_MESSAGE_LENGTH");r(f);return}this._fragments.push(c)}this.dataMessage(r),this._state===st&&this.startLoop(r)})}dataMessage(e){if(!this._fin){this._state=st;return}let r=this._messageLength,i=this._fragments;if(this._totalPayloadLength=0,this._messageLength=0,this._fragmented=0,this._fragments=[],this._opcode===2){let o;this._binaryType==="nodebuffer"?o=Lc(i,r):this._binaryType==="arraybuffer"?o=Ry(Lc(i,r)):this._binaryType==="blob"?o=new Blob(i):o=i,this._allowSynchronousEvents?(this.emit("message",o,!0),this._state=st):(this._state=uo,setImmediate(()=>{this.emit("message",o,!0),this._state=st,this.startLoop(e)}))}else{let o=Lc(i,r);if(!this._skipUTF8Validation&&!Tl(o)){let c=this.createError(Error,"invalid UTF-8 sequence",!0,1007,"WS_ERR_INVALID_UTF8");e(c);return}this._state===Oc||this._allowSynchronousEvents?(this.emit("message",o,!1),this._state=st):(this._state=uo,setImmediate(()=>{this.emit("message",o,!1),this._state=st,this.startLoop(e)}))}}controlMessage(e,r){if(this._opcode===8){if(e.length===0)this._loop=!1,this.emit("conclude",1005,Al),this.end();else{let i=e.readUInt16BE(0);if(!ky(i)){let c=this.createError(RangeError,`invalid status code ${i}`,!0,1002,"WS_ERR_INVALID_CLOSE_CODE");r(c);return}let o=new fo(e.buffer,e.byteOffset+2,e.length-2);if(!this._skipUTF8Validation&&!Tl(o)){let c=this.createError(Error,"invalid UTF-8 sequence",!0,1007,"WS_ERR_INVALID_UTF8");r(c);return}this._loop=!1,this.emit("conclude",i,o),this.end()}this._state=st;return}this._allowSynchronousEvents?(this.emit(this._opcode===9?"ping":"pong",e),this._state=st):(this._state=uo,setImmediate(()=>{this.emit(this._opcode===9?"ping":"pong",e),this._state=st,this.startLoop(r)}))}createError(e,r,i,o,c){this._loop=!1,this._errored=!0;let f=new e(i?`Invalid WebSocket frame: ${r}`:r);return Error.captureStackTrace(f,this.createError),f.code=c,f[Ty]=o,f}};kl.exports=Nc});var Fc=ne((II,Ol)=>{"use strict";var{Duplex:SI}=ae("stream"),{randomFillSync:Ly}=ae("crypto"),Ll=Er(),{EMPTY_BUFFER:Py,kWebSocket:Oy,NOOP:Ny}=zt(),{isBlob:Sr,isValidStatusCode:My}=vr(),{mask:Pl,toBuffer:kn}=yi(),ot=Symbol("kByteLength"),By=Buffer.alloc(4),lo=8*1024,Ln,Ir=lo,ht=0,zy=1,Fy=2,Bc=class t{constructor(e,r,i){this._extensions=r||{},i&&(this._generateMask=i,this._maskBuffer=Buffer.alloc(4)),this._socket=e,this._firstFragment=!0,this._compress=!1,this._bufferedBytes=0,this._queue=[],this._state=ht,this.onerror=Ny,this[Oy]=void 0}static frame(e,r){let i,o=!1,c=2,f=!1;r.mask&&(i=r.maskBuffer||By,r.generateMask?r.generateMask(i):(Ir===lo&&(Ln===void 0&&(Ln=Buffer.alloc(lo)),Ly(Ln,0,lo),Ir=0),i[0]=Ln[Ir++],i[1]=Ln[Ir++],i[2]=Ln[Ir++],i[3]=Ln[Ir++]),f=(i[0]|i[1]|i[2]|i[3])===0,c=6);let l;typeof e=="string"?(!r.mask||f)&&r[ot]!==void 0?l=r[ot]:(e=Buffer.from(e),l=e.length):(l=e.length,o=r.mask&&r.readOnly&&!f);let x=l;l>=65536?(c+=8,x=127):l>125&&(c+=2,x=126);let p=Buffer.allocUnsafe(o?l+c:c);return p[0]=r.fin?r.opcode|128:r.opcode,r.rsv1&&(p[0]|=64),p[1]=x,x===126?p.writeUInt16BE(l,2):x===127&&(p[2]=p[3]=0,p.writeUIntBE(l,4,6)),r.mask?(p[1]|=128,p[c-4]=i[0],p[c-3]=i[1],p[c-2]=i[2],p[c-1]=i[3],f?[p,e]:o?(Pl(e,i,p,c,l),[p]):(Pl(e,i,e,0,l),[p,e])):[p,e]}close(e,r,i,o){let c;if(e===void 0)c=Py;else{if(typeof e!="number"||!My(e))throw new TypeError("First argument must be a valid error code number");if(r===void 0||!r.length)c=Buffer.allocUnsafe(2),c.writeUInt16BE(e,0);else{let l=Buffer.byteLength(r);if(l>123)throw new RangeError("The message must not be greater than 123 bytes");c=Buffer.allocUnsafe(2+l),c.writeUInt16BE(e,0),typeof r=="string"?c.write(r,2):c.set(r,2)}}let f={[ot]:c.length,fin:!0,generateMask:this._generateMask,mask:i,maskBuffer:this._maskBuffer,opcode:8,readOnly:!1,rsv1:!1};this._state!==ht?this.enqueue([this.dispatch,c,!1,f,o]):this.sendFrame(t.frame(c,f),o)}ping(e,r,i){let o,c;if(typeof e=="string"?(o=Buffer.byteLength(e),c=!1):Sr(e)?(o=e.size,c=!1):(e=kn(e),o=e.length,c=kn.readOnly),o>125)throw new RangeError("The data size must not be greater than 125 bytes");let f={[ot]:o,fin:!0,generateMask:this._generateMask,mask:r,maskBuffer:this._maskBuffer,opcode:9,readOnly:c,rsv1:!1};Sr(e)?this._state!==ht?this.enqueue([this.getBlobData,e,!1,f,i]):this.getBlobData(e,!1,f,i):this._state!==ht?this.enqueue([this.dispatch,e,!1,f,i]):this.sendFrame(t.frame(e,f),i)}pong(e,r,i){let o,c;if(typeof e=="string"?(o=Buffer.byteLength(e),c=!1):Sr(e)?(o=e.size,c=!1):(e=kn(e),o=e.length,c=kn.readOnly),o>125)throw new RangeError("The data size must not be greater than 125 bytes");let f={[ot]:o,fin:!0,generateMask:this._generateMask,mask:r,maskBuffer:this._maskBuffer,opcode:10,readOnly:c,rsv1:!1};Sr(e)?this._state!==ht?this.enqueue([this.getBlobData,e,!1,f,i]):this.getBlobData(e,!1,f,i):this._state!==ht?this.enqueue([this.dispatch,e,!1,f,i]):this.sendFrame(t.frame(e,f),i)}send(e,r,i){let o=this._extensions[Ll.extensionName],c=r.binary?2:1,f=r.compress,l,x;typeof e=="string"?(l=Buffer.byteLength(e),x=!1):Sr(e)?(l=e.size,x=!1):(e=kn(e),l=e.length,x=kn.readOnly),this._firstFragment?(this._firstFragment=!1,f&&o&&o.params[o._isServer?"server_no_context_takeover":"client_no_context_takeover"]&&(f=l>=o._threshold),this._compress=f):(f=!1,c=0),r.fin&&(this._firstFragment=!0);let p={[ot]:l,fin:r.fin,generateMask:this._generateMask,mask:r.mask,maskBuffer:this._maskBuffer,opcode:c,readOnly:x,rsv1:f};Sr(e)?this._state!==ht?this.enqueue([this.getBlobData,e,this._compress,p,i]):this.getBlobData(e,this._compress,p,i):this._state!==ht?this.enqueue([this.dispatch,e,this._compress,p,i]):this.dispatch(e,this._compress,p,i)}getBlobData(e,r,i,o){this._bufferedBytes+=i[ot],this._state=Fy,e.arrayBuffer().then(c=>{if(this._socket.destroyed){let l=new Error("The socket was closed while the blob was being read");process.nextTick(zc,this,l,o);return}this._bufferedBytes-=i[ot];let f=kn(c);r?this.dispatch(f,r,i,o):(this._state=ht,this.sendFrame(t.frame(f,i),o),this.dequeue())}).catch(c=>{process.nextTick(Uy,this,c,o)})}dispatch(e,r,i,o){if(!r){this.sendFrame(t.frame(e,i),o);return}let c=this._extensions[Ll.extensionName];this._bufferedBytes+=i[ot],this._state=zy,c.compress(e,i.fin,(f,l)=>{if(this._socket.destroyed){let x=new Error("The socket was closed while data was being compressed");zc(this,x,o);return}this._bufferedBytes-=i[ot],this._state=ht,i.readOnly=!1,this.sendFrame(t.frame(l,i),o),this.dequeue()})}dequeue(){for(;this._state===ht&&this._queue.length;){let e=this._queue.shift();this._bufferedBytes-=e[3][ot],Reflect.apply(e[0],this,e.slice(1))}}enqueue(e){this._bufferedBytes+=e[3][ot],this._queue.push(e)}sendFrame(e,r){e.length===2?(this._socket.cork(),this._socket.write(e[0]),this._socket.write(e[1],r),this._socket.uncork()):this._socket.write(e[0],r)}};Ol.exports=Bc;function zc(t,e,r){typeof r=="function"&&r(e);for(let i=0;i<t._queue.length;i++){let o=t._queue[i],c=o[o.length-1];typeof c=="function"&&c(e)}}function Uy(t,e,r){zc(t,e,r),t.onerror(e)}});var Gl=ne((AI,Hl)=>{"use strict";var{kForOnEventAttribute:Ei,kListener:Uc}=zt(),Nl=Symbol("kCode"),Ml=Symbol("kData"),Bl=Symbol("kError"),zl=Symbol("kMessage"),Fl=Symbol("kReason"),Ar=Symbol("kTarget"),Ul=Symbol("kType"),ql=Symbol("kWasClean"),Ut=class{constructor(e){this[Ar]=null,this[Ul]=e}get target(){return this[Ar]}get type(){return this[Ul]}};Object.defineProperty(Ut.prototype,"target",{enumerable:!0});Object.defineProperty(Ut.prototype,"type",{enumerable:!0});var Pn=class extends Ut{constructor(e,r={}){super(e),this[Nl]=r.code===void 0?0:r.code,this[Fl]=r.reason===void 0?"":r.reason,this[ql]=r.wasClean===void 0?!1:r.wasClean}get code(){return this[Nl]}get reason(){return this[Fl]}get wasClean(){return this[ql]}};Object.defineProperty(Pn.prototype,"code",{enumerable:!0});Object.defineProperty(Pn.prototype,"reason",{enumerable:!0});Object.defineProperty(Pn.prototype,"wasClean",{enumerable:!0});var Tr=class extends Ut{constructor(e,r={}){super(e),this[Bl]=r.error===void 0?null:r.error,this[zl]=r.message===void 0?"":r.message}get error(){return this[Bl]}get message(){return this[zl]}};Object.defineProperty(Tr.prototype,"error",{enumerable:!0});Object.defineProperty(Tr.prototype,"message",{enumerable:!0});var vi=class extends Ut{constructor(e,r={}){super(e),this[Ml]=r.data===void 0?null:r.data}get data(){return this[Ml]}};Object.defineProperty(vi.prototype,"data",{enumerable:!0});var qy={addEventListener(t,e,r={}){for(let o of this.listeners(t))if(!r[Ei]&&o[Uc]===e&&!o[Ei])return;let i;if(t==="message")i=function(c,f){let l=new vi("message",{data:f?c:c.toString()});l[Ar]=this,xo(e,this,l)};else if(t==="close")i=function(c,f){let l=new Pn("close",{code:c,reason:f.toString(),wasClean:this._closeFrameReceived&&this._closeFrameSent});l[Ar]=this,xo(e,this,l)};else if(t==="error")i=function(c){let f=new Tr("error",{error:c,message:c.message});f[Ar]=this,xo(e,this,f)};else if(t==="open")i=function(){let c=new Ut("open");c[Ar]=this,xo(e,this,c)};else return;i[Ei]=!!r[Ei],i[Uc]=e,r.once?this.once(t,i):this.on(t,i)},removeEventListener(t,e){for(let r of this.listeners(t))if(r[Uc]===e&&!r[Ei]){this.removeListener(t,r);break}}};Hl.exports={CloseEvent:Pn,ErrorEvent:Tr,Event:Ut,EventTarget:qy,MessageEvent:vi};function xo(t,e,r){typeof t=="object"&&t.handleEvent?t.handleEvent.call(t,r):t.call(e,r)}});var ho=ne((TI,jl)=>{"use strict";var{tokenChars:Si}=vr();function Rt(t,e,r){t[e]===void 0?t[e]=[r]:t[e].push(r)}function Hy(t){let e=Object.create(null),r=Object.create(null),i=!1,o=!1,c=!1,f,l,x=-1,p=-1,w=-1,b=0;for(;b<t.length;b++)if(p=t.charCodeAt(b),f===void 0)if(w===-1&&Si[p]===1)x===-1&&(x=b);else if(b!==0&&(p===32||p===9))w===-1&&x!==-1&&(w=b);else if(p===59||p===44){if(x===-1)throw new SyntaxError(`Unexpected character at index ${b}`);w===-1&&(w=b);let E=t.slice(x,w);p===44?(Rt(e,E,r),r=Object.create(null)):f=E,x=w=-1}else throw new SyntaxError(`Unexpected character at index ${b}`);else if(l===void 0)if(w===-1&&Si[p]===1)x===-1&&(x=b);else if(p===32||p===9)w===-1&&x!==-1&&(w=b);else if(p===59||p===44){if(x===-1)throw new SyntaxError(`Unexpected character at index ${b}`);w===-1&&(w=b),Rt(r,t.slice(x,w),!0),p===44&&(Rt(e,f,r),r=Object.create(null),f=void 0),x=w=-1}else if(p===61&&x!==-1&&w===-1)l=t.slice(x,b),x=w=-1;else throw new SyntaxError(`Unexpected character at index ${b}`);else if(o){if(Si[p]!==1)throw new SyntaxError(`Unexpected character at index ${b}`);x===-1?x=b:i||(i=!0),o=!1}else if(c)if(Si[p]===1)x===-1&&(x=b);else if(p===34&&x!==-1)c=!1,w=b;else if(p===92)o=!0;else throw new SyntaxError(`Unexpected character at index ${b}`);else if(p===34&&t.charCodeAt(b-1)===61)c=!0;else if(w===-1&&Si[p]===1)x===-1&&(x=b);else if(x!==-1&&(p===32||p===9))w===-1&&(w=b);else if(p===59||p===44){if(x===-1)throw new SyntaxError(`Unexpected character at index ${b}`);w===-1&&(w=b);let E=t.slice(x,w);i&&(E=E.replace(/\\/g,""),i=!1),Rt(r,l,E),p===44&&(Rt(e,f,r),r=Object.create(null),f=void 0),l=void 0,x=w=-1}else throw new SyntaxError(`Unexpected character at index ${b}`);if(x===-1||c||p===32||p===9)throw new SyntaxError("Unexpected end of input");w===-1&&(w=b);let T=t.slice(x,w);return f===void 0?Rt(e,T,r):(l===void 0?Rt(r,T,!0):i?Rt(r,l,T.replace(/\\/g,"")):Rt(r,l,T),Rt(e,f,r)),e}function Gy(t){return Object.keys(t).map(e=>{let r=t[e];return Array.isArray(r)||(r=[r]),r.map(i=>[e].concat(Object.keys(i).map(o=>{let c=i[o];return Array.isArray(c)||(c=[c]),c.map(f=>f===!0?o:`${o}=${f}`).join("; ")})).join("; ")).join(", ")}).join(", ")}jl.exports={format:Gy,parse:Hy}});var wo=ne((DI,nx)=>{"use strict";var jy=ae("events"),Ky=ae("https"),Wy=ae("http"),Vl=ae("net"),Vy=ae("tls"),{randomBytes:$y,createHash:Jy}=ae("crypto"),{Duplex:CI,Readable:RI}=ae("stream"),{URL:qc}=ae("url"),hn=Er(),Yy=Mc(),Zy=Fc(),{isBlob:Xy}=vr(),{BINARY_TYPES:Kl,CLOSE_TIMEOUT:Qy,EMPTY_BUFFER:po,GUID:e1,kForOnEventAttribute:Hc,kListener:t1,kStatusCode:n1,kWebSocket:Pe,NOOP:$l}=zt(),{EventTarget:{addEventListener:r1,removeEventListener:i1}}=Gl(),{format:s1,parse:o1}=ho(),{toBuffer:a1}=yi(),Jl=Symbol("kAborted"),Gc=[8,13],qt=["CONNECTING","OPEN","CLOSING","CLOSED"],c1=/^[!#$%&'*+\-.0-9A-Z^_`|a-z~]+$/,de=class t extends jy{constructor(e,r,i){super(),this._binaryType=Kl[0],this._closeCode=1006,this._closeFrameReceived=!1,this._closeFrameSent=!1,this._closeMessage=po,this._closeTimer=null,this._errorEmitted=!1,this._extensions={},this._paused=!1,this._protocol="",this._readyState=t.CONNECTING,this._receiver=null,this._sender=null,this._socket=null,e!==null?(this._bufferedAmount=0,this._isServer=!1,this._redirects=0,r===void 0?r=[]:Array.isArray(r)||(typeof r=="object"&&r!==null?(i=r,r=[]):r=[r]),Yl(this,e,r,i)):(this._autoPong=i.autoPong,this._closeTimeout=i.closeTimeout,this._isServer=!0)}get binaryType(){return this._binaryType}set binaryType(e){Kl.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,r,i){let o=new Yy({allowSynchronousEvents:i.allowSynchronousEvents,binaryType:this.binaryType,extensions:this._extensions,isServer:this._isServer,maxPayload:i.maxPayload,skipUTF8Validation:i.skipUTF8Validation}),c=new Zy(e,this._extensions,i.generateMask);this._receiver=o,this._sender=c,this._socket=e,o[Pe]=this,c[Pe]=this,e[Pe]=this,o.on("conclude",u1),o.on("drain",l1),o.on("error",x1),o.on("message",h1),o.on("ping",p1),o.on("pong",g1),c.onerror=m1,e.setTimeout&&e.setTimeout(0),e.setNoDelay&&e.setNoDelay(),r.length>0&&e.unshift(r),e.on("close",Ql),e.on("data",mo),e.on("end",ex),e.on("error",tx),this._readyState=t.OPEN,this.emit("open")}emitClose(){if(!this._socket){this._readyState=t.CLOSED,this.emit("close",this._closeCode,this._closeMessage);return}this._extensions[hn.extensionName]&&this._extensions[hn.extensionName].cleanup(),this._receiver.removeAllListeners(),this._readyState=t.CLOSED,this.emit("close",this._closeCode,this._closeMessage)}close(e,r){if(this.readyState!==t.CLOSED){if(this.readyState===t.CONNECTING){Xe(this,this._req,"WebSocket was closed before the connection was established");return}if(this.readyState===t.CLOSING){this._closeFrameSent&&(this._closeFrameReceived||this._receiver._writableState.errorEmitted)&&this._socket.end();return}this._readyState=t.CLOSING,this._sender.close(e,r,!this._isServer,i=>{i||(this._closeFrameSent=!0,(this._closeFrameReceived||this._receiver._writableState.errorEmitted)&&this._socket.end())}),Xl(this)}}pause(){this.readyState===t.CONNECTING||this.readyState===t.CLOSED||(this._paused=!0,this._socket.pause())}ping(e,r,i){if(this.readyState===t.CONNECTING)throw new Error("WebSocket is not open: readyState 0 (CONNECTING)");if(typeof e=="function"?(i=e,e=r=void 0):typeof r=="function"&&(i=r,r=void 0),typeof e=="number"&&(e=e.toString()),this.readyState!==t.OPEN){jc(this,e,i);return}r===void 0&&(r=!this._isServer),this._sender.ping(e||po,r,i)}pong(e,r,i){if(this.readyState===t.CONNECTING)throw new Error("WebSocket is not open: readyState 0 (CONNECTING)");if(typeof e=="function"?(i=e,e=r=void 0):typeof r=="function"&&(i=r,r=void 0),typeof e=="number"&&(e=e.toString()),this.readyState!==t.OPEN){jc(this,e,i);return}r===void 0&&(r=!this._isServer),this._sender.pong(e||po,r,i)}resume(){this.readyState===t.CONNECTING||this.readyState===t.CLOSED||(this._paused=!1,this._receiver._writableState.needDrain||this._socket.resume())}send(e,r,i){if(this.readyState===t.CONNECTING)throw new Error("WebSocket is not open: readyState 0 (CONNECTING)");if(typeof r=="function"&&(i=r,r={}),typeof e=="number"&&(e=e.toString()),this.readyState!==t.OPEN){jc(this,e,i);return}let o={binary:typeof e!="string",mask:!this._isServer,compress:!0,fin:!0,...r};this._extensions[hn.extensionName]||(o.compress=!1),this._sender.send(e||po,o,i)}terminate(){if(this.readyState!==t.CLOSED){if(this.readyState===t.CONNECTING){Xe(this,this._req,"WebSocket was closed before the connection was established");return}this._socket&&(this._readyState=t.CLOSING,this._socket.destroy())}}};Object.defineProperty(de,"CONNECTING",{enumerable:!0,value:qt.indexOf("CONNECTING")});Object.defineProperty(de.prototype,"CONNECTING",{enumerable:!0,value:qt.indexOf("CONNECTING")});Object.defineProperty(de,"OPEN",{enumerable:!0,value:qt.indexOf("OPEN")});Object.defineProperty(de.prototype,"OPEN",{enumerable:!0,value:qt.indexOf("OPEN")});Object.defineProperty(de,"CLOSING",{enumerable:!0,value:qt.indexOf("CLOSING")});Object.defineProperty(de.prototype,"CLOSING",{enumerable:!0,value:qt.indexOf("CLOSING")});Object.defineProperty(de,"CLOSED",{enumerable:!0,value:qt.indexOf("CLOSED")});Object.defineProperty(de.prototype,"CLOSED",{enumerable:!0,value:qt.indexOf("CLOSED")});["binaryType","bufferedAmount","extensions","isPaused","protocol","readyState","url"].forEach(t=>{Object.defineProperty(de.prototype,t,{enumerable:!0})});["open","error","close","message"].forEach(t=>{Object.defineProperty(de.prototype,`on${t}`,{enumerable:!0,get(){for(let e of this.listeners(t))if(e[Hc])return e[t1];return null},set(e){for(let r of this.listeners(t))if(r[Hc]){this.removeListener(t,r);break}typeof e=="function"&&this.addEventListener(t,e,{[Hc]:!0})}})});de.prototype.addEventListener=r1;de.prototype.removeEventListener=i1;nx.exports=de;function Yl(t,e,r,i){let o={allowSynchronousEvents:!0,autoPong:!0,closeTimeout:Qy,protocolVersion:Gc[1],maxPayload:104857600,skipUTF8Validation:!1,perMessageDeflate:!0,followRedirects:!1,maxRedirects:10,...i,socketPath:void 0,hostname:void 0,protocol:void 0,timeout:void 0,method:"GET",host:void 0,path:void 0,port:void 0};if(t._autoPong=o.autoPong,t._closeTimeout=o.closeTimeout,!Gc.includes(o.protocolVersion))throw new RangeError(`Unsupported protocol version: ${o.protocolVersion} (supported versions: ${Gc.join(", ")})`);let c;if(e instanceof qc)c=e;else try{c=new qc(e)}catch{throw new SyntaxError(`Invalid URL: ${e}`)}c.protocol==="http:"?c.protocol="ws:":c.protocol==="https:"&&(c.protocol="wss:"),t._url=c.href;let f=c.protocol==="wss:",l=c.protocol==="ws+unix:",x;if(c.protocol!=="ws:"&&!f&&!l?x=`The URL's protocol must be one of "ws:", "wss:", "http:", "https:", or "ws+unix:"`:l&&!c.pathname?x="The URL's pathname is empty":c.hash&&(x="The URL contains a fragment identifier"),x){let I=new SyntaxError(x);if(t._redirects===0)throw I;go(t,I);return}let p=f?443:80,w=$y(16).toString("base64"),b=f?Ky.request:Wy.request,T=new Set,E;if(o.createConnection=o.createConnection||(f?f1:d1),o.defaultPort=o.defaultPort||p,o.port=c.port||p,o.host=c.hostname.startsWith("[")?c.hostname.slice(1,-1):c.hostname,o.headers={...o.headers,"Sec-WebSocket-Version":o.protocolVersion,"Sec-WebSocket-Key":w,Connection:"Upgrade",Upgrade:"websocket"},o.path=c.pathname+c.search,o.timeout=o.handshakeTimeout,o.perMessageDeflate&&(E=new hn({...o.perMessageDeflate,isServer:!1,maxPayload:o.maxPayload}),o.headers["Sec-WebSocket-Extensions"]=s1({[hn.extensionName]:E.offer()})),r.length){for(let I of r){if(typeof I!="string"||!c1.test(I)||T.has(I))throw new SyntaxError("An invalid or duplicated subprotocol was specified");T.add(I)}o.headers["Sec-WebSocket-Protocol"]=r.join(",")}if(o.origin&&(o.protocolVersion<13?o.headers["Sec-WebSocket-Origin"]=o.origin:o.headers.Origin=o.origin),(c.username||c.password)&&(o.auth=`${c.username}:${c.password}`),l){let I=o.path.split(":");o.socketPath=I[0],o.path=I[1]}let v;if(o.followRedirects){if(t._redirects===0){t._originalIpc=l,t._originalSecure=f,t._originalHostOrSocketPath=l?o.socketPath:c.host;let I=i&&i.headers;if(i={...i,headers:{}},I)for(let[A,k]of Object.entries(I))i.headers[A.toLowerCase()]=k}else if(t.listenerCount("redirect")===0){let I=l?t._originalIpc?o.socketPath===t._originalHostOrSocketPath:!1:t._originalIpc?!1:c.host===t._originalHostOrSocketPath;(!I||t._originalSecure&&!f)&&(delete o.headers.authorization,delete o.headers.cookie,I||delete o.headers.host,o.auth=void 0)}o.auth&&!i.headers.authorization&&(i.headers.authorization="Basic "+Buffer.from(o.auth).toString("base64")),v=t._req=b(o),t._redirects&&t.emit("redirect",t.url,v)}else v=t._req=b(o);o.timeout&&v.on("timeout",()=>{Xe(t,v,"Opening handshake has timed out")}),v.on("error",I=>{v===null||v[Jl]||(v=t._req=null,go(t,I))}),v.on("response",I=>{let A=I.headers.location,k=I.statusCode;if(A&&o.followRedirects&&k>=300&&k<400){if(++t._redirects>o.maxRedirects){Xe(t,v,"Maximum redirects exceeded");return}v.abort();let O;try{O=new qc(A,e)}catch{let C=new SyntaxError(`Invalid URL: ${A}`);go(t,C);return}Yl(t,O,r,i)}else t.emit("unexpected-response",v,I)||Xe(t,v,`Unexpected server response: ${I.statusCode}`)}),v.on("upgrade",(I,A,k)=>{if(t.emit("upgrade",I),t.readyState!==de.CONNECTING)return;v=t._req=null;let O=I.headers.upgrade;if(O===void 0||O.toLowerCase()!=="websocket"){Xe(t,A,"Invalid Upgrade header");return}let y=Jy("sha1").update(w+e1).digest("base64");if(I.headers["sec-websocket-accept"]!==y){Xe(t,A,"Invalid Sec-WebSocket-Accept header");return}let C=I.headers["sec-websocket-protocol"],L;if(C!==void 0?T.size?T.has(C)||(L="Server sent an invalid subprotocol"):L="Server sent a subprotocol but none was requested":T.size&&(L="Server sent no subprotocol"),L){Xe(t,A,L);return}C&&(t._protocol=C);let F=I.headers["sec-websocket-extensions"];if(F!==void 0){if(!E){Xe(t,A,"Server sent a Sec-WebSocket-Extensions header but no extension was requested");return}let z;try{z=o1(F)}catch{Xe(t,A,"Invalid Sec-WebSocket-Extensions header");return}let P=Object.keys(z);if(P.length!==1||P[0]!==hn.extensionName){Xe(t,A,"Server indicated an extension that was not requested");return}try{E.accept(z[hn.extensionName])}catch{Xe(t,A,"Invalid Sec-WebSocket-Extensions header");return}t._extensions[hn.extensionName]=E}t.setSocket(A,k,{allowSynchronousEvents:o.allowSynchronousEvents,generateMask:o.generateMask,maxPayload:o.maxPayload,skipUTF8Validation:o.skipUTF8Validation})}),o.finishRequest?o.finishRequest(v,t):v.end()}function go(t,e){t._readyState=de.CLOSING,t._errorEmitted=!0,t.emit("error",e),t.emitClose()}function d1(t){return t.path=t.socketPath,Vl.connect(t)}function f1(t){return t.path=void 0,!t.servername&&t.servername!==""&&(t.servername=Vl.isIP(t.host)?"":t.host),Vy.connect(t)}function Xe(t,e,r){t._readyState=de.CLOSING;let i=new Error(r);Error.captureStackTrace(i,Xe),e.setHeader?(e[Jl]=!0,e.abort(),e.socket&&!e.socket.destroyed&&e.socket.destroy(),process.nextTick(go,t,i)):(e.destroy(i),e.once("error",t.emit.bind(t,"error")),e.once("close",t.emitClose.bind(t)))}function jc(t,e,r){if(e){let i=Xy(e)?e.size:a1(e).length;t._socket?t._sender._bufferedBytes+=i:t._bufferedAmount+=i}if(r){let i=new Error(`WebSocket is not open: readyState ${t.readyState} (${qt[t.readyState]})`);process.nextTick(r,i)}}function u1(t,e){let r=this[Pe];r._closeFrameReceived=!0,r._closeMessage=e,r._closeCode=t,r._socket[Pe]!==void 0&&(r._socket.removeListener("data",mo),process.nextTick(Zl,r._socket),t===1005?r.close():r.close(t,e))}function l1(){let t=this[Pe];t.isPaused||t._socket.resume()}function x1(t){let e=this[Pe];e._socket[Pe]!==void 0&&(e._socket.removeListener("data",mo),process.nextTick(Zl,e._socket),e.close(t[n1])),e._errorEmitted||(e._errorEmitted=!0,e.emit("error",t))}function Wl(){this[Pe].emitClose()}function h1(t,e){this[Pe].emit("message",t,e)}function p1(t){let e=this[Pe];e._autoPong&&e.pong(t,!this._isServer,$l),e.emit("ping",t)}function g1(t){this[Pe].emit("pong",t)}function Zl(t){t.resume()}function m1(t){let e=this[Pe];e.readyState!==de.CLOSED&&(e.readyState===de.OPEN&&(e._readyState=de.CLOSING,Xl(e)),this._socket.end(),e._errorEmitted||(e._errorEmitted=!0,e.emit("error",t)))}function Xl(t){t._closeTimer=setTimeout(t._socket.destroy.bind(t._socket),t._closeTimeout)}function Ql(){let t=this[Pe];if(this.removeListener("close",Ql),this.removeListener("data",mo),this.removeListener("end",ex),t._readyState=de.CLOSING,!this._readableState.endEmitted&&!t._closeFrameReceived&&!t._receiver._writableState.errorEmitted&&this._readableState.length!==0){let e=this.read(this._readableState.length);t._receiver.write(e)}t._receiver.end(),this[Pe]=void 0,clearTimeout(t._closeTimer),t._receiver._writableState.finished||t._receiver._writableState.errorEmitted?t.emitClose():(t._receiver.on("error",Wl),t._receiver.on("finish",Wl))}function mo(t){this[Pe]._receiver.write(t)||this.pause()}function ex(){let t=this[Pe];t._readyState=de.CLOSING,t._receiver.end(),this.end()}function tx(){let t=this[Pe];this.removeListener("error",tx),this.on("error",$l),t&&(t._readyState=de.CLOSING,this.destroy())}});var ox=ne((LI,sx)=>{"use strict";var kI=wo(),{Duplex:w1}=ae("stream");function rx(t){t.emit("close")}function _1(){!this.destroyed&&this._writableState.finished&&this.destroy()}function ix(t){this.removeListener("error",ix),this.destroy(),this.listenerCount("error")===0&&this.emit("error",t)}function y1(t,e){let r=!0,i=new w1({...e,autoDestroy:!1,emitClose:!1,objectMode:!1,writableObjectMode:!1});return t.on("message",function(c,f){let l=!f&&i._readableState.objectMode?c.toString():c;i.push(l)||t.pause()}),t.once("error",function(c){i.destroyed||(r=!1,i.destroy(c))}),t.once("close",function(){i.destroyed||i.push(null)}),i._destroy=function(o,c){if(t.readyState===t.CLOSED){c(o),process.nextTick(rx,i);return}let f=!1;t.once("error",function(x){f=!0,c(x)}),t.once("close",function(){f||c(o),process.nextTick(rx,i)}),r&&t.terminate()},i._final=function(o){if(t.readyState===t.CONNECTING){t.once("open",function(){i._final(o)});return}t._socket!==null&&(t._socket._writableState.finished?(o(),i._readableState.endEmitted&&i.destroy()):(t._socket.once("finish",function(){o()}),t.close()))},i._read=function(){t.isPaused&&t.resume()},i._write=function(o,c,f){if(t.readyState===t.CONNECTING){t.once("open",function(){i._write(o,c,f)});return}t.send(o,f)},i.on("end",_1),i.on("error",ix),i}sx.exports=y1});var Kc=ne((PI,ax)=>{"use strict";var{tokenChars:b1}=vr();function E1(t){let e=new Set,r=-1,i=-1,o=0;for(o;o<t.length;o++){let f=t.charCodeAt(o);if(i===-1&&b1[f]===1)r===-1&&(r=o);else if(o!==0&&(f===32||f===9))i===-1&&r!==-1&&(i=o);else if(f===44){if(r===-1)throw new SyntaxError(`Unexpected character at index ${o}`);i===-1&&(i=o);let l=t.slice(r,i);if(e.has(l))throw new SyntaxError(`The "${l}" subprotocol is duplicated`);e.add(l),r=i=-1}else throw new SyntaxError(`Unexpected character at index ${o}`)}if(r===-1||i!==-1)throw new SyntaxError("Unexpected end of input");let c=t.slice(r,o);if(e.has(c))throw new SyntaxError(`The "${c}" subprotocol is duplicated`);return e.add(c),e}ax.exports={parse:E1}});var hx=ne((NI,xx)=>{"use strict";var v1=ae("events"),_o=ae("http"),{Duplex:OI}=ae("stream"),{createHash:S1}=ae("crypto"),cx=ho(),On=Er(),I1=Kc(),A1=wo(),{CLOSE_TIMEOUT:T1,GUID:C1,kWebSocket:R1}=zt(),D1=/^[+/0-9A-Za-z]{22}==$/,dx=0,fx=1,lx=2,Wc=class extends v1{constructor(e,r){if(super(),e={allowSynchronousEvents:!0,autoPong:!0,maxPayload:100*1024*1024,skipUTF8Validation:!1,perMessageDeflate:!1,handleProtocols:null,clientTracking:!0,closeTimeout:T1,verifyClient:null,noServer:!1,backlog:null,server:null,host:null,path:null,port:null,WebSocket:A1,...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=_o.createServer((i,o)=>{let c=_o.STATUS_CODES[426];o.writeHead(426,{"Content-Length":c.length,"Content-Type":"text/plain"}),o.end(c)}),this._server.listen(e.port,e.host,e.backlog,r)):e.server&&(this._server=e.server),this._server){let i=this.emit.bind(this,"connection");this._removeListeners=k1(this._server,{listening:this.emit.bind(this,"listening"),error:this.emit.bind(this,"error"),upgrade:(o,c,f)=>{this.handleUpgrade(o,c,f,i)}})}e.perMessageDeflate===!0&&(e.perMessageDeflate={}),e.clientTracking&&(this.clients=new Set,this._shouldEmitClose=!1),this.options=e,this._state=dx}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===lx){e&&this.once("close",()=>{e(new Error("The server is not running"))}),process.nextTick(Ii,this);return}if(e&&this.once("close",e),this._state!==fx)if(this._state=fx,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(Ii,this):process.nextTick(Ii,this);else{let r=this._server;this._removeListeners(),this._removeListeners=this._server=null,r.close(()=>{Ii(this)})}}shouldHandle(e){if(this.options.path){let r=e.url.indexOf("?");if((r!==-1?e.url.slice(0,r):e.url)!==this.options.path)return!1}return!0}handleUpgrade(e,r,i,o){r.on("error",ux);let c=e.headers["sec-websocket-key"],f=e.headers.upgrade,l=+e.headers["sec-websocket-version"];if(e.method!=="GET"){Nn(this,e,r,405,"Invalid HTTP method");return}if(f===void 0||f.toLowerCase()!=="websocket"){Nn(this,e,r,400,"Invalid Upgrade header");return}if(c===void 0||!D1.test(c)){Nn(this,e,r,400,"Missing or invalid Sec-WebSocket-Key header");return}if(l!==13&&l!==8){Nn(this,e,r,400,"Missing or invalid Sec-WebSocket-Version header",{"Sec-WebSocket-Version":"13, 8"});return}if(!this.shouldHandle(e)){Ai(r,400);return}let x=e.headers["sec-websocket-protocol"],p=new Set;if(x!==void 0)try{p=I1.parse(x)}catch{Nn(this,e,r,400,"Invalid Sec-WebSocket-Protocol header");return}let w=e.headers["sec-websocket-extensions"],b={};if(this.options.perMessageDeflate&&w!==void 0){let T=new On({...this.options.perMessageDeflate,isServer:!0,maxPayload:this.options.maxPayload});try{let E=cx.parse(w);E[On.extensionName]&&(T.accept(E[On.extensionName]),b[On.extensionName]=T)}catch{Nn(this,e,r,400,"Invalid or unacceptable Sec-WebSocket-Extensions header");return}}if(this.options.verifyClient){let T={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(T,(E,v,I,A)=>{if(!E)return Ai(r,v||401,I,A);this.completeUpgrade(b,c,p,e,r,i,o)});return}if(!this.options.verifyClient(T))return Ai(r,401)}this.completeUpgrade(b,c,p,e,r,i,o)}completeUpgrade(e,r,i,o,c,f,l){if(!c.readable||!c.writable)return c.destroy();if(c[R1])throw new Error("server.handleUpgrade() was called more than once with the same socket, possibly due to a misconfiguration");if(this._state>dx)return Ai(c,503);let p=["HTTP/1.1 101 Switching Protocols","Upgrade: websocket","Connection: Upgrade",`Sec-WebSocket-Accept: ${S1("sha1").update(r+C1).digest("base64")}`],w=new this.options.WebSocket(null,void 0,this.options);if(i.size){let b=this.options.handleProtocols?this.options.handleProtocols(i,o):i.values().next().value;b&&(p.push(`Sec-WebSocket-Protocol: ${b}`),w._protocol=b)}if(e[On.extensionName]){let b=e[On.extensionName].params,T=cx.format({[On.extensionName]:[b]});p.push(`Sec-WebSocket-Extensions: ${T}`),w._extensions=e}this.emit("headers",p,o),c.write(p.concat(`\r
13
13
  `).join(`\r
14
- `)),c.removeListener("error",ux),m.setSocket(c,f,{allowSynchronousEvents:this.options.allowSynchronousEvents,maxPayload:this.options.maxPayload,skipUTF8Validation:this.options.skipUTF8Validation}),this.clients&&(this.clients.add(m),m.on("close",()=>{this.clients.delete(m),this._shouldEmitClose&&!this.clients.size&&process.nextTick(Ci,this)})),l(m,a)}};hx.exports=$c;function jE(t,e){for(let r of Object.keys(e))t.on(r,e[r]);return function(){for(let s of Object.keys(e))t.removeListener(s,e[s])}}function Ci(t){t._state=xx,t.emit("close")}function ux(){this.destroy()}function Ti(t,e,r,s){r=r||_o.STATUS_CODES[e],s={Connection:"close","Content-Type":"text/html","Content-Length":Buffer.byteLength(r),...s},t.once("finish",t.destroy),t.end(`HTTP/1.1 ${e} ${_o.STATUS_CODES[e]}\r
15
- `+Object.keys(s).map(a=>`${a}: ${s[a]}`).join(`\r
14
+ `)),c.removeListener("error",ux),w.setSocket(c,f,{allowSynchronousEvents:this.options.allowSynchronousEvents,maxPayload:this.options.maxPayload,skipUTF8Validation:this.options.skipUTF8Validation}),this.clients&&(this.clients.add(w),w.on("close",()=>{this.clients.delete(w),this._shouldEmitClose&&!this.clients.size&&process.nextTick(Ii,this)})),l(w,o)}};xx.exports=Wc;function k1(t,e){for(let r of Object.keys(e))t.on(r,e[r]);return function(){for(let i of Object.keys(e))t.removeListener(i,e[i])}}function Ii(t){t._state=lx,t.emit("close")}function ux(){this.destroy()}function Ai(t,e,r,i){r=r||_o.STATUS_CODES[e],i={Connection:"close","Content-Type":"text/html","Content-Length":Buffer.byteLength(r),...i},t.once("finish",t.destroy),t.end(`HTTP/1.1 ${e} ${_o.STATUS_CODES[e]}\r
15
+ `+Object.keys(i).map(o=>`${o}: ${i[o]}`).join(`\r
16
16
  `)+`\r
17
17
  \r
18
- `+r)}function Fn(t,e,r,s,a,c){if(t.listenerCount("wsClientError")){let f=new Error(a);Error.captureStackTrace(f,Fn),t.emit("wsClientError",f,r,e)}else Ti(r,s,a,c)}});import{existsSync as mb,openSync as wb}from"node:fs";import{mkdir as _b}from"node:fs/promises";import{dirname as yb}from"node:path";import{fileURLToPath as Eb}from"node:url";function Yc(t=te()){return mb(t.libEntry)?t.libEntry:Eb(new URL("../index.ts",import.meta.url))}async function Xc(t={}){let e=t.paths??te(),r=t.entryOverride??Yc(e);await _b(yb(e.logFile),{recursive:!0});let s=wb(e.logFile,"a"),c=r.endsWith(".ts")?["--import","tsx/esm",r,"--daemon"]:[r,"--daemon"],f=Vt(process.execPath,c,{detached:!0,stdio:["ignore",s,s],env:{...process.env,COZE_BRIDGE_DAEMON:"1"}});if(f.unref(),typeof f.pid!="number")throw new Error("failed to spawn daemon (no pid)");return bb.info("daemon spawned",{pid:f.pid,entry:r}),{pid:f.pid,entry:r}}var bb,Qc=dt(()=>{"use strict";Wn();ee();Me();bb=H("spawn-daemon")});import{spawn as Bb}from"node:child_process";import{mkdir as zb,unlink as Fb,writeFile as Ub}from"node:fs/promises";import{dirname as qb,join as Hb}from"node:path";function To(t){return t.replace(/&/g,"&amp;").replace(/</g,"&lt;").replace(/>/g,"&gt;").replace(/"/g,"&quot;")}function zx(t,e){return new Promise((r,s)=>{let a=Bb(t,e,{stdio:["ignore","pipe","pipe"]}),c="";a.stderr?.on("data",f=>{c+=f.toString("utf8")}),a.on("error",s),a.on("close",f=>{f===0?r():s(new Error(`${t} ${e.join(" ")} exited ${f}: ${c.trim()}`))})})}var Co,r0,i0,Fx=dt(()=>{"use strict";ee();Co=H("supervisor.launchd"),r0="ai.coze.bridge",i0={platform:"darwin",renderConfig(t){return`<?xml version="1.0" encoding="UTF-8"?>
18
+ `+r)}function Nn(t,e,r,i,o,c){if(t.listenerCount("wsClientError")){let f=new Error(o);Error.captureStackTrace(f,Nn),t.emit("wsClientError",f,r,e)}else Ai(r,i,o,c)}});import{existsSync as sb,openSync as ob}from"node:fs";import{mkdir as ab}from"node:fs/promises";import{dirname as cb}from"node:path";import{fileURLToPath as db}from"node:url";function Yc(t=te()){return sb(t.libEntry)?t.libEntry:db(new URL("../index.ts",import.meta.url))}async function Zc(t={}){let e=t.paths??te(),r=t.entryOverride??Yc(e);await ab(cb(e.logFile),{recursive:!0});let i=ob(e.logFile,"a"),c=r.endsWith(".ts")?["--import","tsx/esm",r,"--daemon"]:[r,"--daemon"],f=Vt(process.execPath,c,{detached:!0,stdio:["ignore",i,i],env:{...process.env,COZE_BRIDGE_DAEMON:"1"}});if(f.unref(),typeof f.pid!="number")throw new Error("failed to spawn daemon (no pid)");return fb.info("daemon spawned",{pid:f.pid,entry:r}),{pid:f.pid,entry:r}}var fb,Xc=nt(()=>{"use strict";Hn();ee();Me();fb=G("spawn-daemon")});import{spawn as Ib}from"node:child_process";import{mkdir as Ab,unlink as Tb,writeFile as Cb}from"node:fs/promises";import{dirname as Rb,join as Db}from"node:path";function Co(t){return t.replace(/&/g,"&amp;").replace(/</g,"&lt;").replace(/>/g,"&gt;").replace(/"/g,"&quot;")}function Bx(t,e){return new Promise((r,i)=>{let o=Ib(t,e,{stdio:["ignore","pipe","pipe"]}),c="";o.stderr?.on("data",f=>{c+=f.toString("utf8")}),o.on("error",i),o.on("close",f=>{f===0?r():i(new Error(`${t} ${e.join(" ")} exited ${f}: ${c.trim()}`))})})}var To,n0,r0,zx=nt(()=>{"use strict";ee();To=G("supervisor.launchd"),n0="ai.coze.bridge",r0={platform:"darwin",renderConfig(t){return`<?xml version="1.0" encoding="UTF-8"?>
19
19
  <!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
20
20
  <plist version="1.0">
21
21
  <dict>
22
22
  <key>Label</key>
23
- <string>${r0}</string>
23
+ <string>${n0}</string>
24
24
  <key>ProgramArguments</key>
25
25
  <array>
26
- <string>${To(t.nodeBin)}</string>
27
- <string>${To(t.entry)}</string>
26
+ <string>${Co(t.nodeBin)}</string>
27
+ <string>${Co(t.entry)}</string>
28
28
  <string>--daemon</string>
29
29
  </array>
30
30
  <key>RunAtLoad</key>
@@ -34,12 +34,12 @@ ${t.stack??""}`:String(t);return up.test(r)||xp.test(r)}function z0(t){if(t==nul
34
34
  <key>ThrottleInterval</key>
35
35
  <integer>10</integer>
36
36
  <key>StandardOutPath</key>
37
- <string>${To(t.logFile)}</string>
37
+ <string>${Co(t.logFile)}</string>
38
38
  <key>StandardErrorPath</key>
39
- <string>${To(t.logFile)}</string>
39
+ <string>${Co(t.logFile)}</string>
40
40
  </dict>
41
41
  </plist>
42
- `},configPath(t){return Hb(t.homeDir,"Library","LaunchAgents",`${r0}.plist`)},async install(t){let e=this.configPath(t);await zb(qb(e),{recursive:!0}),await Ub(e,this.renderConfig(t),"utf8"),Co.info("plist written",{plistPath:e}),await zx("launchctl",["load","-w",e]),Co.info("launchd job loaded",{label:r0})},async uninstall(t){let e=this.configPath(t);await zx("launchctl",["unload","-w",e]).catch(r=>Co.warn("launchctl unload failed (ignored)",{err:String(r)})),await Fb(e).catch(r=>{if(r.code!=="ENOENT")throw r}),Co.info("launchd job removed",{plistPath:e})}}});import{spawn as jb}from"node:child_process";import{mkdir as Gb,unlink as Kb,writeFile as Wb}from"node:fs/promises";import{dirname as $b,join as Vb}from"node:path";function ko(t,e){return new Promise((r,s)=>{let a=jb(t,e,{stdio:["ignore","pipe","pipe"]}),c="";a.stderr?.on("data",f=>{c+=f.toString("utf8")}),a.on("error",s),a.on("close",f=>{f===0?r():s(new Error(`${t} ${e.join(" ")} exited ${f}: ${c.trim()}`))})})}var Do,Ro,s0,Ux=dt(()=>{"use strict";ee();Do=H("supervisor.systemd"),Ro="coze-bridge.service",s0={platform:"linux",renderConfig(t){return`[Unit]
42
+ `},configPath(t){return Db(t.homeDir,"Library","LaunchAgents",`${n0}.plist`)},async install(t){let e=this.configPath(t);await Ab(Rb(e),{recursive:!0}),await Cb(e,this.renderConfig(t),"utf8"),To.info("plist written",{plistPath:e}),await Bx("launchctl",["load","-w",e]),To.info("launchd job loaded",{label:n0})},async uninstall(t){let e=this.configPath(t);await Bx("launchctl",["unload","-w",e]).catch(r=>To.warn("launchctl unload failed (ignored)",{err:String(r)})),await Tb(e).catch(r=>{if(r.code!=="ENOENT")throw r}),To.info("launchd job removed",{plistPath:e})}}});import{spawn as kb}from"node:child_process";import{mkdir as Lb,unlink as Pb,writeFile as Ob}from"node:fs/promises";import{dirname as Nb,join as Mb}from"node:path";function ko(t,e){return new Promise((r,i)=>{let o=kb(t,e,{stdio:["ignore","pipe","pipe"]}),c="";o.stderr?.on("data",f=>{c+=f.toString("utf8")}),o.on("error",i),o.on("close",f=>{f===0?r():i(new Error(`${t} ${e.join(" ")} exited ${f}: ${c.trim()}`))})})}var Ro,Do,i0,Fx=nt(()=>{"use strict";ee();Ro=G("supervisor.systemd"),Do="coze-bridge.service",i0={platform:"linux",renderConfig(t){return`[Unit]
43
43
  Description=Coze Bridge daemon
44
44
  After=network.target
45
45
 
@@ -53,7 +53,7 @@ StandardError=append:${t.logFile}
53
53
 
54
54
  [Install]
55
55
  WantedBy=default.target
56
- `},configPath(t){return Vb(t.homeDir,".config","systemd","user",Ro)},async install(t){let e=this.configPath(t);await Gb($b(e),{recursive:!0}),await Wb(e,this.renderConfig(t),"utf8"),Do.info("systemd unit written",{unitPath:e}),await ko("systemctl",["--user","daemon-reload"]),await ko("systemctl",["--user","enable","--now",Ro]),Do.info("systemd unit enabled",{unitName:Ro})},async uninstall(t){let e=this.configPath(t);await ko("systemctl",["--user","disable","--now",Ro]).catch(r=>Do.warn("systemctl disable failed (ignored)",{err:String(r)})),await Kb(e).catch(r=>{if(r.code!=="ENOENT")throw r}),await ko("systemctl",["--user","daemon-reload"]).catch(()=>{}),Do.info("systemd unit removed",{unitPath:e})}}});import{spawn as Jb}from"node:child_process";import{join as Zb}from"node:path";function qx(t,e){return new Promise((r,s)=>{let a=Jb(t,e,{stdio:["ignore","pipe","pipe"],shell:!1}),c="";a.stderr?.on("data",f=>{c+=f.toString("utf8")}),a.on("error",s),a.on("close",f=>{f===0?r():s(new Error(`${t} ${e.join(" ")} exited ${f}: ${c.trim()}`))})})}var o0,Oo,a0,Hx=dt(()=>{"use strict";ee();o0=H("supervisor.taskscheduler"),Oo="CozeBridge",a0={platform:"win32",renderConfig(t){return`<?xml version="1.0" encoding="UTF-16"?>
56
+ `},configPath(t){return Mb(t.homeDir,".config","systemd","user",Do)},async install(t){let e=this.configPath(t);await Lb(Nb(e),{recursive:!0}),await Ob(e,this.renderConfig(t),"utf8"),Ro.info("systemd unit written",{unitPath:e}),await ko("systemctl",["--user","daemon-reload"]),await ko("systemctl",["--user","enable","--now",Do]),Ro.info("systemd unit enabled",{unitName:Do})},async uninstall(t){let e=this.configPath(t);await ko("systemctl",["--user","disable","--now",Do]).catch(r=>Ro.warn("systemctl disable failed (ignored)",{err:String(r)})),await Pb(e).catch(r=>{if(r.code!=="ENOENT")throw r}),await ko("systemctl",["--user","daemon-reload"]).catch(()=>{}),Ro.info("systemd unit removed",{unitPath:e})}}});import{spawn as Bb}from"node:child_process";import{join as zb}from"node:path";function Ux(t,e){return new Promise((r,i)=>{let o=Bb(t,e,{stdio:["ignore","pipe","pipe"],shell:!1}),c="";o.stderr?.on("data",f=>{c+=f.toString("utf8")}),o.on("error",i),o.on("close",f=>{f===0?r():i(new Error(`${t} ${e.join(" ")} exited ${f}: ${c.trim()}`))})})}var s0,Lo,o0,qx=nt(()=>{"use strict";ee();s0=G("supervisor.taskscheduler"),Lo="CozeBridge",o0={platform:"win32",renderConfig(t){return`<?xml version="1.0" encoding="UTF-16"?>
57
57
  <Task version="1.2" xmlns="http://schemas.microsoft.com/windows/2004/02/mit/task">
58
58
  <RegistrationInfo>
59
59
  <Description>Coze Bridge daemon</Description>
@@ -77,29 +77,29 @@ WantedBy=default.target
77
77
  </Exec>
78
78
  </Actions>
79
79
  </Task>
80
- `},configPath(t){return Zb(t.homeDir,".coze","bridge","task.xml")},async install(t){let r=`cmd.exe /c ${[`^"${t.nodeBin}^"`,`^"${t.entry}^"`,"--daemon",`>> ^"${t.logFile}^" 2>&1`].join(" ")}`;await qx("schtasks",["/Create","/SC","ONLOGON","/TN",Oo,"/TR",r,"/RU",t.userName,"/F"]),o0.info("task scheduler entry created",{task:Oo,logFile:t.logFile})},async uninstall(t){await qx("schtasks",["/Delete","/TN",Oo,"/F"]).catch(e=>o0.warn("schtasks /Delete failed (ignored)",{err:String(e)})),o0.info("task scheduler entry removed",{task:Oo})}}});var jx={};Ko(jx,{buildContext:()=>e2,getSupervisor:()=>Qb,launchdSupervisor:()=>i0,systemdSupervisor:()=>s0,taskSchedulerSupervisor:()=>a0});import{homedir as Yb,userInfo as Xb}from"node:os";function Qb(t=process.platform){switch(t){case"darwin":return i0;case"linux":return s0;case"win32":return a0;default:throw new Error(`unsupported platform for OS supervisor: ${t}`)}}function e2(){let t=te();return{nodeBin:process.execPath,entry:Yc(t),logFile:t.logFile,homeDir:Yb(),userName:Xb().username}}var Gx=dt(()=>{"use strict";Me();Qc();Fx();Ux();Hx()});ee();Zt();var q0=H("acp-installer-warmup"),_p=["claude-code","codex"];async function H0(t={}){let e=t.ensure??yn,s=(await Promise.allSettled(_p.map(async a=>{let c=await e(a);q0.info("acp wrapper warmup ok",{framework:a,installed:!!c,path:c??""})}))).filter(a=>a.status==="rejected");s.length>0&&q0.warn("acp wrapper warmup partial failure (acp-installer negative cache 5min \u5185\u4E0D\u91CD\u8BD5)",{failedCount:s.length,reasons:s.map(a=>String(a.reason))})}Yt();ee();import{readdir as Rp}from"node:fs/promises";import{mkdir as V0,writeFile as J0}from"node:fs/promises";import{join as Yo}from"node:path";var Dp={"claude-code":"CLAUDE.md",codex:"AGENTS.md",openclaw:"SOUL.md"};async function Zn(t,e,r){await V0(t,{recursive:!0});let s=Dp[e],a=Yo(t,s);return await J0(a,r??"","utf8"),a}async function Z0(t){let e=Yo(t,".claude");await V0(e,{recursive:!0});let r=Yo(e,"settings.local.json"),s=JSON.stringify({permissions:{defaultMode:"bypassPermissions"}},null,2);return await J0(r,s,"utf8"),r}var Je=H("agent-detail-sync"),kp=6e4,Op=5*6e4,Gi=class{constructor(e){this.opts=e}opts;retryQueue=new Map;async syncAll(e){let r=this.opts.paths.agentsRoot,s;try{s=await Rp(r)}catch(a){Je.info("agents dir not found, skip detail sync",{root:r,err:String(a)});return}Je.info("starting detail sync",{reason:e,count:s.length}),await Promise.allSettled(s.map(async a=>{let c=await Ue(a,this.opts.paths).catch(()=>null);if(c){if(c.disconnectedAt){Je.debug("detail sync: skip disconnected agent",{agentId:a});return}try{await this.syncOne(a,c)}catch(f){Je.warn("detail sync failed for agent, skipping",{agentId:a,err:String(f)})}}})),Je.info("detail sync done",{reason:e})}async retryPending(){if(this.retryQueue.size===0)return;let e=Date.now(),r=[];for(let[s,a]of this.retryQueue)e>=a.dueAt&&r.push(s);if(r.length!==0){Je.info("retrying pending detail syncs",{count:r.length});for(let s of r)try{await this.syncOne(s)}catch(a){Je.debug("detail sync retry still failing, will try again",{agentId:s,err:String(a)})}}}async syncOne(e,r){let s=r??await Ue(e,this.opts.paths);if(!s){Je.info("detail sync: agent config missing, skip",{agentId:e});return}let a;try{a=await this.opts.sendDetail({_meta:{cozeAgentId:e}}),this.retryQueue.delete(e)}catch(l){Je.warn("detail RPC failed, using local data",{agentId:e,err:String(l)});let x=this.retryQueue.get(e),h=x?Math.min(x.currentDelay*2,Op):kp;this.retryQueue.set(e,{dueAt:Date.now()+h,currentDelay:h});return}if(a.agentId&&a.agentId!==e){Je.warn("detail response agentId mismatch, ignoring",{agentId:e,responseAgentId:a.agentId});return}let c=!1,f=!1;if(a.agentName&&a.agentName!==s.agentName&&(s.agentName=a.agentName,c=!0),a.description!==void 0&&a.description!==s.description&&(s.description=a.description,c=!0),a.cozeIdentity&&a.cozeIdentity!==s.cozeIdentity&&(s.cozeIdentity=a.cozeIdentity,c=!0,f=!0),a.deployType&&Je.info("detail.deployType",{agentId:e,deployType:a.deployType}),!c){Je.debug("detail sync: no diff",{agentId:e});return}await Ve(s,this.opts.paths),Je.info("detail sync: config updated",{agentId:e,identityChanged:f,agentName:s.agentName}),f&&(await Zn(s.workspace,s.framework,s.cozeIdentity),this.opts.handlers.reloadAgentSessionsPublic(e,"detail-sync"))}};var xl=gt(Dd(),1);import{lstat as fc,mkdir as lc,readFile as dl,readdir as iw,rm as sw,stat as ow,writeFile as uc}from"node:fs/promises";import{dirname as aw,join as It,normalize as cw,relative as pc,resolve as xc,sep as fl}from"node:path";import{Readable as ll}from"node:stream";import{pipeline as ul}from"node:stream/promises";import eg from"events";import We from"fs";import{EventEmitter as Za}from"node:events";import lf from"node:stream";import{StringDecoder as tg}from"node:string_decoder";import hf from"node:path";import cr from"node:fs";import{dirname as hg,parse as pg}from"path";import{EventEmitter as Sg}from"events";import ka from"assert";import{Buffer as kn}from"buffer";import*as Ld from"zlib";import vg from"zlib";import{posix as tr}from"node:path";import{basename as Yg}from"node:path";import bs from"fs";import yt from"fs";import qd from"path";import{win32 as cm}from"node:path";import Vd from"path";import Df from"node:fs";import Im from"node:assert";import{randomBytes as Rf}from"node:crypto";import X from"node:fs";import Se from"node:path";import kf from"fs";import ks from"node:fs";import ei from"node:path";import Xe from"node:fs";import Om from"node:fs/promises";import Is from"node:path";import{join as Hf}from"node:path";import Ye from"node:fs";import Kf from"node:path";var Xp=Object.defineProperty,Qp=(t,e)=>{for(var r in e)Xp(t,r,{get:e[r],enumerable:!0})},Rd=typeof process=="object"&&process?process:{stdout:null,stderr:null},ng=t=>!!t&&typeof t=="object"&&(t instanceof Ln||t instanceof lf||rg(t)||ig(t)),rg=t=>!!t&&typeof t=="object"&&t instanceof Za&&typeof t.pipe=="function"&&t.pipe!==lf.Writable.prototype.pipe,ig=t=>!!t&&typeof t=="object"&&t instanceof Za&&typeof t.write=="function"&&typeof t.end=="function",Ot=Symbol("EOF"),Pt=Symbol("maybeEmitEnd"),Qt=Symbol("emittedEnd"),Ji=Symbol("emittingEnd"),Br=Symbol("emittedError"),Zi=Symbol("closed"),kd=Symbol("read"),Yi=Symbol("flush"),Od=Symbol("flushChunk"),ft=Symbol("encoding"),er=Symbol("decoder"),Ce=Symbol("flowing"),zr=Symbol("paused"),sr=Symbol("resume"),Te=Symbol("buffer"),Ge=Symbol("pipes"),De=Symbol("bufferLength"),ra=Symbol("bufferPush"),Xi=Symbol("bufferShift"),qe=Symbol("objectMode"),me=Symbol("destroyed"),ia=Symbol("error"),sa=Symbol("emitData"),Pd=Symbol("emitEnd"),oa=Symbol("emitEnd2"),mt=Symbol("async"),aa=Symbol("abort"),Qi=Symbol("aborted"),Fr=Symbol("signal"),bn=Symbol("dataListeners"),Ze=Symbol("discarded"),Ur=t=>Promise.resolve().then(t),sg=t=>t(),og=t=>t==="end"||t==="finish"||t==="prefinish",ag=t=>t instanceof ArrayBuffer||!!t&&typeof t=="object"&&t.constructor&&t.constructor.name==="ArrayBuffer"&&t.byteLength>=0,cg=t=>!Buffer.isBuffer(t)&&ArrayBuffer.isView(t),uf=class{src;dest;opts;ondrain;constructor(t,e,r){this.src=t,this.dest=e,this.opts=r,this.ondrain=()=>t[sr](),this.dest.on("drain",this.ondrain)}unpipe(){this.dest.removeListener("drain",this.ondrain)}proxyErrors(t){}end(){this.unpipe(),this.opts.end&&this.dest.end()}},dg=class extends uf{unpipe(){this.src.removeListener("error",this.proxyErrors),super.unpipe()}constructor(t,e,r){super(t,e,r),this.proxyErrors=s=>this.dest.emit("error",s),t.on("error",this.proxyErrors)}},fg=t=>!!t.objectMode,lg=t=>!t.objectMode&&!!t.encoding&&t.encoding!=="buffer",Ln=class extends Za{[Ce]=!1;[zr]=!1;[Ge]=[];[Te]=[];[qe];[ft];[mt];[er];[Ot]=!1;[Qt]=!1;[Ji]=!1;[Zi]=!1;[Br]=null;[De]=0;[me]=!1;[Fr];[Qi]=!1;[bn]=0;[Ze]=!1;writable=!0;readable=!0;constructor(...t){let e=t[0]||{};if(super(),e.objectMode&&typeof e.encoding=="string")throw new TypeError("Encoding and objectMode may not be used together");fg(e)?(this[qe]=!0,this[ft]=null):lg(e)?(this[ft]=e.encoding,this[qe]=!1):(this[qe]=!1,this[ft]=null),this[mt]=!!e.async,this[er]=this[ft]?new tg(this[ft]):null,e&&e.debugExposeBuffer===!0&&Object.defineProperty(this,"buffer",{get:()=>this[Te]}),e&&e.debugExposePipes===!0&&Object.defineProperty(this,"pipes",{get:()=>this[Ge]});let{signal:r}=e;r&&(this[Fr]=r,r.aborted?this[aa]():r.addEventListener("abort",()=>this[aa]()))}get bufferLength(){return this[De]}get encoding(){return this[ft]}set encoding(t){throw new Error("Encoding must be set at instantiation time")}setEncoding(t){throw new Error("Encoding must be set at instantiation time")}get objectMode(){return this[qe]}set objectMode(t){throw new Error("objectMode must be set at instantiation time")}get async(){return this[mt]}set async(t){this[mt]=this[mt]||!!t}[aa](){this[Qi]=!0,this.emit("abort",this[Fr]?.reason),this.destroy(this[Fr]?.reason)}get aborted(){return this[Qi]}set aborted(t){}write(t,e,r){if(this[Qi])return!1;if(this[Ot])throw new Error("write after end");if(this[me])return this.emit("error",Object.assign(new Error("Cannot call write after a stream was destroyed"),{code:"ERR_STREAM_DESTROYED"})),!0;typeof e=="function"&&(r=e,e="utf8"),e||(e="utf8");let s=this[mt]?Ur:sg;if(!this[qe]&&!Buffer.isBuffer(t)){if(cg(t))t=Buffer.from(t.buffer,t.byteOffset,t.byteLength);else if(ag(t))t=Buffer.from(t);else if(typeof t!="string")throw new Error("Non-contiguous data written to non-objectMode stream")}return this[qe]?(this[Ce]&&this[De]!==0&&this[Yi](!0),this[Ce]?this.emit("data",t):this[ra](t),this[De]!==0&&this.emit("readable"),r&&s(r),this[Ce]):t.length?(typeof t=="string"&&!(e===this[ft]&&!this[er]?.lastNeed)&&(t=Buffer.from(t,e)),Buffer.isBuffer(t)&&this[ft]&&(t=this[er].write(t)),this[Ce]&&this[De]!==0&&this[Yi](!0),this[Ce]?this.emit("data",t):this[ra](t),this[De]!==0&&this.emit("readable"),r&&s(r),this[Ce]):(this[De]!==0&&this.emit("readable"),r&&s(r),this[Ce])}read(t){if(this[me])return null;if(this[Ze]=!1,this[De]===0||t===0||t&&t>this[De])return this[Pt](),null;this[qe]&&(t=null),this[Te].length>1&&!this[qe]&&(this[Te]=[this[ft]?this[Te].join(""):Buffer.concat(this[Te],this[De])]);let e=this[kd](t||null,this[Te][0]);return this[Pt](),e}[kd](t,e){if(this[qe])this[Xi]();else{let r=e;t===r.length||t===null?this[Xi]():typeof r=="string"?(this[Te][0]=r.slice(t),e=r.slice(0,t),this[De]-=t):(this[Te][0]=r.subarray(t),e=r.subarray(0,t),this[De]-=t)}return this.emit("data",e),!this[Te].length&&!this[Ot]&&this.emit("drain"),e}end(t,e,r){return typeof t=="function"&&(r=t,t=void 0),typeof e=="function"&&(r=e,e="utf8"),t!==void 0&&this.write(t,e),r&&this.once("end",r),this[Ot]=!0,this.writable=!1,(this[Ce]||!this[zr])&&this[Pt](),this}[sr](){this[me]||(!this[bn]&&!this[Ge].length&&(this[Ze]=!0),this[zr]=!1,this[Ce]=!0,this.emit("resume"),this[Te].length?this[Yi]():this[Ot]?this[Pt]():this.emit("drain"))}resume(){return this[sr]()}pause(){this[Ce]=!1,this[zr]=!0,this[Ze]=!1}get destroyed(){return this[me]}get flowing(){return this[Ce]}get paused(){return this[zr]}[ra](t){this[qe]?this[De]+=1:this[De]+=t.length,this[Te].push(t)}[Xi](){return this[qe]?this[De]-=1:this[De]-=this[Te][0].length,this[Te].shift()}[Yi](t=!1){do;while(this[Od](this[Xi]())&&this[Te].length);!t&&!this[Te].length&&!this[Ot]&&this.emit("drain")}[Od](t){return this.emit("data",t),this[Ce]}pipe(t,e){if(this[me])return t;this[Ze]=!1;let r=this[Qt];return e=e||{},t===Rd.stdout||t===Rd.stderr?e.end=!1:e.end=e.end!==!1,e.proxyErrors=!!e.proxyErrors,r?e.end&&t.end():(this[Ge].push(e.proxyErrors?new dg(this,t,e):new uf(this,t,e)),this[mt]?Ur(()=>this[sr]()):this[sr]()),t}unpipe(t){let e=this[Ge].find(r=>r.dest===t);e&&(this[Ge].length===1?(this[Ce]&&this[bn]===0&&(this[Ce]=!1),this[Ge]=[]):this[Ge].splice(this[Ge].indexOf(e),1),e.unpipe())}addListener(t,e){return this.on(t,e)}on(t,e){let r=super.on(t,e);if(t==="data")this[Ze]=!1,this[bn]++,!this[Ge].length&&!this[Ce]&&this[sr]();else if(t==="readable"&&this[De]!==0)super.emit("readable");else if(og(t)&&this[Qt])super.emit(t),this.removeAllListeners(t);else if(t==="error"&&this[Br]){let s=e;this[mt]?Ur(()=>s.call(this,this[Br])):s.call(this,this[Br])}return r}removeListener(t,e){return this.off(t,e)}off(t,e){let r=super.off(t,e);return t==="data"&&(this[bn]=this.listeners("data").length,this[bn]===0&&!this[Ze]&&!this[Ge].length&&(this[Ce]=!1)),r}removeAllListeners(t){let e=super.removeAllListeners(t);return(t==="data"||t===void 0)&&(this[bn]=0,!this[Ze]&&!this[Ge].length&&(this[Ce]=!1)),e}get emittedEnd(){return this[Qt]}[Pt](){!this[Ji]&&!this[Qt]&&!this[me]&&this[Te].length===0&&this[Ot]&&(this[Ji]=!0,this.emit("end"),this.emit("prefinish"),this.emit("finish"),this[Zi]&&this.emit("close"),this[Ji]=!1)}emit(t,...e){let r=e[0];if(t!=="error"&&t!=="close"&&t!==me&&this[me])return!1;if(t==="data")return!this[qe]&&!r?!1:this[mt]?(Ur(()=>this[sa](r)),!0):this[sa](r);if(t==="end")return this[Pd]();if(t==="close"){if(this[Zi]=!0,!this[Qt]&&!this[me])return!1;let a=super.emit("close");return this.removeAllListeners("close"),a}else if(t==="error"){this[Br]=r,super.emit(ia,r);let a=!this[Fr]||this.listeners("error").length?super.emit("error",r):!1;return this[Pt](),a}else if(t==="resume"){let a=super.emit("resume");return this[Pt](),a}else if(t==="finish"||t==="prefinish"){let a=super.emit(t);return this.removeAllListeners(t),a}let s=super.emit(t,...e);return this[Pt](),s}[sa](t){for(let r of this[Ge])r.dest.write(t)===!1&&this.pause();let e=this[Ze]?!1:super.emit("data",t);return this[Pt](),e}[Pd](){return this[Qt]?!1:(this[Qt]=!0,this.readable=!1,this[mt]?(Ur(()=>this[oa]()),!0):this[oa]())}[oa](){if(this[er]){let e=this[er].end();if(e){for(let r of this[Ge])r.dest.write(e);this[Ze]||super.emit("data",e)}}for(let e of this[Ge])e.end();let t=super.emit("end");return this.removeAllListeners("end"),t}async collect(){let t=Object.assign([],{dataLength:0});this[qe]||(t.dataLength=0);let e=this.promise();return this.on("data",r=>{t.push(r),this[qe]||(t.dataLength+=r.length)}),await e,t}async concat(){if(this[qe])throw new Error("cannot concat in objectMode");let t=await this.collect();return this[ft]?t.join(""):Buffer.concat(t,t.dataLength)}async promise(){return new Promise((t,e)=>{this.on(me,()=>e(new Error("stream destroyed"))),this.on("error",r=>e(r)),this.on("end",()=>t())})}[Symbol.asyncIterator](){this[Ze]=!1;let t=!1,e=async()=>(this.pause(),t=!0,{value:void 0,done:!0});return{next:()=>{if(t)return e();let r=this.read();if(r!==null)return Promise.resolve({done:!1,value:r});if(this[Ot])return e();let s,a,c=h=>{this.off("data",f),this.off("end",l),this.off(me,x),e(),a(h)},f=h=>{this.off("error",c),this.off("end",l),this.off(me,x),this.pause(),s({value:h,done:!!this[Ot]})},l=()=>{this.off("error",c),this.off("data",f),this.off(me,x),e(),s({done:!0,value:void 0})},x=()=>c(new Error("stream destroyed"));return new Promise((h,m)=>{a=m,s=h,this.once(me,x),this.once("error",c),this.once("end",l),this.once("data",f)})},throw:e,return:e,[Symbol.asyncIterator](){return this},[Symbol.asyncDispose]:async()=>{}}}[Symbol.iterator](){this[Ze]=!1;let t=!1,e=()=>(this.pause(),this.off(ia,e),this.off(me,e),this.off("end",e),t=!0,{done:!0,value:void 0}),r=()=>{if(t)return e();let s=this.read();return s===null?e():{done:!1,value:s}};return this.once("end",e),this.once(ia,e),this.once(me,e),{next:r,throw:e,return:e,[Symbol.iterator](){return this},[Symbol.dispose]:()=>{}}}destroy(t){if(this[me])return t?this.emit("error",t):this.emit(me),this;this[me]=!0,this[Ze]=!0,this[Te].length=0,this[De]=0;let e=this;return typeof e.close=="function"&&!this[Zi]&&e.close(),t?this.emit("error",t):this.emit(me),this}static get isStream(){return ng}},ug=We.writev,fn=Symbol("_autoClose"),ht=Symbol("_close"),qr=Symbol("_ended"),ie=Symbol("_fd"),ca=Symbol("_finished"),Bt=Symbol("_flags"),da=Symbol("_flush"),Da=Symbol("_handleChunk"),Ra=Symbol("_makeBuf"),Xr=Symbol("_mode"),es=Symbol("_needDrain"),fr=Symbol("_onerror"),lr=Symbol("_onopen"),fa=Symbol("_onread"),or=Symbol("_onwrite"),ln=Symbol("_open"),xt=Symbol("_path"),sn=Symbol("_pos"),wt=Symbol("_queue"),ar=Symbol("_read"),la=Symbol("_readSize"),Mt=Symbol("_reading"),Hr=Symbol("_remain"),ua=Symbol("_size"),fs=Symbol("_write"),Sn=Symbol("_writing"),ls=Symbol("_defaultFlag"),Rn=Symbol("_errored"),Ya=class extends Ln{[Rn]=!1;[ie];[xt];[la];[Mt]=!1;[ua];[Hr];[fn];constructor(t,e){if(e=e||{},super(e),this.readable=!0,this.writable=!1,typeof t!="string")throw new TypeError("path must be a string");this[Rn]=!1,this[ie]=typeof e.fd=="number"?e.fd:void 0,this[xt]=t,this[la]=e.readSize||16*1024*1024,this[Mt]=!1,this[ua]=typeof e.size=="number"?e.size:1/0,this[Hr]=this[ua],this[fn]=typeof e.autoClose=="boolean"?e.autoClose:!0,typeof this[ie]=="number"?this[ar]():this[ln]()}get fd(){return this[ie]}get path(){return this[xt]}write(){throw new TypeError("this is a readable stream")}end(){throw new TypeError("this is a readable stream")}[ln](){We.open(this[xt],"r",(t,e)=>this[lr](t,e))}[lr](t,e){t?this[fr](t):(this[ie]=e,this.emit("open",e),this[ar]())}[Ra](){return Buffer.allocUnsafe(Math.min(this[la],this[Hr]))}[ar](){if(!this[Mt]){this[Mt]=!0;let t=this[Ra]();if(t.length===0)return process.nextTick(()=>this[fa](null,0,t));We.read(this[ie],t,0,t.length,null,(e,r,s)=>this[fa](e,r,s))}}[fa](t,e,r){this[Mt]=!1,t?this[fr](t):this[Da](e,r)&&this[ar]()}[ht](){if(this[fn]&&typeof this[ie]=="number"){let t=this[ie];this[ie]=void 0,We.close(t,e=>e?this.emit("error",e):this.emit("close"))}}[fr](t){this[Mt]=!0,this[ht](),this.emit("error",t)}[Da](t,e){let r=!1;return this[Hr]-=t,t>0&&(r=super.write(t<e.length?e.subarray(0,t):e)),(t===0||this[Hr]<=0)&&(r=!1,this[ht](),super.end()),r}emit(t,...e){switch(t){case"prefinish":case"finish":return!1;case"drain":return typeof this[ie]=="number"&&this[ar](),!1;case"error":return this[Rn]?!1:(this[Rn]=!0,super.emit(t,...e));default:return super.emit(t,...e)}}},xg=class extends Ya{[ln](){let t=!0;try{this[lr](null,We.openSync(this[xt],"r")),t=!1}finally{t&&this[ht]()}}[ar](){let t=!0;try{if(!this[Mt]){this[Mt]=!0;do{let e=this[Ra](),r=e.length===0?0:We.readSync(this[ie],e,0,e.length,null);if(!this[Da](r,e))break}while(!0);this[Mt]=!1}t=!1}finally{t&&this[ht]()}}[ht](){if(this[fn]&&typeof this[ie]=="number"){let t=this[ie];this[ie]=void 0,We.closeSync(t),this.emit("close")}}},As=class extends eg{readable=!1;writable=!0;[Rn]=!1;[Sn]=!1;[qr]=!1;[wt]=[];[es]=!1;[xt];[Xr];[fn];[ie];[ls];[Bt];[ca]=!1;[sn];constructor(t,e){e=e||{},super(e),this[xt]=t,this[ie]=typeof e.fd=="number"?e.fd:void 0,this[Xr]=e.mode===void 0?438:e.mode,this[sn]=typeof e.start=="number"?e.start:void 0,this[fn]=typeof e.autoClose=="boolean"?e.autoClose:!0;let r=this[sn]!==void 0?"r+":"w";this[ls]=e.flags===void 0,this[Bt]=e.flags===void 0?r:e.flags,this[ie]===void 0&&this[ln]()}emit(t,...e){if(t==="error"){if(this[Rn])return!1;this[Rn]=!0}return super.emit(t,...e)}get fd(){return this[ie]}get path(){return this[xt]}[fr](t){this[ht](),this[Sn]=!0,this.emit("error",t)}[ln](){We.open(this[xt],this[Bt],this[Xr],(t,e)=>this[lr](t,e))}[lr](t,e){this[ls]&&this[Bt]==="r+"&&t&&t.code==="ENOENT"?(this[Bt]="w",this[ln]()):t?this[fr](t):(this[ie]=e,this.emit("open",e),this[Sn]||this[da]())}end(t,e){return t&&this.write(t,e),this[qr]=!0,!this[Sn]&&!this[wt].length&&typeof this[ie]=="number"&&this[or](null,0),this}write(t,e){return typeof t=="string"&&(t=Buffer.from(t,e)),this[qr]?(this.emit("error",new Error("write() after end()")),!1):this[ie]===void 0||this[Sn]||this[wt].length?(this[wt].push(t),this[es]=!0,!1):(this[Sn]=!0,this[fs](t),!0)}[fs](t){We.write(this[ie],t,0,t.length,this[sn],(e,r)=>this[or](e,r))}[or](t,e){t?this[fr](t):(this[sn]!==void 0&&typeof e=="number"&&(this[sn]+=e),this[wt].length?this[da]():(this[Sn]=!1,this[qr]&&!this[ca]?(this[ca]=!0,this[ht](),this.emit("finish")):this[es]&&(this[es]=!1,this.emit("drain"))))}[da](){if(this[wt].length===0)this[qr]&&this[or](null,0);else if(this[wt].length===1)this[fs](this[wt].pop());else{let t=this[wt];this[wt]=[],ug(this[ie],t,this[sn],(e,r)=>this[or](e,r))}}[ht](){if(this[fn]&&typeof this[ie]=="number"){let t=this[ie];this[ie]=void 0,We.close(t,e=>e?this.emit("error",e):this.emit("close"))}}},xf=class extends As{[ln](){let t;if(this[ls]&&this[Bt]==="r+")try{t=We.openSync(this[xt],this[Bt],this[Xr])}catch(e){if(e?.code==="ENOENT")return this[Bt]="w",this[ln]();throw e}else t=We.openSync(this[xt],this[Bt],this[Xr]);this[lr](null,t)}[ht](){if(this[fn]&&typeof this[ie]=="number"){let t=this[ie];this[ie]=void 0,We.closeSync(t),this.emit("close")}}[fs](t){let e=!0;try{this[or](null,We.writeSync(this[ie],t,0,t.length,this[sn])),e=!1}finally{if(e)try{this[ht]()}catch{}}}},gg=new Map([["C","cwd"],["f","file"],["z","gzip"],["P","preservePaths"],["U","unlink"],["strip-components","strip"],["stripComponents","strip"],["keep-newer","newer"],["keepNewer","newer"],["keep-newer-files","newer"],["keepNewerFiles","newer"],["k","keep"],["keep-existing","keep"],["keepExisting","keep"],["m","noMtime"],["no-mtime","noMtime"],["p","preserveOwner"],["L","follow"],["h","follow"],["onentry","onReadEntry"]]),mg=t=>!!t.sync&&!!t.file,wg=t=>!t.sync&&!!t.file,_g=t=>!!t.sync&&!t.file,yg=t=>!t.sync&&!t.file,Eg=t=>!!t.file,bg=t=>gg.get(t)||t,Xa=(t={})=>{if(!t)return{};let e={};for(let[r,s]of Object.entries(t)){let a=bg(r);e[a]=s}return e.chmod===void 0&&e.noChmod===!1&&(e.chmod=!0),delete e.noChmod,e},ai=(t,e,r,s,a)=>Object.assign((c=[],f,l)=>{Array.isArray(c)&&(f=c,c={}),typeof f=="function"&&(l=f,f=void 0),f=f?Array.from(f):[];let x=Xa(c);if(a?.(x,f),mg(x)){if(typeof l=="function")throw new TypeError("callback not supported for sync tar functions");return t(x,f)}else if(wg(x)){let h=e(x,f);return l?h.then(()=>l(),l):h}else if(_g(x)){if(typeof l=="function")throw new TypeError("callback not supported for sync tar functions");return r(x,f)}else if(yg(x)){if(typeof l=="function")throw new TypeError("callback only supported with file option");return s(x,f)}throw new Error("impossible options??")},{syncFile:t,asyncFile:e,syncNoFile:r,asyncNoFile:s,validate:a}),Ig=vg.constants||{ZLIB_VERNUM:4736},bt=Object.freeze(Object.assign(Object.create(null),{Z_NO_FLUSH:0,Z_PARTIAL_FLUSH:1,Z_SYNC_FLUSH:2,Z_FULL_FLUSH:3,Z_FINISH:4,Z_BLOCK:5,Z_OK:0,Z_STREAM_END:1,Z_NEED_DICT:2,Z_ERRNO:-1,Z_STREAM_ERROR:-2,Z_DATA_ERROR:-3,Z_MEM_ERROR:-4,Z_BUF_ERROR:-5,Z_VERSION_ERROR:-6,Z_NO_COMPRESSION:0,Z_BEST_SPEED:1,Z_BEST_COMPRESSION:9,Z_DEFAULT_COMPRESSION:-1,Z_FILTERED:1,Z_HUFFMAN_ONLY:2,Z_RLE:3,Z_FIXED:4,Z_DEFAULT_STRATEGY:0,DEFLATE:1,INFLATE:2,GZIP:3,GUNZIP:4,DEFLATERAW:5,INFLATERAW:6,UNZIP:7,BROTLI_DECODE:8,BROTLI_ENCODE:9,Z_MIN_WINDOWBITS:8,Z_MAX_WINDOWBITS:15,Z_DEFAULT_WINDOWBITS:15,Z_MIN_CHUNK:64,Z_MAX_CHUNK:1/0,Z_DEFAULT_CHUNK:16384,Z_MIN_MEMLEVEL:1,Z_MAX_MEMLEVEL:9,Z_DEFAULT_MEMLEVEL:8,Z_MIN_LEVEL:-1,Z_MAX_LEVEL:9,Z_DEFAULT_LEVEL:-1,BROTLI_OPERATION_PROCESS:0,BROTLI_OPERATION_FLUSH:1,BROTLI_OPERATION_FINISH:2,BROTLI_OPERATION_EMIT_METADATA:3,BROTLI_MODE_GENERIC:0,BROTLI_MODE_TEXT:1,BROTLI_MODE_FONT:2,BROTLI_DEFAULT_MODE:0,BROTLI_MIN_QUALITY:0,BROTLI_MAX_QUALITY:11,BROTLI_DEFAULT_QUALITY:11,BROTLI_MIN_WINDOW_BITS:10,BROTLI_MAX_WINDOW_BITS:24,BROTLI_LARGE_MAX_WINDOW_BITS:30,BROTLI_DEFAULT_WINDOW:22,BROTLI_MIN_INPUT_BLOCK_BITS:16,BROTLI_MAX_INPUT_BLOCK_BITS:24,BROTLI_PARAM_MODE:0,BROTLI_PARAM_QUALITY:1,BROTLI_PARAM_LGWIN:2,BROTLI_PARAM_LGBLOCK:3,BROTLI_PARAM_DISABLE_LITERAL_CONTEXT_MODELING:4,BROTLI_PARAM_SIZE_HINT:5,BROTLI_PARAM_LARGE_WINDOW:6,BROTLI_PARAM_NPOSTFIX:7,BROTLI_PARAM_NDIRECT:8,BROTLI_DECODER_RESULT_ERROR:0,BROTLI_DECODER_RESULT_SUCCESS:1,BROTLI_DECODER_RESULT_NEEDS_MORE_INPUT:2,BROTLI_DECODER_RESULT_NEEDS_MORE_OUTPUT:3,BROTLI_DECODER_PARAM_DISABLE_RING_BUFFER_REALLOCATION:0,BROTLI_DECODER_PARAM_LARGE_WINDOW:1,BROTLI_DECODER_NO_ERROR:0,BROTLI_DECODER_SUCCESS:1,BROTLI_DECODER_NEEDS_MORE_INPUT:2,BROTLI_DECODER_NEEDS_MORE_OUTPUT:3,BROTLI_DECODER_ERROR_FORMAT_EXUBERANT_NIBBLE:-1,BROTLI_DECODER_ERROR_FORMAT_RESERVED:-2,BROTLI_DECODER_ERROR_FORMAT_EXUBERANT_META_NIBBLE:-3,BROTLI_DECODER_ERROR_FORMAT_SIMPLE_HUFFMAN_ALPHABET:-4,BROTLI_DECODER_ERROR_FORMAT_SIMPLE_HUFFMAN_SAME:-5,BROTLI_DECODER_ERROR_FORMAT_CL_SPACE:-6,BROTLI_DECODER_ERROR_FORMAT_HUFFMAN_SPACE:-7,BROTLI_DECODER_ERROR_FORMAT_CONTEXT_MAP_REPEAT:-8,BROTLI_DECODER_ERROR_FORMAT_BLOCK_LENGTH_1:-9,BROTLI_DECODER_ERROR_FORMAT_BLOCK_LENGTH_2:-10,BROTLI_DECODER_ERROR_FORMAT_TRANSFORM:-11,BROTLI_DECODER_ERROR_FORMAT_DICTIONARY:-12,BROTLI_DECODER_ERROR_FORMAT_WINDOW_BITS:-13,BROTLI_DECODER_ERROR_FORMAT_PADDING_1:-14,BROTLI_DECODER_ERROR_FORMAT_PADDING_2:-15,BROTLI_DECODER_ERROR_FORMAT_DISTANCE:-16,BROTLI_DECODER_ERROR_DICTIONARY_NOT_SET:-19,BROTLI_DECODER_ERROR_INVALID_ARGUMENTS:-20,BROTLI_DECODER_ERROR_ALLOC_CONTEXT_MODES:-21,BROTLI_DECODER_ERROR_ALLOC_TREE_GROUPS:-22,BROTLI_DECODER_ERROR_ALLOC_CONTEXT_MAP:-25,BROTLI_DECODER_ERROR_ALLOC_RING_BUFFER_1:-26,BROTLI_DECODER_ERROR_ALLOC_RING_BUFFER_2:-27,BROTLI_DECODER_ERROR_ALLOC_BLOCK_TYPE_TREES:-30,BROTLI_DECODER_ERROR_UNREACHABLE:-31},Ig)),Ag=kn.concat,Nd=Object.getOwnPropertyDescriptor(kn,"concat"),Cg=t=>t,xa=Nd?.writable===!0||Nd?.set!==void 0?t=>{kn.concat=t?Cg:Ag}:t=>{},On=Symbol("_superWrite"),ts=class extends Error{code;errno;constructor(t,e){super("zlib: "+t.message,{cause:t}),this.code=t.code,this.errno=t.errno,this.code||(this.code="ZLIB_ERROR"),this.message="zlib: "+t.message,Error.captureStackTrace(this,e??this.constructor)}get name(){return"ZlibError"}},ha=Symbol("flushFlag"),Qa=class extends Ln{#e=!1;#n=!1;#r;#s;#i;#t;#o;get sawError(){return this.#e}get handle(){return this.#t}get flushFlag(){return this.#r}constructor(t,e){if(!t||typeof t!="object")throw new TypeError("invalid options for ZlibBase constructor");if(super(t),this.#r=t.flush??0,this.#s=t.finishFlush??0,this.#i=t.fullFlushFlag??0,typeof Ld[e]!="function")throw new TypeError("Compression method not supported: "+e);try{this.#t=new Ld[e](t)}catch(r){throw new ts(r,this.constructor)}this.#o=r=>{this.#e||(this.#e=!0,this.close(),this.emit("error",r))},this.#t?.on("error",r=>this.#o(new ts(r))),this.once("end",()=>this.close)}close(){this.#t&&(this.#t.close(),this.#t=void 0,this.emit("close"))}reset(){if(!this.#e)return ka(this.#t,"zlib binding closed"),this.#t.reset?.()}flush(t){this.ended||(typeof t!="number"&&(t=this.#i),this.write(Object.assign(kn.alloc(0),{[ha]:t})))}end(t,e,r){return typeof t=="function"&&(r=t,e=void 0,t=void 0),typeof e=="function"&&(r=e,e=void 0),t&&(e?this.write(t,e):this.write(t)),this.flush(this.#s),this.#n=!0,super.end(r)}get ended(){return this.#n}[On](t){return super.write(t)}write(t,e,r){if(typeof e=="function"&&(r=e,e="utf8"),typeof t=="string"&&(t=kn.from(t,e)),this.#e)return;ka(this.#t,"zlib binding closed");let s=this.#t._handle,a=s.close;s.close=()=>{};let c=this.#t.close;this.#t.close=()=>{},xa(!0);let f;try{let x=typeof t[ha]=="number"?t[ha]:this.#r;f=this.#t._processChunk(t,x),xa(!1)}catch(x){xa(!1),this.#o(new ts(x,this.write))}finally{this.#t&&(this.#t._handle=s,s.close=a,this.#t.close=c,this.#t.removeAllListeners("error"))}this.#t&&this.#t.on("error",x=>this.#o(new ts(x,this.write)));let l;if(f)if(Array.isArray(f)&&f.length>0){let x=f[0];l=this[On](kn.from(x));for(let h=1;h<f.length;h++)l=this[On](f[h])}else l=this[On](kn.from(f));return r&&r(),l}},pf=class extends Qa{#e;#n;constructor(t,e){t=t||{},t.flush=t.flush||bt.Z_NO_FLUSH,t.finishFlush=t.finishFlush||bt.Z_FINISH,t.fullFlushFlag=bt.Z_FULL_FLUSH,super(t,e),this.#e=t.level,this.#n=t.strategy}params(t,e){if(!this.sawError){if(!this.handle)throw new Error("cannot switch params when binding is closed");if(!this.handle.params)throw new Error("not supported in this implementation");if(this.#e!==t||this.#n!==e){this.flush(bt.Z_SYNC_FLUSH),ka(this.handle,"zlib binding closed");let r=this.handle.flush;this.handle.flush=(s,a)=>{typeof s=="function"&&(a=s,s=this.flushFlag),this.flush(s),a?.()};try{this.handle.params(t,e)}finally{this.handle.flush=r}this.handle&&(this.#e=t,this.#n=e)}}}},Tg=class extends pf{#e;constructor(t){super(t,"Gzip"),this.#e=t&&!!t.portable}[On](t){return this.#e?(this.#e=!1,t[9]=255,super[On](t)):super[On](t)}},Dg=class extends pf{constructor(t){super(t,"Unzip")}},gf=class extends Qa{constructor(t,e){t=t||{},t.flush=t.flush||bt.BROTLI_OPERATION_PROCESS,t.finishFlush=t.finishFlush||bt.BROTLI_OPERATION_FINISH,t.fullFlushFlag=bt.BROTLI_OPERATION_FLUSH,super(t,e)}},Rg=class extends gf{constructor(t){super(t,"BrotliCompress")}},kg=class extends gf{constructor(t){super(t,"BrotliDecompress")}},mf=class extends Qa{constructor(t,e){t=t||{},t.flush=t.flush||bt.ZSTD_e_continue,t.finishFlush=t.finishFlush||bt.ZSTD_e_end,t.fullFlushFlag=bt.ZSTD_e_flush,super(t,e)}},Og=class extends mf{constructor(t){super(t,"ZstdCompress")}},Pg=class extends mf{constructor(t){super(t,"ZstdDecompress")}},Lg=(t,e)=>{if(Number.isSafeInteger(t))t<0?Mg(t,e):Ng(t,e);else throw Error("cannot encode number outside of javascript safe integer range");return e},Ng=(t,e)=>{e[0]=128;for(var r=e.length;r>1;r--)e[r-1]=t&255,t=Math.floor(t/256)},Mg=(t,e)=>{e[0]=255;var r=!1;t=t*-1;for(var s=e.length;s>1;s--){var a=t&255;t=Math.floor(t/256),r?e[s-1]=wf(a):a===0?e[s-1]=0:(r=!0,e[s-1]=_f(a))}},Bg=t=>{let e=t[0],r=e===128?Fg(t.subarray(1,t.length)):e===255?zg(t):null;if(r===null)throw Error("invalid base256 encoding");if(!Number.isSafeInteger(r))throw Error("parsed number outside of javascript safe integer range");return r},zg=t=>{for(var e=t.length,r=0,s=!1,a=e-1;a>-1;a--){var c=Number(t[a]),f;s?f=wf(c):c===0?f=c:(s=!0,f=_f(c)),f!==0&&(r-=f*Math.pow(256,e-a-1))}return r},Fg=t=>{for(var e=t.length,r=0,s=e-1;s>-1;s--){var a=Number(t[s]);a!==0&&(r+=a*Math.pow(256,e-s-1))}return r},wf=t=>(255^t)&255,_f=t=>(255^t)+1&255,Ug={};Qp(Ug,{code:()=>ec,isCode:()=>us,isName:()=>qg,name:()=>Cs});var us=t=>Cs.has(t),qg=t=>ec.has(t),Cs=new Map([["0","File"],["","OldFile"],["1","Link"],["2","SymbolicLink"],["3","CharacterDevice"],["4","BlockDevice"],["5","Directory"],["6","FIFO"],["7","ContiguousFile"],["g","GlobalExtendedHeader"],["x","ExtendedHeader"],["A","SolarisACL"],["D","GNUDumpDir"],["I","Inode"],["K","NextFileHasLongLinkpath"],["L","NextFileHasLongPath"],["M","ContinuationFile"],["N","OldGnuLongPath"],["S","SparseFile"],["V","TapeVolumeHeader"],["X","OldExtendedHeader"]]),ec=new Map(Array.from(Cs).map(t=>[t[1],t[0]])),Pn=class{cksumValid=!1;needPax=!1;nullBlock=!1;block;path;mode;uid;gid;size;cksum;#e="Unsupported";linkpath;uname;gname;devmaj=0;devmin=0;atime;ctime;mtime;charset;comment;constructor(t,e=0,r,s){Buffer.isBuffer(t)?this.decode(t,e||0,r,s):t&&this.#n(t)}decode(t,e,r,s){if(e||(e=0),!t||!(t.length>=e+512))throw new Error("need 512 bytes for header");this.path=r?.path??vn(t,e,100),this.mode=r?.mode??s?.mode??on(t,e+100,8),this.uid=r?.uid??s?.uid??on(t,e+108,8),this.gid=r?.gid??s?.gid??on(t,e+116,8),this.size=r?.size??s?.size??on(t,e+124,12),this.mtime=r?.mtime??s?.mtime??pa(t,e+136,12),this.cksum=on(t,e+148,12),s&&this.#n(s,!0),r&&this.#n(r);let a=vn(t,e+156,1);if(us(a)&&(this.#e=a||"0"),this.#e==="0"&&this.path.slice(-1)==="/"&&(this.#e="5"),this.#e==="5"&&(this.size=0),this.linkpath=vn(t,e+157,100),t.subarray(e+257,e+265).toString()==="ustar\x0000")if(this.uname=r?.uname??s?.uname??vn(t,e+265,32),this.gname=r?.gname??s?.gname??vn(t,e+297,32),this.devmaj=r?.devmaj??s?.devmaj??on(t,e+329,8)??0,this.devmin=r?.devmin??s?.devmin??on(t,e+337,8)??0,t[e+475]!==0){let f=vn(t,e+345,155);this.path=f+"/"+this.path}else{let f=vn(t,e+345,130);f&&(this.path=f+"/"+this.path),this.atime=r?.atime??s?.atime??pa(t,e+476,12),this.ctime=r?.ctime??s?.ctime??pa(t,e+488,12)}let c=256;for(let f=e;f<e+148;f++)c+=t[f];for(let f=e+156;f<e+512;f++)c+=t[f];this.cksumValid=c===this.cksum,this.cksum===void 0&&c===256&&(this.nullBlock=!0)}#n(t,e=!1){Object.assign(this,Object.fromEntries(Object.entries(t).filter(([r,s])=>!(s==null||r==="path"&&e||r==="linkpath"&&e||r==="global"))))}encode(t,e=0){if(t||(t=this.block=Buffer.alloc(512)),this.#e==="Unsupported"&&(this.#e="0"),!(t.length>=e+512))throw new Error("need 512 bytes for header");let r=this.ctime||this.atime?130:155,s=Hg(this.path||"",r),a=s[0],c=s[1];this.needPax=!!s[2],this.needPax=In(t,e,100,a)||this.needPax,this.needPax=an(t,e+100,8,this.mode)||this.needPax,this.needPax=an(t,e+108,8,this.uid)||this.needPax,this.needPax=an(t,e+116,8,this.gid)||this.needPax,this.needPax=an(t,e+124,12,this.size)||this.needPax,this.needPax=ga(t,e+136,12,this.mtime)||this.needPax,t[e+156]=Number(this.#e.codePointAt(0)),this.needPax=In(t,e+157,100,this.linkpath)||this.needPax,t.write("ustar\x0000",e+257,8),this.needPax=In(t,e+265,32,this.uname)||this.needPax,this.needPax=In(t,e+297,32,this.gname)||this.needPax,this.needPax=an(t,e+329,8,this.devmaj)||this.needPax,this.needPax=an(t,e+337,8,this.devmin)||this.needPax,this.needPax=In(t,e+345,r,c)||this.needPax,t[e+475]!==0?this.needPax=In(t,e+345,155,c)||this.needPax:(this.needPax=In(t,e+345,130,c)||this.needPax,this.needPax=ga(t,e+476,12,this.atime)||this.needPax,this.needPax=ga(t,e+488,12,this.ctime)||this.needPax);let f=256;for(let l=e;l<e+148;l++)f+=t[l];for(let l=e+156;l<e+512;l++)f+=t[l];return this.cksum=f,an(t,e+148,8,this.cksum),this.cksumValid=!0,this.needPax}get type(){return this.#e==="Unsupported"?this.#e:Cs.get(this.#e)}get typeKey(){return this.#e}set type(t){let e=String(ec.get(t));if(us(e)||e==="Unsupported")this.#e=e;else if(us(t))this.#e=t;else throw new TypeError("invalid entry type: "+t)}},Hg=(t,e)=>{let r=t,s="",a,c=tr.parse(t).root||".";if(Buffer.byteLength(r)<100)a=[r,s,!1];else{s=tr.dirname(r),r=tr.basename(r);do Buffer.byteLength(r)<=100&&Buffer.byteLength(s)<=e?a=[r,s,!1]:Buffer.byteLength(r)>100&&Buffer.byteLength(s)<=e?a=[r.slice(0,99),s,!0]:(r=tr.join(tr.basename(s),r),s=tr.dirname(s));while(s!==c&&a===void 0);a||(a=[t.slice(0,99),"",!0])}return a},vn=(t,e,r)=>t.subarray(e,e+r).toString("utf8").replace(/\0.*/,""),pa=(t,e,r)=>jg(on(t,e,r)),jg=t=>t===void 0?void 0:new Date(t*1e3),on=(t,e,r)=>Number(t[e])&128?Bg(t.subarray(e,e+r)):Kg(t,e,r),Gg=t=>isNaN(t)?void 0:t,Kg=(t,e,r)=>Gg(parseInt(t.subarray(e,e+r).toString("utf8").replace(/\0.*$/,"").trim(),8)),Wg={12:8589934591,8:2097151},an=(t,e,r,s)=>s===void 0?!1:s>Wg[r]||s<0?(Lg(s,t.subarray(e,e+r)),!0):($g(t,e,r,s),!1),$g=(t,e,r,s)=>t.write(Vg(s,r),e,r,"ascii"),Vg=(t,e)=>Jg(Math.floor(t).toString(8),e),Jg=(t,e)=>(t.length===e-1?t:new Array(e-t.length-1).join("0")+t+" ")+"\0",ga=(t,e,r,s)=>s===void 0?!1:an(t,e,r,s.getTime()/1e3),Zg=new Array(156).join("\0"),In=(t,e,r,s)=>s===void 0?!1:(t.write(s+Zg,e,r,"utf8"),s.length!==Buffer.byteLength(s)||s.length>r),Es=class yf{atime;mtime;ctime;charset;comment;gid;uid;gname;uname;linkpath;dev;ino;nlink;path;size;mode;global;constructor(e,r=!1){this.atime=e.atime,this.charset=e.charset,this.comment=e.comment,this.ctime=e.ctime,this.dev=e.dev,this.gid=e.gid,this.global=r,this.gname=e.gname,this.ino=e.ino,this.linkpath=e.linkpath,this.mtime=e.mtime,this.nlink=e.nlink,this.path=e.path,this.size=e.size,this.uid=e.uid,this.uname=e.uname}encode(){let e=this.encodeBody();if(e==="")return Buffer.allocUnsafe(0);let r=Buffer.byteLength(e),s=512*Math.ceil(1+r/512),a=Buffer.allocUnsafe(s);for(let c=0;c<512;c++)a[c]=0;new Pn({path:("PaxHeader/"+Yg(this.path??"")).slice(0,99),mode:this.mode||420,uid:this.uid,gid:this.gid,size:r,mtime:this.mtime,type:this.global?"GlobalExtendedHeader":"ExtendedHeader",linkpath:"",uname:this.uname||"",gname:this.gname||"",devmaj:0,devmin:0,atime:this.atime,ctime:this.ctime}).encode(a),a.write(e,512,r,"utf8");for(let c=r+512;c<a.length;c++)a[c]=0;return a}encodeBody(){return this.encodeField("path")+this.encodeField("ctime")+this.encodeField("atime")+this.encodeField("dev")+this.encodeField("ino")+this.encodeField("nlink")+this.encodeField("charset")+this.encodeField("comment")+this.encodeField("gid")+this.encodeField("gname")+this.encodeField("linkpath")+this.encodeField("mtime")+this.encodeField("size")+this.encodeField("uid")+this.encodeField("uname")}encodeField(e){if(this[e]===void 0)return"";let r=this[e],s=r instanceof Date?r.getTime()/1e3:r,a=" "+(e==="dev"||e==="ino"||e==="nlink"?"SCHILY.":"")+e+"="+s+`
81
- `,c=Buffer.byteLength(a),f=Math.floor(Math.log(c)/Math.log(10))+1;return c+f>=Math.pow(10,f)&&(f+=1),f+c+a}static parse(e,r,s=!1){return new yf(Xg(Qg(e),r),s)}},Xg=(t,e)=>e?Object.assign({},e,t):t,Qg=t=>t.replace(/\n$/,"").split(`
82
- `).reduce(em,Object.create(null)),em=(t,e)=>{let r=parseInt(e,10);if(r!==Buffer.byteLength(e)+1)return t;e=e.slice((r+" ").length);let s=e.split("="),a=s.shift();if(!a)return t;let c=a.replace(/^SCHILY\.(dev|ino|nlink)/,"$1"),f=s.join("=");return t[c]=/^([A-Z]+\.)?([mac]|birth|creation)time$/.test(c)?new Date(Number(f)*1e3):/^[0-9]+$/.test(f)?+f:f,t},tm=process.env.TESTING_TAR_FAKE_PLATFORM||process.platform,Z=tm!=="win32"?t=>t:t=>t&&t.replaceAll(/\\/g,"/"),Ef=class extends Ln{extended;globalExtended;header;startBlockSize;blockRemain;remain;type;meta=!1;ignore=!1;path;mode;uid;gid;uname;gname;size=0;mtime;atime;ctime;linkpath;dev;ino;nlink;invalid=!1;absolute;unsupported=!1;constructor(t,e,r){switch(super({}),this.pause(),this.extended=e,this.globalExtended=r,this.header=t,this.remain=t.size??0,this.startBlockSize=512*Math.ceil(this.remain/512),this.blockRemain=this.startBlockSize,this.type=t.type,this.type){case"File":case"OldFile":case"Link":case"SymbolicLink":case"CharacterDevice":case"BlockDevice":case"Directory":case"FIFO":case"ContiguousFile":case"GNUDumpDir":break;case"NextFileHasLongLinkpath":case"NextFileHasLongPath":case"OldGnuLongPath":case"GlobalExtendedHeader":case"ExtendedHeader":case"OldExtendedHeader":this.meta=!0;break;default:this.ignore=!0}if(!t.path)throw new Error("no path provided for tar.ReadEntry");this.path=Z(t.path),this.mode=t.mode,this.mode&&(this.mode=this.mode&4095),this.uid=t.uid,this.gid=t.gid,this.uname=t.uname,this.gname=t.gname,this.size=this.remain,this.mtime=t.mtime,this.atime=t.atime,this.ctime=t.ctime,this.linkpath=t.linkpath?Z(t.linkpath):void 0,this.uname=t.uname,this.gname=t.gname,e&&this.#e(e),r&&this.#e(r,!0)}write(t){let e=t.length;if(e>this.blockRemain)throw new Error("writing more to entry than is appropriate");let r=this.remain,s=this.blockRemain;return this.remain=Math.max(0,r-e),this.blockRemain=Math.max(0,s-e),this.ignore?!0:r>=e?super.write(t):super.write(t.subarray(0,r))}#e(t,e=!1){t.path&&(t.path=Z(t.path)),t.linkpath&&(t.linkpath=Z(t.linkpath)),Object.assign(this,Object.fromEntries(Object.entries(t).filter(([r,s])=>!(s==null||r==="path"&&e))))}},Ts=(t,e,r,s={})=>{t.file&&(s.file=t.file),t.cwd&&(s.cwd=t.cwd),s.code=r instanceof Error&&r.code||e,s.tarCode=e,!t.strict&&s.recoverable!==!1?(r instanceof Error&&(s=Object.assign(r,s),r=r.message),t.emit("warn",e,r,s)):r instanceof Error?t.emit("error",Object.assign(r,s)):t.emit("error",Object.assign(new Error(`${e}: ${r}`),s))},nm=1024*1024,Oa=Buffer.from([31,139]),Pa=Buffer.from([40,181,47,253]),rm=Math.max(Oa.length,Pa.length),nt=Symbol("state"),An=Symbol("writeEntry"),Lt=Symbol("readEntry"),ma=Symbol("nextEntry"),Md=Symbol("processEntry"),_t=Symbol("extendedHeader"),jr=Symbol("globalExtendedHeader"),en=Symbol("meta"),Bd=Symbol("emitMeta"),ce=Symbol("buffer"),Nt=Symbol("queue"),tn=Symbol("ended"),wa=Symbol("emittedEnd"),Cn=Symbol("emit"),ye=Symbol("unzip"),ns=Symbol("consumeChunk"),rs=Symbol("consumeChunkSub"),_a=Symbol("consumeBody"),zd=Symbol("consumeMeta"),Fd=Symbol("consumeHeader"),Gr=Symbol("consuming"),ya=Symbol("bufferConcat"),is=Symbol("maybeEnd"),nr=Symbol("writing"),nn=Symbol("aborted"),ss=Symbol("onDone"),Tn=Symbol("sawValidEntry"),os=Symbol("sawNullBlock"),as=Symbol("sawEOF"),Ud=Symbol("closeStream"),im=()=>!0,oi=class extends Sg{file;strict;maxMetaEntrySize;filter;brotli;zstd;writable=!0;readable=!1;[Nt]=[];[ce];[Lt];[An];[nt]="begin";[en]="";[_t];[jr];[tn]=!1;[ye];[nn]=!1;[Tn];[os]=!1;[as]=!1;[nr]=!1;[Gr]=!1;[wa]=!1;constructor(t={}){super(),this.file=t.file||"",this.on(ss,()=>{(this[nt]==="begin"||this[Tn]===!1)&&this.warn("TAR_BAD_ARCHIVE","Unrecognized archive format")}),t.ondone?this.on(ss,t.ondone):this.on(ss,()=>{this.emit("prefinish"),this.emit("finish"),this.emit("end")}),this.strict=!!t.strict,this.maxMetaEntrySize=t.maxMetaEntrySize||nm,this.filter=typeof t.filter=="function"?t.filter:im;let e=t.file&&(t.file.endsWith(".tar.br")||t.file.endsWith(".tbr"));this.brotli=!(t.gzip||t.zstd)&&t.brotli!==void 0?t.brotli:e?void 0:!1;let r=t.file&&(t.file.endsWith(".tar.zst")||t.file.endsWith(".tzst"));this.zstd=!(t.gzip||t.brotli)&&t.zstd!==void 0?t.zstd:r?!0:void 0,this.on("end",()=>this[Ud]()),typeof t.onwarn=="function"&&this.on("warn",t.onwarn),typeof t.onReadEntry=="function"&&this.on("entry",t.onReadEntry)}warn(t,e,r={}){Ts(this,t,e,r)}[Fd](t,e){this[Tn]===void 0&&(this[Tn]=!1);let r;try{r=new Pn(t,e,this[_t],this[jr])}catch(s){return this.warn("TAR_ENTRY_INVALID",s)}if(r.nullBlock)this[os]?(this[as]=!0,this[nt]==="begin"&&(this[nt]="header"),this[Cn]("eof")):(this[os]=!0,this[Cn]("nullBlock"));else if(this[os]=!1,!r.cksumValid)this.warn("TAR_ENTRY_INVALID","checksum failure",{header:r});else if(!r.path)this.warn("TAR_ENTRY_INVALID","path is required",{header:r});else{let s=r.type;if(/^(Symbolic)?Link$/.test(s)&&!r.linkpath)this.warn("TAR_ENTRY_INVALID","linkpath required",{header:r});else if(!/^(Symbolic)?Link$/.test(s)&&!/^(Global)?ExtendedHeader$/.test(s)&&r.linkpath)this.warn("TAR_ENTRY_INVALID","linkpath forbidden",{header:r});else{let a=this[An]=new Ef(r,this[_t],this[jr]);if(!this[Tn])if(a.remain){let c=()=>{a.invalid||(this[Tn]=!0)};a.on("end",c)}else this[Tn]=!0;a.meta?a.size>this.maxMetaEntrySize?(a.ignore=!0,this[Cn]("ignoredEntry",a),this[nt]="ignore",a.resume()):a.size>0&&(this[en]="",a.on("data",c=>this[en]+=c),this[nt]="meta"):(this[_t]=void 0,a.ignore=a.ignore||!this.filter(a.path,a),a.ignore?(this[Cn]("ignoredEntry",a),this[nt]=a.remain?"ignore":"header",a.resume()):(a.remain?this[nt]="body":(this[nt]="header",a.end()),this[Lt]?this[Nt].push(a):(this[Nt].push(a),this[ma]())))}}}[Ud](){queueMicrotask(()=>this.emit("close"))}[Md](t){let e=!0;if(!t)this[Lt]=void 0,e=!1;else if(Array.isArray(t)){let[r,...s]=t;this.emit(r,...s)}else this[Lt]=t,this.emit("entry",t),t.emittedEnd||(t.on("end",()=>this[ma]()),e=!1);return e}[ma](){do;while(this[Md](this[Nt].shift()));if(this[Nt].length===0){let t=this[Lt];!t||t.flowing||t.size===t.remain?this[nr]||this.emit("drain"):t.once("drain",()=>this.emit("drain"))}}[_a](t,e){let r=this[An];if(!r)throw new Error("attempt to consume body without entry??");let s=r.blockRemain??0,a=s>=t.length&&e===0?t:t.subarray(e,e+s);return r.write(a),r.blockRemain||(this[nt]="header",this[An]=void 0,r.end()),a.length}[zd](t,e){let r=this[An],s=this[_a](t,e);return!this[An]&&r&&this[Bd](r),s}[Cn](t,e,r){this[Nt].length===0&&!this[Lt]?this.emit(t,e,r):this[Nt].push([t,e,r])}[Bd](t){switch(this[Cn]("meta",this[en]),t.type){case"ExtendedHeader":case"OldExtendedHeader":this[_t]=Es.parse(this[en],this[_t],!1);break;case"GlobalExtendedHeader":this[jr]=Es.parse(this[en],this[jr],!0);break;case"NextFileHasLongPath":case"OldGnuLongPath":{let e=this[_t]??Object.create(null);this[_t]=e,e.path=this[en].replace(/\0.*/,"");break}case"NextFileHasLongLinkpath":{let e=this[_t]||Object.create(null);this[_t]=e,e.linkpath=this[en].replace(/\0.*/,"");break}default:throw new Error("unknown meta: "+t.type)}}abort(t){this[nn]=!0,this.emit("abort",t),this.warn("TAR_ABORT",t,{recoverable:!1})}write(t,e,r){if(typeof e=="function"&&(r=e,e=void 0),typeof t=="string"&&(t=Buffer.from(t,typeof e=="string"?e:"utf8")),this[nn])return r?.(),!1;if((this[ye]===void 0||this.brotli===void 0&&this[ye]===!1)&&t){if(this[ce]&&(t=Buffer.concat([this[ce],t]),this[ce]=void 0),t.length<rm)return this[ce]=t,r?.(),!0;for(let f=0;this[ye]===void 0&&f<Oa.length;f++)t[f]!==Oa[f]&&(this[ye]=!1);let a=!1;if(this[ye]===!1&&this.zstd!==!1){a=!0;for(let f=0;f<Pa.length;f++)if(t[f]!==Pa[f]){a=!1;break}}let c=this.brotli===void 0&&!a;if(this[ye]===!1&&c)if(t.length<512)if(this[tn])this.brotli=!0;else return this[ce]=t,r?.(),!0;else try{new Pn(t.subarray(0,512)),this.brotli=!1}catch{this.brotli=!0}if(this[ye]===void 0||this[ye]===!1&&(this.brotli||a)){let f=this[tn];this[tn]=!1,this[ye]=this[ye]===void 0?new Dg({}):a?new Pg({}):new kg({}),this[ye].on("data",x=>this[ns](x)),this[ye].on("error",x=>this.abort(x)),this[ye].on("end",()=>{this[tn]=!0,this[ns]()}),this[nr]=!0;let l=!!this[ye][f?"end":"write"](t);return this[nr]=!1,r?.(),l}}this[nr]=!0,this[ye]?this[ye].write(t):this[ns](t),this[nr]=!1;let s=this[Nt].length>0?!1:this[Lt]?this[Lt].flowing:!0;return!s&&this[Nt].length===0&&this[Lt]?.once("drain",()=>this.emit("drain")),r?.(),s}[ya](t){t&&!this[nn]&&(this[ce]=this[ce]?Buffer.concat([this[ce],t]):t)}[is](){if(this[tn]&&!this[wa]&&!this[nn]&&!this[Gr]){this[wa]=!0;let t=this[An];if(t&&t.blockRemain){let e=this[ce]?this[ce].length:0;this.warn("TAR_BAD_ARCHIVE",`Truncated input (needed ${t.blockRemain} more bytes, only ${e} available)`,{entry:t}),this[ce]&&t.write(this[ce]),t.end()}this[Cn](ss)}}[ns](t){if(this[Gr]&&t)this[ya](t);else if(!t&&!this[ce])this[is]();else if(t){if(this[Gr]=!0,this[ce]){this[ya](t);let e=this[ce];this[ce]=void 0,this[rs](e)}else this[rs](t);for(;this[ce]&&this[ce]?.length>=512&&!this[nn]&&!this[as];){let e=this[ce];this[ce]=void 0,this[rs](e)}this[Gr]=!1}(!this[ce]||this[tn])&&this[is]()}[rs](t){let e=0,r=t.length;for(;e+512<=r&&!this[nn]&&!this[as];)switch(this[nt]){case"begin":case"header":this[Fd](t,e),e+=512;break;case"ignore":case"body":e+=this[_a](t,e);break;case"meta":e+=this[zd](t,e);break;default:throw new Error("invalid state: "+this[nt])}e<r&&(this[ce]=this[ce]?Buffer.concat([t.subarray(e),this[ce]]):t.subarray(e))}end(t,e,r){return typeof t=="function"&&(r=t,e=void 0,t=void 0),typeof e=="function"&&(r=e,e=void 0),typeof t=="string"&&(t=Buffer.from(t,e)),r&&this.once("finish",r),this[nn]||(this[ye]?(t&&this[ye].write(t),this[ye].end()):(this[tn]=!0,(this.brotli===void 0||this.zstd===void 0)&&(t=t||Buffer.alloc(0)),t&&this.write(t),this[is]())),this}},Qr=t=>{let e=t.length-1,r=-1;for(;e>-1&&t.charAt(e)==="/";)r=e,e--;return r===-1?t:t.slice(0,r)},sm=t=>{let e=t.onReadEntry;t.onReadEntry=e?r=>{e(r),r.resume()}:r=>r.resume()},bf=(t,e)=>{let r=new Map(e.map(c=>[Qr(c),!0])),s=t.filter,a=(c,f="")=>{let l=f||pg(c).root||".",x;if(c===l)x=!1;else{let h=r.get(c);x=h!==void 0?h:a(hg(c),l)}return r.set(c,x),x};t.filter=s?(c,f)=>s(c,f)&&a(Qr(c)):c=>a(Qr(c))},om=t=>{let e=new oi(t),r=t.file,s;try{s=cr.openSync(r,"r");let a=cr.fstatSync(s),c=t.maxReadSize||16*1024*1024;if(a.size<c){let f=Buffer.allocUnsafe(a.size),l=cr.readSync(s,f,0,a.size,0);e.end(l===f.byteLength?f:f.subarray(0,l))}else{let f=0,l=Buffer.allocUnsafe(c);for(;f<a.size;){let x=cr.readSync(s,l,0,c,f);if(x===0)break;f+=x,e.write(l.subarray(0,x))}e.end()}}finally{if(typeof s=="number")try{cr.closeSync(s)}catch{}}},am=(t,e)=>{let r=new oi(t),s=t.maxReadSize||16*1024*1024,a=t.file;return new Promise((c,f)=>{r.on("error",f),r.on("end",c),cr.stat(a,(l,x)=>{if(l)f(l);else{let h=new Ya(a,{readSize:s,size:x.size});h.on("error",f),h.pipe(r)}})})},ur=ai(om,am,t=>new oi(t),t=>new oi(t),(t,e)=>{e?.length&&bf(t,e),t.noResume||sm(t)}),Sf=(t,e,r)=>(t&=4095,r&&(t=(t|384)&-19),e&&(t&256&&(t|=64),t&32&&(t|=8),t&4&&(t|=1)),t),{isAbsolute:dm,parse:Hd}=cm,tc=t=>{let e="",r=Hd(t);for(;dm(t)||r.root;){let s=t.charAt(0)==="/"&&t.slice(0,4)!=="//?/"?"/":r.root;t=t.slice(s.length),e+=s,r=Hd(t)}return[e,t]},Ds=["|","<",">","?",":"],nc=Ds.map(t=>String.fromCodePoint(61440+Number(t.codePointAt(0)))),fm=new Map(Ds.map((t,e)=>[t,nc[e]])),lm=new Map(nc.map((t,e)=>[t,Ds[e]])),jd=t=>Ds.reduce((e,r)=>e.split(r).join(fm.get(r)),t),um=t=>nc.reduce((e,r)=>e.split(r).join(lm.get(r)),t),vf=(t,e)=>e?(t=Z(t).replace(/^\.(\/|$)/,""),Qr(e)+"/"+t):Z(t),xm=16*1024*1024,Gd=Symbol("process"),Kd=Symbol("file"),Wd=Symbol("directory"),La=Symbol("symlink"),$d=Symbol("hardlink"),Kr=Symbol("header"),xs=Symbol("read"),Na=Symbol("lstat"),hs=Symbol("onlstat"),Ma=Symbol("onread"),Ba=Symbol("onreadlink"),za=Symbol("openfile"),Fa=Symbol("onopenfile"),cn=Symbol("close"),Ss=Symbol("mode"),Ua=Symbol("awaitDrain"),Ea=Symbol("ondrain"),Et=Symbol("prefix"),If=class extends Ln{path;portable;myuid=process.getuid&&process.getuid()||0;myuser=process.env.USER||"";maxReadSize;linkCache;statCache;preservePaths;cwd;strict;mtime;noPax;noMtime;prefix;fd;blockLen=0;blockRemain=0;buf;pos=0;remain=0;length=0;offset=0;win32;absolute;header;type;linkpath;stat;onWriteEntry;#e=!1;constructor(t,e={}){let r=Xa(e);super(),this.path=Z(t),this.portable=!!r.portable,this.maxReadSize=r.maxReadSize||xm,this.linkCache=r.linkCache||new Map,this.statCache=r.statCache||new Map,this.preservePaths=!!r.preservePaths,this.cwd=Z(r.cwd||process.cwd()),this.strict=!!r.strict,this.noPax=!!r.noPax,this.noMtime=!!r.noMtime,this.mtime=r.mtime,this.prefix=r.prefix?Z(r.prefix):void 0,this.onWriteEntry=r.onWriteEntry,typeof r.onwarn=="function"&&this.on("warn",r.onwarn);let s=!1;if(!this.preservePaths){let[c,f]=tc(this.path);c&&typeof f=="string"&&(this.path=f,s=c)}this.win32=!!r.win32||process.platform==="win32",this.win32&&(this.path=um(this.path.replaceAll(/\\/g,"/")),t=t.replaceAll(/\\/g,"/")),this.absolute=Z(r.absolute||qd.resolve(this.cwd,t)),this.path===""&&(this.path="./"),s&&this.warn("TAR_ENTRY_INFO",`stripping ${s} from absolute path`,{entry:this,path:s+this.path});let a=this.statCache.get(this.absolute);a?this[hs](a):this[Na]()}warn(t,e,r={}){return Ts(this,t,e,r)}emit(t,...e){return t==="error"&&(this.#e=!0),super.emit(t,...e)}[Na](){yt.lstat(this.absolute,(t,e)=>{if(t)return this.emit("error",t);this[hs](e)})}[hs](t){this.statCache.set(this.absolute,t),this.stat=t,t.isFile()||(t.size=0),this.type=gm(t),this.emit("stat",t),this[Gd]()}[Gd](){switch(this.type){case"File":return this[Kd]();case"Directory":return this[Wd]();case"SymbolicLink":return this[La]();default:return this.end()}}[Ss](t){return Sf(t,this.type==="Directory",this.portable)}[Et](t){return vf(t,this.prefix)}[Kr](){if(!this.stat)throw new Error("cannot write header before stat");this.type==="Directory"&&this.portable&&(this.noMtime=!0),this.onWriteEntry?.(this),this.header=new Pn({path:this[Et](this.path),linkpath:this.type==="Link"&&this.linkpath!==void 0?this[Et](this.linkpath):this.linkpath,mode:this[Ss](this.stat.mode),uid:this.portable?void 0:this.stat.uid,gid:this.portable?void 0:this.stat.gid,size:this.stat.size,mtime:this.noMtime?void 0:this.mtime||this.stat.mtime,type:this.type==="Unsupported"?void 0:this.type,uname:this.portable?void 0:this.stat.uid===this.myuid?this.myuser:"",atime:this.portable?void 0:this.stat.atime,ctime:this.portable?void 0:this.stat.ctime}),this.header.encode()&&!this.noPax&&super.write(new Es({atime:this.portable?void 0:this.header.atime,ctime:this.portable?void 0:this.header.ctime,gid:this.portable?void 0:this.header.gid,mtime:this.noMtime?void 0:this.mtime||this.header.mtime,path:this[Et](this.path),linkpath:this.type==="Link"&&this.linkpath!==void 0?this[Et](this.linkpath):this.linkpath,size:this.header.size,uid:this.portable?void 0:this.header.uid,uname:this.portable?void 0:this.header.uname,dev:this.portable?void 0:this.stat.dev,ino:this.portable?void 0:this.stat.ino,nlink:this.portable?void 0:this.stat.nlink}).encode());let t=this.header?.block;if(!t)throw new Error("failed to encode header");super.write(t)}[Wd](){if(!this.stat)throw new Error("cannot create directory entry without stat");this.path.slice(-1)!=="/"&&(this.path+="/"),this.stat.size=0,this[Kr](),this.end()}[La](){yt.readlink(this.absolute,(t,e)=>{if(t)return this.emit("error",t);this[Ba](e)})}[Ba](t){this.linkpath=Z(t),this[Kr](),this.end()}[$d](t){if(!this.stat)throw new Error("cannot create link entry without stat");this.type="Link",this.linkpath=Z(qd.relative(this.cwd,t)),this.stat.size=0,this[Kr](),this.end()}[Kd](){if(!this.stat)throw new Error("cannot create file entry without stat");if(this.stat.nlink>1){let t=`${this.stat.dev}:${this.stat.ino}`,e=this.linkCache.get(t);if(e?.indexOf(this.cwd)===0)return this[$d](e);this.linkCache.set(t,this.absolute)}if(this[Kr](),this.stat.size===0)return this.end();this[za]()}[za](){yt.open(this.absolute,"r",(t,e)=>{if(t)return this.emit("error",t);this[Fa](e)})}[Fa](t){if(this.fd=t,this.#e)return this[cn]();if(!this.stat)throw new Error("should stat before calling onopenfile");this.blockLen=512*Math.ceil(this.stat.size/512),this.blockRemain=this.blockLen;let e=Math.min(this.blockLen,this.maxReadSize);this.buf=Buffer.allocUnsafe(e),this.offset=0,this.pos=0,this.remain=this.stat.size,this.length=this.buf.length,this[xs]()}[xs](){let{fd:t,buf:e,offset:r,length:s,pos:a}=this;if(t===void 0||e===void 0)throw new Error("cannot read file without first opening");yt.read(t,e,r,s,a,(c,f)=>{if(c)return this[cn](()=>this.emit("error",c));this[Ma](f)})}[cn](t=()=>{}){this.fd!==void 0&&yt.close(this.fd,t)}[Ma](t){if(t<=0&&this.remain>0){let r=Object.assign(new Error("encountered unexpected EOF"),{path:this.absolute,syscall:"read",code:"EOF"});return this[cn](()=>this.emit("error",r))}if(t>this.remain){let r=Object.assign(new Error("did not encounter expected EOF"),{path:this.absolute,syscall:"read",code:"EOF"});return this[cn](()=>this.emit("error",r))}if(!this.buf)throw new Error("should have created buffer prior to reading");if(t===this.remain)for(let r=t;r<this.length&&t<this.blockRemain;r++)this.buf[r+this.offset]=0,t++,this.remain++;let e=this.offset===0&&t===this.buf.length?this.buf:this.buf.subarray(this.offset,this.offset+t);this.write(e)?this[Ea]():this[Ua](()=>this[Ea]())}[Ua](t){this.once("drain",t)}write(t,e,r){if(typeof e=="function"&&(r=e,e=void 0),typeof t=="string"&&(t=Buffer.from(t,typeof e=="string"?e:"utf8")),this.blockRemain<t.length){let s=Object.assign(new Error("writing more data than expected"),{path:this.absolute});return this.emit("error",s)}return this.remain-=t.length,this.blockRemain-=t.length,this.pos+=t.length,this.offset+=t.length,super.write(t,null,r)}[Ea](){if(!this.remain)return this.blockRemain&&super.write(Buffer.alloc(this.blockRemain)),this[cn](t=>t?this.emit("error",t):this.end());if(!this.buf)throw new Error("buffer lost somehow in ONDRAIN");this.offset>=this.length&&(this.buf=Buffer.allocUnsafe(Math.min(this.blockRemain,this.buf.length)),this.offset=0),this.length=this.buf.length-this.offset,this[xs]()}},hm=class extends If{sync=!0;[Na](){this[hs](yt.lstatSync(this.absolute))}[La](){this[Ba](yt.readlinkSync(this.absolute))}[za](){this[Fa](yt.openSync(this.absolute,"r"))}[xs](){let t=!0;try{let{fd:e,buf:r,offset:s,length:a,pos:c}=this;if(e===void 0||r===void 0)throw new Error("fd and buf must be set in READ method");let f=yt.readSync(e,r,s,a,c);this[Ma](f),t=!1}finally{if(t)try{this[cn](()=>{})}catch{}}}[Ua](t){t()}[cn](t=()=>{}){this.fd!==void 0&&yt.closeSync(this.fd),t()}},pm=class extends Ln{blockLen=0;blockRemain=0;buf=0;pos=0;remain=0;length=0;preservePaths;portable;strict;noPax;noMtime;readEntry;type;prefix;path;mode;uid;gid;uname;gname;header;mtime;atime;ctime;linkpath;size;onWriteEntry;warn(t,e,r={}){return Ts(this,t,e,r)}constructor(t,e={}){let r=Xa(e);super(),this.preservePaths=!!r.preservePaths,this.portable=!!r.portable,this.strict=!!r.strict,this.noPax=!!r.noPax,this.noMtime=!!r.noMtime,this.onWriteEntry=r.onWriteEntry,this.readEntry=t;let{type:s}=t;if(s==="Unsupported")throw new Error("writing entry that should be ignored");this.type=s,this.type==="Directory"&&this.portable&&(this.noMtime=!0),this.prefix=r.prefix,this.path=Z(t.path),this.mode=t.mode!==void 0?this[Ss](t.mode):void 0,this.uid=this.portable?void 0:t.uid,this.gid=this.portable?void 0:t.gid,this.uname=this.portable?void 0:t.uname,this.gname=this.portable?void 0:t.gname,this.size=t.size,this.mtime=this.noMtime?void 0:r.mtime||t.mtime,this.atime=this.portable?void 0:t.atime,this.ctime=this.portable?void 0:t.ctime,this.linkpath=t.linkpath!==void 0?Z(t.linkpath):void 0,typeof r.onwarn=="function"&&this.on("warn",r.onwarn);let a=!1;if(!this.preservePaths){let[f,l]=tc(this.path);f&&typeof l=="string"&&(this.path=l,a=f)}this.remain=t.size,this.blockRemain=t.startBlockSize,this.onWriteEntry?.(this),this.header=new Pn({path:this[Et](this.path),linkpath:this.type==="Link"&&this.linkpath!==void 0?this[Et](this.linkpath):this.linkpath,mode:this.mode,uid:this.portable?void 0:this.uid,gid:this.portable?void 0:this.gid,size:this.size,mtime:this.noMtime?void 0:this.mtime,type:this.type,uname:this.portable?void 0:this.uname,atime:this.portable?void 0:this.atime,ctime:this.portable?void 0:this.ctime}),a&&this.warn("TAR_ENTRY_INFO",`stripping ${a} from absolute path`,{entry:this,path:a+this.path}),this.header.encode()&&!this.noPax&&super.write(new Es({atime:this.portable?void 0:this.atime,ctime:this.portable?void 0:this.ctime,gid:this.portable?void 0:this.gid,mtime:this.noMtime?void 0:this.mtime,path:this[Et](this.path),linkpath:this.type==="Link"&&this.linkpath!==void 0?this[Et](this.linkpath):this.linkpath,size:this.size,uid:this.portable?void 0:this.uid,uname:this.portable?void 0:this.uname,dev:this.portable?void 0:this.readEntry.dev,ino:this.portable?void 0:this.readEntry.ino,nlink:this.portable?void 0:this.readEntry.nlink}).encode());let c=this.header?.block;if(!c)throw new Error("failed to encode header");super.write(c),t.pipe(this)}[Et](t){return vf(t,this.prefix)}[Ss](t){return Sf(t,this.type==="Directory",this.portable)}write(t,e,r){typeof e=="function"&&(r=e,e=void 0),typeof t=="string"&&(t=Buffer.from(t,typeof e=="string"?e:"utf8"));let s=t.length;if(s>this.blockRemain)throw new Error("writing more to entry than is appropriate");return this.blockRemain-=s,super.write(t,r)}end(t,e,r){return this.blockRemain&&super.write(Buffer.alloc(this.blockRemain)),typeof t=="function"&&(r=t,e=void 0,t=void 0),typeof e=="function"&&(r=e,e=void 0),typeof t=="string"&&(t=Buffer.from(t,e??"utf8")),r&&this.once("finish",r),t?super.end(t,r):super.end(r),this}},gm=t=>t.isFile()?"File":t.isDirectory()?"Directory":t.isSymbolicLink()?"SymbolicLink":"Unsupported",mm=class dr{tail;head;length=0;static create(e=[]){return new dr(e)}constructor(e=[]){for(let r of e)this.push(r)}*[Symbol.iterator](){for(let e=this.head;e;e=e.next)yield e.value}removeNode(e){if(e.list!==this)throw new Error("removing node which does not belong to this list");let r=e.next,s=e.prev;return r&&(r.prev=s),s&&(s.next=r),e===this.head&&(this.head=r),e===this.tail&&(this.tail=s),this.length--,e.next=void 0,e.prev=void 0,e.list=void 0,r}unshiftNode(e){if(e===this.head)return;e.list&&e.list.removeNode(e);let r=this.head;e.list=this,e.next=r,r&&(r.prev=e),this.head=e,this.tail||(this.tail=e),this.length++}pushNode(e){if(e===this.tail)return;e.list&&e.list.removeNode(e);let r=this.tail;e.list=this,e.prev=r,r&&(r.next=e),this.tail=e,this.head||(this.head=e),this.length++}push(...e){for(let r=0,s=e.length;r<s;r++)_m(this,e[r]);return this.length}unshift(...e){for(var r=0,s=e.length;r<s;r++)ym(this,e[r]);return this.length}pop(){if(!this.tail)return;let e=this.tail.value,r=this.tail;return this.tail=this.tail.prev,this.tail?this.tail.next=void 0:this.head=void 0,r.list=void 0,this.length--,e}shift(){if(!this.head)return;let e=this.head.value,r=this.head;return this.head=this.head.next,this.head?this.head.prev=void 0:this.tail=void 0,r.list=void 0,this.length--,e}forEach(e,r){r=r||this;for(let s=this.head,a=0;s;a++)e.call(r,s.value,a,this),s=s.next}forEachReverse(e,r){r=r||this;for(let s=this.tail,a=this.length-1;s;a--)e.call(r,s.value,a,this),s=s.prev}get(e){let r=0,s=this.head;for(;s&&r<e;r++)s=s.next;if(r===e&&s)return s.value}getReverse(e){let r=0,s=this.tail;for(;s&&r<e;r++)s=s.prev;if(r===e&&s)return s.value}map(e,r){r=r||this;let s=new dr;for(let a=this.head;a;)s.push(e.call(r,a.value,this)),a=a.next;return s}mapReverse(e,r){r=r||this;var s=new dr;for(let a=this.tail;a;)s.push(e.call(r,a.value,this)),a=a.prev;return s}reduce(e,r){let s,a=this.head;if(arguments.length>1)s=r;else if(this.head)a=this.head.next,s=this.head.value;else throw new TypeError("Reduce of empty list with no initial value");for(var c=0;a;c++)s=e(s,a.value,c),a=a.next;return s}reduceReverse(e,r){let s,a=this.tail;if(arguments.length>1)s=r;else if(this.tail)a=this.tail.prev,s=this.tail.value;else throw new TypeError("Reduce of empty list with no initial value");for(let c=this.length-1;a;c--)s=e(s,a.value,c),a=a.prev;return s}toArray(){let e=new Array(this.length);for(let r=0,s=this.head;s;r++)e[r]=s.value,s=s.next;return e}toArrayReverse(){let e=new Array(this.length);for(let r=0,s=this.tail;s;r++)e[r]=s.value,s=s.prev;return e}slice(e=0,r=this.length){r<0&&(r+=this.length),e<0&&(e+=this.length);let s=new dr;if(r<e||r<0)return s;e<0&&(e=0),r>this.length&&(r=this.length);let a=this.head,c=0;for(c=0;a&&c<e;c++)a=a.next;for(;a&&c<r;c++,a=a.next)s.push(a.value);return s}sliceReverse(e=0,r=this.length){r<0&&(r+=this.length),e<0&&(e+=this.length);let s=new dr;if(r<e||r<0)return s;e<0&&(e=0),r>this.length&&(r=this.length);let a=this.length,c=this.tail;for(;c&&a>r;a--)c=c.prev;for(;c&&a>e;a--,c=c.prev)s.push(c.value);return s}splice(e,r=0,...s){e>this.length&&(e=this.length-1),e<0&&(e=this.length+e);let a=this.head;for(let f=0;a&&f<e;f++)a=a.next;let c=[];for(let f=0;a&&f<r;f++)c.push(a.value),a=this.removeNode(a);a?a!==this.tail&&(a=a.prev):a=this.tail;for(let f of s)a=wm(this,a,f);return c}reverse(){let e=this.head,r=this.tail;for(let s=e;s;s=s.prev){let a=s.prev;s.prev=s.next,s.next=a}return this.head=r,this.tail=e,this}};function wm(t,e,r){let s=e,a=e?e.next:t.head,c=new rc(r,s,a,t);return c.next===void 0&&(t.tail=c),c.prev===void 0&&(t.head=c),t.length++,c}function _m(t,e){t.tail=new rc(e,t.tail,void 0,t),t.head||(t.head=t.tail),t.length++}function ym(t,e){t.head=new rc(e,void 0,t.head,t),t.tail||(t.tail=t.head),t.length++}var rc=class{list;next;prev;value;constructor(t,e,r,s){this.list=s,this.value=t,e?(e.next=this,this.prev=e):this.prev=void 0,r?(r.prev=this,this.next=r):this.next=void 0}},Jd=class{path;absolute;entry;stat;readdir;pending=!1;pendingLink=!1;ignore=!1;piped=!1;constructor(t,e){this.path=t||"./",this.absolute=e}},Zd=Buffer.alloc(1024),ps=Symbol("onStat"),Wr=Symbol("ended"),lt=Symbol("queue"),$r=Symbol("queue"),rn=Symbol("current"),Dn=Symbol("process"),Vr=Symbol("processing"),cs=Symbol("processJob"),ut=Symbol("jobs"),ba=Symbol("jobDone"),gs=Symbol("addFSEntry"),Yd=Symbol("addTarEntry"),qa=Symbol("stat"),Ha=Symbol("readdir"),ms=Symbol("onreaddir"),ws=Symbol("pipe"),Xd=Symbol("entry"),Sa=Symbol("entryOpt"),_s=Symbol("writeEntryClass"),Af=Symbol("write"),va=Symbol("ondrain"),Rs=class extends Ln{sync=!1;opt;cwd;maxReadSize;preservePaths;strict;noPax;prefix;linkCache;statCache;file;portable;zip;readdirCache;noDirRecurse;follow;noMtime;mtime;filter;jobs;[_s];onWriteEntry;[lt];[$r]=new Map;[ut]=0;[Vr]=!1;[Wr]=!1;constructor(t={}){if(super(),this.opt=t,this.file=t.file||"",this.cwd=t.cwd||process.cwd(),this.maxReadSize=t.maxReadSize,this.preservePaths=!!t.preservePaths,this.strict=!!t.strict,this.noPax=!!t.noPax,this.prefix=Z(t.prefix||""),this.linkCache=t.linkCache||new Map,this.statCache=t.statCache||new Map,this.readdirCache=t.readdirCache||new Map,this.onWriteEntry=t.onWriteEntry,this[_s]=If,typeof t.onwarn=="function"&&this.on("warn",t.onwarn),this.portable=!!t.portable,t.gzip||t.brotli||t.zstd){if((t.gzip?1:0)+(t.brotli?1:0)+(t.zstd?1:0)>1)throw new TypeError("gzip, brotli, zstd are mutually exclusive");if(t.gzip&&(typeof t.gzip!="object"&&(t.gzip={}),this.portable&&(t.gzip.portable=!0),this.zip=new Tg(t.gzip)),t.brotli&&(typeof t.brotli!="object"&&(t.brotli={}),this.zip=new Rg(t.brotli)),t.zstd&&(typeof t.zstd!="object"&&(t.zstd={}),this.zip=new Og(t.zstd)),!this.zip)throw new Error("impossible");let e=this.zip;e.on("data",r=>super.write(r)),e.on("end",()=>super.end()),e.on("drain",()=>this[va]()),this.on("resume",()=>e.resume())}else this.on("drain",this[va]);this.noDirRecurse=!!t.noDirRecurse,this.follow=!!t.follow,this.noMtime=!!t.noMtime,t.mtime&&(this.mtime=t.mtime),this.filter=typeof t.filter=="function"?t.filter:()=>!0,this[lt]=new mm,this[ut]=0,this.jobs=Number(t.jobs)||4,this[Vr]=!1,this[Wr]=!1}[Af](t){return super.write(t)}add(t){return this.write(t),this}end(t,e,r){return typeof t=="function"&&(r=t,t=void 0),typeof e=="function"&&(r=e,e=void 0),t&&this.add(t),this[Wr]=!0,this[Dn](),r&&r(),this}write(t){if(this[Wr])throw new Error("write after end");return t instanceof Ef?this[Yd](t):this[gs](t),this.flowing}[Yd](t){let e=Z(Vd.resolve(this.cwd,t.path));if(!this.filter(t.path,t))t.resume();else{let r=new Jd(t.path,e);r.entry=new pm(t,this[Sa](r)),r.entry.on("end",()=>this[ba](r)),this[ut]+=1,this[lt].push(r)}this[Dn]()}[gs](t){let e=Z(Vd.resolve(this.cwd,t));this[lt].push(new Jd(t,e)),this[Dn]()}[qa](t){t.pending=!0,this[ut]+=1;let e=this.follow?"stat":"lstat";bs[e](t.absolute,(r,s)=>{t.pending=!1,this[ut]-=1,r?this.emit("error",r):this[ps](t,s)})}[ps](t,e){if(this.statCache.set(t.absolute,e),t.stat=e,!this.filter(t.path,e))t.ignore=!0;else if(e.isFile()&&e.nlink>1&&!this.linkCache.get(`${e.dev}:${e.ino}`)&&!this.sync)if(t===this[rn])this[cs](t);else{let r=`${e.dev}:${e.ino}`,s=this[$r].get(r);s?s.push(t):this[$r].set(r,[t]),t.pendingLink=!0,t.pending=!0}this[Dn]()}[Ha](t){t.pending=!0,this[ut]+=1,bs.readdir(t.absolute,(e,r)=>{if(t.pending=!1,this[ut]-=1,e)return this.emit("error",e);this[ms](t,r)})}[ms](t,e){this.readdirCache.set(t.absolute,e),t.readdir=e,this[Dn]()}[Dn](){if(!this[Vr]){this[Vr]=!0;for(let t=this[lt].head;t&&this[ut]<this.jobs;t=t.next)if(this[cs](t.value),t.value.ignore){let e=t.next;this[lt].removeNode(t),t.next=e}this[Vr]=!1,this[Wr]&&this[lt].length===0&&this[ut]===0&&(this.zip?this.zip.end(Zd):(super.write(Zd),super.end()))}}get[rn](){return this[lt]&&this[lt].head&&this[lt].head.value}[ba](t){this[lt].shift(),this[ut]-=1;let{stat:e}=t;if(e&&e.isFile()&&e.nlink>1){let r=`${e.dev}:${e.ino}`,s=this[$r].get(r);if(s){this[$r].delete(r);for(let a of s)a.pending=!1,this[cs](a)}}this[Dn]()}[cs](t){if(t.pending&&t.pendingLink&&t===this[rn]&&(t.pending=!1,t.pendingLink=!1),!t.pending){if(t.entry){t===this[rn]&&!t.piped&&this[ws](t);return}if(!t.stat){let e=this.statCache.get(t.absolute);e?this[ps](t,e):this[qa](t)}if(t.stat&&!t.ignore){if(!this.noDirRecurse&&t.stat.isDirectory()&&!t.readdir){let e=this.readdirCache.get(t.absolute);if(e?this[ms](t,e):this[Ha](t),!t.readdir)return}if(t.entry=this[Xd](t),!t.entry){t.ignore=!0;return}t===this[rn]&&!t.piped&&this[ws](t)}}}[Sa](t){return{onwarn:(e,r,s)=>this.warn(e,r,s),noPax:this.noPax,cwd:this.cwd,absolute:t.absolute,preservePaths:this.preservePaths,maxReadSize:this.maxReadSize,strict:this.strict,portable:this.portable,linkCache:this.linkCache,statCache:this.statCache,noMtime:this.noMtime,mtime:this.mtime,prefix:this.prefix,onWriteEntry:this.onWriteEntry}}[Xd](t){this[ut]+=1;try{return new this[_s](t.path,this[Sa](t)).on("end",()=>this[ba](t)).on("error",e=>this.emit("error",e))}catch(e){this.emit("error",e)}}[va](){this[rn]&&this[rn].entry&&this[rn].entry.resume()}[ws](t){t.piped=!0,t.readdir&&t.readdir.forEach(s=>{let a=t.path,c=a==="./"?"":a.replace(/\/*$/,"/");this[gs](c+s)});let e=t.entry,r=this.zip;if(!e)throw new Error("cannot pipe without source");r?e.on("data",s=>{r.write(s)||e.pause()}):e.on("data",s=>{super.write(s)||e.pause()})}pause(){return this.zip&&this.zip.pause(),super.pause()}warn(t,e,r={}){Ts(this,t,e,r)}},ic=class extends Rs{sync=!0;constructor(t){super(t),this[_s]=hm}pause(){}resume(){}[qa](t){let e=this.follow?"statSync":"lstatSync";this[ps](t,bs[e](t.absolute))}[Ha](t){this[ms](t,bs.readdirSync(t.absolute))}[ws](t){let e=t.entry,r=this.zip;if(t.readdir&&t.readdir.forEach(s=>{let a=t.path,c=a==="./"?"":a.replace(/\/*$/,"/");this[gs](c+s)}),!e)throw new Error("Cannot pipe without source");r?e.on("data",s=>{r.write(s)}):e.on("data",s=>{super[Af](s)})}},Em=(t,e)=>{let r=new ic(t),s=new xf(t.file,{mode:t.mode||438});r.pipe(s),Cf(r,e)},bm=(t,e)=>{let r=new Rs(t),s=new As(t.file,{mode:t.mode||438});r.pipe(s);let a=new Promise((c,f)=>{s.on("error",f),s.on("close",c),r.on("error",f)});return Tf(r,e).catch(c=>r.emit("error",c)),a},Cf=(t,e)=>{e.forEach(r=>{r.charAt(0)==="@"?ur({file:hf.resolve(t.cwd,r.slice(1)),sync:!0,noResume:!0,onReadEntry:s=>t.add(s)}):t.add(r)}),t.end()},Tf=async(t,e)=>{for(let r of e)r.charAt(0)==="@"?await ur({file:hf.resolve(String(t.cwd),r.slice(1)),noResume:!0,onReadEntry:s=>{t.add(s)}}):t.add(r);t.end()},Sm=(t,e)=>{let r=new ic(t);return Cf(r,e),r},vm=(t,e)=>{let r=new Rs(t);return Tf(r,e).catch(s=>r.emit("error",s)),r},AS=ai(Em,bm,Sm,vm,(t,e)=>{if(!e?.length)throw new TypeError("no paths specified to add to archive")}),Am=process.env.__FAKE_PLATFORM__||process.platform,Of=Am==="win32",{O_CREAT:Pf,O_NOFOLLOW:Qd,O_TRUNC:Lf,O_WRONLY:Nf}=kf.constants,Mf=Number(process.env.__FAKE_FS_O_FILENAME__)||kf.constants.UV_FS_O_FILEMAP||0,Cm=Of&&!!Mf,Tm=512*1024,Dm=Mf|Lf|Pf|Nf,ef=!Of&&typeof Qd=="number"?Qd|Lf|Pf|Nf:null,Bf=ef!==null?()=>ef:Cm?t=>t<Tm?Dm:"w":()=>"w",ja=(t,e,r)=>{try{return ks.lchownSync(t,e,r)}catch(s){if(s?.code!=="ENOENT")throw s}},vs=(t,e,r,s)=>{ks.lchown(t,e,r,a=>{s(a&&a?.code!=="ENOENT"?a:null)})},Rm=(t,e,r,s,a)=>{if(e.isDirectory())zf(ei.resolve(t,e.name),r,s,c=>{if(c)return a(c);let f=ei.resolve(t,e.name);vs(f,r,s,a)});else{let c=ei.resolve(t,e.name);vs(c,r,s,a)}},zf=(t,e,r,s)=>{ks.readdir(t,{withFileTypes:!0},(a,c)=>{if(a){if(a.code==="ENOENT")return s();if(a.code!=="ENOTDIR"&&a.code!=="ENOTSUP")return s(a)}if(a||!c.length)return vs(t,e,r,s);let f=c.length,l=null,x=h=>{if(!l){if(h)return s(l=h);if(--f===0)return vs(t,e,r,s)}};for(let h of c)Rm(t,h,e,r,x)})},km=(t,e,r,s)=>{e.isDirectory()&&Ff(ei.resolve(t,e.name),r,s),ja(ei.resolve(t,e.name),r,s)},Ff=(t,e,r)=>{let s;try{s=ks.readdirSync(t,{withFileTypes:!0})}catch(a){let c=a;if(c?.code==="ENOENT")return;if(c?.code==="ENOTDIR"||c?.code==="ENOTSUP")return ja(t,e,r);throw c}for(let a of s)km(t,a,e,r);return ja(t,e,r)},Uf=class extends Error{path;code;syscall="chdir";constructor(t,e){super(`${e}: Cannot cd into '${t}'`),this.path=t,this.code=e}get name(){return"CwdError"}},Os=class extends Error{path;symlink;syscall="symlink";code="TAR_SYMLINK_ERROR";constructor(t,e){super("TAR_SYMLINK_ERROR: Cannot extract through symbolic link"),this.symlink=t,this.path=e}get name(){return"SymlinkError"}},Pm=(t,e)=>{Xe.stat(t,(r,s)=>{(r||!s.isDirectory())&&(r=new Uf(t,r?.code||"ENOTDIR")),e(r)})},Lm=(t,e,r)=>{t=Z(t);let s=e.umask??18,a=e.mode|448,c=(a&s)!==0,f=e.uid,l=e.gid,x=typeof f=="number"&&typeof l=="number"&&(f!==e.processUid||l!==e.processGid),h=e.preserve,m=e.unlink,E=Z(e.cwd),C=(y,v)=>{y?r(y):v&&x?zf(v,f,l,I=>C(I)):c?Xe.chmod(t,a,r):r()};if(t===E)return Pm(t,C);if(h)return Om.mkdir(t,{mode:a,recursive:!0}).then(y=>C(null,y??void 0),C);let _=Z(Is.relative(E,t)).split("/");Ga(E,_,a,m,E,void 0,C)},Ga=(t,e,r,s,a,c,f)=>{if(e.length===0)return f(null,c);let l=e.shift(),x=Z(Is.resolve(t+"/"+l));Xe.mkdir(x,r,qf(x,e,r,s,a,c,f))},qf=(t,e,r,s,a,c,f)=>l=>{l?Xe.lstat(t,(x,h)=>{if(x)x.path=x.path&&Z(x.path),f(x);else if(h.isDirectory())Ga(t,e,r,s,a,c,f);else if(s)Xe.unlink(t,m=>{if(m)return f(m);Xe.mkdir(t,r,qf(t,e,r,s,a,c,f))});else{if(h.isSymbolicLink())return f(new Os(t,t+"/"+e.join("/")));f(l)}}):(c=c||t,Ga(t,e,r,s,a,c,f))},Nm=t=>{let e=!1,r;try{e=Xe.statSync(t).isDirectory()}catch(s){r=s?.code}finally{if(!e)throw new Uf(t,r??"ENOTDIR")}},Mm=(t,e)=>{t=Z(t);let r=e.umask??18,s=e.mode|448,a=(s&r)!==0,c=e.uid,f=e.gid,l=typeof c=="number"&&typeof f=="number"&&(c!==e.processUid||f!==e.processGid),x=e.preserve,h=e.unlink,m=Z(e.cwd),E=y=>{y&&l&&Ff(y,c,f),a&&Xe.chmodSync(t,s)};if(t===m)return Nm(m),E();if(x)return E(Xe.mkdirSync(t,{mode:s,recursive:!0})??void 0);let C=Z(Is.relative(m,t)).split("/"),_;for(let y=C.shift(),v=m;y&&(v+="/"+y);y=C.shift()){v=Z(Is.resolve(v));try{Xe.mkdirSync(v,s),_=_||v}catch{let I=Xe.lstatSync(v);if(I.isDirectory())continue;if(h){Xe.unlinkSync(v),Xe.mkdirSync(v,s),_=_||v;continue}else if(I.isSymbolicLink())return new Os(v,v+"/"+C.join("/"))}}return E(_)},Ia=Object.create(null),tf=1e4,rr=new Set,Bm=t=>{rr.has(t)?rr.delete(t):Ia[t]=t.normalize("NFD").toLocaleLowerCase("en").toLocaleUpperCase("en"),rr.add(t);let e=Ia[t],r=rr.size-tf;if(r>tf/10){for(let s of rr)if(rr.delete(s),delete Ia[s],--r<=0)break}return e},zm=process.env.TESTING_TAR_FAKE_PLATFORM||process.platform,Fm=zm==="win32",Um=t=>t.split("/").slice(0,-1).reduce((e,r)=>{let s=e.at(-1);return s!==void 0&&(r=Hf(s,r)),e.push(r||"/"),e},[]),qm=class{#e=new Map;#n=new Map;#r=new Set;reserve(t,e){t=Fm?["win32 parallelization disabled"]:t.map(s=>Qr(Hf(Bm(s))));let r=new Set(t.map(s=>Um(s)).reduce((s,a)=>s.concat(a)));this.#n.set(e,{dirs:r,paths:t});for(let s of t){let a=this.#e.get(s);a?a.push(e):this.#e.set(s,[e])}for(let s of r){let a=this.#e.get(s);if(!a)this.#e.set(s,[new Set([e])]);else{let c=a.at(-1);c instanceof Set?c.add(e):a.push(new Set([e]))}}return this.#i(e)}#s(t){let e=this.#n.get(t);if(!e)throw new Error("function does not have any path reservations");return{paths:e.paths.map(r=>this.#e.get(r)),dirs:[...e.dirs].map(r=>this.#e.get(r))}}check(t){let{paths:e,dirs:r}=this.#s(t);return e.every(s=>s&&s[0]===t)&&r.every(s=>s&&s[0]instanceof Set&&s[0].has(t))}#i(t){return this.#r.has(t)||!this.check(t)?!1:(this.#r.add(t),t(()=>this.#t(t)),!0)}#t(t){if(!this.#r.has(t))return!1;let e=this.#n.get(t);if(!e)throw new Error("invalid reservation");let{paths:r,dirs:s}=e,a=new Set;for(let c of r){let f=this.#e.get(c);if(!f||f?.[0]!==t)continue;let l=f[1];if(!l){this.#e.delete(c);continue}if(f.shift(),typeof l=="function")a.add(l);else for(let x of l)a.add(x)}for(let c of s){let f=this.#e.get(c),l=f?.[0];if(!(!f||!(l instanceof Set)))if(l.size===1&&f.length===1){this.#e.delete(c);continue}else if(l.size===1){f.shift();let x=f[0];typeof x=="function"&&a.add(x)}else l.delete(t)}return this.#r.delete(t),a.forEach(c=>this.#i(c)),!0}},Hm=()=>process.umask(),nf=Symbol("onEntry"),Ka=Symbol("checkFs"),rf=Symbol("checkFs2"),Wa=Symbol("isReusable"),rt=Symbol("makeFs"),$a=Symbol("file"),Va=Symbol("directory"),ys=Symbol("link"),sf=Symbol("symlink"),of=Symbol("hardlink"),Yr=Symbol("ensureNoSymlink"),af=Symbol("unsupported"),cf=Symbol("checkPath"),Aa=Symbol("stripAbsolutePath"),dn=Symbol("mkdir"),Re=Symbol("onError"),ds=Symbol("pending"),df=Symbol("pend"),ir=Symbol("unpend"),Ca=Symbol("ended"),Ta=Symbol("maybeClose"),Ja=Symbol("skip"),ti=Symbol("doChown"),ni=Symbol("uid"),ri=Symbol("gid"),ii=Symbol("checkedCwd"),jm=process.env.TESTING_TAR_FAKE_PLATFORM||process.platform,si=jm==="win32",Gm=1024,Km=(t,e)=>{if(!si)return X.unlink(t,e);let r=t+".DELETE."+Rf(16).toString("hex");X.rename(t,r,s=>{if(s)return e(s);X.unlink(r,e)})},Wm=t=>{if(!si)return X.unlinkSync(t);let e=t+".DELETE."+Rf(16).toString("hex");X.renameSync(t,e),X.unlinkSync(e)},ff=(t,e,r)=>t!==void 0&&t===t>>>0?t:e!==void 0&&e===e>>>0?e:r,sc=class extends oi{[Ca]=!1;[ii]=!1;[ds]=0;reservations=new qm;transform;writable=!0;readable=!1;uid;gid;setOwner;preserveOwner;processGid;processUid;maxDepth;forceChown;win32;newer;keep;noMtime;preservePaths;unlink;cwd;strip;processUmask;umask;dmode;fmode;chmod;constructor(t={}){if(t.ondone=()=>{this[Ca]=!0,this[Ta]()},super(t),this.transform=t.transform,this.chmod=!!t.chmod,typeof t.uid=="number"||typeof t.gid=="number"){if(typeof t.uid!="number"||typeof t.gid!="number")throw new TypeError("cannot set owner without number uid and gid");if(t.preserveOwner)throw new TypeError("cannot preserve owner in archive and also set owner explicitly");this.uid=t.uid,this.gid=t.gid,this.setOwner=!0}else this.uid=void 0,this.gid=void 0,this.setOwner=!1;this.preserveOwner=t.preserveOwner===void 0&&typeof t.uid!="number"?!!(process.getuid&&process.getuid()===0):!!t.preserveOwner,this.processUid=(this.preserveOwner||this.setOwner)&&process.getuid?process.getuid():void 0,this.processGid=(this.preserveOwner||this.setOwner)&&process.getgid?process.getgid():void 0,this.maxDepth=typeof t.maxDepth=="number"?t.maxDepth:Gm,this.forceChown=t.forceChown===!0,this.win32=!!t.win32||si,this.newer=!!t.newer,this.keep=!!t.keep,this.noMtime=!!t.noMtime,this.preservePaths=!!t.preservePaths,this.unlink=!!t.unlink,this.cwd=Z(Se.resolve(t.cwd||process.cwd())),this.strip=Number(t.strip)||0,this.processUmask=this.chmod?typeof t.processUmask=="number"?t.processUmask:Hm():0,this.umask=typeof t.umask=="number"?t.umask:this.processUmask,this.dmode=t.dmode||511&~this.umask,this.fmode=t.fmode||438&~this.umask,this.on("entry",e=>this[nf](e))}warn(t,e,r={}){return(t==="TAR_BAD_ARCHIVE"||t==="TAR_ABORT")&&(r.recoverable=!1),super.warn(t,e,r)}[Ta](){this[Ca]&&this[ds]===0&&(this.emit("prefinish"),this.emit("finish"),this.emit("end"))}[Aa](t,e){let r=t[e],{type:s}=t;if(!r||this.preservePaths)return!0;let[a,c]=tc(r),f=c.replaceAll(/\\/g,"/").split("/");if(f.includes("..")||si&&/^[a-z]:\.\.$/i.test(f[0]??"")){if(e==="path"||s==="Link")return this.warn("TAR_ENTRY_ERROR",`${e} contains '..'`,{entry:t,[e]:r}),!1;let l=Se.posix.dirname(t.path),x=Se.posix.normalize(Se.posix.join(l,f.join("/")));if(x.startsWith("../")||x==="..")return this.warn("TAR_ENTRY_ERROR",`${e} escapes extraction directory`,{entry:t,[e]:r}),!1}return a&&(t[e]=String(c),this.warn("TAR_ENTRY_INFO",`stripping ${a} from absolute ${e}`,{entry:t,[e]:r})),!0}[cf](t){let e=Z(t.path),r=e.split("/");if(this.strip){if(r.length<this.strip)return!1;if(t.type==="Link"){let s=Z(String(t.linkpath)).split("/");if(s.length>=this.strip)t.linkpath=s.slice(this.strip).join("/");else return!1}r.splice(0,this.strip),t.path=r.join("/")}if(isFinite(this.maxDepth)&&r.length>this.maxDepth)return this.warn("TAR_ENTRY_ERROR","path excessively deep",{entry:t,path:e,depth:r.length,maxDepth:this.maxDepth}),!1;if(!this[Aa](t,"path")||!this[Aa](t,"linkpath"))return!1;if(t.absolute=Se.isAbsolute(t.path)?Z(Se.resolve(t.path)):Z(Se.resolve(this.cwd,t.path)),!this.preservePaths&&typeof t.absolute=="string"&&t.absolute.indexOf(this.cwd+"/")!==0&&t.absolute!==this.cwd)return this.warn("TAR_ENTRY_ERROR","path escaped extraction target",{entry:t,path:Z(t.path),resolvedPath:t.absolute,cwd:this.cwd}),!1;if(t.absolute===this.cwd&&t.type!=="Directory"&&t.type!=="GNUDumpDir")return!1;if(this.win32){let{root:s}=Se.win32.parse(String(t.absolute));t.absolute=s+jd(String(t.absolute).slice(s.length));let{root:a}=Se.win32.parse(t.path);t.path=a+jd(t.path.slice(a.length))}return!0}[nf](t){if(!this[cf](t))return t.resume();switch(Im.equal(typeof t.absolute,"string"),t.type){case"Directory":case"GNUDumpDir":t.mode&&(t.mode=t.mode|448);case"File":case"OldFile":case"ContiguousFile":case"Link":case"SymbolicLink":return this[Ka](t);default:return this[af](t)}}[Re](t,e){t.name==="CwdError"?this.emit("error",t):(this.warn("TAR_ENTRY_ERROR",t,{entry:e}),this[ir](),e.resume())}[dn](t,e,r){Lm(Z(t),{uid:this.uid,gid:this.gid,processUid:this.processUid,processGid:this.processGid,umask:this.processUmask,preserve:this.preservePaths,unlink:this.unlink,cwd:this.cwd,mode:e},r)}[ti](t){return this.forceChown||this.preserveOwner&&(typeof t.uid=="number"&&t.uid!==this.processUid||typeof t.gid=="number"&&t.gid!==this.processGid)||typeof this.uid=="number"&&this.uid!==this.processUid||typeof this.gid=="number"&&this.gid!==this.processGid}[ni](t){return ff(this.uid,t.uid,this.processUid)}[ri](t){return ff(this.gid,t.gid,this.processGid)}[$a](t,e){let r=typeof t.mode=="number"?t.mode&4095:this.fmode,s=new As(String(t.absolute),{flags:Bf(t.size),mode:r,autoClose:!1});s.on("error",l=>{s.fd&&X.close(s.fd,()=>{}),s.write=()=>!0,this[Re](l,t),e()});let a=1,c=l=>{if(l){s.fd&&X.close(s.fd,()=>{}),this[Re](l,t),e();return}--a===0&&s.fd!==void 0&&X.close(s.fd,x=>{x?this[Re](x,t):this[ir](),e()})};s.on("finish",()=>{let l=String(t.absolute),x=s.fd;if(typeof x=="number"&&t.mtime&&!this.noMtime){a++;let h=t.atime||new Date,m=t.mtime;X.futimes(x,h,m,E=>E?X.utimes(l,h,m,C=>c(C&&E)):c())}if(typeof x=="number"&&this[ti](t)){a++;let h=this[ni](t),m=this[ri](t);typeof h=="number"&&typeof m=="number"&&X.fchown(x,h,m,E=>E?X.chown(l,h,m,C=>c(C&&E)):c())}c()});let f=this.transform&&this.transform(t)||t;f!==t&&(f.on("error",l=>{this[Re](l,t),e()}),t.pipe(f)),f.pipe(s)}[Va](t,e){let r=typeof t.mode=="number"?t.mode&4095:this.dmode;this[dn](String(t.absolute),r,s=>{if(s){this[Re](s,t),e();return}let a=1,c=()=>{--a===0&&(e(),this[ir](),t.resume())};t.mtime&&!this.noMtime&&(a++,X.utimes(String(t.absolute),t.atime||new Date,t.mtime,c)),this[ti](t)&&(a++,X.chown(String(t.absolute),Number(this[ni](t)),Number(this[ri](t)),c)),c()})}[af](t){t.unsupported=!0,this.warn("TAR_ENTRY_UNSUPPORTED",`unsupported entry type: ${t.type}`,{entry:t}),t.resume()}[sf](t,e){let r=Z(Se.relative(this.cwd,Se.resolve(Se.dirname(String(t.absolute)),String(t.linkpath)))).split("/");this[Yr](t,this.cwd,r,()=>this[ys](t,String(t.linkpath),"symlink",e),s=>{this[Re](s,t),e()})}[of](t,e){let r=Z(Se.resolve(this.cwd,String(t.linkpath))),s=Z(String(t.linkpath)).split("/");this[Yr](t,this.cwd,s,()=>this[ys](t,r,"link",e),a=>{this[Re](a,t),e()})}[Yr](t,e,r,s,a){let c=r.shift();if(this.preservePaths||c===void 0)return s();let f=Se.resolve(e,c);X.lstat(f,(l,x)=>{if(l)return s();if(x?.isSymbolicLink())return a(new Os(f,Se.resolve(f,r.join("/"))));this[Yr](t,f,r,s,a)})}[df](){this[ds]++}[ir](){this[ds]--,this[Ta]()}[Ja](t){this[ir](),t.resume()}[Wa](t,e){return t.type==="File"&&!this.unlink&&e.isFile()&&e.nlink<=1&&!si}[Ka](t){this[df]();let e=[t.path];t.linkpath&&e.push(t.linkpath),this.reservations.reserve(e,r=>this[rf](t,r))}[rf](t,e){let r=f=>{e(f)},s=()=>{this[dn](this.cwd,this.dmode,f=>{if(f){this[Re](f,t),r();return}this[ii]=!0,a()})},a=()=>{if(t.absolute!==this.cwd){let f=Z(Se.dirname(String(t.absolute)));if(f!==this.cwd)return this[dn](f,this.dmode,l=>{if(l){this[Re](l,t),r();return}c()})}c()},c=()=>{X.lstat(String(t.absolute),(f,l)=>{if(l&&(this.keep||this.newer&&l.mtime>(t.mtime??l.mtime))){this[Ja](t),r();return}if(f||this[Wa](t,l))return this[rt](null,t,r);if(l.isDirectory()){if(t.type==="Directory"){let x=this.chmod&&t.mode&&(l.mode&4095)!==t.mode,h=m=>this[rt](m??null,t,r);return x?X.chmod(String(t.absolute),Number(t.mode),h):h()}if(t.absolute!==this.cwd)return X.rmdir(String(t.absolute),x=>this[rt](x??null,t,r))}if(t.absolute===this.cwd)return this[rt](null,t,r);Km(String(t.absolute),x=>this[rt](x??null,t,r))})};this[ii]?a():s()}[rt](t,e,r){if(t){this[Re](t,e),r();return}switch(e.type){case"File":case"OldFile":case"ContiguousFile":return this[$a](e,r);case"Link":return this[of](e,r);case"SymbolicLink":return this[sf](e,r);case"Directory":case"GNUDumpDir":return this[Va](e,r)}}[ys](t,e,r,s){X[r](e,String(t.absolute),a=>{a?this[Re](a,t):(this[ir](),t.resume()),s()})}},Jr=t=>{try{return[null,t()]}catch(e){return[e,null]}},jf=class extends sc{sync=!0;[rt](t,e){return super[rt](t,e,()=>{})}[Ka](t){if(!this[ii]){let a=this[dn](this.cwd,this.dmode);if(a)return this[Re](a,t);this[ii]=!0}if(t.absolute!==this.cwd){let a=Z(Se.dirname(String(t.absolute)));if(a!==this.cwd){let c=this[dn](a,this.dmode);if(c)return this[Re](c,t)}}let[e,r]=Jr(()=>X.lstatSync(String(t.absolute)));if(r&&(this.keep||this.newer&&r.mtime>(t.mtime??r.mtime)))return this[Ja](t);if(e||this[Wa](t,r))return this[rt](null,t);if(r.isDirectory()){if(t.type==="Directory"){let c=this.chmod&&t.mode&&(r.mode&4095)!==t.mode,[f]=c?Jr(()=>{X.chmodSync(String(t.absolute),Number(t.mode))}):[];return this[rt](f,t)}let[a]=Jr(()=>X.rmdirSync(String(t.absolute)));this[rt](a,t)}let[s]=t.absolute===this.cwd?[]:Jr(()=>Wm(String(t.absolute)));this[rt](s,t)}[$a](t,e){let r=typeof t.mode=="number"?t.mode&4095:this.fmode,s=f=>{let l;try{X.closeSync(a)}catch(x){l=x}(f||l)&&this[Re](f||l,t),e()},a;try{a=X.openSync(String(t.absolute),Bf(t.size),r)}catch(f){return s(f)}let c=this.transform&&this.transform(t)||t;c!==t&&(c.on("error",f=>this[Re](f,t)),t.pipe(c)),c.on("data",f=>{try{X.writeSync(a,f,0,f.length)}catch(l){s(l)}}),c.on("end",()=>{let f=null;if(t.mtime&&!this.noMtime){let l=t.atime||new Date,x=t.mtime;try{X.futimesSync(a,l,x)}catch(h){try{X.utimesSync(String(t.absolute),l,x)}catch{f=h}}}if(this[ti](t)){let l=this[ni](t),x=this[ri](t);try{X.fchownSync(a,Number(l),Number(x))}catch(h){try{X.chownSync(String(t.absolute),Number(l),Number(x))}catch{f=f||h}}}s(f)})}[Va](t,e){let r=typeof t.mode=="number"?t.mode&4095:this.dmode,s=this[dn](String(t.absolute),r);if(s){this[Re](s,t),e();return}if(t.mtime&&!this.noMtime)try{X.utimesSync(String(t.absolute),t.atime||new Date,t.mtime)}catch{}if(this[ti](t))try{X.chownSync(String(t.absolute),Number(this[ni](t)),Number(this[ri](t)))}catch{}e(),t.resume()}[dn](t,e){try{return Mm(Z(t),{uid:this.uid,gid:this.gid,processUid:this.processUid,processGid:this.processGid,umask:this.processUmask,preserve:this.preservePaths,unlink:this.unlink,cwd:this.cwd,mode:e})}catch(r){return r}}[Yr](t,e,r,s,a){if(this.preservePaths||r.length===0)return s();let c=e;for(let f of r){c=Se.resolve(c,f);let[l,x]=Jr(()=>X.lstatSync(c));if(l)return s();if(x.isSymbolicLink())return a(new Os(c,Se.resolve(e,r.join("/"))))}s()}[ys](t,e,r,s){let a=`${r}Sync`;try{X[a](e,String(t.absolute)),s(),t.resume()}catch(c){return this[Re](c,t)}}},$m=t=>{let e=new jf(t),r=t.file,s=Df.statSync(r),a=t.maxReadSize||16*1024*1024;new xg(r,{readSize:a,size:s.size}).pipe(e)},Vm=(t,e)=>{let r=new sc(t),s=t.maxReadSize||16*1024*1024,a=t.file;return new Promise((c,f)=>{r.on("error",f),r.on("close",c),Df.stat(a,(l,x)=>{if(l)f(l);else{let h=new Ya(a,{readSize:s,size:x.size});h.on("error",f),h.pipe(r)}})})},Gf=ai($m,Vm,t=>new jf(t),t=>new sc(t),(t,e)=>{e?.length&&bf(t,e)}),Jm=(t,e)=>{let r=new ic(t),s=!0,a,c;try{try{a=Ye.openSync(t.file,"r+")}catch(x){if(x?.code==="ENOENT")a=Ye.openSync(t.file,"w+");else throw x}let f=Ye.fstatSync(a),l=Buffer.alloc(512);e:for(c=0;c<f.size;c+=512){for(let m=0,E=0;m<512;m+=E){if(E=Ye.readSync(a,l,m,l.length-m,c+m),c===0&&l[0]===31&&l[1]===139)throw new Error("cannot append to compressed archives");if(!E)break e}let x=new Pn(l);if(!x.cksumValid)break;let h=512*Math.ceil((x.size||0)/512);if(c+h+512>f.size)break;c+=h,t.mtimeCache&&x.mtime&&t.mtimeCache.set(String(x.path),x.mtime)}s=!1,Zm(t,r,c,a,e)}finally{if(s)try{Ye.closeSync(a)}catch{}}},Zm=(t,e,r,s,a)=>{let c=new xf(t.file,{fd:s,start:r});e.pipe(c),Xm(e,a)},Ym=(t,e)=>{e=Array.from(e);let r=new Rs(t),s=(a,c,f)=>{let l=(C,_)=>{C?Ye.close(a,y=>f(C)):f(null,_)},x=0;if(c===0)return l(null,0);let h=0,m=Buffer.alloc(512),E=(C,_)=>{if(C||_===void 0)return l(C);if(h+=_,h<512&&_)return Ye.read(a,m,h,m.length-h,x+h,E);if(x===0&&m[0]===31&&m[1]===139)return l(new Error("cannot append to compressed archives"));if(h<512)return l(null,x);let y=new Pn(m);if(!y.cksumValid)return l(null,x);let v=512*Math.ceil((y.size??0)/512);if(x+v+512>c||(x+=v+512,x>=c))return l(null,x);t.mtimeCache&&y.mtime&&t.mtimeCache.set(String(y.path),y.mtime),h=0,Ye.read(a,m,0,512,x,E)};Ye.read(a,m,0,512,x,E)};return new Promise((a,c)=>{r.on("error",c);let f="r+",l=(x,h)=>{if(x&&x.code==="ENOENT"&&f==="r+")return f="w+",Ye.open(t.file,f,l);if(x||!h)return c(x);Ye.fstat(h,(m,E)=>{if(m)return Ye.close(h,()=>c(m));s(h,E.size,(C,_)=>{if(C)return c(C);let y=new As(t.file,{fd:h,start:_});r.pipe(y),y.on("error",c),y.on("close",a),Qm(r,e)})})};Ye.open(t.file,f,l)})},Xm=(t,e)=>{e.forEach(r=>{r.charAt(0)==="@"?ur({file:Kf.resolve(t.cwd,r.slice(1)),sync:!0,noResume:!0,onReadEntry:s=>t.add(s)}):t.add(r)}),t.end()},Qm=async(t,e)=>{for(let r of e)r.charAt(0)==="@"?await ur({file:Kf.resolve(String(t.cwd),r.slice(1)),noResume:!0,onReadEntry:s=>t.add(s)}):t.add(r);t.end()},Zr=ai(Jm,Ym,()=>{throw new TypeError("file is required")},()=>{throw new TypeError("file is required")},(t,e)=>{if(!Eg(t))throw new TypeError("file is required");if(t.gzip||t.brotli||t.zstd||t.file.endsWith(".br")||t.file.endsWith(".tbr"))throw new TypeError("cannot append to compressed archives");if(!e?.length)throw new TypeError("no paths specified to add/replace")}),qS=ai(Zr.syncFile,Zr.asyncFile,Zr.syncNoFile,Zr.asyncNoFile,(t,e=[])=>{Zr.validate?.(t,e),ew(t)}),ew=t=>{let e=t.filter;t.mtimeCache||(t.mtimeCache=new Map),t.filter=e?(r,s)=>e(r,s)&&!((t.mtimeCache?.get(r)??s.mtime??0)>(s.mtime??0)):(r,s)=>!((t.mtimeCache?.get(r)??s.mtime??0)>(s.mtime??0))};Yt();var St={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 ci(t){return t?.cozeDeployType==="cloud"?"cloud":"local"}function Wf(t){let e=t?.cozeAccountId?.trim();if(!(!e||e==="0"))return e}function $f(t){let e=t?.cozeGroupId?.trim();if(!(!e||e==="0"))return e}function Vf(t){let{_meta:e,...r}=t;return{stripped:r,meta:e}}function xr(t){if(!t?.cozeAgentId)throw new Error("missing _meta.cozeAgentId");return t.cozeAgentId}var D=class extends Error{code;retriable;cause;constructor(e,r,s){super(r),this.name="BridgeError",this.code=e,this.retriable=s?.retriable??!1,s?.cause!==void 0&&(this.cause=s.cause)}};ee();Me();function zt(t,e){if(ci(t)!=="cloud")throw new D("OPERATION_NOT_ALLOWED_FOR_LOCAL",`${e} is not allowed for local agent`)}function Ps(t){return t.startsWith("http://")||t.startsWith("https://")}function Ls(t){return t.endsWith("/")?t.slice(0,-1):t}ee();var Ns="1008033",Jf="1289";var Zf="pbbp2",Yf="https://www.coze.cn",Xf="/api/coze_claw/resource/get_frontier_key",nw="https://www.coze.cn",rw="wss://frontier.coze.cn";function Ms(t){return t??process.env.COZE_BRIDGE_HANDSHAKE_URL??nw}function Qf(t){return t??process.env.COZE_BRIDGE_FRONTIER_URL??rw}function hr(t){let e={},r=t?.ttEnv??process.env.COZE_BRIDGE_TT_ENV,s=t?.usePpe??process.env.COZE_BRIDGE_USE_PPE;return r&&(e["x-tt-env"]=r),s&&(e["x-use-ppe"]=s),e}function fi(t){return t?t.startsWith("boe_")?{ttEnv:t}:{ttEnv:t,usePpe:"1"}:{}}var di=H("handshake");async function oc(t){let e=Ms(t.endpoint),r=t.timeoutMs??1e4,s=`${Ls(e)}${Xf}?aid=${encodeURIComponent(Ns)}`,a={Authorization:`Bearer ${t.privatecode}`,Accept:"application/json",...hr(t.ppeOverride)},c=new AbortController,f=setTimeout(()=>c.abort(),r);di.info("frontier key handshake",{base:e});try{let l=await fetch(s,{method:"GET",headers:a,signal:c.signal}),x=l.headers.get("x-tt-logid")??"",h=l.headers.get("x-tt-trace-id")??"";if(!l.ok){let y=await l.text().catch(()=>"");throw new D("UPSTREAM_HANDSHAKE_FAILED",`handshake HTTP ${l.status} logid=${x}: ${y.slice(0,200)}`)}let m=await l.json();if(m.code!==void 0&&m.code!==0)throw new D("UPSTREAM_HANDSHAKE_FAILED",`handshake code=${m.code} msg=${m.msg??"-"} logid=${x}`);let E=m.data??{},C=typeof E.access_key=="string"&&E.access_key||typeof E.accessKey=="string"&&E.accessKey||void 0,_=typeof E.device_id=="string"&&E.device_id||typeof E.deviceId=="string"&&E.deviceId||void 0;if(!C||!_){let y=JSON.stringify(m).slice(0,500);throw new D("UPSTREAM_HANDSHAKE_FAILED",`handshake response missing access_key/device_id (also tried camelCase) logid=${x}: ${y}`)}return di.info("handshake ok",{remoteDeviceId:_,logid:x,traceId:h}),{accessKey:C,deviceId:_}}catch(l){if(l instanceof D)throw di.error("handshake failed (bridge error)",{base:e,message:l.message,code:l.code}),l;if(l.name==="AbortError")throw di.warn("handshake timeout",{base:e,timeoutMs:r}),new D("UPSTREAM_HANDSHAKE_FAILED",`handshake timeout (${r}ms)`,{cause:l});let x=l.cause;throw di.error("handshake error",{base:e,message:l instanceof Error?l.message:String(l),errno:x?.code,syscall:x?.syscall,cause:String(l).slice(0,300)}),new D("UPSTREAM_HANDSHAKE_FAILED",String(l),{cause:l})}finally{clearTimeout(f)}}var ac=process.env.COZE_BRIDGE_LLM_GATEWAY_URL?.trim()||"https://llm-gateway.coze.cn",vt="auto";function el(t){return{model:t.model??vt,...t.modelToken?{modelToken:t.modelToken}:{}}}function tl(t){return!t||t===vt}function nl(t){let e={};return t.modelToken?(e.ANTHROPIC_BASE_URL=ac,e.ANTHROPIC_AUTH_TOKEN=t.modelToken,e.ANTHROPIC_MODEL=t.model||vt,t.modelInfo?.contextWindow&&(e.CLAUDE_CODE_MAX_CONTEXT_TOKENS=String(t.modelInfo.contextWindow))):tl(t.model)||(e.ANTHROPIC_MODEL=t.model),e}function rl(t){let e=[];return t.modelToken?e.push("-c",`model="${t.model||vt}"`):tl(t.model)||e.push("-c",`model="${t.model}"`),t.modelToken&&(e.push("-c",'model_providers.coze.name="coze"'),e.push("-c",`model_providers.coze.base_url="${ac}/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"'),t.modelInfo?.contextWindow&&e.push("-c",`model_context_window=${t.modelInfo.contextWindow}`)),e}function il(t){return t.modelToken?{OPENAI_API_KEY:t.modelToken}:{}}function cc(t,e){let{ttEnv:r,usePpe:s}=fi(t),a={};return r&&(a["x-tt-env"]=r),s&&(a["x-use-ppe"]=s),e&&(a["x-mock-scenario"]=e),a}function sl(t,e,r){if(!t.modelToken)return{};let s=cc(e,r);return Object.keys(s).length===0?{}:{ANTHROPIC_CUSTOM_HEADERS:Object.entries(s).map(([c,f])=>`${c}:${f}`).join(`
83
- `)}}function dc(t){return`coze-session-${t.replace(/[^A-Za-z0-9_-]+/g,"-")}`}function ol(t,e,r){if(!t.modelToken)return null;let s=t.model||vt,a=cc(e,r),c=["text"];t.modelInfo?.capabilities?.image===!0&&c.push("image");let f={baseUrl:`${ac}/v1`,api:"openai-completions",apiKey:t.modelToken,models:[{id:s,name:s,reasoning:!1,input:c,cost:{input:0,output:0,cacheRead:0,cacheWrite:0},contextWindow:t.modelInfo?.contextWindow??128e3,maxTokens:8192,api:"openai-completions"}]};return Object.keys(a).length>0&&(f.headers=a),f}function al(t,e,r){if(!t.modelToken)return[];let s=cc(e,r),a=[];for(let[c,f]of Object.entries(s))a.push("-c",`model_providers.coze.http_headers.${c}="${f}"`);return a}var ke=H("agent-handlers"),cl=5*1024*1024,dw=1,fw=6,lw=new Set(["node_modules",".git",".coze","dist","build",".next"]),Bs=class{constructor(e){this.opts=e}opts;async listSkills(e){zt(e._meta,"_agent/listSkills");let r=xr(e._meta),s=await this.loadAgentCfg(r),a=s?.workspace??kt(r).workspace,c=s?.skills??[],f=[];for(let l of c){let x=It(a,l.relPath,"SKILL.md");await ow(x).then(m=>m.isFile()).catch(()=>!1)&&f.push(gw(l))}return{skills:f}}async addSkills(e){zt(e._meta,"_agent/addSkills");let r=xr(e._meta),s=await this.requireAgentCfg(r),a=e.skills??[],c=[...s.skills??[]],f=new Map(c.map((x,h)=>[x.skillId,h])),l=[];for(let x of a){let h=await gc({agentId:r,workspace:s.workspace,framework:s.framework,skill:x});mc(c,f,h),l.push(x)}return await Hi(r,c),this.reloadAgentSessions(r,"skills-added"),{installedSkills:l}}async removeSkills(e){zt(e._meta,"_agent/removeSkills");let r=xr(e._meta),s=await this.requireAgentCfg(r),a=new Set(e.skillIds??[]),c=s.skills??[],f=[];for(let l of c){if(!a.has(l.skillId)){f.push(l);continue}let x=It(s.workspace,l.relPath);await sw(x,{recursive:!0,force:!0}),ke.info("skill removed",{agentId:r,skillId:l.skillId,relPath:l.relPath})}return await Hi(r,f),this.reloadAgentSessions(r,"skills-removed"),{ok:!0}}reloadAgentSessionsPublic(e,r){this.reloadAgentSessions(e,r)}reloadAgentSessions(e,r){let s=this.opts.agents.get(e);if(s)for(let[a,c]of s.sessions){if(!c.downstream)continue;let f=c.acpSessionId;if(f&&s.activeTriggers.has(f)||this.isRuntimePendingPermission(c)){c.reloadAfterTurn=!0,ke.info("downstream busy, scheduling reload after turn",{reason:r,agentId:e,framework:s.framework,cloudId:a,acpId:f});continue}let x=c.downstream;c.downstream=void 0,ke.info("killing downstream for workspace reload (idle)",{reason:r,agentId:e,framework:s.framework,cloudId:a,acpId:f}),x.stop(r).catch(h=>ke.warn("downstream stop failed during reload (ignored)",{reason:r,agentId:e,cloudId:a,err:String(h)}))}}isRuntimePendingPermission(e){let r=this.opts.isRuntimePendingPermission;return!r||!e.downstream?!1:r(e.downstream)}async updateAgent(e){if(!e.cozeIdentity?.trim())return ke.info("_agent/update: empty cozeIdentity, noop",{agentId:e.agentId}),{ok:!0};let r=e.agentId,s=await Ue(r);if(!s)throw new D("AGENT_NOT_FOUND",`agent not found: ${r}`);if(s.cozeIdentity===e.cozeIdentity)return ke.info("_agent/update: cozeIdentity unchanged, noop",{agentId:r}),{ok:!0};try{await Zn(s.workspace,s.framework,e.cozeIdentity)}catch(a){throw ke.error("_agent/update: writeInstructionFile failed, aborting update",{agentId:r,framework:s.framework,workspace:s.workspace,err:String(a)}),new D("AGENT_PROTOCOL_ERROR",`failed to write instruction file for agent ${r}: ${String(a)}`,{cause:a})}return s.cozeIdentity=e.cozeIdentity,await Ve(s),ke.info("_agent/update: cozeIdentity rewritten",{agentId:r,framework:s.framework}),this.reloadAgentSessions(r,"identity-changed"),{ok:!0}}async disconnectAgent(e){let r=e.agentId;if(!r)throw new D("IPC_BAD_REQUEST","_agent/disconnect: missing agentId");let s=await Ue(r);return s?(s.disconnectedAt=Date.now(),s.disconnectReason=e.reason??"",await Ve(s),ke.info("agent disconnected",{agentId:r,reason:e.reason??"",force:e.force??!1}),this.opts.disposeAndMarkDisconnected&&await this.opts.disposeAndMarkDisconnected(r,e.reason??"disconnect"),{ok:!0}):(ke.warn("_agent/disconnect: agent not found, ignoring",{agentId:r}),{ok:!0})}async switchModel(e){if(zt(e._meta,"_agent/switchModel"),!e.agentId)throw new D("IPC_BAD_REQUEST","_agent/switchModel: missing agentId");let r=e.model?.trim()?e.model:vt,s=await Ue(e.agentId);if(!s)throw new D("AGENT_NOT_FOUND",`agent not found: ${e.agentId}`);s.model=r,e.modelInfo&&(s.modelInfo=e.modelInfo),await Ve(s),ke.info("_agent/switchModel: model persisted",{agentId:e.agentId,model:r,reason:e.reason??""});let a=this.opts.agents.get(e.agentId);if(!a)return ke.info("_agent/switchModel: agent not running, config persisted only",{agentId:e.agentId}),{ok:!0};a.model=r,e.modelInfo&&a.setModelInfo(e.modelInfo),this.opts.cleanupOpenclawProviders&&await this.opts.cleanupOpenclawProviders(a).catch(f=>ke.warn("cleanupOpenclawProviders before switchModel failed (ignored)",{agentId:e.agentId,err:String(f)}));let c=[];for(let[f,l]of a.allSessionQueues())c.push(l.enqueue(async()=>{let x=a.sessions.get(f);x?.downstream&&(await x.downstream.stop(`switchModel: ${r}`).catch(()=>{}),x.downstream=void 0)}));return await Promise.all(c),ke.info("_agent/switchModel: all session runtimes killed, next prompt will respawn",{agentId:e.agentId,model:r,cloudSessions:c.length}),{ok:!0}}async resetAgent(e){if(zt(e._meta,St.RESET),!e.agentId)throw new D("IPC_BAD_REQUEST",`${St.RESET}: missing agentId`);return await this.runDetailSync(e.agentId,St.RESET,e.reason),{ok:!0}}async repairAgent(e){if(zt(e._meta,St.REPAIR),!e.agentId)throw new D("IPC_BAD_REQUEST",`${St.REPAIR}: missing agentId`);let r=await this.loadAgentCfg(e.agentId);if(r&&r.framework!=="openclaw")throw new D("IPC_BAD_REQUEST",`${St.REPAIR} only allowed for openclaw, got ${r.framework}`);if(r&&this.opts.openclawRepair)try{await this.opts.openclawRepair(e.agentId,r.workspace)}catch(s){ke.warn("openclaw repair (delete+add) failed (ignored)",{agentId:e.agentId,reason:e.reason,err:String(s)})}return await this.runDetailSync(e.agentId,St.REPAIR,e.reason),{ok:!0}}async runDetailSync(e,r,s){if(!this.opts.detailSyncer){ke.warn("detailSyncer not wired, skipping sync",{method:r,agentId:e});return}try{await this.opts.detailSyncer(e)}catch(a){ke.warn("detail sync failed (ignored)",{method:r,agentId:e,reason:s,err:String(a)})}}async getFileTree(e){zt(e._meta,"_agent/getFileTree");let r=e._meta,s=xr(r),a=await this.resolveWorkspace(s),c=e.filePath??"",f=this.safeJoin(a,c),l=await fc(f).catch(()=>null);if(!l)throw new D("IPC_BAD_REQUEST",`path not found: ${c}`);if(l.isSymbolicLink())throw new D("IPC_BAD_REQUEST",`symlink not allowed: ${c}`);if(!await Nr(f,a))throw new D("IPC_BAD_REQUEST",`path escapes workspace: ${c}`);let x=Cw(e.depth);return l.isDirectory()?{tree:await Aw(a,f,c,x)}:{tree:[{name:Tw(c),path:pl(c||"."),isDir:!1,size:l.size,modifiedAt:Math.floor(l.mtimeMs)}]}}async getFileContent(e){zt(e._meta,"_agent/getFileContent");let r=xr(e._meta),s=await this.resolveWorkspace(r);if(!e.filePath)throw new D("IPC_BAD_REQUEST","filePath required");let a=this.safeJoin(s,e.filePath),c=await fc(a).catch(()=>null);if(!c||!c.isFile())throw new D("IPC_BAD_REQUEST",`not a file: ${e.filePath}`);if(c.isSymbolicLink())throw new D("IPC_BAD_REQUEST",`symlink not allowed: ${e.filePath}`);if(!await Nr(a,s))throw new D("IPC_BAD_REQUEST",`path escapes workspace: ${e.filePath}`);if(c.size>cl)throw new D("IPC_BAD_REQUEST",`file too large: ${c.size} bytes (max ${cl})`);let f=await dl(a);return f.includes(0)?{content:f.toString("base64"),encoding:"base64",size:c.size}:{content:f.toString("utf8"),encoding:"utf-8",size:c.size}}async resolveWorkspace(e){let r=this.opts.agents.get(e);return r?r.workspace:(await Ue(e).catch(()=>null))?.workspace??kt(e).workspace}safeJoin(e,r){let s=xc(e,r||"."),a=pc(e,s);if(a.startsWith("..")||a===".."||a.startsWith(`..${fl}`))throw new D("IPC_BAD_REQUEST",`path escapes workspace: ${r}`);return s}loadAgentCfg(e){return Ue(e)}async requireAgentCfg(e){let r=await this.loadAgentCfg(e);if(!r)throw new D("AGENT_NOT_FOUND",`no config for agent: ${e}`);return r}};function uw(t){let e=t.trim().replace(/[\x00-\x1f<>:"|?*/\\]+/g,"-").replace(/^[\s.-]+|[\s.-]+$/g,"").slice(0,64);if(!e||e==="."||e==="..")throw new D("IPC_BAD_REQUEST",`invalid skill name: ${t}`);if(/^(con|prn|aux|nul|com[1-9]|lpt[1-9])$/i.test(e))throw new D("IPC_BAD_REQUEST",`reserved windows filename: ${t}`);return e}function xw(t){return t==="claude-code"?It(".claude","skills"):It(".agents","skills")}var hw=3e4,pw=50*1024*1024,pr=3e4;async function gc(t){let{agentId:e,workspace:r,framework:s,skill:a}=t;if(!a.skillName)throw new D("IPC_BAD_REQUEST","skill missing skillName");let c=typeof a.content=="string"&&a.content.length>0,f=typeof a.downloadUrl=="string"&&a.downloadUrl.length>0;if(!c&&!f)throw new D("IPC_BAD_REQUEST",`skill ${a.skillId} missing both content and downloadUrl`);let l=uw(a.skillName),x=xw(s),h=It(x,l),m=It(r,h);if(await lc(m,{recursive:!0}),c){let C=Buffer.from(a.content,"utf8");li(C.length),await uc(It(m,"SKILL.md"),C,"utf8")}else{let C=await mw(a.downloadUrl);_w(C)?await Sw(C,m):yw(C)?await Ew(C,m):await uc(It(m,"SKILL.md"),C.toString("utf8"),"utf8")}let E={skillId:a.skillId,skillName:a.skillName,relPath:h,installedAt:Date.now(),...a.description?{description:a.description}:{},...a.icon?{icon:a.icon}:{},...a.version?{version:a.version}:{},...a.downloadUrl?{downloadUrl:a.downloadUrl}:{},...a.config?{config:a.config}:{},...a.builtin?{builtin:a.builtin}:{}};return ke.info("skill installed",{agentId:e,skillId:a.skillId,skillName:a.skillName,relPath:h,source:c?"content":"downloadUrl"}),E}function mc(t,e,r){let s=e.get(r.skillId);if(s!==void 0){t[s]=r;return}e.set(r.skillId,t.length),t.push(r)}function gw(t){return{skillId:t.skillId,skillName:t.skillName,...t.description?{description:t.description}:{},...t.icon?{icon:t.icon}:{},...t.version?{version:t.version}:{},...t.config?{config:t.config}:{},...t.builtin?{builtin:t.builtin}:{}}}async function mw(t){if(!t)throw new D("IPC_BAD_REQUEST","skill missing downloadUrl");if(t.startsWith("data:")){let e=Math.floor(t.length*3/4);li(e);let r=ww(t);return li(r.length),r}if(t.startsWith("file:")){let e=new URL(t).pathname,r=await dl(e);return li(r.length),r}if(Ps(t)){let e=new AbortController,r=setTimeout(()=>e.abort(),hw);try{let s=await fetch(t,{signal:e.signal});if(!s.ok)throw new D("IPC_BAD_REQUEST",`fetch skill failed HTTP ${s.status} ${t}`);let a=await s.arrayBuffer();return li(a.byteLength),Buffer.from(a)}finally{clearTimeout(r)}}throw new D("IPC_BAD_REQUEST",`unsupported downloadUrl scheme (\u8981 https/data/file): ${t.slice(0,80)}`)}function li(t){if(t>pw)throw new D("IPC_BAD_REQUEST",`skill too large: ${t} bytes`)}function ww(t){let e=/^data:([^,;]*)(;base64)?,(.*)$/s.exec(t);if(!e)throw new D("IPC_BAD_REQUEST","bad data URL");let r=!!e[2],s=e[3]??"";return r?Buffer.from(s,"base64"):Buffer.from(decodeURIComponent(s),"utf8")}function _w(t){return t.length>=2&&t[0]===31&&t[1]===139}function yw(t){if(t.length<4||t[0]!==80||t[1]!==75)return!1;let e=t[2],r=t[3];return e===3&&r===4||e===5&&r===6}function hc(t){return t==="__MACOSX"||t.startsWith("__MACOSX/")}async function Ew(t,e){let r,s;try{r=new xl.default(t),s=r.getEntries()}catch(f){throw new D("IPC_BAD_REQUEST",`zip parse failed: ${f.message}`,{cause:f})}for(let f of s){let l=f.entryName;if(!l||hc(l))continue;if(l.startsWith("/")||/^[A-Za-z]:[\\/]/.test(l))throw new D("IPC_BAD_REQUEST",`zip entry absolute path: ${l}`);if(l.split(/[/\\]/).some(h=>h===".."))throw new D("IPC_BAD_REQUEST",`zip entry contains '..' (traversal): ${l}`);let x=f.header.attr>>>16&61440;if(x!==0&&x!==32768&&x!==16384)throw new D("IPC_BAD_REQUEST",`zip entry kind 0x${x.toString(16)} not allowed (symlink/hardlink/special): ${l}`)}let a=bw(s),c=xc(e);for(let f of s){if(hc(f.entryName))continue;let l=f.entryName;if(a&&l.startsWith(a)&&(l=l.slice(a.length)),!l)continue;let x=xc(e,l),h=pc(c,x);if(h.startsWith("..")||h==="..")throw new D("IPC_BAD_REQUEST",`zip entry escapes destDir: ${l}`);if(f.isDirectory){await lc(x,{recursive:!0});continue}await lc(aw(x),{recursive:!0});let m;try{m=f.getData()}catch(E){throw new D("IPC_BAD_REQUEST",`zip entry getData failed (${f.entryName}): ${E.message}`,{cause:E})}await uc(x,m)}}function bw(t){let e;for(let r of t){let s=r.entryName;if(!s||hc(s))continue;let a=s.indexOf("/");if(a<=0)return;let c=s.slice(0,a+1);if(e===void 0)e=c;else if(e!==c)return}return e}async function Sw(t,e){await vw(t);let r=Gf({cwd:e,strip:1}),s=!1,a=setTimeout(()=>{s=!0,r.destroy(new D("IPC_BAD_REQUEST",`tar extract timeout (${pr}ms)`))},pr);try{await ul(ll.from(t),r)}catch(c){throw c instanceof D?c:s?new D("IPC_BAD_REQUEST",`tar extract timeout (${pr}ms)`):new D("IPC_BAD_REQUEST",`tar extract failed: ${c.message??String(c)}`,{cause:c})}finally{clearTimeout(a)}}async function vw(t){let e=[],r=ur({onReadEntry:c=>{let f=c.path,l=c.type;if(l!=="File"&&l!=="Directory"){e.push(`tar entry kind '${l}' not allowed (symlink/hardlink/special): ${f.slice(0,100)}`);return}if(f.startsWith("/")||f.startsWith("\\")||/^[a-zA-Z]:[\\/]/.test(f)){e.push(`tar entry absolute path: ${f}`);return}f.split(/[/\\]/).some(h=>h==="..")&&e.push(`tar entry contains '..': ${f}`)}}),s=!1,a=setTimeout(()=>{s=!0,r.destroy(new D("IPC_BAD_REQUEST",`tar list timeout (${pr}ms)`))},pr);try{await ul(ll.from(t),r)}catch(c){throw s?new D("IPC_BAD_REQUEST",`tar list timeout (${pr}ms)`):new D("IPC_BAD_REQUEST",`tar list failed: ${c.message??String(c)}`,{cause:c})}finally{clearTimeout(a)}if(e.length>0)throw new D("IPC_BAD_REQUEST",e[0]??"tar entry validation failed")}var Iw=5e3;async function Aw(t,e,r,s){return hl(t,e,r,s,{count:0})}async function hl(t,e,r,s,a){if(s<=0)return[];let c;try{c=await iw(e,{withFileTypes:!0})}catch{return[]}let f=[];for(let l of c){if(lw.has(l.name)||l.isSymbolicLink())continue;if(a.count>=Iw){f.push({name:"...",path:"...",isDir:!1,size:0,modifiedAt:0,hasMore:!0});break}let x=It(e,l.name),h=cw(It(r,l.name)),m=null;try{m=await fc(x)}catch{continue}if(m.isSymbolicLink())continue;a.count++;let E={name:l.name,path:pl(pc(t,x)),isDir:m.isDirectory(),size:m.size,modifiedAt:Math.floor(m.mtimeMs)};m.isDirectory()&&s>1&&(E.children=await hl(t,x,h,s-1,a)),f.push(E)}return f.sort((l,x)=>l.isDir!==x.isDir?l.isDir?-1:1:l.name.localeCompare(x.name)),f}function Cw(t){return!t||t<=0?dw:Math.min(t,fw)}function Tw(t){if(!t||t==="."||t==="/")return".";let e=t.split(/[/\\]/);return e[e.length-1]||"."}function pl(t){return t.split(fl).join("/")}ee();import{readFileSync as Xv}from"node:fs";import{dirname as e1,join as t1}from"node:path";import{fileURLToPath as r1}from"node:url";var gr="0.1.82";var un=H("agent-health-reporter"),Dw=1e4,ui=class{constructor(e){this.opts=e;this.intervalMs=e.intervalMs??Dw}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()}),un.info("heartbeat started",{intervalMs:this.intervalMs}),this.tick())}stop(){this.timer&&(clearInterval(this.timer),this.timer=null,this.unsubscribeRegister&&(this.unsubscribeRegister(),this.unsubscribeRegister=null),un.info("heartbeat stopped"))}async tick(){if(this.inFlight){un.debug("previous tick still in-flight, skip");return}let e=this.opts.getDeviceId();if(!e){un.debug("deviceId not available, skip tick (\u5C1A\u672A pair)");return}this.inFlight=!0;try{let r=[];for(let f of this.opts.core.agents.values()){let l=Rw(f);if(!l)continue;let x={agentId:f.agentId,status:l};f.patToken&&(x.patToken=f.patToken),f.accountId&&(x.accountId=f.accountId),r.push(x)}if(r.length===0)return;let s={agents:r,bridgeVersion:gr,_meta:{cozeDeviceId:e}},a;try{a=await this.opts.core.sendRequest("_agent/health",s,5e3)}catch(f){un.warn("heartbeat batch send failed",{count:r.length,err:String(f)})}let c=a?.authFailures;if(c&&c.length>0&&(un.warn("heartbeat received authFailures from cloud",{count:c.length,agentIds:c.map(f=>f.agentId)}),this.opts.onAuthFailures))try{await this.opts.onAuthFailures(c)}catch(f){un.warn("onAuthFailures callback failed (ignored)",{err:String(f)})}}finally{this.inFlight=!1}if(this.opts.onTickEnd)try{await this.opts.onTickEnd()}catch(r){un.warn("onTickEnd hook failed",{err:String(r)})}}};function Rw(t){return t.status==="error"?"error":t.activeTriggers.size>0?"busy":t.status==="ok"?"online":null}Yt();import{mkdir as yc,rm as d_}from"node:fs/promises";Zt();Zt();import{spawnSync as zw}from"node:child_process";function xi(t,e,r){return r===void 0?{jsonrpc:"2.0",id:t,method:e}:{jsonrpc:"2.0",id:t,method:e,params:r}}function hi(t,e){return e===void 0?{jsonrpc:"2.0",method:t}:{jsonrpc:"2.0",method:t,params:e}}function mr(t,e){return{jsonrpc:"2.0",id:t,result:e}}function xn(t,e){return{jsonrpc:"2.0",id:t,error:e}}var zs=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)}},Q={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,AGENT_FRAME_IDLE_TIMEOUT:-32016,MODEL_MODALITY_UNSUPPORTED:-32017};function gl(t){return"method"in t&&"id"in t&&t.id!==void 0}function ml(t){return"method"in t&&!("id"in t)}function Fs(t){return!("method"in t)&&"id"in t}var kw={AGENT_NOT_FOUND:Q.AGENT_NOT_FOUND,AGENT_BUSY:Q.AGENT_BUSY,AGENT_DISCONNECTED:Q.AGENT_DISCONNECTED,AGENT_TIMEOUT:Q.AGENT_TIMEOUT,AGENT_FRAME_IDLE_TIMEOUT:Q.AGENT_FRAME_IDLE_TIMEOUT,AGENT_SPAWN_FAILED:Q.AGENT_SPAWN_FAILED,AGENT_PROTOCOL_ERROR:Q.INTERNAL_ERROR,BRIDGE_CONFIG_INVALID:Q.INTERNAL_ERROR,BRIDGE_INTERNAL:Q.INTERNAL_ERROR,IPC_AUTH_FAILED:Q.INTERNAL_ERROR,IPC_BAD_REQUEST:Q.INVALID_REQUEST,MODEL_TOKEN_GEN_FAILED:Q.MODEL_TOKEN_GEN_FAILED,MODEL_MODALITY_UNSUPPORTED:Q.MODEL_MODALITY_UNSUPPORTED,OPERATION_NOT_ALLOWED_FOR_LOCAL:Q.OPERATION_NOT_ALLOWED_FOR_LOCAL,UPSTREAM_DISCONNECTED:Q.INTERNAL_ERROR,UPSTREAM_HANDSHAKE_FAILED:Q.INTERNAL_ERROR,PATH_OUTSIDE_WORKSPACE:Q.PATH_OUTSIDE_WORKSPACE,FILE_TOO_LARGE:Q.FILE_TOO_LARGE,UNSUPPORTED_MIME:Q.UNSUPPORTED_MIME,UPLOAD_FAILED:Q.UPLOAD_FAILED,UPSTREAM_NOT_READY:Q.UPSTREAM_NOT_READY,NPX_CACHE_CORRUPT:Q.INTERNAL_ERROR};function Ow(t){if(t!=null)return t instanceof Error?{name:t.name,message:pi(t.message)}:typeof t=="string"?pi(t):typeof t=="object"?Lw(t):t}var Pw=[[/\/Users\/[^/\s'"`)]+/g,"/Users/<redacted>"],[/\/home\/[^/\s'"`)]+/g,"/home/<redacted>"],[/[A-Za-z]:\\Users\\[^\\\s'"`)]+/g,"C:\\Users\\<redacted>"],[/(Bearer|Token|Authorization:)\s+[\w._-]+/gi,"$1 <redacted>"],[/\b(sk|pat|ak)[-_][A-Za-z0-9_-]{20,}\b/g,"<redacted-key>"]];function pi(t){let e=t;for(let[r,s]of Pw)e=e.replace(r,s);return e}function Lw(t){let e={};for(let[r,s]of Object.entries(t))typeof s=="string"?e[r]=pi(s):e[r]=s;return e}function gi(t){if(t instanceof D){let e=Ow(t.cause),r={bridgeCode:t.code,retriable:t.retriable};return e!==void 0&&(r.cause=e),{code:kw[t.code]??Q.INTERNAL_ERROR,message:pi(t.message),data:r}}return{code:Q.INTERNAL_ERROR,message:pi(t instanceof Error?t.message:String(t))}}function wl(t){let e=t.data,r=e?.bridgeCode??"AGENT_PROTOCOL_ERROR",s=!!e&&typeof e.message=="string"&&!!e.message,a=s?e?.message:t.message,c=t.data;if(s&&e){let{message:f,...l}=e;c=l}return new D(r,a,{retriable:e?.retriable??!1,cause:c})}function yl(t){return`${JSON.stringify(t)}
84
- `}var _l=10*1024*1024,Us=class{buffer="";onError;constructor(e={}){this.onError=e.onError}push(e){if(this.buffer+=typeof e=="string"?e:e.toString("utf8"),this.buffer.length>_l){let a=this.buffer.length;return this.buffer="",this.onError?.({line:`<buffer overflow: ${a} bytes, dropped>`,error:new Error(`LdjsonDecoder buffer exceeded ${_l} bytes`)}),[]}let r=this.buffer.split(`
85
- `);this.buffer=r.pop()??"";let s=[];for(let a of r){let c=a.replace(/\r$/,"").trim();if(c)try{s.push(JSON.parse(c))}catch(f){this.onError?.({line:c,error:f})}}return s}flush(){if(!this.buffer)return[];let e=this.buffer.replace(/\r$/,"").trim();if(this.buffer="",!e)return[];try{return[JSON.parse(e)]}catch(r){return this.onError?.({line:e,error:r}),[]}}};var bl={"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"},h1=Object.fromEntries(Object.entries(bl).map(([t,e])=>[e,t])),Nw={"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:[]},wr=class{seq=0;next(e,r){this.seq+=1;let s=bl[e]??Mw(e),a=Nw[s]??[],c=[s,String(this.seq)];if(a.length>0){let f=a.map(x=>El(r?.[x]??"")),l=Bw(f).join(":");l&&c.push(l)}else r&&Object.values(r).some(f=>f)&&c.push(Object.values(r).filter(Boolean).map(f=>El(String(f))).join(":"));return c.join("_")}reset(){this.seq=0}};function Mw(t){return t.replace(/[\s/]+/g,".").replace(/_+/g,"-")}function El(t){return t.replace(/[:_\s]+/g,"-")}function Bw(t){let e=t.length;for(;e>0&&!t[e-1];)e-=1;return t.slice(0,e)}Wn();function hn(t,e){let r=process.env[t];if(!r)return e;let s=Number(r);return Number.isFinite(s)&&s>0?s:e}ee();var Fw=hn("COZE_BRIDGE_INITIALIZE_TIMEOUT_MS",3e4),Uw=200,qw=/(ENOTEMPTY|EEXIST).*_npx[/\\]/;function wc(t){return t.some(e=>qw.test(e))}var Hw=hn("COZE_BRIDGE_SESSION_PROMPT_MAX_MS",3600*1e3),jw=hn("COZE_BRIDGE_SESSION_PROMPT_FRAME_IDLE_MS",600*1e3),Sl=500;function Gw(t){try{let e=JSON.stringify(t);return e===void 0||e.length<=Sl?t:`${e.slice(0,Sl)}...<truncated, total ${e.length} chars>`}catch{return"<unserializable>"}}function vl(t,e){if(!(typeof t!="number"||t<=0))try{if(process.platform==="win32"){let r=["/PID",String(t),"/T"];e==="SIGKILL"&&r.push("/F"),zw("taskkill",r,{stdio:"ignore",windowsHide:!0})}else process.kill(-t,e)}catch{}}var At=class{constructor(e){this.opts=e;this.log=H(`downstream.${this.constructor.name}`),this.decoder=new Us({onError:r=>this.log.warn("decode line failed",{line:r.line})})}opts;child;decoder;pending=new Map;inflightAgentRequests=new Map;idAllocator=new wr;updateHandlers=[];agentRequestHandlers=[];exitHandlers=[];log;stopped=!1;stderrRing=[];sanitizeEnv(e){return e}async start(){if(this.child)throw new D("BRIDGE_INTERNAL","Downstream already started");let e=process.platform!=="win32",r=Vt(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=r,r.stdout?.setEncoding("utf8"),r.stdout?.on("data",s=>{try{for(let a of this.decoder.push(s))this.dispatch(a)}catch(a){this.log.warn("stdout dispatch threw, swallowed to keep daemon alive",{err:String(a)})}}),r.stderr?.setEncoding("utf8"),r.stderr?.on("data",s=>{let a=s.trimEnd();this.stderrRing.push(a),this.stderrRing.length>Uw&&this.stderrRing.shift(),this.log.debug("stderr",{text:a})}),r.stdin?.on("error",s=>{this.log.warn("child stdin error",{err:String(s)})}),r.stdout?.on("error",s=>{this.log.warn("child stdout error",{err:String(s)})}),r.stderr?.on("error",s=>{this.log.warn("child stderr error",{err:String(s)})}),r.on("exit",(s,a)=>{this.stopped=!0,(s!==0||a!==null)&&this.stderrRing.length>0&&(this.log.warn("downstream exited abnormally, recent stderr",{code:s,signal:a,recentStderr:[...this.stderrRing]}),(this.framework==="claude-code"||this.framework==="codex")&&wc(this.stderrRing)&&(this.log.warn("npx cache corruption detected, triggering global install fallback (D93)",{framework:this.framework}),yn(this.framework).catch(l=>{this.log.warn("D93 fallback install failed (will retry next spawn cycle)",{framework:this.framework,err:String(l)})})));try{for(let f of this.decoder.flush())this.dispatch(f)}catch(f){this.log.debug("decoder.flush on exit threw (ignored)",{err:String(f)})}this.failAllPending(new D("AGENT_PROTOCOL_ERROR",`agent exited (${s}/${a})`));for(let f of this.exitHandlers)f(s,a)}),r.on("error",s=>{this.log.error("child error",{err:String(s)}),this.failAllPending(new D("AGENT_SPAWN_FAILED",String(s),{cause:s}))}),this.log.info("downstream started",{command:this.opts.command,pid:r.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 r=this.child,s=new Promise(c=>r.once("exit",()=>c()));vl(r.pid,"SIGTERM");let a=setTimeout(()=>{r.killed||vl(r.pid,"SIGKILL")},5e3);try{await s}finally{clearTimeout(a)}}pid(){return this.child?.pid}isAlive(){return!!this.child&&!this.stopped}getStderrTail(){return[...this.stderrRing]}initialize(e){return this.call("initialize",e)}sessionNew(e){return this.call("session/new",{mcpServers:[],...e})}sessionLoad(e){return this.call("session/load",{mcpServers:[],...e})}sessionPrompt(e,r=Hw,s=jw){return this.call("session/prompt",e,r,s)}async sessionCancel(e){!this.child||this.stopped||this.writeFrame(hi("session/cancel",e))}onUpdate(e){this.updateHandlers.push(e)}onAgentRequest(e){this.agentRequestHandlers.push(e)}respondAgentRequest(e,r){if(this.inflightAgentRequests.delete(e),!(!this.child||this.stopped))try{this.writeFrame(mr(e,r))}catch(s){this.log.warn("respondAgentRequest write failed",{id:e,err:String(s)})}}respondAgentRequestError(e,r){if(this.inflightAgentRequests.delete(e),!(!this.child||this.stopped))try{this.writeFrame(xn(e,r))}catch(s){this.log.warn("respondAgentRequestError write failed",{id:e,err:String(s)})}}onExit(e){this.exitHandlers.push(e)}call(e,r,s=Fw,a=0){if(!this.child||this.stopped)return Promise.reject(new D("AGENT_PROTOCOL_ERROR","downstream not started"));let c=this.idAllocator.next(e),f=xi(c,e,r),l=(()=>{if(typeof r!="object"||r===null)return;let m=r.sessionId;return typeof m=="string"?m:void 0})(),x=s>0&&Number.isFinite(s),h=a>0&&Number.isFinite(a);return new Promise((m,E)=>{let C={resolve:m,reject:E,timer:null,frameIdleTimer:null,armFrameIdle:null,method:e};x&&(C.timer=setTimeout(()=>{this.pending.delete(c),C.frameIdleTimer&&clearTimeout(C.frameIdleTimer),this.log.warn("downstream call timeout",{id:c,method:e,timeoutMs:s,...l?{sessionId:l}:{}}),E(new D("AGENT_TIMEOUT",`${e} timed out after ${s}ms`))},s));let _=h?()=>{C.frameIdleTimer&&clearTimeout(C.frameIdleTimer),C.frameIdleTimer=setTimeout(()=>{if(this.inflightAgentRequests.size>0){this.log.debug("frame-idle fired but agent request inflight, re-arming",{id:c,method:e,inflight:this.inflightAgentRequests.size,...l?{sessionId:l}:{}}),_?.();return}C.timer&&clearTimeout(C.timer),this.pending.delete(c),this.log.warn("frame-idle timeout, rejecting pending call",{id:c,method:e,frameIdleMs:a,...l?{sessionId:l}:{}}),E(new D("AGENT_FRAME_IDLE_TIMEOUT",`${e} no session/update for ${a}ms (no inflight agent request)`))},a)}:null;C.armFrameIdle=_,this.pending.set(c,C),_?.();try{this.writeFrame(f)}catch(y){C.timer&&clearTimeout(C.timer),C.frameIdleTimer&&clearTimeout(C.frameIdleTimer),this.pending.delete(c),E(y)}})}writeFrame(e){if(!this.child?.stdin||this.child.stdin.destroyed)throw new D("AGENT_PROTOCOL_ERROR","downstream stdin not writable");this.child.stdin.write(yl(e),r=>{r&&this.log.warn("stdin write callback err",{err:String(r)})})}dispatch(e){if(Fs(e)){let r=e.id!==null?this.pending.get(e.id):void 0;if(!r){this.log.warn("orphan response",{id:e.id});return}this.pending.delete(e.id),r.timer&&clearTimeout(r.timer),r.frameIdleTimer&&clearTimeout(r.frameIdleTimer),e.error?(this.log.warn("downstream returned error frame",{id:e.id,method:r.method,code:e.error.code,message:e.error.message,data:e.error.data}),r.reject(wl(e.error))):e.result===void 0?(this.log.warn("downstream response missing both result and error",{id:e.id,method:r.method}),r.reject(new D("AGENT_PROTOCOL_ERROR",`${r.method} response missing both result and error`))):(this.log.info("downstream returned result",{id:e.id,method:r.method,result:Gw(e.result)}),r.resolve(e.result));return}if(ml(e)){if(e.method==="session/update"){for(let r of this.pending.values())r.armFrameIdle?.();for(let r of this.updateHandlers)try{Promise.resolve(r(e.params)).catch(s=>this.log.warn("update handler failed (async)",{err:String(s)}))}catch(s){this.log.warn("update handler threw sync, swallowed",{err:String(s)})}}else this.log.info("unknown notification (drop, not forwarded)",{method:e.method});return}if(gl(e)){let r=e;try{this.handleAgentRequest(r).catch(s=>this.log.error("agent request handler failed (async)",{method:r.method,err:String(s)}))}catch(s){this.log.warn("handleAgentRequest threw sync, swallowed",{method:r.method,err:String(s)})}}}async handleAgentRequest(e){if(this.agentRequestHandlers.length===0){this.writeFrame(xn(e.id,{code:-32601,message:`method not handled by Bridge: ${e.method}`}));return}this.inflightAgentRequests.set(e.id,e.method);for(let r of this.agentRequestHandlers)try{await r(e)}catch(s){this.log.error("agentRequestHandler threw",{method:e.method,err:String(s)});try{this.writeFrame(xn(e.id,gi(s)))}catch{}this.inflightAgentRequests.delete(e.id)}}failAllPending(e){for(let r of this.pending.values())r.timer&&clearTimeout(r.timer),r.frameIdleTimer&&clearTimeout(r.frameIdleTimer),r.reject(e);this.pending.clear(),this.inflightAgentRequests.clear()}};var Kw=Lr("claude-code")??"@agentclientprotocol/claude-agent-acp@^0.37";function Ww(t){let e={};for(let[r,s]of Object.entries(t))s!==void 0&&(r.startsWith("CLAUDE")||r==="AI_AGENT"||r==="BAGGAGE"||(e[r]=s));return e}var qs=class extends At{framework="claude-code";constructor(e){let r=Jt("claude-code"),[s,a]=r?[r,[]]:["npx",["-y",Kw]],c=e.command??s,f=e.args??a,l={command:c,args:f,cwd:e.cwd,...e.env?{env:e.env}:{}};super(l)}sanitizeEnv(e){return Ww(e)}};Zt();import{mkdtempSync as $w,rmSync as Vw}from"node:fs";import{tmpdir as Jw}from"node:os";import{join as Zw}from"node:path";var Yw=Lr("codex")??"@zed-industries/codex-acp@^0.15",Hs=class extends At{framework="codex";authMethodId;codexHomeDir;constructor(e){let r=Jt("codex"),[s,a]=r?[r,[]]:["npx",["-y",Yw]],c=e.command??s,f=e.args??a,l=e.extraArgs?[...f,...e.extraArgs]:f,x=e.isolateCodexHome?$w(Zw(Jw(),"coze-bridge-codex-home-")):void 0,h=x?{...e.env??{},CODEX_HOME:x}:e.env,m={command:c,args:l,cwd:e.cwd,...h?{env:h}:{}};super(m),this.authMethodId=e.authMethodId,this.codexHomeDir=x}async initialize(e){let r=await super.initialize(e);return this.authMethodId&&await this.call("authenticate",{methodId:this.authMethodId}),r}async stop(e){if(await super.stop(e),this.codexHomeDir)try{Vw(this.codexHomeDir,{recursive:!0,force:!0})}catch{}}};var Xw=3e4,_r=class extends At{framework="openclaw";agentId;sessionName;slashModelOnStart;constructor(e){let r=e.sessionName??"default",s=["acp","--session",`agent:${e.agentId}:${r}`];e.gatewayToken&&s.push("--token",e.gatewayToken);let a={command:e.command,args:s,cwd:e.cwd,...e.env?{env:e.env}:{}};super(a),this.agentId=e.agentId,this.sessionName=r,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}`}]},Xw))}get acpSessionName(){return this.sessionName}};ee();Me();function _c(t){return t.replace(/[^A-Za-z0-9._-]+/g,"-")}Zt();var yr=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((r,s)=>{this.slots.push({task:e,resolve:r,reject:s}),this.drain()})}close(){this.closed=!0}dispose(e=new Error("AsyncQueue disposed")){for(this.disposed=!0,this.closed=!0;this.slots.length>0;)this.slots.shift()?.reject(e)}get size(){return this.slots.length}get isRunning(){return this.running}get isDisposed(){return this.disposed}async drain(){if(!this.running){this.running=!0;try{for(;this.slots.length>0&&!this.disposed;){let e=this.slots.shift();if(!e)break;try{let r=await e.task();e.resolve(r)}catch(r){e.reject(r)}}}finally{this.running=!1}}}};var js=class{agentId;framework;workspace;deployType;accountId;patToken;modelInfo;sessions=new Map;sessionQueues=new Map;activeTriggers=new Map;activeGroupIds=new Map;status="ok";model;lastActiveAt=Date.now();constructor(e){this.agentId=e.agentId,this.framework=e.framework,this.workspace=e.workspace,this.model=e.model,this.deployType=e.deployType??"local",e.accountId&&(this.accountId=e.accountId),e.patToken&&(this.patToken=e.patToken),e.modelInfo&&(this.modelInfo=e.modelInfo)}setPatToken(e){this.patToken=e}setModelInfo(e){this.modelInfo=e}getSessionQueue(e){let r=this.sessionQueues.get(e);return(!r||r.isDisposed)&&(r=new yr,this.sessionQueues.set(e,r)),r}allSessionQueues(){return this.sessionQueues.entries()}hasSessionQueue(e){let r=this.sessionQueues.get(e);return!!r&&!r.isDisposed}async dispose(e){this.status="stopped";let r=new Error(`AgentSession disposed${e?`: ${e}`:""}`);for(let s of this.sessionQueues.values())s.dispose(r);this.sessionQueues.clear(),await this.killAllRuntimes(e??"dispose")}async killAllRuntimes(e){let r=[];for(let[,s]of this.sessions)mi(s),s.downstream&&(r.push(s.downstream.stop(e).catch(()=>{})),s.downstream=void 0);await Promise.all(r),this.activeTriggers.clear(),this.activeGroupIds.clear()}};function mi(t){t.idleTimer&&(clearTimeout(t.idleTimer),t.idleTimer=void 0)}Wn();ee();import{constants as Il,access as Qw}from"node:fs/promises";import{delimiter as e_,join as t_}from"node:path";var pn=H("framework-detector"),Al={"claude-code":"claude",codex:"codex",openclaw:"openclaw"},n_=[".exe",".cmd",".bat",".ps1"],gn=class{env;constructor(e={}){this.env={pathEnv:e.pathEnv??process.env.PATH??"",platform:e.platform??process.platform,spawn:e.spawn??Vt,access:e.access??Qw}}async detect(e){let r=Al[e],s=await this.which(r);if(!s)return pn.debug("framework binary not found",{framework:e,bin:r}),null;let a=e==="openclaw"?["--log-level","silent"]:[],[c,f]=await Promise.all([this.probeVersion(s,a),e==="openclaw"?this.probeOpenclawDefaultAgent(s):Promise.resolve(null)]),l={path:s,version:c};return f&&(l.defaultAgent=f),l}async detectAll(){let e=await Promise.all(Object.keys(Al).map(async s=>[s,await this.detect(s)])),r={};for(let[s,a]of e)a&&(r[s]=a);return r}async which(e){let r=this.env.pathEnv.split(e_).filter(Boolean),s=this.env.platform==="win32"?["",...n_]:[""];for(let a of r)for(let c of s){let f=t_(a,e+c);if(await this.isExecutable(f))return f}return null}async isExecutable(e){try{let r=this.env.platform==="win32"?Il.F_OK:Il.X_OK;return await this.env.access(e,r),!0}catch{return!1}}async probeOpenclawDefaultAgent(e){let r=await this.runProbe(e,["--log-level","silent","agents","list","--json"]);if(!r)return pn.warn("openclaw default agent probe: runProbe returned null (spawn err / timeout)",{path:e}),null;if(r.code!==0)return pn.warn("openclaw default agent probe: non-zero exit",{path:e,code:r.code,stdoutHead:r.stdout.slice(0,200)}),null;let s=r.stdout.match(/\[\s*\{[\s\S]*\}\s*\]/);if(!s)return pn.warn("openclaw default agent probe: regex no match (no JSON array in stdout)",{path:e,stdoutHead:r.stdout.slice(0,200)}),null;try{let a=JSON.parse(s[0]);if(!Array.isArray(a))return pn.warn("openclaw default agent probe: JSON parsed but not an array",{path:e}),null;let c=a.find(f=>f?.isDefault===!0);return c?!c.id||!c.workspace?(pn.warn("openclaw default agent probe: default agent missing id or workspace",{path:e,hasId:!!c.id,hasWorkspace:!!c.workspace}),null):{id:c.id,workspace:c.workspace}:(pn.info("openclaw default agent probe: no agent has isDefault=true",{path:e,agentCount:a.length}),null)}catch(a){return pn.warn("openclaw default agent probe: JSON.parse failed",{path:e,err:String(a),matchHead:s[0].slice(0,200)}),null}}async probeVersion(e,r=[]){let s=await this.runProbe(e,[...r,"--version"]);return s&&(i_(s.stdout).split(/\r?\n/)[0]??"").trim()||"unknown"}runProbe(e,r){return new Promise(s=>{let a="",c=!1,f,l=x=>{c||(c=!0,f&&clearTimeout(f),s(x))};try{let x=this.env.spawn(e,r,{stdio:["ignore","pipe","pipe"]});f=setTimeout(()=>{x.kill("SIGKILL"),l(null)},15e3),x.stdout?.on("data",h=>{a+=h.toString("utf8")}),x.on("error",()=>l(null)),x.on("close",h=>l({code:h,stdout:a}))}catch{l(null)}})}},r_=new RegExp("\x1B\\[[0-9;]*[A-Za-z]","g");function i_(t){return t.replace(r_,"")}import{spawn as s_}from"node:child_process";import{homedir as o_}from"node:os";import{join as a_}from"node:path";Ui();ee();async function Dl(){let t=a_(o_(),".openclaw/openclaw.json");return(await Jn(t))?.gateway?.auth?.token??""}var Cl=H("openclaw.config"),c_=[0,5e3,5e3],Tl="models.providers.",Gs="agents.defaults.models",Ks=class{command;env;retryDelaysMs;queue=new yr;constructor(e){this.command=e.command,this.env=e.env??process.env,this.retryDelaysMs=e.retryDelaysMs??c_}async withRetry(e,r){let s;for(let a=0;a<this.retryDelaysMs.length;a++){let c=this.retryDelaysMs[a]??0;c>0&&await new Promise(f=>setTimeout(f,c));try{return await r()}catch(f){s=f,Cl.warn("openclaw cli failed, will retry",{label:e,attempt:a+1,err:String(f)})}}throw new D("AGENT_SPAWN_FAILED",`openclaw cli ${e} failed after ${this.retryDelaysMs.length} attempts: ${s?.message??"unknown"}`)}runCli(e){return new Promise((r,s)=>{let a=s_(this.command,e,{stdio:["ignore","pipe","pipe"],env:this.env}),c="";a.stderr?.on("data",f=>{c+=f.toString("utf8")}),a.on("error",s),a.on("close",f=>{f===0?r():s(new Error(`exit ${f}: ${c.trim().slice(0,500)}`))})})}async runCliTolerant(e,r){try{await this.runCli(e)}catch(s){let a=String(s);if(r.some(c=>a.includes(c)))return;throw s}}async bestEffortUnset(e,r){try{await this.queue.enqueue(()=>this.withRetry(e,()=>this.runCli(["config","unset",r])))}catch(s){Cl.warn(`${e} failed (best-effort)`,{configPath:r,err:String(s)})}}ensureProvider(e,r){return this.queue.enqueue(()=>this.withRetry(`config set models.providers.${e}`,()=>this.runCli(["config","set",`${Tl}${e}`,JSON.stringify(r),"--strict-json","--merge"])))}removeProvider(e){return this.bestEffortUnset(`config unset models.providers.${e}`,`${Tl}${e}`)}addModelToAllowlist(e,r){let s={[e]:r?{alias:r}:{}};return this.queue.enqueue(()=>this.withRetry(`config set ${Gs}[${e}]`,()=>this.runCli(["config","set",Gs,JSON.stringify(s),"--strict-json","--merge"])))}removeModelFromAllowlist(e){return this.bestEffortUnset(`config unset ${Gs}[${e}]`,`${Gs}.${e}`)}ensureAgent(e,r,s){let a=["agents","add",e,"--workspace",r,"--non-interactive"];return s&&a.push("--model",s),this.queue.enqueue(()=>this.withRetry(`agents add ${e}`,()=>this.runCliTolerant(a,["already exists","already registered"])))}deleteAgent(e){return this.queue.enqueue(()=>this.withRetry(`agents delete ${e}`,()=>this.runCliTolerant(["agents","delete",e,"--force"],["not found","does not exist"])))}};var Oe=H("agent-manager"),f_=(t,e,r,s,a,c,f,l,x)=>{switch(t){case"claude-code":{let h={...a?{...nl(a),...sl(a,f,l)}:{},...x??{},IS_SANDBOX:"1"};return new qs({cwd:r,env:h})}case"codex":{let m=[...a?[...rl(a),...al(a,f,l)]:[],"-c",'sandbox_mode="danger-full-access"',"-c",'approval_policy="never"'],E={...a?il(a):{},...x??{}},C=!!a;return new Hs({cwd:r,...m.length>0?{extraArgs:m}:{},...Object.keys(E).length>0?{env:E}:{},...C?{authMethodId:"openai-api-key",isolateCodexHome:!0}:{}})}case"openclaw":return new _r({command:e,cwd:r,agentId:s,...c?{sessionName:_c(c)}:{}})}};function Ec(t){return t==="claude-code"||t==="codex"}var l_={path:"",version:"cloud-deployed"},u_={protocolVersion:1,clientCapabilities:{fs:{readTextFile:!0,writeTextFile:!0}}},x_=6e4,h_=hn("COZE_BRIDGE_SPAWN_AWAIT_INSTALL_MS",25e3),Ws=class{paths;config;registry;factory;createTimeoutMs;spawnAwaitInstallMs;openclawConfigCache;ensuredProviders=new Set;detectorFactory;constructor(e){this.paths=e.paths,this.config=e.config,this.registry=e.registry,this.factory=e.downstreamFactory??f_,this.createTimeoutMs=e.createTimeoutMs??x_,this.spawnAwaitInstallMs=e.spawnAwaitInstallMs??h_,this.detectorFactory=e.detectorFactory??(()=>new gn)}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 D("AGENT_SPAWN_FAILED","openclaw binary not detected on this machine");this.openclawConfigCache=new Ks({command:e.path})}return this.openclawConfigCache}async createAgent(e){if(!e.agentId)throw new D("IPC_BAD_REQUEST","agentId required");if(!e.framework)throw new D("IPC_BAD_REQUEST","framework required");let r=ci(e._meta)==="cloud";this.registry.reviveIfDisconnected?.(e.agentId);let s=this.registry.get(e.agentId);if(s){if(s.framework!==e.framework)throw new D("AGENT_BUSY",`agent ${e.agentId} exists with different framework (${s.framework})`);if(s.status==="error")Oe.warn("existing agent in error state, rebuilding",{agentId:e.agentId}),await s.dispose("rebuild after error").catch(y=>Oe.warn("dispose stale agent failed (ignored)",{err:String(y)})),this.registry.unregister(e.agentId);else{if(e.patToken&&e.patToken!==s.patToken){Oe.info("updating agent patToken on re-create (reconnect with new PAT)",{agentId:e.agentId}),s.setPatToken(e.patToken);let y=await Ue(e.agentId,this.paths).catch(()=>null);y&&(y.patToken=e.patToken,await Ve(y,this.paths))}if(s.deployType==="cloud"&&e.modelInfo){Oe.info("updating agent modelInfo on re-create",{agentId:e.agentId}),s.setModelInfo(e.modelInfo);let y=await Ue(e.agentId,this.paths).catch(()=>null);y&&(y.modelInfo=e.modelInfo,await Ve(y,this.paths))}return Oe.info("agent already exists, return current",{agentId:e.agentId}),{ok:!0,agentId:s.agentId,workspace:s.workspace,framework:s.framework}}}if(!r&&!this.config.frameworksCache?.[e.framework])throw new D("AGENT_SPAWN_FAILED",`framework ${e.framework} not detected on this machine; rerun daemon to refresh frameworks_cache`);let c=kt(e.agentId,this.paths),f=ci(e._meta),l=e.framework==="openclaw"&&f==="local",x=l?this.config.frameworksCache?.openclaw?.defaultAgent?.workspace:void 0,h=e.workspace??x??c.workspace,m=new AbortController,E=setTimeout(()=>m.abort(new D("AGENT_TIMEOUT",`_agent/create timed out after ${this.createTimeoutMs}ms`)),this.createTimeoutMs),C,_=!1;try{r&&Ec(e.framework)&&await yn(e.framework,m.signal);let y=()=>{if(m.signal.aborted)throw m.signal.reason instanceof Error?m.signal.reason:new D("AGENT_TIMEOUT","_agent/create aborted")};await yc(c.root,{recursive:!0}),await yc(h,{recursive:!0}),await yc(c.logs,{recursive:!0}),y(),l||await Zn(h,e.framework,e.cozeIdentity),e.framework==="claude-code"&&await Z0(h),y();let v=await Ue(e.agentId,this.paths).catch(()=>null),I=el({model:e.model??v?.model}),R=Wf(e._meta)??v?.accountId,L=e.patToken??v?.patToken,w=f==="cloud"?e.modelInfo??v?.modelInfo:void 0;if(C=new js({agentId:e.agentId,framework:e.framework,workspace:h,model:I.model??vt,deployType:f,...R?{accountId:R}:{},...L?{patToken:L}:{},...w?{modelInfo:w}:{}}),C.status="ok",v?.sessions){for(let[z,O]of Object.entries(v.sessions))C.sessions.set(z,{acpSessionId:O.acpSessionId,modelToken:O.modelToken,tokenGeneratedAt:O.tokenGeneratedAt,lastActiveAt:Date.now(),loadingSession:!1,replySeq:0});let F=Object.keys(v.sessions).length;F>0&&Oe.info("restored persisted session records (no spawn)",{agentId:e.agentId,count:F})}this.registry.register(C),_=!0;let A={agentId:e.agentId,framework:e.framework,workspace:h,cozeIdentity:e.cozeIdentity,createdAt:v?.createdAt??Date.now(),sessions:v?.sessions??{},model:I.model};f==="cloud"&&(A.deployType="cloud"),R&&(A.accountId=R),L&&(A.patToken=L),w&&(A.modelInfo=w),v?.skills&&(A.skills=v.skills),v?.agentName&&(A.agentName=v.agentName),v?.description&&(A.description=v.description),e.framework==="openclaw"&&f==="cloud"&&(this.config.frameworksCache?.openclaw?.path?await this.getOpenclawConfig().ensureAgent(e.agentId,h):Oe.warn("openclaw binary not on this machine, skip agents add (will fail at session/prompt)",{agentId:e.agentId}));let k=e.initialSkills??[];if(k.length>0){let F=[...A.skills??[]],z=new Map(F.map((U,W)=>[U.skillId,W])),O=await Promise.allSettled(k.map(U=>gc({agentId:e.agentId,workspace:h,framework:e.framework,skill:U}))),N=0;for(let[U,W]of O.entries()){let se=k[U];se&&(W.status==="fulfilled"?(mc(F,z,W.value),N++):Oe.warn("initialSkill install failed (skipping)",{agentId:e.agentId,skillId:se.skillId,skillName:se.skillName,err:String(W.reason)}))}N>0&&(A.skills=F,Oe.info("initialSkills installed",{agentId:e.agentId,installed:N,requested:k.length}))}return await Ve(A,this.paths),Oe.info("agent created (no spawn, lazy on first prompt)",{agentId:e.agentId,framework:e.framework,deployType:f}),{ok:!0,agentId:e.agentId,workspace:h,framework:e.framework}}catch(y){throw Oe.error("agent create failed, rolling back",{agentId:e.agentId,err:String(y)}),_&&C&&(await C.dispose("rollback").catch(()=>{}),this.registry.unregister(e.agentId)),await d_(c.root,{recursive:!0,force:!0}).catch(v=>Oe.warn("rm agent dir failed (ignored)",{err:String(v)})),y instanceof D?y:new D("AGENT_SPAWN_FAILED",String(y),{cause:y})}finally{clearTimeout(E)}}async spawnSessionDownstream(e,r,s,a,c){let l=this.config.frameworksCache?.[e.framework];if(!l)if(e.deployType==="cloud"&&Ec(e.framework))l=l_;else throw new D("AGENT_SPAWN_FAILED",`framework ${e.framework} not detected on this machine`);if(Ec(e.framework)&&!Jt(e.framework)){let m=Jo(e.framework);m&&(Oe.info("spawn: awaiting in-flight acp install (D92)",{agentId:e.agentId,framework:e.framework}),await Promise.race([m.catch(()=>{}),new Promise(E=>setTimeout(E,this.spawnAwaitInstallMs))]))}let x=e.deployType==="cloud"?{model:e.model,modelToken:r,...e.modelInfo?{modelInfo:e.modelInfo}:{}}:void 0,h;e.framework==="openclaw"?h=await this.buildOpenclawDownstream({session:e,modelConfig:x,cloudSessionId:s,cozeEnv:a,mockScenario:c,command:l.path}):h=this.factory(e.framework,l.path,e.workspace,e.agentId,x,s,a,c,this.buildBinShimPathEnv());try{return await h.start(),await h.initialize(u_),h}catch(m){let E=h instanceof At?h.getStderrTail():[];E.length>0&&Oe.warn("spawnSessionDownstream failed, recent stderr (D94)",{agentId:e.agentId,framework:e.framework,method:m instanceof D?m.code:"unknown",recentStderr:E});let C=wc(E);await h.stop("spawnSessionDownstream failed").catch(()=>{});let _=C?new D("NPX_CACHE_CORRUPT","~/.npm/_npx \u76EE\u5F55\u635F\u574F (ENOTEMPTY)\u3002\u5EFA\u8BAE: rm -rf ~/.npm/_npx && npm i -g @zed-industries/codex-acp (\u6216\u5BF9\u5E94 @agentclientprotocol/claude-agent-acp)",{cause:m}):m;throw m instanceof D?new D(m.code,m.message,{retriable:m.retriable,cause:_}):new D("AGENT_SPAWN_FAILED",m instanceof Error?m.message:String(m),{cause:_})}}async buildOpenclawDownstream(e){let{session:r,modelConfig:s,cloudSessionId:a,cozeEnv:c,mockScenario:f,command:l}=e,x=_c(a);if(r.deployType==="local"){let C=this.config.frameworksCache?.openclaw?.defaultAgent;if(!C?.id||!C.workspace){Oe.warn("openclaw default agent stale or missing, attempting lazy re-detect");let y=await this.detectorFactory().detect("openclaw");if(y?.defaultAgent?.id&&y?.defaultAgent?.workspace)Oe.info("openclaw lazy re-detect success",{agentId:y.defaultAgent.id,workspace:y.defaultAgent.workspace}),this.config.frameworksCache||(this.config.frameworksCache={}),this.config.frameworksCache.openclaw=y,C=y.defaultAgent;else throw new D("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 _r({command:l,cwd:C.workspace,agentId:C.id,sessionName:x})}let h=await Dl(),m=s?ol(s,c,f):null,E;if(m){let C=dc(a),y=m.models[0]?.id??vt,v=`${C}/${y}`;if(!this.ensuredProviders.has(v)){let I=this.getOpenclawConfig();await I.ensureProvider(C,m),await I.addModelToAllowlist(v),this.ensuredProviders.add(v)}E=v}return new _r({command:l,cwd:r.workspace,agentId:r.agentId,sessionName:x,...h?{gatewayToken:h}:{},...E?{slashModelOnStart:E}:{}})}async openclawRepair(e,r){let s=this.getOpenclawConfig();await s.deleteAgent(e),await s.ensureAgent(e,r)}async cleanupOpenclawSessionProviders(e){if(e.framework!=="openclaw"||!this.openclawConfigCache)return;let r=this.openclawConfigCache;for(let s of e.sessions.keys()){let a=dc(s),c=`${a}/${e.model}`,f=!0;try{await r.removeProvider(a)}catch(l){f=!1,Oe.warn("removeProvider failed, keeping ensuredProviders entry",{providerId:a,err:String(l)})}try{await r.removeModelFromAllowlist(c)}catch(l){f=!1,Oe.warn("removeModelFromAllowlist failed, keeping ensuredProviders entry",{fullModelId:c,err:String(l)})}f&&this.ensuredProviders.delete(c)}}};import{randomUUID as Ll}from"node:crypto";import{promises as I_}from"node:fs";import{basename as Nl}from"node:path";import{promises as g_}from"node:fs";import{basename as m_}from"node:path";ee();var Rl=H("file-upload"),w_="/api/coze_claw/file/agent_upload",__=6e4;async function kl(t,e={}){let s=`${Ls(Ms(e.handshakeBase))}${w_}`,a=e.timeoutMs??__,c=await g_.readFile(t.path),f=new FormData;f.append("agent_id",t.agentId),f.append("session_id",t.sessionId),f.append("file_name",t.name),f.append("file_content",new Blob([c],{type:t.mimeType}),t.name);let l={Authorization:`Bearer ${t.patToken}`,Accept:"application/json","x-coze-version":"3.0",...hr(e.ppeOverride),...t.accountId?{"x-coze-account":t.accountId}:{}},x=new AbortController,h=setTimeout(()=>x.abort(),a);Rl.info("file upload start",{url:s,agentId:t.agentId,sessionId:t.sessionId,name:t.name,bytes:t.sizeBytes,mime:t.mimeType});try{let m=await fetch(s,{method:"POST",headers:l,body:f,signal:x.signal}),E=m.headers.get("x-tt-logid")??"";if(!m.ok){let y=await m.text().catch(()=>"");throw new D("UPLOAD_FAILED",`upload HTTP ${m.status} logid=${E}: ${y.slice(0,200)}`)}let C=await m.json();if(C.code!==void 0&&C.code!==0)throw new D("UPLOAD_FAILED",`upload code=${C.code} msg=${C.msg??"-"} logid=${E}`);let _=C.data?.file?.file_url;if(!_)throw new D("UPLOAD_FAILED",`upload response missing data.file.file_url logid=${E}: ${JSON.stringify(C).slice(0,200)}`);return Rl.info("file upload ok",{uri:_,logid:E}),{uri:_}}catch(m){throw m instanceof D?m:m.name==="AbortError"?new D("UPLOAD_FAILED",`upload timeout (${a}ms) for ${m_(t.path)}`):new D("UPLOAD_FAILED",String(m),{cause:m})}finally{clearTimeout(h)}}ee();import{promises as y_}from"node:fs";import{extname as E_}from"node:path";var b_=[{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 S_(t){return t[0]===82&&t[1]===73&&t[2]===70&&t[3]===70&&t[8]===87&&t[9]===69&&t[10]===66&&t[11]===80}var v_={".txt":"text/plain",".md":"text/markdown",".svg":"image/svg+xml",".json":"application/json"};async function Ol(t){let e=await y_.open(t,"r");try{let r=Buffer.alloc(16);if(await e.read(r,0,16,0),S_(r))return"image/webp";for(let s of b_)if(s.prefix.every((a,c)=>r[c]===a))return s.mime}finally{await e.close()}return v_[E_(t).toLowerCase()]??"application/octet-stream"}Me();var $s=H("agent-send"),Pl=50*1024*1024,A_=new Set(["image/png","image/jpeg","image/webp","image/gif","image/svg+xml","application/pdf","application/json","text/plain","text/markdown"]);function Ml(t,e,r){let s=t.get(e);if(!s)throw new D("AGENT_NOT_FOUND",`agent=${e}`);if(t.disconnectedAgents.has(e))throw new D("AGENT_DISCONNECTED",`agent=${e} was disconnected by cloud`);let a=s.sessions.get(r);if(!a)throw new D("AGENT_NOT_FOUND",`session=${r} not active in agent=${e}`);return{session:s,runtime:a}}async function Bl(t,e,r,s,a,c){let l;for(let x=0;x<=2;x++)try{await t.core.sendAgentFileUpdate(e,r,s,a);return}catch(h){l=h,x<2&&($s.warn("sendAgentFileUpdate failed, retrying",{attempt:x+1,err:String(h)}),await new Promise(m=>setTimeout(m,5e3)))}throw new D("UPSTREAM_NOT_READY",`${c} after 3 attempts: ${String(l)}`,{cause:l})}async function zl(t,e){let{session:r,runtime:s}=Ml(e.core,t.agentId,t.sessionId);if(!await Nr(t.path,r.workspace))throw new D("PATH_OUTSIDE_WORKSPACE",`path=${t.path} not under workspace=${r.workspace}`);let a=await I_.stat(t.path).catch(()=>null);if(!a||!a.isFile())throw new D("IPC_BAD_REQUEST",`path is not a regular file: ${t.path}`);if(a.size>Pl)throw new D("FILE_TOO_LARGE",`${a.size} bytes > limit ${Pl}`);let c=await Ol(t.path);if(!A_.has(c))throw new D("UNSUPPORTED_MIME",`mime=${c} not in whitelist`);if(t.kind==="image"&&!c.startsWith("image/"))throw new D("UNSUPPORTED_MIME",`kind=image but mime=${c}`);if(!e.core.upstream.isConnected())throw new D("UPSTREAM_NOT_READY","cloud WS not connected");let f=t.name??Nl(t.path),l;try{l=await kl({patToken:r.patToken??e.patToken,agentId:t.agentId,sessionId:t.sessionId,path:t.path,mimeType:c,name:f,sizeBytes:a.size,...r.accountId?{accountId:r.accountId}:{}},{handshakeBase:e.handshakeBase,ppeOverride:e.ppeOverride})}catch(h){throw $s.warn("agent file upload failed",{agentId:t.agentId,sessionId:t.sessionId,path:t.path,sizeBytes:a.size,mime:c,code:h instanceof D?h.code:"UNKNOWN",message:h instanceof Error?h.message:String(h)}),h}let x={sessionUpdate:"agent_file",messageId:Ll(),content:{type:t.kind==="image"?"image":"resource",uri:l.uri,mimeType:c,name:f,sizeBytes:a.size,...l.fileId!==void 0?{fileId:l.fileId}:{},...t.caption!==void 0?{caption:t.caption}:{}}};return await Bl(e,r,s,t.sessionId,x,"agent file uploaded to cloud but sendAgentFileUpdate failed"),$s.info("agent file sent",{agentId:t.agentId,sessionId:t.sessionId,kind:t.kind,name:f,bytes:a.size,mime:c,uri:l.uri}),{ok:!0,uri:l.uri,bytes:a.size,mimeType:c,...l.fileId!==void 0?{fileId:l.fileId}:{}}}async function Fl(t,e){let{session:r,runtime:s}=Ml(e.core,t.agentId,t.sessionId);if(!t.mimeType)throw new D("IPC_BAD_REQUEST","group-file requires mimeType");if(!e.core.upstream.isConnected())throw new D("UPSTREAM_NOT_READY","cloud WS not connected");let a=t.name??Nl(t.path),c={sessionUpdate:"group_file",messageId:Ll(),content:{uri:t.path,name:a,mimeType:t.mimeType,...t.caption!==void 0?{caption:t.caption}:{}}};return await Bl(e,r,s,t.sessionId,c,"agent group file sendAgentFileUpdate failed"),$s.info("agent group file sent",{agentId:t.agentId,sessionId:t.sessionId,uri:t.path,name:a,mime:t.mimeType}),{ok:!0,uri:t.path,bytes:0,mimeType:t.mimeType}}function Ul(t,e){let r=t.split(".").map(Number),s=e.split(".").map(Number),a=Math.max(r.length,s.length);for(let c=0;c<a;c++){let f=r[c]??0,l=s[c]??0;if(f<l)return!0;if(f>l)return!1}return!1}Zt();Wn();ee();var Ct=H("coze-cli-installer"),ql="@coze/cli@latest",C_="coze",Hl="0.1.7",T_=5e3,D_=5e3,R_=9e4,jl=1e4,wi=null,Vs=!1;async function bc(t,e={}){if(Vs)return;if(wi)return wi;let r=e.exec??Ni;return wi=(async()=>{try{let s=await k_(C_,r),a=!1;if(s){let f=await O_(r);if(f===void 0)Ct.warn("coze-cli found but version unparseable, fall through to full install",{path:s});else if(Ul(f,Hl))Ct.info("coze-cli version too old, upgrade-only (preserve user config + auth)",{path:s,version:f,min:Hl}),a=!0;else{Ct.info("coze-cli already on PATH with sufficient version, skip",{path:s,version:f}),Vs=!0;return}}let c=a?"upgrade-only":"full";Ct.info("coze-cli install start",{package:ql,mode:c});try{await r("npm",["i","-g","--prefer-online",ql],{timeout:R_,maxBuffer:10*1024*1024}),Ct.info("coze-cli install ok")}catch(f){Ct.warn("coze-cli install failed (skip subsequent steps)",{err:String(f)});return}if(a){Vs=!0;return}if(t.env)try{await r("coze",["config","set","xTTEnv",t.env],{timeout:jl}),Ct.info("coze config set xTTEnv ok",{env:t.env})}catch(f){Ct.warn("coze config set failed (continue to auth login)",{err:String(f)})}try{await r("coze",["auth","login","--token",t.patToken],{timeout:jl}),Ct.info("coze auth login ok")}catch(f){Ct.warn("coze auth login failed",{err:String(f)});return}Vs=!0}finally{wi=null}})(),wi}async function k_(t,e){let r=process.platform==="win32"?"where":"which";try{let{stdout:s}=await e(r,[t],{timeout:T_});return zi(s)}catch{return}}async function O_(t){try{let{stdout:e,stderr:r}=await t("coze",["--version"],{timeout:D_});return(e||r).match(/(\d+\.\d+\.\d+)/)?.[1]}catch{return}}Ui();Me();var P_=10*6e4;function Gl(t){let e=t?.sessionIdleTimeoutMs;return typeof e!="number"||!Number.isFinite(e)||e<=0?P_:e}function Js(t){return Jn(t??te().configFile)}function Er(t,e){return Fi(e??te().configFile,t)}import{randomBytes as Y_}from"node:crypto";import{createReadStream as L_}from"node:fs";import{mkdir as N_,readFile as M_,realpath as B_,stat as z_,writeFile as F_}from"node:fs/promises";import{basename as U_,dirname as Sc,join as q_,relative as H_,resolve as Kl,sep as j_}from"node:path";import{createInterface as G_}from"node:readline";ee();var $l=H("fs-rpc"),_i=hn("COZE_BRIDGE_FS_RPC_MAX_BYTES",20*1024*1024);async function Vl(t,e){let r=Buffer.byteLength(t.content,"utf8");if(r>_i)throw new D("IPC_BAD_REQUEST",`fs/write_text_file content too large: ${r} bytes > limit ${_i} bytes`);let s=await Zl(t.path,e);return await N_(Sc(s),{recursive:!0}),await F_(s,t.content,"utf8"),$l.info("fs/write_text_file ok",{path:s,size:t.content.length}),null}async function Jl(t,e){let r=await Zl(t.path,e),s=await z_(r),a=typeof t.line=="number"||typeof t.limit=="number";if(s.size>_i&&!a)throw new D("IPC_BAD_REQUEST",`fs/read_text_file too large without line/limit slicing: ${s.size} bytes > ${_i} bytes`);let c;if(a&&s.size>_i)c=await K_(r,t.line??1,t.limit);else{let f=await M_(r,"utf8");if(a){let l=f.split(`
86
- `),x=Math.max(0,(t.line??1)-1),h=typeof t.limit=="number"?x+t.limit:void 0;c=l.slice(x,h).join(`
87
- `)}else c=f}return $l.info("fs/read_text_file ok",{path:r,size:c.length}),{content:c}}async function K_(t,e,r){let s=G_({input:L_(t,{encoding:"utf8"}),crlfDelay:Number.POSITIVE_INFINITY}),a=Math.max(0,e-1),c=typeof r=="number"?a+r:Number.POSITIVE_INFINITY,f=[],l=0;try{for await(let x of s)if(l>=a&&l<c&&f.push(x),l++,l>=c)break}finally{s.close()}return f.join(`
88
- `)}async function Zl(t,e){if(typeof t!="string"||t.length===0)throw new D("IPC_BAD_REQUEST","path must be a non-empty string");let[r,s]=await Promise.all([Wl(Kl(e)),Wl(Kl(t))]),a=H_(r,s);if(a.startsWith("..")||a===".."||a.startsWith(`..${j_}`))throw new D("IPC_BAD_REQUEST",`path escapes workspace: ${t}`);return s}async function Wl(t){let e=[],r=t;for(;r!==Sc(r);)try{let s=await B_(r);return e.length?q_(s,...e.reverse()):s}catch{e.push(U_(r)),r=Sc(r)}return t}ee();var Yl=H("prompt-multimodal"),Xl=10*1024*1024,W_=15e3,$_=6;async function Ql(t){let e=new Array(t.length),r=0;async function s(){for(;r<t.length;){let c=r++,f=t[c];f!==void 0&&(e[c]=await V_(f))}}let a=Array.from({length:Math.min($_,t.length)},()=>s());return await Promise.all(a),e}function eu(t){return t.some(e=>e.type==="image")}async function V_(t){if(t.type!=="image")return t;let e=t;if(e.data||!e.uri||!Ps(e.uri))return t;try{let{buf:r,contentType:s}=await Z_(e.uri),a=e.mimeType||J_(s)||"application/octet-stream";return Yl.info("image uri fetched and inlined",{uri:e.uri,bytes:r.length,mimeType:a}),{type:"image",data:r.toString("base64"),mimeType:a}}catch(r){return Yl.warn("image fetch failed, degrading to text block",{uri:e.uri,err:String(r)}),{type:"text",text:`[image load failed: ${e.uri}]`}}}function J_(t){if(!t)return;let e=t.indexOf(";");return(e===-1?t:t.slice(0,e)).trim()||void 0}async function Z_(t){let e=new AbortController,r=setTimeout(()=>e.abort(),W_);try{let s=await fetch(t,{signal:e.signal});if(!s.ok)throw new Error(`HTTP ${s.status} ${s.statusText}`);let a=await s.arrayBuffer();if(a.byteLength>Xl)throw new Error(`image too large: ${a.byteLength} bytes (max ${Xl})`);return{buf:Buffer.from(a),contentType:s.headers.get("content-type")??void 0}}finally{clearTimeout(r)}}Yt();ee();var $=H("core"),X_=3e4,Q_=/^(boe|ppe)_[A-Za-z0-9_-]+$/,ey=3e4,Zs=class{upstream;agents=new Map;disconnectedAgents=new Set;extensions;paths;sessionSpawner;sessionIdleTimeoutMs;upstreamIds=new wr;pendingUpstream=new Map;pendingBridge=new Map;currentCozeEnv;currentMockScenario;constructor(e){this.upstream=e.upstream,this.extensions=e.extensions??{},this.paths=e.paths,this.sessionSpawner=e.sessionSpawner,this.sessionIdleTimeoutMs=Gl(e.bridgeConfig)}registerExtension(e,r){this.extensions[e]=r}getCozeEnv(){return this.currentCozeEnv}getMockScenario(){return this.currentMockScenario}setMockScenario(e){this.currentMockScenario=e&&e.length>0?e:void 0}async start(){this.upstream.onFrame(e=>this.handleFrame(e)),this.upstream.onConnect?.(({initial:e})=>{e||this.rejectAllPendingOnReconnect()}),await this.upstream.start(),$.info("Core started",{extensions:Object.keys(this.extensions)})}async stop(e){$.info("Core stopping",{reason:e}),await Promise.all([...this.agents.values()].map(r=>r.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),$.info("agent registered",{agentId:e.agentId,framework:e.framework});for(let r of this.registerHandlers)try{r(e.agentId)}catch(s){$.warn("onAgentRegister handler threw (ignored)",{agentId:e.agentId,err:String(s)})}}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)&&$.info("agent revived from disconnect",{agentId:e})}attachRuntimeHooks(e,r,s){let a=s.downstream;a&&(a.onUpdate(c=>{s.loadingSession||this.forwardUpdate(e,c)}),a.onAgentRequest(c=>{this.handleAgentRequest(e,a,c)}),a.onExit((c,f)=>{$.info("session runtime exited",{agentId:e.agentId,cloudId:r,code:c,signal:f}),mi(s),s.downstream=void 0,s.replySeq=0,s.acpSessionId&&e.activeTriggers.delete(s.acpSessionId),this.rejectPendingForDownstream(a,"downstream exited")}))}hasPendingPermissionFor(e){for(let r of this.pendingUpstream.values())if(r.downstream===e)return!0;return!1}rejectPendingForDownstream(e,r){let s=[];for(let[a,c]of this.pendingUpstream)c.downstream===e&&s.push(a);if(s.length!==0){$.info("reject pendingUpstream entries (downstream gone)",{reason:r,count:s.length});for(let a of s){let c=this.pendingUpstream.get(a);if(c){this.pendingUpstream.delete(a),this.upstream.send(xn(a,{code:Q.INTERNAL_ERROR,message:`bridge downstream gone: ${r}`})).catch(f=>$.debug("send error response to upstream failed (ignored)",{err:String(f)}));try{c.downstream.respondAgentRequestError(c.agentRequestId,{code:Q.INTERNAL_ERROR,message:`bridge: ${r}`})}catch{}}}}}rejectAllPendingOnReconnect(){let e=this.pendingUpstream.size,r=this.pendingBridge.size;if(!(e===0&&r===0)){$.warn("upstream reconnected, rejecting stale pending requests",{pendingUpstream:e,pendingBridge:r});for(let[,s]of this.pendingUpstream)try{s.downstream.respondAgentRequestError(s.agentRequestId,{code:Q.INTERNAL_ERROR,message:"upstream reconnected; please retry"})}catch{}this.pendingUpstream.clear();for(let[,s]of this.pendingBridge)clearTimeout(s.timer),s.reject(new D("UPSTREAM_DISCONNECTED",`${s.method} aborted: upstream reconnected`));this.pendingBridge.clear()}}async handleFrame(e){if(Fs(e)){this.handleUpstreamResponse(e);return}if(!("method"in e)||typeof e.method!="string")return;let r="id"in e&&e.id!==void 0?e.id:null,s=e.params?._meta?.cozeEnv;s&&Q_.test(s)?this.currentCozeEnv=s:s&&$.warn("rejecting cozeEnv with invalid shape, keeping previous",{rejected:s});try{if(e.method.startsWith("_agent/")){let a=this.extensions[e.method];if(!a){r!==null?await this.sendError(r,Q.METHOD_NOT_FOUND,`extension not registered: ${e.method}`):$.warn("drop notification: extension not registered",{method:e.method});return}let c=await a(e,this);r!==null&&await this.upstream.send(mr(r,c));return}if(e.method.startsWith("session/")){let a=await this.routeSessionMethod(e);r!==null&&await this.upstream.send(mr(r,a));return}if(e.method==="initialize"){r!==null&&await this.upstream.send(mr(r,{protocolVersion:1,agentCapabilities:{loadSession:!0}}));return}r!==null?await this.sendError(r,Q.METHOD_NOT_FOUND,`method not implemented: ${e.method}`):$.warn("drop unknown notification",{method:e.method})}catch(a){$.error("handleFrame failed",{method:e.method,err:String(a)}),r!==null&&await this.upstream.send(xn(r,gi(a)))}}async routeSessionMethod(e){if(!e.params||typeof e.params!="object")throw new D("IPC_BAD_REQUEST",`${e.method} requires params`);let r=e.params,s=r._meta?.cozeAgentId;if(!s)throw new D("IPC_BAD_REQUEST",`${e.method}: missing _meta.cozeAgentId`);let a=this.agents.get(s);if(!a)throw this.disconnectedAgents.has(s)?new D("AGENT_DISCONNECTED",`agent ${s} has been disconnected; cloud must _agent/create to revive`):new D("AGENT_NOT_FOUND",`agent not found: ${s}`);let c=typeof r.sessionId=="string"?r.sessionId:void 0;if(e.method==="session/cancel"||e.method==="session/new"||!c)return this.dispatchSessionCall(a,e.method,r);let f=Date.now(),l=!1;try{let x=await a.getSessionQueue(c).enqueue(()=>this.dispatchSessionCall(a,e.method,r));return l=!0,x}finally{$.info("session call done",{agentId:a.agentId,method:e.method,durationMs:Date.now()-f,ok:l})}}async dispatchSessionCall(e,r,s){e.lastActiveAt=Date.now();let{stripped:a}=Vf(s);switch(r){case"session/new":{let c=ty();return $.info("session/new ack (lazy spawn)",{agentId:e.agentId,cloudId:c}),{sessionId:c}}case"session/load":{let c=a;return $.info("session/load ack (lazy spawn)",{agentId:e.agentId,cloudId:c.sessionId}),{}}case"session/prompt":{let c=a,f=c.sessionId;if(!f)throw new D("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 D("BRIDGE_INTERNAL","session runtime not ready after ensureDownstream");let x=s._meta?.cozeTriggerMsgId;x?e.activeTriggers.set(l.acpSessionId,x):e.activeTriggers.delete(l.acpSessionId);let h=$f(s._meta);if(h?e.activeGroupIds.set(l.acpSessionId,h):e.activeGroupIds.delete(l.acpSessionId),e.deployType==="cloud"&&e.modelInfo?.capabilities?.image===!1&&eu(c.prompt))throw new D("MODEL_MODALITY_UNSUPPORTED",`model=${e.modelInfo.id??e.model} does not support image input`);let m=await Ql(c.prompt);try{let E=await l.downstream.sessionPrompt({...c,sessionId:l.acpSessionId,prompt:m});return l.lastActiveAt=Date.now(),E}finally{if(e.activeTriggers.delete(l.acpSessionId),e.activeGroupIds.delete(l.acpSessionId),l.reloadAfterTurn){l.reloadAfterTurn=!1;let E=l.downstream;E&&(l.downstream=void 0,$.info("reloadAfterTurn: stopping downstream",{agentId:e.agentId,cloudId:f,acpId:l.acpSessionId}),E.stop("reload-after-turn").catch(C=>$.warn("reload-after-turn stop failed (ignored)",{agentId:e.agentId,cloudId:f,err:String(C)})))}else l.downstream?.isAlive()&&this.armIdleTimer(e,f,l)}}case"session/cancel":{let f=a.sessionId;if(!f)throw new D("IPC_BAD_REQUEST","session/cancel: missing sessionId");let l=e.sessions.get(f);if(e.hasSessionQueue(f)){let x=e.getSessionQueue(f);x.size>0&&($.info("session/cancel: draining queued tasks",{agentId:e.agentId,cloudId:f,queuedCount:x.size}),x.dispose(new D("AGENT_PROTOCOL_ERROR",`cancelled by session/cancel on ${f}`)))}return l?.downstream?.isAlive()&&l.acpSessionId&&await l.downstream.sessionCancel({sessionId:l.acpSessionId}),{ok:!0}}default:throw new D("IPC_BAD_REQUEST",`session method not supported: ${r}`)}}async ensureRuntime(e,r){let s=e.sessions.get(r);if(s)return s;let c={modelToken:e.deployType==="cloud"?await this.requestSessionToken(e.agentId,r):"",tokenGeneratedAt:Date.now(),lastActiveAt:Date.now(),loadingSession:!1,replySeq:0};return e.sessions.set(r,c),await this.persistSessionMapping(e),c}async requestSessionToken(e,r){let s={sessionId:r,_meta:{cozeAgentId:e}};try{let a=await this.sendRequest(St.GEN_MODEL_TOKEN,s,ey);if(!a?.modelToken)throw new D("MODEL_TOKEN_GEN_FAILED",`cloud returned empty modelToken (agentId=${e}, cloudSessionId=${r})`);return a.modelToken}catch(a){throw a instanceof D&&a.code==="MODEL_TOKEN_GEN_FAILED"?a:new D("MODEL_TOKEN_GEN_FAILED",a instanceof Error?a.message:String(a),{cause:a})}}async ensureDownstream(e,r,s){if(mi(s),s.downstream?.isAlive())return;if(!this.sessionSpawner)throw new D("AGENT_SPAWN_FAILED","sessionSpawner not wired (cannot spawn per-session downstream)");let a=3,c=3e4,f=s.spawnFailCount??0,l=s.spawnFailedAt??0;if(f>=a&&Date.now()-l<c)throw new D("AGENT_SPAWN_FAILED",`agent ${e.agentId} session ${r} spawn failed ${f} times in a row; please check framework binary / network and retry after ${Math.ceil((c-(Date.now()-l))/1e3)}s`);let x;try{x=await this.sessionSpawner(e,s.modelToken,r,this.currentCozeEnv,this.currentMockScenario)}catch(h){throw s.spawnFailCount=f+1,s.spawnFailedAt=Date.now(),s.spawnFailCount>=a&&s.acpSessionId&&($.warn("clearing stale acpSessionId after repeated spawn failures",{agentId:e.agentId,cloudId:r,staleAcpId:s.acpSessionId}),s.acpSessionId=void 0),h}if(s.spawnFailCount=0,s.spawnFailedAt=void 0,s.downstream=x,this.attachRuntimeHooks(e,r,s),s.acpSessionId){s.loadingSession=!0;try{await x.sessionLoad({sessionId:s.acpSessionId,cwd:e.workspace}),$.info("session restored via session/load",{agentId:e.agentId,cloudId:r,acpId:s.acpSessionId})}catch(h){$.warn("session/load failed, fallback to session/new",{agentId:e.agentId,cloudId:r,acpId:s.acpSessionId,err:String(h)}),s.acpSessionId=void 0;let m=await x.sessionNew({cwd:e.workspace});s.acpSessionId=m.sessionId,await this.persistSessionMapping(e)}finally{s.loadingSession=!1}}else{let h=await x.sessionNew({cwd:e.workspace});s.acpSessionId=h.sessionId,await this.persistSessionMapping(e)}x.afterSessionEstablished&&s.acpSessionId&&await x.afterSessionEstablished(s.acpSessionId)}armIdleTimer(e,r,s){if(mi(s),this.isRuntimeBusy(e,s)){$.debug("skip idle timer: runtime busy (in-flight turn / pending permission)",{agentId:e.agentId,cloudId:r});return}s.idleTimer=setTimeout(()=>{if(s.idleTimer=void 0,this.isRuntimeBusy(e,s)){$.info("idle reaper fired but runtime busy, re-arming",{agentId:e.agentId,cloudId:r}),this.armIdleTimer(e,r,s);return}$.info("session runtime idle timeout, killing downstream",{agentId:e.agentId,cloudId:r});let a=s.downstream;s.downstream=void 0,s.acpSessionId&&e.activeTriggers.delete(s.acpSessionId),a&&a.stop("idle timeout").catch(c=>$.warn("idle stop failed (ignored)",{agentId:e.agentId,cloudId:r,err:String(c)}))},this.sessionIdleTimeoutMs),s.idleTimer.unref?.()}isRuntimeBusy(e,r){if(r.acpSessionId&&e.activeTriggers.has(r.acpSessionId))return!0;let s=r.downstream;if(!s)return!1;for(let a of this.pendingUpstream.values())if(a.downstream===s)return!0;return!1}async sendAgentFileUpdate(e,r,s,a){let c={cozeAgentId:e.agentId,cozeReplySeqID:++r.replySeq};if(r.acpSessionId){let f=e.activeTriggers.get(r.acpSessionId);f&&(c.cozeTriggerMsgId=f);let l=e.activeGroupIds.get(r.acpSessionId);l&&(c.cozeGroupId=l)}await this.upstream.send(hi("session/update",{sessionId:s,update:a,_meta:c}))}forwardUpdate(e,r){let s=r.sessionId,a=this.reverseSessionId(e,s);if(!a){$.debug("drop update for unknown session",{agentId:e.agentId,acpId:s});return}let c=e.sessions.get(a);if(!c){$.debug("drop update: runtime gone",{agentId:e.agentId,cloudId:a});return}if(ry(r)){$.debug("drop codex metadata-warn chunk",{agentId:e.agentId,acpId:s});return}let f={cozeAgentId:e.agentId,cozeReplySeqID:++c.replySeq},l=e.activeTriggers.get(s);l&&(f.cozeTriggerMsgId=l);let x=e.activeGroupIds.get(s);x&&(f.cozeGroupId=x),this.upstream.send(hi("session/update",{...r,sessionId:a,_meta:f})).catch(h=>$.warn("forward update failed",{agentId:e.agentId,err:String(h)}))}handleAgentRequest(e,r,s){if(s.method==="session/request_permission"){this.forwardPermissionRequest(e,r,s);return}if(s.method==="fs/write_text_file"||s.method==="fs/read_text_file"){this.handleFsRpcRequest(e,r,s);return}$.warn("unhandled agent request,returning method_not_found",{agentId:e.agentId,method:s.method}),r.respondAgentRequestError(s.id,{code:Q.METHOD_NOT_FOUND,message:`method not handled by Bridge: ${s.method}`})}async handleFsRpcRequest(e,r,s){try{let a=e.workspace;if(s.method==="fs/write_text_file"){let c=s.params??{},f=await Vl(c,a);r.respondAgentRequest(s.id,f)}else{let c=s.params??{},f=await Jl(c,a);r.respondAgentRequest(s.id,f)}}catch(a){$.warn("fs rpc handler failed",{agentId:e.agentId,method:s.method,err:String(a)}),r.respondAgentRequestError(s.id,gi(a))}}forwardPermissionRequest(e,r,s){let a=this.upstreamIds.next("session/request_permission"),c=s.params??{},l=c.sessionId,x=l?e.activeTriggers.get(l):void 0,h={cozeAgentId:e.agentId};x&&(h.cozeTriggerMsgId=x);let m=l?e.activeGroupIds.get(l):void 0;m&&(h.cozeGroupId=m);let E=l?this.reverseSessionId(e,l):void 0,C={...c,...E?{sessionId:E}:{},_meta:h};this.pendingUpstream.set(a,{agentRequestId:s.id,agentId:e.agentId,downstream:r,method:s.method}),$.info("forward permission_request \u2192 upstream",{agentId:e.agentId,upstreamId:a,acpSessionId:l,cloudSessionId:E,toolCallId:c.toolCall?.toolCallId,options:c.options?.map(_=>({optionId:_.optionId,kind:_.kind,name:_.name}))}),this.upstream.send(xi(a,"session/request_permission",C)).catch(_=>{this.pendingUpstream.delete(a),$.error("forward permission request failed",{agentId:e.agentId,err:String(_)}),r.respondAgentRequestError(s.id,{code:Q.INTERNAL_ERROR,message:`upstream send failed: ${String(_)}`})})}handleUpstreamResponse(e){if(e.id===null)return;let r=this.lookupPending(this.pendingUpstream,e.id,"upstream");if(r){this.pendingUpstream.delete(r.key);let a=r.value;e.error?($.info("upstream \u2192 permission response (error)",{agentId:a.agentId,upstreamId:e.id,method:a.method,error:e.error}),a.downstream.respondAgentRequestError(a.agentRequestId,e.error)):(a.method==="session/request_permission"&&ny(e.result,a),$.info("upstream \u2192 permission response (result)",{agentId:a.agentId,upstreamId:e.id,method:a.method,result:e.result}),a.downstream.respondAgentRequest(a.agentRequestId,e.result));return}let s=this.lookupPending(this.pendingBridge,e.id,"bridge");if(s){this.pendingBridge.delete(s.key),clearTimeout(s.value.timer),e.error?s.value.reject(new zs(e.error)):s.value.resolve(e.result);return}$.debug("orphan upstream response (no pending)",{id:e.id})}lookupPending(e,r,s){let a=e.get(r);if(a)return{value:a,key:r};if(typeof r=="number"){let c=String(r),f=e.get(c);if(f)return $.warn(`${s} id type mismatch: number received but Bridge expected string`,{rawId:r,normalizedId:c}),{value:f,key:c}}}sendRequest(e,r,s=X_){let a=this.upstreamIds.next(e);return new Promise((c,f)=>{let l=setTimeout(()=>{this.pendingBridge.delete(a),f(new D("AGENT_TIMEOUT",`${e} timed out after ${s}ms`))},s);this.pendingBridge.set(a,{method:e,resolve:c,reject:f,timer:l}),this.upstream.send(xi(a,e,r)).catch(x=>{let h=this.pendingBridge.get(a);h&&(clearTimeout(h.timer),this.pendingBridge.delete(a)),f(x)})})}async persistSessionMapping(e){if(this.paths)try{let r=new Map;for(let[s,a]of e.sessions){let c={modelToken:a.modelToken,tokenGeneratedAt:a.tokenGeneratedAt};a.acpSessionId&&(c.acpSessionId=a.acpSessionId),r.set(s,c)}await Zo(e.agentId,r,this.paths)}catch(r){$.warn("persist session mapping failed",{agentId:e.agentId,err:String(r)})}}reverseSessionId(e,r){for(let[s,a]of e.sessions.entries())if(a.acpSessionId===r)return s}sendError(e,r,s){return this.upstream.send(xn(e,{code:r,message:s,data:{bridgeVersion:gr}}))}};function ty(){return Y_(16).toString("hex")}function ny(t,e){if(!t||typeof t!="object"){$.warn("permission response: result not an object (suspicious)",{agentId:e.agentId,result:t});return}let r=t;if("kind"in r&&!("outcome"in r)){$.warn('permission response: top-level "kind" field (D66 historical bug shape)',{agentId:e.agentId,result:t});return}let s=r.outcome;if(!s||typeof s!="object"){$.warn("permission response: missing or non-object outcome field",{agentId:e.agentId,result:t});return}let c=s.outcome;(typeof c!="string"||c!=="selected"&&c!=="cancelled")&&$.warn("permission response: unknown outcome discriminant",{agentId:e.agentId,outcomeValue:c,result:t})}function ry(t){let e=t.update;if(e?.sessionUpdate!=="agent_message_chunk")return!1;let r=e.content;if(!r||typeof r!="object")return!1;let s=r;return s.type!=="text"||typeof s.text!="string"?!1:s.text.startsWith("Model metadata for `")}ee();Me();import{randomBytes as iy}from"node:crypto";import{chmod as sy,mkdir as oy,writeFile as tu}from"node:fs/promises";import{createServer as ay}from"node:http";import{dirname as cy}from"node:path";var dy=1e6,vc=H("ipc"),Ys=class{server=null;port=0;token="";routes;paths;constructor(e){this.routes=new Map(e.routes.map(r=>[`${r.method} ${r.path}`,r])),this.paths=e.paths??te()}async start(){this.token=iy(32).toString("hex");let e=ay((s,a)=>{this.dispatch(s,a)});this.server=e,await new Promise((s,a)=>{e.once("error",a),e.listen(0,"127.0.0.1",()=>s())});let r=e.address();if(!r||typeof r!="object")throw new Error("failed to obtain IPC port");return this.port=r.port,await this.persistAuthFiles(),vc.info("IPC listening",{port:this.port}),{port:this.port,token:this.token}}async stop(){let e=this.server;e&&(await new Promise((r,s)=>{e.close(a=>a?s(a):r())}),this.server=null)}async persistAuthFiles(){await oy(cy(this.paths.portFile),{recursive:!0}),await tu(this.paths.portFile,String(this.port),"utf8"),await tu(this.paths.tokenFile,this.token,{encoding:"utf8",mode:384});try{await sy(this.paths.tokenFile,384)}catch(e){vc.warn("chmod token file failed (non-POSIX?)",{err:String(e)})}}async dispatch(e,r){if(e.headers.authorization!==`Bearer ${this.token}`){yi(r,401,{error:"unauthorized"});return}let a=`${e.method} ${(e.url??"").split("?")[0]}`,c=this.routes.get(a);if(!c){yi(r,404,{error:"not found"});return}let f=null;if(e.method==="POST")try{f=await fy(e)}catch(l){yi(r,400,{error:"invalid json",detail:String(l)});return}try{let l=await c.handler(f,e);yi(r,200,l??{ok:!0})}catch(l){vc.error("IPC handler failed",{key:a,err:String(l)}),yi(r,500,{error:l instanceof Error?l.message:String(l)})}}};function yi(t,e,r){t.statusCode=e,t.setHeader("content-type","application/json"),t.end(JSON.stringify(r))}async function fy(t){let e=[],r=0;for await(let a of t){let c=a;if(r+=c.length,r>dy)throw new Error("body too large");e.push(c)}let s=Buffer.concat(e).toString("utf8");return s?JSON.parse(s):null}var vx=gt(uu(),1);var GE=gt(ax(),1),KE=gt(ho(),1),WE=gt(vr(),1),$E=gt(Bc(),1),VE=gt(Uc(),1),JE=gt(Wc(),1),gx=gt(wo(),1),ZE=gt(px(),1);var mx=gx.default;ee();var Ie=H("upstream.frontier"),yx="application/json",Ex="none",XE=15e3,Di=class{constructor(e){this.opts=e}opts;fws=null;handler=null;connectHandlers=[];opened=!1;lastSendRefusedLogAt=0;sendRefusedSuppressed=0;openCount=0;async start(){if(this.fws){Ie.warn("start called on already-started FrontierUpstream; noop");return}let e={Authorization:`Bearer ${this.opts.privatecode}`,Origin:Yf,...hr(this.opts.ppeOverride)};class r extends mx{constructor(y){super(y,Zf,{headers:e})}send(y,...v){if(P0("debug"))try{let I;typeof y=="string"?I=Buffer.from(y,"utf8"):y instanceof Buffer?I=y:y instanceof ArrayBuffer?I=new Uint8Array(y):ArrayBuffer.isView(y)?I=new Uint8Array(y.buffer,y.byteOffset,y.byteLength):I=new Uint8Array(0);let R=Buffer.from(I.slice(0,128)).toString("hex");Ie.debug("WS raw frame out",{bytes:I.byteLength,headHex:R})}catch(I){Ie.warn("WS raw frame dump failed",{err:String(I)})}super.send(y,...v)}}let s=Qf(this.opts.urlOverride),a={url:s,ws:r,fpID:Jf,aID:Ns,accessKey:this.opts.handshake.accessKey,deviceID:this.opts.handshake.deviceId,payloadType:{type:yx,force:!0},payloadEncoding:{encoding:Ex,force:!0},enableTransformTextPayload:!0,enableQoS:!1,enableAutoAck:!1,automaticOpen:!1,maxRetries:Number.POSITIVE_INFINITY,debug:this.opts.debug??!1},c=new vx.FWS(a),f=!1,l=null,x,h,m=new Promise((_,y)=>{x=_,h=y}),E=_=>{f||(f=!0,l&&(clearTimeout(l),l=null),_?h(_):x())};c.onopen=()=>{this.opened=!0,this.openCount+=1;let _=this.openCount===1;Ie.info("frontier opened",{url:s,remoteDeviceId:this.opts.handshake.deviceId,initial:_,openCount:this.openCount}),_&&E();for(let y of this.connectHandlers)Promise.resolve(y({initial:_})).catch(v=>Ie.warn("onConnect handler threw (ignored)",{err:String(v)}))},c.onclose=_=>{this.opened=!1,Ie.info("frontier closed",{code:_.code,reason:_.reason,willReconnect:_.willReconnect})},c.onerror=_=>{Ie.warn("frontier error",{code:_.code,msg:_.message}),E(new D("UPSTREAM_DISCONNECTED",`frontier connect error before open: code=${_.code} msg=${_.message??""}`))},c.onmessage=_=>this.handleMessage(_),this.fws=c;let C=this.opts.openTimeoutMs??XE;l=setTimeout(()=>{E(new D("UPSTREAM_DISCONNECTED",`frontier ws open timeout after ${C}ms (handshake or upgrade slow)`))},C),await c.connect();try{await m}catch(_){try{c.close(1e3,"open failed")}catch(y){Ie.warn("fws close during start failure threw (ignored)",{err:String(y)})}throw this.fws=null,this.opened=!1,_}}async stop(e){let r=this.fws;if(r){this.fws=null,this.opened=!1;try{r.close(1e3,e??"bridge shutdown")}catch(s){Ie.warn("frontier close threw (ignored)",{err:String(s)})}}}async send(e){let r=this.fws,s=e.method;if(!r)throw Ie.warn("frontier send refused: upstream not started",{method:s}),new D("UPSTREAM_DISCONNECTED","frontier upstream not started");if(!this.isConnected()){let l=Date.now();throw l-this.lastSendRefusedLogAt>1e3?(Ie.warn("frontier send refused: ws not open",{method:s,opened:this.opened,readyState:r.readyState,...this.sendRefusedSuppressed>0?{suppressedSinceLast:this.sendRefusedSuppressed}:{}}),this.lastSendRefusedLogAt=l,this.sendRefusedSuppressed=0):this.sendRefusedSuppressed+=1,new D("UPSTREAM_DISCONNECTED",`frontier ws not open (opened=${this.opened}, readyState=${r.readyState}); refusing to silently buffer`)}this.injectAgentPatToken(e);let a=JSON.stringify(e),c=e;bx(c)||Ie.info("frontier frame out",{method:c.method,jsonrpcId:c.id,size:a.length});try{await r.send(a,{service:33555712,method:1,payloadType:yx,payloadEncoding:Ex})}catch(l){throw Ie.warn("frontier frame send failed",{method:c.method,jsonrpcId:c.id,err:String(l)}),new D("UPSTREAM_DISCONNECTED",`frontier send failed: ${String(l)}`,{cause:l})}}onFrame(e){this.handler=e}onConnect(e){this.connectHandlers.push(e)}isConnected(){return this.opened&&this.fws?.readyState===1}injectAgentPatToken(e){let r=this.opts.getPatTokenForAgent;if(!r)return;let s=e.params?._meta;if(!s?.cozeAgentId)return;let a=r(s.cozeAgentId);a&&(s.cozePatToken=a)}handleMessage(e){let r=e.message?.service;if(r!==33555712){Ie.debug("drop non-adapter frontier frame",{service:r});return}let s=tb(e);if(!s){Ie.debug("frontier message without text payload, drop",{payloadType:e.message?.payloadType});return}if(!this.handler){Ie.debug("frame received but no onFrame handler",{size:s.length});return}let a;try{a=JSON.parse(s)}catch(f){Ie.warn("frontier message JSON parse failed",{err:String(f),head:s.slice(0,80)});return}let c=a;bx(c)||Ie.info("frontier frame in",{logid:eb(e.message?.LogID),logidNew:e.message?.LogIDNew,msgId:e.message?.msgID,jsonrpcId:c.id,method:c.method,body:QE(s)}),Promise.resolve(this.handler(a)).catch(f=>Ie.warn("frontier frame handler threw",{err:String(f)}))}};function bx(t){return t.method==="_agent/health"?!0:typeof t.id=="string"&&t.id.startsWith("agent.health_")}var Sx=2e3;function QE(t){return t.length<=Sx?t:`${t.slice(0,Sx)}...<truncated, total ${t.length} chars>`}function eb(t){return t?t.high===0?String(t.low>>>0):`${t.high.toString(16)}${(t.low>>>0).toString(16).padStart(8,"0")}`:""}function tb(t){let e=t.message;if(e?.textPayload)return e.textPayload;let r=e?.payload;if(!r)return null;try{return Buffer.from(r).toString("utf8")}catch{return null}}ee();var Vc=H("upstream.switchable"),yo=class{inner;handler=null;connectHandlers=[];constructor(e){this.inner=e}async swap(e,r){if(this.inner===e)return;Vc.info("swap upstream",{reason:r});let s=this.inner;if(this.inner=e,this.handler&&e.onFrame(this.handler),e.onConnect)for(let a of this.connectHandlers)e.onConnect(a);try{await e.start()}catch(a){throw Vc.error("swap target start failed, reverting",{err:String(a)}),this.inner=s,a}await s.stop(r??"swapped").catch(a=>Vc.warn("previous upstream stop threw (ignored)",{err:String(a)}))}current(){return this.inner}start(){return this.inner.start()}stop(e){return this.inner.stop(e)}send(e){return this.inner.send(e)}onFrame(e){this.handler=e,this.inner.onFrame(e)}onConnect(e){this.connectHandlers.push(e),this.inner.onConnect?.(e)}isConnected(){return this.inner.isConnected()}};ee();var Jc=H("upstream"),Rr=class{handler=null;async start(){Jc.info("NoopUpstream started (M1 skeleton; real Frontier wired in M4)")}async stop(e){Jc.info("NoopUpstream stopped",{reason:e})}async send(e){Jc.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)}};ee();ee();Me();import{promises as Zc}from"node:fs";import{dirname as nb}from"node:path";var rb=H("pat-token-store");async function Ix(t=te()){try{let r=(await Zc.readFile(t.patTokenFile,"utf8")).trim();return r.length>0?r:null}catch(e){let r=e?.code;return r!=="ENOENT"&&rb.warn("read pat-token failed (treating as missing)",{path:t.patTokenFile,code:r,message:e.message}),null}}async function Ri(t,e=te()){if(!t)throw new Error("writePatToken: empty patToken");await Zc.mkdir(nb(e.patTokenFile),{recursive:!0}),await Zc.writeFile(e.patTokenFile,t,{encoding:"utf8",mode:384})}Me();Me();import{promises as Eo}from"node:fs";import{join as ib}from"node:path";function sb(t,e){return`#!/bin/sh
80
+ `},configPath(t){return zb(t.homeDir,".coze","bridge","task.xml")},async install(t){let r=`cmd.exe /c ${[`^"${t.nodeBin}^"`,`^"${t.entry}^"`,"--daemon",`>> ^"${t.logFile}^" 2>&1`].join(" ")}`;await Ux("schtasks",["/Create","/SC","ONLOGON","/TN",Lo,"/TR",r,"/RU",t.userName,"/F"]),s0.info("task scheduler entry created",{task:Lo,logFile:t.logFile})},async uninstall(t){await Ux("schtasks",["/Delete","/TN",Lo,"/F"]).catch(e=>s0.warn("schtasks /Delete failed (ignored)",{err:String(e)})),s0.info("task scheduler entry removed",{task:Lo})}}});var Hx={};Ko(Hx,{buildContext:()=>Hb,getSupervisor:()=>qb,launchdSupervisor:()=>r0,systemdSupervisor:()=>i0,taskSchedulerSupervisor:()=>o0});import{homedir as Fb,userInfo as Ub}from"node:os";function qb(t=process.platform){switch(t){case"darwin":return r0;case"linux":return i0;case"win32":return o0;default:throw new Error(`unsupported platform for OS supervisor: ${t}`)}}function Hb(){let t=te();return{nodeBin:process.execPath,entry:Yc(t),logFile:t.logFile,homeDir:Fb(),userName:Ub().username}}var Gx=nt(()=>{"use strict";Me();Xc();zx();Fx();qx()});ee();gn();var U0=G("acp-installer-warmup"),pp=["claude-code","codex"];async function q0(t={}){let e=t.ensure??Kn,i=(await Promise.allSettled(pp.map(async o=>{let c=await e(o);U0.info("acp wrapper warmup ok",{framework:o,path:c})}))).filter(o=>o.status==="rejected");i.length>0&&U0.warn("acp wrapper warmup partial failure (\u5C06\u5728\u4E0B\u6B21 createAgent \u65F6\u91CD\u8BD5\u5E76\u629B\u9519\u7ED9\u7528\u6237)",{failedCount:i.length,reasons:i.map(o=>o.reason instanceof Error?o.reason.message:String(o.reason))})}$t();ee();import{readdir as Ap}from"node:fs/promises";import{mkdir as V0,writeFile as $0}from"node:fs/promises";import{join as Zo}from"node:path";var Ip={"claude-code":"CLAUDE.md",codex:"AGENTS.md",openclaw:"SOUL.md"};async function Vn(t,e,r){await V0(t,{recursive:!0});let i=Ip[e],o=Zo(t,i);return await $0(o,r??"","utf8"),o}async function J0(t){let e=Zo(t,".claude");await V0(e,{recursive:!0});let r=Zo(e,"settings.local.json"),i=JSON.stringify({permissions:{defaultMode:"bypassPermissions"}},null,2);return await $0(r,i,"utf8"),r}var $e=G("agent-detail-sync"),Tp=6e4,Cp=5*6e4,ji=class{constructor(e){this.opts=e}opts;retryQueue=new Map;async syncAll(e){let r=this.opts.paths.agentsRoot,i;try{i=await Ap(r)}catch(o){$e.info("agents dir not found, skip detail sync",{root:r,err:String(o)});return}$e.info("starting detail sync",{reason:e,count:i.length}),await Promise.allSettled(i.map(async o=>{let c=await Ue(o,this.opts.paths).catch(()=>null);if(c){if(c.disconnectedAt){$e.debug("detail sync: skip disconnected agent",{agentId:o});return}try{await this.syncOne(o,c)}catch(f){$e.warn("detail sync failed for agent, skipping",{agentId:o,err:String(f)})}}})),$e.info("detail sync done",{reason:e})}async retryPending(){if(this.retryQueue.size===0)return;let e=Date.now(),r=[];for(let[i,o]of this.retryQueue)e>=o.dueAt&&r.push(i);if(r.length!==0){$e.info("retrying pending detail syncs",{count:r.length});for(let i of r)try{await this.syncOne(i)}catch(o){$e.debug("detail sync retry still failing, will try again",{agentId:i,err:String(o)})}}}async syncOne(e,r){let i=r??await Ue(e,this.opts.paths);if(!i){$e.info("detail sync: agent config missing, skip",{agentId:e});return}let o;try{o=await this.opts.sendDetail({_meta:{cozeAgentId:e}}),this.retryQueue.delete(e)}catch(l){$e.warn("detail RPC failed, using local data",{agentId:e,err:String(l)});let x=this.retryQueue.get(e),p=x?Math.min(x.currentDelay*2,Cp):Tp;this.retryQueue.set(e,{dueAt:Date.now()+p,currentDelay:p});return}if(o.agentId&&o.agentId!==e){$e.warn("detail response agentId mismatch, ignoring",{agentId:e,responseAgentId:o.agentId});return}let c=!1,f=!1;if(o.agentName&&o.agentName!==i.agentName&&(i.agentName=o.agentName,c=!0),o.description!==void 0&&o.description!==i.description&&(i.description=o.description,c=!0),o.cozeIdentity&&o.cozeIdentity!==i.cozeIdentity&&(i.cozeIdentity=o.cozeIdentity,c=!0,f=!0),o.deployType&&$e.info("detail.deployType",{agentId:e,deployType:o.deployType}),!c){$e.debug("detail sync: no diff",{agentId:e});return}await Ve(i,this.opts.paths),$e.info("detail sync: config updated",{agentId:e,identityChanged:f,agentName:i.agentName}),f&&(await Vn(i.workspace,i.framework,i.cozeIdentity),this.opts.handlers.reloadAgentSessionsPublic(e,"detail-sync"))}};var lu=pt(Cd(),1);import{lstat as fc,mkdir as uc,readFile as cu,readdir as ew,rm as tw,stat as nw,writeFile as lc}from"node:fs/promises";import{dirname as rw,join as St,normalize as iw,relative as pc,resolve as xc,sep as du}from"node:path";import{Readable as fu}from"node:stream";import{pipeline as uu}from"node:stream/promises";import Yp from"events";import Ke from"fs";import{EventEmitter as Ya}from"node:events";import ff from"node:stream";import{StringDecoder as Zp}from"node:string_decoder";import xf from"node:path";import sr from"node:fs";import{dirname as fg,parse as ug}from"path";import{EventEmitter as _g}from"events";import ka from"assert";import{Buffer as Tn}from"buffer";import*as Pd from"zlib";import yg from"zlib";import{posix as Xn}from"node:path";import{basename as Vg}from"node:path";import Es from"fs";import _t from"fs";import Ud from"path";import{win32 as im}from"node:path";import Vd from"path";import Cf from"node:fs";import bm from"node:assert";import{randomBytes as Rf}from"node:crypto";import X from"node:fs";import ve from"node:path";import Df from"fs";import ks from"node:fs";import Xr from"node:path";import Ze from"node:fs";import Cm from"node:fs/promises";import Is from"node:path";import{join as qf}from"node:path";import Ye from"node:fs";import jf from"node:path";var $p=Object.defineProperty,Jp=(t,e)=>{for(var r in e)$p(t,r,{get:e[r],enumerable:!0})},Rd=typeof process=="object"&&process?process:{stdout:null,stderr:null},Xp=t=>!!t&&typeof t=="object"&&(t instanceof Dn||t instanceof ff||Qp(t)||eg(t)),Qp=t=>!!t&&typeof t=="object"&&t instanceof Ya&&typeof t.pipe=="function"&&t.pipe!==ff.Writable.prototype.pipe,eg=t=>!!t&&typeof t=="object"&&t instanceof Ya&&typeof t.write=="function"&&typeof t.end=="function",kt=Symbol("EOF"),Lt=Symbol("maybeEmitEnd"),Yt=Symbol("emittedEnd"),Ji=Symbol("emittingEnd"),Nr=Symbol("emittedError"),Yi=Symbol("closed"),Dd=Symbol("read"),Zi=Symbol("flush"),kd=Symbol("flushChunk"),dt=Symbol("encoding"),Zn=Symbol("decoder"),Te=Symbol("flowing"),Mr=Symbol("paused"),nr=Symbol("resume"),Ce=Symbol("buffer"),Ge=Symbol("pipes"),Re=Symbol("bufferLength"),ra=Symbol("bufferPush"),Xi=Symbol("bufferShift"),qe=Symbol("objectMode"),me=Symbol("destroyed"),ia=Symbol("error"),sa=Symbol("emitData"),Ld=Symbol("emitEnd"),oa=Symbol("emitEnd2"),gt=Symbol("async"),aa=Symbol("abort"),Qi=Symbol("aborted"),Br=Symbol("signal"),wn=Symbol("dataListeners"),Je=Symbol("discarded"),zr=t=>Promise.resolve().then(t),tg=t=>t(),ng=t=>t==="end"||t==="finish"||t==="prefinish",rg=t=>t instanceof ArrayBuffer||!!t&&typeof t=="object"&&t.constructor&&t.constructor.name==="ArrayBuffer"&&t.byteLength>=0,ig=t=>!Buffer.isBuffer(t)&&ArrayBuffer.isView(t),uf=class{src;dest;opts;ondrain;constructor(t,e,r){this.src=t,this.dest=e,this.opts=r,this.ondrain=()=>t[nr](),this.dest.on("drain",this.ondrain)}unpipe(){this.dest.removeListener("drain",this.ondrain)}proxyErrors(t){}end(){this.unpipe(),this.opts.end&&this.dest.end()}},sg=class extends uf{unpipe(){this.src.removeListener("error",this.proxyErrors),super.unpipe()}constructor(t,e,r){super(t,e,r),this.proxyErrors=i=>this.dest.emit("error",i),t.on("error",this.proxyErrors)}},og=t=>!!t.objectMode,ag=t=>!t.objectMode&&!!t.encoding&&t.encoding!=="buffer",Dn=class extends Ya{[Te]=!1;[Mr]=!1;[Ge]=[];[Ce]=[];[qe];[dt];[gt];[Zn];[kt]=!1;[Yt]=!1;[Ji]=!1;[Yi]=!1;[Nr]=null;[Re]=0;[me]=!1;[Br];[Qi]=!1;[wn]=0;[Je]=!1;writable=!0;readable=!0;constructor(...t){let e=t[0]||{};if(super(),e.objectMode&&typeof e.encoding=="string")throw new TypeError("Encoding and objectMode may not be used together");og(e)?(this[qe]=!0,this[dt]=null):ag(e)?(this[dt]=e.encoding,this[qe]=!1):(this[qe]=!1,this[dt]=null),this[gt]=!!e.async,this[Zn]=this[dt]?new Zp(this[dt]):null,e&&e.debugExposeBuffer===!0&&Object.defineProperty(this,"buffer",{get:()=>this[Ce]}),e&&e.debugExposePipes===!0&&Object.defineProperty(this,"pipes",{get:()=>this[Ge]});let{signal:r}=e;r&&(this[Br]=r,r.aborted?this[aa]():r.addEventListener("abort",()=>this[aa]()))}get bufferLength(){return this[Re]}get encoding(){return this[dt]}set encoding(t){throw new Error("Encoding must be set at instantiation time")}setEncoding(t){throw new Error("Encoding must be set at instantiation time")}get objectMode(){return this[qe]}set objectMode(t){throw new Error("objectMode must be set at instantiation time")}get async(){return this[gt]}set async(t){this[gt]=this[gt]||!!t}[aa](){this[Qi]=!0,this.emit("abort",this[Br]?.reason),this.destroy(this[Br]?.reason)}get aborted(){return this[Qi]}set aborted(t){}write(t,e,r){if(this[Qi])return!1;if(this[kt])throw new Error("write after end");if(this[me])return this.emit("error",Object.assign(new Error("Cannot call write after a stream was destroyed"),{code:"ERR_STREAM_DESTROYED"})),!0;typeof e=="function"&&(r=e,e="utf8"),e||(e="utf8");let i=this[gt]?zr:tg;if(!this[qe]&&!Buffer.isBuffer(t)){if(ig(t))t=Buffer.from(t.buffer,t.byteOffset,t.byteLength);else if(rg(t))t=Buffer.from(t);else if(typeof t!="string")throw new Error("Non-contiguous data written to non-objectMode stream")}return this[qe]?(this[Te]&&this[Re]!==0&&this[Zi](!0),this[Te]?this.emit("data",t):this[ra](t),this[Re]!==0&&this.emit("readable"),r&&i(r),this[Te]):t.length?(typeof t=="string"&&!(e===this[dt]&&!this[Zn]?.lastNeed)&&(t=Buffer.from(t,e)),Buffer.isBuffer(t)&&this[dt]&&(t=this[Zn].write(t)),this[Te]&&this[Re]!==0&&this[Zi](!0),this[Te]?this.emit("data",t):this[ra](t),this[Re]!==0&&this.emit("readable"),r&&i(r),this[Te]):(this[Re]!==0&&this.emit("readable"),r&&i(r),this[Te])}read(t){if(this[me])return null;if(this[Je]=!1,this[Re]===0||t===0||t&&t>this[Re])return this[Lt](),null;this[qe]&&(t=null),this[Ce].length>1&&!this[qe]&&(this[Ce]=[this[dt]?this[Ce].join(""):Buffer.concat(this[Ce],this[Re])]);let e=this[Dd](t||null,this[Ce][0]);return this[Lt](),e}[Dd](t,e){if(this[qe])this[Xi]();else{let r=e;t===r.length||t===null?this[Xi]():typeof r=="string"?(this[Ce][0]=r.slice(t),e=r.slice(0,t),this[Re]-=t):(this[Ce][0]=r.subarray(t),e=r.subarray(0,t),this[Re]-=t)}return this.emit("data",e),!this[Ce].length&&!this[kt]&&this.emit("drain"),e}end(t,e,r){return typeof t=="function"&&(r=t,t=void 0),typeof e=="function"&&(r=e,e="utf8"),t!==void 0&&this.write(t,e),r&&this.once("end",r),this[kt]=!0,this.writable=!1,(this[Te]||!this[Mr])&&this[Lt](),this}[nr](){this[me]||(!this[wn]&&!this[Ge].length&&(this[Je]=!0),this[Mr]=!1,this[Te]=!0,this.emit("resume"),this[Ce].length?this[Zi]():this[kt]?this[Lt]():this.emit("drain"))}resume(){return this[nr]()}pause(){this[Te]=!1,this[Mr]=!0,this[Je]=!1}get destroyed(){return this[me]}get flowing(){return this[Te]}get paused(){return this[Mr]}[ra](t){this[qe]?this[Re]+=1:this[Re]+=t.length,this[Ce].push(t)}[Xi](){return this[qe]?this[Re]-=1:this[Re]-=this[Ce][0].length,this[Ce].shift()}[Zi](t=!1){do;while(this[kd](this[Xi]())&&this[Ce].length);!t&&!this[Ce].length&&!this[kt]&&this.emit("drain")}[kd](t){return this.emit("data",t),this[Te]}pipe(t,e){if(this[me])return t;this[Je]=!1;let r=this[Yt];return e=e||{},t===Rd.stdout||t===Rd.stderr?e.end=!1:e.end=e.end!==!1,e.proxyErrors=!!e.proxyErrors,r?e.end&&t.end():(this[Ge].push(e.proxyErrors?new sg(this,t,e):new uf(this,t,e)),this[gt]?zr(()=>this[nr]()):this[nr]()),t}unpipe(t){let e=this[Ge].find(r=>r.dest===t);e&&(this[Ge].length===1?(this[Te]&&this[wn]===0&&(this[Te]=!1),this[Ge]=[]):this[Ge].splice(this[Ge].indexOf(e),1),e.unpipe())}addListener(t,e){return this.on(t,e)}on(t,e){let r=super.on(t,e);if(t==="data")this[Je]=!1,this[wn]++,!this[Ge].length&&!this[Te]&&this[nr]();else if(t==="readable"&&this[Re]!==0)super.emit("readable");else if(ng(t)&&this[Yt])super.emit(t),this.removeAllListeners(t);else if(t==="error"&&this[Nr]){let i=e;this[gt]?zr(()=>i.call(this,this[Nr])):i.call(this,this[Nr])}return r}removeListener(t,e){return this.off(t,e)}off(t,e){let r=super.off(t,e);return t==="data"&&(this[wn]=this.listeners("data").length,this[wn]===0&&!this[Je]&&!this[Ge].length&&(this[Te]=!1)),r}removeAllListeners(t){let e=super.removeAllListeners(t);return(t==="data"||t===void 0)&&(this[wn]=0,!this[Je]&&!this[Ge].length&&(this[Te]=!1)),e}get emittedEnd(){return this[Yt]}[Lt](){!this[Ji]&&!this[Yt]&&!this[me]&&this[Ce].length===0&&this[kt]&&(this[Ji]=!0,this.emit("end"),this.emit("prefinish"),this.emit("finish"),this[Yi]&&this.emit("close"),this[Ji]=!1)}emit(t,...e){let r=e[0];if(t!=="error"&&t!=="close"&&t!==me&&this[me])return!1;if(t==="data")return!this[qe]&&!r?!1:this[gt]?(zr(()=>this[sa](r)),!0):this[sa](r);if(t==="end")return this[Ld]();if(t==="close"){if(this[Yi]=!0,!this[Yt]&&!this[me])return!1;let o=super.emit("close");return this.removeAllListeners("close"),o}else if(t==="error"){this[Nr]=r,super.emit(ia,r);let o=!this[Br]||this.listeners("error").length?super.emit("error",r):!1;return this[Lt](),o}else if(t==="resume"){let o=super.emit("resume");return this[Lt](),o}else if(t==="finish"||t==="prefinish"){let o=super.emit(t);return this.removeAllListeners(t),o}let i=super.emit(t,...e);return this[Lt](),i}[sa](t){for(let r of this[Ge])r.dest.write(t)===!1&&this.pause();let e=this[Je]?!1:super.emit("data",t);return this[Lt](),e}[Ld](){return this[Yt]?!1:(this[Yt]=!0,this.readable=!1,this[gt]?(zr(()=>this[oa]()),!0):this[oa]())}[oa](){if(this[Zn]){let e=this[Zn].end();if(e){for(let r of this[Ge])r.dest.write(e);this[Je]||super.emit("data",e)}}for(let e of this[Ge])e.end();let t=super.emit("end");return this.removeAllListeners("end"),t}async collect(){let t=Object.assign([],{dataLength:0});this[qe]||(t.dataLength=0);let e=this.promise();return this.on("data",r=>{t.push(r),this[qe]||(t.dataLength+=r.length)}),await e,t}async concat(){if(this[qe])throw new Error("cannot concat in objectMode");let t=await this.collect();return this[dt]?t.join(""):Buffer.concat(t,t.dataLength)}async promise(){return new Promise((t,e)=>{this.on(me,()=>e(new Error("stream destroyed"))),this.on("error",r=>e(r)),this.on("end",()=>t())})}[Symbol.asyncIterator](){this[Je]=!1;let t=!1,e=async()=>(this.pause(),t=!0,{value:void 0,done:!0});return{next:()=>{if(t)return e();let r=this.read();if(r!==null)return Promise.resolve({done:!1,value:r});if(this[kt])return e();let i,o,c=p=>{this.off("data",f),this.off("end",l),this.off(me,x),e(),o(p)},f=p=>{this.off("error",c),this.off("end",l),this.off(me,x),this.pause(),i({value:p,done:!!this[kt]})},l=()=>{this.off("error",c),this.off("data",f),this.off(me,x),e(),i({done:!0,value:void 0})},x=()=>c(new Error("stream destroyed"));return new Promise((p,w)=>{o=w,i=p,this.once(me,x),this.once("error",c),this.once("end",l),this.once("data",f)})},throw:e,return:e,[Symbol.asyncIterator](){return this},[Symbol.asyncDispose]:async()=>{}}}[Symbol.iterator](){this[Je]=!1;let t=!1,e=()=>(this.pause(),this.off(ia,e),this.off(me,e),this.off("end",e),t=!0,{done:!0,value:void 0}),r=()=>{if(t)return e();let i=this.read();return i===null?e():{done:!1,value:i}};return this.once("end",e),this.once(ia,e),this.once(me,e),{next:r,throw:e,return:e,[Symbol.iterator](){return this},[Symbol.dispose]:()=>{}}}destroy(t){if(this[me])return t?this.emit("error",t):this.emit(me),this;this[me]=!0,this[Je]=!0,this[Ce].length=0,this[Re]=0;let e=this;return typeof e.close=="function"&&!this[Yi]&&e.close(),t?this.emit("error",t):this.emit(me),this}static get isStream(){return Xp}},cg=Ke.writev,an=Symbol("_autoClose"),xt=Symbol("_close"),Fr=Symbol("_ended"),ie=Symbol("_fd"),ca=Symbol("_finished"),Mt=Symbol("_flags"),da=Symbol("_flush"),Ra=Symbol("_handleChunk"),Da=Symbol("_makeBuf"),Yr=Symbol("_mode"),es=Symbol("_needDrain"),ar=Symbol("_onerror"),cr=Symbol("_onopen"),fa=Symbol("_onread"),rr=Symbol("_onwrite"),cn=Symbol("_open"),lt=Symbol("_path"),tn=Symbol("_pos"),mt=Symbol("_queue"),ir=Symbol("_read"),ua=Symbol("_readSize"),Nt=Symbol("_reading"),Ur=Symbol("_remain"),la=Symbol("_size"),fs=Symbol("_write"),_n=Symbol("_writing"),us=Symbol("_defaultFlag"),An=Symbol("_errored"),Za=class extends Dn{[An]=!1;[ie];[lt];[ua];[Nt]=!1;[la];[Ur];[an];constructor(t,e){if(e=e||{},super(e),this.readable=!0,this.writable=!1,typeof t!="string")throw new TypeError("path must be a string");this[An]=!1,this[ie]=typeof e.fd=="number"?e.fd:void 0,this[lt]=t,this[ua]=e.readSize||16*1024*1024,this[Nt]=!1,this[la]=typeof e.size=="number"?e.size:1/0,this[Ur]=this[la],this[an]=typeof e.autoClose=="boolean"?e.autoClose:!0,typeof this[ie]=="number"?this[ir]():this[cn]()}get fd(){return this[ie]}get path(){return this[lt]}write(){throw new TypeError("this is a readable stream")}end(){throw new TypeError("this is a readable stream")}[cn](){Ke.open(this[lt],"r",(t,e)=>this[cr](t,e))}[cr](t,e){t?this[ar](t):(this[ie]=e,this.emit("open",e),this[ir]())}[Da](){return Buffer.allocUnsafe(Math.min(this[ua],this[Ur]))}[ir](){if(!this[Nt]){this[Nt]=!0;let t=this[Da]();if(t.length===0)return process.nextTick(()=>this[fa](null,0,t));Ke.read(this[ie],t,0,t.length,null,(e,r,i)=>this[fa](e,r,i))}}[fa](t,e,r){this[Nt]=!1,t?this[ar](t):this[Ra](e,r)&&this[ir]()}[xt](){if(this[an]&&typeof this[ie]=="number"){let t=this[ie];this[ie]=void 0,Ke.close(t,e=>e?this.emit("error",e):this.emit("close"))}}[ar](t){this[Nt]=!0,this[xt](),this.emit("error",t)}[Ra](t,e){let r=!1;return this[Ur]-=t,t>0&&(r=super.write(t<e.length?e.subarray(0,t):e)),(t===0||this[Ur]<=0)&&(r=!1,this[xt](),super.end()),r}emit(t,...e){switch(t){case"prefinish":case"finish":return!1;case"drain":return typeof this[ie]=="number"&&this[ir](),!1;case"error":return this[An]?!1:(this[An]=!0,super.emit(t,...e));default:return super.emit(t,...e)}}},dg=class extends Za{[cn](){let t=!0;try{this[cr](null,Ke.openSync(this[lt],"r")),t=!1}finally{t&&this[xt]()}}[ir](){let t=!0;try{if(!this[Nt]){this[Nt]=!0;do{let e=this[Da](),r=e.length===0?0:Ke.readSync(this[ie],e,0,e.length,null);if(!this[Ra](r,e))break}while(!0);this[Nt]=!1}t=!1}finally{t&&this[xt]()}}[xt](){if(this[an]&&typeof this[ie]=="number"){let t=this[ie];this[ie]=void 0,Ke.closeSync(t),this.emit("close")}}},As=class extends Yp{readable=!1;writable=!0;[An]=!1;[_n]=!1;[Fr]=!1;[mt]=[];[es]=!1;[lt];[Yr];[an];[ie];[us];[Mt];[ca]=!1;[tn];constructor(t,e){e=e||{},super(e),this[lt]=t,this[ie]=typeof e.fd=="number"?e.fd:void 0,this[Yr]=e.mode===void 0?438:e.mode,this[tn]=typeof e.start=="number"?e.start:void 0,this[an]=typeof e.autoClose=="boolean"?e.autoClose:!0;let r=this[tn]!==void 0?"r+":"w";this[us]=e.flags===void 0,this[Mt]=e.flags===void 0?r:e.flags,this[ie]===void 0&&this[cn]()}emit(t,...e){if(t==="error"){if(this[An])return!1;this[An]=!0}return super.emit(t,...e)}get fd(){return this[ie]}get path(){return this[lt]}[ar](t){this[xt](),this[_n]=!0,this.emit("error",t)}[cn](){Ke.open(this[lt],this[Mt],this[Yr],(t,e)=>this[cr](t,e))}[cr](t,e){this[us]&&this[Mt]==="r+"&&t&&t.code==="ENOENT"?(this[Mt]="w",this[cn]()):t?this[ar](t):(this[ie]=e,this.emit("open",e),this[_n]||this[da]())}end(t,e){return t&&this.write(t,e),this[Fr]=!0,!this[_n]&&!this[mt].length&&typeof this[ie]=="number"&&this[rr](null,0),this}write(t,e){return typeof t=="string"&&(t=Buffer.from(t,e)),this[Fr]?(this.emit("error",new Error("write() after end()")),!1):this[ie]===void 0||this[_n]||this[mt].length?(this[mt].push(t),this[es]=!0,!1):(this[_n]=!0,this[fs](t),!0)}[fs](t){Ke.write(this[ie],t,0,t.length,this[tn],(e,r)=>this[rr](e,r))}[rr](t,e){t?this[ar](t):(this[tn]!==void 0&&typeof e=="number"&&(this[tn]+=e),this[mt].length?this[da]():(this[_n]=!1,this[Fr]&&!this[ca]?(this[ca]=!0,this[xt](),this.emit("finish")):this[es]&&(this[es]=!1,this.emit("drain"))))}[da](){if(this[mt].length===0)this[Fr]&&this[rr](null,0);else if(this[mt].length===1)this[fs](this[mt].pop());else{let t=this[mt];this[mt]=[],cg(this[ie],t,this[tn],(e,r)=>this[rr](e,r))}}[xt](){if(this[an]&&typeof this[ie]=="number"){let t=this[ie];this[ie]=void 0,Ke.close(t,e=>e?this.emit("error",e):this.emit("close"))}}},lf=class extends As{[cn](){let t;if(this[us]&&this[Mt]==="r+")try{t=Ke.openSync(this[lt],this[Mt],this[Yr])}catch(e){if(e?.code==="ENOENT")return this[Mt]="w",this[cn]();throw e}else t=Ke.openSync(this[lt],this[Mt],this[Yr]);this[cr](null,t)}[xt](){if(this[an]&&typeof this[ie]=="number"){let t=this[ie];this[ie]=void 0,Ke.closeSync(t),this.emit("close")}}[fs](t){let e=!0;try{this[rr](null,Ke.writeSync(this[ie],t,0,t.length,this[tn])),e=!1}finally{if(e)try{this[xt]()}catch{}}}},lg=new Map([["C","cwd"],["f","file"],["z","gzip"],["P","preservePaths"],["U","unlink"],["strip-components","strip"],["stripComponents","strip"],["keep-newer","newer"],["keepNewer","newer"],["keep-newer-files","newer"],["keepNewerFiles","newer"],["k","keep"],["keep-existing","keep"],["keepExisting","keep"],["m","noMtime"],["no-mtime","noMtime"],["p","preserveOwner"],["L","follow"],["h","follow"],["onentry","onReadEntry"]]),xg=t=>!!t.sync&&!!t.file,hg=t=>!t.sync&&!!t.file,pg=t=>!!t.sync&&!t.file,gg=t=>!t.sync&&!t.file,mg=t=>!!t.file,wg=t=>lg.get(t)||t,Xa=(t={})=>{if(!t)return{};let e={};for(let[r,i]of Object.entries(t)){let o=wg(r);e[o]=i}return e.chmod===void 0&&e.noChmod===!1&&(e.chmod=!0),delete e.noChmod,e},si=(t,e,r,i,o)=>Object.assign((c=[],f,l)=>{Array.isArray(c)&&(f=c,c={}),typeof f=="function"&&(l=f,f=void 0),f=f?Array.from(f):[];let x=Xa(c);if(o?.(x,f),xg(x)){if(typeof l=="function")throw new TypeError("callback not supported for sync tar functions");return t(x,f)}else if(hg(x)){let p=e(x,f);return l?p.then(()=>l(),l):p}else if(pg(x)){if(typeof l=="function")throw new TypeError("callback not supported for sync tar functions");return r(x,f)}else if(gg(x)){if(typeof l=="function")throw new TypeError("callback only supported with file option");return i(x,f)}throw new Error("impossible options??")},{syncFile:t,asyncFile:e,syncNoFile:r,asyncNoFile:i,validate:o}),bg=yg.constants||{ZLIB_VERNUM:4736},bt=Object.freeze(Object.assign(Object.create(null),{Z_NO_FLUSH:0,Z_PARTIAL_FLUSH:1,Z_SYNC_FLUSH:2,Z_FULL_FLUSH:3,Z_FINISH:4,Z_BLOCK:5,Z_OK:0,Z_STREAM_END:1,Z_NEED_DICT:2,Z_ERRNO:-1,Z_STREAM_ERROR:-2,Z_DATA_ERROR:-3,Z_MEM_ERROR:-4,Z_BUF_ERROR:-5,Z_VERSION_ERROR:-6,Z_NO_COMPRESSION:0,Z_BEST_SPEED:1,Z_BEST_COMPRESSION:9,Z_DEFAULT_COMPRESSION:-1,Z_FILTERED:1,Z_HUFFMAN_ONLY:2,Z_RLE:3,Z_FIXED:4,Z_DEFAULT_STRATEGY:0,DEFLATE:1,INFLATE:2,GZIP:3,GUNZIP:4,DEFLATERAW:5,INFLATERAW:6,UNZIP:7,BROTLI_DECODE:8,BROTLI_ENCODE:9,Z_MIN_WINDOWBITS:8,Z_MAX_WINDOWBITS:15,Z_DEFAULT_WINDOWBITS:15,Z_MIN_CHUNK:64,Z_MAX_CHUNK:1/0,Z_DEFAULT_CHUNK:16384,Z_MIN_MEMLEVEL:1,Z_MAX_MEMLEVEL:9,Z_DEFAULT_MEMLEVEL:8,Z_MIN_LEVEL:-1,Z_MAX_LEVEL:9,Z_DEFAULT_LEVEL:-1,BROTLI_OPERATION_PROCESS:0,BROTLI_OPERATION_FLUSH:1,BROTLI_OPERATION_FINISH:2,BROTLI_OPERATION_EMIT_METADATA:3,BROTLI_MODE_GENERIC:0,BROTLI_MODE_TEXT:1,BROTLI_MODE_FONT:2,BROTLI_DEFAULT_MODE:0,BROTLI_MIN_QUALITY:0,BROTLI_MAX_QUALITY:11,BROTLI_DEFAULT_QUALITY:11,BROTLI_MIN_WINDOW_BITS:10,BROTLI_MAX_WINDOW_BITS:24,BROTLI_LARGE_MAX_WINDOW_BITS:30,BROTLI_DEFAULT_WINDOW:22,BROTLI_MIN_INPUT_BLOCK_BITS:16,BROTLI_MAX_INPUT_BLOCK_BITS:24,BROTLI_PARAM_MODE:0,BROTLI_PARAM_QUALITY:1,BROTLI_PARAM_LGWIN:2,BROTLI_PARAM_LGBLOCK:3,BROTLI_PARAM_DISABLE_LITERAL_CONTEXT_MODELING:4,BROTLI_PARAM_SIZE_HINT:5,BROTLI_PARAM_LARGE_WINDOW:6,BROTLI_PARAM_NPOSTFIX:7,BROTLI_PARAM_NDIRECT:8,BROTLI_DECODER_RESULT_ERROR:0,BROTLI_DECODER_RESULT_SUCCESS:1,BROTLI_DECODER_RESULT_NEEDS_MORE_INPUT:2,BROTLI_DECODER_RESULT_NEEDS_MORE_OUTPUT:3,BROTLI_DECODER_PARAM_DISABLE_RING_BUFFER_REALLOCATION:0,BROTLI_DECODER_PARAM_LARGE_WINDOW:1,BROTLI_DECODER_NO_ERROR:0,BROTLI_DECODER_SUCCESS:1,BROTLI_DECODER_NEEDS_MORE_INPUT:2,BROTLI_DECODER_NEEDS_MORE_OUTPUT:3,BROTLI_DECODER_ERROR_FORMAT_EXUBERANT_NIBBLE:-1,BROTLI_DECODER_ERROR_FORMAT_RESERVED:-2,BROTLI_DECODER_ERROR_FORMAT_EXUBERANT_META_NIBBLE:-3,BROTLI_DECODER_ERROR_FORMAT_SIMPLE_HUFFMAN_ALPHABET:-4,BROTLI_DECODER_ERROR_FORMAT_SIMPLE_HUFFMAN_SAME:-5,BROTLI_DECODER_ERROR_FORMAT_CL_SPACE:-6,BROTLI_DECODER_ERROR_FORMAT_HUFFMAN_SPACE:-7,BROTLI_DECODER_ERROR_FORMAT_CONTEXT_MAP_REPEAT:-8,BROTLI_DECODER_ERROR_FORMAT_BLOCK_LENGTH_1:-9,BROTLI_DECODER_ERROR_FORMAT_BLOCK_LENGTH_2:-10,BROTLI_DECODER_ERROR_FORMAT_TRANSFORM:-11,BROTLI_DECODER_ERROR_FORMAT_DICTIONARY:-12,BROTLI_DECODER_ERROR_FORMAT_WINDOW_BITS:-13,BROTLI_DECODER_ERROR_FORMAT_PADDING_1:-14,BROTLI_DECODER_ERROR_FORMAT_PADDING_2:-15,BROTLI_DECODER_ERROR_FORMAT_DISTANCE:-16,BROTLI_DECODER_ERROR_DICTIONARY_NOT_SET:-19,BROTLI_DECODER_ERROR_INVALID_ARGUMENTS:-20,BROTLI_DECODER_ERROR_ALLOC_CONTEXT_MODES:-21,BROTLI_DECODER_ERROR_ALLOC_TREE_GROUPS:-22,BROTLI_DECODER_ERROR_ALLOC_CONTEXT_MAP:-25,BROTLI_DECODER_ERROR_ALLOC_RING_BUFFER_1:-26,BROTLI_DECODER_ERROR_ALLOC_RING_BUFFER_2:-27,BROTLI_DECODER_ERROR_ALLOC_BLOCK_TYPE_TREES:-30,BROTLI_DECODER_ERROR_UNREACHABLE:-31},bg)),Eg=Tn.concat,Od=Object.getOwnPropertyDescriptor(Tn,"concat"),vg=t=>t,xa=Od?.writable===!0||Od?.set!==void 0?t=>{Tn.concat=t?vg:Eg}:t=>{},Cn=Symbol("_superWrite"),ts=class extends Error{code;errno;constructor(t,e){super("zlib: "+t.message,{cause:t}),this.code=t.code,this.errno=t.errno,this.code||(this.code="ZLIB_ERROR"),this.message="zlib: "+t.message,Error.captureStackTrace(this,e??this.constructor)}get name(){return"ZlibError"}},ha=Symbol("flushFlag"),Qa=class extends Dn{#e=!1;#n=!1;#r;#s;#i;#t;#o;get sawError(){return this.#e}get handle(){return this.#t}get flushFlag(){return this.#r}constructor(t,e){if(!t||typeof t!="object")throw new TypeError("invalid options for ZlibBase constructor");if(super(t),this.#r=t.flush??0,this.#s=t.finishFlush??0,this.#i=t.fullFlushFlag??0,typeof Pd[e]!="function")throw new TypeError("Compression method not supported: "+e);try{this.#t=new Pd[e](t)}catch(r){throw new ts(r,this.constructor)}this.#o=r=>{this.#e||(this.#e=!0,this.close(),this.emit("error",r))},this.#t?.on("error",r=>this.#o(new ts(r))),this.once("end",()=>this.close)}close(){this.#t&&(this.#t.close(),this.#t=void 0,this.emit("close"))}reset(){if(!this.#e)return ka(this.#t,"zlib binding closed"),this.#t.reset?.()}flush(t){this.ended||(typeof t!="number"&&(t=this.#i),this.write(Object.assign(Tn.alloc(0),{[ha]:t})))}end(t,e,r){return typeof t=="function"&&(r=t,e=void 0,t=void 0),typeof e=="function"&&(r=e,e=void 0),t&&(e?this.write(t,e):this.write(t)),this.flush(this.#s),this.#n=!0,super.end(r)}get ended(){return this.#n}[Cn](t){return super.write(t)}write(t,e,r){if(typeof e=="function"&&(r=e,e="utf8"),typeof t=="string"&&(t=Tn.from(t,e)),this.#e)return;ka(this.#t,"zlib binding closed");let i=this.#t._handle,o=i.close;i.close=()=>{};let c=this.#t.close;this.#t.close=()=>{},xa(!0);let f;try{let x=typeof t[ha]=="number"?t[ha]:this.#r;f=this.#t._processChunk(t,x),xa(!1)}catch(x){xa(!1),this.#o(new ts(x,this.write))}finally{this.#t&&(this.#t._handle=i,i.close=o,this.#t.close=c,this.#t.removeAllListeners("error"))}this.#t&&this.#t.on("error",x=>this.#o(new ts(x,this.write)));let l;if(f)if(Array.isArray(f)&&f.length>0){let x=f[0];l=this[Cn](Tn.from(x));for(let p=1;p<f.length;p++)l=this[Cn](f[p])}else l=this[Cn](Tn.from(f));return r&&r(),l}},hf=class extends Qa{#e;#n;constructor(t,e){t=t||{},t.flush=t.flush||bt.Z_NO_FLUSH,t.finishFlush=t.finishFlush||bt.Z_FINISH,t.fullFlushFlag=bt.Z_FULL_FLUSH,super(t,e),this.#e=t.level,this.#n=t.strategy}params(t,e){if(!this.sawError){if(!this.handle)throw new Error("cannot switch params when binding is closed");if(!this.handle.params)throw new Error("not supported in this implementation");if(this.#e!==t||this.#n!==e){this.flush(bt.Z_SYNC_FLUSH),ka(this.handle,"zlib binding closed");let r=this.handle.flush;this.handle.flush=(i,o)=>{typeof i=="function"&&(o=i,i=this.flushFlag),this.flush(i),o?.()};try{this.handle.params(t,e)}finally{this.handle.flush=r}this.handle&&(this.#e=t,this.#n=e)}}}},Sg=class extends hf{#e;constructor(t){super(t,"Gzip"),this.#e=t&&!!t.portable}[Cn](t){return this.#e?(this.#e=!1,t[9]=255,super[Cn](t)):super[Cn](t)}},Ig=class extends hf{constructor(t){super(t,"Unzip")}},pf=class extends Qa{constructor(t,e){t=t||{},t.flush=t.flush||bt.BROTLI_OPERATION_PROCESS,t.finishFlush=t.finishFlush||bt.BROTLI_OPERATION_FINISH,t.fullFlushFlag=bt.BROTLI_OPERATION_FLUSH,super(t,e)}},Ag=class extends pf{constructor(t){super(t,"BrotliCompress")}},Tg=class extends pf{constructor(t){super(t,"BrotliDecompress")}},gf=class extends Qa{constructor(t,e){t=t||{},t.flush=t.flush||bt.ZSTD_e_continue,t.finishFlush=t.finishFlush||bt.ZSTD_e_end,t.fullFlushFlag=bt.ZSTD_e_flush,super(t,e)}},Cg=class extends gf{constructor(t){super(t,"ZstdCompress")}},Rg=class extends gf{constructor(t){super(t,"ZstdDecompress")}},Dg=(t,e)=>{if(Number.isSafeInteger(t))t<0?Lg(t,e):kg(t,e);else throw Error("cannot encode number outside of javascript safe integer range");return e},kg=(t,e)=>{e[0]=128;for(var r=e.length;r>1;r--)e[r-1]=t&255,t=Math.floor(t/256)},Lg=(t,e)=>{e[0]=255;var r=!1;t=t*-1;for(var i=e.length;i>1;i--){var o=t&255;t=Math.floor(t/256),r?e[i-1]=mf(o):o===0?e[i-1]=0:(r=!0,e[i-1]=wf(o))}},Pg=t=>{let e=t[0],r=e===128?Ng(t.subarray(1,t.length)):e===255?Og(t):null;if(r===null)throw Error("invalid base256 encoding");if(!Number.isSafeInteger(r))throw Error("parsed number outside of javascript safe integer range");return r},Og=t=>{for(var e=t.length,r=0,i=!1,o=e-1;o>-1;o--){var c=Number(t[o]),f;i?f=mf(c):c===0?f=c:(i=!0,f=wf(c)),f!==0&&(r-=f*Math.pow(256,e-o-1))}return r},Ng=t=>{for(var e=t.length,r=0,i=e-1;i>-1;i--){var o=Number(t[i]);o!==0&&(r+=o*Math.pow(256,e-i-1))}return r},mf=t=>(255^t)&255,wf=t=>(255^t)+1&255,Mg={};Jp(Mg,{code:()=>ec,isCode:()=>ls,isName:()=>Bg,name:()=>Ts});var ls=t=>Ts.has(t),Bg=t=>ec.has(t),Ts=new Map([["0","File"],["","OldFile"],["1","Link"],["2","SymbolicLink"],["3","CharacterDevice"],["4","BlockDevice"],["5","Directory"],["6","FIFO"],["7","ContiguousFile"],["g","GlobalExtendedHeader"],["x","ExtendedHeader"],["A","SolarisACL"],["D","GNUDumpDir"],["I","Inode"],["K","NextFileHasLongLinkpath"],["L","NextFileHasLongPath"],["M","ContinuationFile"],["N","OldGnuLongPath"],["S","SparseFile"],["V","TapeVolumeHeader"],["X","OldExtendedHeader"]]),ec=new Map(Array.from(Ts).map(t=>[t[1],t[0]])),Rn=class{cksumValid=!1;needPax=!1;nullBlock=!1;block;path;mode;uid;gid;size;cksum;#e="Unsupported";linkpath;uname;gname;devmaj=0;devmin=0;atime;ctime;mtime;charset;comment;constructor(t,e=0,r,i){Buffer.isBuffer(t)?this.decode(t,e||0,r,i):t&&this.#n(t)}decode(t,e,r,i){if(e||(e=0),!t||!(t.length>=e+512))throw new Error("need 512 bytes for header");this.path=r?.path??yn(t,e,100),this.mode=r?.mode??i?.mode??nn(t,e+100,8),this.uid=r?.uid??i?.uid??nn(t,e+108,8),this.gid=r?.gid??i?.gid??nn(t,e+116,8),this.size=r?.size??i?.size??nn(t,e+124,12),this.mtime=r?.mtime??i?.mtime??pa(t,e+136,12),this.cksum=nn(t,e+148,12),i&&this.#n(i,!0),r&&this.#n(r);let o=yn(t,e+156,1);if(ls(o)&&(this.#e=o||"0"),this.#e==="0"&&this.path.slice(-1)==="/"&&(this.#e="5"),this.#e==="5"&&(this.size=0),this.linkpath=yn(t,e+157,100),t.subarray(e+257,e+265).toString()==="ustar\x0000")if(this.uname=r?.uname??i?.uname??yn(t,e+265,32),this.gname=r?.gname??i?.gname??yn(t,e+297,32),this.devmaj=r?.devmaj??i?.devmaj??nn(t,e+329,8)??0,this.devmin=r?.devmin??i?.devmin??nn(t,e+337,8)??0,t[e+475]!==0){let f=yn(t,e+345,155);this.path=f+"/"+this.path}else{let f=yn(t,e+345,130);f&&(this.path=f+"/"+this.path),this.atime=r?.atime??i?.atime??pa(t,e+476,12),this.ctime=r?.ctime??i?.ctime??pa(t,e+488,12)}let c=256;for(let f=e;f<e+148;f++)c+=t[f];for(let f=e+156;f<e+512;f++)c+=t[f];this.cksumValid=c===this.cksum,this.cksum===void 0&&c===256&&(this.nullBlock=!0)}#n(t,e=!1){Object.assign(this,Object.fromEntries(Object.entries(t).filter(([r,i])=>!(i==null||r==="path"&&e||r==="linkpath"&&e||r==="global"))))}encode(t,e=0){if(t||(t=this.block=Buffer.alloc(512)),this.#e==="Unsupported"&&(this.#e="0"),!(t.length>=e+512))throw new Error("need 512 bytes for header");let r=this.ctime||this.atime?130:155,i=zg(this.path||"",r),o=i[0],c=i[1];this.needPax=!!i[2],this.needPax=bn(t,e,100,o)||this.needPax,this.needPax=rn(t,e+100,8,this.mode)||this.needPax,this.needPax=rn(t,e+108,8,this.uid)||this.needPax,this.needPax=rn(t,e+116,8,this.gid)||this.needPax,this.needPax=rn(t,e+124,12,this.size)||this.needPax,this.needPax=ga(t,e+136,12,this.mtime)||this.needPax,t[e+156]=Number(this.#e.codePointAt(0)),this.needPax=bn(t,e+157,100,this.linkpath)||this.needPax,t.write("ustar\x0000",e+257,8),this.needPax=bn(t,e+265,32,this.uname)||this.needPax,this.needPax=bn(t,e+297,32,this.gname)||this.needPax,this.needPax=rn(t,e+329,8,this.devmaj)||this.needPax,this.needPax=rn(t,e+337,8,this.devmin)||this.needPax,this.needPax=bn(t,e+345,r,c)||this.needPax,t[e+475]!==0?this.needPax=bn(t,e+345,155,c)||this.needPax:(this.needPax=bn(t,e+345,130,c)||this.needPax,this.needPax=ga(t,e+476,12,this.atime)||this.needPax,this.needPax=ga(t,e+488,12,this.ctime)||this.needPax);let f=256;for(let l=e;l<e+148;l++)f+=t[l];for(let l=e+156;l<e+512;l++)f+=t[l];return this.cksum=f,rn(t,e+148,8,this.cksum),this.cksumValid=!0,this.needPax}get type(){return this.#e==="Unsupported"?this.#e:Ts.get(this.#e)}get typeKey(){return this.#e}set type(t){let e=String(ec.get(t));if(ls(e)||e==="Unsupported")this.#e=e;else if(ls(t))this.#e=t;else throw new TypeError("invalid entry type: "+t)}},zg=(t,e)=>{let r=t,i="",o,c=Xn.parse(t).root||".";if(Buffer.byteLength(r)<100)o=[r,i,!1];else{i=Xn.dirname(r),r=Xn.basename(r);do Buffer.byteLength(r)<=100&&Buffer.byteLength(i)<=e?o=[r,i,!1]:Buffer.byteLength(r)>100&&Buffer.byteLength(i)<=e?o=[r.slice(0,99),i,!0]:(r=Xn.join(Xn.basename(i),r),i=Xn.dirname(i));while(i!==c&&o===void 0);o||(o=[t.slice(0,99),"",!0])}return o},yn=(t,e,r)=>t.subarray(e,e+r).toString("utf8").replace(/\0.*/,""),pa=(t,e,r)=>Fg(nn(t,e,r)),Fg=t=>t===void 0?void 0:new Date(t*1e3),nn=(t,e,r)=>Number(t[e])&128?Pg(t.subarray(e,e+r)):qg(t,e,r),Ug=t=>isNaN(t)?void 0:t,qg=(t,e,r)=>Ug(parseInt(t.subarray(e,e+r).toString("utf8").replace(/\0.*$/,"").trim(),8)),Hg={12:8589934591,8:2097151},rn=(t,e,r,i)=>i===void 0?!1:i>Hg[r]||i<0?(Dg(i,t.subarray(e,e+r)),!0):(Gg(t,e,r,i),!1),Gg=(t,e,r,i)=>t.write(jg(i,r),e,r,"ascii"),jg=(t,e)=>Kg(Math.floor(t).toString(8),e),Kg=(t,e)=>(t.length===e-1?t:new Array(e-t.length-1).join("0")+t+" ")+"\0",ga=(t,e,r,i)=>i===void 0?!1:rn(t,e,r,i.getTime()/1e3),Wg=new Array(156).join("\0"),bn=(t,e,r,i)=>i===void 0?!1:(t.write(i+Wg,e,r,"utf8"),i.length!==Buffer.byteLength(i)||i.length>r),bs=class _f{atime;mtime;ctime;charset;comment;gid;uid;gname;uname;linkpath;dev;ino;nlink;path;size;mode;global;constructor(e,r=!1){this.atime=e.atime,this.charset=e.charset,this.comment=e.comment,this.ctime=e.ctime,this.dev=e.dev,this.gid=e.gid,this.global=r,this.gname=e.gname,this.ino=e.ino,this.linkpath=e.linkpath,this.mtime=e.mtime,this.nlink=e.nlink,this.path=e.path,this.size=e.size,this.uid=e.uid,this.uname=e.uname}encode(){let e=this.encodeBody();if(e==="")return Buffer.allocUnsafe(0);let r=Buffer.byteLength(e),i=512*Math.ceil(1+r/512),o=Buffer.allocUnsafe(i);for(let c=0;c<512;c++)o[c]=0;new Rn({path:("PaxHeader/"+Vg(this.path??"")).slice(0,99),mode:this.mode||420,uid:this.uid,gid:this.gid,size:r,mtime:this.mtime,type:this.global?"GlobalExtendedHeader":"ExtendedHeader",linkpath:"",uname:this.uname||"",gname:this.gname||"",devmaj:0,devmin:0,atime:this.atime,ctime:this.ctime}).encode(o),o.write(e,512,r,"utf8");for(let c=r+512;c<o.length;c++)o[c]=0;return o}encodeBody(){return this.encodeField("path")+this.encodeField("ctime")+this.encodeField("atime")+this.encodeField("dev")+this.encodeField("ino")+this.encodeField("nlink")+this.encodeField("charset")+this.encodeField("comment")+this.encodeField("gid")+this.encodeField("gname")+this.encodeField("linkpath")+this.encodeField("mtime")+this.encodeField("size")+this.encodeField("uid")+this.encodeField("uname")}encodeField(e){if(this[e]===void 0)return"";let r=this[e],i=r instanceof Date?r.getTime()/1e3:r,o=" "+(e==="dev"||e==="ino"||e==="nlink"?"SCHILY.":"")+e+"="+i+`
81
+ `,c=Buffer.byteLength(o),f=Math.floor(Math.log(c)/Math.log(10))+1;return c+f>=Math.pow(10,f)&&(f+=1),f+c+o}static parse(e,r,i=!1){return new _f($g(Jg(e),r),i)}},$g=(t,e)=>e?Object.assign({},e,t):t,Jg=t=>t.replace(/\n$/,"").split(`
82
+ `).reduce(Yg,Object.create(null)),Yg=(t,e)=>{let r=parseInt(e,10);if(r!==Buffer.byteLength(e)+1)return t;e=e.slice((r+" ").length);let i=e.split("="),o=i.shift();if(!o)return t;let c=o.replace(/^SCHILY\.(dev|ino|nlink)/,"$1"),f=i.join("=");return t[c]=/^([A-Z]+\.)?([mac]|birth|creation)time$/.test(c)?new Date(Number(f)*1e3):/^[0-9]+$/.test(f)?+f:f,t},Zg=process.env.TESTING_TAR_FAKE_PLATFORM||process.platform,Y=Zg!=="win32"?t=>t:t=>t&&t.replaceAll(/\\/g,"/"),yf=class extends Dn{extended;globalExtended;header;startBlockSize;blockRemain;remain;type;meta=!1;ignore=!1;path;mode;uid;gid;uname;gname;size=0;mtime;atime;ctime;linkpath;dev;ino;nlink;invalid=!1;absolute;unsupported=!1;constructor(t,e,r){switch(super({}),this.pause(),this.extended=e,this.globalExtended=r,this.header=t,this.remain=t.size??0,this.startBlockSize=512*Math.ceil(this.remain/512),this.blockRemain=this.startBlockSize,this.type=t.type,this.type){case"File":case"OldFile":case"Link":case"SymbolicLink":case"CharacterDevice":case"BlockDevice":case"Directory":case"FIFO":case"ContiguousFile":case"GNUDumpDir":break;case"NextFileHasLongLinkpath":case"NextFileHasLongPath":case"OldGnuLongPath":case"GlobalExtendedHeader":case"ExtendedHeader":case"OldExtendedHeader":this.meta=!0;break;default:this.ignore=!0}if(!t.path)throw new Error("no path provided for tar.ReadEntry");this.path=Y(t.path),this.mode=t.mode,this.mode&&(this.mode=this.mode&4095),this.uid=t.uid,this.gid=t.gid,this.uname=t.uname,this.gname=t.gname,this.size=this.remain,this.mtime=t.mtime,this.atime=t.atime,this.ctime=t.ctime,this.linkpath=t.linkpath?Y(t.linkpath):void 0,this.uname=t.uname,this.gname=t.gname,e&&this.#e(e),r&&this.#e(r,!0)}write(t){let e=t.length;if(e>this.blockRemain)throw new Error("writing more to entry than is appropriate");let r=this.remain,i=this.blockRemain;return this.remain=Math.max(0,r-e),this.blockRemain=Math.max(0,i-e),this.ignore?!0:r>=e?super.write(t):super.write(t.subarray(0,r))}#e(t,e=!1){t.path&&(t.path=Y(t.path)),t.linkpath&&(t.linkpath=Y(t.linkpath)),Object.assign(this,Object.fromEntries(Object.entries(t).filter(([r,i])=>!(i==null||r==="path"&&e))))}},Cs=(t,e,r,i={})=>{t.file&&(i.file=t.file),t.cwd&&(i.cwd=t.cwd),i.code=r instanceof Error&&r.code||e,i.tarCode=e,!t.strict&&i.recoverable!==!1?(r instanceof Error&&(i=Object.assign(r,i),r=r.message),t.emit("warn",e,r,i)):r instanceof Error?t.emit("error",Object.assign(r,i)):t.emit("error",Object.assign(new Error(`${e}: ${r}`),i))},Xg=1024*1024,La=Buffer.from([31,139]),Pa=Buffer.from([40,181,47,253]),Qg=Math.max(La.length,Pa.length),rt=Symbol("state"),En=Symbol("writeEntry"),Pt=Symbol("readEntry"),ma=Symbol("nextEntry"),Nd=Symbol("processEntry"),wt=Symbol("extendedHeader"),qr=Symbol("globalExtendedHeader"),Zt=Symbol("meta"),Md=Symbol("emitMeta"),ce=Symbol("buffer"),Ot=Symbol("queue"),Xt=Symbol("ended"),wa=Symbol("emittedEnd"),vn=Symbol("emit"),ye=Symbol("unzip"),ns=Symbol("consumeChunk"),rs=Symbol("consumeChunkSub"),_a=Symbol("consumeBody"),Bd=Symbol("consumeMeta"),zd=Symbol("consumeHeader"),Hr=Symbol("consuming"),ya=Symbol("bufferConcat"),is=Symbol("maybeEnd"),Qn=Symbol("writing"),Qt=Symbol("aborted"),ss=Symbol("onDone"),Sn=Symbol("sawValidEntry"),os=Symbol("sawNullBlock"),as=Symbol("sawEOF"),Fd=Symbol("closeStream"),em=()=>!0,ii=class extends _g{file;strict;maxMetaEntrySize;filter;brotli;zstd;writable=!0;readable=!1;[Ot]=[];[ce];[Pt];[En];[rt]="begin";[Zt]="";[wt];[qr];[Xt]=!1;[ye];[Qt]=!1;[Sn];[os]=!1;[as]=!1;[Qn]=!1;[Hr]=!1;[wa]=!1;constructor(t={}){super(),this.file=t.file||"",this.on(ss,()=>{(this[rt]==="begin"||this[Sn]===!1)&&this.warn("TAR_BAD_ARCHIVE","Unrecognized archive format")}),t.ondone?this.on(ss,t.ondone):this.on(ss,()=>{this.emit("prefinish"),this.emit("finish"),this.emit("end")}),this.strict=!!t.strict,this.maxMetaEntrySize=t.maxMetaEntrySize||Xg,this.filter=typeof t.filter=="function"?t.filter:em;let e=t.file&&(t.file.endsWith(".tar.br")||t.file.endsWith(".tbr"));this.brotli=!(t.gzip||t.zstd)&&t.brotli!==void 0?t.brotli:e?void 0:!1;let r=t.file&&(t.file.endsWith(".tar.zst")||t.file.endsWith(".tzst"));this.zstd=!(t.gzip||t.brotli)&&t.zstd!==void 0?t.zstd:r?!0:void 0,this.on("end",()=>this[Fd]()),typeof t.onwarn=="function"&&this.on("warn",t.onwarn),typeof t.onReadEntry=="function"&&this.on("entry",t.onReadEntry)}warn(t,e,r={}){Cs(this,t,e,r)}[zd](t,e){this[Sn]===void 0&&(this[Sn]=!1);let r;try{r=new Rn(t,e,this[wt],this[qr])}catch(i){return this.warn("TAR_ENTRY_INVALID",i)}if(r.nullBlock)this[os]?(this[as]=!0,this[rt]==="begin"&&(this[rt]="header"),this[vn]("eof")):(this[os]=!0,this[vn]("nullBlock"));else if(this[os]=!1,!r.cksumValid)this.warn("TAR_ENTRY_INVALID","checksum failure",{header:r});else if(!r.path)this.warn("TAR_ENTRY_INVALID","path is required",{header:r});else{let i=r.type;if(/^(Symbolic)?Link$/.test(i)&&!r.linkpath)this.warn("TAR_ENTRY_INVALID","linkpath required",{header:r});else if(!/^(Symbolic)?Link$/.test(i)&&!/^(Global)?ExtendedHeader$/.test(i)&&r.linkpath)this.warn("TAR_ENTRY_INVALID","linkpath forbidden",{header:r});else{let o=this[En]=new yf(r,this[wt],this[qr]);if(!this[Sn])if(o.remain){let c=()=>{o.invalid||(this[Sn]=!0)};o.on("end",c)}else this[Sn]=!0;o.meta?o.size>this.maxMetaEntrySize?(o.ignore=!0,this[vn]("ignoredEntry",o),this[rt]="ignore",o.resume()):o.size>0&&(this[Zt]="",o.on("data",c=>this[Zt]+=c),this[rt]="meta"):(this[wt]=void 0,o.ignore=o.ignore||!this.filter(o.path,o),o.ignore?(this[vn]("ignoredEntry",o),this[rt]=o.remain?"ignore":"header",o.resume()):(o.remain?this[rt]="body":(this[rt]="header",o.end()),this[Pt]?this[Ot].push(o):(this[Ot].push(o),this[ma]())))}}}[Fd](){queueMicrotask(()=>this.emit("close"))}[Nd](t){let e=!0;if(!t)this[Pt]=void 0,e=!1;else if(Array.isArray(t)){let[r,...i]=t;this.emit(r,...i)}else this[Pt]=t,this.emit("entry",t),t.emittedEnd||(t.on("end",()=>this[ma]()),e=!1);return e}[ma](){do;while(this[Nd](this[Ot].shift()));if(this[Ot].length===0){let t=this[Pt];!t||t.flowing||t.size===t.remain?this[Qn]||this.emit("drain"):t.once("drain",()=>this.emit("drain"))}}[_a](t,e){let r=this[En];if(!r)throw new Error("attempt to consume body without entry??");let i=r.blockRemain??0,o=i>=t.length&&e===0?t:t.subarray(e,e+i);return r.write(o),r.blockRemain||(this[rt]="header",this[En]=void 0,r.end()),o.length}[Bd](t,e){let r=this[En],i=this[_a](t,e);return!this[En]&&r&&this[Md](r),i}[vn](t,e,r){this[Ot].length===0&&!this[Pt]?this.emit(t,e,r):this[Ot].push([t,e,r])}[Md](t){switch(this[vn]("meta",this[Zt]),t.type){case"ExtendedHeader":case"OldExtendedHeader":this[wt]=bs.parse(this[Zt],this[wt],!1);break;case"GlobalExtendedHeader":this[qr]=bs.parse(this[Zt],this[qr],!0);break;case"NextFileHasLongPath":case"OldGnuLongPath":{let e=this[wt]??Object.create(null);this[wt]=e,e.path=this[Zt].replace(/\0.*/,"");break}case"NextFileHasLongLinkpath":{let e=this[wt]||Object.create(null);this[wt]=e,e.linkpath=this[Zt].replace(/\0.*/,"");break}default:throw new Error("unknown meta: "+t.type)}}abort(t){this[Qt]=!0,this.emit("abort",t),this.warn("TAR_ABORT",t,{recoverable:!1})}write(t,e,r){if(typeof e=="function"&&(r=e,e=void 0),typeof t=="string"&&(t=Buffer.from(t,typeof e=="string"?e:"utf8")),this[Qt])return r?.(),!1;if((this[ye]===void 0||this.brotli===void 0&&this[ye]===!1)&&t){if(this[ce]&&(t=Buffer.concat([this[ce],t]),this[ce]=void 0),t.length<Qg)return this[ce]=t,r?.(),!0;for(let f=0;this[ye]===void 0&&f<La.length;f++)t[f]!==La[f]&&(this[ye]=!1);let o=!1;if(this[ye]===!1&&this.zstd!==!1){o=!0;for(let f=0;f<Pa.length;f++)if(t[f]!==Pa[f]){o=!1;break}}let c=this.brotli===void 0&&!o;if(this[ye]===!1&&c)if(t.length<512)if(this[Xt])this.brotli=!0;else return this[ce]=t,r?.(),!0;else try{new Rn(t.subarray(0,512)),this.brotli=!1}catch{this.brotli=!0}if(this[ye]===void 0||this[ye]===!1&&(this.brotli||o)){let f=this[Xt];this[Xt]=!1,this[ye]=this[ye]===void 0?new Ig({}):o?new Rg({}):new Tg({}),this[ye].on("data",x=>this[ns](x)),this[ye].on("error",x=>this.abort(x)),this[ye].on("end",()=>{this[Xt]=!0,this[ns]()}),this[Qn]=!0;let l=!!this[ye][f?"end":"write"](t);return this[Qn]=!1,r?.(),l}}this[Qn]=!0,this[ye]?this[ye].write(t):this[ns](t),this[Qn]=!1;let i=this[Ot].length>0?!1:this[Pt]?this[Pt].flowing:!0;return!i&&this[Ot].length===0&&this[Pt]?.once("drain",()=>this.emit("drain")),r?.(),i}[ya](t){t&&!this[Qt]&&(this[ce]=this[ce]?Buffer.concat([this[ce],t]):t)}[is](){if(this[Xt]&&!this[wa]&&!this[Qt]&&!this[Hr]){this[wa]=!0;let t=this[En];if(t&&t.blockRemain){let e=this[ce]?this[ce].length:0;this.warn("TAR_BAD_ARCHIVE",`Truncated input (needed ${t.blockRemain} more bytes, only ${e} available)`,{entry:t}),this[ce]&&t.write(this[ce]),t.end()}this[vn](ss)}}[ns](t){if(this[Hr]&&t)this[ya](t);else if(!t&&!this[ce])this[is]();else if(t){if(this[Hr]=!0,this[ce]){this[ya](t);let e=this[ce];this[ce]=void 0,this[rs](e)}else this[rs](t);for(;this[ce]&&this[ce]?.length>=512&&!this[Qt]&&!this[as];){let e=this[ce];this[ce]=void 0,this[rs](e)}this[Hr]=!1}(!this[ce]||this[Xt])&&this[is]()}[rs](t){let e=0,r=t.length;for(;e+512<=r&&!this[Qt]&&!this[as];)switch(this[rt]){case"begin":case"header":this[zd](t,e),e+=512;break;case"ignore":case"body":e+=this[_a](t,e);break;case"meta":e+=this[Bd](t,e);break;default:throw new Error("invalid state: "+this[rt])}e<r&&(this[ce]=this[ce]?Buffer.concat([t.subarray(e),this[ce]]):t.subarray(e))}end(t,e,r){return typeof t=="function"&&(r=t,e=void 0,t=void 0),typeof e=="function"&&(r=e,e=void 0),typeof t=="string"&&(t=Buffer.from(t,e)),r&&this.once("finish",r),this[Qt]||(this[ye]?(t&&this[ye].write(t),this[ye].end()):(this[Xt]=!0,(this.brotli===void 0||this.zstd===void 0)&&(t=t||Buffer.alloc(0)),t&&this.write(t),this[is]())),this}},Zr=t=>{let e=t.length-1,r=-1;for(;e>-1&&t.charAt(e)==="/";)r=e,e--;return r===-1?t:t.slice(0,r)},tm=t=>{let e=t.onReadEntry;t.onReadEntry=e?r=>{e(r),r.resume()}:r=>r.resume()},bf=(t,e)=>{let r=new Map(e.map(c=>[Zr(c),!0])),i=t.filter,o=(c,f="")=>{let l=f||ug(c).root||".",x;if(c===l)x=!1;else{let p=r.get(c);x=p!==void 0?p:o(fg(c),l)}return r.set(c,x),x};t.filter=i?(c,f)=>i(c,f)&&o(Zr(c)):c=>o(Zr(c))},nm=t=>{let e=new ii(t),r=t.file,i;try{i=sr.openSync(r,"r");let o=sr.fstatSync(i),c=t.maxReadSize||16*1024*1024;if(o.size<c){let f=Buffer.allocUnsafe(o.size),l=sr.readSync(i,f,0,o.size,0);e.end(l===f.byteLength?f:f.subarray(0,l))}else{let f=0,l=Buffer.allocUnsafe(c);for(;f<o.size;){let x=sr.readSync(i,l,0,c,f);if(x===0)break;f+=x,e.write(l.subarray(0,x))}e.end()}}finally{if(typeof i=="number")try{sr.closeSync(i)}catch{}}},rm=(t,e)=>{let r=new ii(t),i=t.maxReadSize||16*1024*1024,o=t.file;return new Promise((c,f)=>{r.on("error",f),r.on("end",c),sr.stat(o,(l,x)=>{if(l)f(l);else{let p=new Za(o,{readSize:i,size:x.size});p.on("error",f),p.pipe(r)}})})},dr=si(nm,rm,t=>new ii(t),t=>new ii(t),(t,e)=>{e?.length&&bf(t,e),t.noResume||tm(t)}),Ef=(t,e,r)=>(t&=4095,r&&(t=(t|384)&-19),e&&(t&256&&(t|=64),t&32&&(t|=8),t&4&&(t|=1)),t),{isAbsolute:sm,parse:qd}=im,tc=t=>{let e="",r=qd(t);for(;sm(t)||r.root;){let i=t.charAt(0)==="/"&&t.slice(0,4)!=="//?/"?"/":r.root;t=t.slice(i.length),e+=i,r=qd(t)}return[e,t]},Rs=["|","<",">","?",":"],nc=Rs.map(t=>String.fromCodePoint(61440+Number(t.codePointAt(0)))),om=new Map(Rs.map((t,e)=>[t,nc[e]])),am=new Map(nc.map((t,e)=>[t,Rs[e]])),Hd=t=>Rs.reduce((e,r)=>e.split(r).join(om.get(r)),t),cm=t=>nc.reduce((e,r)=>e.split(r).join(am.get(r)),t),vf=(t,e)=>e?(t=Y(t).replace(/^\.(\/|$)/,""),Zr(e)+"/"+t):Y(t),dm=16*1024*1024,Gd=Symbol("process"),jd=Symbol("file"),Kd=Symbol("directory"),Oa=Symbol("symlink"),Wd=Symbol("hardlink"),Gr=Symbol("header"),xs=Symbol("read"),Na=Symbol("lstat"),hs=Symbol("onlstat"),Ma=Symbol("onread"),Ba=Symbol("onreadlink"),za=Symbol("openfile"),Fa=Symbol("onopenfile"),sn=Symbol("close"),vs=Symbol("mode"),Ua=Symbol("awaitDrain"),ba=Symbol("ondrain"),yt=Symbol("prefix"),Sf=class extends Dn{path;portable;myuid=process.getuid&&process.getuid()||0;myuser=process.env.USER||"";maxReadSize;linkCache;statCache;preservePaths;cwd;strict;mtime;noPax;noMtime;prefix;fd;blockLen=0;blockRemain=0;buf;pos=0;remain=0;length=0;offset=0;win32;absolute;header;type;linkpath;stat;onWriteEntry;#e=!1;constructor(t,e={}){let r=Xa(e);super(),this.path=Y(t),this.portable=!!r.portable,this.maxReadSize=r.maxReadSize||dm,this.linkCache=r.linkCache||new Map,this.statCache=r.statCache||new Map,this.preservePaths=!!r.preservePaths,this.cwd=Y(r.cwd||process.cwd()),this.strict=!!r.strict,this.noPax=!!r.noPax,this.noMtime=!!r.noMtime,this.mtime=r.mtime,this.prefix=r.prefix?Y(r.prefix):void 0,this.onWriteEntry=r.onWriteEntry,typeof r.onwarn=="function"&&this.on("warn",r.onwarn);let i=!1;if(!this.preservePaths){let[c,f]=tc(this.path);c&&typeof f=="string"&&(this.path=f,i=c)}this.win32=!!r.win32||process.platform==="win32",this.win32&&(this.path=cm(this.path.replaceAll(/\\/g,"/")),t=t.replaceAll(/\\/g,"/")),this.absolute=Y(r.absolute||Ud.resolve(this.cwd,t)),this.path===""&&(this.path="./"),i&&this.warn("TAR_ENTRY_INFO",`stripping ${i} from absolute path`,{entry:this,path:i+this.path});let o=this.statCache.get(this.absolute);o?this[hs](o):this[Na]()}warn(t,e,r={}){return Cs(this,t,e,r)}emit(t,...e){return t==="error"&&(this.#e=!0),super.emit(t,...e)}[Na](){_t.lstat(this.absolute,(t,e)=>{if(t)return this.emit("error",t);this[hs](e)})}[hs](t){this.statCache.set(this.absolute,t),this.stat=t,t.isFile()||(t.size=0),this.type=lm(t),this.emit("stat",t),this[Gd]()}[Gd](){switch(this.type){case"File":return this[jd]();case"Directory":return this[Kd]();case"SymbolicLink":return this[Oa]();default:return this.end()}}[vs](t){return Ef(t,this.type==="Directory",this.portable)}[yt](t){return vf(t,this.prefix)}[Gr](){if(!this.stat)throw new Error("cannot write header before stat");this.type==="Directory"&&this.portable&&(this.noMtime=!0),this.onWriteEntry?.(this),this.header=new Rn({path:this[yt](this.path),linkpath:this.type==="Link"&&this.linkpath!==void 0?this[yt](this.linkpath):this.linkpath,mode:this[vs](this.stat.mode),uid:this.portable?void 0:this.stat.uid,gid:this.portable?void 0:this.stat.gid,size:this.stat.size,mtime:this.noMtime?void 0:this.mtime||this.stat.mtime,type:this.type==="Unsupported"?void 0:this.type,uname:this.portable?void 0:this.stat.uid===this.myuid?this.myuser:"",atime:this.portable?void 0:this.stat.atime,ctime:this.portable?void 0:this.stat.ctime}),this.header.encode()&&!this.noPax&&super.write(new bs({atime:this.portable?void 0:this.header.atime,ctime:this.portable?void 0:this.header.ctime,gid:this.portable?void 0:this.header.gid,mtime:this.noMtime?void 0:this.mtime||this.header.mtime,path:this[yt](this.path),linkpath:this.type==="Link"&&this.linkpath!==void 0?this[yt](this.linkpath):this.linkpath,size:this.header.size,uid:this.portable?void 0:this.header.uid,uname:this.portable?void 0:this.header.uname,dev:this.portable?void 0:this.stat.dev,ino:this.portable?void 0:this.stat.ino,nlink:this.portable?void 0:this.stat.nlink}).encode());let t=this.header?.block;if(!t)throw new Error("failed to encode header");super.write(t)}[Kd](){if(!this.stat)throw new Error("cannot create directory entry without stat");this.path.slice(-1)!=="/"&&(this.path+="/"),this.stat.size=0,this[Gr](),this.end()}[Oa](){_t.readlink(this.absolute,(t,e)=>{if(t)return this.emit("error",t);this[Ba](e)})}[Ba](t){this.linkpath=Y(t),this[Gr](),this.end()}[Wd](t){if(!this.stat)throw new Error("cannot create link entry without stat");this.type="Link",this.linkpath=Y(Ud.relative(this.cwd,t)),this.stat.size=0,this[Gr](),this.end()}[jd](){if(!this.stat)throw new Error("cannot create file entry without stat");if(this.stat.nlink>1){let t=`${this.stat.dev}:${this.stat.ino}`,e=this.linkCache.get(t);if(e?.indexOf(this.cwd)===0)return this[Wd](e);this.linkCache.set(t,this.absolute)}if(this[Gr](),this.stat.size===0)return this.end();this[za]()}[za](){_t.open(this.absolute,"r",(t,e)=>{if(t)return this.emit("error",t);this[Fa](e)})}[Fa](t){if(this.fd=t,this.#e)return this[sn]();if(!this.stat)throw new Error("should stat before calling onopenfile");this.blockLen=512*Math.ceil(this.stat.size/512),this.blockRemain=this.blockLen;let e=Math.min(this.blockLen,this.maxReadSize);this.buf=Buffer.allocUnsafe(e),this.offset=0,this.pos=0,this.remain=this.stat.size,this.length=this.buf.length,this[xs]()}[xs](){let{fd:t,buf:e,offset:r,length:i,pos:o}=this;if(t===void 0||e===void 0)throw new Error("cannot read file without first opening");_t.read(t,e,r,i,o,(c,f)=>{if(c)return this[sn](()=>this.emit("error",c));this[Ma](f)})}[sn](t=()=>{}){this.fd!==void 0&&_t.close(this.fd,t)}[Ma](t){if(t<=0&&this.remain>0){let r=Object.assign(new Error("encountered unexpected EOF"),{path:this.absolute,syscall:"read",code:"EOF"});return this[sn](()=>this.emit("error",r))}if(t>this.remain){let r=Object.assign(new Error("did not encounter expected EOF"),{path:this.absolute,syscall:"read",code:"EOF"});return this[sn](()=>this.emit("error",r))}if(!this.buf)throw new Error("should have created buffer prior to reading");if(t===this.remain)for(let r=t;r<this.length&&t<this.blockRemain;r++)this.buf[r+this.offset]=0,t++,this.remain++;let e=this.offset===0&&t===this.buf.length?this.buf:this.buf.subarray(this.offset,this.offset+t);this.write(e)?this[ba]():this[Ua](()=>this[ba]())}[Ua](t){this.once("drain",t)}write(t,e,r){if(typeof e=="function"&&(r=e,e=void 0),typeof t=="string"&&(t=Buffer.from(t,typeof e=="string"?e:"utf8")),this.blockRemain<t.length){let i=Object.assign(new Error("writing more data than expected"),{path:this.absolute});return this.emit("error",i)}return this.remain-=t.length,this.blockRemain-=t.length,this.pos+=t.length,this.offset+=t.length,super.write(t,null,r)}[ba](){if(!this.remain)return this.blockRemain&&super.write(Buffer.alloc(this.blockRemain)),this[sn](t=>t?this.emit("error",t):this.end());if(!this.buf)throw new Error("buffer lost somehow in ONDRAIN");this.offset>=this.length&&(this.buf=Buffer.allocUnsafe(Math.min(this.blockRemain,this.buf.length)),this.offset=0),this.length=this.buf.length-this.offset,this[xs]()}},fm=class extends Sf{sync=!0;[Na](){this[hs](_t.lstatSync(this.absolute))}[Oa](){this[Ba](_t.readlinkSync(this.absolute))}[za](){this[Fa](_t.openSync(this.absolute,"r"))}[xs](){let t=!0;try{let{fd:e,buf:r,offset:i,length:o,pos:c}=this;if(e===void 0||r===void 0)throw new Error("fd and buf must be set in READ method");let f=_t.readSync(e,r,i,o,c);this[Ma](f),t=!1}finally{if(t)try{this[sn](()=>{})}catch{}}}[Ua](t){t()}[sn](t=()=>{}){this.fd!==void 0&&_t.closeSync(this.fd),t()}},um=class extends Dn{blockLen=0;blockRemain=0;buf=0;pos=0;remain=0;length=0;preservePaths;portable;strict;noPax;noMtime;readEntry;type;prefix;path;mode;uid;gid;uname;gname;header;mtime;atime;ctime;linkpath;size;onWriteEntry;warn(t,e,r={}){return Cs(this,t,e,r)}constructor(t,e={}){let r=Xa(e);super(),this.preservePaths=!!r.preservePaths,this.portable=!!r.portable,this.strict=!!r.strict,this.noPax=!!r.noPax,this.noMtime=!!r.noMtime,this.onWriteEntry=r.onWriteEntry,this.readEntry=t;let{type:i}=t;if(i==="Unsupported")throw new Error("writing entry that should be ignored");this.type=i,this.type==="Directory"&&this.portable&&(this.noMtime=!0),this.prefix=r.prefix,this.path=Y(t.path),this.mode=t.mode!==void 0?this[vs](t.mode):void 0,this.uid=this.portable?void 0:t.uid,this.gid=this.portable?void 0:t.gid,this.uname=this.portable?void 0:t.uname,this.gname=this.portable?void 0:t.gname,this.size=t.size,this.mtime=this.noMtime?void 0:r.mtime||t.mtime,this.atime=this.portable?void 0:t.atime,this.ctime=this.portable?void 0:t.ctime,this.linkpath=t.linkpath!==void 0?Y(t.linkpath):void 0,typeof r.onwarn=="function"&&this.on("warn",r.onwarn);let o=!1;if(!this.preservePaths){let[f,l]=tc(this.path);f&&typeof l=="string"&&(this.path=l,o=f)}this.remain=t.size,this.blockRemain=t.startBlockSize,this.onWriteEntry?.(this),this.header=new Rn({path:this[yt](this.path),linkpath:this.type==="Link"&&this.linkpath!==void 0?this[yt](this.linkpath):this.linkpath,mode:this.mode,uid:this.portable?void 0:this.uid,gid:this.portable?void 0:this.gid,size:this.size,mtime:this.noMtime?void 0:this.mtime,type:this.type,uname:this.portable?void 0:this.uname,atime:this.portable?void 0:this.atime,ctime:this.portable?void 0:this.ctime}),o&&this.warn("TAR_ENTRY_INFO",`stripping ${o} from absolute path`,{entry:this,path:o+this.path}),this.header.encode()&&!this.noPax&&super.write(new bs({atime:this.portable?void 0:this.atime,ctime:this.portable?void 0:this.ctime,gid:this.portable?void 0:this.gid,mtime:this.noMtime?void 0:this.mtime,path:this[yt](this.path),linkpath:this.type==="Link"&&this.linkpath!==void 0?this[yt](this.linkpath):this.linkpath,size:this.size,uid:this.portable?void 0:this.uid,uname:this.portable?void 0:this.uname,dev:this.portable?void 0:this.readEntry.dev,ino:this.portable?void 0:this.readEntry.ino,nlink:this.portable?void 0:this.readEntry.nlink}).encode());let c=this.header?.block;if(!c)throw new Error("failed to encode header");super.write(c),t.pipe(this)}[yt](t){return vf(t,this.prefix)}[vs](t){return Ef(t,this.type==="Directory",this.portable)}write(t,e,r){typeof e=="function"&&(r=e,e=void 0),typeof t=="string"&&(t=Buffer.from(t,typeof e=="string"?e:"utf8"));let i=t.length;if(i>this.blockRemain)throw new Error("writing more to entry than is appropriate");return this.blockRemain-=i,super.write(t,r)}end(t,e,r){return this.blockRemain&&super.write(Buffer.alloc(this.blockRemain)),typeof t=="function"&&(r=t,e=void 0,t=void 0),typeof e=="function"&&(r=e,e=void 0),typeof t=="string"&&(t=Buffer.from(t,e??"utf8")),r&&this.once("finish",r),t?super.end(t,r):super.end(r),this}},lm=t=>t.isFile()?"File":t.isDirectory()?"Directory":t.isSymbolicLink()?"SymbolicLink":"Unsupported",xm=class or{tail;head;length=0;static create(e=[]){return new or(e)}constructor(e=[]){for(let r of e)this.push(r)}*[Symbol.iterator](){for(let e=this.head;e;e=e.next)yield e.value}removeNode(e){if(e.list!==this)throw new Error("removing node which does not belong to this list");let r=e.next,i=e.prev;return r&&(r.prev=i),i&&(i.next=r),e===this.head&&(this.head=r),e===this.tail&&(this.tail=i),this.length--,e.next=void 0,e.prev=void 0,e.list=void 0,r}unshiftNode(e){if(e===this.head)return;e.list&&e.list.removeNode(e);let r=this.head;e.list=this,e.next=r,r&&(r.prev=e),this.head=e,this.tail||(this.tail=e),this.length++}pushNode(e){if(e===this.tail)return;e.list&&e.list.removeNode(e);let r=this.tail;e.list=this,e.prev=r,r&&(r.next=e),this.tail=e,this.head||(this.head=e),this.length++}push(...e){for(let r=0,i=e.length;r<i;r++)pm(this,e[r]);return this.length}unshift(...e){for(var r=0,i=e.length;r<i;r++)gm(this,e[r]);return this.length}pop(){if(!this.tail)return;let e=this.tail.value,r=this.tail;return this.tail=this.tail.prev,this.tail?this.tail.next=void 0:this.head=void 0,r.list=void 0,this.length--,e}shift(){if(!this.head)return;let e=this.head.value,r=this.head;return this.head=this.head.next,this.head?this.head.prev=void 0:this.tail=void 0,r.list=void 0,this.length--,e}forEach(e,r){r=r||this;for(let i=this.head,o=0;i;o++)e.call(r,i.value,o,this),i=i.next}forEachReverse(e,r){r=r||this;for(let i=this.tail,o=this.length-1;i;o--)e.call(r,i.value,o,this),i=i.prev}get(e){let r=0,i=this.head;for(;i&&r<e;r++)i=i.next;if(r===e&&i)return i.value}getReverse(e){let r=0,i=this.tail;for(;i&&r<e;r++)i=i.prev;if(r===e&&i)return i.value}map(e,r){r=r||this;let i=new or;for(let o=this.head;o;)i.push(e.call(r,o.value,this)),o=o.next;return i}mapReverse(e,r){r=r||this;var i=new or;for(let o=this.tail;o;)i.push(e.call(r,o.value,this)),o=o.prev;return i}reduce(e,r){let i,o=this.head;if(arguments.length>1)i=r;else if(this.head)o=this.head.next,i=this.head.value;else throw new TypeError("Reduce of empty list with no initial value");for(var c=0;o;c++)i=e(i,o.value,c),o=o.next;return i}reduceReverse(e,r){let i,o=this.tail;if(arguments.length>1)i=r;else if(this.tail)o=this.tail.prev,i=this.tail.value;else throw new TypeError("Reduce of empty list with no initial value");for(let c=this.length-1;o;c--)i=e(i,o.value,c),o=o.prev;return i}toArray(){let e=new Array(this.length);for(let r=0,i=this.head;i;r++)e[r]=i.value,i=i.next;return e}toArrayReverse(){let e=new Array(this.length);for(let r=0,i=this.tail;i;r++)e[r]=i.value,i=i.prev;return e}slice(e=0,r=this.length){r<0&&(r+=this.length),e<0&&(e+=this.length);let i=new or;if(r<e||r<0)return i;e<0&&(e=0),r>this.length&&(r=this.length);let o=this.head,c=0;for(c=0;o&&c<e;c++)o=o.next;for(;o&&c<r;c++,o=o.next)i.push(o.value);return i}sliceReverse(e=0,r=this.length){r<0&&(r+=this.length),e<0&&(e+=this.length);let i=new or;if(r<e||r<0)return i;e<0&&(e=0),r>this.length&&(r=this.length);let o=this.length,c=this.tail;for(;c&&o>r;o--)c=c.prev;for(;c&&o>e;o--,c=c.prev)i.push(c.value);return i}splice(e,r=0,...i){e>this.length&&(e=this.length-1),e<0&&(e=this.length+e);let o=this.head;for(let f=0;o&&f<e;f++)o=o.next;let c=[];for(let f=0;o&&f<r;f++)c.push(o.value),o=this.removeNode(o);o?o!==this.tail&&(o=o.prev):o=this.tail;for(let f of i)o=hm(this,o,f);return c}reverse(){let e=this.head,r=this.tail;for(let i=e;i;i=i.prev){let o=i.prev;i.prev=i.next,i.next=o}return this.head=r,this.tail=e,this}};function hm(t,e,r){let i=e,o=e?e.next:t.head,c=new rc(r,i,o,t);return c.next===void 0&&(t.tail=c),c.prev===void 0&&(t.head=c),t.length++,c}function pm(t,e){t.tail=new rc(e,t.tail,void 0,t),t.head||(t.head=t.tail),t.length++}function gm(t,e){t.head=new rc(e,void 0,t.head,t),t.tail||(t.tail=t.head),t.length++}var rc=class{list;next;prev;value;constructor(t,e,r,i){this.list=i,this.value=t,e?(e.next=this,this.prev=e):this.prev=void 0,r?(r.prev=this,this.next=r):this.next=void 0}},$d=class{path;absolute;entry;stat;readdir;pending=!1;pendingLink=!1;ignore=!1;piped=!1;constructor(t,e){this.path=t||"./",this.absolute=e}},Jd=Buffer.alloc(1024),ps=Symbol("onStat"),jr=Symbol("ended"),ft=Symbol("queue"),Kr=Symbol("queue"),en=Symbol("current"),In=Symbol("process"),Wr=Symbol("processing"),cs=Symbol("processJob"),ut=Symbol("jobs"),Ea=Symbol("jobDone"),gs=Symbol("addFSEntry"),Yd=Symbol("addTarEntry"),qa=Symbol("stat"),Ha=Symbol("readdir"),ms=Symbol("onreaddir"),ws=Symbol("pipe"),Zd=Symbol("entry"),va=Symbol("entryOpt"),_s=Symbol("writeEntryClass"),If=Symbol("write"),Sa=Symbol("ondrain"),Ds=class extends Dn{sync=!1;opt;cwd;maxReadSize;preservePaths;strict;noPax;prefix;linkCache;statCache;file;portable;zip;readdirCache;noDirRecurse;follow;noMtime;mtime;filter;jobs;[_s];onWriteEntry;[ft];[Kr]=new Map;[ut]=0;[Wr]=!1;[jr]=!1;constructor(t={}){if(super(),this.opt=t,this.file=t.file||"",this.cwd=t.cwd||process.cwd(),this.maxReadSize=t.maxReadSize,this.preservePaths=!!t.preservePaths,this.strict=!!t.strict,this.noPax=!!t.noPax,this.prefix=Y(t.prefix||""),this.linkCache=t.linkCache||new Map,this.statCache=t.statCache||new Map,this.readdirCache=t.readdirCache||new Map,this.onWriteEntry=t.onWriteEntry,this[_s]=Sf,typeof t.onwarn=="function"&&this.on("warn",t.onwarn),this.portable=!!t.portable,t.gzip||t.brotli||t.zstd){if((t.gzip?1:0)+(t.brotli?1:0)+(t.zstd?1:0)>1)throw new TypeError("gzip, brotli, zstd are mutually exclusive");if(t.gzip&&(typeof t.gzip!="object"&&(t.gzip={}),this.portable&&(t.gzip.portable=!0),this.zip=new Sg(t.gzip)),t.brotli&&(typeof t.brotli!="object"&&(t.brotli={}),this.zip=new Ag(t.brotli)),t.zstd&&(typeof t.zstd!="object"&&(t.zstd={}),this.zip=new Cg(t.zstd)),!this.zip)throw new Error("impossible");let e=this.zip;e.on("data",r=>super.write(r)),e.on("end",()=>super.end()),e.on("drain",()=>this[Sa]()),this.on("resume",()=>e.resume())}else this.on("drain",this[Sa]);this.noDirRecurse=!!t.noDirRecurse,this.follow=!!t.follow,this.noMtime=!!t.noMtime,t.mtime&&(this.mtime=t.mtime),this.filter=typeof t.filter=="function"?t.filter:()=>!0,this[ft]=new xm,this[ut]=0,this.jobs=Number(t.jobs)||4,this[Wr]=!1,this[jr]=!1}[If](t){return super.write(t)}add(t){return this.write(t),this}end(t,e,r){return typeof t=="function"&&(r=t,t=void 0),typeof e=="function"&&(r=e,e=void 0),t&&this.add(t),this[jr]=!0,this[In](),r&&r(),this}write(t){if(this[jr])throw new Error("write after end");return t instanceof yf?this[Yd](t):this[gs](t),this.flowing}[Yd](t){let e=Y(Vd.resolve(this.cwd,t.path));if(!this.filter(t.path,t))t.resume();else{let r=new $d(t.path,e);r.entry=new um(t,this[va](r)),r.entry.on("end",()=>this[Ea](r)),this[ut]+=1,this[ft].push(r)}this[In]()}[gs](t){let e=Y(Vd.resolve(this.cwd,t));this[ft].push(new $d(t,e)),this[In]()}[qa](t){t.pending=!0,this[ut]+=1;let e=this.follow?"stat":"lstat";Es[e](t.absolute,(r,i)=>{t.pending=!1,this[ut]-=1,r?this.emit("error",r):this[ps](t,i)})}[ps](t,e){if(this.statCache.set(t.absolute,e),t.stat=e,!this.filter(t.path,e))t.ignore=!0;else if(e.isFile()&&e.nlink>1&&!this.linkCache.get(`${e.dev}:${e.ino}`)&&!this.sync)if(t===this[en])this[cs](t);else{let r=`${e.dev}:${e.ino}`,i=this[Kr].get(r);i?i.push(t):this[Kr].set(r,[t]),t.pendingLink=!0,t.pending=!0}this[In]()}[Ha](t){t.pending=!0,this[ut]+=1,Es.readdir(t.absolute,(e,r)=>{if(t.pending=!1,this[ut]-=1,e)return this.emit("error",e);this[ms](t,r)})}[ms](t,e){this.readdirCache.set(t.absolute,e),t.readdir=e,this[In]()}[In](){if(!this[Wr]){this[Wr]=!0;for(let t=this[ft].head;t&&this[ut]<this.jobs;t=t.next)if(this[cs](t.value),t.value.ignore){let e=t.next;this[ft].removeNode(t),t.next=e}this[Wr]=!1,this[jr]&&this[ft].length===0&&this[ut]===0&&(this.zip?this.zip.end(Jd):(super.write(Jd),super.end()))}}get[en](){return this[ft]&&this[ft].head&&this[ft].head.value}[Ea](t){this[ft].shift(),this[ut]-=1;let{stat:e}=t;if(e&&e.isFile()&&e.nlink>1){let r=`${e.dev}:${e.ino}`,i=this[Kr].get(r);if(i){this[Kr].delete(r);for(let o of i)o.pending=!1,this[cs](o)}}this[In]()}[cs](t){if(t.pending&&t.pendingLink&&t===this[en]&&(t.pending=!1,t.pendingLink=!1),!t.pending){if(t.entry){t===this[en]&&!t.piped&&this[ws](t);return}if(!t.stat){let e=this.statCache.get(t.absolute);e?this[ps](t,e):this[qa](t)}if(t.stat&&!t.ignore){if(!this.noDirRecurse&&t.stat.isDirectory()&&!t.readdir){let e=this.readdirCache.get(t.absolute);if(e?this[ms](t,e):this[Ha](t),!t.readdir)return}if(t.entry=this[Zd](t),!t.entry){t.ignore=!0;return}t===this[en]&&!t.piped&&this[ws](t)}}}[va](t){return{onwarn:(e,r,i)=>this.warn(e,r,i),noPax:this.noPax,cwd:this.cwd,absolute:t.absolute,preservePaths:this.preservePaths,maxReadSize:this.maxReadSize,strict:this.strict,portable:this.portable,linkCache:this.linkCache,statCache:this.statCache,noMtime:this.noMtime,mtime:this.mtime,prefix:this.prefix,onWriteEntry:this.onWriteEntry}}[Zd](t){this[ut]+=1;try{return new this[_s](t.path,this[va](t)).on("end",()=>this[Ea](t)).on("error",e=>this.emit("error",e))}catch(e){this.emit("error",e)}}[Sa](){this[en]&&this[en].entry&&this[en].entry.resume()}[ws](t){t.piped=!0,t.readdir&&t.readdir.forEach(i=>{let o=t.path,c=o==="./"?"":o.replace(/\/*$/,"/");this[gs](c+i)});let e=t.entry,r=this.zip;if(!e)throw new Error("cannot pipe without source");r?e.on("data",i=>{r.write(i)||e.pause()}):e.on("data",i=>{super.write(i)||e.pause()})}pause(){return this.zip&&this.zip.pause(),super.pause()}warn(t,e,r={}){Cs(this,t,e,r)}},ic=class extends Ds{sync=!0;constructor(t){super(t),this[_s]=fm}pause(){}resume(){}[qa](t){let e=this.follow?"statSync":"lstatSync";this[ps](t,Es[e](t.absolute))}[Ha](t){this[ms](t,Es.readdirSync(t.absolute))}[ws](t){let e=t.entry,r=this.zip;if(t.readdir&&t.readdir.forEach(i=>{let o=t.path,c=o==="./"?"":o.replace(/\/*$/,"/");this[gs](c+i)}),!e)throw new Error("Cannot pipe without source");r?e.on("data",i=>{r.write(i)}):e.on("data",i=>{super[If](i)})}},mm=(t,e)=>{let r=new ic(t),i=new lf(t.file,{mode:t.mode||438});r.pipe(i),Af(r,e)},wm=(t,e)=>{let r=new Ds(t),i=new As(t.file,{mode:t.mode||438});r.pipe(i);let o=new Promise((c,f)=>{i.on("error",f),i.on("close",c),r.on("error",f)});return Tf(r,e).catch(c=>r.emit("error",c)),o},Af=(t,e)=>{e.forEach(r=>{r.charAt(0)==="@"?dr({file:xf.resolve(t.cwd,r.slice(1)),sync:!0,noResume:!0,onReadEntry:i=>t.add(i)}):t.add(r)}),t.end()},Tf=async(t,e)=>{for(let r of e)r.charAt(0)==="@"?await dr({file:xf.resolve(String(t.cwd),r.slice(1)),noResume:!0,onReadEntry:i=>{t.add(i)}}):t.add(r);t.end()},_m=(t,e)=>{let r=new ic(t);return Af(r,e),r},ym=(t,e)=>{let r=new Ds(t);return Tf(r,e).catch(i=>r.emit("error",i)),r},gv=si(mm,wm,_m,ym,(t,e)=>{if(!e?.length)throw new TypeError("no paths specified to add to archive")}),Em=process.env.__FAKE_PLATFORM__||process.platform,kf=Em==="win32",{O_CREAT:Lf,O_NOFOLLOW:Xd,O_TRUNC:Pf,O_WRONLY:Of}=Df.constants,Nf=Number(process.env.__FAKE_FS_O_FILENAME__)||Df.constants.UV_FS_O_FILEMAP||0,vm=kf&&!!Nf,Sm=512*1024,Im=Nf|Pf|Lf|Of,Qd=!kf&&typeof Xd=="number"?Xd|Pf|Lf|Of:null,Mf=Qd!==null?()=>Qd:vm?t=>t<Sm?Im:"w":()=>"w",Ga=(t,e,r)=>{try{return ks.lchownSync(t,e,r)}catch(i){if(i?.code!=="ENOENT")throw i}},Ss=(t,e,r,i)=>{ks.lchown(t,e,r,o=>{i(o&&o?.code!=="ENOENT"?o:null)})},Am=(t,e,r,i,o)=>{if(e.isDirectory())Bf(Xr.resolve(t,e.name),r,i,c=>{if(c)return o(c);let f=Xr.resolve(t,e.name);Ss(f,r,i,o)});else{let c=Xr.resolve(t,e.name);Ss(c,r,i,o)}},Bf=(t,e,r,i)=>{ks.readdir(t,{withFileTypes:!0},(o,c)=>{if(o){if(o.code==="ENOENT")return i();if(o.code!=="ENOTDIR"&&o.code!=="ENOTSUP")return i(o)}if(o||!c.length)return Ss(t,e,r,i);let f=c.length,l=null,x=p=>{if(!l){if(p)return i(l=p);if(--f===0)return Ss(t,e,r,i)}};for(let p of c)Am(t,p,e,r,x)})},Tm=(t,e,r,i)=>{e.isDirectory()&&zf(Xr.resolve(t,e.name),r,i),Ga(Xr.resolve(t,e.name),r,i)},zf=(t,e,r)=>{let i;try{i=ks.readdirSync(t,{withFileTypes:!0})}catch(o){let c=o;if(c?.code==="ENOENT")return;if(c?.code==="ENOTDIR"||c?.code==="ENOTSUP")return Ga(t,e,r);throw c}for(let o of i)Tm(t,o,e,r);return Ga(t,e,r)},Ff=class extends Error{path;code;syscall="chdir";constructor(t,e){super(`${e}: Cannot cd into '${t}'`),this.path=t,this.code=e}get name(){return"CwdError"}},Ls=class extends Error{path;symlink;syscall="symlink";code="TAR_SYMLINK_ERROR";constructor(t,e){super("TAR_SYMLINK_ERROR: Cannot extract through symbolic link"),this.symlink=t,this.path=e}get name(){return"SymlinkError"}},Rm=(t,e)=>{Ze.stat(t,(r,i)=>{(r||!i.isDirectory())&&(r=new Ff(t,r?.code||"ENOTDIR")),e(r)})},Dm=(t,e,r)=>{t=Y(t);let i=e.umask??18,o=e.mode|448,c=(o&i)!==0,f=e.uid,l=e.gid,x=typeof f=="number"&&typeof l=="number"&&(f!==e.processUid||l!==e.processGid),p=e.preserve,w=e.unlink,b=Y(e.cwd),T=(v,I)=>{v?r(v):I&&x?Bf(I,f,l,A=>T(A)):c?Ze.chmod(t,o,r):r()};if(t===b)return Rm(t,T);if(p)return Cm.mkdir(t,{mode:o,recursive:!0}).then(v=>T(null,v??void 0),T);let E=Y(Is.relative(b,t)).split("/");ja(b,E,o,w,b,void 0,T)},ja=(t,e,r,i,o,c,f)=>{if(e.length===0)return f(null,c);let l=e.shift(),x=Y(Is.resolve(t+"/"+l));Ze.mkdir(x,r,Uf(x,e,r,i,o,c,f))},Uf=(t,e,r,i,o,c,f)=>l=>{l?Ze.lstat(t,(x,p)=>{if(x)x.path=x.path&&Y(x.path),f(x);else if(p.isDirectory())ja(t,e,r,i,o,c,f);else if(i)Ze.unlink(t,w=>{if(w)return f(w);Ze.mkdir(t,r,Uf(t,e,r,i,o,c,f))});else{if(p.isSymbolicLink())return f(new Ls(t,t+"/"+e.join("/")));f(l)}}):(c=c||t,ja(t,e,r,i,o,c,f))},km=t=>{let e=!1,r;try{e=Ze.statSync(t).isDirectory()}catch(i){r=i?.code}finally{if(!e)throw new Ff(t,r??"ENOTDIR")}},Lm=(t,e)=>{t=Y(t);let r=e.umask??18,i=e.mode|448,o=(i&r)!==0,c=e.uid,f=e.gid,l=typeof c=="number"&&typeof f=="number"&&(c!==e.processUid||f!==e.processGid),x=e.preserve,p=e.unlink,w=Y(e.cwd),b=v=>{v&&l&&zf(v,c,f),o&&Ze.chmodSync(t,i)};if(t===w)return km(w),b();if(x)return b(Ze.mkdirSync(t,{mode:i,recursive:!0})??void 0);let T=Y(Is.relative(w,t)).split("/"),E;for(let v=T.shift(),I=w;v&&(I+="/"+v);v=T.shift()){I=Y(Is.resolve(I));try{Ze.mkdirSync(I,i),E=E||I}catch{let A=Ze.lstatSync(I);if(A.isDirectory())continue;if(p){Ze.unlinkSync(I),Ze.mkdirSync(I,i),E=E||I;continue}else if(A.isSymbolicLink())return new Ls(I,I+"/"+T.join("/"))}}return b(E)},Ia=Object.create(null),ef=1e4,er=new Set,Pm=t=>{er.has(t)?er.delete(t):Ia[t]=t.normalize("NFD").toLocaleLowerCase("en").toLocaleUpperCase("en"),er.add(t);let e=Ia[t],r=er.size-ef;if(r>ef/10){for(let i of er)if(er.delete(i),delete Ia[i],--r<=0)break}return e},Om=process.env.TESTING_TAR_FAKE_PLATFORM||process.platform,Nm=Om==="win32",Mm=t=>t.split("/").slice(0,-1).reduce((e,r)=>{let i=e.at(-1);return i!==void 0&&(r=qf(i,r)),e.push(r||"/"),e},[]),Bm=class{#e=new Map;#n=new Map;#r=new Set;reserve(t,e){t=Nm?["win32 parallelization disabled"]:t.map(i=>Zr(qf(Pm(i))));let r=new Set(t.map(i=>Mm(i)).reduce((i,o)=>i.concat(o)));this.#n.set(e,{dirs:r,paths:t});for(let i of t){let o=this.#e.get(i);o?o.push(e):this.#e.set(i,[e])}for(let i of r){let o=this.#e.get(i);if(!o)this.#e.set(i,[new Set([e])]);else{let c=o.at(-1);c instanceof Set?c.add(e):o.push(new Set([e]))}}return this.#i(e)}#s(t){let e=this.#n.get(t);if(!e)throw new Error("function does not have any path reservations");return{paths:e.paths.map(r=>this.#e.get(r)),dirs:[...e.dirs].map(r=>this.#e.get(r))}}check(t){let{paths:e,dirs:r}=this.#s(t);return e.every(i=>i&&i[0]===t)&&r.every(i=>i&&i[0]instanceof Set&&i[0].has(t))}#i(t){return this.#r.has(t)||!this.check(t)?!1:(this.#r.add(t),t(()=>this.#t(t)),!0)}#t(t){if(!this.#r.has(t))return!1;let e=this.#n.get(t);if(!e)throw new Error("invalid reservation");let{paths:r,dirs:i}=e,o=new Set;for(let c of r){let f=this.#e.get(c);if(!f||f?.[0]!==t)continue;let l=f[1];if(!l){this.#e.delete(c);continue}if(f.shift(),typeof l=="function")o.add(l);else for(let x of l)o.add(x)}for(let c of i){let f=this.#e.get(c),l=f?.[0];if(!(!f||!(l instanceof Set)))if(l.size===1&&f.length===1){this.#e.delete(c);continue}else if(l.size===1){f.shift();let x=f[0];typeof x=="function"&&o.add(x)}else l.delete(t)}return this.#r.delete(t),o.forEach(c=>this.#i(c)),!0}},zm=()=>process.umask(),tf=Symbol("onEntry"),Ka=Symbol("checkFs"),nf=Symbol("checkFs2"),Wa=Symbol("isReusable"),it=Symbol("makeFs"),Va=Symbol("file"),$a=Symbol("directory"),ys=Symbol("link"),rf=Symbol("symlink"),sf=Symbol("hardlink"),Jr=Symbol("ensureNoSymlink"),of=Symbol("unsupported"),af=Symbol("checkPath"),Aa=Symbol("stripAbsolutePath"),on=Symbol("mkdir"),De=Symbol("onError"),ds=Symbol("pending"),cf=Symbol("pend"),tr=Symbol("unpend"),Ta=Symbol("ended"),Ca=Symbol("maybeClose"),Ja=Symbol("skip"),Qr=Symbol("doChown"),ei=Symbol("uid"),ti=Symbol("gid"),ni=Symbol("checkedCwd"),Fm=process.env.TESTING_TAR_FAKE_PLATFORM||process.platform,ri=Fm==="win32",Um=1024,qm=(t,e)=>{if(!ri)return X.unlink(t,e);let r=t+".DELETE."+Rf(16).toString("hex");X.rename(t,r,i=>{if(i)return e(i);X.unlink(r,e)})},Hm=t=>{if(!ri)return X.unlinkSync(t);let e=t+".DELETE."+Rf(16).toString("hex");X.renameSync(t,e),X.unlinkSync(e)},df=(t,e,r)=>t!==void 0&&t===t>>>0?t:e!==void 0&&e===e>>>0?e:r,sc=class extends ii{[Ta]=!1;[ni]=!1;[ds]=0;reservations=new Bm;transform;writable=!0;readable=!1;uid;gid;setOwner;preserveOwner;processGid;processUid;maxDepth;forceChown;win32;newer;keep;noMtime;preservePaths;unlink;cwd;strip;processUmask;umask;dmode;fmode;chmod;constructor(t={}){if(t.ondone=()=>{this[Ta]=!0,this[Ca]()},super(t),this.transform=t.transform,this.chmod=!!t.chmod,typeof t.uid=="number"||typeof t.gid=="number"){if(typeof t.uid!="number"||typeof t.gid!="number")throw new TypeError("cannot set owner without number uid and gid");if(t.preserveOwner)throw new TypeError("cannot preserve owner in archive and also set owner explicitly");this.uid=t.uid,this.gid=t.gid,this.setOwner=!0}else this.uid=void 0,this.gid=void 0,this.setOwner=!1;this.preserveOwner=t.preserveOwner===void 0&&typeof t.uid!="number"?!!(process.getuid&&process.getuid()===0):!!t.preserveOwner,this.processUid=(this.preserveOwner||this.setOwner)&&process.getuid?process.getuid():void 0,this.processGid=(this.preserveOwner||this.setOwner)&&process.getgid?process.getgid():void 0,this.maxDepth=typeof t.maxDepth=="number"?t.maxDepth:Um,this.forceChown=t.forceChown===!0,this.win32=!!t.win32||ri,this.newer=!!t.newer,this.keep=!!t.keep,this.noMtime=!!t.noMtime,this.preservePaths=!!t.preservePaths,this.unlink=!!t.unlink,this.cwd=Y(ve.resolve(t.cwd||process.cwd())),this.strip=Number(t.strip)||0,this.processUmask=this.chmod?typeof t.processUmask=="number"?t.processUmask:zm():0,this.umask=typeof t.umask=="number"?t.umask:this.processUmask,this.dmode=t.dmode||511&~this.umask,this.fmode=t.fmode||438&~this.umask,this.on("entry",e=>this[tf](e))}warn(t,e,r={}){return(t==="TAR_BAD_ARCHIVE"||t==="TAR_ABORT")&&(r.recoverable=!1),super.warn(t,e,r)}[Ca](){this[Ta]&&this[ds]===0&&(this.emit("prefinish"),this.emit("finish"),this.emit("end"))}[Aa](t,e){let r=t[e],{type:i}=t;if(!r||this.preservePaths)return!0;let[o,c]=tc(r),f=c.replaceAll(/\\/g,"/").split("/");if(f.includes("..")||ri&&/^[a-z]:\.\.$/i.test(f[0]??"")){if(e==="path"||i==="Link")return this.warn("TAR_ENTRY_ERROR",`${e} contains '..'`,{entry:t,[e]:r}),!1;let l=ve.posix.dirname(t.path),x=ve.posix.normalize(ve.posix.join(l,f.join("/")));if(x.startsWith("../")||x==="..")return this.warn("TAR_ENTRY_ERROR",`${e} escapes extraction directory`,{entry:t,[e]:r}),!1}return o&&(t[e]=String(c),this.warn("TAR_ENTRY_INFO",`stripping ${o} from absolute ${e}`,{entry:t,[e]:r})),!0}[af](t){let e=Y(t.path),r=e.split("/");if(this.strip){if(r.length<this.strip)return!1;if(t.type==="Link"){let i=Y(String(t.linkpath)).split("/");if(i.length>=this.strip)t.linkpath=i.slice(this.strip).join("/");else return!1}r.splice(0,this.strip),t.path=r.join("/")}if(isFinite(this.maxDepth)&&r.length>this.maxDepth)return this.warn("TAR_ENTRY_ERROR","path excessively deep",{entry:t,path:e,depth:r.length,maxDepth:this.maxDepth}),!1;if(!this[Aa](t,"path")||!this[Aa](t,"linkpath"))return!1;if(t.absolute=ve.isAbsolute(t.path)?Y(ve.resolve(t.path)):Y(ve.resolve(this.cwd,t.path)),!this.preservePaths&&typeof t.absolute=="string"&&t.absolute.indexOf(this.cwd+"/")!==0&&t.absolute!==this.cwd)return this.warn("TAR_ENTRY_ERROR","path escaped extraction target",{entry:t,path:Y(t.path),resolvedPath:t.absolute,cwd:this.cwd}),!1;if(t.absolute===this.cwd&&t.type!=="Directory"&&t.type!=="GNUDumpDir")return!1;if(this.win32){let{root:i}=ve.win32.parse(String(t.absolute));t.absolute=i+Hd(String(t.absolute).slice(i.length));let{root:o}=ve.win32.parse(t.path);t.path=o+Hd(t.path.slice(o.length))}return!0}[tf](t){if(!this[af](t))return t.resume();switch(bm.equal(typeof t.absolute,"string"),t.type){case"Directory":case"GNUDumpDir":t.mode&&(t.mode=t.mode|448);case"File":case"OldFile":case"ContiguousFile":case"Link":case"SymbolicLink":return this[Ka](t);default:return this[of](t)}}[De](t,e){t.name==="CwdError"?this.emit("error",t):(this.warn("TAR_ENTRY_ERROR",t,{entry:e}),this[tr](),e.resume())}[on](t,e,r){Dm(Y(t),{uid:this.uid,gid:this.gid,processUid:this.processUid,processGid:this.processGid,umask:this.processUmask,preserve:this.preservePaths,unlink:this.unlink,cwd:this.cwd,mode:e},r)}[Qr](t){return this.forceChown||this.preserveOwner&&(typeof t.uid=="number"&&t.uid!==this.processUid||typeof t.gid=="number"&&t.gid!==this.processGid)||typeof this.uid=="number"&&this.uid!==this.processUid||typeof this.gid=="number"&&this.gid!==this.processGid}[ei](t){return df(this.uid,t.uid,this.processUid)}[ti](t){return df(this.gid,t.gid,this.processGid)}[Va](t,e){let r=typeof t.mode=="number"?t.mode&4095:this.fmode,i=new As(String(t.absolute),{flags:Mf(t.size),mode:r,autoClose:!1});i.on("error",l=>{i.fd&&X.close(i.fd,()=>{}),i.write=()=>!0,this[De](l,t),e()});let o=1,c=l=>{if(l){i.fd&&X.close(i.fd,()=>{}),this[De](l,t),e();return}--o===0&&i.fd!==void 0&&X.close(i.fd,x=>{x?this[De](x,t):this[tr](),e()})};i.on("finish",()=>{let l=String(t.absolute),x=i.fd;if(typeof x=="number"&&t.mtime&&!this.noMtime){o++;let p=t.atime||new Date,w=t.mtime;X.futimes(x,p,w,b=>b?X.utimes(l,p,w,T=>c(T&&b)):c())}if(typeof x=="number"&&this[Qr](t)){o++;let p=this[ei](t),w=this[ti](t);typeof p=="number"&&typeof w=="number"&&X.fchown(x,p,w,b=>b?X.chown(l,p,w,T=>c(T&&b)):c())}c()});let f=this.transform&&this.transform(t)||t;f!==t&&(f.on("error",l=>{this[De](l,t),e()}),t.pipe(f)),f.pipe(i)}[$a](t,e){let r=typeof t.mode=="number"?t.mode&4095:this.dmode;this[on](String(t.absolute),r,i=>{if(i){this[De](i,t),e();return}let o=1,c=()=>{--o===0&&(e(),this[tr](),t.resume())};t.mtime&&!this.noMtime&&(o++,X.utimes(String(t.absolute),t.atime||new Date,t.mtime,c)),this[Qr](t)&&(o++,X.chown(String(t.absolute),Number(this[ei](t)),Number(this[ti](t)),c)),c()})}[of](t){t.unsupported=!0,this.warn("TAR_ENTRY_UNSUPPORTED",`unsupported entry type: ${t.type}`,{entry:t}),t.resume()}[rf](t,e){let r=Y(ve.relative(this.cwd,ve.resolve(ve.dirname(String(t.absolute)),String(t.linkpath)))).split("/");this[Jr](t,this.cwd,r,()=>this[ys](t,String(t.linkpath),"symlink",e),i=>{this[De](i,t),e()})}[sf](t,e){let r=Y(ve.resolve(this.cwd,String(t.linkpath))),i=Y(String(t.linkpath)).split("/");this[Jr](t,this.cwd,i,()=>this[ys](t,r,"link",e),o=>{this[De](o,t),e()})}[Jr](t,e,r,i,o){let c=r.shift();if(this.preservePaths||c===void 0)return i();let f=ve.resolve(e,c);X.lstat(f,(l,x)=>{if(l)return i();if(x?.isSymbolicLink())return o(new Ls(f,ve.resolve(f,r.join("/"))));this[Jr](t,f,r,i,o)})}[cf](){this[ds]++}[tr](){this[ds]--,this[Ca]()}[Ja](t){this[tr](),t.resume()}[Wa](t,e){return t.type==="File"&&!this.unlink&&e.isFile()&&e.nlink<=1&&!ri}[Ka](t){this[cf]();let e=[t.path];t.linkpath&&e.push(t.linkpath),this.reservations.reserve(e,r=>this[nf](t,r))}[nf](t,e){let r=f=>{e(f)},i=()=>{this[on](this.cwd,this.dmode,f=>{if(f){this[De](f,t),r();return}this[ni]=!0,o()})},o=()=>{if(t.absolute!==this.cwd){let f=Y(ve.dirname(String(t.absolute)));if(f!==this.cwd)return this[on](f,this.dmode,l=>{if(l){this[De](l,t),r();return}c()})}c()},c=()=>{X.lstat(String(t.absolute),(f,l)=>{if(l&&(this.keep||this.newer&&l.mtime>(t.mtime??l.mtime))){this[Ja](t),r();return}if(f||this[Wa](t,l))return this[it](null,t,r);if(l.isDirectory()){if(t.type==="Directory"){let x=this.chmod&&t.mode&&(l.mode&4095)!==t.mode,p=w=>this[it](w??null,t,r);return x?X.chmod(String(t.absolute),Number(t.mode),p):p()}if(t.absolute!==this.cwd)return X.rmdir(String(t.absolute),x=>this[it](x??null,t,r))}if(t.absolute===this.cwd)return this[it](null,t,r);qm(String(t.absolute),x=>this[it](x??null,t,r))})};this[ni]?o():i()}[it](t,e,r){if(t){this[De](t,e),r();return}switch(e.type){case"File":case"OldFile":case"ContiguousFile":return this[Va](e,r);case"Link":return this[sf](e,r);case"SymbolicLink":return this[rf](e,r);case"Directory":case"GNUDumpDir":return this[$a](e,r)}}[ys](t,e,r,i){X[r](e,String(t.absolute),o=>{o?this[De](o,t):(this[tr](),t.resume()),i()})}},Vr=t=>{try{return[null,t()]}catch(e){return[e,null]}},Hf=class extends sc{sync=!0;[it](t,e){return super[it](t,e,()=>{})}[Ka](t){if(!this[ni]){let o=this[on](this.cwd,this.dmode);if(o)return this[De](o,t);this[ni]=!0}if(t.absolute!==this.cwd){let o=Y(ve.dirname(String(t.absolute)));if(o!==this.cwd){let c=this[on](o,this.dmode);if(c)return this[De](c,t)}}let[e,r]=Vr(()=>X.lstatSync(String(t.absolute)));if(r&&(this.keep||this.newer&&r.mtime>(t.mtime??r.mtime)))return this[Ja](t);if(e||this[Wa](t,r))return this[it](null,t);if(r.isDirectory()){if(t.type==="Directory"){let c=this.chmod&&t.mode&&(r.mode&4095)!==t.mode,[f]=c?Vr(()=>{X.chmodSync(String(t.absolute),Number(t.mode))}):[];return this[it](f,t)}let[o]=Vr(()=>X.rmdirSync(String(t.absolute)));this[it](o,t)}let[i]=t.absolute===this.cwd?[]:Vr(()=>Hm(String(t.absolute)));this[it](i,t)}[Va](t,e){let r=typeof t.mode=="number"?t.mode&4095:this.fmode,i=f=>{let l;try{X.closeSync(o)}catch(x){l=x}(f||l)&&this[De](f||l,t),e()},o;try{o=X.openSync(String(t.absolute),Mf(t.size),r)}catch(f){return i(f)}let c=this.transform&&this.transform(t)||t;c!==t&&(c.on("error",f=>this[De](f,t)),t.pipe(c)),c.on("data",f=>{try{X.writeSync(o,f,0,f.length)}catch(l){i(l)}}),c.on("end",()=>{let f=null;if(t.mtime&&!this.noMtime){let l=t.atime||new Date,x=t.mtime;try{X.futimesSync(o,l,x)}catch(p){try{X.utimesSync(String(t.absolute),l,x)}catch{f=p}}}if(this[Qr](t)){let l=this[ei](t),x=this[ti](t);try{X.fchownSync(o,Number(l),Number(x))}catch(p){try{X.chownSync(String(t.absolute),Number(l),Number(x))}catch{f=f||p}}}i(f)})}[$a](t,e){let r=typeof t.mode=="number"?t.mode&4095:this.dmode,i=this[on](String(t.absolute),r);if(i){this[De](i,t),e();return}if(t.mtime&&!this.noMtime)try{X.utimesSync(String(t.absolute),t.atime||new Date,t.mtime)}catch{}if(this[Qr](t))try{X.chownSync(String(t.absolute),Number(this[ei](t)),Number(this[ti](t)))}catch{}e(),t.resume()}[on](t,e){try{return Lm(Y(t),{uid:this.uid,gid:this.gid,processUid:this.processUid,processGid:this.processGid,umask:this.processUmask,preserve:this.preservePaths,unlink:this.unlink,cwd:this.cwd,mode:e})}catch(r){return r}}[Jr](t,e,r,i,o){if(this.preservePaths||r.length===0)return i();let c=e;for(let f of r){c=ve.resolve(c,f);let[l,x]=Vr(()=>X.lstatSync(c));if(l)return i();if(x.isSymbolicLink())return o(new Ls(c,ve.resolve(e,r.join("/"))))}i()}[ys](t,e,r,i){let o=`${r}Sync`;try{X[o](e,String(t.absolute)),i(),t.resume()}catch(c){return this[De](c,t)}}},Gm=t=>{let e=new Hf(t),r=t.file,i=Cf.statSync(r),o=t.maxReadSize||16*1024*1024;new dg(r,{readSize:o,size:i.size}).pipe(e)},jm=(t,e)=>{let r=new sc(t),i=t.maxReadSize||16*1024*1024,o=t.file;return new Promise((c,f)=>{r.on("error",f),r.on("close",c),Cf.stat(o,(l,x)=>{if(l)f(l);else{let p=new Za(o,{readSize:i,size:x.size});p.on("error",f),p.pipe(r)}})})},Gf=si(Gm,jm,t=>new Hf(t),t=>new sc(t),(t,e)=>{e?.length&&bf(t,e)}),Km=(t,e)=>{let r=new ic(t),i=!0,o,c;try{try{o=Ye.openSync(t.file,"r+")}catch(x){if(x?.code==="ENOENT")o=Ye.openSync(t.file,"w+");else throw x}let f=Ye.fstatSync(o),l=Buffer.alloc(512);e:for(c=0;c<f.size;c+=512){for(let w=0,b=0;w<512;w+=b){if(b=Ye.readSync(o,l,w,l.length-w,c+w),c===0&&l[0]===31&&l[1]===139)throw new Error("cannot append to compressed archives");if(!b)break e}let x=new Rn(l);if(!x.cksumValid)break;let p=512*Math.ceil((x.size||0)/512);if(c+p+512>f.size)break;c+=p,t.mtimeCache&&x.mtime&&t.mtimeCache.set(String(x.path),x.mtime)}i=!1,Wm(t,r,c,o,e)}finally{if(i)try{Ye.closeSync(o)}catch{}}},Wm=(t,e,r,i,o)=>{let c=new lf(t.file,{fd:i,start:r});e.pipe(c),$m(e,o)},Vm=(t,e)=>{e=Array.from(e);let r=new Ds(t),i=(o,c,f)=>{let l=(T,E)=>{T?Ye.close(o,v=>f(T)):f(null,E)},x=0;if(c===0)return l(null,0);let p=0,w=Buffer.alloc(512),b=(T,E)=>{if(T||E===void 0)return l(T);if(p+=E,p<512&&E)return Ye.read(o,w,p,w.length-p,x+p,b);if(x===0&&w[0]===31&&w[1]===139)return l(new Error("cannot append to compressed archives"));if(p<512)return l(null,x);let v=new Rn(w);if(!v.cksumValid)return l(null,x);let I=512*Math.ceil((v.size??0)/512);if(x+I+512>c||(x+=I+512,x>=c))return l(null,x);t.mtimeCache&&v.mtime&&t.mtimeCache.set(String(v.path),v.mtime),p=0,Ye.read(o,w,0,512,x,b)};Ye.read(o,w,0,512,x,b)};return new Promise((o,c)=>{r.on("error",c);let f="r+",l=(x,p)=>{if(x&&x.code==="ENOENT"&&f==="r+")return f="w+",Ye.open(t.file,f,l);if(x||!p)return c(x);Ye.fstat(p,(w,b)=>{if(w)return Ye.close(p,()=>c(w));i(p,b.size,(T,E)=>{if(T)return c(T);let v=new As(t.file,{fd:p,start:E});r.pipe(v),v.on("error",c),v.on("close",o),Jm(r,e)})})};Ye.open(t.file,f,l)})},$m=(t,e)=>{e.forEach(r=>{r.charAt(0)==="@"?dr({file:jf.resolve(t.cwd,r.slice(1)),sync:!0,noResume:!0,onReadEntry:i=>t.add(i)}):t.add(r)}),t.end()},Jm=async(t,e)=>{for(let r of e)r.charAt(0)==="@"?await dr({file:jf.resolve(String(t.cwd),r.slice(1)),noResume:!0,onReadEntry:i=>t.add(i)}):t.add(r);t.end()},$r=si(Km,Vm,()=>{throw new TypeError("file is required")},()=>{throw new TypeError("file is required")},(t,e)=>{if(!mg(t))throw new TypeError("file is required");if(t.gzip||t.brotli||t.zstd||t.file.endsWith(".br")||t.file.endsWith(".tbr"))throw new TypeError("cannot append to compressed archives");if(!e?.length)throw new TypeError("no paths specified to add/replace")}),kv=si($r.syncFile,$r.asyncFile,$r.syncNoFile,$r.asyncNoFile,(t,e=[])=>{$r.validate?.(t,e),Ym(t)}),Ym=t=>{let e=t.filter;t.mtimeCache||(t.mtimeCache=new Map),t.filter=e?(r,i)=>e(r,i)&&!((t.mtimeCache?.get(r)??i.mtime??0)>(i.mtime??0)):(r,i)=>!((t.mtimeCache?.get(r)??i.mtime??0)>(i.mtime??0))};$t();var Et={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 oi(t){return t?.cozeDeployType==="cloud"?"cloud":"local"}function Kf(t){let e=t?.cozeAccountId?.trim();if(!(!e||e==="0"))return e}function Wf(t){let e=t?.cozeGroupId?.trim();if(!(!e||e==="0"))return e}function Vf(t){let{_meta:e,...r}=t;return{stripped:r,meta:e}}function fr(t){if(!t?.cozeAgentId)throw new Error("missing _meta.cozeAgentId");return t.cozeAgentId}He();ee();Me();He();function Bt(t,e){if(oi(t)!=="cloud")throw new D("OPERATION_NOT_ALLOWED_FOR_LOCAL",`${e} is not allowed for local agent`)}function Ps(t){return t.startsWith("http://")||t.startsWith("https://")}function Os(t){return t.endsWith("/")?t.slice(0,-1):t}He();ee();var Ns="1008033",$f="1289";var Jf="pbbp2",Yf="https://www.coze.cn",Zf="/api/coze_claw/resource/get_frontier_key",Xm="https://www.coze.cn",Qm="wss://frontier.coze.cn";function Ms(t){return t??process.env.COZE_BRIDGE_HANDSHAKE_URL??Xm}function Xf(t){return t??process.env.COZE_BRIDGE_FRONTIER_URL??Qm}function ur(t){let e={},r=t?.ttEnv??process.env.COZE_BRIDGE_TT_ENV,i=t?.usePpe??process.env.COZE_BRIDGE_USE_PPE;return r&&(e["x-tt-env"]=r),i&&(e["x-use-ppe"]=i),e}function ci(t){return t?t.startsWith("boe_")?{ttEnv:t}:{ttEnv:t,usePpe:"1"}:{}}var ai=G("handshake");async function oc(t){let e=Ms(t.endpoint),r=t.timeoutMs??1e4,i=`${Os(e)}${Zf}?aid=${encodeURIComponent(Ns)}`,o={Authorization:`Bearer ${t.privatecode}`,Accept:"application/json",...ur(t.ppeOverride)},c=new AbortController,f=setTimeout(()=>c.abort(),r);ai.info("frontier key handshake",{base:e});try{let l=await fetch(i,{method:"GET",headers:o,signal:c.signal}),x=l.headers.get("x-tt-logid")??"",p=l.headers.get("x-tt-trace-id")??"";if(!l.ok){let v=await l.text().catch(()=>"");throw new D("UPSTREAM_HANDSHAKE_FAILED",`handshake HTTP ${l.status} logid=${x}: ${v.slice(0,200)}`)}let w=await l.json();if(w.code!==void 0&&w.code!==0)throw new D("UPSTREAM_HANDSHAKE_FAILED",`handshake code=${w.code} msg=${w.msg??"-"} logid=${x}`);let b=w.data??{},T=typeof b.access_key=="string"&&b.access_key||typeof b.accessKey=="string"&&b.accessKey||void 0,E=typeof b.device_id=="string"&&b.device_id||typeof b.deviceId=="string"&&b.deviceId||void 0;if(!T||!E){let v=JSON.stringify(w).slice(0,500);throw new D("UPSTREAM_HANDSHAKE_FAILED",`handshake response missing access_key/device_id (also tried camelCase) logid=${x}: ${v}`)}return ai.info("handshake ok",{remoteDeviceId:E,logid:x,traceId:p}),{accessKey:T,deviceId:E}}catch(l){if(l instanceof D)throw ai.error("handshake failed (bridge error)",{base:e,message:l.message,code:l.code}),l;if(l.name==="AbortError")throw ai.warn("handshake timeout",{base:e,timeoutMs:r}),new D("UPSTREAM_HANDSHAKE_FAILED",`handshake timeout (${r}ms)`,{cause:l});let x=l.cause;throw ai.error("handshake error",{base:e,message:l instanceof Error?l.message:String(l),errno:x?.code,syscall:x?.syscall,cause:String(l).slice(0,300)}),new D("UPSTREAM_HANDSHAKE_FAILED",String(l),{cause:l})}finally{clearTimeout(f)}}var ac=process.env.COZE_BRIDGE_LLM_GATEWAY_URL?.trim()||"https://llm-gateway.coze.cn",vt="auto";function Qf(t){return{model:t.model??vt,...t.modelToken?{modelToken:t.modelToken}:{}}}function eu(t){return!t||t===vt}function tu(t){let e={};return t.modelToken?(e.ANTHROPIC_BASE_URL=ac,e.ANTHROPIC_AUTH_TOKEN=t.modelToken,e.ANTHROPIC_MODEL=t.model||vt,t.modelInfo?.contextWindow&&(e.CLAUDE_CODE_MAX_CONTEXT_TOKENS=String(t.modelInfo.contextWindow))):eu(t.model)||(e.ANTHROPIC_MODEL=t.model),e}function nu(t){let e=[];return t.modelToken?e.push("-c",`model="${t.model||vt}"`):eu(t.model)||e.push("-c",`model="${t.model}"`),t.modelToken&&(e.push("-c",'model_providers.coze.name="coze"'),e.push("-c",`model_providers.coze.base_url="${ac}/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"'),t.modelInfo?.contextWindow&&e.push("-c",`model_context_window=${t.modelInfo.contextWindow}`)),e}function ru(t){return t.modelToken?{OPENAI_API_KEY:t.modelToken}:{}}function cc(t,e){let{ttEnv:r,usePpe:i}=ci(t),o={};return r&&(o["x-tt-env"]=r),i&&(o["x-use-ppe"]=i),e&&(o["x-mock-scenario"]=e),o}function iu(t,e,r){if(!t.modelToken)return{};let i=cc(e,r);return Object.keys(i).length===0?{}:{ANTHROPIC_CUSTOM_HEADERS:Object.entries(i).map(([c,f])=>`${c}:${f}`).join(`
83
+ `)}}function dc(t){return`coze-session-${t.replace(/[^A-Za-z0-9_-]+/g,"-")}`}function su(t,e,r){if(!t.modelToken)return null;let i=t.model||vt,o=cc(e,r),c=["text"];t.modelInfo?.capabilities?.image===!0&&c.push("image");let f={baseUrl:`${ac}/v1`,api:"openai-completions",apiKey:t.modelToken,models:[{id:i,name:i,reasoning:!1,input:c,cost:{input:0,output:0,cacheRead:0,cacheWrite:0},contextWindow:t.modelInfo?.contextWindow??128e3,maxTokens:8192,api:"openai-completions"}]};return Object.keys(o).length>0&&(f.headers=o),f}function ou(t,e,r){if(!t.modelToken)return[];let i=cc(e,r),o=[];for(let[c,f]of Object.entries(i))o.push("-c",`model_providers.coze.http_headers.${c}="${f}"`);return o}var ke=G("agent-handlers"),au=5*1024*1024,sw=1,ow=6,aw=new Set(["node_modules",".git",".coze","dist","build",".next"]),Bs=class{constructor(e){this.opts=e}opts;async listSkills(e){Bt(e._meta,"_agent/listSkills");let r=fr(e._meta),i=await this.loadAgentCfg(r),o=i?.workspace??Dt(r).workspace,c=i?.skills??[],f=[];for(let l of c){let x=St(o,l.relPath,"SKILL.md");await nw(x).then(w=>w.isFile()).catch(()=>!1)&&f.push(lw(l))}return{skills:f}}async addSkills(e){Bt(e._meta,"_agent/addSkills");let r=fr(e._meta),i=await this.requireAgentCfg(r),o=e.skills??[],c=[...i.skills??[]],f=new Map(c.map((x,p)=>[x.skillId,p])),l=[];for(let x of o){let p=await gc({agentId:r,workspace:i.workspace,framework:i.framework,skill:x});mc(c,f,p),l.push(x)}return await Hi(r,c),this.reloadAgentSessions(r,"skills-added"),{installedSkills:l}}async removeSkills(e){Bt(e._meta,"_agent/removeSkills");let r=fr(e._meta),i=await this.requireAgentCfg(r),o=new Set(e.skillIds??[]),c=i.skills??[],f=[];for(let l of c){if(!o.has(l.skillId)){f.push(l);continue}let x=St(i.workspace,l.relPath);await tw(x,{recursive:!0,force:!0}),ke.info("skill removed",{agentId:r,skillId:l.skillId,relPath:l.relPath})}return await Hi(r,f),this.reloadAgentSessions(r,"skills-removed"),{ok:!0}}reloadAgentSessionsPublic(e,r){this.reloadAgentSessions(e,r)}reloadAgentSessions(e,r){let i=this.opts.agents.get(e);if(i)for(let[o,c]of i.sessions){if(!c.downstream)continue;let f=c.acpSessionId;if(f&&i.activeTriggers.has(f)||this.isRuntimePendingPermission(c)){c.reloadAfterTurn=!0,ke.info("downstream busy, scheduling reload after turn",{reason:r,agentId:e,framework:i.framework,cloudId:o,acpId:f});continue}let x=c.downstream;c.downstream=void 0,ke.info("killing downstream for workspace reload (idle)",{reason:r,agentId:e,framework:i.framework,cloudId:o,acpId:f}),x.stop(r).catch(p=>ke.warn("downstream stop failed during reload (ignored)",{reason:r,agentId:e,cloudId:o,err:String(p)}))}}isRuntimePendingPermission(e){let r=this.opts.isRuntimePendingPermission;return!r||!e.downstream?!1:r(e.downstream)}async updateAgent(e){if(!e.cozeIdentity?.trim())return ke.info("_agent/update: empty cozeIdentity, noop",{agentId:e.agentId}),{ok:!0};let r=e.agentId,i=await Ue(r);if(!i)throw new D("AGENT_NOT_FOUND",`agent not found: ${r}`);if(i.cozeIdentity===e.cozeIdentity)return ke.info("_agent/update: cozeIdentity unchanged, noop",{agentId:r}),{ok:!0};try{await Vn(i.workspace,i.framework,e.cozeIdentity)}catch(o){throw ke.error("_agent/update: writeInstructionFile failed, aborting update",{agentId:r,framework:i.framework,workspace:i.workspace,err:String(o)}),new D("AGENT_PROTOCOL_ERROR",`failed to write instruction file for agent ${r}: ${String(o)}`,{cause:o})}return i.cozeIdentity=e.cozeIdentity,await Ve(i),ke.info("_agent/update: cozeIdentity rewritten",{agentId:r,framework:i.framework}),this.reloadAgentSessions(r,"identity-changed"),{ok:!0}}async disconnectAgent(e){let r=e.agentId;if(!r)throw new D("IPC_BAD_REQUEST","_agent/disconnect: missing agentId");let i=await Ue(r);return i?(i.disconnectedAt=Date.now(),i.disconnectReason=e.reason??"",await Ve(i),ke.info("agent disconnected",{agentId:r,reason:e.reason??"",force:e.force??!1}),this.opts.disposeAndMarkDisconnected&&await this.opts.disposeAndMarkDisconnected(r,e.reason??"disconnect"),{ok:!0}):(ke.warn("_agent/disconnect: agent not found, ignoring",{agentId:r}),{ok:!0})}async switchModel(e){if(Bt(e._meta,"_agent/switchModel"),!e.agentId)throw new D("IPC_BAD_REQUEST","_agent/switchModel: missing agentId");let r=e.model?.trim()?e.model:vt,i=await Ue(e.agentId);if(!i)throw new D("AGENT_NOT_FOUND",`agent not found: ${e.agentId}`);i.model=r,e.modelInfo&&(i.modelInfo=e.modelInfo),await Ve(i),ke.info("_agent/switchModel: model persisted",{agentId:e.agentId,model:r,reason:e.reason??""});let o=this.opts.agents.get(e.agentId);if(!o)return ke.info("_agent/switchModel: agent not running, config persisted only",{agentId:e.agentId}),{ok:!0};o.model=r,e.modelInfo&&o.setModelInfo(e.modelInfo),this.opts.cleanupOpenclawProviders&&await this.opts.cleanupOpenclawProviders(o).catch(f=>ke.warn("cleanupOpenclawProviders before switchModel failed (ignored)",{agentId:e.agentId,err:String(f)}));let c=[];for(let[f,l]of o.allSessionQueues())c.push(l.enqueue(async()=>{let x=o.sessions.get(f);x?.downstream&&(await x.downstream.stop(`switchModel: ${r}`).catch(()=>{}),x.downstream=void 0)}));return await Promise.all(c),ke.info("_agent/switchModel: all session runtimes killed, next prompt will respawn",{agentId:e.agentId,model:r,cloudSessions:c.length}),{ok:!0}}async resetAgent(e){if(Bt(e._meta,Et.RESET),!e.agentId)throw new D("IPC_BAD_REQUEST",`${Et.RESET}: missing agentId`);return await this.runDetailSync(e.agentId,Et.RESET,e.reason),{ok:!0}}async repairAgent(e){if(Bt(e._meta,Et.REPAIR),!e.agentId)throw new D("IPC_BAD_REQUEST",`${Et.REPAIR}: missing agentId`);let r=await this.loadAgentCfg(e.agentId);if(r&&r.framework!=="openclaw")throw new D("IPC_BAD_REQUEST",`${Et.REPAIR} only allowed for openclaw, got ${r.framework}`);if(r&&this.opts.openclawRepair)try{await this.opts.openclawRepair(e.agentId,r.workspace)}catch(i){ke.warn("openclaw repair (delete+add) failed (ignored)",{agentId:e.agentId,reason:e.reason,err:String(i)})}return await this.runDetailSync(e.agentId,Et.REPAIR,e.reason),{ok:!0}}async runDetailSync(e,r,i){if(!this.opts.detailSyncer){ke.warn("detailSyncer not wired, skipping sync",{method:r,agentId:e});return}try{await this.opts.detailSyncer(e)}catch(o){ke.warn("detail sync failed (ignored)",{method:r,agentId:e,reason:i,err:String(o)})}}async getFileTree(e){Bt(e._meta,"_agent/getFileTree");let r=e._meta,i=fr(r),o=await this.resolveWorkspace(i),c=e.filePath??"",f=this.safeJoin(o,c),l=await fc(f).catch(()=>null);if(!l)throw new D("IPC_BAD_REQUEST",`path not found: ${c}`);if(l.isSymbolicLink())throw new D("IPC_BAD_REQUEST",`symlink not allowed: ${c}`);if(!await Pr(f,o))throw new D("IPC_BAD_REQUEST",`path escapes workspace: ${c}`);let x=vw(e.depth);return l.isDirectory()?{tree:await Ew(o,f,c,x)}:{tree:[{name:Sw(c),path:hu(c||"."),isDir:!1,size:l.size,modifiedAt:Math.floor(l.mtimeMs)}]}}async getFileContent(e){Bt(e._meta,"_agent/getFileContent");let r=fr(e._meta),i=await this.resolveWorkspace(r);if(!e.filePath)throw new D("IPC_BAD_REQUEST","filePath required");let o=this.safeJoin(i,e.filePath),c=await fc(o).catch(()=>null);if(!c||!c.isFile())throw new D("IPC_BAD_REQUEST",`not a file: ${e.filePath}`);if(c.isSymbolicLink())throw new D("IPC_BAD_REQUEST",`symlink not allowed: ${e.filePath}`);if(!await Pr(o,i))throw new D("IPC_BAD_REQUEST",`path escapes workspace: ${e.filePath}`);if(c.size>au)throw new D("IPC_BAD_REQUEST",`file too large: ${c.size} bytes (max ${au})`);let f=await cu(o);return f.includes(0)?{content:f.toString("base64"),encoding:"base64",size:c.size}:{content:f.toString("utf8"),encoding:"utf-8",size:c.size}}async resolveWorkspace(e){let r=this.opts.agents.get(e);return r?r.workspace:(await Ue(e).catch(()=>null))?.workspace??Dt(e).workspace}safeJoin(e,r){let i=xc(e,r||"."),o=pc(e,i);if(o.startsWith("..")||o===".."||o.startsWith(`..${du}`))throw new D("IPC_BAD_REQUEST",`path escapes workspace: ${r}`);return i}loadAgentCfg(e){return Ue(e)}async requireAgentCfg(e){let r=await this.loadAgentCfg(e);if(!r)throw new D("AGENT_NOT_FOUND",`no config for agent: ${e}`);return r}};function cw(t){let e=t.trim().replace(/[\x00-\x1f<>:"|?*/\\]+/g,"-").replace(/^[\s.-]+|[\s.-]+$/g,"").slice(0,64);if(!e||e==="."||e==="..")throw new D("IPC_BAD_REQUEST",`invalid skill name: ${t}`);if(/^(con|prn|aux|nul|com[1-9]|lpt[1-9])$/i.test(e))throw new D("IPC_BAD_REQUEST",`reserved windows filename: ${t}`);return e}function dw(t){return t==="claude-code"?St(".claude","skills"):St(".agents","skills")}var fw=3e4,uw=50*1024*1024,lr=3e4;async function gc(t){let{agentId:e,workspace:r,framework:i,skill:o}=t;if(!o.skillName)throw new D("IPC_BAD_REQUEST","skill missing skillName");let c=typeof o.content=="string"&&o.content.length>0,f=typeof o.downloadUrl=="string"&&o.downloadUrl.length>0;if(!c&&!f)throw new D("IPC_BAD_REQUEST",`skill ${o.skillId} missing both content and downloadUrl`);let l=cw(o.skillName),x=dw(i),p=St(x,l),w=St(r,p);if(await uc(w,{recursive:!0}),c){let T=Buffer.from(o.content,"utf8");di(T.length),await lc(St(w,"SKILL.md"),T,"utf8")}else{let T=await xw(o.downloadUrl);pw(T)?await _w(T,w):gw(T)?await mw(T,w):await lc(St(w,"SKILL.md"),T.toString("utf8"),"utf8")}let b={skillId:o.skillId,skillName:o.skillName,relPath:p,installedAt:Date.now(),...o.description?{description:o.description}:{},...o.icon?{icon:o.icon}:{},...o.version?{version:o.version}:{},...o.downloadUrl?{downloadUrl:o.downloadUrl}:{},...o.config?{config:o.config}:{},...o.builtin?{builtin:o.builtin}:{}};return ke.info("skill installed",{agentId:e,skillId:o.skillId,skillName:o.skillName,relPath:p,source:c?"content":"downloadUrl"}),b}function mc(t,e,r){let i=e.get(r.skillId);if(i!==void 0){t[i]=r;return}e.set(r.skillId,t.length),t.push(r)}function lw(t){return{skillId:t.skillId,skillName:t.skillName,...t.description?{description:t.description}:{},...t.icon?{icon:t.icon}:{},...t.version?{version:t.version}:{},...t.config?{config:t.config}:{},...t.builtin?{builtin:t.builtin}:{}}}async function xw(t){if(!t)throw new D("IPC_BAD_REQUEST","skill missing downloadUrl");if(t.startsWith("data:")){let e=Math.floor(t.length*3/4);di(e);let r=hw(t);return di(r.length),r}if(t.startsWith("file:")){let e=new URL(t).pathname,r=await cu(e);return di(r.length),r}if(Ps(t)){let e=new AbortController,r=setTimeout(()=>e.abort(),fw);try{let i=await fetch(t,{signal:e.signal});if(!i.ok)throw new D("IPC_BAD_REQUEST",`fetch skill failed HTTP ${i.status} ${t}`);let o=await i.arrayBuffer();return di(o.byteLength),Buffer.from(o)}finally{clearTimeout(r)}}throw new D("IPC_BAD_REQUEST",`unsupported downloadUrl scheme (\u8981 https/data/file): ${t.slice(0,80)}`)}function di(t){if(t>uw)throw new D("IPC_BAD_REQUEST",`skill too large: ${t} bytes`)}function hw(t){let e=/^data:([^,;]*)(;base64)?,(.*)$/s.exec(t);if(!e)throw new D("IPC_BAD_REQUEST","bad data URL");let r=!!e[2],i=e[3]??"";return r?Buffer.from(i,"base64"):Buffer.from(decodeURIComponent(i),"utf8")}function pw(t){return t.length>=2&&t[0]===31&&t[1]===139}function gw(t){if(t.length<4||t[0]!==80||t[1]!==75)return!1;let e=t[2],r=t[3];return e===3&&r===4||e===5&&r===6}function hc(t){return t==="__MACOSX"||t.startsWith("__MACOSX/")}async function mw(t,e){let r,i;try{r=new lu.default(t),i=r.getEntries()}catch(f){throw new D("IPC_BAD_REQUEST",`zip parse failed: ${f.message}`,{cause:f})}for(let f of i){let l=f.entryName;if(!l||hc(l))continue;if(l.startsWith("/")||/^[A-Za-z]:[\\/]/.test(l))throw new D("IPC_BAD_REQUEST",`zip entry absolute path: ${l}`);if(l.split(/[/\\]/).some(p=>p===".."))throw new D("IPC_BAD_REQUEST",`zip entry contains '..' (traversal): ${l}`);let x=f.header.attr>>>16&61440;if(x!==0&&x!==32768&&x!==16384)throw new D("IPC_BAD_REQUEST",`zip entry kind 0x${x.toString(16)} not allowed (symlink/hardlink/special): ${l}`)}let o=ww(i),c=xc(e);for(let f of i){if(hc(f.entryName))continue;let l=f.entryName;if(o&&l.startsWith(o)&&(l=l.slice(o.length)),!l)continue;let x=xc(e,l),p=pc(c,x);if(p.startsWith("..")||p==="..")throw new D("IPC_BAD_REQUEST",`zip entry escapes destDir: ${l}`);if(f.isDirectory){await uc(x,{recursive:!0});continue}await uc(rw(x),{recursive:!0});let w;try{w=f.getData()}catch(b){throw new D("IPC_BAD_REQUEST",`zip entry getData failed (${f.entryName}): ${b.message}`,{cause:b})}await lc(x,w)}}function ww(t){let e;for(let r of t){let i=r.entryName;if(!i||hc(i))continue;let o=i.indexOf("/");if(o<=0)return;let c=i.slice(0,o+1);if(e===void 0)e=c;else if(e!==c)return}return e}async function _w(t,e){await yw(t);let r=Gf({cwd:e,strip:1}),i=!1,o=setTimeout(()=>{i=!0,r.destroy(new D("IPC_BAD_REQUEST",`tar extract timeout (${lr}ms)`))},lr);try{await uu(fu.from(t),r)}catch(c){throw c instanceof D?c:i?new D("IPC_BAD_REQUEST",`tar extract timeout (${lr}ms)`):new D("IPC_BAD_REQUEST",`tar extract failed: ${c.message??String(c)}`,{cause:c})}finally{clearTimeout(o)}}async function yw(t){let e=[],r=dr({onReadEntry:c=>{let f=c.path,l=c.type;if(l!=="File"&&l!=="Directory"){e.push(`tar entry kind '${l}' not allowed (symlink/hardlink/special): ${f.slice(0,100)}`);return}if(f.startsWith("/")||f.startsWith("\\")||/^[a-zA-Z]:[\\/]/.test(f)){e.push(`tar entry absolute path: ${f}`);return}f.split(/[/\\]/).some(p=>p==="..")&&e.push(`tar entry contains '..': ${f}`)}}),i=!1,o=setTimeout(()=>{i=!0,r.destroy(new D("IPC_BAD_REQUEST",`tar list timeout (${lr}ms)`))},lr);try{await uu(fu.from(t),r)}catch(c){throw i?new D("IPC_BAD_REQUEST",`tar list timeout (${lr}ms)`):new D("IPC_BAD_REQUEST",`tar list failed: ${c.message??String(c)}`,{cause:c})}finally{clearTimeout(o)}if(e.length>0)throw new D("IPC_BAD_REQUEST",e[0]??"tar entry validation failed")}var bw=5e3;async function Ew(t,e,r,i){return xu(t,e,r,i,{count:0})}async function xu(t,e,r,i,o){if(i<=0)return[];let c;try{c=await ew(e,{withFileTypes:!0})}catch{return[]}let f=[];for(let l of c){if(aw.has(l.name)||l.isSymbolicLink())continue;if(o.count>=bw){f.push({name:"...",path:"...",isDir:!1,size:0,modifiedAt:0,hasMore:!0});break}let x=St(e,l.name),p=iw(St(r,l.name)),w=null;try{w=await fc(x)}catch{continue}if(w.isSymbolicLink())continue;o.count++;let b={name:l.name,path:hu(pc(t,x)),isDir:w.isDirectory(),size:w.size,modifiedAt:Math.floor(w.mtimeMs)};w.isDirectory()&&i>1&&(b.children=await xu(t,x,p,i-1,o)),f.push(b)}return f.sort((l,x)=>l.isDir!==x.isDir?l.isDir?-1:1:l.name.localeCompare(x.name)),f}function vw(t){return!t||t<=0?sw:Math.min(t,ow)}function Sw(t){if(!t||t==="."||t==="/")return".";let e=t.split(/[/\\]/);return e[e.length-1]||"."}function hu(t){return t.split(du).join("/")}ee();import{readFileSync as qS}from"node:fs";import{dirname as GS,join as jS}from"node:path";import{fileURLToPath as WS}from"node:url";var xr="0.1.83-alpha.0";var dn=G("agent-health-reporter"),Iw=1e4,fi=class{constructor(e){this.opts=e;this.intervalMs=e.intervalMs??Iw}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()}),dn.info("heartbeat started",{intervalMs:this.intervalMs}),this.tick())}stop(){this.timer&&(clearInterval(this.timer),this.timer=null,this.unsubscribeRegister&&(this.unsubscribeRegister(),this.unsubscribeRegister=null),dn.info("heartbeat stopped"))}async tick(){if(this.inFlight){dn.debug("previous tick still in-flight, skip");return}let e=this.opts.getDeviceId();if(!e){dn.debug("deviceId not available, skip tick (\u5C1A\u672A pair)");return}this.inFlight=!0;try{let r=[];for(let f of this.opts.core.agents.values()){let l=Aw(f);if(!l)continue;let x={agentId:f.agentId,status:l};f.patToken&&(x.patToken=f.patToken),f.accountId&&(x.accountId=f.accountId),r.push(x)}if(r.length===0)return;let i={agents:r,bridgeVersion:xr,_meta:{cozeDeviceId:e}},o;try{o=await this.opts.core.sendRequest("_agent/health",i,5e3)}catch(f){dn.warn("heartbeat batch send failed",{count:r.length,err:String(f)})}let c=o?.authFailures;if(c&&c.length>0&&(dn.warn("heartbeat received authFailures from cloud",{count:c.length,agentIds:c.map(f=>f.agentId)}),this.opts.onAuthFailures))try{await this.opts.onAuthFailures(c)}catch(f){dn.warn("onAuthFailures callback failed (ignored)",{err:String(f)})}}finally{this.inFlight=!1}if(this.opts.onTickEnd)try{await this.opts.onTickEnd()}catch(r){dn.warn("onTickEnd hook failed",{err:String(r)})}}};function Aw(t){return t.status==="error"?"error":t.activeTriggers.size>0?"busy":t.status==="ok"?"online":null}$t();import{mkdir as _c,rm as n_}from"node:fs/promises";gn();import{spawnSync as Ow}from"node:child_process";function ui(t,e,r){return r===void 0?{jsonrpc:"2.0",id:t,method:e}:{jsonrpc:"2.0",id:t,method:e,params:r}}function li(t,e){return e===void 0?{jsonrpc:"2.0",method:t}:{jsonrpc:"2.0",method:t,params:e}}function hr(t,e){return{jsonrpc:"2.0",id:t,result:e}}function fn(t,e){return{jsonrpc:"2.0",id:t,error:e}}He();var zs=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)}},Q={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,AGENT_FRAME_IDLE_TIMEOUT:-32016,MODEL_MODALITY_UNSUPPORTED:-32017,AGENT_DEPENDENCY_INSTALL_FAILED:-32018};function pu(t){return"method"in t&&"id"in t&&t.id!==void 0}function gu(t){return"method"in t&&!("id"in t)}function Fs(t){return!("method"in t)&&"id"in t}var Tw={AGENT_NOT_FOUND:Q.AGENT_NOT_FOUND,AGENT_BUSY:Q.AGENT_BUSY,AGENT_DISCONNECTED:Q.AGENT_DISCONNECTED,AGENT_TIMEOUT:Q.AGENT_TIMEOUT,AGENT_FRAME_IDLE_TIMEOUT:Q.AGENT_FRAME_IDLE_TIMEOUT,AGENT_SPAWN_FAILED:Q.AGENT_SPAWN_FAILED,AGENT_PROTOCOL_ERROR:Q.INTERNAL_ERROR,BRIDGE_CONFIG_INVALID:Q.INTERNAL_ERROR,BRIDGE_INTERNAL:Q.INTERNAL_ERROR,IPC_AUTH_FAILED:Q.INTERNAL_ERROR,IPC_BAD_REQUEST:Q.INVALID_REQUEST,MODEL_TOKEN_GEN_FAILED:Q.MODEL_TOKEN_GEN_FAILED,MODEL_MODALITY_UNSUPPORTED:Q.MODEL_MODALITY_UNSUPPORTED,OPERATION_NOT_ALLOWED_FOR_LOCAL:Q.OPERATION_NOT_ALLOWED_FOR_LOCAL,UPSTREAM_DISCONNECTED:Q.INTERNAL_ERROR,UPSTREAM_HANDSHAKE_FAILED:Q.INTERNAL_ERROR,PATH_OUTSIDE_WORKSPACE:Q.PATH_OUTSIDE_WORKSPACE,FILE_TOO_LARGE:Q.FILE_TOO_LARGE,UNSUPPORTED_MIME:Q.UNSUPPORTED_MIME,UPLOAD_FAILED:Q.UPLOAD_FAILED,UPSTREAM_NOT_READY:Q.UPSTREAM_NOT_READY,AGENT_DEPENDENCY_INSTALL_FAILED:Q.AGENT_DEPENDENCY_INSTALL_FAILED};function Cw(t){if(t!=null)return t instanceof Error?{name:t.name,message:xi(t.message)}:typeof t=="string"?xi(t):typeof t=="object"?Dw(t):t}var Rw=[[/\/Users\/[^/\s'"`)]+/g,"/Users/<redacted>"],[/\/home\/[^/\s'"`)]+/g,"/home/<redacted>"],[/[A-Za-z]:\\Users\\[^\\\s'"`)]+/g,"C:\\Users\\<redacted>"],[/(Bearer|Token|Authorization:)\s+[\w._-]+/gi,"$1 <redacted>"],[/\b(sk|pat|ak)[-_][A-Za-z0-9_-]{20,}\b/g,"<redacted-key>"]];function xi(t){let e=t;for(let[r,i]of Rw)e=e.replace(r,i);return e}function Dw(t){let e={};for(let[r,i]of Object.entries(t))typeof i=="string"?e[r]=xi(i):e[r]=i;return e}function hi(t){if(t instanceof D){let e=Cw(t.cause),r={bridgeCode:t.code,retriable:t.retriable};return e!==void 0&&(r.cause=e),{code:Tw[t.code]??Q.INTERNAL_ERROR,message:xi(t.message),data:r}}return{code:Q.INTERNAL_ERROR,message:xi(t instanceof Error?t.message:String(t))}}function mu(t){let e=t.data,r=e?.bridgeCode??"AGENT_PROTOCOL_ERROR",i=!!e&&typeof e.message=="string"&&!!e.message,o=i?e?.message:t.message,c=t.data;if(i&&e){let{message:f,...l}=e;c=l}return new D(r,o,{retriable:e?.retriable??!1,cause:c})}function _u(t){return`${JSON.stringify(t)}
84
+ `}var wu=10*1024*1024,Us=class{buffer="";onError;constructor(e={}){this.onError=e.onError}push(e){if(this.buffer+=typeof e=="string"?e:e.toString("utf8"),this.buffer.length>wu){let o=this.buffer.length;return this.buffer="",this.onError?.({line:`<buffer overflow: ${o} bytes, dropped>`,error:new Error(`LdjsonDecoder buffer exceeded ${wu} bytes`)}),[]}let r=this.buffer.split(`
85
+ `);this.buffer=r.pop()??"";let i=[];for(let o of r){let c=o.replace(/\r$/,"").trim();if(c)try{i.push(JSON.parse(c))}catch(f){this.onError?.({line:c,error:f})}}return i}flush(){if(!this.buffer)return[];let e=this.buffer.replace(/\r$/,"").trim();if(this.buffer="",!e)return[];try{return[JSON.parse(e)]}catch(r){return this.onError?.({line:e,error:r}),[]}}};var bu={"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"},r2=Object.fromEntries(Object.entries(bu).map(([t,e])=>[e,t])),kw={"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:[]},pr=class{seq=0;next(e,r){this.seq+=1;let i=bu[e]??Lw(e),o=kw[i]??[],c=[i,String(this.seq)];if(o.length>0){let f=o.map(x=>yu(r?.[x]??"")),l=Pw(f).join(":");l&&c.push(l)}else r&&Object.values(r).some(f=>f)&&c.push(Object.values(r).filter(Boolean).map(f=>yu(String(f))).join(":"));return c.join("_")}reset(){this.seq=0}};function Lw(t){return t.replace(/[\s/]+/g,".").replace(/_+/g,"-")}function yu(t){return t.replace(/[:_\s]+/g,"-")}function Pw(t){let e=t.length;for(;e>0&&!t[e-1];)e-=1;return t.slice(0,e)}Hn();function gr(t,e){let r=process.env[t];if(!r)return e;let i=Number(r);return Number.isFinite(i)&&i>0?i:e}He();ee();var Nw=gr("COZE_BRIDGE_INITIALIZE_TIMEOUT_MS",3e4),Mw=200,Bw=gr("COZE_BRIDGE_SESSION_PROMPT_MAX_MS",3600*1e3),zw=gr("COZE_BRIDGE_SESSION_PROMPT_FRAME_IDLE_MS",600*1e3),Eu=500;function Fw(t){try{let e=JSON.stringify(t);return e===void 0||e.length<=Eu?t:`${e.slice(0,Eu)}...<truncated, total ${e.length} chars>`}catch{return"<unserializable>"}}function vu(t,e){if(!(typeof t!="number"||t<=0))try{if(process.platform==="win32"){let r=["/PID",String(t),"/T"];e==="SIGKILL"&&r.push("/F"),Ow("taskkill",r,{stdio:"ignore",windowsHide:!0})}else process.kill(-t,e)}catch{}}var It=class{constructor(e){this.opts=e;this.log=G(`downstream.${this.constructor.name}`),this.decoder=new Us({onError:r=>this.log.warn("decode line failed",{line:r.line})})}opts;child;decoder;pending=new Map;inflightAgentRequests=new Map;idAllocator=new pr;updateHandlers=[];agentRequestHandlers=[];exitHandlers=[];log;stopped=!1;stderrRing=[];sanitizeEnv(e){return e}async start(){if(this.child)throw new D("BRIDGE_INTERNAL","Downstream already started");let e=process.platform!=="win32",r=Vt(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=r,r.stdout?.setEncoding("utf8"),r.stdout?.on("data",i=>{try{for(let o of this.decoder.push(i))this.dispatch(o)}catch(o){this.log.warn("stdout dispatch threw, swallowed to keep daemon alive",{err:String(o)})}}),r.stderr?.setEncoding("utf8"),r.stderr?.on("data",i=>{let o=i.trimEnd();this.stderrRing.push(o),this.stderrRing.length>Mw&&this.stderrRing.shift(),this.log.debug("stderr",{text:o})}),r.stdin?.on("error",i=>{this.log.warn("child stdin error",{err:String(i)})}),r.stdout?.on("error",i=>{this.log.warn("child stdout error",{err:String(i)})}),r.stderr?.on("error",i=>{this.log.warn("child stderr error",{err:String(i)})}),r.on("exit",(i,o)=>{this.stopped=!0,(i!==0||o!==null)&&this.stderrRing.length>0&&this.log.warn("downstream exited abnormally, recent stderr",{code:i,signal:o,recentStderr:[...this.stderrRing]});try{for(let f of this.decoder.flush())this.dispatch(f)}catch(f){this.log.debug("decoder.flush on exit threw (ignored)",{err:String(f)})}this.failAllPending(new D("AGENT_PROTOCOL_ERROR",`agent exited (${i}/${o})`));for(let f of this.exitHandlers)f(i,o)}),r.on("error",i=>{this.log.error("child error",{err:String(i)}),this.failAllPending(new D("AGENT_SPAWN_FAILED",String(i),{cause:i}))}),this.log.info("downstream started",{command:this.opts.command,pid:r.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 r=this.child,i=new Promise(c=>r.once("exit",()=>c()));vu(r.pid,"SIGTERM");let o=setTimeout(()=>{r.killed||vu(r.pid,"SIGKILL")},5e3);try{await i}finally{clearTimeout(o)}}pid(){return this.child?.pid}isAlive(){return!!this.child&&!this.stopped}getStderrTail(){return[...this.stderrRing]}initialize(e){return this.call("initialize",e)}sessionNew(e){return this.call("session/new",{mcpServers:[],...e})}sessionLoad(e){return this.call("session/load",{mcpServers:[],...e})}sessionPrompt(e,r=Bw,i=zw){return this.call("session/prompt",e,r,i)}async sessionCancel(e){!this.child||this.stopped||this.writeFrame(li("session/cancel",e))}onUpdate(e){this.updateHandlers.push(e)}onAgentRequest(e){this.agentRequestHandlers.push(e)}respondAgentRequest(e,r){if(this.inflightAgentRequests.delete(e),!(!this.child||this.stopped))try{this.writeFrame(hr(e,r))}catch(i){this.log.warn("respondAgentRequest write failed",{id:e,err:String(i)})}}respondAgentRequestError(e,r){if(this.inflightAgentRequests.delete(e),!(!this.child||this.stopped))try{this.writeFrame(fn(e,r))}catch(i){this.log.warn("respondAgentRequestError write failed",{id:e,err:String(i)})}}onExit(e){this.exitHandlers.push(e)}call(e,r,i=Nw,o=0){if(!this.child||this.stopped)return Promise.reject(new D("AGENT_PROTOCOL_ERROR","downstream not started"));let c=this.idAllocator.next(e),f=ui(c,e,r),l=(()=>{if(typeof r!="object"||r===null)return;let w=r.sessionId;return typeof w=="string"?w:void 0})(),x=i>0&&Number.isFinite(i),p=o>0&&Number.isFinite(o);return new Promise((w,b)=>{let T={resolve:w,reject:b,timer:null,frameIdleTimer:null,armFrameIdle:null,method:e};x&&(T.timer=setTimeout(()=>{this.pending.delete(c),T.frameIdleTimer&&clearTimeout(T.frameIdleTimer),this.log.warn("downstream call timeout",{id:c,method:e,timeoutMs:i,...l?{sessionId:l}:{}}),b(new D("AGENT_TIMEOUT",`${e} timed out after ${i}ms`))},i));let E=p?()=>{T.frameIdleTimer&&clearTimeout(T.frameIdleTimer),T.frameIdleTimer=setTimeout(()=>{if(this.inflightAgentRequests.size>0){this.log.debug("frame-idle fired but agent request inflight, re-arming",{id:c,method:e,inflight:this.inflightAgentRequests.size,...l?{sessionId:l}:{}}),E?.();return}T.timer&&clearTimeout(T.timer),this.pending.delete(c),this.log.warn("frame-idle timeout, rejecting pending call",{id:c,method:e,frameIdleMs:o,...l?{sessionId:l}:{}}),b(new D("AGENT_FRAME_IDLE_TIMEOUT",`${e} no session/update for ${o}ms (no inflight agent request)`))},o)}:null;T.armFrameIdle=E,this.pending.set(c,T),E?.();try{this.writeFrame(f)}catch(v){T.timer&&clearTimeout(T.timer),T.frameIdleTimer&&clearTimeout(T.frameIdleTimer),this.pending.delete(c),b(v)}})}writeFrame(e){if(!this.child?.stdin||this.child.stdin.destroyed)throw new D("AGENT_PROTOCOL_ERROR","downstream stdin not writable");this.child.stdin.write(_u(e),r=>{r&&this.log.warn("stdin write callback err",{err:String(r)})})}dispatch(e){if(Fs(e)){let r=e.id!==null?this.pending.get(e.id):void 0;if(!r){this.log.warn("orphan response",{id:e.id});return}this.pending.delete(e.id),r.timer&&clearTimeout(r.timer),r.frameIdleTimer&&clearTimeout(r.frameIdleTimer),e.error?(this.log.warn("downstream returned error frame",{id:e.id,method:r.method,code:e.error.code,message:e.error.message,data:e.error.data}),r.reject(mu(e.error))):e.result===void 0?(this.log.warn("downstream response missing both result and error",{id:e.id,method:r.method}),r.reject(new D("AGENT_PROTOCOL_ERROR",`${r.method} response missing both result and error`))):(this.log.info("downstream returned result",{id:e.id,method:r.method,result:Fw(e.result)}),r.resolve(e.result));return}if(gu(e)){if(e.method==="session/update"){for(let r of this.pending.values())r.armFrameIdle?.();for(let r of this.updateHandlers)try{Promise.resolve(r(e.params)).catch(i=>this.log.warn("update handler failed (async)",{err:String(i)}))}catch(i){this.log.warn("update handler threw sync, swallowed",{err:String(i)})}}else this.log.info("unknown notification (drop, not forwarded)",{method:e.method});return}if(pu(e)){let r=e;try{this.handleAgentRequest(r).catch(i=>this.log.error("agent request handler failed (async)",{method:r.method,err:String(i)}))}catch(i){this.log.warn("handleAgentRequest threw sync, swallowed",{method:r.method,err:String(i)})}}}async handleAgentRequest(e){if(this.agentRequestHandlers.length===0){this.writeFrame(fn(e.id,{code:-32601,message:`method not handled by Bridge: ${e.method}`}));return}this.inflightAgentRequests.set(e.id,e.method);for(let r of this.agentRequestHandlers)try{await r(e)}catch(i){this.log.error("agentRequestHandler threw",{method:e.method,err:String(i)});try{this.writeFrame(fn(e.id,hi(i)))}catch{}this.inflightAgentRequests.delete(e.id)}}failAllPending(e){for(let r of this.pending.values())r.timer&&clearTimeout(r.timer),r.frameIdleTimer&&clearTimeout(r.frameIdleTimer),r.reject(e);this.pending.clear(),this.inflightAgentRequests.clear()}};function Uw(t){let e={};for(let[r,i]of Object.entries(t))i!==void 0&&(r.startsWith("CLAUDE")||r==="AI_AGENT"||r==="BAGGAGE"||(e[r]=i));return e}var qs=class extends It{framework="claude-code";constructor(e){let r=Lr("claude-code",e.command),i=e.args??[],o={command:r,args:i,cwd:e.cwd,...e.env?{env:e.env}:{}};super(o)}sanitizeEnv(e){return Uw(e)}};gn();import{mkdtempSync as qw,rmSync as Hw}from"node:fs";import{tmpdir as Gw}from"node:os";import{join as jw}from"node:path";var Hs=class extends It{framework="codex";authMethodId;codexHomeDir;constructor(e){let r=Lr("codex",e.command),i=e.args??[],o=e.extraArgs?[...i,...e.extraArgs]:i,c=e.isolateCodexHome?qw(jw(Gw(),"coze-bridge-codex-home-")):void 0,f=c?{...e.env??{},CODEX_HOME:c}:e.env,l={command:r,args:o,cwd:e.cwd,...f?{env:f}:{}};super(l),this.authMethodId=e.authMethodId,this.codexHomeDir=c}async initialize(e){let r=await super.initialize(e);return this.authMethodId&&await this.call("authenticate",{methodId:this.authMethodId}),r}async stop(e){if(await super.stop(e),this.codexHomeDir)try{Hw(this.codexHomeDir,{recursive:!0,force:!0})}catch{}}};var Kw=3e4,mr=class extends It{framework="openclaw";agentId;sessionName;slashModelOnStart;constructor(e){let r=e.sessionName??"default",i=["acp","--session",`agent:${e.agentId}:${r}`];e.gatewayToken&&i.push("--token",e.gatewayToken);let o={command:e.command,args:i,cwd:e.cwd,...e.env?{env:e.env}:{}};super(o),this.agentId=e.agentId,this.sessionName=r,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}`}]},Kw))}get acpSessionName(){return this.sessionName}};He();ee();Me();function wc(t){return t.replace(/[^A-Za-z0-9._-]+/g,"-")}gn();var wr=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((r,i)=>{this.slots.push({task:e,resolve:r,reject:i}),this.drain()})}close(){this.closed=!0}dispose(e=new Error("AsyncQueue disposed")){for(this.disposed=!0,this.closed=!0;this.slots.length>0;)this.slots.shift()?.reject(e)}get size(){return this.slots.length}get isRunning(){return this.running}get isDisposed(){return this.disposed}async drain(){if(!this.running){this.running=!0;try{for(;this.slots.length>0&&!this.disposed;){let e=this.slots.shift();if(!e)break;try{let r=await e.task();e.resolve(r)}catch(r){e.reject(r)}}}finally{this.running=!1}}}};var Gs=class{agentId;framework;workspace;deployType;accountId;patToken;modelInfo;sessions=new Map;sessionQueues=new Map;activeTriggers=new Map;activeGroupIds=new Map;status="ok";model;lastActiveAt=Date.now();constructor(e){this.agentId=e.agentId,this.framework=e.framework,this.workspace=e.workspace,this.model=e.model,this.deployType=e.deployType??"local",e.accountId&&(this.accountId=e.accountId),e.patToken&&(this.patToken=e.patToken),e.modelInfo&&(this.modelInfo=e.modelInfo)}setPatToken(e){this.patToken=e}setModelInfo(e){this.modelInfo=e}getSessionQueue(e){let r=this.sessionQueues.get(e);return(!r||r.isDisposed)&&(r=new wr,this.sessionQueues.set(e,r)),r}allSessionQueues(){return this.sessionQueues.entries()}hasSessionQueue(e){let r=this.sessionQueues.get(e);return!!r&&!r.isDisposed}async dispose(e){this.status="stopped";let r=new Error(`AgentSession disposed${e?`: ${e}`:""}`);for(let i of this.sessionQueues.values())i.dispose(r);this.sessionQueues.clear(),await this.killAllRuntimes(e??"dispose")}async killAllRuntimes(e){let r=[];for(let[,i]of this.sessions)pi(i),i.downstream&&(r.push(i.downstream.stop(e).catch(()=>{})),i.downstream=void 0);await Promise.all(r),this.activeTriggers.clear(),this.activeGroupIds.clear()}};function pi(t){t.idleTimer&&(clearTimeout(t.idleTimer),t.idleTimer=void 0)}Hn();ee();import{constants as Su,access as Ww}from"node:fs/promises";import{delimiter as Vw,join as $w}from"node:path";var un=G("framework-detector"),Iu={"claude-code":"claude",codex:"codex",openclaw:"openclaw"},Jw=[".exe",".cmd",".bat",".ps1"],ln=class{env;constructor(e={}){this.env={pathEnv:e.pathEnv??process.env.PATH??"",platform:e.platform??process.platform,spawn:e.spawn??Vt,access:e.access??Ww}}async detect(e){let r=Iu[e],i=await this.which(r);if(!i)return un.debug("framework binary not found",{framework:e,bin:r}),null;let o=e==="openclaw"?["--log-level","silent"]:[],[c,f]=await Promise.all([this.probeVersion(i,o),e==="openclaw"?this.probeOpenclawDefaultAgent(i):Promise.resolve(null)]),l={path:i,version:c};return f&&(l.defaultAgent=f),l}async detectAll(){let e=await Promise.all(Object.keys(Iu).map(async i=>[i,await this.detect(i)])),r={};for(let[i,o]of e)o&&(r[i]=o);return r}async which(e){let r=this.env.pathEnv.split(Vw).filter(Boolean),i=this.env.platform==="win32"?["",...Jw]:[""];for(let o of r)for(let c of i){let f=$w(o,e+c);if(await this.isExecutable(f))return f}return null}async isExecutable(e){try{let r=this.env.platform==="win32"?Su.F_OK:Su.X_OK;return await this.env.access(e,r),!0}catch{return!1}}async probeOpenclawDefaultAgent(e){let r=await this.runProbe(e,["--log-level","silent","agents","list","--json"]);if(!r)return un.warn("openclaw default agent probe: runProbe returned null (spawn err / timeout)",{path:e}),null;if(r.code!==0)return un.warn("openclaw default agent probe: non-zero exit",{path:e,code:r.code,stdoutHead:r.stdout.slice(0,200)}),null;let i=r.stdout.match(/\[\s*\{[\s\S]*\}\s*\]/);if(!i)return un.warn("openclaw default agent probe: regex no match (no JSON array in stdout)",{path:e,stdoutHead:r.stdout.slice(0,200)}),null;try{let o=JSON.parse(i[0]);if(!Array.isArray(o))return un.warn("openclaw default agent probe: JSON parsed but not an array",{path:e}),null;let c=o.find(f=>f?.isDefault===!0);return c?!c.id||!c.workspace?(un.warn("openclaw default agent probe: default agent missing id or workspace",{path:e,hasId:!!c.id,hasWorkspace:!!c.workspace}),null):{id:c.id,workspace:c.workspace}:(un.info("openclaw default agent probe: no agent has isDefault=true",{path:e,agentCount:o.length}),null)}catch(o){return un.warn("openclaw default agent probe: JSON.parse failed",{path:e,err:String(o),matchHead:i[0].slice(0,200)}),null}}async probeVersion(e,r=[]){let i=await this.runProbe(e,[...r,"--version"]);return i&&(Zw(i.stdout).split(/\r?\n/)[0]??"").trim()||"unknown"}runProbe(e,r){return new Promise(i=>{let o="",c=!1,f,l=x=>{c||(c=!0,f&&clearTimeout(f),i(x))};try{let x=this.env.spawn(e,r,{stdio:["ignore","pipe","pipe"]});f=setTimeout(()=>{x.kill("SIGKILL"),l(null)},15e3),x.stdout?.on("data",p=>{o+=p.toString("utf8")}),x.on("error",()=>l(null)),x.on("close",p=>l({code:p,stdout:o}))}catch{l(null)}})}},Yw=new RegExp("\x1B\\[[0-9;]*[A-Za-z]","g");function Zw(t){return t.replace(Yw,"")}import{spawn as Xw}from"node:child_process";import{homedir as Qw}from"node:os";import{join as e_}from"node:path";He();Ui();ee();async function Cu(){let t=e_(Qw(),".openclaw/openclaw.json");return(await Wn(t))?.gateway?.auth?.token??""}var Au=G("openclaw.config"),t_=[0,5e3,5e3],Tu="models.providers.",js="agents.defaults.models",Ks=class{command;env;retryDelaysMs;queue=new wr;constructor(e){this.command=e.command,this.env=e.env??process.env,this.retryDelaysMs=e.retryDelaysMs??t_}async withRetry(e,r){let i;for(let o=0;o<this.retryDelaysMs.length;o++){let c=this.retryDelaysMs[o]??0;c>0&&await new Promise(f=>setTimeout(f,c));try{return await r()}catch(f){i=f,Au.warn("openclaw cli failed, will retry",{label:e,attempt:o+1,err:String(f)})}}throw new D("AGENT_SPAWN_FAILED",`openclaw cli ${e} failed after ${this.retryDelaysMs.length} attempts: ${i?.message??"unknown"}`)}runCli(e){return new Promise((r,i)=>{let o=Xw(this.command,e,{stdio:["ignore","pipe","pipe"],env:this.env}),c="";o.stderr?.on("data",f=>{c+=f.toString("utf8")}),o.on("error",i),o.on("close",f=>{f===0?r():i(new Error(`exit ${f}: ${c.trim().slice(0,500)}`))})})}async runCliTolerant(e,r){try{await this.runCli(e)}catch(i){let o=String(i);if(r.some(c=>o.includes(c)))return;throw i}}async bestEffortUnset(e,r){try{await this.queue.enqueue(()=>this.withRetry(e,()=>this.runCli(["config","unset",r])))}catch(i){Au.warn(`${e} failed (best-effort)`,{configPath:r,err:String(i)})}}ensureProvider(e,r){return this.queue.enqueue(()=>this.withRetry(`config set models.providers.${e}`,()=>this.runCli(["config","set",`${Tu}${e}`,JSON.stringify(r),"--strict-json","--merge"])))}removeProvider(e){return this.bestEffortUnset(`config unset models.providers.${e}`,`${Tu}${e}`)}addModelToAllowlist(e,r){let i={[e]:r?{alias:r}:{}};return this.queue.enqueue(()=>this.withRetry(`config set ${js}[${e}]`,()=>this.runCli(["config","set",js,JSON.stringify(i),"--strict-json","--merge"])))}removeModelFromAllowlist(e){return this.bestEffortUnset(`config unset ${js}[${e}]`,`${js}.${e}`)}ensureAgent(e,r,i){let o=["agents","add",e,"--workspace",r,"--non-interactive"];return i&&o.push("--model",i),this.queue.enqueue(()=>this.withRetry(`agents add ${e}`,()=>this.runCliTolerant(o,["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 Le=G("agent-manager"),r_=(t,e,r,i,o,c,f,l,x)=>{switch(t){case"claude-code":{let p={...o?{...tu(o),...iu(o,f,l)}:{},...x??{},IS_SANDBOX:"1"};return new qs({cwd:r,env:p})}case"codex":{let w=[...o?[...nu(o),...ou(o,f,l)]:[],"-c",'sandbox_mode="danger-full-access"',"-c",'approval_policy="never"'],b={...o?ru(o):{},...x??{}},T=!!o;return new Hs({cwd:r,...w.length>0?{extraArgs:w}:{},...Object.keys(b).length>0?{env:b}:{},...T?{authMethodId:"openai-api-key",isolateCodexHome:!0}:{}})}case"openclaw":return new mr({command:e,cwd:r,agentId:i,...c?{sessionName:wc(c)}:{}})}};function yc(t){return t==="claude-code"||t==="codex"}var i_={path:"",version:"cloud-deployed"},s_={protocolVersion:1,clientCapabilities:{fs:{readTextFile:!0,writeTextFile:!0}}},o_=6e4,Ws=class{paths;config;registry;factory;createTimeoutMs;openclawConfigCache;ensuredProviders=new Set;detectorFactory;constructor(e){this.paths=e.paths,this.config=e.config,this.registry=e.registry,this.factory=e.downstreamFactory??r_,this.createTimeoutMs=e.createTimeoutMs??o_,this.detectorFactory=e.detectorFactory??(()=>new ln)}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 D("AGENT_SPAWN_FAILED","openclaw binary not detected on this machine");this.openclawConfigCache=new Ks({command:e.path})}return this.openclawConfigCache}async createAgent(e){if(!e.agentId)throw new D("IPC_BAD_REQUEST","agentId required");if(!e.framework)throw new D("IPC_BAD_REQUEST","framework required");let r=oi(e._meta)==="cloud";this.registry.reviveIfDisconnected?.(e.agentId);let i=this.registry.get(e.agentId);if(i){if(i.framework!==e.framework)throw new D("AGENT_BUSY",`agent ${e.agentId} exists with different framework (${i.framework})`);if(i.status==="error")Le.warn("existing agent in error state, rebuilding",{agentId:e.agentId}),await i.dispose("rebuild after error").catch(v=>Le.warn("dispose stale agent failed (ignored)",{err:String(v)})),this.registry.unregister(e.agentId);else{if(e.patToken&&e.patToken!==i.patToken){Le.info("updating agent patToken on re-create (reconnect with new PAT)",{agentId:e.agentId}),i.setPatToken(e.patToken);let v=await Ue(e.agentId,this.paths).catch(()=>null);v&&(v.patToken=e.patToken,await Ve(v,this.paths))}if(i.deployType==="cloud"&&e.modelInfo){Le.info("updating agent modelInfo on re-create",{agentId:e.agentId}),i.setModelInfo(e.modelInfo);let v=await Ue(e.agentId,this.paths).catch(()=>null);v&&(v.modelInfo=e.modelInfo,await Ve(v,this.paths))}return Le.info("agent already exists, return current",{agentId:e.agentId}),{ok:!0,agentId:i.agentId,workspace:i.workspace,framework:i.framework}}}if(!r&&!this.config.frameworksCache?.[e.framework])throw new D("AGENT_SPAWN_FAILED",`framework ${e.framework} not detected on this machine; rerun daemon to refresh frameworks_cache`);let c=Dt(e.agentId,this.paths),f=oi(e._meta),l=e.framework==="openclaw"&&f==="local",x=l?this.config.frameworksCache?.openclaw?.defaultAgent?.workspace:void 0,p=e.workspace??x??c.workspace,w=new AbortController,b=setTimeout(()=>w.abort(new D("AGENT_TIMEOUT",`_agent/create timed out after ${this.createTimeoutMs}ms`)),this.createTimeoutMs),T,E=!1;try{r&&yc(e.framework)&&await Kn(e.framework,w.signal);let v=()=>{if(w.signal.aborted)throw w.signal.reason instanceof Error?w.signal.reason:new D("AGENT_TIMEOUT","_agent/create aborted")};await _c(c.root,{recursive:!0}),await _c(p,{recursive:!0}),await _c(c.logs,{recursive:!0}),v(),l||await Vn(p,e.framework,e.cozeIdentity),e.framework==="claude-code"&&await J0(p),v();let I=await Ue(e.agentId,this.paths).catch(()=>null),A=Qf({model:e.model??I?.model}),k=Kf(e._meta)??I?.accountId,O=e.patToken??I?.patToken,y=f==="cloud"?e.modelInfo??I?.modelInfo:void 0;if(T=new Gs({agentId:e.agentId,framework:e.framework,workspace:p,model:A.model??vt,deployType:f,...k?{accountId:k}:{},...O?{patToken:O}:{},...y?{modelInfo:y}:{}}),T.status="ok",I?.sessions){for(let[z,P]of Object.entries(I.sessions))T.sessions.set(z,{acpSessionId:P.acpSessionId,modelToken:P.modelToken,tokenGeneratedAt:P.tokenGeneratedAt,lastActiveAt:Date.now(),loadingSession:!1,replySeq:0});let F=Object.keys(I.sessions).length;F>0&&Le.info("restored persisted session records (no spawn)",{agentId:e.agentId,count:F})}this.registry.register(T),E=!0;let C={agentId:e.agentId,framework:e.framework,workspace:p,cozeIdentity:e.cozeIdentity,createdAt:I?.createdAt??Date.now(),sessions:I?.sessions??{},model:A.model};f==="cloud"&&(C.deployType="cloud"),k&&(C.accountId=k),O&&(C.patToken=O),y&&(C.modelInfo=y),I?.skills&&(C.skills=I.skills),I?.agentName&&(C.agentName=I.agentName),I?.description&&(C.description=I.description),e.framework==="openclaw"&&f==="cloud"&&(this.config.frameworksCache?.openclaw?.path?await this.getOpenclawConfig().ensureAgent(e.agentId,p):Le.warn("openclaw binary not on this machine, skip agents add (will fail at session/prompt)",{agentId:e.agentId}));let L=e.initialSkills??[];if(L.length>0){let F=[...C.skills??[]],z=new Map(F.map((U,$)=>[U.skillId,$])),P=await Promise.allSettled(L.map(U=>gc({agentId:e.agentId,workspace:p,framework:e.framework,skill:U}))),N=0;for(let[U,$]of P.entries()){let se=L[U];se&&($.status==="fulfilled"?(mc(F,z,$.value),N++):Le.warn("initialSkill install failed (skipping)",{agentId:e.agentId,skillId:se.skillId,skillName:se.skillName,err:String($.reason)}))}N>0&&(C.skills=F,Le.info("initialSkills installed",{agentId:e.agentId,installed:N,requested:L.length}))}return await Ve(C,this.paths),Le.info("agent created (no spawn, lazy on first prompt)",{agentId:e.agentId,framework:e.framework,deployType:f}),{ok:!0,agentId:e.agentId,workspace:p,framework:e.framework}}catch(v){throw Le.error("agent create failed, rolling back",{agentId:e.agentId,err:String(v)}),E&&T&&(await T.dispose("rollback").catch(()=>{}),this.registry.unregister(e.agentId)),await n_(c.root,{recursive:!0,force:!0}).catch(I=>Le.warn("rm agent dir failed (ignored)",{err:String(I)})),v instanceof D?v:new D("AGENT_SPAWN_FAILED",String(v),{cause:v})}finally{clearTimeout(b)}}async spawnSessionDownstream(e,r,i,o,c){let l=this.config.frameworksCache?.[e.framework];if(!l)if(e.deployType==="cloud"&&yc(e.framework))l=i_;else throw new D("AGENT_SPAWN_FAILED",`framework ${e.framework} not detected on this machine`);if(yc(e.framework)&&!kr(e.framework)){let w=Jo(e.framework);Le.info("spawn: ensuring acp wrapper installed",{agentId:e.agentId,framework:e.framework,reusingInFlight:!!w}),await Kn(e.framework)}let x=e.deployType==="cloud"?{model:e.model,modelToken:r,...e.modelInfo?{modelInfo:e.modelInfo}:{}}:void 0,p;e.framework==="openclaw"?p=await this.buildOpenclawDownstream({session:e,modelConfig:x,cloudSessionId:i,cozeEnv:o,mockScenario:c,command:l.path}):p=this.factory(e.framework,l.path,e.workspace,e.agentId,x,i,o,c,this.buildBinShimPathEnv());try{return await p.start(),await p.initialize(s_),p}catch(w){let b=p instanceof It?p.getStderrTail():[];throw b.length>0&&Le.warn("spawnSessionDownstream failed, recent stderr (D94)",{agentId:e.agentId,framework:e.framework,method:w instanceof D?w.code:"unknown",recentStderr:b}),await p.stop("spawnSessionDownstream failed").catch(()=>{}),w instanceof D?new D(w.code,w.message,{retriable:w.retriable,cause:w}):new D("AGENT_SPAWN_FAILED",w instanceof Error?w.message:String(w),{cause:w})}}async buildOpenclawDownstream(e){let{session:r,modelConfig:i,cloudSessionId:o,cozeEnv:c,mockScenario:f,command:l}=e,x=wc(o);if(r.deployType==="local"){let T=this.config.frameworksCache?.openclaw?.defaultAgent;if(!T?.id||!T.workspace){Le.warn("openclaw default agent stale or missing, attempting lazy re-detect");let v=await this.detectorFactory().detect("openclaw");if(v?.defaultAgent?.id&&v?.defaultAgent?.workspace)Le.info("openclaw lazy re-detect success",{agentId:v.defaultAgent.id,workspace:v.defaultAgent.workspace}),this.config.frameworksCache||(this.config.frameworksCache={}),this.config.frameworksCache.openclaw=v,T=v.defaultAgent;else throw new D("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 mr({command:l,cwd:T.workspace,agentId:T.id,sessionName:x})}let p=await Cu(),w=i?su(i,c,f):null,b;if(w){let T=dc(o),v=w.models[0]?.id??vt,I=`${T}/${v}`;if(!this.ensuredProviders.has(I)){let A=this.getOpenclawConfig();await A.ensureProvider(T,w),await A.addModelToAllowlist(I),this.ensuredProviders.add(I)}b=I}return new mr({command:l,cwd:r.workspace,agentId:r.agentId,sessionName:x,...p?{gatewayToken:p}:{},...b?{slashModelOnStart:b}:{}})}async openclawRepair(e,r){let i=this.getOpenclawConfig();await i.deleteAgent(e),await i.ensureAgent(e,r)}async cleanupOpenclawSessionProviders(e){if(e.framework!=="openclaw"||!this.openclawConfigCache)return;let r=this.openclawConfigCache;for(let i of e.sessions.keys()){let o=dc(i),c=`${o}/${e.model}`,f=!0;try{await r.removeProvider(o)}catch(l){f=!1,Le.warn("removeProvider failed, keeping ensuredProviders entry",{providerId:o,err:String(l)})}try{await r.removeModelFromAllowlist(c)}catch(l){f=!1,Le.warn("removeModelFromAllowlist failed, keeping ensuredProviders entry",{fullModelId:c,err:String(l)})}f&&this.ensuredProviders.delete(c)}}};import{randomUUID as Pu}from"node:crypto";import{promises as h_}from"node:fs";import{basename as Ou}from"node:path";He();ee();import{promises as c_}from"node:fs";import{basename as d_}from"node:path";var Ru=G("file-upload"),f_="/api/coze_claw/file/agent_upload",u_=6e4;async function Du(t,e={}){let i=`${Os(Ms(e.handshakeBase))}${f_}`,o=e.timeoutMs??u_,c=await c_.readFile(t.path),f=new FormData;f.append("agent_id",t.agentId),f.append("session_id",t.sessionId),f.append("file_name",t.name),f.append("file_content",new Blob([c],{type:t.mimeType}),t.name);let l={Authorization:`Bearer ${t.patToken}`,Accept:"application/json","x-coze-version":"3.0",...ur(e.ppeOverride),...t.accountId?{"x-coze-account":t.accountId}:{}},x=new AbortController,p=setTimeout(()=>x.abort(),o);Ru.info("file upload start",{url:i,agentId:t.agentId,sessionId:t.sessionId,name:t.name,bytes:t.sizeBytes,mime:t.mimeType});try{let w=await fetch(i,{method:"POST",headers:l,body:f,signal:x.signal}),b=w.headers.get("x-tt-logid")??"";if(!w.ok){let v=await w.text().catch(()=>"");throw new D("UPLOAD_FAILED",`upload HTTP ${w.status} logid=${b}: ${v.slice(0,200)}`)}let T=await w.json();if(T.code!==void 0&&T.code!==0)throw new D("UPLOAD_FAILED",`upload code=${T.code} msg=${T.msg??"-"} logid=${b}`);let E=T.data?.file?.file_url;if(!E)throw new D("UPLOAD_FAILED",`upload response missing data.file.file_url logid=${b}: ${JSON.stringify(T).slice(0,200)}`);return Ru.info("file upload ok",{uri:E,logid:b}),{uri:E}}catch(w){throw w instanceof D?w:w.name==="AbortError"?new D("UPLOAD_FAILED",`upload timeout (${o}ms) for ${d_(t.path)}`):new D("UPLOAD_FAILED",String(w),{cause:w})}finally{clearTimeout(p)}}He();ee();import{extname as l_}from"node:path";var x_={".png":"image/png",".jpg":"image/jpeg",".jpeg":"image/jpeg",".gif":"image/gif",".webp":"image/webp",".svg":"image/svg+xml",".bmp":"image/bmp",".ico":"image/x-icon",".heic":"image/heic",".heif":"image/heif",".pdf":"application/pdf",".doc":"application/msword",".docx":"application/vnd.openxmlformats-officedocument.wordprocessingml.document",".xls":"application/vnd.ms-excel",".xlsx":"application/vnd.openxmlformats-officedocument.spreadsheetml.sheet",".ppt":"application/vnd.ms-powerpoint",".pptx":"application/vnd.openxmlformats-officedocument.presentationml.presentation",".txt":"text/plain",".md":"text/markdown",".markdown":"text/markdown",".json":"application/json",".yaml":"text/yaml",".yml":"text/yaml",".csv":"text/csv",".html":"text/html",".htm":"text/html",".xml":"application/xml",".log":"text/plain",".zip":"application/zip",".tar":"application/x-tar",".gz":"application/gzip",".tgz":"application/gzip",".mp3":"audio/mpeg",".wav":"audio/wav",".mp4":"video/mp4",".mov":"video/quicktime",".webm":"video/webm"};async function ku(t){let e=l_(t).toLowerCase();return x_[e]??"application/octet-stream"}Me();var Vs=G("agent-send"),Lu=50*1024*1024;function Nu(t,e,r){let i=t.get(e);if(!i)throw new D("AGENT_NOT_FOUND",`agent=${e}`);if(t.disconnectedAgents.has(e))throw new D("AGENT_DISCONNECTED",`agent=${e} was disconnected by cloud`);let o=i.sessions.get(r);if(!o)throw new D("AGENT_NOT_FOUND",`session=${r} not active in agent=${e}`);return{session:i,runtime:o}}async function Mu(t,e,r,i,o,c){let l;for(let x=0;x<=2;x++)try{await t.core.sendAgentFileUpdate(e,r,i,o);return}catch(p){l=p,x<2&&(Vs.warn("sendAgentFileUpdate failed, retrying",{attempt:x+1,err:String(p)}),await new Promise(w=>setTimeout(w,5e3)))}throw new D("UPSTREAM_NOT_READY",`${c} after 3 attempts: ${String(l)}`,{cause:l})}async function Bu(t,e){let{session:r,runtime:i}=Nu(e.core,t.agentId,t.sessionId);if(!await Pr(t.path,r.workspace))throw new D("PATH_OUTSIDE_WORKSPACE",`path=${t.path} not under workspace=${r.workspace}`);let o=await h_.stat(t.path).catch(()=>null);if(!o||!o.isFile())throw new D("IPC_BAD_REQUEST",`path is not a regular file: ${t.path}`);if(o.size>Lu)throw new D("FILE_TOO_LARGE",`${o.size} bytes > limit ${Lu}`);let c=await ku(t.path);if(t.kind==="image"&&!c.startsWith("image/"))throw new D("UNSUPPORTED_MIME",`kind=image but mime=${c}`);if(!e.core.upstream.isConnected())throw new D("UPSTREAM_NOT_READY","cloud WS not connected");let f=t.name??Ou(t.path),l;try{l=await Du({patToken:r.patToken??e.patToken,agentId:t.agentId,sessionId:t.sessionId,path:t.path,mimeType:c,name:f,sizeBytes:o.size,...r.accountId?{accountId:r.accountId}:{}},{handshakeBase:e.handshakeBase,ppeOverride:e.ppeOverride})}catch(p){throw Vs.warn("agent file upload failed",{agentId:t.agentId,sessionId:t.sessionId,path:t.path,sizeBytes:o.size,mime:c,code:p instanceof D?p.code:"UNKNOWN",message:p instanceof Error?p.message:String(p)}),p}let x={sessionUpdate:"agent_file",messageId:Pu(),content:{type:t.kind==="image"?"image":"resource",uri:l.uri,mimeType:c,name:f,sizeBytes:o.size,...l.fileId!==void 0?{fileId:l.fileId}:{},...t.caption!==void 0?{caption:t.caption}:{}}};return await Mu(e,r,i,t.sessionId,x,"agent file uploaded to cloud but sendAgentFileUpdate failed"),Vs.info("agent file sent",{agentId:t.agentId,sessionId:t.sessionId,kind:t.kind,name:f,bytes:o.size,mime:c,uri:l.uri}),{ok:!0,uri:l.uri,bytes:o.size,mimeType:c,...l.fileId!==void 0?{fileId:l.fileId}:{}}}async function zu(t,e){let{session:r,runtime:i}=Nu(e.core,t.agentId,t.sessionId);if(!t.mimeType)throw new D("IPC_BAD_REQUEST","group-file requires mimeType");if(!e.core.upstream.isConnected())throw new D("UPSTREAM_NOT_READY","cloud WS not connected");let o=t.name??Ou(t.path),c={sessionUpdate:"group_file",messageId:Pu(),content:{uri:t.path,name:o,mimeType:t.mimeType,...t.caption!==void 0?{caption:t.caption}:{}}};return await Mu(e,r,i,t.sessionId,c,"agent group file sendAgentFileUpdate failed"),Vs.info("agent group file sent",{agentId:t.agentId,sessionId:t.sessionId,uri:t.path,name:o,mime:t.mimeType}),{ok:!0,uri:t.path,bytes:0,mimeType:t.mimeType}}function Fu(t,e){let r=t.split(".").map(Number),i=e.split(".").map(Number),o=Math.max(r.length,i.length);for(let c=0;c<o;c++){let f=r[c]??0,l=i[c]??0;if(f<l)return!0;if(f>l)return!1}return!1}gn();Hn();ee();var At=G("coze-cli-installer"),Uu="@coze/cli@latest",p_="coze",qu="0.1.7",g_=5e3,m_=5e3,w_=9e4,Hu=1e4,gi=null,$s=!1;async function bc(t,e={}){if($s)return;if(gi)return gi;let r=e.exec??Ni;return gi=(async()=>{try{let i=await __(p_,r),o=!1;if(i){let f=await y_(r);if(f===void 0)At.warn("coze-cli found but version unparseable, fall through to full install",{path:i});else if(Fu(f,qu))At.info("coze-cli version too old, upgrade-only (preserve user config + auth)",{path:i,version:f,min:qu}),o=!0;else{At.info("coze-cli already on PATH with sufficient version, skip",{path:i,version:f}),$s=!0;return}}let c=o?"upgrade-only":"full";At.info("coze-cli install start",{package:Uu,mode:c});try{await r("npm",["i","-g","--prefer-online",Uu],{timeout:w_,maxBuffer:10*1024*1024}),At.info("coze-cli install ok")}catch(f){At.warn("coze-cli install failed (skip subsequent steps)",{err:String(f)});return}if(o){$s=!0;return}if(t.env)try{await r("coze",["config","set","xTTEnv",t.env],{timeout:Hu}),At.info("coze config set xTTEnv ok",{env:t.env})}catch(f){At.warn("coze config set failed (continue to auth login)",{err:String(f)})}try{await r("coze",["auth","login","--token",t.patToken],{timeout:Hu}),At.info("coze auth login ok")}catch(f){At.warn("coze auth login failed",{err:String(f)});return}$s=!0}finally{gi=null}})(),gi}async function __(t,e){let r=process.platform==="win32"?"where":"which";try{let{stdout:i}=await e(r,[t],{timeout:g_});return zi(i)}catch{return}}async function y_(t){try{let{stdout:e,stderr:r}=await t("coze",["--version"],{timeout:m_});return(e||r).match(/(\d+\.\d+\.\d+)/)?.[1]}catch{return}}Ui();Me();var b_=10*6e4;function Gu(t){let e=t?.sessionIdleTimeoutMs;return typeof e!="number"||!Number.isFinite(e)||e<=0?b_:e}function Js(t){return Wn(t??te().configFile)}function _r(t,e){return Fi(e??te().configFile,t)}import{randomBytes as F_}from"node:crypto";import{createReadStream as E_}from"node:fs";import{mkdir as v_,readFile as S_,realpath as I_,stat as A_,writeFile as T_}from"node:fs/promises";import{basename as C_,dirname as Ec,join as R_,relative as D_,resolve as ju,sep as k_}from"node:path";import{createInterface as L_}from"node:readline";He();ee();var Wu=G("fs-rpc"),mi=gr("COZE_BRIDGE_FS_RPC_MAX_BYTES",20*1024*1024);async function Vu(t,e){let r=Buffer.byteLength(t.content,"utf8");if(r>mi)throw new D("IPC_BAD_REQUEST",`fs/write_text_file content too large: ${r} bytes > limit ${mi} bytes`);let i=await Ju(t.path,e);return await v_(Ec(i),{recursive:!0}),await T_(i,t.content,"utf8"),Wu.info("fs/write_text_file ok",{path:i,size:t.content.length}),null}async function $u(t,e){let r=await Ju(t.path,e),i=await A_(r),o=typeof t.line=="number"||typeof t.limit=="number";if(i.size>mi&&!o)throw new D("IPC_BAD_REQUEST",`fs/read_text_file too large without line/limit slicing: ${i.size} bytes > ${mi} bytes`);let c;if(o&&i.size>mi)c=await P_(r,t.line??1,t.limit);else{let f=await S_(r,"utf8");if(o){let l=f.split(`
86
+ `),x=Math.max(0,(t.line??1)-1),p=typeof t.limit=="number"?x+t.limit:void 0;c=l.slice(x,p).join(`
87
+ `)}else c=f}return Wu.info("fs/read_text_file ok",{path:r,size:c.length}),{content:c}}async function P_(t,e,r){let i=L_({input:E_(t,{encoding:"utf8"}),crlfDelay:Number.POSITIVE_INFINITY}),o=Math.max(0,e-1),c=typeof r=="number"?o+r:Number.POSITIVE_INFINITY,f=[],l=0;try{for await(let x of i)if(l>=o&&l<c&&f.push(x),l++,l>=c)break}finally{i.close()}return f.join(`
88
+ `)}async function Ju(t,e){if(typeof t!="string"||t.length===0)throw new D("IPC_BAD_REQUEST","path must be a non-empty string");let[r,i]=await Promise.all([Ku(ju(e)),Ku(ju(t))]),o=D_(r,i);if(o.startsWith("..")||o===".."||o.startsWith(`..${k_}`))throw new D("IPC_BAD_REQUEST",`path escapes workspace: ${t}`);return i}async function Ku(t){let e=[],r=t;for(;r!==Ec(r);)try{let i=await I_(r);return e.length?R_(i,...e.reverse()):i}catch{e.push(C_(r)),r=Ec(r)}return t}ee();var Yu=G("prompt-multimodal"),Zu=10*1024*1024,O_=15e3,N_=6;async function Xu(t){let e=new Array(t.length),r=0;async function i(){for(;r<t.length;){let c=r++,f=t[c];f!==void 0&&(e[c]=await M_(f))}}let o=Array.from({length:Math.min(N_,t.length)},()=>i());return await Promise.all(o),e}function Qu(t){return t.some(e=>e.type==="image")}async function M_(t){if(t.type!=="image")return t;let e=t;if(e.data||!e.uri||!Ps(e.uri))return t;try{let{buf:r,contentType:i}=await z_(e.uri),o=e.mimeType||B_(i)||"application/octet-stream";return Yu.info("image uri fetched and inlined",{uri:e.uri,bytes:r.length,mimeType:o}),{type:"image",data:r.toString("base64"),mimeType:o}}catch(r){return Yu.warn("image fetch failed, degrading to text block",{uri:e.uri,err:String(r)}),{type:"text",text:`[image load failed: ${e.uri}]`}}}function B_(t){if(!t)return;let e=t.indexOf(";");return(e===-1?t:t.slice(0,e)).trim()||void 0}async function z_(t){let e=new AbortController,r=setTimeout(()=>e.abort(),O_);try{let i=await fetch(t,{signal:e.signal});if(!i.ok)throw new Error(`HTTP ${i.status} ${i.statusText}`);let o=await i.arrayBuffer();if(o.byteLength>Zu)throw new Error(`image too large: ${o.byteLength} bytes (max ${Zu})`);return{buf:Buffer.from(o),contentType:i.headers.get("content-type")??void 0}}finally{clearTimeout(r)}}$t();He();ee();var J=G("core"),U_=3e4,q_=/^(boe|ppe)_[A-Za-z0-9_-]+$/,H_=3e4,Ys=class{upstream;agents=new Map;disconnectedAgents=new Set;extensions;paths;sessionSpawner;sessionIdleTimeoutMs;upstreamIds=new pr;pendingUpstream=new Map;pendingBridge=new Map;currentCozeEnv;currentMockScenario;constructor(e){this.upstream=e.upstream,this.extensions=e.extensions??{},this.paths=e.paths,this.sessionSpawner=e.sessionSpawner,this.sessionIdleTimeoutMs=Gu(e.bridgeConfig)}registerExtension(e,r){this.extensions[e]=r}getCozeEnv(){return this.currentCozeEnv}getMockScenario(){return this.currentMockScenario}setMockScenario(e){this.currentMockScenario=e&&e.length>0?e:void 0}async start(){this.upstream.onFrame(e=>this.handleFrame(e)),this.upstream.onConnect?.(({initial:e})=>{e||this.rejectAllPendingOnReconnect()}),await this.upstream.start(),J.info("Core started",{extensions:Object.keys(this.extensions)})}async stop(e){J.info("Core stopping",{reason:e}),await Promise.all([...this.agents.values()].map(r=>r.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),J.info("agent registered",{agentId:e.agentId,framework:e.framework});for(let r of this.registerHandlers)try{r(e.agentId)}catch(i){J.warn("onAgentRegister handler threw (ignored)",{agentId:e.agentId,err:String(i)})}}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)&&J.info("agent revived from disconnect",{agentId:e})}attachRuntimeHooks(e,r,i){let o=i.downstream;o&&(o.onUpdate(c=>{i.loadingSession||this.forwardUpdate(e,c)}),o.onAgentRequest(c=>{this.handleAgentRequest(e,o,c)}),o.onExit((c,f)=>{J.info("session runtime exited",{agentId:e.agentId,cloudId:r,code:c,signal:f}),pi(i),i.downstream=void 0,i.replySeq=0,i.acpSessionId&&e.activeTriggers.delete(i.acpSessionId),this.rejectPendingForDownstream(o,"downstream exited")}))}hasPendingPermissionFor(e){for(let r of this.pendingUpstream.values())if(r.downstream===e)return!0;return!1}rejectPendingForDownstream(e,r){let i=[];for(let[o,c]of this.pendingUpstream)c.downstream===e&&i.push(o);if(i.length!==0){J.info("reject pendingUpstream entries (downstream gone)",{reason:r,count:i.length});for(let o of i){let c=this.pendingUpstream.get(o);if(c){this.pendingUpstream.delete(o),this.upstream.send(fn(o,{code:Q.INTERNAL_ERROR,message:`bridge downstream gone: ${r}`})).catch(f=>J.debug("send error response to upstream failed (ignored)",{err:String(f)}));try{c.downstream.respondAgentRequestError(c.agentRequestId,{code:Q.INTERNAL_ERROR,message:`bridge: ${r}`})}catch{}}}}}rejectAllPendingOnReconnect(){let e=this.pendingUpstream.size,r=this.pendingBridge.size;if(!(e===0&&r===0)){J.warn("upstream reconnected, rejecting stale pending requests",{pendingUpstream:e,pendingBridge:r});for(let[,i]of this.pendingUpstream)try{i.downstream.respondAgentRequestError(i.agentRequestId,{code:Q.INTERNAL_ERROR,message:"upstream reconnected; please retry"})}catch{}this.pendingUpstream.clear();for(let[,i]of this.pendingBridge)clearTimeout(i.timer),i.reject(new D("UPSTREAM_DISCONNECTED",`${i.method} aborted: upstream reconnected`));this.pendingBridge.clear()}}async handleFrame(e){if(Fs(e)){this.handleUpstreamResponse(e);return}if(!("method"in e)||typeof e.method!="string")return;let r="id"in e&&e.id!==void 0?e.id:null,i=e.params?._meta?.cozeEnv;i&&q_.test(i)?this.currentCozeEnv=i:i&&J.warn("rejecting cozeEnv with invalid shape, keeping previous",{rejected:i});try{if(e.method.startsWith("_agent/")){let o=this.extensions[e.method];if(!o){r!==null?await this.sendError(r,Q.METHOD_NOT_FOUND,`extension not registered: ${e.method}`):J.warn("drop notification: extension not registered",{method:e.method});return}let c=await o(e,this);r!==null&&await this.upstream.send(hr(r,c));return}if(e.method.startsWith("session/")){let o=await this.routeSessionMethod(e);r!==null&&await this.upstream.send(hr(r,o));return}if(e.method==="initialize"){r!==null&&await this.upstream.send(hr(r,{protocolVersion:1,agentCapabilities:{loadSession:!0}}));return}r!==null?await this.sendError(r,Q.METHOD_NOT_FOUND,`method not implemented: ${e.method}`):J.warn("drop unknown notification",{method:e.method})}catch(o){J.error("handleFrame failed",{method:e.method,err:String(o)}),r!==null&&await this.upstream.send(fn(r,hi(o)))}}async routeSessionMethod(e){if(!e.params||typeof e.params!="object")throw new D("IPC_BAD_REQUEST",`${e.method} requires params`);let r=e.params,i=r._meta?.cozeAgentId;if(!i)throw new D("IPC_BAD_REQUEST",`${e.method}: missing _meta.cozeAgentId`);let o=this.agents.get(i);if(!o)throw this.disconnectedAgents.has(i)?new D("AGENT_DISCONNECTED",`agent ${i} has been disconnected; cloud must _agent/create to revive`):new D("AGENT_NOT_FOUND",`agent not found: ${i}`);let c=typeof r.sessionId=="string"?r.sessionId:void 0;if(e.method==="session/cancel"||e.method==="session/new"||!c)return this.dispatchSessionCall(o,e.method,r);let f=Date.now(),l=!1;try{let x=await o.getSessionQueue(c).enqueue(()=>this.dispatchSessionCall(o,e.method,r));return l=!0,x}finally{J.info("session call done",{agentId:o.agentId,method:e.method,durationMs:Date.now()-f,ok:l})}}async dispatchSessionCall(e,r,i){e.lastActiveAt=Date.now();let{stripped:o}=Vf(i);switch(r){case"session/new":{let c=G_();return J.info("session/new ack (lazy spawn)",{agentId:e.agentId,cloudId:c}),{sessionId:c}}case"session/load":{let c=o;return J.info("session/load ack (lazy spawn)",{agentId:e.agentId,cloudId:c.sessionId}),{}}case"session/prompt":{let c=o,f=c.sessionId;if(!f)throw new D("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 D("BRIDGE_INTERNAL","session runtime not ready after ensureDownstream");let x=i._meta?.cozeTriggerMsgId;x?e.activeTriggers.set(l.acpSessionId,x):e.activeTriggers.delete(l.acpSessionId);let p=Wf(i._meta);if(p?e.activeGroupIds.set(l.acpSessionId,p):e.activeGroupIds.delete(l.acpSessionId),e.deployType==="cloud"&&e.modelInfo?.capabilities?.image===!1&&Qu(c.prompt))throw new D("MODEL_MODALITY_UNSUPPORTED",`model=${e.modelInfo.id??e.model} does not support image input`);let w=await Xu(c.prompt);try{let b=await l.downstream.sessionPrompt({...c,sessionId:l.acpSessionId,prompt:w});return l.lastActiveAt=Date.now(),b}finally{if(e.activeTriggers.delete(l.acpSessionId),e.activeGroupIds.delete(l.acpSessionId),l.reloadAfterTurn){l.reloadAfterTurn=!1;let b=l.downstream;b&&(l.downstream=void 0,J.info("reloadAfterTurn: stopping downstream",{agentId:e.agentId,cloudId:f,acpId:l.acpSessionId}),b.stop("reload-after-turn").catch(T=>J.warn("reload-after-turn stop failed (ignored)",{agentId:e.agentId,cloudId:f,err:String(T)})))}else l.downstream?.isAlive()&&this.armIdleTimer(e,f,l)}}case"session/cancel":{let f=o.sessionId;if(!f)throw new D("IPC_BAD_REQUEST","session/cancel: missing sessionId");let l=e.sessions.get(f);if(e.hasSessionQueue(f)){let x=e.getSessionQueue(f);x.size>0&&(J.info("session/cancel: draining queued tasks",{agentId:e.agentId,cloudId:f,queuedCount:x.size}),x.dispose(new D("AGENT_PROTOCOL_ERROR",`cancelled by session/cancel on ${f}`)))}return l?.downstream?.isAlive()&&l.acpSessionId&&await l.downstream.sessionCancel({sessionId:l.acpSessionId}),{ok:!0}}default:throw new D("IPC_BAD_REQUEST",`session method not supported: ${r}`)}}async ensureRuntime(e,r){let i=e.sessions.get(r);if(i)return i;let c={modelToken:e.deployType==="cloud"?await this.requestSessionToken(e.agentId,r):"",tokenGeneratedAt:Date.now(),lastActiveAt:Date.now(),loadingSession:!1,replySeq:0};return e.sessions.set(r,c),await this.persistSessionMapping(e),c}async requestSessionToken(e,r){let i={sessionId:r,_meta:{cozeAgentId:e}};try{let o=await this.sendRequest(Et.GEN_MODEL_TOKEN,i,H_);if(!o?.modelToken)throw new D("MODEL_TOKEN_GEN_FAILED",`cloud returned empty modelToken (agentId=${e}, cloudSessionId=${r})`);return o.modelToken}catch(o){throw o instanceof D&&o.code==="MODEL_TOKEN_GEN_FAILED"?o:new D("MODEL_TOKEN_GEN_FAILED",o instanceof Error?o.message:String(o),{cause:o})}}async ensureDownstream(e,r,i){if(pi(i),i.downstream?.isAlive())return;if(!this.sessionSpawner)throw new D("AGENT_SPAWN_FAILED","sessionSpawner not wired (cannot spawn per-session downstream)");let o=3,c=3e4,f=i.spawnFailCount??0,l=i.spawnFailedAt??0;if(f>=o&&Date.now()-l<c)throw new D("AGENT_SPAWN_FAILED",`agent ${e.agentId} session ${r} spawn failed ${f} times in a row; please check framework binary / network and retry after ${Math.ceil((c-(Date.now()-l))/1e3)}s`);let x;try{x=await this.sessionSpawner(e,i.modelToken,r,this.currentCozeEnv,this.currentMockScenario)}catch(p){throw i.spawnFailCount=f+1,i.spawnFailedAt=Date.now(),i.spawnFailCount>=o&&i.acpSessionId&&(J.warn("clearing stale acpSessionId after repeated spawn failures",{agentId:e.agentId,cloudId:r,staleAcpId:i.acpSessionId}),i.acpSessionId=void 0),p}if(i.spawnFailCount=0,i.spawnFailedAt=void 0,i.downstream=x,this.attachRuntimeHooks(e,r,i),i.acpSessionId){i.loadingSession=!0;try{await x.sessionLoad({sessionId:i.acpSessionId,cwd:e.workspace}),J.info("session restored via session/load",{agentId:e.agentId,cloudId:r,acpId:i.acpSessionId})}catch(p){J.warn("session/load failed, fallback to session/new",{agentId:e.agentId,cloudId:r,acpId:i.acpSessionId,err:String(p)}),i.acpSessionId=void 0;let w=await x.sessionNew({cwd:e.workspace});i.acpSessionId=w.sessionId,await this.persistSessionMapping(e)}finally{i.loadingSession=!1}}else{let p=await x.sessionNew({cwd:e.workspace});i.acpSessionId=p.sessionId,await this.persistSessionMapping(e)}x.afterSessionEstablished&&i.acpSessionId&&await x.afterSessionEstablished(i.acpSessionId)}armIdleTimer(e,r,i){if(pi(i),this.isRuntimeBusy(e,i)){J.debug("skip idle timer: runtime busy (in-flight turn / pending permission)",{agentId:e.agentId,cloudId:r});return}i.idleTimer=setTimeout(()=>{if(i.idleTimer=void 0,this.isRuntimeBusy(e,i)){J.info("idle reaper fired but runtime busy, re-arming",{agentId:e.agentId,cloudId:r}),this.armIdleTimer(e,r,i);return}J.info("session runtime idle timeout, killing downstream",{agentId:e.agentId,cloudId:r});let o=i.downstream;i.downstream=void 0,i.acpSessionId&&e.activeTriggers.delete(i.acpSessionId),o&&o.stop("idle timeout").catch(c=>J.warn("idle stop failed (ignored)",{agentId:e.agentId,cloudId:r,err:String(c)}))},this.sessionIdleTimeoutMs),i.idleTimer.unref?.()}isRuntimeBusy(e,r){if(r.acpSessionId&&e.activeTriggers.has(r.acpSessionId))return!0;let i=r.downstream;if(!i)return!1;for(let o of this.pendingUpstream.values())if(o.downstream===i)return!0;return!1}async sendAgentFileUpdate(e,r,i,o){let c={cozeAgentId:e.agentId,cozeReplySeqID:++r.replySeq};if(r.acpSessionId){let f=e.activeTriggers.get(r.acpSessionId);f&&(c.cozeTriggerMsgId=f);let l=e.activeGroupIds.get(r.acpSessionId);l&&(c.cozeGroupId=l)}await this.upstream.send(li("session/update",{sessionId:i,update:o,_meta:c}))}forwardUpdate(e,r){let i=r.sessionId,o=this.reverseSessionId(e,i);if(!o){J.debug("drop update for unknown session",{agentId:e.agentId,acpId:i});return}let c=e.sessions.get(o);if(!c){J.debug("drop update: runtime gone",{agentId:e.agentId,cloudId:o});return}if(K_(r)){J.debug("drop codex metadata-warn chunk",{agentId:e.agentId,acpId:i});return}let f={cozeAgentId:e.agentId,cozeReplySeqID:++c.replySeq},l=e.activeTriggers.get(i);l&&(f.cozeTriggerMsgId=l);let x=e.activeGroupIds.get(i);x&&(f.cozeGroupId=x),this.upstream.send(li("session/update",{...r,sessionId:o,_meta:f})).catch(p=>J.warn("forward update failed",{agentId:e.agentId,err:String(p)}))}handleAgentRequest(e,r,i){if(i.method==="session/request_permission"){this.forwardPermissionRequest(e,r,i);return}if(i.method==="fs/write_text_file"||i.method==="fs/read_text_file"){this.handleFsRpcRequest(e,r,i);return}J.warn("unhandled agent request,returning method_not_found",{agentId:e.agentId,method:i.method}),r.respondAgentRequestError(i.id,{code:Q.METHOD_NOT_FOUND,message:`method not handled by Bridge: ${i.method}`})}async handleFsRpcRequest(e,r,i){try{let o=e.workspace;if(i.method==="fs/write_text_file"){let c=i.params??{},f=await Vu(c,o);r.respondAgentRequest(i.id,f)}else{let c=i.params??{},f=await $u(c,o);r.respondAgentRequest(i.id,f)}}catch(o){J.warn("fs rpc handler failed",{agentId:e.agentId,method:i.method,err:String(o)}),r.respondAgentRequestError(i.id,hi(o))}}forwardPermissionRequest(e,r,i){let o=this.upstreamIds.next("session/request_permission"),c=i.params??{},l=c.sessionId,x=l?e.activeTriggers.get(l):void 0,p={cozeAgentId:e.agentId};x&&(p.cozeTriggerMsgId=x);let w=l?e.activeGroupIds.get(l):void 0;w&&(p.cozeGroupId=w);let b=l?this.reverseSessionId(e,l):void 0,T={...c,...b?{sessionId:b}:{},_meta:p};this.pendingUpstream.set(o,{agentRequestId:i.id,agentId:e.agentId,downstream:r,method:i.method}),J.info("forward permission_request \u2192 upstream",{agentId:e.agentId,upstreamId:o,acpSessionId:l,cloudSessionId:b,toolCallId:c.toolCall?.toolCallId,options:c.options?.map(E=>({optionId:E.optionId,kind:E.kind,name:E.name}))}),this.upstream.send(ui(o,"session/request_permission",T)).catch(E=>{this.pendingUpstream.delete(o),J.error("forward permission request failed",{agentId:e.agentId,err:String(E)}),r.respondAgentRequestError(i.id,{code:Q.INTERNAL_ERROR,message:`upstream send failed: ${String(E)}`})})}handleUpstreamResponse(e){if(e.id===null)return;let r=this.lookupPending(this.pendingUpstream,e.id,"upstream");if(r){this.pendingUpstream.delete(r.key);let o=r.value;e.error?(J.info("upstream \u2192 permission response (error)",{agentId:o.agentId,upstreamId:e.id,method:o.method,error:e.error}),o.downstream.respondAgentRequestError(o.agentRequestId,e.error)):(o.method==="session/request_permission"&&j_(e.result,o),J.info("upstream \u2192 permission response (result)",{agentId:o.agentId,upstreamId:e.id,method:o.method,result:e.result}),o.downstream.respondAgentRequest(o.agentRequestId,e.result));return}let i=this.lookupPending(this.pendingBridge,e.id,"bridge");if(i){this.pendingBridge.delete(i.key),clearTimeout(i.value.timer),e.error?i.value.reject(new zs(e.error)):i.value.resolve(e.result);return}J.debug("orphan upstream response (no pending)",{id:e.id})}lookupPending(e,r,i){let o=e.get(r);if(o)return{value:o,key:r};if(typeof r=="number"){let c=String(r),f=e.get(c);if(f)return J.warn(`${i} id type mismatch: number received but Bridge expected string`,{rawId:r,normalizedId:c}),{value:f,key:c}}}sendRequest(e,r,i=U_){let o=this.upstreamIds.next(e);return new Promise((c,f)=>{let l=setTimeout(()=>{this.pendingBridge.delete(o),f(new D("AGENT_TIMEOUT",`${e} timed out after ${i}ms`))},i);this.pendingBridge.set(o,{method:e,resolve:c,reject:f,timer:l}),this.upstream.send(ui(o,e,r)).catch(x=>{let p=this.pendingBridge.get(o);p&&(clearTimeout(p.timer),this.pendingBridge.delete(o)),f(x)})})}async persistSessionMapping(e){if(this.paths)try{let r=new Map;for(let[i,o]of e.sessions){let c={modelToken:o.modelToken,tokenGeneratedAt:o.tokenGeneratedAt};o.acpSessionId&&(c.acpSessionId=o.acpSessionId),r.set(i,c)}await Yo(e.agentId,r,this.paths)}catch(r){J.warn("persist session mapping failed",{agentId:e.agentId,err:String(r)})}}reverseSessionId(e,r){for(let[i,o]of e.sessions.entries())if(o.acpSessionId===r)return i}sendError(e,r,i){return this.upstream.send(fn(e,{code:r,message:i,data:{bridgeVersion:xr}}))}};function G_(){return F_(16).toString("hex")}function j_(t,e){if(!t||typeof t!="object"){J.warn("permission response: result not an object (suspicious)",{agentId:e.agentId,result:t});return}let r=t;if("kind"in r&&!("outcome"in r)){J.warn('permission response: top-level "kind" field (D66 historical bug shape)',{agentId:e.agentId,result:t});return}let i=r.outcome;if(!i||typeof i!="object"){J.warn("permission response: missing or non-object outcome field",{agentId:e.agentId,result:t});return}let c=i.outcome;(typeof c!="string"||c!=="selected"&&c!=="cancelled")&&J.warn("permission response: unknown outcome discriminant",{agentId:e.agentId,outcomeValue:c,result:t})}function K_(t){let e=t.update;if(e?.sessionUpdate!=="agent_message_chunk")return!1;let r=e.content;if(!r||typeof r!="object")return!1;let i=r;return i.type!=="text"||typeof i.text!="string"?!1:i.text.startsWith("Model metadata for `")}ee();Me();import{randomBytes as W_}from"node:crypto";import{chmod as V_,mkdir as $_,writeFile as el}from"node:fs/promises";import{createServer as J_}from"node:http";import{dirname as Y_}from"node:path";var Z_=1e6,vc=G("ipc"),Zs=class{server=null;port=0;token="";routes;paths;constructor(e){this.routes=new Map(e.routes.map(r=>[`${r.method} ${r.path}`,r])),this.paths=e.paths??te()}async start(){this.token=W_(32).toString("hex");let e=J_((i,o)=>{this.dispatch(i,o)});this.server=e,await new Promise((i,o)=>{e.once("error",o),e.listen(0,"127.0.0.1",()=>i())});let r=e.address();if(!r||typeof r!="object")throw new Error("failed to obtain IPC port");return this.port=r.port,await this.persistAuthFiles(),vc.info("IPC listening",{port:this.port}),{port:this.port,token:this.token}}async stop(){let e=this.server;e&&(await new Promise((r,i)=>{e.close(o=>o?i(o):r())}),this.server=null)}async persistAuthFiles(){await $_(Y_(this.paths.portFile),{recursive:!0}),await el(this.paths.portFile,String(this.port),"utf8"),await el(this.paths.tokenFile,this.token,{encoding:"utf8",mode:384});try{await V_(this.paths.tokenFile,384)}catch(e){vc.warn("chmod token file failed (non-POSIX?)",{err:String(e)})}}async dispatch(e,r){if(e.headers.authorization!==`Bearer ${this.token}`){wi(r,401,{error:"unauthorized"});return}let o=`${e.method} ${(e.url??"").split("?")[0]}`,c=this.routes.get(o);if(!c){wi(r,404,{error:"not found"});return}let f=null;if(e.method==="POST")try{f=await X_(e)}catch(l){wi(r,400,{error:"invalid json",detail:String(l)});return}try{let l=await c.handler(f,e);wi(r,200,l??{ok:!0})}catch(l){vc.error("IPC handler failed",{key:o,err:String(l)}),wi(r,500,{error:l instanceof Error?l.message:String(l)})}}};function wi(t,e,r){t.statusCode=e,t.setHeader("content-type","application/json"),t.end(JSON.stringify(r))}async function X_(t){let e=[],r=0;for await(let o of t){let c=o;if(r+=c.length,r>Z_)throw new Error("body too large");e.push(c)}let i=Buffer.concat(e).toString("utf8");return i?JSON.parse(i):null}var vx=pt(ul(),1);var L1=pt(ox(),1),P1=pt(ho(),1),O1=pt(Er(),1),N1=pt(Mc(),1),M1=pt(Fc(),1),B1=pt(Kc(),1),px=pt(wo(),1),z1=pt(hx(),1);var gx=px.default;He();ee();var Ie=G("upstream.frontier"),_x="application/json",yx="none",U1=15e3,Ti=class{constructor(e){this.opts=e}opts;fws=null;handler=null;connectHandlers=[];opened=!1;lastSendRefusedLogAt=0;sendRefusedSuppressed=0;openCount=0;async start(){if(this.fws){Ie.warn("start called on already-started FrontierUpstream; noop");return}let e={Authorization:`Bearer ${this.opts.privatecode}`,Origin:Yf,...ur(this.opts.ppeOverride)};class r extends gx{constructor(v){super(v,Jf,{headers:e})}send(v,...I){if(k0("debug"))try{let A;typeof v=="string"?A=Buffer.from(v,"utf8"):v instanceof Buffer?A=v:v instanceof ArrayBuffer?A=new Uint8Array(v):ArrayBuffer.isView(v)?A=new Uint8Array(v.buffer,v.byteOffset,v.byteLength):A=new Uint8Array(0);let k=Buffer.from(A.slice(0,128)).toString("hex");Ie.debug("WS raw frame out",{bytes:A.byteLength,headHex:k})}catch(A){Ie.warn("WS raw frame dump failed",{err:String(A)})}super.send(v,...I)}}let i=Xf(this.opts.urlOverride),o={url:i,ws:r,fpID:$f,aID:Ns,accessKey:this.opts.handshake.accessKey,deviceID:this.opts.handshake.deviceId,payloadType:{type:_x,force:!0},payloadEncoding:{encoding:yx,force:!0},enableTransformTextPayload:!0,enableQoS:!1,enableAutoAck:!1,automaticOpen:!1,maxRetries:Number.POSITIVE_INFINITY,debug:this.opts.debug??!1},c=new vx.FWS(o),f=!1,l=null,x,p,w=new Promise((E,v)=>{x=E,p=v}),b=E=>{f||(f=!0,l&&(clearTimeout(l),l=null),E?p(E):x())};c.onopen=()=>{this.opened=!0,this.openCount+=1;let E=this.openCount===1;Ie.info("frontier opened",{url:i,remoteDeviceId:this.opts.handshake.deviceId,initial:E,openCount:this.openCount}),E&&b();for(let v of this.connectHandlers)Promise.resolve(v({initial:E})).catch(I=>Ie.warn("onConnect handler threw (ignored)",{err:String(I)}))},c.onclose=E=>{this.opened=!1,Ie.info("frontier closed",{code:E.code,reason:E.reason,willReconnect:E.willReconnect})},c.onerror=E=>{Ie.warn("frontier error",{code:E.code,msg:E.message}),b(new D("UPSTREAM_DISCONNECTED",`frontier connect error before open: code=${E.code} msg=${E.message??""}`))},c.onmessage=E=>this.handleMessage(E),this.fws=c;let T=this.opts.openTimeoutMs??U1;l=setTimeout(()=>{b(new D("UPSTREAM_DISCONNECTED",`frontier ws open timeout after ${T}ms (handshake or upgrade slow)`))},T),await c.connect();try{await w}catch(E){try{c.close(1e3,"open failed")}catch(v){Ie.warn("fws close during start failure threw (ignored)",{err:String(v)})}throw this.fws=null,this.opened=!1,E}}async stop(e){let r=this.fws;if(r){this.fws=null,this.opened=!1;try{r.close(1e3,e??"bridge shutdown")}catch(i){Ie.warn("frontier close threw (ignored)",{err:String(i)})}}}async send(e){let r=this.fws,i=e.method;if(!r)throw Ie.warn("frontier send refused: upstream not started",{method:i}),new D("UPSTREAM_DISCONNECTED","frontier upstream not started");if(!this.isConnected()){let l=Date.now();throw l-this.lastSendRefusedLogAt>1e3?(Ie.warn("frontier send refused: ws not open",{method:i,opened:this.opened,readyState:r.readyState,...this.sendRefusedSuppressed>0?{suppressedSinceLast:this.sendRefusedSuppressed}:{}}),this.lastSendRefusedLogAt=l,this.sendRefusedSuppressed=0):this.sendRefusedSuppressed+=1,new D("UPSTREAM_DISCONNECTED",`frontier ws not open (opened=${this.opened}, readyState=${r.readyState}); refusing to silently buffer`)}this.injectAgentPatToken(e);let o=JSON.stringify(e),c=e;bx(c)||Ie.info("frontier frame out",{method:c.method,jsonrpcId:c.id,size:o.length});try{await r.send(o,{service:33555712,method:1,payloadType:_x,payloadEncoding:yx})}catch(l){throw Ie.warn("frontier frame send failed",{method:c.method,jsonrpcId:c.id,err:String(l)}),new D("UPSTREAM_DISCONNECTED",`frontier send failed: ${String(l)}`,{cause:l})}}onFrame(e){this.handler=e}onConnect(e){this.connectHandlers.push(e)}isConnected(){return this.opened&&this.fws?.readyState===1}injectAgentPatToken(e){let r=this.opts.getPatTokenForAgent;if(!r)return;let i=e.params?._meta;if(!i?.cozeAgentId)return;let o=r(i.cozeAgentId);o&&(i.cozePatToken=o)}handleMessage(e){let r=e.message?.service;if(r!==33555712){Ie.debug("drop non-adapter frontier frame",{service:r});return}let i=G1(e);if(!i){Ie.debug("frontier message without text payload, drop",{payloadType:e.message?.payloadType});return}if(!this.handler){Ie.debug("frame received but no onFrame handler",{size:i.length});return}let o;try{o=JSON.parse(i)}catch(f){Ie.warn("frontier message JSON parse failed",{err:String(f),head:i.slice(0,80)});return}let c=o;bx(c)||Ie.info("frontier frame in",{logid:H1(e.message?.LogID),logidNew:e.message?.LogIDNew,msgId:e.message?.msgID,jsonrpcId:c.id,method:c.method,body:q1(i)}),Promise.resolve(this.handler(o)).catch(f=>Ie.warn("frontier frame handler threw",{err:String(f)}))}};function bx(t){return t.method==="_agent/health"?!0:typeof t.id=="string"&&t.id.startsWith("agent.health_")}var Ex=2e3;function q1(t){return t.length<=Ex?t:`${t.slice(0,Ex)}...<truncated, total ${t.length} chars>`}function H1(t){return t?t.high===0?String(t.low>>>0):`${t.high.toString(16)}${(t.low>>>0).toString(16).padStart(8,"0")}`:""}function G1(t){let e=t.message;if(e?.textPayload)return e.textPayload;let r=e?.payload;if(!r)return null;try{return Buffer.from(r).toString("utf8")}catch{return null}}ee();var Vc=G("upstream.switchable"),yo=class{inner;handler=null;connectHandlers=[];constructor(e){this.inner=e}async swap(e,r){if(this.inner===e)return;Vc.info("swap upstream",{reason:r});let i=this.inner;if(this.inner=e,this.handler&&e.onFrame(this.handler),e.onConnect)for(let o of this.connectHandlers)e.onConnect(o);try{await e.start()}catch(o){throw Vc.error("swap target start failed, reverting",{err:String(o)}),this.inner=i,o}await i.stop(r??"swapped").catch(o=>Vc.warn("previous upstream stop threw (ignored)",{err:String(o)}))}current(){return this.inner}start(){return this.inner.start()}stop(e){return this.inner.stop(e)}send(e){return this.inner.send(e)}onFrame(e){this.handler=e,this.inner.onFrame(e)}onConnect(e){this.connectHandlers.push(e),this.inner.onConnect?.(e)}isConnected(){return this.inner.isConnected()}};ee();var $c=G("upstream"),Cr=class{handler=null;async start(){$c.info("NoopUpstream started (M1 skeleton; real Frontier wired in M4)")}async stop(e){$c.info("NoopUpstream stopped",{reason:e})}async send(e){$c.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)}};He();ee();ee();Me();import{promises as Jc}from"node:fs";import{dirname as j1}from"node:path";var K1=G("pat-token-store");async function Sx(t=te()){try{let r=(await Jc.readFile(t.patTokenFile,"utf8")).trim();return r.length>0?r:null}catch(e){let r=e?.code;return r!=="ENOENT"&&K1.warn("read pat-token failed (treating as missing)",{path:t.patTokenFile,code:r,message:e.message}),null}}async function Ci(t,e=te()){if(!t)throw new Error("writePatToken: empty patToken");await Jc.mkdir(j1(e.patTokenFile),{recursive:!0}),await Jc.writeFile(e.patTokenFile,t,{encoding:"utf8",mode:384})}Me();Me();import{promises as bo}from"node:fs";import{join as W1}from"node:path";function V1(t,e){return`#!/bin/sh
89
89
  exec ${JSON.stringify(e)} ${JSON.stringify(t)} "$@"
90
- `}function ob(t,e){return`@echo off\r
90
+ `}function $1(t,e){return`@echo off\r
91
91
  "${e}" "${t}" %*\r
92
- `}async function Ax(t,e=te()){let r=e.binDir;await Eo.mkdir(r,{recursive:!0});let s=ib(r,process.platform==="win32"?"coze-bridge.cmd":"coze-bridge"),a=process.execPath,c=process.platform==="win32"?ob(t,a):sb(t,a);return await Eo.readFile(s,"utf8").catch(()=>null)===c||(await Eo.writeFile(s,c,"utf8"),process.platform!=="win32"&&await Eo.chmod(s,493)),r}ee();Me();import{execSync as Tx}from"node:child_process";import{readFileSync as Dx,unlinkSync as ab}from"node:fs";import{mkdir as cb,readFile as Rx,unlink as kx,writeFile as db}from"node:fs/promises";import{dirname as fb}from"node:path";function Cx(t){try{return process.kill(t,0),!0}catch(e){return e.code==="EPERM"}}var lb=H("single-instance"),bo=class{pidFile;acquired=!1;constructor(e={}){this.pidFile=e.pidFile??te().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&&(lb.warn("removing stale pid file",{stalePid:e}),await kx(this.pidFile).catch(()=>{})),await cb(fb(this.pidFile),{recursive:!0}),await db(this.pidFile,String(process.pid),"utf8"),this.acquired=!0,this.installCleanupHooks(),{kind:"acquired"})}async release(){if(this.acquired){try{(await Rx(this.pidFile,"utf8")).trim()===String(process.pid)&&await kx(this.pidFile)}catch{}this.acquired=!1}}async readExistingPid(){try{let e=await Rx(this.pidFile,"utf8"),r=Number.parseInt(e.trim(),10);return Number.isFinite(r)&&r>0?r:null}catch(e){if(e.code==="ENOENT")return null;throw e}}isAlive(e){return Cx(e)?this.matchesDaemonTitle(e):!1}matchesDaemonTitle(e){if(process.platform==="win32")return this.matchesDaemonTitleWindows(e);try{let r=Dx(`/proc/${e}/cmdline`,"utf8").replace(/\0/g," ");return!!(r.includes("coze-bridge-daemon")||r.includes("lib/index.js"))}catch{}try{let r=Tx(`ps -o command= -p ${e}`,{stdio:["ignore","pipe","ignore"],timeout:1e3}).toString();return r.trim()?r.includes("coze-bridge-daemon")||r.includes("lib/index.js"):!1}catch{return!0}}matchesDaemonTitleWindows(e){try{let s=Tx(`tasklist /FI "PID eq ${e}" /FO CSV /NH`,{stdio:["ignore","pipe","ignore"],timeout:2e3}).toString().trim();if(!s||/^(INFO|信息)[::]/.test(s))return!1;let a=s.split(",",1)[0]?.replace(/^"|"$/g,"").toLowerCase()??"";return a.includes("node")||a.includes("coze-bridge")}catch{return!0}}installCleanupHooks(){process.once("exit",()=>{if(this.acquired)try{Dx(this.pidFile,"utf8").trim()===String(process.pid)&&ab(this.pidFile)}catch{}})}};var G=H("daemon"),ub="coze-bridge-daemon";async function Px(){let t=new bo({processTitle:ub}),e=await t.acquire();if(e.kind==="already-running")throw new Error(`coze-bridge daemon already running (pid=${e.pid})`);let r=await Js(),s=r??{};Li({pid:process.pid}),G.info(r?"loaded bridge config":"initialized bridge config");try{let O=new gn;s.frameworksCache=await O.detectAll(),G.info("refreshed frameworks_cache",{detected:Object.keys(s.frameworksCache)})}catch(O){G.warn("framework detection failed",{err:String(O)})}await Er(s);let a=new yo(new Rr),c=te(),f=null,l=new Zs({upstream:a,paths:c,bridgeConfig:s,sessionSpawner:async(O,N,U,W)=>{if(!f)throw new Error("agentManager not ready");return f.spawnSessionDownstream(O,N,U,W)}});await hb(c,l);let x=new Ws({paths:c,config:s,registry:l});f=x;let h,m,E=null,C={},_,y=null;l.registerExtension("_agent/create",async O=>x.createAgent(O.params)),l.registerExtension("_agent/health",async()=>({ok:!0}));let v={},I=new Bs({agents:l.agents,disposeAndMarkDisconnected:async(O,N)=>{let U=l.agents.get(O);if(U){await x.cleanupOpenclawSessionProviders(U).catch(se=>G.warn("cleanup openclaw providers failed (ignored)",{agentId:O,err:String(se)}));let W=!0;try{await U.dispose(`disconnect: ${N}`)}catch(se){W=!1,G.error("dispose during disconnect FAILED, leaving agent in error state",{agentId:O,err:String(se)}),U.status="error"}W&&(U.status="disconnected",l.unregister(O),l.disconnectedAgents.add(O))}else l.disconnectedAgents.add(O)},detailSyncer:async O=>{if(!v.ref)throw new Error("agent-detail-sync not initialized yet");await v.ref.syncOne(O)},cleanupOpenclawProviders:async O=>{await x.cleanupOpenclawSessionProviders(O)},openclawRepair:async(O,N)=>{await x.openclawRepair(O,N)},isRuntimePendingPermission:O=>l.hasPendingPermissionFor(O)});l.registerExtension("_agent/listSkills",O=>I.listSkills(O.params)),l.registerExtension("_agent/addSkills",O=>I.addSkills(O.params)),l.registerExtension("_agent/removeSkills",O=>I.removeSkills(O.params)),l.registerExtension("_agent/getFileTree",O=>I.getFileTree(O.params)),l.registerExtension("_agent/getFileContent",O=>I.getFileContent(O.params)),l.registerExtension("_agent/update",O=>I.updateAgent(O.params)),l.registerExtension("_agent/disconnect",O=>I.disconnectAgent(O.params)),l.registerExtension("_agent/switchModel",O=>I.switchModel(O.params)),l.registerExtension("_agent/reset",O=>I.resetAgent(O.params)),l.registerExtension("_agent/repair",O=>I.repairAgent(O.params));let R=new Gi({paths:c,handlers:I,sendDetail:O=>l.sendRequest("_agent/detail",O)});v.ref=R;let L=async O=>{await Promise.allSettled(O.map(async N=>{try{await I.disconnectAgent({agentId:N.agentId,reason:`auth_failure: code=${N.code} ${N.message}`}),G.info("agent disconnected due to auth failure from heartbeat response",{agentId:N.agentId,code:N.code,message:N.message})}catch(U){G.warn("disconnect during authFailure handling failed (ignored)",{agentId:N.agentId,err:String(U)})}}))};a.onConnect(({initial:O})=>{G.info("frontier upstream connected, triggering detail sync",{initial:O}),R.syncAll(O?"initial-connect":"reconnect").catch(N=>G.warn("detail sync top-level error (ignored)",{err:String(N)}))});let w=new Ys({paths:c,routes:[{method:"GET",path:"/status",handler:async()=>{let O=l.getMockScenario();return{running:!0,pid:process.pid,agents:[...l.agents.keys()],deviceId:E??"",frameworksCache:s.frameworksCache??{},...O?{mockScenario:O}:{}}}},{method:"POST",path:"/pair",handler:async O=>{let N=O,U=N?.privatecode,W=N?.pairing_code;if(!U||!W)throw new D("IPC_BAD_REQUEST","/pair requires privatecode + pairing_code");let se=fi(N.env),fe=N.handshake_url,we=N.frontier_url,Le=Ox(N.env,fe,we),ot=!!h&&h!==U,Ae=m!==void 0&&m!==Le,Gt=ot||Ae,_e=await oc({privatecode:U,...fe?{endpoint:fe}:{},ppeOverride:se});if(Gt){G.warn("pair config switched, resetting agents",{pcChanged:ot,envChanged:Ae,previousPc:h?So(h):"",nextPc:So(U),previousEnvKey:m??"",nextEnvKey:Le});for(let ge of[...l.agents.values()])await ge.dispose("pair config switch").catch(()=>{}),l.agents.delete(ge.agentId);l.disconnectedAgents.size>0&&(G.info("clearing disconnectedAgents set on pair config switch",{count:l.disconnectedAgents.size}),l.disconnectedAgents.clear()),await a.swap(new Rr,"pair switch").catch(()=>{})}E=_e.deviceId,Li({deviceId:E,pid:process.pid}),bc({patToken:U,env:N.env}).catch(ge=>G.warn("coze-cli setup error (ignored)",{err:String(ge)}));let Y=new Di({handshake:_e,privatecode:U,...we?{urlOverride:we}:{},ppeOverride:se,getPatTokenForAgent:ge=>l.agents.get(ge)?.patToken});await a.swap(Y,"pair");try{let ge=new gn;s.frameworksCache=await ge.detectAll(),await Er(s),G.info("frameworks_cache refreshed before pair",{detected:Object.keys(s.frameworksCache)})}catch(ge){G.warn("frameworks_cache refresh failed (ignored, using cached)",{err:String(ge)})}let Un=Object.keys(s.frameworksCache??{});try{let ge=await l.sendRequest("_agent/pair",{pairCode:W,patToken:U,frameworks:Un,_meta:{cozeDeviceId:E}});G.info("_agent/pair ok",{pairResult:ge}),h=U,m=Le,C=se,_=fe,N.mock_scenario!==void 0&&(l.setMockScenario(N.mock_scenario),G.info("mock scenario set",{scenario:N.mock_scenario})),Ri(U,c).catch(Ke=>G.warn("writePatToken after /pair failed (ignored)",{err:String(Ke)})),y||(y=new ui({core:l,getDeviceId:()=>E??"",onTickEnd:()=>R.retryPending().catch(Ke=>G.warn("detailSync.retryPending failed (ignored)",{err:String(Ke)})),onAuthFailures:L})),y.start(),Gt&&vo(c,x).catch(Ke=>G.warn("post-pair-switch auto-revive error (ignored)",{err:String(Ke)}));let qn;return N.agent_id&&(qn=await pb(N.agent_id,c,x,Ke=>l.sendRequest("_agent/detail",Ke),U).catch(Ke=>(G.error("--agent-id ensureAgent failed",{agentId:N.agent_id,err:String(Ke)}),{ok:!1,agentId:N.agent_id??"",note:String(Ke)}))),{ok:!0,note:"paired with cloud",...qn?{agent:qn}:{}}}catch(ge){return G.error("_agent/pair failed",{err:String(ge)}),{ok:!1,note:`pair failed: ${String(ge)}`}}}},{method:"POST",path:"/connect",handler:async O=>{let N=O,U=N?.privatecode;if(!U)throw new D("IPC_BAD_REQUEST","/connect requires privatecode");let W=fi(N.env),se=N.handshake_url,fe=N.frontier_url,we=Ox(N.env,se,fe);if(h===U&&m===we){let Y=await xb(c);return l.agents.size===0&&Y?(G.warn("/connect noop but core.agents empty with configs on disk; re-running auto-revive"),vo(c,x).catch(Un=>G.warn("connect-noop auto-revive error (ignored)",{err:String(Un)}))):G.info("/connect: already connected with same PAT + env, noop"),{ok:!0,note:"already connected"}}let Le=!!h&&h!==U,ot=m!==void 0&&m!==we,Ae=Le||ot,Gt=await oc({privatecode:U,...se?{endpoint:se}:{},ppeOverride:W});if(Ae){G.warn("connect config switched, resetting agents",{pcChanged:Le,envChanged:ot,previousPc:h?So(h):"",nextPc:So(U)});for(let Y of[...l.agents.values()])await Y.dispose("connect config switch").catch(()=>{}),l.agents.delete(Y.agentId);l.disconnectedAgents.size>0&&(G.info("clearing disconnectedAgents set on connect config switch",{count:l.disconnectedAgents.size}),l.disconnectedAgents.clear()),await a.swap(new Rr,"connect switch").catch(()=>{})}E=Gt.deviceId,Li({deviceId:E,pid:process.pid}),bc({patToken:U,env:N.env}).catch(Y=>G.warn("coze-cli setup error (ignored)",{err:String(Y)}));let _e=new Di({handshake:Gt,privatecode:U,...fe?{urlOverride:fe}:{},ppeOverride:W,getPatTokenForAgent:Y=>l.agents.get(Y)?.patToken});return await a.swap(_e,"connect"),h=U,m=we,C=W,_=se,N.mock_scenario!==void 0&&(l.setMockScenario(N.mock_scenario),G.info("mock scenario set",{scenario:N.mock_scenario})),y||(y=new ui({core:l,getDeviceId:()=>E??"",onTickEnd:()=>R.retryPending().catch(Y=>G.warn("detailSync.retryPending failed (ignored)",{err:String(Y)})),onAuthFailures:L})),y.start(),Ae&&vo(c,x).catch(Y=>G.warn("post-connect-switch auto-revive error (ignored)",{err:String(Y)})),Ri(U,c).catch(Y=>G.warn("writePatToken after /connect failed (ignored)",{err:String(Y)})),G.info("/connect: WS established",{deviceId:E}),{ok:!0,note:"connected"}}},{method:"POST",path:"/_agent/create",handler:async O=>{let N=O;return{ok:!0,result:await x.createAgent(N)}}},{method:"POST",path:"/agent/send",handler:async O=>{let N=O;if(!N?.agentId||!N?.sessionId||!N?.kind||!N?.path)throw new D("IPC_BAD_REQUEST","/agent/send requires agentId, sessionId, kind, path");if(!h)throw new D("UPSTREAM_NOT_READY","daemon not yet paired with cloud (run --pair-code first)");try{let U=N;return await(U.groupFile?Fl:zl)(U,{core:l,patToken:h,handshakeBase:_,ppeOverride:C})}catch(U){if(U instanceof D)return{ok:!1,code:U.code,message:U.message};throw U}}},{method:"POST",path:"/refresh",handler:async()=>{G.info("IPC /refresh: re-detecting frameworks");let O=new gn;return s.frameworksCache=await O.detectAll(),await Er(s),{ok:!0,frameworks:s.frameworksCache}}},{method:"POST",path:"/shutdown",handler:async()=>(G.info("IPC /shutdown received"),setImmediate(()=>{z.shutdown("ipc /shutdown")}),{ok:!0})}]}),{port:A,token:k}=await w.start();try{await Ax(c.libEntry,c)}catch(O){G.warn("bin shim install failed (D72 send \u547D\u4EE4\u53EF\u80FD\u4E0D\u53EF\u7528)",{err:String(O)})}await l.start(),vo(c,x).catch(O=>G.warn("auto-revive top-level error (ignored)",{err:String(O)})),H0().then(async()=>{let{probeAcpVersion:O}=await Promise.resolve().then(()=>(Zt(),U0));for(let N of["claude-code","codex"]){let U=await O(N);U&&G.info("acp wrapper version",{framework:N,version:U})}}).catch(O=>G.warn("acp wrapper warmup / probe top-level error (ignored)",{err:String(O)}));let F=null,z={port:A,token:k,core:l,ipc:w,shutdown(O){return F||(G.info("daemon shutdown",{reason:O}),F=(async()=>{y?.stop(),await l.stop(O),await w.stop(),await t.release()})(),F)}};for(let O of["SIGTERM","SIGINT"])process.on(O,()=>{z.shutdown(O).then(()=>process.exit(0))});return process.on("unhandledRejection",O=>{G.error("unhandledRejection",{reason:O instanceof Error?O.message:String(O),stack:O instanceof Error?O.stack:void 0})}),process.on("uncaughtException",O=>{G.error("uncaughtException (will exit, supervisor will restart)",{message:O.message,stack:O.stack,name:O.name}),process.exit(1)}),G.info("daemon ready",{port:A,pid:process.pid,nodeVersion:process.version,platform:process.platform,frameworks:Object.keys(s.frameworksCache??{}),libVersion:s.libVersion??"dev"}),z}async function xb(t){let{readdir:e}=await import("node:fs/promises");try{return(await e(t.agentsRoot)).length>0}catch{return!1}}function So(t){return t.length<=8?"***":`${t.slice(0,4)}***${t.slice(-4)}`}function Ox(t,e,r){return`${t??""}|${e??""}|${r??""}`}async function hb(t,e){let{readdir:r}=await import("node:fs/promises"),s;try{s=await r(t.agentsRoot)}catch{return}let{loadAgentConfig:a,enforceAgentConfigMode:c}=await Promise.resolve().then(()=>(Yt(),ji));for(let f of s){await c(f,t).catch(l=>G.warn("enforceAgentConfigMode failed (ignored)",{agentId:f,err:String(l)}));try{let l=await a(f,t);l?.disconnectedAt&&(e.disconnectedAgents.add(f),G.info("agent marked disconnected on startup",{agentId:f,disconnectedAt:l.disconnectedAt,reason:l.disconnectReason??""}))}catch(l){G.warn("failed to load agent config on startup, skipping",{agentId:f,err:String(l)})}}}async function pb(t,e,r,s,a){let{loadAgentConfig:c}=await Promise.resolve().then(()=>(Yt(),ji)),f=await c(t,e);if(f){G.info("--agent-id: local config found, reconnecting",{agentId:t,framework:f.framework,hadDisconnect:!!f.disconnectedAt});let m={agentId:f.agentId,framework:f.framework,...f.cozeIdentity?{cozeIdentity:f.cozeIdentity}:{},...f.model?{model:f.model}:{},...a?{patToken:a}:{}};return await r.createAgent(m),{ok:!0,agentId:t,note:f.disconnectedAt?"revived from local config":"connected from local config"}}G.info("--agent-id: local config missing, pulling _agent/detail from cloud",{agentId:t});let l=await s({_meta:{cozeAgentId:t}});if(!l.framework)throw new D("AGENT_NOT_FOUND",`agent ${t} \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 x={agentId:l.agentId,framework:l.framework,...l.cozeIdentity?{cozeIdentity:l.cozeIdentity}:{},...l.model?{model:l.model}:{},...a?{patToken:a}:{},...l.deployType?{_meta:{cozeDeployType:l.deployType}}:{}};await r.createAgent(x);let h=l.deployType==="cloud"&&l.framework==="openclaw";return{ok:!0,agentId:t,note:h?"cloud agent acknowledged":"created from cloud detail"}}async function vo(t,e){let{readdir:r}=await import("node:fs/promises"),s;try{s=await r(t.agentsRoot)}catch{return{revived:0,skipped:0,total:0}}if(s.length===0)return{revived:0,skipped:0,total:0};let{loadAgentConfig:a}=await Promise.resolve().then(()=>(Yt(),ji));G.info("auto-revive: scanning local agents on startup",{count:s.length});let c=0,f=0;for(let l of s){let x;try{x=await a(l,t)}catch(h){G.warn("auto-revive: load config failed (skipping)",{agentId:l,err:String(h)}),f+=1;continue}if(!x){f+=1;continue}if(x.disconnectedAt){G.info("auto-revive: skip disconnected agent",{agentId:l,disconnectedAt:x.disconnectedAt}),f+=1;continue}try{G.info("auto-revive: re-registering agent (D44 no spawn)",{agentId:l,framework:x.framework});let h=gb(x);await e.createAgent({agentId:x.agentId,framework:x.framework,...x.cozeIdentity?{cozeIdentity:x.cozeIdentity}:{},...x.model?{model:x.model}:{},...h?{_meta:h}:{}}),c+=1}catch(h){G.warn("auto-revive: createAgent failed (skipping)",{agentId:l,framework:x.framework,err:String(h)}),f+=1}}return G.info("auto-revive: done",{revived:c,skipped:f,total:s.length}),{revived:c,skipped:f,total:s.length}}function gb(t){let e={};return t.deployType&&(e.cozeDeployType=t.deployType),t.accountId&&(e.cozeAccountId=t.accountId),Object.keys(e).length>0?e:void 0}Qc();Me();import{readFile as Lx}from"node:fs/promises";var jt=class{paths;constructor(e){this.paths=e??te()}async probe(e=1e3){let r=await Io(this.paths);if(!r)return{kind:"not-running"};try{let s=await this.fetch(r,{method:"GET",path:"/status",timeoutMs:e});return s.status===200?{kind:"connected",...r}:{kind:"stale",reason:`unexpected status ${s.status}`}}catch(s){return{kind:"stale",reason:vb(s)}}}async request(e){let r=await Io(this.paths);if(!r)throw new Error("coze-bridge daemon not running (no port/token files)");return this.fetch(r,e)}async fetch(e,r){let s=r.body!==void 0,a={Authorization:`Bearer ${e.token}`};s&&(a["content-type"]="application/json");let c=new AbortController,f=setTimeout(()=>c.abort(),r.timeoutMs??5e3);try{let l=await fetch(`http://127.0.0.1:${e.port}${r.path}`,{method:r.method,headers:a,body:s?JSON.stringify(r.body):void 0,signal:c.signal}),x=await l.text();return{status:l.status,body:Sb(x)}}finally{clearTimeout(f)}}};async function Io(t){try{let[e,r]=await Promise.all([Lx(t.portFile,"utf8"),Lx(t.tokenFile,"utf8")]),s=Number.parseInt(e.trim(),10),a=r.trim();return!Number.isFinite(s)||s<=0||!a?null:{port:s,token:a}}catch(e){if(e.code==="ENOENT")return null;throw e}}function Sb(t){if(!t)return null;try{return JSON.parse(t)}catch{return t}}function vb(t){return t instanceof Error?t.message:String(t)}ee();Me();import{copyFile as Nx,mkdir as Ib,readFile as e0,writeFile as Ab}from"node:fs/promises";import{homedir as s5}from"node:os";import{dirname as Cb,resolve as t0,sep as Ao}from"node:path";import{fileURLToPath as Tb}from"node:url";ee();Me();var Mx=H("dist-install");function Db(t){let e=Tb(t),r=Cb(e),s=`${Ao}src${Ao}`;if(r.includes(s)||r.endsWith(`${Ao}src${Ao}cli`))return null;let a=t0(r,"index.js"),c=t0(r,"..","package.json");return{dist:a,pkgJson:c}}async function n0(t={}){let e=t.paths??te(),r=Db(import.meta.url),s=t.sourceDist??r?.dist,a=t.sourcePackageJson??r?.pkgJson;if(!s||!a)return{kind:"dev-mode-skip",reason:"running from src/(tsx loader);no dist/ to install"};let c;try{c=JSON.parse(await e0(a,"utf8")).version??"unknown"}catch(E){return Mx.warn("cannot read source package.json,skip dist install",{err:String(E)}),{kind:"dev-mode-skip",reason:`package.json read failed: ${String(E)}`}}let f=await Js(e.configFile)??{},l=f.libVersion;if(l===c)try{return await e0(e.libEntry),{kind:"already-current",libVersion:c}}catch{}await Ib(e.libDir,{recursive:!0}),await Nx(s,e.libEntry),await Nx(`${s}.map`,`${e.libEntry}.map`).catch(()=>{});let x=t0(e.libDir,"package.json"),h=`${JSON.stringify({type:"module"},null,2)}
93
- `;return await e0(x,"utf8").catch(()=>null)!==h&&await Ab(x,h),f.libVersion=c,await Er(f,e.configFile),Mx.info("dist installed",{libEntry:e.libEntry,fromVersion:l,toVersion:c}),l?{kind:"version-changed",fromVersion:l,toVersion:c,libEntry:e.libEntry}:{kind:"first-install",libVersion:c,libEntry:e.libEntry}}import{basename as Rb,resolve as kb}from"node:path";Me();var Ob=9e4,Pb={PATH_OUTSIDE_WORKSPACE:3,FILE_TOO_LARGE:3,UNSUPPORTED_MIME:3,MODEL_MODALITY_UNSUPPORTED:3,IPC_BAD_REQUEST:3,AGENT_NOT_FOUND:4,IPC_AUTH_FAILED:4,AGENT_DISCONNECTED:5,UPLOAD_FAILED:5,UPSTREAM_NOT_READY:5,UPSTREAM_DISCONNECTED:5,UPSTREAM_HANDSHAKE_FAILED:5,AGENT_BUSY:1,AGENT_SPAWN_FAILED:1,AGENT_TIMEOUT:1,AGENT_FRAME_IDLE_TIMEOUT:1,AGENT_PROTOCOL_ERROR:1,BRIDGE_CONFIG_INVALID:1,BRIDGE_INTERNAL:1,MODEL_TOKEN_GEN_FAILED:1,OPERATION_NOT_ALLOWED_FOR_LOCAL:1,NPX_CACHE_CORRUPT:1};function Lb(t){return Pb[t]??1}async function Bx(t,e={}){let r=e.paths??te();if(!t.agentId||!t.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>
92
+ `}async function Ix(t,e=te()){let r=e.binDir;await bo.mkdir(r,{recursive:!0});let i=W1(r,process.platform==="win32"?"coze-bridge.cmd":"coze-bridge"),o=process.execPath,c=process.platform==="win32"?$1(t,o):V1(t,o);return await bo.readFile(i,"utf8").catch(()=>null)===c||(await bo.writeFile(i,c,"utf8"),process.platform!=="win32"&&await bo.chmod(i,493)),r}ee();Me();import{execSync as Tx}from"node:child_process";import{readFileSync as Cx,unlinkSync as J1}from"node:fs";import{mkdir as Y1,readFile as Rx,unlink as Dx,writeFile as Z1}from"node:fs/promises";import{dirname as X1}from"node:path";function Ax(t){try{return process.kill(t,0),!0}catch(e){return e.code==="EPERM"}}var Q1=G("single-instance"),Eo=class{pidFile;acquired=!1;constructor(e={}){this.pidFile=e.pidFile??te().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&&(Q1.warn("removing stale pid file",{stalePid:e}),await Dx(this.pidFile).catch(()=>{})),await Y1(X1(this.pidFile),{recursive:!0}),await Z1(this.pidFile,String(process.pid),"utf8"),this.acquired=!0,this.installCleanupHooks(),{kind:"acquired"})}async release(){if(this.acquired){try{(await Rx(this.pidFile,"utf8")).trim()===String(process.pid)&&await Dx(this.pidFile)}catch{}this.acquired=!1}}async readExistingPid(){try{let e=await Rx(this.pidFile,"utf8"),r=Number.parseInt(e.trim(),10);return Number.isFinite(r)&&r>0?r:null}catch(e){if(e.code==="ENOENT")return null;throw e}}isAlive(e){return Ax(e)?this.matchesDaemonTitle(e):!1}matchesDaemonTitle(e){if(process.platform==="win32")return this.matchesDaemonTitleWindows(e);try{let r=Cx(`/proc/${e}/cmdline`,"utf8").replace(/\0/g," ");return!!(r.includes("coze-bridge-daemon")||r.includes("lib/index.js"))}catch{}try{let r=Tx(`ps -o command= -p ${e}`,{stdio:["ignore","pipe","ignore"],timeout:1e3}).toString();return r.trim()?r.includes("coze-bridge-daemon")||r.includes("lib/index.js"):!1}catch{return!0}}matchesDaemonTitleWindows(e){try{let i=Tx(`tasklist /FI "PID eq ${e}" /FO CSV /NH`,{stdio:["ignore","pipe","ignore"],timeout:2e3}).toString().trim();if(!i||/^(INFO|信息)[::]/.test(i))return!1;let o=i.split(",",1)[0]?.replace(/^"|"$/g,"").toLowerCase()??"";return o.includes("node")||o.includes("coze-bridge")}catch{return!0}}installCleanupHooks(){process.once("exit",()=>{if(this.acquired)try{Cx(this.pidFile,"utf8").trim()===String(process.pid)&&J1(this.pidFile)}catch{}})}};var W=G("daemon"),eb="coze-bridge-daemon";async function Lx(){let t=new Eo({processTitle:eb}),e=await t.acquire();if(e.kind==="already-running")throw new Error(`coze-bridge daemon already running (pid=${e.pid})`);let r=await Js(),i=r??{};Oi({pid:process.pid}),W.info(r?"loaded bridge config":"initialized bridge config");try{let P=new ln;i.frameworksCache=await P.detectAll(),W.info("refreshed frameworks_cache",{detected:Object.keys(i.frameworksCache)})}catch(P){W.warn("framework detection failed",{err:String(P)})}await _r(i);let o=new yo(new Cr),c=te(),f=null,l=new Ys({upstream:o,paths:c,bridgeConfig:i,sessionSpawner:async(P,N,U,$)=>{if(!f)throw new Error("agentManager not ready");return f.spawnSessionDownstream(P,N,U,$)}});await nb(c,l);let x=new Ws({paths:c,config:i,registry:l});f=x;let p,w,b=null,T={},E,v=null;l.registerExtension("_agent/create",async P=>x.createAgent(P.params)),l.registerExtension("_agent/health",async()=>({ok:!0}));let I={},A=new Bs({agents:l.agents,disposeAndMarkDisconnected:async(P,N)=>{let U=l.agents.get(P);if(U){await x.cleanupOpenclawSessionProviders(U).catch(se=>W.warn("cleanup openclaw providers failed (ignored)",{agentId:P,err:String(se)}));let $=!0;try{await U.dispose(`disconnect: ${N}`)}catch(se){$=!1,W.error("dispose during disconnect FAILED, leaving agent in error state",{agentId:P,err:String(se)}),U.status="error"}$&&(U.status="disconnected",l.unregister(P),l.disconnectedAgents.add(P))}else l.disconnectedAgents.add(P)},detailSyncer:async P=>{if(!I.ref)throw new Error("agent-detail-sync not initialized yet");await I.ref.syncOne(P)},cleanupOpenclawProviders:async P=>{await x.cleanupOpenclawSessionProviders(P)},openclawRepair:async(P,N)=>{await x.openclawRepair(P,N)},isRuntimePendingPermission:P=>l.hasPendingPermissionFor(P)});l.registerExtension("_agent/listSkills",P=>A.listSkills(P.params)),l.registerExtension("_agent/addSkills",P=>A.addSkills(P.params)),l.registerExtension("_agent/removeSkills",P=>A.removeSkills(P.params)),l.registerExtension("_agent/getFileTree",P=>A.getFileTree(P.params)),l.registerExtension("_agent/getFileContent",P=>A.getFileContent(P.params)),l.registerExtension("_agent/update",P=>A.updateAgent(P.params)),l.registerExtension("_agent/disconnect",P=>A.disconnectAgent(P.params)),l.registerExtension("_agent/switchModel",P=>A.switchModel(P.params)),l.registerExtension("_agent/reset",P=>A.resetAgent(P.params)),l.registerExtension("_agent/repair",P=>A.repairAgent(P.params));let k=new ji({paths:c,handlers:A,sendDetail:P=>l.sendRequest("_agent/detail",P)});I.ref=k;let O=async P=>{await Promise.allSettled(P.map(async N=>{try{await A.disconnectAgent({agentId:N.agentId,reason:`auth_failure: code=${N.code} ${N.message}`}),W.info("agent disconnected due to auth failure from heartbeat response",{agentId:N.agentId,code:N.code,message:N.message})}catch(U){W.warn("disconnect during authFailure handling failed (ignored)",{agentId:N.agentId,err:String(U)})}}))};o.onConnect(({initial:P})=>{W.info("frontier upstream connected, triggering detail sync",{initial:P}),k.syncAll(P?"initial-connect":"reconnect").catch(N=>W.warn("detail sync top-level error (ignored)",{err:String(N)}))});let y=new Zs({paths:c,routes:[{method:"GET",path:"/status",handler:async()=>{let P=l.getMockScenario();return{running:!0,pid:process.pid,agents:[...l.agents.keys()],deviceId:b??"",frameworksCache:i.frameworksCache??{},...P?{mockScenario:P}:{}}}},{method:"POST",path:"/pair",handler:async P=>{let N=P,U=N?.privatecode,$=N?.pairing_code;if(!U||!$)throw new D("IPC_BAD_REQUEST","/pair requires privatecode + pairing_code");let se=ci(N.env),fe=N.handshake_url,we=N.frontier_url,Oe=kx(N.env,fe,we),at=!!p&&p!==U,Ae=w!==void 0&&w!==Oe,Gt=at||Ae,_e=await oc({privatecode:U,...fe?{endpoint:fe}:{},ppeOverride:se});if(Gt){W.warn("pair config switched, resetting agents",{pcChanged:at,envChanged:Ae,previousPc:p?vo(p):"",nextPc:vo(U),previousEnvKey:w??"",nextEnvKey:Oe});for(let ge of[...l.agents.values()])await ge.dispose("pair config switch").catch(()=>{}),l.agents.delete(ge.agentId);l.disconnectedAgents.size>0&&(W.info("clearing disconnectedAgents set on pair config switch",{count:l.disconnectedAgents.size}),l.disconnectedAgents.clear()),await o.swap(new Cr,"pair switch").catch(()=>{})}b=_e.deviceId,Oi({deviceId:b,pid:process.pid}),bc({patToken:U,env:N.env}).catch(ge=>W.warn("coze-cli setup error (ignored)",{err:String(ge)}));let Z=new Ti({handshake:_e,privatecode:U,...we?{urlOverride:we}:{},ppeOverride:se,getPatTokenForAgent:ge=>l.agents.get(ge)?.patToken});await o.swap(Z,"pair");try{let ge=new ln;i.frameworksCache=await ge.detectAll(),await _r(i),W.info("frameworks_cache refreshed before pair",{detected:Object.keys(i.frameworksCache)})}catch(ge){W.warn("frameworks_cache refresh failed (ignored, using cached)",{err:String(ge)})}let Mn=Object.keys(i.frameworksCache??{});try{let ge=await l.sendRequest("_agent/pair",{pairCode:$,patToken:U,frameworks:Mn,_meta:{cozeDeviceId:b}});W.info("_agent/pair ok",{pairResult:ge}),p=U,w=Oe,T=se,E=fe,N.mock_scenario!==void 0&&(l.setMockScenario(N.mock_scenario),W.info("mock scenario set",{scenario:N.mock_scenario})),Ci(U,c).catch(je=>W.warn("writePatToken after /pair failed (ignored)",{err:String(je)})),v||(v=new fi({core:l,getDeviceId:()=>b??"",onTickEnd:()=>k.retryPending().catch(je=>W.warn("detailSync.retryPending failed (ignored)",{err:String(je)})),onAuthFailures:O})),v.start(),Gt&&So(c,x).catch(je=>W.warn("post-pair-switch auto-revive error (ignored)",{err:String(je)}));let Bn;return N.agent_id&&(Bn=await rb(N.agent_id,c,x,je=>l.sendRequest("_agent/detail",je),U).catch(je=>(W.error("--agent-id ensureAgent failed",{agentId:N.agent_id,err:String(je)}),{ok:!1,agentId:N.agent_id??"",note:String(je)}))),{ok:!0,note:"paired with cloud",...Bn?{agent:Bn}:{}}}catch(ge){return W.error("_agent/pair failed",{err:String(ge)}),{ok:!1,note:`pair failed: ${String(ge)}`}}}},{method:"POST",path:"/connect",handler:async P=>{let N=P,U=N?.privatecode;if(!U)throw new D("IPC_BAD_REQUEST","/connect requires privatecode");let $=ci(N.env),se=N.handshake_url,fe=N.frontier_url,we=kx(N.env,se,fe);if(p===U&&w===we){let Z=await tb(c);return l.agents.size===0&&Z?(W.warn("/connect noop but core.agents empty with configs on disk; re-running auto-revive"),So(c,x).catch(Mn=>W.warn("connect-noop auto-revive error (ignored)",{err:String(Mn)}))):W.info("/connect: already connected with same PAT + env, noop"),{ok:!0,note:"already connected"}}let Oe=!!p&&p!==U,at=w!==void 0&&w!==we,Ae=Oe||at,Gt=await oc({privatecode:U,...se?{endpoint:se}:{},ppeOverride:$});if(Ae){W.warn("connect config switched, resetting agents",{pcChanged:Oe,envChanged:at,previousPc:p?vo(p):"",nextPc:vo(U)});for(let Z of[...l.agents.values()])await Z.dispose("connect config switch").catch(()=>{}),l.agents.delete(Z.agentId);l.disconnectedAgents.size>0&&(W.info("clearing disconnectedAgents set on connect config switch",{count:l.disconnectedAgents.size}),l.disconnectedAgents.clear()),await o.swap(new Cr,"connect switch").catch(()=>{})}b=Gt.deviceId,Oi({deviceId:b,pid:process.pid}),bc({patToken:U,env:N.env}).catch(Z=>W.warn("coze-cli setup error (ignored)",{err:String(Z)}));let _e=new Ti({handshake:Gt,privatecode:U,...fe?{urlOverride:fe}:{},ppeOverride:$,getPatTokenForAgent:Z=>l.agents.get(Z)?.patToken});return await o.swap(_e,"connect"),p=U,w=we,T=$,E=se,N.mock_scenario!==void 0&&(l.setMockScenario(N.mock_scenario),W.info("mock scenario set",{scenario:N.mock_scenario})),v||(v=new fi({core:l,getDeviceId:()=>b??"",onTickEnd:()=>k.retryPending().catch(Z=>W.warn("detailSync.retryPending failed (ignored)",{err:String(Z)})),onAuthFailures:O})),v.start(),Ae&&So(c,x).catch(Z=>W.warn("post-connect-switch auto-revive error (ignored)",{err:String(Z)})),Ci(U,c).catch(Z=>W.warn("writePatToken after /connect failed (ignored)",{err:String(Z)})),W.info("/connect: WS established",{deviceId:b}),{ok:!0,note:"connected"}}},{method:"POST",path:"/_agent/create",handler:async P=>{let N=P;return{ok:!0,result:await x.createAgent(N)}}},{method:"POST",path:"/agent/send",handler:async P=>{let N=P;if(!N?.agentId||!N?.sessionId||!N?.kind||!N?.path)throw new D("IPC_BAD_REQUEST","/agent/send requires agentId, sessionId, kind, path");if(!p)throw new D("UPSTREAM_NOT_READY","daemon not yet paired with cloud (run --pair-code first)");try{let U=N;return await(U.groupFile?zu:Bu)(U,{core:l,patToken:p,handshakeBase:E,ppeOverride:T})}catch(U){if(U instanceof D)return{ok:!1,code:U.code,message:U.message};throw U}}},{method:"POST",path:"/refresh",handler:async()=>{W.info("IPC /refresh: re-detecting frameworks");let P=new ln;return i.frameworksCache=await P.detectAll(),await _r(i),{ok:!0,frameworks:i.frameworksCache}}},{method:"POST",path:"/shutdown",handler:async()=>(W.info("IPC /shutdown received"),setImmediate(()=>{z.shutdown("ipc /shutdown")}),{ok:!0})}]}),{port:C,token:L}=await y.start();try{await Ix(c.libEntry,c)}catch(P){W.warn("bin shim install failed (D72 send \u547D\u4EE4\u53EF\u80FD\u4E0D\u53EF\u7528)",{err:String(P)})}await l.start(),So(c,x).catch(P=>W.warn("auto-revive top-level error (ignored)",{err:String(P)})),q0().then(async()=>{let{probeAcpVersion:P}=await Promise.resolve().then(()=>(gn(),F0));for(let N of["claude-code","codex"]){let U=await P(N);U&&W.info("acp wrapper version",{framework:N,version:U})}}).catch(P=>W.warn("acp wrapper warmup / probe top-level error (ignored)",{err:String(P)}));let F=null,z={port:C,token:L,core:l,ipc:y,shutdown(P){return F||(W.info("daemon shutdown",{reason:P}),F=(async()=>{v?.stop(),await l.stop(P),await y.stop(),await t.release()})(),F)}};for(let P of["SIGTERM","SIGINT"])process.on(P,()=>{z.shutdown(P).then(()=>process.exit(0))});return process.on("unhandledRejection",P=>{W.error("unhandledRejection",{reason:P instanceof Error?P.message:String(P),stack:P instanceof Error?P.stack:void 0})}),process.on("uncaughtException",P=>{W.error("uncaughtException (will exit, supervisor will restart)",{message:P.message,stack:P.stack,name:P.name}),process.exit(1)}),W.info("daemon ready",{port:C,pid:process.pid,nodeVersion:process.version,platform:process.platform,frameworks:Object.keys(i.frameworksCache??{}),libVersion:i.libVersion??"dev"}),z}async function tb(t){let{readdir:e}=await import("node:fs/promises");try{return(await e(t.agentsRoot)).length>0}catch{return!1}}function vo(t){return t.length<=8?"***":`${t.slice(0,4)}***${t.slice(-4)}`}function kx(t,e,r){return`${t??""}|${e??""}|${r??""}`}async function nb(t,e){let{readdir:r}=await import("node:fs/promises"),i;try{i=await r(t.agentsRoot)}catch{return}let{loadAgentConfig:o,enforceAgentConfigMode:c}=await Promise.resolve().then(()=>($t(),Gi));for(let f of i){await c(f,t).catch(l=>W.warn("enforceAgentConfigMode failed (ignored)",{agentId:f,err:String(l)}));try{let l=await o(f,t);l?.disconnectedAt&&(e.disconnectedAgents.add(f),W.info("agent marked disconnected on startup",{agentId:f,disconnectedAt:l.disconnectedAt,reason:l.disconnectReason??""}))}catch(l){W.warn("failed to load agent config on startup, skipping",{agentId:f,err:String(l)})}}}async function rb(t,e,r,i,o){let{loadAgentConfig:c}=await Promise.resolve().then(()=>($t(),Gi)),f=await c(t,e);if(f){W.info("--agent-id: local config found, reconnecting",{agentId:t,framework:f.framework,hadDisconnect:!!f.disconnectedAt});let w={agentId:f.agentId,framework:f.framework,...f.cozeIdentity?{cozeIdentity:f.cozeIdentity}:{},...f.model?{model:f.model}:{},...o?{patToken:o}:{}};return await r.createAgent(w),{ok:!0,agentId:t,note:f.disconnectedAt?"revived from local config":"connected from local config"}}W.info("--agent-id: local config missing, pulling _agent/detail from cloud",{agentId:t});let l=await i({_meta:{cozeAgentId:t}});if(!l.framework)throw new D("AGENT_NOT_FOUND",`agent ${t} \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 x={agentId:l.agentId,framework:l.framework,...l.cozeIdentity?{cozeIdentity:l.cozeIdentity}:{},...l.model?{model:l.model}:{},...o?{patToken:o}:{},...l.deployType?{_meta:{cozeDeployType:l.deployType}}:{}};await r.createAgent(x);let p=l.deployType==="cloud"&&l.framework==="openclaw";return{ok:!0,agentId:t,note:p?"cloud agent acknowledged":"created from cloud detail"}}async function So(t,e){let{readdir:r}=await import("node:fs/promises"),i;try{i=await r(t.agentsRoot)}catch{return{revived:0,skipped:0,total:0}}if(i.length===0)return{revived:0,skipped:0,total:0};let{loadAgentConfig:o}=await Promise.resolve().then(()=>($t(),Gi));W.info("auto-revive: scanning local agents on startup",{count:i.length});let c=0,f=0;for(let l of i){let x;try{x=await o(l,t)}catch(p){W.warn("auto-revive: load config failed (skipping)",{agentId:l,err:String(p)}),f+=1;continue}if(!x){f+=1;continue}if(x.disconnectedAt){W.info("auto-revive: skip disconnected agent",{agentId:l,disconnectedAt:x.disconnectedAt}),f+=1;continue}try{W.info("auto-revive: re-registering agent (D44 no spawn)",{agentId:l,framework:x.framework});let p=ib(x);await e.createAgent({agentId:x.agentId,framework:x.framework,...x.cozeIdentity?{cozeIdentity:x.cozeIdentity}:{},...x.model?{model:x.model}:{},...p?{_meta:p}:{}}),c+=1}catch(p){W.warn("auto-revive: createAgent failed (skipping)",{agentId:l,framework:x.framework,err:String(p)}),f+=1}}return W.info("auto-revive: done",{revived:c,skipped:f,total:i.length}),{revived:c,skipped:f,total:i.length}}function ib(t){let e={};return t.deployType&&(e.cozeDeployType=t.deployType),t.accountId&&(e.cozeAccountId=t.accountId),Object.keys(e).length>0?e:void 0}Xc();Me();import{readFile as Px}from"node:fs/promises";var Ht=class{paths;constructor(e){this.paths=e??te()}async probe(e=1e3){let r=await Io(this.paths);if(!r)return{kind:"not-running"};try{let i=await this.fetch(r,{method:"GET",path:"/status",timeoutMs:e});return i.status===200?{kind:"connected",...r}:{kind:"stale",reason:`unexpected status ${i.status}`}}catch(i){return{kind:"stale",reason:lb(i)}}}async request(e){let r=await Io(this.paths);if(!r)throw new Error("coze-bridge daemon not running (no port/token files)");return this.fetch(r,e)}async fetch(e,r){let i=r.body!==void 0,o={Authorization:`Bearer ${e.token}`};i&&(o["content-type"]="application/json");let c=new AbortController,f=setTimeout(()=>c.abort(),r.timeoutMs??5e3);try{let l=await fetch(`http://127.0.0.1:${e.port}${r.path}`,{method:r.method,headers:o,body:i?JSON.stringify(r.body):void 0,signal:c.signal}),x=await l.text();return{status:l.status,body:ub(x)}}finally{clearTimeout(f)}}};async function Io(t){try{let[e,r]=await Promise.all([Px(t.portFile,"utf8"),Px(t.tokenFile,"utf8")]),i=Number.parseInt(e.trim(),10),o=r.trim();return!Number.isFinite(i)||i<=0||!o?null:{port:i,token:o}}catch(e){if(e.code==="ENOENT")return null;throw e}}function ub(t){if(!t)return null;try{return JSON.parse(t)}catch{return t}}function lb(t){return t instanceof Error?t.message:String(t)}ee();Me();import{copyFile as Ox,mkdir as xb,readFile as Qc,writeFile as hb}from"node:fs/promises";import{homedir as KA}from"node:os";import{dirname as pb,resolve as e0,sep as Ao}from"node:path";import{fileURLToPath as gb}from"node:url";ee();Me();var Nx=G("dist-install");function mb(t){let e=gb(t),r=pb(e),i=`${Ao}src${Ao}`;if(r.includes(i)||r.endsWith(`${Ao}src${Ao}cli`))return null;let o=e0(r,"index.js"),c=e0(r,"..","package.json");return{dist:o,pkgJson:c}}async function t0(t={}){let e=t.paths??te(),r=mb(import.meta.url),i=t.sourceDist??r?.dist,o=t.sourcePackageJson??r?.pkgJson;if(!i||!o)return{kind:"dev-mode-skip",reason:"running from src/(tsx loader);no dist/ to install"};let c;try{c=JSON.parse(await Qc(o,"utf8")).version??"unknown"}catch(b){return Nx.warn("cannot read source package.json,skip dist install",{err:String(b)}),{kind:"dev-mode-skip",reason:`package.json read failed: ${String(b)}`}}let f=await Js(e.configFile)??{},l=f.libVersion;if(l===c)try{return await Qc(e.libEntry),{kind:"already-current",libVersion:c}}catch{}await xb(e.libDir,{recursive:!0}),await Ox(i,e.libEntry),await Ox(`${i}.map`,`${e.libEntry}.map`).catch(()=>{});let x=e0(e.libDir,"package.json"),p=`${JSON.stringify({type:"module"},null,2)}
93
+ `;return await Qc(x,"utf8").catch(()=>null)!==p&&await hb(x,p),f.libVersion=c,await _r(f,e.configFile),Nx.info("dist installed",{libEntry:e.libEntry,fromVersion:l,toVersion:c}),l?{kind:"version-changed",fromVersion:l,toVersion:c,libEntry:e.libEntry}:{kind:"first-install",libVersion:c,libEntry:e.libEntry}}import{basename as wb,resolve as _b}from"node:path";Me();var yb=9e4,bb={PATH_OUTSIDE_WORKSPACE:3,FILE_TOO_LARGE:3,UNSUPPORTED_MIME:3,MODEL_MODALITY_UNSUPPORTED:3,IPC_BAD_REQUEST:3,AGENT_NOT_FOUND:4,IPC_AUTH_FAILED:4,AGENT_DISCONNECTED:5,UPLOAD_FAILED:5,UPSTREAM_NOT_READY:5,UPSTREAM_DISCONNECTED:5,UPSTREAM_HANDSHAKE_FAILED:5,AGENT_BUSY:1,AGENT_SPAWN_FAILED:1,AGENT_TIMEOUT:1,AGENT_FRAME_IDLE_TIMEOUT:1,AGENT_PROTOCOL_ERROR:1,BRIDGE_CONFIG_INVALID:1,BRIDGE_INTERNAL:1,MODEL_TOKEN_GEN_FAILED:1,OPERATION_NOT_ALLOWED_FOR_LOCAL:1,AGENT_DEPENDENCY_INSTALL_FAILED:1};function Eb(t){return bb[t]??1}async function Mx(t,e={}){let r=e.paths??te();if(!t.agentId||!t.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>
94
94
  `),4;if(t.groupFile&&!t.mimeType)return process.stderr.write(`Error: --group-file requires --mime <mimeType> (e.g. application/pdf, image/png). No local file is read in group-file mode, mime cannot be auto-detected.
95
- `),3;let s=await Io(r).catch(()=>null);if(!s)return process.stderr.write(`Error: coze-bridge daemon not running (cannot read ${r.portFile} / ${r.tokenFile}). Make sure you are inside an agent session spawned by the daemon.
96
- `),4;let a={agentId:t.agentId,sessionId:t.sessionId,kind:t.kind,path:t.groupFile?t.path:kb(process.cwd(),t.path),...t.caption?{caption:t.caption}:{},...t.name?{name:t.name}:{},...t.groupFile?{groupFile:!0}:{},...t.mimeType?{mimeType:t.mimeType}:{}},c;try{c=await Nb(s,"/agent/send",a,Ob)}catch(f){return process.stderr.write(`Error: daemon IPC failed: ${f instanceof Error?f.message:String(f)}
95
+ `),3;let i=await Io(r).catch(()=>null);if(!i)return process.stderr.write(`Error: coze-bridge daemon not running (cannot read ${r.portFile} / ${r.tokenFile}). Make sure you are inside an agent session spawned by the daemon.
96
+ `),4;let o={agentId:t.agentId,sessionId:t.sessionId,kind:t.kind,path:t.groupFile?t.path:_b(process.cwd(),t.path),...t.caption?{caption:t.caption}:{},...t.name?{name:t.name}:{},...t.groupFile?{groupFile:!0}:{},...t.mimeType?{mimeType:t.mimeType}:{}},c;try{c=await vb(i,"/agent/send",o,yb)}catch(f){return process.stderr.write(`Error: daemon IPC failed: ${f instanceof Error?f.message:String(f)}
97
97
  `),4}if(!c.ok)return process.stderr.write(`Error: ${c.code}: ${c.message}
98
- `),Lb(c.code);if(t.json)process.stdout.write(`${JSON.stringify(c)}
99
- `);else{let f=t.name??Rb(a.path);if(t.groupFile){let l=c.uri.length>60?`${c.uri.slice(0,57)}...`:c.uri;process.stdout.write(`Sent group file ${f} (uri=${l})
100
- `)}else process.stdout.write(`Sent ${t.kind} ${f} (${Mb(c.bytes)})
101
- `)}return 0}async function Nb(t,e,r,s){let a=new AbortController,c=setTimeout(()=>a.abort(),s);try{let f=await fetch(`http://127.0.0.1:${t.port}${e}`,{method:"POST",headers:{Authorization:`Bearer ${t.token}`,"content-type":"application/json"},body:JSON.stringify(r),signal:a.signal}),l=await f.text(),x=l?JSON.parse(l):null;return x&&typeof x=="object"&&"ok"in x?x:{ok:!1,code:"BRIDGE_INTERNAL",message:`unexpected daemon response (status=${f.status}): ${l.slice(0,200)}`}}finally{clearTimeout(c)}}function Mb(t){return t<1024?`${t}B`:t<1024*1024?`${(t/1024).toFixed(1)}KB`:`${(t/1024/1024).toFixed(1)}MB`}var Kx=H("cli");function ze(t,e){let r=[],s;for(let a=0;a<t.length;a++){let c=t[a];if(c===e){s=t[a+1],a+=1;continue}if(c.startsWith(`${e}=`)){s=c.slice(e.length+1);continue}r.push(c)}return{value:s,rest:r}}function ki(t,e){process.stderr.write(`[deprecated] '${t}' will be removed in a future release, use '${e}' instead
102
- `)}function t2(t){let e=t.slice(2);if(e.includes("--version")||e.includes("-v"))return{mode:"version"};if(e.includes("--daemon"))return{mode:"daemon"};if(e[0]==="status")return{mode:"status"};if(e[0]==="stop")return{mode:"stop"};if(e[0]==="refresh")return{mode:"refresh"};if(e[0]==="purge")return{mode:"purge"};if(e[0]==="service")return e[1]==="install"?{mode:"service-install"}:e[1]==="uninstall"?{mode:"service-uninstall"}:{mode:"help"};if(e[0]==="send")return n2(e.slice(1));if(e[0]==="connect")return r2(e.slice(1));if(e.includes("--status"))return ki("--status","coze-bridge status"),{mode:"status"};if(e.includes("--stop"))return ki("--stop","coze-bridge stop"),{mode:"stop"};if(e.includes("--refresh"))return ki("--refresh","coze-bridge refresh"),{mode:"refresh"};if(e.includes("--uninstall"))return ki("--uninstall","coze-bridge purge"),{mode:"purge"};if(e.includes("--install-service"))return ki("--install-service","coze-bridge service install"),{mode:"service-install"};if(e.includes("--help")||e.includes("-h")||e.length===0)return{mode:"help"};let r=e,{value:s,rest:a}=ze(r,"--pat-token");r=a;let{value:c,rest:f}=ze(r,"--pair-code");r=f;let{value:l,rest:x}=ze(r,"--env");r=x;let{value:h,rest:m}=ze(r,"--handshake-url");r=m;let{value:E,rest:C}=ze(r,"--frontier-url");r=C;let{value:_,rest:y}=ze(r,"--mock-scenario");r=y;let{value:v}=ze(r,"--agent-id");if(!s||!c)return{mode:"help"};let I={mode:"pair",privatecode:s,pairingCode:c};return l&&(I.env=l),h&&(I.handshakeUrl=h),E&&(I.frontierUrl=E),_&&(I.mockScenario=_),v&&(I.agentId=v),I}function n2(t){let e=t[0],r=t[1];if(e!=="image"&&e!=="file")return{mode:"help"};if(!r||r.startsWith("--"))return{mode:"help"};let s=t.slice(2),{value:a,rest:c}=ze(s,"--caption");s=c;let{value:f,rest:l}=ze(s,"--name");s=l;let{value:x,rest:h}=ze(s,"--agent-id");s=h;let{value:m,rest:E}=ze(s,"--session-id");s=E;let{value:C,rest:_}=ze(s,"--mime");s=_;let y=s.includes("--group-file");s=s.filter(R=>R!=="--group-file");let v=s.includes("--json"),I={mode:"send",kind:e,path:r,json:v};return a&&(I.caption=a),f&&(I.name=f),x&&(I.agentId=x),m&&(I.sessionId=m),y&&(I.groupFile=!0),C&&(I.mimeType=C),I}function r2(t){let e=t,{value:r,rest:s}=ze(e,"--pat-token");e=s;let{value:a,rest:c}=ze(e,"--env");e=c;let{value:f,rest:l}=ze(e,"--handshake-url");e=l;let{value:x,rest:h}=ze(e,"--frontier-url");e=h;let{value:m,rest:E}=ze(e,"--mock-scenario");e=E;let C={mode:"connect"};return r&&(C.privatecode=r),a&&(C.env=a),f&&(C.handshakeUrl=f),x&&(C.frontierUrl=x),m&&(C.mockScenario=m),C}var i2=`
98
+ `),Eb(c.code);if(t.json)process.stdout.write(`${JSON.stringify(c)}
99
+ `);else{let f=t.name??wb(o.path);if(t.groupFile){let l=c.uri.length>60?`${c.uri.slice(0,57)}...`:c.uri;process.stdout.write(`Sent group file ${f} (uri=${l})
100
+ `)}else process.stdout.write(`Sent ${t.kind} ${f} (${Sb(c.bytes)})
101
+ `)}return 0}async function vb(t,e,r,i){let o=new AbortController,c=setTimeout(()=>o.abort(),i);try{let f=await fetch(`http://127.0.0.1:${t.port}${e}`,{method:"POST",headers:{Authorization:`Bearer ${t.token}`,"content-type":"application/json"},body:JSON.stringify(r),signal:o.signal}),l=await f.text(),x=l?JSON.parse(l):null;return x&&typeof x=="object"&&"ok"in x?x:{ok:!1,code:"BRIDGE_INTERNAL",message:`unexpected daemon response (status=${f.status}): ${l.slice(0,200)}`}}finally{clearTimeout(c)}}function Sb(t){return t<1024?`${t}B`:t<1024*1024?`${(t/1024).toFixed(1)}KB`:`${(t/1024/1024).toFixed(1)}MB`}var jx=G("cli");function ze(t,e){let r=[],i;for(let o=0;o<t.length;o++){let c=t[o];if(c===e){i=t[o+1],o+=1;continue}if(c.startsWith(`${e}=`)){i=c.slice(e.length+1);continue}r.push(c)}return{value:i,rest:r}}function Ri(t,e){process.stderr.write(`[deprecated] '${t}' will be removed in a future release, use '${e}' instead
102
+ `)}function Gb(t){let e=t.slice(2);if(e.includes("--version")||e.includes("-v"))return{mode:"version"};if(e.includes("--daemon"))return{mode:"daemon"};if(e[0]==="status")return{mode:"status"};if(e[0]==="stop")return{mode:"stop"};if(e[0]==="refresh")return{mode:"refresh"};if(e[0]==="purge")return{mode:"purge"};if(e[0]==="service")return e[1]==="install"?{mode:"service-install"}:e[1]==="uninstall"?{mode:"service-uninstall"}:{mode:"help"};if(e[0]==="send")return jb(e.slice(1));if(e[0]==="connect")return Kb(e.slice(1));if(e.includes("--status"))return Ri("--status","coze-bridge status"),{mode:"status"};if(e.includes("--stop"))return Ri("--stop","coze-bridge stop"),{mode:"stop"};if(e.includes("--refresh"))return Ri("--refresh","coze-bridge refresh"),{mode:"refresh"};if(e.includes("--uninstall"))return Ri("--uninstall","coze-bridge purge"),{mode:"purge"};if(e.includes("--install-service"))return Ri("--install-service","coze-bridge service install"),{mode:"service-install"};if(e.includes("--help")||e.includes("-h")||e.length===0)return{mode:"help"};let r=e,{value:i,rest:o}=ze(r,"--pat-token");r=o;let{value:c,rest:f}=ze(r,"--pair-code");r=f;let{value:l,rest:x}=ze(r,"--env");r=x;let{value:p,rest:w}=ze(r,"--handshake-url");r=w;let{value:b,rest:T}=ze(r,"--frontier-url");r=T;let{value:E,rest:v}=ze(r,"--mock-scenario");r=v;let{value:I}=ze(r,"--agent-id");if(!i||!c)return{mode:"help"};let A={mode:"pair",privatecode:i,pairingCode:c};return l&&(A.env=l),p&&(A.handshakeUrl=p),b&&(A.frontierUrl=b),E&&(A.mockScenario=E),I&&(A.agentId=I),A}function jb(t){let e=t[0],r=t[1];if(e!=="image"&&e!=="file")return{mode:"help"};if(!r||r.startsWith("--"))return{mode:"help"};let i=t.slice(2),{value:o,rest:c}=ze(i,"--caption");i=c;let{value:f,rest:l}=ze(i,"--name");i=l;let{value:x,rest:p}=ze(i,"--agent-id");i=p;let{value:w,rest:b}=ze(i,"--session-id");i=b;let{value:T,rest:E}=ze(i,"--mime");i=E;let v=i.includes("--group-file");i=i.filter(k=>k!=="--group-file");let I=i.includes("--json"),A={mode:"send",kind:e,path:r,json:I};return o&&(A.caption=o),f&&(A.name=f),x&&(A.agentId=x),w&&(A.sessionId=w),v&&(A.groupFile=!0),T&&(A.mimeType=T),A}function Kb(t){let e=t,{value:r,rest:i}=ze(e,"--pat-token");e=i;let{value:o,rest:c}=ze(e,"--env");e=c;let{value:f,rest:l}=ze(e,"--handshake-url");e=l;let{value:x,rest:p}=ze(e,"--frontier-url");e=p;let{value:w,rest:b}=ze(e,"--mock-scenario");e=b;let T={mode:"connect"};return r&&(T.privatecode=r),o&&(T.env=o),f&&(T.handshakeUrl=f),x&&(T.frontierUrl=x),w&&(T.mockScenario=w),T}var Wb=`
103
103
  coze-bridge - local bridge daemon for cloud Agent Service
104
104
 
105
105
  Pair (paste from cloud UI; start/reuse daemon and deliver pair-code):
@@ -166,46 +166,46 @@ Deprecated flags (still work, but emit a warning; will be removed in a future re
166
166
 
167
167
  Internal:
168
168
  <node> <entry> --daemon daemon mode (OS supervisor only)
169
- `.trimStart();async function Wx(t=process.argv,e={}){let r=t2(t);switch(r.mode){case"help":return process.stdout.write(i2),0;case"version":return process.stdout.write(`${gr}
170
- `),0;case"daemon":{try{await Px()}catch(s){return Kx.error("daemon start failed",{err:String(s)}),1}return new Promise(()=>{})}case"status":return s2(e);case"stop":return o2(e);case"refresh":return a2(e);case"purge":return c2(e);case"service-install":return d2(e);case"service-uninstall":return f2(e);case"pair":{let s={};return r.env&&(s.env=r.env),r.handshakeUrl&&(s.handshakeUrl=r.handshakeUrl),r.frontierUrl&&(s.frontierUrl=r.frontierUrl),r.mockScenario&&(s.mockScenario=r.mockScenario),l2(r.privatecode,r.pairingCode,e,s,r.agentId)}case"connect":{let s={};return r.env&&(s.env=r.env),r.handshakeUrl&&(s.handshakeUrl=r.handshakeUrl),r.frontierUrl&&(s.frontierUrl=r.frontierUrl),r.mockScenario&&(s.mockScenario=r.mockScenario),u2(r.privatecode,e,s)}case"send":return Bx({kind:r.kind,path:r.path,...r.agentId?{agentId:r.agentId}:{},...r.sessionId?{sessionId:r.sessionId}:{},...r.caption?{caption:r.caption}:{},...r.name?{name:r.name}:{},...r.groupFile?{groupFile:!0}:{},...r.mimeType?{mimeType:r.mimeType}:{},json:r.json},e)}}async function $x(t){let{unlink:e}=await import("node:fs/promises");await Promise.all([e(t.pidFile).catch(()=>{}),e(t.portFile).catch(()=>{}),e(t.tokenFile).catch(()=>{})])}async function s2(t){let e=t.paths??te(),r=new jt(e),s=await r.probe();if(s.kind==="not-running")return process.stdout.write(`coze-bridge: not running
171
- `),1;if(s.kind==="stale")return await $x(e),process.stdout.write(`coze-bridge: not running (cleaned stale state)
172
- `),1;let a=await r.request({method:"GET",path:"/status"});return process.stdout.write(`coze-bridge: running
173
- ${JSON.stringify(a.body,null,2)}
174
- `),0}async function o2(t){let e=t.paths??te(),r=new jt(e),s=await r.probe();if(s.kind==="not-running")return process.stdout.write(`coze-bridge: not running
175
- `),0;if(s.kind==="stale")return await $x(e),process.stdout.write(`coze-bridge: not running (cleaned stale state)
169
+ `.trimStart();async function Kx(t=process.argv,e={}){let r=Gb(t);switch(r.mode){case"help":return process.stdout.write(Wb),0;case"version":return process.stdout.write(`${xr}
170
+ `),0;case"daemon":{try{await Lx()}catch(i){return jx.error("daemon start failed",{err:String(i)}),1}return new Promise(()=>{})}case"status":return Vb(e);case"stop":return $b(e);case"refresh":return Jb(e);case"purge":return Yb(e);case"service-install":return Zb(e);case"service-uninstall":return Xb(e);case"pair":{let i={};return r.env&&(i.env=r.env),r.handshakeUrl&&(i.handshakeUrl=r.handshakeUrl),r.frontierUrl&&(i.frontierUrl=r.frontierUrl),r.mockScenario&&(i.mockScenario=r.mockScenario),Qb(r.privatecode,r.pairingCode,e,i,r.agentId)}case"connect":{let i={};return r.env&&(i.env=r.env),r.handshakeUrl&&(i.handshakeUrl=r.handshakeUrl),r.frontierUrl&&(i.frontierUrl=r.frontierUrl),r.mockScenario&&(i.mockScenario=r.mockScenario),eE(r.privatecode,e,i)}case"send":return Mx({kind:r.kind,path:r.path,...r.agentId?{agentId:r.agentId}:{},...r.sessionId?{sessionId:r.sessionId}:{},...r.caption?{caption:r.caption}:{},...r.name?{name:r.name}:{},...r.groupFile?{groupFile:!0}:{},...r.mimeType?{mimeType:r.mimeType}:{},json:r.json},e)}}async function Wx(t){let{unlink:e}=await import("node:fs/promises");await Promise.all([e(t.pidFile).catch(()=>{}),e(t.portFile).catch(()=>{}),e(t.tokenFile).catch(()=>{})])}async function Vb(t){let e=t.paths??te(),r=new Ht(e),i=await r.probe();if(i.kind==="not-running")return process.stdout.write(`coze-bridge: not running
171
+ `),1;if(i.kind==="stale")return await Wx(e),process.stdout.write(`coze-bridge: not running (cleaned stale state)
172
+ `),1;let o=await r.request({method:"GET",path:"/status"});return process.stdout.write(`coze-bridge: running
173
+ ${JSON.stringify(o.body,null,2)}
174
+ `),0}async function $b(t){let e=t.paths??te(),r=new Ht(e),i=await r.probe();if(i.kind==="not-running")return process.stdout.write(`coze-bridge: not running
175
+ `),0;if(i.kind==="stale")return await Wx(e),process.stdout.write(`coze-bridge: not running (cleaned stale state)
176
176
  `),0;try{return await r.request({method:"POST",path:"/shutdown"}),process.stdout.write(`coze-bridge: stopped
177
- `),0}catch(a){return process.stdout.write(`coze-bridge: stop failed: ${String(a)}
178
- `),1}}async function a2(t){let e=new jt(t.paths);if((await e.probe()).kind==="not-running")return process.stdout.write(`coze-bridge: not running (start daemon first)
179
- `),1;try{let s=await e.request({method:"POST",path:"/refresh",timeoutMs:35e3});return s.status===200?(process.stdout.write(`coze-bridge: refreshed
180
- ${JSON.stringify(s.body,null,2)}
181
- `),0):(process.stderr.write(`coze-bridge: refresh failed: ${JSON.stringify(s.body)}
182
- `),1)}catch(s){return process.stderr.write(`coze-bridge: refresh failed: ${String(s)}
183
- `),1}}async function c0(t){if(t.supervisor){let c=t.supervisor,f={nodeBin:"",entry:"",logFile:"",homeDir:"",userName:""};return{platform:c.platform,install:()=>c.install(f),uninstall:()=>c.uninstall(f)}}if(t.skipSupervisor)return;let{getSupervisor:e,buildContext:r}=await Promise.resolve().then(()=>(Gx(),jx)),s=e(),a=r();return{platform:s.platform,install:()=>s.install(a),uninstall:()=>s.uninstall(a)}}async function c2(t){let e=new jt(t.paths);if((await e.probe()).kind==="connected"){process.stdout.write(`coze-bridge: stopping daemon...
177
+ `),0}catch(o){return process.stdout.write(`coze-bridge: stop failed: ${String(o)}
178
+ `),1}}async function Jb(t){let e=new Ht(t.paths);if((await e.probe()).kind==="not-running")return process.stdout.write(`coze-bridge: not running (start daemon first)
179
+ `),1;try{let i=await e.request({method:"POST",path:"/refresh",timeoutMs:35e3});return i.status===200?(process.stdout.write(`coze-bridge: refreshed
180
+ ${JSON.stringify(i.body,null,2)}
181
+ `),0):(process.stderr.write(`coze-bridge: refresh failed: ${JSON.stringify(i.body)}
182
+ `),1)}catch(i){return process.stderr.write(`coze-bridge: refresh failed: ${String(i)}
183
+ `),1}}async function a0(t){if(t.supervisor){let c=t.supervisor,f={nodeBin:"",entry:"",logFile:"",homeDir:"",userName:""};return{platform:c.platform,install:()=>c.install(f),uninstall:()=>c.uninstall(f)}}if(t.skipSupervisor)return;let{getSupervisor:e,buildContext:r}=await Promise.resolve().then(()=>(Gx(),Hx)),i=e(),o=r();return{platform:i.platform,install:()=>i.install(o),uninstall:()=>i.uninstall(o)}}async function Yb(t){let e=new Ht(t.paths);if((await e.probe()).kind==="connected"){process.stdout.write(`coze-bridge: stopping daemon...
184
184
  `);try{await e.request({method:"POST",path:"/shutdown"})}catch(f){process.stderr.write(`coze-bridge: stop failed (continuing): ${String(f)}
185
- `)}await new Promise(f=>setTimeout(f,500))}let s=await c0(t);if(s)try{await s.uninstall(),process.stdout.write(`coze-bridge: ${s.platform} supervisor unregistered
185
+ `)}await new Promise(f=>setTimeout(f,500))}let i=await a0(t);if(i)try{await i.uninstall(),process.stdout.write(`coze-bridge: ${i.platform} supervisor unregistered
186
186
  `)}catch(f){process.stderr.write(`coze-bridge: supervisor uninstall failed (continuing): ${String(f)}
187
- `)}let a=t.paths??te(),{rm:c}=await import("node:fs/promises");try{await c(a.bridgeRoot,{recursive:!0,force:!0}),process.stdout.write(`coze-bridge: removed ${a.bridgeRoot}
187
+ `)}let o=t.paths??te(),{rm:c}=await import("node:fs/promises");try{await c(o.bridgeRoot,{recursive:!0,force:!0}),process.stdout.write(`coze-bridge: removed ${o.bridgeRoot}
188
188
  `)}catch(f){return process.stderr.write(`coze-bridge: remove failed: ${String(f)}
189
189
  `),1}return process.stdout.write(`coze-bridge: purged (agents workspaces preserved under ~/.coze/agents)
190
- `),0}async function d2(t){let e=await c0(t);if(!e)return 0;try{return process.stdout.write(`coze-bridge: installing ${e.platform} supervisor...
190
+ `),0}async function Zb(t){let e=await a0(t);if(!e)return 0;try{return process.stdout.write(`coze-bridge: installing ${e.platform} supervisor...
191
191
  `),await e.install(),process.stdout.write(`coze-bridge: supervisor installed (daemon will auto-start on login)
192
192
  `),0}catch(r){return process.stderr.write(`coze-bridge: service install failed: ${String(r)}
193
- `),1}}async function f2(t){let e=await c0(t);if(!e)return 0;try{return await e.uninstall(),process.stdout.write(`coze-bridge: ${e.platform} supervisor unregistered
193
+ `),1}}async function Xb(t){let e=await a0(t);if(!e)return 0;try{return await e.uninstall(),process.stdout.write(`coze-bridge: ${e.platform} supervisor unregistered
194
194
  `),0}catch(r){return process.stderr.write(`coze-bridge: service uninstall failed: ${String(r)}
195
- `),1}}async function l2(t,e,r,s={},a){let c=new jt(r.paths),f=r.spawnDaemon??Xc;if(!r.skipDistInstall){let h=await n0({paths:r.paths});h.kind==="version-changed"?(process.stdout.write(`coze-bridge: upgraded ${h.fromVersion} \u2192 ${h.toVersion}
196
- `),(await c.probe()).kind==="connected"&&(await c.request({method:"POST",path:"/shutdown"}).catch(()=>{}),await new Promise(E=>setTimeout(E,500)))):h.kind==="first-install"&&process.stdout.write(`coze-bridge: installed ${h.libVersion}
195
+ `),1}}async function Qb(t,e,r,i={},o){let c=new Ht(r.paths),f=r.spawnDaemon??Zc;if(!r.skipDistInstall){let p=await t0({paths:r.paths});p.kind==="version-changed"?(process.stdout.write(`coze-bridge: upgraded ${p.fromVersion} \u2192 ${p.toVersion}
196
+ `),(await c.probe()).kind==="connected"&&(await c.request({method:"POST",path:"/shutdown"}).catch(()=>{}),await new Promise(b=>setTimeout(b,500)))):p.kind==="first-install"&&process.stdout.write(`coze-bridge: installed ${p.libVersion}
197
197
  `)}let l=await c.probe();if(l.kind!=="connected"&&(process.stdout.write(`coze-bridge: starting daemon...
198
- `),await f({paths:r.paths}),l=await Vx(c,r.waitTimeoutMs??1e4,r.sleep??Jx),l.kind!=="connected"))return process.stderr.write(`coze-bridge: daemon did not come up: ${l.kind}
199
- `),1;let x={privatecode:t,pairing_code:e};s.env&&(x.env=s.env),s.handshakeUrl&&(x.handshake_url=s.handshakeUrl),s.frontierUrl&&(x.frontier_url=s.frontierUrl),s.mockScenario&&(x.mock_scenario=s.mockScenario),a&&(x.agent_id=a);try{let h=await c.request({method:"POST",path:"/pair",body:x,timeoutMs:35e3});if(h.status===200&&h.body?.ok){let m=h.body.agent;return m&&!m.ok?(process.stderr.write(`coze-bridge: paired but agent ensure failed (agentId=${m.agentId}): ${m.note}
198
+ `),await f({paths:r.paths}),l=await Vx(c,r.waitTimeoutMs??1e4,r.sleep??$x),l.kind!=="connected"))return process.stderr.write(`coze-bridge: daemon did not come up: ${l.kind}
199
+ `),1;let x={privatecode:t,pairing_code:e};i.env&&(x.env=i.env),i.handshakeUrl&&(x.handshake_url=i.handshakeUrl),i.frontierUrl&&(x.frontier_url=i.frontierUrl),i.mockScenario&&(x.mock_scenario=i.mockScenario),o&&(x.agent_id=o);try{let p=await c.request({method:"POST",path:"/pair",body:x,timeoutMs:35e3});if(p.status===200&&p.body?.ok){let w=p.body.agent;return w&&!w.ok?(process.stderr.write(`coze-bridge: paired but agent ensure failed (agentId=${w.agentId}): ${w.note}
200
200
  `),1):(process.stdout.write(`\u5DF2\u914D\u5BF9\u8FDE\u63A5\u5B8C\u6210\uFF0C\u8BF7\u8FD4\u56DE\u5230 coze \u5E73\u53F0\u4E0A\u70B9\u51FB "\u6211\u5DF2\u6267\u884C"
201
- `),0)}return process.stderr.write(`coze-bridge: pair failed: ${JSON.stringify(h.body)}
202
- `),1}catch(h){return process.stderr.write(`coze-bridge: pair failed: ${String(h)}
203
- `),1}}async function u2(t,e,r={}){let s=e.paths??te(),a=t??await Ix(s);if(!a)return process.stderr.write("coze-bridge: \u627E\u4E0D\u5230 patToken \u2014 \u5148\u8DD1\u4E00\u6B21 `coze-bridge --pat-token=<sat_xxx> --pair-code=<xxx>` \u914D\u5BF9, \u6216\u672C\u6B21\u7528 `--pat-token` \u6307\u5B9A\n"),1;let c=new jt(e.paths),f=e.spawnDaemon??Xc;if(!e.skipDistInstall){let h=await n0({paths:e.paths});h.kind==="version-changed"?(process.stdout.write(`coze-bridge: upgraded ${h.fromVersion} \u2192 ${h.toVersion}
204
- `),(await c.probe()).kind==="connected"&&(await c.request({method:"POST",path:"/shutdown"}).catch(()=>{}),await new Promise(E=>setTimeout(E,500)))):h.kind==="first-install"&&process.stdout.write(`coze-bridge: installed ${h.libVersion}
201
+ `),0)}return process.stderr.write(`coze-bridge: pair failed: ${JSON.stringify(p.body)}
202
+ `),1}catch(p){return process.stderr.write(`coze-bridge: pair failed: ${String(p)}
203
+ `),1}}async function eE(t,e,r={}){let i=e.paths??te(),o=t??await Sx(i);if(!o)return process.stderr.write("coze-bridge: \u627E\u4E0D\u5230 patToken \u2014 \u5148\u8DD1\u4E00\u6B21 `coze-bridge --pat-token=<sat_xxx> --pair-code=<xxx>` \u914D\u5BF9, \u6216\u672C\u6B21\u7528 `--pat-token` \u6307\u5B9A\n"),1;let c=new Ht(e.paths),f=e.spawnDaemon??Zc;if(!e.skipDistInstall){let p=await t0({paths:e.paths});p.kind==="version-changed"?(process.stdout.write(`coze-bridge: upgraded ${p.fromVersion} \u2192 ${p.toVersion}
204
+ `),(await c.probe()).kind==="connected"&&(await c.request({method:"POST",path:"/shutdown"}).catch(()=>{}),await new Promise(b=>setTimeout(b,500)))):p.kind==="first-install"&&process.stdout.write(`coze-bridge: installed ${p.libVersion}
205
205
  `)}let l=await c.probe();if(l.kind!=="connected"&&(process.stdout.write(`coze-bridge: starting daemon...
206
- `),await f({paths:e.paths}),l=await Vx(c,e.waitTimeoutMs??1e4,e.sleep??Jx),l.kind!=="connected"))return process.stderr.write(`coze-bridge: daemon did not come up: ${l.kind}
207
- `),1;let x={privatecode:a};r.env&&(x.env=r.env),r.handshakeUrl&&(x.handshake_url=r.handshakeUrl),r.frontierUrl&&(x.frontier_url=r.frontierUrl),r.mockScenario&&(x.mock_scenario=r.mockScenario);try{let h=await c.request({method:"POST",path:"/connect",body:x,timeoutMs:35e3});return h.status===200&&h.body?.ok?(process.stdout.write(`coze-bridge: connected (${h.body.note??"ok"})
208
- `),await Ri(a,s).catch(m=>Kx.warn("writePatToken after connect failed (ignored)",{err:String(m)})),0):(process.stderr.write(`coze-bridge: connect failed: ${JSON.stringify(h.body)}
209
- `),1)}catch(h){return process.stderr.write(`coze-bridge: connect failed: ${String(h)}
210
- `),1}}async function Vx(t,e,r){let s=Date.now()+e;for(;Date.now()<s;){let a=await t.probe(500);if(a.kind==="connected")return a;await r(200)}return t.probe(500)}function Jx(t){return new Promise(e=>setTimeout(e,t))}ee();!process.argv.includes("--daemon")&&!process.env.COZE_BRIDGE_LOG_LEVEL&&O0("warn");Wx(process.argv).then(t=>process.exit(t),t=>{process.stderr.write(`fatal: ${t instanceof Error?t.stack??t.message:String(t)}
206
+ `),await f({paths:e.paths}),l=await Vx(c,e.waitTimeoutMs??1e4,e.sleep??$x),l.kind!=="connected"))return process.stderr.write(`coze-bridge: daemon did not come up: ${l.kind}
207
+ `),1;let x={privatecode:o};r.env&&(x.env=r.env),r.handshakeUrl&&(x.handshake_url=r.handshakeUrl),r.frontierUrl&&(x.frontier_url=r.frontierUrl),r.mockScenario&&(x.mock_scenario=r.mockScenario);try{let p=await c.request({method:"POST",path:"/connect",body:x,timeoutMs:35e3});return p.status===200&&p.body?.ok?(process.stdout.write(`coze-bridge: connected (${p.body.note??"ok"})
208
+ `),await Ci(o,i).catch(w=>jx.warn("writePatToken after connect failed (ignored)",{err:String(w)})),0):(process.stderr.write(`coze-bridge: connect failed: ${JSON.stringify(p.body)}
209
+ `),1)}catch(p){return process.stderr.write(`coze-bridge: connect failed: ${String(p)}
210
+ `),1}}async function Vx(t,e,r){let i=Date.now()+e;for(;Date.now()<i;){let o=await t.probe(500);if(o.kind==="connected")return o;await r(200)}return t.probe(500)}function $x(t){return new Promise(e=>setTimeout(e,t))}ee();!process.argv.includes("--daemon")&&!process.env.COZE_BRIDGE_LOG_LEVEL&&D0("warn");Kx(process.argv).then(t=>process.exit(t),t=>{process.stderr.write(`fatal: ${t instanceof Error?t.stack??t.message:String(t)}
211
211
  `),process.exit(1)});