coze-bridge 0.1.95-beta.0 → 0.1.95
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.
- package/dist/index.js +78 -78
- package/package.json +1 -1
package/dist/index.js
CHANGED
|
@@ -5,34 +5,34 @@ 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 Ap=Object.create;var
|
|
9
|
-
`)),this.stream=
|
|
10
|
-
`),this.stream=void 0;return}this.currentDate!==void 0&&
|
|
11
|
-
`;zp(t,{recursive:!0}),Bp(Fp(t,
|
|
12
|
-
`;if(
|
|
13
|
-
`),{cause:o})}}async function Vp(t){let e=
|
|
14
|
-
`,o=`${t}.tmp-${process.pid}-${Math.random().toString(36).slice(2,10)}`;try{r?.mode!==void 0?await fl(o,i,{encoding:"utf8",mode:r.mode}):await fl(o,i,"utf8"),await ul(o,t),r?.mode!==void 0&&await Qp(t,r.mode)}catch(c){await ul(o,o).catch(()=>{});let{rm:l}=await import("node:fs/promises");throw await l(o,{force:!0}).catch(()=>{}),c}}var $r=Ve(()=>{"use strict"});import{promises as xl,readdirSync as rg}from"node:fs";import{homedir as ig}from"node:os";import{sep as sg,join as Ie,resolve as hl}from"node:path";function Q(t){let e=t??ig(),r=Ie(e,".coze"),i=Ie(r,"bridge"),o=Ie(i,"lib"),c=Ie(i,"logs");return{cozeRoot:r,bridgeRoot:i,libDir:o,libEntry:Ie(o,"index.js"),binDir:Ie(i,"bin"),pidFile:Ie(i,"bridge.pid"),portFile:Ie(i,"bridge.port"),tokenFile:Ie(i,"bridge.token"),patTokenFile:Ie(i,"pat-token"),agentEnvFile:Ie(i,"agent-env.json"),logFile:Ie(i,"bridge.log"),bridgeLogsDir:c,daemonStdioLog:Ie(c,"daemon-stdio.log"),installLock:Ie(i,"install.lock"),configFile:Ie(i,"config.json"),agentsRoot:Ie(r,"agents")}}function Ye(t,e=Q()){let r=Ie(e.agentsRoot,t);return{root:r,config:Ie(r,"config.json"),workspace:Ie(r,"workspace"),logs:Ie(r,"logs")}}function rs(t=Q()){try{return rg(t.agentsRoot,{withFileTypes:!0}).filter(e=>e.isDirectory()).map(e=>e.name)}catch{return[]}}async function Jr(t,e){let r=await xl.realpath(hl(t)).catch(()=>null);if(!r)return!1;let i=await xl.realpath(hl(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+sg)}var De=Ve(()=>{"use strict"});var os={};ha(os,{AGENT_CONFIG_FILE_MODE:()=>is,enforceAgentConfigMode:()=>cg,loadAgentConfig:()=>Ge,persistAgentSessions:()=>Vr,persistAgentSkills:()=>ss,saveAgentConfig:()=>Ze});import{chmod as og,stat as ag}from"node:fs/promises";function Ge(t,e){return Qn(Ye(t,e).config)}function Ze(t,e){return er(Ye(t.agentId,e).config,t,{mode:is})}async function cg(t,e){if(process.platform==="win32")return;let r=Ye(t,e).config;try{let i=await ag(r);if(!i.isFile())return;let o=i.mode&511;o!==is&&(await og(r,is),pl.warn("agent config mode auto-corrected to 0600",{path:r,from:o.toString(8)}))}catch(i){if(i.code==="ENOENT")return;pl.warn("enforceAgentConfigMode: chmod failed (ignored)",{path:r,err:String(i)})}}async function Vr(t,e,r){let i=await Ge(t,r);i&&(i.sessions=Object.fromEntries(e),await Ze(i,r))}async function ss(t,e,r){let i=await Ge(t,r);i&&(i.skills=e,await Ze(i,r))}var pl,is,en=Ve(()=>{"use strict";$r();ne();De();pl=H("agent-config"),is=384});var Ea=se((T2,_l)=>{_l.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 cs=se(bl=>{var yl={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 xg(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(yl))bl[t]=xg(yl[t])});var Al=se((R2,Il)=>{var hg=de("fs"),ke=de("path"),El=Ea(),pg=cs(),gg=typeof process=="object"&&process.platform==="win32",vl=t=>typeof t=="object"&&t!==null,Sl=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 ye(t){this.sep=ke.sep,this.fs=hg,vl(t)&&vl(t.fs)&&typeof t.fs.statSync=="function"&&(this.fs=t.fs)}Il.exports=ye;ye.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 l;try{l=e.fs.statSync(o)}catch(u){if(u.message&&u.message.startsWith("ENOENT"))e.fs.mkdirSync(o);else throw u}if(l&&l.isFile())throw pg.FILE_IN_THE_WAY(`"${o}"`)}})}r(t)};ye.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 l=ke.dirname(t);o.fs.existsSync(l)||o.makeDir(l);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};ye.prototype.writeFileToAsync=function(t,e,r,i,o){typeof i=="function"&&(o=i,i=void 0);let c=this;c.fs.exists(t,function(l){if(l&&!r)return o(!1);c.fs.stat(t,function(u,x){if(l&&x.isDirectory())return o(!1);var p=ke.dirname(t);c.fs.exists(p,function(m){m||c.makeDir(p),c.fs.open(t,"w",438,function(b,I){b?c.fs.chmod(t,438,function(){c.fs.open(t,"w",438,function(y,E){c.fs.write(E,e,0,e.length,0,function(){c.fs.close(E,function(){c.fs.chmod(t,i||438,function(){o(!0)})})})})}):I?c.fs.write(I,e,0,e.length,0,function(){c.fs.close(I,function(){c.fs.chmod(t,i||438,function(){o(!0)})})}):c.fs.chmod(t,i||438,function(){o(!0)})})})})})};ye.prototype.findFiles=function(t){let e=this;function r(i,o,c){typeof o=="boolean"&&(c=o,o=void 0);let l=[];return e.fs.readdirSync(i).forEach(function(u){let x=ke.join(i,u),p=e.fs.statSync(x);(!o||o.test(x))&&l.push(ke.normalize(x)+(p.isDirectory()?e.sep:"")),p.isDirectory()&&c&&(l=l.concat(r(x,o,c)))}),l}return r(t,void 0,!0)};ye.prototype.findFilesAsync=function(t,e){let r=this,i=[];r.fs.readdir(t,function(o,c){if(o)return e(o);let l=c.length;if(!l)return e(null,i);c.forEach(function(u){u=ke.join(t,u),r.fs.stat(u,function(x,p){if(x)return e(x);p&&(i.push(ke.normalize(u)+(p.isDirectory()?r.sep:"")),p.isDirectory()?r.findFilesAsync(u,function(m,b){if(m)return e(m);i=i.concat(b),--l||e(null,i)}):--l||e(null,i))})})})};ye.prototype.getAttributes=function(){};ye.prototype.setAttributes=function(){};ye.crc32update=function(t,e){return Sl[(t^e)&255]^t>>>8};ye.crc32=function(t){typeof t=="string"&&(t=Buffer.from(t,"utf8"));let e=t.length,r=-1;for(let i=0;i<e;)r=ye.crc32update(r,t[i++]);return~r>>>0};ye.methodToString=function(t){switch(t){case El.STORED:return"STORED ("+t+")";case El.DEFLATED:return"DEFLATED ("+t+")";default:return"UNSUPPORTED ("+t+")"}};ye.canonical=function(t){if(!t)return"";let e=ke.posix.normalize("/"+t.split("\\").join("/"));return ke.join(".",e)};ye.zipnamefix=function(t){if(!t)return"";let e=ke.posix.normalize("/"+t.split("\\").join("/"));return ke.posix.join(".",e)};ye.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]};ye.sanitize=function(t,e){t=ke.resolve(ke.normalize(t));for(var r=e.split("/"),i=0,o=r.length;i<o;i++){var c=ke.normalize(ke.join(t,r.slice(i,o).join(ke.sep)));if(c.indexOf(t)===0)return c}return ke.normalize(ke.join(t,ke.basename(e)))};ye.toBuffer=function(e,r){return Buffer.isBuffer(e)?e:e instanceof Uint8Array?Buffer.from(e):typeof e=="string"?r(e):Buffer.alloc(0)};ye.readBigUInt64LE=function(t,e){let r=t.readUInt32LE(e);return t.readUInt32LE(e+4)*4294967296+r};ye.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)};ye.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};ye.isWin=gg;ye.crcTable=Sl});var Cl=se((D2,Tl)=>{var mg=de("path");Tl.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=mg.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 Dl=se((k2,Rl)=>{Rl.exports={efs:!0,encode:t=>Buffer.from(t,"utf8"),decode:t=>t.toString("utf8")}});var rr=se((P2,nr)=>{nr.exports=Al();nr.exports.Constants=Ea();nr.exports.Errors=cs();nr.exports.FileAttr=Cl();nr.exports.decoder=Dl()});var Pl=se((L2,kl)=>{var tn=rr(),U=tn.Constants;kl.exports=function(){var t=20,e=10,r=0,i=0,o=0,c=0,l=0,u=0,x=0,p=0,m=0,b=0,I=0,y=0,E=0;t|=tn.isWin?2560:768,r|=U.FLG_EFS;let S={extraLen:0},A=_=>Math.max(0,_)>>>0,D=_=>Math.max(0,_)&65535,L=_=>Math.max(0,_)&255;return o=tn.fromDate2DOS(new Date),{get made(){return t},set made(_){t=_},get version(){return e},set version(_){e=_},get flags(){return r},set flags(_){r=_},get flags_efs(){return(r&U.FLG_EFS)>0},set flags_efs(_){_?r|=U.FLG_EFS:r&=~U.FLG_EFS},get flags_desc(){return(r&U.FLG_DESC)>0},set flags_desc(_){_?r|=U.FLG_DESC:r&=~U.FLG_DESC},get method(){return i},set method(_){switch(_){case U.STORED:this.version=10;case U.DEFLATED:default:this.version=20}i=_},get time(){return tn.fromDOS2Date(this.timeval)},set time(_){_=new Date(_),this.timeval=tn.fromDate2DOS(_)},get timeval(){return o},set timeval(_){o=A(_)},get timeHighByte(){return L(o>>>8)},get crc(){return c},set crc(_){c=A(_)},get compressedSize(){return l},set compressedSize(_){l=A(_)},get size(){return u},set size(_){u=A(_)},get fileNameLength(){return x},set fileNameLength(_){x=_},get extraLength(){return p},set extraLength(_){p=_},get extraLocalLength(){return S.extraLen},set extraLocalLength(_){S.extraLen=_},get commentLength(){return m},set commentLength(_){m=_},get diskNumStart(){return b},set diskNumStart(_){b=A(_)},get inAttr(){return I},set inAttr(_){I=A(_)},get attr(){return y},set attr(_){y=A(_)},get fileAttr(){return(y||0)>>16&4095},get offset(){return E},set offset(_){E=A(_)},get encrypted(){return(r&U.FLG_ENC)===U.FLG_ENC},get centralHeaderSize(){return U.CENHDR+x+p+m},get realDataOffset(){return E+U.LOCHDR+S.fnameLen+S.extraLen},get localHeader(){return S},loadLocalHeaderFromBinary:function(_){var R=_.slice(E,E+U.LOCHDR);if(R.readUInt32LE(0)!==U.LOCSIG)throw tn.Errors.INVALID_LOC();S.version=R.readUInt16LE(U.LOCVER),S.flags=R.readUInt16LE(U.LOCFLG),S.flags_desc=(S.flags&U.FLG_DESC)>0,S.method=R.readUInt16LE(U.LOCHOW),S.time=R.readUInt32LE(U.LOCTIM),S.crc=R.readUInt32LE(U.LOCCRC),S.compressedSize=R.readUInt32LE(U.LOCSIZ),S.size=R.readUInt32LE(U.LOCLEN),S.fnameLen=R.readUInt16LE(U.LOCNAM),S.extraLen=R.readUInt16LE(U.LOCEXT);let k=E+U.LOCHDR+S.fnameLen,z=k+S.extraLen;return _.slice(k,z)},loadFromBinary:function(_){if(_.length!==U.CENHDR||_.readUInt32LE(0)!==U.CENSIG)throw tn.Errors.INVALID_CEN();t=_.readUInt16LE(U.CENVEM),e=_.readUInt16LE(U.CENVER),r=_.readUInt16LE(U.CENFLG),i=_.readUInt16LE(U.CENHOW),o=_.readUInt32LE(U.CENTIM),c=_.readUInt32LE(U.CENCRC),l=_.readUInt32LE(U.CENSIZ),u=_.readUInt32LE(U.CENLEN),x=_.readUInt16LE(U.CENNAM),p=_.readUInt16LE(U.CENEXT),m=_.readUInt16LE(U.CENCOM),b=_.readUInt16LE(U.CENDSK),I=_.readUInt16LE(U.CENATT),y=_.readUInt32LE(U.CENATX),E=_.readUInt32LE(U.CENOFF)},localHeaderToBinary:function(){var _=Buffer.alloc(U.LOCHDR);return _.writeUInt32LE(U.LOCSIG,0),_.writeUInt16LE(e,U.LOCVER),_.writeUInt16LE(r,U.LOCFLG),_.writeUInt16LE(i,U.LOCHOW),_.writeUInt32LE(o,U.LOCTIM),_.writeUInt32LE(c,U.LOCCRC),_.writeUInt32LE(l,U.LOCSIZ),_.writeUInt32LE(u,U.LOCLEN),_.writeUInt16LE(x,U.LOCNAM),_.writeUInt16LE(S.extraLen,U.LOCEXT),_},centralHeaderToBinary:function(){var _=Buffer.alloc(U.CENHDR+x+p+m);return _.writeUInt32LE(U.CENSIG,0),_.writeUInt16LE(t,U.CENVEM),_.writeUInt16LE(e,U.CENVER),_.writeUInt16LE(r,U.CENFLG),_.writeUInt16LE(i,U.CENHOW),_.writeUInt32LE(o,U.CENTIM),_.writeUInt32LE(c,U.CENCRC),_.writeUInt32LE(l,U.CENSIZ),_.writeUInt32LE(u,U.CENLEN),_.writeUInt16LE(x,U.CENNAM),_.writeUInt16LE(p,U.CENEXT),_.writeUInt16LE(m,U.CENCOM),_.writeUInt16LE(b,U.CENDSK),_.writeUInt16LE(I,U.CENATT),_.writeUInt32LE(y,U.CENATX),_.writeUInt32LE(E,U.CENOFF),_},toJSON:function(){let _=function(R){return R+" bytes"};return{made:t,version:e,flags:r,method:tn.methodToString(i),time:this.time,crc:"0x"+c.toString(16).toUpperCase(),compressedSize:_(l),size:_(u),fileNameLength:_(x),extraLength:_(p),commentLength:_(m),diskNumStart:b,inAttr:I,attr:y,offset:E,centralHeaderSize:_(U.CENHDR+x+p+m)}},toString:function(){return JSON.stringify(this.toJSON(),null," ")}}}});var Ol=se((O2,Ll)=>{var ir=rr(),ge=ir.Constants;Ll.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 ge.ENDHDR+o},loadFromBinary:function(c){if((c.length!==ge.ENDHDR||c.readUInt32LE(0)!==ge.ENDSIG)&&(c.length<ge.ZIP64HDR||c.readUInt32LE(0)!==ge.ZIP64SIG))throw ir.Errors.INVALID_END();c.readUInt32LE(0)===ge.ENDSIG?(t=c.readUInt16LE(ge.ENDSUB),e=c.readUInt16LE(ge.ENDTOT),r=c.readUInt32LE(ge.ENDSIZ),i=c.readUInt32LE(ge.ENDOFF),o=c.readUInt16LE(ge.ENDCOM)):(t=ir.readBigUInt64LE(c,ge.ZIP64SUB),e=ir.readBigUInt64LE(c,ge.ZIP64TOT),r=ir.readBigUInt64LE(c,ge.ZIP64SIZE),i=ir.readBigUInt64LE(c,ge.ZIP64OFF),o=0)},toBinary:function(){var c=Buffer.alloc(ge.ENDHDR+o);return c.writeUInt32LE(ge.ENDSIG,0),c.writeUInt32LE(0,4),c.writeUInt16LE(t,ge.ENDSUB),c.writeUInt16LE(e,ge.ENDTOT),c.writeUInt32LE(r,ge.ENDSIZ),c.writeUInt32LE(i,ge.ENDOFF),c.writeUInt16LE(o,ge.ENDCOM),c.fill(" ",ge.ENDHDR),c},toJSON:function(){let c=function(l,u){let x=l.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 Sa=se(va=>{va.EntryHeader=Pl();va.MainHeader=Ol()});var Ml=se((M2,Nl)=>{Nl.exports=function(t){var e=de("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=[],l=0;o.on("data",function(u){c.push(u),l+=u.length}),o.on("end",function(){var u=Buffer.alloc(l),x=0;u.fill(0);for(var p=0;p<c.length;p++){var m=c[p];m.copy(u,x),x+=m.length}i&&i(u)}),o.end(t)}}}});var zl=se((B2,Bl)=>{var wg=+(process.versions?process.versions.node:"").split(".")[0]||0;Bl.exports=function(t,e){var r=de("zlib");let i=wg>=15&&e>0?{maxOutputLength:e}:{};return{inflate:function(){return r.inflateRawSync(t,i)},inflateAsync:function(o){var c=r.createInflateRaw(i),l=[],u=0;c.on("data",function(x){l.push(x),u+=x.length}),c.on("end",function(){var x=Buffer.alloc(u),p=0;x.fill(0);for(var m=0;m<l.length;m++){var b=l[m];b.copy(x,p),p+=b.length}o&&o(x)}),c.end(t)}}}});var Gl=se((z2,ql)=>{"use strict";var{randomFillSync:Fl}=de("crypto"),_g=cs(),yg=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}),Hl=(t,e)=>Math.imul(t,e)>>>0,Ul=(t,e)=>yg[(t^e)&255]^t>>>8,Yr=()=>typeof Fl=="function"?Fl(Buffer.alloc(12)):Yr.node();Yr.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 ds={genSalt:Yr};function ls(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])}ls.prototype.updateKeys=function(t){let e=this.keys;return e[0]=Ul(e[0],t),e[1]+=e[0]&255,e[1]=Hl(e[1],134775813)+1,e[2]=Ul(e[2],e[1]>>>24),t};ls.prototype.next=function(){let t=(this.keys[2]|2)>>>0;return Hl(t,t^1)>>8&255};function bg(t){let e=new ls(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 Eg(t){let e=new ls(t);return function(r,i,o=0){i||(i=Buffer.alloc(r.length));for(let c of r){let l=e.next();i[o++]=c^l,e.updateKeys(c)}return i}}function vg(t,e,r){if(!t||!Buffer.isBuffer(t)||t.length<12)return Buffer.alloc(0);let i=bg(r),o=i(t.slice(0,12)),c=(e.flags&8)===8?e.timeHighByte:e.crc>>>24;if(o[11]!==c)throw _g.WRONG_PASSWORD();return i(t.slice(12))}function Sg(t){Buffer.isBuffer(t)&&t.length>=12?ds.genSalt=function(){return t.slice(0,12)}:t==="node"?ds.genSalt=Yr.node:ds.genSalt=Yr}function Ig(t,e,r,i=!1){t==null&&(t=Buffer.alloc(0)),Buffer.isBuffer(t)||(t=Buffer.from(t.toString()));let o=Eg(r),c=ds.genSalt();c[11]=e.crc>>>24&255,i&&(c[10]=e.crc>>>16&255);let l=Buffer.alloc(t.length+12);return o(c,l),o(t,l,12)}ql.exports={decrypt:vg,encrypt:Ig,_salter:Sg}});var jl=se(us=>{us.Deflater=Ml();us.Inflater=zl();us.ZipCrypto=Gl()});var Aa=se((U2,Wl)=>{var oe=rr(),Ag=Sa(),be=oe.Constants,Ia=jl();Wl.exports=function(t,e){var r=new Ag.EntryHeader,i=Buffer.alloc(0),o=Buffer.alloc(0),c=!1,l=null,u=Buffer.alloc(0),x=Buffer.alloc(0),p=!0;let m=t,b=typeof m.decoder=="object"?m.decoder:oe.decoder;p=b.hasOwnProperty("efs")?b.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 y(_){if(!r.flags_desc&&!r.localHeader.flags_desc){if(oe.crc32(_)!==r.localHeader.crc)return!1}else{let R={},k=r.realDataOffset+r.compressedSize;if(e.readUInt32LE(k)==be.LOCSIG||e.readUInt32LE(k)==be.CENSIG)throw oe.Errors.DESCRIPTOR_NOT_EXIST();if(e.readUInt32LE(k)==be.EXTSIG)R.crc=e.readUInt32LE(k+be.EXTCRC),R.compressedSize=e.readUInt32LE(k+be.EXTSIZ),R.size=e.readUInt32LE(k+be.EXTLEN);else if(e.readUInt16LE(k+12)===19280)R.crc=e.readUInt32LE(k+be.EXTCRC-4),R.compressedSize=e.readUInt32LE(k+be.EXTSIZ-4),R.size=e.readUInt32LE(k+be.EXTLEN-4);else throw oe.Errors.DESCRIPTOR_UNKNOWN();if(R.compressedSize!==r.compressedSize||R.size!==r.size||R.crc!==r.crc)throw oe.Errors.DESCRIPTOR_FAULTY();if(oe.crc32(_)!==R.crc)return!1}return!0}function E(_,R,k){if(typeof R>"u"&&typeof _=="string"&&(k=_,_=void 0),c)return _&&R&&R(Buffer.alloc(0),oe.Errors.DIRECTORY_CONTENT_ERROR()),Buffer.alloc(0);var z=I();if(z.length===0)return _&&R&&R(z),z;if(r.encrypted){if(typeof k!="string"&&!Buffer.isBuffer(k))throw oe.Errors.INVALID_PASS_PARAM();z=Ia.ZipCrypto.decrypt(z,r,k)}var F=Buffer.alloc(r.size);switch(r.method){case oe.Constants.STORED:if(z.copy(F),y(F))return _&&R&&R(F),F;throw _&&R&&R(F,oe.Errors.BAD_CRC()),oe.Errors.BAD_CRC();case oe.Constants.DEFLATED:var V=new Ia.Inflater(z,r.size);if(_)V.inflateAsync(function(J){J.copy(J,0),R&&(y(J)?R(J):R(J,oe.Errors.BAD_CRC()))});else{if(V.inflate(F).copy(F,0),!y(F))throw oe.Errors.BAD_CRC(`"${b.decode(i)}"`);return F}break;default:throw _&&R&&R(Buffer.alloc(0),oe.Errors.UNKNOWN_METHOD()),oe.Errors.UNKNOWN_METHOD()}}function S(_,R){if((!l||!l.length)&&Buffer.isBuffer(e))return _&&R&&R(I()),I();if(l.length&&!c){var k;switch(r.method){case oe.Constants.STORED:return r.compressedSize=r.size,k=Buffer.alloc(l.length),l.copy(k),_&&R&&R(k),k;default:case oe.Constants.DEFLATED:var z=new Ia.Deflater(l);if(_)z.deflateAsync(function(V){k=Buffer.alloc(V.length),r.compressedSize=V.length,V.copy(k),R&&R(k)});else{var F=z.deflate();return r.compressedSize=F.length,F}z=null;break}}else if(_&&R)R(Buffer.alloc(0));else return Buffer.alloc(0)}function A(_,R){return oe.readBigUInt64LE(_,R)}function D(_){try{for(var R=0,k,z,F;R+4<_.length;)k=_.readUInt16LE(R),R+=2,z=_.readUInt16LE(R),R+=2,F=_.slice(R,R+z),R+=z,be.ID_ZIP64===k&&L(F)}catch{throw oe.Errors.EXTRA_FIELD_PARSE_ERROR()}}function L(_){var R,k,z,F;_.length>=be.EF_ZIP64_SCOMP&&(R=A(_,be.EF_ZIP64_SUNCOMP),r.size===be.EF_ZIP64_OR_32&&(r.size=R)),_.length>=be.EF_ZIP64_RHO&&(k=A(_,be.EF_ZIP64_SCOMP),r.compressedSize===be.EF_ZIP64_OR_32&&(r.compressedSize=k)),_.length>=be.EF_ZIP64_DSN&&(z=A(_,be.EF_ZIP64_RHO),r.offset===be.EF_ZIP64_OR_32&&(r.offset=z)),_.length>=be.EF_ZIP64_DSN+4&&(F=_.readUInt32LE(be.EF_ZIP64_DSN),r.diskNumStart===be.EF_ZIP64_OR_16&&(r.diskNumStart=F))}return{get entryName(){return b.decode(i)},get rawEntryName(){return i},set entryName(_){i=oe.toBuffer(_,b.encode);var R=i[i.length-1];c=R===47||R===92,r.fileNameLength=i.length},get efs(){return typeof p=="function"?p(this.entryName):p},get extra(){return u},set extra(_){u=_,r.extraLength=_.length,D(_)},get comment(){return b.decode(o)},set comment(_){if(o=oe.toBuffer(_,b.encode),r.commentLength=o.length,o.length>65535)throw oe.Errors.COMMENT_TOO_LONG()},get name(){var _=b.decode(i);return c?_.substr(_.length-1).split("/").pop():_.split("/").pop()},get isDirectory(){return c},getCompressedData:function(){return S(!1,null)},getCompressedDataAsync:function(_){S(!0,_)},setData:function(_){l=oe.toBuffer(_,oe.decoder.encode),!c&&l.length?(r.size=l.length,r.method=oe.Constants.DEFLATED,r.crc=oe.crc32(_),r.changed=!0):r.method=oe.Constants.STORED},getData:function(_){return r.changed?l:E(!1,null,_)},getDataAsync:function(_,R){r.changed?_(l):E(!0,_,R)},set attr(_){r.attr=_},get attr(){return r.attr},set header(_){r.loadFromBinary(_)},get header(){return r},packCentralHeader:function(){r.flags_efs=this.efs,r.extraLength=u.length;var _=r.centralHeaderToBinary(),R=oe.Constants.CENHDR;return i.copy(_,R),R+=i.length,u.copy(_,R),R+=r.extraLength,o.copy(_,R),_},packLocalHeader:function(){let _=0;r.flags_efs=this.efs,r.extraLocalLength=x.length;let R=r.localHeaderToBinary(),k=Buffer.alloc(R.length+i.length+r.extraLocalLength);return R.copy(k,_),_+=R.length,i.copy(k,_),_+=i.length,x.copy(k,_),_+=x.length,k},toJSON:function(){let _=function(R){return"<"+(R&&R.length+" bytes buffer"||"null")+">"};return{entryName:this.entryName,name:this.name,comment:this.comment,isDirectory:this.isDirectory,header:r.toJSON(),compressedData:_(e),data:_(l)}},toString:function(){return JSON.stringify(this.toJSON(),null," ")}}}});var Jl=se((H2,$l)=>{var Kl=Aa(),Tg=Sa(),je=rr();$l.exports=function(t,e){var r=[],i={},o=Buffer.alloc(0),c=new Tg.MainHeader,l=!1,u=null;let x=new Set,p=e,{noSort:m,decoder:b}=p;t?E(p.readEntries):l=!0;function I(){let A=new Set;for(let D of Object.keys(i)){let L=D.split("/");if(L.pop(),!!L.length)for(let _=0;_<L.length;_++){let R=L.slice(0,_+1).join("/")+"/";A.add(R)}}for(let D of A)if(!(D in i)){let L=new Kl(p);L.entryName=D,L.attr=16,L.temporary=!0,r.push(L),i[L.entryName]=L,x.add(L)}}function y(){if(l=!0,i={},c.diskEntries>(t.length-c.offset)/je.Constants.CENHDR)throw je.Errors.DISK_ENTRY_TOO_LARGE();r=new Array(c.diskEntries);for(var A=c.offset,D=0;D<r.length;D++){var L=A,_=new Kl(p,t);_.header=t.slice(L,L+=je.Constants.CENHDR),_.entryName=t.slice(L,L+=_.header.fileNameLength),_.header.extraLength&&(_.extra=t.slice(L,L+=_.header.extraLength)),_.header.commentLength&&(_.comment=t.slice(L,L+_.header.commentLength)),A+=_.header.centralHeaderSize,r[D]=_,i[_.entryName]=_}x.clear(),I()}function E(A){var D=t.length-je.Constants.ENDHDR,L=Math.max(0,D-65535),_=L,R=t.length,k=-1,z=0;for(typeof p.trailingSpace=="boolean"&&p.trailingSpace&&(L=0),D;D>=_;D--)if(t[D]===80){if(t.readUInt32LE(D)===je.Constants.ENDSIG){k=D,z=D,R=D+je.Constants.ENDHDR,_=D-je.Constants.END64HDR;continue}if(t.readUInt32LE(D)===je.Constants.END64SIG){_=L;continue}if(t.readUInt32LE(D)===je.Constants.ZIP64SIG){k=D,R=D+je.readBigUInt64LE(t,D+je.Constants.ZIP64SIZE)+je.Constants.ZIP64LEAD;break}}if(k==-1)throw je.Errors.INVALID_FORMAT();c.loadFromBinary(t.slice(k,R)),c.commentLength&&(o=t.slice(z+je.Constants.ENDHDR)),A&&y()}function S(){r.length>1&&!m&&r.sort((A,D)=>A.entryName.toLowerCase().localeCompare(D.entryName.toLowerCase()))}return{get entries(){return l||y(),r.filter(A=>!x.has(A))},get comment(){return b.decode(o)},set comment(A){o=je.toBuffer(A,b.encode),c.commentLength=o.length},getEntryCount:function(){return l?r.length:c.diskEntries},forEach:function(A){this.entries.forEach(A)},getEntry:function(A){return l||y(),i[A]||null},setEntry:function(A){l||y(),r.push(A),i[A.entryName]=A,c.totalEntries=r.length},deleteFile:function(A,D=!0){l||y();let L=i[A];this.getEntryChildren(L,D).map(R=>R.entryName).forEach(this.deleteEntry)},deleteEntry:function(A){l||y();let D=i[A],L=r.indexOf(D);L>=0&&(r.splice(L,1),delete i[A],c.totalEntries=r.length)},getEntryChildren:function(A,D=!0){if(l||y(),typeof A=="object")if(A.isDirectory&&D){let L=[],_=A.entryName;for(let R of r)R.entryName.startsWith(_)&&L.push(R);return L}else return[A];return[]},getChildCount:function(A){if(A&&A.isDirectory){let D=this.getEntryChildren(A);return D.includes(A)?D.length-1:D.length}return 0},compressToBuffer:function(){l||y(),S();let A=[],D=[],L=0,_=0;c.size=0,c.offset=0;let R=0;for(let F of this.entries){let V=F.getCompressedData();F.header.offset=_;let J=F.packLocalHeader(),ee=J.length+V.length;_+=ee,A.push(J),A.push(V);let X=F.packCentralHeader();D.push(X),c.size+=X.length,L+=ee+X.length,R++}L+=c.mainHeaderSize,c.offset=_,c.totalEntries=R,_=0;let k=Buffer.alloc(L);for(let F of A)F.copy(k,_),_+=F.length;for(let F of D)F.copy(k,_),_+=F.length;let z=c.toBinary();return o&&o.copy(z,je.Constants.ENDHDR),z.copy(k,_),t=k,l=!1,k},toAsyncBuffer:function(A,D,L,_){try{l||y(),S();let R=[],k=[],z=0,F=0,V=0;c.size=0,c.offset=0;let J=function(ee){if(ee.length>0){let X=ee.shift(),ve=X.entryName+X.extra.toString();L&&L(ve),X.getCompressedDataAsync(function(Ne){_&&_(ve),X.header.offset=F;let O=X.packLocalHeader(),G=O.length+Ne.length;F+=G,R.push(O),R.push(Ne);let W=X.packCentralHeader();k.push(W),c.size+=W.length,z+=G+W.length,V++,J(ee)})}else{z+=c.mainHeaderSize,c.offset=F,c.totalEntries=V,F=0;let X=Buffer.alloc(z);R.forEach(function(Ne){Ne.copy(X,F),F+=Ne.length}),k.forEach(function(Ne){Ne.copy(X,F),F+=Ne.length});let ve=c.toBinary();o&&o.copy(ve,je.Constants.ENDHDR),ve.copy(X,F),t=X,l=!1,A(X)}};J(Array.from(this.entries))}catch(R){D(R)}}}}});var Zl=se((q2,Yl)=>{var we=rr(),me=de("path"),Cg=Aa(),Rg=Jl(),In=(...t)=>we.findLast(t,e=>typeof e=="boolean"),Vl=(...t)=>we.findLast(t,e=>typeof e=="string"),Dg=(...t)=>we.findLast(t,e=>typeof e=="function"),kg={noSort:!1,readEntries:!1,method:we.Constants.NONE,fs:null};Yl.exports=function(t,e){let r=null,i=Object.assign(Object.create(null),kg);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=we.Constants.BUFFER,t=void 0)),Object.assign(i,e);let o=new we(i);if((typeof i.decoder!="object"||typeof i.decoder.encode!="function"||typeof i.decoder.decode!="function")&&(i.decoder=we.decoder),t&&typeof t=="string")if(o.fs.existsSync(t))i.method=we.Constants.FILE,i.filename=t,r=o.fs.readFileSync(t);else throw we.Errors.INVALID_FILENAME();let c=new Rg(r,i),{canonical:l,sanitize:u,zipnamefix:x}=we;function p(y){if(y&&c){var E;if(typeof y=="string"&&(E=c.getEntry(me.posix.normalize(y))),typeof y=="object"&&typeof y.entryName<"u"&&typeof y.header<"u"&&(E=c.getEntry(y.entryName)),E)return E}return null}function m(y){let{join:E,normalize:S,sep:A}=me.posix;return E(me.isAbsolute(y)?"/":".",S(A+y.split("\\").join(A)+A))}function b(y){return y instanceof RegExp?(function(E){return function(S){return E.test(S)}})(y):typeof y!="function"?()=>!0:y}let I=(y,E)=>{let S=E.slice(-1);return S=S===o.sep?o.sep:"",me.relative(y,E)+S};return{readFile:function(y,E){var S=p(y);return S&&S.getData(E)||null},childCount:function(y){let E=p(y);if(E)return c.getChildCount(E)},readFileAsync:function(y,E){var S=p(y);S?S.getDataAsync(E):E(null,"getEntry failed for:"+y)},readAsText:function(y,E){var S=p(y);if(S){var A=S.getData();if(A&&A.length)return A.toString(E||"utf8")}return""},readAsTextAsync:function(y,E,S){var A=p(y);A?A.getDataAsync(function(D,L){if(L){E(D,L);return}D&&D.length?E(D.toString(S||"utf8")):E("")}):E("")},deleteFile:function(y,E=!0){var S=p(y);S&&c.deleteFile(S.entryName,E)},deleteEntry:function(y){var E=p(y);E&&c.deleteEntry(E.entryName)},addZipComment:function(y){c.comment=y},getZipComment:function(){return c.comment||""},addZipEntryComment:function(y,E){var S=p(y);S&&(S.comment=E)},getZipEntryComment:function(y){var E=p(y);return E&&E.comment||""},updateFile:function(y,E){var S=p(y);S&&S.setData(E)},addLocalFile:function(y,E,S,A){if(o.fs.existsSync(y)){E=E?m(E):"";let D=me.win32.basename(me.win32.normalize(y));E+=S||D;let L=o.fs.statSync(y),_=L.isFile()?o.fs.readFileSync(y):Buffer.alloc(0);L.isDirectory()&&(E+=o.sep),this.addFile(E,_,A,L)}else throw we.Errors.FILE_NOT_FOUND(y)},addLocalFileAsync:function(y,E){y=typeof y=="object"?y:{localPath:y};let S=me.resolve(y.localPath),{comment:A}=y,{zipPath:D,zipName:L}=y,_=this;o.fs.stat(S,function(R,k){if(R)return E(R,!1);D=D?m(D):"";let z=me.win32.basename(me.win32.normalize(S));if(D+=L||z,k.isFile())o.fs.readFile(S,function(F,V){return F?E(F,!1):(_.addFile(D,V,A,k),setImmediate(E,void 0,!0))});else if(k.isDirectory())return D+=o.sep,_.addFile(D,Buffer.alloc(0),A,k),setImmediate(E,void 0,!0)})},addLocalFolder:function(y,E,S){if(S=b(S),E=E?m(E):"",y=me.normalize(y),o.fs.existsSync(y)){let A=o.findFiles(y),D=this;if(A.length)for(let L of A){let _=me.join(E,I(y,L));S(_)&&D.addLocalFile(L,me.dirname(_))}}else throw we.Errors.FILE_NOT_FOUND(y)},addLocalFolderAsync:function(y,E,S,A){A=b(A),S=S?m(S):"",y=me.normalize(y);var D=this;o.fs.open(y,"r",function(L){if(L&&L.code==="ENOENT")E(void 0,we.Errors.FILE_NOT_FOUND(y));else if(L)E(void 0,L);else{var _=o.findFiles(y),R=-1,k=function(){if(R+=1,R<_.length){var z=_[R],F=I(y,z).split("\\").join("/");F=F.normalize("NFD").replace(/[\u0300-\u036f]/g,"").replace(/[^\x20-\x7E]/g,""),A(F)?o.fs.stat(z,function(V,J){V&&E(void 0,V),J.isFile()?o.fs.readFile(z,function(ee,X){ee?E(void 0,ee):(D.addFile(S+F,X,"",J),k())}):(D.addFile(S+F+"/",Buffer.alloc(0),"",J),k())}):process.nextTick(()=>{k()})}else E(!0,void 0)};k()}})},addLocalFolderAsync2:function(y,E){let S=this;y=typeof y=="object"?y:{localPath:y},localPath=me.resolve(m(y.localPath));let{zipPath:A,filter:D,namefix:L}=y;D instanceof RegExp?D=(function(k){return function(z){return k.test(z)}})(D):typeof D!="function"&&(D=function(){return!0}),A=A?m(A):"",L=="latin1"&&(L=k=>k.normalize("NFD").replace(/[\u0300-\u036f]/g,"").replace(/[^\x20-\x7E]/g,"")),typeof L!="function"&&(L=k=>k);let _=k=>me.join(A,L(I(localPath,k))),R=k=>me.win32.basename(me.win32.normalize(L(k)));o.fs.open(localPath,"r",function(k){k&&k.code==="ENOENT"?E(void 0,we.Errors.FILE_NOT_FOUND(localPath)):k?E(void 0,k):o.findFilesAsync(localPath,function(z,F){if(z)return E(z);F=F.filter(V=>D(_(V))),F.length||E(void 0,!1),setImmediate(F.reverse().reduce(function(V,J){return function(ee,X){if(ee||X===!1)return setImmediate(V,ee,!1);S.addLocalFileAsync({localPath:J,zipPath:me.dirname(_(J)),zipName:R(J)},V)}},E))})})},addLocalFolderPromise:function(y,E){return new Promise((S,A)=>{this.addLocalFolderAsync2(Object.assign({localPath:y},E),(D,L)=>{D&&A(D),L&&S(this)})})},addFile:function(y,E,S,A){y=x(y);let D=p(y),L=D!=null;L||(D=new Cg(i),D.entryName=y),D.comment=S||"";let _=typeof A=="object"&&A instanceof o.fs.Stats;_&&(D.header.time=A.mtime);var R=D.isDirectory?16:0;let k=D.isDirectory?16384:32768;return _?k|=4095&A.mode:typeof A=="number"?k|=4095&A:k|=D.isDirectory?493:420,R=(R|k<<16)>>>0,D.attr=R,D.setData(E),L||c.setEntry(D),D},getEntries:function(y){return c.password=y,c?c.entries:[]},getEntry:function(y){return p(y)},getEntryCount:function(){return c.getEntryCount()},forEach:function(y){return c.forEach(y)},extractEntryTo:function(y,E,S,A,D,L){A=In(!1,A),D=In(!1,D),S=In(!0,S),L=Vl(D,L);var _=p(y);if(!_)throw we.Errors.NO_ENTRY();var R=l(_.entryName),k=u(E,L&&!_.isDirectory?L:S?R:me.basename(R));if(_.isDirectory){var z=c.getEntryChildren(_);return z.forEach(function(J){if(J.isDirectory)return;var ee=J.getData();if(!ee)throw we.Errors.CANT_EXTRACT_FILE();var X=l(J.entryName),ve=u(E,S?X:me.basename(X));let Ne=D?J.header.fileAttr:void 0;o.writeFileTo(ve,ee,A,Ne)}),!0}var F=_.getData(c.password);if(!F)throw we.Errors.CANT_EXTRACT_FILE();if(o.fs.existsSync(k)&&!A)throw we.Errors.CANT_OVERRIDE();let V=D?y.header.fileAttr:void 0;return o.writeFileTo(k,F,A,V),!0},test:function(y){if(!c)return!1;for(var E in c.entries)try{if(E.isDirectory)continue;var S=c.entries[E].getData(y);if(!S)return!1}catch{return!1}return!0},extractAllTo:function(y,E,S,A){if(S=In(!1,S),A=Vl(S,A),E=In(!1,E),!c)throw we.Errors.NO_ZIP();c.entries.forEach(function(D){var L=u(y,l(D.entryName));if(D.isDirectory){o.makeDir(L);return}var _=D.getData(A);if(!_)throw we.Errors.CANT_EXTRACT_FILE();let R=S?D.header.fileAttr:void 0;o.writeFileTo(L,_,E,R);try{o.fs.utimesSync(L,D.header.time,D.header.time)}catch{throw we.Errors.CANT_EXTRACT_FILE()}})},extractAllToAsync:function(y,E,S,A){if(A=Dg(E,S,A),S=In(!1,S),E=In(!1,E),!A)return new Promise((k,z)=>{this.extractAllToAsync(y,E,S,function(F){F?z(F):k(this)})});if(!c){A(we.Errors.NO_ZIP());return}y=me.resolve(y);let D=k=>u(y,me.normalize(l(k.entryName))),L=(k,z)=>new Error(k+': "'+z+'"'),_=[],R=[];c.entries.forEach(k=>{k.isDirectory?_.push(k):R.push(k)});for(let k of _){let z=D(k),F=S?k.header.fileAttr:void 0;try{o.makeDir(z),F&&o.fs.chmodSync(z,F),o.fs.utimesSync(z,k.header.time,k.header.time)}catch{A(L("Unable to create folder",z))}}R.reverse().reduce(function(k,z){return function(F){if(F)k(F);else{let V=me.normalize(l(z.entryName)),J=u(y,V);z.getDataAsync(function(ee,X){if(X)k(X);else if(!ee)k(we.Errors.CANT_EXTRACT_FILE());else{let ve=S?z.header.fileAttr:void 0;o.writeFileToAsync(J,ee,E,ve,function(Ne){Ne||k(L("Unable to write file",J)),o.fs.utimes(J,z.header.time,z.header.time,function(O){O?k(L("Unable to set times",J)):k()})})}})}}},A)()},writeZip:function(y,E){if(arguments.length===1&&typeof y=="function"&&(E=y,y=""),!y&&i.filename&&(y=i.filename),!!y){var S=c.compressToBuffer();if(S){var A=o.writeFileTo(y,S,!0);typeof E=="function"&&E(A?null:new Error("failed"),"")}}},writeZipPromise:function(y,E){let{overwrite:S,perm:A}=Object.assign({overwrite:!0},E);return new Promise((D,L)=>{!y&&i.filename&&(y=i.filename),y||L("ADM-ZIP: ZIP File Name Missing"),this.toBufferPromise().then(_=>{let R=k=>k?D(k):L("ADM-ZIP: Wasn't able to write zip file");o.writeFileToAsync(y,_,S,A,R)},L)})},toBufferPromise:function(){return new Promise((y,E)=>{c.toAsyncBuffer(y,E)})},toBuffer:function(y,E,S,A){return typeof y=="function"?(c.toAsyncBuffer(y,E,S,A),null):c.compressToBuffer()}}}});import{execFile as b_,spawn as E_,spawnSync as tA}from"node:child_process";import{promisify as v_}from"node:util";function I_(t){if(process.platform!=="win32")return!1;if(Wu.test(t))return!0;let r=(t.split(/[/\\]/).pop()??t).replace(Wu,"").toLowerCase();return S_.has(r)}function Ku(t,e){if(process.platform!=="win32")return e??{};let r={...e??{}};return I_(t)&&r.shell===void 0&&(r.shell=!0),r.windowsHide===void 0&&(r.windowsHide=!0),r}function ct(t,e=[],r={}){return E_(t,e,Ku(t,r))}function $u(t,e=[],r={}){return A_(t,e,Ku(t,r))}var S_,Wu,A_,mn=Ve(()=>{"use strict";S_=new Set(["npm","npx","yarn","pnpm","coze","tsx","claude-agent-acp","codex-acp","openclaw"]),Wu=/\.(cmd|bat|ps1)$/i;A_=v_(b_)});var Uf=se(Oe=>{"use strict";var M=q;(function(t,e){let r=q,i=t();for(;;)try{if(parseInt(r(868))/1*(parseInt(r(417))/2)+parseInt(r(445))/3+-parseInt(r(1308))/4+-parseInt(r(681))/5*(parseInt(r(1041))/6)+parseInt(r(1549))/7+parseInt(r(834))/8*(-parseInt(r(919))/9)+parseInt(r(1028))/10*(parseInt(r(1879))/11)===e)break;i.push(i.shift())}catch{i.push(i.shift())}})(yo,110474);var db=Object[M(903)+M(1712)],lb=Object[M(1268)+M(1351)+M(1363)],Nf=(t,e)=>function(){return t&&(e=(0,t[lb(t)[0]])(t=0)),e},ub=(t,e)=>{for(var r in e)db(t,r,{get:e[r],enumerable:!0})};function fb(){return Df||(Df=[IDBDatabase,IDBObjectStore,IDBIndex,IDBCursor,IDBTransaction])}function xb(){let t=M;return kf||(kf=[IDBCursor[t(750)+"e"][t(1615)],IDBCursor.prototype[t(643)],IDBCursor[t(750)+"e"][t(643)+"PrimaryKey"]])}function hb(t){let e=M,r={HRxsP:"success",riFnQ:function(o,c){return o===c},okGhn:e(425),nlmOj:function(o,c,l){return o(c,l)},dDsxE:function(o,c){return o<<c},aVeyd:e(1226)},i=new Promise((o,c)=>{let l=e,u={UaCsI:r.HRxsP,UyUDe:function(b,I){return b(I)},TtFBB:function(b,I){return b(I)},ZqPkK:function(b){return b()},dXvQR:function(b,I){return r[q(1116)](b,I)}},x=()=>{let b=q;t[b(501)+b(607)+b(714)](u.UaCsI,p),t[b(501)+b(607)+b(714)](b(425),m)},p=()=>{let b=q;u.UyUDe(o,u[b(1854)](Lt,t[b(1058)])),u[b(1272)](x)},m=()=>{let b=q;if(u[b(1274)](b(1925),b(1925)))u[b(1854)](c,t.error),u[b(1272)](x);else return _0xbd8f0f[b(1791)][_0x284c36(_0x2e7668,1)]};t[l(1350)+l(953)](r[l(1467)],p),t.addEventListener(r.okGhn,m)});return i[e(1101)](o=>{let c=e;if(r[c(1116)](c(1226),r[c(1656)]))o instanceof IDBCursor&&Xc[c(1592)](o,t);else{let{value:l,offset:u}=r[c(1650)](_0x19fa6b,_0x403412,_0x534084);_0x1765b2=u,_0x363977=r[c(1576)](_0x5bdee8,8)>>>0,_0x58cb55+=l}}).catch(()=>{}),Eo[e(1592)](i,t),i}function pb(t){let e=M,r={JDXEN:function(o){return o()},GLvcg:e(973)+"or",zeQpb:e(481),CrrCm:e(425),DEzoB:e(1366)};if(bo.has(t))return;let i=new Promise((o,c)=>{let l=e,u={chYZx:r[l(1303)],YCnLf:r.CrrCm,xgMpy:r[l(586)]},x=()=>{let b=l;t["removeEventListe"+b(714)](u[b(780)],p),t[b(501)+b(607)+b(714)](u.YCnLf,m),t[b(501)+b(607)+"ner"](u[b(548)],m)},p=()=>{r[l(584)](o),x()},m=()=>{let b=l;c(t[b(425)]||new DOMException(r[b(936)],r[b(936)])),r[b(584)](x)};t[l(1350)+l(953)](r[l(1303)],p),t[l(1350)+l(953)](r[l(562)],m),t[l(1350)+"Listener"](r[l(586)],m)});bo[e(1592)](t,i)}function yo(){let t=["zgvS","s0jJvuq","EMr5uLe","svnZD1a","AvHzrNu","DhnJBha","DhjPzxmGCMu","CxvJvNG","uxL1C1e","vwnTEKC","z2u6ia","AuXhD04","Cgfjz2K","yLzRrge","zcbLCNjVCI4","vezMD3m","B25Uzwn0Aw4","A0vryuu","qwHsy1K","mhWXFdD8m3W","yxv0B21HDgK","A0nYq3C","y0H5r3m","C2vezeq","uej3seW","D1jnBhu","y3vZDg9Tshq","zw5XDwv1zq","BNrbBMrvCgq","r3Pxsgm","A2v0ignVBNm","r21eDMW","zxq9DxrMltG","C2v0q3vYC28","qNjXvge","Ew9kD3i","sfj4C1a","Bwf4tg9ZC0m","CufPwLu","y29SBM8","rxzLBNq","CfHzrfe","CgLUz19VBMm","Cu5JCvu","yMLeBgW","Cfruwgy","DMfSDwvZ","q0PHreu","se94uKG","yNL0zu9MzNm","DhDVCMTdAge","zxjHDg9Y","D0Tpz1O","DePxChG","yNPgDMG","zxH0zw5ZAw8","BNnRBgu","B3jLtMfTzxm","Bhm6ia","x29UvgLTzw8","vgfAD1m","Dgj5BNC","igzPzwXKoIa","BvvhuMe","v2zYrMO","uhL1D2O","vvf0t3e","B2fK","x3vYBa","Cu9iBui","zLbhzwu","zhf2BMm","t0TyyLy","CgXpCg8","BMCGB3iGyw4","nhWXFdb8m3W","BgLZDgvUtMu","zw50","y2TvuMW","s1vdCvi","thPfwvm","ufjAAvO","vg9LBxK","Evvsthe","CuLWqNG","AMfcrMS","u3nPvvy","BMruD2m","rxb3z0S","CuLXv3q","s0rSqva","veL2zvu","B2LUDfjLywm","sMnJAxi","x3jLywr5q2W","CMTLCKDSB2i","BNf4swS","wxvTvKm","CYbPBNn0yw4","yxrHlcbKyxq","s1nmwNm","CgTjCwu","zMXVB3i","Aw5KzxGGB3u","BwvKAwf0zwW","DevLB3e","DuvpCKu","CM92AwrLige","y3vYC29Y","zxrxB3jRq2G","y3jLyxrLt2i","BwLZzq","CeHAvMi","B3bLBIa","CMvQzwn0","DwrcAMe","ser3y1K","rNP2B0y","ndq0ndiZzxf3ver2","vuLUyLO","y2XVC2uSihC","v2vIu29JA2u","zxjFCw9Z","DerYu3q","v2TmBfK","x19LC01Vzhu","z09VDgO","vePYCNy","DK1AvgK","y1LMrhy","AefJA01LC3m","EeXSyxy","tfLHANa","rNjVBNrPzxi","qK1RvuW","rfbACgu","Cg9PBNrbBMq","tKDFrvjst1i","x2LUAxrqCM8","q25grNa","Ahr0Ca","y2r4ChO","rKvmywe","txf0AKK","D3rnA24","zerZEeu","x2vUzhbVAw4","rhrPD1i","AvfLAgi","y3vYC29YlNm","x2LUAxq","zwrPyxrLBhK","ANn1u1a","s0rIr1u","Dwv4vhG","y3vYDMfSDwu","rfr3sgS","ANPmz2O","uw1TrKG","qwzMrxe","q3DRB3G","C2v0","C2XryxC","AfvXEva","wKTYrfq","DfbLC1O","tun3y3i","u2L6q3i","ENHQB1m","y2f0y2G","x29UrxjYB3i","qwXZALG","x2n1CNnVCK0","t2HithC","vwjbDvO","yLH3swS","tgvQy1m","Cgf5Bg9Hzeu","zxH2v0K","CwrKz04","qMzIu2W","v0n1wwG","sfjisKy","uunPAwu","ywr2yw5Jzq","sfnJB1e","mdaWma","C2ffqKO","BwHiBKW","x2nSzwfYvgK","u0f0AuG","Aw47y2HHCNm","vK9hv3u","CM92AwrLihC","sgHcsNq","AenSB3nLrxy","yxrLq291BNq","DgLUzYbZzxi","x194x21Zz18","AxmGDw5Kzwy","A0H0r1i","BLDtteu","EuTsyNO","zMLN","DKXSsge","y09Wzw4","CeTAwve","t3f5y00","CNzHBfzHBhu","Fdv8mtf8m3W","t29tB20","q0XNvfK","y3L1uNG","AwPXyNO","ywX3yxLZ","BgLTAxq","yxv0BW","twDMC1i","BvbLDgO","BMXTt2O","u0TWs2S","sxfYAMC","zKDswuS","Aw5N","DgfIyxnL","yvzLEwq","BgPlwve","tfr1vhC","y2HnyxHuCMK","wvPVzuG","D2v2rei","yLL3wLO","CgLUz0LUDgu","Bwv0Ag9K","ywvbD0u","y05TDwO","qurnsMu","uxr1tgm","Cg9PBNrdB24","igXHCMDLCIa","vxbKyxrLq28","x3bHDgHlzxK","AKLvAw0","v1DVEwq","rLjptLrjrvi","wLjUsLK","tMfTzq","Dg9hzw5LCMe","uffOsg4","u3rQAuO","CMvZzxruCMK","uuzYu1i","CNnVCL92ywW","CgrPsgm","quXywhu","sM15q1C","BIWGAg9ZDg4","v0Tgrva","zNjVBNrPzxi","zMLSDgvY","zfHStKu","BMrLEa","ywnOzwq","nNWXFdeWFdC","AMDgDe4","Ae9Wzw5fDMu","DgLTzw91DcW","rvfivMK","tuvtu0fhrv8","AhD0Dgy","D1vztxi","BNbQrKu","x2rPC2nVBM4","tvbhAwO","EhLKCMm","Bgf1BNC","C2vUzf9Hy2S","wxzny0O","ExbL","v2vPEgLUsLm","DNDot3C","B3bLCNr5","DMvYC2LVBG","x3nLCuLK","rMTyA3O","EuP2rwe","ug1Wv1i","Aw5KzxHpzG","u2vXsuq","AvDAC1y","ywzL","CfPyD1i","DwHnwwG","wMnmuvm","EeLvq1K","zxDrtNq","CMzrr0q","CMvUDevUzha","DxbNCMfKzw4","zNjVBunOyxi","rKjgwvy","ANrQAuC","AxnbCNjHEq","zhPkDLO","DgLLCKPtt04","weDdwvm","EMLXDe8","zwnYwuy","z296sgy","t1DuA0K","yNLL","A0TKrxO","x2HHBMrSzva","sLz1quq","ANrVBgO","BKn0q2y","vw9Ssum","Bxb1s2O","x2rYB3bhBg8","uKrzzxC","BNvTyMvY","lcbTyxGGCMu","EgHIwuW","qNLxzeO","AgLNAa","ihzHBgLKihm","CgLxBMy","sLnptLa","CgDbB2e","DLngD3G","qvnjCNO","C3bSAwnL","B2zMC2v0","Cgf5Bg9Hzfq","yxGGCMv0CMK","vg94sg0","zgvJB2rLzey","v3DYyM4","r3rbshi","y2XLyxi","yMXVy2TLza","wenbEwu","DfrTqKW","tg14t1u","y2rhsMe","x3bPBMC","Dg9cExrLC0W","rvHOzNC","sez6z20","rLbXCLi","r2TRuLK","D3bdru4","r2zKvxy","BLP6v1O","suntqva","rxPOyKe","D3jPDgvvAw4","vuPRA0S","twLZC2LUzYa","zv9ZDwnJzxm","yNL0zxm","yuXtD2C","nxW0Fdj8nNW","q3vZDg9Trxi","CMj3yw0","z2v0s2v5","sg5ID00","Fdr8oxW4Fda","re92uu0","B25szwnLAxy","zuH2qve","CKTdrwS","zxH0ugf5Bg8","Bg9NsurozxC","Bg9N","zxv0D24","wgP0BK8","C29Tzq","C3DQz2y","B25tDg9Wsw0","rxjYB3jdB2q","wLnrqNm","uMvJB25Uzwm","yw5ZzM9YBvq","yxbWBhK","B25SAw5L","zMn3vuq","r29sAvu","C0nZuuG","wLzhAK4","uhnzs2u","x3bPBMDqB24","AgvHzgvY","y29UDgv4Da","reHOwLq","ueDey3u","DNHhwvq","DfDIs0e","DxzNDNq","CYbHBhjLywq","A2f2ugO","Dg9cExrLCW","zuLWBLu","nxWXmxWZFda","sMH4CNO","sxrxz0S","wuv3A0q","EvbYEKK","tKTgB2m","tunfvuq","zNjVBu51Bwi","vgXPsMG","CeTKvKG","uK9Wu0u","u3rYyxrLz3K","BNruCMLLC0m","wvbLr0C","rNDkCxK","u2DOtLi","BuLdALK","Bg93","u1r2EvO","s2DkD1O","vhrgqKi","Bwf4uMv0CMK","EhPZENi","rKHVzNy","De5LsKS","Eg50zfa","x2nSzwfYugK","CMvJB25Uzwm","CgfYC2u","whLiCMq","wwvmv0S","AMf0wfC","uKDNu2i","sezoDfq","C0rntuS","wwf1uLy","rgDxr3O","AxnrB1nnzxm","ihjLy29UBMu","rgrQuwG","BhLhr2u","AwXSihvZzsa","zNjVBujPDhm","BgrXteq","Dg9mB3DLCKm","mtiYndqXtKrmuK1I","BezSDxnO","zfjrBMm","Ec1TC2CTy3u","DNrJyvi","svbhCfG","BKXXwuy","x0rctMfTzq","r012z0O","AevYCM9Yrxy","tfPirvy","C0nVDw50zxi","C1Hvu2O","B2XKvMvYC2K","BuHhD0i","B3bLBKrc","vM1fEuW","qvHPCfi","CeDZCMe","q3jou2i","s2j6yLO","BgvUz3rO","x3nVy2TLDa","v29cueG","ELPWEu4","AwXK","C2HZrNC","BuDHt3m","zg9Uzq","D2vI","Eejquw0","BwHPAuS","BwvZC2fNztO","Aw5orxi","DgvmB2Djre4","x2TLEvbHDgG","svrNuue","zfDVCMTLCKC","A2TrsLa","q1jRse8","Aw9Ul2PZB24","ywDLu2HVDW","vxrwswW","nhWYFdf8m3W","zgvSzxrLrge","uhHgAMG","rMPPr1K","Aw5L","Cw9Z","C3vIC3rYAw4","B25dBg9Zzq","AvHqAxC","B3PMA2e","rfjRs2y","id4G","BgfqvMK","EKf4z2W","wMrzBeG","B01jBgC","rLDt","sffSqLi","uLjpuG","sfzRA3q","rgPwwvC","B2nRzxrtDwm","x29WDgLVBNm","A1vLqK4","zhzQC0C","AgfZ","BMDLza","uhPwruK","Dw5RBM93BIa","vgHYt2C","sMHNt1a","ignVzgu6ia","A2LXq3m","re1ODwK","DhjHBNnHy3q","wM5ADLu","x2rPC3bHDgm","mtm4vNLAuLfb","uK5JCw0","tufyx1jfvfi","sxDWyLu","BvjUEK8","CNnVCL9Uyw0","wvnxuvm","DhLWzq","zxjYB3i","pxv0zI04","y3jLyxrLrwW","AgDnDKq","rgvKAwnHDgu","yLfHtwG","zxjFCw9Zx2e","CMzVz1G","FdD8nhW5Fde","sgTLywm","D0XwDNq","u1nWvhK","BwXuvva","B25fCNjVCG","BeDfwfy","C3PgyNG","z2vjBMzVu3K","zfbdENC","yw1L","AwDHDg9Yt24","ndGYmdGYDfrgu05l","BgLbrui","r3vrCLm","AxnmB25N","x29UtwvZC2e","C0jf","q29Kzq","DMnRq0C","vLLhs3u","Dwjgzgu","ywXSzwqGBxu","C2HPzNq","CxjgDei","r0jHB2G","tM9nt08","x2n1CNnVCK4","sgf3yLm","C3rLBMvYCW","re9qwNO","weDWBve","uvbzrfy","tKTPwKq","D3jPDgu","v3fhrNq","DuvkDMi","tNHMsvC","Ahr0Chm6","DuX4v1m","De1HBMfNzxi","A0zwweC","tLnyrNC","q09oveLovuu","sKfdzNa","zw5KCg9PBNq","uhz6r0W","AxnrB1nby2S","y29TCgXLDgu","B3jpBMXPBMu","BgLOuee","ihzHBgLKigq","z2vtEw5J","z1fzBwK","thPrEhC","C3LSqwG","DNbvr2y","B3vUDa","wenyD3y","vwDXtwe","zwDYqNa","uKnWCuS","BgX1Bue","lcbxzwjtB2m","EujIAxy","Chn5B2K","CMvHC29U","wMLYq0O","CMvTB3zLrxy","wNDVrwi","CM92AwrLihy","CNnVCKzPBgu","DfvRq2u","D2D1AhG","DuTtCfC","CKz4t0K","y3r4","rvfbuwu","zMvcBeK","DKjuBe0","yM5bBum","BwvZC2fNzq","y3LWtvm","CMvHzfvjBNq","y2uGBM90igK","zcWG","A21pAuK","zu5Lt3C","ChnIsMC","t1bqzey","C0rjsu4","Dg9tDhjPBMC","BxHVAxe","veHHz0e","EKz0vLq","EuHLvuC","y2XLyxjtDg8","DervAuG","D3LlzKm","tePirvO","q1rsD0S","zxj2AwnL","Bhj0twi","q0jWu1K","Ew5vExC","u1HkqKW","y3jfsKy","thjPBey","zLHVr3q","D1HAs28","rwXUwfq","D3vTyu4","x2LZsw5PDa","DMvY","AxDdv3a","EgDnChK","yLb5re4","zfLuChO","tND6BhO","AwXLtMfTzq","v0DVtva","C3bSAxq","u3jpBgm","Cg93","q0Teyxu","BgLUzw5V","vuHUCNq","AhnvrKO","CNb6CLq","q3jYq20","x29Uq2XVC2u","wfzYuNq","AuDzDvG","zgvIDwC","qLDMwxq","x29Ut3bLBG","vwXJvw8","Ec11C2uT","BMv4DcGPigm","zhrwu04","vMv5EK8","uff3Chi","CNjVCK1LC3m","quT6seK","ELvHDee","zw1LBNq","Cgf2r0q","Chrhywm","qLn0sNe","wgrbrvy","AMDACNO","sKryru4","wvbNDuW","rev6B0i","CMvJzwL2zwq","zMLSzw5HBwu","ywDL","zM9Yy2u","B3bLBG","q09otKvdveK","uKvYz04","yLjlwfO","y29UBMvJDeu","z2v0qwXSs2u","reTLr2i","yxnL","t2nvzxu","yvbtzwW","ihrPBwvVDxq","AwDUAgm","ywDLrxzLBNq","BgDPte0","BLbQAM4","Bwn4DMS","zw50tgLZDgu","BMzhDwe","veXQC2O","DwPUuu0","z2vY","vgLTzw91Da","uuDmBxm","DuXgs3C","uuHbCey","B2zM","mhWZFdf8mNW","wLDNDMy","r0zYAva","C0XPC3rLBMu","DeLUDgvYy2u","BwLUAvbYB2C","BeD2wgm","uK1ttNG","v29TD3i","qM1rB3G","qKnztha","wujYsK8","AxnszwfKEq","Dgv4DfbHEwW","zLLbAhq","BxLbwuG","zgTuqLm","C3rYAw5N","DLHbvNi","yw5Nzq","Dg9cExrLC0i","A1fHDwm","u3fZsgO","zvvYBa","BxnXywu","seLyq2i","y29UDgLUDwu","s3fHz28","uLbfsu8","qw5nCuy","zKvJA0C","x3DHAxq","yNPOy0W","BfPoB00","C0HqBLa","zgTlEhq","vNjPvuG","BLrxzLK","zw1PDa","D29ZB0K","tLLwtvy","vMXvtgm","rNvSEe4","rfnbz2e","C2vYDMLJzq","BwvY","EgvVEhK","C3rYAw5NAwy","BNfhyu4","CMvWBgfJzq","EhDHzKq","B3v0sw50zxi","DLrOtvi","y2HLy2Tszwe","DhjPBq","yM9L","CMfTzq","t3HLre4","DNzmrMK","wMrXAfG","y2fSBa","uwTwDe4","C3vJy2vZCW","Ae1LC3nHz2u","nJvMqvb1ruu","ALPZEw4","x3bPBMDmB3m","v3z6s2m","uuvjr3K","yuDJALa","qvzbCgy","qxvcD0O","sNj1wxG","BMDMy3O","tg9JAW","x2LUAxrhBg8","wvDWzu4","ufLhDgy","ChrVCG","EhvWruS","tw94zMG","AgTJyKq","wfrXBM0","yM9KEq","DunRC20","CKrUBfm","uu1wvvq","z2vrDwv1zuW","C2vUza","CgLUz1rPBwu","qxrNyKi","zNjVBuHHC2G","CuTIswi","sezTzxy","sMnvDva","x3bYB3rVy28","BxnNsuq","BMvY","qMzvDuO","ugHtzM0","sevyAhK","zMLQDge","qunVvwS","EfzmANe","yxbWzw5Kq2G","B2nRzxrgywK","x2XPC3rLBMu","y29Kzq","CNDpC3m","D3DLugO","ugjNExq","t1bftL9fuLi","q3biwKe","CgLUz0XVC3m","DNnWuNq","D0LcwLm","Aw5JBhvKzxm","yMfSrxzLBNq","uKLwz1G","y3vYCMvUDeK","yxKSig5LDhC","ELbyt2i","ywXSq3vYC28","A1z6ywe","ruXfCNy","vMPfA0S","wLDxANu","wg5LC1q","r0TLrNe","DhrbBeq","x2nVBM5Ly3q","qMLdEvi","z29PBMCGyxC","ChjVDg90Exa","C29YDa","Ehv4t0e","surHz20","Ce9kELC","txrOCxe","B2DsrMm","Ag5YEvO","zNPSr3G","vfzsvei","thz1AMG","AvzRvwK","q1LWsLy","z2v0qwXS","B25VCgvU","BeHHBMrSzxi","EKvRCee","DxnLCKLW","tKfusvzfx0u","DgvZDa","Bw1Nz0e","yxKSihrYEsa","D1fHt2y","C2fNzq","we9Su2S","u2HHCMvKv28","rgnlrhi","qxjxwhe","ALDXy1C","zsbHihn0CMK","y2HzwNG","zgfquMG","yw1LoIa","CK90wgS","zwn0","B25tDgfYDfi","CNz2vK0","BKzkvwG","uMPbELa","nhW2Fdj8nq","r1zutNC","wgXstvC","CMvXDwLYzwq","qNnlB0m","veTgEvC","B25pCgvU","tgXqA0W","C2XPy2u","x2LZtwLUAvC","vejlDfi","BwLUzW","zxmGCMvHy2G","ugnYBuC","uM9wqMe","B2nXDMu","zgf0yq","C3rVCcbPBw0","CK5XwLy","ywXPzcb1CMW","x2HHBMrSzu8","zufJAW","Dev2zw50","mdaWmdaWmda","zw5HyMXLuw8","uw1htLG","C3LSBKe","weDLqM8","C3vIyxjYyxK","ihn1y2nLC3m","y3jLyxrLq2W","wMDmAuC","yw9wBfa","x1fVu01HBMe","Bg9Nsurhzw4","t0LfseC","zevHreG","DgLntxq","v2Hoqvq","B2fYCMm","BM93","qwHltLC","BMCGDxjSoIa","zMzLCG","CMnZDLm","mtzovLntDvm","zv90Aw1LB3u","v1LLtxe","D2fZq2XLyw4","jMPZy2fSBgi","uM5Trwi","t3bLBKv2zw4","yvf2C1y","vw1ev24","y29UBMvJDgK","r1PrwLe","q291BNq","qvr5vuG","vefjB1q","zxjFywnRx20","qxbsA0G","DLDTBwi","y29Uy2f0","C2zHvgy","reXhBNu","AM9PBG","tuPHrvi","t1bftG","DMfSDwu","Dg1IC20","zgLZywjSzue","icSG","Ef9MCM9UDgK","z3zotgS","BMfTzq","v2j1sKG","rNvZy0O","CK5MELm","DMTzvNi","mJK2owr4EvLVCW","AeXwA0O","EsbJBg9Zzwq","x2LZqNjVD3m","vxPXEwK","AgHzEgO","vw5pzva","yNfjwLO","rwHxt2S","u1r3z1q","CMvTB3zLq2G","x3jLy29UBMu","ig1LC3nHz2u","Dxrjza","l3DZl3yY","shbbtve","zMrIrMK","ywnOzwqSihC","BK9iDhi","vLjzB2W","rNr0qwC","DfjlvxC","CYbWyxjHBxm","vxbtqLy","yK9WzNy","x3bYzwzPEa","ue9YA2q","DcbSAw1PDa","rvzqCfq","Ec1TC2CTCw8","yw51Ce1LC3m","z0TzBgO","yMLUyxj5vhK","shPPEeO","A2zlA3q","zgvMAw5Luhi","EgPrBNK","B25mAw5L","DfvQz2O","vgrzrhK","DgjLy2q","s1PluKq","A2v5CW","DfLnDLy","Chv0","C2v0zgi","uNneqNG","zKrOD1y","sgj5Aum","yMLUyxj5","CMfTugfYyw0","mtCYotHkEKHdAw4","y3ruAw1LB3u","r0rRzfK","zKD3q3e","x21LC3nHz2u","zxHWB3j0CW","seD2uMi","EgrmBe4","lcbOB3n0BMe","yvzmAwe","vuLWtxi","vvvmq2C","DeDWzwW","z2LmuMO","u29cyMu","x2rLC3rYB3K","wwzRr1G","r0X2y2C","Derisfu","x2rItMfTzq","tKXkrxu","ruHczu0","txLjCfu","Dw5ZAwDUzwq","y3jLyxrLuMu","tK5Zsfq","v3jqAey","wg5uugu","BefVr3q","zKT6swS","u29dvhO","sKHkBgG","rMnVB0K","y291BNq","tgLZDgvUzxi","y29UC3rYDwm","y2XVC2u","ihbYB3rVy28","zKneD0W","yxbWBgLJyxq","s3b2y1u","ywWGy3vYC28","uMfxEMu","B3jRzxjhBg8","C0Xf","rLLtBNe","x2n1CNnVCKy","CgvYC2LZDgu","CLzHBhvLCW","s3HJv3u","zw5HyMXLqxu","y3jLyxrLt3a","zvnfyMC","sKXMD0e","qwjVCNrfCNi","rLfereu","yxPIAuC","CMffDvO","yxnZAwDU","su5oy2C","x2LUDgvYDMe","rKLmrv9ot1q","thrQrwC","De5oEgu","C0fPCMW","teL2Bha","qKHPAuG","uvHvzu8","CMLLC0nVDw4","EfzvBKC","ywnRtxnNswq","ywXS","z2DvA2S","y2XVC2veqG","yMLnz3m","DhDkz3a","q09ItMO","AenNEwi","r2fdDe4","z3voC3m","C3nHz2vfDMu","CvPtu1a","vvrWwem","BMrWB2LUDca","q25iCg4","vfHeyLm","DMrRyLK","yw1Lu3bHy2u","yNL0zuXLBMC","Bef1Cwu","uxryC0u","AujiENO","z2v0u3rVCMe","x2LZtwLUAvq","ywPgvhe","AxjLza","qKjwsKy","sevRAhC","BMvJDa","su5tvefova","q29UzMLN","D3HkAve","C215rLC","zwn1r0C","BgvY","sK9mANq","vuftCei","EKPUqMu","y3vYCMvUDeu","mZb0D1D6Bum","CM9YrxzLBNq","ChjVDg9JB2W","q0jxsem","Cgf5Bg9Hza","uhjPBwfYEuS","wMzIswG","ywrKq291BNq","sKD5txi","BwnVuxm","EvPHBha","DfLStey","z2v0sxrLBq","oda0mtHHthPQuxO","z2r1BNe","vuvnyvu","n3WZFdj8mhW","B25ozxr3B3i","D3nZoI8V","z1jKB0S","EM5zvxC","u2vYDMLJzvC","z2v0","AhbRyw0","EeTpAhm","y3Ppzvu","rxnfsLu","D25gtLa","EfjUEvC","A2zmt0W","CMvZDwX0","yxjYyxLIDwy","x2nYzwf0zvm","AgvHzgvYCW","wgXiywG","B3nLza","vNzmDfu","B2jQzwn0u3q","D1bZsvm","wxvvveC","BNrfBMrWB2K","B0P2vxu","vLH4yMy","B25TzxnZywC","ywnRx2LK","y0fzC0G","vKL0ALO","B3jRig9MzMW","qMvZy1u","CuTTqve","z2v0q3vYC28","aaaaaaaaaaa","DMrsvfa","ihrPBwvZ","quPMvee","vvvbBwK","q0Xpu0LorW","ywnRDxbfBMq","DxjS","BwvZC2fNzv8","x3jLBw92zvC","y3vYC29Yx2y","zeD4zKu","vwD6yMW","zcWGDw5RBM8","Cw9vs1i","CMvZB2X2zq","x2HHBMrSzvi","C3vJvvC","Ae5kqLy","B2zMBgLUzq","A2fgC1u","uMvZCgq","DgHLBG","EKzHC0O","yuPwv1u","y2HHCKnVzgu","ugzUy3a","m3WXFdj8nhW","x2zVCM1HDeu","CM92AwrLigi","y1DssMW","vhL0vNi","DKnPyve","y29UBMvJDfm","CgXLyxnLiha","tePfuwi","shjsC2C","CMLgBLe","qNzfy2O","sgLwufi","D24GCMvHC28","vgvvtvG","AgvKtwf4uMu","sNDsCMW","BML0AwfSAxO","yxjKzwm","Bg9IywXty28","y3jLyxrLtwu","C2XusM4","EwTpsK0","DK13u3O","y2jbtKu","BfzRsgK","BMrWB2LUDfq","tu1MB1m","y0fyrNe","sMLcyKy","twvZC2fNzuu","z0DvDeW","C2vUDa","AwvcugW","BKXPBMu","tw9Ou3u","wefgvwW","BMnbzK0","DKPesxK","vM53Cem","wKHcALG","t3HNuLi","BgLUzq","zw5JB2rLrNi","BKXmueu","zunTD0y","swvwzKq","yNvMzMvYzwq","vNP2r1i","zNjHBwvuExa","EMfxAe0","ENz5r2W","Cw5rBNm","wwfRB2m","C3rHCNq","r3fnEhO","BNrLCG","DMvUDa","mhW0Fdf8nxW","rxLYEKu","y2HHqNi","vhfWDKq","z09Jwgq","y3jLyxrLrxi","CMvWBgfJzui","tuP1B0S","x2DLDeLUDgu","igzHAwWSig0","uhjQzfm","yNvMzMvY","AMvJDfn0B3i","mNWXFdb8nhW","DxrVuMvJB24","C2v0y3vYC28","CLzRrKC","x3fVC0rc","zM9YrwfJAa","s1f2Ce0","Dw5KzwzPBMu","B25JBg9Zzq","DMTQyK4","t0jizwS","t1fct20","r3rcvwi","ywrovMO","Bu1MsMu","BhnsEeW","BwTXsLO","zxjYtxnN","DgXgAvm","C2DmsMi","BfrPBwvVDxq","t3nys20","x3nLBMrby2S","zxjFBxnNAwq","Aw5PDcbrB1m","zNvUy3rPB24","ywnR","yxPJuwC","t1HKDwu","x2LZtM9Kzq","CMvHzhDYAxq","vvLuu3y","wgjKwee","uu9Su1e","qw1VDw50","t3rVy3G","CvbrvMy","sgzMB3y","Aw9UvgLTzw8","seHeywK","Bwf4twvZC2e","txPhtLu","Aw5KzxG","rKHYrxq","q1jgrgO","yMLUza","ChDjAxK","sgjRDgi","BfftCxu","A2nUC0O","x2LZv29YA2u","y3vYC29Yx24","zNbsA08","yvDyrwK","thLrzLG","sKfYB0u","Axnby2TdBgu","surfBNq","txDhz3a","x2jPBMfYEvq","z1rPBwvVDxq","Dg9Y","zw5JB2rPBMC","DxrMofDYAxq","zgXpvMG","wfHvEeu","BwfW","z1jRrwi","vwfxy3u","AhLxz2q","wNHRrwG","uxvLDwu","zxD3DLa","zhblBNi","rMnZsgi","tLjdz2W","rhnlB0m","Ewn0BMq","BhrPCgXLihq","CKzsCLC","x2rLyNvN","qKjxzKW","zwnVBM5Ly3q","CMvHzhLtDge","BMnLq2XVC2u","Bwu6ia","yw5Hz2vY","ChvZAa","zNjVBuj5Dgu","Bufdvhq","BvPTt2e","z2v0t3DUuhi","zNbTtgW","s3nWrMi","x3DZsw5ZDge","wNfqA0S","u2TPCcbWyxm","zfH2uvi","x3DZ","tg9Nsuq","qKfSu0K","ywnRpwzYB24","y29UBMvJDca","yxnfr20","BMDuAw1LCG","zuHdBM0","uhjnzeW","s1nft08","rMvIsgK","Aw9U","B3zfqu4","EfvZzuvUDG","Ce5XBhO","BMzlvLK","B2nRzxq","yMnIt2W","tuXOz3y","vezswfe","B25LCNjVCG","CgjVCwi","AwXLx25HBwu","ihrVihjLDhi","BNjtCeG","Be5ivhm","x29UugfNzu4","rfndtKm","EMvrCgi","AerowhO","z3nHqLq","suzjEge","suHOCu0","nJK1ntiWENfKug55","A3v2BgK","zNDZxZeUmc4","q2vpvMK","tM1mweq","ufH4C1a","Dgv4Dc9Qyxy","zMfcvhi","tw9KDwXL","ywDLsgLKzq","C2vYDMvYvgK","A3jcqw8","vKrJz3a","x2fKzfDZtgK","wKzluKW","vMP1uKm","Ehngs20","CNzHBa","CuXYr0q","B2jIyxe","tNvJteq","vvPwwwC","DeLK","veHzyuK","zgvSzxrL","y29UBMvJDa","y2vZC0HHBMq","v0rWz3e","zg5iEuu","CKLpALq","uhjAzK0","B0T3uMq","seDZtLu","zMX1C2HfEha","Dg9VigXHCMC","y2HnyxHdB3u","CeTsqKm","zw5fDMvUDa","B3nLrxzLBNq","zxjYtM8","v2LUzg93","ign1CNnVCIa","ywrKrxzLBNq","B3bLCNr5tMe","sgPbCvm","C3rVCMu","BMHKC28","BMnVzgLUzW","CgfNzwHPzgu","BNHOqwS","z2v0q3vYCMu","r0rpyLC","D1PZsM8","svzjsuu","uKnyuuC","BwvZ","x21PBMLoyxy","veTSzNa","ywjVCNq","zez2sfC","zMzmAw5L","AgfUz2u","D2LSBfjLy28","y0rJzgy","s0zVD0S","thrwzuW","u3vgt0C","u1jkBeS","ANr1se0","x2DLBMvYyxq","A2v5","BMCGzMfPBgu","C3jJ","A05VufK","zw5HyMXLvhi","rhLTq0K","vLHZsK4","q0Xpu0ve","AwrI","EMXdu0C","qxf4tuW","uKjvB08","AfjyCei","rMzIzNu","AMvmvhm","y2HLy2TdDxi","s2vOCfq","CMvZzxrfBMq","r2nowge","zezpAK4","rNLTvwK","A0PfCgO","Cvvgu28","DgHsA0i","BM5Ly3q","q3vZDg9Tq2W","tez2rem","BMv3vMvYC2K","yMfSu2nVCgu","CvHjy1C","x25HDMLNyxq","B2jOyu0","AxnAzxjV","Dhr3Awq","EvjLy29UBMu","DgXXwfa","yxnJCMLWDa","t29cBwW","vgfN","tvnABgy","DhbizwfKzxi","D0HpEeG","AgzJCfe","CMfUzg9T","suvtx0vsuK8","DxbKyxrLq3u","vNfysuy","t0HSAxC","BxnN","shLcsKG","BK1NCha","CMvZzxrdB3u","DM5eAhO"];return yo=function(){return t},yo()}function gb(t){vo={Armyo:function(r,i){return r(i)}}.Armyo(t,vo)}function mb(t){let e=M,r={hhYxj:function(i,o){return i(o)},PzVEI:function(i,o){return i(o)},qvybq:function(i,o){return i(o)},nrSpH:function(i,o){return i===o},WhNAT:function(i,o){return i in o},TKFyW:function(i){return i()}};return r[e(1299)](t,IDBDatabase[e(750)+"e"]["transact"+e(1286)])&&!r[e(827)]("objectStoreNames",IDBTransaction.prototype)?function(i,...o){let c=e,l=t[c(677)](r[c(873)](Ni,this),i,...o);return Zc.set(l,i[c(751)]?i.sort():[i]),r.hhYxj(Lt,l)}:r[e(794)](xb)[e(733)](t)?function(...i){let o=e;return t[o(1815)](r[o(873)](Ni,this),i),r[o(407)](Lt,Xc[o(1050)](this))}:function(...i){return Lt(t[e(1815)](r.qvybq(Ni,this),i))}}function wb(t){let e=M,r={lCiqZ:function(i,o){return i===o},zdyRQ:"function",DbOMu:function(i,o){return i(o)},gRkEb:function(i,o){return i instanceof o},KgJwZ:function(i,o){return i(o)},fcwIh:function(i,o,c){return i(o,c)},ITgQA:function(i){return i()}};return r.lCiqZ(typeof t,r[e(1433)])?r.DbOMu(mb,t):(r[e(1244)](t,IDBTransaction)&&r[e(1853)](pb,t),r.fcwIh(Mf,t,r[e(1915)](fb))?new Proxy(t,vo):t)}function Lt(t){let e=M,r={HIXCb:function(o,c){return o instanceof c},wmDsc:function(o,c){return o(c)},KpvcU:function(o,c){return o(c)}};if(r[e(642)](t,IDBRequest))return r.wmDsc(hb,t);if(wo.has(t))return wo[e(1050)](t);let i=r[e(959)](wb,t);return i!==t&&(wo[e(1592)](t,i),Eo[e(1592)](i,t)),i}function q(t,e){t=t-389;let r=yo(),i=r[t];if(q.DfCGqK===void 0){var o=function(x){let p="abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789+/=",m="",b="";for(let I=0,y,E,S=0;E=x.charAt(S++);~E&&(y=I%4?y*64+E:E,I++%4)?m+=String.fromCharCode(255&y>>(-2*I&6)):0)E=p.indexOf(E);for(let I=0,y=m.length;I<y;I++)b+="%"+("00"+m.charCodeAt(I).toString(16)).slice(-2);return decodeURIComponent(b)};q.lkIZbm=o,q.CGcnDz={},q.DfCGqK=!0}let c=r[0],l=t+c,u=q.CGcnDz[l];return u?i=u:(i=q.lkIZbm(i),q.CGcnDz[l]=i),i}var Mf,Df,kf,Xc,bo,Zc,wo,Eo,vo,Ni,Pf=Nf({"node_modules/idb/build/wrap-idb-value.js"(){let t=M,e={ngfcz:function(r,i){return r===i},dvjsG:t(1065)+t(1488),IXkVE:function(r,i){return r===i},uLxWS:t(1353),vkjbN:function(r,i){return r(i)},SuFOG:function(r,i){return r instanceof i},xntdP:"done",ibaUg:function(r,i){return r in i}};Mf=(r,i)=>i[t(1808)](o=>r instanceof o),Xc=new WeakMap,bo=new WeakMap,Zc=new WeakMap,wo=new WeakMap,Eo=new WeakMap,vo={get(r,i,o){let c=t;if(r instanceof IDBTransaction){if(e[c(690)](i,"done"))return bo[c(1050)](r);if(e[c(690)](i,e[c(404)]))return r[c(1065)+c(1488)]||Zc[c(1050)](r);if(e.IXkVE(i,e[c(472)]))return o[c(1065)+c(1488)][1]?void 0:o[c(1065)+"ore"](o[c(1065)+c(1488)][0])}return e[c(1186)](Lt,r[i])},set(r,i,o){return r[i]=o,!0},has(r,i){let o=t;return e[o(1374)](r,IDBTransaction)&&(e.IXkVE(i,e[o(1859)])||e.ngfcz(i,e[o(472)]))?!0:e.ibaUg(i,r)}},Ni=r=>Eo[t(1050)](r)}}),Bf={};ub(Bf,{deleteDB:()=>yb,openDB:()=>_b,unwrap:()=>Ni,wrap:()=>Lt});function _b(t,e,{blocked:r,upgrade:i,blocking:o,terminated:c}={}){let l=M,u={VmEyL:function(m,b,I,y,E){return m(b,I,y,E)},IDagm:function(m,b){return m(b)},dnHyE:l(955),lihPA:"versionc"+l(1369),LejcS:"blocked"},x=indexedDB[l(591)](t,e),p=Lt(x);return i&&x[l(1350)+l(953)](l(1729)+"eeded",m=>{let b=l;u[b(1895)](i,u[b(753)](Lt,x[b(1058)]),m[b(1892)+"on"],m[b(1405)+"on"],u[b(753)](Lt,x["transact"+b(1286)]))}),r&&x[l(1350)+l(953)](u[l(1607)],()=>r()),p[l(1101)](m=>{let b=l;c&&m[b(1350)+b(953)](u[b(1336)],()=>c()),o&&m[b(1350)+"Listener"](u[b(483)],()=>o())})[l(1600)](()=>{}),p}function yb(t,{blocked:e}={}){let r=M,i={vctDY:r(1771),CBpSY:function(c,l){return c(l)}},o=indexedDB[r(1923)+r(1655)](t);return e&&o[r(1350)+r(953)](i.vctDY,()=>e()),i[r(536)](Lt,o)[r(1101)](()=>{})}function Lf(t,e){let r=M,i={IVIIE:function(x,p){return x(p)},dXlNE:function(x,p){return x>=p},hfcpQ:function(x,p){return x<=p},tEeoq:function(x,p){return x|p},TaZwS:function(x,p){return x%p},hEfdL:function(x,p){return x!==p},pavGD:"NcCbt",xBPQm:r(1207)+"e",bOpfv:"readonly",PXxsP:function(x,p){return x in p},TeUMX:function(x,p){return x===p},KQMEZ:"UhVlU",dOkqo:r(676)};if(!(t instanceof IDBDatabase&&!i[r(1313)](e,t)&&i[r(1120)](typeof e,r(634)))){if(i.hEfdL(i.KQMEZ,i.dOkqo))return;_0x408743.log(_0x929d60)}if(_o[r(1050)](e))return _o[r(1050)](e);let o=e[r(666)](/FromIndex$/,""),c=e!==o,l=Ff[r(733)](o);if(!(o in(c?IDBIndex:IDBObjectStore).prototype)||!(l||zf[r(733)](o)))return;let u=async function(x,...p){let m=r;if(i.hEfdL(i.pavGD,i[m(579)])){if(i[m(1361)](_0x499850,_0xe0c3a1))return _0x2b4741?_0x217cdf:_0x3b5c9f;if(_0x3a0cf4){if(i[m(1691)](_0x369c1d,_0x31a90c))return _0x3fe68b}else{if(i[m(1420)](_0x24ccaa,-_0x2bd3b9))return _0xb08d1b;if(i[m(1691)](_0x5085a6+1,_0x53f57b))return _0x7dccc5}return _0x15f8bc[m(1876)](i[m(1536)](i[m(1491)](_0x99dce4,_0x3fba5c),0),_0x306d04/_0x4796bf|0,_0x3dcb20)}else{let b=this[m(414)+m(1286)](x,l?i[m(1909)]:i[m(892)]),I=b[m(1353)];return c&&(I=I[m(1219)](p[m(456)]())),(await Promise[m(990)]([I[o](...p),l&&b[m(1907)]]))[0]}};return _o[r(1592)](e,u),u}var zf,Ff,_o,bb=Nf({"node_modules/idb/build/index.js"(){let t=M,e={sylAh:t(1164)+"2|3",AnMqF:function(o){return o()},liAEB:t(1050),Pyuwj:t(1796),NLJEu:t(763),inNEr:"getAllKeys",ZgLiG:t(952),FHrEt:function(o,c){return o(c)},EVBHn:function(o){return o()},WCuYh:t(912),RofjA:t(1332)},r=e[t(488)].split("|"),i=0;for(;;){switch(r[i++]){case"0":e[t(646)](Pf);continue;case"1":zf=[e[t(446)],e[t(1496)],e[t(939)],e[t(1912)],e[t(820)]];continue;case"2":_o=new Map;continue;case"3":e[t(1220)](gb,o=>({...o,get:(c,l,u)=>Lf(c,l)||o[t(1050)](c,l,u),has:(c,l)=>!!Lf(c,l)||o[t(405)](c,l)}));continue;case"4":e.EVBHn(Pf);continue;case"5":Ff=[e[t(1612)],"add",e.RofjA,"clear"];continue}break}}}),Eb={idb:function(t){let e=M;t[e(924)]=Promise[e(1094)]()[e(1101)](()=>(bb(),Bf))[e(1101)](function(r){return r})}},Of={};function Pt(t){let e=M,r=(e(1106)+"0")[e(554)]("|"),i=0;for(;;){switch(r[i++]){case"0":return o[e(924)];case"1":if(c!==void 0)return c.exports;continue;case"2":var o=Of[t]={exports:{}};continue;case"3":var c=Of[t];continue;case"4":Eb[t](o,o[e(924)],Pt);continue}break}}Pt.d=(t,e)=>{let r=q;for(var i in e)Pt.o(e,i)&&!Pt.o(t,i)&&Object[r(903)+r(1712)](t,i,{enumerable:!0,get:e[i]})},(()=>{let t=M;Pt.o=(e,r)=>Object[t(750)+"e"]["hasOwnPr"+t(1712)][t(677)](e,r)})(),(()=>{let t=M,e={PxFjh:"undefined",pZXwR:t(1316),PhSfm:t(1556)+"le"};Pt.r=r=>{let i=t;e[i(1924)]!=typeof Symbol&&Symbol[i(524)+i(1416)]&&Object[i(903)+i(1712)](r,Symbol["toString"+i(1416)],{value:e[i(1722)]}),Object[i(903)+i(1712)](r,e[i(716)],{value:!0})}})();var Te={};(()=>{let t=M,e={wUYMr:function(a,n){return a(n)},XlHah:function(a,n){return a+n},HjAqS:function(a,n){return a+n},JiBbF:function(a,n){return a*n},mpuKj:function(a,n){return a*n},uLFKw:function(a,n,s){return a(n,s)},WKFEP:function(a,n){return a(n)},lyGGe:function(a,n){return a(n)},cdxpz:t(1617),ONkMa:"ffff",Moxfh:function(a,n){return a(n)},cYfDv:function(a,n){return a(n)},qAiZU:function(a){return a()},aLSwg:function(a,n){return a>n},sucUW:function(a,n){return a<n},FYSnq:function(a,n){return a-n},psyoi:function(a,n){return a===n},OxgRR:t(602),aPSel:t(1573),yPrzI:function(a,n){return a-n},YauRV:function(a,n){return a<n},VjEkK:function(a,n){return a-n},VeyzO:function(a,n){return a+n},mRnzO:function(a,n){return a+n},zFasJ:t(1534)+"t of ran"+t(1441),ZnZvU:function(a,n){return a||n},NYVMV:function(a,n){return a!==n},nMgpp:t(925),pkIqe:function(a,n,s){return a(n,s)},FHofv:function(a,n){return a<n},wevDB:function(a,n){return a|n},MohSu:function(a,n){return a>>n},vspRt:function(a,n){return a|n},EQHVi:function(a,n){return a&n},Uzqyi:function(a,n){return a===n},CLgTY:function(a,n){return a+n},pdiHc:function(a,n){return a&n},KxcWu:function(a,n){return a|n},JmyCW:function(a,n){return a>>n},krBAo:function(a,n){return a|n},rwOss:function(a,n){return a|n},tNeJK:function(a,n){return a&n},OhHLw:function(a,n){return a&n},hnryZ:function(a,n){return a>>n},rIOjT:function(a,n){return a===n},egrBp:"ksesK",EXhfw:function(a,n){return a(n)},fCDwL:function(a,n){return a>>>n},kNoPY:function(a,n){return a(n)},rDnlS:function(a,n){return a===n},THYaI:t(1789)+t(792)+t(1493)+t(857),xzszr:function(a,n){return a>=n},wpCEN:function(a,n){return a!==n},czOeU:function(a,n,s){return a(n,s)},YuUTG:function(a,n){return a!==n},UmDWn:function(a,n,s){return a(n,s)},XnTPe:function(a,n,s){return a(n,s)},UtVIl:function(a,n){return a!==n},xzcPJ:function(a,n,s){return a(n,s)},HyBJH:function(a,n,s){return a(n,s)},ZHBjX:function(a,n,s){return a(n,s)},MqtjI:function(a,n,s){return a(n,s)},LZHEV:function(a,n,s){return a(n,s)},ZKrDT:function(a,n,s){return a(n,s)},rvvVM:function(a,n){return a!==n},INNcg:function(a,n,s){return a(n,s)},WoBPH:function(a,n){return a!==n},RNcqm:function(a,n,s){return a(n,s)},YBrJO:function(a,n){return a!==n},StjiJ:t(1614),lOQjP:function(a,n){return a(n)},xsFKm:function(a,n,s){return a(n,s)},HawbS:function(a,n,s){return a(n,s)},xjQny:function(a,n){return a(n)},KspFb:function(a,n,s){return a(n,s)},fYAht:function(a,n){return a(n)},dqvnc:function(a,n,s){return a(n,s)},daPRh:function(a,n){return a(n)},eKPCT:function(a,n,s){return a(n,s)},uEOrE:t(1789)+"required field: service",Pfncp:"Missing "+t(792)+t(1493)+t(1664),DShQc:function(a,n){return a(n)},YvMcJ:function(a,n){return a&n},tPesZ:function(a,n,s){return a(n,s)},LrilF:function(a,n,s){return a(n,s)},rfQGD:"Unimplemented type: ",ldqLD:t(1273)+t(895),iLGwN:function(a,n){return a===n},vmHGq:t(1241),HNTOI:t(651),RDYew:function(a,n){return a>>>n},YumVC:function(a,n){return a!==n},dFvHW:"ItqWH",TXDbS:function(a,n){return a===n},mOMAN:t(1521),sEiaQ:"HUKRa",YPguL:function(a,n){return a>n},cWRJl:function(a,n){return a+n},tRKUw:function(a){return a()},lgiLM:t(1165),nZzWZ:function(a,n){return a>n},GZQZQ:function(a,n){return a>n},iwCWp:function(a,n,s){return a(n,s)},OHliw:function(a,n,s){return a(n,s)},jtjiG:function(a,n){return a<n},bXwIk:function(a,n){return a-n},OcUeu:function(a,n,s,d){return a(n,s,d)},mUGRa:t(726),vSFwx:function(a,n){return a+n},hCgyb:function(a,n){return a&n},qLrGD:function(a,n){return a(n)},OBHek:function(a,n){return a===n},etgLU:t(1290),sCsQH:function(a,n){return a+n},cAXFq:function(a,n){return a<<n},psbJg:function(a,n){return a&n},adNVj:function(a,n){return a&n},dzJvZ:function(a,n){return a==n},AhKNW:function(a,n){return a>=n},VDcgp:function(a,n){return a+n},GuQrS:function(a,n){return a&n},uhMYh:function(a,n){return a<<n},hUqyP:function(a,n){return a&n},ykOJM:function(a,n){return a&n},FwJqy:function(a,n){return a<n},qOHmB:function(a,n){return a<=n},RUqVc:function(a,n){return a!==n},rbwam:t(1780),ieBPl:t(659),DLGnu:function(a,n){return a(n)},PrMdL:function(a,n){return a>=n},MCEUD:function(a,n){return a+n},zFtVT:function(a,n){return a+n},MJuoK:function(a,n){return a+n},UgqMa:function(a,n){return a&n},fGRYK:function(a,n){return a|n},RBUoO:t(684),vvLFi:function(a,n){return a|n},XAFUl:function(a,n){return a|n},kVzaa:function(a,n){return a&n},saEBJ:function(a,n,s){return a(n,s)},TKlfp:function(a,n){return a&n},hyWgd:t(425),QHApF:function(a,n){return a(n)},rcsvS:t(650),zEkpA:t(1775),pGsra:function(a,n){return a<n},DOPZz:function(a,n){return a-n},LJHEZ:function(a,n){return a<n},vhcun:function(a,n){return a<n},GVTNw:function(a,n,s){return a(n,s)},JVuAD:function(a,n){return a<n},JOLjt:function(a,n){return a+n},ZdYlH:function(a,n){return a<<n},pTTXf:function(a,n){return a<n},JGezb:function(a,n){return a<n},ubFde:function(a,n){return a===n},ZvFRg:t(678),szFbx:function(a,n){return a<n},BBVJF:function(a,n){return a|n},ToxHm:function(a,n){return a>>n},cbANE:function(a,n){return a|n},ZfbIh:function(a,n){return a>>n},fDQbJ:function(a,n){return a>>n},xVLjq:function(a,n){return a|n},EVPpT:function(a,n,s){return a(n,s)},tWbKA:function(a,n){return a(n)},ljKYQ:function(a,n){return a<n},MtKIo:function(a,n){return a>=n},thRkB:function(a,n,s){return a(n,s)},IHhqM:function(a,n){return a|n},iBHzz:function(a,n,s){return a(n,s)},qXIcW:function(a,n,s,d){return a(n,s,d)},YZoeH:t(861)+t(431)+"ck",XGpmQ:function(a,n,s,d){return a(n,s,d)},twJgp:"x_frontier_is_ack",BrqTa:function(a,n,s){return a(n,s)},aVLia:t(1694)+t(1798)+t(1640)+"2",CeOVi:function(a,n){return a|n},ujnQM:function(a,n){return a&n},bcbOl:function(a,n){return a>>>n},tvngX:function(a,n){return a|n},fKzIk:function(a,n){return a|n},vXAVr:t(955),NKFoc:function(a,n,s){return a(n,s)},iFASZ:t(1825),HDwcY:function(a,n){return a(n)},RIVgX:function(a,n){return a(n)},SoBbe:t(487),PrZfM:"uLYva",aeAwE:function(a,n){return a(n)},qNcqU:function(a,n){return a<<n},SrOlc:function(a,n){return a&n},fGwCq:function(a,n){return a<<n},HpAMQ:function(a,n){return a&n},HScoQ:t(1739),myAYH:function(a,n){return a&n},sAirl:function(a,n){return a&n},xVUnG:function(a,n){return a(n)},LtVeL:function(a,n){return a(n)},pXYDQ:function(a,n){return a&n},xRnyW:function(a,n){return a&n},ujncs:function(a,n){return a|n},UInbZ:function(a,n){return a<<n},fdbFi:function(a,n){return a>>>n},QOlSQ:function(a,n){return a<n},yoJwr:function(a,n){return a<n},AKzHI:function(a,n){return a+n},npjFE:function(a,n){return a+n},UoLDg:function(a,n){return a!==n},BHiiH:function(a,n){return a&n},PGDcu:function(a,n){return a+n},QPYDV:function(a,n){return a>>>n},wRMlu:function(a,n){return a&n},vdRTP:function(a,n){return a!==n},msqae:function(a,n){return a>>>n},SSpTy:function(a,n){return a+n},hNJBV:function(a,n){return a!==n},dpKnr:function(a,n){return a|n},rNfzS:function(a,n){return a&n},HHDai:function(a,n){return a>>>n},FkXkz:function(a,n){return a!==n},iXYFu:function(a,n){return a|n},mMfJe:function(a,n){return a>>>n},lNHTs:function(a,n){return a&n},mcxvk:function(a,n){return a!==n},vJDIy:function(a,n){return a|n},DTwHk:function(a,n){return a|n},RGgSb:function(a,n){return a|n},bzFvh:"JstPV",hpkam:t(1038),obhaM:t(1599),zZpyN:function(a,n){return a===n},lVkHi:t(1707),lAoGt:t(1873),KUCqR:function(a,n){return a|n},BAlSI:function(a,n){return a<<n},vyYmn:function(a,n){return a<<n},JruYx:function(a,n){return a|n},HrRsg:function(a,n){return a|n},fXoGt:function(a,n){return a<<n},WWoyd:function(a,n){return a<<n},DymCI:function(a,n){return a|n},BvEcj:function(a,n){return a<<n},wLVvt:function(a,n){return a<<n},PsYKe:function(a,n){return a|n},QFrSR:function(a,n){return a<<n},YfkGX:function(a,n){return a<<n},kEQaE:function(a,n){return a>>>n},xdLlN:function(a,n){return a|n},FttAg:function(a,n){return a!==n},wIBZS:t(1362),KZKRD:t(921),jzLgj:function(a,n){return a&n},kFVXG:function(a,n,s){return a(n,s)},xIUCY:function(a,n,s){return a(n,s)},TliJh:t(1905),rVkFG:function(a,n){return a(n)},NoMOO:function(a,n){return a<=n},AffEq:function(a,n){return a>=n},AJfTA:function(a,n){return a|n},fpmLl:function(a,n){return a/n},VzvGR:function(a,n){return a+n},zlCSG:function(a,n){return a+n},ofYHC:function(a,n){return a<=n},pXdUq:function(a,n){return a&n},GcNXa:function(a,n){return a>=n},biDll:function(a,n){return a<<n},PQwpr:function(a,n){return a&n},OPPdF:function(a,n){return a>=n},llumA:function(a,n){return a-n},BBWfL:function(a,n){return a|n},kaFsU:function(a,n){return a|n},nTWfY:function(a,n){return a<<n},vtcaR:function(a,n){return a&n},yURLq:function(a,n){return a<<n},CYpJV:function(a,n){return a!==n},NKiZD:t(1340),yBbiv:t(783),ASIrz:function(a,n){return a>>>n},OoSom:function(a,n){return a&n},EQAQe:function(a,n){return a&n},xeoxy:function(a,n){return a>>>n},tbecd:function(a,n){return a+n},aUCCV:function(a,n){return a+n},piWnf:function(a,n){return a+n},PYGtf:function(a,n){return a<<n},cHyGs:function(a,n){return a>>>n},HEXhy:t(1504),lrtMb:t(1497),JGyMr:function(a,n){return a===n},PrjdS:function(a,n){return a===n},qKbIb:function(a,n){return a===n},JLfwA:function(a,n){return a===n},jhysY:function(a,n){return a===n},pKdVH:function(a,n){return a+n},EhWOk:function(a,n){return a&n},ArWXq:function(a,n){return a>>>n},MwHUI:function(a,n){return a>>>n},JdrGp:function(a,n){return a&n},OXdue:function(a,n){return a&n},iQehb:function(a,n){return a>>>n},rfogX:function(a,n){return a>>>n},VnwpC:function(a,n){return a>>>n},Pbgyt:function(a,n){return a&n},oJvUu:function(a,n){return a&n},zUatA:function(a,n){return a&n},wHOxH:function(a,n){return a>>>n},rNqZV:function(a,n){return a>>>n},uCksm:function(a,n){return a&n},YhPVF:t(768)+t(398),CnHpn:t(592)+t(1568),fijta:"MAX_RETR"+t(1422)+"R",jWqcW:t(1699)+"ERROR",syVZr:t(1716),SAtiH:t(1177)+"3",ovEAN:t(1399),WDpgq:function(a,n){return a===n},EzhbA:"CbRWM",FymUi:"VgnId",eHCnm:function(a,n){return a(n)},kCkcX:function(a,n){return a(n)},sfaTf:"eUqHL",fEckG:function(a,n){return a(n)},JACfp:"script",HFmev:t(1571),QXUeO:function(a,n){return a!==n},GoRiU:t(1430),mGaOs:"Unhandle"+t(1445),OBgxl:function(a,n){return a+n},rsYGn:function(a,n){return a!==n},NYQHl:t(506),MzGNU:t(591),zaWhM:function(a,n,s){return a(n,s)},ynUyw:t(755),DKeGb:t(514),vCiaQ:function(a,n,s){return a(n,s)},vMZTi:function(a,n){return a instanceof n},LlPkL:function(a,n){return a===n},chaBr:function(a,n,s){return a(n,s)},HQlBR:"hRXpB",MCwcr:function(a,n){return a||n},HRHJF:function(a,n){return a!=n},kQauc:"undefined",GDObW:function(a,n){return a||n},IDEnt:t(571)+t(455)+t(1255)+"imes in process",gOcXd:t(1578),BescU:function(a,n){return a<n},gKYlj:function(a,n){return a===n},wtMkn:"cDaRb",ocqve:function(a,n){return a===n},eutwn:function(a,n){return a&n},mUdzE:t(1847),WkLlY:function(a,n){return a-n},Otocx:function(a,n){return a>=n},mZmOa:function(a,n){return a|n},MgfsR:function(a,n){return a&n},VXsJN:function(a,n){return a<n},yHeUG:function(a,n){return a|n},BARNq:function(a,n){return a&n},crEJF:function(a,n){return a>=n},dRQnc:function(a,n){return a-n},yctnd:function(a,n){return a|n},GQWqY:function(a,n){return a|n},launw:function(a,n){return a<<n},wPsIS:function(a,n){return a+n},UASpB:t(672),mACTt:"ppe",odbqQ:function(a,n){return a<n},UTpXC:t(841),jgZrz:t(1440),RCpqK:function(a,n){return a>>n},DkdvK:function(a,n){return a|n},mHGwB:function(a,n){return a&n},VOGWu:function(a,n){return a===n},vckCG:t(617)+"5|4",qKmAQ:function(a,n){return a<<n},nqGaN:function(a,n){return a&n},MyIpU:function(a,n){return a|n},bqIZZ:function(a,n){return a>>n},DsKoC:function(a,n){return a|n},OxeDN:function(a,n){return a&n},hhyvA:function(a,n){return a|n},KBcUD:function(a,n){return a|n},wosoI:function(a,n){return a>>n},MwGgp:function(a,n){return a|n},tJWpx:function(a,n){return a&n},MPGij:"pKkYl",POrkd:t(634),JcUuP:function(a,n){return a instanceof n},RaWze:t(1122),MSZlf:t(1852),oMIlg:function(a,n){return a instanceof n},ThOCY:t(958)+t(1919),GmDvl:"text/pla"+t(1622)+t(1463),HhBJt:function(a,n){return a>=n},Wpfmd:function(a,n){return a(n)},ZVGjN:t(408)+t(499),Womwr:function(a,n){return a==n},XnesT:function(a,n){return a(n)},Lvujh:function(a,n){return a!==n},NxfIW:t(549),CObNj:t(1314)+"ascript",ZSQBs:function(a,n){return a+n},xhbYL:t(838)+t(1278)+t(1735)+"P",vWmmb:"aPvQv",LWDdU:"Ppzbq",UIpMr:t(1632),OsXKm:function(a,n){return a===n},LmxOU:function(a,n){return a instanceof n},FcsHb:function(a,n){return a+n},FQDDE:t(439),YeLWK:function(a,n){return a&n},Hkeac:"QFHQN",WqGFt:"versionc"+t(1369),fPGee:t(1e3),DPZpe:function(a,n){return a<=n},PmpWR:function(a,n){return a>=n},JHJlh:function(a){return a()},ardec:function(a,n){return a===n},DxoCo:t(1807),cypMS:function(a){return a()},WrPhF:function(a,n){return a(n)},laPVi:"NLvcm",AlsjX:t(1503),JhgOP:function(a,n){return a===n},tYMvV:function(a,n){return a!==n},hgMvD:t(1397),HVkkt:t(1543),Hbktb:t(891),paIgi:t(1884),CTRwK:function(a,n){return a||n},IFIxa:t(1152),ptGac:function(a,n){return a||n},XGeBo:t(513),smyFW:function(a,n){return a||n},RnmEb:function(a,n){return a||n},WGoMP:function(a,n){return a||n},QMVUT:function(a,n){return a||n},ADMJe:"AjScr",kiqCs:function(a,n){return a||n},UlcUo:function(a,n){return a||n},ApRkH:t(1201)+"DB failed",HqfVj:t(1927),TBKtR:t(1087)+"id",QmmFH:function(a,n){return a&n},NmLXD:function(a,n){return a|n},ZcLQS:function(a,n){return a<<n},ZJCqZ:function(a,n){return a|n},yXLPw:function(a,n){return a>n},jPIZk:t(1454),TFRXQ:t(1524),tDUiH:t(543),CBqyl:t(861)+t(1553),YWpeN:function(a,n,s){return a(n,s)},UInYR:t(861)+t(848)+"sgid",jZsyn:"need_ack",SXJBL:function(a,n,s,d){return a(n,s,d)},ROpSE:"is_ack",ttAlD:function(a,n){return a&&n},gRdoK:t(1072),cjsAf:"received",jIUim:function(a){return a()},xICog:function(a,n){return a(n)},sDMMK:function(a,n){return a(n)},LIvlp:function(a,n){return a instanceof n},MJaER:"none_none",VjuRC:function(a,n){return a(n)},sylnA:function(a,n){return a(n)},tYlLF:function(a,n){return a+n},OIEHG:function(a,n){return a+n},Heipu:t(860),VqXIF:function(a,n){return a||n},AVApf:" > ",ApvWs:t(1652),lQSqu:t(1057),TytVr:function(a,n){return a>n},XyHrd:function(a,n){return a+n},CNMpl:t(1885),NucLD:"4|0|3|1|2",rFxOI:function(a,n){return a<n},Ffbfu:function(a,n){return a+n},bRKXZ:function(a,n){return a+n},GsUiE:function(a,n,s,d){return a(n,s,d)},Ugzbl:function(a,n){return a|n},IwpbU:function(a,n){return a|n},LzEYS:function(a,n){return a+n},DjVYW:function(a,n){return a+n},ZWWju:function(a,n){return a|n},DSAga:function(a,n){return a|n},wKkVJ:function(a,n){return a<<n},RjAzP:function(a,n){return a+n},ATyUH:function(a,n){return a+n},eSEbg:function(a,n){return a>>>n},BMkUL:function(a,n){return a>>>n},bPdCT:function(a,n){return a+n},ZxkEh:function(a,n){return a>>>n},GKeFq:function(a,n){return a+n},iKmKW:function(a,n){return a&n},CwJgC:function(a,n){return a+n},bVkDa:function(a,n){return a+n},eIpnU:function(a,n){return a(n)},TVzmg:function(a,n){return a!==n},dYTpz:t(1591),swbny:function(a,n){return a+n},DOvQM:t(1834)+t(433)+"|8|6|10|2",FzvoF:function(a,n){return a<n},SydMz:function(a,n){return a|n},LjvcT:function(a,n){return a>>>n},DJSbC:function(a,n){return a&n},suvEQ:function(a,n){return a>>>n},hwPGC:function(a,n){return a>>>n},AuBwJ:function(a,n){return a&n},mICjY:function(a,n,s,d){return a(n,s,d)},kHtGR:function(a,n){return a|n},beSZN:function(a,n){return a(n)},hLVkJ:function(a,n){return a+n},DRkKf:t(1633),ecuGG:t(1580)+t(534),tNNxe:function(a,n,s,d){return a(n,s,d)},zPXOb:t(1823),vpmjT:t(661),rtHKJ:function(a,n,s,d){return a(n,s,d)},OoBml:"service-"+t(863),tiMMt:"name",udBja:function(a,n,s,d){return a(n,s,d)},MRQhr:t(1586),URDUX:function(a,n){return a(n)},tbynw:function(a,n){return a(n)},tDHHU:function(a,n,s){return a(n,s)},tpzyB:function(a,n){return a+n},kuvli:t(1089)+t(1297),tbgqE:"ALL",NSXFw:function(a,n,s,d){return a(n,s,d)},qPQVf:t(913),pwIiy:function(a,n){return a(n)},biMgs:t(1179)+"r",YSWQS:function(a,n){return a!==n},GkkRY:"KeTJT",iVkUi:function(a,n,s){return a(n,s)},QtXsE:t(902),ACoUk:function(a,n,s,d){return a(n,s,d)},uexTx:t(724),RoVBa:function(a,n,s,d){return a(n,s,d)},GfdUv:function(a,n,s){return a(n,s)},nPjjn:t(861)+t(1200),ZRnJY:function(a,n,s){return a(n,s)},XCXwv:"x_frontier_ttl",DcKDr:t(897)+"s",ItWgK:function(a,n,s){return a(n,s)},vwNOw:t(1882)+t(422)+"e",cDcdf:t(1882)+t(1683)+"ue",GHUGz:t(453),CRFDj:function(a){return a()},eCmwF:function(a,n){return a!==n},gvNLk:t(1809),AtgbB:t(1400),wZsJo:function(a,n,s){return a(n,s)},KDbGU:t(1289),WbuJH:function(a){return a()},baEyQ:function(a){return a()},CRkHO:t(1458),XTqnm:function(a,n){return a===n},YDVec:function(a){return a()},XlLTX:t(1478),giLRj:t(430),vxGYT:function(a,n){return a(n)},fpRkO:function(a,n,s){return a(n,s)},VvLtU:function(a){return a()},xwafD:function(a,n){return a===n},RsDBx:t(1647),wQaOf:t(567),CrNSb:t(1016),LTuTw:t(1473)+t(1790)+"s",LXbcK:t(679),jeLTs:function(a,n){return a===n},xupEK:function(a,n,s,d){return a(n,s,d)},CnFFp:function(a,n,s){return a(n,s)},DSCNC:function(a,n,s){return a(n,s)},PcrmG:t(887),zvyGl:function(a,n,s){return a(n,s)},znYUw:function(a,n,s){return a(n,s)},LJEQb:t(1741),nuiAq:function(a,n,s){return a(n,s)},LtjEg:function(a,n){return a!==n},XlRMW:function(a,n){return a!==n},GBaoh:t(1643),ClOJX:function(a,n,s){return a(n,s)},jatXW:function(a,n){return a(n)},zSjIW:function(a,n,s){return a(n,s)},TVRTB:t(658),iGYuX:function(a,n,s,d){return a(n,s,d)},GFriP:t(1059)+"fer",KQUXD:function(a,n){return a/n},ogRFc:t(476),UaWcu:"please p"+t(1624)+t(890)+t(496)+t(1461)+"tructor "+t(1630)+"ined",pKRBC:t(806)+t(1582)+t(1872)+"ct",ivNLe:t(1127),hDNXz:t(1816),Hffov:t(1098),CpHZA:t(1356),UHnrt:"pageshow",cAYsH:function(a,n){return a===n},XCAye:t(644),AyYin:function(a,n){return a===n},hwttf:function(a,n){return a!==n},zOFBK:function(a,n){return a==n},adZmE:t(1046),BmQox:t(1411),qrFtB:"device_id",WqSln:t(1202),UjoDz:t(1908),HFNtT:t(1310)+"0",kKdEz:function(a,n,s){return a(n,s)},WYeMq:function(a,n){return a!==n},zlovT:"IXUwt",SsiUV:t(1829),kmOiI:t(1773),zJnBe:function(a,n,s){return a(n,s)},xKOhs:t(1160),ISswP:function(a,n){return a>n},uEJvb:function(a,n,s){return a(n,s)},sXUSj:t(1675)+">",DgWGz:function(a,n){return a*n},tNIBU:function(a,n){return a-n},dkTBS:function(a,n,s){return a(n,s)},BHQtM:function(a,n){return a!==n},faBTr:"timeout",PQhHn:function(a,n){return a(n)},BsKoC:function(a,n){return a===n},obbaq:"FxUWs",QmGNX:t(561),hYtzr:t(749)+t(771)+t(1861)+t(1628)+t(546),ckURl:t(1697)+" try rec"+t(1447)+"g",gQYmi:function(a,n){return a(n)},TAIoT:function(a,n){return a===n},lsRxL:function(a,n){return a===n},xuxOA:function(a,n,s){return a(n,s)},Yakoc:function(a,n,s,d){return a(n,s,d)},xDRxA:function(a,n,s){return a(n,s)},Toemy:t(1685),qnQns:function(a,n){return a!==n},wbxZe:t(1518),rFRrW:t(1284),TJrrv:t(1922)+"0",UULCg:function(a,n,s){return a(n,s)},KmpVt:function(a,n,s){return a(n,s)},hmOKv:function(a,n){return a(n)},HbyiC:function(a,n){return a!==n},jtolj:t(1074),exvWI:t(1203),GaCtN:function(a,n){return a===n},EmEWs:"lWSIX",tiDbL:t(1044)+"1|5|4|6",wnFNP:t(1551)+t(1529)+t(517)+t(1123)+"ed",zAxgl:t(1817),XdAEV:t(1662),wyKfC:"uKxKA",HiVPR:t(1736),pboqb:function(a,n){return a===n},fJEVR:t(1551)+t(1830)+"y closed",YEwkD:function(a,n){return a>>>n},GtAHr:function(a,n){return a>>>n},mcoQs:function(a,n,s){return a(n,s)},FcooI:t(1137),oDnWB:t(403),MhwAZ:function(a,n){return a==n},ecrYF:t(1113)+t(1538)+t(484)+t(1530)+"a must b"+t(779)+t(1505)+" arraybu"+t(832),tlaah:t(1751),hkcbD:function(a,n){return a instanceof n},UbamR:function(a,n){return a(n)},cNmuj:t(1113)+t(1538)+t(1756)+t(534),YgmWZ:function(a,n){return a instanceof n},sgLJb:function(a,n){return a===n},MLhgv:t(1138),pgAoa:function(a,n){return a<n},nOHtr:function(a,n){return a===n},Respd:t(998),TIveU:function(a,n){return a(n)},uSkmu:function(a,n){return a(n)},dtVSN:function(a,n){return a&n},LYajp:function(a,n){return a===n},tlFiS:"CFxhB",vpUGf:function(a,n){return a!==n},fzlGx:"manual r"+t(1259)+t(1654),nqxIk:t(1506)+"2",ELErv:function(a,n){return a(n)},hMzeZ:t(1079),jsuSP:function(a,n){return a*n},NRCgl:function(a,n){return a/n},ewwvP:function(a,n){return a!=n},tUkCe:t(1348),mhiiK:function(a,n){return a!=n},SJNmo:function(a,n){return a!=n},ZwoEb:"Object",asEGm:function(a,n){return a===n},PRZiZ:function(a,n){return a!=n},UmlJK:function(a,n){return a===n},EsEJU:t(775)+t(1526)+"alScope",AqxML:function(a,n){return a!=n},nLLPE:function(a,n){return a!=n},qoUKR:function(a,n){return a===n},TqpvD:function(a,n,s){return a(n,s)},GqMxz:t(1629)+"qos__"};Pt.r(Te),Pt.d(Te,{FWS:()=>Ep,CustomErrorEvent:()=>Md,createCloseEvent:()=>ft,ReconnectEvent:()=>Nd,createErrorEvent:()=>st,decodedFrame:()=>Vt,createOpenEvent:()=>qd,CustomCloseEvent:()=>Bd,createReconnectEvent:()=>na,FrontierMessageEvent:()=>Fd,encodeFrame:()=>Nt,createMessageEvent:()=>Hd,OpenEvent:()=>Ud,ErrorCode:()=>Zt,Event:()=>$n,MessageEvent:()=>zd});let r="";function i(a=""){let n=t,s="02",d=""+Date[n(829)](),f=r||(r=e[n(1701)](x,a)),h=Math[n(1421)]()[n(524)](16)[n(797)](-6);return e.XlHah(e.XlHah(e.HjAqS(s,d),f),h)}function o(){let a=t;return e[a(1352)](e[a(1135)](1e4,Date[a(829)]()),Math[a(1533)](e[a(1748)](1e4,Math[a(1421)]())))}function c(a){let n=t;return(Array(8)[n(854)]("0")+e[n(614)](parseInt,a,10)[n(524)](2))[n(797)](-8)}function l(a){let n=t;return e.XlHah(e[n(1701)](Array,4)[n(854)]("0"),parseInt(a,2)[n(524)](16))[n(797)](-4)}function u(a){let n=t,s=a[n(554)](/\./)[n(1243)](h=>c(h)),d=[];return d[0]=e[n(1688)](l,e[n(1352)](s[0],s[1])),d[1]=e[n(1874)](l,e[n(1062)](s[2],s[3])),[n(1617),e[n(1572)],e[n(1572)],e[n(1572)],e[n(1572)],e.ONkMa,d[0],d[1]][n(854)]("")}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(769)](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]))/.test(a);return s?e[n(697)](u,a):d?e[n(1560)](p,a):n(812)+n(812)+n(812)+n(812)}function p(a){let n=t,s={AhRcY:n(587),UMQuH:function(T){return e[n(1469)](T)}},d="",f=[],h=0,w=0,v=!0,g=n(1617);if(e[n(1792)](a[n(1718)]("::"),-1)){let T=a[n(554)]("::");for(let N=0;N<T[n(1900)];N++){let B=T[N];if(e.aLSwg(B.indexOf(":"),0)){let K=B[n(554)](":");v&&(h=K.length),w+=K[n(1900)];for(let Y=0;e[n(1096)](Y,K.length);Y++)if(K[Y][n(1900)]!==4){let pe=g[n(1928)+"g"](0,e[n(964)](4,K[Y][n(1900)])),qe=pe[n(851)](K[Y]);f[n(1264)](qe)}else f[n(1264)](K[Y]);v=!1}else if(e[n(498)](e[n(1147)],e[n(600)]))this[n(1257)](s[n(1449)],_0x410c7b.message),s.UMQuH(_0x2425f6);else{if(B.length!==4){let K=g[n(1928)+"g"](0,e.yPrzI(4,B[n(1900)])),Y=K[n(851)](B);f.push(Y)}else f[n(1264)](B);v&&(h+=1),w+=1,v=!1}}let P="";for(let N=0;e[n(1869)](N,e[n(742)](8,w));N++)P=P[n(851)](g);for(let N=0;e[n(1869)](N,f[n(1900)]);N++)N===h?(d=d[n(851)](P),d=d[n(851)](f[N])):d=d.concat(f[N]);return d}{let T=a[n(554)](":");for(let P=0;e.YauRV(P,T[n(1900)]);P++){let N=T[P];if(T[P][n(1900)]!==4){let B=g[n(1928)+"g"](0,e[n(1838)](4,T[P][n(1900)])),K=B[n(851)](N);d=d[n(851)](K)}else d=d.concat(N)}return d}}function m(a,n){let s=t,d=a[s(1378)];e[s(657)](void 0,d)&&(s(409)==="WKEPA"?(this[s(1886)]=_0x5dc650,this[s(1672)]=_0x1664e4,this[s(1181)]=_0xaefa36?_0x14cbd6:_0x30d8e4?_0x157d2e:null):(ue(n,10),G(n,d)));let f=a.value;if(e[s(657)](void 0,f)){if(e[s(657)](e[s(1428)],e.nMgpp))return e[s(1688)](_0x2965c9,e[s(1352)](e[s(573)](e[s(421)](e[s(1102)],_0xe6144c)," + "),e[s(415)](_0x2437ea,1))+s(391)+_0x37e775);e[s(614)](ue,n,18),e[s(1532)](G,n,f)}}function b(a){let n=t;if(e[n(1337)](e[n(493)],e[n(493)])){let s={};e:for(;!e[n(1778)](J,a);){let d=e[n(1778)](le,a);switch(e[n(957)](d,3)){case 0:break e;case 1:s[n(1378)]=e[n(614)](O,a,e[n(1381)](le,a));break;case 2:s[n(857)]=O(a,e.cYfDv(le,a));break;default:e[n(614)](D,a,e[n(1604)](7,d))}}if(e[n(702)](void 0,s[n(1378)]))throw new Error(n(1789)+n(792)+n(1493)+n(1378));if(e[n(702)](void 0,s[n(857)]))throw new Error(e[n(1331)]);return s}else _0x3db24d=_0x507012[n(1104)+"At"](_0x4ee1ea),e[n(1857)](_0x2c853a,128)?_0x5a4dd5[_0x18f8aa++]=_0x52ab56:_0xbc4135<2048?(_0x1028c4[_0x5239e1++]=e[n(1661)](e[n(1141)](_0x4a25a1,6),192),_0x31aa97[_0xfecd2b++]=e[n(731)](e[n(1698)](63,_0x34145d),128)):e.Uzqyi(e[n(1698)](64512,_0x59ca54),55296)&&e[n(872)](e.EQHVi(64512,_0x990397=_0x493de2.charCodeAt(_0x58f273+1)),56320)?(_0x85552a=e[n(1642)](65536,e.pdiHc(1023,_0x4e77f6)<<10)+(1023&_0x56e4a1),++_0x13d53c,_0x560ef7[_0x37d621++]=e[n(968)](e.JmyCW(_0x120f85,18),240),_0x2e1936[_0x2a102d++]=e[n(1319)](e[n(1684)](e.MohSu(_0xd2eaf7,12),63),128),_0x1b77e2[_0x1d989d++]=e[n(725)](e.tNeJK(_0x1abb51>>6,63),128),_0x3ae60d[_0x3220cf++]=e[n(1604)](63,_0x414336)|128):(_0x19dd3c[_0x16b033++]=e[n(1141)](_0x390ef9,12)|224,_0x14819d[_0xe00677++]=e.KxcWu(e[n(1858)](e[n(757)](_0x1fe64d,6),63),128),_0x5b8f78[_0x2f9081++]=e[n(1858)](63,_0x4f812b)|128)}function I(a){let n=t,s=e[n(1469)](R);return e[n(1532)](y,a,s),e[n(1778)](F,s)}function y(a,n){let s=t,d=a[s(1719)];e[s(1782)](void 0,d)&&(e[s(1053)](ue,n,8),ut(n,d));let f=a.LogID;e[s(1067)](void 0,f)&&(e[s(842)](ue,n,16),e[s(946)](ut,n,f));let h=a.service;e[s(1921)](void 0,h)&&(e.xzcPJ(ue,n,24),e[s(1427)](ut,n,e[s(697)](L,h)));let w=a.method;e.wpCEN(void 0,w)&&(e[s(1146)](ue,n,32),e[s(946)](ut,n,e[s(1381)](L,w)));let v=a[s(1061)];if(e[s(1067)](void 0,v))for(let pe of v){e.ZHBjX(ue,n,42);let qe=e[s(1469)](R);m(pe,qe),ue(n,qe[s(1646)]),e.MqtjI(W,n,qe),e[s(1381)](k,qe)}let g=a[s(1608)+s(1355)];g!==void 0&&(e[s(1889)](ue,n,50),G(n,g));let T=a[s(1764)+s(1709)];e[s(1782)](void 0,T)&&(ue(n,58),e[s(1146)](G,n,T));let P=a[s(1032)];e[s(1921)](void 0,P)&&(e.HyBJH(ue,n,66),ue(n,P[s(1900)]),e.ZKrDT(Ne,n,P));let N=a.LogIDNew;e[s(786)](void 0,N)&&(e[s(978)](ue,n,74),G(n,N));let B=a[s(1318)+s(800)];e[s(1902)](void 0,B)&&(e[s(842)](ue,n,82),e[s(418)](G,n,B));let K=a[s(713)];if(e[s(628)](void 0,K))if(e[s(498)](e[s(1680)],e[s(1680)]))e[s(418)](ue,n,90),e[s(946)](G,n,K);else return e[s(1856)](this[s(952)],this[s(1468)+"ount"]);let Y=a[s(1155)+"e"];e[s(657)](void 0,Y)&&(e.ZHBjX(ue,n,96),e[s(1889)](ut,n,e[s(1778)](L,Y)))}function E(a){return S(e.lOQjP(z,a))}function S(a){let n=t,s={};e:for(;!e[n(1778)](J,a);){let d=e[n(1560)](le,a);switch(e[n(957)](d,3)){case 0:break e;case 1:s[n(1719)]=e[n(1324)](bt,a,!0);break;case 2:s[n(1276)]=e[n(461)](bt,a,!0);break;case 3:s[n(661)]=e[n(904)](le,a);break;case 4:s[n(1664)]=e.WKFEP(le,a);break;case 5:{let f=A(a);(s[n(1061)]||(s[n(1061)]=[]))[n(1264)](b(a)),a[n(1646)]=f;break}case 6:s[n(1608)+"ncoding"]=e[n(1595)](O,a,e.cYfDv(le,a));break;case 7:s[n(1764)+"ype"]=e[n(1324)](O,a,e[n(1688)](le,a));break;case 8:s[n(1032)]=e[n(1270)](ve,a,e[n(1560)](le,a));break;case 9:s.LogIDNew=e[n(1889)](O,a,e[n(631)](le,a));break;case 10:s[n(1318)+"ming"]=e[n(1502)](O,a,e[n(781)](le,a));break;case 11:s.msgID=e[n(1574)](O,a,le(a));break;case 12:s[n(1155)+"e"]=le(a);break;default:e.eKPCT(D,a,e.OhHLw(7,d))}}if(e[n(872)](void 0,s.SeqID))throw new Error(n(1789)+n(792)+n(1493)+n(1719));if(e[n(702)](void 0,s[n(1276)]))throw new Error(n(1789)+"required"+n(1493)+n(1276));if(s.service===void 0)throw new Error(e[n(1537)]);if(e[n(872)](void 0,s[n(1664)]))throw new Error(e[n(1105)]);return s}function A(a){let n=t,s=e.DShQc(le,a),d=a[n(1646)];return a[n(1646)]=e.XlHah(a[n(1763)],s),d}function D(a,n){let s=t;switch(n){case 0:for(;e.YvMcJ(128,e[s(697)](ie,a)););break;case 2:e[s(1596)](V,a,le(a));break;case 5:e[s(1596)](V,a,4);break;case 1:e[s(540)](V,a,8);break;default:throw new Error(e[s(1727)]+n)}}function L(a){let n=t;return a|=0,{low:a,high:e[n(1686)](a,31),unsigned:e[n(1856)](a,0)}}let _=[];function R(){let a=t,n={XbdXA:function(s,d){return s>d},nfGua:e[a(1877)]};if(e[a(1442)](e.vmHGq,e.HNTOI)){if(n[a(1209)](_0xbada8c[a(1763)]+_0xc7ae09,_0x32bc13[a(1646)]))throw new _0x512d94(n[a(608)]);_0x327e67.offset+=_0x4166c7}else{let s=_.pop();return s?(s[a(1763)]=s[a(1646)]=0,s):{bytes:new Uint8Array(64),offset:0,limit:0}}}function k(a){_[t(1264)](a)}function z(a){return{bytes:a,offset:0,limit:a[t(1900)]}}function F(a){let n=t,s={aJVWU:function(d,f){return e[q(1096)](d,f)},TdYDy:function(d,f){return d>f},kEseN:function(d,f){return d(f)},rKCEk:function(d,f){return d+f},ziqtO:function(d,f){return e[q(1604)](d,f)},BStJq:function(d,f){return e[q(1319)](d,f)},wmjYr:function(d,f){return e.ZnZvU(d,f)},lGvXc:function(d,f){return e[q(1750)](d,f)}};if(e[n(1528)](e[n(1367)],e[n(1367)])){let d=s.wmjYr(_0x8f0145,8192),f=s[n(623)](d,1),h=null,w=d;return function(v){let g=n;if(s[g(1103)](v,1)||s[g(907)](v,f))return s.kEseN(_0x3f6cf6,v);s[g(907)](s[g(1802)](w,v),d)&&(h=_0x3b396b(d),w=0);let T=_0x7ad574[g(677)](h,w,w+=v);return s[g(1737)](7,w)&&(w=s[g(1802)](s[g(581)](7,w),1)),T}}else{let d=a.bytes,f=a[n(1646)];return e[n(1004)](d[n(1900)],f)?d:d[n(817)](0,f)}}function V(a,n){let s=t;if(e.mOMAN===e.sEiaQ)return this._socket[s(1030)];if(e[s(585)](e[s(1109)](a[s(1763)],n),a[s(1646)]))throw new Error(s(1273)+s(895));a.offset+=n}function J(a){let n=t;if(e[n(786)](e[n(604)],n(1611)))return a[n(1763)]>=a[n(1646)];{let s=this[n(1577)+n(473)]?.[n(1358)+n(1068)+"nt"]();this[n(1257)]("open "+s),e.tRKUw(_0x10198c)}}function ee(a,n){let s=t,d=a[s(1791)],f=a[s(1763)],h=a[s(1646)],w=e[s(421)](f,n);if(w>d.length){let v=new Uint8Array(e[s(1135)](2,w));v[s(1592)](d),a[s(1791)]=v}return a[s(1763)]=w,e[s(1784)](w,h)&&(a[s(1646)]=w),f}function X(a,n){let s=t,d=a[s(1763)];if(e[s(844)](d+n,a.limit))throw new Error("Read pas"+s(895));return a.offset+=n,d}function ve(a,n){let s=t,d=e.iwCWp(X,a,n);return a[s(1791)][s(817)](d,d+n)}function Ne(a,n){let s=t,d=e[s(1425)](ee,a,n[s(1900)]);a[s(1791)][s(1592)](n,d)}function O(a,n){let s=t,d={FuscJ:function(f,h,w,v){return e.OcUeu(f,h,w,v)},XOedZ:"FRONTIER>"};if(e[s(628)](e[s(1494)],e.mUGRa))return new _0xefa83f(_0x5a124a,{data:_0x5b6a2a,message:_0x4d05c7});{let f=e[s(946)](X,a,n),h=String[s(1730)+s(451)],w=a[s(1791)],v="\uFFFD",g="";for(let T=0;e[s(1096)](T,n);T++){let P=w[e[s(1760)](T,f)],N,B,K,Y;if(e[s(1337)](e[s(996)](128,P),0))g+=e[s(1326)](h,P);else if(e[s(1187)](e[s(1858)](224,P),192))if(e[s(1856)](e[s(421)](T,1),n))g+=v;else{if(e[s(1921)](s(1290),e.etgLU))throw _0x47334b=_0x461f3d[s(1900)],d[s(865)](_0x3a5e79,_0x2d0bdb,10,_0x9d2382[s(1900)]);N=w[e[s(1819)](e.mRnzO(T,f),1)],e[s(1902)](192&N,128)?g+=v:(Y=e[s(1319)](e.cAXFq(e[s(521)](31,P),6),e[s(1190)](63,N)),e[s(1096)](Y,128)?g+=v:(g+=e[s(1560)](h,Y),T++))}else if(e.dzJvZ(e[s(1684)](240,P),224))e[s(830)](e[s(573)](T,2),n)?g+=v:(N=w[e[s(573)](T+f,1)],B=w[e[s(1320)](T,f)+2],e[s(1528)](e[s(447)](e[s(1661)](N,e.uhMYh(B,8)),49344),32896)?g+=v:(Y=e.rwOss(e.uhMYh(e.hUqyP(15,P),12),e[s(1134)](e.hUqyP(63,N),6))|e.ykOJM(63,B),e.FwJqy(Y,2048)||Y>=55296&&e.qOHmB(Y,57343)?g+=v:e.RUqVc(e[s(1795)],e[s(1139)])?(g+=e[s(853)](h,Y),T+=2):this[s(402)][s(566)]&&_0x42d9e8[s(1805)][s(1815)](_0x47423f,[d.XOedZ,..._0x51a676])));else if(e[s(1734)](248&P,240))if(e[s(1283)](e[s(1840)](T,3),n))g+=v;else if(N=w[e[s(1642)](e[s(527)](T,f),1)],B=w[e[s(1171)](T,f)+2],K=w[T+f+3],e[s(1528)](e[s(492)](e[s(1319)](e[s(1653)](N,e.uhMYh(B,8)),e.uhMYh(K,16)),12632256),8421504))g+=v;else if(e[s(1067)](e.RBUoO,e[s(1389)])){let pe=_0xb7d82[s(554)](":");_0x4a58f3&&(_0x53a946=pe.length),_0x533ed9+=pe.length;for(let qe=0;e.jtjiG(qe,pe[s(1900)]);qe++)if(e[s(1902)](4,pe[qe][s(1900)])){let Vi=_0x5c8f7f[s(1928)+"g"](0,e[s(1606)](4,pe[qe][s(1900)])),Yi=Vi.concat(pe[qe]);_0x7b356c[s(1264)](Yi)}else _0x4961af[s(1264)](pe[qe]);_0x1fcede=!1}else Y=e[s(675)](e[s(1142)](e[s(1661)](e[s(1134)](e[s(1698)](7,P),18),(63&N)<<12),e.uhMYh(e.kVzaa(63,B),6)),63&K),e[s(1869)](Y,65536)||Y>1114111?g+=v:(Y-=65536,g+=e.saEBJ(h,e[s(1320)](e[s(1686)](Y,10),55296),e[s(1365)](1023,Y)+56320),T+=3);else g+=v}return g}}function G(a,n){let s=t,d={eUfZg:function(f,h){return e[q(615)](f,h)},mmggA:function(f,h){return e[q(631)](f,h)}};if(e[s(1337)](e[s(833)],e[s(766)]))try{_0x10a3bf(this,_0x2768e3,[_0x191a07,_0x44324d,_0x1e2460])}catch(f){let h=e[s(1146)](_0x797135,e[s(1246)],{message:f[s(514)],code:_0x16109f.OPEN_ERROR,error:f});this["_dispatc"+s(1888)+s(1508)](h)}else{let f=n[s(1900)],h=0;for(let g=0;e[s(1732)](g,f);g++){let T=n[s(1104)+"At"](g);T>=55296&&e[s(1500)](T,56319)&&e.pGsra(g+1,f)&&(T=e[s(463)](e[s(1171)](e.uhMYh(T,10),n.charCodeAt(++g)),56613888)),h+=e.pGsra(T,128)?1:e[s(532)](T,2048)?2:e.vhcun(T,65536)?3:4}e[s(790)](ue,a,h);let w=ee(a,h),v=a.bytes;for(let g=0;e[s(1744)](g,f);g++){let T=n[s(1104)+"At"](g);if(T>=55296&&e[s(1500)](T,56319)&&e[s(1744)](g+1,f)&&(T=e.bXwIk(e[s(1024)](e[s(394)](T,10),n[s(1104)+"At"](++g)),56613888)),e.pTTXf(T,128))v[w++]=T;else{if(e.JGezb(T,2048))v[w++]=T>>6&31|192;else{if(e.ubFde(s(1801),e.ZvFRg))return _0x3ce70f[s(1815)](oknhYd.eUfZg(_0x83daf1,this),_0x569a1a),oknhYd[s(770)](_0x4a8004,_0x387f28[s(1050)](this));e[s(440)](T,65536)?v[w++]=e[s(1015)](e[s(447)](e[s(1766)](T,12),15),224):(v[w++]=e[s(1130)](e[s(1034)](T,18)&7,240),v[w++]=e.ZfbIh(T,12)&63|128),v[w++]=e.KxcWu(e.fDQbJ(T,6)&63,128)}v[w++]=e[s(720)](63&T,128)}}}}function W(a,n){let s=t,d=e[s(896)](ee,a,n[s(1646)]),f=a[s(1791)],h=n[s(1791)];for(let w=0,v=n.limit;e[s(1476)](w,v);w++)f[w+d]=h[w]}function ie(a){let n=t;return a[n(1791)][e[n(1574)](X,a,1)]}function Je(a,n){let s=t,d=e[s(946)](ee,a,1);a.bytes[d]=n}function le(a){let n=t,s=0,d=0,f;do f=e[n(1828)](ie,a),e.ljKYQ(s,32)&&(d|=e[n(740)](127,f)<<s),s+=7;while(e.kVzaa(128,f));return d}function ue(a,n){let s=t;for(n>>>=0;e.MtKIo(n,128);)e[s(1401)](Je,a,e.IHhqM(e.hCgyb(127,n),128)),n>>>=7;e[s(1010)](Je,a,n)}function bt(a,n){let s=t,d={FebHi:e[s(928)],SizCr:function(f,h){return f<h},ajFTq:function(f,h){return f<h},mxoiq:function(f,h){return e[s(1311)](f,h)},nskle:function(f,h){return e[s(1792)](f,h)},dEaDH:function(f,h,w,v){return f(h,w,v)},xydrc:function(f,h){return e[s(1653)](f,h)},gsaBT:function(f,h){return e.ujnQM(f,h)},dGxfE:function(f,h){return e[s(1292)](f,h)},wKOgZ:function(f,h){return e.tvngX(f,h)},HFzgm:function(f,h){return f<<h},QyusQ:function(f,h){return e.fKzIk(f,h)},mfGmy:function(f,h){return e[s(675)](f,h)},jtuHM:function(f,h){return f|h},EwnKz:function(f,h){return e[s(1476)](f,h)},mhHnL:function(f,h){return e[s(1142)](f,h)},slQaw:e[s(635)],ICSAP:function(f,h,w){return e[s(1839)](f,h,w)}};if(e.iFASZ!=="DopcN"){let f=0,h=0,w=0,v;if(v=e[s(1547)](ie,a),f=e[s(1190)](127,v),e[s(996)](128,v)&&(v=e[s(735)](ie,a),f|=(127&v)<<7,128&v))if(e.Uzqyi(e[s(933)],e[s(1338)])){let g=4294967295;return function(T,P,N=!0){let B=s,K=d[B(1285)].split("|"),Y=0;for(;;){switch(K[Y++]){case"0":if(d[B(1598)](T[P++],128))return{value:N?g:0|g,offset:P};continue;case"1":if(d[B(1013)](T[P++],128))return{value:N?g:d[B(525)](0,g),offset:P};continue;case"2":return{value:N?g:d[B(525)](0,g),offset:P};case"3":if(d[B(1487)](P+=5,T[B(1900)]))throw P=T[B(1900)],d[B(825)](_0xf1a61f,P,10,T[B(1900)]);continue;case"4":g=d[B(1705)](g,d[B(1305)](127,T[P])<<14)>>>0;continue;case"5":g=d.dGxfE(d[B(1483)](g,d[B(1779)](15&T[P],28)),0);continue;case"6":g=d[B(1090)](d.gsaBT(127,T[P]),0);continue;case"7":if(T[P++]<128)return{value:N?g:d[B(1439)](0,g),offset:P};continue;case"8":g=d.dGxfE(d.mfGmy(g,(127&T[P])<<21),0);continue;case"9":if(d[B(1598)](T[P++],128))return{value:N?g:0|g,offset:P};continue;case"10":g=d[B(1376)](g,d.HFzgm(127&T[P],7))>>>0;continue;case"11":if(d.EwnKz(T[P++],128))return{value:N?g:d[B(1619)](0,g),offset:P};continue}break}}}else v=e[s(1665)](ie,a),f|=e[s(1474)](e[s(555)](127,v),14),e[s(1698)](128,v)&&(v=e[s(1778)](ie,a),f|=e.fGwCq(e[s(883)](127,v),21),e[s(521)](128,v)&&(v=e[s(1828)](ie,a),h=e[s(1190)](127,v),128&v&&(e[s(628)](s(1638),e[s(1616)])?(v=ie(a),h|=e[s(492)](127,v)<<7,e[s(632)](128,v)&&(v=e[s(1560)](ie,a),h|=e[s(394)](e[s(632)](127,v),14),e[s(983)](128,v)&&(v=e[s(988)](ie,a),h|=e[s(1134)](127&v,21),e[s(555)](128,v)&&(v=e[s(1373)](ie,a),w=e.YvMcJ(127,v),e.pXYDQ(128,v)&&(v=e[s(1547)](ie,a),w|=e[s(1056)](127,v)<<7))))):this[s(655)](d.slQaw,d[s(1785)](_0x2515dd,d[s(1593)],{..._0x290781})))));return{low:e[s(948)](f,e[s(922)](h,28)),high:e.ujncs(h>>>4,e[s(1550)](w,24)),unsigned:n}}else{let f=!!this[s(402)][s(813)+"S"];if(!f)return{enabled:f,isQoSMessage:!1,isQoSAck:!1,isAckCleanupMessage:!1,ackMsgIds:[]};let h=e[s(599)](_0x3b2baa,_0x3d636d.message[s(1061)],"x_fronti"+s(1553),"2"),w=h&&e[s(1407)](_0x369af9,_0x2f4e22.message[s(1061)],e[s(1660)],"1"),v=h&&e[s(464)](_0x4413af,_0x11abf3[s(514)][s(1061)],e[s(994)],"1"),g=v?e[s(1465)](_0x50d049,_0x135c9b[s(514)][s(1061)],s(861)+s(848)+"sgid")?.[s(554)](",")[s(1690)](_0x361e09)||[]:[];return{enabled:f,isQoSMessage:h,isQoSAck:w,isAckCleanupMessage:v,ackMsgIds:g}}}function ut(a,n){let s=t,d=e[s(1750)](n[s(1851)],0),f=e[s(1292)](e[s(1307)](e[s(1292)](n.low,28),e[s(394)](n[s(1755)],4)),0),h=e[s(884)](n[s(1755)],24),w=e[s(454)](0,h)?f===0?e.jtjiG(d,16384)?d<128?1:2:e[s(1210)](d,2097152)?3:4:e[s(1466)](f,16384)?f<128?5:6:f<2097152?7:8:e[s(1657)](h,128)?9:10,v=ee(a,w),g=a[s(1791)];switch(w){case 10:g[e[s(576)](v,9)]=e[s(555)](h>>>7,1);case 9:g[e[s(1702)](v,8)]=e.UoLDg(9,w)?128|h:e[s(985)](127,h);case 8:g[e[s(573)](v,7)]=e[s(657)](8,w)?e.ujncs(e.fdbFi(f,21),128):e[s(1708)](f>>>21,127);case 7:g[e[s(1826)](v,6)]=w!==7?e.tvngX(e[s(465)](f,14),128):e[s(1456)](e[s(884)](f,14),127);case 6:g[e[s(1840)](v,5)]=e[s(1080)](6,w)?e.xVLjq(e[s(641)](f,7),128):e[s(492)](f>>>7,127);case 5:g[e[s(436)](v,4)]=e[s(1097)](5,w)?e[s(1250)](128,f):e[s(866)](127,f);case 4:g[v+3]=e.UtVIl(4,w)?e[s(1015)](e.HHDai(d,21),128):e[s(884)](d,21)&127;case 3:g[e[s(1062)](v,2)]=e[s(1715)](3,w)?e.rwOss(e[s(957)](d,14),128):e.xRnyW(e.msqae(d,14),127);case 2:g[v+1]=e[s(1921)](2,w)?e[s(1435)](e[s(1191)](d,7),128):e[s(1300)](d>>>7,127);case 1:g[v]=e[s(606)](1,w)?e[s(1144)](128,d):e[s(1698)](127,d)}}function Vt(a){return E(a)}function Nt(a){return I(a)}let Yt=65536,Fr=e.hMzeZ,he=e[t(1583)](Yt,Yt),Se=e.jsuSP(he,he),Kn=e[t(1252)](Se,2),Re=String[t(750)+"e"][t(1104)+"At"];class ce{constructor(n,s,d){let f=t;this[f(448)]=!0,this[f(1851)]=e[f(1587)](0,n),this[f(1755)]=e[f(1866)](0,s),this[f(942)]=!!d}static isLong(n){let s=t;if(e[s(1902)](e[s(1485)],e.bzFvh))this[s(1275)]&&this._ws[s(955)](_0x1afc93,_0x3ed3d4);else return n&&e[s(1004)](!0,n.isLong)}static[t(1876)](n,s,d){let f=t;if(e[f(1051)]!==e[f(1409)])return new ce(n,s,d);if(!this[f(1275)])return;this[f(934)+"WebSocket"](_0x383a88,_0x463aed,_0x234f7d)}static[t(1265)+"s"](n,s,d){let f=t,h={PvzGL:function(w,v){return e[q(1903)](w,v)},VriUH:e.lVkHi};if(e.rDnlS(e[f(947)],f(523))){let w=_0x1c5dff(_0x34079d);this[f(1275)]&&h[f(479)](this[f(1275)][f(1260)+"te"],this[f(856)])&&(this[f(1275)]&&this[f(1275)][f(705)](w),this[f(1257)](h[f(653)],_0x5145ad))}else return d?ce[f(1265)+f(963)](n,s):ce["fromByte"+f(450)](n,s)}static[t(1265)+t(963)](n,s){let d=t;return new ce(e[d(731)](e[d(1510)](n[0],e[d(1277)](n[1],8)),e.vyYmn(n[2],16))|n[3]<<24,e[d(689)](e[d(1115)](n[4],e[d(541)](n[5],8))|e[d(1674)](n[6],16),n[7]<<24),s)}static[t(1265)+t(450)](n,s){let d=t;return new ce(e[d(1383)](e[d(1130)](e[d(1510)](e[d(541)](n[4],24),n[5]<<16),e.ZdYlH(n[6],8)),n[7]),e[d(1015)](e[d(1319)](e[d(1117)](n[0],24)|e[d(435)](n[1],16),n[2]<<8),n[3]),s)}static[t(708)](n){let s=t;return n===Fr?Od:new ce(e[s(1292)](e[s(1587)](e[s(1250)](e[s(1821)](Re[s(677)](n,0),e[s(1682)](Re[s(677)](n,1),8)),e[s(935)](Re[s(677)](n,2),16)),e.qNcqU(Re[s(677)](n,3),24)),0),e[s(1448)](e[s(1587)](e[s(926)](e[s(1142)](Re.call(n,4),Re[s(677)](n,5)<<8),e[s(1474)](Re.call(n,6),16)),e.WWoyd(Re[s(677)](n,7),24)),0),!0)}toHash(){let n=t;return e[n(888)](e[n(732)],e[n(909)])?String[n(1730)+n(451)](e[n(1365)](255,this.low),e[n(1708)](e[n(1750)](this.low,8),255),this[n(1851)]>>>16&255,this[n(1851)]>>>24,e[n(1588)](255,this[n(1755)]),e[n(740)](this[n(1755)]>>>8,255),e[n(1365)](this[n(1755)]>>>16,255),e[n(465)](this[n(1755)],24)):(_0x55c3fd||(_0x1362eb=_0x1c0de2[n(1094)]()[n(1101)](_0xbd213d[n(1222)](_0x53726d,n(1386)))),_0x42093)}static[t(1841)+"er"](n,s=!0){let d=t;if(e[d(1067)](d(1835),e[d(1842)])){if(e[d(1180)](isNaN,n))return s?Oh:Od;if(s){if(e.xzszr(n,Se))return Mh}else{if(e[d(459)](n,-Kn))return Bh;if(e[d(1590)](e[d(1840)](n,1),Kn))return Nh}return ce.fromBits(e[d(1661)](n%he,0),e[d(1082)](e[d(1269)](n,he),0),s)}else e.kFVXG(_0x1d634c,_0x554fde,58),e[d(1725)](_0x1d6d23,_0x59d499,_0x1f7811)}toNumber(){let n=t;return this[n(942)]?e[n(1154)](e.JiBbF(e[n(957)](this.high,0),he),e.mMfJe(this[n(1851)],0)):e[n(1387)](e.JiBbF(this[n(1755)],he),e[n(1216)](this.low,0))}[t(1410)](){let n=t;if(e[n(762)](e[n(466)],e[n(497)]))return e.rIOjT(0,this[n(1755)])&&e[n(1004)](0,this[n(1851)]);{let s=_0x3c6005[_0x27b5aa++];if(e.ofYHC(s,127))_0x4eb924+=_0x403c0a[n(1730)+"Code"](s);else if(e[n(1590)](s,192)&&e[n(1096)](s,224))_0x485f8e+=_0x445055[n(1730)+n(451)](e[n(1866)](e.UInbZ(e.pXdUq(31,s),6),63&_0x2bc167[_0x59df82++]));else if(e[n(1396)](s,224)&&s<240)_0x1c4c58+=_0x471786[n(1730)+n(451)](e[n(720)](e[n(541)](e[n(1365)](15,s),12),e[n(1475)](e[n(1128)](63,_0x334855[_0x5ef5b6++]),6))|e[n(574)](63,_0x133011[_0x62413a++]));else if(e[n(522)](s,240)){let d=e[n(495)](e[n(1258)](e[n(1099)](e[n(654)](e[n(610)](7,s),18),e[n(935)](e[n(1883)](63,_0x3bd008[_0x3d5e2b++]),12))|e[n(1514)](e[n(1594)](63,_0x38520e[_0x1edbac++]),6),e[n(985)](63,_0x1baf48[_0x580980++])),65536);_0x2c4c29+=_0x315c99[n(1730)+n(451)](55296+e[n(757)](d,10)),_0x4e5556+=_0x5cc50e.fromCharCode(56320+e[n(1472)](1023,d))}}}add(n){let s=t;ce.isLong(n)||(n=ce[s(1841)+"er"](n));let d=e[s(1761)](this[s(1755)],16),f=e[s(1641)](65535,this.high),h=this[s(1851)]>>>16,w=e[s(510)](65535,this[s(1851)]),v=n.high>>>16,g=e[s(983)](65535,n[s(1755)]),T=e[s(663)](n.low,16),P=e.adNVj(65535,n[s(1851)]),N=0,B=0,K=0,Y=0;return Y+=e[s(1760)](w,P),K+=e[s(957)](Y,16),Y&=65535,K+=e[s(908)](h,T),B+=e.ASIrz(K,16),K&=65535,B+=e.aUCCV(f,g),N+=e[s(957)](B,16),B&=65535,N+=e[s(1757)](d,v),N&=65535,ce[s(1876)](e.ZdYlH(K,16)|Y,e[s(720)](e[s(694)](N,16),B),this[s(942)])}equals(n){let s=t,d={mlTUP:function(f,h){return e[q(1453)](f,h)},kCrCw:function(f,h){return e.cAXFq(f,h)}};if(e[s(1097)](e[s(717)],e[s(535)]))return ce.isLong(n)||(n=ce[s(1841)+"er"](n)),this.unsigned!==n[s(942)]&&e[s(498)](e[s(1750)](this[s(1755)],31),1)&&e[s(1036)](e[s(1453)](n.high,31),1)?!1:e[s(1174)](this[s(1755)],n[s(1755)])&&e[s(709)](this[s(1851)],n[s(1851)]);{let f=0,h=_0x11cc9f,w=_0x38629d+4;for(;h<w;){let{value:v,offset:g}=_0x3933f3(_0x1fd777,h);h=g,f=d[s(437)](d[s(1452)](f,8),0),f+=v}return{value:f,offset:w}}}addOne(){let n=t;return e[n(972)](-1,this.low)&&this[n(1755)]===-1?ce[n(1876)](0,0,this[n(942)]):e.jhysY(-1,this.low)?ce.fromBits(0,e[n(1843)](this[n(1755)],1),this[n(942)]):ce.fromBits(e.HjAqS(this[n(1851)],1),this[n(1755)],this[n(942)])}[t(1832)](n){let s=t;return n?this[s(1777)+"E"]():this[s(637)+"E"]()}[t(1777)+"E"](){let n=t,s=this[n(1755)],d=this.low;return[e[n(876)](255,d),e.tNeJK(d>>>8,255),e[n(777)](d,16)&255,e.MwHUI(d,24),e.JdrGp(255,s),e[n(1205)](s>>>8,255),e.OXdue(e[n(1579)](s,16),255),e[n(432)](s,24)]}[t(637)+"E"](){let n=t,s=this[n(1755)],d=this[n(1851)];return[e[n(1145)](s,24),e[n(727)](e[n(1453)](s,16),255),e[n(1069)](e[n(1448)](s,8),255),e[n(577)](255,s),e[n(1419)](d,24),e[n(883)](e[n(807)](d,16),255),e[n(1292)](d,8)&255,e[n(701)](255,d)]}}let Od=new ce(0,0,!1),Oh=new ce(0,0,!0),Nh=ce[t(1876)](-1,2147483647,!1),Mh=ce[t(1876)](-1,-1,!0),Bh=ce.fromBits(0,-2147483648,!1);var Zt=(function(a){let n=t;return a[a["NATIVE_E"+n(398)]=5001]=e.YhPVF,a[a[e[n(1003)]]=5002]=e[n(1003)],a[a[e[n(718)]]=5003]=e[n(718)],a[a[e.jWqcW]=5004]=e[n(778)],a[a.OPEN_ERROR=5005]=n(728)+"OR",a})({});class $n{constructor(n){let s=t;this[s(424)]=n,this.target=null}}class Nd extends $n{constructor(n,s){let d=t;super(n),this[d(514)]=s&&s.message||null}}class Md extends $n{constructor(n,s){let d=t,f=(d(1793)+"3|1|0")[d(554)]("|"),h=0;for(;;){switch(f[h++]){case"0":this[d(724)]=s&&s[d(724)]||5001;continue;case"1":this[d(514)]=s&&s[d(514)]||"";continue;case"2":this[d(1470)]=s&&s[d(1470)]||0;continue;case"3":this[d(558)]=s&&s[d(558)]||0;continue;case"4":this[d(425)]=s&&s[d(425)]||null;continue;case"5":super(n);continue;case"6":this[d(588)]=s&&s[d(588)]||"";continue}break}}}class Bd extends $n{constructor(n,s){let d=t;if(e[d(762)]("DLPIJ",e.syVZr)){let f=e[d(1621)][d(554)]("|"),h=0;for(;;){switch(f[h++]){case"0":this[d(499)]=s&&s.reason||"";continue;case"1":this[d(724)]=s&&s[d(724)]||0;continue;case"2":super(n);continue;case"3":this[d(1370)+"nnect"]=s&&s[d(1370)+d(1402)]||!1;continue;case"4":this.wasClean=s&&s[d(837)]||!1;continue}break}}else return this["currentEndpointT"+d(987)+"t"]}}class zd extends $n{constructor(n,s){let d=t;if(e.qKbIb(e[d(1287)],e[d(1287)]))super(n),this[d(805)]=s&&s[d(805)]||null;else try{this._qosDB?.[d(955)](),this[d(1181)]=void 0}catch(f){_0x56927f[d(1805)](f)}}}class Fd extends zd{constructor(n,s){let d=t;e[d(1335)](e[d(1786)],e[d(1398)])?(_0x2c378d(_0x306ec8,e[d(1594)](127,_0x1bc090)|128),_0x974fee>>>=7):(super(n),this.data=s&&s[d(805)]||null,this.message=s&&s.message||null)}}class Ud extends $n{constructor(n,s){let d=t;super(n),this[d(805)]=s&&s.data||null}}function st(a,{message:n,code:s,error:d}){return new Md(a,{message:n,code:s,error:d})}function ft(a,{code:n,reason:s,wasClean:d,willReconnect:f}){return new Bd(a,{code:n,reason:s,wasClean:d,willReconnect:f})}function Hd(a,{data:n,message:s}){let d=t;if(e[d(1715)](e[d(852)],d(1031)))return new Fd(a,{data:n,message:s});{let f=_0x597129.call(heLMSf[d(1282)](_0x2020d4,this),_0x4651cf,..._0x47ee03);return _0x540ad9[d(1592)](f,_0x4fd72e.sort?_0xea6357[d(751)]():[_0xbf67a0]),heLMSf.kCkcX(_0x51011d,f)}}function qd(a,{data:n}){return new Ud(a,{data:n})}function na(a,{message:n}){return new Nd(a,{message:n})}class Gd{constructor(n,s){let d=t;this[d(478)+"s"]=n,this[d(1855)+"es"]=s,this[d(736)+d(1692)]=0,this["currentE"+d(1132)+"riesCount"]=0}[t(1395)+t(1669)+t(1634)](){let n=t;this[n(736)+"ndex"]=0,this["currentE"+n(1132)+n(987)+"t"]=0}[t(1681)+"es"](){let n=t;this[n(1027)+"ndpointTriesCount"]=0}["getCurre"+t(1068)+"nt"](){let n=t;return this[n(478)+"s"][this[n(736)+n(1692)]]}["getCurre"+t(1068)+t(1846)+"ount"](){let n=t;return this[n(1027)+n(1132)+n(987)+"t"]}[t(670)+t(1659)+"es"](){let n=t;return!!(e[n(1856)](this[n(736)+n(1692)],this[n(478)+"s"][n(1900)])||e[n(1187)](this[n(736)+"ndex"],e[n(495)](this.endpoints[n(1900)],1))&&this["currentE"+n(1132)+"riesCount"]===this[n(1855)+"es"])}[t(1393)+"rentEndp"+t(1523)+t(1121)+"tries"](){let n=t;return this.currentIndex==this.endpoints[n(1900)]?!0:this[n(1027)+"ndpointT"+n(987)+"t"]>this[n(1855)+"es"]}["replaceB"+t(1085)+t(1567)+"UpdateCount"](){let n=t;return this[n(1027)+"ndpointT"+n(987)+"t"]=1,this["currentI"+n(1692)]++,this[n(478)+"s"][this["currentI"+n(1692)]]}[t(1358)+t(1068)+t(1459)+t(1627)](){let n=t,s={XOlSk:function(d,f){return e[q(647)](d,f)},KdIOd:n(408)+n(499),qucVx:e[n(477)],nhdso:"text/jav"+n(1414),pKZYQ:e[n(710)],kkQJP:n(838)+"ack=fron"+n(1735)+"P"};if(e[n(986)](n(609),"TLjsj")){let d=_0x2d28cd[n(427)+"ement"](s[n(1438)]);_0xb1b610[n(1689)+n(1758)]=f=>{let h=n;_0x5560e6[h(700)].removeChild(d),_0x1d77f6[h(1689)+h(1758)]=void 0,s[h(774)](_0x37694d,f&&f[h(1426)]||s.KdIOd)},d[n(424)]=s[n(1354)],d[n(1380)]=_0x20be1a[n(666)](/^ws/,s[n(1637)])+s[n(1917)];try{_0x4a173b[n(700)][n(721)+n(1904)](d)}catch{_0x128db3[n(700)][n(878)+"ild"](d)}}else return this[n(1027)+"ndpointT"+n(987)+"t"]++,this[n(1358)+n(1068)+"nt"]()}}let Jn=(e[t(1249)](e[t(638)],typeof globalThis)&&e[t(899)](e[t(505)],globalThis[t(954)+t(1238)].name)||e[t(1910)](t(1184)+"d",typeof window)&&e[t(1442)](t(1348),window["construc"+t(1238)][t(863)]))&&e.SJNmo(e[t(638)],typeof document),vn=e[t(638)]!=typeof globalThis&&(e[t(502)]===globalThis["construc"+t(1238)].name||e[t(1280)](t(429)+t(1916)+t(1125)+"pe",globalThis[t(954)+"tor"][t(863)]))&&e.SJNmo(e[t(638)],typeof tt),Ur=(t(1184)+"d"!=typeof globalThis&&e[t(502)]===globalThis[t(954)+t(1238)].name||e[t(638)]==typeof globalThis||e[t(1512)](e.kQauc,typeof globalThis)&&!!globalThis[t(1710)+"Bridge"])&&e[t(638)]!=typeof wx,Hr=e[t(1613)](e[t(638)],typeof globalThis)&&(t(429)+t(1916)+t(1125)+"pe"===globalThis[t(954)+"tor"].name||e.UmlJK(e[t(1054)],globalThis[t(954)+"tor"][t(863)])||t(1049)+t(962)+t(1406)===globalThis["construc"+t(1238)][t(863)])&&e.AqxML(t(1184)+"d",typeof self),zh=e[t(1150)](e[t(638)],typeof globalThis)&&e[t(1093)](e[t(502)],globalThis[t(954)+t(1238)][t(863)])&&e[t(638)]!=typeof global&&e[t(502)]===global[t(954)+t(1238)][t(863)]&&e[t(1388)](e[t(638)],typeof process)&&!!process[t(1713)];class ra{constructor(){let n=t;this[n(723)+"rs"]={}}[t(655)](n,...s){let d=t;if(e[d(1782)](d(557),e[d(1818)])){let f=this._listeners[n];if(f)f[d(797)]()[d(1182)](h=>h.fn[d(1815)](h[d(509)],s));else if(e[d(498)](e[d(1246)],n)&&!this.onerror){let h=s.length&&s[0];if(h instanceof Error)throw h;let w=new Error(e[d(1906)]+(h?e.OBgxl(" ("+h[d(514)],")"):""));throw w[d(1824)]=h,h}return this}else{let f=d(1279)+_0x129f8f+(d(1173)+d(1765)+d(801)+"ed");this["_dispatc"+d(1888)+d(1508)](_0x16daa6(d(425),{message:f,code:_0x4e9b54[d(419)+d(1422)+"R"],error:_0x5be4ea}));return}}[t(616)](n,s){let d=t;if(e.ubFde(void 0,n))this[d(723)+"rs"]={};else if(s===void 0)this[d(723)+"rs"][n]=null;else{let f=this[d(723)+"rs"][n];if(f)for(let h=0;h<f[d(1900)];)f[h].fn===s?f[d(1762)](h,1):++h}return this}on(n,s,d){let f=t;return(this[f(723)+"rs"][n]||(this[f(723)+"rs"][n]=[]))[f(1264)]({fn:s,ctx:d||this}),this}}class Fh extends ra{["_formatErrorMess"+t(589)](n){let s=t;return n[s(1194)]||n.errNo?(s(1911)+" "+(n[s(1194)]||"")+s(411)+(n[s(1347)]||""))[s(671)]():JSON[s(664)+"y"](n)}constructor(n,s,d){let f=t;super(),this[f(1901)]=null,Ur&&wx[f(1112)+f(1291)]&&(this[f(1901)]=wx[f(1112)+"ocket"]({url:n,protocols:s,header:d,fail:this[f(1060)+f(722)+f(765)][f(1222)](this),success:this._createSocketSuccessHandler[f(1222)](this)})),vn&&tt["connectS"+f(1291)]&&(this[f(1901)]=tt[f(1112)+f(1291)]({url:n,protocols:s,header:d,fail:this[f(1060)+"ocketFai"+f(765)][f(1222)](this),success:this[f(1060)+f(401)+f(1334)+f(1023)].bind(this)}))}["_createS"+t(401)+"cessHandler"](){let n=t,s={sTala:function(d,f,h){return d(f,h)},NNsHT:n(955)};if(e.rsYGn(e.NYQHl,n(506))){let d=this._endpointManager?.[n(1358)+n(1068)+"nt"](),f=this[n(402)][n(1861)+n(621)+"ptor"](_0x244bdd[n(724)],_0x227265.reason);this[n(416)+n(1626)+n(1508)](s.sTala(_0x3cdc72,s[n(944)],{code:1006,reason:_0xe0e1f6[n(499)]||"connecti"+n(1379)+n(1092)+n(1119)+n(1687)+n(782)+d,willReconnect:f})),f&&this[n(747)]();return}else Promise[n(1094)]()[n(1101)](()=>{let d=n;this[d(1321)+d(462)]()})}[t(1060)+t(722)+"lHandler"](n){let s=t;Promise[s(1094)]()[s(1101)](()=>{let d=s,f=e.dqvnc(st,"error",{message:this[d(1107)+d(575)+d(589)](n)});this.emit(e[d(1246)],f);let h=e[d(474)](ft,e[d(635)],{reason:this[d(1107)+d(575)+d(589)](n)});this[d(655)](e[d(635)],h)})}_addWsListeners(){let n=t,s={vThMR:e[n(1218)],Wwrbn:function(d,f,h){return e[n(1156)](d,f,h)},EMYVT:e[n(635)],aoVlP:function(d,f){return e[n(1528)](d,f)},vBTlM:e[n(537)],GMvgJ:e[n(597)]};this[n(1901)][n(795)](d=>{let f=n;this[f(655)](s[f(669)],s[f(1768)](qd,f(591),{...d,data:d[f(1194)]||""}))}),this[n(1901)][n(1929)](d=>{let f=n;this[f(655)](s.EMYVT,s[f(1768)](ft,f(955),{...d}))}),this[n(1901)].onMessage(d=>{let f=n;if(s[f(821)](s[f(512)],f(1372)))this[f(655)](s[f(1887)],s.Wwrbn(Hd,f(514),{...d}));else{let h=_0x32bbce[f(514)][f(1032)];h&&_0x120a32[f(1464)+"rs"](h)}}),this[n(1901)][n(438)](d=>{let f=n;this[f(655)](e.hyWgd,e[f(1324)](st,e.hyWgd,{...d,message:d[f(1194)]||""}))})}[t(705)](n){let s=t,d={KehpT:s(425),hsUFJ:function(f,h,w){return e[s(1111)](f,h,w)}};if(e[s(1559)](n,Uint8Array)){let f=n[s(1175)].slice(n.byteOffset,e[s(1154)](n.byteLength,n.byteOffset));this[s(1901)]&&this._socket[s(705)]({data:f,fail:h=>{let w=s;this[w(655)](w(425),st(w(425),{message:this[w(1107)+w(575)+w(589)](h)}))}})}else this[s(1901)]&&this[s(1901)][s(705)]({data:n,fail:f=>{let h=s;this[h(655)](d[h(1394)],d[h(560)](st,h(425),{message:this["_formatE"+h(575)+h(589)](f)}))}})}[t(955)](n,s){let d=t;this[d(1901)]&&this[d(1901)][d(955)]({code:n,reason:s})}[t(1350)+t(953)](n,s){this.on(n,s)}[t(501)+t(607)+"ner"](n,s){this.off(n,s)}get readyState(){let n=t;if(e[n(786)](e[n(397)],n(1390))){let s=this[n(1577)+"tManager"]?.[n(670)+n(1659)+"es"](),d=this[n(1577)+n(473)]?.[n(1358)+n(1068)+"nt"]();if(s&&!_0x35fd03[n(514)]){let f="connect "+d+(n(1173)+n(1765)+n(801)+"ed");this[n(416)+n(1888)+"ent"](_0x5442b2(e.hyWgd,{message:f,code:_0x783d7c[n(419)+n(1422)+"R"],error:_0x435d23}));return}this[n(1275)]&&e[n(796)](this._ws.readyState,this[n(856)])&&this[n(1703)+"ect"](),this[n(416)+n(1888)+"ent"](e.chaBr(_0x38019e,e.hyWgd,{message:_0x279786.message,code:_0x3222bc[n(768)+"RROR"],error:_0x469988}))}else return this[n(1901)][n(1260)+"te"]}get[t(900)+"pe"](){let n=t;return this[n(1901)][n(900)+"pe"]}set[t(900)+"pe"](n){}get url(){let n=t;return this[n(1901)][n(1086)]}get[t(1030)](){return this[t(1901)].protocol}get extensions(){let n=t;return this[n(1901)][n(1486)+"ns"]}get[t(1153)+"Amount"](){return 0}}function Uh(a,n){let s=t;if(n)return new n(a[s(1086)],a[s(1030)]);if(e[s(1597)](Ur,vn))return new Fh(a[s(1086)],a[s(1030)],a[s(1061)]);if((Jn||Hr)&&e.HRHJF(e[s(638)],typeof WebSocket)&&WebSocket)return new WebSocket(a.url,a[s(1030)+"s"])}function Hh(a){let n=t;return!!(a||Ur&&wx["connectS"+n(1291)]||vn&&tt[n(1112)+n(1291)]||e[n(1359)](Jn,Hr)&&e[n(1613)](e.kQauc,typeof WebSocket)&&WebSocket)}function jd(a,n,s){let d=t,f=-1;async function h(w){let v=q;return w<=f?Promise.reject(new Error(e.IDEnt)):(f=w,e.psyoi(w,s[v(1900)])?Promise.resolve():s[w][v(1222)](a)(n,h[v(1222)](null,e[v(908)](w,1))))}e[d(853)](h,0)}function Wd(a){let n=t;if(e.NYVMV(e[n(1168)],e[n(1168)]))return this[n(1181)]?.[n(1050)](_0x478cb1);{let s=0,d=0;for(let f=0;e[n(1076)](f,a[n(1900)]);++f){if(e[n(899)](e[n(1575)],n(949)))return!!this[n(1181)];if(d=a[n(1104)+"At"](f),d<128)s+=1;else if(e[n(1848)](d,2048))s+=2;else if(e[n(1337)](64512&d,55296)&&e[n(804)](e[n(1806)](64512,a[n(1104)+"At"](e[n(573)](f,1))),56320)){if(e[n(986)]("YPeGG",e.mUdzE))return _0x4c17da||(_0x4d2975=[_0x1e4045[n(750)+"e"][n(1615)],_0x4d016c[n(750)+"e"][n(643)],_0x52ef0e[n(750)+"e"]["continue"+n(1033)+"ey"]]);++f,s+=4}else s+=3}return s}}function Kd(a,n,s){let d=t;if(e[d(1076)](e[d(1555)](s,n),1))return"";let f="";for(let h=n;e[d(1476)](h,s);){let w=a[h++];if(w<=127)f+=String[d(1730)+d(451)](w);else if(e[d(1212)](w,192)&&e[d(1857)](w,224))f+=String[d(1730)+d(451)](e[d(1267)](e[d(1674)](e.HpAMQ(31,w),6),e[d(1648)](63,a[h++])));else if(w>=224&&e[d(1384)](w,240))f+=String.fromCharCode(e[d(720)](e[d(528)](e[d(1698)](15,w)<<12,e.BARNq(63,a[h++])<<6),e.hUqyP(63,a[h++])));else if(e[d(539)](w,240)){let v=e[d(1881)](e[d(1254)](e.GQWqY(e[d(1706)](e[d(1708)](7,w),18)|e.MgfsR(63,a[h++])<<12,e.eutwn(63,a[h++])<<6),e[d(996)](63,a[h++])),65536);f+=String["fromChar"+d(451)](e[d(1702)](55296,e.JmyCW(v,10))),f+=String[d(1730)+d(451)](e[d(1066)](56320,1023&v))}}return f}function ia(a,n,s){let d=t,f={azbiG:e[d(1025)],RErgN:e[d(1266)]},h=s,w,v;for(let g=0;e[d(1897)](g,a[d(1900)]);++g)if(w=a.charCodeAt(g),w<128)n[s++]=w;else if(e.odbqQ(w,2048))if(e[d(1001)]===e[d(583)])switch(_0x189ad5){case f[d(975)]:case f[d(593)]:return{[d(570)+_0x413c06]:1,"x-tt-env":_0x2b26ac};default:return{}}else n[s++]=e[d(494)](w,6)|192,n[s++]=e.DkdvK(e[d(1893)](63,w),128);else if(e[d(454)](64512&w,55296)&&e[d(1623)](e[d(1472)](64512,v=a.charCodeAt(e[d(573)](g,1))),56320)){let T=e[d(452)][d(554)]("|"),P=0;for(;;){switch(T[P++]){case"0":w=e[d(1387)](e.MJuoK(65536,e[d(1077)](e[d(1205)](1023,w),10)),e[d(665)](1023,v));continue;case"1":n[s++]=e[d(941)](e[d(875)](w,18),240);continue;case"2":n[s++]=e[d(1253)](e[d(674)](w>>12,63),128);continue;case"3":++g;continue;case"4":n[s++]=e.hhyvA(e[d(727)](63,w),128);continue;case"5":n[s++]=e[d(1432)](e[d(656)](w,6)&63,128);continue}break}}else n[s++]=e[d(1235)](w>>12,224),n[s++]=e[d(875)](w,6)&63|128,n[s++]=e[d(1484)](63,w)|128;return e[d(495)](s,h)}async function $d(a){let n=t,s={fHclu:e[n(597)]};if(e.FkXkz(e[n(1704)],e[n(1704)]))this[n(655)](s.fHclu,_0x18c375),this.onmessage&&this[n(1071)+"e"](_0x4c1e14);else{if(e[n(1734)](e.POrkd,typeof a)){let d=new Uint8Array(Wd(a));return e.qXIcW(ia,a,d,0),d}return e[n(711)](a,ArrayBuffer)?new Uint8Array(a):new Uint8Array(a[n(1175)],a[n(1480)+"et"],a[n(1007)+"th"])}}function qh(a){let n=t;if(e[n(786)](e[n(961)],e[n(1417)]))try{return e[n(894)]!=typeof a&&(e[n(711)](a,ArrayBuffer)||a.buffer&&e[n(395)](a.buffer,ArrayBuffer))||e[n(1613)](e.POrkd,typeof a)?"":(JSON[n(1862)](a),e.ThOCY)}catch{return n(634)==typeof a?e[n(1462)]:""}else _0x356e63.d=(s,d)=>{let f=n;for(var h in d)_0x1908c6.o(d,h)&&!_0xbb41cd.o(s,h)&&_0x5c8f5c[f(903)+"operty"](s,h,{enumerable:!0,get:d[h]})}}let Gh=(a,n)=>{let s=t;switch(a){case e[s(1025)]:case e[s(1266)]:return{[s(570)+a]:1,"x-tt-env":n};default:return{}}};class jh{constructor(n){let s=t;this["maxLossC"+s(490)]=n,this[s(952)]=0}[t(1035)](){let n=t;this[n(952)]++}[t(670)+t(1343)+"nt"](){let n=t;return e[n(1625)](this[n(952)],this[n(1468)+n(490)])}[t(1429)+t(1162)](n=0){let s=t;this[s(1468)+s(490)]=n,this.count=0}}async function Wh(a){let n={GtBUb:function(s,d){return e[q(1198)](s,d)}};return new Promise(s=>{let d=q,f={zsAXS:function(h,w){return e.Wpfmd(h,w)},ewQNt:e[d(1820)],ZirCJ:function(h,w){return e.Womwr(h,w)}};if(!Jn)return e.XnesT(s,d(408)+d(499));try{if(e[d(760)](e[d(470)],"aVTxi")){let h=document[d(427)+d(578)](e[d(477)]);window[d(1689)+d(1758)]=w=>{let v=d;document.body[v(878)+"ild"](h),window[v(1689)+"JSONP"]=void 0,f.zsAXS(s,w&&w.msg||f[v(1726)])},h[d(424)]=e[d(995)],h.src=e[d(1812)](a[d(666)](/^ws/,e[d(710)]),e[d(1753)]);try{document[d(700)][d(721)+d(1904)](h)}catch{if(e[d(1528)](e[d(850)],d(1193)))document[d(700)]["removeCh"+d(1904)](h);else return _0x2200c1&&BiRQSn[d(1189)](!0,_0x1135a0[d(448)])}}else return bgoYBS[d(500)](this[d(736)+d(1692)],this[d(478)+"s"][d(1900)])?!0:this[d(1027)+d(1132)+"riesCount"]>this.maxRetries}catch{e.LWDdU!==e[d(929)]?(window[d(1689)+"JSONP"]=void 0,s(e[d(1820)])):(this["_cursorN"+d(1006)]=_0x132d10,this[d(965)+d(552)]=_0x1bdf30,this[d(923)+d(1845)]=_0x49728a,this[d(1181)]=_0x556520(this[d(460)+d(1006)],d(1228)+d(443)))}})}function Xt(a,n,s){let d=t;return!!a?.find(f=>f[d(1378)]===n&&f.value===s)}function Vn(a,n){let s=t;if(e[s(974)]!==s(1446))return a?.find(d=>d.key===n)?.[s(857)];{let d=this[s(723)+"rs"][_0x55ac5d];if(d)d[s(797)]()[s(1182)](f=>f.fn[s(1815)](f[s(509)],_0x3940a1));else if(e[s(899)]("error",_0x534073)&&!this[s(1295)]){let f=_0x1fd194.length&&_0x4cae3d[0];if(e[s(1774)](f,_0x5d018b))throw f;let h=new _0x268e3d(e[s(1906)]+(f?e[s(1251)](" (",f[s(514)])+")":""));throw h[s(1824)]=f,f}return this}}let sa=null;async function Kh(){let a=t;return sa||(sa=Promise.resolve().then(Pt.bind(Pt,a(1386)))),sa}class $h extends ra{constructor(n,s){let d=t,f={KQvpM:function(h,w){return h(w)},KbzbZ:function(h,w){return e[q(1674)](h,w)},aWXEi:function(h,w){return e.YeLWK(h,w)}};if(e[d(709)](e[d(434)],e[d(434)]))super(),this[d(938)]=n,this[d(1914)]=s,this[d(1181)]=void 0,this[d(1569)+d(1542)]=null;else{let h=0,w=0,v;do v=cIEclE[d(1183)](_0xde0141,_0x580727),h<32&&(w|=cIEclE[d(1899)](cIEclE[d(1230)](127,v),h)),h+=7;while(cIEclE[d(1230)](128,v));return w}}async[t(1894)](){let n=t;n(511)!==e[n(1501)]?await this._init():(_0x16a7c4&&_0x4b254c[n(1350)+n(953)](heLMSf.vXAVr,()=>_0x3ce273()),_0x3e5bdb&&_0x3fa2dd["addEvent"+n(953)](heLMSf[n(468)],()=>_0xf0dd89()))}async _init(){let n=t,s={aczNR:function(d,f){return e[q(1124)](d,f)},tWrIo:e.DxoCo};if(!this[n(1181)]){if(this[n(1569)+"mise"])return this[n(1569)+n(1542)];try{let d=this[n(938)],f=this[n(1914)];this["_initPro"+n(1542)]=(async()=>{let h=n,w={iXPiw:function(g,T){return e[q(1566)](g,T)},Nwzlz:function(g,T){return e[q(1717)](g,T)},MMfoS:function(g,T){return e[q(1062)](g,T)}},{openDB:v}=await e[h(950)](Kh);this[h(1181)]=await e[h(599)](v,h(1689)+"_"+d,1,{upgrade(g){let T=h;if(s.aczNR(T(1807),s.tWrIo))g[T(1541)+T(1176)+"e"](d,{keyPath:f});else{if(ekTPtZ[T(1930)](_0x47afa2,-_0x98e9de))return _0x12c66c;if(ekTPtZ[T(551)](ekTPtZ[T(1133)](_0x65a06e,1),_0x5bc63e))return _0x3305b3}}})})(),await this["_initPro"+n(1542)]}catch(d){console[n(1805)](d)}finally{this[n(1569)+n(1542)]=null}}}async[t(1050)](n){let s=t;if(e[s(899)](e[s(392)],e[s(1602)]))heLMSf[s(950)](_0x26760c),heLMSf[s(515)](_0x4616c3);else try{return await this[s(1581)](),this[s(1181)]?.[s(1050)](this[s(938)],n)}catch(d){e[s(410)](s(544),s(544))?console.log(d):(_0x466203=e[s(945)](_0x1951ba,_0x457dfe),_0x567909=0)}}async[t(1592)](n,s){let d=t;return await this[d(1581)](),this[d(1181)]?.put(this[d(938)],n)}async[t(1431)](n){let s=t,d={qIqWt:"blocked",ByWdJ:function(f,h){return f(h)}};if(e[s(911)](e[s(428)],e[s(399)]))try{return await this[s(1581)](),this._qosDB?.delete(this[s(938)],n)}catch(f){e[s(786)](e[s(1224)],e[s(1443)])?console[s(1805)](f):(this._isInit=!0,this._connect())}else{let f=_0x226686[s(1923)+s(1655)](_0x2610a4);return _0x4ed116&&f[s(1350)+s(953)](JUGLyG[s(1520)],()=>_0x100254()),JUGLyG[s(1754)](_0x191e5f,f).then(()=>{})}}async[t(1770)](){let n=t;try{return await this[n(1581)](),this[n(1181)]?.[n(1770)](this[n(938)])}catch(s){console[n(1805)](s)}}async[t(910)](){let n=t;return await this[n(1581)](),this[n(1181)]?.[n(596)+"ys"](this[n(938)])}async[t(763)](){let n=t;return await this[n(1581)](),this[n(1181)]?.[n(763)](this[n(938)])}async[t(992)](){let n=t;try{this._qosDB?.[n(955)](),this[n(1181)]=void 0}catch(s){console[n(1805)](s)}}get isReady(){let n=t,s={KSLZs:function(d,f){return e[q(533)](d,f)}};try{if(e.IFIxa===e[n(1306)])return!!this._qosDB;{let d=this[n(1181)].getStorageInfoSync(this[n(893)]),f=_0x17859a.parse(s[n(1531)](d,"{}"));return _0x3d5c87[n(910)](f)}}catch(d){return console[n(1805)](d),!1}}}class Jh{constructor(n,s){let d=t;this[d(1886)]=n,this[d(1672)]=s,this[d(1181)]=localStorage}async openDB(){}get[t(893)](){let n=t;return n(1689)+"_"+this[n(1886)]}async[t(1050)](n){let s=t,d=this[s(1181)].getItem(this[s(893)]);return JSON[s(1862)](e[s(1597)](d,"{}"))[n]}async[t(1592)](n,s){let d=t,f=this[d(1181)][d(1040)](this[d(893)]),h=JSON[d(1862)](f||"{}");return h[s||n[this[d(1672)]]]=n,this[d(1181)].setItem(this[d(893)],JSON[d(664)+"y"](h)),s||n[this._pathKey]}async del(n){let s=t,d=this._qosDB[s(1040)](this[s(893)]),f=JSON[s(1862)](d||"{}");return f[n]=void 0,this[s(1181)].setItem(this[s(893)],JSON[s(664)+"y"](f))}async[t(1770)](){let n=t;return this[n(1181)][n(1770)]()}async keys(){let n=t,s=this._qosDB[n(1040)](this[n(893)]),d=JSON.parse(e[n(1597)](s,"{}"));return Object[n(910)](d)}async[t(763)](){let n=t,s=this[n(1181)].getItem(this[n(893)]),d=JSON[n(1862)](e[n(580)](s,"{}"));return Object.values(d)}[t(992)](){let n=t;return e[n(816)]!==n(513)?new _0x2b7f2b(_0x7ca856,{message:_0x19c0ec,code:_0x193de8,error:_0x4d7f92}):Promise.resolve()}get isReady(){return!!this[t(1181)]}}class Vh{constructor(n,s){let d=t;this[d(1886)]=n,this[d(1672)]=s,this[d(1181)]=vn?tt:Ur?wx:null}async[t(1894)](){}get[t(893)](){let n=t;return n(1689)+"_"+this[n(1886)]}async get(n){let s=t,d=this[s(1181)][s(1011)+s(485)](this[s(893)]);return JSON[s(1862)](e.MCwcr(d,"{}"))[n]}async set(n,s){let d=t,f=this[d(1181)][d(1011)+"geSync"](this._prefix),h=JSON.parse(e[d(1021)](f,"{}"));return h[s||n[this[d(1672)]]]=n,this._qosDB["setStora"+d(485)](this[d(893)],JSON[d(664)+"y"](h)),s||n[this[d(1672)]]}async[t(1431)](n){let s=t,d=this._qosDB[s(1011)+s(485)](this[s(893)]),f=JSON[s(1862)](e[s(839)](d,"{}"));return f[n]=void 0,this._qosDB["setStora"+s(485)](this._prefix,JSON[s(664)+"y"](f))}async clear(){let n=t;return this._qosDB[n(529)+"rageSync"]()}async[t(910)](){let n=t,s=this[n(1181)][n(1011)+n(441)+"nc"](this[n(893)]),d=JSON[n(1862)](e.WGoMP(s,"{}"));return Object[n(910)](d)}async[t(763)](){let n=t,s=this._qosDB[n(1011)+n(441)+"nc"](this[n(893)]),d=JSON[n(1862)](e[n(703)](s,"{}"));return Object[n(1477)](d)}[t(992)](){return Promise[t(1094)]()}get[t(629)](){let n=t;return e.JLfwA(e[n(1667)],e[n(1667)])?!!this._qosDB:this[n(1181)].isReady}}function Jd(a,n){let s=t;if(e[s(412)](vn,vn))return new Vh(a,n);if(e[s(553)](Jn,Hr)&&e.HRHJF(e[s(638)],typeof indexedDB))return new $h(a,n);if(e[s(569)](Jn,Hr)&&e.kQauc!=typeof localStorage)return new Jh(a,n);throw new Error(e[s(849)])}class Yh{constructor(){let n=t;this["_interva"+n(1197)+"Id"]=null,this[n(979)+"l"]=36e5,this[n(1181)]=Jd(e.HqfVj,e[n(799)])}async[t(979)+t(1880)](){let n=t;e[n(1180)](clearInterval,this[n(979)+"lTimeoutId"]),this[n(979)+"lTimeoutId"]=e.tPesZ(setInterval,()=>{let s=n;this[s(1341)+s(1014)]()},this[n(979)+"l"])}async openDB(){let n=t;await this._qosDB[n(1894)]()[n(1101)](()=>{let s=n;this[s(979)+s(1880)]()})}async["flushExp"+t(1014)](){let n=t,s={PBwHL:function(d,f){return e[q(1589)](d,f)},azcQg:function(d,f){return e[q(1476)](d,f)},nxhAk:function(d,f){return e[q(1312)](d,f)},fDhwV:function(d,f){return d>>>f},vkYVr:function(d,f){return e[q(1724)](d,f)},nFJUh:function(d,f){return d<f},jaBFk:function(d,f){return e.MyIpU(d,f)},rDcfU:function(d,f){return e.jtjiG(d,f)},OUWDD:function(d,f){return e.yURLq(d,f)},SRJlK:function(d,f){return e.ZJCqZ(d,f)},WXeUy:function(d,f){return e.yXLPw(d,f)}};if(e[n(709)](e.jPIZk,e[n(1294)])){if(_0x51130b=s.PBwHL(127,_0x4b54b3[_0x31b8d6])>>>0,s.azcQg(_0x53180e[_0x586612++],128))return{value:_0xfddd37?_0x1e871f:s[n(1357)](0,_0x36cf72),offset:_0x39af33};if(_0x285a5a=s.fDhwV(s.nxhAk(_0x52109b,s[n(867)](127&_0x2c5b4d[_0x39f41d],7)),0),s[n(1204)](_0x127901[_0x22a767++],128))return{value:_0x4d13e6?_0x16cc6d:s[n(1357)](0,_0x311af5),offset:_0x3890ee};if(_0x1136ce=s[n(915)](s[n(1357)](_0x536754,s.vkYVr(s[n(1455)](127,_0x17b6b8[_0x59e89e]),14)),0),s[n(787)](_0x4f5887[_0x403927++],128))return{value:_0x3afd7f?_0x33705e:s[n(1357)](0,_0x261578),offset:_0x33800a};if(_0x430c47=s[n(1516)](_0x5cde02,s[n(867)](127&_0x231c2c[_0x49a5dc],21))>>>0,s.rDcfU(_0x3ca46a[_0x20fdbf++],128))return{value:_0x21812d?_0xf08acd:0|_0x2c539a,offset:_0xad8430};if(_0x1e9f2e=s.fDhwV(s[n(1516)](_0x333287,s.OUWDD(15&_0x8b8792[_0x4bb412],28)),0),_0x2a434a[_0x1218b5++]<128)return{value:_0x1bac24?_0x47dd47:s[n(1375)](0,_0x370c5b),offset:_0x19bfbd};if(s.WXeUy(_0xab766c+=5,_0x2fa05c[n(1900)]))throw _0x25882e=_0x5c739c[n(1900)],_0x1ea764(_0x3a308d,10,_0x37c19d[n(1900)]);return{value:_0x53981d?_0x5c9cb2:0|_0x24d4c4,offset:_0x3f6f23}}else(await this[n(1181)]?.[n(763)]()||[]).filter(({timestamp:h})=>h<Date.now())[n(1182)](h=>{this[n(1181)]?.del(h.message_id)})}async del(n){let s=t;return this[s(1181)]?.[s(1431)](n)}async[t(1592)](n,s){return this[t(1181)]?.set({message_id:n,timestamp:s})}async get(n){let s=t;return this[s(1181)]?.[s(1050)](n)}async closeDB(){let n=t;e[n(781)](clearInterval,this[n(979)+n(1197)+"Id"]),await this[n(1181)]?.[n(992)]()}get[t(629)](){let n=t;return e[n(1442)](e[n(530)],e[n(530)])?this[n(1181)]?.[n(629)]:this._socket[n(1486)+"ns"]}}function oa(a){let n=t,s=!!this[n(402)].enableQoS;if(!s)return{enabled:s,isQoSMessage:!1,isQoSAck:!1,isAckCleanupMessage:!1,ackMsgIds:[]};let d=Xt(a[n(514)][n(1061)],e.CBqyl,"2"),f=d&&e[n(599)](Xt,a[n(514)][n(1061)],e[n(1660)],"1"),h=d&&e.qXIcW(Xt,a[n(514)][n(1061)],e.twJgp,"1"),w=h?e[n(693)](Vn,a[n(514)][n(1061)],e.UInYR)?.[n(554)](",").filter(Boolean)||[]:[];return{enabled:s,isQoSMessage:d,isQoSAck:f,isAckCleanupMessage:h,ackMsgIds:w}}async function Vd(){let a=t;return this[a(822)+a(611)]||(this[a(822)+a(611)]=new Yh),this[a(822)+a(611)][a(629)]||await this["_QoSMana"+a(611)][a(1894)](),this[a(822)+a(611)]}async function Zh(a,n){let s=t,{enableAutoAck:d}=this[s(402)],f=e[s(599)](Xt,a[s(514)][s(1061)],e[s(682)],"1"),h=e[s(538)](Xt,a.message[s(1061)],e[s(1844)],"1"),w=oa[s(677)](this,a);if(e[s(746)](d,f)){let{SeqID:v,LogID:g,service:T,LogIDNew:P,method:N}=a[s(514)];this._sendAck({SeqID:v,LogID:g,LogIDNew:P,service:T,method:N,headers:[{key:e[s(1844)],value:"1"},{key:e[s(1047)],value:P||""},{key:"ack_code",value:"0"}]})}h&&!w[s(480)]&&this[s(416)+s(1561)+s(603)](a),e[s(889)](n)}async function Xh(a,n){let s=t;this[s(1257)](e.cjsAf,a[s(514)]),e[s(1673)](n)}async function Qh(a,n){let s=t,d=e.xICog(Vt,await e[s(1868)]($d,a[s(805)]));try{if(d[s(1032)]instanceof Uint8Array){let f=e[s(984)](this[s(402)][s(1608)+s(1355)],Object)?{force:!!this._options["payloadE"+s(1355)].force,encoding:this[s(402)]["payloadE"+s(1355)].encoding?this[s(402)][s(1608)+s(1355)][s(1239)].replace(/\s/g,"")[s(1878)+"ase"]():""}:{force:!1,encoding:this[s(402)][s(1608)+"ncoding"]?this[s(402)][s(1608)+"ncoding"].replace(/\s/g,"")["toLowerC"+s(598)]():""},h=d[s(1608)+s(1355)]?d[s(1608)+"ncoding"][s(666)](/\s/g,"")[s(1878)+s(598)]():"",w=this._options["payloadT"+s(1709)]instanceof Object?{force:!!this[s(402)]["payloadT"+s(1709)][s(590)],type:this[s(402)][s(1764)+s(1709)].type?this[s(402)][s(1764)+s(1709)][s(424)][s(666)](/\s/g,"")["toLowerC"+s(598)]():""}:{force:!1,type:this[s(402)][s(1764)+s(1709)]?this[s(402)][s(1764)+s(1709)][s(666)](/\s/g,"").toLowerCase():""},v=d["payloadT"+s(1709)]?d[s(1764)+s(1709)][s(666)](/\s/g,"")[s(1878)+s(598)]():"",g=w.force?w.type:v||w[s(424)],T=f[s(590)]?f[s(1239)]:h||f.encoding,P=[e[s(1462)],e.ThOCY,s(958)+"ion/json;charset"+s(426),s(634)],N=[e[s(855)],s(917)];this._options[s(1382)+s(1814)+s(1803)+"ad"]&&P[s(733)](g)&&(!T||N[s(733)](T))?d["textPayl"+s(1498)]=e[s(599)](Kd,d[s(1032)],0,d[s(1032)][s(1007)+"th"]):d["textPayl"+s(1498)]=""}else d["textPayl"+s(1498)]=""}catch(f){d[s(630)+"oad"]="",console[s(1805)](f)}a.message=d,n()}function ep(a,n,s){let d=t,f=e[d(569)](s,8192),h=e.kEQaE(f,1),w=null,v=f;return function(g){let T=d;if(e.pTTXf(g,1)||e.YPguL(g,h))return e[T(1323)](a,g);e[T(1784)](v+g,f)&&(w=e.sylnA(a,f),v=0);let P=n[T(677)](w,v,v+=g);return e[T(1864)](7,v)&&(v=e[T(1039)](7|v,1)),P}}let tp=4294967295;function np(a,n,s){let d=t;return RangeError(e[d(527)](e[d(824)](e[d(824)](e.zFasJ+a+e.Heipu,e.VqXIF(n,1)),e[d(687)]),s))}function rp(a,n,s){let d=t;if(e.ApvWs!==e[d(1225)]){if(e[d(1110)](s,tp))throw new Error("integer "+d(1342)+"e");let f=3;for(;e[d(1212)](f,0);){let h=255&s;e[d(538)](ca,h,a,n+f),s>>>=8,f--}return n+4}else this[d(478)+"s"]=_0x407ba5,this.maxRetries=_0x38b12f,this[d(736)+"ndex"]=0,this[d(1027)+d(1132)+d(987)+"t"]=0}function ip(a,n){let s=t,d={SJbsQ:function(f,h){return e.XyHrd(f,h)},qIpBx:function(f,h){return e[q(1863)](f,h)},wxJiQ:function(f,h){return f!==h},iWZsV:function(f,h){return f&h},UnOeP:function(f,h){return e[q(1319)](f,h)},STwgT:function(f,h){return e[q(1134)](f,h)},xyeTr:function(f,h){return e[q(876)](f,h)},RfCqp:function(f,h){return e[q(1744)](f,h)}};if(s(1885)!==e.CNMpl)_0x5a0371=_0x1f7a07[dJzbXH.SJbsQ(dJzbXH[s(1515)](_0x15ca05,_0x12a1e9),1)],dJzbXH[s(1020)](dJzbXH[s(1720)](192,_0x6842e0),128)?_0x28e806+=_0x4e55e5:(_0x313be9=dJzbXH[s(874)](dJzbXH[s(877)](dJzbXH.xyeTr(31,_0x41e209),6),dJzbXH[s(1720)](63,_0x55672c)),dJzbXH.RfCqp(_0x59614c,128)?_0x41476e+=_0x46bafc:(_0x575560+=_0x4fa45b(_0x17c8c4),_0x31a247++));else{let f=0,h=n,w=e[s(1863)](n,4);for(;h<w;){let{value:v,offset:g}=e[s(547)](aa,a,h);h=g,f=e[s(1145)](e.biDll(f,8),0),f+=v}return{value:f,offset:w}}}function sp(a,n,s){let d=t,f=e[d(1328)][d(554)]("|"),h=0;for(;;){switch(f[h++]){case"0":if(e[d(508)](a[d(1900)],40))return e[d(1391)](e[d(538)](ia,a,n,s),s);continue;case"1":if(n.write)return e[d(594)](n[d(467)](a,s),s);continue;case"2":return e[d(1843)](e.GsUiE(ia,a,n,s),s);case"3":if(n.utf8Write)return e[d(1819)](n[d(1240)+"e"](a,s),s);continue;case"4":if(!a)return s;continue}break}}function op(a,n){let s=t,d=new ce(e[s(1091)](e[s(420)](a[e[s(1819)](n,4)]<<24|a[e[s(1511)](n,5)]<<16,a[e[s(1840)](n,6)]<<8),a[e[s(400)](n,7)]),e[s(743)](e[s(660)](e[s(926)](a[e.XyHrd(n,0)]<<24,e[s(1723)](a[e.LzEYS(n,1)],16)),e.wKkVJ(a[n+2],8)),a[e[s(788)](n,3)]),!0);return n+=8,{value:d,offset:e[s(594)](n,8)}}function ap(a,n,s){let d=t,f=a[d(1851)],h=a[d(1755)];return n[s]=e.bcbOl(h,24),n[e.ATyUH(s,1)]=e.rNfzS(h>>>16,255),n[s+2]=e[d(971)](h,8)&255,n[e[d(1826)](s,3)]=255&h,n[s+4]=e[d(1565)](f,24),n[e[d(846)](s,5)]=e[d(1216)](f,16)&255,n[e.bPdCT(s,6)]=e[d(1056)](e[d(1247)](f,8),255),n[e[d(745)](s,7)]=e.iKmKW(255,f),s+=8,s}function aa(a,n){let s=t;return a.readUInt8?{value:a[s(516)+"8"](n),offset:e.CwJgC(n,1)}:{value:255&a[n],offset:e[s(1444)](n,1)}}function ca(a,n,s){let d=t,f={xzDtO:function(h,w){return e[q(1833)](h,w)},tUjgj:function(h,w){return h(w)}};return e.TVzmg(d(1591),e[d(550)])?yAOCES.xzDtO(_0x21ea87,_0x2d0278[d(1815)](yAOCES[d(906)](_0x38eba1,this),_0x3db738)):(n.writeUint8?n[d(1787)+"t8"](a,s):n[s]=255&a,e.swbny(s,1))}let cp=function(a){return new Uint8Array(a)},dp=typeof Buffer<"u"?Buffer["allocUns"+t(1721)]:e[t(1167)](ep,cp,Uint8Array[t(750)+"e"][t(817)]);(()=>{let a=t,n={OWTkI:e[a(1799)],BfUuJ:function(d,f){return e[a(1548)](d,f)},gOotj:function(d,f){return e[a(1311)](d,f)},dkKxt:function(d,f){return e.fKzIk(d,f)},HOxRH:function(d,f){return d<<f},aGcjP:function(d,f){return e[a(1648)](d,f)},lAuqe:function(d,f){return d<f},lhrXJ:function(d,f){return e.SydMz(d,f)},HnbwM:function(d,f){return e.LjvcT(d,f)},tGpel:function(d,f){return e[a(1587)](d,f)},LFvDC:function(d,f){return e.DJSbC(d,f)},xkVAh:function(d,f){return e.suvEQ(d,f)},AXipR:function(d,f){return e.uhMYh(d,f)},UEMaU:function(d,f){return e.hwPGC(d,f)},HzixJ:function(d,f){return e[a(688)](d,f)},jgFtN:function(d,f){return d>f},kavPj:function(d,f,h,w){return e[a(1850)](d,f,h,w)},eNeOw:function(d,f){return e[a(1631)](d,f)}},s=4294967295;return function(d,f,h=!0){let w=a,v=n[w(1740)].split("|"),g=0;for(;;){switch(v[g++]){case"0":if(n[w(715)](d[f++],128))return{value:h?s:n[w(1557)](0,s),offset:f};continue;case"1":if(n[w(715)](d[f++],128))return{value:h?s:n[w(652)](0,s),offset:f};continue;case"2":return{value:h?s:0|s,offset:f};case"3":s=(s|n.HOxRH(n[w(686)](127,d[f]),7))>>>0;continue;case"4":if(n[w(1008)](d[f++],128))return{value:h?s:0|s,offset:f};continue;case"5":s=n[w(686)](127,d[f])>>>0;continue;case"6":if(n.lAuqe(d[f++],128))return{value:h?s:n.lhrXJ(0,s),offset:f};continue;case"7":s=n[w(1797)](n[w(931)](s,n[w(1479)](n[w(1404)](127,d[f]),14)),0);continue;case"8":s=n.xkVAh(s|n[w(1896)](n[w(686)](15,d[f]),28),0);continue;case"9":s=n[w(1043)](n[w(1557)](s,n[w(901)](127,d[f])<<21),0);continue;case"10":if(n[w(1695)](f+=5,d[w(1900)]))throw f=d[w(1900)],n[w(1831)](np,f,10,d[w(1900)]);continue;case"11":if(d[f++]<128)return{value:h?s:n[w(520)](0,s),offset:f};continue}break}}})();let lp=16,da=32;function up(a){let n=t,s=0,d={};for(let f=0;f<a[n(1900)];f++)d[a[f][n(1228)+n(443)]]=e.beSZN(Wd,a[f][n(1228)+"ame"]),s+=e[n(869)](14,d[a[f]["cursor_n"+n(443)]]);return[s,d]}function Yd(a,n,s){let d=t,f={gdunq:function(T,P){return e[q(1004)](T,P)},BiCyR:"dPUNs",qddgN:e[d(390)],LyQfX:e[d(1022)],xLlav:function(T,P,N,B){return e[d(982)](T,P,N,B)},mPetj:e[d(738)],UbAuZ:e.vpmjT,VJpeB:function(T,P,N,B){return e.rtHKJ(T,P,N,B)},XVrRt:e[d(1415)],GzWHc:e[d(826)],dPCzw:function(T,P,N,B){return e[d(1546)](T,P,N,B)},qfstl:e.MRQhr},[h,w]=e.URDUX(up,a),v=e[d(1492)](dp,h),g=0;return a[d(1182)](T=>{let P=d;if(f[P(1042)](f[P(748)],f[P(1610)]))return _0xcd9640.log(_0x29dd6c),!1;console[P(1805)](f[P(1231)],T,T.service),g=f[P(1562)](ca,0,v,g),console[P(1805)](f[P(1649)],g),g=f[P(1562)](rp,v,g,T[P(661)]||0),console.log(f[P(1605)],g),g=f.VJpeB(ca,w[T[P(1228)+P(443)]],v,g),console.log(f[P(564)],g),g=f[P(1562)](sp,T[P(1228)+P(443)],v,g),console[P(1805)](f[P(1460)],g),g=f[P(442)](ap,ce[P(1841)+"er"](T[P(1539)]||n),v,g),console[P(1805)](f.qfstl,g)}),{frameType:da,headers:[{key:d(1089)+d(1297),value:s}],payload:v}}function fp(a){let n=t,s=0,d=[];for(;s<a[n(1007)+"th"];){let{offset:f}=e.eKPCT(aa,a,s);s=f;let h={cursor_name:"",cursor:0,service:0},{value:w,offset:v}=e[n(937)](ip,a,s);h.service=w,s=v;let{value:g,offset:T}=aa(a,s);s=T,h[n(1228)+n(443)]=Kd(a,s,e.tpzyB(s,g)),s+=g;let{value:P,offset:N}=e[n(978)](op,a,s);h[n(1539)]=P.toNumber(),s=N,d[n(1264)](h)}return d}function xp(){let a=t;return{frameType:da,headers:[{key:e[a(1309)],value:a(980)+"_EXIST"}],payload:void 0}}class hp{constructor(n,s,d){let f=t;this[f(460)+f(1006)]=n,this._cursorFileName=s,this["_message"+f(1845)]=d,this[f(1181)]=e.INNcg(Jd,this["_cursorN"+f(1006)],f(1228)+f(443))}async[t(1894)](){await this[t(1181)].openDB()}async getCursors(){let n=t;if(!this[n(1181)][n(629)])return;let s=this[n(923)+n(1845)],d=await this[n(1181)][n(763)]();switch(console.log(n(739)+n(967),d),s){case e.tbgqE:return d&&d[n(1900)]?e[n(475)](Yd,d,0,this[n(965)+"ileName"]):void 0;case n(1018):return;case"CONTINUE":return d&&d[n(1900)]?e[n(982)](Yd,d,0,this[n(965)+n(552)]):xp()}}async[t(1592)](n,s,d){let f=t;return console.log(e[f(1213)],n,s,d),this[f(1181)][f(1592)]({cursor_name:n,cursor:s,service:d})}async[t(1464)+"rs"](n){let s=t,d=e[s(1223)](fp,n);for(let f of d)console.log(e[s(993)],d),await this[s(1181)][s(1592)](f)}async[t(1050)](n){let s=t;return(await this[s(1181)].get(n))?.[s(1539)]}async closeDB(){let n=t;if(e[n(423)](n(828),e[n(1781)]))await this._qosDB.closeDB();else return _0x1a226b[n(1094)]()}[t(1423)+t(504)+t(1677)](n){let s=t;this["_cursorF"+s(552)]=n}get[t(629)](){return this[t(1181)].isReady}}let pp=e[t(1161)];async function Zd(a){let n=t;if(!this[n(402)].enableQoS)return null;let{aID:s,fpID:d,messageStrategy:f}=this[n(402)],h=e[n(412)](a,pp);try{return this["_cursorM"+n(1263)]?a&&this["_cursorM"+n(1263)].updateCursorFileName(a):this[n(1603)+n(1263)]=new hp(d+"_"+s+"_"+h,h,f),this["_cursorM"+n(1263)].isReady||await this["_cursorM"+n(1263)][n(1894)](),this[n(1603)+n(1263)]}catch{return null}}async function gp(a,n){let s=t;if(e[s(1009)]!=="KlYVW"){let d=e[s(719)](Xt,a[s(514)].headers,e[s(1585)],"-1"),f=e[s(803)](Xt,a.message.headers,e[s(1844)],"1"),h=e[s(1783)](Vn,a[s(514)][s(1061)],e[s(605)]),w=Number(e[s(1676)](Vn,a[s(514)][s(1061)],e[s(491)]))||0,v=oa.call(this,a),g=Xt(a[s(514)][s(1061)],e[s(776)],"2"),T=e[s(1836)](Vn,a[s(514)][s(1061)],e[s(1711)]),P=Number(e[s(1166)](Vn,a[s(514)][s(1061)],e[s(1371)]));if(v.isQoSAck)return e[s(1673)](n);let N=v[s(1871)+s(773)]?await Vd[s(677)](this):null;if(a[s(514)][s(661)]>0&&f&&!d||a[s(514)][s(661)]>0){if(h&&v["isQoSMes"+s(773)]&&N)return e.GHUGz!==e.GHUGz?new _0x2ac7c3(_0x1bc205,{code:_0x364216,reason:_0xd7dae,wasClean:_0x51c026,willReconnect:_0x34c0b4}):(!!!await N[s(1050)](h)&&(this[s(416)+s(680)+s(1471)](a),await N[s(1592)](h,e[s(1109)](Date[s(829)](),w))),e[s(1221)](n));if(g)if(e[s(1151)](e[s(862)],e[s(707)])){let B=await Zd[s(677)](this);if(!B)return this["_dispatc"+s(680)+"Event"](a),e[s(515)](n);let K=await B.get(T)??-1;if(e.FHofv(K,P))this[s(416)+s(680)+s(1471)](a),B[s(1592)](T,P,a[s(514)].service);else throw new Error("recevied"+s(880)+s(1349)+P+(s(1670)+"than loc"+s(960)+"r ")+K);return e[s(889)](n)}else _0x38275a(_0x3b5c4e,50),e[s(761)](_0x17947e,_0x9eb5aa,_0x22273d);return this[s(416)+s(680)+s(1471)](a),e.jIUim(n)}}else{let d=this._qosDB[s(1011)+s(485)](this[s(893)]);return _0x126e0d[s(1862)](d||"{}")[_0x461743]}}async function mp(a,n){let s=t;if(s(413)===e[s(1584)]){this["_clearPi"+s(1281)](),this[s(1822)+s(1237)+"Id"]=e[s(1360)](_0x41db18,this[s(1776)][s(1222)](this),this[s(402)][s(1663)+s(1325)]);return}else{let d=oa[s(677)](this,a);if(!d[s(1871)+s(773)])return e[s(864)](n);let f=await Vd[s(677)](this);if(d[s(1233)+s(898)+s(589)]&&d[s(989)+"s"][s(1900)])for(let h of d[s(989)+"s"])await f[s(1431)](h);e.baEyQ(n)}}async function wp(a,n){let s=t,d=e[s(1004)](a.message[s(1155)+"e"],lp),f=e.XTqnm(a[s(514)][s(1155)+"e"],da);if(!d&&!f)return e.YDVec(n);let h=e[s(978)](Vn,a[s(514)].headers,s(1089)+"ile_name");if(!h)return e[s(1673)](n);let w=await Zd[s(677)](this,h);if(!w)return e[s(950)](n);if(d)if(e.XlLTX===e[s(932)])this[s(923)+"Queue"][s(1264)](_0x49eb9d),this._debug(e[s(1918)],_0x272edc);else{let v=await w[s(1078)+"rs"](),g={frameType:v?.[s(1155)+"e"],SeqID:ce[s(1841)+"er"](this[s(1714)]++),LogID:ce[s(1841)+"er"](this._options[s(823)+s(1482)]()),service:9e3,method:5,headers:v?.[s(1061)],payload:v?.payload},T=e[s(1827)](I,g);this[s(1275)]&&this._ws[s(1260)+"te"]&&this._ws[s(705)](T)}if(f){let v=a[s(514)].payload;v&&w[s(1464)+"rs"](v)}}let _p=async function(a,n){let s=t;this[s(545)]=!1,clearTimeout(this[s(747)+s(1215)+s(881)]),e[s(1221)](n)},yp=async function(a,n){let s=t;if(!this[s(1275)]||e[s(606)](this[s(1275)][s(1260)+"te"],this[s(856)]))return n();let{pingInterval:d}=this[s(402)];this[s(1577)+s(473)]?.["resetEndpointCon"+s(1634)]();for(let h=0;e.ljKYQ(h,this["_message"+s(1248)][s(1900)]);h++){let w=this[s(923)+s(1248)][h];if(e.JhgOP(this[s(1275)][s(1260)+"te"],this.OPEN)&&w!==null)this[s(1275)]&&this[s(1275)][s(705)](w),this[s(923)+s(1248)][h]=null;else break}this[s(923)+s(1248)]=this["_message"+s(1248)][s(1690)](h=>!!h),this[s(1822)+"gTimeoutId"]=e[s(1229)](setTimeout,()=>this[s(1776)](),d),this[s(416)+s(1696)+"nt"](a),this[s(871)+"er"]&&this._ws&&(this[s(1275)][s(900)+"pe"]=this[s(1236)+s(1709)]);let f=this["_endpoin"+s(473)]?.[s(1358)+s(1068)+"nt"]();this[s(1257)](s(1544)+f+s(818)),e.jIUim(n)},bp=async function(a,n){let s=t,d=this["_endpoin"+s(473)]?.[s(1358)+s(1068)+"nt"]();this[s(1257)](s(1544)+d),e[s(1064)](n)};class Ep extends ra{constructor(n){let s=t,d={nCtCf:function(v,g){return e.tYlLF(v,g)},oPFeG:function(v,g){return e[q(1865)](v,g)},ZFKRL:function(v,g,T){return e.zSjIW(v,g,T)},BCYLp:e[s(759)],bzhcL:function(v,g,T,P){return e[s(565)](v,g,T,P)},uKSpW:e.hyWgd};super(),this["_miniNavigatorOn"+s(1148)]=!0,this[s(871)+"er"]=Jn,this[s(1206)]=zh,this._isMiniTT=vn,this[s(798)+"X"]=Ur,this[s(1227)+"r"]=Hr,this["_message"+s(1248)]=[],this[s(1577)+s(473)]=null,this[s(1525)+s(1063)]=!1,this[s(1236)+s(1709)]=e[s(619)],this["_connect"+s(691)]=!1,this["_connect"+s(1215)+"utId"]=null,this[s(879)+s(920)+"tId"]=null,this["_pingPon"+s(1237)+"Id"]=null,this._seqId=0,this[s(545)]=!1,this._url="",this["_QoSMana"+s(611)]=null,this["_cursorM"+s(1263)]=null,this[s(683)+"sCounter"]=null,this[s(712)+"ls"]="pbbp2",this[s(1385)]=3,this[s(592)+"NG"]=0,this[s(856)]=1,this[s(1084)]=2,this[s(568)]=v=>{let g=s,T={RMSNx:function(P,N){return d[q(1746)](P,N)},ncAfM:function(P,N){return d.oPFeG(P,N)},PGFsa:function(P,N,B){return d[q(1322)](P,N,B)}};try{if(d[g(627)]==="ehOmX")return dBzpRp[g(624)](dBzpRp[g(1143)](_0x4761bb,4)[g(854)]("0"),dBzpRp.PGFsa(_0x149715,_0x21a88f,2)[g(524)](16))[g(797)](-4);d[g(649)](jd,this,v,[_p,yp,bp])}catch(P){let N=st(d[g(507)],{message:P.message,code:Zt.OPEN_ERROR,error:P});this[g(416)+g(1888)+g(1508)](N)}},this._onMessage=async v=>{let g=s,T={SghNR:e[g(1246)],ALpoF:function(B,K,Y){return e[g(1502)](B,K,Y)}},{pingInterval:P,pingFrequency:N}=this[g(402)];if((v.data==="hi"&&N==="always"||e[g(667)](e[g(914)],N))&&(e[g(1715)](e[g(772)],e[g(1898)])?(this[g(1860)+g(1281)](),this.emit(e[g(1658)],e.LXbcK),this[g(1822)+"gTimeoutId"]=e[g(1053)](setTimeout,this[g(1776)][g(1222)](this),P)):this[g(655)](JwIdEr[g(1849)],JwIdEr.ALpoF(_0xe1fc4f,JwIdEr.SghNR,{message:this[g(1107)+g(575)+"age"](_0x5a871c)}))),!e[g(1392)]("hi",v[g(805)]))try{e[g(696)](jd,this,v,[Qh,Zh,mp,wp,gp,Xh])}catch(B){let K=e.KspFb(st,e[g(1246)],{message:B[g(514)],code:Zt.MESSAGE_ERROR,error:B});this[g(416)+"hErrorEv"+g(1508)](K)}},this[s(1601)]=v=>{let g=s,T=this[g(1577)+g(473)]?.[g(670)+g(1659)+"es"](),P=this[g(1577)+g(473)]?.[g(1358)+g(1068)+"nt"]();if(T&&!v[g(514)]){let N="connect "+P+(g(1173)+g(1765)+g(801)+"ed");this[g(416)+g(1888)+g(1508)](e[g(1570)](st,g(425),{message:N,code:Zt[g(419)+g(1422)+"R"],error:v}));return}this[g(1275)]&&e[g(699)](this[g(1275)][g(1260)+"te"],this.OPEN)&&this[g(1703)+g(784)](),this[g(416)+g(1888)+g(1508)](e[g(1302)](st,g(425),{message:v[g(514)],code:Zt[g(768)+g(398)],error:v}))},this[s(563)]=async v=>{let g=s,T={QtuLc:function(N,B){return e[q(1424)](N,B)},omKAZ:function(N,B){return N!=B},oKwRd:g(1184)+"d",SKpKk:function(N,B){return e[g(1613)](N,B)},QGLms:e[g(849)]};this[g(1620)+g(662)](),this[g(1860)+g(1281)](),this[g(1088)+g(620)+"rs"](),this[g(1275)]=null,this[g(747)+g(691)]=!1;let P=this[g(1577)+g(473)]?.[g(670)+g(1659)+"es"]();if(!P&&this[g(1408)+g(482)]()&&!this[g(1525)+g(1063)])if(e[g(802)]!==e[g(802)]){if(MLoYQG[g(1668)](_0x339366,_0x23fcbb))return new _0x549d0e(_0x33d90a,_0x2699d3);if(MLoYQG[g(1668)](_0x20f705,_0x5b4562)&&MLoYQG.omKAZ(MLoYQG[g(1339)],typeof _0x45e8a1))return new _0x486da3(_0x5ef50e,_0xab5c64);if((_0x356a15||_0x25a0e2)&&MLoYQG[g(1651)](MLoYQG[g(1339)],typeof _0x58fc3f))return new _0x415c25(_0x46cee2,_0x560236);throw new _0x18b308(MLoYQG[g(613)])}else{let N=this[g(1577)+g(473)]?.[g(1358)+g(1068)+"nt"](),B=this[g(402)]["reconnec"+g(621)+"ptor"](v.code,v[g(499)]);this[g(416)+g(1626)+g(1508)](e[g(1157)](ft,"close",{code:1006,reason:v[g(499)]||g(843)+g(1379)+g(1092)+g(1119)+g(1687)+g(782)+N,willReconnect:B})),B&&this[g(747)]();return}if(v[g(724)]!==1e3&&this[g(1525)+g(1063)]){this[g(416)+g(1626)+g(1508)](e[g(1048)](ft,e.vXAVr,{code:1e3,reason:e[g(1114)]})),this[g(1577)+g(473)]?.[g(1395)+g(1669)+"fig"](),this[g(683)+g(1890)]?.[g(1429)+g(1162)]();return}if(v[g(724)]!==1e3&&P){let N=this[g(1577)+g(473)]?.[g(1358)+g(1068)+"nt"](),B=v[g(499)];B||(B=await e[g(744)](Wh,this[g(1499)])),B=g(843)+g(1379)+g(518)+B+(g(927)+g(1262))+N+(", max re"+g(1437)+g(1693)),this[g(416)+g(1626)+"ent"](e.nuiAq(ft,e[g(635)],{code:v.code,reason:B}));let K=g(1279)+N+(g(1173)+g(1765)+g(801)+"ed");this["_dispatc"+g(1888)+g(1508)](e.xIUCY(st,e[g(1246)],{message:K,code:Zt.MAX_RETRIES_ERROR})),this._endpointManager?.[g(1395)+g(1669)+g(1634)](),this[g(683)+g(1890)]?.["resetCou"+g(1162)]();return}if(e[g(981)](1e3,v[g(724)])&&!v.reason){if(e[g(791)](g(1643),e[g(458)]))return new _0x4f7c9c(_0x410b0f);{let N=this[g(1577)+g(473)]?.[g(1358)+g(1068)+"nt"]();this[g(416)+"hCloseEv"+g(1508)](e.ClOJX(ft,e[g(635)],{code:v.code,reason:"connecti"+g(1379)+"d, unkno"+g(1119)+g(1687)+"ame: "+N})),this[g(1577)+g(473)]?.[g(1395)+g(1669)+"fig"](),this["_pingLos"+g(1890)]?.["resetCou"+g(1162)]();return}}this[g(416)+"hCloseEv"+g(1508)](v),this[g(1577)+g(473)]?.[g(1395)+g(1669)+g(1634)](),this[g(683)+g(1890)]?.[g(1429)+g(1162)]()},this.onclose=null,this[s(1295)]=null,this[s(1071)+"e"]=null,this.onopen=null,this[s(785)+s(1259)]=null,this[s(1800)+"eAck"]=null,this[s(1810)+s(1535)+s(1412)+"ct"]=null,this[s(809)+"nLine"]=this[s(809)+s(1140)][s(1222)](this),this[s(809)+s(1368)]=this[s(809)+s(1368)].bind(this),this[s(1743)+"ageHide"]=this[s(1743)+s(1317)].bind(this),this[s(1743)+s(1920)]=this[s(1743)+"ageShow"][s(1222)](this),this[s(402)]={url:"",automaticOpen:!0,initReconnectInterval:1e3,maxReconnectInterval:1e4,reconnectIntervalGrowFactor:2,timeoutInterval:5e3,maxRetries:5,debug:!1,maxMessageQueueLength:e.KQUXD(1,0),service:0,logIDGenerator:o,headers:void 0,payloadEncoding:"",payloadType:"",fpID:"",deviceID:"",accessKey:"",ttwID:"",bddID:"",aID:"",disableAutoReconnect:!1,customParams:{},pingInterval:15e3,pingTimeoutInterval:4e3,pingFrequency:"auto",pingLossCount:2,enableTransformTextPayload:!1,logIDNewConfig:{enableAutoGenerateLogIDNew:!1,userIp:""},miniProgramParams:{customHttpHeader:{}},enableAutoAck:!1,reconnectInterceptor:()=>!0,enableQoS:!1,QoSLevel:2,messageStrategy:e[s(756)],env:{xTTEnv:"",xUseEnv:""},listenNetworkChanged:!0};let{url:f,ws:h}=n,w=Array[s(1733)](f)?f:e[s(894)]==typeof f?[f]:[];if(!w||e.xwafD(0,w.length))throw new Error(s(1113)+s(503)+s(808));if(!e.rVkFG(Hh,h))throw new Error(e[s(1245)]);Object[s(977)](this[s(402)],n),this[s(1577)+s(473)]=new Gd(w,this[s(402)][s(1855)+"es"]),this[s(683)+s(1890)]=new jh(this[s(402)][s(730)+"Count"]),this[s(402)][s(1451)+"cOpen"]&&(this[s(545)]=!0,this._connect()),this[s(402)][s(1507)+s(1481)+s(406)]&&(this[s(1012)+"T"]||this[s(798)+"X"]?this[s(1301)+s(1540)+s(636)]():this[s(871)+"er"]&&this[s(692)+s(734)+s(953)]())}[t(809)+t(1140)](){let n=t;this[n(402)][n(859)+n(1178)+n(1017)]||this[n(1525)+n(1063)]||this[n(1095)+n(1259)]()}[t(809)+t(1368)](){let n=t;this._destroyWebSocket();let s=e[n(1270)](na,n(1861)+"t",{message:e[n(1344)]});this[n(1810)+"mediatelyReconnect"]&&this[n(1810)+"mediatelyReconnect"](s)}[t(692)+t(734)+"Listener"](){let n=t;e.zZpyN("PVPSH",e.ivNLe)?(_0x144c78[n(630)+n(1498)]="",_0x1e7cd7[n(1805)](_0x255fdd)):(this[n(871)+"er"]&&window[n(1350)+n(953)](e[n(1304)],this[n(809)+"nLine"]),this._isBrowser&&window[n(1350)+n(953)](e[n(1214)],this[n(809)+n(1368)]),this[n(871)+"er"]&&window[n(1350)+n(953)](e.CpHZA,this[n(1743)+n(1317)]),this[n(871)+"er"]&&window.addEventListener(e[n(559)],this["_handleP"+n(1920)]))}["_dropGlo"+t(734)+t(953)](){let n=t,s={FBFYV:function(d,f){return e.DPZpe(d,f)},THagA:e[n(1234)],ggUkk:function(d,f){return e[n(1073)](d,f)},UJkkK:function(d,f){return d+f}};if(e[n(1903)](n(644),e[n(1772)]))this[n(871)+"er"]&&window[n(501)+n(607)+n(714)](e[n(1304)],this[n(809)+"nLine"]),this[n(871)+"er"]&&window[n(501)+n(607)+n(714)](e[n(1214)],this[n(809)+n(1368)]),this[n(871)+"er"]&&window[n(501)+n(607)+n(714)]("pagehide",this[n(1743)+n(1317)]),this[n(871)+"er"]&&window[n(501)+n(607)+n(714)](e[n(559)],this[n(1743)+n(1920)]);else return NYAOfZ[n(1731)](_0x41dccb,_0x586280)?_0x431528[n(1545)](new _0x2c0866(NYAOfZ[n(526)])):(_0x34d3cc=_0x344a18,NYAOfZ[n(991)](_0xf51d6,_0x1a948b[n(1900)])?_0x412b8f[n(1094)]():_0x282a8b[_0x7eb0ce][n(1222)](_0xbc8934)(_0x1c95ad,_0x171acc[n(1222)](null,NYAOfZ[n(1788)](_0x447e62,1))))}["_handleP"+t(1317)](n){let s=t,d={SqsHj:function(f,h,w){return e[q(693)](f,h,w)}};e.AyYin(s(1495),s(1644))?(NknRxv[s(639)](_0x397ef0,_0x208df7,74),NknRxv[s(639)](_0x233229,_0x15ab4b,_0x4f5ad7)):(!n[s(966)+"d"]&&(this[s(871)+"er"]&&window[s(501)+s(607)+"ner"](e[s(729)],this[s(1743)+s(1317)]),this[s(871)+"er"]&&window[s(501)+s(607)+s(714)](e.UHnrt,this[s(1743)+"ageShow"]),this[s(955)]()),this[s(871)+"er"]&&window[s(501)+s(607)+s(714)](e.hDNXz,this[s(809)+"nLine"]),this[s(871)+"er"]&&window["removeEv"+s(607)+s(714)](s(1098),this[s(809)+"ffLine"]))}["_handleP"+t(1920)](n){let s=t;n[s(966)+"d"]&&(this[s(1408)+s(482)]()&&(!this[s(1275)]||this[s(1275)][s(1260)+"te"]!==this[s(856)]||e[s(1700)](this[s(1275)][s(1260)+"te"],this[s(592)+"NG"]))&&this[s(809)+s(1140)](),this[s(871)+"er"]&&window[s(1350)+s(953)]("online",this["_handleO"+s(1140)]),this[s(871)+"er"]&&window["addEvent"+s(953)](e[s(1214)],this[s(809)+s(1368)]))}async[t(1377)+t(640)](n){let s=t,{fpID:d,deviceID:f,bddID:h,ttwID:w,accessKey:v,aID:g,customParams:T={},enableAutoAck:P,enableQoS:N,QoSLevel:B,env:K}=this[s(402)],Y,pe,qe;this[s(871)+"er"]||this._isMiniWX||this[s(1012)+"T"]?(Y=location&&e.zOFBK(s(471),location[s(1030)])?e.adZmE:"ws://",pe=n[s(666)](/((^ws)|(^http))((?:[s]*:\/\/))/,""),qe=/^wss(.*:\/\/)/.test(n)?n:""+Y+pe):(Y=s(1046),pe=n[s(666)](/(^http)((?:[s]*:\/\/))/,""),qe=/(^ws)((?:[s]*:\/\/))/[s(769)](pe)?pe:""+Y+pe);let Vi=h?"bd_did":w?e[s(626)]:e[s(457)],Yi=h||w||f;if(!Yi||!Vi)throw new Error(s(1113)+s(1108)+"ddID, deviceID or ttwID");let vp=e.WqSln==typeof T?await e[s(889)](T):T,Sp=K?Gh(K[s(1288)],K.xTTEnv):{},la=Object[s(977)]({device_platform:e.UjoDz,version_code:e[s(1867)],access_key:v,fpid:d,aid:g,[Vi]:Yi,xsack:P?1:0,xaack:P?1:0,xsqos:N?1:0,qos_level:N?B:void 0,qos_sdk_version:2,...Sp},vp),Ip=Object[s(910)](la).reduce((ua,fa)=>la[fa]!==void 0?""+ua+(ua?"&":"?")+fa+"="+la[fa]:ua,"");return qe+s(882)+Ip}async[t(747)](){let n=t,s={UYTSv:function(d){return d()},tDrSt:function(d,f,h){return e[q(1742)](d,f,h)},yJjLe:function(d,f){return e.sylnA(d,f)},TwjVI:e[n(1213)]};if(!(this[n(747)+"Lock"]||this[n(1525)+n(1063)])){this._connectLock=!0;try{if(e[n(836)](e.zlovT,e[n(1517)])){let d=this[n(1577)+n(473)]?.[n(1393)+n(1728)+n(1523)+n(1121)+"tries"](),{timeoutInterval:f}=this[n(402)];if(d){let w=this[n(1577)+n(473)]?.[n(1358)+n(1068)+"nt"](),v=this["_endpoin"+n(473)]?.[n(1170)+n(1085)+n(1567)+n(1671)+"unt"](),g=this[n(1577)+n(473)]?.[n(1358)+n(1068)+"ntTriesC"+n(490)]();if(v){let T=n(1279)+w+(n(601)+n(1752)+n(1437)+n(885)+n(1875)+"backup e"+n(1002))+v+(n(1298)+"y"),P=st(n(425),{message:T,code:Zt[n(419)+n(1422)+"R"]});this._debug(T),this[n(416)+"hErrorEv"+n(1508)](P),this._url=await this[n(1377)+"eUrl"](v),this[n(1257)]("connect "+v+" "+g+n(1081)),this[n(1088)+n(620)+"rs"]()}else{let T=n(1279)+w+(" timeout"+n(1752)+n(1437)+"ached");this._debug(T),this[n(416)+"hErrorEv"+n(1508)](st(e.hyWgd,{message:T,code:Zt["MAX_RETR"+n(1422)+"R"]}));return}}else if(e[n(1528)](n(940),e[n(519)])){let w=this[n(1577)+n(473)]?.[n(1358)+n(1068)+n(1459)+n(1627)](),v=this["_endpoin"+n(473)]?.[n(1358)+n(1068)+n(1846)+"ount"]();this[n(1499)]=await this[n(1377)+n(640)](w||""),this[n(1257)]("connect "+w+" "+v+n(1081)),this[n(1088)+n(620)+"rs"]()}else{let w=jmHZpl[n(1208)](_0x57ca3a);return jmHZpl[n(1554)](_0x332eff,_0x528bc8,w),jmHZpl.yJjLe(_0x12ca00,w)}if(this[n(545)])this[n(545)]=!1;else{let w=e[n(1026)](na,n(1861)+"t",{message:e[n(1052)]});this.onStartReconnect&&this[n(785)+n(1259)](w)}let h=this[n(1577)+"tManager"]?.[n(1358)+n(1068)+n(1846)+n(490)]()||0;e[n(1434)](h,1)&&await this._wait(e.DOPZz(h,1)),this._debug(n(843)+n(831)+this._url+(n(956)+n(1489))+this[n(712)+"ls"]),this[n(1275)]=e[n(1425)](Uh,{url:this[n(1499)],protocols:[this[n(712)+"ls"]],headers:this[n(402)][n(622)+n(918)+"s"][n(1457)+n(1418)]},this[n(402)].ws),(this._isBrowser||this[n(1227)+"r"])&&this[n(1275)]&&(this[n(1275)][n(900)+"pe"]=this[n(1236)+n(1709)]),this[n(1321)+n(462)](),this["_connect"+n(1215)+n(881)]=e[n(469)](setTimeout,this[n(1490)+"ut"][n(1222)](this),f)}else return _0x188e14[n(1805)](jmHZpl.TwjVI,_0x230999,_0x341e4c,_0xe0f2c2),this[n(1181)][n(1592)]({cursor_name:_0x2a76c3,cursor:_0x52b1d1,service:_0x45ae50})}catch(d){throw this["_connect"+n(691)]=!1,d}}}["_clearTi"+t(662)](){let n=t;e.beSZN(clearTimeout,this["_connect"+n(1215)+n(881)]),this[n(747)+"ionTimeo"+n(881)]=null}_clearPingTimer(){let n=t;e[n(815)](clearTimeout,this["_pingPon"+n(1237)+"Id"]),e[n(697)](clearTimeout,this[n(879)+"ctTimeou"+n(1330)]),this[n(1822)+"gTimeoutId"]=null,this._reconnectTimeoutId=null}[t(1257)](...n){let s=t;this[s(402)][s(566)]&&console.log[s(1815)](console,[e[s(1891)],...n])}[t(1172)+t(1639)+"e"](n){let s=t,{initReconnectInterval:d,maxReconnectInterval:f,reconnectIntervalGrowFactor:h}=this._options,w=e[s(1870)](d,Math[s(556)](h,e.tNIBU(n,1)));return e[s(1110)](w,f)?f:w}[t(1776)](){let n=t;if(this[n(1275)]&&this[n(1275)][n(1260)+"te"]===this[n(592)+"NG"]){this[n(1860)+"ngTimer"](),this[n(1822)+n(1237)+"Id"]=e[n(633)](setTimeout,this[n(1776)].bind(this),this[n(402)][n(1663)+n(1325)]);return}if(!this[n(1275)]||e.BHQtM(this[n(1275)][n(1260)+"te"],this.OPEN))return void this[n(1095)+n(1259)]();this[n(1275)]&&this[n(1275)][n(705)]("hi"),this[n(879)+n(920)+n(1330)]=e[n(1618)](setTimeout,this[n(1095)+n(1259)+n(612)].bind(this),this._options[n(706)+n(668)+"val"])}[t(1095)+"econnect"+t(612)](){let n=t;this[n(683)+n(1890)]?.[n(1035)](),this[n(655)]("ping_onc"+n(835)+"t",e[n(1315)]),this[n(683)+n(1890)]?.[n(670)+n(1343)+"nt"]()?this[n(1095)+"econnect"]():this[n(1776)]()}[t(1408)+"orOnline"](){let n=t;return this[n(1012)+"T"]||this[n(798)+"X"]?this[n(1364)+n(444)+n(1148)]:(this[n(871)+"er"]||this[n(1227)+"r"])&&this[n(402)][n(1507)+n(1481)+"nged"]?navigator[n(905)]:!0}[t(1095)+"econnect"](){let n=t,s={vMwSz:function(d,f){return e[q(1679)](d,f)},wXZKo:function(d,f){return d(f)}};if(e[n(793)](e[n(1327)],e[n(814)]))return function(d,...f){let h=n,w=_0x1c3443.call(oHFQwG[h(1129)](_0x292d90,this),d,...f);return _0x27264a.set(w,d[h(751)]?d.sort():[d]),oHFQwG[h(542)](_0x5af94a,w)};if(!this[n(1408)+n(482)]()||this[n(1525)+n(1063)])return;this["_endpoin"+n(473)]?.[n(1395)+n(1669)+"fig"](),this[n(683)+n(1890)]?.[n(1429)+n(1162)](),this[n(1275)]?this[n(1703)+"ect"](1001,e.hYtzr,!0):this[n(747)]()}[t(1301)+t(1540)+t(636)](){let n=t;this[n(1012)+"T"]?tt[n(1045)+"kStatusC"+n(1369)](({isConnected:s})=>{let d=n;this[d(1364)+d(444)+d(1148)]=s,s?this["_handleO"+d(1140)]():this["_handleO"+d(1368)]()}):this._isMiniWX&&wx[n(1045)+"kStatusC"+n(1369)](({isConnected:s})=>{let d=n;this[d(1364)+"igatorOn"+d(1148)]=s,s?this[d(809)+d(1140)]():this._handleOffLine()})}[t(648)](n){let s={vLlHa:function(d,f,h){return e[q(1502)](d,f,h)}};return new Promise(d=>{let f=q;s[f(1635)](setTimeout,d,this[f(1172)+f(1639)+"e"](n))})}[t(1703)+t(784)](n=1e3,s="",d=!1){let f=t;this[f(1275)]&&this["_destroy"+f(1552)+"t"](n,s,d)}_onTimeout(){let n=t,s=this["_endpoin"+n(473)]?.["getCurre"+n(1068)+"nt"]();this[n(1257)]("connect "+s+" timeout"),this["_disconn"+n(784)](1001,e[n(1509)],!0)}[t(1199)](n){let s=t,d=e[s(486)](Nt,n);this[s(1275)]&&e.ubFde(this[s(1275)].readyState,this[s(856)])&&(this[s(1275)]&&this[s(1275)][s(705)](d),this[s(1257)](e[s(1131)],n))}[t(1088)+t(620)+"rs"](){let n=t;if(e[n(1513)]===e.Toemy){if(!this[n(1275)])return;this[n(1275)][n(501)+"entListe"+n(714)](e[n(1218)],this[n(568)]),this[n(1275)][n(501)+n(607)+n(714)](e[n(635)],this._onClose),this[n(1275)][n(501)+n(607)+n(714)](e[n(597)],this[n(449)+"ge"]),this[n(1275)][n(501)+n(607)+n(714)](n(425),this[n(1601)])}else{let{pingInterval:s,pingFrequency:d}=this._options;if((e[n(1187)]("hi",_0x428692.data)&&e[n(847)](n(1645),d)||e[n(1192)](e[n(914)],d))&&(this["_clearPi"+n(1281)](),this[n(655)](n(1473)+"e_success",n(679)),this[n(1822)+"gTimeoutId"]=e[n(752)](_0x23279d,this[n(1776)][n(1222)](this),s)),e[n(1198)]("hi",_0xc7c26f[n(805)]))return;try{e[n(1159)](_0x4f6bac,this,_0x3957c8,[_0x8b9aa3,_0x19b070,_0x34fb31,_0x17eb17,_0x382c1a,_0x224194])}catch(f){let h=e.xDRxA(_0x157420,e[n(1246)],{message:f.message,code:_0x48f6ec[n(1699)+"ERROR"],error:f});this[n(416)+n(1888)+n(1508)](h)}}}_addWsListeners(){let n=t,s={xxYso:function(d,f,h){return e[q(1783)](d,f,h)},RPEIO:function(d,f,h){return e[q(946)](d,f,h)},JAroE:e.vXAVr,raEuZ:function(d,f,h){return e.LZHEV(d,f,h)},XjgiC:e.LJEQb,ZWgvf:function(d,f,h){return e[q(937)](d,f,h)}};if(e[n(1158)](e.wbxZe,e[n(1256)])){let d=e[n(1558)][n(554)]("|"),f=0;for(;;){switch(d[f++]){case"0":this._ws.addEventListener(n(425),this[n(1601)]);continue;case"1":this[n(1275)][n(1350)+"Listener"](e[n(635)],this[n(563)]);continue;case"2":this[n(1275)][n(1350)+n(953)](e.MzGNU,this[n(568)]);continue;case"3":this[n(1275)][n(1350)+n(953)](e[n(597)],this[n(449)+"ge"]);continue;case"4":if(!this._ws)return;continue}break}}else{if(this["_clearPi"+n(1281)](),this[n(1620)+n(662)](),this._removeWsListeners(),this[n(1271)+n(1261)](1e3,_0x2ac6cc),this[n(747)+n(691)]=!1,_0x1e755a&&this[n(1408)+n(482)]()&&!this[n(1525)+n(1063)]){if(this[n(1577)+n(473)]?.[n(670)+n(1659)+"es"]()){let f=this[n(1577)+"tManager"]?.[n(1358)+n(1068)+"nt"]();this[n(416)+n(1626)+"ent"](s.xxYso(_0x2cbf7f,n(955),{code:1006,reason:n(1279)+f+(n(601)+n(1752)+n(1437)+n(1693)),wasClean:!0}))}else{let f=this[n(402)][n(1861)+n(621)+n(695)](_0x25afb5,_0x25f140);this[n(416)+n(1626)+n(1508)](s[n(645)](_0x13e3e0,s[n(1232)],{code:_0x54a026,reason:_0x9512e9,wasClean:!0,willReconnect:f})),f&&this._connect()}return}this[n(1408)+n(482)]()||this[n(1525)+n(1063)]?this[n(416)+n(1626)+n(1508)](s[n(976)](_0x53e751,s[n(1232)],{code:_0x81c498,reason:s.XjgiC})):this[n(416)+n(1626)+"ent"](s[n(618)](_0x240583,s[n(1232)],{code:1006,reason:n(749)+n(737)+n(1075)+n(1926)})),this[n(1275)]=null,this[n(1577)+n(473)]?.[n(1395)+"pointConfig"](),this[n(683)+n(1890)]?.[n(1429)+n(1162)]()}}[t(1271)+t(1261)](n=1e3,s=""){let d=t;try{this._ws&&this[d(1275)].close(n,s)}catch{}}_destroyWebSocket(n=1e3,s="",d=!1){let f=t;if(this[f(1860)+f(1281)](),this[f(1620)+"mer"](),this[f(1088)+"sListeners"](),this[f(1271)+"nceClose"](1e3,s),this["_connect"+f(691)]=!1,d&&this["_navigat"+f(482)]()&&!this["_readyCl"+f(1063)]){if(this["_endpoin"+f(473)]?.["checkRea"+f(1659)+"es"]()){let w=this["_endpoin"+f(473)]?.[f(1358)+f(1068)+"nt"]();this["_dispatchCloseEv"+f(1508)](e[f(930)](ft,e[f(635)],{code:1006,reason:f(1279)+w+(f(601)+f(1752)+"tries re"+f(1693)),wasClean:!0}))}else{let w=this[f(402)]["reconnec"+f(621)+"ptor"](n,s);this[f(416)+f(1626)+f(1508)](e.KmpVt(ft,e[f(635)],{code:n,reason:s,wasClean:!0,willReconnect:w})),w&&this._connect()}return}this._navigatorOnline()||this._readyClosed?this[f(416)+"hCloseEv"+f(1508)](ft(e[f(635)],{code:n,reason:e[f(1114)]})):this[f(416)+f(1626)+f(1508)](e[f(930)](ft,f(955),{code:1006,reason:"going away, netw"+f(1075)+"ine"})),this[f(1275)]=null,this._endpointManager?.["resetEnd"+f(1669)+f(1634)](),this["_pingLos"+f(1890)]?.[f(1429)+f(1162)]()}[t(416)+"hOpenEvent"](n){let s=t;this.emit(s(591),n),this[s(764)]&&this.onopen(n)}_dispatchMessageEvent(n){let s=t;e[s(916)](s(1074),e[s(1745)])?(e.hmOKv(_0x44f5de,this[s(1822)+"gTimeoutId"]),e[s(815)](_0x4cd49d,this[s(879)+s(920)+s(1330)]),this[s(1822)+s(1237)+"Id"]=null,this[s(879)+s(920)+s(1330)]=null):(this[s(655)](e.DKeGb,n),this[s(1071)+"e"]&&this[s(1071)+"e"](n))}[t(416)+t(1561)+t(603)](n){let s=t;this[s(655)](e[s(1609)],n),this["onReceiv"+s(810)]&&this[s(1800)+"eAck"](n)}["_dispatc"+t(1888)+"ent"](n){let s=t;this.emit(e[s(1246)],n),this.onerror&&this[s(1295)](n)}[t(416)+t(1626)+t(1508)](n){let s=t,d={tsclp:function(f,h){return e[q(997)](f,h)},QEIGy:function(f,h){return e[q(1606)](f,h)}};if(e.FttAg(e.EmEWs,e.EmEWs))return!!(this["currentI"+s(1692)]>=this.endpoints[s(1900)]||VhURvx[s(1436)](this[s(736)+s(1692)],VhURvx[s(685)](this.endpoints[s(1900)],1))&&VhURvx[s(1436)](this["currentE"+s(1132)+s(987)+"t"],this[s(1855)+"es"]));this[s(655)](e.vXAVr,n),this.onclose&&this[s(1185)](n)}get[t(900)+"pe"](){let n=t;if(e[n(1174)](e[n(393)],e[n(393)]))return this[n(1275)]?this[n(1275)].binaryType:this[n(1236)+n(1709)];{let s=e.tiDbL[n(554)]("|"),d=0;for(;;){switch(s[d++]){case"0":this[n(1749)+n(734)+n(953)]();continue;case"1":this[n(822)+n(611)]?.[n(992)]();continue;case"2":this[n(1860)+"ngTimer"]();continue;case"3":this[n(1620)+n(662)]();continue;case"4":if(e[n(1036)](this[n(1275)][n(1260)+"te"],this[n(1385)])||e[n(1392)](this[n(1275)][n(1260)+"te"],this[n(1084)]))return void this[n(1257)]("close, w"+n(1830)+n(870));continue;case"5":if(!this[n(1275)])return void this._debug(e[n(1055)]);continue;case"6":this[n(934)+"WebSocket"](_0x2814c0,_0x5e7bb6);continue;case"7":this[n(1525)+n(1063)]=!0;continue}break}}}set[t(900)+"pe"](n){let s=t;this["_binaryT"+s(1709)]=n,this[s(1275)]&&(this[s(1275)][s(900)+"pe"]=n)}get retryCount(){let n=t;return this["_endpoin"+n(473)]?.[n(1358)+n(1068)+n(1846)+"ount"]()||0}get[t(1153)+t(1211)](){let n=t;if(e[n(872)](e[n(582)],e[n(531)]))return _0x329cee+=_0x373360&&_0x55e266[n(1007)+"th"]||0,_0x5a30e5;{let s=this[n(923)+n(1248)].reduce((d,f)=>(d+=f&&f[n(1007)+"th"]||0,d),0);return e[n(1109)](s,this._ws?this[n(1275)].bufferedAmount:0)}}get[t(1486)+"ns"](){let n=t;return this[n(1275)]?this[n(1275)][n(1486)+"ns"]:""}get[t(1030)](){let n=t;return e[n(804)](e[n(1118)],e[n(1118)])?this._ws?this[n(1275)].protocol:"":new _0x516a7b(_0x313e7c,_0x46f6ba,_0x42123c)}get[t(1260)+"te"](){let n=t;return this[n(1275)]?this[n(1275)][n(1260)+"te"]:this[n(402)]["automati"+n(1636)]?this[n(592)+"NG"]:this[n(1385)]}get url(){let n=t;return this._ws?this._ws[n(1086)]:this[n(1499)]}close(n=1e3,s){let d=t,f=(d(1450)+d(789))[d(554)]("|"),h=0;for(;;){switch(f[h++]){case"0":this._readyClosed=!0;continue;case"1":this[d(1620)+"mer"]();continue;case"2":if(e[d(1296)](this[d(1275)][d(1260)+"te"],this.CLOSED)||this._ws[d(1260)+"te"]===this[d(1084)])return void this._debug(e.fJEVR);continue;case"3":this[d(1749)+d(734)+"Listener"]();continue;case"4":this[d(822)+"ger"]?.closeDB();continue;case"5":this[d(934)+d(1552)+"t"](n,s);continue;case"6":if(!this[d(1275)])return void this[d(1257)](d(1551)+d(1529)+"ce not i"+d(1123)+"ed");continue;case"7":this[d(1860)+"ngTimer"]();continue}break}}async[t(705)](n,s){let d=t,f={XXUxE:function(h,w){return h&w},vdkbY:function(h,w){return e[q(1837)](h,w)},VXxbf:function(h,w){return e[q(1761)](h,w)},pOJzW:function(h,w){return e[q(1769)](h,w)},tmbsm:function(h,w){return h>>>w},ozfka:function(h,w){return e[q(521)](h,w)},sLkDk:function(h,w){return e.VnwpC(h,w)},tlqXP:e[d(1246)],UZVYg:function(h,w,v){return e[d(1037)](h,w,v)}};if(e[d(951)]===e.oDnWB)return _0x2d9b4e[d(1730)+d(451)](AYJoXU[d(1242)](255,this[d(1851)]),AYJoXU.XXUxE(AYJoXU[d(1005)](this[d(1851)],8),255),AYJoXU.XXUxE(AYJoXU[d(1070)](this[d(1851)],16),255),AYJoXU[d(754)](this[d(1851)],24),AYJoXU[d(1242)](255,this[d(1755)]),AYJoXU[d(1242)](AYJoXU[d(858)](this.high,8),255),AYJoXU[d(389)](AYJoXU.tmbsm(this.high,16),255),AYJoXU.sLkDk(this[d(1755)],24));{if(e.MhwAZ(null,n))throw new Error(e[d(1738)]);e[d(625)](e.tlaah,typeof n)&&(n=JSON[d(664)+"y"](n)),e[d(1613)](e.POrkd,typeof n)&&!e[d(698)](n,ArrayBuffer)&&!(n.buffer&&e[d(698)](n[d(1175)],ArrayBuffer))&&(n=JSON.stringify(n));let h=await e.UbamR($d,n),w=e.eIpnU(qh,n),{method:v=0,service:g=this[d(402)][d(661)],logID:T=this[d(402)][d(823)+d(1482)](),headers:P=this._options[d(1061)],payloadEncoding:N=this._options[d(1608)+"ncoding"],payloadType:B=this._options[d(1764)+"ype"],logIDNew:K=this[d(402)][d(1804)+"Config"][d(969)+d(1678)+d(1913)+"ew"]?i(this[d(402)][d(1804)+d(1019)][d(767)]):""}=s||{};if(!g)throw new Error(e[d(1666)]);let Y={SeqID:ce.fromNumber(this[d(1714)]++),LogID:ce[d(1841)+"er"](T),service:g,method:v,headers:P,payloadEncoding:e[d(984)](N,Object)?N.encoding?N.encoding:"":N,payloadType:e.YgmWZ(B,Object)?B[d(424)]?B[d(424)]:w:B||w,payload:h,LogIDNew:K},pe=e[d(1547)](Nt,Y);return this[d(1275)]&&e[d(1196)](this[d(1275)][d(1260)+"te"],this[d(856)])?(this._ws&&this[d(1275)][d(705)](pe),this[d(1257)](e[d(1293)],Y)):e[d(1759)](this[d(923)+d(1248)][d(1900)],this[d(402)][d(1217)+d(704)+"ength"])?e[d(886)](e[d(1100)],e[d(1100)])?(this[d(923)+d(1248)][d(1264)](pe),this[d(1257)](e[d(1918)],Y)):this[d(655)](AYJoXU[d(1413)],AYJoXU[d(1329)](_0x10a41a,AYJoXU[d(1413)],{message:this[d(1107)+d(575)+d(589)](_0x5184dc)})):(this[d(923)+d(1248)][d(456)](),this[d(923)+d(1248)][d(1264)](pe)),{seqID:this[d(1714)],logID:T,logIDNew:K}}}async[t(1861)+"t"](n){let s=t;if(e[s(1563)](e[s(1195)],e.tlFiS)){let{url:d}=e[s(553)](n,{}),f=Array[s(1733)](d)?d:e[s(894)]==typeof d?[d]:[];n&&Object[s(977)](this[s(402)],n),f&&f[s(1900)]?this[s(1577)+s(473)]=new Gd(f,this._options[s(1855)+"es"]):this[s(1577)+s(473)]?.[s(1395)+s(1669)+s(1634)](),this["_pingLos"+s(1890)]?.[s(1429)+"nter"](this._options[s(730)+s(845)]),this[s(1525)+s(1063)]=!1,this._ws&&e[s(489)](this._ws[s(1260)+"te"],this.CLOSED)?this[s(1703)+s(784)](1e3,e[s(758)],!0):(this._isInit=!0,this[s(747)]())}else{if(_0x7025e9<1||e[s(1784)](_0x5371bb,_0x56f363))return e[s(1522)](_0x528132,_0x9d85b9);e[s(1792)](e.hLVkJ(_0x6efeff,_0x11902d),_0x3765e6)&&(_0x5acbd6=e.uSkmu(_0x3baacd,_0xebe3d9),_0x27915c=0);let d=_0x19a457.call(_0x2d401d,_0x56ba0f,_0x520ffd+=_0x41452b);return e[s(572)](7,_0x1b340c)&&(_0x36241a=e[s(1171)](e[s(528)](7,_0x114f61),1)),d}}async[t(1333)](){let n=t;if(!this[n(747)+n(691)]){let s=e[n(1527)][n(554)]("|"),d=0;for(;;){switch(s[d++]){case"0":this[n(1525)+n(1063)]=!1;continue;case"1":this["_pingLos"+n(1890)]?.[n(1429)+n(1162)]();continue;case"2":this[n(747)]();continue;case"3":this[n(545)]=!0;continue;case"4":this[n(1577)+n(473)]?.[n(1395)+n(1669)+n(1634)]();continue}break}}}["addEvent"+t(953)](n,s){this.on(n,s)}["dispatch"+t(1471)](n){let s=t,{type:d}=n;this[s(655)](d,n)}[t(501)+t(607)+t(714)](n,s){this[t(616)](n,s)}pingOnce(){let n=t,s={vKmjb:function(d,f){return e[q(741)](d,f)},PpYiA:e[n(1315)],EpwgK:function(d,f,h){return d(f,h)},UolIC:e[n(1658)]};return new Promise((d,f)=>{let h=n,w={OQBOm:function(T,P){return s.vKmjb(T,P)},ovtmf:h(1473)+h(1790)+"s",UUAmi:s.PpYiA,HMzOg:h(1473)+h(835)+"t"};this["_clearPi"+h(1281)](),this["_pingPon"+h(1237)+"Id"]=s[h(1519)](setTimeout,this[h(1776)][h(1222)](this),this[h(402)][h(1663)+h(1325)]);let v=()=>{let T=h;w[T(1188)](d,"success"),this.off(w.ovtmf,v),this[T(616)](T(1473)+T(835)+"t",g)},g=()=>{let T=h;f(w[T(1083)]),this[T(616)](w.ovtmf,v),this[T(616)](w.HMzOg,g)};this.on(s[h(1747)],v),this.on(h(1473)+h(835)+"t",g),this[h(1776)]()})}}})(),Oe[M(1403)+M(1346)]=Te[M(1403)+"oseEvent"],Oe[M(1794)+M(1029)]=Te[M(1794)+M(1029)],Oe[M(1811)+"e"]=Te[M(1811)+"e"],Oe.Event=Te.Event,Oe.FWS=Te[M(396)],Oe[M(1564)+"MessageE"+M(1163)]=Te[M(1564)+M(1136)+M(1163)],Oe[M(1136)+M(1163)]=Te[M(1136)+M(1163)],Oe[M(840)+"t"]=Te[M(840)+"t"],Oe[M(1813)+M(811)]=Te[M(1813)+"tEvent"],Oe[M(819)+M(1346)]=Te[M(819)+M(1346)],Oe["createEr"+M(1029)]=Te[M(1169)+M(1029)],Oe[M(1126)+M(999)+"nt"]=Te[M(1126)+"ssageEvent"],Oe[M(970)+"enEvent"]=Te[M(970)+M(1345)],Oe[M(943)+M(595)+M(1163)]=Te[M(943)+M(595)+M(1163)],Oe["decodedF"+M(673)]=Te[M(1767)+M(673)],Oe["encodeFr"+M(443)]=Te[M(1149)+M(443)];for(mo in Te)["CustomCl"+M(1346),"CustomErrorEvent","ErrorCode","Event","FWS",M(1564)+M(1136)+"vent",M(1136)+M(1163),M(840)+"t",M(1813)+M(811),M(819)+M(1346),"createEr"+M(1029),M(1126)+"ssageEvent","createOp"+M(1345),M(943)+M(595)+M(1163),M(1767)+"rame",M(1149)+M(443)][M(1718)](mo)===-1&&(Oe[mo]=Te[mo]);var mo;Object[M(903)+"operty"](Oe,M(1556)+"le",{value:!0})});var jt=se((ST,Gf)=>{"use strict";var Hf=["nodebuffer","arraybuffer","fragments"],qf=typeof Blob<"u";qf&&Hf.push("blob");Gf.exports={BINARY_TYPES:Hf,CLOSE_TIMEOUT:3e4,EMPTY_BUFFER:Buffer.alloc(0),GUID:"258EAFA5-E914-47DA-95CA-C5AB0DC85B11",hasBlob:qf,kForOnEventAttribute:Symbol("kIsForOnEventAttribute"),kListener:Symbol("kListener"),kStatusCode:Symbol("status-code"),kWebSocket:Symbol("websocket"),NOOP:()=>{}}});var Mi=se((IT,So)=>{"use strict";var{EMPTY_BUFFER:vb}=jt(),Qc=Buffer[Symbol.species];function Sb(t,e){if(t.length===0)return vb;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 Qc(r.buffer,r.byteOffset,i):r}function jf(t,e,r,i,o){for(let c=0;c<o;c++)r[i+c]=t[c]^e[c&3]}function Wf(t,e){for(let r=0;r<t.length;r++)t[r]^=e[r&3]}function Ib(t){return t.length===t.buffer.byteLength?t.buffer:t.buffer.slice(t.byteOffset,t.byteOffset+t.length)}function ed(t){if(ed.readOnly=!0,Buffer.isBuffer(t))return t;let e;return t instanceof ArrayBuffer?e=new Qc(t):ArrayBuffer.isView(t)?e=new Qc(t.buffer,t.byteOffset,t.byteLength):(e=Buffer.from(t),ed.readOnly=!1),e}So.exports={concat:Sb,mask:jf,toArrayBuffer:Ib,toBuffer:ed,unmask:Wf};if(!process.env.WS_NO_BUFFER_UTIL)try{let t=de("bufferutil");So.exports.mask=function(e,r,i,o,c){c<48?jf(e,r,i,o,c):t.mask(e,r,i,o,c)},So.exports.unmask=function(e,r){e.length<32?Wf(e,r):t.unmask(e,r)}}catch{}});var Jf=se((AT,$f)=>{"use strict";var Kf=Symbol("kDone"),td=Symbol("kRun"),nd=class{constructor(e){this[Kf]=()=>{this.pending--,this[td]()},this.concurrency=e||1/0,this.jobs=[],this.pending=0}add(e){this.jobs.push(e),this[td]()}[td](){if(this.pending!==this.concurrency&&this.jobs.length){let e=this.jobs.shift();this.pending++,e(this[Kf])}}};$f.exports=nd});var Cr=se((TT,Xf)=>{"use strict";var Bi=de("zlib"),Vf=Mi(),Ab=Jf(),{kStatusCode:Yf}=jt(),Tb=Buffer[Symbol.species],Cb=Buffer.from([0,0,255,255]),Ao=Symbol("permessage-deflate"),Wt=Symbol("total-length"),Ar=Symbol("callback"),yn=Symbol("buffers"),Tr=Symbol("error"),Io,rd=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,!Io){let r=this._options.concurrencyLimit!==void 0?this._options.concurrencyLimit:10;Io=new Ab(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[Ar];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){Io.add(o=>{this._decompress(e,r,(c,l)=>{o(),i(c,l)})})}compress(e,r,i){Io.add(o=>{this._compress(e,r,(c,l)=>{o(),i(c,l)})})}_decompress(e,r,i){let o=this._isServer?"client":"server";if(!this._inflate){let c=`${o}_max_window_bits`,l=typeof this.params[c]!="number"?Bi.Z_DEFAULT_WINDOWBITS:this.params[c];this._inflate=Bi.createInflateRaw({...this._options.zlibInflateOptions,windowBits:l}),this._inflate[Ao]=this,this._inflate[Wt]=0,this._inflate[yn]=[],this._inflate.on("error",Db),this._inflate.on("data",Zf)}this._inflate[Ar]=i,this._inflate.write(e),r&&this._inflate.write(Cb),this._inflate.flush(()=>{let c=this._inflate[Tr];if(c){this._inflate.close(),this._inflate=null,i(c);return}let l=Vf.concat(this._inflate[yn],this._inflate[Wt]);this._inflate._readableState.endEmitted?(this._inflate.close(),this._inflate=null):(this._inflate[Wt]=0,this._inflate[yn]=[],r&&this.params[`${o}_no_context_takeover`]&&this._inflate.reset()),i(null,l)})}_compress(e,r,i){let o=this._isServer?"server":"client";if(!this._deflate){let c=`${o}_max_window_bits`,l=typeof this.params[c]!="number"?Bi.Z_DEFAULT_WINDOWBITS:this.params[c];this._deflate=Bi.createDeflateRaw({...this._options.zlibDeflateOptions,windowBits:l}),this._deflate[Wt]=0,this._deflate[yn]=[],this._deflate.on("data",Rb)}this._deflate[Ar]=i,this._deflate.write(e),this._deflate.flush(Bi.Z_SYNC_FLUSH,()=>{if(!this._deflate)return;let c=Vf.concat(this._deflate[yn],this._deflate[Wt]);r&&(c=new Tb(c.buffer,c.byteOffset,c.length-4)),this._deflate[Ar]=null,this._deflate[Wt]=0,this._deflate[yn]=[],r&&this.params[`${o}_no_context_takeover`]&&this._deflate.reset(),i(null,c)})}};Xf.exports=rd;function Rb(t){this[yn].push(t),this[Wt]+=t.length}function Zf(t){if(this[Wt]+=t.length,this[Ao]._maxPayload<1||this[Wt]<=this[Ao]._maxPayload){this[yn].push(t);return}this[Tr]=new RangeError("Max payload size exceeded"),this[Tr].code="WS_ERR_UNSUPPORTED_MESSAGE_LENGTH",this[Tr][Yf]=1009,this.removeListener("data",Zf),this.reset()}function Db(t){if(this[Ao]._inflate=null,this[Tr]){this[Ar](this[Tr]);return}t[Yf]=1007,this[Ar](t)}});var Rr=se((CT,To)=>{"use strict";var{isUtf8:Qf}=de("buffer"),{hasBlob:kb}=jt(),Pb=[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 Lb(t){return t>=1e3&&t<=1014&&t!==1004&&t!==1005&&t!==1006||t>=3e3&&t<=4999}function id(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 Ob(t){return kb&&typeof t=="object"&&typeof t.arrayBuffer=="function"&&typeof t.type=="string"&&typeof t.stream=="function"&&(t[Symbol.toStringTag]==="Blob"||t[Symbol.toStringTag]==="File")}To.exports={isBlob:Ob,isValidStatusCode:Lb,isValidUTF8:id,tokenChars:Pb};if(Qf)To.exports.isValidUTF8=function(t){return t.length<24?id(t):Qf(t)};else if(!process.env.WS_NO_UTF_8_VALIDATE)try{let t=de("utf-8-validate");To.exports.isValidUTF8=function(e){return e.length<32?id(e):t(e)}}catch{}});var dd=se((RT,ox)=>{"use strict";var{Writable:Nb}=de("stream"),ex=Cr(),{BINARY_TYPES:Mb,EMPTY_BUFFER:tx,kStatusCode:Bb,kWebSocket:zb}=jt(),{concat:sd,toArrayBuffer:Fb,unmask:Ub}=Mi(),{isValidStatusCode:Hb,isValidUTF8:nx}=Rr(),Co=Buffer[Symbol.species],dt=0,rx=1,ix=2,sx=3,od=4,ad=5,Ro=6,cd=class extends Nb{constructor(e={}){super(),this._allowSynchronousEvents=e.allowSynchronousEvents!==void 0?e.allowSynchronousEvents:!0,this._binaryType=e.binaryType||Mb[0],this._extensions=e.extensions||{},this._isServer=!!e.isServer,this._maxPayload=e.maxPayload|0,this._skipUTF8Validation=!!e.skipUTF8Validation,this[zb]=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=dt}_write(e,r,i){if(this._opcode===8&&this._state==dt)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 Co(i.buffer,i.byteOffset+e,i.length-e),new Co(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 Co(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 dt:this.getInfo(e);break;case rx:this.getPayloadLength16(e);break;case ix:this.getPayloadLength64(e);break;case sx:this.getMask();break;case od:this.getData(e);break;case ad:case Ro: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[ex.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=rx:this._payloadLength===127?this._state=ix: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=sx:this._state=od}getMask(){if(this._bufferedBytes<4){this._loop=!1;return}this._mask=this.consume(4),this._state=od}getData(e){let r=tx;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&&Ub(r,this._mask)}if(this._opcode>7){this.controlMessage(r,e);return}if(this._compressed){this._state=ad,this.decompress(r,e);return}r.length&&(this._messageLength=this._totalPayloadLength,this._fragments.push(r)),this.dataMessage(e)}decompress(e,r){this._extensions[ex.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 l=this.createError(RangeError,"Max payload size exceeded",!1,1009,"WS_ERR_UNSUPPORTED_MESSAGE_LENGTH");r(l);return}this._fragments.push(c)}this.dataMessage(r),this._state===dt&&this.startLoop(r)})}dataMessage(e){if(!this._fin){this._state=dt;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=sd(i,r):this._binaryType==="arraybuffer"?o=Fb(sd(i,r)):this._binaryType==="blob"?o=new Blob(i):o=i,this._allowSynchronousEvents?(this.emit("message",o,!0),this._state=dt):(this._state=Ro,setImmediate(()=>{this.emit("message",o,!0),this._state=dt,this.startLoop(e)}))}else{let o=sd(i,r);if(!this._skipUTF8Validation&&!nx(o)){let c=this.createError(Error,"invalid UTF-8 sequence",!0,1007,"WS_ERR_INVALID_UTF8");e(c);return}this._state===ad||this._allowSynchronousEvents?(this.emit("message",o,!1),this._state=dt):(this._state=Ro,setImmediate(()=>{this.emit("message",o,!1),this._state=dt,this.startLoop(e)}))}}controlMessage(e,r){if(this._opcode===8){if(e.length===0)this._loop=!1,this.emit("conclude",1005,tx),this.end();else{let i=e.readUInt16BE(0);if(!Hb(i)){let c=this.createError(RangeError,`invalid status code ${i}`,!0,1002,"WS_ERR_INVALID_CLOSE_CODE");r(c);return}let o=new Co(e.buffer,e.byteOffset+2,e.length-2);if(!this._skipUTF8Validation&&!nx(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=dt;return}this._allowSynchronousEvents?(this.emit(this._opcode===9?"ping":"pong",e),this._state=dt):(this._state=Ro,setImmediate(()=>{this.emit(this._opcode===9?"ping":"pong",e),this._state=dt,this.startLoop(r)}))}createError(e,r,i,o,c){this._loop=!1,this._errored=!0;let l=new e(i?`Invalid WebSocket frame: ${r}`:r);return Error.captureStackTrace(l,this.createError),l.code=c,l[Bb]=o,l}};ox.exports=cd});var fd=se((kT,dx)=>{"use strict";var{Duplex:DT}=de("stream"),{randomFillSync:qb}=de("crypto"),ax=Cr(),{EMPTY_BUFFER:Gb,kWebSocket:jb,NOOP:Wb}=jt(),{isBlob:Dr,isValidStatusCode:Kb}=Rr(),{mask:cx,toBuffer:Un}=Mi(),lt=Symbol("kByteLength"),$b=Buffer.alloc(4),Do=8*1024,Hn,kr=Do,yt=0,Jb=1,Vb=2,ld=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=yt,this.onerror=Wb,this[jb]=void 0}static frame(e,r){let i,o=!1,c=2,l=!1;r.mask&&(i=r.maskBuffer||$b,r.generateMask?r.generateMask(i):(kr===Do&&(Hn===void 0&&(Hn=Buffer.alloc(Do)),qb(Hn,0,Do),kr=0),i[0]=Hn[kr++],i[1]=Hn[kr++],i[2]=Hn[kr++],i[3]=Hn[kr++]),l=(i[0]|i[1]|i[2]|i[3])===0,c=6);let u;typeof e=="string"?(!r.mask||l)&&r[lt]!==void 0?u=r[lt]:(e=Buffer.from(e),u=e.length):(u=e.length,o=r.mask&&r.readOnly&&!l);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],l?[p,e]:o?(cx(e,i,p,c,u),[p]):(cx(e,i,e,0,u),[p,e])):[p,e]}close(e,r,i,o){let c;if(e===void 0)c=Gb;else{if(typeof e!="number"||!Kb(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 l={[lt]:c.length,fin:!0,generateMask:this._generateMask,mask:i,maskBuffer:this._maskBuffer,opcode:8,readOnly:!1,rsv1:!1};this._state!==yt?this.enqueue([this.dispatch,c,!1,l,o]):this.sendFrame(t.frame(c,l),o)}ping(e,r,i){let o,c;if(typeof e=="string"?(o=Buffer.byteLength(e),c=!1):Dr(e)?(o=e.size,c=!1):(e=Un(e),o=e.length,c=Un.readOnly),o>125)throw new RangeError("The data size must not be greater than 125 bytes");let l={[lt]:o,fin:!0,generateMask:this._generateMask,mask:r,maskBuffer:this._maskBuffer,opcode:9,readOnly:c,rsv1:!1};Dr(e)?this._state!==yt?this.enqueue([this.getBlobData,e,!1,l,i]):this.getBlobData(e,!1,l,i):this._state!==yt?this.enqueue([this.dispatch,e,!1,l,i]):this.sendFrame(t.frame(e,l),i)}pong(e,r,i){let o,c;if(typeof e=="string"?(o=Buffer.byteLength(e),c=!1):Dr(e)?(o=e.size,c=!1):(e=Un(e),o=e.length,c=Un.readOnly),o>125)throw new RangeError("The data size must not be greater than 125 bytes");let l={[lt]:o,fin:!0,generateMask:this._generateMask,mask:r,maskBuffer:this._maskBuffer,opcode:10,readOnly:c,rsv1:!1};Dr(e)?this._state!==yt?this.enqueue([this.getBlobData,e,!1,l,i]):this.getBlobData(e,!1,l,i):this._state!==yt?this.enqueue([this.dispatch,e,!1,l,i]):this.sendFrame(t.frame(e,l),i)}send(e,r,i){let o=this._extensions[ax.extensionName],c=r.binary?2:1,l=r.compress,u,x;typeof e=="string"?(u=Buffer.byteLength(e),x=!1):Dr(e)?(u=e.size,x=!1):(e=Un(e),u=e.length,x=Un.readOnly),this._firstFragment?(this._firstFragment=!1,l&&o&&o.params[o._isServer?"server_no_context_takeover":"client_no_context_takeover"]&&(l=u>=o._threshold),this._compress=l):(l=!1,c=0),r.fin&&(this._firstFragment=!0);let p={[lt]:u,fin:r.fin,generateMask:this._generateMask,mask:r.mask,maskBuffer:this._maskBuffer,opcode:c,readOnly:x,rsv1:l};Dr(e)?this._state!==yt?this.enqueue([this.getBlobData,e,this._compress,p,i]):this.getBlobData(e,this._compress,p,i):this._state!==yt?this.enqueue([this.dispatch,e,this._compress,p,i]):this.dispatch(e,this._compress,p,i)}getBlobData(e,r,i,o){this._bufferedBytes+=i[lt],this._state=Vb,e.arrayBuffer().then(c=>{if(this._socket.destroyed){let u=new Error("The socket was closed while the blob was being read");process.nextTick(ud,this,u,o);return}this._bufferedBytes-=i[lt];let l=Un(c);r?this.dispatch(l,r,i,o):(this._state=yt,this.sendFrame(t.frame(l,i),o),this.dequeue())}).catch(c=>{process.nextTick(Yb,this,c,o)})}dispatch(e,r,i,o){if(!r){this.sendFrame(t.frame(e,i),o);return}let c=this._extensions[ax.extensionName];this._bufferedBytes+=i[lt],this._state=Jb,c.compress(e,i.fin,(l,u)=>{if(this._socket.destroyed){let x=new Error("The socket was closed while data was being compressed");ud(this,x,o);return}this._bufferedBytes-=i[lt],this._state=yt,i.readOnly=!1,this.sendFrame(t.frame(u,i),o),this.dequeue()})}dequeue(){for(;this._state===yt&&this._queue.length;){let e=this._queue.shift();this._bufferedBytes-=e[3][lt],Reflect.apply(e[0],this,e.slice(1))}}enqueue(e){this._bufferedBytes+=e[3][lt],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)}};dx.exports=ld;function ud(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 Yb(t,e,r){ud(t,e,r),t.onerror(e)}});var _x=se((PT,mx)=>{"use strict";var{kForOnEventAttribute:zi,kListener:xd}=jt(),lx=Symbol("kCode"),ux=Symbol("kData"),fx=Symbol("kError"),xx=Symbol("kMessage"),hx=Symbol("kReason"),Pr=Symbol("kTarget"),px=Symbol("kType"),gx=Symbol("kWasClean"),Kt=class{constructor(e){this[Pr]=null,this[px]=e}get target(){return this[Pr]}get type(){return this[px]}};Object.defineProperty(Kt.prototype,"target",{enumerable:!0});Object.defineProperty(Kt.prototype,"type",{enumerable:!0});var qn=class extends Kt{constructor(e,r={}){super(e),this[lx]=r.code===void 0?0:r.code,this[hx]=r.reason===void 0?"":r.reason,this[gx]=r.wasClean===void 0?!1:r.wasClean}get code(){return this[lx]}get reason(){return this[hx]}get wasClean(){return this[gx]}};Object.defineProperty(qn.prototype,"code",{enumerable:!0});Object.defineProperty(qn.prototype,"reason",{enumerable:!0});Object.defineProperty(qn.prototype,"wasClean",{enumerable:!0});var Lr=class extends Kt{constructor(e,r={}){super(e),this[fx]=r.error===void 0?null:r.error,this[xx]=r.message===void 0?"":r.message}get error(){return this[fx]}get message(){return this[xx]}};Object.defineProperty(Lr.prototype,"error",{enumerable:!0});Object.defineProperty(Lr.prototype,"message",{enumerable:!0});var Fi=class extends Kt{constructor(e,r={}){super(e),this[ux]=r.data===void 0?null:r.data}get data(){return this[ux]}};Object.defineProperty(Fi.prototype,"data",{enumerable:!0});var Zb={addEventListener(t,e,r={}){for(let o of this.listeners(t))if(!r[zi]&&o[xd]===e&&!o[zi])return;let i;if(t==="message")i=function(c,l){let u=new Fi("message",{data:l?c:c.toString()});u[Pr]=this,ko(e,this,u)};else if(t==="close")i=function(c,l){let u=new qn("close",{code:c,reason:l.toString(),wasClean:this._closeFrameReceived&&this._closeFrameSent});u[Pr]=this,ko(e,this,u)};else if(t==="error")i=function(c){let l=new Lr("error",{error:c,message:c.message});l[Pr]=this,ko(e,this,l)};else if(t==="open")i=function(){let c=new Kt("open");c[Pr]=this,ko(e,this,c)};else return;i[zi]=!!r[zi],i[xd]=e,r.once?this.once(t,i):this.on(t,i)},removeEventListener(t,e){for(let r of this.listeners(t))if(r[xd]===e&&!r[zi]){this.removeListener(t,r);break}}};mx.exports={CloseEvent:qn,ErrorEvent:Lr,Event:Kt,EventTarget:Zb,MessageEvent:Fi};function ko(t,e,r){typeof t=="object"&&t.handleEvent?t.handleEvent.call(t,r):t.call(e,r)}});var Po=se((LT,yx)=>{"use strict";var{tokenChars:Ui}=Rr();function Ot(t,e,r){t[e]===void 0?t[e]=[r]:t[e].push(r)}function Xb(t){let e=Object.create(null),r=Object.create(null),i=!1,o=!1,c=!1,l,u,x=-1,p=-1,m=-1,b=0;for(;b<t.length;b++)if(p=t.charCodeAt(b),l===void 0)if(m===-1&&Ui[p]===1)x===-1&&(x=b);else if(b!==0&&(p===32||p===9))m===-1&&x!==-1&&(m=b);else if(p===59||p===44){if(x===-1)throw new SyntaxError(`Unexpected character at index ${b}`);m===-1&&(m=b);let y=t.slice(x,m);p===44?(Ot(e,y,r),r=Object.create(null)):l=y,x=m=-1}else throw new SyntaxError(`Unexpected character at index ${b}`);else if(u===void 0)if(m===-1&&Ui[p]===1)x===-1&&(x=b);else if(p===32||p===9)m===-1&&x!==-1&&(m=b);else if(p===59||p===44){if(x===-1)throw new SyntaxError(`Unexpected character at index ${b}`);m===-1&&(m=b),Ot(r,t.slice(x,m),!0),p===44&&(Ot(e,l,r),r=Object.create(null),l=void 0),x=m=-1}else if(p===61&&x!==-1&&m===-1)u=t.slice(x,b),x=m=-1;else throw new SyntaxError(`Unexpected character at index ${b}`);else if(o){if(Ui[p]!==1)throw new SyntaxError(`Unexpected character at index ${b}`);x===-1?x=b:i||(i=!0),o=!1}else if(c)if(Ui[p]===1)x===-1&&(x=b);else if(p===34&&x!==-1)c=!1,m=b;else if(p===92)o=!0;else throw new SyntaxError(`Unexpected character at index ${b}`);else if(p===34&&t.charCodeAt(b-1)===61)c=!0;else if(m===-1&&Ui[p]===1)x===-1&&(x=b);else if(x!==-1&&(p===32||p===9))m===-1&&(m=b);else if(p===59||p===44){if(x===-1)throw new SyntaxError(`Unexpected character at index ${b}`);m===-1&&(m=b);let y=t.slice(x,m);i&&(y=y.replace(/\\/g,""),i=!1),Ot(r,u,y),p===44&&(Ot(e,l,r),r=Object.create(null),l=void 0),u=void 0,x=m=-1}else throw new SyntaxError(`Unexpected character at index ${b}`);if(x===-1||c||p===32||p===9)throw new SyntaxError("Unexpected end of input");m===-1&&(m=b);let I=t.slice(x,m);return l===void 0?Ot(e,I,r):(u===void 0?Ot(r,I,!0):i?Ot(r,u,I.replace(/\\/g,"")):Ot(r,u,I),Ot(e,l,r)),e}function Qb(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(l=>l===!0?o:`${o}=${l}`).join("; ")})).join("; ")).join(", ")}).join(", ")}yx.exports={format:Qb,parse:Xb}});var Mo=se((MT,Px)=>{"use strict";var eE=de("events"),tE=de("https"),nE=de("http"),vx=de("net"),rE=de("tls"),{randomBytes:iE,createHash:sE}=de("crypto"),{Duplex:OT,Readable:NT}=de("stream"),{URL:hd}=de("url"),bn=Cr(),oE=dd(),aE=fd(),{isBlob:cE}=Rr(),{BINARY_TYPES:bx,CLOSE_TIMEOUT:dE,EMPTY_BUFFER:Lo,GUID:lE,kForOnEventAttribute:pd,kListener:uE,kStatusCode:fE,kWebSocket:Ue,NOOP:Sx}=jt(),{EventTarget:{addEventListener:xE,removeEventListener:hE}}=_x(),{format:pE,parse:gE}=Po(),{toBuffer:mE}=Mi(),Ix=Symbol("kAborted"),gd=[8,13],$t=["CONNECTING","OPEN","CLOSING","CLOSED"],wE=/^[!#$%&'*+\-.0-9A-Z^_`|a-z~]+$/,xe=class t extends eE{constructor(e,r,i){super(),this._binaryType=bx[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?(i=r,r=[]):r=[r]),Ax(this,e,r,i)):(this._autoPong=i.autoPong,this._closeTimeout=i.closeTimeout,this._isServer=!0)}get binaryType(){return this._binaryType}set binaryType(e){bx.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 oE({allowSynchronousEvents:i.allowSynchronousEvents,binaryType:this.binaryType,extensions:this._extensions,isServer:this._isServer,maxPayload:i.maxPayload,skipUTF8Validation:i.skipUTF8Validation}),c=new aE(e,this._extensions,i.generateMask);this._receiver=o,this._sender=c,this._socket=e,o[Ue]=this,c[Ue]=this,e[Ue]=this,o.on("conclude",bE),o.on("drain",EE),o.on("error",vE),o.on("message",SE),o.on("ping",IE),o.on("pong",AE),c.onerror=TE,e.setTimeout&&e.setTimeout(0),e.setNoDelay&&e.setNoDelay(),r.length>0&&e.unshift(r),e.on("close",Rx),e.on("data",No),e.on("end",Dx),e.on("error",kx),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[bn.extensionName]&&this._extensions[bn.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){it(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())}),Cx(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){md(this,e,i);return}r===void 0&&(r=!this._isServer),this._sender.ping(e||Lo,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){md(this,e,i);return}r===void 0&&(r=!this._isServer),this._sender.pong(e||Lo,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){md(this,e,i);return}let o={binary:typeof e!="string",mask:!this._isServer,compress:!0,fin:!0,...r};this._extensions[bn.extensionName]||(o.compress=!1),this._sender.send(e||Lo,o,i)}terminate(){if(this.readyState!==t.CLOSED){if(this.readyState===t.CONNECTING){it(this,this._req,"WebSocket was closed before the connection was established");return}this._socket&&(this._readyState=t.CLOSING,this._socket.destroy())}}};Object.defineProperty(xe,"CONNECTING",{enumerable:!0,value:$t.indexOf("CONNECTING")});Object.defineProperty(xe.prototype,"CONNECTING",{enumerable:!0,value:$t.indexOf("CONNECTING")});Object.defineProperty(xe,"OPEN",{enumerable:!0,value:$t.indexOf("OPEN")});Object.defineProperty(xe.prototype,"OPEN",{enumerable:!0,value:$t.indexOf("OPEN")});Object.defineProperty(xe,"CLOSING",{enumerable:!0,value:$t.indexOf("CLOSING")});Object.defineProperty(xe.prototype,"CLOSING",{enumerable:!0,value:$t.indexOf("CLOSING")});Object.defineProperty(xe,"CLOSED",{enumerable:!0,value:$t.indexOf("CLOSED")});Object.defineProperty(xe.prototype,"CLOSED",{enumerable:!0,value:$t.indexOf("CLOSED")});["binaryType","bufferedAmount","extensions","isPaused","protocol","readyState","url"].forEach(t=>{Object.defineProperty(xe.prototype,t,{enumerable:!0})});["open","error","close","message"].forEach(t=>{Object.defineProperty(xe.prototype,`on${t}`,{enumerable:!0,get(){for(let e of this.listeners(t))if(e[pd])return e[uE];return null},set(e){for(let r of this.listeners(t))if(r[pd]){this.removeListener(t,r);break}typeof e=="function"&&this.addEventListener(t,e,{[pd]:!0})}})});xe.prototype.addEventListener=xE;xe.prototype.removeEventListener=hE;Px.exports=xe;function Ax(t,e,r,i){let o={allowSynchronousEvents:!0,autoPong:!0,closeTimeout:dE,protocolVersion:gd[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,!gd.includes(o.protocolVersion))throw new RangeError(`Unsupported protocol version: ${o.protocolVersion} (supported versions: ${gd.join(", ")})`);let c;if(e instanceof hd)c=e;else try{c=new hd(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 l=c.protocol==="wss:",u=c.protocol==="ws+unix:",x;if(c.protocol!=="ws:"&&!l&&!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;Oo(t,S);return}let p=l?443:80,m=iE(16).toString("base64"),b=l?tE.request:nE.request,I=new Set,y;if(o.createConnection=o.createConnection||(l?yE:_E),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":m,Connection:"Upgrade",Upgrade:"websocket"},o.path=c.pathname+c.search,o.timeout=o.handshakeTimeout,o.perMessageDeflate&&(y=new bn({...o.perMessageDeflate,isServer:!1,maxPayload:o.maxPayload}),o.headers["Sec-WebSocket-Extensions"]=pE({[bn.extensionName]:y.offer()})),r.length){for(let S of r){if(typeof S!="string"||!wE.test(S)||I.has(S))throw new SyntaxError("An invalid or duplicated subprotocol was specified");I.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 E;if(o.followRedirects){if(t._redirects===0){t._originalIpc=u,t._originalSecure=l,t._originalHostOrSocketPath=u?o.socketPath:c.host;let S=i&&i.headers;if(i={...i,headers:{}},S)for(let[A,D]of Object.entries(S))i.headers[A.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&&!l)&&(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")),E=t._req=b(o),t._redirects&&t.emit("redirect",t.url,E)}else E=t._req=b(o);o.timeout&&E.on("timeout",()=>{it(t,E,"Opening handshake has timed out")}),E.on("error",S=>{E===null||E[Ix]||(E=t._req=null,Oo(t,S))}),E.on("response",S=>{let A=S.headers.location,D=S.statusCode;if(A&&o.followRedirects&&D>=300&&D<400){if(++t._redirects>o.maxRedirects){it(t,E,"Maximum redirects exceeded");return}E.abort();let L;try{L=new hd(A,e)}catch{let R=new SyntaxError(`Invalid URL: ${A}`);Oo(t,R);return}Ax(t,L,r,i)}else t.emit("unexpected-response",E,S)||it(t,E,`Unexpected server response: ${S.statusCode}`)}),E.on("upgrade",(S,A,D)=>{if(t.emit("upgrade",S),t.readyState!==xe.CONNECTING)return;E=t._req=null;let L=S.headers.upgrade;if(L===void 0||L.toLowerCase()!=="websocket"){it(t,A,"Invalid Upgrade header");return}let _=sE("sha1").update(m+lE).digest("base64");if(S.headers["sec-websocket-accept"]!==_){it(t,A,"Invalid Sec-WebSocket-Accept header");return}let R=S.headers["sec-websocket-protocol"],k;if(R!==void 0?I.size?I.has(R)||(k="Server sent an invalid subprotocol"):k="Server sent a subprotocol but none was requested":I.size&&(k="Server sent no subprotocol"),k){it(t,A,k);return}R&&(t._protocol=R);let z=S.headers["sec-websocket-extensions"];if(z!==void 0){if(!y){it(t,A,"Server sent a Sec-WebSocket-Extensions header but no extension was requested");return}let F;try{F=gE(z)}catch{it(t,A,"Invalid Sec-WebSocket-Extensions header");return}let V=Object.keys(F);if(V.length!==1||V[0]!==bn.extensionName){it(t,A,"Server indicated an extension that was not requested");return}try{y.accept(F[bn.extensionName])}catch{it(t,A,"Invalid Sec-WebSocket-Extensions header");return}t._extensions[bn.extensionName]=y}t.setSocket(A,D,{allowSynchronousEvents:o.allowSynchronousEvents,generateMask:o.generateMask,maxPayload:o.maxPayload,skipUTF8Validation:o.skipUTF8Validation})}),o.finishRequest?o.finishRequest(E,t):E.end()}function Oo(t,e){t._readyState=xe.CLOSING,t._errorEmitted=!0,t.emit("error",e),t.emitClose()}function _E(t){return t.path=t.socketPath,vx.connect(t)}function yE(t){return t.path=void 0,!t.servername&&t.servername!==""&&(t.servername=vx.isIP(t.host)?"":t.host),rE.connect(t)}function it(t,e,r){t._readyState=xe.CLOSING;let i=new Error(r);Error.captureStackTrace(i,it),e.setHeader?(e[Ix]=!0,e.abort(),e.socket&&!e.socket.destroyed&&e.socket.destroy(),process.nextTick(Oo,t,i)):(e.destroy(i),e.once("error",t.emit.bind(t,"error")),e.once("close",t.emitClose.bind(t)))}function md(t,e,r){if(e){let i=cE(e)?e.size:mE(e).length;t._socket?t._sender._bufferedBytes+=i:t._bufferedAmount+=i}if(r){let i=new Error(`WebSocket is not open: readyState ${t.readyState} (${$t[t.readyState]})`);process.nextTick(r,i)}}function bE(t,e){let r=this[Ue];r._closeFrameReceived=!0,r._closeMessage=e,r._closeCode=t,r._socket[Ue]!==void 0&&(r._socket.removeListener("data",No),process.nextTick(Tx,r._socket),t===1005?r.close():r.close(t,e))}function EE(){let t=this[Ue];t.isPaused||t._socket.resume()}function vE(t){let e=this[Ue];e._socket[Ue]!==void 0&&(e._socket.removeListener("data",No),process.nextTick(Tx,e._socket),e.close(t[fE])),e._errorEmitted||(e._errorEmitted=!0,e.emit("error",t))}function Ex(){this[Ue].emitClose()}function SE(t,e){this[Ue].emit("message",t,e)}function IE(t){let e=this[Ue];e._autoPong&&e.pong(t,!this._isServer,Sx),e.emit("ping",t)}function AE(t){this[Ue].emit("pong",t)}function Tx(t){t.resume()}function TE(t){let e=this[Ue];e.readyState!==xe.CLOSED&&(e.readyState===xe.OPEN&&(e._readyState=xe.CLOSING,Cx(e)),this._socket.end(),e._errorEmitted||(e._errorEmitted=!0,e.emit("error",t)))}function Cx(t){t._closeTimer=setTimeout(t._socket.destroy.bind(t._socket),t._closeTimeout)}function Rx(){let t=this[Ue];if(this.removeListener("close",Rx),this.removeListener("data",No),this.removeListener("end",Dx),t._readyState=xe.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[Ue]=void 0,clearTimeout(t._closeTimer),t._receiver._writableState.finished||t._receiver._writableState.errorEmitted?t.emitClose():(t._receiver.on("error",Ex),t._receiver.on("finish",Ex))}function No(t){this[Ue]._receiver.write(t)||this.pause()}function Dx(){let t=this[Ue];t._readyState=xe.CLOSING,t._receiver.end(),this.end()}function kx(){let t=this[Ue];this.removeListener("error",kx),this.on("error",Sx),t&&(t._readyState=xe.CLOSING,this.destroy())}});var Mx=se((zT,Nx)=>{"use strict";var BT=Mo(),{Duplex:CE}=de("stream");function Lx(t){t.emit("close")}function RE(){!this.destroyed&&this._writableState.finished&&this.destroy()}function Ox(t){this.removeListener("error",Ox),this.destroy(),this.listenerCount("error")===0&&this.emit("error",t)}function DE(t,e){let r=!0,i=new CE({...e,autoDestroy:!1,emitClose:!1,objectMode:!1,writableObjectMode:!1});return t.on("message",function(c,l){let u=!l&&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(Lx,i);return}let l=!1;t.once("error",function(x){l=!0,c(x)}),t.once("close",function(){l||c(o),process.nextTick(Lx,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,l){if(t.readyState===t.CONNECTING){t.once("open",function(){i._write(o,c,l)});return}t.send(o,l)},i.on("end",RE),i.on("error",Ox),i}Nx.exports=DE});var wd=se((FT,Bx)=>{"use strict";var{tokenChars:kE}=Rr();function PE(t){let e=new Set,r=-1,i=-1,o=0;for(o;o<t.length;o++){let l=t.charCodeAt(o);if(i===-1&&kE[l]===1)r===-1&&(r=o);else if(o!==0&&(l===32||l===9))i===-1&&r!==-1&&(i=o);else if(l===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}Bx.exports={parse:PE}});var jx=se((HT,Gx)=>{"use strict";var LE=de("events"),Bo=de("http"),{Duplex:UT}=de("stream"),{createHash:OE}=de("crypto"),zx=Po(),Gn=Cr(),NE=wd(),ME=Mo(),{CLOSE_TIMEOUT:BE,GUID:zE,kWebSocket:FE}=jt(),UE=/^[+/0-9A-Za-z]{22}==$/,Fx=0,Ux=1,qx=2,_d=class extends LE{constructor(e,r){if(super(),e={allowSynchronousEvents:!0,autoPong:!0,maxPayload:100*1024*1024,skipUTF8Validation:!1,perMessageDeflate:!1,handleProtocols:null,clientTracking:!0,closeTimeout:BE,verifyClient:null,noServer:!1,backlog:null,server:null,host:null,path:null,port:null,WebSocket:ME,...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=Bo.createServer((i,o)=>{let c=Bo.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=HE(this._server,{listening:this.emit.bind(this,"listening"),error:this.emit.bind(this,"error"),upgrade:(o,c,l)=>{this.handleUpgrade(o,c,l,i)}})}e.perMessageDeflate===!0&&(e.perMessageDeflate={}),e.clientTracking&&(this.clients=new Set,this._shouldEmitClose=!1),this.options=e,this._state=Fx}address(){if(this.options.noServer)throw new Error('The server is operating in "noServer" mode');return this._server?this._server.address():null}close(e){if(this._state===qx){e&&this.once("close",()=>{e(new Error("The server is not running"))}),process.nextTick(Hi,this);return}if(e&&this.once("close",e),this._state!==Ux)if(this._state=Ux,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(Hi,this):process.nextTick(Hi,this);else{let r=this._server;this._removeListeners(),this._removeListeners=this._server=null,r.close(()=>{Hi(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",Hx);let c=e.headers["sec-websocket-key"],l=e.headers.upgrade,u=+e.headers["sec-websocket-version"];if(e.method!=="GET"){jn(this,e,r,405,"Invalid HTTP method");return}if(l===void 0||l.toLowerCase()!=="websocket"){jn(this,e,r,400,"Invalid Upgrade header");return}if(c===void 0||!UE.test(c)){jn(this,e,r,400,"Missing or invalid Sec-WebSocket-Key header");return}if(u!==13&&u!==8){jn(this,e,r,400,"Missing or invalid Sec-WebSocket-Version header",{"Sec-WebSocket-Version":"13, 8"});return}if(!this.shouldHandle(e)){qi(r,400);return}let x=e.headers["sec-websocket-protocol"],p=new Set;if(x!==void 0)try{p=NE.parse(x)}catch{jn(this,e,r,400,"Invalid Sec-WebSocket-Protocol header");return}let m=e.headers["sec-websocket-extensions"],b={};if(this.options.perMessageDeflate&&m!==void 0){let I=new Gn({...this.options.perMessageDeflate,isServer:!0,maxPayload:this.options.maxPayload});try{let y=zx.parse(m);y[Gn.extensionName]&&(I.accept(y[Gn.extensionName]),b[Gn.extensionName]=I)}catch{jn(this,e,r,400,"Invalid or unacceptable Sec-WebSocket-Extensions header");return}}if(this.options.verifyClient){let I={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(I,(y,E,S,A)=>{if(!y)return qi(r,E||401,S,A);this.completeUpgrade(b,c,p,e,r,i,o)});return}if(!this.options.verifyClient(I))return qi(r,401)}this.completeUpgrade(b,c,p,e,r,i,o)}completeUpgrade(e,r,i,o,c,l,u){if(!c.readable||!c.writable)return c.destroy();if(c[FE])throw new Error("server.handleUpgrade() was called more than once with the same socket, possibly due to a misconfiguration");if(this._state>Fx)return qi(c,503);let p=["HTTP/1.1 101 Switching Protocols","Upgrade: websocket","Connection: Upgrade",`Sec-WebSocket-Accept: ${OE("sha1").update(r+zE).digest("base64")}`],m=new this.options.WebSocket(null,void 0,this.options);if(i.size){let b=this.options.handleProtocols?this.options.handleProtocols(i,o):i.values().next().value;b&&(p.push(`Sec-WebSocket-Protocol: ${b}`),m._protocol=b)}if(e[Gn.extensionName]){let b=e[Gn.extensionName].params,I=zx.format({[Gn.extensionName]:[b]});p.push(`Sec-WebSocket-Extensions: ${I}`),m._extensions=e}this.emit("headers",p,o),c.write(p.concat(`\r
|
|
8
|
+
var Ap=Object.create;var ga=Object.defineProperty;var Tp=Object.getOwnPropertyDescriptor;var Cp=Object.getOwnPropertyNames;var Dp=Object.getPrototypeOf,Rp=Object.prototype.hasOwnProperty;var fe=(t=>typeof require<"u"?require:typeof Proxy<"u"?new Proxy(t,{get:(e,n)=>(typeof require<"u"?require:e)[n]}):t)(function(t){if(typeof require<"u")return require.apply(this,arguments);throw Error('Dynamic require of "'+t+'" is not supported')});var Ye=(t,e)=>()=>(t&&(e=t(t=0)),e);var ae=(t,e)=>()=>(e||t((e={exports:{}}).exports,e),e.exports),ma=(t,e)=>{for(var n in e)ga(t,n,{get:e[n],enumerable:!0})},kp=(t,e,n,i)=>{if(e&&typeof e=="object"||typeof e=="function")for(let o of Cp(e))!Rp.call(t,o)&&o!==n&&ga(t,o,{get:()=>e[o],enumerable:!(i=Tp(e,o))||i.enumerable});return t};var Tt=(t,e,n)=>(n=t!=null?Ap(Dp(t)):{},kp(e||!t||!t.__esModule?ga(n,"default",{value:t,enumerable:!0}):n,t));function qt(t,e){let n=process.env[t];if(!n)return e;let i=Number(n);return Number.isFinite(i)&&i>0?i:e}var ts=Ye(()=>{"use strict"});import{createWriteStream as Lp,mkdirSync as Pp,readdirSync as Op,unlinkSync as Np}from"node:fs";import{join as t0}from"node:path";function Dn(t){let e=n=>String(n).padStart(2,"0");return`${t.getFullYear()}-${e(t.getMonth()+1)}-${e(t.getDate())}`}function tr(t,e){return`${t}-${e}.log`}function wa(t,e){let n=t.match(/^(.+)-(\d{4}-\d{2}-\d{2})\.log$/);return!n||n[1]!==e?null:n[2]??null}function Mp(t,e,n){let i=c=>{let[l,f,x]=c.split("-").map(Number);return Date.UTC(l??0,(f??1)-1,x??1)};return Math.floor((i(e)-i(t))/864e5)>n}function ns(t,e,n,i){let o;try{o=Op(t)}catch{return}for(let c of o){let l=wa(c,e);if(l&&Mp(l,n,i))try{Np(t0(t,c))}catch{}}}var Jr,_a=Ye(()=>{"use strict";Jr=class{constructor(e,n,i){this.dir=e;this.prefix=n;this.opts=i;this.clock=i.clock??(()=>Dn(new Date))}dir;prefix;opts;currentDate;stream;clock;write(e){let n=this.clock();n!==this.currentDate&&this.rotate(n),this.stream?.write(e)}rotate(e){this.stream?.end();try{Pp(this.dir,{recursive:!0});let n=Lp(t0(this.dir,tr(this.prefix,e)),{flags:"a"});n.on("error",i=>process.stderr.write(`[log-sink] stream error: ${String(i)}
|
|
9
|
+
`)),this.stream=n}catch(n){process.stderr.write(`[log-sink] rotate failed: ${String(n)}
|
|
10
|
+
`),this.stream=void 0;return}this.currentDate!==void 0&&ns(this.dir,this.prefix,e,this.opts.retentionDays),this.currentDate=e}close(){this.stream?.end(),this.stream=void 0,this.currentDate=void 0}}});import{appendFileSync as Bp,mkdirSync as zp}from"node:fs";import{join as Fp}from"node:path";function r0(t){let e=t.retentionDays??Hp,n=t.clock??(()=>Dn(new Date));is={bridgeSink:new Jr(t.bridgeLogsDir,"bridge",{retentionDays:e,clock:n}),agentSinks:new Map,makeAgentSink:o=>new Jr(t.agentLogsDir(o),"agent",{retentionDays:e,clock:n})};let i=n();ns(t.bridgeLogsDir,"bridge",i,e);for(let o of t.listAgentIds?.()??[])ns(t.agentLogsDir(o),"agent",i,e)}function Gp(t,e){let n=t.agentSinks.get(e);return n||(n=t.makeAgentSink(e),t.agentSinks.set(e,n)),n}function i0(t){ya=t}function s0(t){return nr[ya]<=nr[t]}function o0(t,e){let n=nr[t];return n===void 0?!0:n>=nr[e]}function ss(t){n0={...t}}function a0(t){let e=(f,x=2)=>String(f).padStart(x,"0"),n=-t.getTimezoneOffset(),i=n>=0?"+":"-",o=Math.abs(n),c=e(Math.floor(o/60)),l=e(o%60);return`${Dn(t)}T${e(t.getHours())}:${e(t.getMinutes())}:${e(t.getSeconds())}.${e(t.getMilliseconds(),3)}${i}${c}:${l}`}function Vr(t,e,n,i,o){try{let c=`${JSON.stringify({ts:a0(new Date),level:e,module:n,msg:i,...o})}
|
|
11
|
+
`;zp(t,{recursive:!0}),Bp(Fp(t,tr("bridge",Dn(new Date))),c)}catch{}}function jp(t,e){if(t)return t;let n=e?.agentId;return typeof n=="string"&&n.length>0?n:void 0}function rs(t,e,n,i,o){if(nr[t]<nr[ya])return;let c=`${JSON.stringify({ts:a0(new Date),level:t,module:e,msg:n,...n0,...i})}
|
|
12
|
+
`;if(is){let l=jp(o,i),f=l?Gp(is,l):is.bridgeSink;try{f.write(c)}catch{process.stderr.write(c)}return}t==="error"||t==="warn"?qp.write(c):Up.write(c)}function H(t,e){return{debug:(n,i)=>rs("debug",t,n,i,e),info:(n,i)=>rs("info",t,n,i,e),warn:(n,i)=>rs("warn",t,n,i,e),error:(n,i)=>rs("error",t,n,i,e),child:n=>H(`${t}.${n}`,e),forAgent:n=>H(t,n)}}var nr,ya,Up,qp,n0,Hp,is,re=Ye(()=>{"use strict";ts();_a();nr={debug:10,info:20,warn:30,error:40},ya=(()=>{let t=process.env.COZE_BRIDGE_LOG_LEVEL;return t==="debug"||t==="info"||t==="warn"||t==="error"?t:"info"})(),Up=process.stdout,qp=process.stderr,n0={},Hp=qt("COZE_BRIDGE_LOG_RETENTION_DAYS",30),is=null});var C,Ve=Ye(()=>{"use strict";C=class extends Error{code;retriable;cause;constructor(e,n,i){super(n),this.name="BridgeError",this.code=e,this.retriable=i?.retriable??!1,i?.cause!==void 0&&(this.cause=i.cause)}}});var f0={};ma(f0,{ACP_WRAPPER_NPM_PACKAGES:()=>Xr,_resetAcpInstallerForTests:()=>Zp,_setBinaryPathCacheForTests:()=>Xp,buildAcpSpawn:()=>Yr,ensureAcpInstalled:()=>rr,getAcpBinaryPath:()=>os,pickWhichLine:()=>va,probeAcpVersion:()=>Vp,resolveAcpCommand:()=>l0});import{readFileSync as c0}from"node:fs";import{createRequire as Wp}from"node:module";import{dirname as Kp,resolve as $p}from"node:path";function va(t){let e=t.split(/\r?\n/).map(i=>i.trim()).filter(Boolean);if(e.length===0)return;if(process.platform!=="win32")return e[0];let n=i=>e.find(o=>o.toLowerCase().endsWith(i));return n(".cmd")??n(".exe")??n(".bat")??n(".ps1")??e[0]}function Jp(t){let e=d0.resolve(`${t.npmPackage}/package.json`),n=Kp(e),i=JSON.parse(c0(e,"utf8")),o=typeof i.bin=="string"?i.bin:i.bin?.[t.binary];if(!o)throw new Error(`${t.npmPackage} package.json \u7F3A bin[${t.binary}]`);return $p(n,o)}async function rr(t,e){let n=ba[t];if(!n)throw new C("BRIDGE_INTERNAL",`ensureAcpInstalled called for non-npm framework: ${t}`);let i=Zr.get(t);if(i)return i;try{let o=Jp(n);return Zr.set(t,o),Ea.info("acp wrapper resolved",{framework:t,binary:n.binary,path:o}),o}catch(o){throw Ea.warn("acp wrapper \u89E3\u6790\u5931\u8D25 (\u672A\u968F\u5305\u56FA\u5316\u5230 lib/node_modules?)",{framework:t,npmPackage:n.npmPackage,err:String(o)}),new C("AGENT_DEPENDENCY_INSTALL_FAILED",[`ACP wrapper \u672A\u5C31\u7EEA: ${n.npmPackage} (framework=${t})`,"\u8BE5 wrapper \u968F coze-bridge \u4E00\u8D77\u5B89\u88C5 (\u56FA\u5316\u5230 ~/.coze/bridge/lib/node_modules)\u3002","\u8BF7\u91CD\u8DD1 `coze-bridge pair` / `connect` \u89E6\u53D1\u56FA\u5316\u5B89\u88C5; \u82E5\u4ECD\u5931\u8D25, \u68C0\u67E5\u7F51\u7EDC / npm \u7F13\u5B58\u3002"].join(`
|
|
13
|
+
`),{cause:o})}}async function Vp(t){let e=ba[t];if(e)try{let n=d0.resolve(`${e.npmPackage}/package.json`),i=JSON.parse(c0(n,"utf8"));return typeof i.version=="string"&&i.version.length>0?i.version:void 0}catch(n){Ea.warn("acp wrapper probe: \u89E3\u6790 package.json \u5931\u8D25",{framework:t,npmPackage:e.npmPackage,err:String(n)});return}}function os(t){return Zr.get(t)}function l0(t,e){if(e)return e;let n=os(t);if(!n)throw new C("BRIDGE_INTERNAL",`${t} ACP wrapper \u8DEF\u5F84\u672A\u89E3\u6790 (ensureAcpInstalled \u672A\u5728\u6784\u9020\u524D\u8DD1\u901A)`);return n}function Yr(t,e,n){if(e)return{command:e,args:[...n]};let i=l0(t);return{command:process.execPath,args:[i,...n]}}function Zp(){Zr.clear()}function Xp(t,e){Zr.set(t,e)}var Ea,ba,Xr,d0,Zr,sn=Ye(()=>{"use strict";Ve();re();Ea=H("agents.acp-installer"),ba={"claude-code":{npmPackage:"@agentclientprotocol/claude-agent-acp",binary:"claude-agent-acp"},codex:{npmPackage:"@zed-industries/codex-acp",binary:"codex-acp"}},Xr=Object.values(ba).filter(t=>t!==void 0).map(t=>t.npmPackage),d0=Wp(import.meta.url),Zr=new Map});import{chmod as Qp,mkdir as eg,readFile as tg,rename as h0,writeFile as p0}from"node:fs/promises";import{dirname as ng}from"node:path";async function ir(t){try{let e=await tg(t,"utf8");return JSON.parse(e)}catch(e){if(e.code==="ENOENT")return null;throw e}}async function sr(t,e,n){await eg(ng(t),{recursive:!0});let i=`${JSON.stringify(e,null,2)}
|
|
14
|
+
`,o=`${t}.tmp-${process.pid}-${Math.random().toString(36).slice(2,10)}`;try{n?.mode!==void 0?await p0(o,i,{encoding:"utf8",mode:n.mode}):await p0(o,i,"utf8"),await h0(o,t),n?.mode!==void 0&&await Qp(t,n.mode)}catch(c){await h0(o,o).catch(()=>{});let{rm:l}=await import("node:fs/promises");throw await l(o,{force:!0}).catch(()=>{}),c}}var Qr=Ye(()=>{"use strict"});import{promises as g0,readdirSync as rg}from"node:fs";import{homedir as ig}from"node:os";import{sep as sg,join as De,resolve as m0}from"node:path";function Q(t){let e=t??ig(),n=De(e,".coze"),i=De(n,"bridge"),o=De(i,"lib"),c=De(i,"logs");return{cozeRoot:n,bridgeRoot:i,libDir:o,libEntry:De(o,"index.js"),binDir:De(i,"bin"),pidFile:De(i,"bridge.pid"),portFile:De(i,"bridge.port"),tokenFile:De(i,"bridge.token"),patTokenFile:De(i,"pat-token"),agentEnvFile:De(i,"agent-env.json"),logFile:De(i,"bridge.log"),bridgeLogsDir:c,daemonStdioLog:De(c,"daemon-stdio.log"),installLock:De(i,"install.lock"),configFile:De(i,"config.json"),agentsRoot:De(n,"agents")}}function Qe(t,e=Q()){let n=De(e.agentsRoot,t);return{root:n,config:De(n,"config.json"),workspace:De(n,"workspace"),logs:De(n,"logs")}}function as(t=Q()){try{return rg(t.agentsRoot,{withFileTypes:!0}).filter(e=>e.isDirectory()).map(e=>e.name)}catch{return[]}}async function ei(t,e){let n=await g0.realpath(m0(t)).catch(()=>null);if(!n)return!1;let i=await g0.realpath(m0(e)).catch(()=>null);if(!i)return!1;let o=process.platform==="win32"?n.toLowerCase():n,c=process.platform==="win32"?i.toLowerCase():i;return o===c||o.startsWith(c+sg)}var Oe=Ye(()=>{"use strict"});var ls={};ma(ls,{AGENT_CONFIG_FILE_MODE:()=>cs,enforceAgentConfigMode:()=>cg,loadAgentConfig:()=>Ke,persistAgentSessions:()=>ti,persistAgentSkills:()=>ds,saveAgentConfig:()=>et});import{chmod as og,stat as ag}from"node:fs/promises";function Ke(t,e){return ir(Qe(t,e).config)}function et(t,e){return sr(Qe(t.agentId,e).config,t,{mode:cs})}async function cg(t,e){if(process.platform==="win32")return;let n=Qe(t,e).config;try{let i=await ag(n);if(!i.isFile())return;let o=i.mode&511;o!==cs&&(await og(n,cs),w0.warn("agent config mode auto-corrected to 0600",{path:n,from:o.toString(8)}))}catch(i){if(i.code==="ENOENT")return;w0.warn("enforceAgentConfigMode: chmod failed (ignored)",{path:n,err:String(i)})}}async function ti(t,e,n){let i=await Ke(t,n);i&&(i.sessions=Object.fromEntries(e),await et(i,n))}async function ds(t,e,n){let i=await Ke(t,n);i&&(i.skills=e,await et(i,n))}var w0,cs,on=Ye(()=>{"use strict";Qr();re();Oe();w0=H("agent-config"),cs=384});var Ia=ae((TS,b0)=>{b0.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 us=ae(S0=>{var v0={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 xg(t){return function(...e){return e.length&&(t=t.replace(/\{(\d)\}/g,(n,i)=>e[i]||"")),new Error("ADM-ZIP: "+t)}}for(let t of Object.keys(v0))S0[t]=xg(v0[t])});var D0=ae((DS,C0)=>{var hg=fe("fs"),Ne=fe("path"),I0=Ia(),pg=us(),gg=typeof process=="object"&&process.platform==="win32",A0=t=>typeof t=="object"&&t!==null,T0=new Uint32Array(256).map((t,e)=>{for(let n=0;n<8;n++)(e&1)!==0?e=3988292384^e>>>1:e>>>=1;return e>>>0});function ve(t){this.sep=Ne.sep,this.fs=hg,A0(t)&&A0(t.fs)&&typeof t.fs.statSync=="function"&&(this.fs=t.fs)}C0.exports=ve;ve.prototype.makeDir=function(t){let e=this;function n(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 l;try{l=e.fs.statSync(o)}catch(f){if(f.message&&f.message.startsWith("ENOENT"))e.fs.mkdirSync(o);else throw f}if(l&&l.isFile())throw pg.FILE_IN_THE_WAY(`"${o}"`)}})}n(t)};ve.prototype.writeFileTo=function(t,e,n,i){let o=this;if(o.fs.existsSync(t)){if(!n)return!1;var c=o.fs.statSync(t);if(c.isDirectory())return!1}var l=Ne.dirname(t);o.fs.existsSync(l)||o.makeDir(l);var f;try{f=o.fs.openSync(t,"w",438)}catch{o.fs.chmodSync(t,438),f=o.fs.openSync(t,"w",438)}if(f)try{o.fs.writeSync(f,e,0,e.length,0)}finally{o.fs.closeSync(f)}return o.fs.chmodSync(t,i||438),!0};ve.prototype.writeFileToAsync=function(t,e,n,i,o){typeof i=="function"&&(o=i,i=void 0);let c=this;c.fs.exists(t,function(l){if(l&&!n)return o(!1);c.fs.stat(t,function(f,x){if(l&&x.isDirectory())return o(!1);var p=Ne.dirname(t);c.fs.exists(p,function(w){w||c.makeDir(p),c.fs.open(t,"w",438,function(v,T){v?c.fs.chmod(t,438,function(){c.fs.open(t,"w",438,function(y,b){c.fs.write(b,e,0,e.length,0,function(){c.fs.close(b,function(){c.fs.chmod(t,i||438,function(){o(!0)})})})})}):T?c.fs.write(T,e,0,e.length,0,function(){c.fs.close(T,function(){c.fs.chmod(t,i||438,function(){o(!0)})})}):c.fs.chmod(t,i||438,function(){o(!0)})})})})})};ve.prototype.findFiles=function(t){let e=this;function n(i,o,c){typeof o=="boolean"&&(c=o,o=void 0);let l=[];return e.fs.readdirSync(i).forEach(function(f){let x=Ne.join(i,f),p=e.fs.statSync(x);(!o||o.test(x))&&l.push(Ne.normalize(x)+(p.isDirectory()?e.sep:"")),p.isDirectory()&&c&&(l=l.concat(n(x,o,c)))}),l}return n(t,void 0,!0)};ve.prototype.findFilesAsync=function(t,e){let n=this,i=[];n.fs.readdir(t,function(o,c){if(o)return e(o);let l=c.length;if(!l)return e(null,i);c.forEach(function(f){f=Ne.join(t,f),n.fs.stat(f,function(x,p){if(x)return e(x);p&&(i.push(Ne.normalize(f)+(p.isDirectory()?n.sep:"")),p.isDirectory()?n.findFilesAsync(f,function(w,v){if(w)return e(w);i=i.concat(v),--l||e(null,i)}):--l||e(null,i))})})})};ve.prototype.getAttributes=function(){};ve.prototype.setAttributes=function(){};ve.crc32update=function(t,e){return T0[(t^e)&255]^t>>>8};ve.crc32=function(t){typeof t=="string"&&(t=Buffer.from(t,"utf8"));let e=t.length,n=-1;for(let i=0;i<e;)n=ve.crc32update(n,t[i++]);return~n>>>0};ve.methodToString=function(t){switch(t){case I0.STORED:return"STORED ("+t+")";case I0.DEFLATED:return"DEFLATED ("+t+")";default:return"UNSUPPORTED ("+t+")"}};ve.canonical=function(t){if(!t)return"";let e=Ne.posix.normalize("/"+t.split("\\").join("/"));return Ne.join(".",e)};ve.zipnamefix=function(t){if(!t)return"";let e=Ne.posix.normalize("/"+t.split("\\").join("/"));return Ne.posix.join(".",e)};ve.findLast=function(t,e){if(!Array.isArray(t))throw new TypeError("arr is not array");let n=t.length>>>0;for(let i=n-1;i>=0;i--)if(e(t[i],i,t))return t[i]};ve.sanitize=function(t,e){t=Ne.resolve(Ne.normalize(t));for(var n=e.split("/"),i=0,o=n.length;i<o;i++){var c=Ne.normalize(Ne.join(t,n.slice(i,o).join(Ne.sep)));if(c.indexOf(t)===0)return c}return Ne.normalize(Ne.join(t,Ne.basename(e)))};ve.toBuffer=function(e,n){return Buffer.isBuffer(e)?e:e instanceof Uint8Array?Buffer.from(e):typeof e=="string"?n(e):Buffer.alloc(0)};ve.readBigUInt64LE=function(t,e){let n=t.readUInt32LE(e);return t.readUInt32LE(e+4)*4294967296+n};ve.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)};ve.fromDate2DOS=function(t){let e=0,n=0;return t.getFullYear()>1979&&(e=(t.getFullYear()-1980&127)<<9|t.getMonth()+1<<5|t.getDate(),n=t.getHours()<<11|t.getMinutes()<<5|t.getSeconds()>>1),e<<16|n};ve.isWin=gg;ve.crcTable=T0});var k0=ae((RS,R0)=>{var mg=fe("path");R0.exports=function(t,{fs:e}){var n=t||"",i=c(),o=null;function c(){return{directory:!1,readonly:!1,hidden:!1,executable:!1,mtime:0,atime:0}}return n&&e.existsSync(n)?(o=e.statSync(n),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=mg.basename(n)[0]==="."):console.warn("Invalid path: "+n),{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:n,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 P0=ae((kS,L0)=>{L0.exports={efs:!0,encode:t=>Buffer.from(t,"utf8"),decode:t=>t.toString("utf8")}});var cr=ae((LS,ar)=>{ar.exports=D0();ar.exports.Constants=Ia();ar.exports.Errors=us();ar.exports.FileAttr=k0();ar.exports.decoder=P0()});var N0=ae((PS,O0)=>{var an=cr(),F=an.Constants;O0.exports=function(){var t=20,e=10,n=0,i=0,o=0,c=0,l=0,f=0,x=0,p=0,w=0,v=0,T=0,y=0,b=0;t|=an.isWin?2560:768,n|=F.FLG_EFS;let S={extraLen:0},A=_=>Math.max(0,_)>>>0,R=_=>Math.max(0,_)&65535,P=_=>Math.max(0,_)&255;return o=an.fromDate2DOS(new Date),{get made(){return t},set made(_){t=_},get version(){return e},set version(_){e=_},get flags(){return n},set flags(_){n=_},get flags_efs(){return(n&F.FLG_EFS)>0},set flags_efs(_){_?n|=F.FLG_EFS:n&=~F.FLG_EFS},get flags_desc(){return(n&F.FLG_DESC)>0},set flags_desc(_){_?n|=F.FLG_DESC:n&=~F.FLG_DESC},get method(){return i},set method(_){switch(_){case F.STORED:this.version=10;case F.DEFLATED:default:this.version=20}i=_},get time(){return an.fromDOS2Date(this.timeval)},set time(_){_=new Date(_),this.timeval=an.fromDate2DOS(_)},get timeval(){return o},set timeval(_){o=A(_)},get timeHighByte(){return P(o>>>8)},get crc(){return c},set crc(_){c=A(_)},get compressedSize(){return l},set compressedSize(_){l=A(_)},get size(){return f},set size(_){f=A(_)},get fileNameLength(){return x},set fileNameLength(_){x=_},get extraLength(){return p},set extraLength(_){p=_},get extraLocalLength(){return S.extraLen},set extraLocalLength(_){S.extraLen=_},get commentLength(){return w},set commentLength(_){w=_},get diskNumStart(){return v},set diskNumStart(_){v=A(_)},get inAttr(){return T},set inAttr(_){T=A(_)},get attr(){return y},set attr(_){y=A(_)},get fileAttr(){return(y||0)>>16&4095},get offset(){return b},set offset(_){b=A(_)},get encrypted(){return(n&F.FLG_ENC)===F.FLG_ENC},get centralHeaderSize(){return F.CENHDR+x+p+w},get realDataOffset(){return b+F.LOCHDR+S.fnameLen+S.extraLen},get localHeader(){return S},loadLocalHeaderFromBinary:function(_){var D=_.slice(b,b+F.LOCHDR);if(D.readUInt32LE(0)!==F.LOCSIG)throw an.Errors.INVALID_LOC();S.version=D.readUInt16LE(F.LOCVER),S.flags=D.readUInt16LE(F.LOCFLG),S.flags_desc=(S.flags&F.FLG_DESC)>0,S.method=D.readUInt16LE(F.LOCHOW),S.time=D.readUInt32LE(F.LOCTIM),S.crc=D.readUInt32LE(F.LOCCRC),S.compressedSize=D.readUInt32LE(F.LOCSIZ),S.size=D.readUInt32LE(F.LOCLEN),S.fnameLen=D.readUInt16LE(F.LOCNAM),S.extraLen=D.readUInt16LE(F.LOCEXT);let L=b+F.LOCHDR+S.fnameLen,B=L+S.extraLen;return _.slice(L,B)},loadFromBinary:function(_){if(_.length!==F.CENHDR||_.readUInt32LE(0)!==F.CENSIG)throw an.Errors.INVALID_CEN();t=_.readUInt16LE(F.CENVEM),e=_.readUInt16LE(F.CENVER),n=_.readUInt16LE(F.CENFLG),i=_.readUInt16LE(F.CENHOW),o=_.readUInt32LE(F.CENTIM),c=_.readUInt32LE(F.CENCRC),l=_.readUInt32LE(F.CENSIZ),f=_.readUInt32LE(F.CENLEN),x=_.readUInt16LE(F.CENNAM),p=_.readUInt16LE(F.CENEXT),w=_.readUInt16LE(F.CENCOM),v=_.readUInt16LE(F.CENDSK),T=_.readUInt16LE(F.CENATT),y=_.readUInt32LE(F.CENATX),b=_.readUInt32LE(F.CENOFF)},localHeaderToBinary:function(){var _=Buffer.alloc(F.LOCHDR);return _.writeUInt32LE(F.LOCSIG,0),_.writeUInt16LE(e,F.LOCVER),_.writeUInt16LE(n,F.LOCFLG),_.writeUInt16LE(i,F.LOCHOW),_.writeUInt32LE(o,F.LOCTIM),_.writeUInt32LE(c,F.LOCCRC),_.writeUInt32LE(l,F.LOCSIZ),_.writeUInt32LE(f,F.LOCLEN),_.writeUInt16LE(x,F.LOCNAM),_.writeUInt16LE(S.extraLen,F.LOCEXT),_},centralHeaderToBinary:function(){var _=Buffer.alloc(F.CENHDR+x+p+w);return _.writeUInt32LE(F.CENSIG,0),_.writeUInt16LE(t,F.CENVEM),_.writeUInt16LE(e,F.CENVER),_.writeUInt16LE(n,F.CENFLG),_.writeUInt16LE(i,F.CENHOW),_.writeUInt32LE(o,F.CENTIM),_.writeUInt32LE(c,F.CENCRC),_.writeUInt32LE(l,F.CENSIZ),_.writeUInt32LE(f,F.CENLEN),_.writeUInt16LE(x,F.CENNAM),_.writeUInt16LE(p,F.CENEXT),_.writeUInt16LE(w,F.CENCOM),_.writeUInt16LE(v,F.CENDSK),_.writeUInt16LE(T,F.CENATT),_.writeUInt32LE(y,F.CENATX),_.writeUInt32LE(b,F.CENOFF),_},toJSON:function(){let _=function(D){return D+" bytes"};return{made:t,version:e,flags:n,method:an.methodToString(i),time:this.time,crc:"0x"+c.toString(16).toUpperCase(),compressedSize:_(l),size:_(f),fileNameLength:_(x),extraLength:_(p),commentLength:_(w),diskNumStart:v,inAttr:T,attr:y,offset:b,centralHeaderSize:_(F.CENHDR+x+p+w)}},toString:function(){return JSON.stringify(this.toJSON(),null," ")}}}});var B0=ae((OS,M0)=>{var dr=cr(),_e=dr.Constants;M0.exports=function(){var t=0,e=0,n=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 n},set size(c){n=c},get offset(){return i},set offset(c){i=c},get commentLength(){return o},set commentLength(c){o=c},get mainHeaderSize(){return _e.ENDHDR+o},loadFromBinary:function(c){if((c.length!==_e.ENDHDR||c.readUInt32LE(0)!==_e.ENDSIG)&&(c.length<_e.ZIP64HDR||c.readUInt32LE(0)!==_e.ZIP64SIG))throw dr.Errors.INVALID_END();c.readUInt32LE(0)===_e.ENDSIG?(t=c.readUInt16LE(_e.ENDSUB),e=c.readUInt16LE(_e.ENDTOT),n=c.readUInt32LE(_e.ENDSIZ),i=c.readUInt32LE(_e.ENDOFF),o=c.readUInt16LE(_e.ENDCOM)):(t=dr.readBigUInt64LE(c,_e.ZIP64SUB),e=dr.readBigUInt64LE(c,_e.ZIP64TOT),n=dr.readBigUInt64LE(c,_e.ZIP64SIZE),i=dr.readBigUInt64LE(c,_e.ZIP64OFF),o=0)},toBinary:function(){var c=Buffer.alloc(_e.ENDHDR+o);return c.writeUInt32LE(_e.ENDSIG,0),c.writeUInt32LE(0,4),c.writeUInt16LE(t,_e.ENDSUB),c.writeUInt16LE(e,_e.ENDTOT),c.writeUInt32LE(n,_e.ENDSIZ),c.writeUInt32LE(i,_e.ENDOFF),c.writeUInt16LE(o,_e.ENDCOM),c.fill(" ",_e.ENDHDR),c},toJSON:function(){let c=function(l,f){let x=l.toString(16).toUpperCase();for(;x.length<f;)x="0"+x;return"0x"+x};return{diskEntries:t,totalEntries:e,size:n+" bytes",offset:c(i,4),commentLength:o}},toString:function(){return JSON.stringify(this.toJSON(),null," ")}}}});var Ta=ae(Aa=>{Aa.EntryHeader=N0();Aa.MainHeader=B0()});var F0=ae((MS,z0)=>{z0.exports=function(t){var e=fe("zlib"),n={chunkSize:(parseInt(t.length/1024)+1)*1024};return{deflate:function(){return e.deflateRawSync(t,n)},deflateAsync:function(i){var o=e.createDeflateRaw(n),c=[],l=0;o.on("data",function(f){c.push(f),l+=f.length}),o.on("end",function(){var f=Buffer.alloc(l),x=0;f.fill(0);for(var p=0;p<c.length;p++){var w=c[p];w.copy(f,x),x+=w.length}i&&i(f)}),o.end(t)}}}});var q0=ae((BS,U0)=>{var wg=+(process.versions?process.versions.node:"").split(".")[0]||0;U0.exports=function(t,e){var n=fe("zlib");let i=wg>=15&&e>0?{maxOutputLength:e}:{};return{inflate:function(){return n.inflateRawSync(t,i)},inflateAsync:function(o){var c=n.createInflateRaw(i),l=[],f=0;c.on("data",function(x){l.push(x),f+=x.length}),c.on("end",function(){var x=Buffer.alloc(f),p=0;x.fill(0);for(var w=0;w<l.length;w++){var v=l[w];v.copy(x,p),p+=v.length}o&&o(x)}),c.end(t)}}}});var K0=ae((zS,W0)=>{"use strict";var{randomFillSync:H0}=fe("crypto"),_g=us(),yg=new Uint32Array(256).map((t,e)=>{for(let n=0;n<8;n++)(e&1)!==0?e=e>>>1^3988292384:e>>>=1;return e>>>0}),j0=(t,e)=>Math.imul(t,e)>>>0,G0=(t,e)=>yg[(t^e)&255]^t>>>8,ni=()=>typeof H0=="function"?H0(Buffer.alloc(12)):ni.node();ni.node=()=>{let t=Buffer.alloc(12),e=t.length;for(let n=0;n<e;n++)t[n]=Math.random()*256&255;return t};var xs={genSalt:ni};function hs(t){let e=Buffer.isBuffer(t)?t:Buffer.from(t);this.keys=new Uint32Array([305419896,591751049,878082192]);for(let n=0;n<e.length;n++)this.updateKeys(e[n])}hs.prototype.updateKeys=function(t){let e=this.keys;return e[0]=G0(e[0],t),e[1]+=e[0]&255,e[1]=j0(e[1],134775813)+1,e[2]=G0(e[2],e[1]>>>24),t};hs.prototype.next=function(){let t=(this.keys[2]|2)>>>0;return j0(t,t^1)>>8&255};function Eg(t){let e=new hs(t);return function(n){let i=Buffer.alloc(n.length),o=0;for(let c of n)i[o++]=e.updateKeys(c^e.next());return i}}function bg(t){let e=new hs(t);return function(n,i,o=0){i||(i=Buffer.alloc(n.length));for(let c of n){let l=e.next();i[o++]=c^l,e.updateKeys(c)}return i}}function vg(t,e,n){if(!t||!Buffer.isBuffer(t)||t.length<12)return Buffer.alloc(0);let i=Eg(n),o=i(t.slice(0,12)),c=(e.flags&8)===8?e.timeHighByte:e.crc>>>24;if(o[11]!==c)throw _g.WRONG_PASSWORD();return i(t.slice(12))}function Sg(t){Buffer.isBuffer(t)&&t.length>=12?xs.genSalt=function(){return t.slice(0,12)}:t==="node"?xs.genSalt=ni.node:xs.genSalt=ni}function Ig(t,e,n,i=!1){t==null&&(t=Buffer.alloc(0)),Buffer.isBuffer(t)||(t=Buffer.from(t.toString()));let o=bg(n),c=xs.genSalt();c[11]=e.crc>>>24&255,i&&(c[10]=e.crc>>>16&255);let l=Buffer.alloc(t.length+12);return o(c,l),o(t,l,12)}W0.exports={decrypt:vg,encrypt:Ig,_salter:Sg}});var $0=ae(ps=>{ps.Deflater=F0();ps.Inflater=q0();ps.ZipCrypto=K0()});var Da=ae((US,J0)=>{var ce=cr(),Ag=Ta(),Se=ce.Constants,Ca=$0();J0.exports=function(t,e){var n=new Ag.EntryHeader,i=Buffer.alloc(0),o=Buffer.alloc(0),c=!1,l=null,f=Buffer.alloc(0),x=Buffer.alloc(0),p=!0;let w=t,v=typeof w.decoder=="object"?w.decoder:ce.decoder;p=v.hasOwnProperty("efs")?v.efs:!1;function T(){return!e||!(e instanceof Uint8Array)?Buffer.alloc(0):(x=n.loadLocalHeaderFromBinary(e),e.slice(n.realDataOffset,n.realDataOffset+n.compressedSize))}function y(_){if(!n.flags_desc&&!n.localHeader.flags_desc){if(ce.crc32(_)!==n.localHeader.crc)return!1}else{let D={},L=n.realDataOffset+n.compressedSize;if(e.readUInt32LE(L)==Se.LOCSIG||e.readUInt32LE(L)==Se.CENSIG)throw ce.Errors.DESCRIPTOR_NOT_EXIST();if(e.readUInt32LE(L)==Se.EXTSIG)D.crc=e.readUInt32LE(L+Se.EXTCRC),D.compressedSize=e.readUInt32LE(L+Se.EXTSIZ),D.size=e.readUInt32LE(L+Se.EXTLEN);else if(e.readUInt16LE(L+12)===19280)D.crc=e.readUInt32LE(L+Se.EXTCRC-4),D.compressedSize=e.readUInt32LE(L+Se.EXTSIZ-4),D.size=e.readUInt32LE(L+Se.EXTLEN-4);else throw ce.Errors.DESCRIPTOR_UNKNOWN();if(D.compressedSize!==n.compressedSize||D.size!==n.size||D.crc!==n.crc)throw ce.Errors.DESCRIPTOR_FAULTY();if(ce.crc32(_)!==D.crc)return!1}return!0}function b(_,D,L){if(typeof D>"u"&&typeof _=="string"&&(L=_,_=void 0),c)return _&&D&&D(Buffer.alloc(0),ce.Errors.DIRECTORY_CONTENT_ERROR()),Buffer.alloc(0);var B=T();if(B.length===0)return _&&D&&D(B),B;if(n.encrypted){if(typeof L!="string"&&!Buffer.isBuffer(L))throw ce.Errors.INVALID_PASS_PARAM();B=Ca.ZipCrypto.decrypt(B,n,L)}var z=Buffer.alloc(n.size);switch(n.method){case ce.Constants.STORED:if(B.copy(z),y(z))return _&&D&&D(z),z;throw _&&D&&D(z,ce.Errors.BAD_CRC()),ce.Errors.BAD_CRC();case ce.Constants.DEFLATED:var J=new Ca.Inflater(B,n.size);if(_)J.inflateAsync(function($){$.copy($,0),D&&(y($)?D($):D($,ce.Errors.BAD_CRC()))});else{if(J.inflate(z).copy(z,0),!y(z))throw ce.Errors.BAD_CRC(`"${v.decode(i)}"`);return z}break;default:throw _&&D&&D(Buffer.alloc(0),ce.Errors.UNKNOWN_METHOD()),ce.Errors.UNKNOWN_METHOD()}}function S(_,D){if((!l||!l.length)&&Buffer.isBuffer(e))return _&&D&&D(T()),T();if(l.length&&!c){var L;switch(n.method){case ce.Constants.STORED:return n.compressedSize=n.size,L=Buffer.alloc(l.length),l.copy(L),_&&D&&D(L),L;default:case ce.Constants.DEFLATED:var B=new Ca.Deflater(l);if(_)B.deflateAsync(function(J){L=Buffer.alloc(J.length),n.compressedSize=J.length,J.copy(L),D&&D(L)});else{var z=B.deflate();return n.compressedSize=z.length,z}B=null;break}}else if(_&&D)D(Buffer.alloc(0));else return Buffer.alloc(0)}function A(_,D){return ce.readBigUInt64LE(_,D)}function R(_){try{for(var D=0,L,B,z;D+4<_.length;)L=_.readUInt16LE(D),D+=2,B=_.readUInt16LE(D),D+=2,z=_.slice(D,D+B),D+=B,Se.ID_ZIP64===L&&P(z)}catch{throw ce.Errors.EXTRA_FIELD_PARSE_ERROR()}}function P(_){var D,L,B,z;_.length>=Se.EF_ZIP64_SCOMP&&(D=A(_,Se.EF_ZIP64_SUNCOMP),n.size===Se.EF_ZIP64_OR_32&&(n.size=D)),_.length>=Se.EF_ZIP64_RHO&&(L=A(_,Se.EF_ZIP64_SCOMP),n.compressedSize===Se.EF_ZIP64_OR_32&&(n.compressedSize=L)),_.length>=Se.EF_ZIP64_DSN&&(B=A(_,Se.EF_ZIP64_RHO),n.offset===Se.EF_ZIP64_OR_32&&(n.offset=B)),_.length>=Se.EF_ZIP64_DSN+4&&(z=_.readUInt32LE(Se.EF_ZIP64_DSN),n.diskNumStart===Se.EF_ZIP64_OR_16&&(n.diskNumStart=z))}return{get entryName(){return v.decode(i)},get rawEntryName(){return i},set entryName(_){i=ce.toBuffer(_,v.encode);var D=i[i.length-1];c=D===47||D===92,n.fileNameLength=i.length},get efs(){return typeof p=="function"?p(this.entryName):p},get extra(){return f},set extra(_){f=_,n.extraLength=_.length,R(_)},get comment(){return v.decode(o)},set comment(_){if(o=ce.toBuffer(_,v.encode),n.commentLength=o.length,o.length>65535)throw ce.Errors.COMMENT_TOO_LONG()},get name(){var _=v.decode(i);return c?_.substr(_.length-1).split("/").pop():_.split("/").pop()},get isDirectory(){return c},getCompressedData:function(){return S(!1,null)},getCompressedDataAsync:function(_){S(!0,_)},setData:function(_){l=ce.toBuffer(_,ce.decoder.encode),!c&&l.length?(n.size=l.length,n.method=ce.Constants.DEFLATED,n.crc=ce.crc32(_),n.changed=!0):n.method=ce.Constants.STORED},getData:function(_){return n.changed?l:b(!1,null,_)},getDataAsync:function(_,D){n.changed?_(l):b(!0,_,D)},set attr(_){n.attr=_},get attr(){return n.attr},set header(_){n.loadFromBinary(_)},get header(){return n},packCentralHeader:function(){n.flags_efs=this.efs,n.extraLength=f.length;var _=n.centralHeaderToBinary(),D=ce.Constants.CENHDR;return i.copy(_,D),D+=i.length,f.copy(_,D),D+=n.extraLength,o.copy(_,D),_},packLocalHeader:function(){let _=0;n.flags_efs=this.efs,n.extraLocalLength=x.length;let D=n.localHeaderToBinary(),L=Buffer.alloc(D.length+i.length+n.extraLocalLength);return D.copy(L,_),_+=D.length,i.copy(L,_),_+=i.length,x.copy(L,_),_+=x.length,L},toJSON:function(){let _=function(D){return"<"+(D&&D.length+" bytes buffer"||"null")+">"};return{entryName:this.entryName,name:this.name,comment:this.comment,isDirectory:this.isDirectory,header:n.toJSON(),compressedData:_(e),data:_(l)}},toString:function(){return JSON.stringify(this.toJSON(),null," ")}}}});var X0=ae((qS,Z0)=>{var V0=Da(),Tg=Ta(),$e=cr();Z0.exports=function(t,e){var n=[],i={},o=Buffer.alloc(0),c=new Tg.MainHeader,l=!1,f=null;let x=new Set,p=e,{noSort:w,decoder:v}=p;t?b(p.readEntries):l=!0;function T(){let A=new Set;for(let R of Object.keys(i)){let P=R.split("/");if(P.pop(),!!P.length)for(let _=0;_<P.length;_++){let D=P.slice(0,_+1).join("/")+"/";A.add(D)}}for(let R of A)if(!(R in i)){let P=new V0(p);P.entryName=R,P.attr=16,P.temporary=!0,n.push(P),i[P.entryName]=P,x.add(P)}}function y(){if(l=!0,i={},c.diskEntries>(t.length-c.offset)/$e.Constants.CENHDR)throw $e.Errors.DISK_ENTRY_TOO_LARGE();n=new Array(c.diskEntries);for(var A=c.offset,R=0;R<n.length;R++){var P=A,_=new V0(p,t);_.header=t.slice(P,P+=$e.Constants.CENHDR),_.entryName=t.slice(P,P+=_.header.fileNameLength),_.header.extraLength&&(_.extra=t.slice(P,P+=_.header.extraLength)),_.header.commentLength&&(_.comment=t.slice(P,P+_.header.commentLength)),A+=_.header.centralHeaderSize,n[R]=_,i[_.entryName]=_}x.clear(),T()}function b(A){var R=t.length-$e.Constants.ENDHDR,P=Math.max(0,R-65535),_=P,D=t.length,L=-1,B=0;for(typeof p.trailingSpace=="boolean"&&p.trailingSpace&&(P=0),R;R>=_;R--)if(t[R]===80){if(t.readUInt32LE(R)===$e.Constants.ENDSIG){L=R,B=R,D=R+$e.Constants.ENDHDR,_=R-$e.Constants.END64HDR;continue}if(t.readUInt32LE(R)===$e.Constants.END64SIG){_=P;continue}if(t.readUInt32LE(R)===$e.Constants.ZIP64SIG){L=R,D=R+$e.readBigUInt64LE(t,R+$e.Constants.ZIP64SIZE)+$e.Constants.ZIP64LEAD;break}}if(L==-1)throw $e.Errors.INVALID_FORMAT();c.loadFromBinary(t.slice(L,D)),c.commentLength&&(o=t.slice(B+$e.Constants.ENDHDR)),A&&y()}function S(){n.length>1&&!w&&n.sort((A,R)=>A.entryName.toLowerCase().localeCompare(R.entryName.toLowerCase()))}return{get entries(){return l||y(),n.filter(A=>!x.has(A))},get comment(){return v.decode(o)},set comment(A){o=$e.toBuffer(A,v.encode),c.commentLength=o.length},getEntryCount:function(){return l?n.length:c.diskEntries},forEach:function(A){this.entries.forEach(A)},getEntry:function(A){return l||y(),i[A]||null},setEntry:function(A){l||y(),n.push(A),i[A.entryName]=A,c.totalEntries=n.length},deleteFile:function(A,R=!0){l||y();let P=i[A];this.getEntryChildren(P,R).map(D=>D.entryName).forEach(this.deleteEntry)},deleteEntry:function(A){l||y();let R=i[A],P=n.indexOf(R);P>=0&&(n.splice(P,1),delete i[A],c.totalEntries=n.length)},getEntryChildren:function(A,R=!0){if(l||y(),typeof A=="object")if(A.isDirectory&&R){let P=[],_=A.entryName;for(let D of n)D.entryName.startsWith(_)&&P.push(D);return P}else return[A];return[]},getChildCount:function(A){if(A&&A.isDirectory){let R=this.getEntryChildren(A);return R.includes(A)?R.length-1:R.length}return 0},compressToBuffer:function(){l||y(),S();let A=[],R=[],P=0,_=0;c.size=0,c.offset=0;let D=0;for(let z of this.entries){let J=z.getCompressedData();z.header.offset=_;let $=z.packLocalHeader(),ee=$.length+J.length;_+=ee,A.push($),A.push(J);let X=z.packCentralHeader();R.push(X),c.size+=X.length,P+=ee+X.length,D++}P+=c.mainHeaderSize,c.offset=_,c.totalEntries=D,_=0;let L=Buffer.alloc(P);for(let z of A)z.copy(L,_),_+=z.length;for(let z of R)z.copy(L,_),_+=z.length;let B=c.toBinary();return o&&o.copy(B,$e.Constants.ENDHDR),B.copy(L,_),t=L,l=!1,L},toAsyncBuffer:function(A,R,P,_){try{l||y(),S();let D=[],L=[],B=0,z=0,J=0;c.size=0,c.offset=0;let $=function(ee){if(ee.length>0){let X=ee.shift(),Ae=X.entryName+X.extra.toString();P&&P(Ae),X.getCompressedDataAsync(function(ze){_&&_(Ae),X.header.offset=z;let O=X.packLocalHeader(),G=O.length+ze.length;z+=G,D.push(O),D.push(ze);let W=X.packCentralHeader();L.push(W),c.size+=W.length,B+=G+W.length,J++,$(ee)})}else{B+=c.mainHeaderSize,c.offset=z,c.totalEntries=J,z=0;let X=Buffer.alloc(B);D.forEach(function(ze){ze.copy(X,z),z+=ze.length}),L.forEach(function(ze){ze.copy(X,z),z+=ze.length});let Ae=c.toBinary();o&&o.copy(Ae,$e.Constants.ENDHDR),Ae.copy(X,z),t=X,l=!1,A(X)}};$(Array.from(this.entries))}catch(D){R(D)}}}}});var el=ae((HS,Q0)=>{var Ee=cr(),ye=fe("path"),Cg=Da(),Dg=X0(),Rn=(...t)=>Ee.findLast(t,e=>typeof e=="boolean"),Y0=(...t)=>Ee.findLast(t,e=>typeof e=="string"),Rg=(...t)=>Ee.findLast(t,e=>typeof e=="function"),kg={noSort:!1,readEntries:!1,method:Ee.Constants.NONE,fs:null};Q0.exports=function(t,e){let n=null,i=Object.assign(Object.create(null),kg);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)&&(n=t,i.method=Ee.Constants.BUFFER,t=void 0)),Object.assign(i,e);let o=new Ee(i);if((typeof i.decoder!="object"||typeof i.decoder.encode!="function"||typeof i.decoder.decode!="function")&&(i.decoder=Ee.decoder),t&&typeof t=="string")if(o.fs.existsSync(t))i.method=Ee.Constants.FILE,i.filename=t,n=o.fs.readFileSync(t);else throw Ee.Errors.INVALID_FILENAME();let c=new Dg(n,i),{canonical:l,sanitize:f,zipnamefix:x}=Ee;function p(y){if(y&&c){var b;if(typeof y=="string"&&(b=c.getEntry(ye.posix.normalize(y))),typeof y=="object"&&typeof y.entryName<"u"&&typeof y.header<"u"&&(b=c.getEntry(y.entryName)),b)return b}return null}function w(y){let{join:b,normalize:S,sep:A}=ye.posix;return b(ye.isAbsolute(y)?"/":".",S(A+y.split("\\").join(A)+A))}function v(y){return y instanceof RegExp?(function(b){return function(S){return b.test(S)}})(y):typeof y!="function"?()=>!0:y}let T=(y,b)=>{let S=b.slice(-1);return S=S===o.sep?o.sep:"",ye.relative(y,b)+S};return{readFile:function(y,b){var S=p(y);return S&&S.getData(b)||null},childCount:function(y){let b=p(y);if(b)return c.getChildCount(b)},readFileAsync:function(y,b){var S=p(y);S?S.getDataAsync(b):b(null,"getEntry failed for:"+y)},readAsText:function(y,b){var S=p(y);if(S){var A=S.getData();if(A&&A.length)return A.toString(b||"utf8")}return""},readAsTextAsync:function(y,b,S){var A=p(y);A?A.getDataAsync(function(R,P){if(P){b(R,P);return}R&&R.length?b(R.toString(S||"utf8")):b("")}):b("")},deleteFile:function(y,b=!0){var S=p(y);S&&c.deleteFile(S.entryName,b)},deleteEntry:function(y){var b=p(y);b&&c.deleteEntry(b.entryName)},addZipComment:function(y){c.comment=y},getZipComment:function(){return c.comment||""},addZipEntryComment:function(y,b){var S=p(y);S&&(S.comment=b)},getZipEntryComment:function(y){var b=p(y);return b&&b.comment||""},updateFile:function(y,b){var S=p(y);S&&S.setData(b)},addLocalFile:function(y,b,S,A){if(o.fs.existsSync(y)){b=b?w(b):"";let R=ye.win32.basename(ye.win32.normalize(y));b+=S||R;let P=o.fs.statSync(y),_=P.isFile()?o.fs.readFileSync(y):Buffer.alloc(0);P.isDirectory()&&(b+=o.sep),this.addFile(b,_,A,P)}else throw Ee.Errors.FILE_NOT_FOUND(y)},addLocalFileAsync:function(y,b){y=typeof y=="object"?y:{localPath:y};let S=ye.resolve(y.localPath),{comment:A}=y,{zipPath:R,zipName:P}=y,_=this;o.fs.stat(S,function(D,L){if(D)return b(D,!1);R=R?w(R):"";let B=ye.win32.basename(ye.win32.normalize(S));if(R+=P||B,L.isFile())o.fs.readFile(S,function(z,J){return z?b(z,!1):(_.addFile(R,J,A,L),setImmediate(b,void 0,!0))});else if(L.isDirectory())return R+=o.sep,_.addFile(R,Buffer.alloc(0),A,L),setImmediate(b,void 0,!0)})},addLocalFolder:function(y,b,S){if(S=v(S),b=b?w(b):"",y=ye.normalize(y),o.fs.existsSync(y)){let A=o.findFiles(y),R=this;if(A.length)for(let P of A){let _=ye.join(b,T(y,P));S(_)&&R.addLocalFile(P,ye.dirname(_))}}else throw Ee.Errors.FILE_NOT_FOUND(y)},addLocalFolderAsync:function(y,b,S,A){A=v(A),S=S?w(S):"",y=ye.normalize(y);var R=this;o.fs.open(y,"r",function(P){if(P&&P.code==="ENOENT")b(void 0,Ee.Errors.FILE_NOT_FOUND(y));else if(P)b(void 0,P);else{var _=o.findFiles(y),D=-1,L=function(){if(D+=1,D<_.length){var B=_[D],z=T(y,B).split("\\").join("/");z=z.normalize("NFD").replace(/[\u0300-\u036f]/g,"").replace(/[^\x20-\x7E]/g,""),A(z)?o.fs.stat(B,function(J,$){J&&b(void 0,J),$.isFile()?o.fs.readFile(B,function(ee,X){ee?b(void 0,ee):(R.addFile(S+z,X,"",$),L())}):(R.addFile(S+z+"/",Buffer.alloc(0),"",$),L())}):process.nextTick(()=>{L()})}else b(!0,void 0)};L()}})},addLocalFolderAsync2:function(y,b){let S=this;y=typeof y=="object"?y:{localPath:y},localPath=ye.resolve(w(y.localPath));let{zipPath:A,filter:R,namefix:P}=y;R instanceof RegExp?R=(function(L){return function(B){return L.test(B)}})(R):typeof R!="function"&&(R=function(){return!0}),A=A?w(A):"",P=="latin1"&&(P=L=>L.normalize("NFD").replace(/[\u0300-\u036f]/g,"").replace(/[^\x20-\x7E]/g,"")),typeof P!="function"&&(P=L=>L);let _=L=>ye.join(A,P(T(localPath,L))),D=L=>ye.win32.basename(ye.win32.normalize(P(L)));o.fs.open(localPath,"r",function(L){L&&L.code==="ENOENT"?b(void 0,Ee.Errors.FILE_NOT_FOUND(localPath)):L?b(void 0,L):o.findFilesAsync(localPath,function(B,z){if(B)return b(B);z=z.filter(J=>R(_(J))),z.length||b(void 0,!1),setImmediate(z.reverse().reduce(function(J,$){return function(ee,X){if(ee||X===!1)return setImmediate(J,ee,!1);S.addLocalFileAsync({localPath:$,zipPath:ye.dirname(_($)),zipName:D($)},J)}},b))})})},addLocalFolderPromise:function(y,b){return new Promise((S,A)=>{this.addLocalFolderAsync2(Object.assign({localPath:y},b),(R,P)=>{R&&A(R),P&&S(this)})})},addFile:function(y,b,S,A){y=x(y);let R=p(y),P=R!=null;P||(R=new Cg(i),R.entryName=y),R.comment=S||"";let _=typeof A=="object"&&A instanceof o.fs.Stats;_&&(R.header.time=A.mtime);var D=R.isDirectory?16:0;let L=R.isDirectory?16384:32768;return _?L|=4095&A.mode:typeof A=="number"?L|=4095&A:L|=R.isDirectory?493:420,D=(D|L<<16)>>>0,R.attr=D,R.setData(b),P||c.setEntry(R),R},getEntries:function(y){return c.password=y,c?c.entries:[]},getEntry:function(y){return p(y)},getEntryCount:function(){return c.getEntryCount()},forEach:function(y){return c.forEach(y)},extractEntryTo:function(y,b,S,A,R,P){A=Rn(!1,A),R=Rn(!1,R),S=Rn(!0,S),P=Y0(R,P);var _=p(y);if(!_)throw Ee.Errors.NO_ENTRY();var D=l(_.entryName),L=f(b,P&&!_.isDirectory?P:S?D:ye.basename(D));if(_.isDirectory){var B=c.getEntryChildren(_);return B.forEach(function($){if($.isDirectory)return;var ee=$.getData();if(!ee)throw Ee.Errors.CANT_EXTRACT_FILE();var X=l($.entryName),Ae=f(b,S?X:ye.basename(X));let ze=R?$.header.fileAttr:void 0;o.writeFileTo(Ae,ee,A,ze)}),!0}var z=_.getData(c.password);if(!z)throw Ee.Errors.CANT_EXTRACT_FILE();if(o.fs.existsSync(L)&&!A)throw Ee.Errors.CANT_OVERRIDE();let J=R?y.header.fileAttr:void 0;return o.writeFileTo(L,z,A,J),!0},test:function(y){if(!c)return!1;for(var b in c.entries)try{if(b.isDirectory)continue;var S=c.entries[b].getData(y);if(!S)return!1}catch{return!1}return!0},extractAllTo:function(y,b,S,A){if(S=Rn(!1,S),A=Y0(S,A),b=Rn(!1,b),!c)throw Ee.Errors.NO_ZIP();c.entries.forEach(function(R){var P=f(y,l(R.entryName));if(R.isDirectory){o.makeDir(P);return}var _=R.getData(A);if(!_)throw Ee.Errors.CANT_EXTRACT_FILE();let D=S?R.header.fileAttr:void 0;o.writeFileTo(P,_,b,D);try{o.fs.utimesSync(P,R.header.time,R.header.time)}catch{throw Ee.Errors.CANT_EXTRACT_FILE()}})},extractAllToAsync:function(y,b,S,A){if(A=Rg(b,S,A),S=Rn(!1,S),b=Rn(!1,b),!A)return new Promise((L,B)=>{this.extractAllToAsync(y,b,S,function(z){z?B(z):L(this)})});if(!c){A(Ee.Errors.NO_ZIP());return}y=ye.resolve(y);let R=L=>f(y,ye.normalize(l(L.entryName))),P=(L,B)=>new Error(L+': "'+B+'"'),_=[],D=[];c.entries.forEach(L=>{L.isDirectory?_.push(L):D.push(L)});for(let L of _){let B=R(L),z=S?L.header.fileAttr:void 0;try{o.makeDir(B),z&&o.fs.chmodSync(B,z),o.fs.utimesSync(B,L.header.time,L.header.time)}catch{A(P("Unable to create folder",B))}}D.reverse().reduce(function(L,B){return function(z){if(z)L(z);else{let J=ye.normalize(l(B.entryName)),$=f(y,J);B.getDataAsync(function(ee,X){if(X)L(X);else if(!ee)L(Ee.Errors.CANT_EXTRACT_FILE());else{let Ae=S?B.header.fileAttr:void 0;o.writeFileToAsync($,ee,b,Ae,function(ze){ze||L(P("Unable to write file",$)),o.fs.utimes($,B.header.time,B.header.time,function(O){O?L(P("Unable to set times",$)):L()})})}})}}},A)()},writeZip:function(y,b){if(arguments.length===1&&typeof y=="function"&&(b=y,y=""),!y&&i.filename&&(y=i.filename),!!y){var S=c.compressToBuffer();if(S){var A=o.writeFileTo(y,S,!0);typeof b=="function"&&b(A?null:new Error("failed"),"")}}},writeZipPromise:function(y,b){let{overwrite:S,perm:A}=Object.assign({overwrite:!0},b);return new Promise((R,P)=>{!y&&i.filename&&(y=i.filename),y||P("ADM-ZIP: ZIP File Name Missing"),this.toBufferPromise().then(_=>{let D=L=>L?R(L):P("ADM-ZIP: Wasn't able to write zip file");o.writeFileToAsync(y,_,S,A,D)},P)})},toBufferPromise:function(){return new Promise((y,b)=>{c.toAsyncBuffer(y,b)})},toBuffer:function(y,b,S,A){return typeof y=="function"?(c.toAsyncBuffer(y,b,S,A),null):c.compressToBuffer()}}}});import{execFile as E_,spawn as b_,spawnSync as tI}from"node:child_process";import{promisify as v_}from"node:util";function I_(t){if(process.platform!=="win32")return!1;if(Vf.test(t))return!0;let n=(t.split(/[/\\]/).pop()??t).replace(Vf,"").toLowerCase();return S_.has(n)}function Zf(t,e){if(process.platform!=="win32")return e??{};let n={...e??{}};return I_(t)&&n.shell===void 0&&(n.shell=!0),n.windowsHide===void 0&&(n.windowsHide=!0),n}function ut(t,e=[],n={}){return b_(t,e,Zf(t,n))}function Xf(t,e=[],n={}){return A_(t,e,Zf(t,n))}var S_,Vf,A_,bn=Ye(()=>{"use strict";S_=new Set(["npm","npx","yarn","pnpm","coze","tsx","claude-agent-acp","codex-acp","openclaw"]),Vf=/\.(cmd|bat|ps1)$/i;A_=v_(E_)});var Gu=ae(ue=>{"use strict";var M=V;(function(t,e){let n=V,i=t();for(;;)try{if(parseInt(n(376))/1*(-parseInt(n(1432))/2)+parseInt(n(654))/3*(parseInt(n(1093))/4)+parseInt(n(396))/5+parseInt(n(734))/6+parseInt(n(556))/7*(-parseInt(n(1013))/8)+parseInt(n(561))/9+-parseInt(n(1053))/10===e)break;i.push(i.shift())}catch{i.push(i.shift())}})(To,686818);function V(t,e){t=t-112;let n=To(),i=n[t];if(V.mBdvqs===void 0){var o=function(x){let p="abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789+/=",w="",v="";for(let T=0,y,b,S=0;b=x.charAt(S++);~b&&(y=T%4?y*64+b:b,T++%4)?w+=String.fromCharCode(255&y>>(-2*T&6)):0)b=p.indexOf(b);for(let T=0,y=w.length;T<y;T++)v+="%"+("00"+w.charCodeAt(T).toString(16)).slice(-2);return decodeURIComponent(v)};V.RdoIdL=o,V.VyxRTS={},V.mBdvqs=!0}let c=n[0],l=t+c,f=V.VyxRTS[l];return f?i=f:(i=V.RdoIdL(i),V.VyxRTS[l]=i),i}var d1=Object[M(351)+M(147)],l1=Object["getOwnPr"+M(643)+"mes"],zu=(t,e)=>function(){return t&&(e=(0,t[{pHEXx:function(c,l){return c(l)}}[M(826)](l1,t)[0]])(t=0)),e},f1=(t,e)=>{let n=M,i={zSbDt:function(c,l,f,x){return c(l,f,x)}};for(var o in e)i[n(1329)](d1,t,o,{get:e[o],enumerable:!0})};function u1(){return Pu||(Pu=[IDBDatabase,IDBObjectStore,IDBIndex,IDBCursor,IDBTransaction])}function x1(){let t=M;return Ou||(Ou=[IDBCursor[t(1608)+"e"][t(791)],IDBCursor[t(1608)+"e"][t(1043)],IDBCursor.prototype[t(1043)+"PrimaryKey"]])}function h1(t){let e=M,n={BWpAs:function(o,c){return o(c)},uglqQ:function(o,c){return o(c)},mjZqT:function(o){return o()},viwkr:function(o,c){return o===c},ABrrh:e(1301),dObuy:e(1430),ByPOD:function(o,c){return o(c)},tdxMl:function(o){return o()},InaQA:e(1440),PoRMB:"error",nzJsY:function(o,c){return o instanceof c}},i=new Promise((o,c)=>{let l=e,f={qMers:n[l(970)],hLQWd:n[l(544)]},x=()=>{let v=l;t["removeEventListe"+v(1379)](f[v(1444)],p),t[v(1247)+v(348)+"ner"](f[v(478)],w)},p=()=>{let v=l;n[v(613)](o,n[v(1492)](zt,t[v(1045)])),n[v(1e3)](x)},w=()=>{let v=l;if(n.viwkr(n[v(990)],n[v(614)]))return!0;n[v(1386)](c,t.error),n.tdxMl(x)};t[l(141)+l(136)](n[l(970)],p),t[l(141)+l(136)](n[l(544)],w)});return i[e(1336)](o=>{let c=e;n.nzJsY(o,IDBCursor)&&td[c(558)](o,t)})[e(1576)](()=>{}),Io[e(558)](i,t),i}function p1(t){let e=M,n={BwJko:function(o,c){return o(c)},TNsaR:e(1394)+"or",KlCZB:function(o){return o()},ycrdL:e(924),JgBCf:e(310),UWeaz:e(659),bEJDC:e(736),cWBTJ:function(o,c){return o!==c},IMxom:e(806),TbRjt:e(708)};if(So[e(627)](t))return;let i=new Promise((o,c)=>{let l=e,f={nBmgV:n[l(381)],rUsfP:n[l(327)],XGLNZ:function(x){return n[l(920)](x)},BaFEM:l(337),IaTxi:n[l(1221)],Wbmnh:n[l(1622)]};if(n[l(603)](n[l(1500)],"kgVxl")){let x=()=>{let v=l;t[v(1247)+"entListe"+v(1379)](f.nBmgV,p),t[v(1247)+"entListe"+v(1379)](f[v(724)],w),t[v(1247)+"entListener"]("abort",w)},p=()=>{f[l(169)](o),x()},w=()=>{let v=l;n.BwJko(c,t[v(310)]||new DOMException(v(1394)+"or",n.TNsaR)),n[v(920)](x)};t["addEvent"+l(136)](n[l(381)],p),t[l(141)+l(136)](n.JgBCf,w),t["addEvent"+l(136)](n[l(982)],w)}else!_0x177399[l(531)+"d"]&&(this[l(711)+"er"]&&_0x26ed20[l(1247)+l(348)+"ner"](f[l(867)],this[l(1445)+l(1088)]),this._isBrowser&&_0x4fc494[l(1247)+l(348)+l(1379)](f[l(312)],this[l(1445)+"ageShow"]),this[l(1128)]()),this[l(711)+"er"]&&_0xb93160[l(1247)+l(348)+l(1379)](l(872),this[l(403)+l(321)]),this._isBrowser&&_0x259e16[l(1247)+"entListe"+l(1379)](f[l(1136)],this[l(403)+"ffLine"])});So.set(t,i)}function g1(t){Ao={KqEZf:function(i,o){return i(o)}}[M(394)](t,Ao)}function m1(t){let e=M,n={VbtgF:function(i,o){return i(o)},beqka:function(i,o){return i(o)},zdXdQ:function(i,o){return i(o)},NINqt:function(i,o){return i(o)},bbbkV:function(i,o){return i>>>o},Myfhj:function(i,o){return i+o},YfSTI:function(i,o){return i&o},GXMbE:function(i,o){return i>>>o},Mbzxo:function(i,o){return i+o},TztRs:function(i,o){return i+o},YWCYC:function(i,o){return i&o},BbQxj:function(i,o){return i>>>o},CkdUS:function(i,o){return i+o},nVbhN:function(i,o){return i+o},RexRs:function(i,o){return i===o},LFUJG:e(259),WMzgj:function(i,o){return i(o)},XZPRL:function(i,o){return i===o},ydWWH:function(i,o){return i in o},jxRBr:e(393)+e(880),vWHOL:function(i){return i()}};return n.XZPRL(t,IDBDatabase[e(1608)+"e"][e(511)+e(808)])&&!n[e(844)](n.jxRBr,IDBTransaction[e(1608)+"e"])?function(i,...o){let c=e,l=t[c(929)](n.VbtgF(qi,this),i,...o);return ed[c(558)](l,i[c(1218)]?i[c(1218)]():[i]),n[c(815)](zt,l)}:n[e(976)](x1)[e(344)](t)?function(...i){let o=e;return t[o(1530)](n[o(836)](qi,this),i),n[o(1636)](zt,td[o(167)](this))}:function(...i){let o=e;if(n[o(712)](n[o(1163)],n[o(1163)]))return zt(t[o(1530)](n[o(1039)](qi,this),i));{let c=_0x4db6fd[o(1408)],l=_0x1aafe7[o(738)];return _0x58bc46[_0xad2f6c]=n.bbbkV(l,24),_0x4fed74[n.Myfhj(_0x5acd84,1)]=n.YfSTI(n[o(925)](l,16),255),_0x1f0bdf[n[o(1319)](_0x3fd8e6,2)]=l>>>8&255,_0x128a48[n[o(1420)](_0x277404,3)]=n[o(653)](255,l),_0x5ddc5b[n.TztRs(_0x356f07,4)]=n[o(668)](c,24),_0x371326[n[o(1278)](_0x3f1a82,5)]=n[o(972)](n.GXMbE(c,16),255),_0x143876[n.CkdUS(_0x400799,6)]=n[o(608)](c,8)&255,_0x46fcab[n[o(809)](_0x4d1b26,7)]=n[o(653)](255,c),_0x9fbf52+=8,_0x450992}}}function w1(t){let e=M,n={WXcaX:e(948),BFFNC:function(i,o){return i(o)},rAxmC:function(i,o){return i(o)},cHxAq:function(i,o,c){return i(o,c)},ApgtW:function(i){return i()}};return typeof t===n.WXcaX?n.BFFNC(m1,t):(t instanceof IDBTransaction&&n[e(678)](p1,t),n[e(1158)](Fu,t,n[e(405)](u1))?new Proxy(t,Ao):t)}function zt(t){let e=M,n={HaCVx:function(o,c){return o instanceof c},rQpUF:function(o,c){return o(c)},EBaMR:function(o,c){return o!==c}};if(n[e(630)](t,IDBRequest))return h1(t);if(bo.has(t))return bo.get(t);let i=n[e(649)](w1,t);return n.EBaMR(i,t)&&(bo[e(558)](t,i),Io[e(558)](i,t)),i}var Fu,Pu,Ou,td,So,ed,bo,Io,Ao,qi,Nu=zu({"node_modules/idb/build/wrap-idb-value.js"(){let t=M,e={lgoPB:function(n,i){return n&i},aWXgA:"FImvM",nhuEF:t(1360),QjMWi:function(n,i){return n instanceof i},DWQub:function(n,i){return n===i},sqCJB:"done",oQqfH:t(393)+t(880),uSQVM:t(320),XqwbN:function(n,i){return n instanceof i},FQAjy:function(n,i){return n in i}};Fu=(n,i)=>i[t(884)](o=>n instanceof o),td=new WeakMap,So=new WeakMap,ed=new WeakMap,bo=new WeakMap,Io=new WeakMap,Ao={get(n,i,o){let c=t,l={HUoMf:function(f,x){return f|x},rPpkH:function(f,x){return e[V(481)](f,x)},bxXYA:function(f,x){return f>>x}};if(e[c(249)]!==e[c(552)]){if(e[c(780)](n,IDBTransaction)){if(e[c(422)](i,e.sqCJB))return So.get(n);if(i===e[c(823)])return n[c(393)+c(880)]||ed.get(n);if(e[c(422)](i,e[c(774)]))return o["objectSt"+c(880)][1]?void 0:o[c(393)+c(1109)](o[c(393)+c(880)][0])}return zt(n[i])}else _0x3369da[_0x460805++]=l.HUoMf(l[c(526)](l.bxXYA(_0x16a596,18),7),240),_0x503de6[_0x181011++]=l[c(392)](l[c(526)](l[c(1049)](_0x1286b8,12),63),128)},set(n,i,o){return n[i]=o,!0},has(n,i){let o=t;return e[o(162)](n,IDBTransaction)&&(i===e[o(583)]||e[o(422)](i,e.uSQVM))?!0:e[o(1254)](i,n)}},qi=n=>Io[t(167)](n)}}),Uu={};f1(Uu,{deleteDB:()=>y1,openDB:()=>_1,unwrap:()=>qi,wrap:()=>zt});function _1(t,e,{blocked:n,upgrade:i,blocking:o,terminated:c}={}){let l=M,f={PjizV:function(w,v){return w(v)},yezFb:function(w,v){return w(v)},ZILPQ:l(883)+l(1097)},x=indexedDB[l(1558)](t,e),p=f[l(1580)](zt,x);return i&&x[l(141)+l(136)]("upgraden"+l(214),w=>{let v=l;i(f.PjizV(zt,x.result),w[v(1389)+"on"],w[v(593)+"on"],f[v(210)](zt,x["transact"+v(808)]))}),n&&x[l(141)+l(136)](l(1115),()=>n()),p[l(1336)](w=>{let v=l;c&&w[v(141)+v(136)](v(1128),()=>c()),o&&w.addEventListener(f[v(1457)],()=>o())})[l(1576)](()=>{}),p}function y1(t,{blocked:e}={}){let n=M,i={bpEpg:n(1115)},o=indexedDB[n(185)+n(201)](t);return e&&o[n(141)+"Listener"](i[n(903)],()=>e()),zt(o).then(()=>{})}function To(){let t=["AMDZz1y","DxbKyxrLq3u","BKPWv2W","yxbWBhK","AuLUDhC","vfnxzee","uKHHswu","r2zkz0O","A0XHv2S","yMfSu2nVCgu","txP6DfG","AvfAt2i","tKf5D3i","EgDvvhG","rvffBNq","zLbut3e","zv90Aw1LB3u","zuvwre8","q3HruuK","EgvmuhK","zwnst1O","EKLfwe4","C2v0u3rVCMe","C2XbC3K","x29WDgLVBNm","DuzMAg8","D2rqDNG","AxnFywnR","A2L0zKe","CgviCLm","DNnHuuC","B3bLBG","tfvlvfu","BhDhChm","B0vmCgy","Dfr4Awi","qNzKuve","r0PMDgW","C3jJ","vLHyvLy","zw50zwqGDhK","BNnUv3G","uKP2ue4","t2rzC0S","zxH0zw5ZAw8","DhbRBfi","z0DtuvO","DNn5A1e","AxnmB25N","y2f0y2G","sKjgruS","x2rItMfTzq","B25tDg9Wsw0","ugPPELy","B1vqufy","q29KrMm","C3vIC3rYAw4","x2LUAxrqCM8","AwPcBve","zLvNyxu","A3rbqKy","uMXvreO","q2Pvv1K","BMr5Dwi","x2rPC2nVBM4","sNvmrNC","zNjVBuHHC2G","Ec1TC2CTCw8","C2vUza","tvntEKK","Ahr0Chm6","Dg9cExrLC0i","yNL0zxm","Ew5WBMW","uuXfvLq","wevurvi","C2PxueW","sNjgu1u","Dufzz3a","EKXIChu","yxLyv2O","ChjVDg90Exa","ww93Eu8","B3bLBIa","Aw5PDcbrB1m","CMLLC0nVDw4","Bwv0Ag9K","y29UBMvJDgK","ALzsvxe","BxjtDxi","AxnbCNjHEq","Aw9Zrg8","y1vctLm","C3bSAxq","C2vUzf9Hy2S","yKvkrem","sMfHz2C","rKvvBeK","CgLUz1rPBwu","D1HUBLO","mxW0","z2vjBMzVu3K","q0LHCgm","yNvMzMvY","m3WWFdj8nhW","CwvmreS","ywDLrxzLBNq","ChvZAa","uNzMugW","tKLoCxq","q3zyCva","BMrLEa","r0P0zMq","Aw47y2HHCNm","Ee1TC3q","q3vZDg9Tq2W","yMfJA3vWigu","whjUsw0","wgXuENu","BMrWB2LUDca","u1jPzKu","veH5s1a","D0jXwg0","uufgs0K","CKHWzeu","sNLZzvu","BMDLza","AwXLtMfTzq","uLDbA2y","vxvcExm","t1DIzuG","Aw5Lza","y2uGBM90igK","A0n4AMu","rxzLDK0","vMHOC08","tgLZDgvUzxi","yM9L","BKXMA28","B2LcA3y","vLHYEhO","ywrKrxzLBNq","C1rRq2e","DMfSDwu","Aw1LCYbPBIa","qxvzDxO","r3neD2W","B3bLCNr5","D21Ny1K","qNjgzLe","zfvNsLC","y2HLy2Tszwe","ww5QDue","quXm","Be5ZyM8","x3nLCuLK","z2vtEw5J","CMvQzwn0","wLbSDxy","DgLUzYbZzxi","AxnrB1nnzxm","zgvS","whf3yK4","u0HWuwy","C1nlDNe","vvfXDfa","BuDozvi","z2v0","BfrPBwvVDxq","weDmtLO","yxKSig5LDhC","Dhnxz3K","DeLK","CgLUz0LUDgu","yNLL","qwzPBNK","B3nLrxzLBNq","x2LUDgvYDMe","rw5TA2W","ywDYueW","C2jIzNu","jMPZy2fSBgi","CMzbCu0","Aw9UvgLTzw8","DhjPzxm","zgvSzxrLrge","yw1LoIa","vefXCNG","oxW4Fdv8m3W","DxbNCMfKzw4","D3H5wwe","qK1oCxG","BvbRtwW","B0XPDvi","z2v0sxrLBq","q2DmB04","BennqwO","x2zVCM1HDeu","vMjnvKq","EvrxAuu","ywnRpwzYB24","DgfIyxnL","yMfdB2e","seLhuNK","C2DPza","zcbLCNjVCI4","uLzUtgm","rxDsyMC","DgvZDa","yMXqsgm","Ewv6rMi","ruHjCey","sgHUwfO","vxzNC3O","zwvKzwq","DxHWv3a","B25TzxnZywC","yMjWzNG","zNjVBuj5Dgu","x2LUAxrhBg8","yxnZAwDU","DLnrEem","x3vYBa","CMvWBgfJzui","rMrmue0","t2PWCNy","AM9PBG","Dgv4Dc9Qyxy","Cg9Av1C","rxjYB3jdB2q","z2v0qwXSs2u","CMvJzwL2zwq","uw5evgO","zwHWtvu","vxbKyxrLq28","yMLUza","EKLvyNG","v3bZzfi","yvvewgu","q2DqvNm","Cgf5Bg9Hza","AfbLt0m","zw5fDMvUDa","BxnNsuq","x3bYzwzPEa","C2v0zgi","qKPNteK","EvzIqw8","AuXmyM0","yvDyz0e","t3rhsKq","serRBxm","r3fizfy","BgLUzw5V","AgjgD1K","D2fZq2XLyw4","vgLTzw91Da","yNv6r04","AxjLza","q0LKDMy","AMPYBKy","x2LUAxq","DeTyyuS","BwLbAgy","D3nZoI8V","zw5HyMXLuw8","zuDVDwy","B1zgAKq","CMfTugfYyw0","B3vluvm","B25JBg9Zzq","qMnwwMO","v0rZwu0","CLbpuMK","CMvHC29U","weLgvMq","BM93","z1jwAgm","zxjFDhrS","A3v1Bwe","ALvTsNi","ihrPBwvZ","AMv5ru0","zMLN","x29UtwvZC2e","yLjOywy","zMzOCfK","ChjVy2vZCW","C2vYDMLJzq","CYbWyxjHBxm","zwn0","DgLTzw91DcW","whH4vxK","ChL0B1y","AwrI","Cw9Zx18","yMfSrxzLBNq","zMLSzw5HBwu","yMD4t1C","y29UBMvJDca","qxHKAK0","CM92AwrLihC","wuHYwxG","z0Disvy","EK1ADK4","DxrMofDYAxq","tK1yExO","tvnyvLC","x29UrxjYB3i","z3fRrxG","zxjYB3i","C1PyzLu","swfuEgK","x3bPBMC","x2jPBMfYEvq","BvrTDuC","y29SBM8","ihn1y2nLC3m","CM9YrxzLBNq","DxjS","C3rVCMu","BKXPBMu","A2nsu1y","BgvY","ywX3yxLZ","q09otKvdveK","sKXYuvK","sMDcq2y","AMvJDfn0B3i","u3rYyxrLz3K","rKLhsvi","x3DHAxq","Cgu6ia","AvLlCK4","B2fK","C2v0sxrLBq","B2nbrvK","CgfNzwHPzgu","v3zSD2G","qwP0vwy","B25fCNjVCG","DhjPBq","CxD6uwq","wgnKy2W","Aw5JBhvKzxm","tu9rweu","we5YBhC","ywnRtxnNswq","zw50tgLZDgu","Cfjiz1i","verwEgq","zgvMAw5Luhi","CNzHBfzHBhu","wgzRuKe","Bu9Mzem","lcbxzwjtB2m","A0Pbzvy","AenSB3nLrxy","CMvZzxrdB3u","C0nVDw50zxi","tufJsuW","ugfhuwS","rfDMu2W","z1LLuem","y29kDei","qNjPzgDL","t1bftL9fuLi","BNvTyMvY","AuHmvfe","CNnVCL9Uyw0","DgLTzw91Da","EgjnEeW","yurMExa","rgfZsK0","Dw5dqu0","sLvKwLK","mujVzMDjqG","re5izMe","DLjjALq","t1L1tLO","CMvKDwnL","EwnYzeW","DxnwqNe","x21LC3nHz2u","v1rwuey","x2LZsw5PDa","EuTXuhK","BgLZDgvUtMu","seLSAMS","AxrYs1C","zgLZywjSzue","rg5bs1G","sfvVtwy","B2jQzwn0u3q","s3ffwMy","BwvvCey","nJa3mJaXnwfREuHTDG","u3jAAvi","C2nYAxb0","zNzbr0e","AfDivw4","C2XPy2u","BMfTzq","x2HHBMrSzu8","zeX1sfG","qxbNDfC","DxvmBuK","vgTbzvy","y29UBMvJDeu","ALPOy3u","qunPrw4","CxHNANi","D24GCMvHC28","CMTLCKDSB2i","DcbSAw1PDa","zgrjrcWGzgu","zxjFCw9Z","C2T5qKO","y3jLyxrLt3a","rgXwDKS","B0PLq24","DvPXB0K","rfDrDwi","B25LCNjVCG","x3DZsw5ZDge","tfDkrLq","ign1CNnVCIa","ze9Tu0G","y29UC3rYDwm","rxL3z0O","x2fKzfDZtgK","CgfYC2u","rgXyt0u","v0DWu1K","t3DZu2i","CMvTB3zLq2G","BMDuAw1LCG","sgvoBhu","y29Uy2f0","uhvvB3u","tKDLuM4","u2rcuu8","wvjfBwS","B2nRzxrgywK","s2XjBhi","vLPgsNm","rvzKEgy","DMvUDa","q1LVCeC","C2vYDMvYvgK","v2jICM4","C3rYAw5NAwy","Bg9N","C3rVCcbPBw0","DxrVuMvJB24","tKfusvzfx0u","qKzfAeG","vKDWrMO","tg9Nsuq","CMvZzxrfBMq","qKjprxC","ELLSy2m","B25pCgvU","sKXeBfa","x2n1CNnVCKy","zMPUvvm","zw5NDgG","BwvZC2fNzv8","BuLiuue","yxv0B21HDgK","x2HHBMrSzvi","D1HLz2y","DMLJzuLeig8","DKfXBwC","t3bLBKv2zw4","uvfmz1y","CMvZzxruCMK","ChjYr2y","AeXrv2q","qxrIEMi","rML4EwW","BgDVuei","uezvr0u","senmq24","AxnAzxjV","vxbVAKK","t0DtAMi","BLrkre4","u2vXsuq","Cgf5Bg9Hzeu","ywnRDxbfBMq","BwvZC2fNztO","z1zmtKK","zvLps1u","u2vYDMLJzvC","vw5Oyw5KBgu","mxWZFdj8nNW","zNPsvuy","D1n3ANm","y3vYC29Yx2y","B3nLza","q25ZvNq","D0j0Du0","wKPmsg8","BIWGAg9ZDg4","qwjjEfO","rhnst1e","uxHsENK","zxjFBxnNAwq","C3rYAw5N","zK5StLC","DhjHBNnHy3q","EePHyLi","u1HWB1m","vePuzw0","BgvUz3rO","Cerzzg0","wLDkrwq","Dg9tDhjPBMC","AeDJzgO","BwvjD20","r3zUuMe","C3b3q24","AMjMyui","BM5Ly3q","Axz5qMC","CLbWA0G","Bwu6ia","wgrXvMS","zw5HyMXLqxu","zKPQrwK","CgvYC2LZDgu","Dfb0sK0","x0rctMfTzq","EgHVwhe","ywXSq3vYC28","rePks0S","zNjVBujPDhm","qK1Az0i","rfDoweq","B25VCgvU","u2TPCcbWyxm","DuXHrhC","ufjZA2e","ug9stui","A1vJqwi","yMTtAuW","qw5bqwO","zxjHDg9Y","wKnSB24","BezSDxnO","qvnpv24","BMH1ruy","ChbL","BMCGB3iGyw4","vw5PBxbSzw0","n09iwuTbta","zw5JB2rLrNi","C2v0","sKHkChu","Dg9mB3DLCKm","nJeWotuZm09xqLzOuW","CNjVCK1LC3m","qMTNreG","tuLiseW","l3DZl3yY","zuHft1G","s0zsv0q","Aw5KzxG","CxbWAvG","A09XtuW","z3r5Awq","yNL0zu9MzNm","x2DLBMvYyxq","yNnKtgK","x2rLC3rYB3K","AuvHyu4","aaaaaaaaaaa","B25szwnLAxy","zgPfs0O","BM9Uzv9UB24","Dwves0S","sxjPsuS","C3fdsKi","q2Dove8","BxnMrxi","z2u6ia","rvjst1i","zxjYtxnN","rxzLBNq","y0r4qvq","u2nqzgq","qKvcuxm","BMv3vMvYC2K","B2zM","CgTcBMG","vNbTwfe","B2LUDfjLywm","x3bHDgHlzxK","CvHZtKW","vwX0sxK","BLLhueS","vu10ENa","y1DcveO","r2nWvMe","CM92AwrLige","zcWG","zwrPyxrLBhK","yMjIA1y","DwHUsNC","uvLgB1C","AKT6Dg4","igzHAwWSig0","qLDWqxm","ze9IDxK","BgjxELe","tvrtuuq","mhWZFdj8nhW","z2v0q3vYCMu","x29UvgLTzw8","C1nrA0O","uw5qqKC","vgDWqMy","BMnVzgLUzW","r0rztNi","BwLUAvbYB2C","Dhn1Egi","AgfZ","shf3y0m","nxWXmhW3","sgfdvNG","Cg9PBNrdB24","CMvWBgfJzq","vM9Jz28","qwnJBhC","Ee5XDgm","x2nSzwfYugK","qw1VDw50","y21Usfy","ExbL","yMLUyxj5vhK","tuvtu0fhrv8","BNrbBMrvCgq","B3bLCNr5tMe","sgzIA3G","zMLSDgvY","zgvJB2rLzey","v05XzeC","zLris3y","CLfWvuy","ywTlBhO","Dg9oDw1Izxi","q3HPrva","wvDdwum","m1vRy21Xra","vufvELa","yLrvEue","veTxBNO","CMnrvum","CgfNzxnOB3C","z2vrDwv1zuW","CIb0DhDjra","Dgv4Dc9WBge","tNHVuNC","t0LlrNO","CeXlDu8","rKPOAhC","r1rLEw4","qMjrEgO","zvnNDM0","sKT3s3G","x25HDMLNyxq","A3bXBfm","Bhm6ia","DhDVCMTdAge","qu1JvhC","wfPeu3m","Dg9iyxnO","CKf4Bum","zKDqs1O","u2nquxO","AwDHDg9Yt24","C2DTrxi","zw5mCgW","qM5rru4","C2v0q3vYC28","sMjKv3C","v3b6tNC","vLfVrxG","AffUEwK","igfYCMf5yNu","BKLxywe","sfjQAgi","qw9zsMe","D3v0uNa","rKTQwKq","sgHMt2m","tNzHq0u","BgfVCwG","whrsDKq","zNjgwNm","B2vHq20","CMvUDevUzha","y2XLyxjtDg8","uMvHzcbWyxm","txbIDLC","Ec1TC2CTy3u","vhHxBw4","ywjVCNq","x194x21Zz18","v0PkquS","x2LZqNjVD3m","uMv4uNm","DMfSDwvZ","rfH0zMe","A2v0ignVBNm","C3nHz2vfDMu","rxnAvhq","D1bSDei","C0Xf","ALLUrhi","Ahr0Ca","Aw5N","Dg9Y","CLvZzLa","y3jLyxrLrxi","DgPTz1a","qNrYq2W","CwziD1K","y3vYC29Yx24","BM90veK","DKP3CLK","Axnby2TdBgu","x2rLyNvN","mZG5odqZnefzANbIDW","zw5XDwv1zq","B2zMBgLUzq","q05sv0m","AgLNAa","D3jPDgu","y2XLyxi","Avf0Deu","AxvgvMK","CgLUz19VBMm","z3Hzthu","BfnqyMO","uvP1z3a","B0vns3K","zxmGCMvHy2G","y09Wzw4","t051shq","v3HmrLy","zNjVBu51Bwi","C1ngwfe","x3bPBMDqB24","t1bftG","zxH0ugf5Bg8","tfzcqwO","qNvhquO","D1fyDve","r2Prwxi","B3jpBMXPBMu","v1risgi","rKzsveu","Dg9cExrLCW","C3bSAwnL","CMvHzhLtDge","CgLUz09Uy2u","CMfUzg9T","Ahf5yNm","x2nSzwfYvgK","vg96we8","CfflsuC","zgvIDwC","DvnrvK0","yNvMzMvYzwq","BwvZC2fNzq","BfLhCfu","qur2sge","zxjFCw9Zx2e","uwPnv2K","CMvJB25Uzwm","zMnczey","A05ewKi","BLLnqvy","Du5jvwW","txrQv3q","Cgf5Bg9Hzfq","Dg9hzw5LCMe","sNvSCey","qMvUCwK","ywr2yw5Jzq","Evbwwu4","D1fpDfO","y3vYC29Y","x2nYzwf0zvm","z2Xru04","BNrfBMrWB2K","Bu5uu0W","mNWWFdr8mxW","DMfS","x2vUzhbVAw4","B3v0sw50zxi","q3PwuKq","CvbysKG","Dw5ZAwDUzwq","v3HAwxC","yu5fANy","Aw9U","BLzIAe4","yvvWEvy","BMnLq2XVC2u","B2Pqvgi","y2HHCKnVzgu","y2HnyxHdB3u","yMvXA2e","s2r5BgO","x3jLywr5q2W","ExfTr3O","z01xAuC","CMv0CNLdB3u","yK9hBgS","zMzLCG","B1fXzKG","q09oveLovuu","Cg9PBNrbBMq","CeHfwhG","Ae1LC3nHz2u","qKfiz2m","BwLZzq","CfnjEK4","C3zvC3C","zw5KCg9PBNq","rNjVBNrPzxi","y05QEMS","A1n0yxr1C0m","EMryzfe","rLjptLrjrvi","C2HPzNq","D0Dowuu","EvjLy29UBMu","reDkAhG","Aw9Ul2PZB24","u2XhyMW","Ewrxv0G","y0rvsxy","nNWXmxW5Fdu","qLzbs28","r09nuge","DgLLCKPtt04","ihrPBwvVDxq","mNWXFdr8mhW","whD2su8","Eu9TCuq","q3DwuNa","ywzL","yvv1C0y","twLZC2LUzYa","rfHjsgS","CMfTzq","y1nJre8","y3vYDMfSDwu","rxLnvxG","zvvYBa","senosKq","qLD0CxK","oxWYFdH8nNW","qMfgru0","BMv5Eha","wxfnAuK","r3Hnwfm","B25mAw5L","B25SAw5L","rg5rALy","q05rD1a","v2r5Cu0","zNjVBNrPzxi","y29UBMvJDa","uLjpuG","EKX4zLu","B3jLtMfTzxm","y2vHywG","wuvnshG","DMvYC2LVBMm","C29Tzq","Au9lEgG","AuDJzLy","y2HLy2TdDxi","s09tyLO","vwnJCKK","sLDwshy","DMD2u00","Cu1Pzw0","uuXtDwW","tg9NsurozxC","uw9ADfy","sMjnv1e","wgLnq2O","Be5byxC","yxbWBgLJyxq","rK1Hzei","Bxbcweu","C2zHDu4","yNbfCgC","D1rwshG","qMHAr0C","BwLUzW","EvjezNq","z0z6qKK","uLjhugC","u0XyC0C","ywWGy3vYC28","rwrTwMm","Cxbptfi","ihzHBgLKigq","u1Hvzwm","Auvvz3y","twDNEK8","BMrWB2LUDfq","yw5Hz2vY","s2XdwKi","A2v5","AxnszwfKEq","C2vYDMLJzs0","y29TCgXLDgu","r1HnyKu","DLv1Afq","C0XPC3rLBMu","x2n1CNnVCK0","y2fSBa","AvrMvfC","t2z0ChO","Aw5KzxHpzG","v3r6ruq","zxjFAxnFywm","B2fjuLe","yw1Lu3bHy2u","uM5mu0C","wNrcuLe","Bwf4tg9ZC0m","tw9KDwXL","sNzLvKC","Ae9Wzw5fDMu","yw51Ce1LC3m","DunJwu4","rgDTDgq","Fdb8mxWY","AMnUDKG","zNvUy3rPB24","zNPZsMG","t0fqDLK","rfveuNC","EK11Dxa","vMvmBfu","EMLktu0","ywvKCMe","q3vZDg9Trxi","u0XWuNi","zLnbCNi","Dg1OquW","sxjoz2K","D1nOr2q","uujPt2O","A0jXsvC","q0Xpu0ve","uxz0t0K","wujmqNy","Bu9ivwS","y1vrDvO","B25nzxnZywC","sw5Huue","ChrAAKq","wwztveK","wLf5ru4","wKnHruG","t1bpDwm","DLDit0W","CuDLyxC","De1HBMfNzxi","ufDiz1i","Dhfpsu0","BeP2yKu","vgjsANq","Bwf4twvZC2e","B2zMC2v0","zgv2AwnLx2K","tgXcBxC","Eu90zeq","swjuzNC","B2nRzxq","qujYCMG","z25WA2y","ugfcsLi","wevhsK4","wwjmvLO","y29Kzq","rLrsuK8","zKjtDgO","teDTy1C","zcWGDw5RBM8","BwPACvq","s3bMsfG","nhWZFdy","zMLUza","s0ThwKq","ELfmExG","B3bLBKrc","sxPZEMy","sKPoEgu","CNnVCKzPBgu","ywnR","AhrwwfG","Bhzdt1K","ndGWmdG3mLLxDM5nzq","ohWZFdf8mhW","Cw9Z","ywDLu2HVDW","D05JDKi","B25ozxr3B3i","x19LC01Vzhu","AfbZD3G","z2v0s2v5","AgvHzgvY","yxGGCMv0CMK","ChjZzMm","x2XPC3rLBMu","wMrjyuS","AgHLqK8","DhjQtMS","Cgn4q2y","C3fLqKC","x3jLy29UBMu","AhPgqLq","vezMtNe","y2XVC2uSihC","zw5JB2rPBMC","q29Kzq","BM1xyMK","Dw50","v016z2O","x2TLEvbHDgG","x2n1CNnVCK4","o2nOyxjZzxq","y29UDgLUDwu","AgvKtwf4uMu","CMvZDwX0","B3jJrNm","yxv0BW","BeP5wfy","yNHywue","C3rLBMvYCW","x29UugfNzu4","sKX1DKy","otCXmJKZmgDYD1HLEq","Bg9NsurozxC","x2LZtwLUAvC","vfnqzuy","thP3zxe","sLPAEuG","ugDVCgq","zKXWy2S","Cg93","zwnVBM5Ly3q","y3vYCMvUDeK","sKnnAMS","ignVzgu6ia","BMCGzMfPBgu","B2nRzxrtDwm","zLvZD1O","zNzMtey","t2PSwLq","BKTQuKW","zLzWywy","DLrowfe","EfrJuMm","x2rYB3bhBg8","ihrYEsbYzwm","yw1L","rKnKBhe","ywnOzwq","qxfzuxu","y3jLyxrLq2W","zM9Yy2u","t2jQzwn0","x3bYB3rVy28","BML0AwfSAxO","ywXSB2nvBNm","z1rPBwvVDxq","ywDLsgLKzq","y3r4","DxnLCKLW","u3PPzeS","ruHgD0y","mJu4nZKZmKrbwKXmtG","id4G","su5tvefova","AgfZt3DUuhi","AgfUz2u","rxHbue4","BfzfzxO","wKvpveS","t2rAEKu","AevYCM9Yrxy","zw9Yq3G","sLvwufi","zgLZCgf0y2G","r2TyDhm","ruzLBKe","v1DAz08","B3jL","y1bqtuS","uhL6y1C","CMvHzfvjBNq","DgHHBIbSB2m","tufyx1jfvfi","yMXVy2TLza","ig1LC3nHz2u","AhfLB2K","y3ruAw1LB3u","x3nVy2TLDa","Dgv4DfbHEwW","ywnOzwqSihC","Bg9IywXty28","yK1PtKe","AvzMv3C","CLvMEgW","zw50","CNzHBa","y2XVC2u","BNruCMLLC0m","zuHcsMG","y29UDgv4Da","igXHCMDLCIa","t3Dswwe","EfvZzuvUDG","z3fmr3C","v2jTBMG","wfnbCwm","x29Uq2XVC2u","ENbqthO","wffRvhm","DhbizwfKzxi","D2LSBfjLy28","D3fIueK","y2vZC0HHBMq","yxnL","CMvZB2X2zq","wgnmreO","rKzgCeq","Dhvvtu8","AvrKAe0","tfr6ANa","ELP5zva","u1LkB08","Ef9MCM9UDgK","zefOswS","Bwf4uMv0CMK","ze1zuKS","y0H4qxe","zsbHihn0CMK","CNnVCL92ywW","Dxrjza","C3rXC00","tezvsKC","sND1Cg4","wfDfs3K","s1PlCuG","C2v0y3vYC28","t25mvLK","tKjhuKC","BuXZCgW","vMHHyvq","r1vdAe4","DgrUrwO","BhrPCgXLihq","x2LZtwLUAvq","swPvCeW","Dw5KzwzPBMu","wfflu0m","DwTTr0e","CMvXDwLYzwq","mdaWmdaWmda","zxHWB3j0CW","wvvqwhq","D2vI","uw1zwLG","tMLRwe8","reiGzMfPBgu","swzXvNe","AfnYAxa","Du15reO","B25tDgfYDfi","Bu1yzNm","weD3zNa","tuTqCey","s1z5ze8","C0zAv1C","zhbizuu","DhjPzxmGCMu","Dhj1y3rVCIa","x2LZv29YA2u","qxHgzhy","CKndCwe","v1LTrNy","Duv1s0e","yKTfD0K","BNrLCG","z2vY","qLneC3u","whvHA1G","zMX1C2HfEha","rg9Jt3C","CuTIq2K","BK1dqw4","y2XVC2veqG","C3vIyxjYyxK","zNjVBunOyxi","qLngDgW","C29YDa","x3fVC0rc","tuPUAuW","vvDLyxO","x2LZtM9Kzq","ruX0q1a","seDgu2S","sgr4u3C","EhjgsvG","sLnptLa","z2v0u3rVCMe","BvbRAKO","wLvkrMO","AgvHzgvYCW","rMryEuG","x0vysvnu","zgTcyNm","r2Psru4","x2rPC3bHDgm","yLfWv3e","D0HnvKS","q3P5sgu","qxPbv1y","rxbQD0S","Dwz0sui","zLLnyLC","zg9Uzq","y3vYC29YlNm","yxrPrue","CMvTB3zLrxy","yuDXCNe","s1j4Dvq","u2TtB0O","BM1Uyve","z2n6Dgy","ww1szhC","rLfbANK","y3vYCMvUDeu","t2zWqwu","wuDsvvm","zMzmAw5L","wLPxvNy","ywnVweW","Chv0","y3jLyxrLtwu","Aw5L","zxjYtM8","swfXCgi","Bg93Axe","q0vssLi","x2DLDeLUDgu","uvz3Ehm","Bg1PDva","x29Ut3bLBG","wgXkz28","BeHHBMrSzxi","zwnjuLi","v1PtA3O","lcbTyxGGCMu","ywnRx2LK","txLMAgO","BxnN","igzPzwXKoIa","ywXS","BwvY","BMHXrLa","u0Ljtu8","q29UzMLN","quTmy28","CgjICdi","zw5HyMXLvhi","tKz2Dge","A2v5CW","C0jf","D3m6lY8","svndCg0","Berkuhu","zvfyrgK","ywrKt25L","DgrZA08","suvtx0vsuK8","B0TdsgW","sfDWD1y","Bg5gtMS","ywDgBKK","y291BNq","BgLTAxq","y0HjsMC","wevduLi","ywrKq291BNq","CfzIBwe","uuviru0","Dev2zw50","A2zrywy","CeLstfy","zu94wfy","zKzczfC","uerzvfa","v2vIu29JA2u","r2fXugG","CuLABxy","twj6Eg8","ELblC0u","ywDL","AxnrB1nby2S","y0Dkwvq","zxrxB3jRq2G","u3fyzuK","rgvKAwnHDgu","x1fVu01HBMe","tvfuyxG","ELnIrhq","EMjnsg4","ywXPzcb1CMW","teHzshm","zgf0yq","z2v0qwXS","wMHMq2S","DgHLBG","zvHorwe","CYbPBNn0yw4","twzJyNC","Dg9VigXHCMC","tMroBgy","AvPxvKy","zg9iC1m","uePoCMu","B0L3Dwe","AKnkEvO","BeHwAg0","x21PBMLoyxy","zxj2AwnL","s3fhChy","yuffrg0","sxfsy2O","vwfurhu","zv9ZDwnJzxm","pxv0zI04","EM5Ls3C","EuLcz1i","BMCGDxjSoIa","qLPcwgK","yxbAuvi","sxz1zge","B3vUDa","ihbYB3rVy28","yxrLq291BNq","BgLUzq","vhrTywm","zLvrBuy","uxvLDwu","rfzcsuO","z1LvAwO","ChPuwuO","wevAwNu","DgfYz2v0","zgvSzxrL","r2HWzvG","Efrurw52","BMjYCe0","y29UBMvJDfm","BMvY","ELjUwNi","vgfN","yM9KEq","CeLovu8","AwXK","uMvJB25Uzwm","qNLqt0q","DvDHs3a","vKTRy3a","B2XKvMvYC2K","y1HvEwm","twvZC2fNzuu","vLjPELe","v2LUzg93","qwjVCNrfCNi","DKDdzhe","ugHKDui","vgnwuuq","ufvnufq","tfrmEMu","wu52tvy","CvLPBNG","sLHpCxy","y3jLyxrLuMu","qLDAAeC","EunAzfy","CeHHwM8","CM92AwrLigi","Bg93","AxP4uha","CgXssvC","tKTbsNy","Ehbqq3y","Dg1TEKW","BMv4DcGPigm","swzKwKO","yMrFzgLK","ugHdzui","y2HnyxHuCMK","yw5Nzq","vhP0uNm","yNL0zuXLBMC","x3bPBMDmB3m","uLDRtfC","D09iyKm","lcbOB3n0BMe","C05crfq","v015DgO","rMHlvwm","A1H1Cvq","AuLIrMm","y3jLyxrLrwW","mtG2mZq4nhLdAw1fta","ufDRDfu","vw9NCMO","z29PBMCGyxC","DhLWzq","zKjJy0y","sMXNtNq","t3v2vKW","C3vJy2vZCW","qxLhs1e","v3ndBLi","sePTvxC","Cu1LCNm","x2HHBMrSzva","A1rxzLG","zNDZxZeUmc4","C2fNzq","verSww4","tg9JAW","rLDt","CLHnyxa","rg53BNC","x3nLBMrby2S","r1P4Cgy","Dg9cExrLC0W","wKLmufe","zNjHBwvuExa","rKfbuwC","wNzWtuO","wfzoAeq","wfjwvNK","ywXty29Wzq","sgLlAgG","rLvYB0K","Axf1BvG","Afviz2q","DeLUDgvYy2u","tg1VEfe","zM9YrwfJAa","AwXLx25HBwu","CYbHBhjLywq","x3DZ","sffxCxe","AeTxzLq","CKHrq1y","mdaWma","DKfrEe0","CgLUz0XVC3m","AefJA01LC3m","sxbsyMu","zw1PDa","t3zYB0G","yuHlq0W","D2j0su4","uwnduuy","DKjuwKK","wMv3BKO","DMvmD1e","ChjVDg9JB2W","AKrYwMy","DwDSCve","BwDrDuS","Dhf3B0u","DMvY","z2DsvwW","shzdy3m","CMvHzhDYAxq","ugD2Bgm","su14B20","ChrVCG","D1DNtfy","yufpBgO","Bg9Nsurhzw4","x3jLBw92zvC","DgrdBeq","A2Xxtui","CgXLyxnLiha","zfDVCMTLCKC","qKL5y0i","Fdj8nhW3Fde","wujvCLm","x2nVBM5Ly3q","u0LMueG","sfnzqMq","rMT5BMm","Aejotfe","CMHwtMe","rKLmrv9ot1q","zufJAW","yMfqr2K","tMfTzq","ANnXsue","ywrK","seTtwgm","uwr1Bgq"];return To=function(){return t},To()}function Mu(t,e){let n=M,i={ecIRR:"readonly",UltIy:function(x,p){return x instanceof p},aHKCL:n(509),DXIHk:function(x,p){return x!==p},ZUJFj:function(x,p){return x in p},iYKrN:n(145),XtRvD:n(852)};if(!(i[n(600)](t,IDBDatabase)&&!(e in t)&&typeof e===i[n(1484)]))return;if(vo[n(167)](e))return vo[n(167)](e);let o=e.replace(/FromIndex$/,""),c=i[n(858)](e,o),l=Hu[n(344)](o);if(!i[n(1230)](o,(c?IDBIndex:IDBObjectStore)[n(1608)+"e"])||!(l||qu.includes(o))){if(i.DXIHk(i[n(333)],i[n(699)]))return;this._isMiniTT?_0x5a9e13[n(1018)+n(835)+n(1097)](({isConnected:x})=>{let p=n;this[p(1348)+"igatorOn"+p(1365)]=x,x?this[p(403)+p(321)]():this[p(403)+p(1258)]()}):this._isMiniWX&&_0x545a1f[n(1018)+n(835)+n(1097)](({isConnected:x})=>{let p=n;this[p(1348)+p(681)+p(1365)]=x,x?this["_handleO"+p(321)]():this[p(403)+p(1258)]()})}let f=async function(x,...p){let w=n,v=this[w(511)+w(808)](x,l?w(1498)+"e":i[w(1274)]),T=v[w(320)];return c&&(T=T[w(568)](p[w(838)]())),(await Promise[w(1281)]([T[o](...p),l&&v[w(1244)]]))[0]};return vo.set(e,f),f}var qu,Hu,vo,E1=zu({"node_modules/idb/build/index.js"(){let t=M,e={ZQyEN:function(n){return n()},DnQjV:t(1334),JkLSd:t(230)+"ys",DNHfa:t(1303),zMZvN:t(1261),XfcPE:t(1524),Afiny:t(1374),FCdlq:t(740)};e[t(973)](Nu),e[t(973)](Nu),qu=[t(167),t(1021),e[t(873)],e.JkLSd,e[t(377)]],Hu=[e[t(304)],e.XfcPE,e[t(175)],e[t(1078)]],vo=new Map,g1(n=>({...n,get:(i,o,c)=>Mu(i,o)||n[t(167)](i,o,c),has:(i,o)=>!!Mu(i,o)||n.has(i,o)}))}}),b1={idb:function(t){let e=M,n={RVnLc:function(i,o){return i===o},lNsbo:"zdNXd"};t.exports=Promise.resolve()[e(1336)](()=>(E1(),Uu))[e(1336)](function(i){let o=e;if(n[o(206)](n[o(154)],n[o(154)]))return i;throw this[o(1513)+o(1450)]=!1,_0x145211})}},Bu={};function Bt(t){let e=M;var n=Bu[t];if(n!==void 0)return n[e(1182)];var i=Bu[t]={exports:{}};return b1[t](i,i.exports,Bt),i[e(1182)]}Bt.d=(t,e)=>{let n=V;for(var i in e)Bt.o(e,i)&&!Bt.o(t,i)&&Object[n(351)+n(147)](t,i,{enumerable:!0,get:e[i]})},(()=>{let t=M;Bt.o=(e,n)=>Object[t(1608)+"e"]["hasOwnPr"+t(147)].call(e,n)})(),(()=>{let t=M,e={DsROQ:function(n,i){return n!=i},unMSd:t(1177)+"d",rcQUC:t(940)};Bt.r=n=>{let i=t;e[i(506)](e.unMSd,typeof Symbol)&&Symbol["toString"+i(1381)]&&Object[i(351)+i(147)](n,Symbol[i(518)+i(1381)],{value:e[i(658)]}),Object[i(351)+i(147)](n,"__esModule",{value:!0})}})();var ke={};(()=>{let t=M,e={BSDsu:function(a,r){return a+r},GjREN:function(a,r){return a+r},vsaQG:function(a,r){return a instanceof r},XGwfp:function(a,r){return a===r},QBiOj:t(1244),xJabR:function(a,r){return a in r},ZJLHo:t(1352),aNEjv:function(a,r){return a*r},XWEKy:function(a,r){return a+r},mPkjJ:function(a,r){return a(r)},CNRWC:function(a,r,s){return a(r,s)},DnAKX:function(a,r){return a(r)},pIRLV:function(a,r){return a+r},uCcYN:function(a,r){return a+r},NKAJv:t(1477),oJeCn:"ffff",CzyHe:function(a,r){return a(r)},GkXts:t(1181)+t(1181)+t(1181)+t(1181),nbrpM:function(a,r){return a&r},TDlYn:function(a,r){return a(r)},BMZgB:function(a,r){return a<<r},EvevM:function(a){return a()},yOtdD:function(a,r){return a(r)},ynpnl:function(a,r){return a(r)},qYinx:function(a,r){return a>r},lCMAj:function(a,r){return a<r},qMiem:t(282),FMadB:function(a,r){return a!==r},SRifE:t(1359),okIVX:"GfrVO",XIFVd:function(a,r){return a-r},mGNeR:t(1266),lHVhm:function(a,r){return a!==r},XEZZu:function(a,r){return a-r},ZewnJ:function(a,r){return a!==r},acoXL:function(a,r){return a!==r},JuLFw:function(a,r,s){return a(r,s)},wxyYa:function(a,r){return a>>>r},eGouf:function(a,r,s){return a(r,s)},vUuhT:function(a,r){return a(r)},pytoV:function(a,r){return a===r},cPPMK:"Missing "+t(1180)+t(1280)+t(921),Fhipb:t(857)+t(1180)+t(1280)+t(143),wqbPI:function(a,r,s){return a(r,s)},QoZtV:function(a,r){return a+r},FhKUc:function(a,r){return a<=r},ehpMU:function(a,r){return a+r},rPORi:function(a,r){return a!==r},iEUgv:t(687),TFfNq:t(952),lmiuP:function(a,r,s){return a(r,s)},qXsNL:function(a,r){return a!==r},wShGd:"oVONR",sNBDT:function(a,r,s){return a(r,s)},VhaaT:function(a,r){return a(r)},HGFSk:function(a,r){return a!==r},CxQQI:function(a,r){return a!==r},QnDTj:t(1506),oIwua:t(701),mTmuG:function(a,r,s){return a(r,s)},GJftl:function(a,r,s){return a(r,s)},cHIJg:function(a,r,s){return a(r,s)},sSFXQ:function(a,r,s){return a(r,s)},hheBO:function(a,r,s){return a(r,s)},rHpdE:function(a,r){return a!==r},frFZs:function(a,r){return a(r)},Enmkl:function(a,r){return a(r)},YUPXt:function(a,r,s){return a(r,s)},cScDO:function(a,r){return a(r)},iOKxh:function(a,r,s){return a(r,s)},UuBys:function(a,r){return a(r)},UMtzp:function(a,r,s){return a(r,s)},HvCcs:function(a,r,s){return a(r,s)},Qduld:function(a,r,s){return a(r,s)},msfEr:function(a,r,s){return a(r,s)},BMNqx:function(a,r){return a===r},yPVYN:t(857)+"required"+t(1280)+t(488),LHYHs:t(857)+t(1180)+t(1280)+t(458),dLuHX:t(857)+t(1180)+" field: service",BzoUE:t(857)+t(1180)+t(1280)+t(1613),MAcIL:function(a,r){return a&r},BtrCl:function(a,r){return a(r)},nYGPK:function(a,r,s){return a(r,s)},RlUDJ:t(555)+t(1567)+t(332),Jwupn:function(a,r){return a>>r},gVLNI:function(a,r){return a>=r},uMyDJ:t(541)+t(414),mIHQA:t(793),Uvgsz:"pkSvm",yqmGz:function(a,r){return a>r},kTWfX:t(704)+"t limit",JyseU:function(a,r){return a+r},ZhfCk:function(a,r){return a===r},neyxp:t(1485),wXegf:function(a,r,s){return a(r,s)},fPTOq:function(a,r,s){return a(r,s)},BnQEN:function(a,r,s){return a(r,s)},aDfyp:function(a,r){return a(r)},YEMHx:function(a,r){return a|r},Vocgo:function(a,r){return a<<r},izxPp:function(a,r){return a&r},FTRRO:function(a,r){return a<r},GUChN:t(203),NLIIp:function(a,r){return a(r)},DocOw:function(a,r){return a&r},uhnJw:function(a,r){return a&r},NFvta:function(a,r){return a<<r},iTdhM:function(a,r){return a|r},gGSQZ:function(a,r){return a|r},JLDlP:function(a,r){return a&r},QVwxs:function(a,r){return a<=r},CNQwP:function(a,r){return a(r)},iIntw:function(a,r){return a+r},bDWhg:function(a,r){return a+r},mpBXE:function(a,r){return a!==r},aAEDm:function(a,r){return a|r},WtzED:function(a,r){return a<<r},agFnI:function(a,r){return a<<r},oaIRQ:function(a,r){return a<<r},QQPUh:function(a,r){return a>r},MOQXE:function(a,r){return a+r},ZRwoh:function(a,r){return a(r)},kUcAb:function(a,r){return a<r},TxWmn:function(a,r){return a!==r},TEObY:t(353),peHrS:t(1225),OvroH:function(a,r){return a>=r},xpPCv:function(a,r){return a<r},cDxAT:function(a,r,s){return a(r,s)},kBqIW:function(a,r,s){return a(r,s)},JUVPR:function(a,r){return a<=r},JulpF:function(a,r){return a-r},oKCHl:function(a,r){return a<r},pRHgR:function(a,r){return a&r},UpojI:function(a,r){return a|r},NAywr:function(a,r){return a&r},gcztf:function(a,r){return a>>r},YREmk:function(a,r){return a|r},ijBmQ:function(a,r){return a&r},zYlcc:function(a,r){return a|r},XZDSs:function(a,r){return a&r},rHQCV:function(a,r){return a+r},fBStj:function(a,r,s){return a(r,s)},XQKSC:function(a,r,s){return a(r,s)},JlgNt:t(621),YbLVZ:t(1535),nsnWx:function(a,r){return a(r)},KZKqH:function(a,r){return a<r},enLpl:function(a,r){return a&r},CgPVs:function(a,r,s){return a(r,s)},AIFcq:function(a,r){return a|r},wPltB:function(a,r){return a|r},Mfcbw:function(a,r){return a&r},mrSur:function(a,r){return a&r},iTfTW:function(a,r){return a<<r},wiwBO:function(a,r){return a&r},EHFwF:function(a,r){return a(r)},BhZGG:function(a,r){return a<<r},dcjxr:t(1466),FFFpD:"OepVV",aedra:function(a,r){return a&r},laoqh:function(a,r){return a<<r},uAYgp:function(a,r){return a&r},UQqtP:t(1481),JZZyH:t(373),SLXsG:function(a,r){return a(r)},nMCAn:function(a,r){return a&r},aAOlj:function(a,r){return a&r},Pgvlc:function(a,r){return a|r},atiEA:function(a,r){return a>>>r},BvdQQ:t(743)+t(1543)+"t",JveVG:"timeout",veLwQ:t(743)+t(1354)+"s",deyfE:t(669),YmRdw:"jTtrl",zLxfU:function(a,r){return a>>>r},RWAkf:function(a,r){return a|r},BSFtl:function(a,r){return a===r},doHsS:function(a,r){return a===r},sqeBG:function(a,r){return a<r},ZvpMJ:function(a,r){return a<r},CjUWY:function(a,r){return a+r},wutRp:function(a,r){return a+r},tsuxb:function(a,r){return a!==r},GDYNr:function(a,r){return a&r},BWZhG:function(a,r){return a>>>r},ziJMM:function(a,r){return a!==r},nKjRL:function(a,r){return a|r},sjWPL:function(a,r){return a&r},gxYLu:function(a,r){return a+r},lbWzQ:function(a,r){return a&r},EFenA:function(a,r){return a>>>r},pQKIG:function(a,r){return a!==r},YnjuA:function(a,r){return a!==r},MSXVW:function(a,r){return a|r},pDYdm:function(a,r){return a&r},GZxpf:function(a,r){return a>>>r},hPeOC:function(a,r){return a!==r},zIUbx:function(a,r){return a|r},OIKFz:function(a,r){return a(r)},xeLPy:function(a,r){return a|r},GOMPa:function(a,r){return a<<r},rCCqa:t(310),WTVPF:t(1128),nmnaQ:t(1209),iVfWw:function(a,r){return a<<r},IbTfw:function(a,r){return a<<r},OGSjb:function(a,r){return a|r},tdskO:function(a,r){return a<<r},gMWiG:function(a,r){return a===r},FdLPM:function(a,r){return a|r},VRizQ:function(a,r){return a|r},OwsSb:function(a,r){return a<<r},tjmgP:function(a,r){return a<<r},CIapc:function(a,r){return a|r},ZtBRQ:function(a,r){return a<<r},OfpAe:function(a,r){return a&r},fTHKv:function(a,r){return a>>>r},lUzCJ:function(a,r){return a&r},yXMAG:function(a,r){return a&r},cNjzk:function(a,r){return a&r},VpmXQ:function(a,r){return a>>>r},aGqrq:function(a,r){return a>>>r},XRVVy:function(a,r){return a(r)},hbFwY:function(a,r){return a>=r},ayXWj:function(a,r){return a%r},KRxuT:function(a,r){return a/r},WWZgO:function(a,r){return a*r},wQXuQ:function(a,r){return a===r},ivyBg:function(a,r){return a&r},HeNlu:function(a,r){return a&r},xbMxL:function(a,r){return a>>>r},ZEOTK:function(a,r){return a>>>r},pVbma:function(a,r){return a+r},dMYRK:function(a,r){return a<<r},YBLBv:t(1440),fFBdW:"sxcuh",Fkync:function(a,r){return a===r},SdBQO:function(a,r){return a+r},nLfko:"VUCFg",nIWaa:"NhGZB",vAqmg:function(a,r){return a&r},MggzO:function(a,r){return a>>>r},sJsHb:function(a,r){return a>>>r},BJgLI:function(a,r){return a&r},zbMHn:function(a,r){return a>>>r},meIwm:function(a,r){return a>>>r},OWbeH:function(a,r){return a&r},xTcRc:function(a,r){return a&r},DUDRw:function(a,r){return a>>>r},XNrlw:t(455)+t(878),MKPpF:t(325)+"NG_ERROR",zQLyx:t(1114)+t(1298)+"R",eoCrj:"MESSAGE_"+t(587),mOHUk:"OPEN_ERROR",oLiuR:"1|0|2|5|"+t(1002),HceSi:t(851)+"3",vRIjT:t(1518),fvfLF:t(872),jDrZf:t(736),orcFs:t(337),kXuqT:t(659),uWaKp:t(1017),GTeyn:t(979),HKSXc:function(a){return a()},vAQxM:function(a,r,s){return a(r,s)},WTHHb:t(389),WUETV:t(225),QcCQF:function(a,r){return a===r},CnsVt:function(a,r){return a==r},uLaDw:t(495)+t(205),GxMXS:function(a,r){return a===r},ADvHa:function(a,r){return a<r},ecROZ:function(a,r,s,d){return a(r,s,d)},Wvlwh:t(215),lwGps:t(1553),LmoxQ:function(a,r,s){return a(r,s)},xMmst:t(1558),Gkvwh:function(a,r,s){return a(r,s)},Jaagg:"message",usVBq:function(a,r){return a!==r},tuUMO:"UrHaH",unCAM:function(a,r,s){return a(r,s)},eorCx:t(294),WNqdG:t(1306),WZkhf:t(798),ScPdd:function(a,r){return a(r)},RnLSG:t(1423),zRnZr:t(891),JbdWw:function(a,r){return a||r},NYgbC:function(a,r){return a!==r},GhpeX:"eteJs",meUpF:function(a,r){return a||r},Xcdcl:function(a,r){return a!=r},VXXVV:t(1015),umBOu:function(a,r){return a<=r},OnLVY:function(a,r){return a+r},oYPhO:"bITzc",BuGAJ:t(1176),DWfSl:function(a,r){return a(r)},SXUec:function(a,r){return a<r},uhUcD:function(a,r){return a&r},tdnEj:function(a,r){return a===r},ROspU:function(a,r){return a&r},SYJoO:function(a,r){return a+r},vTNXQ:function(a,r){return a<r},ummfY:function(a,r){return a-r},HSkzm:function(a,r){return a<r},JJNxe:function(a,r){return a>=r},fYMbW:function(a,r){return a<<r},MpbvW:function(a,r){return a&r},tXzbi:function(a,r){return a>=r},VZFJs:function(a,r){return a<r},nTOaK:function(a,r){return a|r},ZZWVv:function(a,r){return a&r},BIycB:function(a,r){return a|r},BEBQs:function(a,r){return a&r},OlDoF:function(a,r){return a<<r},XdqVk:function(a,r){return a&r},hPswx:function(a,r){return a&r},DlXOE:function(a,r){return a+r},kHrWW:function(a,r){return a&r},EpjwK:function(a,r){return a<r},KwaYo:function(a,r){return a<r},htVXX:function(a,r){return a===r},olDKg:function(a,r){return a&r},bQpWq:function(a,r){return a+r},pyWvO:function(a,r){return a<<r},SdhdQ:function(a,r){return a&r},PWktU:function(a,r){return a|r},sFZWW:function(a,r){return a&r},OYuNZ:function(a,r){return a>>r},sZXfU:function(a,r){return a&r},OOqhI:function(a,r){return a|r},ScPQz:function(a,r){return a&r},iuFVi:function(a,r){return a&r},Fixyl:t(509),aUusF:function(a,r,s,d){return a(r,s,d)},Ivuda:function(a,r){return a instanceof r},CYopG:t(662)+t(113)+"et=utf-8",gYePC:function(a,r){return a===r},wBqXm:"auto",LWJFT:function(a,r,s,d){return a(r,s,d)},oEMKy:function(a,r){return a===r},AoYJa:t(1353),WDsYM:t(137),WCZCb:t(553),zpPLz:"unknown reason",gYUij:t(398),LGmcW:t(227)+"ascript",BkgDH:t(181)+t(200)+t(849)+"P",XQkTs:function(a,r,s){return a(r,s)},QLSul:t(174),CgLoN:"going aw"+t(170)+"ork offl"+t(1263),CodFc:t(252),jbfaB:function(a){return a()},lvCOY:"jfzMZ",gqLGw:t(559),GsDwl:t(847),MgwPR:t(1242),WYmFv:t(179),eHEOX:function(a,r){return a||r},ceaah:function(a,r){return a||r},Oftpz:function(a,r){return a||r},WMytj:function(a,r){return a||r},zLbpu:function(a,r){return a||r},slAsy:t(1177)+"d",ELtCP:function(a,r){return a||r},tpklR:t(467)+"id",qKbCi:t(237),aUpyV:function(a,r){return a(r)},skyBJ:function(a,r){return a===r},lYGpU:"GCoew",NLMcK:t(187),iHLTQ:function(a,r,s,d){return a(r,s,d)},qGeaw:"x_fronti"+t(416),JXOqv:function(a,r,s,d){return a(r,s,d)},OGDNe:"x_fronti"+t(934)+"k",iLLbm:function(a,r,s){return a(r,s)},vBTZI:t(1154)+"er_ack_m"+t(204),oELpf:function(a,r,s,d){return a(r,s,d)},MzztX:t(1554),EywgJ:function(a,r){return a&&r},Lzweq:t(247),MQTax:t(231),baPGi:function(a,r){return a(r)},Benqi:"binary",fUswZ:function(a,r,s,d){return a(r,s,d)},MssTE:function(a,r){return a+r},RJvPN:function(a,r){return a&r},SrZiR:function(a,r){return a||r},baFPf:function(a,r){return a>>>r},PaYPz:function(a,r){return a(r)},ZBCcL:function(a,r){return a+r},trjNk:function(a,r){return a+r},PRska:"index out of ran"+t(586),XiMCj:" + ",tmhAL:t(1094),wHMVK:"integer "+t(1340)+"e",NdNlf:function(a,r){return a&r},JbMWQ:function(a,r,s,d){return a(r,s,d)},hWHUn:function(a,r){return a+r},ONuHt:function(a,r){return a+r},VQoEx:function(a,r){return a<<r},BcVZj:t(1631)+"1",prsfc:function(a,r){return a+r},FKjZD:function(a,r){return a+r},wWgLV:function(a,r){return a+r},XlTzu:function(a,r){return a|r},MtjWt:function(a,r){return a|r},spwCn:function(a,r){return a+r},gGHIV:function(a,r){return a<<r},ueDKK:function(a,r){return a+r},OuvVL:function(a,r){return a|r},LUKTU:function(a,r){return a+r},gFzBI:function(a,r){return a+r},uFfho:function(a,r){return a>>>r},QmYZX:function(a,r){return a>>>r},lVEez:function(a,r){return a&r},CYusQ:function(a,r){return a+r},HSYBd:function(a,r){return a>>>r},HDAdx:function(a,r){return a+r},dOmSH:function(a,r){return a>>>r},yRDft:function(a,r){return a+r},PhduB:function(a,r){return a&r},prrGf:"LDhBr",kJtcd:"KZDnm",XETER:function(a,r){return a+r},NBGRG:function(a,r){return a&r},KVydO:"PdBsd",YXVon:function(a,r){return a>>>r},QLEVT:function(a,r){return a|r},iosDo:function(a,r){return a&r},buzGN:function(a,r){return a|r},HCLCn:function(a,r){return a>>>r},iEaaN:function(a,r){return a&r},qppiX:function(a,r){return a>>>r},SzidK:function(a,r){return a>>>r},YGRUS:function(a,r){return a&r},EnYHm:function(a,r){return a|r},VKkcp:function(a,r){return a>r},Izszf:t(519),ojPTb:function(a,r){return a<r},bbpfx:function(a,r){return a(r)},qIZmv:"3|4|0|1|"+t(866)+t(629),Dnwnw:t(1245)+"ervice",CzVRD:function(a,r,s,d){return a(r,s,d)},ocAEY:t(402),rXMap:t(923)+t(402),RHaIe:function(a,r){return a(r)},vGCdq:t(499)+t(1471),xNqtc:function(a,r,s){return a(r,s)},BrFfQ:t(729)+t(1077),HhnXZ:function(a,r){return a===r},YHrYx:function(a,r){return a!==r},VeLlU:t(717),Kdylj:t(535)+"rValues",DJJKK:t(153),NTwVv:t(1095),OjlZT:"CONTINUE",BFEhH:t(1624),EBEzz:t(260),PJNre:function(a,r){return a!==r},HIljk:t(986),QYFoW:"nfMUi",KpfHX:function(a,r,s,d){return a(r,s,d)},ICvmh:function(a,r,s){return a(r,s)},SXpoS:t(1154)+t(508),SLpRr:function(a,r){return a(r)},zIEXN:t(1154)+t(278),ojOqV:t(1594)+"s",jCJyZ:t(706)+t(369)+"e",Wbbrn:t(706)+t(1160)+"ue",RvfPl:function(a){return a()},ExAPN:function(a,r){return a>r},OAPvY:function(a,r){return a>r},EyMUx:function(a){return a()},kcRSV:function(a,r){return a<r},tKXaK:function(a){return a()},PuUou:function(a){return a()},djEKJ:t(1621),kpqlS:t(1117),JBFEK:function(a){return a()},WdyqM:t(457),fGPKZ:function(a,r,s){return a(r,s)},DFMgf:function(a,r,s){return a(r,s)},jcnvH:function(a,r){return a(r)},WGpSY:function(a,r,s){return a(r,s)},hqybs:function(a,r){return a<r},nmWbi:function(a,r){return a|r},wyONP:function(a,r){return a>>r},ouKQS:t(981),KqGpv:function(a,r){return a===r},wBtuM:"objectSt"+t(880),XEGJN:t(320),bKEwI:t(188)+"4|10|6|7"+t(946),nhqFP:t(324),OPOuc:function(a,r){return a!==r},AMcTw:t(1162),pINUO:t(869),JCMjk:function(a,r,s){return a(r,s)},AbIxZ:"arraybuffer",SlGbl:t(1287),YowyO:t(1508)+"rovide v"+t(1331),wmgcY:function(a,r){return a(r)},jYnDr:t(1508)+t(301)+t(289)+t(355)+t(715)+t(1199)+"is undef"+t(131),plRIW:t(781)+"t",ASOWn:t(453)+t(607)+" reconnect",DVBIJ:t(1538),hBNLQ:t(1415),XrnIm:t(1597),lSPbj:t(264),fNlNW:t(1416),gqkEx:"ttwid",fvAGA:t(1508)+t(1407)+t(415)+t(472)+t(661),JWVHv:t(948),YBUrS:function(a,r,s){return a(r,s)},MTSQD:t(1184),wpBOu:t(1447)+"0",rUfxl:function(a,r){return a+r},TSWdA:t(771),mPkMl:function(a,r,s){return a(r,s)},fJjEi:t(1494),AzAWV:t(547),bkSiL:function(a,r,s){return a(r,s)},ZdIaK:"start",qSTAt:function(a,r){return a>r},GjQYr:function(a,r){return a!==r},JKwKx:t(974),XIrbQ:t(837)+">",XSAqc:function(a,r,s){return a(r,s)},WxLFV:t(611),dUgJW:t(1014)+t(846)+t(1511)+"0",zPKsE:function(a,r){return a<r},XxxUy:function(a,r){return a>>>r},OUYeQ:t(163),WllAA:t(291)+t(1076)+"onnecting",dUnyv:function(a,r){return a===r},TcVQD:t(757),OwRYa:t(1010),fcBdF:t(902),rsmIT:t(1570),ZPluv:function(a,r){return a>=r},fjnUS:"uGTyY",FFRTE:t(949),HWpwV:t(924),hUHgd:"abort",CYOEU:function(a){return a()},iGcfV:t(1394)+"or",jVRUq:function(a){return a()},GfJgJ:function(a,r){return a===r},ggRUl:t(1059),rkNgC:"qXGCp",CxiEP:function(a,r){return a===r},VWLuS:function(a,r){return a===r},QEHEM:t(286),gnpkf:t(496)+"7|0|5|4",ozTsG:function(a,r){return a===r},rNagn:t(1034)+t(1472)+"y closed",notTI:function(a,r){return a==r},vJwrY:t(1508)+t(605)+t(914)+"ata, data must b"+t(1159)+t(554)+t(690)+t(822),IVwdV:function(a,r){return a instanceof r},dkBbs:function(a,r){return a(r)},ZClon:function(a,r){return a(r)},wOHbC:t(1508)+"rovide a valid s"+t(1349),VXrxz:function(a,r){return a instanceof r},cmnHV:function(a,r){return a(r)},AxdjM:function(a,r){return a===r},eYOKU:"sent",kNDZB:function(a,r){return a!==r},eHBJh:t(980),PUMPT:t(507),glQSN:function(a,r){return a||r},TdqjI:function(a,r){return a==r},gdYEj:"manual r"+t(1062)+t(722),fSArr:t(912),qwzQd:t(799)+"3",MIHHL:t(828),Hfbkx:function(a,r){return a===r},yTWiE:t(1405),rLtmd:t(1443),siznB:t(497),KFRWD:function(a,r){return a(r)},CERJR:t(577),Iaqpb:function(a,r){return a!=r},OUywr:t(1393),kCxje:t(1083),svSnh:function(a,r){return a===r},wTVHx:function(a,r){return a!=r},PcsQd:function(a,r){return a!=r},cDUIv:function(a,r){return a!=r},MJniL:function(a,r){return a!=r},DlVvK:function(a,r){return a===r},GaqPh:t(494)+"orkerGlo"+t(1536),OtGJD:function(a,r){return a!=r},bsdLi:function(a,r){return a!=r},EVdxf:function(a,r){return a!=r},ktABF:function(a,r,s){return a(r,s)}};Bt.r(ke),Bt.d(ke,{FWS:()=>Ip,CustomErrorEvent:()=>Fd,createCloseEvent:()=>gt,ReconnectEvent:()=>zd,createErrorEvent:()=>dt,decodedFrame:()=>en,createOpenEvent:()=>Wd,CustomCloseEvent:()=>Ud,createReconnectEvent:()=>oa,FrontierMessageEvent:()=>Hd,encodeFrame:()=>Ut,createMessageEvent:()=>jd,OpenEvent:()=>Gd,ErrorCode:()=>nn,Event:()=>Yn,MessageEvent:()=>qd});let n="";function i(a=""){let r=t,s="02",d=""+Date[r(276)](),u=n||(n=x(a)),g=Math[r(768)]().toString(16)[r(401)](-6);return e.BSDsu(e[r(1235)](s+d,u),g)}function o(){let a=t,r={CpkgB:function(s,d){return e[V(1557)](s,d)},tPtJM:function(s,d){return e[V(1193)](s,d)},WJJAK:e[a(962)],klWMB:function(s,d){return e.XGwfp(s,d)},sTkCa:function(s,d){return e[a(512)](s,d)}};return e[a(1193)](e[a(503)],"IqRcj")?e[a(807)](1e4,Date[a(276)]())+Math.floor(e[a(807)](1e4,Math[a(768)]())):aTpEWc.CpkgB(_0x4ea68d,_0x30ab95)&&(aTpEWc[a(532)](_0xb19d6d,aTpEWc[a(710)])||aTpEWc[a(1507)](_0x1fd035,"store"))?!0:aTpEWc[a(142)](_0xf78c6c,_0x275f72)}function c(a){let r=t;return e[r(1165)](e[r(1229)](Array,8)[r(226)]("0"),e.CNRWC(parseInt,a,10).toString(2)).slice(-8)}function l(a){let r=t;return e[r(1208)](e[r(391)](Array,4).join("0"),parseInt(a,2)[r(518)](16))[r(401)](-4)}function f(a){let r=t,s=a[r(1620)](/\./).map(g=>c(g)),d=[];return d[0]=l(e[r(1312)](s[0],s[1])),d[1]=l(e[r(944)](s[2],s[3])),[e[r(1411)],e.NKAJv,e.NKAJv,e[r(1411)],e[r(1411)],e[r(420)],d[0],d[1]][r(226)]("")}function x(a){let r=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}/[r(208)](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]))/[r(208)](a);return s?f(a):d?e[r(1239)](p,a):e[r(1106)]}function p(a){let r=t,s="",d=[],u=0,g=0,m=!0,E=e[r(1411)];if(e[r(1401)](a[r(932)]("::"),-1)){let h=a[r(1620)]("::");for(let I=0;e.lCMAj(I,h[r(515)]);I++){let N=h[I];if(e.qYinx(N[r(932)](":"),0))if(e.XGwfp(e.qMiem,e[r(892)])){let q=N[r(1620)](":");m&&(u=q[r(515)]),g+=q[r(515)];for(let U=0;U<q[r(515)];U++)if(e[r(900)](4,q[U][r(515)]))if(e[r(1193)](e[r(120)],e.okIVX))_0x1e8165=e[r(1239)](_0x2f595a,_0x4ac8aa),_0x49f1dd=e[r(1377)](127,_0x50ce59),128&_0x28fd36&&(_0xd2c16e=e[r(1449)](_0x35d923,_0x2c5409),_0x5315eb|=e.BMZgB(e[r(1377)](127,_0x27a3d6),7));else{let pe=E[r(1583)+"g"](0,e[r(275)](4,q[U][r(515)])),We=pe[r(438)](q[U]);d.push(We)}else d.push(q[U]);m=!1}else JKWDuG.TDlYn(_0x2b38ea,_0x356efd[r(310)]),JKWDuG[r(134)](_0x111b8d);else if(e[r(166)]!==r(1266)){let q=/(25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?)(\.(25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?)){3}/[r(208)](_0x3585f0),U=/(([0-9a-fA-F]{1,4}:){7,7}[0-9a-fA-F]{1,4}|([0-9a-fA-F]{1,4}:){1,7}:|([0-9a-fA-F]{1,4}:){1,6}:[0-9a-fA-F]{1,4}|([0-9a-fA-F]{1,4}:){1,5}(:[0-9a-fA-F]{1,4}){1,2}|([0-9a-fA-F]{1,4}:){1,4}(:[0-9a-fA-F]{1,4}){1,3}|([0-9a-fA-F]{1,4}:){1,3}(:[0-9a-fA-F]{1,4}){1,4}|([0-9a-fA-F]{1,4}:){1,2}(:[0-9a-fA-F]{1,4}){1,5}|[0-9a-fA-F]{1,4}:((:[0-9a-fA-F]{1,4}){1,6})|:((:[0-9a-fA-F]{1,4}){1,7}|:)|fe80:(:[0-9a-fA-F]{0,4}){0,4}%[0-9a-zA-Z]{1,}|::(ffff(:0{1,4}){0,1}:){0,1}((25[0-5]|(2[0-4]|1{0,1}[0-9]){0,1}[0-9])\.){3,3}(25[0-5]|(2[0-4]|1{0,1}[0-9]){0,1}[0-9])|([0-9a-fA-F]{1,4}:){1,4}:((25[0-5]|(2[0-4]|1{0,1}[0-9]){0,1}[0-9])\.){3,3}(25[0-5]|(2[0-4]|1{0,1}[0-9]){0,1}[0-9]))/[r(208)](_0x4bedb2);return q?e[r(987)](_0x43096b,_0x39eee9):U?e[r(1600)](_0x1015db,_0x4e1bb6):e[r(1106)]}else{if(e[r(1347)](4,N[r(515)])){let q=E[r(1583)+"g"](0,4-N[r(515)]),U=q.concat(N);d[r(1634)](U)}else d.push(N);m&&(u+=1),g+=1,m=!1}}let k="";for(let I=0;e[r(196)](I,e[r(1372)](8,g));I++)k=k.concat(E);for(let I=0;e[r(196)](I,d[r(515)]);I++)e.XGwfp(I,u)&&(s=s.concat(k)),s=s[r(438)](d[I]);return s}{let h=a.split(":");for(let k=0;e[r(196)](k,h[r(515)]);k++){let I=h[k];if(e[r(1488)](4,h[k].length)){let N=E[r(1583)+"g"](0,4-h[k][r(515)]),q=N[r(438)](I);s=s[r(438)](q)}else s=s.concat(I)}return s}}function w(a,r){let s=t,d=a[s(921)];e[s(1260)](void 0,d)&&(e[s(737)](he,r,10),e[s(1592)](G,r,d));let u=a[s(143)];e[s(1347)](void 0,u)&&(e[s(737)](he,r,18),G(r,u))}function v(a){let r=t,s={};e:for(;!e[r(987)]($,a);){let d=xe(a);switch(e[r(190)](d,3)){case 0:break e;case 1:s[r(921)]=e[r(266)](O,a,xe(a));break;case 2:s[r(143)]=O(a,e.vUuhT(xe,a));break;default:e[r(737)](R,a,e[r(1377)](7,d))}}if(e[r(293)](void 0,s[r(921)]))throw new Error(e[r(1110)]);if(e.pytoV(void 0,s.value))throw new Error(e.Fhipb);return s}function T(a){let r=t,s=D();return e.wqbPI(y,a,s),e[r(1600)](z,s)}function y(a,r){let s=t,d={NMXyz:function(Y,te){return e[V(1428)](Y,te)},cUBNS:function(Y,te){return e.lCMAj(Y,te)},UAUzP:function(Y,te){return e[V(233)](Y,te)},JUdZY:function(Y,te){return e.pIRLV(Y,te)},jZhcu:function(Y,te){return e[V(196)](Y,te)}},u=a[s(488)];if(u!==void 0)if(e.rPORi(e[s(916)],e[s(1033)]))e[s(1143)](he,r,8),e[s(1270)](pt,r,u);else{let Y=_0x3362c3.length&&_0x4ae36f[0];if(Y instanceof _0x4c1894)throw Y;let te=new _0x592303(s(495)+s(205)+(Y?e[s(895)](" (",Y[s(776)])+")":""));throw te.context=Y,Y}let g=a[s(458)];g!==void 0&&(he(r,16),e[s(1592)](pt,r,g));let m=a[s(288)];e[s(599)](void 0,m)&&(e.lmiuP(he,r,24),e[s(737)](pt,r,e[s(926)](P,m)));let E=a[s(1613)];E!==void 0&&(e.pytoV(e.wShGd,e[s(961)])?(e.sNBDT(he,r,32),e[s(737)](pt,r,e[s(1171)](P,E))):_0x13e6ea&&this[s(928)+s(919)]["updateCu"+s(1009)+"Name"](_0x4de792));let h=a.headers;if(e.HGFSk(void 0,h))for(let Y of h){e[s(1143)](he,r,42);let te=D();e[s(1143)](w,Y,te),e[s(266)](he,r,te[s(1304)]),e[s(1426)](W,r,te),e[s(391)](L,te)}let k=a["payloadE"+s(623)];e[s(599)](void 0,k)&&(he(r,50),e[s(266)](G,r,k));let I=a[s(787)+"ype"];if(e.CxQQI(void 0,I))if(e[s(232)]===e[s(1345)]){let Y=_0x245f59[s(813)+"At"](_0x3b5b84);Y>=55296&&d[s(306)](Y,56319)&&d[s(1619)](d[s(655)](_0x5e8fc2,1),_0xc1b51f)&&(Y=d[s(375)](Y<<10,_0x185148[s(813)+"At"](++_0x22763c))-56613888),_0x324a25+=d[s(1619)](Y,128)?1:d[s(1619)](Y,2048)?2:d[s(409)](Y,65536)?3:4}else e[s(315)](he,r,58),e[s(315)](G,r,I);let N=a[s(240)];N!==void 0&&(e[s(1564)](he,r,66),e[s(1305)](he,r,N.length),e[s(753)](ze,r,N));let q=a[s(894)];q!==void 0&&(e[s(753)](he,r,74),e.hheBO(G,r,q));let U=a["serverTi"+s(906)];e.HGFSk(void 0,U)&&(e.eGouf(he,r,82),e[s(1564)](G,r,U));let pe=a[s(243)];e[s(1545)](void 0,pe)&&(e[s(1143)](he,r,90),G(r,pe));let We=a[s(1458)+"e"];e.rHpdE(void 0,We)&&(e[s(266)](he,r,96),pt(r,e.ynpnl(P,We)))}function b(a){return e[t(987)](S,B(a))}function S(a){let r=t,s={};e:for(;!e[r(700)]($,a);){let d=e[r(178)](xe,a);switch(e.wxyYa(d,3)){case 0:break e;case 1:s[r(488)]=e[r(1027)](At,a,!0);break;case 2:s[r(458)]=e[r(1183)](At,a,!0);break;case 3:s[r(288)]=e[r(860)](xe,a);break;case 4:s[r(1613)]=e[r(860)](xe,a);break;case 5:{let u=A(a);(s[r(1231)]||(s[r(1231)]=[]))[r(1634)](e[r(1229)](v,a)),a[r(1304)]=u;break}case 6:s[r(489)+r(623)]=e[r(885)](O,a,e[r(1449)](xe,a));break;case 7:s["payloadT"+r(639)]=e[r(1592)](O,a,e.UuBys(xe,a));break;case 8:s[r(240)]=e[r(602)](Ae,a,e[r(987)](xe,a));break;case 9:s.LogIDNew=e[r(1497)](O,a,e[r(1449)](xe,a));break;case 10:s[r(449)+"ming"]=e[r(1526)](O,a,e[r(926)](xe,a));break;case 11:s[r(243)]=e[r(585)](O,a,e[r(1239)](xe,a));break;case 12:s[r(1458)+"e"]=xe(a);break;default:e[r(753)](R,a,e[r(1377)](7,d))}}if(e[r(191)](void 0,s[r(488)]))throw new Error(e[r(792)]);if(e[r(191)](void 0,s[r(458)]))throw new Error(e[r(1332)]);if(e[r(1193)](void 0,s[r(288)]))throw new Error(e[r(404)]);if(s[r(1613)]===void 0)throw new Error(e.BzoUE);return s}function A(a){let r=t,s=e[r(1171)](xe,a),d=a[r(1304)];return a[r(1304)]=e[r(944)](a[r(984)],s),d}function R(a,r){let s=t;switch(r){case 0:for(;e[s(360)](128,se(a)););break;case 2:J(a,e[s(727)](xe,a));break;case 5:e[s(601)](J,a,4);break;case 1:e[s(1027)](J,a,8);break;default:throw new Error(e.pIRLV(e[s(1588)],r))}}function P(a){let r=t;return a|=0,{low:a,high:e.Jwupn(a,31),unsigned:e[r(492)](a,0)}}let _=[];function D(){let a=t,r=_.pop();return r?(r[a(984)]=r.limit=0,r):{bytes:new Uint8Array(64),offset:0,limit:0}}function L(a){_[t(1634)](a)}function B(a){return{bytes:a,offset:0,limit:a[t(515)]}}function z(a){let r=t,s=a[r(1599)],d=a[r(1304)];return e[r(191)](s[r(515)],d)?s:s[r(1215)](0,d)}function J(a,r){let s=t;if(e[s(944)](a.offset,r)>a[s(1304)])throw new Error(e[s(1190)]);a[s(984)]+=r}function $(a){let r=t;return e[r(492)](a[r(984)],a[r(1304)])}function ee(a,r){let s=t,d={UccrI:function(u,g,m){return e.iOKxh(u,g,m)},sPfss:s(174)};if(e[s(468)]===e[s(213)]){this[s(1236)+s(357)+s(1126)](d[s(889)](_0x48b0bf,s(1128),{code:1e3,reason:d.sPfss})),this[s(801)+s(978)]?.["resetEnd"+s(631)+"fig"](),this[s(1422)+"sCounter"]?.[s(358)+"nter"]();return}else{let u=a[s(1599)],g=a.offset,m=a[s(1304)],E=e[s(233)](g,r);if(e.qYinx(E,u[s(515)])){let h=new Uint8Array(e[s(807)](2,E));h[s(558)](u),a[s(1599)]=h}return a[s(984)]=E,e[s(818)](E,m)&&(a[s(1304)]=E),g}}function X(a,r){let s=t,d=a.offset;if(e.yqmGz(e[s(944)](d,r),a.limit))throw new Error(e[s(1446)]);return a[s(984)]+=r,d}function Ae(a,r){let s=t,d={wSwjs:function(u,g){return e[V(293)](u,g)},IriIK:function(u,g){return e[V(125)](u,g)}};if(e[s(1335)](e[s(868)],s(1485))){let u=e[s(471)](X,a,r);return a[s(1599)].subarray(u,e[s(1235)](u,r))}else return _0x586c24<=_0x59371d?_0x2f85e4[s(157)](new _0xa520d4(s(1414)+"alled multiple t"+s(144)+"process")):(_0x5d9b1c=_0x316903,d[s(498)](_0x6ce689,_0x57f530.length)?_0x6f2162[s(1146)]():_0x4d805d[_0x3a254e][s(235)](_0x5a21fb)(_0x3a9c24,_0x4f0dc3[s(235)](null,d[s(582)](_0x1bbcef,1))))}function ze(a,r){let s=t,d=e.fPTOq(ee,a,r[s(515)]);a.bytes.set(r,d)}function O(a,r){let s=t,d=e[s(684)](X,a,r),u=String[s(1216)+"Code"],g=a[s(1599)],m="\uFFFD",E="";for(let h=0;e.lCMAj(h,r);h++){let k=g[h+d],I,N,q,U;e[s(191)](128&k,0)?E+=e[s(372)](u,k):e.XGwfp(e[s(1377)](224,k),192)?e[s(492)](h+1,r)?E+=m:(I=g[e[s(125)](e[s(1235)](h,d),1)],e[s(360)](192,I)!==128?E+=m:(U=e[s(882)](e[s(633)](e[s(1409)](31,k),6),63&I),e[s(996)](U,128)?E+=m:s(1465)!==e[s(1172)]?(E+=e.NLIIp(u,U),h++):(_0x3182e7(_0x44de4f,16),_0x558399(_0x209420,_0x786f3b)))):e[s(1211)](240,k)==224?h+2>=r?E+=m:(I=g[e[s(125)](h+d,1)],N=g[e[s(1235)](h+d,2)],e[s(609)](I|e[s(1289)](N,8),49344)!==32896?E+=m:(U=e[s(1150)](e[s(1573)](e[s(1289)](e[s(463)](15,k),12),e.NFvta(e[s(609)](63,I),6)),e[s(609)](63,N)),e.lCMAj(U,2048)||e[s(492)](U,55296)&&e.QVwxs(U,57343)?E+=m:(E+=e[s(874)](u,U),h+=2))):e[s(1377)](248,k)==240?e.gVLNI(e[s(1312)](h,3),r)?E+=m:(I=g[e[s(1531)](e[s(1531)](h,d),1)],N=g[e.bDWhg(e[s(944)](h,d),2)],q=g[e[s(1165)](e[s(1531)](h,d),3)],e[s(901)](e[s(1211)](e[s(1351)](e[s(882)](I,e.WtzED(N,8)),e.agFnI(q,16)),12632256),8421504)?E+=m:(U=e.aAEDm(e[s(1150)](e.YEMHx((7&k)<<18,e[s(935)](e[s(609)](63,I),12)),e[s(1289)](63&N,6)),e.MAcIL(63,q)),U<65536||e.QQPUh(U,1114111)?E+=m:(U-=65536,E+=u(e.GjREN(e[s(1164)](U,10),55296),e[s(345)](e[s(1211)](1023,U),56320)),h+=3))):E+=m}return E}function G(a,r){let s=t,d=r[s(515)],u=0;for(let E=0;e[s(545)](E,d);E++)if(e[s(707)](e.TEObY,e[s(1556)])){let h=r[s(813)+"At"](E);e[s(1483)](h,55296)&&e[s(1269)](h,56319)&&e[s(996)](E+1,d)&&(h=e[s(1372)](e[s(633)](h,10)+r[s(813)+"At"](++E),56613888)),u+=h<128?1:e[s(1412)](h,2048)?2:e[s(1412)](h,65536)?3:4}else _0x37e036+=e.ZRwoh(_0x3487ec,_0x3472d7),_0x13eb46+=2;e[s(590)](he,a,u);let g=e[s(963)](ee,a,u),m=a[s(1599)];for(let E=0;e[s(196)](E,d);E++){let h=r[s(813)+"At"](E);h>=55296&&e[s(1104)](h,56319)&&e[s(1531)](E,1)<d&&(h=e[s(789)](e[s(1165)](h<<10,r[s(813)+"At"](++E)),56613888)),e[s(1299)](h,128)?m[g++]=h:(h<2048?m[g++]=e[s(1150)](h>>6&31,192):(h<65536?m[g++]=e[s(1351)](e[s(349)](h>>12,15),224):(m[g++]=e[s(485)](e.NAywr(e.gcztf(h,18),7),240),m[g++]=e.YREmk(e[s(1539)](e[s(1252)](h,12),63),128)),m[g++]=e[s(1150)](e.ijBmQ(e[s(1164)](h,6),63),128)),m[g++]=e[s(461)](e.XZDSs(63,h),128))}}function W(a,r){let s=t,d=e[s(590)](ee,a,r[s(1304)]),u=a[s(1599)],g=r.bytes;for(let m=0,E=r[s(1304)];e.kUcAb(m,E);m++)u[e[s(1476)](m,d)]=g[m]}function se(a){let r=t;return a[r(1599)][e[r(997)](X,a,1)]}function Xe(a,r){let s=t,d=e[s(1178)](ee,a,1);a[s(1599)][d]=r}function xe(a){let r=t,s=0,d=0,u;do e[r(1438)]!==e[r(994)]?(u=e[r(1568)](se,a),e.KZKqH(s,32)&&(d|=e.WtzED(e.ijBmQ(127,u),s)),s+=7):(_0x50f4ff=_0x5ab99c[r(438)](_0x44fb83),_0x50a745=_0xf2a7f3[r(438)](_0x41895d[_0x1c90ae]));while(e[r(683)](128,u));return d}function he(a,r){let s=t;for(r>>>=0;e[s(1483)](r,128);)e[s(239)](Xe,a,e.AIFcq(127&r,128)),r>>>=7;e.JuLFw(Xe,a,r)}function At(a,r){let s=t,d=0,u=0,g=0,m;if(m=e[s(874)](se,a),d=e[s(463)](127,m),e.mrSur(128,m)&&(m=e.aDfyp(se,a),d|=e[s(360)](127,m)<<7,128&m&&(m=se(a),d|=e.iTfTW(e[s(1409)](127,m),14),e.wiwBO(128,m)&&(m=e[s(1092)](se,a),d|=e.BhZGG(e[s(609)](127,m),21),e[s(1211)](128,m)))))if(e.dcjxr!==e[s(1148)]){if(m=e[s(129)](se,a),u=e[s(955)](127,m),e[s(1377)](128,m)&&(m=se(a),u|=e.laoqh(127&m,7),e.wiwBO(128,m)&&(m=e.CzyHe(se,a),u|=e[s(1289)](e[s(349)](127,m),14),e.uAYgp(128,m))))if(e[s(165)]===e[s(1058)]){let E=this[s(1219)].getItem(this[s(244)]),h=_0x297ed5.parse(E||"{}");return h[_0x4df1b5]=void 0,this[s(1219)][s(335)](this[s(244)],_0x10be5c[s(451)+"y"](h))}else m=e[s(910)](se,a),u|=e.BhZGG(e[s(1213)](127,m),21),e[s(1605)](128,m)&&(m=se(a),g=e[s(683)](127,m),e.izxPp(128,m)&&(m=e[s(1449)](se,a),g|=e[s(930)](e[s(1503)](127,m),7)))}else{for(_0x526584>>>=0;_0x3925f2>=128;)e[s(1542)](_0x466f1e,_0x17e66c,e.wPltB(e.Mfcbw(127,_0x505ad4),128)),_0x44002b>>>=7;e[s(601)](_0x263164,_0xc82536,_0x430ef7)}return{low:e[s(718)](d,e.WtzED(u,28)),high:e[s(1499)](e[s(1246)](u,4),e[s(905)](g,24)),unsigned:r}}function pt(a,r){let s=t;if(e.deyfE===e[s(1253)]){let d={OdZzE:function(u,g){return e.TDlYn(u,g)},qxgjr:e[s(1563)],bgxOW:e[s(941)],sSQkJ:e[s(1489)],cGJYT:function(u,g,m){return e[s(684)](u,g,m)}};return new _0x2f1680((u,g)=>{let m=s,E={haFiZ:function(I,N){return d.OdZzE(I,N)},Dgmtd:d[m(298)],PDYTP:d[m(620)]};this[m(636)+"ngTimer"](),this[m(754)+m(1087)+"Id"]=d[m(1323)](_0x3893ec,this[m(313)].bind(this),this[m(1551)][m(173)+m(1127)]);let h=()=>{let I=m;d[I(1101)](u,I(1440)),this[I(594)](I(743)+I(1354)+"s",h),this[I(594)](d[I(411)],k)},k=()=>{let I=m;E.haFiZ(g,E[I(945)]),this[I(594)](E[I(1315)],h),this[I(594)](I(743)+I(1543)+"t",k)};this.on(d[m(620)],h),this.on(d.qxgjr,k),this[m(313)]()})}else{let d=e[s(879)](r[s(1408)],0),u=e.wxyYa(e[s(128)](r[s(1408)]>>>28,e[s(1302)](r[s(738)],4)),0),g=e[s(190)](r[s(738)],24),m=e[s(1217)](0,g)?e.doHsS(0,u)?e.lCMAj(d,16384)?e.kUcAb(d,128)?1:2:e[s(545)](d,2097152)?3:4:e.xpPCv(u,16384)?e[s(1030)](u,128)?5:6:e[s(1299)](u,2097152)?7:8:e[s(1460)](g,128)?9:10,E=ee(a,m),h=a.bytes;switch(m){case 10:h[e[s(944)](E,9)]=e[s(879)](g,7)&1;case 9:h[e[s(1589)](E,8)]=m!==9?128|g:127&g;case 8:h[e[s(694)](E,7)]=e[s(626)](8,m)?u>>>21|128:e[s(1616)](e[s(1246)](u,21),127);case 7:h[e.rHQCV(E,6)]=e[s(124)](7,m)?e[s(1499)](u>>>14,128):e[s(624)](e.BWZhG(u,14),127);case 6:h[e[s(1589)](E,5)]=e[s(954)](6,m)?e.nKjRL(u>>>7,128):e[s(1213)](u>>>7,127);case 5:h[e.rHQCV(E,4)]=e[s(901)](5,m)?e[s(442)](128,u):e[s(1603)](127,u);case 4:h[e[s(744)](E,3)]=e.qXsNL(4,m)?e[s(1404)](d,21)|128:e[s(615)](e[s(1107)](d,21),127);case 3:h[e.rHQCV(E,2)]=e[s(772)](3,m)?e[s(1071)](e[s(1246)](d,14),128):e[s(1503)](e.BWZhG(d,14),127);case 2:h[e[s(694)](E,1)]=e[s(152)](2,m)?e.MSXVW(e.zLxfU(d,7),128):e[s(516)](e[s(1455)](d,7),127);case 1:h[E]=e[s(241)](1,m)?e[s(236)](128,d):e[s(1585)](127,d)}}}function en(a){return e[t(1092)](b,a)}function Ut(a){return e[t(664)](T,a)}let tn=65536,jr=e[t(1267)],we=tn*tn,Te=e.WWZgO(we,we),Xn=e[t(1249)](Te,2),Pe=String.prototype[t(813)+"At"];class le{constructor(r,s,d){let u=t;this[u(1575)]=!0,this[u(1408)]=0|r,this[u(738)]=e[u(128)](0,s),this[u(805)]=!!d}static[t(1575)](r){let s=t;return r&&e[s(1335)](!0,r[s(1575)])}static[t(537)](r,s,d){return new le(r,s,d)}static[t(218)+"s"](r,s,d){let u=t;return d?le[u(218)+u(719)](r,s):le[u(218)+"sBE"](r,s)}static[t(218)+t(719)](r,s){let d=t;return new le(e[d(1351)](e[d(1351)](r[0],e[d(935)](r[1],8)),e.agFnI(r[2],16))|e[d(538)](r[3],24),e[d(1546)](r[4]|e[d(848)](r[5],8)|e.laoqh(r[6],16),e[d(1289)](r[7],24)),s)}static["fromByte"+t(1291)](r,s){let d=t;if(e[d(1251)]===e.nmnaQ)return new le(e[d(1071)](e.iTdhM(e.xeLPy(e[d(1124)](r[4],24),e[d(988)](r[5],16)),e[d(633)](r[6],8)),r[7]),e.YREmk(e[d(718)](e.OGSjb(e[d(1297)](r[0],24),e[d(933)](r[1],16)),r[2]<<8),r[3]),s);{let u=_0x21c6e6(e[d(1202)],{message:this[d(197)+d(562)+d(1321)](_0x4af978)});this[d(1482)](e[d(1202)],u);let g=e[d(315)](_0xd01db4,d(1128),{reason:this[d(197)+d(562)+d(1321)](_0x1c7585)});this[d(1482)](e.WTVPF,g)}}static[t(1593)](r){let s=t;return e[s(819)](r,jr)?Bd:new le(e[s(1455)](e[s(224)](e[s(1392)](Pe[s(929)](r,0)|e[s(434)](Pe.call(r,1),8),e[s(988)](Pe[s(929)](r,2),16)),e[s(726)](Pe[s(929)](r,3),24)),0),(e.RWAkf(e.CIapc(Pe[s(929)](r,4),e[s(938)](Pe[s(929)](r,5),8)),e[s(938)](Pe[s(929)](r,6),16))|e[s(698)](Pe[s(929)](r,7),24))>>>0,!0)}[t(677)](){let r=t;return String[r(1216)+r(1036)](e[r(1256)](255,this.low),e[r(676)](this.low>>>8,255),this[r(1408)]>>>16&255,e[r(648)](this[r(1408)],24),e.lUzCJ(255,this[r(738)]),e.yXMAG(e[r(190)](this[r(738)],8),255),e[r(834)](e[r(596)](this[r(738)],16),255),e[r(1248)](this.high,24))}static fromNumber(r,s=!0){let d=t;if(e[d(1462)](isNaN,r))return s?Bh:Bd;if(s){if(e.gVLNI(r,Te))return Fh}else{if(e.QVwxs(r,-Xn))return Uh;if(e[d(254)](r+1,Xn))return zh}return le[d(537)](e[d(1607)](r,we)|0,e.KRxuT(r,we)|0,s)}[t(651)](){let r=t;return this[r(805)]?e[r(1108)](e.BWZhG(this[r(738)],0),we)+e.zLxfU(this.low,0):e[r(807)](this.high,we)+e[r(648)](this[r(1408)],0)}[t(484)](){let r=t;return e[r(759)](0,this[r(738)])&&this[r(1408)]===0}add(r){let s=t;le[s(1575)](r)||(r=le[s(752)+"er"](r));let d=this[s(738)]>>>16,u=e[s(1377)](65535,this[s(738)]),g=e[s(190)](this[s(1408)],16),m=e[s(525)](65535,this[s(1408)]),E=e[s(1404)](r[s(738)],16),h=e[s(437)](65535,r[s(738)]),k=e[s(1404)](r[s(1408)],16),I=65535&r[s(1408)],N=0,q=0,U=0,pe=0;return pe+=e[s(1165)](m,I),U+=e[s(371)](pe,16),pe&=65535,U+=e[s(694)](g,k),q+=e[s(1107)](U,16),U&=65535,q+=e[s(125)](u,h),N+=e[s(1100)](q,16),q&=65535,N+=e[s(1308)](d,E),N&=65535,le.fromBits(e[s(882)](e[s(1157)](U,16),pe),e[s(1629)](e[s(1302)](N,16),q),this[s(805)])}equals(r){let s=t;return le[s(1575)](r)||(r=le[s(752)+"er"](r)),this[s(805)]!==r[s(805)]&&this[s(738)]>>>31===1&&e[s(1343)](r[s(738)]>>>31,1)?!1:this.high===r[s(738)]&&this[s(1408)]===r.low}[t(1296)](){let r=t;if(e[r(1314)]!==e[r(1314)]){let s={xhoXq:function(g,m){return g(m)},tsWgy:e[r(966)],DWNXD:e.veLwQ,lDJPu:e.BvdQQ,pkBnh:function(g,m){return e[r(874)](g,m)},flLCE:e[r(941)]};this[r(636)+r(436)](),this[r(754)+r(1087)+"Id"]=e[r(997)](_0x25092d,this[r(313)][r(235)](this),this[r(1551)][r(173)+r(1127)]);let d=()=>{let g=r;s[g(534)](_0x199229,s[g(171)]),this[g(594)](s[g(539)],d),this.off(s[g(1294)],u)},u=()=>{let g=r;s[g(595)](_0x37a067,s.flLCE),this[g(594)](s[g(539)],d),this.off("ping_onc"+g(1543)+"t",u)};this.on(e[r(1489)],d),this.on(e.BvdQQ,u),this[r(313)]()}else return e[r(1193)](-1,this[r(1408)])&&this[r(738)]===-1?le[r(537)](0,0,this[r(805)]):e[r(1516)](-1,this.low)?le[r(537)](0,this[r(738)]+1,this[r(805)]):le.fromBits(e[r(441)](this.low,1),this[r(738)],this.unsigned)}[t(764)](r){let s=t,d={eXNEa:function(u,g,m,E,h){return u(g,m,E,h)},ukmGA:function(u,g){return e[V(1462)](u,g)}};if(e.ZewnJ(e[s(138)],e[s(691)]))return r?this[s(1456)+"E"]():this.toBytesBE();_0x3fbbc0.addEventListener(s(189)+"eeded",u=>{let g=s;IDqLkJ[g(1337)](_0x4bac5d,_0x528038(_0x3a0e38[g(1045)]),u[g(1389)+"on"],u[g(593)+"on"],IDqLkJ[g(1179)](_0x193d9a,_0x2e5e2a[g(511)+g(808)]))})}toBytesLE(){let r=t,s=this.high,d=this[r(1408)];return[255&d,e[r(473)](e[r(917)](d,8),255),e.sJsHb(d,16)&255,e[r(917)](d,24),255&s,e[r(246)](e[r(1107)](s,8),255),e[r(955)](e[r(371)](s,16),255),e[r(1330)](s,24)]}[t(1598)+"E"](){let r=t,s=this[r(738)],d=this[r(1408)];return[e[r(648)](s,24),e[r(520)](s,16)&255,e[r(1256)](e.atiEA(s,8),255),e[r(130)](255,s),d>>>24,e[r(1074)](d>>>16,255),e[r(951)](d,8)&255,255&d]}}let Bd=new le(0,0,!1),Bh=new le(0,0,!0),zh=le[t(537)](-1,2147483647,!1),Fh=le[t(537)](-1,-1,!0),Uh=le[t(537)](0,-2147483648,!1);var nn=(function(a){let r=t;return a[a[e[r(346)]]=5001]=e.XNrlw,a[a[e[r(1194)]]=5002]=e[r(1194)],a[a[e[r(1005)]]=5003]=e.zQLyx,a[a[e.eoCrj]=5004]=e.eoCrj,a[a[e[r(967)]]=5005]=e[r(967)],a})({});class Yn{constructor(r){let s=t;this.type=r,this[s(1373)]=null}}class zd extends Yn{constructor(r,s){let d=t;super(r),this[d(776)]=s&&s[d(776)]||null}}class Fd extends Yn{constructor(r,s){let d=t,u=e[d(193)].split("|"),g=0;for(;;){switch(u[g++]){case"0":this[d(310)]=s&&s[d(310)]||null;continue;case"1":super(r);continue;case"2":this[d(316)]=s&&s[d(316)]||0;continue;case"3":this.message=s&&s[d(776)]||"";continue;case"4":this[d(253)]=s&&s[d(253)]||0;continue;case"5":this[d(297)]=s&&s[d(297)]||"";continue;case"6":this.code=s&&s[d(995)]||5001;continue}break}}}class Ud extends Yn{constructor(r,s){let d=t,u=e.HceSi.split("|"),g=0;for(;;){switch(u[g++]){case"0":this[d(255)]=s&&s[d(255)]||!1;continue;case"1":this[d(995)]=s&&s[d(995)]||0;continue;case"2":super(r);continue;case"3":this["willReco"+d(524)]=s&&s[d(1142)+"nnect"]||!1;continue;case"4":this[d(274)]=s&&s.reason||"";continue}break}}}class qd extends Yn{constructor(r,s){let d=t;super(r),this[d(1333)]=s&&s.data||null}}class Hd extends qd{constructor(r,s){let d=t;super(r),this[d(1333)]=s&&s.data||null,this.message=s&&s[d(776)]||null}}class Gd extends Yn{constructor(r,s){let d=t;super(r),this.data=s&&s[d(1333)]||null}}function dt(a,{message:r,code:s,error:d}){let u=t;return e[u(1260)](e[u(378)],e.vRIjT)?null:new Fd(a,{message:r,code:s,error:d})}function gt(a,{code:r,reason:s,wasClean:d,willReconnect:u}){return new Ud(a,{code:r,reason:s,wasClean:d,willReconnect:u})}function jd(a,{data:r,message:s}){let d=t,u={gtyid:e[d(1069)],mLspl:e[d(1491)],DYgJd:e[d(1046)],FAAQg:e.kXuqT};if(d(682)===e[d(1387)])this[d(711)+"er"]&&_0x8f0281.addEventListener(u[d(571)],this["_handleO"+d(321)]),this[d(711)+"er"]&&_0x290f34.addEventListener(u[d(1170)],this[d(403)+d(1258)]),this[d(711)+"er"]&&_0x23b072[d(141)+"Listener"](u.DYgJd,this[d(1445)+d(1088)]),this[d(711)+"er"]&&_0x576431[d(141)+"Listener"](u[d(1459)],this[d(1445)+d(1016)]);else return new Hd(a,{data:r,message:s})}function Wd(a,{data:r}){return new Gd(a,{data:r})}function oa(a,{message:r}){return new zd(a,{message:r})}class Kd{constructor(r,s){let d=t;this[d(832)+"s"]=r,this[d(1156)+"es"]=s,this[d(1063)+"ndex"]=0,this[d(1255)+d(918)+d(1612)+"t"]=0}[t(459)+t(631)+t(283)](){let r=t;this[r(1063)+r(1638)]=0,this[r(1255)+r(918)+r(1612)+"t"]=0}[t(476)+"es"](){let r=t;if(e.qXsNL(e[r(667)],e[r(667)]))return _0x674e9a;this[r(1255)+"ndpointT"+r(1612)+"t"]=0}[t(618)+"ntEndpoint"](){let r=t;return this.endpoints[this[r(1063)+r(1638)]]}[t(618)+"ntEndpointTriesC"+t(1362)](){let r=t,s={oiBkv:function(d){return e[V(1525)](d)},XlJgo:function(d,u,g){return e[V(1478)](d,u,g)},OaPMx:function(d,u){return e[V(1239)](d,u)}};if(e[r(762)]===e.WUETV){let d=EOGPoY[r(139)](_0x1cd80f);return EOGPoY[r(1272)](_0x30a572,_0x3edc6f,d),EOGPoY.OaPMx(_0x12d954,d)}else return this[r(1255)+r(918)+r(1612)+"t"]}[t(151)+t(1418)+"es"](){let r=t;return!!(this[r(1063)+"ndex"]>=this[r(832)+"s"][r(515)]||e[r(1486)](this[r(1063)+r(1638)],this[r(832)+"s"][r(515)]-1)&&e[r(191)](this[r(1255)+r(918)+r(1612)+"t"],this[r(1156)+"es"]))}[t(887)+"rentEndp"+t(597)+t(1044)+t(184)](){let r=t;return e[r(501)](this["currentI"+r(1638)],this[r(832)+"s"].length)?!0:e[r(1401)](this["currentEndpointT"+r(1612)+"t"],this[r(1156)+"es"])}[t(223)+"ackupEnd"+t(825)+t(234)+t(1038)](){let r=t;return this["currentE"+r(918)+r(1612)+"t"]=1,this[r(1063)+r(1638)]++,this[r(832)+"s"][this[r(1063)+"ndex"]]}[t(618)+t(797)+t(642)+t(1364)](){let r=t;return this[r(1255)+r(918)+r(1612)+"t"]++,this[r(618)+r(797)+"nt"]()}}let Qn=(e[t(1265)](t(1177)+"d",typeof globalThis)&&e[t(417)](e.OUywr,globalThis[t(428)+t(723)][t(402)])||e[t(1550)]!=typeof window&&e[t(1011)]("Window",window[t(428)+"tor"][t(402)]))&&t(1177)+"d"!=typeof document,Cn=e[t(1550)]!=typeof globalThis&&(e[t(133)]===globalThis[t(428)+t(723)][t(402)]||e.svSnh(t(1326)+t(1509)+t(1122)+"pe",globalThis[t(428)+t(723)][t(402)]))&&e[t(904)](e.slAsy,typeof tt),Wr=(e[t(1265)](e[t(1550)],typeof globalThis)&&e.AxdjM(t(1083),globalThis[t(428)+t(723)][t(402)])||e.TdqjI(e[t(1550)],typeof globalThis)||e.PcsQd(e[t(1550)],typeof globalThis)&&!!globalThis["WeixinJS"+t(365)])&&e[t(845)](e[t(1550)],typeof wx),Kr=e[t(1220)](t(1177)+"d",typeof globalThis)&&(e[t(419)](t(1326)+t(1509)+t(1122)+"pe",globalThis[t(428)+t(723)].name)||e[t(819)]("SharedWo"+t(413)+t(1463),globalThis[t(428)+t(723)][t(402)])||e[t(759)](e[t(1317)],globalThis[t(428)+t(723)][t(402)]))&&e[t(250)](t(1177)+"d",typeof self),qh=e[t(574)](t(1177)+"d",typeof globalThis)&&e[t(644)](t(1083),globalThis[t(428)+t(723)].name)&&e[t(446)](e[t(1550)],typeof global)&&e.QcCQF(e[t(133)],global[t(428)+"tor"][t(402)])&&e[t(446)](e[t(1550)],typeof process)&&!!process.version;class aa{constructor(){let r=t;this[r(1025)+"rs"]={}}emit(r,...s){let d=t,u=this._listeners[r];if(u)u[d(401)]()[d(1470)](g=>g.fn.apply(g[d(1089)],s));else if(e[d(293)](e[d(1202)],r)&&!this[d(423)]){let g=s[d(515)]&&s[0];if(e[d(1557)](g,Error))throw g;let m=new Error(e.pVbma(e[d(542)],g?" ("+g.message+")":""));throw m[d(1131)]=g,g}return this}[t(594)](r,s){let d=t;if(e[d(819)](void 0,r))this[d(1025)+"rs"]={};else if(e[d(870)](void 0,s))this[d(1025)+"rs"][r]=null;else{let u=this[d(1025)+"rs"][r];if(u)for(let g=0;e.ADvHa(g,u[d(515)]);)u[g].fn===s?u[d(765)](g,1):++g}return this}on(r,s,d){let u=t;return(this[u(1025)+"rs"][r]||(this[u(1025)+"rs"][r]=[]))[u(1634)]({fn:s,ctx:d||this}),this}}class Hh extends aa{[t(197)+t(562)+t(1321)](r){let s=t,d={FIGIR:function(u,g,m,E){return e[V(1547)](u,g,m,E)}};if(e[s(273)](s(280),e[s(338)]))return r[s(588)]||r[s(1264)]?(s(491)+" "+(r.errMsg||"")+s(1065)+(r[s(1264)]||"")).trim():JSON.stringify(r);throw _0x41be3b=_0x3ab6bd.length,d[s(330)](_0x4df6e1,_0x2cb5d4,10,_0x3f693b[s(515)])}constructor(r,s,d){let u=t;super(),this[u(1119)]=null,Wr&&wx[u(1378)+u(989)]&&(this._socket=wx["connectS"+u(989)]({url:r,protocols:s,header:d,fail:this["_createS"+u(443)+u(1273)].bind(this),success:this[u(795)+u(1067)+u(1144)+"ler"][u(235)](this)})),Cn&&tt["connectS"+u(989)]&&(this[u(1119)]=tt[u(1378)+u(989)]({url:r,protocols:s,header:d,fail:this[u(795)+u(443)+"lHandler"][u(235)](this),success:this[u(795)+u(1067)+u(1144)+"ler"][u(235)](this)}))}[t(795)+t(1067)+t(1144)+t(323)](){let r=t;Promise.resolve()[r(1336)](()=>{this["_addWsLi"+r(1050)]()})}[t(795)+t(443)+t(1273)](r){let s=t,d={bMiNA:function(u,g,m){return e[V(315)](u,g,m)},JrFSU:e[s(1202)],uNIUl:e[s(384)]};Promise[s(1146)]().then(()=>{let u=s,g=d[u(1123)](dt,d.JrFSU,{message:this[u(197)+u(562)+"age"](r)});this[u(1482)](d[u(1604)],g);let m=d.bMiNA(gt,d[u(785)],{reason:this[u(197)+u(562)+u(1321)](r)});this[u(1482)](d[u(785)],m)})}["_addWsLi"+t(1050)](){let r=t,s={bTUyA:e.xMmst,dAhIk:function(d,u,g){return e.Gkvwh(d,u,g)},PaBJR:e.Jaagg,SIIMO:function(d,u,g){return e[V(737)](d,u,g)},BWtqy:e[r(1202)]};this[r(1119)][r(462)](d=>{let u=r;this[u(1482)](s[u(656)],s[u(1155)](Wd,s[u(656)],{...d,data:d[u(588)]||""}))}),this[r(1119)].onClose(d=>{let u=r;if(e[u(1560)]===e.lwGps)this[u(1482)](e[u(384)],e[u(1469)](gt,e.WTVPF,{...d}));else{let g=_0x579cc1.message[u(240)];g&&_0x3d1529.setCursors(g)}}),this[r(1119)][r(969)+"e"](d=>{let u=r;this[u(1482)](s[u(992)],s[u(1155)](jd,s[u(992)],{...d}))}),this[r(1119)][r(340)](d=>{let u=r;this[u(1482)](u(310),s[u(1284)](dt,s[u(865)],{...d,message:d.errMsg||""}))})}[t(1595)](r){let s=t,d={eEVDO:e[s(1103)]};if(e[s(1557)](r,Uint8Array)){if(e.WNqdG!==e[s(647)])return _0x2315b3||(_0x3146bf=_0x42856b.resolve().then(_0x2907c8[s(235)](_0x7d1de0,d[s(1544)]))),_0x50f698;{let u=r[s(1630)][s(401)](r[s(572)+"et"],r.byteLength+r.byteOffset);this._socket&&this[s(1119)][s(1595)]({data:u,fail:g=>{let m=s,E={KlIlr:e[m(384)]};e[m(382)](m(1366),e[m(1149)])?this[m(1482)](m(310),e[m(1178)](dt,m(310),{message:this[m(197)+"rrorMess"+m(1321)](g)})):this[m(1482)](m(1128),_0x31e2d4(ZRiaUY[m(444)],{..._0x158bde}))}})}}else this[s(1119)]&&this._socket[s(1595)]({data:r,fail:u=>{let g=s;this[g(1482)](g(310),e[g(374)](dt,e.rCCqa,{message:this[g(197)+g(562)+g(1321)](u)}))}})}[t(1128)](r,s){let d=t;this[d(1119)]&&this._socket[d(1128)]({code:r,reason:s})}addEventListener(r,s){this.on(r,s)}[t(1247)+t(348)+t(1379)](r,s){this[t(594)](r,s)}get[t(766)+"te"](){let r=t;return this[r(1119)][r(766)+"te"]}get[t(640)+"pe"](){let r=t;return this[r(1119)][r(640)+"pe"]}set[t(640)+"pe"](r){}get[t(319)](){let r=t;return e[r(293)]("mNTSL",e.WZkhf)?this[r(1119)][r(319)]:new _0x3f30da(_0x11d830,{data:_0x44f8c0,message:_0x935410})}get[t(1490)](){return this[t(1119)].protocol}get[t(1571)+"ns"](){let r=t;if(e[r(293)](e[r(937)],e[r(1380)]))e[r(591)](_0x31bcf2,this["_pingPon"+r(1087)+"Id"]),e[r(910)](_0x317e53,this["_reconne"+r(1118)+r(172)]),this["_pingPon"+r(1087)+"Id"]=null,this[r(1031)+r(1118)+r(172)]=null;else return this[r(1119)][r(1571)+"ns"]}get["buffered"+t(637)](){return 0}}function Gh(a,r){let s=t;if(r)return new r(a[s(319)],a[s(1490)]);if(e[s(686)](Wr,Cn))return new Hh(a[s(319)],a[s(1490)],a[s(1231)]);if(e[s(686)](Qn,Kr)&&s(1177)+"d"!=typeof WebSocket&&WebSocket)return new WebSocket(a[s(319)],a[s(1490)+"s"])}function jh(a){let r=t;if(e.NYgbC(e[r(1375)],e[r(1375)]))this["flushExp"+r(258)]();else return!!(a||Wr&&wx[r(1378)+r(989)]||Cn&&tt[r(1378)+"ocket"]||e[r(395)](Qn,Kr)&&e.Xcdcl("undefined",typeof WebSocket)&&WebSocket)}function $d(a,r,s){let d=t,u={IZYUA:function(g,m){return e.umBOu(g,m)},nYMAV:function(g,m){return e[V(1168)](g,m)}};if(e[d(124)](e.oYPhO,e[d(758)])){let g=-1;async function m(E){let h=d;return u.IZYUA(E,g)?Promise[h(157)](new Error(h(1414)+"alled mu"+h(1174)+h(144)+h(287))):(g=E,E===s.length?Promise[h(1146)]():s[E][h(235)](a)(r,m.bind(null,u[h(784)](E,1))))}e[d(362)](m,0)}else this[d(177)+"lTimeoutId"]=null,this._interval=36e5,this[d(1219)]=_0x48acc9(e[d(1566)],d(467)+"id")}function Jd(a){let r=t,s=0,d=0;for(let u=0;e[r(778)](u,a[r(515)]);++u)d=a.charCodeAt(u),e[r(915)](d,128)?s+=1:e[r(1166)](d,2048)?s+=2:e[r(1193)](e.uhUcD(64512,d),55296)&&e[r(1173)](e.ROspU(64512,a[r(813)+"At"](e[r(1153)](u,1))),56320)?(++u,s+=4):s+=3;return s}function Vd(a,r,s){let d=t;if(e[d(1073)](e.ummfY(s,r),1))return"";let u="";for(let g=r;e.HSkzm(g,s);){let m=a[g++];if(m<=127)u+=String[d(1216)+d(1036)](m);else if(e[d(1008)](m,192)&&e.vTNXQ(m,224))u+=String[d(1216)+d(1036)](e[d(1243)](e[d(615)](31,m),6)|e[d(705)](63,a[g++]));else if(e.tXzbi(m,224)&&e[d(445)](m,240))u+=String["fromChar"+d(1036)](e.CIapc(e.nTOaK((15&m)<<12,(63&a[g++])<<6),e[d(1259)](63,a[g++])));else if(e[d(492)](m,240)){let E=e.XIFVd(e[d(1510)](e[d(592)](7,m)<<18,e.OlDoF(e[d(528)](63,a[g++]),12))|e[d(538)](e[d(1020)](63,a[g++]),6)|e[d(1603)](63,a[g++]),65536);u+=String[d(1216)+d(1036)](e.SdBQO(55296,E>>10)),u+=String[d(1216)+d(1036)](e[d(432)](56320,e.kHrWW(1023,E)))}}return u}function ca(a,r,s){let d=t,u=s,g,m;for(let E=0;e[d(1241)](E,a[d(515)]);++E)if(g=a.charCodeAt(E),g<128)r[s++]=g;else if(e.KwaYo(g,2048))if(e[d(1011)](d(1529),d(1342))){let h=new _0x3cf96f(2*_0x4c73ba);h.set(_0x3eda2c),_0x4ec257.bytes=h}else r[s++]=e[d(307)](g>>6,192),r[s++]=e[d(1150)](e.olDKg(63,g),128);else(64512&g)===55296&&e.BSFtl(e[d(1256)](64512,m=a[d(813)+"At"](e[d(1237)](E,1))),56320)?(g=65536+e.pyWvO(e.SdhdQ(1023,g),10)+(1023&m),++E,r[s++]=e[d(1433)](g>>18,240),r[s++]=e[d(882)](e[d(1196)](e[d(379)](g,12),63),128),r[s++]=e.zYlcc(e[d(311)](g>>6,63),128),r[s++]=e.OOqhI(e.MpbvW(63,g),128)):(r[s++]=e[d(307)](e.Jwupn(g,12),224),r[s++]=e[d(485)](e.ScPQz(e[d(1252)](g,6),63),128),r[s++]=e.nTOaK(e[d(742)](63,g),128));return e.ummfY(s,u)}async function Zd(a){let r=t;if(e.Fixyl==typeof a){let s=new Uint8Array(Jd(a));return e[r(856)](ca,a,s,0),s}return a instanceof ArrayBuffer?new Uint8Array(a):new Uint8Array(a[r(1630)],a[r(572)+"et"],a[r(1421)+"th"])}function Wh(a){let r=t;try{return e[r(480)]!=typeof a&&(a instanceof ArrayBuffer||a[r(1630)]&&e[r(1361)](a[r(1630)],ArrayBuffer))||e[r(343)](e[r(480)],typeof a)?"":(JSON[r(431)](a),"applicat"+r(842))}catch{return e[r(480)]==typeof a?e[r(448)]:""}}let Kh=(a,r)=>{let s=t;if(e[s(747)](e[s(693)],e[s(693)]))switch(a){case e[s(272)]:case e.WCZCb:return{["x-use-"+a]:1,"x-tt-env":r};default:return{}}else{let{pingInterval:d,pingFrequency:u}=ue[s(1551)];if((e[s(363)]("hi",_0x189fbf[s(1333)])&&e[s(819)](s(324),u)||e[s(1343)](e[s(122)],u))&&(ue[s(636)+"ngTimer"](),ue.emit(e.veLwQ,e[s(966)]),ue["_pingPon"+s(1087)+"Id"]=_0x95f23a(ue[s(313)][s(235)](ue),d)),e[s(870)]("hi",_0x403922.data))return;try{e[s(425)](_0x9ea30b,ue,_0x17da21,[_0x40cc7e,_0x4d5562,_0x262c15,_0x5985d3,_0x169f99,_0x177734])}catch(g){let m=e[s(737)](_0x4e3d24,e[s(1202)],{message:g[s(776)],code:_0x560fae[s(641)+s(587)],error:g});ue["_dispatc"+s(1102)+s(1126)](m)}}};class $h{constructor(r){let s=t;this.maxLossCount=r,this[s(1303)]=0}[t(1307)](){let r=t;this[r(1303)]++}[t(151)+t(814)+"nt"](){let r=t;return this[r(1303)]>=this["maxLossC"+r(1362)]}[t(358)+t(1206)](r=0){let s=t;this[s(939)+s(1362)]=r,this.count=0}}async function Jh(a){let r=t,s={iQttE:function(d,u){return e[V(1229)](d,u)},aUDXe:e[r(1139)],KOSbZ:e[r(1370)],mMXfs:e[r(998)],WCojv:r(721),GvnRa:e[r(563)]};return new Promise(d=>{let u=r;if(!Qn)return d("unknown reason");try{let g=document[u(1431)+"ement"](s[u(888)]);window[u(876)+u(1227)]=m=>{let E=u;document.body[E(435)+E(1384)](g),window["frontier"+E(1227)]=void 0,s[E(741)](d,m&&m[E(1279)]||s[E(238)])},g.type=s[u(1192)],g[u(1565)]=a[u(632)](/^ws/,s.WCojv)+s[u(521)];try{document[u(1382)]["appendCh"+u(1384)](g)}catch{document[u(1382)]["removeCh"+u(1384)](g)}}catch{window[u(876)+u(1227)]=void 0,d(s[u(238)])}})}function rn(a,r,s){let d=t;if(e[d(1011)](e[d(1582)],e[d(1582)]))return!!a?.[d(1003)](u=>u[d(921)]===r&&u[d(143)]===s);if(this[d(636)+"ngTimer"](),this[d(770)+d(1282)](),this[d(1505)+"sListeners"](),this[d(424)+"nceClose"](1e3,_0x53d107),this[d(1513)+d(1450)]=!1,_0xe541cf&&this[d(671)+d(761)]()&&!this[d(817)+d(500)]){if(this[d(801)+"tManager"]?.[d(151)+"chMaxTries"]()){let g=this[d(801)+d(978)]?.[d(618)+d(797)+"nt"]();this[d(1236)+d(357)+d(1126)](_0xfde83(d(1128),{code:1006,reason:"connect "+g+(" timeout, max re"+d(1198)+d(1079)),wasClean:!0}))}else{let g=this._options[d(781)+d(1468)+d(1501)](_0x521c84,_0x30da1c);this["_dispatc"+d(357)+d(1126)](e[d(1140)](_0x105f68,"close",{code:_0x20b2d7,reason:_0x5a95f2,wasClean:!0,willReconnect:g})),g&&this._connect()}return}this["_navigat"+d(761)]()||this[d(817)+d(500)]?this[d(1236)+d(357)+d(1126)](_0x239e4c("close",{code:_0x331de8,reason:e.QLSul})):this[d(1236)+"hCloseEv"+d(1126)](_0x87a13b(e[d(384)],{code:1006,reason:e[d(195)]})),this[d(1473)]=null,this._endpointManager?.["resetEnd"+d(631)+d(283)](),this[d(1422)+"sCounter"]?.resetCounter()}function er(a,r){let s=t;return a?.[s(1003)](d=>d[s(921)]===r)?.[s(143)]}let da=null;async function Vh(){let a=t;return da||(da=Promise.resolve()[a(1336)](Bt[a(235)](Bt,e[a(1103)]))),da}class Zh extends aa{constructor(r,s){let d=t;super(),this[d(1578)]=r,this[d(1040)]=s,this._qosDB=void 0,this[d(1584)+d(829)]=null}async[t(1006)](){await this[t(261)]()}async _init(){let r=t;if(!this._qosDB){if(this[r(1584)+r(829)])return this[r(1584)+r(829)];try{let s=this[r(1578)],d=this._keyPath;this[r(1584)+"mise"]=(async()=>{let u=r,{openDB:g}=await e[u(523)](Vh);this._qosDB=await e[u(425)](g,u(876)+"_"+s,1,{upgrade(m){m["createOb"+u(328)+"e"](s,{keyPath:d})}})})(),await this[r(1584)+"mise"]}catch(s){console[r(452)](s)}finally{this[r(1584)+r(829)]=null}}}async[t(167)](r){let s=t;try{return await this._init(),this[s(1219)]?.[s(167)](this[s(1578)],r)}catch(d){console[s(452)](d)}}async[t(558)](r,s){let d=t;return await this[d(261)](),this[d(1219)]?.[d(1261)](this._dbName,r)}async del(r){let s=t;if(e.XGwfp("avlwb",e[s(1012)]))_0x2ef475.exports=_0x2d3025[s(1146)]().then(()=>(_0x27c205(),_0x52449e))[s(1336)](function(d){return d});else try{return await this[s(261)](),this._qosDB?.delete(this._dbName,r)}catch(d){console[s(452)](d)}}async clear(){let r=t;try{return await this[r(261)](),this[r(1219)]?.[r(740)](this._dbName)}catch(s){console[r(452)](s)}}async keys(){let r=t;return await this[r(261)](),this[r(1219)]?.[r(230)+"ys"](this[r(1578)])}async[t(1334)](){let r=t;return await this[r(261)](),this[r(1219)]?.getAll(this[r(1578)])}async closeDB(){let r=t;if(e.gqLGw!==e[r(1135)])this._listeners={};else try{this[r(1219)]?.[r(1128)](),this._qosDB=void 0}catch(s){console[r(452)](s)}}get[t(922)](){let r=t;try{return!!this[r(1219)]}catch(s){return console.log(s),!1}}}class Xh{constructor(r,s){let d=t;e.CxQQI(d(847),e[d(146)])?_0x9b366.o=(u,g)=>_0x572131[d(1608)+"e"][d(1096)+d(147)][d(929)](u,g):(this[d(533)]=r,this._pathKey=s,this[d(1219)]=localStorage)}async[t(1006)](){}get[t(244)](){let r=t;return r(876)+"_"+this[r(533)]}async get(r){let s=t,d=this[s(1219)][s(194)](this[s(244)]);return JSON[s(431)](d||"{}")[r]}async[t(558)](r,s){let d=t,u=this[d(1219)][d(194)](this[d(244)]),g=JSON[d(431)](e[d(395)](u,"{}"));return g[s||r[this[d(598)]]]=r,this[d(1219)].setItem(this[d(244)],JSON.stringify(g)),s||r[this[d(598)]]}async[t(161)](r){let s=t;if(e[s(1486)](e.MgwPR,e[s(1203)]))return _0x2271e3?.[s(1003)](d=>d.key===_0x1cfcb6)?.[s(143)];{let d=this[s(1219)].getItem(this[s(244)]),u=JSON[s(431)](e.eHEOX(d,"{}"));return u[r]=void 0,this[s(1219)][s(335)](this._prefix,JSON.stringify(u))}}async[t(740)](){let r=t;return this[r(1219)][r(740)]()}async[t(1290)](){let r=t,s=this._qosDB[r(194)](this[r(244)]),d=JSON[r(431)](e[r(566)](s,"{}"));return Object[r(1290)](d)}async[t(1334)](){let r=t,s=this[r(1219)][r(194)](this._prefix),d=JSON[r(431)](e[r(686)](s,"{}"));return Object[r(713)](d)}[t(1214)](){return Promise[t(1146)]()}get isReady(){return!!this[t(1219)]}}class Yh{constructor(r,s){let d=t;this[d(533)]=r,this[d(598)]=s,this[d(1219)]=Cn?tt:Wr?wx:null}async openDB(){}get[t(244)](){let r=t;return r(876)+"_"+this[r(533)]}async[t(167)](r){let s=t,d=this[s(1219)][s(1228)+s(156)](this._prefix);return JSON.parse(e[s(395)](d,"{}"))[r]}async set(r,s){let d=t,u=this._qosDB[d(1228)+"geSync"](this[d(244)]),g=JSON[d(431)](e.ceaah(u,"{}"));return g[s||r[this[d(598)]]]=r,this._qosDB[d(1549)+d(156)](this[d(244)],JSON[d(451)+"y"](g)),s||r[this[d(598)]]}async[t(161)](r){let s=t,d=this._qosDB.getStorageSync(this[s(244)]),u=JSON[s(431)](e[s(931)](d,"{}"));return u[r]=void 0,this[s(1219)][s(1549)+s(156)](this._prefix,JSON[s(451)+"y"](u))}async[t(740)](){let r=t;return this._qosDB[r(703)+"rageSync"]()}async[t(1290)](){let r=t,s=this[r(1219)][r(1228)+r(1628)+"nc"](this._prefix),d=JSON[r(431)](e[r(931)](s,"{}"));return Object[r(1290)](d)}async[t(1334)](){let r=t;if(r(663)!==r(663))_0x525cb5+=e[r(1449)](_0x4aee45,_0x3691df),_0x26cb27++;else{let s=this[r(1219)]["getStora"+r(1628)+"nc"](this._prefix),d=JSON.parse(e[r(1427)](s,"{}"));return Object[r(713)](d)}}[t(1214)](){return Promise[t(1146)]()}get isReady(){return!!this[t(1219)]}}function Xd(a,r){let s=t;if(e[s(881)](Cn,Cn))return new Yh(a,r);if(e[s(1606)](Qn,Kr)&&e[s(1550)]!=typeof indexedDB)return new Zh(a,r);if(e[s(1223)](Qn,Kr)&&e[s(1550)]!=typeof localStorage)return new Xh(a,r);throw new Error(s(1611)+s(1187)+"d")}class Qh{constructor(){let r=t;this["_interva"+r(168)+"Id"]=null,this[r(177)+"l"]=36e5,this[r(1219)]=e[r(1183)](Xd,e.VXXVV,e[r(1572)])}async[t(177)+"lFlush"](){let r=t;e[r(810)](clearInterval,this[r(177)+r(168)+"Id"]),this[r(177)+r(168)+"Id"]=e[r(239)](setInterval,()=>{let s=r,d={iskBh:function(u,g,m){return e.kBqIW(u,g,m)},miAhf:e.WTVPF};if(e[s(1347)](e[s(1212)],e.qKbCi)){let u=this[s(801)+s(978)]?.[s(618)+s(797)+"nt"](),g=this[s(1551)]["reconnectInterce"+s(1501)](_0x25c340[s(995)],_0x4352f6[s(274)]);this[s(1236)+"hCloseEv"+s(1126)](d.iskBh(_0x109c5b,d[s(263)],{code:1006,reason:_0x102bb4[s(274)]||s(1614)+s(1066)+s(999)+s(412)+"n, hostname: "+u,willReconnect:g})),g&&this[s(1513)]();return}else this[s(1210)+s(258)]()},this[r(177)+"l"])}async[t(1006)](){let r=t;await this._qosDB[r(1006)]()[r(1336)](()=>{let s=r;this[s(177)+s(550)]()})}async["flushExp"+t(258)](){let r=t;(await this[r(1219)]?.[r(1334)]()||[])[r(645)](({timestamp:u})=>u<Date[r(276)]())[r(1470)](u=>{let g=r;this[g(1219)]?.[g(161)](u.message_id)})}async[t(161)](r){let s=t;return this[s(1219)]?.[s(161)](r)}async[t(558)](r,s){let d=t;return e.skyBJ(e[d(777)],e.NLMcK)?_0xd70379||(_0x151425=[_0x2a9cd2,_0x3fd46a,_0x5c2143,_0x27c832,_0x4d3a3f]):this._qosDB?.[d(558)]({message_id:r,timestamp:s})}async[t(167)](r){return this[t(1219)]?.get(r)}async closeDB(){let r=t;clearInterval(this[r(177)+"lTimeoutId"]),await this[r(1219)]?.[r(1214)]()}get[t(922)](){let r=t;return this[r(1219)]?.[r(922)]}}function la(a){let r=t,s=!!this[r(1551)][r(265)+"S"];if(!s)return{enabled:s,isQoSMessage:!1,isQoSAck:!1,isAckCleanupMessage:!1,ackMsgIds:[]};let d=e[r(368)](rn,a[r(776)][r(1231)],e[r(977)],"2"),u=d&&e[r(1402)](rn,a[r(776)][r(1231)],r(1154)+r(779)+"ck","1"),g=d&&rn(a[r(776)][r(1231)],e.OGDNe,"1"),m=g?e[r(248)](er,a[r(776)].headers,e[r(1487)])?.[r(1620)](",")[r(645)](Boolean)||[]:[];return{enabled:s,isQoSMessage:d,isQoSAck:u,isAckCleanupMessage:g,ackMsgIds:m}}async function Yd(){let a=t;return this[a(1327)+"ger"]||(this[a(1327)+a(1207)]=new Qh),this[a(1327)+a(1207)][a(922)]||await this[a(1327)+"ger"][a(1006)](),this._QoSManager}async function ep(a,r){let s=t;if(e[s(293)](s(1400),s(1400))){let{enableAutoAck:d}=this[s(1551)],u=e[s(425)](rn,a[s(776)].headers,"need_ack","1"),g=e[s(1561)](rn,a.message[s(1231)],e[s(1537)],"1"),m=la[s(929)](this,a);if(e[s(429)](d,u))if(e[s(759)](e[s(1057)],e[s(1057)])){let{SeqID:E,LogID:h,service:k,LogIDNew:I,method:N}=a[s(776)];this._sendAck({SeqID:E,LogID:h,LogIDNew:I,service:k,method:N,headers:[{key:e[s(1537)],value:"1"},{key:s(1277),value:e[s(1427)](I,"")},{key:"ack_code",value:"0"}]})}else return _0x46ce84[s(588)]||_0x5099a8[s(1264)]?(s(491)+" "+(_0xdf4110[s(588)]||"")+s(1065)+(_0x29601d[s(1264)]||""))[s(341)]():_0x217af7[s(451)+"y"](_0x4425d6);g&&!m[s(1322)]&&this[s(1236)+"hAckMessageEvent"](a),r()}else return{bytes:_0x112040,offset:0,limit:_0x2e6eed[s(515)]}}async function tp(a,r){let s=t;this[s(733)](e[s(1328)],a[s(776)]),e[s(1525)](r)}async function np(a,r){let s=t,d=e[s(1521)](en,await Zd(a.data));try{if(d[s(240)]instanceof Uint8Array){let u=e[s(1361)](this[s(1551)][s(489)+"ncoding"],Object)?{force:!!this[s(1551)]["payloadE"+s(623)][s(1082)],encoding:this[s(1551)][s(489)+s(623)][s(1035)]?this[s(1551)][s(489)+s(623)].encoding[s(632)](/\s/g,"")[s(560)+s(1145)]():""}:{force:!1,encoding:this._options["payloadE"+s(623)]?this._options[s(489)+s(623)][s(632)](/\s/g,"")["toLowerC"+s(1145)]():""},g=d[s(489)+s(623)]?d["payloadE"+s(623)][s(632)](/\s/g,"")[s(560)+s(1145)]():"",m=e[s(1361)](this[s(1551)][s(787)+s(639)],Object)?{force:!!this[s(1551)][s(787)+"ype"][s(1082)],type:this[s(1551)][s(787)+"ype"][s(1436)]?this[s(1551)][s(787)+"ype"][s(1436)][s(632)](/\s/g,"")[s(560)+s(1145)]():""}:{force:!1,type:this._options[s(787)+s(639)]?this[s(1551)][s(787)+s(639)][s(632)](/\s/g,"")[s(560)+s(1145)]():""},E=d["payloadT"+s(639)]?d["payloadT"+s(639)][s(632)](/\s/g,"")[s(560)+s(1145)]():"",h=m[s(1082)]?m[s(1436)]:E||m[s(1436)],k=u[s(1082)]?u[s(1035)]:g||u.encoding,I=[e[s(448)],s(899)+s(842),"applicat"+s(842)+s(1042)+s(1355),s(509)],N=[s(580)+"e",e[s(790)]];this._options[s(1288)+"ansformT"+s(756)+"ad"]&&I[s(344)](h)&&(!k||N[s(344)](k))?d[s(1120)+s(334)]=e.fUswZ(Vd,d.payload,0,d[s(240)][s(1421)+"th"]):d[s(1120)+s(334)]=""}else d[s(1120)+s(334)]=""}catch(u){d[s(1120)+s(334)]="",console[s(452)](u)}a[s(776)]=d,e.jbfaB(r)}function rp(a,r,s){let d=t,u={eQXDi:function(k,I){return k<I},DGJhx:function(k,I){return k>I},poZWW:function(k,I){return k(I)},Riphk:function(k,I){return e.MssTE(k,I)},Atbzb:function(k,I){return e[V(1569)](k,I)},coJtB:function(k,I){return e.wPltB(k,I)}},g=e[d(397)](s,8192),m=e.baFPf(g,1),E=null,h=g;return function(k){let I=d;if(u[I(1295)](k,1)||u.DGJhx(k,m))return u[I(228)](a,k);u[I(841)](u.Riphk(h,k),g)&&(E=u.poZWW(a,g),h=0);let N=r[I(929)](E,h,h+=k);return u[I(479)](7,h)&&(h=u[I(364)](7,h)+1),N}}let ip=4294967295;function sp(a,r,s){let d=t;return e.PaYPz(RangeError,e.ZBCcL(e.rHQCV(e[d(1028)](e[d(694)](e[d(543)],a),e[d(897)]),r||1),e[d(959)])+s)}function op(a,r,s){let d=t;if(s>ip)throw new Error(e[d(1238)]);let u=3;for(;e.gVLNI(u,0);){let g=e[d(1341)](255,s);e[d(896)](ua,g,a,r+u),s>>>=8,u--}return e[d(400)](r,4)}function ap(a,r){let s=t,d=0,u=r,g=e[s(750)](r,4);for(;e[s(1460)](u,g);){let{value:m,offset:E}=e[s(1564)](fa,a,u);u=E,d=e[s(688)](d,8)>>>0,d+=m}return{value:d,offset:g}}function cp(a,r,s){let d=t,u=e[d(271)].split("|"),g=0;for(;;){switch(u[g++]){case"0":if(e[d(445)](a[d(515)],40))return e[d(368)](ca,a,r,s)+s;continue;case"1":return e[d(1024)](e[d(1402)](ca,a,r,s),s);case"2":if(r[d(305)+"e"])return e[d(695)](r.utf8Write(a,s),s);continue;case"3":if(!a)return s;continue;case"4":if(r[d(739)])return e[d(1502)](r[d(739)](a,s),s);continue}break}}function dp(a,r){let s=t,d=new le(e[s(485)](e[s(118)](e[s(786)](e.ZtBRQ(a[e[s(522)](r,4)],24),a[r+5]<<16),e[s(303)](a[e[s(895)](r,6)],8)),a[e[s(581)](r,7)]),e[s(1499)](e[s(1573)](e[s(1439)](e[s(905)](a[e[s(1559)](r,0)],24),e[s(1297)](a[e[s(1237)](r,1)],16)),a[e[s(908)](r,2)]<<8),a[e[s(1024)](r,3)]),!0);return r+=8,{value:d,offset:e[s(1308)](r,8)}}function lp(a,r,s){let d=t,u=a.low,g=a[d(738)];return r[s]=e[d(879)](g,24),r[e.XWEKy(s,1)]=e[d(676)](e[d(1552)](g,16),255),r[e[d(1559)](s,2)]=e[d(680)](e[d(1185)](g,8),255),r[s+3]=e[d(1099)](255,g),r[e.CYusQ(s,4)]=e[d(1515)](u,24),r[e.HDAdx(s,5)]=e[d(427)](u,16)&255,r[e[d(907)](s,6)]=e[d(1396)](e[d(1404)](u,8),255),r[s+7]=255&u,s+=8,s}function fa(a,r){let s=t,d={sSKvq:function(u,g,m){return e.CgPVs(u,g,m)}};if(e[s(1545)](e[s(477)],e.kJtcd))return a[s(1112)+"8"]?{value:a.readUInt8(r),offset:e[s(1602)](r,1)}:{value:e[s(1169)](255,a[r]),offset:r+1};this[s(1041)+s(936)]=_0x187791,this[s(464)+s(127)]=_0x2582ea,this[s(383)+s(329)]=_0x1e7f96,this._qosDB=d[s(164)](_0x3748ef,this[s(1041)+s(936)],"cursor_name")}function ua(a,r,s){return r.writeUint8?r.writeUint8(a,s):r[s]=e.pDYdm(255,a),e.MOQXE(s,1)}let fp=function(a){return new Uint8Array(a)},up=e[t(1550)]!=typeof Buffer?Buffer[t(1086)+t(855)]:e[t(1587)](rp,fp,Uint8Array[t(1608)+"e"][t(1215)]),xp=16,xa=32;function hp(a){let r=t,s=0,d={};for(let u=0;e[r(812)](u,a[r(515)]);u++)d[a[u][r(729)+r(1077)]]=e[r(217)](Jd,a[u][r(729)+r(1077)]),s+=e[r(1028)](14,d[a[u][r(729)+r(1077)]]);return[s,d]}function Qd(a,r,s){let d=t,u={HCNJD:e[d(1318)],hSrip:d(1022),mgQuK:function(k,I,N,q){return k(I,N,q)},PyzcW:e[d(1453)],qPXJH:function(k,I,N,q){return e[d(803)](k,I,N,q)},FhUdv:e.ocAEY,RRGPg:e[d(1452)]},[g,m]=e.nsnWx(hp,a),E=e[d(1533)](up,g),h=0;return a.forEach(k=>{let I=d,N=u[I(864)][I(1620)]("|"),q=0;for(;;){switch(N[q++]){case"0":console[I(452)](u[I(1189)],h);continue;case"1":h=op(E,h,k[I(288)]||0);continue;case"2":h=u.mgQuK(ua,m[k[I(729)+"ame"]],E,h);continue;case"3":console.log(u[I(1111)],k,k[I(288)]);continue;case"4":h=u[I(804)](ua,0,E,h);continue;case"5":console[I(452)](u.FhUdv,h);continue;case"6":h=u[I(1493)](cp,k[I(729)+I(1077)],E,h);continue;case"7":console[I(452)](I(861),h);continue;case"8":console[I(452)](u[I(909)],h);continue;case"9":console.log("service",h);continue;case"10":h=u[I(804)](lp,le[I(752)+"er"](k[I(794)]||r),E,h);continue}break}}),{frameType:xa,headers:[{key:e[d(1395)],value:s}],payload:E}}function pp(a){let r=t,s=0,d=[];for(;e[r(545)](s,a[r(1421)+"th"]);){let{offset:u}=e[r(997)](fa,a,s);s=u;let g={cursor_name:"",cursor:0,service:0},{value:m,offset:E}=e[r(315)](ap,a,s);g[r(288)]=m,s=E;let{value:h,offset:k}=e.UMtzp(fa,a,s);s=k,g[r(729)+r(1077)]=e[r(1561)](Vd,a,s,e.DlXOE(s,h)),s+=h;let{value:I,offset:N}=e[r(602)](dp,a,s);g[r(794)]=I[r(651)](),s=N,d.push(g)}return d}function gp(){let a=t;return{frameType:xa,headers:[{key:e[a(1395)],value:a(1519)+a(1233)}],payload:void 0}}class mp{constructor(r,s,d){let u=t;this["_cursorN"+u(936)]=r,this["_cursorF"+u(127)]=s,this["_message"+u(329)]=d,this[u(1219)]=e[u(635)](Xd,this[u(1041)+u(936)],e[u(149)])}async[t(1006)](){let r=t;if(e[r(302)](e[r(953)],r(960)))await this[r(1219)].openDB();else return _0x5c82be&&e[r(212)](!0,_0x10c803[r(1575)])}async getCursors(){let r=t;if(!this[r(1219)][r(922)])return;let s=this._messageStrategy,d=await this[r(1219)].getAll();switch(console.log(e[r(816)],d),s){case e[r(536)]:return d&&d[r(515)]?e.CzVRD(Qd,d,0,this["_cursorF"+r(127)]):void 0;case e.NTwVv:return;case e[r(1070)]:return d&&d[r(515)]?e[r(1068)](Qd,d,0,this._cursorFileName):e[r(1525)](gp)}}async[t(558)](r,s,d){let u=t;return console.log(u(245),r,s,d),this[u(1219)].set({cursor_name:r,cursor:s,service:d})}async[t(685)+"rs"](r){let s=t,d=e[s(1568)](pp,r);for(let u of d)console.log(s(1167)+"r",d),await this[s(1219)].set(u)}async[t(167)](r){let s=t;return(await this[s(1219)][s(167)](r))?.[s(794)]}async closeDB(){let r=t;await this[r(1219)][r(1214)]()}[t(1528)+"rsorFile"+t(1522)](r){let s=t;this[s(464)+s(127)]=r}get[t(922)](){let r=t,s={yIBgR:e[r(114)]};if(e[r(456)]===e.EBEzz)this[r(1482)](s[r(1357)],_0x13337b),this[r(540)]&&this[r(540)](_0x1043a9);else return this._qosDB.isReady}}let wp=t(709)+t(295);async function e0(a){let r=t;if(e[r(1344)](e[r(388)],e[r(610)])){if(!this._options[r(265)+"S"])return null;let{aID:s,fpID:d,messageStrategy:u}=this[r(1551)],g=a||wp;try{return this["_cursorM"+r(919)]?a&&this[r(928)+"anager"][r(1528)+r(1009)+r(1522)](a):this[r(928)+r(919)]=new mp(d+"_"+s+"_"+g,g,u),this["_cursorM"+r(919)][r(922)]||await this[r(928)+r(919)][r(1006)](),this[r(928)+r(919)]}catch{return null}}else return e[r(480)]==typeof _0x58eac3?e[r(448)]:""}async function _p(a,r){let s=t,d=e[s(1001)](rn,a[s(776)].headers,"code","-1"),u=rn(a[s(776)].headers,e[s(1537)],"1"),g=e.ICvmh(er,a.message[s(1231)],e[s(513)]),m=e[s(957)](Number,er(a[s(776)][s(1231)],e[s(1548)]))||0,E=la.call(this,a),h=rn(a[s(776)].headers,e.ojOqV,"2"),k=er(a.message[s(1231)],e[s(1346)]),I=e[s(727)](Number,e.msfEr(er,a[s(776)].headers,e[s(450)]));if(E[s(1322)])return e[s(1635)](r);let N=E.isQoSMessage?await Yd[s(929)](this):null;if(e.ExAPN(a[s(776)][s(288)],0)&&u&&!d||e[s(950)](a[s(776)][s(288)],0)){if(g&&E[s(160)+s(1448)]&&N)return!!!await N[s(167)](g)&&(this[s(1236)+"hMessage"+s(589)](a),await N.set(g,e[s(432)](Date[s(276)](),m))),r();if(h){let q=await e0.call(this);if(!q)return this["_dispatc"+s(827)+s(589)](a),e[s(862)](r);let U=await q[s(167)](k)??-1;if(e[s(322)](U,I))this[s(1236)+s(827)+s(589)](a),q[s(558)](k,I,a[s(776)][s(288)]);else throw new Error("recevied"+s(1116)+s(426)+I+(s(1132)+s(1113)+s(911)+"r ")+U);return r()}return this[s(1236)+"hMessageEvent"](a),e[s(262)](r)}}async function yp(a,r){let s=t,d=la[s(929)](this,a);if(!d[s(160)+s(1448)])return e[s(523)](r);let u=await Yd[s(929)](this);if(d[s(732)+s(943)+s(1321)]&&d[s(347)+"s"].length)for(let g of d[s(347)+"s"])await u[s(161)](g);r()}async function Ep(a,r){let s=t,d=a[s(776)].frameType===xp,u=a.message.frameType===xa;if(e.EywgJ(!d,!u))return e[s(439)](r);let g=e[s(374)](er,a.message[s(1231)],e[s(1395)]);if(!g)return e[s(862)](r);let m=await e0[s(929)](this,g);if(!m)return r();if(d){let E=await m.getCursors(),h={frameType:E?.[s(1458)+"e"],SeqID:le[s(752)+"er"](this[s(155)]++),LogID:le.fromNumber(this._options[s(1504)+s(548)]()),service:9e3,method:5,headers:E?.headers,payload:E?.payload},k=e[s(372)](T,h);this._ws&&this[s(1473)][s(766)+"te"]&&this._ws[s(1595)](k)}if(u){let E=a.message[s(240)];E&&m[s(685)+"rs"](E)}}let bp=async function(a,r){let s=t;this[s(385)]=!1,clearTimeout(this[s(1513)+"ionTimeo"+s(1161)]),e.EvevM(r)},vp=async function(a,r){let s=t;if(!this[s(1473)]||this[s(1473)][s(766)+"te"]!==this[s(755)])return e[s(262)](r);let{pingInterval:d}=this[s(1551)];this["_endpoin"+s(978)]?.[s(459)+s(631)+s(283)]();for(let g=0;g<this[s(383)+s(1368)].length;g++){let m=this[s(383)+s(1368)][g];if(e[s(747)](this[s(1473)][s(766)+"te"],this[s(755)])&&m!==null)if(e[s(672)]===e[s(672)])this[s(1473)]&&this._ws[s(1595)](m),this._messageQueue[g]=null;else{let E=e[s(217)](_0x23cd9c,_0x5b6ff9);this[s(1473)]&&this[s(1473)][s(766)+"te"]===this[s(755)]&&(this[s(1473)]&&this[s(1473)].send(E),this[s(733)](e[s(579)],_0x527297))}else break}this[s(383)+s(1368)]=this[s(383)+"Queue"][s(645)](g=>!!g),this[s(754)+s(1087)+"Id"]=e[s(1027)](setTimeout,()=>this[s(313)](),d),this[s(1236)+"hOpenEvent"](a),this._isBrowser&&this._ws&&(this[s(1473)][s(640)+"pe"]=this[s(314)+"ype"]);let u=this["_endpoin"+s(978)]?.getCurrentEndpoint();this._debug("open "+u+s(317)),e[s(262)](r)},Sp=async function(a,r){let s=t,d=this[s(801)+"tManager"]?.[s(618)+"ntEndpoint"]();this._debug(s(1610)+d),e[s(1577)](r)};class Ip extends aa{constructor(r){let s=t,d={fUgau:function(E,h){return e[V(769)](E,h)},GJtfd:function(E,h){return e[V(1037)](E,h)},TuHqd:function(E,h){return e.wyONP(E,h)},pcxCf:function(E,h){return e[V(1409)](E,h)},hzFBT:function(E,h){return E===h},ZWJEd:function(E,h){return E&h},tRrfI:function(E,h){return e[V(1237)](E,h)},AxFdv:"2|3|0|5|"+s(1627),pLKuO:function(E,h){return e.wyONP(E,h)},wGNYE:function(E,h){return E>>h},pitnQ:s(1626),hQnyi:e[s(269)],WZSkz:function(E,h,k,I){return e.iHLTQ(E,h,k,I)},KKGZD:e[s(1202)],fLpck:e[s(962)],uEuKA:function(E,h){return e[s(1350)](E,h)},NvaCE:e[s(502)],bOGlk:e[s(993)],HhfOc:e[s(1205)],jgsgV:e[s(336)],JLrQY:e[s(1453)],CgNTO:function(E,h){return E(h)},QAFKI:e[s(1395)],QvtOI:function(E,h){return e[s(1173)](E,h)},VhhsO:e[s(1283)],kuuma:function(E,h){return E===h},TEvjf:s(1047),AKLco:e.veLwQ,MSSzI:"success",tTxib:function(E,h){return E===h},vSQxC:function(E,h){return e[s(975)](E,h)},fBccF:e[s(675)],JLuvF:e[s(1383)],oUPPV:function(E,h,k){return e[s(1064)](E,h,k)},Czwth:function(E,h,k){return E(h,k)},Cimty:e[s(1563)]};super(),this["_miniNav"+s(681)+s(1365)]=!0,this[s(711)+"er"]=Qn,this[s(1222)]=qh,this[s(1175)+"T"]=Cn,this._isMiniWX=Wr,this[s(1200)+"r"]=Kr,this[s(383)+"Queue"]=[],this[s(801)+"tManager"]=null,this[s(817)+"osed"]=!1,this[s(314)+s(639)]=e[s(505)],this[s(1513)+s(1450)]=!1,this["_connect"+s(183)+s(1161)]=null,this[s(1031)+s(1118)+s(172)]=null,this[s(754)+"gTimeoutId"]=null,this._seqId=0,this._isInit=!1,this[s(222)]="",this[s(1327)+s(1207)]=null,this[s(928)+s(919)]=null,this[s(1422)+s(359)]=null,this[s(1084)+"ls"]=e[s(843)],this[s(964)]=3,this[s(325)+"NG"]=0,this[s(755)]=1,this.CLOSING=2,this[s(1271)]=E=>{let h=s,k={gRVhc:function(I,N){return d[V(1586)](I,N)},ptZjD:function(I,N){return d[V(112)](I,N)},HDkms:function(I,N){return d.TuHqd(I,N)},FdXyH:function(I,N){return d.pcxCf(I,N)},HQWqq:function(I,N){return d[V(1032)](I,N)},CwVRp:function(I,N){return d.ZWJEd(I,N)},fUQmF:function(I,N){return d.tRrfI(I,N)},zpsdh:d[h(1201)],uqcKw:function(I,N){return I|N},TDVxd:function(I,N){return I|N},bRhaf:function(I,N){return d[h(517)](I,N)},kJAeV:function(I,N){return I+N},rfAqM:function(I,N){return d[h(1029)](I,N)},ACiEn:function(I,N){return I&N},rSWwY:function(I,N){return d[h(665)](I,N)},FJhhw:function(I,N){return d[h(112)](I,N)},AMEEB:function(I,N){return d[h(839)](I,N)},NikXO:function(I,N){return d[h(665)](I,N)},OWqod:function(I,N){return d[h(1029)](I,N)}};if(d.pitnQ!==d[h(689)])try{d[h(1275)]($d,this,E,[bp,vp,Sp])}catch(I){let N=dt(d[h(1004)],{message:I[h(776)],code:nn[h(366)+"OR"],error:I});this[h(1236)+"hErrorEv"+h(1126)](N)}else if(_0x5d4143=_0x164cb2[h(813)+"At"](_0x106378),AbQLJA.gRVhc(_0x23c028,128))_0x6597d4[_0x5955b3++]=_0x165664;else if(AbQLJA[h(277)](_0x446c23,2048))_0x392308[_0x8b39d4++]=AbQLJA[h(971)](AbQLJA[h(251)](_0x57b21a,6),192),_0x35d09b[_0x4b1812++]=AbQLJA[h(1232)](63,_0xd107bd)|128;else if(AbQLJA[h(1232)](64512,_0x591190)===55296&&AbQLJA[h(1474)](AbQLJA[h(854)](64512,_0x91f8f5=_0xfd44cb[h(813)+"At"](AbQLJA.fUQmF(_0x5467b2,1))),56320)){let I=AbQLJA.zpsdh.split("|"),N=0;for(;;){switch(I[N++]){case"0":_0x5188c5[_0x37fcc5++]=AbQLJA.uqcKw(_0x24b480>>18,240);continue;case"1":_0x249fa9[_0x46b55f++]=AbQLJA[h(350)](AbQLJA[h(285)](AbQLJA[h(251)](_0x1587e3,6),63),128);continue;case"2":_0xf93c28=AbQLJA[h(1367)](AbQLJA[h(356)](65536,AbQLJA.rfAqM(1023,_0x584bcf)<<10),AbQLJA[h(1232)](1023,_0x2a1b11));continue;case"3":++_0x3a0896;continue;case"4":_0x27ca25[_0x881e82++]=AbQLJA[h(350)](AbQLJA[h(854)](63,_0x5e7bf6),128);continue;case"5":_0x3a29c6[_0x2926ec++]=AbQLJA[h(971)](AbQLJA[h(410)](AbQLJA.rSWwY(_0x16cbb2,12),63),128);continue}break}}else _0x57c7bc[_0x59d186++]=AbQLJA[h(666)](AbQLJA.AMEEB(_0x87125b,12),224),_0x25c37f[_0x2e02ed++]=AbQLJA.uqcKw(AbQLJA[h(182)](AbQLJA[h(1186)](_0x242fb4,6),63),128),_0xa4c96b[_0x22ae3e++]=AbQLJA[h(971)](AbQLJA.OWqod(63,_0x51e9c8),128)},this._onMessage=async E=>{let h=s,k={qfHwY:d[h(696)],THyKP:d[h(1527)],NGeRn:function(q,U,pe,We){return q(U,pe,We)},MlbXt:h(861),pHaZo:function(q,U,pe,We){return d[h(1275)](q,U,pe,We)},GcpVa:d[h(326)],hSKeu:function(q,U){return d[h(584)](q,U)},Acclw:d[h(123)]},{pingInterval:I,pingFrequency:N}=this[h(1551)];if((d.hzFBT("hi",E.data)&&d[h(965)](d[h(135)],N)||d[h(279)](d.TEvjf,N))&&(this[h(636)+"ngTimer"](),this.emit(d[h(1286)],d[h(1596)]),this[h(754)+h(1087)+"Id"]=setTimeout(this[h(313)][h(235)](this),I)),!d[h(1562)]("hi",E.data))try{if(d[h(221)](d[h(1437)],d[h(1437)])){if(_0x154739 instanceof _0x1b464e){if(PQdNGp[h(1032)](_0x164e1f,PQdNGp[h(1060)]))return _0x45f8e4[h(167)](_0x24a14a);if(PQdNGp[h(1204)](_0x144d63,PQdNGp[h(697)]))return _0x5ac310[h(393)+h(880)]||_0x271f0e[h(167)](_0x388a1);if(PQdNGp[h(1204)](_0x11b7b8,PQdNGp[h(821)]))return _0x59035e[h(393)+h(880)][1]?void 0:_0x4e605b[h(393)+h(1109)](_0x306df8["objectSt"+h(880)][0])}return _0x29d079(_0x2e9aea[_0x19699a])}else $d(this,E,[np,ep,yp,Ep,_p,tp])}catch(q){if(d[h(221)](d[h(1052)],d[h(1052)])){let U={LTLze:oLJJCt[h(728)],AfUXA:oLJJCt[h(121)],eIgvw:function(Ce,oe,mt,rt){return oLJJCt.NGeRn(Ce,oe,mt,rt)},NoGcU:oLJJCt.MlbXt,tmmzL:h(1022),zDPDK:h(923)+h(402),xgUTx:function(Ce,oe,mt,rt){return oLJJCt.NGeRn(Ce,oe,mt,rt)},HqwcC:function(Ce,oe,mt,rt){let $r=h;return oLJJCt[$r(1406)](Ce,oe,mt,rt)},Uogrj:oLJJCt[h(604)],sbbfu:function(Ce,oe,mt,rt){let $r=h;return oLJJCt[$r(440)](Ce,oe,mt,rt)}},[pe,We]=oLJJCt.hSKeu(_0x2f26ab,_0x2bc1df),Y=_0x476a82(pe),te=0;return _0x59ce21[h(1470)](Ce=>{let oe=h,mt=U[oe(1399)][oe(1620)]("|"),rt=0;for(;;){switch(mt[rt++]){case"0":_0x872de6[oe(452)](U.AfUXA,te);continue;case"1":te=U.eIgvw(_0x1e1308,_0x4462ed[oe(752)+"er"](Ce[oe(794)]||_0x2b53c9),Y,te);continue;case"2":_0x1ab0ec[oe(452)](U.NoGcU,te);continue;case"3":te=_0x23aa4a(Y,te,Ce[oe(288)]||0);continue;case"4":_0x267061[oe(452)](oe(288),te);continue;case"5":_0x44180f[oe(452)](U[oe(1413)],te);continue;case"6":_0x39dd83.log(U.zDPDK,te);continue;case"7":te=U[oe(1540)](_0x3bf58c,Ce["cursor_n"+oe(1077)],Y,te);continue;case"8":te=U[oe(628)](_0x4b155a,0,Y,te);continue;case"9":_0x1050e6[oe(452)](U[oe(1434)],Ce,Ce[oe(288)]);continue;case"10":te=U[oe(180)](_0x5ea7db,We[Ce[oe(729)+oe(1077)]],Y,te);continue}break}}),{frameType:_0x58a30a,headers:[{key:oLJJCt[h(634)],value:_0x3ee58d}],payload:Y}}else{let U=d[h(1581)](dt,d.KKGZD,{message:q[h(776)],code:nn[h(641)+"ERROR"],error:q});this["_dispatchErrorEv"+h(1126)](U)}}},this[s(308)]=E=>{let h=s,k=this[h(801)+h(978)]?.["checkRea"+h(1418)+"es"](),I=this[h(801)+h(978)]?.["getCurre"+h(797)+"nt"]();if(k&&!E.message){let N=h(299)+I+(h(612)+h(1023)+h(748)+"ed");this[h(1236)+h(1102)+h(1126)](d.Czwth(dt,h(310),{message:N,code:nn[h(1114)+h(1298)+"R"],error:E}));return}this[h(1473)]&&d.QvtOI(this._ws[h(766)+"te"],this[h(755)])&&this[h(1591)+h(290)](),this[h(1236)+"hErrorEv"+h(1126)](d.Czwth(dt,d.KKGZD,{message:E[h(776)],code:nn["NATIVE_E"+h(878)],error:E}))},this[s(1138)]=async E=>{let h=s;this[h(770)+h(1282)](),this[h(636)+h(436)](),this[h(1505)+h(927)+"rs"](),this[h(1473)]=null,this["_connect"+h(1450)]=!1;let k=this[h(801)+h(978)]?.["checkRea"+h(1418)+"es"]();if(!k&&this[h(671)+h(761)]()&&!this["_readyCl"+h(500)])if(e[h(901)](e[h(875)],e[h(875)]))_0x4097c3("success"),this.off(h(743)+"e_success",_0x308456),this[h(594)](d.Cimty,_0x59fbbe);else{let I=this[h(801)+h(978)]?.[h(618)+h(797)+"nt"](),N=this[h(1551)][h(781)+h(1468)+h(1501)](E.code,E[h(274)]);this["_dispatchCloseEv"+h(1126)](e[h(679)](gt,h(1128),{code:1006,reason:E[h(274)]||h(1614)+h(1066)+h(999)+h(412)+"n, hostn"+h(186)+I,willReconnect:N})),N&&this[h(1513)]();return}if(e[h(1224)](1e3,E[h(995)])&&this[h(817)+h(500)])if(h(1574)===h(1574)){this["_dispatc"+h(357)+h(1126)](e.DFMgf(gt,e[h(384)],{code:1e3,reason:e[h(893)]})),this[h(801)+h(978)]?.[h(459)+h(631)+h(283)](),this["_pingLos"+h(359)]?.[h(358)+h(1206)]();return}else{let N=""+_0x22bee8[h(276)](),q=_0x9c93d6||(_0x65cd91=PQdNGp[h(584)](_0x19675c,_0x4396b6)),U=_0x39afae[h(768)]()[h(518)](16)[h(401)](-6);return PQdNGp.tRrfI(PQdNGp.tRrfI("02",N),q)+U}if(e[h(1545)](1e3,E[h(995)])&&k){let I=this[h(801)+h(978)]?.[h(618)+h(797)+"nt"](),N=E[h(274)];N||(N=await e[h(947)](Jh,this._url)),N=h(1614)+h(1066)+h(606)+N+(h(1425)+h(527))+I+(h(1276)+h(1198)+"ached"),this[h(1236)+h(357)+h(1126)](e[h(433)](gt,e.WTVPF,{code:E[h(995)],reason:N}));let q=h(299)+I+(h(612)+h(1023)+h(748)+"ed");this[h(1236)+h(1102)+h(1126)](dt(h(310),{message:q,code:nn[h(1114)+h(1298)+"R"]})),this._endpointManager?.[h(459)+"pointCon"+h(283)](),this[h(1422)+h(359)]?.[h(358)+"nter"]();return}if(E.code!==1e3&&!E[h(274)]){let I=this[h(801)+h(978)]?.[h(618)+"ntEndpoint"]();this[h(1236)+"hCloseEv"+h(1126)](e.unCAM(gt,e.WTVPF,{code:E[h(995)],reason:"connecti"+h(1066)+"d, unkno"+h(412)+h(504)+h(186)+I})),this[h(801)+"tManager"]?.[h(459)+h(631)+h(283)](),this[h(1422)+"sCounter"]?.[h(358)+"nter"]();return}this[h(1236)+"hCloseEv"+h(1126)](E),this[h(801)+h(978)]?.["resetEnd"+h(631)+h(283)](),this[h(1422)+h(359)]?.[h(358)+h(1206)]()},this.onclose=null,this[s(423)]=null,this[s(216)+"e"]=null,this[s(540)]=null,this[s(1191)+s(1062)]=null,this[s(578)+s(1520)]=null,this[s(1579)+"mediatel"+s(840)+"ct"]=null,this[s(403)+s(321)]=this[s(403)+s(321)].bind(this),this["_handleO"+s(1258)]=this[s(403)+s(1258)][s(235)](this),this["_handleP"+s(1088)]=this[s(1445)+s(1088)][s(235)](this),this["_handleP"+s(1016)]=this["_handleP"+s(1016)][s(235)](this),this[s(1551)]={url:"",automaticOpen:!0,initReconnectInterval:1e3,maxReconnectInterval:1e4,reconnectIntervalGrowFactor:2,timeoutInterval:5e3,maxRetries:5,debug:!1,maxMessageQueueLength:e[s(1249)](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:s(1047),pingLossCount:2,enableTransformTextPayload:!1,logIDNewConfig:{enableAutoGenerateLogIDNew:!1,userIp:""},miniProgramParams:{customHttpHeader:{}},enableAutoAck:!1,reconnectInterceptor:()=>!0,enableQoS:!1,QoSLevel:2,messageStrategy:s(824),env:{xTTEnv:"",xUseEnv:""},listenNetworkChanged:!0};let{url:u,ws:g}=r,m=Array[s(1617)](u)?u:e[s(501)](e[s(480)],typeof u)?[u]:[];if(!m||e.KqGpv(0,m.length))throw new Error(e[s(1609)]);if(!e[s(148)](jh,g))throw new Error(e[s(720)]);Object[s(220)](this[s(1551)],r),this[s(801)+s(978)]=new Kd(m,this._options[s(1156)+"es"]),this[s(1422)+s(359)]=new $h(this[s(1551)][s(1479)+"Count"]),this[s(1551)][s(469)+s(749)]&&(this[s(385)]=!0,this[s(1513)]()),this[s(1551)]["listenNetworkCha"+s(126)]&&(this[s(1175)+"T"]||this[s(1055)+"X"]?this[s(1051)+s(1324)+s(1419)]():this[s(711)+"er"]&&this["_initGlo"+s(296)+s(136)]())}[t(403)+"nLine"](){let r=t;this._options[r(390)+r(454)+"nect"]||this["_readyCl"+r(500)]||this[r(470)+"econnect"]()}[t(403)+t(1258)](){let r=t;this[r(575)+"WebSocket"]();let s=e[r(248)](oa,e[r(1410)],{message:e[r(551)]});this[r(1579)+"mediatel"+r(840)+"ct"]&&this[r(1579)+"mediatel"+r(840)+"ct"](s)}[t(219)+"balEvent"+t(136)](){let r=t;this[r(711)+"er"]&&window[r(141)+r(136)](e[r(1069)],this[r(403)+r(321)]),this[r(711)+"er"]&&window[r(141)+"Listener"](r(736),this[r(403)+r(1258)]),this[r(711)+"er"]&&window[r(141)+r(136)](e[r(1046)],this[r(1445)+r(1088)]),this[r(711)+"er"]&&window[r(141)+r(136)](e.kXuqT,this[r(1445)+r(1016)])}[t(1075)+t(296)+t(136)](){let r=t;this[r(711)+"er"]&&window[r(1247)+"entListe"+r(1379)](e[r(1069)],this["_handleO"+r(321)]),this._isBrowser&&window[r(1247)+r(348)+"ner"](r(736),this[r(403)+"ffLine"]),this[r(711)+"er"]&&window[r(1247)+r(348)+r(1379)](e.orcFs,this[r(1445)+r(1088)]),this._isBrowser&&window[r(1247)+"entListe"+r(1379)](e[r(1429)],this[r(1445)+"ageShow"])}[t(1445)+t(1088)](r){let s=t;if(e[s(1369)]!==e[s(1517)])!r.persisted&&(this._isBrowser&&window["removeEv"+s(348)+s(1379)](e.orcFs,this[s(1445)+s(1088)]),this[s(711)+"er"]&&window[s(1247)+s(348)+s(1379)](e[s(1429)],this._handlePageShow),this[s(1128)]()),this[s(711)+"er"]&&window[s(1247)+s(348)+"ner"](s(872),this[s(403)+s(321)]),this._isBrowser&&window[s(1247)+s(348)+s(1379)](e[s(1491)],this[s(403)+"ffLine"]);else return this[s(1219)]?.[s(167)](_0x20bcdd)}[t(1445)+t(1016)](r){let s=t;r[s(531)+"d"]&&(this["_navigat"+s(761)]()&&(!this[s(1473)]||e.OPOuc(this[s(1473)].readyState,this[s(755)])||e[s(1347)](this[s(1473)].readyState,this[s(325)+"NG"]))&&this[s(403)+s(321)](),this[s(711)+"er"]&&window[s(141)+s(136)](s(872),this[s(403)+s(321)]),this[s(711)+"er"]&&window["addEvent"+s(136)](e[s(1491)],this[s(403)+s(1258)]))}async _generateUrl(r){let s=t,{fpID:d,deviceID:u,bddID:g,ttwID:m,accessKey:E,aID:h,customParams:k={},enableAutoAck:I,enableQoS:N,QoSLevel:q,env:U}=this[s(1551)],pe,We,Y;this._isBrowser||this[s(1055)+"X"]||this[s(1175)+"T"]?(pe=location&&e[s(501)](e[s(117)],location.protocol)?e[s(745)]:s(1292),We=r[s(632)](/((^ws)|(^http))((?:[s]*:\/\/))/,""),Y=/^wss(.*:\/\/)/.test(r)?r:""+pe+We):(pe=e[s(745)],We=r[s(632)](/(^http)((?:[s]*:\/\/))/,""),Y=/(^ws)((?:[s]*:\/\/))/[s(208)](We)?We:""+pe+We);let te=g?e[s(510)]:m?e[s(309)]:s(985)+"d",Ce=g||m||u;if(!Ce||!te)throw new Error(e[s(399)]);let oe=e[s(890)]==typeof k?await k():k,mt=U?e[s(1512)](Kh,U[s(1134)],U[s(1376)]):{},rt=Object[s(220)]({device_platform:e[s(616)],version_code:e.wpBOu,access_key:E,fpid:d,aid:h,[te]:Ce,xsack:I?1:0,xaack:I?1:0,xsqos:N?1:0,qos_level:N?q:void 0,qos_sdk_version:2,...mt},oe),$r=Object[s(1290)](rt)[s(380)]((ha,pa)=>rt[pa]!==void 0?""+ha+(ha?"&":"?")+pa+"="+rt[pa]:ha,"");return Y+s(565)+$r}async[t(1513)](){let r=t,s={LTzjp:function(d,u){return e[V(1098)](d,u)},EHIpF:e[r(1238)],oVjoE:function(d,u,g,m){return d(u,g,m)},cUQuZ:function(d,u){return e[r(1125)](d,u)}};if(!(this["_connect"+r(1450)]||this[r(817)+r(500)])){this[r(1513)+r(1450)]=!0;try{let d=this[r(801)+r(978)]?.[r(887)+r(702)+r(597)+r(1044)+r(184)](),{timeoutInterval:u}=this[r(1551)];if(d){let m=this[r(801)+r(978)]?.getCurrentEndpoint(),E=this[r(801)+r(978)]?.[r(223)+r(490)+r(825)+"UpdateCo"+r(1038)](),h=this[r(801)+"tManager"]?.[r(618)+r(797)+r(1129)+r(1362)]();if(E)if(e[r(599)](r(771),e[r(1532)])){if(EBQIIx[r(1151)](_0xb0714f,_0x17970e))throw new _0x3b3cba(EBQIIx[r(211)]);let k=3;for(;k>=0;){let I=255&_0x571774;EBQIIx.oVjoE(_0x2b13bf,I,_0x415f50,EBQIIx[r(968)](_0x2715c3,k)),_0x262bcc>>>=8,k--}return _0x4b8d81+4}else{let k=r(299)+m+(r(850)+", max re"+r(1198)+r(1121)+"ill use "+r(116)+r(119))+E+" to retry",I=e[r(433)](dt,e[r(1202)],{message:k,code:nn[r(1114)+"IES_ERROR"]});this[r(733)](k),this[r(1236)+"hErrorEv"+r(1126)](I),this[r(222)]=await this[r(573)+r(863)](E),this[r(733)]("connect "+E+" "+h+r(281)),this[r(1505)+r(927)+"rs"]()}else{let k="connect "+m+(r(850)+r(1276)+"tries re"+r(1079));this[r(733)](k),this[r(1236)+"hErrorEvent"](e[r(192)](dt,e.rCCqa,{message:k,code:nn[r(1114)+r(1298)+"R"]}));return}}else{let m=this["_endpoin"+r(978)]?.[r(618)+r(797)+r(642)+r(1364)](),E=this["_endpoin"+r(978)]?.["getCurre"+r(797)+r(1129)+r(1362)]();this[r(222)]=await this[r(573)+r(863)](m||""),this[r(733)](r(299)+m+" "+E+" times"),this[r(1505)+r(927)+"rs"]()}if(this[r(385)])this[r(385)]=!1;else if(e[r(302)](e[r(530)],e[r(1240)])){let m=e[r(546)](oa,e.plRIW,{message:e[r(1026)]});this[r(1191)+r(1062)]&&this[r(1191)+r(1062)](m)}else _0x13b63f(_0x5cec8d,50),_0x4347a(_0x2017f7,_0x30ee16);let g=this[r(801)+r(978)]?.["getCurre"+r(797)+r(1129)+r(1362)]()||0;e.qSTAt(g,1)&&await this[r(331)](e.JulpF(g,1)),this._debug(r(1614)+r(1358)+this[r(222)]+(r(1363)+r(673))+this[r(1084)+"ls"]),this[r(1473)]=Gh({url:this[r(222)],protocols:[this._protocols],headers:this[r(1551)][r(625)+r(268)+"s"]["customHt"+r(1141)]},this[r(1551)].ws),(this[r(711)+"er"]||this[r(1200)+"r"])&&this._ws&&(this[r(1473)][r(640)+"pe"]=this[r(314)+r(639)]),this._addWsListeners(),this[r(1513)+"ionTimeo"+r(1161)]=e[r(1512)](setTimeout,this[r(619)+"ut"][r(235)](this),u)}catch(d){throw this["_connect"+r(1450)]=!1,d}}}["_clearTi"+t(1282)](){let r=t;clearTimeout(this[r(1513)+"ionTimeo"+r(1161)]),this[r(1513)+r(183)+r(1161)]=null}["_clearPi"+t(436)](){let r=t;e[r(874)](clearTimeout,this[r(754)+r(1087)+"Id"]),e.SLXsG(clearTimeout,this[r(1031)+"ctTimeoutId"]),this[r(754)+r(1087)+"Id"]=null,this[r(1031)+r(1118)+r(172)]=null}[t(733)](...r){let s=t;if(e[s(760)](e[s(670)],s(974)))return this[s(1119)][s(1571)+"ns"];this[s(1551)][s(773)]&&console[s(452)].apply(console,[e.XIrbQ,...r])}[t(1268)+t(352)+"e"](r){let s=t,{initReconnectInterval:d,maxReconnectInterval:u,reconnectIntervalGrowFactor:g}=this[s(1551)],m=e[s(1108)](d,Math[s(1061)](g,e[s(275)](r,1)));return m>u?u:m}[t(313)](){let r=t;if(this._ws&&e.gYePC(this[r(1473)][r(766)+"te"],this[r(325)+"NG"])){this[r(636)+"ngTimer"](),this[r(754)+r(1087)+"Id"]=setTimeout(this._ping[r(235)](this),this[r(1551)][r(173)+r(1127)]);return}if(!this[r(1473)]||e[r(901)](this._ws[r(766)+"te"],this.OPEN))return void this._handleReconnect();this[r(1473)]&&this._ws[r(1595)]("hi"),this[r(1031)+r(1118)+r(172)]=e[r(1137)](setTimeout,this["_handleR"+r(1062)+r(256)][r(235)](this),this._options[r(1625)+r(802)+r(800)])}["_handleR"+t(1062)+t(256)](){let r=t;this[r(1422)+r(359)]?.[r(1307)](),this[r(1482)](r(743)+r(1543)+"t",e.JveVG),this[r(1422)+r(359)]?.checkReachMaxCount()?this[r(470)+"econnect"]():this[r(313)]()}[t(671)+t(761)](){let r=t;return this._isMiniTT||this[r(1055)+"X"]?this[r(1348)+"igatorOn"+r(1365)]:(this[r(711)+"er"]||this._isWorker)&&this[r(1551)][r(387)+r(674)+r(126)]?navigator[r(871)]:!0}[t(470)+"econnect"](){let r=t;!this[r(671)+r(761)]()||this[r(817)+r(500)]||(this[r(801)+"tManager"]?.[r(459)+r(631)+r(283)](),this[r(1422)+r(359)]?.[r(358)+r(1206)](),this._ws?this[r(1591)+r(290)](1001,r(1435)+"ay, try "+r(781)+r(159)+r(1495),!0):this[r(1513)]())}[t(1051)+t(1324)+t(1419)](){let r=t,s={xrFIX:e[r(150)],PFUGE:function(d,u){return e[r(1320)](d,u)},VbMVD:function(d,u){return e[r(427)](d,u)},oVFjD:function(d,u){return e[r(292)](d,u)},eOxXV:function(d,u){return d|u},DXtfa:function(d,u){return e[r(1339)](d,u)},akKlz:function(d,u){return e[r(322)](d,u)},hKWfT:function(d,u){return e.qYinx(d,u)},CvXqP:function(d,u,g,m){return e[r(896)](d,u,g,m)},SkSoJ:function(d,u){return e[r(954)](d,u)},LTWam:e.OUYeQ};this._isMiniTT?tt["onNetwor"+r(835)+r(1097)](({isConnected:d})=>{let u=r;u(487)===e[u(751)]?this[u(177)+u(550)]():(this[u(1348)+u(681)+u(1365)]=d,d?this[u(403)+u(321)]():this[u(403)+"ffLine"]())}):this[r(1055)+"X"]&&wx[r(1018)+"kStatusC"+r(1097)](({isConnected:d})=>{let u=r,g={QQLgV:s[u(1226)],WsCnR:function(m,E){return s[u(482)](m,E)},lNAaw:function(m,E){return s[u(198)](m,E)},TkAeV:function(m,E){return m<<E},wzZEG:function(m,E){return s[u(267)](m,E)},kitfA:function(m,E){return s.eOxXV(m,E)},qpOLR:function(m,E){return s[u(714)](m,E)},jsqIA:function(m,E){return s[u(1313)](m,E)},AqYQu:function(m,E){return s[u(482)](m,E)},zneKw:function(m,E){return s.eOxXV(m,E)},XcLDJ:function(m,E){return s[u(650)](m,E)},TSPeF:function(m,E){return m>>>E},EwRbg:function(m,E){return s[u(1475)](m,E)},cHCsT:function(m,E,h,k){return s[u(1637)](m,E,h,k)},uZqoI:function(m,E){return s[u(267)](m,E)},QZugp:function(m,E){return s.eOxXV(m,E)},voXys:function(m,E){return m<<E}};if(s[u(1250)](s.LTWam,u(163))){let m=g[u(475)][u(1620)]("|"),E=0;for(;;){switch(m[E++]){case"0":if(BNKgij[u(1442)](_0x21aef5[_0x55dff0++],128))return{value:_0x29c836?_0x483e85:0|_0x342c80,offset:_0x24174f};continue;case"1":_0xb48ad6=BNKgij[u(898)](_0x31738c|BNKgij[u(407)](127&_0x4a3ee6[_0x2a4a50],7),0);continue;case"2":_0x286248=BNKgij.wzZEG(BNKgij[u(1555)](_0x42d67e,BNKgij.TkAeV(BNKgij.qpOLR(15,_0x174938[_0x4f05eb]),28)),0);continue;case"3":if(BNKgij.WsCnR(_0x1f520f[_0x3965c2++],128))return{value:_0x26ec96?_0x34d890:BNKgij[u(1523)](0,_0x1b5866),offset:_0x5e6b95};continue;case"4":if(BNKgij[u(1080)](_0x5d8bee[_0x3f0f5f++],128))return{value:_0x2498de?_0x3cad17:BNKgij[u(1356)](0,_0x48cf57),offset:_0x4e5b59};continue;case"5":if(BNKgij[u(1147)](_0x2e6c36[_0x5b4801++],128))return{value:_0x294812?_0x13c4ec:BNKgij[u(1523)](0,_0x15b0a3),offset:_0x1dec66};continue;case"6":_0x5a32aa=BNKgij[u(1056)](BNKgij[u(1523)](_0x53295b,BNKgij[u(407)](BNKgij.qpOLR(127,_0x2f104a[_0x1b34a4]),14)),0);continue;case"7":if(BNKgij[u(207)](_0x13b220+=5,_0x447ea6[u(515)]))throw _0x266722=_0x25aa9f.length,BNKgij.cHCsT(_0x1e85f8,_0x1cbf01,10,_0x220c6c[u(515)]);continue;case"8":_0x25a68=BNKgij[u(421)](127&_0x254936[_0x10dbf5],0);continue;case"9":_0x1db126=BNKgij.TSPeF(BNKgij[u(746)](_0x50e02a,BNKgij.voXys(BNKgij[u(913)](127,_0x435a38[_0x2e3d39]),21)),0);continue;case"10":return{value:_0x18e725?_0x27d510:0|_0x235080,offset:_0xac7de5};case"11":if(_0x3a3ae0[_0xce0fe4++]<128)return{value:_0x261f3c?_0x14ac8b:0|_0xd64aaf,offset:_0x5154e1};continue}break}}else this[u(1348)+u(681)+u(1365)]=d,d?this["_handleO"+u(321)]():this["_handleO"+u(1258)]()})}_wait(r){return new Promise(s=>{setTimeout(s,this["_getInte"+V(352)+"e"](r))})}[t(1591)+t(290)](r=1e3,s="",d=!1){let u=t;this[u(1473)]&&this[u(575)+u(1316)+"t"](r,s,d)}[t(619)+"ut"](){let r=t,s=this[r(801)+r(978)]?.[r(618)+r(797)+"nt"]();this._debug("connect "+s+r(850)),this[r(1591)+r(290)](1001,e.WllAA,!0)}[t(1454)](r){let s=t,d=e[s(1449)](Ut,r);this[s(1473)]&&e.dUnyv(this._ws[s(766)+"te"],this[s(755)])&&(this[s(1473)]&&this._ws[s(1595)](d),this[s(733)](e[s(579)],r))}[t(1505)+"sListeners"](){let r=t;this[r(1473)]&&(this[r(1473)]["removeEv"+r(348)+r(1379)](e[r(114)],this[r(1271)]),this._ws[r(1247)+"entListener"](e[r(384)],this._onClose),this[r(1473)][r(1247)+r(348)+r(1379)](e.Jaagg,this[r(284)+"ge"]),this[r(1473)]["removeEv"+r(348)+r(1379)](e[r(1202)],this._onError))}[t(430)+t(1050)](){let r=t,s=(r(617)+"1")[r(1620)]("|"),d=0;for(;;){switch(s[d++]){case"0":if(!this[r(1473)])return;continue;case"1":this[r(1473)]["addEvent"+r(136)](e[r(1202)],this._onError);continue;case"2":this[r(1473)][r(141)+r(136)](e[r(384)],this[r(1138)]);continue;case"3":this._ws[r(141)+r(136)](e.xMmst,this._onOpen);continue;case"4":this[r(1473)][r(141)+r(136)](e[r(1623)],this[r(284)+"ge"]);continue}break}}["_wsInsta"+t(811)](r=1e3,s=""){let d=t;try{this[d(1473)]&&this[d(1473)][d(1128)](r,s)}catch{}}["_destroy"+t(1316)+"t"](r=1e3,s="",d=!1){let u=t;if(this["_clearPi"+u(436)](),this["_clearTi"+u(1282)](),this["_removeW"+u(927)+"rs"](),this["_wsInsta"+u(811)](1e3,s),this["_connect"+u(1450)]=!1,d&&this[u(671)+u(761)]()&&!this[u(817)+u(500)])if(e.Fkync(e.TcVQD,e[u(1397)])){if(this[u(801)+u(978)]?.checkReachMaxTries()){let m=this[u(801)+"tManager"]?.[u(618)+u(797)+"nt"]();this[u(1236)+u(357)+"ent"](e[u(1512)](gt,e[u(384)],{code:1006,reason:u(299)+m+(u(850)+u(1276)+u(1198)+u(1079)),wasClean:!0}))}else{let m=this[u(1551)][u(781)+u(1468)+"ptor"](r,s);this[u(1236)+u(357)+u(1126)](e[u(1270)](gt,e[u(384)],{code:r,reason:s,wasClean:!0,willReconnect:m})),m&&this[u(1513)]()}return}else this[u(430)+"steners"]();this[u(671)+u(761)]()||this[u(817)+u(500)]?this[u(1236)+"hCloseEv"+u(1126)](e[u(1270)](gt,e[u(384)],{code:r,reason:e[u(893)]})):this[u(1236)+u(357)+u(1126)](gt(u(1128),{code:1006,reason:e.CgLoN})),this[u(1473)]=null,this["_endpoin"+u(978)]?.[u(459)+u(631)+u(283)](),this[u(1422)+"sCounter"]?.[u(358)+u(1206)]()}[t(1236)+t(942)+"nt"](r){let s=t;this[s(1482)](e.xMmst,r),this[s(540)]&&this[s(540)](r)}[t(1236)+t(827)+t(589)](r){let s=t;this[s(1482)](e[s(1623)],r),this.onmessage&&this.onmessage(r)}["_dispatc"+t(1480)+t(1633)](r){let s=t;this[s(1482)](e[s(1133)],r),this[s(578)+s(1520)]&&this[s(578)+s(1520)](r)}[t(1236)+t(1102)+t(1126)](r){let s=t;this[s(1482)](e[s(1202)],r),this.onerror&&this[s(423)](r)}["_dispatc"+t(357)+t(1126)](r){let s=t;this[s(1482)](s(1128),r),this[s(270)]&&this[s(270)](r)}get[t(640)+"pe"](){let r=t,s={AyGKQ:function(d,u){return d(u)},pzTYJ:r(370),kOqML:e[r(1563)]};if(e[r(782)]!==e.rsmIT)return this[r(1473)]?this[r(1473)][r(640)+"pe"]:this._binaryType;s[r(1441)](_0x56e488,s[r(1371)]),this[r(594)](r(743)+r(1354)+"s",_0x1724fd),this[r(594)](s[r(570)],_0x1a0f24)}set[t(640)+"pe"](r){let s=t;this[s(314)+s(639)]=r,this[s(1473)]&&(this._ws[s(640)+"pe"]=r)}get[t(820)+"nt"](){let r=t,s={gbqDT:function(d,u){return e[V(158)](d,u)}};return e[r(212)](e[r(465)],e[r(763)])?oxuaJC.gbqDT(this.count,this[r(939)+r(1362)]):this[r(801)+"tManager"]?.[r(618)+"ntEndpoi"+r(1129)+r(1362)]()||0}get[t(775)+t(637)](){let r=t,s={uuLmI:e[r(1300)],svUsw:e[r(1202)],jrEnC:e[r(1467)],blPHc:function(d){return e[r(1577)](d)},zZyeP:function(d){return e.CYOEU(d)},PhCeB:function(d,u){return e[r(129)](d,u)},HRjhb:e[r(886)],TgpBf:function(d){return e[r(1615)](d)}};if(e[r(1534)](e[r(1496)],e.rkNgC)){let d=()=>{let m=r;_0x4927b1[m(1247)+m(348)+m(1379)](XZsDyC[m(406)],u),_0x5462a2[m(1247)+m(348)+m(1379)](XZsDyC[m(831)],g),_0x106ab9["removeEventListe"+m(1379)](XZsDyC.jrEnC,g)},u=()=>{let m=r;XZsDyC[m(209)](_0x10d95c),XZsDyC[m(1152)](d)},g=()=>{let m=r;XZsDyC[m(1417)](_0x10d896,_0x2df8eb[m(310)]||new _0x160af7(XZsDyC[m(692)],XZsDyC.HRjhb)),XZsDyC[m(622)](d)};_0x2f0fae[r(141)+r(136)](JKWDuG[r(1300)],u),_0x52c887.addEventListener(JKWDuG[r(1202)],g),_0x439958[r(141)+r(136)](JKWDuG.hUHgd,g)}else return this._messageQueue.reduce((u,g)=>(u+=g&&g[r(1421)+"th"]||0,u),0)+(this[r(1473)]?this[r(1473)][r(775)+r(637)]:0)}get[t(1571)+"ns"](){let r=t;return this[r(1473)]?this[r(1473)][r(1571)+"ns"]:""}get[t(1490)](){let r=t;return this[r(1473)]?this[r(1473)].protocol:""}get[t(766)+"te"](){let r=t,s={HiKhh:function(d,u){return e[V(870)](d,u)},dpHeE:function(d,u){return e[V(652)](d,u)},fVpaf:function(d,u){return d===u}};if(e.VWLuS(e[r(1309)],e[r(1309)]))return this[r(1473)]?this[r(1473)][r(766)+"te"]:this._options[r(469)+"cOpen"]?this[r(325)+"NG"]:this[r(964)];if(Mjbuig[r(1464)](void 0,_0x331f43))this._listeners={};else if(Mjbuig[r(1197)](void 0,_0x1e6136))this[r(1025)+"rs"][_0x21b0bf]=null;else{let d=this[r(1025)+"rs"][_0xd31f17];if(d)for(let u=0;u<d[r(515)];)Mjbuig[r(1072)](d[u].fn,_0x14c05b)?d[r(765)](u,1):++u}return this}get url(){let r=t;return this[r(1473)]?this[r(1473)][r(319)]:this[r(222)]}close(r=1e3,s){let d=t,u=e[d(991)].split("|"),g=0;for(;;){switch(u[g++]){case"0":if(!this[d(1473)])return void this[d(733)](d(1034)+d(1338)+d(132)+d(1085)+"ed");continue;case"1":this[d(817)+d(500)]=!0;continue;case"2":this[d(636)+d(436)]();continue;case"3":this[d(770)+d(1282)]();continue;case"4":this[d(575)+d(1316)+"t"](r,s);continue;case"5":if(e.ozTsG(this[d(1473)][d(766)+"te"],this[d(964)])||this[d(1473)][d(766)+"te"]===this.CLOSING)return void this[d(733)](e.rNagn);continue;case"6":this[d(1075)+d(296)+d(136)]();continue;case"7":this["_QoSMana"+d(1207)]?.[d(1214)]();continue}break}}async[t(1595)](r,s){let d=t;if(e[d(730)](null,r))throw new Error(e[d(731)]);e[d(501)](d(367),typeof r)&&(r=JSON[d(451)+"y"](r)),d(509)!=typeof r&&!e.IVwdV(r,ArrayBuffer)&&!(r.buffer&&e.vsaQG(r.buffer,ArrayBuffer))&&(r=JSON[d(451)+"y"](r));let u=await e[d(1234)](Zd,r),g=Wh(r),{method:m=0,service:E=this[d(1551)][d(288)],logID:h=this[d(1551)][d(1504)+"erator"](),headers:k=this[d(1551)][d(1231)],payloadEncoding:I=this[d(1551)][d(489)+"ncoding"],payloadType:N=this[d(1551)][d(787)+d(639)],logIDNew:q=this[d(1551)]["logIDNew"+d(1285)][d(529)+d(788)+"teLogIDNew"]?e[d(549)](i,this._options[d(1054)+d(1285)][d(1090)]):""}=s||{};if(!E)throw new Error(e[d(1424)]);let U={SeqID:le[d(752)+"er"](this[d(155)]++),LogID:le[d(752)+"er"](h),service:E,method:m,headers:k,payloadEncoding:e[d(140)](I,Object)?I[d(1035)]?I[d(1035)]:"":I,payloadType:N instanceof Object?N[d(1436)]?N.type:g:N||g,payload:u,LogIDNew:q},pe=e[d(638)](Ut,U);return this[d(1473)]&&e[d(300)](this[d(1473)][d(766)+"te"],this[d(755)])?(this[d(1473)]&&this._ws[d(1595)](pe),this[d(733)](e[d(493)],U)):e.EpjwK(this[d(383)+"Queue"][d(515)],this[d(1551)][d(983)+d(660)+d(466)])?(this["_message"+d(1368)][d(1634)](pe),this[d(733)](d(735),U)):(this[d(383)+"Queue"][d(838)](),this[d(383)+"Queue"][d(1634)](pe)),{seqID:this[d(155)],logID:h,logIDNew:q}}async[t(781)+"t"](r){let s=t;if(e[s(1130)]!==e[s(1398)]){let{url:d}=e[s(796)](r,{}),u=Array[s(1617)](d)?d:e.TdqjI(e[s(480)],typeof d)?[d]:[];if(r&&Object[s(220)](this[s(1551)],r),u&&u[s(515)]?this["_endpoin"+s(978)]=new Kd(u,this[s(1551)].maxRetries):this[s(801)+"tManager"]?.[s(459)+"pointCon"+s(283)](),this[s(1422)+"sCounter"]?.[s(358)+s(1206)](this._options.pingLossCount),this[s(817)+s(500)]=!1,this[s(1473)]&&e.NYgbC(this[s(1473)][s(766)+"te"],this.CLOSED))this[s(1591)+"ect"](1e3,e.gdYEj,!0);else if(e.skyBJ(e[s(958)],e[s(958)]))this[s(385)]=!0,this[s(1513)]();else return!!_0x1c08c8?.[s(1003)](g=>g.key===_0xe2d3e8&&g[s(143)]===_0x34d8b1)}else{let d=_0x19097e[_0x114b7c];if(e[s(783)](4,_0x5eb1c5[_0x16469d][s(515)])){let u=_0x6e7f78[s(1583)+"g"](0,4-_0xbbfd0[_0x52b435][s(515)]),g=u[s(438)](d);_0x5902d4=_0x2d238e.concat(g)}else _0x215cf9=_0xbfa132[s(438)](d)}}async[t(877)](){let r=t;if(!this._connectLock){let s=e[r(342)][r(1620)]("|"),d=0;for(;;){switch(s[d++]){case"0":this[r(1422)+r(359)]?.[r(358)+r(1206)]();continue;case"1":this[r(385)]=!0;continue;case"2":this[r(801)+"tManager"]?.[r(459)+r(631)+"fig"]();continue;case"3":this[r(1513)]();continue;case"4":this["_readyCl"+r(500)]=!1;continue}break}}}[t(141)+t(136)](r,s){let d=t;e[d(975)](e[d(564)],e[d(564)])?_0x128835(this,_0x1b0e37,[_0x33e9be,_0x9bd176,_0x1058b3,_0x2528fb,_0x3109b1,_0x2e16f8]):this.on(r,s)}[t(1105)+t(589)](r){let s=t,d={pSIzN:e[s(1202)],AjtUf:function(u,g){return u(g)},UIoGa:function(u){return u()},EQEnt:e[s(966)]};if(e.Hfbkx(s(1590),e[s(199)])){let u={kfQaf:s(1440),cXUyc:HBcJLV[s(830)],TJTem:function(h,k){let I=s;return HBcJLV[I(339)](h,k)},mOfdC:function(h){return HBcJLV.UIoGa(h)}},g=()=>{let h=s;_0x47af76[h(1247)+h(348)+h(1379)](u[h(1311)],m),_0x15a0ff[h(1247)+"entListe"+h(1379)](u[h(1390)],E)},m=()=>{let h=s;u[h(514)](_0x3cd514,u[h(514)](_0x3e3769,_0x2d1646[h(1045)])),u[h(354)](g)},E=()=>{let h=s;_0x39fb98(_0x131ad7[h(310)]),g()};_0x19301a["addEvent"+s(136)](HBcJLV[s(1541)],m),_0x35ce4e[s(141)+s(136)](HBcJLV.pSIzN,E)}else{let{type:u}=r;this[s(1482)](u,r)}}["removeEv"+t(348)+t(1379)](r,s){let d=t;d(1514)!==e.rLtmd?this[d(594)](r,s):(this[d(385)]=!0,this[d(1513)]())}[t(767)](){let r=t,s={BBOEw:"GQtCE",GUzKw:e.siznB,ISCpm:function(d,u){return e[V(567)](d,u)},wHuJV:r(370),lJyXV:e[r(1489)],IfqVq:e[r(1563)],TKWnz:function(d,u,g){return e[r(1542)](d,u,g)}};return new Promise((d,u)=>{let g=r,m={SqXeI:function(k,I){return k(I)},PaGQk:s[g(1048)],yOmqD:s[g(1188)]};this[g(636)+g(436)](),this[g(754)+g(1087)+"Id"]=s[g(657)](setTimeout,this._ping[g(235)](this),this[g(1551)][g(173)+"rval"]);let E=()=>{let k=g;m[k(1325)](d,"success"),this[k(594)](m[k(361)],E),this[k(594)](m[k(853)],h)},h=()=>{let k=g;s[k(460)]!==s.GUzKw?(s[k(1293)](u,s.wHuJV),this[k(594)](s.lJyXV,E),this[k(594)]("ping_onc"+k(1543)+"t",h)):(this[k(1348)+k(681)+k(1365)]=_0x48f5c1,_0x2e2798?this["_handleO"+k(321)]():this[k(403)+k(1258)]())};this.on(s[g(1048)],E),this.on(s.IfqVq,h),this[g(313)]()})}}})(),ue["CustomCl"+M(176)]=ke[M(115)+M(176)],ue[M(956)+"rorEvent"]=ke["CustomEr"+M(318)],ue[M(229)+"e"]=ke[M(229)+"e"],ue[M(589)]=ke.Event,ue[M(1451)]=ke[M(1451)],ue[M(833)+M(1391)+M(447)]=ke[M(833)+"MessageE"+M(447)],ue[M(1391)+M(447)]=ke[M(1391)+M(447)],ue[M(474)+"t"]=ke[M(474)+"t"],ue.ReconnectEvent=ke[M(1385)+M(1310)],ue.createCloseEvent=ke[M(1081)+M(176)],ue[M(725)+"rorEvent"]=ke["createEr"+M(318)],ue[M(1262)+"ssageEvent"]=ke[M(1262)+M(716)+"nt"],ue[M(418)+M(242)]=ke["createOp"+M(242)],ue["createReconnectE"+M(447)]=ke[M(1403)+M(408)+M(447)],ue[M(646)+M(859)]=ke[M(646)+"rame"],ue["encodeFr"+M(1077)]=ke.encodeFrame;for(Eo in ke)[M(115)+M(176),M(956)+"rorEvent",M(229)+"e",M(589),M(1451),M(833)+M(1391)+M(447),M(1391)+"vent","OpenEvent",M(1385)+"tEvent",M(1081)+M(176),M(725)+M(318),"createMe"+M(716)+"nt","createOpenEvent",M(1403)+M(408)+M(447),M(646)+M(859),M(557)+M(1077)].indexOf(Eo)===-1&&(ue[Eo]=ke[Eo]);var Eo;Object["definePr"+M(147)](ue,M(1019)+"le",{value:!0})});var Vt=ae((ST,Ku)=>{"use strict";var ju=["nodebuffer","arraybuffer","fragments"],Wu=typeof Blob<"u";Wu&&ju.push("blob");Ku.exports={BINARY_TYPES:ju,CLOSE_TIMEOUT:3e4,EMPTY_BUFFER:Buffer.alloc(0),GUID:"258EAFA5-E914-47DA-95CA-C5AB0DC85B11",hasBlob:Wu,kForOnEventAttribute:Symbol("kIsForOnEventAttribute"),kListener:Symbol("kListener"),kStatusCode:Symbol("status-code"),kWebSocket:Symbol("websocket"),NOOP:()=>{}}});var Hi=ae((IT,Co)=>{"use strict";var{EMPTY_BUFFER:v1}=Vt(),nd=Buffer[Symbol.species];function S1(t,e){if(t.length===0)return v1;if(t.length===1)return t[0];let n=Buffer.allocUnsafe(e),i=0;for(let o=0;o<t.length;o++){let c=t[o];n.set(c,i),i+=c.length}return i<e?new nd(n.buffer,n.byteOffset,i):n}function $u(t,e,n,i,o){for(let c=0;c<o;c++)n[i+c]=t[c]^e[c&3]}function Ju(t,e){for(let n=0;n<t.length;n++)t[n]^=e[n&3]}function I1(t){return t.length===t.buffer.byteLength?t.buffer:t.buffer.slice(t.byteOffset,t.byteOffset+t.length)}function rd(t){if(rd.readOnly=!0,Buffer.isBuffer(t))return t;let e;return t instanceof ArrayBuffer?e=new nd(t):ArrayBuffer.isView(t)?e=new nd(t.buffer,t.byteOffset,t.byteLength):(e=Buffer.from(t),rd.readOnly=!1),e}Co.exports={concat:S1,mask:$u,toArrayBuffer:I1,toBuffer:rd,unmask:Ju};if(!process.env.WS_NO_BUFFER_UTIL)try{let t=fe("bufferutil");Co.exports.mask=function(e,n,i,o,c){c<48?$u(e,n,i,o,c):t.mask(e,n,i,o,c)},Co.exports.unmask=function(e,n){e.length<32?Ju(e,n):t.unmask(e,n)}}catch{}});var Xu=ae((AT,Zu)=>{"use strict";var Vu=Symbol("kDone"),id=Symbol("kRun"),sd=class{constructor(e){this[Vu]=()=>{this.pending--,this[id]()},this.concurrency=e||1/0,this.jobs=[],this.pending=0}add(e){this.jobs.push(e),this[id]()}[id](){if(this.pending!==this.concurrency&&this.jobs.length){let e=this.jobs.shift();this.pending++,e(this[Vu])}}};Zu.exports=sd});var Pr=ae((TT,tx)=>{"use strict";var Gi=fe("zlib"),Yu=Hi(),A1=Xu(),{kStatusCode:Qu}=Vt(),T1=Buffer[Symbol.species],C1=Buffer.from([0,0,255,255]),Ro=Symbol("permessage-deflate"),Zt=Symbol("total-length"),kr=Symbol("callback"),In=Symbol("buffers"),Lr=Symbol("error"),Do,od=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,!Do){let n=this._options.concurrencyLimit!==void 0?this._options.concurrencyLimit:10;Do=new A1(n)}}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[kr];this._deflate.close(),this._deflate=null,e&&e(new Error("The deflate stream was closed while data was being processed"))}}acceptAsServer(e){let n=this._options,i=e.find(o=>!(n.serverNoContextTakeover===!1&&o.server_no_context_takeover||o.server_max_window_bits&&(n.serverMaxWindowBits===!1||typeof n.serverMaxWindowBits=="number"&&n.serverMaxWindowBits>o.server_max_window_bits)||typeof n.clientMaxWindowBits=="number"&&!o.client_max_window_bits));if(!i)throw new Error("None of the extension offers can be accepted");return n.serverNoContextTakeover&&(i.server_no_context_takeover=!0),n.clientNoContextTakeover&&(i.client_no_context_takeover=!0),typeof n.serverMaxWindowBits=="number"&&(i.server_max_window_bits=n.serverMaxWindowBits),typeof n.clientMaxWindowBits=="number"?i.client_max_window_bits=n.clientMaxWindowBits:(i.client_max_window_bits===!0||n.clientMaxWindowBits===!1)&&delete i.client_max_window_bits,i}acceptAsClient(e){let n=e[0];if(this._options.clientNoContextTakeover===!1&&n.client_no_context_takeover)throw new Error('Unexpected parameter "client_no_context_takeover"');if(!n.client_max_window_bits)typeof this._options.clientMaxWindowBits=="number"&&(n.client_max_window_bits=this._options.clientMaxWindowBits);else if(this._options.clientMaxWindowBits===!1||typeof this._options.clientMaxWindowBits=="number"&&n.client_max_window_bits>this._options.clientMaxWindowBits)throw new Error('Unexpected or invalid parameter "client_max_window_bits"');return n}normalizeParams(e){return e.forEach(n=>{Object.keys(n).forEach(i=>{let o=n[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}"`);n[i]=o})}),e}decompress(e,n,i){Do.add(o=>{this._decompress(e,n,(c,l)=>{o(),i(c,l)})})}compress(e,n,i){Do.add(o=>{this._compress(e,n,(c,l)=>{o(),i(c,l)})})}_decompress(e,n,i){let o=this._isServer?"client":"server";if(!this._inflate){let c=`${o}_max_window_bits`,l=typeof this.params[c]!="number"?Gi.Z_DEFAULT_WINDOWBITS:this.params[c];this._inflate=Gi.createInflateRaw({...this._options.zlibInflateOptions,windowBits:l}),this._inflate[Ro]=this,this._inflate[Zt]=0,this._inflate[In]=[],this._inflate.on("error",R1),this._inflate.on("data",ex)}this._inflate[kr]=i,this._inflate.write(e),n&&this._inflate.write(C1),this._inflate.flush(()=>{let c=this._inflate[Lr];if(c){this._inflate.close(),this._inflate=null,i(c);return}let l=Yu.concat(this._inflate[In],this._inflate[Zt]);this._inflate._readableState.endEmitted?(this._inflate.close(),this._inflate=null):(this._inflate[Zt]=0,this._inflate[In]=[],n&&this.params[`${o}_no_context_takeover`]&&this._inflate.reset()),i(null,l)})}_compress(e,n,i){let o=this._isServer?"server":"client";if(!this._deflate){let c=`${o}_max_window_bits`,l=typeof this.params[c]!="number"?Gi.Z_DEFAULT_WINDOWBITS:this.params[c];this._deflate=Gi.createDeflateRaw({...this._options.zlibDeflateOptions,windowBits:l}),this._deflate[Zt]=0,this._deflate[In]=[],this._deflate.on("data",D1)}this._deflate[kr]=i,this._deflate.write(e),this._deflate.flush(Gi.Z_SYNC_FLUSH,()=>{if(!this._deflate)return;let c=Yu.concat(this._deflate[In],this._deflate[Zt]);n&&(c=new T1(c.buffer,c.byteOffset,c.length-4)),this._deflate[kr]=null,this._deflate[Zt]=0,this._deflate[In]=[],n&&this.params[`${o}_no_context_takeover`]&&this._deflate.reset(),i(null,c)})}};tx.exports=od;function D1(t){this[In].push(t),this[Zt]+=t.length}function ex(t){if(this[Zt]+=t.length,this[Ro]._maxPayload<1||this[Zt]<=this[Ro]._maxPayload){this[In].push(t);return}this[Lr]=new RangeError("Max payload size exceeded"),this[Lr].code="WS_ERR_UNSUPPORTED_MESSAGE_LENGTH",this[Lr][Qu]=1009,this.removeListener("data",ex),this.reset()}function R1(t){if(this[Ro]._inflate=null,this[Lr]){this[kr](this[Lr]);return}t[Qu]=1007,this[kr](t)}});var Or=ae((CT,ko)=>{"use strict";var{isUtf8:nx}=fe("buffer"),{hasBlob:k1}=Vt(),L1=[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 P1(t){return t>=1e3&&t<=1014&&t!==1004&&t!==1005&&t!==1006||t>=3e3&&t<=4999}function ad(t){let e=t.length,n=0;for(;n<e;)if((t[n]&128)===0)n++;else if((t[n]&224)===192){if(n+1===e||(t[n+1]&192)!==128||(t[n]&254)===192)return!1;n+=2}else if((t[n]&240)===224){if(n+2>=e||(t[n+1]&192)!==128||(t[n+2]&192)!==128||t[n]===224&&(t[n+1]&224)===128||t[n]===237&&(t[n+1]&224)===160)return!1;n+=3}else if((t[n]&248)===240){if(n+3>=e||(t[n+1]&192)!==128||(t[n+2]&192)!==128||(t[n+3]&192)!==128||t[n]===240&&(t[n+1]&240)===128||t[n]===244&&t[n+1]>143||t[n]>244)return!1;n+=4}else return!1;return!0}function O1(t){return k1&&typeof t=="object"&&typeof t.arrayBuffer=="function"&&typeof t.type=="string"&&typeof t.stream=="function"&&(t[Symbol.toStringTag]==="Blob"||t[Symbol.toStringTag]==="File")}ko.exports={isBlob:O1,isValidStatusCode:P1,isValidUTF8:ad,tokenChars:L1};if(nx)ko.exports.isValidUTF8=function(t){return t.length<24?ad(t):nx(t)};else if(!process.env.WS_NO_UTF_8_VALIDATE)try{let t=fe("utf-8-validate");ko.exports.isValidUTF8=function(e){return e.length<32?ad(e):t(e)}}catch{}});var ud=ae((DT,dx)=>{"use strict";var{Writable:N1}=fe("stream"),rx=Pr(),{BINARY_TYPES:M1,EMPTY_BUFFER:ix,kStatusCode:B1,kWebSocket:z1}=Vt(),{concat:cd,toArrayBuffer:F1,unmask:U1}=Hi(),{isValidStatusCode:q1,isValidUTF8:sx}=Or(),Lo=Buffer[Symbol.species],xt=0,ox=1,ax=2,cx=3,dd=4,ld=5,Po=6,fd=class extends N1{constructor(e={}){super(),this._allowSynchronousEvents=e.allowSynchronousEvents!==void 0?e.allowSynchronousEvents:!0,this._binaryType=e.binaryType||M1[0],this._extensions=e.extensions||{},this._isServer=!!e.isServer,this._maxPayload=e.maxPayload|0,this._skipUTF8Validation=!!e.skipUTF8Validation,this[z1]=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=xt}_write(e,n,i){if(this._opcode===8&&this._state==xt)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 Lo(i.buffer,i.byteOffset+e,i.length-e),new Lo(i.buffer,i.byteOffset,e)}let n=Buffer.allocUnsafe(e);do{let i=this._buffers[0],o=n.length-e;e>=i.length?n.set(this._buffers.shift(),o):(n.set(new Uint8Array(i.buffer,i.byteOffset,e),o),this._buffers[0]=new Lo(i.buffer,i.byteOffset+e,i.length-e)),e-=i.length}while(e>0);return n}startLoop(e){this._loop=!0;do switch(this._state){case xt:this.getInfo(e);break;case ox:this.getPayloadLength16(e);break;case ax:this.getPayloadLength64(e);break;case cx:this.getMask();break;case dd:this.getData(e);break;case ld:case Po:this._loop=!1;return}while(this._loop);this._errored||e()}getInfo(e){if(this._bufferedBytes<2){this._loop=!1;return}let n=this.consume(2);if((n[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=(n[0]&64)===64;if(i&&!this._extensions[rx.extensionName]){let o=this.createError(RangeError,"RSV1 must be clear",!0,1002,"WS_ERR_UNEXPECTED_RSV_1");e(o);return}if(this._fin=(n[0]&128)===128,this._opcode=n[0]&15,this._payloadLength=n[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=(n[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=ox:this._payloadLength===127?this._state=ax: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 n=this.consume(8),i=n.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)+n.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 n=this.createError(RangeError,"Max payload size exceeded",!1,1009,"WS_ERR_UNSUPPORTED_MESSAGE_LENGTH");e(n);return}this._masked?this._state=cx:this._state=dd}getMask(){if(this._bufferedBytes<4){this._loop=!1;return}this._mask=this.consume(4),this._state=dd}getData(e){let n=ix;if(this._payloadLength){if(this._bufferedBytes<this._payloadLength){this._loop=!1;return}n=this.consume(this._payloadLength),this._masked&&(this._mask[0]|this._mask[1]|this._mask[2]|this._mask[3])!==0&&U1(n,this._mask)}if(this._opcode>7){this.controlMessage(n,e);return}if(this._compressed){this._state=ld,this.decompress(n,e);return}n.length&&(this._messageLength=this._totalPayloadLength,this._fragments.push(n)),this.dataMessage(e)}decompress(e,n){this._extensions[rx.extensionName].decompress(e,this._fin,(o,c)=>{if(o)return n(o);if(c.length){if(this._messageLength+=c.length,this._messageLength>this._maxPayload&&this._maxPayload>0){let l=this.createError(RangeError,"Max payload size exceeded",!1,1009,"WS_ERR_UNSUPPORTED_MESSAGE_LENGTH");n(l);return}this._fragments.push(c)}this.dataMessage(n),this._state===xt&&this.startLoop(n)})}dataMessage(e){if(!this._fin){this._state=xt;return}let n=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=cd(i,n):this._binaryType==="arraybuffer"?o=F1(cd(i,n)):this._binaryType==="blob"?o=new Blob(i):o=i,this._allowSynchronousEvents?(this.emit("message",o,!0),this._state=xt):(this._state=Po,setImmediate(()=>{this.emit("message",o,!0),this._state=xt,this.startLoop(e)}))}else{let o=cd(i,n);if(!this._skipUTF8Validation&&!sx(o)){let c=this.createError(Error,"invalid UTF-8 sequence",!0,1007,"WS_ERR_INVALID_UTF8");e(c);return}this._state===ld||this._allowSynchronousEvents?(this.emit("message",o,!1),this._state=xt):(this._state=Po,setImmediate(()=>{this.emit("message",o,!1),this._state=xt,this.startLoop(e)}))}}controlMessage(e,n){if(this._opcode===8){if(e.length===0)this._loop=!1,this.emit("conclude",1005,ix),this.end();else{let i=e.readUInt16BE(0);if(!q1(i)){let c=this.createError(RangeError,`invalid status code ${i}`,!0,1002,"WS_ERR_INVALID_CLOSE_CODE");n(c);return}let o=new Lo(e.buffer,e.byteOffset+2,e.length-2);if(!this._skipUTF8Validation&&!sx(o)){let c=this.createError(Error,"invalid UTF-8 sequence",!0,1007,"WS_ERR_INVALID_UTF8");n(c);return}this._loop=!1,this.emit("conclude",i,o),this.end()}this._state=xt;return}this._allowSynchronousEvents?(this.emit(this._opcode===9?"ping":"pong",e),this._state=xt):(this._state=Po,setImmediate(()=>{this.emit(this._opcode===9?"ping":"pong",e),this._state=xt,this.startLoop(n)}))}createError(e,n,i,o,c){this._loop=!1,this._errored=!0;let l=new e(i?`Invalid WebSocket frame: ${n}`:n);return Error.captureStackTrace(l,this.createError),l.code=c,l[B1]=o,l}};dx.exports=fd});var pd=ae((kT,ux)=>{"use strict";var{Duplex:RT}=fe("stream"),{randomFillSync:H1}=fe("crypto"),lx=Pr(),{EMPTY_BUFFER:G1,kWebSocket:j1,NOOP:W1}=Vt(),{isBlob:Nr,isValidStatusCode:K1}=Or(),{mask:fx,toBuffer:Wn}=Hi(),ht=Symbol("kByteLength"),$1=Buffer.alloc(4),Oo=8*1024,Kn,Mr=Oo,It=0,J1=1,V1=2,xd=class t{constructor(e,n,i){this._extensions=n||{},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=It,this.onerror=W1,this[j1]=void 0}static frame(e,n){let i,o=!1,c=2,l=!1;n.mask&&(i=n.maskBuffer||$1,n.generateMask?n.generateMask(i):(Mr===Oo&&(Kn===void 0&&(Kn=Buffer.alloc(Oo)),H1(Kn,0,Oo),Mr=0),i[0]=Kn[Mr++],i[1]=Kn[Mr++],i[2]=Kn[Mr++],i[3]=Kn[Mr++]),l=(i[0]|i[1]|i[2]|i[3])===0,c=6);let f;typeof e=="string"?(!n.mask||l)&&n[ht]!==void 0?f=n[ht]:(e=Buffer.from(e),f=e.length):(f=e.length,o=n.mask&&n.readOnly&&!l);let x=f;f>=65536?(c+=8,x=127):f>125&&(c+=2,x=126);let p=Buffer.allocUnsafe(o?f+c:c);return p[0]=n.fin?n.opcode|128:n.opcode,n.rsv1&&(p[0]|=64),p[1]=x,x===126?p.writeUInt16BE(f,2):x===127&&(p[2]=p[3]=0,p.writeUIntBE(f,4,6)),n.mask?(p[1]|=128,p[c-4]=i[0],p[c-3]=i[1],p[c-2]=i[2],p[c-1]=i[3],l?[p,e]:o?(fx(e,i,p,c,f),[p]):(fx(e,i,e,0,f),[p,e])):[p,e]}close(e,n,i,o){let c;if(e===void 0)c=G1;else{if(typeof e!="number"||!K1(e))throw new TypeError("First argument must be a valid error code number");if(n===void 0||!n.length)c=Buffer.allocUnsafe(2),c.writeUInt16BE(e,0);else{let f=Buffer.byteLength(n);if(f>123)throw new RangeError("The message must not be greater than 123 bytes");c=Buffer.allocUnsafe(2+f),c.writeUInt16BE(e,0),typeof n=="string"?c.write(n,2):c.set(n,2)}}let l={[ht]:c.length,fin:!0,generateMask:this._generateMask,mask:i,maskBuffer:this._maskBuffer,opcode:8,readOnly:!1,rsv1:!1};this._state!==It?this.enqueue([this.dispatch,c,!1,l,o]):this.sendFrame(t.frame(c,l),o)}ping(e,n,i){let o,c;if(typeof e=="string"?(o=Buffer.byteLength(e),c=!1):Nr(e)?(o=e.size,c=!1):(e=Wn(e),o=e.length,c=Wn.readOnly),o>125)throw new RangeError("The data size must not be greater than 125 bytes");let l={[ht]:o,fin:!0,generateMask:this._generateMask,mask:n,maskBuffer:this._maskBuffer,opcode:9,readOnly:c,rsv1:!1};Nr(e)?this._state!==It?this.enqueue([this.getBlobData,e,!1,l,i]):this.getBlobData(e,!1,l,i):this._state!==It?this.enqueue([this.dispatch,e,!1,l,i]):this.sendFrame(t.frame(e,l),i)}pong(e,n,i){let o,c;if(typeof e=="string"?(o=Buffer.byteLength(e),c=!1):Nr(e)?(o=e.size,c=!1):(e=Wn(e),o=e.length,c=Wn.readOnly),o>125)throw new RangeError("The data size must not be greater than 125 bytes");let l={[ht]:o,fin:!0,generateMask:this._generateMask,mask:n,maskBuffer:this._maskBuffer,opcode:10,readOnly:c,rsv1:!1};Nr(e)?this._state!==It?this.enqueue([this.getBlobData,e,!1,l,i]):this.getBlobData(e,!1,l,i):this._state!==It?this.enqueue([this.dispatch,e,!1,l,i]):this.sendFrame(t.frame(e,l),i)}send(e,n,i){let o=this._extensions[lx.extensionName],c=n.binary?2:1,l=n.compress,f,x;typeof e=="string"?(f=Buffer.byteLength(e),x=!1):Nr(e)?(f=e.size,x=!1):(e=Wn(e),f=e.length,x=Wn.readOnly),this._firstFragment?(this._firstFragment=!1,l&&o&&o.params[o._isServer?"server_no_context_takeover":"client_no_context_takeover"]&&(l=f>=o._threshold),this._compress=l):(l=!1,c=0),n.fin&&(this._firstFragment=!0);let p={[ht]:f,fin:n.fin,generateMask:this._generateMask,mask:n.mask,maskBuffer:this._maskBuffer,opcode:c,readOnly:x,rsv1:l};Nr(e)?this._state!==It?this.enqueue([this.getBlobData,e,this._compress,p,i]):this.getBlobData(e,this._compress,p,i):this._state!==It?this.enqueue([this.dispatch,e,this._compress,p,i]):this.dispatch(e,this._compress,p,i)}getBlobData(e,n,i,o){this._bufferedBytes+=i[ht],this._state=V1,e.arrayBuffer().then(c=>{if(this._socket.destroyed){let f=new Error("The socket was closed while the blob was being read");process.nextTick(hd,this,f,o);return}this._bufferedBytes-=i[ht];let l=Wn(c);n?this.dispatch(l,n,i,o):(this._state=It,this.sendFrame(t.frame(l,i),o),this.dequeue())}).catch(c=>{process.nextTick(Z1,this,c,o)})}dispatch(e,n,i,o){if(!n){this.sendFrame(t.frame(e,i),o);return}let c=this._extensions[lx.extensionName];this._bufferedBytes+=i[ht],this._state=J1,c.compress(e,i.fin,(l,f)=>{if(this._socket.destroyed){let x=new Error("The socket was closed while data was being compressed");hd(this,x,o);return}this._bufferedBytes-=i[ht],this._state=It,i.readOnly=!1,this.sendFrame(t.frame(f,i),o),this.dequeue()})}dequeue(){for(;this._state===It&&this._queue.length;){let e=this._queue.shift();this._bufferedBytes-=e[3][ht],Reflect.apply(e[0],this,e.slice(1))}}enqueue(e){this._bufferedBytes+=e[3][ht],this._queue.push(e)}sendFrame(e,n){e.length===2?(this._socket.cork(),this._socket.write(e[0]),this._socket.write(e[1],n),this._socket.uncork()):this._socket.write(e[0],n)}};ux.exports=xd;function hd(t,e,n){typeof n=="function"&&n(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 Z1(t,e,n){hd(t,e,n),t.onerror(e)}});var bx=ae((LT,Ex)=>{"use strict";var{kForOnEventAttribute:ji,kListener:gd}=Vt(),xx=Symbol("kCode"),hx=Symbol("kData"),px=Symbol("kError"),gx=Symbol("kMessage"),mx=Symbol("kReason"),Br=Symbol("kTarget"),_x=Symbol("kType"),yx=Symbol("kWasClean"),Xt=class{constructor(e){this[Br]=null,this[_x]=e}get target(){return this[Br]}get type(){return this[_x]}};Object.defineProperty(Xt.prototype,"target",{enumerable:!0});Object.defineProperty(Xt.prototype,"type",{enumerable:!0});var $n=class extends Xt{constructor(e,n={}){super(e),this[xx]=n.code===void 0?0:n.code,this[mx]=n.reason===void 0?"":n.reason,this[yx]=n.wasClean===void 0?!1:n.wasClean}get code(){return this[xx]}get reason(){return this[mx]}get wasClean(){return this[yx]}};Object.defineProperty($n.prototype,"code",{enumerable:!0});Object.defineProperty($n.prototype,"reason",{enumerable:!0});Object.defineProperty($n.prototype,"wasClean",{enumerable:!0});var zr=class extends Xt{constructor(e,n={}){super(e),this[px]=n.error===void 0?null:n.error,this[gx]=n.message===void 0?"":n.message}get error(){return this[px]}get message(){return this[gx]}};Object.defineProperty(zr.prototype,"error",{enumerable:!0});Object.defineProperty(zr.prototype,"message",{enumerable:!0});var Wi=class extends Xt{constructor(e,n={}){super(e),this[hx]=n.data===void 0?null:n.data}get data(){return this[hx]}};Object.defineProperty(Wi.prototype,"data",{enumerable:!0});var X1={addEventListener(t,e,n={}){for(let o of this.listeners(t))if(!n[ji]&&o[gd]===e&&!o[ji])return;let i;if(t==="message")i=function(c,l){let f=new Wi("message",{data:l?c:c.toString()});f[Br]=this,No(e,this,f)};else if(t==="close")i=function(c,l){let f=new $n("close",{code:c,reason:l.toString(),wasClean:this._closeFrameReceived&&this._closeFrameSent});f[Br]=this,No(e,this,f)};else if(t==="error")i=function(c){let l=new zr("error",{error:c,message:c.message});l[Br]=this,No(e,this,l)};else if(t==="open")i=function(){let c=new Xt("open");c[Br]=this,No(e,this,c)};else return;i[ji]=!!n[ji],i[gd]=e,n.once?this.once(t,i):this.on(t,i)},removeEventListener(t,e){for(let n of this.listeners(t))if(n[gd]===e&&!n[ji]){this.removeListener(t,n);break}}};Ex.exports={CloseEvent:$n,ErrorEvent:zr,Event:Xt,EventTarget:X1,MessageEvent:Wi};function No(t,e,n){typeof t=="object"&&t.handleEvent?t.handleEvent.call(t,n):t.call(e,n)}});var Mo=ae((PT,vx)=>{"use strict";var{tokenChars:Ki}=Or();function Ft(t,e,n){t[e]===void 0?t[e]=[n]:t[e].push(n)}function Y1(t){let e=Object.create(null),n=Object.create(null),i=!1,o=!1,c=!1,l,f,x=-1,p=-1,w=-1,v=0;for(;v<t.length;v++)if(p=t.charCodeAt(v),l===void 0)if(w===-1&&Ki[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 y=t.slice(x,w);p===44?(Ft(e,y,n),n=Object.create(null)):l=y,x=w=-1}else throw new SyntaxError(`Unexpected character at index ${v}`);else if(f===void 0)if(w===-1&&Ki[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),Ft(n,t.slice(x,w),!0),p===44&&(Ft(e,l,n),n=Object.create(null),l=void 0),x=w=-1}else if(p===61&&x!==-1&&w===-1)f=t.slice(x,v),x=w=-1;else throw new SyntaxError(`Unexpected character at index ${v}`);else if(o){if(Ki[p]!==1)throw new SyntaxError(`Unexpected character at index ${v}`);x===-1?x=v:i||(i=!0),o=!1}else if(c)if(Ki[p]===1)x===-1&&(x=v);else if(p===34&&x!==-1)c=!1,w=v;else if(p===92)o=!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&&Ki[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 y=t.slice(x,w);i&&(y=y.replace(/\\/g,""),i=!1),Ft(n,f,y),p===44&&(Ft(e,l,n),n=Object.create(null),l=void 0),f=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 T=t.slice(x,w);return l===void 0?Ft(e,T,n):(f===void 0?Ft(n,T,!0):i?Ft(n,f,T.replace(/\\/g,"")):Ft(n,f,T),Ft(e,l,n)),e}function Q1(t){return Object.keys(t).map(e=>{let n=t[e];return Array.isArray(n)||(n=[n]),n.map(i=>[e].concat(Object.keys(i).map(o=>{let c=i[o];return Array.isArray(c)||(c=[c]),c.map(l=>l===!0?o:`${o}=${l}`).join("; ")})).join("; ")).join(", ")}).join(", ")}vx.exports={format:Q1,parse:Y1}});var Uo=ae((MT,Nx)=>{"use strict";var eE=fe("events"),tE=fe("https"),nE=fe("http"),Ax=fe("net"),rE=fe("tls"),{randomBytes:iE,createHash:sE}=fe("crypto"),{Duplex:OT,Readable:NT}=fe("stream"),{URL:md}=fe("url"),An=Pr(),oE=ud(),aE=pd(),{isBlob:cE}=Or(),{BINARY_TYPES:Sx,CLOSE_TIMEOUT:dE,EMPTY_BUFFER:Bo,GUID:lE,kForOnEventAttribute:wd,kListener:fE,kStatusCode:uE,kWebSocket:Ge,NOOP:Tx}=Vt(),{EventTarget:{addEventListener:xE,removeEventListener:hE}}=bx(),{format:pE,parse:gE}=Mo(),{toBuffer:mE}=Hi(),Cx=Symbol("kAborted"),_d=[8,13],Yt=["CONNECTING","OPEN","CLOSING","CLOSED"],wE=/^[!#$%&'*+\-.0-9A-Z^_`|a-z~]+$/,me=class t extends eE{constructor(e,n,i){super(),this._binaryType=Sx[0],this._closeCode=1006,this._closeFrameReceived=!1,this._closeFrameSent=!1,this._closeMessage=Bo,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,n===void 0?n=[]:Array.isArray(n)||(typeof n=="object"&&n!==null?(i=n,n=[]):n=[n]),Dx(this,e,n,i)):(this._autoPong=i.autoPong,this._closeTimeout=i.closeTimeout,this._isServer=!0)}get binaryType(){return this._binaryType}set binaryType(e){Sx.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,n,i){let o=new oE({allowSynchronousEvents:i.allowSynchronousEvents,binaryType:this.binaryType,extensions:this._extensions,isServer:this._isServer,maxPayload:i.maxPayload,skipUTF8Validation:i.skipUTF8Validation}),c=new aE(e,this._extensions,i.generateMask);this._receiver=o,this._sender=c,this._socket=e,o[Ge]=this,c[Ge]=this,e[Ge]=this,o.on("conclude",EE),o.on("drain",bE),o.on("error",vE),o.on("message",SE),o.on("ping",IE),o.on("pong",AE),c.onerror=TE,e.setTimeout&&e.setTimeout(0),e.setNoDelay&&e.setNoDelay(),n.length>0&&e.unshift(n),e.on("close",Lx),e.on("data",Fo),e.on("end",Px),e.on("error",Ox),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[An.extensionName]&&this._extensions[An.extensionName].cleanup(),this._receiver.removeAllListeners(),this._readyState=t.CLOSED,this.emit("close",this._closeCode,this._closeMessage)}close(e,n){if(this.readyState!==t.CLOSED){if(this.readyState===t.CONNECTING){ct(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,n,!this._isServer,i=>{i||(this._closeFrameSent=!0,(this._closeFrameReceived||this._receiver._writableState.errorEmitted)&&this._socket.end())}),kx(this)}}pause(){this.readyState===t.CONNECTING||this.readyState===t.CLOSED||(this._paused=!0,this._socket.pause())}ping(e,n,i){if(this.readyState===t.CONNECTING)throw new Error("WebSocket is not open: readyState 0 (CONNECTING)");if(typeof e=="function"?(i=e,e=n=void 0):typeof n=="function"&&(i=n,n=void 0),typeof e=="number"&&(e=e.toString()),this.readyState!==t.OPEN){yd(this,e,i);return}n===void 0&&(n=!this._isServer),this._sender.ping(e||Bo,n,i)}pong(e,n,i){if(this.readyState===t.CONNECTING)throw new Error("WebSocket is not open: readyState 0 (CONNECTING)");if(typeof e=="function"?(i=e,e=n=void 0):typeof n=="function"&&(i=n,n=void 0),typeof e=="number"&&(e=e.toString()),this.readyState!==t.OPEN){yd(this,e,i);return}n===void 0&&(n=!this._isServer),this._sender.pong(e||Bo,n,i)}resume(){this.readyState===t.CONNECTING||this.readyState===t.CLOSED||(this._paused=!1,this._receiver._writableState.needDrain||this._socket.resume())}send(e,n,i){if(this.readyState===t.CONNECTING)throw new Error("WebSocket is not open: readyState 0 (CONNECTING)");if(typeof n=="function"&&(i=n,n={}),typeof e=="number"&&(e=e.toString()),this.readyState!==t.OPEN){yd(this,e,i);return}let o={binary:typeof e!="string",mask:!this._isServer,compress:!0,fin:!0,...n};this._extensions[An.extensionName]||(o.compress=!1),this._sender.send(e||Bo,o,i)}terminate(){if(this.readyState!==t.CLOSED){if(this.readyState===t.CONNECTING){ct(this,this._req,"WebSocket was closed before the connection was established");return}this._socket&&(this._readyState=t.CLOSING,this._socket.destroy())}}};Object.defineProperty(me,"CONNECTING",{enumerable:!0,value:Yt.indexOf("CONNECTING")});Object.defineProperty(me.prototype,"CONNECTING",{enumerable:!0,value:Yt.indexOf("CONNECTING")});Object.defineProperty(me,"OPEN",{enumerable:!0,value:Yt.indexOf("OPEN")});Object.defineProperty(me.prototype,"OPEN",{enumerable:!0,value:Yt.indexOf("OPEN")});Object.defineProperty(me,"CLOSING",{enumerable:!0,value:Yt.indexOf("CLOSING")});Object.defineProperty(me.prototype,"CLOSING",{enumerable:!0,value:Yt.indexOf("CLOSING")});Object.defineProperty(me,"CLOSED",{enumerable:!0,value:Yt.indexOf("CLOSED")});Object.defineProperty(me.prototype,"CLOSED",{enumerable:!0,value:Yt.indexOf("CLOSED")});["binaryType","bufferedAmount","extensions","isPaused","protocol","readyState","url"].forEach(t=>{Object.defineProperty(me.prototype,t,{enumerable:!0})});["open","error","close","message"].forEach(t=>{Object.defineProperty(me.prototype,`on${t}`,{enumerable:!0,get(){for(let e of this.listeners(t))if(e[wd])return e[fE];return null},set(e){for(let n of this.listeners(t))if(n[wd]){this.removeListener(t,n);break}typeof e=="function"&&this.addEventListener(t,e,{[wd]:!0})}})});me.prototype.addEventListener=xE;me.prototype.removeEventListener=hE;Nx.exports=me;function Dx(t,e,n,i){let o={allowSynchronousEvents:!0,autoPong:!0,closeTimeout:dE,protocolVersion:_d[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,!_d.includes(o.protocolVersion))throw new RangeError(`Unsupported protocol version: ${o.protocolVersion} (supported versions: ${_d.join(", ")})`);let c;if(e instanceof md)c=e;else try{c=new md(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 l=c.protocol==="wss:",f=c.protocol==="ws+unix:",x;if(c.protocol!=="ws:"&&!l&&!f?x=`The URL's protocol must be one of "ws:", "wss:", "http:", "https:", or "ws+unix:"`:f&&!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;zo(t,S);return}let p=l?443:80,w=iE(16).toString("base64"),v=l?tE.request:nE.request,T=new Set,y;if(o.createConnection=o.createConnection||(l?yE:_E),o.defaultPort=o.defaultPort||p,o.port=c.port||p,o.host=c.hostname.startsWith("[")?c.hostname.slice(1,-1):c.hostname,o.headers={...o.headers,"Sec-WebSocket-Version":o.protocolVersion,"Sec-WebSocket-Key":w,Connection:"Upgrade",Upgrade:"websocket"},o.path=c.pathname+c.search,o.timeout=o.handshakeTimeout,o.perMessageDeflate&&(y=new An({...o.perMessageDeflate,isServer:!1,maxPayload:o.maxPayload}),o.headers["Sec-WebSocket-Extensions"]=pE({[An.extensionName]:y.offer()})),n.length){for(let S of n){if(typeof S!="string"||!wE.test(S)||T.has(S))throw new SyntaxError("An invalid or duplicated subprotocol was specified");T.add(S)}o.headers["Sec-WebSocket-Protocol"]=n.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}`),f){let S=o.path.split(":");o.socketPath=S[0],o.path=S[1]}let b;if(o.followRedirects){if(t._redirects===0){t._originalIpc=f,t._originalSecure=l,t._originalHostOrSocketPath=f?o.socketPath:c.host;let S=i&&i.headers;if(i={...i,headers:{}},S)for(let[A,R]of Object.entries(S))i.headers[A.toLowerCase()]=R}else if(t.listenerCount("redirect")===0){let S=f?t._originalIpc?o.socketPath===t._originalHostOrSocketPath:!1:t._originalIpc?!1:c.host===t._originalHostOrSocketPath;(!S||t._originalSecure&&!l)&&(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")),b=t._req=v(o),t._redirects&&t.emit("redirect",t.url,b)}else b=t._req=v(o);o.timeout&&b.on("timeout",()=>{ct(t,b,"Opening handshake has timed out")}),b.on("error",S=>{b===null||b[Cx]||(b=t._req=null,zo(t,S))}),b.on("response",S=>{let A=S.headers.location,R=S.statusCode;if(A&&o.followRedirects&&R>=300&&R<400){if(++t._redirects>o.maxRedirects){ct(t,b,"Maximum redirects exceeded");return}b.abort();let P;try{P=new md(A,e)}catch{let D=new SyntaxError(`Invalid URL: ${A}`);zo(t,D);return}Dx(t,P,n,i)}else t.emit("unexpected-response",b,S)||ct(t,b,`Unexpected server response: ${S.statusCode}`)}),b.on("upgrade",(S,A,R)=>{if(t.emit("upgrade",S),t.readyState!==me.CONNECTING)return;b=t._req=null;let P=S.headers.upgrade;if(P===void 0||P.toLowerCase()!=="websocket"){ct(t,A,"Invalid Upgrade header");return}let _=sE("sha1").update(w+lE).digest("base64");if(S.headers["sec-websocket-accept"]!==_){ct(t,A,"Invalid Sec-WebSocket-Accept header");return}let D=S.headers["sec-websocket-protocol"],L;if(D!==void 0?T.size?T.has(D)||(L="Server sent an invalid subprotocol"):L="Server sent a subprotocol but none was requested":T.size&&(L="Server sent no subprotocol"),L){ct(t,A,L);return}D&&(t._protocol=D);let B=S.headers["sec-websocket-extensions"];if(B!==void 0){if(!y){ct(t,A,"Server sent a Sec-WebSocket-Extensions header but no extension was requested");return}let z;try{z=gE(B)}catch{ct(t,A,"Invalid Sec-WebSocket-Extensions header");return}let J=Object.keys(z);if(J.length!==1||J[0]!==An.extensionName){ct(t,A,"Server indicated an extension that was not requested");return}try{y.accept(z[An.extensionName])}catch{ct(t,A,"Invalid Sec-WebSocket-Extensions header");return}t._extensions[An.extensionName]=y}t.setSocket(A,R,{allowSynchronousEvents:o.allowSynchronousEvents,generateMask:o.generateMask,maxPayload:o.maxPayload,skipUTF8Validation:o.skipUTF8Validation})}),o.finishRequest?o.finishRequest(b,t):b.end()}function zo(t,e){t._readyState=me.CLOSING,t._errorEmitted=!0,t.emit("error",e),t.emitClose()}function _E(t){return t.path=t.socketPath,Ax.connect(t)}function yE(t){return t.path=void 0,!t.servername&&t.servername!==""&&(t.servername=Ax.isIP(t.host)?"":t.host),rE.connect(t)}function ct(t,e,n){t._readyState=me.CLOSING;let i=new Error(n);Error.captureStackTrace(i,ct),e.setHeader?(e[Cx]=!0,e.abort(),e.socket&&!e.socket.destroyed&&e.socket.destroy(),process.nextTick(zo,t,i)):(e.destroy(i),e.once("error",t.emit.bind(t,"error")),e.once("close",t.emitClose.bind(t)))}function yd(t,e,n){if(e){let i=cE(e)?e.size:mE(e).length;t._socket?t._sender._bufferedBytes+=i:t._bufferedAmount+=i}if(n){let i=new Error(`WebSocket is not open: readyState ${t.readyState} (${Yt[t.readyState]})`);process.nextTick(n,i)}}function EE(t,e){let n=this[Ge];n._closeFrameReceived=!0,n._closeMessage=e,n._closeCode=t,n._socket[Ge]!==void 0&&(n._socket.removeListener("data",Fo),process.nextTick(Rx,n._socket),t===1005?n.close():n.close(t,e))}function bE(){let t=this[Ge];t.isPaused||t._socket.resume()}function vE(t){let e=this[Ge];e._socket[Ge]!==void 0&&(e._socket.removeListener("data",Fo),process.nextTick(Rx,e._socket),e.close(t[uE])),e._errorEmitted||(e._errorEmitted=!0,e.emit("error",t))}function Ix(){this[Ge].emitClose()}function SE(t,e){this[Ge].emit("message",t,e)}function IE(t){let e=this[Ge];e._autoPong&&e.pong(t,!this._isServer,Tx),e.emit("ping",t)}function AE(t){this[Ge].emit("pong",t)}function Rx(t){t.resume()}function TE(t){let e=this[Ge];e.readyState!==me.CLOSED&&(e.readyState===me.OPEN&&(e._readyState=me.CLOSING,kx(e)),this._socket.end(),e._errorEmitted||(e._errorEmitted=!0,e.emit("error",t)))}function kx(t){t._closeTimer=setTimeout(t._socket.destroy.bind(t._socket),t._closeTimeout)}function Lx(){let t=this[Ge];if(this.removeListener("close",Lx),this.removeListener("data",Fo),this.removeListener("end",Px),t._readyState=me.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[Ge]=void 0,clearTimeout(t._closeTimer),t._receiver._writableState.finished||t._receiver._writableState.errorEmitted?t.emitClose():(t._receiver.on("error",Ix),t._receiver.on("finish",Ix))}function Fo(t){this[Ge]._receiver.write(t)||this.pause()}function Px(){let t=this[Ge];t._readyState=me.CLOSING,t._receiver.end(),this.end()}function Ox(){let t=this[Ge];this.removeListener("error",Ox),this.on("error",Tx),t&&(t._readyState=me.CLOSING,this.destroy())}});var Fx=ae((zT,zx)=>{"use strict";var BT=Uo(),{Duplex:CE}=fe("stream");function Mx(t){t.emit("close")}function DE(){!this.destroyed&&this._writableState.finished&&this.destroy()}function Bx(t){this.removeListener("error",Bx),this.destroy(),this.listenerCount("error")===0&&this.emit("error",t)}function RE(t,e){let n=!0,i=new CE({...e,autoDestroy:!1,emitClose:!1,objectMode:!1,writableObjectMode:!1});return t.on("message",function(c,l){let f=!l&&i._readableState.objectMode?c.toString():c;i.push(f)||t.pause()}),t.once("error",function(c){i.destroyed||(n=!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(Mx,i);return}let l=!1;t.once("error",function(x){l=!0,c(x)}),t.once("close",function(){l||c(o),process.nextTick(Mx,i)}),n&&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,l){if(t.readyState===t.CONNECTING){t.once("open",function(){i._write(o,c,l)});return}t.send(o,l)},i.on("end",DE),i.on("error",Bx),i}zx.exports=RE});var Ed=ae((FT,Ux)=>{"use strict";var{tokenChars:kE}=Or();function LE(t){let e=new Set,n=-1,i=-1,o=0;for(o;o<t.length;o++){let l=t.charCodeAt(o);if(i===-1&&kE[l]===1)n===-1&&(n=o);else if(o!==0&&(l===32||l===9))i===-1&&n!==-1&&(i=o);else if(l===44){if(n===-1)throw new SyntaxError(`Unexpected character at index ${o}`);i===-1&&(i=o);let f=t.slice(n,i);if(e.has(f))throw new SyntaxError(`The "${f}" subprotocol is duplicated`);e.add(f),n=i=-1}else throw new SyntaxError(`Unexpected character at index ${o}`)}if(n===-1||i!==-1)throw new SyntaxError("Unexpected end of input");let c=t.slice(n,o);if(e.has(c))throw new SyntaxError(`The "${c}" subprotocol is duplicated`);return e.add(c),e}Ux.exports={parse:LE}});var $x=ae((qT,Kx)=>{"use strict";var PE=fe("events"),qo=fe("http"),{Duplex:UT}=fe("stream"),{createHash:OE}=fe("crypto"),qx=Mo(),Jn=Pr(),NE=Ed(),ME=Uo(),{CLOSE_TIMEOUT:BE,GUID:zE,kWebSocket:FE}=Vt(),UE=/^[+/0-9A-Za-z]{22}==$/,Hx=0,Gx=1,Wx=2,bd=class extends PE{constructor(e,n){if(super(),e={allowSynchronousEvents:!0,autoPong:!0,maxPayload:100*1024*1024,skipUTF8Validation:!1,perMessageDeflate:!1,handleProtocols:null,clientTracking:!0,closeTimeout:BE,verifyClient:null,noServer:!1,backlog:null,server:null,host:null,path:null,port:null,WebSocket:ME,...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=qo.createServer((i,o)=>{let c=qo.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,n)):e.server&&(this._server=e.server),this._server){let i=this.emit.bind(this,"connection");this._removeListeners=qE(this._server,{listening:this.emit.bind(this,"listening"),error:this.emit.bind(this,"error"),upgrade:(o,c,l)=>{this.handleUpgrade(o,c,l,i)}})}e.perMessageDeflate===!0&&(e.perMessageDeflate={}),e.clientTracking&&(this.clients=new Set,this._shouldEmitClose=!1),this.options=e,this._state=Hx}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===Wx){e&&this.once("close",()=>{e(new Error("The server is not running"))}),process.nextTick($i,this);return}if(e&&this.once("close",e),this._state!==Gx)if(this._state=Gx,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($i,this):process.nextTick($i,this);else{let n=this._server;this._removeListeners(),this._removeListeners=this._server=null,n.close(()=>{$i(this)})}}shouldHandle(e){if(this.options.path){let n=e.url.indexOf("?");if((n!==-1?e.url.slice(0,n):e.url)!==this.options.path)return!1}return!0}handleUpgrade(e,n,i,o){n.on("error",jx);let c=e.headers["sec-websocket-key"],l=e.headers.upgrade,f=+e.headers["sec-websocket-version"];if(e.method!=="GET"){Vn(this,e,n,405,"Invalid HTTP method");return}if(l===void 0||l.toLowerCase()!=="websocket"){Vn(this,e,n,400,"Invalid Upgrade header");return}if(c===void 0||!UE.test(c)){Vn(this,e,n,400,"Missing or invalid Sec-WebSocket-Key header");return}if(f!==13&&f!==8){Vn(this,e,n,400,"Missing or invalid Sec-WebSocket-Version header",{"Sec-WebSocket-Version":"13, 8"});return}if(!this.shouldHandle(e)){Ji(n,400);return}let x=e.headers["sec-websocket-protocol"],p=new Set;if(x!==void 0)try{p=NE.parse(x)}catch{Vn(this,e,n,400,"Invalid Sec-WebSocket-Protocol header");return}let w=e.headers["sec-websocket-extensions"],v={};if(this.options.perMessageDeflate&&w!==void 0){let T=new Jn({...this.options.perMessageDeflate,isServer:!0,maxPayload:this.options.maxPayload});try{let y=qx.parse(w);y[Jn.extensionName]&&(T.accept(y[Jn.extensionName]),v[Jn.extensionName]=T)}catch{Vn(this,e,n,400,"Invalid or unacceptable Sec-WebSocket-Extensions header");return}}if(this.options.verifyClient){let T={origin:e.headers[`${f===8?"sec-websocket-origin":"origin"}`],secure:!!(e.socket.authorized||e.socket.encrypted),req:e};if(this.options.verifyClient.length===2){this.options.verifyClient(T,(y,b,S,A)=>{if(!y)return Ji(n,b||401,S,A);this.completeUpgrade(v,c,p,e,n,i,o)});return}if(!this.options.verifyClient(T))return Ji(n,401)}this.completeUpgrade(v,c,p,e,n,i,o)}completeUpgrade(e,n,i,o,c,l,f){if(!c.readable||!c.writable)return c.destroy();if(c[FE])throw new Error("server.handleUpgrade() was called more than once with the same socket, possibly due to a misconfiguration");if(this._state>Hx)return Ji(c,503);let p=["HTTP/1.1 101 Switching Protocols","Upgrade: websocket","Connection: Upgrade",`Sec-WebSocket-Accept: ${OE("sha1").update(n+zE).digest("base64")}`],w=new this.options.WebSocket(null,void 0,this.options);if(i.size){let v=this.options.handleProtocols?this.options.handleProtocols(i,o):i.values().next().value;v&&(p.push(`Sec-WebSocket-Protocol: ${v}`),w._protocol=v)}if(e[Jn.extensionName]){let v=e[Jn.extensionName].params,T=qx.format({[Jn.extensionName]:[v]});p.push(`Sec-WebSocket-Extensions: ${T}`),w._extensions=e}this.emit("headers",p,o),c.write(p.concat(`\r
|
|
15
15
|
`).join(`\r
|
|
16
|
-
`)),c.removeListener("error",
|
|
16
|
+
`)),c.removeListener("error",jx),w.setSocket(c,l,{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($i,this)})),f(w,o)}};Kx.exports=bd;function qE(t,e){for(let n of Object.keys(e))t.on(n,e[n]);return function(){for(let i of Object.keys(e))t.removeListener(i,e[i])}}function $i(t){t._state=Wx,t.emit("close")}function jx(){this.destroy()}function Ji(t,e,n,i){n=n||qo.STATUS_CODES[e],i={Connection:"close","Content-Type":"text/html","Content-Length":Buffer.byteLength(n),...i},t.once("finish",t.destroy),t.end(`HTTP/1.1 ${e} ${qo.STATUS_CODES[e]}\r
|
|
17
17
|
`+Object.keys(i).map(o=>`${o}: ${i[o]}`).join(`\r
|
|
18
18
|
`)+`\r
|
|
19
19
|
\r
|
|
20
|
-
`+
|
|
21
|
-
<string>${
|
|
20
|
+
`+n)}function Vn(t,e,n,i,o,c){if(t.listenerCount("wsClientError")){let l=new Error(o);Error.captureStackTrace(l,Vn),t.emit("wsClientError",l,n,e)}else Ji(n,i,o,c)}});import{existsSync as fb,openSync as ub}from"node:fs";import{mkdir as xb}from"node:fs/promises";import{dirname as hb}from"node:path";import{fileURLToPath as pb}from"node:url";function mb(t,e){return e==="legacy"?t.logFile:t.daemonStdioLog}function Ad(t=Q()){return fb(t.libEntry)?t.libEntry:pb(new URL("../index.ts",import.meta.url))}async function ah(t={}){let e=t.paths??Q(),n=t.entryOverride??Ad(e),i=mb(e,process.env.COZE_BRIDGE_LOG_MODE);await xb(hb(i),{recursive:!0});let o=ub(i,"a"),l=n.endsWith(".ts")?["--import","tsx/esm",n,"--daemon"]:[n,"--daemon"],f=ut(process.execPath,l,{detached:!0,stdio:["ignore",o,o],env:{...process.env,[Xi]:"1"}});if(f.unref(),typeof f.pid!="number")throw new Error("failed to spawn daemon (no pid)");return gb.info("daemon spawned",{pid:f.pid,entry:n}),{pid:f.pid,entry:n}}var gb,Xi,$o=Ye(()=>{"use strict";bn();re();Oe();gb=H("spawn-daemon"),Xi="COZE_BRIDGE_DAEMON"});import{spawn as sv}from"node:child_process";import{mkdir as ov,unlink as av,writeFile as cv}from"node:fs/promises";import{dirname as dv,join as lv}from"node:path";function Hr(t){return t.replace(/&/g,"&").replace(/</g,"<").replace(/>/g,">").replace(/"/g,""")}function fv(t){if(!t)return"";let e=Object.entries(t).map(([n,i])=>` <key>${Hr(n)}</key>
|
|
21
|
+
<string>${Hr(i)}</string>`).join(`
|
|
22
22
|
`);return e?`
|
|
23
23
|
<key>EnvironmentVariables</key>
|
|
24
24
|
<dict>
|
|
25
25
|
${e}
|
|
26
|
-
</dict>`:""}function
|
|
26
|
+
</dict>`:""}function uv(t,e){return new Promise((n,i)=>{let o=sv(t,e,{stdio:["ignore","pipe","pipe"]}),c="";o.stderr?.on("data",l=>{c+=l.toString("utf8")}),o.on("error",i),o.on("close",l=>{l===0?n():i(new Error(`${t} ${e.join(" ")} exited ${l}: ${c.trim()}`))})})}var qr,Qi,ea,Pd,Sh=Ye(()=>{"use strict";re();qr=H("supervisor.launchd"),Qi="ai.coze.bridge",ea=uv,Pd={platform:"darwin",renderConfig(t){return`<?xml version="1.0" encoding="UTF-8"?>
|
|
27
27
|
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
|
|
28
28
|
<plist version="1.0">
|
|
29
29
|
<dict>
|
|
30
30
|
<key>Label</key>
|
|
31
|
-
<string>${
|
|
31
|
+
<string>${Qi}</string>
|
|
32
32
|
<key>ProgramArguments</key>
|
|
33
33
|
<array>
|
|
34
|
-
<string>${
|
|
35
|
-
<string>${
|
|
34
|
+
<string>${Hr(t.nodeBin)}</string>
|
|
35
|
+
<string>${Hr(t.entry)}</string>
|
|
36
36
|
<string>--daemon</string>
|
|
37
37
|
</array>
|
|
38
38
|
<key>RunAtLoad</key>
|
|
@@ -42,13 +42,13 @@ ${e}
|
|
|
42
42
|
<key>ThrottleInterval</key>
|
|
43
43
|
<integer>10</integer>
|
|
44
44
|
<key>StandardOutPath</key>
|
|
45
|
-
<string>${
|
|
45
|
+
<string>${Hr(t.logFile)}</string>
|
|
46
46
|
<key>StandardErrorPath</key>
|
|
47
|
-
<string>${
|
|
47
|
+
<string>${Hr(t.logFile)}</string>${fv(t.env)}
|
|
48
48
|
</dict>
|
|
49
49
|
</plist>
|
|
50
|
-
`},configPath(t){return
|
|
51
|
-
`):""}function
|
|
50
|
+
`},configPath(t){return lv(t.homeDir,"Library","LaunchAgents",`${Qi}.plist`)},async install(t,e){let n=e?.activate!==!1,i=this.configPath(t);if(await ov(dv(i),{recursive:!0}),await cv(i,this.renderConfig(t),"utf8"),qr.info("plist written",{plistPath:i,activate:n}),!n)return;await ea("launchctl",["unload","-w",i]).catch(c=>qr.info("launchctl unload before load (ignored, likely not loaded yet)",{err:String(c)})),await ea("launchctl",["load","-w",i]),qr.info("launchd job loaded",{label:Qi});let o=process.getuid?.()??0;await ea("launchctl",["kickstart","-k",`gui/${o}/${Qi}`]),qr.info("launchd job kickstarted",{label:Qi,uid:o})},async uninstall(t){let e=this.configPath(t);await ea("launchctl",["unload","-w",e]).catch(n=>qr.warn("launchctl unload failed (ignored)",{err:String(n)})),await av(e).catch(n=>{if(n.code!=="ENOENT")throw n}),qr.info("launchd job removed",{plistPath:e})}}});import{spawn as xv}from"node:child_process";import{mkdir as hv,unlink as pv,writeFile as gv}from"node:fs/promises";import{dirname as mv,join as Ih}from"node:path";function na(t,e){return t.isRoot?e:["--user",...e]}function _v(t){return t?Object.entries(t).map(([e,n])=>{let i=n.replace(/\\/g,"\\\\").replace(/"/g,'\\"');return`Environment="${e}=${i}"`}).join(`
|
|
51
|
+
`):""}function ra(t,e){return new Promise((n,i)=>{let o=xv(t,e,{stdio:["ignore","pipe","pipe"]}),c="";o.stderr?.on("data",l=>{c+=l.toString("utf8")}),o.on("error",i),o.on("close",l=>{l===0?n():i(new Error(`${t} ${e.join(" ")} exited ${l}: ${c.trim()}`))})})}var ta,Gr,wv,Od,Ah=Ye(()=>{"use strict";re();ta=H("supervisor.systemd"),Gr="coze-bridge.service",wv="/etc/systemd/system";Od={platform:"linux",renderConfig(t){let e=t.isRoot?"multi-user.target":"default.target";return`[Unit]
|
|
52
52
|
Description=Coze Bridge daemon
|
|
53
53
|
After=network.target
|
|
54
54
|
|
|
@@ -59,10 +59,10 @@ Restart=always
|
|
|
59
59
|
RestartSec=3
|
|
60
60
|
StandardOutput=append:${t.logFile}
|
|
61
61
|
StandardError=append:${t.logFile}
|
|
62
|
-
${
|
|
62
|
+
${_v(t.env)}
|
|
63
63
|
[Install]
|
|
64
64
|
WantedBy=${e}
|
|
65
|
-
`},configPath(t){return t.isRoot?
|
|
65
|
+
`},configPath(t){return t.isRoot?Ih(wv,Gr):Ih(t.homeDir,".config","systemd","user",Gr)},async install(t,e){let n=e?.activate!==!1,i=this.configPath(t),o=t.isRoot?"system":"user";await hv(mv(i),{recursive:!0}),await gv(i,this.renderConfig(t),"utf8"),ta.info("systemd unit written",{unitPath:i,mode:o,activate:n}),await ra("systemctl",na(t,["daemon-reload"])),await ra("systemctl",na(t,n?["enable","--now",Gr]:["enable",Gr])),ta.info("systemd unit enabled",{unitName:Gr,mode:o,activate:n})},async uninstall(t){let e=this.configPath(t);await ra("systemctl",na(t,["disable","--now",Gr])).catch(n=>ta.warn("systemctl disable failed (ignored)",{err:String(n)})),await pv(e).catch(n=>{if(n.code!=="ENOENT")throw n}),await ra("systemctl",na(t,["daemon-reload"])).catch(()=>{}),ta.info("systemd unit removed",{unitPath:e})}}});import{spawn as yv}from"node:child_process";import{join as Ev}from"node:path";function Th(t,e){return new Promise((n,i)=>{let o=yv(t,e,{stdio:["ignore","pipe","pipe"],shell:!1}),c="";o.stderr?.on("data",l=>{c+=l.toString("utf8")}),o.on("error",i),o.on("close",l=>{l===0?n():i(new Error(`${t} ${e.join(" ")} exited ${l}: ${c.trim()}`))})})}var Nd,ia,Md,Ch=Ye(()=>{"use strict";re();Nd=H("supervisor.taskscheduler"),ia="CozeBridge",Md={platform:"win32",renderConfig(t){return`<?xml version="1.0" encoding="UTF-16"?>
|
|
66
66
|
<Task version="1.2" xmlns="http://schemas.microsoft.com/windows/2004/02/mit/task">
|
|
67
67
|
<RegistrationInfo>
|
|
68
68
|
<Description>Coze Bridge daemon</Description>
|
|
@@ -86,43 +86,43 @@ WantedBy=${e}
|
|
|
86
86
|
</Exec>
|
|
87
87
|
</Actions>
|
|
88
88
|
</Task>
|
|
89
|
-
`},configPath(t){return bS(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 Sh("schtasks",["/Create","/SC","ONLOGON","/TN",ea,"/TR",r,"/RU",t.userName,"/F"]),Pd.info("task scheduler entry created",{task:ea,logFile:t.logFile})},async uninstall(t){await Sh("schtasks",["/Delete","/TN",ea,"/F"]).catch(e=>Pd.warn("schtasks /Delete failed (ignored)",{err:String(e)})),Pd.info("task scheduler entry removed",{task:ea})}}});var Ah={};ha(Ah,{buildContext:()=>TS,getSupervisor:()=>SS,launchdSupervisor:()=>Dd,systemdSupervisor:()=>kd,taskSchedulerSupervisor:()=>Ld});import{homedir as ES,userInfo as vS}from"node:os";function SS(t=process.platform){switch(t){case"darwin":return Dd;case"linux":return kd;case"win32":return Ld;default:throw new Error(`unsupported platform for OS supervisor: ${t}`)}}function AS(){let t={};for(let e of IS){let r=process.env[e];r&&(t[e]=r)}return t}function TS(){let t=Q();return{nodeBin:process.execPath,entry:vd(t),logFile:t.logFile,homeDir:ES(),userName:vS().username,isRoot:process.getuid?.()===0,env:AS()}}var IS,Th=Ve(()=>{"use strict";De();Go();bh();vh();Ih();IS=["PATH","HOME","HTTP_PROXY","HTTPS_PROXY","NO_PROXY","ALL_PROXY","http_proxy","https_proxy","no_proxy","all_proxy","NODE_EXTRA_CA_CERTS"]});ne();Qt();var dl=H("acp-installer-warmup"),Xp=["claude-code","codex"];async function ll(t={}){let e=t.ensure??Xn,i=(await Promise.allSettled(Xp.map(async o=>{let c=await e(o);dl.info("acp wrapper warmup ok",{framework:o,path:c})}))).filter(o=>o.status==="rejected");i.length>0&&dl.warn("acp wrapper warmup partial failure (\u5C06\u5728\u4E0B\u6B21 createAgent \u65F6\u91CD\u8BD5\u5E76\u629B\u9519\u7ED9\u7528\u6237)",{failedCount:i.length,reasons:i.map(o=>o.reason instanceof Error?o.reason.message:String(o.reason))})}en();ne();import{readdir as lg}from"node:fs/promises";import{mkdir as gl,writeFile as ml}from"node:fs/promises";import{join as ba}from"node:path";var dg={"claude-code":"CLAUDE.md",codex:"AGENTS.md",openclaw:"SOUL.md"};async function tr(t,e,r){await gl(t,{recursive:!0});let i=dg[e],o=ba(t,i);return await ml(o,r??"","utf8"),o}async function wl(t){let e=ba(t,".claude");await gl(e,{recursive:!0});let r=ba(e,"settings.local.json"),i=JSON.stringify({permissions:{defaultMode:"bypassPermissions"}},null,2);return await ml(r,i,"utf8"),r}var Qe=H("agent-detail-sync"),ug=6e4,fg=5*6e4,as=class{constructor(e){this.opts=e}opts;retryQueue=new Map;async syncAll(e){let r=this.opts.paths.agentsRoot,i;try{i=await lg(r)}catch(o){Qe.info("agents dir not found, skip detail sync",{root:r,err:String(o)});return}Qe.info("starting detail sync",{reason:e,count:i.length}),await Promise.allSettled(i.map(async o=>{let c=await Ge(o,this.opts.paths).catch(()=>null);if(c){if(c.disconnectedAt){Qe.debug("detail sync: skip disconnected agent",{agentId:o});return}try{await this.syncOne(o,c)}catch(l){Qe.warn("detail sync failed for agent, skipping",{agentId:o,err:String(l)})}}})),Qe.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){Qe.info("retrying pending detail syncs",{count:r.length});for(let i of r)try{await this.syncOne(i)}catch(o){Qe.debug("detail sync retry still failing, will try again",{agentId:i,err:String(o)})}}}async syncOne(e,r){let i=r??await Ge(e,this.opts.paths);if(!i){Qe.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){Qe.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,fg):ug;this.retryQueue.set(e,{dueAt:Date.now()+p,currentDelay:p});return}if(o.agentId&&o.agentId!==e){Qe.warn("detail response agentId mismatch, ignoring",{agentId:e,responseAgentId:o.agentId});return}let c=!1,l=!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,l=!0),o.deployType&&Qe.info("detail.deployType",{agentId:e,deployType:o.deployType}),!c){Qe.debug("detail sync: no diff",{agentId:e});return}await Ze(i,this.opts.paths),Qe.info("detail sync: config updated",{agentId:e,identityChanged:l,agentName:i.agentName}),l&&(await tr(i.workspace,i.framework,i.cozeIdentity),this.opts.handlers.reloadAgentSessionsPublic(e,"detail-sync"))}};var Ou=Et(Zl(),1);import{lstat as Mc,mkdir as Bc,readFile as Du,readdir as Fw,rm as Uw,stat as Hw,writeFile as zc}from"node:fs/promises";import{dirname as qw,join as Rt,normalize as Gw,relative as Hc,resolve as Fc,sep as ku}from"node:path";import{Readable as Pu}from"node:stream";import{pipeline as Lu}from"node:stream/promises";import Og from"events";import Xe from"fs";import{EventEmitter as yc}from"node:events";import P0 from"node:stream";import{StringDecoder as Ng}from"node:string_decoder";import N0 from"node:path";import xr from"node:fs";import{dirname as Jg,parse as Vg}from"path";import{EventEmitter as rm}from"events";import tc from"assert";import{Buffer as Nn}from"buffer";import*as n0 from"zlib";import im from"zlib";import{posix as or}from"node:path";import{basename as km}from"node:path";import Fs from"fs";import At from"fs";import d0 from"path";import{win32 as qm}from"node:path";import g0 from"path";import Y0 from"node:fs";import sw from"node:assert";import{randomBytes as Z0}from"node:crypto";import re from"node:fs";import Pe from"node:path";import X0 from"fs";import Js from"node:fs";import hi from"node:path";import rt from"node:fs";import fw from"node:fs/promises";import qs from"node:path";import{join as du}from"node:path";import nt from"node:fs";import fu from"node:path";var Pg=Object.defineProperty,Lg=(t,e)=>{for(var r in e)Pg(t,r,{get:e[r],enumerable:!0})},Xl=typeof process=="object"&&process?process:{stdout:null,stderr:null},Mg=t=>!!t&&typeof t=="object"&&(t instanceof zn||t instanceof P0||Bg(t)||zg(t)),Bg=t=>!!t&&typeof t=="object"&&t instanceof yc&&typeof t.pipe=="function"&&t.pipe!==P0.Writable.prototype.pipe,zg=t=>!!t&&typeof t=="object"&&t instanceof yc&&typeof t.write=="function"&&typeof t.end=="function",Bt=Symbol("EOF"),zt=Symbol("maybeEmitEnd"),nn=Symbol("emittedEnd"),fs=Symbol("emittingEnd"),Zr=Symbol("emittedError"),xs=Symbol("closed"),Ql=Symbol("read"),hs=Symbol("flush"),e0=Symbol("flushChunk"),xt=Symbol("encoding"),sr=Symbol("decoder"),Me=Symbol("flowing"),Xr=Symbol("paused"),lr=Symbol("resume"),Be=Symbol("buffer"),$e=Symbol("pipes"),ze=Symbol("bufferLength"),Ta=Symbol("bufferPush"),ps=Symbol("bufferShift"),We=Symbol("objectMode"),Ee=Symbol("destroyed"),Ca=Symbol("error"),Ra=Symbol("emitData"),t0=Symbol("emitEnd"),Da=Symbol("emitEnd2"),vt=Symbol("async"),ka=Symbol("abort"),gs=Symbol("aborted"),Qr=Symbol("signal"),An=Symbol("dataListeners"),et=Symbol("discarded"),ei=t=>Promise.resolve().then(t),Fg=t=>t(),Ug=t=>t==="end"||t==="finish"||t==="prefinish",Hg=t=>t instanceof ArrayBuffer||!!t&&typeof t=="object"&&t.constructor&&t.constructor.name==="ArrayBuffer"&&t.byteLength>=0,qg=t=>!Buffer.isBuffer(t)&&ArrayBuffer.isView(t),L0=class{src;dest;opts;ondrain;constructor(t,e,r){this.src=t,this.dest=e,this.opts=r,this.ondrain=()=>t[lr](),this.dest.on("drain",this.ondrain)}unpipe(){this.dest.removeListener("drain",this.ondrain)}proxyErrors(t){}end(){this.unpipe(),this.opts.end&&this.dest.end()}},Gg=class extends L0{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)}},jg=t=>!!t.objectMode,Wg=t=>!t.objectMode&&!!t.encoding&&t.encoding!=="buffer",zn=class extends yc{[Me]=!1;[Xr]=!1;[$e]=[];[Be]=[];[We];[xt];[vt];[sr];[Bt]=!1;[nn]=!1;[fs]=!1;[xs]=!1;[Zr]=null;[ze]=0;[Ee]=!1;[Qr];[gs]=!1;[An]=0;[et]=!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");jg(e)?(this[We]=!0,this[xt]=null):Wg(e)?(this[xt]=e.encoding,this[We]=!1):(this[We]=!1,this[xt]=null),this[vt]=!!e.async,this[sr]=this[xt]?new Ng(this[xt]):null,e&&e.debugExposeBuffer===!0&&Object.defineProperty(this,"buffer",{get:()=>this[Be]}),e&&e.debugExposePipes===!0&&Object.defineProperty(this,"pipes",{get:()=>this[$e]});let{signal:r}=e;r&&(this[Qr]=r,r.aborted?this[ka]():r.addEventListener("abort",()=>this[ka]()))}get bufferLength(){return this[ze]}get encoding(){return this[xt]}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[We]}set objectMode(t){throw new Error("objectMode must be set at instantiation time")}get async(){return this[vt]}set async(t){this[vt]=this[vt]||!!t}[ka](){this[gs]=!0,this.emit("abort",this[Qr]?.reason),this.destroy(this[Qr]?.reason)}get aborted(){return this[gs]}set aborted(t){}write(t,e,r){if(this[gs])return!1;if(this[Bt])throw new Error("write after end");if(this[Ee])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[vt]?ei:Fg;if(!this[We]&&!Buffer.isBuffer(t)){if(qg(t))t=Buffer.from(t.buffer,t.byteOffset,t.byteLength);else if(Hg(t))t=Buffer.from(t);else if(typeof t!="string")throw new Error("Non-contiguous data written to non-objectMode stream")}return this[We]?(this[Me]&&this[ze]!==0&&this[hs](!0),this[Me]?this.emit("data",t):this[Ta](t),this[ze]!==0&&this.emit("readable"),r&&i(r),this[Me]):t.length?(typeof t=="string"&&!(e===this[xt]&&!this[sr]?.lastNeed)&&(t=Buffer.from(t,e)),Buffer.isBuffer(t)&&this[xt]&&(t=this[sr].write(t)),this[Me]&&this[ze]!==0&&this[hs](!0),this[Me]?this.emit("data",t):this[Ta](t),this[ze]!==0&&this.emit("readable"),r&&i(r),this[Me]):(this[ze]!==0&&this.emit("readable"),r&&i(r),this[Me])}read(t){if(this[Ee])return null;if(this[et]=!1,this[ze]===0||t===0||t&&t>this[ze])return this[zt](),null;this[We]&&(t=null),this[Be].length>1&&!this[We]&&(this[Be]=[this[xt]?this[Be].join(""):Buffer.concat(this[Be],this[ze])]);let e=this[Ql](t||null,this[Be][0]);return this[zt](),e}[Ql](t,e){if(this[We])this[ps]();else{let r=e;t===r.length||t===null?this[ps]():typeof r=="string"?(this[Be][0]=r.slice(t),e=r.slice(0,t),this[ze]-=t):(this[Be][0]=r.subarray(t),e=r.subarray(0,t),this[ze]-=t)}return this.emit("data",e),!this[Be].length&&!this[Bt]&&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[Bt]=!0,this.writable=!1,(this[Me]||!this[Xr])&&this[zt](),this}[lr](){this[Ee]||(!this[An]&&!this[$e].length&&(this[et]=!0),this[Xr]=!1,this[Me]=!0,this.emit("resume"),this[Be].length?this[hs]():this[Bt]?this[zt]():this.emit("drain"))}resume(){return this[lr]()}pause(){this[Me]=!1,this[Xr]=!0,this[et]=!1}get destroyed(){return this[Ee]}get flowing(){return this[Me]}get paused(){return this[Xr]}[Ta](t){this[We]?this[ze]+=1:this[ze]+=t.length,this[Be].push(t)}[ps](){return this[We]?this[ze]-=1:this[ze]-=this[Be][0].length,this[Be].shift()}[hs](t=!1){do;while(this[e0](this[ps]())&&this[Be].length);!t&&!this[Be].length&&!this[Bt]&&this.emit("drain")}[e0](t){return this.emit("data",t),this[Me]}pipe(t,e){if(this[Ee])return t;this[et]=!1;let r=this[nn];return e=e||{},t===Xl.stdout||t===Xl.stderr?e.end=!1:e.end=e.end!==!1,e.proxyErrors=!!e.proxyErrors,r?e.end&&t.end():(this[$e].push(e.proxyErrors?new Gg(this,t,e):new L0(this,t,e)),this[vt]?ei(()=>this[lr]()):this[lr]()),t}unpipe(t){let e=this[$e].find(r=>r.dest===t);e&&(this[$e].length===1?(this[Me]&&this[An]===0&&(this[Me]=!1),this[$e]=[]):this[$e].splice(this[$e].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[et]=!1,this[An]++,!this[$e].length&&!this[Me]&&this[lr]();else if(t==="readable"&&this[ze]!==0)super.emit("readable");else if(Ug(t)&&this[nn])super.emit(t),this.removeAllListeners(t);else if(t==="error"&&this[Zr]){let i=e;this[vt]?ei(()=>i.call(this,this[Zr])):i.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[An]=this.listeners("data").length,this[An]===0&&!this[et]&&!this[$e].length&&(this[Me]=!1)),r}removeAllListeners(t){let e=super.removeAllListeners(t);return(t==="data"||t===void 0)&&(this[An]=0,!this[et]&&!this[$e].length&&(this[Me]=!1)),e}get emittedEnd(){return this[nn]}[zt](){!this[fs]&&!this[nn]&&!this[Ee]&&this[Be].length===0&&this[Bt]&&(this[fs]=!0,this.emit("end"),this.emit("prefinish"),this.emit("finish"),this[xs]&&this.emit("close"),this[fs]=!1)}emit(t,...e){let r=e[0];if(t!=="error"&&t!=="close"&&t!==Ee&&this[Ee])return!1;if(t==="data")return!this[We]&&!r?!1:this[vt]?(ei(()=>this[Ra](r)),!0):this[Ra](r);if(t==="end")return this[t0]();if(t==="close"){if(this[xs]=!0,!this[nn]&&!this[Ee])return!1;let o=super.emit("close");return this.removeAllListeners("close"),o}else if(t==="error"){this[Zr]=r,super.emit(Ca,r);let o=!this[Qr]||this.listeners("error").length?super.emit("error",r):!1;return this[zt](),o}else if(t==="resume"){let o=super.emit("resume");return this[zt](),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[zt](),i}[Ra](t){for(let r of this[$e])r.dest.write(t)===!1&&this.pause();let e=this[et]?!1:super.emit("data",t);return this[zt](),e}[t0](){return this[nn]?!1:(this[nn]=!0,this.readable=!1,this[vt]?(ei(()=>this[Da]()),!0):this[Da]())}[Da](){if(this[sr]){let e=this[sr].end();if(e){for(let r of this[$e])r.dest.write(e);this[et]||super.emit("data",e)}}for(let e of this[$e])e.end();let t=super.emit("end");return this.removeAllListeners("end"),t}async collect(){let t=Object.assign([],{dataLength:0});this[We]||(t.dataLength=0);let e=this.promise();return this.on("data",r=>{t.push(r),this[We]||(t.dataLength+=r.length)}),await e,t}async concat(){if(this[We])throw new Error("cannot concat in objectMode");let t=await this.collect();return this[xt]?t.join(""):Buffer.concat(t,t.dataLength)}async promise(){return new Promise((t,e)=>{this.on(Ee,()=>e(new Error("stream destroyed"))),this.on("error",r=>e(r)),this.on("end",()=>t())})}[Symbol.asyncIterator](){this[et]=!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[Bt])return e();let i,o,c=p=>{this.off("data",l),this.off("end",u),this.off(Ee,x),e(),o(p)},l=p=>{this.off("error",c),this.off("end",u),this.off(Ee,x),this.pause(),i({value:p,done:!!this[Bt]})},u=()=>{this.off("error",c),this.off("data",l),this.off(Ee,x),e(),i({done:!0,value:void 0})},x=()=>c(new Error("stream destroyed"));return new Promise((p,m)=>{o=m,i=p,this.once(Ee,x),this.once("error",c),this.once("end",u),this.once("data",l)})},throw:e,return:e,[Symbol.asyncIterator](){return this},[Symbol.asyncDispose]:async()=>{}}}[Symbol.iterator](){this[et]=!1;let t=!1,e=()=>(this.pause(),this.off(Ca,e),this.off(Ee,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(Ca,e),this.once(Ee,e),{next:r,throw:e,return:e,[Symbol.iterator](){return this},[Symbol.dispose]:()=>{}}}destroy(t){if(this[Ee])return t?this.emit("error",t):this.emit(Ee),this;this[Ee]=!0,this[et]=!0,this[Be].length=0,this[ze]=0;let e=this;return typeof e.close=="function"&&!this[xs]&&e.close(),t?this.emit("error",t):this.emit(Ee),this}static get isStream(){return Mg}},Kg=Xe.writev,xn=Symbol("_autoClose"),mt=Symbol("_close"),ti=Symbol("_ended"),ae=Symbol("_fd"),Pa=Symbol("_finished"),qt=Symbol("_flags"),La=Symbol("_flush"),Qa=Symbol("_handleChunk"),ec=Symbol("_makeBuf"),fi=Symbol("_mode"),ms=Symbol("_needDrain"),pr=Symbol("_onerror"),gr=Symbol("_onopen"),Oa=Symbol("_onread"),ur=Symbol("_onwrite"),hn=Symbol("_open"),gt=Symbol("_path"),cn=Symbol("_pos"),St=Symbol("_queue"),fr=Symbol("_read"),Na=Symbol("_readSize"),Ht=Symbol("_reading"),ni=Symbol("_remain"),Ma=Symbol("_size"),Ts=Symbol("_write"),Tn=Symbol("_writing"),Cs=Symbol("_defaultFlag"),On=Symbol("_errored"),bc=class extends zn{[On]=!1;[ae];[gt];[Na];[Ht]=!1;[Ma];[ni];[xn];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[On]=!1,this[ae]=typeof e.fd=="number"?e.fd:void 0,this[gt]=t,this[Na]=e.readSize||16*1024*1024,this[Ht]=!1,this[Ma]=typeof e.size=="number"?e.size:1/0,this[ni]=this[Ma],this[xn]=typeof e.autoClose=="boolean"?e.autoClose:!0,typeof this[ae]=="number"?this[fr]():this[hn]()}get fd(){return this[ae]}get path(){return this[gt]}write(){throw new TypeError("this is a readable stream")}end(){throw new TypeError("this is a readable stream")}[hn](){Xe.open(this[gt],"r",(t,e)=>this[gr](t,e))}[gr](t,e){t?this[pr](t):(this[ae]=e,this.emit("open",e),this[fr]())}[ec](){return Buffer.allocUnsafe(Math.min(this[Na],this[ni]))}[fr](){if(!this[Ht]){this[Ht]=!0;let t=this[ec]();if(t.length===0)return process.nextTick(()=>this[Oa](null,0,t));Xe.read(this[ae],t,0,t.length,null,(e,r,i)=>this[Oa](e,r,i))}}[Oa](t,e,r){this[Ht]=!1,t?this[pr](t):this[Qa](e,r)&&this[fr]()}[mt](){if(this[xn]&&typeof this[ae]=="number"){let t=this[ae];this[ae]=void 0,Xe.close(t,e=>e?this.emit("error",e):this.emit("close"))}}[pr](t){this[Ht]=!0,this[mt](),this.emit("error",t)}[Qa](t,e){let r=!1;return this[ni]-=t,t>0&&(r=super.write(t<e.length?e.subarray(0,t):e)),(t===0||this[ni]<=0)&&(r=!1,this[mt](),super.end()),r}emit(t,...e){switch(t){case"prefinish":case"finish":return!1;case"drain":return typeof this[ae]=="number"&&this[fr](),!1;case"error":return this[On]?!1:(this[On]=!0,super.emit(t,...e));default:return super.emit(t,...e)}}},$g=class extends bc{[hn](){let t=!0;try{this[gr](null,Xe.openSync(this[gt],"r")),t=!1}finally{t&&this[mt]()}}[fr](){let t=!0;try{if(!this[Ht]){this[Ht]=!0;do{let e=this[ec](),r=e.length===0?0:Xe.readSync(this[ae],e,0,e.length,null);if(!this[Qa](r,e))break}while(!0);this[Ht]=!1}t=!1}finally{t&&this[mt]()}}[mt](){if(this[xn]&&typeof this[ae]=="number"){let t=this[ae];this[ae]=void 0,Xe.closeSync(t),this.emit("close")}}},Gs=class extends Og{readable=!1;writable=!0;[On]=!1;[Tn]=!1;[ti]=!1;[St]=[];[ms]=!1;[gt];[fi];[xn];[ae];[Cs];[qt];[Pa]=!1;[cn];constructor(t,e){e=e||{},super(e),this[gt]=t,this[ae]=typeof e.fd=="number"?e.fd:void 0,this[fi]=e.mode===void 0?438:e.mode,this[cn]=typeof e.start=="number"?e.start:void 0,this[xn]=typeof e.autoClose=="boolean"?e.autoClose:!0;let r=this[cn]!==void 0?"r+":"w";this[Cs]=e.flags===void 0,this[qt]=e.flags===void 0?r:e.flags,this[ae]===void 0&&this[hn]()}emit(t,...e){if(t==="error"){if(this[On])return!1;this[On]=!0}return super.emit(t,...e)}get fd(){return this[ae]}get path(){return this[gt]}[pr](t){this[mt](),this[Tn]=!0,this.emit("error",t)}[hn](){Xe.open(this[gt],this[qt],this[fi],(t,e)=>this[gr](t,e))}[gr](t,e){this[Cs]&&this[qt]==="r+"&&t&&t.code==="ENOENT"?(this[qt]="w",this[hn]()):t?this[pr](t):(this[ae]=e,this.emit("open",e),this[Tn]||this[La]())}end(t,e){return t&&this.write(t,e),this[ti]=!0,!this[Tn]&&!this[St].length&&typeof this[ae]=="number"&&this[ur](null,0),this}write(t,e){return typeof t=="string"&&(t=Buffer.from(t,e)),this[ti]?(this.emit("error",new Error("write() after end()")),!1):this[ae]===void 0||this[Tn]||this[St].length?(this[St].push(t),this[ms]=!0,!1):(this[Tn]=!0,this[Ts](t),!0)}[Ts](t){Xe.write(this[ae],t,0,t.length,this[cn],(e,r)=>this[ur](e,r))}[ur](t,e){t?this[pr](t):(this[cn]!==void 0&&typeof e=="number"&&(this[cn]+=e),this[St].length?this[La]():(this[Tn]=!1,this[ti]&&!this[Pa]?(this[Pa]=!0,this[mt](),this.emit("finish")):this[ms]&&(this[ms]=!1,this.emit("drain"))))}[La](){if(this[St].length===0)this[ti]&&this[ur](null,0);else if(this[St].length===1)this[Ts](this[St].pop());else{let t=this[St];this[St]=[],Kg(this[ae],t,this[cn],(e,r)=>this[ur](e,r))}}[mt](){if(this[xn]&&typeof this[ae]=="number"){let t=this[ae];this[ae]=void 0,Xe.close(t,e=>e?this.emit("error",e):this.emit("close"))}}},O0=class extends Gs{[hn](){let t;if(this[Cs]&&this[qt]==="r+")try{t=Xe.openSync(this[gt],this[qt],this[fi])}catch(e){if(e?.code==="ENOENT")return this[qt]="w",this[hn]();throw e}else t=Xe.openSync(this[gt],this[qt],this[fi]);this[gr](null,t)}[mt](){if(this[xn]&&typeof this[ae]=="number"){let t=this[ae];this[ae]=void 0,Xe.closeSync(t),this.emit("close")}}[Ts](t){let e=!0;try{this[ur](null,Xe.writeSync(this[ae],t,0,t.length,this[cn])),e=!1}finally{if(e)try{this[mt]()}catch{}}}},Yg=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"]]),Zg=t=>!!t.sync&&!!t.file,Xg=t=>!t.sync&&!!t.file,Qg=t=>!!t.sync&&!t.file,em=t=>!t.sync&&!t.file,tm=t=>!!t.file,nm=t=>Yg.get(t)||t,Ec=(t={})=>{if(!t)return{};let e={};for(let[r,i]of Object.entries(t)){let o=nm(r);e[o]=i}return e.chmod===void 0&&e.noChmod===!1&&(e.chmod=!0),delete e.noChmod,e},bi=(t,e,r,i,o)=>Object.assign((c=[],l,u)=>{Array.isArray(c)&&(l=c,c={}),typeof l=="function"&&(u=l,l=void 0),l=l?Array.from(l):[];let x=Ec(c);if(o?.(x,l),Zg(x)){if(typeof u=="function")throw new TypeError("callback not supported for sync tar functions");return t(x,l)}else if(Xg(x)){let p=e(x,l);return u?p.then(()=>u(),u):p}else if(Qg(x)){if(typeof u=="function")throw new TypeError("callback not supported for sync tar functions");return r(x,l)}else if(em(x)){if(typeof u=="function")throw new TypeError("callback only supported with file option");return i(x,l)}throw new Error("impossible options??")},{syncFile:t,asyncFile:e,syncNoFile:r,asyncNoFile:i,validate:o}),sm=im.constants||{ZLIB_VERNUM:4736},Ct=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},sm)),om=Nn.concat,r0=Object.getOwnPropertyDescriptor(Nn,"concat"),am=t=>t,Ba=r0?.writable===!0||r0?.set!==void 0?t=>{Nn.concat=t?am:om}:t=>{},Mn=Symbol("_superWrite"),ws=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"}},za=Symbol("flushFlag"),vc=class extends zn{#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 n0[e]!="function")throw new TypeError("Compression method not supported: "+e);try{this.#t=new n0[e](t)}catch(r){throw new ws(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 ws(r))),this.once("end",()=>this.close)}close(){this.#t&&(this.#t.close(),this.#t=void 0,this.emit("close"))}reset(){if(!this.#e)return tc(this.#t,"zlib binding closed"),this.#t.reset?.()}flush(t){this.ended||(typeof t!="number"&&(t=this.#i),this.write(Object.assign(Nn.alloc(0),{[za]: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}[Mn](t){return super.write(t)}write(t,e,r){if(typeof e=="function"&&(r=e,e="utf8"),typeof t=="string"&&(t=Nn.from(t,e)),this.#e)return;tc(this.#t,"zlib binding closed");let i=this.#t._handle,o=i.close;i.close=()=>{};let c=this.#t.close;this.#t.close=()=>{},Ba(!0);let l;try{let x=typeof t[za]=="number"?t[za]:this.#r;l=this.#t._processChunk(t,x),Ba(!1)}catch(x){Ba(!1),this.#o(new ws(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 ws(x,this.write)));let u;if(l)if(Array.isArray(l)&&l.length>0){let x=l[0];u=this[Mn](Nn.from(x));for(let p=1;p<l.length;p++)u=this[Mn](l[p])}else u=this[Mn](Nn.from(l));return r&&r(),u}},M0=class extends vc{#e;#n;constructor(t,e){t=t||{},t.flush=t.flush||Ct.Z_NO_FLUSH,t.finishFlush=t.finishFlush||Ct.Z_FINISH,t.fullFlushFlag=Ct.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(Ct.Z_SYNC_FLUSH),tc(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)}}}},cm=class extends M0{#e;constructor(t){super(t,"Gzip"),this.#e=t&&!!t.portable}[Mn](t){return this.#e?(this.#e=!1,t[9]=255,super[Mn](t)):super[Mn](t)}},dm=class extends M0{constructor(t){super(t,"Unzip")}},B0=class extends vc{constructor(t,e){t=t||{},t.flush=t.flush||Ct.BROTLI_OPERATION_PROCESS,t.finishFlush=t.finishFlush||Ct.BROTLI_OPERATION_FINISH,t.fullFlushFlag=Ct.BROTLI_OPERATION_FLUSH,super(t,e)}},lm=class extends B0{constructor(t){super(t,"BrotliCompress")}},um=class extends B0{constructor(t){super(t,"BrotliDecompress")}},z0=class extends vc{constructor(t,e){t=t||{},t.flush=t.flush||Ct.ZSTD_e_continue,t.finishFlush=t.finishFlush||Ct.ZSTD_e_end,t.fullFlushFlag=Ct.ZSTD_e_flush,super(t,e)}},fm=class extends z0{constructor(t){super(t,"ZstdCompress")}},xm=class extends z0{constructor(t){super(t,"ZstdDecompress")}},hm=(t,e)=>{if(Number.isSafeInteger(t))t<0?gm(t,e):pm(t,e);else throw Error("cannot encode number outside of javascript safe integer range");return e},pm=(t,e)=>{e[0]=128;for(var r=e.length;r>1;r--)e[r-1]=t&255,t=Math.floor(t/256)},gm=(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]=F0(o):o===0?e[i-1]=0:(r=!0,e[i-1]=U0(o))}},mm=t=>{let e=t[0],r=e===128?_m(t.subarray(1,t.length)):e===255?wm(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},wm=t=>{for(var e=t.length,r=0,i=!1,o=e-1;o>-1;o--){var c=Number(t[o]),l;i?l=F0(c):c===0?l=c:(i=!0,l=U0(c)),l!==0&&(r-=l*Math.pow(256,e-o-1))}return r},_m=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},F0=t=>(255^t)&255,U0=t=>(255^t)+1&255,ym={};Lg(ym,{code:()=>Sc,isCode:()=>Rs,isName:()=>bm,name:()=>js});var Rs=t=>js.has(t),bm=t=>Sc.has(t),js=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"]]),Sc=new Map(Array.from(js).map(t=>[t[1],t[0]])),Bn=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??Cn(t,e,100),this.mode=r?.mode??i?.mode??dn(t,e+100,8),this.uid=r?.uid??i?.uid??dn(t,e+108,8),this.gid=r?.gid??i?.gid??dn(t,e+116,8),this.size=r?.size??i?.size??dn(t,e+124,12),this.mtime=r?.mtime??i?.mtime??Fa(t,e+136,12),this.cksum=dn(t,e+148,12),i&&this.#n(i,!0),r&&this.#n(r);let o=Cn(t,e+156,1);if(Rs(o)&&(this.#e=o||"0"),this.#e==="0"&&this.path.slice(-1)==="/"&&(this.#e="5"),this.#e==="5"&&(this.size=0),this.linkpath=Cn(t,e+157,100),t.subarray(e+257,e+265).toString()==="ustar\x0000")if(this.uname=r?.uname??i?.uname??Cn(t,e+265,32),this.gname=r?.gname??i?.gname??Cn(t,e+297,32),this.devmaj=r?.devmaj??i?.devmaj??dn(t,e+329,8)??0,this.devmin=r?.devmin??i?.devmin??dn(t,e+337,8)??0,t[e+475]!==0){let l=Cn(t,e+345,155);this.path=l+"/"+this.path}else{let l=Cn(t,e+345,130);l&&(this.path=l+"/"+this.path),this.atime=r?.atime??i?.atime??Fa(t,e+476,12),this.ctime=r?.ctime??i?.ctime??Fa(t,e+488,12)}let c=256;for(let l=e;l<e+148;l++)c+=t[l];for(let l=e+156;l<e+512;l++)c+=t[l];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=Em(this.path||"",r),o=i[0],c=i[1];this.needPax=!!i[2],this.needPax=Rn(t,e,100,o)||this.needPax,this.needPax=ln(t,e+100,8,this.mode)||this.needPax,this.needPax=ln(t,e+108,8,this.uid)||this.needPax,this.needPax=ln(t,e+116,8,this.gid)||this.needPax,this.needPax=ln(t,e+124,12,this.size)||this.needPax,this.needPax=Ua(t,e+136,12,this.mtime)||this.needPax,t[e+156]=Number(this.#e.codePointAt(0)),this.needPax=Rn(t,e+157,100,this.linkpath)||this.needPax,t.write("ustar\x0000",e+257,8),this.needPax=Rn(t,e+265,32,this.uname)||this.needPax,this.needPax=Rn(t,e+297,32,this.gname)||this.needPax,this.needPax=ln(t,e+329,8,this.devmaj)||this.needPax,this.needPax=ln(t,e+337,8,this.devmin)||this.needPax,this.needPax=Rn(t,e+345,r,c)||this.needPax,t[e+475]!==0?this.needPax=Rn(t,e+345,155,c)||this.needPax:(this.needPax=Rn(t,e+345,130,c)||this.needPax,this.needPax=Ua(t,e+476,12,this.atime)||this.needPax,this.needPax=Ua(t,e+488,12,this.ctime)||this.needPax);let l=256;for(let u=e;u<e+148;u++)l+=t[u];for(let u=e+156;u<e+512;u++)l+=t[u];return this.cksum=l,ln(t,e+148,8,this.cksum),this.cksumValid=!0,this.needPax}get type(){return this.#e==="Unsupported"?this.#e:js.get(this.#e)}get typeKey(){return this.#e}set type(t){let e=String(Sc.get(t));if(Rs(e)||e==="Unsupported")this.#e=e;else if(Rs(t))this.#e=t;else throw new TypeError("invalid entry type: "+t)}},Em=(t,e)=>{let r=t,i="",o,c=or.parse(t).root||".";if(Buffer.byteLength(r)<100)o=[r,i,!1];else{i=or.dirname(r),r=or.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=or.join(or.basename(i),r),i=or.dirname(i));while(i!==c&&o===void 0);o||(o=[t.slice(0,99),"",!0])}return o},Cn=(t,e,r)=>t.subarray(e,e+r).toString("utf8").replace(/\0.*/,""),Fa=(t,e,r)=>vm(dn(t,e,r)),vm=t=>t===void 0?void 0:new Date(t*1e3),dn=(t,e,r)=>Number(t[e])&128?mm(t.subarray(e,e+r)):Im(t,e,r),Sm=t=>isNaN(t)?void 0:t,Im=(t,e,r)=>Sm(parseInt(t.subarray(e,e+r).toString("utf8").replace(/\0.*$/,"").trim(),8)),Am={12:8589934591,8:2097151},ln=(t,e,r,i)=>i===void 0?!1:i>Am[r]||i<0?(hm(i,t.subarray(e,e+r)),!0):(Tm(t,e,r,i),!1),Tm=(t,e,r,i)=>t.write(Cm(i,r),e,r,"ascii"),Cm=(t,e)=>Rm(Math.floor(t).toString(8),e),Rm=(t,e)=>(t.length===e-1?t:new Array(e-t.length-1).join("0")+t+" ")+"\0",Ua=(t,e,r,i)=>i===void 0?!1:ln(t,e,r,i.getTime()/1e3),Dm=new Array(156).join("\0"),Rn=(t,e,r,i)=>i===void 0?!1:(t.write(i+Dm,e,r,"utf8"),i.length!==Buffer.byteLength(i)||i.length>r),zs=class H0{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 Bn({path:("PaxHeader/"+km(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+`
|
|
90
|
-
`,c=Buffer.byteLength(o),l=Math.floor(Math.log(c)/Math.log(10))+1;return c+l>=Math.pow(10,l)&&(l+=1),l+c+o}static parse(e,
|
|
91
|
-
`).reduce(Om,Object.create(null)),Om=(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"),l=i.join("=");return t[c]=/^([A-Z]+\.)?([mac]|birth|creation)time$/.test(c)?new Date(Number(l)*1e3):/^[0-9]+$/.test(l)?+l:l,t},Nm=process.env.TESTING_TAR_FAKE_PLATFORM||process.platform,Z=Nm!=="win32"?t=>t:t=>t&&t.replaceAll(/\\/g,"/"),q0=class extends zn{extended;globalExtended;header;startBlockSize;blockRemain;remain;type;meta=!1;ignore=!1;path;mode;uid;gid;uname;gname;size=0;mtime;atime;ctime;linkpath;dev;ino;nlink;invalid=!1;absolute;unsupported=!1;constructor(t,e,r){switch(super({}),this.pause(),this.extended=e,this.globalExtended=r,this.header=t,this.remain=t.size??0,this.startBlockSize=512*Math.ceil(this.remain/512),this.blockRemain=this.startBlockSize,this.type=t.type,this.type){case"File":case"OldFile":case"Link":case"SymbolicLink":case"CharacterDevice":case"BlockDevice":case"Directory":case"FIFO":case"ContiguousFile":case"GNUDumpDir":break;case"NextFileHasLongLinkpath":case"NextFileHasLongPath":case"OldGnuLongPath":case"GlobalExtendedHeader":case"ExtendedHeader":case"OldExtendedHeader":this.meta=!0;break;default:this.ignore=!0}if(!t.path)throw new Error("no path provided for tar.ReadEntry");this.path=Z(t.path),this.mode=t.mode,this.mode&&(this.mode=this.mode&4095),this.uid=t.uid,this.gid=t.gid,this.uname=t.uname,this.gname=t.gname,this.size=this.remain,this.mtime=t.mtime,this.atime=t.atime,this.ctime=t.ctime,this.linkpath=t.linkpath?Z(t.linkpath):void 0,this.uname=t.uname,this.gname=t.gname,e&&this.#e(e),r&&this.#e(r,!0)}write(t){let e=t.length;if(e>this.blockRemain)throw new Error("writing more to entry than is appropriate");let r=this.remain,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=Z(t.path)),t.linkpath&&(t.linkpath=Z(t.linkpath)),Object.assign(this,Object.fromEntries(Object.entries(t).filter(([r,i])=>!(i==null||r==="path"&&e))))}},Ws=(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))},Mm=1024*1024,nc=Buffer.from([31,139]),rc=Buffer.from([40,181,47,253]),Bm=Math.max(nc.length,rc.length),ot=Symbol("state"),Dn=Symbol("writeEntry"),Ft=Symbol("readEntry"),Ha=Symbol("nextEntry"),i0=Symbol("processEntry"),It=Symbol("extendedHeader"),ri=Symbol("globalExtendedHeader"),rn=Symbol("meta"),s0=Symbol("emitMeta"),fe=Symbol("buffer"),Ut=Symbol("queue"),sn=Symbol("ended"),qa=Symbol("emittedEnd"),kn=Symbol("emit"),Ae=Symbol("unzip"),_s=Symbol("consumeChunk"),ys=Symbol("consumeChunkSub"),Ga=Symbol("consumeBody"),o0=Symbol("consumeMeta"),a0=Symbol("consumeHeader"),ii=Symbol("consuming"),ja=Symbol("bufferConcat"),bs=Symbol("maybeEnd"),ar=Symbol("writing"),on=Symbol("aborted"),Es=Symbol("onDone"),Pn=Symbol("sawValidEntry"),vs=Symbol("sawNullBlock"),Ss=Symbol("sawEOF"),c0=Symbol("closeStream"),zm=()=>!0,yi=class extends rm{file;strict;maxMetaEntrySize;filter;brotli;zstd;writable=!0;readable=!1;[Ut]=[];[fe];[Ft];[Dn];[ot]="begin";[rn]="";[It];[ri];[sn]=!1;[Ae];[on]=!1;[Pn];[vs]=!1;[Ss]=!1;[ar]=!1;[ii]=!1;[qa]=!1;constructor(t={}){super(),this.file=t.file||"",this.on(Es,()=>{(this[ot]==="begin"||this[Pn]===!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||Mm,this.filter=typeof t.filter=="function"?t.filter:zm;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[c0]()),typeof t.onwarn=="function"&&this.on("warn",t.onwarn),typeof t.onReadEntry=="function"&&this.on("entry",t.onReadEntry)}warn(t,e,r={}){Ws(this,t,e,r)}[a0](t,e){this[Pn]===void 0&&(this[Pn]=!1);let r;try{r=new Bn(t,e,this[It],this[ri])}catch(i){return this.warn("TAR_ENTRY_INVALID",i)}if(r.nullBlock)this[vs]?(this[Ss]=!0,this[ot]==="begin"&&(this[ot]="header"),this[kn]("eof")):(this[vs]=!0,this[kn]("nullBlock"));else if(this[vs]=!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[Dn]=new q0(r,this[It],this[ri]);if(!this[Pn])if(o.remain){let c=()=>{o.invalid||(this[Pn]=!0)};o.on("end",c)}else this[Pn]=!0;o.meta?o.size>this.maxMetaEntrySize?(o.ignore=!0,this[kn]("ignoredEntry",o),this[ot]="ignore",o.resume()):o.size>0&&(this[rn]="",o.on("data",c=>this[rn]+=c),this[ot]="meta"):(this[It]=void 0,o.ignore=o.ignore||!this.filter(o.path,o),o.ignore?(this[kn]("ignoredEntry",o),this[ot]=o.remain?"ignore":"header",o.resume()):(o.remain?this[ot]="body":(this[ot]="header",o.end()),this[Ft]?this[Ut].push(o):(this[Ut].push(o),this[Ha]())))}}}[c0](){queueMicrotask(()=>this.emit("close"))}[i0](t){let e=!0;if(!t)this[Ft]=void 0,e=!1;else if(Array.isArray(t)){let[r,...i]=t;this.emit(r,...i)}else this[Ft]=t,this.emit("entry",t),t.emittedEnd||(t.on("end",()=>this[Ha]()),e=!1);return e}[Ha](){do;while(this[i0](this[Ut].shift()));if(this[Ut].length===0){let t=this[Ft];!t||t.flowing||t.size===t.remain?this[ar]||this.emit("drain"):t.once("drain",()=>this.emit("drain"))}}[Ga](t,e){let r=this[Dn];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[ot]="header",this[Dn]=void 0,r.end()),o.length}[o0](t,e){let r=this[Dn],i=this[Ga](t,e);return!this[Dn]&&r&&this[s0](r),i}[kn](t,e,r){this[Ut].length===0&&!this[Ft]?this.emit(t,e,r):this[Ut].push([t,e,r])}[s0](t){switch(this[kn]("meta",this[rn]),t.type){case"ExtendedHeader":case"OldExtendedHeader":this[It]=zs.parse(this[rn],this[It],!1);break;case"GlobalExtendedHeader":this[ri]=zs.parse(this[rn],this[ri],!0);break;case"NextFileHasLongPath":case"OldGnuLongPath":{let e=this[It]??Object.create(null);this[It]=e,e.path=this[rn].replace(/\0.*/,"");break}case"NextFileHasLongLinkpath":{let e=this[It]||Object.create(null);this[It]=e,e.linkpath=this[rn].replace(/\0.*/,"");break}default:throw new Error("unknown meta: "+t.type)}}abort(t){this[on]=!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[on])return r?.(),!1;if((this[Ae]===void 0||this.brotli===void 0&&this[Ae]===!1)&&t){if(this[fe]&&(t=Buffer.concat([this[fe],t]),this[fe]=void 0),t.length<Bm)return this[fe]=t,r?.(),!0;for(let l=0;this[Ae]===void 0&&l<nc.length;l++)t[l]!==nc[l]&&(this[Ae]=!1);let o=!1;if(this[Ae]===!1&&this.zstd!==!1){o=!0;for(let l=0;l<rc.length;l++)if(t[l]!==rc[l]){o=!1;break}}let c=this.brotli===void 0&&!o;if(this[Ae]===!1&&c)if(t.length<512)if(this[sn])this.brotli=!0;else return this[fe]=t,r?.(),!0;else try{new Bn(t.subarray(0,512)),this.brotli=!1}catch{this.brotli=!0}if(this[Ae]===void 0||this[Ae]===!1&&(this.brotli||o)){let l=this[sn];this[sn]=!1,this[Ae]=this[Ae]===void 0?new dm({}):o?new xm({}):new um({}),this[Ae].on("data",x=>this[_s](x)),this[Ae].on("error",x=>this.abort(x)),this[Ae].on("end",()=>{this[sn]=!0,this[_s]()}),this[ar]=!0;let u=!!this[Ae][l?"end":"write"](t);return this[ar]=!1,r?.(),u}}this[ar]=!0,this[Ae]?this[Ae].write(t):this[_s](t),this[ar]=!1;let i=this[Ut].length>0?!1:this[Ft]?this[Ft].flowing:!0;return!i&&this[Ut].length===0&&this[Ft]?.once("drain",()=>this.emit("drain")),r?.(),i}[ja](t){t&&!this[on]&&(this[fe]=this[fe]?Buffer.concat([this[fe],t]):t)}[bs](){if(this[sn]&&!this[qa]&&!this[on]&&!this[ii]){this[qa]=!0;let t=this[Dn];if(t&&t.blockRemain){let e=this[fe]?this[fe].length:0;this.warn("TAR_BAD_ARCHIVE",`Truncated input (needed ${t.blockRemain} more bytes, only ${e} available)`,{entry:t}),this[fe]&&t.write(this[fe]),t.end()}this[kn](Es)}}[_s](t){if(this[ii]&&t)this[ja](t);else if(!t&&!this[fe])this[bs]();else if(t){if(this[ii]=!0,this[fe]){this[ja](t);let e=this[fe];this[fe]=void 0,this[ys](e)}else this[ys](t);for(;this[fe]&&this[fe]?.length>=512&&!this[on]&&!this[Ss];){let e=this[fe];this[fe]=void 0,this[ys](e)}this[ii]=!1}(!this[fe]||this[sn])&&this[bs]()}[ys](t){let e=0,r=t.length;for(;e+512<=r&&!this[on]&&!this[Ss];)switch(this[ot]){case"begin":case"header":this[a0](t,e),e+=512;break;case"ignore":case"body":e+=this[Ga](t,e);break;case"meta":e+=this[o0](t,e);break;default:throw new Error("invalid state: "+this[ot])}e<r&&(this[fe]=this[fe]?Buffer.concat([t.subarray(e),this[fe]]):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[on]||(this[Ae]?(t&&this[Ae].write(t),this[Ae].end()):(this[sn]=!0,(this.brotli===void 0||this.zstd===void 0)&&(t=t||Buffer.alloc(0)),t&&this.write(t),this[bs]())),this}},xi=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)},Fm=t=>{let e=t.onReadEntry;t.onReadEntry=e?r=>{e(r),r.resume()}:r=>r.resume()},G0=(t,e)=>{let r=new Map(e.map(c=>[xi(c),!0])),i=t.filter,o=(c,l="")=>{let u=l||Vg(c).root||".",x;if(c===u)x=!1;else{let p=r.get(c);x=p!==void 0?p:o(Jg(c),u)}return r.set(c,x),x};t.filter=i?(c,l)=>i(c,l)&&o(xi(c)):c=>o(xi(c))},Um=t=>{let e=new yi(t),r=t.file,i;try{i=xr.openSync(r,"r");let o=xr.fstatSync(i),c=t.maxReadSize||16*1024*1024;if(o.size<c){let l=Buffer.allocUnsafe(o.size),u=xr.readSync(i,l,0,o.size,0);e.end(u===l.byteLength?l:l.subarray(0,u))}else{let l=0,u=Buffer.allocUnsafe(c);for(;l<o.size;){let x=xr.readSync(i,u,0,c,l);if(x===0)break;l+=x,e.write(u.subarray(0,x))}e.end()}}finally{if(typeof i=="number")try{xr.closeSync(i)}catch{}}},Hm=(t,e)=>{let r=new yi(t),i=t.maxReadSize||16*1024*1024,o=t.file;return new Promise((c,l)=>{r.on("error",l),r.on("end",c),xr.stat(o,(u,x)=>{if(u)l(u);else{let p=new bc(o,{readSize:i,size:x.size});p.on("error",l),p.pipe(r)}})})},mr=bi(Um,Hm,t=>new yi(t),t=>new yi(t),(t,e)=>{e?.length&&G0(t,e),t.noResume||Fm(t)}),j0=(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:Gm,parse:l0}=qm,Ic=t=>{let e="",r=l0(t);for(;Gm(t)||r.root;){let i=t.charAt(0)==="/"&&t.slice(0,4)!=="//?/"?"/":r.root;t=t.slice(i.length),e+=i,r=l0(t)}return[e,t]},Ks=["|","<",">","?",":"],Ac=Ks.map(t=>String.fromCodePoint(61440+Number(t.codePointAt(0)))),jm=new Map(Ks.map((t,e)=>[t,Ac[e]])),Wm=new Map(Ac.map((t,e)=>[t,Ks[e]])),u0=t=>Ks.reduce((e,r)=>e.split(r).join(jm.get(r)),t),Km=t=>Ac.reduce((e,r)=>e.split(r).join(Wm.get(r)),t),W0=(t,e)=>e?(t=Z(t).replace(/^\.(\/|$)/,""),xi(e)+"/"+t):Z(t),$m=16*1024*1024,f0=Symbol("process"),x0=Symbol("file"),h0=Symbol("directory"),ic=Symbol("symlink"),p0=Symbol("hardlink"),si=Symbol("header"),Ds=Symbol("read"),sc=Symbol("lstat"),ks=Symbol("onlstat"),oc=Symbol("onread"),ac=Symbol("onreadlink"),cc=Symbol("openfile"),dc=Symbol("onopenfile"),un=Symbol("close"),Us=Symbol("mode"),lc=Symbol("awaitDrain"),Wa=Symbol("ondrain"),Tt=Symbol("prefix"),K0=class extends zn{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=Ec(e);super(),this.path=Z(t),this.portable=!!r.portable,this.maxReadSize=r.maxReadSize||$m,this.linkCache=r.linkCache||new Map,this.statCache=r.statCache||new Map,this.preservePaths=!!r.preservePaths,this.cwd=Z(r.cwd||process.cwd()),this.strict=!!r.strict,this.noPax=!!r.noPax,this.noMtime=!!r.noMtime,this.mtime=r.mtime,this.prefix=r.prefix?Z(r.prefix):void 0,this.onWriteEntry=r.onWriteEntry,typeof r.onwarn=="function"&&this.on("warn",r.onwarn);let i=!1;if(!this.preservePaths){let[c,l]=Ic(this.path);c&&typeof l=="string"&&(this.path=l,i=c)}this.win32=!!r.win32||process.platform==="win32",this.win32&&(this.path=Km(this.path.replaceAll(/\\/g,"/")),t=t.replaceAll(/\\/g,"/")),this.absolute=Z(r.absolute||d0.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[ks](o):this[sc]()}warn(t,e,r={}){return Ws(this,t,e,r)}emit(t,...e){return t==="error"&&(this.#e=!0),super.emit(t,...e)}[sc](){At.lstat(this.absolute,(t,e)=>{if(t)return this.emit("error",t);this[ks](e)})}[ks](t){this.statCache.set(this.absolute,t),this.stat=t,t.isFile()||(t.size=0),this.type=Ym(t),this.emit("stat",t),this[f0]()}[f0](){switch(this.type){case"File":return this[x0]();case"Directory":return this[h0]();case"SymbolicLink":return this[ic]();default:return this.end()}}[Us](t){return j0(t,this.type==="Directory",this.portable)}[Tt](t){return W0(t,this.prefix)}[si](){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 Bn({path:this[Tt](this.path),linkpath:this.type==="Link"&&this.linkpath!==void 0?this[Tt](this.linkpath):this.linkpath,mode:this[Us](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 zs({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[Tt](this.path),linkpath:this.type==="Link"&&this.linkpath!==void 0?this[Tt](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)}[h0](){if(!this.stat)throw new Error("cannot create directory entry without stat");this.path.slice(-1)!=="/"&&(this.path+="/"),this.stat.size=0,this[si](),this.end()}[ic](){At.readlink(this.absolute,(t,e)=>{if(t)return this.emit("error",t);this[ac](e)})}[ac](t){this.linkpath=Z(t),this[si](),this.end()}[p0](t){if(!this.stat)throw new Error("cannot create link entry without stat");this.type="Link",this.linkpath=Z(d0.relative(this.cwd,t)),this.stat.size=0,this[si](),this.end()}[x0](){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[p0](e);this.linkCache.set(t,this.absolute)}if(this[si](),this.stat.size===0)return this.end();this[cc]()}[cc](){At.open(this.absolute,"r",(t,e)=>{if(t)return this.emit("error",t);this[dc](e)})}[dc](t){if(this.fd=t,this.#e)return this[un]();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:i,pos:o}=this;if(t===void 0||e===void 0)throw new Error("cannot read file without first opening");At.read(t,e,r,i,o,(c,l)=>{if(c)return this[un](()=>this.emit("error",c));this[oc](l)})}[un](t=()=>{}){this.fd!==void 0&&At.close(this.fd,t)}[oc](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[un](()=>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[un](()=>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[Wa]():this[lc](()=>this[Wa]())}[lc](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)}[Wa](){if(!this.remain)return this.blockRemain&&super.write(Buffer.alloc(this.blockRemain)),this[un](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]()}},Jm=class extends K0{sync=!0;[sc](){this[ks](At.lstatSync(this.absolute))}[ic](){this[ac](At.readlinkSync(this.absolute))}[cc](){this[dc](At.openSync(this.absolute,"r"))}[Ds](){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 l=At.readSync(e,r,i,o,c);this[oc](l),t=!1}finally{if(t)try{this[un](()=>{})}catch{}}}[lc](t){t()}[un](t=()=>{}){this.fd!==void 0&&At.closeSync(this.fd),t()}},Vm=class extends zn{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 Ws(this,t,e,r)}constructor(t,e={}){let r=Ec(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=Z(t.path),this.mode=t.mode!==void 0?this[Us](t.mode):void 0,this.uid=this.portable?void 0:t.uid,this.gid=this.portable?void 0:t.gid,this.uname=this.portable?void 0:t.uname,this.gname=this.portable?void 0:t.gname,this.size=t.size,this.mtime=this.noMtime?void 0:r.mtime||t.mtime,this.atime=this.portable?void 0:t.atime,this.ctime=this.portable?void 0:t.ctime,this.linkpath=t.linkpath!==void 0?Z(t.linkpath):void 0,typeof r.onwarn=="function"&&this.on("warn",r.onwarn);let o=!1;if(!this.preservePaths){let[l,u]=Ic(this.path);l&&typeof u=="string"&&(this.path=u,o=l)}this.remain=t.size,this.blockRemain=t.startBlockSize,this.onWriteEntry?.(this),this.header=new Bn({path:this[Tt](this.path),linkpath:this.type==="Link"&&this.linkpath!==void 0?this[Tt](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 zs({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[Tt](this.path),linkpath:this.type==="Link"&&this.linkpath!==void 0?this[Tt](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)}[Tt](t){return W0(t,this.prefix)}[Us](t){return j0(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}},Ym=t=>t.isFile()?"File":t.isDirectory()?"Directory":t.isSymbolicLink()?"SymbolicLink":"Unsupported",Zm=class hr{tail;head;length=0;static create(e=[]){return new hr(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++)Qm(this,e[r]);return this.length}unshift(...e){for(var r=0,i=e.length;r<i;r++)ew(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 hr;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 hr;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 hr;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 hr;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 l=0;o&&l<e;l++)o=o.next;let c=[];for(let l=0;o&&l<r;l++)c.push(o.value),o=this.removeNode(o);o?o!==this.tail&&(o=o.prev):o=this.tail;for(let l of i)o=Xm(this,o,l);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 Xm(t,e,r){let i=e,o=e?e.next:t.head,c=new Tc(r,i,o,t);return c.next===void 0&&(t.tail=c),c.prev===void 0&&(t.head=c),t.length++,c}function Qm(t,e){t.tail=new Tc(e,t.tail,void 0,t),t.head||(t.head=t.tail),t.length++}function ew(t,e){t.head=new Tc(e,void 0,t.head,t),t.tail||(t.tail=t.head),t.length++}var Tc=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}},m0=class{path;absolute;entry;stat;readdir;pending=!1;pendingLink=!1;ignore=!1;piped=!1;constructor(t,e){this.path=t||"./",this.absolute=e}},w0=Buffer.alloc(1024),Ps=Symbol("onStat"),oi=Symbol("ended"),ht=Symbol("queue"),ai=Symbol("queue"),an=Symbol("current"),Ln=Symbol("process"),ci=Symbol("processing"),Is=Symbol("processJob"),pt=Symbol("jobs"),Ka=Symbol("jobDone"),Ls=Symbol("addFSEntry"),_0=Symbol("addTarEntry"),uc=Symbol("stat"),fc=Symbol("readdir"),Os=Symbol("onreaddir"),Ns=Symbol("pipe"),y0=Symbol("entry"),$a=Symbol("entryOpt"),Ms=Symbol("writeEntryClass"),$0=Symbol("write"),Ja=Symbol("ondrain"),$s=class extends zn{sync=!1;opt;cwd;maxReadSize;preservePaths;strict;noPax;prefix;linkCache;statCache;file;portable;zip;readdirCache;noDirRecurse;follow;noMtime;mtime;filter;jobs;[Ms];onWriteEntry;[ht];[ai]=new Map;[pt]=0;[ci]=!1;[oi]=!1;constructor(t={}){if(super(),this.opt=t,this.file=t.file||"",this.cwd=t.cwd||process.cwd(),this.maxReadSize=t.maxReadSize,this.preservePaths=!!t.preservePaths,this.strict=!!t.strict,this.noPax=!!t.noPax,this.prefix=Z(t.prefix||""),this.linkCache=t.linkCache||new Map,this.statCache=t.statCache||new Map,this.readdirCache=t.readdirCache||new Map,this.onWriteEntry=t.onWriteEntry,this[Ms]=K0,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 cm(t.gzip)),t.brotli&&(typeof t.brotli!="object"&&(t.brotli={}),this.zip=new lm(t.brotli)),t.zstd&&(typeof t.zstd!="object"&&(t.zstd={}),this.zip=new fm(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[Ja]()),this.on("resume",()=>e.resume())}else this.on("drain",this[Ja]);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[ht]=new Zm,this[pt]=0,this.jobs=Number(t.jobs)||4,this[ci]=!1,this[oi]=!1}[$0](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[oi]=!0,this[Ln](),r&&r(),this}write(t){if(this[oi])throw new Error("write after end");return t instanceof q0?this[_0](t):this[Ls](t),this.flowing}[_0](t){let e=Z(g0.resolve(this.cwd,t.path));if(!this.filter(t.path,t))t.resume();else{let r=new m0(t.path,e);r.entry=new Vm(t,this[$a](r)),r.entry.on("end",()=>this[Ka](r)),this[pt]+=1,this[ht].push(r)}this[Ln]()}[Ls](t){let e=Z(g0.resolve(this.cwd,t));this[ht].push(new m0(t,e)),this[Ln]()}[uc](t){t.pending=!0,this[pt]+=1;let e=this.follow?"stat":"lstat";Fs[e](t.absolute,(r,i)=>{t.pending=!1,this[pt]-=1,r?this.emit("error",r):this[Ps](t,i)})}[Ps](t,e){if(this.statCache.set(t.absolute,e),t.stat=e,!this.filter(t.path,e))t.ignore=!0;else if(e.isFile()&&e.nlink>1&&!this.linkCache.get(`${e.dev}:${e.ino}`)&&!this.sync)if(t===this[an])this[Is](t);else{let r=`${e.dev}:${e.ino}`,i=this[ai].get(r);i?i.push(t):this[ai].set(r,[t]),t.pendingLink=!0,t.pending=!0}this[Ln]()}[fc](t){t.pending=!0,this[pt]+=1,Fs.readdir(t.absolute,(e,r)=>{if(t.pending=!1,this[pt]-=1,e)return this.emit("error",e);this[Os](t,r)})}[Os](t,e){this.readdirCache.set(t.absolute,e),t.readdir=e,this[Ln]()}[Ln](){if(!this[ci]){this[ci]=!0;for(let t=this[ht].head;t&&this[pt]<this.jobs;t=t.next)if(this[Is](t.value),t.value.ignore){let e=t.next;this[ht].removeNode(t),t.next=e}this[ci]=!1,this[oi]&&this[ht].length===0&&this[pt]===0&&(this.zip?this.zip.end(w0):(super.write(w0),super.end()))}}get[an](){return this[ht]&&this[ht].head&&this[ht].head.value}[Ka](t){this[ht].shift(),this[pt]-=1;let{stat:e}=t;if(e&&e.isFile()&&e.nlink>1){let r=`${e.dev}:${e.ino}`,i=this[ai].get(r);if(i){this[ai].delete(r);for(let o of i)o.pending=!1,this[Is](o)}}this[Ln]()}[Is](t){if(t.pending&&t.pendingLink&&t===this[an]&&(t.pending=!1,t.pendingLink=!1),!t.pending){if(t.entry){t===this[an]&&!t.piped&&this[Ns](t);return}if(!t.stat){let e=this.statCache.get(t.absolute);e?this[Ps](t,e):this[uc](t)}if(t.stat&&!t.ignore){if(!this.noDirRecurse&&t.stat.isDirectory()&&!t.readdir){let e=this.readdirCache.get(t.absolute);if(e?this[Os](t,e):this[fc](t),!t.readdir)return}if(t.entry=this[y0](t),!t.entry){t.ignore=!0;return}t===this[an]&&!t.piped&&this[Ns](t)}}}[$a](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}}[y0](t){this[pt]+=1;try{return new this[Ms](t.path,this[$a](t)).on("end",()=>this[Ka](t)).on("error",e=>this.emit("error",e))}catch(e){this.emit("error",e)}}[Ja](){this[an]&&this[an].entry&&this[an].entry.resume()}[Ns](t){t.piped=!0,t.readdir&&t.readdir.forEach(i=>{let o=t.path,c=o==="./"?"":o.replace(/\/*$/,"/");this[Ls](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={}){Ws(this,t,e,r)}},Cc=class extends $s{sync=!0;constructor(t){super(t),this[Ms]=Jm}pause(){}resume(){}[uc](t){let e=this.follow?"statSync":"lstatSync";this[Ps](t,Fs[e](t.absolute))}[fc](t){this[Os](t,Fs.readdirSync(t.absolute))}[Ns](t){let e=t.entry,r=this.zip;if(t.readdir&&t.readdir.forEach(i=>{let o=t.path,c=o==="./"?"":o.replace(/\/*$/,"/");this[Ls](c+i)}),!e)throw new Error("Cannot pipe without source");r?e.on("data",i=>{r.write(i)}):e.on("data",i=>{super[$0](i)})}},tw=(t,e)=>{let r=new Cc(t),i=new O0(t.file,{mode:t.mode||438});r.pipe(i),J0(r,e)},nw=(t,e)=>{let r=new $s(t),i=new Gs(t.file,{mode:t.mode||438});r.pipe(i);let o=new Promise((c,l)=>{i.on("error",l),i.on("close",c),r.on("error",l)});return V0(r,e).catch(c=>r.emit("error",c)),o},J0=(t,e)=>{e.forEach(r=>{r.charAt(0)==="@"?mr({file:N0.resolve(t.cwd,r.slice(1)),sync:!0,noResume:!0,onReadEntry:i=>t.add(i)}):t.add(r)}),t.end()},V0=async(t,e)=>{for(let r of e)r.charAt(0)==="@"?await mr({file:N0.resolve(String(t.cwd),r.slice(1)),noResume:!0,onReadEntry:i=>{t.add(i)}}):t.add(r);t.end()},rw=(t,e)=>{let r=new Cc(t);return J0(r,e),r},iw=(t,e)=>{let r=new $s(t);return V0(r,e).catch(i=>r.emit("error",i)),r},c1=bi(tw,nw,rw,iw,(t,e)=>{if(!e?.length)throw new TypeError("no paths specified to add to archive")}),ow=process.env.__FAKE_PLATFORM__||process.platform,Q0=ow==="win32",{O_CREAT:eu,O_NOFOLLOW:b0,O_TRUNC:tu,O_WRONLY:nu}=X0.constants,ru=Number(process.env.__FAKE_FS_O_FILENAME__)||X0.constants.UV_FS_O_FILEMAP||0,aw=Q0&&!!ru,cw=512*1024,dw=ru|tu|eu|nu,E0=!Q0&&typeof b0=="number"?b0|tu|eu|nu:null,iu=E0!==null?()=>E0:aw?t=>t<cw?dw:"w":()=>"w",xc=(t,e,r)=>{try{return Js.lchownSync(t,e,r)}catch(i){if(i?.code!=="ENOENT")throw i}},Hs=(t,e,r,i)=>{Js.lchown(t,e,r,o=>{i(o&&o?.code!=="ENOENT"?o:null)})},lw=(t,e,r,i,o)=>{if(e.isDirectory())su(hi.resolve(t,e.name),r,i,c=>{if(c)return o(c);let l=hi.resolve(t,e.name);Hs(l,r,i,o)});else{let c=hi.resolve(t,e.name);Hs(c,r,i,o)}},su=(t,e,r,i)=>{Js.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 Hs(t,e,r,i);let l=c.length,u=null,x=p=>{if(!u){if(p)return i(u=p);if(--l===0)return Hs(t,e,r,i)}};for(let p of c)lw(t,p,e,r,x)})},uw=(t,e,r,i)=>{e.isDirectory()&&ou(hi.resolve(t,e.name),r,i),xc(hi.resolve(t,e.name),r,i)},ou=(t,e,r)=>{let i;try{i=Js.readdirSync(t,{withFileTypes:!0})}catch(o){let c=o;if(c?.code==="ENOENT")return;if(c?.code==="ENOTDIR"||c?.code==="ENOTSUP")return xc(t,e,r);throw c}for(let o of i)uw(t,o,e,r);return xc(t,e,r)},au=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"}},Vs=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"}},xw=(t,e)=>{rt.stat(t,(r,i)=>{(r||!i.isDirectory())&&(r=new au(t,r?.code||"ENOTDIR")),e(r)})},hw=(t,e,r)=>{t=Z(t);let i=e.umask??18,o=e.mode|448,c=(o&i)!==0,l=e.uid,u=e.gid,x=typeof l=="number"&&typeof u=="number"&&(l!==e.processUid||u!==e.processGid),p=e.preserve,m=e.unlink,b=Z(e.cwd),I=(E,S)=>{E?r(E):S&&x?su(S,l,u,A=>I(A)):c?rt.chmod(t,o,r):r()};if(t===b)return xw(t,I);if(p)return fw.mkdir(t,{mode:o,recursive:!0}).then(E=>I(null,E??void 0),I);let y=Z(qs.relative(b,t)).split("/");hc(b,y,o,m,b,void 0,I)},hc=(t,e,r,i,o,c,l)=>{if(e.length===0)return l(null,c);let u=e.shift(),x=Z(qs.resolve(t+"/"+u));rt.mkdir(x,r,cu(x,e,r,i,o,c,l))},cu=(t,e,r,i,o,c,l)=>u=>{u?rt.lstat(t,(x,p)=>{if(x)x.path=x.path&&Z(x.path),l(x);else if(p.isDirectory())hc(t,e,r,i,o,c,l);else if(i)rt.unlink(t,m=>{if(m)return l(m);rt.mkdir(t,r,cu(t,e,r,i,o,c,l))});else{if(p.isSymbolicLink())return l(new Vs(t,t+"/"+e.join("/")));l(u)}}):(c=c||t,hc(t,e,r,i,o,c,l))},pw=t=>{let e=!1,r;try{e=rt.statSync(t).isDirectory()}catch(i){r=i?.code}finally{if(!e)throw new au(t,r??"ENOTDIR")}},gw=(t,e)=>{t=Z(t);let r=e.umask??18,i=e.mode|448,o=(i&r)!==0,c=e.uid,l=e.gid,u=typeof c=="number"&&typeof l=="number"&&(c!==e.processUid||l!==e.processGid),x=e.preserve,p=e.unlink,m=Z(e.cwd),b=E=>{E&&u&&ou(E,c,l),o&&rt.chmodSync(t,i)};if(t===m)return pw(m),b();if(x)return b(rt.mkdirSync(t,{mode:i,recursive:!0})??void 0);let I=Z(qs.relative(m,t)).split("/"),y;for(let E=I.shift(),S=m;E&&(S+="/"+E);E=I.shift()){S=Z(qs.resolve(S));try{rt.mkdirSync(S,i),y=y||S}catch{let A=rt.lstatSync(S);if(A.isDirectory())continue;if(p){rt.unlinkSync(S),rt.mkdirSync(S,i),y=y||S;continue}else if(A.isSymbolicLink())return new Vs(S,S+"/"+I.join("/"))}}return b(y)},Va=Object.create(null),v0=1e4,cr=new Set,mw=t=>{cr.has(t)?cr.delete(t):Va[t]=t.normalize("NFD").toLocaleLowerCase("en").toLocaleUpperCase("en"),cr.add(t);let e=Va[t],r=cr.size-v0;if(r>v0/10){for(let i of cr)if(cr.delete(i),delete Va[i],--r<=0)break}return e},ww=process.env.TESTING_TAR_FAKE_PLATFORM||process.platform,_w=ww==="win32",yw=t=>t.split("/").slice(0,-1).reduce((e,r)=>{let i=e.at(-1);return i!==void 0&&(r=du(i,r)),e.push(r||"/"),e},[]),bw=class{#e=new Map;#n=new Map;#r=new Set;reserve(t,e){t=_w?["win32 parallelization disabled"]:t.map(i=>xi(du(mw(i))));let r=new Set(t.map(i=>yw(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 l=this.#e.get(c);if(!l||l?.[0]!==t)continue;let u=l[1];if(!u){this.#e.delete(c);continue}if(l.shift(),typeof u=="function")o.add(u);else for(let x of u)o.add(x)}for(let c of i){let l=this.#e.get(c),u=l?.[0];if(!(!l||!(u instanceof Set)))if(u.size===1&&l.length===1){this.#e.delete(c);continue}else if(u.size===1){l.shift();let x=l[0];typeof x=="function"&&o.add(x)}else u.delete(t)}return this.#r.delete(t),o.forEach(c=>this.#i(c)),!0}},Ew=()=>process.umask(),S0=Symbol("onEntry"),pc=Symbol("checkFs"),I0=Symbol("checkFs2"),gc=Symbol("isReusable"),at=Symbol("makeFs"),mc=Symbol("file"),wc=Symbol("directory"),Bs=Symbol("link"),A0=Symbol("symlink"),T0=Symbol("hardlink"),ui=Symbol("ensureNoSymlink"),C0=Symbol("unsupported"),R0=Symbol("checkPath"),Ya=Symbol("stripAbsolutePath"),fn=Symbol("mkdir"),Fe=Symbol("onError"),As=Symbol("pending"),D0=Symbol("pend"),dr=Symbol("unpend"),Za=Symbol("ended"),Xa=Symbol("maybeClose"),_c=Symbol("skip"),pi=Symbol("doChown"),gi=Symbol("uid"),mi=Symbol("gid"),wi=Symbol("checkedCwd"),vw=process.env.TESTING_TAR_FAKE_PLATFORM||process.platform,_i=vw==="win32",Sw=1024,Iw=(t,e)=>{if(!_i)return re.unlink(t,e);let r=t+".DELETE."+Z0(16).toString("hex");re.rename(t,r,i=>{if(i)return e(i);re.unlink(r,e)})},Aw=t=>{if(!_i)return re.unlinkSync(t);let e=t+".DELETE."+Z0(16).toString("hex");re.renameSync(t,e),re.unlinkSync(e)},k0=(t,e,r)=>t!==void 0&&t===t>>>0?t:e!==void 0&&e===e>>>0?e:r,Rc=class extends yi{[Za]=!1;[wi]=!1;[As]=0;reservations=new bw;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[Za]=!0,this[Xa]()},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:Sw,this.forceChown=t.forceChown===!0,this.win32=!!t.win32||_i,this.newer=!!t.newer,this.keep=!!t.keep,this.noMtime=!!t.noMtime,this.preservePaths=!!t.preservePaths,this.unlink=!!t.unlink,this.cwd=Z(Pe.resolve(t.cwd||process.cwd())),this.strip=Number(t.strip)||0,this.processUmask=this.chmod?typeof t.processUmask=="number"?t.processUmask:Ew():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[S0](e))}warn(t,e,r={}){return(t==="TAR_BAD_ARCHIVE"||t==="TAR_ABORT")&&(r.recoverable=!1),super.warn(t,e,r)}[Xa](){this[Za]&&this[As]===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]=Ic(r),l=c.replaceAll(/\\/g,"/").split("/");if(l.includes("..")||_i&&/^[a-z]:\.\.$/i.test(l[0]??"")){if(e==="path"||i==="Link")return this.warn("TAR_ENTRY_ERROR",`${e} contains '..'`,{entry:t,[e]:r}),!1;let u=Pe.posix.dirname(t.path),x=Pe.posix.normalize(Pe.posix.join(u,l.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}[R0](t){let e=Z(t.path),r=e.split("/");if(this.strip){if(r.length<this.strip)return!1;if(t.type==="Link"){let i=Z(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=Pe.isAbsolute(t.path)?Z(Pe.resolve(t.path)):Z(Pe.resolve(this.cwd,t.path)),!this.preservePaths&&typeof t.absolute=="string"&&t.absolute.indexOf(this.cwd+"/")!==0&&t.absolute!==this.cwd)return this.warn("TAR_ENTRY_ERROR","path escaped extraction target",{entry:t,path:Z(t.path),resolvedPath:t.absolute,cwd:this.cwd}),!1;if(t.absolute===this.cwd&&t.type!=="Directory"&&t.type!=="GNUDumpDir")return!1;if(this.win32){let{root:i}=Pe.win32.parse(String(t.absolute));t.absolute=i+u0(String(t.absolute).slice(i.length));let{root:o}=Pe.win32.parse(t.path);t.path=o+u0(t.path.slice(o.length))}return!0}[S0](t){if(!this[R0](t))return t.resume();switch(sw.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[pc](t);default:return this[C0](t)}}[Fe](t,e){t.name==="CwdError"?this.emit("error",t):(this.warn("TAR_ENTRY_ERROR",t,{entry:e}),this[dr](),e.resume())}[fn](t,e,r){hw(Z(t),{uid:this.uid,gid:this.gid,processUid:this.processUid,processGid:this.processGid,umask:this.processUmask,preserve:this.preservePaths,unlink:this.unlink,cwd:this.cwd,mode:e},r)}[pi](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}[gi](t){return k0(this.uid,t.uid,this.processUid)}[mi](t){return k0(this.gid,t.gid,this.processGid)}[mc](t,e){let r=typeof t.mode=="number"?t.mode&4095:this.fmode,i=new Gs(String(t.absolute),{flags:iu(t.size),mode:r,autoClose:!1});i.on("error",u=>{i.fd&&re.close(i.fd,()=>{}),i.write=()=>!0,this[Fe](u,t),e()});let o=1,c=u=>{if(u){i.fd&&re.close(i.fd,()=>{}),this[Fe](u,t),e();return}--o===0&&i.fd!==void 0&&re.close(i.fd,x=>{x?this[Fe](x,t):this[dr](),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,m=t.mtime;re.futimes(x,p,m,b=>b?re.utimes(u,p,m,I=>c(I&&b)):c())}if(typeof x=="number"&&this[pi](t)){o++;let p=this[gi](t),m=this[mi](t);typeof p=="number"&&typeof m=="number"&&re.fchown(x,p,m,b=>b?re.chown(u,p,m,I=>c(I&&b)):c())}c()});let l=this.transform&&this.transform(t)||t;l!==t&&(l.on("error",u=>{this[Fe](u,t),e()}),t.pipe(l)),l.pipe(i)}[wc](t,e){let r=typeof t.mode=="number"?t.mode&4095:this.dmode;this[fn](String(t.absolute),r,i=>{if(i){this[Fe](i,t),e();return}let o=1,c=()=>{--o===0&&(e(),this[dr](),t.resume())};t.mtime&&!this.noMtime&&(o++,re.utimes(String(t.absolute),t.atime||new Date,t.mtime,c)),this[pi](t)&&(o++,re.chown(String(t.absolute),Number(this[gi](t)),Number(this[mi](t)),c)),c()})}[C0](t){t.unsupported=!0,this.warn("TAR_ENTRY_UNSUPPORTED",`unsupported entry type: ${t.type}`,{entry:t}),t.resume()}[A0](t,e){let r=Z(Pe.relative(this.cwd,Pe.resolve(Pe.dirname(String(t.absolute)),String(t.linkpath)))).split("/");this[ui](t,this.cwd,r,()=>this[Bs](t,String(t.linkpath),"symlink",e),i=>{this[Fe](i,t),e()})}[T0](t,e){let r=Z(Pe.resolve(this.cwd,String(t.linkpath))),i=Z(String(t.linkpath)).split("/");this[ui](t,this.cwd,i,()=>this[Bs](t,r,"link",e),o=>{this[Fe](o,t),e()})}[ui](t,e,r,i,o){let c=r.shift();if(this.preservePaths||c===void 0)return i();let l=Pe.resolve(e,c);re.lstat(l,(u,x)=>{if(u)return i();if(x?.isSymbolicLink())return o(new Vs(l,Pe.resolve(l,r.join("/"))));this[ui](t,l,r,i,o)})}[D0](){this[As]++}[dr](){this[As]--,this[Xa]()}[_c](t){this[dr](),t.resume()}[gc](t,e){return t.type==="File"&&!this.unlink&&e.isFile()&&e.nlink<=1&&!_i}[pc](t){this[D0]();let e=[t.path];t.linkpath&&e.push(t.linkpath),this.reservations.reserve(e,r=>this[I0](t,r))}[I0](t,e){let r=l=>{e(l)},i=()=>{this[fn](this.cwd,this.dmode,l=>{if(l){this[Fe](l,t),r();return}this[wi]=!0,o()})},o=()=>{if(t.absolute!==this.cwd){let l=Z(Pe.dirname(String(t.absolute)));if(l!==this.cwd)return this[fn](l,this.dmode,u=>{if(u){this[Fe](u,t),r();return}c()})}c()},c=()=>{re.lstat(String(t.absolute),(l,u)=>{if(u&&(this.keep||this.newer&&u.mtime>(t.mtime??u.mtime))){this[_c](t),r();return}if(l||this[gc](t,u))return this[at](null,t,r);if(u.isDirectory()){if(t.type==="Directory"){let x=this.chmod&&t.mode&&(u.mode&4095)!==t.mode,p=m=>this[at](m??null,t,r);return x?re.chmod(String(t.absolute),Number(t.mode),p):p()}if(t.absolute!==this.cwd)return re.rmdir(String(t.absolute),x=>this[at](x??null,t,r))}if(t.absolute===this.cwd)return this[at](null,t,r);Iw(String(t.absolute),x=>this[at](x??null,t,r))})};this[wi]?o():i()}[at](t,e,r){if(t){this[Fe](t,e),r();return}switch(e.type){case"File":case"OldFile":case"ContiguousFile":return this[mc](e,r);case"Link":return this[T0](e,r);case"SymbolicLink":return this[A0](e,r);case"Directory":case"GNUDumpDir":return this[wc](e,r)}}[Bs](t,e,r,i){re[r](e,String(t.absolute),o=>{o?this[Fe](o,t):(this[dr](),t.resume()),i()})}},di=t=>{try{return[null,t()]}catch(e){return[e,null]}},lu=class extends Rc{sync=!0;[at](t,e){return super[at](t,e,()=>{})}[pc](t){if(!this[wi]){let o=this[fn](this.cwd,this.dmode);if(o)return this[Fe](o,t);this[wi]=!0}if(t.absolute!==this.cwd){let o=Z(Pe.dirname(String(t.absolute)));if(o!==this.cwd){let c=this[fn](o,this.dmode);if(c)return this[Fe](c,t)}}let[e,r]=di(()=>re.lstatSync(String(t.absolute)));if(r&&(this.keep||this.newer&&r.mtime>(t.mtime??r.mtime)))return this[_c](t);if(e||this[gc](t,r))return this[at](null,t);if(r.isDirectory()){if(t.type==="Directory"){let c=this.chmod&&t.mode&&(r.mode&4095)!==t.mode,[l]=c?di(()=>{re.chmodSync(String(t.absolute),Number(t.mode))}):[];return this[at](l,t)}let[o]=di(()=>re.rmdirSync(String(t.absolute)));this[at](o,t)}let[i]=t.absolute===this.cwd?[]:di(()=>Aw(String(t.absolute)));this[at](i,t)}[mc](t,e){let r=typeof t.mode=="number"?t.mode&4095:this.fmode,i=l=>{let u;try{re.closeSync(o)}catch(x){u=x}(l||u)&&this[Fe](l||u,t),e()},o;try{o=re.openSync(String(t.absolute),iu(t.size),r)}catch(l){return i(l)}let c=this.transform&&this.transform(t)||t;c!==t&&(c.on("error",l=>this[Fe](l,t)),t.pipe(c)),c.on("data",l=>{try{re.writeSync(o,l,0,l.length)}catch(u){i(u)}}),c.on("end",()=>{let l=null;if(t.mtime&&!this.noMtime){let u=t.atime||new Date,x=t.mtime;try{re.futimesSync(o,u,x)}catch(p){try{re.utimesSync(String(t.absolute),u,x)}catch{l=p}}}if(this[pi](t)){let u=this[gi](t),x=this[mi](t);try{re.fchownSync(o,Number(u),Number(x))}catch(p){try{re.chownSync(String(t.absolute),Number(u),Number(x))}catch{l=l||p}}}i(l)})}[wc](t,e){let r=typeof t.mode=="number"?t.mode&4095:this.dmode,i=this[fn](String(t.absolute),r);if(i){this[Fe](i,t),e();return}if(t.mtime&&!this.noMtime)try{re.utimesSync(String(t.absolute),t.atime||new Date,t.mtime)}catch{}if(this[pi](t))try{re.chownSync(String(t.absolute),Number(this[gi](t)),Number(this[mi](t)))}catch{}e(),t.resume()}[fn](t,e){try{return gw(Z(t),{uid:this.uid,gid:this.gid,processUid:this.processUid,processGid:this.processGid,umask:this.processUmask,preserve:this.preservePaths,unlink:this.unlink,cwd:this.cwd,mode:e})}catch(r){return r}}[ui](t,e,r,i,o){if(this.preservePaths||r.length===0)return i();let c=e;for(let l of r){c=Pe.resolve(c,l);let[u,x]=di(()=>re.lstatSync(c));if(u)return i();if(x.isSymbolicLink())return o(new Vs(c,Pe.resolve(e,r.join("/"))))}i()}[Bs](t,e,r,i){let o=`${r}Sync`;try{re[o](e,String(t.absolute)),i(),t.resume()}catch(c){return this[Fe](c,t)}}},Tw=t=>{let e=new lu(t),r=t.file,i=Y0.statSync(r),o=t.maxReadSize||16*1024*1024;new $g(r,{readSize:o,size:i.size}).pipe(e)},Cw=(t,e)=>{let r=new Rc(t),i=t.maxReadSize||16*1024*1024,o=t.file;return new Promise((c,l)=>{r.on("error",l),r.on("close",c),Y0.stat(o,(u,x)=>{if(u)l(u);else{let p=new bc(o,{readSize:i,size:x.size});p.on("error",l),p.pipe(r)}})})},uu=bi(Tw,Cw,t=>new lu(t),t=>new Rc(t),(t,e)=>{e?.length&&G0(t,e)}),Rw=(t,e)=>{let r=new Cc(t),i=!0,o,c;try{try{o=nt.openSync(t.file,"r+")}catch(x){if(x?.code==="ENOENT")o=nt.openSync(t.file,"w+");else throw x}let l=nt.fstatSync(o),u=Buffer.alloc(512);e:for(c=0;c<l.size;c+=512){for(let m=0,b=0;m<512;m+=b){if(b=nt.readSync(o,u,m,u.length-m,c+m),c===0&&u[0]===31&&u[1]===139)throw new Error("cannot append to compressed archives");if(!b)break e}let x=new Bn(u);if(!x.cksumValid)break;let p=512*Math.ceil((x.size||0)/512);if(c+p+512>l.size)break;c+=p,t.mtimeCache&&x.mtime&&t.mtimeCache.set(String(x.path),x.mtime)}i=!1,Dw(t,r,c,o,e)}finally{if(i)try{nt.closeSync(o)}catch{}}},Dw=(t,e,r,i,o)=>{let c=new O0(t.file,{fd:i,start:r});e.pipe(c),Pw(e,o)},kw=(t,e)=>{e=Array.from(e);let r=new $s(t),i=(o,c,l)=>{let u=(I,y)=>{I?nt.close(o,E=>l(I)):l(null,y)},x=0;if(c===0)return u(null,0);let p=0,m=Buffer.alloc(512),b=(I,y)=>{if(I||y===void 0)return u(I);if(p+=y,p<512&&y)return nt.read(o,m,p,m.length-p,x+p,b);if(x===0&&m[0]===31&&m[1]===139)return u(new Error("cannot append to compressed archives"));if(p<512)return u(null,x);let E=new Bn(m);if(!E.cksumValid)return u(null,x);let S=512*Math.ceil((E.size??0)/512);if(x+S+512>c||(x+=S+512,x>=c))return u(null,x);t.mtimeCache&&E.mtime&&t.mtimeCache.set(String(E.path),E.mtime),p=0,nt.read(o,m,0,512,x,b)};nt.read(o,m,0,512,x,b)};return new Promise((o,c)=>{r.on("error",c);let l="r+",u=(x,p)=>{if(x&&x.code==="ENOENT"&&l==="r+")return l="w+",nt.open(t.file,l,u);if(x||!p)return c(x);nt.fstat(p,(m,b)=>{if(m)return nt.close(p,()=>c(m));i(p,b.size,(I,y)=>{if(I)return c(I);let E=new Gs(t.file,{fd:p,start:y});r.pipe(E),E.on("error",c),E.on("close",o),Lw(r,e)})})};nt.open(t.file,l,u)})},Pw=(t,e)=>{e.forEach(r=>{r.charAt(0)==="@"?mr({file:fu.resolve(t.cwd,r.slice(1)),sync:!0,noResume:!0,onReadEntry:i=>t.add(i)}):t.add(r)}),t.end()},Lw=async(t,e)=>{for(let r of e)r.charAt(0)==="@"?await mr({file:fu.resolve(String(t.cwd),r.slice(1)),noResume:!0,onReadEntry:i=>t.add(i)}):t.add(r);t.end()},li=bi(Rw,kw,()=>{throw new TypeError("file is required")},()=>{throw new TypeError("file is required")},(t,e)=>{if(!tm(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")}),v1=bi(li.syncFile,li.asyncFile,li.syncNoFile,li.asyncNoFile,(t,e=[])=>{li.validate?.(t,e),Ow(t)}),Ow=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))};en();var wt={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 Ei(t){return t?.cozeDeployType==="cloud"?"cloud":"local"}function xu(t){let e=t?.cozeAccountId?.trim();if(!(!e||e==="0"))return e}function Dc(t){let e=t?.cozeGroupId?.trim();if(!(!e||e==="0"))return e}function hu(t){let{_meta:e,...r}=t;return{stripped:r,meta:e}}function wr(t){if(!t?.cozeAgentId)throw new Error("missing _meta.cozeAgentId");return t.cozeAgentId}Ke();ne();De();Ke();function Gt(t,e){if(Ei(t)!=="cloud")throw new C("OPERATION_NOT_ALLOWED_FOR_LOCAL",`${e} is not allowed for local agent`)}function Ys(t){return t.startsWith("http://")||t.startsWith("https://")}function Zs(t){return t.endsWith("/")?t.slice(0,-1):t}Ke();ne();var Xs="1008033",pu="1289";var gu="pbbp2",mu="https://www.coze.cn",wu="/api/coze_claw/resource/get_frontier_key",Mw="https://www.coze.cn",Bw="wss://frontier.coze.cn";function Qs(t){return t??process.env.COZE_BRIDGE_HANDSHAKE_URL??Mw}function _u(t){return t??process.env.COZE_BRIDGE_FRONTIER_URL??Bw}function _r(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 Si(t){return t?t.startsWith("boe_")?{ttEnv:t}:{ttEnv:t,usePpe:"1"}:{}}var vi=H("handshake");async function kc(t){let e=Qs(t.endpoint),r=t.timeoutMs??1e4,i=`${Zs(e)}${wu}?aid=${encodeURIComponent(Xs)}`,o={Authorization:`Bearer ${t.privatecode}`,Accept:"application/json",..._r(t.ppeOverride)},c=new AbortController,l=setTimeout(()=>c.abort(),r);vi.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 E=await u.text().catch(()=>"");throw new C("UPSTREAM_HANDSHAKE_FAILED",`handshake HTTP ${u.status} logid=${x}: ${E.slice(0,200)}`)}let m=await u.json();if(m.code!==void 0&&m.code!==0)throw new C("UPSTREAM_HANDSHAKE_FAILED",`handshake code=${m.code} msg=${m.msg??"-"} logid=${x}`);let b=m.data??{},I=typeof b.access_key=="string"&&b.access_key||typeof b.accessKey=="string"&&b.accessKey||void 0,y=typeof b.device_id=="string"&&b.device_id||typeof b.deviceId=="string"&&b.deviceId||void 0;if(!I||!y){let E=JSON.stringify(m).slice(0,500);throw new C("UPSTREAM_HANDSHAKE_FAILED",`handshake response missing access_key/device_id (also tried camelCase) logid=${x}: ${E}`)}return vi.info("handshake ok",{remoteDeviceId:y,logid:x,traceId:p}),{accessKey:I,deviceId:y}}catch(u){if(u instanceof C)throw vi.error("handshake failed (bridge error)",{base:e,message:u.message,code:u.code}),u;if(u.name==="AbortError")throw vi.warn("handshake timeout",{base:e,timeoutMs:r}),new C("UPSTREAM_HANDSHAKE_FAILED",`handshake timeout (${r}ms)`,{cause:u});let x=u.cause;throw vi.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 C("UPSTREAM_HANDSHAKE_FAILED",String(u),{cause:u})}finally{clearTimeout(l)}}var Pc=process.env.COZE_BRIDGE_LLM_GATEWAY_URL?.trim()||"https://llm-gateway.coze.cn",_t="auto",yu=2e5;function bu(t){return{model:Lc(t.model)??_t,...t.modelToken?{modelToken:t.modelToken}:{}}}function Eu(t){return!t||t===_t}var zw=new Set(["auto","\u81EA\u52A8"]);function Lc(t){let e=t?.trim();if(e)return zw.has(e.toLowerCase())?_t:e}function vu(t){let e={};if(t.modelToken){e.ANTHROPIC_BASE_URL=Pc,e.ANTHROPIC_AUTH_TOKEN=t.modelToken;let r=t.model||_t;e.ANTHROPIC_MODEL=r,e.ANTHROPIC_SMALL_FAST_MODEL=r,e.ANTHROPIC_DEFAULT_HAIKU_MODEL=r,t.modelInfo?.contextWindow&&(e.CLAUDE_CODE_MAX_CONTEXT_TOKENS=String(t.modelInfo.contextWindow))}else Eu(t.model)||(e.ANTHROPIC_MODEL=t.model);return e}function Su(t){let e=[];if(t.modelToken?e.push("-c",`model="${t.model||_t}"`):Eu(t.model)||e.push("-c",`model="${t.model}"`),t.modelToken){e.push("-c",'model_providers.coze.name="coze"'),e.push("-c",`model_providers.coze.base_url="${Pc}/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"');let r=t.modelInfo?.contextWindow??yu;e.push("-c",`model_context_window=${r}`)}return e}function Iu(t){return t.modelToken?{OPENAI_API_KEY:t.modelToken}:{}}function Oc(t,e){let{ttEnv:r,usePpe:i}=Si(t),o={};return r&&(o["x-tt-env"]=r),i&&(o["x-use-ppe"]=i),e&&(o["x-mock-scenario"]=e),o}function Au(t,e,r){if(!t.modelToken)return{};let i=Oc(e,r);return Object.keys(i).length===0?{}:{ANTHROPIC_CUSTOM_HEADERS:Object.entries(i).map(([c,l])=>`${c}:${l}`).join(`
|
|
92
|
-
`)}}function Nc(t){return`coze-session-${t.replace(/[^A-Za-z0-9_-]+/g,"-")}`}function Tu(t,e,r){if(!t.modelToken)return null;let i=t.model||_t,o=Oc(e,r),c=["text"];t.modelInfo?.capabilities?.image===!0&&c.push("image");let l={baseUrl:`${Pc}/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??yu,maxTokens:8192,api:"openai-completions"}]};return Object.keys(o).length>0&&(l.headers=o),l}function Cu(t,e,r){if(!t.modelToken)return[];let i=Oc(e,r),o=[];for(let[c,l]of Object.entries(i))o.push("-c",`model_providers.coze.http_headers.${c}="${l}"`);return o}var Le=H("agent-handlers"),Ru=5*1024*1024,jw=1,Ww=6,Kw=new Set(["node_modules",".git",".coze","dist","build",".next"]),eo=class{constructor(e){this.opts=e}opts;async listSkills(e){Gt(e._meta,"_agent/listSkills");let r=wr(e._meta),i=await this.loadAgentCfg(r),o=i?.workspace??Ye(r).workspace,c=i?.skills??[],l=[];for(let u of c){let x=Rt(o,u.relPath,"SKILL.md");await Hw(x).then(m=>m.isFile()).catch(()=>!1)&&l.push(Zw(u))}return{skills:l}}async addSkills(e){Gt(e._meta,"_agent/addSkills");let r=wr(e._meta),i=await this.requireAgentCfg(r),o=e.skills??[],c=[...i.skills??[]],l=new Map(c.map((x,p)=>[x.skillId,p])),u=[];for(let x of o){let p=await qc({agentId:r,workspace:i.workspace,framework:i.framework,skill:x});Gc(c,l,p),u.push(x)}return await ss(r,c),this.reloadAgentSessions(r,"skills-added"),{installedSkills:u}}async removeSkills(e){Gt(e._meta,"_agent/removeSkills");let r=wr(e._meta),i=await this.requireAgentCfg(r),o=new Set(e.skillIds??[]),c=i.skills??[],l=[];for(let u of c){if(!o.has(u.skillId)){l.push(u);continue}let x=Rt(i.workspace,u.relPath);await Uw(x,{recursive:!0,force:!0}),Le.info("skill removed",{agentId:r,skillId:u.skillId,relPath:u.relPath})}return await ss(r,l),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 l=c.acpSessionId;if(l&&i.activeTriggers.has(l)||this.isRuntimePendingPermission(c)){c.reloadAfterTurn=!0,Le.info("downstream busy, scheduling reload after turn",{reason:r,agentId:e,framework:i.framework,cloudId:o,acpId:l});continue}let x=c.downstream;c.downstream=void 0,Le.info("killing downstream for workspace reload (idle)",{reason:r,agentId:e,framework:i.framework,cloudId:o,acpId:l}),x.stop(r).catch(p=>Le.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 Le.info("_agent/update: empty cozeIdentity, noop",{agentId:e.agentId}),{ok:!0};let r=e.agentId,i=await Ge(r);if(!i)throw new C("AGENT_NOT_FOUND",`agent not found: ${r}`);if(i.cozeIdentity===e.cozeIdentity)return Le.info("_agent/update: cozeIdentity unchanged, noop",{agentId:r}),{ok:!0};try{await tr(i.workspace,i.framework,e.cozeIdentity)}catch(o){throw Le.error("_agent/update: writeInstructionFile failed, aborting update",{agentId:r,framework:i.framework,workspace:i.workspace,err:String(o)}),new C("AGENT_PROTOCOL_ERROR",`failed to write instruction file for agent ${r}: ${String(o)}`,{cause:o})}return i.cozeIdentity=e.cozeIdentity,await Ze(i),Le.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 C("IPC_BAD_REQUEST","_agent/disconnect: missing agentId");let i=await Ge(r);return i?(i.disconnectedAt=Date.now(),i.disconnectReason=e.reason??"",await Ze(i),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(Gt(e._meta,"_agent/switchModel"),!e.agentId)throw new C("IPC_BAD_REQUEST","_agent/switchModel: missing agentId");let r=Lc(e.model)??_t,i=await Ge(e.agentId);if(!i)throw new C("AGENT_NOT_FOUND",`agent not found: ${e.agentId}`);i.model=r,e.modelInfo&&(i.modelInfo=e.modelInfo),await Ze(i),Le.info("_agent/switchModel: model persisted",{agentId:e.agentId,model:r,reason:e.reason??""});let o=this.opts.agents.get(e.agentId);if(!o)return Le.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(l=>Le.warn("cleanupOpenclawProviders before switchModel failed (ignored)",{agentId:e.agentId,err:String(l)}));let c=[];for(let[l,u]of o.allSessionQueues())c.push(u.enqueue(async()=>{let x=o.sessions.get(l);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(Gt(e._meta,wt.RESET),!e.agentId)throw new C("IPC_BAD_REQUEST",`${wt.RESET}: missing agentId`);return await this.clearSessionMappings(e.agentId,wt.RESET),await this.runDetailSync(e.agentId,wt.RESET,e.reason),{ok:!0}}async clearSessionMappings(e,r){let i=this.opts.agents.get(e);if(!i){await this.clearPersistedAcpSessionIds(e),Le.info("reset: agent not in memory, cleared persisted acpSessionIds only",{agentId:e});return}await i.killAllRuntimes(r);for(let c of i.sessions.values())c.acpSessionId=void 0,c.replySeq=0,c.loadingSession=!1,c.spawnFailCount=void 0,c.spawnFailedAt=void 0;let o=new Map;for(let[c,l]of i.sessions)o.set(c,{modelToken:l.modelToken,tokenGeneratedAt:l.tokenGeneratedAt});await Vr(e,o)}async clearPersistedAcpSessionIds(e){let r=await Ge(e).catch(()=>null);if(!r?.sessions)return;let i=!1;for(let o of Object.values(r.sessions))o.acpSessionId&&(o.acpSessionId=void 0,i=!0);i&&await Ze(r)}async repairAgent(e){if(Gt(e._meta,wt.REPAIR),!e.agentId)throw new C("IPC_BAD_REQUEST",`${wt.REPAIR}: missing agentId`);let r=await this.loadAgentCfg(e.agentId);if(r&&r.framework!=="openclaw")throw new C("IPC_BAD_REQUEST",`${wt.REPAIR} only allowed for openclaw, got ${r.framework}`);if(r&&this.opts.openclawRepair)try{await this.opts.openclawRepair(e.agentId,r.workspace)}catch(i){Le.warn("openclaw repair (delete+add) failed (ignored)",{agentId:e.agentId,reason:e.reason,err:String(i)})}return await this.runDetailSync(e.agentId,wt.REPAIR,e.reason),{ok:!0}}async runDetailSync(e,r,i){if(!this.opts.detailSyncer){Le.warn("detailSyncer not wired, skipping sync",{method:r,agentId:e});return}try{await this.opts.detailSyncer(e)}catch(o){Le.warn("detail sync failed (ignored)",{method:r,agentId:e,reason:i,err:String(o)})}}async getFileTree(e){Gt(e._meta,"_agent/getFileTree");let r=e._meta,i=wr(r),o=await this.resolveWorkspace(i),c=e.filePath??"",l=this.safeJoin(o,c),u=await Mc(l).catch(()=>null);if(!u)throw new C("IPC_BAD_REQUEST",`path not found: ${c}`);if(u.isSymbolicLink())throw new C("IPC_BAD_REQUEST",`symlink not allowed: ${c}`);if(!await Jr(l,o))throw new C("IPC_BAD_REQUEST",`path escapes workspace: ${c}`);let x=c_(e.depth);return u.isDirectory()?{tree:await a_(o,l,c,x)}:{tree:[{name:d_(c),path:Mu(c||"."),isDir:!1,size:u.size,modifiedAt:Math.floor(u.mtimeMs)}]}}async getFileContent(e){Gt(e._meta,"_agent/getFileContent");let r=wr(e._meta),i=await this.resolveWorkspace(r);if(!e.filePath)throw new C("IPC_BAD_REQUEST","filePath required");let o=this.safeJoin(i,e.filePath),c=await Mc(o).catch(()=>null);if(!c||!c.isFile())throw new C("IPC_BAD_REQUEST",`not a file: ${e.filePath}`);if(c.isSymbolicLink())throw new C("IPC_BAD_REQUEST",`symlink not allowed: ${e.filePath}`);if(!await Jr(o,i))throw new C("IPC_BAD_REQUEST",`path escapes workspace: ${e.filePath}`);if(c.size>Ru)throw new C("IPC_BAD_REQUEST",`file too large: ${c.size} bytes (max ${Ru})`);let l=await Du(o);return l.includes(0)?{content:l.toString("base64"),encoding:"base64",size:c.size}:{content:l.toString("utf8"),encoding:"utf-8",size:c.size}}async resolveWorkspace(e){let r=this.opts.agents.get(e);return r?r.workspace:(await Ge(e).catch(()=>null))?.workspace??Ye(e).workspace}safeJoin(e,r){let i=Fc(e,r||"."),o=Hc(e,i);if(o.startsWith("..")||o===".."||o.startsWith(`..${ku}`))throw new C("IPC_BAD_REQUEST",`path escapes workspace: ${r}`);return i}loadAgentCfg(e){return Ge(e)}async requireAgentCfg(e){let r=await this.loadAgentCfg(e);if(!r)throw new C("AGENT_NOT_FOUND",`no config for agent: ${e}`);return r}};function $w(t){let e=t.trim().replace(/[\x00-\x1f<>:"|?*/\\]+/g,"-").replace(/^[\s.-]+|[\s.-]+$/g,"").slice(0,64);if(!e||e==="."||e==="..")throw new C("IPC_BAD_REQUEST",`invalid skill name: ${t}`);if(/^(con|prn|aux|nul|com[1-9]|lpt[1-9])$/i.test(e))throw new C("IPC_BAD_REQUEST",`reserved windows filename: ${t}`);return e}function Jw(t){return t==="claude-code"?Rt(".claude","skills"):Rt(".agents","skills")}var Vw=3e4,Yw=50*1024*1024,yr=3e4;async function qc(t){let{agentId:e,workspace:r,framework:i,skill:o}=t;if(!o.skillName)throw new C("IPC_BAD_REQUEST","skill missing skillName");let c=typeof o.content=="string"&&o.content.length>0,l=typeof o.downloadUrl=="string"&&o.downloadUrl.length>0;if(!c&&!l)throw new C("IPC_BAD_REQUEST",`skill ${o.skillId} missing both content and downloadUrl`);let u=$w(o.skillName),x=Jw(i),p=Rt(x,u),m=Rt(r,p);if(await Bc(m,{recursive:!0}),c){let I=Buffer.from(o.content,"utf8");Ii(I.length),await zc(Rt(m,"SKILL.md"),I,"utf8")}else{let I=await Xw(o.downloadUrl);e_(I)?await i_(I,m):t_(I)?await n_(I,m):await zc(Rt(m,"SKILL.md"),I.toString("utf8"),"utf8")}let b={skillId:o.skillId,skillName:o.skillName,relPath:p,installedAt:Date.now(),...o.description?{description:o.description}:{},...o.icon?{icon:o.icon}:{},...o.version?{version:o.version}:{},...o.downloadUrl?{downloadUrl:o.downloadUrl}:{},...o.config?{config:o.config}:{},...o.builtin?{builtin:o.builtin}:{}};return Le.info("skill installed",{agentId:e,skillId:o.skillId,skillName:o.skillName,relPath:p,source:c?"content":"downloadUrl"}),b}function Gc(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 Zw(t){return{skillId:t.skillId,skillName:t.skillName,...t.description?{description:t.description}:{},...t.icon?{icon:t.icon}:{},...t.version?{version:t.version}:{},...t.config?{config:t.config}:{},...t.builtin?{builtin:t.builtin}:{}}}async function Xw(t){if(!t)throw new C("IPC_BAD_REQUEST","skill missing downloadUrl");if(t.startsWith("data:")){let e=Math.floor(t.length*3/4);Ii(e);let r=Qw(t);return Ii(r.length),r}if(t.startsWith("file:")){let e=new URL(t).pathname,r=await Du(e);return Ii(r.length),r}if(Ys(t)){let e=new AbortController,r=setTimeout(()=>e.abort(),Vw);try{let i=await fetch(t,{signal:e.signal});if(!i.ok)throw new C("IPC_BAD_REQUEST",`fetch skill failed HTTP ${i.status} ${t}`);let o=await i.arrayBuffer();return Ii(o.byteLength),Buffer.from(o)}finally{clearTimeout(r)}}throw new C("IPC_BAD_REQUEST",`unsupported downloadUrl scheme (\u8981 https/data/file): ${t.slice(0,80)}`)}function Ii(t){if(t>Yw)throw new C("IPC_BAD_REQUEST",`skill too large: ${t} bytes`)}function Qw(t){let e=/^data:([^,;]*)(;base64)?,(.*)$/s.exec(t);if(!e)throw new C("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 e_(t){return t.length>=2&&t[0]===31&&t[1]===139}function t_(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 Uc(t){return t==="__MACOSX"||t.startsWith("__MACOSX/")}async function n_(t,e){let r,i;try{r=new Ou.default(t),i=r.getEntries()}catch(l){throw new C("IPC_BAD_REQUEST",`zip parse failed: ${l.message}`,{cause:l})}for(let l of i){let u=l.entryName;if(!u||Uc(u))continue;if(u.startsWith("/")||/^[A-Za-z]:[\\/]/.test(u))throw new C("IPC_BAD_REQUEST",`zip entry absolute path: ${u}`);if(u.split(/[/\\]/).some(p=>p===".."))throw new C("IPC_BAD_REQUEST",`zip entry contains '..' (traversal): ${u}`);let x=l.header.attr>>>16&61440;if(x!==0&&x!==32768&&x!==16384)throw new C("IPC_BAD_REQUEST",`zip entry kind 0x${x.toString(16)} not allowed (symlink/hardlink/special): ${u}`)}let o=r_(i),c=Fc(e);for(let l of i){if(Uc(l.entryName))continue;let u=l.entryName;if(o&&u.startsWith(o)&&(u=u.slice(o.length)),!u)continue;let x=Fc(e,u),p=Hc(c,x);if(p.startsWith("..")||p==="..")throw new C("IPC_BAD_REQUEST",`zip entry escapes destDir: ${u}`);if(l.isDirectory){await Bc(x,{recursive:!0});continue}await Bc(qw(x),{recursive:!0});let m;try{m=l.getData()}catch(b){throw new C("IPC_BAD_REQUEST",`zip entry getData failed (${l.entryName}): ${b.message}`,{cause:b})}await zc(x,m)}}function r_(t){let e;for(let r of t){let i=r.entryName;if(!i||Uc(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 i_(t,e){await s_(t);let r=uu({cwd:e,strip:1}),i=!1,o=setTimeout(()=>{i=!0,r.destroy(new C("IPC_BAD_REQUEST",`tar extract timeout (${yr}ms)`))},yr);try{await Lu(Pu.from(t),r)}catch(c){throw c instanceof C?c:i?new C("IPC_BAD_REQUEST",`tar extract timeout (${yr}ms)`):new C("IPC_BAD_REQUEST",`tar extract failed: ${c.message??String(c)}`,{cause:c})}finally{clearTimeout(o)}}async function s_(t){let e=[],r=mr({onReadEntry:c=>{let l=c.path,u=c.type;if(u!=="File"&&u!=="Directory"){e.push(`tar entry kind '${u}' not allowed (symlink/hardlink/special): ${l.slice(0,100)}`);return}if(l.startsWith("/")||l.startsWith("\\")||/^[a-zA-Z]:[\\/]/.test(l)){e.push(`tar entry absolute path: ${l}`);return}l.split(/[/\\]/).some(p=>p==="..")&&e.push(`tar entry contains '..': ${l}`)}}),i=!1,o=setTimeout(()=>{i=!0,r.destroy(new C("IPC_BAD_REQUEST",`tar list timeout (${yr}ms)`))},yr);try{await Lu(Pu.from(t),r)}catch(c){throw i?new C("IPC_BAD_REQUEST",`tar list timeout (${yr}ms)`):new C("IPC_BAD_REQUEST",`tar list failed: ${c.message??String(c)}`,{cause:c})}finally{clearTimeout(o)}if(e.length>0)throw new C("IPC_BAD_REQUEST",e[0]??"tar entry validation failed")}var o_=5e3;async function a_(t,e,r,i){return Nu(t,e,r,i,{count:0})}async function Nu(t,e,r,i,o){if(i<=0)return[];let c;try{c=await Fw(e,{withFileTypes:!0})}catch{return[]}let l=[];for(let u of c){if(Kw.has(u.name)||u.isSymbolicLink())continue;if(o.count>=o_){l.push({name:"...",path:"...",isDir:!1,size:0,modifiedAt:0,hasMore:!0});break}let x=Rt(e,u.name),p=Gw(Rt(r,u.name)),m=null;try{m=await Mc(x)}catch{continue}if(m.isSymbolicLink())continue;o.count++;let b={name:u.name,path:Mu(Hc(t,x)),isDir:m.isDirectory(),size:m.size,modifiedAt:Math.floor(m.mtimeMs)};m.isDirectory()&&i>1&&(b.children=await Nu(t,x,p,i-1,o)),l.push(b)}return l.sort((u,x)=>u.isDir!==x.isDir?u.isDir?-1:1:u.name.localeCompare(x.name)),l}function c_(t){return!t||t<=0?jw:Math.min(t,Ww)}function d_(t){if(!t||t==="."||t==="/")return".";let e=t.split(/[/\\]/);return e[e.length-1]||"."}function Mu(t){return t.split(ku).join("/")}ne();import{readFileSync as LI}from"node:fs";import{dirname as NI,join as MI}from"node:path";import{fileURLToPath as zI}from"node:url";var br="0.1.95-beta.0";var pn=H("agent-health-reporter"),l_=1e4,Ai=class{constructor(e){this.opts=e;this.intervalMs=e.intervalMs??l_}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()}),pn.info("heartbeat started",{intervalMs:this.intervalMs}),this.tick())}stop(){this.timer&&(clearInterval(this.timer),this.timer=null,this.unsubscribeRegister&&(this.unsubscribeRegister(),this.unsubscribeRegister=null),pn.info("heartbeat stopped"))}async tick(){if(this.inFlight){pn.debug("previous tick still in-flight, skip");return}let e=this.opts.getDeviceId();if(!e){pn.debug("deviceId not available, skip tick (\u5C1A\u672A pair)");return}this.inFlight=!0;try{let r=[];for(let l of this.opts.core.agents.values()){let u=u_(l);if(!u)continue;let x={agentId:l.agentId,status:u};l.patToken&&(x.patToken=l.patToken),l.accountId&&(x.accountId=l.accountId),r.push(x)}if(r.length===0)return;let i={agents:r,bridgeVersion:br,_meta:{cozeDeviceId:e}},o;try{o=await this.opts.core.sendRequest("_agent/health",i,5e3)}catch(l){pn.warn("heartbeat batch send failed",{count:r.length,err:String(l)})}let c=o?.authFailures;if(c&&c.length>0&&(pn.warn("heartbeat received authFailures from cloud",{count:c.length,agentIds:c.map(l=>l.agentId)}),this.opts.onAuthFailures))try{await this.opts.onAuthFailures(c)}catch(l){pn.warn("onAuthFailures callback failed (ignored)",{err:String(l)})}}finally{this.inFlight=!1}if(this.opts.onTickEnd)try{await this.opts.onTickEnd()}catch(r){pn.warn("onTickEnd hook failed",{err:String(r)})}}};function u_(t){return t.status==="error"?"error":t.activeTriggers.size>0?"busy":t.status==="ok"?"online":null}en();import{chmod as ny,mkdir as lo,rm as ry,stat as iy,writeFile as sy}from"node:fs/promises";import{homedir as oy}from"node:os";import{join as nf}from"node:path";Qt();import{spawnSync as T_}from"node:child_process";import{existsSync as C_}from"node:fs";import{release as R_}from"node:os";import{basename as D_,isAbsolute as k_}from"node:path";function Ti(t,e,r){return r===void 0?{jsonrpc:"2.0",id:t,method:e}:{jsonrpc:"2.0",id:t,method:e,params:r}}function Er(t,e){return e===void 0?{jsonrpc:"2.0",method:t}:{jsonrpc:"2.0",method:t,params:e}}function vr(t,e){return{jsonrpc:"2.0",id:t,result:e}}function gn(t,e){return{jsonrpc:"2.0",id:t,error:e}}Ke();var to=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)}},te={PARSE_ERROR:-32700,INVALID_REQUEST:-32600,METHOD_NOT_FOUND:-32601,INVALID_PARAMS:-32602,INTERNAL_ERROR:-32603,AGENT_NOT_FOUND:-32001,AGENT_BUSY:-32002,AGENT_TIMEOUT:-32003,AGENT_SPAWN_FAILED:-32004,OPERATION_NOT_ALLOWED_FOR_LOCAL:-32005,AGENT_DISCONNECTED:-32006,MODEL_TOKEN_GEN_FAILED:-32009,PATH_OUTSIDE_WORKSPACE:-32010,FILE_TOO_LARGE:-32011,UNSUPPORTED_MIME:-32012,UPLOAD_FAILED:-32013,UPSTREAM_NOT_READY:-32014,AGENT_FRAME_IDLE_TIMEOUT:-32016,MODEL_MODALITY_UNSUPPORTED:-32017,AGENT_DEPENDENCY_INSTALL_FAILED:-32018,AGENT_APPROVAL_TIMEOUT:-32019,AGENT_TURN_ABORTED:-32020};function Bu(t){return"method"in t&&"id"in t&&t.id!==void 0}function zu(t){return"method"in t&&!("id"in t)}function no(t){return!("method"in t)&&"id"in t}var f_={AGENT_NOT_FOUND:te.AGENT_NOT_FOUND,AGENT_BUSY:te.AGENT_BUSY,AGENT_DISCONNECTED:te.AGENT_DISCONNECTED,AGENT_TIMEOUT:te.AGENT_TIMEOUT,AGENT_FRAME_IDLE_TIMEOUT:te.AGENT_FRAME_IDLE_TIMEOUT,AGENT_SPAWN_FAILED:te.AGENT_SPAWN_FAILED,AGENT_PROTOCOL_ERROR:te.INTERNAL_ERROR,BRIDGE_CONFIG_INVALID:te.INTERNAL_ERROR,BRIDGE_INTERNAL:te.INTERNAL_ERROR,IPC_AUTH_FAILED:te.INTERNAL_ERROR,IPC_BAD_REQUEST:te.INVALID_REQUEST,MODEL_TOKEN_GEN_FAILED:te.MODEL_TOKEN_GEN_FAILED,MODEL_MODALITY_UNSUPPORTED:te.MODEL_MODALITY_UNSUPPORTED,OPERATION_NOT_ALLOWED_FOR_LOCAL:te.OPERATION_NOT_ALLOWED_FOR_LOCAL,UPSTREAM_DISCONNECTED:te.INTERNAL_ERROR,UPSTREAM_HANDSHAKE_FAILED:te.INTERNAL_ERROR,PATH_OUTSIDE_WORKSPACE:te.PATH_OUTSIDE_WORKSPACE,FILE_TOO_LARGE:te.FILE_TOO_LARGE,UNSUPPORTED_MIME:te.UNSUPPORTED_MIME,UPLOAD_FAILED:te.UPLOAD_FAILED,UPSTREAM_NOT_READY:te.UPSTREAM_NOT_READY,AGENT_DEPENDENCY_INSTALL_FAILED:te.AGENT_DEPENDENCY_INSTALL_FAILED,AGENT_APPROVAL_TIMEOUT:te.AGENT_APPROVAL_TIMEOUT,AGENT_TURN_ABORTED:te.AGENT_TURN_ABORTED};function x_(t){if(t!=null)return t instanceof Error?{name:t.name,message:Ci(t.message)}:typeof t=="string"?Ci(t):typeof t=="object"?p_(t):t}var h_=[[/\/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 Ci(t){let e=t;for(let[r,i]of h_)e=e.replace(r,i);return e}function p_(t){let e={};for(let[r,i]of Object.entries(t))typeof i=="string"?e[r]=Ci(i):e[r]=i;return e}function Ri(t){if(t instanceof C){let e=x_(t.cause),r={bridgeCode:t.code,retriable:t.retriable};return e!==void 0&&(r.cause=e),{code:f_[t.code]??te.INTERNAL_ERROR,message:Ci(t.message),data:r}}return{code:te.INTERNAL_ERROR,message:Ci(t instanceof Error?t.message:String(t))}}function Fu(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:l,...u}=e;c=u}return new C(r,o,{retriable:e?.retriable??!1,cause:c})}function Hu(t){return`${JSON.stringify(t)}
|
|
93
|
-
`}var
|
|
94
|
-
`);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(l){this.onError?.({line:c,error:l})}}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"},VI=Object.fromEntries(Object.entries(Gu).map(([t,e])=>[e,t])),g_={"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:[]},Sr=class{seq=0;next(e,r){this.seq+=1;let i=Gu[e]??m_(e),o=g_[i]??[],c=[i,String(this.seq)];if(o.length>0){let l=o.map(x=>qu(r?.[x]??"")),u=w_(l).join(":");u&&c.push(u)}else r&&Object.values(r).some(l=>l)&&c.push(Object.values(r).filter(Boolean).map(l=>qu(String(l))).join(":"));return c.join("_")}reset(){this.seq=0}};function m_(t){return t.replace(/[\s/]+/g,".").replace(/_+/g,"-")}function qu(t){return t.replace(/[:_\s]+/g,"-")}function w_(t){let e=t.length;for(;e>0&&!t[e-1];)e-=1;return t.slice(0,e)}$r();import{readFileSync as __}from"node:fs";var y_=384;async function jc(t,e=process.env){let r={};for(let[i,o]of Object.entries(e))typeof o=="string"&&(r[i]=o);await er(t.agentEnvFile,r,{mode:y_})}function Wc(t){try{let e=JSON.parse(__(t,"utf8"));return e&&typeof e=="object"&&!Array.isArray(e)?e:{}}catch{return{}}}function ju(t,e,r={},i=o=>o){return{...i({...t,...Wc(e)}),...r}}mn();Zi();Ke();ne();De();var P_=Mt("COZE_BRIDGE_INITIALIZE_TIMEOUT_MS",3e4),L_=200,O_=40,N_=Mt("COZE_BRIDGE_SESSION_PROMPT_MAX_MS",3600*1e3),M_=Mt("COZE_BRIDGE_SESSION_PROMPT_FIRST_UPDATE_MS",600*1e3),B_=Mt("COZE_BRIDGE_SESSION_PROMPT_APPROVAL_MAX_MS",1440*60*1e3),Ju=500;function z_(t){try{let e=JSON.stringify(t);return e===void 0||e.length<=Ju?t:`${e.slice(0,Ju)}...<truncated, total ${e.length} chars>`}catch{return"<unserializable>"}}function Vu(t,e){if(!(typeof t!="number"||t<=0))try{if(process.platform==="win32"){let r=["/PID",String(t),"/T"];e==="SIGKILL"&&r.push("/F"),T_("taskkill",r,{stdio:"ignore",windowsHide:!0})}else process.kill(-t,e)}catch{}}function Yu(t){try{return C_(t)}catch{return}}function F_(t,e){return{platform:process.platform,osRelease:R_(),code:t.code,errno:t.errno,syscall:t.syscall,errPath:t.path,command:e.command,commandExists:k_(e.command)?Yu(e.command):void 0,cwd:e.cwd,cwdExists:Yu(e.cwd),envKeys:e.envKeys}}function U_(t,e){return`${t.message} [diag: platform=${e.platform} os=${e.osRelease} code=${e.code} errno=${e.errno} syscall=${e.syscall} cmd=${D_(e.command)} cmdExists=${e.commandExists} cwdExists=${e.cwdExists} envKeys=${e.envKeys}]`}var Dt=class{constructor(e){this.opts=e;this.log=H(`downstream.${this.constructor.name}`,this.opts.agentId),this.decoder=new ro({onError:r=>this.log.warn("decode line failed",{line:r.line})})}opts;child;decoder;pending=new Map;inflightAgentRequests=new Map;idAllocator=new Sr;updateHandlers=[];agentRequestHandlers=[];exitHandlers=[];log;stopped=!1;stopReason;stderrRing=[];sanitizeEnv(e){return e}async start(){if(this.child)throw new C("BRIDGE_INTERNAL","Downstream already started");let e=process.platform!=="win32",r=ju(process.env,this.opts.agentEnvFile??Q().agentEnvFile,this.opts.env,o=>this.sanitizeEnv(o)),i=ct(this.opts.command,this.opts.args,{cwd:this.opts.cwd,env:r,stdio:["pipe","pipe","pipe"],detached:e});this.child=i,i.stdout?.setEncoding("utf8"),i.stdout?.on("data",o=>{try{for(let c of this.decoder.push(o))this.dispatch(c)}catch(c){this.log.warn("stdout dispatch threw, swallowed to keep daemon alive",{err:String(c)})}}),i.stderr?.setEncoding("utf8"),i.stderr?.on("data",o=>{let c=o.trimEnd();this.stderrRing.push(c),this.stderrRing.length>L_&&this.stderrRing.shift(),this.log.debug("stderr",{text:c})}),i.stdin?.on("error",o=>{this.log.warn("child stdin error",{err:String(o)})}),i.stdout?.on("error",o=>{this.log.warn("child stdout error",{err:String(o)})}),i.stderr?.on("error",o=>{this.log.warn("child stderr error",{err:String(o)})}),i.on("exit",(o,c)=>{this.stopped=!0,(o!==0||c!==null)&&this.stderrRing.length>0&&this.log.warn("downstream exited abnormally, recent stderr",{code:o,signal:c,recentStderr:[...this.stderrRing]});try{for(let u of this.decoder.flush())this.dispatch(u)}catch(u){this.log.debug("decoder.flush on exit threw (ignored)",{err:String(u)})}this.failAllPending(this.buildExitError(o,c));for(let u of this.exitHandlers)u(o,c)}),i.on("error",o=>{let c=o,l=F_(c,{command:this.opts.command,cwd:this.opts.cwd,envKeys:Object.keys(r).length});this.log.error("child error",{err:String(o),diag:l}),this.failAllPending(new C("AGENT_SPAWN_FAILED",U_(c,l),{cause:l}))}),this.log.info("downstream started",{command:this.opts.command,pid:i.pid,cwd:this.opts.cwd})}async stop(e){if(!this.child||this.stopped)return;this.stopped=!0,this.stopReason=e??"stopped",this.log.info("downstream stopping",{reason:e});let r=this.child,i=new Promise(c=>r.once("exit",()=>c()));Vu(r.pid,"SIGTERM");let o=setTimeout(()=>{r.killed||Vu(r.pid,"SIGKILL")},5e3);try{await i}finally{clearTimeout(o)}}pid(){return this.child?.pid}isAlive(){return!!this.child&&!this.stopped}getStderrTail(e){return e===void 0?[...this.stderrRing]:this.stderrRing.slice(-e)}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=N_,i=M_,o=B_){return this.call("session/prompt",e,r,i,o)}async sessionCancel(e){!this.child||this.stopped||this.writeFrame(Er("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(vr(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(gn(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=P_,o=0,c=0){if(!this.child||this.stopped)return Promise.reject(new C("AGENT_PROTOCOL_ERROR","downstream not started"));let l=this.idAllocator.next(e),u=Ti(l,e,r),x=(()=>{if(typeof r!="object"||r===null)return;let b=r.sessionId;return typeof b=="string"?b:void 0})(),p=i>0&&Number.isFinite(i),m=o>0&&Number.isFinite(o);return new Promise((b,I)=>{let y={resolve:b,reject:I,timer:null,firstUpdateTimer:null,onFirstUpdate:null,method:e},E=Date.now();if(p){let A=()=>{y.timer=setTimeout(()=>{let D=Date.now()-E;if(this.inflightAgentRequests.size>0&&D<c){this.log.debug("hard cap fired but agent request inflight, extending to approval cap",{id:l,method:e,elapsed:D,approvalMaxMs:c,...x?{sessionId:x}:{}}),A();return}this.pending.delete(l),y.firstUpdateTimer&&clearTimeout(y.firstUpdateTimer);let L=this.inflightAgentRequests.size>0;this.log.warn("downstream call timeout",{id:l,method:e,timeoutMs:i,approvalMaxMs:c,awaitingApproval:L,...x?{sessionId:x}:{}}),I(L?new C("AGENT_APPROVAL_TIMEOUT",`${e} awaiting permission timed out after ${c}ms`):new C("AGENT_TIMEOUT",`${e} timed out after ${i}ms`))},i)};A()}let S=m?()=>{y.firstUpdateTimer&&clearTimeout(y.firstUpdateTimer),y.firstUpdateTimer=setTimeout(()=>{if(this.inflightAgentRequests.size>0){this.log.debug("first-update wait fired but agent request inflight, re-arming",{id:l,method:e,inflight:this.inflightAgentRequests.size,...x?{sessionId:x}:{}}),S?.();return}y.timer&&clearTimeout(y.timer),this.pending.delete(l),this.log.warn("first session/update timeout, rejecting pending call",{id:l,method:e,firstUpdateMs:o,...x?{sessionId:x}:{}}),I(new C("AGENT_FRAME_IDLE_TIMEOUT",`${e} no first session/update within ${o}ms`))},o)}:null;y.onFirstUpdate=m?()=>{y.firstUpdateTimer&&clearTimeout(y.firstUpdateTimer),y.firstUpdateTimer=null,y.onFirstUpdate=null}:null,this.pending.set(l,y),S?.();try{this.writeFrame(u)}catch(A){y.timer&&clearTimeout(y.timer),y.firstUpdateTimer&&clearTimeout(y.firstUpdateTimer),this.pending.delete(l),I(A)}})}writeFrame(e){if(!this.child?.stdin||this.child.stdin.destroyed)throw new C("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(no(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.firstUpdateTimer&&clearTimeout(r.firstUpdateTimer),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(Fu(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 C("AGENT_PROTOCOL_ERROR",`${r.method} response missing both result and error`))):(this.log.info("downstream returned result",{id:e.id,method:r.method,result:z_(e.result)}),r.resolve(e.result));return}if(zu(e)){if(e.method==="session/update"){for(let r of this.pending.values())r.onFirstUpdate?.();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(Bu(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(gn(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(gn(e.id,Ri(i)))}catch{}this.inflightAgentRequests.delete(e.id)}}buildExitError(e,r){if(this.stopReason!==void 0)return new C("AGENT_TURN_ABORTED",`turn aborted: ${this.stopReason}`,{cause:{reason:this.stopReason}});let i=this.getStderrTail(O_).join(`
|
|
95
|
-
`);return new C("AGENT_PROTOCOL_ERROR",`agent exited (${e}/${r})`,{cause:{code:e,signal:r,stderrTail:i}})}failAllPending(e){for(let r of this.pending.values())r.timer&&clearTimeout(r.timer),r.firstUpdateTimer&&clearTimeout(r.firstUpdateTimer),r.reject(e);this.pending.clear(),this.inflightAgentRequests.clear()}};function H_(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 io=class extends Dt{framework="claude-code";constructor(e){let{command:r,args:i}=Kr("claude-code",e.command,e.args??[]),o={command:r,args:i,cwd:e.cwd,agentId:e.agentId,...e.env?{env:e.env}:{}};super(o)}sanitizeEnv(e){return H_(e)}};Qt();import{mkdtempSync as q_,rmSync as G_}from"node:fs";import{tmpdir as j_}from"node:os";import{join as W_}from"node:path";var so=class extends Dt{framework="codex";authMethodId;codexHomeDir;constructor(e){let r=e.args??[],i=e.extraArgs?[...r,...e.extraArgs]:r,{command:o,args:c}=Kr("codex",e.command,i),l=e.isolateCodexHome?q_(W_(j_(),"coze-bridge-codex-home-")):void 0,u=l?{...e.env??{},CODEX_HOME:l}:e.env,x={command:o,args:c,cwd:e.cwd,agentId:e.agentId,...u?{env:u}:{}};super(x),this.authMethodId=e.authMethodId,this.codexHomeDir=l}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{G_(this.codexHomeDir,{recursive:!0,force:!0})}catch{}}};var K_=3e4,Ir=class extends Dt{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,agentId:e.agentId,...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}`}]},K_))}get acpSessionName(){return this.sessionName}};Ke();ne();De();function Kc(t){return t.replace(/[^A-Za-z0-9._-]+/g,"-")}Qt();var wn=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 oo=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 wn,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)Di(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 Di(t){t.idleTimer&&(clearTimeout(t.idleTimer),t.idleTimer=void 0)}mn();ne();import{constants as Zu,access as $_}from"node:fs/promises";import{delimiter as J_,join as V_}from"node:path";var _n=H("framework-detector"),Xu={"claude-code":"claude",codex:"codex",openclaw:"openclaw"},Y_=[".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??ct,access:e.access??$_}}async detect(e){let r=Xu[e],i=await this.which(r);if(!i)return _n.debug("framework binary not found",{framework:e,bin:r}),null;let o=e==="openclaw"?["--log-level","silent"]:[],[c,l]=await Promise.all([this.probeVersion(i,o),e==="openclaw"?this.probeOpenclawDefaultAgent(i):Promise.resolve(null)]),u={path:i,version:c};return l&&(u.defaultAgent=l),u}async detectAll(){let e=await Promise.all(Object.keys(Xu).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(J_).filter(Boolean),i=this.env.platform==="win32"?["",...Y_]:[""];for(let o of r)for(let c of i){let l=V_(o,e+c);if(await this.isExecutable(l))return l}return null}async isExecutable(e){try{let r=this.env.platform==="win32"?Zu.F_OK:Zu.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 _n.warn("openclaw default agent probe: runProbe returned null (spawn err / timeout)",{path:e}),null;if(r.code!==0)return _n.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 _n.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 _n.warn("openclaw default agent probe: JSON parsed but not an array",{path:e}),null;let c=o.find(l=>l?.isDefault===!0);return c?!c.id||!c.workspace?(_n.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}:(_n.info("openclaw default agent probe: no agent has isDefault=true",{path:e,agentCount:o.length}),null)}catch(o){return _n.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&&(X_(i.stdout).split(/\r?\n/)[0]??"").trim()||"unknown"}runProbe(e,r){return new Promise(i=>{let o="",c=!1,l,u=x=>{c||(c=!0,l&&clearTimeout(l),i(x))};try{let x=this.env.spawn(e,r,{stdio:["ignore","pipe","pipe"]});l=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)}})}},Z_=new RegExp("\x1B\\[[0-9;]*[A-Za-z]","g");function X_(t){return t.replace(Z_,"")}import{homedir as Q_}from"node:os";import{join as ey}from"node:path";mn();Ke();$r();ne();async function tf(){let t=ey(Q_(),".openclaw/openclaw.json");return(await Qn(t))?.gateway?.auth?.token??""}var Qu=H("openclaw.config"),ty=[0,5e3,5e3],ef="models.providers.",ao="agents.defaults.models",co=class{command;env;retryDelaysMs;queue=new wn;constructor(e){this.command=e.command,this.env=e.env??process.env,this.retryDelaysMs=e.retryDelaysMs??ty}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(l=>setTimeout(l,c));try{return await r()}catch(l){i=l,Qu.warn("openclaw cli failed, will retry",{label:e,attempt:o+1,err:String(l)})}}throw new C("AGENT_SPAWN_FAILED",`openclaw cli ${e} failed after ${this.retryDelaysMs.length} attempts: ${i?.message??"unknown"}`)}runCli(e){return new Promise((r,i)=>{let o=ct(this.command,e,{stdio:["ignore","pipe","pipe"],env:this.env}),c="";o.stderr?.on("data",l=>{c+=l.toString("utf8")}),o.on("error",i),o.on("close",l=>{l===0?r():i(new Error(`exit ${l}: ${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){Qu.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",`${ef}${e}`,JSON.stringify(r),"--strict-json","--merge"])))}removeProvider(e){return this.bestEffortUnset(`config unset models.providers.${e}`,`${ef}${e}`)}addModelToAllowlist(e,r){let i={[e]:r?{alias:r}:{}};return this.queue.enqueue(()=>this.withRetry(`config set ${ao}[${e}]`,()=>this.runCli(["config","set",ao,JSON.stringify(i),"--strict-json","--merge"])))}removeModelFromAllowlist(e){return this.bestEffortUnset(`config unset ${ao}[${e}]`,`${ao}.${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"])))}restartGateway(){return this.queue.enqueue(()=>this.withRetry("gateway restart",()=>this.runCli(["gateway","restart"])))}deleteAgent(e){return this.queue.enqueue(()=>this.withRetry(`agents delete ${e}`,()=>this.runCliTolerant(["agents","delete",e,"--force"],["not found","does not exist"])))}};var _e=H("agent-manager"),ay=(t,e,r,i,o,c,l,u,x)=>{switch(t){case"claude-code":{let p={...o?{...vu(o),...Au(o,l,u)}:{},...x??{},IS_SANDBOX:"1"};return new io({cwd:r,env:p,agentId:i})}case"codex":{let m=[...o?[...Su(o),...Cu(o,l,u)]:[],"-c",'sandbox_mode="danger-full-access"',"-c",'approval_policy="never"'],b={...o?Iu(o):{},...x??{}},I=!!o;return new so({cwd:r,agentId:i,...m.length>0?{extraArgs:m}:{},...Object.keys(b).length>0?{env:b}:{},...I?{authMethodId:"openai-api-key",isolateCodexHome:!0}:{}})}case"openclaw":return new Ir({command:e,cwd:r,agentId:i,...c?{sessionName:Kc(c)}:{}})}};function $c(t){return t==="claude-code"||t==="codex"}function cy(t){let e=[],r=Object.keys(t).sort();for(let i of r){let o=t[i];o!==void 0&&(dy(o)||e.push(`${i}=${o}`))}return e.length===0?"":`${e.join(`
|
|
89
|
+
`},configPath(t){return Ev(t.homeDir,".coze","bridge","task.xml")},async install(t){let n=`cmd.exe /c ${[`^"${t.nodeBin}^"`,`^"${t.entry}^"`,"--daemon",`>> ^"${t.logFile}^" 2>&1`].join(" ")}`;await Th("schtasks",["/Create","/SC","ONLOGON","/TN",ia,"/TR",n,"/RU",t.userName,"/F"]),Nd.info("task scheduler entry created",{task:ia,logFile:t.logFile})},async uninstall(t){await Th("schtasks",["/Delete","/TN",ia,"/F"]).catch(e=>Nd.warn("schtasks /Delete failed (ignored)",{err:String(e)})),Nd.info("task scheduler entry removed",{task:ia})}}});var Dh={};ma(Dh,{buildContext:()=>Tv,getSupervisor:()=>Sv,launchdSupervisor:()=>Pd,systemdSupervisor:()=>Od,taskSchedulerSupervisor:()=>Md});import{homedir as bv,userInfo as vv}from"node:os";function Sv(t=process.platform){switch(t){case"darwin":return Pd;case"linux":return Od;case"win32":return Md;default:throw new Error(`unsupported platform for OS supervisor: ${t}`)}}function Av(){let t={};for(let e of Iv){let n=process.env[e];n&&(t[e]=n)}return t}function Tv(){let t=Q();return{nodeBin:process.execPath,entry:Ad(t),logFile:t.logFile,homeDir:bv(),userName:vv().username,isRoot:process.getuid?.()===0,env:Av()}}var Iv,Rh=Ye(()=>{"use strict";Oe();$o();Sh();Ah();Ch();Iv=["PATH","HOME","HTTP_PROXY","HTTPS_PROXY","NO_PROXY","ALL_PROXY","http_proxy","https_proxy","no_proxy","all_proxy","NODE_EXTRA_CA_CERTS"]});re();sn();var u0=H("acp-installer-warmup"),Yp=["claude-code","codex"];async function x0(t={}){let e=t.ensure??rr,i=(await Promise.allSettled(Yp.map(async o=>{let c=await e(o);u0.info("acp wrapper warmup ok",{framework:o,path:c})}))).filter(o=>o.status==="rejected");i.length>0&&u0.warn("acp wrapper warmup partial failure (\u5C06\u5728\u4E0B\u6B21 createAgent \u65F6\u91CD\u8BD5\u5E76\u629B\u9519\u7ED9\u7528\u6237)",{failedCount:i.length,reasons:i.map(o=>o.reason instanceof Error?o.reason.message:String(o.reason))})}on();re();import{readdir as lg}from"node:fs/promises";import{mkdir as _0,writeFile as y0}from"node:fs/promises";import{join as Sa}from"node:path";var dg={"claude-code":"CLAUDE.md",codex:"AGENTS.md",openclaw:"SOUL.md"};async function or(t,e,n){await _0(t,{recursive:!0});let i=dg[e],o=Sa(t,i);return await y0(o,n??"","utf8"),o}async function E0(t){let e=Sa(t,".claude");await _0(e,{recursive:!0});let n=Sa(e,"settings.local.json"),i=JSON.stringify({permissions:{defaultMode:"bypassPermissions"}},null,2);return await y0(n,i,"utf8"),n}var it=H("agent-detail-sync"),fg=6e4,ug=5*6e4,fs=class{constructor(e){this.opts=e}opts;retryQueue=new Map;async syncAll(e){let n=this.opts.paths.agentsRoot,i;try{i=await lg(n)}catch(o){it.info("agents dir not found, skip detail sync",{root:n,err:String(o)});return}it.info("starting detail sync",{reason:e,count:i.length}),await Promise.allSettled(i.map(async o=>{let c=await Ke(o,this.opts.paths).catch(()=>null);if(c){if(c.disconnectedAt){it.debug("detail sync: skip disconnected agent",{agentId:o});return}try{await this.syncOne(o,c)}catch(l){it.warn("detail sync failed for agent, skipping",{agentId:o,err:String(l)})}}})),it.info("detail sync done",{reason:e})}async retryPending(){if(this.retryQueue.size===0)return;let e=Date.now(),n=[];for(let[i,o]of this.retryQueue)e>=o.dueAt&&n.push(i);if(n.length!==0){it.info("retrying pending detail syncs",{count:n.length});for(let i of n)try{await this.syncOne(i)}catch(o){it.debug("detail sync retry still failing, will try again",{agentId:i,err:String(o)})}}}async syncOne(e,n){let i=n??await Ke(e,this.opts.paths);if(!i){it.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(f){it.warn("detail RPC failed, using local data",{agentId:e,err:String(f)});let x=this.retryQueue.get(e),p=x?Math.min(x.currentDelay*2,ug):fg;this.retryQueue.set(e,{dueAt:Date.now()+p,currentDelay:p});return}if(o.agentId&&o.agentId!==e){it.warn("detail response agentId mismatch, ignoring",{agentId:e,responseAgentId:o.agentId});return}let c=!1,l=!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,l=!0),o.deployType&&it.info("detail.deployType",{agentId:e,deployType:o.deployType}),!c){it.debug("detail sync: no diff",{agentId:e});return}await et(i,this.opts.paths),it.info("detail sync: config updated",{agentId:e,identityChanged:l,agentName:i.agentName}),l&&(await or(i.workspace,i.framework,i.cozeIdentity),this.opts.handlers.reloadAgentSessionsPublic(e,"detail-sync"))}};var zf=Tt(el(),1);import{lstat as Fc,mkdir as Uc,readFile as Of,readdir as Fw,rm as Uw,stat as qw,writeFile as qc}from"node:fs/promises";import{dirname as Hw,join as Ot,normalize as Gw,relative as jc,resolve as Hc,sep as Nf}from"node:path";import{Readable as Mf}from"node:stream";import{pipeline as Bf}from"node:stream/promises";import Og from"events";import nt from"fs";import{EventEmitter as vc}from"node:events";import Nl from"node:stream";import{StringDecoder as Ng}from"node:string_decoder";import zl from"node:path";import wr from"node:fs";import{dirname as Jg,parse as Vg}from"path";import{EventEmitter as rm}from"events";import ic from"assert";import{Buffer as Un}from"buffer";import*as sl from"zlib";import im from"zlib";import{posix as fr}from"node:path";import{basename as km}from"node:path";import Gs from"fs";import kt from"fs";import ul from"path";import{win32 as Hm}from"node:path";import _l from"path";import Ql from"node:fs";import sw from"node:assert";import{randomBytes as ef}from"node:crypto";import ie from"node:fs";import Me from"node:path";import tf from"fs";import Ys from"node:fs";import yi from"node:path";import at from"node:fs";import uw from"node:fs/promises";import Ks from"node:path";import{join as xf}from"node:path";import ot from"node:fs";import gf from"node:path";var Lg=Object.defineProperty,Pg=(t,e)=>{for(var n in e)Lg(t,n,{get:e[n],enumerable:!0})},tl=typeof process=="object"&&process?process:{stdout:null,stderr:null},Mg=t=>!!t&&typeof t=="object"&&(t instanceof Gn||t instanceof Nl||Bg(t)||zg(t)),Bg=t=>!!t&&typeof t=="object"&&t instanceof vc&&typeof t.pipe=="function"&&t.pipe!==Nl.Writable.prototype.pipe,zg=t=>!!t&&typeof t=="object"&&t instanceof vc&&typeof t.write=="function"&&typeof t.end=="function",Ht=Symbol("EOF"),Gt=Symbol("maybeEmitEnd"),cn=Symbol("emittedEnd"),gs=Symbol("emittingEnd"),ri=Symbol("emittedError"),ms=Symbol("closed"),nl=Symbol("read"),ws=Symbol("flush"),rl=Symbol("flushChunk"),wt=Symbol("encoding"),lr=Symbol("decoder"),Fe=Symbol("flowing"),ii=Symbol("paused"),pr=Symbol("resume"),Ue=Symbol("buffer"),Ze=Symbol("pipes"),qe=Symbol("bufferLength"),Ra=Symbol("bufferPush"),_s=Symbol("bufferShift"),Je=Symbol("objectMode"),Ie=Symbol("destroyed"),ka=Symbol("error"),La=Symbol("emitData"),il=Symbol("emitEnd"),Pa=Symbol("emitEnd2"),Ct=Symbol("async"),Oa=Symbol("abort"),ys=Symbol("aborted"),si=Symbol("signal"),kn=Symbol("dataListeners"),st=Symbol("discarded"),oi=t=>Promise.resolve().then(t),Fg=t=>t(),Ug=t=>t==="end"||t==="finish"||t==="prefinish",qg=t=>t instanceof ArrayBuffer||!!t&&typeof t=="object"&&t.constructor&&t.constructor.name==="ArrayBuffer"&&t.byteLength>=0,Hg=t=>!Buffer.isBuffer(t)&&ArrayBuffer.isView(t),Ml=class{src;dest;opts;ondrain;constructor(t,e,n){this.src=t,this.dest=e,this.opts=n,this.ondrain=()=>t[pr](),this.dest.on("drain",this.ondrain)}unpipe(){this.dest.removeListener("drain",this.ondrain)}proxyErrors(t){}end(){this.unpipe(),this.opts.end&&this.dest.end()}},Gg=class extends Ml{unpipe(){this.src.removeListener("error",this.proxyErrors),super.unpipe()}constructor(t,e,n){super(t,e,n),this.proxyErrors=i=>this.dest.emit("error",i),t.on("error",this.proxyErrors)}},jg=t=>!!t.objectMode,Wg=t=>!t.objectMode&&!!t.encoding&&t.encoding!=="buffer",Gn=class extends vc{[Fe]=!1;[ii]=!1;[Ze]=[];[Ue]=[];[Je];[wt];[Ct];[lr];[Ht]=!1;[cn]=!1;[gs]=!1;[ms]=!1;[ri]=null;[qe]=0;[Ie]=!1;[si];[ys]=!1;[kn]=0;[st]=!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");jg(e)?(this[Je]=!0,this[wt]=null):Wg(e)?(this[wt]=e.encoding,this[Je]=!1):(this[Je]=!1,this[wt]=null),this[Ct]=!!e.async,this[lr]=this[wt]?new Ng(this[wt]):null,e&&e.debugExposeBuffer===!0&&Object.defineProperty(this,"buffer",{get:()=>this[Ue]}),e&&e.debugExposePipes===!0&&Object.defineProperty(this,"pipes",{get:()=>this[Ze]});let{signal:n}=e;n&&(this[si]=n,n.aborted?this[Oa]():n.addEventListener("abort",()=>this[Oa]()))}get bufferLength(){return this[qe]}get encoding(){return this[wt]}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[Je]}set objectMode(t){throw new Error("objectMode must be set at instantiation time")}get async(){return this[Ct]}set async(t){this[Ct]=this[Ct]||!!t}[Oa](){this[ys]=!0,this.emit("abort",this[si]?.reason),this.destroy(this[si]?.reason)}get aborted(){return this[ys]}set aborted(t){}write(t,e,n){if(this[ys])return!1;if(this[Ht])throw new Error("write after end");if(this[Ie])return this.emit("error",Object.assign(new Error("Cannot call write after a stream was destroyed"),{code:"ERR_STREAM_DESTROYED"})),!0;typeof e=="function"&&(n=e,e="utf8"),e||(e="utf8");let i=this[Ct]?oi:Fg;if(!this[Je]&&!Buffer.isBuffer(t)){if(Hg(t))t=Buffer.from(t.buffer,t.byteOffset,t.byteLength);else if(qg(t))t=Buffer.from(t);else if(typeof t!="string")throw new Error("Non-contiguous data written to non-objectMode stream")}return this[Je]?(this[Fe]&&this[qe]!==0&&this[ws](!0),this[Fe]?this.emit("data",t):this[Ra](t),this[qe]!==0&&this.emit("readable"),n&&i(n),this[Fe]):t.length?(typeof t=="string"&&!(e===this[wt]&&!this[lr]?.lastNeed)&&(t=Buffer.from(t,e)),Buffer.isBuffer(t)&&this[wt]&&(t=this[lr].write(t)),this[Fe]&&this[qe]!==0&&this[ws](!0),this[Fe]?this.emit("data",t):this[Ra](t),this[qe]!==0&&this.emit("readable"),n&&i(n),this[Fe]):(this[qe]!==0&&this.emit("readable"),n&&i(n),this[Fe])}read(t){if(this[Ie])return null;if(this[st]=!1,this[qe]===0||t===0||t&&t>this[qe])return this[Gt](),null;this[Je]&&(t=null),this[Ue].length>1&&!this[Je]&&(this[Ue]=[this[wt]?this[Ue].join(""):Buffer.concat(this[Ue],this[qe])]);let e=this[nl](t||null,this[Ue][0]);return this[Gt](),e}[nl](t,e){if(this[Je])this[_s]();else{let n=e;t===n.length||t===null?this[_s]():typeof n=="string"?(this[Ue][0]=n.slice(t),e=n.slice(0,t),this[qe]-=t):(this[Ue][0]=n.subarray(t),e=n.subarray(0,t),this[qe]-=t)}return this.emit("data",e),!this[Ue].length&&!this[Ht]&&this.emit("drain"),e}end(t,e,n){return typeof t=="function"&&(n=t,t=void 0),typeof e=="function"&&(n=e,e="utf8"),t!==void 0&&this.write(t,e),n&&this.once("end",n),this[Ht]=!0,this.writable=!1,(this[Fe]||!this[ii])&&this[Gt](),this}[pr](){this[Ie]||(!this[kn]&&!this[Ze].length&&(this[st]=!0),this[ii]=!1,this[Fe]=!0,this.emit("resume"),this[Ue].length?this[ws]():this[Ht]?this[Gt]():this.emit("drain"))}resume(){return this[pr]()}pause(){this[Fe]=!1,this[ii]=!0,this[st]=!1}get destroyed(){return this[Ie]}get flowing(){return this[Fe]}get paused(){return this[ii]}[Ra](t){this[Je]?this[qe]+=1:this[qe]+=t.length,this[Ue].push(t)}[_s](){return this[Je]?this[qe]-=1:this[qe]-=this[Ue][0].length,this[Ue].shift()}[ws](t=!1){do;while(this[rl](this[_s]())&&this[Ue].length);!t&&!this[Ue].length&&!this[Ht]&&this.emit("drain")}[rl](t){return this.emit("data",t),this[Fe]}pipe(t,e){if(this[Ie])return t;this[st]=!1;let n=this[cn];return e=e||{},t===tl.stdout||t===tl.stderr?e.end=!1:e.end=e.end!==!1,e.proxyErrors=!!e.proxyErrors,n?e.end&&t.end():(this[Ze].push(e.proxyErrors?new Gg(this,t,e):new Ml(this,t,e)),this[Ct]?oi(()=>this[pr]()):this[pr]()),t}unpipe(t){let e=this[Ze].find(n=>n.dest===t);e&&(this[Ze].length===1?(this[Fe]&&this[kn]===0&&(this[Fe]=!1),this[Ze]=[]):this[Ze].splice(this[Ze].indexOf(e),1),e.unpipe())}addListener(t,e){return this.on(t,e)}on(t,e){let n=super.on(t,e);if(t==="data")this[st]=!1,this[kn]++,!this[Ze].length&&!this[Fe]&&this[pr]();else if(t==="readable"&&this[qe]!==0)super.emit("readable");else if(Ug(t)&&this[cn])super.emit(t),this.removeAllListeners(t);else if(t==="error"&&this[ri]){let i=e;this[Ct]?oi(()=>i.call(this,this[ri])):i.call(this,this[ri])}return n}removeListener(t,e){return this.off(t,e)}off(t,e){let n=super.off(t,e);return t==="data"&&(this[kn]=this.listeners("data").length,this[kn]===0&&!this[st]&&!this[Ze].length&&(this[Fe]=!1)),n}removeAllListeners(t){let e=super.removeAllListeners(t);return(t==="data"||t===void 0)&&(this[kn]=0,!this[st]&&!this[Ze].length&&(this[Fe]=!1)),e}get emittedEnd(){return this[cn]}[Gt](){!this[gs]&&!this[cn]&&!this[Ie]&&this[Ue].length===0&&this[Ht]&&(this[gs]=!0,this.emit("end"),this.emit("prefinish"),this.emit("finish"),this[ms]&&this.emit("close"),this[gs]=!1)}emit(t,...e){let n=e[0];if(t!=="error"&&t!=="close"&&t!==Ie&&this[Ie])return!1;if(t==="data")return!this[Je]&&!n?!1:this[Ct]?(oi(()=>this[La](n)),!0):this[La](n);if(t==="end")return this[il]();if(t==="close"){if(this[ms]=!0,!this[cn]&&!this[Ie])return!1;let o=super.emit("close");return this.removeAllListeners("close"),o}else if(t==="error"){this[ri]=n,super.emit(ka,n);let o=!this[si]||this.listeners("error").length?super.emit("error",n):!1;return this[Gt](),o}else if(t==="resume"){let o=super.emit("resume");return this[Gt](),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[Gt](),i}[La](t){for(let n of this[Ze])n.dest.write(t)===!1&&this.pause();let e=this[st]?!1:super.emit("data",t);return this[Gt](),e}[il](){return this[cn]?!1:(this[cn]=!0,this.readable=!1,this[Ct]?(oi(()=>this[Pa]()),!0):this[Pa]())}[Pa](){if(this[lr]){let e=this[lr].end();if(e){for(let n of this[Ze])n.dest.write(e);this[st]||super.emit("data",e)}}for(let e of this[Ze])e.end();let t=super.emit("end");return this.removeAllListeners("end"),t}async collect(){let t=Object.assign([],{dataLength:0});this[Je]||(t.dataLength=0);let e=this.promise();return this.on("data",n=>{t.push(n),this[Je]||(t.dataLength+=n.length)}),await e,t}async concat(){if(this[Je])throw new Error("cannot concat in objectMode");let t=await this.collect();return this[wt]?t.join(""):Buffer.concat(t,t.dataLength)}async promise(){return new Promise((t,e)=>{this.on(Ie,()=>e(new Error("stream destroyed"))),this.on("error",n=>e(n)),this.on("end",()=>t())})}[Symbol.asyncIterator](){this[st]=!1;let t=!1,e=async()=>(this.pause(),t=!0,{value:void 0,done:!0});return{next:()=>{if(t)return e();let n=this.read();if(n!==null)return Promise.resolve({done:!1,value:n});if(this[Ht])return e();let i,o,c=p=>{this.off("data",l),this.off("end",f),this.off(Ie,x),e(),o(p)},l=p=>{this.off("error",c),this.off("end",f),this.off(Ie,x),this.pause(),i({value:p,done:!!this[Ht]})},f=()=>{this.off("error",c),this.off("data",l),this.off(Ie,x),e(),i({done:!0,value:void 0})},x=()=>c(new Error("stream destroyed"));return new Promise((p,w)=>{o=w,i=p,this.once(Ie,x),this.once("error",c),this.once("end",f),this.once("data",l)})},throw:e,return:e,[Symbol.asyncIterator](){return this},[Symbol.asyncDispose]:async()=>{}}}[Symbol.iterator](){this[st]=!1;let t=!1,e=()=>(this.pause(),this.off(ka,e),this.off(Ie,e),this.off("end",e),t=!0,{done:!0,value:void 0}),n=()=>{if(t)return e();let i=this.read();return i===null?e():{done:!1,value:i}};return this.once("end",e),this.once(ka,e),this.once(Ie,e),{next:n,throw:e,return:e,[Symbol.iterator](){return this},[Symbol.dispose]:()=>{}}}destroy(t){if(this[Ie])return t?this.emit("error",t):this.emit(Ie),this;this[Ie]=!0,this[st]=!0,this[Ue].length=0,this[qe]=0;let e=this;return typeof e.close=="function"&&!this[ms]&&e.close(),t?this.emit("error",t):this.emit(Ie),this}static get isStream(){return Mg}},Kg=nt.writev,wn=Symbol("_autoClose"),bt=Symbol("_close"),ai=Symbol("_ended"),de=Symbol("_fd"),Na=Symbol("_finished"),$t=Symbol("_flags"),Ma=Symbol("_flush"),nc=Symbol("_handleChunk"),rc=Symbol("_makeBuf"),wi=Symbol("_mode"),Es=Symbol("_needDrain"),yr=Symbol("_onerror"),Er=Symbol("_onopen"),Ba=Symbol("_onread"),gr=Symbol("_onwrite"),_n=Symbol("_open"),Et=Symbol("_path"),xn=Symbol("_pos"),Dt=Symbol("_queue"),mr=Symbol("_read"),za=Symbol("_readSize"),Kt=Symbol("_reading"),ci=Symbol("_remain"),Fa=Symbol("_size"),ks=Symbol("_write"),Ln=Symbol("_writing"),Ls=Symbol("_defaultFlag"),Fn=Symbol("_errored"),Sc=class extends Gn{[Fn]=!1;[de];[Et];[za];[Kt]=!1;[Fa];[ci];[wn];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[Fn]=!1,this[de]=typeof e.fd=="number"?e.fd:void 0,this[Et]=t,this[za]=e.readSize||16*1024*1024,this[Kt]=!1,this[Fa]=typeof e.size=="number"?e.size:1/0,this[ci]=this[Fa],this[wn]=typeof e.autoClose=="boolean"?e.autoClose:!0,typeof this[de]=="number"?this[mr]():this[_n]()}get fd(){return this[de]}get path(){return this[Et]}write(){throw new TypeError("this is a readable stream")}end(){throw new TypeError("this is a readable stream")}[_n](){nt.open(this[Et],"r",(t,e)=>this[Er](t,e))}[Er](t,e){t?this[yr](t):(this[de]=e,this.emit("open",e),this[mr]())}[rc](){return Buffer.allocUnsafe(Math.min(this[za],this[ci]))}[mr](){if(!this[Kt]){this[Kt]=!0;let t=this[rc]();if(t.length===0)return process.nextTick(()=>this[Ba](null,0,t));nt.read(this[de],t,0,t.length,null,(e,n,i)=>this[Ba](e,n,i))}}[Ba](t,e,n){this[Kt]=!1,t?this[yr](t):this[nc](e,n)&&this[mr]()}[bt](){if(this[wn]&&typeof this[de]=="number"){let t=this[de];this[de]=void 0,nt.close(t,e=>e?this.emit("error",e):this.emit("close"))}}[yr](t){this[Kt]=!0,this[bt](),this.emit("error",t)}[nc](t,e){let n=!1;return this[ci]-=t,t>0&&(n=super.write(t<e.length?e.subarray(0,t):e)),(t===0||this[ci]<=0)&&(n=!1,this[bt](),super.end()),n}emit(t,...e){switch(t){case"prefinish":case"finish":return!1;case"drain":return typeof this[de]=="number"&&this[mr](),!1;case"error":return this[Fn]?!1:(this[Fn]=!0,super.emit(t,...e));default:return super.emit(t,...e)}}},$g=class extends Sc{[_n](){let t=!0;try{this[Er](null,nt.openSync(this[Et],"r")),t=!1}finally{t&&this[bt]()}}[mr](){let t=!0;try{if(!this[Kt]){this[Kt]=!0;do{let e=this[rc](),n=e.length===0?0:nt.readSync(this[de],e,0,e.length,null);if(!this[nc](n,e))break}while(!0);this[Kt]=!1}t=!1}finally{t&&this[bt]()}}[bt](){if(this[wn]&&typeof this[de]=="number"){let t=this[de];this[de]=void 0,nt.closeSync(t),this.emit("close")}}},$s=class extends Og{readable=!1;writable=!0;[Fn]=!1;[Ln]=!1;[ai]=!1;[Dt]=[];[Es]=!1;[Et];[wi];[wn];[de];[Ls];[$t];[Na]=!1;[xn];constructor(t,e){e=e||{},super(e),this[Et]=t,this[de]=typeof e.fd=="number"?e.fd:void 0,this[wi]=e.mode===void 0?438:e.mode,this[xn]=typeof e.start=="number"?e.start:void 0,this[wn]=typeof e.autoClose=="boolean"?e.autoClose:!0;let n=this[xn]!==void 0?"r+":"w";this[Ls]=e.flags===void 0,this[$t]=e.flags===void 0?n:e.flags,this[de]===void 0&&this[_n]()}emit(t,...e){if(t==="error"){if(this[Fn])return!1;this[Fn]=!0}return super.emit(t,...e)}get fd(){return this[de]}get path(){return this[Et]}[yr](t){this[bt](),this[Ln]=!0,this.emit("error",t)}[_n](){nt.open(this[Et],this[$t],this[wi],(t,e)=>this[Er](t,e))}[Er](t,e){this[Ls]&&this[$t]==="r+"&&t&&t.code==="ENOENT"?(this[$t]="w",this[_n]()):t?this[yr](t):(this[de]=e,this.emit("open",e),this[Ln]||this[Ma]())}end(t,e){return t&&this.write(t,e),this[ai]=!0,!this[Ln]&&!this[Dt].length&&typeof this[de]=="number"&&this[gr](null,0),this}write(t,e){return typeof t=="string"&&(t=Buffer.from(t,e)),this[ai]?(this.emit("error",new Error("write() after end()")),!1):this[de]===void 0||this[Ln]||this[Dt].length?(this[Dt].push(t),this[Es]=!0,!1):(this[Ln]=!0,this[ks](t),!0)}[ks](t){nt.write(this[de],t,0,t.length,this[xn],(e,n)=>this[gr](e,n))}[gr](t,e){t?this[yr](t):(this[xn]!==void 0&&typeof e=="number"&&(this[xn]+=e),this[Dt].length?this[Ma]():(this[Ln]=!1,this[ai]&&!this[Na]?(this[Na]=!0,this[bt](),this.emit("finish")):this[Es]&&(this[Es]=!1,this.emit("drain"))))}[Ma](){if(this[Dt].length===0)this[ai]&&this[gr](null,0);else if(this[Dt].length===1)this[ks](this[Dt].pop());else{let t=this[Dt];this[Dt]=[],Kg(this[de],t,this[xn],(e,n)=>this[gr](e,n))}}[bt](){if(this[wn]&&typeof this[de]=="number"){let t=this[de];this[de]=void 0,nt.close(t,e=>e?this.emit("error",e):this.emit("close"))}}},Bl=class extends $s{[_n](){let t;if(this[Ls]&&this[$t]==="r+")try{t=nt.openSync(this[Et],this[$t],this[wi])}catch(e){if(e?.code==="ENOENT")return this[$t]="w",this[_n]();throw e}else t=nt.openSync(this[Et],this[$t],this[wi]);this[Er](null,t)}[bt](){if(this[wn]&&typeof this[de]=="number"){let t=this[de];this[de]=void 0,nt.closeSync(t),this.emit("close")}}[ks](t){let e=!0;try{this[gr](null,nt.writeSync(this[de],t,0,t.length,this[xn])),e=!1}finally{if(e)try{this[bt]()}catch{}}}},Zg=new Map([["C","cwd"],["f","file"],["z","gzip"],["P","preservePaths"],["U","unlink"],["strip-components","strip"],["stripComponents","strip"],["keep-newer","newer"],["keepNewer","newer"],["keep-newer-files","newer"],["keepNewerFiles","newer"],["k","keep"],["keep-existing","keep"],["keepExisting","keep"],["m","noMtime"],["no-mtime","noMtime"],["p","preserveOwner"],["L","follow"],["h","follow"],["onentry","onReadEntry"]]),Xg=t=>!!t.sync&&!!t.file,Yg=t=>!t.sync&&!!t.file,Qg=t=>!!t.sync&&!t.file,em=t=>!t.sync&&!t.file,tm=t=>!!t.file,nm=t=>Zg.get(t)||t,Ic=(t={})=>{if(!t)return{};let e={};for(let[n,i]of Object.entries(t)){let o=nm(n);e[o]=i}return e.chmod===void 0&&e.noChmod===!1&&(e.chmod=!0),delete e.noChmod,e},Ti=(t,e,n,i,o)=>Object.assign((c=[],l,f)=>{Array.isArray(c)&&(l=c,c={}),typeof l=="function"&&(f=l,l=void 0),l=l?Array.from(l):[];let x=Ic(c);if(o?.(x,l),Xg(x)){if(typeof f=="function")throw new TypeError("callback not supported for sync tar functions");return t(x,l)}else if(Yg(x)){let p=e(x,l);return f?p.then(()=>f(),f):p}else if(Qg(x)){if(typeof f=="function")throw new TypeError("callback not supported for sync tar functions");return n(x,l)}else if(em(x)){if(typeof f=="function")throw new TypeError("callback only supported with file option");return i(x,l)}throw new Error("impossible options??")},{syncFile:t,asyncFile:e,syncNoFile:n,asyncNoFile:i,validate:o}),sm=im.constants||{ZLIB_VERNUM:4736},Pt=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},sm)),om=Un.concat,ol=Object.getOwnPropertyDescriptor(Un,"concat"),am=t=>t,Ua=ol?.writable===!0||ol?.set!==void 0?t=>{Un.concat=t?am:om}:t=>{},qn=Symbol("_superWrite"),bs=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"}},qa=Symbol("flushFlag"),Ac=class extends Gn{#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 sl[e]!="function")throw new TypeError("Compression method not supported: "+e);try{this.#t=new sl[e](t)}catch(n){throw new bs(n,this.constructor)}this.#o=n=>{this.#e||(this.#e=!0,this.close(),this.emit("error",n))},this.#t?.on("error",n=>this.#o(new bs(n))),this.once("end",()=>this.close)}close(){this.#t&&(this.#t.close(),this.#t=void 0,this.emit("close"))}reset(){if(!this.#e)return ic(this.#t,"zlib binding closed"),this.#t.reset?.()}flush(t){this.ended||(typeof t!="number"&&(t=this.#i),this.write(Object.assign(Un.alloc(0),{[qa]:t})))}end(t,e,n){return typeof t=="function"&&(n=t,e=void 0,t=void 0),typeof e=="function"&&(n=e,e=void 0),t&&(e?this.write(t,e):this.write(t)),this.flush(this.#s),this.#n=!0,super.end(n)}get ended(){return this.#n}[qn](t){return super.write(t)}write(t,e,n){if(typeof e=="function"&&(n=e,e="utf8"),typeof t=="string"&&(t=Un.from(t,e)),this.#e)return;ic(this.#t,"zlib binding closed");let i=this.#t._handle,o=i.close;i.close=()=>{};let c=this.#t.close;this.#t.close=()=>{},Ua(!0);let l;try{let x=typeof t[qa]=="number"?t[qa]:this.#r;l=this.#t._processChunk(t,x),Ua(!1)}catch(x){Ua(!1),this.#o(new bs(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 bs(x,this.write)));let f;if(l)if(Array.isArray(l)&&l.length>0){let x=l[0];f=this[qn](Un.from(x));for(let p=1;p<l.length;p++)f=this[qn](l[p])}else f=this[qn](Un.from(l));return n&&n(),f}},Fl=class extends Ac{#e;#n;constructor(t,e){t=t||{},t.flush=t.flush||Pt.Z_NO_FLUSH,t.finishFlush=t.finishFlush||Pt.Z_FINISH,t.fullFlushFlag=Pt.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(Pt.Z_SYNC_FLUSH),ic(this.handle,"zlib binding closed");let n=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=n}this.handle&&(this.#e=t,this.#n=e)}}}},cm=class extends Fl{#e;constructor(t){super(t,"Gzip"),this.#e=t&&!!t.portable}[qn](t){return this.#e?(this.#e=!1,t[9]=255,super[qn](t)):super[qn](t)}},dm=class extends Fl{constructor(t){super(t,"Unzip")}},Ul=class extends Ac{constructor(t,e){t=t||{},t.flush=t.flush||Pt.BROTLI_OPERATION_PROCESS,t.finishFlush=t.finishFlush||Pt.BROTLI_OPERATION_FINISH,t.fullFlushFlag=Pt.BROTLI_OPERATION_FLUSH,super(t,e)}},lm=class extends Ul{constructor(t){super(t,"BrotliCompress")}},fm=class extends Ul{constructor(t){super(t,"BrotliDecompress")}},ql=class extends Ac{constructor(t,e){t=t||{},t.flush=t.flush||Pt.ZSTD_e_continue,t.finishFlush=t.finishFlush||Pt.ZSTD_e_end,t.fullFlushFlag=Pt.ZSTD_e_flush,super(t,e)}},um=class extends ql{constructor(t){super(t,"ZstdCompress")}},xm=class extends ql{constructor(t){super(t,"ZstdDecompress")}},hm=(t,e)=>{if(Number.isSafeInteger(t))t<0?gm(t,e):pm(t,e);else throw Error("cannot encode number outside of javascript safe integer range");return e},pm=(t,e)=>{e[0]=128;for(var n=e.length;n>1;n--)e[n-1]=t&255,t=Math.floor(t/256)},gm=(t,e)=>{e[0]=255;var n=!1;t=t*-1;for(var i=e.length;i>1;i--){var o=t&255;t=Math.floor(t/256),n?e[i-1]=Hl(o):o===0?e[i-1]=0:(n=!0,e[i-1]=Gl(o))}},mm=t=>{let e=t[0],n=e===128?_m(t.subarray(1,t.length)):e===255?wm(t):null;if(n===null)throw Error("invalid base256 encoding");if(!Number.isSafeInteger(n))throw Error("parsed number outside of javascript safe integer range");return n},wm=t=>{for(var e=t.length,n=0,i=!1,o=e-1;o>-1;o--){var c=Number(t[o]),l;i?l=Hl(c):c===0?l=c:(i=!0,l=Gl(c)),l!==0&&(n-=l*Math.pow(256,e-o-1))}return n},_m=t=>{for(var e=t.length,n=0,i=e-1;i>-1;i--){var o=Number(t[i]);o!==0&&(n+=o*Math.pow(256,e-i-1))}return n},Hl=t=>(255^t)&255,Gl=t=>(255^t)+1&255,ym={};Pg(ym,{code:()=>Tc,isCode:()=>Ps,isName:()=>Em,name:()=>Js});var Ps=t=>Js.has(t),Em=t=>Tc.has(t),Js=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"]]),Tc=new Map(Array.from(Js).map(t=>[t[1],t[0]])),Hn=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,n,i){Buffer.isBuffer(t)?this.decode(t,e||0,n,i):t&&this.#n(t)}decode(t,e,n,i){if(e||(e=0),!t||!(t.length>=e+512))throw new Error("need 512 bytes for header");this.path=n?.path??Pn(t,e,100),this.mode=n?.mode??i?.mode??hn(t,e+100,8),this.uid=n?.uid??i?.uid??hn(t,e+108,8),this.gid=n?.gid??i?.gid??hn(t,e+116,8),this.size=n?.size??i?.size??hn(t,e+124,12),this.mtime=n?.mtime??i?.mtime??Ha(t,e+136,12),this.cksum=hn(t,e+148,12),i&&this.#n(i,!0),n&&this.#n(n);let o=Pn(t,e+156,1);if(Ps(o)&&(this.#e=o||"0"),this.#e==="0"&&this.path.slice(-1)==="/"&&(this.#e="5"),this.#e==="5"&&(this.size=0),this.linkpath=Pn(t,e+157,100),t.subarray(e+257,e+265).toString()==="ustar\x0000")if(this.uname=n?.uname??i?.uname??Pn(t,e+265,32),this.gname=n?.gname??i?.gname??Pn(t,e+297,32),this.devmaj=n?.devmaj??i?.devmaj??hn(t,e+329,8)??0,this.devmin=n?.devmin??i?.devmin??hn(t,e+337,8)??0,t[e+475]!==0){let l=Pn(t,e+345,155);this.path=l+"/"+this.path}else{let l=Pn(t,e+345,130);l&&(this.path=l+"/"+this.path),this.atime=n?.atime??i?.atime??Ha(t,e+476,12),this.ctime=n?.ctime??i?.ctime??Ha(t,e+488,12)}let c=256;for(let l=e;l<e+148;l++)c+=t[l];for(let l=e+156;l<e+512;l++)c+=t[l];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(([n,i])=>!(i==null||n==="path"&&e||n==="linkpath"&&e||n==="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 n=this.ctime||this.atime?130:155,i=bm(this.path||"",n),o=i[0],c=i[1];this.needPax=!!i[2],this.needPax=On(t,e,100,o)||this.needPax,this.needPax=pn(t,e+100,8,this.mode)||this.needPax,this.needPax=pn(t,e+108,8,this.uid)||this.needPax,this.needPax=pn(t,e+116,8,this.gid)||this.needPax,this.needPax=pn(t,e+124,12,this.size)||this.needPax,this.needPax=Ga(t,e+136,12,this.mtime)||this.needPax,t[e+156]=Number(this.#e.codePointAt(0)),this.needPax=On(t,e+157,100,this.linkpath)||this.needPax,t.write("ustar\x0000",e+257,8),this.needPax=On(t,e+265,32,this.uname)||this.needPax,this.needPax=On(t,e+297,32,this.gname)||this.needPax,this.needPax=pn(t,e+329,8,this.devmaj)||this.needPax,this.needPax=pn(t,e+337,8,this.devmin)||this.needPax,this.needPax=On(t,e+345,n,c)||this.needPax,t[e+475]!==0?this.needPax=On(t,e+345,155,c)||this.needPax:(this.needPax=On(t,e+345,130,c)||this.needPax,this.needPax=Ga(t,e+476,12,this.atime)||this.needPax,this.needPax=Ga(t,e+488,12,this.ctime)||this.needPax);let l=256;for(let f=e;f<e+148;f++)l+=t[f];for(let f=e+156;f<e+512;f++)l+=t[f];return this.cksum=l,pn(t,e+148,8,this.cksum),this.cksumValid=!0,this.needPax}get type(){return this.#e==="Unsupported"?this.#e:Js.get(this.#e)}get typeKey(){return this.#e}set type(t){let e=String(Tc.get(t));if(Ps(e)||e==="Unsupported")this.#e=e;else if(Ps(t))this.#e=t;else throw new TypeError("invalid entry type: "+t)}},bm=(t,e)=>{let n=t,i="",o,c=fr.parse(t).root||".";if(Buffer.byteLength(n)<100)o=[n,i,!1];else{i=fr.dirname(n),n=fr.basename(n);do Buffer.byteLength(n)<=100&&Buffer.byteLength(i)<=e?o=[n,i,!1]:Buffer.byteLength(n)>100&&Buffer.byteLength(i)<=e?o=[n.slice(0,99),i,!0]:(n=fr.join(fr.basename(i),n),i=fr.dirname(i));while(i!==c&&o===void 0);o||(o=[t.slice(0,99),"",!0])}return o},Pn=(t,e,n)=>t.subarray(e,e+n).toString("utf8").replace(/\0.*/,""),Ha=(t,e,n)=>vm(hn(t,e,n)),vm=t=>t===void 0?void 0:new Date(t*1e3),hn=(t,e,n)=>Number(t[e])&128?mm(t.subarray(e,e+n)):Im(t,e,n),Sm=t=>isNaN(t)?void 0:t,Im=(t,e,n)=>Sm(parseInt(t.subarray(e,e+n).toString("utf8").replace(/\0.*$/,"").trim(),8)),Am={12:8589934591,8:2097151},pn=(t,e,n,i)=>i===void 0?!1:i>Am[n]||i<0?(hm(i,t.subarray(e,e+n)),!0):(Tm(t,e,n,i),!1),Tm=(t,e,n,i)=>t.write(Cm(i,n),e,n,"ascii"),Cm=(t,e)=>Dm(Math.floor(t).toString(8),e),Dm=(t,e)=>(t.length===e-1?t:new Array(e-t.length-1).join("0")+t+" ")+"\0",Ga=(t,e,n,i)=>i===void 0?!1:pn(t,e,n,i.getTime()/1e3),Rm=new Array(156).join("\0"),On=(t,e,n,i)=>i===void 0?!1:(t.write(i+Rm,e,n,"utf8"),i.length!==Buffer.byteLength(i)||i.length>n),Hs=class jl{atime;mtime;ctime;charset;comment;gid;uid;gname;uname;linkpath;dev;ino;nlink;path;size;mode;global;constructor(e,n=!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=n,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 n=Buffer.byteLength(e),i=512*Math.ceil(1+n/512),o=Buffer.allocUnsafe(i);for(let c=0;c<512;c++)o[c]=0;new Hn({path:("PaxHeader/"+km(this.path??"")).slice(0,99),mode:this.mode||420,uid:this.uid,gid:this.gid,size:n,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,n,"utf8");for(let c=n+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 n=this[e],i=n instanceof Date?n.getTime()/1e3:n,o=" "+(e==="dev"||e==="ino"||e==="nlink"?"SCHILY.":"")+e+"="+i+`
|
|
90
|
+
`,c=Buffer.byteLength(o),l=Math.floor(Math.log(c)/Math.log(10))+1;return c+l>=Math.pow(10,l)&&(l+=1),l+c+o}static parse(e,n,i=!1){return new jl(Lm(Pm(e),n),i)}},Lm=(t,e)=>e?Object.assign({},e,t):t,Pm=t=>t.replace(/\n$/,"").split(`
|
|
91
|
+
`).reduce(Om,Object.create(null)),Om=(t,e)=>{let n=parseInt(e,10);if(n!==Buffer.byteLength(e)+1)return t;e=e.slice((n+" ").length);let i=e.split("="),o=i.shift();if(!o)return t;let c=o.replace(/^SCHILY\.(dev|ino|nlink)/,"$1"),l=i.join("=");return t[c]=/^([A-Z]+\.)?([mac]|birth|creation)time$/.test(c)?new Date(Number(l)*1e3):/^[0-9]+$/.test(l)?+l:l,t},Nm=process.env.TESTING_TAR_FAKE_PLATFORM||process.platform,Z=Nm!=="win32"?t=>t:t=>t&&t.replaceAll(/\\/g,"/"),Wl=class extends Gn{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,n){switch(super({}),this.pause(),this.extended=e,this.globalExtended=n,this.header=t,this.remain=t.size??0,this.startBlockSize=512*Math.ceil(this.remain/512),this.blockRemain=this.startBlockSize,this.type=t.type,this.type){case"File":case"OldFile":case"Link":case"SymbolicLink":case"CharacterDevice":case"BlockDevice":case"Directory":case"FIFO":case"ContiguousFile":case"GNUDumpDir":break;case"NextFileHasLongLinkpath":case"NextFileHasLongPath":case"OldGnuLongPath":case"GlobalExtendedHeader":case"ExtendedHeader":case"OldExtendedHeader":this.meta=!0;break;default:this.ignore=!0}if(!t.path)throw new Error("no path provided for tar.ReadEntry");this.path=Z(t.path),this.mode=t.mode,this.mode&&(this.mode=this.mode&4095),this.uid=t.uid,this.gid=t.gid,this.uname=t.uname,this.gname=t.gname,this.size=this.remain,this.mtime=t.mtime,this.atime=t.atime,this.ctime=t.ctime,this.linkpath=t.linkpath?Z(t.linkpath):void 0,this.uname=t.uname,this.gname=t.gname,e&&this.#e(e),n&&this.#e(n,!0)}write(t){let e=t.length;if(e>this.blockRemain)throw new Error("writing more to entry than is appropriate");let n=this.remain,i=this.blockRemain;return this.remain=Math.max(0,n-e),this.blockRemain=Math.max(0,i-e),this.ignore?!0:n>=e?super.write(t):super.write(t.subarray(0,n))}#e(t,e=!1){t.path&&(t.path=Z(t.path)),t.linkpath&&(t.linkpath=Z(t.linkpath)),Object.assign(this,Object.fromEntries(Object.entries(t).filter(([n,i])=>!(i==null||n==="path"&&e))))}},Vs=(t,e,n,i={})=>{t.file&&(i.file=t.file),t.cwd&&(i.cwd=t.cwd),i.code=n instanceof Error&&n.code||e,i.tarCode=e,!t.strict&&i.recoverable!==!1?(n instanceof Error&&(i=Object.assign(n,i),n=n.message),t.emit("warn",e,n,i)):n instanceof Error?t.emit("error",Object.assign(n,i)):t.emit("error",Object.assign(new Error(`${e}: ${n}`),i))},Mm=1024*1024,sc=Buffer.from([31,139]),oc=Buffer.from([40,181,47,253]),Bm=Math.max(sc.length,oc.length),lt=Symbol("state"),Nn=Symbol("writeEntry"),jt=Symbol("readEntry"),ja=Symbol("nextEntry"),al=Symbol("processEntry"),Rt=Symbol("extendedHeader"),di=Symbol("globalExtendedHeader"),dn=Symbol("meta"),cl=Symbol("emitMeta"),ge=Symbol("buffer"),Wt=Symbol("queue"),ln=Symbol("ended"),Wa=Symbol("emittedEnd"),Mn=Symbol("emit"),Re=Symbol("unzip"),vs=Symbol("consumeChunk"),Ss=Symbol("consumeChunkSub"),Ka=Symbol("consumeBody"),dl=Symbol("consumeMeta"),ll=Symbol("consumeHeader"),li=Symbol("consuming"),$a=Symbol("bufferConcat"),Is=Symbol("maybeEnd"),ur=Symbol("writing"),fn=Symbol("aborted"),As=Symbol("onDone"),Bn=Symbol("sawValidEntry"),Ts=Symbol("sawNullBlock"),Cs=Symbol("sawEOF"),fl=Symbol("closeStream"),zm=()=>!0,Ai=class extends rm{file;strict;maxMetaEntrySize;filter;brotli;zstd;writable=!0;readable=!1;[Wt]=[];[ge];[jt];[Nn];[lt]="begin";[dn]="";[Rt];[di];[ln]=!1;[Re];[fn]=!1;[Bn];[Ts]=!1;[Cs]=!1;[ur]=!1;[li]=!1;[Wa]=!1;constructor(t={}){super(),this.file=t.file||"",this.on(As,()=>{(this[lt]==="begin"||this[Bn]===!1)&&this.warn("TAR_BAD_ARCHIVE","Unrecognized archive format")}),t.ondone?this.on(As,t.ondone):this.on(As,()=>{this.emit("prefinish"),this.emit("finish"),this.emit("end")}),this.strict=!!t.strict,this.maxMetaEntrySize=t.maxMetaEntrySize||Mm,this.filter=typeof t.filter=="function"?t.filter:zm;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 n=t.file&&(t.file.endsWith(".tar.zst")||t.file.endsWith(".tzst"));this.zstd=!(t.gzip||t.brotli)&&t.zstd!==void 0?t.zstd:n?!0:void 0,this.on("end",()=>this[fl]()),typeof t.onwarn=="function"&&this.on("warn",t.onwarn),typeof t.onReadEntry=="function"&&this.on("entry",t.onReadEntry)}warn(t,e,n={}){Vs(this,t,e,n)}[ll](t,e){this[Bn]===void 0&&(this[Bn]=!1);let n;try{n=new Hn(t,e,this[Rt],this[di])}catch(i){return this.warn("TAR_ENTRY_INVALID",i)}if(n.nullBlock)this[Ts]?(this[Cs]=!0,this[lt]==="begin"&&(this[lt]="header"),this[Mn]("eof")):(this[Ts]=!0,this[Mn]("nullBlock"));else if(this[Ts]=!1,!n.cksumValid)this.warn("TAR_ENTRY_INVALID","checksum failure",{header:n});else if(!n.path)this.warn("TAR_ENTRY_INVALID","path is required",{header:n});else{let i=n.type;if(/^(Symbolic)?Link$/.test(i)&&!n.linkpath)this.warn("TAR_ENTRY_INVALID","linkpath required",{header:n});else if(!/^(Symbolic)?Link$/.test(i)&&!/^(Global)?ExtendedHeader$/.test(i)&&n.linkpath)this.warn("TAR_ENTRY_INVALID","linkpath forbidden",{header:n});else{let o=this[Nn]=new Wl(n,this[Rt],this[di]);if(!this[Bn])if(o.remain){let c=()=>{o.invalid||(this[Bn]=!0)};o.on("end",c)}else this[Bn]=!0;o.meta?o.size>this.maxMetaEntrySize?(o.ignore=!0,this[Mn]("ignoredEntry",o),this[lt]="ignore",o.resume()):o.size>0&&(this[dn]="",o.on("data",c=>this[dn]+=c),this[lt]="meta"):(this[Rt]=void 0,o.ignore=o.ignore||!this.filter(o.path,o),o.ignore?(this[Mn]("ignoredEntry",o),this[lt]=o.remain?"ignore":"header",o.resume()):(o.remain?this[lt]="body":(this[lt]="header",o.end()),this[jt]?this[Wt].push(o):(this[Wt].push(o),this[ja]())))}}}[fl](){queueMicrotask(()=>this.emit("close"))}[al](t){let e=!0;if(!t)this[jt]=void 0,e=!1;else if(Array.isArray(t)){let[n,...i]=t;this.emit(n,...i)}else this[jt]=t,this.emit("entry",t),t.emittedEnd||(t.on("end",()=>this[ja]()),e=!1);return e}[ja](){do;while(this[al](this[Wt].shift()));if(this[Wt].length===0){let t=this[jt];!t||t.flowing||t.size===t.remain?this[ur]||this.emit("drain"):t.once("drain",()=>this.emit("drain"))}}[Ka](t,e){let n=this[Nn];if(!n)throw new Error("attempt to consume body without entry??");let i=n.blockRemain??0,o=i>=t.length&&e===0?t:t.subarray(e,e+i);return n.write(o),n.blockRemain||(this[lt]="header",this[Nn]=void 0,n.end()),o.length}[dl](t,e){let n=this[Nn],i=this[Ka](t,e);return!this[Nn]&&n&&this[cl](n),i}[Mn](t,e,n){this[Wt].length===0&&!this[jt]?this.emit(t,e,n):this[Wt].push([t,e,n])}[cl](t){switch(this[Mn]("meta",this[dn]),t.type){case"ExtendedHeader":case"OldExtendedHeader":this[Rt]=Hs.parse(this[dn],this[Rt],!1);break;case"GlobalExtendedHeader":this[di]=Hs.parse(this[dn],this[di],!0);break;case"NextFileHasLongPath":case"OldGnuLongPath":{let e=this[Rt]??Object.create(null);this[Rt]=e,e.path=this[dn].replace(/\0.*/,"");break}case"NextFileHasLongLinkpath":{let e=this[Rt]||Object.create(null);this[Rt]=e,e.linkpath=this[dn].replace(/\0.*/,"");break}default:throw new Error("unknown meta: "+t.type)}}abort(t){this[fn]=!0,this.emit("abort",t),this.warn("TAR_ABORT",t,{recoverable:!1})}write(t,e,n){if(typeof e=="function"&&(n=e,e=void 0),typeof t=="string"&&(t=Buffer.from(t,typeof e=="string"?e:"utf8")),this[fn])return n?.(),!1;if((this[Re]===void 0||this.brotli===void 0&&this[Re]===!1)&&t){if(this[ge]&&(t=Buffer.concat([this[ge],t]),this[ge]=void 0),t.length<Bm)return this[ge]=t,n?.(),!0;for(let l=0;this[Re]===void 0&&l<sc.length;l++)t[l]!==sc[l]&&(this[Re]=!1);let o=!1;if(this[Re]===!1&&this.zstd!==!1){o=!0;for(let l=0;l<oc.length;l++)if(t[l]!==oc[l]){o=!1;break}}let c=this.brotli===void 0&&!o;if(this[Re]===!1&&c)if(t.length<512)if(this[ln])this.brotli=!0;else return this[ge]=t,n?.(),!0;else try{new Hn(t.subarray(0,512)),this.brotli=!1}catch{this.brotli=!0}if(this[Re]===void 0||this[Re]===!1&&(this.brotli||o)){let l=this[ln];this[ln]=!1,this[Re]=this[Re]===void 0?new dm({}):o?new xm({}):new fm({}),this[Re].on("data",x=>this[vs](x)),this[Re].on("error",x=>this.abort(x)),this[Re].on("end",()=>{this[ln]=!0,this[vs]()}),this[ur]=!0;let f=!!this[Re][l?"end":"write"](t);return this[ur]=!1,n?.(),f}}this[ur]=!0,this[Re]?this[Re].write(t):this[vs](t),this[ur]=!1;let i=this[Wt].length>0?!1:this[jt]?this[jt].flowing:!0;return!i&&this[Wt].length===0&&this[jt]?.once("drain",()=>this.emit("drain")),n?.(),i}[$a](t){t&&!this[fn]&&(this[ge]=this[ge]?Buffer.concat([this[ge],t]):t)}[Is](){if(this[ln]&&!this[Wa]&&!this[fn]&&!this[li]){this[Wa]=!0;let t=this[Nn];if(t&&t.blockRemain){let e=this[ge]?this[ge].length:0;this.warn("TAR_BAD_ARCHIVE",`Truncated input (needed ${t.blockRemain} more bytes, only ${e} available)`,{entry:t}),this[ge]&&t.write(this[ge]),t.end()}this[Mn](As)}}[vs](t){if(this[li]&&t)this[$a](t);else if(!t&&!this[ge])this[Is]();else if(t){if(this[li]=!0,this[ge]){this[$a](t);let e=this[ge];this[ge]=void 0,this[Ss](e)}else this[Ss](t);for(;this[ge]&&this[ge]?.length>=512&&!this[fn]&&!this[Cs];){let e=this[ge];this[ge]=void 0,this[Ss](e)}this[li]=!1}(!this[ge]||this[ln])&&this[Is]()}[Ss](t){let e=0,n=t.length;for(;e+512<=n&&!this[fn]&&!this[Cs];)switch(this[lt]){case"begin":case"header":this[ll](t,e),e+=512;break;case"ignore":case"body":e+=this[Ka](t,e);break;case"meta":e+=this[dl](t,e);break;default:throw new Error("invalid state: "+this[lt])}e<n&&(this[ge]=this[ge]?Buffer.concat([t.subarray(e),this[ge]]):t.subarray(e))}end(t,e,n){return typeof t=="function"&&(n=t,e=void 0,t=void 0),typeof e=="function"&&(n=e,e=void 0),typeof t=="string"&&(t=Buffer.from(t,e)),n&&this.once("finish",n),this[fn]||(this[Re]?(t&&this[Re].write(t),this[Re].end()):(this[ln]=!0,(this.brotli===void 0||this.zstd===void 0)&&(t=t||Buffer.alloc(0)),t&&this.write(t),this[Is]())),this}},_i=t=>{let e=t.length-1,n=-1;for(;e>-1&&t.charAt(e)==="/";)n=e,e--;return n===-1?t:t.slice(0,n)},Fm=t=>{let e=t.onReadEntry;t.onReadEntry=e?n=>{e(n),n.resume()}:n=>n.resume()},Kl=(t,e)=>{let n=new Map(e.map(c=>[_i(c),!0])),i=t.filter,o=(c,l="")=>{let f=l||Vg(c).root||".",x;if(c===f)x=!1;else{let p=n.get(c);x=p!==void 0?p:o(Jg(c),f)}return n.set(c,x),x};t.filter=i?(c,l)=>i(c,l)&&o(_i(c)):c=>o(_i(c))},Um=t=>{let e=new Ai(t),n=t.file,i;try{i=wr.openSync(n,"r");let o=wr.fstatSync(i),c=t.maxReadSize||16*1024*1024;if(o.size<c){let l=Buffer.allocUnsafe(o.size),f=wr.readSync(i,l,0,o.size,0);e.end(f===l.byteLength?l:l.subarray(0,f))}else{let l=0,f=Buffer.allocUnsafe(c);for(;l<o.size;){let x=wr.readSync(i,f,0,c,l);if(x===0)break;l+=x,e.write(f.subarray(0,x))}e.end()}}finally{if(typeof i=="number")try{wr.closeSync(i)}catch{}}},qm=(t,e)=>{let n=new Ai(t),i=t.maxReadSize||16*1024*1024,o=t.file;return new Promise((c,l)=>{n.on("error",l),n.on("end",c),wr.stat(o,(f,x)=>{if(f)l(f);else{let p=new Sc(o,{readSize:i,size:x.size});p.on("error",l),p.pipe(n)}})})},br=Ti(Um,qm,t=>new Ai(t),t=>new Ai(t),(t,e)=>{e?.length&&Kl(t,e),t.noResume||Fm(t)}),$l=(t,e,n)=>(t&=4095,n&&(t=(t|384)&-19),e&&(t&256&&(t|=64),t&32&&(t|=8),t&4&&(t|=1)),t),{isAbsolute:Gm,parse:xl}=Hm,Cc=t=>{let e="",n=xl(t);for(;Gm(t)||n.root;){let i=t.charAt(0)==="/"&&t.slice(0,4)!=="//?/"?"/":n.root;t=t.slice(i.length),e+=i,n=xl(t)}return[e,t]},Zs=["|","<",">","?",":"],Dc=Zs.map(t=>String.fromCodePoint(61440+Number(t.codePointAt(0)))),jm=new Map(Zs.map((t,e)=>[t,Dc[e]])),Wm=new Map(Dc.map((t,e)=>[t,Zs[e]])),hl=t=>Zs.reduce((e,n)=>e.split(n).join(jm.get(n)),t),Km=t=>Dc.reduce((e,n)=>e.split(n).join(Wm.get(n)),t),Jl=(t,e)=>e?(t=Z(t).replace(/^\.(\/|$)/,""),_i(e)+"/"+t):Z(t),$m=16*1024*1024,pl=Symbol("process"),gl=Symbol("file"),ml=Symbol("directory"),ac=Symbol("symlink"),wl=Symbol("hardlink"),fi=Symbol("header"),Os=Symbol("read"),cc=Symbol("lstat"),Ns=Symbol("onlstat"),dc=Symbol("onread"),lc=Symbol("onreadlink"),fc=Symbol("openfile"),uc=Symbol("onopenfile"),gn=Symbol("close"),js=Symbol("mode"),xc=Symbol("awaitDrain"),Ja=Symbol("ondrain"),Lt=Symbol("prefix"),Vl=class extends Gn{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 n=Ic(e);super(),this.path=Z(t),this.portable=!!n.portable,this.maxReadSize=n.maxReadSize||$m,this.linkCache=n.linkCache||new Map,this.statCache=n.statCache||new Map,this.preservePaths=!!n.preservePaths,this.cwd=Z(n.cwd||process.cwd()),this.strict=!!n.strict,this.noPax=!!n.noPax,this.noMtime=!!n.noMtime,this.mtime=n.mtime,this.prefix=n.prefix?Z(n.prefix):void 0,this.onWriteEntry=n.onWriteEntry,typeof n.onwarn=="function"&&this.on("warn",n.onwarn);let i=!1;if(!this.preservePaths){let[c,l]=Cc(this.path);c&&typeof l=="string"&&(this.path=l,i=c)}this.win32=!!n.win32||process.platform==="win32",this.win32&&(this.path=Km(this.path.replaceAll(/\\/g,"/")),t=t.replaceAll(/\\/g,"/")),this.absolute=Z(n.absolute||ul.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[Ns](o):this[cc]()}warn(t,e,n={}){return Vs(this,t,e,n)}emit(t,...e){return t==="error"&&(this.#e=!0),super.emit(t,...e)}[cc](){kt.lstat(this.absolute,(t,e)=>{if(t)return this.emit("error",t);this[Ns](e)})}[Ns](t){this.statCache.set(this.absolute,t),this.stat=t,t.isFile()||(t.size=0),this.type=Zm(t),this.emit("stat",t),this[pl]()}[pl](){switch(this.type){case"File":return this[gl]();case"Directory":return this[ml]();case"SymbolicLink":return this[ac]();default:return this.end()}}[js](t){return $l(t,this.type==="Directory",this.portable)}[Lt](t){return Jl(t,this.prefix)}[fi](){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 Hn({path:this[Lt](this.path),linkpath:this.type==="Link"&&this.linkpath!==void 0?this[Lt](this.linkpath):this.linkpath,mode:this[js](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 Hs({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[Lt](this.path),linkpath:this.type==="Link"&&this.linkpath!==void 0?this[Lt](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)}[ml](){if(!this.stat)throw new Error("cannot create directory entry without stat");this.path.slice(-1)!=="/"&&(this.path+="/"),this.stat.size=0,this[fi](),this.end()}[ac](){kt.readlink(this.absolute,(t,e)=>{if(t)return this.emit("error",t);this[lc](e)})}[lc](t){this.linkpath=Z(t),this[fi](),this.end()}[wl](t){if(!this.stat)throw new Error("cannot create link entry without stat");this.type="Link",this.linkpath=Z(ul.relative(this.cwd,t)),this.stat.size=0,this[fi](),this.end()}[gl](){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[wl](e);this.linkCache.set(t,this.absolute)}if(this[fi](),this.stat.size===0)return this.end();this[fc]()}[fc](){kt.open(this.absolute,"r",(t,e)=>{if(t)return this.emit("error",t);this[uc](e)})}[uc](t){if(this.fd=t,this.#e)return this[gn]();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[Os]()}[Os](){let{fd:t,buf:e,offset:n,length:i,pos:o}=this;if(t===void 0||e===void 0)throw new Error("cannot read file without first opening");kt.read(t,e,n,i,o,(c,l)=>{if(c)return this[gn](()=>this.emit("error",c));this[dc](l)})}[gn](t=()=>{}){this.fd!==void 0&&kt.close(this.fd,t)}[dc](t){if(t<=0&&this.remain>0){let n=Object.assign(new Error("encountered unexpected EOF"),{path:this.absolute,syscall:"read",code:"EOF"});return this[gn](()=>this.emit("error",n))}if(t>this.remain){let n=Object.assign(new Error("did not encounter expected EOF"),{path:this.absolute,syscall:"read",code:"EOF"});return this[gn](()=>this.emit("error",n))}if(!this.buf)throw new Error("should have created buffer prior to reading");if(t===this.remain)for(let n=t;n<this.length&&t<this.blockRemain;n++)this.buf[n+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[Ja]():this[xc](()=>this[Ja]())}[xc](t){this.once("drain",t)}write(t,e,n){if(typeof e=="function"&&(n=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,n)}[Ja](){if(!this.remain)return this.blockRemain&&super.write(Buffer.alloc(this.blockRemain)),this[gn](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[Os]()}},Jm=class extends Vl{sync=!0;[cc](){this[Ns](kt.lstatSync(this.absolute))}[ac](){this[lc](kt.readlinkSync(this.absolute))}[fc](){this[uc](kt.openSync(this.absolute,"r"))}[Os](){let t=!0;try{let{fd:e,buf:n,offset:i,length:o,pos:c}=this;if(e===void 0||n===void 0)throw new Error("fd and buf must be set in READ method");let l=kt.readSync(e,n,i,o,c);this[dc](l),t=!1}finally{if(t)try{this[gn](()=>{})}catch{}}}[xc](t){t()}[gn](t=()=>{}){this.fd!==void 0&&kt.closeSync(this.fd),t()}},Vm=class extends Gn{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,n={}){return Vs(this,t,e,n)}constructor(t,e={}){let n=Ic(e);super(),this.preservePaths=!!n.preservePaths,this.portable=!!n.portable,this.strict=!!n.strict,this.noPax=!!n.noPax,this.noMtime=!!n.noMtime,this.onWriteEntry=n.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=n.prefix,this.path=Z(t.path),this.mode=t.mode!==void 0?this[js](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:n.mtime||t.mtime,this.atime=this.portable?void 0:t.atime,this.ctime=this.portable?void 0:t.ctime,this.linkpath=t.linkpath!==void 0?Z(t.linkpath):void 0,typeof n.onwarn=="function"&&this.on("warn",n.onwarn);let o=!1;if(!this.preservePaths){let[l,f]=Cc(this.path);l&&typeof f=="string"&&(this.path=f,o=l)}this.remain=t.size,this.blockRemain=t.startBlockSize,this.onWriteEntry?.(this),this.header=new Hn({path:this[Lt](this.path),linkpath:this.type==="Link"&&this.linkpath!==void 0?this[Lt](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 Hs({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[Lt](this.path),linkpath:this.type==="Link"&&this.linkpath!==void 0?this[Lt](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)}[Lt](t){return Jl(t,this.prefix)}[js](t){return $l(t,this.type==="Directory",this.portable)}write(t,e,n){typeof e=="function"&&(n=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,n)}end(t,e,n){return this.blockRemain&&super.write(Buffer.alloc(this.blockRemain)),typeof t=="function"&&(n=t,e=void 0,t=void 0),typeof e=="function"&&(n=e,e=void 0),typeof t=="string"&&(t=Buffer.from(t,e??"utf8")),n&&this.once("finish",n),t?super.end(t,n):super.end(n),this}},Zm=t=>t.isFile()?"File":t.isDirectory()?"Directory":t.isSymbolicLink()?"SymbolicLink":"Unsupported",Xm=class _r{tail;head;length=0;static create(e=[]){return new _r(e)}constructor(e=[]){for(let n of e)this.push(n)}*[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 n=e.next,i=e.prev;return n&&(n.prev=i),i&&(i.next=n),e===this.head&&(this.head=n),e===this.tail&&(this.tail=i),this.length--,e.next=void 0,e.prev=void 0,e.list=void 0,n}unshiftNode(e){if(e===this.head)return;e.list&&e.list.removeNode(e);let n=this.head;e.list=this,e.next=n,n&&(n.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 n=this.tail;e.list=this,e.prev=n,n&&(n.next=e),this.tail=e,this.head||(this.head=e),this.length++}push(...e){for(let n=0,i=e.length;n<i;n++)Qm(this,e[n]);return this.length}unshift(...e){for(var n=0,i=e.length;n<i;n++)ew(this,e[n]);return this.length}pop(){if(!this.tail)return;let e=this.tail.value,n=this.tail;return this.tail=this.tail.prev,this.tail?this.tail.next=void 0:this.head=void 0,n.list=void 0,this.length--,e}shift(){if(!this.head)return;let e=this.head.value,n=this.head;return this.head=this.head.next,this.head?this.head.prev=void 0:this.tail=void 0,n.list=void 0,this.length--,e}forEach(e,n){n=n||this;for(let i=this.head,o=0;i;o++)e.call(n,i.value,o,this),i=i.next}forEachReverse(e,n){n=n||this;for(let i=this.tail,o=this.length-1;i;o--)e.call(n,i.value,o,this),i=i.prev}get(e){let n=0,i=this.head;for(;i&&n<e;n++)i=i.next;if(n===e&&i)return i.value}getReverse(e){let n=0,i=this.tail;for(;i&&n<e;n++)i=i.prev;if(n===e&&i)return i.value}map(e,n){n=n||this;let i=new _r;for(let o=this.head;o;)i.push(e.call(n,o.value,this)),o=o.next;return i}mapReverse(e,n){n=n||this;var i=new _r;for(let o=this.tail;o;)i.push(e.call(n,o.value,this)),o=o.prev;return i}reduce(e,n){let i,o=this.head;if(arguments.length>1)i=n;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,n){let i,o=this.tail;if(arguments.length>1)i=n;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 n=0,i=this.head;i;n++)e[n]=i.value,i=i.next;return e}toArrayReverse(){let e=new Array(this.length);for(let n=0,i=this.tail;i;n++)e[n]=i.value,i=i.prev;return e}slice(e=0,n=this.length){n<0&&(n+=this.length),e<0&&(e+=this.length);let i=new _r;if(n<e||n<0)return i;e<0&&(e=0),n>this.length&&(n=this.length);let o=this.head,c=0;for(c=0;o&&c<e;c++)o=o.next;for(;o&&c<n;c++,o=o.next)i.push(o.value);return i}sliceReverse(e=0,n=this.length){n<0&&(n+=this.length),e<0&&(e+=this.length);let i=new _r;if(n<e||n<0)return i;e<0&&(e=0),n>this.length&&(n=this.length);let o=this.length,c=this.tail;for(;c&&o>n;o--)c=c.prev;for(;c&&o>e;o--,c=c.prev)i.push(c.value);return i}splice(e,n=0,...i){e>this.length&&(e=this.length-1),e<0&&(e=this.length+e);let o=this.head;for(let l=0;o&&l<e;l++)o=o.next;let c=[];for(let l=0;o&&l<n;l++)c.push(o.value),o=this.removeNode(o);o?o!==this.tail&&(o=o.prev):o=this.tail;for(let l of i)o=Ym(this,o,l);return c}reverse(){let e=this.head,n=this.tail;for(let i=e;i;i=i.prev){let o=i.prev;i.prev=i.next,i.next=o}return this.head=n,this.tail=e,this}};function Ym(t,e,n){let i=e,o=e?e.next:t.head,c=new Rc(n,i,o,t);return c.next===void 0&&(t.tail=c),c.prev===void 0&&(t.head=c),t.length++,c}function Qm(t,e){t.tail=new Rc(e,t.tail,void 0,t),t.head||(t.head=t.tail),t.length++}function ew(t,e){t.head=new Rc(e,void 0,t.head,t),t.tail||(t.tail=t.head),t.length++}var Rc=class{list;next;prev;value;constructor(t,e,n,i){this.list=i,this.value=t,e?(e.next=this,this.prev=e):this.prev=void 0,n?(n.prev=this,this.next=n):this.next=void 0}},yl=class{path;absolute;entry;stat;readdir;pending=!1;pendingLink=!1;ignore=!1;piped=!1;constructor(t,e){this.path=t||"./",this.absolute=e}},El=Buffer.alloc(1024),Ms=Symbol("onStat"),ui=Symbol("ended"),_t=Symbol("queue"),xi=Symbol("queue"),un=Symbol("current"),zn=Symbol("process"),hi=Symbol("processing"),Ds=Symbol("processJob"),yt=Symbol("jobs"),Va=Symbol("jobDone"),Bs=Symbol("addFSEntry"),bl=Symbol("addTarEntry"),hc=Symbol("stat"),pc=Symbol("readdir"),zs=Symbol("onreaddir"),Fs=Symbol("pipe"),vl=Symbol("entry"),Za=Symbol("entryOpt"),Us=Symbol("writeEntryClass"),Zl=Symbol("write"),Xa=Symbol("ondrain"),Xs=class extends Gn{sync=!1;opt;cwd;maxReadSize;preservePaths;strict;noPax;prefix;linkCache;statCache;file;portable;zip;readdirCache;noDirRecurse;follow;noMtime;mtime;filter;jobs;[Us];onWriteEntry;[_t];[xi]=new Map;[yt]=0;[hi]=!1;[ui]=!1;constructor(t={}){if(super(),this.opt=t,this.file=t.file||"",this.cwd=t.cwd||process.cwd(),this.maxReadSize=t.maxReadSize,this.preservePaths=!!t.preservePaths,this.strict=!!t.strict,this.noPax=!!t.noPax,this.prefix=Z(t.prefix||""),this.linkCache=t.linkCache||new Map,this.statCache=t.statCache||new Map,this.readdirCache=t.readdirCache||new Map,this.onWriteEntry=t.onWriteEntry,this[Us]=Vl,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 cm(t.gzip)),t.brotli&&(typeof t.brotli!="object"&&(t.brotli={}),this.zip=new lm(t.brotli)),t.zstd&&(typeof t.zstd!="object"&&(t.zstd={}),this.zip=new um(t.zstd)),!this.zip)throw new Error("impossible");let e=this.zip;e.on("data",n=>super.write(n)),e.on("end",()=>super.end()),e.on("drain",()=>this[Xa]()),this.on("resume",()=>e.resume())}else this.on("drain",this[Xa]);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[_t]=new Xm,this[yt]=0,this.jobs=Number(t.jobs)||4,this[hi]=!1,this[ui]=!1}[Zl](t){return super.write(t)}add(t){return this.write(t),this}end(t,e,n){return typeof t=="function"&&(n=t,t=void 0),typeof e=="function"&&(n=e,e=void 0),t&&this.add(t),this[ui]=!0,this[zn](),n&&n(),this}write(t){if(this[ui])throw new Error("write after end");return t instanceof Wl?this[bl](t):this[Bs](t),this.flowing}[bl](t){let e=Z(_l.resolve(this.cwd,t.path));if(!this.filter(t.path,t))t.resume();else{let n=new yl(t.path,e);n.entry=new Vm(t,this[Za](n)),n.entry.on("end",()=>this[Va](n)),this[yt]+=1,this[_t].push(n)}this[zn]()}[Bs](t){let e=Z(_l.resolve(this.cwd,t));this[_t].push(new yl(t,e)),this[zn]()}[hc](t){t.pending=!0,this[yt]+=1;let e=this.follow?"stat":"lstat";Gs[e](t.absolute,(n,i)=>{t.pending=!1,this[yt]-=1,n?this.emit("error",n):this[Ms](t,i)})}[Ms](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[un])this[Ds](t);else{let n=`${e.dev}:${e.ino}`,i=this[xi].get(n);i?i.push(t):this[xi].set(n,[t]),t.pendingLink=!0,t.pending=!0}this[zn]()}[pc](t){t.pending=!0,this[yt]+=1,Gs.readdir(t.absolute,(e,n)=>{if(t.pending=!1,this[yt]-=1,e)return this.emit("error",e);this[zs](t,n)})}[zs](t,e){this.readdirCache.set(t.absolute,e),t.readdir=e,this[zn]()}[zn](){if(!this[hi]){this[hi]=!0;for(let t=this[_t].head;t&&this[yt]<this.jobs;t=t.next)if(this[Ds](t.value),t.value.ignore){let e=t.next;this[_t].removeNode(t),t.next=e}this[hi]=!1,this[ui]&&this[_t].length===0&&this[yt]===0&&(this.zip?this.zip.end(El):(super.write(El),super.end()))}}get[un](){return this[_t]&&this[_t].head&&this[_t].head.value}[Va](t){this[_t].shift(),this[yt]-=1;let{stat:e}=t;if(e&&e.isFile()&&e.nlink>1){let n=`${e.dev}:${e.ino}`,i=this[xi].get(n);if(i){this[xi].delete(n);for(let o of i)o.pending=!1,this[Ds](o)}}this[zn]()}[Ds](t){if(t.pending&&t.pendingLink&&t===this[un]&&(t.pending=!1,t.pendingLink=!1),!t.pending){if(t.entry){t===this[un]&&!t.piped&&this[Fs](t);return}if(!t.stat){let e=this.statCache.get(t.absolute);e?this[Ms](t,e):this[hc](t)}if(t.stat&&!t.ignore){if(!this.noDirRecurse&&t.stat.isDirectory()&&!t.readdir){let e=this.readdirCache.get(t.absolute);if(e?this[zs](t,e):this[pc](t),!t.readdir)return}if(t.entry=this[vl](t),!t.entry){t.ignore=!0;return}t===this[un]&&!t.piped&&this[Fs](t)}}}[Za](t){return{onwarn:(e,n,i)=>this.warn(e,n,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}}[vl](t){this[yt]+=1;try{return new this[Us](t.path,this[Za](t)).on("end",()=>this[Va](t)).on("error",e=>this.emit("error",e))}catch(e){this.emit("error",e)}}[Xa](){this[un]&&this[un].entry&&this[un].entry.resume()}[Fs](t){t.piped=!0,t.readdir&&t.readdir.forEach(i=>{let o=t.path,c=o==="./"?"":o.replace(/\/*$/,"/");this[Bs](c+i)});let e=t.entry,n=this.zip;if(!e)throw new Error("cannot pipe without source");n?e.on("data",i=>{n.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,n={}){Vs(this,t,e,n)}},kc=class extends Xs{sync=!0;constructor(t){super(t),this[Us]=Jm}pause(){}resume(){}[hc](t){let e=this.follow?"statSync":"lstatSync";this[Ms](t,Gs[e](t.absolute))}[pc](t){this[zs](t,Gs.readdirSync(t.absolute))}[Fs](t){let e=t.entry,n=this.zip;if(t.readdir&&t.readdir.forEach(i=>{let o=t.path,c=o==="./"?"":o.replace(/\/*$/,"/");this[Bs](c+i)}),!e)throw new Error("Cannot pipe without source");n?e.on("data",i=>{n.write(i)}):e.on("data",i=>{super[Zl](i)})}},tw=(t,e)=>{let n=new kc(t),i=new Bl(t.file,{mode:t.mode||438});n.pipe(i),Xl(n,e)},nw=(t,e)=>{let n=new Xs(t),i=new $s(t.file,{mode:t.mode||438});n.pipe(i);let o=new Promise((c,l)=>{i.on("error",l),i.on("close",c),n.on("error",l)});return Yl(n,e).catch(c=>n.emit("error",c)),o},Xl=(t,e)=>{e.forEach(n=>{n.charAt(0)==="@"?br({file:zl.resolve(t.cwd,n.slice(1)),sync:!0,noResume:!0,onReadEntry:i=>t.add(i)}):t.add(n)}),t.end()},Yl=async(t,e)=>{for(let n of e)n.charAt(0)==="@"?await br({file:zl.resolve(String(t.cwd),n.slice(1)),noResume:!0,onReadEntry:i=>{t.add(i)}}):t.add(n);t.end()},rw=(t,e)=>{let n=new kc(t);return Xl(n,e),n},iw=(t,e)=>{let n=new Xs(t);return Yl(n,e).catch(i=>n.emit("error",i)),n},c2=Ti(tw,nw,rw,iw,(t,e)=>{if(!e?.length)throw new TypeError("no paths specified to add to archive")}),ow=process.env.__FAKE_PLATFORM__||process.platform,nf=ow==="win32",{O_CREAT:rf,O_NOFOLLOW:Sl,O_TRUNC:sf,O_WRONLY:of}=tf.constants,af=Number(process.env.__FAKE_FS_O_FILENAME__)||tf.constants.UV_FS_O_FILEMAP||0,aw=nf&&!!af,cw=512*1024,dw=af|sf|rf|of,Il=!nf&&typeof Sl=="number"?Sl|sf|rf|of:null,cf=Il!==null?()=>Il:aw?t=>t<cw?dw:"w":()=>"w",gc=(t,e,n)=>{try{return Ys.lchownSync(t,e,n)}catch(i){if(i?.code!=="ENOENT")throw i}},Ws=(t,e,n,i)=>{Ys.lchown(t,e,n,o=>{i(o&&o?.code!=="ENOENT"?o:null)})},lw=(t,e,n,i,o)=>{if(e.isDirectory())df(yi.resolve(t,e.name),n,i,c=>{if(c)return o(c);let l=yi.resolve(t,e.name);Ws(l,n,i,o)});else{let c=yi.resolve(t,e.name);Ws(c,n,i,o)}},df=(t,e,n,i)=>{Ys.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 Ws(t,e,n,i);let l=c.length,f=null,x=p=>{if(!f){if(p)return i(f=p);if(--l===0)return Ws(t,e,n,i)}};for(let p of c)lw(t,p,e,n,x)})},fw=(t,e,n,i)=>{e.isDirectory()&&lf(yi.resolve(t,e.name),n,i),gc(yi.resolve(t,e.name),n,i)},lf=(t,e,n)=>{let i;try{i=Ys.readdirSync(t,{withFileTypes:!0})}catch(o){let c=o;if(c?.code==="ENOENT")return;if(c?.code==="ENOTDIR"||c?.code==="ENOTSUP")return gc(t,e,n);throw c}for(let o of i)fw(t,o,e,n);return gc(t,e,n)},ff=class extends Error{path;code;syscall="chdir";constructor(t,e){super(`${e}: Cannot cd into '${t}'`),this.path=t,this.code=e}get name(){return"CwdError"}},Qs=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"}},xw=(t,e)=>{at.stat(t,(n,i)=>{(n||!i.isDirectory())&&(n=new ff(t,n?.code||"ENOTDIR")),e(n)})},hw=(t,e,n)=>{t=Z(t);let i=e.umask??18,o=e.mode|448,c=(o&i)!==0,l=e.uid,f=e.gid,x=typeof l=="number"&&typeof f=="number"&&(l!==e.processUid||f!==e.processGid),p=e.preserve,w=e.unlink,v=Z(e.cwd),T=(b,S)=>{b?n(b):S&&x?df(S,l,f,A=>T(A)):c?at.chmod(t,o,n):n()};if(t===v)return xw(t,T);if(p)return uw.mkdir(t,{mode:o,recursive:!0}).then(b=>T(null,b??void 0),T);let y=Z(Ks.relative(v,t)).split("/");mc(v,y,o,w,v,void 0,T)},mc=(t,e,n,i,o,c,l)=>{if(e.length===0)return l(null,c);let f=e.shift(),x=Z(Ks.resolve(t+"/"+f));at.mkdir(x,n,uf(x,e,n,i,o,c,l))},uf=(t,e,n,i,o,c,l)=>f=>{f?at.lstat(t,(x,p)=>{if(x)x.path=x.path&&Z(x.path),l(x);else if(p.isDirectory())mc(t,e,n,i,o,c,l);else if(i)at.unlink(t,w=>{if(w)return l(w);at.mkdir(t,n,uf(t,e,n,i,o,c,l))});else{if(p.isSymbolicLink())return l(new Qs(t,t+"/"+e.join("/")));l(f)}}):(c=c||t,mc(t,e,n,i,o,c,l))},pw=t=>{let e=!1,n;try{e=at.statSync(t).isDirectory()}catch(i){n=i?.code}finally{if(!e)throw new ff(t,n??"ENOTDIR")}},gw=(t,e)=>{t=Z(t);let n=e.umask??18,i=e.mode|448,o=(i&n)!==0,c=e.uid,l=e.gid,f=typeof c=="number"&&typeof l=="number"&&(c!==e.processUid||l!==e.processGid),x=e.preserve,p=e.unlink,w=Z(e.cwd),v=b=>{b&&f&&lf(b,c,l),o&&at.chmodSync(t,i)};if(t===w)return pw(w),v();if(x)return v(at.mkdirSync(t,{mode:i,recursive:!0})??void 0);let T=Z(Ks.relative(w,t)).split("/"),y;for(let b=T.shift(),S=w;b&&(S+="/"+b);b=T.shift()){S=Z(Ks.resolve(S));try{at.mkdirSync(S,i),y=y||S}catch{let A=at.lstatSync(S);if(A.isDirectory())continue;if(p){at.unlinkSync(S),at.mkdirSync(S,i),y=y||S;continue}else if(A.isSymbolicLink())return new Qs(S,S+"/"+T.join("/"))}}return v(y)},Ya=Object.create(null),Al=1e4,xr=new Set,mw=t=>{xr.has(t)?xr.delete(t):Ya[t]=t.normalize("NFD").toLocaleLowerCase("en").toLocaleUpperCase("en"),xr.add(t);let e=Ya[t],n=xr.size-Al;if(n>Al/10){for(let i of xr)if(xr.delete(i),delete Ya[i],--n<=0)break}return e},ww=process.env.TESTING_TAR_FAKE_PLATFORM||process.platform,_w=ww==="win32",yw=t=>t.split("/").slice(0,-1).reduce((e,n)=>{let i=e.at(-1);return i!==void 0&&(n=xf(i,n)),e.push(n||"/"),e},[]),Ew=class{#e=new Map;#n=new Map;#r=new Set;reserve(t,e){t=_w?["win32 parallelization disabled"]:t.map(i=>_i(xf(mw(i))));let n=new Set(t.map(i=>yw(i)).reduce((i,o)=>i.concat(o)));this.#n.set(e,{dirs:n,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 n){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(n=>this.#e.get(n)),dirs:[...e.dirs].map(n=>this.#e.get(n))}}check(t){let{paths:e,dirs:n}=this.#s(t);return e.every(i=>i&&i[0]===t)&&n.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:n,dirs:i}=e,o=new Set;for(let c of n){let l=this.#e.get(c);if(!l||l?.[0]!==t)continue;let f=l[1];if(!f){this.#e.delete(c);continue}if(l.shift(),typeof f=="function")o.add(f);else for(let x of f)o.add(x)}for(let c of i){let l=this.#e.get(c),f=l?.[0];if(!(!l||!(f instanceof Set)))if(f.size===1&&l.length===1){this.#e.delete(c);continue}else if(f.size===1){l.shift();let x=l[0];typeof x=="function"&&o.add(x)}else f.delete(t)}return this.#r.delete(t),o.forEach(c=>this.#i(c)),!0}},bw=()=>process.umask(),Tl=Symbol("onEntry"),wc=Symbol("checkFs"),Cl=Symbol("checkFs2"),_c=Symbol("isReusable"),ft=Symbol("makeFs"),yc=Symbol("file"),Ec=Symbol("directory"),qs=Symbol("link"),Dl=Symbol("symlink"),Rl=Symbol("hardlink"),mi=Symbol("ensureNoSymlink"),kl=Symbol("unsupported"),Ll=Symbol("checkPath"),Qa=Symbol("stripAbsolutePath"),mn=Symbol("mkdir"),He=Symbol("onError"),Rs=Symbol("pending"),Pl=Symbol("pend"),hr=Symbol("unpend"),ec=Symbol("ended"),tc=Symbol("maybeClose"),bc=Symbol("skip"),Ei=Symbol("doChown"),bi=Symbol("uid"),vi=Symbol("gid"),Si=Symbol("checkedCwd"),vw=process.env.TESTING_TAR_FAKE_PLATFORM||process.platform,Ii=vw==="win32",Sw=1024,Iw=(t,e)=>{if(!Ii)return ie.unlink(t,e);let n=t+".DELETE."+ef(16).toString("hex");ie.rename(t,n,i=>{if(i)return e(i);ie.unlink(n,e)})},Aw=t=>{if(!Ii)return ie.unlinkSync(t);let e=t+".DELETE."+ef(16).toString("hex");ie.renameSync(t,e),ie.unlinkSync(e)},Ol=(t,e,n)=>t!==void 0&&t===t>>>0?t:e!==void 0&&e===e>>>0?e:n,Lc=class extends Ai{[ec]=!1;[Si]=!1;[Rs]=0;reservations=new Ew;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[ec]=!0,this[tc]()},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:Sw,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=Z(Me.resolve(t.cwd||process.cwd())),this.strip=Number(t.strip)||0,this.processUmask=this.chmod?typeof t.processUmask=="number"?t.processUmask:bw():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[Tl](e))}warn(t,e,n={}){return(t==="TAR_BAD_ARCHIVE"||t==="TAR_ABORT")&&(n.recoverable=!1),super.warn(t,e,n)}[tc](){this[ec]&&this[Rs]===0&&(this.emit("prefinish"),this.emit("finish"),this.emit("end"))}[Qa](t,e){let n=t[e],{type:i}=t;if(!n||this.preservePaths)return!0;let[o,c]=Cc(n),l=c.replaceAll(/\\/g,"/").split("/");if(l.includes("..")||Ii&&/^[a-z]:\.\.$/i.test(l[0]??"")){if(e==="path"||i==="Link")return this.warn("TAR_ENTRY_ERROR",`${e} contains '..'`,{entry:t,[e]:n}),!1;let f=Me.posix.dirname(t.path),x=Me.posix.normalize(Me.posix.join(f,l.join("/")));if(x.startsWith("../")||x==="..")return this.warn("TAR_ENTRY_ERROR",`${e} escapes extraction directory`,{entry:t,[e]:n}),!1}return o&&(t[e]=String(c),this.warn("TAR_ENTRY_INFO",`stripping ${o} from absolute ${e}`,{entry:t,[e]:n})),!0}[Ll](t){let e=Z(t.path),n=e.split("/");if(this.strip){if(n.length<this.strip)return!1;if(t.type==="Link"){let i=Z(String(t.linkpath)).split("/");if(i.length>=this.strip)t.linkpath=i.slice(this.strip).join("/");else return!1}n.splice(0,this.strip),t.path=n.join("/")}if(isFinite(this.maxDepth)&&n.length>this.maxDepth)return this.warn("TAR_ENTRY_ERROR","path excessively deep",{entry:t,path:e,depth:n.length,maxDepth:this.maxDepth}),!1;if(!this[Qa](t,"path")||!this[Qa](t,"linkpath"))return!1;if(t.absolute=Me.isAbsolute(t.path)?Z(Me.resolve(t.path)):Z(Me.resolve(this.cwd,t.path)),!this.preservePaths&&typeof t.absolute=="string"&&t.absolute.indexOf(this.cwd+"/")!==0&&t.absolute!==this.cwd)return this.warn("TAR_ENTRY_ERROR","path escaped extraction target",{entry:t,path:Z(t.path),resolvedPath:t.absolute,cwd:this.cwd}),!1;if(t.absolute===this.cwd&&t.type!=="Directory"&&t.type!=="GNUDumpDir")return!1;if(this.win32){let{root:i}=Me.win32.parse(String(t.absolute));t.absolute=i+hl(String(t.absolute).slice(i.length));let{root:o}=Me.win32.parse(t.path);t.path=o+hl(t.path.slice(o.length))}return!0}[Tl](t){if(!this[Ll](t))return t.resume();switch(sw.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[wc](t);default:return this[kl](t)}}[He](t,e){t.name==="CwdError"?this.emit("error",t):(this.warn("TAR_ENTRY_ERROR",t,{entry:e}),this[hr](),e.resume())}[mn](t,e,n){hw(Z(t),{uid:this.uid,gid:this.gid,processUid:this.processUid,processGid:this.processGid,umask:this.processUmask,preserve:this.preservePaths,unlink:this.unlink,cwd:this.cwd,mode:e},n)}[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}[bi](t){return Ol(this.uid,t.uid,this.processUid)}[vi](t){return Ol(this.gid,t.gid,this.processGid)}[yc](t,e){let n=typeof t.mode=="number"?t.mode&4095:this.fmode,i=new $s(String(t.absolute),{flags:cf(t.size),mode:n,autoClose:!1});i.on("error",f=>{i.fd&&ie.close(i.fd,()=>{}),i.write=()=>!0,this[He](f,t),e()});let o=1,c=f=>{if(f){i.fd&&ie.close(i.fd,()=>{}),this[He](f,t),e();return}--o===0&&i.fd!==void 0&&ie.close(i.fd,x=>{x?this[He](x,t):this[hr](),e()})};i.on("finish",()=>{let f=String(t.absolute),x=i.fd;if(typeof x=="number"&&t.mtime&&!this.noMtime){o++;let p=t.atime||new Date,w=t.mtime;ie.futimes(x,p,w,v=>v?ie.utimes(f,p,w,T=>c(T&&v)):c())}if(typeof x=="number"&&this[Ei](t)){o++;let p=this[bi](t),w=this[vi](t);typeof p=="number"&&typeof w=="number"&&ie.fchown(x,p,w,v=>v?ie.chown(f,p,w,T=>c(T&&v)):c())}c()});let l=this.transform&&this.transform(t)||t;l!==t&&(l.on("error",f=>{this[He](f,t),e()}),t.pipe(l)),l.pipe(i)}[Ec](t,e){let n=typeof t.mode=="number"?t.mode&4095:this.dmode;this[mn](String(t.absolute),n,i=>{if(i){this[He](i,t),e();return}let o=1,c=()=>{--o===0&&(e(),this[hr](),t.resume())};t.mtime&&!this.noMtime&&(o++,ie.utimes(String(t.absolute),t.atime||new Date,t.mtime,c)),this[Ei](t)&&(o++,ie.chown(String(t.absolute),Number(this[bi](t)),Number(this[vi](t)),c)),c()})}[kl](t){t.unsupported=!0,this.warn("TAR_ENTRY_UNSUPPORTED",`unsupported entry type: ${t.type}`,{entry:t}),t.resume()}[Dl](t,e){let n=Z(Me.relative(this.cwd,Me.resolve(Me.dirname(String(t.absolute)),String(t.linkpath)))).split("/");this[mi](t,this.cwd,n,()=>this[qs](t,String(t.linkpath),"symlink",e),i=>{this[He](i,t),e()})}[Rl](t,e){let n=Z(Me.resolve(this.cwd,String(t.linkpath))),i=Z(String(t.linkpath)).split("/");this[mi](t,this.cwd,i,()=>this[qs](t,n,"link",e),o=>{this[He](o,t),e()})}[mi](t,e,n,i,o){let c=n.shift();if(this.preservePaths||c===void 0)return i();let l=Me.resolve(e,c);ie.lstat(l,(f,x)=>{if(f)return i();if(x?.isSymbolicLink())return o(new Qs(l,Me.resolve(l,n.join("/"))));this[mi](t,l,n,i,o)})}[Pl](){this[Rs]++}[hr](){this[Rs]--,this[tc]()}[bc](t){this[hr](),t.resume()}[_c](t,e){return t.type==="File"&&!this.unlink&&e.isFile()&&e.nlink<=1&&!Ii}[wc](t){this[Pl]();let e=[t.path];t.linkpath&&e.push(t.linkpath),this.reservations.reserve(e,n=>this[Cl](t,n))}[Cl](t,e){let n=l=>{e(l)},i=()=>{this[mn](this.cwd,this.dmode,l=>{if(l){this[He](l,t),n();return}this[Si]=!0,o()})},o=()=>{if(t.absolute!==this.cwd){let l=Z(Me.dirname(String(t.absolute)));if(l!==this.cwd)return this[mn](l,this.dmode,f=>{if(f){this[He](f,t),n();return}c()})}c()},c=()=>{ie.lstat(String(t.absolute),(l,f)=>{if(f&&(this.keep||this.newer&&f.mtime>(t.mtime??f.mtime))){this[bc](t),n();return}if(l||this[_c](t,f))return this[ft](null,t,n);if(f.isDirectory()){if(t.type==="Directory"){let x=this.chmod&&t.mode&&(f.mode&4095)!==t.mode,p=w=>this[ft](w??null,t,n);return x?ie.chmod(String(t.absolute),Number(t.mode),p):p()}if(t.absolute!==this.cwd)return ie.rmdir(String(t.absolute),x=>this[ft](x??null,t,n))}if(t.absolute===this.cwd)return this[ft](null,t,n);Iw(String(t.absolute),x=>this[ft](x??null,t,n))})};this[Si]?o():i()}[ft](t,e,n){if(t){this[He](t,e),n();return}switch(e.type){case"File":case"OldFile":case"ContiguousFile":return this[yc](e,n);case"Link":return this[Rl](e,n);case"SymbolicLink":return this[Dl](e,n);case"Directory":case"GNUDumpDir":return this[Ec](e,n)}}[qs](t,e,n,i){ie[n](e,String(t.absolute),o=>{o?this[He](o,t):(this[hr](),t.resume()),i()})}},pi=t=>{try{return[null,t()]}catch(e){return[e,null]}},hf=class extends Lc{sync=!0;[ft](t,e){return super[ft](t,e,()=>{})}[wc](t){if(!this[Si]){let o=this[mn](this.cwd,this.dmode);if(o)return this[He](o,t);this[Si]=!0}if(t.absolute!==this.cwd){let o=Z(Me.dirname(String(t.absolute)));if(o!==this.cwd){let c=this[mn](o,this.dmode);if(c)return this[He](c,t)}}let[e,n]=pi(()=>ie.lstatSync(String(t.absolute)));if(n&&(this.keep||this.newer&&n.mtime>(t.mtime??n.mtime)))return this[bc](t);if(e||this[_c](t,n))return this[ft](null,t);if(n.isDirectory()){if(t.type==="Directory"){let c=this.chmod&&t.mode&&(n.mode&4095)!==t.mode,[l]=c?pi(()=>{ie.chmodSync(String(t.absolute),Number(t.mode))}):[];return this[ft](l,t)}let[o]=pi(()=>ie.rmdirSync(String(t.absolute)));this[ft](o,t)}let[i]=t.absolute===this.cwd?[]:pi(()=>Aw(String(t.absolute)));this[ft](i,t)}[yc](t,e){let n=typeof t.mode=="number"?t.mode&4095:this.fmode,i=l=>{let f;try{ie.closeSync(o)}catch(x){f=x}(l||f)&&this[He](l||f,t),e()},o;try{o=ie.openSync(String(t.absolute),cf(t.size),n)}catch(l){return i(l)}let c=this.transform&&this.transform(t)||t;c!==t&&(c.on("error",l=>this[He](l,t)),t.pipe(c)),c.on("data",l=>{try{ie.writeSync(o,l,0,l.length)}catch(f){i(f)}}),c.on("end",()=>{let l=null;if(t.mtime&&!this.noMtime){let f=t.atime||new Date,x=t.mtime;try{ie.futimesSync(o,f,x)}catch(p){try{ie.utimesSync(String(t.absolute),f,x)}catch{l=p}}}if(this[Ei](t)){let f=this[bi](t),x=this[vi](t);try{ie.fchownSync(o,Number(f),Number(x))}catch(p){try{ie.chownSync(String(t.absolute),Number(f),Number(x))}catch{l=l||p}}}i(l)})}[Ec](t,e){let n=typeof t.mode=="number"?t.mode&4095:this.dmode,i=this[mn](String(t.absolute),n);if(i){this[He](i,t),e();return}if(t.mtime&&!this.noMtime)try{ie.utimesSync(String(t.absolute),t.atime||new Date,t.mtime)}catch{}if(this[Ei](t))try{ie.chownSync(String(t.absolute),Number(this[bi](t)),Number(this[vi](t)))}catch{}e(),t.resume()}[mn](t,e){try{return gw(Z(t),{uid:this.uid,gid:this.gid,processUid:this.processUid,processGid:this.processGid,umask:this.processUmask,preserve:this.preservePaths,unlink:this.unlink,cwd:this.cwd,mode:e})}catch(n){return n}}[mi](t,e,n,i,o){if(this.preservePaths||n.length===0)return i();let c=e;for(let l of n){c=Me.resolve(c,l);let[f,x]=pi(()=>ie.lstatSync(c));if(f)return i();if(x.isSymbolicLink())return o(new Qs(c,Me.resolve(e,n.join("/"))))}i()}[qs](t,e,n,i){let o=`${n}Sync`;try{ie[o](e,String(t.absolute)),i(),t.resume()}catch(c){return this[He](c,t)}}},Tw=t=>{let e=new hf(t),n=t.file,i=Ql.statSync(n),o=t.maxReadSize||16*1024*1024;new $g(n,{readSize:o,size:i.size}).pipe(e)},Cw=(t,e)=>{let n=new Lc(t),i=t.maxReadSize||16*1024*1024,o=t.file;return new Promise((c,l)=>{n.on("error",l),n.on("close",c),Ql.stat(o,(f,x)=>{if(f)l(f);else{let p=new Sc(o,{readSize:i,size:x.size});p.on("error",l),p.pipe(n)}})})},pf=Ti(Tw,Cw,t=>new hf(t),t=>new Lc(t),(t,e)=>{e?.length&&Kl(t,e)}),Dw=(t,e)=>{let n=new kc(t),i=!0,o,c;try{try{o=ot.openSync(t.file,"r+")}catch(x){if(x?.code==="ENOENT")o=ot.openSync(t.file,"w+");else throw x}let l=ot.fstatSync(o),f=Buffer.alloc(512);e:for(c=0;c<l.size;c+=512){for(let w=0,v=0;w<512;w+=v){if(v=ot.readSync(o,f,w,f.length-w,c+w),c===0&&f[0]===31&&f[1]===139)throw new Error("cannot append to compressed archives");if(!v)break e}let x=new Hn(f);if(!x.cksumValid)break;let p=512*Math.ceil((x.size||0)/512);if(c+p+512>l.size)break;c+=p,t.mtimeCache&&x.mtime&&t.mtimeCache.set(String(x.path),x.mtime)}i=!1,Rw(t,n,c,o,e)}finally{if(i)try{ot.closeSync(o)}catch{}}},Rw=(t,e,n,i,o)=>{let c=new Bl(t.file,{fd:i,start:n});e.pipe(c),Lw(e,o)},kw=(t,e)=>{e=Array.from(e);let n=new Xs(t),i=(o,c,l)=>{let f=(T,y)=>{T?ot.close(o,b=>l(T)):l(null,y)},x=0;if(c===0)return f(null,0);let p=0,w=Buffer.alloc(512),v=(T,y)=>{if(T||y===void 0)return f(T);if(p+=y,p<512&&y)return ot.read(o,w,p,w.length-p,x+p,v);if(x===0&&w[0]===31&&w[1]===139)return f(new Error("cannot append to compressed archives"));if(p<512)return f(null,x);let b=new Hn(w);if(!b.cksumValid)return f(null,x);let S=512*Math.ceil((b.size??0)/512);if(x+S+512>c||(x+=S+512,x>=c))return f(null,x);t.mtimeCache&&b.mtime&&t.mtimeCache.set(String(b.path),b.mtime),p=0,ot.read(o,w,0,512,x,v)};ot.read(o,w,0,512,x,v)};return new Promise((o,c)=>{n.on("error",c);let l="r+",f=(x,p)=>{if(x&&x.code==="ENOENT"&&l==="r+")return l="w+",ot.open(t.file,l,f);if(x||!p)return c(x);ot.fstat(p,(w,v)=>{if(w)return ot.close(p,()=>c(w));i(p,v.size,(T,y)=>{if(T)return c(T);let b=new $s(t.file,{fd:p,start:y});n.pipe(b),b.on("error",c),b.on("close",o),Pw(n,e)})})};ot.open(t.file,l,f)})},Lw=(t,e)=>{e.forEach(n=>{n.charAt(0)==="@"?br({file:gf.resolve(t.cwd,n.slice(1)),sync:!0,noResume:!0,onReadEntry:i=>t.add(i)}):t.add(n)}),t.end()},Pw=async(t,e)=>{for(let n of e)n.charAt(0)==="@"?await br({file:gf.resolve(String(t.cwd),n.slice(1)),noResume:!0,onReadEntry:i=>t.add(i)}):t.add(n);t.end()},gi=Ti(Dw,kw,()=>{throw new TypeError("file is required")},()=>{throw new TypeError("file is required")},(t,e)=>{if(!tm(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")}),v2=Ti(gi.syncFile,gi.asyncFile,gi.syncNoFile,gi.asyncNoFile,(t,e=[])=>{gi.validate?.(t,e),Ow(t)}),Ow=t=>{let e=t.filter;t.mtimeCache||(t.mtimeCache=new Map),t.filter=e?(n,i)=>e(n,i)&&!((t.mtimeCache?.get(n)??i.mtime??0)>(i.mtime??0)):(n,i)=>!((t.mtimeCache?.get(n)??i.mtime??0)>(i.mtime??0))};on();var vt={PAIR:"_agent/pair",CREATE:"_agent/create",HEALTH:"_agent/health",LIST_SKILLS:"_agent/listSkills",ADD_SKILLS:"_agent/addSkills",REMOVE_SKILLS:"_agent/removeSkills",GET_FILE_TREE:"_agent/getFileTree",GET_FILE_CONTENT:"_agent/getFileContent",DETAIL:"_agent/detail",UPDATE:"_agent/update",DISCONNECT:"_agent/disconnect",SWITCH_MODEL:"_agent/switchModel",GEN_MODEL_TOKEN:"_agent/genModelToken",RESET:"_agent/reset",REPAIR:"_agent/repair",DELETE:"_agent/delete"};function Ci(t){return t?.cozeDeployType==="cloud"?"cloud":"local"}function mf(t){let e=t?.cozeAccountId?.trim();if(!(!e||e==="0"))return e}function Pc(t){let e=t?.cozeGroupId?.trim();if(!(!e||e==="0"))return e}function wf(t){let{_meta:e,...n}=t;return{stripped:n,meta:e}}function vr(t){if(!t?.cozeAgentId)throw new Error("missing _meta.cozeAgentId");return t.cozeAgentId}Ve();re();Oe();Ve();function Jt(t,e){if(Ci(t)!=="cloud")throw new C("OPERATION_NOT_ALLOWED_FOR_LOCAL",`${e} is not allowed for local agent`)}function eo(t){return t.startsWith("http://")||t.startsWith("https://")}function to(t){return t.endsWith("/")?t.slice(0,-1):t}Ve();re();var no="1008033",_f="1289";var yf="pbbp2",Ef="https://www.coze.cn",bf="/api/coze_claw/resource/get_frontier_key",Mw="https://www.coze.cn",Bw="wss://frontier.coze.cn";function ro(t){return t??process.env.COZE_BRIDGE_HANDSHAKE_URL??Mw}function vf(t){return t??process.env.COZE_BRIDGE_FRONTIER_URL??Bw}function Sr(t){let e={},n=t?.ttEnv??process.env.COZE_BRIDGE_TT_ENV,i=t?.usePpe??process.env.COZE_BRIDGE_USE_PPE;return n&&(e["x-tt-env"]=n),i&&(e["x-use-ppe"]=i),e}function Ri(t){return t?t.startsWith("boe_")?{ttEnv:t}:{ttEnv:t,usePpe:"1"}:{}}var Di=H("handshake");async function Oc(t){let e=ro(t.endpoint),n=t.timeoutMs??1e4,i=`${to(e)}${bf}?aid=${encodeURIComponent(no)}`,o={Authorization:`Bearer ${t.privatecode}`,Accept:"application/json",...Sr(t.ppeOverride)},c=new AbortController,l=setTimeout(()=>c.abort(),n);Di.info("frontier key handshake",{base:e});try{let f=await fetch(i,{method:"GET",headers:o,signal:c.signal}),x=f.headers.get("x-tt-logid")??"",p=f.headers.get("x-tt-trace-id")??"";if(!f.ok){let b=await f.text().catch(()=>"");throw new C("UPSTREAM_HANDSHAKE_FAILED",`handshake HTTP ${f.status} logid=${x}: ${b.slice(0,200)}`)}let w=await f.json();if(w.code!==void 0&&w.code!==0)throw new C("UPSTREAM_HANDSHAKE_FAILED",`handshake code=${w.code} msg=${w.msg??"-"} logid=${x}`);let v=w.data??{},T=typeof v.access_key=="string"&&v.access_key||typeof v.accessKey=="string"&&v.accessKey||void 0,y=typeof v.device_id=="string"&&v.device_id||typeof v.deviceId=="string"&&v.deviceId||void 0;if(!T||!y){let b=JSON.stringify(w).slice(0,500);throw new C("UPSTREAM_HANDSHAKE_FAILED",`handshake response missing access_key/device_id (also tried camelCase) logid=${x}: ${b}`)}return Di.info("handshake ok",{remoteDeviceId:y,logid:x,traceId:p}),{accessKey:T,deviceId:y}}catch(f){if(f instanceof C)throw Di.error("handshake failed (bridge error)",{base:e,message:f.message,code:f.code}),f;if(f.name==="AbortError")throw Di.warn("handshake timeout",{base:e,timeoutMs:n}),new C("UPSTREAM_HANDSHAKE_FAILED",`handshake timeout (${n}ms)`,{cause:f});let x=f.cause;throw Di.error("handshake error",{base:e,message:f instanceof Error?f.message:String(f),errno:x?.code,syscall:x?.syscall,cause:String(f).slice(0,300)}),new C("UPSTREAM_HANDSHAKE_FAILED",String(f),{cause:f})}finally{clearTimeout(l)}}var Nc=process.env.COZE_BRIDGE_LLM_GATEWAY_URL?.trim()||"https://llm-gateway.coze.cn",St="auto",Sf=2e5;function If(t){return{model:Mc(t.model)??St,...t.modelToken?{modelToken:t.modelToken}:{}}}function Af(t){return!t||t===St}var zw=new Set(["auto","\u81EA\u52A8"]);function Mc(t){let e=t?.trim();if(e)return zw.has(e.toLowerCase())?St:e}function Tf(t){let e={};if(t.modelToken){e.ANTHROPIC_BASE_URL=Nc,e.ANTHROPIC_AUTH_TOKEN=t.modelToken;let n=t.model||St;e.ANTHROPIC_MODEL=n,e.ANTHROPIC_SMALL_FAST_MODEL=n,e.ANTHROPIC_DEFAULT_HAIKU_MODEL=n,t.modelInfo?.contextWindow&&(e.CLAUDE_CODE_MAX_CONTEXT_TOKENS=String(t.modelInfo.contextWindow))}else Af(t.model)||(e.ANTHROPIC_MODEL=t.model);return e}function Cf(t){let e=[];if(t.modelToken?e.push("-c",`model="${t.model||St}"`):Af(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="${Nc}/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"');let n=t.modelInfo?.contextWindow??Sf;e.push("-c",`model_context_window=${n}`)}return e}function Df(t){return t.modelToken?{OPENAI_API_KEY:t.modelToken}:{}}function Bc(t,e){let{ttEnv:n,usePpe:i}=Ri(t),o={};return n&&(o["x-tt-env"]=n),i&&(o["x-use-ppe"]=i),e&&(o["x-mock-scenario"]=e),o}function Rf(t,e,n){if(!t.modelToken)return{};let i=Bc(e,n);return Object.keys(i).length===0?{}:{ANTHROPIC_CUSTOM_HEADERS:Object.entries(i).map(([c,l])=>`${c}:${l}`).join(`
|
|
92
|
+
`)}}function zc(t){return`coze-session-${t.replace(/[^A-Za-z0-9_-]+/g,"-")}`}function kf(t,e,n){if(!t.modelToken)return null;let i=t.model||St,o=Bc(e,n),c=["text"];t.modelInfo?.capabilities?.image===!0&&c.push("image");let l={baseUrl:`${Nc}/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??Sf,maxTokens:8192,api:"openai-completions"}]};return Object.keys(o).length>0&&(l.headers=o),l}function Lf(t,e,n){if(!t.modelToken)return[];let i=Bc(e,n),o=[];for(let[c,l]of Object.entries(i))o.push("-c",`model_providers.coze.http_headers.${c}="${l}"`);return o}var Be=H("agent-handlers"),Pf=5*1024*1024,jw=1,Ww=6,Kw=new Set(["node_modules",".git",".coze","dist","build",".next"]),io=class{constructor(e){this.opts=e}opts;async listSkills(e){Jt(e._meta,"_agent/listSkills");let n=vr(e._meta),i=await this.loadAgentCfg(n),o=i?.workspace??Qe(n).workspace,c=i?.skills??[],l=[];for(let f of c){let x=Ot(o,f.relPath,"SKILL.md");await qw(x).then(w=>w.isFile()).catch(()=>!1)&&l.push(Xw(f))}return{skills:l}}async addSkills(e){Jt(e._meta,"_agent/addSkills");let n=vr(e._meta),i=await this.requireAgentCfg(n),o=e.skills??[],c=[...i.skills??[]],l=new Map(c.map((x,p)=>[x.skillId,p])),f=[];for(let x of o){let p=await Wc({agentId:n,workspace:i.workspace,framework:i.framework,skill:x});Kc(c,l,p),f.push(x)}return await ds(n,c),this.reloadAgentSessions(n,"skills-added"),{installedSkills:f}}async removeSkills(e){Jt(e._meta,"_agent/removeSkills");let n=vr(e._meta),i=await this.requireAgentCfg(n),o=new Set(e.skillIds??[]),c=i.skills??[],l=[];for(let f of c){if(!o.has(f.skillId)){l.push(f);continue}let x=Ot(i.workspace,f.relPath);await Uw(x,{recursive:!0,force:!0}),Be.info("skill removed",{agentId:n,skillId:f.skillId,relPath:f.relPath})}return await ds(n,l),this.reloadAgentSessions(n,"skills-removed"),{ok:!0}}reloadAgentSessionsPublic(e,n){this.reloadAgentSessions(e,n)}reloadAgentSessions(e,n){let i=this.opts.agents.get(e);if(i)for(let[o,c]of i.sessions){if(!c.downstream)continue;let l=c.acpSessionId;if(l&&i.activeTriggers.has(l)||this.isRuntimePendingPermission(c)){c.reloadAfterTurn=!0,Be.info("downstream busy, scheduling reload after turn",{reason:n,agentId:e,framework:i.framework,cloudId:o,acpId:l});continue}let x=c.downstream;c.downstream=void 0,Be.info("killing downstream for workspace reload (idle)",{reason:n,agentId:e,framework:i.framework,cloudId:o,acpId:l}),x.stop(n).catch(p=>Be.warn("downstream stop failed during reload (ignored)",{reason:n,agentId:e,cloudId:o,err:String(p)}))}}isRuntimePendingPermission(e){let n=this.opts.isRuntimePendingPermission;return!n||!e.downstream?!1:n(e.downstream)}async updateAgent(e){if(!e.cozeIdentity?.trim())return Be.info("_agent/update: empty cozeIdentity, noop",{agentId:e.agentId}),{ok:!0};let n=e.agentId,i=await Ke(n);if(!i)throw new C("AGENT_NOT_FOUND",`agent not found: ${n}`);if(i.cozeIdentity===e.cozeIdentity)return Be.info("_agent/update: cozeIdentity unchanged, noop",{agentId:n}),{ok:!0};try{await or(i.workspace,i.framework,e.cozeIdentity)}catch(o){throw Be.error("_agent/update: writeInstructionFile failed, aborting update",{agentId:n,framework:i.framework,workspace:i.workspace,err:String(o)}),new C("AGENT_PROTOCOL_ERROR",`failed to write instruction file for agent ${n}: ${String(o)}`,{cause:o})}return i.cozeIdentity=e.cozeIdentity,await et(i),Be.info("_agent/update: cozeIdentity rewritten",{agentId:n,framework:i.framework}),this.reloadAgentSessions(n,"identity-changed"),{ok:!0}}async disconnectAgent(e){let n=e.agentId;if(!n)throw new C("IPC_BAD_REQUEST","_agent/disconnect: missing agentId");let i=await Ke(n);return i?(i.disconnectedAt=Date.now(),i.disconnectReason=e.reason??"",await et(i),Be.info("agent disconnected",{agentId:n,reason:e.reason??"",force:e.force??!1}),this.opts.disposeAndMarkDisconnected&&await this.opts.disposeAndMarkDisconnected(n,e.reason??"disconnect"),{ok:!0}):(Be.warn("_agent/disconnect: agent not found, ignoring",{agentId:n}),{ok:!0})}async switchModel(e){if(Jt(e._meta,"_agent/switchModel"),!e.agentId)throw new C("IPC_BAD_REQUEST","_agent/switchModel: missing agentId");let n=Mc(e.model)??St,i=await Ke(e.agentId);if(!i)throw new C("AGENT_NOT_FOUND",`agent not found: ${e.agentId}`);i.model=n,e.modelInfo&&(i.modelInfo=e.modelInfo),await et(i),Be.info("_agent/switchModel: model persisted",{agentId:e.agentId,model:n,reason:e.reason??""});let o=this.opts.agents.get(e.agentId);if(!o)return Be.info("_agent/switchModel: agent not running, config persisted only",{agentId:e.agentId}),{ok:!0};o.model=n,e.modelInfo&&o.setModelInfo(e.modelInfo),this.opts.cleanupOpenclawProviders&&await this.opts.cleanupOpenclawProviders(o).catch(l=>Be.warn("cleanupOpenclawProviders before switchModel failed (ignored)",{agentId:e.agentId,err:String(l)}));let c=[];for(let[l,f]of o.allSessionQueues())c.push(f.enqueue(async()=>{let x=o.sessions.get(l);x?.downstream&&(await x.downstream.stop(`switchModel: ${n}`).catch(()=>{}),x.downstream=void 0)}));return await Promise.all(c),Be.info("_agent/switchModel: all session runtimes killed, next prompt will respawn",{agentId:e.agentId,model:n,cloudSessions:c.length}),{ok:!0}}async resetAgent(e){if(Jt(e._meta,vt.RESET),!e.agentId)throw new C("IPC_BAD_REQUEST",`${vt.RESET}: missing agentId`);return await this.clearSessionMappings(e.agentId,vt.RESET),await this.runDetailSync(e.agentId,vt.RESET,e.reason),{ok:!0}}async clearSessionMappings(e,n){let i=this.opts.agents.get(e);if(!i){await this.clearPersistedAcpSessionIds(e),Be.info("reset: agent not in memory, cleared persisted acpSessionIds only",{agentId:e});return}await i.killAllRuntimes(n);for(let c of i.sessions.values())c.acpSessionId=void 0,c.replySeq=0,c.loadingSession=!1,c.spawnFailCount=void 0,c.spawnFailedAt=void 0;let o=new Map;for(let[c,l]of i.sessions)o.set(c,{modelToken:l.modelToken,tokenGeneratedAt:l.tokenGeneratedAt});await ti(e,o)}async clearPersistedAcpSessionIds(e){let n=await Ke(e).catch(()=>null);if(!n?.sessions)return;let i=!1;for(let o of Object.values(n.sessions))o.acpSessionId&&(o.acpSessionId=void 0,i=!0);i&&await et(n)}async repairAgent(e){if(Jt(e._meta,vt.REPAIR),!e.agentId)throw new C("IPC_BAD_REQUEST",`${vt.REPAIR}: missing agentId`);let n=await this.loadAgentCfg(e.agentId);if(n&&n.framework!=="openclaw")throw new C("IPC_BAD_REQUEST",`${vt.REPAIR} only allowed for openclaw, got ${n.framework}`);if(n&&this.opts.openclawRepair)try{await this.opts.openclawRepair(e.agentId,n.workspace)}catch(i){Be.warn("openclaw repair (delete+add) failed (ignored)",{agentId:e.agentId,reason:e.reason,err:String(i)})}return await this.runDetailSync(e.agentId,vt.REPAIR,e.reason),{ok:!0}}async runDetailSync(e,n,i){if(!this.opts.detailSyncer){Be.warn("detailSyncer not wired, skipping sync",{method:n,agentId:e});return}try{await this.opts.detailSyncer(e)}catch(o){Be.warn("detail sync failed (ignored)",{method:n,agentId:e,reason:i,err:String(o)})}}async getFileTree(e){Jt(e._meta,"_agent/getFileTree");let n=e._meta,i=vr(n),o=await this.resolveWorkspace(i),c=e.filePath??"",l=this.safeJoin(o,c),f=await Fc(l).catch(()=>null);if(!f)throw new C("IPC_BAD_REQUEST",`path not found: ${c}`);if(f.isSymbolicLink())throw new C("IPC_BAD_REQUEST",`symlink not allowed: ${c}`);if(!await ei(l,o))throw new C("IPC_BAD_REQUEST",`path escapes workspace: ${c}`);let x=c_(e.depth);return f.isDirectory()?{tree:await a_(o,l,c,x)}:{tree:[{name:d_(c),path:Uf(c||"."),isDir:!1,size:f.size,modifiedAt:Math.floor(f.mtimeMs)}]}}async getFileContent(e){Jt(e._meta,"_agent/getFileContent");let n=vr(e._meta),i=await this.resolveWorkspace(n);if(!e.filePath)throw new C("IPC_BAD_REQUEST","filePath required");let o=this.safeJoin(i,e.filePath),c=await Fc(o).catch(()=>null);if(!c||!c.isFile())throw new C("IPC_BAD_REQUEST",`not a file: ${e.filePath}`);if(c.isSymbolicLink())throw new C("IPC_BAD_REQUEST",`symlink not allowed: ${e.filePath}`);if(!await ei(o,i))throw new C("IPC_BAD_REQUEST",`path escapes workspace: ${e.filePath}`);if(c.size>Pf)throw new C("IPC_BAD_REQUEST",`file too large: ${c.size} bytes (max ${Pf})`);let l=await Of(o);return l.includes(0)?{content:l.toString("base64"),encoding:"base64",size:c.size}:{content:l.toString("utf8"),encoding:"utf-8",size:c.size}}async resolveWorkspace(e){let n=this.opts.agents.get(e);return n?n.workspace:(await Ke(e).catch(()=>null))?.workspace??Qe(e).workspace}safeJoin(e,n){let i=Hc(e,n||"."),o=jc(e,i);if(o.startsWith("..")||o===".."||o.startsWith(`..${Nf}`))throw new C("IPC_BAD_REQUEST",`path escapes workspace: ${n}`);return i}loadAgentCfg(e){return Ke(e)}async requireAgentCfg(e){let n=await this.loadAgentCfg(e);if(!n)throw new C("AGENT_NOT_FOUND",`no config for agent: ${e}`);return n}};function $w(t){let e=t.trim().replace(/[\x00-\x1f<>:"|?*/\\]+/g,"-").replace(/^[\s.-]+|[\s.-]+$/g,"").slice(0,64);if(!e||e==="."||e==="..")throw new C("IPC_BAD_REQUEST",`invalid skill name: ${t}`);if(/^(con|prn|aux|nul|com[1-9]|lpt[1-9])$/i.test(e))throw new C("IPC_BAD_REQUEST",`reserved windows filename: ${t}`);return e}function Jw(t){return t==="claude-code"?Ot(".claude","skills"):Ot(".agents","skills")}var Vw=3e4,Zw=50*1024*1024,Ir=3e4;async function Wc(t){let{agentId:e,workspace:n,framework:i,skill:o}=t;if(!o.skillName)throw new C("IPC_BAD_REQUEST","skill missing skillName");let c=typeof o.content=="string"&&o.content.length>0,l=typeof o.downloadUrl=="string"&&o.downloadUrl.length>0;if(!c&&!l)throw new C("IPC_BAD_REQUEST",`skill ${o.skillId} missing both content and downloadUrl`);let f=$w(o.skillName),x=Jw(i),p=Ot(x,f),w=Ot(n,p);if(await Uc(w,{recursive:!0}),c){let T=Buffer.from(o.content,"utf8");ki(T.length),await qc(Ot(w,"SKILL.md"),T,"utf8")}else{let T=await Yw(o.downloadUrl);e_(T)?await i_(T,w):t_(T)?await n_(T,w):await qc(Ot(w,"SKILL.md"),T.toString("utf8"),"utf8")}let v={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 Be.info("skill installed",{agentId:e,skillId:o.skillId,skillName:o.skillName,relPath:p,source:c?"content":"downloadUrl"}),v}function Kc(t,e,n){let i=e.get(n.skillId);if(i!==void 0){t[i]=n;return}e.set(n.skillId,t.length),t.push(n)}function Xw(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 Yw(t){if(!t)throw new C("IPC_BAD_REQUEST","skill missing downloadUrl");if(t.startsWith("data:")){let e=Math.floor(t.length*3/4);ki(e);let n=Qw(t);return ki(n.length),n}if(t.startsWith("file:")){let e=new URL(t).pathname,n=await Of(e);return ki(n.length),n}if(eo(t)){let e=new AbortController,n=setTimeout(()=>e.abort(),Vw);try{let i=await fetch(t,{signal:e.signal});if(!i.ok)throw new C("IPC_BAD_REQUEST",`fetch skill failed HTTP ${i.status} ${t}`);let o=await i.arrayBuffer();return ki(o.byteLength),Buffer.from(o)}finally{clearTimeout(n)}}throw new C("IPC_BAD_REQUEST",`unsupported downloadUrl scheme (\u8981 https/data/file): ${t.slice(0,80)}`)}function ki(t){if(t>Zw)throw new C("IPC_BAD_REQUEST",`skill too large: ${t} bytes`)}function Qw(t){let e=/^data:([^,;]*)(;base64)?,(.*)$/s.exec(t);if(!e)throw new C("IPC_BAD_REQUEST","bad data URL");let n=!!e[2],i=e[3]??"";return n?Buffer.from(i,"base64"):Buffer.from(decodeURIComponent(i),"utf8")}function e_(t){return t.length>=2&&t[0]===31&&t[1]===139}function t_(t){if(t.length<4||t[0]!==80||t[1]!==75)return!1;let e=t[2],n=t[3];return e===3&&n===4||e===5&&n===6}function Gc(t){return t==="__MACOSX"||t.startsWith("__MACOSX/")}async function n_(t,e){let n,i;try{n=new zf.default(t),i=n.getEntries()}catch(l){throw new C("IPC_BAD_REQUEST",`zip parse failed: ${l.message}`,{cause:l})}for(let l of i){let f=l.entryName;if(!f||Gc(f))continue;if(f.startsWith("/")||/^[A-Za-z]:[\\/]/.test(f))throw new C("IPC_BAD_REQUEST",`zip entry absolute path: ${f}`);if(f.split(/[/\\]/).some(p=>p===".."))throw new C("IPC_BAD_REQUEST",`zip entry contains '..' (traversal): ${f}`);let x=l.header.attr>>>16&61440;if(x!==0&&x!==32768&&x!==16384)throw new C("IPC_BAD_REQUEST",`zip entry kind 0x${x.toString(16)} not allowed (symlink/hardlink/special): ${f}`)}let o=r_(i),c=Hc(e);for(let l of i){if(Gc(l.entryName))continue;let f=l.entryName;if(o&&f.startsWith(o)&&(f=f.slice(o.length)),!f)continue;let x=Hc(e,f),p=jc(c,x);if(p.startsWith("..")||p==="..")throw new C("IPC_BAD_REQUEST",`zip entry escapes destDir: ${f}`);if(l.isDirectory){await Uc(x,{recursive:!0});continue}await Uc(Hw(x),{recursive:!0});let w;try{w=l.getData()}catch(v){throw new C("IPC_BAD_REQUEST",`zip entry getData failed (${l.entryName}): ${v.message}`,{cause:v})}await qc(x,w)}}function r_(t){let e;for(let n of t){let i=n.entryName;if(!i||Gc(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 i_(t,e){await s_(t);let n=pf({cwd:e,strip:1}),i=!1,o=setTimeout(()=>{i=!0,n.destroy(new C("IPC_BAD_REQUEST",`tar extract timeout (${Ir}ms)`))},Ir);try{await Bf(Mf.from(t),n)}catch(c){throw c instanceof C?c:i?new C("IPC_BAD_REQUEST",`tar extract timeout (${Ir}ms)`):new C("IPC_BAD_REQUEST",`tar extract failed: ${c.message??String(c)}`,{cause:c})}finally{clearTimeout(o)}}async function s_(t){let e=[],n=br({onReadEntry:c=>{let l=c.path,f=c.type;if(f!=="File"&&f!=="Directory"){e.push(`tar entry kind '${f}' not allowed (symlink/hardlink/special): ${l.slice(0,100)}`);return}if(l.startsWith("/")||l.startsWith("\\")||/^[a-zA-Z]:[\\/]/.test(l)){e.push(`tar entry absolute path: ${l}`);return}l.split(/[/\\]/).some(p=>p==="..")&&e.push(`tar entry contains '..': ${l}`)}}),i=!1,o=setTimeout(()=>{i=!0,n.destroy(new C("IPC_BAD_REQUEST",`tar list timeout (${Ir}ms)`))},Ir);try{await Bf(Mf.from(t),n)}catch(c){throw i?new C("IPC_BAD_REQUEST",`tar list timeout (${Ir}ms)`):new C("IPC_BAD_REQUEST",`tar list failed: ${c.message??String(c)}`,{cause:c})}finally{clearTimeout(o)}if(e.length>0)throw new C("IPC_BAD_REQUEST",e[0]??"tar entry validation failed")}var o_=5e3;async function a_(t,e,n,i){return Ff(t,e,n,i,{count:0})}async function Ff(t,e,n,i,o){if(i<=0)return[];let c;try{c=await Fw(e,{withFileTypes:!0})}catch{return[]}let l=[];for(let f of c){if(Kw.has(f.name)||f.isSymbolicLink())continue;if(o.count>=o_){l.push({name:"...",path:"...",isDir:!1,size:0,modifiedAt:0,hasMore:!0});break}let x=Ot(e,f.name),p=Gw(Ot(n,f.name)),w=null;try{w=await Fc(x)}catch{continue}if(w.isSymbolicLink())continue;o.count++;let v={name:f.name,path:Uf(jc(t,x)),isDir:w.isDirectory(),size:w.size,modifiedAt:Math.floor(w.mtimeMs)};w.isDirectory()&&i>1&&(v.children=await Ff(t,x,p,i-1,o)),l.push(v)}return l.sort((f,x)=>f.isDir!==x.isDir?f.isDir?-1:1:f.name.localeCompare(x.name)),l}function c_(t){return!t||t<=0?jw:Math.min(t,Ww)}function d_(t){if(!t||t==="."||t==="/")return".";let e=t.split(/[/\\]/);return e[e.length-1]||"."}function Uf(t){return t.split(Nf).join("/")}re();import{readFileSync as P3}from"node:fs";import{dirname as N3,join as M3}from"node:path";import{fileURLToPath as z3}from"node:url";var Ar="0.1.95";var yn=H("agent-health-reporter"),l_=1e4,Li=class{constructor(e){this.opts=e;this.intervalMs=e.intervalMs??l_}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()}),yn.info("heartbeat started",{intervalMs:this.intervalMs}),this.tick())}stop(){this.timer&&(clearInterval(this.timer),this.timer=null,this.unsubscribeRegister&&(this.unsubscribeRegister(),this.unsubscribeRegister=null),yn.info("heartbeat stopped"))}async tick(){if(this.inFlight){yn.debug("previous tick still in-flight, skip");return}let e=this.opts.getDeviceId();if(!e){yn.debug("deviceId not available, skip tick (\u5C1A\u672A pair)");return}this.inFlight=!0;try{let n=[];for(let l of this.opts.core.agents.values()){let f=f_(l);if(!f)continue;let x={agentId:l.agentId,status:f};l.patToken&&(x.patToken=l.patToken),l.accountId&&(x.accountId=l.accountId),n.push(x)}if(n.length===0)return;let i={agents:n,bridgeVersion:Ar,_meta:{cozeDeviceId:e}},o;try{o=await this.opts.core.sendRequest("_agent/health",i,5e3)}catch(l){yn.warn("heartbeat batch send failed",{count:n.length,err:String(l)})}let c=o?.authFailures;if(c&&c.length>0&&(yn.warn("heartbeat received authFailures from cloud",{count:c.length,agentIds:c.map(l=>l.agentId)}),this.opts.onAuthFailures))try{await this.opts.onAuthFailures(c)}catch(l){yn.warn("onAuthFailures callback failed (ignored)",{err:String(l)})}}finally{this.inFlight=!1}if(this.opts.onTickEnd)try{await this.opts.onTickEnd()}catch(n){yn.warn("onTickEnd hook failed",{err:String(n)})}}};function f_(t){return t.status==="error"?"error":t.activeTriggers.size>0?"busy":t.status==="ok"?"online":null}on();import{chmod as ny,mkdir as ho,rm as ry,stat as iy,writeFile as sy}from"node:fs/promises";import{homedir as oy}from"node:os";import{join as ou}from"node:path";sn();import{spawnSync as T_}from"node:child_process";import{existsSync as C_}from"node:fs";import{release as D_}from"node:os";import{basename as R_,isAbsolute as k_}from"node:path";function Pi(t,e,n){return n===void 0?{jsonrpc:"2.0",id:t,method:e}:{jsonrpc:"2.0",id:t,method:e,params:n}}function Tr(t,e){return e===void 0?{jsonrpc:"2.0",method:t}:{jsonrpc:"2.0",method:t,params:e}}function Cr(t,e){return{jsonrpc:"2.0",id:t,result:e}}function En(t,e){return{jsonrpc:"2.0",id:t,error:e}}Ve();var so=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)}},ne={PARSE_ERROR:-32700,INVALID_REQUEST:-32600,METHOD_NOT_FOUND:-32601,INVALID_PARAMS:-32602,INTERNAL_ERROR:-32603,AGENT_NOT_FOUND:-32001,AGENT_BUSY:-32002,AGENT_TIMEOUT:-32003,AGENT_SPAWN_FAILED:-32004,OPERATION_NOT_ALLOWED_FOR_LOCAL:-32005,AGENT_DISCONNECTED:-32006,MODEL_TOKEN_GEN_FAILED:-32009,PATH_OUTSIDE_WORKSPACE:-32010,FILE_TOO_LARGE:-32011,UNSUPPORTED_MIME:-32012,UPLOAD_FAILED:-32013,UPSTREAM_NOT_READY:-32014,AGENT_FRAME_IDLE_TIMEOUT:-32016,MODEL_MODALITY_UNSUPPORTED:-32017,AGENT_DEPENDENCY_INSTALL_FAILED:-32018,AGENT_APPROVAL_TIMEOUT:-32019,AGENT_TURN_ABORTED:-32020};function qf(t){return"method"in t&&"id"in t&&t.id!==void 0}function Hf(t){return"method"in t&&!("id"in t)}function oo(t){return!("method"in t)&&"id"in t}var u_={AGENT_NOT_FOUND:ne.AGENT_NOT_FOUND,AGENT_BUSY:ne.AGENT_BUSY,AGENT_DISCONNECTED:ne.AGENT_DISCONNECTED,AGENT_TIMEOUT:ne.AGENT_TIMEOUT,AGENT_FRAME_IDLE_TIMEOUT:ne.AGENT_FRAME_IDLE_TIMEOUT,AGENT_SPAWN_FAILED:ne.AGENT_SPAWN_FAILED,AGENT_PROTOCOL_ERROR:ne.INTERNAL_ERROR,BRIDGE_CONFIG_INVALID:ne.INTERNAL_ERROR,BRIDGE_INTERNAL:ne.INTERNAL_ERROR,IPC_AUTH_FAILED:ne.INTERNAL_ERROR,IPC_BAD_REQUEST:ne.INVALID_REQUEST,MODEL_TOKEN_GEN_FAILED:ne.MODEL_TOKEN_GEN_FAILED,MODEL_MODALITY_UNSUPPORTED:ne.MODEL_MODALITY_UNSUPPORTED,OPERATION_NOT_ALLOWED_FOR_LOCAL:ne.OPERATION_NOT_ALLOWED_FOR_LOCAL,UPSTREAM_DISCONNECTED:ne.INTERNAL_ERROR,UPSTREAM_HANDSHAKE_FAILED:ne.INTERNAL_ERROR,PATH_OUTSIDE_WORKSPACE:ne.PATH_OUTSIDE_WORKSPACE,FILE_TOO_LARGE:ne.FILE_TOO_LARGE,UNSUPPORTED_MIME:ne.UNSUPPORTED_MIME,UPLOAD_FAILED:ne.UPLOAD_FAILED,UPSTREAM_NOT_READY:ne.UPSTREAM_NOT_READY,AGENT_DEPENDENCY_INSTALL_FAILED:ne.AGENT_DEPENDENCY_INSTALL_FAILED,AGENT_APPROVAL_TIMEOUT:ne.AGENT_APPROVAL_TIMEOUT,AGENT_TURN_ABORTED:ne.AGENT_TURN_ABORTED};function x_(t){if(t!=null)return t instanceof Error?{name:t.name,message:Oi(t.message)}:typeof t=="string"?Oi(t):typeof t=="object"?p_(t):t}var h_=[[/\/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 Oi(t){let e=t;for(let[n,i]of h_)e=e.replace(n,i);return e}function p_(t){let e={};for(let[n,i]of Object.entries(t))typeof i=="string"?e[n]=Oi(i):e[n]=i;return e}function Ni(t){if(t instanceof C){let e=x_(t.cause),n={bridgeCode:t.code,retriable:t.retriable};return e!==void 0&&(n.cause=e),{code:u_[t.code]??ne.INTERNAL_ERROR,message:Oi(t.message),data:n}}return{code:ne.INTERNAL_ERROR,message:Oi(t instanceof Error?t.message:String(t))}}function Gf(t){let e=t.data,n=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:l,...f}=e;c=f}return new C(n,o,{retriable:e?.retriable??!1,cause:c})}function Wf(t){return`${JSON.stringify(t)}
|
|
93
|
+
`}var jf=10*1024*1024,ao=class{buffer="";onError;constructor(e={}){this.onError=e.onError}push(e){if(this.buffer+=typeof e=="string"?e:e.toString("utf8"),this.buffer.length>jf){let o=this.buffer.length;return this.buffer="",this.onError?.({line:`<buffer overflow: ${o} bytes, dropped>`,error:new Error(`LdjsonDecoder buffer exceeded ${jf} bytes`)}),[]}let n=this.buffer.split(`
|
|
94
|
+
`);this.buffer=n.pop()??"";let i=[];for(let o of n){let c=o.replace(/\r$/,"").trim();if(c)try{i.push(JSON.parse(c))}catch(l){this.onError?.({line:c,error:l})}}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(n){return this.onError?.({line:e,error:n}),[]}}};var $f={"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"},V3=Object.fromEntries(Object.entries($f).map(([t,e])=>[e,t])),g_={"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:[]},Dr=class{seq=0;next(e,n){this.seq+=1;let i=$f[e]??m_(e),o=g_[i]??[],c=[i,String(this.seq)];if(o.length>0){let l=o.map(x=>Kf(n?.[x]??"")),f=w_(l).join(":");f&&c.push(f)}else n&&Object.values(n).some(l=>l)&&c.push(Object.values(n).filter(Boolean).map(l=>Kf(String(l))).join(":"));return c.join("_")}reset(){this.seq=0}};function m_(t){return t.replace(/[\s/]+/g,".").replace(/_+/g,"-")}function Kf(t){return t.replace(/[:_\s]+/g,"-")}function w_(t){let e=t.length;for(;e>0&&!t[e-1];)e-=1;return t.slice(0,e)}Qr();import{readFileSync as __}from"node:fs";var y_=384;async function $c(t,e=process.env){let n={};for(let[i,o]of Object.entries(e))typeof o=="string"&&(n[i]=o);await sr(t.agentEnvFile,n,{mode:y_})}function Jc(t){try{let e=JSON.parse(__(t,"utf8"));return e&&typeof e=="object"&&!Array.isArray(e)?e:{}}catch{return{}}}function Jf(t,e,n={},i=o=>o){return{...i({...t,...Jc(e)}),...n}}bn();ts();Ve();re();Oe();var L_=qt("COZE_BRIDGE_INITIALIZE_TIMEOUT_MS",3e4),P_=200,O_=40,N_=qt("COZE_BRIDGE_SESSION_PROMPT_MAX_MS",3600*1e3),M_=qt("COZE_BRIDGE_SESSION_PROMPT_FIRST_UPDATE_MS",600*1e3),B_=qt("COZE_BRIDGE_SESSION_PROMPT_APPROVAL_MAX_MS",1440*60*1e3),Yf=500;function z_(t){try{let e=JSON.stringify(t);return e===void 0||e.length<=Yf?t:`${e.slice(0,Yf)}...<truncated, total ${e.length} chars>`}catch{return"<unserializable>"}}function Qf(t,e){if(!(typeof t!="number"||t<=0))try{if(process.platform==="win32"){let n=["/PID",String(t),"/T"];e==="SIGKILL"&&n.push("/F"),T_("taskkill",n,{stdio:"ignore",windowsHide:!0})}else process.kill(-t,e)}catch{}}function eu(t){try{return C_(t)}catch{return}}function F_(t,e){return{platform:process.platform,osRelease:D_(),code:t.code,errno:t.errno,syscall:t.syscall,errPath:t.path,command:e.command,commandExists:k_(e.command)?eu(e.command):void 0,cwd:e.cwd,cwdExists:eu(e.cwd),envKeys:e.envKeys}}function U_(t,e){return`${t.message} [diag: platform=${e.platform} os=${e.osRelease} code=${e.code} errno=${e.errno} syscall=${e.syscall} cmd=${R_(e.command)} cmdExists=${e.commandExists} cwdExists=${e.cwdExists} envKeys=${e.envKeys}]`}var Nt=class{constructor(e){this.opts=e;this.log=H(`downstream.${this.constructor.name}`,this.opts.agentId),this.decoder=new ao({onError:n=>this.log.warn("decode line failed",{line:n.line})})}opts;child;decoder;pending=new Map;inflightAgentRequests=new Map;idAllocator=new Dr;updateHandlers=[];agentRequestHandlers=[];exitHandlers=[];log;stopped=!1;stopReason;stderrRing=[];sanitizeEnv(e){return e}async start(){if(this.child)throw new C("BRIDGE_INTERNAL","Downstream already started");let e=process.platform!=="win32",n=Jf(process.env,this.opts.agentEnvFile??Q().agentEnvFile,this.opts.env,o=>this.sanitizeEnv(o)),i=ut(this.opts.command,this.opts.args,{cwd:this.opts.cwd,env:n,stdio:["pipe","pipe","pipe"],detached:e});this.child=i,i.stdout?.setEncoding("utf8"),i.stdout?.on("data",o=>{try{for(let c of this.decoder.push(o))this.dispatch(c)}catch(c){this.log.warn("stdout dispatch threw, swallowed to keep daemon alive",{err:String(c)})}}),i.stderr?.setEncoding("utf8"),i.stderr?.on("data",o=>{let c=o.trimEnd();this.stderrRing.push(c),this.stderrRing.length>P_&&this.stderrRing.shift(),this.log.debug("stderr",{text:c})}),i.stdin?.on("error",o=>{this.log.warn("child stdin error",{err:String(o)})}),i.stdout?.on("error",o=>{this.log.warn("child stdout error",{err:String(o)})}),i.stderr?.on("error",o=>{this.log.warn("child stderr error",{err:String(o)})}),i.on("exit",(o,c)=>{this.stopped=!0,(o!==0||c!==null)&&this.stderrRing.length>0&&this.log.warn("downstream exited abnormally, recent stderr",{code:o,signal:c,recentStderr:[...this.stderrRing]});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(this.buildExitError(o,c));for(let f of this.exitHandlers)f(o,c)}),i.on("error",o=>{let c=o,l=F_(c,{command:this.opts.command,cwd:this.opts.cwd,envKeys:Object.keys(n).length});this.log.error("child error",{err:String(o),diag:l}),this.failAllPending(new C("AGENT_SPAWN_FAILED",U_(c,l),{cause:l}))}),this.log.info("downstream started",{command:this.opts.command,pid:i.pid,cwd:this.opts.cwd})}async stop(e){if(!this.child||this.stopped)return;this.stopped=!0,this.stopReason=e??"stopped",this.log.info("downstream stopping",{reason:e});let n=this.child,i=new Promise(c=>n.once("exit",()=>c()));Qf(n.pid,"SIGTERM");let o=setTimeout(()=>{n.killed||Qf(n.pid,"SIGKILL")},5e3);try{await i}finally{clearTimeout(o)}}pid(){return this.child?.pid}isAlive(){return!!this.child&&!this.stopped}getStderrTail(e){return e===void 0?[...this.stderrRing]:this.stderrRing.slice(-e)}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,n=N_,i=M_,o=B_){return this.call("session/prompt",e,n,i,o)}async sessionCancel(e){!this.child||this.stopped||this.writeFrame(Tr("session/cancel",e))}onUpdate(e){this.updateHandlers.push(e)}onAgentRequest(e){this.agentRequestHandlers.push(e)}respondAgentRequest(e,n){if(this.inflightAgentRequests.delete(e),!(!this.child||this.stopped))try{this.writeFrame(Cr(e,n))}catch(i){this.log.warn("respondAgentRequest write failed",{id:e,err:String(i)})}}respondAgentRequestError(e,n){if(this.inflightAgentRequests.delete(e),!(!this.child||this.stopped))try{this.writeFrame(En(e,n))}catch(i){this.log.warn("respondAgentRequestError write failed",{id:e,err:String(i)})}}onExit(e){this.exitHandlers.push(e)}call(e,n,i=L_,o=0,c=0){if(!this.child||this.stopped)return Promise.reject(new C("AGENT_PROTOCOL_ERROR","downstream not started"));let l=this.idAllocator.next(e),f=Pi(l,e,n),x=(()=>{if(typeof n!="object"||n===null)return;let v=n.sessionId;return typeof v=="string"?v:void 0})(),p=i>0&&Number.isFinite(i),w=o>0&&Number.isFinite(o);return new Promise((v,T)=>{let y={resolve:v,reject:T,timer:null,firstUpdateTimer:null,onFirstUpdate:null,method:e},b=Date.now();if(p){let A=()=>{y.timer=setTimeout(()=>{let R=Date.now()-b;if(this.inflightAgentRequests.size>0&&R<c){this.log.debug("hard cap fired but agent request inflight, extending to approval cap",{id:l,method:e,elapsed:R,approvalMaxMs:c,...x?{sessionId:x}:{}}),A();return}this.pending.delete(l),y.firstUpdateTimer&&clearTimeout(y.firstUpdateTimer);let P=this.inflightAgentRequests.size>0;this.log.warn("downstream call timeout",{id:l,method:e,timeoutMs:i,approvalMaxMs:c,awaitingApproval:P,...x?{sessionId:x}:{}}),T(P?new C("AGENT_APPROVAL_TIMEOUT",`${e} awaiting permission timed out after ${c}ms`):new C("AGENT_TIMEOUT",`${e} timed out after ${i}ms`))},i)};A()}let S=w?()=>{y.firstUpdateTimer&&clearTimeout(y.firstUpdateTimer),y.firstUpdateTimer=setTimeout(()=>{if(this.inflightAgentRequests.size>0){this.log.debug("first-update wait fired but agent request inflight, re-arming",{id:l,method:e,inflight:this.inflightAgentRequests.size,...x?{sessionId:x}:{}}),S?.();return}y.timer&&clearTimeout(y.timer),this.pending.delete(l),this.log.warn("first session/update timeout, rejecting pending call",{id:l,method:e,firstUpdateMs:o,...x?{sessionId:x}:{}}),T(new C("AGENT_FRAME_IDLE_TIMEOUT",`${e} no first session/update within ${o}ms`))},o)}:null;y.onFirstUpdate=w?()=>{y.firstUpdateTimer&&clearTimeout(y.firstUpdateTimer),y.firstUpdateTimer=null,y.onFirstUpdate=null}:null,this.pending.set(l,y),S?.();try{this.writeFrame(f)}catch(A){y.timer&&clearTimeout(y.timer),y.firstUpdateTimer&&clearTimeout(y.firstUpdateTimer),this.pending.delete(l),T(A)}})}writeFrame(e){if(!this.child?.stdin||this.child.stdin.destroyed)throw new C("AGENT_PROTOCOL_ERROR","downstream stdin not writable");this.child.stdin.write(Wf(e),n=>{n&&this.log.warn("stdin write callback err",{err:String(n)})})}dispatch(e){if(oo(e)){let n=e.id!==null?this.pending.get(e.id):void 0;if(!n){this.log.warn("orphan response",{id:e.id});return}this.pending.delete(e.id),n.timer&&clearTimeout(n.timer),n.firstUpdateTimer&&clearTimeout(n.firstUpdateTimer),e.error?(this.log.warn("downstream returned error frame",{id:e.id,method:n.method,code:e.error.code,message:e.error.message,data:e.error.data}),n.reject(Gf(e.error))):e.result===void 0?(this.log.warn("downstream response missing both result and error",{id:e.id,method:n.method}),n.reject(new C("AGENT_PROTOCOL_ERROR",`${n.method} response missing both result and error`))):(this.log.info("downstream returned result",{id:e.id,method:n.method,result:z_(e.result)}),n.resolve(e.result));return}if(Hf(e)){if(e.method==="session/update"){for(let n of this.pending.values())n.onFirstUpdate?.();for(let n of this.updateHandlers)try{Promise.resolve(n(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(qf(e)){let n=e;try{this.handleAgentRequest(n).catch(i=>this.log.error("agent request handler failed (async)",{method:n.method,err:String(i)}))}catch(i){this.log.warn("handleAgentRequest threw sync, swallowed",{method:n.method,err:String(i)})}}}async handleAgentRequest(e){if(this.agentRequestHandlers.length===0){this.writeFrame(En(e.id,{code:-32601,message:`method not handled by Bridge: ${e.method}`}));return}this.inflightAgentRequests.set(e.id,e.method);for(let n of this.agentRequestHandlers)try{await n(e)}catch(i){this.log.error("agentRequestHandler threw",{method:e.method,err:String(i)});try{this.writeFrame(En(e.id,Ni(i)))}catch{}this.inflightAgentRequests.delete(e.id)}}buildExitError(e,n){if(this.stopReason!==void 0)return new C("AGENT_TURN_ABORTED",`turn aborted: ${this.stopReason}`,{cause:{reason:this.stopReason}});let i=this.getStderrTail(O_).join(`
|
|
95
|
+
`);return new C("AGENT_PROTOCOL_ERROR",`agent exited (${e}/${n})`,{cause:{code:e,signal:n,stderrTail:i}})}failAllPending(e){for(let n of this.pending.values())n.timer&&clearTimeout(n.timer),n.firstUpdateTimer&&clearTimeout(n.firstUpdateTimer),n.reject(e);this.pending.clear(),this.inflightAgentRequests.clear()}};function q_(t){let e={};for(let[n,i]of Object.entries(t))i!==void 0&&(n.startsWith("CLAUDE")||n==="AI_AGENT"||n==="BAGGAGE"||(e[n]=i));return e}var co=class extends Nt{framework="claude-code";constructor(e){let{command:n,args:i}=Yr("claude-code",e.command,e.args??[]),o={command:n,args:i,cwd:e.cwd,agentId:e.agentId,...e.env?{env:e.env}:{}};super(o)}sanitizeEnv(e){return q_(e)}};sn();import{mkdtempSync as H_,rmSync as G_}from"node:fs";import{tmpdir as j_}from"node:os";import{join as W_}from"node:path";var lo=class extends Nt{framework="codex";authMethodId;codexHomeDir;constructor(e){let n=e.args??[],i=e.extraArgs?[...n,...e.extraArgs]:n,{command:o,args:c}=Yr("codex",e.command,i),l=e.isolateCodexHome?H_(W_(j_(),"coze-bridge-codex-home-")):void 0,f=l?{...e.env??{},CODEX_HOME:l}:e.env,x={command:o,args:c,cwd:e.cwd,agentId:e.agentId,...f?{env:f}:{}};super(x),this.authMethodId=e.authMethodId,this.codexHomeDir=l}async initialize(e){let n=await super.initialize(e);return this.authMethodId&&await this.call("authenticate",{methodId:this.authMethodId}),n}async stop(e){if(await super.stop(e),this.codexHomeDir)try{G_(this.codexHomeDir,{recursive:!0,force:!0})}catch{}}};var K_=3e4,Rr=class extends Nt{framework="openclaw";agentId;sessionName;slashModelOnStart;constructor(e){let n=e.sessionName??"default",i=["acp","--session",`agent:${e.agentId}:${n}`];e.gatewayToken&&i.push("--token",e.gatewayToken);let o={command:e.command,args:i,cwd:e.cwd,agentId:e.agentId,...e.env?{env:e.env}:{}};super(o),this.agentId=e.agentId,this.sessionName=n,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}`}]},K_))}get acpSessionName(){return this.sessionName}};Ve();re();Oe();function Vc(t){return t.replace(/[^A-Za-z0-9._-]+/g,"-")}sn();var vn=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((n,i)=>{this.slots.push({task:e,resolve:n,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 n=await e.task();e.resolve(n)}catch(n){e.reject(n)}}}finally{this.running=!1}}}};var fo=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 n=this.sessionQueues.get(e);return(!n||n.isDisposed)&&(n=new vn,this.sessionQueues.set(e,n)),n}allSessionQueues(){return this.sessionQueues.entries()}hasSessionQueue(e){let n=this.sessionQueues.get(e);return!!n&&!n.isDisposed}async dispose(e){this.status="stopped";let n=new Error(`AgentSession disposed${e?`: ${e}`:""}`);for(let i of this.sessionQueues.values())i.dispose(n);this.sessionQueues.clear(),await this.killAllRuntimes(e??"dispose")}async killAllRuntimes(e){let n=[];for(let[,i]of this.sessions)Mi(i),i.downstream&&(n.push(i.downstream.stop(e).catch(()=>{})),i.downstream=void 0);await Promise.all(n),this.activeTriggers.clear(),this.activeGroupIds.clear()}};function Mi(t){t.idleTimer&&(clearTimeout(t.idleTimer),t.idleTimer=void 0)}bn();re();import{constants as tu,access as $_}from"node:fs/promises";import{delimiter as J_,join as V_}from"node:path";var Sn=H("framework-detector"),nu={"claude-code":"claude",codex:"codex",openclaw:"openclaw"},Z_=[".exe",".cmd",".bat",".ps1"],jn=class{env;constructor(e={}){this.env={pathEnv:e.pathEnv??process.env.PATH??"",platform:e.platform??process.platform,spawn:e.spawn??ut,access:e.access??$_}}async detect(e){let n=nu[e],i=await this.which(n);if(!i)return Sn.debug("framework binary not found",{framework:e,bin:n}),null;let o=e==="openclaw"?["--log-level","silent"]:[],[c,l]=await Promise.all([this.probeVersion(i,o),e==="openclaw"?this.probeOpenclawDefaultAgent(i):Promise.resolve(null)]),f={path:i,version:c};return l&&(f.defaultAgent=l),f}async detectAll(){let e=await Promise.all(Object.keys(nu).map(async i=>[i,await this.detect(i)])),n={};for(let[i,o]of e)o&&(n[i]=o);return n}async which(e){let n=this.env.pathEnv.split(J_).filter(Boolean),i=this.env.platform==="win32"?["",...Z_]:[""];for(let o of n)for(let c of i){let l=V_(o,e+c);if(await this.isExecutable(l))return l}return null}async isExecutable(e){try{let n=this.env.platform==="win32"?tu.F_OK:tu.X_OK;return await this.env.access(e,n),!0}catch{return!1}}async probeOpenclawDefaultAgent(e){let n=await this.runProbe(e,["--log-level","silent","agents","list","--json"]);if(!n)return Sn.warn("openclaw default agent probe: runProbe returned null (spawn err / timeout)",{path:e}),null;if(n.code!==0)return Sn.warn("openclaw default agent probe: non-zero exit",{path:e,code:n.code,stdoutHead:n.stdout.slice(0,200)}),null;let i=n.stdout.match(/\[\s*\{[\s\S]*\}\s*\]/);if(!i)return Sn.warn("openclaw default agent probe: regex no match (no JSON array in stdout)",{path:e,stdoutHead:n.stdout.slice(0,200)}),null;try{let o=JSON.parse(i[0]);if(!Array.isArray(o))return Sn.warn("openclaw default agent probe: JSON parsed but not an array",{path:e}),null;let c=o.find(l=>l?.isDefault===!0);return c?!c.id||!c.workspace?(Sn.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}:(Sn.info("openclaw default agent probe: no agent has isDefault=true",{path:e,agentCount:o.length}),null)}catch(o){return Sn.warn("openclaw default agent probe: JSON.parse failed",{path:e,err:String(o),matchHead:i[0].slice(0,200)}),null}}async probeVersion(e,n=[]){let i=await this.runProbe(e,[...n,"--version"]);return i&&(Y_(i.stdout).split(/\r?\n/)[0]??"").trim()||"unknown"}runProbe(e,n){return new Promise(i=>{let o="",c=!1,l,f=x=>{c||(c=!0,l&&clearTimeout(l),i(x))};try{let x=this.env.spawn(e,n,{stdio:["ignore","pipe","pipe"]});l=setTimeout(()=>{x.kill("SIGKILL"),f(null)},15e3),x.stdout?.on("data",p=>{o+=p.toString("utf8")}),x.on("error",()=>f(null)),x.on("close",p=>f({code:p,stdout:o}))}catch{f(null)}})}},X_=new RegExp("\x1B\\[[0-9;]*[A-Za-z]","g");function Y_(t){return t.replace(X_,"")}import{homedir as Q_}from"node:os";import{join as ey}from"node:path";bn();Ve();Qr();re();async function su(){let t=ey(Q_(),".openclaw/openclaw.json");return(await ir(t))?.gateway?.auth?.token??""}var ru=H("openclaw.config"),ty=[0,5e3,5e3],iu="models.providers.",uo="agents.defaults.models",xo=class{command;env;retryDelaysMs;queue=new vn;constructor(e){this.command=e.command,this.env=e.env??process.env,this.retryDelaysMs=e.retryDelaysMs??ty}async withRetry(e,n){let i;for(let o=0;o<this.retryDelaysMs.length;o++){let c=this.retryDelaysMs[o]??0;c>0&&await new Promise(l=>setTimeout(l,c));try{return await n()}catch(l){i=l,ru.warn("openclaw cli failed, will retry",{label:e,attempt:o+1,err:String(l)})}}throw new C("AGENT_SPAWN_FAILED",`openclaw cli ${e} failed after ${this.retryDelaysMs.length} attempts: ${i?.message??"unknown"}`)}runCli(e){return new Promise((n,i)=>{let o=ut(this.command,e,{stdio:["ignore","pipe","pipe"],env:this.env}),c="";o.stderr?.on("data",l=>{c+=l.toString("utf8")}),o.on("error",i),o.on("close",l=>{l===0?n():i(new Error(`exit ${l}: ${c.trim().slice(0,500)}`))})})}async runCliTolerant(e,n){try{await this.runCli(e)}catch(i){let o=String(i);if(n.some(c=>o.includes(c)))return;throw i}}async bestEffortUnset(e,n){try{await this.queue.enqueue(()=>this.withRetry(e,()=>this.runCli(["config","unset",n])))}catch(i){ru.warn(`${e} failed (best-effort)`,{configPath:n,err:String(i)})}}ensureProvider(e,n){return this.queue.enqueue(()=>this.withRetry(`config set models.providers.${e}`,()=>this.runCli(["config","set",`${iu}${e}`,JSON.stringify(n),"--strict-json","--merge"])))}removeProvider(e){return this.bestEffortUnset(`config unset models.providers.${e}`,`${iu}${e}`)}addModelToAllowlist(e,n){let i={[e]:n?{alias:n}:{}};return this.queue.enqueue(()=>this.withRetry(`config set ${uo}[${e}]`,()=>this.runCli(["config","set",uo,JSON.stringify(i),"--strict-json","--merge"])))}removeModelFromAllowlist(e){return this.bestEffortUnset(`config unset ${uo}[${e}]`,`${uo}.${e}`)}ensureAgent(e,n,i){let o=["agents","add",e,"--workspace",n,"--non-interactive"];return i&&o.push("--model",i),this.queue.enqueue(()=>this.withRetry(`agents add ${e}`,()=>this.runCliTolerant(o,["already exists","already registered"])))}restartGateway(){return this.queue.enqueue(()=>this.withRetry("gateway restart",()=>this.runCli(["gateway","restart"])))}deleteAgent(e){return this.queue.enqueue(()=>this.withRetry(`agents delete ${e}`,()=>this.runCliTolerant(["agents","delete",e,"--force"],["not found","does not exist"])))}};var be=H("agent-manager"),ay=(t,e,n,i,o,c,l,f,x)=>{switch(t){case"claude-code":{let p={...o?{...Tf(o),...Rf(o,l,f)}:{},...x??{},IS_SANDBOX:"1"};return new co({cwd:n,env:p,agentId:i})}case"codex":{let w=[...o?[...Cf(o),...Lf(o,l,f)]:[],"-c",'sandbox_mode="danger-full-access"',"-c",'approval_policy="never"'],v={...o?Df(o):{},...x??{}},T=!!o;return new lo({cwd:n,agentId:i,...w.length>0?{extraArgs:w}:{},...Object.keys(v).length>0?{env:v}:{},...T?{authMethodId:"openai-api-key",isolateCodexHome:!0}:{}})}case"openclaw":return new Rr({command:e,cwd:n,agentId:i,...c?{sessionName:Vc(c)}:{}})}};function Zc(t){return t==="claude-code"||t==="codex"}function cy(t){let e=[],n=Object.keys(t).sort();for(let i of n){let o=t[i];o!==void 0&&(dy(o)||e.push(`${i}=${o}`))}return e.length===0?"":`${e.join(`
|
|
96
96
|
`)}
|
|
97
97
|
`}function dy(t){if(t.includes(`
|
|
98
|
-
`)||t.includes("\r")||t.includes("$")||t.includes("#"))return!0;let e=t[0];return e==="'"||e==='"'}var ly={path:"",version:"cloud-deployed"},uy={protocolVersion:1,clientCapabilities:{fs:{readTextFile:!0,writeTextFile:!0}}},fy=6e4,uo=class{paths;config;registry;factory;createTimeoutMs;openclawConfigCache;ensuredProviders=new Set;detectorFactory;openclawEnvBootstrapPromise;openclawConfigFactory;openclawConfigDir;constructor(e){this.paths=e.paths,this.config=e.config,this.registry=e.registry,this.factory=e.downstreamFactory??ay,this.createTimeoutMs=e.createTimeoutMs??fy,this.detectorFactory=e.detectorFactory??(()=>new Fn),this.openclawConfigFactory=e.openclawConfigFactory??(r=>new co({command:r})),this.openclawConfigDir=e.openclawConfigDir??nf(oy(),".openclaw")}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 C("AGENT_SPAWN_FAILED","openclaw binary not detected on this machine");this.openclawConfigCache=this.openclawConfigFactory(e.path)}return this.openclawConfigCache}bootstrapOpenclawEnvIfNeeded(){return this.openclawEnvBootstrapPromise?this.openclawEnvBootstrapPromise:(this.openclawEnvBootstrapPromise=this.doBootstrapOpenclawEnv().catch(e=>{_e.warn("openclaw env bootstrap failed (ignored)",{err:String(e)}),this.openclawEnvBootstrapPromise=void 0}),this.openclawEnvBootstrapPromise)}async doBootstrapOpenclawEnv(){let e=this.openclawConfigDir,r=nf(e,".env");if(await iy(r).then(c=>c.isFile()).catch(()=>!1)){_e.debug("openclaw .env exists, skip bootstrap",{envFile:r});return}await lo(e,{recursive:!0});let o=cy({...process.env,...Wc(this.paths.agentEnvFile)});if(await sy(r,o,"utf8"),process.platform!=="win32")try{await ny(r,384)}catch(c){_e.warn("chmod ~/.openclaw/.env to 0600 failed (ignored)",{err:String(c)})}_e.info("openclaw .env bootstrapped",{envFile:r,bytes:o.length}),await this.getOpenclawConfig().restartGateway(),_e.info("openclaw gateway restarted after env bootstrap")}async createAgent(e){if(!e.agentId)throw new C("IPC_BAD_REQUEST","agentId required");if(!e.framework)throw new C("IPC_BAD_REQUEST","framework required");let r=Ei(e._meta)==="cloud";this.registry.reviveIfDisconnected?.(e.agentId);let i=this.registry.get(e.agentId);if(i){if(i.framework!==e.framework)throw new C("AGENT_BUSY",`agent ${e.agentId} exists with different framework (${i.framework})`);if(i.status==="error")_e.warn("existing agent in error state, rebuilding",{agentId:e.agentId}),await i.dispose("rebuild after error").catch(E=>_e.warn("dispose stale agent failed (ignored)",{err:String(E)})),this.registry.unregister(e.agentId);else{if(e.patToken&&e.patToken!==i.patToken){_e.info("updating agent patToken on re-create (reconnect with new PAT)",{agentId:e.agentId}),i.setPatToken(e.patToken);let E=await Ge(e.agentId,this.paths).catch(()=>null);E&&(E.patToken=e.patToken,await Ze(E,this.paths))}if(i.deployType==="cloud"&&e.modelInfo){_e.info("updating agent modelInfo on re-create",{agentId:e.agentId}),i.setModelInfo(e.modelInfo);let E=await Ge(e.agentId,this.paths).catch(()=>null);E&&(E.modelInfo=e.modelInfo,await Ze(E,this.paths))}return _e.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 C("AGENT_SPAWN_FAILED",`framework ${e.framework} not detected on this machine; rerun daemon to refresh frameworks_cache`);let c=Ye(e.agentId,this.paths),l=Ei(e._meta),u=e.framework==="openclaw"&&l==="local",x=u?this.config.frameworksCache?.openclaw?.defaultAgent?.workspace:void 0,p=e.workspace??x??c.workspace,m=new AbortController,b=setTimeout(()=>m.abort(new C("AGENT_TIMEOUT",`_agent/create timed out after ${this.createTimeoutMs}ms`)),this.createTimeoutMs),I,y=!1;try{r&&$c(e.framework)&&await Xn(e.framework,m.signal);let E=()=>{if(m.signal.aborted)throw m.signal.reason instanceof Error?m.signal.reason:new C("AGENT_TIMEOUT","_agent/create aborted")};await lo(c.root,{recursive:!0}),await lo(p,{recursive:!0}),await lo(c.logs,{recursive:!0}),E(),u||await tr(p,e.framework,e.cozeIdentity),e.framework==="claude-code"&&await wl(p),E();let S=await Ge(e.agentId,this.paths).catch(()=>null),A=bu({model:e.model??S?.model}),D=xu(e._meta)??S?.accountId,L=e.patToken??S?.patToken,_=l==="cloud"?e.modelInfo??S?.modelInfo:void 0;if(I=new oo({agentId:e.agentId,framework:e.framework,workspace:p,model:A.model??_t,deployType:l,...D?{accountId:D}:{},...L?{patToken:L}:{},..._?{modelInfo:_}:{}}),I.status="ok",S?.sessions){for(let[F,V]of Object.entries(S.sessions))I.sessions.set(F,{acpSessionId:V.acpSessionId,modelToken:V.modelToken,tokenGeneratedAt:V.tokenGeneratedAt,lastActiveAt:Date.now(),loadingSession:!1,replySeq:0});let z=Object.keys(S.sessions).length;z>0&&_e.info("restored persisted session records (no spawn)",{agentId:e.agentId,count:z})}this.registry.register(I),y=!0;let R={agentId:e.agentId,framework:e.framework,workspace:p,cozeIdentity:e.cozeIdentity,createdAt:S?.createdAt??Date.now(),sessions:S?.sessions??{},model:A.model};l==="cloud"&&(R.deployType="cloud"),D&&(R.accountId=D),L&&(R.patToken=L),_&&(R.modelInfo=_),S?.skills&&(R.skills=S.skills),S?.agentName&&(R.agentName=S.agentName),S?.description&&(R.description=S.description),e.framework==="openclaw"&&l==="cloud"&&(this.config.frameworksCache?.openclaw?.path?(await this.bootstrapOpenclawEnvIfNeeded(),await this.getOpenclawConfig().ensureAgent(e.agentId,p)):_e.warn("openclaw binary not on this machine, skip agents add (will fail at session/prompt)",{agentId:e.agentId}));let k=e.initialSkills??[];if(k.length>0){let z=[...R.skills??[]],F=new Map(z.map((ee,X)=>[ee.skillId,X])),V=await Promise.allSettled(k.map(ee=>qc({agentId:e.agentId,workspace:p,framework:e.framework,skill:ee}))),J=0;for(let[ee,X]of V.entries()){let ve=k[ee];ve&&(X.status==="fulfilled"?(Gc(z,F,X.value),J++):_e.warn("initialSkill install failed (skipping)",{agentId:e.agentId,skillId:ve.skillId,skillName:ve.skillName,err:String(X.reason)}))}J>0&&(R.skills=z,_e.info("initialSkills installed",{agentId:e.agentId,installed:J,requested:k.length}))}return await Ze(R,this.paths),_e.info("agent created (no spawn, lazy on first prompt)",{agentId:e.agentId,framework:e.framework,deployType:l}),{ok:!0,agentId:e.agentId,workspace:p,framework:e.framework}}catch(E){throw _e.error("agent create failed, rolling back",{agentId:e.agentId,err:String(E)}),y&&I&&(await I.dispose("rollback").catch(()=>{}),this.registry.unregister(e.agentId)),await ry(c.root,{recursive:!0,force:!0}).catch(S=>_e.warn("rm agent dir failed (ignored)",{err:String(S)})),E instanceof C?E:new C("AGENT_SPAWN_FAILED",String(E),{cause:E})}finally{clearTimeout(b)}}async spawnSessionDownstream(e,r,i,o,c){let u=this.config.frameworksCache?.[e.framework];if(!u)if(e.deployType==="cloud"&&$c(e.framework))u=ly;else throw new C("AGENT_SPAWN_FAILED",`framework ${e.framework} not detected on this machine`);$c(e.framework)&&!ns(e.framework)&&(_e.info("spawn: resolving acp wrapper",{agentId:e.agentId,framework:e.framework}),await Xn(e.framework));let x=e.deployType==="cloud"?{model:e.model,modelToken:r,...e.modelInfo?{modelInfo:e.modelInfo}:{}}:void 0,p;e.framework==="openclaw"?p=await this.buildOpenclawDownstream({session:e,modelConfig:x,cloudSessionId:i,cozeEnv:o,mockScenario:c,command: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(uy),p}catch(m){let b=p instanceof Dt?p.getStderrTail():[];throw b.length>0&&_e.warn("spawnSessionDownstream failed, recent stderr (D94)",{agentId:e.agentId,framework:e.framework,method:m instanceof C?m.code:"unknown",recentStderr:b}),await p.stop("spawnSessionDownstream failed").catch(()=>{}),m instanceof C?new C(m.code,m.message,{retriable:m.retriable,cause:m.cause??m}):new C("AGENT_SPAWN_FAILED",m instanceof Error?m.message:String(m),{cause:m})}}async buildOpenclawDownstream(e){let{session:r,modelConfig:i,cloudSessionId:o,cozeEnv:c,mockScenario:l,command:u}=e,x=Kc(o);if(r.deployType==="local"){let I=this.config.frameworksCache?.openclaw?.defaultAgent;if(!I?.id||!I.workspace){_e.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)_e.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 C("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 Ir({command:u,cwd:I.workspace,agentId:I.id,sessionName:x})}let p=await tf(),m=i?Tu(i,c,l):null,b;if(m){let I=Nc(o),E=m.models[0]?.id??_t,S=`${I}/${E}`;if(!this.ensuredProviders.has(S)){let A=this.getOpenclawConfig();await A.ensureProvider(I,m),await A.addModelToAllowlist(S),this.ensuredProviders.add(S)}b=S}return new Ir({command:u,cwd:r.workspace,agentId:r.agentId,sessionName:x,...p?{gatewayToken:p}:{},...b?{slashModelOnStart:b}:{}})}async openclawRepair(e,r){let i=this.getOpenclawConfig();await i.deleteAgent(e),await i.ensureAgent(e,r)}async cleanupOpenclawSessionProviders(e){if(e.framework!=="openclaw"||!this.openclawConfigCache)return;let r=this.openclawConfigCache;for(let i of e.sessions.keys()){let o=Nc(i),c=`${o}/${e.model}`,l=!0;try{await r.removeProvider(o)}catch(u){l=!1,_e.warn("removeProvider failed, keeping ensuredProviders entry",{providerId:o,err:String(u)})}try{await r.removeModelFromAllowlist(c)}catch(u){l=!1,_e.warn("removeModelFromAllowlist failed, keeping ensuredProviders entry",{fullModelId:c,err:String(u)})}l&&this.ensuredProviders.delete(c)}}};import{randomUUID as cf}from"node:crypto";import{promises as yy}from"node:fs";import{basename as df}from"node:path";Ke();ne();import{promises as hy}from"node:fs";import{basename as py}from"node:path";var rf=H("file-upload"),gy="/api/coze_claw/file/agent_upload",my=6e4;async function sf(t,e={}){let i=`${Zs(Qs(e.handshakeBase))}${gy}`,o=e.timeoutMs??my,c=await hy.readFile(t.path),l=new FormData;l.append("agent_id",t.agentId),l.append("session_id",t.sessionId),l.append("file_name",t.name),l.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",..._r(e.ppeOverride),...t.accountId?{"x-coze-account":t.accountId}:{}},x=new AbortController,p=setTimeout(()=>x.abort(),o);rf.info("file upload start",{url:i,agentId:t.agentId,sessionId:t.sessionId,name:t.name,bytes:t.sizeBytes,mime:t.mimeType});try{let m=await fetch(i,{method:"POST",headers:u,body:l,signal:x.signal}),b=m.headers.get("x-tt-logid")??"";if(!m.ok){let E=await m.text().catch(()=>"");throw new C("UPLOAD_FAILED",`upload HTTP ${m.status} logid=${b}: ${E.slice(0,200)}`)}let I=await m.json();if(I.code!==void 0&&I.code!==0)throw new C("UPLOAD_FAILED",`upload code=${I.code} msg=${I.msg??"-"} logid=${b}`);let y=I.data?.file?.file_url;if(!y)throw new C("UPLOAD_FAILED",`upload response missing data.file.file_url logid=${b}: ${JSON.stringify(I).slice(0,200)}`);return rf.info("file upload ok",{uri:y,logid:b}),{uri:y}}catch(m){throw m instanceof C?m:m.name==="AbortError"?new C("UPLOAD_FAILED",`upload timeout (${o}ms) for ${py(t.path)}`):new C("UPLOAD_FAILED",String(m),{cause:m})}finally{clearTimeout(p)}}Ke();ne();import{extname as wy}from"node:path";var _y={".png":"image/png",".jpg":"image/jpeg",".jpeg":"image/jpeg",".gif":"image/gif",".webp":"image/webp",".svg":"image/svg+xml",".bmp":"image/bmp",".ico":"image/x-icon",".heic":"image/heic",".heif":"image/heif",".pdf":"application/pdf",".doc":"application/msword",".docx":"application/vnd.openxmlformats-officedocument.wordprocessingml.document",".xls":"application/vnd.ms-excel",".xlsx":"application/vnd.openxmlformats-officedocument.spreadsheetml.sheet",".ppt":"application/vnd.ms-powerpoint",".pptx":"application/vnd.openxmlformats-officedocument.presentationml.presentation",".txt":"text/plain",".md":"text/markdown",".markdown":"text/markdown",".json":"application/json",".yaml":"text/yaml",".yml":"text/yaml",".csv":"text/csv",".html":"text/html",".htm":"text/html",".xml":"application/xml",".log":"text/plain",".zip":"application/zip",".tar":"application/x-tar",".gz":"application/gzip",".tgz":"application/gzip",".mp3":"audio/mpeg",".wav":"audio/wav",".mp4":"video/mp4",".mov":"video/quicktime",".webm":"video/webm"};async function of(t){let e=wy(t).toLowerCase();return _y[e]??"application/octet-stream"}De();var fo=H("agent-send"),af=50*1024*1024;function lf(t,e,r){let i=t.get(e);if(!i)throw new C("AGENT_NOT_FOUND",`agent=${e}`);if(t.disconnectedAgents.has(e))throw new C("AGENT_DISCONNECTED",`agent=${e} was disconnected by cloud`);let o=i.sessions.get(r);if(!o)throw new C("AGENT_NOT_FOUND",`session=${r} not active in agent=${e}`);return{session:i,runtime:o}}async function uf(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&&(fo.warn("sendAgentFileUpdate failed, retrying",{attempt:x+1,err:String(p)}),await new Promise(m=>setTimeout(m,5e3)))}throw new C("UPSTREAM_NOT_READY",`${c} after 3 attempts: ${String(u)}`,{cause:u})}async function ff(t,e){let{session:r,runtime:i}=lf(e.core,t.agentId,t.sessionId);if(!await Jr(t.path,r.workspace))throw new C("PATH_OUTSIDE_WORKSPACE",`path=${t.path} not under workspace=${r.workspace}`);let o=await yy.stat(t.path).catch(()=>null);if(!o||!o.isFile())throw new C("IPC_BAD_REQUEST",`path is not a regular file: ${t.path}`);if(o.size>af)throw new C("FILE_TOO_LARGE",`${o.size} bytes > limit ${af}`);let c=await of(t.path);if(t.kind==="image"&&!c.startsWith("image/"))throw new C("UNSUPPORTED_MIME",`kind=image but mime=${c}`);if(!e.core.upstream.isConnected())throw new C("UPSTREAM_NOT_READY","cloud WS not connected");let l=t.name??df(t.path),u;try{u=await sf({patToken:r.patToken??e.patToken,agentId:t.agentId,sessionId:t.sessionId,path:t.path,mimeType:c,name:l,sizeBytes:o.size,...r.accountId?{accountId:r.accountId}:{}},{handshakeBase:e.handshakeBase,ppeOverride:e.ppeOverride})}catch(p){throw fo.warn("agent file upload failed",{agentId:t.agentId,sessionId:t.sessionId,path:t.path,sizeBytes:o.size,mime:c,code:p instanceof C?p.code:"UNKNOWN",message:p instanceof Error?p.message:String(p)}),p}let x={sessionUpdate:"agent_file",messageId:cf(),content:{type:t.kind==="image"?"image":"resource",uri:u.uri,mimeType:c,name:l,sizeBytes:o.size,...u.fileId!==void 0?{fileId:u.fileId}:{},...t.caption!==void 0?{caption:t.caption}:{}}};return await uf(e,r,i,t.sessionId,x,"agent file uploaded to cloud but sendAgentFileUpdate failed"),fo.info("agent file sent",{agentId:t.agentId,sessionId:t.sessionId,kind:t.kind,name:l,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 xf(t,e){let{session:r,runtime:i}=lf(e.core,t.agentId,t.sessionId);if(!t.mimeType)throw new C("IPC_BAD_REQUEST","group-file requires mimeType");if(!e.core.upstream.isConnected())throw new C("UPSTREAM_NOT_READY","cloud WS not connected");let o=t.name??df(t.path),c={sessionUpdate:"group_file",messageId:cf(),content:{uri:t.path,name:o,mimeType:t.mimeType,...t.caption!==void 0?{caption:t.caption}:{}}};return await uf(e,r,i,t.sessionId,c,"agent group file sendAgentFileUpdate failed"),fo.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 hf(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 l=r[c]??0,u=i[c]??0;if(l<u)return!0;if(l>u)return!1}return!1}Qt();mn();ne();var kt=H("coze-cli-installer"),pf="@coze/cli@latest",by="coze",gf="0.1.8",Ey=5e3,vy=5e3,Sy=9e4,mf=1e4,ki=null,xo=!1;async function Jc(t,e={}){if(xo)return;if(ki)return ki;let r=e.exec??$u;return ki=(async()=>{try{let i=await Iy(by,r),o=!1;if(i){let l=await Ay(r);if(l===void 0)kt.warn("coze-cli found but version unparseable, fall through to full install",{path:i});else if(hf(l,gf))kt.info("coze-cli version too old, upgrade-only (preserve user config + auth)",{path:i,version:l,min:gf}),o=!0;else{kt.info("coze-cli already on PATH with sufficient version, skip",{path:i,version:l}),xo=!0;return}}let c=o?"upgrade-only":"full";kt.info("coze-cli install start",{package:pf,mode:c});try{await r("npm",["i","-g","--prefer-online",pf],{timeout:Sy,maxBuffer:10*1024*1024}),kt.info("coze-cli install ok")}catch(l){kt.warn("coze-cli install failed (skip subsequent steps)",{err:String(l)});return}if(o){xo=!0;return}if(t.env)try{await r("coze",["config","set","xTTEnv",t.env],{timeout:mf}),kt.info("coze config set xTTEnv ok",{env:t.env})}catch(l){kt.warn("coze config set failed (continue to auth login)",{err:String(l)})}try{await r("coze",["auth","login","--token",t.patToken],{timeout:mf}),kt.info("coze auth login ok")}catch(l){kt.warn("coze auth login failed",{err:String(l)});return}xo=!0}finally{ki=null}})(),ki}async function Iy(t,e){let r=process.platform==="win32"?"where":"which";try{let{stdout:i}=await e(r,[t],{timeout:Ey});return ya(i)}catch{return}}async function Ay(t){try{let{stdout:e,stderr:r}=await t("coze",["--version"],{timeout:vy});return(e||r).match(/(\d+\.\d+\.\d+)/)?.[1]}catch{return}}$r();De();var Ty=10*6e4;function wf(t){let e=t?.sessionIdleTimeoutMs;return typeof e!="number"||!Number.isFinite(e)||e<=0?Ty:e}function ho(t){return Qn(t??Q().configFile)}function Pi(t,e){return er(e??Q().configFile,t)}import{randomBytes as $y}from"node:crypto";Zi();Ke();ne();import{createReadStream as Cy}from"node:fs";import{mkdir as Ry,readFile as Dy,realpath as ky,stat as Py,writeFile as Ly}from"node:fs/promises";import{basename as Oy,dirname as Vc,isAbsolute as Ny,join as My,relative as By,resolve as _f,sep as zy}from"node:path";import{createInterface as Fy}from"node:readline";var bf=H("fs-rpc"),Li=Mt("COZE_BRIDGE_FS_RPC_MAX_BYTES",20*1024*1024);async function Ef(t,e){let r=Buffer.byteLength(t.content,"utf8");if(r>Li)throw new C("IPC_BAD_REQUEST",`fs/write_text_file content too large: ${r} bytes > limit ${Li} bytes`);let i=await Sf(t.path,e);return await Ry(Vc(i),{recursive:!0}),await Ly(i,t.content,"utf8"),bf.info("fs/write_text_file ok",{path:i,size:t.content.length}),null}async function vf(t,e){let r=await Sf(t.path,e),i=await Py(r),o=typeof t.line=="number"||typeof t.limit=="number";if(i.size>Li&&!o)throw new C("IPC_BAD_REQUEST",`fs/read_text_file too large without line/limit slicing: ${i.size} bytes > ${Li} bytes`);let c;if(o&&i.size>Li)c=await Uy(r,t.line??1,t.limit);else{let l=await Dy(r,"utf8");if(o){let u=l.split(`
|
|
99
|
-
`),x=Math.max(0,(t.line??1)-1),p=typeof t.limit=="number"?x+t.limit:void 0;c=
|
|
100
|
-
`)}else c=l}return
|
|
101
|
-
`)}async function Sf(t,e){if(typeof t!="string"||t.length===0)throw new C("IPC_BAD_REQUEST","path must be a non-empty string");let[r,i]=await Promise.all([yf(_f(e)),yf(_f(t))]),o=By(r,i);if(Hy(o,zy,Ny(o)))throw new C("IPC_BAD_REQUEST",`path escapes workspace: ${t}`);return i}function Hy(t,e,r){return t===""?!1:r?!0:t===".."||t.startsWith(`..${e}`)}async function yf(t){let e=[],r=t;for(;r!==Vc(r);)try{let i=await ky(r);return e.length?My(i,...e.reverse()):i}catch{e.push(Oy(r)),r=Vc(r)}return t}ne();var If=H("prompt-multimodal"),Af=10*1024*1024,qy=15e3,Gy=6;async function Tf(t){let e=new Array(t.length),r=0;async function i(){for(;r<t.length;){let c=r++,l=t[c];l!==void 0&&(e[c]=await jy(l))}}let o=Array.from({length:Math.min(Gy,t.length)},()=>i());return await Promise.all(o),e}function Cf(t){return t.some(e=>e.type==="image")}async function jy(t){if(t.type!=="image")return t;let e=t;if(e.data||!e.uri||!Ys(e.uri))return t;try{let{buf:r,contentType:i}=await Ky(e.uri),o=e.mimeType||Wy(i)||"application/octet-stream";return If.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 If.warn("image fetch failed, degrading to text block",{uri:e.uri,err:String(r)}),{type:"text",text:`[image load failed: ${e.uri}]`}}}function Wy(t){if(!t)return;let e=t.indexOf(";");return(e===-1?t:t.slice(0,e)).trim()||void 0}async function Ky(t){let e=new AbortController,r=setTimeout(()=>e.abort(),qy);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>Af)throw new Error(`image too large: ${o.byteLength} bytes (max ${Af})`);return{buf:Buffer.from(o),contentType:i.headers.get("content-type")??void 0}}finally{clearTimeout(r)}}en();Ke();ne();var $=H("core"),Jy=3e4,Vy=/^(boe|ppe)_[A-Za-z0-9_-]+$/,Yy="\u6211\u6B63\u5728\u7B49\u5F85\u5BA1\u6279\uFF0C\u8BF7\u7A0D\u540E\u518D\u8054\u7CFB\u6211",Zy="\u5BA1\u6279\u5DF2\u8D85\u65F6",Xy=3e4,po=class{upstream;agents=new Map;disconnectedAgents=new Set;extensions;paths;sessionSpawner;sessionIdleTimeoutMs;upstreamIds=new Sr;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=wf(e.bridgeConfig)}registerExtension(e,r){this.extensions[e]=r}getCozeEnv(){return this.currentCozeEnv}getMockScenario(){return this.currentMockScenario}setMockScenario(e){this.currentMockScenario=e&&e.length>0?e:void 0}async start(){this.upstream.onFrame(e=>this.handleFrame(e)),this.upstream.onConnect?.(({initial:e})=>{e||this.rejectAllPendingOnReconnect()}),await this.upstream.start(),$.info("Core started",{extensions:Object.keys(this.extensions)})}async stop(e){$.info("Core stopping",{reason:e}),await Promise.all([...this.agents.values()].map(r=>r.dispose(e))),this.agents.clear(),await this.upstream.stop(e)}async reloadAgents(e){let r=e?this.agents.has(e)?[e]:[]:[...this.agents.keys()];for(let i of r)await this.agents.get(i)?.killAllRuntimes("reload");return r}get(e){return this.agents.get(e)}register(e){this.agents.set(e.agentId,e),$.info("agent registered",{agentId:e.agentId,framework:e.framework});for(let r of this.registerHandlers)try{r(e.agentId)}catch(i){$.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)&&$.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,l)=>{$.info("session runtime exited",{agentId:e.agentId,cloudId:r,code:c,signal:l}),Di(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){$.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(gn(o,{code:te.INTERNAL_ERROR,message:`bridge downstream gone: ${r}`})).catch(l=>$.debug("send error response to upstream failed (ignored)",{err:String(l)}));try{c.downstream.respondAgentRequestError(c.agentRequestId,{code:te.INTERNAL_ERROR,message:`bridge: ${r}`})}catch{}}}}}rejectAllPendingOnReconnect(){let e=this.pendingUpstream.size,r=this.pendingBridge.size;if(!(e===0&&r===0)){$.warn("upstream reconnected, rejecting stale pending requests",{pendingUpstream:e,pendingBridge:r});for(let[,i]of this.pendingUpstream){try{i.downstream.respondAgentRequestError(i.agentRequestId,{code:te.INTERNAL_ERROR,message:"upstream reconnected; please retry"})}catch{}this.clearPendingPermissionFor(i)}this.pendingUpstream.clear();for(let[,i]of this.pendingBridge)clearTimeout(i.timer),i.reject(new C("UPSTREAM_DISCONNECTED",`${i.method} aborted: upstream reconnected`));this.pendingBridge.clear()}}async handleFrame(e){if(no(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&&Vy.test(i)?this.currentCozeEnv=i:i&&$.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,te.METHOD_NOT_FOUND,`extension not registered: ${e.method}`):$.warn("drop notification: extension not registered",{method:e.method});return}let c=await o(e,this);r!==null&&await this.upstream.send(vr(r,c));return}if(e.method.startsWith("session/")){let o=await this.routeSessionMethod(e);r!==null&&await this.upstream.send(vr(r,o));return}if(e.method==="initialize"){r!==null&&await this.upstream.send(vr(r,{protocolVersion:1,agentCapabilities:{loadSession:!0}}));return}r!==null?await this.sendError(r,te.METHOD_NOT_FOUND,`method not implemented: ${e.method}`):$.warn("drop unknown notification",{method:e.method})}catch(o){$.error("handleFrame failed",{method:e.method,err:String(o)}),r!==null&&await this.upstream.send(gn(r,Ri(o)))}}async routeSessionMethod(e){if(!e.params||typeof e.params!="object")throw new C("IPC_BAD_REQUEST",`${e.method} requires params`);let r=e.params,i=r._meta?.cozeAgentId;if(!i)throw new C("IPC_BAD_REQUEST",`${e.method}: missing _meta.cozeAgentId`);let o=this.agents.get(i);if(!o)throw this.disconnectedAgents.has(i)?new C("AGENT_DISCONNECTED",`agent ${i} has been disconnected; cloud must _agent/create to revive`):new C("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);if(e.method==="session/prompt"){let x=o.sessions.get(c);if(x?.pendingPermission){let p=r._meta?.cozeTriggerMsgId,m=Dc(r._meta);return $.info("session in pendingPermission, bouncing new prompt",{agentId:o.agentId,cloudSessionId:c}),this.synthesizePromptReply(o,x,c,Yy,p,m)}}let l=Date.now(),u=!1;try{let x=await o.getSessionQueue(c).enqueue(()=>this.dispatchSessionCall(o,e.method,r));return u=!0,x}finally{$.info("session call done",{agentId:o.agentId,method:e.method,durationMs:Date.now()-l,ok:u})}}async dispatchSessionCall(e,r,i){e.lastActiveAt=Date.now();let{stripped:o}=hu(i);switch(r){case"session/new":{let c=Qy();return $.info("session/new ack (lazy spawn)",{agentId:e.agentId,cloudId:c}),{sessionId:c}}case"session/load":{let c=o;return $.info("session/load ack (lazy spawn)",{agentId:e.agentId,cloudId:c.sessionId}),{}}case"session/prompt":{let c=o,l=c.sessionId;if(!l)throw new C("IPC_BAD_REQUEST","session/prompt: missing sessionId");let u=await this.ensureRuntime(e,l);if(u.replySeq=0,await this.ensureDownstream(e,l,u),!u.downstream||!u.acpSessionId)throw new C("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=Dc(i._meta);if(p?e.activeGroupIds.set(u.acpSessionId,p):e.activeGroupIds.delete(u.acpSessionId),e.deployType==="cloud"&&e.modelInfo?.capabilities?.image===!1&&Cf(c.prompt))throw new C("MODEL_MODALITY_UNSUPPORTED",`model=${e.modelInfo.id??e.model} does not support image input`);let m=await Tf(c.prompt);try{let b=await u.downstream.sessionPrompt({...c,sessionId:u.acpSessionId,prompt:m});return u.lastActiveAt=Date.now(),b}catch(b){if(b instanceof C&&b.code==="AGENT_APPROVAL_TIMEOUT"){let I=u.pendingPermission;I&&(I.downstream.respondAgentRequest(I.agentRequestId,{outcome:{outcome:"cancelled"}}),this.pendingUpstream.delete(I.upstreamId),u.pendingPermission=void 0);let y=u.acpSessionId,E=y?e.activeTriggers.get(y):void 0,S=y?e.activeGroupIds.get(y):void 0;return $.warn("approval timed out, synthesizing \u5BA1\u6279\u5DF2\u8D85\u65F6 reply + recovering session",{agentId:e.agentId,cloudId:l}),await this.synthesizePromptReply(e,u,l,Zy,E,S)}throw b}finally{if(e.activeTriggers.delete(u.acpSessionId),e.activeGroupIds.delete(u.acpSessionId),u.pendingPermission=void 0,u.reloadAfterTurn){u.reloadAfterTurn=!1;let b=u.downstream;b&&(u.downstream=void 0,$.info("reloadAfterTurn: stopping downstream",{agentId:e.agentId,cloudId:l,acpId:u.acpSessionId}),b.stop("reload-after-turn").catch(I=>$.warn("reload-after-turn stop failed (ignored)",{agentId:e.agentId,cloudId:l,err:String(I)})))}else u.downstream?.isAlive()&&this.armIdleTimer(e,l,u)}}case"session/cancel":{let l=o.sessionId;if(!l)throw new C("IPC_BAD_REQUEST","session/cancel: missing sessionId");let u=e.sessions.get(l);if(e.hasSessionQueue(l)){let x=e.getSessionQueue(l);x.size>0&&($.info("session/cancel: draining queued tasks",{agentId:e.agentId,cloudId:l,queuedCount:x.size}),x.dispose(new C("AGENT_PROTOCOL_ERROR",`cancelled by session/cancel on ${l}`)))}return u?.downstream?.isAlive()&&u.acpSessionId&&await u.downstream.sessionCancel({sessionId:u.acpSessionId}),{ok:!0}}default:throw new C("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(wt.GEN_MODEL_TOKEN,i,Xy);if(!o?.modelToken)throw new C("MODEL_TOKEN_GEN_FAILED",`cloud returned empty modelToken (agentId=${e}, cloudSessionId=${r})`);return o.modelToken}catch(o){throw o instanceof C&&o.code==="MODEL_TOKEN_GEN_FAILED"?o:new C("MODEL_TOKEN_GEN_FAILED",o instanceof Error?o.message:String(o),{cause:o})}}async ensureDownstream(e,r,i){if(Di(i),i.downstream?.isAlive())return;if(!this.sessionSpawner)throw new C("AGENT_SPAWN_FAILED","sessionSpawner not wired (cannot spawn per-session downstream)");let o=3,c=3e4,l=i.spawnFailCount??0,u=i.spawnFailedAt??0;if(l>=o&&Date.now()-u<c)throw new C("AGENT_SPAWN_FAILED",`agent ${e.agentId} session ${r} spawn failed ${l} 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=l+1,i.spawnFailedAt=Date.now(),i.spawnFailCount>=o&&i.acpSessionId&&($.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}),$.info("session restored via session/load",{agentId:e.agentId,cloudId:r,acpId:i.acpSessionId})}catch(p){$.warn("session/load failed, fallback to session/new",{agentId:e.agentId,cloudId:r,acpId:i.acpSessionId,err:String(p)}),i.acpSessionId=void 0;let m=await x.sessionNew({cwd:e.workspace});i.acpSessionId=m.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(Di(i),this.isRuntimeBusy(e,i)){$.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)){$.info("idle reaper fired but runtime busy, re-arming",{agentId:e.agentId,cloudId:r}),this.armIdleTimer(e,r,i);return}$.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=>$.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 l=e.activeTriggers.get(r.acpSessionId);l&&(c.cozeTriggerMsgId=l);let u=e.activeGroupIds.get(r.acpSessionId);u&&(c.cozeGroupId=u)}await this.upstream.send(Er("session/update",{sessionId:i,update:o,_meta:c}))}async synthesizePromptReply(e,r,i,o,c,l){let u={cozeAgentId:e.agentId,cozeReplySeqID:++r.replySeq};return c&&(u.cozeTriggerMsgId=c),l&&(u.cozeGroupId=l),await this.upstream.send(Er("session/update",{sessionId:i,update:{sessionUpdate:"agent_message_chunk",content:{type:"text",text:o}},_meta:u})).catch(x=>$.warn("synthesizePromptReply update send failed (ignored)",{err:String(x)})),{stopReason:"end_turn"}}forwardUpdate(e,r){let i=r.sessionId,o=this.reverseSessionId(e,i);if(!o){$.debug("drop update for unknown session",{agentId:e.agentId,acpId:i});return}let c=e.sessions.get(o);if(!c){$.debug("drop update: runtime gone",{agentId:e.agentId,cloudId:o});return}if(tb(r)){$.debug("drop codex metadata-warn chunk",{agentId:e.agentId,acpId:i});return}let l={cozeAgentId:e.agentId,cozeReplySeqID:++c.replySeq},u=e.activeTriggers.get(i);u&&(l.cozeTriggerMsgId=u);let x=e.activeGroupIds.get(i);x&&(l.cozeGroupId=x),this.upstream.send(Er("session/update",{...r,sessionId:o,_meta:l})).catch(p=>$.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}$.warn("unhandled agent request,returning method_not_found",{agentId:e.agentId,method:i.method}),r.respondAgentRequestError(i.id,{code:te.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??{},l=await Ef(c,o);r.respondAgentRequest(i.id,l)}else{let c=i.params??{},l=await vf(c,o);r.respondAgentRequest(i.id,l)}}catch(o){$.warn("fs rpc handler failed",{agentId:e.agentId,method:i.method,err:String(o)}),r.respondAgentRequestError(i.id,Ri(o))}}clearPendingPermissionFor(e){if(e.method!=="session/request_permission"||!e.cloudSessionId)return;let r=this.agents.get(e.agentId)?.sessions.get(e.cloudSessionId);r&&(r.pendingPermission=void 0)}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 m=u?e.activeGroupIds.get(u):void 0;m&&(p.cozeGroupId=m);let b=u?this.reverseSessionId(e,u):void 0,I=b?e.sessions.get(b):void 0;I&&(I.pendingPermission={downstream:r,agentRequestId:i.id,upstreamId:o});let y={...c,...b?{sessionId:b}:{},_meta:p};this.pendingUpstream.set(o,{agentRequestId:i.id,agentId:e.agentId,downstream:r,method:i.method,cloudSessionId:b}),$.info("forward permission_request \u2192 upstream",{agentId:e.agentId,upstreamId:o,acpSessionId:u,cloudSessionId:b,toolCallId:c.toolCall?.toolCallId,options:c.options?.map(E=>({optionId:E.optionId,kind:E.kind,name:E.name}))}),this.upstream.send(Ti(o,"session/request_permission",y)).catch(E=>{this.pendingUpstream.delete(o),$.error("forward permission request failed",{agentId:e.agentId,err:String(E)}),r.respondAgentRequestError(i.id,{code:te.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;this.clearPendingPermissionFor(o),e.error?($.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"&&eb(e.result,o),$.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 to(e.error)):i.value.resolve(e.result);return}$.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),l=e.get(c);if(l)return $.warn(`${i} id type mismatch: number received but Bridge expected string`,{rawId:r,normalizedId:c}),{value:l,key:c}}}sendRequest(e,r,i=Jy){let o=this.upstreamIds.next(e);return new Promise((c,l)=>{let u=setTimeout(()=>{this.pendingBridge.delete(o),l(new C("AGENT_TIMEOUT",`${e} timed out after ${i}ms`))},i);this.pendingBridge.set(o,{method:e,resolve:c,reject:l,timer:u}),this.upstream.send(Ti(o,e,r)).catch(x=>{let p=this.pendingBridge.get(o);p&&(clearTimeout(p.timer),this.pendingBridge.delete(o)),l(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 Vr(e.agentId,r,this.paths)}catch(r){$.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(gn(e,{code:r,message:i,data:{bridgeVersion:br}}))}};function Qy(){return $y(16).toString("hex")}function eb(t,e){if(!t||typeof t!="object"){$.warn("permission response: result not an object (suspicious)",{agentId:e.agentId,result:t});return}let r=t;if("kind"in r&&!("outcome"in r)){$.warn('permission response: top-level "kind" field (D66 historical bug shape)',{agentId:e.agentId,result:t});return}let i=r.outcome;if(!i||typeof i!="object"){$.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")&&$.warn("permission response: unknown outcome discriminant",{agentId:e.agentId,outcomeValue:c,result:t})}function tb(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 `")}ne();De();import{randomBytes as nb}from"node:crypto";import{chmod as rb,mkdir as ib,writeFile as Rf}from"node:fs/promises";import{createServer as sb}from"node:http";import{dirname as ob}from"node:path";var ab=1e6,Yc=H("ipc"),go=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??Q()}async start(){this.token=nb(32).toString("hex");let e=sb((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(),Yc.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 ib(ob(this.paths.portFile),{recursive:!0}),await Rf(this.paths.portFile,String(this.port),"utf8"),await Rf(this.paths.tokenFile,this.token,{encoding:"utf8",mode:384});try{await rb(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}`){Oi(r,401,{error:"unauthorized"});return}let o=`${e.method} ${(e.url??"").split("?")[0]}`,c=this.routes.get(o);if(!c){Oi(r,404,{error:"not found"});return}let l=null;if(e.method==="POST")try{l=await cb(e)}catch(u){Oi(r,400,{error:"invalid json",detail:String(u)});return}try{let u=await c.handler(l,e);Oi(r,200,u??{ok:!0})}catch(u){Yc.error("IPC handler failed",{key:o,err:String(u)}),Oi(r,500,{error:u instanceof Error?u.message:String(u)})}}};function Oi(t,e,r){t.statusCode=e,t.setHeader("content-type","application/json"),t.end(JSON.stringify(r))}async function cb(t){let e=[],r=0;for await(let o of t){let c=o;if(r+=c.length,r>ab)throw new Error("body too large");e.push(c)}let i=Buffer.concat(e).toString("utf8");return i?JSON.parse(i):null}var Xx=Et(Uf(),1);var qE=Et(Mx(),1),GE=Et(Po(),1),jE=Et(Cr(),1),WE=Et(dd(),1),KE=Et(fd(),1),$E=Et(wd(),1),Wx=Et(Mo(),1),JE=Et(jx(),1);var Kx=Wx.default;Ke();ne();var Ce=H("upstream.frontier"),Jx="application/json",Vx="none",YE=15e3;function ZE(t){class e extends Kx{constructor(i){super(i,gu,{headers:t})}guardTeardown(){this.listenerCount("error")===0&&this.on("error",i=>Ce.warn("frontier ws error during teardown (handled, prevents daemon crash)",{err:i instanceof Error?i.message:String(i)}))}close(i,o){this.guardTeardown(),super.close(i,o)}terminate(){this.guardTeardown(),super.terminate()}send(i,...o){if(nl("debug"))try{let c;typeof i=="string"?c=Buffer.from(i,"utf8"):i instanceof Buffer?c=i:i instanceof ArrayBuffer?c=new Uint8Array(i):ArrayBuffer.isView(i)?c=new Uint8Array(i.buffer,i.byteOffset,i.byteLength):c=new Uint8Array(0);let l=Buffer.from(c.slice(0,128)).toString("hex");Ce.debug("WS raw frame out",{bytes:c.byteLength,headHex:l})}catch(c){Ce.warn("WS raw frame dump failed",{err:String(c)})}super.send(i,...o)}}return e}var Gi=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){Ce.warn("start called on already-started FrontierUpstream; noop");return}let e={Authorization:`Bearer ${this.opts.privatecode}`,Origin:mu,..._r(this.opts.ppeOverride)},r=ZE(e),i=_u(this.opts.urlOverride),o={url:i,ws:r,fpID:pu,aID:Xs,accessKey:this.opts.handshake.accessKey,deviceID:this.opts.handshake.deviceId,payloadType:{type:Jx,force:!0},payloadEncoding:{encoding:Vx,force:!0},enableTransformTextPayload:!0,enableQoS:!1,enableAutoAck:!1,automaticOpen:!1,maxRetries:Number.POSITIVE_INFINITY,debug:this.opts.debug??!1},c=new Xx.FWS(o),l=!1,u=null,x,p,m=new Promise((y,E)=>{x=y,p=E}),b=y=>{l||(l=!0,u&&(clearTimeout(u),u=null),y?p(y):x())};c.onopen=()=>{this.opened=!0,this.openCount+=1;let y=this.openCount===1;Ce.info("frontier opened",{url:i,remoteDeviceId:this.opts.handshake.deviceId,initial:y,openCount:this.openCount}),y&&b();for(let E of this.connectHandlers)Promise.resolve(E({initial:y})).catch(S=>Ce.warn("onConnect handler threw (ignored)",{err:String(S)}))},c.onclose=y=>{this.opened=!1,Ce.info("frontier closed",{code:y.code,reason:y.reason,willReconnect:y.willReconnect})},c.onerror=y=>{Ce.warn("frontier error",{code:y.code,msg:y.message}),b(new C("UPSTREAM_DISCONNECTED",`frontier connect error before open: code=${y.code} msg=${y.message??""}`))},c.onmessage=y=>this.handleMessage(y),this.fws=c;let I=this.opts.openTimeoutMs??YE;u=setTimeout(()=>{b(new C("UPSTREAM_DISCONNECTED",`frontier ws open timeout after ${I}ms (handshake or upgrade slow)`))},I),await c.connect();try{await m}catch(y){try{c.close(1e3,"open failed")}catch(E){Ce.warn("fws close during start failure threw (ignored)",{err:String(E)})}throw this.fws=null,this.opened=!1,y}}async stop(e){let r=this.fws;if(r){this.fws=null,this.opened=!1;try{r.close(1e3,e??"bridge shutdown")}catch(i){Ce.warn("frontier close threw (ignored)",{err:String(i)})}}}async send(e){let r=this.fws,i=e.method;if(!r)throw Ce.warn("frontier send refused: upstream not started",{method:i}),new C("UPSTREAM_DISCONNECTED","frontier upstream not started");if(!this.isConnected()){let u=Date.now();throw u-this.lastSendRefusedLogAt>1e3?(Ce.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 C("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;Yx(c)||Ce.info("frontier frame out",{method:c.method,jsonrpcId:c.id,size:o.length});try{await r.send(o,{service:33555712,method:1,payloadType:Jx,payloadEncoding:Vx})}catch(u){throw Ce.warn("frontier frame send failed",{method:c.method,jsonrpcId:c.id,err:String(u)}),new C("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){Ce.debug("drop non-adapter frontier frame",{service:r});return}let i=ev(e);if(!i){Ce.debug("frontier message without text payload, drop",{payloadType:e.message?.payloadType});return}if(!this.handler){Ce.debug("frame received but no onFrame handler",{size:i.length});return}let o;try{o=JSON.parse(i)}catch(l){Ce.warn("frontier message JSON parse failed",{err:String(l),head:i.slice(0,80)});return}let c=o;Yx(c)||Ce.info("frontier frame in",{logid:QE(e.message?.LogID),logidNew:e.message?.LogIDNew,msgId:e.message?.msgID,jsonrpcId:c.id,method:c.method,body:XE(i)}),Promise.resolve(this.handler(o)).catch(l=>Ce.warn("frontier frame handler threw",{err:String(l)}))}};function Yx(t){return t.method==="_agent/health"?!0:typeof t.id=="string"&&t.id.startsWith("agent.health_")}var Zx=2e3;function XE(t){return t.length<=Zx?t:`${t.slice(0,Zx)}...<truncated, total ${t.length} chars>`}function QE(t){return t?t.high===0?String(t.low>>>0):`${t.high.toString(16)}${(t.low>>>0).toString(16).padStart(8,"0")}`:""}function ev(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}}ne();var yd=H("upstream.switchable"),zo=class{inner;handler=null;connectHandlers=[];constructor(e){this.inner=e}async swap(e,r){if(this.inner===e)return;yd.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 yd.error("swap target start failed, reverting",{err:String(o)}),this.inner=i,o}await i.stop(r??"swapped").catch(o=>yd.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()}};ne();var bd=H("upstream"),Or=class{handler=null;async start(){bd.info("NoopUpstream started (M1 skeleton; real Frontier wired in M4)")}async stop(e){bd.info("NoopUpstream stopped",{reason:e})}async send(e){bd.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)}};Ke();ne();ne();De();import{promises as Ed}from"node:fs";import{dirname as tv}from"node:path";var nv=H("pat-token-store");async function Fo(t=Q()){try{let r=(await Ed.readFile(t.patTokenFile,"utf8")).trim();return r.length>0?r:null}catch(e){let r=e?.code;return r!=="ENOENT"&&nv.warn("read pat-token failed (treating as missing)",{path:t.patTokenFile,code:r,message:e.message}),null}}async function ji(t,e=Q()){if(!t)throw new Error("writePatToken: empty patToken");await Ed.mkdir(tv(e.patTokenFile),{recursive:!0}),await Ed.writeFile(e.patTokenFile,t,{encoding:"utf8",mode:384})}De();De();import{promises as Uo}from"node:fs";import{join as rv}from"node:path";function iv(t,e){return`#!/bin/sh
|
|
98
|
+
`)||t.includes("\r")||t.includes("$")||t.includes("#"))return!0;let e=t[0];return e==="'"||e==='"'}var ly={path:"",version:"cloud-deployed"},fy={protocolVersion:1,clientCapabilities:{fs:{readTextFile:!0,writeTextFile:!0}}},uy=6e4,po=class{paths;config;registry;factory;createTimeoutMs;openclawConfigCache;ensuredProviders=new Set;detectorFactory;openclawEnvBootstrapPromise;openclawConfigFactory;openclawConfigDir;constructor(e){this.paths=e.paths,this.config=e.config,this.registry=e.registry,this.factory=e.downstreamFactory??ay,this.createTimeoutMs=e.createTimeoutMs??uy,this.detectorFactory=e.detectorFactory??(()=>new jn),this.openclawConfigFactory=e.openclawConfigFactory??(n=>new xo({command:n})),this.openclawConfigDir=e.openclawConfigDir??ou(oy(),".openclaw")}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 C("AGENT_SPAWN_FAILED","openclaw binary not detected on this machine");this.openclawConfigCache=this.openclawConfigFactory(e.path)}return this.openclawConfigCache}bootstrapOpenclawEnvIfNeeded(){return this.openclawEnvBootstrapPromise?this.openclawEnvBootstrapPromise:(this.openclawEnvBootstrapPromise=this.doBootstrapOpenclawEnv().catch(e=>{be.warn("openclaw env bootstrap failed (ignored)",{err:String(e)}),this.openclawEnvBootstrapPromise=void 0}),this.openclawEnvBootstrapPromise)}async doBootstrapOpenclawEnv(){let e=this.openclawConfigDir,n=ou(e,".env");if(await iy(n).then(c=>c.isFile()).catch(()=>!1)){be.debug("openclaw .env exists, skip bootstrap",{envFile:n});return}await ho(e,{recursive:!0});let o=cy({...process.env,...Jc(this.paths.agentEnvFile)});if(await sy(n,o,"utf8"),process.platform!=="win32")try{await ny(n,384)}catch(c){be.warn("chmod ~/.openclaw/.env to 0600 failed (ignored)",{err:String(c)})}be.info("openclaw .env bootstrapped",{envFile:n,bytes:o.length}),await this.getOpenclawConfig().restartGateway(),be.info("openclaw gateway restarted after env bootstrap")}async createAgent(e){if(!e.agentId)throw new C("IPC_BAD_REQUEST","agentId required");if(!e.framework)throw new C("IPC_BAD_REQUEST","framework required");let n=Ci(e._meta)==="cloud";this.registry.reviveIfDisconnected?.(e.agentId);let i=this.registry.get(e.agentId);if(i){if(i.framework!==e.framework)throw new C("AGENT_BUSY",`agent ${e.agentId} exists with different framework (${i.framework})`);if(i.status==="error")be.warn("existing agent in error state, rebuilding",{agentId:e.agentId}),await i.dispose("rebuild after error").catch(b=>be.warn("dispose stale agent failed (ignored)",{err:String(b)})),this.registry.unregister(e.agentId);else{if(e.patToken&&e.patToken!==i.patToken){be.info("updating agent patToken on re-create (reconnect with new PAT)",{agentId:e.agentId}),i.setPatToken(e.patToken);let b=await Ke(e.agentId,this.paths).catch(()=>null);b&&(b.patToken=e.patToken,await et(b,this.paths))}if(i.deployType==="cloud"&&e.modelInfo){be.info("updating agent modelInfo on re-create",{agentId:e.agentId}),i.setModelInfo(e.modelInfo);let b=await Ke(e.agentId,this.paths).catch(()=>null);b&&(b.modelInfo=e.modelInfo,await et(b,this.paths))}return be.info("agent already exists, return current",{agentId:e.agentId}),{ok:!0,agentId:i.agentId,workspace:i.workspace,framework:i.framework}}}if(!n&&!this.config.frameworksCache?.[e.framework])throw new C("AGENT_SPAWN_FAILED",`framework ${e.framework} not detected on this machine; rerun daemon to refresh frameworks_cache`);let c=Qe(e.agentId,this.paths),l=Ci(e._meta),f=e.framework==="openclaw"&&l==="local",x=f?this.config.frameworksCache?.openclaw?.defaultAgent?.workspace:void 0,p=e.workspace??x??c.workspace,w=new AbortController,v=setTimeout(()=>w.abort(new C("AGENT_TIMEOUT",`_agent/create timed out after ${this.createTimeoutMs}ms`)),this.createTimeoutMs),T,y=!1;try{n&&Zc(e.framework)&&await rr(e.framework,w.signal);let b=()=>{if(w.signal.aborted)throw w.signal.reason instanceof Error?w.signal.reason:new C("AGENT_TIMEOUT","_agent/create aborted")};await ho(c.root,{recursive:!0}),await ho(p,{recursive:!0}),await ho(c.logs,{recursive:!0}),b(),f||await or(p,e.framework,e.cozeIdentity),e.framework==="claude-code"&&await E0(p),b();let S=await Ke(e.agentId,this.paths).catch(()=>null),A=If({model:e.model??S?.model}),R=mf(e._meta)??S?.accountId,P=e.patToken??S?.patToken,_=l==="cloud"?e.modelInfo??S?.modelInfo:void 0;if(T=new fo({agentId:e.agentId,framework:e.framework,workspace:p,model:A.model??St,deployType:l,...R?{accountId:R}:{},...P?{patToken:P}:{},..._?{modelInfo:_}:{}}),T.status="ok",S?.sessions){for(let[z,J]of Object.entries(S.sessions))T.sessions.set(z,{acpSessionId:J.acpSessionId,modelToken:J.modelToken,tokenGeneratedAt:J.tokenGeneratedAt,lastActiveAt:Date.now(),loadingSession:!1,replySeq:0});let B=Object.keys(S.sessions).length;B>0&&be.info("restored persisted session records (no spawn)",{agentId:e.agentId,count:B})}this.registry.register(T),y=!0;let D={agentId:e.agentId,framework:e.framework,workspace:p,cozeIdentity:e.cozeIdentity,createdAt:S?.createdAt??Date.now(),sessions:S?.sessions??{},model:A.model};l==="cloud"&&(D.deployType="cloud"),R&&(D.accountId=R),P&&(D.patToken=P),_&&(D.modelInfo=_),S?.skills&&(D.skills=S.skills),S?.agentName&&(D.agentName=S.agentName),S?.description&&(D.description=S.description),e.framework==="openclaw"&&l==="cloud"&&(this.config.frameworksCache?.openclaw?.path?(await this.bootstrapOpenclawEnvIfNeeded(),await this.getOpenclawConfig().ensureAgent(e.agentId,p)):be.warn("openclaw binary not on this machine, skip agents add (will fail at session/prompt)",{agentId:e.agentId}));let L=e.initialSkills??[];if(L.length>0){let B=[...D.skills??[]],z=new Map(B.map((ee,X)=>[ee.skillId,X])),J=await Promise.allSettled(L.map(ee=>Wc({agentId:e.agentId,workspace:p,framework:e.framework,skill:ee}))),$=0;for(let[ee,X]of J.entries()){let Ae=L[ee];Ae&&(X.status==="fulfilled"?(Kc(B,z,X.value),$++):be.warn("initialSkill install failed (skipping)",{agentId:e.agentId,skillId:Ae.skillId,skillName:Ae.skillName,err:String(X.reason)}))}$>0&&(D.skills=B,be.info("initialSkills installed",{agentId:e.agentId,installed:$,requested:L.length}))}return await et(D,this.paths),be.info("agent created (no spawn, lazy on first prompt)",{agentId:e.agentId,framework:e.framework,deployType:l}),{ok:!0,agentId:e.agentId,workspace:p,framework:e.framework}}catch(b){throw be.error("agent create failed, rolling back",{agentId:e.agentId,err:String(b)}),y&&T&&(await T.dispose("rollback").catch(()=>{}),this.registry.unregister(e.agentId)),await ry(c.root,{recursive:!0,force:!0}).catch(S=>be.warn("rm agent dir failed (ignored)",{err:String(S)})),b instanceof C?b:new C("AGENT_SPAWN_FAILED",String(b),{cause:b})}finally{clearTimeout(v)}}async spawnSessionDownstream(e,n,i,o,c){let f=this.config.frameworksCache?.[e.framework];if(!f)if(e.deployType==="cloud"&&Zc(e.framework))f=ly;else throw new C("AGENT_SPAWN_FAILED",`framework ${e.framework} not detected on this machine`);Zc(e.framework)&&!os(e.framework)&&(be.info("spawn: resolving acp wrapper",{agentId:e.agentId,framework:e.framework}),await rr(e.framework));let x=e.deployType==="cloud"?{model:e.model,modelToken:n,...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:f.path}):p=this.factory(e.framework,f.path,e.workspace,e.agentId,x,i,o,c,this.buildBinShimPathEnv());try{return await p.start(),await p.initialize(fy),p}catch(w){let v=p instanceof Nt?p.getStderrTail():[];throw v.length>0&&be.warn("spawnSessionDownstream failed, recent stderr (D94)",{agentId:e.agentId,framework:e.framework,method:w instanceof C?w.code:"unknown",recentStderr:v}),await p.stop("spawnSessionDownstream failed").catch(()=>{}),w instanceof C?new C(w.code,w.message,{retriable:w.retriable,cause:w.cause??w}):new C("AGENT_SPAWN_FAILED",w instanceof Error?w.message:String(w),{cause:w})}}async buildOpenclawDownstream(e){let{session:n,modelConfig:i,cloudSessionId:o,cozeEnv:c,mockScenario:l,command:f}=e,x=Vc(o);if(n.deployType==="local"){let T=this.config.frameworksCache?.openclaw?.defaultAgent;if(!T?.id||!T.workspace){be.warn("openclaw default agent stale or missing, attempting lazy re-detect");let b=await this.detectorFactory().detect("openclaw");if(b?.defaultAgent?.id&&b?.defaultAgent?.workspace)be.info("openclaw lazy re-detect success",{agentId:b.defaultAgent.id,workspace:b.defaultAgent.workspace}),this.config.frameworksCache||(this.config.frameworksCache={}),this.config.frameworksCache.openclaw=b,T=b.defaultAgent;else throw new C("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 Rr({command:f,cwd:T.workspace,agentId:T.id,sessionName:x})}let p=await su(),w=i?kf(i,c,l):null,v;if(w){let T=zc(o),b=w.models[0]?.id??St,S=`${T}/${b}`;if(!this.ensuredProviders.has(S)){let A=this.getOpenclawConfig();await A.ensureProvider(T,w),await A.addModelToAllowlist(S),this.ensuredProviders.add(S)}v=S}return new Rr({command:f,cwd:n.workspace,agentId:n.agentId,sessionName:x,...p?{gatewayToken:p}:{},...v?{slashModelOnStart:v}:{}})}async openclawRepair(e,n){let i=this.getOpenclawConfig();await i.deleteAgent(e),await i.ensureAgent(e,n)}async cleanupOpenclawSessionProviders(e){if(e.framework!=="openclaw"||!this.openclawConfigCache)return;let n=this.openclawConfigCache;for(let i of e.sessions.keys()){let o=zc(i),c=`${o}/${e.model}`,l=!0;try{await n.removeProvider(o)}catch(f){l=!1,be.warn("removeProvider failed, keeping ensuredProviders entry",{providerId:o,err:String(f)})}try{await n.removeModelFromAllowlist(c)}catch(f){l=!1,be.warn("removeModelFromAllowlist failed, keeping ensuredProviders entry",{fullModelId:c,err:String(f)})}l&&this.ensuredProviders.delete(c)}}};import{randomUUID as fu}from"node:crypto";import{promises as yy}from"node:fs";import{basename as uu}from"node:path";Ve();re();import{promises as hy}from"node:fs";import{basename as py}from"node:path";var au=H("file-upload"),gy="/api/coze_claw/file/agent_upload",my=6e4;async function cu(t,e={}){let i=`${to(ro(e.handshakeBase))}${gy}`,o=e.timeoutMs??my,c=await hy.readFile(t.path),l=new FormData;l.append("agent_id",t.agentId),l.append("session_id",t.sessionId),l.append("file_name",t.name),l.append("file_content",new Blob([c],{type:t.mimeType}),t.name);let f={Authorization:`Bearer ${t.patToken}`,Accept:"application/json","x-coze-version":"3.0",...Sr(e.ppeOverride),...t.accountId?{"x-coze-account":t.accountId}:{}},x=new AbortController,p=setTimeout(()=>x.abort(),o);au.info("file upload start",{url:i,agentId:t.agentId,sessionId:t.sessionId,name:t.name,bytes:t.sizeBytes,mime:t.mimeType});try{let w=await fetch(i,{method:"POST",headers:f,body:l,signal:x.signal}),v=w.headers.get("x-tt-logid")??"";if(!w.ok){let b=await w.text().catch(()=>"");throw new C("UPLOAD_FAILED",`upload HTTP ${w.status} logid=${v}: ${b.slice(0,200)}`)}let T=await w.json();if(T.code!==void 0&&T.code!==0)throw new C("UPLOAD_FAILED",`upload code=${T.code} msg=${T.msg??"-"} logid=${v}`);let y=T.data?.file?.file_url;if(!y)throw new C("UPLOAD_FAILED",`upload response missing data.file.file_url logid=${v}: ${JSON.stringify(T).slice(0,200)}`);return au.info("file upload ok",{uri:y,logid:v}),{uri:y}}catch(w){throw w instanceof C?w:w.name==="AbortError"?new C("UPLOAD_FAILED",`upload timeout (${o}ms) for ${py(t.path)}`):new C("UPLOAD_FAILED",String(w),{cause:w})}finally{clearTimeout(p)}}Ve();re();import{extname as wy}from"node:path";var _y={".png":"image/png",".jpg":"image/jpeg",".jpeg":"image/jpeg",".gif":"image/gif",".webp":"image/webp",".svg":"image/svg+xml",".bmp":"image/bmp",".ico":"image/x-icon",".heic":"image/heic",".heif":"image/heif",".pdf":"application/pdf",".doc":"application/msword",".docx":"application/vnd.openxmlformats-officedocument.wordprocessingml.document",".xls":"application/vnd.ms-excel",".xlsx":"application/vnd.openxmlformats-officedocument.spreadsheetml.sheet",".ppt":"application/vnd.ms-powerpoint",".pptx":"application/vnd.openxmlformats-officedocument.presentationml.presentation",".txt":"text/plain",".md":"text/markdown",".markdown":"text/markdown",".json":"application/json",".yaml":"text/yaml",".yml":"text/yaml",".csv":"text/csv",".html":"text/html",".htm":"text/html",".xml":"application/xml",".log":"text/plain",".zip":"application/zip",".tar":"application/x-tar",".gz":"application/gzip",".tgz":"application/gzip",".mp3":"audio/mpeg",".wav":"audio/wav",".mp4":"video/mp4",".mov":"video/quicktime",".webm":"video/webm"};async function du(t){let e=wy(t).toLowerCase();return _y[e]??"application/octet-stream"}Oe();var go=H("agent-send"),lu=50*1024*1024;function xu(t,e,n){let i=t.get(e);if(!i)throw new C("AGENT_NOT_FOUND",`agent=${e}`);if(t.disconnectedAgents.has(e))throw new C("AGENT_DISCONNECTED",`agent=${e} was disconnected by cloud`);let o=i.sessions.get(n);if(!o)throw new C("AGENT_NOT_FOUND",`session=${n} not active in agent=${e}`);return{session:i,runtime:o}}async function hu(t,e,n,i,o,c){let f;for(let x=0;x<=2;x++)try{await t.core.sendAgentFileUpdate(e,n,i,o);return}catch(p){f=p,x<2&&(go.warn("sendAgentFileUpdate failed, retrying",{attempt:x+1,err:String(p)}),await new Promise(w=>setTimeout(w,5e3)))}throw new C("UPSTREAM_NOT_READY",`${c} after 3 attempts: ${String(f)}`,{cause:f})}async function pu(t,e){let{session:n,runtime:i}=xu(e.core,t.agentId,t.sessionId);if(!await ei(t.path,n.workspace))throw new C("PATH_OUTSIDE_WORKSPACE",`path=${t.path} not under workspace=${n.workspace}`);let o=await yy.stat(t.path).catch(()=>null);if(!o||!o.isFile())throw new C("IPC_BAD_REQUEST",`path is not a regular file: ${t.path}`);if(o.size>lu)throw new C("FILE_TOO_LARGE",`${o.size} bytes > limit ${lu}`);let c=await du(t.path);if(t.kind==="image"&&!c.startsWith("image/"))throw new C("UNSUPPORTED_MIME",`kind=image but mime=${c}`);if(!e.core.upstream.isConnected())throw new C("UPSTREAM_NOT_READY","cloud WS not connected");let l=t.name??uu(t.path),f;try{f=await cu({patToken:n.patToken??e.patToken,agentId:t.agentId,sessionId:t.sessionId,path:t.path,mimeType:c,name:l,sizeBytes:o.size,...n.accountId?{accountId:n.accountId}:{}},{handshakeBase:e.handshakeBase,ppeOverride:e.ppeOverride})}catch(p){throw go.warn("agent file upload failed",{agentId:t.agentId,sessionId:t.sessionId,path:t.path,sizeBytes:o.size,mime:c,code:p instanceof C?p.code:"UNKNOWN",message:p instanceof Error?p.message:String(p)}),p}let x={sessionUpdate:"agent_file",messageId:fu(),content:{type:t.kind==="image"?"image":"resource",uri:f.uri,mimeType:c,name:l,sizeBytes:o.size,...f.fileId!==void 0?{fileId:f.fileId}:{},...t.caption!==void 0?{caption:t.caption}:{}}};return await hu(e,n,i,t.sessionId,x,"agent file uploaded to cloud but sendAgentFileUpdate failed"),go.info("agent file sent",{agentId:t.agentId,sessionId:t.sessionId,kind:t.kind,name:l,bytes:o.size,mime:c,uri:f.uri}),{ok:!0,uri:f.uri,bytes:o.size,mimeType:c,...f.fileId!==void 0?{fileId:f.fileId}:{}}}async function gu(t,e){let{session:n,runtime:i}=xu(e.core,t.agentId,t.sessionId);if(!t.mimeType)throw new C("IPC_BAD_REQUEST","group-file requires mimeType");if(!e.core.upstream.isConnected())throw new C("UPSTREAM_NOT_READY","cloud WS not connected");let o=t.name??uu(t.path),c={sessionUpdate:"group_file",messageId:fu(),content:{uri:t.path,name:o,mimeType:t.mimeType,...t.caption!==void 0?{caption:t.caption}:{}}};return await hu(e,n,i,t.sessionId,c,"agent group file sendAgentFileUpdate failed"),go.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 mu(t,e){let n=t.split(".").map(Number),i=e.split(".").map(Number),o=Math.max(n.length,i.length);for(let c=0;c<o;c++){let l=n[c]??0,f=i[c]??0;if(l<f)return!0;if(l>f)return!1}return!1}sn();bn();re();var Mt=H("coze-cli-installer"),wu="@coze/cli@latest",Ey="coze",_u="0.1.8",by=5e3,vy=5e3,Sy=9e4,yu=1e4,Bi=null,mo=!1;async function Xc(t,e={}){if(mo)return;if(Bi)return Bi;let n=e.exec??Xf;return Bi=(async()=>{try{let i=await Iy(Ey,n),o=!1;if(i){let l=await Ay(n);if(l===void 0)Mt.warn("coze-cli found but version unparseable, fall through to full install",{path:i});else if(mu(l,_u))Mt.info("coze-cli version too old, upgrade-only (preserve user config + auth)",{path:i,version:l,min:_u}),o=!0;else{Mt.info("coze-cli already on PATH with sufficient version, skip",{path:i,version:l}),mo=!0;return}}let c=o?"upgrade-only":"full";Mt.info("coze-cli install start",{package:wu,mode:c});try{await n("npm",["i","-g","--prefer-online",wu],{timeout:Sy,maxBuffer:10*1024*1024}),Mt.info("coze-cli install ok")}catch(l){Mt.warn("coze-cli install failed (skip subsequent steps)",{err:String(l)});return}if(o){mo=!0;return}if(t.env)try{await n("coze",["config","set","xTTEnv",t.env],{timeout:yu}),Mt.info("coze config set xTTEnv ok",{env:t.env})}catch(l){Mt.warn("coze config set failed (continue to auth login)",{err:String(l)})}try{await n("coze",["auth","login","--token",t.patToken],{timeout:yu}),Mt.info("coze auth login ok")}catch(l){Mt.warn("coze auth login failed",{err:String(l)});return}mo=!0}finally{Bi=null}})(),Bi}async function Iy(t,e){let n=process.platform==="win32"?"where":"which";try{let{stdout:i}=await e(n,[t],{timeout:by});return va(i)}catch{return}}async function Ay(t){try{let{stdout:e,stderr:n}=await t("coze",["--version"],{timeout:vy});return(e||n).match(/(\d+\.\d+\.\d+)/)?.[1]}catch{return}}Qr();Oe();var Ty=10*6e4;function Eu(t){let e=t?.sessionIdleTimeoutMs;return typeof e!="number"||!Number.isFinite(e)||e<=0?Ty:e}function wo(t){return ir(t??Q().configFile)}function zi(t,e){return sr(e??Q().configFile,t)}import{randomBytes as $y}from"node:crypto";ts();Ve();re();import{createReadStream as Cy}from"node:fs";import{mkdir as Dy,readFile as Ry,realpath as ky,stat as Ly,writeFile as Py}from"node:fs/promises";import{basename as Oy,dirname as Yc,isAbsolute as Ny,join as My,relative as By,resolve as bu,sep as zy}from"node:path";import{createInterface as Fy}from"node:readline";var Su=H("fs-rpc"),Fi=qt("COZE_BRIDGE_FS_RPC_MAX_BYTES",20*1024*1024);async function Iu(t,e){let n=Buffer.byteLength(t.content,"utf8");if(n>Fi)throw new C("IPC_BAD_REQUEST",`fs/write_text_file content too large: ${n} bytes > limit ${Fi} bytes`);let i=await Tu(t.path,e);return await Dy(Yc(i),{recursive:!0}),await Py(i,t.content,"utf8"),Su.info("fs/write_text_file ok",{path:i,size:t.content.length}),null}async function Au(t,e){let n=await Tu(t.path,e),i=await Ly(n),o=typeof t.line=="number"||typeof t.limit=="number";if(i.size>Fi&&!o)throw new C("IPC_BAD_REQUEST",`fs/read_text_file too large without line/limit slicing: ${i.size} bytes > ${Fi} bytes`);let c;if(o&&i.size>Fi)c=await Uy(n,t.line??1,t.limit);else{let l=await Ry(n,"utf8");if(o){let f=l.split(`
|
|
99
|
+
`),x=Math.max(0,(t.line??1)-1),p=typeof t.limit=="number"?x+t.limit:void 0;c=f.slice(x,p).join(`
|
|
100
|
+
`)}else c=l}return Su.info("fs/read_text_file ok",{path:n,size:c.length}),{content:c}}async function Uy(t,e,n){let i=Fy({input:Cy(t,{encoding:"utf8"}),crlfDelay:Number.POSITIVE_INFINITY}),o=Math.max(0,e-1),c=typeof n=="number"?o+n:Number.POSITIVE_INFINITY,l=[],f=0;try{for await(let x of i)if(f>=o&&f<c&&l.push(x),f++,f>=c)break}finally{i.close()}return l.join(`
|
|
101
|
+
`)}async function Tu(t,e){if(typeof t!="string"||t.length===0)throw new C("IPC_BAD_REQUEST","path must be a non-empty string");let[n,i]=await Promise.all([vu(bu(e)),vu(bu(t))]),o=By(n,i);if(qy(o,zy,Ny(o)))throw new C("IPC_BAD_REQUEST",`path escapes workspace: ${t}`);return i}function qy(t,e,n){return t===""?!1:n?!0:t===".."||t.startsWith(`..${e}`)}async function vu(t){let e=[],n=t;for(;n!==Yc(n);)try{let i=await ky(n);return e.length?My(i,...e.reverse()):i}catch{e.push(Oy(n)),n=Yc(n)}return t}re();var Cu=H("prompt-multimodal"),Du=10*1024*1024,Hy=15e3,Gy=6;async function Ru(t){let e=new Array(t.length),n=0;async function i(){for(;n<t.length;){let c=n++,l=t[c];l!==void 0&&(e[c]=await jy(l))}}let o=Array.from({length:Math.min(Gy,t.length)},()=>i());return await Promise.all(o),e}function ku(t){return t.some(e=>e.type==="image")}async function jy(t){if(t.type!=="image")return t;let e=t;if(e.data||!e.uri||!eo(e.uri))return t;try{let{buf:n,contentType:i}=await Ky(e.uri),o=e.mimeType||Wy(i)||"application/octet-stream";return Cu.info("image uri fetched and inlined",{uri:e.uri,bytes:n.length,mimeType:o}),{type:"image",data:n.toString("base64"),mimeType:o}}catch(n){return Cu.warn("image fetch failed, degrading to text block",{uri:e.uri,err:String(n)}),{type:"text",text:`[image load failed: ${e.uri}]`}}}function Wy(t){if(!t)return;let e=t.indexOf(";");return(e===-1?t:t.slice(0,e)).trim()||void 0}async function Ky(t){let e=new AbortController,n=setTimeout(()=>e.abort(),Hy);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>Du)throw new Error(`image too large: ${o.byteLength} bytes (max ${Du})`);return{buf:Buffer.from(o),contentType:i.headers.get("content-type")??void 0}}finally{clearTimeout(n)}}on();Ve();re();var K=H("core"),Jy=3e4,Vy=/^(boe|ppe)_[A-Za-z0-9_-]+$/,Zy="\u6211\u6B63\u5728\u7B49\u5F85\u5BA1\u6279\uFF0C\u8BF7\u7A0D\u540E\u518D\u8054\u7CFB\u6211",Xy="\u5BA1\u6279\u5DF2\u8D85\u65F6",Yy=3e4,_o=class{upstream;agents=new Map;disconnectedAgents=new Set;extensions;paths;sessionSpawner;sessionIdleTimeoutMs;upstreamIds=new Dr;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=Eu(e.bridgeConfig)}registerExtension(e,n){this.extensions[e]=n}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(),K.info("Core started",{extensions:Object.keys(this.extensions)})}async stop(e){K.info("Core stopping",{reason:e}),await Promise.all([...this.agents.values()].map(n=>n.dispose(e))),this.agents.clear(),await this.upstream.stop(e)}async reloadAgents(e){let n=e?this.agents.has(e)?[e]:[]:[...this.agents.keys()];for(let i of n)await this.agents.get(i)?.killAllRuntimes("reload");return n}get(e){return this.agents.get(e)}register(e){this.agents.set(e.agentId,e),K.info("agent registered",{agentId:e.agentId,framework:e.framework});for(let n of this.registerHandlers)try{n(e.agentId)}catch(i){K.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)&&K.info("agent revived from disconnect",{agentId:e})}attachRuntimeHooks(e,n,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,l)=>{K.info("session runtime exited",{agentId:e.agentId,cloudId:n,code:c,signal:l}),Mi(i),i.downstream=void 0,i.replySeq=0,i.acpSessionId&&e.activeTriggers.delete(i.acpSessionId),this.rejectPendingForDownstream(o,"downstream exited")}))}hasPendingPermissionFor(e){for(let n of this.pendingUpstream.values())if(n.downstream===e)return!0;return!1}rejectPendingForDownstream(e,n){let i=[];for(let[o,c]of this.pendingUpstream)c.downstream===e&&i.push(o);if(i.length!==0){K.info("reject pendingUpstream entries (downstream gone)",{reason:n,count:i.length});for(let o of i){let c=this.pendingUpstream.get(o);if(c){this.pendingUpstream.delete(o),this.upstream.send(En(o,{code:ne.INTERNAL_ERROR,message:`bridge downstream gone: ${n}`})).catch(l=>K.debug("send error response to upstream failed (ignored)",{err:String(l)}));try{c.downstream.respondAgentRequestError(c.agentRequestId,{code:ne.INTERNAL_ERROR,message:`bridge: ${n}`})}catch{}}}}}rejectAllPendingOnReconnect(){let e=this.pendingUpstream.size,n=this.pendingBridge.size;if(!(e===0&&n===0)){K.warn("upstream reconnected, rejecting stale pending requests",{pendingUpstream:e,pendingBridge:n});for(let[,i]of this.pendingUpstream){try{i.downstream.respondAgentRequestError(i.agentRequestId,{code:ne.INTERNAL_ERROR,message:"upstream reconnected; please retry"})}catch{}this.clearPendingPermissionFor(i)}this.pendingUpstream.clear();for(let[,i]of this.pendingBridge)clearTimeout(i.timer),i.reject(new C("UPSTREAM_DISCONNECTED",`${i.method} aborted: upstream reconnected`));this.pendingBridge.clear()}}async handleFrame(e){if(oo(e)){this.handleUpstreamResponse(e);return}if(!("method"in e)||typeof e.method!="string")return;let n="id"in e&&e.id!==void 0?e.id:null,i=e.params?._meta?.cozeEnv;i&&Vy.test(i)?this.currentCozeEnv=i:i&&K.warn("rejecting cozeEnv with invalid shape, keeping previous",{rejected:i});try{if(e.method.startsWith("_agent/")){let o=this.extensions[e.method];if(!o){n!==null?await this.sendError(n,ne.METHOD_NOT_FOUND,`extension not registered: ${e.method}`):K.warn("drop notification: extension not registered",{method:e.method});return}let c=await o(e,this);n!==null&&await this.upstream.send(Cr(n,c));return}if(e.method.startsWith("session/")){let o=await this.routeSessionMethod(e);n!==null&&await this.upstream.send(Cr(n,o));return}if(e.method==="initialize"){n!==null&&await this.upstream.send(Cr(n,{protocolVersion:1,agentCapabilities:{loadSession:!0}}));return}n!==null?await this.sendError(n,ne.METHOD_NOT_FOUND,`method not implemented: ${e.method}`):K.warn("drop unknown notification",{method:e.method})}catch(o){K.error("handleFrame failed",{method:e.method,err:String(o)}),n!==null&&await this.upstream.send(En(n,Ni(o)))}}async routeSessionMethod(e){if(!e.params||typeof e.params!="object")throw new C("IPC_BAD_REQUEST",`${e.method} requires params`);let n=e.params,i=n._meta?.cozeAgentId;if(!i)throw new C("IPC_BAD_REQUEST",`${e.method}: missing _meta.cozeAgentId`);let o=this.agents.get(i);if(!o)throw this.disconnectedAgents.has(i)?new C("AGENT_DISCONNECTED",`agent ${i} has been disconnected; cloud must _agent/create to revive`):new C("AGENT_NOT_FOUND",`agent not found: ${i}`);let c=typeof n.sessionId=="string"?n.sessionId:void 0;if(e.method==="session/cancel"||e.method==="session/new"||!c)return this.dispatchSessionCall(o,e.method,n);if(e.method==="session/prompt"){let x=o.sessions.get(c);if(x?.pendingPermission){let p=n._meta?.cozeTriggerMsgId,w=Pc(n._meta);return K.info("session in pendingPermission, bouncing new prompt",{agentId:o.agentId,cloudSessionId:c}),this.synthesizePromptReply(o,x,c,Zy,p,w)}}let l=Date.now(),f=!1;try{let x=await o.getSessionQueue(c).enqueue(()=>this.dispatchSessionCall(o,e.method,n));return f=!0,x}finally{K.info("session call done",{agentId:o.agentId,method:e.method,durationMs:Date.now()-l,ok:f})}}async dispatchSessionCall(e,n,i){e.lastActiveAt=Date.now();let{stripped:o}=wf(i);switch(n){case"session/new":{let c=Qy();return K.info("session/new ack (lazy spawn)",{agentId:e.agentId,cloudId:c}),{sessionId:c}}case"session/load":{let c=o;return K.info("session/load ack (lazy spawn)",{agentId:e.agentId,cloudId:c.sessionId}),{}}case"session/prompt":{let c=o,l=c.sessionId;if(!l)throw new C("IPC_BAD_REQUEST","session/prompt: missing sessionId");let f=await this.ensureRuntime(e,l);if(f.replySeq=0,await this.ensureDownstream(e,l,f),!f.downstream||!f.acpSessionId)throw new C("BRIDGE_INTERNAL","session runtime not ready after ensureDownstream");let x=i._meta?.cozeTriggerMsgId;x?e.activeTriggers.set(f.acpSessionId,x):e.activeTriggers.delete(f.acpSessionId);let p=Pc(i._meta);if(p?e.activeGroupIds.set(f.acpSessionId,p):e.activeGroupIds.delete(f.acpSessionId),e.deployType==="cloud"&&e.modelInfo?.capabilities?.image===!1&&ku(c.prompt))throw new C("MODEL_MODALITY_UNSUPPORTED",`model=${e.modelInfo.id??e.model} does not support image input`);let w=await Ru(c.prompt);try{let v=await f.downstream.sessionPrompt({...c,sessionId:f.acpSessionId,prompt:w});return f.lastActiveAt=Date.now(),v}catch(v){if(v instanceof C&&v.code==="AGENT_APPROVAL_TIMEOUT"){let T=f.pendingPermission;T&&(T.downstream.respondAgentRequest(T.agentRequestId,{outcome:{outcome:"cancelled"}}),this.pendingUpstream.delete(T.upstreamId),f.pendingPermission=void 0);let y=f.acpSessionId,b=y?e.activeTriggers.get(y):void 0,S=y?e.activeGroupIds.get(y):void 0;return K.warn("approval timed out, synthesizing \u5BA1\u6279\u5DF2\u8D85\u65F6 reply + recovering session",{agentId:e.agentId,cloudId:l}),await this.synthesizePromptReply(e,f,l,Xy,b,S)}throw v}finally{if(e.activeTriggers.delete(f.acpSessionId),e.activeGroupIds.delete(f.acpSessionId),f.pendingPermission=void 0,f.reloadAfterTurn){f.reloadAfterTurn=!1;let v=f.downstream;v&&(f.downstream=void 0,K.info("reloadAfterTurn: stopping downstream",{agentId:e.agentId,cloudId:l,acpId:f.acpSessionId}),v.stop("reload-after-turn").catch(T=>K.warn("reload-after-turn stop failed (ignored)",{agentId:e.agentId,cloudId:l,err:String(T)})))}else f.downstream?.isAlive()&&this.armIdleTimer(e,l,f)}}case"session/cancel":{let l=o.sessionId;if(!l)throw new C("IPC_BAD_REQUEST","session/cancel: missing sessionId");let f=e.sessions.get(l);if(e.hasSessionQueue(l)){let x=e.getSessionQueue(l);x.size>0&&(K.info("session/cancel: draining queued tasks",{agentId:e.agentId,cloudId:l,queuedCount:x.size}),x.dispose(new C("AGENT_PROTOCOL_ERROR",`cancelled by session/cancel on ${l}`)))}return f?.downstream?.isAlive()&&f.acpSessionId&&await f.downstream.sessionCancel({sessionId:f.acpSessionId}),{ok:!0}}default:throw new C("IPC_BAD_REQUEST",`session method not supported: ${n}`)}}async ensureRuntime(e,n){let i=e.sessions.get(n);if(i)return i;let c={modelToken:e.deployType==="cloud"?await this.requestSessionToken(e.agentId,n):"",tokenGeneratedAt:Date.now(),lastActiveAt:Date.now(),loadingSession:!1,replySeq:0};return e.sessions.set(n,c),await this.persistSessionMapping(e),c}async requestSessionToken(e,n){let i={sessionId:n,_meta:{cozeAgentId:e}};try{let o=await this.sendRequest(vt.GEN_MODEL_TOKEN,i,Yy);if(!o?.modelToken)throw new C("MODEL_TOKEN_GEN_FAILED",`cloud returned empty modelToken (agentId=${e}, cloudSessionId=${n})`);return o.modelToken}catch(o){throw o instanceof C&&o.code==="MODEL_TOKEN_GEN_FAILED"?o:new C("MODEL_TOKEN_GEN_FAILED",o instanceof Error?o.message:String(o),{cause:o})}}async ensureDownstream(e,n,i){if(Mi(i),i.downstream?.isAlive())return;if(!this.sessionSpawner)throw new C("AGENT_SPAWN_FAILED","sessionSpawner not wired (cannot spawn per-session downstream)");let o=3,c=3e4,l=i.spawnFailCount??0,f=i.spawnFailedAt??0;if(l>=o&&Date.now()-f<c)throw new C("AGENT_SPAWN_FAILED",`agent ${e.agentId} session ${n} spawn failed ${l} times in a row; please check framework binary / network and retry after ${Math.ceil((c-(Date.now()-f))/1e3)}s`);let x;try{x=await this.sessionSpawner(e,i.modelToken,n,this.currentCozeEnv,this.currentMockScenario)}catch(p){throw i.spawnFailCount=l+1,i.spawnFailedAt=Date.now(),i.spawnFailCount>=o&&i.acpSessionId&&(K.warn("clearing stale acpSessionId after repeated spawn failures",{agentId:e.agentId,cloudId:n,staleAcpId:i.acpSessionId}),i.acpSessionId=void 0),p}if(i.spawnFailCount=0,i.spawnFailedAt=void 0,i.downstream=x,this.attachRuntimeHooks(e,n,i),i.acpSessionId){i.loadingSession=!0;try{await x.sessionLoad({sessionId:i.acpSessionId,cwd:e.workspace}),K.info("session restored via session/load",{agentId:e.agentId,cloudId:n,acpId:i.acpSessionId})}catch(p){K.warn("session/load failed, fallback to session/new",{agentId:e.agentId,cloudId:n,acpId:i.acpSessionId,err:String(p)}),i.acpSessionId=void 0;let w=await x.sessionNew({cwd:e.workspace});i.acpSessionId=w.sessionId,await this.persistSessionMapping(e)}finally{i.loadingSession=!1}}else{let p=await x.sessionNew({cwd:e.workspace});i.acpSessionId=p.sessionId,await this.persistSessionMapping(e)}x.afterSessionEstablished&&i.acpSessionId&&await x.afterSessionEstablished(i.acpSessionId)}armIdleTimer(e,n,i){if(Mi(i),this.isRuntimeBusy(e,i)){K.debug("skip idle timer: runtime busy (in-flight turn / pending permission)",{agentId:e.agentId,cloudId:n});return}i.idleTimer=setTimeout(()=>{if(i.idleTimer=void 0,this.isRuntimeBusy(e,i)){K.info("idle reaper fired but runtime busy, re-arming",{agentId:e.agentId,cloudId:n}),this.armIdleTimer(e,n,i);return}K.info("session runtime idle timeout, killing downstream",{agentId:e.agentId,cloudId:n});let o=i.downstream;i.downstream=void 0,i.acpSessionId&&e.activeTriggers.delete(i.acpSessionId),o&&o.stop("idle timeout").catch(c=>K.warn("idle stop failed (ignored)",{agentId:e.agentId,cloudId:n,err:String(c)}))},this.sessionIdleTimeoutMs),i.idleTimer.unref?.()}isRuntimeBusy(e,n){if(n.acpSessionId&&e.activeTriggers.has(n.acpSessionId))return!0;let i=n.downstream;if(!i)return!1;for(let o of this.pendingUpstream.values())if(o.downstream===i)return!0;return!1}async sendAgentFileUpdate(e,n,i,o){let c={cozeAgentId:e.agentId,cozeReplySeqID:++n.replySeq};if(n.acpSessionId){let l=e.activeTriggers.get(n.acpSessionId);l&&(c.cozeTriggerMsgId=l);let f=e.activeGroupIds.get(n.acpSessionId);f&&(c.cozeGroupId=f)}await this.upstream.send(Tr("session/update",{sessionId:i,update:o,_meta:c}))}async synthesizePromptReply(e,n,i,o,c,l){let f={cozeAgentId:e.agentId,cozeReplySeqID:++n.replySeq};return c&&(f.cozeTriggerMsgId=c),l&&(f.cozeGroupId=l),await this.upstream.send(Tr("session/update",{sessionId:i,update:{sessionUpdate:"agent_message_chunk",content:{type:"text",text:o}},_meta:f})).catch(x=>K.warn("synthesizePromptReply update send failed (ignored)",{err:String(x)})),{stopReason:"end_turn"}}forwardUpdate(e,n){let i=n.sessionId,o=this.reverseSessionId(e,i);if(!o){K.debug("drop update for unknown session",{agentId:e.agentId,acpId:i});return}let c=e.sessions.get(o);if(!c){K.debug("drop update: runtime gone",{agentId:e.agentId,cloudId:o});return}if(t1(n)){K.debug("drop codex metadata-warn chunk",{agentId:e.agentId,acpId:i});return}let l={cozeAgentId:e.agentId,cozeReplySeqID:++c.replySeq},f=e.activeTriggers.get(i);f&&(l.cozeTriggerMsgId=f);let x=e.activeGroupIds.get(i);x&&(l.cozeGroupId=x),this.upstream.send(Tr("session/update",{...n,sessionId:o,_meta:l})).catch(p=>K.warn("forward update failed",{agentId:e.agentId,err:String(p)}))}handleAgentRequest(e,n,i){if(i.method==="session/request_permission"){this.forwardPermissionRequest(e,n,i);return}if(i.method==="fs/write_text_file"||i.method==="fs/read_text_file"){this.handleFsRpcRequest(e,n,i);return}K.warn("unhandled agent request,returning method_not_found",{agentId:e.agentId,method:i.method}),n.respondAgentRequestError(i.id,{code:ne.METHOD_NOT_FOUND,message:`method not handled by Bridge: ${i.method}`})}async handleFsRpcRequest(e,n,i){try{let o=e.workspace;if(i.method==="fs/write_text_file"){let c=i.params??{},l=await Iu(c,o);n.respondAgentRequest(i.id,l)}else{let c=i.params??{},l=await Au(c,o);n.respondAgentRequest(i.id,l)}}catch(o){K.warn("fs rpc handler failed",{agentId:e.agentId,method:i.method,err:String(o)}),n.respondAgentRequestError(i.id,Ni(o))}}clearPendingPermissionFor(e){if(e.method!=="session/request_permission"||!e.cloudSessionId)return;let n=this.agents.get(e.agentId)?.sessions.get(e.cloudSessionId);n&&(n.pendingPermission=void 0)}forwardPermissionRequest(e,n,i){let o=this.upstreamIds.next("session/request_permission"),c=i.params??{},f=c.sessionId,x=f?e.activeTriggers.get(f):void 0,p={cozeAgentId:e.agentId};x&&(p.cozeTriggerMsgId=x);let w=f?e.activeGroupIds.get(f):void 0;w&&(p.cozeGroupId=w);let v=f?this.reverseSessionId(e,f):void 0,T=v?e.sessions.get(v):void 0;T&&(T.pendingPermission={downstream:n,agentRequestId:i.id,upstreamId:o});let y={...c,...v?{sessionId:v}:{},_meta:p};this.pendingUpstream.set(o,{agentRequestId:i.id,agentId:e.agentId,downstream:n,method:i.method,cloudSessionId:v}),K.info("forward permission_request \u2192 upstream",{agentId:e.agentId,upstreamId:o,acpSessionId:f,cloudSessionId:v,toolCallId:c.toolCall?.toolCallId,options:c.options?.map(b=>({optionId:b.optionId,kind:b.kind,name:b.name}))}),this.upstream.send(Pi(o,"session/request_permission",y)).catch(b=>{this.pendingUpstream.delete(o),K.error("forward permission request failed",{agentId:e.agentId,err:String(b)}),n.respondAgentRequestError(i.id,{code:ne.INTERNAL_ERROR,message:`upstream send failed: ${String(b)}`})})}handleUpstreamResponse(e){if(e.id===null)return;let n=this.lookupPending(this.pendingUpstream,e.id,"upstream");if(n){this.pendingUpstream.delete(n.key);let o=n.value;this.clearPendingPermissionFor(o),e.error?(K.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"&&e1(e.result,o),K.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 so(e.error)):i.value.resolve(e.result);return}K.debug("orphan upstream response (no pending)",{id:e.id})}lookupPending(e,n,i){let o=e.get(n);if(o)return{value:o,key:n};if(typeof n=="number"){let c=String(n),l=e.get(c);if(l)return K.warn(`${i} id type mismatch: number received but Bridge expected string`,{rawId:n,normalizedId:c}),{value:l,key:c}}}sendRequest(e,n,i=Jy){let o=this.upstreamIds.next(e);return new Promise((c,l)=>{let f=setTimeout(()=>{this.pendingBridge.delete(o),l(new C("AGENT_TIMEOUT",`${e} timed out after ${i}ms`))},i);this.pendingBridge.set(o,{method:e,resolve:c,reject:l,timer:f}),this.upstream.send(Pi(o,e,n)).catch(x=>{let p=this.pendingBridge.get(o);p&&(clearTimeout(p.timer),this.pendingBridge.delete(o)),l(x)})})}async persistSessionMapping(e){if(this.paths)try{let n=new Map;for(let[i,o]of e.sessions){let c={modelToken:o.modelToken,tokenGeneratedAt:o.tokenGeneratedAt};o.acpSessionId&&(c.acpSessionId=o.acpSessionId),n.set(i,c)}await ti(e.agentId,n,this.paths)}catch(n){K.warn("persist session mapping failed",{agentId:e.agentId,err:String(n)})}}reverseSessionId(e,n){for(let[i,o]of e.sessions.entries())if(o.acpSessionId===n)return i}sendError(e,n,i){return this.upstream.send(En(e,{code:n,message:i,data:{bridgeVersion:Ar}}))}};function Qy(){return $y(16).toString("hex")}function e1(t,e){if(!t||typeof t!="object"){K.warn("permission response: result not an object (suspicious)",{agentId:e.agentId,result:t});return}let n=t;if("kind"in n&&!("outcome"in n)){K.warn('permission response: top-level "kind" field (D66 historical bug shape)',{agentId:e.agentId,result:t});return}let i=n.outcome;if(!i||typeof i!="object"){K.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")&&K.warn("permission response: unknown outcome discriminant",{agentId:e.agentId,outcomeValue:c,result:t})}function t1(t){let e=t.update;if(e?.sessionUpdate!=="agent_message_chunk")return!1;let n=e.content;if(!n||typeof n!="object")return!1;let i=n;return i.type!=="text"||typeof i.text!="string"?!1:i.text.startsWith("Model metadata for `")}re();Oe();import{randomBytes as n1}from"node:crypto";import{chmod as r1,mkdir as i1,writeFile as Lu}from"node:fs/promises";import{createServer as s1}from"node:http";import{dirname as o1}from"node:path";var a1=1e6,Qc=H("ipc"),yo=class{server=null;port=0;token="";routes;paths;constructor(e){this.routes=new Map(e.routes.map(n=>[`${n.method} ${n.path}`,n])),this.paths=e.paths??Q()}async start(){this.token=n1(32).toString("hex");let e=s1((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 n=e.address();if(!n||typeof n!="object")throw new Error("failed to obtain IPC port");return this.port=n.port,await this.persistAuthFiles(),Qc.info("IPC listening",{port:this.port}),{port:this.port,token:this.token}}async stop(){let e=this.server;e&&(await new Promise((n,i)=>{e.close(o=>o?i(o):n())}),this.server=null)}async persistAuthFiles(){await i1(o1(this.paths.portFile),{recursive:!0}),await Lu(this.paths.portFile,String(this.port),"utf8"),await Lu(this.paths.tokenFile,this.token,{encoding:"utf8",mode:384});try{await r1(this.paths.tokenFile,384)}catch(e){Qc.warn("chmod token file failed (non-POSIX?)",{err:String(e)})}}async dispatch(e,n){if(e.headers.authorization!==`Bearer ${this.token}`){Ui(n,401,{error:"unauthorized"});return}let o=`${e.method} ${(e.url??"").split("?")[0]}`,c=this.routes.get(o);if(!c){Ui(n,404,{error:"not found"});return}let l=null;if(e.method==="POST")try{l=await c1(e)}catch(f){Ui(n,400,{error:"invalid json",detail:String(f)});return}try{let f=await c.handler(l,e);Ui(n,200,f??{ok:!0})}catch(f){Qc.error("IPC handler failed",{key:o,err:String(f)}),Ui(n,500,{error:f instanceof Error?f.message:String(f)})}}};function Ui(t,e,n){t.statusCode=e,t.setHeader("content-type","application/json"),t.end(JSON.stringify(n))}async function c1(t){let e=[],n=0;for await(let o of t){let c=o;if(n+=c.length,n>a1)throw new Error("body too large");e.push(c)}let i=Buffer.concat(e).toString("utf8");return i?JSON.parse(i):null}var th=Tt(Gu(),1);var HE=Tt(Fx(),1),GE=Tt(Mo(),1),jE=Tt(Pr(),1),WE=Tt(ud(),1),KE=Tt(pd(),1),$E=Tt(Ed(),1),Jx=Tt(Uo(),1),JE=Tt($x(),1);var Vx=Jx.default;Ve();re();var Le=H("upstream.frontier"),Xx="application/json",Yx="none",ZE=15e3;function XE(t){class e extends Vx{constructor(i){super(i,yf,{headers:t})}guardTeardown(){this.listenerCount("error")===0&&this.on("error",i=>Le.warn("frontier ws error during teardown (handled, prevents daemon crash)",{err:i instanceof Error?i.message:String(i)}))}close(i,o){this.guardTeardown(),super.close(i,o)}terminate(){this.guardTeardown(),super.terminate()}send(i,...o){if(s0("debug"))try{let c;typeof i=="string"?c=Buffer.from(i,"utf8"):i instanceof Buffer?c=i:i instanceof ArrayBuffer?c=new Uint8Array(i):ArrayBuffer.isView(i)?c=new Uint8Array(i.buffer,i.byteOffset,i.byteLength):c=new Uint8Array(0);let l=Buffer.from(c.slice(0,128)).toString("hex");Le.debug("WS raw frame out",{bytes:c.byteLength,headHex:l})}catch(c){Le.warn("WS raw frame dump failed",{err:String(c)})}super.send(i,...o)}}return e}var Vi=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){Le.warn("start called on already-started FrontierUpstream; noop");return}let e={Authorization:`Bearer ${this.opts.privatecode}`,Origin:Ef,...Sr(this.opts.ppeOverride)},n=XE(e),i=vf(this.opts.urlOverride),o={url:i,ws:n,fpID:_f,aID:no,accessKey:this.opts.handshake.accessKey,deviceID:this.opts.handshake.deviceId,payloadType:{type:Xx,force:!0},payloadEncoding:{encoding:Yx,force:!0},enableTransformTextPayload:!0,enableQoS:!1,enableAutoAck:!1,automaticOpen:!1,maxRetries:Number.POSITIVE_INFINITY,debug:this.opts.debug??!1},c=new th.FWS(o),l=!1,f=null,x,p,w=new Promise((y,b)=>{x=y,p=b}),v=y=>{l||(l=!0,f&&(clearTimeout(f),f=null),y?p(y):x())};c.onopen=()=>{this.opened=!0,this.openCount+=1;let y=this.openCount===1;Le.info("frontier opened",{url:i,remoteDeviceId:this.opts.handshake.deviceId,initial:y,openCount:this.openCount}),y&&v();for(let b of this.connectHandlers)Promise.resolve(b({initial:y})).catch(S=>Le.warn("onConnect handler threw (ignored)",{err:String(S)}))},c.onclose=y=>{this.opened=!1,Le.info("frontier closed",{code:y.code,reason:y.reason,willReconnect:y.willReconnect})},c.onerror=y=>{Le.warn("frontier error",{code:y.code,msg:y.message}),v(new C("UPSTREAM_DISCONNECTED",`frontier connect error before open: code=${y.code} msg=${y.message??""}`))},c.onmessage=y=>this.handleMessage(y),this.fws=c;let T=this.opts.openTimeoutMs??ZE;f=setTimeout(()=>{v(new C("UPSTREAM_DISCONNECTED",`frontier ws open timeout after ${T}ms (handshake or upgrade slow)`))},T),await c.connect();try{await w}catch(y){try{c.close(1e3,"open failed")}catch(b){Le.warn("fws close during start failure threw (ignored)",{err:String(b)})}throw this.fws=null,this.opened=!1,y}}async stop(e){let n=this.fws;if(n){this.fws=null,this.opened=!1;try{n.close(1e3,e??"bridge shutdown")}catch(i){Le.warn("frontier close threw (ignored)",{err:String(i)})}}}async send(e){let n=this.fws,i=e.method;if(!n)throw Le.warn("frontier send refused: upstream not started",{method:i}),new C("UPSTREAM_DISCONNECTED","frontier upstream not started");if(!this.isConnected()){let f=Date.now();throw f-this.lastSendRefusedLogAt>1e3?(Le.warn("frontier send refused: ws not open",{method:i,opened:this.opened,readyState:n.readyState,...this.sendRefusedSuppressed>0?{suppressedSinceLast:this.sendRefusedSuppressed}:{}}),this.lastSendRefusedLogAt=f,this.sendRefusedSuppressed=0):this.sendRefusedSuppressed+=1,new C("UPSTREAM_DISCONNECTED",`frontier ws not open (opened=${this.opened}, readyState=${n.readyState}); refusing to silently buffer`)}this.injectAgentPatToken(e);let o=JSON.stringify(e),c=e;Qx(c)||Le.info("frontier frame out",{method:c.method,jsonrpcId:c.id,size:o.length});try{await n.send(o,{service:33555712,method:1,payloadType:Xx,payloadEncoding:Yx})}catch(f){throw Le.warn("frontier frame send failed",{method:c.method,jsonrpcId:c.id,err:String(f)}),new C("UPSTREAM_DISCONNECTED",`frontier send failed: ${String(f)}`,{cause:f})}}onFrame(e){this.handler=e}onConnect(e){this.connectHandlers.push(e)}isConnected(){return this.opened&&this.fws?.readyState===1}injectAgentPatToken(e){let n=this.opts.getPatTokenForAgent;if(!n)return;let i=e.params?._meta;if(!i?.cozeAgentId)return;let o=n(i.cozeAgentId);o&&(i.cozePatToken=o)}handleMessage(e){let n=e.message?.service;if(n!==33555712){Le.debug("drop non-adapter frontier frame",{service:n});return}let i=eb(e);if(!i){Le.debug("frontier message without text payload, drop",{payloadType:e.message?.payloadType});return}if(!this.handler){Le.debug("frame received but no onFrame handler",{size:i.length});return}let o;try{o=JSON.parse(i)}catch(l){Le.warn("frontier message JSON parse failed",{err:String(l),head:i.slice(0,80)});return}let c=o;Qx(c)||Le.info("frontier frame in",{logid:QE(e.message?.LogID),logidNew:e.message?.LogIDNew,msgId:e.message?.msgID,jsonrpcId:c.id,method:c.method,body:YE(i)}),Promise.resolve(this.handler(o)).catch(l=>Le.warn("frontier frame handler threw",{err:String(l)}))}};function Qx(t){return t.method==="_agent/health"?!0:typeof t.id=="string"&&t.id.startsWith("agent.health_")}var eh=2e3;function YE(t){return t.length<=eh?t:`${t.slice(0,eh)}...<truncated, total ${t.length} chars>`}function QE(t){return t?t.high===0?String(t.low>>>0):`${t.high.toString(16)}${(t.low>>>0).toString(16).padStart(8,"0")}`:""}function eb(t){let e=t.message;if(e?.textPayload)return e.textPayload;let n=e?.payload;if(!n)return null;try{return Buffer.from(n).toString("utf8")}catch{return null}}re();var vd=H("upstream.switchable"),Ho=class{inner;handler=null;connectHandlers=[];constructor(e){this.inner=e}async swap(e,n){if(this.inner===e)return;vd.info("swap upstream",{reason:n});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 vd.error("swap target start failed, reverting",{err:String(o)}),this.inner=i,o}await i.stop(n??"swapped").catch(o=>vd.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()}};re();var Sd=H("upstream"),Fr=class{handler=null;async start(){Sd.info("NoopUpstream started (M1 skeleton; real Frontier wired in M4)")}async stop(e){Sd.info("NoopUpstream stopped",{reason:e})}async send(e){Sd.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)}};Ve();re();re();Oe();import{promises as Id}from"node:fs";import{dirname as tb}from"node:path";var nb=H("pat-token-store");async function Go(t=Q()){try{let n=(await Id.readFile(t.patTokenFile,"utf8")).trim();return n.length>0?n:null}catch(e){let n=e?.code;return n!=="ENOENT"&&nb.warn("read pat-token failed (treating as missing)",{path:t.patTokenFile,code:n,message:e.message}),null}}async function Zi(t,e=Q()){if(!t)throw new Error("writePatToken: empty patToken");await Id.mkdir(tb(e.patTokenFile),{recursive:!0}),await Id.writeFile(e.patTokenFile,t,{encoding:"utf8",mode:384})}Oe();Oe();import{promises as jo}from"node:fs";import{join as rb}from"node:path";function ib(t,e){return`#!/bin/sh
|
|
102
102
|
exec ${JSON.stringify(e)} ${JSON.stringify(t)} "$@"
|
|
103
|
-
`}function
|
|
103
|
+
`}function sb(t,e){return`@echo off\r
|
|
104
104
|
"${e}" "${t}" %*\r
|
|
105
|
-
`}async function Qx(t,e=Q()){let r=e.binDir;await Uo.mkdir(r,{recursive:!0});let i=rv(r,process.platform==="win32"?"coze-bridge.cmd":"coze-bridge"),o=process.execPath,c=process.platform==="win32"?sv(t,o):iv(t,o);return await Uo.readFile(i,"utf8").catch(()=>null)===c||(await Uo.writeFile(i,c,"utf8"),process.platform!=="win32"&&await Uo.chmod(i,493)),r}ne();De();import{execSync as eh}from"node:child_process";import{readFileSync as th,unlinkSync as ov}from"node:fs";import{mkdir as av,readFile as nh,unlink as rh,writeFile as cv}from"node:fs/promises";import{dirname as dv}from"node:path";function Ho(t){try{return process.kill(t,0),!0}catch(e){return e.code==="EPERM"}}var lv=H("single-instance"),qo=class{pidFile;acquired=!1;constructor(e={}){this.pidFile=e.pidFile??Q().pidFile,e.processTitle&&(process.title=e.processTitle)}async acquire(){let e=await this.readExistingPid();return e!==null&&this.isAlive(e)?{kind:"already-running",pid:e}:(e!==null&&(lv.warn("removing stale pid file",{stalePid:e}),await rh(this.pidFile).catch(()=>{})),await av(dv(this.pidFile),{recursive:!0}),await cv(this.pidFile,String(process.pid),"utf8"),this.acquired=!0,this.installCleanupHooks(),{kind:"acquired"})}async release(){if(this.acquired){try{(await nh(this.pidFile,"utf8")).trim()===String(process.pid)&&await rh(this.pidFile)}catch{}this.acquired=!1}}async readExistingPid(){try{let e=await nh(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 Ho(e)?this.matchesDaemonTitle(e):!1}matchesDaemonTitle(e){if(process.platform==="win32")return this.matchesDaemonTitleWindows(e);try{let r=th(`/proc/${e}/cmdline`,"utf8").replace(/\0/g," ");return!!(r.includes("coze-bridge-daemon")||r.includes("lib/index.js"))}catch{}try{let r=eh(`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=eh(`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{th(this.pidFile,"utf8").trim()===String(process.pid)&&ov(this.pidFile)}catch{}})}};Go();ne();var Wn=H("daemon.upstream-watchdog"),wv=12e4,_v=9e5,yv=3e4;function Sd(t,e){let r=process.env[t];if(!r)return e;let i=Number(r);return Number.isFinite(i)&&i>0?i:e}var jo=class{constructor(e){this.opts=e;this.softMs=e.softMs??Sd("COZE_BRIDGE_UPSTREAM_WATCHDOG_SOFT_MS",wv),this.hardMs=e.hardMs??Sd("COZE_BRIDGE_UPSTREAM_WATCHDOG_HARD_MS",_v),this.intervalMs=e.intervalMs??Sd("COZE_BRIDGE_UPSTREAM_WATCHDOG_INTERVAL_MS",yv),this.now=e.now??Date.now}opts;softMs;hardMs;intervalMs;now;timer=null;downSince=null;forcedAt=null;forcing=!1;lastTickAt=null;start(){this.timer||(this.timer=setInterval(()=>this.tick(),this.intervalMs),this.timer.unref?.(),Wn.info("upstream watchdog started",{softMs:this.softMs,hardMs:this.hardMs,intervalMs:this.intervalMs}))}stop(){this.timer&&(clearInterval(this.timer),this.timer=null),this.downSince=null,this.forcedAt=null,this.lastTickAt=null}tick(){let e=this.now();if(this.lastTickAt!==null&&e-this.lastTickAt>this.intervalMs*3&&(this.downSince!==null&&Wn.warn("upstream watchdog: large tick gap (likely sleep/suspend), resetting downSince",{gapMs:e-this.lastTickAt}),this.downSince=null,this.forcedAt=null),this.lastTickAt=e,this.opts.isConnected()){this.downSince!==null&&Wn.info("upstream watchdog: reconnected, reset",{downMs:this.now()-this.downSince}),this.downSince=null,this.forcedAt=null;return}if(this.downSince===null){this.downSince=e,Wn.warn("upstream watchdog: disconnect detected, arming",{softMs:this.softMs,hardMs:this.hardMs});return}let r=e-this.downSince;if(r>=this.hardMs){Wn.error("upstream watchdog: disconnected too long, exiting for supervisor restart",{downMs:r,hardMs:this.hardMs}),this.opts.onFatal(r);return}r>=this.softMs&&this.shouldForceNow(e)&&(this.forcedAt=e,this.forcing=!0,Wn.warn("upstream watchdog: forcing reconnect",{downMs:r,softMs:this.softMs}),Promise.resolve().then(()=>this.opts.forceReconnect()).catch(i=>Wn.warn("upstream watchdog: forceReconnect error (ignored)",{err:String(i)})).finally(()=>{this.forcing=!1}))}shouldForceNow(e){return!(this.forcing||this.forcedAt!==null&&e-this.forcedAt<this.softMs)}};var j=H("daemon"),bv="coze-bridge-daemon";async function oh(){let t=Q();process.env.COZE_BRIDGE_LOG_MODE!=="legacy"&&el({bridgeLogsDir:t.bridgeLogsDir,agentLogsDir:O=>Ye(O,t).logs,listAgentIds:()=>rs(t)});let e=new qo({processTitle:bv}),r=await e.acquire();if(r.kind==="already-running")throw new Error(`coze-bridge daemon already running (pid=${r.pid})`);let i=await ho(),o=i??{};ts({pid:process.pid}),j.info(i?"loaded bridge config":"initialized bridge config");try{let O=new Fn;o.frameworksCache=await O.detectAll(),j.info("refreshed frameworks_cache",{detected:Object.keys(o.frameworksCache)})}catch(O){j.warn("framework detection failed",{err:String(O)})}await Pi(o);let c=new zo(new Or),l=null,u=new po({upstream:c,paths:t,bridgeConfig:o,sessionSpawner:async(O,G,W,ie)=>{if(!l)throw new Error("agentManager not ready");return l.spawnSessionDownstream(O,G,W,ie)}});await vv(t,u);let x=new uo({paths:t,config:o,registry:u});l=x;let p,m,b=null,I={},y,E=null,S=null,A=null,D=new wn;function L(O,G){return D.enqueue(()=>R(O,G))}function _(){S||(S=new jo({isConnected:()=>c.isConnected(),forceReconnect:()=>A?L(A,{force:!0}):void 0,onFatal:O=>{if(process.env[Wi]==="1"){j.error("upstream watchdog fatal, but daemon is unmanaged (CLI-spawned) \u2014 staying alive for soft-reconnect instead of exiting",{downMs:O});return}j.error("upstream watchdog fatal: exiting for supervisor restart",{downMs:O}),process.exit(1)}})),S.start()}async function R(O,G){let W=O,ie=W?.privatecode;if(!ie)throw new C("IPC_BAD_REQUEST","/connect requires privatecode");let Je=Si(W.env),le=W.handshake_url,ue=W.frontier_url,bt=sh(W.env,le,ue);if(A=W,!G?.force&&p===ie&&m===bt){let he=await Ev(t);return u.agents.size===0&&he?(j.warn("/connect noop but core.agents empty with configs on disk; re-running auto-revive"),Ko(t,x).catch(Se=>j.warn("connect-noop auto-revive error (ignored)",{err:String(Se)}))):j.info("/connect: already connected with same PAT + env, noop"),{ok:!0,note:"already connected"}}let ut=!!p&&p!==ie,Vt=m!==void 0&&m!==bt,Nt=ut||Vt,Yt=await kc({privatecode:ie,...le?{endpoint:le}:{},ppeOverride:Je});if(Nt){j.warn("connect config switched, resetting agents",{pcChanged:ut,envChanged:Vt,previousPc:p?Wo(p):"",nextPc:Wo(ie)});for(let he of[...u.agents.values()])await he.dispose("connect config switch").catch(()=>{}),u.agents.delete(he.agentId);u.disconnectedAgents.size>0&&(j.info("clearing disconnectedAgents set on connect config switch",{count:u.disconnectedAgents.size}),u.disconnectedAgents.clear()),await c.swap(new Or,"connect switch").catch(()=>{})}b=Yt.deviceId,ts({deviceId:b,pid:process.pid}),Jc({patToken:ie,env:W.env}).catch(he=>j.warn("coze-cli setup error (ignored)",{err:String(he)}));let Fr=new Gi({handshake:Yt,privatecode:ie,...ue?{urlOverride:ue}:{},ppeOverride:Je,getPatTokenForAgent:he=>u.agents.get(he)?.patToken});return await c.swap(Fr,"connect"),p=ie,m=bt,I=Je,y=le,W.mock_scenario!==void 0&&(u.setMockScenario(W.mock_scenario),j.info("mock scenario set",{scenario:W.mock_scenario})),E||(E=new Ai({core:u,getDeviceId:()=>b??"",onTickEnd:()=>F.retryPending().catch(he=>j.warn("detailSync.retryPending failed (ignored)",{err:String(he)})),onAuthFailures:V})),E.start(),_(),Nt&&Ko(t,x).catch(he=>j.warn("post-connect-switch auto-revive error (ignored)",{err:String(he)})),ji(ie,t).catch(he=>j.warn("writePatToken after /connect failed (ignored)",{err:String(he)})),j.info("/connect: WS established",{deviceId:b}),{ok:!0,note:"connected"}}u.registerExtension("_agent/create",async O=>x.createAgent(O.params)),u.registerExtension("_agent/health",async()=>({ok:!0}));let k={},z=new eo({agents:u.agents,disposeAndMarkDisconnected:async(O,G)=>{let W=u.agents.get(O);if(W){await x.cleanupOpenclawSessionProviders(W).catch(Je=>j.warn("cleanup openclaw providers failed (ignored)",{agentId:O,err:String(Je)}));let ie=!0;try{await W.dispose(`disconnect: ${G}`)}catch(Je){ie=!1,j.error("dispose during disconnect FAILED, leaving agent in error state",{agentId:O,err:String(Je)}),W.status="error"}ie&&(W.status="disconnected",u.unregister(O),u.disconnectedAgents.add(O))}else u.disconnectedAgents.add(O)},detailSyncer:async O=>{if(!k.ref)throw new Error("agent-detail-sync not initialized yet");await k.ref.syncOne(O)},cleanupOpenclawProviders:async O=>{await x.cleanupOpenclawSessionProviders(O)},openclawRepair:async(O,G)=>{await x.openclawRepair(O,G)},isRuntimePendingPermission:O=>u.hasPendingPermissionFor(O)});u.registerExtension("_agent/listSkills",O=>z.listSkills(O.params)),u.registerExtension("_agent/addSkills",O=>z.addSkills(O.params)),u.registerExtension("_agent/removeSkills",O=>z.removeSkills(O.params)),u.registerExtension("_agent/getFileTree",O=>z.getFileTree(O.params)),u.registerExtension("_agent/getFileContent",O=>z.getFileContent(O.params)),u.registerExtension("_agent/update",O=>z.updateAgent(O.params)),u.registerExtension("_agent/disconnect",O=>z.disconnectAgent(O.params)),u.registerExtension("_agent/switchModel",O=>z.switchModel(O.params)),u.registerExtension("_agent/reset",O=>z.resetAgent(O.params)),u.registerExtension("_agent/repair",O=>z.repairAgent(O.params));let F=new as({paths:t,handlers:z,sendDetail:O=>u.sendRequest("_agent/detail",O)});k.ref=F;let V=async O=>{await Promise.allSettled(O.map(async G=>{try{await z.disconnectAgent({agentId:G.agentId,reason:`auth_failure: code=${G.code} ${G.message}`}),j.info("agent disconnected due to auth failure from heartbeat response",{agentId:G.agentId,code:G.code,message:G.message})}catch(W){j.warn("disconnect during authFailure handling failed (ignored)",{agentId:G.agentId,err:String(W)})}}))};c.onConnect(({initial:O})=>{j.info("frontier upstream connected, triggering detail sync",{initial:O}),F.syncAll(O?"initial-connect":"reconnect").catch(G=>j.warn("detail sync top-level error (ignored)",{err:String(G)}))});let J=new go({paths:t,routes:[{method:"GET",path:"/status",handler:async()=>{let O=u.getMockScenario();return{running:!0,pid:process.pid,spawnedBy:process.env[Wi]==="1"?"manual":"supervisor",agents:[...u.agents.keys()],deviceId:b??"",frameworksCache:o.frameworksCache??{},...O?{mockScenario:O}:{}}}},{method:"POST",path:"/pair",handler:async O=>{let G=O,W=G?.privatecode,ie=G?.pairing_code;if(!W||!ie)throw new C("IPC_BAD_REQUEST","/pair requires privatecode + pairing_code");let Je=Si(G.env),le=G.handshake_url,ue=G.frontier_url,bt=sh(G.env,le,ue),ut=!!p&&p!==W,Vt=m!==void 0&&m!==bt,Nt=ut||Vt,Yt=await kc({privatecode:W,...le?{endpoint:le}:{},ppeOverride:Je});if(Nt){j.warn("pair config switched, resetting agents",{pcChanged:ut,envChanged:Vt,previousPc:p?Wo(p):"",nextPc:Wo(W),previousEnvKey:m??"",nextEnvKey:bt});for(let Se of[...u.agents.values()])await Se.dispose("pair config switch").catch(()=>{}),u.agents.delete(Se.agentId);u.disconnectedAgents.size>0&&(j.info("clearing disconnectedAgents set on pair config switch",{count:u.disconnectedAgents.size}),u.disconnectedAgents.clear()),await c.swap(new Or,"pair switch").catch(()=>{})}b=Yt.deviceId,ts({deviceId:b,pid:process.pid}),Jc({patToken:W,env:G.env}).catch(Se=>j.warn("coze-cli setup error (ignored)",{err:String(Se)}));let Fr=new Gi({handshake:Yt,privatecode:W,...ue?{urlOverride:ue}:{},ppeOverride:Je,getPatTokenForAgent:Se=>u.agents.get(Se)?.patToken});await c.swap(Fr,"pair");try{let Se=new Fn;o.frameworksCache=await Se.detectAll(),await Pi(o),j.info("frameworks_cache refreshed before pair",{detected:Object.keys(o.frameworksCache)})}catch(Se){j.warn("frameworks_cache refresh failed (ignored, using cached)",{err:String(Se)})}let he=Object.keys(o.frameworksCache??{});try{let Se=await u.sendRequest("_agent/pair",{pairCode:ie,patToken:W,frameworks:he,_meta:{cozeDeviceId:b}});j.info("_agent/pair ok",{pairResult:Se}),p=W,m=bt,I=Je,y=le,G.mock_scenario!==void 0&&(u.setMockScenario(G.mock_scenario),j.info("mock scenario set",{scenario:G.mock_scenario})),ji(W,t).catch(Re=>j.warn("writePatToken after /pair failed (ignored)",{err:String(Re)})),E||(E=new Ai({core:u,getDeviceId:()=>b??"",onTickEnd:()=>F.retryPending().catch(Re=>j.warn("detailSync.retryPending failed (ignored)",{err:String(Re)})),onAuthFailures:V})),E.start(),_(),Nt&&Ko(t,x).catch(Re=>j.warn("post-pair-switch auto-revive error (ignored)",{err:String(Re)}));let Kn;return G.agent_id&&(Kn=await Sv(G.agent_id,t,x,Re=>u.sendRequest("_agent/detail",Re),W).catch(Re=>(j.error("--agent-id ensureAgent failed",{agentId:G.agent_id,err:String(Re)}),{ok:!1,agentId:G.agent_id??"",note:String(Re)}))),{ok:!0,note:"paired with cloud",...Kn?{agent:Kn}:{}}}catch(Se){return j.error("_agent/pair failed",{err:String(Se)}),{ok:!1,note:`pair failed: ${String(Se)}`}}}},{method:"POST",path:"/connect",handler:O=>L(O)},{method:"POST",path:"/_agent/create",handler:async O=>{let G=O;return{ok:!0,result:await x.createAgent(G)}}},{method:"POST",path:"/agent/send",handler:async O=>{let G=O;if(!G?.agentId||!G?.sessionId||!G?.kind||!G?.path)throw new C("IPC_BAD_REQUEST","/agent/send requires agentId, sessionId, kind, path");if(!p)throw new C("UPSTREAM_NOT_READY","daemon not yet paired with cloud (run --pair-code first)");try{let W=G;return await(W.groupFile?xf:ff)(W,{core:u,patToken:p,handshakeBase:y,ppeOverride:I})}catch(W){if(W instanceof C)return{ok:!1,code:W.code,message:W.message};throw W}}},{method:"POST",path:"/reload",handler:async O=>{let G=O?.agent_id,W=await u.reloadAgents(G);return j.info("IPC /reload: recycled agent subprocesses",{agentId:G??"(all)",recycled:W}),{ok:!0,recycled:W}}},{method:"POST",path:"/shutdown",handler:async()=>(j.info("IPC /shutdown received"),setImmediate(()=>{Ne.shutdown("ipc /shutdown")}),{ok:!0})}]}),{port:ee,token:X}=await J.start();try{await Qx(t.libEntry,t)}catch(O){j.warn("bin shim install failed (D72 send \u547D\u4EE4\u53EF\u80FD\u4E0D\u53EF\u7528)",{err:String(O)})}await u.start(),Ko(t,x).catch(O=>j.warn("auto-revive top-level error (ignored)",{err:String(O)})),ll().then(async()=>{let{probeAcpVersion:O}=await Promise.resolve().then(()=>(Qt(),cl));for(let G of["claude-code","codex"]){let W=await O(G);W&&j.info("acp wrapper version",{framework:G,version:W})}}).catch(O=>j.warn("acp wrapper warmup / probe top-level error (ignored)",{err:String(O)}));let ve=null,Ne={port:ee,token:X,core:u,ipc:J,shutdown(O){return ve||(j.info("daemon shutdown",{reason:O}),ve=(async()=>{E?.stop(),S?.stop(),await u.stop(O),await J.stop(),await e.release()})(),ve)}};for(let O of["SIGTERM","SIGINT"])process.on(O,()=>{Ne.shutdown(O).then(()=>process.exit(0))});return process.on("unhandledRejection",O=>{j.error("unhandledRejection",{reason:O instanceof Error?O.message:String(O),stack:O instanceof Error?O.stack:void 0})}),process.on("uncaughtException",O=>{j.error("uncaughtException (will exit, supervisor will restart)",{message:O.message,stack:O.stack,name:O.name});try{process.stderr.write(`FATAL uncaughtException: ${O.stack??O.message}
|
|
106
|
-
`)}catch{}process.exit(1)}),j.info("daemon ready",{port:ee,pid:process.pid,nodeVersion:process.version,platform:process.platform,frameworks:Object.keys(o.frameworksCache??{}),libVersion:o.libVersion??"dev"}),
|
|
107
|
-
`;await
|
|
108
|
-
`).filter(l=>l.length>0).filter(l=>
|
|
109
|
-
`)}async function
|
|
105
|
+
`}async function nh(t,e=Q()){let n=e.binDir;await jo.mkdir(n,{recursive:!0});let i=rb(n,process.platform==="win32"?"coze-bridge.cmd":"coze-bridge"),o=process.execPath,c=process.platform==="win32"?sb(t,o):ib(t,o);return await jo.readFile(i,"utf8").catch(()=>null)===c||(await jo.writeFile(i,c,"utf8"),process.platform!=="win32"&&await jo.chmod(i,493)),n}re();Oe();import{execSync as rh}from"node:child_process";import{readFileSync as ih,unlinkSync as ob}from"node:fs";import{mkdir as ab,readFile as sh,unlink as oh,writeFile as cb}from"node:fs/promises";import{dirname as db}from"node:path";function Wo(t){try{return process.kill(t,0),!0}catch(e){return e.code==="EPERM"}}var lb=H("single-instance"),Ko=class{pidFile;acquired=!1;constructor(e={}){this.pidFile=e.pidFile??Q().pidFile,e.processTitle&&(process.title=e.processTitle)}async acquire(){let e=await this.readExistingPid();return e!==null&&this.isAlive(e)?{kind:"already-running",pid:e}:(e!==null&&(lb.warn("removing stale pid file",{stalePid:e}),await oh(this.pidFile).catch(()=>{})),await ab(db(this.pidFile),{recursive:!0}),await cb(this.pidFile,String(process.pid),"utf8"),this.acquired=!0,this.installCleanupHooks(),{kind:"acquired"})}async release(){if(this.acquired){try{(await sh(this.pidFile,"utf8")).trim()===String(process.pid)&&await oh(this.pidFile)}catch{}this.acquired=!1}}async readExistingPid(){try{let e=await sh(this.pidFile,"utf8"),n=Number.parseInt(e.trim(),10);return Number.isFinite(n)&&n>0?n:null}catch(e){if(e.code==="ENOENT")return null;throw e}}isAlive(e){return Wo(e)?this.matchesDaemonTitle(e):!1}matchesDaemonTitle(e){if(process.platform==="win32")return this.matchesDaemonTitleWindows(e);try{let n=ih(`/proc/${e}/cmdline`,"utf8").replace(/\0/g," ");return!!(n.includes("coze-bridge-daemon")||n.includes("lib/index.js"))}catch{}try{let n=rh(`ps -o command= -p ${e}`,{stdio:["ignore","pipe","ignore"],timeout:1e3}).toString();return n.trim()?n.includes("coze-bridge-daemon")||n.includes("lib/index.js"):!1}catch{return!0}}matchesDaemonTitleWindows(e){try{let i=rh(`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{ih(this.pidFile,"utf8").trim()===String(process.pid)&&ob(this.pidFile)}catch{}})}};$o();re();var Zn=H("daemon.upstream-watchdog"),wb=12e4,_b=9e5,yb=3e4;function Td(t,e){let n=process.env[t];if(!n)return e;let i=Number(n);return Number.isFinite(i)&&i>0?i:e}var Jo=class{constructor(e){this.opts=e;this.softMs=e.softMs??Td("COZE_BRIDGE_UPSTREAM_WATCHDOG_SOFT_MS",wb),this.hardMs=e.hardMs??Td("COZE_BRIDGE_UPSTREAM_WATCHDOG_HARD_MS",_b),this.intervalMs=e.intervalMs??Td("COZE_BRIDGE_UPSTREAM_WATCHDOG_INTERVAL_MS",yb),this.now=e.now??Date.now}opts;softMs;hardMs;intervalMs;now;timer=null;downSince=null;forcedAt=null;forcing=!1;lastTickAt=null;start(){this.timer||(this.timer=setInterval(()=>this.tick(),this.intervalMs),this.timer.unref?.(),Zn.info("upstream watchdog started",{softMs:this.softMs,hardMs:this.hardMs,intervalMs:this.intervalMs}))}stop(){this.timer&&(clearInterval(this.timer),this.timer=null),this.downSince=null,this.forcedAt=null,this.lastTickAt=null}tick(){let e=this.now();if(this.lastTickAt!==null&&e-this.lastTickAt>this.intervalMs*3&&(this.downSince!==null&&Zn.warn("upstream watchdog: large tick gap (likely sleep/suspend), resetting downSince",{gapMs:e-this.lastTickAt}),this.downSince=null,this.forcedAt=null),this.lastTickAt=e,this.opts.isConnected()){this.downSince!==null&&Zn.info("upstream watchdog: reconnected, reset",{downMs:this.now()-this.downSince}),this.downSince=null,this.forcedAt=null;return}if(this.downSince===null){this.downSince=e,Zn.warn("upstream watchdog: disconnect detected, arming",{softMs:this.softMs,hardMs:this.hardMs});return}let n=e-this.downSince;if(n>=this.hardMs){Zn.error("upstream watchdog: disconnected too long, exiting for supervisor restart",{downMs:n,hardMs:this.hardMs}),this.opts.onFatal(n);return}n>=this.softMs&&this.shouldForceNow(e)&&(this.forcedAt=e,this.forcing=!0,Zn.warn("upstream watchdog: forcing reconnect",{downMs:n,softMs:this.softMs}),Promise.resolve().then(()=>this.opts.forceReconnect()).catch(i=>Zn.warn("upstream watchdog: forceReconnect error (ignored)",{err:String(i)})).finally(()=>{this.forcing=!1}))}shouldForceNow(e){return!(this.forcing||this.forcedAt!==null&&e-this.forcedAt<this.softMs)}};var j=H("daemon"),Eb="coze-bridge-daemon";async function dh(){let t=Q();process.env.COZE_BRIDGE_LOG_MODE!=="legacy"&&r0({bridgeLogsDir:t.bridgeLogsDir,agentLogsDir:O=>Qe(O,t).logs,listAgentIds:()=>as(t)});let e=new Ko({processTitle:Eb}),n=await e.acquire();if(n.kind==="already-running")throw new Error(`coze-bridge daemon already running (pid=${n.pid})`);let i=await wo(),o=i??{};ss({pid:process.pid}),j.info(i?"loaded bridge config":"initialized bridge config");try{let O=new jn;o.frameworksCache=await O.detectAll(),j.info("refreshed frameworks_cache",{detected:Object.keys(o.frameworksCache)})}catch(O){j.warn("framework detection failed",{err:String(O)})}await zi(o);let c=new Ho(new Fr),l=null,f=new _o({upstream:c,paths:t,bridgeConfig:o,sessionSpawner:async(O,G,W,se)=>{if(!l)throw new Error("agentManager not ready");return l.spawnSessionDownstream(O,G,W,se)}});await vb(t,f);let x=new po({paths:t,config:o,registry:f});l=x;let p,w,v=null,T={},y,b=null,S=null,A=null,R=new vn;function P(O,G){return R.enqueue(()=>D(O,G))}function _(){S||(S=new Jo({isConnected:()=>c.isConnected(),forceReconnect:()=>A?P(A,{force:!0}):void 0,onFatal:O=>{if(process.env[Xi]==="1"){j.error("upstream watchdog fatal, but daemon is unmanaged (CLI-spawned) \u2014 staying alive for soft-reconnect instead of exiting",{downMs:O});return}j.error("upstream watchdog fatal: exiting for supervisor restart",{downMs:O}),process.exit(1)}})),S.start()}async function D(O,G){let W=O,se=W?.privatecode;if(!se)throw new C("IPC_BAD_REQUEST","/connect requires privatecode");let Xe=Ri(W.env),xe=W.handshake_url,he=W.frontier_url,At=ch(W.env,xe,he);if(A=W,!G?.force&&p===se&&w===At){let we=await bb(t);return f.agents.size===0&&we?(j.warn("/connect noop but core.agents empty with configs on disk; re-running auto-revive"),Zo(t,x).catch(Te=>j.warn("connect-noop auto-revive error (ignored)",{err:String(Te)}))):j.info("/connect: already connected with same PAT + env, noop"),{ok:!0,note:"already connected"}}let pt=!!p&&p!==se,en=w!==void 0&&w!==At,Ut=pt||en,tn=await Oc({privatecode:se,...xe?{endpoint:xe}:{},ppeOverride:Xe});if(Ut){j.warn("connect config switched, resetting agents",{pcChanged:pt,envChanged:en,previousPc:p?Vo(p):"",nextPc:Vo(se)});for(let we of[...f.agents.values()])await we.dispose("connect config switch").catch(()=>{}),f.agents.delete(we.agentId);f.disconnectedAgents.size>0&&(j.info("clearing disconnectedAgents set on connect config switch",{count:f.disconnectedAgents.size}),f.disconnectedAgents.clear()),await c.swap(new Fr,"connect switch").catch(()=>{})}v=tn.deviceId,ss({deviceId:v,pid:process.pid}),Xc({patToken:se,env:W.env}).catch(we=>j.warn("coze-cli setup error (ignored)",{err:String(we)}));let jr=new Vi({handshake:tn,privatecode:se,...he?{urlOverride:he}:{},ppeOverride:Xe,getPatTokenForAgent:we=>f.agents.get(we)?.patToken});return await c.swap(jr,"connect"),p=se,w=At,T=Xe,y=xe,W.mock_scenario!==void 0&&(f.setMockScenario(W.mock_scenario),j.info("mock scenario set",{scenario:W.mock_scenario})),b||(b=new Li({core:f,getDeviceId:()=>v??"",onTickEnd:()=>z.retryPending().catch(we=>j.warn("detailSync.retryPending failed (ignored)",{err:String(we)})),onAuthFailures:J})),b.start(),_(),Ut&&Zo(t,x).catch(we=>j.warn("post-connect-switch auto-revive error (ignored)",{err:String(we)})),Zi(se,t).catch(we=>j.warn("writePatToken after /connect failed (ignored)",{err:String(we)})),j.info("/connect: WS established",{deviceId:v}),{ok:!0,note:"connected"}}f.registerExtension("_agent/create",async O=>x.createAgent(O.params)),f.registerExtension("_agent/health",async()=>({ok:!0}));let L={},B=new io({agents:f.agents,disposeAndMarkDisconnected:async(O,G)=>{let W=f.agents.get(O);if(W){await x.cleanupOpenclawSessionProviders(W).catch(Xe=>j.warn("cleanup openclaw providers failed (ignored)",{agentId:O,err:String(Xe)}));let se=!0;try{await W.dispose(`disconnect: ${G}`)}catch(Xe){se=!1,j.error("dispose during disconnect FAILED, leaving agent in error state",{agentId:O,err:String(Xe)}),W.status="error"}se&&(W.status="disconnected",f.unregister(O),f.disconnectedAgents.add(O))}else f.disconnectedAgents.add(O)},detailSyncer:async O=>{if(!L.ref)throw new Error("agent-detail-sync not initialized yet");await L.ref.syncOne(O)},cleanupOpenclawProviders:async O=>{await x.cleanupOpenclawSessionProviders(O)},openclawRepair:async(O,G)=>{await x.openclawRepair(O,G)},isRuntimePendingPermission:O=>f.hasPendingPermissionFor(O)});f.registerExtension("_agent/listSkills",O=>B.listSkills(O.params)),f.registerExtension("_agent/addSkills",O=>B.addSkills(O.params)),f.registerExtension("_agent/removeSkills",O=>B.removeSkills(O.params)),f.registerExtension("_agent/getFileTree",O=>B.getFileTree(O.params)),f.registerExtension("_agent/getFileContent",O=>B.getFileContent(O.params)),f.registerExtension("_agent/update",O=>B.updateAgent(O.params)),f.registerExtension("_agent/disconnect",O=>B.disconnectAgent(O.params)),f.registerExtension("_agent/switchModel",O=>B.switchModel(O.params)),f.registerExtension("_agent/reset",O=>B.resetAgent(O.params)),f.registerExtension("_agent/repair",O=>B.repairAgent(O.params));let z=new fs({paths:t,handlers:B,sendDetail:O=>f.sendRequest("_agent/detail",O)});L.ref=z;let J=async O=>{await Promise.allSettled(O.map(async G=>{try{await B.disconnectAgent({agentId:G.agentId,reason:`auth_failure: code=${G.code} ${G.message}`}),j.info("agent disconnected due to auth failure from heartbeat response",{agentId:G.agentId,code:G.code,message:G.message})}catch(W){j.warn("disconnect during authFailure handling failed (ignored)",{agentId:G.agentId,err:String(W)})}}))};c.onConnect(({initial:O})=>{j.info("frontier upstream connected, triggering detail sync",{initial:O}),z.syncAll(O?"initial-connect":"reconnect").catch(G=>j.warn("detail sync top-level error (ignored)",{err:String(G)}))});let $=new yo({paths:t,routes:[{method:"GET",path:"/status",handler:async()=>{let O=f.getMockScenario();return{running:!0,pid:process.pid,spawnedBy:process.env[Xi]==="1"?"manual":"supervisor",agents:[...f.agents.keys()],deviceId:v??"",frameworksCache:o.frameworksCache??{},...O?{mockScenario:O}:{}}}},{method:"POST",path:"/pair",handler:async O=>{let G=O,W=G?.privatecode,se=G?.pairing_code;if(!W||!se)throw new C("IPC_BAD_REQUEST","/pair requires privatecode + pairing_code");let Xe=Ri(G.env),xe=G.handshake_url,he=G.frontier_url,At=ch(G.env,xe,he),pt=!!p&&p!==W,en=w!==void 0&&w!==At,Ut=pt||en,tn=await Oc({privatecode:W,...xe?{endpoint:xe}:{},ppeOverride:Xe});if(Ut){j.warn("pair config switched, resetting agents",{pcChanged:pt,envChanged:en,previousPc:p?Vo(p):"",nextPc:Vo(W),previousEnvKey:w??"",nextEnvKey:At});for(let Te of[...f.agents.values()])await Te.dispose("pair config switch").catch(()=>{}),f.agents.delete(Te.agentId);f.disconnectedAgents.size>0&&(j.info("clearing disconnectedAgents set on pair config switch",{count:f.disconnectedAgents.size}),f.disconnectedAgents.clear()),await c.swap(new Fr,"pair switch").catch(()=>{})}v=tn.deviceId,ss({deviceId:v,pid:process.pid}),Xc({patToken:W,env:G.env}).catch(Te=>j.warn("coze-cli setup error (ignored)",{err:String(Te)}));let jr=new Vi({handshake:tn,privatecode:W,...he?{urlOverride:he}:{},ppeOverride:Xe,getPatTokenForAgent:Te=>f.agents.get(Te)?.patToken});await c.swap(jr,"pair");try{let Te=new jn;o.frameworksCache=await Te.detectAll(),await zi(o),j.info("frameworks_cache refreshed before pair",{detected:Object.keys(o.frameworksCache)})}catch(Te){j.warn("frameworks_cache refresh failed (ignored, using cached)",{err:String(Te)})}let we=Object.keys(o.frameworksCache??{});try{let Te=await f.sendRequest("_agent/pair",{pairCode:se,patToken:W,frameworks:we,_meta:{cozeDeviceId:v}});j.info("_agent/pair ok",{pairResult:Te}),p=W,w=At,T=Xe,y=xe,G.mock_scenario!==void 0&&(f.setMockScenario(G.mock_scenario),j.info("mock scenario set",{scenario:G.mock_scenario})),Zi(W,t).catch(Pe=>j.warn("writePatToken after /pair failed (ignored)",{err:String(Pe)})),b||(b=new Li({core:f,getDeviceId:()=>v??"",onTickEnd:()=>z.retryPending().catch(Pe=>j.warn("detailSync.retryPending failed (ignored)",{err:String(Pe)})),onAuthFailures:J})),b.start(),_(),Ut&&Zo(t,x).catch(Pe=>j.warn("post-pair-switch auto-revive error (ignored)",{err:String(Pe)}));let Xn;return G.agent_id&&(Xn=await Sb(G.agent_id,t,x,Pe=>f.sendRequest("_agent/detail",Pe),W).catch(Pe=>(j.error("--agent-id ensureAgent failed",{agentId:G.agent_id,err:String(Pe)}),{ok:!1,agentId:G.agent_id??"",note:String(Pe)}))),{ok:!0,note:"paired with cloud",...Xn?{agent:Xn}:{}}}catch(Te){return j.error("_agent/pair failed",{err:String(Te)}),{ok:!1,note:`pair failed: ${String(Te)}`}}}},{method:"POST",path:"/connect",handler:O=>P(O)},{method:"POST",path:"/_agent/create",handler:async O=>{let G=O;return{ok:!0,result:await x.createAgent(G)}}},{method:"POST",path:"/agent/send",handler:async O=>{let G=O;if(!G?.agentId||!G?.sessionId||!G?.kind||!G?.path)throw new C("IPC_BAD_REQUEST","/agent/send requires agentId, sessionId, kind, path");if(!p)throw new C("UPSTREAM_NOT_READY","daemon not yet paired with cloud (run --pair-code first)");try{let W=G;return await(W.groupFile?gu:pu)(W,{core:f,patToken:p,handshakeBase:y,ppeOverride:T})}catch(W){if(W instanceof C)return{ok:!1,code:W.code,message:W.message};throw W}}},{method:"POST",path:"/reload",handler:async O=>{let G=O?.agent_id,W=await f.reloadAgents(G);return j.info("IPC /reload: recycled agent subprocesses",{agentId:G??"(all)",recycled:W}),{ok:!0,recycled:W}}},{method:"POST",path:"/shutdown",handler:async()=>(j.info("IPC /shutdown received"),setImmediate(()=>{ze.shutdown("ipc /shutdown")}),{ok:!0})}]}),{port:ee,token:X}=await $.start();try{await nh(t.libEntry,t)}catch(O){j.warn("bin shim install failed (D72 send \u547D\u4EE4\u53EF\u80FD\u4E0D\u53EF\u7528)",{err:String(O)})}await f.start(),Zo(t,x).catch(O=>j.warn("auto-revive top-level error (ignored)",{err:String(O)})),x0().then(async()=>{let{probeAcpVersion:O}=await Promise.resolve().then(()=>(sn(),f0));for(let G of["claude-code","codex"]){let W=await O(G);W&&j.info("acp wrapper version",{framework:G,version:W})}}).catch(O=>j.warn("acp wrapper warmup / probe top-level error (ignored)",{err:String(O)}));let Ae=null,ze={port:ee,token:X,core:f,ipc:$,shutdown(O){return Ae||(j.info("daemon shutdown",{reason:O}),Ae=(async()=>{b?.stop(),S?.stop(),await f.stop(O),await $.stop(),await e.release()})(),Ae)}};for(let O of["SIGTERM","SIGINT"])process.on(O,()=>{ze.shutdown(O).then(()=>process.exit(0))});return process.on("unhandledRejection",O=>{j.error("unhandledRejection",{reason:O instanceof Error?O.message:String(O),stack:O instanceof Error?O.stack:void 0})}),process.on("uncaughtException",O=>{j.error("uncaughtException (will exit, supervisor will restart)",{message:O.message,stack:O.stack,name:O.name});try{process.stderr.write(`FATAL uncaughtException: ${O.stack??O.message}
|
|
106
|
+
`)}catch{}process.exit(1)}),j.info("daemon ready",{port:ee,pid:process.pid,nodeVersion:process.version,platform:process.platform,frameworks:Object.keys(o.frameworksCache??{}),libVersion:o.libVersion??"dev"}),Ib({cliSpawned:process.env[Xi]==="1",readPatToken:()=>Go(t),connect:P}).catch(O=>j.warn("maybeAutoConnectOnStartup error (ignored)",{err:String(O)})),ze}async function bb(t){return as(t).length>0}function Vo(t){return t.length<=8?"***":`${t.slice(0,4)}***${t.slice(-4)}`}function ch(t,e,n){return`${t??""}|${e??""}|${n??""}`}async function vb(t,e){let n=as(t);if(n.length===0)return;let{loadAgentConfig:i,enforceAgentConfigMode:o}=await Promise.resolve().then(()=>(on(),ls));for(let c of n){await o(c,t).catch(l=>j.warn("enforceAgentConfigMode failed (ignored)",{agentId:c,err:String(l)}));try{let l=await i(c,t);l?.disconnectedAt&&(e.disconnectedAgents.add(c),j.info("agent marked disconnected on startup",{agentId:c,disconnectedAt:l.disconnectedAt,reason:l.disconnectReason??""}))}catch(l){j.warn("failed to load agent config on startup, skipping",{agentId:c,err:String(l)})}}}async function Sb(t,e,n,i,o){let{loadAgentConfig:c}=await Promise.resolve().then(()=>(on(),ls)),l=await c(t,e);if(l){j.info("--agent-id: local config found, reconnecting",{agentId:t,framework:l.framework,hadDisconnect:!!l.disconnectedAt});let w={agentId:l.agentId,framework:l.framework,...l.cozeIdentity?{cozeIdentity:l.cozeIdentity}:{},...l.model?{model:l.model}:{},...o?{patToken:o}:{}};return await n.createAgent(w),{ok:!0,agentId:t,note:l.disconnectedAt?"revived from local config":"connected from local config"}}j.info("--agent-id: local config missing, pulling _agent/detail from cloud",{agentId:t});let f=await i({_meta:{cozeAgentId:t}});if(!f.framework)throw new C("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:f.agentId,framework:f.framework,...f.cozeIdentity?{cozeIdentity:f.cozeIdentity}:{},...f.model?{model:f.model}:{},...o?{patToken:o}:{},...f.deployType?{_meta:{cozeDeployType:f.deployType}}:{}};await n.createAgent(x);let p=f.deployType==="cloud"&&f.framework==="openclaw";return{ok:!0,agentId:t,note:p?"cloud agent acknowledged":"created from cloud detail"}}async function Zo(t,e){let{readdir:n}=await import("node:fs/promises"),i;try{i=await n(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(()=>(on(),ls));j.info("auto-revive: scanning local agents on startup",{count:i.length});let c=0,l=0;for(let f of i){let x;try{x=await o(f,t)}catch(p){j.warn("auto-revive: load config failed (skipping)",{agentId:f,err:String(p)}),l+=1;continue}if(!x){l+=1;continue}if(x.disconnectedAt){j.info("auto-revive: skip disconnected agent",{agentId:f,disconnectedAt:x.disconnectedAt}),l+=1;continue}try{j.info("auto-revive: re-registering agent (D44 no spawn)",{agentId:f,framework:x.framework});let p=Ab(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:f,framework:x.framework,err:String(p)}),l+=1}}return j.info("auto-revive: done",{revived:c,skipped:l,total:i.length}),{revived:c,skipped:l,total:i.length}}async function Ib(t){let e=t.logger??j;if(t.cliSpawned)return"skipped-cli";let n=await t.readPatToken();return n?(e.info("supervisor-spawned daemon, auto-connecting with stored PAT"),t.connect({privatecode:n}).catch(i=>e.warn("startup auto-connect failed (staying idle)",{err:String(i)})),"connecting"):(e.info("no stored PAT, skip startup auto-connect"),"skipped-no-pat")}function Ab(t){let e={};return t.deployType&&(e.cozeDeployType=t.deployType),t.accountId&&(e.cozeAccountId=t.accountId),Object.keys(e).length>0?e:void 0}$o();Oe();import{readFile as lh}from"node:fs/promises";var Qt=class{paths;constructor(e){this.paths=e??Q()}async probe(e=1e3){let n=await Xo(this.paths);if(!n)return{kind:"not-running"};try{let i=await this.fetch(n,{method:"GET",path:"/status",timeoutMs:e});return i.status===200?{kind:"connected",...n}:{kind:"stale",reason:`unexpected status ${i.status}`}}catch(i){return{kind:"stale",reason:Cb(i)}}}async request(e){let n=await Xo(this.paths);if(!n)throw new Error("coze-bridge daemon not running (no port/token files)");return this.fetch(n,e)}async fetch(e,n){let i=n.body!==void 0,o={Authorization:`Bearer ${e.token}`};i&&(o["content-type"]="application/json");let c=new AbortController,l=setTimeout(()=>c.abort(),n.timeoutMs??5e3);try{let f=await fetch(`http://127.0.0.1:${e.port}${n.path}`,{method:n.method,headers:o,body:i?JSON.stringify(n.body):void 0,signal:c.signal}),x=await f.text();return{status:f.status,body:Tb(x)}}finally{clearTimeout(l)}}};async function Xo(t){try{let[e,n]=await Promise.all([lh(t.portFile,"utf8"),lh(t.tokenFile,"utf8")]),i=Number.parseInt(e.trim(),10),o=n.trim();return!Number.isFinite(i)||i<=0||!o?null:{port:i,token:o}}catch(e){if(e.code==="ENOENT")return null;throw e}}function Tb(t){if(!t)return null;try{return JSON.parse(t)}catch{return t}}function Cb(t){return t instanceof Error?t.message:String(t)}bn();re();Oe();function Tn(t,...e){let n=[],i;for(let o=0;o<t.length;o++){let c=t[o],l=!1;for(let f of e){if(c===f){i=t[o+1],o+=1,l=!0;break}if(c.startsWith(`${f}=`)){i=c.slice(f.length+1),l=!0;break}}l||n.push(c)}return{value:i,rest:n}}sn();import{chmod as Db,copyFile as fh,mkdir as xh,readFile as Yo,rename as uh,rm as Cd,stat as hh,writeFile as Rb}from"node:fs/promises";import{homedir as rD}from"node:os";import{dirname as kb,join as Ur,resolve as Dd,sep as Yi}from"node:path";import{fileURLToPath as Lb}from"node:url";bn();re();Oe();var Rd=H("dist-install");function Pb(t){let e=Lb(t),n=kb(e),i=`${Yi}src${Yi}`;if(n.includes(i)||n.endsWith(`${Yi}src${Yi}cli`))return null;let o=Dd(n,"index.js"),c=Dd(n,"..","package.json");return{dist:o,pkgJson:c}}async function Ld(t={}){let e=t.paths??Q(),n=Pb(import.meta.url),i=t.sourceDist??n?.dist,o=t.sourcePackageJson??n?.pkgJson;if(!i||!o)return{kind:"dev-mode-skip",reason:"running from src/(tsx loader);no dist/ to install"};if(i===e.libEntry)return{kind:"dev-mode-skip",reason:"running from installed lib path; no re-install needed"};let c,l;try{let T=JSON.parse(await Yo(o,"utf8"));c=T.version??"unknown",l=T.dependencies??{}}catch(T){return Rd.warn("cannot read source package.json,skip dist install",{err:String(T)}),{kind:"dev-mode-skip",reason:`package.json read failed: ${String(T)}`}}let f=Xr.map(T=>`${T}@${l[T]??"latest"}`),x=await wo(e.configFile)??{},p=x.libVersion,w=await Yo(e.libEntry).then(()=>!0).catch(()=>!1),v=p===c;if(v&&w&&await kd(e))return{kind:"already-current",libVersion:c};if(!v||!w){await xh(e.libDir,{recursive:!0}),await fh(i,e.libEntry),await fh(`${i}.map`,`${e.libEntry}.map`).catch(()=>{});let T=Dd(e.libDir,"package.json"),y=`${JSON.stringify({type:"module"},null,2)}
|
|
107
|
+
`;await Yo(T,"utf8").catch(()=>null)!==y&&await Rb(T,y)}return(!v||!await kd(e))&&await(t.installWrappers??Ob)(e,f),x.libVersion=c,await zi(x,e.configFile),Rd.info("dist installed",{libEntry:e.libEntry,fromVersion:p,toVersion:c}),v&&w?{kind:"already-current",libVersion:c}:p?{kind:"version-changed",fromVersion:p,toVersion:c,libEntry:e.libEntry}:{kind:"first-install",libVersion:c,libEntry:e.libEntry}}async function kd(t){for(let e of Xr){let n=Ur(t.libDir,"node_modules",...e.split("/"),"package.json");if(!await hh(n).then(o=>o.isFile()).catch(()=>!1))return!1}return!0}async function Ob(t,e){await Bb(t.installLock,async()=>{if(await kd(t))return;let n=Math.random().toString(36).slice(2,10),i=`${t.libDir}${Yi}.staging-${process.pid}-${n}`,o=Ur(i,"node_modules"),c=Ur(t.libDir,"node_modules");try{await xh(i,{recursive:!0}),await Nb(e,i),await Mb(o);let l=`${c}.trash-${n}`;await uh(c,l).catch(()=>{}),await uh(o,c),await Cd(l,{recursive:!0,force:!0}).catch(()=>{}),Rd.info("wrapper closure installed",{liveNm:c,specs:e})}finally{await Cd(i,{recursive:!0,force:!0}).catch(()=>{})}})}function Nb(t,e){let n=["install",...t,"--prefix",e,"--omit=dev","--prefer-offline","--no-audit","--no-fund"];return new Promise((i,o)=>{let c=ut("npm",n,{stdio:["ignore","pipe","pipe"]}),l="";c.stderr?.on("data",x=>{l.length<8192&&(l+=x.toString("utf8"))});let f=setTimeout(()=>c.kill("SIGKILL"),18e4);c.once("error",x=>{clearTimeout(f),o(new Error(`spawn npm failed: ${String(x)}`))}),c.once("close",x=>{clearTimeout(f),x===0?i():o(new Error(`npm install \u9000\u51FA\u7801 ${x}: ${l.trim().slice(0,2e3)}`))})})}async function Mb(t){for(let e of Xr){let n=Ur(t,...e.split("/")),i=JSON.parse(await Yo(Ur(n,"package.json"),"utf8"));if(!i.version)throw new Error(`${e}: package.json \u7F3A version`);let o=typeof i.bin=="string"?e.split("/").pop():Object.keys(i.bin??{})[0];if(!o)throw new Error(`${e}: package.json \u7F3A bin`);let c=Ur(t,".bin",o),l=await hh(c);process.platform!=="win32"&&!(l.mode&73)&&await Db(c,l.mode|73).catch(()=>{})}}async function Bb(t,e){let{open:n}=await import("node:fs/promises"),i=!1;for(let o=0;o<60&&!i;o++)try{await(await n(t,"wx")).close(),i=!0}catch{await new Promise(c=>setTimeout(c,500))}try{return await e()}finally{i&&await Cd(t,{force:!0}).catch(()=>{})}}_a();re();Oe();import{closeSync as gh,fstatSync as mh,openSync as wh,readFileSync as zb,readSync as Fb,readdirSync as Ub,statSync as qb}from"node:fs";import{join as Qo}from"node:path";var Hb=new Set(["debug","info","warn","error"]);function _h(t){let e=t,n=Tn(e,"--agent-id");e=n.rest;let i=Tn(e,"--date");e=i.rest;let o=Tn(e,"-n","--lines");e=o.rest;let c=Tn(e,"--level");e=c.rest;let l=Tn(e,"--grep");e=l.rest;let f=o.value===void 0?200:Number(o.value),x=Number.isInteger(f)&&f>=0?f:200,p=c.value&&Hb.has(c.value)?c.value:void 0,w={lines:x,follow:e.includes("-f")||e.includes("--follow"),raw:e.includes("--raw"),list:e.includes("--list")};return n.value&&(w.agentId=n.value),i.value&&(w.date=i.value),p&&(w.level=p),l.value&&(w.grep=l.value),w}function Gb(t,e){return t.agentId?Qo(Qe(t.agentId,e).logs,tr("agent",t.date)):Qo(e.bridgeLogsDir,tr("bridge",t.date))}function jb(t,e){return e<=0||e>=t.length?t:t.slice(t.length-e)}function Wb(t,e){let n;try{n=Ub(t)}catch{return[]}let i=[];for(let o of n){let c=wa(o,e);if(!c)continue;let l=0;try{l=qb(Qo(t,o)).size}catch{}i.push({file:Qo(t,o),date:c,size:l})}return i.sort((o,c)=>c.date.localeCompare(o.date)),i}function yh(t,e){if(e.grep&&!t.includes(e.grep))return!1;if(e.level){let n;try{n=JSON.parse(t).level}catch{return!0}if(typeof n=="string"&&!o0(n,e.level))return!1}return!0}var ph={debug:"90",info:"36",warn:"33",error:"31"},Kb=new Set(["ts","level","module","msg"]);function $b(t){if(typeof t!="string")return"";let e=t.split("T")[1];return e?e.slice(0,12):""}function Eh(t,e){if(e.raw)return t;let n;try{n=JSON.parse(t)}catch{return t}let i=$b(n.ts),o=typeof n.level=="string"?n.level:"",c=o.toUpperCase().padEnd(5);e.color&&ph[o]&&(c=`\x1B[${ph[o]}m${c}\x1B[0m`);let l=typeof n.module=="string"?n.module:"",f=typeof n.msg=="string"?n.msg:"",x=Object.entries(n).filter(([p])=>!Kb.has(p)).map(([p,w])=>` ${p}=${typeof w=="string"?w:JSON.stringify(w)}`).join("");return`${i} ${c} ${l} ${f}${x}`}function Jb(t,e,n){let c=zb(t,"utf8").split(`
|
|
108
|
+
`).filter(l=>l.length>0).filter(l=>yh(l,{level:e.level,grep:e.grep}));for(let l of jb(c,e.lines))process.stdout.write(`${Eh(l,{raw:e.raw,color:n})}
|
|
109
|
+
`)}async function bh(t,e){let n=e.paths??Q(),i=process.stdout.isTTY===!0;if(t.list){let l=t.agentId?Qe(t.agentId,n).logs:n.bridgeLogsDir,f=t.agentId?"agent":"bridge",x=Wb(l,f);if(x.length===0)return process.stderr.write(`coze-bridge log: \u65E0\u65E5\u5FD7\u6587\u4EF6\u4E8E ${l}
|
|
110
110
|
`),1;for(let p of x)process.stdout.write(`${p.date} ${(p.size/1024).toFixed(1)}KB ${p.file}
|
|
111
|
-
`);return 0}let o=t.date??
|
|
111
|
+
`);return 0}let o=t.date??Dn(new Date),c=Gb({agentId:t.agentId,date:o},n);try{Jb(c,t,i)}catch{return process.stderr.write(`coze-bridge log: \u627E\u4E0D\u5230\u65E5\u5FD7 ${c}
|
|
112
112
|
\u7528 'coze-bridge log${t.agentId?` --agent-id ${t.agentId}`:""} --list' \u770B\u6709\u54EA\u4E9B\u65E5\u671F\u3002
|
|
113
|
-
(legacy \u6A21\u5F0F\u65E0 dated \u6587\u4EF6, \u89C1 ${
|
|
114
|
-
`),1}return t.follow&&await
|
|
115
|
-
`);o=x.pop()??"";for(let p of x)p.length>0&&
|
|
116
|
-
`)}await new Promise(x=>setTimeout(x,
|
|
113
|
+
(legacy \u6A21\u5F0F\u65E0 dated \u6587\u4EF6, \u89C1 ${n.logFile})
|
|
114
|
+
`),1}return t.follow&&await Xb(c,t,i),0}var Vb=500;function Zb(t){try{let e=wh(t,"r");try{return mh(e).size}finally{gh(e)}}catch{return 0}}async function Xb(t,e,n){let i=Zb(t),o="",c=!1,l=()=>{c=!0};process.on("SIGINT",l);try{for(;!c;){let f="";try{let x=wh(t,"r");try{let p=mh(x).size;if(p>i){let w=Buffer.allocUnsafe(p-i),v=Fb(x,w,0,w.length,i);f=w.subarray(0,v).toString("utf8"),i+=v}}finally{gh(x)}}catch{}if(f){let x=(o+f).split(`
|
|
115
|
+
`);o=x.pop()??"";for(let p of x)p.length>0&&yh(p,{level:e.level,grep:e.grep})&&process.stdout.write(`${Eh(p,{raw:e.raw,color:n})}
|
|
116
|
+
`)}await new Promise(x=>setTimeout(x,Vb))}}finally{process.off("SIGINT",l)}}import{basename as Yb,resolve as Qb}from"node:path";Oe();var ev=9e4,tv={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,AGENT_TURN_ABORTED:1,BRIDGE_CONFIG_INVALID:1,BRIDGE_INTERNAL:1,MODEL_TOKEN_GEN_FAILED:1,OPERATION_NOT_ALLOWED_FOR_LOCAL:1,AGENT_DEPENDENCY_INSTALL_FAILED:1,AGENT_APPROVAL_TIMEOUT:1};function nv(t){return tv[t]??1}async function vh(t,e={}){let n=e.paths??Q();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>
|
|
117
117
|
`),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.
|
|
118
|
-
`),3;let i=await
|
|
119
|
-
`),4;let o={agentId:t.agentId,sessionId:t.sessionId,kind:t.kind,path:t.groupFile?t.path:
|
|
118
|
+
`),3;let i=await Xo(n).catch(()=>null);if(!i)return process.stderr.write(`Error: coze-bridge daemon not running (cannot read ${n.portFile} / ${n.tokenFile}). Make sure you are inside an agent session spawned by the daemon.
|
|
119
|
+
`),4;let o={agentId:t.agentId,sessionId:t.sessionId,kind:t.kind,path:t.groupFile?t.path:Qb(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 rv(i,"/agent/send",o,ev)}catch(l){return process.stderr.write(`Error: daemon IPC failed: ${l instanceof Error?l.message:String(l)}
|
|
120
120
|
`),4}if(!c.ok)return process.stderr.write(`Error: ${c.code}: ${c.message}
|
|
121
|
-
`),
|
|
122
|
-
`);else{let l=t.name??
|
|
123
|
-
`)}else process.stdout.write(`Sent ${t.kind} ${l} (${
|
|
124
|
-
`)}return 0}async function
|
|
125
|
-
`)}function
|
|
121
|
+
`),nv(c.code);if(t.json)process.stdout.write(`${JSON.stringify(c)}
|
|
122
|
+
`);else{let l=t.name??Yb(o.path);if(t.groupFile){let f=c.uri.length>60?`${c.uri.slice(0,57)}...`:c.uri;process.stdout.write(`Sent group file ${l} (uri=${f})
|
|
123
|
+
`)}else process.stdout.write(`Sent ${t.kind} ${l} (${iv(c.bytes)})
|
|
124
|
+
`)}return 0}async function rv(t,e,n,i){let o=new AbortController,c=setTimeout(()=>o.abort(),i);try{let l=await fetch(`http://127.0.0.1:${t.port}${e}`,{method:"POST",headers:{Authorization:`Bearer ${t.token}`,"content-type":"application/json"},body:JSON.stringify(n),signal:o.signal}),f=await l.text(),x=f?JSON.parse(f):null;return x&&typeof x=="object"&&"ok"in x?x:{ok:!1,code:"BRIDGE_INTERNAL",message:`unexpected daemon response (status=${l.status}): ${f.slice(0,200)}`}}finally{clearTimeout(c)}}function iv(t){return t<1024?`${t}B`:t<1024*1024?`${(t/1024).toFixed(1)}KB`:`${(t/1024/1024).toFixed(1)}MB`}var Lh=H("cli");function je(t,e){let{value:n,rest:i}=Tn(t,e);return{value:n,rest:i}}function sa(t,e){process.stderr.write(`[deprecated] '${t}' will be removed in a future release, use '${e}' instead
|
|
125
|
+
`)}function Cv(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]==="reload"){let{value:R}=je(e.slice(1),"--agent-id");return R?{mode:"reload",agentId:R}:{mode:"reload"}}if(e[0]==="update")return{mode:"update"};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 Dv(e.slice(1));if(e[0]==="log")return{mode:"log",..._h(e.slice(1))};if(e[0]==="connect")return Rv(e.slice(1));if(e.includes("--status"))return sa("--status","coze-bridge status"),{mode:"status"};if(e.includes("--stop"))return sa("--stop","coze-bridge stop"),{mode:"stop"};if(e.includes("--uninstall"))return sa("--uninstall","coze-bridge purge"),{mode:"purge"};if(e.includes("--install-service"))return sa("--install-service","coze-bridge service install"),{mode:"service-install"};if(e.includes("--help")||e.includes("-h")||e.length===0)return{mode:"help"};let n=e,{value:i,rest:o}=je(n,"--pat-token");n=o;let{value:c,rest:l}=je(n,"--pair-code");n=l;let{value:f,rest:x}=je(n,"--env");n=x;let{value:p,rest:w}=je(n,"--handshake-url");n=w;let{value:v,rest:T}=je(n,"--frontier-url");n=T;let{value:y,rest:b}=je(n,"--mock-scenario");n=b;let{value:S}=je(n,"--agent-id");if(!i||!c)return{mode:"help"};let A={mode:"pair",privatecode:i,pairingCode:c};return f&&(A.env=f),p&&(A.handshakeUrl=p),v&&(A.frontierUrl=v),y&&(A.mockScenario=y),S&&(A.agentId=S),A}function Dv(t){let e=t[0],n=t[1];if(e!=="image"&&e!=="file")return{mode:"help"};if(!n||n.startsWith("--"))return{mode:"help"};let i=t.slice(2),{value:o,rest:c}=je(i,"--caption");i=c;let{value:l,rest:f}=je(i,"--name");i=f;let{value:x,rest:p}=je(i,"--agent-id");i=p;let{value:w,rest:v}=je(i,"--session-id");i=v;let{value:T,rest:y}=je(i,"--mime");i=y;let b=i.includes("--group-file");i=i.filter(R=>R!=="--group-file");let S=i.includes("--json"),A={mode:"send",kind:e,path:n,json:S};return o&&(A.caption=o),l&&(A.name=l),x&&(A.agentId=x),w&&(A.sessionId=w),b&&(A.groupFile=!0),T&&(A.mimeType=T),A}function Rv(t){let e=t,{value:n,rest:i}=je(e,"--pat-token");e=i;let{value:o,rest:c}=je(e,"--env");e=c;let{value:l,rest:f}=je(e,"--handshake-url");e=f;let{value:x,rest:p}=je(e,"--frontier-url");e=p;let{value:w,rest:v}=je(e,"--mock-scenario");e=v;let T={mode:"connect"};return n&&(T.privatecode=n),o&&(T.env=o),l&&(T.handshakeUrl=l),x&&(T.frontierUrl=x),w&&(T.mockScenario=w),T}var kv=`
|
|
126
126
|
coze-bridge - local bridge daemon for cloud Agent Service
|
|
127
127
|
|
|
128
128
|
Pair (paste from cloud UI; start/reuse daemon and deliver pair-code):
|
|
@@ -201,50 +201,50 @@ Deprecated flags (still work, but emit a warning; will be removed in a future re
|
|
|
201
201
|
|
|
202
202
|
Internal:
|
|
203
203
|
<node> <entry> --daemon daemon mode (OS supervisor only)
|
|
204
|
-
`.trimStart();async function
|
|
205
|
-
`),0;case"daemon":{try{await
|
|
206
|
-
`),1;if(i.kind==="stale")return await
|
|
207
|
-
`),1;let o=await
|
|
204
|
+
`.trimStart();async function Ph(t=process.argv,e={}){let n=Cv(t);switch(n.mode){case"help":return process.stdout.write(kv),0;case"version":return process.stdout.write(`${Ar}
|
|
205
|
+
`),0;case"daemon":{try{await dh()}catch(i){return Lh.error("daemon start failed",{err:String(i)}),1}return new Promise(()=>{})}case"status":return Lv(e);case"stop":return Nh(e);case"reload":return Nv(n.agentId,e);case"log":return bh(n,e);case"update":return Pv(e);case"purge":return Mv(e);case"service-install":return Bv(e);case"service-uninstall":return zv(e);case"pair":{let i={};return n.env&&(i.env=n.env),n.handshakeUrl&&(i.handshakeUrl=n.handshakeUrl),n.frontierUrl&&(i.frontierUrl=n.frontierUrl),n.mockScenario&&(i.mockScenario=n.mockScenario),Fv(n.privatecode,n.pairingCode,e,i,n.agentId)}case"connect":{let i={};return n.env&&(i.env=n.env),n.handshakeUrl&&(i.handshakeUrl=n.handshakeUrl),n.frontierUrl&&(i.frontierUrl=n.frontierUrl),n.mockScenario&&(i.mockScenario=n.mockScenario),Uv(n.privatecode,e,i)}case"send":return vh({kind:n.kind,path:n.path,...n.agentId?{agentId:n.agentId}:{},...n.sessionId?{sessionId:n.sessionId}:{},...n.caption?{caption:n.caption}:{},...n.name?{name:n.name}:{},...n.groupFile?{groupFile:!0}:{},...n.mimeType?{mimeType:n.mimeType}:{},json:n.json},e)}}async function Oh(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 Lv(t){let e=t.paths??Q(),n=new Qt(e),i=await n.probe();if(i.kind==="not-running")return process.stdout.write(`coze-bridge: not running
|
|
206
|
+
`),1;if(i.kind==="stale")return await Oh(e),process.stdout.write(`coze-bridge: not running (cleaned stale state)
|
|
207
|
+
`),1;let o=await n.request({method:"GET",path:"/status"});return process.stdout.write(`coze-bridge: running
|
|
208
208
|
${JSON.stringify(o.body,null,2)}
|
|
209
|
-
`),0}async function
|
|
210
|
-
`)}let c=await
|
|
209
|
+
`),0}async function Nh(t){let e=t.paths??Q(),n=new Qt(e),i=await es(t),o=!1;if(i)try{await i.uninstall(),o=!0}catch(l){process.stderr.write(`coze-bridge: supervisor uninstall failed (continuing): ${String(l)}
|
|
210
|
+
`)}let c=await n.probe();if(c.kind==="not-running")return process.stdout.write(o?`coze-bridge: stopped
|
|
211
211
|
`:`coze-bridge: not running
|
|
212
|
-
`),0;if(c.kind==="stale")return await
|
|
213
|
-
`),0;try{return await
|
|
214
|
-
`),0}catch(l){return(await
|
|
212
|
+
`),0;if(c.kind==="stale")return await Oh(e),process.stdout.write(`coze-bridge: not running (cleaned stale state)
|
|
213
|
+
`),0;try{return await n.request({method:"POST",path:"/shutdown"}),process.stdout.write(`coze-bridge: stopped
|
|
214
|
+
`),0}catch(l){return(await n.probe()).kind!=="connected"?(process.stdout.write(`coze-bridge: stopped
|
|
215
215
|
`),0):(process.stdout.write(`coze-bridge: stop failed: ${String(l)}
|
|
216
|
-
`),1)}}async function
|
|
217
|
-
`),e(1)})})}async function
|
|
218
|
-
`),1;try{let o=await
|
|
216
|
+
`),1)}}async function Pv(t){return await Nh(t),(t.spawnNpx??Ov)(["-y","--ignore-existing","coze-bridge@latest","connect"])}function Ov(t){return new Promise(e=>{let n=ut("npx",t,{stdio:"inherit"});n.on("exit",i=>e(i??1)),n.on("error",i=>{process.stderr.write(`coze-bridge: spawn npx failed: ${String(i)}
|
|
217
|
+
`),e(1)})})}async function Nv(t,e){let n=new Qt(e.paths);if((await n.probe()).kind==="not-running")return process.stdout.write(`coze-bridge: not running (start daemon first)
|
|
218
|
+
`),1;try{let o=await n.request({method:"POST",path:"/reload",body:t?{agent_id:t}:{},timeoutMs:35e3});if(o.status===200&&o.body?.ok){let c=o.body.recycled??[];return t&&c.length===0?process.stdout.write(`coze-bridge: agent ${t} \u65E0\u8FD0\u884C\u4E2D\u5B50\u8FDB\u7A0B\u53EF\u56DE\u6536 (\u672A\u6CE8\u518C / \u5DF2 idle)
|
|
219
219
|
`):process.stdout.write(`coze-bridge: reloaded ${c.length} agent(s): ${c.join(", ")||"(none)"}
|
|
220
220
|
`),0}return process.stderr.write(`coze-bridge: reload failed: ${JSON.stringify(o.body)}
|
|
221
221
|
`),1}catch(o){return process.stderr.write(`coze-bridge: reload failed: ${String(o)}
|
|
222
|
-
`),1}}async function
|
|
222
|
+
`),1}}async function es(t){if(t.supervisor){let c=t.supervisor,l={nodeBin:"",entry:"",logFile:"",homeDir:"",userName:""};return{platform:c.platform,install:f=>c.install(l,f),uninstall:()=>c.uninstall(l)}}if(t.skipSupervisor)return;let{getSupervisor:e,buildContext:n}=await Promise.resolve().then(()=>(Rh(),Dh)),i=e(),o=n();return{platform:i.platform,install:c=>i.install(o,c),uninstall:()=>i.uninstall(o)}}async function Mh(t,e){let n=await e.probe();if(n.kind==="connected")return n;let i=t.spawnDaemon??ah,o=t.waitTimeoutMs??15e3,c=t.sleep??Hv,l=t.paths??Q(),f=await es(t);if(f&&(f.platform==="darwin"||f.platform==="linux")){try{await f.install({activate:!0});let x=await kh(e,o,c);if(x.kind==="connected")return x;Vr(l.bridgeLogsDir,"warn","cli","supervisor \u8D77 daemon \u8D85\u65F6, \u56DE\u9000\u624B\u52A8 spawn (\u672C\u6B21\u65E0\u5D29\u6E83\u4FDD\u6D3B)",{waitMs:o})}catch(x){Vr(l.bridgeLogsDir,"warn","cli","supervisor \u63A5\u7BA1\u5931\u8D25, \u56DE\u9000\u624B\u52A8 spawn",{err:String(x)})}await f.uninstall().catch(()=>{}),await qv(l.pidFile,c)}else f&&await f.install({activate:!1}).catch(x=>process.stderr.write(`coze-bridge: \u81EA\u542F\u6CE8\u518C\u5931\u8D25(\u4E0D\u5F71\u54CD\u672C\u6B21): ${String(x)}
|
|
223
223
|
`));return process.stdout.write(`coze-bridge: starting daemon...
|
|
224
|
-
`),await i({paths:t.paths}),
|
|
224
|
+
`),await i({paths:t.paths}),kh(e,o,c)}async function Mv(t){let e=new Qt(t.paths);if((await e.probe()).kind==="connected"){process.stdout.write(`coze-bridge: stopping daemon...
|
|
225
225
|
`);try{await e.request({method:"POST",path:"/shutdown"})}catch(l){process.stderr.write(`coze-bridge: stop failed (continuing): ${String(l)}
|
|
226
|
-
`)}await new Promise(l=>setTimeout(l,500))}let i=await
|
|
226
|
+
`)}await new Promise(l=>setTimeout(l,500))}let i=await es(t);if(i)try{await i.uninstall(),process.stdout.write(`coze-bridge: ${i.platform} supervisor unregistered
|
|
227
227
|
`)}catch(l){process.stderr.write(`coze-bridge: supervisor uninstall failed (continuing): ${String(l)}
|
|
228
228
|
`)}let o=t.paths??Q(),{rm:c}=await import("node:fs/promises");try{await c(o.bridgeRoot,{recursive:!0,force:!0}),process.stdout.write(`coze-bridge: removed ${o.bridgeRoot}
|
|
229
229
|
`)}catch(l){return process.stderr.write(`coze-bridge: remove failed: ${String(l)}
|
|
230
230
|
`),1}return process.stdout.write(`coze-bridge: purged (agents workspaces preserved under ~/.coze/agents)
|
|
231
|
-
`),0}async function
|
|
231
|
+
`),0}async function Bv(t){let e=await es(t);if(!e)return 0;try{return process.stdout.write(`coze-bridge: installing ${e.platform} supervisor...
|
|
232
232
|
`),await e.install(),process.stdout.write(`coze-bridge: supervisor installed (daemon will auto-start on login)
|
|
233
|
-
`),0}catch(
|
|
234
|
-
`),1}}async function
|
|
235
|
-
`),0}catch(
|
|
236
|
-
`),1}}async function
|
|
237
|
-
`),(await c.probe()).kind==="connected"&&(await c.request({method:"POST",path:"/shutdown"}).catch(()=>{}),await new Promise(
|
|
238
|
-
`)}let
|
|
239
|
-
`),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
|
|
233
|
+
`),0}catch(n){return process.stderr.write(`coze-bridge: service install failed: ${String(n)}
|
|
234
|
+
`),1}}async function zv(t){let e=await es(t);if(!e)return 0;try{return await e.uninstall(),process.stdout.write(`coze-bridge: ${e.platform} supervisor unregistered
|
|
235
|
+
`),0}catch(n){return process.stderr.write(`coze-bridge: service uninstall failed: ${String(n)}
|
|
236
|
+
`),1}}async function Fv(t,e,n,i={},o){let c=new Qt(n.paths),l=n.paths??Q();if(await $c(l).catch(p=>Vr(l.bridgeLogsDir,"warn","cli","writeAgentEnv failed (ignored)",{err:String(p)})),!n.skipDistInstall){let p=await Ld({paths:n.paths});p.kind==="version-changed"?(process.stdout.write(`coze-bridge: upgraded ${p.fromVersion} \u2192 ${p.toVersion}
|
|
237
|
+
`),(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}
|
|
238
|
+
`)}let f=await Mh(n,c);if(f.kind!=="connected")return process.stderr.write(`coze-bridge: daemon did not come up: ${f.kind}
|
|
239
|
+
`),1;let x={privatecode:t,pairing_code:e};i.env&&(x.env=i.env),i.handshakeUrl&&(x.handshake_url=i.handshakeUrl),i.frontierUrl&&(x.frontier_url=i.frontierUrl),i.mockScenario&&(x.mock_scenario=i.mockScenario),o&&(x.agent_id=o);try{let p=await c.request({method:"POST",path:"/pair",body:x,timeoutMs:35e3});if(p.status===200&&p.body?.ok){let w=p.body.agent;return w&&!w.ok?(process.stderr.write(`coze-bridge: paired but agent ensure failed (agentId=${w.agentId}): ${w.note}
|
|
240
240
|
`),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"
|
|
241
241
|
`),0)}return process.stderr.write(`coze-bridge: pair failed: ${JSON.stringify(p.body)}
|
|
242
242
|
`),1}catch(p){return process.stderr.write(`coze-bridge: pair failed: ${String(p)}
|
|
243
|
-
`),1}}async function
|
|
244
|
-
`),(await c.probe()).kind==="connected"&&(await c.request({method:"POST",path:"/shutdown"}).catch(()=>{}),await new Promise(
|
|
245
|
-
`)}let l=await
|
|
246
|
-
`),1;let
|
|
247
|
-
`),await
|
|
243
|
+
`),1}}async function Uv(t,e,n={}){let i=e.paths??Q(),o=t??await Go(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 Qt(e.paths);if(await $c(i).catch(x=>Vr(i.bridgeLogsDir,"warn","cli","writeAgentEnv failed (ignored)",{err:String(x)})),!e.skipDistInstall){let x=await Ld({paths:e.paths});x.kind==="version-changed"?(process.stdout.write(`coze-bridge: upgraded ${x.fromVersion} \u2192 ${x.toVersion}
|
|
244
|
+
`),(await c.probe()).kind==="connected"&&(await c.request({method:"POST",path:"/shutdown"}).catch(()=>{}),await new Promise(w=>setTimeout(w,500)))):x.kind==="first-install"&&process.stdout.write(`coze-bridge: installed ${x.libVersion}
|
|
245
|
+
`)}let l=await Mh(e,c);if(l.kind!=="connected")return process.stderr.write(`coze-bridge: daemon did not come up: ${l.kind}
|
|
246
|
+
`),1;let f={privatecode:o};n.env&&(f.env=n.env),n.handshakeUrl&&(f.handshake_url=n.handshakeUrl),n.frontierUrl&&(f.frontier_url=n.frontierUrl),n.mockScenario&&(f.mock_scenario=n.mockScenario);try{let x=await c.request({method:"POST",path:"/connect",body:f,timeoutMs:35e3});return x.status===200&&x.body?.ok?(process.stdout.write(`coze-bridge: connected (${x.body.note??"ok"})
|
|
247
|
+
`),await Zi(o,i).catch(p=>Lh.warn("writePatToken after connect failed (ignored)",{err:String(p)})),0):(process.stderr.write(`coze-bridge: connect failed: ${JSON.stringify(x.body)}
|
|
248
248
|
`),1)}catch(x){return process.stderr.write(`coze-bridge: connect failed: ${String(x)}
|
|
249
|
-
`),1}}async function
|
|
249
|
+
`),1}}async function kh(t,e,n){let i=Date.now()+e;for(;Date.now()<i;){let o=await t.probe(500);if(o.kind==="connected")return o;await n(200)}return t.probe(500)}async function qv(t,e,n=60,i=200){let{readFile:o}=await import("node:fs/promises");for(let c=0;c<n;c++){let l;try{l=await o(t,"utf8")}catch{return}let f=Number.parseInt(l.trim(),10);if(!Number.isFinite(f)||f<=0||!Wo(f))return;await e(i)}}function Hv(t){return new Promise(e=>setTimeout(e,t))}re();!process.argv.includes("--daemon")&&!process.env.COZE_BRIDGE_LOG_LEVEL&&i0("warn");Ph(process.argv).then(t=>process.exit(t),t=>{process.stderr.write(`fatal: ${t instanceof Error?t.stack??t.message:String(t)}
|
|
250
250
|
`),process.exit(1)});
|