coze-bridge 0.1.75 → 0.1.76

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 +76 -77
  2. package/package.json +1 -1
package/dist/index.js CHANGED
@@ -5,28 +5,28 @@ 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 Bh=Object.create;var Ho=Object.defineProperty;var zh=Object.getOwnPropertyDescriptor;var Fh=Object.getOwnPropertyNames;var Uh=Object.getPrototypeOf,Hh=Object.prototype.hasOwnProperty;var fe=(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 at=(t,e)=>()=>(t&&(e=t(t=0)),e);var re=(t,e)=>()=>(e||t((e={exports:{}}).exports,e),e.exports),qo=(t,e)=>{for(var r in e)Ho(t,r,{get:e[r],enumerable:!0})},qh=(t,e,r,s)=>{if(e&&typeof e=="object"||typeof e=="function")for(let a of Fh(e))!Hh.call(t,a)&&a!==r&&Ho(t,a,{get:()=>e[a],enumerable:!(s=zh(e,a))||s.enumerable});return t};var ht=(t,e,r)=>(r=t!=null?Bh(Uh(t)):{},qh(e||!t||!t.__esModule?Ho(r,"default",{value:t,enumerable:!0}):r,t));function T0(t){Go=t}function A0(t){return Li[Go]<=Li[t]}function Ni(t){C0={...t}}function Wh(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)),d=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}:${d}`}function Pi(t,e,r,s){if(Li[t]<Li[Go])return;let a=JSON.stringify({ts:Wh(new Date),level:t,module:e,msg:r,...C0,...s});t==="error"||t==="warn"?jh.write(`${a}
9
- `):Gh.write(`${a}
10
- `)}function G(t){return{debug:(e,r)=>Pi("debug",t,e,r),info:(e,r)=>Pi("info",t,e,r),warn:(e,r)=>Pi("warn",t,e,r),error:(e,r)=>Pi("error",t,e,r),child:e=>G(`${t}.${e}`)}}var Li,Go,Gh,jh,C0,te=at(()=>{"use strict";Li={debug:10,info:20,warn:30,error:40},Go=(()=>{let t=process.env.COZE_BRIDGE_LOG_LEVEL;return t==="debug"||t==="info"||t==="warn"||t==="error"?t:"info"})(),Gh=process.stdout,jh=process.stderr,C0={}});import{execFile as Kh,spawn as $h,spawnSync as cv}from"node:child_process";import{promisify as Vh}from"node:util";function Jh(t){if(process.platform!=="win32")return!1;if(R0.test(t))return!0;let r=(t.split(/[/\\]/).pop()??t).replace(R0,"").toLowerCase();return Zh.has(r)}function D0(t,e){if(process.platform!=="win32")return e??{};let r={...e??{}};return Jh(t)&&r.shell===void 0&&(r.shell=!0),r.windowsHide===void 0&&(r.windowsHide=!0),r}function jn(t,e=[],r={}){return $h(t,e,D0(t,r))}function Wn(t,e=[],r={}){return Yh(t,e,D0(t,r))}var Zh,R0,Yh,Kn=at(()=>{"use strict";Zh=new Set(["npm","npx","yarn","pnpm","coze","tsx"]),R0=/\.(cmd|bat|ps1)$/i;Yh=Vh(Kh)});var L0={};qo(L0,{_resetAcpInstallerForTests:()=>op,_setInFlightForTests:()=>ap,ensureAcpInstalled:()=>gn,formatExecError:()=>P0,getAcpBinaryPath:()=>mn,getAcpPackageSpec:()=>Nr,getInFlightInstall:()=>Wo,probeAcpVersion:()=>ip});function Nr(t){let e=jo[t];if(e)return`${e.npmPackage}@${e.versionSpec}`}function rp(t){let e=t?.code;if(e&&ep.has(e))return!0;let r=t instanceof Error?`${t.message}
11
- ${t.stack??""}`:String(t);return tp.test(r)||np.test(r)}function P0(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 k0(t){let e=process.platform==="win32"?"where":"which";try{let{stdout:r}=await Wn(e,[t],{timeout:O0});return r.split(`
12
- `)[0]?.trim()||void 0}catch{return}}async function ip(t){let e=jo[t];if(e)try{let{stdout:r}=await Wn(e.binary,["--version"],{timeout:O0});return r.split(`
13
- `)[0]?.trim()||void 0}catch{return}}async function sp(t,e,r){Pr.info("npm install -g start",{npmPackage:t,versionSpec:e}),await Wn("npm",["install","-g",`${t}@${e}`],{timeout:Xh,maxBuffer:10*1024*1024,...r?{signal:r}:{}}),Pr.info("npm install -g done",{npmPackage:t,versionSpec:e})}async function gn(t,e){let r=jo[t];if(!r)return;let s=Lr.get(t);if(s)return s;let a=Or.get(t);if(a&&Date.now()-a<Qh)return;let c=$n.get(t);if(c)return c;let d=(async()=>{let l=await k0(r.binary);if(l)return Lr.set(t,l),Pr.info("acp wrapper found on PATH",{binary:r.binary,path:l}),l;try{await sp(r.npmPackage,r.versionSpec,e)}catch(p){let w=rp(p);Pr.warn("acp wrapper install failed (will fallback to npx)",{npmPackage:r.npmPackage,transient:w,err:P0(p)}),w||Or.set(t,Date.now());return}let x=await k0(r.binary);if(!x){Pr.warn("acp wrapper installed but binary not found on PATH",{binary:r.binary}),Or.set(t,Date.now());return}return Lr.set(t,x),Or.delete(t),x})().finally(()=>{$n.delete(t)});return $n.set(t,d),d}function mn(t){return Lr.get(t)}function Wo(t){return $n.get(t)}function op(){Lr.clear(),Or.clear(),$n.clear()}function ap(t,e){$n.set(t,e)}var Pr,jo,Xh,O0,Qh,ep,tp,np,Lr,Or,$n,wn=at(()=>{"use strict";Kn();te();Pr=G("agents.acp-installer"),jo={"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"}};Xh=5e4,O0=5e3,Qh=5*6e4,ep=new Set(["ETIMEDOUT","ECONNRESET","ECONNREFUSED","ENETUNREACH","EAI_AGAIN","ERR_SOCKET_TIMEOUT","ENOTFOUND"]),tp=/\b(5\d\d|408|429)\b\s+(Bad Gateway|Service Unavailable|Gateway Timeout|Internal Server Error|Too Many Requests|Request Timeout)/i,np=/fetch failed|request timed out|socket hang up|network timeout/i;Lr=new Map,Or=new Map,$n=new Map});import{chmod as fp,mkdir as dp,readFile as up,rename as B0,writeFile as z0}from"node:fs/promises";import{dirname as lp}from"node:path";async function Vn(t){try{let e=await up(t,"utf8");return JSON.parse(e)}catch(e){if(e.code==="ENOENT")return null;throw e}}async function Mi(t,e,r){await dp(lp(t),{recursive:!0});let s=`${JSON.stringify(e,null,2)}
14
- `,a=`${t}.tmp-${process.pid}-${Math.random().toString(36).slice(2,10)}`;try{r?.mode!==void 0?await z0(a,s,{encoding:"utf8",mode:r.mode}):await z0(a,s,"utf8"),await B0(a,t),r?.mode!==void 0&&await fp(t,r.mode)}catch(c){await B0(a,a).catch(()=>{});let{rm:d}=await import("node:fs/promises");throw await d(a,{force:!0}).catch(()=>{}),c}}var Bi=at(()=>{"use strict"});import{promises as F0}from"node:fs";import{homedir as xp}from"node:os";import{sep as hp,join as ze,resolve as U0}from"node:path";function ne(t){let e=t??xp(),r=ze(e,".coze"),s=ze(r,"bridge"),a=ze(s,"lib");return{cozeRoot:r,bridgeRoot:s,libDir:a,libEntry:ze(a,"index.js"),binDir:ze(s,"bin"),pidFile:ze(s,"bridge.pid"),portFile:ze(s,"bridge.port"),tokenFile:ze(s,"bridge.token"),patTokenFile:ze(s,"pat-token"),logFile:ze(s,"bridge.log"),installLock:ze(s,"install.lock"),configFile:ze(s,"config.json"),agentsRoot:ze(r,"agents")}}function Rt(t,e=ne()){let r=ze(e.agentsRoot,t);return{root:r,config:ze(r,"config.json"),workspace:ze(r,"workspace"),logs:ze(r,"logs")}}async function Mr(t,e){let r=await F0.realpath(U0(t)).catch(()=>null);if(!r)return!1;let s=await F0.realpath(U0(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+hp)}var Fe=at(()=>{"use strict"});var Ui={};qo(Ui,{AGENT_CONFIG_FILE_MODE:()=>zi,enforceAgentConfigMode:()=>mp,loadAgentConfig:()=>qe,persistAgentSessions:()=>Ko,persistAgentSkills:()=>Fi,saveAgentConfig:()=>$e});import{chmod as pp,stat as gp}from"node:fs/promises";function qe(t,e){return Vn(Rt(t,e).config)}function $e(t,e){return Mi(Rt(t.agentId,e).config,t,{mode:zi})}async function mp(t,e){if(process.platform==="win32")return;let r=Rt(t,e).config;try{let s=await gp(r);if(!s.isFile())return;let a=s.mode&511;a!==zi&&(await pp(r,zi),H0.warn("agent config mode auto-corrected to 0600",{path:r,from:a.toString(8)}))}catch(s){if(s.code==="ENOENT")return;H0.warn("enforceAgentConfigMode: chmod failed (ignored)",{path:r,err:String(s)})}}async function Ko(t,e,r){let s=await qe(t,r);s&&(s.sessions=Object.fromEntries(e),await $e(s,r))}async function Fi(t,e,r){let s=await qe(t,r);s&&(s.skills=e,await $e(s,r))}var H0,zi,Kt=at(()=>{"use strict";Bi();te();Fe();H0=G("agent-config"),zi=384});var Vo=re((Nv,W0)=>{W0.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 qi=re($0=>{var K0={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 Ip(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(K0))$0[t]=Ip(K0[t])});var X0=re((Bv,Y0)=>{var Cp=fe("fs"),Ie=fe("path"),V0=Vo(),Tp=qi(),Ap=typeof process=="object"&&process.platform==="win32",Z0=t=>typeof t=="object"&&t!==null,J0=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 me(t){this.sep=Ie.sep,this.fs=Cp,Z0(t)&&Z0(t.fs)&&typeof t.fs.statSync=="function"&&(this.fs=t.fs)}Y0.exports=me;me.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 d;try{d=e.fs.statSync(a)}catch(l){if(l.message&&l.message.startsWith("ENOENT"))e.fs.mkdirSync(a);else throw l}if(d&&d.isFile())throw Tp.FILE_IN_THE_WAY(`"${a}"`)}})}r(t)};me.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 d=Ie.dirname(t);a.fs.existsSync(d)||a.makeDir(d);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};me.prototype.writeFileToAsync=function(t,e,r,s,a){typeof s=="function"&&(a=s,s=void 0);let c=this;c.fs.exists(t,function(d){if(d&&!r)return a(!1);c.fs.stat(t,function(l,x){if(d&&x.isDirectory())return a(!1);var p=Ie.dirname(t);c.fs.exists(p,function(w){w||c.makeDir(p),c.fs.open(t,"w",438,function(v,I){v?c.fs.chmod(t,438,function(){c.fs.open(t,"w",438,function(b,E){c.fs.write(E,e,0,e.length,0,function(){c.fs.close(E,function(){c.fs.chmod(t,s||438,function(){a(!0)})})})})}):I?c.fs.write(I,e,0,e.length,0,function(){c.fs.close(I,function(){c.fs.chmod(t,s||438,function(){a(!0)})})}):c.fs.chmod(t,s||438,function(){a(!0)})})})})})};me.prototype.findFiles=function(t){let e=this;function r(s,a,c){typeof a=="boolean"&&(c=a,a=void 0);let d=[];return e.fs.readdirSync(s).forEach(function(l){let x=Ie.join(s,l),p=e.fs.statSync(x);(!a||a.test(x))&&d.push(Ie.normalize(x)+(p.isDirectory()?e.sep:"")),p.isDirectory()&&c&&(d=d.concat(r(x,a,c)))}),d}return r(t,void 0,!0)};me.prototype.findFilesAsync=function(t,e){let r=this,s=[];r.fs.readdir(t,function(a,c){if(a)return e(a);let d=c.length;if(!d)return e(null,s);c.forEach(function(l){l=Ie.join(t,l),r.fs.stat(l,function(x,p){if(x)return e(x);p&&(s.push(Ie.normalize(l)+(p.isDirectory()?r.sep:"")),p.isDirectory()?r.findFilesAsync(l,function(w,v){if(w)return e(w);s=s.concat(v),--d||e(null,s)}):--d||e(null,s))})})})};me.prototype.getAttributes=function(){};me.prototype.setAttributes=function(){};me.crc32update=function(t,e){return J0[(t^e)&255]^t>>>8};me.crc32=function(t){typeof t=="string"&&(t=Buffer.from(t,"utf8"));let e=t.length,r=-1;for(let s=0;s<e;)r=me.crc32update(r,t[s++]);return~r>>>0};me.methodToString=function(t){switch(t){case V0.STORED:return"STORED ("+t+")";case V0.DEFLATED:return"DEFLATED ("+t+")";default:return"UNSUPPORTED ("+t+")"}};me.canonical=function(t){if(!t)return"";let e=Ie.posix.normalize("/"+t.split("\\").join("/"));return Ie.join(".",e)};me.zipnamefix=function(t){if(!t)return"";let e=Ie.posix.normalize("/"+t.split("\\").join("/"));return Ie.posix.join(".",e)};me.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]};me.sanitize=function(t,e){t=Ie.resolve(Ie.normalize(t));for(var r=e.split("/"),s=0,a=r.length;s<a;s++){var c=Ie.normalize(Ie.join(t,r.slice(s,a).join(Ie.sep)));if(c.indexOf(t)===0)return c}return Ie.normalize(Ie.join(t,Ie.basename(e)))};me.toBuffer=function(e,r){return Buffer.isBuffer(e)?e:e instanceof Uint8Array?Buffer.from(e):typeof e=="string"?r(e):Buffer.alloc(0)};me.readBigUInt64LE=function(t,e){let r=t.readUInt32LE(e);return t.readUInt32LE(e+4)*4294967296+r};me.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)};me.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};me.isWin=Ap;me.crcTable=J0});var ef=re((zv,Q0)=>{var Rp=fe("path");Q0.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=Rp.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 nf=re((Fv,tf)=>{tf.exports={efs:!0,encode:t=>Buffer.from(t,"utf8"),decode:t=>t.toString("utf8")}});var Yn=re((Uv,Jn)=>{Jn.exports=X0();Jn.exports.Constants=Vo();Jn.exports.Errors=qi();Jn.exports.FileAttr=ef();Jn.exports.decoder=nf()});var sf=re((Hv,rf)=>{var $t=Yn(),q=$t.Constants;rf.exports=function(){var t=20,e=10,r=0,s=0,a=0,c=0,d=0,l=0,x=0,p=0,w=0,v=0,I=0,b=0,E=0;t|=$t.isWin?2560:768,r|=q.FLG_EFS;let S={extraLen:0},C=y=>Math.max(0,y)>>>0,D=y=>Math.max(0,y)&65535,P=y=>Math.max(0,y)&255;return a=$t.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 s},set method(y){switch(y){case q.STORED:this.version=10;case q.DEFLATED:default:this.version=20}s=y},get time(){return $t.fromDOS2Date(this.timeval)},set time(y){y=new Date(y),this.timeval=$t.fromDate2DOS(y)},get timeval(){return a},set timeval(y){a=C(y)},get timeHighByte(){return P(a>>>8)},get crc(){return c},set crc(y){c=C(y)},get compressedSize(){return d},set compressedSize(y){d=C(y)},get size(){return l},set size(y){l=C(y)},get fileNameLength(){return x},set fileNameLength(y){x=y},get extraLength(){return p},set extraLength(y){p=y},get extraLocalLength(){return S.extraLen},set extraLocalLength(y){S.extraLen=y},get commentLength(){return w},set commentLength(y){w=y},get diskNumStart(){return v},set diskNumStart(y){v=C(y)},get inAttr(){return I},set inAttr(y){I=C(y)},get attr(){return b},set attr(y){b=C(y)},get fileAttr(){return(b||0)>>16&4095},get offset(){return E},set offset(y){E=C(y)},get encrypted(){return(r&q.FLG_ENC)===q.FLG_ENC},get centralHeaderSize(){return q.CENHDR+x+p+w},get realDataOffset(){return E+q.LOCHDR+S.fnameLen+S.extraLen},get localHeader(){return S},loadLocalHeaderFromBinary:function(y){var A=y.slice(E,E+q.LOCHDR);if(A.readUInt32LE(0)!==q.LOCSIG)throw $t.Errors.INVALID_LOC();S.version=A.readUInt16LE(q.LOCVER),S.flags=A.readUInt16LE(q.LOCFLG),S.flags_desc=(S.flags&q.FLG_DESC)>0,S.method=A.readUInt16LE(q.LOCHOW),S.time=A.readUInt32LE(q.LOCTIM),S.crc=A.readUInt32LE(q.LOCCRC),S.compressedSize=A.readUInt32LE(q.LOCSIZ),S.size=A.readUInt32LE(q.LOCLEN),S.fnameLen=A.readUInt16LE(q.LOCNAM),S.extraLen=A.readUInt16LE(q.LOCEXT);let O=E+q.LOCHDR+S.fnameLen,U=O+S.extraLen;return y.slice(O,U)},loadFromBinary:function(y){if(y.length!==q.CENHDR||y.readUInt32LE(0)!==q.CENSIG)throw $t.Errors.INVALID_CEN();t=y.readUInt16LE(q.CENVEM),e=y.readUInt16LE(q.CENVER),r=y.readUInt16LE(q.CENFLG),s=y.readUInt16LE(q.CENHOW),a=y.readUInt32LE(q.CENTIM),c=y.readUInt32LE(q.CENCRC),d=y.readUInt32LE(q.CENSIZ),l=y.readUInt32LE(q.CENLEN),x=y.readUInt16LE(q.CENNAM),p=y.readUInt16LE(q.CENEXT),w=y.readUInt16LE(q.CENCOM),v=y.readUInt16LE(q.CENDSK),I=y.readUInt16LE(q.CENATT),b=y.readUInt32LE(q.CENATX),E=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(s,q.LOCHOW),y.writeUInt32LE(a,q.LOCTIM),y.writeUInt32LE(c,q.LOCCRC),y.writeUInt32LE(d,q.LOCSIZ),y.writeUInt32LE(l,q.LOCLEN),y.writeUInt16LE(x,q.LOCNAM),y.writeUInt16LE(S.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(s,q.CENHOW),y.writeUInt32LE(a,q.CENTIM),y.writeUInt32LE(c,q.CENCRC),y.writeUInt32LE(d,q.CENSIZ),y.writeUInt32LE(l,q.CENLEN),y.writeUInt16LE(x,q.CENNAM),y.writeUInt16LE(p,q.CENEXT),y.writeUInt16LE(w,q.CENCOM),y.writeUInt16LE(v,q.CENDSK),y.writeUInt16LE(I,q.CENATT),y.writeUInt32LE(b,q.CENATX),y.writeUInt32LE(E,q.CENOFF),y},toJSON:function(){let y=function(A){return A+" bytes"};return{made:t,version:e,flags:r,method:$t.methodToString(s),time:this.time,crc:"0x"+c.toString(16).toUpperCase(),compressedSize:y(d),size:y(l),fileNameLength:y(x),extraLength:y(p),commentLength:y(w),diskNumStart:v,inAttr:I,attr:b,offset:E,centralHeaderSize:y(q.CENHDR+x+p+w)}},toString:function(){return JSON.stringify(this.toJSON(),null," ")}}}});var af=re((qv,of)=>{var Xn=Yn(),he=Xn.Constants;of.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 he.ENDHDR+a},loadFromBinary:function(c){if((c.length!==he.ENDHDR||c.readUInt32LE(0)!==he.ENDSIG)&&(c.length<he.ZIP64HDR||c.readUInt32LE(0)!==he.ZIP64SIG))throw Xn.Errors.INVALID_END();c.readUInt32LE(0)===he.ENDSIG?(t=c.readUInt16LE(he.ENDSUB),e=c.readUInt16LE(he.ENDTOT),r=c.readUInt32LE(he.ENDSIZ),s=c.readUInt32LE(he.ENDOFF),a=c.readUInt16LE(he.ENDCOM)):(t=Xn.readBigUInt64LE(c,he.ZIP64SUB),e=Xn.readBigUInt64LE(c,he.ZIP64TOT),r=Xn.readBigUInt64LE(c,he.ZIP64SIZE),s=Xn.readBigUInt64LE(c,he.ZIP64OFF),a=0)},toBinary:function(){var c=Buffer.alloc(he.ENDHDR+a);return c.writeUInt32LE(he.ENDSIG,0),c.writeUInt32LE(0,4),c.writeUInt16LE(t,he.ENDSUB),c.writeUInt16LE(e,he.ENDTOT),c.writeUInt32LE(r,he.ENDSIZ),c.writeUInt32LE(s,he.ENDOFF),c.writeUInt16LE(a,he.ENDCOM),c.fill(" ",he.ENDHDR),c},toJSON:function(){let c=function(d,l){let x=d.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 Jo=re(Zo=>{Zo.EntryHeader=sf();Zo.MainHeader=af()});var ff=re((jv,cf)=>{cf.exports=function(t){var e=fe("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=[],d=0;a.on("data",function(l){c.push(l),d+=l.length}),a.on("end",function(){var l=Buffer.alloc(d),x=0;l.fill(0);for(var p=0;p<c.length;p++){var w=c[p];w.copy(l,x),x+=w.length}s&&s(l)}),a.end(t)}}}});var uf=re((Wv,df)=>{var Dp=+(process.versions?process.versions.node:"").split(".")[0]||0;df.exports=function(t,e){var r=fe("zlib");let s=Dp>=15&&e>0?{maxOutputLength:e}:{};return{inflate:function(){return r.inflateRawSync(t,s)},inflateAsync:function(a){var c=r.createInflateRaw(s),d=[],l=0;c.on("data",function(x){d.push(x),l+=x.length}),c.on("end",function(){var x=Buffer.alloc(l),p=0;x.fill(0);for(var w=0;w<d.length;w++){var v=d[w];v.copy(x,p),p+=v.length}a&&a(x)}),c.end(t)}}}});var gf=re((Kv,pf)=>{"use strict";var{randomFillSync:lf}=fe("crypto"),kp=qi(),Op=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}),hf=(t,e)=>Math.imul(t,e)>>>0,xf=(t,e)=>Op[(t^e)&255]^t>>>8,Br=()=>typeof lf=="function"?lf(Buffer.alloc(12)):Br.node();Br.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 Gi={genSalt:Br};function ji(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])}ji.prototype.updateKeys=function(t){let e=this.keys;return e[0]=xf(e[0],t),e[1]+=e[0]&255,e[1]=hf(e[1],134775813)+1,e[2]=xf(e[2],e[1]>>>24),t};ji.prototype.next=function(){let t=(this.keys[2]|2)>>>0;return hf(t,t^1)>>8&255};function Pp(t){let e=new ji(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 Lp(t){let e=new ji(t);return function(r,s,a=0){s||(s=Buffer.alloc(r.length));for(let c of r){let d=e.next();s[a++]=c^d,e.updateKeys(c)}return s}}function Np(t,e,r){if(!t||!Buffer.isBuffer(t)||t.length<12)return Buffer.alloc(0);let s=Pp(r),a=s(t.slice(0,12)),c=(e.flags&8)===8?e.timeHighByte:e.crc>>>24;if(a[11]!==c)throw kp.WRONG_PASSWORD();return s(t.slice(12))}function Mp(t){Buffer.isBuffer(t)&&t.length>=12?Gi.genSalt=function(){return t.slice(0,12)}:t==="node"?Gi.genSalt=Br.node:Gi.genSalt=Br}function Bp(t,e,r,s=!1){t==null&&(t=Buffer.alloc(0)),Buffer.isBuffer(t)||(t=Buffer.from(t.toString()));let a=Lp(r),c=Gi.genSalt();c[11]=e.crc>>>24&255,s&&(c[10]=e.crc>>>16&255);let d=Buffer.alloc(t.length+12);return a(c,d),a(t,d,12)}pf.exports={decrypt:Np,encrypt:Bp,_salter:Mp}});var mf=re(Wi=>{Wi.Deflater=ff();Wi.Inflater=uf();Wi.ZipCrypto=gf()});var Xo=re((Vv,wf)=>{var ie=Yn(),zp=Jo(),we=ie.Constants,Yo=mf();wf.exports=function(t,e){var r=new zp.EntryHeader,s=Buffer.alloc(0),a=Buffer.alloc(0),c=!1,d=null,l=Buffer.alloc(0),x=Buffer.alloc(0),p=!0;let w=t,v=typeof w.decoder=="object"?w.decoder:ie.decoder;p=v.hasOwnProperty("efs")?v.efs:!1;function I(){return!e||!(e instanceof Uint8Array)?Buffer.alloc(0):(x=r.loadLocalHeaderFromBinary(e),e.slice(r.realDataOffset,r.realDataOffset+r.compressedSize))}function b(y){if(!r.flags_desc&&!r.localHeader.flags_desc){if(ie.crc32(y)!==r.localHeader.crc)return!1}else{let A={},O=r.realDataOffset+r.compressedSize;if(e.readUInt32LE(O)==we.LOCSIG||e.readUInt32LE(O)==we.CENSIG)throw ie.Errors.DESCRIPTOR_NOT_EXIST();if(e.readUInt32LE(O)==we.EXTSIG)A.crc=e.readUInt32LE(O+we.EXTCRC),A.compressedSize=e.readUInt32LE(O+we.EXTSIZ),A.size=e.readUInt32LE(O+we.EXTLEN);else if(e.readUInt16LE(O+12)===19280)A.crc=e.readUInt32LE(O+we.EXTCRC-4),A.compressedSize=e.readUInt32LE(O+we.EXTSIZ-4),A.size=e.readUInt32LE(O+we.EXTLEN-4);else throw ie.Errors.DESCRIPTOR_UNKNOWN();if(A.compressedSize!==r.compressedSize||A.size!==r.size||A.crc!==r.crc)throw ie.Errors.DESCRIPTOR_FAULTY();if(ie.crc32(y)!==A.crc)return!1}return!0}function E(y,A,O){if(typeof A>"u"&&typeof y=="string"&&(O=y,y=void 0),c)return y&&A&&A(Buffer.alloc(0),ie.Errors.DIRECTORY_CONTENT_ERROR()),Buffer.alloc(0);var U=I();if(U.length===0)return y&&A&&A(U),U;if(r.encrypted){if(typeof O!="string"&&!Buffer.isBuffer(O))throw ie.Errors.INVALID_PASS_PARAM();U=Yo.ZipCrypto.decrypt(U,r,O)}var z=Buffer.alloc(r.size);switch(r.method){case ie.Constants.STORED:if(U.copy(z),b(z))return y&&A&&A(z),z;throw y&&A&&A(z,ie.Errors.BAD_CRC()),ie.Errors.BAD_CRC();case ie.Constants.DEFLATED:var k=new Yo.Inflater(U,r.size);if(y)k.inflateAsync(function(L){L.copy(L,0),A&&(b(L)?A(L):A(L,ie.Errors.BAD_CRC()))});else{if(k.inflate(z).copy(z,0),!b(z))throw ie.Errors.BAD_CRC(`"${v.decode(s)}"`);return z}break;default:throw y&&A&&A(Buffer.alloc(0),ie.Errors.UNKNOWN_METHOD()),ie.Errors.UNKNOWN_METHOD()}}function S(y,A){if((!d||!d.length)&&Buffer.isBuffer(e))return y&&A&&A(I()),I();if(d.length&&!c){var O;switch(r.method){case ie.Constants.STORED:return r.compressedSize=r.size,O=Buffer.alloc(d.length),d.copy(O),y&&A&&A(O),O;default:case ie.Constants.DEFLATED:var U=new Yo.Deflater(d);if(y)U.deflateAsync(function(k){O=Buffer.alloc(k.length),r.compressedSize=k.length,k.copy(O),A&&A(O)});else{var z=U.deflate();return r.compressedSize=z.length,z}U=null;break}}else if(y&&A)A(Buffer.alloc(0));else return Buffer.alloc(0)}function C(y,A){return ie.readBigUInt64LE(y,A)}function D(y){try{for(var A=0,O,U,z;A+4<y.length;)O=y.readUInt16LE(A),A+=2,U=y.readUInt16LE(A),A+=2,z=y.slice(A,A+U),A+=U,we.ID_ZIP64===O&&P(z)}catch{throw ie.Errors.EXTRA_FIELD_PARSE_ERROR()}}function P(y){var A,O,U,z;y.length>=we.EF_ZIP64_SCOMP&&(A=C(y,we.EF_ZIP64_SUNCOMP),r.size===we.EF_ZIP64_OR_32&&(r.size=A)),y.length>=we.EF_ZIP64_RHO&&(O=C(y,we.EF_ZIP64_SCOMP),r.compressedSize===we.EF_ZIP64_OR_32&&(r.compressedSize=O)),y.length>=we.EF_ZIP64_DSN&&(U=C(y,we.EF_ZIP64_RHO),r.offset===we.EF_ZIP64_OR_32&&(r.offset=U)),y.length>=we.EF_ZIP64_DSN+4&&(z=y.readUInt32LE(we.EF_ZIP64_DSN),r.diskNumStart===we.EF_ZIP64_OR_16&&(r.diskNumStart=z))}return{get entryName(){return v.decode(s)},get rawEntryName(){return s},set entryName(y){s=ie.toBuffer(y,v.encode);var A=s[s.length-1];c=A===47||A===92,r.fileNameLength=s.length},get efs(){return typeof p=="function"?p(this.entryName):p},get extra(){return l},set extra(y){l=y,r.extraLength=y.length,D(y)},get comment(){return v.decode(a)},set comment(y){if(a=ie.toBuffer(y,v.encode),r.commentLength=a.length,a.length>65535)throw ie.Errors.COMMENT_TOO_LONG()},get name(){var y=v.decode(s);return c?y.substr(y.length-1).split("/").pop():y.split("/").pop()},get isDirectory(){return c},getCompressedData:function(){return S(!1,null)},getCompressedDataAsync:function(y){S(!0,y)},setData:function(y){d=ie.toBuffer(y,ie.decoder.encode),!c&&d.length?(r.size=d.length,r.method=ie.Constants.DEFLATED,r.crc=ie.crc32(y),r.changed=!0):r.method=ie.Constants.STORED},getData:function(y){return r.changed?d:E(!1,null,y)},getDataAsync:function(y,A){r.changed?y(d):E(!0,y,A)},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(),A=ie.Constants.CENHDR;return s.copy(y,A),A+=s.length,l.copy(y,A),A+=r.extraLength,a.copy(y,A),y},packLocalHeader:function(){let y=0;r.flags_efs=this.efs,r.extraLocalLength=x.length;let A=r.localHeaderToBinary(),O=Buffer.alloc(A.length+s.length+r.extraLocalLength);return A.copy(O,y),y+=A.length,s.copy(O,y),y+=s.length,x.copy(O,y),y+=x.length,O},toJSON:function(){let y=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:y(e),data:y(d)}},toString:function(){return JSON.stringify(this.toJSON(),null," ")}}}});var bf=re((Zv,yf)=>{var _f=Xo(),Fp=Jo(),Ue=Yn();yf.exports=function(t,e){var r=[],s={},a=Buffer.alloc(0),c=new Fp.MainHeader,d=!1,l=null;let x=new Set,p=e,{noSort:w,decoder:v}=p;t?E(p.readEntries):d=!0;function I(){let C=new Set;for(let D of Object.keys(s)){let P=D.split("/");if(P.pop(),!!P.length)for(let y=0;y<P.length;y++){let A=P.slice(0,y+1).join("/")+"/";C.add(A)}}for(let D of C)if(!(D in s)){let P=new _f(p);P.entryName=D,P.attr=16,P.temporary=!0,r.push(P),s[P.entryName]=P,x.add(P)}}function b(){if(d=!0,s={},c.diskEntries>(t.length-c.offset)/Ue.Constants.CENHDR)throw Ue.Errors.DISK_ENTRY_TOO_LARGE();r=new Array(c.diskEntries);for(var C=c.offset,D=0;D<r.length;D++){var P=C,y=new _f(p,t);y.header=t.slice(P,P+=Ue.Constants.CENHDR),y.entryName=t.slice(P,P+=y.header.fileNameLength),y.header.extraLength&&(y.extra=t.slice(P,P+=y.header.extraLength)),y.header.commentLength&&(y.comment=t.slice(P,P+y.header.commentLength)),C+=y.header.centralHeaderSize,r[D]=y,s[y.entryName]=y}x.clear(),I()}function E(C){var D=t.length-Ue.Constants.ENDHDR,P=Math.max(0,D-65535),y=P,A=t.length,O=-1,U=0;for(typeof p.trailingSpace=="boolean"&&p.trailingSpace&&(P=0),D;D>=y;D--)if(t[D]===80){if(t.readUInt32LE(D)===Ue.Constants.ENDSIG){O=D,U=D,A=D+Ue.Constants.ENDHDR,y=D-Ue.Constants.END64HDR;continue}if(t.readUInt32LE(D)===Ue.Constants.END64SIG){y=P;continue}if(t.readUInt32LE(D)===Ue.Constants.ZIP64SIG){O=D,A=D+Ue.readBigUInt64LE(t,D+Ue.Constants.ZIP64SIZE)+Ue.Constants.ZIP64LEAD;break}}if(O==-1)throw Ue.Errors.INVALID_FORMAT();c.loadFromBinary(t.slice(O,A)),c.commentLength&&(a=t.slice(U+Ue.Constants.ENDHDR)),C&&b()}function S(){r.length>1&&!w&&r.sort((C,D)=>C.entryName.toLowerCase().localeCompare(D.entryName.toLowerCase()))}return{get entries(){return d||b(),r.filter(C=>!x.has(C))},get comment(){return v.decode(a)},set comment(C){a=Ue.toBuffer(C,v.encode),c.commentLength=a.length},getEntryCount:function(){return d?r.length:c.diskEntries},forEach:function(C){this.entries.forEach(C)},getEntry:function(C){return d||b(),s[C]||null},setEntry:function(C){d||b(),r.push(C),s[C.entryName]=C,c.totalEntries=r.length},deleteFile:function(C,D=!0){d||b();let P=s[C];this.getEntryChildren(P,D).map(A=>A.entryName).forEach(this.deleteEntry)},deleteEntry:function(C){d||b();let D=s[C],P=r.indexOf(D);P>=0&&(r.splice(P,1),delete s[C],c.totalEntries=r.length)},getEntryChildren:function(C,D=!0){if(d||b(),typeof C=="object")if(C.isDirectory&&D){let P=[],y=C.entryName;for(let A of r)A.entryName.startsWith(y)&&P.push(A);return P}else return[C];return[]},getChildCount:function(C){if(C&&C.isDirectory){let D=this.getEntryChildren(C);return D.includes(C)?D.length-1:D.length}return 0},compressToBuffer:function(){d||b(),S();let C=[],D=[],P=0,y=0;c.size=0,c.offset=0;let A=0;for(let z of this.entries){let k=z.getCompressedData();z.header.offset=y;let L=z.packLocalHeader(),H=L.length+k.length;y+=H,C.push(L),C.push(k);let V=z.packCentralHeader();D.push(V),c.size+=V.length,P+=H+V.length,A++}P+=c.mainHeaderSize,c.offset=y,c.totalEntries=A,y=0;let O=Buffer.alloc(P);for(let z of C)z.copy(O,y),y+=z.length;for(let z of D)z.copy(O,y),y+=z.length;let U=c.toBinary();return a&&a.copy(U,Ue.Constants.ENDHDR),U.copy(O,y),t=O,d=!1,O},toAsyncBuffer:function(C,D,P,y){try{d||b(),S();let A=[],O=[],U=0,z=0,k=0;c.size=0,c.offset=0;let L=function(H){if(H.length>0){let V=H.shift(),oe=V.entryName+V.extra.toString();P&&P(oe),V.getCompressedDataAsync(function(le){y&&y(oe),V.header.offset=z;let be=V.packLocalHeader(),Be=be.length+le.length;z+=Be,A.push(be),A.push(le);let st=V.packCentralHeader();O.push(st),c.size+=st.length,U+=Be+st.length,k++,L(H)})}else{U+=c.mainHeaderSize,c.offset=z,c.totalEntries=k,z=0;let V=Buffer.alloc(U);A.forEach(function(le){le.copy(V,z),z+=le.length}),O.forEach(function(le){le.copy(V,z),z+=le.length});let oe=c.toBinary();a&&a.copy(oe,Ue.Constants.ENDHDR),oe.copy(V,z),t=V,d=!1,C(V)}};L(Array.from(this.entries))}catch(A){D(A)}}}}});var Sf=re((Jv,vf)=>{var ge=Yn(),pe=fe("path"),Up=Xo(),Hp=bf(),_n=(...t)=>ge.findLast(t,e=>typeof e=="boolean"),Ef=(...t)=>ge.findLast(t,e=>typeof e=="string"),qp=(...t)=>ge.findLast(t,e=>typeof e=="function"),Gp={noSort:!1,readEntries:!1,method:ge.Constants.NONE,fs:null};vf.exports=function(t,e){let r=null,s=Object.assign(Object.create(null),Gp);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=ge.Constants.BUFFER,t=void 0)),Object.assign(s,e);let a=new ge(s);if((typeof s.decoder!="object"||typeof s.decoder.encode!="function"||typeof s.decoder.decode!="function")&&(s.decoder=ge.decoder),t&&typeof t=="string")if(a.fs.existsSync(t))s.method=ge.Constants.FILE,s.filename=t,r=a.fs.readFileSync(t);else throw ge.Errors.INVALID_FILENAME();let c=new Hp(r,s),{canonical:d,sanitize:l,zipnamefix:x}=ge;function p(b){if(b&&c){var E;if(typeof b=="string"&&(E=c.getEntry(pe.posix.normalize(b))),typeof b=="object"&&typeof b.entryName<"u"&&typeof b.header<"u"&&(E=c.getEntry(b.entryName)),E)return E}return null}function w(b){let{join:E,normalize:S,sep:C}=pe.posix;return E(pe.isAbsolute(b)?"/":".",S(C+b.split("\\").join(C)+C))}function v(b){return b instanceof RegExp?(function(E){return function(S){return E.test(S)}})(b):typeof b!="function"?()=>!0:b}let I=(b,E)=>{let S=E.slice(-1);return S=S===a.sep?a.sep:"",pe.relative(b,E)+S};return{readFile:function(b,E){var S=p(b);return S&&S.getData(E)||null},childCount:function(b){let E=p(b);if(E)return c.getChildCount(E)},readFileAsync:function(b,E){var S=p(b);S?S.getDataAsync(E):E(null,"getEntry failed for:"+b)},readAsText:function(b,E){var S=p(b);if(S){var C=S.getData();if(C&&C.length)return C.toString(E||"utf8")}return""},readAsTextAsync:function(b,E,S){var C=p(b);C?C.getDataAsync(function(D,P){if(P){E(D,P);return}D&&D.length?E(D.toString(S||"utf8")):E("")}):E("")},deleteFile:function(b,E=!0){var S=p(b);S&&c.deleteFile(S.entryName,E)},deleteEntry:function(b){var E=p(b);E&&c.deleteEntry(E.entryName)},addZipComment:function(b){c.comment=b},getZipComment:function(){return c.comment||""},addZipEntryComment:function(b,E){var S=p(b);S&&(S.comment=E)},getZipEntryComment:function(b){var E=p(b);return E&&E.comment||""},updateFile:function(b,E){var S=p(b);S&&S.setData(E)},addLocalFile:function(b,E,S,C){if(a.fs.existsSync(b)){E=E?w(E):"";let D=pe.win32.basename(pe.win32.normalize(b));E+=S||D;let P=a.fs.statSync(b),y=P.isFile()?a.fs.readFileSync(b):Buffer.alloc(0);P.isDirectory()&&(E+=a.sep),this.addFile(E,y,C,P)}else throw ge.Errors.FILE_NOT_FOUND(b)},addLocalFileAsync:function(b,E){b=typeof b=="object"?b:{localPath:b};let S=pe.resolve(b.localPath),{comment:C}=b,{zipPath:D,zipName:P}=b,y=this;a.fs.stat(S,function(A,O){if(A)return E(A,!1);D=D?w(D):"";let U=pe.win32.basename(pe.win32.normalize(S));if(D+=P||U,O.isFile())a.fs.readFile(S,function(z,k){return z?E(z,!1):(y.addFile(D,k,C,O),setImmediate(E,void 0,!0))});else if(O.isDirectory())return D+=a.sep,y.addFile(D,Buffer.alloc(0),C,O),setImmediate(E,void 0,!0)})},addLocalFolder:function(b,E,S){if(S=v(S),E=E?w(E):"",b=pe.normalize(b),a.fs.existsSync(b)){let C=a.findFiles(b),D=this;if(C.length)for(let P of C){let y=pe.join(E,I(b,P));S(y)&&D.addLocalFile(P,pe.dirname(y))}}else throw ge.Errors.FILE_NOT_FOUND(b)},addLocalFolderAsync:function(b,E,S,C){C=v(C),S=S?w(S):"",b=pe.normalize(b);var D=this;a.fs.open(b,"r",function(P){if(P&&P.code==="ENOENT")E(void 0,ge.Errors.FILE_NOT_FOUND(b));else if(P)E(void 0,P);else{var y=a.findFiles(b),A=-1,O=function(){if(A+=1,A<y.length){var U=y[A],z=I(b,U).split("\\").join("/");z=z.normalize("NFD").replace(/[\u0300-\u036f]/g,"").replace(/[^\x20-\x7E]/g,""),C(z)?a.fs.stat(U,function(k,L){k&&E(void 0,k),L.isFile()?a.fs.readFile(U,function(H,V){H?E(void 0,H):(D.addFile(S+z,V,"",L),O())}):(D.addFile(S+z+"/",Buffer.alloc(0),"",L),O())}):process.nextTick(()=>{O()})}else E(!0,void 0)};O()}})},addLocalFolderAsync2:function(b,E){let S=this;b=typeof b=="object"?b:{localPath:b},localPath=pe.resolve(w(b.localPath));let{zipPath:C,filter:D,namefix:P}=b;D instanceof RegExp?D=(function(O){return function(U){return O.test(U)}})(D):typeof D!="function"&&(D=function(){return!0}),C=C?w(C):"",P=="latin1"&&(P=O=>O.normalize("NFD").replace(/[\u0300-\u036f]/g,"").replace(/[^\x20-\x7E]/g,"")),typeof P!="function"&&(P=O=>O);let y=O=>pe.join(C,P(I(localPath,O))),A=O=>pe.win32.basename(pe.win32.normalize(P(O)));a.fs.open(localPath,"r",function(O){O&&O.code==="ENOENT"?E(void 0,ge.Errors.FILE_NOT_FOUND(localPath)):O?E(void 0,O):a.findFilesAsync(localPath,function(U,z){if(U)return E(U);z=z.filter(k=>D(y(k))),z.length||E(void 0,!1),setImmediate(z.reverse().reduce(function(k,L){return function(H,V){if(H||V===!1)return setImmediate(k,H,!1);S.addLocalFileAsync({localPath:L,zipPath:pe.dirname(y(L)),zipName:A(L)},k)}},E))})})},addLocalFolderPromise:function(b,E){return new Promise((S,C)=>{this.addLocalFolderAsync2(Object.assign({localPath:b},E),(D,P)=>{D&&C(D),P&&S(this)})})},addFile:function(b,E,S,C){b=x(b);let D=p(b),P=D!=null;P||(D=new Up(s),D.entryName=b),D.comment=S||"";let y=typeof C=="object"&&C instanceof a.fs.Stats;y&&(D.header.time=C.mtime);var A=D.isDirectory?16:0;let O=D.isDirectory?16384:32768;return y?O|=4095&C.mode:typeof C=="number"?O|=4095&C:O|=D.isDirectory?493:420,A=(A|O<<16)>>>0,D.attr=A,D.setData(E),P||c.setEntry(D),D},getEntries:function(b){return c.password=b,c?c.entries:[]},getEntry:function(b){return p(b)},getEntryCount:function(){return c.getEntryCount()},forEach:function(b){return c.forEach(b)},extractEntryTo:function(b,E,S,C,D,P){C=_n(!1,C),D=_n(!1,D),S=_n(!0,S),P=Ef(D,P);var y=p(b);if(!y)throw ge.Errors.NO_ENTRY();var A=d(y.entryName),O=l(E,P&&!y.isDirectory?P:S?A:pe.basename(A));if(y.isDirectory){var U=c.getEntryChildren(y);return U.forEach(function(L){if(L.isDirectory)return;var H=L.getData();if(!H)throw ge.Errors.CANT_EXTRACT_FILE();var V=d(L.entryName),oe=l(E,S?V:pe.basename(V));let le=D?L.header.fileAttr:void 0;a.writeFileTo(oe,H,C,le)}),!0}var z=y.getData(c.password);if(!z)throw ge.Errors.CANT_EXTRACT_FILE();if(a.fs.existsSync(O)&&!C)throw ge.Errors.CANT_OVERRIDE();let k=D?b.header.fileAttr:void 0;return a.writeFileTo(O,z,C,k),!0},test:function(b){if(!c)return!1;for(var E in c.entries)try{if(E.isDirectory)continue;var S=c.entries[E].getData(b);if(!S)return!1}catch{return!1}return!0},extractAllTo:function(b,E,S,C){if(S=_n(!1,S),C=Ef(S,C),E=_n(!1,E),!c)throw ge.Errors.NO_ZIP();c.entries.forEach(function(D){var P=l(b,d(D.entryName));if(D.isDirectory){a.makeDir(P);return}var y=D.getData(C);if(!y)throw ge.Errors.CANT_EXTRACT_FILE();let A=S?D.header.fileAttr:void 0;a.writeFileTo(P,y,E,A);try{a.fs.utimesSync(P,D.header.time,D.header.time)}catch{throw ge.Errors.CANT_EXTRACT_FILE()}})},extractAllToAsync:function(b,E,S,C){if(C=qp(E,S,C),S=_n(!1,S),E=_n(!1,E),!C)return new Promise((O,U)=>{this.extractAllToAsync(b,E,S,function(z){z?U(z):O(this)})});if(!c){C(ge.Errors.NO_ZIP());return}b=pe.resolve(b);let D=O=>l(b,pe.normalize(d(O.entryName))),P=(O,U)=>new Error(O+': "'+U+'"'),y=[],A=[];c.entries.forEach(O=>{O.isDirectory?y.push(O):A.push(O)});for(let O of y){let U=D(O),z=S?O.header.fileAttr:void 0;try{a.makeDir(U),z&&a.fs.chmodSync(U,z),a.fs.utimesSync(U,O.header.time,O.header.time)}catch{C(P("Unable to create folder",U))}}A.reverse().reduce(function(O,U){return function(z){if(z)O(z);else{let k=pe.normalize(d(U.entryName)),L=l(b,k);U.getDataAsync(function(H,V){if(V)O(V);else if(!H)O(ge.Errors.CANT_EXTRACT_FILE());else{let oe=S?U.header.fileAttr:void 0;a.writeFileToAsync(L,H,E,oe,function(le){le||O(P("Unable to write file",L)),a.fs.utimes(L,U.header.time,U.header.time,function(be){be?O(P("Unable to set times",L)):O()})})}})}}},C)()},writeZip:function(b,E){if(arguments.length===1&&typeof b=="function"&&(E=b,b=""),!b&&s.filename&&(b=s.filename),!!b){var S=c.compressToBuffer();if(S){var C=a.writeFileTo(b,S,!0);typeof E=="function"&&E(C?null:new Error("failed"),"")}}},writeZipPromise:function(b,E){let{overwrite:S,perm:C}=Object.assign({overwrite:!0},E);return new Promise((D,P)=>{!b&&s.filename&&(b=s.filename),b||P("ADM-ZIP: ZIP File Name Missing"),this.toBufferPromise().then(y=>{let A=O=>O?D(O):P("ADM-ZIP: Wasn't able to write zip file");a.writeFileToAsync(b,y,S,C,A)},P)})},toBufferPromise:function(){return new Promise((b,E)=>{c.toAsyncBuffer(b,E)})},toBuffer:function(b,E,S,C){return typeof b=="function"?(c.toAsyncBuffer(b,E,S,C),null):c.compressToBuffer()}}}});var ol=re(Te=>{"use strict";var N=B;(function(t,e){let r=B,s=t();for(;;)try{if(parseInt(r(1947))/1*(-parseInt(r(1939))/2)+-parseInt(r(1618))/3+parseInt(r(1492))/4*(-parseInt(r(1119))/5)+parseInt(r(2057))/6+-parseInt(r(1916))/7+-parseInt(r(1441))/8*(parseInt(r(1503))/9)+parseInt(r(1731))/10===e)break;s.push(s.shift())}catch{s.push(s.shift())}})(to,679362);function B(t,e){t=t-464;let r=to(),s=r[t];if(B.ctCqqg===void 0){var a=function(x){let p="abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789+/=",w="",v="";for(let I=0,b,E,S=0;E=x.charAt(S++);~E&&(b=I%4?b*64+E:E,I++%4)?w+=String.fromCharCode(255&b>>(-2*I&6)):0)E=p.indexOf(E);for(let I=0,b=w.length;I<b;I++)v+="%"+("00"+w.charCodeAt(I).toString(16)).slice(-2);return decodeURIComponent(v)};B.vTZgkx=a,B.ujuBSh={},B.ctCqqg=!0}let c=r[0],d=t+c,l=B.ujuBSh[d];return l?s=l:(s=B.vTZgkx(s),B.ujuBSh[d]=s),s}var ry=Object[N(1300)+N(1209)],iy=Object["getOwnPr"+N(1384)+N(533)],tl=(t,e)=>function(){return t&&(e=(0,t[{pHHVc:function(c,d){return c(d)}}[N(1749)](iy,t)[0]])(t=0)),e},sy=(t,e)=>{let r=N,s={GmMtf:function(c,d,l,x){return c(d,l,x)}};for(var a in e)s[r(1070)](ry,t,a,{get:e[a],enumerable:!0})};function oy(){return Ju||(Ju=[IDBDatabase,IDBObjectStore,IDBIndex,IDBCursor,IDBTransaction])}function ay(){let t=N;return Yu||(Yu=[IDBCursor[t(907)+"e"].advance,IDBCursor.prototype[t(1041)],IDBCursor[t(907)+"e"][t(1041)+"PrimaryKey"]])}function cy(t){let e=N,r={wZhIw:e(2013),doSTg:function(a,c){return a===c},ZRoDt:e(1502),UylzW:"vfwtD",pZOrc:function(a,c){return a(c)},TkNFA:function(a){return a()},symht:e(988),NFHwn:function(a,c,d){return a(c,d)},SwaqE:"cursor_n"+e(1287),tulnt:function(a,c){return a===c},mGQZy:e(1407),WpeXe:function(a,c){return a instanceof c}},s=new Promise((a,c)=>{let d=e,l={ivsWs:function(v,I){return r[B(578)](v,I)},BOKCj:r[d(1114)],DMxar:r.UylzW,QKSpZ:function(v,I){return r[d(566)](v,I)},NNjKl:function(v){return r[d(691)](v)},lPumv:function(v,I){return v(I)},PfpWR:function(v){return r[d(691)](v)}},x=()=>{let v=d;t[v(1597)+v(1759)+"ner"](r[v(1197)],p),t[v(1597)+v(1759)+v(1094)]("error",w)},p=()=>{let v=d;l.ivsWs(l[v(914)],l[v(1271)])?_0x574d36[v(803)]=_0x53fbfd[v(1499)]()[v(2015)](()=>(_0x3ee3b7(),_0x50ced2)).then(function(I){return I}):(l[v(839)](a,l[v(839)](Tt,t[v(639)])),l[v(929)](x))},w=()=>{let v=d;l.lPumv(c,t[v(988)]),l.PfpWR(x)};t[d(1799)+d(1422)](r.wZhIw,p),t[d(1799)+d(1422)](r.symht,w)});return s[e(2015)](a=>{let c=e;r[c(1284)](c(939),r.mGQZy)?(this[c(1931)+c(817)]=_0x4fa1f7,this[c(1418)+"ileName"]=_0x322f0d,this._messageStrategy=_0x49c63b,this[c(1269)]=r[c(792)](_0x840143,this["_cursorN"+c(817)],r[c(1748)])):r[c(755)](a,IDBCursor)&&Ec[c(873)](a,t)})[e(1494)](()=>{}),Qs[e(873)](s,t),s}function fy(t){let e=N,r={pjtbP:"complete",NVDov:function(a,c,d){return a(c,d)},JEnEM:function(a,c){return a&c},qJlmp:function(a,c){return a!==c},HRiOV:e(1524),KnvLl:function(a){return a()},neuoU:function(a){return a()},WdJpQ:function(a,c){return a(c)},mbYKV:e(877)+"or",jFTHI:"abort"};if(Xs[e(1790)](t))return;let s=new Promise((a,c)=>{let d=e,l=()=>{let w=B;t["removeEv"+w(1759)+"ner"](r[w(767)],x),t[w(1597)+w(1759)+w(1094)]("error",p),t[w(1597)+"entListe"+w(1094)](w(2009),p)},x=()=>{let w=B,v={kabwq:function(I,b,E){return r[B(1778)](I,b,E)},hFDBc:function(I,b){return I|b},ubSQx:function(I,b){return r[B(1988)](I,b)}};r.qJlmp(r[w(1591)],r[w(1591)])?(v[w(1921)](_0x5ab738,_0x2b5b1b,v[w(525)](v[w(1511)](127,_0x1b78c4),128)),_0x20057b>>>=7):(r.KnvLl(a),r.neuoU(l))},p=()=>{let w=B;r[w(1346)](c,t.error||new DOMException(w(877)+"or",r[w(1830)])),r[w(863)](l)};t[d(1799)+d(1422)](r[d(767)],x),t[d(1799)+d(1422)](d(988),p),t[d(1799)+d(1422)](r[d(890)],p)});Xs[e(873)](t,s)}function dy(t){eo={qWIfJ:function(s,a){return s(a)}}[N(1433)](t,eo)}function uy(t){let e=N,r={eyVfN:function(s,a){return s(a)},SwmPv:function(s,a){return s(a)},eGrzB:function(s,a){return s===a},FsheY:"objectSt"+e(475),aDAfs:function(s){return s()}};return r.eGrzB(t,IDBDatabase[e(907)+"e"][e(1930)+e(1715)])&&!(r[e(1159)]in IDBTransaction[e(907)+"e"])?function(s,...a){let c=e,d=t.call(Ei(this),s,...a);return bc[c(873)](d,s[c(1680)]?s[c(1680)]():[s]),Tt(d)}:r[e(1915)](ay)[e(728)](t)?function(...s){let a=e;return t.apply(Ei(this),s),r.eyVfN(Tt,Ec[a(1205)](this))}:function(...s){let a=e;return r.SwmPv(Tt,t[a(1551)](r[a(1254)](Ei,this),s))}}function ly(t){let e=N,r={MjiFw:e(1086),nybUt:function(s,a){return s(a)},OBgFy:function(s,a){return s instanceof a}};return typeof t===r.MjiFw?r[e(668)](uy,t):(r[e(1171)](t,IDBTransaction)&&r[e(668)](fy,t),nl(t,oy())?new Proxy(t,eo):t)}function Tt(t){let e=N,r={uYkNm:function(a,c){return a instanceof c},ciaPf:function(a,c){return a(c)},tYeDK:function(a,c){return a!==c}};if(r[e(583)](t,IDBRequest))return r[e(605)](cy,t);if(Js[e(1790)](t))return Js[e(1205)](t);let s=r[e(605)](ly,t);return r[e(1684)](s,t)&&(Js.set(t,s),Qs[e(873)](s,t)),s}var nl,Ju,Yu,Ec,Xs,bc,Js,Qs,eo,Ei,Xu=tl({"node_modules/idb/build/wrap-idb-value.js"(){let t=N,e={mOngP:"vtexk",NtRAs:function(r,s){return r instanceof s},uziCP:t(1780),wszOm:function(r,s){return r===s},aDpUO:t(747)+t(475),CBqsw:function(r,s){return r(s)},NCTaJ:t(681)+t(1110),pBHqu:function(r,s){return r>>s},VNYPQ:function(r,s){return r+s},bXRXr:function(r,s){return r<<s},CtARU:function(r,s){return r&s},HjJQg:function(r,s){return r&s},AJPtf:function(r,s){return r|s},eJhQT:function(r,s){return r&s},zaZcA:t(889),hjUPa:function(r,s){return r in s}};nl=(r,s)=>s[t(1165)](a=>r instanceof a),Ec=new WeakMap,Xs=new WeakMap,bc=new WeakMap,Js=new WeakMap,Qs=new WeakMap,eo={get(r,s,a){let c=t;if(c(1098)!==e[c(1101)]){if(e[c(1854)](r,IDBTransaction)){if(s===e[c(1693)])return Xs.get(r);if(e[c(1606)](s,e[c(789)]))return r[c(747)+"oreNames"]||bc[c(1205)](r);if(s==="store")return a[c(747)+c(475)][1]?void 0:a["objectSt"+c(1465)](a["objectSt"+c(475)][0])}return e[c(478)](Tt,r[s])}else return(this[c(1023)+"rs"][_0x5b90ca]||(this[c(1023)+"rs"][_0x3b23b3]=[]))[c(737)]({fn:_0x362ca6,ctx:_0x2f236c||this}),this},set(r,s,a){return r[s]=a,!0},has(r,s){let a=t;if(e[a(1854)](r,IDBTransaction)&&(e[a(1606)](s,e.uziCP)||e[a(1606)](s,e[a(1755)])))if(e.wszOm(a(856),a(1436))){let c=e.NCTaJ[a(941)]("|"),d=0;for(;;){switch(c[d++]){case"0":++_0x2a29b0;continue;case"1":_0x358b1f[_0x3cf4e3++]=e[a(1987)](_0x917f4c,18)|240;continue;case"2":_0x297e3a=e[a(748)](e[a(748)](65536,e[a(933)](e.CtARU(1023,_0x537322),10)),e[a(1825)](1023,_0x3125b2));continue;case"3":_0x4cfe9d[_0x19824e++]=e.HjJQg(63,_0x96973d)|128;continue;case"4":_0x530b88[_0x11eb56++]=e[a(1295)](e[a(1431)](_0xa2f8b>>6,63),128);continue;case"5":_0x46a81e[_0x5d777d++]=e[a(1295)](e[a(1078)](e[a(1987)](_0x38a099,12),63),128);continue}break}}else return!0;return e[a(977)](s,r)}},Ei=r=>Qs.get(r)}}),rl={};sy(rl,{deleteDB:()=>hy,openDB:()=>xy,unwrap:()=>Ei,wrap:()=>Tt});function xy(t,e,{blocked:r,upgrade:s,blocking:a,terminated:c}={}){let d=N,l={PoMTl:function(w,v){return w(v)},ValCK:function(w,v){return w(v)},PnLRF:"error",ERngv:function(w,v){return w!==v},KURVS:d(1493),opPwM:d(1490),vVZWm:function(w,v,I,b,E){return w(v,I,b,E)},NqHAq:d(928)+d(1997),ZTAYU:d(966),TsIDY:"upgraden"+d(1356)},x=indexedDB.open(t,e),p=l[d(948)](Tt,x);if(s){if(l.ERngv(l[d(2037)],"ZIPBC"))return function(w,...v){let I=d,b=_0x472574[I(1299)](rTnBBE[I(1488)](_0x594b12,this),w,...v);return _0x4a6e37[I(873)](b,w[I(1680)]?w[I(1680)]():[w]),rTnBBE[I(948)](_0x566509,b)};x[d(1799)+d(1422)](l[d(1256)],w=>{let v=d,I={nigPw:function(b,E,S){return b(E,S)},eLyWk:l[v(911)]};l[v(1105)](l[v(2020)],l[v(1840)])?l[v(785)](s,l.PoMTl(Tt,x[v(639)]),w.oldVersion,w[v(815)+"on"],l[v(948)](Tt,x[v(1930)+v(1715)])):this[v(1322)]("error",I.nigPw(_0x3bca3d,I[v(867)],{..._0x1860fb,message:_0x28554a[v(501)]||""}))})}return r&&x["addEvent"+d(1422)]("blocked",()=>r()),p[d(2015)](w=>{let v=d;c&&w[v(1799)+v(1422)](v(1142),()=>c()),a&&w["addEvent"+v(1422)](l[v(591)],()=>a())})[d(1494)](()=>{}),p}function to(){let t=["tLHVrLG","CvP1wgC","BMnLq2XVC2u","icSG","zeXXrNi","zMvxzhG","uMvJB25Uzwm","BMv4DcGPigm","rMDzwKW","t0LOq2y","BxHytwK","CejHsNa","wgfutK8","q1jAEfm","q0DNBMW","uMLqAfu","vg9ouuy","sNz2EKe","rvjst1i","uxzRA1m","qKf2wxC","Aw5Lza","rwXAB0m","Ec1TC2CTCw8","r2T6B3K","zeThEe4","A29kBhq","AxnbCNjHEq","t0jRsMG","v29XD2C","zhrbqLC","B2nRzxrtDwm","aaaaaaaaaaa","C0Xf","CejiCxu","sKvUru0","zuHSBNm","ugjbDwC","C2vYDMLJzq","uLbor0m","Efrurw52","CMvZzxrfBMq","CgLUz1rPBwu","yM9L","AgfUz2u","AMvjwNu","BNjQAgO","ywrK","ENj5sfu","y3jLyxrLuMu","mhW0Fdj8mxW","tKzJCwi","vfPnwNe","mxWWFdj8nhW","Ewv1zNy","x2nSzwfYugK","ywjVCNq","D2r4vKS","BMDuAw1LCG","Dw5KzwzPBMu","C3vJy2vZCW","wfPpD3m","DgHLBG","Be1ft2C","BxnNsuq","CND1tgq","vwLHzLG","s1vsvLm","s2XKwNq","x3jLywr5q2W","u2vYDMLJzvC","zM9Yy2u","yur0s04","EvnoEeG","sKvVrMG","r2veuee","y3jnCKG","wfzQzLe","vMXwtNy","x2LZtM9Kzq","tNjZr04","CM92AwrLihC","vKHiAuq","CNnVCL9Uyw0","wLrbwvu","zxq9DxrMltG","tufyx1jfvfi","AxrWEu4","rhnLr3y","y09Wzw4","yNnvAgy","sw9lvge","A3nwCKu","vK1qBeO","yM5ctfy","rwvMCuC","zK9Mv3G","BNrbBMrvCgq","qNrbDNi","DxDUt28","tK9Lufq","Efbryva","rKnlz1a","EvrJyKe","mte0nZa5oejNwuXnrG","BxHoreW","tfb5qKe","tvzOs2W","qKfuzfO","B25LCNjVCG","qMfNtfm","Bwf4tg9ZC0m","igfYCMf5yNu","Aw5WB2u","wuTKquK","vw5Oyw5KBgu","s2X2q20","wLf2B1q","wKP1Cfm","DuP4v2m","B3jLtMfTzxm","y2HLy2Tszwe","zgLZCgf0y2G","q0jXC3C","zufJAW","A2v0ignVBNm","weXlCgu","Afb3zhu","tLjJuuW","B2nRzxrgywK","wxzwENa","qKDREve","CMvZzxruCMK","B2zM","zxrzy0q","BvrjC3m","D2fZq2XLyw4","D0PzDeG","B25SAw5L","zfrkvNe","D21oruy","ihjLy29UBMu","y29UBMvJDa","yNnVBwu","vM9xqMG","u3rYyxrLz3K","zxjYtxnN","qKDxquS","y2jgt0G","Ec1TC2CTy3u","vKrYC3q","q2TQyKK","uNHfv08","x3DHAxq","C3ntwwG","uu1trNq","z2vY","y29UBMvJDfm","CuPnz0S","BNruCMLLC0m","zMzmAw5L","DK5Mz00","zgDfCK4","x3bYzwzPEa","CNzIq0m","uKz1vwC","B0rdC0W","y1b4C00","ChbxAvy","t1HuEgu","AezeqMm","CM9ny28","ALPgDLC","y3r4","thjuELG","y3jLyxrLtwu","yMLYr0O","DMfSDwvZ","BwvZ","DK1Hv2u","su5oA3u","vufvC2W","A0L4uhe","C2v0sxrLBq","D2z4q0W","zK9ju3C","rezxyNe","yxbWBgLJyxq","B0vfs3i","x2HHBMrSzvi","Dwv1sfi","uxDqC2G","BxnN","CgfNzwHPzgu","tw5Hvgq","pxv0zI04","vLn1B3e","x2HHBMrSzu8","rLP4tuu","DgDjEvO","m3W1Fdj8nhW","mtb8ohW3","AgHUzgq","ihrPBwvZ","DhPxwKC","DxnNtMe","ihzHBgLKihm","CNzHBfzHBhu","zuTizvC","DcbSAw1PDa","yMzRqKO","CfPpCMm","C1r4y00","t0PHr3O","C3vIC3rYAw4","DhbizwfKzxi","A1Horu0","BwfW","zgPrD20","zcWGDw5RBM8","BLPtzxm","EgHoA2S","qK1svhq","zg9tvgC","zw5KCg9PBNq","wKvhq1O","q2vZDK4","Dgv4DfbHEwW","DvLRtM0","ufPeyxi","CMvWBgfJzui","zgvJB2rLzey","CIb0DhDjra","yMfJA3vWigu","Dwfczxa","Aw5L","tNfiqxe","ANLwyKe","vMXZEKi","B21xvxK","Dhbwuwm","zMLSzw5HBwu","y3jLyxrLt2i","EhLpv04","t0jTAvq","rMPVuKi","zvn6CKW","y2HnyxHuCMK","y2HHCKnVzgu","qwrPCei","y2LHugy","qK5ryNq","BgLMvM8","rfD0vgi","B0HwtKO","ign1CNnVCIa","EffQv1u","BMLizxm","BgXWt1C","zM9YrwfJAa","AxnmB25N","t2P2uuW","C2fNzq","B25TzxnZywC","x2jPBMfYEvq","wLH1ChC","Bw5twwC","twjus3y","BhLbv2C","jMPZy2fSBgi","C1jpEfi","BMrWB2LUDca","zxjFAxnFywm","twLZC2LUzYa","zNjVBu51Bwi","vMXws1G","x2LZv29YA2u","zgvSzxrLrge","tvrutKO","teXSDwi","wwftEeK","BM5Ly3q","Cgu6ia","y291BNq","CMvZDwX0","B25tDg9Wsw0","nxWW","x29UtwvZC2e","BLzIqLm","C2DPza","AwT2s0u","vgfN","zNjVBunOyxi","y29UBMvJDca","Chzhr1e","EufvD1u","x2nVBM5Ly3q","EM1PrxG","B3D5DNO","AKzMt0i","tg9Nsuq","DxbKyxrLq3u","q29UzMLN","ywnRx2nVzgu","AMHMsvK","v0Xvve8","y3DYvw8","DgHHBIbSB2m","tg9JAW","veDUDw8","BgvY","ihn1y2nLC3m","CNzKAgW","BNLIvxq","BgvUz3rO","y3vYCMvUDeK","rgLqvw0","zMLN","ENjHyNC","y2rVzg0","Ae1LC3nHz2u","quz5DK0","tM9gAhe","q2zHweu","CwrWvg0","BvzQveO","mNWWFdf8nxW","yu5qDu8","x29Uq2XVC2u","x2LZtwLUAvq","shfTtxC","v1vbvuS","zNjhAeW","AenSB3nLrxy","BvPQDgK","y3jLyxrLq2W","vgTorKe","sfb1yM8","AhjWAuC","tfnIy2e","Eur4zfu","wevQqxi","CgXLyxnLiha","zw51s0u","wevdC2e","AwXSihvZzsa","z0rMu0C","Aw13DKG","uxnQqwq","x29UvgLTzw8","EvzJDwu","Bwf4twvZC2e","r1nbDxG","zevKs1y","y2PeCee","yuvqvwm","qwvVteC","q29Kzq","rKLmrv9ot1q","zNb0twC","q1b1uNy","yNL0zu9MzNm","CMvHzg9UBhK","veX2Bhm","B2zMBgLUzq","uxL3CKG","CM92AwrLihy","ugPtyuK","vvbbyNy","s2PgvxO","CNjVCK1LC3m","qw1VDw50","B3bLBG","Aw5JBhvKzxm","vhzorw0","y0nTDvG","zgLZywjSzue","z1rPBwvVDxq","CgLUz19VBMm","CfbJr3m","AvDiz24","vuXjzLm","ChvZAa","sNvSqu0","t3ritfC","DffJsgW","BMr3vg0","DLPYvK4","uMvou0i","tLb1Cvi","rgDLCKq","id4G","B2jQzwn0u3q","vK5zufe","yMnTthy","CMfTugfYyw0","uNHstgW","sKHwteC","BMCGDxjSoIa","qLLIC2K","v3bLwgu","BMCGzMfPBgu","Ec11C2uT","zxmGCMvHy2G","DM9ksuy","Ce5ez2G","vNDqveW","DevsAhC","zw5fDMvUDa","ChPzsMi","ANbAEK8","B3nbDgS","CgP0yLa","sgfUyuq","x1fVu01HBMe","qvz5CLi","q21yELK","uuTUvgS","y3jLyxrLrxi","B3jRig9MzMW","Aw9Ul2PZB24","tNnzr0W","yxKSihrYEsa","Aw9UvgLTzw8","y29UDgv4Da","Bg9N","x2LUAxrqCM8","se9Mz3u","yMDHEu4","BMzQq24","DLzAv20","x2DLBMvYyxq","svrkCM4","vMDLugK","yurWvu8","u0HsEuy","Dujvs3u","tKziD24","rxzLBNq","tunQD3a","wu9Ytuq","BMrWB2LUDfq","q1bez0G","AwPsuvm","sffRCee","rgX4A1a","wMvzDNe","x2LZtwLUAvC","zxHWB3j0CW","Dgv4Dc9WBge","DMfSDwu","r05UBM8","Dvzwwhy","ChjVDg9JB2W","zxz1B1i","wg1SC0K","qxvTtgy","tMfLsee","DMfS","rxrdBK0","BMv3vMvYC2K","z1fNsxC","yw1Lu3bHy2u","EM56D0O","A2Hfqxa","v2vIu29JA2u","qwDTyui","sKz6vMG","m3WWFdj8mxW","BgLUzw5V","uxvlDMe","tgzjy04","BwvZC2fNzq","suXHuvO","AwDHDg9Yt24","CM92AwrLige","BMvLzf9Hy2S","s09ADNy","y29SBM8","BhrPCgXLihq","y2uGBM90igK","DLb2D1e","Dw5ZAwDUzwq","C3LABwy","uuTtCfO","EhzIvgu","sKjqywm","t1Dlt2S","zvjHrwK","sgLzBK8","AvLjzvy","y2XVC2uSihC","y3LAsxO","r2jXBwq","v2LUzg93","ywrKq291BNq","mxWW","sKjxr3G","x29UrxjYB3i","AfHlr3G","uwLIBeS","vMjwDLm","C1rKrg8","sNH6vLa","C3rHCNq","Ahr0Chm6","ruHUqwG","B2fK","s252tgW","swz5y2S","wM5VCLm","vwTbAeG","zuX5v2S","vuTLtLC","t21jD1G","C0DfA3q","AKzeDw0","AgvHzgvYCW","C2v0","B0zqs2q","uNrTD0C","yw51Ce1LC3m","qwjVCNrfCNi","sgDOv1u","x3nLCuLK","BKfXD28","Bgvoy2y","zxjFBxnNAwq","s3PIqK0","zffMAvm","v21dqxi","D24GCMvHC28","rvDnD24","q2HuA3e","C3rVCMu","AKzuseK","ELPNuui","uK5mvNC","ywXSq3vYC28","v3n3A2e","Bwu6ia","v3vICe0","Dg9cExrLC0i","x29WDgLVBNm","Aw1LCYbPBIa","z3jtCLu","zeX2q1m","uwHovei","sMDRvLa","EhHUAgm","AwXLtMfTzq","EunRwhy","ChjVDg90Exa","CMzfBfe","qw1mBu0","CNnVCL92ywW","ug5muKy","y3vYCMvUDeu","qKffz08","qK9lq2O","C3vIyxjYyxK","t2jQzwn0","BNjjsve","Dg9tDhjPBMC","u3vsqva","zLncrKu","tKDFrvjst1i","o2nOyxjZzxq","x2nSzwfYvgK","q291BNq","ywDL","u3HoC1q","qNzzzKK","DMvYC2LVBMm","tK5Qs2W","vM1Ozg0","BuL4sNu","qxrYugi","yLHswhi","nhWYFdf8mhW","tKfnswW","vfbRD28","Dhjnwwu","B25dBg9Zzq","CLbuEeS","rKnLEu8","C3bSAxq","A0XTB2O","x2n1CNnVCK0","x2LUAxrhBg8","yu10zva","z2v0q3vYCMu","EvjLy29UBMu","vMfSq0S","zMv5D1K","AgfKDxC","CerLwge","vLv4Cem","z1vxAwi","s0TgBxO","u1fWqxK","rMjSyKm","B25tDgfYDfi","Aw5KzxGGB3u","BgLZDgvUtMu","AwXLx25HBwu","rgvesvC","ywXS","x2rPC3bHDgm","C3LsC0i","m3W1","wKLqqKm","t0jJv1y","z21iz2K","Ag1owvO","ywnOzwq","BK1kD20","ywXPzcb1CMW","C0DKEwG","zw5JB2rPBMC","tMHhDvm","DgvmB2Djre4","AgPvuge","CMfUzg9T","zxjHDg9Y","x2rLC3rYB3K","DfzQu2m","ugzLshm","q0DSzwm","CKfju0O","suzwqw8","uvzgBue","CgXMDNe","zxjYB3i","x194x21Zz18","t1bftL9fuLi","Bg9Nsurhzw4","vLzRtKS","yMLUza","t2jxtLC","CMvJB25Uzwm","C2v0u3rVCMe","AeP6thG","ihrYEsbYzwm","DgLTzw91Da","wgHwruG","CKHpyKq","z2v0u3rVCMe","y3vYC29YlNm","wLHTAwK","z0vVuKi","wNHrvuW","BMvJDa","CKr6rNe","wMfZrei","DhjPBq","C2nYAxb0","BKnXELO","uwjKBwe","Bg93","y3vYC29Yx2y","sLjttvK","DhjPzxm","r1Hry0S","CM9YrxzLBNq","yMXVy2TLza","zKnjD08","CM92AwrLigi","x2XPC3rLBMu","vNfLzMy","C2vYDMLJzs0","Dwj2C1i","sgfrB2e","qLrZA0m","C2XPy2u","yLzMzfG","ufzkDKi","DMvUDa","yuzjthi","B3v0sw50zxi","DMPXEvC","q09yBvm","lcbTyxGGCMu","wLDkDgO","yxnJCMLWDa","x21LC3nHz2u","y29UDgLUDwu","q09otKvdveK","yKLbB2W","CMv0CNLdB3u","C1fZB2G","DgfYz2v0","uK5rvvu","wNfUsK4","t0XpBM4","AM9PBG","qNjPzgDL","Cg5Jwxi","tvbcD2m","suzJDvG","A3LLz1m","AxnAzxjV","DeHSt0e","yKX1y3m","mxW1Fdr8n3W","zxH0ugf5Bg8","wvjXqvK","Bg15C0m","Cgf5Bg9Hza","zfDVCMTLCKC","s3nws2W","D3fptxO","rxP5EMW","vgnxtgu","BML0AwfSAxO","r21nDgy","C0jf","ywnOzwqSihC","AxnFywnR","x2rPC2nVBM4","Bwv0Ag9K","sMj3CLK","D2nXtLO","zuPOuvq","yMrFzgLK","DeLK","zKnoz0O","yw5REM8","Exb4tu4","BMfTzq","CLzHBhvLCW","zNvUy3rPB24","rM9LzMS","ywnR","q3reAg8","x3bHDgHlzxK","x2LUDgvYDMe","yu14s1a","CMvqCxK","BMvY","x3nVy2TLDa","C3rVCcbPBw0","zNjHBwvuExa","r0Xhzvq","wLjiuve","x3bYB3rVy28","Bu9Uz1a","yuDque0","B25ozxr3B3i","quPWs0u","rvjUz3y","FdD8nxWXFdy","sLnptLa","vunJAvi","CePvqu4","nhWZ","wKnvzfG","CgfcEwi","B0Hhtue","wLjVrhq","x3nLBMrby2S","y2vZC0HHBMq","wxnArfa","ExbL","ntbnqvnLuxK","uunmvLq","Eevnz2m","DgLTzw91DcW","q0Xpu0ve","vxfrzvK","De1HBMfNzxi","D3m6lY8","Bhm6ia","CNLpEM0","DMvYC2LVBG","uejdrwG","rhzsu0q","EgLJEKe","x2rLyNvN","yMHyugC","tvzZu2O","DevOrwG","BwvZC2fNztO","EvbMtLy","zgnRCxC","C3nHz2vfDMu","mdaWma","y2XVC2u","z2vjBMzVu3K","vw9QDuC","B2jpq1m","CvbgAgG","CgLUz0LUDgu","DvvYz0G","twzxuKG","DuDtvw0","BwLZzq","BMCGB3iGyw4","vxv3De8","C0rtqM4","BIWGAg9ZDg4","Dw50","DLz6rve","ELvmAwm","rNnOzvK","zxj2AwnL","BMjftKe","s3PUENu","B25VCgvU","BMnVzgLUzW","C29Tzq","DxbNCMfKzw4","lcbxzwjtB2m","ChrVCG","BgLUzq","ELrhq0y","t0jNrNK","x3jLBw92zvC","uwXesvm","z2v0sxrLBq","zMnqA1e","zw5NDgG","Dxrjza","D2vI","D1bLvfu","whL4ELm","A3jmy2C","vwPryxm","y29UBMvJDgK","CwzxD3a","sgnlD3O","uLDsCha","q3vZDg9Trxi","u3fJyMK","vxbKyxrLq28","v2vWAva","ENPOzvi","DMjMsfu","x2fKzfDZtgK","u3rMEwK","C2vUDa","A0LnCue","D1POsxC","v0rkENG","ufz5wgy","yNbpBfq","DwXzt3O","q1DPv2i","r3PqsMu","uvj0DNy","z2v0","z2vrDwv1zuW","zhDJvhq","CKXqquC","B3bLCNr5","DKLXz3C","C2vUza","CMvWBgfJzq","uw1UCM4","reiGzMfPBgu","ue9rAw4","vNDutw0","r0LPBLu","BKvxC1y","y3vYC29Y","zK5Qz3K","m3WWFdH8mta","q09TrLu","t0fSqLa","vMHcDKS","x2LUAxq","vMTRs2i","x0vysvnu","sNfuC2i","x29UugfNzu4","zuHVvhi","q2Tpyw4","s0n1reG","DxrMofDYAxq","EMPLr1G","wfPQEfO","yNvnv20","B3nLrxzLBNq","z2v0s2v5","txDywxm","DcbVzIbYyw4","tgj6A24","zxLdtxO","rLDt","q21sv28","CMfTzq","rK5UqvC","D2nbtLO","C1nuAvm","yw5ZzM9YBvq","ywXSB2nvBNm","whjQue0","oxW2FdH8mhW","zxjFywnRx20","zxLwzK4","zxjFDhrS","vhnjrfK","ignVzgu6ia","z0XQwKS","ANr4uNm","x3DZ","t0rjCfy","t0zhqMG","D3jPDgu","C3bSAwnL","wvDWBei","Aw5KzxHpzG","yw1LoIa","su1vAeK","x3fVC0rc","BfrPBwvVDxq","re14yxi","rKvWv1m","Cgf5Bg9Hzeu","Cwvdr3u","C3rYAw5NAwy","whjhyLG","vwPyDhC","DxjS","EKXkBNO","BgLTAxq","yxrLq291BNq","vLrZA1e","zNjVBNrPzxi","DhvSBNq","qw5qAw4","q09oveLovuu","yw1L","A3vtr3q","Bu9QvKm","C0nVDw50zxi","CeLACwO","v1H6B2e","yNvMzMvY","Ef9MCM9UDgK","quPqDgy","ExH0yvK","twfUv2q","q3bZtgu","y2fSBa","zgvMAw5Luhi","sMvVrwS","DMrmC3K","y3vYC29Yx24","BMDLza","ywnRDxbfBMq","Cg9PBNrbBMq","uxvLDwu","uMfUB1a","vLfhBfu","uNvjugG","yuXsuxC","Ag1sB3u","x2LZqNjVD3m","zgvIDwC","Dhj1y3rVCIa","uLjpuG","igzPzwXKoIa","yNjqr1u","q0Xpu0LorW","rNvPtLu","BMrLEa","zw1PDa","rwrAzMS","rNniwhq","swPiv0y","Aw47y2HHCNm","s2vhAuK","rgjgCNq","EfvZzuvUDG","tgLVr1q","CgLUz0XVC3m","Avf1C3C","rgvvtKW","zMvY","u3rzyue","thLpCxK","EvrKrfK","mtb8m3WY","A1L5s2S","D3bpBM8","D0DMCNG","qMT0zxK","C2v0y3vYC28","wNL1sM0","x3bPBMDmB3m","v2rkCfe","DgLUzYbZzxi","CgfYC2u","zgvSzxrL","ywnRtxnNswq","s2r3s2C","lcbOB3n0BMe","ru93EK0","mhWZFdj8mxW","t3bLBKv2zw4","zwvKzwq","AxmGDw5Kzwy","vMHryLK","zK93vu8","zMzMzG","Cu1eyvm","tNndr0m","Dg9hzw5LCMe","DgfIyxnL","ufHzANq","zgf0yq","zMfprey","Eg52u1C","zv9ZDwnJzxm","z2vtEw5J","BKXPBMu","A2v5CW","uhvRsgm","AwXK","q0vSBvK","x29Ut3bLBG","EsbJBg9Zzwq","Dg9mB3DLCKm","rxzQDuO","tvrPDhu","t3PPyKC","C3Dvr0u","yNLL","B3bLCNr5tMe","DgvZDa","Axrjywu","r0jeAhe","x2rYB3bhBg8","z0n2Efi","sfPqC1i","quzxv1u","D3nltKe","C21gC20","uxnAruG","yw5Hz2vY","r05lwey","zejbzue","ue9js3m","rvPbDfC","ysbTDxn0igi","y2XVC2veqG","C2v0q3vYC28","x2vUzhbVAw4","sNrQvxy","rM1du0e","DxrVuMvJB24","yxrvAMm","qwj4uKi","zNjVBuj5Dgu","zNjVBujPDhm","Chv0","CgrsDKi","x3bPBMDqB24","AwrI","CKvUy0C","A3jgqwO","v2vPEgLUsLm","x2n1CNnVCKy","B3bLBIa","tvvwtwm","tuvtu0fhrv8","tgLZDgvUzxi","Dhjxrg4","yNvMzMvYzwq","ELrrCwW","AM1YuuG","tLboD28","yufYBe0","BwvY","whHbvMC","sgPkuwC","BKjAtwO","CvDjzKO","wgHttvK","EKPvDuu","uKT4wKi","ANz3ChC","ugX6wum","D1zmzxm","rxjYB3jdB2q","mtz3BevUvw4","rgrluKG","AgvKtwf4uMu","EgrXthm","ALLJs0i","BKrrs2y","u1jpAvK","CvDJsxq","uMfty3u","ywnRx2LK","qLjKEKO","q3vZDg9Tq2W","zLLLqxO","vwHVq0O","uxPTzvy","nhWYFdf8oxW","AevYCM9Yrxy","x2HHBMrSzva","rKHWD2K","ALziqK8","u2zIswO","suvtx0vsuK8","CunHEeG","Cg9PBNrdB24","B3jL","zw5HyMXLqxu","y2Ljy3G","zxLJse0","De9csKW","C3rMu2y","vMfKAxG","zwn0","tKHNyu4","rLjptLrjrvi","mxW0Fdn8mhW","q3j1ruu","vwXltwK","DeLUDgvYy2u","r1fssu0","yxv0B21HDgK","Ewvgre4","vw5PBxbSzw0","B05Qqwq","m3W2Fdb8nxW","Bwf4uMv0CMK","AhDPtMO","x3vYBa","ug9nvgW","zxf2seK","t0H2BgC","CMvUDevUzha","mJC2otC2zMLlruPw","wNr5C0u","y2f0y2G","CMLLC0nVDw4","y1PWtvi","t1bxs0W","B0nJENO","CMvZB2X2zq","zKH4CxK","C0XPC3rLBMu","Cur0sNi","mZeWmti1nLfpDe14Ca","B3jpBMXPBMu","EMfytwG","uhHHAhK","yw5Nzq","AKvHA2u","uLDTvfu","qMnwruy","DwjtuxG","D2TXBwu","EKHAr28","EgDsDhO","EgfvwMe","EeTPwwK","z2v0q3vYC28","EfzgvLy","zKzws0u","l3DZl3yY","svPlyKG","rhjIBw8","z0PXDLm","r1rKsgq","vu92CvC","z2jRCwy","u1D6t2e","t1bftG","uxnqqxO","z3vSzNy","B2zcwKK","y0H1seq","uwPKCwS","BwLUAvbYB2C","vvrSB20","vwfey3K","sLPhugu","ue1yB3a","s09TAwK","quzOA3K","CMvKDwnL","tgnWAgq","A2v5","B2XKvMvYC2K","EKjcz1q","sMfWBeG","B3jQBxq","y3ruAw1LB3u","y3jLyxrLt3a","ywWGy3vYC28","yxbWBhK","vKzsCfa","v3ryCMi","Bxjzv3q","qMfyz0G","ELLjvxG","BM93","DfL3AeO","v3HSD0G","t2vyvLC","ihrPBwvVDxq","rNjVBNrPzxi","BuHgrg4","rNfKvxO","CMvXDwLYzwq","EuTpvfi","q2nzqM0","uvbiEgy","Au5qEeq","EuL3wMC","ALffsu8","zNjVBuHHC2G","uxjwr08","qNL5A3q","zxf1ywXZ","CMvHzfvjBNq","qKDtv2K","qNnprfm","zw50zwqGDhK","rgflB3q","EKfUDhK","wNzOC3K","rhj2CfO","thnHte8","tg92r24","s0Dlr2C","DhLWzq","BLrTzwK","q1DQDuG","wwvoDhG","sfjPt1y","x2zVCM1HDeu","CeLfB04","yxnL","CNnVCKzPBgu","uwjzD1a","CMvTB3zLrxy","B3Lbu3u","zvLot0G","r091uhG","EvLVwgS","DMfXyxe","vvLJz1i","B25szwnLAxy","z2v0qwXS","D3n6t20","Eu1ZDLa","z2DcB20","BwLUzW","s0D4ze0","CgrxB3a","zw5HyMXLvhi","r0zWvKG","rxboELe","Bujkz20","y2XLyxi","uxzeA2S","mJyWndGYnvbrBfzAuq","EwHrufC","zxjFCw9Zx2e","DLb0rM4","DND0Cwy","su9cuvO","DhjPzxmGCMu","y29UBMvJDeu","EhLuBxK","ugfKq3i","zcWG","zMLUza","x0rctMfTzq","tMPvBxG","EgXcA0G","uLDXwKW","tw9QEM8","BeLwv1G","uujNC3G","mdaWmdaWmda","u2TPCcbWyxm","AfvuAxq","q2vfufm","ywDLrxzLBNq","z29PBMCGyxC","yxnZAwDU","CMvHzhLtDge","BKz5rgS","AxjLza","CNzHBa","Dw5RBM93BIa","zeDezg0","zv90Aw1LB3u","zw5HyMXLuw8","BNrfBMrWB2K","CNrZuhO","yNL0zxm","z3D2EMO","v09itM0","vNPZwKG","rfPrtM8","u2HHCMvKv28","CwTewgy","wuHty1G","yMLUyxj5vhK","zuf0v2y","D1n4ug0","C1rJq2O","uvfruKK","C0nfCxG","EffkC0G","D1HIrhG","AfHYs0y","thLwy20","x2rItMfTzq","tKnxsg8","zwnVBM5Ly3q","CfLSAM8","CMvHC29U","wKzZuKG","BNrLCG","wK9nD3i","C29YDa","qKnQrfe","t3LeEMO","q0TZq3y","DfLLreS","wurZvKC","AxnrB1nby2S","CNj4BNm","thrnq0K","BwvZC2fNzv8","s3L5ELa","BeX3tfy","AKPQtNq","DxPPq1a","B3vUDa","twvZC2fNzuu","zxH0zw5ZAw8","zxrxB3jRq2G","Dg9VigXHCMC","yxv0BW","BvjnD2q","uLD2yu0","qwDVuMe","tgvmD0i","u2vXsuq","u2v2ugq","y3vYDMfSDwu","z1vYBLu","B3bLBKrc","DNvNB3y","CgfNzxnOB3C","wu9Tv3q","x2DLDeLUDgu","q0D6Exa","rhbpz00","Aw9U","D0TeDLi","CMX2tha","DgDZzKu","z2T6qwO","zenms2K","wvnvAwq","quDquNm","q2P6Bxe","Fdj8nhWWFde","yNL0zuXLBMC","BwLvCvi","t014swW","B2LUDfjLywm","rgvKAwnHDgu","rhrHAu4","ndq0nZq2ndbQrgvJEM4","z3zWCK0","ywzL","ALDbEgK","y2HnyxHdB3u","AgLNAa","sfftsLC","zgvS","C2XPD2m","x2TLEvbHDgG","wgngCuO","vwP4yxO","C1Hcz0m","z2v0qwXSs2u","x3jLy29UBMu","yMfSrxzLBNq","zwzrCMm","u3DHCuu","CeHivMm","DhDVCMTdAge","uLvMrxm","ELDvvgS","t0rtq2m","twzZCK0","EMfAy0e","BuXduMy","vuzKDfG","y2HLy2TdDxi","zw50tgLZDgu","wvfPzvq","vK1usvC","tKTcvMi","C3rLBMvYCW","CMHOvxu","CMvTB3zLq2G","rNDcB3u","x25HDMLNyxq","tenuA3C","DgLtq0O","DMLJzuLeig8","C2HPzNq","BwvKAwf0zwW","sLHdsNO","B2nRzxq","BezSDxnO","ue5lAM4","x21PBMLoyxy","tLzeB3y","sg9PEe0","zg9Uzq","t3LxruC","Dg9oDw1Izxi","zw5JB2rLrNi","rhn1zem","zNDZxZeUmc4","BwfSzLq","yM9KEq","vwzyrhy","ywDLsgLKzq","AgfZ","wg10C3y","A2nlA0q","wLPlvgS","wKTzueu","z2DZwNO","qNjZs2W","uxL0rvG","q2TNrNe","ywrKrxzLBNq","vLb5yu8","zMXVB3i","CgvYC2LZDgu","zw5XDwv1zq","Dgv4Dc9Qyxy","C3rYAw5N","ywXSzwqGBxu","CvrIC0u","CMvZzxrdB3u","zvvYBa","q1PPu3a","qvL6Bwy","Dg9cExrLC0W","Dg9cExrLCW","tw9KDwXL","zMzLCG","Bw5dtwm","Cgf5Bg9Hzfq","vfD6ruG","zMX1C2HfEha","x2LZsw5PDa","z0Xptwi","ufDSAMe","BLfkAgC","Dg9Y","q3rbuLu","uK5MzwW","Bu5qCKe","rhDgsvm","yKrdrMC","Bwjzs1y","zw50","qwvdr2y","y01it2C","rNLjAvu","zKrqy2i","C0XbAgq","Bg9kELO","D3nZoI8V","EgnSyvC","B3bqD00","Cg9W","CgjICdi","Dev2zw50","tKDoDfe","ywXty29Wzq","D1jpugW","BhDrAxu","D0Xotwy","AwzvzeC","s0nXB0W","ChbL","quj4D2u","s3vRCvm","tNrsqxm","B05HtMK","tvfurva","Axnby2TdBgu","AxnszwfKEq","Eg95y2u","sNr5teu","Cu9nzKO","sNfzreu","vxntC1m","y29Kzq","BffiseW","x19LC01Vzhu","CMvQzwn0","Aw10vfy","wKv5yu8","CgTqu1y","uvLbDNu","ufHKr0u","sMzluu0","Bhf2wMe","q0D2vNy","vgLTzw91Da","sfLRDuu","sMDeAhq","yxLzt1e","uu1nu28","sMTuwuG","sevzzue","B25mAw5L","igXHCMDLCIa","B2zMC2v0","AgzrswS","DxHQB04","u0vUr2u","terzthy","Cw9Zx18","yMfSu2nVCgu","yMLUyxj5","ALf1zLC","txn1vvK","y29UC3rYDwm","uefnyKq","AefJA01LC3m","x3DZsw5ZDge","C25lzvm","BxzNrLm","swLtwu8","yxGGCMv0CMK","vKrdBey","Ae9Wzw5fDMu","ywHyyNK","EvDKBMm","zwneB2G","vhjXB3m","B25JBg9Zzq","B2TVrxy","DMfyCuG","Axjirvq","y2XLyxjtDg8","x2nYzwf0zvm","yurbzNm","ntKXmJC1m1DxCgLxyq","r0zYwNm","Agjcrg4","yNv1tLK","ywDLu2HVDW","A2fID3e","AxnrB1nnzxm","vhr3yMq","t0Tqv28","D2LSBfjLy28","EvjeB0y","x3bPBMC","DwPKyvK","zcbLCNjVCI4","DhjHBNnHy3q","x2n1CNnVCK4","wunkAgi","tg9NsurozxC","D3jPDgvvAw4","qvzfvKe","BeHHBMrSzxi","rhnLuLG","tMfTzq","mtCYotq0nNDysNLwvq","tujvugW","yKrdAKO","vNLxBe0","vu5RExq","B3nLza","CMDHrvq","Bg9NsurozxC","mw93t0HiyW","A1zLwem","ChrAtuS","vvvcvMq","y29Uy2f0","qxnov0C"];return to=function(){return t},to()}function hy(t,{blocked:e}={}){let r=N,s={ESrxf:r(1020),UojuG:function(c,d){return c(d)}},a=indexedDB.deleteDatabase(t);return e&&a[r(1799)+r(1422)](s.ESrxf,()=>e()),s[r(1144)](Tt,a)[r(2015)](()=>{})}function Qu(t,e){let r=N,s={IoKTa:"readwrite",VMPlJ:r(717),VHHiD:function(x,p){return x instanceof p},QsjAd:function(x,p){return x===p},ypxMN:r(1805),nVbBS:r(997),BYbsi:function(x,p){return x in p}};if(!(s[r(2035)](t,IDBDatabase)&&!(e in t)&&s[r(703)](typeof e,s[r(1083)]))){if(s.QsjAd(s[r(643)],s[r(643)]))return;{let x=_0xe9475d[r(827)][r(1063)];x&&_0x4cd21e[r(1402)+"rs"](x)}}if(Ys.get(e))return Ys.get(e);let a=e[r(1212)](/FromIndex$/,""),c=e!==a,d=sl[r(728)](a);if(!s[r(754)](a,(c?IDBIndex:IDBObjectStore)[r(907)+"e"])||!(d||il[r(728)](a)))return;let l=async function(x,...p){let w=r,v=this["transact"+w(1715)](x,d?s[w(2044)]:s[w(2046)]),I=v[w(889)];return c&&(I=I.index(p[w(1771)]())),(await Promise[w(962)]([I[a](...p),d&&v.done]))[0]};return Ys[r(873)](e,l),l}var il,sl,Ys,py=tl({"node_modules/idb/build/index.js"(){let t=N,e={DeDIW:t(2006)+t(965),ujdaY:function(a){return a()},tHlOA:t(1238),hPwdu:t(1744)+"ys",RanoP:t(638),GGCMm:"delete",LkRIY:t(1616),sROxR:function(a,c){return a(c)}},r=e[t(961)][t(941)]("|"),s=0;for(;;){switch(r[s++]){case"0":Xu();continue;case"1":e[t(1928)](Xu);continue;case"2":il=["get",e[t(1057)],t(1605),e[t(482)],e[t(1308)]];continue;case"3":Ys=new Map;continue;case"4":sl=["put",t(2e3),e.GGCMm,e.LkRIY];continue;case"5":e[t(625)](dy,a=>({...a,get:(c,d,l)=>Qu(c,d)||a[t(1205)](c,d,l),has:(c,d)=>!!Qu(c,d)||a[t(1790)](c,d)}));continue}break}}}),gy={idb:function(t){let e=N;t[e(803)]=Promise[e(1499)]()[e(2015)](()=>(py(),rl))[e(2015)](function(r){return r})}},el={};function Ct(t){let e=N,r={XaTNO:e(934)+"3"},s=r[e(1965)][e(941)]("|"),a=0;for(;;){switch(s[a++]){case"0":gy[t](c,c.exports,Ct);continue;case"1":var c=el[t]={exports:{}};continue;case"2":if(d!==void 0)return d[e(803)];continue;case"3":return c[e(803)];case"4":var d=el[t];continue}break}}Ct.d=(t,e)=>{let r=B;for(var s in e)Ct.o(e,s)&&!Ct.o(t,s)&&Object[r(1300)+r(1209)](t,s,{enumerable:!0,get:e[s]})},(()=>{let t=N;Ct.o=(e,r)=>Object[t(907)+"e"]["hasOwnPr"+t(1209)].call(e,r)})(),(()=>{let t=N,e={BATdZ:function(r,s){return r!=s},HyisY:t(1814),VDYYN:t(1866)+"le"};Ct.r=r=>{let s=t;e[s(2061)]("undefined",typeof Symbol)&&Symbol[s(918)+"Tag"]&&Object[s(1300)+"operty"](r,Symbol[s(918)+s(646)],{value:e.HyisY}),Object["definePr"+s(1209)](r,e.VDYYN,{value:!0})}})();var Se={};(()=>{let t=N,e={gCvxR:function(o,n){return o(n)},MfWRH:function(o,n){return o+n},OjvQL:function(o,n){return o*n},ULIfS:function(o,n){return o(n)},jzTZg:t(1475)+"2",Byykt:function(o,n){return o===n},Wxjgt:t(1709),FblbC:t(932),pDeXa:function(o,n){return o(n)},JulAM:function(o,n,i){return o(n,i)},XrGbX:function(o,n){return o(n)},RWRpp:function(o,n){return o(n)},DsudC:t(1141),orjmt:t(1360),JqYDE:function(o,n){return o(n)},PZDar:function(o,n){return o!==n},OBkJh:function(o,n,i,f){return o(n,i,f)},cwrUo:function(o,n){return o<n},WtXrb:function(o,n){return o>n},BcVEF:function(o,n){return o<n},MnaTd:function(o,n){return o!==n},ManWd:t(1760),mIxJu:function(o,n){return o-n},lMEOg:t(1973),qMDaS:function(o,n){return o-n},UiafX:function(o,n){return o===n},gLjZK:t(1375),RiPhU:t(1476),NPNwo:function(o,n){return o<n},LhfrZ:t(1073),AumLf:t(1450),Wswka:function(o,n){return o||n},PFdLu:t(658),eYNOH:function(o,n){return o===n},KGKGg:"mhrQZ",zWPNb:t(1132),QvDkk:function(o,n,i){return o(n,i)},nDQKf:function(o,n){return o!==n},ToNQF:"FtAkL",pdRvB:function(o,n,i){return o(n,i)},vaXqH:t(1020),birGJ:t(1932),imtTV:function(o,n){return o>>>n},CtDho:function(o,n,i){return o(n,i)},kuSGt:function(o,n,i){return o(n,i)},PWlja:function(o,n,i){return o(n,i)},QYAvu:function(o,n){return o&n},wDZqQ:t(628)+t(1565)+t(1317)+"key",AdipB:function(o,n){return o===n},nEWsV:t(628)+"required"+t(1317)+t(805),QsZEH:function(o){return o()},uGSUm:function(o,n,i){return o(n,i)},UTlom:function(o,n){return o(n)},XcFqJ:function(o,n){return o+n},MbTKv:function(o,n){return o(n)},LtMCI:function(o,n){return o>=n},gDfSG:function(o,n){return o|n},iNPxD:function(o,n){return o/n},jVHBO:function(o,n,i){return o(n,i)},HaQoa:function(o,n){return o(n)},HqmMw:t(1324),TcWLe:function(o,n){return o!==n},VTskQ:function(o){return o()},kXNEM:function(o,n,i){return o(n,i)},CGvVv:function(o,n,i){return o(n,i)},HEYeA:function(o,n){return o!==n},KxRhx:t(865),bDCFg:function(o,n,i){return o(n,i)},SfbIj:function(o,n,i){return o(n,i)},UCciR:function(o,n,i){return o(n,i)},sliwc:function(o,n,i){return o(n,i)},AgoRa:function(o,n){return o!==n},fHxqy:function(o,n,i,f,u){return o(n,i,f,u)},mLCRf:function(o,n){return o(n)},ZEyaO:function(o,n){return o>>>n},OWKOk:function(o,n){return o(n)},mRMwd:"ZxoTz",VgePi:t(1880),RxRLl:function(o,n,i){return o(n,i)},QKnTk:function(o,n,i){return o(n,i)},sDSBn:function(o,n,i){return o(n,i)},YHScX:function(o,n){return o(n)},owhvf:function(o,n,i){return o(n,i)},SIubn:function(o,n){return o&n},jWAxi:function(o,n){return o===n},AmLmM:t(628)+t(1565)+t(1317)+"SeqID",OzibG:function(o,n){return o===n},ecDoh:t(628)+t(1565)+t(1317)+"LogID",SaCec:t(628)+"required"+t(1317)+t(1991),dtABW:function(o,n){return o(n)},qdpTm:function(o,n){return o+n},TPkwo:function(o,n){return o&n},JYHot:function(o,n){return o(n)},UYcgR:function(o,n){return o(n)},Kznzu:function(o,n,i){return o(n,i)},mvgFS:t(1482)+t(1579)+t(637),ITJrn:function(o,n){return o>=n},dCLKi:function(o,n){return o+n},xVFVV:t(1638)+t(564),CGgnl:function(o,n){return o*n},djQwm:function(o,n){return o+n},WrQTz:"Read pas"+t(564),LfIcN:function(o,n,i){return o(n,i)},mNPrA:function(o,n){return o+n},ZeYvq:function(o,n){return o+n},jmrQH:function(o,n){return o+n},mnSYg:function(o,n){return o|n},lwQiu:function(o,n){return o==n},rAISJ:function(o,n){return o&n},KlvCm:function(o,n){return o>=n},Lbzkn:function(o,n){return o+n},HYkuE:function(o,n){return o+n},XLKpe:function(o,n){return o+n},swUGE:function(o,n){return o+n},OBcWV:function(o,n){return o+n},hfQIk:function(o,n){return o!==n},bLucs:function(o,n){return o&n},vMaWe:function(o,n){return o|n},OLOnn:function(o,n){return o|n},ZCUdX:function(o,n){return o|n},YaSxI:function(o,n){return o<<n},LrTzX:function(o,n){return o<<n},mHFDn:function(o,n){return o&n},zaXMh:function(o,n){return o&n},PVyXf:function(o,n){return o<=n},EpNzQ:function(o,n){return o==n},cyZIz:function(o,n){return o|n},eSzrL:function(o,n){return o<<n},VoWBh:function(o,n){return o<<n},nrjhj:t(1470),gzOLm:"cjapH",DgerD:function(o,n){return o|n},DWtTb:function(o,n){return o&n},tERhw:function(o,n){return o&n},ssSYh:function(o,n){return o&n},loJzZ:function(o,n){return o>n},Vqeff:function(o,n,i){return o(n,i)},lifVo:function(o,n){return o+n},JZGPe:function(o,n){return o&n},VkkKb:function(o,n){return o<n},yDxdU:function(o,n){return o>=n},yMsvP:function(o,n){return o<=n},fcPkQ:function(o,n){return o+n},RWQTL:function(o,n){return o<<n},wpOno:function(o,n){return o<n},AeoLG:t(766),IkGrl:t(1923),qPFhh:function(o,n){return o>=n},dLvCS:function(o,n){return o<n},yVcue:function(o,n){return o<n},DtaiN:t(814),oFPKd:t(1570),QlDIS:function(o,n){return o|n},gbkqf:function(o,n){return o&n},tzWZG:function(o,n){return o>>n},rePqy:function(o,n){return o<n},PjSaI:function(o,n){return o|n},GmxVn:function(o,n){return o&n},xvbTe:function(o,n){return o&n},hXrKF:function(o,n){return o>>n},UFdtX:function(o,n){return o|n},WLUTO:function(o,n){return o&n},NGNtQ:function(o,n,i){return o(n,i)},ZRHQQ:function(o,n,i){return o(n,i)},sTxcM:function(o,n){return o<<n},DbFrt:function(o,n,i){return o(n,i)},uaBep:function(o,n,i){return o(n,i)},ZOMwr:function(o,n){return o&n},yeufv:function(o,n){return o&n},yRDoF:t(1924),GFrZs:function(o,n){return o(n)},NPuqR:function(o,n){return o<<n},EtoXK:function(o,n){return o&n},PMXop:t(1416),Qqvgu:t(1718),vPvwQ:function(o,n){return o(n)},dbmzx:function(o,n){return o<<n},XhSMY:function(o,n){return o&n},VSuoq:function(o,n){return o(n)},aLRQw:function(o,n){return o&n},DaKot:function(o,n){return o&n},JgkVP:function(o,n){return o&n},Qjdqk:function(o,n){return o(n)},uUrgH:function(o,n){return o&n},sCEqx:function(o,n){return o(n)},OXsLu:function(o,n){return o<<n},GIinU:function(o,n){return o>>>n},SMecC:function(o,n){return o<<n},yYoXk:function(o,n){return o<n},iWHgn:function(o,n){return o<n},BCjDQ:function(o,n){return o<n},aGPPM:function(o,n){return o<n},BLpzt:function(o,n){return o+n},ObWNW:function(o,n){return o|n},FqdUz:function(o,n){return o&n},JkTYH:function(o,n){return o>>>n},feWdx:function(o,n){return o+n},GBDhq:function(o,n){return o|n},nYjyy:function(o,n){return o>>>n},sTcCj:function(o,n){return o&n},plfvq:function(o,n){return o>>>n},LDYLv:function(o,n){return o+n},jtxRs:function(o,n){return o>>>n},BGkyQ:function(o,n){return o!==n},vzdyH:function(o,n){return o+n},cPxsM:function(o,n){return o|n},kIxPq:function(o,n){return o&n},rDzFq:function(o,n){return o>>>n},CPDgH:function(o,n){return o+n},enuKE:function(o,n){return o|n},LXDsC:function(o,n){return o&n},hhndd:function(o,n){return o!==n},LCTkw:function(o,n){return o|n},xEMgc:function(o,n){return o|n},cZRTV:t(687),OIhCf:function(o,n){return o|n},mZjti:function(o,n){return o|n},OFGBh:function(o,n){return o<<n},CcYBm:function(o,n){return o|n},trWDn:function(o,n){return o<<n},RtmwG:function(o,n){return o|n},GeDPA:function(o,n){return o<<n},zWUTk:function(o,n){return o|n},COmFU:function(o,n){return o>>>n},rEncG:function(o,n){return o|n},Vmhdm:function(o,n){return o|n},SHRyF:function(o,n){return o>>>n},YSUid:function(o,n){return o>>>n},IZKbH:function(o,n){return o>>>n},eHoTr:function(o,n){return o&n},WOHNm:function(o,n){return o(n)},rHObD:function(o,n){return o===n},TEKpu:t(1135),PBCEh:function(o,n){return o(n)},zZgQB:function(o,n){return o>=n},wJYtH:function(o,n){return o>=n},BagLS:function(o,n){return o|n},EKwOd:function(o,n){return o%n},tBnoQ:t(1798),bVfdX:"EEjlU",soIrx:function(o,n){return o>>>n},FgYZL:function(o,n){return o>>>n},DfTIy:function(o,n){return o*n},trMYe:"axKZe",RNQUU:function(o,n){return o&n},cdodm:function(o,n){return o&n},DvRSD:function(o,n){return o>>>n},pIZqj:function(o,n){return o+n},DiPUm:function(o,n){return o>>>n},pNDgh:function(o,n){return o+n},kIMqA:function(o,n){return o|n},ryOzm:function(o,n){return o|n},JeoEk:function(o,n){return o<<n},CkOan:function(o,n){return o===n},zBBgT:function(o,n){return o===n},JvvzA:function(o,n){return o>>>n},jhfIY:function(o,n){return o===n},UuwtO:function(o,n){return o===n},WmCAr:function(o,n){return o&n},VhBvK:function(o,n){return o>>>n},vVzEQ:function(o,n){return o&n},ayYOQ:function(o,n){return o&n},LovGn:function(o,n){return o>>>n},KCqoL:function(o,n){return o&n},vNfgM:function(o,n){return o>>>n},QzmeV:function(o,n){return o>>>n},fDPcb:function(o,n){return o&n},bnBLV:function(o,n){return o>>>n},pJUAN:t(1188),Gkzoy:t(555)+t(851),CkjbI:t(990)+"OR",VQGlU:t(2039)+t(1462)+"R",nrIIQ:"NATIVE_E"+t(1316),HGOiE:t(1421)+"ERROR",YvVzp:"CONNECTI"+t(921),WepiP:function(o,n){return o===n},fOfWx:"bjwXB",wkqme:"2|0|1|4|3",RNLVw:function(o,n){return o&n},AFhky:function(o,n){return o>>>n},FmCSA:function(o,n){return o&n},jQufW:function(o,n){return o&n},hYGRG:function(o,n){return o+n},YPVlG:function(o,n){return o>>>n},NpZjT:function(o,n){return o>>>n},HiYnO:function(o,n){return o+n},vDXOa:function(o,n){return o<<n},UjQas:function(o,n){return o===n},kyegS:t(2043),FqpEq:function(o,n){return o>>>n},kcKkD:function(o,n){return o+n},KCuDH:function(o,n){return o+n},QLGEj:function(o,n){return o&n},fOISw:function(o,n){return o>>>n},hmRou:function(o,n){return o+n},JFzVh:function(o,n){return o>>>n},yTuHm:function(o,n){return o!==n},zjeGX:t(1341),pRNoC:t(1639),QBgsx:function(o,n){return o>=n},BvYfI:function(o,n){return o===n},tYwhJ:function(o,n){return o==n},JEoFh:t(1035),mrYWt:"xowJF",JgDht:function(o,n){return o!=n},WOMYI:function(o,n){return o===n},aEPUc:t(1279),VhQbY:"2|1|4|3|"+t(641),EOwzM:t(1673),VlVNv:t(988),xyTmy:"QwPsh",GXQcK:function(o,n){return o instanceof n},cRAdR:t(470)+t(1929),qfWwp:function(o,n){return o+n},koJlt:function(o,n){return o===n},eyCMz:function(o,n){return o===n},fptMg:function(o,n){return o<n},ILaQZ:"FRONTIER>",FCeyO:function(o,n){return o!==n},fOwUO:t(563),wcqNZ:t(1142),gvprM:t(1954),BaXgH:t(827),GSAux:t(727),IFVAo:function(o,n,i){return o(n,i)},JcBjS:function(o,n){return o<n},ifUdG:function(o,n,i){return o(n,i)},iLkyy:function(o,n){return o+n},HghWU:function(o,n){return o===n},aoAyK:t(593),feywY:"next() c"+t(1806)+t(834)+t(899)+"process",XLHMr:t(1645),RWvaM:t(2012)+"d",GzPJe:t(934)+"3",JbwrY:function(o,n){return o||n},COXmS:"DBWiA",leNcf:function(o,n){return o<=n},ZqnJN:function(o,n){return o+n},jFDum:function(o,n){return o<n},NhGuS:function(o,n){return o<n},ODIpV:function(o,n){return o&n},LsaLO:t(606),jpZzO:"Yzrhc",IMUhI:function(o,n){return o<=n},agBnY:function(o,n){return o<n},NaeHA:function(o,n){return o>=n},yAUwU:function(o,n){return o|n},DFWbq:function(o,n){return o&n},BRdzJ:function(o,n){return o<<n},ODSCc:function(o,n){return o>=n},ciIcx:function(o,n){return o-n},mTzvo:function(o,n){return o|n},kLmoj:function(o,n){return o|n},gulfv:function(o,n){return o&n},RWqZL:function(o,n){return o+n},wXbDx:function(o,n){return o<n},lyAWg:t(1251),AlvMF:t(1532),YKdAI:function(o,n){return o>>n},GQRIM:function(o,n){return o&n},FwBou:function(o,n){return o&n},bWOFr:function(o,n){return o+n},BtAvr:function(o,n){return o&n},DlxkP:function(o,n){return o|n},pvGGQ:function(o,n){return o&n},GOuPx:function(o,n){return o>>n},ZyuJm:function(o,n){return o+n},mVjTJ:function(o,n){return o<<n},SxNsT:function(o,n){return o|n},StYaA:function(o,n){return o>>n},tiSCJ:function(o,n){return o>>n},QMSFt:function(o,n){return o|n},ZEGCZ:function(o,n){return o-n},IOBQZ:t(1966),jJjNt:t(1805),TLvls:function(o,n){return o instanceof n},oCczz:t(542)+"ion/json",miUqR:t(804)+t(1326)+t(2038),jFfOB:t(1996),feuOd:t(1851),XmlsI:function(o,n){return o&n},JXCJz:function(o,n){return o>>n},dcsxw:function(o,n){return o|n},wROPl:function(o,n){return o>>n},ySNxH:function(o,n){return o===n},TGnuo:"ubvsR",VwPTL:function(o,n){return o+n},bfkBJ:function(o,n){return o||n},CeEPS:function(o,n){return o!==n},malfT:t(719),Ifyck:function(o,n){return o<n},aArlM:function(o,n){return o(n)},BsODS:t(1800),ZJupS:"amzgS",HQSJW:t(1011),RuIPh:"http",bgayN:"Vzldi",pzYJb:function(o,n){return o!==n},XntJn:t(1648)+t(1676),VlVKX:t(1414),nqfYx:function(o,n){return o!==n},lcVRN:t(1497),MfZAd:function(o,n){return o&n},UUBVd:function(o,n){return o<n},UAUsl:function(o,n){return o<<n},hdIeh:function(o,n){return o|n},LeLwB:function(o,n){return o<n},ZXupw:t(770),AsNWG:"complete",snKeS:t(2009),nFytw:"AbortError",NKBVb:function(o){return o()},QhNTB:function(o,n){return o===n},HcGVc:t(1092),sLAhd:function(o,n){return o!==n},fCNgJ:function(o,n){return o!==n},psZBi:t(1009),DdKRH:t(1655),gEoRB:t(1989),WXzoa:t(2003)+"3",niHes:function(o,n){return o+n},CmXzY:function(o,n){return o+n},SEnGe:function(o,n,i,f){return o(n,i,f)},yeFDN:function(o,n){return o<n},xdqLs:function(o,n){return o!==n},dwcTt:t(1588),dBAeA:t(1194),jYcKB:function(o,n){return o||n},mnCMc:function(o,n){return o<<n},EZAtW:function(o,n){return o<n},MfsrM:t(1274),OtHLW:function(o,n){return o===n},VDrst:"IQWVJ",XwFAP:function(o,n,i){return o(n,i)},POQin:function(o,n){return o!==n},QVFmA:t(1513),DZQNo:function(o,n){return o||n},cZkng:function(o,n){return o(n)},pPcGs:"ping_onc"+t(1369)+"s",voJIF:t(733)+t(1650)+"t",grSrU:function(o,n){return o!==n},NrsGN:t(1201),SWzOa:t(1874),aNPuO:function(o,n){return o||n},zzheR:function(o,n){return o!=n},QCLVT:t(1449),yPfNV:"qos",euBOu:t(1689)+"id",ikvKE:function(o,n){return o!==n},cMHOg:t(1948),UaDcy:function(o,n,i,f){return o(n,i,f)},UagsV:function(o,n,i,f){return o(n,i,f)},xgRtz:t(1294)+t(1620)+"ck",QDuTN:t(1294)+t(627)+"k",jrxYv:t(1294)+t(1253)+t(644),kOigZ:function(o,n,i,f){return o(n,i,f)},nbENA:t(831),CKsCv:"received",VwTMm:function(o){return o()},ZxQUL:function(o,n){return o&n},BTskC:function(o,n){return o+n},xaUZa:t(498),NHgaN:t(542)+t(775)+t(922)+t(550),jEake:t(1892),BGWAK:function(o,n,i,f){return o(n,i,f)},dGDdm:function(o,n){return o>n},RFuUg:function(o,n){return o+n},nCqzZ:function(o,n){return o(n)},HveLe:function(o,n){return o|n},buuNY:t(1828),ZWJtj:function(o,n){return o||n},yhQPW:function(o,n){return o(n)},GOYJf:function(o,n){return o+n},juLxV:t(958)+t(1240)+"ge: ",dgErN:t(1956),TVenI:function(o,n){return o||n},dKGxN:t(746),zrabw:function(o,n,i,f){return o(n,i,f)},AvDmD:function(o,n){return o+n},yKgUS:function(o,n){return o<<n},PadCr:t(1354)+"4",etHnY:function(o,n){return o+n},VzsZH:function(o,n){return o|n},omWUy:function(o,n){return o<<n},DseGv:function(o,n){return o+n},inpoe:function(o,n){return o+n},AeCGf:function(o,n){return o|n},uxjoN:function(o,n){return o|n},eycHM:function(o,n){return o<<n},NOePT:function(o,n){return o+n},vaqaq:function(o,n){return o<<n},EHnAh:function(o,n){return o+n},jHqzB:function(o,n){return o<<n},tuRch:function(o,n){return o+n},HQkpA:function(o,n){return o+n},PNKjn:function(o,n){return o&n},nFnET:function(o,n){return o+n},rhhUu:function(o,n){return o+n},RHjDs:t(1124),DrvpZ:function(o,n){return o+n},LyOqy:function(o,n){return o&n},NAMIl:t(1221)+"|2|5|11|7|1|9|6|4",pIEoN:function(o,n){return o>>>n},Trqos:function(o,n){return o<<n},FCKgP:function(o,n){return o&n},gJqvS:function(o,n){return o<n},sXBgC:function(o,n){return o|n},AUauW:function(o,n){return o<<n},rLPAG:function(o,n){return o(n)},jZFvW:t(1456)+t(1484)+t(556),Mojzo:t(1025)+t(1084),HanaD:"header",RNfel:function(o,n,i,f){return o(n,i,f)},zTQql:"service",KukqS:t(1003)+t(1160),rDGHv:function(o,n,i,f){return o(n,i,f)},QQQRI:"name",nQJhg:function(o,n){return o(n)},UPAbv:function(o,n,i){return o(n,i)},MBUPl:t(1015)+t(960),eqvHI:t(713)+t(1227),xKiYi:t(1303)+t(1287),IiSYO:t(893)+t(1085),zIrkL:"ALL",LSbca:"INSTANT",YeNtx:t(1286),ksVrE:function(o,n,i,f){return o(n,i,f)},zMjTf:"setdb",OXTxe:function(o,n){return o(n)},smFsm:function(o,n){return o===n},INNku:t(1529),qOMfJ:t(1343)+"r",UOvqW:function(o,n){return o===n},HcKwz:t(1945),itIae:function(o,n){return o>=n},pkPSV:function(o,n){return o===n},cbFOH:function(o,n){return o===n},PukHc:function(o,n){return o(n)},Zvhsy:"PPhlY",FuiNU:t(1104),CfaXE:function(o,n,i,f){return o(n,i,f)},gKawD:t(1864),kYyKk:t(1294)+t(882),OyWEG:t(1294)+t(1255),FEpWS:t(1976)+"s",pncYr:t(504)+t(2036)+"e",bcmLv:function(o,n){return o>n},qJMgK:function(o,n){return o+n},UNkyt:t(1568),uBUKu:function(o){return o()},UFlKK:t(1964),nAqwo:function(o,n){return o===n},CGlec:function(o,n){return o&&n},CWjuH:function(o,n,i){return o(n,i)},xOVbt:function(o){return o()},evuoR:function(o){return o()},TvNEm:function(o,n){return o(n)},JfKQM:function(o,n,i){return o(n,i)},OBmiT:function(o,n,i){return o(n,i)},xoyce:t(490),RPNGC:"tVdAW",XhVEH:function(o,n){return o!==n},SuRAP:function(o){return o()},vbfHU:function(o,n){return o<n},PVJvB:function(o,n){return o!==n},tVjSc:"odvBP",jQEIO:"QSpCI",WUAUK:"always",PKHuI:function(o,n){return o===n},NXoFX:t(1699),ozGrA:t(1687),zryHU:t(2013),NRcQL:function(o,n){return o===n},QrVGO:function(o,n,i){return o(n,i)},gkzAj:function(o,n,i){return o(n,i)},MVhKl:function(o,n){return o!==n},qTbsE:"EuJai",xQJsH:function(o,n){return o!==n},lIVWX:function(o,n,i){return o(n,i)},roMco:function(o,n){return o!==n},hXKGx:function(o,n,i){return o(n,i)},cjDpA:function(o,n){return o||n},wfxCL:function(o,n){return o===n},MUVMc:"versionc"+t(1997),YsZDP:"arraybuf"+t(1334),yBwaJ:t(1842),ReNSB:function(o,n){return o===n},eOJXq:t(697)+t(721)+t(972),KOZvv:function(o,n){return o+n},FZxME:function(o,n){return o|n},AGPRs:function(o,n){return o>>n},KOmii:function(o,n){return o===n},VMTIW:t(1181),FyIiU:t(1351),wmNEF:t(995)+"t",OmIwX:t(1096)+"ediately"+t(496)+"ct",brPGU:"online",bDCjJ:"pagehide",VDClF:t(1710),okoEv:function(o,n){return o&n},nZSes:function(o,n){return o&n},lmysC:function(o,n){return o>>>n},HPubo:function(o,n){return o>>>n},CpsLe:function(o,n){return o&n},VRGlB:function(o,n){return o&n},mxXMi:function(o,n){return o&n},LcftK:function(o,n){return o>>>n},lEJFV:"nSAhn",VyWlM:t(992),TZGaZ:t(1810),owyvz:t(860),uJvJQ:t(1838),syRsB:t(1126),MPBwc:"ttwid",yCkXv:t(697)+t(1022)+"ddID, de"+t(1770)+t(587),Tnxmc:t(1086),LioGT:function(o){return o()},xyOWN:function(o,n,i){return o(n,i)},yxtaY:t(1178),WubpM:t(1059)+t(1252)+t(1338),hbBDn:t(1706),EvjuJ:function(o,n,i){return o(n,i)},iYIeV:function(o,n){return o||n},khEAp:function(o,n,i){return o(n,i)},YWplB:t(859),irHET:function(o,n){return o-n},OogSG:function(o,n,i){return o(n,i)},gUrnU:t(1496),MsuUY:function(o,n){return o(n)},lQWeC:function(o,n){return o*n},zYIUx:function(o,n,i){return o(n,i)},znzwJ:function(o,n,i){return o(n,i)},Ezyzl:t(1642)+t(777)+t(995)+t(1347)+"ver",SIUrP:function(o,n){return o>n},KeGiI:function(o,n){return o>>>n},bIAol:function(o,n){return o|n},dTJVq:function(o,n){return o|n},aMteP:function(o,n){return o|n},eRaEi:function(o,n){return o!==n},EefqG:t(1982),hwiNj:function(o,n,i){return o(n,i)},fYeAz:function(o,n){return o!==n},ankzo:"BSlrk",XEjAr:t(913),pYljo:t(2058),vZrVN:function(o,n){return o(n)},PXdGE:"send_ack",bpOlT:function(o,n){return o|n},rtsPz:function(o,n){return o|n},yWdnc:function(o,n){return o<<n},SQpAy:function(o,n){return o&n},QiblK:t(1435),ueuHR:t(823)+"4",CGzyp:function(o,n){return o<<n},UhoCJ:function(o,n){return o===n},nspJC:t(1705),OJaGz:"qNaEL",PlzYC:"tgCuf",wcGuM:function(o,n,i){return o(n,i)},QbYwP:function(o,n,i){return o(n,i)},UjqYY:t(1642)+"ay, netw"+t(774)+t(590),KKFmz:"MHjVn",fCIwO:function(o,n){return o-n},yGAqy:function(o,n){return o!==n},iAmCb:t(1542),qkDXf:"close, ws instan"+t(835)+t(1069)+"ed",IVweD:function(o,n){return o===n},AVEVA:t(846)+"s alread"+t(1377),gUWib:t(697)+t(830)+" valid data, dat"+t(1400)+"e a stri"+t(1152)+t(467)+t(1815),AbxRB:"number",AFWWU:function(o,n){return o instanceof n},sGEkt:function(o,n){return o(n)},KGxdM:function(o,n){return o(n)},OAlBP:function(o,n){return o||n},BnjFw:function(o,n){return o instanceof n},XECsa:function(o,n){return o(n)},xxnhc:function(o,n){return o===n},miSFy:t(1195),xnvSW:t(1803),JtjUv:function(o,n){return o!==n},CmRWo:"manual r"+t(1674)+"ing",BZkMt:"3|4|1|0|2",llpOW:function(o,n,i){return o(n,i)},uJxWc:"UZmMc",pMuXU:t(1985),TZMZq:function(o,n){return o*n},JqTsb:function(o,n){return o!=n},vIqgw:t(849),fSBFE:function(o,n){return o!=n},QvkkS:function(o,n){return o===n},oyASu:t(916),WTSEx:function(o,n){return o===n},wcANZ:function(o,n){return o!=n},HOfgu:function(o,n){return o==n},JBWGx:function(o,n){return o!=n},SROiY:function(o,n){return o===n},rFgrv:t(1729)+t(1064)+"lobalScope",uVVXv:function(o,n){return o===n},etYcD:t(1659)+"rkerGlob"+t(1845),UsSsS:t(2023)+"orkerGlo"+t(1891),YDsVG:function(o,n){return o!=n},OeXVW:function(o,n){return o!=n},yTqMS:function(o,n){return o!=n},QSDaZ:t(989)+t(1890)};Ct.r(Se),Ct.d(Se,{FWS:()=>Ph,CustomErrorEvent:()=>d0,createCloseEvent:()=>ot,ReconnectEvent:()=>f0,createErrorEvent:()=>Qe,decodedFrame:()=>Fn,createOpenEvent:()=>g0,CustomCloseEvent:()=>u0,createReconnectEvent:()=>Do,FrontierMessageEvent:()=>x0,encodeFrame:()=>We,createMessageEvent:()=>p0,OpenEvent:()=>h0,ErrorCode:()=>jt,Event:()=>Hn,MessageEvent:()=>l0});let r="";function s(o=""){let n=t,i="02",f=""+Date[n(1557)](),u=r||(r=e.gCvxR(x,o)),h=Math[n(978)]()[n(918)](16).slice(-6);return e.MfWRH(e[n(1149)](e.MfWRH(i,f),u),h)}function a(){let o=t;return e[o(1149)](e[o(616)](1e4,Date.now()),Math[o(1801)](1e4*Math[o(978)]()))}function c(o){let n=t;return(e.ULIfS(Array,8).join("0")+parseInt(o,10).toString(2))[n(1029)](-8)}function d(o){let n=t;if(e[n(1574)](e.Wxjgt,e[n(956)])){let i=e.jzTZg[n(941)]("|"),f=0;for(;;){switch(i[f++]){case"0":this[n(1820)]=!0;continue;case"1":this[n(1403)+n(1125)]?.[n(1994)+n(1464)+"fig"]();continue;case"2":this._connect();continue;case"3":this["_readyCl"+n(1944)]=!1;continue;case"4":this[n(1345)+n(1290)]?.[n(1808)+"nter"]();continue}break}}else return e[n(1149)](e[n(951)](Array,4).join("0"),e[n(738)](parseInt,o,2).toString(16)).slice(-4)}function l(o){let n=t,i=o[n(941)](/\./)[n(572)](h=>c(h)),f=[];return f[0]=e[n(1276)](d,e[n(1149)](i[0],i[1])),f[1]=e.RWRpp(d,i[2]+i[3]),[e.DsudC,e[n(1784)],n(1141),e[n(1784)],e.DsudC,e[n(1547)],f[0],f[1]][n(1050)]("")}function x(o){let n=t,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}/.test(o),f=/(([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(1385)](o);return i?e[n(1862)](l,o):f?e[n(951)](p,o):n(1637)+"00000000"+n(1637)+n(1637)}function p(o){let n=t,i={wsKNA:function(M,K,$,W){return e[B(1981)](M,K,$,W)},HZPsR:function(M,K,$){return M(K,$)}},f="",u=[],h=0,m=0,_=!0,g=e[n(1784)];if(o[n(1266)]("::")>-1){let M=o.split("::");for(let $=0;e[n(661)]($,M[n(669)]);$++){let W=M[$];if(e.WtXrb(W[n(1266)](":"),0)){let ae=W[n(941)](":");_&&(h=ae[n(669)]),m+=ae[n(669)];for(let Q=0;e[n(1510)](Q,ae[n(669)]);Q++)if(e.MnaTd(4,ae[Q][n(669)]))if(e[n(549)](e[n(1297)],n(1506))){let xe=g[n(569)+"g"](0,e[n(931)](4,ae[Q][n(669)])),pn=xe[n(1951)](ae[Q]);u[n(737)](pn)}else{var T=_0x49d966[_0x18aa86];if(StRHGB.PZDar(void 0,T))return T[n(803)];var F=_0x4c340f[_0x17afc4]={exports:{}};return _0x25ddda[_0x33dcd6](F,F[n(803)],_0x467b65),F[n(803)]}else u.push(ae[Q]);_=!1}else{if(e[n(584)](4,W.length))if(e.lMEOg!==e[n(2016)])i[n(1392)](_0x1435ab,this,_0x368232,[_0x2ad7ce,_0x4f113d,_0x4b5adb,_0x48d1d6,_0x163e7e,_0x3e7208]);else{let ae=g[n(569)+"g"](0,e[n(1361)](4,W[n(669)])),Q=ae[n(1951)](W);u[n(737)](Q)}else u.push(W);_&&(h+=1),m+=1,_=!1}}let K="";for(let $=0;$<8-m;$++)K=K[n(1951)](g);for(let $=0;$<u[n(669)];$++)$===h&&(f=f[n(1951)](K)),f=f[n(1951)](u[$]);return f}if(e[n(2019)](e[n(1258)],e[n(1968)]))_0x1b55f9(_0x5265c6,82),i[n(1390)](_0x1b5e9e,_0x3f1a14,_0x2db7ff);else{let M=o[n(941)](":");for(let K=0;e.NPNwo(K,M[n(669)]);K++){let $=M[K];if(e[n(584)](4,M[K][n(669)])){let W=g[n(569)+"g"](0,4-M[K][n(669)]),ae=W[n(1951)]($);f=f.concat(ae)}else f=f[n(1951)]($)}return f}}function w(o,n){let i=t;if(e[i(1599)](e[i(1586)],e.zWPNb)){let{SeqID:f,LogID:u,service:h,LogIDNew:m,method:_}=_0xdc5d65.message;this[i(1115)]({SeqID:f,LogID:u,LogIDNew:m,service:h,method:_,headers:[{key:e.LhfrZ,value:"1"},{key:e.AumLf,value:e[i(894)](m,"")},{key:e.PFdLu,value:"0"}]})}else{let f=o[i(1543)];e[i(549)](void 0,f)&&(e[i(738)](Y,n,10),e[i(1617)](Be,n,f));let u=o[i(805)];if(e[i(1446)](void 0,u))if(e[i(2019)](i(1791),e[i(1969)]))try{return!!this[i(1269)]}catch(h){return _0x4f0278[i(780)](h),!1}else e[i(1412)](Y,n,18),e[i(1412)](Be,n,u)}}function v(o){let n=t,i={};e:for(;!e[n(951)](L,o);)if(e[n(1446)](e[n(531)],n(1932))){let f=_0x17a27c[n(632)+n(1364)](_0x590a05);return _0x860f83&&f[n(1799)+n(1422)](StRHGB[n(1911)],()=>_0x20df70()),StRHGB[n(1186)](_0xc94209,f)[n(2015)](()=>{})}else{let f=Ee(o);switch(e[n(1868)](f,3)){case 0:break e;case 1:i[n(1543)]=e[n(1089)](be,o,Ee(o));break;case 2:i.value=e[n(1288)](be,o,e[n(951)](Ee,o));break;default:e[n(1822)](D,o,e[n(1871)](7,f))}}if(i[n(1543)]===void 0)throw new Error(e.wDZqQ);if(e.AdipB(void 0,i[n(805)]))throw new Error(e[n(1218)]);return i}function I(o){let n=t,i=e[n(1394)](A);return e[n(1150)](b,o,i),e[n(1535)](z,i)}function b(o,n){let i=t,f={QytEX:function(Q,xe){return e[B(622)](Q,xe)},xIyDf:function(Q,xe){return e[B(1688)](Q,xe)},JJENn:function(Q,xe){return Q<=xe},itpyN:function(Q,xe){return Q+xe},EWMwn:function(Q,xe){return Q%xe},NFcqb:function(Q,xe){return e.gDfSG(Q,xe)},DeUNL:function(Q,xe){return e[B(1569)](Q,xe)}},u=o[i(1704)];e[i(584)](void 0,u)&&(e[i(1617)](Y,n,8),e[i(1460)](_e,n,u));let h=o[i(655)];h!==void 0&&(e[i(1460)](Y,n,16),e.JulAM(_e,n,h));let m=o[i(1991)];e[i(584)](void 0,m)&&(e.pdRvB(Y,n,24),_e(n,e[i(1027)](P,m)));let _=o[i(1075)];if(e.nDQKf(void 0,_))if(e[i(2019)](e[i(685)],e[i(685)]))Y(n,32),_e(n,e[i(1027)](P,_));else{if(f[i(1797)](_0x352560,_0x2fed2e))return _0x7b786d?_0x5657f3:_0x14f452;if(_0x5df655){if(f.xIyDf(_0x30004e,_0x419565))return _0x4ab6bd}else{if(f.JJENn(_0x32f3b8,-_0x560cec))return _0x59a14f;if(f.xIyDf(f[i(2040)](_0x491859,1),_0xbe371b))return _0x490bbd}return _0x49cd6c[i(1410)](f[i(887)](_0x75a6b8,_0x1bff22)|0,f[i(2004)](f[i(1333)](_0x2ead0e,_0x1aef01),0),_0x4280c8)}let g=o.headers;if(e[i(1068)](void 0,g))for(let Q of g){Y(n,42);let xe=e[i(1282)](A);e[i(1288)](w,Q,xe),Y(n,xe.limit),e.uGSUm(st,n,xe),e[i(736)](O,xe)}let T=o[i(1273)+i(1164)];T!==void 0&&(e[i(571)](Y,n,50),e.CGvVv(Be,n,T));let F=o[i(1817)+i(1118)];if(e[i(1882)](void 0,F)){if(e[i(584)](i(865),e.KxRhx))return e[i(1574)](-1,this[i(1014)])&&e.eYNOH(-1,this[i(1736)])?_0x420205[i(1410)](0,0,this.unsigned):e[i(1599)](-1,this[i(1014)])?_0x187981[i(1410)](0,e[i(1741)](this.high,1),this[i(837)]):_0x23ce76[i(1410)](this[i(1014)]+1,this[i(1736)],this[i(837)]);e[i(1829)](Y,n,58),e[i(1461)](Be,n,F)}let M=o[i(1063)];e[i(584)](void 0,M)&&(Y(n,66),e.UCciR(Y,n,M[i(669)]),e.sliwc(le,n,M));let K=o[i(1933)];K!==void 0&&(e[i(1822)](Y,n,74),Be(n,K));let $=o["serverTi"+i(1609)];e[i(1702)](void 0,$)&&(e[i(1822)](Y,n,82),e[i(1822)](Be,n,$));let W=o.msgID;W!==void 0&&(e[i(1875)](Y,n,90),Be(n,W));let ae=o[i(1097)+"e"];e[i(584)](void 0,ae)&&(e[i(1829)](Y,n,96),e[i(1412)](_e,n,e[i(1862)](P,ae)))}function E(o){let n=t;return e.XrGbX(S,e[n(1389)](U,o))}function S(o){let n=t,i={};e:for(;!e[n(1535)](L,o);){let f=e[n(736)](Ee,o);switch(e[n(1869)](f,3)){case 0:break e;case 1:i.SeqID=zn(o,!0);break;case 2:i[n(655)]=e[n(1829)](zn,o,!0);break;case 3:i[n(1991)]=e[n(1535)](Ee,o);break;case 4:i[n(1075)]=e[n(842)](Ee,o);break;case 5:if(e[n(1700)]!==e[n(788)]){let u=e.UTlom(C,o);(i[n(872)]||(i[n(872)]=[]))[n(737)](v(o)),o[n(1280)]=u;break}else{let u={ZZKTk:function(h,m,_,g,T){let F=n;return StRHGB[F(1500)](h,m,_,g,T)},CPuRv:function(h,m){return StRHGB.mLCRf(h,m)}};_0x5ae046[n(1799)+n(1422)](n(1166)+n(1356),h=>{let m=n;u[m(1793)](_0x7ac617,u.CPuRv(_0x10a131,_0x8407a5.result),h[m(1544)+"on"],h[m(815)+"on"],u[m(715)](_0x5adfe3,_0x4b7676[m(1930)+m(1715)]))})}case 6:i[n(1273)+n(1164)]=e[n(738)](be,o,Ee(o));break;case 7:i["payloadT"+n(1118)]=e[n(1875)](be,o,Ee(o));break;case 8:i.payload=e[n(751)](oe,o,e[n(951)](Ee,o));break;case 9:i.LogIDNew=e.PWlja(be,o,e[n(736)](Ee,o));break;case 10:i["serverTi"+n(1609)]=e[n(772)](be,o,e[n(1756)](Ee,o));break;case 11:i[n(2017)]=e.sDSBn(be,o,e[n(1661)](Ee,o));break;case 12:i[n(1097)+"e"]=e[n(1862)](Ee,o);break;default:e.owhvf(D,o,e.SIubn(7,f))}}if(e[n(1734)](void 0,i[n(1704)]))throw new Error(e[n(909)]);if(e.OzibG(void 0,i[n(655)]))throw new Error(e[n(1907)]);if(i.service===void 0)throw new Error(e.SaCec);if(i.method===void 0)throw new Error("Missing required"+n(1317)+n(1075));return i}function C(o){let n=t,i=e[n(1983)](Ee,o),f=o.limit;return o[n(1280)]=e.qdpTm(o[n(1885)],i),f}function D(o,n){let i=t;switch(n){case 0:for(;e.TPkwo(128,e.JYHot(Re,o)););break;case 2:k(o,e[i(1603)](Ee,o));break;case 5:e[i(1162)](k,o,4);break;case 1:k(o,8);break;default:throw new Error(e[i(679)](e[i(1900)],n))}}function P(o){let n=t;return o|=0,{low:o,high:o>>31,unsigned:e[n(787)](o,0)}}let y=[];function A(){let o=t,n=y[o(1841)]();return n?(n[o(1885)]=n[o(1280)]=0,n):{bytes:new Uint8Array(64),offset:0,limit:0}}function O(o){y[t(737)](o)}function U(o){return{bytes:o,offset:0,limit:o[t(669)]}}function z(o){let n=t,i=o[n(1654)],f=o[n(1280)];return e[n(1381)](i[n(669)],f)?i:i[n(915)](0,f)}function k(o,n){let i=t;if(e[i(1553)](e.dCLKi(o[i(1885)],n),o.limit))throw new Error(e[i(1518)]);o.offset+=n}function L(o){let n=t;return e[n(787)](o[n(1885)],o.limit)}function H(o,n){let i=t,f=o[i(1654)],u=o[i(1885)],h=o[i(1280)],m=e[i(1720)](u,n);if(e[i(1553)](m,f[i(669)])){let _=new Uint8Array(e[i(1967)](2,m));_[i(873)](f),o[i(1654)]=_}return o.offset=m,m>h&&(o[i(1280)]=m),u}function V(o,n){let i=t,f=o.offset;if(e[i(573)](f,n)>o.limit)throw new Error(e.WrQTz);return o[i(1885)]+=n,f}function oe(o,n){let i=t,f=e[i(826)](V,o,n);return o[i(1654)][i(915)](f,e[i(1827)](f,n))}function le(o,n){let i=t,f=e[i(1154)](H,o,n[i(669)]);o.bytes[i(873)](n,f)}function be(o,n){let i=t,f={wLNMf:function(T,F,M){return e.LfIcN(T,F,M)}},u=V(o,n),h=String[i(647)+i(712)],m=o.bytes,_="\uFFFD",g="";for(let T=0;T<n;T++){let F=m[e[i(801)](T,u)],M,K,$,W;e[i(936)](128,F)===0?g+=e[i(1389)](h,F):e[i(1381)](e.TPkwo(224,F),192)?e[i(1688)](e[i(801)](T,1),n)?g+=_:(M=m[e.jmrQH(e.jmrQH(T,u),1)],e[i(1702)](e[i(936)](192,M),128)?g+=_:(W=e[i(621)]((31&F)<<6,63&M),e.NPNwo(W,128)?g+=_:(g+=e[i(1276)](h,W),T++))):e[i(1847)](e[i(984)](240,F),224)?e[i(471)](e[i(1241)](T,2),n)?g+=_:(M=m[e.HYkuE(e.XLKpe(T,u),1)],K=m[e[i(1382)](e[i(967)](T,u),2)],e.hfQIk(e[i(1058)](e[i(534)](M,K<<8),49344),32896)?g+=_:(W=e[i(1049)](e.ZCUdX(e.YaSxI(15&F,12),e[i(529)](e[i(1563)](63,M),6)),e[i(1505)](63,K)),e[i(1510)](W,2048)||e[i(471)](W,55296)&&e[i(1199)](W,57343)?g+=_:(g+=e[i(1276)](h,W),T+=2))):e[i(1614)](248&F,240)?e[i(1426)](T,3)>=n?g+=_:(M=m[e[i(1877)](T+u,1)],K=m[T+u+2],$=m[e[i(1382)](T,u)+3],(e[i(847)](e[i(847)](M,e[i(601)](K,8)),e[i(499)]($,16))&12632256)!==8421504?g+=_:e[i(1999)]!==e.gzOLm?(W=e[i(701)](e.DgerD(e[i(635)](e[i(608)](7,F),18),e[i(762)](63,M)<<12)|(63&K)<<6,e[i(509)](63,$)),W<65536||e[i(1837)](W,1114111)?g+=_:(W-=65536,g+=e[i(1024)](h,(W>>10)+55296,e[i(607)](e[i(1537)](1023,W),56320)),T+=3)):f[i(1848)](_0x52c450,_0x3d94bc,this[i(1712)+"rvalValue"](_0xae5430))):g+=_}return g}function Be(o,n){let i=t,f={yTcbA:function(g,T){return e[B(1427)](g,T)},ahXby:function(g,T){return g|T}},u=n.length,h=0;for(let g=0;e[i(1226)](g,u);g++){let T=n[i(603)+"At"](g);e[i(695)](T,55296)&&e[i(1607)](T,56319)&&e[i(1427)](e[i(573)](g,1),u)&&(T=e.fcPkQ(e.RWQTL(T,10),n.charCodeAt(++g))-56613888),h+=e.wpOno(T,128)?1:e.NPNwo(T,2048)?2:e[i(1226)](T,65536)?3:4}e[i(1829)](Y,o,h);let m=H(o,h),_=o[i(1654)];for(let g=0;g<u;g++)if(e[i(1381)](e[i(711)],e.IkGrl)){let T=0,F={};for(let M=0;f[i(2056)](M,_0x190350[i(669)]);M++)F[_0x1d554d[M][i(1303)+"ame"]]=_0x2535ff(_0x3d91ed[M][i(1303)+i(1287)]),T+=14+F[_0x5704af[M][i(1303)+i(1287)]];return[T,F]}else{let T=n[i(603)+"At"](g);e[i(1146)](T,55296)&&T<=56319&&e[i(901)](g+1,u)&&(T=e.qMDaS(e[i(1741)](e[i(635)](T,10),n[i(603)+"At"](++g)),56613888)),e[i(705)](T,128)?_[m++]=T:e[i(1730)]===e[i(874)]?(this[i(615)]=!0,this[i(1014)]=f.ahXby(0,_0x300d40),this[i(1736)]=f[i(1905)](0,_0x8ae11e),this[i(837)]=!!_0x305df):(e[i(1226)](T,2048)?_[m++]=e[i(1173)](e[i(1526)](e[i(559)](T,6),31),192):(e[i(1093)](T,65536)?_[m++]=e[i(722)](e[i(1058)](T>>12,15),224):(_[m++]=e.GmxVn(e[i(559)](T,18),7)|240,_[m++]=e[i(534)](e[i(840)](e[i(559)](T,12),63),128)),_[m++]=e[i(984)](e[i(1670)](T,6),63)|128),_[m++]=e[i(1757)](e[i(660)](63,T),128))}}function st(o,n){let i=t,f=e[i(1844)](H,o,n.limit),u=o[i(1654)],h=n[i(1654)];for(let m=0,_=n[i(1280)];e[i(705)](m,_);m++)u[e[i(1877)](m,f)]=h[m]}function Re(o){let n=t;return o.bytes[e[n(1617)](V,o,1)]}function qt(o,n){let i=t,f=e.ZRHQQ(H,o,1);o[i(1654)][f]=n}function Ee(o){let n=t,i=0,f=0,u;do u=Re(o),i<32&&(f|=e[n(567)](127&u,i)),i+=7;while(e[n(840)](128,u));return f}function Y(o,n){let i=t;for(n>>>=0;e[i(471)](n,128);)e.DbFrt(qt,o,e.xvbTe(127,n)|128),n>>>=7;e[i(589)](qt,o,n)}function zn(o,n){let i=t,f=0,u=0,h=0,m;if(m=Re(o),f=e[i(1679)](127,m),e[i(2007)](128,m)){if(e[i(584)](e[i(1926)],e[i(1926)])){let _=_0x41f636(_0x34d67b,1);_0x1dface.bytes[_]=_0x3ac041}else if(m=e[i(1917)](Re,o),f|=e[i(744)](127&m,7),e.EtoXK(128,m))if(e.PZDar(e[i(1538)],e.Qqvgu))m=e[i(836)](Re,o),f|=e.dbmzx(e[i(660)](127,m),14),e.XhSMY(128,m)&&(m=e[i(551)](Re,o),f|=e[i(744)](e[i(1311)](127,m),21),e[i(1580)](128,m)&&(m=Re(o),u=127&m,e.bLucs(128,m)&&(m=e.ULIfS(Re,o),u|=e[i(744)](e[i(2007)](127,m),7),e[i(903)](128,m)&&(m=e[i(1533)](Re,o),u|=e.RWQTL(e[i(1311)](127,m),14),128&m&&(m=e[i(1186)](Re,o),u|=e[i(529)](127&m,21),e.JgkVP(128,m)&&(m=e[i(736)](Re,o),h=e[i(2007)](127,m),e[i(1148)](128,m)&&(m=e[i(1667)](Re,o),h|=e.SIubn(127,m)<<7)))))));else return 0}return{low:e[i(1173)](f,e.OXsLu(u,28)),high:e[i(621)](e.ZEyaO(u,4),h<<24),unsigned:n}}function _e(o,n){let i=t,f=e[i(1869)](n[i(1014)],0),u=e[i(1869)](e[i(1217)](n[i(1014)],28)|e.SMecC(n[i(1736)],4),0),h=n.high>>>24,m=h===0?u===0?e[i(901)](f,16384)?e[i(1601)](f,128)?1:2:e[i(735)](f,2097152)?3:4:e[i(1681)](u,16384)?e[i(1681)](u,128)?5:6:e[i(1102)](u,2097152)?7:8:e[i(705)](h,128)?9:10,_=e.QvDkk(H,o,m),g=o.bytes;switch(m){case 10:g[_+9]=e[i(660)](e[i(1217)](h,7),1);case 9:g[e.BLpzt(_,8)]=e[i(584)](9,m)?e[i(994)](128,h):e[i(1564)](127,h);case 8:g[e[i(1741)](_,7)]=e.MnaTd(8,m)?e.gDfSG(e[i(1881)](u,21),128):e[i(1311)](e[i(1868)](u,21),127);case 7:g[e[i(1958)](_,6)]=e.MnaTd(7,m)?e[i(1387)](e.nYjyy(u,14),128):e[i(1665)](e.plfvq(u,14),127);case 6:g[e[i(1889)](_,5)]=e[i(549)](6,m)?e[i(1259)](u,7)|128:e[i(984)](u>>>7,127);case 5:g[_+4]=e[i(486)](5,m)?e.DgerD(128,u):e[i(936)](127,u);case 4:g[e.vzdyH(_,3)]=e[i(1882)](4,m)?e[i(522)](f>>>21,128):e[i(537)](e[i(1869)](f,21),127);case 3:g[e[i(1889)](_,2)]=m!==3?e[i(1111)](e[i(1881)](f,14),128):e.rDzFq(f,14)&127;case 2:g[e[i(797)](_,1)]=m!==2?e[i(698)](f>>>7,128):e.LXDsC(e[i(1869)](f,7),127);case 1:g[_]=e[i(557)](1,m)?e[i(1768)](128,f):127&f}}function Fn(o){return e[t(1389)](E,o)}function We(o){return I(o)}let s0=65536,jx=e.pMuXU,Un=e[t(2005)](s0,s0),o0=e.lQWeC(Un,Un),a0=o0/2,Gt=String[t(907)+"e"].charCodeAt;class ce{constructor(n,i,f){let u=t;this[u(615)]=!0,this[u(1014)]=0|n,this[u(1736)]=e[u(1121)](0,i),this[u(837)]=!!f}static isLong(n){return n&&n.isLong===!0}static[t(1410)](n,i,f){return new ce(n,i,f)}static fromBytes(n,i,f){let u=t;return f?ce[u(1409)+u(1986)](n,i):ce[u(1409)+u(1071)](n,i)}static[t(1409)+"sLE"](n,i){let f=t;if(f(1380)===e.cZRTV)this[f(638)]++;else return new ce(e[f(1962)](e[f(689)](e[f(698)](n[0],e[f(1262)](n[1],8)),n[2]<<16),n[3]<<24),e[f(621)](e[f(1567)](n[4],e[f(1423)](n[5],8))|n[6]<<16,e.YaSxI(n[7],24)),i)}static[t(1409)+t(1071)](n,i){let f=t;return new ce(e[f(1757)](e.mnSYg(e[f(875)](e[f(2028)](n[4],24),n[5]<<16),n[6]<<8),n[7]),e[f(1752)](n[0]<<24,e[f(529)](n[1],16))|e.eSzrL(n[2],8)|n[3],i)}static[t(1572)](n){let i=t;return n===jx?c0:new ce(e.COmFU(e[i(1415)](e[i(930)](Gt.call(n,0),Gt[i(1299)](n,1)<<8),Gt[i(1299)](n,2)<<16)|e[i(529)](Gt[i(1299)](n,3),24),0),e[i(1008)](e[i(1387)](e.xEMgc(e[i(621)](Gt[i(1299)](n,4),Gt[i(1299)](n,5)<<8),e.LrTzX(Gt.call(n,6),16)),Gt[i(1299)](n,7)<<24),0),!0)}toHash(){let n=t;return String[n(647)+"Code"](e[n(984)](255,this[n(1014)]),e[n(790)](this[n(1014)],8)&255,e.SIubn(e[n(1721)](this.low,16),255),e[n(1521)](this.low,24),e[n(1871)](255,this[n(1736)]),e[n(1230)](e[n(1217)](this[n(1736)],8),255),e[n(1537)](this[n(1736)]>>>16,255),e[n(987)](this[n(1736)],24))}static[t(629)+"er"](n,i=!0){let f=t;if(e.rHObD(f(1135),e.TEKpu)){if(e[f(1130)](isNaN,n))return i?Wx:c0;if(i){if(e[f(891)](n,o0))return $x}else{if(n<=-a0)return Vx;if(e[f(492)](e[f(1149)](n,1),a0))return Kx}return ce[f(1410)](e[f(465)](e.EKwOd(n,Un),0),e[f(522)](n/Un,0),i)}else{let u=e[f(1656)](_0x58077b,_0x451480),h=_0x1dfa87[f(1280)];return _0x44ce65[f(1280)]=_0xfa8091.offset+u,h}}[t(1782)](){let n=t;if(e.hhndd(e.tBnoQ,e[n(1030)]))return this[n(837)]?e[n(1967)](e.soIrx(this[n(1736)],0),Un)+e[n(1961)](this[n(1014)],0):e.dCLKi(e.DfTIy(this.high,Un),e[n(1008)](this.low,0));_0x2266e9[n(1787)][n(1765)+n(1374)](_0x368996)}[t(1056)](){let n=t;if(e[n(1599)](e.trMYe,e[n(937)]))return e[n(1599)](0,this[n(1736)])&&e[n(604)](0,this[n(1014)]);e[n(1983)](_0x324cbc,this[n(1413)+n(732)+"Id"]),e[n(951)](_0x2810c9,this[n(1745)+"ctTimeou"+n(1080)]),this[n(1413)+n(732)+"Id"]=null,this[n(1745)+n(1548)+n(1080)]=null}[t(2e3)](n){let i=t;ce.isLong(n)||(n=ce[i(629)+"er"](n));let f=e[i(1869)](this[i(1736)],16),u=e[i(1580)](65535,this[i(1736)]),h=this[i(1014)]>>>16,m=e[i(1047)](65535,this[i(1014)]),_=e.FgYZL(n.high,16),g=65535&n[i(1736)],T=e[i(1222)](n[i(1014)],16),F=e.cdodm(65535,n[i(1014)]),M=0,K=0,$=0,W=0;return W+=e.Lbzkn(m,F),$+=e[i(1131)](W,16),W&=65535,$+=e[i(1291)](h,T),K+=e[i(671)]($,16),$&=65535,K+=e.pNDgh(u,g),M+=K>>>16,K&=65535,M+=e[i(679)](f,_),M&=65535,ce[i(1410)](e[i(1196)](e.RWQTL($,16),W),e[i(1128)](e[i(1301)](M,16),K),this[i(837)])}[t(1575)](n){let i=t;return ce.isLong(n)||(n=ce[i(629)+"er"](n)),e[i(1882)](this[i(837)],n[i(837)])&&e[i(1231)](this[i(1736)]>>>31,1)&&e[i(1545)](e[i(1970)](n[i(1736)],31),1)?!1:e[i(659)](this[i(1736)],n[i(1736)])&&e[i(604)](this[i(1014)],n[i(1014)])}addOne(){let n=t;return this.low===-1&&e[n(1599)](-1,this[n(1736)])?ce[n(1410)](0,0,this[n(837)]):e[n(1153)](-1,this[n(1014)])?ce[n(1410)](0,this[n(1736)]+1,this[n(837)]):ce[n(1410)](this.low+1,this[n(1736)],this[n(837)])}[t(1813)](n){return n?this[t(1812)+"E"]():this.toBytesBE()}[t(1812)+"E"](){let n=t,i=this[n(1736)],f=this[n(1014)];return[e[n(660)](255,f),e.WmCAr(f>>>8,255),e[n(1224)](f,16)&255,e[n(790)](f,24),e[n(1157)](255,i),e.ayYOQ(e[n(1585)](i,8),255),e[n(1850)](i>>>16,255),i>>>24]}[t(897)+"E"](){let n=t,i=this[n(1736)],f=this.low;return[e[n(516)](i,24),e[n(1455)](i,16)&255,e.FqdUz(i>>>8,255),e[n(1835)](255,i),e[n(516)](f,24),e[n(984)](e[n(1008)](f,16),255),e[n(2047)](f,8)&255,e[n(762)](255,f)]}}let c0=new ce(0,0,!1),Wx=new ce(0,0,!0),Kx=ce.fromBits(-1,2147483647,!1),$x=ce[t(1410)](-1,-1,!0),Vx=ce[t(1410)](0,-2147483648,!1);var jt=(function(o){let n=t;if(e[n(1882)](e.pJUAN,e[n(1109)]))return this[n(912)+n(796)+n(1495)+"t"]=1,this[n(670)+n(1321)]++,this[n(579)+"s"][this["currentI"+n(1321)]];{let i=e[n(1977)].split("|"),f=0;for(;;){switch(i[f++]){case"0":return o;case"1":o[o[e.CkjbI]=5005]=e[n(506)];continue;case"2":o[o[e.VQGlU]=5003]=e[n(1309)];continue;case"3":o[o[e[n(917)]]=5001]=e[n(917)];continue;case"4":o[o[e.HGOiE]=5004]=e.HGOiE;continue;case"5":o[o[e[n(485)]]=5002]=e[n(485)];continue}break}}})({});class Hn{constructor(n){let i=t;e[i(1190)](i(866),e[i(2049)])?this[i(1095)]&&this[i(1095)].close({code:_0x4c770e,reason:_0x5cd96d}):(this[i(1587)]=n,this[i(1046)]=null)}}class f0 extends Hn{constructor(n,i){let f=t;super(n),this[f(827)]=i&&i.message||null}}class d0 extends Hn{constructor(n,i){let f=t;super(n),this.error=i&&i[f(988)]||null,this.colno=i&&i[f(833)]||0,this[f(596)]=i&&i[f(596)]||"",this[f(824)]=i&&i[f(824)]||0,this[f(827)]=i&&i[f(827)]||"",this[f(1864)]=i&&i.code||5001}}class u0 extends Hn{constructor(n,i){let f=t,u=e[f(1512)][f(941)]("|"),h=0;for(;;){switch(u[h++]){case"0":this[f(1864)]=i&&i[f(1864)]||0;continue;case"1":this.reason=i&&i[f(1676)]||"";continue;case"2":super(n);continue;case"3":this[f(1925)+"nnect"]=i&&i[f(1925)+f(636)]||!1;continue;case"4":this.wasClean=i&&i[f(491)]||!1;continue}break}}}class l0 extends Hn{constructor(n,i){let f=t;super(n),this[f(1366)]=i&&i[f(1366)]||null}}class x0 extends l0{constructor(n,i){let f=t;super(n),this.data=i&&i.data||null,this.message=i&&i[f(827)]||null}}class h0 extends Hn{constructor(n,i){let f=t;super(n),this.data=i&&i[f(1366)]||null}}function Qe(o,{message:n,code:i,error:f}){let u=t;if(e[u(1182)](u(1716),e[u(1055)])){_0x19b101[u(615)](_0x5d508f)||(_0x10a766=_0x499afa[u(629)+"er"](_0xd460c7));let h=this.high>>>16,m=e[u(892)](65535,this[u(1736)]),_=e[u(1540)](this[u(1014)],16),g=e[u(1405)](65535,this[u(1014)]),T=e[u(1131)](_0x25d777.high,16),F=65535&_0x3dc49d[u(1736)],M=e.bnBLV(_0xe17138[u(1014)],16),K=e[u(1893)](65535,_0x4fe81e[u(1014)]),$=0,W=0,ae=0,Q=0;return Q+=e.hYGRG(g,K),ae+=e.YPVlG(Q,16),Q&=65535,ae+=_+M,W+=e.NpZjT(ae,16),ae&=65535,W+=e[u(844)](m,F),$+=e[u(1131)](W,16),W&=65535,$+=h+T,$&=65535,_0x29b5b5[u(1410)](ae<<16|Q,e[u(621)](e.vDXOa($,16),W),this[u(837)])}else return new d0(o,{message:n,code:i,error:f})}function ot(o,{code:n,reason:i,wasClean:f,willReconnect:u}){return new u0(o,{code:n,reason:i,wasClean:f,willReconnect:u})}function p0(o,{data:n,message:i}){return new x0(o,{data:n,message:i})}function g0(o,{data:n}){return new h0(o,{data:n})}function Do(o,{message:n}){return new f0(o,{message:n})}class m0{constructor(n,i){let f=t;this[f(579)+"s"]=n,this[f(1485)+"es"]=i,this["currentI"+f(1321)]=0,this[f(912)+f(796)+f(1495)+"t"]=0}[t(1994)+"pointCon"+t(672)](){let n=t;this["currentI"+n(1321)]=0,this[n(912)+"ndpointT"+n(1495)+"t"]=0}[t(487)+"es"](){let n=t;this[n(912)+n(796)+n(1495)+"t"]=0}[t(946)+t(1652)+"nt"](){let n=t;return this[n(579)+"s"][this["currentI"+n(1321)]]}[t(946)+"ntEndpoi"+t(514)+t(1694)](){let n=t;if(e.yTuHm(e[n(1234)],e.pRNoC))return this["currentE"+n(796)+n(1495)+"t"];{let i=_0x22e699[n(1014)],f=_0x3a74cf.high;return _0x228493[_0x5aa892]=e[n(1259)](f,24),_0x5fdf33[_0x2f86e5+1]=e[n(1665)](e[n(1455)](f,16),255),_0xef76bf[e[n(760)](_0x59845f,2)]=e[n(1434)](e.FqpEq(f,8),255),_0x34a735[e.kcKkD(_0x589bfd,3)]=e[n(1563)](255,f),_0x4ca041[e[n(1232)](_0x10e4da,4)]=e[n(1521)](i,24),_0x2a3bd6[e[n(573)](_0x273b35,5)]=e.QLGEj(e.fOISw(i,16),255),_0x189c41[e[n(1312)](_0x142bb6,6)]=e[n(822)](i,8)&255,_0x45c17d[e[n(1175)](_0xf6e274,7)]=255&i,_0x5c6d86+=8,_0x186a37}}[t(476)+"chMaxTries"](){let n=t;return!!(e[n(1636)](this[n(670)+n(1321)],this.endpoints[n(669)])||this[n(670)+n(1321)]===this[n(579)+"s"][n(669)]-1&&e[n(927)](this[n(912)+"ndpointT"+n(1495)+"t"],this.maxRetries))}[t(1758)+t(1491)+t(1728)+"hedMaxRe"+t(1017)](){let n=t;return e[n(1558)](this[n(670)+n(1321)],this[n(579)+"s"][n(669)])?!0:e[n(1837)](this[n(912)+"ndpointTriesCount"],this[n(1485)+"es"])}["replaceB"+t(1305)+t(1306)+t(1189)+"unt"](){let n=t,i={ijRQS:function(f,u){return f<u},bhXPg:function(f,u){return e[B(1553)](f,u)},yKOTR:function(f,u){return e[B(801)](f,u)}};if(e[n(659)](e[n(2027)],e[n(1554)])){if(i[n(798)](_0x200d87,1)||_0x23e4e7>_0x3696cb)return _0x5b5748(_0x12373a);i[n(1134)](_0x3599fc+_0x29be94,_0x474354)&&(_0xd4a673=_0x2d200e(_0x4eaaaa),_0x35f127=0);let f=_0x4203cb.call(_0x4daaad,_0x4bab43,_0x3dc5ad+=_0x1407fd);return 7&_0x3fc05d&&(_0x2f7b18=i[n(1566)](7|_0x34005b,1)),f}else return this[n(912)+n(796)+n(1495)+"t"]=1,this[n(670)+"ndex"]++,this[n(579)+"s"][this.currentIndex]}[t(946)+t(1652)+"ntAndUpd"+t(1281)](){let n=t;return this[n(912)+n(796)+n(1495)+"t"]++,this[n(946)+n(1652)+"nt"]()}}let qn=(e[t(1228)](t(2012)+"d",typeof globalThis)&&e.CkOan(e[t(1210)],globalThis.constructor[t(1084)])||e.RWvaM!=typeof window&&e.nAqwo(e[t(1210)],window["construc"+t(1824)][t(1084)]))&&e.RWvaM!=typeof document,hn=e.fSBFE(e.RWvaM,typeof globalThis)&&(e[t(1972)](e[t(1598)],globalThis[t(1895)+"tor"][t(1084)])||e.WTSEx(t(1729)+t(1064)+"lobalScope",globalThis[t(1895)+"tor"].name))&&e[t(920)](e[t(1701)],typeof tt),Dr=(e[t(1247)](e[t(1701)],typeof globalThis)&&e.oyASu===globalThis["construc"+t(1824)].name||e[t(782)](e[t(1701)],typeof globalThis)||e[t(852)](e[t(1701)],typeof globalThis)&&!!globalThis[t(1417)+t(1051)])&&e[t(1247)](t(2012)+"d",typeof wx),kr=e[t(1247)](e[t(1701)],typeof globalThis)&&(e[t(1447)](e.rFgrv,globalThis[t(1895)+t(1824)][t(1084)])||e[t(807)](e[t(489)],globalThis[t(1895)+t(1824)][t(1084)])||e[t(1545)](e[t(1863)],globalThis[t(1895)+t(1824)][t(1084)]))&&e.fSBFE(e[t(1701)],typeof self),Zx=e.YDsVG("undefined",typeof globalThis)&&t(916)===globalThis[t(1895)+t(1824)][t(1084)]&&e[t(1560)](e[t(1701)],typeof global)&&e.HghWU(t(916),global[t(1895)+t(1824)].name)&&e.yTqMS(e.RWvaM,typeof process)&&!!process[t(1129)];class ko{constructor(){let n=t,i={eiwDY:function(f,u){return e[B(1878)](f,u)},ptZMK:n(1805),QRtvv:function(f,u){return f instanceof u},jeIZu:function(f,u){return e[n(1878)](f,u)}};if(e.WOMYI(e[n(710)],e[n(710)]))this[n(1023)+"rs"]={};else return i.eiwDY(i[n(1949)],typeof _0x49df8f)&&(_0x2f0870 instanceof _0x10ce0d||_0x2a7b1d.buffer&&i[n(1204)](_0x5db8bd.buffer,_0x96ba0e))||i[n(1998)](i[n(1949)],typeof _0x50731d)?"":(_0x592949[n(1348)](_0x1e5627),n(542)+"ion/json")}[t(1322)](n,...i){let f=t,u={YOmWt:function(h,m){return e[B(549)](h,m)},Gpyss:function(h,m){return e.UuwtO(h,m)},yTdDY:function(h,m){return h>>>m},xclaW:e[f(1358)],Vadix:e[f(485)],JHVLG:e[f(917)],xPQaP:e[f(1309)]};if(e[f(1353)]==="NCWHo"){let h=this[f(1023)+"rs"][n];if(h)h.slice().forEach(m=>m.fn.apply(m[f(528)],i));else if(e.VlVNv===n&&!this[f(464)]){if(e[f(549)](e[f(1626)],f(546)))return _0x5f544c.isLong(_0xa84cc0)||(_0x4090e9=_0x9c2786[f(629)+"er"](_0x2f87d6)),eEMALB[f(1711)](this[f(837)],_0x4e6740[f(837)])&&eEMALB.Gpyss(this[f(1736)]>>>31,1)&&eEMALB[f(1337)](_0x31e346[f(1736)],31)===1?!1:eEMALB.Gpyss(this[f(1736)],_0x1781c0[f(1736)])&&eEMALB.Gpyss(this[f(1014)],_0xced5e3[f(1014)]);{let m=i[f(669)]&&i[0];if(e.GXQcK(m,Error))throw m;let _=new Error(e.cRAdR+(m?e[f(1720)](e[f(1184)](" (",m[f(827)]),")"):""));throw _[f(779)]=m,m}}return this}else{let h=u[f(1839)][f(941)]("|"),m=0;for(;;){switch(h[m++]){case"0":return _0x1c715c;case"1":_0x129668[_0x1c5c67[eEMALB[f(1471)]]=5002]=eEMALB[f(1471)];continue;case"2":_0x4fd115[_0x1eff0b[eEMALB[f(752)]]=5001]=eEMALB[f(752)];continue;case"3":_0x8d7ba8[_0x4bc34a.MESSAGE_ERROR=5004]=f(1421)+f(1971);continue;case"4":_0x79ab46[_0x163534[eEMALB[f(2054)]]=5003]=f(2039)+f(1462)+"R";continue;case"5":_0x562cb2[_0x41283e.OPEN_ERROR=5005]=f(990)+"OR";continue}break}}}off(n,i){let f=t;if(e[f(1979)](void 0,n))this[f(1023)+"rs"]={};else if(e[f(1242)](void 0,i))this[f(1023)+"rs"][n]=null;else{let u=this._listeners[n];if(u)for(let h=0;e[f(714)](h,u[f(669)]);)u[h].fn===i?u[f(1264)](h,1):++h}return this}on(n,i,f){let u=t;if(e[u(940)](e[u(1359)],u(633)))return(this[u(1023)+"rs"][n]||(this[u(1023)+"rs"][n]=[]))[u(737)]({fn:i,ctx:f||this}),this;this[u(898)].debug&&_0x26ce8b[u(780)][u(1551)](_0x1569e4,[e[u(828)],..._0x1a6f67])}}class Jx extends ko{[t(1592)+t(725)+t(925)](n){let i=t;return n[i(501)]||n.errNo?(i(1137)+" "+(n[i(501)]||"")+i(1257)+(n.errNo||""))[i(1010)]():JSON.stringify(n)}constructor(n,i,f){let u=t;super(),this._socket=null,Dr&&wx[u(512)+u(1774)]&&(this._socket=wx[u(512)+u(1774)]({url:n,protocols:i,header:f,fail:this[u(1914)+u(484)+u(1936)][u(993)](this),success:this[u(1914)+"ocketSuc"+u(1116)+u(665)].bind(this)})),hn&&tt[u(512)+u(1774)]&&(this[u(1095)]=tt[u(512)+u(1774)]({url:n,protocols:i,header:f,fail:this[u(1914)+"ocketFai"+u(1936)].bind(this),success:this[u(1914)+u(1984)+u(1116)+"ler"][u(993)](this)}))}["_createS"+t(1984)+t(1116)+t(665)](){let n=t;Promise[n(1499)]()[n(2015)](()=>{let i=n;this[i(1193)+i(1763)]()})}["_createSocketFai"+t(1936)](n){let i=t,f={QuKva:function(u,h,m){return e[B(1844)](u,h,m)},PfeHs:e[i(2031)],ofBZI:e[i(1077)]};Promise[i(1499)]()[i(2015)](()=>{let u=i,h=f.QuKva(Qe,f.PfeHs,{message:this[u(1592)+"rrorMessage"](n)});this.emit(f[u(982)],h);let m=f[u(825)](ot,f[u(1531)],{reason:this[u(1592)+"rrorMessage"](n)});this[u(1322)](f[u(1531)],m)})}["_addWsLi"+t(1763)](){let n=t,i={wPeTU:e[n(707)],mOjVC:function(f,u,h){return e[n(985)](f,u,h)},nfjCn:function(f,u){return e.JcBjS(f,u)},MQTEP:function(f,u){return f>>>u},JBPac:function(f,u){return f<<u}};this[n(1095)].onOpen(f=>{let u=n;this[u(1322)](i.wPeTU,i[u(1289)](g0,i[u(1179)],{...f,data:f[u(501)]||""}))}),this[n(1095)][n(938)](f=>{let u=n;if(e[u(1732)]===e[u(1732)])this[u(1322)](e[u(1077)],e[u(1739)](ot,u(1142),{...f}));else{let h=0,m=_0x25daea,_=_0x100ad5+4;for(;i[u(784)](m,_);){let{value:g,offset:T}=i[u(1289)](_0x5c44c1,_0x362eb8,m);m=T,h=i[u(1856)](i[u(841)](h,8),0),h+=g}return{value:h,offset:_}}}),this[n(1095)].onMessage(f=>{let u=n;this[u(1322)](e[u(1555)],p0("message",{...f}))}),this[n(1095)].onError(f=>{let u=n;this.emit(u(988),e[u(1108)](Qe,e[u(2031)],{...f,message:f[u(501)]||""}))})}send(n){let i=t,f={obOCS:e[i(2031)]};if(e[i(1018)](n,Uint8Array)){let u=n[i(1293)][i(1029)](n[i(716)+"et"],e.iLkyy(n[i(1725)+"th"],n[i(716)+"et"]));this._socket&&this[i(1095)].send({data:u,fail:h=>{let m=i;this[m(1322)](m(988),e[m(1849)](Qe,e[m(2031)],{message:this[m(1592)+m(725)+m(925)](h)}))}})}else this[i(1095)]&&this[i(1095)].send({data:n,fail:u=>{let h=i;this[h(1322)](f[h(1145)],Qe(h(988),{message:this["_formatE"+h(725)+h(925)](u)}))}})}[t(1142)](n,i){let f=t;this[f(1095)]&&this[f(1095)][f(1142)]({code:n,reason:i})}[t(1799)+t(1422)](n,i){let f=t;if(e[f(878)](f(593),e.aoAyK))this.on(n,i);else{let u={BrsKl:e[f(2031)],FNnAW:function(h,m,_){return e[f(571)](h,m,_)}};if(e[f(1018)](_0x43a823,_0x19c2a6)){let h=_0x7b2e3a.buffer.slice(_0x1195f1.byteOffset,_0x2bb244.byteLength+_0x1d23ec.byteOffset);this[f(1095)]&&this[f(1095)].send({data:h,fail:m=>{let _=f;this.emit(u[_(1796)],u[_(1246)](_0x1b493b,u[_(1796)],{message:this[_(1592)+"rrorMess"+_(925)](m)}))}})}else this[f(1095)]&&this[f(1095)][f(1211)]({data:_0x2be690,fail:h=>{let m=f;this[m(1322)](u[m(1796)],_0x19c363(u[m(1796)],{message:this[m(1592)+m(725)+m(925)](h)}))}})}}[t(1597)+t(1759)+t(1094)](n,i){let f=t,u={QywrH:e[f(949)],OMxIl:function(h,m){return e[f(1190)](h,m)},LyVcm:function(h,m){return h+m}};if(f(2052)!==e.XLHMr)this[f(488)](n,i);else return _0x5cb7c2<=_0x49fe47?_0x477d11[f(1867)](new _0x213b4e(u[f(720)])):(_0x9d1b9c=_0x2e24b8,u[f(1727)](_0x1a4049,_0x144dc0.length)?_0x4ff8af[f(1499)]():_0x2640dd[_0x2e71fb][f(993)](_0x2713c5)(_0x2dd698,_0x480581[f(993)](null,u[f(1671)](_0x2500ab,1))))}get readyState(){let n=t;return this[n(1095)][n(1644)+"te"]}get[t(1662)+"pe"](){let n=t;return this[n(1095)][n(1662)+"pe"]}set[t(1662)+"pe"](n){}get[t(1278)](){let n=t;return this[n(1095)][n(1278)]}get[t(808)](){return this[t(1095)].protocol}get[t(1696)+"ns"](){let n=t;return this[n(1095)][n(1696)+"ns"]}get[t(1424)+t(726)](){return 0}}function Yx(o,n){let i=t;if(n)return new n(o[i(1278)],o[i(808)]);if(Dr||hn)return new Jx(o.url,o[i(808)],o[i(872)]);if(e[i(894)](qn,kr)&&e[i(1878)](e.RWvaM,typeof WebSocket)&&WebSocket)return new WebSocket(o.url,o[i(808)+"s"])}function Xx(o){let n=t,i=e[n(1203)][n(941)]("|"),f=0;for(;;){switch(i[f++]){case"0":if(e[n(1076)](qn,kr)&&e.JgDht(e[n(1701)],typeof WebSocket)&&WebSocket)return!0;continue;case"1":if(hn&&tt[n(512)+n(1774)])return!0;continue;case"2":if(Dr&&wx[n(512)+n(1774)])return!0;continue;case"3":return!1;case"4":if(o)return!0;continue}break}}function w0(o,n,i){let f=t,u={NsCGC:function(_,g){return e[B(1190)](_,g)},fFZXv:e[f(1036)],slAQe:function(_,g){return e[f(881)](_,g)},XVjfQ:function(_,g){return _===g},yZpUy:function(_,g){return e[f(1048)](_,g)}},h=-1;async function m(_){let g=f;return u[g(1362)](u.fFZXv,"DBWiA")?u.slAQe(_,h)?Promise[g(1867)](new Error(g(1960)+g(1806)+g(834)+"imes in process")):(h=_,u[g(2030)](_,i[g(669)])?Promise[g(1499)]():i[_][g(993)](o)(n,m[g(993)](null,u.yZpUy(_,1)))):this._ws?this[g(1260)][g(1644)+"te"]:this[g(898)][g(1480)+g(2042)]?this[g(1042)+"NG"]:this[g(1123)]}e[f(1535)](m,0)}function _0(o){let n=t,i=0,f=0;for(let u=0;e[n(661)](u,o.length);++u)f=o[n(603)+"At"](u),e.jFDum(f,128)?i+=1:e[n(975)](f,2048)?i+=2:e[n(927)](e[n(1893)](64512,f),55296)&&e[n(1734)](e[n(1261)](64512,o[n(603)+"At"](e.djQwm(u,1))),56320)?(++u,i+=4):i+=3;return i}function y0(o,n,i){let f=t,u={xQjWU:function(m,_){return m!==_},FuYbn:function(m,_){return e.qMDaS(m,_)}};if(e[f(705)](e[f(1361)](i,n),1))return"";let h="";for(let m=n;e.JcBjS(m,i);)if(e[f(604)](e[f(1584)],e[f(765)])){let _=_0x56d765[_0x4b430c];if(NsRKsf[f(611)](4,_0x5c50ba[_0x47726b][f(669)])){let g=_0x3fbed2[f(569)+"g"](0,NsRKsf.FuYbn(4,_0xf25ed[_0x24318f].length)),T=g[f(1951)](_);_0x589cae=_0x55e248[f(1951)](T)}else _0x464119=_0x502337[f(1951)](_)}else{let _=o[m++];if(e[f(1268)](_,127))h+=String[f(647)+f(712)](_);else if(_>=192&&e.agBnY(_,224))h+=String[f(647)+"Code"](e[f(1423)](31&_,6)|63&o[m++]);else if(e[f(812)](_,224)&&e[f(975)](_,240))h+=String[f(647)+f(712)](e[f(650)](e.QlDIS(e[f(541)](15,_)<<12,e[f(1451)](63&o[m++],6)),e[f(1526)](63,o[m++])));else if(e[f(1753)](_,240)){let g=e[f(1467)](e.mTzvo(e[f(745)](e[f(942)](e[f(1580)](7,_)<<18,e[f(2028)](63&o[m++],12)),(63&o[m++])<<6),e[f(1530)](63,o[m++])),65536);h+=String[f(647)+"Code"](e[f(1720)](55296,e[f(1670)](g,10))),h+=String["fromChar"+f(712)](e.RWqZL(56320,e[f(984)](1023,g)))}}return h}function Oo(o,n,i){let f=t,u=i,h,m;for(let _=0;e[f(1669)](_,o.length);++_)if(h=o[f(603)+"At"](_),h<128)n[i++]=h;else if(e[f(871)](h,2048)){if(e.zBBgT(e[f(623)],e.AlvMF))throw this[f(651)+f(663)]=!1,_0x146a6b;n[i++]=e.YKdAI(h,6)|192,n[i++]=e[f(1049)](e[f(1479)](63,h),128)}else if(e[f(1545)](e.gulfv(64512,h),55296)&&e.UjQas(e[f(1766)](64512,m=o[f(603)+"At"](e.bWOFr(_,1))),56320)){let g="4|3|5|2|1|0"[f(941)]("|"),T=0;for(;;){switch(g[T++]){case"0":n[i++]=e[f(2051)](63,h)|128;continue;case"1":n[i++]=e[f(1415)](e[f(885)](e[f(469)](h,6),63),128);continue;case"2":n[i++]=e[f(800)](e[f(649)](e[f(1600)](h,12),63),128);continue;case"3":++_;continue;case"4":h=e[f(1344)](65536+e[f(680)](1023&h,10),1023&m);continue;case"5":n[i++]=h>>18|240;continue}break}}else n[i++]=e[f(926)](e[f(1335)](h,12),224),n[i++]=e[f(1173)](e[f(1879)](e[f(1769)](h,6),63),128),n[i++]=e[f(510)](e[f(1835)](63,h),128);return e[f(580)](i,u)}async function b0(o){let n=t,i={Cjzmq:function(f,u){return e[B(894)](f,u)}};if(e.HEYeA(e[n(1623)],e[n(1623)])){let f=this[n(1269)][n(1002)+n(1370)](this[n(518)]),u=_0x21db30[n(1348)](i[n(1723)](f,"{}"));return u[_0x3951ad]=void 0,this[n(1269)][n(996)+"geSync"](this._prefix,_0x21de34.stringify(u))}else{if(e[n(1558)]("string",typeof o)){let f=new Uint8Array(_0(o));return Oo(o,f,0),f}return e.GXQcK(o,ArrayBuffer)?new Uint8Array(o):new Uint8Array(o[n(1293)],o.byteOffset,o[n(1725)+"th"])}}function Qx(o){let n=t;try{return e.JgDht(e[n(1692)],typeof o)&&(o instanceof ArrayBuffer||o[n(1293)]&&e[n(718)](o[n(1293)],ArrayBuffer))||e.JgDht(e[n(1692)],typeof o)?"":(JSON.parse(o),e[n(1498)])}catch{return e[n(1558)](e[n(1692)],typeof o)?e.miUqR:""}}let eh=(o,n)=>{let i=t;switch(o){case e[i(654)]:case e.feuOd:return{[i(757)+o]:1,"x-tt-env":n};default:return{}}};class th{constructor(n){let i=t;this[i(466)+i(1694)]=n,this[i(638)]=0}[t(850)](){this.count++}[t(476)+"chMaxCount"](){let n=t,i={PHToC:function(f,u){return e.XmlsI(f,u)},IFcuX:function(f,u){return e[B(1773)](f,u)},sGdyh:function(f,u){return e.dcsxw(f,u)},KjFUz:function(f,u){return e[B(903)](f,u)},rLAbD:function(f,u){return e[B(1846)](f,u)}};if(e[n(2026)](e[n(664)],n(1026)))return e[n(1753)](this.count,this["maxLossC"+n(1694)]);_0x53820e[_0x7ca106++]=iSyChV.PHToC(iSyChV[n(1054)](_0x18ee0a,18),7)|240,_0x1959b6[_0x324fef++]=iSyChV[n(973)](iSyChV[n(724)](iSyChV.rLAbD(_0xe6b935,12),63),128)}[t(1808)+t(1678)](n=0){let i=t;this[i(466)+i(1694)]=n,this[i(638)]=0}}async function nh(o){let n=t,i={jvwpw:function(f,u){return e[B(761)](f,u)},Qbdma:function(f,u){return e[B(1917)](f,u)},rvbCC:function(f,u,h){return e[B(1099)](f,u,h)},ZXmii:function(f,u){return e[B(565)](f,u)},BMRTt:function(f,u){return e[B(1585)](f,u)},wVLes:function(f,u){return e[B(1640)](f,u)},lQHHL:n(493),FposE:e.malfT,ppWiV:function(f,u){return e[n(864)](f,u)},Ujxaz:function(f,u){return e[n(650)](f,u)},GSYmC:function(f,u){return e[n(1428)](f,u)},JtyLE:function(f,u){return e.hhndd(f,u)},oDCsL:e[n(1578)],QRRHo:e[n(473)],oEEKr:e[n(1737)],zAnty:e[n(1310)],buMWm:n(624)+"ack=frontierJSONP",tOBJL:e[n(783)],YOrMD:function(f,u){return e[n(764)](f,u)},KzbBM:n(1459),eAtWf:e.XntJn};return new Promise(f=>{let u=n,h={Bktey:function(m,_){return i[B(1439)](m,_)},sTdDo:function(m,_){return i[B(1439)](m,_)},LLlub:i[u(1865)],qWcIt:i.FposE,PXYjt:"diXLa",tpVQc:u(2059),rwuLd:function(m,_){return i[u(523)](m,_)},WDJzx:function(m,_){return i[u(1013)](m,_)},RWmTU:function(m,_){return i[u(1437)](m,_)},aFILr:function(m,_){return i[u(1742)](m,_)}};if(!qn)return i.GSYmC(f,u(1648)+"reason");try{if(i[u(1860)](i[u(521)],i.QRRHo)){let m=document.createElement(i[u(543)]);window["frontier"+u(1107)]=_=>{let g=u;h[g(1365)]===h[g(595)]?(this[g(1767)+g(1504)]()&&(!this[g(1260)]||h[g(1342)](this[g(1260)][g(1644)+"te"],this.OPEN)||h[g(857)](this[g(1260)].readyState,this.CONNECTING))&&this[g(552)+g(1371)](),this[g(1313)+"er"]&&_0x8b28a2[g(1799)+g(1422)](h[g(634)],this[g(552)+g(1371)]),this._isBrowser&&_0x5cefde["addEvent"+g(1422)](h[g(1448)],this[g(552)+g(515)])):(document.body[g(1765)+g(1374)](m),window["frontier"+g(1107)]=void 0,f(_&&_[g(547)]||g(1648)+g(1676)))},m[u(1587)]=u(1804)+u(1039),m.src=o[u(1212)](/^ws/,i[u(1581)])+i[u(1236)];try{document[u(1787)]["appendCh"+u(1374)](m)}catch{if(i[u(1469)]===i[u(1469)])document.body[u(1765)+u(1374)](m);else return MgZBSQ[u(1437)](MgZBSQ.Qbdma(_0x49edb8,4).join("0"),MgZBSQ[u(519)](_0x239f4a,_0x4ab050,2)[u(918)](16)).slice(-4)}}else this[u(1630)]=_0x3a0f42,this[u(1090)]=_0x548253,this[u(1269)]=_0x39b6be?_0x316d8f:_0x55ba40?_0x5e2886:null}catch{if(i[u(795)](i[u(883)],u(1788)))window[u(1283)+u(1107)]=void 0,f(i[u(1663)]);else{let m=i[u(1004)](_0x59f50c,8192),_=i[u(577)](m,1),g=null,T=m;return function(F){let M=u;if(h[M(2018)](F,1)||F>_)return h.WDJzx(_0x452d92,F);h[M(1509)](T,F)>m&&(g=h[M(1198)](_0x123ea4,m),T=0);let K=_0x4d4d72[M(1299)](g,T,T+=F);return 7&T&&(T=h[M(1033)](7,T)+1),K}}}})}function Wt(o,n,i){let f=t;return!!o?.[f(1629)](u=>u[f(1543)]===n&&u[f(805)]===i)}function Gn(o,n){let i=t;return o?.[i(1629)](f=>f[i(1543)]===n)?.[i(805)]}let Po=null;async function rh(){let o=t;return Po||(Po=Promise[o(1499)]().then(Ct[o(993)](Ct,e[o(630)]))),Po}class ih extends ko{constructor(n,i){let f=t;super(),this._dbName=n,this[f(1740)]=i,this[f(1269)]=void 0,this[f(781)+f(1151)]=null}async[t(1708)](){await this[t(1225)]()}async _init(){let n=t;if(e.nqfYx(n(581),e.lcVRN)){if(this[n(1269)])return;if(this._initPromise)return this[n(781)+"mise"];try{let i=this._dbName,f=this[n(1740)];this[n(781)+"mise"]=(async()=>{let u=n,{openDB:h}=await e.VTskQ(rh);this[u(1269)]=await e.OBkJh(h,u(1283)+"_"+i,1,{upgrade(m){m[u(597)+"jectStore"](i,{keyPath:f})}})})(),await this[n(781)+"mise"]}catch(i){console[n(780)](i)}finally{this[n(781)+n(1151)]=null}}else{let i=this[n(898)][n(995)+"tInterce"+n(1168)](_0x26f4a2,_0x29cec0);this[n(963)+n(688)+n(1831)](_0x46aed5(n(1142),{code:_0x4176eb,reason:_0xcc8a6b,wasClean:!0,willReconnect:i})),i&&this[n(651)]()}}async get(n){let i=t;try{return await this._init(),this._qosDB?.[i(1205)](this[i(1672)],n)}catch(f){console.log(f)}}async[t(873)](n,i){let f=t;return await this[f(1225)](),this[f(1269)]?.[f(1411)](this[f(1672)],n)}async[t(1738)](n){let i=t;try{return await this[i(1225)](),this[i(1269)]?.[i(1349)](this[i(1672)],n)}catch(f){console[i(780)](f)}}async[t(1616)](){let n=t,i={bVScM:function(f,u){return e.rDzFq(f,u)},tEhEh:function(f,u){return e.MfZAd(f,u)},xlBkH:function(f,u){return e[B(1950)](f,u)},ZKYPE:function(f,u){return e[B(994)](f,u)},UlKMi:function(f,u){return e[B(536)](f,u)},KsVKl:function(f,u){return e.hdIeh(f,u)},VUxpC:function(f,u){return f>>>u},UjXtw:function(f,u){return e.LeLwB(f,u)},haduw:function(f,u){return e[B(864)](f,u)},IjHWF:function(f,u,h,m){return e[B(1981)](f,u,h,m)}};try{if(e[n(659)](n(1220),e[n(620)])){let f=4294967295;return function(u,h,m=!0){let _=n;if(f=i.bVScM(i[_(1136)](127,u[h]),0),i[_(1632)](u[h++],128))return{value:m?f:i.ZKYPE(0,f),offset:h};if(f=i[_(1794)](f,i.UlKMi(i.tEhEh(127,u[h]),7))>>>0,i[_(1632)](u[h++],128))return{value:m?f:i[_(1065)](0,f),offset:h};if(f=i[_(952)](i[_(1065)](f,i[_(1477)](i[_(1136)](127,u[h]),14)),0),i[_(1277)](u[h++],128))return{value:m?f:i.KsVKl(0,f),offset:h};if(f=i[_(952)](f|i[_(1477)](127&u[h],21),0),i[_(950)](u[h++],128))return{value:m?f:i[_(1794)](0,f),offset:h};if(f=i[_(952)](i[_(1794)](f,i[_(1477)](i[_(1136)](15,u[h]),28)),0),u[h++]<128)return{value:m?f:i.ZKYPE(0,f),offset:h};if((h+=5)>u[_(669)])throw h=u[_(669)],i[_(1325)](_0x1d662f,h,10,u[_(669)]);return{value:m?f:i[_(1794)](0,f),offset:h}}}else return await this[n(1225)](),this._qosDB?.[n(1616)](this[n(1672)])}catch(f){console.log(f)}}async[t(1372)](){let n=t;return await this[n(1225)](),this[n(1269)]?.[n(1744)+"ys"](this[n(1672)])}async[t(1605)](){let n=t,i={MCjwp:e[n(1952)],ZQvoT:e.VlVNv,EdZfk:e[n(1899)],XxAVg:function(f){return e[n(1394)](f)},crMrH:function(f,u){return f(u)},AVYxM:e.nFytw,FjoRB:function(f){return e[n(1762)](f)}};if(e[n(902)](e.HcGVc,n(1092)))return await this[n(1225)](),this._qosDB?.[n(1605)](this[n(1672)]);{let f={YRqAY:function(_,g){let T=n;return aCTXWT[T(2029)](_,g)},JhESy:aCTXWT.AVYxM,qIWCu:function(_){let g=n;return aCTXWT[g(600)](_)}},u=()=>{let _=n;_0x7a6f59[_(1597)+_(1759)+_(1094)](aCTXWT[_(794)],h),_0x20b750[_(1597)+_(1759)+_(1094)](aCTXWT[_(472)],m),_0x4465c5[_(1597)+_(1759)+_(1094)](aCTXWT[_(1323)],m)},h=()=>{let _=n;aCTXWT[_(1430)](_0x500112),u()},m=()=>{let _=n;f[_(1061)](_0x507086,_0xa1a105[_(988)]||new _0x13c5f4(f.JhESy,f.JhESy)),f.qIWCu(u)};_0xc09379[n(1799)+n(1422)](aCTXWT[n(794)],h),_0x49e81e["addEvent"+n(1422)](aCTXWT[n(472)],m),_0x23a7a8[n(1799)+"Listener"](aCTXWT[n(1323)],m)}}async[t(1401)](){let n=t;try{if(e[n(1836)](n(507),n(507)))return this.endpoints[this[n(670)+n(1321)]];this[n(1269)]?.close(),this._qosDB=void 0}catch(i){e[n(1081)](e.psZBi,"ZasDB")?(_0x19b641[_0x4f6375[_0x5a2afa]["cursor_n"+n(1287)]]=_0x137f5e(_0x1bedd9[_0x327220].cursor_name),_0x46cdf1+=e.MfWRH(14,_0x75a9[_0x36aaba[_0x46bdf5][n(1303)+n(1287)]])):console[n(780)](i)}}get[t(1858)](){let n=t;try{return!!this[n(1269)]}catch(i){return console[n(780)](i),!1}}}class sh{constructor(n,i){let f=t;e[f(1442)]===e[f(1005)]?this[f(1819)+"ired"]():(this[f(1630)]=n,this._pathKey=i,this[f(1269)]=localStorage)}async[t(1708)](){}get _prefix(){return"frontier_"+this[t(1630)]}async[t(1205)](n){let i=t,f=this[i(1269)][i(1174)](this[i(518)]);return JSON[i(1348)](f||"{}")[n]}async set(n,i){let f=t,u=this[f(1269)][f(1174)](this[f(518)]),h=JSON[f(1348)](e[f(894)](u,"{}"));return h[i||n[this[f(1090)]]]=n,this[f(1269)][f(538)](this[f(518)],JSON[f(1275)+"y"](h)),i||n[this[f(1090)]]}async[t(1738)](n){let i=t,f=this[i(1269)][i(1174)](this[i(518)]),u=JSON.parse(f||"{}");return u[n]=void 0,this[i(1269)][i(538)](this[i(518)],JSON[i(1275)+"y"](u))}async clear(){return this[t(1269)].clear()}async[t(1372)](){let n=t,i={GNnno:e[n(1292)],ABxwe:function(f,u){return e[n(612)](f,u)},dLqFr:function(f,u){return e[n(771)](f,u)},ggBom:function(f,u){return f+u},tgIyZ:function(f,u,h,m){return e[n(1888)](f,u,h,m)},xhNkk:function(f,u){return e[n(1481)](f,u)}};if(e[n(1444)](e[n(1207)],e[n(1397)])){let f=this[n(1269)][n(1174)](this[n(518)]),u=JSON[n(1348)](e[n(1445)](f,"{}"));return Object[n(1372)](u)}else{let f=i[n(806)][n(941)]("|"),u=0;for(;;){switch(f[u++]){case"0":if(!_0x2ce317)return _0x13fd36;continue;case"1":if(_0x29ab8e.write)return i[n(1852)](_0x1709f4.write(_0x51351a,_0x3939de),_0x1e9279);continue;case"2":if(_0x499dcb[n(1233)+"e"])return i[n(1957)](_0x416124[n(1233)+"e"](_0x16382f,_0x44007e),_0x5cf940);continue;case"3":return i[n(1608)](i.tgIyZ(_0x32b71e,_0x139f5e,_0x424ba9,_0x173d1f),_0x30e28f);case"4":if(i[n(576)](_0x12b423.length,40))return i[n(1852)](i[n(554)](_0x392807,_0x2f6281,_0x119ae7,_0x2335fd),_0x13448b);continue}break}}}async[t(1605)](){let n=t,i=this[n(1269)][n(1174)](this[n(518)]),f=JSON.parse(e.bfkBJ(i,"{}"));return Object[n(532)](f)}[t(1401)](){return Promise[t(1499)]()}get[t(1858)](){return!!this[t(1269)]}}class oh{constructor(n,i){let f=t;this._DBName=n,this._pathKey=i,this[f(1269)]=hn?tt:Dr?wx:null}async[t(1708)](){}get[t(518)](){let n=t,i={KyyzP:function(f,u){return f|u},CWiWb:function(f,u){return e[B(1816)](f,u)},qUnAB:function(f,u){return e[B(840)](f,u)},nIFQX:function(f,u){return e[B(1399)](f,u)},POIKs:function(f,u){return f(u)}};if(e[n(1754)]===n(741))_0x396893=BDfHxr[n(1690)](BDfHxr[n(1202)](BDfHxr.qUnAB(31,_0x4a220d),6),63&_0x3a3d5a),BDfHxr.nIFQX(_0x2383fe,128)?_0x275849+=_0x371ff0:(_0x21c1ca+=BDfHxr[n(1398)](_0x1f8713,_0x15cff6),_0x4683ad++);else return n(1283)+"_"+this[n(1630)]}async get(n){let i=t,f=this[i(1269)]["getStora"+i(1370)](this[i(518)]);return JSON[i(1348)](f||"{}")[n]}async[t(873)](n,i){let f=t,u=this[f(1269)][f(1002)+f(1370)](this._prefix),h=JSON[f(1348)](e[f(565)](u,"{}"));return h[i||n[this[f(1090)]]]=n,this[f(1269)][f(996)+f(1370)](this[f(518)],JSON[f(1275)+"y"](h)),i||n[this[f(1090)]]}async[t(1738)](n){let i=t,f=this[i(1269)]["getStora"+i(1370)](this[i(518)]),u=JSON[i(1348)](e[i(1445)](f,"{}"));return u[n]=void 0,this[i(1269)]["setStora"+i(1370)](this[i(518)],JSON[i(1275)+"y"](u))}async[t(1616)](){let n=t;return e[n(739)](n(1795),e[n(505)])?(_0x2ced4c+=_0x3439e7&&_0x5c1b22[n(1725)+"th"]||0,_0x52af06):this[n(1269)][n(1913)+"rageSync"]()}async keys(){let n=t,i={aDtKN:function(f,u,h){return e.XwFAP(f,u,h)},KTlTN:function(f,u,h){return f(u,h)}};if(e[n(1215)](n(1087),e[n(986)])){let f=this[n(1269)][n(1002)+n(1143)+"nc"](this[n(518)]),u=JSON.parse(e.jYcKB(f,"{}"));return Object.keys(u)}else rjdQNc[n(2025)](_0x204ba8,_0x51753f,96),rjdQNc.KTlTN(_0xa4c90f,_0x46d067,_0x4c7cdd(_0x33b8b0))}async[t(1605)](){let n=t,i=this._qosDB["getStora"+n(1143)+"nc"](this._prefix),f=JSON.parse(e[n(1658)](i,"{}"));return Object[n(532)](f)}[t(1401)](){let n=t;if(e[n(900)](e[n(2033)],e[n(2033)]))e.cZkng(_0x543b53,n(2013)),this[n(488)](e[n(734)],_0x5a76e3),this.off(e[n(759)],_0x139564);else return Promise[n(1499)]()}get[t(1858)](){return!!this[t(1269)]}}function E0(o,n){let i=t;if(e[i(1527)]!==i(1874))return _0x157be4&&_0x39ed95[i(615)]===!0;if(e[i(682)](hn,hn))return new oh(o,n);if((qn||kr)&&e.JgDht(e[i(1701)],typeof indexedDB))return new ih(o,n);if((qn||kr)&&e[i(1191)](e[i(1701)],typeof localStorage))return new sh(o,n);throw new Error("init QoS"+i(1214)+"d")}class ah{constructor(){let n=t;if(e[n(584)](e.QCLVT,e[n(1120)]))try{this._qosDB?.[n(1142)](),this._qosDB=void 0}catch(i){_0x50ece2[n(780)](i)}else this[n(1091)+n(1270)+"Id"]=null,this[n(1091)+"l"]=36e5,this[n(1269)]=E0(e[n(1138)],e.euBOu)}async[t(1091)+t(1775)](){let n=t;e[n(1428)](clearInterval,this[n(1091)+"lTimeoutId"]),this[n(1091)+n(1270)+"Id"]=setInterval(()=>{this[n(1819)+"ired"]()},this[n(1091)+"l"])}async[t(1708)](){let n=t;await this[n(1269)][n(1708)]().then(()=>{let i=n;this[i(1091)+i(1775)]()})}async[t(1819)+t(1646)](){let n=t;(await this[n(1269)]?.[n(1605)]()||[]).filter(({timestamp:u})=>u<Date.now()).forEach(u=>{let h=n;this._qosDB?.[h(1738)](u.message_id)})}async[t(1738)](n){let i=t;return this[i(1269)]?.[i(1738)](n)}async[t(873)](n,i){return this._qosDB?.set({message_id:n,timestamp:i})}async[t(1205)](n){return this._qosDB?.get(n)}async[t(1401)](){let n=t;e[n(1186)](clearInterval,this[n(1091)+"lTimeoutId"]),await this[n(1269)]?.[n(1401)]()}get isReady(){let n=t;return this[n(1269)]?.[n(1858)]}}function Lo(o){let n=t;if(e[n(645)](e[n(1833)],e[n(1833)]))return _0x2dab1d[n(747)+n(475)]||_0x779d0e[n(1205)](_0x327450);{let i=!!this[n(898)][n(1651)+"S"];if(!i)return{enabled:i,isQoSMessage:!1,isQoSAck:!1,isAckCleanupMessage:!1,ackMsgIds:[]};let f=e[n(1536)](Wt,o[n(827)][n(872)],n(1294)+"er_qos","2"),u=f&&e.UagsV(Wt,o[n(827)][n(872)],e[n(1514)],"1"),h=f&&e[n(1888)](Wt,o[n(827)][n(872)],e.QDuTN,"1"),m=h?e.UCciR(Gn,o[n(827)][n(872)],e.jrxYv)?.[n(941)](",").filter(Boolean)||[]:[];return{enabled:i,isQoSMessage:f,isQoSAck:u,isAckCleanupMessage:h,ackMsgIds:m}}}async function v0(){let o=t;return this[o(769)+o(511)]||(this[o(769)+"ger"]=new ah),this[o(769)+"ger"][o(1858)]||await this[o(769)+o(511)][o(1708)](),this[o(769)+o(511)]}async function ch(o,n){let i=t,{enableAutoAck:f}=this[i(898)],u=e.kOigZ(Wt,o[i(827)][i(872)],e[i(1161)],"1"),h=Wt(o[i(827)].headers,e.LhfrZ,"1"),m=Lo[i(1299)](this,o);if(f&&u){let{SeqID:_,LogID:g,service:T,LogIDNew:F,method:M}=o.message;this[i(1115)]({SeqID:_,LogID:g,LogIDNew:F,service:T,method:M,headers:[{key:i(1073),value:"1"},{key:e[i(811)],value:e[i(1658)](F,"")},{key:i(658),value:"0"}]})}h&&!m[i(1686)]&&this[i(963)+i(1897)+i(1641)](o),e.QsZEH(n)}async function fh(o,n){let i=t;this._debug(e[i(1683)],o.message),e[i(1216)](n)}async function dh(o,n){let i=t,f={WxlwH:function(u,h){return e[B(1827)](u,h)},GNKXF:function(u,h){return e[B(1006)](u,h)},OyDzj:function(u,h){return e[B(1028)](u,h)}};if(e.xaUZa===e[i(1515)]){let u=e[i(1428)](Fn,await e[i(1667)](b0,o[i(1366)]));try{if(e[i(1018)](u[i(1063)],Uint8Array)){let h=this[i(898)][i(1273)+i(1164)]instanceof Object?{force:!!this[i(898)][i(1273)+"ncoding"][i(2024)],encoding:this[i(898)][i(1273)+i(1164)].encoding?this[i(898)][i(1273)+i(1164)][i(974)][i(1212)](/\s/g,"")[i(1378)+i(1594)]():""}:{force:!1,encoding:this._options[i(1273)+i(1164)]?this[i(898)][i(1273)+"ncoding"][i(1212)](/\s/g,"")[i(1378)+i(1594)]():""},m=u["payloadE"+i(1164)]?u["payloadE"+i(1164)][i(1212)](/\s/g,"").toLowerCase():"",_=e[i(718)](this[i(898)][i(1817)+i(1118)],Object)?{force:!!this[i(898)].payloadType[i(2024)],type:this[i(898)][i(1817)+i(1118)][i(1587)]?this._options.payloadType.type[i(1212)](/\s/g,"")["toLowerC"+i(1594)]():""}:{force:!1,type:this[i(898)][i(1817)+i(1118)]?this._options["payloadT"+i(1118)][i(1212)](/\s/g,"")[i(1378)+i(1594)]():""},g=u[i(1817)+"ype"]?u[i(1817)+i(1118)][i(1212)](/\s/g,"")[i(1378)+i(1594)]():"",T=_.force?_[i(1587)]:g||_[i(1587)],F=h[i(2024)]?h[i(974)]:m||h[i(974)],M=[e[i(1726)],e[i(1498)],e[i(1473)],i(1805)],K=["none_none",e[i(1508)]];this._options[i(1612)+i(1249)+i(1060)+"ad"]&&M[i(728)](T)&&(!F||K[i(728)](F))?u[i(582)+i(862)]=e[i(502)](y0,u[i(1063)],0,u[i(1063)][i(1725)+"th"]):u[i(582)+i(862)]=""}else u["textPayl"+i(862)]=""}catch(h){u[i(582)+i(862)]="",console[i(780)](h)}o[i(827)]=u,e.VwTMm(n)}else return _0x4f565a[i(1576)+"8"]?{value:_0xa3f531.readUInt8(_0x2df7dc),offset:f[i(1559)](_0x23ab16,1)}:{value:f[i(1396)](255,_0x2d03f5[_0x34c0ee]),offset:f[i(1682)](_0xc879c3,1)}}function uh(o,n,i){let f=t,u={oNjAd:function(h,m){return h<m},JxzVP:function(h,m){return e[B(1649)](h,m)},gmHgi:function(h,m){return h(m)},ElZoC:function(h,m){return e[B(520)](h,m)},ChTkq:function(h,m){return e.nCqzZ(h,m)},wdxVK:function(h,m){return h&m},VdbeX:function(h,m){return e.HveLe(h,m)},PbAug:function(h,m){return h||m},RaPbB:function(h,m){return e[B(1191)](h,m)},EXxWe:e[f(1701)]};if(e[f(1001)](e[f(1919)],e[f(1919)])){let h=e[f(1038)](i,8192),m=h>>>1,_=null,g=h;return function(T){let F=f;if(u[F(1483)](T,1)||u[F(858)](T,m))return u[F(968)](o,T);u.JxzVP(u[F(1975)](g,T),h)&&(_=u[F(888)](o,h),g=0);let M=n.call(_,g,g+=T);return u[F(2010)](7,g)&&(g=u.VdbeX(7,g)+1),M}}else{if(_0x57e4e4)return new _0x3f7494(_0x1d3c90.url,_0x35eb9f[f(808)]);if(UxKVPi[f(1990)](_0x52bfc5,_0x13e929))return new _0x36cb19(_0x4b76f1[f(1278)],_0x25dc3a[f(808)],_0x472d29[f(872)]);if((_0x2515cc||_0x5aa0a7)&&UxKVPi.RaPbB(UxKVPi.EXxWe,typeof _0x318cfb)&&_0x1a9a9d)return new _0xe04c5c(_0x3a463f[f(1278)],_0xd205bc[f(808)+"s"])}}let lh=4294967295;function xh(o,n,i){let f=t;return e[f(1619)](RangeError,e[f(1792)](e.GOYJf(e[f(1344)](e.juLxV,o),e[f(517)])+e.TVenI(n,1),e[f(1978)])+i)}function hh(o,n,i){let f=t;if(i>lh)throw new Error("integer "+f(1698)+"e");let u=3;for(;e[f(695)](u,0);){let h=255&i;e[f(673)](Mo,h,o,e[f(1877)](n,u)),i>>>=8,u--}return e[f(1175)](n,4)}function ph(o,n){let i=0,f=n,u=e.AvDmD(n,4);for(;e.EZAtW(f,u);){let{value:h,offset:m}=No(o,f);f=m,i=e.yKgUS(i,8)>>>0,i+=h}return{value:i,offset:u}}function gh(o,n,i){let f=t,u=e[f(1627)].split("|"),h=0;for(;;){switch(u[h++]){case"0":if(!o)return i;continue;case"1":if(n[f(1263)])return e.etHnY(n[f(1263)](o,i),i);continue;case"2":if(n[f(1233)+"e"])return e[f(801)](n[f(1233)+"e"](o,i),i);continue;case"3":if(o.length<40)return Oo(o,n,i)+i;continue;case"4":return e[f(1888)](Oo,o,n,i)+i}break}}function mh(o,n){let i=t,f=new ce(e[i(1657)](e[i(701)](e[i(594)](o[e[i(2041)](n,4)],24),o[n+5]<<16)|e[i(635)](o[e[i(468)](n,6)],8),o[e[i(468)](n,7)]),e[i(1832)](e[i(1887)](e[i(1468)](o[e[i(2053)](n,0)],24),e[i(1602)](o[e[i(861)](n,1)],16))|e.jHqzB(o[e[i(1633)](n,2)],8),o[e.tuRch(n,3)]),!0);return n+=8,{value:f,offset:n+8}}function wh(o,n,i){let f=t,u=o[f(1014)],h=o[f(1736)];return n[i]=h>>>24,n[e[f(468)](i,1)]=e[f(671)](h,16)&255,n[e[f(799)](i,2)]=e[f(1776)](e[f(540)](h,8),255),n[i+3]=255&h,n[e.nFnET(i,4)]=u>>>24,n[e[f(1764)](i,5)]=e[f(1479)](e[f(1259)](u,16),255),n[e[f(1633)](i,6)]=e[f(840)](u>>>8,255),n[e.CPDgH(i,7)]=255&u,i+=8,i}function No(o,n){let i=t,f={faODF:function(u,h,m){return e.UCciR(u,h,m)}};if(e[i(1001)](e.RHjDs,i(676)))_0x5813a1(_0x314a12,90),ONZsOK[i(1367)](_0x2475e3,_0x463c18,_0x14daf3);else return o[i(1576)+"8"]?{value:o[i(1576)+"8"](n),offset:e[i(1583)](n,1)}:{value:255&o[n],offset:e[i(1741)](n,1)}}function Mo(o,n,i){let f=t;return n[f(1934)+"t8"]?n.writeUint8(o,i):n[i]=e[f(1336)](255,o),e[f(1877)](i,1)}let _h=function(o){return new Uint8Array(o)},yh=e[t(1685)](e[t(1701)],typeof Buffer)?Buffer[t(1250)+t(1733)]:uh(_h,Uint8Array[t(907)+"e"][t(915)]),bh=16,Bo=32;function Eh(o){let n=t,i=0,f={};for(let u=0;e[n(1093)](u,o.length);u++)f[o[u][n(1303)+n(1287)]]=e[n(1208)](_0,o[u][n(1303)+n(1287)]),i+=14+f[o[u][n(1303)+n(1287)]];return[i,f]}function S0(o,n,i){let f=t,[u,h]=e.nQJhg(Eh,o),m=e[f(1823)](yh,u),_=0;return o[f(614)](g=>{let T=f,F=e[T(527)][T(941)]("|"),M=0;for(;;){switch(F[M++]){case"0":console.log(e[T(1634)],_);continue;case"1":console[T(780)](e.HanaD,_);continue;case"2":_=e[T(1826)](Mo,0,m,_);continue;case"3":console[T(780)](e[T(1425)],_);continue;case"4":console[T(780)](e[T(1853)],g,g[T(1991)]);continue;case"5":_=gh(g[T(1303)+"ame"],m,_);continue;case"6":_=e.zrabw(Mo,h[g.cursor_name],m,_);continue;case"7":console[T(780)]("curvalue",_);continue;case"8":_=e.rDGHv(wh,ce[T(629)+"er"](g.cursor||n),m,_);continue;case"9":_=e[T(673)](hh,m,_,g[T(1991)]||0);continue;case"10":console[T(780)](e[T(1666)],_);continue}break}}),{frameType:Bo,headers:[{key:f(1015)+f(960),value:i}],payload:m}}function vh(o){let n=t,i=0,f=[];for(;i<o.byteLength;){let{offset:u}=e[n(571)](No,o,i);i=u;let h={cursor_name:"",cursor:0,service:0},{value:m,offset:_}=e[n(723)](ph,o,i);h[n(1991)]=m,i=_;let{value:g,offset:T}=e[n(1328)](No,o,i);i=T,h[n(1303)+n(1287)]=y0(o,i,e[n(481)](i,g)),i+=g;let{value:F,offset:M}=e[n(1099)](mh,o,i);h[n(1219)]=F.toNumber(),i=M,f[n(737)](h)}return f}function Sh(){let o=t;return{frameType:Bo,headers:[{key:e[o(1940)],value:e[o(1489)]}],payload:void 0}}class Ih{constructor(n,i,f){let u=t;this["_cursorN"+u(817)]=n,this[u(1418)+u(905)]=i,this[u(1040)+u(500)]=f,this._qosDB=e.uaBep(E0,this[u(1931)+"ameSpace"],e[u(1516)])}async openDB(){let n=t;await this[n(1269)][n(1708)]()}async[t(1517)+"rs"](){let n=t;if(!this[n(1269)][n(1858)])return;let i=this[n(1040)+n(500)],f=await this._qosDB[n(1605)]();switch(console.log(e[n(1901)],f),i){case e.zIrkL:return f&&f[n(669)]?e.UagsV(S0,f,0,this["_cursorF"+n(905)]):void 0;case e[n(694)]:return;case e[n(1590)]:return f&&f.length?e.ksVrE(S0,f,0,this[n(1418)+n(905)]):Sh()}}async set(n,i,f){let u=t;return console[u(780)](e.zMjTf,n,i,f),this[u(1269)][u(873)]({cursor_name:n,cursor:i,service:f})}async[t(1402)+"rs"](n){let i=t,f=e[i(524)](vh,n);for(let u of f){if(e[i(1393)](e[i(535)],"ztRYv"))return _0xacaf50||(_0x160382=_0xdd9a18[i(1499)]()[i(2015)](_0x2cfba2[i(993)](_0x420b8d,i(1414)))),_0x599a93;console[i(780)](e[i(1861)],f),await this[i(1269)].set(u)}}async[t(1205)](n){let i=t;return(await this._qosDB[i(1205)](n))?.[i(1219)]}async[t(1401)](){let n=t;if(e[n(1525)](n(884),e[n(1185)]))return _0x505b89.resolve();await this[n(1269)][n(1401)]()}[t(656)+"rsorFile"+t(1938)](n){let i=t;this[i(1418)+i(905)]=n}get[t(1858)](){let n=t;return this[n(1269)][n(1858)]}}let Ch=e.QSDaZ;async function I0(o){let n=t;if(!this[n(898)][n(1651)+"S"])return null;let{aID:i,fpID:f,messageStrategy:u}=this[n(898)],h=e[n(682)](o,Ch);try{return this[n(943)+n(1395)]?o&&this[n(943)+n(1395)][n(656)+n(1595)+n(1938)](o):this["_cursorM"+n(1395)]=new Ih(f+"_"+i+"_"+h,h,u),this[n(943)+n(1395)].isReady||await this[n(943)+n(1395)][n(1708)](),this["_cursorM"+n(1395)]}catch{return null}}async function Th(o,n){let i=t,f={vdLsy:function(u,h){return e[B(1373)](u,h)}};if(e[i(1393)](e[i(1582)],e[i(1320)]))return!!(e[i(1386)](this[i(670)+i(1321)],this[i(579)+"s"][i(669)])||e[i(1870)](this[i(670)+i(1321)],this.endpoints[i(669)]-1)&&e[i(503)](this[i(912)+i(796)+i(1495)+"t"],this[i(1485)+"es"]));{let u=e[i(678)](Wt,o.message[i(872)],e.gKawD,"-1"),h=e.zrabw(Wt,o[i(827)][i(872)],i(1073),"1"),m=e[i(985)](Gn,o[i(827)][i(872)],e[i(1339)]),_=e[i(1917)](Number,Gn(o[i(827)][i(872)],e[i(1781)]))||0,g=Lo.call(this,o),T=e[i(2045)](Wt,o.message[i(872)],e[i(1272)],"2"),F=Gn(o[i(827)][i(872)],e[i(1052)]),M=e[i(1535)](Number,Gn(o[i(827)][i(872)],i(504)+i(910)+"ue"));if(g[i(1686)])return e[i(1216)](n);let K=g.isQoSMessage?await v0.call(this):null;if(e[i(1649)](o[i(827)][i(1991)],0)&&h&&!u||e[i(749)](o[i(827)][i(1991)],0)){if(m&&g[i(1922)+i(617)]&&K)return!!!await K[i(1205)](m)&&(this[i(963)+i(675)+i(793)](o),await K[i(873)](m,e[i(513)](Date[i(1557)](),_))),n();if(T){let $=await I0[i(1299)](this);if(!$)return e[i(1886)](i(1568),e[i(1943)])?nbdgQs[i(1302)](_0x2a8fa6,_0x122552):(this[i(963)+i(675)+"Event"](o),e[i(791)](n));let W=await $[i(1205)](F)??-1;if(W<M)this[i(963)+i(675)+"Event"](o),$[i(873)](F,M,o[i(827)][i(1991)]);else throw new Error("recevied message"+i(610)+M+(i(1884)+i(662)+i(1550)+"r ")+W);return e[i(1282)](n)}return this[i(963)+"hMessageEvent"](o),e.QsZEH(n)}}}async function Ah(o,n){let i=t;if(e.UFlKK!==i(1964))this.on(_0x4c7381,_0x5d07f5);else{let f=Lo[i(1299)](this,o);if(!f[i(1922)+i(617)])return n();let u=await v0[i(1299)](this);if(f[i(1857)+i(876)+i(925)]&&f[i(1350)+"s"][i(669)])for(let h of f[i(1350)+"s"])await u[i(1738)](h);e[i(1394)](n)}}async function Rh(o,n){let i=t,f=o[i(827)][i(1097)+"e"]===bh,u=e[i(880)](o[i(827)].frameType,Bo);if(e[i(983)](!f,!u))return n();let h=e[i(1589)](Gn,o.message[i(872)],e[i(1940)]);if(!h)return e.xOVbt(n);let m=await I0[i(1299)](this,h);if(!m)return e.evuoR(n);if(f){let _=await m[i(1517)+"rs"](),g={frameType:_?.["frameType"],SeqID:ce.fromNumber(this._seqId++),LogID:ce[i(629)+"er"](this[i(898)][i(991)+i(979)]()),service:9e3,method:5,headers:_?.[i(872)],payload:_?.[i(1063)]},T=e[i(1823)](I,g);this._ws&&this[i(1260)][i(1644)+"te"]&&this._ws[i(1211)](T)}if(u){let _=o[i(827)][i(1063)];_&&m[i(1402)+"rs"](_)}}let Dh=async function(o,n){let i=t;this[i(1820)]=!1,e[i(729)](clearTimeout,this[i(651)+"ionTimeo"+i(1177)]),e[i(809)](n)},kh=async function(o,n){let i=t;if(e[i(1859)]!==e[i(1992)]){if(!this[i(1260)]||e[i(1e3)](this[i(1260)][i(1644)+"te"],this[i(1528)]))return e[i(919)](n);let{pingInterval:f}=this[i(898)];this[i(1403)+i(1125)]?.["resetEnd"+i(1464)+i(672)]();for(let h=0;e[i(1192)](h,this[i(1040)+"Queue"][i(669)]);h++){let m=this[i(1040)+i(1307)][h];if(this[i(1260)][i(1644)+"te"]===this.OPEN&&e[i(1031)](null,m))if(e[i(981)]!==e[i(1571)])this[i(1260)]&&this[i(1260)][i(1211)](m),this._messageQueue[h]=null;else{if(this._ws&&this._ws[i(1644)+"te"]===this[i(1042)+"NG"]){this[i(2008)+"ngTimer"](),this[i(1413)+i(732)+"Id"]=e[i(1873)](_0x23b800,this[i(1927)][i(993)](this),this._options["pingInte"+i(1647)]);return}if(!this[i(1260)]||e.AgoRa(this._ws[i(1644)+"te"],this[i(1528)]))return void this[i(544)+i(1674)]();this[i(1260)]&&this[i(1260)][i(1211)]("hi"),this[i(1745)+"ctTimeou"+i(1080)]=e[i(599)](_0x231839,this["_handleR"+i(1674)+i(1876)].bind(this),this[i(898)][i(1995)+i(1034)+i(813)])}else break}this[i(1040)+i(1307)]=this[i(1040)+i(1307)].filter(h=>!!h),this[i(1413)+i(732)+"Id"]=setTimeout(()=>this[i(1927)](),f),this[i(963)+"hOpenEvent"](o),this[i(1313)+"er"]&&this[i(1260)]&&(this[i(1260)][i(1662)+"pe"]=this["_binaryT"+i(1118)]);let u=this[i(1403)+"tManager"]?.[i(946)+i(1652)+"nt"]();this[i(1133)](i(1419)+u+i(666)),n()}else return this[i(1095)][i(1278)]},Oh=async function(o,n){let i=t,f=this[i(1403)+i(1125)]?.getCurrentEndpoint();this[i(1133)]("open "+f),n()};class Ph extends ko{constructor(n){let i=t,f={Qmnrn:function(_,g,T){return e[B(854)](_,g,T)},sSTiS:e[i(2031)],Gbqmd:function(_,g){return e[i(709)](_,g)},wSxPm:function(_,g){return e[i(539)](_,g)},hrpiG:e[i(1077)],VFRpP:e[i(1420)]};super(),this[i(1777)+"igatorOn"+i(1169)]=!0,this._isBrowser=qn,this[i(2032)]=Zx,this[i(684)+"T"]=hn,this[i(802)+"X"]=Dr,this._isWorker=kr,this[i(1040)+"Queue"]=[],this[i(1403)+i(1125)]=null,this._readyClosed=!1,this[i(619)+"ype"]=e[i(1117)],this[i(651)+i(663)]=!1,this[i(651)+i(778)+i(1177)]=null,this._reconnectTimeoutId=null,this[i(1413)+i(732)+"Id"]=null,this[i(879)]=0,this[i(1820)]=!1,this._url="",this[i(769)+i(511)]=null,this["_cursorM"+i(1395)]=null,this[i(1345)+i(1290)]=null,this[i(1100)+"ls"]=e.yBwaJ,this[i(1123)]=3,this[i(1042)+"NG"]=0,this[i(1528)]=1,this[i(1319)]=2,this[i(1376)]=_=>{let g=i;try{w0(this,_,[Dh,kh,Oh])}catch(T){let F=f[g(1213)](Qe,f[g(1248)],{message:T[g(827)],code:jt[g(990)+"OR"],error:T});this[g(963)+"hErrorEvent"](F)}},this[i(642)+"ge"]=async _=>{let g=i,{pingInterval:T,pingFrequency:F}=this[g(898)];if(e[g(1545)]("hi",_.data)&&e[g(1182)](e[g(686)],F)||e.PKHuI(e[g(1953)],F))if(e[g(1545)](e.ozGrA,"rrxns"))this[g(2008)+g(2011)](),this[g(1322)](e[g(734)],e[g(2001)]),this[g(1413)+g(732)+"Id"]=e[g(1873)](setTimeout,this[g(1927)][g(993)](this),T);else{let M=this[g(1269)][g(1174)](this._prefix),K=_0x1114e4[g(1348)](hIQgPQ[g(848)](M,"{}"));return _0x26541a[g(1372)](K)}if(!e[g(483)]("hi",_[g(1366)]))try{w0(this,_,[dh,ch,Ah,Rh,Th,fh])}catch(M){let K=e[g(1573)](Qe,"error",{message:M[g(827)],code:jt.MESSAGE_ERROR,error:M});this[g(963)+g(1457)+"ent"](K)}},this._onError=_=>{let g=i,T=this[g(1403)+g(1125)]?.checkReachMaxTries(),F=this[g(1403)+g(1125)]?.[g(946)+g(1652)+"nt"]();if(T&&!_[g(827)]){let M=g(648)+F+(" fail, m"+g(1902)+g(758)+"ed");this[g(963)+g(1457)+g(1831)](f[g(1213)](Qe,f.sSTiS,{message:M,code:jt[g(2039)+g(1462)+"R"],error:_}));return}this[g(1260)]&&f[g(1664)](this._ws[g(1644)+"te"],this.OPEN)&&this[g(1074)+"ect"](),this["_dispatc"+g(1457)+g(1831)](f[g(1213)](Qe,f[g(1248)],{message:_[g(827)],code:jt["NATIVE_E"+g(1316)],error:_}))},this[i(683)]=async _=>{let g=i;this[g(923)+"mer"](),this[g(2008)+g(2011)](),this[g(1172)+g(1501)+"rs"](),this._ws=null,this[g(651)+g(663)]=!1;let T=this["_endpoin"+g(1125)]?.[g(476)+"chMaxTries"]();if(!T&&this[g(1767)+g(1504)]()&&!this._readyClosed){let F=this[g(1403)+g(1125)]?.[g(946)+"ntEndpoint"](),M=this[g(898)][g(995)+g(1478)+"ptor"](_.code,_.reason);this["_dispatc"+g(688)+g(1831)](e[g(1719)](ot,g(1142),{code:1006,reason:_[g(1676)]||"connecti"+g(756)+"d, unkno"+g(886)+g(1155)+"ame: "+F,willReconnect:M})),M&&this[g(651)]();return}if(e[g(900)](1e3,_[g(1864)])&&this[g(2022)+"osed"])if(e[g(2060)](e[g(1807)],e[g(1807)]))_0x331bac&&_0x207f04.addEventListener(hIQgPQ[g(693)],()=>_0x58407c()),_0x3aedcc&&_0x1eccb3[g(1799)+"Listener"](hIQgPQ[g(1552)],()=>_0x2d59c1());else{this[g(963)+g(688)+g(1831)](e.OBmiT(ot,"close",{code:1e3,reason:g(1383)})),this[g(1403)+g(1125)]?.[g(1994)+g(1464)+g(672)](),this["_pingLos"+g(1290)]?.resetCounter();return}if(e[g(1668)](1e3,_[g(1864)])&&T){let F=this[g(1403)+g(1125)]?.[g(946)+g(1652)+"nt"](),M=_[g(1676)];M||(M=await nh(this[g(1487)])),M=g(1183)+g(756)+g(1628)+M+(g(1352)+g(895))+F+(", max retries re"+g(970)),this[g(963)+g(688)+"ent"](e[g(1635)](ot,e.wcqNZ,{code:_[g(1864)],reason:M}));let K="connect "+F+(" fail, max retri"+g(758)+"ed");this["_dispatc"+g(1457)+g(1831)](e[g(1849)](Qe,e[g(2031)],{message:K,code:jt[g(2039)+"IES_ERROR"]})),this[g(1403)+g(1125)]?.["resetEnd"+g(1464)+"fig"](),this["_pingLos"+g(1290)]?.["resetCou"+g(1678)]();return}if(e[g(526)](1e3,_.code)&&!_[g(1676)]){let F=this["_endpoin"+g(1125)]?.[g(946)+g(1652)+"nt"]();this[g(963)+g(688)+g(1831)](ot(e[g(1077)],{code:_.code,reason:"connecti"+g(756)+g(574)+g(886)+g(1155)+g(1267)+F})),this["_endpoin"+g(1125)]?.[g(1994)+g(1464)+g(672)](),this[g(1345)+"sCounter"]?.["resetCou"+g(1678)]();return}this[g(963)+g(688)+g(1831)](_),this[g(1403)+"tManager"]?.[g(1994)+"pointCon"+g(672)](),this["_pingLos"+g(1290)]?.[g(1808)+"nter"]()},this[i(1909)]=null,this.onerror=null,this[i(618)+"e"]=null,this[i(1163)]=null,this[i(957)+i(1674)]=null,this[i(1604)+i(479)]=null,this[i(640)+i(1772)+i(947)+"ct"]=null,this[i(552)+"nLine"]=this["_handleO"+i(1371)][i(993)](this),this[i(552)+"ffLine"]=this[i(552)+i(515)][i(993)](this),this[i(1458)+i(1789)]=this[i(1458)+i(1789)][i(993)](this),this[i(1458)+"ageShow"]=this._handlePageShow[i(993)](this),this[i(898)]={url:"",automaticOpen:!0,initReconnectInterval:1e3,maxReconnectInterval:1e4,reconnectIntervalGrowFactor:2,timeoutInterval:5e3,maxRetries:5,debug:!1,maxMessageQueueLength: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.NXoFX,pingLossCount:2,enableTransformTextPayload:!1,logIDNewConfig:{enableAutoGenerateLogIDNew:!1,userIp:""},miniProgramParams:{customHttpHeader:{}},enableAutoAck:!1,reconnectInterceptor:()=>!0,enableQoS:!1,QoSLevel:2,messageStrategy:e[i(1590)],env:{xTTEnv:"",xUseEnv:""},listenNetworkChanged:!0};let{url:u,ws:h}=n,m=Array[i(1980)](u)?u:e[i(1614)](e[i(1692)],typeof u)?[u]:[];if(!m||e[i(743)](0,m[i(669)]))throw new Error(e.eOJXq);if(!e[i(1428)](Xx,h))throw new Error("please p"+i(2034)+"s params"+i(1167)+i(480)+i(1315)+i(1357)+i(1974));Object[i(1643)](this[i(898)],n),this[i(1403)+"tManager"]=new m0(m,this[i(898)].maxRetries),this[i(1345)+i(1290)]=new th(this[i(898)]["pingLoss"+i(924)]),this[i(898)][i(1480)+i(2042)]&&(this[i(1820)]=!0,this[i(651)]()),this._options[i(959)+i(1750)+i(1304)]&&(this[i(684)+"T"]||this._isMiniWX?this[i(1229)+i(1697)+i(1507)]():this[i(1313)+"er"]&&this[i(944)+i(1746)+i(1422)]())}[t(552)+t(1371)](){let n=t;this[n(898)][n(731)+n(1406)+n(1007)]||this["_readyCl"+n(1944)]||this[n(544)+n(1674)]()}[t(552)+t(515)](){let n=t,i={XyxzS:function(f,u){return f<=u},syZmf:function(f,u){return f<u},fFVKE:function(f,u){return e[B(832)](f,u)},nBZMj:function(f,u){return e[B(931)](f,u)},WvoYn:function(f,u){return f<<u},paByb:function(f,u){return e[B(1703)](f,u)},HoixM:function(f,u){return e[B(553)](f,u)},DpOgM:function(f,u){return f&u},dckqw:function(f,u){return e[B(1722)](f,u)},DseRX:function(f,u){return e[B(800)](f,u)},jyVbA:function(f,u){return e.YKdAI(f,u)},oHGMA:function(f,u){return e[B(674)](f,u)}};if(e[n(1539)](e[n(1761)],e[n(1834)])){let f=_0x3c7b1f[n(603)+"At"](_0x54daf7);f>=55296&&hhniUH[n(1180)](f,56319)&&hhniUH[n(838)](hhniUH[n(1519)](_0x301951,1),_0x22462b)&&(f=hhniUH[n(1432)](hhniUH[n(1519)](hhniUH.WvoYn(f,10),_0x13114b[n(603)+"At"](++_0x5310d8)),56613888)),hhniUH[n(1112)](f,128)?_0x349b74[_0x274608++]=f:(hhniUH.syZmf(f,2048)?_0x533004[_0x3862ff++]=hhniUH[n(1779)](hhniUH[n(1714)](hhniUH[n(1139)](f,6),31),192):(f<65536?_0x1b02e6[_0x45ed19++]=hhniUH[n(1779)](hhniUH[n(1714)](hhniUH[n(1139)](f,12),15),224):(_0xe2fcc4[_0x1b3a69++]=hhniUH[n(1779)](hhniUH[n(1139)](f,18)&7,240),_0x203912[_0x2cd329++]=hhniUH.dckqw(f,12)&63|128),_0x27fa25[_0x256174++]=hhniUH[n(1937)](hhniUH[n(592)](f,6)&63,128)),_0x530914[_0x5707e2++]=hhniUH[n(1113)](63,f)|128)}else{this[n(980)+n(820)+"t"]();let f=e[n(826)](Do,e[n(495)],{message:e[n(869)]});this.onStopImmediatelyReconnect&&this[n(640)+n(1772)+n(947)+"ct"](f)}}[t(944)+t(1746)+t(1422)](){let n=t;this[n(1313)+"er"]&&window["addEvent"+n(1422)](e.brPGU,this[n(552)+n(1371)]),this._isBrowser&&window.addEventListener(n(719),this[n(552)+n(515)]),this[n(1313)+"er"]&&window[n(1799)+n(1422)](e[n(1941)],this[n(1458)+"ageHide"]),this[n(1313)+"er"]&&window[n(1799)+n(1422)](n(1710),this[n(1458)+n(1920)])}[t(1388)+t(1746)+t(1422)](){let n=t;this._isBrowser&&window[n(1597)+"entListe"+n(1094)](e[n(1318)],this[n(552)+n(1371)]),this[n(1313)+"er"]&&window[n(1597)+n(1759)+n(1094)](n(719),this["_handleO"+n(515)]),this[n(1313)+"er"]&&window[n(1597)+n(1759)+"ner"](n(548),this._handlePageHide),this[n(1313)+"er"]&&window[n(1597)+n(1759)+n(1094)](e[n(1903)],this[n(1458)+n(1920)])}[t(1458)+"ageHide"](n){let i=t;!n[i(1802)+"d"]&&(this[i(1313)+"er"]&&window[i(1597)+"entListe"+i(1094)](e[i(1941)],this[i(1458)+"ageHide"]),this[i(1313)+"er"]&&window[i(1597)+i(1759)+i(1094)](e[i(1903)],this[i(1458)+i(1920)]),this[i(1142)]()),this[i(1313)+"er"]&&window[i(1597)+"entListe"+i(1094)](e[i(1318)],this._handleOnLine),this._isBrowser&&window[i(1597)+i(1759)+i(1094)](i(719),this[i(552)+i(515)])}_handlePageShow(n){let i=t,f={sQsoh:function(u,h){return e[B(1533)](u,h)}};if(e[i(1539)](e.lEJFV,"WkVot")){let u=this[i(1736)],h=this[i(1014)];return[e[i(1910)](255,h),h>>>8&255,e[i(575)](e[i(1062)](h,16),255),e[i(692)](h,24),e[i(1298)](255,u),e.VRGlB(u>>>8,255),e[i(1963)](u>>>16,255),e.LcftK(u,24)]}else if(n.persisted){if(e[i(1942)]===e.TZGaZ)return _0x24b3ee&&(_0x171a5d=(0,_0x214b77[iEbNLN[i(1045)](_0x95c0b3,_0x2cb89f)[0]])(_0x4811a4=0)),_0x2957d8;this[i(1767)+i(1504)]()&&(!this._ws||e[i(1444)](this[i(1260)][i(1644)+"te"],this[i(1528)])||this[i(1260)][i(1644)+"te"]!==this[i(1042)+"NG"])&&this["_handleO"+i(1371)](),this[i(1313)+"er"]&&window[i(1799)+i(1422)](e[i(1318)],this["_handleO"+i(1371)]),this[i(1313)+"er"]&&window["addEvent"+i(1422)](e[i(1786)],this[i(552)+i(515)])}}async["_generat"+t(1809)](n){let i=t,{fpID:f,deviceID:u,bddID:h,ttwID:m,accessKey:_,aID:g,customParams:T={},enableAutoAck:F,enableQoS:M,QoSLevel:K,env:$}=this[i(898)],W,ae,Q;this[i(1313)+"er"]||this[i(802)+"X"]||this[i(684)+"T"]?(W=location&&e.lwQiu(e[i(653)],location.protocol)?e.uJvJQ:e[i(964)],ae=n[i(1212)](/((^ws)|(^http))((?:[s]*:\/\/))/,""),Q=/^wss(.*:\/\/)/[i(1385)](n)?n:""+W+ae):(W=e.uJvJQ,ae=n[i(1212)](/(^http)((?:[s]*:\/\/))/,""),Q=/(^ws)((?:[s]*:\/\/))/[i(1385)](ae)?ae:""+W+ae);let xe=h?i(1079):m?e[i(1053)]:"device_id",pn=h||m||u;if(e[i(894)](!pn,!xe))throw new Error(e[i(906)]);let Lh=e.Tnxmc==typeof T?await e[i(1330)](T):T,Nh=$?e[i(598)](eh,$[i(1329)],$[i(1993)]):{},zo=Object[i(1643)]({device_platform:e[i(1296)],version_code:i(1785)+"0",access_key:_,fpid:f,aid:g,[xe]:pn,xsack:F?1:0,xaack:F?1:0,xsqos:M?1:0,qos_level:M?K:void 0,qos_sdk_version:2,...Nh},Lh),Mh=Object.keys(zo)[i(1541)]((Fo,Uo)=>zo[Uo]!==void 0?""+Fo+(Fo?"&":"?")+Uo+"="+zo[Uo]:Fo,"");return Q+i(1520)+Mh}async _connect(){let n=t,i={usgNa:e[n(896)],mBJgm:function(f,u,h,m){return e.rDGHv(f,u,h,m)},GFpVH:n(1003)+"ervice",AgmaB:e[n(1918)],TWzEH:e[n(768)],NoFhq:e[n(1425)],imwvH:e[n(1666)]};if(!(this["_connect"+n(663)]||this[n(2022)+n(1944)])){this["_connect"+n(663)]=!0;try{let f=this["_endpoin"+n(1125)]?.["checkCur"+n(1491)+n(1728)+n(1443)+n(1017)](),{timeoutInterval:u}=this._options;if(f){let m=this[n(1403)+"tManager"]?.[n(946)+n(1652)+"nt"](),_=this[n(1403)+n(1125)]?.[n(585)+n(1305)+n(1306)+"UpdateCo"+n(1156)](),g=this[n(1403)+n(1125)]?.[n(946)+n(1652)+n(514)+n(1694)]();if(_){let T=n(648)+m+(n(1561)+n(1037)+n(1624)+n(1072)+n(700)+n(588)+n(626))+_+" to retry",F=e.lIVWX(Qe,e[n(2031)],{message:T,code:jt[n(2039)+n(1462)+"R"]});this[n(1133)](T),this[n(963)+n(1457)+n(1831)](F),this[n(1487)]=await this[n(786)+n(1809)](_),this[n(1133)](n(648)+_+" "+g+n(558)),this[n(1172)+n(1501)+"rs"]()}else{let T=n(648)+m+(n(1561)+n(1037)+"tries reached");this[n(1133)](T),this[n(963)+n(1457)+n(1831)](e[n(1379)](Qe,e[n(2031)],{message:T,code:jt[n(2039)+n(1462)+"R"]}));return}}else{let m=this[n(1403)+n(1125)]?.[n(946)+n(1652)+n(2050)+n(1281)](),_=this["_endpoin"+n(1125)]?.[n(946)+n(1652)+n(514)+"ount"]();this._url=await this["_generat"+n(1809)](e[n(845)](m,"")),this[n(1133)](n(648)+m+" "+_+n(558)),this[n(1172)+"sListeners"]()}if(this[n(1820)])this[n(1820)]=!1;else{let m=e[n(819)](Do,e[n(495)],{message:e[n(1265)]});this[n(957)+n(1674)]&&this.onStartReconnect(m)}let h=this[n(1403)+n(1125)]?.["getCurre"+n(1652)+n(514)+n(1694)]()||0;e[n(749)](h,1)&&await this[n(508)](e[n(1912)](h,1)),this[n(1133)](n(1183)+n(753)+this[n(1487)]+(" protoco"+n(1127))+this[n(1100)+"ls"]),this._ws=Yx({url:this._url,protocols:[this[n(1100)+"ls"]],headers:this[n(898)][n(1534)+n(750)+"s"]["customHt"+n(570)]},this[n(898)].ws),(this[n(1313)+"er"]||this._isWorker)&&this[n(1260)]&&(this[n(1260)][n(1662)+"pe"]=this[n(619)+n(1118)]),this[n(1193)+"steners"](),this[n(651)+n(778)+n(1177)]=e.OogSG(setTimeout,this[n(704)+"ut"][n(993)](this),u)}catch(f){if(e[n(1707)]===n(1496))throw this[n(651)+"Lock"]=!1,f;{let u=i[n(560)][n(941)]("|"),h=0;for(;;){switch(u[h++]){case"0":_0x1ef443=wxHmtH[n(1615)](_0x5f0f4d,_0x4e406d[n(1303)+n(1287)],_0x1af3ee,_0x378c01);continue;case"1":_0x10707c.log(wxHmtH[n(1613)],_0x392b0f,_0x456640[n(1991)]);continue;case"2":_0x8d22f[n(780)](wxHmtH[n(821)],_0x5a13bc);continue;case"3":_0x50ba77=wxHmtH.mBJgm(_0x2da60f,_0x40714a.fromNumber(_0x3e9556[n(1219)]||_0x3cedb4),_0x48a4aa,_0x293bf3);continue;case"4":_0x22c76b[n(780)](wxHmtH[n(1818)],_0x240c47);continue;case"5":_0x37f595=_0x164549(0,_0x1937d4,_0x310b7c);continue;case"6":_0x40f93a=_0x4bd883(_0x48b2d6[_0x158602["cursor_n"+n(1287)]],_0xeb9c3e,_0x55604c);continue;case"7":_0xe100d7=wxHmtH[n(1615)](_0x202f21,_0x3a21be,_0x3f00d9,_0x5675c8.service||0);continue;case"8":_0x540d63[n(780)](n(1025)+"name",_0x22a7fd);continue;case"9":_0xcfb6fb.log(wxHmtH[n(677)],_0x1505e6);continue;case"10":_0x3a976c[n(780)](wxHmtH[n(702)],_0x29da9d);continue}break}}}}}[t(923)+"mer"](){let n=t;e[n(1894)](clearTimeout,this["_connect"+n(778)+"utId"]),this[n(651)+n(778)+"utId"]=null}[t(2008)+t(2011)](){let n=t;clearTimeout(this[n(1413)+n(732)+"Id"]),clearTimeout(this[n(1745)+n(1548)+n(1080)]),this[n(1413)+"gTimeoutId"]=null,this[n(1745)+n(1548)+n(1080)]=null}[t(1133)](...n){let i=t;this._options[i(1314)]&&console[i(780)][i(1551)](console,[i(1474)+">",...n])}[t(1712)+t(562)+"e"](n){let i=t,{initReconnectInterval:f,maxReconnectInterval:u,reconnectIntervalGrowFactor:h}=this[i(898)],m=e.lQWeC(f,Math.pow(h,n-1));return e[i(1837)](m,u)?u:m}[t(1927)](){let n=t;if(this[n(1260)]&&e[n(743)](this[n(1260)][n(1644)+"te"],this.CONNECTING)){this[n(2008)+n(2011)](),this[n(1413)+"gTimeoutId"]=e[n(1556)](setTimeout,this._ping.bind(this),this[n(898)][n(1147)+"rval"]);return}if(!this[n(1260)]||e[n(900)](this[n(1260)][n(1644)+"te"],this.OPEN))return void this[n(544)+n(1674)]();this[n(1260)]&&this[n(1260)][n(1211)]("hi"),this[n(1745)+n(1548)+n(1080)]=e.znzwJ(setTimeout,this[n(544)+n(1674)+n(1876)].bind(this),this[n(898)]["pingTime"+n(1034)+"val"])}[t(544)+"econnect"+t(1876)](){let n=t;this[n(1345)+n(1290)]?.[n(850)](),this.emit(n(733)+n(1650)+"t",n(999)),this[n(1345)+n(1290)]?.[n(476)+n(1735)+"nt"]()?this["_handleR"+n(1674)]():this[n(1927)]()}[t(1767)+t(1504)](){let n=t;return this[n(684)+"T"]||this[n(802)+"X"]?this[n(1777)+"igatorOn"+n(1169)]:(this[n(1313)+"er"]||this[n(631)+"r"])&&this._options[n(959)+n(1750)+n(1304)]?navigator[n(1883)]:!0}["_handleR"+t(1674)](){let n=t;!this[n(1767)+n(1504)]()||this["_readyCl"+n(1944)]||(this[n(1403)+n(1125)]?.[n(1994)+n(1464)+n(672)](),this["_pingLos"+n(1290)]?.[n(1808)+n(1678)](),this._ws?this[n(1074)+n(1472)](1001,e[n(1067)],!0):this[n(651)]())}[t(1229)+t(1697)+t(1507)](){let n=t;this[n(684)+"T"]?tt.onNetworkStatusChange(({isConnected:i})=>{let f=n;this[f(1777)+"igatorOn"+f(1169)]=i,i?this["_handleO"+f(1371)]():this[f(552)+f(515)]()}):this[n(802)+"X"]&&wx[n(1103)+"kStatusC"+n(1997)](({isConnected:i})=>{let f=n;this[f(1777)+f(829)+f(1169)]=i,i?this[f(552)+f(1371)]():this["_handleO"+f(515)]()})}[t(508)](n){let i=t,f={ZFsRH:function(u,h){return e.SIUrP(u,h)},rfElQ:function(u,h,m,_){return e[B(1981)](u,h,m,_)},JaplH:function(u,h){return e[B(1327)](u,h)},tQcHl:function(u,h){return e[B(1816)](u,h)},vwtqf:function(u,h){return e[B(810)](u,h)},qCaxH:function(u,h){return e[B(1043)](u,h)},vPtFn:function(u,h){return e.fptMg(u,h)},Drbmo:function(u,h){return e[B(494)](u,h)},iQusw:function(u,h){return e[B(945)](u,h)},NjUmx:function(u,h){return e[B(601)](u,h)},KldZt:function(u,h){return u&h}};if(e[i(843)](e[i(2048)],e.EefqG)){let u=("9|11|8|3"+i(1106)+i(1724)+"0")[i(941)]("|"),h=0;for(;;){switch(u[h++]){case"0":if(tttWsN[i(1677)](_0x573949+=5,_0x2c6347[i(669)]))throw _0x4dd8fe=_0x5eb6c5[i(669)],tttWsN[i(908)](_0x39ba2f,_0x2163c4,10,_0xc4f8c9[i(669)]);continue;case"1":_0x17a6b5=tttWsN[i(1546)](_0x3fc204|tttWsN[i(740)](tttWsN[i(1622)](127,_0x2da279[_0xeaa70f]),21),0);continue;case"2":_0x2e942a=tttWsN[i(1546)](tttWsN.qCaxH(_0xa70ea1,tttWsN[i(1622)](15,_0x4a6677[_0x3cf305])<<28),0);continue;case"3":if(tttWsN[i(1621)](_0x5cd1d2[_0x55b575++],128))return{value:_0x44c42c?_0x20e225:0|_0x4b399c,offset:_0x59b2cc};continue;case"4":if(_0x281e9d[_0x421f0a++]<128)return{value:_0x127448?_0x4096f2:0|_0x4d5e84,offset:_0x60610};continue;case"5":if(tttWsN[i(1621)](_0x1227b0[_0x40b15a++],128))return{value:_0x164064?_0x6a794c:tttWsN[i(1522)](0,_0x56fbc0),offset:_0x47a837};continue;case"6":if(tttWsN[i(1621)](_0x49da92[_0x1d67c4++],128))return{value:_0x53a827?_0x57e564:tttWsN[i(1332)](0,_0xe2bed2),offset:_0x32747c};continue;case"7":_0x439ad3=(_0x13d610|tttWsN[i(1631)](tttWsN[i(1622)](127,_0x18b220[_0x26c3cd]),14))>>>0;continue;case"8":_0x338148=tttWsN.JaplH(_0x787e9e|(127&_0x546bbf[_0x136627])<<7,0);continue;case"9":_0x209a63=tttWsN[i(2021)](127,_0x3d2397[_0x341f91])>>>0;continue;case"10":return{value:_0x334794?_0x218249:tttWsN[i(1463)](0,_0x15056b),offset:_0x5972ba};case"11":if(_0x5a3b73[_0x48083e++]<128)return{value:_0x2acd83?_0x32aabe:0|_0x25f064,offset:_0x536496};continue}break}}else return new Promise(u=>{let h=i;setTimeout(u,this[h(1712)+h(562)+"e"](n))})}[t(1074)+t(1472)](n=1e3,i="",f=!1){let u=t;this[u(1260)]&&this[u(980)+u(820)+"t"](n,i,f)}[t(704)+"ut"](){let n=t,i={rvdhl:function(f,u,h){return e[B(1486)](f,u,h)},AYzmf:function(f,u){return f+u}};if(e[n(1453)](e[n(1082)],e[n(696)])){let f=this._endpointManager?.["getCurre"+n(1652)+"nt"]();this[n(1133)](n(648)+f+n(1561)),this[n(1074)+n(1472)](1001,n(1122)+n(998)+"onnecting",!0)}else{let f=Rfhayn[n(667)](_0x51a3d1,_0x8a3ff6,_0x5b8932);return _0xbf2d36[n(1654)][n(915)](f,Rfhayn[n(1811)](f,_0x334c52))}}[t(1115)](n){let i=t;if(i(868)===e[i(1675)]){let f=this[i(1403)+i(1125)]?.[i(946)+i(1652)+"nt"]();this[i(963)+i(688)+"ent"](_0x3b63e4(e.wcqNZ,{code:1006,reason:i(648)+f+(i(1561)+", max re"+i(1624)+"ached"),wasClean:!0}))}else{let f=e[i(742)](We,n);this[i(1260)]&&this[i(1260)][i(1644)+"te"]===this[i(1528)]&&(this[i(1260)]&&this[i(1260)][i(1211)](f),this[i(1133)](e[i(1872)],n))}}[t(1172)+t(1501)+"rs"](){let n=t;this[n(1260)]&&(this._ws[n(1597)+"entListe"+n(1094)](n(727),this._onOpen),this[n(1260)][n(1597)+n(1759)+n(1094)](e[n(1077)],this[n(683)]),this._ws["removeEv"+n(1759)+"ner"](e[n(1555)],this[n(642)+"ge"]),this[n(1260)]["removeEv"+n(1759)+n(1094)]("error",this[n(853)]))}[t(1193)+t(1763)](){let n=t,i={hmNYZ:function(f,u){return e[B(1200)](f,u)},JRSMY:function(f,u){return e[B(1653)](f,u)},BGSWi:function(f,u){return e[B(1906)](f,u)},MwXYs:function(f,u){return e[B(955)](f,u)},oNaNi:function(f,u){return f<u},zULic:function(f,u){return f>u},dEdKV:function(f,u){return f+u},nMJwm:function(f,u){return f>>u}};if(e.TcWLe(e.QiblK,e[n(855)]))_0x2b2ece=JSjmqi[n(969)](JSjmqi[n(1016)](JSjmqi[n(1577)](7&_0x214008,18)|JSjmqi[n(1577)](63&_0x2af6cf,12),JSjmqi[n(1577)](JSjmqi[n(1239)](63,_0xe7f01d),6)),63&_0x5dc709),JSjmqi[n(1855)](_0x523d09,65536)||JSjmqi[n(1158)](_0x1f001b,1114111)?_0x517b5d+=_0x3ee468:(_0x3d3767-=65536,_0x124211+=_0x576111(JSjmqi[n(708)](JSjmqi[n(971)](_0x892cd0,10),55296),JSjmqi.MwXYs(1023,_0x3d542b)+56320),_0x18cdbd+=3);else{let f=e[n(545)][n(941)]("|"),u=0;for(;;){switch(f[u++]){case"0":this._ws[n(1799)+n(1422)](e[n(707)],this[n(1376)]);continue;case"1":this[n(1260)][n(1799)+n(1422)](e[n(1555)],this[n(642)+"ge"]);continue;case"2":this[n(1260)][n(1799)+n(1422)](e[n(1077)],this._onClose);continue;case"3":if(!this._ws)return;continue;case"4":this[n(1260)][n(1799)+n(1422)](e[n(2031)],this[n(853)]);continue}break}}}[t(1898)+t(1955)](n=1e3,i=""){let f=t;try{this[f(1260)]&&this[f(1260)][f(1142)](n,i)}catch{}}["_destroy"+t(820)+"t"](n=1e3,i="",f=!1){let u=t,h={zmiEx:function(m,_){return e[B(926)](m,_)},PAMbD:function(m,_){return e[B(1713)](m,_)},efQrc:function(m,_){return m<<_}};if(e[u(1454)](e.nspJC,e[u(568)]))this._ws&&this[u(1260)][u(1142)](_0x38466f,_0x174e9d);else{if(this[u(2008)+u(2011)](),this[u(923)+u(1429)](),this._removeWsListeners(),this[u(1898)+"nceClose"](1e3,i),this["_connect"+u(663)]=!1,f&&this[u(1767)+u(1504)]()&&!this[u(2022)+u(1944)]){if(this["_endpoin"+u(1125)]?.[u(476)+"chMaxTries"]()){if(e[u(549)](e[u(1438)],e[u(1438)]))return new _0x34c612(hvHDTA[u(652)](hvHDTA[u(652)](hvHDTA[u(1896)](_0x550a47[4],24),hvHDTA[u(1896)](_0x57eb4f[5],16))|hvHDTA.PAMbD(_0x1368b5[6],8),_0x5e29f4[7]),hvHDTA.zmiEx(hvHDTA.zmiEx(hvHDTA[u(652)](hvHDTA[u(1896)](_0x4bcf24[0],24),_0x2bed3c[1]<<16),hvHDTA[u(1747)](_0x474a72[2],8)),_0xfe0b9c[3]),_0x5d97a3);{let _=this["_endpoin"+u(1125)]?.[u(946)+u(1652)+"nt"]();this[u(963)+u(688)+u(1831)](e[u(1617)](ot,e[u(1077)],{code:1006,reason:u(648)+_+(u(1561)+", max retries reached"),wasClean:!0}))}}else{let _=this[u(898)][u(995)+u(1478)+"ptor"](n,i);this[u(963)+u(688)+u(1831)](ot(e[u(1077)],{code:n,reason:i,wasClean:!0,willReconnect:_})),_&&this[u(651)]()}return}this[u(1767)+u(1504)]()||this[u(2022)+"osed"]?this[u(963)+u(688)+u(1831)](e.wcGuM(ot,e[u(1077)],{code:n,reason:u(1383)})):this[u(963)+u(688)+u(1831)](e[u(1596)](ot,e[u(1077)],{code:1006,reason:e.UjqYY})),this[u(1260)]=null,this[u(1403)+u(1125)]?.["resetEnd"+u(1464)+u(672)](),this[u(1345)+u(1290)]?.[u(1808)+"nter"]()}}["_dispatc"+t(1904)+"nt"](n){let i=t;this[i(1322)](e[i(707)],n),this.onopen&&this[i(1163)](n)}[t(963)+t(675)+t(793)](n){let i=t;this.emit(e.BaXgH,n),this[i(618)+"e"]&&this[i(618)+"e"](n)}["_dispatc"+t(1897)+t(1641)](n){let i=t;this[i(1322)](i(1088),n),this[i(1604)+"eAck"]&&this[i(1604)+"eAck"](n)}[t(963)+t(1457)+t(1831)](n){let i=t;this[i(1322)](e[i(2031)],n),this[i(464)]&&this[i(464)](n)}[t(963)+t(688)+t(1831)](n){let i=t,f={RUfEs:function(u,h,m){return e[B(818)](u,h,m)},NsYGL:e.wcqNZ};if(e[i(954)]===i(1717)){if(this[i(1403)+i(1125)]?.[i(476)+i(602)+"es"]()){let h=this[i(1403)+"tManager"]?.[i(946)+i(1652)+"nt"]();this["_dispatc"+i(688)+"ent"](EgIPmV[i(1751)](_0x466b4,EgIPmV[i(776)],{code:1006,reason:i(648)+h+(i(1561)+", max re"+i(1624)+i(970)),wasClean:!0}))}else{let h=this._options[i(995)+i(1478)+i(1168)](_0x6aa73a,_0x335711);this["_dispatc"+i(688)+"ent"](EgIPmV[i(1751)](_0x5a52f4,EgIPmV.NsYGL,{code:_0x407b08,reason:_0x4a672a,wasClean:!0,willReconnect:h})),h&&this._connect()}return}else this[i(1322)](e[i(1077)],n),this[i(1909)]&&this[i(1909)](n)}get binaryType(){let n=t;return this[n(1260)]?this[n(1260)].binaryType:this[n(619)+n(1118)]}set[t(1662)+"pe"](n){let i=t;this[i(619)+"ype"]=n,this[i(1260)]&&(this[i(1260)][i(1662)+"pe"]=n)}get[t(1044)+"nt"](){let n=t;return this["_endpoin"+n(1125)]?.[n(946)+n(1652)+n(514)+n(1694)]()||0}get[t(1424)+t(726)](){let n=t,i=this[n(1040)+"Queue"][n(1541)]((f,u)=>(f+=u&&u[n(1725)+"th"]||0,f),0);return e[n(771)](i,this[n(1260)]?this._ws[n(1424)+"Amount"]:0)}get[t(1696)+"ns"](){let n=t;return this._ws?this[n(1260)].extensions:""}get[t(808)](){let n=t;return this._ws?this[n(1260)][n(808)]:""}get[t(1644)+"te"](){let n=t;return this._ws?this[n(1260)][n(1644)+"te"]:this[n(898)][n(1480)+n(2042)]?this[n(1042)+"NG"]:this[n(1123)]}get[t(1278)](){let n=t;if(e.yGAqy(e.iAmCb,n(1170)))return this[n(1260)]?this[n(1260)][n(1278)]:this[n(1487)];{let i=_0x44a548.substring(0,e[n(1021)](4,_0x500479[n(669)])),f=i[n(1951)](_0x13deb7);_0x35e9e6.push(f)}}[t(1142)](n=1e3,i){let f=t;if(this._readyClosed=!0,this[f(923)+f(1429)](),this["_clearPi"+f(2011)](),this[f(1388)+f(1746)+f(1422)](),this[f(769)+"ger"]?.[f(1401)](),!this[f(1260)])return void this[f(1133)](e[f(1660)]);if(e[f(659)](this[f(1260)][f(1644)+"te"],this.CLOSED)||e.IVweD(this[f(1260)][f(1644)+"te"],this[f(1319)]))return void this[f(1133)](e[f(1935)]);this[f(980)+f(820)+"t"](n,i)}async send(n,i){let f=t;if(e[f(1558)](null,n))throw new Error(e[f(953)]);e[f(1408)]==typeof n&&(n=JSON[f(1275)+"y"](n)),e[f(1191)](e[f(1692)],typeof n)&&!e[f(1391)](n,ArrayBuffer)&&!(n.buffer&&e.TLvls(n[f(1293)],ArrayBuffer))&&(n=JSON[f(1275)+"y"](n));let u=await e[f(870)](b0,n),h=e[f(1610)](Qx,n),{method:m=0,service:_=this[f(898)][f(1991)],logID:g=this[f(898)][f(991)+f(979)](),headers:T=this._options[f(872)],payloadEncoding:F=this[f(898)]["payloadE"+f(1164)],payloadType:M=this._options[f(1817)+"ype"],logIDNew:K=this[f(898)][f(1946)+f(657)][f(1466)+f(1363)+f(976)+"ew"]?e[f(1389)](s,this._options[f(1946)+f(657)].userIp):""}=e[f(1223)](i,{});if(!_)throw new Error(f(697)+f(830)+f(561)+"ervice");let $={SeqID:ce.fromNumber(this[f(879)]++),LogID:ce[f(629)+"er"](g),service:_,method:m,headers:T,payloadEncoding:F instanceof Object?F[f(974)]?F[f(974)]:"":F,payloadType:e.BnjFw(M,Object)?M[f(1587)]?M[f(1587)]:h:M||h,payload:u,LogIDNew:K},W=e[f(699)](We,$);return this[f(1260)]&&e[f(904)](this[f(1260)][f(1644)+"te"],this.OPEN)?(this[f(1260)]&&this[f(1260)][f(1211)](W),this[f(1133)](e.miSFy,$)):this[f(1040)+"Queue"].length<this._options[f(706)+f(1206)+f(1176)]?(this["_message"+f(1307)].push(W),this[f(1133)](e[f(1368)],$)):(this[f(1040)+f(1307)][f(1771)](),this["_message"+f(1307)].push(W)),{seqID:this[f(879)],logID:g,logIDNew:K}}async[t(995)+"t"](n){let i=t,{url:f}=n||{},u=Array[i(1980)](f)?f:i(1805)==typeof f?[f]:[];n&&Object.assign(this._options,n),u&&u[i(669)]?this[i(1403)+i(1125)]=new m0(u,this[i(898)][i(1485)+"es"]):this[i(1403)+i(1125)]?.[i(1994)+"pointCon"+i(672)](),this[i(1345)+i(1290)]?.[i(1808)+i(1678)](this[i(898)][i(1331)+"Count"]),this["_readyCl"+i(1944)]=!1,this[i(1260)]&&e[i(1404)](this[i(1260)][i(1644)+"te"],this.CLOSED)?this[i(1074)+"ect"](1e3,e[i(1244)],!0):(this._isInit=!0,this[i(651)]())}async[t(497)](){let n=t;if(!this[n(651)+n(663)]){let i=e.BZkMt[n(941)]("|"),f=0;for(;;){switch(i[f++]){case"0":this[n(1820)]=!0;continue;case"1":this[n(2022)+"osed"]=!1;continue;case"2":this[n(651)]();continue;case"3":this[n(1403)+n(1125)]?.[n(1994)+n(1464)+n(672)]();continue;case"4":this[n(1345)+n(1290)]?.["resetCou"+n(1678)]();continue}break}}}[t(1799)+"Listener"](n,i){this.on(n,i)}[t(477)+t(793)](n){let{type:i}=n;this.emit(i,n)}[t(1597)+t(1759)+t(1094)](n,i){let f=t;if(e[f(474)]!==f(1235))this.off(n,i);else{let u=e[f(613)](_0x4fd330,e[f(2031)],{message:this[f(1592)+f(725)+f(925)](_0xfcca08)});this[f(1322)](e[f(2031)],u);let h=_0x41953f("close",{reason:this[f(1592)+f(725)+f(925)](_0x375e47)});this.emit(e.wcqNZ,h)}}pingOnce(){let n=t,i={pdWop:function(f,u){return e[B(1012)](f,u)},wqOMz:e.zryHU,lLwLV:n(733)+n(1369)+"s",oHVNJ:e[n(759)],CQkGE:function(f,u){return f!==u},gLOMb:n(1285),gQgIw:function(f,u,h){return e[n(1719)](f,u,h)}};return new Promise((f,u)=>{let h=n,m={XZOws:function(_,g){return _(g)},ODTvt:i[h(1691)],cyolm:i[h(609)]};if(i.CQkGE(h(730),i[h(1821)])){this._clearPingTimer(),this[h(1413)+"gTimeoutId"]=i[h(816)](setTimeout,this._ping.bind(this),this[h(898)][h(1147)+"rval"]);let _=()=>{let T=h;i[T(1611)](f,i[T(1066)]),this[T(488)](i[T(1691)],_),this[T(488)](i[T(609)],g)},g=()=>{let T=h;m[T(2014)](u,T(999)),this.off(m.ODTvt,_),this[T(488)](m.cyolm,g)};this.on(i.lLwLV,_),this.on(i[h(609)],g),this[h(1927)]()}else return!0})}}})(),Te[N(1452)+"oseEvent"]=Se[N(1452)+"oseEvent"],Te[N(1187)+"rorEvent"]=Se[N(1187)+"rorEvent"],Te[N(1440)+"e"]=Se[N(1440)+"e"],Te[N(793)]=Se[N(793)],Te[N(1243)]=Se[N(1243)],Te[N(1562)+N(1695)+"vent"]=Se[N(1562)+N(1695)+N(1032)],Te[N(1695)+"vent"]=Se["MessageE"+N(1032)],Te.OpenEvent=Se[N(1355)+"t"],Te[N(1959)+N(1843)]=Se.ReconnectEvent,Te[N(690)+"oseEvent"]=Se[N(690)+"oseEvent"],Te["createEr"+N(1019)]=Se[N(773)+N(1019)],Te[N(530)+"ssageEvent"]=Se[N(530)+N(1140)+"nt"],Te[N(1549)+N(763)]=Se[N(1549)+N(763)],Te["createReconnectE"+N(1032)]=Se[N(2002)+N(1625)+"vent"],Te["decodedF"+N(1245)]=Se[N(586)+N(1245)],Te[N(1783)+"ame"]=Se["encodeFr"+N(1287)];for(Zs in Se)[N(1452)+"oseEvent",N(1187)+N(1019),N(1440)+"e",N(793),N(1243),N(1562)+"MessageEvent",N(1695)+"vent",N(1355)+"t","ReconnectEvent",N(690)+N(1237),"createEr"+N(1019),N(530)+N(1140)+"nt",N(1549)+"enEvent",N(2002)+"connectE"+N(1032),N(586)+N(1245),"encodeFr"+N(1287)][N(1266)](Zs)===-1&&(Te[Zs]=Se[Zs]);var Zs;Object[N(1300)+"operty"](Te,N(1866)+"le",{value:!0})});var Bt=re((bI,fl)=>{"use strict";var al=["nodebuffer","arraybuffer","fragments"],cl=typeof Blob<"u";cl&&al.push("blob");fl.exports={BINARY_TYPES:al,CLOSE_TIMEOUT:3e4,EMPTY_BUFFER:Buffer.alloc(0),GUID:"258EAFA5-E914-47DA-95CA-C5AB0DC85B11",hasBlob:cl,kForOnEventAttribute:Symbol("kIsForOnEventAttribute"),kListener:Symbol("kListener"),kStatusCode:Symbol("status-code"),kWebSocket:Symbol("websocket"),NOOP:()=>{}}});var vi=re((EI,no)=>{"use strict";var{EMPTY_BUFFER:my}=Bt(),vc=Buffer[Symbol.species];function wy(t,e){if(t.length===0)return my;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 vc(r.buffer,r.byteOffset,s):r}function dl(t,e,r,s,a){for(let c=0;c<a;c++)r[s+c]=t[c]^e[c&3]}function ul(t,e){for(let r=0;r<t.length;r++)t[r]^=e[r&3]}function _y(t){return t.length===t.buffer.byteLength?t.buffer:t.buffer.slice(t.byteOffset,t.byteOffset+t.length)}function Sc(t){if(Sc.readOnly=!0,Buffer.isBuffer(t))return t;let e;return t instanceof ArrayBuffer?e=new vc(t):ArrayBuffer.isView(t)?e=new vc(t.buffer,t.byteOffset,t.byteLength):(e=Buffer.from(t),Sc.readOnly=!1),e}no.exports={concat:wy,mask:dl,toArrayBuffer:_y,toBuffer:Sc,unmask:ul};if(!process.env.WS_NO_BUFFER_UTIL)try{let t=fe("bufferutil");no.exports.mask=function(e,r,s,a,c){c<48?dl(e,r,s,a,c):t.mask(e,r,s,a,c)},no.exports.unmask=function(e,r){e.length<32?ul(e,r):t.unmask(e,r)}}catch{}});var hl=re((vI,xl)=>{"use strict";var ll=Symbol("kDone"),Ic=Symbol("kRun"),Cc=class{constructor(e){this[ll]=()=>{this.pending--,this[Ic]()},this.concurrency=e||1/0,this.jobs=[],this.pending=0}add(e){this.jobs.push(e),this[Ic]()}[Ic](){if(this.pending!==this.concurrency&&this.jobs.length){let e=this.jobs.shift();this.pending++,e(this[ll])}}};xl.exports=Cc});var vr=re((SI,wl)=>{"use strict";var Si=fe("zlib"),pl=vi(),yy=hl(),{kStatusCode:gl}=Bt(),by=Buffer[Symbol.species],Ey=Buffer.from([0,0,255,255]),io=Symbol("permessage-deflate"),zt=Symbol("total-length"),br=Symbol("callback"),ln=Symbol("buffers"),Er=Symbol("error"),ro,Tc=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,!ro){let r=this._options.concurrencyLimit!==void 0?this._options.concurrencyLimit:10;ro=new yy(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){ro.add(a=>{this._decompress(e,r,(c,d)=>{a(),s(c,d)})})}compress(e,r,s){ro.add(a=>{this._compress(e,r,(c,d)=>{a(),s(c,d)})})}_decompress(e,r,s){let a=this._isServer?"client":"server";if(!this._inflate){let c=`${a}_max_window_bits`,d=typeof this.params[c]!="number"?Si.Z_DEFAULT_WINDOWBITS:this.params[c];this._inflate=Si.createInflateRaw({...this._options.zlibInflateOptions,windowBits:d}),this._inflate[io]=this,this._inflate[zt]=0,this._inflate[ln]=[],this._inflate.on("error",Sy),this._inflate.on("data",ml)}this._inflate[br]=s,this._inflate.write(e),r&&this._inflate.write(Ey),this._inflate.flush(()=>{let c=this._inflate[Er];if(c){this._inflate.close(),this._inflate=null,s(c);return}let d=pl.concat(this._inflate[ln],this._inflate[zt]);this._inflate._readableState.endEmitted?(this._inflate.close(),this._inflate=null):(this._inflate[zt]=0,this._inflate[ln]=[],r&&this.params[`${a}_no_context_takeover`]&&this._inflate.reset()),s(null,d)})}_compress(e,r,s){let a=this._isServer?"server":"client";if(!this._deflate){let c=`${a}_max_window_bits`,d=typeof this.params[c]!="number"?Si.Z_DEFAULT_WINDOWBITS:this.params[c];this._deflate=Si.createDeflateRaw({...this._options.zlibDeflateOptions,windowBits:d}),this._deflate[zt]=0,this._deflate[ln]=[],this._deflate.on("data",vy)}this._deflate[br]=s,this._deflate.write(e),this._deflate.flush(Si.Z_SYNC_FLUSH,()=>{if(!this._deflate)return;let c=pl.concat(this._deflate[ln],this._deflate[zt]);r&&(c=new by(c.buffer,c.byteOffset,c.length-4)),this._deflate[br]=null,this._deflate[zt]=0,this._deflate[ln]=[],r&&this.params[`${a}_no_context_takeover`]&&this._deflate.reset(),s(null,c)})}};wl.exports=Tc;function vy(t){this[ln].push(t),this[zt]+=t.length}function ml(t){if(this[zt]+=t.length,this[io]._maxPayload<1||this[zt]<=this[io]._maxPayload){this[ln].push(t);return}this[Er]=new RangeError("Max payload size exceeded"),this[Er].code="WS_ERR_UNSUPPORTED_MESSAGE_LENGTH",this[Er][gl]=1009,this.removeListener("data",ml),this.reset()}function Sy(t){if(this[io]._inflate=null,this[Er]){this[br](this[Er]);return}t[gl]=1007,this[br](t)}});var Sr=re((II,so)=>{"use strict";var{isUtf8:_l}=fe("buffer"),{hasBlob:Iy}=Bt(),Cy=[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 Ty(t){return t>=1e3&&t<=1014&&t!==1004&&t!==1005&&t!==1006||t>=3e3&&t<=4999}function Ac(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 Ay(t){return Iy&&typeof t=="object"&&typeof t.arrayBuffer=="function"&&typeof t.type=="string"&&typeof t.stream=="function"&&(t[Symbol.toStringTag]==="Blob"||t[Symbol.toStringTag]==="File")}so.exports={isBlob:Ay,isValidStatusCode:Ty,isValidUTF8:Ac,tokenChars:Cy};if(_l)so.exports.isValidUTF8=function(t){return t.length<24?Ac(t):_l(t)};else if(!process.env.WS_NO_UTF_8_VALIDATE)try{let t=fe("utf-8-validate");so.exports.isValidUTF8=function(e){return e.length<32?Ac(e):t(e)}}catch{}});var Pc=re((CI,Cl)=>{"use strict";var{Writable:Ry}=fe("stream"),yl=vr(),{BINARY_TYPES:Dy,EMPTY_BUFFER:bl,kStatusCode:ky,kWebSocket:Oy}=Bt(),{concat:Rc,toArrayBuffer:Py,unmask:Ly}=vi(),{isValidStatusCode:Ny,isValidUTF8:El}=Sr(),oo=Buffer[Symbol.species],rt=0,vl=1,Sl=2,Il=3,Dc=4,kc=5,ao=6,Oc=class extends Ry{constructor(e={}){super(),this._allowSynchronousEvents=e.allowSynchronousEvents!==void 0?e.allowSynchronousEvents:!0,this._binaryType=e.binaryType||Dy[0],this._extensions=e.extensions||{},this._isServer=!!e.isServer,this._maxPayload=e.maxPayload|0,this._skipUTF8Validation=!!e.skipUTF8Validation,this[Oy]=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=rt}_write(e,r,s){if(this._opcode===8&&this._state==rt)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 oo(s.buffer,s.byteOffset+e,s.length-e),new oo(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 oo(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 rt:this.getInfo(e);break;case vl:this.getPayloadLength16(e);break;case Sl:this.getPayloadLength64(e);break;case Il:this.getMask();break;case Dc:this.getData(e);break;case kc:case ao: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[yl.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=vl:this._payloadLength===127?this._state=Sl: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=Il:this._state=Dc}getMask(){if(this._bufferedBytes<4){this._loop=!1;return}this._mask=this.consume(4),this._state=Dc}getData(e){let r=bl;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&&Ly(r,this._mask)}if(this._opcode>7){this.controlMessage(r,e);return}if(this._compressed){this._state=kc,this.decompress(r,e);return}r.length&&(this._messageLength=this._totalPayloadLength,this._fragments.push(r)),this.dataMessage(e)}decompress(e,r){this._extensions[yl.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 d=this.createError(RangeError,"Max payload size exceeded",!1,1009,"WS_ERR_UNSUPPORTED_MESSAGE_LENGTH");r(d);return}this._fragments.push(c)}this.dataMessage(r),this._state===rt&&this.startLoop(r)})}dataMessage(e){if(!this._fin){this._state=rt;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=Rc(s,r):this._binaryType==="arraybuffer"?a=Py(Rc(s,r)):this._binaryType==="blob"?a=new Blob(s):a=s,this._allowSynchronousEvents?(this.emit("message",a,!0),this._state=rt):(this._state=ao,setImmediate(()=>{this.emit("message",a,!0),this._state=rt,this.startLoop(e)}))}else{let a=Rc(s,r);if(!this._skipUTF8Validation&&!El(a)){let c=this.createError(Error,"invalid UTF-8 sequence",!0,1007,"WS_ERR_INVALID_UTF8");e(c);return}this._state===kc||this._allowSynchronousEvents?(this.emit("message",a,!1),this._state=rt):(this._state=ao,setImmediate(()=>{this.emit("message",a,!1),this._state=rt,this.startLoop(e)}))}}controlMessage(e,r){if(this._opcode===8){if(e.length===0)this._loop=!1,this.emit("conclude",1005,bl),this.end();else{let s=e.readUInt16BE(0);if(!Ny(s)){let c=this.createError(RangeError,`invalid status code ${s}`,!0,1002,"WS_ERR_INVALID_CLOSE_CODE");r(c);return}let a=new oo(e.buffer,e.byteOffset+2,e.length-2);if(!this._skipUTF8Validation&&!El(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=rt;return}this._allowSynchronousEvents?(this.emit(this._opcode===9?"ping":"pong",e),this._state=rt):(this._state=ao,setImmediate(()=>{this.emit(this._opcode===9?"ping":"pong",e),this._state=rt,this.startLoop(r)}))}createError(e,r,s,a,c){this._loop=!1,this._errored=!0;let d=new e(s?`Invalid WebSocket frame: ${r}`:r);return Error.captureStackTrace(d,this.createError),d.code=c,d[ky]=a,d}};Cl.exports=Oc});var Mc=re((AI,Rl)=>{"use strict";var{Duplex:TI}=fe("stream"),{randomFillSync:My}=fe("crypto"),Tl=vr(),{EMPTY_BUFFER:By,kWebSocket:zy,NOOP:Fy}=Bt(),{isBlob:Ir,isValidStatusCode:Uy}=Sr(),{mask:Al,toBuffer:Pn}=vi(),it=Symbol("kByteLength"),Hy=Buffer.alloc(4),co=8*1024,Ln,Cr=co,xt=0,qy=1,Gy=2,Lc=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=xt,this.onerror=Fy,this[zy]=void 0}static frame(e,r){let s,a=!1,c=2,d=!1;r.mask&&(s=r.maskBuffer||Hy,r.generateMask?r.generateMask(s):(Cr===co&&(Ln===void 0&&(Ln=Buffer.alloc(co)),My(Ln,0,co),Cr=0),s[0]=Ln[Cr++],s[1]=Ln[Cr++],s[2]=Ln[Cr++],s[3]=Ln[Cr++]),d=(s[0]|s[1]|s[2]|s[3])===0,c=6);let l;typeof e=="string"?(!r.mask||d)&&r[it]!==void 0?l=r[it]:(e=Buffer.from(e),l=e.length):(l=e.length,a=r.mask&&r.readOnly&&!d);let x=l;l>=65536?(c+=8,x=127):l>125&&(c+=2,x=126);let p=Buffer.allocUnsafe(a?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]=s[0],p[c-3]=s[1],p[c-2]=s[2],p[c-1]=s[3],d?[p,e]:a?(Al(e,s,p,c,l),[p]):(Al(e,s,e,0,l),[p,e])):[p,e]}close(e,r,s,a){let c;if(e===void 0)c=By;else{if(typeof e!="number"||!Uy(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 d={[it]:c.length,fin:!0,generateMask:this._generateMask,mask:s,maskBuffer:this._maskBuffer,opcode:8,readOnly:!1,rsv1:!1};this._state!==xt?this.enqueue([this.dispatch,c,!1,d,a]):this.sendFrame(t.frame(c,d),a)}ping(e,r,s){let a,c;if(typeof e=="string"?(a=Buffer.byteLength(e),c=!1):Ir(e)?(a=e.size,c=!1):(e=Pn(e),a=e.length,c=Pn.readOnly),a>125)throw new RangeError("The data size must not be greater than 125 bytes");let d={[it]:a,fin:!0,generateMask:this._generateMask,mask:r,maskBuffer:this._maskBuffer,opcode:9,readOnly:c,rsv1:!1};Ir(e)?this._state!==xt?this.enqueue([this.getBlobData,e,!1,d,s]):this.getBlobData(e,!1,d,s):this._state!==xt?this.enqueue([this.dispatch,e,!1,d,s]):this.sendFrame(t.frame(e,d),s)}pong(e,r,s){let a,c;if(typeof e=="string"?(a=Buffer.byteLength(e),c=!1):Ir(e)?(a=e.size,c=!1):(e=Pn(e),a=e.length,c=Pn.readOnly),a>125)throw new RangeError("The data size must not be greater than 125 bytes");let d={[it]:a,fin:!0,generateMask:this._generateMask,mask:r,maskBuffer:this._maskBuffer,opcode:10,readOnly:c,rsv1:!1};Ir(e)?this._state!==xt?this.enqueue([this.getBlobData,e,!1,d,s]):this.getBlobData(e,!1,d,s):this._state!==xt?this.enqueue([this.dispatch,e,!1,d,s]):this.sendFrame(t.frame(e,d),s)}send(e,r,s){let a=this._extensions[Tl.extensionName],c=r.binary?2:1,d=r.compress,l,x;typeof e=="string"?(l=Buffer.byteLength(e),x=!1):Ir(e)?(l=e.size,x=!1):(e=Pn(e),l=e.length,x=Pn.readOnly),this._firstFragment?(this._firstFragment=!1,d&&a&&a.params[a._isServer?"server_no_context_takeover":"client_no_context_takeover"]&&(d=l>=a._threshold),this._compress=d):(d=!1,c=0),r.fin&&(this._firstFragment=!0);let p={[it]:l,fin:r.fin,generateMask:this._generateMask,mask:r.mask,maskBuffer:this._maskBuffer,opcode:c,readOnly:x,rsv1:d};Ir(e)?this._state!==xt?this.enqueue([this.getBlobData,e,this._compress,p,s]):this.getBlobData(e,this._compress,p,s):this._state!==xt?this.enqueue([this.dispatch,e,this._compress,p,s]):this.dispatch(e,this._compress,p,s)}getBlobData(e,r,s,a){this._bufferedBytes+=s[it],this._state=Gy,e.arrayBuffer().then(c=>{if(this._socket.destroyed){let l=new Error("The socket was closed while the blob was being read");process.nextTick(Nc,this,l,a);return}this._bufferedBytes-=s[it];let d=Pn(c);r?this.dispatch(d,r,s,a):(this._state=xt,this.sendFrame(t.frame(d,s),a),this.dequeue())}).catch(c=>{process.nextTick(jy,this,c,a)})}dispatch(e,r,s,a){if(!r){this.sendFrame(t.frame(e,s),a);return}let c=this._extensions[Tl.extensionName];this._bufferedBytes+=s[it],this._state=qy,c.compress(e,s.fin,(d,l)=>{if(this._socket.destroyed){let x=new Error("The socket was closed while data was being compressed");Nc(this,x,a);return}this._bufferedBytes-=s[it],this._state=xt,s.readOnly=!1,this.sendFrame(t.frame(l,s),a),this.dequeue()})}dequeue(){for(;this._state===xt&&this._queue.length;){let e=this._queue.shift();this._bufferedBytes-=e[3][it],Reflect.apply(e[0],this,e.slice(1))}}enqueue(e){this._bufferedBytes+=e[3][it],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)}};Rl.exports=Lc;function Nc(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 jy(t,e,r){Nc(t,e,r),t.onerror(e)}});var zl=re((RI,Bl)=>{"use strict";var{kForOnEventAttribute:Ii,kListener:Bc}=Bt(),Dl=Symbol("kCode"),kl=Symbol("kData"),Ol=Symbol("kError"),Pl=Symbol("kMessage"),Ll=Symbol("kReason"),Tr=Symbol("kTarget"),Nl=Symbol("kType"),Ml=Symbol("kWasClean"),Ft=class{constructor(e){this[Tr]=null,this[Nl]=e}get target(){return this[Tr]}get type(){return this[Nl]}};Object.defineProperty(Ft.prototype,"target",{enumerable:!0});Object.defineProperty(Ft.prototype,"type",{enumerable:!0});var Nn=class extends Ft{constructor(e,r={}){super(e),this[Dl]=r.code===void 0?0:r.code,this[Ll]=r.reason===void 0?"":r.reason,this[Ml]=r.wasClean===void 0?!1:r.wasClean}get code(){return this[Dl]}get reason(){return this[Ll]}get wasClean(){return this[Ml]}};Object.defineProperty(Nn.prototype,"code",{enumerable:!0});Object.defineProperty(Nn.prototype,"reason",{enumerable:!0});Object.defineProperty(Nn.prototype,"wasClean",{enumerable:!0});var Ar=class extends Ft{constructor(e,r={}){super(e),this[Ol]=r.error===void 0?null:r.error,this[Pl]=r.message===void 0?"":r.message}get error(){return this[Ol]}get message(){return this[Pl]}};Object.defineProperty(Ar.prototype,"error",{enumerable:!0});Object.defineProperty(Ar.prototype,"message",{enumerable:!0});var Ci=class extends Ft{constructor(e,r={}){super(e),this[kl]=r.data===void 0?null:r.data}get data(){return this[kl]}};Object.defineProperty(Ci.prototype,"data",{enumerable:!0});var Wy={addEventListener(t,e,r={}){for(let a of this.listeners(t))if(!r[Ii]&&a[Bc]===e&&!a[Ii])return;let s;if(t==="message")s=function(c,d){let l=new Ci("message",{data:d?c:c.toString()});l[Tr]=this,fo(e,this,l)};else if(t==="close")s=function(c,d){let l=new Nn("close",{code:c,reason:d.toString(),wasClean:this._closeFrameReceived&&this._closeFrameSent});l[Tr]=this,fo(e,this,l)};else if(t==="error")s=function(c){let d=new Ar("error",{error:c,message:c.message});d[Tr]=this,fo(e,this,d)};else if(t==="open")s=function(){let c=new Ft("open");c[Tr]=this,fo(e,this,c)};else return;s[Ii]=!!r[Ii],s[Bc]=e,r.once?this.once(t,s):this.on(t,s)},removeEventListener(t,e){for(let r of this.listeners(t))if(r[Bc]===e&&!r[Ii]){this.removeListener(t,r);break}}};Bl.exports={CloseEvent:Nn,ErrorEvent:Ar,Event:Ft,EventTarget:Wy,MessageEvent:Ci};function fo(t,e,r){typeof t=="object"&&t.handleEvent?t.handleEvent.call(t,r):t.call(e,r)}});var uo=re((DI,Fl)=>{"use strict";var{tokenChars:Ti}=Sr();function At(t,e,r){t[e]===void 0?t[e]=[r]:t[e].push(r)}function Ky(t){let e=Object.create(null),r=Object.create(null),s=!1,a=!1,c=!1,d,l,x=-1,p=-1,w=-1,v=0;for(;v<t.length;v++)if(p=t.charCodeAt(v),d===void 0)if(w===-1&&Ti[p]===1)x===-1&&(x=v);else if(v!==0&&(p===32||p===9))w===-1&&x!==-1&&(w=v);else if(p===59||p===44){if(x===-1)throw new SyntaxError(`Unexpected character at index ${v}`);w===-1&&(w=v);let b=t.slice(x,w);p===44?(At(e,b,r),r=Object.create(null)):d=b,x=w=-1}else throw new SyntaxError(`Unexpected character at index ${v}`);else if(l===void 0)if(w===-1&&Ti[p]===1)x===-1&&(x=v);else if(p===32||p===9)w===-1&&x!==-1&&(w=v);else if(p===59||p===44){if(x===-1)throw new SyntaxError(`Unexpected character at index ${v}`);w===-1&&(w=v),At(r,t.slice(x,w),!0),p===44&&(At(e,d,r),r=Object.create(null),d=void 0),x=w=-1}else if(p===61&&x!==-1&&w===-1)l=t.slice(x,v),x=w=-1;else throw new SyntaxError(`Unexpected character at index ${v}`);else if(a){if(Ti[p]!==1)throw new SyntaxError(`Unexpected character at index ${v}`);x===-1?x=v:s||(s=!0),a=!1}else if(c)if(Ti[p]===1)x===-1&&(x=v);else if(p===34&&x!==-1)c=!1,w=v;else if(p===92)a=!0;else throw new SyntaxError(`Unexpected character at index ${v}`);else if(p===34&&t.charCodeAt(v-1)===61)c=!0;else if(w===-1&&Ti[p]===1)x===-1&&(x=v);else if(x!==-1&&(p===32||p===9))w===-1&&(w=v);else if(p===59||p===44){if(x===-1)throw new SyntaxError(`Unexpected character at index ${v}`);w===-1&&(w=v);let b=t.slice(x,w);s&&(b=b.replace(/\\/g,""),s=!1),At(r,l,b),p===44&&(At(e,d,r),r=Object.create(null),d=void 0),l=void 0,x=w=-1}else throw new SyntaxError(`Unexpected character at index ${v}`);if(x===-1||c||p===32||p===9)throw new SyntaxError("Unexpected end of input");w===-1&&(w=v);let I=t.slice(x,w);return d===void 0?At(e,I,r):(l===void 0?At(r,I,!0):s?At(r,l,I.replace(/\\/g,"")):At(r,l,I),At(e,d,r)),e}function $y(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(d=>d===!0?a:`${a}=${d}`).join("; ")})).join("; ")).join(", ")}).join(", ")}Fl.exports={format:$y,parse:Ky}});var po=re((PI,Yl)=>{"use strict";var Vy=fe("events"),Zy=fe("https"),Jy=fe("http"),ql=fe("net"),Yy=fe("tls"),{randomBytes:Xy,createHash:Qy}=fe("crypto"),{Duplex:kI,Readable:OI}=fe("stream"),{URL:zc}=fe("url"),xn=vr(),eb=Pc(),tb=Mc(),{isBlob:nb}=Sr(),{BINARY_TYPES:Ul,CLOSE_TIMEOUT:rb,EMPTY_BUFFER:lo,GUID:ib,kForOnEventAttribute:Fc,kListener:sb,kStatusCode:ob,kWebSocket:Me,NOOP:Gl}=Bt(),{EventTarget:{addEventListener:ab,removeEventListener:cb}}=zl(),{format:fb,parse:db}=uo(),{toBuffer:ub}=vi(),jl=Symbol("kAborted"),Uc=[8,13],Ut=["CONNECTING","OPEN","CLOSING","CLOSED"],lb=/^[!#$%&'*+\-.0-9A-Z^_`|a-z~]+$/,ue=class t extends Vy{constructor(e,r,s){super(),this._binaryType=Ul[0],this._closeCode=1006,this._closeFrameReceived=!1,this._closeFrameSent=!1,this._closeMessage=lo,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]),Wl(this,e,r,s)):(this._autoPong=s.autoPong,this._closeTimeout=s.closeTimeout,this._isServer=!0)}get binaryType(){return this._binaryType}set binaryType(e){Ul.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 eb({allowSynchronousEvents:s.allowSynchronousEvents,binaryType:this.binaryType,extensions:this._extensions,isServer:this._isServer,maxPayload:s.maxPayload,skipUTF8Validation:s.skipUTF8Validation}),c=new tb(e,this._extensions,s.generateMask);this._receiver=a,this._sender=c,this._socket=e,a[Me]=this,c[Me]=this,e[Me]=this,a.on("conclude",pb),a.on("drain",gb),a.on("error",mb),a.on("message",wb),a.on("ping",_b),a.on("pong",yb),c.onerror=bb,e.setTimeout&&e.setTimeout(0),e.setNoDelay&&e.setNoDelay(),r.length>0&&e.unshift(r),e.on("close",Vl),e.on("data",ho),e.on("end",Zl),e.on("error",Jl),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[xn.extensionName]&&this._extensions[xn.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,s=>{s||(this._closeFrameSent=!0,(this._closeFrameReceived||this._receiver._writableState.errorEmitted)&&this._socket.end())}),$l(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){Hc(this,e,s);return}r===void 0&&(r=!this._isServer),this._sender.ping(e||lo,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){Hc(this,e,s);return}r===void 0&&(r=!this._isServer),this._sender.pong(e||lo,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){Hc(this,e,s);return}let a={binary:typeof e!="string",mask:!this._isServer,compress:!0,fin:!0,...r};this._extensions[xn.extensionName]||(a.compress=!1),this._sender.send(e||lo,a,s)}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(ue,"CONNECTING",{enumerable:!0,value:Ut.indexOf("CONNECTING")});Object.defineProperty(ue.prototype,"CONNECTING",{enumerable:!0,value:Ut.indexOf("CONNECTING")});Object.defineProperty(ue,"OPEN",{enumerable:!0,value:Ut.indexOf("OPEN")});Object.defineProperty(ue.prototype,"OPEN",{enumerable:!0,value:Ut.indexOf("OPEN")});Object.defineProperty(ue,"CLOSING",{enumerable:!0,value:Ut.indexOf("CLOSING")});Object.defineProperty(ue.prototype,"CLOSING",{enumerable:!0,value:Ut.indexOf("CLOSING")});Object.defineProperty(ue,"CLOSED",{enumerable:!0,value:Ut.indexOf("CLOSED")});Object.defineProperty(ue.prototype,"CLOSED",{enumerable:!0,value:Ut.indexOf("CLOSED")});["binaryType","bufferedAmount","extensions","isPaused","protocol","readyState","url"].forEach(t=>{Object.defineProperty(ue.prototype,t,{enumerable:!0})});["open","error","close","message"].forEach(t=>{Object.defineProperty(ue.prototype,`on${t}`,{enumerable:!0,get(){for(let e of this.listeners(t))if(e[Fc])return e[sb];return null},set(e){for(let r of this.listeners(t))if(r[Fc]){this.removeListener(t,r);break}typeof e=="function"&&this.addEventListener(t,e,{[Fc]:!0})}})});ue.prototype.addEventListener=ab;ue.prototype.removeEventListener=cb;Yl.exports=ue;function Wl(t,e,r,s){let a={allowSynchronousEvents:!0,autoPong:!0,closeTimeout:rb,protocolVersion:Uc[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,!Uc.includes(a.protocolVersion))throw new RangeError(`Unsupported protocol version: ${a.protocolVersion} (supported versions: ${Uc.join(", ")})`);let c;if(e instanceof zc)c=e;else try{c=new zc(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 d=c.protocol==="wss:",l=c.protocol==="ws+unix:",x;if(c.protocol!=="ws:"&&!d&&!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 S=new SyntaxError(x);if(t._redirects===0)throw S;xo(t,S);return}let p=d?443:80,w=Xy(16).toString("base64"),v=d?Zy.request:Jy.request,I=new Set,b;if(a.createConnection=a.createConnection||(d?hb:xb),a.defaultPort=a.defaultPort||p,a.port=c.port||p,a.host=c.hostname.startsWith("[")?c.hostname.slice(1,-1):c.hostname,a.headers={...a.headers,"Sec-WebSocket-Version":a.protocolVersion,"Sec-WebSocket-Key":w,Connection:"Upgrade",Upgrade:"websocket"},a.path=c.pathname+c.search,a.timeout=a.handshakeTimeout,a.perMessageDeflate&&(b=new xn({...a.perMessageDeflate,isServer:!1,maxPayload:a.maxPayload}),a.headers["Sec-WebSocket-Extensions"]=fb({[xn.extensionName]:b.offer()})),r.length){for(let S of r){if(typeof S!="string"||!lb.test(S)||I.has(S))throw new SyntaxError("An invalid or duplicated subprotocol was specified");I.add(S)}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 S=a.path.split(":");a.socketPath=S[0],a.path=S[1]}let E;if(a.followRedirects){if(t._redirects===0){t._originalIpc=l,t._originalSecure=d,t._originalHostOrSocketPath=l?a.socketPath:c.host;let S=s&&s.headers;if(s={...s,headers:{}},S)for(let[C,D]of Object.entries(S))s.headers[C.toLowerCase()]=D}else if(t.listenerCount("redirect")===0){let S=l?t._originalIpc?a.socketPath===t._originalHostOrSocketPath:!1:t._originalIpc?!1:c.host===t._originalHostOrSocketPath;(!S||t._originalSecure&&!d)&&(delete a.headers.authorization,delete a.headers.cookie,S||delete a.headers.host,a.auth=void 0)}a.auth&&!s.headers.authorization&&(s.headers.authorization="Basic "+Buffer.from(a.auth).toString("base64")),E=t._req=v(a),t._redirects&&t.emit("redirect",t.url,E)}else E=t._req=v(a);a.timeout&&E.on("timeout",()=>{Xe(t,E,"Opening handshake has timed out")}),E.on("error",S=>{E===null||E[jl]||(E=t._req=null,xo(t,S))}),E.on("response",S=>{let C=S.headers.location,D=S.statusCode;if(C&&a.followRedirects&&D>=300&&D<400){if(++t._redirects>a.maxRedirects){Xe(t,E,"Maximum redirects exceeded");return}E.abort();let P;try{P=new zc(C,e)}catch{let A=new SyntaxError(`Invalid URL: ${C}`);xo(t,A);return}Wl(t,P,r,s)}else t.emit("unexpected-response",E,S)||Xe(t,E,`Unexpected server response: ${S.statusCode}`)}),E.on("upgrade",(S,C,D)=>{if(t.emit("upgrade",S),t.readyState!==ue.CONNECTING)return;E=t._req=null;let P=S.headers.upgrade;if(P===void 0||P.toLowerCase()!=="websocket"){Xe(t,C,"Invalid Upgrade header");return}let y=Qy("sha1").update(w+ib).digest("base64");if(S.headers["sec-websocket-accept"]!==y){Xe(t,C,"Invalid Sec-WebSocket-Accept header");return}let A=S.headers["sec-websocket-protocol"],O;if(A!==void 0?I.size?I.has(A)||(O="Server sent an invalid subprotocol"):O="Server sent a subprotocol but none was requested":I.size&&(O="Server sent no subprotocol"),O){Xe(t,C,O);return}A&&(t._protocol=A);let U=S.headers["sec-websocket-extensions"];if(U!==void 0){if(!b){Xe(t,C,"Server sent a Sec-WebSocket-Extensions header but no extension was requested");return}let z;try{z=db(U)}catch{Xe(t,C,"Invalid Sec-WebSocket-Extensions header");return}let k=Object.keys(z);if(k.length!==1||k[0]!==xn.extensionName){Xe(t,C,"Server indicated an extension that was not requested");return}try{b.accept(z[xn.extensionName])}catch{Xe(t,C,"Invalid Sec-WebSocket-Extensions header");return}t._extensions[xn.extensionName]=b}t.setSocket(C,D,{allowSynchronousEvents:a.allowSynchronousEvents,generateMask:a.generateMask,maxPayload:a.maxPayload,skipUTF8Validation:a.skipUTF8Validation})}),a.finishRequest?a.finishRequest(E,t):E.end()}function xo(t,e){t._readyState=ue.CLOSING,t._errorEmitted=!0,t.emit("error",e),t.emitClose()}function xb(t){return t.path=t.socketPath,ql.connect(t)}function hb(t){return t.path=void 0,!t.servername&&t.servername!==""&&(t.servername=ql.isIP(t.host)?"":t.host),Yy.connect(t)}function Xe(t,e,r){t._readyState=ue.CLOSING;let s=new Error(r);Error.captureStackTrace(s,Xe),e.setHeader?(e[jl]=!0,e.abort(),e.socket&&!e.socket.destroyed&&e.socket.destroy(),process.nextTick(xo,t,s)):(e.destroy(s),e.once("error",t.emit.bind(t,"error")),e.once("close",t.emitClose.bind(t)))}function Hc(t,e,r){if(e){let s=nb(e)?e.size:ub(e).length;t._socket?t._sender._bufferedBytes+=s:t._bufferedAmount+=s}if(r){let s=new Error(`WebSocket is not open: readyState ${t.readyState} (${Ut[t.readyState]})`);process.nextTick(r,s)}}function pb(t,e){let r=this[Me];r._closeFrameReceived=!0,r._closeMessage=e,r._closeCode=t,r._socket[Me]!==void 0&&(r._socket.removeListener("data",ho),process.nextTick(Kl,r._socket),t===1005?r.close():r.close(t,e))}function gb(){let t=this[Me];t.isPaused||t._socket.resume()}function mb(t){let e=this[Me];e._socket[Me]!==void 0&&(e._socket.removeListener("data",ho),process.nextTick(Kl,e._socket),e.close(t[ob])),e._errorEmitted||(e._errorEmitted=!0,e.emit("error",t))}function Hl(){this[Me].emitClose()}function wb(t,e){this[Me].emit("message",t,e)}function _b(t){let e=this[Me];e._autoPong&&e.pong(t,!this._isServer,Gl),e.emit("ping",t)}function yb(t){this[Me].emit("pong",t)}function Kl(t){t.resume()}function bb(t){let e=this[Me];e.readyState!==ue.CLOSED&&(e.readyState===ue.OPEN&&(e._readyState=ue.CLOSING,$l(e)),this._socket.end(),e._errorEmitted||(e._errorEmitted=!0,e.emit("error",t)))}function $l(t){t._closeTimer=setTimeout(t._socket.destroy.bind(t._socket),t._closeTimeout)}function Vl(){let t=this[Me];if(this.removeListener("close",Vl),this.removeListener("data",ho),this.removeListener("end",Zl),t._readyState=ue.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[Me]=void 0,clearTimeout(t._closeTimer),t._receiver._writableState.finished||t._receiver._writableState.errorEmitted?t.emitClose():(t._receiver.on("error",Hl),t._receiver.on("finish",Hl))}function ho(t){this[Me]._receiver.write(t)||this.pause()}function Zl(){let t=this[Me];t._readyState=ue.CLOSING,t._receiver.end(),this.end()}function Jl(){let t=this[Me];this.removeListener("error",Jl),this.on("error",Gl),t&&(t._readyState=ue.CLOSING,this.destroy())}});var tx=re((NI,ex)=>{"use strict";var LI=po(),{Duplex:Eb}=fe("stream");function Xl(t){t.emit("close")}function vb(){!this.destroyed&&this._writableState.finished&&this.destroy()}function Ql(t){this.removeListener("error",Ql),this.destroy(),this.listenerCount("error")===0&&this.emit("error",t)}function Sb(t,e){let r=!0,s=new Eb({...e,autoDestroy:!1,emitClose:!1,objectMode:!1,writableObjectMode:!1});return t.on("message",function(c,d){let l=!d&&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(Xl,s);return}let d=!1;t.once("error",function(x){d=!0,c(x)}),t.once("close",function(){d||c(a),process.nextTick(Xl,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,d){if(t.readyState===t.CONNECTING){t.once("open",function(){s._write(a,c,d)});return}t.send(a,d)},s.on("end",vb),s.on("error",Ql),s}ex.exports=Sb});var qc=re((MI,nx)=>{"use strict";var{tokenChars:Ib}=Sr();function Cb(t){let e=new Set,r=-1,s=-1,a=0;for(a;a<t.length;a++){let d=t.charCodeAt(a);if(s===-1&&Ib[d]===1)r===-1&&(r=a);else if(a!==0&&(d===32||d===9))s===-1&&r!==-1&&(s=a);else if(d===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}nx.exports={parse:Cb}});var fx=re((zI,cx)=>{"use strict";var Tb=fe("events"),go=fe("http"),{Duplex:BI}=fe("stream"),{createHash:Ab}=fe("crypto"),rx=uo(),Mn=vr(),Rb=qc(),Db=po(),{CLOSE_TIMEOUT:kb,GUID:Ob,kWebSocket:Pb}=Bt(),Lb=/^[+/0-9A-Za-z]{22}==$/,ix=0,sx=1,ax=2,Gc=class extends Tb{constructor(e,r){if(super(),e={allowSynchronousEvents:!0,autoPong:!0,maxPayload:100*1024*1024,skipUTF8Validation:!1,perMessageDeflate:!1,handleProtocols:null,clientTracking:!0,closeTimeout:kb,verifyClient:null,noServer:!1,backlog:null,server:null,host:null,path:null,port:null,WebSocket:Db,...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=go.createServer((s,a)=>{let c=go.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=Nb(this._server,{listening:this.emit.bind(this,"listening"),error:this.emit.bind(this,"error"),upgrade:(a,c,d)=>{this.handleUpgrade(a,c,d,s)}})}e.perMessageDeflate===!0&&(e.perMessageDeflate={}),e.clientTracking&&(this.clients=new Set,this._shouldEmitClose=!1),this.options=e,this._state=ix}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===ax){e&&this.once("close",()=>{e(new Error("The server is not running"))}),process.nextTick(Ai,this);return}if(e&&this.once("close",e),this._state!==sx)if(this._state=sx,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(Ai,this):process.nextTick(Ai,this);else{let r=this._server;this._removeListeners(),this._removeListeners=this._server=null,r.close(()=>{Ai(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",ox);let c=e.headers["sec-websocket-key"],d=e.headers.upgrade,l=+e.headers["sec-websocket-version"];if(e.method!=="GET"){Bn(this,e,r,405,"Invalid HTTP method");return}if(d===void 0||d.toLowerCase()!=="websocket"){Bn(this,e,r,400,"Invalid Upgrade header");return}if(c===void 0||!Lb.test(c)){Bn(this,e,r,400,"Missing or invalid Sec-WebSocket-Key header");return}if(l!==13&&l!==8){Bn(this,e,r,400,"Missing or invalid Sec-WebSocket-Version header",{"Sec-WebSocket-Version":"13, 8"});return}if(!this.shouldHandle(e)){Ri(r,400);return}let x=e.headers["sec-websocket-protocol"],p=new Set;if(x!==void 0)try{p=Rb.parse(x)}catch{Bn(this,e,r,400,"Invalid Sec-WebSocket-Protocol header");return}let w=e.headers["sec-websocket-extensions"],v={};if(this.options.perMessageDeflate&&w!==void 0){let I=new Mn({...this.options.perMessageDeflate,isServer:!0,maxPayload:this.options.maxPayload});try{let b=rx.parse(w);b[Mn.extensionName]&&(I.accept(b[Mn.extensionName]),v[Mn.extensionName]=I)}catch{Bn(this,e,r,400,"Invalid or unacceptable Sec-WebSocket-Extensions header");return}}if(this.options.verifyClient){let I={origin:e.headers[`${l===8?"sec-websocket-origin":"origin"}`],secure:!!(e.socket.authorized||e.socket.encrypted),req:e};if(this.options.verifyClient.length===2){this.options.verifyClient(I,(b,E,S,C)=>{if(!b)return Ri(r,E||401,S,C);this.completeUpgrade(v,c,p,e,r,s,a)});return}if(!this.options.verifyClient(I))return Ri(r,401)}this.completeUpgrade(v,c,p,e,r,s,a)}completeUpgrade(e,r,s,a,c,d,l){if(!c.readable||!c.writable)return c.destroy();if(c[Pb])throw new Error("server.handleUpgrade() was called more than once with the same socket, possibly due to a misconfiguration");if(this._state>ix)return Ri(c,503);let p=["HTTP/1.1 101 Switching Protocols","Upgrade: websocket","Connection: Upgrade",`Sec-WebSocket-Accept: ${Ab("sha1").update(r+Ob).digest("base64")}`],w=new this.options.WebSocket(null,void 0,this.options);if(s.size){let v=this.options.handleProtocols?this.options.handleProtocols(s,a):s.values().next().value;v&&(p.push(`Sec-WebSocket-Protocol: ${v}`),w._protocol=v)}if(e[Mn.extensionName]){let v=e[Mn.extensionName].params,I=rx.format({[Mn.extensionName]:[v]});p.push(`Sec-WebSocket-Extensions: ${I}`),w._extensions=e}this.emit("headers",p,a),c.write(p.concat(`\r
8
+ var Bh=Object.create;var Fo=Object.defineProperty;var zh=Object.getOwnPropertyDescriptor;var Fh=Object.getOwnPropertyNames;var Uh=Object.getPrototypeOf,Hh=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 ot=(t,e)=>()=>(t&&(e=t(t=0)),e);var ne=(t,e)=>()=>(e||t((e={exports:{}}).exports,e),e.exports),Uo=(t,e)=>{for(var r in e)Fo(t,r,{get:e[r],enumerable:!0})},qh=(t,e,r,i)=>{if(e&&typeof e=="object"||typeof e=="function")for(let o of Fh(e))!Hh.call(t,o)&&o!==r&&Fo(t,o,{get:()=>e[o],enumerable:!(i=zh(e,o))||i.enumerable});return t};var xt=(t,e,r)=>(r=t!=null?Bh(Uh(t)):{},qh(e||!t||!t.__esModule?Fo(r,"default",{value:t,enumerable:!0}):r,t));function T0(t){Ho=t}function C0(t){return Oi[Ho]<=Oi[t]}function Pi(t){A0={...t}}function Kh(t){let e=(u,x=2)=>String(u).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 ki(t,e,r,i){if(Oi[t]<Oi[Ho])return;let o=JSON.stringify({ts:Kh(new Date),level:t,module:e,msg:r,...A0,...i});t==="error"||t==="warn"?jh.write(`${o}
9
+ `):Gh.write(`${o}
10
+ `)}function G(t){return{debug:(e,r)=>ki("debug",t,e,r),info:(e,r)=>ki("info",t,e,r),warn:(e,r)=>ki("warn",t,e,r),error:(e,r)=>ki("error",t,e,r),child:e=>G(`${t}.${e}`)}}var Oi,Ho,Gh,jh,A0,ee=ot(()=>{"use strict";Oi={debug:10,info:20,warn:30,error:40},Ho=(()=>{let t=process.env.COZE_BRIDGE_LOG_LEVEL;return t==="debug"||t==="info"||t==="warn"||t==="error"?t:"info"})(),Gh=process.stdout,jh=process.stderr,A0={}});import{execFile as Wh,spawn as $h,spawnSync as cb}from"node:child_process";import{promisify as Jh}from"node:util";function Vh(t){if(process.platform!=="win32")return!1;if(R0.test(t))return!0;let r=(t.split(/[/\\]/).pop()??t).replace(R0,"").toLowerCase();return Zh.has(r)}function D0(t,e){if(process.platform!=="win32")return e??{};let r={...e??{}};return Vh(t)&&r.shell===void 0&&(r.shell=!0),r.windowsHide===void 0&&(r.windowsHide=!0),r}function qn(t,e=[],r={}){return $h(t,e,D0(t,r))}function Gn(t,e=[],r={}){return Yh(t,e,D0(t,r))}var Zh,R0,Yh,jn=ot(()=>{"use strict";Zh=new Set(["npm","npx","yarn","pnpm","coze","tsx"]),R0=/\.(cmd|bat|ps1)$/i;Yh=Jh(Wh)});var L0={};Uo(L0,{_resetAcpInstallerForTests:()=>op,_setInFlightForTests:()=>ap,ensureAcpInstalled:()=>hn,formatExecError:()=>P0,getAcpBinaryPath:()=>pn,getAcpPackageSpec:()=>Pr,getInFlightInstall:()=>Go,probeAcpVersion:()=>ip});function Pr(t){let e=qo[t];if(e)return`${e.npmPackage}@${e.versionSpec}`}function rp(t){let e=t?.code;if(e&&ep.has(e))return!0;let r=t instanceof Error?`${t.message}
11
+ ${t.stack??""}`:String(t);return tp.test(r)||np.test(r)}function P0(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 k0(t){let e=process.platform==="win32"?"where":"which";try{let{stdout:r}=await Gn(e,[t],{timeout:O0});return r.split(`
12
+ `)[0]?.trim()||void 0}catch{return}}async function ip(t){let e=qo[t];if(e)try{let{stdout:r}=await Gn(e.binary,["--version"],{timeout:O0});return r.split(`
13
+ `)[0]?.trim()||void 0}catch{return}}async function sp(t,e,r){kr.info("npm install -g start",{npmPackage:t,versionSpec:e}),await Gn("npm",["install","-g",`${t}@${e}`],{timeout:Xh,maxBuffer:10*1024*1024,...r?{signal:r}:{}}),kr.info("npm install -g done",{npmPackage:t,versionSpec:e})}async function hn(t,e){let r=qo[t];if(!r)return;let i=Or.get(t);if(i)return i;let o=Dr.get(t);if(o&&Date.now()-o<Qh)return;let c=Kn.get(t);if(c)return c;let f=(async()=>{let u=await k0(r.binary);if(u)return Or.set(t,u),kr.info("acp wrapper found on PATH",{binary:r.binary,path:u}),u;try{await sp(r.npmPackage,r.versionSpec,e)}catch(p){let _=rp(p);kr.warn("acp wrapper install failed (will fallback to npx)",{npmPackage:r.npmPackage,transient:_,err:P0(p)}),_||Dr.set(t,Date.now());return}let x=await k0(r.binary);if(!x){kr.warn("acp wrapper installed but binary not found on PATH",{binary:r.binary}),Dr.set(t,Date.now());return}return Or.set(t,x),Dr.delete(t),x})().finally(()=>{Kn.delete(t)});return Kn.set(t,f),f}function pn(t){return Or.get(t)}function Go(t){return Kn.get(t)}function op(){Or.clear(),Dr.clear(),Kn.clear()}function ap(t,e){Kn.set(t,e)}var kr,qo,Xh,O0,Qh,ep,tp,np,Or,Dr,Kn,gn=ot(()=>{"use strict";jn();ee();kr=G("agents.acp-installer"),qo={"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"}};Xh=5e4,O0=5e3,Qh=5*6e4,ep=new Set(["ETIMEDOUT","ECONNRESET","ECONNREFUSED","ENETUNREACH","EAI_AGAIN","ERR_SOCKET_TIMEOUT","ENOTFOUND"]),tp=/\b(5\d\d|408|429)\b\s+(Bad Gateway|Service Unavailable|Gateway Timeout|Internal Server Error|Too Many Requests|Request Timeout)/i,np=/fetch failed|request timed out|socket hang up|network timeout/i;Or=new Map,Dr=new Map,Kn=new Map});import{chmod as dp,mkdir as fp,readFile as up,rename as B0,writeFile as z0}from"node:fs/promises";import{dirname as lp}from"node:path";async function Wn(t){try{let e=await up(t,"utf8");return JSON.parse(e)}catch(e){if(e.code==="ENOENT")return null;throw e}}async function Li(t,e,r){await fp(lp(t),{recursive:!0});let i=`${JSON.stringify(e,null,2)}
14
+ `,o=`${t}.tmp-${process.pid}-${Math.random().toString(36).slice(2,10)}`;try{r?.mode!==void 0?await z0(o,i,{encoding:"utf8",mode:r.mode}):await z0(o,i,"utf8"),await B0(o,t),r?.mode!==void 0&&await dp(t,r.mode)}catch(c){await B0(o,o).catch(()=>{});let{rm:f}=await import("node:fs/promises");throw await f(o,{force:!0}).catch(()=>{}),c}}var Ni=ot(()=>{"use strict"});import{promises as F0}from"node:fs";import{homedir as xp}from"node:os";import{sep as hp,join as Me,resolve as U0}from"node:path";function te(t){let e=t??xp(),r=Me(e,".coze"),i=Me(r,"bridge"),o=Me(i,"lib");return{cozeRoot:r,bridgeRoot:i,libDir:o,libEntry:Me(o,"index.js"),binDir:Me(i,"bin"),pidFile:Me(i,"bridge.pid"),portFile:Me(i,"bridge.port"),tokenFile:Me(i,"bridge.token"),patTokenFile:Me(i,"pat-token"),logFile:Me(i,"bridge.log"),installLock:Me(i,"install.lock"),configFile:Me(i,"config.json"),agentsRoot:Me(r,"agents")}}function Ct(t,e=te()){let r=Me(e.agentsRoot,t);return{root:r,config:Me(r,"config.json"),workspace:Me(r,"workspace"),logs:Me(r,"logs")}}async function Lr(t,e){let r=await F0.realpath(U0(t)).catch(()=>null);if(!r)return!1;let i=await F0.realpath(U0(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+hp)}var Be=ot(()=>{"use strict"});var zi={};Uo(zi,{AGENT_CONFIG_FILE_MODE:()=>Mi,enforceAgentConfigMode:()=>mp,loadAgentConfig:()=>Ue,persistAgentSessions:()=>jo,persistAgentSkills:()=>Bi,saveAgentConfig:()=>We});import{chmod as pp,stat as gp}from"node:fs/promises";function Ue(t,e){return Wn(Ct(t,e).config)}function We(t,e){return Li(Ct(t.agentId,e).config,t,{mode:Mi})}async function mp(t,e){if(process.platform==="win32")return;let r=Ct(t,e).config;try{let i=await gp(r);if(!i.isFile())return;let o=i.mode&511;o!==Mi&&(await pp(r,Mi),H0.warn("agent config mode auto-corrected to 0600",{path:r,from:o.toString(8)}))}catch(i){if(i.code==="ENOENT")return;H0.warn("enforceAgentConfigMode: chmod failed (ignored)",{path:r,err:String(i)})}}async function jo(t,e,r){let i=await Ue(t,r);i&&(i.sessions=Object.fromEntries(e),await We(i,r))}async function Bi(t,e,r){let i=await Ue(t,r);i&&(i.skills=e,await We(i,r))}var H0,Mi,Kt=ot(()=>{"use strict";Ni();ee();Be();H0=G("agent-config"),Mi=384});var Wo=ne((Nb,K0)=>{K0.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 Ui=ne($0=>{var W0={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 Ip(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(W0))$0[t]=Ip(W0[t])});var X0=ne((Bb,Y0)=>{var Ap=ae("fs"),ve=ae("path"),J0=Wo(),Tp=Ui(),Cp=typeof process=="object"&&process.platform==="win32",Z0=t=>typeof t=="object"&&t!==null,V0=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=ve.sep,this.fs=Ap,Z0(t)&&Z0(t.fs)&&typeof t.fs.statSync=="function"&&(this.fs=t.fs)}Y0.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(u){if(u.message&&u.message.startsWith("ENOENT"))e.fs.mkdirSync(o);else throw u}if(f&&f.isFile())throw Tp.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=ve.dirname(t);o.fs.existsSync(f)||o.makeDir(f);var u;try{u=o.fs.openSync(t,"w",438)}catch{o.fs.chmodSync(t,438),u=o.fs.openSync(t,"w",438)}if(u)try{o.fs.writeSync(u,e,0,e.length,0)}finally{o.fs.closeSync(u)}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(u,x){if(f&&x.isDirectory())return o(!1);var p=ve.dirname(t);c.fs.exists(p,function(_){_||c.makeDir(p),c.fs.open(t,"w",438,function(y,A){y?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)})})})})}):A?c.fs.write(A,e,0,e.length,0,function(){c.fs.close(A,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(u){let x=ve.join(i,u),p=e.fs.statSync(x);(!o||o.test(x))&&f.push(ve.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(u){u=ve.join(t,u),r.fs.stat(u,function(x,p){if(x)return e(x);p&&(i.push(ve.normalize(u)+(p.isDirectory()?r.sep:"")),p.isDirectory()?r.findFilesAsync(u,function(_,y){if(_)return e(_);i=i.concat(y),--f||e(null,i)}):--f||e(null,i))})})})};he.prototype.getAttributes=function(){};he.prototype.setAttributes=function(){};he.crc32update=function(t,e){return V0[(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 J0.STORED:return"STORED ("+t+")";case J0.DEFLATED:return"DEFLATED ("+t+")";default:return"UNSUPPORTED ("+t+")"}};he.canonical=function(t){if(!t)return"";let e=ve.posix.normalize("/"+t.split("\\").join("/"));return ve.join(".",e)};he.zipnamefix=function(t){if(!t)return"";let e=ve.posix.normalize("/"+t.split("\\").join("/"));return ve.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=ve.resolve(ve.normalize(t));for(var r=e.split("/"),i=0,o=r.length;i<o;i++){var c=ve.normalize(ve.join(t,r.slice(i,o).join(ve.sep)));if(c.indexOf(t)===0)return c}return ve.normalize(ve.join(t,ve.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=Cp;he.crcTable=V0});var ed=ne((zb,Q0)=>{var Rp=ae("path");Q0.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=Rp.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 nd=ne((Fb,td)=>{td.exports={efs:!0,encode:t=>Buffer.from(t,"utf8"),decode:t=>t.toString("utf8")}});var Zn=ne((Ub,Jn)=>{Jn.exports=X0();Jn.exports.Constants=Wo();Jn.exports.Errors=Ui();Jn.exports.FileAttr=ed();Jn.exports.decoder=nd()});var id=ne((Hb,rd)=>{var Wt=Zn(),U=Wt.Constants;rd.exports=function(){var t=20,e=10,r=0,i=0,o=0,c=0,f=0,u=0,x=0,p=0,_=0,y=0,A=0,E=0,v=0;t|=Wt.isWin?2560:768,r|=U.FLG_EFS;let S={extraLen:0},I=w=>Math.max(0,w)>>>0,D=w=>Math.max(0,w)&65535,P=w=>Math.max(0,w)&255;return o=Wt.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&U.FLG_EFS)>0},set flags_efs(w){w?r|=U.FLG_EFS:r&=~U.FLG_EFS},get flags_desc(){return(r&U.FLG_DESC)>0},set flags_desc(w){w?r|=U.FLG_DESC:r&=~U.FLG_DESC},get method(){return i},set method(w){switch(w){case U.STORED:this.version=10;case U.DEFLATED:default:this.version=20}i=w},get time(){return Wt.fromDOS2Date(this.timeval)},set time(w){w=new Date(w),this.timeval=Wt.fromDate2DOS(w)},get timeval(){return o},set timeval(w){o=I(w)},get timeHighByte(){return P(o>>>8)},get crc(){return c},set crc(w){c=I(w)},get compressedSize(){return f},set compressedSize(w){f=I(w)},get size(){return u},set size(w){u=I(w)},get fileNameLength(){return x},set fileNameLength(w){x=w},get extraLength(){return p},set extraLength(w){p=w},get extraLocalLength(){return S.extraLen},set extraLocalLength(w){S.extraLen=w},get commentLength(){return _},set commentLength(w){_=w},get diskNumStart(){return y},set diskNumStart(w){y=I(w)},get inAttr(){return A},set inAttr(w){A=I(w)},get attr(){return E},set attr(w){E=I(w)},get fileAttr(){return(E||0)>>16&4095},get offset(){return v},set offset(w){v=I(w)},get encrypted(){return(r&U.FLG_ENC)===U.FLG_ENC},get centralHeaderSize(){return U.CENHDR+x+p+_},get realDataOffset(){return v+U.LOCHDR+S.fnameLen+S.extraLen},get localHeader(){return S},loadLocalHeaderFromBinary:function(w){var C=w.slice(v,v+U.LOCHDR);if(C.readUInt32LE(0)!==U.LOCSIG)throw Wt.Errors.INVALID_LOC();S.version=C.readUInt16LE(U.LOCVER),S.flags=C.readUInt16LE(U.LOCFLG),S.flags_desc=(S.flags&U.FLG_DESC)>0,S.method=C.readUInt16LE(U.LOCHOW),S.time=C.readUInt32LE(U.LOCTIM),S.crc=C.readUInt32LE(U.LOCCRC),S.compressedSize=C.readUInt32LE(U.LOCSIZ),S.size=C.readUInt32LE(U.LOCLEN),S.fnameLen=C.readUInt16LE(U.LOCNAM),S.extraLen=C.readUInt16LE(U.LOCEXT);let O=v+U.LOCHDR+S.fnameLen,z=O+S.extraLen;return w.slice(O,z)},loadFromBinary:function(w){if(w.length!==U.CENHDR||w.readUInt32LE(0)!==U.CENSIG)throw Wt.Errors.INVALID_CEN();t=w.readUInt16LE(U.CENVEM),e=w.readUInt16LE(U.CENVER),r=w.readUInt16LE(U.CENFLG),i=w.readUInt16LE(U.CENHOW),o=w.readUInt32LE(U.CENTIM),c=w.readUInt32LE(U.CENCRC),f=w.readUInt32LE(U.CENSIZ),u=w.readUInt32LE(U.CENLEN),x=w.readUInt16LE(U.CENNAM),p=w.readUInt16LE(U.CENEXT),_=w.readUInt16LE(U.CENCOM),y=w.readUInt16LE(U.CENDSK),A=w.readUInt16LE(U.CENATT),E=w.readUInt32LE(U.CENATX),v=w.readUInt32LE(U.CENOFF)},localHeaderToBinary:function(){var w=Buffer.alloc(U.LOCHDR);return w.writeUInt32LE(U.LOCSIG,0),w.writeUInt16LE(e,U.LOCVER),w.writeUInt16LE(r,U.LOCFLG),w.writeUInt16LE(i,U.LOCHOW),w.writeUInt32LE(o,U.LOCTIM),w.writeUInt32LE(c,U.LOCCRC),w.writeUInt32LE(f,U.LOCSIZ),w.writeUInt32LE(u,U.LOCLEN),w.writeUInt16LE(x,U.LOCNAM),w.writeUInt16LE(S.extraLen,U.LOCEXT),w},centralHeaderToBinary:function(){var w=Buffer.alloc(U.CENHDR+x+p+_);return w.writeUInt32LE(U.CENSIG,0),w.writeUInt16LE(t,U.CENVEM),w.writeUInt16LE(e,U.CENVER),w.writeUInt16LE(r,U.CENFLG),w.writeUInt16LE(i,U.CENHOW),w.writeUInt32LE(o,U.CENTIM),w.writeUInt32LE(c,U.CENCRC),w.writeUInt32LE(f,U.CENSIZ),w.writeUInt32LE(u,U.CENLEN),w.writeUInt16LE(x,U.CENNAM),w.writeUInt16LE(p,U.CENEXT),w.writeUInt16LE(_,U.CENCOM),w.writeUInt16LE(y,U.CENDSK),w.writeUInt16LE(A,U.CENATT),w.writeUInt32LE(E,U.CENATX),w.writeUInt32LE(v,U.CENOFF),w},toJSON:function(){let w=function(C){return C+" bytes"};return{made:t,version:e,flags:r,method:Wt.methodToString(i),time:this.time,crc:"0x"+c.toString(16).toUpperCase(),compressedSize:w(f),size:w(u),fileNameLength:w(x),extraLength:w(p),commentLength:w(_),diskNumStart:y,inAttr:A,attr:E,offset:v,centralHeaderSize:w(U.CENHDR+x+p+_)}},toString:function(){return JSON.stringify(this.toJSON(),null," ")}}}});var od=ne((qb,sd)=>{var Vn=Zn(),ue=Vn.Constants;sd.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 Vn.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=Vn.readBigUInt64LE(c,ue.ZIP64SUB),e=Vn.readBigUInt64LE(c,ue.ZIP64TOT),r=Vn.readBigUInt64LE(c,ue.ZIP64SIZE),i=Vn.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,u){let x=f.toString(16).toUpperCase();for(;x.length<u;)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 Jo=ne($o=>{$o.EntryHeader=id();$o.MainHeader=od()});var cd=ne((jb,ad)=>{ad.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(u){c.push(u),f+=u.length}),o.on("end",function(){var u=Buffer.alloc(f),x=0;u.fill(0);for(var p=0;p<c.length;p++){var _=c[p];_.copy(u,x),x+=_.length}i&&i(u)}),o.end(t)}}}});var fd=ne((Kb,dd)=>{var Dp=+(process.versions?process.versions.node:"").split(".")[0]||0;dd.exports=function(t,e){var r=ae("zlib");let i=Dp>=15&&e>0?{maxOutputLength:e}:{};return{inflate:function(){return r.inflateRawSync(t,i)},inflateAsync:function(o){var c=r.createInflateRaw(i),f=[],u=0;c.on("data",function(x){f.push(x),u+=x.length}),c.on("end",function(){var x=Buffer.alloc(u),p=0;x.fill(0);for(var _=0;_<f.length;_++){var y=f[_];y.copy(x,p),p+=y.length}o&&o(x)}),c.end(t)}}}});var pd=ne((Wb,hd)=>{"use strict";var{randomFillSync:ud}=ae("crypto"),kp=Ui(),Op=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}),xd=(t,e)=>Math.imul(t,e)>>>0,ld=(t,e)=>Op[(t^e)&255]^t>>>8,Nr=()=>typeof ud=="function"?ud(Buffer.alloc(12)):Nr.node();Nr.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 Hi={genSalt:Nr};function qi(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])}qi.prototype.updateKeys=function(t){let e=this.keys;return e[0]=ld(e[0],t),e[1]+=e[0]&255,e[1]=xd(e[1],134775813)+1,e[2]=ld(e[2],e[1]>>>24),t};qi.prototype.next=function(){let t=(this.keys[2]|2)>>>0;return xd(t,t^1)>>8&255};function Pp(t){let e=new qi(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 Lp(t){let e=new qi(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 Np(t,e,r){if(!t||!Buffer.isBuffer(t)||t.length<12)return Buffer.alloc(0);let i=Pp(r),o=i(t.slice(0,12)),c=(e.flags&8)===8?e.timeHighByte:e.crc>>>24;if(o[11]!==c)throw kp.WRONG_PASSWORD();return i(t.slice(12))}function Mp(t){Buffer.isBuffer(t)&&t.length>=12?Hi.genSalt=function(){return t.slice(0,12)}:t==="node"?Hi.genSalt=Nr.node:Hi.genSalt=Nr}function Bp(t,e,r,i=!1){t==null&&(t=Buffer.alloc(0)),Buffer.isBuffer(t)||(t=Buffer.from(t.toString()));let o=Lp(r),c=Hi.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)}hd.exports={decrypt:Np,encrypt:Bp,_salter:Mp}});var gd=ne(Gi=>{Gi.Deflater=cd();Gi.Inflater=fd();Gi.ZipCrypto=pd()});var Vo=ne((Jb,md)=>{var re=Zn(),zp=Jo(),pe=re.Constants,Zo=gd();md.exports=function(t,e){var r=new zp.EntryHeader,i=Buffer.alloc(0),o=Buffer.alloc(0),c=!1,f=null,u=Buffer.alloc(0),x=Buffer.alloc(0),p=!0;let _=t,y=typeof _.decoder=="object"?_.decoder:re.decoder;p=y.hasOwnProperty("efs")?y.efs:!1;function A(){return!e||!(e instanceof Uint8Array)?Buffer.alloc(0):(x=r.loadLocalHeaderFromBinary(e),e.slice(r.realDataOffset,r.realDataOffset+r.compressedSize))}function E(w){if(!r.flags_desc&&!r.localHeader.flags_desc){if(re.crc32(w)!==r.localHeader.crc)return!1}else{let C={},O=r.realDataOffset+r.compressedSize;if(e.readUInt32LE(O)==pe.LOCSIG||e.readUInt32LE(O)==pe.CENSIG)throw re.Errors.DESCRIPTOR_NOT_EXIST();if(e.readUInt32LE(O)==pe.EXTSIG)C.crc=e.readUInt32LE(O+pe.EXTCRC),C.compressedSize=e.readUInt32LE(O+pe.EXTSIZ),C.size=e.readUInt32LE(O+pe.EXTLEN);else if(e.readUInt16LE(O+12)===19280)C.crc=e.readUInt32LE(O+pe.EXTCRC-4),C.compressedSize=e.readUInt32LE(O+pe.EXTSIZ-4),C.size=e.readUInt32LE(O+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(w)!==C.crc)return!1}return!0}function v(w,C,O){if(typeof C>"u"&&typeof w=="string"&&(O=w,w=void 0),c)return w&&C&&C(Buffer.alloc(0),re.Errors.DIRECTORY_CONTENT_ERROR()),Buffer.alloc(0);var z=A();if(z.length===0)return w&&C&&C(z),z;if(r.encrypted){if(typeof O!="string"&&!Buffer.isBuffer(O))throw re.Errors.INVALID_PASS_PARAM();z=Zo.ZipCrypto.decrypt(z,r,O)}var B=Buffer.alloc(r.size);switch(r.method){case re.Constants.STORED:if(z.copy(B),E(B))return w&&C&&C(B),B;throw w&&C&&C(B,re.Errors.BAD_CRC()),re.Errors.BAD_CRC();case re.Constants.DEFLATED:var k=new Zo.Inflater(z,r.size);if(w)k.inflateAsync(function(N){N.copy(N,0),C&&(E(N)?C(N):C(N,re.Errors.BAD_CRC()))});else{if(k.inflate(B).copy(B,0),!E(B))throw re.Errors.BAD_CRC(`"${y.decode(i)}"`);return B}break;default:throw w&&C&&C(Buffer.alloc(0),re.Errors.UNKNOWN_METHOD()),re.Errors.UNKNOWN_METHOD()}}function S(w,C){if((!f||!f.length)&&Buffer.isBuffer(e))return w&&C&&C(A()),A();if(f.length&&!c){var O;switch(r.method){case re.Constants.STORED:return r.compressedSize=r.size,O=Buffer.alloc(f.length),f.copy(O),w&&C&&C(O),O;default:case re.Constants.DEFLATED:var z=new Zo.Deflater(f);if(w)z.deflateAsync(function(k){O=Buffer.alloc(k.length),r.compressedSize=k.length,k.copy(O),C&&C(O)});else{var B=z.deflate();return r.compressedSize=B.length,B}z=null;break}}else if(w&&C)C(Buffer.alloc(0));else return Buffer.alloc(0)}function I(w,C){return re.readBigUInt64LE(w,C)}function D(w){try{for(var C=0,O,z,B;C+4<w.length;)O=w.readUInt16LE(C),C+=2,z=w.readUInt16LE(C),C+=2,B=w.slice(C,C+z),C+=z,pe.ID_ZIP64===O&&P(B)}catch{throw re.Errors.EXTRA_FIELD_PARSE_ERROR()}}function P(w){var C,O,z,B;w.length>=pe.EF_ZIP64_SCOMP&&(C=I(w,pe.EF_ZIP64_SUNCOMP),r.size===pe.EF_ZIP64_OR_32&&(r.size=C)),w.length>=pe.EF_ZIP64_RHO&&(O=I(w,pe.EF_ZIP64_SCOMP),r.compressedSize===pe.EF_ZIP64_OR_32&&(r.compressedSize=O)),w.length>=pe.EF_ZIP64_DSN&&(z=I(w,pe.EF_ZIP64_RHO),r.offset===pe.EF_ZIP64_OR_32&&(r.offset=z)),w.length>=pe.EF_ZIP64_DSN+4&&(B=w.readUInt32LE(pe.EF_ZIP64_DSN),r.diskNumStart===pe.EF_ZIP64_OR_16&&(r.diskNumStart=B))}return{get entryName(){return y.decode(i)},get rawEntryName(){return i},set entryName(w){i=re.toBuffer(w,y.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 u},set extra(w){u=w,r.extraLength=w.length,D(w)},get comment(){return y.decode(o)},set comment(w){if(o=re.toBuffer(w,y.encode),r.commentLength=o.length,o.length>65535)throw re.Errors.COMMENT_TOO_LONG()},get name(){var w=y.decode(i);return c?w.substr(w.length-1).split("/").pop():w.split("/").pop()},get isDirectory(){return c},getCompressedData:function(){return S(!1,null)},getCompressedDataAsync:function(w){S(!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:v(!1,null,w)},getDataAsync:function(w,C){r.changed?w(f):v(!0,w,C)},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=u.length;var w=r.centralHeaderToBinary(),C=re.Constants.CENHDR;return i.copy(w,C),C+=i.length,u.copy(w,C),C+=r.extraLength,o.copy(w,C),w},packLocalHeader:function(){let w=0;r.flags_efs=this.efs,r.extraLocalLength=x.length;let C=r.localHeaderToBinary(),O=Buffer.alloc(C.length+i.length+r.extraLocalLength);return C.copy(O,w),w+=C.length,i.copy(O,w),w+=i.length,x.copy(O,w),w+=x.length,O},toJSON:function(){let w=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:w(e),data:w(f)}},toString:function(){return JSON.stringify(this.toJSON(),null," ")}}}});var yd=ne((Zb,_d)=>{var wd=Vo(),Fp=Jo(),ze=Zn();_d.exports=function(t,e){var r=[],i={},o=Buffer.alloc(0),c=new Fp.MainHeader,f=!1,u=null;let x=new Set,p=e,{noSort:_,decoder:y}=p;t?v(p.readEntries):f=!0;function A(){let I=new Set;for(let D of Object.keys(i)){let P=D.split("/");if(P.pop(),!!P.length)for(let w=0;w<P.length;w++){let C=P.slice(0,w+1).join("/")+"/";I.add(C)}}for(let D of I)if(!(D in i)){let P=new wd(p);P.entryName=D,P.attr=16,P.temporary=!0,r.push(P),i[P.entryName]=P,x.add(P)}}function E(){if(f=!0,i={},c.diskEntries>(t.length-c.offset)/ze.Constants.CENHDR)throw ze.Errors.DISK_ENTRY_TOO_LARGE();r=new Array(c.diskEntries);for(var I=c.offset,D=0;D<r.length;D++){var P=I,w=new wd(p,t);w.header=t.slice(P,P+=ze.Constants.CENHDR),w.entryName=t.slice(P,P+=w.header.fileNameLength),w.header.extraLength&&(w.extra=t.slice(P,P+=w.header.extraLength)),w.header.commentLength&&(w.comment=t.slice(P,P+w.header.commentLength)),I+=w.header.centralHeaderSize,r[D]=w,i[w.entryName]=w}x.clear(),A()}function v(I){var D=t.length-ze.Constants.ENDHDR,P=Math.max(0,D-65535),w=P,C=t.length,O=-1,z=0;for(typeof p.trailingSpace=="boolean"&&p.trailingSpace&&(P=0),D;D>=w;D--)if(t[D]===80){if(t.readUInt32LE(D)===ze.Constants.ENDSIG){O=D,z=D,C=D+ze.Constants.ENDHDR,w=D-ze.Constants.END64HDR;continue}if(t.readUInt32LE(D)===ze.Constants.END64SIG){w=P;continue}if(t.readUInt32LE(D)===ze.Constants.ZIP64SIG){O=D,C=D+ze.readBigUInt64LE(t,D+ze.Constants.ZIP64SIZE)+ze.Constants.ZIP64LEAD;break}}if(O==-1)throw ze.Errors.INVALID_FORMAT();c.loadFromBinary(t.slice(O,C)),c.commentLength&&(o=t.slice(z+ze.Constants.ENDHDR)),I&&E()}function S(){r.length>1&&!_&&r.sort((I,D)=>I.entryName.toLowerCase().localeCompare(D.entryName.toLowerCase()))}return{get entries(){return f||E(),r.filter(I=>!x.has(I))},get comment(){return y.decode(o)},set comment(I){o=ze.toBuffer(I,y.encode),c.commentLength=o.length},getEntryCount:function(){return f?r.length:c.diskEntries},forEach:function(I){this.entries.forEach(I)},getEntry:function(I){return f||E(),i[I]||null},setEntry:function(I){f||E(),r.push(I),i[I.entryName]=I,c.totalEntries=r.length},deleteFile:function(I,D=!0){f||E();let P=i[I];this.getEntryChildren(P,D).map(C=>C.entryName).forEach(this.deleteEntry)},deleteEntry:function(I){f||E();let D=i[I],P=r.indexOf(D);P>=0&&(r.splice(P,1),delete i[I],c.totalEntries=r.length)},getEntryChildren:function(I,D=!0){if(f||E(),typeof I=="object")if(I.isDirectory&&D){let P=[],w=I.entryName;for(let C of r)C.entryName.startsWith(w)&&P.push(C);return P}else return[I];return[]},getChildCount:function(I){if(I&&I.isDirectory){let D=this.getEntryChildren(I);return D.includes(I)?D.length-1:D.length}return 0},compressToBuffer:function(){f||E(),S();let I=[],D=[],P=0,w=0;c.size=0,c.offset=0;let C=0;for(let B of this.entries){let k=B.getCompressedData();B.header.offset=w;let N=B.packLocalHeader(),F=N.length+k.length;w+=F,I.push(N),I.push(k);let K=B.packCentralHeader();D.push(K),c.size+=K.length,P+=F+K.length,C++}P+=c.mainHeaderSize,c.offset=w,c.totalEntries=C,w=0;let O=Buffer.alloc(P);for(let B of I)B.copy(O,w),w+=B.length;for(let B of D)B.copy(O,w),w+=B.length;let z=c.toBinary();return o&&o.copy(z,ze.Constants.ENDHDR),z.copy(O,w),t=O,f=!1,O},toAsyncBuffer:function(I,D,P,w){try{f||E(),S();let C=[],O=[],z=0,B=0,k=0;c.size=0,c.offset=0;let N=function(F){if(F.length>0){let K=F.shift(),se=K.entryName+K.extra.toString();P&&P(se),K.getCompressedDataAsync(function(fe){w&&w(se),K.header.offset=B;let we=K.packLocalHeader(),Ne=we.length+fe.length;B+=Ne,C.push(we),C.push(fe);let it=K.packCentralHeader();O.push(it),c.size+=it.length,z+=Ne+it.length,k++,N(F)})}else{z+=c.mainHeaderSize,c.offset=B,c.totalEntries=k,B=0;let K=Buffer.alloc(z);C.forEach(function(fe){fe.copy(K,B),B+=fe.length}),O.forEach(function(fe){fe.copy(K,B),B+=fe.length});let se=c.toBinary();o&&o.copy(se,ze.Constants.ENDHDR),se.copy(K,B),t=K,f=!1,I(K)}};N(Array.from(this.entries))}catch(C){D(C)}}}}});var vd=ne((Vb,bd)=>{var xe=Zn(),le=ae("path"),Up=Vo(),Hp=yd(),mn=(...t)=>xe.findLast(t,e=>typeof e=="boolean"),Ed=(...t)=>xe.findLast(t,e=>typeof e=="string"),qp=(...t)=>xe.findLast(t,e=>typeof e=="function"),Gp={noSort:!1,readEntries:!1,method:xe.Constants.NONE,fs:null};bd.exports=function(t,e){let r=null,i=Object.assign(Object.create(null),Gp);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 Hp(r,i),{canonical:f,sanitize:u,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 _(E){let{join:v,normalize:S,sep:I}=le.posix;return v(le.isAbsolute(E)?"/":".",S(I+E.split("\\").join(I)+I))}function y(E){return E instanceof RegExp?(function(v){return function(S){return v.test(S)}})(E):typeof E!="function"?()=>!0:E}let A=(E,v)=>{let S=v.slice(-1);return S=S===o.sep?o.sep:"",le.relative(E,v)+S};return{readFile:function(E,v){var S=p(E);return S&&S.getData(v)||null},childCount:function(E){let v=p(E);if(v)return c.getChildCount(v)},readFileAsync:function(E,v){var S=p(E);S?S.getDataAsync(v):v(null,"getEntry failed for:"+E)},readAsText:function(E,v){var S=p(E);if(S){var I=S.getData();if(I&&I.length)return I.toString(v||"utf8")}return""},readAsTextAsync:function(E,v,S){var I=p(E);I?I.getDataAsync(function(D,P){if(P){v(D,P);return}D&&D.length?v(D.toString(S||"utf8")):v("")}):v("")},deleteFile:function(E,v=!0){var S=p(E);S&&c.deleteFile(S.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 S=p(E);S&&(S.comment=v)},getZipEntryComment:function(E){var v=p(E);return v&&v.comment||""},updateFile:function(E,v){var S=p(E);S&&S.setData(v)},addLocalFile:function(E,v,S,I){if(o.fs.existsSync(E)){v=v?_(v):"";let D=le.win32.basename(le.win32.normalize(E));v+=S||D;let P=o.fs.statSync(E),w=P.isFile()?o.fs.readFileSync(E):Buffer.alloc(0);P.isDirectory()&&(v+=o.sep),this.addFile(v,w,I,P)}else throw xe.Errors.FILE_NOT_FOUND(E)},addLocalFileAsync:function(E,v){E=typeof E=="object"?E:{localPath:E};let S=le.resolve(E.localPath),{comment:I}=E,{zipPath:D,zipName:P}=E,w=this;o.fs.stat(S,function(C,O){if(C)return v(C,!1);D=D?_(D):"";let z=le.win32.basename(le.win32.normalize(S));if(D+=P||z,O.isFile())o.fs.readFile(S,function(B,k){return B?v(B,!1):(w.addFile(D,k,I,O),setImmediate(v,void 0,!0))});else if(O.isDirectory())return D+=o.sep,w.addFile(D,Buffer.alloc(0),I,O),setImmediate(v,void 0,!0)})},addLocalFolder:function(E,v,S){if(S=y(S),v=v?_(v):"",E=le.normalize(E),o.fs.existsSync(E)){let I=o.findFiles(E),D=this;if(I.length)for(let P of I){let w=le.join(v,A(E,P));S(w)&&D.addLocalFile(P,le.dirname(w))}}else throw xe.Errors.FILE_NOT_FOUND(E)},addLocalFolderAsync:function(E,v,S,I){I=y(I),S=S?_(S):"",E=le.normalize(E);var D=this;o.fs.open(E,"r",function(P){if(P&&P.code==="ENOENT")v(void 0,xe.Errors.FILE_NOT_FOUND(E));else if(P)v(void 0,P);else{var w=o.findFiles(E),C=-1,O=function(){if(C+=1,C<w.length){var z=w[C],B=A(E,z).split("\\").join("/");B=B.normalize("NFD").replace(/[\u0300-\u036f]/g,"").replace(/[^\x20-\x7E]/g,""),I(B)?o.fs.stat(z,function(k,N){k&&v(void 0,k),N.isFile()?o.fs.readFile(z,function(F,K){F?v(void 0,F):(D.addFile(S+B,K,"",N),O())}):(D.addFile(S+B+"/",Buffer.alloc(0),"",N),O())}):process.nextTick(()=>{O()})}else v(!0,void 0)};O()}})},addLocalFolderAsync2:function(E,v){let S=this;E=typeof E=="object"?E:{localPath:E},localPath=le.resolve(_(E.localPath));let{zipPath:I,filter:D,namefix:P}=E;D instanceof RegExp?D=(function(O){return function(z){return O.test(z)}})(D):typeof D!="function"&&(D=function(){return!0}),I=I?_(I):"",P=="latin1"&&(P=O=>O.normalize("NFD").replace(/[\u0300-\u036f]/g,"").replace(/[^\x20-\x7E]/g,"")),typeof P!="function"&&(P=O=>O);let w=O=>le.join(I,P(A(localPath,O))),C=O=>le.win32.basename(le.win32.normalize(P(O)));o.fs.open(localPath,"r",function(O){O&&O.code==="ENOENT"?v(void 0,xe.Errors.FILE_NOT_FOUND(localPath)):O?v(void 0,O):o.findFilesAsync(localPath,function(z,B){if(z)return v(z);B=B.filter(k=>D(w(k))),B.length||v(void 0,!1),setImmediate(B.reverse().reduce(function(k,N){return function(F,K){if(F||K===!1)return setImmediate(k,F,!1);S.addLocalFileAsync({localPath:N,zipPath:le.dirname(w(N)),zipName:C(N)},k)}},v))})})},addLocalFolderPromise:function(E,v){return new Promise((S,I)=>{this.addLocalFolderAsync2(Object.assign({localPath:E},v),(D,P)=>{D&&I(D),P&&S(this)})})},addFile:function(E,v,S,I){E=x(E);let D=p(E),P=D!=null;P||(D=new Up(i),D.entryName=E),D.comment=S||"";let w=typeof I=="object"&&I instanceof o.fs.Stats;w&&(D.header.time=I.mtime);var C=D.isDirectory?16:0;let O=D.isDirectory?16384:32768;return w?O|=4095&I.mode:typeof I=="number"?O|=4095&I:O|=D.isDirectory?493:420,C=(C|O<<16)>>>0,D.attr=C,D.setData(v),P||c.setEntry(D),D},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,S,I,D,P){I=mn(!1,I),D=mn(!1,D),S=mn(!0,S),P=Ed(D,P);var w=p(E);if(!w)throw xe.Errors.NO_ENTRY();var C=f(w.entryName),O=u(v,P&&!w.isDirectory?P:S?C:le.basename(C));if(w.isDirectory){var z=c.getEntryChildren(w);return z.forEach(function(N){if(N.isDirectory)return;var F=N.getData();if(!F)throw xe.Errors.CANT_EXTRACT_FILE();var K=f(N.entryName),se=u(v,S?K:le.basename(K));let fe=D?N.header.fileAttr:void 0;o.writeFileTo(se,F,I,fe)}),!0}var B=w.getData(c.password);if(!B)throw xe.Errors.CANT_EXTRACT_FILE();if(o.fs.existsSync(O)&&!I)throw xe.Errors.CANT_OVERRIDE();let k=D?E.header.fileAttr:void 0;return o.writeFileTo(O,B,I,k),!0},test:function(E){if(!c)return!1;for(var v in c.entries)try{if(v.isDirectory)continue;var S=c.entries[v].getData(E);if(!S)return!1}catch{return!1}return!0},extractAllTo:function(E,v,S,I){if(S=mn(!1,S),I=Ed(S,I),v=mn(!1,v),!c)throw xe.Errors.NO_ZIP();c.entries.forEach(function(D){var P=u(E,f(D.entryName));if(D.isDirectory){o.makeDir(P);return}var w=D.getData(I);if(!w)throw xe.Errors.CANT_EXTRACT_FILE();let C=S?D.header.fileAttr:void 0;o.writeFileTo(P,w,v,C);try{o.fs.utimesSync(P,D.header.time,D.header.time)}catch{throw xe.Errors.CANT_EXTRACT_FILE()}})},extractAllToAsync:function(E,v,S,I){if(I=qp(v,S,I),S=mn(!1,S),v=mn(!1,v),!I)return new Promise((O,z)=>{this.extractAllToAsync(E,v,S,function(B){B?z(B):O(this)})});if(!c){I(xe.Errors.NO_ZIP());return}E=le.resolve(E);let D=O=>u(E,le.normalize(f(O.entryName))),P=(O,z)=>new Error(O+': "'+z+'"'),w=[],C=[];c.entries.forEach(O=>{O.isDirectory?w.push(O):C.push(O)});for(let O of w){let z=D(O),B=S?O.header.fileAttr:void 0;try{o.makeDir(z),B&&o.fs.chmodSync(z,B),o.fs.utimesSync(z,O.header.time,O.header.time)}catch{I(P("Unable to create folder",z))}}C.reverse().reduce(function(O,z){return function(B){if(B)O(B);else{let k=le.normalize(f(z.entryName)),N=u(E,k);z.getDataAsync(function(F,K){if(K)O(K);else if(!F)O(xe.Errors.CANT_EXTRACT_FILE());else{let se=S?z.header.fileAttr:void 0;o.writeFileToAsync(N,F,v,se,function(fe){fe||O(P("Unable to write file",N)),o.fs.utimes(N,z.header.time,z.header.time,function(we){we?O(P("Unable to set times",N)):O()})})}})}}},I)()},writeZip:function(E,v){if(arguments.length===1&&typeof E=="function"&&(v=E,E=""),!E&&i.filename&&(E=i.filename),!!E){var S=c.compressToBuffer();if(S){var I=o.writeFileTo(E,S,!0);typeof v=="function"&&v(I?null:new Error("failed"),"")}}},writeZipPromise:function(E,v){let{overwrite:S,perm:I}=Object.assign({overwrite:!0},v);return new Promise((D,P)=>{!E&&i.filename&&(E=i.filename),E||P("ADM-ZIP: ZIP File Name Missing"),this.toBufferPromise().then(w=>{let C=O=>O?D(O):P("ADM-ZIP: Wasn't able to write zip file");o.writeFileToAsync(E,w,S,I,C)},P)})},toBufferPromise:function(){return new Promise((E,v)=>{c.toAsyncBuffer(E,v)})},toBuffer:function(E,v,S,I){return typeof E=="function"?(c.toAsyncBuffer(E,v,S,I),null):c.compressToBuffer()}}}});var ol=ne(Ie=>{"use strict";function H(t,e){t=t-166;let r=Qs(),i=r[t];if(H.hZRblG===void 0){var o=function(x){let p="abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789+/=",_="",y="";for(let A=0,E,v,S=0;v=x.charAt(S++);~v&&(E=A%4?E*64+v:v,A++%4)?_+=String.fromCharCode(255&E>>(-2*A&6)):0)v=p.indexOf(v);for(let A=0,E=_.length;A<E;A++)y+="%"+("00"+_.charCodeAt(A).toString(16)).slice(-2);return decodeURIComponent(y)};H.vkizxn=o,H.TJyeud={},H.hZRblG=!0}let c=r[0],f=t+c,u=H.TJyeud[f];return u?i=u:(i=H.vkizxn(i),H.TJyeud[f]=i),i}var M=H;(function(t,e){let r=H,i=t();for(;;)try{if(parseInt(r(1292))/1+parseInt(r(1005))/2+parseInt(r(648))/3*(parseInt(r(173))/4)+parseInt(r(275))/5+-parseInt(r(1235))/6*(parseInt(r(461))/7)+parseInt(r(886))/8+-parseInt(r(236))/9===e)break;i.push(i.shift())}catch{i.push(i.shift())}})(Qs,177126);var ry=Object[M(1316)+M(1516)],iy=Object[M(1150)+M(871)+M(1612)],tl=(t,e)=>function(){return t&&(e=(0,t[{LsDZl:function(c,f){return c(f)}}[M(975)](iy,t)[0]])(t=0)),e},sy=(t,e)=>{let r=M,i={marfJ:function(c,f,u,x){return c(f,u,x)}};for(var o in e)i[r(1588)](ry,t,o,{get:e[o],enumerable:!0})};function oy(){return Vu||(Vu=[IDBDatabase,IDBObjectStore,IDBIndex,IDBCursor,IDBTransaction])}function ay(){let t=M;return Yu||(Yu=[IDBCursor[t(1476)+"e"][t(1543)],IDBCursor[t(1476)+"e"][t(386)],IDBCursor[t(1476)+"e"][t(386)+t(761)+"ey"]])}function cy(t){let e=M,r={MuzEN:function(o,c){return o!==c},ClWYs:e(661),LPDgB:e(1182),tboFp:function(o,c){return o(c)},gvpkv:e(575),xUgIC:e(295),xQxgN:function(o){return o()},rpbrN:"success",FaDMC:e(789),BKHkj:function(o,c){return o instanceof c}},i=new Promise((o,c)=>{let f=e,u={eSHoh:r[f(1190)]},x=()=>{let y=f;t["removeEv"+y(250)+y(773)](u.eSHoh,p),t["removeEv"+y(250)+y(773)](y(789),_)},p=()=>{let y=f;r[y(795)](r[y(983)],r[y(1635)])?(o(r.tboFp(At,t.result)),x()):_0x435a57[y(683)]()[y(785)](()=>{let A=y;this[A(1658)+A(406)]()})},_=()=>{let y=f;if(r.MuzEN(r[y(213)],r[y(1144)]))c(t[y(789)]),r.xQxgN(x);else return _0x4402cc["objectSt"+y(514)]||_0x5c9d51[y(656)](_0x2d0081)};t[f(668)+f(662)](r[f(1190)],p),t[f(668)+f(662)](r.FaDMC,_)});return i[e(785)](o=>{let c=e;r[c(581)](o,IDBCursor)&&yc[c(554)](o,t)})[e(1450)](()=>{}),Ys[e(554)](i,t),i}function dy(t){let e=M,r={XYpZl:function(o,c){return o<c},mEEYU:function(o,c){return o-c},JAuXN:function(o,c){return o!==c},RiIHD:e(260),WCrIT:e(1673),EtxKc:e(789),MPiIA:"abort",keZgy:function(o){return o()},hRqCx:"AbortError"};if(Vs.has(t))return;let i=new Promise((o,c)=>{let f=e,u={CawSO:function(y,A){return r[H(176)](y,A)},cETdY:function(y,A){return y!==A},DXnyL:function(y,A){return r.mEEYU(y,A)},MYvjV:function(y,A){return r.JAuXN(y,A)},mReNe:r[f(1145)],BVDfM:r[f(714)],lIjht:r[f(1015)],RuHrF:r[f(533)],uJwlu:function(y){return r[f(1666)](y)},rwjtg:function(y,A){return y(A)},kQJeA:r[f(843)]},x=()=>{let y=f;if(u[y(694)](u[y(1212)],"ukXws"))t["removeEv"+y(250)+y(773)](u[y(682)],p),t["removeEv"+y(250)+"ner"](u[y(1605)],_),t["removeEv"+y(250)+y(773)](u[y(1712)],_);else{let A=_0x1b9130[y(513)](":");for(let E=0;u[y(1323)](E,A[y(784)]);E++){let v=A[E];if(u[y(1684)](4,A[E].length)){let S=_0x323dd2[y(1531)+"g"](0,u[y(587)](4,A[E][y(784)])),I=S[y(311)](v);_0x66210=_0x2487d9[y(311)](I)}else _0x4c2b76=_0x1c9894[y(311)](v)}return _0x22e406}},p=()=>{u[f(1071)](o),x()},_=()=>{let y=f;u[y(1026)](c,t[y(789)]||new DOMException(u[y(537)],u.kQJeA)),x()};t[f(668)+f(662)](r[f(714)],p),t["addEvent"+f(662)](r.EtxKc,_),t[f(668)+f(662)](f(488),_)});Vs[e(554)](t,i)}function fy(t){Xs={jBhnF:function(r,i){return r(i)}}.jBhnF(t,Xs)}function uy(t){let e=M,r={KCsuv:e(1249),afNUj:e(865),tmhuB:function(i,o){return i(o)},RQjGE:function(i,o){return i(o)},bPZWh:function(i,o){return i in o},yMJWd:"objectSt"+e(514),XPCUB:function(i){return i()}};return t===IDBDatabase.prototype.transaction&&!r[e(1582)](r[e(1563)],IDBTransaction[e(1476)+"e"])?function(i,...o){let c=e;if(r[c(545)]===r[c(951)])_0x48854b&&_0x3f275f[c(668)+"Listener"](c(764),()=>_0x4c33c7()),_0x11f768&&_0x4abe4a[c(668)+c(662)](c(1370)+c(1700),()=>_0x3d2b50());else{let f=t.call(yi(this),i,...o);return _c[c(554)](f,i[c(741)]?i[c(741)]():[i]),r[c(702)](At,f)}}:r[e(1619)](ay)[e(578)](t)?function(...i){let o=e;return t.apply(r[o(702)](yi,this),i),r[o(702)](At,yc[o(656)](this))}:function(...i){let o=e;return r.RQjGE(At,t[o(1504)](yi(this),i))}}function ly(t){let e=M,r={LqpFO:function(i,o){return i===o},dPNsK:"function",hfqRB:function(i,o){return i(o)},dpnaE:function(i,o){return i instanceof o},LYGLJ:function(i,o){return i(o)},wCLoS:function(i,o,c){return i(o,c)}};return r[e(1532)](typeof t,r[e(1008)])?r.hfqRB(uy,t):(r[e(232)](t,IDBTransaction)&&r.LYGLJ(dy,t),r.wCLoS(nl,t,oy())?new Proxy(t,Xs):t)}function At(t){let e=M,r={vmPLb:function(o,c,f){return o(c,f)},iIqSq:function(o,c){return o(c)},vQQwU:function(o,c){return o instanceof c},lxxbZ:function(o,c){return o(c)},duTHS:function(o,c){return o!==c},xYIxr:function(o,c){return o===c},EYMpM:"QacCO"};if(r.vQQwU(t,IDBRequest))return r[e(643)](cy,t);if(Js[e(768)](t))return Js.get(t);let i=ly(t);return r[e(914)](i,t)&&(r[e(538)](r[e(1094)],"QacCO")?(Js[e(554)](t,i),Ys[e(554)](i,t)):(_0x3bbab4(_0x585738,96),r.vmPLb(_0x3438a3,_0x212e97,r.iIqSq(_0x3fcb01,_0x3dad1e)))),i}var nl,Vu,Yu,yc,Vs,_c,Js,Ys,Xs,yi,Xu=tl({"node_modules/idb/build/wrap-idb-value.js"(){let t=M,e={CnGlR:t(553),dEzKr:function(r,i){return r!==i},rXGDE:t(1571),rsvyS:function(r,i){return r instanceof i},eETpF:function(r,i){return r===i},MosGX:t(1035),RcEPn:function(r,i){return r===i},NRiZl:t(280)+"oreNames",xEyvJ:function(r,i){return r===i},xcYEw:function(r,i){return r!==i},jIPTh:t(620),hTsKy:function(r,i){return r(i)},phcBU:t(972),mJzBu:function(r,i){return r in i}};nl=(r,i)=>i.some(o=>r instanceof o),yc=new WeakMap,Vs=new WeakMap,_c=new WeakMap,Js=new WeakMap,Ys=new WeakMap,Xs={get(r,i,o){let c=t;if(e[c(1270)](e[c(233)],e[c(233)]))_0x23ac66.body[c(1185)+c(1453)](_0x5d11d4);else{if(e[c(251)](r,IDBTransaction)){if(e.eETpF(i,e[c(810)]))return Vs[c(656)](r);if(e[c(892)](i,e[c(1219)]))return r["objectSt"+c(514)]||_c[c(656)](r);if(e.xEyvJ(i,c(972)))if(e[c(1426)](e[c(935)],e[c(935)]))this._debug(e.CnGlR,_0x1bb112.message),_0x37294e();else return o[c(280)+c(514)][1]?void 0:o[c(280)+"ore"](o[c(280)+c(514)][0])}return e.hTsKy(At,r[i])}},set(r,i,o){return r[i]=o,!0},has(r,i){let o=t;return r instanceof IDBTransaction&&(e[o(1179)](i,e[o(810)])||i===e[o(500)])?!0:e[o(551)](i,r)}},yi=r=>Ys[t(656)](r)}}),rl={};sy(rl,{deleteDB:()=>hy,openDB:()=>xy,unwrap:()=>yi,wrap:()=>At});function xy(t,e,{blocked:r,upgrade:i,blocking:o,terminated:c}={}){let f=M,u={OIBWM:function(_,y){return _===y},TEQpX:f(1621),XlYmx:"YHDbY",oVhcP:function(_,y,A,E,v){return _(y,A,E,v)},qwlpH:function(_,y){return _(y)},AfPSK:f(764),AaLCt:"versionchange",oVBUE:"upgraden"+f(1607),EhiaG:f(631)},x=indexedDB[f(447)](t,e),p=u[f(829)](At,x);return i&&x[f(668)+f(662)](u[f(1378)],_=>{let y=f;if(u[y(1627)](u[y(1696)],u[y(432)]))for(var A in _0x1e5eca)_0xd2b0e(_0x1e0d7e,A,{get:_0x499885[A],enumerable:!0});else u.oVhcP(i,At(x.result),_[y(1067)+"on"],_[y(1131)+"on"],u[y(829)](At,x[y(1305)+y(389)]))}),r&&x[f(668)+f(662)](u[f(907)],()=>r()),p[f(785)](_=>{let y=f;c&&_["addEvent"+y(662)](u[y(670)],()=>c()),o&&_["addEvent"+y(662)](u[y(1027)],()=>o())})[f(1450)](()=>{}),p}function hy(t,{blocked:e}={}){let r=M,i={wxuwu:r(631),cwMec:function(c,f){return c(f)}},o=indexedDB.deleteDatabase(t);return e&&o[r(668)+r(662)](i.wxuwu,()=>e()),i[r(296)](At,o)[r(785)](()=>{})}function Qu(t,e){let r=M,i={fAgMX:"readwrite",SogOI:"readonly",IOVxE:function(x,p){return x instanceof p},KgKVs:function(x,p){return x in p},LihaP:r(1407),KsooS:function(x,p){return x in p}};if(!(i[r(950)](t,IDBDatabase)&&!i.KgKVs(e,t)&&typeof e===i.LihaP))return;if(Zs[r(656)](e))return Zs[r(656)](e);let o=e[r(1313)](/FromIndex$/,""),c=e!==o,f=sl[r(578)](o);if(!i[r(948)](o,(c?IDBIndex:IDBObjectStore)[r(1476)+"e"])||!(f||il[r(578)](o)))return;let u=async function(x,...p){let _=r,y=this[_(1305)+_(389)](x,f?i[_(414)]:i[_(349)]),A=y[_(972)];return c&&(A=A.index(p[_(207)]())),(await Promise[_(1632)]([A[o](...p),f&&y[_(1035)]]))[0]};return Zs[r(554)](e,u),u}var il,sl,Zs,py=tl({"node_modules/idb/build/index.js"(){let t=M,e={UPlhK:t(1303)+t(1420),tOfEs:function(o){return o()},cnUKY:t(656),uQiMP:t(1399),TKOwT:"getAllKeys",qlkNc:t(618),cRVXi:function(o){return o()},pUtEc:t(413),FboIe:t(301),KjkZY:"clear"},r=e[t(1302)][t(513)]("|"),i=0;for(;;){switch(r[i++]){case"0":fy(o=>({...o,get:(c,f,u)=>Qu(c,f)||o.get(c,f,u),has:(c,f)=>!!Qu(c,f)||o[t(768)](c,f)}));continue;case"1":e.tOfEs(Xu);continue;case"2":il=[e.cnUKY,e[t(739)],t(818),e[t(1411)],e[t(1230)]];continue;case"3":Zs=new Map;continue;case"4":e[t(187)](Xu);continue;case"5":sl=[e[t(1063)],e[t(1299)],t(1264),e[t(1552)]];continue}break}}}),gy={idb:function(t){let e=M,r={eOQlM:function(i,o){return i<=o},VuyqO:function(i,o){return i|o},RIByq:function(i,o){return i<<o},cmEQj:function(i,o){return i&o},dHZeK:function(i,o){return i<<o},iPgwG:function(i,o){return i>=o},QmFBf:function(i,o){return i-o},rBEWg:function(i,o){return i<<o},yCXis:function(i,o){return i&o},SLItM:function(i,o){return i&o},YjCYE:function(i,o){return i+o},PrzRO:function(i,o){return i>>o},AQsDd:function(i,o){return i+o},FmqIx:function(i,o){return i!==o},lZTar:e(375),OyMzd:e(897)};t[e(1692)]=Promise[e(683)]()[e(785)](()=>(py(),rl))[e(785)](function(i){let o=e,c={IIPzM:function(f,u){return f<u},AIdQr:function(f,u){return r[H(912)](f,u)},ZMGIm:function(f,u){return r[H(1311)](f,u)},niKCD:function(f,u){return f<<u},wIZLz:function(f,u){return r[H(1311)](f,u)},CPGxN:function(f,u){return r[H(916)](f,u)},TYgcb:function(f,u){return r[H(1558)](f,u)},PdYWG:function(f,u){return r[H(341)](f,u)},PIEUe:function(f,u){return r[H(1558)](f,u)},ZwFyk:function(f,u){return r[H(1636)](f,u)},CsbvX:function(f,u){return r.QmFBf(f,u)},KOedw:function(f,u){return f|u},IpYEu:function(f,u){return r[H(1070)](f,u)},gkXAa:function(f,u){return r[H(723)](f,u)},pNOJL:function(f,u){return r.SLItM(f,u)},pGeyL:function(f,u){return r[H(456)](f,u)},okLnT:function(f,u){return r.PrzRO(f,u)},gZFSM:function(f,u){return r[H(780)](f,u)},UaZrH:function(f,u){return r[H(723)](f,u)}};if(r[o(831)](r.lZTar,r[o(1081)]))return i;{if(_0x25cd7e-_0x53a3a9<1)return"";let f="";for(let u=_0x263387;c[o(1718)](u,_0xe6b2aa);){let x=_0x5be00e[u++];if(c[o(689)](x,127))f+=_0x212efb["fromChar"+o(1025)](x);else if(x>=192&&c[o(1718)](x,224))f+=_0x2a572f[o(266)+"Code"](c[o(1714)](c[o(188)](31&x,6),63&_0x5dd22e[u++]));else if(x>=224&&c[o(1718)](x,240))f+=_0x27f25a[o(266)+o(1025)](c[o(800)](c[o(1717)](c[o(1741)](15,x),12),c.PdYWG(63&_0x361cb9[u++],6))|c[o(882)](63,_0x3a33ed[u++]));else if(c[o(1599)](x,240)){let p=c.CsbvX(c[o(1162)](c[o(1047)](7&x,18)|c[o(1717)](63&_0x5265d3[u++],12)|c[o(188)](c[o(174)](63,_0x4cdef9[u++]),6),c.pNOJL(63,_0x4da5d2[u++])),65536);f+=_0x56ad4a["fromChar"+o(1025)](c[o(988)](55296,c[o(1423)](p,10))),f+=_0xe0142a[o(266)+o(1025)](c[o(246)](56320,c[o(1437)](1023,p)))}}return f}})}},el={};function It(t){let e=M,r={dGwIh:"2|3|1|4|0"},i=r.dGwIh[e(513)]("|"),o=0;for(;;){switch(i[o++]){case"0":return c[e(1692)];case"1":var c=el[t]={exports:{}};continue;case"2":var f=el[t];continue;case"3":if(f!==void 0)return f[e(1692)];continue;case"4":gy[t](c,c[e(1692)],It);continue}break}}It.d=(t,e)=>{let r=H;for(var i in e)It.o(e,i)&&!It.o(t,i)&&Object[r(1316)+r(1516)](t,i,{enumerable:!0,get:e[i]})},(()=>{let t=M;It.o=(e,r)=>Object[t(1476)+"e"][t(625)+t(1516)][t(1691)](e,r)})(),(()=>{let t=M,e={YHrVm:function(r,i){return r+i},Jmbop:function(r,i){return r!==i},ijEIW:function(r,i){return r|i},RUnjZ:function(r,i){return r<<i},UHJQP:function(r,i){return r&i},veVHp:function(r,i,o){return r(i,o)},SkDTc:function(r,i){return r+i},gkYSX:function(r,i){return r&i},CsSFo:t(1052),DlgGN:function(r,i){return r!=i},Qwuro:"undefined",LHNVR:t(749),jNIWg:t(1484)+"le"};It.r=r=>{let i=t,o={Rihif:function(c,f){return e[H(431)](c,f)},aAuKt:function(c,f){return e[H(431)](c,f)},DZhYP:function(c,f){return c+f},gNRnl:function(c,f){return e.Jmbop(c,f)},GZeyX:function(c,f){return e[H(781)](c,f)},zgmFd:function(c,f){return e[H(222)](c,f)},LtdUq:function(c,f){return c|f},UxOOE:function(c,f){return c&f},vsFVF:function(c,f){return c<<f},JeiGv:function(c,f){return e.UHJQP(c,f)},UBVDz:function(c,f,u){return e[H(1159)](c,f,u)},hMXyx:function(c,f){return e[H(1003)](c,f)},WyrXZ:function(c,f){return c>>f},HJsqc:function(c,f){return e.gkYSX(c,f)}};e[i(1408)](i(1052),e[i(936)])?(_0x50dfc9=_0x4d097f[o[i(1624)](o[i(270)](_0x2258a2,_0x516d37),1)],_0x15b6cd=_0x56e71a[o.DZhYP(_0x17d029,_0xc94f4)+2],_0x553002=_0xa32136[o.Rihif(_0x54fabf+_0x38c24b,3)],o[i(1154)](o[i(1285)](o[i(1285)](_0x3139c7,o.zgmFd(_0x2638e2,8)),o[i(294)](_0x4847d5,16))&12632256,8421504)?_0x381cee+=_0x4d680b:(_0x2d7b51=o[i(1285)](o[i(327)](o[i(294)](o.UxOOE(7,_0x58393c),18),o[i(294)](o[i(924)](63,_0x5e15bb),12))|o.vsFVF(o[i(372)](63,_0x2a8627),6),o.JeiGv(63,_0x504cf7)),_0x32f39f<65536||_0x207af6>1114111?_0xe7d4f9+=_0x649d30:(_0x10f2e9-=65536,_0x395a74+=o.UBVDz(_0x1332c0,o[i(548)](o.WyrXZ(_0x374fbc,10),55296),o[i(270)](o[i(959)](1023,_0x3dd868),56320)),_0xa9ec0b+=3))):(e.DlgGN(e[i(216)],typeof Symbol)&&Symbol[i(1614)+"Tag"]&&Object[i(1316)+i(1516)](r,Symbol[i(1614)+"Tag"],{value:e[i(356)]}),Object[i(1316)+i(1516)](r,e[i(1244)],{value:!0}))}})();function Qs(){let t=["rffutgS","zMfzBfC","Bw1KC2i","ChvZAa","x3DZ","qxzxuMK","BNrfBMrWB2K","wgPeqMO","Dg9Y","zK1yv0i","DNfjvfK","wwHWCuu","te5nvfO","DxnAB1a","Afj4u0C","DuHHB3m","twz0Bxm","Dxrjza","z2v0s2v5","B0niy1e","wuX5A1e","rfvVzKi","CMPAtgG","vw5PBxbSzw0","u0rRyxm","vhrcuM8","C3rYAw5N","sM1IB3a","EwXezhq","ig1LC3nHz2u","veTpD1q","rMXsDge","zvLorMS","CM92AwrLigi","tvrgwMe","tfP6AfG","Eg1duMO","BLfpELi","we9ltwm","m3WW","AevYCM9Yrxy","v3Dnr04","B2TmBLq","tvHNt3i","uuDUwfy","EgnzrxC","Aw9Ul2PZB24","ExbL","z0rmuxm","rhvvzwS","AK92BNm","y29UBMvJDfm","vxniC00","quXm","q1LWte4","zcWGDw5RBM8","vwfACKG","yNL0zu9MzNm","qLfsD0S","x3bHDgHlzxK","yw5Hz2vY","x2LUAxq","x2LZv29YA2u","C3bSAwnL","Cg93","ELzoEu4","vxrXvxq","DMfS","yw5Nzq","y2f0y2G","x194x21Zz18","y3zyDue","AwXK","yNL0zuXLBMC","zNDsChy","BLv0sNq","CLf6vLm","yLf4yNy","qNnTEu8","D2vI","qufLDMy","zw5XDwv1zq","zMLUza","x2HHBMrSzu8","ywDLrxzLBNq","sNjWsxi","rNjVBNrPzxi","aaaaaaaaaaa","v2DhDeG","A0fWAwq","v2vPEgLUsLm","uunivwS","ENHOywu","B05otgu","weLuze4","ChjVDg90Exa","B3nLza","s3res0C","Ec1TC2CTy3u","vxLmzeq","uhDcufC","x2HHBMrSzvi","EK9IAwe","x19LC01Vzhu","zNjVBujPDhm","tfnrB3u","DMfSDwvZ","Egngu1O","z2v0qwXSs2u","v1foBgG","BNzHy2e","x2rPC2nVBM4","DhDVCMTdAge","zxj2AwnL","yLz6Dw8","ANjrt00","x2LZtM9Kzq","B25ozxr3B3i","vvrVuxK","AenSB3nLrxy","C01jyvy","D0LVBvq","ufbKt1K","yxbWBhK","DuvgEvm","y2PPB3a","rhPNCwe","BMv4DcGPigm","CKverfC","Bg9Nsurhzw4","ywnRDxbfBMq","Dw5ZAwDUzwq","B3nLrxzLBNq","r3LIB1C","B1bUDxO","B3bLCNr5","zgvJB2rLzey","DvbuvLy","vwTzBuK","AKjKAeS","sxHKuLi","lcbTyxGGCMu","CYbHBhjLywq","rK9Az04","rxzLBNq","x2LZtwLUAvq","q0Xpu0LorW","Aw5N","EwHqvwK","ywXSB2nvBNm","C3vIC3rYAw4","thfWrK8","zxjHDg9Y","CwHLAgW","mxWYFdn8nhW","yNPIz3q","t2jbq0e","EgT4qMS","ywXPzcb1CMW","AMvkug0","y2HnDg4","tgjrwhm","ywr2yw5Jzq","Cg9PBNrbBMq","zvb0BNy","rwngANy","qu1TELm","uMvHzcbWyxm","x2rItMfTzq","EK9Rvg4","zw1LBNq","s2PRwLK","Ae9Wzw5fDMu","tNrSywO","rKzuAe0","Dev2zw50","tLjIv00","y21fuwO","D1PYr0W","C1D3BvG","rurwv0S","x29Uq2XVC2u","Eu1kv2q","D3j0rLO","BMXswNa","z1rPBwvVDxq","y3ruAw1LB3u","AwDcDwC","yLnkAuC","svrZDvu","s3zqCuS","Aej6zwm","mhWZFdj8mxW","Dg5SEKC","yxv0BW","x0rctMfTzq","sNb0tfe","rKHVshq","Ee5eCu8","DMLoDuO","ugz3wvy","yLbAv2G","y3jLyxrLtwu","zNjVBuHHC2G","B0fZwuS","zxrptxq","vuHJtNC","BwfYzKO","twHNzwK","Axbbrvq","zw50","zgf0yq","wLvlsvC","AxnrB1nnzxm","vw9Pzwm","y3vYC29Y","vKzmr20","AxmGDw5Kzwy","wNDgEwS","u2XfEfC","C3rYAw5NAwy","rKTcwKm","wvHWtMi","vw5Oyw5KBgu","BeLQAhq","zvvYBa","zwvKzwq","yKXSrhG","yNvMzMvY","uhPHwhi","y3r4","BwvZ","Bwv0Ag9K","Dg9tDhjPBMC","BfrPBwvVDxq","s3HmtLK","tgzJu0G","Bgj3rMu","wfbdvui","ihrVihjLDhi","AgvAqMK","ChrVCG","B25tDg9Wsw0","uMLOAwy","rKfAuee","BhfzweC","t0Lcv00","DvHkEKq","q0L3u2q","ywHXC1K","CMvUDevUzha","ywXS","EfvAuKe","B0PKtve","tfbez0i","AvbND0C","v0TND2q","DgvZDa","Aw5PDcbrB1m","t2jQzwn0","rhDPyuq","rgfjt28","ExHUBMy","yxv0B21HDgK","zKTfBwG","x3bPBMDqB24","DxrMofDYAxq","y2HLy2TdDxi","zv9ZDwnJzxm","y3vZDg9Tshq","C2v0zgi","zw50zwqGDhK","tezfsgm","zxDgDKG","qw9MD1i","CMvHC29U","A0r3qwy","x2fKzfDZtgK","zgX0uxm","BKzWzNG","DM9Ky0K","reiGzMfPBgu","B25dBg9Zzq","BgL1Bfa","yKTewuu","A2vAz3K","B25tDgfYDfi","vxbKyxrLq28","B25szwnLAxy","x29UugfNzu4","qw94rxO","zg1eu1O","y29TCgXLDgu","B0vxuMO","x2LUAxrqCM8","wuftrey","BgDdCNa","zgPXuLa","txPttuW","BgncDgq","zgvIDwC","BMvJDa","y29SBM8","y0vuzfK","tu9PAMW","yvLuCvm","CMvZzxrfBMq","x2nVBM5Ly3q","BKDVCeq","y29Kzq","y2fSBa","zxHWB3j0CW","x2rYB3bhBg8","DMLJzuLeig8","Egf4weW","vevrCfG","uuzWtu8","Bfncr0q","zw5HyMXLuw8","AgfUz2u","AMjtuwm","D0vRtue","sKLPyw4","t3rPAMG","C2vYDMLJzs0","Aw47y2HHCNm","rKnZAgy","sMHpEgC","uvf0B0C","uuvNr1q","sLnptLa","uNviCKy","EK5qufC","wK1hsw0","z1f5tfe","q0LnEvi","q1bhEe4","suLqEK0","v0nzv0e","Ec11C2uT","DvbTyu4","r1Dsz0y","wLrOALu","u3LKsKG","A3zdu2m","ww15EgG","rNP5t00","C0zQy28","u0zHteO","vgflD3O","AgLNAa","AgroseO","A2Djq2u","B3jpBMXPBMu","yxbWzw5Kq2G","B25fCNjVCG","CIb0DhDjra","D012Dwy","Dg1OAxm","rMD0Auu","vfLNy2i","BhDwsKm","AwLhCMW","icSG","uMXfyw0","zNH4uLe","CefJEKC","s2vky1u","AernD1O","BMrWB2LUDca","qvn5q3K","vxn4v3u","Bwu6ia","x3jLy29UBMu","rNPjtxq","Cu9ksum","mtG4y3jNvuXe","z2Tyqwe","qLPdrgW","wfLWwMW","vgXZr1q","BxjNvM8","DxjS","sKTTzuq","zM9YrwfJAa","BxDkBNi","svLHDfG","te1cwKG","C2DWCge","zLLSB08","y1jwwgK","BMLlq0q","rffZD0G","AxnrB1nby2S","re9MBfO","ug5Zzwq","swThwva","C3rHCNq","y3jLyxrLrwW","uMXWA1e","zgLZywjSzue","qwfZvg4","rNHjAgO","u2TLs3K","y2HnyxHuCMK","vMHMEu0","thHkvLK","ign1CNnVCIa","yK51Bxu","rNHxyxy","C2HPzNq","BxnNsuq","ywrKq291BNq","EhH1Bfq","z0jlthK","x2vUzhbVAw4","z3zWA3y","tMPOC2O","r3vrvgO","uxD1CM8","vhPQwMm","DxbiuKO","AvPXDxi","y29UDgv4Da","CKT2sLa","uLvUALO","DgLLCKPtt04","yM9KEq","rxLXq1y","wxn3q1e","vKfovLm","BgLUzw5V","vNjiCgi","C2vYDMvYvgK","o2nOyxjZzxq","zhbUyuu","CLHhreu","vLHSExa","zufJAW","ndK5ndiYnLfgBNbTsW","vM1Lt1u","rxjnr08","BKXPBMu","DMvUDa","D24GCMvHC28","tg5wsM0","rMzzy3m","y2XVC2uSihC","yujsDwS","z1Pgu00","zMX1C2HfEha","Euvws1e","zxjFAxnFywm","zw50tgLZDgu","CNn2Evm","sLLXAw8","su5tvefova","id4G","t1vQtfG","y29UBMvJDca","x2XPC3rLBMu","D0rPB3y","yKDPseW","vuv2qMO","uLniD1a","wM55zhy","Bwf4uMv0CMK","AKjZyM0","ze1qq24","zNjVBunOyxi","teHPCfm","veHXB04","renQChG","yuf1s3q","B25pCgvU","CM9YrxzLBNq","vgr2zwO","BM9drui","mJG5nZi1EMTgzuft","vvrpDMC","zMzLCG","B1Hhq2C","CMvXDwLYzwq","B2jQzwn0u3q","txbQC1q","C1nhChG","quLpr1C","u2TPCcbWyxm","ENzdtuW","Aw5KzxGGB3u","s21YALO","Dg50ug8","CwzIteq","wvnYDgy","BNvTyMvY","tKTtzvu","rgvKAwnHDgu","EMDTrMq","EMTftwy","y3Dnzwm","z21Ut20","BNruCMLLC0m","tvbzqvq","s1LAuNK","ywrK","t1bftL9fuLi","uxbZtfO","zxjFywnRx20","CMvQzwn0","uhPnA2O","twLZC2LUzYa","y3vYC29Yx2y","yxPMvuK","x3bPBMC","y29Uy2f0","CMfUzg9T","Ahr0Chm6","zej6y2O","B3zkufC","Egvrr0m","wwPjueW","CMvTB3zLrxy","u2Lks2W","x2zVCM1HDeu","zMHtzK8","sMjiquW","s3DJCu8","y3vYDMfSDwu","v1P2veu","q2zOy1O","thrKvxe","Be1svKG","zNHIyKG","sK5wyNq","ywXSzwqGBxu","zwPIv1C","t0vryxC","B2Xduvi","zgrjrcWGzgu","sNb3Bui","CMfNzvn5BMm","s3fwtg4","CgLbsxe","EKPoEK0","zeHAzuS","sKnNqMO","C0XPC3rLBMu","BNrLCG","zcbLCNjVCI4","zwn0","zgv2AwnLx2K","Dg9cExrLCW","u29Nt0K","vfbksvy","sgfeAwS","r0TlAfK","Cg9PBNrdB24","C3jwwLK","t1bftG","teHovLi","D09pr2W","qKHVzvO","s1bJt2W","C2vUzf9Hy2S","DvvyAMS","DwXpDha","EfvZzuvUDG","zMLSzw5HBwu","sgrUyvC","x3fVC0rc","vKjtCva","qMTbruK","zxjFDhrS","BMDuAw1LCG","zxnJqxG","sMvPr3y","ihjLy29UBMu","shnREu0","zhj4uNa","tKTZzwe","Ee5drxi","vKvKtu4","rLftu3a","y2XVC2veqG","vLHdBeu","CMfTzq","De9ds0S","BMHtsgO","yMLUyxj5vhK","y29UDgLUDwu","x25HDMLNyxq","BwvKAwf0zwW","Aw9U","m3W0Fdb8mNW","zg1bq0m","BM5Ly3q","qLbvz3e","t1HdCMm","q291BNq","x1fVu01HBMe","y2HnyxHdB3u","B2zMBgLUzq","tufyx1jfvfi","ueD5DKW","BgLZDgvUtMu","y3vKC3K","Dgvurgy","x2rLyNvN","CMvZzxrdB3u","C3rLBMvYCW","D3jPDgvvAw4","wuDOtwG","yxKSihrYEsa","EhbqwKm","q09otKvdveK","B25LCNjVCG","Chv0","zKfNtvG","rLjptLrjrvi","yuXKAuy","zgvSzxrLrge","mNW0Fdf8mhW","x3bPBMDmB3m","zMvY","CNbzvLK","qxDQC3G","v2DPEhq","z0ToBwy","CMvHzfvjBNq","B2zMC2v0","Avruwxe","shfwtLa","vgneqwO","BwLUzW","wuHYvM0","wgXzBxG","y2XLyxi","zuPWtvG","t3PWEvq","mdaWmdaWmda","Dxr2B3G","ENztA0S","zM9Yy2u","Dg9cExrLC0i","zeLHEw0","CgLUz19VBMm","CfnmwwC","r0jgs24","yK5yCNe","De5gA1G","B3bLBG","D2vdtvi","D3zXCg8","yNvMzMvYzwq","BgLqqu8","yun6EwG","wuTWB3y","v3vwwKy","q0Xpu0ve","wwPdwuu","s1jIsMe","sxPou2G","AMvJDfn0B3i","AxbNzhK","mta1BwDlzM9y","v2XlENK","wLb2wMO","tuPKshu","l3DZl3yY","vgrPvLy","rLzQB1a","D0LjtNG","AM9PBG","x3nVy2TLDa","CMvKDwnL","zgvNruG","y1D1zM4","y2vivwG","Aw5Lza","DKffCwm","zM9lt3q","zw5fDMvUDa","D3nZoI8V","x2n1CNnVCKy","D29pC2u","DvfMvNi","zw5NDgG","Cg9W","Aen6uhK","yw51Ce1LC3m","vevvDKW","ywjVCNq","DerSAfK","x2jPBMfYEvq","ANjQyMm","y2uGBM90igK","AhrHu0S","rMzPA00","t3nZDw8","x3jLBw92zvC","BhrPCgXLihq","twvZC2fNzuu","DLrpAKi","CgHJqLu","C2vUza","CgfNzxnOB3C","tvzsANO","zxH0ugf5Bg8","ufnvzxu","uLj0veq","rKLmrv9ot1q","uhPlzxO","ChjVDg9JB2W","s0Tgr3q","EgHxsuC","Ec1TC2CTCw8","C3bSAxq","B3jLtMfTzxm","rKzjAuK","zv90Aw1LB3u","zhLgzwy","yxrLq291BNq","ywX3yxLZ","rgDYAxa","yNL0zxm","C3HQBLq","CNzHBfzHBhu","rgPrAxq","DvjHz3u","EurRu1G","ihrPBwvVDxq","C3nHz2vfDMu","y3jLyxrLt3a","B25SAw5L","u215t1C","DxnNzhO","tvbPsue","zMLN","yxnL","rM5Wru0","A1fkzue","EfLjEhi","Cw9Zx18","yw1pAuG","qLDSDLy","y3jLyxrLt2i","zvfhC20","uvbuzxi","s0nZDxy","EsbJBg9Zzwq","rNLerKe","Ae1yExG","BM93","q21bEMi","BuP6qNu","AgjwBfq","CMvJzwL2zwq","C2v0","D0npEeS","CxvSEhu","wvn4vxO","x2rLC3rYB3K","q3rcy1y","EhncBKm","rfv4y1G","vKz1zNm","ENHIyNy","DeLK","tLPWr1O","B2nRzxrtDwm","y3vYq1G","DKHkCgK","wuXmDgi","x3nLBMrby2S","DffprLy","q0n2AwW","qNr0u1G","wMrMAhm","C3bqCu4","x3bYzwzPEa","Ae1LC3nHz2u","Aw5JBhvKzxm","zxjYtM8","s0vTyNy","qKTiA2O","rhfwAgq","v2T0uxG","C1jYB2K","BuHVug0","wvnqz0q","rfHUEuW","Dw50","ywrztxK","zgjLvfe","zejYyuS","z2v0q3vYCMu","CYbWyxjHBxm","C0nxwem","swfdv2q","shbJAfi","rfr0tMW","BMfTzq","yMrFzgLK","EvPZuxK","uunoAKW","BM9Uzv9UB24","rLDt","B0v0Bhe","Dvvbyva","y2HHCKnVzgu","DwjVCum","yMLUza","x3DZsw5ZDge","uwDJsKW","ueDrt2W","uuHrA0u","zxmGCMvHy2G","AwTUtwm","ysbTDxn0igi","BKXRDwW","BwvY","y291BNq","BwvZC2fNzv8","swPUzgy","BM5ct2y","zeTnzxO","CMvJzxzPzwq","ohW1Fdz8n3W","AgfZt3DUuhi","ihrYEsbYzwm","AxnszwfKEq","Bg9IywXty28","vgfN","BwrzC0u","yMXVy2TLza","C3jJ","igzHAwWSig0","q0Lfyxi","AwXLx25HBwu","CMfTugfYyw0","wvPMq3O","CgLUz09Uy2u","DM9eBhG","EvbiENG","wKHmse8","A3DRrvK","BhH4yLO","yxGGCMv0CMK","DxnLCKLW","y3jLyxrLuMu","BKLHzNe","ntm0nLHTEgzqsq","ihrPBwvZ","t1LprgW","y3vYCMvUDeu","CNP0ywu","yxnJCMLWDa","CfrKDhi","EMnRBve","z2v0","A2LSr2u","mxW0Fdj8mhW","rLnpDwq","x2TLEvbHDgG","BuHSCe0","tgLZDgvUzxi","yMPRqxa","BMCGDxjSoIa","DgXwzeC","yK9yuNK","wvjNBuK","ywrKrxzLBNq","q2Xkrg0","qwzqu0S","CM92AwrLige","u01zu2u","twXmyxC","ywrKt25L","sMHLt00","CfrxDfC","uhzSwNO","t3Hqwvu","r0XbELy","A05hEMO","DhLWzq","qLzezK0","CMvZB2X2zq","wNHwt20","zw5HyMXLqxu","su9htfu","rMrPsLy","BezSDxnO","quLKuxi","ufDSy3q","zxrxB3jRq2G","A2v5CW","BMCGzMfPBgu","tvL2ALy","Dhzeq2y","Cgf5Bg9Hza","yxbWBgLJyxq","uKLWr1i","sxjRqLa","D2HstM0","Bg93","Dg1ODui","A2v5","yw1LoIa","t095sfu","BgLUzq","zwnVAuC","x21PBMLoyxy","z2u6ia","yMjSquW","se9nrw4","DKThBw8","BML0AwfSAxO","v0nYsvq","zhvqqu0","uvb2rwS","AurWyw4","s2Luv0S","EMfeA2S","t3rOtMW","B2LUDfjLywm","DMzZCgW","EunyAxm","DKTdqKe","CvLuwKO","Cgu6ia","sfPYCMi","zcWG","CYbPBNn0yw4","qMvYELm","C0TAD3m","AM90tva","zLbvBuW","zvn4ANG","tg9NsurozxC","nxW0","ignVzgu6ia","qLLhruC","DvfPtva","A2jJqLC","C29YDa","DxbKyxrLq3u","Bw1PBK8","EKHnu2O","wenvv1u","yw1Lu3bHy2u","y3vYC29YlNm","Eu5lA2y","tw9KDwXL","mxW0Fdb8m3W","BMnLq2XVC2u","Buzlswm","yurzwhe","vMz3CKW","wu5MA3O","uwjbrhu","tfn6DgW","tefMqwy","wLDcs0G","CLzHBhvLCW","uhjPBwfYEuS","DxrVuMvJB24","DLblAei","y2XVC2u","CNnVCKzPBgu","x2LZtwLUAvC","ywTowuK","AgfZ","ELrhyxy","zgrWr3u","x21LC3nHz2u","A09Sv1y","BMvY","sfj5uvi","x2LUDgvYDMe","Dgf1reO","CK1vwuu","B3jRig9MzMW","sLLIreu","qvfZrgq","AwPfsvC","r0nmDg0","EgvqzeO","BgvUz3rO","DgHLBG","tKDjrKW","DKfvy20","BMvrEwi","zxjYB3i","ueLmvu0","r3rZru4","y2P4ueC","B2nRzxq","x2LUAxrhBg8","txv6ru4","EgTWD0O","yw1L","yxntyKe","uxvLDwu","D0LAthO","CKr3DxO","AxDVrNC","te5oC3i","ExPQAfO","BKrsBfq","BLnOzu8","vKfICgK","DhbizwfKzxi","zxHZrfe","tw9Zr1G","ihn1y2nLC3m","r25XCwK","BKzYzfi","s1rysfu","y29UBMvJDeu","u3zZvfi","DfDZsem","z2v0qwXS","zK1br2W","u0PJtfe","yvfLuxq","vur6yNq","EvjLy29UBMu","x2DLBMvYyxq","zNjVBu51Bwi","yw5MAhO","DhjPzxmGCMu","CgLUz1rPBwu","CxDSCeG","x3bYB3rVy28","rM1XsxG","tg9Nsuq","C3jwqLy","C2XPy2u","Du9cwu8","r2rdAxy","CNzHBa","B3vUDa","tLLqt0G","BM54DK4","BMrWB2LUDfq","zNjVBuj5Dgu","AfjXq3G","DwXvENO","yMfSrxzLBNq","D2LSBfjLy28","CMTLCKDSB2i","yuLjt2O","tvPTEvi","rhLhyKO","t2zyzwi","A3LjvMm","A1rIAe0","tgrzte4","mNWXmhW5","CxDIrvy","sNPpqKy","wgfiEgq","y2vZC0HHBMq","reLVDeO","AMfRuxG","CgfYC2u","z2v0q3vYC28","zNjVBNrPzxi","z3vnB2i","Ae1fr3i","BejtzKO","y09Wzw4","EfDIDgC","DMP1Evu","B3bLCNr5tMe","zvbzDM0","DvL0t08","q0H6yu8","DNzbzLG","tMHwtuW","qxjKqw8","Axnby2TdBgu","t3bLBKv2zw4","x29UvgLTzw8","uerIv3G","ueLfvwu","uKPMCMO","y3vYC29Yx24","q050twK","mty3ndi0ognOALjACW","Euvtsxu","B3niDLq","CgvYC2LZDgu","Avb1A0G","t0fRwhC","uMnfug4","AgvHzgvYCW","Cfvnr0K","zNH4Du4","CeHmsKm","ENzYD24","t3LNtxa","weXREva","uhPeCu0","yM5iDe4","C0Xf","Bg5yuha","BMrOCMu","BMnVzgLUzW","vgLTzw91Da","rwHPyuC","sgnYt3q","y29UBMvJDgK","sw1urNO","CxHxA0i","zu9rBe0","zNvUy3rPB24","zhvusfm","DgLTzw91Da","uKLcExe","C2v0sxrLBq","u2vYDMLJzvC","ruDgBuy","B3bLBKrc","r3Hjz3C","CNjVCK1LC3m","CeDnBvO","vxHpt0u","A0jLC3q","EevbCNe","CefwwNm","y0XhCxi","z2vjBMzVu3K","tKDdthy","CMXhyLO","wKrWv1K","t0T2t0m","CgLUz0LUDgu","AKLqvgG","q3ntrM8","yNLqv0O","uuPMtKi","q2n4C2u","EKPoBNm","BwvZC2fNztO","z1PhBei","DuPxCfG","CgXLyxnLiha","wwP2DuC","u2vXsuq","Cg5fCw8","s3nVB1m","uw9gDva","su9wEeu","ywzovwO","EKrhzem","werYDuu","wuv0C0W","ihbYB3rVy28","B2nRzxrgywK","EKjIzNm","CgLUz0XVC3m","sePZCwm","svLpCe4","AgvKtwf4uMu","z09Mt1q","yxryAgm","Au1Pu2W","vgLjyK0","D3jPDgu","zw5JB2rPBMC","sKXSrxK","C3vIyxjYyxK","uenlue0","B1bcBhi","C3rVCMu","x3nLCuLK","Dhf3zMO","thnewMW","x3vYBa","AhPcteG","teLMD2O","x2nYzwf0zvm","zwrPDuS","yMLUyxj5","BMvcruC","q2Xxwxm","Bwf4tg9ZC0m","B25Uzwn0Aw4","z2v0u3rVCMe","uuP1r0u","CeDLEuW","wLvgAvK","v1DSDxO","tejdqvO","zMzmAw5L","sgDbCMm","uKTAvK4","wuLbv3q","uuTkC20","Ahr0Ca","A1vkrwy","CvzHrfa","zMvsufO","yMfJA3vWigu","z0XMseW","u2Tevgm","zMzMzG","nJC0mdiWvgLrtNLi","D1zQyK8","x2nSzwfYugK","zfboC0S","wvLeEgO","igzPzwXKoIa","sMrHB0K","BwvZC2fNzq","B3bHBhm","BK9qvfG","rxr4s2m","wwLTCvu","CvPgquW","BwfUDwfSihi","vgrxEvO","AgzrD2y","r0zcv1a","t3DLDLO","uLjpuG","DerVtwO","q29Kzq","CNDQDgC","qwfmq3q","twr3vLG","AxjLza","zLztBve","y3vYCMvUDeK","CLfru0y","tKfusvzfx0u","vw9iDMG","zg9Uzq","yMngu1q","quXWrva","DNHOzhO","tvfcCK4","rejvvfC","zw1PDa","BIWGAg9ZDg4","DgLTzw91DcW","y2vOrvy","AMjXsKC","tNH3sgS","sxbzrxu","AxnAzxjV","wMXRD2S","CePjr2e","suvtx0vsuK8","CMrXAwW","B3jL","DhjPBq","wxfRwKK","vwPVwKO","yNPZreK","Dg9hzw5LCMe","z2vrDwv1zuW","zwr5z2G","vhH1yNK","Aw50zwDLCIa","Cfv0rwm","CMLLC0nVDw4","y3jLyxrLq2W","BKzRtwW","B2XKvMvYC2K","t0zOqwK","C2vYDMLJzq","CKjfv2C","DuP3Bhu","Dg9VigXHCMC","z2vXtLe","ChDiwvK","B25JBg9Zzq","veXPs3C","AxnFywnR","zvbkAe8","A1rTDei","q29UzMLN","t3LnEMq","lcbOB3n0BMe","zwrPyxrLBhK","qKjzvu4","q3vZDg9Trxi","zxjFCw9Zx2e","CuHNwwi","x2LZsw5PDa","s0LOre8","revcsxm","tKztDKC","Cgf5Bg9Hzfq","t0zju3e","rvLnCe0","x29WDgLVBNm","DNLwqNG","wgzLAuK","ywDLsgLKzq","sMrJu3K","u3bQwNu","qLfZBxC","tvPIsKK","x2nSzwfYvgK","Aw55yue","BNrbBMrvCgq","CMvHzhLtDge","B2fK","suzKBNe","uLziwgO","y29UC3rYDwm","u0jHzw8","ChjVy2vZCW","ywnRpwzYB24","BwLpENa","Du5bsfe","rxjYB3jdB2q","vvjxEKO","zwnVBM5Ly3q","CgPXuNu","rNn6sgm","C2v0q3vYC28","x2HHBMrSzva","DKPytK0","AKD5BKK","AwDHDg9Yt24","u3rYyxrLz3K","DgfYz2v0","zgvS","Ef9MCM9UDgK","ruHxExu","BMv3vMvYC2K","v2vIu29JA2u","Dg9oDw1Izxi","x2LZqNjVD3m","x2n1CNnVCK4","ywDLu2HVDW","DwDVCwm","BwXXEeq","AhDcy2W","whrAt0u","AefJA01LC3m","BvH1zw0","DgLUzYbZzxi","EfvNsum","uMLjseq","s3jYy0m","yxjYyxLIDwy","BMCGB3iGyw4","tuvtu0fhrv8","z2v0t3DUuhi","wLjvqvK","sKvuBw4","CuX2EMe","z05sBMW","BvfswK8","vKnNqwy","DNfnvMq","BeLAv3i","DMvwsha","yxDVEM0","surxs0C","s09LzhC","u1LiwLm","C0nVDw50zxi","A2fdtee","Cgf5Bg9Hzeu","Bhn2u2O","BMDLza","u1rJsuq","Bg9N","yvDvuwu","mdaWma","zxjYtxnN","zfDVCMTLCKC","uLHPBM0","yxrHlcbKyxq","zxH0zw5ZAw8","tK1mvMe","Eev5DKO","x2rPC3bHDgm","B25TzxnZywC","uLPNB3q","z2vtEw5J","C21ks0W","CMvTB3zLq2G","CM92AwrLihC","EK1HtKm","Dgv4DfbHEwW","ihzHBgLKihm","CNbICK4","Dg9mB3DLCKm","A2HMwNK","y0HhEM8","t21cEMS","zhrWDu0","DePJtfe","qvnewxa","DLb4BMK","qw1VDw50","D1DYwui","qvHkDMK","sgvTC1a","zMPLEKm","uNPgv0S","C0f0ywW","ywPqywi","DxfLzK0","tKPizMC","vffpDva","ywXty29Wzq","q3vZDg9Tq2W","BvjLtMu","wwn0reG","whnTquC","zKLTug4","A1n0yxr1C0m","DvLsuM8","AxnmB25N","tLjPwMW","DerwAem","ugvvtgu","twTsBfq","z0vLzNC","Dg9cExrLC0W","s2HgB2e","B3jRzxjhBg8","zgXvBuu","x2n1CNnVCK0","EfH5uue","CwXRtMm","BgLTAxq","zgXZELK","tenOvMG","ywDL","nty5odjZthbuBvu","BfnbEwi","tKLot3a","CNnVCL92ywW","C0jf","Dgv4Dc9WBge","DwTwt08","sxbRDKG","B2zM","AK5jv2C","x29UtwvZC2e","BKLiAee","u2PcsK0","ywnRx2LK","sLfHwKy","vNjKDLC","swPJz3a","ze5zv00","thfHzfq","DhjPzxm","uMT1CgW","m3WWFdj8mxW","Eev6r0W","uLnJCgq","svjSBgW","uvrft0e","AwrI","sKzUwfq","C0fuvwW","zgvSzxrL","ufjjCMy","C2nYAxb0","sNrOELe","AgvHzgvY","rLHku0e","zev6s3i","ALjHruq","DwzMELe","Aw9UvgLTzw8","ALzmBwK","uMvJB25Uzwm","EffYs2W","qxfJq2S","zw5KCg9PBNq","DKLhvMe","x0vysvnu","DLn5vMe","DgfIyxnL","CKLhEuW","BeHHBMrSzxi","r1PLEvG","zMHlBuC","EhjyCNe","zerLq2G","CM92AwrLihy","ueXTB1i","DcbSAw1PDa","mtG2nta1se53v0XM","sNPTvg8","AxrVBgi","tKDFrvjst1i","x3jLywr5q2W","y3jLyxrLrxi","r3zwuKK","rMjVswu","z2vY","zNDYDxm","vvbSAeS","nhWXFdj8nxW","whrHvxi","DhjHBNnHy3q","AwXLtMfTzq","yNLL","BMrLEa","y2HLy2Tszwe","BgvY","vNv5Cu8","DMfSDwu","CMvWBgfJzq","ALDwC1K","se1drwy","zgvMAw5Luhi","vgzwz2W","Aw5L","Bxvyz2m","C0znz1e","EwHTqwm","zK1rqM4","q2f3u08","z3HlBuS","z3j1rMC","BKz0Eu0","y2XLyxjtDg8","BwfW","tg9JAW","zw5JB2rLrNi","zNjHBwvuExa","C3vJy2vZCW","ywWGy3vYC28","BunAwgS","A2v0ignVBNm","EgLiwuC","yK5ZzK4","BwLZzq","weryswG","yxnZAwDU","B25mAw5L","B3v0sw50zxi","zKLbwwG","sMTPvKG","CMvJB25Uzwm","B25VCgvU","x29Ut3bLBG","Aw1LCYbPBIa","Cfb0yMG","vxvyyxm","Dgv4Dc9Qyxy","BLzuEeG","CM9QsNC","veTrshG","rvjst1i","C2vtruC","zw5HyMXLvhi","AxzZA3G","rLnwtNG","C2v0u3rVCMe","ywnRtxnNswq","jMPZy2fSBgi","C2fNzq","zxjFBxnNAwq","z2v0sxrLBq","yKnqtMe","D2fZq2XLyw4","ywnOzwq","rM9bA08","DMvYC2LVBMm","DNrHAha","DeLUDgvYy2u","Dw5KzwzPBMu","x3DHAxq","Aw5KzxHpzG","vef3yMC","CMvZDwX0","B1zcvuu","zMLSDgvY","De1HBMfNzxi"];return Qs=function(){return t},Qs()}var be={};(()=>{let t=M,e={kTmtB:function(a,n){return a+n},dtpuM:function(a,n){return a+n},WwMGN:function(a,n){return a*n},MQBrN:function(a,n){return a+n},TKQHx:function(a,n,s){return a(n,s)},KPcOl:function(a,n){return a+n},PzKez:function(a,n){return a!==n},WCYWA:t(861),ePJhO:function(a,n){return a(n)},jVLmi:function(a,n){return a+n},qfbLD:t(1172),lSAyb:function(a,n){return a(n)},oPBlr:t(436)+t(436)+t(436)+"00000000",uJWpX:function(a,n){return a<n},sSGpx:function(a,n){return a>n},xkpwJ:function(a,n){return a!==n},jsqdf:t(182),VrHpb:t(1749),aLdiF:function(a,n){return a-n},AvWRi:function(a,n){return a<n},osHvT:function(a,n){return a===n},ipAET:function(a,n){return a<n},ejbWW:function(a,n){return a&n},xBMnr:t(1207),UsxWu:function(a,n,s){return a(n,s)},HMCEf:function(a,n){return a>>>n},mlqxD:function(a,n){return a(n)},fMQBn:function(a,n,s){return a(n,s)},NKsea:function(a,n){return a&n},KKFGt:t(307)+t(279)+t(1010)+t(703),geqNQ:function(a){return a()},tWsHC:function(a,n,s){return a(n,s)},IYOpN:function(a,n){return a==n},iwoFw:"ws://",zvCML:function(a,n){return a===n},fhKmG:t(707),lIZWr:t(1419),cWufn:function(a,n){return a!==n},URWzJ:function(a,n,s){return a(n,s)},wrtFZ:function(a,n,s){return a(n,s)},fwRpv:function(a,n,s){return a(n,s)},DyGbJ:function(a,n,s){return a(n,s)},pJIGa:function(a,n){return a!==n},DTtNl:function(a){return a()},AoxEz:function(a,n,s){return a(n,s)},vKCBA:function(a,n,s){return a(n,s)},FzIMt:function(a,n){return a!==n},xQrKl:function(a,n,s){return a(n,s)},NxwHk:function(a,n,s){return a(n,s)},NFSvG:function(a,n){return a!==n},ddpGu:function(a,n){return a!==n},zTGav:t(675),TfVgl:function(a,n,s){return a(n,s)},PzZkm:function(a,n,s){return a(n,s)},YGhMh:function(a,n){return a(n)},GtsEN:t(1314),BBYUN:function(a,n){return a(n)},oEtlq:function(a,n,s){return a(n,s)},xGkAl:function(a,n){return a(n)},JKmeD:function(a,n){return a(n)},iajfF:function(a,n,s){return a(n,s)},qhehl:function(a,n){return a(n)},obShv:function(a,n,s){return a(n,s)},dyFef:function(a,n){return a(n)},sWwmX:function(a,n){return a(n)},UuXas:function(a,n){return a===n},rlGbZ:t(307)+"required"+t(1010)+t(946),dKMez:function(a,n){return a===n},RKsQB:t(307)+t(279)+t(1010)+t(832),etOMt:function(a,n){return a===n},WWluz:t(307)+"required field: "+t(1613),YZZmx:function(a,n){return a(n)},QTEOA:function(a,n){return a+n},gBKLy:function(a,n,s){return a(n,s)},YjvuG:function(a,n){return a(n)},EDVWK:function(a,n,s){return a(n,s)},THqoN:t(1404)+t(1652)+t(726),fxxRQ:t(278),XnMkL:t(1376),pAczG:function(a,n){return a>n},tlVdG:function(a,n){return a+n},OpeuW:t(284)+t(1291),CfhcZ:function(a,n){return a>=n},DCjpx:function(a,n){return a+n},XtaUr:function(a,n){return a>n},vyVBx:function(a,n){return a*n},uYRRo:function(a,n){return a>n},tDlhY:t(1548)+"t limit",ZUObj:t(415)+">",kilGe:function(a,n,s){return a(n,s)},byPWJ:function(a,n){return a+n},IxdRR:function(a,n){return a===n},TQOuP:function(a,n){return a&n},PGyvL:function(a,n){return a(n)},XtZOE:function(a,n){return a===n},gmnOm:function(a,n){return a+n},usgdz:function(a,n){return a&n},MlLaw:function(a,n){return a|n},TzjZc:function(a,n){return a<<n},oAsYK:function(a,n){return a==n},DwiaD:function(a,n){return a+n},ediuK:function(a,n){return a|n},vAUcm:function(a,n){return a<<n},ipgdy:function(a,n){return a<<n},nUtJt:function(a,n){return a<<n},hwBcl:function(a,n){return a&n},ZxVOm:function(a,n){return a>=n},PSUeu:function(a,n){return a<=n},bcFST:function(a,n){return a&n},GCLtm:function(a,n){return a>=n},SjBJM:function(a,n){return a+n},kOlWV:function(a,n){return a+n},IzNSh:function(a,n){return a+n},qYTZJ:function(a,n){return a&n},VBSqP:function(a,n){return a<<n},kgICe:function(a,n){return a|n},RlEam:function(a,n){return a&n},FzyOM:function(a,n){return a&n},fMAGl:function(a,n){return a<n},yZsQy:t(536),HSELX:function(a,n,s){return a(n,s)},ylDdt:function(a,n){return a+n},woOse:function(a,n){return a>>n},aDYXq:function(a,n){return a&n},kDwAf:function(a,n){return a>>>n},EAGPK:function(a,n){return a<<n},bQxbv:t(1068),miOzp:function(a,n){return a<n},SOKGb:function(a,n){return a>=n},ajPab:function(a,n){return a<=n},EHWyu:function(a,n){return a+n},xocQy:function(a,n){return a>=n},sJgoU:function(a,n){return a<n},zckmQ:function(a,n){return a-n},JYqio:function(a,n){return a<n},fImPn:function(a,n){return a!==n},ricCO:"ZJaXk",zgCfp:"pAnaJ",nIafq:function(a,n){return a&n},xxulT:function(a,n){return a|n},IrkBP:function(a,n){return a>>n},wDiov:function(a,n){return a|n},oJdMQ:function(a,n){return a&n},rMUYE:function(a,n){return a>>n},GWRgF:function(a,n){return a>>n},OmBzk:function(a,n){return a|n},mXuem:function(a,n){return a>>n},sxjnT:function(a,n){return a&n},UsHsM:function(a,n,s){return a(n,s)},lbwFe:"pagehide",aYTqS:t(502),uHaos:t(860),iCfBQ:t(423),oCHcQ:function(a,n){return a<<n},JdaoI:function(a,n){return a&n},UToQy:function(a,n,s){return a(n,s)},PzMkj:t(530),QFpMO:t(398),vTOjB:function(a,n){return a(n)},APFCk:t(1710),AOabq:function(a,n){return a(n)},bSJiG:function(a,n){return a<<n},uYtOO:function(a,n){return a&n},TEUvL:function(a,n){return a&n},nGopD:function(a,n){return a(n)},pPtbh:function(a,n){return a<<n},GuQTj:function(a,n){return a&n},Njhsj:function(a,n){return a&n},upHRJ:t(1020),uUXjk:function(a,n){return a&n},mUssD:function(a,n){return a<<n},uNAHQ:function(a,n){return a&n},MTFZa:function(a,n){return a&n},nOPTX:function(a,n){return a&n},dltQs:function(a,n){return a<<n},gLfHL:function(a,n){return a|n},KTXHU:function(a,n){return a|n},dDeCh:function(a,n){return a>>>n},Mhgei:function(a,n){return a>>>n},HpchR:function(a,n){return a===n},qOcid:function(a,n){return a<n},ITsuU:function(a,n){return a<n},AXJvi:function(a,n){return a<n},VXlyp:function(a,n){return a<n},Gnqqi:function(a,n){return a<n},BttSX:function(a,n){return a>>>n},WuVZF:function(a,n){return a+n},wIINx:function(a,n){return a|n},SxMSv:function(a,n){return a>>>n},YctDH:function(a,n){return a&n},KELrq:function(a,n){return a>>>n},rIGyL:function(a,n){return a>>>n},mQRZO:function(a,n){return a!==n},amOiH:function(a,n){return a>>>n},rDwuz:function(a,n){return a>>>n},FFThM:function(a,n){return a&n},sgppa:function(a,n){return a+n},chmYb:function(a,n){return a|n},fxbbH:function(a,n){return a|n},NRbWM:function(a,n){return a&n},VfwrL:function(a,n){return a|n},nvaca:function(a,n){return a(n)},QCHUk:t(1554),XLkyP:function(a,n){return a|n},xmCRj:function(a,n){return a|n},fMXWB:function(a,n){return a|n},qZFAL:function(a,n){return a|n},VANVS:function(a,n){return a<<n},KwcqO:function(a,n){return a<<n},dmDSZ:function(a,n){return a===n},sMIaV:t(474),GLAzV:t(1461),ugoqc:function(a,n){return a|n},sRroi:function(a,n){return a<<n},dHhqp:function(a,n){return a<<n},wZrGL:function(a,n){return a===n},fIAYh:function(a,n){return a>>>n},tntPo:function(a,n){return a|n},UziPN:function(a,n){return a>>>n},ASyCy:function(a,n){return a<<n},LbQXs:function(a,n){return a<<n},xhWIG:function(a,n){return a>>>n},SBaeo:function(a,n){return a>>>n},CIwSd:function(a,n){return a&n},Awjsx:function(a,n){return a>>>n},NqxmC:function(a,n){return a&n},iEXnK:function(a,n){return a>>>n},gQyLQ:function(a,n){return a|n},aQeQt:function(a,n){return a%n},PPdOY:function(a,n){return a|n},TdWyZ:function(a,n){return a+n},GdCiv:function(a,n){return a>>>n},AqcCk:function(a,n){return a+n},YimqU:function(a,n){return a*n},YZfCz:t(610),BerzS:function(a,n){return a>>>n},KYZRy:function(a,n){return a&n},YjIPL:function(a,n){return a>>>n},AIOGW:function(a,n){return a>>>n},HemsP:function(a,n){return a+n},jrjbc:function(a,n){return a!==n},UyLdD:function(a,n){return a>>>n},LNNsr:function(a,n){return a===n},LZzhX:function(a,n){return a+n},VhfyM:function(a,n){return a&n},vjuyU:function(a,n){return a&n},ZPvZj:function(a,n){return a&n},BQRwK:function(a,n){return a>>>n},RIpGR:function(a,n){return a&n},EyqCV:function(a,n){return a>>>n},adYMy:function(a,n){return a>>>n},qLvza:function(a,n){return a&n},WktQx:function(a,n){return a>>>n},LwiRq:function(a,n){return a>>>n},teTDf:t(1033)+"RROR",NCjtE:t(411)+t(1295),rQQSF:t(399)+t(1051)+"R",VFufs:"MESSAGE_"+t(1355),FxWav:t(302)+"OR",bGiHL:function(a,n){return a===n},opals:t(402),DQpOz:"wPJQK",TtNVW:t(418)+"3",LHipS:t(867),rojJw:"wjuaF",kUJEf:"message",bgUmD:t(964),vodcI:function(a,n){return a===n},FFIiI:"error",NJHfg:function(a,n){return a instanceof n},MzSML:function(a,n){return a+n},QHQkE:t(1604)+t(345),zNPPW:function(a,n){return a+n},IpkvH:t(1035),OUjLX:function(a,n){return a===n},JkiVH:t(280)+t(514),zxbbv:function(a,n){return a===n},tvDCf:t(740),dIaym:function(a,n){return a===n},QJuGE:function(a,n){return a===n},KtDKG:t(1373)+"d",uPmaN:t(749),XFWxs:"XgEAb",itolb:"close",VEdMN:t(447),nIHhA:function(a,n,s){return a(n,s)},aIIOj:function(a,n,s){return a(n,s)},ukVOO:function(a,n,s){return a(n,s)},HlbdA:function(a,n,s){return a(n,s)},iDpan:function(a,n,s){return a(n,s)},ErMGO:t(1345)+"t",TlsGT:"stop imm"+t(1083)+t(373)+"ct",lKdir:t(774),VFLGm:t(1352),DjQit:function(a,n){return a instanceof n},wIomT:t(851),PzDqM:function(a,n){return a||n},vxhdz:function(a,n){return a!=n},ePtnv:t(1508)+t(331)+t(497)+t(1348)+t(1112),VrdvW:t(1321),oPnuz:"vQNIv",QoFuP:function(a,n){return a(n)},LnVJm:function(a,n){return a===n},jOvns:t(732),NMLVa:t(654),RlpkQ:function(a,n){return a<n},fPUmL:function(a,n){return a<n},YPxbp:function(a,n){return a&n},BZRWY:function(a,n){return a===n},nLkul:function(a,n){return a+n},AMmzS:function(a,n){return a!==n},MUafM:t(1518),jBsbm:function(a,n){return a<n},mdYsE:function(a,n){return a>=n},DaIOo:function(a,n){return a<n},exsDQ:function(a,n){return a|n},yEVKQ:function(a,n){return a<<n},qHgYb:function(a,n){return a<<n},srVZY:function(a,n){return a&n},Otijh:function(a,n){return a&n},PGQOl:function(a,n){return a|n},FKBZC:function(a,n){return a<<n},kBKjz:function(a,n){return a&n},nSheO:function(a,n){return a+n},NYPOH:function(a,n){return a&n},Ossuo:function(a,n){return a===n},YSPgD:t(890),bnHtN:function(a,n){return a<n},neQyb:function(a,n){return a&n},PzaXr:function(a,n){return a===n},xUZRA:function(a,n){return a===n},NRSLo:function(a,n){return a&n},IxTTu:function(a,n){return a+n},fQtjE:function(a,n){return a+n},STcID:function(a,n){return a<<n},FdmIr:function(a,n){return a&n},NSMqF:function(a,n){return a&n},faYlW:function(a,n){return a|n},rhWBh:function(a,n){return a>>n},kyIVc:function(a,n){return a|n},ArdAo:function(a,n){return a&n},muXgc:function(a,n){return a|n},OFISq:function(a,n){return a&n},bCPNa:function(a,n){return a(n)},LxJVY:function(a,n,s,d){return a(n,s,d)},escAx:function(a,n){return a instanceof n},lSBGD:t(1151),pHLJC:"string",oEWRj:"application/json",SydJH:function(a,n){return a==n},dmACC:t(1240)+t(1706)+"et=utf-8",hMQaN:"ppe",vtahp:function(a,n){return a-n},tDVhC:function(a,n){return a!==n},dNYWM:t(552),cjiop:function(a,n){return a>=n},BkAEI:"unknown "+t(1656),vfspl:function(a,n){return a*n},wOOGl:function(a,n){return a===n},sAtal:t(1021),QQtoG:function(a,n){return a+n},jGynI:t(997),uOKxd:t(1362)+t(1113)+t(223)+"P",YcwsF:function(a,n){return a(n)},SiJKl:t(1261),LfcSH:t(607),TdiVV:function(a){return a()},cHGzo:function(a,n,s,d){return a(n,s,d)},Rkupl:function(a,n){return a!==n},JpwmB:"Xjenk",xrXrq:function(a,n){return a===n},iMUwI:t(923),wdlNg:t(1743),RKZVN:function(a,n){return a(n)},dlszY:function(a,n){return a!==n},UtqUt:t(894),tauDJ:t(503),BAJhX:function(a,n){return a||n},JbHAL:function(a,n){return a(n)},ckXVV:function(a,n){return a<<n},kwkEY:function(a,n){return a&n},qTOhN:function(a,n){return a&n},UDzbt:function(a,n){return a&n},AasTn:function(a,n){return a<<n},VmeOU:function(a,n){return a&n},FjaAe:"xLFVB",SMYSe:function(a,n){return a||n},KywaL:function(a,n){return a(n)},rKLrT:t(919),sATUl:t(677),Nlrqk:function(a,n){return a||n},jBdhK:function(a,n){return a||n},jbSQc:t(614),xsBnC:function(a,n){return a>>>n},JETmn:function(a,n){return a>n},usZoP:function(a,n){return a&n},eJpMX:function(a,n){return a|n},asSbA:function(a,n){return a!==n},oVigP:t(199),wCOxK:t(1120),RLTDX:"xMWhq",BPUgq:function(a,n){return a||n},feRPZ:function(a,n){return a!=n},bblAL:function(a,n){return a||n},WlKzy:t(1639)+t(1662)+"d",KqVLn:function(a,n,s){return a(n,s)},MJdHu:"qos",pwHYY:function(a,n){return a(n)},zJNzM:function(a,n,s){return a(n,s)},rEDDW:t(624)+t(750)+t(855),BWlvV:t(1705)+t(598),NGCLv:"service",oNNLe:t(747)+"ervice",LSztl:t(324),qOJIC:function(a,n){return a===n},ZDpWY:"yqXYv",JIian:"RmrzP",ivskx:function(a,n){return a===n},SlExW:"AFNuC",mCZXk:t(1129)+"er_qos",utvox:function(a,n,s,d){return a(n,s,d)},Zlkwk:t(1129)+t(1086)+"ck",YEtsL:function(a,n,s,d){return a(n,s,d)},fhSfO:function(a,n,s){return a(n,s)},AofwR:t(1129)+t(304)+"sgid",KeJcU:function(a,n,s,d){return a(n,s,d)},bOXRy:function(a,n,s,d){return a(n,s,d)},tDoMj:t(1077),ZThjU:t(1248),LrIsS:"ack_code",qVaDP:function(a){return a()},PCKPM:function(a,n){return a(n)},curCX:function(a,n){return a<<n},zxhae:function(a,n){return a===n},JhOxg:"TKscQ",iTTYq:t(553),ImTFz:function(a,n){return a(n)},itfgm:function(a,n){return a(n)},QzXmF:function(a,n){return a instanceof n},mmdsb:t(602)+"e",FSVNx:t(981),qxWkB:function(a,n){return a(n)},nFtyM:"ffff",bjkAp:t(1301),xXyQA:function(a,n){return a>n},LAfAf:t(303),qwbEV:t(1401),ANSWB:function(a,n){return a(n)},IaCWd:function(a,n){return a&n},TPJIV:function(a,n){return a+n},Znydv:function(a,n){return a|n},CIEar:function(a,n){return a===n},DEBIs:t(1044),SvsTR:t(1608),nakJe:function(a,n){return a||n},hCzPy:function(a,n){return a>>>n},YRgmI:function(a,n,s){return a(n,s)},RRtTD:t(1307),GlPhJ:"going away, netw"+t(778)+t(1318),XaHxd:t(1572),zBbfs:t(621),tnlzG:function(a,n){return a+n},kNGzj:t(286)+"t of ran"+t(709),OthNl:t(1744),pQZHZ:t(254),jRaED:function(a,n){return a>n},zObia:t(1062)+"too large",whRNm:function(a,n){return a&n},WKgwd:function(a,n){return a+n},fLisP:function(a,n){return a===n},lsvSj:t(1685),TiIbM:function(a,n,s){return a(n,s)},lrOFM:t(390)+"1",NZpGZ:function(a,n){return a+n},gKNmf:function(a,n,s,d){return a(n,s,d)},RScpd:function(a,n){return a+n},degEH:function(a,n,s,d){return a(n,s,d)},PILUM:function(a,n){return a|n},xaxXL:function(a,n){return a+n},BHoeZ:function(a,n){return a<<n},UHcNw:function(a,n){return a+n},sFjco:function(a,n){return a<<n},YASDF:function(a,n){return a+n},FoAkO:function(a,n){return a===n},eYNFk:t(1740),ClJDm:"xyLXp",bHwNu:function(a,n){return a+n},foKOt:function(a,n){return a&n},xfkZJ:function(a,n){return a>>>n},OYODl:function(a,n){return a+n},XDXIh:function(a,n){return a&n},dXQGC:function(a,n){return a+n},ALpEP:function(a,n){return a>>>n},smJKL:function(a,n){return a&n},ofgiq:function(a,n){return a&n},SpjZu:function(a,n){return a(n)},PeULe:function(a,n){return a&n},ghcDE:function(a,n){return a<n},nztAM:function(a,n){return a|n},azfUI:function(a,n){return a>>>n},cuHrh:function(a,n){return a&n},vKGmo:function(a,n){return a<n},hIwwt:function(a,n){return a&n},piAIq:function(a,n){return a<<n},CmAzb:function(a,n){return a|n},HgArc:function(a,n){return a>>>n},Ijcgp:function(a,n){return a|n},VdfPO:function(a,n){return a<<n},ulUzz:function(a,n){return a&n},bKDYE:function(a,n){return a===n},KRbJa:t(1161),UkYmI:function(a,n){return a<<n},IRlll:function(a,n){return a<<n},ZUKIW:function(a,n){return a!==n},yDkSX:t(1268),fVSmQ:function(a,n,s,d){return a(n,s,d)},FfYcs:t(598),fKEmh:function(a,n){return a(n)},dlUmE:t(308)+t(635),DQswH:function(a,n,s){return a(n,s)},JptLQ:function(a,n,s){return a(n,s)},XCUWU:function(a,n,s){return a(n,s)},QGnXV:function(a,n,s,d){return a(n,s,d)},QPTer:t(507)+t(1280),YswCQ:t(1434),LChVh:t(253),sFMgQ:t(1651),zJNns:function(a,n,s){return a(n,s)},pAVZs:function(a,n){return a(n)},wCIbH:function(a,n){return a!==n},vPxni:t(1565),OKvOC:t(743),hMEGr:"setcursor",hzBLH:function(a,n){return a(n)},cjxPG:t(193),YIAWt:function(a,n,s){return a(n,s)},hdNHJ:function(a,n){return a!==n},YXpNb:t(1459),uEFyS:"Zjuqk",TtBRo:function(a,n){return a|n},JNVbt:function(a,n){return a|n},Dzgqa:function(a,n){return a+n},yxnnf:function(a,n){return a<<n},zHMSj:function(a,n){return a+n},FSOud:function(a,n){return a|n},xeQGC:function(a,n){return a+n},xEzGL:function(a,n){return a+n},djqRP:function(a,n){return a+n},fYloO:function(a,n){return a||n},nFkMl:function(a,n){return a===n},wMvuf:t(325),ulOtp:t(1690),NINOp:function(a,n,s,d){return a(n,s,d)},zvSkK:t(1129)+t(1364),igBug:t(1129)+t(369),liPAO:function(a,n,s,d){return a(n,s,d)},kaCLA:t(512)+"s",MZmyR:"x-msg-cursor_name",FHoHt:function(a,n,s){return a(n,s)},khgNX:t(1479)+t(1238)+"ue",BYGEG:function(a,n){return a+n},yNKkf:function(a){return a()},EcFjv:function(a,n){return a<n},sbWhv:function(a){return a()},FOZgN:function(a,n){return a===n},DQTLk:t(1536),wEkMA:function(a){return a()},YLLtb:function(a,n){return a&&n},nnxvN:function(a,n,s){return a(n,s)},LSQou:function(a){return a()},LqadT:function(a,n){return a===n},KIhDO:"TVnei",CHzaO:function(a,n){return a(n)},jeJPm:function(a){return a()},SHjJp:function(a,n,s){return a(n,s)},FVjoP:function(a,n,s){return a(n,s)},ndhre:function(a,n,s,d){return a(n,s,d)},tOCKK:t(377),NhVML:function(a,n,s){return a(n,s)},lnXPp:t(519),chMtn:"ping_once_success",xpPZC:function(a,n,s){return a(n,s)},JzOBF:t(1147)+t(420),FfikM:"pbbp2",vIGVa:function(a,n){return a/n},XsmAG:t(1575),aWUQe:"CONTINUE",PDbWx:t(944)+t(1289)+t(1539),XLJjR:function(a,n){return a===n},VXClE:t(1653),srVBV:t(1104),IOGLU:function(a,n){return a+n},VCgAf:function(a,n){return a+n},CIMyR:function(a,n){return a!==n},OaXGN:t(191),bNXrq:t(928),xWbtg:t(313),pTWtW:t(479),SkeKy:t(599),ZUFiY:"ttwid",xkxBk:t(347)+"d",LIfwj:t(944)+t(1414)+t(335)+t(1694)+t(1737),FCshf:t(913),akNYI:function(a,n,s){return a(n,s)},KEmbv:"fws_1.0.0",ePYvm:"ummHV",gOfOT:function(a,n){return a>n},odPnl:function(a,n){return a-n},ZHLHO:function(a,n,s){return a(n,s)},aCzyh:function(a,n){return a(n)},mHoPm:function(a,n){return a-n},seSEG:function(a,n){return a===n},nEImR:t(290),yPHzx:function(a,n,s){return a(n,s)},bNsfN:function(a,n){return a!==n},xEArq:function(a,n,s){return a(n,s)},DqVhd:t(442)+"e_timeout",gZGlB:t(915),YSxUz:function(a,n){return a instanceof n},lMRVH:t(697)+t(1427)+t(231)+"=utf-8",zTuNg:function(a,n,s,d){return a(n,s,d)},vvAfX:function(a,n){return a===n},BGgUb:t(1006),wvqpo:"going aw"+t(409)+t(1345)+t(1143)+"ver",rKvJP:function(a,n,s,d){return a(n,s,d)},uQfVr:t(444),liulP:t(887),AXRdq:t(1043)+t(626)+t(985)+"g",kApid:function(a,n){return a(n)},lgCrp:function(a,n){return a===n},xiHYG:t(1256)+"4",OOyHU:function(a,n,s){return a(n,s)},JCgBj:function(a,n,s){return a(n,s)},xNDqO:function(a,n,s){return a(n,s)},vqMVd:t(1475),dRtSS:"ack",MbqKd:t(1742),TaKwz:t(561),GyboW:function(a,n){return a!==n},nQOzR:t(1061),uRagu:function(a,n){return a!==n},JUKZX:t(853),anfhz:t(244)+t(729)+t(492)+t(713)+"ed",IYatX:function(a,n){return a===n},jbqJG:t(244)+t(1523)+t(546),LNMTZ:function(a,n,s,d){return a(n,s,d)},OXCrc:function(a,n){return a+n},Cvict:t(944)+t(671)+" valid d"+t(1176)+t(615)+"e a stri"+t(1148)+" arraybu"+t(277),LMQkX:function(a,n){return a!=n},XjDBj:function(a,n){return a instanceof n},UjoZJ:function(a,n){return a(n)},olCQR:function(a,n){return a||n},nDRlT:"please p"+t(671)+t(1189)+t(1494),yhPUi:"sent",zVNyN:"UDIZs",gruFg:function(a,n){return a>>>n},OAkXw:function(a,n){return a&n},RVHXj:function(a,n){return a===n},lqYXG:function(a,n){return a<n},RJfrj:function(a,n){return a===n},ewFvH:t(1076),CNtMi:function(a,n){return a||n},hRxSG:function(a,n){return a==n},sCWXC:function(a,n){return a!==n},pnEqo:t(1018)+"econnect"+t(1528),tNFkX:t(314),aBRuk:"BRWKM",ovJPW:t(1060),mFKIc:t(453),sDHwn:function(a,n){return a===n},dkIoV:function(a,n){return a(n)},mrgVo:t(1397),VDhQg:function(a,n){return a(n)},fjezC:t(1468),RzFWK:function(a,n){return a===n},atXhc:"Window",iZqur:function(a,n){return a!=n},WgGtH:function(a,n){return a!=n},KxLNY:t(1640),Uoiec:function(a,n){return a===n},rQzVS:"Dedicate"+t(1174)+t(628)+"pe",jrQOM:function(a,n){return a===n},IFdnq:function(a,n){return a!=n},rztae:function(a,n){return a===n},oSVCZ:function(a,n){return a===n},MpjsT:"SharedWo"+t(847)+t(1210),KrrcC:function(a,n){return a!=n},DuUek:function(a,n){return a===n},tqwfj:function(a,n){return a!=n},YJQVr:t(1451)+t(539)};It.r(be),It.d(be,{FWS:()=>Ph,CustomErrorEvent:()=>c0,createCloseEvent:()=>st,ReconnectEvent:()=>a0,createErrorEvent:()=>Xe,decodedFrame:()=>Bn,createOpenEvent:()=>h0,CustomCloseEvent:()=>d0,createReconnectEvent:()=>Co,FrontierMessageEvent:()=>u0,encodeFrame:()=>Ge,createMessageEvent:()=>x0,OpenEvent:()=>l0,ErrorCode:()=>Gt,Event:()=>Fn,MessageEvent:()=>f0});let r="";function i(a=""){let n=t,s="02",d=""+Date.now(),l=r||(r=x(a)),h=Math[n(312)]().toString(16)[n(834)](-6);return e[n(1079)](e[n(1195)](s,d)+l,h)}function o(){let a=t;return e.dtpuM(e[a(1422)](1e4,Date[a(549)]()),Math.floor(e.WwMGN(1e4,Math[a(312)]())))}function c(a){let n=t;return e[n(1039)](Array(8)[n(469)]("0"),e[n(1354)](parseInt,a,10)[n(1614)](2)).slice(-8)}function f(a){let n=t;return e[n(359)](Array(4)[n(469)]("0"),parseInt(a,2)[n(1614)](16))[n(834)](-4)}function u(a){let n=t;if(e[n(508)](e[n(1719)],e.WCYWA))return this[n(651)+"ndpointT"+n(1064)+"t"]=1,this[n(1031)+n(1308)]++,this[n(1278)+"s"][this["currentI"+n(1308)]];{let s=a[n(513)](/\./)[n(1328)](h=>c(h)),d=[];return d[0]=f(s[0]+s[1]),d[1]=e.ePJhO(f,e[n(1274)](s[2],s[3])),[e[n(289)],"0000",e[n(289)],e[n(289)],n(1172),n(1004),d[0],d[1]][n(469)]("")}}function x(a){let n=t,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(1638)](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(1638)](a);return s?u(a):d?e[n(1236)](p,a):e[n(971)]}function p(a){let n=t,s={nFrdR:function(T,L){return T>=L}},d="",l=[],h=0,m=0,b=!0,g="0000";if(a[n(1375)]("::")>-1){let T=a.split("::");for(let q=0;e[n(943)](q,T.length);q++){let J=T[q];if(e[n(282)](J[n(1375)](":"),0))if(e.xkpwJ(e.jsqdf,"grQom")){let $=J[n(513)](":");b&&(h=$[n(784)]),m+=$[n(784)];for(let W=0;W<$[n(784)];W++)if(e[n(508)](4,$[W][n(784)])){let ye=g[n(1531)+"g"](0,4-$[W][n(784)]),je=ye.concat($[W]);l[n(1384)](je)}else l[n(1384)]($[W]);b=!1}else return s[n(813)](_0x440d35.offset,_0x29f656[n(1231)]);else{if(J[n(784)]!==4)if(e[n(508)](e[n(229)],"dHnIP")){let $=g[n(1531)+"g"](0,e[n(416)](4,J.length)),W=$[n(311)](J);l[n(1384)](W)}else return e[n(1079)](e[n(1422)](1e4,_0x15abcc[n(549)]()),_0x40b198.floor(e[n(1422)](1e4,_0x4de107[n(312)]())));else l[n(1384)](J);b&&(h+=1),m+=1,b=!1}}let L="";for(let q=0;e[n(1386)](q,e[n(416)](8,m));q++)L=L[n(311)](g);for(let q=0;e[n(1386)](q,l[n(784)]);q++)e[n(888)](q,h)&&(d=d[n(311)](L)),d=d[n(311)](l[q]);return d}{let T=a[n(513)](":");for(let L=0;e[n(1590)](L,T[n(784)]);L++){let q=T[L];if(e[n(508)](4,T[L][n(784)])){let J=g[n(1531)+"g"](0,4-T[L].length),$=J[n(311)](q);d=d.concat($)}else d=d[n(311)](q)}return d}}function _(a,n){let s=t,d={zaDkk:function(m,b){return e[H(332)](m,b)},zJhVy:function(m,b){return e[H(359)](m,b)}},l=a[s(703)];e[s(796)](void 0,l)&&(Y(n,10),e[s(1354)](Ne,n,l));let h=a.value;if(e[s(508)](void 0,h)){if(e[s(888)](s(854),e.xBMnr))return _0x2f66fa[s(407)+"t8"]?_0x475954[s(407)+"t8"](_0x59cb2c,_0x2d7407):_0x537780[_0x2abd79]=d[s(719)](255,_0x4b5f3e),d.zJhVy(_0x3833ba,1);e[s(168)](Y,n,18),e[s(168)](Ne,n,h)}}function y(a){let n=t;if(e.xkpwJ(n(1272),n(273))){let s={};e:for(;!N(a);){let d=e[n(1078)](_e,a);switch(e[n(1315)](d,3)){case 0:break e;case 1:s[n(703)]=we(a,e.mlqxD(_e,a));break;case 2:s[n(1312)]=e[n(1354)](we,a,_e(a));break;default:e[n(1322)](D,a,e[n(376)](7,d))}}if(s[n(703)]===void 0)throw new Error(e[n(510)]);if(e[n(888)](void 0,s.value))throw new Error(n(307)+n(279)+n(1010)+n(1312));return s}else return _0x3fc1ea.log(_0x5e1178),!1}function A(a){let n=t,s=e[n(1073)](C);return e[n(817)](E,a,s),e[n(1236)](B,s)}function E(a,n){let s=t,d=a.SeqID;e[s(508)](void 0,d)&&(Y(n,8),e[s(1354)](ge,n,d));let l=a.LogID;if(e[s(796)](void 0,l)){if(e[s(285)](e[s(1286)],e[s(1158)]))return!!this[s(366)];Y(n,16),ge(n,l)}let h=a[s(1069)];e[s(473)](void 0,h)&&(e[s(1117)](Y,n,24),e[s(1564)](ge,n,e[s(1138)](P,h)));let m=a[s(1613)];e[s(473)](void 0,m)&&(e[s(1455)](Y,n,32),e[s(850)](ge,n,e[s(1138)](P,m)));let b=a[s(893)];if(e.pJIGa(void 0,b))for(let ye of b){Y(n,42);let je=e[s(597)](C);e[s(1671)](_,ye,je),e[s(1671)](Y,n,je.limit),e[s(1354)](it,n,je),e.lSAyb(O,je)}let g=a[s(1166)+s(905)];e[s(796)](void 0,g)&&(e[s(168)](Y,n,50),Ne(n,g));let T=a.payloadType;e[s(1050)](void 0,T)&&(Y(n,58),e[s(724)](Ne,n,T));let L=a[s(696)];e[s(171)](void 0,L)&&(e[s(1671)](Y,n,66),e[s(1276)](Y,n,L[s(784)]),e[s(1276)](fe,n,L));let q=a[s(735)];e[s(796)](void 0,q)&&(e[s(1671)](Y,n,74),e[s(1046)](Ne,n,q));let J=a[s(230)+s(430)];e[s(1091)](void 0,J)&&(e.ddpGu(e[s(769)],s(556))?(Y(n,82),e[s(1317)](Ne,n,J)):(_0x1545c1=_0x1447bd&&e[s(960)](s(313),_0x49b131[s(509)])?s(479):e[s(802)],_0x55b2a3=_0x18a9af.replace(/((^ws)|(^http))((?:[s]*:\/\/))/,""),_0x23fb8a=/^wss(.*:\/\/)/[s(1638)](_0xf9c0d8)?_0xf4aede:""+_0x416b19+_0x560b78));let $=a[s(208)];$!==void 0&&(e.wrtFZ(Y,n,90),Ne(n,$));let W=a.frameType;e[s(796)](void 0,W)&&(e.PzZkm(Y,n,96),e.wrtFZ(ge,n,e[s(408)](P,W)))}function v(a){let n=t;if(e[n(796)](e[n(791)],n(1314)))this[n(1675)+n(1338)]=null;else return e[n(1084)](S,e[n(1138)](z,a))}function S(a){let n=t,s={};e:for(;!e.lSAyb(N,a);){let d=e[n(1236)](_e,a);switch(d>>>3){case 0:break e;case 1:s.SeqID=e[n(604)](Mn,a,!0);break;case 2:s.LogID=Mn(a,!0);break;case 3:s[n(1069)]=e[n(408)](_e,a);break;case 4:s[n(1613)]=e[n(1138)](_e,a);break;case 5:{let l=e.xGkAl(I,a);(s[n(893)]||(s[n(893)]=[])).push(e[n(1236)](y,a)),a[n(1231)]=l;break}case 6:s["payloadE"+n(905)]=we(a,e[n(1138)](_e,a));break;case 7:s[n(1092)+n(1428)]=we(a,e[n(408)](_e,a));break;case 8:s[n(696)]=se(a,e[n(180)](_e,a));break;case 9:s[n(735)]=e.iajfF(we,a,e[n(1534)](_e,a));break;case 10:s[n(230)+n(430)]=e.obShv(we,a,_e(a));break;case 11:s[n(208)]=e[n(1671)](we,a,e.dyFef(_e,a));break;case 12:s.frameType=e[n(1560)](_e,a);break;default:D(a,7&d)}}if(e[n(1350)](void 0,s[n(946)]))throw new Error(e[n(931)]);if(e[n(622)](void 0,s[n(832)]))throw new Error(e.RKsQB);if(e[n(1586)](void 0,s[n(1069)]))throw new Error("Missing required field: service");if(e[n(622)](void 0,s.method))throw new Error(e[n(990)]);return s}function I(a){let n=t,s=e.YZZmx(_e,a),d=a.limit;return a.limit=e[n(1260)](a[n(426)],s),d}function D(a,n){let s=t;switch(n){case 0:for(;128&e[s(1084)](Te,a););break;case 2:e[s(211)](k,a,e[s(945)](_e,a));break;case 5:k(a,4);break;case 1:e[s(1561)](k,a,8);break;default:throw new Error(e[s(1274)](e[s(268)],n))}}function P(a){return a|=0,{low:a,high:a>>31,unsigned:a>=0}}let w=[];function C(){let a=t,n=w[a(484)]();return n?(n[a(426)]=n[a(1231)]=0,n):{bytes:new Uint8Array(64),offset:0,limit:0}}function O(a){let n=t;if(e[n(1746)]!==e.XnMkL)w[n(1384)](a);else return new _0x106fa9(_0x3234a9,{code:_0x1c973a,reason:_0x3b71ed,wasClean:_0x1b1701,willReconnect:_0x345fcc})}function z(a){return{bytes:a,offset:0,limit:a[t(784)]}}function B(a){let n=t,s=a.bytes,d=a[n(1231)];return e[n(1350)](s[n(784)],d)?s:s.subarray(0,d)}function k(a,n){let s=t;if(e.pAczG(e.tlVdG(a[s(426)],n),a[s(1231)]))throw new Error(e.OpeuW);a[s(426)]+=n}function N(a){let n=t;return e[n(326)](a[n(426)],a[n(1231)])}function F(a,n){let s=t,d=a[s(521)],l=a[s(426)],h=a.limit,m=e[s(269)](l,n);if(e[s(1304)](m,d[s(784)])){let b=new Uint8Array(e[s(1096)](2,m));b.set(d),a[s(521)]=b}return a.offset=m,e.uYRRo(m,h)&&(a[s(1231)]=m),l}function K(a,n){let s=t,d=a[s(426)];if(d+n>a[s(1231)])throw new Error(e[s(489)]);return a[s(426)]+=n,d}function se(a,n){let s=t,d=e[s(1322)](K,a,n);return a[s(521)].subarray(d,e[s(1039)](d,n))}function fe(a,n){let s=t,d=F(a,n[s(784)]);a[s(521)][s(554)](n,d)}function we(a,n){let s=t,d={oDDFr:e.ZUObj},l=e.kilGe(K,a,n),h=String[s(266)+s(1025)],m=a[s(521)],b="\uFFFD",g="";for(let T=0;e[s(1590)](T,n);T++){let L=m[e.byPWJ(T,l)],q,J,$,W;e[s(1521)](e[s(1209)](128,L),0)?g+=e[s(400)](h,L):e.XtZOE(e[s(1209)](224,L),192)?e[s(1039)](T,1)>=n?g+=b:(q=m[e[s(297)](e[s(1260)](T,l),1)],e[s(532)](192,q)!==128?g+=b:(W=e[s(673)](e.TzjZc(31&L,6),e[s(1209)](63,q)),e[s(1590)](W,128)?g+=b:(g+=e.sWwmX(h,W),T++))):e[s(1585)](240&L,224)?e[s(326)](T+2,n)?g+=b:(q=m[e[s(665)](e[s(1641)](T,l),1)],J=m[e[s(1079)](T+l,2)],e.cWufn(e[s(1209)](e[s(980)](q,e[s(787)](J,8)),49344),32896)?g+=b:(W=e[s(980)](e[s(460)](e[s(1209)](15,L),12),e[s(1456)](e.TQOuP(63,q),6))|e[s(1139)](63,J),W<2048||e[s(684)](W,55296)&&e.PSUeu(W,57343)?g+=b:(g+=e.ePJhO(h,W),T+=2))):e.IYOpN(e[s(1036)](248,L),240)?e[s(782)](e[s(1247)](T,3),n)?g+=b:(q=m[e[s(772)](T+l,1)],J=m[e[s(458)](T,l)+2],$=m[e[s(1260)](T,l)+3],e[s(1091)](e[s(725)](e[s(980)](q,e[s(367)](J,8))|e.nUtJt($,16),12632256),8421504)?g+=b:(W=e[s(1733)](e[s(673)](e.vAUcm(e[s(1745)](7,L),18),e[s(367)](e.bcFST(63,q),12)),e[s(1036)](63,J)<<6)|e[s(1727)](63,$),e.fMAGl(W,65536)||e[s(1217)](W,1114111)?g+=b:e.xkpwJ(e[s(600)],e.yZsQy)?this[s(1095)][s(1681)]&&_0x53c578[s(1170)].apply(_0x23f4e4,[d.oDDFr,..._0x505cf6]):(W-=65536,g+=e.HSELX(h,e[s(1409)](e[s(481)](W,10),55296),e[s(269)](e[s(753)](1023,W),56320)),T+=3))):g+=b}return g}function Ne(a,n){let s=t,d={HskyM:function(l,h,m){return e[H(657)](l,h,m)},GydEo:function(l,h){return l(h)}};if(e[s(1458)]==="Etffw")jYOgqj[s(374)](_0x4e5b81,_0x5b6fbf,24),jYOgqj[s(374)](_0x117e3e,_0x182a30,jYOgqj.GydEo(_0x2b6bf9,_0x119c88));else{let l=n.length,h=0;for(let g=0;e[s(1114)](g,l);g++){let T=n.charCodeAt(g);e.SOKGb(T,55296)&&e[s(1206)](T,56319)&&e[s(1590)](e[s(1130)](g,1),l)&&(T=e.aLdiF(e[s(1130)](T<<10,n[s(606)+"At"](++g)),56613888)),h+=T<128?1:e.miOzp(T,2048)?2:T<65536?3:4}Y(a,h);let m=e.fwRpv(F,a,h),b=a[s(521)];for(let g=0;g<l;g++){let T=n[s(606)+"At"](g);if(e.xocQy(T,55296)&&T<=56319&&e.sJgoU(e.MQBrN(g,1),l)&&(T=e[s(655)]((T<<10)+n[s(606)+"At"](++g),56613888)),e.JYqio(T,128))b[m++]=T;else if(e[s(1215)](e.ricCO,e.zgCfp))e[s(819)](T,2048)?b[m++]=e.kgICe(e.nIafq(T>>6,31),192):(T<65536?b[m++]=e.xxulT(e[s(699)](T,12)&15,224):(b[m++]=e.wDiov(e[s(1634)](e[s(777)](T,18),7),240),b[m++]=e[s(210)](e[s(532)](e[s(1722)](T,12),63),128)),b[m++]=e[s(1194)](e.mXuem(T,6)&63,128)),b[m++]=e[s(210)](e[s(522)](63,T),128);else{let{value:L,offset:q}=e.fMQBn(_0x4ed97a,_0x55e463,_0x562502);_0x554fae=q,_0x4d835e=e[s(1657)](e.EAGPK(_0x4887f1,8),0),_0x584620+=L}}}}function it(a,n){let s=t,d=e[s(1433)](F,a,n[s(1231)]),l=a[s(521)],h=n[s(521)];for(let m=0,b=n[s(1231)];m<b;m++)l[e.kTmtB(m,d)]=h[m]}function Te(a){let n=t;return a[n(521)][e[n(1561)](K,a,1)]}function Ht(a,n){let s=t,d=F(a,1);a[s(521)][d]=n}function _e(a){let n=t;if(e[n(1215)](e[n(1396)],e.iCfBQ)){let s=0,d=0,l;do l=e.YGhMh(Te,a),e.sJgoU(s,32)&&(d|=e.oCHcQ(e[n(1011)](127,l),s)),s+=7;while(e[n(725)](128,l));return d}else this[n(1134)+"er"]&&_0x1a1f90[n(318)+"entListe"+n(773)](e[n(1618)],this[n(1122)+n(1098)]),this[n(1134)+"er"]&&_0x464b85["removeEv"+n(250)+n(773)](e.aYTqS,this[n(1122)+n(1136)]),this.close()}function Y(a,n){let s=t;for(n>>>=0;n>=128;)e[s(1499)](Ht,a,e[s(1011)](127,n)|128),n>>>=7;Ht(a,n)}function Mn(a,n){let s=t,d={HZrrb:function(g,T){return e.NFSvG(g,T)},RXinm:e[s(306)],XmgPo:e.QFpMO},l=0,h=0,m=0,b;if(b=e[s(499)](Te,a),l=e.hwBcl(127,b),e[s(1209)](128,b)){if(e.dKMez(e.APFCk,s(786)))_0x40a978[s(889)+"d"]&&(this["_navigat"+s(1734)]()&&(!this._ws||this[s(1385)][s(1106)+"te"]!==this[s(355)]||d[s(727)](this[s(1385)][s(1106)+"te"],this[s(411)+"NG"]))&&this[s(1464)+s(239)](),this[s(1134)+"er"]&&_0x4c2ac1.addEventListener(d[s(1175)],this[s(1464)+s(239)]),this._isBrowser&&_0x53eacb[s(668)+s(662)](d.XmgPo,this[s(1464)+s(992)]));else if(b=e.AOabq(Te,a),l|=e[s(460)](e[s(1634)](127,b),7),128&b&&(b=Te(a),l|=e[s(1569)](e[s(873)](127,b),14),e[s(487)](128,b)&&(b=e[s(1689)](Te,a),l|=e[s(1349)](e[s(215)](127,b),21),e.Njhsj(128,b))))if(e[s(1091)](e[s(218)],e[s(218)])){if(this[s(1095)][s(197)+s(762)+"nect"]||this[s(1296)+s(1477)])return;this["_handleR"+s(1118)]()}else b=e[s(499)](Te,a),h=127&b,e[s(332)](128,b)&&(b=e.YjvuG(Te,a),h|=e[s(487)](127,b)<<7,e.uUXjk(128,b)&&(b=Te(a),h|=e.mUssD(e[s(361)](127,b),14),e[s(1115)](128,b)&&(b=e.YjvuG(Te,a),h|=e.TzjZc(127&b,21),e[s(1415)](128,b)&&(b=e.BBYUN(Te,a),m=e[s(1014)](127,b),e.usgdz(128,b)&&(b=Te(a),m|=e[s(1659)](e[s(332)](127,b),7))))))}return{low:e[s(1002)](l,h<<28),high:e[s(814)](e[s(1288)](h,4),e[s(1456)](m,24)),unsigned:n}}function ge(a,n){let s=t,d=n[s(701)]>>>0,l=e[s(1589)](e[s(258)](e[s(1315)](n[s(701)],28),e.oCHcQ(n[s(1731)],4)),0),h=n[s(1731)]>>>24,m=e[s(596)](0,h)?l===0?e.qOcid(d,16384)?e[s(1570)](d,128)?1:2:e[s(1201)](d,2097152)?3:4:e.VXlyp(l,16384)?e[s(812)](l,128)?5:6:l<2097152?7:8:h<128?9:10,b=F(a,m),g=a[s(521)];switch(m){case 10:g[e[s(1260)](b,9)]=e.FzyOM(e[s(573)](h,7),1);case 9:g[e[s(454)](b,8)]=m!==9?e[s(980)](128,h):e[s(361)](127,h);case 8:g[b+7]=m!==8?e[s(468)](e.SxMSv(l,21),128):e[s(1213)](e[s(573)](l,21),127);case 7:g[e[s(937)](b,6)]=m!==7?e.OmBzk(e.KELrq(l,14),128):e[s(1283)](l,14)&127;case 6:g[e.kOlWV(b,5)]=e[s(1155)](6,m)?e[s(1002)](e[s(1589)](l,7),128):e[s(214)](e[s(540)](l,7),127);case 5:g[b+4]=e[s(770)](5,m)?e[s(1733)](128,l):127&l;case 4:g[b+3]=e[s(796)](4,m)?e.gLfHL(e[s(801)](d,21),128):e[s(1555)](e[s(1589)](d,21),127);case 3:g[e.sgppa(b,2)]=e[s(508)](3,m)?e.chmYb(e[s(1315)](d,14),128):d>>>14&127;case 2:g[b+1]=e[s(508)](2,m)?e[s(329)](d>>>7,128):e[s(1557)](e[s(1288)](d,7),127);case 1:g[b]=e[s(171)](1,m)?e[s(754)](128,d):127&d}}function Bn(a){return e[t(1491)](v,a)}function Ge(a){return e[t(517)](A,a)}let r0=65536,jx=e[t(1203)],zn=e[t(1422)](r0,r0),i0=e[t(1096)](zn,zn),s0=e[t(1279)](i0,2),qt=String.prototype.charCodeAt;class oe{constructor(n,s,d){let l=t,h={HOMEn:function(m){return e.geqNQ(m)}};e[l(1140)](e[l(1472)],e[l(1472)])?(this.isLong=!0,this.low=e[l(899)](0,n),this[l(1731)]=e[l(1417)](0,s),this.unsigned=!!d):(ueFfRY[l(711)](_0x27e049),ueFfRY[l(711)](_0x5791fa))}static isLong(n){let s=t;return n&&e.osHvT(!0,n[s(1218)])}static[t(1485)](n,s,d){return new oe(n,s,d)}static[t(842)+"s"](n,s,d){return d?oe.fromBytesLE(n,s):oe[t(842)+"sBE"](n,s)}static[t(842)+t(902)](n,s){let d=t;return new oe(e.fMXWB(e[d(1417)](e[d(1017)](n[0],e[d(1400)](n[1],8)),e[d(227)](n[2],16)),e[d(1456)](n[3],24)),e[d(1733)](e[d(673)](e[d(1390)](n[4],e[d(1569)](n[5],8)),n[6]<<16),e[d(323)](n[7],24)),s)}static[t(842)+t(1239)](n,s){let d=t;return e[d(1672)](e[d(1501)],e[d(679)])?this[d(212)+d(1380)]?.[d(592)+d(1387)+d(298)+"ount"]()||0:new oe(e[d(1137)](e.MlLaw(e[d(787)](n[4],24),e[d(1456)](n[5],16)),n[6]<<8)|n[7],e[d(468)](e[d(329)](e[d(899)](e[d(584)](n[0],24),e.dHhqp(n[1],16)),e[d(367)](n[2],8)),n[3]),s)}static[t(1584)](n){let s=t;return e[s(1559)](n,jx)?o0:new oe(e[s(1343)](e[s(288)](e[s(899)](e[s(1417)](qt[s(1691)](n,0),e[s(1569)](qt[s(1691)](n,1),8)),e[s(217)](qt.call(n,2),16)),e.mUssD(qt[s(1691)](n,3),24)),0),e.UziPN(e[s(1002)](e[s(210)](qt.call(n,4),e.ASyCy(qt[s(1691)](n,5),8)),e.ASyCy(qt[s(1691)](n,6),16))|e[s(1542)](qt[s(1691)](n,7),24),0),!0)}toHash(){let n=t;return String[n(266)+n(1025)](255&this[n(701)],e[n(511)](this.low,8)&255,this.low>>>16&255,e[n(1111)](this[n(701)],24),e[n(1629)](255,this.high),e[n(873)](e[n(422)](this[n(1731)],8),255),e.NqxmC(e[n(1283)](this[n(1731)],16),255),e.iEXnK(this[n(1731)],24))}static[t(825)+"er"](n,s=!0){let d=t;if(e[d(1078)](isNaN,n))return s?Kx:o0;if(s){if(e.GCLtm(n,i0))return $x}else{if(e.PSUeu(n,-s0))return Jx;if(e.DwiaD(n,1)>=s0)return Wx}return oe.fromBits(e[d(1715)](e[d(821)](n,zn),0),e[d(1503)](n/zn,0),s)}[t(1133)](){let n=t;return this[n(1512)]?e[n(1019)](e[n(1422)](this.high>>>0,zn),e[n(836)](this[n(701)],0)):e[n(1277)](e[n(1016)](this[n(1731)],zn),e[n(1111)](this.low,0))}[t(1048)](){let n=t;return e[n(285)](0,this.high)&&this[n(701)]===0}add(n){let s=t,d={YhpqE:function(l,h){return e.PGyvL(l,h)}};if(e[s(1050)](e[s(637)],e[s(637)]))return _0x5b0d34[s(1504)](CWevZh[s(1392)](_0x1843ee,this),_0x10f3e8),_0x51429e(_0x59d58b[s(656)](this));{oe[s(1218)](n)||(n=oe.fromNumber(n));let l=e[s(730)](this[s(1731)],16),h=e[s(300)](65535,this.high),m=this.low>>>16,b=e[s(215)](65535,this[s(701)]),g=n[s(1731)]>>>16,T=e[s(1115)](65535,n[s(1731)]),L=e[s(540)](n.low,16),q=e[s(1014)](65535,n[s(701)]),J=0,$=0,W=0,ye=0;return ye+=e.KPcOl(b,q),W+=e[s(317)](ye,16),ye&=65535,W+=m+L,$+=e.AIOGW(W,16),W&=65535,$+=e[s(1202)](h,T),J+=e.iEXnK($,16),$&=65535,J+=e[s(185)](l,g),J&=65535,oe[s(1485)](e[s(460)](W,16)|ye,e.oCHcQ(J,16)|$,this.unsigned)}}equals(n){let s=t;return oe.isLong(n)||(n=oe.fromNumber(n)),e[s(491)](this[s(1512)],n.unsigned)&&e[s(1559)](e[s(1480)](this[s(1731)],31),1)&&e[s(596)](e.iEXnK(n[s(1731)],31),1)?!1:this[s(1731)]===n[s(1731)]&&e[s(803)](this.low,n[s(701)])}[t(674)](){let n=t;return e[n(285)](-1,this[n(701)])&&e[n(1140)](-1,this.high)?oe[n(1485)](0,0,this.unsigned):e.osHvT(-1,this[n(701)])?oe[n(1485)](0,e[n(665)](this[n(1731)],1),this[n(1512)]):oe[n(1485)](e[n(1416)](this[n(701)],1),this[n(1731)],this[n(1512)])}[t(348)](n){let s=t;return n?this[s(1224)+"E"]():this[s(440)+"E"]()}[t(1224)+"E"](){let n=t,s=this[n(1731)],d=this.low;return[e[n(202)](255,d),e[n(870)](e.fIAYh(d,8),255),e[n(463)](e.KELrq(d,16),255),d>>>24,e[n(463)](255,s),e[n(647)](e[n(1439)](s,8),255),e[n(698)](e[n(1589)](s,16),255),e[n(1288)](s,24)]}toBytesBE(){let n=t,s=this[n(1731)],d=this[n(701)];return[e[n(225)](s,24),e.NqxmC(e[n(589)](s,16),255),e.qYTZJ(e.kDwAf(s,8),255),e[n(1213)](255,s),e[n(1589)](d,24),e[n(1153)](e[n(583)](d,16),255),e[n(300)](e.LwiRq(d,8),255),e[n(332)](255,d)]}}let o0=new oe(0,0,!1),Kx=new oe(0,0,!0),Wx=oe[t(1485)](-1,2147483647,!1),$x=oe.fromBits(-1,-1,!0),Jx=oe[t(1485)](0,-2147483648,!1);var Gt=(function(a){let n=t,s=(n(1535)+"5|0").split("|"),d=0;for(;;){switch(s[d++]){case"0":return a;case"1":a[a[e[n(403)]]=5001]=n(1033)+n(1023);continue;case"2":a[a[e.NCjtE]=5002]=n(411)+n(1295);continue;case"3":a[a[e[n(1032)]]=5003]=e[n(1032)];continue;case"4":a[a[e.VFufs]=5004]=e[n(562)];continue;case"5":a[a[e[n(206)]]=5005]=e.FxWav;continue}break}})({});class Fn{constructor(n){let s=t;this[s(681)]=n,this[s(1127)]=null}}class a0 extends Fn{constructor(n,s){let d=t;super(n),this[d(1012)]=s&&s[d(1012)]||null}}class c0 extends Fn{constructor(n,s){let d=t;if(e[d(259)](e[d(1013)],e.DQpOz)){let l=this[d(366)][d(1365)](this[d(576)]),h=_0x131bf1[d(862)](l||"{}");return _0x5cbc43.keys(h)}else super(n),this.error=s&&s.error||null,this[d(1683)]=s&&s[d(1683)]||0,this[d(364)]=s&&s.filename||"",this[d(228)]=s&&s[d(228)]||0,this[d(1012)]=s&&s[d(1012)]||"",this[d(1690)]=s&&s[d(1690)]||5001}}class d0 extends Fn{constructor(n,s){let d=t,l=e.TtNVW.split("|"),h=0;for(;;){switch(l[h++]){case"0":this[d(1367)]=s&&s[d(1367)]||!1;continue;case"1":this[d(1656)]=s&&s[d(1656)]||"";continue;case"2":super(n);continue;case"3":this[d(846)+d(392)]=s&&s[d(846)+d(392)]||!1;continue;case"4":this[d(1690)]=s&&s[d(1690)]||0;continue}break}}}class f0 extends Fn{constructor(n,s){let d=t;super(n),this.data=s&&s[d(1592)]||null}}class u0 extends f0{constructor(n,s){let d=t;super(n),this[d(1592)]=s&&s[d(1592)]||null,this[d(1012)]=s&&s[d(1012)]||null}}class l0 extends Fn{constructor(n,s){let d=t;super(n),this[d(1592)]=s&&s[d(1592)]||null}}function Xe(a,{message:n,code:s,error:d}){return new c0(a,{message:n,code:s,error:d})}function st(a,{code:n,reason:s,wasClean:d,willReconnect:l}){return new d0(a,{code:n,reason:s,wasClean:d,willReconnect:l})}function x0(a,{data:n,message:s}){return new u0(a,{data:n,message:s})}function h0(a,{data:n}){return new l0(a,{data:n})}function Co(a,{message:n}){return new a0(a,{message:n})}class p0{constructor(n,s){let d=t;this.endpoints=n,this[d(263)+"es"]=s,this.currentIndex=0,this["currentE"+d(841)+d(1064)+"t"]=0}[t(1687)+t(353)+"fig"](){let n=t;e.dmDSZ(e[n(267)],e[n(1353)])?(this[n(1041)]("error",_0xbbc6bf),this.onerror&&this[n(412)](_0x49c2fc)):(this[n(1031)+n(1308)]=0,this["currentE"+n(841)+n(1064)+"t"]=0)}resetTries(){let n=t;this[n(651)+n(841)+n(1064)+"t"]=0}[t(592)+t(1387)+"nt"](){let n=t;if(e.bgUmD===n(964))return this[n(1278)+"s"][this[n(1031)+n(1308)]];this[n(1041)](e[n(998)],_0x3b2187),this[n(1181)+"e"]&&this[n(1181)+"e"](_0x132072)}[t(592)+t(1387)+"ntTriesCount"](){let n=t;return this[n(651)+n(841)+"riesCount"]}["checkRea"+t(201)+"es"](){let n=t;return!!(this[n(1031)+"ndex"]>=this.endpoints[n(784)]||e.dKMez(this[n(1031)+n(1308)],e[n(655)](this[n(1278)+"s"][n(784)],1))&&e.vodcI(this[n(651)+n(841)+n(1064)+"t"],this[n(263)+"es"]))}["checkCur"+t(1631)+t(721)+t(961)+t(1254)](){let n=t;return e[n(960)](this[n(1031)+n(1308)],this.endpoints[n(784)])?!0:e[n(1304)](this[n(651)+n(841)+n(1064)+"t"],this[n(263)+"es"])}["replaceB"+t(1511)+t(1544)+t(1668)+t(588)](){let n=t;return this["currentE"+n(841)+n(1064)+"t"]=1,this["currentI"+n(1308)]++,this[n(1278)+"s"][this["currentI"+n(1308)]]}["getCurre"+t(1387)+"ntAndUpd"+t(518)](){let n=t;return this["currentE"+n(841)+"riesCount"]++,this[n(592)+n(1387)+"nt"]()}}let Un=(e.feRPZ(e[t(1478)],typeof globalThis)&&e[t(1204)](e[t(963)],globalThis[t(1110)+t(1389)][t(598)])||e.KtDKG!=typeof window&&e[t(1356)](e[t(963)],window[t(1110)+t(1389)][t(598)]))&&e[t(219)](e[t(1478)],typeof document),xn=e[t(1469)](e.KtDKG,typeof globalThis)&&(e[t(1616)]===globalThis[t(1110)+t(1389)].name||e[t(1595)](e[t(1457)],globalThis[t(1110)+t(1389)][t(598)]))&&e[t(1478)]!=typeof tt,Cr=(e[t(219)](t(1373)+"d",typeof globalThis)&&e[t(1496)]("Object",globalThis[t(1110)+t(1389)][t(598)])||e.oAsYK(e[t(1478)],typeof globalThis)||e[t(1108)]("undefined",typeof globalThis)&&!!globalThis[t(1471)+"Bridge"])&&e[t(1e3)](e[t(1478)],typeof wx),Rr=e.KtDKG!=typeof globalThis&&(e[t(652)](t(293)+t(1174)+"lobalScope",globalThis[t(1110)+t(1389)].name)||e.oSVCZ(e[t(281)],globalThis[t(1110)+t(1389)].name)||t(918)+t(1226)+"balScope"===globalThis.constructor[t(598)])&&e[t(219)](e[t(1478)],typeof self),Zx=e[t(1146)](e[t(1478)],typeof globalThis)&&e[t(883)](e.KxLNY,globalThis["construc"+t(1389)][t(598)])&&e[t(1108)](e[t(1478)],typeof global)&&e[t(1430)](e[t(1616)],global[t(1110)+t(1389)].name)&&e[t(219)](e[t(1478)],typeof process)&&!!process.version;class Ro{constructor(){let n=t;this[n(257)+"rs"]={}}[t(1041)](n,...s){let d=t,l=this[d(257)+"rs"][n];if(l)l[d(834)]()[d(181)](h=>h.fn[d(1504)](h.ctx,s));else if(e[d(1586)](e[d(515)],n)&&!this[d(412)]){let h=s[d(784)]&&s[0];if(e[d(1208)](h,Error))throw h;let m=new Error(e[d(1679)](e[d(612)],h?e[d(1713)](e[d(1130)](" (",h.message),")"):""));throw m.context=h,h}return this}[t(1243)](n,s){let d=t;if(e[d(563)](e[d(695)],e[d(695)])){if(e[d(441)](void 0,n))this._listeners={};else if(s===void 0)this[d(257)+"rs"][n]=null;else{let l=this[d(257)+"rs"][n];if(l)for(let h=0;h<l.length;)e[d(987)](l[h].fn,s)?l.splice(h,1):++h}return this}else{if(VLahjy.IxdRR(_0x530374,VLahjy[d(1242)]))return _0x113491[d(656)](_0x45da17);if(VLahjy[d(255)](_0x1ef8cf,VLahjy[d(1344)]))return _0x27b30c[d(280)+d(514)]||_0x42c48a.get(_0xbc6112);if(VLahjy[d(888)](_0x490734,d(972)))return _0x22c33e.objectStoreNames[1]?void 0:_0x31f208[d(280)+d(1053)](_0x326501[d(280)+d(514)][0])}}on(n,s,d){let l=t;return(this._listeners[n]||(this[l(257)+"rs"][n]=[]))[l(1384)]({fn:s,ctx:d||this}),this}}class Vx extends Ro{["_formatE"+t(922)+t(1234)](n){let s=t;if(e[s(473)](e.XFWxs,e.XFWxs)){let d={kBest:function(l,h){return l!=h},bVzuo:VLahjy.KtDKG,GxIgw:VLahjy[s(1721)]};_0x11999a.r=l=>{let h=s;d[h(925)](d[h(1495)],typeof _0x24142f)&&_0x2ca738[h(1614)+h(629)]&&_0x195410[h(1316)+h(1516)](l,_0x4295a9[h(1614)+h(629)],{value:d[h(921)]}),_0x142e40[h(1316)+h(1516)](l,"__esModule",{value:!0})}}else return n[s(1173)]||n.errNo?(s(941)+" "+(n[s(1173)]||"")+s(737)+(n[s(579)]||""))[s(1054)]():JSON[s(1601)+"y"](n)}constructor(n,s,d){let l=t;super(),this._socket=null,Cr&&wx[l(1432)+"ocket"]&&(this[l(470)]=wx[l(1432)+l(793)]({url:n,protocols:s,header:d,fail:this[l(979)+l(956)+l(1284)].bind(this),success:this[l(979)+l(566)+l(859)+l(1310)][l(608)](this)})),xn&&tt[l(1432)+l(793)]&&(this[l(470)]=tt[l(1432)+l(793)]({url:n,protocols:s,header:d,fail:this[l(979)+"ocketFai"+l(1284)].bind(this),success:this[l(979)+l(566)+"cessHand"+l(1310)].bind(this)}))}[t(979)+"ocketSuc"+t(859)+"ler"](){let n=t;Promise[n(683)]()[n(785)](()=>{this[n(1658)+"steners"]()})}[t(979)+"ocketFailHandler"](n){let s=t,d={XfeiI:function(l,h,m){return e.wrtFZ(l,h,m)},nFpfx:e[s(515)],CtBcV:e[s(1294)]};Promise[s(683)]()[s(785)](()=>{let l=s,h=d.XfeiI(Xe,l(789),{message:this[l(320)+"rrorMess"+l(1234)](n)});this[l(1041)](d[l(1660)],h);let m=d[l(1097)](st,"close",{reason:this[l(320)+l(922)+l(1234)](n)});this[l(1041)](d[l(559)],m)})}[t(1658)+t(406)](){let n=t,s={MXgOr:e[n(378)],UTOvg:function(d,l,h){return d(l,h)},weCMR:function(d,l,h){return d(l,h)},JLlEy:e.itolb,MkRlT:e[n(998)],pGRTc:function(d,l,h){return e[n(1246)](d,l,h)},tJcLQ:e.FFIiI,XDruE:function(d,l,h){return e[n(848)](d,l,h)}};this._socket[n(271)](d=>{let l=n;this[l(1041)](s[l(1424)],s[l(276)](h0,s.MXgOr,{...d,data:d[l(1173)]||""}))}),this[n(470)][n(1663)](d=>{let l=n;this[l(1041)](l(764),s[l(448)](st,s[l(968)],{...d}))}),this[n(470)].onMessage(d=>{let l=n;this[l(1041)](s[l(1222)],s.pGRTc(x0,s[l(1222)],{...d}))}),this[n(470)][n(1736)](d=>{let l=n;this[l(1041)](s[l(1196)],s[l(953)](Xe,l(789),{...d,message:d[l(1173)]||""}))})}send(n){let s=t,d={tQOFV:function(l,h,m){return e[H(717)](l,h,m)},MdwVX:e.ErMGO,PfwYV:e[s(177)]};if(e.lKdir===e[s(1597)]){this[s(558)+s(1132)+"t"]();let l=d[s(571)](_0xb8a36,d[s(1028)],{message:d[s(1581)]});this["onStopIm"+s(388)+"yReconnect"]&&this[s(1623)+"mediatel"+s(823)+"ct"](l)}else if(e[s(524)](n,Uint8Array)){let l=n.buffer.slice(n[s(1438)+"et"],e.jVLmi(n[s(1454)+"th"],n[s(1438)+"et"]));this[s(470)]&&this._socket[s(501)]({data:l,fail:h=>{let m=s;this.emit(e[m(515)],e[m(1241)](Xe,m(789),{message:this[m(320)+m(922)+"age"](h)}))}})}else this[s(470)]&&this[s(470)][s(501)]({data:n,fail:l=>{let h=s;this[h(1041)](e[h(515)],e.HlbdA(Xe,h(789),{message:this[h(320)+"rrorMess"+h(1234)](l)}))}})}[t(764)](n,s){let d=t;this._socket&&this[d(470)].close({code:n,reason:s})}[t(668)+t(662)](n,s){this.on(n,s)}[t(318)+"entListe"+t(773)](n,s){this[t(1243)](n,s)}get readyState(){return this[t(470)].readyState}get binaryType(){let n=t;return this[n(470)][n(385)+"pe"]}set binaryType(n){}get[t(179)](){let n=t;return this[n(470)][n(179)]}get[t(509)](){let n=t;return e[n(1502)]===n(531)?e[n(408)](_0x53ca05,_0x1e4a11(_0x594f4a)):this[n(470)][n(509)]}get extensions(){let n=t;return this[n(470)][n(1177)+"ns"]}get[t(450)+t(1199)](){return 0}}function Yx(a,n){let s=t;if(n)return new n(a[s(179)],a[s(509)]);if(Cr||xn)return new Vx(a[s(179)],a[s(509)],a[s(893)]);if(e[s(900)](Un,Rr)&&e[s(1038)](e[s(1478)],typeof WebSocket)&&WebSocket)return new WebSocket(a.url,a[s(509)+"s"])}function Xx(a){let n=t,s=(n(658)+"3")[n(513)]("|"),d=0;for(;;){switch(s[d++]){case"0":if(e[n(900)](Un,Rr)&&e[n(1038)](e.KtDKG,typeof WebSocket)&&WebSocket)return!0;continue;case"1":if(a)return!0;continue;case"2":if(xn&&tt["connectS"+n(793)])return!0;continue;case"3":return!1;case"4":if(Cr&&wx.connectSocket)return!0;continue}break}}function g0(a,n,s){let d=t,l={PCnUx:e[d(1545)],PRIrf:function(h,m){return h===m}};if(e[d(1250)]!==e[d(1515)]){let h=-1;async function m(b){let g=d;return b<=h?Promise[g(305)](new Error(l.PCnUx)):(h=b,l[g(1265)](b,s.length)?Promise[g(683)]():s[b][g(608)](a)(n,m[g(608)](null,b+1)))}e[d(949)](m,0)}else try{this[d(1385)]&&this[d(1385)][d(764)](_0x40a668,_0x5c9ce0)}catch{}}function m0(a){let n=t,s={gEefw:function(d,l,h){return e[H(1046)](d,l,h)},SYHZS:e[n(1294)]};if(e[n(242)](e[n(1431)],e[n(1178)])){let d=this._options[n(1345)+n(1372)+n(1622)](_0x21c450,_0x1f65d7);this[n(1180)+n(1500)+n(1591)](s[n(1223)](_0x2a9d2e,s[n(1163)],{code:_0x1a5651,reason:_0x5948a6,wasClean:!0,willReconnect:d})),d&&this[n(1688)]()}else{let d=0,l=0;for(let h=0;e[n(1201)](h,a[n(784)]);++h)l=a[n(606)+"At"](h),e[n(196)](l,128)?d+=1:e[n(733)](l,2048)?d+=2:e[n(987)](e.YPxbp(64512,l),55296)&&e.BZRWY(64512&a[n(606)+"At"](e[n(616)](h,1)),56320)?e[n(1547)](n(718),e.MUafM)?(++h,d+=4):(this[n(771)+"Queue"][n(1384)](_0x2dde52),this[n(404)](n(1462),_0x29a8d4)):d+=3;return d}}function w0(a,n,s){let d=t;if(e[d(264)](e[d(655)](s,n),1))return"";let l="";for(let h=n;h<s;){let m=a[h++];if(e[d(505)](m,127))l+=String["fromChar"+d(1025)](m);else if(e[d(630)](m,192)&&e[d(252)](m,224))l+=String[d(266)+d(1025)](e[d(1115)](31,m)<<6|e.qLvza(63,a[h++]));else if(e[d(630)](m,224)&&e[d(1642)](m,240))l+=String[d(266)+d(1025)](e.exsDQ(e[d(258)](e[d(248)](e[d(463)](15,m),12),e[d(1087)](e[d(354)](63,a[h++]),6)),e[d(1704)](63,a[h++])));else if(m>=240){let b=e[d(655)](e.wDiov(e[d(611)](e.wDiov(e[d(1036)](7,m)<<18,e[d(1602)](e.kBKjz(63,a[h++]),12)),e[d(167)](e[d(354)](63,a[h++]),6)),e[d(214)](63,a[h++])),65536);l+=String[d(266)+d(1025)](e[d(1039)](55296,b>>10)),l+=String[d(266)+d(1025)](e[d(806)](56320,e[d(839)](1023,b)))}}return l}function Do(a,n,s){let d=t,l={OzpyT:function(h,m){return h||m}};if(e[d(495)](d(1192),e[d(586)])){let h=this[d(366)][d(986)+d(1183)](this[d(576)]),m=_0x22921d[d(862)](l[d(435)](h,"{}"));return m[_0x127e11]=void 0,this[d(366)][d(1360)+d(1183)](this._prefix,_0x32e4b7[d(1601)+"y"](m))}else{let h=s,m,b;for(let g=0;e[d(1386)](g,a.length);++g)if(m=a[d(606)+"At"](g),e[d(901)](m,128))n[s++]=m;else if(e[d(1590)](m,2048))n[s++]=e[d(899)](m>>6,192),n[s++]=e[d(788)](63,m)|128;else if(e[d(1610)](e.uNAHQ(64512,m),55296)&&e[d(1633)](e.NRSLo(64512,b=a.charCodeAt(e[d(1247)](g,1))),56320)){let T=(d(1573)+d(736)).split("|"),L=0;for(;;){switch(T[L++]){case"0":m=e.IxTTu(e.fQtjE(65536,e[d(1169)](e.FdmIr(1023,m),10)),e.NSMqF(1023,b));continue;case"1":n[s++]=e[d(1634)](m>>12,63)|128;continue;case"2":n[s++]=e[d(1382)](e.rhWBh(m,18),240);continue;case"3":++g;continue;case"4":n[s++]=e[d(852)](e.ArdAo(63,m),128);continue;case"5":n[s++]=e[d(1137)](e[d(839)](e[d(481)](m,6),63),128);continue}break}}else n[s++]=e[d(1319)](m>>12,224),n[s++]=e[d(258)](e[d(1093)](m>>6,63),128),n[s++]=63&m|128;return s-h}}async function _0(a){let n=t;if(n(1407)==typeof a){let s=new Uint8Array(e[n(1366)](m0,a));return e[n(203)](Do,a,s,0),s}return e.escAx(a,ArrayBuffer)?new Uint8Array(a):new Uint8Array(a[n(1609)],a[n(1438)+"et"],a.byteLength)}function Qx(a){let n=t;if(e[n(1091)](e[n(1698)],"ZRUAY")){let{initReconnectInterval:s,maxReconnectInterval:d,reconnectIntervalGrowFactor:l}=this._options,h=e.YimqU(s,_0x31b968[n(1445)](l,e[n(416)](_0x16c72e,1)));return h>d?d:h}else try{return e.vxhdz(e.pHLJC,typeof a)&&(e.NJHfg(a,ArrayBuffer)||a[n(1609)]&&e[n(524)](a[n(1609)],ArrayBuffer))||e[n(896)]!=typeof a?"":(JSON.parse(a),e[n(1674)])}catch{return e[n(1724)](e[n(896)],typeof a)?e[n(391)]:""}}let eh=(a,n)=>{let s=t;switch(a){case"boe":case e.hMQaN:return{[s(1720)+a]:1,"x-tt-env":n};default:return{}}};class th{constructor(n){let s=t;this[s(984)+s(838)]=n,this[s(618)]=0}[t(209)](){let n=t;if(e[n(1220)](e[n(1252)],n(1429)))this[n(618)]++;else{let s=_0x1ad595[n(1531)+"g"](0,e[n(1371)](4,_0x1d8d56[n(784)])),d=s.concat(_0x1818b9);_0x5a9293[n(1384)](d)}}[t(1309)+t(397)+"nt"](){let n=t;return e[n(1506)](this.count,this[n(984)+n(838)])}[t(405)+t(344)](n=0){let s=t;this["maxLossC"+s(838)]=n,this[s(618)]=0}}async function nh(a){let n=t,s={GvVRI:e[n(368)],MPYAT:function(d,l){return e[n(1277)](d,l)},DUofB:function(d,l){return e[n(730)](d,l)},HdnaW:function(d,l){return e[n(722)](d,l)},bFbyE:function(d,l){return e[n(357)](d,l)},pSLYg:e[n(1205)],ZWBKH:n(1351)+n(653),YdPdu:function(d,l){return e[n(1709)](d,l)},neBEG:e[n(1124)],vqITY:e.uOKxd,eiNWF:function(d,l){return e.YcwsF(d,l)}};return new Promise(d=>{let l=n,h={TkRoP:function(m,b){return s[H(299)](m,b)},YYDxj:function(m,b){return s[H(1402)](m,b)},wMpGM:function(m,b){return s[H(299)](m,b)},gxKmK:function(m,b){return s[H(365)](m,b)}};if(s.bFbyE(l(1021),s[l(443)])){if(!Un)return d("unknown "+l(1656));try{let m=document[l(195)+l(1551)](l(1266));window[l(864)+l(1711)]=b=>{let g=l;document[g(224)][g(1185)+"ild"](m),window[g(864)+g(1711)]=void 0,d(b&&b.msg||s[g(1298)])},m.type=s[l(759)],m[l(632)]=s.YdPdu(a[l(1313)](/^ws/,s[l(982)]),s[l(1391)]);try{document[l(224)][l(1735)+"ild"](m)}catch{document[l(224)][l(1185)+l(1453)](m)}}catch{window[l(864)+l(1711)]=void 0,s.eiNWF(d,s[l(1298)])}}else return this.unsigned?BhilAB.TkRoP(BhilAB[l(1009)](this[l(1731)],0)*_0x18dbd5,this[l(701)]>>>0):BhilAB.wMpGM(BhilAB[l(1324)](this.high,_0x346afe),this[l(701)]>>>0)})}function jt(a,n,s){let d=t;return!!a?.[d(1463)](l=>l[d(703)]===n&&l[d(1312)]===s)}function Hn(a,n){let s=t;return a?.[s(1463)](d=>d[s(703)]===n)?.[s(1312)]}let ko=null;async function rh(){let a=t;return ko||(ko=Promise[a(683)]()[a(785)](It.bind(It,e[a(319)]))),ko}class ih extends Ro{constructor(n,s){let d=t;super(),this._dbName=n,this._keyPath=s,this[d(366)]=void 0,this[d(1675)+"mise"]=null}async openDB(){let n=t;e[n(1617)]===e[n(1617)]?await this[n(1442)]():(this[n(366)]?.[n(764)](),this[n(366)]=void 0)}async[t(1442)](){let n=t,s={yZcTJ:function(d){return e.TdiVV(d)},tJSka:function(d,l,h,m){return e[H(1193)](d,l,h,m)}};if(!this[n(366)]){if(this[n(1675)+"mise"])return this["_initPro"+n(1338)];try{let d=this[n(1549)],l=this[n(660)];this[n(1675)+n(1338)]=(async()=>{let h=n,{openDB:m}=await s.yZcTJ(rh);this[h(366)]=await s.tJSka(m,h(864)+"_"+d,1,{upgrade(b){let g=h;b[g(542)+g(459)+"e"](d,{keyPath:l})}})})(),await this[n(1675)+n(1338)]}catch(d){console[n(1170)](d)}finally{this[n(1675)+n(1338)]=null}}}async[t(656)](n){let s=t;try{if(e[s(1255)](e[s(336)],s(1452)))return await this[s(1442)](),this[s(366)]?.[s(656)](this[s(1549)],n);this.endpoints=_0x49de02,this[s(263)+"es"]=_0xc01f32,this[s(1031)+s(1308)]=0,this[s(651)+s(841)+"riesCount"]=0}catch(d){console.log(d)}}async[t(554)](n,s){let d=t;return await this[d(1442)](),this[d(366)]?.[d(413)](this[d(1549)],n)}async[t(1128)](n){let s=t;try{return await this._init(),this[s(366)]?.delete(this._dbName,n)}catch(d){console[s(1170)](d)}}async[t(433)](){let n=t;try{return await this[n(1442)](),this[n(366)]?.[n(433)](this[n(1549)])}catch(s){console.log(s)}}async keys(){let n=t;return await this[n(1442)](),this[n(366)]?.[n(1489)+"ys"](this[n(1549)])}async getAll(){let n=t;return await this[n(1442)](),this[n(366)]?.[n(818)](this[n(1549)])}async[t(380)](){let n=t;try{this[n(366)]?.[n(764)](),this[n(366)]=void 0}catch(s){if(e.xrXrq(e.iMUwI,e.wdlNg))return _0x20b269(_0x3356b7[n(1504)](_0x195c4b(this),_0xca91fc));console.log(s)}}get isReady(){let n=t;if(e[n(255)]("HyrUP",n(690)))return!!_0x536fd4?.find(s=>s[n(703)]===_0x2badb5&&s.value===_0x22e077);try{return!!this[n(366)]}catch(s){return console[n(1170)](s),!1}}}class sh{constructor(n,s){let d=t;this[d(1576)]=n,this[d(1440)]=s,this._qosDB=localStorage}async openDB(){}get[t(576)](){return t(864)+"_"+this._DBName}async[t(656)](n){let s=t,d=this[s(366)][s(1365)](this[s(576)]);return JSON.parse(d||"{}")[n]}async[t(554)](n,s){let d=t,l=this[d(366)].getItem(this[d(576)]),h=JSON[d(862)](e[d(900)](l,"{}"));return h[s||n[this[d(1440)]]]=n,this._qosDB[d(917)](this[d(576)],JSON[d(1601)+"y"](h)),s||n[this[d(1440)]]}async[t(1128)](n){let s=t,d=this._qosDB[s(1365)](this[s(576)]),l=JSON[s(862)](d||"{}");return l[n]=void 0,this[s(366)][s(917)](this[s(576)],JSON.stringify(l))}async clear(){let n=t;return this._qosDB[n(433)]()}async[t(692)](){let n=t,s=this._qosDB[n(1365)](this._prefix),d=JSON.parse(s||"{}");return Object[n(692)](d)}async[t(818)](){let n=t,s={ObACA:function(d,l){return e.RKZVN(d,l)},OEQaw:function(d,l){return e[H(1689)](d,l)},PwBPW:function(d,l){return e[H(1560)](d,l)},JthzQ:e.FFIiI};if(e.dlszY(e[n(1447)],e[n(776)])){let d=this._qosDB[n(1365)](this[n(576)]),l=JSON.parse(e.BAJhX(d,"{}"));return Object[n(1487)](l)}else{let d={bUqyx:n(1332),htaSK:AiMmDf[n(1267)]},l=()=>{let b=n;_0x575740["removeEv"+b(250)+b(773)](d.bUqyx,h),_0x4e4415[b(318)+b(250)+b(773)](d[b(493)],m)},h=()=>{let b=n;AiMmDf[b(1537)](_0x514f17,AiMmDf[b(333)](_0x5358f8,_0xd522a5[b(1377)])),l()},m=()=>{let b=n;AiMmDf[b(1481)](_0x57ca07,_0x210f17[b(789)]),l()};_0xa97fdf[n(668)+n(662)](n(1332),h),_0x10e3d7[n(668)+n(662)](AiMmDf[n(1267)],m)}}[t(380)](){return Promise[t(683)]()}get[t(627)](){return!!this[t(366)]}}class oh{constructor(n,s){let d=t;this[d(1576)]=n,this[d(1440)]=s,this._qosDB=xn?tt:Cr?wx:null}async openDB(){}get _prefix(){return"frontier_"+this[t(1576)]}async[t(656)](n){let s=t,d=this[s(366)][s(986)+"geSync"](this[s(576)]);return JSON[s(862)](d||"{}")[n]}async[t(554)](n,s){let d=t;if(e.FjaAe===d(1290))_0x5ea38e=e[d(322)](_0x3a2a48,_0x1bed28),_0x54a309|=e.ckXVV(e[d(642)](127,_0x540b9e),21),e.qTOhN(128,_0x4674e2)&&(_0x51c1ef=e[d(180)](_0x579f32,_0x205584),_0x22bfb5=e[d(1704)](127,_0x1ae753),e[d(822)](128,_0x49fc28)&&(_0x3c12ce=_0x5bfef1(_0x3f1ed3),_0x566bd8|=e[d(198)](e[d(237)](127,_0x33882e),7)));else{let l=this[d(366)][d(986)+d(1183)](this._prefix),h=JSON[d(862)](e[d(672)](l,"{}"));return h[s||n[this._pathKey]]=n,this._qosDB[d(1360)+d(1183)](this._prefix,JSON.stringify(h)),s||n[this[d(1440)]]}}async del(n){let s=t,d={JrpIr:function(l,h){return l+h},sKZws:function(l,h){return e.KywaL(l,h)},JdcSy:function(l,h,m){return l(h,m)}};if(e.rKLrT!==e[s(1263)]){let l=this[s(366)][s(986)+"geSync"](this[s(576)]),h=JSON[s(862)](e[s(672)](l,"{}"));return h[n]=void 0,this[s(366)][s(1360)+s(1183)](this[s(576)],JSON[s(1601)+"y"](h))}else return HqkuOq[s(1466)](HqkuOq[s(731)](_0x126414,8).join("0"),HqkuOq[s(1099)](_0x69c8a8,_0x2e768e,10)[s(1614)](2)).slice(-8)}async[t(433)](){let n=t;return this._qosDB[n(1327)+n(337)]()}async[t(692)](){let n=t,s=this[n(366)][n(986)+n(929)+"nc"](this[n(576)]),d=JSON[n(862)](e.Nlrqk(s,"{}"));return Object[n(692)](d)}async[t(818)](){let n=t,s=this._qosDB["getStora"+n(929)+"nc"](this._prefix),d=JSON[n(862)](e[n(1520)](s,"{}"));return Object.values(d)}closeDB(){let n=t,s={cIzom:function(d,l,h){return e[H(817)](d,l,h)},OxPYU:n(1345)+"t"};if(e[n(1701)]!==e[n(1701)]){let d=s.cIzom(_0x544a47,s[n(678)],{message:n(194)});this[n(1667)+n(1118)]&&this[n(1667)+n(1118)](d)}else return Promise[n(683)]()}get[t(627)](){let n=t,s={GKKhY:function(d,l){return d>l},bNumu:function(d,l){return e[H(322)](d,l)},ASDYp:function(d,l){return e[H(1152)](d,l)},kvCSc:function(d,l){return e.SjBJM(d,l)},RSHwP:function(d,l){return e[H(1394)](d,l)},oUEPB:function(d,l){return d+l},vSyVa:function(d,l){return e[H(434)](d,l)}};if(e[n(798)](e.oVigP,n(199))){let d=_0x65c7c2||8192,l=e[n(560)](d,1),h=null,m=d;return function(b){let g=n;if(b<1||s[g(352)](b,l))return s[g(205)](_0x4fc8a0,b);s[g(1197)](s[g(1725)](m,b),d)&&(h=s[g(205)](_0x1a040c,d),m=0);let T=_0xd7c843[g(1691)](h,m,m+=b);return s[g(261)](7,m)&&(m=s.oUEPB(s[g(1281)](7,m),1)),T}}else return!!this[n(366)]}}function y0(a,n){let s=t;if(e[s(555)]===e.RLTDX)return this._qosDB[s(433)]();if(e[s(1520)](xn,xn))return new oh(a,n);if(e[s(393)](Un,Rr)&&e[s(1e3)](e[s(1478)],typeof indexedDB))return new ih(a,n);if(e[s(710)](Un,Rr)&&e[s(1e3)](e[s(1478)],typeof localStorage))return new sh(a,n);throw new Error(e[s(462)])}class ah{constructor(){let n=t;this["_interva"+n(1615)+"Id"]=null,this._interval=36e5,this[n(366)]=e[n(338)](y0,e[n(464)],n(619)+"id")}async[t(775)+"lFlush"](){let n=t;e[n(1074)](clearInterval,this[n(775)+n(1615)+"Id"]),this[n(775)+n(1615)+"Id"]=e[n(340)](setInterval,()=>{this.flushExpired()},this[n(775)+"l"])}async[t(920)](){let n=t,s={YqkZI:e[n(1509)],Dgrip:e[n(541)],eSxjx:e[n(930)],ZDRDx:n(598),Pnsed:function(d,l,h,m){return d(l,h,m)},QKJsm:function(d,l,h,m){return e[n(1193)](d,l,h,m)},uUAaP:n(1268),vaCwW:function(d,l,h,m){return e.cHGzo(d,l,h,m)},WQNlh:e[n(1474)],dbeTQ:e[n(757)],dMPCn:function(d,l){return d(l)},JyUPt:"cursor_f"+n(635)};if(e[n(172)](e[n(932)],e[n(1703)])){let[d,l]=s[n(265)](_0x43533f,_0xf0368d),h=_0x4ddce0(d),m=0;return _0x37d998[n(181)](b=>{let g=n,T=s[g(1055)][g(513)]("|"),L=0;for(;;){switch(T[L++]){case"0":_0xcb12d1[g(1170)](s[g(520)],m);continue;case"1":_0x45cf0e[g(1170)](s[g(734)],m);continue;case"2":_0x45c653[g(1170)](s.ZDRDx,m);continue;case"3":m=s.Pnsed(_0x58bc4f,b[g(884)+g(797)],h,m);continue;case"4":m=s[g(996)](_0x4cf5f8,l[b[g(884)+g(797)]],h,m);continue;case"5":m=_0xfbb9a4(0,h,m);continue;case"6":_0x553b77[g(1170)](s[g(605)],m);continue;case"7":m=s.vaCwW(_0xcebae2,h,m,b[g(1069)]||0);continue;case"8":_0x43348c.log(s[g(1490)],b,b[g(1069)]);continue;case"9":_0xd3385b.log(s[g(590)],m);continue;case"10":m=s[g(192)](_0x53e338,_0x44c7d8[g(825)+"er"](b[g(1596)]||_0x2c1b14),h,m);continue}break}}),{frameType:_0x3901e8,headers:[{key:s.JyUPt,value:_0x7e7541}],payload:h}}else await this[n(366)][n(920)]()[n(785)](()=>{let d=n;this[d(775)+d(688)]()})}async[t(247)+t(1029)](){let n=t;(await this[n(366)]?.[n(818)]()||[]).filter(({timestamp:l})=>l<Date.now())[n(181)](l=>{let h=n;this._qosDB?.[h(1128)](l[h(619)+"id"])})}async[t(1128)](n){let s=t;return this[s(366)]?.[s(1128)](n)}async[t(554)](n,s){let d=t;return this[d(366)]?.[d(554)]({message_id:n,timestamp:s})}async[t(656)](n){let s=t;return this[s(366)]?.[s(656)](n)}async[t(380)](){let n=t;if(e[n(1358)](n(379),e[n(1600)]))return!0;clearInterval(this[n(775)+n(1615)+"Id"]),await this[n(366)]?.[n(380)]()}get[t(627)](){let n=t;return this[n(366)]?.[n(627)]}}function Oo(a){let n=t,s={dBraK:function(d,l){return e[H(994)](d,l)},LBCAZ:function(d,l){return e.bCPNa(d,l)}};if(e.wOOGl("IbIjh",n(384)))return function(...d){let l=n;return _0xaea70f[l(1504)](VoyhIX[l(591)](_0x433d92,this),d),VoyhIX[l(991)](_0x59ea30,_0x3c76a1[l(656)](this))};{let d=!!this[n(1095)].enableQoS;if(!d)return{enabled:d,isQoSMessage:!1,isQoSAck:!1,isAckCleanupMessage:!1,ackMsgIds:[]};let l=jt(a[n(1012)][n(893)],e[n(1334)],"2"),h=l&&e[n(437)](jt,a[n(1012)][n(893)],e[n(1049)],"1"),m=l&&e.YEtsL(jt,a[n(1012)][n(893)],n(1129)+n(249)+"k","1"),b=m?e[n(321)](Hn,a[n(1012)][n(893)],e[n(1655)])?.split(",")[n(1379)](Boolean)||[]:[];return{enabled:d,isQoSMessage:l,isQoSAck:h,isAckCleanupMessage:m,ackMsgIds:b}}}async function E0(){let a=t;return this[a(396)+"ger"]||(this[a(396)+a(1300)]=new ah),this[a(396)+"ger"][a(627)]||await this[a(396)+a(1300)][a(920)](),this[a(396)+a(1300)]}async function ch(a,n){let s=t,{enableAutoAck:d}=this[s(1095)],l=e[s(1748)](jt,a[s(1012)].headers,"need_ack","1"),h=e.bOXRy(jt,a[s(1012)][s(893)],e.tDoMj,"1"),m=Oo.call(this,a);if(d&&l){let{SeqID:b,LogID:g,service:T,LogIDNew:L,method:q}=a.message;this[s(570)]({SeqID:b,LogID:g,LogIDNew:L,service:T,method:q,headers:[{key:s(1077),value:"1"},{key:e[s(1723)],value:e.BPUgq(L,"")},{key:e.LrIsS,value:"0"}]})}h&&!m[s(190)]&&this["_dispatc"+s(1141)+s(1465)](a),e[s(999)](n)}async function dh(a,n){let s=t;if(e[s(1473)](s(1680),e[s(1708)])){let d=0,l=0,h;do h=e[s(970)](_0x4319bd,_0x5ace7b),e[s(1570)](d,32)&&(l|=e[s(567)](e[s(877)](127,h),d)),d+=7;while(e[s(877)](128,h));return l}else this[s(404)](e[s(427)],a[s(1012)]),e[s(466)](n)}async function fh(a,n){let s=t,d=e[s(910)](Bn,await e.itfgm(_0,a[s(1592)]));try{if(d[s(696)]instanceof Uint8Array){let l=e[s(371)](this._options[s(1166)+s(905)],Object)?{force:!!this[s(1095)][s(1166)+"ncoding"][s(439)],encoding:this[s(1095)]["payloadE"+s(905)][s(967)]?this._options[s(1166)+s(905)][s(967)][s(1313)](/\s/g,"")[s(1191)+s(535)]():""}:{force:!1,encoding:this._options[s(1166)+"ncoding"]?this[s(1095)][s(1166)+s(905)][s(1313)](/\s/g,"")[s(1191)+s(535)]():""},h=d.payloadEncoding?d[s(1166)+"ncoding"][s(1313)](/\s/g,"")[s(1191)+s(535)]():"",m=e.QzXmF(this[s(1095)][s(1092)+"ype"],Object)?{force:!!this[s(1095)][s(1092)+"ype"][s(439)],type:this[s(1095)][s(1092)+s(1428)][s(681)]?this._options["payloadT"+s(1428)].type[s(1313)](/\s/g,"")[s(1191)+s(535)]():""}:{force:!1,type:this._options["payloadT"+s(1428)]?this._options[s(1092)+s(1428)].replace(/\s/g,"")["toLowerC"+s(535)]():""},b=d[s(1092)+"ype"]?d[s(1092)+s(1428)][s(1313)](/\s/g,"")[s(1191)+s(535)]():"",g=m.force?m.type:b||m.type,T=l[s(439)]?l.encoding:h||l[s(967)],L=[e[s(391)],e.oEWRj,s(697)+"ion/json;charset=utf-8",e[s(896)]],q=[e[s(1383)],e[s(1359)]];this[s(1095)][s(1357)+"ansformT"+s(504)+"ad"]&&L[s(578)](g)&&(!T||q[s(578)](T))?d["textPayl"+s(1107)]=e[s(1748)](w0,d[s(696)],0,d[s(696)][s(1454)+"th"]):d[s(1188)+s(1107)]=""}else d["textPayl"+s(1107)]=""}catch(l){d[s(1188)+s(1107)]="",console[s(1170)](l)}a[s(1012)]=d,e.geqNQ(n)}function uh(a,n,s){let d=t,l={ceTNb:function(h,m){return e.QzXmF(h,m)}};if(!e[d(634)](e[d(1090)],e[d(816)])){let h=e.nakJe(s,8192),m=e[d(485)](h,1),b=null,g=h;return function(T){let L=d,q={VAbpi:function(J,$){return e[H(911)](J,$)},viNuJ:function(J,$){return J+$},BQsmw:e.qfbLD,xePdJ:e[L(1326)]};if(e[L(663)]===e[L(663)]){if(e[L(234)](T,1)||e[L(1229)](T,m))return e[L(1138)](a,T);if(e[L(1416)](g,T)>h)if(e[L(1255)](e[L(758)],e[L(856)]))b=e.ANSWB(a,h),g=0;else{let $=_0x47dc15[L(513)](/\./)[L(1328)](je=>_0x575a77(je)),W=[];return W[0]=jrmJZy[L(807)](_0x2bb121,jrmJZy[L(1580)]($[0],$[1])),W[1]=_0x1a0bbc(jrmJZy[L(1580)]($[2],$[3])),["0000",jrmJZy[L(1101)],jrmJZy[L(1101)],jrmJZy[L(1101)],jrmJZy[L(1101)],jrmJZy[L(783)],W[0],W[1]].join("")}let J=n[L(1691)](b,g,g+=T);return e[L(595)](7,g)&&(g=e[L(350)](e[L(262)](7,g),1)),J}else dmkQrE.ceTNb(_0x388083,_0x5adaa1)&&_0x14fcb1[L(554)](_0x143f68,_0x3ca22c)}}}let lh=4294967295;function xh(a,n,s){let d=t,l={FlRta:function(h,m,b){return e[H(667)](h,m,b)},QJfNB:e[d(1294)],Ccxse:e[d(506)],JzmTo:e.GlPhJ};if(e[d(1091)](e[d(858)],e[d(957)]))return e.QoFuP(RangeError,e[d(1416)](e[d(1574)](e[d(1274)](e[d(680)],a)+e[d(720)],e.BPUgq(n,1))+e.pQZHZ,s));if(this[d(1007)+d(370)](),this[d(1103)+d(617)](),this[d(496)+d(343)+"rs"](),this["_wsInsta"+d(751)](1e3,_0x4615e2),this["_connect"+d(1329)]=!1,_0x1ffdac&&this[d(387)+d(1734)]()&&!this["_readyCl"+d(1477)]){if(this[d(212)+d(1380)]?.[d(1309)+d(201)+"es"]()){let m=this[d(212)+"tManager"]?.[d(592)+d(1387)+"nt"]();this[d(1180)+d(1500)+d(1591)](l[d(1412)](_0x498a2f,l[d(938)],{code:1006,reason:d(256)+m+(d(527)+d(1522)+d(827)+d(1368)),wasClean:!0}))}else{let m=this[d(1095)]["reconnec"+d(1372)+"ptor"](_0x54f4f4,_0x28a84e);this[d(1180)+d(1500)+d(1591)](_0x589772(l[d(938)],{code:_0x513e3e,reason:_0x25b641,wasClean:!0,willReconnect:m})),m&&this[d(1688)]()}return}this[d(387)+d(1734)]()||this["_readyCl"+d(1477)]?this[d(1180)+d(1500)+d(1591)](_0xa852ae(d(764),{code:_0x9ba363,reason:l[d(939)]})):this[d(1180)+d(1500)+d(1591)](l[d(1412)](_0x9047a2,l[d(938)],{code:1006,reason:l[d(1293)]})),this[d(1385)]=null,this[d(212)+d(1380)]?.["resetEnd"+d(353)+"fig"](),this["_pingLos"+d(1164)]?.[d(405)+"nter"]()}function hh(a,n,s){let d=t;if(e[d(1271)](s,lh))throw new Error(e[d(1483)]);let l=3;for(;l>=0;){let h=e[d(700)](255,s);e[d(954)](Lo,h,a,n+l),s>>>=8,l--}return e[d(1637)](n,4)}function ph(a,n){let s=t,d={SJcLQ:function(l,h){return l!==h},noCEB:function(l,h){return e[H(283)](l,h)},Ymyxh:function(l,h){return e[H(255)](l,h)}};if(e.fLisP(e[s(1167)],s(1685))){let l=0,h=n,m=e[s(1195)](n,4);for(;h<m;){let{value:b,offset:g}=e[s(965)](Po,a,h);h=g,l=e.HMCEf(e.oCHcQ(l,8),0),l+=b}return{value:l,offset:m}}else return _0x3a50f5[s(1218)](_0x4e564c)||(_0x565f7b=_0x5e4bac[s(825)+"er"](_0x16a118)),fSvOmZ[s(820)](this.unsigned,_0x13353b.unsigned)&&fSvOmZ[s(274)](this.high,31)===1&&fSvOmZ[s(1726)](fSvOmZ[s(274)](_0x4e8eb4[s(1731)],31),1)?!1:fSvOmZ.Ymyxh(this[s(1731)],_0x233787[s(1731)])&&this.low===_0x324a73[s(701)]}function gh(a,n,s){let d=t,l=e.lrOFM[d(513)]("|"),h=0;for(;;){switch(l[h++]){case"0":if(n[d(1647)+"e"])return e[d(565)](n.utf8Write(a,s),s);continue;case"1":return e[d(1277)](e[d(424)](Do,a,n,s),s);case"2":if(n[d(966)])return e[d(1258)](n[d(966)](a,s),s);continue;case"3":if(!a)return s;continue;case"4":if(e[d(812)](a[d(784)],40))return e[d(472)](Do,a,n,s)+s;continue}break}}function mh(a,n){let s=t,d=new oe(e[s(790)](e[s(1382)](e[s(1087)](a[n+4],24),a[e[s(1695)](n,5)]<<16),e[s(358)](a[n+6],8))|a[e[s(1019)](n,7)],e[s(611)](e[s(434)](e[s(1349)](a[e[s(1587)](n,0)],24),a[e.nSheO(n,1)]<<16)|e[s(1728)](a[e[s(1676)](n,2)],8),a[e.LZzhX(n,3)]),!0);return n+=8,{value:d,offset:n+8}}function wh(a,n,s){let d=t;if(e[d(1369)](e[d(1413)],e[d(669)]))this[d(775)+"lFlush"]();else{let l=a.low,h=a[d(1731)];return n[s]=e.BQRwK(h,24),n[e.bHwNu(s,1)]=e[d(477)](e.xfkZJ(h,16),255),n[e[d(650)](s,2)]=e[d(487)](h>>>8,255),n[s+3]=e[d(1339)](255,h),n[e.dXQGC(s,4)]=e[d(1037)](l,24),n[e.NZpGZ(s,5)]=e[d(1184)](l>>>16,255),n[e[d(1260)](s,6)]=e.ZPvZj(e.SxMSv(l,8),255),n[s+7]=e.NYPOH(255,l),s+=8,s}}function Po(a,n){let s=t;return a[s(425)+"8"]?{value:a[s(425)+"8"](n),offset:e.HemsP(n,1)}:{value:e.ofgiq(255,a[n]),offset:e[s(1574)](n,1)}}function Lo(a,n,s){let d=t;return n[d(407)+"t8"]?n[d(407)+"t8"](a,s):n[s]=e.NRbWM(255,a),e.sgppa(s,1)}let _h=function(a){return new Uint8Array(a)},yh=e[t(974)](t(1373)+"d",typeof Buffer)?Buffer[t(1530)+"afe"]:e.gBKLy(uh,_h,Uint8Array[t(1476)+"e"][t(969)]);(()=>{let a=t,n={vHJpi:function(s,d){return s|d},rjZLh:function(s,d){return s|d},HaDik:function(s,d){return e[H(1519)](s,d)},FXJSA:function(s,d){return e[H(1503)](s,d)},voDlx:function(s,d){return e[H(1259)](s,d)}};if(e[a(1593)]("zDGdC",a(952)))return new _0x39e4b0(MkWJMz[a(568)](MkWJMz[a(568)](MkWJMz[a(1403)](MkWJMz[a(351)](_0x425d49[4],24),_0x110e7a[5]<<16),_0x59498d[6]<<8),_0x30a481[7]),MkWJMz[a(568)](MkWJMz[a(1269)](MkWJMz[a(1269)](MkWJMz[a(639)](_0x4f72b2[0],24),MkWJMz[a(351)](_0x43e84f[1],16)),_0x5f2c9d[2]<<8),_0x472f1a[3]),_0x5aca76);{let s=4294967295;return function(d,l,h=!0){let m=a,b={BZCDl:function(g,T){return e[H(1100)](g,T)},vAEqc:function(g){return e[H(597)](g)}};if(s=e[m(1221)](127,d[l])>>>0,e.ghcDE(d[l++],128))return{value:h?s:e.nztAM(0,s),offset:l};if(s=e[m(309)](e[m(1503)](s,e[m(217)](e.cuHrh(127,d[l]),7)),0),e[m(712)](d[l++],128))return{value:h?s:e[m(809)](0,s),offset:l};if(s=e.GdCiv(e.Znydv(s,e.hIwwt(127,d[l])<<14),0),d[l++]<128)return{value:h?s:0|s,offset:l};if(s=e[m(540)](e[m(980)](s,e[m(339)](e.hwBcl(127,d[l]),21)),0),e[m(196)](d[l++],128))return{value:h?s:e[m(550)](0,s),offset:l};if(s=e[m(993)](e[m(1251)](s,e.VdfPO(e[m(844)](15,d[l]),28)),0),d[l++]<128)return{value:h?s:e.Znydv(0,s),offset:l};if(e[m(1271)](l+=5,d.length))if(e[m(1665)](e[m(457)],m(1628)))AwTxwr[m(175)](_0x385df7,_0xa13284.error),AwTxwr[m(476)](_0x560124);else throw l=d[m(784)],xh(l,10,d[m(784)]);return{value:h?s:e[m(210)](0,s),offset:l}}}})();let Eh=16,No=32;function bh(a){let n=t,s=0,d={};for(let l=0;e[n(1590)](l,a[n(784)]);l++)d[a[l][n(884)+n(797)]]=m0(a[l][n(884)+"ame"]),s+=14+d[a[l][n(884)+"ame"]];return[s,d]}function b0(a,n,s){let d=t,[l,h]=e[d(1074)](bh,a),m=e[d(1645)](yh,l),b=0;return a[d(181)](g=>{let T=d;console[T(1170)]("cursor.s"+T(1494),g,g.service),b=e[T(666)](Lo,0,m,b),console[T(1170)](e[T(526)],b),b=e[T(1193)](hh,m,b,g[T(1069)]||0),console.log(T(1069),b),b=e[T(1030)](Lo,h[g[T(884)+"ame"]],m,b),console[T(1170)](T(1705)+T(598),b),b=e[T(472)](gh,g[T(884)+T(797)],m,b),console[T(1170)](e[T(243)],b),b=e[T(437)](wh,oe[T(825)+"er"](g[T(1596)]||n),m,b),console.log(e[T(757)],b)}),{frameType:No,headers:[{key:e[d(1227)],value:s}],payload:m}}function vh(a){let n=t,s=0,d=[];for(;e[n(1570)](s,a[n(1454)+"th"]);){let{offset:l}=e[n(189)](Po,a,s);s=l;let h={cursor_name:"",cursor:0,service:0},{value:m,offset:b}=e[n(1577)](ph,a,s);h.service=m,s=b;let{value:g,offset:T}=e[n(745)](Po,a,s);s=T,h[n(884)+n(797)]=e[n(1425)](w0,a,s,e.MzSML(s,g)),s+=g;let{value:L,offset:q}=e.fMQBn(mh,a,s);h[n(1596)]=L[n(1133)](),s=q,d[n(1384)](h)}return d}function Sh(){let a=t;return{frameType:No,headers:[{key:a(308)+a(635),value:e[a(544)]}],payload:void 0}}class Ih{constructor(n,s,d){let l=t;this[l(1135)+l(746)]=n,this[l(480)+l(1306)]=s,this._messageStrategy=d,this[l(366)]=y0(this["_cursorN"+l(746)],l(884)+l(797))}async[t(920)](){let n=t;await this._qosDB[n(920)]()}async[t(863)+"rs"](){let n=t;if(!this[n(366)][n(627)])return;let s=this[n(771)+n(1126)],d=await this[n(366)][n(818)]();switch(console[n(1170)]("allCurso"+n(760),d),s){case e[n(226)]:return d&&d[n(784)]?e[n(954)](b0,d,0,this[n(480)+"ileName"]):void 0;case e[n(1233)]:return;case"CONTINUE":return d&&d[n(784)]?e[n(954)](b0,d,0,this[n(480)+n(1306)]):e.geqNQ(Sh)}}async set(n,s,d){let l=t;return console[l(1170)](e[l(1320)],n,s,d),this[l(366)].set({cursor_name:n,cursor:s,service:d})}async setCursors(n){let s=t,d={CYpLN:function(h,m,b){return e.zJNns(h,m,b)},QCrMR:function(h,m,b){return e[H(1499)](h,m,b)}},l=e[s(927)](vh,n);for(let h of l)e.wCIbH(e[s(1198)],e[s(933)])?(console[s(1170)](e[s(866)],l),await this[s(366)][s(554)](h)):(ehTYZx[s(1435)](_0x4c0537,_0x423cf0,18),ehTYZx.QCrMR(_0x1ef73f,_0xec4e9c,_0x59b641))}async[t(656)](n){let s=t;return(await this._qosDB[s(656)](n))?.[s(1596)]}async closeDB(){let n=t;if(e[n(792)]===e[n(792)])await this._qosDB.closeDB();else{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(1638)](_0x3a4af3),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(1638)](_0x125119);return s?e.YjvuG(_0x5c298d,_0x4312f7):d?e[n(977)](_0x2d45d2,_0x713fad):n(436)+"00000000"+n(436)+n(436)}}[t(742)+t(765)+"Name"](n){let s=t;this[s(480)+s(1306)]=n}get[t(627)](){let n=t;if(e.hdNHJ(e[n(1603)],e[n(1505)]))return this[n(366)][n(627)];this[n(1180)+n(1500)+"ent"](e[n(995)](_0x3dadf3,"close",{code:1e3,reason:e[n(506)]})),this[n(212)+n(1380)]?.[n(1687)+n(353)+n(534)](),this[n(419)+n(1164)]?.[n(405)+n(344)]()}}let Ah=e.YJQVr;async function v0(a){let n=t;if(!this[n(1095)][n(1699)+"S"])return null;let{aID:s,fpID:d,messageStrategy:l}=this[n(1095)],h=e[n(186)](a,Ah);try{if(e[n(1066)](e[n(1738)],e[n(1738)]))return this[n(1228)+"anager"]?a&&this["_cursorM"+n(1441)]["updateCu"+n(765)+"Name"](a):this["_cursorM"+n(1441)]=new Ih(d+"_"+s+"_"+h,h,l),this[n(1228)+n(1441)][n(627)]||await this[n(1228)+n(1441)][n(920)](),this._cursorManager;{let m=new _0x451e6b(e[n(1417)](e[n(1406)](e.JNVbt(e[n(460)](_0x4a89b7[e[n(1507)](_0x231980,4)],24),e[n(1643)](_0x5e7b65[e[n(665)](_0x2405ab,5)],16)),e[n(1087)](_0x4654e5[e[n(1195)](_0x715b18,6)],8)),_0x105bcc[e[n(744)](_0x35ef7a,7)]),e[n(1319)](e[n(659)](e[n(330)](_0x356e21[e[n(1202)](_0x39ee6d,0)]<<24,_0x2256ce[e[n(316)](_0x21f6c0,1)]<<16),e[n(460)](_0x5e5a26[e[n(1257)](_0x3aa24d,2)],8)),_0x489ce0[e.dXQGC(_0x350437,3)]),!0);return _0x2702db+=8,{value:m,offset:e[n(1678)](_0x573194,8)}}}catch{return null}}async function Th(a,n){let s=t,d=e[s(954)](jt,a[s(1012)][s(893)],e[s(362)],"-1"),l=e[s(1237)](jt,a[s(1012)].headers,e[s(1024)],"1"),h=Hn(a[s(1012)][s(893)],e[s(438)]),m=Number(Hn(a[s(1012)].headers,e[s(1568)]))||0,b=Oo[s(1691)](this,a),g=e[s(451)](jt,a[s(1012)][s(893)],e[s(1165)],"2"),T=e[s(1671)](Hn,a[s(1012)][s(893)],e[s(849)]),L=Number(e[s(1578)](Hn,a.message[s(893)],e.khgNX));if(b.isQoSAck)return e[s(466)](n);let q=b[s(1594)+"sage"]?await E0[s(1691)](this):null;if(e[s(1747)](a.message[s(1069)],0)&&l&&!d||a.message.service>0){if(h&&b[s(1594)+s(1363)]&&q)return!!!await q[s(656)](h)&&(this[s(1180)+s(577)+"Event"](a),await q[s(554)](h,e[s(738)](Date[s(549)](),m))),e[s(748)](n);if(g){let J=await v0.call(this);if(!J)return this[s(1180)+"hMessage"+s(1525)](a),e[s(466)](n);let $=await J.get(T)??-1;if(e[s(1546)]($,L))this["_dispatc"+s(577)+"Event"](a),J[s(554)](T,L,a[s(1012)][s(1069)]);else throw new Error(s(623)+s(1410)+s(204)+L+(" larger than loc"+s(1333)+"r ")+$);return e.geqNQ(n)}return this[s(1180)+s(577)+s(1525)](a),e.sbWhv(n)}}async function Ch(a,n){let s=t;if(e[s(1524)](s(428),e[s(1381)]))this[s(618)]++;else{let d=Oo[s(1691)](this,a);if(!d[s(1594)+s(1363)])return n();let l=await E0[s(1691)](this);if(d[s(878)+s(486)+"age"]&&d[s(1361)+"s"][s(784)])for(let h of d.ackMsgIds)await l.del(h);e[s(1702)](n)}}async function Rh(a,n){let s=t,d=e[s(1661)](a[s(1012)][s(1331)+"e"],Eh),l=e.wOOGl(a[s(1012)][s(1331)+"e"],No);if(e[s(569)](!d,!l))return n();let h=e[s(840)](Hn,a[s(1012)].headers,s(308)+s(635));if(!h)return e.sbWhv(n);let m=await v0[s(1691)](this,h);if(!m)return e[s(1486)](n);if(d)if(e[s(1253)]("TVnei",e[s(1089)])){let b=await m.getCursors(),g={frameType:b?.[s(1331)+"e"],SeqID:oe[s(825)+"er"](this[s(973)]++),LogID:oe[s(825)+"er"](this[s(1095)][s(1510)+s(1533)]()),service:9e3,method:5,headers:b?.[s(893)],payload:b?.payload},T=e[s(874)](A,g);this[s(1385)]&&this[s(1385)][s(1106)+"te"]&&this[s(1385)][s(501)](T)}else{let b=_0x5c29bf[s(417)+s(1282)](_0xf56d1a);return _0x592326&&b[s(668)+s(662)](s(631),()=>_0x39039e()),VLahjy.xGkAl(_0x29ead6,b).then(()=>{})}if(l){let b=a[s(1012)][s(696)];b&&m[s(1121)+"rs"](b)}}let Dh=async function(a,n){let s=t;this._isInit=!1,e[s(1084)](clearTimeout,this["_connect"+s(1273)+"utId"]),e[s(1540)](n)},kh=async function(a,n){let s=t;if(!this[s(1385)]||this[s(1385)][s(1106)+"te"]!==this[s(355)])return n();let{pingInterval:d}=this._options;this[s(212)+s(1380)]?.[s(1687)+s(353)+s(534)]();for(let h=0;e[s(819)](h,this[s(771)+s(799)][s(784)]);h++){let m=this._messageQueue[h];if(this._ws.readyState===this[s(355)]&&e[s(1732)](null,m))this[s(1385)]&&this[s(1385)].send(m),this[s(771)+s(799)][h]=null;else break}this[s(771)+s(799)]=this[s(771)+"Queue"].filter(h=>!!h),this[s(1646)+s(1566)+"Id"]=setTimeout(()=>this[s(310)](),d),this[s(1180)+s(1553)+"nt"](a),this[s(1134)+"er"]&&this[s(1385)]&&(this._ws.binaryType=this["_binaryT"+s(1428)]);let l=this[s(212)+s(1380)]?.["getCurre"+s(1387)+"nt"]();this[s(404)]("open "+l+s(811)),e[s(1486)](n)},Oh=async function(a,n){let s=t,d=this[s(212)+s(1380)]?.[s(592)+s(1387)+"nt"]();this[s(404)]("open "+d),e.wEkMA(n)};class Ph extends Ro{constructor(n){let s=t,d={ewIQY:function(b,g,T,L){return e[H(904)](b,g,T,L)},uOBYO:function(b,g){return b!==g},KhFoa:e[s(383)],eQGsm:function(b,g,T){return e[s(876)](b,g,T)},vJXNM:function(b,g){return b===g},dAPwm:function(b,g){return e[s(1358)](b,g)},CCvil:e[s(903)],duPAM:"auto",QfrGV:e.chMtn,QPvEk:e[s(515)],OBInw:e.itolb,wWrYB:function(b,g,T){return e[s(817)](b,g,T)},BgQFs:e[s(506)],fxxuN:function(b,g,T){return e[s(410)](b,g,T)},NBWYj:function(b,g,T){return e.TKQHx(b,g,T)},SFaLJ:function(b,g){return e.wCIbH(b,g)},SDkas:function(b,g,T){return b(g,T)}};super(),this[s(708)+"igatorOn"+s(706)]=!0,this[s(1134)+"er"]=Un,this[s(1497)]=Zx,this[s(1526)+"T"]=xn,this._isMiniWX=Cr,this[s(1443)+"r"]=Rr,this[s(771)+s(799)]=[],this[s(212)+s(1380)]=null,this[s(1296)+s(1477)]=!1,this[s(490)+s(1428)]=e[s(857)],this[s(1688)+s(1329)]=!1,this[s(1688)+"ionTimeo"+s(1398)]=null,this["_reconnectTimeou"+s(564)]=null,this[s(1646)+"gTimeoutId"]=null,this._seqId=0,this[s(1088)]=!1,this[s(976)]="",this[s(396)+s(1300)]=null,this[s(1228)+"anager"]=null,this[s(419)+s(1164)]=null,this[s(830)+"ls"]=e[s(494)],this.CLOSED=3,this[s(411)+"NG"]=0,this[s(355)]=1,this[s(1527)]=2,this._onOpen=b=>{let g=s;try{d.ewIQY(g0,this,b,[Dh,kh,Oh])}catch(T){if(d[g(835)](d[g(1225)],g(1160))){let L=d[g(543)](Xe,g(789),{message:T.message,code:Gt[g(302)+"OR"],error:T});this[g(1180)+"hErrorEv"+g(1591)](L)}else{let{type:L}=_0x24c28b;this[g(1041)](L,_0x520fbe)}}},this[s(1245)+"ge"]=async b=>{let g=s,{pingInterval:T,pingFrequency:L}=this[g(1095)];if((d[g(1123)]("hi",b[g(1592)])&&d.dAPwm(d[g(572)],L)||d.vJXNM(d[g(715)],L))&&(this["_clearPi"+g(370)](),this[g(1041)](d.QfrGV,g(1332)),this["_pingPon"+g(1566)+"Id"]=setTimeout(this[g(310)][g(608)](this),T)),!d[g(1123)]("hi",b[g(1592)]))try{g0(this,b,[fh,ch,Ch,Rh,Th,dh])}catch(q){let J=Xe(d[g(716)],{message:q.message,code:Gt[g(1149)+g(1355)],error:q});this[g(1180)+g(1421)+"ent"](J)}},this._onError=b=>{let g=s,T=this["_endpoin"+g(1380)]?.[g(1309)+"chMaxTries"](),L=this[g(212)+g(1380)]?.[g(592)+g(1387)+"nt"]();if(T&&!b[g(1012)]){let q=g(256)+L+(g(633)+g(644)+g(613)+"ed");this[g(1180)+g(1421)+g(1591)](e.SHjJp(Xe,g(789),{message:q,code:Gt[g(399)+g(1051)+"R"],error:b}));return}this[g(1385)]&&this[g(1385)][g(1106)+"te"]===this[g(355)]&&this[g(1492)+g(346)](),this[g(1180)+g(1421)+g(1591)](e[g(467)](Xe,e[g(515)],{message:b.message,code:Gt.NATIVE_ERROR,error:b}))},this[s(1562)]=async b=>{let g=s;this[g(1103)+g(617)](),this["_clearPi"+g(370)](),this[g(496)+g(343)+"rs"](),this[g(1385)]=null,this[g(1688)+g(1329)]=!1;let T=this["_endpoin"+g(1380)]?.[g(1309)+g(201)+"es"]();if(!T&&this[g(387)+g(1734)]()&&!this[g(1296)+g(1477)]){let L=this[g(212)+g(1380)]?.[g(592)+g(1387)+"nt"](),q=this[g(1095)][g(1345)+"tInterce"+g(1622)](b[g(1690)],b[g(1656)]);this["_dispatchCloseEv"+g(1591)](d.eQGsm(st,d.OBInw,{code:1006,reason:b.reason||g(909)+g(693)+g(1436)+g(241)+g(1042)+g(704)+L,willReconnect:q})),q&&this[g(1688)]();return}if(d[g(835)](1e3,b[g(1690)])&&this[g(1296)+g(1477)]){this[g(1180)+g(1500)+g(1591)](d[g(1200)](st,g(764),{code:1e3,reason:d.BgQFs})),this["_endpoin"+g(1380)]?.["resetEnd"+g(353)+"fig"](),this["_pingLos"+g(1164)]?.[g(405)+g(344)]();return}if(b[g(1690)]!==1e3&&T){let L=this[g(212)+g(1380)]?.[g(592)+g(1387)+"nt"](),q=b[g(1656)];q||(q=await nh(this[g(976)])),q=g(909)+g(693)+g(728)+q+(g(1082)+g(169))+L+(g(1522)+g(827)+g(1368)),this[g(1180)+g(1500)+g(1591)](d[g(895)](st,"close",{code:b.code,reason:q}));let J="connect "+L+(g(633)+g(644)+"es reached");this[g(1180)+g(1421)+g(1591)](d.NBWYj(Xe,d[g(716)],{message:J,code:Gt["MAX_RETR"+g(1051)+"R"]})),this[g(212)+g(1380)]?.[g(1687)+g(353)+"fig"](),this[g(419)+g(1164)]?.[g(405)+g(344)]();return}if(d[g(1729)](1e3,b[g(1690)])&&!b.reason){let L=this[g(212)+g(1380)]?.[g(592)+g(1387)+"nt"]();this[g(1180)+g(1500)+"ent"](d[g(1405)](st,d.OBInw,{code:b[g(1690)],reason:"connecti"+g(693)+g(1436)+g(241)+g(1042)+g(704)+L})),this[g(212)+g(1380)]?.[g(1687)+g(353)+"fig"](),this[g(419)+"sCounter"]?.resetCounter();return}this._dispatchCloseEvent(b),this[g(212)+"tManager"]?.[g(1687)+g(353)+g(534)](),this[g(419)+g(1164)]?.[g(405)+g(344)]()},this.onclose=null,this[s(412)]=null,this.onmessage=null,this.onopen=null,this.onStartReconnect=null,this[s(1669)+s(235)]=null,this["onStopImmediatel"+s(823)+"ct"]=null,this[s(1464)+s(239)]=this["_handleO"+s(239)].bind(this),this["_handleO"+s(992)]=this[s(1464)+s(992)][s(608)](this),this[s(1122)+s(1098)]=this[s(1122)+s(1098)][s(608)](this),this._handlePageShow=this[s(1122)+s(1136)][s(608)](this),this._options={url:"",automaticOpen:!0,initReconnectInterval:1e3,maxReconnectInterval:1e4,reconnectIntervalGrowFactor:2,timeoutInterval:5e3,maxRetries:5,debug:!1,maxMessageQueueLength:e[s(1279)](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:e[s(1214)],pingLossCount:2,enableTransformTextPayload:!1,logIDNewConfig:{enableAutoGenerateLogIDNew:!1,userIp:""},miniProgramParams:{customHttpHeader:{}},enableAutoAck:!1,reconnectInterceptor:()=>!0,enableQoS:!1,QoSLevel:2,messageStrategy:e[s(1171)],env:{xTTEnv:"",xUseEnv:""},listenNetworkChanged:!0};let{url:l,ws:h}=n,m=Array.isArray(l)?l:e.pHLJC==typeof l?[l]:[];if(!m||m[s(784)]===0)throw new Error(e[s(881)]);if(!Xx(h))throw new Error(s(944)+s(1186)+s(593)+", WebSoc"+s(1335)+"tructor "+s(1598)+s(475));if(Object[s(1340)](this._options,n),this[s(212)+s(1380)]=new p0(m,this[s(1095)][s(263)+"es"]),this[s(419)+s(1164)]=new th(this._options[s(958)+s(395)]),this[s(1095)][s(1644)+s(868)])if(s(804)!==s(1022))this[s(1088)]=!0,this[s(1688)]();else{let b="connect "+_0x152922+(s(633)+s(644)+s(613)+"ed");this["_dispatchErrorEv"+s(1591)](d.eQGsm(_0x2e7e32,d[s(716)],{message:b,code:_0xafe3a3[s(399)+s(1051)+"R"],error:_0x2347e1}));return}this[s(1095)][s(401)+"tworkCha"+s(1168)]&&(this[s(1526)+"T"]||this[s(766)+"X"]?this[s(1670)+s(691)+"ange"]():this[s(1134)+"er"]&&this[s(794)+s(845)+s(662)]())}[t(1464)+t(239)](){let n=t;this[n(1095)][n(197)+n(762)+n(1682)]||this[n(1296)+n(1477)]||this["_handleR"+n(1118)]()}[t(1464)+"ffLine"](){let n=t;this[n(558)+n(1132)+"t"]();let s=e[n(717)](Co,e[n(238)],{message:e.TlsGT});this["onStopIm"+n(388)+n(823)+"ct"]&&this["onStopIm"+n(388)+n(823)+"ct"](s)}[t(794)+t(845)+t(662)](){let n=t;this[n(1134)+"er"]&&window[n(668)+"Listener"](e.PzMkj,this[n(1464)+n(239)]),this[n(1134)+"er"]&&window[n(668)+n(662)](e[n(1697)],this[n(1464)+"ffLine"]),this[n(1134)+"er"]&&window[n(668)+n(662)](e[n(1618)],this._handlePageHide),this[n(1134)+"er"]&&window[n(668)+"Listener"]("pageshow",this[n(1122)+n(1136)])}[t(1693)+t(845)+t(662)](){let n=t;this[n(1134)+"er"]&&window["removeEv"+n(250)+n(773)](e[n(306)],this[n(1464)+"nLine"]),this[n(1134)+"er"]&&window[n(318)+n(250)+n(773)](n(398),this[n(1464)+n(992)]),this[n(1134)+"er"]&&window[n(318)+n(250)+n(773)](e[n(1618)],this[n(1122)+n(1098)]),this[n(1134)+"er"]&&window.removeEventListener(e.aYTqS,this[n(1122)+"ageShow"])}["_handleP"+t(1098)](n){let s=t;e.XLJjR(e[s(381)],e[s(833)])?(this._messageQueue[s(207)](),this[s(771)+s(799)][s(1384)](_0x4ffaae)):(!n[s(889)+"d"]&&(this[s(1134)+"er"]&&window[s(318)+s(250)+"ner"](e[s(1618)],this._handlePageHide),this[s(1134)+"er"]&&window.removeEventListener(e[s(1686)],this._handlePageShow),this[s(764)]()),this[s(1134)+"er"]&&window[s(318)+"entListe"+s(773)](s(530),this[s(1464)+s(239)]),this[s(1134)+"er"]&&window[s(318)+s(250)+s(773)](e[s(1697)],this["_handleO"+s(992)]))}[t(1122)+t(1136)](n){let s=t,d={rpYVY:function(l,h){return e[H(1287)](l,h)},MZbJI:e[s(515)],UoHvh:function(l,h){return l instanceof h},NKSeU:function(l,h){return e[s(686)](l,h)},YNfkz:e.QHQkE,LMBZH:function(l,h){return e.xaxXL(l,h)},JFnXT:function(l,h){return e[s(1156)](l,h)}};if(n[s(889)+"d"])if(e[s(1716)](e.OaXGN,e[s(445)]))this[s(387)+s(1734)]()&&(!this[s(1385)]||e.hdNHJ(this[s(1385)].readyState,this[s(355)])||e[s(1050)](this._ws[s(1106)+"te"],this[s(411)+"NG"]))&&this[s(1464)+s(239)](),this[s(1134)+"er"]&&window[s(668)+s(662)]("online",this[s(1464)+s(239)]),this._isBrowser&&window[s(668)+s(662)](e[s(1697)],this[s(1464)+s(992)]);else{let l=this._listeners[_0x538a96];if(l)l[s(834)]()[s(181)](h=>h.fn[s(1504)](h[s(1611)],_0x144916));else if(xNPuvH[s(421)](xNPuvH[s(1102)],_0x473be3)&&!this[s(412)]){let h=_0x2eb7a1[s(784)]&&_0x2f2f2e[0];if(xNPuvH[s(1034)](h,_0x2f6abc))throw h;let m=new _0x2d1e77(xNPuvH[s(292)](xNPuvH[s(755)],h?xNPuvH[s(184)](xNPuvH[s(1262)](" (",h[s(1012)]),")"):""));throw m[s(220)]=h,h}return this}}async _generateUrl(n){let s=t,{fpID:d,deviceID:l,bddID:h,ttwID:m,accessKey:b,aID:g,customParams:T={},enableAutoAck:L,enableQoS:q,QoSLevel:J,env:$}=this._options,W,ye,je;this._isBrowser||this[s(766)+"X"]||this[s(1526)+"T"]?(W=location&&e.SydJH(e[s(869)],location[s(509)])?e[s(676)]:e[s(802)],ye=n.replace(/((^ws)|(^http))((?:[s]*:\/\/))/,""),je=/^wss(.*:\/\/)/[s(1638)](n)?n:""+W+ye):(W=s(479),ye=n.replace(/(^http)((?:[s]*:\/\/))/,""),je=/(^ws)((?:[s]*:\/\/))/.test(ye)?ye:""+W+ye);let S0=h?e[s(200)]:m?e[s(989)]:e[s(1538)],I0=h||m||l;if(!I0||!S0)throw new Error(e[s(978)]);let Lh=e[s(1585)](e[s(1707)],typeof T)?await T():T,Nh=$?e[s(767)](eh,$[s(363)],$.xTTEnv):{},Mo=Object[s(1340)]({device_platform:s(1460),version_code:e[s(580)],access_key:b,fpid:d,aid:g,[S0]:I0,xsack:L?1:0,xaack:L?1:0,xsqos:q?1:0,qos_level:q?J:void 0,qos_sdk_version:2,...Nh},Lh),Mh=Object[s(692)](Mo)[s(471)]((Bo,zo)=>Mo[zo]!==void 0?""+Bo+(Bo?"&":"?")+zo+"="+Mo[zo]:Bo,"");return je+s(465)+Mh}async[t(1688)](){let n=t;if(!(this["_connect"+n(1329)]||this["_readyCl"+n(1477)])){this[n(1688)+n(1329)]=!0;try{let s=this[n(212)+n(1380)]?.[n(1648)+n(1631)+n(721)+n(961)+n(1254)](),{timeoutInterval:d}=this[n(1095)];if(s){let h=this["_endpoin"+n(1380)]?.[n(592)+n(1387)+"nt"](),m=this[n(212)+n(1380)]?.["replaceB"+n(1511)+"pointAnd"+n(1668)+n(588)](),b=this[n(212)+n(1380)]?.[n(592)+"ntEndpointTriesC"+n(838)]();if(m){let g=n(256)+h+(" timeout"+n(1522)+n(827)+"ached, will use "+n(1001)+n(166))+m+(n(1620)+"y"),T=Xe(e[n(515)],{message:g,code:Gt["MAX_RETR"+n(1051)+"R"]});this[n(404)](g),this["_dispatc"+n(1421)+"ent"](T),this._url=await this[n(824)+n(1606)](m),this[n(404)](n(256)+m+" "+b+n(649)),this._removeWsListeners()}else{let g=n(256)+h+(" timeout"+n(1522)+n(827)+n(1368));this._debug(g),this[n(1180)+"hErrorEv"+n(1591)](Xe(e[n(515)],{message:g,code:Gt["MAX_RETR"+n(1051)+"R"]}));return}}else if(e[n(872)]===e.ePYvm){let h=this[n(212)+n(1380)]?.[n(592)+n(1387)+n(1105)+n(518)](),m=this[n(212)+n(1380)]?.[n(592)+n(1387)+n(298)+n(838)]();this[n(976)]=await this["_generat"+n(1606)](h||""),this[n(404)](n(256)+h+" "+m+n(649)),this[n(496)+"sListeners"]()}else this[n(1526)+"T"]||this[n(766)+"X"]?this["_onPageN"+n(691)+n(1449)]():this[n(1134)+"er"]&&this[n(794)+n(845)+"Listener"]();if(this[n(1088)])this[n(1088)]=!1;else{let h=e.EDVWK(Co,e[n(238)],{message:"start"});this[n(1667)+n(1118)]&&this[n(1667)+"econnect"](h)}let l=this[n(212)+"tManager"]?.[n(592)+"ntEndpoi"+n(298)+"ount"]()||0;e[n(962)](l,1)&&await this[n(1374)](e.odPnl(l,1)),this[n(404)]("connecti"+n(664)+this._url+(n(955)+"ls: ")+this[n(830)+"ls"]),this[n(1385)]=e.URWzJ(Yx,{url:this[n(976)],protocols:[this[n(830)+"ls"]],headers:this._options["miniProg"+n(636)+"s"][n(1650)+n(808)]},this[n(1095)].ws),(this[n(1134)+"er"]||this[n(1443)+"r"])&&this._ws&&(this[n(1385)][n(385)+"pe"]=this[n(490)+n(1428)]),this[n(1658)+"steners"](),this["_connect"+n(1273)+n(1398)]=e[n(641)](setTimeout,this._onTimeout[n(608)](this),d)}catch(s){throw this[n(1688)+n(1329)]=!1,s}}}["_clearTi"+t(617)](){let n=t;e.RKZVN(clearTimeout,this[n(1688)+"ionTimeo"+n(1398)]),this[n(1688)+n(1273)+n(1398)]=null}[t(1007)+"ngTimer"](){let n=t;e[n(945)](clearTimeout,this["_pingPon"+n(1566)+"Id"]),e[n(452)](clearTimeout,this[n(170)+n(1567)+n(564)]),this["_pingPon"+n(1566)+"Id"]=null,this[n(170)+n(1567)+n(564)]=null}[t(404)](...n){let s=t;this[s(1095)][s(1681)]&&console[s(1170)][s(1504)](console,[s(415)+">",...n])}["_getInte"+t(523)+"e"](n){let s=t,{initReconnectInterval:d,maxReconnectInterval:l,reconnectIntervalGrowFactor:h}=this[s(1095)],m=e[s(1096)](d,Math[s(1445)](h,e[s(585)](n,1)));return e[s(1271)](m,l)?l:m}[t(310)](){let n=t;if(e[n(1356)](n(1057),e.nEImR))return this[n(366)][n(627)];if(this[n(1385)]&&this[n(1385)][n(1106)+"te"]===this[n(411)+"NG"]){this[n(1007)+n(370)](),this["_pingPon"+n(1566)+"Id"]=e[n(640)](setTimeout,this[n(310)][n(608)](this),this._options["pingInte"+n(837)]);return}if(!this[n(1385)]||e[n(1337)](this[n(1385)].readyState,this.OPEN))return void this[n(1482)+"econnect"]();this[n(1385)]&&this[n(1385)][n(501)]("hi"),this[n(170)+n(1567)+n(564)]=e[n(926)](setTimeout,this[n(1482)+n(1118)+"Timeout"].bind(this),this._options[n(828)+n(1342)+n(1448)])}["_handleReconnect"+t(906)](){let n=t;this[n(419)+n(1164)]?.[n(209)](),this[n(1041)](e[n(582)],e[n(942)]),this["_pingLos"+n(1164)]?.checkReachMaxCount()?this["_handleR"+n(1118)]():this[n(310)]()}[t(387)+t(1734)](){let n=t;return this[n(1526)+"T"]||this[n(766)+"X"]?this[n(708)+n(1125)+n(706)]:(this[n(1134)+"er"]||this[n(1443)+"r"])&&this[n(1095)]["listenNe"+n(1493)+"nged"]?navigator[n(1341)]:!0}[t(1482)+t(1118)](){let n=t;if(e[n(875)](n(429),e.BGgUb)){let s=e[n(557)](this[n(1095)][n(1166)+"ncoding"],_0x1c775f)?{force:!!this[n(1095)][n(1166)+n(905)][n(439)],encoding:this[n(1095)].payloadEncoding[n(967)]?this._options["payloadE"+n(905)].encoding[n(1313)](/\s/g,"")["toLowerC"+n(535)]():""}:{force:!1,encoding:this[n(1095)][n(1166)+"ncoding"]?this[n(1095)]["payloadE"+n(905)][n(1313)](/\s/g,"")[n(1191)+n(535)]():""},d=_0x13f43f[n(1166)+n(905)]?_0x57dfc1.payloadEncoding[n(1313)](/\s/g,"")[n(1191)+n(535)]():"",l=this[n(1095)]["payloadT"+n(1428)]instanceof _0x29bcee?{force:!!this[n(1095)][n(1092)+"ype"].force,type:this[n(1095)][n(1092)+n(1428)][n(681)]?this[n(1095)][n(1092)+"ype"].type.replace(/\s/g,"")[n(1191)+n(535)]():""}:{force:!1,type:this[n(1095)]["payloadT"+n(1428)]?this[n(1095)][n(1092)+"ype"][n(1313)](/\s/g,"")[n(1191)+n(535)]():""},h=_0x1546a0.payloadType?_0x34ea04[n(1092)+n(1428)][n(1313)](/\s/g,"")["toLowerC"+n(535)]():"",m=l[n(439)]?l[n(681)]:h||l.type,b=s[n(439)]?s[n(967)]:d||s[n(967)],g=[e[n(391)],e[n(1674)],e[n(328)],e[n(896)]],T=[e.mmdsb,e[n(1359)]];this[n(1095)][n(1357)+"ansformT"+n(504)+"ad"]&&g[n(578)](m)&&(!b||T[n(578)](b))?_0x5605c3[n(1188)+"oad"]=e.zTuNg(_0x2b902b,_0x19d39c[n(696)],0,_0x3fd440[n(696)][n(1454)+"th"]):_0x511522[n(1188)+n(1107)]=""}else{if(!this["_navigat"+n(1734)]()||this[n(1296)+"osed"])return;this[n(212)+"tManager"]?.[n(1687)+"pointCon"+n(534)](),this._pingLossCounter?.["resetCou"+n(344)](),this._ws?this["_disconn"+n(346)](1001,e[n(449)],!0):this[n(1688)]()}}["_onPageN"+t(691)+t(1449)](){let n=t;this._isMiniTT?tt[n(1498)+n(1216)+n(1700)](({isConnected:s})=>{let d=n;this._miniNavigatorOnline=s,s?this[d(1464)+"nLine"]():this["_handleO"+d(992)]()}):this[n(766)+"X"]&&wx[n(1498)+n(1216)+n(1700)](({isConnected:s})=>{let d=n;this[d(708)+"igatorOn"+d(706)]=s,s?this[d(1464)+d(239)]():this["_handleO"+d(992)]()})}[t(1374)](n){let s={vPKhB:function(d,l,h){return d(l,h)}};return new Promise(d=>{let l=H;s[l(763)](setTimeout,d,this["_getInte"+l(523)+"e"](n))})}[t(1492)+"ect"](n=1e3,s="",d=!1){this[t(1385)]&&this._destroyWebSocket(n,s,d)}[t(880)+"ut"](){let n=t;if(e[n(875)](e[n(482)],e[n(1664)]))e[n(221)](_0x5a18ff,this,_0x4f271b,[_0x38fe89,_0x5ce773,_0x1c1def]);else{let s=this["_endpoin"+n(1380)]?.[n(592)+"ntEndpoint"]();this[n(404)](n(256)+s+n(527)),this[n(1492)+"ect"](1001,e.AXRdq,!0)}}[t(570)](n){let s=t,d=e[s(1470)](Ge,n);this._ws&&e[s(1677)](this[s(1385)][s(1106)+"te"],this[s(355)])&&(this[s(1385)]&&this._ws[s(501)](d),this[s(404)](s(360),n))}[t(496)+"sListeners"](){let n=t,s=e[n(1336)][n(513)]("|"),d=0;for(;;){switch(s[d++]){case"0":this[n(1385)]["removeEventListe"+n(773)](n(447),this[n(1347)]);continue;case"1":this[n(1385)][n(318)+n(250)+n(773)](n(1012),this._onMessage);continue;case"2":this[n(1385)][n(318)+n(250)+n(773)](e[n(1294)],this[n(1562)]);continue;case"3":if(!this[n(1385)])return;continue;case"4":this[n(1385)][n(318)+n(250)+n(773)](n(789),this._onError);continue}break}}[t(1658)+t(406)](){let n=t;this[n(1385)]&&(this[n(1385)]["addEvent"+n(662)](e[n(378)],this[n(1347)]),this[n(1385)][n(668)+n(662)]("close",this[n(1562)]),this[n(1385)]["addEvent"+n(662)](e[n(998)],this[n(1245)+"ge"]),this[n(1385)][n(668)+n(662)](e[n(515)],this._onError))}[t(609)+t(751)](n=1e3,s=""){let d=t;try{this[d(1385)]&&this[d(1385)][d(764)](n,s)}catch{}}[t(558)+t(1132)+"t"](n=1e3,s="",d=!1){let l=t;if(e[l(1337)](l(547),l(547))){let h=_0x50c91c(_0x38abcd,_0x5b7a04[l(784)]);_0x5c7ffa[l(521)].set(_0x3ab430,h)}else{if(this[l(1007)+l(370)](),this[l(1103)+l(617)](),this[l(496)+l(343)+"rs"](),this[l(609)+l(751)](1e3,s),this[l(1688)+l(1329)]=!1,d&&this[l(387)+"orOnline"]()&&!this["_readyCl"+l(1477)]){if(this[l(212)+"tManager"]?.[l(1309)+l(201)+"es"]()){let m=this["_endpoin"+l(1380)]?.getCurrentEndpoint();this[l(1180)+l(1500)+l(1591)](e[l(705)](st,e[l(1294)],{code:1006,reason:l(256)+m+(l(527)+l(1522)+l(827)+l(1368)),wasClean:!0}))}else{let m=this[l(1095)][l(1345)+l(1372)+l(1622)](n,s);this[l(1180)+l(1500)+l(1591)](e[l(342)](st,e[l(1294)],{code:n,reason:s,wasClean:!0,willReconnect:m})),m&&this[l(1688)]()}return}this["_navigat"+l(1734)]()||this["_readyCl"+l(1477)]?this._dispatchCloseEvent(st(e[l(1294)],{code:n,reason:e.RRtTD})):this["_dispatchCloseEv"+l(1591)](e[l(1579)](st,e[l(1294)],{code:1006,reason:e.GlPhJ})),this[l(1385)]=null,this["_endpoin"+l(1380)]?.[l(1687)+l(353)+l(534)](),this[l(419)+"sCounter"]?.[l(405)+l(344)]()}}["_dispatc"+t(1553)+"nt"](n){let s=t;this[s(1041)](e[s(378)],n),this[s(1346)]&&this.onopen(n)}["_dispatc"+t(577)+t(1525)](n){let s=t;e[s(770)](e[s(1157)],e[s(1157)])?(this[s(1041)](e[s(1294)],_0xccbfa9),this[s(1075)]&&this[s(1075)](_0x59b650)):(this[s(1041)](e.kUJEf,n),this.onmessage&&this[s(1181)+"e"](n))}["_dispatc"+t(1141)+t(1465)](n){let s=t;this[s(1041)](e.dRtSS,n),this[s(1669)+s(235)]&&this[s(1669)+s(235)](n)}[t(1180)+"hErrorEv"+t(1591)](n){this[t(1041)](e.FFIiI,n),this.onerror&&this.onerror(n)}["_dispatc"+t(1500)+t(1591)](n){let s=t;this.emit(e[s(1294)],n),this[s(1075)]&&this[s(1075)](n)}get[t(385)+"pe"](){let n=t;if(e[n(622)](e.MbqKd,e[n(1730)])){if(_0x554846||_0x49209f)return new _0x3025a8(_0x5d01c6,_0x277471);if(e[n(672)](_0x869f5f,_0x484594)&&e[n(1e3)](e[n(1478)],typeof _0x200c75))return new _0x31bc0e(_0x3132ca,_0x2743f6);if((_0x530a91||_0x366b72)&&e[n(1478)]!=typeof _0x4aa1e0)return new _0x5d8b53(_0x23e1f2,_0x1a3e5a);throw new _0x23ef40(e.WlKzy)}else return this._ws?this[n(1385)].binaryType:this[n(490)+n(1428)]}set[t(385)+"pe"](n){let s=t;this[s(490)+s(1428)]=n,this._ws&&(this._ws[s(385)+"pe"]=n)}get retryCount(){let n=t,s={HcrOt:function(d,l,h){return e[H(940)](d,l,h)},tmhis:function(d,l,h){return e[H(995)](d,l,h)}};if(n(779)!=="PganA")return this["_endpoin"+n(1380)]?.[n(592)+"ntEndpoi"+n(298)+n(838)]()||0;zdEAVn.HcrOt(_0x3cff1d,_0x5c1905,66),zdEAVn[n(908)](_0x3cebc9,_0x2f40ae,_0x2333f8[n(784)]),zdEAVn[n(1739)](_0x2b6be5,_0x5c3773,_0x4d97d1)}get[t(450)+t(1199)](){let n=t;if(e[n(1514)](e[n(1418)],e[n(1418)]))_0x4bc53c(this["_pingPon"+n(1566)+"Id"]),e[n(400)](_0x324eb3,this["_reconne"+n(1567)+n(564)]),this[n(1646)+n(1566)+"Id"]=null,this[n(170)+n(1567)+n(564)]=null;else return this[n(771)+n(799)][n(471)]((d,l)=>(d+=l&&l.byteLength||0,d),0)+(this[n(1385)]?this[n(1385)]["buffered"+n(1199)]:0)}get[t(1177)+"ns"](){let n=t;return this[n(1385)]?this[n(1385)].extensions:""}get[t(509)](){let n=t;return this[n(1385)]?this[n(1385)].protocol:""}get[t(1106)+"te"](){let n=t;return this[n(1385)]?this._ws[n(1106)+"te"]:this._options.automaticOpen?this.CONNECTING:this[n(455)]}get[t(179)](){let n=t;return this._ws?this[n(1385)][n(179)]:this._url}[t(764)](n=1e3,s){let d=t;if(e[d(525)](e.JUKZX,d(853)))return _0x229287[_0x2aedd9]=_0x431a51,!0;if(this[d(1296)+"osed"]=!0,this[d(1103)+d(617)](),this["_clearPi"+d(370)](),this[d(1693)+"balEvent"+d(662)](),this[d(396)+d(1300)]?.closeDB(),!this[d(1385)])return void this[d(404)](e[d(826)]);if(e[d(183)](this[d(1385)][d(1106)+"te"],this[d(455)])||this[d(1385)][d(1106)+"te"]===this.CLOSING)return void this._debug(e[d(1045)]);this[d(558)+d(1132)+"t"](n,s)}async send(n,s){let d=t;if(e[d(960)](null,n))throw new Error(e.Cvict);e[d(1724)](d(291),typeof n)&&(n=JSON[d(1601)+"y"](n)),e.LMQkX(d(1407),typeof n)&&!e[d(371)](n,ArrayBuffer)&&!(n[d(1609)]&&e[d(1388)](n[d(1609)],ArrayBuffer))&&(n=JSON[d(1601)+"y"](n));let l=await e[d(970)](_0,n),h=e[d(452)](Qx,n),{method:m=0,service:b=this[d(1095)][d(1069)],logID:g=this[d(1095)]["logIDGen"+d(1533)](),headers:T=this[d(1095)][d(893)],payloadEncoding:L=this[d(1095)][d(1166)+d(905)],payloadType:q=this[d(1095)][d(1092)+"ype"],logIDNew:J=this[d(1095)]["logIDNew"+d(1080)][d(685)+d(1058)+"teLogIDNew"]?e[d(1056)](i,this[d(1095)]["logIDNew"+d(1080)][d(645)]):""}=e[d(334)](s,{});if(!b)throw new Error(e[d(805)]);let $={SeqID:oe[d(825)+"er"](this[d(973)]++),LogID:oe[d(825)+"er"](g),service:b,method:m,headers:T,payloadEncoding:L instanceof Object?L[d(967)]?L.encoding:"":L,payloadType:q instanceof Object?q[d(681)]?q[d(681)]:h:q||h,payload:l,LogIDNew:J},W=Ge($);if(this[d(1385)]&&this[d(1385)][d(1106)+"te"]===this[d(355)])this[d(1385)]&&this[d(1385)][d(501)](W),this[d(404)](e[d(1529)],$);else if(this[d(771)+"Queue"][d(784)]<this[d(1095)]["maxMessa"+d(1059)+d(483)])this[d(771)+d(799)][d(1384)](W),this._debug(d(1462),$);else if(e[d(1232)](e[d(1446)],e[d(1446)])){if(e[d(1152)](_0x12b900,_0x225607))throw new _0x4c981d(d(1062)+d(1072)+"e");let ye=3;for(;e[d(782)](ye,0);){let je=e[d(870)](255,_0x4538be);e[d(1393)](_0x68de08,je,_0x4aaa25,e[d(394)](_0x130c18,ye)),_0x476fa7>>>=8,ye--}return e.IOGLU(_0x12ca61,4)}else this["_message"+d(799)].shift(),this[d(771)+d(799)].push(W);return{seqID:this[d(973)],logID:g,logIDNew:J}}async reconnect(n){let s=t,d={bwAtD:function(l,h){return e[H(1325)](l,h)},pjqRu:function(l,h){return e[H(532)](l,h)},zOkTn:function(l,h){return e[H(485)](l,h)},QbADu:function(l,h){return e[H(891)](l,h)},RZOoj:function(l,h){return e[H(1109)](l,h)},KmrjZ:function(l,h){return e[H(1626)](l,h)},FdiJV:function(l,h){return l===h}};if(e[s(883)](s(1625),e[s(1654)])){let l=this.high,h=this[s(701)];return[KpyyeO.bwAtD(l,24),KpyyeO[s(1119)](l>>>16,255),KpyyeO[s(1550)](l,8)&255,KpyyeO[s(756)](255,l),KpyyeO.zOkTn(h,24),KpyyeO[s(756)](h>>>16,255),KpyyeO[s(756)](h>>>8,255),KpyyeO[s(1119)](255,h)]}else{let{url:l}=e[s(885)](n,{}),h=Array.isArray(l)?l:e[s(1395)](e[s(896)],typeof l)?[l]:[];if(n&&Object.assign(this[s(1095)],n),h&&h[s(784)]?this[s(212)+s(1380)]=new p0(h,this[s(1095)][s(263)+"es"]):this[s(212)+s(1380)]?.[s(1687)+s(353)+"fig"](),this[s(419)+s(1164)]?.[s(405)+"nter"](this[s(1095)][s(958)+s(395)]),this[s(1296)+s(1477)]=!1,this._ws&&e[s(594)](this[s(1385)][s(1106)+"te"],this[s(455)]))this[s(1492)+s(346)](1e3,e[s(947)],!0);else if(e[s(1665)](e[s(446)],e[s(245)])){if(KpyyeO.RZOoj(void 0,_0x24803b))this._listeners={};else if(_0x135435===void 0)this[s(257)+"rs"][_0x56ea28]=null;else{let m=this._listeners[_0x5e2b9d];if(m)for(let b=0;KpyyeO[s(287)](b,m[s(784)]);)KpyyeO[s(687)](m[b].fn,_0x39bd69)?m[s(1444)](b,1):++b}return this}else this[s(1088)]=!0,this[s(1688)]()}}async connect(){let n=t;if(e[n(525)](e[n(315)],e[n(752)])){if(!this[n(1688)+n(1329)]){let s="1|4|3|2|0"[n(513)]("|"),d=0;for(;;){switch(s[d++]){case"0":this[n(1688)]();continue;case"1":this[n(212)+n(1380)]?.[n(1687)+"pointConfig"]();continue;case"2":this._isInit=!0;continue;case"3":this[n(1296)+n(1477)]=!1;continue;case"4":this[n(419)+n(1164)]?.["resetCou"+n(344)]();continue}break}}}else return this[n(366)]?.[n(554)]({message_id:_0x43c2cd,timestamp:_0x185284})}[t(668)+t(662)](n,s){this.on(n,s)}["dispatch"+t(1525)](n){let s=t,{type:d}=n;this[s(1041)](d,n)}[t(318)+t(250)+t(773)](n,s){let d=t;if(e.sDHwn(d(1630),d(1630)))this.off(n,s);else return _0x504601}[t(638)](){let n=t,s={QCNjL:function(d,l){return e[H(1142)](d,l)},AtIHM:function(d,l){return e[H(1506)](d,l)},Zdfhs:function(d,l){return e.VDhQg(d,l)},oZOhH:"success",OygMp:e[n(1541)],DBUTW:"ping_onc"+n(516)+"t"};return new Promise((d,l)=>{let h=n,m={xcFSZ:function(b,g){return e.dkIoV(b,g)},zMaNC:h(442)+"e_timeout"};if(e.pJIGa(e[h(178)],h(1397)))return _0x5124c2|=0,{low:_0x48cd09,high:EWTteZ[h(601)](_0x9b9fa6,31),unsigned:EWTteZ.AtIHM(_0x214db8,0)};{this._clearPingTimer(),this[h(1646)+h(1566)+"Id"]=e.fMQBn(setTimeout,this[h(310)][h(608)](this),this[h(1095)][h(934)+h(837)]);let b=()=>{let T=h;s[T(574)](d,s.oZOhH),this.off(s[T(898)],b),this[T(1243)](s[T(1040)],g)},g=()=>{let T=h;m[T(1488)](l,T(915)),this[T(1243)](T(442)+T(1649)+"s",b),this[T(1243)](m[T(1187)],g)};this.on(e[h(1541)],b),this.on(e[h(582)],g),this._ping()}})}}})(),Ie["CustomCl"+M(1513)]=be[M(1211)+M(1513)],Ie[M(1085)+M(272)]=be[M(1085)+M(272)],Ie[M(1116)+"e"]=be.ErrorCode,Ie[M(1525)]=be[M(1525)],Ie[M(603)]=be[M(603)],Ie[M(1467)+"MessageE"+M(240)]=be[M(1467)+"MessageE"+M(240)],Ie["MessageE"+M(240)]=be[M(498)+M(240)],Ie[M(879)+"t"]=be[M(879)+"t"],Ie[M(1275)+M(1556)]=be[M(1275)+M(1556)],Ie[M(1065)+M(1513)]=be[M(1065)+M(1513)],Ie[M(1297)+M(272)]=be.createErrorEvent,Ie[M(1583)+"ssageEvent"]=be[M(1583)+M(528)+"nt"],Ie[M(529)+M(478)]=be[M(529)+M(478)],Ie["createRe"+M(815)+M(240)]=be["createRe"+M(815)+M(240)],Ie[M(1517)+"rame"]=be[M(1517)+M(382)],Ie[M(1330)+M(797)]=be[M(1330)+"ame"];for($s in be)[M(1211)+M(1513),M(1085)+"rorEvent",M(1116)+"e",M(1525),M(603),"Frontier"+M(498)+"vent","MessageE"+M(240),M(879)+"t",M(1275)+M(1556),M(1065)+M(1513),M(1297)+M(272),"createMe"+M(528)+"nt","createOpenEvent",M(646)+M(815)+M(240),M(1517)+M(382),M(1330)+"ame"].indexOf($s)===-1&&(Ie[$s]=be[$s]);var $s;Object["definePr"+M(1516)](Ie,"__esModule",{value:!0})});var Mt=ne((E4,dl)=>{"use strict";var al=["nodebuffer","arraybuffer","fragments"],cl=typeof Blob<"u";cl&&al.push("blob");dl.exports={BINARY_TYPES:al,CLOSE_TIMEOUT:3e4,EMPTY_BUFFER:Buffer.alloc(0),GUID:"258EAFA5-E914-47DA-95CA-C5AB0DC85B11",hasBlob:cl,kForOnEventAttribute:Symbol("kIsForOnEventAttribute"),kListener:Symbol("kListener"),kStatusCode:Symbol("status-code"),kWebSocket:Symbol("websocket"),NOOP:()=>{}}});var Ei=ne((b4,eo)=>{"use strict";var{EMPTY_BUFFER:my}=Mt(),Ec=Buffer[Symbol.species];function wy(t,e){if(t.length===0)return my;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 Ec(r.buffer,r.byteOffset,i):r}function fl(t,e,r,i,o){for(let c=0;c<o;c++)r[i+c]=t[c]^e[c&3]}function ul(t,e){for(let r=0;r<t.length;r++)t[r]^=e[r&3]}function _y(t){return t.length===t.buffer.byteLength?t.buffer:t.buffer.slice(t.byteOffset,t.byteOffset+t.length)}function bc(t){if(bc.readOnly=!0,Buffer.isBuffer(t))return t;let e;return t instanceof ArrayBuffer?e=new Ec(t):ArrayBuffer.isView(t)?e=new Ec(t.buffer,t.byteOffset,t.byteLength):(e=Buffer.from(t),bc.readOnly=!1),e}eo.exports={concat:wy,mask:fl,toArrayBuffer:_y,toBuffer:bc,unmask:ul};if(!process.env.WS_NO_BUFFER_UTIL)try{let t=ae("bufferutil");eo.exports.mask=function(e,r,i,o,c){c<48?fl(e,r,i,o,c):t.mask(e,r,i,o,c)},eo.exports.unmask=function(e,r){e.length<32?ul(e,r):t.unmask(e,r)}}catch{}});var hl=ne((v4,xl)=>{"use strict";var ll=Symbol("kDone"),vc=Symbol("kRun"),Sc=class{constructor(e){this[ll]=()=>{this.pending--,this[vc]()},this.concurrency=e||1/0,this.jobs=[],this.pending=0}add(e){this.jobs.push(e),this[vc]()}[vc](){if(this.pending!==this.concurrency&&this.jobs.length){let e=this.jobs.shift();this.pending++,e(this[ll])}}};xl.exports=Sc});var Er=ne((S4,wl)=>{"use strict";var bi=ae("zlib"),pl=Ei(),yy=hl(),{kStatusCode:gl}=Mt(),Ey=Buffer[Symbol.species],by=Buffer.from([0,0,255,255]),no=Symbol("permessage-deflate"),Bt=Symbol("total-length"),_r=Symbol("callback"),un=Symbol("buffers"),yr=Symbol("error"),to,Ic=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,!to){let r=this._options.concurrencyLimit!==void 0?this._options.concurrencyLimit:10;to=new yy(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[_r];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){to.add(o=>{this._decompress(e,r,(c,f)=>{o(),i(c,f)})})}compress(e,r,i){to.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[no]=this,this._inflate[Bt]=0,this._inflate[un]=[],this._inflate.on("error",Sy),this._inflate.on("data",ml)}this._inflate[_r]=i,this._inflate.write(e),r&&this._inflate.write(by),this._inflate.flush(()=>{let c=this._inflate[yr];if(c){this._inflate.close(),this._inflate=null,i(c);return}let f=pl.concat(this._inflate[un],this._inflate[Bt]);this._inflate._readableState.endEmitted?(this._inflate.close(),this._inflate=null):(this._inflate[Bt]=0,this._inflate[un]=[],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[Bt]=0,this._deflate[un]=[],this._deflate.on("data",vy)}this._deflate[_r]=i,this._deflate.write(e),this._deflate.flush(bi.Z_SYNC_FLUSH,()=>{if(!this._deflate)return;let c=pl.concat(this._deflate[un],this._deflate[Bt]);r&&(c=new Ey(c.buffer,c.byteOffset,c.length-4)),this._deflate[_r]=null,this._deflate[Bt]=0,this._deflate[un]=[],r&&this.params[`${o}_no_context_takeover`]&&this._deflate.reset(),i(null,c)})}};wl.exports=Ic;function vy(t){this[un].push(t),this[Bt]+=t.length}function ml(t){if(this[Bt]+=t.length,this[no]._maxPayload<1||this[Bt]<=this[no]._maxPayload){this[un].push(t);return}this[yr]=new RangeError("Max payload size exceeded"),this[yr].code="WS_ERR_UNSUPPORTED_MESSAGE_LENGTH",this[yr][gl]=1009,this.removeListener("data",ml),this.reset()}function Sy(t){if(this[no]._inflate=null,this[yr]){this[_r](this[yr]);return}t[gl]=1007,this[_r](t)}});var br=ne((I4,ro)=>{"use strict";var{isUtf8:_l}=ae("buffer"),{hasBlob:Iy}=Mt(),Ay=[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 Ty(t){return t>=1e3&&t<=1014&&t!==1004&&t!==1005&&t!==1006||t>=3e3&&t<=4999}function Ac(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 Cy(t){return Iy&&typeof t=="object"&&typeof t.arrayBuffer=="function"&&typeof t.type=="string"&&typeof t.stream=="function"&&(t[Symbol.toStringTag]==="Blob"||t[Symbol.toStringTag]==="File")}ro.exports={isBlob:Cy,isValidStatusCode:Ty,isValidUTF8:Ac,tokenChars:Ay};if(_l)ro.exports.isValidUTF8=function(t){return t.length<24?Ac(t):_l(t)};else if(!process.env.WS_NO_UTF_8_VALIDATE)try{let t=ae("utf-8-validate");ro.exports.isValidUTF8=function(e){return e.length<32?Ac(e):t(e)}}catch{}});var kc=ne((A4,Al)=>{"use strict";var{Writable:Ry}=ae("stream"),yl=Er(),{BINARY_TYPES:Dy,EMPTY_BUFFER:El,kStatusCode:ky,kWebSocket:Oy}=Mt(),{concat:Tc,toArrayBuffer:Py,unmask:Ly}=Ei(),{isValidStatusCode:Ny,isValidUTF8:bl}=br(),io=Buffer[Symbol.species],nt=0,vl=1,Sl=2,Il=3,Cc=4,Rc=5,so=6,Dc=class extends Ry{constructor(e={}){super(),this._allowSynchronousEvents=e.allowSynchronousEvents!==void 0?e.allowSynchronousEvents:!0,this._binaryType=e.binaryType||Dy[0],this._extensions=e.extensions||{},this._isServer=!!e.isServer,this._maxPayload=e.maxPayload|0,this._skipUTF8Validation=!!e.skipUTF8Validation,this[Oy]=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=nt}_write(e,r,i){if(this._opcode===8&&this._state==nt)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 io(i.buffer,i.byteOffset+e,i.length-e),new io(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 io(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 nt:this.getInfo(e);break;case vl:this.getPayloadLength16(e);break;case Sl:this.getPayloadLength64(e);break;case Il:this.getMask();break;case Cc:this.getData(e);break;case Rc:case so: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[yl.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=vl:this._payloadLength===127?this._state=Sl: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=Il:this._state=Cc}getMask(){if(this._bufferedBytes<4){this._loop=!1;return}this._mask=this.consume(4),this._state=Cc}getData(e){let r=El;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&&Ly(r,this._mask)}if(this._opcode>7){this.controlMessage(r,e);return}if(this._compressed){this._state=Rc,this.decompress(r,e);return}r.length&&(this._messageLength=this._totalPayloadLength,this._fragments.push(r)),this.dataMessage(e)}decompress(e,r){this._extensions[yl.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===nt&&this.startLoop(r)})}dataMessage(e){if(!this._fin){this._state=nt;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=Tc(i,r):this._binaryType==="arraybuffer"?o=Py(Tc(i,r)):this._binaryType==="blob"?o=new Blob(i):o=i,this._allowSynchronousEvents?(this.emit("message",o,!0),this._state=nt):(this._state=so,setImmediate(()=>{this.emit("message",o,!0),this._state=nt,this.startLoop(e)}))}else{let o=Tc(i,r);if(!this._skipUTF8Validation&&!bl(o)){let c=this.createError(Error,"invalid UTF-8 sequence",!0,1007,"WS_ERR_INVALID_UTF8");e(c);return}this._state===Rc||this._allowSynchronousEvents?(this.emit("message",o,!1),this._state=nt):(this._state=so,setImmediate(()=>{this.emit("message",o,!1),this._state=nt,this.startLoop(e)}))}}controlMessage(e,r){if(this._opcode===8){if(e.length===0)this._loop=!1,this.emit("conclude",1005,El),this.end();else{let i=e.readUInt16BE(0);if(!Ny(i)){let c=this.createError(RangeError,`invalid status code ${i}`,!0,1002,"WS_ERR_INVALID_CLOSE_CODE");r(c);return}let o=new io(e.buffer,e.byteOffset+2,e.length-2);if(!this._skipUTF8Validation&&!bl(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=nt;return}this._allowSynchronousEvents?(this.emit(this._opcode===9?"ping":"pong",e),this._state=nt):(this._state=so,setImmediate(()=>{this.emit(this._opcode===9?"ping":"pong",e),this._state=nt,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[ky]=o,f}};Al.exports=Dc});var Lc=ne((C4,Rl)=>{"use strict";var{Duplex:T4}=ae("stream"),{randomFillSync:My}=ae("crypto"),Tl=Er(),{EMPTY_BUFFER:By,kWebSocket:zy,NOOP:Fy}=Mt(),{isBlob:vr,isValidStatusCode:Uy}=br(),{mask:Cl,toBuffer:kn}=Ei(),rt=Symbol("kByteLength"),Hy=Buffer.alloc(4),oo=8*1024,On,Sr=oo,lt=0,qy=1,Gy=2,Oc=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=lt,this.onerror=Fy,this[zy]=void 0}static frame(e,r){let i,o=!1,c=2,f=!1;r.mask&&(i=r.maskBuffer||Hy,r.generateMask?r.generateMask(i):(Sr===oo&&(On===void 0&&(On=Buffer.alloc(oo)),My(On,0,oo),Sr=0),i[0]=On[Sr++],i[1]=On[Sr++],i[2]=On[Sr++],i[3]=On[Sr++]),f=(i[0]|i[1]|i[2]|i[3])===0,c=6);let u;typeof e=="string"?(!r.mask||f)&&r[rt]!==void 0?u=r[rt]:(e=Buffer.from(e),u=e.length):(u=e.length,o=r.mask&&r.readOnly&&!f);let x=u;u>=65536?(c+=8,x=127):u>125&&(c+=2,x=126);let p=Buffer.allocUnsafe(o?u+c:c);return p[0]=r.fin?r.opcode|128:r.opcode,r.rsv1&&(p[0]|=64),p[1]=x,x===126?p.writeUInt16BE(u,2):x===127&&(p[2]=p[3]=0,p.writeUIntBE(u,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?(Cl(e,i,p,c,u),[p]):(Cl(e,i,e,0,u),[p,e])):[p,e]}close(e,r,i,o){let c;if(e===void 0)c=By;else{if(typeof e!="number"||!Uy(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 u=Buffer.byteLength(r);if(u>123)throw new RangeError("The message must not be greater than 123 bytes");c=Buffer.allocUnsafe(2+u),c.writeUInt16BE(e,0),typeof r=="string"?c.write(r,2):c.set(r,2)}}let f={[rt]:c.length,fin:!0,generateMask:this._generateMask,mask:i,maskBuffer:this._maskBuffer,opcode:8,readOnly:!1,rsv1:!1};this._state!==lt?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):vr(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={[rt]:o,fin:!0,generateMask:this._generateMask,mask:r,maskBuffer:this._maskBuffer,opcode:9,readOnly:c,rsv1:!1};vr(e)?this._state!==lt?this.enqueue([this.getBlobData,e,!1,f,i]):this.getBlobData(e,!1,f,i):this._state!==lt?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):vr(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={[rt]:o,fin:!0,generateMask:this._generateMask,mask:r,maskBuffer:this._maskBuffer,opcode:10,readOnly:c,rsv1:!1};vr(e)?this._state!==lt?this.enqueue([this.getBlobData,e,!1,f,i]):this.getBlobData(e,!1,f,i):this._state!==lt?this.enqueue([this.dispatch,e,!1,f,i]):this.sendFrame(t.frame(e,f),i)}send(e,r,i){let o=this._extensions[Tl.extensionName],c=r.binary?2:1,f=r.compress,u,x;typeof e=="string"?(u=Buffer.byteLength(e),x=!1):vr(e)?(u=e.size,x=!1):(e=kn(e),u=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=u>=o._threshold),this._compress=f):(f=!1,c=0),r.fin&&(this._firstFragment=!0);let p={[rt]:u,fin:r.fin,generateMask:this._generateMask,mask:r.mask,maskBuffer:this._maskBuffer,opcode:c,readOnly:x,rsv1:f};vr(e)?this._state!==lt?this.enqueue([this.getBlobData,e,this._compress,p,i]):this.getBlobData(e,this._compress,p,i):this._state!==lt?this.enqueue([this.dispatch,e,this._compress,p,i]):this.dispatch(e,this._compress,p,i)}getBlobData(e,r,i,o){this._bufferedBytes+=i[rt],this._state=Gy,e.arrayBuffer().then(c=>{if(this._socket.destroyed){let u=new Error("The socket was closed while the blob was being read");process.nextTick(Pc,this,u,o);return}this._bufferedBytes-=i[rt];let f=kn(c);r?this.dispatch(f,r,i,o):(this._state=lt,this.sendFrame(t.frame(f,i),o),this.dequeue())}).catch(c=>{process.nextTick(jy,this,c,o)})}dispatch(e,r,i,o){if(!r){this.sendFrame(t.frame(e,i),o);return}let c=this._extensions[Tl.extensionName];this._bufferedBytes+=i[rt],this._state=qy,c.compress(e,i.fin,(f,u)=>{if(this._socket.destroyed){let x=new Error("The socket was closed while data was being compressed");Pc(this,x,o);return}this._bufferedBytes-=i[rt],this._state=lt,i.readOnly=!1,this.sendFrame(t.frame(u,i),o),this.dequeue()})}dequeue(){for(;this._state===lt&&this._queue.length;){let e=this._queue.shift();this._bufferedBytes-=e[3][rt],Reflect.apply(e[0],this,e.slice(1))}}enqueue(e){this._bufferedBytes+=e[3][rt],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)}};Rl.exports=Oc;function Pc(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 jy(t,e,r){Pc(t,e,r),t.onerror(e)}});var zl=ne((R4,Bl)=>{"use strict";var{kForOnEventAttribute:vi,kListener:Nc}=Mt(),Dl=Symbol("kCode"),kl=Symbol("kData"),Ol=Symbol("kError"),Pl=Symbol("kMessage"),Ll=Symbol("kReason"),Ir=Symbol("kTarget"),Nl=Symbol("kType"),Ml=Symbol("kWasClean"),zt=class{constructor(e){this[Ir]=null,this[Nl]=e}get target(){return this[Ir]}get type(){return this[Nl]}};Object.defineProperty(zt.prototype,"target",{enumerable:!0});Object.defineProperty(zt.prototype,"type",{enumerable:!0});var Pn=class extends zt{constructor(e,r={}){super(e),this[Dl]=r.code===void 0?0:r.code,this[Ll]=r.reason===void 0?"":r.reason,this[Ml]=r.wasClean===void 0?!1:r.wasClean}get code(){return this[Dl]}get reason(){return this[Ll]}get wasClean(){return this[Ml]}};Object.defineProperty(Pn.prototype,"code",{enumerable:!0});Object.defineProperty(Pn.prototype,"reason",{enumerable:!0});Object.defineProperty(Pn.prototype,"wasClean",{enumerable:!0});var Ar=class extends zt{constructor(e,r={}){super(e),this[Ol]=r.error===void 0?null:r.error,this[Pl]=r.message===void 0?"":r.message}get error(){return this[Ol]}get message(){return this[Pl]}};Object.defineProperty(Ar.prototype,"error",{enumerable:!0});Object.defineProperty(Ar.prototype,"message",{enumerable:!0});var Si=class extends zt{constructor(e,r={}){super(e),this[kl]=r.data===void 0?null:r.data}get data(){return this[kl]}};Object.defineProperty(Si.prototype,"data",{enumerable:!0});var Ky={addEventListener(t,e,r={}){for(let o of this.listeners(t))if(!r[vi]&&o[Nc]===e&&!o[vi])return;let i;if(t==="message")i=function(c,f){let u=new Si("message",{data:f?c:c.toString()});u[Ir]=this,ao(e,this,u)};else if(t==="close")i=function(c,f){let u=new Pn("close",{code:c,reason:f.toString(),wasClean:this._closeFrameReceived&&this._closeFrameSent});u[Ir]=this,ao(e,this,u)};else if(t==="error")i=function(c){let f=new Ar("error",{error:c,message:c.message});f[Ir]=this,ao(e,this,f)};else if(t==="open")i=function(){let c=new zt("open");c[Ir]=this,ao(e,this,c)};else return;i[vi]=!!r[vi],i[Nc]=e,r.once?this.once(t,i):this.on(t,i)},removeEventListener(t,e){for(let r of this.listeners(t))if(r[Nc]===e&&!r[vi]){this.removeListener(t,r);break}}};Bl.exports={CloseEvent:Pn,ErrorEvent:Ar,Event:zt,EventTarget:Ky,MessageEvent:Si};function ao(t,e,r){typeof t=="object"&&t.handleEvent?t.handleEvent.call(t,r):t.call(e,r)}});var co=ne((D4,Fl)=>{"use strict";var{tokenChars:Ii}=br();function Tt(t,e,r){t[e]===void 0?t[e]=[r]:t[e].push(r)}function Wy(t){let e=Object.create(null),r=Object.create(null),i=!1,o=!1,c=!1,f,u,x=-1,p=-1,_=-1,y=0;for(;y<t.length;y++)if(p=t.charCodeAt(y),f===void 0)if(_===-1&&Ii[p]===1)x===-1&&(x=y);else if(y!==0&&(p===32||p===9))_===-1&&x!==-1&&(_=y);else if(p===59||p===44){if(x===-1)throw new SyntaxError(`Unexpected character at index ${y}`);_===-1&&(_=y);let E=t.slice(x,_);p===44?(Tt(e,E,r),r=Object.create(null)):f=E,x=_=-1}else throw new SyntaxError(`Unexpected character at index ${y}`);else if(u===void 0)if(_===-1&&Ii[p]===1)x===-1&&(x=y);else if(p===32||p===9)_===-1&&x!==-1&&(_=y);else if(p===59||p===44){if(x===-1)throw new SyntaxError(`Unexpected character at index ${y}`);_===-1&&(_=y),Tt(r,t.slice(x,_),!0),p===44&&(Tt(e,f,r),r=Object.create(null),f=void 0),x=_=-1}else if(p===61&&x!==-1&&_===-1)u=t.slice(x,y),x=_=-1;else throw new SyntaxError(`Unexpected character at index ${y}`);else if(o){if(Ii[p]!==1)throw new SyntaxError(`Unexpected character at index ${y}`);x===-1?x=y:i||(i=!0),o=!1}else if(c)if(Ii[p]===1)x===-1&&(x=y);else if(p===34&&x!==-1)c=!1,_=y;else if(p===92)o=!0;else throw new SyntaxError(`Unexpected character at index ${y}`);else if(p===34&&t.charCodeAt(y-1)===61)c=!0;else if(_===-1&&Ii[p]===1)x===-1&&(x=y);else if(x!==-1&&(p===32||p===9))_===-1&&(_=y);else if(p===59||p===44){if(x===-1)throw new SyntaxError(`Unexpected character at index ${y}`);_===-1&&(_=y);let E=t.slice(x,_);i&&(E=E.replace(/\\/g,""),i=!1),Tt(r,u,E),p===44&&(Tt(e,f,r),r=Object.create(null),f=void 0),u=void 0,x=_=-1}else throw new SyntaxError(`Unexpected character at index ${y}`);if(x===-1||c||p===32||p===9)throw new SyntaxError("Unexpected end of input");_===-1&&(_=y);let A=t.slice(x,_);return f===void 0?Tt(e,A,r):(u===void 0?Tt(r,A,!0):i?Tt(r,u,A.replace(/\\/g,"")):Tt(r,u,A),Tt(e,f,r)),e}function $y(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(", ")}Fl.exports={format:$y,parse:Wy}});var xo=ne((P4,Yl)=>{"use strict";var Jy=ae("events"),Zy=ae("https"),Vy=ae("http"),ql=ae("net"),Yy=ae("tls"),{randomBytes:Xy,createHash:Qy}=ae("crypto"),{Duplex:k4,Readable:O4}=ae("stream"),{URL:Mc}=ae("url"),ln=Er(),e1=kc(),t1=Lc(),{isBlob:n1}=br(),{BINARY_TYPES:Ul,CLOSE_TIMEOUT:r1,EMPTY_BUFFER:fo,GUID:i1,kForOnEventAttribute:Bc,kListener:s1,kStatusCode:o1,kWebSocket:Le,NOOP:Gl}=Mt(),{EventTarget:{addEventListener:a1,removeEventListener:c1}}=zl(),{format:d1,parse:f1}=co(),{toBuffer:u1}=Ei(),jl=Symbol("kAborted"),zc=[8,13],Ft=["CONNECTING","OPEN","CLOSING","CLOSED"],l1=/^[!#$%&'*+\-.0-9A-Z^_`|a-z~]+$/,de=class t extends Jy{constructor(e,r,i){super(),this._binaryType=Ul[0],this._closeCode=1006,this._closeFrameReceived=!1,this._closeFrameSent=!1,this._closeMessage=fo,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]),Kl(this,e,r,i)):(this._autoPong=i.autoPong,this._closeTimeout=i.closeTimeout,this._isServer=!0)}get binaryType(){return this._binaryType}set binaryType(e){Ul.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 e1({allowSynchronousEvents:i.allowSynchronousEvents,binaryType:this.binaryType,extensions:this._extensions,isServer:this._isServer,maxPayload:i.maxPayload,skipUTF8Validation:i.skipUTF8Validation}),c=new t1(e,this._extensions,i.generateMask);this._receiver=o,this._sender=c,this._socket=e,o[Le]=this,c[Le]=this,e[Le]=this,o.on("conclude",p1),o.on("drain",g1),o.on("error",m1),o.on("message",w1),o.on("ping",_1),o.on("pong",y1),c.onerror=E1,e.setTimeout&&e.setTimeout(0),e.setNoDelay&&e.setNoDelay(),r.length>0&&e.unshift(r),e.on("close",Jl),e.on("data",lo),e.on("end",Zl),e.on("error",Vl),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[ln.extensionName]&&this._extensions[ln.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){Ye(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())}),$l(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){Fc(this,e,i);return}r===void 0&&(r=!this._isServer),this._sender.ping(e||fo,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){Fc(this,e,i);return}r===void 0&&(r=!this._isServer),this._sender.pong(e||fo,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){Fc(this,e,i);return}let o={binary:typeof e!="string",mask:!this._isServer,compress:!0,fin:!0,...r};this._extensions[ln.extensionName]||(o.compress=!1),this._sender.send(e||fo,o,i)}terminate(){if(this.readyState!==t.CLOSED){if(this.readyState===t.CONNECTING){Ye(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:Ft.indexOf("CONNECTING")});Object.defineProperty(de.prototype,"CONNECTING",{enumerable:!0,value:Ft.indexOf("CONNECTING")});Object.defineProperty(de,"OPEN",{enumerable:!0,value:Ft.indexOf("OPEN")});Object.defineProperty(de.prototype,"OPEN",{enumerable:!0,value:Ft.indexOf("OPEN")});Object.defineProperty(de,"CLOSING",{enumerable:!0,value:Ft.indexOf("CLOSING")});Object.defineProperty(de.prototype,"CLOSING",{enumerable:!0,value:Ft.indexOf("CLOSING")});Object.defineProperty(de,"CLOSED",{enumerable:!0,value:Ft.indexOf("CLOSED")});Object.defineProperty(de.prototype,"CLOSED",{enumerable:!0,value:Ft.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[Bc])return e[s1];return null},set(e){for(let r of this.listeners(t))if(r[Bc]){this.removeListener(t,r);break}typeof e=="function"&&this.addEventListener(t,e,{[Bc]:!0})}})});de.prototype.addEventListener=a1;de.prototype.removeEventListener=c1;Yl.exports=de;function Kl(t,e,r,i){let o={allowSynchronousEvents:!0,autoPong:!0,closeTimeout:r1,protocolVersion:zc[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,!zc.includes(o.protocolVersion))throw new RangeError(`Unsupported protocol version: ${o.protocolVersion} (supported versions: ${zc.join(", ")})`);let c;if(e instanceof Mc)c=e;else try{c=new Mc(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:",u=c.protocol==="ws+unix:",x;if(c.protocol!=="ws:"&&!f&&!u?x=`The URL's protocol must be one of "ws:", "wss:", "http:", "https:", or "ws+unix:"`:u&&!c.pathname?x="The URL's pathname is empty":c.hash&&(x="The URL contains a fragment identifier"),x){let S=new SyntaxError(x);if(t._redirects===0)throw S;uo(t,S);return}let p=f?443:80,_=Xy(16).toString("base64"),y=f?Zy.request:Vy.request,A=new Set,E;if(o.createConnection=o.createConnection||(f?h1:x1),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":_,Connection:"Upgrade",Upgrade:"websocket"},o.path=c.pathname+c.search,o.timeout=o.handshakeTimeout,o.perMessageDeflate&&(E=new ln({...o.perMessageDeflate,isServer:!1,maxPayload:o.maxPayload}),o.headers["Sec-WebSocket-Extensions"]=d1({[ln.extensionName]:E.offer()})),r.length){for(let S of r){if(typeof S!="string"||!l1.test(S)||A.has(S))throw new SyntaxError("An invalid or duplicated subprotocol was specified");A.add(S)}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}`),u){let S=o.path.split(":");o.socketPath=S[0],o.path=S[1]}let v;if(o.followRedirects){if(t._redirects===0){t._originalIpc=u,t._originalSecure=f,t._originalHostOrSocketPath=u?o.socketPath:c.host;let S=i&&i.headers;if(i={...i,headers:{}},S)for(let[I,D]of Object.entries(S))i.headers[I.toLowerCase()]=D}else if(t.listenerCount("redirect")===0){let S=u?t._originalIpc?o.socketPath===t._originalHostOrSocketPath:!1:t._originalIpc?!1:c.host===t._originalHostOrSocketPath;(!S||t._originalSecure&&!f)&&(delete o.headers.authorization,delete o.headers.cookie,S||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=y(o),t._redirects&&t.emit("redirect",t.url,v)}else v=t._req=y(o);o.timeout&&v.on("timeout",()=>{Ye(t,v,"Opening handshake has timed out")}),v.on("error",S=>{v===null||v[jl]||(v=t._req=null,uo(t,S))}),v.on("response",S=>{let I=S.headers.location,D=S.statusCode;if(I&&o.followRedirects&&D>=300&&D<400){if(++t._redirects>o.maxRedirects){Ye(t,v,"Maximum redirects exceeded");return}v.abort();let P;try{P=new Mc(I,e)}catch{let C=new SyntaxError(`Invalid URL: ${I}`);uo(t,C);return}Kl(t,P,r,i)}else t.emit("unexpected-response",v,S)||Ye(t,v,`Unexpected server response: ${S.statusCode}`)}),v.on("upgrade",(S,I,D)=>{if(t.emit("upgrade",S),t.readyState!==de.CONNECTING)return;v=t._req=null;let P=S.headers.upgrade;if(P===void 0||P.toLowerCase()!=="websocket"){Ye(t,I,"Invalid Upgrade header");return}let w=Qy("sha1").update(_+i1).digest("base64");if(S.headers["sec-websocket-accept"]!==w){Ye(t,I,"Invalid Sec-WebSocket-Accept header");return}let C=S.headers["sec-websocket-protocol"],O;if(C!==void 0?A.size?A.has(C)||(O="Server sent an invalid subprotocol"):O="Server sent a subprotocol but none was requested":A.size&&(O="Server sent no subprotocol"),O){Ye(t,I,O);return}C&&(t._protocol=C);let z=S.headers["sec-websocket-extensions"];if(z!==void 0){if(!E){Ye(t,I,"Server sent a Sec-WebSocket-Extensions header but no extension was requested");return}let B;try{B=f1(z)}catch{Ye(t,I,"Invalid Sec-WebSocket-Extensions header");return}let k=Object.keys(B);if(k.length!==1||k[0]!==ln.extensionName){Ye(t,I,"Server indicated an extension that was not requested");return}try{E.accept(B[ln.extensionName])}catch{Ye(t,I,"Invalid Sec-WebSocket-Extensions header");return}t._extensions[ln.extensionName]=E}t.setSocket(I,D,{allowSynchronousEvents:o.allowSynchronousEvents,generateMask:o.generateMask,maxPayload:o.maxPayload,skipUTF8Validation:o.skipUTF8Validation})}),o.finishRequest?o.finishRequest(v,t):v.end()}function uo(t,e){t._readyState=de.CLOSING,t._errorEmitted=!0,t.emit("error",e),t.emitClose()}function x1(t){return t.path=t.socketPath,ql.connect(t)}function h1(t){return t.path=void 0,!t.servername&&t.servername!==""&&(t.servername=ql.isIP(t.host)?"":t.host),Yy.connect(t)}function Ye(t,e,r){t._readyState=de.CLOSING;let i=new Error(r);Error.captureStackTrace(i,Ye),e.setHeader?(e[jl]=!0,e.abort(),e.socket&&!e.socket.destroyed&&e.socket.destroy(),process.nextTick(uo,t,i)):(e.destroy(i),e.once("error",t.emit.bind(t,"error")),e.once("close",t.emitClose.bind(t)))}function Fc(t,e,r){if(e){let i=n1(e)?e.size:u1(e).length;t._socket?t._sender._bufferedBytes+=i:t._bufferedAmount+=i}if(r){let i=new Error(`WebSocket is not open: readyState ${t.readyState} (${Ft[t.readyState]})`);process.nextTick(r,i)}}function p1(t,e){let r=this[Le];r._closeFrameReceived=!0,r._closeMessage=e,r._closeCode=t,r._socket[Le]!==void 0&&(r._socket.removeListener("data",lo),process.nextTick(Wl,r._socket),t===1005?r.close():r.close(t,e))}function g1(){let t=this[Le];t.isPaused||t._socket.resume()}function m1(t){let e=this[Le];e._socket[Le]!==void 0&&(e._socket.removeListener("data",lo),process.nextTick(Wl,e._socket),e.close(t[o1])),e._errorEmitted||(e._errorEmitted=!0,e.emit("error",t))}function Hl(){this[Le].emitClose()}function w1(t,e){this[Le].emit("message",t,e)}function _1(t){let e=this[Le];e._autoPong&&e.pong(t,!this._isServer,Gl),e.emit("ping",t)}function y1(t){this[Le].emit("pong",t)}function Wl(t){t.resume()}function E1(t){let e=this[Le];e.readyState!==de.CLOSED&&(e.readyState===de.OPEN&&(e._readyState=de.CLOSING,$l(e)),this._socket.end(),e._errorEmitted||(e._errorEmitted=!0,e.emit("error",t)))}function $l(t){t._closeTimer=setTimeout(t._socket.destroy.bind(t._socket),t._closeTimeout)}function Jl(){let t=this[Le];if(this.removeListener("close",Jl),this.removeListener("data",lo),this.removeListener("end",Zl),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[Le]=void 0,clearTimeout(t._closeTimer),t._receiver._writableState.finished||t._receiver._writableState.errorEmitted?t.emitClose():(t._receiver.on("error",Hl),t._receiver.on("finish",Hl))}function lo(t){this[Le]._receiver.write(t)||this.pause()}function Zl(){let t=this[Le];t._readyState=de.CLOSING,t._receiver.end(),this.end()}function Vl(){let t=this[Le];this.removeListener("error",Vl),this.on("error",Gl),t&&(t._readyState=de.CLOSING,this.destroy())}});var tx=ne((N4,ex)=>{"use strict";var L4=xo(),{Duplex:b1}=ae("stream");function Xl(t){t.emit("close")}function v1(){!this.destroyed&&this._writableState.finished&&this.destroy()}function Ql(t){this.removeListener("error",Ql),this.destroy(),this.listenerCount("error")===0&&this.emit("error",t)}function S1(t,e){let r=!0,i=new b1({...e,autoDestroy:!1,emitClose:!1,objectMode:!1,writableObjectMode:!1});return t.on("message",function(c,f){let u=!f&&i._readableState.objectMode?c.toString():c;i.push(u)||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(Xl,i);return}let f=!1;t.once("error",function(x){f=!0,c(x)}),t.once("close",function(){f||c(o),process.nextTick(Xl,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",v1),i.on("error",Ql),i}ex.exports=S1});var Uc=ne((M4,nx)=>{"use strict";var{tokenChars:I1}=br();function A1(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&&I1[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 u=t.slice(r,i);if(e.has(u))throw new SyntaxError(`The "${u}" subprotocol is duplicated`);e.add(u),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}nx.exports={parse:A1}});var dx=ne((z4,cx)=>{"use strict";var T1=ae("events"),ho=ae("http"),{Duplex:B4}=ae("stream"),{createHash:C1}=ae("crypto"),rx=co(),Ln=Er(),R1=Uc(),D1=xo(),{CLOSE_TIMEOUT:k1,GUID:O1,kWebSocket:P1}=Mt(),L1=/^[+/0-9A-Za-z]{22}==$/,ix=0,sx=1,ax=2,Hc=class extends T1{constructor(e,r){if(super(),e={allowSynchronousEvents:!0,autoPong:!0,maxPayload:100*1024*1024,skipUTF8Validation:!1,perMessageDeflate:!1,handleProtocols:null,clientTracking:!0,closeTimeout:k1,verifyClient:null,noServer:!1,backlog:null,server:null,host:null,path:null,port:null,WebSocket:D1,...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=ho.createServer((i,o)=>{let c=ho.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=N1(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=ix}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===ax){e&&this.once("close",()=>{e(new Error("The server is not running"))}),process.nextTick(Ai,this);return}if(e&&this.once("close",e),this._state!==sx)if(this._state=sx,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(Ai,this):process.nextTick(Ai,this);else{let r=this._server;this._removeListeners(),this._removeListeners=this._server=null,r.close(()=>{Ai(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",ox);let c=e.headers["sec-websocket-key"],f=e.headers.upgrade,u=+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||!L1.test(c)){Nn(this,e,r,400,"Missing or invalid Sec-WebSocket-Key header");return}if(u!==13&&u!==8){Nn(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"],p=new Set;if(x!==void 0)try{p=R1.parse(x)}catch{Nn(this,e,r,400,"Invalid Sec-WebSocket-Protocol header");return}let _=e.headers["sec-websocket-extensions"],y={};if(this.options.perMessageDeflate&&_!==void 0){let A=new Ln({...this.options.perMessageDeflate,isServer:!0,maxPayload:this.options.maxPayload});try{let E=rx.parse(_);E[Ln.extensionName]&&(A.accept(E[Ln.extensionName]),y[Ln.extensionName]=A)}catch{Nn(this,e,r,400,"Invalid or unacceptable Sec-WebSocket-Extensions header");return}}if(this.options.verifyClient){let A={origin:e.headers[`${u===8?"sec-websocket-origin":"origin"}`],secure:!!(e.socket.authorized||e.socket.encrypted),req:e};if(this.options.verifyClient.length===2){this.options.verifyClient(A,(E,v,S,I)=>{if(!E)return Ti(r,v||401,S,I);this.completeUpgrade(y,c,p,e,r,i,o)});return}if(!this.options.verifyClient(A))return Ti(r,401)}this.completeUpgrade(y,c,p,e,r,i,o)}completeUpgrade(e,r,i,o,c,f,u){if(!c.readable||!c.writable)return c.destroy();if(c[P1])throw new Error("server.handleUpgrade() was called more than once with the same socket, possibly due to a misconfiguration");if(this._state>ix)return Ti(c,503);let p=["HTTP/1.1 101 Switching Protocols","Upgrade: websocket","Connection: Upgrade",`Sec-WebSocket-Accept: ${C1("sha1").update(r+O1).digest("base64")}`],_=new this.options.WebSocket(null,void 0,this.options);if(i.size){let y=this.options.handleProtocols?this.options.handleProtocols(i,o):i.values().next().value;y&&(p.push(`Sec-WebSocket-Protocol: ${y}`),_._protocol=y)}if(e[Ln.extensionName]){let y=e[Ln.extensionName].params,A=rx.format({[Ln.extensionName]:[y]});p.push(`Sec-WebSocket-Extensions: ${A}`),_._extensions=e}this.emit("headers",p,o),c.write(p.concat(`\r
15
15
  `).join(`\r
16
- `)),c.removeListener("error",ox),w.setSocket(c,d,{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(Ai,this)})),l(w,a)}};cx.exports=Gc;function Nb(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 Ai(t){t._state=ax,t.emit("close")}function ox(){this.destroy()}function Ri(t,e,r,s){r=r||go.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} ${go.STATUS_CODES[e]}\r
17
- `+Object.keys(s).map(a=>`${a}: ${s[a]}`).join(`\r
16
+ `)),c.removeListener("error",ox),_.setSocket(c,f,{allowSynchronousEvents:this.options.allowSynchronousEvents,maxPayload:this.options.maxPayload,skipUTF8Validation:this.options.skipUTF8Validation}),this.clients&&(this.clients.add(_),_.on("close",()=>{this.clients.delete(_),this._shouldEmitClose&&!this.clients.size&&process.nextTick(Ai,this)})),u(_,o)}};cx.exports=Hc;function N1(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 Ai(t){t._state=ax,t.emit("close")}function ox(){this.destroy()}function Ti(t,e,r,i){r=r||ho.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} ${ho.STATUS_CODES[e]}\r
17
+ `+Object.keys(i).map(o=>`${o}: ${i[o]}`).join(`\r
18
18
  `)+`\r
19
19
  \r
20
- `+r)}function Bn(t,e,r,s,a,c){if(t.listenerCount("wsClientError")){let d=new Error(a);Error.captureStackTrace(d,Bn),t.emit("wsClientError",d,r,e)}else Ri(r,s,a,c)}});import{existsSync as fE,openSync as dE}from"node:fs";import{mkdir as uE}from"node:fs/promises";import{dirname as lE}from"node:path";import{fileURLToPath as xE}from"node:url";function $c(t=ne()){return fE(t.libEntry)?t.libEntry:xE(new URL("../index.ts",import.meta.url))}async function Vc(t={}){let e=t.paths??ne(),r=t.entryOverride??$c(e);await uE(lE(e.logFile),{recursive:!0});let s=dE(e.logFile,"a"),c=r.endsWith(".ts")?["--import","tsx/esm",r,"--daemon"]:[r,"--daemon"],d=jn(process.execPath,c,{detached:!0,stdio:["ignore",s,s],env:{...process.env,COZE_BRIDGE_DAEMON:"1"}});if(d.unref(),typeof d.pid!="number")throw new Error("failed to spawn daemon (no pid)");return hE.info("daemon spawned",{pid:d.pid,entry:r}),{pid:d.pid,entry:r}}var hE,Zc=at(()=>{"use strict";Kn();te();Fe();hE=G("spawn-daemon")});import{spawn as RE}from"node:child_process";import{mkdir as DE,unlink as kE,writeFile as OE}from"node:fs/promises";import{dirname as PE,join as LE}from"node:path";function Io(t){return t.replace(/&/g,"&amp;").replace(/</g,"&lt;").replace(/>/g,"&gt;").replace(/"/g,"&quot;")}function Ox(t,e){return new Promise((r,s)=>{let a=RE(t,e,{stdio:["ignore","pipe","pipe"]}),c="";a.stderr?.on("data",d=>{c+=d.toString("utf8")}),a.on("error",s),a.on("close",d=>{d===0?r():s(new Error(`${t} ${e.join(" ")} exited ${d}: ${c.trim()}`))})})}var So,Qc,e0,Px=at(()=>{"use strict";te();So=G("supervisor.launchd"),Qc="ai.coze.bridge",e0={platform:"darwin",renderConfig(t){return`<?xml version="1.0" encoding="UTF-8"?>
20
+ `+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 Ti(r,i,o,c)}});import{existsSync as dE,openSync as fE}from"node:fs";import{mkdir as uE}from"node:fs/promises";import{dirname as lE}from"node:path";import{fileURLToPath as xE}from"node:url";function Kc(t=te()){return dE(t.libEntry)?t.libEntry:xE(new URL("../index.ts",import.meta.url))}async function Wc(t={}){let e=t.paths??te(),r=t.entryOverride??Kc(e);await uE(lE(e.logFile),{recursive:!0});let i=fE(e.logFile,"a"),c=r.endsWith(".ts")?["--import","tsx/esm",r,"--daemon"]:[r,"--daemon"],f=qn(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 hE.info("daemon spawned",{pid:f.pid,entry:r}),{pid:f.pid,entry:r}}var hE,$c=ot(()=>{"use strict";jn();ee();Be();hE=G("spawn-daemon")});import{spawn as RE}from"node:child_process";import{mkdir as DE,unlink as kE,writeFile as OE}from"node:fs/promises";import{dirname as PE,join as LE}from"node:path";function vo(t){return t.replace(/&/g,"&amp;").replace(/</g,"&lt;").replace(/>/g,"&gt;").replace(/"/g,"&quot;")}function Ox(t,e){return new Promise((r,i)=>{let o=RE(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 bo,Yc,Xc,Px=ot(()=>{"use strict";ee();bo=G("supervisor.launchd"),Yc="ai.coze.bridge",Xc={platform:"darwin",renderConfig(t){return`<?xml version="1.0" encoding="UTF-8"?>
21
21
  <!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
22
22
  <plist version="1.0">
23
23
  <dict>
24
24
  <key>Label</key>
25
- <string>${Qc}</string>
25
+ <string>${Yc}</string>
26
26
  <key>ProgramArguments</key>
27
27
  <array>
28
- <string>${Io(t.nodeBin)}</string>
29
- <string>${Io(t.entry)}</string>
28
+ <string>${vo(t.nodeBin)}</string>
29
+ <string>${vo(t.entry)}</string>
30
30
  <string>--daemon</string>
31
31
  </array>
32
32
  <key>RunAtLoad</key>
@@ -36,12 +36,12 @@ ${t.stack??""}`:String(t);return tp.test(r)||np.test(r)}function P0(t){if(t==nul
36
36
  <key>ThrottleInterval</key>
37
37
  <integer>10</integer>
38
38
  <key>StandardOutPath</key>
39
- <string>${Io(t.logFile)}</string>
39
+ <string>${vo(t.logFile)}</string>
40
40
  <key>StandardErrorPath</key>
41
- <string>${Io(t.logFile)}</string>
41
+ <string>${vo(t.logFile)}</string>
42
42
  </dict>
43
43
  </plist>
44
- `},configPath(t){return LE(t.homeDir,"Library","LaunchAgents",`${Qc}.plist`)},async install(t){let e=this.configPath(t);await DE(PE(e),{recursive:!0}),await OE(e,this.renderConfig(t),"utf8"),So.info("plist written",{plistPath:e}),await Ox("launchctl",["load","-w",e]),So.info("launchd job loaded",{label:Qc})},async uninstall(t){let e=this.configPath(t);await Ox("launchctl",["unload","-w",e]).catch(r=>So.warn("launchctl unload failed (ignored)",{err:String(r)})),await kE(e).catch(r=>{if(r.code!=="ENOENT")throw r}),So.info("launchd job removed",{plistPath:e})}}});import{spawn as NE}from"node:child_process";import{mkdir as ME,unlink as BE,writeFile as zE}from"node:fs/promises";import{dirname as FE,join as UE}from"node:path";function Ao(t,e){return new Promise((r,s)=>{let a=NE(t,e,{stdio:["ignore","pipe","pipe"]}),c="";a.stderr?.on("data",d=>{c+=d.toString("utf8")}),a.on("error",s),a.on("close",d=>{d===0?r():s(new Error(`${t} ${e.join(" ")} exited ${d}: ${c.trim()}`))})})}var Co,To,t0,Lx=at(()=>{"use strict";te();Co=G("supervisor.systemd"),To="coze-bridge.service",t0={platform:"linux",renderConfig(t){return`[Unit]
44
+ `},configPath(t){return LE(t.homeDir,"Library","LaunchAgents",`${Yc}.plist`)},async install(t){let e=this.configPath(t);await DE(PE(e),{recursive:!0}),await OE(e,this.renderConfig(t),"utf8"),bo.info("plist written",{plistPath:e}),await Ox("launchctl",["load","-w",e]),bo.info("launchd job loaded",{label:Yc})},async uninstall(t){let e=this.configPath(t);await Ox("launchctl",["unload","-w",e]).catch(r=>bo.warn("launchctl unload failed (ignored)",{err:String(r)})),await kE(e).catch(r=>{if(r.code!=="ENOENT")throw r}),bo.info("launchd job removed",{plistPath:e})}}});import{spawn as NE}from"node:child_process";import{mkdir as ME,unlink as BE,writeFile as zE}from"node:fs/promises";import{dirname as FE,join as UE}from"node:path";function Ao(t,e){return new Promise((r,i)=>{let o=NE(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 So,Io,Qc,Lx=ot(()=>{"use strict";ee();So=G("supervisor.systemd"),Io="coze-bridge.service",Qc={platform:"linux",renderConfig(t){return`[Unit]
45
45
  Description=Coze Bridge daemon
46
46
  After=network.target
47
47
 
@@ -55,7 +55,7 @@ StandardError=append:${t.logFile}
55
55
 
56
56
  [Install]
57
57
  WantedBy=default.target
58
- `},configPath(t){return UE(t.homeDir,".config","systemd","user",To)},async install(t){let e=this.configPath(t);await ME(FE(e),{recursive:!0}),await zE(e,this.renderConfig(t),"utf8"),Co.info("systemd unit written",{unitPath:e}),await Ao("systemctl",["--user","daemon-reload"]),await Ao("systemctl",["--user","enable","--now",To]),Co.info("systemd unit enabled",{unitName:To})},async uninstall(t){let e=this.configPath(t);await Ao("systemctl",["--user","disable","--now",To]).catch(r=>Co.warn("systemctl disable failed (ignored)",{err:String(r)})),await BE(e).catch(r=>{if(r.code!=="ENOENT")throw r}),await Ao("systemctl",["--user","daemon-reload"]).catch(()=>{}),Co.info("systemd unit removed",{unitPath:e})}}});import{spawn as HE}from"node:child_process";import{join as qE}from"node:path";function Nx(t,e){return new Promise((r,s)=>{let a=HE(t,e,{stdio:["ignore","pipe","pipe"],shell:!1}),c="";a.stderr?.on("data",d=>{c+=d.toString("utf8")}),a.on("error",s),a.on("close",d=>{d===0?r():s(new Error(`${t} ${e.join(" ")} exited ${d}: ${c.trim()}`))})})}var n0,Ro,r0,Mx=at(()=>{"use strict";te();n0=G("supervisor.taskscheduler"),Ro="CozeBridge",r0={platform:"win32",renderConfig(t){return`<?xml version="1.0" encoding="UTF-16"?>
58
+ `},configPath(t){return UE(t.homeDir,".config","systemd","user",Io)},async install(t){let e=this.configPath(t);await ME(FE(e),{recursive:!0}),await zE(e,this.renderConfig(t),"utf8"),So.info("systemd unit written",{unitPath:e}),await Ao("systemctl",["--user","daemon-reload"]),await Ao("systemctl",["--user","enable","--now",Io]),So.info("systemd unit enabled",{unitName:Io})},async uninstall(t){let e=this.configPath(t);await Ao("systemctl",["--user","disable","--now",Io]).catch(r=>So.warn("systemctl disable failed (ignored)",{err:String(r)})),await BE(e).catch(r=>{if(r.code!=="ENOENT")throw r}),await Ao("systemctl",["--user","daemon-reload"]).catch(()=>{}),So.info("systemd unit removed",{unitPath:e})}}});import{spawn as HE}from"node:child_process";import{join as qE}from"node:path";function Nx(t,e){return new Promise((r,i)=>{let o=HE(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 e0,To,t0,Mx=ot(()=>{"use strict";ee();e0=G("supervisor.taskscheduler"),To="CozeBridge",t0={platform:"win32",renderConfig(t){return`<?xml version="1.0" encoding="UTF-16"?>
59
59
  <Task version="1.2" xmlns="http://schemas.microsoft.com/windows/2004/02/mit/task">
60
60
  <RegistrationInfo>
61
61
  <Description>Coze Bridge daemon</Description>
@@ -79,17 +79,17 @@ WantedBy=default.target
79
79
  </Exec>
80
80
  </Actions>
81
81
  </Task>
82
- `},configPath(t){return qE(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 Nx("schtasks",["/Create","/SC","ONLOGON","/TN",Ro,"/TR",r,"/RU",t.userName,"/F"]),n0.info("task scheduler entry created",{task:Ro,logFile:t.logFile})},async uninstall(t){await Nx("schtasks",["/Delete","/TN",Ro,"/F"]).catch(e=>n0.warn("schtasks /Delete failed (ignored)",{err:String(e)})),n0.info("task scheduler entry removed",{task:Ro})}}});var Bx={};qo(Bx,{buildContext:()=>KE,getSupervisor:()=>WE,launchdSupervisor:()=>e0,systemdSupervisor:()=>t0,taskSchedulerSupervisor:()=>r0});import{homedir as GE,userInfo as jE}from"node:os";function WE(t=process.platform){switch(t){case"darwin":return e0;case"linux":return t0;case"win32":return r0;default:throw new Error(`unsupported platform for OS supervisor: ${t}`)}}function KE(){let t=ne();return{nodeBin:process.execPath,entry:$c(t),logFile:t.logFile,homeDir:GE(),userName:jE().username}}var zx=at(()=>{"use strict";Fe();Zc();Px();Lx();Mx()});te();wn();var N0=G("acp-installer-warmup"),cp=["claude-code","codex"];async function M0(t={}){let e=t.ensure??gn,s=(await Promise.allSettled(cp.map(async a=>{let c=await e(a);N0.info("acp wrapper warmup ok",{framework:a,installed:!!c,path:c??""})}))).filter(a=>a.status==="rejected");s.length>0&&N0.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))})}Kt();te();import{readdir as Ep}from"node:fs/promises";import{mkdir as q0,writeFile as G0}from"node:fs/promises";import{join as $o}from"node:path";var wp={"claude-code":"CLAUDE.md",codex:"AGENTS.md",openclaw:"SOUL.md"};async function Zn(t,e,r,s){await q0(t,{recursive:!0});let a=wp[e],c=$o(t,a),d=_p(e,r,s);return await G0(c,d,"utf8"),c}async function j0(t){let e=$o(t,".claude");await q0(e,{recursive:!0});let r=$o(e,"settings.local.json"),s=JSON.stringify({permissions:{defaultMode:"bypassPermissions"}},null,2);return await G0(r,s,"utf8"),r}function _p(t,e,r){let s=`# Coze Agent: ${e}
82
+ `},configPath(t){return qE(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 Nx("schtasks",["/Create","/SC","ONLOGON","/TN",To,"/TR",r,"/RU",t.userName,"/F"]),e0.info("task scheduler entry created",{task:To,logFile:t.logFile})},async uninstall(t){await Nx("schtasks",["/Delete","/TN",To,"/F"]).catch(e=>e0.warn("schtasks /Delete failed (ignored)",{err:String(e)})),e0.info("task scheduler entry removed",{task:To})}}});var Bx={};Uo(Bx,{buildContext:()=>WE,getSupervisor:()=>KE,launchdSupervisor:()=>Xc,systemdSupervisor:()=>Qc,taskSchedulerSupervisor:()=>t0});import{homedir as GE,userInfo as jE}from"node:os";function KE(t=process.platform){switch(t){case"darwin":return Xc;case"linux":return Qc;case"win32":return t0;default:throw new Error(`unsupported platform for OS supervisor: ${t}`)}}function WE(){let t=te();return{nodeBin:process.execPath,entry:Kc(t),logFile:t.logFile,homeDir:GE(),userName:jE().username}}var zx=ot(()=>{"use strict";Be();$c();Px();Lx();Mx()});ee();gn();var N0=G("acp-installer-warmup"),cp=["claude-code","codex"];async function M0(t={}){let e=t.ensure??hn,i=(await Promise.allSettled(cp.map(async o=>{let c=await e(o);N0.info("acp wrapper warmup ok",{framework:o,installed:!!c,path:c??""})}))).filter(o=>o.status==="rejected");i.length>0&&N0.warn("acp wrapper warmup partial failure (acp-installer negative cache 5min \u5185\u4E0D\u91CD\u8BD5)",{failedCount:i.length,reasons:i.map(o=>String(o.reason))})}Kt();ee();import{readdir as bp}from"node:fs/promises";import{mkdir as q0,writeFile as G0}from"node:fs/promises";import{join as Ko}from"node:path";var wp={"claude-code":"CLAUDE.md",codex:"AGENTS.md",openclaw:"SOUL.md"};async function $n(t,e,r,i){await q0(t,{recursive:!0});let o=wp[e],c=Ko(t,o),f=_p(e,r,i);return await G0(c,f,"utf8"),c}async function j0(t){let e=Ko(t,".claude");await q0(e,{recursive:!0});let r=Ko(e,"settings.local.json"),i=JSON.stringify({permissions:{defaultMode:"bypassPermissions"}},null,2);return await G0(r,i,"utf8"),r}function _p(t,e,r){let i=`# Coze Agent: ${e}
83
83
 
84
84
  > framework: \`${t}\`
85
85
 
86
- `,a=r?.trim()?r.endsWith(`
86
+ `,o=r?.trim()?r.endsWith(`
87
87
  `)?r:`${r}
88
88
  `:`_No instructions provided._
89
- `;return`${s}---
89
+ `;return`${i}---
90
90
 
91
- ${a}
92
- ${yp()}`}function yp(){let t=process.platform==="win32"?"coze-bridge.cmd":"coze-bridge";return bp.replace(/\bcoze-bridge\b(?!\.cmd)/g,t)}var bp=`## \u53D1\u9001\u6587\u4EF6 / \u56FE\u7247\u7ED9\u7528\u6237
91
+ ${o}
92
+ ${yp()}`}function yp(){let t=process.platform==="win32"?"coze-bridge.cmd":"coze-bridge";return Ep.replace(/\bcoze-bridge\b(?!\.cmd)/g,t)}var Ep=`## \u53D1\u9001\u6587\u4EF6 / \u56FE\u7247\u7ED9\u7528\u6237
93
93
 
94
94
  \u6BCF\u6761\u7528\u6237\u6D88\u606F\u5F00\u5934\u4F1A\u6709\u4E91\u7AEF\u6CE8\u5165\u7684 \`<coze-context>\` \u5757, \u5F62\u5982:
95
95
 
@@ -113,30 +113,30 @@ ${yp()}`}function yp(){let t=process.platform==="win32"?"coze-bridge.cmd":"coze-
113
113
  - \`sessionId\` \u5FC5\u987B\u7528\u4E91\u7AEF \`<coze-context>\` \u7ED9\u7684 ID, **\u4E0D\u8981**\u81EA\u5DF1\u7F16\u6216\u8005\u7528\u5176\u5B83\u6765\u6E90
114
114
 
115
115
  \u26A0\uFE0F \u751F\u6210\u6587\u4EF6\u540E\u8BF7**\u7B49\u6587\u4EF6\u5B8C\u6574\u5199\u76D8**\u518D send (\u7528 \`&&\` \u4E32\u884C, \u4E0D\u8981 \`&\` \u540E\u53F0)\u3002
116
- `;var Ve=G("agent-detail-sync"),vp=6e4,Sp=5*6e4,Hi=class{constructor(e){this.opts=e}opts;retryQueue=new Map;async syncAll(e){let r=this.opts.paths.agentsRoot,s;try{s=await Ep(r)}catch(a){Ve.info("agents dir not found, skip detail sync",{root:r,err:String(a)});return}Ve.info("starting detail sync",{reason:e,count:s.length}),await Promise.allSettled(s.map(async a=>{let c=await qe(a,this.opts.paths).catch(()=>null);if(c){if(c.disconnectedAt){Ve.debug("detail sync: skip disconnected agent",{agentId:a});return}try{await this.syncOne(a,c)}catch(d){Ve.warn("detail sync failed for agent, skipping",{agentId:a,err:String(d)})}}})),Ve.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){Ve.info("retrying pending detail syncs",{count:r.length});for(let s of r)try{await this.syncOne(s)}catch(a){Ve.debug("detail sync retry still failing, will try again",{agentId:s,err:String(a)})}}}async syncOne(e,r){let s=r??await qe(e,this.opts.paths);if(!s){Ve.info("detail sync: agent config missing, skip",{agentId:e});return}let a;try{a=await this.opts.sendDetail({_meta:{cozeAgentId:e}}),this.retryQueue.delete(e)}catch(l){Ve.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,Sp):vp;this.retryQueue.set(e,{dueAt:Date.now()+p,currentDelay:p});return}if(a.agentId&&a.agentId!==e){Ve.warn("detail response agentId mismatch, ignoring",{agentId:e,responseAgentId:a.agentId});return}let c=!1,d=!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,d=!0),a.deployType&&Ve.info("detail.deployType",{agentId:e,deployType:a.deployType}),!c){Ve.debug("detail sync: no diff",{agentId:e});return}await $e(s,this.opts.paths),Ve.info("detail sync: config updated",{agentId:e,identityChanged:d,agentName:s.agentName}),d&&(await Zn(s.workspace,s.framework,e,s.cozeIdentity),this.opts.handlers.reloadAgentSessionsPublic(e,"detail-sync"))}};var au=ht(Sf(),1);import{lstat as oc,mkdir as ac,readFile as ru,readdir as Jm,rm as Ym,stat as Xm,writeFile as cc}from"node:fs/promises";import{dirname as Qm,join as vt,normalize as ew,relative as uc,resolve as fc,sep as iu}from"node:path";import{Readable as su}from"node:stream";import{pipeline as ou}from"node:stream/promises";import Kp from"events";import Ke from"fs";import{EventEmitter as Ka}from"node:events";import sd from"node:stream";import{StringDecoder as $p}from"node:string_decoder";import cd from"node:path";import ar from"node:fs";import{dirname as og,parse as ag}from"path";import{EventEmitter as pg}from"events";import Ta from"assert";import{Buffer as Rn}from"buffer";import*as Rf from"zlib";import gg from"zlib";import{posix as er}from"node:path";import{basename as Gg}from"node:path";import _s from"fs";import wt from"fs";import Mf from"path";import{win32 as em}from"node:path";import Gf from"path";import vd from"node:fs";import mm from"node:assert";import{randomBytes as Sd}from"node:crypto";import X from"node:fs";import Ce from"node:path";import Id from"fs";import As from"node:fs";import ti from"node:path";import Ye from"node:fs";import Sm from"node:fs/promises";import Es from"node:path";import{join as Md}from"node:path";import Je from"node:fs";import Fd from"node:path";var jp=Object.defineProperty,Wp=(t,e)=>{for(var r in e)jp(t,r,{get:e[r],enumerable:!0})},If=typeof process=="object"&&process?process:{stdout:null,stderr:null},Vp=t=>!!t&&typeof t=="object"&&(t instanceof On||t instanceof sd||Zp(t)||Jp(t)),Zp=t=>!!t&&typeof t=="object"&&t instanceof Ka&&typeof t.pipe=="function"&&t.pipe!==sd.Writable.prototype.pipe,Jp=t=>!!t&&typeof t=="object"&&t instanceof Ka&&typeof t.write=="function"&&typeof t.end=="function",Dt=Symbol("EOF"),kt=Symbol("maybeEmitEnd"),Vt=Symbol("emittedEnd"),Ki=Symbol("emittingEnd"),zr=Symbol("emittedError"),$i=Symbol("closed"),Cf=Symbol("read"),Vi=Symbol("flush"),Tf=Symbol("flushChunk"),ct=Symbol("encoding"),Qn=Symbol("decoder"),De=Symbol("flowing"),Fr=Symbol("paused"),ir=Symbol("resume"),ke=Symbol("buffer"),je=Symbol("pipes"),Oe=Symbol("bufferLength"),Qo=Symbol("bufferPush"),Zi=Symbol("bufferShift"),Ge=Symbol("objectMode"),ye=Symbol("destroyed"),ea=Symbol("error"),ta=Symbol("emitData"),Af=Symbol("emitEnd"),na=Symbol("emitEnd2"),pt=Symbol("async"),ra=Symbol("abort"),Ji=Symbol("aborted"),Ur=Symbol("signal"),yn=Symbol("dataListeners"),Ze=Symbol("discarded"),Hr=t=>Promise.resolve().then(t),Yp=t=>t(),Xp=t=>t==="end"||t==="finish"||t==="prefinish",Qp=t=>t instanceof ArrayBuffer||!!t&&typeof t=="object"&&t.constructor&&t.constructor.name==="ArrayBuffer"&&t.byteLength>=0,eg=t=>!Buffer.isBuffer(t)&&ArrayBuffer.isView(t),od=class{src;dest;opts;ondrain;constructor(t,e,r){this.src=t,this.dest=e,this.opts=r,this.ondrain=()=>t[ir](),this.dest.on("drain",this.ondrain)}unpipe(){this.dest.removeListener("drain",this.ondrain)}proxyErrors(t){}end(){this.unpipe(),this.opts.end&&this.dest.end()}},tg=class extends od{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)}},ng=t=>!!t.objectMode,rg=t=>!t.objectMode&&!!t.encoding&&t.encoding!=="buffer",On=class extends Ka{[De]=!1;[Fr]=!1;[je]=[];[ke]=[];[Ge];[ct];[pt];[Qn];[Dt]=!1;[Vt]=!1;[Ki]=!1;[$i]=!1;[zr]=null;[Oe]=0;[ye]=!1;[Ur];[Ji]=!1;[yn]=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");ng(e)?(this[Ge]=!0,this[ct]=null):rg(e)?(this[ct]=e.encoding,this[Ge]=!1):(this[Ge]=!1,this[ct]=null),this[pt]=!!e.async,this[Qn]=this[ct]?new $p(this[ct]):null,e&&e.debugExposeBuffer===!0&&Object.defineProperty(this,"buffer",{get:()=>this[ke]}),e&&e.debugExposePipes===!0&&Object.defineProperty(this,"pipes",{get:()=>this[je]});let{signal:r}=e;r&&(this[Ur]=r,r.aborted?this[ra]():r.addEventListener("abort",()=>this[ra]()))}get bufferLength(){return this[Oe]}get encoding(){return this[ct]}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[Ge]}set objectMode(t){throw new Error("objectMode must be set at instantiation time")}get async(){return this[pt]}set async(t){this[pt]=this[pt]||!!t}[ra](){this[Ji]=!0,this.emit("abort",this[Ur]?.reason),this.destroy(this[Ur]?.reason)}get aborted(){return this[Ji]}set aborted(t){}write(t,e,r){if(this[Ji])return!1;if(this[Dt])throw new Error("write after end");if(this[ye])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[pt]?Hr:Yp;if(!this[Ge]&&!Buffer.isBuffer(t)){if(eg(t))t=Buffer.from(t.buffer,t.byteOffset,t.byteLength);else if(Qp(t))t=Buffer.from(t);else if(typeof t!="string")throw new Error("Non-contiguous data written to non-objectMode stream")}return this[Ge]?(this[De]&&this[Oe]!==0&&this[Vi](!0),this[De]?this.emit("data",t):this[Qo](t),this[Oe]!==0&&this.emit("readable"),r&&s(r),this[De]):t.length?(typeof t=="string"&&!(e===this[ct]&&!this[Qn]?.lastNeed)&&(t=Buffer.from(t,e)),Buffer.isBuffer(t)&&this[ct]&&(t=this[Qn].write(t)),this[De]&&this[Oe]!==0&&this[Vi](!0),this[De]?this.emit("data",t):this[Qo](t),this[Oe]!==0&&this.emit("readable"),r&&s(r),this[De]):(this[Oe]!==0&&this.emit("readable"),r&&s(r),this[De])}read(t){if(this[ye])return null;if(this[Ze]=!1,this[Oe]===0||t===0||t&&t>this[Oe])return this[kt](),null;this[Ge]&&(t=null),this[ke].length>1&&!this[Ge]&&(this[ke]=[this[ct]?this[ke].join(""):Buffer.concat(this[ke],this[Oe])]);let e=this[Cf](t||null,this[ke][0]);return this[kt](),e}[Cf](t,e){if(this[Ge])this[Zi]();else{let r=e;t===r.length||t===null?this[Zi]():typeof r=="string"?(this[ke][0]=r.slice(t),e=r.slice(0,t),this[Oe]-=t):(this[ke][0]=r.subarray(t),e=r.subarray(0,t),this[Oe]-=t)}return this.emit("data",e),!this[ke].length&&!this[Dt]&&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[Dt]=!0,this.writable=!1,(this[De]||!this[Fr])&&this[kt](),this}[ir](){this[ye]||(!this[yn]&&!this[je].length&&(this[Ze]=!0),this[Fr]=!1,this[De]=!0,this.emit("resume"),this[ke].length?this[Vi]():this[Dt]?this[kt]():this.emit("drain"))}resume(){return this[ir]()}pause(){this[De]=!1,this[Fr]=!0,this[Ze]=!1}get destroyed(){return this[ye]}get flowing(){return this[De]}get paused(){return this[Fr]}[Qo](t){this[Ge]?this[Oe]+=1:this[Oe]+=t.length,this[ke].push(t)}[Zi](){return this[Ge]?this[Oe]-=1:this[Oe]-=this[ke][0].length,this[ke].shift()}[Vi](t=!1){do;while(this[Tf](this[Zi]())&&this[ke].length);!t&&!this[ke].length&&!this[Dt]&&this.emit("drain")}[Tf](t){return this.emit("data",t),this[De]}pipe(t,e){if(this[ye])return t;this[Ze]=!1;let r=this[Vt];return e=e||{},t===If.stdout||t===If.stderr?e.end=!1:e.end=e.end!==!1,e.proxyErrors=!!e.proxyErrors,r?e.end&&t.end():(this[je].push(e.proxyErrors?new tg(this,t,e):new od(this,t,e)),this[pt]?Hr(()=>this[ir]()):this[ir]()),t}unpipe(t){let e=this[je].find(r=>r.dest===t);e&&(this[je].length===1?(this[De]&&this[yn]===0&&(this[De]=!1),this[je]=[]):this[je].splice(this[je].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[yn]++,!this[je].length&&!this[De]&&this[ir]();else if(t==="readable"&&this[Oe]!==0)super.emit("readable");else if(Xp(t)&&this[Vt])super.emit(t),this.removeAllListeners(t);else if(t==="error"&&this[zr]){let s=e;this[pt]?Hr(()=>s.call(this,this[zr])):s.call(this,this[zr])}return r}removeListener(t,e){return this.off(t,e)}off(t,e){let r=super.off(t,e);return t==="data"&&(this[yn]=this.listeners("data").length,this[yn]===0&&!this[Ze]&&!this[je].length&&(this[De]=!1)),r}removeAllListeners(t){let e=super.removeAllListeners(t);return(t==="data"||t===void 0)&&(this[yn]=0,!this[Ze]&&!this[je].length&&(this[De]=!1)),e}get emittedEnd(){return this[Vt]}[kt](){!this[Ki]&&!this[Vt]&&!this[ye]&&this[ke].length===0&&this[Dt]&&(this[Ki]=!0,this.emit("end"),this.emit("prefinish"),this.emit("finish"),this[$i]&&this.emit("close"),this[Ki]=!1)}emit(t,...e){let r=e[0];if(t!=="error"&&t!=="close"&&t!==ye&&this[ye])return!1;if(t==="data")return!this[Ge]&&!r?!1:this[pt]?(Hr(()=>this[ta](r)),!0):this[ta](r);if(t==="end")return this[Af]();if(t==="close"){if(this[$i]=!0,!this[Vt]&&!this[ye])return!1;let a=super.emit("close");return this.removeAllListeners("close"),a}else if(t==="error"){this[zr]=r,super.emit(ea,r);let a=!this[Ur]||this.listeners("error").length?super.emit("error",r):!1;return this[kt](),a}else if(t==="resume"){let a=super.emit("resume");return this[kt](),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[kt](),s}[ta](t){for(let r of this[je])r.dest.write(t)===!1&&this.pause();let e=this[Ze]?!1:super.emit("data",t);return this[kt](),e}[Af](){return this[Vt]?!1:(this[Vt]=!0,this.readable=!1,this[pt]?(Hr(()=>this[na]()),!0):this[na]())}[na](){if(this[Qn]){let e=this[Qn].end();if(e){for(let r of this[je])r.dest.write(e);this[Ze]||super.emit("data",e)}}for(let e of this[je])e.end();let t=super.emit("end");return this.removeAllListeners("end"),t}async collect(){let t=Object.assign([],{dataLength:0});this[Ge]||(t.dataLength=0);let e=this.promise();return this.on("data",r=>{t.push(r),this[Ge]||(t.dataLength+=r.length)}),await e,t}async concat(){if(this[Ge])throw new Error("cannot concat in objectMode");let t=await this.collect();return this[ct]?t.join(""):Buffer.concat(t,t.dataLength)}async promise(){return new Promise((t,e)=>{this.on(ye,()=>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[Dt])return e();let s,a,c=p=>{this.off("data",d),this.off("end",l),this.off(ye,x),e(),a(p)},d=p=>{this.off("error",c),this.off("end",l),this.off(ye,x),this.pause(),s({value:p,done:!!this[Dt]})},l=()=>{this.off("error",c),this.off("data",d),this.off(ye,x),e(),s({done:!0,value:void 0})},x=()=>c(new Error("stream destroyed"));return new Promise((p,w)=>{a=w,s=p,this.once(ye,x),this.once("error",c),this.once("end",l),this.once("data",d)})},throw:e,return:e,[Symbol.asyncIterator](){return this},[Symbol.asyncDispose]:async()=>{}}}[Symbol.iterator](){this[Ze]=!1;let t=!1,e=()=>(this.pause(),this.off(ea,e),this.off(ye,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(ea,e),this.once(ye,e),{next:r,throw:e,return:e,[Symbol.iterator](){return this},[Symbol.dispose]:()=>{}}}destroy(t){if(this[ye])return t?this.emit("error",t):this.emit(ye),this;this[ye]=!0,this[Ze]=!0,this[ke].length=0,this[Oe]=0;let e=this;return typeof e.close=="function"&&!this[$i]&&e.close(),t?this.emit("error",t):this.emit(ye),this}static get isStream(){return Vp}},ig=Ke.writev,sn=Symbol("_autoClose"),lt=Symbol("_close"),qr=Symbol("_ended"),se=Symbol("_fd"),ia=Symbol("_finished"),Nt=Symbol("_flags"),sa=Symbol("_flush"),Ia=Symbol("_handleChunk"),Ca=Symbol("_makeBuf"),Qr=Symbol("_mode"),Yi=Symbol("_needDrain"),fr=Symbol("_onerror"),dr=Symbol("_onopen"),oa=Symbol("_onread"),sr=Symbol("_onwrite"),on=Symbol("_open"),ut=Symbol("_path"),Qt=Symbol("_pos"),gt=Symbol("_queue"),or=Symbol("_read"),aa=Symbol("_readSize"),Lt=Symbol("_reading"),Gr=Symbol("_remain"),ca=Symbol("_size"),as=Symbol("_write"),bn=Symbol("_writing"),cs=Symbol("_defaultFlag"),An=Symbol("_errored"),$a=class extends On{[An]=!1;[se];[ut];[aa];[Lt]=!1;[ca];[Gr];[sn];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[se]=typeof e.fd=="number"?e.fd:void 0,this[ut]=t,this[aa]=e.readSize||16*1024*1024,this[Lt]=!1,this[ca]=typeof e.size=="number"?e.size:1/0,this[Gr]=this[ca],this[sn]=typeof e.autoClose=="boolean"?e.autoClose:!0,typeof this[se]=="number"?this[or]():this[on]()}get fd(){return this[se]}get path(){return this[ut]}write(){throw new TypeError("this is a readable stream")}end(){throw new TypeError("this is a readable stream")}[on](){Ke.open(this[ut],"r",(t,e)=>this[dr](t,e))}[dr](t,e){t?this[fr](t):(this[se]=e,this.emit("open",e),this[or]())}[Ca](){return Buffer.allocUnsafe(Math.min(this[aa],this[Gr]))}[or](){if(!this[Lt]){this[Lt]=!0;let t=this[Ca]();if(t.length===0)return process.nextTick(()=>this[oa](null,0,t));Ke.read(this[se],t,0,t.length,null,(e,r,s)=>this[oa](e,r,s))}}[oa](t,e,r){this[Lt]=!1,t?this[fr](t):this[Ia](e,r)&&this[or]()}[lt](){if(this[sn]&&typeof this[se]=="number"){let t=this[se];this[se]=void 0,Ke.close(t,e=>e?this.emit("error",e):this.emit("close"))}}[fr](t){this[Lt]=!0,this[lt](),this.emit("error",t)}[Ia](t,e){let r=!1;return this[Gr]-=t,t>0&&(r=super.write(t<e.length?e.subarray(0,t):e)),(t===0||this[Gr]<=0)&&(r=!1,this[lt](),super.end()),r}emit(t,...e){switch(t){case"prefinish":case"finish":return!1;case"drain":return typeof this[se]=="number"&&this[or](),!1;case"error":return this[An]?!1:(this[An]=!0,super.emit(t,...e));default:return super.emit(t,...e)}}},sg=class extends $a{[on](){let t=!0;try{this[dr](null,Ke.openSync(this[ut],"r")),t=!1}finally{t&&this[lt]()}}[or](){let t=!0;try{if(!this[Lt]){this[Lt]=!0;do{let e=this[Ca](),r=e.length===0?0:Ke.readSync(this[se],e,0,e.length,null);if(!this[Ia](r,e))break}while(!0);this[Lt]=!1}t=!1}finally{t&&this[lt]()}}[lt](){if(this[sn]&&typeof this[se]=="number"){let t=this[se];this[se]=void 0,Ke.closeSync(t),this.emit("close")}}},vs=class extends Kp{readable=!1;writable=!0;[An]=!1;[bn]=!1;[qr]=!1;[gt]=[];[Yi]=!1;[ut];[Qr];[sn];[se];[cs];[Nt];[ia]=!1;[Qt];constructor(t,e){e=e||{},super(e),this[ut]=t,this[se]=typeof e.fd=="number"?e.fd:void 0,this[Qr]=e.mode===void 0?438:e.mode,this[Qt]=typeof e.start=="number"?e.start:void 0,this[sn]=typeof e.autoClose=="boolean"?e.autoClose:!0;let r=this[Qt]!==void 0?"r+":"w";this[cs]=e.flags===void 0,this[Nt]=e.flags===void 0?r:e.flags,this[se]===void 0&&this[on]()}emit(t,...e){if(t==="error"){if(this[An])return!1;this[An]=!0}return super.emit(t,...e)}get fd(){return this[se]}get path(){return this[ut]}[fr](t){this[lt](),this[bn]=!0,this.emit("error",t)}[on](){Ke.open(this[ut],this[Nt],this[Qr],(t,e)=>this[dr](t,e))}[dr](t,e){this[cs]&&this[Nt]==="r+"&&t&&t.code==="ENOENT"?(this[Nt]="w",this[on]()):t?this[fr](t):(this[se]=e,this.emit("open",e),this[bn]||this[sa]())}end(t,e){return t&&this.write(t,e),this[qr]=!0,!this[bn]&&!this[gt].length&&typeof this[se]=="number"&&this[sr](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[se]===void 0||this[bn]||this[gt].length?(this[gt].push(t),this[Yi]=!0,!1):(this[bn]=!0,this[as](t),!0)}[as](t){Ke.write(this[se],t,0,t.length,this[Qt],(e,r)=>this[sr](e,r))}[sr](t,e){t?this[fr](t):(this[Qt]!==void 0&&typeof e=="number"&&(this[Qt]+=e),this[gt].length?this[sa]():(this[bn]=!1,this[qr]&&!this[ia]?(this[ia]=!0,this[lt](),this.emit("finish")):this[Yi]&&(this[Yi]=!1,this.emit("drain"))))}[sa](){if(this[gt].length===0)this[qr]&&this[sr](null,0);else if(this[gt].length===1)this[as](this[gt].pop());else{let t=this[gt];this[gt]=[],ig(this[se],t,this[Qt],(e,r)=>this[sr](e,r))}}[lt](){if(this[sn]&&typeof this[se]=="number"){let t=this[se];this[se]=void 0,Ke.close(t,e=>e?this.emit("error",e):this.emit("close"))}}},ad=class extends vs{[on](){let t;if(this[cs]&&this[Nt]==="r+")try{t=Ke.openSync(this[ut],this[Nt],this[Qr])}catch(e){if(e?.code==="ENOENT")return this[Nt]="w",this[on]();throw e}else t=Ke.openSync(this[ut],this[Nt],this[Qr]);this[dr](null,t)}[lt](){if(this[sn]&&typeof this[se]=="number"){let t=this[se];this[se]=void 0,Ke.closeSync(t),this.emit("close")}}[as](t){let e=!0;try{this[sr](null,Ke.writeSync(this[se],t,0,t.length,this[Qt])),e=!1}finally{if(e)try{this[lt]()}catch{}}}},cg=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"]]),fg=t=>!!t.sync&&!!t.file,dg=t=>!t.sync&&!!t.file,ug=t=>!!t.sync&&!t.file,lg=t=>!t.sync&&!t.file,xg=t=>!!t.file,hg=t=>cg.get(t)||t,Va=(t={})=>{if(!t)return{};let e={};for(let[r,s]of Object.entries(t)){let a=hg(r);e[a]=s}return e.chmod===void 0&&e.noChmod===!1&&(e.chmod=!0),delete e.noChmod,e},ci=(t,e,r,s,a)=>Object.assign((c=[],d,l)=>{Array.isArray(c)&&(d=c,c={}),typeof d=="function"&&(l=d,d=void 0),d=d?Array.from(d):[];let x=Va(c);if(a?.(x,d),fg(x)){if(typeof l=="function")throw new TypeError("callback not supported for sync tar functions");return t(x,d)}else if(dg(x)){let p=e(x,d);return l?p.then(()=>l(),l):p}else if(ug(x)){if(typeof l=="function")throw new TypeError("callback not supported for sync tar functions");return r(x,d)}else if(lg(x)){if(typeof l=="function")throw new TypeError("callback only supported with file option");return s(x,d)}throw new Error("impossible options??")},{syncFile:t,asyncFile:e,syncNoFile:r,asyncNoFile:s,validate:a}),mg=gg.constants||{ZLIB_VERNUM:4736},yt=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},mg)),wg=Rn.concat,Df=Object.getOwnPropertyDescriptor(Rn,"concat"),_g=t=>t,fa=Df?.writable===!0||Df?.set!==void 0?t=>{Rn.concat=t?_g:wg}:t=>{},Dn=Symbol("_superWrite"),Xi=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"}},da=Symbol("flushFlag"),Za=class extends On{#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 Rf[e]!="function")throw new TypeError("Compression method not supported: "+e);try{this.#t=new Rf[e](t)}catch(r){throw new Xi(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 Xi(r))),this.once("end",()=>this.close)}close(){this.#t&&(this.#t.close(),this.#t=void 0,this.emit("close"))}reset(){if(!this.#e)return Ta(this.#t,"zlib binding closed"),this.#t.reset?.()}flush(t){this.ended||(typeof t!="number"&&(t=this.#i),this.write(Object.assign(Rn.alloc(0),{[da]: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}[Dn](t){return super.write(t)}write(t,e,r){if(typeof e=="function"&&(r=e,e="utf8"),typeof t=="string"&&(t=Rn.from(t,e)),this.#e)return;Ta(this.#t,"zlib binding closed");let s=this.#t._handle,a=s.close;s.close=()=>{};let c=this.#t.close;this.#t.close=()=>{},fa(!0);let d;try{let x=typeof t[da]=="number"?t[da]:this.#r;d=this.#t._processChunk(t,x),fa(!1)}catch(x){fa(!1),this.#o(new Xi(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 Xi(x,this.write)));let l;if(d)if(Array.isArray(d)&&d.length>0){let x=d[0];l=this[Dn](Rn.from(x));for(let p=1;p<d.length;p++)l=this[Dn](d[p])}else l=this[Dn](Rn.from(d));return r&&r(),l}},fd=class extends Za{#e;#n;constructor(t,e){t=t||{},t.flush=t.flush||yt.Z_NO_FLUSH,t.finishFlush=t.finishFlush||yt.Z_FINISH,t.fullFlushFlag=yt.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(yt.Z_SYNC_FLUSH),Ta(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)}}}},yg=class extends fd{#e;constructor(t){super(t,"Gzip"),this.#e=t&&!!t.portable}[Dn](t){return this.#e?(this.#e=!1,t[9]=255,super[Dn](t)):super[Dn](t)}},bg=class extends fd{constructor(t){super(t,"Unzip")}},dd=class extends Za{constructor(t,e){t=t||{},t.flush=t.flush||yt.BROTLI_OPERATION_PROCESS,t.finishFlush=t.finishFlush||yt.BROTLI_OPERATION_FINISH,t.fullFlushFlag=yt.BROTLI_OPERATION_FLUSH,super(t,e)}},Eg=class extends dd{constructor(t){super(t,"BrotliCompress")}},vg=class extends dd{constructor(t){super(t,"BrotliDecompress")}},ud=class extends Za{constructor(t,e){t=t||{},t.flush=t.flush||yt.ZSTD_e_continue,t.finishFlush=t.finishFlush||yt.ZSTD_e_end,t.fullFlushFlag=yt.ZSTD_e_flush,super(t,e)}},Sg=class extends ud{constructor(t){super(t,"ZstdCompress")}},Ig=class extends ud{constructor(t){super(t,"ZstdDecompress")}},Cg=(t,e)=>{if(Number.isSafeInteger(t))t<0?Ag(t,e):Tg(t,e);else throw Error("cannot encode number outside of javascript safe integer range");return e},Tg=(t,e)=>{e[0]=128;for(var r=e.length;r>1;r--)e[r-1]=t&255,t=Math.floor(t/256)},Ag=(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]=ld(a):a===0?e[s-1]=0:(r=!0,e[s-1]=xd(a))}},Rg=t=>{let e=t[0],r=e===128?kg(t.subarray(1,t.length)):e===255?Dg(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},Dg=t=>{for(var e=t.length,r=0,s=!1,a=e-1;a>-1;a--){var c=Number(t[a]),d;s?d=ld(c):c===0?d=c:(s=!0,d=xd(c)),d!==0&&(r-=d*Math.pow(256,e-a-1))}return r},kg=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},ld=t=>(255^t)&255,xd=t=>(255^t)+1&255,Og={};Wp(Og,{code:()=>Ja,isCode:()=>fs,isName:()=>Pg,name:()=>Ss});var fs=t=>Ss.has(t),Pg=t=>Ja.has(t),Ss=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"]]),Ja=new Map(Array.from(Ss).map(t=>[t[1],t[0]])),kn=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??En(t,e,100),this.mode=r?.mode??s?.mode??en(t,e+100,8),this.uid=r?.uid??s?.uid??en(t,e+108,8),this.gid=r?.gid??s?.gid??en(t,e+116,8),this.size=r?.size??s?.size??en(t,e+124,12),this.mtime=r?.mtime??s?.mtime??ua(t,e+136,12),this.cksum=en(t,e+148,12),s&&this.#n(s,!0),r&&this.#n(r);let a=En(t,e+156,1);if(fs(a)&&(this.#e=a||"0"),this.#e==="0"&&this.path.slice(-1)==="/"&&(this.#e="5"),this.#e==="5"&&(this.size=0),this.linkpath=En(t,e+157,100),t.subarray(e+257,e+265).toString()==="ustar\x0000")if(this.uname=r?.uname??s?.uname??En(t,e+265,32),this.gname=r?.gname??s?.gname??En(t,e+297,32),this.devmaj=r?.devmaj??s?.devmaj??en(t,e+329,8)??0,this.devmin=r?.devmin??s?.devmin??en(t,e+337,8)??0,t[e+475]!==0){let d=En(t,e+345,155);this.path=d+"/"+this.path}else{let d=En(t,e+345,130);d&&(this.path=d+"/"+this.path),this.atime=r?.atime??s?.atime??ua(t,e+476,12),this.ctime=r?.ctime??s?.ctime??ua(t,e+488,12)}let c=256;for(let d=e;d<e+148;d++)c+=t[d];for(let d=e+156;d<e+512;d++)c+=t[d];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=Lg(this.path||"",r),a=s[0],c=s[1];this.needPax=!!s[2],this.needPax=vn(t,e,100,a)||this.needPax,this.needPax=tn(t,e+100,8,this.mode)||this.needPax,this.needPax=tn(t,e+108,8,this.uid)||this.needPax,this.needPax=tn(t,e+116,8,this.gid)||this.needPax,this.needPax=tn(t,e+124,12,this.size)||this.needPax,this.needPax=la(t,e+136,12,this.mtime)||this.needPax,t[e+156]=Number(this.#e.codePointAt(0)),this.needPax=vn(t,e+157,100,this.linkpath)||this.needPax,t.write("ustar\x0000",e+257,8),this.needPax=vn(t,e+265,32,this.uname)||this.needPax,this.needPax=vn(t,e+297,32,this.gname)||this.needPax,this.needPax=tn(t,e+329,8,this.devmaj)||this.needPax,this.needPax=tn(t,e+337,8,this.devmin)||this.needPax,this.needPax=vn(t,e+345,r,c)||this.needPax,t[e+475]!==0?this.needPax=vn(t,e+345,155,c)||this.needPax:(this.needPax=vn(t,e+345,130,c)||this.needPax,this.needPax=la(t,e+476,12,this.atime)||this.needPax,this.needPax=la(t,e+488,12,this.ctime)||this.needPax);let d=256;for(let l=e;l<e+148;l++)d+=t[l];for(let l=e+156;l<e+512;l++)d+=t[l];return this.cksum=d,tn(t,e+148,8,this.cksum),this.cksumValid=!0,this.needPax}get type(){return this.#e==="Unsupported"?this.#e:Ss.get(this.#e)}get typeKey(){return this.#e}set type(t){let e=String(Ja.get(t));if(fs(e)||e==="Unsupported")this.#e=e;else if(fs(t))this.#e=t;else throw new TypeError("invalid entry type: "+t)}},Lg=(t,e)=>{let r=t,s="",a,c=er.parse(t).root||".";if(Buffer.byteLength(r)<100)a=[r,s,!1];else{s=er.dirname(r),r=er.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=er.join(er.basename(s),r),s=er.dirname(s));while(s!==c&&a===void 0);a||(a=[t.slice(0,99),"",!0])}return a},En=(t,e,r)=>t.subarray(e,e+r).toString("utf8").replace(/\0.*/,""),ua=(t,e,r)=>Ng(en(t,e,r)),Ng=t=>t===void 0?void 0:new Date(t*1e3),en=(t,e,r)=>Number(t[e])&128?Rg(t.subarray(e,e+r)):Bg(t,e,r),Mg=t=>isNaN(t)?void 0:t,Bg=(t,e,r)=>Mg(parseInt(t.subarray(e,e+r).toString("utf8").replace(/\0.*$/,"").trim(),8)),zg={12:8589934591,8:2097151},tn=(t,e,r,s)=>s===void 0?!1:s>zg[r]||s<0?(Cg(s,t.subarray(e,e+r)),!0):(Fg(t,e,r,s),!1),Fg=(t,e,r,s)=>t.write(Ug(s,r),e,r,"ascii"),Ug=(t,e)=>Hg(Math.floor(t).toString(8),e),Hg=(t,e)=>(t.length===e-1?t:new Array(e-t.length-1).join("0")+t+" ")+"\0",la=(t,e,r,s)=>s===void 0?!1:tn(t,e,r,s.getTime()/1e3),qg=new Array(156).join("\0"),vn=(t,e,r,s)=>s===void 0?!1:(t.write(s+qg,e,r,"utf8"),s.length!==Buffer.byteLength(s)||s.length>r),ws=class hd{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 kn({path:("PaxHeader/"+Gg(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+`
117
- `,c=Buffer.byteLength(a),d=Math.floor(Math.log(c)/Math.log(10))+1;return c+d>=Math.pow(10,d)&&(d+=1),d+c+a}static parse(e,r,s=!1){return new hd(jg(Wg(e),r),s)}},jg=(t,e)=>e?Object.assign({},e,t):t,Wg=t=>t.replace(/\n$/,"").split(`
118
- `).reduce(Kg,Object.create(null)),Kg=(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"),d=s.join("=");return t[c]=/^([A-Z]+\.)?([mac]|birth|creation)time$/.test(c)?new Date(Number(d)*1e3):/^[0-9]+$/.test(d)?+d:d,t},$g=process.env.TESTING_TAR_FAKE_PLATFORM||process.platform,J=$g!=="win32"?t=>t:t=>t&&t.replaceAll(/\\/g,"/"),pd=class extends On{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=J(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?J(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=J(t.path)),t.linkpath&&(t.linkpath=J(t.linkpath)),Object.assign(this,Object.fromEntries(Object.entries(t).filter(([r,s])=>!(s==null||r==="path"&&e))))}},Is=(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))},Vg=1024*1024,Aa=Buffer.from([31,139]),Ra=Buffer.from([40,181,47,253]),Zg=Math.max(Aa.length,Ra.length),et=Symbol("state"),Sn=Symbol("writeEntry"),Ot=Symbol("readEntry"),xa=Symbol("nextEntry"),kf=Symbol("processEntry"),mt=Symbol("extendedHeader"),jr=Symbol("globalExtendedHeader"),Zt=Symbol("meta"),Of=Symbol("emitMeta"),de=Symbol("buffer"),Pt=Symbol("queue"),Jt=Symbol("ended"),ha=Symbol("emittedEnd"),In=Symbol("emit"),ve=Symbol("unzip"),Qi=Symbol("consumeChunk"),es=Symbol("consumeChunkSub"),pa=Symbol("consumeBody"),Pf=Symbol("consumeMeta"),Lf=Symbol("consumeHeader"),Wr=Symbol("consuming"),ga=Symbol("bufferConcat"),ts=Symbol("maybeEnd"),tr=Symbol("writing"),Yt=Symbol("aborted"),ns=Symbol("onDone"),Cn=Symbol("sawValidEntry"),rs=Symbol("sawNullBlock"),is=Symbol("sawEOF"),Nf=Symbol("closeStream"),Jg=()=>!0,ai=class extends pg{file;strict;maxMetaEntrySize;filter;brotli;zstd;writable=!0;readable=!1;[Pt]=[];[de];[Ot];[Sn];[et]="begin";[Zt]="";[mt];[jr];[Jt]=!1;[ve];[Yt]=!1;[Cn];[rs]=!1;[is]=!1;[tr]=!1;[Wr]=!1;[ha]=!1;constructor(t={}){super(),this.file=t.file||"",this.on(ns,()=>{(this[et]==="begin"||this[Cn]===!1)&&this.warn("TAR_BAD_ARCHIVE","Unrecognized archive format")}),t.ondone?this.on(ns,t.ondone):this.on(ns,()=>{this.emit("prefinish"),this.emit("finish"),this.emit("end")}),this.strict=!!t.strict,this.maxMetaEntrySize=t.maxMetaEntrySize||Vg,this.filter=typeof t.filter=="function"?t.filter:Jg;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[Nf]()),typeof t.onwarn=="function"&&this.on("warn",t.onwarn),typeof t.onReadEntry=="function"&&this.on("entry",t.onReadEntry)}warn(t,e,r={}){Is(this,t,e,r)}[Lf](t,e){this[Cn]===void 0&&(this[Cn]=!1);let r;try{r=new kn(t,e,this[mt],this[jr])}catch(s){return this.warn("TAR_ENTRY_INVALID",s)}if(r.nullBlock)this[rs]?(this[is]=!0,this[et]==="begin"&&(this[et]="header"),this[In]("eof")):(this[rs]=!0,this[In]("nullBlock"));else if(this[rs]=!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[Sn]=new pd(r,this[mt],this[jr]);if(!this[Cn])if(a.remain){let c=()=>{a.invalid||(this[Cn]=!0)};a.on("end",c)}else this[Cn]=!0;a.meta?a.size>this.maxMetaEntrySize?(a.ignore=!0,this[In]("ignoredEntry",a),this[et]="ignore",a.resume()):a.size>0&&(this[Zt]="",a.on("data",c=>this[Zt]+=c),this[et]="meta"):(this[mt]=void 0,a.ignore=a.ignore||!this.filter(a.path,a),a.ignore?(this[In]("ignoredEntry",a),this[et]=a.remain?"ignore":"header",a.resume()):(a.remain?this[et]="body":(this[et]="header",a.end()),this[Ot]?this[Pt].push(a):(this[Pt].push(a),this[xa]())))}}}[Nf](){queueMicrotask(()=>this.emit("close"))}[kf](t){let e=!0;if(!t)this[Ot]=void 0,e=!1;else if(Array.isArray(t)){let[r,...s]=t;this.emit(r,...s)}else this[Ot]=t,this.emit("entry",t),t.emittedEnd||(t.on("end",()=>this[xa]()),e=!1);return e}[xa](){do;while(this[kf](this[Pt].shift()));if(this[Pt].length===0){let t=this[Ot];!t||t.flowing||t.size===t.remain?this[tr]||this.emit("drain"):t.once("drain",()=>this.emit("drain"))}}[pa](t,e){let r=this[Sn];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[et]="header",this[Sn]=void 0,r.end()),a.length}[Pf](t,e){let r=this[Sn],s=this[pa](t,e);return!this[Sn]&&r&&this[Of](r),s}[In](t,e,r){this[Pt].length===0&&!this[Ot]?this.emit(t,e,r):this[Pt].push([t,e,r])}[Of](t){switch(this[In]("meta",this[Zt]),t.type){case"ExtendedHeader":case"OldExtendedHeader":this[mt]=ws.parse(this[Zt],this[mt],!1);break;case"GlobalExtendedHeader":this[jr]=ws.parse(this[Zt],this[jr],!0);break;case"NextFileHasLongPath":case"OldGnuLongPath":{let e=this[mt]??Object.create(null);this[mt]=e,e.path=this[Zt].replace(/\0.*/,"");break}case"NextFileHasLongLinkpath":{let e=this[mt]||Object.create(null);this[mt]=e,e.linkpath=this[Zt].replace(/\0.*/,"");break}default:throw new Error("unknown meta: "+t.type)}}abort(t){this[Yt]=!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[Yt])return r?.(),!1;if((this[ve]===void 0||this.brotli===void 0&&this[ve]===!1)&&t){if(this[de]&&(t=Buffer.concat([this[de],t]),this[de]=void 0),t.length<Zg)return this[de]=t,r?.(),!0;for(let d=0;this[ve]===void 0&&d<Aa.length;d++)t[d]!==Aa[d]&&(this[ve]=!1);let a=!1;if(this[ve]===!1&&this.zstd!==!1){a=!0;for(let d=0;d<Ra.length;d++)if(t[d]!==Ra[d]){a=!1;break}}let c=this.brotli===void 0&&!a;if(this[ve]===!1&&c)if(t.length<512)if(this[Jt])this.brotli=!0;else return this[de]=t,r?.(),!0;else try{new kn(t.subarray(0,512)),this.brotli=!1}catch{this.brotli=!0}if(this[ve]===void 0||this[ve]===!1&&(this.brotli||a)){let d=this[Jt];this[Jt]=!1,this[ve]=this[ve]===void 0?new bg({}):a?new Ig({}):new vg({}),this[ve].on("data",x=>this[Qi](x)),this[ve].on("error",x=>this.abort(x)),this[ve].on("end",()=>{this[Jt]=!0,this[Qi]()}),this[tr]=!0;let l=!!this[ve][d?"end":"write"](t);return this[tr]=!1,r?.(),l}}this[tr]=!0,this[ve]?this[ve].write(t):this[Qi](t),this[tr]=!1;let s=this[Pt].length>0?!1:this[Ot]?this[Ot].flowing:!0;return!s&&this[Pt].length===0&&this[Ot]?.once("drain",()=>this.emit("drain")),r?.(),s}[ga](t){t&&!this[Yt]&&(this[de]=this[de]?Buffer.concat([this[de],t]):t)}[ts](){if(this[Jt]&&!this[ha]&&!this[Yt]&&!this[Wr]){this[ha]=!0;let t=this[Sn];if(t&&t.blockRemain){let e=this[de]?this[de].length:0;this.warn("TAR_BAD_ARCHIVE",`Truncated input (needed ${t.blockRemain} more bytes, only ${e} available)`,{entry:t}),this[de]&&t.write(this[de]),t.end()}this[In](ns)}}[Qi](t){if(this[Wr]&&t)this[ga](t);else if(!t&&!this[de])this[ts]();else if(t){if(this[Wr]=!0,this[de]){this[ga](t);let e=this[de];this[de]=void 0,this[es](e)}else this[es](t);for(;this[de]&&this[de]?.length>=512&&!this[Yt]&&!this[is];){let e=this[de];this[de]=void 0,this[es](e)}this[Wr]=!1}(!this[de]||this[Jt])&&this[ts]()}[es](t){let e=0,r=t.length;for(;e+512<=r&&!this[Yt]&&!this[is];)switch(this[et]){case"begin":case"header":this[Lf](t,e),e+=512;break;case"ignore":case"body":e+=this[pa](t,e);break;case"meta":e+=this[Pf](t,e);break;default:throw new Error("invalid state: "+this[et])}e<r&&(this[de]=this[de]?Buffer.concat([t.subarray(e),this[de]]):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[Yt]||(this[ve]?(t&&this[ve].write(t),this[ve].end()):(this[Jt]=!0,(this.brotli===void 0||this.zstd===void 0)&&(t=t||Buffer.alloc(0)),t&&this.write(t),this[ts]())),this}},ei=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)},Yg=t=>{let e=t.onReadEntry;t.onReadEntry=e?r=>{e(r),r.resume()}:r=>r.resume()},gd=(t,e)=>{let r=new Map(e.map(c=>[ei(c),!0])),s=t.filter,a=(c,d="")=>{let l=d||ag(c).root||".",x;if(c===l)x=!1;else{let p=r.get(c);x=p!==void 0?p:a(og(c),l)}return r.set(c,x),x};t.filter=s?(c,d)=>s(c,d)&&a(ei(c)):c=>a(ei(c))},Xg=t=>{let e=new ai(t),r=t.file,s;try{s=ar.openSync(r,"r");let a=ar.fstatSync(s),c=t.maxReadSize||16*1024*1024;if(a.size<c){let d=Buffer.allocUnsafe(a.size),l=ar.readSync(s,d,0,a.size,0);e.end(l===d.byteLength?d:d.subarray(0,l))}else{let d=0,l=Buffer.allocUnsafe(c);for(;d<a.size;){let x=ar.readSync(s,l,0,c,d);if(x===0)break;d+=x,e.write(l.subarray(0,x))}e.end()}}finally{if(typeof s=="number")try{ar.closeSync(s)}catch{}}},Qg=(t,e)=>{let r=new ai(t),s=t.maxReadSize||16*1024*1024,a=t.file;return new Promise((c,d)=>{r.on("error",d),r.on("end",c),ar.stat(a,(l,x)=>{if(l)d(l);else{let p=new $a(a,{readSize:s,size:x.size});p.on("error",d),p.pipe(r)}})})},ur=ci(Xg,Qg,t=>new ai(t),t=>new ai(t),(t,e)=>{e?.length&&gd(t,e),t.noResume||Yg(t)}),md=(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:tm,parse:Bf}=em,Ya=t=>{let e="",r=Bf(t);for(;tm(t)||r.root;){let s=t.charAt(0)==="/"&&t.slice(0,4)!=="//?/"?"/":r.root;t=t.slice(s.length),e+=s,r=Bf(t)}return[e,t]},Cs=["|","<",">","?",":"],Xa=Cs.map(t=>String.fromCodePoint(61440+Number(t.codePointAt(0)))),nm=new Map(Cs.map((t,e)=>[t,Xa[e]])),rm=new Map(Xa.map((t,e)=>[t,Cs[e]])),zf=t=>Cs.reduce((e,r)=>e.split(r).join(nm.get(r)),t),im=t=>Xa.reduce((e,r)=>e.split(r).join(rm.get(r)),t),wd=(t,e)=>e?(t=J(t).replace(/^\.(\/|$)/,""),ei(e)+"/"+t):J(t),sm=16*1024*1024,Ff=Symbol("process"),Uf=Symbol("file"),Hf=Symbol("directory"),Da=Symbol("symlink"),qf=Symbol("hardlink"),Kr=Symbol("header"),ds=Symbol("read"),ka=Symbol("lstat"),us=Symbol("onlstat"),Oa=Symbol("onread"),Pa=Symbol("onreadlink"),La=Symbol("openfile"),Na=Symbol("onopenfile"),nn=Symbol("close"),ys=Symbol("mode"),Ma=Symbol("awaitDrain"),ma=Symbol("ondrain"),_t=Symbol("prefix"),_d=class extends On{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=Va(e);super(),this.path=J(t),this.portable=!!r.portable,this.maxReadSize=r.maxReadSize||sm,this.linkCache=r.linkCache||new Map,this.statCache=r.statCache||new Map,this.preservePaths=!!r.preservePaths,this.cwd=J(r.cwd||process.cwd()),this.strict=!!r.strict,this.noPax=!!r.noPax,this.noMtime=!!r.noMtime,this.mtime=r.mtime,this.prefix=r.prefix?J(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,d]=Ya(this.path);c&&typeof d=="string"&&(this.path=d,s=c)}this.win32=!!r.win32||process.platform==="win32",this.win32&&(this.path=im(this.path.replaceAll(/\\/g,"/")),t=t.replaceAll(/\\/g,"/")),this.absolute=J(r.absolute||Mf.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[us](a):this[ka]()}warn(t,e,r={}){return Is(this,t,e,r)}emit(t,...e){return t==="error"&&(this.#e=!0),super.emit(t,...e)}[ka](){wt.lstat(this.absolute,(t,e)=>{if(t)return this.emit("error",t);this[us](e)})}[us](t){this.statCache.set(this.absolute,t),this.stat=t,t.isFile()||(t.size=0),this.type=cm(t),this.emit("stat",t),this[Ff]()}[Ff](){switch(this.type){case"File":return this[Uf]();case"Directory":return this[Hf]();case"SymbolicLink":return this[Da]();default:return this.end()}}[ys](t){return md(t,this.type==="Directory",this.portable)}[_t](t){return wd(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 kn({path:this[_t](this.path),linkpath:this.type==="Link"&&this.linkpath!==void 0?this[_t](this.linkpath):this.linkpath,mode:this[ys](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 ws({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[_t](this.path),linkpath:this.type==="Link"&&this.linkpath!==void 0?this[_t](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)}[Hf](){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()}[Da](){wt.readlink(this.absolute,(t,e)=>{if(t)return this.emit("error",t);this[Pa](e)})}[Pa](t){this.linkpath=J(t),this[Kr](),this.end()}[qf](t){if(!this.stat)throw new Error("cannot create link entry without stat");this.type="Link",this.linkpath=J(Mf.relative(this.cwd,t)),this.stat.size=0,this[Kr](),this.end()}[Uf](){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[qf](e);this.linkCache.set(t,this.absolute)}if(this[Kr](),this.stat.size===0)return this.end();this[La]()}[La](){wt.open(this.absolute,"r",(t,e)=>{if(t)return this.emit("error",t);this[Na](e)})}[Na](t){if(this.fd=t,this.#e)return this[nn]();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[ds]()}[ds](){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");wt.read(t,e,r,s,a,(c,d)=>{if(c)return this[nn](()=>this.emit("error",c));this[Oa](d)})}[nn](t=()=>{}){this.fd!==void 0&&wt.close(this.fd,t)}[Oa](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[nn](()=>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[nn](()=>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[ma]():this[Ma](()=>this[ma]())}[Ma](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)}[ma](){if(!this.remain)return this.blockRemain&&super.write(Buffer.alloc(this.blockRemain)),this[nn](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[ds]()}},om=class extends _d{sync=!0;[ka](){this[us](wt.lstatSync(this.absolute))}[Da](){this[Pa](wt.readlinkSync(this.absolute))}[La](){this[Na](wt.openSync(this.absolute,"r"))}[ds](){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 d=wt.readSync(e,r,s,a,c);this[Oa](d),t=!1}finally{if(t)try{this[nn](()=>{})}catch{}}}[Ma](t){t()}[nn](t=()=>{}){this.fd!==void 0&&wt.closeSync(this.fd),t()}},am=class extends On{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 Is(this,t,e,r)}constructor(t,e={}){let r=Va(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=J(t.path),this.mode=t.mode!==void 0?this[ys](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?J(t.linkpath):void 0,typeof r.onwarn=="function"&&this.on("warn",r.onwarn);let a=!1;if(!this.preservePaths){let[d,l]=Ya(this.path);d&&typeof l=="string"&&(this.path=l,a=d)}this.remain=t.size,this.blockRemain=t.startBlockSize,this.onWriteEntry?.(this),this.header=new kn({path:this[_t](this.path),linkpath:this.type==="Link"&&this.linkpath!==void 0?this[_t](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 ws({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[_t](this.path),linkpath:this.type==="Link"&&this.linkpath!==void 0?this[_t](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)}[_t](t){return wd(t,this.prefix)}[ys](t){return md(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}},cm=t=>t.isFile()?"File":t.isDirectory()?"Directory":t.isSymbolicLink()?"SymbolicLink":"Unsupported",fm=class cr{tail;head;length=0;static create(e=[]){return new cr(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++)um(this,e[r]);return this.length}unshift(...e){for(var r=0,s=e.length;r<s;r++)lm(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 cr;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 cr;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 cr;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 cr;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 d=0;a&&d<e;d++)a=a.next;let c=[];for(let d=0;a&&d<r;d++)c.push(a.value),a=this.removeNode(a);a?a!==this.tail&&(a=a.prev):a=this.tail;for(let d of s)a=dm(this,a,d);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 dm(t,e,r){let s=e,a=e?e.next:t.head,c=new Qa(r,s,a,t);return c.next===void 0&&(t.tail=c),c.prev===void 0&&(t.head=c),t.length++,c}function um(t,e){t.tail=new Qa(e,t.tail,void 0,t),t.head||(t.head=t.tail),t.length++}function lm(t,e){t.head=new Qa(e,void 0,t.head,t),t.tail||(t.tail=t.head),t.length++}var Qa=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}},jf=class{path;absolute;entry;stat;readdir;pending=!1;pendingLink=!1;ignore=!1;piped=!1;constructor(t,e){this.path=t||"./",this.absolute=e}},Wf=Buffer.alloc(1024),ls=Symbol("onStat"),$r=Symbol("ended"),ft=Symbol("queue"),Vr=Symbol("queue"),Xt=Symbol("current"),Tn=Symbol("process"),Zr=Symbol("processing"),ss=Symbol("processJob"),dt=Symbol("jobs"),wa=Symbol("jobDone"),xs=Symbol("addFSEntry"),Kf=Symbol("addTarEntry"),Ba=Symbol("stat"),za=Symbol("readdir"),hs=Symbol("onreaddir"),ps=Symbol("pipe"),$f=Symbol("entry"),_a=Symbol("entryOpt"),gs=Symbol("writeEntryClass"),yd=Symbol("write"),ya=Symbol("ondrain"),Ts=class extends On{sync=!1;opt;cwd;maxReadSize;preservePaths;strict;noPax;prefix;linkCache;statCache;file;portable;zip;readdirCache;noDirRecurse;follow;noMtime;mtime;filter;jobs;[gs];onWriteEntry;[ft];[Vr]=new Map;[dt]=0;[Zr]=!1;[$r]=!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=J(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[gs]=_d,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 yg(t.gzip)),t.brotli&&(typeof t.brotli!="object"&&(t.brotli={}),this.zip=new Eg(t.brotli)),t.zstd&&(typeof t.zstd!="object"&&(t.zstd={}),this.zip=new Sg(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[ya]()),this.on("resume",()=>e.resume())}else this.on("drain",this[ya]);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 fm,this[dt]=0,this.jobs=Number(t.jobs)||4,this[Zr]=!1,this[$r]=!1}[yd](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[$r]=!0,this[Tn](),r&&r(),this}write(t){if(this[$r])throw new Error("write after end");return t instanceof pd?this[Kf](t):this[xs](t),this.flowing}[Kf](t){let e=J(Gf.resolve(this.cwd,t.path));if(!this.filter(t.path,t))t.resume();else{let r=new jf(t.path,e);r.entry=new am(t,this[_a](r)),r.entry.on("end",()=>this[wa](r)),this[dt]+=1,this[ft].push(r)}this[Tn]()}[xs](t){let e=J(Gf.resolve(this.cwd,t));this[ft].push(new jf(t,e)),this[Tn]()}[Ba](t){t.pending=!0,this[dt]+=1;let e=this.follow?"stat":"lstat";_s[e](t.absolute,(r,s)=>{t.pending=!1,this[dt]-=1,r?this.emit("error",r):this[ls](t,s)})}[ls](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[Xt])this[ss](t);else{let r=`${e.dev}:${e.ino}`,s=this[Vr].get(r);s?s.push(t):this[Vr].set(r,[t]),t.pendingLink=!0,t.pending=!0}this[Tn]()}[za](t){t.pending=!0,this[dt]+=1,_s.readdir(t.absolute,(e,r)=>{if(t.pending=!1,this[dt]-=1,e)return this.emit("error",e);this[hs](t,r)})}[hs](t,e){this.readdirCache.set(t.absolute,e),t.readdir=e,this[Tn]()}[Tn](){if(!this[Zr]){this[Zr]=!0;for(let t=this[ft].head;t&&this[dt]<this.jobs;t=t.next)if(this[ss](t.value),t.value.ignore){let e=t.next;this[ft].removeNode(t),t.next=e}this[Zr]=!1,this[$r]&&this[ft].length===0&&this[dt]===0&&(this.zip?this.zip.end(Wf):(super.write(Wf),super.end()))}}get[Xt](){return this[ft]&&this[ft].head&&this[ft].head.value}[wa](t){this[ft].shift(),this[dt]-=1;let{stat:e}=t;if(e&&e.isFile()&&e.nlink>1){let r=`${e.dev}:${e.ino}`,s=this[Vr].get(r);if(s){this[Vr].delete(r);for(let a of s)a.pending=!1,this[ss](a)}}this[Tn]()}[ss](t){if(t.pending&&t.pendingLink&&t===this[Xt]&&(t.pending=!1,t.pendingLink=!1),!t.pending){if(t.entry){t===this[Xt]&&!t.piped&&this[ps](t);return}if(!t.stat){let e=this.statCache.get(t.absolute);e?this[ls](t,e):this[Ba](t)}if(t.stat&&!t.ignore){if(!this.noDirRecurse&&t.stat.isDirectory()&&!t.readdir){let e=this.readdirCache.get(t.absolute);if(e?this[hs](t,e):this[za](t),!t.readdir)return}if(t.entry=this[$f](t),!t.entry){t.ignore=!0;return}t===this[Xt]&&!t.piped&&this[ps](t)}}}[_a](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}}[$f](t){this[dt]+=1;try{return new this[gs](t.path,this[_a](t)).on("end",()=>this[wa](t)).on("error",e=>this.emit("error",e))}catch(e){this.emit("error",e)}}[ya](){this[Xt]&&this[Xt].entry&&this[Xt].entry.resume()}[ps](t){t.piped=!0,t.readdir&&t.readdir.forEach(s=>{let a=t.path,c=a==="./"?"":a.replace(/\/*$/,"/");this[xs](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={}){Is(this,t,e,r)}},ec=class extends Ts{sync=!0;constructor(t){super(t),this[gs]=om}pause(){}resume(){}[Ba](t){let e=this.follow?"statSync":"lstatSync";this[ls](t,_s[e](t.absolute))}[za](t){this[hs](t,_s.readdirSync(t.absolute))}[ps](t){let e=t.entry,r=this.zip;if(t.readdir&&t.readdir.forEach(s=>{let a=t.path,c=a==="./"?"":a.replace(/\/*$/,"/");this[xs](c+s)}),!e)throw new Error("Cannot pipe without source");r?e.on("data",s=>{r.write(s)}):e.on("data",s=>{super[yd](s)})}},xm=(t,e)=>{let r=new ec(t),s=new ad(t.file,{mode:t.mode||438});r.pipe(s),bd(r,e)},hm=(t,e)=>{let r=new Ts(t),s=new vs(t.file,{mode:t.mode||438});r.pipe(s);let a=new Promise((c,d)=>{s.on("error",d),s.on("close",c),r.on("error",d)});return Ed(r,e).catch(c=>r.emit("error",c)),a},bd=(t,e)=>{e.forEach(r=>{r.charAt(0)==="@"?ur({file:cd.resolve(t.cwd,r.slice(1)),sync:!0,noResume:!0,onReadEntry:s=>t.add(s)}):t.add(r)}),t.end()},Ed=async(t,e)=>{for(let r of e)r.charAt(0)==="@"?await ur({file:cd.resolve(String(t.cwd),r.slice(1)),noResume:!0,onReadEntry:s=>{t.add(s)}}):t.add(r);t.end()},pm=(t,e)=>{let r=new ec(t);return bd(r,e),r},gm=(t,e)=>{let r=new Ts(t);return Ed(r,e).catch(s=>r.emit("error",s)),r},g2=ci(xm,hm,pm,gm,(t,e)=>{if(!e?.length)throw new TypeError("no paths specified to add to archive")}),wm=process.env.__FAKE_PLATFORM__||process.platform,Cd=wm==="win32",{O_CREAT:Td,O_NOFOLLOW:Vf,O_TRUNC:Ad,O_WRONLY:Rd}=Id.constants,Dd=Number(process.env.__FAKE_FS_O_FILENAME__)||Id.constants.UV_FS_O_FILEMAP||0,_m=Cd&&!!Dd,ym=512*1024,bm=Dd|Ad|Td|Rd,Zf=!Cd&&typeof Vf=="number"?Vf|Ad|Td|Rd:null,kd=Zf!==null?()=>Zf:_m?t=>t<ym?bm:"w":()=>"w",Fa=(t,e,r)=>{try{return As.lchownSync(t,e,r)}catch(s){if(s?.code!=="ENOENT")throw s}},bs=(t,e,r,s)=>{As.lchown(t,e,r,a=>{s(a&&a?.code!=="ENOENT"?a:null)})},Em=(t,e,r,s,a)=>{if(e.isDirectory())Od(ti.resolve(t,e.name),r,s,c=>{if(c)return a(c);let d=ti.resolve(t,e.name);bs(d,r,s,a)});else{let c=ti.resolve(t,e.name);bs(c,r,s,a)}},Od=(t,e,r,s)=>{As.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 bs(t,e,r,s);let d=c.length,l=null,x=p=>{if(!l){if(p)return s(l=p);if(--d===0)return bs(t,e,r,s)}};for(let p of c)Em(t,p,e,r,x)})},vm=(t,e,r,s)=>{e.isDirectory()&&Pd(ti.resolve(t,e.name),r,s),Fa(ti.resolve(t,e.name),r,s)},Pd=(t,e,r)=>{let s;try{s=As.readdirSync(t,{withFileTypes:!0})}catch(a){let c=a;if(c?.code==="ENOENT")return;if(c?.code==="ENOTDIR"||c?.code==="ENOTSUP")return Fa(t,e,r);throw c}for(let a of s)vm(t,a,e,r);return Fa(t,e,r)},Ld=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"}},Rs=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"}},Im=(t,e)=>{Ye.stat(t,(r,s)=>{(r||!s.isDirectory())&&(r=new Ld(t,r?.code||"ENOTDIR")),e(r)})},Cm=(t,e,r)=>{t=J(t);let s=e.umask??18,a=e.mode|448,c=(a&s)!==0,d=e.uid,l=e.gid,x=typeof d=="number"&&typeof l=="number"&&(d!==e.processUid||l!==e.processGid),p=e.preserve,w=e.unlink,v=J(e.cwd),I=(E,S)=>{E?r(E):S&&x?Od(S,d,l,C=>I(C)):c?Ye.chmod(t,a,r):r()};if(t===v)return Im(t,I);if(p)return Sm.mkdir(t,{mode:a,recursive:!0}).then(E=>I(null,E??void 0),I);let b=J(Es.relative(v,t)).split("/");Ua(v,b,a,w,v,void 0,I)},Ua=(t,e,r,s,a,c,d)=>{if(e.length===0)return d(null,c);let l=e.shift(),x=J(Es.resolve(t+"/"+l));Ye.mkdir(x,r,Nd(x,e,r,s,a,c,d))},Nd=(t,e,r,s,a,c,d)=>l=>{l?Ye.lstat(t,(x,p)=>{if(x)x.path=x.path&&J(x.path),d(x);else if(p.isDirectory())Ua(t,e,r,s,a,c,d);else if(s)Ye.unlink(t,w=>{if(w)return d(w);Ye.mkdir(t,r,Nd(t,e,r,s,a,c,d))});else{if(p.isSymbolicLink())return d(new Rs(t,t+"/"+e.join("/")));d(l)}}):(c=c||t,Ua(t,e,r,s,a,c,d))},Tm=t=>{let e=!1,r;try{e=Ye.statSync(t).isDirectory()}catch(s){r=s?.code}finally{if(!e)throw new Ld(t,r??"ENOTDIR")}},Am=(t,e)=>{t=J(t);let r=e.umask??18,s=e.mode|448,a=(s&r)!==0,c=e.uid,d=e.gid,l=typeof c=="number"&&typeof d=="number"&&(c!==e.processUid||d!==e.processGid),x=e.preserve,p=e.unlink,w=J(e.cwd),v=E=>{E&&l&&Pd(E,c,d),a&&Ye.chmodSync(t,s)};if(t===w)return Tm(w),v();if(x)return v(Ye.mkdirSync(t,{mode:s,recursive:!0})??void 0);let I=J(Es.relative(w,t)).split("/"),b;for(let E=I.shift(),S=w;E&&(S+="/"+E);E=I.shift()){S=J(Es.resolve(S));try{Ye.mkdirSync(S,s),b=b||S}catch{let C=Ye.lstatSync(S);if(C.isDirectory())continue;if(p){Ye.unlinkSync(S),Ye.mkdirSync(S,s),b=b||S;continue}else if(C.isSymbolicLink())return new Rs(S,S+"/"+I.join("/"))}}return v(b)},ba=Object.create(null),Jf=1e4,nr=new Set,Rm=t=>{nr.has(t)?nr.delete(t):ba[t]=t.normalize("NFD").toLocaleLowerCase("en").toLocaleUpperCase("en"),nr.add(t);let e=ba[t],r=nr.size-Jf;if(r>Jf/10){for(let s of nr)if(nr.delete(s),delete ba[s],--r<=0)break}return e},Dm=process.env.TESTING_TAR_FAKE_PLATFORM||process.platform,km=Dm==="win32",Om=t=>t.split("/").slice(0,-1).reduce((e,r)=>{let s=e.at(-1);return s!==void 0&&(r=Md(s,r)),e.push(r||"/"),e},[]),Pm=class{#e=new Map;#n=new Map;#r=new Set;reserve(t,e){t=km?["win32 parallelization disabled"]:t.map(s=>ei(Md(Rm(s))));let r=new Set(t.map(s=>Om(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 d=this.#e.get(c);if(!d||d?.[0]!==t)continue;let l=d[1];if(!l){this.#e.delete(c);continue}if(d.shift(),typeof l=="function")a.add(l);else for(let x of l)a.add(x)}for(let c of s){let d=this.#e.get(c),l=d?.[0];if(!(!d||!(l instanceof Set)))if(l.size===1&&d.length===1){this.#e.delete(c);continue}else if(l.size===1){d.shift();let x=d[0];typeof x=="function"&&a.add(x)}else l.delete(t)}return this.#r.delete(t),a.forEach(c=>this.#i(c)),!0}},Lm=()=>process.umask(),Yf=Symbol("onEntry"),Ha=Symbol("checkFs"),Xf=Symbol("checkFs2"),qa=Symbol("isReusable"),nt=Symbol("makeFs"),Ga=Symbol("file"),ja=Symbol("directory"),ms=Symbol("link"),Qf=Symbol("symlink"),ed=Symbol("hardlink"),Xr=Symbol("ensureNoSymlink"),td=Symbol("unsupported"),nd=Symbol("checkPath"),Ea=Symbol("stripAbsolutePath"),rn=Symbol("mkdir"),Pe=Symbol("onError"),os=Symbol("pending"),rd=Symbol("pend"),rr=Symbol("unpend"),va=Symbol("ended"),Sa=Symbol("maybeClose"),Wa=Symbol("skip"),ni=Symbol("doChown"),ri=Symbol("uid"),ii=Symbol("gid"),si=Symbol("checkedCwd"),Nm=process.env.TESTING_TAR_FAKE_PLATFORM||process.platform,oi=Nm==="win32",Mm=1024,Bm=(t,e)=>{if(!oi)return X.unlink(t,e);let r=t+".DELETE."+Sd(16).toString("hex");X.rename(t,r,s=>{if(s)return e(s);X.unlink(r,e)})},zm=t=>{if(!oi)return X.unlinkSync(t);let e=t+".DELETE."+Sd(16).toString("hex");X.renameSync(t,e),X.unlinkSync(e)},id=(t,e,r)=>t!==void 0&&t===t>>>0?t:e!==void 0&&e===e>>>0?e:r,tc=class extends ai{[va]=!1;[si]=!1;[os]=0;reservations=new Pm;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[va]=!0,this[Sa]()},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:Mm,this.forceChown=t.forceChown===!0,this.win32=!!t.win32||oi,this.newer=!!t.newer,this.keep=!!t.keep,this.noMtime=!!t.noMtime,this.preservePaths=!!t.preservePaths,this.unlink=!!t.unlink,this.cwd=J(Ce.resolve(t.cwd||process.cwd())),this.strip=Number(t.strip)||0,this.processUmask=this.chmod?typeof t.processUmask=="number"?t.processUmask:Lm():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[Yf](e))}warn(t,e,r={}){return(t==="TAR_BAD_ARCHIVE"||t==="TAR_ABORT")&&(r.recoverable=!1),super.warn(t,e,r)}[Sa](){this[va]&&this[os]===0&&(this.emit("prefinish"),this.emit("finish"),this.emit("end"))}[Ea](t,e){let r=t[e],{type:s}=t;if(!r||this.preservePaths)return!0;let[a,c]=Ya(r),d=c.replaceAll(/\\/g,"/").split("/");if(d.includes("..")||oi&&/^[a-z]:\.\.$/i.test(d[0]??"")){if(e==="path"||s==="Link")return this.warn("TAR_ENTRY_ERROR",`${e} contains '..'`,{entry:t,[e]:r}),!1;let l=Ce.posix.dirname(t.path),x=Ce.posix.normalize(Ce.posix.join(l,d.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}[nd](t){let e=J(t.path),r=e.split("/");if(this.strip){if(r.length<this.strip)return!1;if(t.type==="Link"){let s=J(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[Ea](t,"path")||!this[Ea](t,"linkpath"))return!1;if(t.absolute=Ce.isAbsolute(t.path)?J(Ce.resolve(t.path)):J(Ce.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:J(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}=Ce.win32.parse(String(t.absolute));t.absolute=s+zf(String(t.absolute).slice(s.length));let{root:a}=Ce.win32.parse(t.path);t.path=a+zf(t.path.slice(a.length))}return!0}[Yf](t){if(!this[nd](t))return t.resume();switch(mm.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[Ha](t);default:return this[td](t)}}[Pe](t,e){t.name==="CwdError"?this.emit("error",t):(this.warn("TAR_ENTRY_ERROR",t,{entry:e}),this[rr](),e.resume())}[rn](t,e,r){Cm(J(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)}[ni](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}[ri](t){return id(this.uid,t.uid,this.processUid)}[ii](t){return id(this.gid,t.gid,this.processGid)}[Ga](t,e){let r=typeof t.mode=="number"?t.mode&4095:this.fmode,s=new vs(String(t.absolute),{flags:kd(t.size),mode:r,autoClose:!1});s.on("error",l=>{s.fd&&X.close(s.fd,()=>{}),s.write=()=>!0,this[Pe](l,t),e()});let a=1,c=l=>{if(l){s.fd&&X.close(s.fd,()=>{}),this[Pe](l,t),e();return}--a===0&&s.fd!==void 0&&X.close(s.fd,x=>{x?this[Pe](x,t):this[rr](),e()})};s.on("finish",()=>{let l=String(t.absolute),x=s.fd;if(typeof x=="number"&&t.mtime&&!this.noMtime){a++;let p=t.atime||new Date,w=t.mtime;X.futimes(x,p,w,v=>v?X.utimes(l,p,w,I=>c(I&&v)):c())}if(typeof x=="number"&&this[ni](t)){a++;let p=this[ri](t),w=this[ii](t);typeof p=="number"&&typeof w=="number"&&X.fchown(x,p,w,v=>v?X.chown(l,p,w,I=>c(I&&v)):c())}c()});let d=this.transform&&this.transform(t)||t;d!==t&&(d.on("error",l=>{this[Pe](l,t),e()}),t.pipe(d)),d.pipe(s)}[ja](t,e){let r=typeof t.mode=="number"?t.mode&4095:this.dmode;this[rn](String(t.absolute),r,s=>{if(s){this[Pe](s,t),e();return}let a=1,c=()=>{--a===0&&(e(),this[rr](),t.resume())};t.mtime&&!this.noMtime&&(a++,X.utimes(String(t.absolute),t.atime||new Date,t.mtime,c)),this[ni](t)&&(a++,X.chown(String(t.absolute),Number(this[ri](t)),Number(this[ii](t)),c)),c()})}[td](t){t.unsupported=!0,this.warn("TAR_ENTRY_UNSUPPORTED",`unsupported entry type: ${t.type}`,{entry:t}),t.resume()}[Qf](t,e){let r=J(Ce.relative(this.cwd,Ce.resolve(Ce.dirname(String(t.absolute)),String(t.linkpath)))).split("/");this[Xr](t,this.cwd,r,()=>this[ms](t,String(t.linkpath),"symlink",e),s=>{this[Pe](s,t),e()})}[ed](t,e){let r=J(Ce.resolve(this.cwd,String(t.linkpath))),s=J(String(t.linkpath)).split("/");this[Xr](t,this.cwd,s,()=>this[ms](t,r,"link",e),a=>{this[Pe](a,t),e()})}[Xr](t,e,r,s,a){let c=r.shift();if(this.preservePaths||c===void 0)return s();let d=Ce.resolve(e,c);X.lstat(d,(l,x)=>{if(l)return s();if(x?.isSymbolicLink())return a(new Rs(d,Ce.resolve(d,r.join("/"))));this[Xr](t,d,r,s,a)})}[rd](){this[os]++}[rr](){this[os]--,this[Sa]()}[Wa](t){this[rr](),t.resume()}[qa](t,e){return t.type==="File"&&!this.unlink&&e.isFile()&&e.nlink<=1&&!oi}[Ha](t){this[rd]();let e=[t.path];t.linkpath&&e.push(t.linkpath),this.reservations.reserve(e,r=>this[Xf](t,r))}[Xf](t,e){let r=d=>{e(d)},s=()=>{this[rn](this.cwd,this.dmode,d=>{if(d){this[Pe](d,t),r();return}this[si]=!0,a()})},a=()=>{if(t.absolute!==this.cwd){let d=J(Ce.dirname(String(t.absolute)));if(d!==this.cwd)return this[rn](d,this.dmode,l=>{if(l){this[Pe](l,t),r();return}c()})}c()},c=()=>{X.lstat(String(t.absolute),(d,l)=>{if(l&&(this.keep||this.newer&&l.mtime>(t.mtime??l.mtime))){this[Wa](t),r();return}if(d||this[qa](t,l))return this[nt](null,t,r);if(l.isDirectory()){if(t.type==="Directory"){let x=this.chmod&&t.mode&&(l.mode&4095)!==t.mode,p=w=>this[nt](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[nt](x??null,t,r))}if(t.absolute===this.cwd)return this[nt](null,t,r);Bm(String(t.absolute),x=>this[nt](x??null,t,r))})};this[si]?a():s()}[nt](t,e,r){if(t){this[Pe](t,e),r();return}switch(e.type){case"File":case"OldFile":case"ContiguousFile":return this[Ga](e,r);case"Link":return this[ed](e,r);case"SymbolicLink":return this[Qf](e,r);case"Directory":case"GNUDumpDir":return this[ja](e,r)}}[ms](t,e,r,s){X[r](e,String(t.absolute),a=>{a?this[Pe](a,t):(this[rr](),t.resume()),s()})}},Jr=t=>{try{return[null,t()]}catch(e){return[e,null]}},Bd=class extends tc{sync=!0;[nt](t,e){return super[nt](t,e,()=>{})}[Ha](t){if(!this[si]){let a=this[rn](this.cwd,this.dmode);if(a)return this[Pe](a,t);this[si]=!0}if(t.absolute!==this.cwd){let a=J(Ce.dirname(String(t.absolute)));if(a!==this.cwd){let c=this[rn](a,this.dmode);if(c)return this[Pe](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[Wa](t);if(e||this[qa](t,r))return this[nt](null,t);if(r.isDirectory()){if(t.type==="Directory"){let c=this.chmod&&t.mode&&(r.mode&4095)!==t.mode,[d]=c?Jr(()=>{X.chmodSync(String(t.absolute),Number(t.mode))}):[];return this[nt](d,t)}let[a]=Jr(()=>X.rmdirSync(String(t.absolute)));this[nt](a,t)}let[s]=t.absolute===this.cwd?[]:Jr(()=>zm(String(t.absolute)));this[nt](s,t)}[Ga](t,e){let r=typeof t.mode=="number"?t.mode&4095:this.fmode,s=d=>{let l;try{X.closeSync(a)}catch(x){l=x}(d||l)&&this[Pe](d||l,t),e()},a;try{a=X.openSync(String(t.absolute),kd(t.size),r)}catch(d){return s(d)}let c=this.transform&&this.transform(t)||t;c!==t&&(c.on("error",d=>this[Pe](d,t)),t.pipe(c)),c.on("data",d=>{try{X.writeSync(a,d,0,d.length)}catch(l){s(l)}}),c.on("end",()=>{let d=null;if(t.mtime&&!this.noMtime){let l=t.atime||new Date,x=t.mtime;try{X.futimesSync(a,l,x)}catch(p){try{X.utimesSync(String(t.absolute),l,x)}catch{d=p}}}if(this[ni](t)){let l=this[ri](t),x=this[ii](t);try{X.fchownSync(a,Number(l),Number(x))}catch(p){try{X.chownSync(String(t.absolute),Number(l),Number(x))}catch{d=d||p}}}s(d)})}[ja](t,e){let r=typeof t.mode=="number"?t.mode&4095:this.dmode,s=this[rn](String(t.absolute),r);if(s){this[Pe](s,t),e();return}if(t.mtime&&!this.noMtime)try{X.utimesSync(String(t.absolute),t.atime||new Date,t.mtime)}catch{}if(this[ni](t))try{X.chownSync(String(t.absolute),Number(this[ri](t)),Number(this[ii](t)))}catch{}e(),t.resume()}[rn](t,e){try{return Am(J(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}}[Xr](t,e,r,s,a){if(this.preservePaths||r.length===0)return s();let c=e;for(let d of r){c=Ce.resolve(c,d);let[l,x]=Jr(()=>X.lstatSync(c));if(l)return s();if(x.isSymbolicLink())return a(new Rs(c,Ce.resolve(e,r.join("/"))))}s()}[ms](t,e,r,s){let a=`${r}Sync`;try{X[a](e,String(t.absolute)),s(),t.resume()}catch(c){return this[Pe](c,t)}}},Fm=t=>{let e=new Bd(t),r=t.file,s=vd.statSync(r),a=t.maxReadSize||16*1024*1024;new sg(r,{readSize:a,size:s.size}).pipe(e)},Um=(t,e)=>{let r=new tc(t),s=t.maxReadSize||16*1024*1024,a=t.file;return new Promise((c,d)=>{r.on("error",d),r.on("close",c),vd.stat(a,(l,x)=>{if(l)d(l);else{let p=new $a(a,{readSize:s,size:x.size});p.on("error",d),p.pipe(r)}})})},zd=ci(Fm,Um,t=>new Bd(t),t=>new tc(t),(t,e)=>{e?.length&&gd(t,e)}),Hm=(t,e)=>{let r=new ec(t),s=!0,a,c;try{try{a=Je.openSync(t.file,"r+")}catch(x){if(x?.code==="ENOENT")a=Je.openSync(t.file,"w+");else throw x}let d=Je.fstatSync(a),l=Buffer.alloc(512);e:for(c=0;c<d.size;c+=512){for(let w=0,v=0;w<512;w+=v){if(v=Je.readSync(a,l,w,l.length-w,c+w),c===0&&l[0]===31&&l[1]===139)throw new Error("cannot append to compressed archives");if(!v)break e}let x=new kn(l);if(!x.cksumValid)break;let p=512*Math.ceil((x.size||0)/512);if(c+p+512>d.size)break;c+=p,t.mtimeCache&&x.mtime&&t.mtimeCache.set(String(x.path),x.mtime)}s=!1,qm(t,r,c,a,e)}finally{if(s)try{Je.closeSync(a)}catch{}}},qm=(t,e,r,s,a)=>{let c=new ad(t.file,{fd:s,start:r});e.pipe(c),jm(e,a)},Gm=(t,e)=>{e=Array.from(e);let r=new Ts(t),s=(a,c,d)=>{let l=(I,b)=>{I?Je.close(a,E=>d(I)):d(null,b)},x=0;if(c===0)return l(null,0);let p=0,w=Buffer.alloc(512),v=(I,b)=>{if(I||b===void 0)return l(I);if(p+=b,p<512&&b)return Je.read(a,w,p,w.length-p,x+p,v);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 E=new kn(w);if(!E.cksumValid)return l(null,x);let S=512*Math.ceil((E.size??0)/512);if(x+S+512>c||(x+=S+512,x>=c))return l(null,x);t.mtimeCache&&E.mtime&&t.mtimeCache.set(String(E.path),E.mtime),p=0,Je.read(a,w,0,512,x,v)};Je.read(a,w,0,512,x,v)};return new Promise((a,c)=>{r.on("error",c);let d="r+",l=(x,p)=>{if(x&&x.code==="ENOENT"&&d==="r+")return d="w+",Je.open(t.file,d,l);if(x||!p)return c(x);Je.fstat(p,(w,v)=>{if(w)return Je.close(p,()=>c(w));s(p,v.size,(I,b)=>{if(I)return c(I);let E=new vs(t.file,{fd:p,start:b});r.pipe(E),E.on("error",c),E.on("close",a),Wm(r,e)})})};Je.open(t.file,d,l)})},jm=(t,e)=>{e.forEach(r=>{r.charAt(0)==="@"?ur({file:Fd.resolve(t.cwd,r.slice(1)),sync:!0,noResume:!0,onReadEntry:s=>t.add(s)}):t.add(r)}),t.end()},Wm=async(t,e)=>{for(let r of e)r.charAt(0)==="@"?await ur({file:Fd.resolve(String(t.cwd),r.slice(1)),noResume:!0,onReadEntry:s=>t.add(s)}):t.add(r);t.end()},Yr=ci(Hm,Gm,()=>{throw new TypeError("file is required")},()=>{throw new TypeError("file is required")},(t,e)=>{if(!xg(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")}),k2=ci(Yr.syncFile,Yr.asyncFile,Yr.syncNoFile,Yr.asyncNoFile,(t,e=[])=>{Yr.validate?.(t,e),Km(t)}),Km=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))};Kt();var bt={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 fi(t){return t?.cozeDeployType==="cloud"?"cloud":"local"}function Ud(t){let e=t?.cozeAccountId?.trim();if(!(!e||e==="0"))return e}function Hd(t){let e=t?.cozeGroupId?.trim();if(!(!e||e==="0"))return e}function qd(t){let{_meta:e,...r}=t;return{stripped:r,meta:e}}function lr(t){if(!t?.cozeAgentId)throw new Error("missing _meta.cozeAgentId");return t.cozeAgentId}var R=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)}};te();Fe();function Mt(t,e){if(fi(t)!=="cloud")throw new R("OPERATION_NOT_ALLOWED_FOR_LOCAL",`${e} is not allowed for local agent`)}function Ds(t){return t.startsWith("http://")||t.startsWith("https://")}function ks(t){return t.endsWith("/")?t.slice(0,-1):t}te();var Os="1008033",Gd="1289";var jd="pbbp2",Wd="https://www.coze.cn",Kd="/api/coze_claw/resource/get_frontier_key",Vm="https://www.coze.cn",Zm="wss://frontier.coze.cn";function Ps(t){return t??process.env.COZE_BRIDGE_HANDSHAKE_URL??Vm}function $d(t){return t??process.env.COZE_BRIDGE_FRONTIER_URL??Zm}function xr(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 ui(t){return t?t.startsWith("boe_")?{ttEnv:t}:{ttEnv:t,usePpe:"1"}:{}}var di=G("handshake");async function nc(t){let e=Ps(t.endpoint),r=t.timeoutMs??1e4,s=`${ks(e)}${Kd}?aid=${encodeURIComponent(Os)}`,a={Authorization:`Bearer ${t.privatecode}`,Accept:"application/json",...xr(t.ppeOverride)},c=new AbortController,d=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")??"",p=l.headers.get("x-tt-trace-id")??"";if(!l.ok){let E=await l.text().catch(()=>"");throw new R("UPSTREAM_HANDSHAKE_FAILED",`handshake HTTP ${l.status} logid=${x}: ${E.slice(0,200)}`)}let w=await l.json();if(w.code!==void 0&&w.code!==0)throw new R("UPSTREAM_HANDSHAKE_FAILED",`handshake code=${w.code} msg=${w.msg??"-"} logid=${x}`);let v=w.data??{},I=typeof v.access_key=="string"&&v.access_key||typeof v.accessKey=="string"&&v.accessKey||void 0,b=typeof v.device_id=="string"&&v.device_id||typeof v.deviceId=="string"&&v.deviceId||void 0;if(!I||!b){let E=JSON.stringify(w).slice(0,500);throw new R("UPSTREAM_HANDSHAKE_FAILED",`handshake response missing access_key/device_id (also tried camelCase) logid=${x}: ${E}`)}return di.info("handshake ok",{remoteDeviceId:b,logid:x,traceId:p}),{accessKey:I,deviceId:b}}catch(l){if(l instanceof R)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 R("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 R("UPSTREAM_HANDSHAKE_FAILED",String(l),{cause:l})}finally{clearTimeout(d)}}var rc=process.env.COZE_BRIDGE_LLM_GATEWAY_URL?.trim()||"https://llm-gateway.coze.cn",Et="auto";function Vd(t){return{model:t.model??Et,...t.modelToken?{modelToken:t.modelToken}:{}}}function Zd(t){return!t||t===Et}function Jd(t){let e={};return t.modelToken?(e.ANTHROPIC_BASE_URL=rc,e.ANTHROPIC_AUTH_TOKEN=t.modelToken,e.ANTHROPIC_MODEL=t.model||Et,t.modelInfo?.contextWindow&&(e.CLAUDE_CODE_MAX_CONTEXT_TOKENS=String(t.modelInfo.contextWindow))):Zd(t.model)||(e.ANTHROPIC_MODEL=t.model),e}function Yd(t){let e=[];return t.modelToken?e.push("-c",`model="${t.model||Et}"`):Zd(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="${rc}/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 Xd(t){return t.modelToken?{OPENAI_API_KEY:t.modelToken}:{}}function ic(t,e){let{ttEnv:r,usePpe:s}=ui(t),a={};return r&&(a["x-tt-env"]=r),s&&(a["x-use-ppe"]=s),e&&(a["x-mock-scenario"]=e),a}function Qd(t,e,r){if(!t.modelToken)return{};let s=ic(e,r);return Object.keys(s).length===0?{}:{ANTHROPIC_CUSTOM_HEADERS:Object.entries(s).map(([c,d])=>`${c}:${d}`).join(`
119
- `)}}function sc(t){return`coze-session-${t.replace(/[^A-Za-z0-9_-]+/g,"-")}`}function eu(t,e,r){if(!t.modelToken)return null;let s=t.model||Et,a=ic(e,r),c=["text"];t.modelInfo?.capabilities?.image===!0&&c.push("image");let d={baseUrl:`${rc}/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&&(d.headers=a),d}function tu(t,e,r){if(!t.modelToken)return[];let s=ic(e,r),a=[];for(let[c,d]of Object.entries(s))a.push("-c",`model_providers.coze.http_headers.${c}="${d}"`);return a}var Le=G("agent-handlers"),nu=5*1024*1024,tw=1,nw=6,rw=new Set(["node_modules",".git",".coze","dist","build",".next"]),Ls=class{constructor(e){this.opts=e}opts;async listSkills(e){Mt(e._meta,"_agent/listSkills");let r=lr(e._meta),s=await this.loadAgentCfg(r),a=s?.workspace??Rt(r).workspace,c=s?.skills??[],d=[];for(let l of c){let x=vt(a,l.relPath,"SKILL.md");await Xm(x).then(w=>w.isFile()).catch(()=>!1)&&d.push(cw(l))}return{skills:d}}async addSkills(e){Mt(e._meta,"_agent/addSkills");let r=lr(e._meta),s=await this.requireAgentCfg(r),a=e.skills??[],c=[...s.skills??[]],d=new Map(c.map((x,p)=>[x.skillId,p])),l=[];for(let x of a){let p=await lc({agentId:r,workspace:s.workspace,framework:s.framework,skill:x});xc(c,d,p),l.push(x)}return await Fi(r,c),this.reloadAgentSessions(r,"skills-added"),{installedSkills:l}}async removeSkills(e){Mt(e._meta,"_agent/removeSkills");let r=lr(e._meta),s=await this.requireAgentCfg(r),a=new Set(e.skillIds??[]),c=s.skills??[],d=[];for(let l of c){if(!a.has(l.skillId)){d.push(l);continue}let x=vt(s.workspace,l.relPath);await Ym(x,{recursive:!0,force:!0}),Le.info("skill removed",{agentId:r,skillId:l.skillId,relPath:l.relPath})}return await Fi(r,d),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 d=c.acpSessionId;if(d&&s.activeTriggers.has(d)||this.isRuntimePendingPermission(c)){c.reloadAfterTurn=!0,Le.info("downstream busy, scheduling reload after turn",{reason:r,agentId:e,framework:s.framework,cloudId:a,acpId:d});continue}let x=c.downstream;c.downstream=void 0,Le.info("killing downstream for workspace reload (idle)",{reason:r,agentId:e,framework:s.framework,cloudId:a,acpId:d}),x.stop(r).catch(p=>Le.warn("downstream stop failed during reload (ignored)",{reason:r,agentId:e,cloudId:a,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 Le.info("_agent/update: empty cozeIdentity, noop",{agentId:e.agentId}),{ok:!0};let r=e.agentId,s=await qe(r);if(!s)throw new R("AGENT_NOT_FOUND",`agent not found: ${r}`);if(s.cozeIdentity===e.cozeIdentity)return Le.info("_agent/update: cozeIdentity unchanged, noop",{agentId:r}),{ok:!0};try{await Zn(s.workspace,s.framework,r,e.cozeIdentity)}catch(a){throw Le.error("_agent/update: writeInstructionFile failed, aborting update",{agentId:r,framework:s.framework,workspace:s.workspace,err:String(a)}),new R("AGENT_PROTOCOL_ERROR",`failed to write instruction file for agent ${r}: ${String(a)}`,{cause:a})}return s.cozeIdentity=e.cozeIdentity,await $e(s),Le.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 R("IPC_BAD_REQUEST","_agent/disconnect: missing agentId");let s=await qe(r);return s?(s.disconnectedAt=Date.now(),s.disconnectReason=e.reason??"",await $e(s),Le.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}):(Le.warn("_agent/disconnect: agent not found, ignoring",{agentId:r}),{ok:!0})}async switchModel(e){if(Mt(e._meta,"_agent/switchModel"),!e.agentId)throw new R("IPC_BAD_REQUEST","_agent/switchModel: missing agentId");let r=e.model?.trim()?e.model:Et,s=await qe(e.agentId);if(!s)throw new R("AGENT_NOT_FOUND",`agent not found: ${e.agentId}`);s.model=r,e.modelInfo&&(s.modelInfo=e.modelInfo),await $e(s),Le.info("_agent/switchModel: model persisted",{agentId:e.agentId,model:r,reason:e.reason??""});let a=this.opts.agents.get(e.agentId);if(!a)return Le.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(d=>Le.warn("cleanupOpenclawProviders before switchModel failed (ignored)",{agentId:e.agentId,err:String(d)}));let c=[];for(let[d,l]of a.allSessionQueues())c.push(l.enqueue(async()=>{let x=a.sessions.get(d);x?.downstream&&(await x.downstream.stop(`switchModel: ${r}`).catch(()=>{}),x.downstream=void 0)}));return await Promise.all(c),Le.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(Mt(e._meta,bt.RESET),!e.agentId)throw new R("IPC_BAD_REQUEST",`${bt.RESET}: missing agentId`);return await this.runDetailSync(e.agentId,bt.RESET,e.reason),{ok:!0}}async repairAgent(e){if(Mt(e._meta,bt.REPAIR),!e.agentId)throw new R("IPC_BAD_REQUEST",`${bt.REPAIR}: missing agentId`);let r=await this.loadAgentCfg(e.agentId);if(r&&r.framework!=="openclaw")throw new R("IPC_BAD_REQUEST",`${bt.REPAIR} only allowed for openclaw, got ${r.framework}`);if(r&&this.opts.openclawRepair)try{await this.opts.openclawRepair(e.agentId,r.workspace)}catch(s){Le.warn("openclaw repair (delete+add) failed (ignored)",{agentId:e.agentId,reason:e.reason,err:String(s)})}return await this.runDetailSync(e.agentId,bt.REPAIR,e.reason),{ok:!0}}async runDetailSync(e,r,s){if(!this.opts.detailSyncer){Le.warn("detailSyncer not wired, skipping sync",{method:r,agentId:e});return}try{await this.opts.detailSyncer(e)}catch(a){Le.warn("detail sync failed (ignored)",{method:r,agentId:e,reason:s,err:String(a)})}}async getFileTree(e){Mt(e._meta,"_agent/getFileTree");let r=e._meta,s=lr(r),a=await this.resolveWorkspace(s),c=e.filePath??"",d=this.safeJoin(a,c),l=await oc(d).catch(()=>null);if(!l)throw new R("IPC_BAD_REQUEST",`path not found: ${c}`);if(l.isSymbolicLink())throw new R("IPC_BAD_REQUEST",`symlink not allowed: ${c}`);if(!await Mr(d,a))throw new R("IPC_BAD_REQUEST",`path escapes workspace: ${c}`);let x=_w(e.depth);return l.isDirectory()?{tree:await ww(a,d,c,x)}:{tree:[{name:yw(c),path:fu(c||"."),isDir:!1,size:l.size,modifiedAt:Math.floor(l.mtimeMs)}]}}async getFileContent(e){Mt(e._meta,"_agent/getFileContent");let r=lr(e._meta),s=await this.resolveWorkspace(r);if(!e.filePath)throw new R("IPC_BAD_REQUEST","filePath required");let a=this.safeJoin(s,e.filePath),c=await oc(a).catch(()=>null);if(!c||!c.isFile())throw new R("IPC_BAD_REQUEST",`not a file: ${e.filePath}`);if(c.isSymbolicLink())throw new R("IPC_BAD_REQUEST",`symlink not allowed: ${e.filePath}`);if(!await Mr(a,s))throw new R("IPC_BAD_REQUEST",`path escapes workspace: ${e.filePath}`);if(c.size>nu)throw new R("IPC_BAD_REQUEST",`file too large: ${c.size} bytes (max ${nu})`);let d=await ru(a);return d.includes(0)?{content:d.toString("base64"),encoding:"base64",size:c.size}:{content:d.toString("utf8"),encoding:"utf-8",size:c.size}}async resolveWorkspace(e){let r=this.opts.agents.get(e);return r?r.workspace:(await qe(e).catch(()=>null))?.workspace??Rt(e).workspace}safeJoin(e,r){let s=fc(e,r||"."),a=uc(e,s);if(a.startsWith("..")||a===".."||a.startsWith(`..${iu}`))throw new R("IPC_BAD_REQUEST",`path escapes workspace: ${r}`);return s}loadAgentCfg(e){return qe(e)}async requireAgentCfg(e){let r=await this.loadAgentCfg(e);if(!r)throw new R("AGENT_NOT_FOUND",`no config for agent: ${e}`);return r}};function iw(t){let e=t.trim().replace(/[\x00-\x1f<>:"|?*/\\]+/g,"-").replace(/^[\s.-]+|[\s.-]+$/g,"").slice(0,64);if(!e||e==="."||e==="..")throw new R("IPC_BAD_REQUEST",`invalid skill name: ${t}`);if(/^(con|prn|aux|nul|com[1-9]|lpt[1-9])$/i.test(e))throw new R("IPC_BAD_REQUEST",`reserved windows filename: ${t}`);return e}function sw(t){return t==="claude-code"?vt(".claude","skills"):vt(".agents","skills")}var ow=3e4,aw=50*1024*1024,hr=3e4;async function lc(t){let{agentId:e,workspace:r,framework:s,skill:a}=t;if(!a.skillName)throw new R("IPC_BAD_REQUEST","skill missing skillName");let c=typeof a.content=="string"&&a.content.length>0,d=typeof a.downloadUrl=="string"&&a.downloadUrl.length>0;if(!c&&!d)throw new R("IPC_BAD_REQUEST",`skill ${a.skillId} missing both content and downloadUrl`);let l=iw(a.skillName),x=sw(s),p=vt(x,l),w=vt(r,p);if(await ac(w,{recursive:!0}),c){let I=Buffer.from(a.content,"utf8");li(I.length),await cc(vt(w,"SKILL.md"),I,"utf8")}else{let I=await fw(a.downloadUrl);uw(I)?await pw(I,w):lw(I)?await xw(I,w):await cc(vt(w,"SKILL.md"),I.toString("utf8"),"utf8")}let v={skillId:a.skillId,skillName:a.skillName,relPath:p,installedAt:Date.now(),...a.description?{description:a.description}:{},...a.icon?{icon:a.icon}:{},...a.version?{version:a.version}:{},...a.downloadUrl?{downloadUrl:a.downloadUrl}:{},...a.config?{config:a.config}:{},...a.builtin?{builtin:a.builtin}:{}};return Le.info("skill installed",{agentId:e,skillId:a.skillId,skillName:a.skillName,relPath:p,source:c?"content":"downloadUrl"}),v}function xc(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 cw(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 fw(t){if(!t)throw new R("IPC_BAD_REQUEST","skill missing downloadUrl");if(t.startsWith("data:")){let e=Math.floor(t.length*3/4);li(e);let r=dw(t);return li(r.length),r}if(t.startsWith("file:")){let e=new URL(t).pathname,r=await ru(e);return li(r.length),r}if(Ds(t)){let e=new AbortController,r=setTimeout(()=>e.abort(),ow);try{let s=await fetch(t,{signal:e.signal});if(!s.ok)throw new R("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 R("IPC_BAD_REQUEST",`unsupported downloadUrl scheme (\u8981 https/data/file): ${t.slice(0,80)}`)}function li(t){if(t>aw)throw new R("IPC_BAD_REQUEST",`skill too large: ${t} bytes`)}function dw(t){let e=/^data:([^,;]*)(;base64)?,(.*)$/s.exec(t);if(!e)throw new R("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 uw(t){return t.length>=2&&t[0]===31&&t[1]===139}function lw(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 dc(t){return t==="__MACOSX"||t.startsWith("__MACOSX/")}async function xw(t,e){let r,s;try{r=new au.default(t),s=r.getEntries()}catch(d){throw new R("IPC_BAD_REQUEST",`zip parse failed: ${d.message}`,{cause:d})}for(let d of s){let l=d.entryName;if(!l||dc(l))continue;if(l.startsWith("/")||/^[A-Za-z]:[\\/]/.test(l))throw new R("IPC_BAD_REQUEST",`zip entry absolute path: ${l}`);if(l.split(/[/\\]/).some(p=>p===".."))throw new R("IPC_BAD_REQUEST",`zip entry contains '..' (traversal): ${l}`);let x=d.header.attr>>>16&61440;if(x!==0&&x!==32768&&x!==16384)throw new R("IPC_BAD_REQUEST",`zip entry kind 0x${x.toString(16)} not allowed (symlink/hardlink/special): ${l}`)}let a=hw(s),c=fc(e);for(let d of s){if(dc(d.entryName))continue;let l=d.entryName;if(a&&l.startsWith(a)&&(l=l.slice(a.length)),!l)continue;let x=fc(e,l),p=uc(c,x);if(p.startsWith("..")||p==="..")throw new R("IPC_BAD_REQUEST",`zip entry escapes destDir: ${l}`);if(d.isDirectory){await ac(x,{recursive:!0});continue}await ac(Qm(x),{recursive:!0});let w;try{w=d.getData()}catch(v){throw new R("IPC_BAD_REQUEST",`zip entry getData failed (${d.entryName}): ${v.message}`,{cause:v})}await cc(x,w)}}function hw(t){let e;for(let r of t){let s=r.entryName;if(!s||dc(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 pw(t,e){await gw(t);let r=zd({cwd:e,strip:1}),s=!1,a=setTimeout(()=>{s=!0,r.destroy(new R("IPC_BAD_REQUEST",`tar extract timeout (${hr}ms)`))},hr);try{await ou(su.from(t),r)}catch(c){throw c instanceof R?c:s?new R("IPC_BAD_REQUEST",`tar extract timeout (${hr}ms)`):new R("IPC_BAD_REQUEST",`tar extract failed: ${c.message??String(c)}`,{cause:c})}finally{clearTimeout(a)}}async function gw(t){let e=[],r=ur({onReadEntry:c=>{let d=c.path,l=c.type;if(l!=="File"&&l!=="Directory"){e.push(`tar entry kind '${l}' not allowed (symlink/hardlink/special): ${d.slice(0,100)}`);return}if(d.startsWith("/")||d.startsWith("\\")||/^[a-zA-Z]:[\\/]/.test(d)){e.push(`tar entry absolute path: ${d}`);return}d.split(/[/\\]/).some(p=>p==="..")&&e.push(`tar entry contains '..': ${d}`)}}),s=!1,a=setTimeout(()=>{s=!0,r.destroy(new R("IPC_BAD_REQUEST",`tar list timeout (${hr}ms)`))},hr);try{await ou(su.from(t),r)}catch(c){throw s?new R("IPC_BAD_REQUEST",`tar list timeout (${hr}ms)`):new R("IPC_BAD_REQUEST",`tar list failed: ${c.message??String(c)}`,{cause:c})}finally{clearTimeout(a)}if(e.length>0)throw new R("IPC_BAD_REQUEST",e[0]??"tar entry validation failed")}var mw=5e3;async function ww(t,e,r,s){return cu(t,e,r,s,{count:0})}async function cu(t,e,r,s,a){if(s<=0)return[];let c;try{c=await Jm(e,{withFileTypes:!0})}catch{return[]}let d=[];for(let l of c){if(rw.has(l.name)||l.isSymbolicLink())continue;if(a.count>=mw){d.push({name:"...",path:"...",isDir:!1,size:0,modifiedAt:0,hasMore:!0});break}let x=vt(e,l.name),p=ew(vt(r,l.name)),w=null;try{w=await oc(x)}catch{continue}if(w.isSymbolicLink())continue;a.count++;let v={name:l.name,path:fu(uc(t,x)),isDir:w.isDirectory(),size:w.size,modifiedAt:Math.floor(w.mtimeMs)};w.isDirectory()&&s>1&&(v.children=await cu(t,x,p,s-1,a)),d.push(v)}return d.sort((l,x)=>l.isDir!==x.isDir?l.isDir?-1:1:l.name.localeCompare(x.name)),d}function _w(t){return!t||t<=0?tw:Math.min(t,nw)}function yw(t){if(!t||t==="."||t==="/")return".";let e=t.split(/[/\\]/);return e[e.length-1]||"."}function fu(t){return t.split(iu).join("/")}te();import{readFileSync as qS}from"node:fs";import{dirname as jS,join as WS}from"node:path";import{fileURLToPath as $S}from"node:url";var pr="0.1.75";var an=G("agent-health-reporter"),bw=1e4,xi=class{constructor(e){this.opts=e;this.intervalMs=e.intervalMs??bw}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()}),an.info("heartbeat started",{intervalMs:this.intervalMs}),this.tick())}stop(){this.timer&&(clearInterval(this.timer),this.timer=null,this.unsubscribeRegister&&(this.unsubscribeRegister(),this.unsubscribeRegister=null),an.info("heartbeat stopped"))}async tick(){if(this.inFlight){an.debug("previous tick still in-flight, skip");return}let e=this.opts.getDeviceId();if(!e){an.debug("deviceId not available, skip tick (\u5C1A\u672A pair)");return}this.inFlight=!0;try{let r=[];for(let d of this.opts.core.agents.values()){let l=Ew(d);if(!l)continue;let x={agentId:d.agentId,status:l};d.patToken&&(x.patToken=d.patToken),d.accountId&&(x.accountId=d.accountId),r.push(x)}if(r.length===0)return;let s={agents:r,bridgeVersion:pr,_meta:{cozeDeviceId:e}},a;try{a=await this.opts.core.sendRequest("_agent/health",s,5e3)}catch(d){an.warn("heartbeat batch send failed",{count:r.length,err:String(d)})}let c=a?.authFailures;if(c&&c.length>0&&(an.warn("heartbeat received authFailures from cloud",{count:c.length,agentIds:c.map(d=>d.agentId)}),this.opts.onAuthFailures))try{await this.opts.onAuthFailures(c)}catch(d){an.warn("onAuthFailures callback failed (ignored)",{err:String(d)})}}finally{this.inFlight=!1}if(this.opts.onTickEnd)try{await this.opts.onTickEnd()}catch(r){an.warn("onTickEnd hook failed",{err:String(r)})}}};function Ew(t){return t.status==="error"?"error":t.activeTriggers.size>0?"busy":t.status==="ok"?"online":null}Kt();import{mkdir as gc,rm as t_}from"node:fs/promises";wn();wn();import{spawnSync as Dw}from"node:child_process";function hi(t,e,r){return r===void 0?{jsonrpc:"2.0",id:t,method:e}:{jsonrpc:"2.0",id:t,method:e,params:r}}function pi(t,e){return e===void 0?{jsonrpc:"2.0",method:t}:{jsonrpc:"2.0",method:t,params:e}}function gr(t,e){return{jsonrpc:"2.0",id:t,result:e}}function cn(t,e){return{jsonrpc:"2.0",id:t,error:e}}var Ns=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)}},ee={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 du(t){return"method"in t&&"id"in t&&t.id!==void 0}function uu(t){return"method"in t&&!("id"in t)}function Ms(t){return!("method"in t)&&"id"in t}var vw={AGENT_NOT_FOUND:ee.AGENT_NOT_FOUND,AGENT_BUSY:ee.AGENT_BUSY,AGENT_DISCONNECTED:ee.AGENT_DISCONNECTED,AGENT_TIMEOUT:ee.AGENT_TIMEOUT,AGENT_FRAME_IDLE_TIMEOUT:ee.AGENT_FRAME_IDLE_TIMEOUT,AGENT_SPAWN_FAILED:ee.AGENT_SPAWN_FAILED,AGENT_PROTOCOL_ERROR:ee.INTERNAL_ERROR,BRIDGE_CONFIG_INVALID:ee.INTERNAL_ERROR,BRIDGE_INTERNAL:ee.INTERNAL_ERROR,IPC_AUTH_FAILED:ee.INTERNAL_ERROR,IPC_BAD_REQUEST:ee.INVALID_REQUEST,MODEL_TOKEN_GEN_FAILED:ee.MODEL_TOKEN_GEN_FAILED,MODEL_MODALITY_UNSUPPORTED:ee.MODEL_MODALITY_UNSUPPORTED,OPERATION_NOT_ALLOWED_FOR_LOCAL:ee.OPERATION_NOT_ALLOWED_FOR_LOCAL,UPSTREAM_DISCONNECTED:ee.INTERNAL_ERROR,UPSTREAM_HANDSHAKE_FAILED:ee.INTERNAL_ERROR,PATH_OUTSIDE_WORKSPACE:ee.PATH_OUTSIDE_WORKSPACE,FILE_TOO_LARGE:ee.FILE_TOO_LARGE,UNSUPPORTED_MIME:ee.UNSUPPORTED_MIME,UPLOAD_FAILED:ee.UPLOAD_FAILED,UPSTREAM_NOT_READY:ee.UPSTREAM_NOT_READY,NPX_CACHE_CORRUPT:ee.INTERNAL_ERROR};function Sw(t){if(t!=null)return t instanceof Error?{name:t.name,message:gi(t.message)}:typeof t=="string"?gi(t):typeof t=="object"?Cw(t):t}var Iw=[[/\/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 gi(t){let e=t;for(let[r,s]of Iw)e=e.replace(r,s);return e}function Cw(t){let e={};for(let[r,s]of Object.entries(t))typeof s=="string"?e[r]=gi(s):e[r]=s;return e}function mi(t){if(t instanceof R){let e=Sw(t.cause),r={bridgeCode:t.code,retriable:t.retriable};return e!==void 0&&(r.cause=e),{code:vw[t.code]??ee.INTERNAL_ERROR,message:gi(t.message),data:r}}return{code:ee.INTERNAL_ERROR,message:gi(t instanceof Error?t.message:String(t))}}function lu(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:d,...l}=e;c=l}return new R(r,a,{retriable:e?.retriable??!1,cause:c})}function hu(t){return`${JSON.stringify(t)}
120
- `}var xu=10*1024*1024,Bs=class{buffer="";onError;constructor(e={}){this.onError=e.onError}push(e){if(this.buffer+=typeof e=="string"?e:e.toString("utf8"),this.buffer.length>xu){let a=this.buffer.length;return this.buffer="",this.onError?.({line:`<buffer overflow: ${a} bytes, dropped>`,error:new Error(`LdjsonDecoder buffer exceeded ${xu} bytes`)}),[]}let r=this.buffer.split(`
121
- `);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(d){this.onError?.({line:c,error:d})}}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 gu={"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"},i1=Object.fromEntries(Object.entries(gu).map(([t,e])=>[e,t])),Tw={"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:[]},mr=class{seq=0;next(e,r){this.seq+=1;let s=gu[e]??Aw(e),a=Tw[s]??[],c=[s,String(this.seq)];if(a.length>0){let d=a.map(x=>pu(r?.[x]??"")),l=Rw(d).join(":");l&&c.push(l)}else r&&Object.values(r).some(d=>d)&&c.push(Object.values(r).filter(Boolean).map(d=>pu(String(d))).join(":"));return c.join("_")}reset(){this.seq=0}};function Aw(t){return t.replace(/[\s/]+/g,".").replace(/_+/g,"-")}function pu(t){return t.replace(/[:_\s]+/g,"-")}function Rw(t){let e=t.length;for(;e>0&&!t[e-1];)e-=1;return t.slice(0,e)}Kn();function fn(t,e){let r=process.env[t];if(!r)return e;let s=Number(r);return Number.isFinite(s)&&s>0?s:e}te();var kw=fn("COZE_BRIDGE_INITIALIZE_TIMEOUT_MS",3e4),Ow=200,Pw=/(ENOTEMPTY|EEXIST).*_npx[/\\]/;function hc(t){return t.some(e=>Pw.test(e))}var Lw=fn("COZE_BRIDGE_SESSION_PROMPT_MAX_MS",3600*1e3),Nw=fn("COZE_BRIDGE_SESSION_PROMPT_FRAME_IDLE_MS",600*1e3),mu=500;function Mw(t){try{let e=JSON.stringify(t);return e===void 0||e.length<=mu?t:`${e.slice(0,mu)}...<truncated, total ${e.length} chars>`}catch{return"<unserializable>"}}function wu(t,e){if(!(typeof t!="number"||t<=0))try{if(process.platform==="win32"){let r=["/PID",String(t),"/T"];e==="SIGKILL"&&r.push("/F"),Dw("taskkill",r,{stdio:"ignore",windowsHide:!0})}else process.kill(-t,e)}catch{}}var St=class{constructor(e){this.opts=e;this.log=G(`downstream.${this.constructor.name}`),this.decoder=new Bs({onError:r=>this.log.warn("decode line failed",{line:r.line})})}opts;child;decoder;pending=new Map;inflightAgentRequests=new Map;idAllocator=new mr;updateHandlers=[];agentRequestHandlers=[];exitHandlers=[];log;stopped=!1;stderrRing=[];sanitizeEnv(e){return e}async start(){if(this.child)throw new R("BRIDGE_INTERNAL","Downstream already started");let e=process.platform!=="win32",r=jn(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>Ow&&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")&&hc(this.stderrRing)&&(this.log.warn("npx cache corruption detected, triggering global install fallback (D93)",{framework:this.framework}),gn(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 d of this.decoder.flush())this.dispatch(d)}catch(d){this.log.debug("decoder.flush on exit threw (ignored)",{err:String(d)})}this.failAllPending(new R("AGENT_PROTOCOL_ERROR",`agent exited (${s}/${a})`));for(let d of this.exitHandlers)d(s,a)}),r.on("error",s=>{this.log.error("child error",{err:String(s)}),this.failAllPending(new R("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()));wu(r.pid,"SIGTERM");let a=setTimeout(()=>{r.killed||wu(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=Lw,s=Nw){return this.call("session/prompt",e,r,s)}async sessionCancel(e){!this.child||this.stopped||this.writeFrame(pi("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(gr(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(cn(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=kw,a=0){if(!this.child||this.stopped)return Promise.reject(new R("AGENT_PROTOCOL_ERROR","downstream not started"));let c=this.idAllocator.next(e),d=hi(c,e,r),l=(()=>{if(typeof r!="object"||r===null)return;let w=r.sessionId;return typeof w=="string"?w:void 0})(),x=s>0&&Number.isFinite(s),p=a>0&&Number.isFinite(a);return new Promise((w,v)=>{let I={resolve:w,reject:v,timer:null,frameIdleTimer:null,armFrameIdle:null,method:e};x&&(I.timer=setTimeout(()=>{this.pending.delete(c),I.frameIdleTimer&&clearTimeout(I.frameIdleTimer),this.log.warn("downstream call timeout",{id:c,method:e,timeoutMs:s,...l?{sessionId:l}:{}}),v(new R("AGENT_TIMEOUT",`${e} timed out after ${s}ms`))},s));let b=p?()=>{I.frameIdleTimer&&clearTimeout(I.frameIdleTimer),I.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}:{}}),b?.();return}I.timer&&clearTimeout(I.timer),this.pending.delete(c),this.log.warn("frame-idle timeout, rejecting pending call",{id:c,method:e,frameIdleMs:a,...l?{sessionId:l}:{}}),v(new R("AGENT_FRAME_IDLE_TIMEOUT",`${e} no session/update for ${a}ms (no inflight agent request)`))},a)}:null;I.armFrameIdle=b,this.pending.set(c,I),b?.();try{this.writeFrame(d)}catch(E){I.timer&&clearTimeout(I.timer),I.frameIdleTimer&&clearTimeout(I.frameIdleTimer),this.pending.delete(c),v(E)}})}writeFrame(e){if(!this.child?.stdin||this.child.stdin.destroyed)throw new R("AGENT_PROTOCOL_ERROR","downstream stdin not writable");this.child.stdin.write(hu(e),r=>{r&&this.log.warn("stdin write callback err",{err:String(r)})})}dispatch(e){if(Ms(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(lu(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 R("AGENT_PROTOCOL_ERROR",`${r.method} response missing both result and error`))):(this.log.info("downstream returned result",{id:e.id,method:r.method,result:Mw(e.result)}),r.resolve(e.result));return}if(uu(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(du(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(cn(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(cn(e.id,mi(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 Bw=Nr("claude-code")??"@agentclientprotocol/claude-agent-acp@^0.37";function zw(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 zs=class extends St{framework="claude-code";constructor(e){let r=mn("claude-code"),[s,a]=r?[r,[]]:["npx",["-y",Bw]],c=e.command??s,d=e.args??a,l={command:c,args:d,cwd:e.cwd,...e.env?{env:e.env}:{}};super(l)}sanitizeEnv(e){return zw(e)}};wn();import{mkdtempSync as Fw,rmSync as Uw}from"node:fs";import{tmpdir as Hw}from"node:os";import{join as qw}from"node:path";var Gw=Nr("codex")??"@zed-industries/codex-acp@^0.15",Fs=class extends St{framework="codex";authMethodId;codexHomeDir;constructor(e){let r=mn("codex"),[s,a]=r?[r,[]]:["npx",["-y",Gw]],c=e.command??s,d=e.args??a,l=e.extraArgs?[...d,...e.extraArgs]:d,x=e.isolateCodexHome?Fw(qw(Hw(),"coze-bridge-codex-home-")):void 0,p=x?{...e.env??{},CODEX_HOME:x}:e.env,w={command:c,args:l,cwd:e.cwd,...p?{env:p}:{}};super(w),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{Uw(this.codexHomeDir,{recursive:!0,force:!0})}catch{}}};var jw=3e4,wr=class extends St{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}`}]},jw))}get acpSessionName(){return this.sessionName}};te();Fe();function pc(t){return t.replace(/[^A-Za-z0-9._-]+/g,"-")}wn();var _r=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 Us=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 _r,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)wi(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 wi(t){t.idleTimer&&(clearTimeout(t.idleTimer),t.idleTimer=void 0)}Kn();te();import{constants as _u,access as Ww}from"node:fs/promises";import{delimiter as Kw,join as $w}from"node:path";var dn=G("framework-detector"),yu={"claude-code":"claude",codex:"codex",openclaw:"openclaw"},Vw=[".exe",".cmd",".bat",".ps1"],un=class{env;constructor(e={}){this.env={pathEnv:e.pathEnv??process.env.PATH??"",platform:e.platform??process.platform,spawn:e.spawn??jn,access:e.access??Ww}}async detect(e){let r=yu[e],s=await this.which(r);if(!s)return dn.debug("framework binary not found",{framework:e,bin:r}),null;let a=e==="openclaw"?["--log-level","silent"]:[],[c,d]=await Promise.all([this.probeVersion(s,a),e==="openclaw"?this.probeOpenclawDefaultAgent(s):Promise.resolve(null)]),l={path:s,version:c};return d&&(l.defaultAgent=d),l}async detectAll(){let e=await Promise.all(Object.keys(yu).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(Kw).filter(Boolean),s=this.env.platform==="win32"?["",...Vw]:[""];for(let a of r)for(let c of s){let d=$w(a,e+c);if(await this.isExecutable(d))return d}return null}async isExecutable(e){try{let r=this.env.platform==="win32"?_u.F_OK:_u.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 dn.warn("openclaw default agent probe: runProbe returned null (spawn err / timeout)",{path:e}),null;if(r.code!==0)return dn.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 dn.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 dn.warn("openclaw default agent probe: JSON parsed but not an array",{path:e}),null;let c=a.find(d=>d?.isDefault===!0);return c?!c.id||!c.workspace?(dn.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}:(dn.info("openclaw default agent probe: no agent has isDefault=true",{path:e,agentCount:a.length}),null)}catch(a){return dn.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&&(Jw(s.stdout).split(/\r?\n/)[0]??"").trim()||"unknown"}runProbe(e,r){return new Promise(s=>{let a="",c=!1,d,l=x=>{c||(c=!0,d&&clearTimeout(d),s(x))};try{let x=this.env.spawn(e,r,{stdio:["ignore","pipe","pipe"]});d=setTimeout(()=>{x.kill("SIGKILL"),l(null)},15e3),x.stdout?.on("data",p=>{a+=p.toString("utf8")}),x.on("error",()=>l(null)),x.on("close",p=>l({code:p,stdout:a}))}catch{l(null)}})}},Zw=new RegExp("\x1B\\[[0-9;]*[A-Za-z]","g");function Jw(t){return t.replace(Zw,"")}import{spawn as Yw}from"node:child_process";import{homedir as Xw}from"node:os";import{join as Qw}from"node:path";Bi();te();async function vu(){let t=Qw(Xw(),".openclaw/openclaw.json");return(await Vn(t))?.gateway?.auth?.token??""}var bu=G("openclaw.config"),e_=[0,5e3,5e3],Eu="models.providers.",Hs="agents.defaults.models",qs=class{command;env;retryDelaysMs;queue=new _r;constructor(e){this.command=e.command,this.env=e.env??process.env,this.retryDelaysMs=e.retryDelaysMs??e_}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(d=>setTimeout(d,c));try{return await r()}catch(d){s=d,bu.warn("openclaw cli failed, will retry",{label:e,attempt:a+1,err:String(d)})}}throw new R("AGENT_SPAWN_FAILED",`openclaw cli ${e} failed after ${this.retryDelaysMs.length} attempts: ${s?.message??"unknown"}`)}runCli(e){return new Promise((r,s)=>{let a=Yw(this.command,e,{stdio:["ignore","pipe","pipe"],env:this.env}),c="";a.stderr?.on("data",d=>{c+=d.toString("utf8")}),a.on("error",s),a.on("close",d=>{d===0?r():s(new Error(`exit ${d}: ${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){bu.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",`${Eu}${e}`,JSON.stringify(r),"--strict-json","--merge"])))}removeProvider(e){return this.bestEffortUnset(`config unset models.providers.${e}`,`${Eu}${e}`)}addModelToAllowlist(e,r){let s={[e]:r?{alias:r}:{}};return this.queue.enqueue(()=>this.withRetry(`config set ${Hs}[${e}]`,()=>this.runCli(["config","set",Hs,JSON.stringify(s),"--strict-json","--merge"])))}removeModelFromAllowlist(e){return this.bestEffortUnset(`config unset ${Hs}[${e}]`,`${Hs}.${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 Ne=G("agent-manager"),n_=(t,e,r,s,a,c,d,l,x)=>{switch(t){case"claude-code":{let p={...a?{...Jd(a),...Qd(a,d,l)}:{},...x??{},IS_SANDBOX:"1"};return new zs({cwd:r,env:p})}case"codex":{let w=[...a?[...Yd(a),...tu(a,d,l)]:[],"-c",'sandbox_mode="danger-full-access"',"-c",'approval_policy="never"'],v={...a?Xd(a):{},...x??{}},I=!!a;return new Fs({cwd:r,...w.length>0?{extraArgs:w}:{},...Object.keys(v).length>0?{env:v}:{},...I?{authMethodId:"openai-api-key",isolateCodexHome:!0}:{}})}case"openclaw":return new wr({command:e,cwd:r,agentId:s,...c?{sessionName:pc(c)}:{}})}};function mc(t){return t==="claude-code"||t==="codex"}var r_={path:"",version:"cloud-deployed"},i_={protocolVersion:1,clientCapabilities:{fs:{readTextFile:!0,writeTextFile:!0}}},s_=6e4,o_=fn("COZE_BRIDGE_SPAWN_AWAIT_INSTALL_MS",25e3),Gs=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??n_,this.createTimeoutMs=e.createTimeoutMs??s_,this.spawnAwaitInstallMs=e.spawnAwaitInstallMs??o_,this.detectorFactory=e.detectorFactory??(()=>new un)}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 R("AGENT_SPAWN_FAILED","openclaw binary not detected on this machine");this.openclawConfigCache=new qs({command:e.path})}return this.openclawConfigCache}async createAgent(e){if(!e.agentId)throw new R("IPC_BAD_REQUEST","agentId required");if(!e.framework)throw new R("IPC_BAD_REQUEST","framework required");let r=fi(e._meta)==="cloud";this.registry.reviveIfDisconnected?.(e.agentId);let s=this.registry.get(e.agentId);if(s){if(s.framework!==e.framework)throw new R("AGENT_BUSY",`agent ${e.agentId} exists with different framework (${s.framework})`);if(s.status==="error")Ne.warn("existing agent in error state, rebuilding",{agentId:e.agentId}),await s.dispose("rebuild after error").catch(E=>Ne.warn("dispose stale agent failed (ignored)",{err:String(E)})),this.registry.unregister(e.agentId);else{if(e.patToken&&e.patToken!==s.patToken){Ne.info("updating agent patToken on re-create (reconnect with new PAT)",{agentId:e.agentId}),s.setPatToken(e.patToken);let E=await qe(e.agentId,this.paths).catch(()=>null);E&&(E.patToken=e.patToken,await $e(E,this.paths))}if(s.deployType==="cloud"&&e.modelInfo){Ne.info("updating agent modelInfo on re-create",{agentId:e.agentId}),s.setModelInfo(e.modelInfo);let E=await qe(e.agentId,this.paths).catch(()=>null);E&&(E.modelInfo=e.modelInfo,await $e(E,this.paths))}return Ne.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 R("AGENT_SPAWN_FAILED",`framework ${e.framework} not detected on this machine; rerun daemon to refresh frameworks_cache`);let c=Rt(e.agentId,this.paths),d=fi(e._meta),l=e.framework==="openclaw"&&d==="local",x=l?this.config.frameworksCache?.openclaw?.defaultAgent?.workspace:void 0,p=e.workspace??x??c.workspace,w=new AbortController,v=setTimeout(()=>w.abort(new R("AGENT_TIMEOUT",`_agent/create timed out after ${this.createTimeoutMs}ms`)),this.createTimeoutMs),I,b=!1;try{r&&mc(e.framework)&&await gn(e.framework,w.signal);let E=()=>{if(w.signal.aborted)throw w.signal.reason instanceof Error?w.signal.reason:new R("AGENT_TIMEOUT","_agent/create aborted")};await gc(c.root,{recursive:!0}),await gc(p,{recursive:!0}),await gc(c.logs,{recursive:!0}),E(),l||await Zn(p,e.framework,e.agentId,e.cozeIdentity),e.framework==="claude-code"&&await j0(p),E();let S=await qe(e.agentId,this.paths).catch(()=>null),C=Vd({model:e.model??S?.model}),D=Ud(e._meta)??S?.accountId,P=e.patToken??S?.patToken,y=d==="cloud"?e.modelInfo??S?.modelInfo:void 0;if(I=new Us({agentId:e.agentId,framework:e.framework,workspace:p,model:C.model??Et,deployType:d,...D?{accountId:D}:{},...P?{patToken:P}:{},...y?{modelInfo:y}:{}}),I.status="ok",S?.sessions){for(let[z,k]of Object.entries(S.sessions))I.sessions.set(z,{acpSessionId:k.acpSessionId,modelToken:k.modelToken,tokenGeneratedAt:k.tokenGeneratedAt,lastActiveAt:Date.now(),loadingSession:!1,replySeq:0});let U=Object.keys(S.sessions).length;U>0&&Ne.info("restored persisted session records (no spawn)",{agentId:e.agentId,count:U})}this.registry.register(I),b=!0;let A={agentId:e.agentId,framework:e.framework,workspace:p,cozeIdentity:e.cozeIdentity,createdAt:S?.createdAt??Date.now(),sessions:S?.sessions??{},model:C.model};d==="cloud"&&(A.deployType="cloud"),D&&(A.accountId=D),P&&(A.patToken=P),y&&(A.modelInfo=y),S?.skills&&(A.skills=S.skills),S?.agentName&&(A.agentName=S.agentName),S?.description&&(A.description=S.description),e.framework==="openclaw"&&d==="cloud"&&(this.config.frameworksCache?.openclaw?.path?await this.getOpenclawConfig().ensureAgent(e.agentId,p):Ne.warn("openclaw binary not on this machine, skip agents add (will fail at session/prompt)",{agentId:e.agentId}));let O=e.initialSkills??[];if(O.length>0){let U=[...A.skills??[]],z=new Map(U.map((H,V)=>[H.skillId,V])),k=await Promise.allSettled(O.map(H=>lc({agentId:e.agentId,workspace:p,framework:e.framework,skill:H}))),L=0;for(let[H,V]of k.entries()){let oe=O[H];oe&&(V.status==="fulfilled"?(xc(U,z,V.value),L++):Ne.warn("initialSkill install failed (skipping)",{agentId:e.agentId,skillId:oe.skillId,skillName:oe.skillName,err:String(V.reason)}))}L>0&&(A.skills=U,Ne.info("initialSkills installed",{agentId:e.agentId,installed:L,requested:O.length}))}return await $e(A,this.paths),Ne.info("agent created (no spawn, lazy on first prompt)",{agentId:e.agentId,framework:e.framework,deployType:d}),{ok:!0,agentId:e.agentId,workspace:p,framework:e.framework}}catch(E){throw Ne.error("agent create failed, rolling back",{agentId:e.agentId,err:String(E)}),b&&I&&(await I.dispose("rollback").catch(()=>{}),this.registry.unregister(e.agentId)),await t_(c.root,{recursive:!0,force:!0}).catch(S=>Ne.warn("rm agent dir failed (ignored)",{err:String(S)})),E instanceof R?E:new R("AGENT_SPAWN_FAILED",String(E),{cause:E})}finally{clearTimeout(v)}}async spawnSessionDownstream(e,r,s,a,c){let l=this.config.frameworksCache?.[e.framework];if(!l)if(e.deployType==="cloud"&&mc(e.framework))l=r_;else throw new R("AGENT_SPAWN_FAILED",`framework ${e.framework} not detected on this machine`);if(mc(e.framework)&&!mn(e.framework)){let w=Wo(e.framework);w&&(Ne.info("spawn: awaiting in-flight acp install (D92)",{agentId:e.agentId,framework:e.framework}),await Promise.race([w.catch(()=>{}),new Promise(v=>setTimeout(v,this.spawnAwaitInstallMs))]))}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:s,cozeEnv:a,mockScenario:c,command:l.path}):p=this.factory(e.framework,l.path,e.workspace,e.agentId,x,s,a,c,this.buildBinShimPathEnv());try{return await p.start(),await p.initialize(i_),p}catch(w){let v=p instanceof St?p.getStderrTail():[];v.length>0&&Ne.warn("spawnSessionDownstream failed, recent stderr (D94)",{agentId:e.agentId,framework:e.framework,method:w instanceof R?w.code:"unknown",recentStderr:v});let I=hc(v);await p.stop("spawnSessionDownstream failed").catch(()=>{});let b=I?new R("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:w}):w;throw w instanceof R?new R(w.code,w.message,{retriable:w.retriable,cause:b}):new R("AGENT_SPAWN_FAILED",w instanceof Error?w.message:String(w),{cause:b})}}async buildOpenclawDownstream(e){let{session:r,modelConfig:s,cloudSessionId:a,cozeEnv:c,mockScenario:d,command:l}=e,x=pc(a);if(r.deployType==="local"){let I=this.config.frameworksCache?.openclaw?.defaultAgent;if(!I?.id||!I.workspace){Ne.warn("openclaw default agent stale or missing, attempting lazy re-detect");let E=await this.detectorFactory().detect("openclaw");if(E?.defaultAgent?.id&&E?.defaultAgent?.workspace)Ne.info("openclaw lazy re-detect success",{agentId:E.defaultAgent.id,workspace:E.defaultAgent.workspace}),this.config.frameworksCache||(this.config.frameworksCache={}),this.config.frameworksCache.openclaw=E,I=E.defaultAgent;else throw new R("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 wr({command:l,cwd:I.workspace,agentId:I.id,sessionName:x})}let p=await vu(),w=s?eu(s,c,d):null,v;if(w){let I=sc(a),E=w.models[0]?.id??Et,S=`${I}/${E}`;if(!this.ensuredProviders.has(S)){let C=this.getOpenclawConfig();await C.ensureProvider(I,w),await C.addModelToAllowlist(S),this.ensuredProviders.add(S)}v=S}return new wr({command:l,cwd:r.workspace,agentId:r.agentId,sessionName:x,...p?{gatewayToken:p}:{},...v?{slashModelOnStart:v}:{}})}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=sc(s),c=`${a}/${e.model}`,d=!0;try{await r.removeProvider(a)}catch(l){d=!1,Ne.warn("removeProvider failed, keeping ensuredProviders entry",{providerId:a,err:String(l)})}try{await r.removeModelFromAllowlist(c)}catch(l){d=!1,Ne.warn("removeModelFromAllowlist failed, keeping ensuredProviders entry",{fullModelId:c,err:String(l)})}d&&this.ensuredProviders.delete(c)}}};import{randomUUID as Au}from"node:crypto";import{promises as m_}from"node:fs";import{basename as Ru}from"node:path";import{promises as c_}from"node:fs";import{basename as f_}from"node:path";te();var Su=G("file-upload"),d_="/api/coze_claw/file/agent_upload",u_=6e4;async function Iu(t,e={}){let s=`${ks(Ps(e.handshakeBase))}${d_}`,a=e.timeoutMs??u_,c=await c_.readFile(t.path),d=new FormData;d.append("agent_id",t.agentId),d.append("session_id",t.sessionId),d.append("file_name",t.name),d.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",...xr(e.ppeOverride),...t.accountId?{"x-coze-account":t.accountId}:{}},x=new AbortController,p=setTimeout(()=>x.abort(),a);Su.info("file upload start",{url:s,agentId:t.agentId,sessionId:t.sessionId,name:t.name,bytes:t.sizeBytes,mime:t.mimeType});try{let w=await fetch(s,{method:"POST",headers:l,body:d,signal:x.signal}),v=w.headers.get("x-tt-logid")??"";if(!w.ok){let E=await w.text().catch(()=>"");throw new R("UPLOAD_FAILED",`upload HTTP ${w.status} logid=${v}: ${E.slice(0,200)}`)}let I=await w.json();if(I.code!==void 0&&I.code!==0)throw new R("UPLOAD_FAILED",`upload code=${I.code} msg=${I.msg??"-"} logid=${v}`);let b=I.data?.file?.file_url;if(!b)throw new R("UPLOAD_FAILED",`upload response missing data.file.file_url logid=${v}: ${JSON.stringify(I).slice(0,200)}`);return Su.info("file upload ok",{uri:b,logid:v}),{uri:b}}catch(w){throw w instanceof R?w:w.name==="AbortError"?new R("UPLOAD_FAILED",`upload timeout (${a}ms) for ${f_(t.path)}`):new R("UPLOAD_FAILED",String(w),{cause:w})}finally{clearTimeout(p)}}te();import{promises as l_}from"node:fs";import{extname as x_}from"node:path";var h_=[{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 p_(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 g_={".txt":"text/plain",".md":"text/markdown",".svg":"image/svg+xml",".json":"application/json"};async function Cu(t){let e=await l_.open(t,"r");try{let r=Buffer.alloc(16);if(await e.read(r,0,16,0),p_(r))return"image/webp";for(let s of h_)if(s.prefix.every((a,c)=>r[c]===a))return s.mime}finally{await e.close()}return g_[x_(t).toLowerCase()]??"application/octet-stream"}Fe();var js=G("agent-send"),Tu=50*1024*1024,w_=new Set(["image/png","image/jpeg","image/webp","image/gif","image/svg+xml","application/pdf","application/json","text/plain","text/markdown"]);function Du(t,e,r){let s=t.get(e);if(!s)throw new R("AGENT_NOT_FOUND",`agent=${e}`);if(t.disconnectedAgents.has(e))throw new R("AGENT_DISCONNECTED",`agent=${e} was disconnected by cloud`);let a=s.sessions.get(r);if(!a)throw new R("AGENT_NOT_FOUND",`session=${r} not active in agent=${e}`);return{session:s,runtime:a}}async function ku(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(p){l=p,x<2&&(js.warn("sendAgentFileUpdate failed, retrying",{attempt:x+1,err:String(p)}),await new Promise(w=>setTimeout(w,5e3)))}throw new R("UPSTREAM_NOT_READY",`${c} after 3 attempts: ${String(l)}`,{cause:l})}async function Ou(t,e){let{session:r,runtime:s}=Du(e.core,t.agentId,t.sessionId);if(!await Mr(t.path,r.workspace))throw new R("PATH_OUTSIDE_WORKSPACE",`path=${t.path} not under workspace=${r.workspace}`);let a=await m_.stat(t.path).catch(()=>null);if(!a||!a.isFile())throw new R("IPC_BAD_REQUEST",`path is not a regular file: ${t.path}`);if(a.size>Tu)throw new R("FILE_TOO_LARGE",`${a.size} bytes > limit ${Tu}`);let c=await Cu(t.path);if(!w_.has(c))throw new R("UNSUPPORTED_MIME",`mime=${c} not in whitelist`);if(t.kind==="image"&&!c.startsWith("image/"))throw new R("UNSUPPORTED_MIME",`kind=image but mime=${c}`);if(!e.core.upstream.isConnected())throw new R("UPSTREAM_NOT_READY","cloud WS not connected");let d=t.name??Ru(t.path),l;try{l=await Iu({patToken:r.patToken??e.patToken,agentId:t.agentId,sessionId:t.sessionId,path:t.path,mimeType:c,name:d,sizeBytes:a.size,...r.accountId?{accountId:r.accountId}:{}},{handshakeBase:e.handshakeBase,ppeOverride:e.ppeOverride})}catch(p){throw js.warn("agent file upload failed",{agentId:t.agentId,sessionId:t.sessionId,path:t.path,sizeBytes:a.size,mime:c,code:p instanceof R?p.code:"UNKNOWN",message:p instanceof Error?p.message:String(p)}),p}let x={sessionUpdate:"agent_file",messageId:Au(),content:{type:t.kind==="image"?"image":"resource",uri:l.uri,mimeType:c,name:d,sizeBytes:a.size,...l.fileId!==void 0?{fileId:l.fileId}:{},...t.caption!==void 0?{caption:t.caption}:{}}};return await ku(e,r,s,t.sessionId,x,"agent file uploaded to cloud but sendAgentFileUpdate failed"),js.info("agent file sent",{agentId:t.agentId,sessionId:t.sessionId,kind:t.kind,name:d,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 Pu(t,e){let{session:r,runtime:s}=Du(e.core,t.agentId,t.sessionId);if(!t.mimeType)throw new R("IPC_BAD_REQUEST","group-file requires mimeType");if(!e.core.upstream.isConnected())throw new R("UPSTREAM_NOT_READY","cloud WS not connected");let a=t.name??Ru(t.path),c={sessionUpdate:"group_file",messageId:Au(),content:{uri:t.path,name:a,mimeType:t.mimeType,...t.caption!==void 0?{caption:t.caption}:{}}};return await ku(e,r,s,t.sessionId,c,"agent group file sendAgentFileUpdate failed"),js.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 Lu(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 d=r[c]??0,l=s[c]??0;if(d<l)return!0;if(d>l)return!1}return!1}Kn();te();var It=G("coze-cli-installer"),Nu="@coze/cli@latest",__="coze",Mu="0.1.7",y_=5e3,b_=5e3,E_=9e4,Bu=1e4,_i=null,Ws=!1;async function wc(t,e={}){if(Ws)return;if(_i)return _i;let r=e.exec??Wn;return _i=(async()=>{try{let s=await v_(__,r),a=!1;if(s){let d=await S_(r);if(d===void 0)It.warn("coze-cli found but version unparseable, fall through to full install",{path:s});else if(Lu(d,Mu))It.info("coze-cli version too old, upgrade-only (preserve user config + auth)",{path:s,version:d,min:Mu}),a=!0;else{It.info("coze-cli already on PATH with sufficient version, skip",{path:s,version:d}),Ws=!0;return}}let c=a?"upgrade-only":"full";It.info("coze-cli install start",{package:Nu,mode:c});try{await r("npm",["i","-g","--prefer-online",Nu],{timeout:E_,maxBuffer:10*1024*1024}),It.info("coze-cli install ok")}catch(d){It.warn("coze-cli install failed (skip subsequent steps)",{err:String(d)});return}if(a){Ws=!0;return}if(t.env)try{await r("coze",["config","set","xTTEnv",t.env],{timeout:Bu}),It.info("coze config set xTTEnv ok",{env:t.env})}catch(d){It.warn("coze config set failed (continue to auth login)",{err:String(d)})}try{await r("coze",["auth","login","--token",t.patToken],{timeout:Bu}),It.info("coze auth login ok")}catch(d){It.warn("coze auth login failed",{err:String(d)});return}Ws=!0}finally{_i=null}})(),_i}async function v_(t,e){let r=process.platform==="win32"?"where":"which";try{let{stdout:s}=await e(r,[t],{timeout:y_});return s.split(`
122
- `)[0]?.trim()||void 0}catch{return}}async function S_(t){try{let{stdout:e,stderr:r}=await t("coze",["--version"],{timeout:b_});return(e||r).match(/(\d+\.\d+\.\d+)/)?.[1]}catch{return}}Bi();Fe();var I_=10*6e4;function zu(t){let e=t?.sessionIdleTimeoutMs;return typeof e!="number"||!Number.isFinite(e)||e<=0?I_:e}function Ks(t){return Vn(t??ne().configFile)}function yr(t,e){return Mi(e??ne().configFile,t)}import{randomBytes as G_}from"node:crypto";import{createReadStream as C_}from"node:fs";import{mkdir as T_,readFile as A_,realpath as R_,stat as D_,writeFile as k_}from"node:fs/promises";import{basename as O_,dirname as _c,join as P_,relative as L_,resolve as Fu,sep as N_}from"node:path";import{createInterface as M_}from"node:readline";te();var Hu=G("fs-rpc"),yi=fn("COZE_BRIDGE_FS_RPC_MAX_BYTES",20*1024*1024);async function qu(t,e){let r=Buffer.byteLength(t.content,"utf8");if(r>yi)throw new R("IPC_BAD_REQUEST",`fs/write_text_file content too large: ${r} bytes > limit ${yi} bytes`);let s=await ju(t.path,e);return await T_(_c(s),{recursive:!0}),await k_(s,t.content,"utf8"),Hu.info("fs/write_text_file ok",{path:s,size:t.content.length}),null}async function Gu(t,e){let r=await ju(t.path,e),s=await D_(r),a=typeof t.line=="number"||typeof t.limit=="number";if(s.size>yi&&!a)throw new R("IPC_BAD_REQUEST",`fs/read_text_file too large without line/limit slicing: ${s.size} bytes > ${yi} bytes`);let c;if(a&&s.size>yi)c=await B_(r,t.line??1,t.limit);else{let d=await A_(r,"utf8");if(a){let l=d.split(`
123
- `),x=Math.max(0,(t.line??1)-1),p=typeof t.limit=="number"?x+t.limit:void 0;c=l.slice(x,p).join(`
124
- `)}else c=d}return Hu.info("fs/read_text_file ok",{path:r,size:c.length}),{content:c}}async function B_(t,e,r){let s=M_({input:C_(t,{encoding:"utf8"}),crlfDelay:Number.POSITIVE_INFINITY}),a=Math.max(0,e-1),c=typeof r=="number"?a+r:Number.POSITIVE_INFINITY,d=[],l=0;try{for await(let x of s)if(l>=a&&l<c&&d.push(x),l++,l>=c)break}finally{s.close()}return d.join(`
125
- `)}async function ju(t,e){if(typeof t!="string"||t.length===0)throw new R("IPC_BAD_REQUEST","path must be a non-empty string");let[r,s]=await Promise.all([Uu(Fu(e)),Uu(Fu(t))]),a=L_(r,s);if(a.startsWith("..")||a===".."||a.startsWith(`..${N_}`))throw new R("IPC_BAD_REQUEST",`path escapes workspace: ${t}`);return s}async function Uu(t){let e=[],r=t;for(;r!==_c(r);)try{let s=await R_(r);return e.length?P_(s,...e.reverse()):s}catch{e.push(O_(r)),r=_c(r)}return t}te();var Wu=G("prompt-multimodal"),Ku=10*1024*1024,z_=15e3,F_=6;async function $u(t){let e=new Array(t.length),r=0;async function s(){for(;r<t.length;){let c=r++,d=t[c];d!==void 0&&(e[c]=await U_(d))}}let a=Array.from({length:Math.min(F_,t.length)},()=>s());return await Promise.all(a),e}function Vu(t){return t.some(e=>e.type==="image")}async function U_(t){if(t.type!=="image")return t;let e=t;if(e.data||!e.uri||!Ds(e.uri))return t;try{let{buf:r,contentType:s}=await q_(e.uri),a=e.mimeType||H_(s)||"application/octet-stream";return Wu.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 Wu.warn("image fetch failed, degrading to text block",{uri:e.uri,err:String(r)}),{type:"text",text:`[image load failed: ${e.uri}]`}}}function H_(t){if(!t)return;let e=t.indexOf(";");return(e===-1?t:t.slice(0,e)).trim()||void 0}async function q_(t){let e=new AbortController,r=setTimeout(()=>e.abort(),z_);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>Ku)throw new Error(`image too large: ${a.byteLength} bytes (max ${Ku})`);return{buf:Buffer.from(a),contentType:s.headers.get("content-type")??void 0}}finally{clearTimeout(r)}}Kt();te();var Z=G("core"),j_=3e4,W_=/^(boe|ppe)_[A-Za-z0-9_-]+$/,K_=3e4,$s=class{upstream;agents=new Map;disconnectedAgents=new Set;extensions;paths;sessionSpawner;sessionIdleTimeoutMs;upstreamIds=new mr;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=zu(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(),Z.info("Core started",{extensions:Object.keys(this.extensions)})}async stop(e){Z.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),Z.info("agent registered",{agentId:e.agentId,framework:e.framework});for(let r of this.registerHandlers)try{r(e.agentId)}catch(s){Z.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)&&Z.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,d)=>{Z.info("session runtime exited",{agentId:e.agentId,cloudId:r,code:c,signal:d}),wi(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){Z.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(cn(a,{code:ee.INTERNAL_ERROR,message:`bridge downstream gone: ${r}`})).catch(d=>Z.debug("send error response to upstream failed (ignored)",{err:String(d)}));try{c.downstream.respondAgentRequestError(c.agentRequestId,{code:ee.INTERNAL_ERROR,message:`bridge: ${r}`})}catch{}}}}}rejectAllPendingOnReconnect(){let e=this.pendingUpstream.size,r=this.pendingBridge.size;if(!(e===0&&r===0)){Z.warn("upstream reconnected, rejecting stale pending requests",{pendingUpstream:e,pendingBridge:r});for(let[,s]of this.pendingUpstream)try{s.downstream.respondAgentRequestError(s.agentRequestId,{code:ee.INTERNAL_ERROR,message:"upstream reconnected; please retry"})}catch{}this.pendingUpstream.clear();for(let[,s]of this.pendingBridge)clearTimeout(s.timer),s.reject(new R("UPSTREAM_DISCONNECTED",`${s.method} aborted: upstream reconnected`));this.pendingBridge.clear()}}async handleFrame(e){if(Ms(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&&W_.test(s)?this.currentCozeEnv=s:s&&Z.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,ee.METHOD_NOT_FOUND,`extension not registered: ${e.method}`):Z.warn("drop notification: extension not registered",{method:e.method});return}let c=await a(e,this);r!==null&&await this.upstream.send(gr(r,c));return}if(e.method.startsWith("session/")){let a=await this.routeSessionMethod(e);r!==null&&await this.upstream.send(gr(r,a));return}if(e.method==="initialize"){r!==null&&await this.upstream.send(gr(r,{protocolVersion:1,agentCapabilities:{loadSession:!0}}));return}r!==null?await this.sendError(r,ee.METHOD_NOT_FOUND,`method not implemented: ${e.method}`):Z.warn("drop unknown notification",{method:e.method})}catch(a){Z.error("handleFrame failed",{method:e.method,err:String(a)}),r!==null&&await this.upstream.send(cn(r,mi(a)))}}async routeSessionMethod(e){if(!e.params||typeof e.params!="object")throw new R("IPC_BAD_REQUEST",`${e.method} requires params`);let r=e.params,s=r._meta?.cozeAgentId;if(!s)throw new R("IPC_BAD_REQUEST",`${e.method}: missing _meta.cozeAgentId`);let a=this.agents.get(s);if(!a)throw this.disconnectedAgents.has(s)?new R("AGENT_DISCONNECTED",`agent ${s} has been disconnected; cloud must _agent/create to revive`):new R("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 d=Date.now(),l=!1;try{let x=await a.getSessionQueue(c).enqueue(()=>this.dispatchSessionCall(a,e.method,r));return l=!0,x}finally{Z.info("session call done",{agentId:a.agentId,method:e.method,durationMs:Date.now()-d,ok:l})}}async dispatchSessionCall(e,r,s){e.lastActiveAt=Date.now();let{stripped:a}=qd(s);switch(r){case"session/new":{let c=$_();return Z.info("session/new ack (lazy spawn)",{agentId:e.agentId,cloudId:c}),{sessionId:c}}case"session/load":{let c=a;return Z.info("session/load ack (lazy spawn)",{agentId:e.agentId,cloudId:c.sessionId}),{}}case"session/prompt":{let c=a,d=c.sessionId;if(!d)throw new R("IPC_BAD_REQUEST","session/prompt: missing sessionId");let l=await this.ensureRuntime(e,d);if(l.replySeq=0,await this.ensureDownstream(e,d,l),!l.downstream||!l.acpSessionId)throw new R("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 p=Hd(s._meta);if(p?e.activeGroupIds.set(l.acpSessionId,p):e.activeGroupIds.delete(l.acpSessionId),e.deployType==="cloud"&&e.modelInfo?.capabilities?.image===!1&&Vu(c.prompt))throw new R("MODEL_MODALITY_UNSUPPORTED",`model=${e.modelInfo.id??e.model} does not support image input`);let w=await $u(c.prompt);try{let v=await l.downstream.sessionPrompt({...c,sessionId:l.acpSessionId,prompt:w});return l.lastActiveAt=Date.now(),v}finally{if(e.activeTriggers.delete(l.acpSessionId),e.activeGroupIds.delete(l.acpSessionId),l.reloadAfterTurn){l.reloadAfterTurn=!1;let v=l.downstream;v&&(l.downstream=void 0,Z.info("reloadAfterTurn: stopping downstream",{agentId:e.agentId,cloudId:d,acpId:l.acpSessionId}),v.stop("reload-after-turn").catch(I=>Z.warn("reload-after-turn stop failed (ignored)",{agentId:e.agentId,cloudId:d,err:String(I)})))}else l.downstream?.isAlive()&&this.armIdleTimer(e,d,l)}}case"session/cancel":{let d=a.sessionId;if(!d)throw new R("IPC_BAD_REQUEST","session/cancel: missing sessionId");let l=e.sessions.get(d);if(e.hasSessionQueue(d)){let x=e.getSessionQueue(d);x.size>0&&(Z.info("session/cancel: draining queued tasks",{agentId:e.agentId,cloudId:d,queuedCount:x.size}),x.dispose(new R("AGENT_PROTOCOL_ERROR",`cancelled by session/cancel on ${d}`)))}return l?.downstream?.isAlive()&&l.acpSessionId&&await l.downstream.sessionCancel({sessionId:l.acpSessionId}),{ok:!0}}default:throw new R("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(bt.GEN_MODEL_TOKEN,s,K_);if(!a?.modelToken)throw new R("MODEL_TOKEN_GEN_FAILED",`cloud returned empty modelToken (agentId=${e}, cloudSessionId=${r})`);return a.modelToken}catch(a){throw a instanceof R&&a.code==="MODEL_TOKEN_GEN_FAILED"?a:new R("MODEL_TOKEN_GEN_FAILED",a instanceof Error?a.message:String(a),{cause:a})}}async ensureDownstream(e,r,s){if(wi(s),s.downstream?.isAlive())return;if(!this.sessionSpawner)throw new R("AGENT_SPAWN_FAILED","sessionSpawner not wired (cannot spawn per-session downstream)");let a=3,c=3e4,d=s.spawnFailCount??0,l=s.spawnFailedAt??0;if(d>=a&&Date.now()-l<c)throw new R("AGENT_SPAWN_FAILED",`agent ${e.agentId} session ${r} spawn failed ${d} 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(p){throw s.spawnFailCount=d+1,s.spawnFailedAt=Date.now(),s.spawnFailCount>=a&&s.acpSessionId&&(Z.warn("clearing stale acpSessionId after repeated spawn failures",{agentId:e.agentId,cloudId:r,staleAcpId:s.acpSessionId}),s.acpSessionId=void 0),p}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}),Z.info("session restored via session/load",{agentId:e.agentId,cloudId:r,acpId:s.acpSessionId})}catch(p){Z.warn("session/load failed, fallback to session/new",{agentId:e.agentId,cloudId:r,acpId:s.acpSessionId,err:String(p)}),s.acpSessionId=void 0;let w=await x.sessionNew({cwd:e.workspace});s.acpSessionId=w.sessionId,await this.persistSessionMapping(e)}finally{s.loadingSession=!1}}else{let p=await x.sessionNew({cwd:e.workspace});s.acpSessionId=p.sessionId,await this.persistSessionMapping(e)}x.afterSessionEstablished&&s.acpSessionId&&await x.afterSessionEstablished(s.acpSessionId)}armIdleTimer(e,r,s){if(wi(s),this.isRuntimeBusy(e,s)){Z.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)){Z.info("idle reaper fired but runtime busy, re-arming",{agentId:e.agentId,cloudId:r}),this.armIdleTimer(e,r,s);return}Z.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=>Z.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 d=e.activeTriggers.get(r.acpSessionId);d&&(c.cozeTriggerMsgId=d);let l=e.activeGroupIds.get(r.acpSessionId);l&&(c.cozeGroupId=l)}await this.upstream.send(pi("session/update",{sessionId:s,update:a,_meta:c}))}forwardUpdate(e,r){let s=r.sessionId,a=this.reverseSessionId(e,s);if(!a){Z.debug("drop update for unknown session",{agentId:e.agentId,acpId:s});return}let c=e.sessions.get(a);if(!c){Z.debug("drop update: runtime gone",{agentId:e.agentId,cloudId:a});return}if(Z_(r)){Z.debug("drop codex metadata-warn chunk",{agentId:e.agentId,acpId:s});return}let d={cozeAgentId:e.agentId,cozeReplySeqID:++c.replySeq},l=e.activeTriggers.get(s);l&&(d.cozeTriggerMsgId=l);let x=e.activeGroupIds.get(s);x&&(d.cozeGroupId=x),this.upstream.send(pi("session/update",{...r,sessionId:a,_meta:d})).catch(p=>Z.warn("forward update failed",{agentId:e.agentId,err:String(p)}))}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}Z.warn("unhandled agent request,returning method_not_found",{agentId:e.agentId,method:s.method}),r.respondAgentRequestError(s.id,{code:ee.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??{},d=await qu(c,a);r.respondAgentRequest(s.id,d)}else{let c=s.params??{},d=await Gu(c,a);r.respondAgentRequest(s.id,d)}}catch(a){Z.warn("fs rpc handler failed",{agentId:e.agentId,method:s.method,err:String(a)}),r.respondAgentRequestError(s.id,mi(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,p={cozeAgentId:e.agentId};x&&(p.cozeTriggerMsgId=x);let w=l?e.activeGroupIds.get(l):void 0;w&&(p.cozeGroupId=w);let v=l?this.reverseSessionId(e,l):void 0,I={...c,...v?{sessionId:v}:{},_meta:p};this.pendingUpstream.set(a,{agentRequestId:s.id,agentId:e.agentId,downstream:r,method:s.method}),Z.info("forward permission_request \u2192 upstream",{agentId:e.agentId,upstreamId:a,acpSessionId:l,cloudSessionId:v,toolCallId:c.toolCall?.toolCallId,options:c.options?.map(b=>({optionId:b.optionId,kind:b.kind,name:b.name}))}),this.upstream.send(hi(a,"session/request_permission",I)).catch(b=>{this.pendingUpstream.delete(a),Z.error("forward permission request failed",{agentId:e.agentId,err:String(b)}),r.respondAgentRequestError(s.id,{code:ee.INTERNAL_ERROR,message:`upstream send failed: ${String(b)}`})})}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?(Z.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"&&V_(e.result,a),Z.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 Ns(e.error)):s.value.resolve(e.result);return}Z.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),d=e.get(c);if(d)return Z.warn(`${s} id type mismatch: number received but Bridge expected string`,{rawId:r,normalizedId:c}),{value:d,key:c}}}sendRequest(e,r,s=j_){let a=this.upstreamIds.next(e);return new Promise((c,d)=>{let l=setTimeout(()=>{this.pendingBridge.delete(a),d(new R("AGENT_TIMEOUT",`${e} timed out after ${s}ms`))},s);this.pendingBridge.set(a,{method:e,resolve:c,reject:d,timer:l}),this.upstream.send(hi(a,e,r)).catch(x=>{let p=this.pendingBridge.get(a);p&&(clearTimeout(p.timer),this.pendingBridge.delete(a)),d(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 Ko(e.agentId,r,this.paths)}catch(r){Z.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(cn(e,{code:r,message:s,data:{bridgeVersion:pr}}))}};function $_(){return G_(16).toString("hex")}function V_(t,e){if(!t||typeof t!="object"){Z.warn("permission response: result not an object (suspicious)",{agentId:e.agentId,result:t});return}let r=t;if("kind"in r&&!("outcome"in r)){Z.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"){Z.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")&&Z.warn("permission response: unknown outcome discriminant",{agentId:e.agentId,outcomeValue:c,result:t})}function Z_(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 `")}te();Fe();import{randomBytes as J_}from"node:crypto";import{chmod as Y_,mkdir as X_,writeFile as Zu}from"node:fs/promises";import{createServer as Q_}from"node:http";import{dirname as ey}from"node:path";var ty=1e6,yc=G("ipc"),Vs=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??ne()}async start(){this.token=J_(32).toString("hex");let e=Q_((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(),yc.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 X_(ey(this.paths.portFile),{recursive:!0}),await Zu(this.paths.portFile,String(this.port),"utf8"),await Zu(this.paths.tokenFile,this.token,{encoding:"utf8",mode:384});try{await Y_(this.paths.tokenFile,384)}catch(e){yc.warn("chmod token file failed (non-POSIX?)",{err:String(e)})}}async dispatch(e,r){if(e.headers.authorization!==`Bearer ${this.token}`){bi(r,401,{error:"unauthorized"});return}let a=`${e.method} ${(e.url??"").split("?")[0]}`,c=this.routes.get(a);if(!c){bi(r,404,{error:"not found"});return}let d=null;if(e.method==="POST")try{d=await ny(e)}catch(l){bi(r,400,{error:"invalid json",detail:String(l)});return}try{let l=await c.handler(d,e);bi(r,200,l??{ok:!0})}catch(l){yc.error("IPC handler failed",{key:a,err:String(l)}),bi(r,500,{error:l instanceof Error?l.message:String(l)})}}};function bi(t,e,r){t.statusCode=e,t.setHeader("content-type","application/json"),t.end(JSON.stringify(r))}async function ny(t){let e=[],r=0;for await(let a of t){let c=a;if(r+=c.length,r>ty)throw new Error("body too large");e.push(c)}let s=Buffer.concat(e).toString("utf8");return s?JSON.parse(s):null}var mx=ht(ol(),1);var Mb=ht(tx(),1),Bb=ht(uo(),1),zb=ht(vr(),1),Fb=ht(Pc(),1),Ub=ht(Mc(),1),Hb=ht(qc(),1),dx=ht(po(),1),qb=ht(fx(),1);var ux=dx.default;te();var Ae=G("upstream.frontier"),xx="application/json",hx="none",jb=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){Ae.warn("start called on already-started FrontierUpstream; noop");return}let e={Authorization:`Bearer ${this.opts.privatecode}`,Origin:Wd,...xr(this.opts.ppeOverride)};class r extends ux{constructor(E){super(E,jd,{headers:e})}send(E,...S){if(A0("debug"))try{let C;typeof E=="string"?C=Buffer.from(E,"utf8"):E instanceof Buffer?C=E:E instanceof ArrayBuffer?C=new Uint8Array(E):ArrayBuffer.isView(E)?C=new Uint8Array(E.buffer,E.byteOffset,E.byteLength):C=new Uint8Array(0);let D=Buffer.from(C.slice(0,128)).toString("hex");Ae.debug("WS raw frame out",{bytes:C.byteLength,headHex:D})}catch(C){Ae.warn("WS raw frame dump failed",{err:String(C)})}super.send(E,...S)}}let s=$d(this.opts.urlOverride),a={url:s,ws:r,fpID:Gd,aID:Os,accessKey:this.opts.handshake.accessKey,deviceID:this.opts.handshake.deviceId,payloadType:{type:xx,force:!0},payloadEncoding:{encoding:hx,force:!0},enableTransformTextPayload:!0,enableQoS:!1,enableAutoAck:!1,automaticOpen:!1,maxRetries:Number.POSITIVE_INFINITY,debug:this.opts.debug??!1},c=new mx.FWS(a),d=!1,l=null,x,p,w=new Promise((b,E)=>{x=b,p=E}),v=b=>{d||(d=!0,l&&(clearTimeout(l),l=null),b?p(b):x())};c.onopen=()=>{this.opened=!0,this.openCount+=1;let b=this.openCount===1;Ae.info("frontier opened",{url:s,remoteDeviceId:this.opts.handshake.deviceId,initial:b,openCount:this.openCount}),b&&v();for(let E of this.connectHandlers)Promise.resolve(E({initial:b})).catch(S=>Ae.warn("onConnect handler threw (ignored)",{err:String(S)}))},c.onclose=b=>{this.opened=!1,Ae.info("frontier closed",{code:b.code,reason:b.reason,willReconnect:b.willReconnect})},c.onerror=b=>{Ae.warn("frontier error",{code:b.code,msg:b.message}),v(new R("UPSTREAM_DISCONNECTED",`frontier connect error before open: code=${b.code} msg=${b.message??""}`))},c.onmessage=b=>this.handleMessage(b),this.fws=c;let I=this.opts.openTimeoutMs??jb;l=setTimeout(()=>{v(new R("UPSTREAM_DISCONNECTED",`frontier ws open timeout after ${I}ms (handshake or upgrade slow)`))},I),await c.connect();try{await w}catch(b){try{c.close(1e3,"open failed")}catch(E){Ae.warn("fws close during start failure threw (ignored)",{err:String(E)})}throw this.fws=null,this.opened=!1,b}}async stop(e){let r=this.fws;if(r){this.fws=null,this.opened=!1;try{r.close(1e3,e??"bridge shutdown")}catch(s){Ae.warn("frontier close threw (ignored)",{err:String(s)})}}}async send(e){let r=this.fws,s=e.method;if(!r)throw Ae.warn("frontier send refused: upstream not started",{method:s}),new R("UPSTREAM_DISCONNECTED","frontier upstream not started");if(!this.isConnected()){let l=Date.now();throw l-this.lastSendRefusedLogAt>1e3?(Ae.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 R("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;px(c)||Ae.info("frontier frame out",{method:c.method,jsonrpcId:c.id,size:a.length});try{await r.send(a,{service:33555712,method:1,payloadType:xx,payloadEncoding:hx})}catch(l){throw Ae.warn("frontier frame send failed",{method:c.method,jsonrpcId:c.id,err:String(l)}),new R("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){Ae.debug("drop non-adapter frontier frame",{service:r});return}let s=$b(e);if(!s){Ae.debug("frontier message without text payload, drop",{payloadType:e.message?.payloadType});return}if(!this.handler){Ae.debug("frame received but no onFrame handler",{size:s.length});return}let a;try{a=JSON.parse(s)}catch(d){Ae.warn("frontier message JSON parse failed",{err:String(d),head:s.slice(0,80)});return}let c=a;px(c)||Ae.info("frontier frame in",{logid:Kb(e.message?.LogID),logidNew:e.message?.LogIDNew,msgId:e.message?.msgID,jsonrpcId:c.id,method:c.method,body:Wb(s)}),Promise.resolve(this.handler(a)).catch(d=>Ae.warn("frontier frame handler threw",{err:String(d)}))}};function px(t){return t.method==="_agent/health"?!0:typeof t.id=="string"&&t.id.startsWith("agent.health_")}var gx=2e3;function Wb(t){return t.length<=gx?t:`${t.slice(0,gx)}...<truncated, total ${t.length} chars>`}function Kb(t){return t?t.high===0?String(t.low>>>0):`${t.high.toString(16)}${(t.low>>>0).toString(16).padStart(8,"0")}`:""}function $b(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}}te();var jc=G("upstream.switchable"),mo=class{inner;handler=null;connectHandlers=[];constructor(e){this.inner=e}async swap(e,r){if(this.inner===e)return;jc.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 jc.error("swap target start failed, reverting",{err:String(a)}),this.inner=s,a}await s.stop(r??"swapped").catch(a=>jc.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()}};te();var Wc=G("upstream"),Rr=class{handler=null;async start(){Wc.info("NoopUpstream started (M1 skeleton; real Frontier wired in M4)")}async stop(e){Wc.info("NoopUpstream stopped",{reason:e})}async send(e){Wc.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)}};te();te();Fe();import{promises as Kc}from"node:fs";import{dirname as Vb}from"node:path";var Zb=G("pat-token-store");async function _x(t=ne()){try{let r=(await Kc.readFile(t.patTokenFile,"utf8")).trim();return r.length>0?r:null}catch(e){let r=e?.code;return r!=="ENOENT"&&Zb.warn("read pat-token failed (treating as missing)",{path:t.patTokenFile,code:r,message:e.message}),null}}async function ki(t,e=ne()){if(!t)throw new Error("writePatToken: empty patToken");await Kc.mkdir(Vb(e.patTokenFile),{recursive:!0}),await Kc.writeFile(e.patTokenFile,t,{encoding:"utf8",mode:384})}Fe();Fe();import{promises as wo}from"node:fs";import{join as Jb}from"node:path";function Yb(t,e){return`#!/bin/sh
116
+ `;var $e=G("agent-detail-sync"),vp=6e4,Sp=5*6e4,Fi=class{constructor(e){this.opts=e}opts;retryQueue=new Map;async syncAll(e){let r=this.opts.paths.agentsRoot,i;try{i=await bp(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(u){$e.warn("detail RPC failed, using local data",{agentId:e,err:String(u)});let x=this.retryQueue.get(e),p=x?Math.min(x.currentDelay*2,Sp):vp;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 We(i,this.opts.paths),$e.info("detail sync: config updated",{agentId:e,identityChanged:f,agentName:i.agentName}),f&&(await $n(i.workspace,i.framework,e,i.cozeIdentity),this.opts.handlers.reloadAgentSessionsPublic(e,"detail-sync"))}};var au=xt(vd(),1);import{lstat as ic,mkdir as sc,readFile as ru,readdir as Vm,rm as Ym,stat as Xm,writeFile as oc}from"node:fs/promises";import{dirname as Qm,join as bt,normalize as ew,relative as dc,resolve as ac,sep as iu}from"node:path";import{Readable as su}from"node:stream";import{pipeline as ou}from"node:stream/promises";import Wp from"events";import Ke from"fs";import{EventEmitter as ja}from"node:events";import sf from"node:stream";import{StringDecoder as $p}from"node:string_decoder";import cf from"node:path";import sr from"node:fs";import{dirname as og,parse as ag}from"path";import{EventEmitter as pg}from"events";import Ia from"assert";import{Buffer as Tn}from"buffer";import*as Cd from"zlib";import gg from"zlib";import{posix as Xn}from"node:path";import{basename as Gg}from"node:path";import ms from"fs";import mt from"fs";import Nd from"path";import{win32 as em}from"node:path";import qd from"path";import vf from"node:fs";import mm from"node:assert";import{randomBytes as Sf}from"node:crypto";import X from"node:fs";import Se from"node:path";import If from"fs";import As from"node:fs";import Qr from"node:path";import Ve from"node:fs";import Sm from"node:fs/promises";import ys from"node:path";import{join as Mf}from"node:path";import Ze from"node:fs";import Ff from"node:path";var jp=Object.defineProperty,Kp=(t,e)=>{for(var r in e)jp(t,r,{get:e[r],enumerable:!0})},Sd=typeof process=="object"&&process?process:{stdout:null,stderr:null},Jp=t=>!!t&&typeof t=="object"&&(t instanceof Dn||t instanceof sf||Zp(t)||Vp(t)),Zp=t=>!!t&&typeof t=="object"&&t instanceof ja&&typeof t.pipe=="function"&&t.pipe!==sf.Writable.prototype.pipe,Vp=t=>!!t&&typeof t=="object"&&t instanceof ja&&typeof t.write=="function"&&typeof t.end=="function",Rt=Symbol("EOF"),Dt=Symbol("maybeEmitEnd"),$t=Symbol("emittedEnd"),ji=Symbol("emittingEnd"),Mr=Symbol("emittedError"),Ki=Symbol("closed"),Id=Symbol("read"),Wi=Symbol("flush"),Ad=Symbol("flushChunk"),at=Symbol("encoding"),Yn=Symbol("decoder"),Ce=Symbol("flowing"),Br=Symbol("paused"),nr=Symbol("resume"),Re=Symbol("buffer"),qe=Symbol("pipes"),De=Symbol("bufferLength"),Yo=Symbol("bufferPush"),$i=Symbol("bufferShift"),He=Symbol("objectMode"),me=Symbol("destroyed"),Xo=Symbol("error"),Qo=Symbol("emitData"),Td=Symbol("emitEnd"),ea=Symbol("emitEnd2"),ht=Symbol("async"),ta=Symbol("abort"),Ji=Symbol("aborted"),zr=Symbol("signal"),wn=Symbol("dataListeners"),Je=Symbol("discarded"),Fr=t=>Promise.resolve().then(t),Yp=t=>t(),Xp=t=>t==="end"||t==="finish"||t==="prefinish",Qp=t=>t instanceof ArrayBuffer||!!t&&typeof t=="object"&&t.constructor&&t.constructor.name==="ArrayBuffer"&&t.byteLength>=0,eg=t=>!Buffer.isBuffer(t)&&ArrayBuffer.isView(t),of=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()}},tg=class extends of{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)}},ng=t=>!!t.objectMode,rg=t=>!t.objectMode&&!!t.encoding&&t.encoding!=="buffer",Dn=class extends ja{[Ce]=!1;[Br]=!1;[qe]=[];[Re]=[];[He];[at];[ht];[Yn];[Rt]=!1;[$t]=!1;[ji]=!1;[Ki]=!1;[Mr]=null;[De]=0;[me]=!1;[zr];[Ji]=!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");ng(e)?(this[He]=!0,this[at]=null):rg(e)?(this[at]=e.encoding,this[He]=!1):(this[He]=!1,this[at]=null),this[ht]=!!e.async,this[Yn]=this[at]?new $p(this[at]):null,e&&e.debugExposeBuffer===!0&&Object.defineProperty(this,"buffer",{get:()=>this[Re]}),e&&e.debugExposePipes===!0&&Object.defineProperty(this,"pipes",{get:()=>this[qe]});let{signal:r}=e;r&&(this[zr]=r,r.aborted?this[ta]():r.addEventListener("abort",()=>this[ta]()))}get bufferLength(){return this[De]}get encoding(){return this[at]}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[He]}set objectMode(t){throw new Error("objectMode must be set at instantiation time")}get async(){return this[ht]}set async(t){this[ht]=this[ht]||!!t}[ta](){this[Ji]=!0,this.emit("abort",this[zr]?.reason),this.destroy(this[zr]?.reason)}get aborted(){return this[Ji]}set aborted(t){}write(t,e,r){if(this[Ji])return!1;if(this[Rt])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[ht]?Fr:Yp;if(!this[He]&&!Buffer.isBuffer(t)){if(eg(t))t=Buffer.from(t.buffer,t.byteOffset,t.byteLength);else if(Qp(t))t=Buffer.from(t);else if(typeof t!="string")throw new Error("Non-contiguous data written to non-objectMode stream")}return this[He]?(this[Ce]&&this[De]!==0&&this[Wi](!0),this[Ce]?this.emit("data",t):this[Yo](t),this[De]!==0&&this.emit("readable"),r&&i(r),this[Ce]):t.length?(typeof t=="string"&&!(e===this[at]&&!this[Yn]?.lastNeed)&&(t=Buffer.from(t,e)),Buffer.isBuffer(t)&&this[at]&&(t=this[Yn].write(t)),this[Ce]&&this[De]!==0&&this[Wi](!0),this[Ce]?this.emit("data",t):this[Yo](t),this[De]!==0&&this.emit("readable"),r&&i(r),this[Ce]):(this[De]!==0&&this.emit("readable"),r&&i(r),this[Ce])}read(t){if(this[me])return null;if(this[Je]=!1,this[De]===0||t===0||t&&t>this[De])return this[Dt](),null;this[He]&&(t=null),this[Re].length>1&&!this[He]&&(this[Re]=[this[at]?this[Re].join(""):Buffer.concat(this[Re],this[De])]);let e=this[Id](t||null,this[Re][0]);return this[Dt](),e}[Id](t,e){if(this[He])this[$i]();else{let r=e;t===r.length||t===null?this[$i]():typeof r=="string"?(this[Re][0]=r.slice(t),e=r.slice(0,t),this[De]-=t):(this[Re][0]=r.subarray(t),e=r.subarray(0,t),this[De]-=t)}return this.emit("data",e),!this[Re].length&&!this[Rt]&&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[Rt]=!0,this.writable=!1,(this[Ce]||!this[Br])&&this[Dt](),this}[nr](){this[me]||(!this[wn]&&!this[qe].length&&(this[Je]=!0),this[Br]=!1,this[Ce]=!0,this.emit("resume"),this[Re].length?this[Wi]():this[Rt]?this[Dt]():this.emit("drain"))}resume(){return this[nr]()}pause(){this[Ce]=!1,this[Br]=!0,this[Je]=!1}get destroyed(){return this[me]}get flowing(){return this[Ce]}get paused(){return this[Br]}[Yo](t){this[He]?this[De]+=1:this[De]+=t.length,this[Re].push(t)}[$i](){return this[He]?this[De]-=1:this[De]-=this[Re][0].length,this[Re].shift()}[Wi](t=!1){do;while(this[Ad](this[$i]())&&this[Re].length);!t&&!this[Re].length&&!this[Rt]&&this.emit("drain")}[Ad](t){return this.emit("data",t),this[Ce]}pipe(t,e){if(this[me])return t;this[Je]=!1;let r=this[$t];return e=e||{},t===Sd.stdout||t===Sd.stderr?e.end=!1:e.end=e.end!==!1,e.proxyErrors=!!e.proxyErrors,r?e.end&&t.end():(this[qe].push(e.proxyErrors?new tg(this,t,e):new of(this,t,e)),this[ht]?Fr(()=>this[nr]()):this[nr]()),t}unpipe(t){let e=this[qe].find(r=>r.dest===t);e&&(this[qe].length===1?(this[Ce]&&this[wn]===0&&(this[Ce]=!1),this[qe]=[]):this[qe].splice(this[qe].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[qe].length&&!this[Ce]&&this[nr]();else if(t==="readable"&&this[De]!==0)super.emit("readable");else if(Xp(t)&&this[$t])super.emit(t),this.removeAllListeners(t);else if(t==="error"&&this[Mr]){let i=e;this[ht]?Fr(()=>i.call(this,this[Mr])):i.call(this,this[Mr])}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[qe].length&&(this[Ce]=!1)),r}removeAllListeners(t){let e=super.removeAllListeners(t);return(t==="data"||t===void 0)&&(this[wn]=0,!this[Je]&&!this[qe].length&&(this[Ce]=!1)),e}get emittedEnd(){return this[$t]}[Dt](){!this[ji]&&!this[$t]&&!this[me]&&this[Re].length===0&&this[Rt]&&(this[ji]=!0,this.emit("end"),this.emit("prefinish"),this.emit("finish"),this[Ki]&&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[He]&&!r?!1:this[ht]?(Fr(()=>this[Qo](r)),!0):this[Qo](r);if(t==="end")return this[Td]();if(t==="close"){if(this[Ki]=!0,!this[$t]&&!this[me])return!1;let o=super.emit("close");return this.removeAllListeners("close"),o}else if(t==="error"){this[Mr]=r,super.emit(Xo,r);let o=!this[zr]||this.listeners("error").length?super.emit("error",r):!1;return this[Dt](),o}else if(t==="resume"){let o=super.emit("resume");return this[Dt](),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[Dt](),i}[Qo](t){for(let r of this[qe])r.dest.write(t)===!1&&this.pause();let e=this[Je]?!1:super.emit("data",t);return this[Dt](),e}[Td](){return this[$t]?!1:(this[$t]=!0,this.readable=!1,this[ht]?(Fr(()=>this[ea]()),!0):this[ea]())}[ea](){if(this[Yn]){let e=this[Yn].end();if(e){for(let r of this[qe])r.dest.write(e);this[Je]||super.emit("data",e)}}for(let e of this[qe])e.end();let t=super.emit("end");return this.removeAllListeners("end"),t}async collect(){let t=Object.assign([],{dataLength:0});this[He]||(t.dataLength=0);let e=this.promise();return this.on("data",r=>{t.push(r),this[He]||(t.dataLength+=r.length)}),await e,t}async concat(){if(this[He])throw new Error("cannot concat in objectMode");let t=await this.collect();return this[at]?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[Rt])return e();let i,o,c=p=>{this.off("data",f),this.off("end",u),this.off(me,x),e(),o(p)},f=p=>{this.off("error",c),this.off("end",u),this.off(me,x),this.pause(),i({value:p,done:!!this[Rt]})},u=()=>{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,_)=>{o=_,i=p,this.once(me,x),this.once("error",c),this.once("end",u),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(Xo,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(Xo,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[Re].length=0,this[De]=0;let e=this;return typeof e.close=="function"&&!this[Ki]&&e.close(),t?this.emit("error",t):this.emit(me),this}static get isStream(){return Jp}},ig=Ke.writev,rn=Symbol("_autoClose"),ut=Symbol("_close"),Ur=Symbol("_ended"),ie=Symbol("_fd"),na=Symbol("_finished"),Lt=Symbol("_flags"),ra=Symbol("_flush"),va=Symbol("_handleChunk"),Sa=Symbol("_makeBuf"),Yr=Symbol("_mode"),Zi=Symbol("_needDrain"),ar=Symbol("_onerror"),cr=Symbol("_onopen"),ia=Symbol("_onread"),rr=Symbol("_onwrite"),sn=Symbol("_open"),ft=Symbol("_path"),Xt=Symbol("_pos"),pt=Symbol("_queue"),ir=Symbol("_read"),sa=Symbol("_readSize"),Pt=Symbol("_reading"),Hr=Symbol("_remain"),oa=Symbol("_size"),ss=Symbol("_write"),_n=Symbol("_writing"),os=Symbol("_defaultFlag"),An=Symbol("_errored"),Ka=class extends Dn{[An]=!1;[ie];[ft];[sa];[Pt]=!1;[oa];[Hr];[rn];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[ft]=t,this[sa]=e.readSize||16*1024*1024,this[Pt]=!1,this[oa]=typeof e.size=="number"?e.size:1/0,this[Hr]=this[oa],this[rn]=typeof e.autoClose=="boolean"?e.autoClose:!0,typeof this[ie]=="number"?this[ir]():this[sn]()}get fd(){return this[ie]}get path(){return this[ft]}write(){throw new TypeError("this is a readable stream")}end(){throw new TypeError("this is a readable stream")}[sn](){Ke.open(this[ft],"r",(t,e)=>this[cr](t,e))}[cr](t,e){t?this[ar](t):(this[ie]=e,this.emit("open",e),this[ir]())}[Sa](){return Buffer.allocUnsafe(Math.min(this[sa],this[Hr]))}[ir](){if(!this[Pt]){this[Pt]=!0;let t=this[Sa]();if(t.length===0)return process.nextTick(()=>this[ia](null,0,t));Ke.read(this[ie],t,0,t.length,null,(e,r,i)=>this[ia](e,r,i))}}[ia](t,e,r){this[Pt]=!1,t?this[ar](t):this[va](e,r)&&this[ir]()}[ut](){if(this[rn]&&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[Pt]=!0,this[ut](),this.emit("error",t)}[va](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[ut](),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)}}},sg=class extends Ka{[sn](){let t=!0;try{this[cr](null,Ke.openSync(this[ft],"r")),t=!1}finally{t&&this[ut]()}}[ir](){let t=!0;try{if(!this[Pt]){this[Pt]=!0;do{let e=this[Sa](),r=e.length===0?0:Ke.readSync(this[ie],e,0,e.length,null);if(!this[va](r,e))break}while(!0);this[Pt]=!1}t=!1}finally{t&&this[ut]()}}[ut](){if(this[rn]&&typeof this[ie]=="number"){let t=this[ie];this[ie]=void 0,Ke.closeSync(t),this.emit("close")}}},Es=class extends Wp{readable=!1;writable=!0;[An]=!1;[_n]=!1;[Ur]=!1;[pt]=[];[Zi]=!1;[ft];[Yr];[rn];[ie];[os];[Lt];[na]=!1;[Xt];constructor(t,e){e=e||{},super(e),this[ft]=t,this[ie]=typeof e.fd=="number"?e.fd:void 0,this[Yr]=e.mode===void 0?438:e.mode,this[Xt]=typeof e.start=="number"?e.start:void 0,this[rn]=typeof e.autoClose=="boolean"?e.autoClose:!0;let r=this[Xt]!==void 0?"r+":"w";this[os]=e.flags===void 0,this[Lt]=e.flags===void 0?r:e.flags,this[ie]===void 0&&this[sn]()}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[ft]}[ar](t){this[ut](),this[_n]=!0,this.emit("error",t)}[sn](){Ke.open(this[ft],this[Lt],this[Yr],(t,e)=>this[cr](t,e))}[cr](t,e){this[os]&&this[Lt]==="r+"&&t&&t.code==="ENOENT"?(this[Lt]="w",this[sn]()):t?this[ar](t):(this[ie]=e,this.emit("open",e),this[_n]||this[ra]())}end(t,e){return t&&this.write(t,e),this[Ur]=!0,!this[_n]&&!this[pt].length&&typeof this[ie]=="number"&&this[rr](null,0),this}write(t,e){return typeof t=="string"&&(t=Buffer.from(t,e)),this[Ur]?(this.emit("error",new Error("write() after end()")),!1):this[ie]===void 0||this[_n]||this[pt].length?(this[pt].push(t),this[Zi]=!0,!1):(this[_n]=!0,this[ss](t),!0)}[ss](t){Ke.write(this[ie],t,0,t.length,this[Xt],(e,r)=>this[rr](e,r))}[rr](t,e){t?this[ar](t):(this[Xt]!==void 0&&typeof e=="number"&&(this[Xt]+=e),this[pt].length?this[ra]():(this[_n]=!1,this[Ur]&&!this[na]?(this[na]=!0,this[ut](),this.emit("finish")):this[Zi]&&(this[Zi]=!1,this.emit("drain"))))}[ra](){if(this[pt].length===0)this[Ur]&&this[rr](null,0);else if(this[pt].length===1)this[ss](this[pt].pop());else{let t=this[pt];this[pt]=[],ig(this[ie],t,this[Xt],(e,r)=>this[rr](e,r))}}[ut](){if(this[rn]&&typeof this[ie]=="number"){let t=this[ie];this[ie]=void 0,Ke.close(t,e=>e?this.emit("error",e):this.emit("close"))}}},af=class extends Es{[sn](){let t;if(this[os]&&this[Lt]==="r+")try{t=Ke.openSync(this[ft],this[Lt],this[Yr])}catch(e){if(e?.code==="ENOENT")return this[Lt]="w",this[sn]();throw e}else t=Ke.openSync(this[ft],this[Lt],this[Yr]);this[cr](null,t)}[ut](){if(this[rn]&&typeof this[ie]=="number"){let t=this[ie];this[ie]=void 0,Ke.closeSync(t),this.emit("close")}}[ss](t){let e=!0;try{this[rr](null,Ke.writeSync(this[ie],t,0,t.length,this[Xt])),e=!1}finally{if(e)try{this[ut]()}catch{}}}},cg=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"]]),dg=t=>!!t.sync&&!!t.file,fg=t=>!t.sync&&!!t.file,ug=t=>!!t.sync&&!t.file,lg=t=>!t.sync&&!t.file,xg=t=>!!t.file,hg=t=>cg.get(t)||t,Wa=(t={})=>{if(!t)return{};let e={};for(let[r,i]of Object.entries(t)){let o=hg(r);e[o]=i}return e.chmod===void 0&&e.noChmod===!1&&(e.chmod=!0),delete e.noChmod,e},oi=(t,e,r,i,o)=>Object.assign((c=[],f,u)=>{Array.isArray(c)&&(f=c,c={}),typeof f=="function"&&(u=f,f=void 0),f=f?Array.from(f):[];let x=Wa(c);if(o?.(x,f),dg(x)){if(typeof u=="function")throw new TypeError("callback not supported for sync tar functions");return t(x,f)}else if(fg(x)){let p=e(x,f);return u?p.then(()=>u(),u):p}else if(ug(x)){if(typeof u=="function")throw new TypeError("callback not supported for sync tar functions");return r(x,f)}else if(lg(x)){if(typeof u=="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}),mg=gg.constants||{ZLIB_VERNUM:4736},_t=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},mg)),wg=Tn.concat,Rd=Object.getOwnPropertyDescriptor(Tn,"concat"),_g=t=>t,aa=Rd?.writable===!0||Rd?.set!==void 0?t=>{Tn.concat=t?_g:wg}:t=>{},Cn=Symbol("_superWrite"),Vi=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"}},ca=Symbol("flushFlag"),$a=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 Cd[e]!="function")throw new TypeError("Compression method not supported: "+e);try{this.#t=new Cd[e](t)}catch(r){throw new Vi(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 Vi(r))),this.once("end",()=>this.close)}close(){this.#t&&(this.#t.close(),this.#t=void 0,this.emit("close"))}reset(){if(!this.#e)return Ia(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),{[ca]: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;Ia(this.#t,"zlib binding closed");let i=this.#t._handle,o=i.close;i.close=()=>{};let c=this.#t.close;this.#t.close=()=>{},aa(!0);let f;try{let x=typeof t[ca]=="number"?t[ca]:this.#r;f=this.#t._processChunk(t,x),aa(!1)}catch(x){aa(!1),this.#o(new Vi(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 Vi(x,this.write)));let u;if(f)if(Array.isArray(f)&&f.length>0){let x=f[0];u=this[Cn](Tn.from(x));for(let p=1;p<f.length;p++)u=this[Cn](f[p])}else u=this[Cn](Tn.from(f));return r&&r(),u}},df=class extends $a{#e;#n;constructor(t,e){t=t||{},t.flush=t.flush||_t.Z_NO_FLUSH,t.finishFlush=t.finishFlush||_t.Z_FINISH,t.fullFlushFlag=_t.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(_t.Z_SYNC_FLUSH),Ia(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)}}}},yg=class extends df{#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)}},Eg=class extends df{constructor(t){super(t,"Unzip")}},ff=class extends $a{constructor(t,e){t=t||{},t.flush=t.flush||_t.BROTLI_OPERATION_PROCESS,t.finishFlush=t.finishFlush||_t.BROTLI_OPERATION_FINISH,t.fullFlushFlag=_t.BROTLI_OPERATION_FLUSH,super(t,e)}},bg=class extends ff{constructor(t){super(t,"BrotliCompress")}},vg=class extends ff{constructor(t){super(t,"BrotliDecompress")}},uf=class extends $a{constructor(t,e){t=t||{},t.flush=t.flush||_t.ZSTD_e_continue,t.finishFlush=t.finishFlush||_t.ZSTD_e_end,t.fullFlushFlag=_t.ZSTD_e_flush,super(t,e)}},Sg=class extends uf{constructor(t){super(t,"ZstdCompress")}},Ig=class extends uf{constructor(t){super(t,"ZstdDecompress")}},Ag=(t,e)=>{if(Number.isSafeInteger(t))t<0?Cg(t,e):Tg(t,e);else throw Error("cannot encode number outside of javascript safe integer range");return e},Tg=(t,e)=>{e[0]=128;for(var r=e.length;r>1;r--)e[r-1]=t&255,t=Math.floor(t/256)},Cg=(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]=lf(o):o===0?e[i-1]=0:(r=!0,e[i-1]=xf(o))}},Rg=t=>{let e=t[0],r=e===128?kg(t.subarray(1,t.length)):e===255?Dg(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},Dg=t=>{for(var e=t.length,r=0,i=!1,o=e-1;o>-1;o--){var c=Number(t[o]),f;i?f=lf(c):c===0?f=c:(i=!0,f=xf(c)),f!==0&&(r-=f*Math.pow(256,e-o-1))}return r},kg=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},lf=t=>(255^t)&255,xf=t=>(255^t)+1&255,Og={};Kp(Og,{code:()=>Ja,isCode:()=>as,isName:()=>Pg,name:()=>bs});var as=t=>bs.has(t),Pg=t=>Ja.has(t),bs=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"]]),Ja=new Map(Array.from(bs).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??Qt(t,e+100,8),this.uid=r?.uid??i?.uid??Qt(t,e+108,8),this.gid=r?.gid??i?.gid??Qt(t,e+116,8),this.size=r?.size??i?.size??Qt(t,e+124,12),this.mtime=r?.mtime??i?.mtime??da(t,e+136,12),this.cksum=Qt(t,e+148,12),i&&this.#n(i,!0),r&&this.#n(r);let o=yn(t,e+156,1);if(as(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??Qt(t,e+329,8)??0,this.devmin=r?.devmin??i?.devmin??Qt(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??da(t,e+476,12),this.ctime=r?.ctime??i?.ctime??da(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=Lg(this.path||"",r),o=i[0],c=i[1];this.needPax=!!i[2],this.needPax=En(t,e,100,o)||this.needPax,this.needPax=en(t,e+100,8,this.mode)||this.needPax,this.needPax=en(t,e+108,8,this.uid)||this.needPax,this.needPax=en(t,e+116,8,this.gid)||this.needPax,this.needPax=en(t,e+124,12,this.size)||this.needPax,this.needPax=fa(t,e+136,12,this.mtime)||this.needPax,t[e+156]=Number(this.#e.codePointAt(0)),this.needPax=En(t,e+157,100,this.linkpath)||this.needPax,t.write("ustar\x0000",e+257,8),this.needPax=En(t,e+265,32,this.uname)||this.needPax,this.needPax=En(t,e+297,32,this.gname)||this.needPax,this.needPax=en(t,e+329,8,this.devmaj)||this.needPax,this.needPax=en(t,e+337,8,this.devmin)||this.needPax,this.needPax=En(t,e+345,r,c)||this.needPax,t[e+475]!==0?this.needPax=En(t,e+345,155,c)||this.needPax:(this.needPax=En(t,e+345,130,c)||this.needPax,this.needPax=fa(t,e+476,12,this.atime)||this.needPax,this.needPax=fa(t,e+488,12,this.ctime)||this.needPax);let f=256;for(let u=e;u<e+148;u++)f+=t[u];for(let u=e+156;u<e+512;u++)f+=t[u];return this.cksum=f,en(t,e+148,8,this.cksum),this.cksumValid=!0,this.needPax}get type(){return this.#e==="Unsupported"?this.#e:bs.get(this.#e)}get typeKey(){return this.#e}set type(t){let e=String(Ja.get(t));if(as(e)||e==="Unsupported")this.#e=e;else if(as(t))this.#e=t;else throw new TypeError("invalid entry type: "+t)}},Lg=(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.*/,""),da=(t,e,r)=>Ng(Qt(t,e,r)),Ng=t=>t===void 0?void 0:new Date(t*1e3),Qt=(t,e,r)=>Number(t[e])&128?Rg(t.subarray(e,e+r)):Bg(t,e,r),Mg=t=>isNaN(t)?void 0:t,Bg=(t,e,r)=>Mg(parseInt(t.subarray(e,e+r).toString("utf8").replace(/\0.*$/,"").trim(),8)),zg={12:8589934591,8:2097151},en=(t,e,r,i)=>i===void 0?!1:i>zg[r]||i<0?(Ag(i,t.subarray(e,e+r)),!0):(Fg(t,e,r,i),!1),Fg=(t,e,r,i)=>t.write(Ug(i,r),e,r,"ascii"),Ug=(t,e)=>Hg(Math.floor(t).toString(8),e),Hg=(t,e)=>(t.length===e-1?t:new Array(e-t.length-1).join("0")+t+" ")+"\0",fa=(t,e,r,i)=>i===void 0?!1:en(t,e,r,i.getTime()/1e3),qg=new Array(156).join("\0"),En=(t,e,r,i)=>i===void 0?!1:(t.write(i+qg,e,r,"utf8"),i.length!==Buffer.byteLength(i)||i.length>r),gs=class hf{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/"+Gg(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+`
117
+ `,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 hf(jg(Kg(e),r),i)}},jg=(t,e)=>e?Object.assign({},e,t):t,Kg=t=>t.replace(/\n$/,"").split(`
118
+ `).reduce(Wg,Object.create(null)),Wg=(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},$g=process.env.TESTING_TAR_FAKE_PLATFORM||process.platform,V=$g!=="win32"?t=>t:t=>t&&t.replaceAll(/\\/g,"/"),pf=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=V(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?V(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=V(t.path)),t.linkpath&&(t.linkpath=V(t.linkpath)),Object.assign(this,Object.fromEntries(Object.entries(t).filter(([r,i])=>!(i==null||r==="path"&&e))))}},vs=(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))},Jg=1024*1024,Aa=Buffer.from([31,139]),Ta=Buffer.from([40,181,47,253]),Zg=Math.max(Aa.length,Ta.length),Qe=Symbol("state"),bn=Symbol("writeEntry"),kt=Symbol("readEntry"),ua=Symbol("nextEntry"),Dd=Symbol("processEntry"),gt=Symbol("extendedHeader"),qr=Symbol("globalExtendedHeader"),Jt=Symbol("meta"),kd=Symbol("emitMeta"),ce=Symbol("buffer"),Ot=Symbol("queue"),Zt=Symbol("ended"),la=Symbol("emittedEnd"),vn=Symbol("emit"),Ee=Symbol("unzip"),Yi=Symbol("consumeChunk"),Xi=Symbol("consumeChunkSub"),xa=Symbol("consumeBody"),Od=Symbol("consumeMeta"),Pd=Symbol("consumeHeader"),Gr=Symbol("consuming"),ha=Symbol("bufferConcat"),Qi=Symbol("maybeEnd"),Qn=Symbol("writing"),Vt=Symbol("aborted"),es=Symbol("onDone"),Sn=Symbol("sawValidEntry"),ts=Symbol("sawNullBlock"),ns=Symbol("sawEOF"),Ld=Symbol("closeStream"),Vg=()=>!0,si=class extends pg{file;strict;maxMetaEntrySize;filter;brotli;zstd;writable=!0;readable=!1;[Ot]=[];[ce];[kt];[bn];[Qe]="begin";[Jt]="";[gt];[qr];[Zt]=!1;[Ee];[Vt]=!1;[Sn];[ts]=!1;[ns]=!1;[Qn]=!1;[Gr]=!1;[la]=!1;constructor(t={}){super(),this.file=t.file||"",this.on(es,()=>{(this[Qe]==="begin"||this[Sn]===!1)&&this.warn("TAR_BAD_ARCHIVE","Unrecognized archive format")}),t.ondone?this.on(es,t.ondone):this.on(es,()=>{this.emit("prefinish"),this.emit("finish"),this.emit("end")}),this.strict=!!t.strict,this.maxMetaEntrySize=t.maxMetaEntrySize||Jg,this.filter=typeof t.filter=="function"?t.filter:Vg;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[Ld]()),typeof t.onwarn=="function"&&this.on("warn",t.onwarn),typeof t.onReadEntry=="function"&&this.on("entry",t.onReadEntry)}warn(t,e,r={}){vs(this,t,e,r)}[Pd](t,e){this[Sn]===void 0&&(this[Sn]=!1);let r;try{r=new Rn(t,e,this[gt],this[qr])}catch(i){return this.warn("TAR_ENTRY_INVALID",i)}if(r.nullBlock)this[ts]?(this[ns]=!0,this[Qe]==="begin"&&(this[Qe]="header"),this[vn]("eof")):(this[ts]=!0,this[vn]("nullBlock"));else if(this[ts]=!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[bn]=new pf(r,this[gt],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[Qe]="ignore",o.resume()):o.size>0&&(this[Jt]="",o.on("data",c=>this[Jt]+=c),this[Qe]="meta"):(this[gt]=void 0,o.ignore=o.ignore||!this.filter(o.path,o),o.ignore?(this[vn]("ignoredEntry",o),this[Qe]=o.remain?"ignore":"header",o.resume()):(o.remain?this[Qe]="body":(this[Qe]="header",o.end()),this[kt]?this[Ot].push(o):(this[Ot].push(o),this[ua]())))}}}[Ld](){queueMicrotask(()=>this.emit("close"))}[Dd](t){let e=!0;if(!t)this[kt]=void 0,e=!1;else if(Array.isArray(t)){let[r,...i]=t;this.emit(r,...i)}else this[kt]=t,this.emit("entry",t),t.emittedEnd||(t.on("end",()=>this[ua]()),e=!1);return e}[ua](){do;while(this[Dd](this[Ot].shift()));if(this[Ot].length===0){let t=this[kt];!t||t.flowing||t.size===t.remain?this[Qn]||this.emit("drain"):t.once("drain",()=>this.emit("drain"))}}[xa](t,e){let r=this[bn];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[Qe]="header",this[bn]=void 0,r.end()),o.length}[Od](t,e){let r=this[bn],i=this[xa](t,e);return!this[bn]&&r&&this[kd](r),i}[vn](t,e,r){this[Ot].length===0&&!this[kt]?this.emit(t,e,r):this[Ot].push([t,e,r])}[kd](t){switch(this[vn]("meta",this[Jt]),t.type){case"ExtendedHeader":case"OldExtendedHeader":this[gt]=gs.parse(this[Jt],this[gt],!1);break;case"GlobalExtendedHeader":this[qr]=gs.parse(this[Jt],this[qr],!0);break;case"NextFileHasLongPath":case"OldGnuLongPath":{let e=this[gt]??Object.create(null);this[gt]=e,e.path=this[Jt].replace(/\0.*/,"");break}case"NextFileHasLongLinkpath":{let e=this[gt]||Object.create(null);this[gt]=e,e.linkpath=this[Jt].replace(/\0.*/,"");break}default:throw new Error("unknown meta: "+t.type)}}abort(t){this[Vt]=!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[Vt])return r?.(),!1;if((this[Ee]===void 0||this.brotli===void 0&&this[Ee]===!1)&&t){if(this[ce]&&(t=Buffer.concat([this[ce],t]),this[ce]=void 0),t.length<Zg)return this[ce]=t,r?.(),!0;for(let f=0;this[Ee]===void 0&&f<Aa.length;f++)t[f]!==Aa[f]&&(this[Ee]=!1);let o=!1;if(this[Ee]===!1&&this.zstd!==!1){o=!0;for(let f=0;f<Ta.length;f++)if(t[f]!==Ta[f]){o=!1;break}}let c=this.brotli===void 0&&!o;if(this[Ee]===!1&&c)if(t.length<512)if(this[Zt])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[Ee]===void 0||this[Ee]===!1&&(this.brotli||o)){let f=this[Zt];this[Zt]=!1,this[Ee]=this[Ee]===void 0?new Eg({}):o?new Ig({}):new vg({}),this[Ee].on("data",x=>this[Yi](x)),this[Ee].on("error",x=>this.abort(x)),this[Ee].on("end",()=>{this[Zt]=!0,this[Yi]()}),this[Qn]=!0;let u=!!this[Ee][f?"end":"write"](t);return this[Qn]=!1,r?.(),u}}this[Qn]=!0,this[Ee]?this[Ee].write(t):this[Yi](t),this[Qn]=!1;let i=this[Ot].length>0?!1:this[kt]?this[kt].flowing:!0;return!i&&this[Ot].length===0&&this[kt]?.once("drain",()=>this.emit("drain")),r?.(),i}[ha](t){t&&!this[Vt]&&(this[ce]=this[ce]?Buffer.concat([this[ce],t]):t)}[Qi](){if(this[Zt]&&!this[la]&&!this[Vt]&&!this[Gr]){this[la]=!0;let t=this[bn];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](es)}}[Yi](t){if(this[Gr]&&t)this[ha](t);else if(!t&&!this[ce])this[Qi]();else if(t){if(this[Gr]=!0,this[ce]){this[ha](t);let e=this[ce];this[ce]=void 0,this[Xi](e)}else this[Xi](t);for(;this[ce]&&this[ce]?.length>=512&&!this[Vt]&&!this[ns];){let e=this[ce];this[ce]=void 0,this[Xi](e)}this[Gr]=!1}(!this[ce]||this[Zt])&&this[Qi]()}[Xi](t){let e=0,r=t.length;for(;e+512<=r&&!this[Vt]&&!this[ns];)switch(this[Qe]){case"begin":case"header":this[Pd](t,e),e+=512;break;case"ignore":case"body":e+=this[xa](t,e);break;case"meta":e+=this[Od](t,e);break;default:throw new Error("invalid state: "+this[Qe])}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[Vt]||(this[Ee]?(t&&this[Ee].write(t),this[Ee].end()):(this[Zt]=!0,(this.brotli===void 0||this.zstd===void 0)&&(t=t||Buffer.alloc(0)),t&&this.write(t),this[Qi]())),this}},Xr=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)},Yg=t=>{let e=t.onReadEntry;t.onReadEntry=e?r=>{e(r),r.resume()}:r=>r.resume()},gf=(t,e)=>{let r=new Map(e.map(c=>[Xr(c),!0])),i=t.filter,o=(c,f="")=>{let u=f||ag(c).root||".",x;if(c===u)x=!1;else{let p=r.get(c);x=p!==void 0?p:o(og(c),u)}return r.set(c,x),x};t.filter=i?(c,f)=>i(c,f)&&o(Xr(c)):c=>o(Xr(c))},Xg=t=>{let e=new si(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),u=sr.readSync(i,f,0,o.size,0);e.end(u===f.byteLength?f:f.subarray(0,u))}else{let f=0,u=Buffer.allocUnsafe(c);for(;f<o.size;){let x=sr.readSync(i,u,0,c,f);if(x===0)break;f+=x,e.write(u.subarray(0,x))}e.end()}}finally{if(typeof i=="number")try{sr.closeSync(i)}catch{}}},Qg=(t,e)=>{let r=new si(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,(u,x)=>{if(u)f(u);else{let p=new Ka(o,{readSize:i,size:x.size});p.on("error",f),p.pipe(r)}})})},dr=oi(Xg,Qg,t=>new si(t),t=>new si(t),(t,e)=>{e?.length&&gf(t,e),t.noResume||Yg(t)}),mf=(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:tm,parse:Md}=em,Za=t=>{let e="",r=Md(t);for(;tm(t)||r.root;){let i=t.charAt(0)==="/"&&t.slice(0,4)!=="//?/"?"/":r.root;t=t.slice(i.length),e+=i,r=Md(t)}return[e,t]},Ss=["|","<",">","?",":"],Va=Ss.map(t=>String.fromCodePoint(61440+Number(t.codePointAt(0)))),nm=new Map(Ss.map((t,e)=>[t,Va[e]])),rm=new Map(Va.map((t,e)=>[t,Ss[e]])),Bd=t=>Ss.reduce((e,r)=>e.split(r).join(nm.get(r)),t),im=t=>Va.reduce((e,r)=>e.split(r).join(rm.get(r)),t),wf=(t,e)=>e?(t=V(t).replace(/^\.(\/|$)/,""),Xr(e)+"/"+t):V(t),sm=16*1024*1024,zd=Symbol("process"),Fd=Symbol("file"),Ud=Symbol("directory"),Ca=Symbol("symlink"),Hd=Symbol("hardlink"),jr=Symbol("header"),cs=Symbol("read"),Ra=Symbol("lstat"),ds=Symbol("onlstat"),Da=Symbol("onread"),ka=Symbol("onreadlink"),Oa=Symbol("openfile"),Pa=Symbol("onopenfile"),tn=Symbol("close"),ws=Symbol("mode"),La=Symbol("awaitDrain"),pa=Symbol("ondrain"),wt=Symbol("prefix"),_f=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=Wa(e);super(),this.path=V(t),this.portable=!!r.portable,this.maxReadSize=r.maxReadSize||sm,this.linkCache=r.linkCache||new Map,this.statCache=r.statCache||new Map,this.preservePaths=!!r.preservePaths,this.cwd=V(r.cwd||process.cwd()),this.strict=!!r.strict,this.noPax=!!r.noPax,this.noMtime=!!r.noMtime,this.mtime=r.mtime,this.prefix=r.prefix?V(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]=Za(this.path);c&&typeof f=="string"&&(this.path=f,i=c)}this.win32=!!r.win32||process.platform==="win32",this.win32&&(this.path=im(this.path.replaceAll(/\\/g,"/")),t=t.replaceAll(/\\/g,"/")),this.absolute=V(r.absolute||Nd.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[ds](o):this[Ra]()}warn(t,e,r={}){return vs(this,t,e,r)}emit(t,...e){return t==="error"&&(this.#e=!0),super.emit(t,...e)}[Ra](){mt.lstat(this.absolute,(t,e)=>{if(t)return this.emit("error",t);this[ds](e)})}[ds](t){this.statCache.set(this.absolute,t),this.stat=t,t.isFile()||(t.size=0),this.type=cm(t),this.emit("stat",t),this[zd]()}[zd](){switch(this.type){case"File":return this[Fd]();case"Directory":return this[Ud]();case"SymbolicLink":return this[Ca]();default:return this.end()}}[ws](t){return mf(t,this.type==="Directory",this.portable)}[wt](t){return wf(t,this.prefix)}[jr](){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[wt](this.path),linkpath:this.type==="Link"&&this.linkpath!==void 0?this[wt](this.linkpath):this.linkpath,mode:this[ws](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 gs({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[wt](this.path),linkpath:this.type==="Link"&&this.linkpath!==void 0?this[wt](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)}[Ud](){if(!this.stat)throw new Error("cannot create directory entry without stat");this.path.slice(-1)!=="/"&&(this.path+="/"),this.stat.size=0,this[jr](),this.end()}[Ca](){mt.readlink(this.absolute,(t,e)=>{if(t)return this.emit("error",t);this[ka](e)})}[ka](t){this.linkpath=V(t),this[jr](),this.end()}[Hd](t){if(!this.stat)throw new Error("cannot create link entry without stat");this.type="Link",this.linkpath=V(Nd.relative(this.cwd,t)),this.stat.size=0,this[jr](),this.end()}[Fd](){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[Hd](e);this.linkCache.set(t,this.absolute)}if(this[jr](),this.stat.size===0)return this.end();this[Oa]()}[Oa](){mt.open(this.absolute,"r",(t,e)=>{if(t)return this.emit("error",t);this[Pa](e)})}[Pa](t){if(this.fd=t,this.#e)return this[tn]();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[cs]()}[cs](){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");mt.read(t,e,r,i,o,(c,f)=>{if(c)return this[tn](()=>this.emit("error",c));this[Da](f)})}[tn](t=()=>{}){this.fd!==void 0&&mt.close(this.fd,t)}[Da](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[tn](()=>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[tn](()=>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[pa]():this[La](()=>this[pa]())}[La](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)}[pa](){if(!this.remain)return this.blockRemain&&super.write(Buffer.alloc(this.blockRemain)),this[tn](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[cs]()}},om=class extends _f{sync=!0;[Ra](){this[ds](mt.lstatSync(this.absolute))}[Ca](){this[ka](mt.readlinkSync(this.absolute))}[Oa](){this[Pa](mt.openSync(this.absolute,"r"))}[cs](){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=mt.readSync(e,r,i,o,c);this[Da](f),t=!1}finally{if(t)try{this[tn](()=>{})}catch{}}}[La](t){t()}[tn](t=()=>{}){this.fd!==void 0&&mt.closeSync(this.fd),t()}},am=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 vs(this,t,e,r)}constructor(t,e={}){let r=Wa(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=V(t.path),this.mode=t.mode!==void 0?this[ws](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?V(t.linkpath):void 0,typeof r.onwarn=="function"&&this.on("warn",r.onwarn);let o=!1;if(!this.preservePaths){let[f,u]=Za(this.path);f&&typeof u=="string"&&(this.path=u,o=f)}this.remain=t.size,this.blockRemain=t.startBlockSize,this.onWriteEntry?.(this),this.header=new Rn({path:this[wt](this.path),linkpath:this.type==="Link"&&this.linkpath!==void 0?this[wt](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 gs({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[wt](this.path),linkpath:this.type==="Link"&&this.linkpath!==void 0?this[wt](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)}[wt](t){return wf(t,this.prefix)}[ws](t){return mf(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}},cm=t=>t.isFile()?"File":t.isDirectory()?"Directory":t.isSymbolicLink()?"SymbolicLink":"Unsupported",dm=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++)um(this,e[r]);return this.length}unshift(...e){for(var r=0,i=e.length;r<i;r++)lm(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=fm(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 fm(t,e,r){let i=e,o=e?e.next:t.head,c=new Ya(r,i,o,t);return c.next===void 0&&(t.tail=c),c.prev===void 0&&(t.head=c),t.length++,c}function um(t,e){t.tail=new Ya(e,t.tail,void 0,t),t.head||(t.head=t.tail),t.length++}function lm(t,e){t.head=new Ya(e,void 0,t.head,t),t.tail||(t.tail=t.head),t.length++}var Ya=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}},Gd=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),fs=Symbol("onStat"),Kr=Symbol("ended"),ct=Symbol("queue"),Wr=Symbol("queue"),Yt=Symbol("current"),In=Symbol("process"),$r=Symbol("processing"),rs=Symbol("processJob"),dt=Symbol("jobs"),ga=Symbol("jobDone"),us=Symbol("addFSEntry"),Kd=Symbol("addTarEntry"),Na=Symbol("stat"),Ma=Symbol("readdir"),ls=Symbol("onreaddir"),xs=Symbol("pipe"),Wd=Symbol("entry"),ma=Symbol("entryOpt"),hs=Symbol("writeEntryClass"),yf=Symbol("write"),wa=Symbol("ondrain"),Is=class extends Dn{sync=!1;opt;cwd;maxReadSize;preservePaths;strict;noPax;prefix;linkCache;statCache;file;portable;zip;readdirCache;noDirRecurse;follow;noMtime;mtime;filter;jobs;[hs];onWriteEntry;[ct];[Wr]=new Map;[dt]=0;[$r]=!1;[Kr]=!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=V(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[hs]=_f,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 yg(t.gzip)),t.brotli&&(typeof t.brotli!="object"&&(t.brotli={}),this.zip=new bg(t.brotli)),t.zstd&&(typeof t.zstd!="object"&&(t.zstd={}),this.zip=new Sg(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[wa]()),this.on("resume",()=>e.resume())}else this.on("drain",this[wa]);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[ct]=new dm,this[dt]=0,this.jobs=Number(t.jobs)||4,this[$r]=!1,this[Kr]=!1}[yf](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[Kr]=!0,this[In](),r&&r(),this}write(t){if(this[Kr])throw new Error("write after end");return t instanceof pf?this[Kd](t):this[us](t),this.flowing}[Kd](t){let e=V(qd.resolve(this.cwd,t.path));if(!this.filter(t.path,t))t.resume();else{let r=new Gd(t.path,e);r.entry=new am(t,this[ma](r)),r.entry.on("end",()=>this[ga](r)),this[dt]+=1,this[ct].push(r)}this[In]()}[us](t){let e=V(qd.resolve(this.cwd,t));this[ct].push(new Gd(t,e)),this[In]()}[Na](t){t.pending=!0,this[dt]+=1;let e=this.follow?"stat":"lstat";ms[e](t.absolute,(r,i)=>{t.pending=!1,this[dt]-=1,r?this.emit("error",r):this[fs](t,i)})}[fs](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[Yt])this[rs](t);else{let r=`${e.dev}:${e.ino}`,i=this[Wr].get(r);i?i.push(t):this[Wr].set(r,[t]),t.pendingLink=!0,t.pending=!0}this[In]()}[Ma](t){t.pending=!0,this[dt]+=1,ms.readdir(t.absolute,(e,r)=>{if(t.pending=!1,this[dt]-=1,e)return this.emit("error",e);this[ls](t,r)})}[ls](t,e){this.readdirCache.set(t.absolute,e),t.readdir=e,this[In]()}[In](){if(!this[$r]){this[$r]=!0;for(let t=this[ct].head;t&&this[dt]<this.jobs;t=t.next)if(this[rs](t.value),t.value.ignore){let e=t.next;this[ct].removeNode(t),t.next=e}this[$r]=!1,this[Kr]&&this[ct].length===0&&this[dt]===0&&(this.zip?this.zip.end(jd):(super.write(jd),super.end()))}}get[Yt](){return this[ct]&&this[ct].head&&this[ct].head.value}[ga](t){this[ct].shift(),this[dt]-=1;let{stat:e}=t;if(e&&e.isFile()&&e.nlink>1){let r=`${e.dev}:${e.ino}`,i=this[Wr].get(r);if(i){this[Wr].delete(r);for(let o of i)o.pending=!1,this[rs](o)}}this[In]()}[rs](t){if(t.pending&&t.pendingLink&&t===this[Yt]&&(t.pending=!1,t.pendingLink=!1),!t.pending){if(t.entry){t===this[Yt]&&!t.piped&&this[xs](t);return}if(!t.stat){let e=this.statCache.get(t.absolute);e?this[fs](t,e):this[Na](t)}if(t.stat&&!t.ignore){if(!this.noDirRecurse&&t.stat.isDirectory()&&!t.readdir){let e=this.readdirCache.get(t.absolute);if(e?this[ls](t,e):this[Ma](t),!t.readdir)return}if(t.entry=this[Wd](t),!t.entry){t.ignore=!0;return}t===this[Yt]&&!t.piped&&this[xs](t)}}}[ma](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}}[Wd](t){this[dt]+=1;try{return new this[hs](t.path,this[ma](t)).on("end",()=>this[ga](t)).on("error",e=>this.emit("error",e))}catch(e){this.emit("error",e)}}[wa](){this[Yt]&&this[Yt].entry&&this[Yt].entry.resume()}[xs](t){t.piped=!0,t.readdir&&t.readdir.forEach(i=>{let o=t.path,c=o==="./"?"":o.replace(/\/*$/,"/");this[us](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={}){vs(this,t,e,r)}},Xa=class extends Is{sync=!0;constructor(t){super(t),this[hs]=om}pause(){}resume(){}[Na](t){let e=this.follow?"statSync":"lstatSync";this[fs](t,ms[e](t.absolute))}[Ma](t){this[ls](t,ms.readdirSync(t.absolute))}[xs](t){let e=t.entry,r=this.zip;if(t.readdir&&t.readdir.forEach(i=>{let o=t.path,c=o==="./"?"":o.replace(/\/*$/,"/");this[us](c+i)}),!e)throw new Error("Cannot pipe without source");r?e.on("data",i=>{r.write(i)}):e.on("data",i=>{super[yf](i)})}},xm=(t,e)=>{let r=new Xa(t),i=new af(t.file,{mode:t.mode||438});r.pipe(i),Ef(r,e)},hm=(t,e)=>{let r=new Is(t),i=new Es(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 bf(r,e).catch(c=>r.emit("error",c)),o},Ef=(t,e)=>{e.forEach(r=>{r.charAt(0)==="@"?dr({file:cf.resolve(t.cwd,r.slice(1)),sync:!0,noResume:!0,onReadEntry:i=>t.add(i)}):t.add(r)}),t.end()},bf=async(t,e)=>{for(let r of e)r.charAt(0)==="@"?await dr({file:cf.resolve(String(t.cwd),r.slice(1)),noResume:!0,onReadEntry:i=>{t.add(i)}}):t.add(r);t.end()},pm=(t,e)=>{let r=new Xa(t);return Ef(r,e),r},gm=(t,e)=>{let r=new Is(t);return bf(r,e).catch(i=>r.emit("error",i)),r},gv=oi(xm,hm,pm,gm,(t,e)=>{if(!e?.length)throw new TypeError("no paths specified to add to archive")}),wm=process.env.__FAKE_PLATFORM__||process.platform,Af=wm==="win32",{O_CREAT:Tf,O_NOFOLLOW:$d,O_TRUNC:Cf,O_WRONLY:Rf}=If.constants,Df=Number(process.env.__FAKE_FS_O_FILENAME__)||If.constants.UV_FS_O_FILEMAP||0,_m=Af&&!!Df,ym=512*1024,Em=Df|Cf|Tf|Rf,Jd=!Af&&typeof $d=="number"?$d|Cf|Tf|Rf:null,kf=Jd!==null?()=>Jd:_m?t=>t<ym?Em:"w":()=>"w",Ba=(t,e,r)=>{try{return As.lchownSync(t,e,r)}catch(i){if(i?.code!=="ENOENT")throw i}},_s=(t,e,r,i)=>{As.lchown(t,e,r,o=>{i(o&&o?.code!=="ENOENT"?o:null)})},bm=(t,e,r,i,o)=>{if(e.isDirectory())Of(Qr.resolve(t,e.name),r,i,c=>{if(c)return o(c);let f=Qr.resolve(t,e.name);_s(f,r,i,o)});else{let c=Qr.resolve(t,e.name);_s(c,r,i,o)}},Of=(t,e,r,i)=>{As.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 _s(t,e,r,i);let f=c.length,u=null,x=p=>{if(!u){if(p)return i(u=p);if(--f===0)return _s(t,e,r,i)}};for(let p of c)bm(t,p,e,r,x)})},vm=(t,e,r,i)=>{e.isDirectory()&&Pf(Qr.resolve(t,e.name),r,i),Ba(Qr.resolve(t,e.name),r,i)},Pf=(t,e,r)=>{let i;try{i=As.readdirSync(t,{withFileTypes:!0})}catch(o){let c=o;if(c?.code==="ENOENT")return;if(c?.code==="ENOTDIR"||c?.code==="ENOTSUP")return Ba(t,e,r);throw c}for(let o of i)vm(t,o,e,r);return Ba(t,e,r)},Lf=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"}},Ts=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"}},Im=(t,e)=>{Ve.stat(t,(r,i)=>{(r||!i.isDirectory())&&(r=new Lf(t,r?.code||"ENOTDIR")),e(r)})},Am=(t,e,r)=>{t=V(t);let i=e.umask??18,o=e.mode|448,c=(o&i)!==0,f=e.uid,u=e.gid,x=typeof f=="number"&&typeof u=="number"&&(f!==e.processUid||u!==e.processGid),p=e.preserve,_=e.unlink,y=V(e.cwd),A=(v,S)=>{v?r(v):S&&x?Of(S,f,u,I=>A(I)):c?Ve.chmod(t,o,r):r()};if(t===y)return Im(t,A);if(p)return Sm.mkdir(t,{mode:o,recursive:!0}).then(v=>A(null,v??void 0),A);let E=V(ys.relative(y,t)).split("/");za(y,E,o,_,y,void 0,A)},za=(t,e,r,i,o,c,f)=>{if(e.length===0)return f(null,c);let u=e.shift(),x=V(ys.resolve(t+"/"+u));Ve.mkdir(x,r,Nf(x,e,r,i,o,c,f))},Nf=(t,e,r,i,o,c,f)=>u=>{u?Ve.lstat(t,(x,p)=>{if(x)x.path=x.path&&V(x.path),f(x);else if(p.isDirectory())za(t,e,r,i,o,c,f);else if(i)Ve.unlink(t,_=>{if(_)return f(_);Ve.mkdir(t,r,Nf(t,e,r,i,o,c,f))});else{if(p.isSymbolicLink())return f(new Ts(t,t+"/"+e.join("/")));f(u)}}):(c=c||t,za(t,e,r,i,o,c,f))},Tm=t=>{let e=!1,r;try{e=Ve.statSync(t).isDirectory()}catch(i){r=i?.code}finally{if(!e)throw new Lf(t,r??"ENOTDIR")}},Cm=(t,e)=>{t=V(t);let r=e.umask??18,i=e.mode|448,o=(i&r)!==0,c=e.uid,f=e.gid,u=typeof c=="number"&&typeof f=="number"&&(c!==e.processUid||f!==e.processGid),x=e.preserve,p=e.unlink,_=V(e.cwd),y=v=>{v&&u&&Pf(v,c,f),o&&Ve.chmodSync(t,i)};if(t===_)return Tm(_),y();if(x)return y(Ve.mkdirSync(t,{mode:i,recursive:!0})??void 0);let A=V(ys.relative(_,t)).split("/"),E;for(let v=A.shift(),S=_;v&&(S+="/"+v);v=A.shift()){S=V(ys.resolve(S));try{Ve.mkdirSync(S,i),E=E||S}catch{let I=Ve.lstatSync(S);if(I.isDirectory())continue;if(p){Ve.unlinkSync(S),Ve.mkdirSync(S,i),E=E||S;continue}else if(I.isSymbolicLink())return new Ts(S,S+"/"+A.join("/"))}}return y(E)},_a=Object.create(null),Zd=1e4,er=new Set,Rm=t=>{er.has(t)?er.delete(t):_a[t]=t.normalize("NFD").toLocaleLowerCase("en").toLocaleUpperCase("en"),er.add(t);let e=_a[t],r=er.size-Zd;if(r>Zd/10){for(let i of er)if(er.delete(i),delete _a[i],--r<=0)break}return e},Dm=process.env.TESTING_TAR_FAKE_PLATFORM||process.platform,km=Dm==="win32",Om=t=>t.split("/").slice(0,-1).reduce((e,r)=>{let i=e.at(-1);return i!==void 0&&(r=Mf(i,r)),e.push(r||"/"),e},[]),Pm=class{#e=new Map;#n=new Map;#r=new Set;reserve(t,e){t=km?["win32 parallelization disabled"]:t.map(i=>Xr(Mf(Rm(i))));let r=new Set(t.map(i=>Om(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 u=f[1];if(!u){this.#e.delete(c);continue}if(f.shift(),typeof u=="function")o.add(u);else for(let x of u)o.add(x)}for(let c of i){let f=this.#e.get(c),u=f?.[0];if(!(!f||!(u instanceof Set)))if(u.size===1&&f.length===1){this.#e.delete(c);continue}else if(u.size===1){f.shift();let x=f[0];typeof x=="function"&&o.add(x)}else u.delete(t)}return this.#r.delete(t),o.forEach(c=>this.#i(c)),!0}},Lm=()=>process.umask(),Vd=Symbol("onEntry"),Fa=Symbol("checkFs"),Yd=Symbol("checkFs2"),Ua=Symbol("isReusable"),et=Symbol("makeFs"),Ha=Symbol("file"),qa=Symbol("directory"),ps=Symbol("link"),Xd=Symbol("symlink"),Qd=Symbol("hardlink"),Vr=Symbol("ensureNoSymlink"),ef=Symbol("unsupported"),tf=Symbol("checkPath"),ya=Symbol("stripAbsolutePath"),nn=Symbol("mkdir"),ke=Symbol("onError"),is=Symbol("pending"),nf=Symbol("pend"),tr=Symbol("unpend"),Ea=Symbol("ended"),ba=Symbol("maybeClose"),Ga=Symbol("skip"),ei=Symbol("doChown"),ti=Symbol("uid"),ni=Symbol("gid"),ri=Symbol("checkedCwd"),Nm=process.env.TESTING_TAR_FAKE_PLATFORM||process.platform,ii=Nm==="win32",Mm=1024,Bm=(t,e)=>{if(!ii)return X.unlink(t,e);let r=t+".DELETE."+Sf(16).toString("hex");X.rename(t,r,i=>{if(i)return e(i);X.unlink(r,e)})},zm=t=>{if(!ii)return X.unlinkSync(t);let e=t+".DELETE."+Sf(16).toString("hex");X.renameSync(t,e),X.unlinkSync(e)},rf=(t,e,r)=>t!==void 0&&t===t>>>0?t:e!==void 0&&e===e>>>0?e:r,Qa=class extends si{[Ea]=!1;[ri]=!1;[is]=0;reservations=new Pm;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[Ea]=!0,this[ba]()},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:Mm,this.forceChown=t.forceChown===!0,this.win32=!!t.win32||ii,this.newer=!!t.newer,this.keep=!!t.keep,this.noMtime=!!t.noMtime,this.preservePaths=!!t.preservePaths,this.unlink=!!t.unlink,this.cwd=V(Se.resolve(t.cwd||process.cwd())),this.strip=Number(t.strip)||0,this.processUmask=this.chmod?typeof t.processUmask=="number"?t.processUmask:Lm():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[Vd](e))}warn(t,e,r={}){return(t==="TAR_BAD_ARCHIVE"||t==="TAR_ABORT")&&(r.recoverable=!1),super.warn(t,e,r)}[ba](){this[Ea]&&this[is]===0&&(this.emit("prefinish"),this.emit("finish"),this.emit("end"))}[ya](t,e){let r=t[e],{type:i}=t;if(!r||this.preservePaths)return!0;let[o,c]=Za(r),f=c.replaceAll(/\\/g,"/").split("/");if(f.includes("..")||ii&&/^[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 u=Se.posix.dirname(t.path),x=Se.posix.normalize(Se.posix.join(u,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}[tf](t){let e=V(t.path),r=e.split("/");if(this.strip){if(r.length<this.strip)return!1;if(t.type==="Link"){let i=V(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[ya](t,"path")||!this[ya](t,"linkpath"))return!1;if(t.absolute=Se.isAbsolute(t.path)?V(Se.resolve(t.path)):V(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:V(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}=Se.win32.parse(String(t.absolute));t.absolute=i+Bd(String(t.absolute).slice(i.length));let{root:o}=Se.win32.parse(t.path);t.path=o+Bd(t.path.slice(o.length))}return!0}[Vd](t){if(!this[tf](t))return t.resume();switch(mm.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[Fa](t);default:return this[ef](t)}}[ke](t,e){t.name==="CwdError"?this.emit("error",t):(this.warn("TAR_ENTRY_ERROR",t,{entry:e}),this[tr](),e.resume())}[nn](t,e,r){Am(V(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)}[ei](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}[ti](t){return rf(this.uid,t.uid,this.processUid)}[ni](t){return rf(this.gid,t.gid,this.processGid)}[Ha](t,e){let r=typeof t.mode=="number"?t.mode&4095:this.fmode,i=new Es(String(t.absolute),{flags:kf(t.size),mode:r,autoClose:!1});i.on("error",u=>{i.fd&&X.close(i.fd,()=>{}),i.write=()=>!0,this[ke](u,t),e()});let o=1,c=u=>{if(u){i.fd&&X.close(i.fd,()=>{}),this[ke](u,t),e();return}--o===0&&i.fd!==void 0&&X.close(i.fd,x=>{x?this[ke](x,t):this[tr](),e()})};i.on("finish",()=>{let u=String(t.absolute),x=i.fd;if(typeof x=="number"&&t.mtime&&!this.noMtime){o++;let p=t.atime||new Date,_=t.mtime;X.futimes(x,p,_,y=>y?X.utimes(u,p,_,A=>c(A&&y)):c())}if(typeof x=="number"&&this[ei](t)){o++;let p=this[ti](t),_=this[ni](t);typeof p=="number"&&typeof _=="number"&&X.fchown(x,p,_,y=>y?X.chown(u,p,_,A=>c(A&&y)):c())}c()});let f=this.transform&&this.transform(t)||t;f!==t&&(f.on("error",u=>{this[ke](u,t),e()}),t.pipe(f)),f.pipe(i)}[qa](t,e){let r=typeof t.mode=="number"?t.mode&4095:this.dmode;this[nn](String(t.absolute),r,i=>{if(i){this[ke](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[ei](t)&&(o++,X.chown(String(t.absolute),Number(this[ti](t)),Number(this[ni](t)),c)),c()})}[ef](t){t.unsupported=!0,this.warn("TAR_ENTRY_UNSUPPORTED",`unsupported entry type: ${t.type}`,{entry:t}),t.resume()}[Xd](t,e){let r=V(Se.relative(this.cwd,Se.resolve(Se.dirname(String(t.absolute)),String(t.linkpath)))).split("/");this[Vr](t,this.cwd,r,()=>this[ps](t,String(t.linkpath),"symlink",e),i=>{this[ke](i,t),e()})}[Qd](t,e){let r=V(Se.resolve(this.cwd,String(t.linkpath))),i=V(String(t.linkpath)).split("/");this[Vr](t,this.cwd,i,()=>this[ps](t,r,"link",e),o=>{this[ke](o,t),e()})}[Vr](t,e,r,i,o){let c=r.shift();if(this.preservePaths||c===void 0)return i();let f=Se.resolve(e,c);X.lstat(f,(u,x)=>{if(u)return i();if(x?.isSymbolicLink())return o(new Ts(f,Se.resolve(f,r.join("/"))));this[Vr](t,f,r,i,o)})}[nf](){this[is]++}[tr](){this[is]--,this[ba]()}[Ga](t){this[tr](),t.resume()}[Ua](t,e){return t.type==="File"&&!this.unlink&&e.isFile()&&e.nlink<=1&&!ii}[Fa](t){this[nf]();let e=[t.path];t.linkpath&&e.push(t.linkpath),this.reservations.reserve(e,r=>this[Yd](t,r))}[Yd](t,e){let r=f=>{e(f)},i=()=>{this[nn](this.cwd,this.dmode,f=>{if(f){this[ke](f,t),r();return}this[ri]=!0,o()})},o=()=>{if(t.absolute!==this.cwd){let f=V(Se.dirname(String(t.absolute)));if(f!==this.cwd)return this[nn](f,this.dmode,u=>{if(u){this[ke](u,t),r();return}c()})}c()},c=()=>{X.lstat(String(t.absolute),(f,u)=>{if(u&&(this.keep||this.newer&&u.mtime>(t.mtime??u.mtime))){this[Ga](t),r();return}if(f||this[Ua](t,u))return this[et](null,t,r);if(u.isDirectory()){if(t.type==="Directory"){let x=this.chmod&&t.mode&&(u.mode&4095)!==t.mode,p=_=>this[et](_??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[et](x??null,t,r))}if(t.absolute===this.cwd)return this[et](null,t,r);Bm(String(t.absolute),x=>this[et](x??null,t,r))})};this[ri]?o():i()}[et](t,e,r){if(t){this[ke](t,e),r();return}switch(e.type){case"File":case"OldFile":case"ContiguousFile":return this[Ha](e,r);case"Link":return this[Qd](e,r);case"SymbolicLink":return this[Xd](e,r);case"Directory":case"GNUDumpDir":return this[qa](e,r)}}[ps](t,e,r,i){X[r](e,String(t.absolute),o=>{o?this[ke](o,t):(this[tr](),t.resume()),i()})}},Jr=t=>{try{return[null,t()]}catch(e){return[e,null]}},Bf=class extends Qa{sync=!0;[et](t,e){return super[et](t,e,()=>{})}[Fa](t){if(!this[ri]){let o=this[nn](this.cwd,this.dmode);if(o)return this[ke](o,t);this[ri]=!0}if(t.absolute!==this.cwd){let o=V(Se.dirname(String(t.absolute)));if(o!==this.cwd){let c=this[nn](o,this.dmode);if(c)return this[ke](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[Ga](t);if(e||this[Ua](t,r))return this[et](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[et](f,t)}let[o]=Jr(()=>X.rmdirSync(String(t.absolute)));this[et](o,t)}let[i]=t.absolute===this.cwd?[]:Jr(()=>zm(String(t.absolute)));this[et](i,t)}[Ha](t,e){let r=typeof t.mode=="number"?t.mode&4095:this.fmode,i=f=>{let u;try{X.closeSync(o)}catch(x){u=x}(f||u)&&this[ke](f||u,t),e()},o;try{o=X.openSync(String(t.absolute),kf(t.size),r)}catch(f){return i(f)}let c=this.transform&&this.transform(t)||t;c!==t&&(c.on("error",f=>this[ke](f,t)),t.pipe(c)),c.on("data",f=>{try{X.writeSync(o,f,0,f.length)}catch(u){i(u)}}),c.on("end",()=>{let f=null;if(t.mtime&&!this.noMtime){let u=t.atime||new Date,x=t.mtime;try{X.futimesSync(o,u,x)}catch(p){try{X.utimesSync(String(t.absolute),u,x)}catch{f=p}}}if(this[ei](t)){let u=this[ti](t),x=this[ni](t);try{X.fchownSync(o,Number(u),Number(x))}catch(p){try{X.chownSync(String(t.absolute),Number(u),Number(x))}catch{f=f||p}}}i(f)})}[qa](t,e){let r=typeof t.mode=="number"?t.mode&4095:this.dmode,i=this[nn](String(t.absolute),r);if(i){this[ke](i,t),e();return}if(t.mtime&&!this.noMtime)try{X.utimesSync(String(t.absolute),t.atime||new Date,t.mtime)}catch{}if(this[ei](t))try{X.chownSync(String(t.absolute),Number(this[ti](t)),Number(this[ni](t)))}catch{}e(),t.resume()}[nn](t,e){try{return Cm(V(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}}[Vr](t,e,r,i,o){if(this.preservePaths||r.length===0)return i();let c=e;for(let f of r){c=Se.resolve(c,f);let[u,x]=Jr(()=>X.lstatSync(c));if(u)return i();if(x.isSymbolicLink())return o(new Ts(c,Se.resolve(e,r.join("/"))))}i()}[ps](t,e,r,i){let o=`${r}Sync`;try{X[o](e,String(t.absolute)),i(),t.resume()}catch(c){return this[ke](c,t)}}},Fm=t=>{let e=new Bf(t),r=t.file,i=vf.statSync(r),o=t.maxReadSize||16*1024*1024;new sg(r,{readSize:o,size:i.size}).pipe(e)},Um=(t,e)=>{let r=new Qa(t),i=t.maxReadSize||16*1024*1024,o=t.file;return new Promise((c,f)=>{r.on("error",f),r.on("close",c),vf.stat(o,(u,x)=>{if(u)f(u);else{let p=new Ka(o,{readSize:i,size:x.size});p.on("error",f),p.pipe(r)}})})},zf=oi(Fm,Um,t=>new Bf(t),t=>new Qa(t),(t,e)=>{e?.length&&gf(t,e)}),Hm=(t,e)=>{let r=new Xa(t),i=!0,o,c;try{try{o=Ze.openSync(t.file,"r+")}catch(x){if(x?.code==="ENOENT")o=Ze.openSync(t.file,"w+");else throw x}let f=Ze.fstatSync(o),u=Buffer.alloc(512);e:for(c=0;c<f.size;c+=512){for(let _=0,y=0;_<512;_+=y){if(y=Ze.readSync(o,u,_,u.length-_,c+_),c===0&&u[0]===31&&u[1]===139)throw new Error("cannot append to compressed archives");if(!y)break e}let x=new Rn(u);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,qm(t,r,c,o,e)}finally{if(i)try{Ze.closeSync(o)}catch{}}},qm=(t,e,r,i,o)=>{let c=new af(t.file,{fd:i,start:r});e.pipe(c),jm(e,o)},Gm=(t,e)=>{e=Array.from(e);let r=new Is(t),i=(o,c,f)=>{let u=(A,E)=>{A?Ze.close(o,v=>f(A)):f(null,E)},x=0;if(c===0)return u(null,0);let p=0,_=Buffer.alloc(512),y=(A,E)=>{if(A||E===void 0)return u(A);if(p+=E,p<512&&E)return Ze.read(o,_,p,_.length-p,x+p,y);if(x===0&&_[0]===31&&_[1]===139)return u(new Error("cannot append to compressed archives"));if(p<512)return u(null,x);let v=new Rn(_);if(!v.cksumValid)return u(null,x);let S=512*Math.ceil((v.size??0)/512);if(x+S+512>c||(x+=S+512,x>=c))return u(null,x);t.mtimeCache&&v.mtime&&t.mtimeCache.set(String(v.path),v.mtime),p=0,Ze.read(o,_,0,512,x,y)};Ze.read(o,_,0,512,x,y)};return new Promise((o,c)=>{r.on("error",c);let f="r+",u=(x,p)=>{if(x&&x.code==="ENOENT"&&f==="r+")return f="w+",Ze.open(t.file,f,u);if(x||!p)return c(x);Ze.fstat(p,(_,y)=>{if(_)return Ze.close(p,()=>c(_));i(p,y.size,(A,E)=>{if(A)return c(A);let v=new Es(t.file,{fd:p,start:E});r.pipe(v),v.on("error",c),v.on("close",o),Km(r,e)})})};Ze.open(t.file,f,u)})},jm=(t,e)=>{e.forEach(r=>{r.charAt(0)==="@"?dr({file:Ff.resolve(t.cwd,r.slice(1)),sync:!0,noResume:!0,onReadEntry:i=>t.add(i)}):t.add(r)}),t.end()},Km=async(t,e)=>{for(let r of e)r.charAt(0)==="@"?await dr({file:Ff.resolve(String(t.cwd),r.slice(1)),noResume:!0,onReadEntry:i=>t.add(i)}):t.add(r);t.end()},Zr=oi(Hm,Gm,()=>{throw new TypeError("file is required")},()=>{throw new TypeError("file is required")},(t,e)=>{if(!xg(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=oi(Zr.syncFile,Zr.asyncFile,Zr.syncNoFile,Zr.asyncNoFile,(t,e=[])=>{Zr.validate?.(t,e),Wm(t)}),Wm=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))};Kt();var yt={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 ai(t){return t?.cozeDeployType==="cloud"?"cloud":"local"}function Uf(t){let e=t?.cozeAccountId?.trim();if(!(!e||e==="0"))return e}function Hf(t){let e=t?.cozeGroupId?.trim();if(!(!e||e==="0"))return e}function qf(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}var R=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)}};ee();Be();function Nt(t,e){if(ai(t)!=="cloud")throw new R("OPERATION_NOT_ALLOWED_FOR_LOCAL",`${e} is not allowed for local agent`)}function Cs(t){return t.startsWith("http://")||t.startsWith("https://")}function Rs(t){return t.endsWith("/")?t.slice(0,-1):t}ee();var Ds="1008033",Gf="1289";var jf="pbbp2",Kf="https://www.coze.cn",Wf="/api/coze_claw/resource/get_frontier_key",Jm="https://www.coze.cn",Zm="wss://frontier.coze.cn";function ks(t){return t??process.env.COZE_BRIDGE_HANDSHAKE_URL??Jm}function $f(t){return t??process.env.COZE_BRIDGE_FRONTIER_URL??Zm}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 di(t){return t?t.startsWith("boe_")?{ttEnv:t}:{ttEnv:t,usePpe:"1"}:{}}var ci=G("handshake");async function ec(t){let e=ks(t.endpoint),r=t.timeoutMs??1e4,i=`${Rs(e)}${Wf}?aid=${encodeURIComponent(Ds)}`,o={Authorization:`Bearer ${t.privatecode}`,Accept:"application/json",...ur(t.ppeOverride)},c=new AbortController,f=setTimeout(()=>c.abort(),r);ci.info("frontier key handshake",{base:e});try{let u=await fetch(i,{method:"GET",headers:o,signal:c.signal}),x=u.headers.get("x-tt-logid")??"",p=u.headers.get("x-tt-trace-id")??"";if(!u.ok){let v=await u.text().catch(()=>"");throw new R("UPSTREAM_HANDSHAKE_FAILED",`handshake HTTP ${u.status} logid=${x}: ${v.slice(0,200)}`)}let _=await u.json();if(_.code!==void 0&&_.code!==0)throw new R("UPSTREAM_HANDSHAKE_FAILED",`handshake code=${_.code} msg=${_.msg??"-"} logid=${x}`);let y=_.data??{},A=typeof y.access_key=="string"&&y.access_key||typeof y.accessKey=="string"&&y.accessKey||void 0,E=typeof y.device_id=="string"&&y.device_id||typeof y.deviceId=="string"&&y.deviceId||void 0;if(!A||!E){let v=JSON.stringify(_).slice(0,500);throw new R("UPSTREAM_HANDSHAKE_FAILED",`handshake response missing access_key/device_id (also tried camelCase) logid=${x}: ${v}`)}return ci.info("handshake ok",{remoteDeviceId:E,logid:x,traceId:p}),{accessKey:A,deviceId:E}}catch(u){if(u instanceof R)throw ci.error("handshake failed (bridge error)",{base:e,message:u.message,code:u.code}),u;if(u.name==="AbortError")throw ci.warn("handshake timeout",{base:e,timeoutMs:r}),new R("UPSTREAM_HANDSHAKE_FAILED",`handshake timeout (${r}ms)`,{cause:u});let x=u.cause;throw ci.error("handshake error",{base:e,message:u instanceof Error?u.message:String(u),errno:x?.code,syscall:x?.syscall,cause:String(u).slice(0,300)}),new R("UPSTREAM_HANDSHAKE_FAILED",String(u),{cause:u})}finally{clearTimeout(f)}}var tc=process.env.COZE_BRIDGE_LLM_GATEWAY_URL?.trim()||"https://llm-gateway.coze.cn",Et="auto";function Jf(t){return{model:t.model??Et,...t.modelToken?{modelToken:t.modelToken}:{}}}function Zf(t){return!t||t===Et}function Vf(t){let e={};return t.modelToken?(e.ANTHROPIC_BASE_URL=tc,e.ANTHROPIC_AUTH_TOKEN=t.modelToken,e.ANTHROPIC_MODEL=t.model||Et,t.modelInfo?.contextWindow&&(e.CLAUDE_CODE_MAX_CONTEXT_TOKENS=String(t.modelInfo.contextWindow))):Zf(t.model)||(e.ANTHROPIC_MODEL=t.model),e}function Yf(t){let e=[];return t.modelToken?e.push("-c",`model="${t.model||Et}"`):Zf(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="${tc}/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 Xf(t){return t.modelToken?{OPENAI_API_KEY:t.modelToken}:{}}function nc(t,e){let{ttEnv:r,usePpe:i}=di(t),o={};return r&&(o["x-tt-env"]=r),i&&(o["x-use-ppe"]=i),e&&(o["x-mock-scenario"]=e),o}function Qf(t,e,r){if(!t.modelToken)return{};let i=nc(e,r);return Object.keys(i).length===0?{}:{ANTHROPIC_CUSTOM_HEADERS:Object.entries(i).map(([c,f])=>`${c}:${f}`).join(`
119
+ `)}}function rc(t){return`coze-session-${t.replace(/[^A-Za-z0-9_-]+/g,"-")}`}function eu(t,e,r){if(!t.modelToken)return null;let i=t.model||Et,o=nc(e,r),c=["text"];t.modelInfo?.capabilities?.image===!0&&c.push("image");let f={baseUrl:`${tc}/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 tu(t,e,r){if(!t.modelToken)return[];let i=nc(e,r),o=[];for(let[c,f]of Object.entries(i))o.push("-c",`model_providers.coze.http_headers.${c}="${f}"`);return o}var Oe=G("agent-handlers"),nu=5*1024*1024,tw=1,nw=6,rw=new Set(["node_modules",".git",".coze","dist","build",".next"]),Os=class{constructor(e){this.opts=e}opts;async listSkills(e){Nt(e._meta,"_agent/listSkills");let r=fr(e._meta),i=await this.loadAgentCfg(r),o=i?.workspace??Ct(r).workspace,c=i?.skills??[],f=[];for(let u of c){let x=bt(o,u.relPath,"SKILL.md");await Xm(x).then(_=>_.isFile()).catch(()=>!1)&&f.push(cw(u))}return{skills:f}}async addSkills(e){Nt(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])),u=[];for(let x of o){let p=await fc({agentId:r,workspace:i.workspace,framework:i.framework,skill:x});uc(c,f,p),u.push(x)}return await Bi(r,c),this.reloadAgentSessions(r,"skills-added"),{installedSkills:u}}async removeSkills(e){Nt(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 u of c){if(!o.has(u.skillId)){f.push(u);continue}let x=bt(i.workspace,u.relPath);await Ym(x,{recursive:!0,force:!0}),Oe.info("skill removed",{agentId:r,skillId:u.skillId,relPath:u.relPath})}return await Bi(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,Oe.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,Oe.info("killing downstream for workspace reload (idle)",{reason:r,agentId:e,framework:i.framework,cloudId:o,acpId:f}),x.stop(r).catch(p=>Oe.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 Oe.info("_agent/update: empty cozeIdentity, noop",{agentId:e.agentId}),{ok:!0};let r=e.agentId,i=await Ue(r);if(!i)throw new R("AGENT_NOT_FOUND",`agent not found: ${r}`);if(i.cozeIdentity===e.cozeIdentity)return Oe.info("_agent/update: cozeIdentity unchanged, noop",{agentId:r}),{ok:!0};try{await $n(i.workspace,i.framework,r,e.cozeIdentity)}catch(o){throw Oe.error("_agent/update: writeInstructionFile failed, aborting update",{agentId:r,framework:i.framework,workspace:i.workspace,err:String(o)}),new R("AGENT_PROTOCOL_ERROR",`failed to write instruction file for agent ${r}: ${String(o)}`,{cause:o})}return i.cozeIdentity=e.cozeIdentity,await We(i),Oe.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 R("IPC_BAD_REQUEST","_agent/disconnect: missing agentId");let i=await Ue(r);return i?(i.disconnectedAt=Date.now(),i.disconnectReason=e.reason??"",await We(i),Oe.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}):(Oe.warn("_agent/disconnect: agent not found, ignoring",{agentId:r}),{ok:!0})}async switchModel(e){if(Nt(e._meta,"_agent/switchModel"),!e.agentId)throw new R("IPC_BAD_REQUEST","_agent/switchModel: missing agentId");let r=e.model?.trim()?e.model:Et,i=await Ue(e.agentId);if(!i)throw new R("AGENT_NOT_FOUND",`agent not found: ${e.agentId}`);i.model=r,e.modelInfo&&(i.modelInfo=e.modelInfo),await We(i),Oe.info("_agent/switchModel: model persisted",{agentId:e.agentId,model:r,reason:e.reason??""});let o=this.opts.agents.get(e.agentId);if(!o)return Oe.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=>Oe.warn("cleanupOpenclawProviders before switchModel failed (ignored)",{agentId:e.agentId,err:String(f)}));let c=[];for(let[f,u]of o.allSessionQueues())c.push(u.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),Oe.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(Nt(e._meta,yt.RESET),!e.agentId)throw new R("IPC_BAD_REQUEST",`${yt.RESET}: missing agentId`);return await this.runDetailSync(e.agentId,yt.RESET,e.reason),{ok:!0}}async repairAgent(e){if(Nt(e._meta,yt.REPAIR),!e.agentId)throw new R("IPC_BAD_REQUEST",`${yt.REPAIR}: missing agentId`);let r=await this.loadAgentCfg(e.agentId);if(r&&r.framework!=="openclaw")throw new R("IPC_BAD_REQUEST",`${yt.REPAIR} only allowed for openclaw, got ${r.framework}`);if(r&&this.opts.openclawRepair)try{await this.opts.openclawRepair(e.agentId,r.workspace)}catch(i){Oe.warn("openclaw repair (delete+add) failed (ignored)",{agentId:e.agentId,reason:e.reason,err:String(i)})}return await this.runDetailSync(e.agentId,yt.REPAIR,e.reason),{ok:!0}}async runDetailSync(e,r,i){if(!this.opts.detailSyncer){Oe.warn("detailSyncer not wired, skipping sync",{method:r,agentId:e});return}try{await this.opts.detailSyncer(e)}catch(o){Oe.warn("detail sync failed (ignored)",{method:r,agentId:e,reason:i,err:String(o)})}}async getFileTree(e){Nt(e._meta,"_agent/getFileTree");let r=e._meta,i=fr(r),o=await this.resolveWorkspace(i),c=e.filePath??"",f=this.safeJoin(o,c),u=await ic(f).catch(()=>null);if(!u)throw new R("IPC_BAD_REQUEST",`path not found: ${c}`);if(u.isSymbolicLink())throw new R("IPC_BAD_REQUEST",`symlink not allowed: ${c}`);if(!await Lr(f,o))throw new R("IPC_BAD_REQUEST",`path escapes workspace: ${c}`);let x=_w(e.depth);return u.isDirectory()?{tree:await ww(o,f,c,x)}:{tree:[{name:yw(c),path:du(c||"."),isDir:!1,size:u.size,modifiedAt:Math.floor(u.mtimeMs)}]}}async getFileContent(e){Nt(e._meta,"_agent/getFileContent");let r=fr(e._meta),i=await this.resolveWorkspace(r);if(!e.filePath)throw new R("IPC_BAD_REQUEST","filePath required");let o=this.safeJoin(i,e.filePath),c=await ic(o).catch(()=>null);if(!c||!c.isFile())throw new R("IPC_BAD_REQUEST",`not a file: ${e.filePath}`);if(c.isSymbolicLink())throw new R("IPC_BAD_REQUEST",`symlink not allowed: ${e.filePath}`);if(!await Lr(o,i))throw new R("IPC_BAD_REQUEST",`path escapes workspace: ${e.filePath}`);if(c.size>nu)throw new R("IPC_BAD_REQUEST",`file too large: ${c.size} bytes (max ${nu})`);let f=await ru(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??Ct(e).workspace}safeJoin(e,r){let i=ac(e,r||"."),o=dc(e,i);if(o.startsWith("..")||o===".."||o.startsWith(`..${iu}`))throw new R("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 R("AGENT_NOT_FOUND",`no config for agent: ${e}`);return r}};function iw(t){let e=t.trim().replace(/[\x00-\x1f<>:"|?*/\\]+/g,"-").replace(/^[\s.-]+|[\s.-]+$/g,"").slice(0,64);if(!e||e==="."||e==="..")throw new R("IPC_BAD_REQUEST",`invalid skill name: ${t}`);if(/^(con|prn|aux|nul|com[1-9]|lpt[1-9])$/i.test(e))throw new R("IPC_BAD_REQUEST",`reserved windows filename: ${t}`);return e}function sw(t){return t==="claude-code"?bt(".claude","skills"):bt(".agents","skills")}var ow=3e4,aw=50*1024*1024,lr=3e4;async function fc(t){let{agentId:e,workspace:r,framework:i,skill:o}=t;if(!o.skillName)throw new R("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 R("IPC_BAD_REQUEST",`skill ${o.skillId} missing both content and downloadUrl`);let u=iw(o.skillName),x=sw(i),p=bt(x,u),_=bt(r,p);if(await sc(_,{recursive:!0}),c){let A=Buffer.from(o.content,"utf8");fi(A.length),await oc(bt(_,"SKILL.md"),A,"utf8")}else{let A=await dw(o.downloadUrl);uw(A)?await pw(A,_):lw(A)?await xw(A,_):await oc(bt(_,"SKILL.md"),A.toString("utf8"),"utf8")}let y={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 Oe.info("skill installed",{agentId:e,skillId:o.skillId,skillName:o.skillName,relPath:p,source:c?"content":"downloadUrl"}),y}function uc(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 cw(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 dw(t){if(!t)throw new R("IPC_BAD_REQUEST","skill missing downloadUrl");if(t.startsWith("data:")){let e=Math.floor(t.length*3/4);fi(e);let r=fw(t);return fi(r.length),r}if(t.startsWith("file:")){let e=new URL(t).pathname,r=await ru(e);return fi(r.length),r}if(Cs(t)){let e=new AbortController,r=setTimeout(()=>e.abort(),ow);try{let i=await fetch(t,{signal:e.signal});if(!i.ok)throw new R("IPC_BAD_REQUEST",`fetch skill failed HTTP ${i.status} ${t}`);let o=await i.arrayBuffer();return fi(o.byteLength),Buffer.from(o)}finally{clearTimeout(r)}}throw new R("IPC_BAD_REQUEST",`unsupported downloadUrl scheme (\u8981 https/data/file): ${t.slice(0,80)}`)}function fi(t){if(t>aw)throw new R("IPC_BAD_REQUEST",`skill too large: ${t} bytes`)}function fw(t){let e=/^data:([^,;]*)(;base64)?,(.*)$/s.exec(t);if(!e)throw new R("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 uw(t){return t.length>=2&&t[0]===31&&t[1]===139}function lw(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 cc(t){return t==="__MACOSX"||t.startsWith("__MACOSX/")}async function xw(t,e){let r,i;try{r=new au.default(t),i=r.getEntries()}catch(f){throw new R("IPC_BAD_REQUEST",`zip parse failed: ${f.message}`,{cause:f})}for(let f of i){let u=f.entryName;if(!u||cc(u))continue;if(u.startsWith("/")||/^[A-Za-z]:[\\/]/.test(u))throw new R("IPC_BAD_REQUEST",`zip entry absolute path: ${u}`);if(u.split(/[/\\]/).some(p=>p===".."))throw new R("IPC_BAD_REQUEST",`zip entry contains '..' (traversal): ${u}`);let x=f.header.attr>>>16&61440;if(x!==0&&x!==32768&&x!==16384)throw new R("IPC_BAD_REQUEST",`zip entry kind 0x${x.toString(16)} not allowed (symlink/hardlink/special): ${u}`)}let o=hw(i),c=ac(e);for(let f of i){if(cc(f.entryName))continue;let u=f.entryName;if(o&&u.startsWith(o)&&(u=u.slice(o.length)),!u)continue;let x=ac(e,u),p=dc(c,x);if(p.startsWith("..")||p==="..")throw new R("IPC_BAD_REQUEST",`zip entry escapes destDir: ${u}`);if(f.isDirectory){await sc(x,{recursive:!0});continue}await sc(Qm(x),{recursive:!0});let _;try{_=f.getData()}catch(y){throw new R("IPC_BAD_REQUEST",`zip entry getData failed (${f.entryName}): ${y.message}`,{cause:y})}await oc(x,_)}}function hw(t){let e;for(let r of t){let i=r.entryName;if(!i||cc(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 pw(t,e){await gw(t);let r=zf({cwd:e,strip:1}),i=!1,o=setTimeout(()=>{i=!0,r.destroy(new R("IPC_BAD_REQUEST",`tar extract timeout (${lr}ms)`))},lr);try{await ou(su.from(t),r)}catch(c){throw c instanceof R?c:i?new R("IPC_BAD_REQUEST",`tar extract timeout (${lr}ms)`):new R("IPC_BAD_REQUEST",`tar extract failed: ${c.message??String(c)}`,{cause:c})}finally{clearTimeout(o)}}async function gw(t){let e=[],r=dr({onReadEntry:c=>{let f=c.path,u=c.type;if(u!=="File"&&u!=="Directory"){e.push(`tar entry kind '${u}' 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 R("IPC_BAD_REQUEST",`tar list timeout (${lr}ms)`))},lr);try{await ou(su.from(t),r)}catch(c){throw i?new R("IPC_BAD_REQUEST",`tar list timeout (${lr}ms)`):new R("IPC_BAD_REQUEST",`tar list failed: ${c.message??String(c)}`,{cause:c})}finally{clearTimeout(o)}if(e.length>0)throw new R("IPC_BAD_REQUEST",e[0]??"tar entry validation failed")}var mw=5e3;async function ww(t,e,r,i){return cu(t,e,r,i,{count:0})}async function cu(t,e,r,i,o){if(i<=0)return[];let c;try{c=await Vm(e,{withFileTypes:!0})}catch{return[]}let f=[];for(let u of c){if(rw.has(u.name)||u.isSymbolicLink())continue;if(o.count>=mw){f.push({name:"...",path:"...",isDir:!1,size:0,modifiedAt:0,hasMore:!0});break}let x=bt(e,u.name),p=ew(bt(r,u.name)),_=null;try{_=await ic(x)}catch{continue}if(_.isSymbolicLink())continue;o.count++;let y={name:u.name,path:du(dc(t,x)),isDir:_.isDirectory(),size:_.size,modifiedAt:Math.floor(_.mtimeMs)};_.isDirectory()&&i>1&&(y.children=await cu(t,x,p,i-1,o)),f.push(y)}return f.sort((u,x)=>u.isDir!==x.isDir?u.isDir?-1:1:u.name.localeCompare(x.name)),f}function _w(t){return!t||t<=0?tw:Math.min(t,nw)}function yw(t){if(!t||t==="."||t==="/")return".";let e=t.split(/[/\\]/);return e[e.length-1]||"."}function du(t){return t.split(iu).join("/")}ee();import{readFileSync as qS}from"node:fs";import{dirname as jS,join as KS}from"node:path";import{fileURLToPath as $S}from"node:url";var xr="0.1.76";var on=G("agent-health-reporter"),Ew=1e4,ui=class{constructor(e){this.opts=e;this.intervalMs=e.intervalMs??Ew}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()}),on.info("heartbeat started",{intervalMs:this.intervalMs}),this.tick())}stop(){this.timer&&(clearInterval(this.timer),this.timer=null,this.unsubscribeRegister&&(this.unsubscribeRegister(),this.unsubscribeRegister=null),on.info("heartbeat stopped"))}async tick(){if(this.inFlight){on.debug("previous tick still in-flight, skip");return}let e=this.opts.getDeviceId();if(!e){on.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 u=bw(f);if(!u)continue;let x={agentId:f.agentId,status:u};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){on.warn("heartbeat batch send failed",{count:r.length,err:String(f)})}let c=o?.authFailures;if(c&&c.length>0&&(on.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){on.warn("onAuthFailures callback failed (ignored)",{err:String(f)})}}finally{this.inFlight=!1}if(this.opts.onTickEnd)try{await this.opts.onTickEnd()}catch(r){on.warn("onTickEnd hook failed",{err:String(r)})}}};function bw(t){return t.status==="error"?"error":t.activeTriggers.size>0?"busy":t.status==="ok"?"online":null}Kt();import{mkdir as hc,rm as t_}from"node:fs/promises";gn();gn();import{spawnSync as Dw}from"node:child_process";function li(t,e,r){return r===void 0?{jsonrpc:"2.0",id:t,method:e}:{jsonrpc:"2.0",id:t,method:e,params:r}}function xi(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 an(t,e){return{jsonrpc:"2.0",id:t,error:e}}var Ps=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 fu(t){return"method"in t&&"id"in t&&t.id!==void 0}function uu(t){return"method"in t&&!("id"in t)}function Ls(t){return!("method"in t)&&"id"in t}var vw={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 Sw(t){if(t!=null)return t instanceof Error?{name:t.name,message:hi(t.message)}:typeof t=="string"?hi(t):typeof t=="object"?Aw(t):t}var Iw=[[/\/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 hi(t){let e=t;for(let[r,i]of Iw)e=e.replace(r,i);return e}function Aw(t){let e={};for(let[r,i]of Object.entries(t))typeof i=="string"?e[r]=hi(i):e[r]=i;return e}function pi(t){if(t instanceof R){let e=Sw(t.cause),r={bridgeCode:t.code,retriable:t.retriable};return e!==void 0&&(r.cause=e),{code:vw[t.code]??Q.INTERNAL_ERROR,message:hi(t.message),data:r}}return{code:Q.INTERNAL_ERROR,message:hi(t instanceof Error?t.message:String(t))}}function lu(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,...u}=e;c=u}return new R(r,o,{retriable:e?.retriable??!1,cause:c})}function hu(t){return`${JSON.stringify(t)}
120
+ `}var xu=10*1024*1024,Ns=class{buffer="";onError;constructor(e={}){this.onError=e.onError}push(e){if(this.buffer+=typeof e=="string"?e:e.toString("utf8"),this.buffer.length>xu){let o=this.buffer.length;return this.buffer="",this.onError?.({line:`<buffer overflow: ${o} bytes, dropped>`,error:new Error(`LdjsonDecoder buffer exceeded ${xu} bytes`)}),[]}let r=this.buffer.split(`
121
+ `);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 gu={"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"},i2=Object.fromEntries(Object.entries(gu).map(([t,e])=>[e,t])),Tw={"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=gu[e]??Cw(e),o=Tw[i]??[],c=[i,String(this.seq)];if(o.length>0){let f=o.map(x=>pu(r?.[x]??"")),u=Rw(f).join(":");u&&c.push(u)}else r&&Object.values(r).some(f=>f)&&c.push(Object.values(r).filter(Boolean).map(f=>pu(String(f))).join(":"));return c.join("_")}reset(){this.seq=0}};function Cw(t){return t.replace(/[\s/]+/g,".").replace(/_+/g,"-")}function pu(t){return t.replace(/[:_\s]+/g,"-")}function Rw(t){let e=t.length;for(;e>0&&!t[e-1];)e-=1;return t.slice(0,e)}jn();function cn(t,e){let r=process.env[t];if(!r)return e;let i=Number(r);return Number.isFinite(i)&&i>0?i:e}ee();var kw=cn("COZE_BRIDGE_INITIALIZE_TIMEOUT_MS",3e4),Ow=200,Pw=/(ENOTEMPTY|EEXIST).*_npx[/\\]/;function lc(t){return t.some(e=>Pw.test(e))}var Lw=cn("COZE_BRIDGE_SESSION_PROMPT_MAX_MS",3600*1e3),Nw=cn("COZE_BRIDGE_SESSION_PROMPT_FRAME_IDLE_MS",600*1e3),mu=500;function Mw(t){try{let e=JSON.stringify(t);return e===void 0||e.length<=mu?t:`${e.slice(0,mu)}...<truncated, total ${e.length} chars>`}catch{return"<unserializable>"}}function wu(t,e){if(!(typeof t!="number"||t<=0))try{if(process.platform==="win32"){let r=["/PID",String(t),"/T"];e==="SIGKILL"&&r.push("/F"),Dw("taskkill",r,{stdio:"ignore",windowsHide:!0})}else process.kill(-t,e)}catch{}}var vt=class{constructor(e){this.opts=e;this.log=G(`downstream.${this.constructor.name}`),this.decoder=new Ns({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 R("BRIDGE_INTERNAL","Downstream already started");let e=process.platform!=="win32",r=qn(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>Ow&&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]}),(this.framework==="claude-code"||this.framework==="codex")&&lc(this.stderrRing)&&(this.log.warn("npx cache corruption detected, triggering global install fallback (D93)",{framework:this.framework}),hn(this.framework).catch(u=>{this.log.warn("D93 fallback install failed (will retry next spawn cycle)",{framework:this.framework,err:String(u)})})));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 R("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 R("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()));wu(r.pid,"SIGTERM");let o=setTimeout(()=>{r.killed||wu(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=Lw,i=Nw){return this.call("session/prompt",e,r,i)}async sessionCancel(e){!this.child||this.stopped||this.writeFrame(xi("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(an(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=kw,o=0){if(!this.child||this.stopped)return Promise.reject(new R("AGENT_PROTOCOL_ERROR","downstream not started"));let c=this.idAllocator.next(e),f=li(c,e,r),u=(()=>{if(typeof r!="object"||r===null)return;let _=r.sessionId;return typeof _=="string"?_:void 0})(),x=i>0&&Number.isFinite(i),p=o>0&&Number.isFinite(o);return new Promise((_,y)=>{let A={resolve:_,reject:y,timer:null,frameIdleTimer:null,armFrameIdle:null,method:e};x&&(A.timer=setTimeout(()=>{this.pending.delete(c),A.frameIdleTimer&&clearTimeout(A.frameIdleTimer),this.log.warn("downstream call timeout",{id:c,method:e,timeoutMs:i,...u?{sessionId:u}:{}}),y(new R("AGENT_TIMEOUT",`${e} timed out after ${i}ms`))},i));let E=p?()=>{A.frameIdleTimer&&clearTimeout(A.frameIdleTimer),A.frameIdleTimer=setTimeout(()=>{if(this.inflightAgentRequests.size>0){this.log.debug("frame-idle fired but agent request inflight, re-arming",{id:c,method:e,inflight:this.inflightAgentRequests.size,...u?{sessionId:u}:{}}),E?.();return}A.timer&&clearTimeout(A.timer),this.pending.delete(c),this.log.warn("frame-idle timeout, rejecting pending call",{id:c,method:e,frameIdleMs:o,...u?{sessionId:u}:{}}),y(new R("AGENT_FRAME_IDLE_TIMEOUT",`${e} no session/update for ${o}ms (no inflight agent request)`))},o)}:null;A.armFrameIdle=E,this.pending.set(c,A),E?.();try{this.writeFrame(f)}catch(v){A.timer&&clearTimeout(A.timer),A.frameIdleTimer&&clearTimeout(A.frameIdleTimer),this.pending.delete(c),y(v)}})}writeFrame(e){if(!this.child?.stdin||this.child.stdin.destroyed)throw new R("AGENT_PROTOCOL_ERROR","downstream stdin not writable");this.child.stdin.write(hu(e),r=>{r&&this.log.warn("stdin write callback err",{err:String(r)})})}dispatch(e){if(Ls(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(lu(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 R("AGENT_PROTOCOL_ERROR",`${r.method} response missing both result and error`))):(this.log.info("downstream returned result",{id:e.id,method:r.method,result:Mw(e.result)}),r.resolve(e.result));return}if(uu(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(fu(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(an(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(an(e.id,pi(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()}};var Bw=Pr("claude-code")??"@agentclientprotocol/claude-agent-acp@^0.37";function zw(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 Ms=class extends vt{framework="claude-code";constructor(e){let r=pn("claude-code"),[i,o]=r?[r,[]]:["npx",["-y",Bw]],c=e.command??i,f=e.args??o,u={command:c,args:f,cwd:e.cwd,...e.env?{env:e.env}:{}};super(u)}sanitizeEnv(e){return zw(e)}};gn();import{mkdtempSync as Fw,rmSync as Uw}from"node:fs";import{tmpdir as Hw}from"node:os";import{join as qw}from"node:path";var Gw=Pr("codex")??"@zed-industries/codex-acp@^0.15",Bs=class extends vt{framework="codex";authMethodId;codexHomeDir;constructor(e){let r=pn("codex"),[i,o]=r?[r,[]]:["npx",["-y",Gw]],c=e.command??i,f=e.args??o,u=e.extraArgs?[...f,...e.extraArgs]:f,x=e.isolateCodexHome?Fw(qw(Hw(),"coze-bridge-codex-home-")):void 0,p=x?{...e.env??{},CODEX_HOME:x}:e.env,_={command:c,args:u,cwd:e.cwd,...p?{env:p}:{}};super(_),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{Uw(this.codexHomeDir,{recursive:!0,force:!0})}catch{}}};var jw=3e4,gr=class extends vt{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}`}]},jw))}get acpSessionName(){return this.sessionName}};ee();Be();function xc(t){return t.replace(/[^A-Za-z0-9._-]+/g,"-")}gn();var mr=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 zs=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 mr,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)gi(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 gi(t){t.idleTimer&&(clearTimeout(t.idleTimer),t.idleTimer=void 0)}jn();ee();import{constants as _u,access as Kw}from"node:fs/promises";import{delimiter as Ww,join as $w}from"node:path";var dn=G("framework-detector"),yu={"claude-code":"claude",codex:"codex",openclaw:"openclaw"},Jw=[".exe",".cmd",".bat",".ps1"],fn=class{env;constructor(e={}){this.env={pathEnv:e.pathEnv??process.env.PATH??"",platform:e.platform??process.platform,spawn:e.spawn??qn,access:e.access??Kw}}async detect(e){let r=yu[e],i=await this.which(r);if(!i)return dn.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)]),u={path:i,version:c};return f&&(u.defaultAgent=f),u}async detectAll(){let e=await Promise.all(Object.keys(yu).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(Ww).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"?_u.F_OK:_u.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 dn.warn("openclaw default agent probe: runProbe returned null (spawn err / timeout)",{path:e}),null;if(r.code!==0)return dn.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 dn.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 dn.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?(dn.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}:(dn.info("openclaw default agent probe: no agent has isDefault=true",{path:e,agentCount:o.length}),null)}catch(o){return dn.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&&(Vw(i.stdout).split(/\r?\n/)[0]??"").trim()||"unknown"}runProbe(e,r){return new Promise(i=>{let o="",c=!1,f,u=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"),u(null)},15e3),x.stdout?.on("data",p=>{o+=p.toString("utf8")}),x.on("error",()=>u(null)),x.on("close",p=>u({code:p,stdout:o}))}catch{u(null)}})}},Zw=new RegExp("\x1B\\[[0-9;]*[A-Za-z]","g");function Vw(t){return t.replace(Zw,"")}import{spawn as Yw}from"node:child_process";import{homedir as Xw}from"node:os";import{join as Qw}from"node:path";Ni();ee();async function vu(){let t=Qw(Xw(),".openclaw/openclaw.json");return(await Wn(t))?.gateway?.auth?.token??""}var Eu=G("openclaw.config"),e_=[0,5e3,5e3],bu="models.providers.",Fs="agents.defaults.models",Us=class{command;env;retryDelaysMs;queue=new mr;constructor(e){this.command=e.command,this.env=e.env??process.env,this.retryDelaysMs=e.retryDelaysMs??e_}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,Eu.warn("openclaw cli failed, will retry",{label:e,attempt:o+1,err:String(f)})}}throw new R("AGENT_SPAWN_FAILED",`openclaw cli ${e} failed after ${this.retryDelaysMs.length} attempts: ${i?.message??"unknown"}`)}runCli(e){return new Promise((r,i)=>{let o=Yw(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){Eu.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",`${bu}${e}`,JSON.stringify(r),"--strict-json","--merge"])))}removeProvider(e){return this.bestEffortUnset(`config unset models.providers.${e}`,`${bu}${e}`)}addModelToAllowlist(e,r){let i={[e]:r?{alias:r}:{}};return this.queue.enqueue(()=>this.withRetry(`config set ${Fs}[${e}]`,()=>this.runCli(["config","set",Fs,JSON.stringify(i),"--strict-json","--merge"])))}removeModelFromAllowlist(e){return this.bestEffortUnset(`config unset ${Fs}[${e}]`,`${Fs}.${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 Pe=G("agent-manager"),n_=(t,e,r,i,o,c,f,u,x)=>{switch(t){case"claude-code":{let p={...o?{...Vf(o),...Qf(o,f,u)}:{},...x??{},IS_SANDBOX:"1"};return new Ms({cwd:r,env:p})}case"codex":{let _=[...o?[...Yf(o),...tu(o,f,u)]:[],"-c",'sandbox_mode="danger-full-access"',"-c",'approval_policy="never"'],y={...o?Xf(o):{},...x??{}},A=!!o;return new Bs({cwd:r,..._.length>0?{extraArgs:_}:{},...Object.keys(y).length>0?{env:y}:{},...A?{authMethodId:"openai-api-key",isolateCodexHome:!0}:{}})}case"openclaw":return new gr({command:e,cwd:r,agentId:i,...c?{sessionName:xc(c)}:{}})}};function pc(t){return t==="claude-code"||t==="codex"}var r_={path:"",version:"cloud-deployed"},i_={protocolVersion:1,clientCapabilities:{fs:{readTextFile:!0,writeTextFile:!0}}},s_=6e4,o_=cn("COZE_BRIDGE_SPAWN_AWAIT_INSTALL_MS",25e3),Hs=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??n_,this.createTimeoutMs=e.createTimeoutMs??s_,this.spawnAwaitInstallMs=e.spawnAwaitInstallMs??o_,this.detectorFactory=e.detectorFactory??(()=>new fn)}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 R("AGENT_SPAWN_FAILED","openclaw binary not detected on this machine");this.openclawConfigCache=new Us({command:e.path})}return this.openclawConfigCache}async createAgent(e){if(!e.agentId)throw new R("IPC_BAD_REQUEST","agentId required");if(!e.framework)throw new R("IPC_BAD_REQUEST","framework required");let r=ai(e._meta)==="cloud";this.registry.reviveIfDisconnected?.(e.agentId);let i=this.registry.get(e.agentId);if(i){if(i.framework!==e.framework)throw new R("AGENT_BUSY",`agent ${e.agentId} exists with different framework (${i.framework})`);if(i.status==="error")Pe.warn("existing agent in error state, rebuilding",{agentId:e.agentId}),await i.dispose("rebuild after error").catch(v=>Pe.warn("dispose stale agent failed (ignored)",{err:String(v)})),this.registry.unregister(e.agentId);else{if(e.patToken&&e.patToken!==i.patToken){Pe.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 We(v,this.paths))}if(i.deployType==="cloud"&&e.modelInfo){Pe.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 We(v,this.paths))}return Pe.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 R("AGENT_SPAWN_FAILED",`framework ${e.framework} not detected on this machine; rerun daemon to refresh frameworks_cache`);let c=Ct(e.agentId,this.paths),f=ai(e._meta),u=e.framework==="openclaw"&&f==="local",x=u?this.config.frameworksCache?.openclaw?.defaultAgent?.workspace:void 0,p=e.workspace??x??c.workspace,_=new AbortController,y=setTimeout(()=>_.abort(new R("AGENT_TIMEOUT",`_agent/create timed out after ${this.createTimeoutMs}ms`)),this.createTimeoutMs),A,E=!1;try{r&&pc(e.framework)&&await hn(e.framework,_.signal);let v=()=>{if(_.signal.aborted)throw _.signal.reason instanceof Error?_.signal.reason:new R("AGENT_TIMEOUT","_agent/create aborted")};await hc(c.root,{recursive:!0}),await hc(p,{recursive:!0}),await hc(c.logs,{recursive:!0}),v(),u||await $n(p,e.framework,e.agentId,e.cozeIdentity),e.framework==="claude-code"&&await j0(p),v();let S=await Ue(e.agentId,this.paths).catch(()=>null),I=Jf({model:e.model??S?.model}),D=Uf(e._meta)??S?.accountId,P=e.patToken??S?.patToken,w=f==="cloud"?e.modelInfo??S?.modelInfo:void 0;if(A=new zs({agentId:e.agentId,framework:e.framework,workspace:p,model:I.model??Et,deployType:f,...D?{accountId:D}:{},...P?{patToken:P}:{},...w?{modelInfo:w}:{}}),A.status="ok",S?.sessions){for(let[B,k]of Object.entries(S.sessions))A.sessions.set(B,{acpSessionId:k.acpSessionId,modelToken:k.modelToken,tokenGeneratedAt:k.tokenGeneratedAt,lastActiveAt:Date.now(),loadingSession:!1,replySeq:0});let z=Object.keys(S.sessions).length;z>0&&Pe.info("restored persisted session records (no spawn)",{agentId:e.agentId,count:z})}this.registry.register(A),E=!0;let C={agentId:e.agentId,framework:e.framework,workspace:p,cozeIdentity:e.cozeIdentity,createdAt:S?.createdAt??Date.now(),sessions:S?.sessions??{},model:I.model};f==="cloud"&&(C.deployType="cloud"),D&&(C.accountId=D),P&&(C.patToken=P),w&&(C.modelInfo=w),S?.skills&&(C.skills=S.skills),S?.agentName&&(C.agentName=S.agentName),S?.description&&(C.description=S.description),e.framework==="openclaw"&&f==="cloud"&&(this.config.frameworksCache?.openclaw?.path?await this.getOpenclawConfig().ensureAgent(e.agentId,p):Pe.warn("openclaw binary not on this machine, skip agents add (will fail at session/prompt)",{agentId:e.agentId}));let O=e.initialSkills??[];if(O.length>0){let z=[...C.skills??[]],B=new Map(z.map((F,K)=>[F.skillId,K])),k=await Promise.allSettled(O.map(F=>fc({agentId:e.agentId,workspace:p,framework:e.framework,skill:F}))),N=0;for(let[F,K]of k.entries()){let se=O[F];se&&(K.status==="fulfilled"?(uc(z,B,K.value),N++):Pe.warn("initialSkill install failed (skipping)",{agentId:e.agentId,skillId:se.skillId,skillName:se.skillName,err:String(K.reason)}))}N>0&&(C.skills=z,Pe.info("initialSkills installed",{agentId:e.agentId,installed:N,requested:O.length}))}return await We(C,this.paths),Pe.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 Pe.error("agent create failed, rolling back",{agentId:e.agentId,err:String(v)}),E&&A&&(await A.dispose("rollback").catch(()=>{}),this.registry.unregister(e.agentId)),await t_(c.root,{recursive:!0,force:!0}).catch(S=>Pe.warn("rm agent dir failed (ignored)",{err:String(S)})),v instanceof R?v:new R("AGENT_SPAWN_FAILED",String(v),{cause:v})}finally{clearTimeout(y)}}async spawnSessionDownstream(e,r,i,o,c){let u=this.config.frameworksCache?.[e.framework];if(!u)if(e.deployType==="cloud"&&pc(e.framework))u=r_;else throw new R("AGENT_SPAWN_FAILED",`framework ${e.framework} not detected on this machine`);if(pc(e.framework)&&!pn(e.framework)){let _=Go(e.framework);_&&(Pe.info("spawn: awaiting in-flight acp install (D92)",{agentId:e.agentId,framework:e.framework}),await Promise.race([_.catch(()=>{}),new Promise(y=>setTimeout(y,this.spawnAwaitInstallMs))]))}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:u.path}):p=this.factory(e.framework,u.path,e.workspace,e.agentId,x,i,o,c,this.buildBinShimPathEnv());try{return await p.start(),await p.initialize(i_),p}catch(_){let y=p instanceof vt?p.getStderrTail():[];y.length>0&&Pe.warn("spawnSessionDownstream failed, recent stderr (D94)",{agentId:e.agentId,framework:e.framework,method:_ instanceof R?_.code:"unknown",recentStderr:y});let A=lc(y);await p.stop("spawnSessionDownstream failed").catch(()=>{});let E=A?new R("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:_}):_;throw _ instanceof R?new R(_.code,_.message,{retriable:_.retriable,cause:E}):new R("AGENT_SPAWN_FAILED",_ instanceof Error?_.message:String(_),{cause:E})}}async buildOpenclawDownstream(e){let{session:r,modelConfig:i,cloudSessionId:o,cozeEnv:c,mockScenario:f,command:u}=e,x=xc(o);if(r.deployType==="local"){let A=this.config.frameworksCache?.openclaw?.defaultAgent;if(!A?.id||!A.workspace){Pe.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)Pe.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,A=v.defaultAgent;else throw new R("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 gr({command:u,cwd:A.workspace,agentId:A.id,sessionName:x})}let p=await vu(),_=i?eu(i,c,f):null,y;if(_){let A=rc(o),v=_.models[0]?.id??Et,S=`${A}/${v}`;if(!this.ensuredProviders.has(S)){let I=this.getOpenclawConfig();await I.ensureProvider(A,_),await I.addModelToAllowlist(S),this.ensuredProviders.add(S)}y=S}return new gr({command:u,cwd:r.workspace,agentId:r.agentId,sessionName:x,...p?{gatewayToken:p}:{},...y?{slashModelOnStart:y}:{}})}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=rc(i),c=`${o}/${e.model}`,f=!0;try{await r.removeProvider(o)}catch(u){f=!1,Pe.warn("removeProvider failed, keeping ensuredProviders entry",{providerId:o,err:String(u)})}try{await r.removeModelFromAllowlist(c)}catch(u){f=!1,Pe.warn("removeModelFromAllowlist failed, keeping ensuredProviders entry",{fullModelId:c,err:String(u)})}f&&this.ensuredProviders.delete(c)}}};import{randomUUID as Cu}from"node:crypto";import{promises as m_}from"node:fs";import{basename as Ru}from"node:path";import{promises as c_}from"node:fs";import{basename as d_}from"node:path";ee();var Su=G("file-upload"),f_="/api/coze_claw/file/agent_upload",u_=6e4;async function Iu(t,e={}){let i=`${Rs(ks(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 u={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);Su.info("file upload start",{url:i,agentId:t.agentId,sessionId:t.sessionId,name:t.name,bytes:t.sizeBytes,mime:t.mimeType});try{let _=await fetch(i,{method:"POST",headers:u,body:f,signal:x.signal}),y=_.headers.get("x-tt-logid")??"";if(!_.ok){let v=await _.text().catch(()=>"");throw new R("UPLOAD_FAILED",`upload HTTP ${_.status} logid=${y}: ${v.slice(0,200)}`)}let A=await _.json();if(A.code!==void 0&&A.code!==0)throw new R("UPLOAD_FAILED",`upload code=${A.code} msg=${A.msg??"-"} logid=${y}`);let E=A.data?.file?.file_url;if(!E)throw new R("UPLOAD_FAILED",`upload response missing data.file.file_url logid=${y}: ${JSON.stringify(A).slice(0,200)}`);return Su.info("file upload ok",{uri:E,logid:y}),{uri:E}}catch(_){throw _ instanceof R?_:_.name==="AbortError"?new R("UPLOAD_FAILED",`upload timeout (${o}ms) for ${d_(t.path)}`):new R("UPLOAD_FAILED",String(_),{cause:_})}finally{clearTimeout(p)}}ee();import{promises as l_}from"node:fs";import{extname as x_}from"node:path";var h_=[{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 p_(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 g_={".txt":"text/plain",".md":"text/markdown",".svg":"image/svg+xml",".json":"application/json"};async function Au(t){let e=await l_.open(t,"r");try{let r=Buffer.alloc(16);if(await e.read(r,0,16,0),p_(r))return"image/webp";for(let i of h_)if(i.prefix.every((o,c)=>r[c]===o))return i.mime}finally{await e.close()}return g_[x_(t).toLowerCase()]??"application/octet-stream"}Be();var qs=G("agent-send"),Tu=50*1024*1024,w_=new Set(["image/png","image/jpeg","image/webp","image/gif","image/svg+xml","application/pdf","application/json","text/plain","text/markdown"]);function Du(t,e,r){let i=t.get(e);if(!i)throw new R("AGENT_NOT_FOUND",`agent=${e}`);if(t.disconnectedAgents.has(e))throw new R("AGENT_DISCONNECTED",`agent=${e} was disconnected by cloud`);let o=i.sessions.get(r);if(!o)throw new R("AGENT_NOT_FOUND",`session=${r} not active in agent=${e}`);return{session:i,runtime:o}}async function ku(t,e,r,i,o,c){let u;for(let x=0;x<=2;x++)try{await t.core.sendAgentFileUpdate(e,r,i,o);return}catch(p){u=p,x<2&&(qs.warn("sendAgentFileUpdate failed, retrying",{attempt:x+1,err:String(p)}),await new Promise(_=>setTimeout(_,5e3)))}throw new R("UPSTREAM_NOT_READY",`${c} after 3 attempts: ${String(u)}`,{cause:u})}async function Ou(t,e){let{session:r,runtime:i}=Du(e.core,t.agentId,t.sessionId);if(!await Lr(t.path,r.workspace))throw new R("PATH_OUTSIDE_WORKSPACE",`path=${t.path} not under workspace=${r.workspace}`);let o=await m_.stat(t.path).catch(()=>null);if(!o||!o.isFile())throw new R("IPC_BAD_REQUEST",`path is not a regular file: ${t.path}`);if(o.size>Tu)throw new R("FILE_TOO_LARGE",`${o.size} bytes > limit ${Tu}`);let c=await Au(t.path);if(!w_.has(c))throw new R("UNSUPPORTED_MIME",`mime=${c} not in whitelist`);if(t.kind==="image"&&!c.startsWith("image/"))throw new R("UNSUPPORTED_MIME",`kind=image but mime=${c}`);if(!e.core.upstream.isConnected())throw new R("UPSTREAM_NOT_READY","cloud WS not connected");let f=t.name??Ru(t.path),u;try{u=await Iu({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 qs.warn("agent file upload failed",{agentId:t.agentId,sessionId:t.sessionId,path:t.path,sizeBytes:o.size,mime:c,code:p instanceof R?p.code:"UNKNOWN",message:p instanceof Error?p.message:String(p)}),p}let x={sessionUpdate:"agent_file",messageId:Cu(),content:{type:t.kind==="image"?"image":"resource",uri:u.uri,mimeType:c,name:f,sizeBytes:o.size,...u.fileId!==void 0?{fileId:u.fileId}:{},...t.caption!==void 0?{caption:t.caption}:{}}};return await ku(e,r,i,t.sessionId,x,"agent file uploaded to cloud but sendAgentFileUpdate failed"),qs.info("agent file sent",{agentId:t.agentId,sessionId:t.sessionId,kind:t.kind,name:f,bytes:o.size,mime:c,uri:u.uri}),{ok:!0,uri:u.uri,bytes:o.size,mimeType:c,...u.fileId!==void 0?{fileId:u.fileId}:{}}}async function Pu(t,e){let{session:r,runtime:i}=Du(e.core,t.agentId,t.sessionId);if(!t.mimeType)throw new R("IPC_BAD_REQUEST","group-file requires mimeType");if(!e.core.upstream.isConnected())throw new R("UPSTREAM_NOT_READY","cloud WS not connected");let o=t.name??Ru(t.path),c={sessionUpdate:"group_file",messageId:Cu(),content:{uri:t.path,name:o,mimeType:t.mimeType,...t.caption!==void 0?{caption:t.caption}:{}}};return await ku(e,r,i,t.sessionId,c,"agent group file sendAgentFileUpdate failed"),qs.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 Lu(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,u=i[c]??0;if(f<u)return!0;if(f>u)return!1}return!1}jn();ee();var St=G("coze-cli-installer"),Nu="@coze/cli@latest",__="coze",Mu="0.1.7",y_=5e3,E_=5e3,b_=9e4,Bu=1e4,mi=null,Gs=!1;async function gc(t,e={}){if(Gs)return;if(mi)return mi;let r=e.exec??Gn;return mi=(async()=>{try{let i=await v_(__,r),o=!1;if(i){let f=await S_(r);if(f===void 0)St.warn("coze-cli found but version unparseable, fall through to full install",{path:i});else if(Lu(f,Mu))St.info("coze-cli version too old, upgrade-only (preserve user config + auth)",{path:i,version:f,min:Mu}),o=!0;else{St.info("coze-cli already on PATH with sufficient version, skip",{path:i,version:f}),Gs=!0;return}}let c=o?"upgrade-only":"full";St.info("coze-cli install start",{package:Nu,mode:c});try{await r("npm",["i","-g","--prefer-online",Nu],{timeout:b_,maxBuffer:10*1024*1024}),St.info("coze-cli install ok")}catch(f){St.warn("coze-cli install failed (skip subsequent steps)",{err:String(f)});return}if(o){Gs=!0;return}if(t.env)try{await r("coze",["config","set","xTTEnv",t.env],{timeout:Bu}),St.info("coze config set xTTEnv ok",{env:t.env})}catch(f){St.warn("coze config set failed (continue to auth login)",{err:String(f)})}try{await r("coze",["auth","login","--token",t.patToken],{timeout:Bu}),St.info("coze auth login ok")}catch(f){St.warn("coze auth login failed",{err:String(f)});return}Gs=!0}finally{mi=null}})(),mi}async function v_(t,e){let r=process.platform==="win32"?"where":"which";try{let{stdout:i}=await e(r,[t],{timeout:y_});return i.split(`
122
+ `)[0]?.trim()||void 0}catch{return}}async function S_(t){try{let{stdout:e,stderr:r}=await t("coze",["--version"],{timeout:E_});return(e||r).match(/(\d+\.\d+\.\d+)/)?.[1]}catch{return}}Ni();Be();var I_=10*6e4;function zu(t){let e=t?.sessionIdleTimeoutMs;return typeof e!="number"||!Number.isFinite(e)||e<=0?I_:e}function js(t){return Wn(t??te().configFile)}function wr(t,e){return Li(e??te().configFile,t)}import{randomBytes as G_}from"node:crypto";import{createReadStream as A_}from"node:fs";import{mkdir as T_,readFile as C_,realpath as R_,stat as D_,writeFile as k_}from"node:fs/promises";import{basename as O_,dirname as mc,join as P_,relative as L_,resolve as Fu,sep as N_}from"node:path";import{createInterface as M_}from"node:readline";ee();var Hu=G("fs-rpc"),wi=cn("COZE_BRIDGE_FS_RPC_MAX_BYTES",20*1024*1024);async function qu(t,e){let r=Buffer.byteLength(t.content,"utf8");if(r>wi)throw new R("IPC_BAD_REQUEST",`fs/write_text_file content too large: ${r} bytes > limit ${wi} bytes`);let i=await ju(t.path,e);return await T_(mc(i),{recursive:!0}),await k_(i,t.content,"utf8"),Hu.info("fs/write_text_file ok",{path:i,size:t.content.length}),null}async function Gu(t,e){let r=await ju(t.path,e),i=await D_(r),o=typeof t.line=="number"||typeof t.limit=="number";if(i.size>wi&&!o)throw new R("IPC_BAD_REQUEST",`fs/read_text_file too large without line/limit slicing: ${i.size} bytes > ${wi} bytes`);let c;if(o&&i.size>wi)c=await B_(r,t.line??1,t.limit);else{let f=await C_(r,"utf8");if(o){let u=f.split(`
123
+ `),x=Math.max(0,(t.line??1)-1),p=typeof t.limit=="number"?x+t.limit:void 0;c=u.slice(x,p).join(`
124
+ `)}else c=f}return Hu.info("fs/read_text_file ok",{path:r,size:c.length}),{content:c}}async function B_(t,e,r){let i=M_({input:A_(t,{encoding:"utf8"}),crlfDelay:Number.POSITIVE_INFINITY}),o=Math.max(0,e-1),c=typeof r=="number"?o+r:Number.POSITIVE_INFINITY,f=[],u=0;try{for await(let x of i)if(u>=o&&u<c&&f.push(x),u++,u>=c)break}finally{i.close()}return f.join(`
125
+ `)}async function ju(t,e){if(typeof t!="string"||t.length===0)throw new R("IPC_BAD_REQUEST","path must be a non-empty string");let[r,i]=await Promise.all([Uu(Fu(e)),Uu(Fu(t))]),o=L_(r,i);if(o.startsWith("..")||o===".."||o.startsWith(`..${N_}`))throw new R("IPC_BAD_REQUEST",`path escapes workspace: ${t}`);return i}async function Uu(t){let e=[],r=t;for(;r!==mc(r);)try{let i=await R_(r);return e.length?P_(i,...e.reverse()):i}catch{e.push(O_(r)),r=mc(r)}return t}ee();var Ku=G("prompt-multimodal"),Wu=10*1024*1024,z_=15e3,F_=6;async function $u(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 U_(f))}}let o=Array.from({length:Math.min(F_,t.length)},()=>i());return await Promise.all(o),e}function Ju(t){return t.some(e=>e.type==="image")}async function U_(t){if(t.type!=="image")return t;let e=t;if(e.data||!e.uri||!Cs(e.uri))return t;try{let{buf:r,contentType:i}=await q_(e.uri),o=e.mimeType||H_(i)||"application/octet-stream";return Ku.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 Ku.warn("image fetch failed, degrading to text block",{uri:e.uri,err:String(r)}),{type:"text",text:`[image load failed: ${e.uri}]`}}}function H_(t){if(!t)return;let e=t.indexOf(";");return(e===-1?t:t.slice(0,e)).trim()||void 0}async function q_(t){let e=new AbortController,r=setTimeout(()=>e.abort(),z_);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>Wu)throw new Error(`image too large: ${o.byteLength} bytes (max ${Wu})`);return{buf:Buffer.from(o),contentType:i.headers.get("content-type")??void 0}}finally{clearTimeout(r)}}Kt();ee();var Z=G("core"),j_=3e4,K_=/^(boe|ppe)_[A-Za-z0-9_-]+$/,W_=3e4,Ks=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=zu(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(),Z.info("Core started",{extensions:Object.keys(this.extensions)})}async stop(e){Z.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),Z.info("agent registered",{agentId:e.agentId,framework:e.framework});for(let r of this.registerHandlers)try{r(e.agentId)}catch(i){Z.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)&&Z.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)=>{Z.info("session runtime exited",{agentId:e.agentId,cloudId:r,code:c,signal:f}),gi(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){Z.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(an(o,{code:Q.INTERNAL_ERROR,message:`bridge downstream gone: ${r}`})).catch(f=>Z.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)){Z.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 R("UPSTREAM_DISCONNECTED",`${i.method} aborted: upstream reconnected`));this.pendingBridge.clear()}}async handleFrame(e){if(Ls(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&&K_.test(i)?this.currentCozeEnv=i:i&&Z.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}`):Z.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}`):Z.warn("drop unknown notification",{method:e.method})}catch(o){Z.error("handleFrame failed",{method:e.method,err:String(o)}),r!==null&&await this.upstream.send(an(r,pi(o)))}}async routeSessionMethod(e){if(!e.params||typeof e.params!="object")throw new R("IPC_BAD_REQUEST",`${e.method} requires params`);let r=e.params,i=r._meta?.cozeAgentId;if(!i)throw new R("IPC_BAD_REQUEST",`${e.method}: missing _meta.cozeAgentId`);let o=this.agents.get(i);if(!o)throw this.disconnectedAgents.has(i)?new R("AGENT_DISCONNECTED",`agent ${i} has been disconnected; cloud must _agent/create to revive`):new R("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(),u=!1;try{let x=await o.getSessionQueue(c).enqueue(()=>this.dispatchSessionCall(o,e.method,r));return u=!0,x}finally{Z.info("session call done",{agentId:o.agentId,method:e.method,durationMs:Date.now()-f,ok:u})}}async dispatchSessionCall(e,r,i){e.lastActiveAt=Date.now();let{stripped:o}=qf(i);switch(r){case"session/new":{let c=$_();return Z.info("session/new ack (lazy spawn)",{agentId:e.agentId,cloudId:c}),{sessionId:c}}case"session/load":{let c=o;return Z.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 R("IPC_BAD_REQUEST","session/prompt: missing sessionId");let u=await this.ensureRuntime(e,f);if(u.replySeq=0,await this.ensureDownstream(e,f,u),!u.downstream||!u.acpSessionId)throw new R("BRIDGE_INTERNAL","session runtime not ready after ensureDownstream");let x=i._meta?.cozeTriggerMsgId;x?e.activeTriggers.set(u.acpSessionId,x):e.activeTriggers.delete(u.acpSessionId);let p=Hf(i._meta);if(p?e.activeGroupIds.set(u.acpSessionId,p):e.activeGroupIds.delete(u.acpSessionId),e.deployType==="cloud"&&e.modelInfo?.capabilities?.image===!1&&Ju(c.prompt))throw new R("MODEL_MODALITY_UNSUPPORTED",`model=${e.modelInfo.id??e.model} does not support image input`);let _=await $u(c.prompt);try{let y=await u.downstream.sessionPrompt({...c,sessionId:u.acpSessionId,prompt:_});return u.lastActiveAt=Date.now(),y}finally{if(e.activeTriggers.delete(u.acpSessionId),e.activeGroupIds.delete(u.acpSessionId),u.reloadAfterTurn){u.reloadAfterTurn=!1;let y=u.downstream;y&&(u.downstream=void 0,Z.info("reloadAfterTurn: stopping downstream",{agentId:e.agentId,cloudId:f,acpId:u.acpSessionId}),y.stop("reload-after-turn").catch(A=>Z.warn("reload-after-turn stop failed (ignored)",{agentId:e.agentId,cloudId:f,err:String(A)})))}else u.downstream?.isAlive()&&this.armIdleTimer(e,f,u)}}case"session/cancel":{let f=o.sessionId;if(!f)throw new R("IPC_BAD_REQUEST","session/cancel: missing sessionId");let u=e.sessions.get(f);if(e.hasSessionQueue(f)){let x=e.getSessionQueue(f);x.size>0&&(Z.info("session/cancel: draining queued tasks",{agentId:e.agentId,cloudId:f,queuedCount:x.size}),x.dispose(new R("AGENT_PROTOCOL_ERROR",`cancelled by session/cancel on ${f}`)))}return u?.downstream?.isAlive()&&u.acpSessionId&&await u.downstream.sessionCancel({sessionId:u.acpSessionId}),{ok:!0}}default:throw new R("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(yt.GEN_MODEL_TOKEN,i,W_);if(!o?.modelToken)throw new R("MODEL_TOKEN_GEN_FAILED",`cloud returned empty modelToken (agentId=${e}, cloudSessionId=${r})`);return o.modelToken}catch(o){throw o instanceof R&&o.code==="MODEL_TOKEN_GEN_FAILED"?o:new R("MODEL_TOKEN_GEN_FAILED",o instanceof Error?o.message:String(o),{cause:o})}}async ensureDownstream(e,r,i){if(gi(i),i.downstream?.isAlive())return;if(!this.sessionSpawner)throw new R("AGENT_SPAWN_FAILED","sessionSpawner not wired (cannot spawn per-session downstream)");let o=3,c=3e4,f=i.spawnFailCount??0,u=i.spawnFailedAt??0;if(f>=o&&Date.now()-u<c)throw new R("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()-u))/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&&(Z.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}),Z.info("session restored via session/load",{agentId:e.agentId,cloudId:r,acpId:i.acpSessionId})}catch(p){Z.warn("session/load failed, fallback to session/new",{agentId:e.agentId,cloudId:r,acpId:i.acpSessionId,err:String(p)}),i.acpSessionId=void 0;let _=await x.sessionNew({cwd:e.workspace});i.acpSessionId=_.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(gi(i),this.isRuntimeBusy(e,i)){Z.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)){Z.info("idle reaper fired but runtime busy, re-arming",{agentId:e.agentId,cloudId:r}),this.armIdleTimer(e,r,i);return}Z.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=>Z.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 u=e.activeGroupIds.get(r.acpSessionId);u&&(c.cozeGroupId=u)}await this.upstream.send(xi("session/update",{sessionId:i,update:o,_meta:c}))}forwardUpdate(e,r){let i=r.sessionId,o=this.reverseSessionId(e,i);if(!o){Z.debug("drop update for unknown session",{agentId:e.agentId,acpId:i});return}let c=e.sessions.get(o);if(!c){Z.debug("drop update: runtime gone",{agentId:e.agentId,cloudId:o});return}if(Z_(r)){Z.debug("drop codex metadata-warn chunk",{agentId:e.agentId,acpId:i});return}let f={cozeAgentId:e.agentId,cozeReplySeqID:++c.replySeq},u=e.activeTriggers.get(i);u&&(f.cozeTriggerMsgId=u);let x=e.activeGroupIds.get(i);x&&(f.cozeGroupId=x),this.upstream.send(xi("session/update",{...r,sessionId:o,_meta:f})).catch(p=>Z.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}Z.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 qu(c,o);r.respondAgentRequest(i.id,f)}else{let c=i.params??{},f=await Gu(c,o);r.respondAgentRequest(i.id,f)}}catch(o){Z.warn("fs rpc handler failed",{agentId:e.agentId,method:i.method,err:String(o)}),r.respondAgentRequestError(i.id,pi(o))}}forwardPermissionRequest(e,r,i){let o=this.upstreamIds.next("session/request_permission"),c=i.params??{},u=c.sessionId,x=u?e.activeTriggers.get(u):void 0,p={cozeAgentId:e.agentId};x&&(p.cozeTriggerMsgId=x);let _=u?e.activeGroupIds.get(u):void 0;_&&(p.cozeGroupId=_);let y=u?this.reverseSessionId(e,u):void 0,A={...c,...y?{sessionId:y}:{},_meta:p};this.pendingUpstream.set(o,{agentRequestId:i.id,agentId:e.agentId,downstream:r,method:i.method}),Z.info("forward permission_request \u2192 upstream",{agentId:e.agentId,upstreamId:o,acpSessionId:u,cloudSessionId:y,toolCallId:c.toolCall?.toolCallId,options:c.options?.map(E=>({optionId:E.optionId,kind:E.kind,name:E.name}))}),this.upstream.send(li(o,"session/request_permission",A)).catch(E=>{this.pendingUpstream.delete(o),Z.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?(Z.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),Z.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 Ps(e.error)):i.value.resolve(e.result);return}Z.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 Z.warn(`${i} id type mismatch: number received but Bridge expected string`,{rawId:r,normalizedId:c}),{value:f,key:c}}}sendRequest(e,r,i=j_){let o=this.upstreamIds.next(e);return new Promise((c,f)=>{let u=setTimeout(()=>{this.pendingBridge.delete(o),f(new R("AGENT_TIMEOUT",`${e} timed out after ${i}ms`))},i);this.pendingBridge.set(o,{method:e,resolve:c,reject:f,timer:u}),this.upstream.send(li(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 jo(e.agentId,r,this.paths)}catch(r){Z.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(an(e,{code:r,message:i,data:{bridgeVersion:xr}}))}};function $_(){return G_(16).toString("hex")}function J_(t,e){if(!t||typeof t!="object"){Z.warn("permission response: result not an object (suspicious)",{agentId:e.agentId,result:t});return}let r=t;if("kind"in r&&!("outcome"in r)){Z.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"){Z.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")&&Z.warn("permission response: unknown outcome discriminant",{agentId:e.agentId,outcomeValue:c,result:t})}function Z_(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();Be();import{randomBytes as V_}from"node:crypto";import{chmod as Y_,mkdir as X_,writeFile as Zu}from"node:fs/promises";import{createServer as Q_}from"node:http";import{dirname as ey}from"node:path";var ty=1e6,wc=G("ipc"),Ws=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=V_(32).toString("hex");let e=Q_((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(),wc.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 X_(ey(this.paths.portFile),{recursive:!0}),await Zu(this.paths.portFile,String(this.port),"utf8"),await Zu(this.paths.tokenFile,this.token,{encoding:"utf8",mode:384});try{await Y_(this.paths.tokenFile,384)}catch(e){wc.warn("chmod token file failed (non-POSIX?)",{err:String(e)})}}async dispatch(e,r){if(e.headers.authorization!==`Bearer ${this.token}`){_i(r,401,{error:"unauthorized"});return}let o=`${e.method} ${(e.url??"").split("?")[0]}`,c=this.routes.get(o);if(!c){_i(r,404,{error:"not found"});return}let f=null;if(e.method==="POST")try{f=await ny(e)}catch(u){_i(r,400,{error:"invalid json",detail:String(u)});return}try{let u=await c.handler(f,e);_i(r,200,u??{ok:!0})}catch(u){wc.error("IPC handler failed",{key:o,err:String(u)}),_i(r,500,{error:u instanceof Error?u.message:String(u)})}}};function _i(t,e,r){t.statusCode=e,t.setHeader("content-type","application/json"),t.end(JSON.stringify(r))}async function ny(t){let e=[],r=0;for await(let o of t){let c=o;if(r+=c.length,r>ty)throw new Error("body too large");e.push(c)}let i=Buffer.concat(e).toString("utf8");return i?JSON.parse(i):null}var mx=xt(ol(),1);var M1=xt(tx(),1),B1=xt(co(),1),z1=xt(Er(),1),F1=xt(kc(),1),U1=xt(Lc(),1),H1=xt(Uc(),1),fx=xt(xo(),1),q1=xt(dx(),1);var ux=fx.default;ee();var Ae=G("upstream.frontier"),xx="application/json",hx="none",j1=15e3,Ci=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){Ae.warn("start called on already-started FrontierUpstream; noop");return}let e={Authorization:`Bearer ${this.opts.privatecode}`,Origin:Kf,...ur(this.opts.ppeOverride)};class r extends ux{constructor(v){super(v,jf,{headers:e})}send(v,...S){if(C0("debug"))try{let I;typeof v=="string"?I=Buffer.from(v,"utf8"):v instanceof Buffer?I=v:v instanceof ArrayBuffer?I=new Uint8Array(v):ArrayBuffer.isView(v)?I=new Uint8Array(v.buffer,v.byteOffset,v.byteLength):I=new Uint8Array(0);let D=Buffer.from(I.slice(0,128)).toString("hex");Ae.debug("WS raw frame out",{bytes:I.byteLength,headHex:D})}catch(I){Ae.warn("WS raw frame dump failed",{err:String(I)})}super.send(v,...S)}}let i=$f(this.opts.urlOverride),o={url:i,ws:r,fpID:Gf,aID:Ds,accessKey:this.opts.handshake.accessKey,deviceID:this.opts.handshake.deviceId,payloadType:{type:xx,force:!0},payloadEncoding:{encoding:hx,force:!0},enableTransformTextPayload:!0,enableQoS:!1,enableAutoAck:!1,automaticOpen:!1,maxRetries:Number.POSITIVE_INFINITY,debug:this.opts.debug??!1},c=new mx.FWS(o),f=!1,u=null,x,p,_=new Promise((E,v)=>{x=E,p=v}),y=E=>{f||(f=!0,u&&(clearTimeout(u),u=null),E?p(E):x())};c.onopen=()=>{this.opened=!0,this.openCount+=1;let E=this.openCount===1;Ae.info("frontier opened",{url:i,remoteDeviceId:this.opts.handshake.deviceId,initial:E,openCount:this.openCount}),E&&y();for(let v of this.connectHandlers)Promise.resolve(v({initial:E})).catch(S=>Ae.warn("onConnect handler threw (ignored)",{err:String(S)}))},c.onclose=E=>{this.opened=!1,Ae.info("frontier closed",{code:E.code,reason:E.reason,willReconnect:E.willReconnect})},c.onerror=E=>{Ae.warn("frontier error",{code:E.code,msg:E.message}),y(new R("UPSTREAM_DISCONNECTED",`frontier connect error before open: code=${E.code} msg=${E.message??""}`))},c.onmessage=E=>this.handleMessage(E),this.fws=c;let A=this.opts.openTimeoutMs??j1;u=setTimeout(()=>{y(new R("UPSTREAM_DISCONNECTED",`frontier ws open timeout after ${A}ms (handshake or upgrade slow)`))},A),await c.connect();try{await _}catch(E){try{c.close(1e3,"open failed")}catch(v){Ae.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){Ae.warn("frontier close threw (ignored)",{err:String(i)})}}}async send(e){let r=this.fws,i=e.method;if(!r)throw Ae.warn("frontier send refused: upstream not started",{method:i}),new R("UPSTREAM_DISCONNECTED","frontier upstream not started");if(!this.isConnected()){let u=Date.now();throw u-this.lastSendRefusedLogAt>1e3?(Ae.warn("frontier send refused: ws not open",{method:i,opened:this.opened,readyState:r.readyState,...this.sendRefusedSuppressed>0?{suppressedSinceLast:this.sendRefusedSuppressed}:{}}),this.lastSendRefusedLogAt=u,this.sendRefusedSuppressed=0):this.sendRefusedSuppressed+=1,new R("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;px(c)||Ae.info("frontier frame out",{method:c.method,jsonrpcId:c.id,size:o.length});try{await r.send(o,{service:33555712,method:1,payloadType:xx,payloadEncoding:hx})}catch(u){throw Ae.warn("frontier frame send failed",{method:c.method,jsonrpcId:c.id,err:String(u)}),new R("UPSTREAM_DISCONNECTED",`frontier send failed: ${String(u)}`,{cause:u})}}onFrame(e){this.handler=e}onConnect(e){this.connectHandlers.push(e)}isConnected(){return this.opened&&this.fws?.readyState===1}injectAgentPatToken(e){let 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){Ae.debug("drop non-adapter frontier frame",{service:r});return}let i=$1(e);if(!i){Ae.debug("frontier message without text payload, drop",{payloadType:e.message?.payloadType});return}if(!this.handler){Ae.debug("frame received but no onFrame handler",{size:i.length});return}let o;try{o=JSON.parse(i)}catch(f){Ae.warn("frontier message JSON parse failed",{err:String(f),head:i.slice(0,80)});return}let c=o;px(c)||Ae.info("frontier frame in",{logid:W1(e.message?.LogID),logidNew:e.message?.LogIDNew,msgId:e.message?.msgID,jsonrpcId:c.id,method:c.method,body:K1(i)}),Promise.resolve(this.handler(o)).catch(f=>Ae.warn("frontier frame handler threw",{err:String(f)}))}};function px(t){return t.method==="_agent/health"?!0:typeof t.id=="string"&&t.id.startsWith("agent.health_")}var gx=2e3;function K1(t){return t.length<=gx?t:`${t.slice(0,gx)}...<truncated, total ${t.length} chars>`}function W1(t){return t?t.high===0?String(t.low>>>0):`${t.high.toString(16)}${(t.low>>>0).toString(16).padStart(8,"0")}`:""}function $1(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 qc=G("upstream.switchable"),po=class{inner;handler=null;connectHandlers=[];constructor(e){this.inner=e}async swap(e,r){if(this.inner===e)return;qc.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 qc.error("swap target start failed, reverting",{err:String(o)}),this.inner=i,o}await i.stop(r??"swapped").catch(o=>qc.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 Gc=G("upstream"),Tr=class{handler=null;async start(){Gc.info("NoopUpstream started (M1 skeleton; real Frontier wired in M4)")}async stop(e){Gc.info("NoopUpstream stopped",{reason:e})}async send(e){Gc.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();Be();import{promises as jc}from"node:fs";import{dirname as J1}from"node:path";var Z1=G("pat-token-store");async function _x(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"&&Z1.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 jc.mkdir(J1(e.patTokenFile),{recursive:!0}),await jc.writeFile(e.patTokenFile,t,{encoding:"utf8",mode:384})}Be();Be();import{promises as go}from"node:fs";import{join as V1}from"node:path";function Y1(t,e){return`#!/bin/sh
126
126
  exec ${JSON.stringify(e)} ${JSON.stringify(t)} "$@"
127
- `}function Xb(t,e){return`@echo off\r
127
+ `}function X1(t,e){return`@echo off\r
128
128
  "${e}" "${t}" %*\r
129
- `}async function yx(t,e=ne()){let r=e.binDir;await wo.mkdir(r,{recursive:!0});let s=Jb(r,process.platform==="win32"?"coze-bridge.cmd":"coze-bridge"),a=process.execPath,c=process.platform==="win32"?Xb(t,a):Yb(t,a);return await wo.readFile(s,"utf8").catch(()=>null)===c||(await wo.writeFile(s,c,"utf8"),process.platform!=="win32"&&await wo.chmod(s,493)),r}te();Fe();import{execSync as Ex}from"node:child_process";import{readFileSync as vx,unlinkSync as Qb}from"node:fs";import{mkdir as eE,readFile as Sx,unlink as Ix,writeFile as tE}from"node:fs/promises";import{dirname as nE}from"node:path";function bx(t){try{return process.kill(t,0),!0}catch(e){return e.code==="EPERM"}}var rE=G("single-instance"),_o=class{pidFile;acquired=!1;constructor(e={}){this.pidFile=e.pidFile??ne().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&&(rE.warn("removing stale pid file",{stalePid:e}),await Ix(this.pidFile).catch(()=>{})),await eE(nE(this.pidFile),{recursive:!0}),await tE(this.pidFile,String(process.pid),"utf8"),this.acquired=!0,this.installCleanupHooks(),{kind:"acquired"})}async release(){if(this.acquired){try{(await Sx(this.pidFile,"utf8")).trim()===String(process.pid)&&await Ix(this.pidFile)}catch{}this.acquired=!1}}async readExistingPid(){try{let e=await Sx(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 bx(e)?this.matchesDaemonTitle(e):!1}matchesDaemonTitle(e){if(process.platform==="win32")return this.matchesDaemonTitleWindows(e);try{let r=vx(`/proc/${e}/cmdline`,"utf8").replace(/\0/g," ");return!!(r.includes("coze-bridge-daemon")||r.includes("lib/index.js"))}catch{}try{let r=Ex(`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=Ex(`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{vx(this.pidFile,"utf8").trim()===String(process.pid)&&Qb(this.pidFile)}catch{}})}};var j=G("daemon"),iE="coze-bridge-daemon";async function Tx(){let t=new _o({processTitle:iE}),e=await t.acquire();if(e.kind==="already-running")throw new Error(`coze-bridge daemon already running (pid=${e.pid})`);let r=await Ks(),s=r??{};Ni({pid:process.pid}),j.info(r?"loaded bridge config":"initialized bridge config");try{let k=new un;s.frameworksCache=await k.detectAll(),j.info("refreshed frameworks_cache",{detected:Object.keys(s.frameworksCache)})}catch(k){j.warn("framework detection failed",{err:String(k)})}await yr(s);let a=new mo(new Rr),c=ne(),d=null,l=new $s({upstream:a,paths:c,bridgeConfig:s,sessionSpawner:async(k,L,H,V)=>{if(!d)throw new Error("agentManager not ready");return d.spawnSessionDownstream(k,L,H,V)}});await oE(c,l);let x=new Gs({paths:c,config:s,registry:l});d=x;let p,w,v=null,I={},b,E=null;l.registerExtension("_agent/create",async k=>x.createAgent(k.params)),l.registerExtension("_agent/health",async()=>({ok:!0}));let S={},C=new Ls({agents:l.agents,disposeAndMarkDisconnected:async(k,L)=>{let H=l.agents.get(k);if(H){await x.cleanupOpenclawSessionProviders(H).catch(oe=>j.warn("cleanup openclaw providers failed (ignored)",{agentId:k,err:String(oe)}));let V=!0;try{await H.dispose(`disconnect: ${L}`)}catch(oe){V=!1,j.error("dispose during disconnect FAILED, leaving agent in error state",{agentId:k,err:String(oe)}),H.status="error"}V&&(H.status="disconnected",l.unregister(k),l.disconnectedAgents.add(k))}else l.disconnectedAgents.add(k)},detailSyncer:async k=>{if(!S.ref)throw new Error("agent-detail-sync not initialized yet");await S.ref.syncOne(k)},cleanupOpenclawProviders:async k=>{await x.cleanupOpenclawSessionProviders(k)},openclawRepair:async(k,L)=>{await x.openclawRepair(k,L)},isRuntimePendingPermission:k=>l.hasPendingPermissionFor(k)});l.registerExtension("_agent/listSkills",k=>C.listSkills(k.params)),l.registerExtension("_agent/addSkills",k=>C.addSkills(k.params)),l.registerExtension("_agent/removeSkills",k=>C.removeSkills(k.params)),l.registerExtension("_agent/getFileTree",k=>C.getFileTree(k.params)),l.registerExtension("_agent/getFileContent",k=>C.getFileContent(k.params)),l.registerExtension("_agent/update",k=>C.updateAgent(k.params)),l.registerExtension("_agent/disconnect",k=>C.disconnectAgent(k.params)),l.registerExtension("_agent/switchModel",k=>C.switchModel(k.params)),l.registerExtension("_agent/reset",k=>C.resetAgent(k.params)),l.registerExtension("_agent/repair",k=>C.repairAgent(k.params));let D=new Hi({paths:c,handlers:C,sendDetail:k=>l.sendRequest("_agent/detail",k)});S.ref=D;let P=async k=>{await Promise.allSettled(k.map(async L=>{try{await C.disconnectAgent({agentId:L.agentId,reason:`auth_failure: code=${L.code} ${L.message}`}),j.info("agent disconnected due to auth failure from heartbeat response",{agentId:L.agentId,code:L.code,message:L.message})}catch(H){j.warn("disconnect during authFailure handling failed (ignored)",{agentId:L.agentId,err:String(H)})}}))};a.onConnect(({initial:k})=>{j.info("frontier upstream connected, triggering detail sync",{initial:k}),D.syncAll(k?"initial-connect":"reconnect").catch(L=>j.warn("detail sync top-level error (ignored)",{err:String(L)}))});let y=new Vs({paths:c,routes:[{method:"GET",path:"/status",handler:async()=>{let k=l.getMockScenario();return{running:!0,pid:process.pid,agents:[...l.agents.keys()],deviceId:v??"",frameworksCache:s.frameworksCache??{},...k?{mockScenario:k}:{}}}},{method:"POST",path:"/pair",handler:async k=>{let L=k,H=L?.privatecode,V=L?.pairing_code;if(!H||!V)throw new R("IPC_BAD_REQUEST","/pair requires privatecode + pairing_code");let oe=ui(L.env),le=L.handshake_url,be=L.frontier_url,Be=Cx(L.env,le,be),st=!!p&&p!==H,Re=w!==void 0&&w!==Be,qt=st||Re,Ee=await nc({privatecode:H,...le?{endpoint:le}:{},ppeOverride:oe});if(qt){j.warn("pair config switched, resetting agents",{pcChanged:st,envChanged:Re,previousPc:p?yo(p):"",nextPc:yo(H),previousEnvKey:w??"",nextEnvKey:Be});for(let _e of[...l.agents.values()])await _e.dispose("pair config switch").catch(()=>{}),l.agents.delete(_e.agentId);l.disconnectedAgents.size>0&&(j.info("clearing disconnectedAgents set on pair config switch",{count:l.disconnectedAgents.size}),l.disconnectedAgents.clear()),await a.swap(new Rr,"pair switch").catch(()=>{})}v=Ee.deviceId,Ni({deviceId:v,pid:process.pid}),wc({patToken:H,env:L.env}).catch(_e=>j.warn("coze-cli setup error (ignored)",{err:String(_e)}));let Y=new Di({handshake:Ee,privatecode:H,...be?{urlOverride:be}:{},ppeOverride:oe,getPatTokenForAgent:_e=>l.agents.get(_e)?.patToken});await a.swap(Y,"pair");try{let _e=new un;s.frameworksCache=await _e.detectAll(),await yr(s),j.info("frameworks_cache refreshed before pair",{detected:Object.keys(s.frameworksCache)})}catch(_e){j.warn("frameworks_cache refresh failed (ignored, using cached)",{err:String(_e)})}let zn=Object.keys(s.frameworksCache??{});try{let _e=await l.sendRequest("_agent/pair",{pairCode:V,patToken:H,frameworks:zn,_meta:{cozeDeviceId:v}});j.info("_agent/pair ok",{pairResult:_e}),p=H,w=Be,I=oe,b=le,L.mock_scenario!==void 0&&(l.setMockScenario(L.mock_scenario),j.info("mock scenario set",{scenario:L.mock_scenario})),ki(H,c).catch(We=>j.warn("writePatToken after /pair failed (ignored)",{err:String(We)})),E||(E=new xi({core:l,getDeviceId:()=>v??"",onTickEnd:()=>D.retryPending().catch(We=>j.warn("detailSync.retryPending failed (ignored)",{err:String(We)})),onAuthFailures:P})),E.start(),qt&&bo(c,x).catch(We=>j.warn("post-pair-switch auto-revive error (ignored)",{err:String(We)}));let Fn;return L.agent_id&&(Fn=await aE(L.agent_id,c,x,We=>l.sendRequest("_agent/detail",We),H).catch(We=>(j.error("--agent-id ensureAgent failed",{agentId:L.agent_id,err:String(We)}),{ok:!1,agentId:L.agent_id??"",note:String(We)}))),{ok:!0,note:"paired with cloud",...Fn?{agent:Fn}:{}}}catch(_e){return j.error("_agent/pair failed",{err:String(_e)}),{ok:!1,note:`pair failed: ${String(_e)}`}}}},{method:"POST",path:"/connect",handler:async k=>{let L=k,H=L?.privatecode;if(!H)throw new R("IPC_BAD_REQUEST","/connect requires privatecode");let V=ui(L.env),oe=L.handshake_url,le=L.frontier_url,be=Cx(L.env,oe,le);if(p===H&&w===be){let Y=await sE(c);return l.agents.size===0&&Y?(j.warn("/connect noop but core.agents empty with configs on disk; re-running auto-revive"),bo(c,x).catch(zn=>j.warn("connect-noop auto-revive error (ignored)",{err:String(zn)}))):j.info("/connect: already connected with same PAT + env, noop"),{ok:!0,note:"already connected"}}let Be=!!p&&p!==H,st=w!==void 0&&w!==be,Re=Be||st,qt=await nc({privatecode:H,...oe?{endpoint:oe}:{},ppeOverride:V});if(Re){j.warn("connect config switched, resetting agents",{pcChanged:Be,envChanged:st,previousPc:p?yo(p):"",nextPc:yo(H)});for(let Y of[...l.agents.values()])await Y.dispose("connect config switch").catch(()=>{}),l.agents.delete(Y.agentId);l.disconnectedAgents.size>0&&(j.info("clearing disconnectedAgents set on connect config switch",{count:l.disconnectedAgents.size}),l.disconnectedAgents.clear()),await a.swap(new Rr,"connect switch").catch(()=>{})}v=qt.deviceId,Ni({deviceId:v,pid:process.pid}),wc({patToken:H,env:L.env}).catch(Y=>j.warn("coze-cli setup error (ignored)",{err:String(Y)}));let Ee=new Di({handshake:qt,privatecode:H,...le?{urlOverride:le}:{},ppeOverride:V,getPatTokenForAgent:Y=>l.agents.get(Y)?.patToken});return await a.swap(Ee,"connect"),p=H,w=be,I=V,b=oe,L.mock_scenario!==void 0&&(l.setMockScenario(L.mock_scenario),j.info("mock scenario set",{scenario:L.mock_scenario})),E||(E=new xi({core:l,getDeviceId:()=>v??"",onTickEnd:()=>D.retryPending().catch(Y=>j.warn("detailSync.retryPending failed (ignored)",{err:String(Y)})),onAuthFailures:P})),E.start(),Re&&bo(c,x).catch(Y=>j.warn("post-connect-switch auto-revive error (ignored)",{err:String(Y)})),ki(H,c).catch(Y=>j.warn("writePatToken after /connect failed (ignored)",{err:String(Y)})),j.info("/connect: WS established",{deviceId:v}),{ok:!0,note:"connected"}}},{method:"POST",path:"/_agent/create",handler:async k=>{let L=k;return{ok:!0,result:await x.createAgent(L)}}},{method:"POST",path:"/agent/send",handler:async k=>{let L=k;if(!L?.agentId||!L?.sessionId||!L?.kind||!L?.path)throw new R("IPC_BAD_REQUEST","/agent/send requires agentId, sessionId, kind, path");if(!p)throw new R("UPSTREAM_NOT_READY","daemon not yet paired with cloud (run --pair-code first)");try{let H=L;return await(H.groupFile?Pu:Ou)(H,{core:l,patToken:p,handshakeBase:b,ppeOverride:I})}catch(H){if(H instanceof R)return{ok:!1,code:H.code,message:H.message};throw H}}},{method:"POST",path:"/refresh",handler:async()=>{j.info("IPC /refresh: re-detecting frameworks");let k=new un;return s.frameworksCache=await k.detectAll(),await yr(s),{ok:!0,frameworks:s.frameworksCache}}},{method:"POST",path:"/shutdown",handler:async()=>(j.info("IPC /shutdown received"),setImmediate(()=>{z.shutdown("ipc /shutdown")}),{ok:!0})}]}),{port:A,token:O}=await y.start();try{await yx(c.libEntry,c)}catch(k){j.warn("bin shim install failed (D72 send \u547D\u4EE4\u53EF\u80FD\u4E0D\u53EF\u7528)",{err:String(k)})}await l.start(),bo(c,x).catch(k=>j.warn("auto-revive top-level error (ignored)",{err:String(k)})),M0().then(async()=>{let{probeAcpVersion:k}=await Promise.resolve().then(()=>(wn(),L0));for(let L of["claude-code","codex"]){let H=await k(L);H?j.info("acp wrapper version",{framework:L,version:H}):j.warn("acp wrapper version probe failed (binary not on PATH?)",{framework:L})}}).catch(k=>j.warn("acp wrapper warmup / probe top-level error (ignored)",{err:String(k)}));let U=null,z={port:A,token:O,core:l,ipc:y,shutdown(k){return U||(j.info("daemon shutdown",{reason:k}),U=(async()=>{E?.stop(),await l.stop(k),await y.stop(),await t.release()})(),U)}};for(let k of["SIGTERM","SIGINT"])process.on(k,()=>{z.shutdown(k).then(()=>process.exit(0))});return process.on("unhandledRejection",k=>{j.error("unhandledRejection",{reason:k instanceof Error?k.message:String(k),stack:k instanceof Error?k.stack:void 0})}),process.on("uncaughtException",k=>{j.error("uncaughtException (will exit, supervisor will restart)",{message:k.message,stack:k.stack,name:k.name}),process.exit(1)}),j.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 sE(t){let{readdir:e}=await import("node:fs/promises");try{return(await e(t.agentsRoot)).length>0}catch{return!1}}function yo(t){return t.length<=8?"***":`${t.slice(0,4)}***${t.slice(-4)}`}function Cx(t,e,r){return`${t??""}|${e??""}|${r??""}`}async function oE(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(()=>(Kt(),Ui));for(let d of s){await c(d,t).catch(l=>j.warn("enforceAgentConfigMode failed (ignored)",{agentId:d,err:String(l)}));try{let l=await a(d,t);l?.disconnectedAt&&(e.disconnectedAgents.add(d),j.info("agent marked disconnected on startup",{agentId:d,disconnectedAt:l.disconnectedAt,reason:l.disconnectReason??""}))}catch(l){j.warn("failed to load agent config on startup, skipping",{agentId:d,err:String(l)})}}}async function aE(t,e,r,s,a){let{loadAgentConfig:c}=await Promise.resolve().then(()=>(Kt(),Ui)),d=await c(t,e);if(d){j.info("--agent-id: local config found, reconnecting",{agentId:t,framework:d.framework,hadDisconnect:!!d.disconnectedAt});let w={agentId:d.agentId,framework:d.framework,...d.cozeIdentity?{cozeIdentity:d.cozeIdentity}:{},...d.model?{model:d.model}:{},...a?{patToken:a}:{}};return await r.createAgent(w),{ok:!0,agentId:t,note:d.disconnectedAt?"revived from local config":"connected from local config"}}j.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 R("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 p=l.deployType==="cloud"&&l.framework==="openclaw";return{ok:!0,agentId:t,note:p?"cloud agent acknowledged":"created from cloud detail"}}async function bo(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(()=>(Kt(),Ui));j.info("auto-revive: scanning local agents on startup",{count:s.length});let c=0,d=0;for(let l of s){let x;try{x=await a(l,t)}catch(p){j.warn("auto-revive: load config failed (skipping)",{agentId:l,err:String(p)}),d+=1;continue}if(!x){d+=1;continue}if(x.disconnectedAt){j.info("auto-revive: skip disconnected agent",{agentId:l,disconnectedAt:x.disconnectedAt}),d+=1;continue}try{j.info("auto-revive: re-registering agent (D44 no spawn)",{agentId:l,framework:x.framework});let p=cE(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){j.warn("auto-revive: createAgent failed (skipping)",{agentId:l,framework:x.framework,err:String(p)}),d+=1}}return j.info("auto-revive: done",{revived:c,skipped:d,total:s.length}),{revived:c,skipped:d,total:s.length}}function cE(t){let e={};return t.deployType&&(e.cozeDeployType=t.deployType),t.accountId&&(e.cozeAccountId=t.accountId),Object.keys(e).length>0?e:void 0}Zc();Fe();import{readFile as Ax}from"node:fs/promises";var Ht=class{paths;constructor(e){this.paths=e??ne()}async probe(e=1e3){let r=await Eo(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:gE(s)}}}async request(e){let r=await Eo(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,d=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:pE(x)}}finally{clearTimeout(d)}}};async function Eo(t){try{let[e,r]=await Promise.all([Ax(t.portFile,"utf8"),Ax(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 pE(t){if(!t)return null;try{return JSON.parse(t)}catch{return t}}function gE(t){return t instanceof Error?t.message:String(t)}te();Fe();import{copyFile as Rx,mkdir as mE,readFile as Jc,writeFile as wE}from"node:fs/promises";import{homedir as V4}from"node:os";import{dirname as _E,resolve as Yc,sep as vo}from"node:path";import{fileURLToPath as yE}from"node:url";te();Fe();var Dx=G("dist-install");function bE(t){let e=yE(t),r=_E(e),s=`${vo}src${vo}`;if(r.includes(s)||r.endsWith(`${vo}src${vo}cli`))return null;let a=Yc(r,"index.js"),c=Yc(r,"..","package.json");return{dist:a,pkgJson:c}}async function Xc(t={}){let e=t.paths??ne(),r=bE(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 Jc(a,"utf8")).version??"unknown"}catch(v){return Dx.warn("cannot read source package.json,skip dist install",{err:String(v)}),{kind:"dev-mode-skip",reason:`package.json read failed: ${String(v)}`}}let d=await Ks(e.configFile)??{},l=d.libVersion;if(l===c)try{return await Jc(e.libEntry),{kind:"already-current",libVersion:c}}catch{}await mE(e.libDir,{recursive:!0}),await Rx(s,e.libEntry),await Rx(`${s}.map`,`${e.libEntry}.map`).catch(()=>{});let x=Yc(e.libDir,"package.json"),p=`${JSON.stringify({type:"module"},null,2)}
130
- `;return await Jc(x,"utf8").catch(()=>null)!==p&&await wE(x,p),d.libVersion=c,await yr(d,e.configFile),Dx.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 EE,resolve as vE}from"node:path";Fe();var SE=9e4,IE={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 CE(t){return IE[t]??1}async function kx(t,e={}){let r=e.paths??ne();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>
129
+ `}async function yx(t,e=te()){let r=e.binDir;await go.mkdir(r,{recursive:!0});let i=V1(r,process.platform==="win32"?"coze-bridge.cmd":"coze-bridge"),o=process.execPath,c=process.platform==="win32"?X1(t,o):Y1(t,o);return await go.readFile(i,"utf8").catch(()=>null)===c||(await go.writeFile(i,c,"utf8"),process.platform!=="win32"&&await go.chmod(i,493)),r}ee();Be();import{execSync as bx}from"node:child_process";import{readFileSync as vx,unlinkSync as Q1}from"node:fs";import{mkdir as eE,readFile as Sx,unlink as Ix,writeFile as tE}from"node:fs/promises";import{dirname as nE}from"node:path";function Ex(t){try{return process.kill(t,0),!0}catch(e){return e.code==="EPERM"}}var rE=G("single-instance"),mo=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&&(rE.warn("removing stale pid file",{stalePid:e}),await Ix(this.pidFile).catch(()=>{})),await eE(nE(this.pidFile),{recursive:!0}),await tE(this.pidFile,String(process.pid),"utf8"),this.acquired=!0,this.installCleanupHooks(),{kind:"acquired"})}async release(){if(this.acquired){try{(await Sx(this.pidFile,"utf8")).trim()===String(process.pid)&&await Ix(this.pidFile)}catch{}this.acquired=!1}}async readExistingPid(){try{let e=await Sx(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 Ex(e)?this.matchesDaemonTitle(e):!1}matchesDaemonTitle(e){if(process.platform==="win32")return this.matchesDaemonTitleWindows(e);try{let r=vx(`/proc/${e}/cmdline`,"utf8").replace(/\0/g," ");return!!(r.includes("coze-bridge-daemon")||r.includes("lib/index.js"))}catch{}try{let r=bx(`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=bx(`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{vx(this.pidFile,"utf8").trim()===String(process.pid)&&Q1(this.pidFile)}catch{}})}};var j=G("daemon"),iE="coze-bridge-daemon";async function Tx(){let t=new mo({processTitle:iE}),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??{};Pi({pid:process.pid}),j.info(r?"loaded bridge config":"initialized bridge config");try{let k=new fn;i.frameworksCache=await k.detectAll(),j.info("refreshed frameworks_cache",{detected:Object.keys(i.frameworksCache)})}catch(k){j.warn("framework detection failed",{err:String(k)})}await wr(i);let o=new po(new Tr),c=te(),f=null,u=new Ks({upstream:o,paths:c,bridgeConfig:i,sessionSpawner:async(k,N,F,K)=>{if(!f)throw new Error("agentManager not ready");return f.spawnSessionDownstream(k,N,F,K)}});await oE(c,u);let x=new Hs({paths:c,config:i,registry:u});f=x;let p,_,y=null,A={},E,v=null;u.registerExtension("_agent/create",async k=>x.createAgent(k.params)),u.registerExtension("_agent/health",async()=>({ok:!0}));let S={},I=new Os({agents:u.agents,disposeAndMarkDisconnected:async(k,N)=>{let F=u.agents.get(k);if(F){await x.cleanupOpenclawSessionProviders(F).catch(se=>j.warn("cleanup openclaw providers failed (ignored)",{agentId:k,err:String(se)}));let K=!0;try{await F.dispose(`disconnect: ${N}`)}catch(se){K=!1,j.error("dispose during disconnect FAILED, leaving agent in error state",{agentId:k,err:String(se)}),F.status="error"}K&&(F.status="disconnected",u.unregister(k),u.disconnectedAgents.add(k))}else u.disconnectedAgents.add(k)},detailSyncer:async k=>{if(!S.ref)throw new Error("agent-detail-sync not initialized yet");await S.ref.syncOne(k)},cleanupOpenclawProviders:async k=>{await x.cleanupOpenclawSessionProviders(k)},openclawRepair:async(k,N)=>{await x.openclawRepair(k,N)},isRuntimePendingPermission:k=>u.hasPendingPermissionFor(k)});u.registerExtension("_agent/listSkills",k=>I.listSkills(k.params)),u.registerExtension("_agent/addSkills",k=>I.addSkills(k.params)),u.registerExtension("_agent/removeSkills",k=>I.removeSkills(k.params)),u.registerExtension("_agent/getFileTree",k=>I.getFileTree(k.params)),u.registerExtension("_agent/getFileContent",k=>I.getFileContent(k.params)),u.registerExtension("_agent/update",k=>I.updateAgent(k.params)),u.registerExtension("_agent/disconnect",k=>I.disconnectAgent(k.params)),u.registerExtension("_agent/switchModel",k=>I.switchModel(k.params)),u.registerExtension("_agent/reset",k=>I.resetAgent(k.params)),u.registerExtension("_agent/repair",k=>I.repairAgent(k.params));let D=new Fi({paths:c,handlers:I,sendDetail:k=>u.sendRequest("_agent/detail",k)});S.ref=D;let P=async k=>{await Promise.allSettled(k.map(async N=>{try{await I.disconnectAgent({agentId:N.agentId,reason:`auth_failure: code=${N.code} ${N.message}`}),j.info("agent disconnected due to auth failure from heartbeat response",{agentId:N.agentId,code:N.code,message:N.message})}catch(F){j.warn("disconnect during authFailure handling failed (ignored)",{agentId:N.agentId,err:String(F)})}}))};o.onConnect(({initial:k})=>{j.info("frontier upstream connected, triggering detail sync",{initial:k}),D.syncAll(k?"initial-connect":"reconnect").catch(N=>j.warn("detail sync top-level error (ignored)",{err:String(N)}))});let w=new Ws({paths:c,routes:[{method:"GET",path:"/status",handler:async()=>{let k=u.getMockScenario();return{running:!0,pid:process.pid,agents:[...u.agents.keys()],deviceId:y??"",frameworksCache:i.frameworksCache??{},...k?{mockScenario:k}:{}}}},{method:"POST",path:"/pair",handler:async k=>{let N=k,F=N?.privatecode,K=N?.pairing_code;if(!F||!K)throw new R("IPC_BAD_REQUEST","/pair requires privatecode + pairing_code");let se=di(N.env),fe=N.handshake_url,we=N.frontier_url,Ne=Ax(N.env,fe,we),it=!!p&&p!==F,Te=_!==void 0&&_!==Ne,Ht=it||Te,_e=await ec({privatecode:F,...fe?{endpoint:fe}:{},ppeOverride:se});if(Ht){j.warn("pair config switched, resetting agents",{pcChanged:it,envChanged:Te,previousPc:p?wo(p):"",nextPc:wo(F),previousEnvKey:_??"",nextEnvKey:Ne});for(let ge of[...u.agents.values()])await ge.dispose("pair config switch").catch(()=>{}),u.agents.delete(ge.agentId);u.disconnectedAgents.size>0&&(j.info("clearing disconnectedAgents set on pair config switch",{count:u.disconnectedAgents.size}),u.disconnectedAgents.clear()),await o.swap(new Tr,"pair switch").catch(()=>{})}y=_e.deviceId,Pi({deviceId:y,pid:process.pid}),gc({patToken:F,env:N.env}).catch(ge=>j.warn("coze-cli setup error (ignored)",{err:String(ge)}));let Y=new Ci({handshake:_e,privatecode:F,...we?{urlOverride:we}:{},ppeOverride:se,getPatTokenForAgent:ge=>u.agents.get(ge)?.patToken});await o.swap(Y,"pair");try{let ge=new fn;i.frameworksCache=await ge.detectAll(),await wr(i),j.info("frameworks_cache refreshed before pair",{detected:Object.keys(i.frameworksCache)})}catch(ge){j.warn("frameworks_cache refresh failed (ignored, using cached)",{err:String(ge)})}let Mn=Object.keys(i.frameworksCache??{});try{let ge=await u.sendRequest("_agent/pair",{pairCode:K,patToken:F,frameworks:Mn,_meta:{cozeDeviceId:y}});j.info("_agent/pair ok",{pairResult:ge}),p=F,_=Ne,A=se,E=fe,N.mock_scenario!==void 0&&(u.setMockScenario(N.mock_scenario),j.info("mock scenario set",{scenario:N.mock_scenario})),Ri(F,c).catch(Ge=>j.warn("writePatToken after /pair failed (ignored)",{err:String(Ge)})),v||(v=new ui({core:u,getDeviceId:()=>y??"",onTickEnd:()=>D.retryPending().catch(Ge=>j.warn("detailSync.retryPending failed (ignored)",{err:String(Ge)})),onAuthFailures:P})),v.start(),Ht&&_o(c,x).catch(Ge=>j.warn("post-pair-switch auto-revive error (ignored)",{err:String(Ge)}));let Bn;return N.agent_id&&(Bn=await aE(N.agent_id,c,x,Ge=>u.sendRequest("_agent/detail",Ge),F).catch(Ge=>(j.error("--agent-id ensureAgent failed",{agentId:N.agent_id,err:String(Ge)}),{ok:!1,agentId:N.agent_id??"",note:String(Ge)}))),{ok:!0,note:"paired with cloud",...Bn?{agent:Bn}:{}}}catch(ge){return j.error("_agent/pair failed",{err:String(ge)}),{ok:!1,note:`pair failed: ${String(ge)}`}}}},{method:"POST",path:"/connect",handler:async k=>{let N=k,F=N?.privatecode;if(!F)throw new R("IPC_BAD_REQUEST","/connect requires privatecode");let K=di(N.env),se=N.handshake_url,fe=N.frontier_url,we=Ax(N.env,se,fe);if(p===F&&_===we){let Y=await sE(c);return u.agents.size===0&&Y?(j.warn("/connect noop but core.agents empty with configs on disk; re-running auto-revive"),_o(c,x).catch(Mn=>j.warn("connect-noop auto-revive error (ignored)",{err:String(Mn)}))):j.info("/connect: already connected with same PAT + env, noop"),{ok:!0,note:"already connected"}}let Ne=!!p&&p!==F,it=_!==void 0&&_!==we,Te=Ne||it,Ht=await ec({privatecode:F,...se?{endpoint:se}:{},ppeOverride:K});if(Te){j.warn("connect config switched, resetting agents",{pcChanged:Ne,envChanged:it,previousPc:p?wo(p):"",nextPc:wo(F)});for(let Y of[...u.agents.values()])await Y.dispose("connect config switch").catch(()=>{}),u.agents.delete(Y.agentId);u.disconnectedAgents.size>0&&(j.info("clearing disconnectedAgents set on connect config switch",{count:u.disconnectedAgents.size}),u.disconnectedAgents.clear()),await o.swap(new Tr,"connect switch").catch(()=>{})}y=Ht.deviceId,Pi({deviceId:y,pid:process.pid}),gc({patToken:F,env:N.env}).catch(Y=>j.warn("coze-cli setup error (ignored)",{err:String(Y)}));let _e=new Ci({handshake:Ht,privatecode:F,...fe?{urlOverride:fe}:{},ppeOverride:K,getPatTokenForAgent:Y=>u.agents.get(Y)?.patToken});return await o.swap(_e,"connect"),p=F,_=we,A=K,E=se,N.mock_scenario!==void 0&&(u.setMockScenario(N.mock_scenario),j.info("mock scenario set",{scenario:N.mock_scenario})),v||(v=new ui({core:u,getDeviceId:()=>y??"",onTickEnd:()=>D.retryPending().catch(Y=>j.warn("detailSync.retryPending failed (ignored)",{err:String(Y)})),onAuthFailures:P})),v.start(),Te&&_o(c,x).catch(Y=>j.warn("post-connect-switch auto-revive error (ignored)",{err:String(Y)})),Ri(F,c).catch(Y=>j.warn("writePatToken after /connect failed (ignored)",{err:String(Y)})),j.info("/connect: WS established",{deviceId:y}),{ok:!0,note:"connected"}}},{method:"POST",path:"/_agent/create",handler:async k=>{let N=k;return{ok:!0,result:await x.createAgent(N)}}},{method:"POST",path:"/agent/send",handler:async k=>{let N=k;if(!N?.agentId||!N?.sessionId||!N?.kind||!N?.path)throw new R("IPC_BAD_REQUEST","/agent/send requires agentId, sessionId, kind, path");if(!p)throw new R("UPSTREAM_NOT_READY","daemon not yet paired with cloud (run --pair-code first)");try{let F=N;return await(F.groupFile?Pu:Ou)(F,{core:u,patToken:p,handshakeBase:E,ppeOverride:A})}catch(F){if(F instanceof R)return{ok:!1,code:F.code,message:F.message};throw F}}},{method:"POST",path:"/refresh",handler:async()=>{j.info("IPC /refresh: re-detecting frameworks");let k=new fn;return i.frameworksCache=await k.detectAll(),await wr(i),{ok:!0,frameworks:i.frameworksCache}}},{method:"POST",path:"/shutdown",handler:async()=>(j.info("IPC /shutdown received"),setImmediate(()=>{B.shutdown("ipc /shutdown")}),{ok:!0})}]}),{port:C,token:O}=await w.start();try{await yx(c.libEntry,c)}catch(k){j.warn("bin shim install failed (D72 send \u547D\u4EE4\u53EF\u80FD\u4E0D\u53EF\u7528)",{err:String(k)})}await u.start(),_o(c,x).catch(k=>j.warn("auto-revive top-level error (ignored)",{err:String(k)})),M0().then(async()=>{let{probeAcpVersion:k}=await Promise.resolve().then(()=>(gn(),L0));for(let N of["claude-code","codex"]){let F=await k(N);F?j.info("acp wrapper version",{framework:N,version:F}):j.warn("acp wrapper version probe failed (binary not on PATH?)",{framework:N})}}).catch(k=>j.warn("acp wrapper warmup / probe top-level error (ignored)",{err:String(k)}));let z=null,B={port:C,token:O,core:u,ipc:w,shutdown(k){return z||(j.info("daemon shutdown",{reason:k}),z=(async()=>{v?.stop(),await u.stop(k),await w.stop(),await t.release()})(),z)}};for(let k of["SIGTERM","SIGINT"])process.on(k,()=>{B.shutdown(k).then(()=>process.exit(0))});return process.on("unhandledRejection",k=>{j.error("unhandledRejection",{reason:k instanceof Error?k.message:String(k),stack:k instanceof Error?k.stack:void 0})}),process.on("uncaughtException",k=>{j.error("uncaughtException (will exit, supervisor will restart)",{message:k.message,stack:k.stack,name:k.name}),process.exit(1)}),j.info("daemon ready",{port:C,pid:process.pid,nodeVersion:process.version,platform:process.platform,frameworks:Object.keys(i.frameworksCache??{}),libVersion:i.libVersion??"dev"}),B}async function sE(t){let{readdir:e}=await import("node:fs/promises");try{return(await e(t.agentsRoot)).length>0}catch{return!1}}function wo(t){return t.length<=8?"***":`${t.slice(0,4)}***${t.slice(-4)}`}function Ax(t,e,r){return`${t??""}|${e??""}|${r??""}`}async function oE(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(()=>(Kt(),zi));for(let f of i){await c(f,t).catch(u=>j.warn("enforceAgentConfigMode failed (ignored)",{agentId:f,err:String(u)}));try{let u=await o(f,t);u?.disconnectedAt&&(e.disconnectedAgents.add(f),j.info("agent marked disconnected on startup",{agentId:f,disconnectedAt:u.disconnectedAt,reason:u.disconnectReason??""}))}catch(u){j.warn("failed to load agent config on startup, skipping",{agentId:f,err:String(u)})}}}async function aE(t,e,r,i,o){let{loadAgentConfig:c}=await Promise.resolve().then(()=>(Kt(),zi)),f=await c(t,e);if(f){j.info("--agent-id: local config found, reconnecting",{agentId:t,framework:f.framework,hadDisconnect:!!f.disconnectedAt});let _={agentId:f.agentId,framework:f.framework,...f.cozeIdentity?{cozeIdentity:f.cozeIdentity}:{},...f.model?{model:f.model}:{},...o?{patToken:o}:{}};return await r.createAgent(_),{ok:!0,agentId:t,note:f.disconnectedAt?"revived from local config":"connected from local config"}}j.info("--agent-id: local config missing, pulling _agent/detail from cloud",{agentId:t});let u=await i({_meta:{cozeAgentId:t}});if(!u.framework)throw new R("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:u.agentId,framework:u.framework,...u.cozeIdentity?{cozeIdentity:u.cozeIdentity}:{},...u.model?{model:u.model}:{},...o?{patToken:o}:{},...u.deployType?{_meta:{cozeDeployType:u.deployType}}:{}};await r.createAgent(x);let p=u.deployType==="cloud"&&u.framework==="openclaw";return{ok:!0,agentId:t,note:p?"cloud agent acknowledged":"created from cloud detail"}}async function _o(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(()=>(Kt(),zi));j.info("auto-revive: scanning local agents on startup",{count:i.length});let c=0,f=0;for(let u of i){let x;try{x=await o(u,t)}catch(p){j.warn("auto-revive: load config failed (skipping)",{agentId:u,err:String(p)}),f+=1;continue}if(!x){f+=1;continue}if(x.disconnectedAt){j.info("auto-revive: skip disconnected agent",{agentId:u,disconnectedAt:x.disconnectedAt}),f+=1;continue}try{j.info("auto-revive: re-registering agent (D44 no spawn)",{agentId:u,framework:x.framework});let p=cE(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){j.warn("auto-revive: createAgent failed (skipping)",{agentId:u,framework:x.framework,err:String(p)}),f+=1}}return j.info("auto-revive: done",{revived:c,skipped:f,total:i.length}),{revived:c,skipped:f,total:i.length}}function cE(t){let e={};return t.deployType&&(e.cozeDeployType=t.deployType),t.accountId&&(e.cozeAccountId=t.accountId),Object.keys(e).length>0?e:void 0}$c();Be();import{readFile as Cx}from"node:fs/promises";var Ut=class{paths;constructor(e){this.paths=e??te()}async probe(e=1e3){let r=await yo(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:gE(i)}}}async request(e){let r=await yo(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 u=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 u.text();return{status:u.status,body:pE(x)}}finally{clearTimeout(f)}}};async function yo(t){try{let[e,r]=await Promise.all([Cx(t.portFile,"utf8"),Cx(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 pE(t){if(!t)return null;try{return JSON.parse(t)}catch{return t}}function gE(t){return t instanceof Error?t.message:String(t)}ee();Be();import{copyFile as Rx,mkdir as mE,readFile as Jc,writeFile as wE}from"node:fs/promises";import{homedir as J3}from"node:os";import{dirname as _E,resolve as Zc,sep as Eo}from"node:path";import{fileURLToPath as yE}from"node:url";ee();Be();var Dx=G("dist-install");function EE(t){let e=yE(t),r=_E(e),i=`${Eo}src${Eo}`;if(r.includes(i)||r.endsWith(`${Eo}src${Eo}cli`))return null;let o=Zc(r,"index.js"),c=Zc(r,"..","package.json");return{dist:o,pkgJson:c}}async function Vc(t={}){let e=t.paths??te(),r=EE(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 Jc(o,"utf8")).version??"unknown"}catch(y){return Dx.warn("cannot read source package.json,skip dist install",{err:String(y)}),{kind:"dev-mode-skip",reason:`package.json read failed: ${String(y)}`}}let f=await js(e.configFile)??{},u=f.libVersion;if(u===c)try{return await Jc(e.libEntry),{kind:"already-current",libVersion:c}}catch{}await mE(e.libDir,{recursive:!0}),await Rx(i,e.libEntry),await Rx(`${i}.map`,`${e.libEntry}.map`).catch(()=>{});let x=Zc(e.libDir,"package.json"),p=`${JSON.stringify({type:"module"},null,2)}
130
+ `;return await Jc(x,"utf8").catch(()=>null)!==p&&await wE(x,p),f.libVersion=c,await wr(f,e.configFile),Dx.info("dist installed",{libEntry:e.libEntry,fromVersion:u,toVersion:c}),u?{kind:"version-changed",fromVersion:u,toVersion:c,libEntry:e.libEntry}:{kind:"first-install",libVersion:c,libEntry:e.libEntry}}import{basename as bE,resolve as vE}from"node:path";Be();var SE=9e4,IE={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 AE(t){return IE[t]??1}async function kx(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>
131
131
  `),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.
132
- `),3;let s=await Eo(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.
133
- `),4;let a={agentId:t.agentId,sessionId:t.sessionId,kind:t.kind,path:t.groupFile?t.path:vE(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 TE(s,"/agent/send",a,SE)}catch(d){return process.stderr.write(`Error: daemon IPC failed: ${d instanceof Error?d.message:String(d)}
132
+ `),3;let i=await yo(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.
133
+ `),4;let o={agentId:t.agentId,sessionId:t.sessionId,kind:t.kind,path:t.groupFile?t.path:vE(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 TE(i,"/agent/send",o,SE)}catch(f){return process.stderr.write(`Error: daemon IPC failed: ${f instanceof Error?f.message:String(f)}
134
134
  `),4}if(!c.ok)return process.stderr.write(`Error: ${c.code}: ${c.message}
135
- `),CE(c.code);if(t.json)process.stdout.write(`${JSON.stringify(c)}
136
- `);else{let d=t.name??EE(a.path);if(t.groupFile){let l=c.uri.length>60?`${c.uri.slice(0,57)}...`:c.uri;process.stdout.write(`Sent group file ${d} (uri=${l})
137
- `)}else process.stdout.write(`Sent ${t.kind} ${d} (${AE(c.bytes)})
138
- `)}return 0}async function TE(t,e,r,s){let a=new AbortController,c=setTimeout(()=>a.abort(),s);try{let d=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 d.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=${d.status}): ${l.slice(0,200)}`}}finally{clearTimeout(c)}}function AE(t){return t<1024?`${t}B`:t<1024*1024?`${(t/1024).toFixed(1)}KB`:`${(t/1024/1024).toFixed(1)}MB`}var Fx=G("cli");function He(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 Oi(t,e){process.stderr.write(`[deprecated] '${t}' will be removed in a future release, use '${e}' instead
139
- `)}function $E(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 VE(e.slice(1));if(e[0]==="connect")return ZE(e.slice(1));if(e.includes("--status"))return Oi("--status","coze-bridge status"),{mode:"status"};if(e.includes("--stop"))return Oi("--stop","coze-bridge stop"),{mode:"stop"};if(e.includes("--refresh"))return Oi("--refresh","coze-bridge refresh"),{mode:"refresh"};if(e.includes("--uninstall"))return Oi("--uninstall","coze-bridge purge"),{mode:"purge"};if(e.includes("--install-service"))return Oi("--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}=He(r,"--pat-token");r=a;let{value:c,rest:d}=He(r,"--pair-code");r=d;let{value:l,rest:x}=He(r,"--env");r=x;let{value:p,rest:w}=He(r,"--handshake-url");r=w;let{value:v,rest:I}=He(r,"--frontier-url");r=I;let{value:b,rest:E}=He(r,"--mock-scenario");r=E;let{value:S}=He(r,"--agent-id");if(!s||!c)return{mode:"help"};let C={mode:"pair",privatecode:s,pairingCode:c};return l&&(C.env=l),p&&(C.handshakeUrl=p),v&&(C.frontierUrl=v),b&&(C.mockScenario=b),S&&(C.agentId=S),C}function VE(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}=He(s,"--caption");s=c;let{value:d,rest:l}=He(s,"--name");s=l;let{value:x,rest:p}=He(s,"--agent-id");s=p;let{value:w,rest:v}=He(s,"--session-id");s=v;let{value:I,rest:b}=He(s,"--mime");s=b;let E=s.includes("--group-file");s=s.filter(D=>D!=="--group-file");let S=s.includes("--json"),C={mode:"send",kind:e,path:r,json:S};return a&&(C.caption=a),d&&(C.name=d),x&&(C.agentId=x),w&&(C.sessionId=w),E&&(C.groupFile=!0),I&&(C.mimeType=I),C}function ZE(t){let e=t,{value:r,rest:s}=He(e,"--pat-token");e=s;let{value:a,rest:c}=He(e,"--env");e=c;let{value:d,rest:l}=He(e,"--handshake-url");e=l;let{value:x,rest:p}=He(e,"--frontier-url");e=p;let{value:w,rest:v}=He(e,"--mock-scenario");e=v;let I={mode:"connect"};return r&&(I.privatecode=r),a&&(I.env=a),d&&(I.handshakeUrl=d),x&&(I.frontierUrl=x),w&&(I.mockScenario=w),I}var JE=`
135
+ `),AE(c.code);if(t.json)process.stdout.write(`${JSON.stringify(c)}
136
+ `);else{let f=t.name??bE(o.path);if(t.groupFile){let u=c.uri.length>60?`${c.uri.slice(0,57)}...`:c.uri;process.stdout.write(`Sent group file ${f} (uri=${u})
137
+ `)}else process.stdout.write(`Sent ${t.kind} ${f} (${CE(c.bytes)})
138
+ `)}return 0}async function TE(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}),u=await f.text(),x=u?JSON.parse(u):null;return x&&typeof x=="object"&&"ok"in x?x:{ok:!1,code:"BRIDGE_INTERNAL",message:`unexpected daemon response (status=${f.status}): ${u.slice(0,200)}`}}finally{clearTimeout(c)}}function CE(t){return t<1024?`${t}B`:t<1024*1024?`${(t/1024).toFixed(1)}KB`:`${(t/1024/1024).toFixed(1)}MB`}var Fx=G("cli");function Fe(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 Di(t,e){process.stderr.write(`[deprecated] '${t}' will be removed in a future release, use '${e}' instead
139
+ `)}function $E(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 JE(e.slice(1));if(e[0]==="connect")return ZE(e.slice(1));if(e.includes("--status"))return Di("--status","coze-bridge status"),{mode:"status"};if(e.includes("--stop"))return Di("--stop","coze-bridge stop"),{mode:"stop"};if(e.includes("--refresh"))return Di("--refresh","coze-bridge refresh"),{mode:"refresh"};if(e.includes("--uninstall"))return Di("--uninstall","coze-bridge purge"),{mode:"purge"};if(e.includes("--install-service"))return Di("--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}=Fe(r,"--pat-token");r=o;let{value:c,rest:f}=Fe(r,"--pair-code");r=f;let{value:u,rest:x}=Fe(r,"--env");r=x;let{value:p,rest:_}=Fe(r,"--handshake-url");r=_;let{value:y,rest:A}=Fe(r,"--frontier-url");r=A;let{value:E,rest:v}=Fe(r,"--mock-scenario");r=v;let{value:S}=Fe(r,"--agent-id");if(!i||!c)return{mode:"help"};let I={mode:"pair",privatecode:i,pairingCode:c};return u&&(I.env=u),p&&(I.handshakeUrl=p),y&&(I.frontierUrl=y),E&&(I.mockScenario=E),S&&(I.agentId=S),I}function JE(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}=Fe(i,"--caption");i=c;let{value:f,rest:u}=Fe(i,"--name");i=u;let{value:x,rest:p}=Fe(i,"--agent-id");i=p;let{value:_,rest:y}=Fe(i,"--session-id");i=y;let{value:A,rest:E}=Fe(i,"--mime");i=E;let v=i.includes("--group-file");i=i.filter(D=>D!=="--group-file");let S=i.includes("--json"),I={mode:"send",kind:e,path:r,json:S};return o&&(I.caption=o),f&&(I.name=f),x&&(I.agentId=x),_&&(I.sessionId=_),v&&(I.groupFile=!0),A&&(I.mimeType=A),I}function ZE(t){let e=t,{value:r,rest:i}=Fe(e,"--pat-token");e=i;let{value:o,rest:c}=Fe(e,"--env");e=c;let{value:f,rest:u}=Fe(e,"--handshake-url");e=u;let{value:x,rest:p}=Fe(e,"--frontier-url");e=p;let{value:_,rest:y}=Fe(e,"--mock-scenario");e=y;let A={mode:"connect"};return r&&(A.privatecode=r),o&&(A.env=o),f&&(A.handshakeUrl=f),x&&(A.frontierUrl=x),_&&(A.mockScenario=_),A}var VE=`
140
140
  coze-bridge - local bridge daemon for cloud Agent Service
141
141
 
142
142
  Pair (paste from cloud UI; start/reuse daemon and deliver pair-code):
@@ -203,47 +203,46 @@ Deprecated flags (still work, but emit a warning; will be removed in a future re
203
203
 
204
204
  Internal:
205
205
  <node> <entry> --daemon daemon mode (OS supervisor only)
206
- `.trimStart();async function Ux(t=process.argv,e={}){let r=$E(t);switch(r.mode){case"help":return process.stdout.write(JE),0;case"version":return process.stdout.write(`${pr}
207
- `),0;case"daemon":{try{await Tx()}catch(s){return Fx.error("daemon start failed",{err:String(s)}),1}return new Promise(()=>{})}case"status":return YE(e);case"stop":return XE(e);case"refresh":return QE(e);case"purge":return ev(e);case"service-install":return tv(e);case"service-uninstall":return nv(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),rv(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),iv(r.privatecode,e,s)}case"send":return kx({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 Hx(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 YE(t){let e=t.paths??ne(),r=new Ht(e),s=await r.probe();if(s.kind==="not-running")return process.stdout.write(`coze-bridge: not running
208
- `),1;if(s.kind==="stale")return await Hx(e),process.stdout.write(`coze-bridge: not running (cleaned stale state)
209
- `),1;let a=await r.request({method:"GET",path:"/status"});return process.stdout.write(`coze-bridge: running
210
- ${JSON.stringify(a.body,null,2)}
211
- `),0}async function XE(t){let e=t.paths??ne(),r=new Ht(e),s=await r.probe();if(s.kind==="not-running")return process.stdout.write(`coze-bridge: not running
212
- `),0;if(s.kind==="stale")return await Hx(e),process.stdout.write(`coze-bridge: not running (cleaned stale state)
206
+ `.trimStart();async function Ux(t=process.argv,e={}){let r=$E(t);switch(r.mode){case"help":return process.stdout.write(VE),0;case"version":return process.stdout.write(`${xr}
207
+ `),0;case"daemon":{try{await Tx()}catch(i){return Fx.error("daemon start failed",{err:String(i)}),1}return new Promise(()=>{})}case"status":return YE(e);case"stop":return XE(e);case"refresh":return QE(e);case"purge":return eb(e);case"service-install":return tb(e);case"service-uninstall":return nb(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),rb(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),ib(r.privatecode,e,i)}case"send":return kx({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 Hx(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 YE(t){let e=t.paths??te(),r=new Ut(e),i=await r.probe();if(i.kind==="not-running")return process.stdout.write(`coze-bridge: not running
208
+ `),1;if(i.kind==="stale")return await Hx(e),process.stdout.write(`coze-bridge: not running (cleaned stale state)
209
+ `),1;let o=await r.request({method:"GET",path:"/status"});return process.stdout.write(`coze-bridge: running
210
+ ${JSON.stringify(o.body,null,2)}
211
+ `),0}async function XE(t){let e=t.paths??te(),r=new Ut(e),i=await r.probe();if(i.kind==="not-running")return process.stdout.write(`coze-bridge: not running
212
+ `),0;if(i.kind==="stale")return await Hx(e),process.stdout.write(`coze-bridge: not running (cleaned stale state)
213
213
  `),0;try{return await r.request({method:"POST",path:"/shutdown"}),process.stdout.write(`coze-bridge: stopped
214
- `),0}catch(a){return process.stdout.write(`coze-bridge: stop failed: ${String(a)}
215
- `),1}}async function QE(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)
216
- `),1;try{let s=await e.request({method:"POST",path:"/refresh",timeoutMs:35e3});return s.status===200?(process.stdout.write(`coze-bridge: refreshed
217
- ${JSON.stringify(s.body,null,2)}
218
- `),0):(process.stderr.write(`coze-bridge: refresh failed: ${JSON.stringify(s.body)}
219
- `),1)}catch(s){return process.stderr.write(`coze-bridge: refresh failed: ${String(s)}
220
- `),1}}async function i0(t){if(t.supervisor){let c=t.supervisor,d={nodeBin:"",entry:"",logFile:"",homeDir:"",userName:""};return{platform:c.platform,install:()=>c.install(d),uninstall:()=>c.uninstall(d)}}if(t.skipSupervisor)return;let{getSupervisor:e,buildContext:r}=await Promise.resolve().then(()=>(zx(),Bx)),s=e(),a=r();return{platform:s.platform,install:()=>s.install(a),uninstall:()=>s.uninstall(a)}}async function ev(t){let e=new Ht(t.paths);if((await e.probe()).kind==="connected"){process.stdout.write(`coze-bridge: stopping daemon...
221
- `);try{await e.request({method:"POST",path:"/shutdown"})}catch(d){process.stderr.write(`coze-bridge: stop failed (continuing): ${String(d)}
222
- `)}await new Promise(d=>setTimeout(d,500))}let s=await i0(t);if(s)try{await s.uninstall(),process.stdout.write(`coze-bridge: ${s.platform} supervisor unregistered
223
- `)}catch(d){process.stderr.write(`coze-bridge: supervisor uninstall failed (continuing): ${String(d)}
224
- `)}let a=t.paths??ne(),{rm:c}=await import("node:fs/promises");try{await c(a.bridgeRoot,{recursive:!0,force:!0}),process.stdout.write(`coze-bridge: removed ${a.bridgeRoot}
225
- `)}catch(d){return process.stderr.write(`coze-bridge: remove failed: ${String(d)}
214
+ `),0}catch(o){return process.stdout.write(`coze-bridge: stop failed: ${String(o)}
215
+ `),1}}async function QE(t){let e=new Ut(t.paths);if((await e.probe()).kind==="not-running")return process.stdout.write(`coze-bridge: not running (start daemon first)
216
+ `),1;try{let i=await e.request({method:"POST",path:"/refresh",timeoutMs:35e3});return i.status===200?(process.stdout.write(`coze-bridge: refreshed
217
+ ${JSON.stringify(i.body,null,2)}
218
+ `),0):(process.stderr.write(`coze-bridge: refresh failed: ${JSON.stringify(i.body)}
219
+ `),1)}catch(i){return process.stderr.write(`coze-bridge: refresh failed: ${String(i)}
220
+ `),1}}async function n0(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(()=>(zx(),Bx)),i=e(),o=r();return{platform:i.platform,install:()=>i.install(o),uninstall:()=>i.uninstall(o)}}async function eb(t){let e=new Ut(t.paths);if((await e.probe()).kind==="connected"){process.stdout.write(`coze-bridge: stopping daemon...
221
+ `);try{await e.request({method:"POST",path:"/shutdown"})}catch(f){process.stderr.write(`coze-bridge: stop failed (continuing): ${String(f)}
222
+ `)}await new Promise(f=>setTimeout(f,500))}let i=await n0(t);if(i)try{await i.uninstall(),process.stdout.write(`coze-bridge: ${i.platform} supervisor unregistered
223
+ `)}catch(f){process.stderr.write(`coze-bridge: supervisor uninstall failed (continuing): ${String(f)}
224
+ `)}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}
225
+ `)}catch(f){return process.stderr.write(`coze-bridge: remove failed: ${String(f)}
226
226
  `),1}return process.stdout.write(`coze-bridge: purged (agents workspaces preserved under ~/.coze/agents)
227
- `),0}async function tv(t){let e=await i0(t);if(!e)return 0;try{return process.stdout.write(`coze-bridge: installing ${e.platform} supervisor...
227
+ `),0}async function tb(t){let e=await n0(t);if(!e)return 0;try{return process.stdout.write(`coze-bridge: installing ${e.platform} supervisor...
228
228
  `),await e.install(),process.stdout.write(`coze-bridge: supervisor installed (daemon will auto-start on login)
229
229
  `),0}catch(r){return process.stderr.write(`coze-bridge: service install failed: ${String(r)}
230
- `),1}}async function nv(t){let e=await i0(t);if(!e)return 0;try{return await e.uninstall(),process.stdout.write(`coze-bridge: ${e.platform} supervisor unregistered
230
+ `),1}}async function nb(t){let e=await n0(t);if(!e)return 0;try{return await e.uninstall(),process.stdout.write(`coze-bridge: ${e.platform} supervisor unregistered
231
231
  `),0}catch(r){return process.stderr.write(`coze-bridge: service uninstall failed: ${String(r)}
232
- `),1}}async function rv(t,e,r,s={},a){let c=new Ht(r.paths),d=r.spawnDaemon??Vc;if(!r.skipDistInstall){let p=await Xc({paths:r.paths});p.kind==="version-changed"?(process.stdout.write(`coze-bridge: upgraded ${p.fromVersion} \u2192 ${p.toVersion}
233
- `),(await c.probe()).kind==="connected"&&(await c.request({method:"POST",path:"/shutdown"}).catch(()=>{}),await new Promise(v=>setTimeout(v,500)))):p.kind==="first-install"&&process.stdout.write(`coze-bridge: installed ${p.libVersion}
234
- `)}let l=await c.probe();if(l.kind!=="connected"&&(process.stdout.write(`coze-bridge: starting daemon...
235
- `),await d({paths:r.paths}),l=await qx(c,r.waitTimeoutMs??1e4,r.sleep??Gx),l.kind!=="connected"))return process.stderr.write(`coze-bridge: daemon did not come up: ${l.kind}
236
- `),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 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}
237
- `),1):(w?process.stdout.write(`\u5DF2\u914D\u5BF9\u8FDE\u63A5\u5B8C\u6210\uFF0C agent ${w.agentId} \u5DF2\u5C31\u7EEA
238
- `):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"
232
+ `),1}}async function rb(t,e,r,i={},o){let c=new Ut(r.paths),f=r.spawnDaemon??Wc;if(!r.skipDistInstall){let p=await Vc({paths:r.paths});p.kind==="version-changed"?(process.stdout.write(`coze-bridge: upgraded ${p.fromVersion} \u2192 ${p.toVersion}
233
+ `),(await c.probe()).kind==="connected"&&(await c.request({method:"POST",path:"/shutdown"}).catch(()=>{}),await new Promise(y=>setTimeout(y,500)))):p.kind==="first-install"&&process.stdout.write(`coze-bridge: installed ${p.libVersion}
234
+ `)}let u=await c.probe();if(u.kind!=="connected"&&(process.stdout.write(`coze-bridge: starting daemon...
235
+ `),await f({paths:r.paths}),u=await qx(c,r.waitTimeoutMs??1e4,r.sleep??Gx),u.kind!=="connected"))return process.stderr.write(`coze-bridge: daemon did not come up: ${u.kind}
236
+ `),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 _=p.body.agent;return _&&!_.ok?(process.stderr.write(`coze-bridge: paired but agent ensure failed (agentId=${_.agentId}): ${_.note}
237
+ `),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"
239
238
  `),0)}return process.stderr.write(`coze-bridge: pair failed: ${JSON.stringify(p.body)}
240
239
  `),1}catch(p){return process.stderr.write(`coze-bridge: pair failed: ${String(p)}
241
- `),1}}async function iv(t,e,r={}){let s=e.paths??ne(),a=t??await _x(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 Ht(e.paths),d=e.spawnDaemon??Vc;if(!e.skipDistInstall){let p=await Xc({paths:e.paths});p.kind==="version-changed"?(process.stdout.write(`coze-bridge: upgraded ${p.fromVersion} \u2192 ${p.toVersion}
242
- `),(await c.probe()).kind==="connected"&&(await c.request({method:"POST",path:"/shutdown"}).catch(()=>{}),await new Promise(v=>setTimeout(v,500)))):p.kind==="first-install"&&process.stdout.write(`coze-bridge: installed ${p.libVersion}
243
- `)}let l=await c.probe();if(l.kind!=="connected"&&(process.stdout.write(`coze-bridge: starting daemon...
244
- `),await d({paths:e.paths}),l=await qx(c,e.waitTimeoutMs??1e4,e.sleep??Gx),l.kind!=="connected"))return process.stderr.write(`coze-bridge: daemon did not come up: ${l.kind}
245
- `),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 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"})
246
- `),await ki(a,s).catch(w=>Fx.warn("writePatToken after connect failed (ignored)",{err:String(w)})),0):(process.stderr.write(`coze-bridge: connect failed: ${JSON.stringify(p.body)}
240
+ `),1}}async function ib(t,e,r={}){let i=e.paths??te(),o=t??await _x(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 Ut(e.paths),f=e.spawnDaemon??Wc;if(!e.skipDistInstall){let p=await Vc({paths:e.paths});p.kind==="version-changed"?(process.stdout.write(`coze-bridge: upgraded ${p.fromVersion} \u2192 ${p.toVersion}
241
+ `),(await c.probe()).kind==="connected"&&(await c.request({method:"POST",path:"/shutdown"}).catch(()=>{}),await new Promise(y=>setTimeout(y,500)))):p.kind==="first-install"&&process.stdout.write(`coze-bridge: installed ${p.libVersion}
242
+ `)}let u=await c.probe();if(u.kind!=="connected"&&(process.stdout.write(`coze-bridge: starting daemon...
243
+ `),await f({paths:e.paths}),u=await qx(c,e.waitTimeoutMs??1e4,e.sleep??Gx),u.kind!=="connected"))return process.stderr.write(`coze-bridge: daemon did not come up: ${u.kind}
244
+ `),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"})
245
+ `),await Ri(o,i).catch(_=>Fx.warn("writePatToken after connect failed (ignored)",{err:String(_)})),0):(process.stderr.write(`coze-bridge: connect failed: ${JSON.stringify(p.body)}
247
246
  `),1)}catch(p){return process.stderr.write(`coze-bridge: connect failed: ${String(p)}
248
- `),1}}async function qx(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 Gx(t){return new Promise(e=>setTimeout(e,t))}te();!process.argv.includes("--daemon")&&!process.env.COZE_BRIDGE_LOG_LEVEL&&T0("warn");Ux(process.argv).then(t=>process.exit(t),t=>{process.stderr.write(`fatal: ${t instanceof Error?t.stack??t.message:String(t)}
247
+ `),1}}async function qx(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 Gx(t){return new Promise(e=>setTimeout(e,t))}ee();!process.argv.includes("--daemon")&&!process.env.COZE_BRIDGE_LOG_LEVEL&&T0("warn");Ux(process.argv).then(t=>process.exit(t),t=>{process.stderr.write(`fatal: ${t instanceof Error?t.stack??t.message:String(t)}
249
248
  `),process.exit(1)});