coze-bridge 0.1.80 → 0.1.82
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 +62 -96
- package/package.json +1 -1
package/dist/index.js
CHANGED
|
@@ -5,26 +5,26 @@ import { dirname as __coze_dirname } from 'node:path';
|
|
|
5
5
|
const require = __coze_createRequire(import.meta.url);
|
|
6
6
|
const __filename = __coze_fileURLToPath(import.meta.url);
|
|
7
7
|
const __dirname = __coze_dirname(__filename);
|
|
8
|
-
var
|
|
9
|
-
`):
|
|
10
|
-
`)}function
|
|
11
|
-
${t.stack??""}`:String(t);return
|
|
12
|
-
`,a=`${t}.tmp-${process.pid}-${Math.random().toString(36).slice(2,10)}`;try{r?.mode!==void 0?await K0(a,s,{encoding:"utf8",mode:r.mode}):await K0(a,s,"utf8"),await W0(a,t),r?.mode!==void 0&&await Ep(t,r.mode)}catch(c){await W0(a,a).catch(()=>{});let{rm:d}=await import("node:fs/promises");throw await d(a,{force:!0}).catch(()=>{}),c}}var Gi=dt(()=>{"use strict"});import{promises as $0}from"node:fs";import{homedir as Cp}from"node:os";import{sep as Ap,join as Ue,resolve as V0}from"node:path";function se(t){let e=t??Cp(),r=Ue(e,".coze"),s=Ue(r,"bridge"),a=Ue(s,"lib");return{cozeRoot:r,bridgeRoot:s,libDir:a,libEntry:Ue(a,"index.js"),binDir:Ue(s,"bin"),pidFile:Ue(s,"bridge.pid"),portFile:Ue(s,"bridge.port"),tokenFile:Ue(s,"bridge.token"),patTokenFile:Ue(s,"pat-token"),logFile:Ue(s,"bridge.log"),installLock:Ue(s,"install.lock"),configFile:Ue(s,"config.json"),agentsRoot:Ue(r,"agents")}}function Lt(t,e=se()){let r=Ue(e.agentsRoot,t);return{root:r,config:Ue(r,"config.json"),workspace:Ue(r,"workspace"),logs:Ue(r,"logs")}}async function zr(t,e){let r=await $0.realpath(V0(t)).catch(()=>null);if(!r)return!1;let s=await $0.realpath(V0(e)).catch(()=>null);if(!s)return!1;let a=process.platform==="win32"?r.toLowerCase():r,c=process.platform==="win32"?s.toLowerCase():s;return a===c||a.startsWith(c+Ap)}var qe=dt(()=>{"use strict"});var $i={};Vo($i,{AGENT_CONFIG_FILE_MODE:()=>Wi,enforceAgentConfigMode:()=>Rp,loadAgentConfig:()=>We,persistAgentSessions:()=>Qo,persistAgentSkills:()=>Ki,saveAgentConfig:()=>Ze});import{chmod as Tp,stat as Dp}from"node:fs/promises";function We(t,e){return Zn(Lt(t,e).config)}function Ze(t,e){return ji(Lt(t.agentId,e).config,t,{mode:Wi})}async function Rp(t,e){if(process.platform==="win32")return;let r=Lt(t,e).config;try{let s=await Dp(r);if(!s.isFile())return;let a=s.mode&511;a!==Wi&&(await Tp(r,Wi),J0.warn("agent config mode auto-corrected to 0600",{path:r,from:a.toString(8)}))}catch(s){if(s.code==="ENOENT")return;J0.warn("enforceAgentConfigMode: chmod failed (ignored)",{path:r,err:String(s)})}}async function Qo(t,e,r){let s=await We(t,r);s&&(s.sessions=Object.fromEntries(e),await Ze(s,r))}async function Ki(t,e,r){let s=await We(t,r);s&&(s.skills=e,await Ze(s,r))}var J0,Wi,Yt=dt(()=>{"use strict";Gi();ie();qe();J0=$("agent-config"),Wi=384});var ta=oe((Xv,Q0)=>{Q0.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 Ji=oe(tf=>{var ef={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 zp(t){return function(...e){return e.length&&(t=t.replace(/\{(\d)\}/g,(r,s)=>e[s]||"")),new Error("ADM-ZIP: "+t)}}for(let t of Object.keys(ef))tf[t]=zp(ef[t])});var af=oe((Qv,of)=>{var Fp=ue("fs"),Te=ue("path"),nf=ta(),Up=Ji(),qp=typeof process=="object"&&process.platform==="win32",rf=t=>typeof t=="object"&&t!==null,sf=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=Te.sep,this.fs=Fp,rf(t)&&rf(t.fs)&&typeof t.fs.statSync=="function"&&(this.fs=t.fs)}of.exports=ye;ye.prototype.makeDir=function(t){let e=this;function r(s){let a=s.split(e.sep)[0];s.split(e.sep).forEach(function(c){if(!(!c||c.substr(-1,1)===":")){a+=e.sep+c;var d;try{d=e.fs.statSync(a)}catch(u){if(u.message&&u.message.startsWith("ENOENT"))e.fs.mkdirSync(a);else throw u}if(d&&d.isFile())throw Up.FILE_IN_THE_WAY(`"${a}"`)}})}r(t)};ye.prototype.writeFileTo=function(t,e,r,s){let a=this;if(a.fs.existsSync(t)){if(!r)return!1;var c=a.fs.statSync(t);if(c.isDirectory())return!1}var d=Te.dirname(t);a.fs.existsSync(d)||a.makeDir(d);var u;try{u=a.fs.openSync(t,"w",438)}catch{a.fs.chmodSync(t,438),u=a.fs.openSync(t,"w",438)}if(u)try{a.fs.writeSync(u,e,0,e.length,0)}finally{a.fs.closeSync(u)}return a.fs.chmodSync(t,s||438),!0};ye.prototype.writeFileToAsync=function(t,e,r,s,a){typeof s=="function"&&(a=s,s=void 0);let c=this;c.fs.exists(t,function(d){if(d&&!r)return a(!1);c.fs.stat(t,function(u,x){if(d&&x.isDirectory())return a(!1);var p=Te.dirname(t);c.fs.exists(p,function(_){_||c.makeDir(p),c.fs.open(t,"w",438,function(w,S){w?c.fs.chmod(t,438,function(){c.fs.open(t,"w",438,function(b,E){c.fs.write(E,e,0,e.length,0,function(){c.fs.close(E,function(){c.fs.chmod(t,s||438,function(){a(!0)})})})})}):S?c.fs.write(S,e,0,e.length,0,function(){c.fs.close(S,function(){c.fs.chmod(t,s||438,function(){a(!0)})})}):c.fs.chmod(t,s||438,function(){a(!0)})})})})})};ye.prototype.findFiles=function(t){let e=this;function r(s,a,c){typeof a=="boolean"&&(c=a,a=void 0);let d=[];return e.fs.readdirSync(s).forEach(function(u){let x=Te.join(s,u),p=e.fs.statSync(x);(!a||a.test(x))&&d.push(Te.normalize(x)+(p.isDirectory()?e.sep:"")),p.isDirectory()&&c&&(d=d.concat(r(x,a,c)))}),d}return r(t,void 0,!0)};ye.prototype.findFilesAsync=function(t,e){let r=this,s=[];r.fs.readdir(t,function(a,c){if(a)return e(a);let d=c.length;if(!d)return e(null,s);c.forEach(function(u){u=Te.join(t,u),r.fs.stat(u,function(x,p){if(x)return e(x);p&&(s.push(Te.normalize(u)+(p.isDirectory()?r.sep:"")),p.isDirectory()?r.findFilesAsync(u,function(_,w){if(_)return e(_);s=s.concat(w),--d||e(null,s)}):--d||e(null,s))})})})};ye.prototype.getAttributes=function(){};ye.prototype.setAttributes=function(){};ye.crc32update=function(t,e){return sf[(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 s=0;s<e;)r=ye.crc32update(r,t[s++]);return~r>>>0};ye.methodToString=function(t){switch(t){case nf.STORED:return"STORED ("+t+")";case nf.DEFLATED:return"DEFLATED ("+t+")";default:return"UNSUPPORTED ("+t+")"}};ye.canonical=function(t){if(!t)return"";let e=Te.posix.normalize("/"+t.split("\\").join("/"));return Te.join(".",e)};ye.zipnamefix=function(t){if(!t)return"";let e=Te.posix.normalize("/"+t.split("\\").join("/"));return Te.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 s=r-1;s>=0;s--)if(e(t[s],s,t))return t[s]};ye.sanitize=function(t,e){t=Te.resolve(Te.normalize(t));for(var r=e.split("/"),s=0,a=r.length;s<a;s++){var c=Te.normalize(Te.join(t,r.slice(s,a).join(Te.sep)));if(c.indexOf(t)===0)return c}return Te.normalize(Te.join(t,Te.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=qp;ye.crcTable=sf});var ff=oe((e2,cf)=>{var Hp=ue("path");cf.exports=function(t,{fs:e}){var r=t||"",s=c(),a=null;function c(){return{directory:!1,readonly:!1,hidden:!1,executable:!1,mtime:0,atime:0}}return r&&e.existsSync(r)?(a=e.statSync(r),s.directory=a.isDirectory(),s.mtime=a.mtime,s.atime=a.atime,s.executable=(73&a.mode)!==0,s.readonly=(128&a.mode)===0,s.hidden=Hp.basename(r)[0]==="."):console.warn("Invalid path: "+r),{get directory(){return s.directory},get readOnly(){return s.readonly},get hidden(){return s.hidden},get mtime(){return s.mtime},get atime(){return s.atime},get executable(){return s.executable},decodeAttributes:function(){},encodeAttributes:function(){},toJSON:function(){return{path:r,isDirectory:s.directory,isReadOnly:s.readonly,isHidden:s.hidden,isExecutable:s.executable,mTime:s.mtime,aTime:s.atime}},toString:function(){return JSON.stringify(this.toJSON(),null," ")}}}});var uf=oe((t2,df)=>{df.exports={efs:!0,encode:t=>Buffer.from(t,"utf8"),decode:t=>t.toString("utf8")}});var Qn=oe((n2,Yn)=>{Yn.exports=af();Yn.exports.Constants=ta();Yn.exports.Errors=Ji();Yn.exports.FileAttr=ff();Yn.exports.decoder=uf()});var xf=oe((r2,lf)=>{var Qt=Qn(),j=Qt.Constants;lf.exports=function(){var t=20,e=10,r=0,s=0,a=0,c=0,d=0,u=0,x=0,p=0,_=0,w=0,S=0,b=0,E=0;t|=Qt.isWin?2560:768,r|=j.FLG_EFS;let v={extraLen:0},C=y=>Math.max(0,y)>>>0,D=y=>Math.max(0,y)&65535,O=y=>Math.max(0,y)&255;return a=Qt.fromDate2DOS(new Date),{get made(){return t},set made(y){t=y},get version(){return e},set version(y){e=y},get flags(){return r},set flags(y){r=y},get flags_efs(){return(r&j.FLG_EFS)>0},set flags_efs(y){y?r|=j.FLG_EFS:r&=~j.FLG_EFS},get flags_desc(){return(r&j.FLG_DESC)>0},set flags_desc(y){y?r|=j.FLG_DESC:r&=~j.FLG_DESC},get method(){return s},set method(y){switch(y){case j.STORED:this.version=10;case j.DEFLATED:default:this.version=20}s=y},get time(){return Qt.fromDOS2Date(this.timeval)},set time(y){y=new Date(y),this.timeval=Qt.fromDate2DOS(y)},get timeval(){return a},set timeval(y){a=C(y)},get timeHighByte(){return O(a>>>8)},get crc(){return c},set crc(y){c=C(y)},get compressedSize(){return d},set compressedSize(y){d=C(y)},get size(){return u},set size(y){u=C(y)},get fileNameLength(){return x},set fileNameLength(y){x=y},get extraLength(){return p},set extraLength(y){p=y},get extraLocalLength(){return v.extraLen},set extraLocalLength(y){v.extraLen=y},get commentLength(){return _},set commentLength(y){_=y},get diskNumStart(){return w},set diskNumStart(y){w=C(y)},get inAttr(){return S},set inAttr(y){S=C(y)},get attr(){return b},set attr(y){b=C(y)},get fileAttr(){return(b||0)>>16&4095},get offset(){return E},set offset(y){E=C(y)},get encrypted(){return(r&j.FLG_ENC)===j.FLG_ENC},get centralHeaderSize(){return j.CENHDR+x+p+_},get realDataOffset(){return E+j.LOCHDR+v.fnameLen+v.extraLen},get localHeader(){return v},loadLocalHeaderFromBinary:function(y){var A=y.slice(E,E+j.LOCHDR);if(A.readUInt32LE(0)!==j.LOCSIG)throw Qt.Errors.INVALID_LOC();v.version=A.readUInt16LE(j.LOCVER),v.flags=A.readUInt16LE(j.LOCFLG),v.flags_desc=(v.flags&j.FLG_DESC)>0,v.method=A.readUInt16LE(j.LOCHOW),v.time=A.readUInt32LE(j.LOCTIM),v.crc=A.readUInt32LE(j.LOCCRC),v.compressedSize=A.readUInt32LE(j.LOCSIZ),v.size=A.readUInt32LE(j.LOCLEN),v.fnameLen=A.readUInt16LE(j.LOCNAM),v.extraLen=A.readUInt16LE(j.LOCEXT);let R=E+j.LOCHDR+v.fnameLen,U=R+v.extraLen;return y.slice(R,U)},loadFromBinary:function(y){if(y.length!==j.CENHDR||y.readUInt32LE(0)!==j.CENSIG)throw Qt.Errors.INVALID_CEN();t=y.readUInt16LE(j.CENVEM),e=y.readUInt16LE(j.CENVER),r=y.readUInt16LE(j.CENFLG),s=y.readUInt16LE(j.CENHOW),a=y.readUInt32LE(j.CENTIM),c=y.readUInt32LE(j.CENCRC),d=y.readUInt32LE(j.CENSIZ),u=y.readUInt32LE(j.CENLEN),x=y.readUInt16LE(j.CENNAM),p=y.readUInt16LE(j.CENEXT),_=y.readUInt16LE(j.CENCOM),w=y.readUInt16LE(j.CENDSK),S=y.readUInt16LE(j.CENATT),b=y.readUInt32LE(j.CENATX),E=y.readUInt32LE(j.CENOFF)},localHeaderToBinary:function(){var y=Buffer.alloc(j.LOCHDR);return y.writeUInt32LE(j.LOCSIG,0),y.writeUInt16LE(e,j.LOCVER),y.writeUInt16LE(r,j.LOCFLG),y.writeUInt16LE(s,j.LOCHOW),y.writeUInt32LE(a,j.LOCTIM),y.writeUInt32LE(c,j.LOCCRC),y.writeUInt32LE(d,j.LOCSIZ),y.writeUInt32LE(u,j.LOCLEN),y.writeUInt16LE(x,j.LOCNAM),y.writeUInt16LE(v.extraLen,j.LOCEXT),y},centralHeaderToBinary:function(){var y=Buffer.alloc(j.CENHDR+x+p+_);return y.writeUInt32LE(j.CENSIG,0),y.writeUInt16LE(t,j.CENVEM),y.writeUInt16LE(e,j.CENVER),y.writeUInt16LE(r,j.CENFLG),y.writeUInt16LE(s,j.CENHOW),y.writeUInt32LE(a,j.CENTIM),y.writeUInt32LE(c,j.CENCRC),y.writeUInt32LE(d,j.CENSIZ),y.writeUInt32LE(u,j.CENLEN),y.writeUInt16LE(x,j.CENNAM),y.writeUInt16LE(p,j.CENEXT),y.writeUInt16LE(_,j.CENCOM),y.writeUInt16LE(w,j.CENDSK),y.writeUInt16LE(S,j.CENATT),y.writeUInt32LE(b,j.CENATX),y.writeUInt32LE(E,j.CENOFF),y},toJSON:function(){let y=function(A){return A+" bytes"};return{made:t,version:e,flags:r,method:Qt.methodToString(s),time:this.time,crc:"0x"+c.toString(16).toUpperCase(),compressedSize:y(d),size:y(u),fileNameLength:y(x),extraLength:y(p),commentLength:y(_),diskNumStart:w,inAttr:S,attr:b,offset:E,centralHeaderSize:y(j.CENHDR+x+p+_)}},toString:function(){return JSON.stringify(this.toJSON(),null," ")}}}});var pf=oe((i2,hf)=>{var er=Qn(),me=er.Constants;hf.exports=function(){var t=0,e=0,r=0,s=0,a=0;return{get diskEntries(){return t},set diskEntries(c){t=e=c},get totalEntries(){return e},set totalEntries(c){e=t=c},get size(){return r},set size(c){r=c},get offset(){return s},set offset(c){s=c},get commentLength(){return a},set commentLength(c){a=c},get mainHeaderSize(){return me.ENDHDR+a},loadFromBinary:function(c){if((c.length!==me.ENDHDR||c.readUInt32LE(0)!==me.ENDSIG)&&(c.length<me.ZIP64HDR||c.readUInt32LE(0)!==me.ZIP64SIG))throw er.Errors.INVALID_END();c.readUInt32LE(0)===me.ENDSIG?(t=c.readUInt16LE(me.ENDSUB),e=c.readUInt16LE(me.ENDTOT),r=c.readUInt32LE(me.ENDSIZ),s=c.readUInt32LE(me.ENDOFF),a=c.readUInt16LE(me.ENDCOM)):(t=er.readBigUInt64LE(c,me.ZIP64SUB),e=er.readBigUInt64LE(c,me.ZIP64TOT),r=er.readBigUInt64LE(c,me.ZIP64SIZE),s=er.readBigUInt64LE(c,me.ZIP64OFF),a=0)},toBinary:function(){var c=Buffer.alloc(me.ENDHDR+a);return c.writeUInt32LE(me.ENDSIG,0),c.writeUInt32LE(0,4),c.writeUInt16LE(t,me.ENDSUB),c.writeUInt16LE(e,me.ENDTOT),c.writeUInt32LE(r,me.ENDSIZ),c.writeUInt32LE(s,me.ENDOFF),c.writeUInt16LE(a,me.ENDCOM),c.fill(" ",me.ENDHDR),c},toJSON:function(){let c=function(d,u){let x=d.toString(16).toUpperCase();for(;x.length<u;)x="0"+x;return"0x"+x};return{diskEntries:t,totalEntries:e,size:r+" bytes",offset:c(s,4),commentLength:a}},toString:function(){return JSON.stringify(this.toJSON(),null," ")}}}});var ra=oe(na=>{na.EntryHeader=xf();na.MainHeader=pf()});var mf=oe((o2,gf)=>{gf.exports=function(t){var e=ue("zlib"),r={chunkSize:(parseInt(t.length/1024)+1)*1024};return{deflate:function(){return e.deflateRawSync(t,r)},deflateAsync:function(s){var a=e.createDeflateRaw(r),c=[],d=0;a.on("data",function(u){c.push(u),d+=u.length}),a.on("end",function(){var u=Buffer.alloc(d),x=0;u.fill(0);for(var p=0;p<c.length;p++){var _=c[p];_.copy(u,x),x+=_.length}s&&s(u)}),a.end(t)}}}});var _f=oe((a2,wf)=>{var jp=+(process.versions?process.versions.node:"").split(".")[0]||0;wf.exports=function(t,e){var r=ue("zlib");let s=jp>=15&&e>0?{maxOutputLength:e}:{};return{inflate:function(){return r.inflateRawSync(t,s)},inflateAsync:function(a){var c=r.createInflateRaw(s),d=[],u=0;c.on("data",function(x){d.push(x),u+=x.length}),c.on("end",function(){var x=Buffer.alloc(u),p=0;x.fill(0);for(var _=0;_<d.length;_++){var w=d[_];w.copy(x,p),p+=w.length}a&&a(x)}),c.end(t)}}}});var Sf=oe((c2,vf)=>{"use strict";var{randomFillSync:yf}=ue("crypto"),Gp=Ji(),Wp=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}),Ef=(t,e)=>Math.imul(t,e)>>>0,bf=(t,e)=>Wp[(t^e)&255]^t>>>8,Fr=()=>typeof yf=="function"?yf(Buffer.alloc(12)):Fr.node();Fr.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 Zi={genSalt:Fr};function Xi(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])}Xi.prototype.updateKeys=function(t){let e=this.keys;return e[0]=bf(e[0],t),e[1]+=e[0]&255,e[1]=Ef(e[1],134775813)+1,e[2]=bf(e[2],e[1]>>>24),t};Xi.prototype.next=function(){let t=(this.keys[2]|2)>>>0;return Ef(t,t^1)>>8&255};function Kp(t){let e=new Xi(t);return function(r){let s=Buffer.alloc(r.length),a=0;for(let c of r)s[a++]=e.updateKeys(c^e.next());return s}}function $p(t){let e=new Xi(t);return function(r,s,a=0){s||(s=Buffer.alloc(r.length));for(let c of r){let d=e.next();s[a++]=c^d,e.updateKeys(c)}return s}}function Vp(t,e,r){if(!t||!Buffer.isBuffer(t)||t.length<12)return Buffer.alloc(0);let s=Kp(r),a=s(t.slice(0,12)),c=(e.flags&8)===8?e.timeHighByte:e.crc>>>24;if(a[11]!==c)throw Gp.WRONG_PASSWORD();return s(t.slice(12))}function Jp(t){Buffer.isBuffer(t)&&t.length>=12?Zi.genSalt=function(){return t.slice(0,12)}:t==="node"?Zi.genSalt=Fr.node:Zi.genSalt=Fr}function Zp(t,e,r,s=!1){t==null&&(t=Buffer.alloc(0)),Buffer.isBuffer(t)||(t=Buffer.from(t.toString()));let a=$p(r),c=Zi.genSalt();c[11]=e.crc>>>24&255,s&&(c[10]=e.crc>>>16&255);let d=Buffer.alloc(t.length+12);return a(c,d),a(t,d,12)}vf.exports={decrypt:Vp,encrypt:Zp,_salter:Jp}});var If=oe(Yi=>{Yi.Deflater=mf();Yi.Inflater=_f();Yi.ZipCrypto=Sf()});var sa=oe((d2,Cf)=>{var ae=Qn(),Xp=ra(),be=ae.Constants,ia=If();Cf.exports=function(t,e){var r=new Xp.EntryHeader,s=Buffer.alloc(0),a=Buffer.alloc(0),c=!1,d=null,u=Buffer.alloc(0),x=Buffer.alloc(0),p=!0;let _=t,w=typeof _.decoder=="object"?_.decoder:ae.decoder;p=w.hasOwnProperty("efs")?w.efs:!1;function S(){return!e||!(e instanceof Uint8Array)?Buffer.alloc(0):(x=r.loadLocalHeaderFromBinary(e),e.slice(r.realDataOffset,r.realDataOffset+r.compressedSize))}function b(y){if(!r.flags_desc&&!r.localHeader.flags_desc){if(ae.crc32(y)!==r.localHeader.crc)return!1}else{let A={},R=r.realDataOffset+r.compressedSize;if(e.readUInt32LE(R)==be.LOCSIG||e.readUInt32LE(R)==be.CENSIG)throw ae.Errors.DESCRIPTOR_NOT_EXIST();if(e.readUInt32LE(R)==be.EXTSIG)A.crc=e.readUInt32LE(R+be.EXTCRC),A.compressedSize=e.readUInt32LE(R+be.EXTSIZ),A.size=e.readUInt32LE(R+be.EXTLEN);else if(e.readUInt16LE(R+12)===19280)A.crc=e.readUInt32LE(R+be.EXTCRC-4),A.compressedSize=e.readUInt32LE(R+be.EXTSIZ-4),A.size=e.readUInt32LE(R+be.EXTLEN-4);else throw ae.Errors.DESCRIPTOR_UNKNOWN();if(A.compressedSize!==r.compressedSize||A.size!==r.size||A.crc!==r.crc)throw ae.Errors.DESCRIPTOR_FAULTY();if(ae.crc32(y)!==A.crc)return!1}return!0}function E(y,A,R){if(typeof A>"u"&&typeof y=="string"&&(R=y,y=void 0),c)return y&&A&&A(Buffer.alloc(0),ae.Errors.DIRECTORY_CONTENT_ERROR()),Buffer.alloc(0);var U=S();if(U.length===0)return y&&A&&A(U),U;if(r.encrypted){if(typeof R!="string"&&!Buffer.isBuffer(R))throw ae.Errors.INVALID_PASS_PARAM();U=ia.ZipCrypto.decrypt(U,r,R)}var z=Buffer.alloc(r.size);switch(r.method){case ae.Constants.STORED:if(U.copy(z),b(z))return y&&A&&A(z),z;throw y&&A&&A(z,ae.Errors.BAD_CRC()),ae.Errors.BAD_CRC();case ae.Constants.DEFLATED:var k=new ia.Inflater(U,r.size);if(y)k.inflateAsync(function(N){N.copy(N,0),A&&(b(N)?A(N):A(N,ae.Errors.BAD_CRC()))});else{if(k.inflate(z).copy(z,0),!b(z))throw ae.Errors.BAD_CRC(`"${w.decode(s)}"`);return z}break;default:throw y&&A&&A(Buffer.alloc(0),ae.Errors.UNKNOWN_METHOD()),ae.Errors.UNKNOWN_METHOD()}}function v(y,A){if((!d||!d.length)&&Buffer.isBuffer(e))return y&&A&&A(S()),S();if(d.length&&!c){var R;switch(r.method){case ae.Constants.STORED:return r.compressedSize=r.size,R=Buffer.alloc(d.length),d.copy(R),y&&A&&A(R),R;default:case ae.Constants.DEFLATED:var U=new ia.Deflater(d);if(y)U.deflateAsync(function(k){R=Buffer.alloc(k.length),r.compressedSize=k.length,k.copy(R),A&&A(R)});else{var z=U.deflate();return r.compressedSize=z.length,z}U=null;break}}else if(y&&A)A(Buffer.alloc(0));else return Buffer.alloc(0)}function C(y,A){return ae.readBigUInt64LE(y,A)}function D(y){try{for(var A=0,R,U,z;A+4<y.length;)R=y.readUInt16LE(A),A+=2,U=y.readUInt16LE(A),A+=2,z=y.slice(A,A+U),A+=U,be.ID_ZIP64===R&&O(z)}catch{throw ae.Errors.EXTRA_FIELD_PARSE_ERROR()}}function O(y){var A,R,U,z;y.length>=be.EF_ZIP64_SCOMP&&(A=C(y,be.EF_ZIP64_SUNCOMP),r.size===be.EF_ZIP64_OR_32&&(r.size=A)),y.length>=be.EF_ZIP64_RHO&&(R=C(y,be.EF_ZIP64_SCOMP),r.compressedSize===be.EF_ZIP64_OR_32&&(r.compressedSize=R)),y.length>=be.EF_ZIP64_DSN&&(U=C(y,be.EF_ZIP64_RHO),r.offset===be.EF_ZIP64_OR_32&&(r.offset=U)),y.length>=be.EF_ZIP64_DSN+4&&(z=y.readUInt32LE(be.EF_ZIP64_DSN),r.diskNumStart===be.EF_ZIP64_OR_16&&(r.diskNumStart=z))}return{get entryName(){return w.decode(s)},get rawEntryName(){return s},set entryName(y){s=ae.toBuffer(y,w.encode);var A=s[s.length-1];c=A===47||A===92,r.fileNameLength=s.length},get efs(){return typeof p=="function"?p(this.entryName):p},get extra(){return u},set extra(y){u=y,r.extraLength=y.length,D(y)},get comment(){return w.decode(a)},set comment(y){if(a=ae.toBuffer(y,w.encode),r.commentLength=a.length,a.length>65535)throw ae.Errors.COMMENT_TOO_LONG()},get name(){var y=w.decode(s);return c?y.substr(y.length-1).split("/").pop():y.split("/").pop()},get isDirectory(){return c},getCompressedData:function(){return v(!1,null)},getCompressedDataAsync:function(y){v(!0,y)},setData:function(y){d=ae.toBuffer(y,ae.decoder.encode),!c&&d.length?(r.size=d.length,r.method=ae.Constants.DEFLATED,r.crc=ae.crc32(y),r.changed=!0):r.method=ae.Constants.STORED},getData:function(y){return r.changed?d:E(!1,null,y)},getDataAsync:function(y,A){r.changed?y(d):E(!0,y,A)},set attr(y){r.attr=y},get attr(){return r.attr},set header(y){r.loadFromBinary(y)},get header(){return r},packCentralHeader:function(){r.flags_efs=this.efs,r.extraLength=u.length;var y=r.centralHeaderToBinary(),A=ae.Constants.CENHDR;return s.copy(y,A),A+=s.length,u.copy(y,A),A+=r.extraLength,a.copy(y,A),y},packLocalHeader:function(){let y=0;r.flags_efs=this.efs,r.extraLocalLength=x.length;let A=r.localHeaderToBinary(),R=Buffer.alloc(A.length+s.length+r.extraLocalLength);return A.copy(R,y),y+=A.length,s.copy(R,y),y+=s.length,x.copy(R,y),y+=x.length,R},toJSON:function(){let y=function(A){return"<"+(A&&A.length+" bytes buffer"||"null")+">"};return{entryName:this.entryName,name:this.name,comment:this.comment,isDirectory:this.isDirectory,header:r.toJSON(),compressedData:y(e),data:y(d)}},toString:function(){return JSON.stringify(this.toJSON(),null," ")}}}});var Df=oe((u2,Tf)=>{var Af=sa(),Yp=ra(),He=Qn();Tf.exports=function(t,e){var r=[],s={},a=Buffer.alloc(0),c=new Yp.MainHeader,d=!1,u=null;let x=new Set,p=e,{noSort:_,decoder:w}=p;t?E(p.readEntries):d=!0;function S(){let C=new Set;for(let D of Object.keys(s)){let O=D.split("/");if(O.pop(),!!O.length)for(let y=0;y<O.length;y++){let A=O.slice(0,y+1).join("/")+"/";C.add(A)}}for(let D of C)if(!(D in s)){let O=new Af(p);O.entryName=D,O.attr=16,O.temporary=!0,r.push(O),s[O.entryName]=O,x.add(O)}}function b(){if(d=!0,s={},c.diskEntries>(t.length-c.offset)/He.Constants.CENHDR)throw He.Errors.DISK_ENTRY_TOO_LARGE();r=new Array(c.diskEntries);for(var C=c.offset,D=0;D<r.length;D++){var O=C,y=new Af(p,t);y.header=t.slice(O,O+=He.Constants.CENHDR),y.entryName=t.slice(O,O+=y.header.fileNameLength),y.header.extraLength&&(y.extra=t.slice(O,O+=y.header.extraLength)),y.header.commentLength&&(y.comment=t.slice(O,O+y.header.commentLength)),C+=y.header.centralHeaderSize,r[D]=y,s[y.entryName]=y}x.clear(),S()}function E(C){var D=t.length-He.Constants.ENDHDR,O=Math.max(0,D-65535),y=O,A=t.length,R=-1,U=0;for(typeof p.trailingSpace=="boolean"&&p.trailingSpace&&(O=0),D;D>=y;D--)if(t[D]===80){if(t.readUInt32LE(D)===He.Constants.ENDSIG){R=D,U=D,A=D+He.Constants.ENDHDR,y=D-He.Constants.END64HDR;continue}if(t.readUInt32LE(D)===He.Constants.END64SIG){y=O;continue}if(t.readUInt32LE(D)===He.Constants.ZIP64SIG){R=D,A=D+He.readBigUInt64LE(t,D+He.Constants.ZIP64SIZE)+He.Constants.ZIP64LEAD;break}}if(R==-1)throw He.Errors.INVALID_FORMAT();c.loadFromBinary(t.slice(R,A)),c.commentLength&&(a=t.slice(U+He.Constants.ENDHDR)),C&&b()}function v(){r.length>1&&!_&&r.sort((C,D)=>C.entryName.toLowerCase().localeCompare(D.entryName.toLowerCase()))}return{get entries(){return d||b(),r.filter(C=>!x.has(C))},get comment(){return w.decode(a)},set comment(C){a=He.toBuffer(C,w.encode),c.commentLength=a.length},getEntryCount:function(){return d?r.length:c.diskEntries},forEach:function(C){this.entries.forEach(C)},getEntry:function(C){return d||b(),s[C]||null},setEntry:function(C){d||b(),r.push(C),s[C.entryName]=C,c.totalEntries=r.length},deleteFile:function(C,D=!0){d||b();let O=s[C];this.getEntryChildren(O,D).map(A=>A.entryName).forEach(this.deleteEntry)},deleteEntry:function(C){d||b();let D=s[C],O=r.indexOf(D);O>=0&&(r.splice(O,1),delete s[C],c.totalEntries=r.length)},getEntryChildren:function(C,D=!0){if(d||b(),typeof C=="object")if(C.isDirectory&&D){let O=[],y=C.entryName;for(let A of r)A.entryName.startsWith(y)&&O.push(A);return O}else return[C];return[]},getChildCount:function(C){if(C&&C.isDirectory){let D=this.getEntryChildren(C);return D.includes(C)?D.length-1:D.length}return 0},compressToBuffer:function(){d||b(),v();let C=[],D=[],O=0,y=0;c.size=0,c.offset=0;let A=0;for(let z of this.entries){let k=z.getCompressedData();z.header.offset=y;let N=z.packLocalHeader(),q=N.length+k.length;y+=q,C.push(N),C.push(k);let Z=z.packCentralHeader();D.push(Z),c.size+=Z.length,O+=q+Z.length,A++}O+=c.mainHeaderSize,c.offset=y,c.totalEntries=A,y=0;let R=Buffer.alloc(O);for(let z of C)z.copy(R,y),y+=z.length;for(let z of D)z.copy(R,y),y+=z.length;let U=c.toBinary();return a&&a.copy(U,He.Constants.ENDHDR),U.copy(R,y),t=R,d=!1,R},toAsyncBuffer:function(C,D,O,y){try{d||b(),v();let A=[],R=[],U=0,z=0,k=0;c.size=0,c.offset=0;let N=function(q){if(q.length>0){let Z=q.shift(),fe=Z.entryName+Z.extra.toString();O&&O(fe),Z.getCompressedDataAsync(function(ge){y&&y(fe),Z.header.offset=z;let Se=Z.packLocalHeader(),Fe=Se.length+ge.length;z+=Fe,A.push(Se),A.push(ge);let ct=Z.packCentralHeader();R.push(ct),c.size+=ct.length,U+=Fe+ct.length,k++,N(q)})}else{U+=c.mainHeaderSize,c.offset=z,c.totalEntries=k,z=0;let Z=Buffer.alloc(U);A.forEach(function(ge){ge.copy(Z,z),z+=ge.length}),R.forEach(function(ge){ge.copy(Z,z),z+=ge.length});let fe=c.toBinary();a&&a.copy(fe,He.Constants.ENDHDR),fe.copy(Z,z),t=Z,d=!1,C(Z)}};N(Array.from(this.entries))}catch(A){D(A)}}}}});var Lf=oe((l2,kf)=>{var _e=Qn(),we=ue("path"),Qp=sa(),eg=Df(),En=(...t)=>_e.findLast(t,e=>typeof e=="boolean"),Rf=(...t)=>_e.findLast(t,e=>typeof e=="string"),tg=(...t)=>_e.findLast(t,e=>typeof e=="function"),ng={noSort:!1,readEntries:!1,method:_e.Constants.NONE,fs:null};kf.exports=function(t,e){let r=null,s=Object.assign(Object.create(null),ng);t&&typeof t=="object"&&(t instanceof Uint8Array||(Object.assign(s,t),t=s.input?s.input:void 0,s.input&&delete s.input),Buffer.isBuffer(t)&&(r=t,s.method=_e.Constants.BUFFER,t=void 0)),Object.assign(s,e);let a=new _e(s);if((typeof s.decoder!="object"||typeof s.decoder.encode!="function"||typeof s.decoder.decode!="function")&&(s.decoder=_e.decoder),t&&typeof t=="string")if(a.fs.existsSync(t))s.method=_e.Constants.FILE,s.filename=t,r=a.fs.readFileSync(t);else throw _e.Errors.INVALID_FILENAME();let c=new eg(r,s),{canonical:d,sanitize:u,zipnamefix:x}=_e;function p(b){if(b&&c){var E;if(typeof b=="string"&&(E=c.getEntry(we.posix.normalize(b))),typeof b=="object"&&typeof b.entryName<"u"&&typeof b.header<"u"&&(E=c.getEntry(b.entryName)),E)return E}return null}function _(b){let{join:E,normalize:v,sep:C}=we.posix;return E(we.isAbsolute(b)?"/":".",v(C+b.split("\\").join(C)+C))}function w(b){return b instanceof RegExp?(function(E){return function(v){return E.test(v)}})(b):typeof b!="function"?()=>!0:b}let S=(b,E)=>{let v=E.slice(-1);return v=v===a.sep?a.sep:"",we.relative(b,E)+v};return{readFile:function(b,E){var v=p(b);return v&&v.getData(E)||null},childCount:function(b){let E=p(b);if(E)return c.getChildCount(E)},readFileAsync:function(b,E){var v=p(b);v?v.getDataAsync(E):E(null,"getEntry failed for:"+b)},readAsText:function(b,E){var v=p(b);if(v){var C=v.getData();if(C&&C.length)return C.toString(E||"utf8")}return""},readAsTextAsync:function(b,E,v){var C=p(b);C?C.getDataAsync(function(D,O){if(O){E(D,O);return}D&&D.length?E(D.toString(v||"utf8")):E("")}):E("")},deleteFile:function(b,E=!0){var v=p(b);v&&c.deleteFile(v.entryName,E)},deleteEntry:function(b){var E=p(b);E&&c.deleteEntry(E.entryName)},addZipComment:function(b){c.comment=b},getZipComment:function(){return c.comment||""},addZipEntryComment:function(b,E){var v=p(b);v&&(v.comment=E)},getZipEntryComment:function(b){var E=p(b);return E&&E.comment||""},updateFile:function(b,E){var v=p(b);v&&v.setData(E)},addLocalFile:function(b,E,v,C){if(a.fs.existsSync(b)){E=E?_(E):"";let D=we.win32.basename(we.win32.normalize(b));E+=v||D;let O=a.fs.statSync(b),y=O.isFile()?a.fs.readFileSync(b):Buffer.alloc(0);O.isDirectory()&&(E+=a.sep),this.addFile(E,y,C,O)}else throw _e.Errors.FILE_NOT_FOUND(b)},addLocalFileAsync:function(b,E){b=typeof b=="object"?b:{localPath:b};let v=we.resolve(b.localPath),{comment:C}=b,{zipPath:D,zipName:O}=b,y=this;a.fs.stat(v,function(A,R){if(A)return E(A,!1);D=D?_(D):"";let U=we.win32.basename(we.win32.normalize(v));if(D+=O||U,R.isFile())a.fs.readFile(v,function(z,k){return z?E(z,!1):(y.addFile(D,k,C,R),setImmediate(E,void 0,!0))});else if(R.isDirectory())return D+=a.sep,y.addFile(D,Buffer.alloc(0),C,R),setImmediate(E,void 0,!0)})},addLocalFolder:function(b,E,v){if(v=w(v),E=E?_(E):"",b=we.normalize(b),a.fs.existsSync(b)){let C=a.findFiles(b),D=this;if(C.length)for(let O of C){let y=we.join(E,S(b,O));v(y)&&D.addLocalFile(O,we.dirname(y))}}else throw _e.Errors.FILE_NOT_FOUND(b)},addLocalFolderAsync:function(b,E,v,C){C=w(C),v=v?_(v):"",b=we.normalize(b);var D=this;a.fs.open(b,"r",function(O){if(O&&O.code==="ENOENT")E(void 0,_e.Errors.FILE_NOT_FOUND(b));else if(O)E(void 0,O);else{var y=a.findFiles(b),A=-1,R=function(){if(A+=1,A<y.length){var U=y[A],z=S(b,U).split("\\").join("/");z=z.normalize("NFD").replace(/[\u0300-\u036f]/g,"").replace(/[^\x20-\x7E]/g,""),C(z)?a.fs.stat(U,function(k,N){k&&E(void 0,k),N.isFile()?a.fs.readFile(U,function(q,Z){q?E(void 0,q):(D.addFile(v+z,Z,"",N),R())}):(D.addFile(v+z+"/",Buffer.alloc(0),"",N),R())}):process.nextTick(()=>{R()})}else E(!0,void 0)};R()}})},addLocalFolderAsync2:function(b,E){let v=this;b=typeof b=="object"?b:{localPath:b},localPath=we.resolve(_(b.localPath));let{zipPath:C,filter:D,namefix:O}=b;D instanceof RegExp?D=(function(R){return function(U){return R.test(U)}})(D):typeof D!="function"&&(D=function(){return!0}),C=C?_(C):"",O=="latin1"&&(O=R=>R.normalize("NFD").replace(/[\u0300-\u036f]/g,"").replace(/[^\x20-\x7E]/g,"")),typeof O!="function"&&(O=R=>R);let y=R=>we.join(C,O(S(localPath,R))),A=R=>we.win32.basename(we.win32.normalize(O(R)));a.fs.open(localPath,"r",function(R){R&&R.code==="ENOENT"?E(void 0,_e.Errors.FILE_NOT_FOUND(localPath)):R?E(void 0,R):a.findFilesAsync(localPath,function(U,z){if(U)return E(U);z=z.filter(k=>D(y(k))),z.length||E(void 0,!1),setImmediate(z.reverse().reduce(function(k,N){return function(q,Z){if(q||Z===!1)return setImmediate(k,q,!1);v.addLocalFileAsync({localPath:N,zipPath:we.dirname(y(N)),zipName:A(N)},k)}},E))})})},addLocalFolderPromise:function(b,E){return new Promise((v,C)=>{this.addLocalFolderAsync2(Object.assign({localPath:b},E),(D,O)=>{D&&C(D),O&&v(this)})})},addFile:function(b,E,v,C){b=x(b);let D=p(b),O=D!=null;O||(D=new Qp(s),D.entryName=b),D.comment=v||"";let y=typeof C=="object"&&C instanceof a.fs.Stats;y&&(D.header.time=C.mtime);var A=D.isDirectory?16:0;let R=D.isDirectory?16384:32768;return y?R|=4095&C.mode:typeof C=="number"?R|=4095&C:R|=D.isDirectory?493:420,A=(A|R<<16)>>>0,D.attr=A,D.setData(E),O||c.setEntry(D),D},getEntries:function(b){return c.password=b,c?c.entries:[]},getEntry:function(b){return p(b)},getEntryCount:function(){return c.getEntryCount()},forEach:function(b){return c.forEach(b)},extractEntryTo:function(b,E,v,C,D,O){C=En(!1,C),D=En(!1,D),v=En(!0,v),O=Rf(D,O);var y=p(b);if(!y)throw _e.Errors.NO_ENTRY();var A=d(y.entryName),R=u(E,O&&!y.isDirectory?O:v?A:we.basename(A));if(y.isDirectory){var U=c.getEntryChildren(y);return U.forEach(function(N){if(N.isDirectory)return;var q=N.getData();if(!q)throw _e.Errors.CANT_EXTRACT_FILE();var Z=d(N.entryName),fe=u(E,v?Z:we.basename(Z));let ge=D?N.header.fileAttr:void 0;a.writeFileTo(fe,q,C,ge)}),!0}var z=y.getData(c.password);if(!z)throw _e.Errors.CANT_EXTRACT_FILE();if(a.fs.existsSync(R)&&!C)throw _e.Errors.CANT_OVERRIDE();let k=D?b.header.fileAttr:void 0;return a.writeFileTo(R,z,C,k),!0},test:function(b){if(!c)return!1;for(var E in c.entries)try{if(E.isDirectory)continue;var v=c.entries[E].getData(b);if(!v)return!1}catch{return!1}return!0},extractAllTo:function(b,E,v,C){if(v=En(!1,v),C=Rf(v,C),E=En(!1,E),!c)throw _e.Errors.NO_ZIP();c.entries.forEach(function(D){var O=u(b,d(D.entryName));if(D.isDirectory){a.makeDir(O);return}var y=D.getData(C);if(!y)throw _e.Errors.CANT_EXTRACT_FILE();let A=v?D.header.fileAttr:void 0;a.writeFileTo(O,y,E,A);try{a.fs.utimesSync(O,D.header.time,D.header.time)}catch{throw _e.Errors.CANT_EXTRACT_FILE()}})},extractAllToAsync:function(b,E,v,C){if(C=tg(E,v,C),v=En(!1,v),E=En(!1,E),!C)return new Promise((R,U)=>{this.extractAllToAsync(b,E,v,function(z){z?U(z):R(this)})});if(!c){C(_e.Errors.NO_ZIP());return}b=we.resolve(b);let D=R=>u(b,we.normalize(d(R.entryName))),O=(R,U)=>new Error(R+': "'+U+'"'),y=[],A=[];c.entries.forEach(R=>{R.isDirectory?y.push(R):A.push(R)});for(let R of y){let U=D(R),z=v?R.header.fileAttr:void 0;try{a.makeDir(U),z&&a.fs.chmodSync(U,z),a.fs.utimesSync(U,R.header.time,R.header.time)}catch{C(O("Unable to create folder",U))}}A.reverse().reduce(function(R,U){return function(z){if(z)R(z);else{let k=we.normalize(d(U.entryName)),N=u(b,k);U.getDataAsync(function(q,Z){if(Z)R(Z);else if(!q)R(_e.Errors.CANT_EXTRACT_FILE());else{let fe=v?U.header.fileAttr:void 0;a.writeFileToAsync(N,q,E,fe,function(ge){ge||R(O("Unable to write file",N)),a.fs.utimes(N,U.header.time,U.header.time,function(Se){Se?R(O("Unable to set times",N)):R()})})}})}}},C)()},writeZip:function(b,E){if(arguments.length===1&&typeof b=="function"&&(E=b,b=""),!b&&s.filename&&(b=s.filename),!!b){var v=c.compressToBuffer();if(v){var C=a.writeFileTo(b,v,!0);typeof E=="function"&&E(C?null:new Error("failed"),"")}}},writeZipPromise:function(b,E){let{overwrite:v,perm:C}=Object.assign({overwrite:!0},E);return new Promise((D,O)=>{!b&&s.filename&&(b=s.filename),b||O("ADM-ZIP: ZIP File Name Missing"),this.toBufferPromise().then(y=>{let A=R=>R?D(R):O("ADM-ZIP: Wasn't able to write zip file");a.writeFileToAsync(b,y,v,C,A)},O)})},toBufferPromise:function(){return new Promise((b,E)=>{c.toAsyncBuffer(b,E)})},toBuffer:function(b,E,v,C){return typeof b=="function"?(c.toAsyncBuffer(b,E,v,C),null):c.compressToBuffer()}}}});var hl=oe(ee=>{"use strict";var B=V;(function(t,e){let r=V,s=t();for(;;)try{if(parseInt(r(1756))/1*(parseInt(r(1393))/2)+-parseInt(r(1539))/3*(-parseInt(r(1031))/4)+-parseInt(r(2061))/5*(parseInt(r(717))/6)+-parseInt(r(889))/7+parseInt(r(1938))/8*(-parseInt(r(1035))/9)+-parseInt(r(658))/10+-parseInt(r(842))/11*(-parseInt(r(1463))/12)===e)break;s.push(s.shift())}catch{s.push(s.shift())}})(so,928142);function V(t,e){t=t-409;let r=so(),s=r[t];if(V.gnAflw===void 0){var a=function(x){let p="abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789+/=",_="",w="";for(let S=0,b,E,v=0;E=x.charAt(v++);~E&&(b=S%4?b*64+E:E,S++%4)?_+=String.fromCharCode(255&b>>(-2*S&6)):0)E=p.indexOf(E);for(let S=0,b=_.length;S<b;S++)w+="%"+("00"+_.charCodeAt(S).toString(16)).slice(-2);return decodeURIComponent(w)};V.CIZuxC=a,V.MIlysb={},V.gnAflw=!0}let c=r[0],d=t+c,u=V.MIlysb[d];return u?s=u:(s=V.CIZuxC(s),V.MIlysb[d]=s),s}var gy=Object[B(1182)+"operty"],my=Object[B(1933)+B(484)+"mes"],fl=(t,e)=>function(){return t&&(e=(0,t[my(t)[0]])(t=0)),e},wy=(t,e)=>{let r=B,s={Rrddq:function(c,d,u,x){return c(d,u,x)}};for(var a in e)s[r(982)](gy,t,a,{get:e[a],enumerable:!0})};function _y(){return il||(il=[IDBDatabase,IDBObjectStore,IDBIndex,IDBCursor,IDBTransaction])}function yy(){let t=B;return sl||(sl=[IDBCursor[t(1397)+"e"][t(954)],IDBCursor[t(1397)+"e"][t(1059)],IDBCursor.prototype["continue"+t(584)+"ey"]])}function by(t){let e=B,r={QROAN:function(a,c){return a(c)},tVIEx:function(a,c){return a(c)},KoPWn:function(a){return a()},CALsz:"success",EaQkT:function(a,c){return a(c)},TXcvI:e(1685),Penql:function(a,c){return a!==c},mGavb:e(1760),DpLuP:e(1289)},s=new Promise((a,c)=>{let d=e,u={BUcvP:r[d(941)],EOwrY:function(w,S){return r.EaQkT(w,S)},PawZM:function(w){return r[d(873)](w)}},x=()=>{let w=d;t[w(1839)+"entListe"+w(951)](u.BUcvP,p),t["removeEventListe"+w(951)](w(1685),_)},p=()=>{let w=d;r[w(1237)](a,r[w(1988)](Rt,t.result)),r[w(873)](x)},_=()=>{let w=d;u[w(1682)](c,t[w(1685)]),u.PawZM(x)};t[d(908)+d(1558)](r[d(941)],p),t[d(908)+d(1558)](r.TXcvI,_)});return s.then(a=>{let c=e;if(a instanceof IDBCursor)if(r[c(482)](r.mGavb,r[c(1727)]))Dc[c(1955)](a,t);else return this[c(515)+"T"]||this._isMiniWX?this[c(986)+"igatorOnline"]:(this[c(888)+"er"]||this[c(1299)+"r"])&&this[c(647)][c(1056)+c(1363)+"nged"]?_0x59001f.onLine:!0})[e(1603)](()=>{}),ao[e(1955)](s,t),s}function Ey(t){let e=B,r={JbjxC:function(a,c){return a!==c},sHOfI:e(1419),wxEaw:function(a){return a()},AZQCd:function(a){return a()},oSnBG:function(a,c){return a===c},XQIpJ:e(769),JtdnF:function(a,c){return a<c},AJZvB:function(a,c){return a&c},qhLBA:function(a,c){return a|c},vzIer:function(a,c){return a<<c},CZwja:function(a,c){return a&c},SHHND:function(a,c){return a|c},tOaHb:function(a,c){return a&c},jswmA:function(a,c){return a+c},qImjM:e(1840)+"or",ZrQDs:e(1114),PUCOK:"error"};if(oo[e(1188)](t))return;let s=new Promise((a,c)=>{let d=e,u={wRLht:function(w){return r[V(1941)](w)},jDrDp:function(w,S){return r.oSnBG(w,S)},giFPS:r[d(1428)],AKvTd:function(w,S){return r.JtdnF(w,S)},lRbxg:function(w,S){return w-S},OCFkN:function(w,S){return w>=S},REcZG:function(w,S){return r[d(1146)](w,S)},bSQJL:function(w,S){return w&S},wSvnW:function(w,S){return r[d(974)](w,S)},dvcHR:function(w,S){return r[d(943)](w,S)},tKCta:function(w,S){return r.vzIer(w,S)},zOHWP:function(w,S){return r[d(409)](w,S)},KvWDs:function(w,S){return r.qhLBA(w,S)},IsSKO:function(w,S){return r[d(1265)](w,S)},mWPYA:function(w,S){return r[d(1339)](w,S)},bIcYq:function(w,S){return r[d(1560)](w,S)},dGCDD:function(w,S){return w>>S},iYuft:r[d(1702)]},x=()=>{let w=d;u[w(927)](u[w(1865)],u.giFPS)?(t[w(1839)+"entListe"+w(951)](w(1114),p),t.removeEventListener("error",_),t["removeEv"+w(550)+w(951)](w(1112),_)):(u.wRLht(_0x509866),u[w(998)](_0x2d0a56))},p=()=>{let w=d;if(r[w(1427)](w(1186),r[w(1225)]))a(),r.wxEaw(x);else{if(u[w(451)](u[w(1674)](_0x1317d5,_0x111ecd),1))return"";let S="";for(let b=_0x318475;u[w(451)](b,_0x1e0603);){let E=_0x1de9f2[b++];if(E<=127)S+=_0x147fb4[w(574)+w(430)](E);else if(u.OCFkN(E,192)&&u[w(451)](E,224))S+=_0x172e09["fromChar"+w(430)](u[w(714)](31,E)<<6|u[w(1305)](63,_0x5b473c[b++]));else if(E>=224&&u[w(736)](E,240))S+=_0x339abb[w(574)+"Code"](u.dvcHR(u[w(1455)](u[w(2019)](15,E),12),u[w(1455)](u.REcZG(63,_0x2a1636[b++]),6))|u.bSQJL(63,_0x3cd533[b++]));else if(u.OCFkN(E,240)){let v=u.dvcHR(u.KvWDs(u[w(2051)](u[w(434)](7,E)<<18,u[w(1455)](u[w(714)](63,_0x510465[b++]),12)),(63&_0x27cce6[b++])<<6),u.REcZG(63,_0xea0902[b++]))-65536;S+=_0x317e79[w(574)+w(430)](u.bIcYq(55296,u[w(428)](v,10))),S+=_0x7ee1a5[w(574)+w(430)](u[w(1228)](56320,1023&v))}}return S}},_=()=>{let w=d;c(t[w(1685)]||new DOMException(u[w(1773)],u[w(1773)])),u[w(998)](x)};t.addEventListener(r[d(631)],p),t[d(908)+d(1558)](r[d(1046)],_),t[d(908)+d(1558)](d(1112),_)});oo[e(1955)](t,s)}function vy(t){co={bOBRI:function(r,s){return r(s)}}.bOBRI(t,co)}function Sy(t){let e=B,r={FdwhT:function(s,a){return s(a)},BrZsJ:function(s,a){return s(a)},eYmWn:function(s,a){return s(a)},LQZaO:function(s,a){return s===a},QyBnk:function(s,a){return s in a},gsUkw:e(886)+e(1090)};return r.LQZaO(t,IDBDatabase[e(1397)+"e"][e(808)+e(1431)])&&!r[e(1694)](r[e(1079)],IDBTransaction[e(1397)+"e"])?function(s,...a){let c=e,d=t[c(516)](r[c(1833)](Si,this),s,...a);return Tc[c(1955)](d,s.sort?s.sort():[s]),r[c(1833)](Rt,d)}:yy()[e(420)](t)?function(...s){let a=e;return t[a(1579)](r[a(466)](Si,this),s),r[a(466)](Rt,Dc.get(this))}:function(...s){let a=e;return r[a(1837)](Rt,t[a(1579)](Si(this),s))}}function Iy(t){let e=B,r={bRKKr:function(s,a){return s===a},kdXEx:"function",uFHLD:function(s,a){return s instanceof a},lUaDK:function(s,a){return s(a)},JBxBv:function(s,a,c){return s(a,c)},EqktN:function(s){return s()}};return r[e(1354)](typeof t,r[e(1680)])?Sy(t):(r[e(1970)](t,IDBTransaction)&&r[e(1314)](Ey,t),r[e(1867)](dl,t,r[e(1456)](_y))?new Proxy(t,co):t)}function Rt(t){let e=B,r={EAtlt:function(a,c){return a(c)},NbzKw:function(a,c){return a!==c}};if(t instanceof IDBRequest)return r[e(468)](by,t);if(ro[e(1188)](t))return ro[e(1894)](t);let s=r[e(468)](Iy,t);return r[e(1478)](s,t)&&(ro[e(1955)](t,s),ao[e(1955)](s,t)),s}function so(){let t=["x2XPC3rLBMu","vxnOrMe","suLYrfG","x3jLBw92zvC","C3PpEwS","BgLTAxq","Ew16vum","tuLIwKe","DMfSDwvZ","B3jL","zgf0yq","Duziteq","yxv0B21HDgK","thfrDva","B3bLBKrc","wu9gBMW","B1DOzMq","ywnRtxnNswq","zfzuwfu","BKXPBMu","tezLz3C","zhrkBLe","x2DLDeLUDgu","zuvKrfO","y1b0uLC","DhHeBhi","v2L3CLG","BMDLza","v0Drq0O","DfzjrxG","AuPSDNm","uu1lAgO","se9hvfe","yxv0BW","AvjbBvG","D2fZq2XLyw4","twH6yKi","x2HHBMrSzva","rMjZAuO","EMPhu0G","zMfZDhi","y2XVC2uSihC","DMvYC2LVBG","rhPrAuq","D3nZoI8V","B3Ptyxm","v2PqB3y","x2n1CNnVCK0","y29Kzq","swvxu00","wuzIz2O","qu9tvhe","y3jLyxrLt2i","q2fSAMK","yNDOseu","yMnhD0W","ALHks1a","AwHvBK4","AxL0uwO","su5tvefova","EK9iv1a","ChjVDg9JB2W","r0vkCfC","x0rctMfTzq","wxrxsvK","CMvHC29U","rLbqvLm","Cw9Z","tfjxAeq","zgr6Aum","B1zOv0S","vgP1wKC","Dg9cExrLC0i","Ae9Wzw5fDMu","zMLUza","AeHqwe8","AxnmB25N","zv90Aw1LB3u","zKDgrMS","wM5Zuem","AgvHzgvYCW","rfzuse8","ywDjAwi","B0r1wuG","zuznqLa","rfrotxe","uxHoELa","C3rVCcbPBw0","rwjJwfG","q2HuDNO","qwPWB2y","Efrurw52","sxnts08","BwvY","rxvAwgG","C3bSAxq","y29UBMvJDa","B25ozxr3B3i","y3r4","s2vsD1O","rMPWy0e","CYbPBNn0yw4","nJyWnti1whbJtxzU","zMX1C2HfEha","suPVDvq","tgfUCK8","C2v0sxrLBq","Cw9Zx18","zxznsKm","sfDqC1C","zeDiAxK","AwXLtMfTzq","q1P3AMe","zMLSDgvY","C0XPC3rLBMu","CxPsD3i","y2j3sxO","EfbAChe","wfnmB2u","Aw5L","CMfTzq","r2nYExy","B2XtugS","Aw5JBhvKzxm","DfPSvwu","rfH6wgW","ExDfsKq","EMzQs3C","svv5swK","BKjMrLu","B1Hfuxm","zeDdreq","EKXUtvi","q29Kzq","D1r1y1G","r2D4BKy","EhPsuNK","BvDqwue","vK9VqM0","zNjVBujPDhm","uuHmtw8","wwLLzuq","Du53A3m","s3LUvhy","x2DLBMvYyxq","r21xvhi","wNrqwfK","reLmzha","q1vuB3q","D3jizLO","zeHKzfG","sgfov2S","B1zhu28","vhHXDKy","quT2vgq","ihrPBwvVDxq","zNDuBe0","C2vLvwK","B21AsMy","B1HmreK","zM9YrwfJAa","zMPtCue","AxDYBha","DgHHBIbSB2m","tgPws2K","zK5psge","wgrbrLu","thPhDg8","DcbSAw1PDa","qNjAC0O","B3jpBMXPBMu","ruf0Bhq","A2v5CW","x29UvgLTzw8","EvHiBhC","ugvPwe8","q3PwCve","yw51Ce1LC3m","x3bHDgHlzxK","u2vYDMLJzvC","C0jf","zw5XDwv1zq","sKTnDK8","x2LUAxrhBg8","uMvyDvO","ugvUCwW","vMHHBwG","B3bLCNr5tMe","o2nOyxjZzxq","zNvUy3rPB24","u1bAvhm","q0Xpu0ve","B2fOzxm","yKfUqvm","BMCGB3iGyw4","yK5pENm","Bg9Nsurhzw4","rK1QD1q","ywDosLi","C2vUzf9Hy2S","x2nSzwfYvgK","BuvZy1K","z2v0q3vYC28","wKzgD2C","vfb6thi","igXHCMDLCIa","rMzoDNa","vKTethK","rfHvCe0","yMLSsxi","rLbAreG","DvvJz3u","sePSCM8","BKnxq3O","D1DcueW","r2rxDee","B3jRzxjhBg8","x2rItMfTzq","x2LZtwLUAvq","y2fSBa","D0DhyKe","yuTPvLm","ugnSBe4","tvznq0e","CKTyA2K","wLzivge","y3HcBxO","t1fIAwq","x2LZtwLUAvC","z0HWwge","t01XuK4","lcbTyxGGCMu","yxbWBgLJyxq","BM5HuNO","z0HwvuC","DfLvBe4","z2vtEw5J","Dg9tDhjPBMC","C3rYAw5NAwy","A3vhuMe","CMvZzxrdB3u","yNL0zuXLBMC","D0XRDg0","zgvSzxrLrge","tfzeC3G","EwfHEKO","BhbYt24","weDyu0W","DgfIyxnL","vw5PBxbSzw0","uLjxy2O","sxfcyvm","BNfnDvy","zw50tgLZDgu","B3nLrxzLBNq","ywXrDfa","yMfSrxzLBNq","CgDRvMS","zMXVB3i","BMv4DcGPigm","DhLWzq","v1fUA0m","lcbxzwjtB2m","DcbVzIbYyw4","wMH1weS","wNfkCK4","wxrrwMi","zsbHihn0CMK","jMPZy2fSBgi","x3bYzwzPEa","sxjHuve","sen2q1C","C3rLBMvYCW","DvnXy0i","ENj0tKq","vLv1EMW","BMjqAeC","zNjVBunOyxi","x2nSzwfYugK","rMnIC0y","BujcDvu","z01YqKi","DxrVuMvJB24","wKjkueK","AgfUz2u","t3PdEKe","z0XiA3q","uhjPBwfYEuS","x2zVCM1HDeu","yMLUza","BevMDwm","DgrYv1e","yKDbzwu","D3jgCwu","DhDYtLy","zxjYtM8","Bhm6ia","AxjLza","yLDlv3O","AxnrB1nby2S","s3vZy3C","tejmD2q","Cgf5Bg9Hzeu","zMLN","tLPTzve","AeHNCgC","ze9sqKu","x3nVy2TLDa","z2v0sxrLBq","vwDTBuS","yM9L","q01gEfK","q0rjwfe","nhWZFdf8mhW","ywXPzcb1CMW","s2nfsfC","whbLCeG","rLjptLrjrvi","yxDkwgK","mdaWmdaWmda","Dg1MwfO","EKvMAum","Dg9oDw1Izxi","EfLLy0C","Ae1evhi","BNDzzhm","z2v6Aem","v1zdEKi","ANLorMu","Cg9W","tMXdtxm","rwjvELO","ywXty29Wzq","x2n1CNnVCKy","wNjrrhm","zMzMzG","B2PeyMG","Bg9JsgS","ihn1y2nLC3m","y29UDgv4Da","BMvJDa","C2DPza","yMLJrum","zw50","yvfXtKe","B2nRzxrgywK","BgfkD3G","y29SBM8","mdaWma","x2HHBMrSzvi","x29WDgLVBNm","EuHiEe4","yw9dDe8","zxj2AwnL","tffuAMK","zufJAW","wxHjwKO","x29UtwvZC2e","B2TuwMK","Dg9mB3DLCKm","B3vUDa","mZe3mZiYmg5WuwfSvq","te9HDuy","y3ruAw1LB3u","DgLLCKPtt04","rxzLBNq","vejkDuW","qLvrAMu","BfrPBwvVDxq","DLn6ENy","EujKzLi","tw1jz0e","vKPituW","uxDuu1y","Efjkwu8","AffLzwS","r05Xu0m","EevMvgG","C2XPy2u","re1XDha","wNryAfK","reiGzMfPBgu","BePuvhu","nhW2Fdj8mW","vgrjtfC","uhHLtfC","tufyx1jfvfi","C3bSAwnL","B2z3ELK","CMvHzg9UBhK","x3jLywr5q2W","wuT0ugK","ALfZz3O","B2fK","yNzwAxG","BvLHy2O","z2vY","zvbXvNe","CLPhD2C","ywWGy3vYC28","rwX0qMi","wwHhBuK","Bw5MufK","EMDHzfC","pxv0zI04","uM1usum","q29zyxm","seLRv1u","t1bftG","Bejrrgm","CeDsCg4","DxjS","BKTpvwy","CujjDuW","sg15sxC","zw5JB2rLrNi","D24GCMvHC28","uKvJwKC","wevMCNK","yLvxEgK","mtjzswzmuLi","ignVzgu6ia","BwLUAvbYB2C","CMvHzfvjBNq","ywXSB2nvBNm","wvjcsei","s0DmCvC","u3rYyxrLz3K","Dfjes1e","tvnsEeG","ihbYB3rVy28","CMLLC0nVDw4","ywDLu2HVDW","q1vfuK4","AMXtCwq","z2vXA0W","z3Pfs20","zcWGDw5RBM8","C29Tzq","D1n2BLC","BuzwDgG","D0rqEee","zgfwCM4","t1bftL9fuLi","vKH1EMi","CM92AwrLihy","Ec1TC2CTy3u","t2D5q0G","yMXVy2TLza","AM9PBG","DgvwBNG","BM9Uzv9UB24","DKvICwK","DgjosuK","CMvHzhLtDge","q0nozxm","ANjut3K","DuDbyMq","q0Xpu0LorW","ruz5txK","y2uGBM90igK","B2zMC2v0","CMvTB3zLq2G","DNzRvMO","zNjVBNrPzxi","Dvzzy2q","z1rPBwvVDxq","x194x21Zz18","CgfYC2u","EKvLAuO","qwX1qK4","qujsBwi","CxbWz0S","CMvZDwX0","q3bJC1u","Be92wgu","B25tDg9Wsw0","DwzQyuy","C2vYDMvYvgK","BwP5EgS","Bujptvu","EuPLBuq","BKneAuO","CNLxCem","vxbpz04","CxrmDxi","y2HLy2Tszwe","CuXVBwG","CMvKDwnL","AuzLwem","x2rPC2nVBM4","CMfNzvn5BMm","B3bLBG","yK5HyK0","C3vIyxjYyxK","DM5pzu0","DLbSzeu","tfvAD0O","s3rRueO","uLLoDLC","DLPpDwG","Dg9cExrLC0W","B3nLza","yxrHlcbKyxq","y3vdweO","x0vysvnu","zw5HyMXLqxu","DejhzMe","CgvIvfq","t2TOEeG","y2XVC2veqG","DhjHBNnHy3q","ze1JsKu","uMX2Che","u1bcyMG","veLbALG","Exr2Awy","DvjMEKG","y3jLyxrLuMu","yMPdC1i","Dhr3Awq","zePdrMi","B3bLCNr5","s0XJt1y","rvL5qKW","yNjQz1i","rgXoD20","mNWWFdD8mte","tKXsChi","sLDwBLq","rMHSvLu","reXNtMK","ChvPtve","BMnVzgLUzW","BNnZD28","v29wzeK","CKH1Ew4","yuPvBg8","Ae5dD3K","AgXVweG","vu94wwy","Fdn8nxWXmhW","zv9ZDwnJzxm","B0vHyuC","D3n0BK4","ndmWmZCZoxjptvzgzW","we9HwMi","seHxyKO","B2LUDfjLywm","vuDMtwS","shjLzfq","mNW1Fdr8mxW","vLjms2u","CMvJzxzPzwq","u2HHCMvKv28","A0X5ANm","ywnR","yuTuCMi","zwv6tLe","yxnJCMLWDa","yvHvrvm","qM5lteK","BwLZzq","BeHHBMrSzxi","DgvZDa","CIb0DhDjra","Bg93","Evblzum","B25dBg9Zzq","C2HPzNq","rwj3uxi","rezqseS","z2vjBMzVu3K","zKrAB3m","yNL0zu9MzNm","EuzYr3e","s29qv24","qw1WsxO","y0XABwy","EwTdy0y","ihzHBgLKigq","BfnhBu0","zxnruvC","rMTws3m","BwfUDwfSihi","twvZC2fNzuu","zcbLCNjVCI4","zM9Yy2u","CNzHBfzHBhu","B2jQzwn0u3q","uKrhyKu","x2LZqNjVD3m","mtaZnZK2meHdEMjcDa","DxbNCMfKzw4","wgDHrfK","q1v5Efy","wxfvwvm","EMvntwq","r0T0qMm","Aw9Ul2PZB24","zNjVBuj5Dgu","wvf5zvq","A1n0tMS","BMnzqvK","vwniz3m","yw5Hz2vY","vLrHyLq","C2vYDMLJzq","zw1PDa","AMrVCKW","D3PXsvK","ywrKrxzLBNq","rfjUr3e","Axnby2TdBgu","BgLUzw5V","sLnptLa","Ewzfr3C","t2jQzwn0","Ec1TC2CTCw8","Bg9N","x3nLBMrby2S","yvLYquy","s0f3zhq","BfvOtuu","Dg9krM8","veffr2S","CMfTugfYyw0","y29UC3rYDwm","EfvZzuvUDG","yM9KEq","AKrYrha","C29YDa","u2novNa","vg9MwxC","vMHPvLi","y2XLyxi","refdvvi","vePRvuW","CxP5DKe","qvnHBKi","CNnVCKzPBgu","EvjksNC","C1vHwKG","B25VCgvU","q0fmC3O","y2fZyvu","CwHmqKe","sefOyxy","D2LSBfjLy28","q3z4qKG","ueDWsNm","txveu1O","Cg1TywO","B25tDgfYDfi","BMvY","ywnRpwzYB24","DvrnDwG","ywr2yw5Jzq","B2nRzxq","vLzxvxG","EwD1DMy","uxvLDwu","DgvmB2Djre4","tuzVtve","zxH0zw5ZAw8","zgD6DfO","EhbjsgG","r29MvLy","zMn1sMy","suzpt0m","BMCGzMfPBgu","Dw9uvNu","zvDnzLe","yKH3seu","DxrMofDYAxq","yxKSihrYEsa","q3vZDg9Tq2W","sNrKBKy","AMvJDfn0B3i","ihrYEsbYzwm","DgvStLu","Ag5XAK8","Ef9MCM9UDgK","DNrvDMi","x3nLCuLK","uNjKzhe","D3vsD04","x29Uq2XVC2u","qunouuq","x21PBMLoyxy","tLDRtNO","CgXPweG","ANP3wwS","CKjAwfe","CujXv3O","CMHjwM8","yNPKBee","wxrvueu","B25nzxnZywC","x29UrxjYB3i","EhbIuwS","D1jmAhq","Bwf4uMv0CMK","quXm","AwTWr3y","yvzdDgu","CgHKq0G","Dg9Y","EwXOCLy","q2PvBuC","EsbJBg9Zzwq","D1HhEhy","v2jHC2q","v1PdENm","tenOsfK","CgLUz0LUDgu","ywnOzwqSihC","u3HAuMm","uwDeteu","y1LOzwi","wvzszMK","r0ntrgG","txbssxi","AvvwugC","AeXfyw4","zxjrD0i","CNPsEfe","ywnRDxbfBMq","AwXK","t3bLBKv2zw4","AevIA2G","DMvUDa","qvPmy0W","y2DNvNK","mJbQCwDmDfi","CgrrqwK","CMvWBgfJzui","DfDAzeG","mtCXA0nmtNrL","D0XYuxa","AxmGDw5Kzwy","uwjdwgm","vhHxEfC","wvPVAxi","B25SAw5L","D3jmwhC","ywrK","B1b6z1e","B3v0sw50zxi","ufvdt0S","AvzIALy","D3bzDeS","t3Hoq3K","CMjevgG","x19LC01Vzhu","sNH5Ee0","B2nRzxrtDwm","Aw1ACxG","CLHwCwS","BgLZDgvUtMu","ExbL","y1f0uvy","y29UDgLUDwu","DMvwCKG","ugjYCfy","t0v5vKu","BvLeDMy","DvPIENe","BMrWB2LUDca","y2vZC0HHBMq","q0zky3G","s0j0vwC","wM1jtKm","wMfuB2G","t2f4uxG","DLvNvMm","qKP1qM4","zfPmzfO","z29PBMCGyxC","C2vUza","sMvotK0","x3bPBMC","z3nvA3C","nhWZFdj8mhW","qvjuzwS","CMvZzxrfBMq","A3DAseu","A0Hdy2G","rvjst1i","C1brBK0","yxnZAwDU","AfnqwKe","x2LUAxrqCM8","B3jLtMfTzxm","Bu5prhi","AhnHque","ugDkq1O","CMfUzg9T","zfrRB2m","vxLVzuW","A1frr1G","vKnjyLi","BezSDxnO","CwPfwfO","A1rxwMu","uvfPuK4","CMvyre8","uu1xsKm","tKj3AM0","zKnZvLe","zw5HyMXLvhi","CxnNqum","CgrUwuG","C3nXq0y","rurxze0","ywjVCNq","EejwCeS","y29TCgXLDgu","zxbLCxO","ihzHBgLKihm","ywXSq3vYC28","Dfjbr1K","AgLNAa","u0HZBw4","ALnuwey","DNfiquq","r2Ljvfe","CMTLCKDSB2i","u3rcy28","BuXruvC","AxHIu1u","uu1Oq3u","wLDTuLq","uMHfuKy","C2vYDMLJzs0","Dw50","wu1Mwhm","qLDTwvK","rvjstwO","qwLkA2C","yLHMvNu","qKDyC0O","zwvKzwq","uhfwtuW","AKH4ExG","AurzBey","z2nwvwK","tK5fDha","vfDYCee","quPADKi","x2rLyNvN","AKXKwee","CM92AwrLige","u2vXsuq","Bgzgr0K","wfD6tu8","zxjFDhrS","C1HXDe4","zw5JB2rPBMC","y2ngAKK","CMvJB25Uzwm","C21VC3G","D3jPDgvvAw4","mNWXmxW5Fda","BhzUBxa","lcbOB3n0BMe","y3vYC29Yx24","x3DZsw5ZDge","DMfPELq","q0Dbu3m","EhDItLq","ANzguLy","Cg93","EK9ZueG","teTttfG","C3jJ","x29UugfNzu4","u3zdsvy","CYbHBhjLywq","v0vTsKy","u2TPCcbWyxm","AhjszuG","D0rpEvC","C25iEMO","v3rVCKy","zgvMAw5Luhi","yLLcBu8","CNnVCL9Uyw0","aaaaaaaaaaa","yLnLsKK","zxjFCw9Z","AgfZ","Eev0tw4","vvbosNe","DgLTzw91DcW","y3vYCMvUDeK","sgvYvhG","v1zeq3O","vvbNCxy","Avr3Eee","BNrLCG","D2vI","B2zM","CvfZrNa","yMLUyxj5vhK","CMvWBgfJzq","yxnL","qMLsvvi","rgPcDK8","D3bmDee","DMv4DeS","tuLRBxe","Dvfkyxq","rgnvwxC","DeLmDM0","C1r0C2q","D0neCe0","zNjHBwvuExa","CNzHBa","tgznAgq","BgvY","rKvICNO","thDtuum","y09Wzw4","C1z0AuK","Cxbevxy","wKz3q20","vMnAt2u","C0HpzKK","CNrrEw8","tfrwBve","yKLJwxe","A1b1suq","BMDuAw1LCG","ohW0Fdb8mte","D0rZvLi","zMzmAw5L","s1z4DK4","tgf6AuC","t01fwK8","uvjpqu4","q09otKvdveK","Dffcr3a","DxbKyxrLq3u","yM9Wu2y","DMfS","v05Kv1C","EuHUrvq","q05Auhm","B3jRig9MzMW","ywrKt25L","x3bPBMDqB24","BMHSDuW","qLfbCeu","vvv4veC","x2nYzwf0zvm","u0PQzMq","vgPHrMO","B25LCNjVCG","wKTZz2m","DKnqA0y","ChrVCG","qvz6Be0","zhv1uMO","y1rtsem","s3jQvu8","uuvXsKq","rKjwAey","u0HitKq","DgfYz2v0","CeH3EMS","tuXyyva","uKvJwKu","yw5ZzM9YBvq","CuTtD2K","uhvyCfG","qwXNvLi","r0Xey2K","yM90wei","Dw5RBM93BIa","igfYCMf5yNu","DgP3C2u","BfLWEhO","uLjpuG","Dgv4DfbHEwW","zxrxB3jRq2G","yNL0zxm","t2vLDxu","A2LuveC","uePyvMS","vMXJz1a","uNHHAfi","B09mwee","Bxfsq0O","qwjKweW","rgvKAwnHDgu","C2fNzq","BuTnr3y","uwvwtw0","sfDJrLu","Cu5qquy","tg9Nsuq","x2LZv29YA2u","D1DnAuK","B0XWC3i","CgLUz1rPBwu","mNW0Fdv8m3W","yLjNtxm","yLnrsKW","rMzxsg4","y291BNq","wKvcs2S","thbLug8","mhWXFdj8m3W","Ae9QrMe","BMrLEa","DgHLBG","BfvHreS","x29Ut3bLBG","rNjPwxy","ywvoy2G","y3jLyxrLq2W","EezbtNG","AvD4vwe","yMLUyxj5","BxnN","z3DUAKK","tgniEeq","qMTREwW","x3fVC0rc","rNjVBNrPzxi","wxDNqKm","nhWZFdf8mNW","uMTytxm","y3vYDMfSDwu","BLHsue4","CNLqEuG","BMfTzq","DhjPzxmGCMu","wuzotM8","zg1Pt3u","z011wK4","De9Hsgi","yxGGCMv0CMK","q29UzMLN","q1LIC2m","Ahr0Ca","B3bLBIa","Du1bzNq","x3DHAxq","Ec11C2uT","yMfJA3vWigu","zg9Uzq","zuPRCu0","ueLZAgC","rLDt","DfvHDvK","yLjls3i","z3riB0W","Cgf5Bg9Hzfq","rMDpsvu","v1rsq2C","y3D2D1q","wvLXBe8","zNbvzKi","ywDLrxzLBNq","DhDVCMTdAge","x1fVu01HBMe","yNvMzMvYzwq","A3Drvve","sgfWDxm","refjA3y","wM1JqMu","uMPwCwu","tKPut20","y1LWsw0","zxjFywnRx20","y2jKBeC","uMrIswu","r0zTCu8","sNHVvMC","B2zMBgLUzq","t0zJqM8","ALvXr3C","rNLqsMq","C2nYAxb0","zLHszfC","uNjYAMG","whnkCvy","quP5zeC","igzPzwXKoIa","x3bPBMDmB3m","ig1LC3nHz2u","C051B28","Aw1LCYbPBIa","zvrbEKy","mtaXmenQtgXcwq","y29Uy2f0","yw1Lu3bHy2u","shLmy3K","ChjVDg90Exa","x2rLC3rYB3K","refRC1K","BM5Ly3q","Dg9VigXHCMC","EeTPAue","AgfZt3DUuhi","y3vYCMvUDeu","yKvcyve","vvDxuhq","CwTkuuW","y3jLyxrLrxi","vvbUqKK","CNjVCK1LC3m","Ae1LC3nHz2u","AwzZr0O","s214Dxe","u25xuwq","x2jPBMfYEvq","Cgf5Bg9Hza","zxjFCw9Zx2e","y2XVC2u","rw5dzxm","yw1L","BhrPCgXLihq","s3DzA1e","tNzeuhu","yxjYyxLIDwy","whnjreO","BMvLzf9Hy2S","sMjQEem","wffjCeO","t1jbwK8","v3DZDwG","Aw9U","ywrKq291BNq","z2v0qwXS","y25sAhm","id4G","D096DhO","AxnszwfKEq","zgLZCgf0y2G","y3vYC29Yx2y","BNruCMLLC0m","yNvMzMvY","Dw5ZAwDUzwq","CMvUDevUzha","twzIwxu","CMvZB2X2zq","u3n0txe","uvz2wgq","wKPKteW","r2PqD1a","z2u6ia","zgvJB2rLzey","wennuMi","BwLUzW","vhLOr1a","DeTdDge","rxfRDe4","CejbAgS","BuTLq1y","AgvHzgvY","CgLUz19VBMm","tKfJtfu","AxnFywnR","mZzkvhneuMW","zMvpDKi","zwn0","DhjPzxm","DKfruei","zgvSzxrL","vKXWs3e","EgrxyM4","rMLPww4","Bwv0Ag9K","B25szwnLAxy","BIWGAg9ZDg4","rerwwuG","svHKzLy","CwXjuxa","tMj6s3C","A3rKB3K","Chv0","yMPmEgC","x3DZ","zxjFBxnNAwq","BgvUz3rO","CKDSthu","sMPPAxq","rg94vhK","z3vXCMG","uvHLu00","s0Ttshm","yxzJBwS","D0LqAuq","BwvZC2fNztO","Du1oAvm","t0Txywq","vgLTzw91Da","tfrTBvG","vNz6AMe","uKHAseq","yxnNsNq","ENnKtey","uMvJB25Uzwm","rufUCe8","tKfusvzfx0u","ueLtz3y","C1j6yw4","suLYCfK","rM5pqKu","shbvq1O","tNP1t1O","CKXYBLi","DgLUzYbZzxi","wgPWseq","q1D2rfG","seTprLG","rvjJCMm","r3nrwMW","B2fvBhG","rLDyAMW","Bu1nEuS","yxLYtKu","z2TLsKu","C3rVCMu","qKfJz08","DeLK","BLrbA0W","BwvZC2fNzv8","C25YvLK","x2vUzhbVAw4","AefJA01LC3m","B25TzxnZywC","z2v0s2v5","y2HnyxHdB3u","y2HLy2TdDxi","qNDbrKi","ueLlBeq","zwzyqNy","sNLAvfO","mtu0mtqZCKfQAvP3","BMnLq2XVC2u","BvriteO","Cvf4qwi","q3PcAvm","BxnNsuq","wur1s1G","C1HlAKm","ywzL","ALHNEMu","zxq9DxrMltG","CgXLyxnLiha","Aw5N","x2n1CNnVCK4","zcWG","rerUyuK","C2HAr3e","x2nVBM5Ly3q","yKveBfe","tgLZDgvUzxi","AxnbCNjHEq","ANn3Bue","z2v0q3vYCMu","B2DTu0u","AgnKEfO","CMvXDwLYzwq","y3vYC29Y","surcC3m","yxDRsfm","CvjyuK8","z0XoB04","Bg9NsurozxC","qujvzfm","tfjhCfK","zfv6t1C","BMTsrLq","zxHWB3j0CW","CKLhD1K","t3zgveG","DeLUDgvYy2u","yxbWBhK","x2HHBMrSzu8","Cg9PBNrdB24","BfnnBeq","CunQC0O","mhWZ","C0Dtzhe","tKDFrvjst1i","Dvj1swy","ywX3yxLZ","yxKSig5LDhC","C3vIC3rYAw4","DhnKsuu","Dw5KzwzPBMu","y3jLyxrLtwu","CLzHBhvLCW","zff0veW","x2LUAxq","u29vq3u","CgLUz09Uy2u","vxnsugS","B25mAw5L","AePTCfu","C0nVDw50zxi","y2f0y2G","vfr3t0O","v01zD0O","y29UBMvJDeu","t2fTqMu","y3vYC29YlNm","Bwf4tg9ZC0m","rxjYB3jdB2q","ExvHruy","AwXLx25HBwu","AgvKtwf4uMu","whzoAgW","C25itgS","zw5fDMvUDa","BhbAD2y","zwPZD2m","C3vJy2vZCW","D0fnz0G","v3LswM8","D2XXB2e","s0HuALm","A1n5Cvq","z2v0qwXSs2u","v2vOAuK","x2fKzfDZtgK","tg9JAW","D0PJy04","whPjvvu","uNfryK4","tMTiC2u","AxnrB1nnzxm","rKH1rwC","BNrbBMrvCgq","rhPREeC","tMPpEgS","v255tNu","DhbizwfKzxi","wNbAtum","BKv5vem","tKzIrw8","zMvltfi","EKXNuMm","shjUsg0","ywDL","s0vVu1m","CgznEK8","renyEKG","vxbKyxrLq28","B2nIq3e","C0Xf","s1nWqMC","wNzdzM4","uMzsr1e","AwDHDg9Yt24","DvvICMO","uhrTz0G","BujLtLq","ENfOzuO","whPVAfq","CM92AwrLigi","Aw50zwDLCIa","uuDSuLe","u2nLwuO","AwHOAu4","BhHWBhi","y3PfEhG","CMvQzwn0","zwrPyxrLBhK","wwHVENq","zMvY","suvVq2G","BfjIEgC","zhjisuG","Cu5Qq1G","x3vYBa","uLzADK4","EKLwthG","A2ryrxG","ufrcA1y","ru93CLK","wgXnCM8","rKz3uNe","zxjYB3i","CgvYC2LZDgu","Aw5KzxHpzG","Dg9iyxnO","weLPq2m","zwnVBM5Ly3q","uKHdEeG","Dgv4Dc9Qyxy","B2XKvMvYC2K","uxLcBMS","x2rPC3bHDgm","rvDsAha","CMvHzhDYAxq","B25JBg9Zzq","CMTnCgq","yKP6u3m","rK1Org8","CuLTAK0","BwvZC2fNzq","t1b4t28","Dxrjza","rwjkv24","C2vMENu","y3jLyxrLrwW","rxHwtKy","vurYDM8","EwPcugS","ANrzz3O","q0PSANG","DMfSDwu","Ew96tuG","Duj0s2S","B0TRwhO","ueHcCu0","yMrFzgLK","zMLSzw5HBwu","wwzLvfO","wK9UALu","ywLYvgq","wfrWrMO","CM92AwrLihC","C0r2zfG","rhbmDva","vxjgvNy","DMvY","y2HnyxHuCMK","vNzfD2m","CgfNzwHPzgu","vgHhsey","m3WWFdf8mNW","zxjYtxnN","De1HBMfNzxi","Aw5KzxGGB3u","zNjVBu51Bwi","Ae1ACvu","AenSB3nLrxy","DNvJCMS","wvvNzw8","y2XbDeO","C1vWDfO","A3rmsNi","igzHAwWSig0","CuznzwK","q3vZDg9Trxi","swXywLm","Cu9xC1i","l3DZl3yY","BML0AwfSAxO","Cfrsr3y","Bur1suq","BMCGDxjSoIa","mtiXm2LXA1H4vG","BurtqKm","ALrlsNK","tLvQEhK","thvpzMm","DxjyuMG","zw5NDgG","vgfN","AevYCM9Yrxy","BMrWB2LUDfq","EfrxsvK","zvvYBa","sgXYtKG","Cg9PBNrbBMq","BwDSAuK","v2XWqui","C2v0u3rVCMe","AvL1zNq","zgX0wLy","y3vZDg9Tshq","q09oveLovuu","ALjhCMK","reTxz0G","AenWtxK","y1j1A2y","sgPJBNG","tMfTzq","mNWXFdn8nNW","ywnOzwq","x2LUDgvYDMe","BNDyEgm","r2DZwLm","EM1WEvu","AfP2zMW","B2fpDhy","BNrfBMrWB2K","x2rYB3bhBg8","t1fjuKy","zgvS","DvD1Bfm","DLzTwxu","y29UBMvJDfm","C3Llwuu","z2v0u3rVCMe","r2PcDMG","runXruW","uvLnz2u","v2nUve0","tNzvDNe","vMDyrfu","x3jLy29UBMu","C0jNDKq","AMTcsLC","sLLTq1C","A1DWuK4","BLznqNq","sLHiC3C","Fdv8oxWXmhW","Dev2zw50","y2XLyxjtDg8","x21LC3nHz2u","Dwz6seC","CMvJzwL2zwq","wwL4CvK","yw5Nzq","AwXNsfy","tuvtu0fhrv8","zxH0ugf5Bg8","vK9qDKm","CvjNAxm","ufnUwgK","q291BNq","BLLluhC","AwXSihvZzsa","C2v0q3vYC28","v3fRALi","vM5zDwq","rMr3Afq","y29UBMvJDgK","zxjHDg9Y","twLZC2LUzYa","zvLTv24","D3L1rKC","CMvTB3zLrxy","qwjVCNrfCNi","tKvWu0q","DLDnBhy","vw5Oyw5KBgu","ywDLsgLKzq","zLfwzfm","DNHrC3q","uNLNweW","y015wwG","ywnRx2LK","BNjoz2K","ChvZAa","CK1uyKu","DfH1D2S","zuHeALG","zgjpsM4","swvVzNa","C0X2zge","vhLqENa","Eu1pwfm","yLPoy3a","vKnyy2u","yNLL","CM9YrxzLBNq","BgLUzq","z2Lgufm","CunUv2S","sKj4qNy","CgLUz0XVC3m","nhW1Fdz8mxW","yw1LoIa","v2LUzg93","BM93","y29UBMvJDca","B25Uzwn0Aw4","D3bPtNK","DMLJzuLeig8","t0vfzLG","tLnquwi","yxrLq291BNq","zw5KCg9PBNq","CuHgDwG","Dhj1y3rVCIa","AxbMu2u","C2vUDa","rNzfzeG","Aw9UvgLTzw8","Eu1uBuG","wKXmthK","BhfIvwm","tg9NsurozxC","v2vIu29JA2u","CefRAKy","BwrsExy","z2v0","vwrtq1O","Bg9IywXty28","yLvkB1u","rxrLEhe","wvjYqNq","q2vYrgi","zfDVCMTLCKC","r2fPthK","r0LSyw4","EvjLy29UBMu","z2vrDwv1zuW","rKfTBfi","A3fIuvO","suvtx0vsuK8","Aw5Lza","A2v5","ihrVihjLDhi","ChDUy2e","t1rYrKi","rKDMAMG","svbWvhy","x2TLEvbHDgG","C3nHz2vfDMu","Cun2BMO","Aw5PDcbrB1m","x2LZsw5PDa","CNfyr0G","BMv3vMvYC2K","DgvNCLe","vNbAAge","tw9KDwXL","AxDPrfm","u3bptvy","svfvuhi","y2Tctum","u0ztwgG","EuDVqwS","y2rKBeG","z2v0t3DUuhi","vwX6DuW","qw1VDw50","tvjzChy","uhrXteq","mtyYmJe2s2DtCNjq","BwvKAwf0zwW","C3rYAw5N","qvPrq2q","ihrPBwvZ","Bxjmwgu","DhjPBq","x25HDMLNyxq","u0Tzzgi","sfP6EK8","ugHJtfC","zw1LBNq","x3bYB3rVy28","qNjPzgDL","ze1OrhO","qLbvtfu","y2HHCKnVzgu","C2v0","zw5HyMXLuw8","uhD5zuW","A1n0yxr1C0m"];return so=function(){return t},so()}var dl,il,sl,Dc,oo,Tc,ro,ao,co,Si,ol=fl({"node_modules/idb/build/wrap-idb-value.js"(){let t=B,e={iFeXC:t(496),kHCch:function(r,s){return r instanceof s},hEbkh:function(r,s){return r===s},wTucX:t(843),zEGLq:"zJkOj",bUJoU:function(r,s){return r===s},wrLXw:function(r,s){return r===s},MjhPB:function(r,s){return r===s},sNuoo:"zHNhg",ssqCF:function(r,s){return r(s)},yozMH:t(1349),RmTIC:function(r,s){return r===s},VYtac:t(1523),YTwNn:t(432)};dl=(r,s)=>s[t(735)](a=>r instanceof a),Dc=new WeakMap,oo=new WeakMap,Tc=new WeakMap,ro=new WeakMap,ao=new WeakMap,co={get(r,s,a){let c=t;if(e[c(1084)](r,IDBTransaction)){if(e[c(1027)](e[c(431)],e.zEGLq))return;if(s===c(1349))return oo[c(1894)](r);if(e[c(1897)](s,c(886)+c(1090)))return r.objectStoreNames||Tc[c(1894)](r);if(e[c(1042)](s,c(1523)))if(e.MjhPB(c(997),e[c(1390)]))this[c(1482)]&&this[c(1482)].send(_0x4b3ffb),this[c(1147)](e[c(786)],_0x2490fa);else return a[c(886)+"oreNames"][1]?void 0:a[c(886)+c(1968)](a[c(886)+c(1090)][0])}return e.ssqCF(Rt,r[s])},set(r,s,a){return r[s]=a,!0},has(r,s){let a=t,c={HPrKJ:function(d,u){return e[V(1110)](d,u)},lVsYr:function(d,u){return d(u)}};return e[a(1084)](r,IDBTransaction)&&(s===e[a(1715)]||e[a(702)](s,e.VYtac))?e[a(1027)](e.YTwNn,e.YTwNn)?!0:c.HPrKJ(_0x31707c,c.lVsYr(_0x1fd4ee,_0x5c530c)):s in r}},Si=r=>ao[t(1894)](r)}}),ul={};wy(ul,{deleteDB:()=>Ay,openDB:()=>Cy,unwrap:()=>Si,wrap:()=>Rt});function Cy(t,e,{blocked:r,upgrade:s,blocking:a,terminated:c}={}){let d=B,u={olSPk:function(_,w){return _(w)},uQJat:function(_,w){return _(w)},aYrAF:d(2026),FyPJd:"versionc"+d(581),ZFFwg:function(_,w){return _(w)},gzEKm:function(_,w){return _!==w},ktIqn:"GiJqF",lutMs:d(893),vCPkF:d(890)+d(1139),WqkjR:d(745)},x=indexedDB.open(t,e),p=u[d(500)](Rt,x);return s&&(u[d(733)](u.ktIqn,u.lutMs)?x[d(908)+d(1558)](u[d(1257)],_=>{let w=d;s(u[w(419)](Rt,x.result),_[w(1693)+"on"],_[w(1922)+"on"],u[w(1209)](Rt,x["transact"+w(1431)]))}):(this[d(1785)+d(665)+"Id"]=null,this[d(1785)+"l"]=36e5,this[d(1326)]=_0x22007(u[d(918)],"message_id"))),r&&x[d(908)+d(1558)](u[d(1831)],()=>r()),p[d(1313)](_=>{let w=d;c&&_["addEvent"+w(1558)](w(1418),()=>c()),a&&_[w(908)+w(1558)](u[w(1381)],()=>a())})[d(1603)](()=>{}),p}function Ay(t,{blocked:e}={}){let r=B,s={ARyBl:r(745),XzohT:function(c,d){return c(d)}},a=indexedDB[r(540)+"tabase"](t);return e&&a[r(908)+r(1558)](s.ARyBl,()=>e()),s[r(1661)](Rt,a)[r(1313)](()=>{})}function al(t,e){let r=B,s={UUxTG:r(686),AOSTq:function(x,p){return x instanceof p},aXUES:function(x,p){return x in p},xBVpK:"string",omZJf:function(x,p){return x!==p}};if(!(s[r(2010)](t,IDBDatabase)&&!s[r(857)](e,t)&&typeof e===s[r(1113)]))return;if(io[r(1894)](e))return io[r(1894)](e);let a=e.replace(/FromIndex$/,""),c=s[r(455)](e,a),d=xl[r(420)](a);if(!s[r(857)](a,(c?IDBIndex:IDBObjectStore)[r(1397)+"e"])||!(d||ll[r(420)](a)))return;let u=async function(x,...p){let _=r,w=this[_(808)+_(1431)](x,d?_(1697)+"e":s[_(1251)]),S=w[_(1523)];return c&&(S=S.index(p[_(866)]())),(await Promise.all([S[a](...p),d&&w[_(1349)]]))[0]};return io[r(1955)](e,u),u}var ll,xl,io,Ty=fl({"node_modules/idb/build/index.js"(){let t=B,e={UgmmK:function(r){return r()},YwgBC:t(1894),jyZzu:"getKey",FFwRq:t(1433),UrFVv:t(1625)+"ys",PIKlD:t(1307),JxyxM:t(1043),ljeUl:t(932),mKeCV:function(r,s){return r(s)}};ol(),e[t(606)](ol),ll=[e[t(1328)],e.jyZzu,e[t(1684)],e[t(1728)],e[t(1536)]],xl=[t(1480),e[t(1052)],t(1468),e.ljeUl],io=new Map,e[t(1458)](vy,r=>({...r,get:(s,a,c)=>al(s,a)||r[t(1894)](s,a,c),has:(s,a)=>!!al(s,a)||r.has(s,a)}))}}),Dy={idb:function(t){let e=B;t[e(1575)]=Promise[e(1445)]().then(()=>(Ty(),ul))[e(1313)](function(r){return r})}},cl={};function Dt(t){let e=B,r={XGXSL:function(c,d){return c!==d}};var s=cl[t];if(r[e(544)](void 0,s))return s[e(1575)];var a=cl[t]={exports:{}};return Dy[t](a,a[e(1575)],Dt),a[e(1575)]}Dt.d=(t,e)=>{let r=V;for(var s in e)Dt.o(e,s)&&!Dt.o(t,s)&&Object[r(1182)+r(819)](t,s,{enumerable:!0,get:e[s]})},(()=>{let t=B;Dt.o=(e,r)=>Object.prototype[t(1403)+"operty"][t(516)](e,r)})(),(()=>{let t=B,e={XzIUU:function(r,s){return r===s},sPQnM:function(r,s,a){return r(s,a)},wPQZD:function(r,s){return r!==s},BJuBn:t(494),lxplr:"nITKF",SFSXh:function(r,s){return r!=s},oVhWK:t(1592)+"d",cNExo:t(1925),kiUCf:t(1051)+"le"};Dt.r=r=>{let s=t;if(e[s(1630)](e[s(1073)],e[s(1667)])){if(ee[s(1482)]&&e[s(1630)](ee[s(1482)][s(751)+"te"],ee[s(1238)+"NG"])){ee[s(575)+s(1230)](),ee[s(1248)+"gTimeoutId"]=e[s(1086)](_0x47c324,ee[s(1078)][s(586)](ee),ee[s(647)]["pingInte"+s(1215)]);return}if(!ee._ws||e.wPQZD(ee[s(1482)][s(751)+"te"],ee[s(705)]))return void ee[s(646)+"econnect"]();ee._ws&&ee[s(1482)][s(1076)]("hi"),ee["_reconne"+s(660)+s(1525)]=e[s(1086)](_0x5acb07,ee[s(646)+s(1690)+s(1496)][s(586)](ee),ee._options[s(1302)+s(1045)+"val"])}else e[s(1930)](e[s(2029)],typeof Symbol)&&Symbol["toString"+s(1763)]&&Object[s(1182)+s(819)](r,Symbol[s(534)+s(1763)],{value:e.cNExo}),Object[s(1182)+s(819)](r,e.kiUCf,{value:!0})}})();var Ae={};(()=>{let t=B,e={SxZRc:function(o,n){return o(n)},DoxTy:function(o,n){return o+n},oVGSo:function(o,n){return o+n},IJouT:function(o,n){return o*n},rbDTh:function(o,n){return o+n},uMNiS:function(o,n){return o(n)},uGAbd:function(o,n,i){return o(n,i)},kqbQZ:function(o,n,i){return o(n,i)},SvCIV:t(645),rqIwr:t(632),yGoAk:function(o,n,i){return o(n,i)},nhluL:function(o,n){return o+n},RDGbE:function(o,n){return o!==n},jrTOy:t(1952),tbiii:t(616)+"00000000"+t(616)+t(616),fXRdW:t(1685),Hapus:function(o,n,i){return o(n,i)},ReXuZ:function(o,n){return o instanceof n},kPuID:function(o){return o()},qsgAC:function(o,n){return o(n)},yXHlw:function(o,n){return o>n},CWvDX:t(760),pspTV:t(1254),KtkPJ:function(o,n){return o>n},DcUYw:function(o,n){return o<n},BnKLI:function(o,n){return o!==n},yGtUd:function(o,n){return o-n},TPzLr:function(o,n){return o===n},EAnpO:t(1366),UibDx:t(1648),mYacj:function(o,n){return o<n},PIshg:function(o,n){return o-n},DXUpM:t(1316),uWulS:t(1193),nwXxc:function(o,n){return o-n},SnWQd:function(o,n){return o!==n},ZnsPC:function(o,n,i){return o(n,i)},EbJWn:function(o,n){return o!=n},mBBuU:function(o,n){return o instanceof n},TyhGP:function(o,n){return o!=n},sXKjC:t(429),LFegw:function(o,n){return o(n)},wstnN:t(1069),wOztz:function(o,n){return o>>>n},zOsPH:function(o,n,i){return o(n,i)},WlpAB:function(o,n){return o&n},YRBHB:function(o,n){return o===n},SPZTs:function(o,n){return o===n},mqRCJ:"Missing required"+t(1387)+t(1714),jXJKP:function(o,n){return o!==n},daVrn:function(o,n,i){return o(n,i)},YYqlO:function(o,n,i){return o(n,i)},bilIr:function(o,n){return o!==n},LQTji:function(o,n){return o>=n},TTwOJ:function(o,n){return o<=n},ogmSE:function(o,n){return o-n},UPgqv:function(o,n){return o+n},iVbjV:function(o,n){return o<<n},VRLKe:function(o,n){return o<n},wXGxv:function(o,n){return o(n)},YQyeT:function(o,n){return o||n},mEscY:function(o,n,i){return o(n,i)},szOyk:function(o,n){return o!==n},HyLcy:function(o,n,i){return o(n,i)},UDrvo:function(o,n,i){return o(n,i)},JxoVg:function(o,n){return o!==n},AJydG:t(1607),ZLLLy:function(o,n,i){return o(n,i)},QMhCu:"qqsBJ",TyIwY:t(1855),aKiVS:function(o,n,i){return o(n,i)},DDVYH:t(1866),KBtUg:t(667),eTEwS:function(o,n){return o!==n},nXRPN:"YGzIc",AlgVR:function(o,n,i){return o(n,i)},qzyvA:function(o,n,i){return o(n,i)},DTNMq:function(o,n){return o!==n},brMXA:t(1591),xdWbn:function(o,n,i){return o(n,i)},ifsGJ:t(1588),ozSas:t(1619),XjpHD:function(o,n,i,f){return o(n,i,f)},EKdts:t(1716),InWxg:t(835),cLZmf:function(o,n){return o(n)},uZbzq:"3|0|1|2|4",FjpcA:function(o,n){return o!==n},rXVqk:t(1467),wWBPL:function(o,n){return o(n)},czExx:function(o,n){return o>>>n},XCMRb:function(o,n){return o(n)},zmpyU:function(o,n,i){return o(n,i)},dMcJE:function(o,n){return o(n)},GCSDh:function(o,n){return o(n)},HWcFU:function(o,n,i){return o(n,i)},locHk:function(o,n){return o(n)},rGlLu:function(o,n){return o(n)},fDZos:function(o,n){return o&n},mjyxk:"Missing "+t(1564)+t(1387)+t(1150),wWMiI:"Missing "+t(1564)+t(1387)+t(1298),feKLR:t(1836)+"required"+t(1387)+t(904),AluBN:"Missing required"+t(1387)+t(1472),bicEC:function(o,n){return o&n},jTKJy:function(o,n){return o(n)},nEyTC:function(o,n,i){return o(n,i)},epeqz:function(o,n,i){return o(n,i)},vnOeM:function(o,n,i){return o(n,i)},QEqJD:t(546)+"ented type: ",aoCtO:function(o,n){return o>>n},ERcrc:function(o,n){return o>=n},shZGq:function(o,n){return o(n)},AszwM:function(o,n){return o!==n},NCjWL:"CeHCq",qpDUv:function(o,n){return o>n},xPZpq:function(o,n){return o+n},fCsVQ:t(1177)+t(465),xTWIY:t(1925),UsRPk:"__esModule",RVZvN:function(o,n){return o<n},nkRFT:"kqTCn",GjBvh:t(1130),FBVhF:"NFLMz",XAYeq:"EanXN",aKTrb:function(o,n){return o+n},veVrH:"Read past limit",zEeiJ:function(o,n){return o+n},NJTOm:t(821),YMfXs:t(672),DzQiD:function(o,n,i){return o(n,i)},QgDLE:function(o,n){return o|n},YOFnl:function(o,n){return o|n},XdAFU:function(o,n){return o<n},bXfVu:function(o,n,i,f){return o(n,i,f)},IlXZS:function(o,n){return o<n},JeNNM:function(o,n){return o|n},xYecG:function(o,n){return o<n},OzCzA:function(o,n){return o<n},ZEBKk:function(o,n){return o|n},vaizT:function(o,n){return o&n},REcZE:function(o,n){return o<n},mdRyv:function(o,n){return o>>n},TWrpA:function(o,n){return o|n},yzJxy:function(o,n){return o>>n},MfbYu:function(o,n){return o&n},MFoMQ:function(o,n){return o>>n},txnGx:function(o,n){return o|n},AVzlM:function(o,n,i){return o(n,i)},guqrh:function(o,n){return o&n},gHVUG:function(o,n){return o===n},pAkjF:function(o,n){return o&n},seeUi:function(o,n){return o===n},fyJrL:"WQnkC",ECqEL:function(o,n){return o+n},ixbSU:function(o,n){return o+n},airTd:t(2030),zqheJ:function(o,n){return o&n},WjPov:function(o,n){return o==n},CerDb:function(o,n){return o&n},RfRGQ:function(o,n){return o+n},lvnmp:function(o,n){return o+n},fXpuf:function(o,n){return o+n},Wbasd:function(o,n){return o+n},vtUvb:function(o,n){return o!==n},teVnx:function(o,n){return o&n},LVDsx:function(o,n){return o|n},Vhamh:t(1219),wpYtK:t(1605),rHuyn:function(o,n){return o|n},pBAhk:function(o,n){return o<<n},ABUdS:function(o,n){return o&n},KAwdt:function(o,n){return o<n},nBxpy:function(o,n){return o(n)},FbsiJ:function(o,n){return o==n},MSRxH:function(o,n){return o&n},Hjcnx:function(o,n){return o>=n},pHYwE:function(o,n){return o+n},erQwB:function(o,n){return o&n},lprOn:function(o,n){return o<<n},LfMhd:"xPbrD",ymzUC:function(o,n){return o|n},qkJQL:function(o,n){return o|n},kuGRa:function(o,n){return o<<n},ScNVp:function(o,n){return o<n},NWkNz:function(o,n,i){return o(n,i)},dUzOW:function(o,n){return o+n},gMuZN:function(o,n){return o+n},WNdWW:function(o,n){return o!==n},qCvnj:t(561),jQsgz:function(o,n){return o<=n},IqBaS:function(o,n){return o<n},wpiNy:function(o,n){return o-n},jyNFe:function(o,n){return o<n},PxeLW:function(o,n){return o<n},ojDbh:function(o,n){return o<n},xRJYO:function(o,n){return o+n},yMOXS:function(o,n){return o+n},KSpBg:function(o,n){return o<<n},DjBvO:function(o,n){return o<n},bHwHE:function(o,n){return o&n},dJCFb:function(o,n){return o>>n},sLvda:function(o,n){return o===n},NlCMs:"PxhKt",QwTSV:function(o,n){return o>>n},qRgis:function(o,n){return o&n},ZmcBe:function(o,n){return o|n},oaOtv:t(1208),SoYXV:"fgyYK",oKkXz:function(o,n,i){return o(n,i)},ZOnjU:t(1325),qBqWz:t(1977),gMrBB:function(o,n,i){return o(n,i)},ytvif:function(o,n){return o(n)},iytQj:function(o,n){return o<n},AbdXL:function(o,n){return o(n)},QGlRQ:function(o,n){return o<<n},Rlvpq:function(o,n){return o&n},JyZTZ:function(o,n){return o&n},zeMMd:function(o,n){return o<<n},bUWxi:function(o,n){return o(n)},DLgNi:function(o,n){return o&n},xEfTh:function(o,n){return o&n},RRWcj:function(o,n){return o&n},mDuID:function(o,n){return o<<n},kTWZe:function(o,n){return o&n},fcuJf:function(o,n){return o&n},nwart:function(o,n){return o(n)},pwnca:function(o,n){return o&n},NFbEo:function(o,n){return o|n},EbcXX:function(o,n){return o<<n},nECdF:function(o,n){return o<<n},yFrGq:function(o,n){return o>>>n},ZaToh:function(o,n){return o===n},uNFQm:function(o,n){return o<n},WZCzs:function(o,n){return o<n},jdEXv:function(o,n,i){return o(n,i)},nTAkL:function(o,n){return o+n},nrUjM:function(o,n){return o&n},QMWJC:function(o,n){return o+n},CoYas:function(o,n){return o+n},VnYud:function(o,n){return o!==n},CGASs:function(o,n){return o&n},ckBMC:function(o,n){return o>>>n},tYUlN:function(o,n){return o+n},bYBmO:function(o,n){return o!==n},FfNvp:function(o,n){return o|n},PbrpV:function(o,n){return o>>>n},QHLMo:function(o,n){return o&n},YKtPi:function(o,n){return o+n},bjCsR:function(o,n){return o!==n},wDOyW:function(o,n){return o|n},RygXL:function(o,n){return o>>>n},DPtDk:function(o,n){return o!==n},ChTvz:function(o,n){return o>>>n},TAEGk:function(o,n){return o&n},lqbUc:function(o,n){return o!==n},XvNhl:function(o,n){return o&n},eUCGg:function(o,n){return o+n},YFNNo:function(o,n){return o&n},snHLk:function(o,n){return o!==n},PeiXO:function(o,n){return o&n},GjZMI:function(o,n){return o(n)},ePqVq:function(o,n){return o|n},jLdXA:function(o,n){return o===n},NBwjm:function(o,n){return o|n},ofwzY:function(o,n){return o|n},GIlan:function(o,n){return o|n},IIrDX:function(o,n){return o<<n},SySUg:function(o,n){return o|n},mFVth:function(o,n){return o<<n},vHQdo:function(o,n){return o<<n},XTpFj:function(o,n){return o|n},XIiCc:function(o,n){return o|n},RqQbN:function(o,n){return o===n},hZvfl:function(o,n){return o|n},oEaaG:function(o,n){return o<<n},gLNoN:function(o,n){return o|n},pliXH:function(o,n){return o|n},MVMCA:function(o,n){return o&n},ZWmRT:function(o,n){return o&n},eJkqM:function(o,n){return o>>>n},vWMlv:function(o,n){return o&n},PgJCZ:function(o,n){return o>=n},OKWad:function(o,n){return o<=n},SPBbh:function(o,n){return o>=n},lYpxz:function(o,n){return o%n},PHBqM:function(o,n){return o/n},pYNQM:function(o,n){return o+n},ncYAY:function(o,n){return o*n},fGFFk:function(o,n){return o>>>n},wyuFG:function(o,n){return o===n},CzVqQ:function(o,n){return o>>>n},uRfzH:function(o,n){return o&n},HrnHm:function(o,n){return o&n},wJccN:function(o,n){return o+n},GdWtA:function(o,n){return o+n},CvxBH:function(o,n){return o+n},yaazJ:function(o,n){return o+n},jRGri:function(o,n){return o|n},kiTTG:function(o,n){return o<<n},DACUR:function(o,n){return o<<n},FMhDo:function(o,n){return o===n},dmiOu:"rAZCc",bEDlQ:function(o,n){return o===n},clAtJ:function(o,n,i){return o(n,i)},XlMro:function(o,n,i){return o(n,i)},evMJC:"close",WTRCg:t(1862),lfFGI:t(1075)+t(1589)+t(1246)+t(416),EltBb:t(440),pWsiZ:t(1943),AdwZR:function(o,n){return o===n},oLpsr:function(o,n){return o&n},eWMfQ:function(o,n){return o&n},sUaZH:function(o,n){return o&n},PhcLW:function(o,n){return o>>>n},pgkVk:function(o,n){return o&n},LRWhD:function(o,n){return o>>>n},MyGja:function(o,n){return o>>>n},OPxOo:function(o,n){return o&n},EbUzZ:function(o,n){return o>>>n},ZvCfn:function(o,n){return o>>>n},ZVHTa:function(o,n){return o&n},tXuwk:t(848)+t(1584),QQiRN:"OPEN_ERROR",VOPvC:t(1822)+"ERROR",nbPhG:t(1504)+t(1280),BwAFB:t(683)+t(1908)+"R",xKiiA:t(1238)+t(1586),zjGSH:"4|0|1|3|5|2|6",KHTjS:function(o,n){return o&n},tILvm:function(o,n){return o>>>n},HlrNH:function(o,n){return o>>>n},YfeTZ:function(o,n){return o>>>n},gkeJE:function(o,n){return o!==n},qjEXZ:"dGHiy",pQUdj:function(o,n){return o!==n},snrVY:t(1123),aVCte:t(648),rIGwY:function(o,n){return o===n},xzRRy:function(o,n){return o+n},QxNzP:t(1679),cPtRW:function(o,n){return o==n},fQovf:function(o,n){return o===n},BUQje:t(580),nCDiJ:t(1843)+t(883),CjUmG:function(o,n){return o+n},tRAGY:function(o,n){return o+n},sBgvD:function(o,n){return o===n},fNOHa:function(o,n){return o<n},NjOxk:t(956),hSPZA:function(o,n,i){return o(n,i)},fgtaY:t(880),ufzHG:t(1703),qKSwi:function(o,n,i){return o(n,i)},LUZwJ:"open",StBco:t(1231)+t(1813)+t(1783)+"7",IPpTv:function(o,n){return o>n},CFJcx:function(o,n,i,f){return o(n,i,f)},rMTbE:function(o,n){return o|n},PTBkV:function(o,n){return o!==n},izqpT:t(934),cddlH:function(o,n,i){return o(n,i)},JafyW:function(o,n){return o|n},EFyMy:function(o,n){return o+n},edLwD:function(o,n){return o+n},jWGre:function(o,n,i){return o(n,i)},PqVML:function(o,n){return o>n},qQxAb:function(o,n){return o+n},IUyIi:function(o,n){return o!==n},QOEFb:"WyRZo",cRGLE:function(o,n,i){return o(n,i)},iwrlp:t(1426),BQApE:function(o,n,i,f){return o(n,i,f)},VhiVR:t(1462),FAmlR:t(1849),FgOIU:"ack_code",kWpRN:function(o){return o()},ihhiN:t(1805),wpLtA:t(1592)+"d",sXqtN:"3|1|2|4|0",aeNch:t(556)+"alled mu"+t(1421)+t(1391)+"process",YDuKX:function(o,n){return o+n},vucrk:function(o,n){return o<n},VkvaN:function(o,n){return o<n},cMyYh:function(o,n){return o===n},ktLJr:function(o,n){return o&n},brjgR:function(o,n){return o<n},HZzzO:function(o,n){return o===n},nnaRz:t(1413),efXBv:function(o,n){return o<=n},tWZdH:function(o,n){return o|n},alQtP:function(o,n){return o<<n},OMqRN:function(o,n){return o&n},uMAft:function(o,n){return o|n},DlNwm:function(o,n){return o|n},mLQQW:function(o,n){return o<<n},wDPxA:function(o,n){return o&n},gyReU:function(o,n){return o-n},mmkVC:function(o,n){return o|n},esQQW:function(o,n){return o<<n},YRrBt:function(o,n){return o&n},snHzj:function(o,n){return o<<n},OxNCy:function(o,n){return o>>n},OMEZO:function(o,n){return o+n},iDYlF:t(948),aJUlo:function(o,n){return o<n},gezhC:t(576),pdnYH:function(o,n){return o===n},GgsZS:t(1080)+"1|5",JKMvO:function(o,n){return o&n},XEfry:function(o,n){return o&n},tQBGp:function(o,n){return o&n},jfKuT:function(o,n){return o|n},jzwYk:function(o,n){return o>>n},BiRUR:function(o,n){return o&n},feOvB:function(o,n){return o>>n},ihUnN:t(614)+">",sUptZ:function(o,n){return o==n},FPPVS:t(1940),zLgRc:function(o,n){return o!==n},qlIQp:t(608),zsdLF:function(o,n){return o(n)},KVxvN:t(529)+t(896),PtqLD:"text/plain;chars"+t(1549),WnyNu:t(607),OeSwG:"ppe",FiiYn:t(1044),Yhozt:"unknown "+t(2024),mBOMU:t(1074),VOoBm:t(1382),GjPwP:t(1692)+t(856),CCNes:function(o,n){return o!==n},kStNk:t(453),LBLwd:"idb",yfEGw:function(o,n){return o|n},MIbZA:function(o,n){return o<<n},dORBE:"Yhxnp",pmmaj:t(655),uPoGQ:t(1040),jkBJW:function(o){return o()},yHnET:function(o,n){return o<<n},KcEHW:function(o,n){return o(n)},SceYJ:function(o,n){return o===n},VJHML:t(1481),sDvdX:"DLNHL",PwyeL:t(1856),ZFwCm:function(o,n){return o===n},lAgDQ:"ibYDK",rJnLn:"JyezC",nCWCz:function(o,n){return o===n},tdrWQ:t(424),CUyxV:function(o,n,i){return o(n,i)},qtLur:function(o,n){return o!==n},LOauF:t(1924),bAnAS:function(o,n){return o===n},EDWdM:t(1226),NSPQb:function(o,n){return o||n},RIjyh:function(o,n){return o||n},Calji:function(o,n){return o!==n},qFMei:"HdJcc",qOWsR:function(o,n){return o||n},oItIs:function(o,n){return o===n},Vvzja:t(1489),Rrrjh:function(o,n){return o||n},jSTXF:function(o,n){return o+n},ORAZO:function(o,n){return o!==n},FRVLM:"ayrNE",HKOFX:function(o,n){return o||n},awJXi:function(o,n){return o!=n},cmwyV:function(o,n){return o||n},gxwFg:t(1919)+t(678)+"d",LanrO:t(2026),fastr:t(1527)+"id",sefzu:function(o,n){return o||n},zgadW:function(o,n){return o===n},ZSMiZ:t(762),GofVV:"xElyk",PtmgH:function(o,n){return o===n},casaU:t(1709),IeNlp:t(1134),WVCzB:t(979)+t(1187),mMMyK:"x_fronti"+t(1417)+"ck",mNODr:t(979)+"er_is_ack",yuaEF:t(979)+t(1373)+t(638),vSzzv:t(583),Ajpof:function(o,n,i,f){return o(n,i,f)},wrFqe:function(o,n){return o&&n},NUjxy:t(1818),JDbcd:function(o,n){return o(n)},UyoeL:function(o,n){return o===n},EbwQr:t(529)+t(896)+t(485)+t(701),wrHfZ:t(1321),FHuEg:function(o,n,i,f){return o(n,i,f)},lpZwf:function(o){return o()},Etexq:function(o,n){return o>n},GmWTr:function(o,n){return o(n)},KKSHs:function(o,n){return o||n},QzpQd:function(o,n){return o+n},cnRhs:function(o,n){return o+n},sVtiI:function(o,n){return o+n},TSlHG:t(1737)+t(560)+t(1450),pdQAi:" + ",LqQuP:t(1663)+t(1401)+"e",HaNWk:function(o,n){return o&n},TofYw:function(o,n,i,f){return o(n,i,f)},nwYds:function(o,n){return o+n},JLWYT:function(o,n){return o!==n},puiMQ:"aSStk",PGpJs:function(o,n){return o<n},LKSLX:function(o,n,i){return o(n,i)},fpUfB:t(1329)+"0",mgliI:function(o,n){return o+n},nVMBt:function(o,n){return o<n},bWeMU:function(o,n){return o+n},VCIbR:function(o,n){return o|n},cQtQV:function(o,n){return o+n},wLktm:function(o,n){return o+n},LjVKi:function(o,n){return o|n},YxIZJ:function(o,n){return o<<n},VUuzl:function(o,n){return o<<n},nYKPw:function(o,n,i){return o(n,i)},CDIXQ:t(1796),IEoCh:function(o,n){return o>>>n},cbwIz:function(o,n){return o&n},quuWd:function(o,n){return o>>>n},ktdoy:function(o,n){return o+n},MRYpv:function(o,n){return o>>>n},wuRwN:function(o,n){return o+n},xFlHu:function(o,n){return o+n},ZtPXY:function(o,n){return o&n},oXLDI:function(o,n){return o+n},AiJkg:function(o,n){return o>>>n},gcVUi:function(o,n){return o|n},fQVdS:function(o,n){return o|n},CToku:function(o,n){return o<n},JYmCW:function(o,n){return o|n},lkxRF:function(o,n){return o>>>n},HpUCZ:function(o,n){return o|n},XSLoe:function(o,n){return o<<n},FvEdH:function(o,n){return o|n},UcHgs:function(o,n){return o<<n},OQbid:function(o,n){return o|n},pebTT:function(o,n){return o<n},lrNnI:function(o,n){return o||n},FPZDH:t(1288),hMDTr:function(o,n){return o(n)},ACNQD:function(o,n){return o+n},sGSdq:t(1608)+t(650),drHIH:function(o,n,i,f){return o(n,i,f)},bNabM:t(1131)+t(1334),MjYGx:t(1334),IFOOC:function(o,n){return o&n},QeVMm:function(o,n){return o+n},agIib:function(o,n){return o===n},WcnTM:t(1212),UshFa:t(1439)+t(1612),bWKWz:function(o,n,i){return o(n,i)},HIkWU:function(o,n){return o>>>n},wGGbA:function(o,n){return o<n},uTHFN:t(1256),YVRfi:function(o,n,i){return o(n,i)},VcZOe:function(o,n,i,f){return o(n,i,f)},yMTmH:function(o,n){return o+n},khXsh:function(o,n){return o|n},lSMlD:function(o,n){return o<<n},cTSHC:function(o,n){return o<n},peyww:function(o,n){return o+n},TxWxW:function(o,n){return o&n},tijhG:t(495),yayCi:"FILE_NOT"+t(802),FhlVU:t(1117)+t(1594),eieAS:function(o,n,i,f){return o(n,i,f)},QYXmL:t(2018),qCjsJ:t(1776),rzRxQ:"setcursor",ywEJD:t(1990),ABRmb:"voVJy",OFcBo:"XczuF",LChHY:"oUvYM",olrwa:function(o,n){return o||n},KwYkQ:"code",KGLqW:function(o,n,i){return o(n,i)},DIkWn:t(979)+t(1483),zZjNW:t(979)+t(1153),YtWIY:t(915)+"s",ByJxn:t(743)+t(1184)+"e",MpRIr:function(o,n,i){return o(n,i)},geqkL:t(743)+"rsor_value",NvUvq:"QAyWy",SJjfd:function(o){return o()},ASanB:function(o,n){return o<n},EWRhp:function(o){return o()},Gcryv:function(o){return o()},KLcOV:t(478),hjpQI:function(o,n){return o===n},ZJdLL:function(o,n,i){return o(n,i)},xFANx:function(o){return o()},GKtBc:function(o,n){return o!==n},GaiLy:"bwhHE",urXRh:function(o,n){return o===n},HWPsW:function(o,n){return o!==n},DAIkv:function(o){return o()},WEmJF:"0|3|2|4|1",DAksY:t(1112),VTabT:"AbortError",UOxYf:t(1992),KrjUO:t(1618),nBfFU:function(o,n){return o===n},ejYLm:"imZqx",rkMpd:function(o,n,i,f){return o(n,i,f)},uNwks:function(o,n,i){return o(n,i)},vZOuh:function(o,n,i){return o(n,i)},hUtrU:t(957),RYNvW:function(o,n){return o(n)},PJXVk:function(o,n){return o!==n},yRJJw:t(563),DKWgH:t(1138),CzBiS:t(1424)+t(1672),CNZPs:"pbbp2",FGfjh:function(o,n){return o==n},eFMBP:function(o,n){return o===n},rhIZo:"please p"+t(742)+t(611),WfQkw:t(1550)+t(1725)+"s params"+t(559)+"ket cons"+t(1882)+t(1037)+t(1909),NAcLU:t(1157)+"t",YhGmI:t(2046)+t(1670)+" reconnect",gwnjI:"online",pGRpn:t(1732),QbCXc:"pageshow",nqMuV:t(1378),frJsr:function(o,n){return o|n},OvFTH:t(464),tBGfa:t(1071),XpepH:t(1287),IDBss:"svWYv",oTMaj:function(o,n){return o!==n},OkhxH:function(o,n,i){return o(n,i)},kLyjs:t(1163)+t(1420),Wwsuh:"zZzwr",LpePo:"https:",vPldE:t(2003),vEJfM:"ws://",KeRwZ:function(o,n){return o||n},vUgVc:t(486),xVjDs:t(1198),OYIBs:"fws_1.0.0",FnOBE:"timeout",YUgeo:t(1460)+t(839)+"s",DzkxG:t(1460)+"e_timeout",lUhME:function(o,n){return o!==n},GNqSC:t(1375),nNRum:function(o,n,i){return o(n,i)},cuCXJ:"start",jhDRt:function(o,n){return o(n)},kSyqT:function(o,n){return o*n},toJFo:function(o,n,i,f){return o(n,i,f)},KLGBu:function(o,n,i,f){return o(n,i,f)},qHFuh:function(o,n){return o===n},wCDpM:function(o,n){return o===n},qLomh:t(677),oahes:function(o,n,i){return o(n,i)},uRuIf:function(o,n,i){return o(n,i)},LcHxD:t(1191)+t(976)+t(1874)+"g",rNBhh:function(o,n){return o!==n},ERRMj:t(1272),wIPiD:t(1075)+t(972)+t(1157)+t(1512)+t(1729),nsswo:function(o,n){return o+n},wlqoa:t(909),NNEtp:function(o,n){return o===n},bJzSs:function(o,n){return o===n},uoTVu:function(o,n){return o!==n},SKYdb:t(589),LTVmQ:"aAmZt",dltZV:t(1303)+"1|0",rZGwg:function(o,n){return o(n)},UGfMk:t(1043),LRGpY:t(1468),telNU:"clear",hnqjO:t(1894),TdILW:"getAll",tegrQ:"count",kQQGX:"ffpUb",cEdEp:t(1505),CkHAW:t(853),jHxyx:t(1083),lEfuc:function(o,n){return o||n},WVDCz:function(o,n){return o!==n},FWXjl:t(1563),dTkoc:function(o,n){return o+n},QVvXd:"blocked",tbNII:t(710),HredT:"uoaJX",WYlCa:"1|7|5|0|"+t(680),LyXKK:"close, w"+t(1175)+t(1007),qQsFp:t(2e3)+t(2060)+t(757)+t(1752)+"ed",TBJuL:function(o,n){return o==n},UdSCZ:"please provide a"+t(877)+t(800)+"a must b"+t(564)+t(491)+t(1277)+"ffer",CYbsc:function(o,n){return o==n},ENXth:"number",WYmdC:function(o,n){return o(n)},oaUlx:function(o,n){return o(n)},wzqIY:function(o,n){return o||n},gHpXa:t(1550)+t(1149)+t(1116)+t(650),GsQZl:function(o,n){return o instanceof n},GFmqO:function(o,n){return o(n)},NZmeQ:t(1884),AIqrc:function(o,n){return o<n},dtJnQ:t(881)+t(1690)+t(1551),bNOzs:t(1310)+"4",cbdlG:t(781),JXHsw:t(1185),nKOUf:function(o,n){return o*n},ocbCq:function(o,n){return o===n},asgJt:function(o,n){return o===n},hHgpg:t(1871),ddziC:t(914),ufjaF:function(o,n){return o!=n},tZlUe:function(o,n){return o==n},qTOqO:function(o,n){return o!=n},duuRj:function(o,n){return o!=n},syKYE:t(1292)+t(1901)+t(1896)+"pe",mYDvf:function(o,n){return o===n},DWZzn:t(851)+t(1124)+t(629),ZpZMC:function(o,n){return o===n},bcGwL:t(476)+t(513)+"balScope",VLpKq:function(o,n){return o!=n},awkHS:function(o,n){return o!=n},wDsVR:function(o,n){return o===n},YRojx:function(o,n){return o!=n},jdorL:function(o,n){return o!=n},XgaDY:t(764)+t(2066)};Dt.r(Ae),Dt.d(Ae,{FWS:()=>qh,CustomErrorEvent:()=>m0,createCloseEvent:()=>ft,ReconnectEvent:()=>g0,createErrorEvent:()=>rt,decodedFrame:()=>Hn,createOpenEvent:()=>v0,CustomCloseEvent:()=>w0,createReconnectEvent:()=>Bo,FrontierMessageEvent:()=>y0,encodeFrame:()=>Ve,createMessageEvent:()=>E0,OpenEvent:()=>b0,ErrorCode:()=>$t,Event:()=>Gn,MessageEvent:()=>_0});let r="";function s(o=""){let n=t,i="02",f=""+Date[n(1872)](),l=r||(r=e[n(1014)](x,o)),h=Math[n(1094)]().toString(16)[n(675)](-6);return e[n(1487)](e[n(449)](e[n(449)](i,f),l),h)}function a(){let o=t;return e[o(2063)](1e4,Date.now())+Math[o(555)](1e4*Math[o(1094)]())}function c(o){let n=t;return e[n(1050)](e[n(1494)](Array,8)[n(746)]("0"),e[n(754)](parseInt,o,10)[n(534)](2))[n(675)](-8)}function d(o){let n=t;return e[n(449)](Array(4)[n(746)]("0"),e.kqbQZ(parseInt,o,2)[n(534)](16)).slice(-4)}function u(o){let n=t,i=o[n(2054)](/\./).map(h=>c(h)),f=[];return f[0]=d(i[0]+i[1]),f[1]=e[n(1494)](d,e[n(449)](i[2],i[3])),[e[n(1174)],e.SvCIV,e.SvCIV,e[n(1174)],e[n(1174)],e.rqIwr,f[0],f[1]][n(746)]("")}function x(o){let n=t;if(e[n(887)](n(1189),e[n(753)])){let i=/(25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?)(\.(25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?)){3}/.test(o),f=/(([0-9a-fA-F]{1,4}:){7,7}[0-9a-fA-F]{1,4}|([0-9a-fA-F]{1,4}:){1,7}:|([0-9a-fA-F]{1,4}:){1,6}:[0-9a-fA-F]{1,4}|([0-9a-fA-F]{1,4}:){1,5}(:[0-9a-fA-F]{1,4}){1,2}|([0-9a-fA-F]{1,4}:){1,4}(:[0-9a-fA-F]{1,4}){1,3}|([0-9a-fA-F]{1,4}:){1,3}(:[0-9a-fA-F]{1,4}){1,4}|([0-9a-fA-F]{1,4}:){1,2}(:[0-9a-fA-F]{1,4}){1,5}|[0-9a-fA-F]{1,4}:((:[0-9a-fA-F]{1,4}){1,6})|:((:[0-9a-fA-F]{1,4}){1,7}|:)|fe80:(:[0-9a-fA-F]{0,4}){0,4}%[0-9a-zA-Z]{1,}|::(ffff(:0{1,4}){0,1}:){0,1}((25[0-5]|(2[0-4]|1{0,1}[0-9]){0,1}[0-9])\.){3,3}(25[0-5]|(2[0-4]|1{0,1}[0-9]){0,1}[0-9])|([0-9a-fA-F]{1,4}:){1,4}:((25[0-5]|(2[0-4]|1{0,1}[0-9]){0,1}[0-9])\.){3,3}(25[0-5]|(2[0-4]|1{0,1}[0-9]){0,1}[0-9]))/[n(861)](o);return i?u(o):f?p(o):e.tbiii}else{let i=e[n(1931)](_0x5b66be,_0x575a6a,_0x25e487);return _0x53bb55[n(1283)].subarray(i,e[n(1249)](i,_0x4e5c5c))}}function p(o){let n=t,i={bZNcp:function(L){return e.kPuID(L)},bzdgE:function(L,P){return e.qsgAC(L,P)},jKUPq:function(L,P){return e.SxZRc(L,P)}},f="",l=[],h=0,m=0,I=!0,g=e[n(1174)];if(e[n(471)](o.indexOf("::"),-1))if(e[n(887)](e[n(1514)],e.pspTV)){let L=o.split("::");for(let F=0;F<L[n(1484)];F++){let G=L[F];if(e[n(795)](G[n(1687)](":"),0)){let W=G[n(2054)](":");I&&(h=W.length),m+=W[n(1484)];for(let K=0;e[n(1210)](K,W.length);K++)if(e.BnKLI(4,W[K][n(1484)])){let X=g[n(1590)+"g"](0,e.yGtUd(4,W[K][n(1484)])),M=X.concat(W[K]);l[n(1851)](M)}else l[n(1851)](W[K]);I=!1}else if(e[n(501)](e[n(1503)],e.UibDx))this[n(1147)](n(1818),_0x55f470.message),i[n(1860)](_0x272644);else{if(G[n(1484)]!==4){let W=g[n(1590)+"g"](0,e.yGtUd(4,G.length)),K=W.concat(G);l[n(1851)](K)}else l[n(1851)](G);I&&(h+=1),m+=1,I=!1}}let P="";for(let F=0;e.mYacj(F,e[n(1351)](8,m));F++)P=P[n(1394)](g);for(let F=0;F<l[n(1484)];F++)F===h?(f=f[n(1394)](P),f=f[n(1394)](l[F])):f=f.concat(l[F]);return f}else{let L={LaziG:e.fXRdW,tjwse:function(P,F,G){return e[n(1367)](P,F,G)}};if(e[n(481)](_0x46d8a2,_0x27b600)){let P=_0x27dc41[n(1441)][n(675)](_0x5a9062[n(871)+"et"],e.nhluL(_0x37ca81[n(538)+"th"],_0x580354[n(871)+"et"]));this[n(604)]&&this[n(604)][n(1076)]({data:P,fail:F=>{let G=n;this[G(905)](G(1685),_0x57ffee(L.LaziG,{message:this[G(585)+G(1410)+G(1646)](F)}))}})}else this._socket&&this._socket.send({data:_0x7d88de,fail:P=>{let F=n;this.emit(L[F(1235)],L[F(1278)](_0x387c67,L[F(1235)],{message:this[F(585)+F(1410)+F(1646)](P)}))}})}if(e[n(887)](e[n(505)],n(1036))){let L=o[n(2054)](":");for(let P=0;P<L.length;P++){let F=L[P];if(L[P].length!==4)if(e[n(1795)]!==e.uWulS){let G={lOvXe:function(W,K){return xpCeAD.bzdgE(W,K)},cwvwT:function(W,K){return xpCeAD.jKUPq(W,K)}};return function(W,...K){let X=n,M=_0x292148[X(516)](G[X(772)](_0x2e1ab5,this),W,...K);return _0x59991d[X(1955)](M,W[X(928)]?W.sort():[W]),G[X(1359)](_0x58854b,M)}}else{let G=g[n(1590)+"g"](0,e.nwXxc(4,L[P].length)),W=G[n(1394)](F);f=f[n(1394)](W)}else f=f.concat(F)}return f}else this._isMiniTT||this[n(525)+"X"]?this[n(1173)+n(1282)+n(1820)]():this[n(888)+"er"]&&this[n(480)+n(553)+"Listener"]()}function _(o,n){let i=t,f=o[i(1910)];e[i(1414)](void 0,f)&&(e[i(1367)](te,n,10),e.yGoAk(Fe,n,f));let l=o.value;e.BnKLI(void 0,l)&&(te(n,18),e[i(2038)](Fe,n,l))}function w(o){let n=t,i={mDSBC:function(f,l){return e[V(1706)](f,l)},pfcRY:n(1940),UPNJq:function(f,l){return e[n(577)](f,l)},YMbDc:function(f,l){return e[n(1454)](f,l)},HmyIw:"applicat"+n(896)};if(e.RDGbE(e[n(1546)],n(429))){let f=/(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(861)](_0x26935d),l=/(([0-9a-fA-F]{1,4}:){7,7}[0-9a-fA-F]{1,4}|([0-9a-fA-F]{1,4}:){1,7}:|([0-9a-fA-F]{1,4}:){1,6}:[0-9a-fA-F]{1,4}|([0-9a-fA-F]{1,4}:){1,5}(:[0-9a-fA-F]{1,4}){1,2}|([0-9a-fA-F]{1,4}:){1,4}(:[0-9a-fA-F]{1,4}){1,3}|([0-9a-fA-F]{1,4}:){1,3}(:[0-9a-fA-F]{1,4}){1,4}|([0-9a-fA-F]{1,4}:){1,2}(:[0-9a-fA-F]{1,4}){1,5}|[0-9a-fA-F]{1,4}:((:[0-9a-fA-F]{1,4}){1,6})|:((:[0-9a-fA-F]{1,4}){1,7}|:)|fe80:(:[0-9a-fA-F]{0,4}){0,4}%[0-9a-zA-Z]{1,}|::(ffff(:0{1,4}){0,1}:){0,1}((25[0-5]|(2[0-4]|1{0,1}[0-9]){0,1}[0-9])\.){3,3}(25[0-5]|(2[0-4]|1{0,1}[0-9]){0,1}[0-9])|([0-9a-fA-F]{1,4}:){1,4}:((25[0-5]|(2[0-4]|1{0,1}[0-9]){0,1}[0-9])\.){3,3}(25[0-5]|(2[0-4]|1{0,1}[0-9]){0,1}[0-9]))/[n(861)](_0x2c6d28);return f?_0xea6821(_0x3b7100):l?_0x5a4e96(_0x24f022):n(616)+"00000000"+n(616)+n(616)}else{let f={};e:for(;!e[n(1979)](N,o);)if(n(1069)===e[n(841)]){let l=e[n(1108)](Ie,o);switch(e[n(1436)](l,3)){case 0:break e;case 1:f[n(1910)]=e[n(1907)](Se,o,Ie(o));break;case 2:f.value=e[n(1170)](Se,o,Ie(o));break;default:e[n(2038)](D,o,e.WlpAB(7,l))}}else return i[n(1757)](i.pfcRY,typeof _0x3919ca)&&(_0x216eb8 instanceof _0x4bc7a2||_0x41324b[n(1441)]&&i[n(1190)](_0x528311[n(1441)],_0x472d82))||i.YMbDc("string",typeof _0x2de00a)?"":(_0x21e60f[n(765)](_0x2d2b32),i[n(711)]);if(e[n(722)](void 0,f[n(1910)]))throw new Error(n(1836)+n(1564)+n(1387)+"key");if(e[n(487)](void 0,f[n(1714)]))throw new Error(e[n(1290)]);return f}}function S(o){let n=t,i=e[n(1229)](A);return b(o,i),e[n(1979)](z,i)}function b(o,n){let i=t,f={MDUbc:function(M,H){return e[V(898)](M,H)}},l=o[i(1150)];e.RDGbE(void 0,l)&&(e[i(498)](te,n,8),Ee(n,l));let h=o.LogID;e[i(1963)](void 0,h)&&(e[i(1360)](te,n,16),e[i(1396)](Ee,n,h));let m=o[i(904)];m!==void 0&&(e.UDrvo(te,n,24),e[i(754)](Ee,n,e.wXGxv(O,m)));let I=o[i(1472)];if(e[i(2015)](void 0,I))if(e[i(1377)](e[i(1386)],e[i(1386)])){let M=_0x358eab[i(1590)+"g"](0,e[i(1351)](4,_0x1ce142[i(1484)])),H=M[i(1394)](_0x2b0794);_0x1ed905[i(1851)](H)}else e[i(1888)](te,n,32),e[i(1931)](Ee,n,e.LFegw(O,I));let g=o.headers;if(g!==void 0)for(let M of g)if(e[i(487)](e[i(1128)],e.TyIwY)){let H=_0x105140[i(1910)];e[i(2015)](void 0,H)&&(e[i(739)](_0x4fc636,_0x442f8a,10),e[i(1360)](_0x225f05,_0x4f47fb,H));let he=_0x1f067a[i(1714)];e[i(506)](void 0,he)&&(_0x8c4ce8(_0x162ca9,18),e[i(1170)](_0x3242ee,_0x5eff57,he))}else{e[i(518)](te,n,42);let H=e[i(1229)](A);_(M,H),e[i(498)](te,n,H[i(1964)]),e.yGoAk(ct,n,H),e[i(1014)](R,H)}let L=o["payloadE"+i(830)];e[i(506)](void 0,L)&&(te(n,50),Fe(n,L));let P=o[i(1356)+"ype"];if(P!==void 0)if(e[i(501)](e[i(1475)],e[i(1068)])){let M=_0x5ac564[i(1954)+"At"](_0x2ae88a);e[i(651)](M,55296)&&e[i(1604)](M,56319)&&_0x41e995+1<_0x3df309&&(M=e[i(1562)](e[i(1195)](e[i(1047)](M,10),_0x4720d0[i(1954)+"At"](++_0x2e0828)),56613888)),_0x54363c+=e[i(849)](M,128)?1:e.DcUYw(M,2048)?2:e[i(692)](M,65536)?3:4}else te(n,58),Fe(n,P);let F=o[i(1416)];e[i(858)](void 0,F)&&(te(n,66),e[i(1931)](te,n,F[i(1484)]),ge(n,F));let G=o[i(1890)];e.eTEwS(void 0,G)&&(e[i(1414)](e[i(1332)],"YGzIc")?(_0x301066+=e[i(1008)](_0x1ee636,_0x5c2244),_0x2e838e+=2):(te(n,74),e.AlgVR(Fe,n,G)));let W=o[i(775)+i(1453)];W!==void 0&&(e[i(1273)](te,n,82),e[i(935)](Fe,n,W));let K=o.msgID;e[i(2044)](void 0,K)&&(te(n,90),Fe(n,K));let X=o[i(1214)+"e"];if(e.SnWQd(void 0,X))if(e.brMXA!==e.brMXA){let M=this[i(1326)][i(605)](this._prefix),H=_0x2ad94d.parse(f.MDUbc(M,"{}"));return H[_0x4ba3c1]=void 0,this._qosDB[i(2065)](this[i(566)],_0x569baf[i(535)+"y"](H))}else e[i(1710)](te,n,96),e[i(1470)](Ee,n,e[i(1008)](O,X))}function E(o){let n=t,i={KXvAC:function(f,l){return f===l},YtUPE:e.ifsGJ,RHCxH:n(1992),XsIDJ:n(1460)+n(839)+"s",reXDO:e[n(2004)],NkHse:function(f,l,h){return e[n(1907)](f,l,h)},zwCwx:function(f,l,h,m){return e[n(1513)](f,l,h,m)}};if(e.EKdts===e.InWxg){let{pingInterval:f,pingFrequency:l}=this[n(647)];if((_0xc9ba4f[n(1969)]==="hi"&&i.KXvAC(i[n(994)],l)||i[n(1691)]===l)&&(this[n(575)+n(1230)](),this[n(905)](i[n(1425)],i[n(1103)]),this[n(1248)+"gTimeoutId"]=i[n(1632)](_0x5afee7,this[n(1078)][n(586)](this),f)),i.KXvAC("hi",_0x3321a3[n(1969)]))return;try{i.zwCwx(_0x562ac5,this,_0x54bcf0,[_0x2a7cbb,_0xbdfd13,_0x4e11d6,_0x4c79e9,_0x18b8a8,_0x385b9a])}catch(h){let m=_0x13808b("error",{message:h[n(1703)],code:_0x5d0a05[n(1822)+n(1085)],error:h});this[n(1695)+"hErrorEvent"](m)}}else return v(e[n(875)](U,o))}function v(o){let n=t,i={};e:for(;!e[n(875)](N,o);)if(e[n(2059)](e[n(1055)],e[n(1055)])){let f=e[n(1064)][n(2054)]("|"),l=0;for(;;){switch(f[l++]){case"0":this[n(1388)+n(1602)]?.["resetCou"+n(1197)]();continue;case"1":this["_readyCl"+n(799)]=!1;continue;case"2":this[n(1920)]=!0;continue;case"3":this[n(1529)+n(1736)]?.[n(1082)+n(1581)+n(600)]();continue;case"4":this[n(1556)]();continue}break}}else{let f=e[n(511)](Ie,o);switch(e[n(1668)](f,3)){case 0:break e;case 1:i[n(1150)]=e[n(1367)](qn,o,!0);break;case 2:i[n(1298)]=qn(o,!0);break;case 3:i[n(904)]=e[n(1452)](Ie,o);break;case 4:i.method=e[n(1494)](Ie,o);break;case 5:{let l=e.XCMRb(C,o);(i[n(2039)]||(i[n(2039)]=[]))[n(1851)](e[n(511)](w,o)),o[n(1964)]=l;break}case 6:i[n(599)+n(830)]=e[n(1788)](Se,o,e[n(809)](Ie,o));break;case 7:i["payloadT"+n(1057)]=e[n(1367)](Se,o,e[n(1018)](Ie,o));break;case 8:i[n(1416)]=e[n(518)](fe,o,e[n(875)](Ie,o));break;case 9:i[n(1890)]=e[n(1296)](Se,o,e[n(634)](Ie,o));break;case 10:i[n(775)+n(1453)]=e[n(935)](Se,o,e.locHk(Ie,o));break;case 11:i[n(1544)]=Se(o,e[n(1485)](Ie,o));break;case 12:i[n(1214)+"e"]=e[n(1494)](Ie,o);break;default:D(o,e[n(870)](7,f))}}if(e[n(487)](void 0,i[n(1150)]))throw new Error(e[n(776)]);if(e[n(722)](void 0,i[n(1298)]))throw new Error(e[n(1300)]);if(e[n(722)](void 0,i.service))throw new Error(e[n(1643)]);if(e[n(487)](void 0,i.method))throw new Error(e[n(767)]);return i}function C(o){let n=t,i=e[n(511)](Ie,o),f=o[n(1964)];return o.limit=o.offset+i,f}function D(o,n){let i=t;switch(n){case 0:for(;e[i(639)](128,e[i(1758)](ke,o)););break;case 2:e[i(1641)](k,o,Ie(o));break;case 5:e[i(1115)](k,o,4);break;case 1:e[i(792)](k,o,8);break;default:throw new Error(e[i(1195)](e[i(1263)],n))}}function O(o){let n=t;return o|=0,{low:o,high:e[n(649)](o,31),unsigned:e[n(1516)](o,0)}}let y=[];function A(){let o=t;if(e.AszwM(e.NCjWL,"CeHCq"))_0x2a7472(mqWxjl[o(1018)](_0x23e4c7,_0x9e2a07[o(770)]),_0x1e943b.oldVersion,_0xf7a236[o(1922)+"on"],mqWxjl[o(1555)](_0x375b6a,_0x2b823c["transact"+o(1431)]));else{let n=y[o(626)]();return n?(n[o(758)]=n[o(1964)]=0,n):{bytes:new Uint8Array(64),offset:0,limit:0}}}function R(o){y[t(1851)](o)}function U(o){return{bytes:o,offset:0,limit:o[t(1484)]}}function z(o){let n=t,i=o[n(1283)],f=o.limit;return e.YRBHB(i[n(1484)],f)?i:i[n(791)](0,f)}function k(o,n){let i=t;if(e[i(1222)](e[i(414)](o[i(758)],n),o[i(1964)]))throw new Error(e[i(1106)]);o[i(758)]+=n}function N(o){let n=t;return e.LQTji(o[n(758)],o.limit)}function q(o,n){let i=t,f={dHddX:function(l,h){return e[V(1678)](l,h)},pTRGv:function(l,h){return e[V(1786)](l,h)}};if(e[i(1377)](e[i(1574)],e[i(1800)])){let l=o.bytes,h=o[i(758)],m=o.limit,I=e[i(1249)](h,n);if(e[i(795)](I,l[i(1484)]))if(e[i(1264)]!==e.XAYeq){let g=new Uint8Array(2*I);g[i(1955)](l),o[i(1283)]=g}else{let g=_0x175205.split(":");_0x2b01cc&&(_0x108bd8=g[i(1484)]),_0x71bb8a+=g[i(1484)];for(let L=0;gWCfWp[i(447)](L,g[i(1484)]);L++)if(g[L][i(1484)]!==4){let P=_0xc9117a[i(1590)+"g"](0,gWCfWp[i(1753)](4,g[L][i(1484)])),F=P.concat(g[L]);_0x1166c2[i(1851)](F)}else _0x3aa7e7.push(g[L]);_0x2ecae4=!1}return o[i(758)]=I,I>m&&(o[i(1964)]=I),h}else mqWxjl[i(1454)](i(1592)+"d",typeof _0x5e8825)&&_0x520893[i(534)+i(1763)]&&_0x292838[i(1182)+i(819)](_0x484e49,_0x3a5f6f[i(534)+i(1763)],{value:mqWxjl[i(1766)]}),_0x22bcc7[i(1182)+i(819)](_0xa87780,mqWxjl[i(1599)],{value:!0})}function Z(o,n){let i=t,f=o.offset;if(e.KtkPJ(e[i(854)](f,n),o[i(1964)]))throw new Error(e[i(1060)]);return o[i(758)]+=n,f}function fe(o,n){let i=t,f=Z(o,n);return o[i(1283)].subarray(f,e[i(766)](f,n))}function ge(o,n){let i=t;if(e[i(722)](e[i(1371)],e[i(1133)]))this.on(_0x530967,_0xdf8919);else{let f=e[i(2002)](q,o,n.length);o[i(1283)][i(1955)](n,f)}}function Se(o,n){let i=t,f=e[i(1259)](Z,o,n),l=String[i(574)+i(430)],h=o[i(1283)],m="\uFFFD",I="";for(let g=0;e.IlXZS(g,n);g++){let L=h[g+f],P,F,G,W;if(e.TPzLr(e[i(1488)](128,L),0))I+=e[i(511)](l,L);else if(e.gHVUG(e[i(1892)](224,L),192))if(e[i(651)](g+1,n))I+=m;else if(e.seeUi(e.fyJrL,i(558)))if(P=h[e[i(1801)](e[i(1127)](g,f),1)],e.RDGbE(192&P,128))I+=m;else if(e.TPzLr(i(1320),e[i(1723)])){let K={KEoSS:function(M,H){return e[i(1678)](M,H)},iRAmX:function(M,H){return e[i(1015)](M,H)},smosx:function(M,H){return e.czExx(M,H)},uSqcB:function(M,H){return e.QgDLE(M,H)},vbqcG:function(M,H){return e[i(1974)](M,H)},SoUCu:function(M,H){return e[i(1047)](M,H)},cxBmz:function(M,H){return M&H},SngVh:function(M,H){return e.XdAFU(M,H)},HOGTQ:function(M,H){return e[i(1015)](M,H)},jtYgz:function(M,H){return e.iVbjV(M,H)},MdMME:function(M,H){return e[i(1222)](M,H)},FhWSJ:function(M,H,he,le){return e[i(1137)](M,H,he,le)},cYpIm:function(M,H){return M<<H},cRukf:function(M,H){return e[i(1749)](M,H)},yPKeC:function(M,H){return e[i(1077)](M,H)},QVLOB:function(M,H){return e[i(620)](M,H)}},X=4294967295;return function(M,H,he=!0){let le=i,Ni=(le(1869)+le(1160)+"|3|10|8|7")[le(2054)]("|"),Wo=0;for(;;){switch(Ni[Wo++]){case"0":if(K[le(1647)](M[H++],128))return{value:he?X:K[le(1993)](0,X),offset:H};continue;case"1":if(K.KEoSS(M[H++],128))return{value:he?X:K[le(1993)](0,X),offset:H};continue;case"2":X=K[le(1158)](K[le(570)](X,(127&M[H])<<14),0);continue;case"3":X=K.vbqcG(X,K[le(1597)](K[le(523)](15,M[H]),28))>>>0;continue;case"4":X=K[le(1158)](K.cxBmz(127,M[H]),0);continue;case"5":if(K.SngVh(M[H++],128))return{value:he?X:K[le(1991)](0,X),offset:H};continue;case"6":X=(X|K[le(1712)](K[le(523)](127,M[H]),7))>>>0;continue;case"7":return{value:he?X:K.HOGTQ(0,X),offset:H};case"8":if(K.MdMME(H+=5,M[le(1484)]))throw H=M[le(1484)],K.FhWSJ(_0x28db35,H,10,M[le(1484)]);continue;case"9":X=K[le(1158)](X|K[le(1372)](127&M[H],21),0);continue;case"10":if(K[le(1780)](M[H++],128))return{value:he?X:K[le(864)](0,X),offset:H};continue;case"11":if(K.QVLOB(M[H++],128))return{value:he?X:0|X,offset:H};continue}break}}}else W=e[i(1047)](e[i(870)](31,L),6)|e[i(1660)](63,P),e[i(463)](W,128)?I+=m:(I+=e[i(1014)](l,W),g++);else e[i(582)](_0x595b41,2048)?_0x214403[_0x92c7a8++]=e[i(1308)](e[i(1165)](e.aoCtO(_0x591712,6),31),192):(e[i(1269)](_0xd9b4c9,65536)?_0x2975c3[_0x241862++]=e[i(1974)](e.fDZos(e[i(1893)](_0xfa673f,12),15),224):(_0x131003[_0x3769c4++]=e[i(1145)](e[i(1165)](e.yzJxy(_0xa0bdce,18),7),240),_0xfce2e[_0x17ad45++]=e[i(1444)](e[i(960)](_0x3ea6d9,12),63)|128),_0x2d8577[_0x1972b2++]=e.txnGx(e[i(639)](e[i(649)](_0x46a0a2,6),63),128)),_0x386e1c[_0x567efa++]=e.bicEC(63,_0x1cb829)|128;else if(e[i(2005)](e[i(1900)](240,L),224))if(e[i(1655)](g,2)>=n)I+=m;else if(P=h[e[i(766)](e.lvnmp(g,f),1)],F=h[e.fXpuf(e[i(1009)](g,f),2)],e[i(980)](e.teVnx(e[i(541)](P,F<<8),49344),32896))I+=m;else if(e[i(454)](e[i(483)],e[i(1048)])){let K=e[i(2038)](_0x265be2,_0x94d504,1);_0x12b042[i(1283)][K]=_0x19383b}else W=e.LVDsx(e.rHuyn(e.iVbjV(e.CerDb(15,L),12),e[i(1457)](e[i(1571)](63,P),6)),e[i(1571)](63,F)),e.KAwdt(W,2048)||W>=55296&&e.TTwOJ(W,57343)?I+=m:(I+=e.nBxpy(l,W),g+=2);else if(e[i(1997)](e[i(726)](248,L),240))if(e[i(1781)](e.pHYwE(g,3),n))I+=m;else if(P=h[e[i(766)](g,f)+1],F=h[e[i(414)](e[i(854)](g,f),2)],G=h[e[i(854)](e[i(1127)](g,f),3)],e[i(1022)](P|e[i(1457)](F,8)|e[i(543)](G,16),12632256)!==8421504)I+=m;else{if(e[i(1216)]!==e[i(1216)])return this["currentE"+i(1765)+i(728)+"t"];W=e[i(1965)](e[i(1407)](e.erQwB(7,L)<<18|e[i(1457)](63&P,12),e[i(536)](63&F,6)),e[i(726)](63,G)),e[i(929)](W,65536)||e[i(1222)](W,1114111)?I+=m:(W-=65536,I+=e[i(987)](l,e[i(1573)](W>>10,55296),e[i(1338)](1023&W,56320)),g+=3)}else I+=m}return I}function Fe(o,n){let i=t;if(e[i(1243)]("ZhuXK",e[i(1918)]))throw this[i(1556)+i(1628)]=!1,_0x2264a8;{let f=n[i(1484)],l=0;for(let I=0;I<f;I++){let g=n[i(1954)+"At"](I);e[i(651)](g,55296)&&e.jQsgz(g,56319)&&e.IqBaS(I+1,f)&&(g=e[i(1875)](e[i(1195)](g<<10,n[i(1954)+"At"](++I)),56613888)),l+=g<128?1:e[i(625)](g,2048)?2:e[i(682)](g,65536)?3:4}e.HWcFU(te,o,l);let h=q(o,l),m=o[i(1283)];for(let I=0;e[i(633)](I,f);I++){let g=n[i(1954)+"At"](I);g>=55296&&e[i(689)](g,56319)&&e.xRJYO(I,1)<f&&(g=e[i(1859)](e[i(1653)](g,10),n[i(1954)+"At"](++I))-56613888),e[i(1205)](g,128)?m[h++]=g:(g<2048?m[h++]=e[i(833)](g>>6&31,192):(e.RVZvN(g,65536)?m[h++]=e[i(1145)](e[i(970)](e[i(818)](g,12),15),224):e.sLvda(e[i(627)],e.NlCMs)?(m[h++]=e[i(1145)](e[i(1771)](e[i(670)](g,18),7),240),m[h++]=e[i(1825)](e[i(960)](g,12),63)|128):this[i(1326)]?.del(_0x26cf7c[i(1527)+"id"]),m[h++]=e[i(1369)](e[i(1892)](e[i(649)](g,6),63),128)),m[h++]=e[i(1165)](63,g)|128)}}}function ct(o,n){let i=t;if(e[i(2015)](e[i(1790)],e.SoYXV)){let f=e[i(1717)](q,o,n[i(1964)]),l=o[i(1283)],h=n[i(1283)];for(let m=0,I=n.limit;e[i(463)](m,I);m++)l[e[i(1249)](m,f)]=h[m]}else return!!_0x14035d?.find(f=>f.key===_0x3aa7b7&&f[i(1714)]===_0x38017c)}function ke(o){let n=t;if(e[n(531)](e[n(1722)],e[n(991)]))_0x441f22.log(_0x3f96f2);else return o[n(1283)][Z(o,1)]}function Wt(o,n){let i=t,f=e[i(578)](q,o,1);o.bytes[f]=n}function Ie(o){let n=t,i=0,f=0,l;do l=e[n(813)](ke,o),e[n(2017)](i,32)&&(f|=(127&l)<<i),i+=7;while(e[n(1022)](128,l));return f}function te(o,n){let i=t;for(n>>>=0;n>=128;)e[i(1273)](Wt,o,e[i(870)](127,n)|128),n>>>=7;e.yGoAk(Wt,o,n)}function qn(o,n){let i=t,f=0,l=0,h=0,m;return m=e[i(1008)](ke,o),f=e[i(747)](127,m),128&m&&(m=e[i(1291)](ke,o),f|=e.QGlRQ(e.Rlvpq(127,m),7),e.JyZTZ(128,m)&&(m=ke(o),f|=e[i(894)](e[i(1900)](127,m),14),e[i(726)](128,m)&&(m=ke(o),f|=e.iVbjV(127&m,21),e[i(1488)](128,m)&&(m=e[i(716)](ke,o),l=127&m,e[i(828)](128,m)&&(m=e[i(1555)](ke,o),l|=e[i(1047)](e[i(674)](127,m),7),e[i(547)](128,m)&&(m=e.dMcJE(ke,o),l|=e[i(1754)](e[i(674)](127,m),14),e[i(1825)](128,m)&&(i(1380)===i(1850)?(_0x1b9b64(_0x339e67,32),e[i(1788)](_0x434bf6,_0x5e73e1,_0x46bc4c(_0x4079ad))):(m=ke(o),l|=e.iVbjV(e[i(1488)](127,m),21),128&m&&(m=e[i(1018)](ke,o),h=e[i(1101)](127,m),e.fcuJf(128,m)&&(m=e.nwart(ke,o),h|=e[i(1912)](127,m)<<7)))))))))),{low:e[i(1642)](f,e[i(2047)](l,28)),high:e[i(1668)](l,4)|e.nECdF(h,24),unsigned:n}}function Ee(o,n){let i=t,f=n.low>>>0,l=e.yFrGq(e[i(1974)](e[i(1436)](n[i(863)],28),e[i(536)](n[i(1119)],4)),0),h=e.czExx(n[i(1119)],24),m=e.ZaToh(0,h)?e[i(1070)](0,l)?e[i(625)](f,16384)?e[i(919)](f,128)?1:2:f<2097152?3:4:e.uNFQm(l,16384)?e[i(849)](l,128)?5:6:e[i(1010)](l,2097152)?7:8:h<128?9:10,I=e.jdEXv(q,o,m),g=o[i(1283)];switch(m){case 10:g[e[i(1526)](I,9)]=e.nrUjM(e[i(1436)](h,7),1);case 9:g[e[i(1104)](I,8)]=m!==9?e.TWrpA(128,h):127&h;case 8:g[e[i(703)](I,7)]=e[i(1832)](8,m)?e[i(1407)](l>>>21,128):e[i(1166)](e[i(1929)](l,21),127);case 7:g[e[i(532)](I,6)]=e[i(1183)](7,m)?e[i(503)](e[i(1061)](l,14),128):e[i(437)](e.wOztz(l,14),127);case 6:g[e.YKtPi(I,5)]=e.bjCsR(6,m)?e[i(1179)](e[i(1929)](l,7),128):e[i(1847)](l,7)&127;case 5:g[e[i(703)](I,4)]=e.DPtDk(5,m)?e.txnGx(128,l):e[i(437)](127,l);case 4:g[e[i(1104)](I,3)]=m!==4?e[i(2048)](f,21)|128:e[i(922)](f>>>21,127);case 3:g[e[i(1801)](I,2)]=e[i(1889)](3,m)?e[i(1436)](f,14)|128:e[i(1614)](e[i(1847)](f,14),127);case 2:g[e.eUCGg(I,1)]=e[i(816)](2,m)?e[i(541)](f>>>7,128):e[i(1336)](f>>>7,127);case 1:g[I]=e[i(1615)](1,m)?e[i(503)](128,f):e[i(472)](127,f)}}function Hn(o){return e.GjZMI(E,o)}function Ve(o){return e.shZGq(S,o)}let l0=65536,Yx=e[t(1812)],jn=e[t(900)](l0,l0),x0=e[t(709)](jn,jn),h0=x0/2,Kt=String[t(1397)+"e"][t(1954)+"At"];class de{constructor(n,i,f){let l=t;this.isLong=!0,this[l(863)]=e[l(1407)](0,n),this[l(1119)]=e.ePqVq(0,i),this.unsigned=!!f}static[t(2035)](n){let i=t;return n&&e[i(1148)](!0,n[i(2035)])}static[t(436)](n,i,f){return new de(n,i,f)}static[t(897)+"s"](n,i,f){let l=t;return f?de[l(897)+l(1652)](n,i):de[l(897)+l(477)](n,i)}static[t(897)+t(1652)](n,i){let f=t;return new de(e.TWrpA(e[f(1105)](n[0]|n[1]<<8,e[f(1754)](n[2],16)),n[3]<<24),e[f(685)](e[f(1105)](e[f(1903)](n[4],e.IIrDX(n[5],8)),n[6]<<16),e[f(536)](n[7],24)),i)}static[t(897)+t(477)](n,i){let f=t;return new de(e.FfNvp(e[f(541)](e.SySUg(e[f(737)](n[4],24),e.QGlRQ(n[5],16)),e.vHQdo(n[6],8)),n[7]),e[f(1724)](e[f(1689)](e[f(1664)](n[0],24),e[f(1961)](n[1],16)),e[f(1457)](n[2],8))|n[3],i)}static fromHash(n){let i=t;return e[i(1631)](n,Yx)?p0:new de(e[i(1789)](e[i(541)](e[i(1145)](Kt[i(516)](n,0),Kt[i(516)](n,1)<<8),e.pBAhk(Kt[i(516)](n,2),16)),e[i(840)](Kt[i(516)](n,3),24))>>>0,e.wOztz(e[i(1689)](e[i(1569)](e[i(988)](Kt[i(516)](n,4),Kt[i(516)](n,5)<<8),e[i(1457)](Kt[i(516)](n,6),16)),Kt[i(516)](n,7)<<24),0),!0)}[t(1688)](){let n=t;return String.fromCharCode(e[n(520)](255,this.low),this.low>>>8&255,e.kTWZe(this.low>>>16,255),this[n(863)]>>>24,e.ZWmRT(255,this.high),e[n(639)](e[n(1350)](this[n(1119)],8),255),e[n(1842)](e[n(1668)](this[n(1119)],16),255),e.yFrGq(this[n(1119)],24))}static fromNumber(n,i=!0){let f=t;if(e[f(1008)](isNaN,n))return i?Qx:p0;if(i){if(e[f(1093)](n,x0))return th}else{if(e[f(1495)](n,-h0))return nh;if(e[f(811)](e[f(532)](n,1),h0))return eh}return de.fromBits(e[f(541)](e[f(1279)](n,jn),0),e[f(1718)](n,jn)|0,i)}[t(619)](){let n=t;return this[n(1442)]?e.pYNQM(e[n(900)](this[n(1119)]>>>0,jn),e.fGFFk(this.low,0)):e.pYNQM(e[n(900)](this[n(1119)],jn),this[n(863)]>>>0)}isZero(){let n=t;return this[n(1119)]===0&&e[n(1838)](0,this[n(863)])}add(n){let i=t;de[i(2035)](n)||(n=de[i(1738)+"er"](n));let f=e[i(2037)](this.high,16),l=e[i(1488)](65535,this[i(1119)]),h=e[i(473)](this[i(863)],16),m=e[i(814)](65535,this[i(863)]),I=n.high>>>16,g=e[i(1842)](65535,n.high),L=n[i(863)]>>>16,P=e[i(1645)](65535,n[i(863)]),F=0,G=0,W=0,K=0;return K+=e[i(1629)](m,P),W+=K>>>16,K&=65535,W+=e[i(512)](h,L),G+=e[i(1847)](W,16),W&=65535,G+=e[i(946)](l,g),F+=G>>>16,G&=65535,F+=e[i(542)](f,I),F&=65535,de[i(436)](e[i(1777)](e[i(1285)](W,16),K),e[i(933)](F,16)|G,this.unsigned)}equals(n){let i=t;return e.FMhDo(e[i(1337)],"LUZPb")?(_0x45cee2[i(1579)](_0x40ebe4(this),_0x136027),_0x13857c(_0x19f7fa[i(1894)](this))):(de.isLong(n)||(n=de.fromNumber(n)),this[i(1442)]!==n[i(1442)]&&this[i(1119)]>>>31===1&&e[i(1857)](e[i(1668)](n[i(1119)],31),1)?!1:e.TPzLr(this[i(1119)],n[i(1119)])&&e[i(1557)](this[i(863)],n.low))}[t(1247)](){let n=t;if(e[n(1838)](e[n(697)],e.pWsiZ)){if(this[n(575)+"ngTimer"](),this._clearTimer(),this._removeWsListeners(),this[n(1164)+"nceClose"](1e3,_0x536845),this[n(1556)+n(1628)]=!1,_0x457e44&&this[n(1945)+n(467)]()&&!this[n(687)+n(799)]){if(this[n(1529)+n(1736)]?.[n(783)+"chMaxTries"]()){let f=this[n(1529)+"tManager"]?.[n(1561)+n(1791)+"nt"]();this[n(1695)+n(1740)+"ent"](e[n(1743)](_0x3a7db7,n(1418),{code:1006,reason:"connect "+f+(" timeout, max retries re"+n(1784)),wasClean:!0}))}else{let f=this[n(647)]["reconnec"+n(1578)+n(1258)](_0x4a8c16,_0x540630);this[n(1695)+n(1740)+n(640)](e[n(1683)](_0x5e4409,e[n(2067)],{code:_0x30b69f,reason:_0x511322,wasClean:!0,willReconnect:f})),f&&this[n(1556)]()}return}this[n(1945)+"orOnline"]()||this[n(687)+"osed"]?this[n(1695)+"hCloseEv"+n(640)](_0x4be1a5(e[n(2067)],{code:_0x1b6a73,reason:e[n(1358)]})):this[n(1695)+"hCloseEv"+n(640)](e[n(518)](_0x536ba6,e[n(2067)],{code:1006,reason:e[n(1151)]})),this[n(1482)]=null,this[n(1529)+n(1736)]?.resetEndpointConfig(),this[n(1388)+"sCounter"]?.[n(537)+n(1197)]()}else return e[n(722)](-1,this[n(863)])&&e.SPZTs(-1,this.high)?de[n(436)](0,0,this.unsigned):e.AdwZR(-1,this.low)?de[n(436)](0,e[n(1859)](this[n(1119)],1),this[n(1442)]):de[n(436)](this.low+1,this[n(1119)],this[n(1442)])}toBytes(n){let i=t;if(i(458)==="EzsBb")this.count++;else return n?this.toBytesLE():this[i(2031)+"E"]()}[t(798)+"E"](){let n=t,i=this.high,f=this[n(863)];return[e[n(1301)](255,f),e[n(969)](e[n(1061)](f,8),255),f>>>16&255,e[n(872)](f,24),e[n(939)](255,i),e[n(1948)](i,8)&255,e[n(554)](e.LRWhD(i,16),255),e[n(1929)](i,24)]}[t(2031)+"E"](){let n=t,i=this.high,f=this.low;return[e.MyGja(i,24),e[n(1614)](e[n(1847)](i,16),255),e[n(437)](i>>>8,255),e[n(1704)](255,i),e[n(628)](f,24),e[n(872)](f,16)&255,e[n(922)](e[n(1654)](f,8),255),e[n(522)](255,f)]}}let p0=new de(0,0,!1),Qx=new de(0,0,!0),eh=de[t(436)](-1,2147483647,!1),th=de.fromBits(-1,-1,!0),nh=de[t(436)](0,-2147483648,!1);var $t=(function(o){let n=t,i=e[n(1853)].split("|"),f=0;for(;;){switch(i[f++]){case"0":o[o[n(740)+"OR"]=5005]=e[n(1102)];continue;case"1":o[o[e[n(1824)]]=5004]=n(1822)+"ERROR";continue;case"2":o[o[e[n(573)]]=5001]=n(1504)+n(1280);continue;case"3":return o;case"4":o[o[e[n(1535)]]=5003]=e[n(1535)];continue;case"5":o[o[e.xKiiA]=5002]=e[n(1402)];continue}break}})({});class Gn{constructor(n){let i=t;this[i(557)]=n,this[i(1266)]=null}}class g0 extends Gn{constructor(n,i){let f=t;super(n),this[f(1703)]=i&&i[f(1703)]||null}}class m0 extends Gn{constructor(n,i){let f=t,l=e[f(1998)][f(2054)]("|"),h=0;for(;;){switch(l[h++]){case"0":this[f(1685)]=i&&i[f(1685)]||null;continue;case"1":this[f(644)]=i&&i[f(644)]||0;continue;case"2":this.message=i&&i.message||"";continue;case"3":this[f(1720)]=i&&i.filename||"";continue;case"4":super(n);continue;case"5":this[f(911)]=i&&i[f(911)]||0;continue;case"6":this[f(2007)]=i&&i.code||5001;continue}break}}}class w0 extends Gn{constructor(n,i){let f=t;super(n),this[f(2007)]=i&&i[f(2007)]||0,this[f(2024)]=i&&i[f(2024)]||"",this[f(1994)]=i&&i[f(1994)]||!1,this["willReco"+f(1400)]=i&&i[f(945)+f(1400)]||!1}}class _0 extends Gn{constructor(n,i){let f=t;super(n),this[f(1969)]=i&&i.data||null}}class y0 extends _0{constructor(n,i){let f=t;super(n),this[f(1969)]=i&&i[f(1969)]||null,this[f(1703)]=i&&i[f(1703)]||null}}class b0 extends Gn{constructor(n,i){let f=t;super(n),this[f(1969)]=i&&i[f(1969)]||null}}function rt(o,{message:n,code:i,error:f}){return new m0(o,{message:n,code:i,error:f})}function ft(o,{code:n,reason:i,wasClean:f,willReconnect:l}){return new w0(o,{code:n,reason:i,wasClean:f,willReconnect:l})}function E0(o,{data:n,message:i}){let f=t,l={ryWpC:function(h,m){return e[V(1623)](h,m)},TmQup:function(h,m){return e[V(1211)](h,m)},rqXGH:function(h,m){return h>>>m},botXB:function(h,m){return e[V(1768)](h,m)},ZPWgD:function(h,m){return e[V(1721)](h,m)}};if(e[f(1522)](f(2069),e[f(1100)])){let h=this[f(1119)],m=this[f(863)];return[ULMKaZ.ryWpC(255,m),ULMKaZ.TmQup(m,8)&255,ULMKaZ[f(780)](ULMKaZ[f(1921)](m,16),255),ULMKaZ[f(1275)](m,24),ULMKaZ[f(780)](255,h),h>>>8&255,ULMKaZ[f(1921)](h,16)&255,ULMKaZ.ZPWgD(h,24)]}else return new y0(o,{data:n,message:i})}function v0(o,{data:n}){return new b0(o,{data:n})}function Bo(o,{message:n}){return new g0(o,{message:n})}class S0{constructor(n,i){let f=t;this[f(1880)+"s"]=n,this.maxRetries=i,this[f(1192)+f(1312)]=0,this[f(1404)+f(1765)+f(728)+"t"]=0}[t(1082)+t(1581)+t(600)](){let n=t;this[n(1192)+n(1312)]=0,this[n(1404)+n(1765)+n(728)+"t"]=0}resetTries(){let n=t;if(e.pQUdj(e[n(1528)],e[n(1002)]))this[n(1404)+"ndpointTriesCount"]=0;else return this["_dispatc"+n(1411)+n(662)](_0x3ad9a4),_0x2bb8a3()}["getCurre"+t(1791)+"nt"](){let n=t,i={vxQst:function(f,l){return e.rIGwY(f,l)},hsaAA:e[n(1383)],dQtTL:function(f,l){return e[n(481)](f,l)},OgyCH:function(f,l){return f+l},DILdp:function(f,l){return e[n(433)](f,l)},KFVgW:function(f,l){return e[n(688)](f,l)}};if(n(1679)===e[n(2045)])return this[n(1880)+"s"][this[n(1192)+n(1312)]];{let f=this[n(1959)+"rs"][_0x2c22f2];if(f)f[n(675)]()[n(457)](l=>l.fn[n(1579)](l.ctx,_0x1b563a));else if(i[n(1846)](i[n(1092)],_0x35f147)&&!this[n(1255)]){let l=_0x3a8c59.length&&_0x3621d9[0];if(i[n(1595)](l,_0x2d0e75))throw l;let h=new _0x4ebe5b(i[n(744)](n(1843)+n(883),l?i[n(444)](i.KFVgW(" (",l[n(1703)]),")"):""));throw h.context=l,l}return this}}[t(1561)+t(1791)+t(1440)+t(657)](){let n=t;return this[n(1404)+n(1765)+"riesCount"]}[t(783)+t(1730)+"es"](){let n=t;return!!(this[n(1192)+n(1312)]>=this[n(1880)+"s"].length||e[n(1576)](this[n(1192)+n(1312)],this.endpoints[n(1484)]-1)&&e.jLdXA(this[n(1404)+n(1765)+"riesCount"],this.maxRetries))}[t(1534)+"rentEndp"+t(845)+"hedMaxRe"+t(1466)](){let n=t;return e[n(1983)](this[n(1192)+"ndex"],this[n(1880)+"s"].length)?!0:e[n(795)](this["currentE"+n(1765)+"riesCount"],this[n(999)+"es"])}[t(1033)+t(1024)+t(1769)+t(1650)+t(1132)](){let n=t;return this[n(1404)+"ndpointT"+n(728)+"t"]=1,this[n(1192)+n(1312)]++,this[n(1880)+"s"][this[n(1192)+n(1312)]]}[t(1561)+"ntEndpoi"+t(1635)+t(1879)](){let n=t;return this[n(1404)+"ndpointT"+n(728)+"t"]++,this[n(1561)+n(1791)+"nt"]()}}let Wn=(e[t(1206)]!=typeof globalThis&&e[t(1651)](t(1871),globalThis[t(924)+t(1004)][t(1334)])||e[t(1454)](t(1592)+"d",typeof window)&&e[t(1500)](e[t(602)],window.constructor[t(1334)]))&&e[t(1454)](e[t(1206)],typeof document),yn=e[t(1206)]!=typeof globalThis&&(e[t(1109)](e[t(2028)],globalThis[t(924)+t(1004)][t(1334)])||t(1292)+t(1901)+t(1896)+"pe"===globalThis[t(924)+t(1004)][t(1334)])&&e[t(774)](e[t(1206)],typeof tt),Lr=(e.TyhGP(e[t(1206)],typeof globalThis)&&e.bEDlQ(t(914),globalThis[t(924)+t(1004)][t(1334)])||e[t(421)](t(1592)+"d",typeof globalThis)||e.qTOqO(t(1592)+"d",typeof globalThis)&&!!globalThis["WeixinJS"+t(1951)])&&e[t(1206)]!=typeof wx,Or=e[t(1260)](e[t(1206)],typeof globalThis)&&(e[t(1798)]===globalThis[t(924)+t(1004)][t(1334)]||e[t(1063)](e.DWZzn,globalThis[t(924)+t(1004)][t(1334)])||e[t(1640)](e[t(2014)],globalThis[t(924)+t(1004)][t(1334)]))&&e[t(1469)](t(1592)+"d",typeof self),rh=e[t(1567)](e[t(1206)],typeof globalThis)&&e[t(1232)](t(914),globalThis[t(924)+t(1004)][t(1334)])&&e[t(774)](e.wpLtA,typeof global)&&e[t(2028)]===global[t(924)+"tor"][t(1334)]&&e.YRojx(t(1592)+"d",typeof process)&&!!process[t(2001)];class zo{constructor(){let n=t;this[n(1959)+"rs"]={}}[t(905)](n,...i){let f=t;if(e.fQovf(e.BUQje,e[f(664)])){let l=this[f(1959)+"rs"][n];if(l)l.slice()[f(457)](h=>h.fn.apply(h[f(2057)],i));else if(e[f(1383)]===n&&!this.onerror){let h=i.length&&i[0];if(e[f(481)](h,Error))throw h;let m=new Error(e[f(1526)](e[f(779)],h?e[f(1006)](e[f(1118)](" (",h.message),")"):""));throw m[f(636)]=h,h}return this}else return this[f(1326)][f(1437)]}[t(1199)](n,i){let f=t;if(e[f(1807)](void 0,n))this[f(1959)+"rs"]={};else if(i===void 0)this[f(1959)+"rs"][n]=null;else{let l=this[f(1959)+"rs"][n];if(l)for(let h=0;e[f(462)](h,l[f(1484)]);)e[f(1576)](l[h].fn,i)?l[f(684)](h,1):++h}return this}on(n,i,f){let l=t;if(e[l(1838)](e[l(1637)],e[l(1637)]))return(this[l(1959)+"rs"][n]||(this[l(1959)+"rs"][n]=[]))[l(1851)]({fn:i,ctx:f||this}),this;_0xcfa10e.o=(h,m)=>_0x23a00a.prototype[l(1403)+"operty"][l(516)](h,m)}}class ih extends zo{[t(585)+t(1410)+t(1646)](n){let i=t;return n[i(1735)]||n[i(592)]?(i(1493)+" "+(n[i(1735)]||"")+i(718)+(n[i(592)]||""))[i(1944)]():JSON[i(535)+"y"](n)}constructor(n,i,f){let l=t;super(),this[l(604)]=null,Lr&&wx[l(1797)+"ocket"]&&(this[l(604)]=wx[l(1797)+l(955)]({url:n,protocols:i,header:f,fail:this["_createSocketFai"+l(860)][l(586)](this),success:this[l(1252)+"ocketSuc"+l(1066)+l(1217)][l(586)](this)})),yn&&tt[l(1797)+"ocket"]&&(this[l(604)]=tt["connectS"+l(955)]({url:n,protocols:i,header:f,fail:this[l(1252)+l(642)+l(860)][l(586)](this),success:this[l(1252)+l(1053)+"cessHand"+l(1217)].bind(this)}))}[t(1252)+"ocketSuccessHand"+t(1217)](){let n=t;Promise[n(1445)]()[n(1313)](()=>{let i=n;this[i(1627)+i(569)]()})}[t(1252)+t(642)+t(860)](n){let i=t;Promise[i(1445)]()[i(1313)](()=>{let f=i,l=e[f(1088)](rt,e.fXRdW,{message:this["_formatE"+f(1410)+f(1646)](n)});this.emit(e[f(1383)],l);let h=ft(f(1418),{reason:this[f(585)+f(1410)+f(1646)](n)});this[f(905)](f(1418),h)})}["_addWsLi"+t(569)](){let n=t,i={XWzMO:function(f,l,h){return e[V(1115)](f,l,h)},DXzXl:e[n(794)],UWWPt:e[n(1125)],TxqvF:function(f,l){return e[n(541)](f,l)},zuUHM:function(f,l){return f<<l},LTmmX:function(f,l){return e.ckBMC(f,l)},mnfPY:function(f,l){return f&l},EuZXh:function(f,l){return e[n(849)](f,l)},oWhfd:function(f,l){return e[n(1974)](f,l)},AZLcL:function(f,l){return e.QGlRQ(f,l)},ylhrV:function(f,l){return e.IPpTv(f,l)},xpIHh:function(f,l,h,m){return e.CFJcx(f,l,h,m)},eEdDZ:function(f,l){return f<l},WtorF:function(f,l){return e[n(1852)](f,l)},CUTot:function(f,l){return e[n(1681)](f,l)},YixqY:e.izqpT,jXgze:n(1418),uUbrj:function(f,l,h){return e[n(1932)](f,l,h)},fBGnK:function(f,l){return f|l},UPnBI:function(f,l){return e.JafyW(f,l)},nkHwy:function(f,l){return e[n(1457)](f,l)},WoVdI:function(f,l){return e.mDuID(f,l)},hJmpU:function(f,l){return e[n(1892)](f,l)},mKMGv:function(f,l){return e[n(756)](f,l)},sjCCM:function(f,l){return e.edLwD(f,l)},yHQdW:function(f,l){return f&l}};this._socket.onOpen(f=>{let l=n;this.emit(l(789),i[l(1152)](v0,i[l(422)],{...f,data:f[l(1735)]||""}))}),this._socket[n(865)](f=>{let l=n;if(i[l(445)](l(934),i[l(1819)])){let h=i[l(1406)][l(2054)]("|"),m=0;for(;;){switch(h[m++]){case"0":_0x266549=i[l(450)](_0x106d95,i.zuUHM(127&_0x3d5a55[_0x121970],7))>>>0;continue;case"1":_0x3aa5f5=i[l(1497)](i[l(450)](_0x503254,i[l(699)](15,_0x3d868b[_0x5b2160])<<28),0);continue;case"2":if(i[l(2053)](_0x1ab3d1[_0x321d65++],128))return{value:_0x5dd9e5?_0x2f2b17:i.TxqvF(0,_0x2ae9b9),offset:_0xb72648};continue;case"3":if(_0x163b2d[_0x4d014c++]<128)return{value:_0x1ea02c?_0x590c41:i[l(450)](0,_0x3c86a3),offset:_0x4058f3};continue;case"4":if(_0x2d86a5[_0x11da88++]<128)return{value:_0x34ddf5?_0x5e7274:i.oWhfd(0,_0x3f204b),offset:_0x5cec9d};continue;case"5":_0x91944c=i[l(1975)](_0x158747,i[l(1029)](127&_0x26c52e[_0x5ae079],14))>>>0;continue;case"6":if(i[l(1005)](_0x265c53+=5,_0x329d89[l(1484)]))throw _0x590cf8=_0x2e14ed.length,i[l(963)](_0x57554f,_0x1898a4,10,_0x2a4e3f[l(1484)]);continue;case"7":return{value:_0x196bf4?_0x41e70e:i[l(450)](0,_0x592a4b),offset:_0x2d2271};case"8":_0x24b07f=i[l(699)](127,_0x2b5ffc[_0x1e7ff0])>>>0;continue;case"9":if(i[l(1982)](_0x3e0bcb[_0x3ad009++],128))return{value:_0xc0bafc?_0xf787c8:i[l(1181)](0,_0x58bff4),offset:_0x2d44de};continue;case"10":_0x4a25c2=i.oWhfd(_0x1e2120,(127&_0x48fbe8[_0x1a61bf])<<21)>>>0;continue;case"11":if(i[l(1982)](_0x40cb86[_0x16ccaf++],128))return{value:_0x5994cd?_0x214711:i[l(1181)](0,_0x1293e2),offset:_0x37fe99};continue}break}}else this[l(905)](i.jXgze,i[l(1657)](ft,i[l(1548)],{...f}))}),this[n(604)][n(995)+"e"](f=>{let l=n;if(e[l(816)](e.fgtaY,l(880))){let h=i[l(450)](i.fBGnK(i[l(1409)]((7&_0x221779)<<18,i.nkHwy(i[l(699)](63,_0x4b0caf[_0x1207f6++]),12)),i[l(832)](i.hJmpU(63,_0x33208e[_0x170ae8++]),6)),i[l(1601)](63,_0x195a04[_0x509e2a++]))-65536;_0x5b494f+=_0x18eec7[l(574)+l(430)](i[l(1294)](55296,h>>10)),_0x4a4fac+=_0x286e07["fromChar"+l(430)](i.sjCCM(56320,i.yHQdW(1023,h)))}else this.emit(e[l(1817)],e[l(1271)](E0,l(1703),{...f}))}),this[n(604)].onError(f=>{let l=n;this[l(905)](l(1685),e[l(1115)](rt,e.fXRdW,{...f,message:f[l(1735)]||""}))})}send(n){let i=t,f={VKDLy:function(l,h){return e[V(1140)](l,h)},mFXJw:function(l,h){return e[V(1542)](l,h)},mTHLJ:e.fCsVQ,lJTTu:function(l,h){return e[V(425)](l,h)},GQUeE:e.QOEFb,OEyVE:e[i(1383)],ZqJrN:function(l,h,m){return e.cRGLE(l,h,m)}};if(e.ReXuZ(n,Uint8Array)){let l=n.buffer[i(675)](n[i(871)+"et"],e[i(1161)](n[i(538)+"th"],n[i(871)+"et"]));this[i(604)]&&this._socket.send({data:l,fail:h=>{let m=i;if(f[m(679)](m(1621),f.GQUeE)){if(gAfHro[m(504)](gAfHro.mFXJw(_0x2daa76[m(758)],_0x24828d),_0x1bf856[m(1964)]))throw new _0x591dcc(gAfHro[m(1541)]);_0x3a9685[m(758)]+=_0xe94a48}else this[m(905)](f[m(1062)],f[m(562)](rt,f[m(1062)],{message:this[m(585)+m(1410)+m(1646)](h)}))}})}else this._socket&&this[i(604)][i(1076)]({data:n,fail:l=>{let h=i;this[h(905)](e.fXRdW,e.jWGre(rt,e[h(1383)],{message:this["_formatE"+h(1410)+"age"](l)}))}})}[t(1418)](n,i){let f=t;this[f(604)]&&this[f(604)][f(1418)]({code:n,reason:i})}[t(908)+t(1558)](n,i){this.on(n,i)}[t(1839)+t(550)+t(951)](n,i){this.off(n,i)}get[t(751)+"te"](){return this[t(604)].readyState}get[t(1201)+"pe"](){let n=t;return this[n(604)][n(1201)+"pe"]}set[t(1201)+"pe"](n){}get url(){let n=t;return this[n(604)][n(708)]}get[t(2020)](){let n=t;return this[n(604)][n(2020)]}get extensions(){let n=t;return this._socket[n(961)+"ns"]}get bufferedAmount(){let n=t;if(e.ihhiN!==e[n(1666)]){let{enableAutoAck:i}=this[n(647)],f=e[n(1067)](_0x248e70,_0x58d18e.message[n(2039)],e[n(459)],"1"),l=e[n(1250)](_0x46bb96,_0x5ccfbb[n(1703)][n(2039)],e[n(931)],"1"),h=_0x51ae33[n(516)](this,_0x53d3ce);if(i&&f){let{SeqID:m,LogID:I,service:g,LogIDNew:L,method:P}=_0x1c84b3[n(1703)];this._sendAck({SeqID:m,LogID:I,LogIDNew:L,service:g,method:P,headers:[{key:e[n(931)],value:"1"},{key:e[n(1906)],value:e[n(898)](L,"")},{key:e[n(1357)],value:"0"}]})}l&&!h.isQoSAck&&this[n(1695)+n(1530)+n(1362)](_0x232150),e.kWpRN(_0x64eed1)}else return 0}}function sh(o,n){let i=t;if(n)return new n(o[i(708)],o.protocol);if(e.YQyeT(Lr,yn))return new ih(o[i(708)],o.protocol,o.headers);if(e[i(898)](Wn,Or)&&e[i(1454)](e[i(1206)],typeof WebSocket)&&WebSocket)return new WebSocket(o.url,o[i(2020)+"s"])}function oh(o){let n=t,i=e[n(1154)].split("|"),f=0;for(;;){switch(i[f++]){case"0":return!1;case"1":if(Lr&&wx[n(1797)+n(955)])return!0;continue;case"2":if(yn&&tt[n(1797)+n(955)])return!0;continue;case"3":if(o)return!0;continue;case"4":if(e.YQyeT(Wn,Or)&&typeof WebSocket<"u"&&WebSocket)return!0;continue}break}}function I0(o,n,i){let f=t,l=-1;async function h(m){let I=V;return e[I(1604)](m,l)?Promise[I(1669)](new Error(e[I(1317)])):(l=m,e[I(1701)](m,i.length)?Promise[I(1445)]():i[m].bind(o)(n,h[I(586)](null,e[I(1545)](m,1))))}e[f(634)](h,0)}function C0(o){let n=t,i=0,f=0;for(let l=0;e[n(1741)](l,o[n(1484)]);++l)f=o[n(1954)+"At"](l),e.VkvaN(f,128)?i+=1:f<2048?i+=2:e[n(1848)](e[n(1745)](64512,f),55296)&&(64512&o.charCodeAt(e[n(671)](l,1)))===56320?(++l,i+=4):i+=3;return i}function A0(o,n,i){let f=t;if(e[f(620)](i-n,1))return"";let l="";for(let h=n;e[f(822)](h,i);)if(e[f(1947)](e[f(530)],f(1413))){let m=o[h++];if(e[f(1537)](m,127))l+=String[f(574)+f(430)](m);else if(e[f(651)](m,192)&&m<224)l+=String["fromChar"+f(430)](e[f(1034)](e[f(552)](e[f(527)](31,m),6),e[f(1745)](63,o[h++])));else if(e[f(651)](m,224)&&e[f(548)](m,240))l+=String[f(574)+f(430)](e[f(1345)](e[f(823)](e[f(1126)](15&m,12),e[f(738)](63,o[h++])<<6),e[f(1488)](63,o[h++])));else if(m>=240){let I=e.gyReU(e.mmkVC(e.DlNwm(e[f(685)](e[f(879)](7&m,18),e.QGlRQ(e[f(1899)](63,o[h++]),12)),e[f(1180)](e[f(1745)](63,o[h++]),6)),e.PeiXO(63,o[h++])),65536);l+=String["fromChar"+f(430)](55296+e[f(1049)](I,10)),l+=String[f(574)+f(430)](e[f(1236)](56320,e.MfbYu(1023,I)))}}else++_0x3120b7,_0x16b914+=4;return l}function Fo(o,n,i){let f=t,l={eezNQ:function(h,m){return e.wJccN(h,m)},bvVix:f(1418)};if(e.SnWQd(e.iDYlF,e[f(1142)])){let h=this._messageQueue[f(785)]((m,I)=>(m+=I&&I.byteLength||0,m),0);return l[f(855)](h,this[f(1482)]?this[f(1482)][f(1365)+f(1935)]:0)}else{let h=i,m,I;for(let g=0;g<o.length;++g)if(m=o[f(1954)+"At"](g),e[f(834)](m,128))n[i++]=m;else if(e.RVZvN(m,2048))if(e[f(1701)](e.gezhC,e[f(623)]))n[i++]=e.yzJxy(m,6)|192,n[i++]=e[f(1129)](63,m)|128;else{if(this["_endpoin"+f(1736)]?.checkReachMaxTries()){let P=this[f(1529)+"tManager"]?.getCurrentEndpoint();this[f(1695)+f(1740)+"ent"](_0x21f893(f(1418),{code:1006,reason:f(1873)+P+(" timeout"+f(528)+f(1335)+f(1784)),wasClean:!0}))}else{let P=this._options[f(1157)+f(1578)+f(1258)](_0x1c4537,_0xf173c);this[f(1695)+f(1740)+"ent"](_0x29b605(l[f(691)],{code:_0x3e2300,reason:_0x384221,wasClean:!0,willReconnect:P})),P&&this._connect()}return}else if((64512&m)===55296&&e.pdnYH(e[f(747)](64512,I=o.charCodeAt(e.dUzOW(g,1))),56320)){let L=e[f(1787)][f(2054)]("|"),P=0;for(;;){switch(L[P++]){case"0":n[i++]=e[f(479)](m>>12,63)|128;continue;case"1":n[i++]=e[f(715)](e[f(670)](m,6),63)|128;continue;case"2":n[i++]=m>>18|240;continue;case"3":++g;continue;case"4":m=e[f(414)](65536+e[f(1047)](e[f(1239)](1023,m),10),e[f(1825)](1023,I));continue;case"5":n[i++]=e.jfKuT(e[f(554)](63,m),128);continue}break}}else n[i++]=e.txnGx(e[f(989)](m,12),224),n[i++]=e[f(1345)](e[f(1204)](e[f(1464)](m,6),63),128),n[i++]=e[f(547)](63,m)|128;return e.wpiNy(i,h)}}async function T0(o){let n=t,i={lBQDc:e[n(2016)]};if(e[n(1744)](e[n(2025)],typeof o))if(e[n(1644)](e[n(1477)],"CMFxY"))this[n(647)].debug&&_0x26cfe3[n(916)][n(1579)](_0x3c910d,[i[n(706)],..._0x425a0e]);else{let f=new Uint8Array(e[n(1501)](C0,o));return e[n(1137)](Fo,o,f,0),f}return o instanceof ArrayBuffer?new Uint8Array(o):new Uint8Array(o.buffer,o[n(871)+"et"],o[n(538)+"th"])}function ah(o){let n=t;try{return e[n(2025)]!=typeof o&&(o instanceof ArrayBuffer||o[n(1441)]&&e[n(577)](o.buffer,ArrayBuffer))||e[n(1454)](n(1940),typeof o)?"":(JSON[n(765)](o),e[n(1234)])}catch{return e.cPtRW(e[n(2025)],typeof o)?e[n(1937)]:""}}let ch=(o,n)=>{let i=t;switch(o){case e[i(1638)]:case e.OeSwG:return{[i(1347)+o]:1,"x-tt-env":n};default:return{}}};class fh{constructor(n){let i=t;this[i(1609)+i(657)]=n,this[i(1307)]=0}[t(1432)](){let n=t;this[n(1307)]++}[t(783)+t(1533)+"nt"](){let n=t;return this[n(1307)]>=this[n(1609)+n(657)]}[t(537)+"nter"](n=0){let i=t;this["maxLossC"+i(657)]=n,this[i(1307)]=0}}async function dh(o){return new Promise(n=>{let i=V,f={rLrnR:function(l,h){return e.SPZTs(l,h)},vEbqi:e[i(1471)],VCllC:function(l,h){return e.LFegw(l,h)},VHuzb:e[i(1671)]};if(e[i(777)]===e[i(777)]){if(!Wn)return e[i(813)](n,e[i(1671)]);try{let l=document[i(1708)+i(1949)](e[i(435)]);window[i(761)+i(912)]=h=>{let m=i;if(f[m(749)]!==f[m(749)]){let I=_0x66b79c[m(1283)],g=_0x5b4b19.limit;return pQWbTx[m(1511)](I[m(1484)],g)?I:I[m(791)](0,g)}else document.body[m(759)+m(1025)](l),window["frontier"+m(912)]=void 0,f.VCllC(n,h&&h[m(1322)]||f[m(741)])},l.type=e[i(1449)],l[i(1172)]=e[i(532)](o.replace(/^ws/,i(1343)),i(565)+i(952)+i(661)+"P");try{document[i(926)].appendChild(l)}catch{document.body["removeCh"+i(1025)](l)}}catch{window[i(761)+i(912)]=void 0,n(i(1276)+i(2024))}}else _0x88a9d1[i(2011)+i(975)+"e"](_0xbc6f09,{keyPath:_0x22873b})})}function Vt(o,n,i){let f=t;return!!o?.find(l=>l.key===n&&l[f(1714)]===i)}function Kn(o,n){let i=t;return e[i(752)](e[i(899)],i(1854))?o?.find(f=>f[i(1910)]===n)?.[i(1714)]:new _0x21668d(_0x2a355f,{message:_0x65500d})}let Uo=null;async function uh(){let o=t;return Uo||(Uo=Promise.resolve().then(Dt[o(586)](Dt,e[o(598)]))),Uo}class lh extends zo{constructor(n,i){let f=t,l={SHsmn:function(h,m){return e[V(913)](h,m)},DFPHK:function(h,m){return e[V(1126)](h,m)},wAMgH:function(h,m){return e[V(1966)](h,m)},MmIgA:function(h,m){return e[V(840)](h,m)}};if(e[f(603)]!==e[f(949)])super(),this._dbName=n,this[f(1916)]=i,this[f(1326)]=void 0,this["_initPro"+f(859)]=null;else return new _0x27b7fc(VOtWsR[f(1120)](VOtWsR[f(1120)](VOtWsR[f(1120)](_0x5a174d[0],VOtWsR[f(868)](_0x24528e[1],8)),VOtWsR[f(868)](_0x3be4d9[2],16)),VOtWsR[f(868)](_0x980490[3],24)),VOtWsR[f(1120)](VOtWsR.SHsmn(_0xe18cb3[4],_0x4f8cee[5]<<8)|VOtWsR[f(1620)](_0x39728c[6],16),VOtWsR[f(668)](_0x30cbfb[7],24)),_0x3dffd5)}async[t(1973)](){await this[t(1596)]()}async _init(){let n=t,i={NJrBn:e.uPoGQ,pHwzk:function(f){return e[V(1808)](f)},Oeeuu:function(f,l){return e[V(1501)](f,l)},ilgHV:function(f,l){return e[V(1210)](f,l)},rBZXQ:function(f,l){return e[V(1244)](f,l)},IQUPr:function(f,l){return e[V(437)](f,l)},Kuscw:function(f,l){return e.KcEHW(f,l)}};if(!this[n(1326)]){if(this[n(1089)+n(859)])return this[n(1089)+"mise"];try{if(e[n(1665)](e[n(669)],e[n(669)])){let f=this._dbName,l=this[n(1916)];this[n(1089)+"mise"]=(async()=>{let h=n,m={HCvCW:function(g,L){return g!==L},kVkVF:h(1297),zrtND:i.NJrBn},{openDB:I}=await i[h(1267)](uh);this[h(1326)]=await I("frontier_"+f,1,{upgrade(g){let L=h;if(m[L(568)](m.kVkVF,m[L(571)]))g[L(2011)+L(975)+"e"](f,{keyPath:l});else return _0x374bc1?.[L(2033)](P=>P[L(1910)]===_0x5732c8)?.[L(1714)]}})})(),await this[n(1089)+"mise"]}else{let f={zEfiC:function(l,h){let m=n;return oSctxd[m(1284)](l,h)}};return function(...l){let h=n;return _0x3c84af[h(1579)](f[h(618)](_0xb01005,this),l),_0x1558cc(_0x2c25dc[h(1894)](this))}}}catch(f){if(e[n(454)](e[n(1726)],e[n(1957)])){let l=0,h=0,m;do m=oSctxd[n(1284)](_0x28ac13,_0x46199a),oSctxd[n(1821)](l,32)&&(h|=oSctxd[n(990)](oSctxd[n(1928)](127,m),l)),l+=7;while(oSctxd[n(1928)](128,m));return h}else console[n(916)](f)}finally{e[n(1223)](n(1311),e.lAgDQ)?(_0x391567=oSctxd[n(597)](_0x30e07b,_0x192a61),_0x551856|=(127&_0x835c0a)<<7):this[n(1089)+n(859)]=null}}}async[t(1894)](n){let i=t,f={qNjCX:function(l,h){return e[V(694)](l,h)}};try{if(e[i(887)](i(1568),e.rJnLn))return await this[i(1596)](),this[i(1326)]?.[i(1894)](this[i(514)],n);this[i(2035)]=!0,this[i(863)]=tZdSyj[i(1676)](0,_0xc227ec),this[i(1119)]=0|_0x3f345c,this[i(1442)]=!!_0x24562c}catch(l){console.log(l)}}async[t(1955)](n,i){let f=t,l={tmfXZ:function(h,m,I){return e[V(1296)](h,m,I)},aQqNA:e.evMJC};if(e[f(510)](f(1030),e[f(588)])){let h=this[f(1529)+f(1736)]?.["getCurre"+f(1791)+"nt"]();this[f(1695)+f(1740)+f(640)](l[f(617)](_0x2d6bbe,l[f(641)],{code:_0x13a18d.code,reason:"connecti"+f(967)+f(734)+f(713)+f(1474)+f(1870)+h})),this[f(1529)+f(1736)]?.["resetEnd"+f(1581)+f(600)](),this._pingLossCounter?.[f(537)+f(1197)]();return}else return await this[f(1596)](),this[f(1326)]?.put(this[f(514)],n)}async[t(1794)](n){let i=t;try{return await this[i(1596)](),this[i(1326)]?.[i(1468)](this[i(514)],n)}catch(f){console[i(916)](f)}}async[t(932)](){let n=t;try{return await this[n(1596)](),this[n(1326)]?.clear(this._dbName)}catch(i){console[n(916)](i)}}async[t(469)](){let n=t;return await this[n(1596)](),this[n(1326)]?.[n(1625)+"ys"](this[n(514)])}async[t(1433)](){let n=t;return await this._init(),this[n(1326)]?.[n(1433)](this[n(514)])}async[t(807)](){let n=t,i={GEJpW:function(f,l,h){return e.CUyxV(f,l,h)}};try{e[n(782)](e[n(659)],e.LOauF)?(xsxvXy[n(2021)](_0x454ba2,_0x19e8e4,74),xsxvXy[n(2021)](_0x2d3844,_0x2883bd,_0x1427d7)):(this._qosDB?.[n(1418)](),this._qosDB=void 0)}catch(f){console[n(916)](f)}}get[t(1437)](){let n=t;try{return!!this[n(1326)]}catch(i){return console[n(916)](i),!1}}}class xh{constructor(n,i){let f=t,l={PSnXi:function(h,m){return e[V(454)](h,m)},ipfSe:function(h,m){return e.HZzzO(h,m)},avcmk:function(h,m){return e[V(490)](h,m)}};if(e[f(1111)]===f(1226))this[f(2022)]=n,this[f(475)]=i,this._qosDB=localStorage;else{if(zXQCjk[f(1826)](void 0,_0x2f8f5d))this._listeners={};else if(zXQCjk[f(1883)](void 0,_0x383b07))this[f(1959)+"rs"][_0x41a3f7]=null;else{let h=this._listeners[_0x428559];if(h)for(let m=0;m<h[f(1484)];)zXQCjk[f(1491)](h[m].fn,_0x1b548a)?h[f(684)](m,1):++m}return this}}async[t(1973)](){}get[t(566)](){let n=t;return n(761)+"_"+this[n(2022)]}async get(n){let i=t,f=this[i(1326)][i(605)](this[i(566)]);return JSON[i(765)](f||"{}")[n]}async[t(1955)](n,i){let f=t,l=this._qosDB[f(605)](this[f(566)]),h=JSON[f(765)](e.NSPQb(l,"{}"));return h[i||n[this[f(475)]]]=n,this[f(1326)].setItem(this[f(566)],JSON[f(535)+"y"](h)),i||n[this[f(475)]]}async[t(1794)](n){let i=t,f=this[i(1326)][i(605)](this[i(566)]),l=JSON.parse(e[i(1878)](f,"{}"));return l[n]=void 0,this[i(1326)].setItem(this[i(566)],JSON[i(535)+"y"](l))}async clear(){let n=t;return this[n(1326)][n(932)]()}async[t(469)](){let n=t,i=this[n(1326)][n(605)](this[n(566)]),f=JSON.parse(e[n(898)](i,"{}"));return Object.keys(f)}async getAll(){let n=t,i=this[n(1326)][n(605)](this[n(566)]),f=JSON[n(765)](e.RIjyh(i,"{}"));return Object[n(1967)](f)}[t(807)](){return Promise.resolve()}get[t(1437)](){return!!this[t(1326)]}}class hh{constructor(n,i){let f=t,l={sRzan:e[f(794)]};e[f(2012)]("HdJcc",e[f(1747)])?this[f(905)](bkYikq[f(1506)],_0x2d569e(bkYikq.sRzan,{..._0x3c2f78,data:_0x59e0d4[f(1735)]||""})):(this[f(2022)]=n,this[f(475)]=i,this[f(1326)]=yn?tt:Lr?wx:null)}async[t(1973)](){}get[t(566)](){let n=t;return n(761)+"_"+this[n(2022)]}async[t(1894)](n){let i=t,f=this[i(1326)]["getStora"+i(533)](this._prefix);return JSON.parse(e[i(1750)](f,"{}"))[n]}async[t(1955)](n,i){let f=t;if(e.oItIs(e[f(1498)],e[f(1498)])){let l=this[f(1326)][f(1799)+"geSync"](this._prefix),h=JSON[f(765)](l||"{}");return h[i||n[this[f(475)]]]=n,this._qosDB["setStora"+f(533)](this._prefix,JSON[f(535)+"y"](h)),i||n[this._pathKey]}else return this[f(1326)]?.[f(1894)](_0x57f1b2)}async[t(1794)](n){let i=t,f=this[i(1326)][i(1799)+i(533)](this[i(566)]),l=JSON[i(765)](f||"{}");return l[n]=void 0,this[i(1326)][i(1772)+"geSync"](this._prefix,JSON[i(535)+"y"](l))}async[t(932)](){let n=t;return this[n(1326)][n(1815)+n(788)]()}async[t(469)](){let n=t,i=this[n(1326)][n(1799)+"geInfoSync"](this._prefix),f=JSON[n(765)](e[n(1384)](i,"{}"));return Object[n(469)](f)}async[t(1433)](){let n=t,i=this[n(1326)]["getStora"+n(869)+"nc"](this[n(566)]),f=JSON[n(765)](e[n(898)](i,"{}"));return Object[n(1967)](f)}[t(807)](){return Promise[t(1445)]()}get[t(1437)](){return!!this[t(1326)]}}function D0(o,n){let i=t;if(e[i(1429)](e.FRVLM,i(1521))){let f=_0x40469d(_0x1f597b,_0x2f2fea[i(1964)]),l=_0x4ffda4[i(1283)],h=_0x3548de[i(1283)];for(let m=0,I=_0x4f3144[i(1964)];m<I;m++)l[e[i(1121)](m,f)]=h[m]}else{if(yn||yn)return new hh(o,n);if(e[i(1515)](Wn,Or)&&e[i(615)](e[i(1206)],typeof indexedDB))return new lh(o,n);if(e.cmwyV(Wn,Or)&&e[i(1706)](e[i(1206)],typeof localStorage))return new xh(o,n);throw new Error(e.gxwFg)}}class ph{constructor(){let n=t;this[n(1785)+n(665)+"Id"]=null,this[n(1785)+"l"]=36e5,this._qosDB=e[n(1641)](D0,e[n(2064)],e[n(1999)])}async["_interva"+t(1099)](){let n=t,i={bzdlA:function(f,l){return e[V(1707)](f,l)},oXEQs:function(f,l){return e[V(700)](f,l)},QYMge:e.ZSMiZ};e.SxZRc(clearInterval,this[n(1785)+n(665)+"Id"]),this[n(1785)+n(665)+"Id"]=e[n(739)](setInterval,()=>{let f=n,l={hLEan:function(h,m){return i[V(993)](h,m)}};if(i[f(427)](f(730),i[f(1802)])){let h=this[f(1326)][f(1799)+"geInfoSync"](this[f(566)]),m=_0x409447[f(765)](UDSVWK[f(1021)](h,"{}"));return _0x2e0d9a[f(1967)](m)}else this[f(2062)+f(594)]()},this._interval)}async[t(1973)](){let n=t;e[n(2044)](n(1333),e[n(964)])?await this[n(1326)].openDB().then(()=>{let i=n;this[i(1785)+i(1099)]()}):(this[n(2022)]=_0x400c30,this[n(475)]=_0x56f5cf,this[n(1326)]=_0xd61c7c?_0x1153e6:_0x2429d6?_0x30dbc3:null)}async["flushExp"+t(594)](){let n=t;(await this[n(1326)]?.[n(1433)]()||[]).filter(({timestamp:l})=>l<Date[n(1872)]()).forEach(l=>{let h=n;this[h(1326)]?.[h(1794)](l[h(1527)+"id"])})}async[t(1794)](n){let i=t;if(e[i(1658)](e[i(942)],e.IeNlp))this[i(1089)+"mise"]=null;else return this[i(1326)]?.[i(1794)](n)}async[t(1955)](n,i){let f=t;return this[f(1326)]?.[f(1955)]({message_id:n,timestamp:i})}async[t(1894)](n){let i=t;return this._qosDB?.[i(1894)](n)}async closeDB(){clearInterval(this["_interva"+t(665)+"Id"]),await this._qosDB?.closeDB()}get[t(1437)](){let n=t;return this[n(1326)]?.[n(1437)]}}function qo(o){let n=t,i=!!this[n(647)][n(1956)+"S"];if(!i)return{enabled:i,isQoSMessage:!1,isQoSAck:!1,isAckCleanupMessage:!1,ackMsgIds:[]};let f=e[n(1513)](Vt,o[n(1703)][n(2039)],e[n(624)],"2"),l=f&&e[n(1137)](Vt,o[n(1703)][n(2039)],e[n(1520)],"1"),h=f&&e.XjpHD(Vt,o.message[n(2039)],e[n(1091)],"1"),m=h?Kn(o.message[n(2039)],e[n(1611)])?.[n(2054)](",")[n(410)](Boolean)||[]:[];return{enabled:i,isQoSMessage:f,isQoSAck:l,isAckCleanupMessage:h,ackMsgIds:m}}async function R0(){let o=t,n={BAcgO:o(610)+"2",YFbgj:e[o(2067)],AmpIz:e.fXRdW};if(e.pdnYH(e[o(666)],e[o(666)]))return this[o(1364)+o(693)]||(this[o(1364)+o(693)]=new ph),this[o(1364)+o(693)].isReady||await this[o(1364)+"ger"].openDB(),this["_QoSMana"+o(693)];{let i=n[o(1524)][o(2054)]("|"),f=0;for(;;){switch(i[f++]){case"0":this._ws[o(908)+o(1558)](o(1703),this[o(654)+"ge"]);continue;case"1":this[o(1482)][o(908)+o(1558)](n[o(2009)],this[o(984)]);continue;case"2":this[o(1482)][o(908)+o(1558)](n[o(874)],this[o(996)]);continue;case"3":this[o(1482)][o(908)+o(1558)](o(789),this._onOpen);continue;case"4":if(!this[o(1482)])return;continue}break}}}async function gh(o,n){let i=t,{enableAutoAck:f}=this[i(647)],l=e.XjpHD(Vt,o[i(1703)][i(2039)],e[i(459)],"1"),h=e[i(2049)](Vt,o.message.headers,e.VhiVR,"1"),m=qo[i(516)](this,o);if(e[i(590)](f,l)){let{SeqID:I,LogID:g,service:L,LogIDNew:P,method:F}=o[i(1703)];this._sendAck({SeqID:I,LogID:g,LogIDNew:P,service:L,method:F,headers:[{key:e[i(931)],value:"1"},{key:e[i(1906)],value:e[i(1707)](P,"")},{key:e[i(1357)],value:"0"}]})}h&&!m.isQoSAck&&this["_dispatc"+i(1530)+"ageEvent"](o),e.kWpRN(n)}async function mh(o,n){let i=t;this._debug(e[i(1759)],o[i(1703)]),e[i(1810)](n)}async function wh(o,n){let i=t,f=e[i(1452)](Hn,await e.JDbcd(T0,o[i(1969)]));try{if(e[i(1096)](i(567),"IraQQ"))if(f[i(1416)]instanceof Uint8Array){let l=this._options[i(599)+i(830)]instanceof Object?{force:!!this[i(647)]["payloadE"+i(830)][i(884)],encoding:this._options[i(599)+i(830)][i(1155)]?this[i(647)][i(599)+i(830)][i(1155)][i(1202)](/\s/g,"")[i(656)+"ase"]():""}:{force:!1,encoding:this[i(647)]["payloadE"+i(830)]?this[i(647)]["payloadE"+i(830)].replace(/\s/g,"")[i(656)+i(1203)]():""},h=f["payloadE"+i(830)]?f[i(599)+i(830)].replace(/\s/g,"")[i(656)+"ase"]():"",m=e[i(577)](this._options[i(1356)+i(1057)],Object)?{force:!!this[i(647)][i(1356)+"ype"][i(884)],type:this._options[i(1356)+i(1057)].type?this._options[i(1356)+i(1057)][i(557)][i(1202)](/\s/g,"")["toLowerC"+i(1203)]():""}:{force:!1,type:this[i(647)][i(1356)+i(1057)]?this[i(647)][i(1356)+i(1057)].replace(/\s/g,"")[i(656)+i(1203)]():""},I=f[i(1356)+i(1057)]?f["payloadT"+i(1057)][i(1202)](/\s/g,"").toLowerCase():"",g=m[i(884)]?m[i(557)]:I||m[i(557)],L=l[i(884)]?l[i(1155)]:h||l[i(1155)],P=[e[i(1937)],e.KVxvN,e[i(867)],e.FPPVS],F=[i(748)+"e",e[i(446)]];this[i(647)][i(1107)+i(1270)+i(1823)+"ad"]&&P.includes(g)&&(!L||F[i(420)](L))?f["textPayl"+i(690)]=e[i(1634)](A0,f[i(1416)],0,f[i(1416)][i(538)+"th"]):f[i(1281)+i(690)]=""}else f.textPayload="";else return _0xd75045[i(1445)]()}catch(l){f[i(1281)+i(690)]="",console[i(916)](l)}o[i(1703)]=f,e[i(1617)](n)}function _h(o,n,i){let f=t,l={HAhav:function(L,P){return L<P},VITtq:function(L,P){return e[V(1898)](L,P)},ccFjI:function(L,P){return e.xRJYO(L,P)},eTAzF:function(L,P){return e[V(442)](L,P)},vqHAD:function(L,P){return L&P}},h=e[f(1490)](i,8192),m=e[f(2027)](h,1),I=null,g=h;return function(L){let P=f;if(l[P(944)](L,1)||L>m)return o(L);l.VITtq(l[P(1156)](g,L),h)&&(I=l[P(1392)](o,h),g=0);let F=n[P(516)](I,g,g+=L);return l[P(1122)](7,g)&&(g=l.ccFjI(7|g,1)),F}}let yh=4294967295;function bh(o,n,i){let f=t;return RangeError(e.QzpQd(e[f(1249)](e[f(1434)](e[f(1221)](e.TSlHG,o)+e[f(1032)],e.RIjyh(n,1)),f(1435)),i))}function Eh(o,n,i){let f=t;if(i>yh)throw new Error(e[f(1972)]);let l=3;for(;l>=0;){let h=e[f(448)](255,i);e.TofYw(jo,h,o,e[f(1338)](n,l)),i>>>=8,l--}return e[f(622)](n,4)}function vh(o,n){let i=t,f={lSGmM:function(l){return l()}};if(e.JLWYT("hrUfa",e[i(829)])){let l=0,h=n,m=e[i(1236)](n,4);for(;e[i(947)](h,m);){let{value:I,offset:g}=e[i(1171)](Ho,o,h);h=g,l=e[i(1961)](l,8)>>>0,l+=I}return{value:l,offset:m}}else{let l=this[i(1529)+i(1736)]?.[i(1561)+i(1791)+"nt"]();this._debug(i(1344)+l),f[i(878)](_0x14f29d)}}function Sh(o,n,i){let f=t,l=e[f(1361)][f(2054)]("|"),h=0;for(;;){switch(l[h++]){case"0":return e.CFJcx(Fo,o,n,i)+i;case"1":if(n[f(971)+"e"])return e[f(1770)](n[f(971)+"e"](o,i),i);continue;case"2":if(n.write)return e[f(1236)](n.write(o,i),i);continue;case"3":if(e[f(1811)](o[f(1484)],40))return e.bWeMU(e[f(1513)](Fo,o,n,i),i);continue;case"4":if(!o)return i;continue}break}}function Ih(o,n){let i=t,f=new de(e.JafyW(e[i(1098)](e[i(1098)](e[i(1457)](o[e[i(1058)](n,4)],24),e[i(1126)](o[e[i(1859)](n,5)],16)),o[e[i(539)](n,6)]<<8),o[n+7]),e[i(541)](e[i(461)](e[i(1015)](o[e[i(1249)](n,0)]<<24,e[i(653)](o[n+1],16)),e[i(572)](o[n+2],8)),o[n+3]),!0);return n+=8,{value:f,offset:e[i(1487)](n,8)}}function Ch(o,n,i){let f=t,l={ykCcF:function(h,m,I){return e[V(1828)](h,m,I)},tUauY:e[f(1383)],WGQCJ:f(1418)};if(f(521)===e[f(609)])_0x16f619[f(1445)]()[f(1313)](()=>{let h=f,m=Ufpfdn[h(876)](_0x3fd10c,Ufpfdn[h(1353)],{message:this[h(585)+h(1410)+h(1646)](_0x2ccc9e)});this.emit(Ufpfdn[h(1353)],m);let I=Ufpfdn.ykCcF(_0x1dca1c,Ufpfdn[h(1987)],{reason:this[h(585)+h(1410)+h(1646)](_0x53b45e)});this[h(905)](h(1418),I)});else{let h=o.low,m=o[f(1119)];return n[i]=e.IEoCh(m,24),n[i+1]=e[f(413)](m>>>16,255),n[e[f(1118)](i,2)]=m>>>8&255,n[e.zEeiJ(i,3)]=e[f(726)](255,m),n[i+4]=e.quuWd(h,24),n[e[f(1479)](i,5)]=e[f(1538)](e.EbUzZ(h,16),255),n[e[f(1655)](i,6)]=e[f(939)](e[f(1936)](h,8),255),n[e[f(983)](i,7)]=e[f(810)](255,h),i+=8,i}}function Ho(o,n){let i=t;return o.readUInt8?{value:o[i(720)+"8"](n),offset:e.xFlHu(n,1)}:{value:e[i(1704)](255,o[n]),offset:e[i(1118)](n,1)}}function jo(o,n,i){let f=t;return n.writeUint8?n[f(1159)+"t8"](o,i):n[i]=e[f(443)](255,o),e[f(456)](i,1)}let Ah=function(o){return new Uint8Array(o)},Th=e[t(906)](e[t(1206)],typeof Buffer)?Buffer[t(721)+t(1547)]:_h(Ah,Uint8Array[t(1397)+"e"][t(791)]);(()=>{let o=t;if(e[o(507)]===e.FPZDH){let n=4294967295;return function(i,f,l=!0){let h=o,m=("9|8|6|1|"+h(824)+h(838)+"4")[h(2054)]("|"),I=0;for(;;){switch(m[I++]){case"0":if(i[f++]<128)return{value:l?n:0|n,offset:f};continue;case"1":if(e.PGpJs(i[f++],128))return{value:l?n:0|n,offset:f};continue;case"2":n=e[h(1136)](e[h(1143)](n,e.nECdF(127&i[f],14)),0);continue;case"3":n=e[h(1768)](e[h(1845)](n,e[h(1285)](15&i[f],28)),0);continue;case"4":return{value:l?n:e.gLNoN(0,n),offset:f};case"5":if(e.CToku(i[f++],128))return{value:l?n:e[h(1809)](0,n),offset:f};continue;case"6":n=e.lkxRF(e[h(1509)](n,e[h(415)](127&i[f],7)),0);continue;case"7":n=e[h(1885)](n,e[h(901)](127&i[f],21))>>>0;continue;case"8":if(i[f++]<128)return{value:l?n:e[h(524)](0,n),offset:f};continue;case"9":n=e[h(1673)](127&i[f],0);continue;case"10":if((f+=5)>i[h(1484)])throw f=i[h(1484)],e[h(1634)](bh,f,10,i[h(1484)]);continue;case"11":if(e[h(805)](i[f++],128))return{value:l?n:0|n,offset:f};continue}break}}}else{let n=ee[o(1326)][o(605)](ee._prefix);return _0x16fe00[o(765)](e.lrNnI(n,"{}"))[_0x21f258]}})();let Dh=16,Go=32;function Rh(o){let n=t,i=0,f={};for(let l=0;e[n(620)](l,o[n(1484)]);l++)f[o[l]["cursor_n"+n(1420)]]=e[n(621)](C0,o[l][n(1163)+n(1420)]),i+=e[n(985)](14,f[o[l][n(1163)+n(1420)]]);return[i,f]}function k0(o,n,i){let f=t,l={mBeNT:e[f(1585)],CJljx:function(h,m,I,g){return e.drHIH(h,m,I,g)},aKjWv:f(1459),uTMuh:e[f(790)],FEbrz:function(h,m,I,g){return e[f(930)](h,m,I,g)},hHPXO:e.MjYGx,yJemD:function(h,m,I,g){return e.CFJcx(h,m,I,g)},vextK:function(h,m){return e[f(966)](h,m)},twrNV:function(h,m){return e[f(1295)](h,m)}};if(e[f(2041)](f(1212),e[f(1803)])){let[h,m]=Rh(o),I=e[f(875)](Th,h),g=0;return o.forEach(L=>{let P=f;console.log(l[P(1659)],L,L[P(904)]),g=l[P(1713)](jo,0,I,g),console.log(l.aKjWv,g),g=Eh(I,g,L[P(904)]||0),console[P(916)](P(904),g),g=jo(m[L[P(1163)+P(1420)]],I,g),console.log(l[P(953)],g),g=l[P(1218)](Sh,L[P(1163)+"ame"],I,g),console[P(916)](l[P(2034)],g),g=l.yJemD(Ch,de[P(1738)+"er"](L[P(1565)]||n),I,g),console.log(P(1331),g)}),{frameType:Go,headers:[{key:e[f(1960)],value:i}],payload:I}}else{let h=zlDaKy[f(1207)](255,_0x140b40);zlDaKy[f(778)](_0x7ce6aa,h,_0x2b391a,zlDaKy[f(591)](_0xb80ba9,_0x15af33)),_0x3037cd>>>=8,_0x3775b0--}}function kh(o){let n=t,i={iTwxA:function(h,m,I){return e[V(595)](h,m,I)},VCXce:function(h,m){return e[V(704)](h,m)},NvDPu:function(h,m){return e[V(1180)](h,m)}},f=0,l=[];for(;e[n(517)](f,o[n(538)+"th"]);)if(e[n(1889)](e.uTHFN,"IRpqp")){let{offset:h}=e.YVRfi(Ho,o,f);f=h;let m={cursor_name:"",cursor:0,service:0},{value:I,offset:g}=e[n(1088)](vh,o,f);m[n(904)]=I,f=g;let{value:L,offset:P}=e[n(1017)](Ho,o,f);f=P,m.cursor_name=e[n(1224)](A0,o,f,e[n(1887)](f,L)),f+=L;let{value:F,offset:G}=e.uGAbd(Ih,o,f);m[n(1565)]=F[n(619)](),f=G,l.push(m)}else{let{value:h,offset:m}=AUpgHj[n(1196)](_0x2352c0,_0x13c5bb,_0x90af4);_0x28f1e9=m,_0x2428ec=AUpgHj[n(1861)](AUpgHj[n(1423)](_0x4bb609,8),0),_0x3e6f0e+=h}return l}function Lh(){let o=t,n={iPbOf:function(i,f){return e.khXsh(i,f)},FzhSx:function(i,f){return e[V(1345)](i,f)},NzuOZ:function(i,f){return e[V(1582)](i,f)},MhzbB:function(i,f){return e[V(965)](i,f)},RHZHD:function(i,f){return i&f},ThGHF:function(i,f){return i&f},CpcsU:function(i,f){return e[V(1261)](i,f)},bEBaQ:function(i,f){return e[V(471)](i,f)},KRKrZ:function(i,f,l){return i(f,l)},UlzuL:function(i,f){return e.peyww(i,f)},NEpSD:function(i,f){return e[V(818)](i,f)},XsJqV:function(i,f){return e[V(1039)](i,f)}};if(e[o(1832)]("agNJR",e.tijhG))_0x1fd779=Kigjpd.iPbOf(Kigjpd.FzhSx(Kigjpd[o(1510)](Kigjpd[o(1995)](7,_0x3003c8),18)|Kigjpd[o(1510)](Kigjpd[o(1499)](63,_0xae1648),12),Kigjpd[o(1510)](Kigjpd[o(1733)](63,_0x2d7f64),6)),Kigjpd[o(1733)](63,_0x4e870a)),Kigjpd[o(771)](_0xf2b6a5,65536)||Kigjpd[o(1405)](_0x5a3310,1114111)?_0x14e194+=_0x3d15e2:(_0x9aa1d8-=65536,_0x4a596d+=Kigjpd.KRKrZ(_0x5def95,Kigjpd[o(1934)](Kigjpd[o(1841)](_0x57a033,10),55296),Kigjpd[o(1934)](Kigjpd[o(1385)](1023,_0x4c2169),56320)),_0x4e24c5+=3);else return{frameType:Go,headers:[{key:e[o(1960)],value:e.yayCi}],payload:void 0}}class Oh{constructor(n,i,f){let l=t;if(l(1877)===l(1877))this[l(1552)+l(1395)]=n,this[l(630)+l(2070)]=i,this[l(1816)+"Strategy"]=f,this[l(1326)]=e[l(518)](D0,this[l(1552)+"ameSpace"],l(1163)+l(1420));else return this[l(1482)]?this._ws[l(751)+"te"]:this[l(647)][l(1971)+l(1220)]?this[l(1238)+"NG"]:this.CLOSED}async[t(1973)](){let n=t;await this[n(1326)][n(1973)]()}async[t(499)+"rs"](){let n=t;if(!this[n(1326)][n(1437)])return;let i=this[n(1816)+n(724)],f=await this._qosDB.getAll();switch(console.log(e[n(827)],f),i){case n(1e3):return f&&f.length?e.eieAS(k0,f,0,this[n(630)+n(2070)]):void 0;case e.QYXmL:return;case e[n(1583)]:return f&&f[n(1484)]?k0(f,0,this[n(630)+n(2070)]):Lh()}}async[t(1955)](n,i,f){let l=t;return console[l(916)]("setdb",n,i,f),this[l(1326)][l(1955)]({cursor_name:n,cursor:i,service:f})}async[t(1830)+"rs"](n){let i=t,f=e[i(716)](kh,n);for(let l of f)console.log(e[i(1023)],f),await this._qosDB[i(1955)](l)}async[t(1894)](n){let i=t;return(await this._qosDB[i(1894)](n))?.cursor}async[t(807)](){let n=t;e[n(423)]!==e[n(768)]?await this._qosDB[n(807)]():_0x4301e1.log(_0x2ebec6)}[t(1240)+"rsorFile"+t(1782)](n){let i=t;this["_cursorF"+i(2070)]=n}get[t(1437)](){let n=t;return this[n(1326)][n(1437)]}}let Ph=e[t(891)];async function L0(o){let n=t;if(e[n(1379)]===e[n(1011)]){let i=this._qosDB.getItem(this[n(566)]),f=_0x163d5b[n(765)](e[n(1707)](i,"{}"));return _0x5b64d2[n(1967)](f)}else{if(!this[n(647)][n(1956)+"S"])return null;let{aID:i,fpID:f,messageStrategy:l}=this[n(647)],h=e.olrwa(o,Ph);try{return this["_cursorM"+n(902)]?o&&this["_cursorM"+n(902)][n(1240)+n(937)+n(1782)](o):this[n(2006)+n(902)]=new Oh(f+"_"+i+"_"+h,h,l),this[n(2006)+n(902)][n(1437)]||await this[n(2006)+n(902)].openDB(),this[n(2006)+n(902)]}catch{return null}}}async function Nh(o,n){let i=t,f=e[i(1224)](Vt,o[i(1703)][i(2039)],e[i(1422)],"-1"),l=e[i(1250)](Vt,o.message[i(2039)],e[i(931)],"1"),h=e[i(723)](Kn,o[i(1703)].headers,e.DIkWn),m=e.hMDTr(Number,e[i(1888)](Kn,o[i(1703)][i(2039)],e.zZjNW))||0,I=qo[i(516)](this,o),g=e[i(1675)](Vt,o[i(1703)].headers,e[i(2023)],"2"),L=e.qKSwi(Kn,o[i(1703)][i(2039)],e.ByJxn),P=Number(e[i(1019)](Kn,o[i(1703)][i(2039)],e[i(732)]));if(I[i(596)])return e[i(1808)](n);let F=I[i(1633)+i(1293)]?await R0[i(516)](this):null;if(o.message.service>0&&l&&!f||o.message[i(904)]>0){if(h&&I[i(1633)+i(1293)]&&F)return!!!await F[i(1894)](h)&&(this["_dispatc"+i(1411)+"Event"](o),await F[i(1955)](h,e[i(1236)](Date[i(1872)](),m))),e.kWpRN(n);if(g)if(e[i(1804)]!==e[i(1804)]){let{initReconnectInterval:G,maxReconnectInterval:W,reconnectIntervalGrowFactor:K}=this[i(647)],X=e[i(900)](G,_0x49d536[i(1169)](K,_0x4a9766-1));return X>W?W:X}else{let G=await L0[i(516)](this);if(!G)return this[i(1695)+i(1411)+"Event"](o),e[i(1253)](n);let W=await G[i(1894)](L)??-1;if(e[i(936)](W,P))this[i(1695)+i(1411)+i(662)](o),G[i(1955)](L,P,o.message[i(904)]);else throw new Error(i(850)+i(1389)+" cursor "+P+(i(502)+i(460)+i(696)+"r ")+W);return e[i(1696)](n)}return this[i(1695)+i(1411)+"Event"](o),e[i(418)](n)}}async function Mh(o,n){let i=t,f=qo[i(516)](this,o);if(!f["isQoSMes"+i(1293)])return e[i(1810)](n);let l=await R0[i(516)](this);if(f[i(910)+i(474)+i(1646)]&&f[i(1976)+"s"][i(1484)])for(let h of f[i(1976)+"s"])await l[i(1794)](h);e[i(418)](n)}async function Bh(o,n){let i=t,f={PcllN:e[i(820)]},l=e[i(700)](o.message[i(1214)+"e"],Dh),h=e.hjpQI(o[i(1703)][i(1214)+"e"],Go);if(!l&&!h)return n();let m=e[i(1448)](Kn,o[i(1703)][i(2039)],e[i(1960)]);if(!m)return e.xFANx(n);let I=await L0[i(516)](this,m);if(!I)return e[i(1229)](n);if(l)if(e[i(895)](i(2013),e[i(1902)]))this[i(1816)+i(958)][i(1851)](_0x2e65b7),this[i(1147)](f[i(519)],_0x492f52);else{let g=await I[i(499)+"rs"](),L={frameType:g?.[i(1214)+"e"],SeqID:de[i(1738)+"er"](this[i(981)]++),LogID:de[i(1738)+"er"](this[i(647)][i(493)+i(1835)]()),service:9e3,method:5,headers:g?.[i(2039)],payload:g?.[i(1416)]},P=e.shZGq(S,L);this[i(1482)]&&this[i(1482)][i(751)+"te"]&&this[i(1482)].send(P)}if(h){let g=o[i(1703)][i(1416)];g&&I[i(1830)+"rs"](g)}}let zh=async function(o,n){let i=t;this[i(1920)]=!1,e[i(612)](clearTimeout,this[i(1556)+"ionTimeo"+i(1705)]),n()},Fh=async function(o,n){let i=t;if(!this._ws||e[i(425)](this[i(1482)][i(751)+"te"],this[i(705)]))return e[i(1319)](n);let{pingInterval:f}=this[i(647)];this[i(1529)+"tManager"]?.[i(1082)+i(1581)+"fig"]();for(let h=0;e[i(805)](h,this[i(1816)+"Queue"][i(1484)]);h++){let m=this[i(1816)+i(958)][h];if(e[i(1761)](this[i(1482)][i(751)+"te"],this[i(705)])&&e[i(2068)](null,m))this[i(1482)]&&this[i(1482)][i(1076)](m),this[i(1816)+i(958)][h]=null;else break}this[i(1816)+i(958)]=this[i(1816)+"Queue"].filter(h=>!!h),this["_pingPon"+i(763)+"Id"]=e[i(1710)](setTimeout,()=>this[i(1078)](),f),this[i(1695)+i(2032)+"nt"](o),this[i(888)+"er"]&&this[i(1482)]&&(this[i(1482)][i(1201)+"pe"]=this[i(1415)+i(1057)]);let l=this[i(1529)+i(1736)]?.[i(1561)+i(1791)+"nt"]();this._debug(i(1344)+l+i(635)),e.kPuID(n)},Uh=async function(o,n){let i=t,f=this[i(1529)+i(1736)]?.[i(1561)+i(1791)+"nt"]();this[i(1147)]("open "+f),e[i(1368)](n)};class qh extends zo{constructor(n){let i=t,f={IXdfV:function(l,h,m,I){return e[V(2049)](l,h,m,I)},yjBPk:function(l,h,m){return l(h,m)},hPlwI:e[i(1176)],IeWSM:i(1685),OQIRF:e[i(2067)],wEivz:i(789),hNRIs:i(1703),uUcgu:e[i(1399)],qmrRk:e[i(903)],laJwx:i(1114),iUVPg:function(l,h){return l===h},qzRwr:e[i(1412)],iJlvs:e.UOxYf,BPULU:function(l,h){return l!==h},RkXMs:e[i(1262)],QSzhJ:i(1460)+i(839)+"s",phdCH:function(l,h,m){return e[i(2038)](l,h,m)},VvEwc:function(l,h){return e[i(426)](l,h)},NLRpr:e.ejYLm,KQRat:function(l,h,m,I){return e[i(1699)](l,h,m,I)},XNjgT:function(l,h,m){return e[i(439)](l,h,m)},gtHoL:i(1001),nOSCi:function(l,h,m){return e.HWcFU(l,h,m)},hCpMy:e[i(1671)],DCXzH:function(l,h,m){return l(h,m)},FSdYB:function(l,h,m){return e[i(797)](l,h,m)},bopSf:i(1862),DVTHO:e.hUtrU,uGjIt:"tMgtv",WehiI:function(l,h){return e[i(796)](l,h)},YieeD:function(l,h){return e[i(1286)](l,h)}};if(e[i(2012)](e[i(938)],e[i(1778)])){super(),this[i(986)+"igatorOn"+i(1864)]=!0,this[i(888)+"er"]=Wn,this._isNode=rh,this[i(515)+"T"]=yn,this[i(525)+"X"]=Lr,this._isWorker=Or,this[i(1816)+i(958)]=[],this[i(1529)+i(1736)]=null,this[i(687)+"osed"]=!1,this[i(1415)+i(1057)]=e[i(1543)],this[i(1556)+i(1628)]=!1,this[i(1556)+i(1886)+"utId"]=null,this[i(1806)+i(660)+i(1525)]=null,this[i(1248)+i(763)+"Id"]=null,this[i(981)]=0,this[i(1920)]=!1,this[i(1677)]="",this["_QoSMana"+i(693)]=null,this._cursorManager=null,this["_pingLos"+i(1602)]=null,this[i(1950)+"ls"]=e[i(1245)],this.CLOSED=3,this[i(1238)+"NG"]=0,this[i(705)]=1,this[i(755)]=2,this[i(1315)]=I=>{let g=i;try{f[g(1476)](I0,this,I,[zh,Fh,Uh])}catch(L){let P=f[g(1711)](rt,g(1685),{message:L[g(1703)],code:$t[g(740)+"OR"],error:L});this["_dispatc"+g(1764)+g(640)](P)}},this._onMessage=async I=>{let g=i,L={cdcke:f[g(508)],mvzlF:f.qmrRk,CeUVV:f[g(643)],xwbNT:f[g(2008)]},{pingInterval:P,pingFrequency:F}=this[g(647)];if(f.iUVPg("hi",I[g(1969)])&&f[g(1020)](f[g(412)],F)||f[g(1020)](f[g(1989)],F))if(f[g(1953)](f[g(1330)],g(2042)))this._clearPingTimer(),this[g(905)](f.QSzhJ,g(1619)),this[g(1248)+"gTimeoutId"]=f.phdCH(setTimeout,this._ping[g(586)](this),P);else{let G={txDlr:function(M){return M()},HJlro:function(M,H){return M(H)},cYheb:prnSWt.mvzlF},W=()=>{let M=g;_0x5ce112[M(1839)+"entListe"+M(951)](M(1114),K),_0x38417f[M(1839)+M(550)+M(951)]("error",X),_0x260a9a[M(1839)+"entListener"](prnSWt.cdcke,X)},K=()=>{let M=g;G[M(1984)](_0x39cdb6),G[M(1984)](W)},X=()=>{let M=g;G[M(509)](_0x406c98,_0x154ea4[M(1685)]||new _0x126009(G[M(1016)],G[M(1016)])),G.txDlr(W)};_0x223abe[g(908)+"Listener"](prnSWt.CeUVV,K),_0x2a57b5[g(908)+"Listener"](prnSWt[g(1167)],X),_0x40f780["addEvent"+g(1558)](prnSWt.cdcke,X)}if(!f[g(1731)]("hi",I[g(1969)]))try{if(f[g(1953)](f[g(825)],g(1054))){let G=f.hPlwI[g(2054)]("|"),W=0;for(;;){switch(G[W++]){case"0":if(!this[g(1482)])return;continue;case"1":this._ws[g(1839)+g(550)+"ner"](f[g(2008)],this[g(996)]);continue;case"2":this._ws[g(1839)+"entListe"+g(951)](f[g(1793)],this._onClose);continue;case"3":this._ws["removeEv"+g(550)+"ner"](f.wEivz,this[g(1315)]);continue;case"4":this[g(1482)][g(1839)+"entListe"+g(951)](f.hNRIs,this[g(654)+"ge"]);continue}break}}else f.KQRat(I0,this,I,[wh,gh,Mh,Bh,Nh,mh])}catch(G){let W=f.XNjgT(rt,f[g(2008)],{message:G[g(1703)],code:$t[g(1822)+g(1085)],error:G});this[g(1695)+g(1764)+"ent"](W)}},this[i(996)]=I=>{let g=i,L=this["_endpoin"+g(1736)]?.[g(783)+"chMaxTries"](),P=this[g(1529)+"tManager"]?.[g(1561)+g(1791)+"nt"]();if(L&&!I.message){if(f[g(1953)](f.gtHoL,f[g(1355)]))return;{let F="connect "+P+(g(1746)+g(1340)+"es reached");this["_dispatchErrorEv"+g(640)](f[g(1003)](rt,f.IeWSM,{message:F,code:$t[g(683)+g(1908)+"R"],error:I}));return}}this[g(1482)]&&f.iUVPg(this[g(1482)][g(751)+"te"],this[g(705)])&&this[g(787)+g(1465)](),this[g(1695)+g(1764)+"ent"](f.nOSCi(rt,f[g(2008)],{message:I.message,code:$t[g(1504)+g(1280)],error:I}))},this[i(984)]=async I=>{let g=i,L={eZktT:function(F,G){return F(G)},tRDKQ:f[g(1779)]};this[g(497)+g(2052)](),this["_clearPi"+g(1230)](),this["_removeW"+g(411)+"rs"](),this._ws=null,this[g(1556)+g(1628)]=!1;let P=this[g(1529)+g(1736)]?.checkReachMaxTries();if(!P&&this["_navigat"+g(467)]()&&!this["_readyCl"+g(799)]){let F=this[g(1529)+g(1736)]?.[g(1561)+g(1791)+"nt"](),G=this._options[g(1157)+g(1578)+g(1258)](I[g(2007)],I[g(2024)]);this[g(1695)+g(1740)+g(640)](f[g(1649)](ft,f.OQIRF,{code:1006,reason:I[g(2024)]||g(1834)+g(967)+"d, unkno"+g(713)+g(1474)+g(1870)+F,willReconnect:G})),G&&this[g(1556)]();return}if(I[g(2007)]!==1e3&&this["_readyCl"+g(799)]){this[g(1695)+g(1740)+g(640)](f.FSdYB(ft,f.OQIRF,{code:1e3,reason:f[g(1241)]})),this["_endpoin"+g(1736)]?.["resetEnd"+g(1581)+g(600)](),this[g(1388)+g(1602)]?.[g(537)+g(1197)]();return}if(I.code!==1e3&&P)if(f[g(2040)]===f.uGjIt)_0xd1065c[g(761)+g(912)]=void 0,iMJQme.eZktT(_0x467537,iMJQme[g(725)]);else{let F=this[g(1529)+"tManager"]?.[g(1561)+g(1791)+"nt"](),G=I[g(2024)];G||(G=await f[g(1626)](dh,this[g(1677)])),G=g(1834)+"ng faile"+g(1553)+G+(g(1162)+"me: ")+F+(", max re"+g(1335)+g(1784)),this[g(1695)+g(1740)+g(640)](f[g(1711)](ft,g(1418),{code:I[g(2007)],reason:G}));let W="connect "+F+" fail, max retries reached";this[g(1695)+g(1764)+g(640)](rt(f[g(2008)],{message:W,code:$t[g(683)+g(1908)+"R"]})),this[g(1529)+g(1736)]?.[g(1082)+g(1581)+"fig"](),this[g(1388)+g(1602)]?.[g(537)+g(1197)]();return}if(f[g(438)](1e3,I[g(2007)])&&!I[g(2024)]){let F=this["_endpoin"+g(1736)]?.[g(1561)+g(1791)+"nt"]();this[g(1695)+g(1740)+"ent"](f[g(1649)](ft,g(1418),{code:I[g(2007)],reason:g(1834)+g(967)+g(734)+g(713)+g(1474)+g(1870)+F})),this[g(1529)+g(1736)]?.[g(1082)+g(1581)+"fig"](),this[g(1388)+g(1602)]?.[g(537)+g(1197)]();return}this[g(1695)+g(1740)+"ent"](I),this["_endpoin"+g(1736)]?.[g(1082)+"pointCon"+g(600)](),this[g(1388)+g(1602)]?.[g(537)+g(1197)]()},this[i(1698)]=null,this.onerror=null,this.onmessage=null,this[i(940)]=null,this[i(950)+i(1690)]=null,this[i(1473)+"eAck"]=null,this[i(773)+i(1939)+i(1904)+"ct"]=null,this["_handleO"+i(1978)]=this["_handleO"+i(1978)].bind(this),this["_handleO"+i(1233)]=this._handleOffLine[i(586)](this),this[i(1996)+i(1844)]=this[i(1996)+i(1844)][i(586)](this),this[i(1996)+i(729)]=this[i(1996)+"ageShow"].bind(this),this[i(647)]={url:"",automaticOpen:!0,initReconnectInterval:1e3,maxReconnectInterval:1e4,reconnectIntervalGrowFactor:2,timeoutInterval:5e3,maxRetries:5,debug:!1,maxMessageQueueLength:e[i(1718)](1,0),service:0,logIDGenerator:a,headers:void 0,payloadEncoding:"",payloadType:"",fpID:"",deviceID:"",accessKey:"",ttwID:"",bddID:"",aID:"",disableAutoReconnect:!1,customParams:{},pingInterval:15e3,pingTimeoutInterval:4e3,pingFrequency:e[i(837)],pingLossCount:2,enableTransformTextPayload:!1,logIDNewConfig:{enableAutoGenerateLogIDNew:!1,userIp:""},miniProgramParams:{customHttpHeader:{}},enableAutoAck:!1,reconnectInterceptor:()=>!0,enableQoS:!1,QoSLevel:2,messageStrategy:e.qCjsJ,env:{xTTEnv:"",xUseEnv:""},listenNetworkChanged:!0};let{url:l,ws:h}=n,m=Array[i(1559)](l)?l:e[i(1914)](e[i(2025)],typeof l)?[l]:[];if(!m||e[i(2043)](0,m.length))throw new Error(e[i(992)]);if(!oh(h))throw new Error(e.WfQkw);Object[i(1087)](this[i(647)],n),this[i(1529)+"tManager"]=new S0(m,this._options[i(999)+"es"]),this[i(1388)+i(1602)]=new fh(this[i(647)][i(1868)+i(1827)]),this._options[i(1971)+i(1220)]&&(this[i(1920)]=!0,this[i(1556)]()),this[i(647)]["listenNe"+i(1363)+i(1986)]&&(this[i(515)+"T"]||this[i(525)+"X"]?this[i(1173)+i(1282)+i(1820)]():this._isBrowser&&this[i(480)+"balEvent"+i(1558)]())}else{let l=this[i(1326)][i(605)](this._prefix),h=_0x5f11e9[i(765)](e.KKSHs(l,"{}"));return _0x41dcdd[i(469)](h)}}["_handleO"+t(1978)](){let n=t;this[n(647)]["disableA"+n(579)+n(637)]||this[n(687)+n(799)]||this[n(646)+n(1690)]()}[t(1580)+t(1233)](){let n=t;this[n(1398)+n(1891)+"t"]();let i=Bo(e[n(1461)],{message:e[n(698)]});this[n(773)+"mediatel"+n(1904)+"ct"]&&this[n(773)+n(1939)+n(1904)+"ct"](i)}[t(480)+"balEvent"+t(1558)](){let n=t;this[n(888)+"er"]&&window.addEventListener(e.gwnjI,this[n(1580)+n(1978)]),this._isBrowser&&window["addEvent"+n(1558)](n(1378),this[n(1580)+n(1233)]),this[n(888)+"er"]&&window["addEvent"+n(1558)](e[n(707)],this[n(1996)+n(1844)]),this[n(888)+"er"]&&window.addEventListener(e[n(1038)],this[n(1996)+n(729)])}[t(1792)+t(553)+t(1558)](){let n=t;this[n(888)+"er"]&&window["removeEv"+n(550)+n(951)](e[n(1323)],this[n(1580)+n(1978)]),this[n(888)+"er"]&&window["removeEventListe"+n(951)](e[n(549)],this[n(1580)+n(1233)]),this[n(888)+"er"]&&window[n(1839)+n(550)+n(951)](e[n(707)],this[n(1996)+n(1844)]),this._isBrowser&&window[n(1839)+"entListe"+n(951)](e[n(1038)],this[n(1996)+n(729)])}[t(1996)+"ageHide"](n){let i=t;e[i(1577)]!==e[i(804)]?(!n[i(1686)+"d"]&&(e.oItIs(e[i(613)],e[i(1566)])?(this[i(575)+i(1230)](),this[i(905)](i(1460)+i(839)+"s",e[i(2004)]),this[i(1248)+i(763)+"Id"]=_0x3a6476(this._ping[i(586)](this),_0x20c8ae)):(this._isBrowser&&window[i(1839)+"entListener"](e[i(707)],this[i(1996)+i(1844)]),this[i(888)+"er"]&&window[i(1839)+"entListe"+i(951)](e[i(1038)],this[i(1996)+i(729)]),this[i(1418)]())),this[i(888)+"er"]&&window[i(1839)+"entListe"+i(951)]("online",this[i(1580)+"nLine"]),this._isBrowser&&window[i(1839)+i(550)+i(951)](i(1378),this._handleOffLine)):(_0x421b8d[_0x5c6e03++]=e.jRGri(_0x201360>>6,192),_0x40917c[_0x281394++]=e.frJsr(63&_0x149748,128))}["_handleP"+t(729)](n){let i=t;n[i(1686)+"d"]&&(this[i(1945)+i(467)]()&&(!this[i(1482)]||e.oTMaj(this[i(1482)].readyState,this[i(705)])||e.gkeJE(this._ws[i(751)+"te"],this.CONNECTING))&&this["_handleO"+i(1978)](),this._isBrowser&&window["addEvent"+i(1558)](i(1041),this[i(1580)+i(1978)]),this[i(888)+"er"]&&window[i(908)+i(1558)](e[i(549)],this["_handleO"+i(1233)]))}async["_generat"+t(1767)](n){let i=t,f={jlSqd:function(Pr,Nr,jh){return e[V(806)](Pr,Nr,jh)},bRgMs:e[i(852)]},{fpID:l,deviceID:h,bddID:m,ttwID:I,accessKey:g,aID:L,customParams:P={},enableAutoAck:F,enableQoS:G,QoSLevel:W,env:K}=this[i(647)],X,M,H;this._isBrowser||this._isMiniWX||this[i(515)+"T"]?e[i(1430)]==="zZzwr"?(X=location&&e[i(1997)](e[i(1309)],location[i(2020)])?e[i(793)]:e.vEJfM,M=n[i(1202)](/((^ws)|(^http))((?:[s]*:\/\/))/,""),H=/^wss(.*:\/\/)/.test(n)?n:""+X+M):(this[i(1552)+"ameSpace"]=_0x353a39,this[i(630)+i(2070)]=_0x378a5f,this[i(1816)+i(724)]=_0x1b099e,this[i(1326)]=iJdlPF[i(731)](_0x57d7ae,this[i(1552)+"ameSpace"],iJdlPF[i(1304)])):(X=e[i(793)],M=n[i(1202)](/(^http)((?:[s]*:\/\/))/,""),H=/(^ws)((?:[s]*:\/\/))/[i(861)](M)?M:""+X+M);let he=m?i(1719):I?i(817):"device_id",le=m||I||h;if(e[i(2058)](!le,!he))throw new Error(i(1550)+i(1662)+"ddID, de"+i(1876)+i(862));let Ni=e[i(1744)](e[i(1072)],typeof P)?await P():P,Wo=K?e[i(1367)](ch,K[i(925)],K[i(2050)]):{},Ko=Object.assign({device_platform:e.xVjDs,version_code:e.OYIBs,access_key:g,fpid:l,aid:L,[he]:le,xsack:F?1:0,xaack:F?1:0,xsqos:G?1:0,qos_level:G?W:void 0,qos_sdk_version:2,...Wo},Ni),Hh=Object.keys(Ko)[i(785)]((Pr,Nr)=>Ko[Nr]!==void 0?""+Pr+(Pr?"&":"?")+Nr+"="+Ko[Nr]:Pr,"");return H+i(1751)+Hh}async[t(1556)](){let n=t;if(e[n(920)](n(1375),e[n(673)])){let i={SstMq:function(h,m){return h(m)},JWVnT:e.ozSas,OTrFB:e[n(1508)],HEWYS:e.YUgeo,DarGo:e[n(1636)]};this[n(575)+n(1230)](),this["_pingPon"+n(763)+"Id"]=e[n(1907)](_0x4b61d3,this[n(1078)][n(586)](this),this[n(647)][n(1012)+n(1215)]);let f=()=>{let h=n;i[h(1446)](_0x586a26,i[h(826)]),this.off(h(1460)+"e_success",f),this.off("ping_onc"+h(2036)+"t",l)},l=()=>{let h=n;_0x5174a2(i[h(1913)]),this.off(i.HEWYS,f),this[h(1199)](i.DarGo,l)};this.on(e[n(1742)],f),this.on(e[n(1636)],l),this[n(1078)]()}else{if(this[n(1556)+n(1628)]||this[n(687)+n(799)])return;this._connectLock=!0;try{let i=this[n(1529)+n(1736)]?.[n(1534)+n(1443)+n(845)+n(1613)+n(1466)](),{timeoutInterval:f}=this._options;if(i){let h=this["_endpoin"+n(1736)]?.[n(1561)+n(1791)+"nt"](),m=this[n(1529)+n(1736)]?.[n(1033)+"ackupEndpointAnd"+n(1650)+n(1132)](),I=this[n(1529)+n(1736)]?.["getCurrentEndpoi"+n(1440)+n(657)]();if(m){let g=n(1873)+h+(n(452)+n(528)+n(1335)+n(1013)+n(1829)+n(1348)+n(1065))+m+(n(1911)+"y"),L=e[n(518)](rt,e[n(1383)],{message:g,code:$t[n(683)+n(1908)+"R"]});this[n(1147)](g),this[n(1695)+n(1764)+n(640)](L),this._url=await this[n(441)+n(1767)](m),this._debug(n(1873)+m+" "+I+n(1942)),this[n(1962)+"sListeners"]()}else{let g="connect "+h+(n(452)+n(528)+n(1335)+n(1784));this[n(1147)](g),this[n(1695)+"hErrorEv"+n(640)](e[n(578)](rt,n(1685),{message:g,code:$t[n(683)+n(1908)+"R"]}));return}}else{let h=this[n(1529)+n(1736)]?.[n(1561)+n(1791)+n(1635)+n(1879)](),m=this[n(1529)+n(1736)]?.[n(1561)+n(1791)+n(1440)+"ount"]();this[n(1677)]=await this[n(441)+n(1767)](h||""),this._debug(n(1873)+h+" "+m+n(1942)),this[n(1962)+n(411)+"rs"]()}if(this._isInit)this[n(1920)]=!1;else{let h=e.nNRum(Bo,"reconnect",{message:e[n(801)]});this["onStartR"+n(1690)]&&this[n(950)+n(1690)](h)}let l=this[n(1529)+n(1736)]?.[n(1561)+n(1791)+n(1440)+"ount"]()||0;e[n(1915)](l,1)&&await this[n(1346)](l-1),this[n(1147)](n(1834)+n(1755)+this._url+(n(727)+n(593))+this[n(1950)+"ls"]),this[n(1482)]=e[n(1396)](sh,{url:this[n(1677)],protocols:[this[n(1950)+"ls"]],headers:this._options[n(719)+n(923)+"s"][n(1775)+n(1639)]},this._options.ws),(this[n(888)+"er"]||this[n(1299)+"r"])&&this[n(1482)]&&(this._ws[n(1201)+"pe"]=this[n(1415)+n(1057)]),this[n(1627)+"steners"](),this[n(1556)+n(1886)+n(1705)]=e[n(892)](setTimeout,this[n(470)+"ut"][n(586)](this),f)}catch(i){throw this[n(1556)+n(1628)]=!1,i}}}[t(497)+t(2052)](){let n=t;e.jhDRt(clearTimeout,this[n(1556)+"ionTimeoutId"]),this[n(1556)+"ionTimeo"+n(1705)]=null}["_clearPi"+t(1230)](){let n=t;e[n(634)](clearTimeout,this[n(1248)+"gTimeoutId"]),e.ytvif(clearTimeout,this[n(1806)+"ctTimeou"+n(1525)]),this[n(1248)+n(763)+"Id"]=null,this[n(1806)+n(660)+n(1525)]=null}[t(1147)](...n){let i=t;this[i(647)].debug&&console[i(916)][i(1579)](console,[e[i(2016)],...n])}[t(1981)+t(885)+"e"](n){let i=t,{initReconnectInterval:f,maxReconnectInterval:l,reconnectIntervalGrowFactor:h}=this[i(647)],m=e[i(1624)](f,Math[i(1169)](h,n-1));return m>l?l:m}[t(1078)](){let n=t,i={FfWHn:e[n(624)],aDQqA:function(f,l,h,m){return e[n(921)](f,l,h,m)},HHWbJ:e.mMMyK,hloXH:function(f,l,h,m){return e.KLGBu(f,l,h,m)},hMZqU:e[n(1091)],TyPzp:function(f,l,h){return f(l,h)},TIAjX:e[n(1611)]};if(this._ws&&e[n(1881)](this[n(1482)].readyState,this[n(1238)+"NG"]))if(e[n(1213)](e[n(784)],n(1168))){let f=!!this[n(647)].enableQoS;if(!f)return{enabled:f,isQoSMessage:!1,isQoSAck:!1,isAckCleanupMessage:!1,ackMsgIds:[]};let l=_0x4b7763(_0x10d1ec[n(1703)][n(2039)],ncVrps[n(1306)],"2"),h=l&&ncVrps.aDQqA(_0x29cf18,_0x4a6b6b[n(1703)][n(2039)],ncVrps[n(844)],"1"),m=l&&ncVrps[n(836)](_0xf5ea33,_0x5e3614[n(1703)][n(2039)],ncVrps[n(1739)],"1"),I=m?ncVrps[n(1858)](_0x376ce0,_0x57dc6d[n(1703)].headers,ncVrps[n(812)])?.[n(2054)](",")[n(410)](_0x392051)||[]:[];return{enabled:f,isQoSMessage:l,isQoSAck:h,isAckCleanupMessage:m,ackMsgIds:I}}else{this["_clearPi"+n(1230)](),this[n(1248)+n(763)+"Id"]=e[n(489)](setTimeout,this[n(1078)][n(586)](this),this._options[n(1012)+n(1215)]);return}if(!this[n(1482)]||this[n(1482)][n(751)+"te"]!==this[n(705)])return void this[n(646)+n(1690)]();this[n(1482)]&&this._ws[n(1076)]("hi"),this[n(1806)+"ctTimeou"+n(1525)]=e[n(1587)](setTimeout,this[n(646)+n(1690)+n(1496)][n(586)](this),this[n(647)][n(1302)+n(1045)+n(1242)])}["_handleR"+t(1690)+t(1496)](){let n=t;this[n(1388)+n(1602)]?.[n(1432)](),this[n(905)](n(1460)+n(2036)+"t","timeout"),this[n(1388)+n(1602)]?.[n(783)+n(1533)+"nt"]()?this[n(646)+n(1690)]():this._ping()}[t(1945)+"orOnline"](){let n=t;if(e.rNBhh(e[n(1135)],e.ERRMj)){let i=this[n(1529)+"tManager"]?.getCurrentEndpoint();this._debug(n(1873)+i+n(452)),this[n(787)+"ect"](1001,e[n(1324)],!0)}else return this[n(515)+"T"]||this[n(525)+"X"]?this[n(986)+n(1656)+n(1864)]:(this[n(888)+"er"]||this[n(1299)+"r"])&&this[n(647)][n(1056)+n(1363)+"nged"]?navigator[n(1600)]:!0}[t(646)+"econnect"](){let n=t;!this[n(1945)+n(467)]()||this[n(687)+n(799)]||(this._endpointManager?.[n(1082)+n(1581)+n(600)](),this[n(1388)+n(1602)]?.[n(537)+n(1197)](),this._ws?this[n(787)+"ect"](1001,e[n(1492)],!0):this[n(1556)]())}[t(1173)+t(1282)+t(1820)](){let n=t,i={ARTek:function(f,l){return e.qpDUv(f,l)},KDMgZ:function(f,l){return e[V(831)](f,l)},GLDci:function(f,l){return e[V(1118)](f,l)},SpOMV:e[n(1622)]};this[n(515)+"T"]?tt[n(2056)+n(1958)+n(581)](({isConnected:f})=>{let l=n;this["_miniNav"+l(1656)+l(1864)]=f,f?this._handleOnLine():this[l(1580)+l(1233)]()}):this[n(525)+"X"]&&wx[n(2056)+n(1958)+n(581)](({isConnected:f})=>{let l=n;if(i[l(1927)]!==i.SpOMV){if(kciQGx[l(1081)](_0x488d0d,_0x263719))throw new _0x3aa29c(l(1663)+l(1401)+"e");let h=3;for(;h>=0;){let m=255&_0x187a01;_0x2d8fa8(m,_0x5e0604,kciQGx.KDMgZ(_0x57f2f3,h)),_0x2dfa54>>>=8,h--}return kciQGx[l(1274)](_0x32ed54,4)}else this[l(986)+"igatorOnline"]=f,f?this._handleOnLine():this["_handleO"+l(1233)]()})}[t(1346)](n){let i=t,f={zIKcw:function(l,h){return e.NNEtp(l,h)},iwiDS:i(1268)};return new Promise(l=>{let h=i;f.zIKcw(h(1985),f[h(1926)])?(this[h(1482)]&&this[h(1482)][h(1076)](_0x2ffad7),this[h(1816)+"Queue"][_0x25eb45]=null):setTimeout(l,this[h(1981)+h(885)+"e"](n))})}[t(787)+t(1465)](n=1e3,i="",f=!1){let l=t;this[l(1482)]&&this["_destroy"+l(1891)+"t"](n,i,f)}_onTimeout(){let n=t,i=this["_endpoin"+n(1736)]?.[n(1561)+n(1791)+"nt"]();this[n(1147)](n(1873)+i+" timeout"),this[n(787)+n(1465)](1001,e[n(1324)],!0)}[t(917)](n){let i=t,f=Ve(n);this[i(1482)]&&e[i(1700)](this[i(1482)][i(751)+"te"],this[i(705)])&&(this[i(1482)]&&this[i(1482)].send(f),this[i(1147)](i(496),n))}[t(1962)+"sListeners"](){let n=t;this[n(1482)]&&(this[n(1482)][n(1839)+n(550)+n(951)](e[n(794)],this[n(1315)]),this[n(1482)][n(1839)+n(550)+"ner"](e[n(2067)],this._onClose),this._ws[n(1839)+"entListe"+n(951)](e[n(1817)],this[n(654)+"ge"]),this[n(1482)][n(1839)+n(550)+n(951)]("error",this[n(996)]))}[t(1627)+t(569)](){let n=t,i=(n(1734)+"4")[n(2054)]("|"),f=0;for(;;){switch(i[f++]){case"0":this[n(1482)][n(908)+n(1558)](e[n(794)],this._onOpen);continue;case"1":this[n(1482)][n(908)+"Listener"](e[n(2067)],this._onClose);continue;case"2":this[n(1482)][n(908)+n(1558)](e[n(1817)],this[n(654)+"ge"]);continue;case"3":if(!this._ws)return;continue;case"4":this[n(1482)][n(908)+n(1558)](e[n(1383)],this[n(996)]);continue}break}}["_wsInsta"+t(1540)](n=1e3,i=""){let f=t;try{this[f(1482)]&&this._ws[f(1418)](n,i)}catch{}}[t(1398)+t(1891)+"t"](n=1e3,i="",f=!1){let l=t;if(this[l(575)+l(1230)](),this[l(497)+l(2052)](),this[l(1962)+l(411)+"rs"](),this[l(1164)+"nceClose"](1e3,i),this[l(1556)+"Lock"]=!1,f&&this[l(1945)+l(467)]()&&!this[l(687)+l(799)]){if(this[l(1529)+l(1736)]?.["checkRea"+l(1730)+"es"]())if(e[l(968)](e[l(1946)],e[l(1227)])){let m=this[l(1529)+l(1736)]?.[l(1561)+l(1791)+"nt"]();this[l(1695)+l(1740)+"ent"](e[l(1717)](ft,"close",{code:1006,reason:"connect "+m+(" timeout"+l(528)+"tries re"+l(1784)),wasClean:!0}))}else _0x37cfba[l(1575)]=_0x369fc1[l(1445)]()[l(1313)](()=>(_0x2e76f6(),_0x761ea0))[l(1313)](function(m){return m});else{let m=this._options[l(1157)+"tInterceptor"](n,i);this["_dispatc"+l(1740)+l(640)](ft(e[l(2067)],{code:n,reason:i,wasClean:!0,willReconnect:m})),m&&this[l(1556)]()}return}this[l(1945)+"orOnline"]()||this._readyClosed?this[l(1695)+"hCloseEv"+l(640)](ft(e[l(2067)],{code:n,reason:e.WTRCg})):this[l(1695)+l(1740)+"ent"](ft(e[l(2067)],{code:1006,reason:e[l(1151)]})),this[l(1482)]=null,this[l(1529)+l(1736)]?.[l(1082)+l(1581)+l(600)](),this["_pingLos"+l(1602)]?.[l(537)+"nter"]()}[t(1695)+t(2032)+"nt"](n){let i=t;this[i(905)](e[i(794)],n),this[i(940)]&&this.onopen(n)}[t(1695)+t(1411)+t(662)](n){let i=t;if(e[i(1097)]===e.cEdEp){let f=e[i(1774)].split("|"),l=0;for(;;){switch(f[l++]){case"0":mqWxjl.rZGwg(_0x43a5cd,h=>({...h,get:(m,I,g)=>_0x3148f9(m,I)||h[i(1894)](m,I,g),has:(m,I)=>!!_0x32ad7e(m,I)||h[i(1188)](m,I)}));continue;case"1":_0x2c0ae5=new _0x2a0b13;continue;case"2":mqWxjl[i(1229)](_0x367b71);continue;case"3":_0x29eaea=["put",mqWxjl[i(846)],mqWxjl[i(1572)],mqWxjl[i(977)]];continue;case"4":_0x39bc2e();continue;case"5":_0x631823=[mqWxjl[i(978)],i(1532),mqWxjl[i(681)],i(1625)+"ys",mqWxjl[i(1923)]];continue}break}}else this.emit(e.ufzHG,n),this[i(1531)+"e"]&&this[i(1531)+"e"](n)}_dispatchAckMessageEvent(n){let i=t;this[i(905)](e.CkHAW,n),this["onReceiv"+i(652)]&&this["onReceiv"+i(652)](n)}["_dispatc"+t(1764)+t(640)](n){let i=t;e[i(1414)](i(676),e[i(1141)])?(this[i(905)](i(1685),n),this.onerror&&this.onerror(n)):(this[i(1388)+i(1602)]?.[i(1432)](),this[i(905)](e[i(1636)],e.FnOBE),this[i(1388)+i(1602)]?.[i(783)+i(1533)+"nt"]()?this[i(646)+i(1690)]():this[i(1078)]())}[t(1695)+"hCloseEv"+t(640)](n){let i=t;this[i(905)](i(1418),n),this.onclose&&this[i(1698)](n)}get binaryType(){let n=t;return this[n(1482)]?this._ws.binaryType:this[n(1415)+n(1057)]}set[t(1201)+"pe"](n){let i=t;this[i(1415)+i(1057)]=n,this._ws&&(this[i(1482)].binaryType=n)}get retryCount(){let n=t;return this[n(1529)+n(1736)]?.[n(1561)+n(1791)+n(1440)+n(657)]()||0}get[t(1365)+t(1935)](){let n=t;if(e[n(1194)](n(1563),e[n(1519)])){let i=this[n(1326)][n(1799)+n(869)+"nc"](this[n(566)]),f=_0x56a70e[n(765)](e[n(587)](i,"{}"));return _0x409da9[n(469)](f)}else{let i=this[n(1816)+n(958)][n(785)]((f,l)=>(f+=l&&l[n(538)+"th"]||0,f),0);return e[n(1095)](i,this[n(1482)]?this[n(1482)]["buffered"+n(1935)]:0)}}get extensions(){let n=t;return this[n(1482)]?this[n(1482)].extensions:""}get protocol(){let n=t;if(e[n(1243)](e[n(750)],"qBIuL")){let i=_0x2f740a[n(540)+n(545)](_0xb8d222);return _0x4e36a6&&i[n(908)+n(1558)](mqWxjl[n(1447)],()=>_0x345932()),mqWxjl[n(1018)](_0x1e72b5,i)[n(1313)](()=>{})}else return this[n(1482)]?this[n(1482)][n(2020)]:""}get[t(751)+"te"](){let n=t;return this[n(1482)]?this[n(1482)][n(751)+"te"]:this._options[n(1971)+"cOpen"]?this[n(1238)+"NG"]:this[n(488)]}get[t(708)](){let n=t;return this[n(1482)]?this[n(1482)].url:this._url}[t(1418)](n=1e3,i){let f=t;if(e[f(454)](e[f(847)],f(1554)))return _0x33f181["objectSt"+f(1090)][1]?void 0:_0x2e0ae4[f(886)+"ore"](_0x474c29["objectSt"+f(1090)][0]);{let l=e.WYlCa[f(2054)]("|"),h=0;for(;;){switch(l[h++]){case"0":this["_dropGlo"+f(553)+"Listener"]();continue;case"1":this[f(687)+"osed"]=!0;continue;case"2":if(e[f(531)](this[f(1482)][f(751)+"te"],this[f(488)])||this._ws[f(751)+"te"]===this[f(755)])return void this._debug(e.LyXKK);continue;case"3":this["_destroy"+f(1891)+"t"](n,i);continue;case"4":this[f(1364)+f(693)]?.[f(807)]();continue;case"5":this[f(575)+"ngTimer"]();continue;case"6":if(!this[f(1482)])return void this[f(1147)](e[f(1200)]);continue;case"7":this[f(497)+f(2052)]();continue}break}}}async[t(1076)](n,i){let f=t;if(e[f(663)](null,n))throw new Error(e[f(1895)]);e[f(1342)](e.ENXth,typeof n)&&(n=JSON[f(535)+"y"](n)),e[f(1706)](e[f(2025)],typeof n)&&!(n instanceof ArrayBuffer)&&!(n[f(1441)]&&e[f(577)](n[f(1441)],ArrayBuffer))&&(n=JSON.stringify(n));let l=await e[f(695)](T0,n),h=e.WYmdC(ah,n),{method:m=0,service:I=this[f(647)][f(904)],logID:g=this[f(647)][f(493)+f(1835)](),headers:L=this[f(647)][f(2039)],payloadEncoding:P=this[f(647)]["payloadE"+f(830)],payloadType:F=this._options[f(1356)+"ype"],logIDNew:G=this._options[f(1570)+"Config"][f(803)+"toGenera"+f(959)+"ew"]?e[f(1518)](s,this[f(647)][f(1570)+f(1341)].userIp):""}=e[f(907)](i,{});if(!I)throw new Error(e[f(526)]);let W={SeqID:de[f(1738)+"er"](this._seqId++),LogID:de[f(1738)+"er"](g),service:I,method:m,headers:L,payloadEncoding:e[f(1517)](P,Object)?P[f(1155)]?P.encoding:"":P,payloadType:F instanceof Object?F[f(557)]?F[f(557)]:h:F||h,payload:l,LogIDNew:G},K=e[f(1376)](Ve,W);return this[f(1482)]&&this[f(1482)][f(751)+"te"]===this[f(705)]?(this._ws&&this._ws[f(1076)](K),this._debug(e[f(601)],W)):e.AIqrc(this[f(1816)+f(958)][f(1484)],this[f(647)]["maxMessa"+f(1905)+f(1762)])?(this[f(1816)+f(958)][f(1851)](K),this[f(1147)](e[f(820)],W)):(this[f(1816)+f(958)][f(866)](),this["_message"+f(958)][f(1851)](K)),{seqID:this._seqId,logID:g,logIDNew:G}}async[t(1157)+"t"](n){let i=t,{url:f}=e.wzqIY(n,{}),l=Array.isArray(f)?f:i(1940)==typeof f?[f]:[];n&&Object[i(1087)](this[i(647)],n),l&&l.length?this["_endpoin"+i(1736)]=new S0(l,this[i(647)][i(999)+"es"]):this[i(1529)+i(1736)]?.[i(1082)+"pointCon"+i(600)](),this["_pingLos"+i(1602)]?.[i(537)+"nter"](this[i(647)][i(1868)+"Count"]),this["_readyCl"+i(799)]=!1,this[i(1482)]&&this._ws[i(751)+"te"]!==this.CLOSED?this[i(787)+i(1465)](1e3,e[i(1980)],!0):(this[i(1920)]=!0,this[i(1556)]())}async[t(2055)](){let n=t;if(!this[n(1556)+n(1628)]){let i=e[n(492)].split("|"),f=0;for(;;){switch(i[f++]){case"0":this[n(1529)+n(1736)]?.["resetEndpointCon"+n(600)]();continue;case"1":this[n(1388)+n(1602)]?.["resetCou"+n(1197)]();continue;case"2":this[n(687)+"osed"]=!1;continue;case"3":this._isInit=!0;continue;case"4":this[n(1556)]();continue}break}}}["addEvent"+t(1558)](n,i){this.on(n,i)}[t(1438)+"Event"](n){let i=t,{type:f}=n;this[i(905)](f,n)}[t(1839)+t(550)+t(951)](n,i){this[t(1199)](n,i)}[t(1598)](){let n=t,i={hrReH:function(f,l){return f(l)},dgztZ:e[n(2004)],rDlAR:e.YUgeo,HFdgQ:e[n(1636)]};return new Promise((f,l)=>{let h=n,m={RjVqe:function(I,g){return I(g)},Jjiit:e[h(1508)],twcDo:e[h(1742)],IIrpY:e.DzkxG};if(e[h(1144)](h(781),e[h(1374)])){this[h(575)+h(1230)](),this["_pingPon"+h(763)+"Id"]=e[h(1888)](setTimeout,this[h(1078)][h(586)](this),this._options[h(1012)+h(1215)]);let I=()=>{let L=h;i[L(1178)](f,i[L(962)]),this.off(i.rDlAR,I),this.off(i.HFdgQ,g)},g=()=>{let L=h;m[L(1370)](l,m[L(1486)]),this[L(1199)](m.twcDo,I),this[L(1199)](m[L(1507)],g)};this.on(e[h(1742)],I),this.on(e[h(1636)],g),this._ping()}else this[h(1415)+h(1057)]=_0x39fe3a,this[h(1482)]&&(this._ws[h(1201)+"pe"]=_0x23d18c)})}}})(),ee[B(973)+"oseEvent"]=Ae[B(973)+B(551)],ee[B(1748)+B(1863)]=Ae[B(1748)+"rorEvent"],ee[B(1610)+"e"]=Ae[B(1610)+"e"],ee[B(662)]=Ae[B(662)],ee[B(1352)]=Ae[B(1352)],ee[B(1327)+"MessageEvent"]=Ae[B(1327)+B(882)+B(1028)],ee[B(882)+B(1028)]=Ae[B(882)+"vent"],ee[B(1026)+"t"]=Ae[B(1026)+"t"],ee[B(1502)+B(1814)]=Ae[B(1502)+B(1814)],ee[B(1318)+B(551)]=Ae[B(1318)+"oseEvent"],ee[B(1408)+B(1863)]=Ae[B(1408)+"rorEvent"],ee[B(1593)+B(1917)+"nt"]=Ae[B(1593)+"ssageEvent"],ee["createOp"+B(1616)]=Ae["createOp"+B(1616)],ee["createRe"+B(1606)+B(1028)]=Ae[B(815)+B(1606)+"vent"],ee[B(1451)+"rame"]=Ae[B(1451)+B(417)],ee[B(712)+B(1420)]=Ae["encodeFr"+B(1420)];for(no in Ae)[B(973)+B(551),B(1748)+"rorEvent",B(1610)+"e",B(662),"FWS",B(1327)+B(882)+B(1028),B(882)+"vent",B(1026)+"t",B(1502)+B(1814),B(1318)+B(551),B(1408)+B(1863),B(1593)+B(1917)+"nt","createOp"+B(1616),B(815)+"connectEvent",B(1451)+"rame",B(712)+B(1420)][B(1687)](no)===-1&&(ee[no]=Ae[no]);var no;Object[B(1182)+B(819)](ee,"__esModule",{value:!0})});var Ut=oe((z3,ml)=>{"use strict";var pl=["nodebuffer","arraybuffer","fragments"],gl=typeof Blob<"u";gl&&pl.push("blob");ml.exports={BINARY_TYPES:pl,CLOSE_TIMEOUT:3e4,EMPTY_BUFFER:Buffer.alloc(0),GUID:"258EAFA5-E914-47DA-95CA-C5AB0DC85B11",hasBlob:gl,kForOnEventAttribute:Symbol("kIsForOnEventAttribute"),kListener:Symbol("kListener"),kStatusCode:Symbol("status-code"),kWebSocket:Symbol("websocket"),NOOP:()=>{}}});var Ii=oe((F3,fo)=>{"use strict";var{EMPTY_BUFFER:Ry}=Ut(),Rc=Buffer[Symbol.species];function ky(t,e){if(t.length===0)return Ry;if(t.length===1)return t[0];let r=Buffer.allocUnsafe(e),s=0;for(let a=0;a<t.length;a++){let c=t[a];r.set(c,s),s+=c.length}return s<e?new Rc(r.buffer,r.byteOffset,s):r}function wl(t,e,r,s,a){for(let c=0;c<a;c++)r[s+c]=t[c]^e[c&3]}function _l(t,e){for(let r=0;r<t.length;r++)t[r]^=e[r&3]}function Ly(t){return t.length===t.buffer.byteLength?t.buffer:t.buffer.slice(t.byteOffset,t.byteOffset+t.length)}function kc(t){if(kc.readOnly=!0,Buffer.isBuffer(t))return t;let e;return t instanceof ArrayBuffer?e=new Rc(t):ArrayBuffer.isView(t)?e=new Rc(t.buffer,t.byteOffset,t.byteLength):(e=Buffer.from(t),kc.readOnly=!1),e}fo.exports={concat:ky,mask:wl,toArrayBuffer:Ly,toBuffer:kc,unmask:_l};if(!process.env.WS_NO_BUFFER_UTIL)try{let t=ue("bufferutil");fo.exports.mask=function(e,r,s,a,c){c<48?wl(e,r,s,a,c):t.mask(e,r,s,a,c)},fo.exports.unmask=function(e,r){e.length<32?_l(e,r):t.unmask(e,r)}}catch{}});var El=oe((U3,bl)=>{"use strict";var yl=Symbol("kDone"),Lc=Symbol("kRun"),Oc=class{constructor(e){this[yl]=()=>{this.pending--,this[Lc]()},this.concurrency=e||1/0,this.jobs=[],this.pending=0}add(e){this.jobs.push(e),this[Lc]()}[Lc](){if(this.pending!==this.concurrency&&this.jobs.length){let e=this.jobs.shift();this.pending++,e(this[yl])}}};bl.exports=Oc});var Ir=oe((q3,Cl)=>{"use strict";var Ci=ue("zlib"),vl=Ii(),Oy=El(),{kStatusCode:Sl}=Ut(),Py=Buffer[Symbol.species],Ny=Buffer.from([0,0,255,255]),lo=Symbol("permessage-deflate"),qt=Symbol("total-length"),vr=Symbol("callback"),wn=Symbol("buffers"),Sr=Symbol("error"),uo,Pc=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,!uo){let r=this._options.concurrencyLimit!==void 0?this._options.concurrencyLimit:10;uo=new Oy(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[vr];this._deflate.close(),this._deflate=null,e&&e(new Error("The deflate stream was closed while data was being processed"))}}acceptAsServer(e){let r=this._options,s=e.find(a=>!(r.serverNoContextTakeover===!1&&a.server_no_context_takeover||a.server_max_window_bits&&(r.serverMaxWindowBits===!1||typeof r.serverMaxWindowBits=="number"&&r.serverMaxWindowBits>a.server_max_window_bits)||typeof r.clientMaxWindowBits=="number"&&!a.client_max_window_bits));if(!s)throw new Error("None of the extension offers can be accepted");return r.serverNoContextTakeover&&(s.server_no_context_takeover=!0),r.clientNoContextTakeover&&(s.client_no_context_takeover=!0),typeof r.serverMaxWindowBits=="number"&&(s.server_max_window_bits=r.serverMaxWindowBits),typeof r.clientMaxWindowBits=="number"?s.client_max_window_bits=r.clientMaxWindowBits:(s.client_max_window_bits===!0||r.clientMaxWindowBits===!1)&&delete s.client_max_window_bits,s}acceptAsClient(e){let r=e[0];if(this._options.clientNoContextTakeover===!1&&r.client_no_context_takeover)throw new Error('Unexpected parameter "client_no_context_takeover"');if(!r.client_max_window_bits)typeof this._options.clientMaxWindowBits=="number"&&(r.client_max_window_bits=this._options.clientMaxWindowBits);else if(this._options.clientMaxWindowBits===!1||typeof this._options.clientMaxWindowBits=="number"&&r.client_max_window_bits>this._options.clientMaxWindowBits)throw new Error('Unexpected or invalid parameter "client_max_window_bits"');return r}normalizeParams(e){return e.forEach(r=>{Object.keys(r).forEach(s=>{let a=r[s];if(a.length>1)throw new Error(`Parameter "${s}" must have only a single value`);if(a=a[0],s==="client_max_window_bits"){if(a!==!0){let c=+a;if(!Number.isInteger(c)||c<8||c>15)throw new TypeError(`Invalid value for parameter "${s}": ${a}`);a=c}else if(!this._isServer)throw new TypeError(`Invalid value for parameter "${s}": ${a}`)}else if(s==="server_max_window_bits"){let c=+a;if(!Number.isInteger(c)||c<8||c>15)throw new TypeError(`Invalid value for parameter "${s}": ${a}`);a=c}else if(s==="client_no_context_takeover"||s==="server_no_context_takeover"){if(a!==!0)throw new TypeError(`Invalid value for parameter "${s}": ${a}`)}else throw new Error(`Unknown parameter "${s}"`);r[s]=a})}),e}decompress(e,r,s){uo.add(a=>{this._decompress(e,r,(c,d)=>{a(),s(c,d)})})}compress(e,r,s){uo.add(a=>{this._compress(e,r,(c,d)=>{a(),s(c,d)})})}_decompress(e,r,s){let a=this._isServer?"client":"server";if(!this._inflate){let c=`${a}_max_window_bits`,d=typeof this.params[c]!="number"?Ci.Z_DEFAULT_WINDOWBITS:this.params[c];this._inflate=Ci.createInflateRaw({...this._options.zlibInflateOptions,windowBits:d}),this._inflate[lo]=this,this._inflate[qt]=0,this._inflate[wn]=[],this._inflate.on("error",By),this._inflate.on("data",Il)}this._inflate[vr]=s,this._inflate.write(e),r&&this._inflate.write(Ny),this._inflate.flush(()=>{let c=this._inflate[Sr];if(c){this._inflate.close(),this._inflate=null,s(c);return}let d=vl.concat(this._inflate[wn],this._inflate[qt]);this._inflate._readableState.endEmitted?(this._inflate.close(),this._inflate=null):(this._inflate[qt]=0,this._inflate[wn]=[],r&&this.params[`${a}_no_context_takeover`]&&this._inflate.reset()),s(null,d)})}_compress(e,r,s){let a=this._isServer?"server":"client";if(!this._deflate){let c=`${a}_max_window_bits`,d=typeof this.params[c]!="number"?Ci.Z_DEFAULT_WINDOWBITS:this.params[c];this._deflate=Ci.createDeflateRaw({...this._options.zlibDeflateOptions,windowBits:d}),this._deflate[qt]=0,this._deflate[wn]=[],this._deflate.on("data",My)}this._deflate[vr]=s,this._deflate.write(e),this._deflate.flush(Ci.Z_SYNC_FLUSH,()=>{if(!this._deflate)return;let c=vl.concat(this._deflate[wn],this._deflate[qt]);r&&(c=new Py(c.buffer,c.byteOffset,c.length-4)),this._deflate[vr]=null,this._deflate[qt]=0,this._deflate[wn]=[],r&&this.params[`${a}_no_context_takeover`]&&this._deflate.reset(),s(null,c)})}};Cl.exports=Pc;function My(t){this[wn].push(t),this[qt]+=t.length}function Il(t){if(this[qt]+=t.length,this[lo]._maxPayload<1||this[qt]<=this[lo]._maxPayload){this[wn].push(t);return}this[Sr]=new RangeError("Max payload size exceeded"),this[Sr].code="WS_ERR_UNSUPPORTED_MESSAGE_LENGTH",this[Sr][Sl]=1009,this.removeListener("data",Il),this.reset()}function By(t){if(this[lo]._inflate=null,this[Sr]){this[vr](this[Sr]);return}t[Sl]=1007,this[vr](t)}});var Cr=oe((H3,xo)=>{"use strict";var{isUtf8:Al}=ue("buffer"),{hasBlob:zy}=Ut(),Fy=[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 Uy(t){return t>=1e3&&t<=1014&&t!==1004&&t!==1005&&t!==1006||t>=3e3&&t<=4999}function Nc(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 qy(t){return zy&&typeof t=="object"&&typeof t.arrayBuffer=="function"&&typeof t.type=="string"&&typeof t.stream=="function"&&(t[Symbol.toStringTag]==="Blob"||t[Symbol.toStringTag]==="File")}xo.exports={isBlob:qy,isValidStatusCode:Uy,isValidUTF8:Nc,tokenChars:Fy};if(Al)xo.exports.isValidUTF8=function(t){return t.length<24?Nc(t):Al(t)};else if(!process.env.WS_NO_UTF_8_VALIDATE)try{let t=ue("utf-8-validate");xo.exports.isValidUTF8=function(e){return e.length<32?Nc(e):t(e)}}catch{}});var Uc=oe((j3,Pl)=>{"use strict";var{Writable:Hy}=ue("stream"),Tl=Ir(),{BINARY_TYPES:jy,EMPTY_BUFFER:Dl,kStatusCode:Gy,kWebSocket:Wy}=Ut(),{concat:Mc,toArrayBuffer:Ky,unmask:$y}=Ii(),{isValidStatusCode:Vy,isValidUTF8:Rl}=Cr(),ho=Buffer[Symbol.species],ot=0,kl=1,Ll=2,Ol=3,Bc=4,zc=5,po=6,Fc=class extends Hy{constructor(e={}){super(),this._allowSynchronousEvents=e.allowSynchronousEvents!==void 0?e.allowSynchronousEvents:!0,this._binaryType=e.binaryType||jy[0],this._extensions=e.extensions||{},this._isServer=!!e.isServer,this._maxPayload=e.maxPayload|0,this._skipUTF8Validation=!!e.skipUTF8Validation,this[Wy]=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=ot}_write(e,r,s){if(this._opcode===8&&this._state==ot)return s();this._bufferedBytes+=e.length,this._buffers.push(e),this.startLoop(s)}consume(e){if(this._bufferedBytes-=e,e===this._buffers[0].length)return this._buffers.shift();if(e<this._buffers[0].length){let s=this._buffers[0];return this._buffers[0]=new ho(s.buffer,s.byteOffset+e,s.length-e),new ho(s.buffer,s.byteOffset,e)}let r=Buffer.allocUnsafe(e);do{let s=this._buffers[0],a=r.length-e;e>=s.length?r.set(this._buffers.shift(),a):(r.set(new Uint8Array(s.buffer,s.byteOffset,e),a),this._buffers[0]=new ho(s.buffer,s.byteOffset+e,s.length-e)),e-=s.length}while(e>0);return r}startLoop(e){this._loop=!0;do switch(this._state){case ot:this.getInfo(e);break;case kl:this.getPayloadLength16(e);break;case Ll:this.getPayloadLength64(e);break;case Ol:this.getMask();break;case Bc:this.getData(e);break;case zc:case po:this._loop=!1;return}while(this._loop);this._errored||e()}getInfo(e){if(this._bufferedBytes<2){this._loop=!1;return}let r=this.consume(2);if((r[0]&48)!==0){let a=this.createError(RangeError,"RSV2 and RSV3 must be clear",!0,1002,"WS_ERR_UNEXPECTED_RSV_2_3");e(a);return}let s=(r[0]&64)===64;if(s&&!this._extensions[Tl.extensionName]){let a=this.createError(RangeError,"RSV1 must be clear",!0,1002,"WS_ERR_UNEXPECTED_RSV_1");e(a);return}if(this._fin=(r[0]&128)===128,this._opcode=r[0]&15,this._payloadLength=r[1]&127,this._opcode===0){if(s){let a=this.createError(RangeError,"RSV1 must be clear",!0,1002,"WS_ERR_UNEXPECTED_RSV_1");e(a);return}if(!this._fragmented){let a=this.createError(RangeError,"invalid opcode 0",!0,1002,"WS_ERR_INVALID_OPCODE");e(a);return}this._opcode=this._fragmented}else if(this._opcode===1||this._opcode===2){if(this._fragmented){let a=this.createError(RangeError,`invalid opcode ${this._opcode}`,!0,1002,"WS_ERR_INVALID_OPCODE");e(a);return}this._compressed=s}else if(this._opcode>7&&this._opcode<11){if(!this._fin){let a=this.createError(RangeError,"FIN must be set",!0,1002,"WS_ERR_EXPECTED_FIN");e(a);return}if(s){let a=this.createError(RangeError,"RSV1 must be clear",!0,1002,"WS_ERR_UNEXPECTED_RSV_1");e(a);return}if(this._payloadLength>125||this._opcode===8&&this._payloadLength===1){let a=this.createError(RangeError,`invalid payload length ${this._payloadLength}`,!0,1002,"WS_ERR_INVALID_CONTROL_PAYLOAD_LENGTH");e(a);return}}else{let a=this.createError(RangeError,`invalid opcode ${this._opcode}`,!0,1002,"WS_ERR_INVALID_OPCODE");e(a);return}if(!this._fin&&!this._fragmented&&(this._fragmented=this._opcode),this._masked=(r[1]&128)===128,this._isServer){if(!this._masked){let a=this.createError(RangeError,"MASK must be set",!0,1002,"WS_ERR_EXPECTED_MASK");e(a);return}}else if(this._masked){let a=this.createError(RangeError,"MASK must be clear",!0,1002,"WS_ERR_UNEXPECTED_MASK");e(a);return}this._payloadLength===126?this._state=kl:this._payloadLength===127?this._state=Ll:this.haveLength(e)}getPayloadLength16(e){if(this._bufferedBytes<2){this._loop=!1;return}this._payloadLength=this.consume(2).readUInt16BE(0),this.haveLength(e)}getPayloadLength64(e){if(this._bufferedBytes<8){this._loop=!1;return}let r=this.consume(8),s=r.readUInt32BE(0);if(s>Math.pow(2,21)-1){let a=this.createError(RangeError,"Unsupported WebSocket frame: payload length > 2^53 - 1",!1,1009,"WS_ERR_UNSUPPORTED_DATA_PAYLOAD_LENGTH");e(a);return}this._payloadLength=s*Math.pow(2,32)+r.readUInt32BE(4),this.haveLength(e)}haveLength(e){if(this._payloadLength&&this._opcode<8&&(this._totalPayloadLength+=this._payloadLength,this._totalPayloadLength>this._maxPayload&&this._maxPayload>0)){let r=this.createError(RangeError,"Max payload size exceeded",!1,1009,"WS_ERR_UNSUPPORTED_MESSAGE_LENGTH");e(r);return}this._masked?this._state=Ol:this._state=Bc}getMask(){if(this._bufferedBytes<4){this._loop=!1;return}this._mask=this.consume(4),this._state=Bc}getData(e){let r=Dl;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&&$y(r,this._mask)}if(this._opcode>7){this.controlMessage(r,e);return}if(this._compressed){this._state=zc,this.decompress(r,e);return}r.length&&(this._messageLength=this._totalPayloadLength,this._fragments.push(r)),this.dataMessage(e)}decompress(e,r){this._extensions[Tl.extensionName].decompress(e,this._fin,(a,c)=>{if(a)return r(a);if(c.length){if(this._messageLength+=c.length,this._messageLength>this._maxPayload&&this._maxPayload>0){let d=this.createError(RangeError,"Max payload size exceeded",!1,1009,"WS_ERR_UNSUPPORTED_MESSAGE_LENGTH");r(d);return}this._fragments.push(c)}this.dataMessage(r),this._state===ot&&this.startLoop(r)})}dataMessage(e){if(!this._fin){this._state=ot;return}let r=this._messageLength,s=this._fragments;if(this._totalPayloadLength=0,this._messageLength=0,this._fragmented=0,this._fragments=[],this._opcode===2){let a;this._binaryType==="nodebuffer"?a=Mc(s,r):this._binaryType==="arraybuffer"?a=Ky(Mc(s,r)):this._binaryType==="blob"?a=new Blob(s):a=s,this._allowSynchronousEvents?(this.emit("message",a,!0),this._state=ot):(this._state=po,setImmediate(()=>{this.emit("message",a,!0),this._state=ot,this.startLoop(e)}))}else{let a=Mc(s,r);if(!this._skipUTF8Validation&&!Rl(a)){let c=this.createError(Error,"invalid UTF-8 sequence",!0,1007,"WS_ERR_INVALID_UTF8");e(c);return}this._state===zc||this._allowSynchronousEvents?(this.emit("message",a,!1),this._state=ot):(this._state=po,setImmediate(()=>{this.emit("message",a,!1),this._state=ot,this.startLoop(e)}))}}controlMessage(e,r){if(this._opcode===8){if(e.length===0)this._loop=!1,this.emit("conclude",1005,Dl),this.end();else{let s=e.readUInt16BE(0);if(!Vy(s)){let c=this.createError(RangeError,`invalid status code ${s}`,!0,1002,"WS_ERR_INVALID_CLOSE_CODE");r(c);return}let a=new ho(e.buffer,e.byteOffset+2,e.length-2);if(!this._skipUTF8Validation&&!Rl(a)){let c=this.createError(Error,"invalid UTF-8 sequence",!0,1007,"WS_ERR_INVALID_UTF8");r(c);return}this._loop=!1,this.emit("conclude",s,a),this.end()}this._state=ot;return}this._allowSynchronousEvents?(this.emit(this._opcode===9?"ping":"pong",e),this._state=ot):(this._state=po,setImmediate(()=>{this.emit(this._opcode===9?"ping":"pong",e),this._state=ot,this.startLoop(r)}))}createError(e,r,s,a,c){this._loop=!1,this._errored=!0;let d=new e(s?`Invalid WebSocket frame: ${r}`:r);return Error.captureStackTrace(d,this.createError),d.code=c,d[Gy]=a,d}};Pl.exports=Fc});var jc=oe((W3,Bl)=>{"use strict";var{Duplex:G3}=ue("stream"),{randomFillSync:Jy}=ue("crypto"),Nl=Ir(),{EMPTY_BUFFER:Zy,kWebSocket:Xy,NOOP:Yy}=Ut(),{isBlob:Ar,isValidStatusCode:Qy}=Cr(),{mask:Ml,toBuffer:Mn}=Ii(),at=Symbol("kByteLength"),eb=Buffer.alloc(4),go=8*1024,Bn,Tr=go,gt=0,tb=1,nb=2,qc=class t{constructor(e,r,s){this._extensions=r||{},s&&(this._generateMask=s,this._maskBuffer=Buffer.alloc(4)),this._socket=e,this._firstFragment=!0,this._compress=!1,this._bufferedBytes=0,this._queue=[],this._state=gt,this.onerror=Yy,this[Xy]=void 0}static frame(e,r){let s,a=!1,c=2,d=!1;r.mask&&(s=r.maskBuffer||eb,r.generateMask?r.generateMask(s):(Tr===go&&(Bn===void 0&&(Bn=Buffer.alloc(go)),Jy(Bn,0,go),Tr=0),s[0]=Bn[Tr++],s[1]=Bn[Tr++],s[2]=Bn[Tr++],s[3]=Bn[Tr++]),d=(s[0]|s[1]|s[2]|s[3])===0,c=6);let u;typeof e=="string"?(!r.mask||d)&&r[at]!==void 0?u=r[at]:(e=Buffer.from(e),u=e.length):(u=e.length,a=r.mask&&r.readOnly&&!d);let x=u;u>=65536?(c+=8,x=127):u>125&&(c+=2,x=126);let p=Buffer.allocUnsafe(a?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]=s[0],p[c-3]=s[1],p[c-2]=s[2],p[c-1]=s[3],d?[p,e]:a?(Ml(e,s,p,c,u),[p]):(Ml(e,s,e,0,u),[p,e])):[p,e]}close(e,r,s,a){let c;if(e===void 0)c=Zy;else{if(typeof e!="number"||!Qy(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 d={[at]:c.length,fin:!0,generateMask:this._generateMask,mask:s,maskBuffer:this._maskBuffer,opcode:8,readOnly:!1,rsv1:!1};this._state!==gt?this.enqueue([this.dispatch,c,!1,d,a]):this.sendFrame(t.frame(c,d),a)}ping(e,r,s){let a,c;if(typeof e=="string"?(a=Buffer.byteLength(e),c=!1):Ar(e)?(a=e.size,c=!1):(e=Mn(e),a=e.length,c=Mn.readOnly),a>125)throw new RangeError("The data size must not be greater than 125 bytes");let d={[at]:a,fin:!0,generateMask:this._generateMask,mask:r,maskBuffer:this._maskBuffer,opcode:9,readOnly:c,rsv1:!1};Ar(e)?this._state!==gt?this.enqueue([this.getBlobData,e,!1,d,s]):this.getBlobData(e,!1,d,s):this._state!==gt?this.enqueue([this.dispatch,e,!1,d,s]):this.sendFrame(t.frame(e,d),s)}pong(e,r,s){let a,c;if(typeof e=="string"?(a=Buffer.byteLength(e),c=!1):Ar(e)?(a=e.size,c=!1):(e=Mn(e),a=e.length,c=Mn.readOnly),a>125)throw new RangeError("The data size must not be greater than 125 bytes");let d={[at]:a,fin:!0,generateMask:this._generateMask,mask:r,maskBuffer:this._maskBuffer,opcode:10,readOnly:c,rsv1:!1};Ar(e)?this._state!==gt?this.enqueue([this.getBlobData,e,!1,d,s]):this.getBlobData(e,!1,d,s):this._state!==gt?this.enqueue([this.dispatch,e,!1,d,s]):this.sendFrame(t.frame(e,d),s)}send(e,r,s){let a=this._extensions[Nl.extensionName],c=r.binary?2:1,d=r.compress,u,x;typeof e=="string"?(u=Buffer.byteLength(e),x=!1):Ar(e)?(u=e.size,x=!1):(e=Mn(e),u=e.length,x=Mn.readOnly),this._firstFragment?(this._firstFragment=!1,d&&a&&a.params[a._isServer?"server_no_context_takeover":"client_no_context_takeover"]&&(d=u>=a._threshold),this._compress=d):(d=!1,c=0),r.fin&&(this._firstFragment=!0);let p={[at]:u,fin:r.fin,generateMask:this._generateMask,mask:r.mask,maskBuffer:this._maskBuffer,opcode:c,readOnly:x,rsv1:d};Ar(e)?this._state!==gt?this.enqueue([this.getBlobData,e,this._compress,p,s]):this.getBlobData(e,this._compress,p,s):this._state!==gt?this.enqueue([this.dispatch,e,this._compress,p,s]):this.dispatch(e,this._compress,p,s)}getBlobData(e,r,s,a){this._bufferedBytes+=s[at],this._state=nb,e.arrayBuffer().then(c=>{if(this._socket.destroyed){let u=new Error("The socket was closed while the blob was being read");process.nextTick(Hc,this,u,a);return}this._bufferedBytes-=s[at];let d=Mn(c);r?this.dispatch(d,r,s,a):(this._state=gt,this.sendFrame(t.frame(d,s),a),this.dequeue())}).catch(c=>{process.nextTick(rb,this,c,a)})}dispatch(e,r,s,a){if(!r){this.sendFrame(t.frame(e,s),a);return}let c=this._extensions[Nl.extensionName];this._bufferedBytes+=s[at],this._state=tb,c.compress(e,s.fin,(d,u)=>{if(this._socket.destroyed){let x=new Error("The socket was closed while data was being compressed");Hc(this,x,a);return}this._bufferedBytes-=s[at],this._state=gt,s.readOnly=!1,this.sendFrame(t.frame(u,s),a),this.dequeue()})}dequeue(){for(;this._state===gt&&this._queue.length;){let e=this._queue.shift();this._bufferedBytes-=e[3][at],Reflect.apply(e[0],this,e.slice(1))}}enqueue(e){this._bufferedBytes+=e[3][at],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)}};Bl.exports=qc;function Hc(t,e,r){typeof r=="function"&&r(e);for(let s=0;s<t._queue.length;s++){let a=t._queue[s],c=a[a.length-1];typeof c=="function"&&c(e)}}function rb(t,e,r){Hc(t,e,r),t.onerror(e)}});var Kl=oe((K3,Wl)=>{"use strict";var{kForOnEventAttribute:Ai,kListener:Gc}=Ut(),zl=Symbol("kCode"),Fl=Symbol("kData"),Ul=Symbol("kError"),ql=Symbol("kMessage"),Hl=Symbol("kReason"),Dr=Symbol("kTarget"),jl=Symbol("kType"),Gl=Symbol("kWasClean"),Ht=class{constructor(e){this[Dr]=null,this[jl]=e}get target(){return this[Dr]}get type(){return this[jl]}};Object.defineProperty(Ht.prototype,"target",{enumerable:!0});Object.defineProperty(Ht.prototype,"type",{enumerable:!0});var zn=class extends Ht{constructor(e,r={}){super(e),this[zl]=r.code===void 0?0:r.code,this[Hl]=r.reason===void 0?"":r.reason,this[Gl]=r.wasClean===void 0?!1:r.wasClean}get code(){return this[zl]}get reason(){return this[Hl]}get wasClean(){return this[Gl]}};Object.defineProperty(zn.prototype,"code",{enumerable:!0});Object.defineProperty(zn.prototype,"reason",{enumerable:!0});Object.defineProperty(zn.prototype,"wasClean",{enumerable:!0});var Rr=class extends Ht{constructor(e,r={}){super(e),this[Ul]=r.error===void 0?null:r.error,this[ql]=r.message===void 0?"":r.message}get error(){return this[Ul]}get message(){return this[ql]}};Object.defineProperty(Rr.prototype,"error",{enumerable:!0});Object.defineProperty(Rr.prototype,"message",{enumerable:!0});var Ti=class extends Ht{constructor(e,r={}){super(e),this[Fl]=r.data===void 0?null:r.data}get data(){return this[Fl]}};Object.defineProperty(Ti.prototype,"data",{enumerable:!0});var ib={addEventListener(t,e,r={}){for(let a of this.listeners(t))if(!r[Ai]&&a[Gc]===e&&!a[Ai])return;let s;if(t==="message")s=function(c,d){let u=new Ti("message",{data:d?c:c.toString()});u[Dr]=this,mo(e,this,u)};else if(t==="close")s=function(c,d){let u=new zn("close",{code:c,reason:d.toString(),wasClean:this._closeFrameReceived&&this._closeFrameSent});u[Dr]=this,mo(e,this,u)};else if(t==="error")s=function(c){let d=new Rr("error",{error:c,message:c.message});d[Dr]=this,mo(e,this,d)};else if(t==="open")s=function(){let c=new Ht("open");c[Dr]=this,mo(e,this,c)};else return;s[Ai]=!!r[Ai],s[Gc]=e,r.once?this.once(t,s):this.on(t,s)},removeEventListener(t,e){for(let r of this.listeners(t))if(r[Gc]===e&&!r[Ai]){this.removeListener(t,r);break}}};Wl.exports={CloseEvent:zn,ErrorEvent:Rr,Event:Ht,EventTarget:ib,MessageEvent:Ti};function mo(t,e,r){typeof t=="object"&&t.handleEvent?t.handleEvent.call(t,r):t.call(e,r)}});var wo=oe(($3,$l)=>{"use strict";var{tokenChars:Di}=Cr();function kt(t,e,r){t[e]===void 0?t[e]=[r]:t[e].push(r)}function sb(t){let e=Object.create(null),r=Object.create(null),s=!1,a=!1,c=!1,d,u,x=-1,p=-1,_=-1,w=0;for(;w<t.length;w++)if(p=t.charCodeAt(w),d===void 0)if(_===-1&&Di[p]===1)x===-1&&(x=w);else if(w!==0&&(p===32||p===9))_===-1&&x!==-1&&(_=w);else if(p===59||p===44){if(x===-1)throw new SyntaxError(`Unexpected character at index ${w}`);_===-1&&(_=w);let b=t.slice(x,_);p===44?(kt(e,b,r),r=Object.create(null)):d=b,x=_=-1}else throw new SyntaxError(`Unexpected character at index ${w}`);else if(u===void 0)if(_===-1&&Di[p]===1)x===-1&&(x=w);else if(p===32||p===9)_===-1&&x!==-1&&(_=w);else if(p===59||p===44){if(x===-1)throw new SyntaxError(`Unexpected character at index ${w}`);_===-1&&(_=w),kt(r,t.slice(x,_),!0),p===44&&(kt(e,d,r),r=Object.create(null),d=void 0),x=_=-1}else if(p===61&&x!==-1&&_===-1)u=t.slice(x,w),x=_=-1;else throw new SyntaxError(`Unexpected character at index ${w}`);else if(a){if(Di[p]!==1)throw new SyntaxError(`Unexpected character at index ${w}`);x===-1?x=w:s||(s=!0),a=!1}else if(c)if(Di[p]===1)x===-1&&(x=w);else if(p===34&&x!==-1)c=!1,_=w;else if(p===92)a=!0;else throw new SyntaxError(`Unexpected character at index ${w}`);else if(p===34&&t.charCodeAt(w-1)===61)c=!0;else if(_===-1&&Di[p]===1)x===-1&&(x=w);else if(x!==-1&&(p===32||p===9))_===-1&&(_=w);else if(p===59||p===44){if(x===-1)throw new SyntaxError(`Unexpected character at index ${w}`);_===-1&&(_=w);let b=t.slice(x,_);s&&(b=b.replace(/\\/g,""),s=!1),kt(r,u,b),p===44&&(kt(e,d,r),r=Object.create(null),d=void 0),u=void 0,x=_=-1}else throw new SyntaxError(`Unexpected character at index ${w}`);if(x===-1||c||p===32||p===9)throw new SyntaxError("Unexpected end of input");_===-1&&(_=w);let S=t.slice(x,_);return d===void 0?kt(e,S,r):(u===void 0?kt(r,S,!0):s?kt(r,u,S.replace(/\\/g,"")):kt(r,u,S),kt(e,d,r)),e}function ob(t){return Object.keys(t).map(e=>{let r=t[e];return Array.isArray(r)||(r=[r]),r.map(s=>[e].concat(Object.keys(s).map(a=>{let c=s[a];return Array.isArray(c)||(c=[c]),c.map(d=>d===!0?a:`${a}=${d}`).join("; ")})).join("; ")).join(", ")}).join(", ")}$l.exports={format:ob,parse:sb}});var Eo=oe((Z3,sx)=>{"use strict";var ab=ue("events"),cb=ue("https"),fb=ue("http"),Zl=ue("net"),db=ue("tls"),{randomBytes:ub,createHash:lb}=ue("crypto"),{Duplex:V3,Readable:J3}=ue("stream"),{URL:Wc}=ue("url"),_n=Ir(),xb=Uc(),hb=jc(),{isBlob:pb}=Cr(),{BINARY_TYPES:Vl,CLOSE_TIMEOUT:gb,EMPTY_BUFFER:_o,GUID:mb,kForOnEventAttribute:Kc,kListener:wb,kStatusCode:_b,kWebSocket:ze,NOOP:Xl}=Ut(),{EventTarget:{addEventListener:yb,removeEventListener:bb}}=Kl(),{format:Eb,parse:vb}=wo(),{toBuffer:Sb}=Ii(),Yl=Symbol("kAborted"),$c=[8,13],jt=["CONNECTING","OPEN","CLOSING","CLOSED"],Ib=/^[!#$%&'*+\-.0-9A-Z^_`|a-z~]+$/,pe=class t extends ab{constructor(e,r,s){super(),this._binaryType=Vl[0],this._closeCode=1006,this._closeFrameReceived=!1,this._closeFrameSent=!1,this._closeMessage=_o,this._closeTimer=null,this._errorEmitted=!1,this._extensions={},this._paused=!1,this._protocol="",this._readyState=t.CONNECTING,this._receiver=null,this._sender=null,this._socket=null,e!==null?(this._bufferedAmount=0,this._isServer=!1,this._redirects=0,r===void 0?r=[]:Array.isArray(r)||(typeof r=="object"&&r!==null?(s=r,r=[]):r=[r]),Ql(this,e,r,s)):(this._autoPong=s.autoPong,this._closeTimeout=s.closeTimeout,this._isServer=!0)}get binaryType(){return this._binaryType}set binaryType(e){Vl.includes(e)&&(this._binaryType=e,this._receiver&&(this._receiver._binaryType=e))}get bufferedAmount(){return this._socket?this._socket._writableState.length+this._sender._bufferedBytes:this._bufferedAmount}get extensions(){return Object.keys(this._extensions).join()}get isPaused(){return this._paused}get onclose(){return null}get onerror(){return null}get onopen(){return null}get onmessage(){return null}get protocol(){return this._protocol}get readyState(){return this._readyState}get url(){return this._url}setSocket(e,r,s){let a=new xb({allowSynchronousEvents:s.allowSynchronousEvents,binaryType:this.binaryType,extensions:this._extensions,isServer:this._isServer,maxPayload:s.maxPayload,skipUTF8Validation:s.skipUTF8Validation}),c=new hb(e,this._extensions,s.generateMask);this._receiver=a,this._sender=c,this._socket=e,a[ze]=this,c[ze]=this,e[ze]=this,a.on("conclude",Tb),a.on("drain",Db),a.on("error",Rb),a.on("message",kb),a.on("ping",Lb),a.on("pong",Ob),c.onerror=Pb,e.setTimeout&&e.setTimeout(0),e.setNoDelay&&e.setNoDelay(),r.length>0&&e.unshift(r),e.on("close",nx),e.on("data",bo),e.on("end",rx),e.on("error",ix),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[_n.extensionName]&&this._extensions[_n.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){nt(this,this._req,"WebSocket was closed before the connection was established");return}if(this.readyState===t.CLOSING){this._closeFrameSent&&(this._closeFrameReceived||this._receiver._writableState.errorEmitted)&&this._socket.end();return}this._readyState=t.CLOSING,this._sender.close(e,r,!this._isServer,s=>{s||(this._closeFrameSent=!0,(this._closeFrameReceived||this._receiver._writableState.errorEmitted)&&this._socket.end())}),tx(this)}}pause(){this.readyState===t.CONNECTING||this.readyState===t.CLOSED||(this._paused=!0,this._socket.pause())}ping(e,r,s){if(this.readyState===t.CONNECTING)throw new Error("WebSocket is not open: readyState 0 (CONNECTING)");if(typeof e=="function"?(s=e,e=r=void 0):typeof r=="function"&&(s=r,r=void 0),typeof e=="number"&&(e=e.toString()),this.readyState!==t.OPEN){Vc(this,e,s);return}r===void 0&&(r=!this._isServer),this._sender.ping(e||_o,r,s)}pong(e,r,s){if(this.readyState===t.CONNECTING)throw new Error("WebSocket is not open: readyState 0 (CONNECTING)");if(typeof e=="function"?(s=e,e=r=void 0):typeof r=="function"&&(s=r,r=void 0),typeof e=="number"&&(e=e.toString()),this.readyState!==t.OPEN){Vc(this,e,s);return}r===void 0&&(r=!this._isServer),this._sender.pong(e||_o,r,s)}resume(){this.readyState===t.CONNECTING||this.readyState===t.CLOSED||(this._paused=!1,this._receiver._writableState.needDrain||this._socket.resume())}send(e,r,s){if(this.readyState===t.CONNECTING)throw new Error("WebSocket is not open: readyState 0 (CONNECTING)");if(typeof r=="function"&&(s=r,r={}),typeof e=="number"&&(e=e.toString()),this.readyState!==t.OPEN){Vc(this,e,s);return}let a={binary:typeof e!="string",mask:!this._isServer,compress:!0,fin:!0,...r};this._extensions[_n.extensionName]||(a.compress=!1),this._sender.send(e||_o,a,s)}terminate(){if(this.readyState!==t.CLOSED){if(this.readyState===t.CONNECTING){nt(this,this._req,"WebSocket was closed before the connection was established");return}this._socket&&(this._readyState=t.CLOSING,this._socket.destroy())}}};Object.defineProperty(pe,"CONNECTING",{enumerable:!0,value:jt.indexOf("CONNECTING")});Object.defineProperty(pe.prototype,"CONNECTING",{enumerable:!0,value:jt.indexOf("CONNECTING")});Object.defineProperty(pe,"OPEN",{enumerable:!0,value:jt.indexOf("OPEN")});Object.defineProperty(pe.prototype,"OPEN",{enumerable:!0,value:jt.indexOf("OPEN")});Object.defineProperty(pe,"CLOSING",{enumerable:!0,value:jt.indexOf("CLOSING")});Object.defineProperty(pe.prototype,"CLOSING",{enumerable:!0,value:jt.indexOf("CLOSING")});Object.defineProperty(pe,"CLOSED",{enumerable:!0,value:jt.indexOf("CLOSED")});Object.defineProperty(pe.prototype,"CLOSED",{enumerable:!0,value:jt.indexOf("CLOSED")});["binaryType","bufferedAmount","extensions","isPaused","protocol","readyState","url"].forEach(t=>{Object.defineProperty(pe.prototype,t,{enumerable:!0})});["open","error","close","message"].forEach(t=>{Object.defineProperty(pe.prototype,`on${t}`,{enumerable:!0,get(){for(let e of this.listeners(t))if(e[Kc])return e[wb];return null},set(e){for(let r of this.listeners(t))if(r[Kc]){this.removeListener(t,r);break}typeof e=="function"&&this.addEventListener(t,e,{[Kc]:!0})}})});pe.prototype.addEventListener=yb;pe.prototype.removeEventListener=bb;sx.exports=pe;function Ql(t,e,r,s){let a={allowSynchronousEvents:!0,autoPong:!0,closeTimeout:gb,protocolVersion:$c[1],maxPayload:104857600,skipUTF8Validation:!1,perMessageDeflate:!0,followRedirects:!1,maxRedirects:10,...s,socketPath:void 0,hostname:void 0,protocol:void 0,timeout:void 0,method:"GET",host:void 0,path:void 0,port:void 0};if(t._autoPong=a.autoPong,t._closeTimeout=a.closeTimeout,!$c.includes(a.protocolVersion))throw new RangeError(`Unsupported protocol version: ${a.protocolVersion} (supported versions: ${$c.join(", ")})`);let c;if(e instanceof Wc)c=e;else try{c=new Wc(e)}catch{throw new SyntaxError(`Invalid URL: ${e}`)}c.protocol==="http:"?c.protocol="ws:":c.protocol==="https:"&&(c.protocol="wss:"),t._url=c.href;let d=c.protocol==="wss:",u=c.protocol==="ws+unix:",x;if(c.protocol!=="ws:"&&!d&&!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 v=new SyntaxError(x);if(t._redirects===0)throw v;yo(t,v);return}let p=d?443:80,_=ub(16).toString("base64"),w=d?cb.request:fb.request,S=new Set,b;if(a.createConnection=a.createConnection||(d?Ab:Cb),a.defaultPort=a.defaultPort||p,a.port=c.port||p,a.host=c.hostname.startsWith("[")?c.hostname.slice(1,-1):c.hostname,a.headers={...a.headers,"Sec-WebSocket-Version":a.protocolVersion,"Sec-WebSocket-Key":_,Connection:"Upgrade",Upgrade:"websocket"},a.path=c.pathname+c.search,a.timeout=a.handshakeTimeout,a.perMessageDeflate&&(b=new _n({...a.perMessageDeflate,isServer:!1,maxPayload:a.maxPayload}),a.headers["Sec-WebSocket-Extensions"]=Eb({[_n.extensionName]:b.offer()})),r.length){for(let v of r){if(typeof v!="string"||!Ib.test(v)||S.has(v))throw new SyntaxError("An invalid or duplicated subprotocol was specified");S.add(v)}a.headers["Sec-WebSocket-Protocol"]=r.join(",")}if(a.origin&&(a.protocolVersion<13?a.headers["Sec-WebSocket-Origin"]=a.origin:a.headers.Origin=a.origin),(c.username||c.password)&&(a.auth=`${c.username}:${c.password}`),u){let v=a.path.split(":");a.socketPath=v[0],a.path=v[1]}let E;if(a.followRedirects){if(t._redirects===0){t._originalIpc=u,t._originalSecure=d,t._originalHostOrSocketPath=u?a.socketPath:c.host;let v=s&&s.headers;if(s={...s,headers:{}},v)for(let[C,D]of Object.entries(v))s.headers[C.toLowerCase()]=D}else if(t.listenerCount("redirect")===0){let v=u?t._originalIpc?a.socketPath===t._originalHostOrSocketPath:!1:t._originalIpc?!1:c.host===t._originalHostOrSocketPath;(!v||t._originalSecure&&!d)&&(delete a.headers.authorization,delete a.headers.cookie,v||delete a.headers.host,a.auth=void 0)}a.auth&&!s.headers.authorization&&(s.headers.authorization="Basic "+Buffer.from(a.auth).toString("base64")),E=t._req=w(a),t._redirects&&t.emit("redirect",t.url,E)}else E=t._req=w(a);a.timeout&&E.on("timeout",()=>{nt(t,E,"Opening handshake has timed out")}),E.on("error",v=>{E===null||E[Yl]||(E=t._req=null,yo(t,v))}),E.on("response",v=>{let C=v.headers.location,D=v.statusCode;if(C&&a.followRedirects&&D>=300&&D<400){if(++t._redirects>a.maxRedirects){nt(t,E,"Maximum redirects exceeded");return}E.abort();let O;try{O=new Wc(C,e)}catch{let A=new SyntaxError(`Invalid URL: ${C}`);yo(t,A);return}Ql(t,O,r,s)}else t.emit("unexpected-response",E,v)||nt(t,E,`Unexpected server response: ${v.statusCode}`)}),E.on("upgrade",(v,C,D)=>{if(t.emit("upgrade",v),t.readyState!==pe.CONNECTING)return;E=t._req=null;let O=v.headers.upgrade;if(O===void 0||O.toLowerCase()!=="websocket"){nt(t,C,"Invalid Upgrade header");return}let y=lb("sha1").update(_+mb).digest("base64");if(v.headers["sec-websocket-accept"]!==y){nt(t,C,"Invalid Sec-WebSocket-Accept header");return}let A=v.headers["sec-websocket-protocol"],R;if(A!==void 0?S.size?S.has(A)||(R="Server sent an invalid subprotocol"):R="Server sent a subprotocol but none was requested":S.size&&(R="Server sent no subprotocol"),R){nt(t,C,R);return}A&&(t._protocol=A);let U=v.headers["sec-websocket-extensions"];if(U!==void 0){if(!b){nt(t,C,"Server sent a Sec-WebSocket-Extensions header but no extension was requested");return}let z;try{z=vb(U)}catch{nt(t,C,"Invalid Sec-WebSocket-Extensions header");return}let k=Object.keys(z);if(k.length!==1||k[0]!==_n.extensionName){nt(t,C,"Server indicated an extension that was not requested");return}try{b.accept(z[_n.extensionName])}catch{nt(t,C,"Invalid Sec-WebSocket-Extensions header");return}t._extensions[_n.extensionName]=b}t.setSocket(C,D,{allowSynchronousEvents:a.allowSynchronousEvents,generateMask:a.generateMask,maxPayload:a.maxPayload,skipUTF8Validation:a.skipUTF8Validation})}),a.finishRequest?a.finishRequest(E,t):E.end()}function yo(t,e){t._readyState=pe.CLOSING,t._errorEmitted=!0,t.emit("error",e),t.emitClose()}function Cb(t){return t.path=t.socketPath,Zl.connect(t)}function Ab(t){return t.path=void 0,!t.servername&&t.servername!==""&&(t.servername=Zl.isIP(t.host)?"":t.host),db.connect(t)}function nt(t,e,r){t._readyState=pe.CLOSING;let s=new Error(r);Error.captureStackTrace(s,nt),e.setHeader?(e[Yl]=!0,e.abort(),e.socket&&!e.socket.destroyed&&e.socket.destroy(),process.nextTick(yo,t,s)):(e.destroy(s),e.once("error",t.emit.bind(t,"error")),e.once("close",t.emitClose.bind(t)))}function Vc(t,e,r){if(e){let s=pb(e)?e.size:Sb(e).length;t._socket?t._sender._bufferedBytes+=s:t._bufferedAmount+=s}if(r){let s=new Error(`WebSocket is not open: readyState ${t.readyState} (${jt[t.readyState]})`);process.nextTick(r,s)}}function Tb(t,e){let r=this[ze];r._closeFrameReceived=!0,r._closeMessage=e,r._closeCode=t,r._socket[ze]!==void 0&&(r._socket.removeListener("data",bo),process.nextTick(ex,r._socket),t===1005?r.close():r.close(t,e))}function Db(){let t=this[ze];t.isPaused||t._socket.resume()}function Rb(t){let e=this[ze];e._socket[ze]!==void 0&&(e._socket.removeListener("data",bo),process.nextTick(ex,e._socket),e.close(t[_b])),e._errorEmitted||(e._errorEmitted=!0,e.emit("error",t))}function Jl(){this[ze].emitClose()}function kb(t,e){this[ze].emit("message",t,e)}function Lb(t){let e=this[ze];e._autoPong&&e.pong(t,!this._isServer,Xl),e.emit("ping",t)}function Ob(t){this[ze].emit("pong",t)}function ex(t){t.resume()}function Pb(t){let e=this[ze];e.readyState!==pe.CLOSED&&(e.readyState===pe.OPEN&&(e._readyState=pe.CLOSING,tx(e)),this._socket.end(),e._errorEmitted||(e._errorEmitted=!0,e.emit("error",t)))}function tx(t){t._closeTimer=setTimeout(t._socket.destroy.bind(t._socket),t._closeTimeout)}function nx(){let t=this[ze];if(this.removeListener("close",nx),this.removeListener("data",bo),this.removeListener("end",rx),t._readyState=pe.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[ze]=void 0,clearTimeout(t._closeTimer),t._receiver._writableState.finished||t._receiver._writableState.errorEmitted?t.emitClose():(t._receiver.on("error",Jl),t._receiver.on("finish",Jl))}function bo(t){this[ze]._receiver.write(t)||this.pause()}function rx(){let t=this[ze];t._readyState=pe.CLOSING,t._receiver.end(),this.end()}function ix(){let t=this[ze];this.removeListener("error",ix),this.on("error",Xl),t&&(t._readyState=pe.CLOSING,this.destroy())}});var fx=oe((Y3,cx)=>{"use strict";var X3=Eo(),{Duplex:Nb}=ue("stream");function ox(t){t.emit("close")}function Mb(){!this.destroyed&&this._writableState.finished&&this.destroy()}function ax(t){this.removeListener("error",ax),this.destroy(),this.listenerCount("error")===0&&this.emit("error",t)}function Bb(t,e){let r=!0,s=new Nb({...e,autoDestroy:!1,emitClose:!1,objectMode:!1,writableObjectMode:!1});return t.on("message",function(c,d){let u=!d&&s._readableState.objectMode?c.toString():c;s.push(u)||t.pause()}),t.once("error",function(c){s.destroyed||(r=!1,s.destroy(c))}),t.once("close",function(){s.destroyed||s.push(null)}),s._destroy=function(a,c){if(t.readyState===t.CLOSED){c(a),process.nextTick(ox,s);return}let d=!1;t.once("error",function(x){d=!0,c(x)}),t.once("close",function(){d||c(a),process.nextTick(ox,s)}),r&&t.terminate()},s._final=function(a){if(t.readyState===t.CONNECTING){t.once("open",function(){s._final(a)});return}t._socket!==null&&(t._socket._writableState.finished?(a(),s._readableState.endEmitted&&s.destroy()):(t._socket.once("finish",function(){a()}),t.close()))},s._read=function(){t.isPaused&&t.resume()},s._write=function(a,c,d){if(t.readyState===t.CONNECTING){t.once("open",function(){s._write(a,c,d)});return}t.send(a,d)},s.on("end",Mb),s.on("error",ax),s}cx.exports=Bb});var Jc=oe((Q3,dx)=>{"use strict";var{tokenChars:zb}=Cr();function Fb(t){let e=new Set,r=-1,s=-1,a=0;for(a;a<t.length;a++){let d=t.charCodeAt(a);if(s===-1&&zb[d]===1)r===-1&&(r=a);else if(a!==0&&(d===32||d===9))s===-1&&r!==-1&&(s=a);else if(d===44){if(r===-1)throw new SyntaxError(`Unexpected character at index ${a}`);s===-1&&(s=a);let u=t.slice(r,s);if(e.has(u))throw new SyntaxError(`The "${u}" subprotocol is duplicated`);e.add(u),r=s=-1}else throw new SyntaxError(`Unexpected character at index ${a}`)}if(r===-1||s!==-1)throw new SyntaxError("Unexpected end of input");let c=t.slice(r,a);if(e.has(c))throw new SyntaxError(`The "${c}" subprotocol is duplicated`);return e.add(c),e}dx.exports={parse:Fb}});var mx=oe((tC,gx)=>{"use strict";var Ub=ue("events"),vo=ue("http"),{Duplex:eC}=ue("stream"),{createHash:qb}=ue("crypto"),ux=wo(),Fn=Ir(),Hb=Jc(),jb=Eo(),{CLOSE_TIMEOUT:Gb,GUID:Wb,kWebSocket:Kb}=Ut(),$b=/^[+/0-9A-Za-z]{22}==$/,lx=0,xx=1,px=2,Zc=class extends Ub{constructor(e,r){if(super(),e={allowSynchronousEvents:!0,autoPong:!0,maxPayload:100*1024*1024,skipUTF8Validation:!1,perMessageDeflate:!1,handleProtocols:null,clientTracking:!0,closeTimeout:Gb,verifyClient:null,noServer:!1,backlog:null,server:null,host:null,path:null,port:null,WebSocket:jb,...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=vo.createServer((s,a)=>{let c=vo.STATUS_CODES[426];a.writeHead(426,{"Content-Length":c.length,"Content-Type":"text/plain"}),a.end(c)}),this._server.listen(e.port,e.host,e.backlog,r)):e.server&&(this._server=e.server),this._server){let s=this.emit.bind(this,"connection");this._removeListeners=Vb(this._server,{listening:this.emit.bind(this,"listening"),error:this.emit.bind(this,"error"),upgrade:(a,c,d)=>{this.handleUpgrade(a,c,d,s)}})}e.perMessageDeflate===!0&&(e.perMessageDeflate={}),e.clientTracking&&(this.clients=new Set,this._shouldEmitClose=!1),this.options=e,this._state=lx}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===px){e&&this.once("close",()=>{e(new Error("The server is not running"))}),process.nextTick(Ri,this);return}if(e&&this.once("close",e),this._state!==xx)if(this._state=xx,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(Ri,this):process.nextTick(Ri,this);else{let r=this._server;this._removeListeners(),this._removeListeners=this._server=null,r.close(()=>{Ri(this)})}}shouldHandle(e){if(this.options.path){let r=e.url.indexOf("?");if((r!==-1?e.url.slice(0,r):e.url)!==this.options.path)return!1}return!0}handleUpgrade(e,r,s,a){r.on("error",hx);let c=e.headers["sec-websocket-key"],d=e.headers.upgrade,u=+e.headers["sec-websocket-version"];if(e.method!=="GET"){Un(this,e,r,405,"Invalid HTTP method");return}if(d===void 0||d.toLowerCase()!=="websocket"){Un(this,e,r,400,"Invalid Upgrade header");return}if(c===void 0||!$b.test(c)){Un(this,e,r,400,"Missing or invalid Sec-WebSocket-Key header");return}if(u!==13&&u!==8){Un(this,e,r,400,"Missing or invalid Sec-WebSocket-Version header",{"Sec-WebSocket-Version":"13, 8"});return}if(!this.shouldHandle(e)){ki(r,400);return}let x=e.headers["sec-websocket-protocol"],p=new Set;if(x!==void 0)try{p=Hb.parse(x)}catch{Un(this,e,r,400,"Invalid Sec-WebSocket-Protocol header");return}let _=e.headers["sec-websocket-extensions"],w={};if(this.options.perMessageDeflate&&_!==void 0){let S=new Fn({...this.options.perMessageDeflate,isServer:!0,maxPayload:this.options.maxPayload});try{let b=ux.parse(_);b[Fn.extensionName]&&(S.accept(b[Fn.extensionName]),w[Fn.extensionName]=S)}catch{Un(this,e,r,400,"Invalid or unacceptable Sec-WebSocket-Extensions header");return}}if(this.options.verifyClient){let S={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(S,(b,E,v,C)=>{if(!b)return ki(r,E||401,v,C);this.completeUpgrade(w,c,p,e,r,s,a)});return}if(!this.options.verifyClient(S))return ki(r,401)}this.completeUpgrade(w,c,p,e,r,s,a)}completeUpgrade(e,r,s,a,c,d,u){if(!c.readable||!c.writable)return c.destroy();if(c[Kb])throw new Error("server.handleUpgrade() was called more than once with the same socket, possibly due to a misconfiguration");if(this._state>lx)return ki(c,503);let p=["HTTP/1.1 101 Switching Protocols","Upgrade: websocket","Connection: Upgrade",`Sec-WebSocket-Accept: ${qb("sha1").update(r+Wb).digest("base64")}`],_=new this.options.WebSocket(null,void 0,this.options);if(s.size){let w=this.options.handleProtocols?this.options.handleProtocols(s,a):s.values().next().value;w&&(p.push(`Sec-WebSocket-Protocol: ${w}`),_._protocol=w)}if(e[Fn.extensionName]){let w=e[Fn.extensionName].params,S=ux.format({[Fn.extensionName]:[w]});p.push(`Sec-WebSocket-Extensions: ${S}`),_._extensions=e}this.emit("headers",p,a),c.write(p.concat(`\r
|
|
8
|
+
var Hh=Object.create;var Go=Object.defineProperty;var jh=Object.getOwnPropertyDescriptor;var Gh=Object.getOwnPropertyNames;var Kh=Object.getPrototypeOf,Wh=Object.prototype.hasOwnProperty;var ae=(t=>typeof require<"u"?require:typeof Proxy<"u"?new Proxy(t,{get:(e,r)=>(typeof require<"u"?require:e)[r]}):t)(function(t){if(typeof require<"u")return require.apply(this,arguments);throw Error('Dynamic require of "'+t+'" is not supported')});var dt=(t,e)=>()=>(t&&(e=t(t=0)),e);var ne=(t,e)=>()=>(e||t((e={exports:{}}).exports,e),e.exports),Ko=(t,e)=>{for(var r in e)Go(t,r,{get:e[r],enumerable:!0})},$h=(t,e,r,s)=>{if(e&&typeof e=="object"||typeof e=="function")for(let a of Gh(e))!Wh.call(t,a)&&a!==r&&Go(t,a,{get:()=>e[a],enumerable:!(s=jh(e,a))||s.enumerable});return t};var gt=(t,e,r)=>(r=t!=null?Hh(Kh(t)):{},$h(e||!t||!t.__esModule?Go(r,"default",{value:t,enumerable:!0}):r,t));function O0(t){Wo=t}function P0(t){return Pi[Wo]<=Pi[t]}function Li(t){k0={...t}}function Zh(t){let e=(l,x=2)=>String(l).padStart(x,"0"),r=-t.getTimezoneOffset(),s=r>=0?"+":"-",a=Math.abs(r),c=e(Math.floor(a/60)),f=e(a%60);return`${t.getFullYear()}-${e(t.getMonth()+1)}-${e(t.getDate())}T${e(t.getHours())}:${e(t.getMinutes())}:${e(t.getSeconds())}.${e(t.getMilliseconds(),3)}${s}${c}:${f}`}function Oi(t,e,r,s){if(Pi[t]<Pi[Wo])return;let a=JSON.stringify({ts:Zh(new Date),level:t,module:e,msg:r,...k0,...s});t==="error"||t==="warn"?Jh.write(`${a}
|
|
9
|
+
`):Vh.write(`${a}
|
|
10
|
+
`)}function H(t){return{debug:(e,r)=>Oi("debug",t,e,r),info:(e,r)=>Oi("info",t,e,r),warn:(e,r)=>Oi("warn",t,e,r),error:(e,r)=>Oi("error",t,e,r),child:e=>H(`${t}.${e}`)}}var Pi,Wo,Vh,Jh,k0,ee=dt(()=>{"use strict";Pi={debug:10,info:20,warn:30,error:40},Wo=(()=>{let t=process.env.COZE_BRIDGE_LOG_LEVEL;return t==="debug"||t==="info"||t==="warn"||t==="error"?t:"info"})(),Vh=process.stdout,Jh=process.stderr,k0={}});import{execFile as Yh,spawn as Xh,spawnSync as g2}from"node:child_process";import{promisify as Qh}from"node:util";function tp(t){if(process.platform!=="win32")return!1;if(L0.test(t))return!0;let r=(t.split(/[/\\]/).pop()??t).replace(L0,"").toLowerCase();return ep.has(r)}function N0(t,e){if(process.platform!=="win32")return e??{};let r={...e??{}};return tp(t)&&r.shell===void 0&&(r.shell=!0),r.windowsHide===void 0&&(r.windowsHide=!0),r}function Vt(t,e=[],r={}){return Xh(t,e,N0(t,r))}function Ni(t,e=[],r={}){return np(t,e,N0(t,r))}var ep,L0,np,Wn=dt(()=>{"use strict";ep=new Set(["npm","npx","yarn","pnpm","coze","tsx","claude-agent-acp","codex-acp"]),L0=/\.(cmd|bat|ps1)$/i;np=Qh(Yh)});var U0={};Ko(U0,{_resetAcpInstallerForTests:()=>gp,_resetInstallTimeoutsForTests:()=>dp,_setBinaryPathCacheForTests:()=>wp,_setInFlightForTests:()=>mp,_setInstallTimeoutsForTests:()=>cp,ensureAcpInstalled:()=>yn,formatExecError:()=>z0,getAcpBinaryPath:()=>Jt,getAcpPackageSpec:()=>Lr,getInFlightInstall:()=>Jo,npmInstallGlobal:()=>F0,pickWhichLine:()=>zi,probeAcpVersion:()=>pp});import{readFile as rp,realpath as ip,stat as sp}from"node:fs/promises";import{dirname as $o,join as op}from"node:path";function Lr(t){let e=Vo[t];if(e)return`${e.npmPackage}@${e.versionSpec}`}function cp(t,e){Mi=t,Bi=e}function dp(){Mi=5e4,Bi=5e3}function hp(t){let e=t?.code;if(e&&lp.has(e))return!0;let r=t instanceof Error?`${t.message}
|
|
11
|
+
${t.stack??""}`:String(t);return up.test(r)||xp.test(r)}function z0(t){if(t==null||typeof t!="object")return String(t);let e=t,r=[];e.message&&r.push(e.message),e.code!==void 0&&e.code!==null&&r.push(`code=${e.code}`),e.signal&&r.push(`signal=${e.signal}`);let s=e.stderr?.toString().trim();s&&r.push(`stderr=${s.slice(0,2e3)}`);let a=e.stdout?.toString().trim();return a&&r.push(`stdout=${a.slice(0,2e3)}`),r.length>0?r.join(" | "):String(t)}async function M0(t){let e=process.platform==="win32"?"where":"which";try{let{stdout:r}=await Ni(e,[t],{timeout:ap});return zi(r)}catch{return}}function zi(t){let e=t.split(/\r?\n/).map(s=>s.trim()).filter(Boolean);if(e.length===0)return;if(process.platform!=="win32")return e[0];let r=s=>e.find(a=>a.toLowerCase().endsWith(s));return r(".cmd")??r(".exe")??r(".bat")??r(".ps1")??e[0]}async function pp(t){let e=Vo[t];if(!e)return;let r=Jt(t);if(!r){Fe.warn("acp wrapper probe: binary path cache empty",{framework:t,binary:e.binary,hint:"ensureAcpInstalled \u6CA1\u8DD1\u8FC7 / \u88C5\u5931\u8D25 / \u4E4B\u524D negative cache 5min \u5185"});return}let s;try{s=await ip(r)}catch(c){Fe.warn("acp wrapper probe: realpath failed (symlink target \u4E0D\u5B58\u5728?)",{framework:t,binaryPath:r,err:String(c)});return}let a=$o(s);for(let c=0;c<B0;c++){let f=op(a,"package.json");try{if(!(await sp(f)).isFile()){a=$o(a);continue}let h=await rp(f,"utf8"),m=JSON.parse(h);if(m.name===e.npmPackage){if(typeof m.version=="string"&&m.version.length>0)return m.version;Fe.warn("acp wrapper probe: package.json \u627E\u5230\u4F46 version \u5B57\u6BB5\u7F3A",{framework:t,packageJsonPath:f});return}}catch(x){let h=x;h.code!=="ENOENT"&&Fe.warn("acp wrapper probe: package.json \u8BFB\u53D6\u5F02\u5E38",{framework:t,candidate:f,errCode:h?.code,err:String(x)})}let l=$o(a);if(l===a)break;a=l}Fe.warn("acp wrapper probe: \u627E\u4E0D\u5230\u5339\u914D name \u7684 package.json (\u4E0A\u6EAF\u5230 max depth)",{framework:t,binaryPath:r,realBinary:s,expectedName:e.npmPackage,maxDepth:B0})}async function F0(t,e,r){let s=`${t}@${e}`;Fe.info("npm install -g start",{npmPackage:t,versionSpec:e});let a=Date.now(),c=process.platform==="win32";return new Promise((f,l)=>{let x=Vt("npm",["install","-g",s],{stdio:["ignore","pipe","pipe"],...c?{}:{detached:!0}});if(!x.pid){l(new Error(`failed to spawn npm: no pid (npmPackage=${t})`));return}let h=x.pid,m=10*1024*1024,E=[],C=[],_=0,y=0;x.stdout?.on("data",A=>{_+=A.length,_<m&&E.push(A)}),x.stderr?.on("data",A=>{y+=A.length,y<m&&C.push(A)});let v="running",I,R=A=>{try{return c?x.kill(A):process.kill(-h,A),!0}catch(k){return Fe.warn("npm install: kill failed (process already dead?)",{npmPackage:t,pid:h,sig:A,err:String(k)}),!1}},L=setTimeout(()=>{v="terminating",Fe.warn("npm install timeout, sending SIGTERM to process group",{npmPackage:t,versionSpec:e,pid:h,elapsedMs:Date.now()-a,timeoutMs:Mi,graceMs:Bi,stdoutBytes:_,stderrBytes:y}),R("SIGTERM"),I=setTimeout(()=>{v="killing",Fe.warn("npm install SIGTERM grace expired, escalating to SIGKILL",{npmPackage:t,versionSpec:e,pid:h,elapsedMs:Date.now()-a,stdoutBytes:_,stderrBytes:y}),R("SIGKILL")},Bi)},Mi),w=()=>{v="aborted",Fe.warn("npm install externally aborted, sending SIGKILL to process group",{npmPackage:t,versionSpec:e,pid:h,elapsedMs:Date.now()-a}),R("SIGKILL")};r&&(r.aborted?w():r.addEventListener("abort",w,{once:!0})),x.on("error",A=>{clearTimeout(L),I&&clearTimeout(I),r?.removeEventListener("abort",w),Fe.warn("npm install spawn error",{npmPackage:t,versionSpec:e,pid:h,err:String(A)}),l(new Error(`spawn npm failed: ${String(A)}`))}),x.on("close",(A,k)=>{clearTimeout(L),I&&clearTimeout(I),r?.removeEventListener("abort",w);let F=Buffer.concat(E).toString("utf8"),z=Buffer.concat(C).toString("utf8"),O=Date.now()-a;if(A===0&&v==="running"){Fe.info("npm install -g done",{npmPackage:t,versionSpec:e,elapsedMs:O}),f();return}Fe.warn("npm install -g exited non-success",{npmPackage:t,versionSpec:e,pid:h,phase:v,exitCode:A,signal:k,elapsedMs:O,stdoutBytes:_,stderrBytes:y});let N=Object.assign(new Error(`Command failed: npm install -g ${s}`+(k?` (killed by ${k})`:"")+(A!==null?` (exit ${A})`:"")+(v!=="running"?` (phase=${v})`:"")),{code:A,signal:k,stderr:z,stdout:F});l(N)})})}async function yn(t,e){let r=Vo[t];if(!r)return;let s=$n.get(t);if(s)return s;let a=Pr.get(t);if(a&&Date.now()-a<fp)return;let c=Vn.get(t);if(c)return c;let f=(async()=>{let l=await M0(r.binary);if(l)return $n.set(t,l),Fe.info("acp wrapper found on PATH",{binary:r.binary,path:l}),l;try{await F0(r.npmPackage,r.versionSpec,e)}catch(h){let m=hp(h);Fe.warn("acp wrapper install failed (will fallback to npx)",{framework:t,npmPackage:r.npmPackage,versionSpec:r.versionSpec,binary:r.binary,transient:m,err:z0(h)}),m||Pr.set(t,Date.now());return}let x=await M0(r.binary);if(!x){Fe.warn("acp wrapper installed but binary not found on PATH",{framework:t,npmPackage:r.npmPackage,versionSpec:r.versionSpec,binary:r.binary}),Pr.set(t,Date.now());return}return $n.set(t,x),Pr.delete(t),x})().finally(()=>{Vn.delete(t)});return Vn.set(t,f),f}function Jt(t){return $n.get(t)}function Jo(t){return Vn.get(t)}function gp(){$n.clear(),Pr.clear(),Vn.clear()}function mp(t,e){Vn.set(t,e)}function wp(t,e){$n.set(t,e)}var Fe,Vo,Mi,Bi,ap,fp,lp,up,xp,$n,Pr,Vn,B0,Zt=dt(()=>{"use strict";Wn();ee();Fe=H("agents.acp-installer"),Vo={"claude-code":{npmPackage:"@agentclientprotocol/claude-agent-acp",binary:"claude-agent-acp",versionSpec:"^0.37"},codex:{npmPackage:"@zed-industries/codex-acp",binary:"codex-acp",versionSpec:"^0.15"}};Mi=5e4,Bi=5e3,ap=5e3;fp=5*6e4,lp=new Set(["ETIMEDOUT","ECONNRESET","ECONNREFUSED","ENETUNREACH","EAI_AGAIN","ERR_SOCKET_TIMEOUT","ENOTFOUND"]),up=/\b(5\d\d|408|429)\b\s+(Bad Gateway|Service Unavailable|Gateway Timeout|Internal Server Error|Too Many Requests|Request Timeout)/i,xp=/fetch failed|request timed out|socket hang up|network timeout/i;$n=new Map,Pr=new Map,Vn=new Map;B0=6});import{chmod as yp,mkdir as Ep,readFile as bp,rename as j0,writeFile as G0}from"node:fs/promises";import{dirname as Sp}from"node:path";async function Jn(t){try{let e=await bp(t,"utf8");return JSON.parse(e)}catch(e){if(e.code==="ENOENT")return null;throw e}}async function Fi(t,e,r){await Ep(Sp(t),{recursive:!0});let s=`${JSON.stringify(e,null,2)}
|
|
12
|
+
`,a=`${t}.tmp-${process.pid}-${Math.random().toString(36).slice(2,10)}`;try{r?.mode!==void 0?await G0(a,s,{encoding:"utf8",mode:r.mode}):await G0(a,s,"utf8"),await j0(a,t),r?.mode!==void 0&&await yp(t,r.mode)}catch(c){await j0(a,a).catch(()=>{});let{rm:f}=await import("node:fs/promises");throw await f(a,{force:!0}).catch(()=>{}),c}}var Ui=dt(()=>{"use strict"});import{promises as K0}from"node:fs";import{homedir as vp}from"node:os";import{sep as Ip,join as Ne,resolve as W0}from"node:path";function te(t){let e=t??vp(),r=Ne(e,".coze"),s=Ne(r,"bridge"),a=Ne(s,"lib");return{cozeRoot:r,bridgeRoot:s,libDir:a,libEntry:Ne(a,"index.js"),binDir:Ne(s,"bin"),pidFile:Ne(s,"bridge.pid"),portFile:Ne(s,"bridge.port"),tokenFile:Ne(s,"bridge.token"),patTokenFile:Ne(s,"pat-token"),logFile:Ne(s,"bridge.log"),installLock:Ne(s,"install.lock"),configFile:Ne(s,"config.json"),agentsRoot:Ne(r,"agents")}}function kt(t,e=te()){let r=Ne(e.agentsRoot,t);return{root:r,config:Ne(r,"config.json"),workspace:Ne(r,"workspace"),logs:Ne(r,"logs")}}async function Nr(t,e){let r=await K0.realpath(W0(t)).catch(()=>null);if(!r)return!1;let s=await K0.realpath(W0(e)).catch(()=>null);if(!s)return!1;let a=process.platform==="win32"?r.toLowerCase():r,c=process.platform==="win32"?s.toLowerCase():s;return a===c||a.startsWith(c+Ip)}var Me=dt(()=>{"use strict"});var ji={};Ko(ji,{AGENT_CONFIG_FILE_MODE:()=>qi,enforceAgentConfigMode:()=>Tp,loadAgentConfig:()=>Ue,persistAgentSessions:()=>Zo,persistAgentSkills:()=>Hi,saveAgentConfig:()=>Ve});import{chmod as Ap,stat as Cp}from"node:fs/promises";function Ue(t,e){return Jn(kt(t,e).config)}function Ve(t,e){return Fi(kt(t.agentId,e).config,t,{mode:qi})}async function Tp(t,e){if(process.platform==="win32")return;let r=kt(t,e).config;try{let s=await Cp(r);if(!s.isFile())return;let a=s.mode&511;a!==qi&&(await Ap(r,qi),$0.warn("agent config mode auto-corrected to 0600",{path:r,from:a.toString(8)}))}catch(s){if(s.code==="ENOENT")return;$0.warn("enforceAgentConfigMode: chmod failed (ignored)",{path:r,err:String(s)})}}async function Zo(t,e,r){let s=await Ue(t,r);s&&(s.sessions=Object.fromEntries(e),await Ve(s,r))}async function Hi(t,e,r){let s=await Ue(t,r);s&&(s.skills=e,await Ve(s,r))}var $0,qi,Yt=dt(()=>{"use strict";Ui();ee();Me();$0=H("agent-config"),qi=384});var Xo=ne((K2,Y0)=>{Y0.exports={LOCHDR:30,LOCSIG:67324752,LOCVER:4,LOCFLG:6,LOCHOW:8,LOCTIM:10,LOCCRC:14,LOCSIZ:18,LOCLEN:22,LOCNAM:26,LOCEXT:28,EXTSIG:134695760,EXTHDR:16,EXTCRC:4,EXTSIZ:8,EXTLEN:12,CENHDR:46,CENSIG:33639248,CENVEM:4,CENVER:6,CENFLG:8,CENHOW:10,CENTIM:12,CENCRC:16,CENSIZ:20,CENLEN:24,CENNAM:28,CENEXT:30,CENCOM:32,CENDSK:34,CENATT:36,CENATX:38,CENOFF:42,ENDHDR:22,ENDSIG:101010256,ENDSUB:8,ENDTOT:10,ENDSIZ:12,ENDOFF:16,ENDCOM:20,END64HDR:20,END64SIG:117853008,END64START:4,END64OFF:8,END64NUMDISKS:16,ZIP64SIG:101075792,ZIP64HDR:56,ZIP64LEAD:12,ZIP64SIZE:4,ZIP64VEM:12,ZIP64VER:14,ZIP64DSK:16,ZIP64DSKDIR:20,ZIP64SUB:24,ZIP64TOT:32,ZIP64SIZB:40,ZIP64OFF:48,ZIP64EXTRA:56,STORED:0,SHRUNK:1,REDUCED1:2,REDUCED2:3,REDUCED3:4,REDUCED4:5,IMPLODED:6,DEFLATED:8,ENHANCED_DEFLATED:9,PKWARE:10,BZIP2:12,LZMA:14,IBM_TERSE:18,IBM_LZ77:19,AES_ENCRYPT:99,FLG_ENC:1,FLG_COMP1:2,FLG_COMP2:4,FLG_DESC:8,FLG_ENH:16,FLG_PATCH:32,FLG_STR:64,FLG_EFS:2048,FLG_MSK:4096,FILE:2,BUFFER:1,NONE:0,EF_ID:0,EF_SIZE:2,ID_ZIP64:1,ID_AVINFO:7,ID_PFS:8,ID_OS2:9,ID_NTFS:10,ID_OPENVMS:12,ID_UNIX:13,ID_FORK:14,ID_PATCH:15,ID_X509_PKCS7:20,ID_X509_CERTID_F:21,ID_X509_CERTID_C:22,ID_STRONGENC:23,ID_RECORD_MGT:24,ID_X509_PKCS7_RL:25,ID_IBM1:101,ID_IBM2:102,ID_POSZIP:18064,EF_ZIP64_OR_32:4294967295,EF_ZIP64_OR_16:65535,EF_ZIP64_SUNCOMP:0,EF_ZIP64_SCOMP:8,EF_ZIP64_RHO:16,EF_ZIP64_DSN:24}});var Ki=ne(Q0=>{var X0={INVALID_LOC:"Invalid LOC header (bad signature)",INVALID_CEN:"Invalid CEN header (bad signature)",INVALID_END:"Invalid END header (bad signature)",DESCRIPTOR_NOT_EXIST:"No descriptor present",DESCRIPTOR_UNKNOWN:"Unknown descriptor format",DESCRIPTOR_FAULTY:"Descriptor data is malformed",NO_DATA:"Nothing to decompress",BAD_CRC:"CRC32 checksum failed {0}",FILE_IN_THE_WAY:"There is a file in the way: {0}",UNKNOWN_METHOD:"Invalid/unsupported compression method",AVAIL_DATA:"inflate::Available inflate data did not terminate",INVALID_DISTANCE:"inflate::Invalid literal/length or distance code in fixed or dynamic block",TO_MANY_CODES:"inflate::Dynamic block code description: too many length or distance codes",INVALID_REPEAT_LEN:"inflate::Dynamic block code description: repeat more than specified lengths",INVALID_REPEAT_FIRST:"inflate::Dynamic block code description: repeat lengths with no first length",INCOMPLETE_CODES:"inflate::Dynamic block code description: code lengths codes incomplete",INVALID_DYN_DISTANCE:"inflate::Dynamic block code description: invalid distance code lengths",INVALID_CODES_LEN:"inflate::Dynamic block code description: invalid literal/length code lengths",INVALID_STORE_BLOCK:"inflate::Stored block length did not match one's complement",INVALID_BLOCK_TYPE:"inflate::Invalid block type (type == 3)",CANT_EXTRACT_FILE:"Could not extract the file",CANT_OVERRIDE:"Target file already exists",DISK_ENTRY_TOO_LARGE:"Number of disk entries is too large",NO_ZIP:"No zip file was loaded",NO_ENTRY:"Entry doesn't exist",DIRECTORY_CONTENT_ERROR:"A directory cannot have content",FILE_NOT_FOUND:'File not found: "{0}"',NOT_IMPLEMENTED:"Not implemented",INVALID_FILENAME:"Invalid filename",INVALID_FORMAT:"Invalid or unsupported zip format. No END header found",INVALID_PASS_PARAM:"Incompatible password parameter",WRONG_PASSWORD:"Wrong Password",COMMENT_TOO_LONG:"Comment is too long",EXTRA_FIELD_PARSE_ERROR:"Extra field parsing error"};function Pp(t){return function(...e){return e.length&&(t=t.replace(/\{(\d)\}/g,(r,s)=>e[s]||"")),new Error("ADM-ZIP: "+t)}}for(let t of Object.keys(X0))Q0[t]=Pp(X0[t])});var id=ne(($2,rd)=>{var Lp=ae("fs"),be=ae("path"),ed=Xo(),Np=Ki(),Mp=typeof process=="object"&&process.platform==="win32",td=t=>typeof t=="object"&&t!==null,nd=new Uint32Array(256).map((t,e)=>{for(let r=0;r<8;r++)(e&1)!==0?e=3988292384^e>>>1:e>>>=1;return e>>>0});function he(t){this.sep=be.sep,this.fs=Lp,td(t)&&td(t.fs)&&typeof t.fs.statSync=="function"&&(this.fs=t.fs)}rd.exports=he;he.prototype.makeDir=function(t){let e=this;function r(s){let a=s.split(e.sep)[0];s.split(e.sep).forEach(function(c){if(!(!c||c.substr(-1,1)===":")){a+=e.sep+c;var f;try{f=e.fs.statSync(a)}catch(l){if(l.message&&l.message.startsWith("ENOENT"))e.fs.mkdirSync(a);else throw l}if(f&&f.isFile())throw Np.FILE_IN_THE_WAY(`"${a}"`)}})}r(t)};he.prototype.writeFileTo=function(t,e,r,s){let a=this;if(a.fs.existsSync(t)){if(!r)return!1;var c=a.fs.statSync(t);if(c.isDirectory())return!1}var f=be.dirname(t);a.fs.existsSync(f)||a.makeDir(f);var l;try{l=a.fs.openSync(t,"w",438)}catch{a.fs.chmodSync(t,438),l=a.fs.openSync(t,"w",438)}if(l)try{a.fs.writeSync(l,e,0,e.length,0)}finally{a.fs.closeSync(l)}return a.fs.chmodSync(t,s||438),!0};he.prototype.writeFileToAsync=function(t,e,r,s,a){typeof s=="function"&&(a=s,s=void 0);let c=this;c.fs.exists(t,function(f){if(f&&!r)return a(!1);c.fs.stat(t,function(l,x){if(f&&x.isDirectory())return a(!1);var h=be.dirname(t);c.fs.exists(h,function(m){m||c.makeDir(h),c.fs.open(t,"w",438,function(E,C){E?c.fs.chmod(t,438,function(){c.fs.open(t,"w",438,function(_,y){c.fs.write(y,e,0,e.length,0,function(){c.fs.close(y,function(){c.fs.chmod(t,s||438,function(){a(!0)})})})})}):C?c.fs.write(C,e,0,e.length,0,function(){c.fs.close(C,function(){c.fs.chmod(t,s||438,function(){a(!0)})})}):c.fs.chmod(t,s||438,function(){a(!0)})})})})})};he.prototype.findFiles=function(t){let e=this;function r(s,a,c){typeof a=="boolean"&&(c=a,a=void 0);let f=[];return e.fs.readdirSync(s).forEach(function(l){let x=be.join(s,l),h=e.fs.statSync(x);(!a||a.test(x))&&f.push(be.normalize(x)+(h.isDirectory()?e.sep:"")),h.isDirectory()&&c&&(f=f.concat(r(x,a,c)))}),f}return r(t,void 0,!0)};he.prototype.findFilesAsync=function(t,e){let r=this,s=[];r.fs.readdir(t,function(a,c){if(a)return e(a);let f=c.length;if(!f)return e(null,s);c.forEach(function(l){l=be.join(t,l),r.fs.stat(l,function(x,h){if(x)return e(x);h&&(s.push(be.normalize(l)+(h.isDirectory()?r.sep:"")),h.isDirectory()?r.findFilesAsync(l,function(m,E){if(m)return e(m);s=s.concat(E),--f||e(null,s)}):--f||e(null,s))})})})};he.prototype.getAttributes=function(){};he.prototype.setAttributes=function(){};he.crc32update=function(t,e){return nd[(t^e)&255]^t>>>8};he.crc32=function(t){typeof t=="string"&&(t=Buffer.from(t,"utf8"));let e=t.length,r=-1;for(let s=0;s<e;)r=he.crc32update(r,t[s++]);return~r>>>0};he.methodToString=function(t){switch(t){case ed.STORED:return"STORED ("+t+")";case ed.DEFLATED:return"DEFLATED ("+t+")";default:return"UNSUPPORTED ("+t+")"}};he.canonical=function(t){if(!t)return"";let e=be.posix.normalize("/"+t.split("\\").join("/"));return be.join(".",e)};he.zipnamefix=function(t){if(!t)return"";let e=be.posix.normalize("/"+t.split("\\").join("/"));return be.posix.join(".",e)};he.findLast=function(t,e){if(!Array.isArray(t))throw new TypeError("arr is not array");let r=t.length>>>0;for(let s=r-1;s>=0;s--)if(e(t[s],s,t))return t[s]};he.sanitize=function(t,e){t=be.resolve(be.normalize(t));for(var r=e.split("/"),s=0,a=r.length;s<a;s++){var c=be.normalize(be.join(t,r.slice(s,a).join(be.sep)));if(c.indexOf(t)===0)return c}return be.normalize(be.join(t,be.basename(e)))};he.toBuffer=function(e,r){return Buffer.isBuffer(e)?e:e instanceof Uint8Array?Buffer.from(e):typeof e=="string"?r(e):Buffer.alloc(0)};he.readBigUInt64LE=function(t,e){let r=t.readUInt32LE(e);return t.readUInt32LE(e+4)*4294967296+r};he.fromDOS2Date=function(t){return new Date((t>>25&127)+1980,Math.max((t>>21&15)-1,0),Math.max(t>>16&31,1),t>>11&31,t>>5&63,(t&31)<<1)};he.fromDate2DOS=function(t){let e=0,r=0;return t.getFullYear()>1979&&(e=(t.getFullYear()-1980&127)<<9|t.getMonth()+1<<5|t.getDate(),r=t.getHours()<<11|t.getMinutes()<<5|t.getSeconds()>>1),e<<16|r};he.isWin=Mp;he.crcTable=nd});var od=ne((V2,sd)=>{var Bp=ae("path");sd.exports=function(t,{fs:e}){var r=t||"",s=c(),a=null;function c(){return{directory:!1,readonly:!1,hidden:!1,executable:!1,mtime:0,atime:0}}return r&&e.existsSync(r)?(a=e.statSync(r),s.directory=a.isDirectory(),s.mtime=a.mtime,s.atime=a.atime,s.executable=(73&a.mode)!==0,s.readonly=(128&a.mode)===0,s.hidden=Bp.basename(r)[0]==="."):console.warn("Invalid path: "+r),{get directory(){return s.directory},get readOnly(){return s.readonly},get hidden(){return s.hidden},get mtime(){return s.mtime},get atime(){return s.atime},get executable(){return s.executable},decodeAttributes:function(){},encodeAttributes:function(){},toJSON:function(){return{path:r,isDirectory:s.directory,isReadOnly:s.readonly,isHidden:s.hidden,isExecutable:s.executable,mTime:s.mtime,aTime:s.atime}},toString:function(){return JSON.stringify(this.toJSON(),null," ")}}}});var cd=ne((J2,ad)=>{ad.exports={efs:!0,encode:t=>Buffer.from(t,"utf8"),decode:t=>t.toString("utf8")}});var Xn=ne((Z2,Yn)=>{Yn.exports=id();Yn.exports.Constants=Xo();Yn.exports.Errors=Ki();Yn.exports.FileAttr=od();Yn.exports.decoder=cd()});var fd=ne((Y2,dd)=>{var Xt=Xn(),q=Xt.Constants;dd.exports=function(){var t=20,e=10,r=0,s=0,a=0,c=0,f=0,l=0,x=0,h=0,m=0,E=0,C=0,_=0,y=0;t|=Xt.isWin?2560:768,r|=q.FLG_EFS;let v={extraLen:0},I=w=>Math.max(0,w)>>>0,R=w=>Math.max(0,w)&65535,L=w=>Math.max(0,w)&255;return a=Xt.fromDate2DOS(new Date),{get made(){return t},set made(w){t=w},get version(){return e},set version(w){e=w},get flags(){return r},set flags(w){r=w},get flags_efs(){return(r&q.FLG_EFS)>0},set flags_efs(w){w?r|=q.FLG_EFS:r&=~q.FLG_EFS},get flags_desc(){return(r&q.FLG_DESC)>0},set flags_desc(w){w?r|=q.FLG_DESC:r&=~q.FLG_DESC},get method(){return s},set method(w){switch(w){case q.STORED:this.version=10;case q.DEFLATED:default:this.version=20}s=w},get time(){return Xt.fromDOS2Date(this.timeval)},set time(w){w=new Date(w),this.timeval=Xt.fromDate2DOS(w)},get timeval(){return a},set timeval(w){a=I(w)},get timeHighByte(){return L(a>>>8)},get crc(){return c},set crc(w){c=I(w)},get compressedSize(){return f},set compressedSize(w){f=I(w)},get size(){return l},set size(w){l=I(w)},get fileNameLength(){return x},set fileNameLength(w){x=w},get extraLength(){return h},set extraLength(w){h=w},get extraLocalLength(){return v.extraLen},set extraLocalLength(w){v.extraLen=w},get commentLength(){return m},set commentLength(w){m=w},get diskNumStart(){return E},set diskNumStart(w){E=I(w)},get inAttr(){return C},set inAttr(w){C=I(w)},get attr(){return _},set attr(w){_=I(w)},get fileAttr(){return(_||0)>>16&4095},get offset(){return y},set offset(w){y=I(w)},get encrypted(){return(r&q.FLG_ENC)===q.FLG_ENC},get centralHeaderSize(){return q.CENHDR+x+h+m},get realDataOffset(){return y+q.LOCHDR+v.fnameLen+v.extraLen},get localHeader(){return v},loadLocalHeaderFromBinary:function(w){var A=w.slice(y,y+q.LOCHDR);if(A.readUInt32LE(0)!==q.LOCSIG)throw Xt.Errors.INVALID_LOC();v.version=A.readUInt16LE(q.LOCVER),v.flags=A.readUInt16LE(q.LOCFLG),v.flags_desc=(v.flags&q.FLG_DESC)>0,v.method=A.readUInt16LE(q.LOCHOW),v.time=A.readUInt32LE(q.LOCTIM),v.crc=A.readUInt32LE(q.LOCCRC),v.compressedSize=A.readUInt32LE(q.LOCSIZ),v.size=A.readUInt32LE(q.LOCLEN),v.fnameLen=A.readUInt16LE(q.LOCNAM),v.extraLen=A.readUInt16LE(q.LOCEXT);let k=y+q.LOCHDR+v.fnameLen,F=k+v.extraLen;return w.slice(k,F)},loadFromBinary:function(w){if(w.length!==q.CENHDR||w.readUInt32LE(0)!==q.CENSIG)throw Xt.Errors.INVALID_CEN();t=w.readUInt16LE(q.CENVEM),e=w.readUInt16LE(q.CENVER),r=w.readUInt16LE(q.CENFLG),s=w.readUInt16LE(q.CENHOW),a=w.readUInt32LE(q.CENTIM),c=w.readUInt32LE(q.CENCRC),f=w.readUInt32LE(q.CENSIZ),l=w.readUInt32LE(q.CENLEN),x=w.readUInt16LE(q.CENNAM),h=w.readUInt16LE(q.CENEXT),m=w.readUInt16LE(q.CENCOM),E=w.readUInt16LE(q.CENDSK),C=w.readUInt16LE(q.CENATT),_=w.readUInt32LE(q.CENATX),y=w.readUInt32LE(q.CENOFF)},localHeaderToBinary:function(){var w=Buffer.alloc(q.LOCHDR);return w.writeUInt32LE(q.LOCSIG,0),w.writeUInt16LE(e,q.LOCVER),w.writeUInt16LE(r,q.LOCFLG),w.writeUInt16LE(s,q.LOCHOW),w.writeUInt32LE(a,q.LOCTIM),w.writeUInt32LE(c,q.LOCCRC),w.writeUInt32LE(f,q.LOCSIZ),w.writeUInt32LE(l,q.LOCLEN),w.writeUInt16LE(x,q.LOCNAM),w.writeUInt16LE(v.extraLen,q.LOCEXT),w},centralHeaderToBinary:function(){var w=Buffer.alloc(q.CENHDR+x+h+m);return w.writeUInt32LE(q.CENSIG,0),w.writeUInt16LE(t,q.CENVEM),w.writeUInt16LE(e,q.CENVER),w.writeUInt16LE(r,q.CENFLG),w.writeUInt16LE(s,q.CENHOW),w.writeUInt32LE(a,q.CENTIM),w.writeUInt32LE(c,q.CENCRC),w.writeUInt32LE(f,q.CENSIZ),w.writeUInt32LE(l,q.CENLEN),w.writeUInt16LE(x,q.CENNAM),w.writeUInt16LE(h,q.CENEXT),w.writeUInt16LE(m,q.CENCOM),w.writeUInt16LE(E,q.CENDSK),w.writeUInt16LE(C,q.CENATT),w.writeUInt32LE(_,q.CENATX),w.writeUInt32LE(y,q.CENOFF),w},toJSON:function(){let w=function(A){return A+" bytes"};return{made:t,version:e,flags:r,method:Xt.methodToString(s),time:this.time,crc:"0x"+c.toString(16).toUpperCase(),compressedSize:w(f),size:w(l),fileNameLength:w(x),extraLength:w(h),commentLength:w(m),diskNumStart:E,inAttr:C,attr:_,offset:y,centralHeaderSize:w(q.CENHDR+x+h+m)}},toString:function(){return JSON.stringify(this.toJSON(),null," ")}}}});var ud=ne((X2,ld)=>{var Qn=Xn(),le=Qn.Constants;ld.exports=function(){var t=0,e=0,r=0,s=0,a=0;return{get diskEntries(){return t},set diskEntries(c){t=e=c},get totalEntries(){return e},set totalEntries(c){e=t=c},get size(){return r},set size(c){r=c},get offset(){return s},set offset(c){s=c},get commentLength(){return a},set commentLength(c){a=c},get mainHeaderSize(){return le.ENDHDR+a},loadFromBinary:function(c){if((c.length!==le.ENDHDR||c.readUInt32LE(0)!==le.ENDSIG)&&(c.length<le.ZIP64HDR||c.readUInt32LE(0)!==le.ZIP64SIG))throw Qn.Errors.INVALID_END();c.readUInt32LE(0)===le.ENDSIG?(t=c.readUInt16LE(le.ENDSUB),e=c.readUInt16LE(le.ENDTOT),r=c.readUInt32LE(le.ENDSIZ),s=c.readUInt32LE(le.ENDOFF),a=c.readUInt16LE(le.ENDCOM)):(t=Qn.readBigUInt64LE(c,le.ZIP64SUB),e=Qn.readBigUInt64LE(c,le.ZIP64TOT),r=Qn.readBigUInt64LE(c,le.ZIP64SIZE),s=Qn.readBigUInt64LE(c,le.ZIP64OFF),a=0)},toBinary:function(){var c=Buffer.alloc(le.ENDHDR+a);return c.writeUInt32LE(le.ENDSIG,0),c.writeUInt32LE(0,4),c.writeUInt16LE(t,le.ENDSUB),c.writeUInt16LE(e,le.ENDTOT),c.writeUInt32LE(r,le.ENDSIZ),c.writeUInt32LE(s,le.ENDOFF),c.writeUInt16LE(a,le.ENDCOM),c.fill(" ",le.ENDHDR),c},toJSON:function(){let c=function(f,l){let x=f.toString(16).toUpperCase();for(;x.length<l;)x="0"+x;return"0x"+x};return{diskEntries:t,totalEntries:e,size:r+" bytes",offset:c(s,4),commentLength:a}},toString:function(){return JSON.stringify(this.toJSON(),null," ")}}}});var ea=ne(Qo=>{Qo.EntryHeader=fd();Qo.MainHeader=ud()});var hd=ne((eS,xd)=>{xd.exports=function(t){var e=ae("zlib"),r={chunkSize:(parseInt(t.length/1024)+1)*1024};return{deflate:function(){return e.deflateRawSync(t,r)},deflateAsync:function(s){var a=e.createDeflateRaw(r),c=[],f=0;a.on("data",function(l){c.push(l),f+=l.length}),a.on("end",function(){var l=Buffer.alloc(f),x=0;l.fill(0);for(var h=0;h<c.length;h++){var m=c[h];m.copy(l,x),x+=m.length}s&&s(l)}),a.end(t)}}}});var gd=ne((tS,pd)=>{var zp=+(process.versions?process.versions.node:"").split(".")[0]||0;pd.exports=function(t,e){var r=ae("zlib");let s=zp>=15&&e>0?{maxOutputLength:e}:{};return{inflate:function(){return r.inflateRawSync(t,s)},inflateAsync:function(a){var c=r.createInflateRaw(s),f=[],l=0;c.on("data",function(x){f.push(x),l+=x.length}),c.on("end",function(){var x=Buffer.alloc(l),h=0;x.fill(0);for(var m=0;m<f.length;m++){var E=f[m];E.copy(x,h),h+=E.length}a&&a(x)}),c.end(t)}}}});var Ed=ne((nS,yd)=>{"use strict";var{randomFillSync:md}=ae("crypto"),Fp=Ki(),Up=new Uint32Array(256).map((t,e)=>{for(let r=0;r<8;r++)(e&1)!==0?e=e>>>1^3988292384:e>>>=1;return e>>>0}),_d=(t,e)=>Math.imul(t,e)>>>0,wd=(t,e)=>Up[(t^e)&255]^t>>>8,Mr=()=>typeof md=="function"?md(Buffer.alloc(12)):Mr.node();Mr.node=()=>{let t=Buffer.alloc(12),e=t.length;for(let r=0;r<e;r++)t[r]=Math.random()*256&255;return t};var Wi={genSalt:Mr};function $i(t){let e=Buffer.isBuffer(t)?t:Buffer.from(t);this.keys=new Uint32Array([305419896,591751049,878082192]);for(let r=0;r<e.length;r++)this.updateKeys(e[r])}$i.prototype.updateKeys=function(t){let e=this.keys;return e[0]=wd(e[0],t),e[1]+=e[0]&255,e[1]=_d(e[1],134775813)+1,e[2]=wd(e[2],e[1]>>>24),t};$i.prototype.next=function(){let t=(this.keys[2]|2)>>>0;return _d(t,t^1)>>8&255};function qp(t){let e=new $i(t);return function(r){let s=Buffer.alloc(r.length),a=0;for(let c of r)s[a++]=e.updateKeys(c^e.next());return s}}function Hp(t){let e=new $i(t);return function(r,s,a=0){s||(s=Buffer.alloc(r.length));for(let c of r){let f=e.next();s[a++]=c^f,e.updateKeys(c)}return s}}function jp(t,e,r){if(!t||!Buffer.isBuffer(t)||t.length<12)return Buffer.alloc(0);let s=qp(r),a=s(t.slice(0,12)),c=(e.flags&8)===8?e.timeHighByte:e.crc>>>24;if(a[11]!==c)throw Fp.WRONG_PASSWORD();return s(t.slice(12))}function Gp(t){Buffer.isBuffer(t)&&t.length>=12?Wi.genSalt=function(){return t.slice(0,12)}:t==="node"?Wi.genSalt=Mr.node:Wi.genSalt=Mr}function Kp(t,e,r,s=!1){t==null&&(t=Buffer.alloc(0)),Buffer.isBuffer(t)||(t=Buffer.from(t.toString()));let a=Hp(r),c=Wi.genSalt();c[11]=e.crc>>>24&255,s&&(c[10]=e.crc>>>16&255);let f=Buffer.alloc(t.length+12);return a(c,f),a(t,f,12)}yd.exports={decrypt:jp,encrypt:Kp,_salter:Gp}});var bd=ne(Vi=>{Vi.Deflater=hd();Vi.Inflater=gd();Vi.ZipCrypto=Ed()});var na=ne((iS,Sd)=>{var re=Xn(),Wp=ea(),pe=re.Constants,ta=bd();Sd.exports=function(t,e){var r=new Wp.EntryHeader,s=Buffer.alloc(0),a=Buffer.alloc(0),c=!1,f=null,l=Buffer.alloc(0),x=Buffer.alloc(0),h=!0;let m=t,E=typeof m.decoder=="object"?m.decoder:re.decoder;h=E.hasOwnProperty("efs")?E.efs:!1;function C(){return!e||!(e instanceof Uint8Array)?Buffer.alloc(0):(x=r.loadLocalHeaderFromBinary(e),e.slice(r.realDataOffset,r.realDataOffset+r.compressedSize))}function _(w){if(!r.flags_desc&&!r.localHeader.flags_desc){if(re.crc32(w)!==r.localHeader.crc)return!1}else{let A={},k=r.realDataOffset+r.compressedSize;if(e.readUInt32LE(k)==pe.LOCSIG||e.readUInt32LE(k)==pe.CENSIG)throw re.Errors.DESCRIPTOR_NOT_EXIST();if(e.readUInt32LE(k)==pe.EXTSIG)A.crc=e.readUInt32LE(k+pe.EXTCRC),A.compressedSize=e.readUInt32LE(k+pe.EXTSIZ),A.size=e.readUInt32LE(k+pe.EXTLEN);else if(e.readUInt16LE(k+12)===19280)A.crc=e.readUInt32LE(k+pe.EXTCRC-4),A.compressedSize=e.readUInt32LE(k+pe.EXTSIZ-4),A.size=e.readUInt32LE(k+pe.EXTLEN-4);else throw re.Errors.DESCRIPTOR_UNKNOWN();if(A.compressedSize!==r.compressedSize||A.size!==r.size||A.crc!==r.crc)throw re.Errors.DESCRIPTOR_FAULTY();if(re.crc32(w)!==A.crc)return!1}return!0}function y(w,A,k){if(typeof A>"u"&&typeof w=="string"&&(k=w,w=void 0),c)return w&&A&&A(Buffer.alloc(0),re.Errors.DIRECTORY_CONTENT_ERROR()),Buffer.alloc(0);var F=C();if(F.length===0)return w&&A&&A(F),F;if(r.encrypted){if(typeof k!="string"&&!Buffer.isBuffer(k))throw re.Errors.INVALID_PASS_PARAM();F=ta.ZipCrypto.decrypt(F,r,k)}var z=Buffer.alloc(r.size);switch(r.method){case re.Constants.STORED:if(F.copy(z),_(z))return w&&A&&A(z),z;throw w&&A&&A(z,re.Errors.BAD_CRC()),re.Errors.BAD_CRC();case re.Constants.DEFLATED:var O=new ta.Inflater(F,r.size);if(w)O.inflateAsync(function(N){N.copy(N,0),A&&(_(N)?A(N):A(N,re.Errors.BAD_CRC()))});else{if(O.inflate(z).copy(z,0),!_(z))throw re.Errors.BAD_CRC(`"${E.decode(s)}"`);return z}break;default:throw w&&A&&A(Buffer.alloc(0),re.Errors.UNKNOWN_METHOD()),re.Errors.UNKNOWN_METHOD()}}function v(w,A){if((!f||!f.length)&&Buffer.isBuffer(e))return w&&A&&A(C()),C();if(f.length&&!c){var k;switch(r.method){case re.Constants.STORED:return r.compressedSize=r.size,k=Buffer.alloc(f.length),f.copy(k),w&&A&&A(k),k;default:case re.Constants.DEFLATED:var F=new ta.Deflater(f);if(w)F.deflateAsync(function(O){k=Buffer.alloc(O.length),r.compressedSize=O.length,O.copy(k),A&&A(k)});else{var z=F.deflate();return r.compressedSize=z.length,z}F=null;break}}else if(w&&A)A(Buffer.alloc(0));else return Buffer.alloc(0)}function I(w,A){return re.readBigUInt64LE(w,A)}function R(w){try{for(var A=0,k,F,z;A+4<w.length;)k=w.readUInt16LE(A),A+=2,F=w.readUInt16LE(A),A+=2,z=w.slice(A,A+F),A+=F,pe.ID_ZIP64===k&&L(z)}catch{throw re.Errors.EXTRA_FIELD_PARSE_ERROR()}}function L(w){var A,k,F,z;w.length>=pe.EF_ZIP64_SCOMP&&(A=I(w,pe.EF_ZIP64_SUNCOMP),r.size===pe.EF_ZIP64_OR_32&&(r.size=A)),w.length>=pe.EF_ZIP64_RHO&&(k=I(w,pe.EF_ZIP64_SCOMP),r.compressedSize===pe.EF_ZIP64_OR_32&&(r.compressedSize=k)),w.length>=pe.EF_ZIP64_DSN&&(F=I(w,pe.EF_ZIP64_RHO),r.offset===pe.EF_ZIP64_OR_32&&(r.offset=F)),w.length>=pe.EF_ZIP64_DSN+4&&(z=w.readUInt32LE(pe.EF_ZIP64_DSN),r.diskNumStart===pe.EF_ZIP64_OR_16&&(r.diskNumStart=z))}return{get entryName(){return E.decode(s)},get rawEntryName(){return s},set entryName(w){s=re.toBuffer(w,E.encode);var A=s[s.length-1];c=A===47||A===92,r.fileNameLength=s.length},get efs(){return typeof h=="function"?h(this.entryName):h},get extra(){return l},set extra(w){l=w,r.extraLength=w.length,R(w)},get comment(){return E.decode(a)},set comment(w){if(a=re.toBuffer(w,E.encode),r.commentLength=a.length,a.length>65535)throw re.Errors.COMMENT_TOO_LONG()},get name(){var w=E.decode(s);return c?w.substr(w.length-1).split("/").pop():w.split("/").pop()},get isDirectory(){return c},getCompressedData:function(){return v(!1,null)},getCompressedDataAsync:function(w){v(!0,w)},setData:function(w){f=re.toBuffer(w,re.decoder.encode),!c&&f.length?(r.size=f.length,r.method=re.Constants.DEFLATED,r.crc=re.crc32(w),r.changed=!0):r.method=re.Constants.STORED},getData:function(w){return r.changed?f:y(!1,null,w)},getDataAsync:function(w,A){r.changed?w(f):y(!0,w,A)},set attr(w){r.attr=w},get attr(){return r.attr},set header(w){r.loadFromBinary(w)},get header(){return r},packCentralHeader:function(){r.flags_efs=this.efs,r.extraLength=l.length;var w=r.centralHeaderToBinary(),A=re.Constants.CENHDR;return s.copy(w,A),A+=s.length,l.copy(w,A),A+=r.extraLength,a.copy(w,A),w},packLocalHeader:function(){let w=0;r.flags_efs=this.efs,r.extraLocalLength=x.length;let A=r.localHeaderToBinary(),k=Buffer.alloc(A.length+s.length+r.extraLocalLength);return A.copy(k,w),w+=A.length,s.copy(k,w),w+=s.length,x.copy(k,w),w+=x.length,k},toJSON:function(){let w=function(A){return"<"+(A&&A.length+" bytes buffer"||"null")+">"};return{entryName:this.entryName,name:this.name,comment:this.comment,isDirectory:this.isDirectory,header:r.toJSON(),compressedData:w(e),data:w(f)}},toString:function(){return JSON.stringify(this.toJSON(),null," ")}}}});var Ad=ne((sS,Id)=>{var vd=na(),$p=ea(),Be=Xn();Id.exports=function(t,e){var r=[],s={},a=Buffer.alloc(0),c=new $p.MainHeader,f=!1,l=null;let x=new Set,h=e,{noSort:m,decoder:E}=h;t?y(h.readEntries):f=!0;function C(){let I=new Set;for(let R of Object.keys(s)){let L=R.split("/");if(L.pop(),!!L.length)for(let w=0;w<L.length;w++){let A=L.slice(0,w+1).join("/")+"/";I.add(A)}}for(let R of I)if(!(R in s)){let L=new vd(h);L.entryName=R,L.attr=16,L.temporary=!0,r.push(L),s[L.entryName]=L,x.add(L)}}function _(){if(f=!0,s={},c.diskEntries>(t.length-c.offset)/Be.Constants.CENHDR)throw Be.Errors.DISK_ENTRY_TOO_LARGE();r=new Array(c.diskEntries);for(var I=c.offset,R=0;R<r.length;R++){var L=I,w=new vd(h,t);w.header=t.slice(L,L+=Be.Constants.CENHDR),w.entryName=t.slice(L,L+=w.header.fileNameLength),w.header.extraLength&&(w.extra=t.slice(L,L+=w.header.extraLength)),w.header.commentLength&&(w.comment=t.slice(L,L+w.header.commentLength)),I+=w.header.centralHeaderSize,r[R]=w,s[w.entryName]=w}x.clear(),C()}function y(I){var R=t.length-Be.Constants.ENDHDR,L=Math.max(0,R-65535),w=L,A=t.length,k=-1,F=0;for(typeof h.trailingSpace=="boolean"&&h.trailingSpace&&(L=0),R;R>=w;R--)if(t[R]===80){if(t.readUInt32LE(R)===Be.Constants.ENDSIG){k=R,F=R,A=R+Be.Constants.ENDHDR,w=R-Be.Constants.END64HDR;continue}if(t.readUInt32LE(R)===Be.Constants.END64SIG){w=L;continue}if(t.readUInt32LE(R)===Be.Constants.ZIP64SIG){k=R,A=R+Be.readBigUInt64LE(t,R+Be.Constants.ZIP64SIZE)+Be.Constants.ZIP64LEAD;break}}if(k==-1)throw Be.Errors.INVALID_FORMAT();c.loadFromBinary(t.slice(k,A)),c.commentLength&&(a=t.slice(F+Be.Constants.ENDHDR)),I&&_()}function v(){r.length>1&&!m&&r.sort((I,R)=>I.entryName.toLowerCase().localeCompare(R.entryName.toLowerCase()))}return{get entries(){return f||_(),r.filter(I=>!x.has(I))},get comment(){return E.decode(a)},set comment(I){a=Be.toBuffer(I,E.encode),c.commentLength=a.length},getEntryCount:function(){return f?r.length:c.diskEntries},forEach:function(I){this.entries.forEach(I)},getEntry:function(I){return f||_(),s[I]||null},setEntry:function(I){f||_(),r.push(I),s[I.entryName]=I,c.totalEntries=r.length},deleteFile:function(I,R=!0){f||_();let L=s[I];this.getEntryChildren(L,R).map(A=>A.entryName).forEach(this.deleteEntry)},deleteEntry:function(I){f||_();let R=s[I],L=r.indexOf(R);L>=0&&(r.splice(L,1),delete s[I],c.totalEntries=r.length)},getEntryChildren:function(I,R=!0){if(f||_(),typeof I=="object")if(I.isDirectory&&R){let L=[],w=I.entryName;for(let A of r)A.entryName.startsWith(w)&&L.push(A);return L}else return[I];return[]},getChildCount:function(I){if(I&&I.isDirectory){let R=this.getEntryChildren(I);return R.includes(I)?R.length-1:R.length}return 0},compressToBuffer:function(){f||_(),v();let I=[],R=[],L=0,w=0;c.size=0,c.offset=0;let A=0;for(let z of this.entries){let O=z.getCompressedData();z.header.offset=w;let N=z.packLocalHeader(),U=N.length+O.length;w+=U,I.push(N),I.push(O);let W=z.packCentralHeader();R.push(W),c.size+=W.length,L+=U+W.length,A++}L+=c.mainHeaderSize,c.offset=w,c.totalEntries=A,w=0;let k=Buffer.alloc(L);for(let z of I)z.copy(k,w),w+=z.length;for(let z of R)z.copy(k,w),w+=z.length;let F=c.toBinary();return a&&a.copy(F,Be.Constants.ENDHDR),F.copy(k,w),t=k,f=!1,k},toAsyncBuffer:function(I,R,L,w){try{f||_(),v();let A=[],k=[],F=0,z=0,O=0;c.size=0,c.offset=0;let N=function(U){if(U.length>0){let W=U.shift(),se=W.entryName+W.extra.toString();L&&L(se),W.getCompressedDataAsync(function(fe){w&&w(se),W.header.offset=z;let we=W.packLocalHeader(),Le=we.length+fe.length;z+=Le,A.push(we),A.push(fe);let ot=W.packCentralHeader();k.push(ot),c.size+=ot.length,F+=Le+ot.length,O++,N(U)})}else{F+=c.mainHeaderSize,c.offset=z,c.totalEntries=O,z=0;let W=Buffer.alloc(F);A.forEach(function(fe){fe.copy(W,z),z+=fe.length}),k.forEach(function(fe){fe.copy(W,z),z+=fe.length});let se=c.toBinary();a&&a.copy(se,Be.Constants.ENDHDR),se.copy(W,z),t=W,f=!1,I(W)}};N(Array.from(this.entries))}catch(A){R(A)}}}}});var Dd=ne((oS,Td)=>{var xe=Xn(),ue=ae("path"),Vp=na(),Jp=Ad(),En=(...t)=>xe.findLast(t,e=>typeof e=="boolean"),Cd=(...t)=>xe.findLast(t,e=>typeof e=="string"),Zp=(...t)=>xe.findLast(t,e=>typeof e=="function"),Yp={noSort:!1,readEntries:!1,method:xe.Constants.NONE,fs:null};Td.exports=function(t,e){let r=null,s=Object.assign(Object.create(null),Yp);t&&typeof t=="object"&&(t instanceof Uint8Array||(Object.assign(s,t),t=s.input?s.input:void 0,s.input&&delete s.input),Buffer.isBuffer(t)&&(r=t,s.method=xe.Constants.BUFFER,t=void 0)),Object.assign(s,e);let a=new xe(s);if((typeof s.decoder!="object"||typeof s.decoder.encode!="function"||typeof s.decoder.decode!="function")&&(s.decoder=xe.decoder),t&&typeof t=="string")if(a.fs.existsSync(t))s.method=xe.Constants.FILE,s.filename=t,r=a.fs.readFileSync(t);else throw xe.Errors.INVALID_FILENAME();let c=new Jp(r,s),{canonical:f,sanitize:l,zipnamefix:x}=xe;function h(_){if(_&&c){var y;if(typeof _=="string"&&(y=c.getEntry(ue.posix.normalize(_))),typeof _=="object"&&typeof _.entryName<"u"&&typeof _.header<"u"&&(y=c.getEntry(_.entryName)),y)return y}return null}function m(_){let{join:y,normalize:v,sep:I}=ue.posix;return y(ue.isAbsolute(_)?"/":".",v(I+_.split("\\").join(I)+I))}function E(_){return _ instanceof RegExp?(function(y){return function(v){return y.test(v)}})(_):typeof _!="function"?()=>!0:_}let C=(_,y)=>{let v=y.slice(-1);return v=v===a.sep?a.sep:"",ue.relative(_,y)+v};return{readFile:function(_,y){var v=h(_);return v&&v.getData(y)||null},childCount:function(_){let y=h(_);if(y)return c.getChildCount(y)},readFileAsync:function(_,y){var v=h(_);v?v.getDataAsync(y):y(null,"getEntry failed for:"+_)},readAsText:function(_,y){var v=h(_);if(v){var I=v.getData();if(I&&I.length)return I.toString(y||"utf8")}return""},readAsTextAsync:function(_,y,v){var I=h(_);I?I.getDataAsync(function(R,L){if(L){y(R,L);return}R&&R.length?y(R.toString(v||"utf8")):y("")}):y("")},deleteFile:function(_,y=!0){var v=h(_);v&&c.deleteFile(v.entryName,y)},deleteEntry:function(_){var y=h(_);y&&c.deleteEntry(y.entryName)},addZipComment:function(_){c.comment=_},getZipComment:function(){return c.comment||""},addZipEntryComment:function(_,y){var v=h(_);v&&(v.comment=y)},getZipEntryComment:function(_){var y=h(_);return y&&y.comment||""},updateFile:function(_,y){var v=h(_);v&&v.setData(y)},addLocalFile:function(_,y,v,I){if(a.fs.existsSync(_)){y=y?m(y):"";let R=ue.win32.basename(ue.win32.normalize(_));y+=v||R;let L=a.fs.statSync(_),w=L.isFile()?a.fs.readFileSync(_):Buffer.alloc(0);L.isDirectory()&&(y+=a.sep),this.addFile(y,w,I,L)}else throw xe.Errors.FILE_NOT_FOUND(_)},addLocalFileAsync:function(_,y){_=typeof _=="object"?_:{localPath:_};let v=ue.resolve(_.localPath),{comment:I}=_,{zipPath:R,zipName:L}=_,w=this;a.fs.stat(v,function(A,k){if(A)return y(A,!1);R=R?m(R):"";let F=ue.win32.basename(ue.win32.normalize(v));if(R+=L||F,k.isFile())a.fs.readFile(v,function(z,O){return z?y(z,!1):(w.addFile(R,O,I,k),setImmediate(y,void 0,!0))});else if(k.isDirectory())return R+=a.sep,w.addFile(R,Buffer.alloc(0),I,k),setImmediate(y,void 0,!0)})},addLocalFolder:function(_,y,v){if(v=E(v),y=y?m(y):"",_=ue.normalize(_),a.fs.existsSync(_)){let I=a.findFiles(_),R=this;if(I.length)for(let L of I){let w=ue.join(y,C(_,L));v(w)&&R.addLocalFile(L,ue.dirname(w))}}else throw xe.Errors.FILE_NOT_FOUND(_)},addLocalFolderAsync:function(_,y,v,I){I=E(I),v=v?m(v):"",_=ue.normalize(_);var R=this;a.fs.open(_,"r",function(L){if(L&&L.code==="ENOENT")y(void 0,xe.Errors.FILE_NOT_FOUND(_));else if(L)y(void 0,L);else{var w=a.findFiles(_),A=-1,k=function(){if(A+=1,A<w.length){var F=w[A],z=C(_,F).split("\\").join("/");z=z.normalize("NFD").replace(/[\u0300-\u036f]/g,"").replace(/[^\x20-\x7E]/g,""),I(z)?a.fs.stat(F,function(O,N){O&&y(void 0,O),N.isFile()?a.fs.readFile(F,function(U,W){U?y(void 0,U):(R.addFile(v+z,W,"",N),k())}):(R.addFile(v+z+"/",Buffer.alloc(0),"",N),k())}):process.nextTick(()=>{k()})}else y(!0,void 0)};k()}})},addLocalFolderAsync2:function(_,y){let v=this;_=typeof _=="object"?_:{localPath:_},localPath=ue.resolve(m(_.localPath));let{zipPath:I,filter:R,namefix:L}=_;R instanceof RegExp?R=(function(k){return function(F){return k.test(F)}})(R):typeof R!="function"&&(R=function(){return!0}),I=I?m(I):"",L=="latin1"&&(L=k=>k.normalize("NFD").replace(/[\u0300-\u036f]/g,"").replace(/[^\x20-\x7E]/g,"")),typeof L!="function"&&(L=k=>k);let w=k=>ue.join(I,L(C(localPath,k))),A=k=>ue.win32.basename(ue.win32.normalize(L(k)));a.fs.open(localPath,"r",function(k){k&&k.code==="ENOENT"?y(void 0,xe.Errors.FILE_NOT_FOUND(localPath)):k?y(void 0,k):a.findFilesAsync(localPath,function(F,z){if(F)return y(F);z=z.filter(O=>R(w(O))),z.length||y(void 0,!1),setImmediate(z.reverse().reduce(function(O,N){return function(U,W){if(U||W===!1)return setImmediate(O,U,!1);v.addLocalFileAsync({localPath:N,zipPath:ue.dirname(w(N)),zipName:A(N)},O)}},y))})})},addLocalFolderPromise:function(_,y){return new Promise((v,I)=>{this.addLocalFolderAsync2(Object.assign({localPath:_},y),(R,L)=>{R&&I(R),L&&v(this)})})},addFile:function(_,y,v,I){_=x(_);let R=h(_),L=R!=null;L||(R=new Vp(s),R.entryName=_),R.comment=v||"";let w=typeof I=="object"&&I instanceof a.fs.Stats;w&&(R.header.time=I.mtime);var A=R.isDirectory?16:0;let k=R.isDirectory?16384:32768;return w?k|=4095&I.mode:typeof I=="number"?k|=4095&I:k|=R.isDirectory?493:420,A=(A|k<<16)>>>0,R.attr=A,R.setData(y),L||c.setEntry(R),R},getEntries:function(_){return c.password=_,c?c.entries:[]},getEntry:function(_){return h(_)},getEntryCount:function(){return c.getEntryCount()},forEach:function(_){return c.forEach(_)},extractEntryTo:function(_,y,v,I,R,L){I=En(!1,I),R=En(!1,R),v=En(!0,v),L=Cd(R,L);var w=h(_);if(!w)throw xe.Errors.NO_ENTRY();var A=f(w.entryName),k=l(y,L&&!w.isDirectory?L:v?A:ue.basename(A));if(w.isDirectory){var F=c.getEntryChildren(w);return F.forEach(function(N){if(N.isDirectory)return;var U=N.getData();if(!U)throw xe.Errors.CANT_EXTRACT_FILE();var W=f(N.entryName),se=l(y,v?W:ue.basename(W));let fe=R?N.header.fileAttr:void 0;a.writeFileTo(se,U,I,fe)}),!0}var z=w.getData(c.password);if(!z)throw xe.Errors.CANT_EXTRACT_FILE();if(a.fs.existsSync(k)&&!I)throw xe.Errors.CANT_OVERRIDE();let O=R?_.header.fileAttr:void 0;return a.writeFileTo(k,z,I,O),!0},test:function(_){if(!c)return!1;for(var y in c.entries)try{if(y.isDirectory)continue;var v=c.entries[y].getData(_);if(!v)return!1}catch{return!1}return!0},extractAllTo:function(_,y,v,I){if(v=En(!1,v),I=Cd(v,I),y=En(!1,y),!c)throw xe.Errors.NO_ZIP();c.entries.forEach(function(R){var L=l(_,f(R.entryName));if(R.isDirectory){a.makeDir(L);return}var w=R.getData(I);if(!w)throw xe.Errors.CANT_EXTRACT_FILE();let A=v?R.header.fileAttr:void 0;a.writeFileTo(L,w,y,A);try{a.fs.utimesSync(L,R.header.time,R.header.time)}catch{throw xe.Errors.CANT_EXTRACT_FILE()}})},extractAllToAsync:function(_,y,v,I){if(I=Zp(y,v,I),v=En(!1,v),y=En(!1,y),!I)return new Promise((k,F)=>{this.extractAllToAsync(_,y,v,function(z){z?F(z):k(this)})});if(!c){I(xe.Errors.NO_ZIP());return}_=ue.resolve(_);let R=k=>l(_,ue.normalize(f(k.entryName))),L=(k,F)=>new Error(k+': "'+F+'"'),w=[],A=[];c.entries.forEach(k=>{k.isDirectory?w.push(k):A.push(k)});for(let k of w){let F=R(k),z=v?k.header.fileAttr:void 0;try{a.makeDir(F),z&&a.fs.chmodSync(F,z),a.fs.utimesSync(F,k.header.time,k.header.time)}catch{I(L("Unable to create folder",F))}}A.reverse().reduce(function(k,F){return function(z){if(z)k(z);else{let O=ue.normalize(f(F.entryName)),N=l(_,O);F.getDataAsync(function(U,W){if(W)k(W);else if(!U)k(xe.Errors.CANT_EXTRACT_FILE());else{let se=v?F.header.fileAttr:void 0;a.writeFileToAsync(N,U,y,se,function(fe){fe||k(L("Unable to write file",N)),a.fs.utimes(N,F.header.time,F.header.time,function(we){we?k(L("Unable to set times",N)):k()})})}})}}},I)()},writeZip:function(_,y){if(arguments.length===1&&typeof _=="function"&&(y=_,_=""),!_&&s.filename&&(_=s.filename),!!_){var v=c.compressToBuffer();if(v){var I=a.writeFileTo(_,v,!0);typeof y=="function"&&y(I?null:new Error("failed"),"")}}},writeZipPromise:function(_,y){let{overwrite:v,perm:I}=Object.assign({overwrite:!0},y);return new Promise((R,L)=>{!_&&s.filename&&(_=s.filename),_||L("ADM-ZIP: ZIP File Name Missing"),this.toBufferPromise().then(w=>{let A=k=>k?R(k):L("ADM-ZIP: Wasn't able to write zip file");a.writeFileToAsync(_,w,v,I,A)},L)})},toBufferPromise:function(){return new Promise((_,y)=>{c.toAsyncBuffer(_,y)})},toBuffer:function(_,y,v,I){return typeof _=="function"?(c.toAsyncBuffer(_,y,v,I),null):c.compressToBuffer()}}}});var uu=ne(ve=>{"use strict";function to(){let t=["uxfxrvK","DfPcB3u","CxvADge","B3jRzxjhBg8","tu1Hs0u","DMfS","tKXmtM0","AKrYD2W","CM92AwrLige","wwfQzg0","yxrLq291BNq","vLvTCxi","CMfNzvn5BMm","A3f0t2e","zhPItLO","AwXSihvZzsa","s0X3rgO","ru91zwy","y2uGBM90igK","DvrozeC","v0vTAge","Dhfkq1i","t1Doveq","Dg9tDhjPBMC","Bwf4uMv0CMK","swDyrK8","AwXLx25HBwu","AK1LBhe","AhbNveq","CMvWBgfJzui","tg9JAW","yMToA0u","BeHHBMrSzxi","r1rktvi","ihzHBgLKigq","q3vZDg9Tq2W","vgzzuuC","qxDXsfK","EgLXqLy","DhjPBq","Ee9TBK4","C0jf","B3rHvMe","rNjVBNrPzxi","wK9XAMO","tgrtBuC","u21cs20","Dg9hzw5LCMe","DcbVzIbYyw4","zgvIDwC","sxv0qKO","zgvMAw5Luhi","z1n1CuO","vKTesuS","AK96s0m","zw9bA0u","tuLdBe8","zNjVBuHHC2G","wLjpy1C","DvLtuLu","B0nOr3a","suDnAei","C3vIyxjYyxK","AxjsC3O","u3fpwLK","ywzHCgu","x2rItMfTzq","q0jnBKi","Aw5N","t2X3DNC","y2zSsLm","re5RDLC","DurHsvO","q0TQtfC","D3nZoI8V","D2vI","uwrYD1G","yLPOBgC","rw1HC1i","qwHkzuy","DMvYC2LVBMm","mtbNsMrbEhi","zwXdD3C","BgrttNy","u2HSA1u","Cg9PBNrdB24","vLrWD24","s3vpA1i","z1Pev0W","CgfNzwHPzgu","ExPTCfe","tKnxsM4","zNjVBNrPzxi","r0rou1y","Cg9PBNrbBMq","zNbVse4","C2v0y3vYC28","q3DYA04","uejkAvy","ChPmEKy","yLjhufG","zNjVBu51Bwi","vw5Oyw5KBgu","AwTowLK","CgfNzxnOB3C","CMLLC0nVDw4","yLrSquC","quLTv3e","qwfWrKW","Aw5PDcbrB1m","wKTkqwq","DMvY","DhLWzq","zMvY","seLQv3i","wxD2wwy","qKjxBxG","CLbHEMO","yxv3z1a","BhP6EgC","A2LgvxK","vhPKzvu","ywXS","tgLwqum","x29Uq2XVC2u","A2vOsuC","DgvZDa","uxvLDwu","Eefrrei","BMvY","wwL4Bvm","y2DyALy","B25SAw5L","Dgv4DfbHEwW","x25HDMLNyxq","Bg9NsurozxC","vfvJC0O","D2rNCeC","BMnVzgLUzW","CMvZzxrdB3u","mJKZnhjYvgHWtW","s29xyLm","B25nzxnZywC","nhWXmhWXFdG","zw5HyMXLqxu","BLPHtwW","B1bbAMe","BfjbyLa","x2LZqNjVD3m","x3nLBMrby2S","wvruAvK","Bwf4twvZC2e","CgjNzKi","EevhC24","wM5Lyxa","zNvSBLm","rfDxEMW","zKTRB0u","B3bLBG","Dw50","wxrTqMO","x29UrxjYB3i","DeLK","BNrfBMrWB2K","y3jLyxrLt2i","tKDFrvjst1i","BxnNsuq","yxv0BW","C21muNi","Cu9RrK0","B2nRzxq","vxbKyxrLq28","B0fOELK","C3nHz2vfDMu","AMvJDfn0B3i","AwjsuwG","D0PWzxG","yuLpuMW","zunPB0C","yxfJq1y","qKjeD1i","zgvwwu4","q0Xpu0ve","suPsCwS","q2ztDhu","A0fNzgS","l3DZl3yY","qMnhq1C","mte0mJK3nNnkD01eva","ENDPr00","AgTutMe","DMvUDa","y2HLy2TdDxi","C2v0sxrLBq","B25fCNjVCG","whjXrxa","AgfZ","x21LC3nHz2u","u2DuC2C","zgrhy0i","x3nLCuLK","s3vjA3i","DK1dEgW","EeXgEMi","uKzbz0i","mxbdBuHstG","D3rHsNy","x0rctMfTzq","BNruCMLLC0m","ywjVCNq","BwvZC2fNzv8","D2fZq2XLyw4","y29UC3rYDwm","u2XnqNG","ywrKq291BNq","uxvxt1m","EfjSEhu","C0z4tM0","tMLlzhG","DMvYC2LVBG","yMfSu2nVCgu","ANb1EfG","B2P5rfO","q0XIrfi","u0XLz3C","qMrVA0O","qxfnseC","DvrLuuu","x3bPBMDmB3m","Aw5L","ru5rBgy","D0zpqve","yMrFzgLK","wuL1r3C","DeLUDgvYy2u","q29UzMLN","EK9hzuG","x29UvgLTzw8","AwLpv3q","BKnnEeu","r0r5yMK","x2LZv29YA2u","yM9KEq","D05TuxO","q1Douwm","yxbWBhK","EKP4CLC","CvjSEKC","C2nYAxb0","Avntu0K","AwXLtMfTzq","z2v0q3vYCMu","Dhj1y3rVCIa","C0nVDw50zxi","CvjTrxq","uKfVquy","qw1mvwO","D1zmsvq","CMfTugfYyw0","yKLHsMe","ywDLsgLKzq","A29Svwy","vuP3z1G","DxvVB00","zNfysM8","EsbJBg9Zzwq","qvHKuwe","sM5qzw8","yMLUyxj5","ruTyCwC","wg5oreC","BvnbDw0","x2LUDgvYDMe","ywXSzwqGBxu","v2L1sue","x3jLBw92zvC","twLZC2LUzYa","x2n1CNnVCK0","BgncEgC","B2zMBgLUzq","Dgv4Dc9Qyxy","B2LUDfjLywm","EuH0quS","svvetfa","u1DWD1m","u3rYyxrLz3K","t0rov2y","rgvKAwnHDgu","DKDHvgW","tuHPzwK","y3jLyxrLq2W","sfzhy2G","EK1PqKe","x2TLEvbHDgG","C2TVEM0","Aw5JBhvKzxm","AM9PBG","tvP2A1G","wLzuA2S","CMvTB3zLrxy","Dw5RBM93BIa","thLlDfO","zwjVwe0","qLDuEem","igzHAwWSig0","x2nYzwf0zvm","BxrzzMO","CLHfAxe","ywnOzwq","lcbOB3n0BMe","z2vtEw5J","zNjVBujPDhm","tMzJuKm","whvSAuy","u3r4EK0","rLjptLrjrvi","x29UtwvZC2e","x2rLyNvN","x2LZtwLUAvC","y3jLyxrLuMu","EfvLsxy","q0Xpu0LorW","AMXvrKu","D2zWDKS","x3bPBMC","B0DLD3q","s3vJvwG","Dfv2vMO","CgvYC2LZDgu","t0Dluu4","A1z4Bg8","ve5rwNC","vLvrAu8","ntqYmef5A1HsBW","Cgf5Bg9Hzfq","C2vYDMvYvgK","uMvJB25Uzwm","q09oveLovuu","wvniDMm","y29UBMvJDa","Dg9cExrLCW","rgTqwuC","u25LDwC","AhbNr2u","CMTLCKDSB2i","t3nwt2m","BIWGAg9ZDg4","A214sxq","CMvHzg9UBhK","ywXPzcb1CMW","Aw5Lza","AMHUuuu","q2vJsfO","wLLMAhK","zxmGCMvHy2G","x19LC01Vzhu","quXm","BM9VBuW","EvvOBfG","AgvKtwf4uMu","tLvwz0S","z2vjBMzVu3K","zMXVB3i","t0rrsgC","turTCeW","ChrVCG","Aw9UvgLTzw8","uNnTu3y","tufyx1jfvfi","Eg1ZA0y","yMX6yKW","zxH0ugf5Bg8","C2v0","rKLmrv9ot1q","s05yANO","BeDtu1q","yKnwzxq","CM92AwrLihC","B0TYAu4","yM1ytvm","zMLSDgvY","wMT3wgq","AuDlrNy","s2nJtuK","sMrAswG","zMzmAw5L","rLDt","D1jZugq","v0riD3u","tNrwsuS","uKL2uxe","y2HnyxHdB3u","q29Kzq","tgPTqLm","u2D5Ahy","BMvLzf9Hy2S","zwnVBM5Ly3q","CMvJzwL2zwq","CuPpELK","CgLUz19VBMm","qunkELi","ww5fuuu","vgXewfq","tw9Zufu","r0rbywe","CgjnD0m","vKTVu20","BeD1sLC","B3jRig9MzMW","C2vUza","zgLZCgf0y2G","B3nLza","Bwu6ia","y3vYC29Yx24","BMCGzMfPBgu","swzruNC","Aw5KzxGGB3u","y2P3vxm","mhW0Fdn8mNW","ENjYAKO","wKX1EMq","s0DVugW","rxjYB3jdB2q","t1DIwKS","Cw9Zx18","suvtx0vsuK8","DwfoBKK","D24GCMvHC28","nhWZFdf8mNW","y2XLyxi","zgLZywjSzue","BMvJDa","yw1L","yM9L","zsbHihn0CMK","AgLNAa","y3vYC29YlNm","q21qu3m","y2fSBa","rLzbEfa","q0Lvrwu","nxWX","ve1AAhi","yxKSig5LDhC","AM14CKq","DvLlvw4","BxrzCfy","qwT6vKm","EuT4v3q","wwnQB1K","ve9zDvm","uLjpuG","yKPcvgC","x2HHBMrSzu8","CMvTB3zLq2G","x2HHBMrSzva","x3bHDgHlzxK","x3fVC0rc","EgT1v0m","BMrWB2LUDfq","qKroAee","sLnptLa","zv9ZDwnJzxm","wxD4EhG","CurKALC","AgrTCgy","B2zM","t1rQELy","y1zfqMW","uMXwvK4","wgvwrgO","tLjluK8","Cujwu3a","zgvS","twLHv0q","x2rPC2nVBM4","zNjVBunOyxi","ignVzgu6ia","rxbKz1C","BwvZC2fNztO","yxvvt3i","B3bLBKrc","CM9YrxzLBNq","ExftvLm","A2v5CW","BMrWB2LUDca","Ehfiqxu","A1n0yxr1C0m","ihrVihjLDhi","BvnYtLa","Dufdzu0","y29UBMvJDca","y3vYC29Yx2y","DKvnu3e","yMXZtvi","ENnzwNe","yNLlwue","C2v0u3rVCMe","Cerds1a","Aw9Ul2PZB24","ANfxuuK","ww1buey","vfvmwxi","AMvuANu","CMvHzhLtDge","EKDfzgm","ihjLy29UBMu","r0vguvG","rgLVzNa","y2XLyxjtDg8","Bhm6ia","rxzLBNq","yw5Yq0i","yxnL","DLLMsey","BMv3vMvYC2K","t1jzr3K","v1f1te8","EMTXsg4","qxHwA3K","r21zEKy","DMLJzuLeig8","ywDLrxzLBNq","DhbizwfKzxi","Ehrbyuq","twvZC2fNzuu","qwXhDNq","Au1PrLq","EKvqyu0","t1bftG","Dej4Efq","De1gBKm","DLnHChK","v3voqLO","yKDICNK","BgLTAxq","vNvhr1a","x2DLDeLUDgu","B2zMC2v0","Ec1TC2CTy3u","v2ThAKe","DfPky0O","z1rPBwvVDxq","B25JBg9Zzq","zw1LBNq","x2HHBMrSzvi","vuXHEgO","lcbTyxGGCMu","sgPlr2W","yMrtuhe","zMLUza","x2zVCM1HDeu","D3vqAe0","y29Kzq","nJa0mfLNC0flDG","BKHotwS","s1jZEMi","wK15tLq","zxjFAxnFywm","z2v0","B25LCNjVCG","C3bSAxq","qMXPuuu","q05tDwC","mhWYFdr8m3W","zNjVBuj5Dgu","swv0ruO","y3jLyxrLrxi","uurgs0i","tNP3v2i","z2nLwK0","CgXVCeq","BgvY","BLjewgy","yMXVy2TLza","wvvyvgy","z1btBLe","sxzKBgq","DgHHBIbSB2m","zujgD3q","CwPjDNe","sxnswve","ywnRx2LK","EgvVvgW","ruDiCuW","zxjHDg9Y","zxH0zw5ZAw8","C0XPC3rLBMu","zwncwuu","C3v6ug8","y29SBM8","Bwf4tg9ZC0m","BwvKAwf0zwW","EfvZzuvUDG","CMvJB25Uzwm","uenbteK","q09otKvdveK","t0nAyu8","we5nvfy","sgvivLe","BgPNv2e","v2LUzg93","z0zkyvu","tgLZDgvUzxi","yw5ZzM9YBvq","C0PLu24","EfPHs0G","CM9tvhi","CNHRueu","vMvHuum","Ae1LC3nHz2u","C2XPy2u","sxnIBe0","qLLJswm","svH5Cg0","rg1nBwy","mxW2Fdq","yw51Ce1LC3m","C1PIuwy","zv90Aw1LB3u","y2HHCKnVzgu","AgvHzgvYCW","EePHBLK","q291BNq","z2v0qwXS","ELHvEuS","yxPUwvi","AhLHteq","mJeZnZG0rMPnvwLs","CNvcy0u","whjgtKO","twnLrw0","zK9SAhe","Cu54DMu","vgnTyKq","DhHvsei","De9jEgu","CvjrEfm","D1j6Axe","Ae5irwm","vu5esMe","qKzywwG","zfDVCMTLCKC","s1H1Bfi","DcbSAw1PDa","q2LzAgu","rMDxsfG","uvvXBLu","BM93","zxrxB3jRq2G","zxHWB3j0CW","x2XPC3rLBMu","rNjRrMm","qNDdAuW","A2v0ignVBNm","z0rluvO","yxjYyxLIDwy","BwLUAvbYB2C","uKDfBKi","B2Lzwfi","z2v0t3DUuhi","CNnVCL9Uyw0","C1LzBwC","DvfWAw0","mdaWmdaWmda","ywT3zeS","y3jLyxrLtwu","ExbL","tw13ruG","yNL0zu9MzNm","Den5BgW","ywrK","yNL0zxm","sMHdsfu","DxbKyxrLq3u","y3P0yK4","s3DcwKu","DhjPzxmGCMu","AunUrwK","rLvZtK0","CxfPALi","uNnpCNu","B25Xr2O","yxvPEgi","Cg93","CfnSCwW","AenSB3nLrxy","BezSDxnO","z2v0u3rVCMe","wfDdyNi","uu5MvLC","B01gEMi","oxWZFdb8n3W","D3jPDgu","Buf5qwm","rM1Py1C","wMzOtxu","AefJA01LC3m","BhLHENy","CKz3ugK","yxnJCMLWDa","BLfQs3G","DxrMofDYAxq","u1jsswW","ywWGy3vYC28","terwBhi","Dur0zgy","vNfJwKy","ywDL","B3DlrK4","DhjPzxm","rKfKrM0","ANHitxy","Cu5YEwe","Dg5kyvy","Ahr0Chm6","pxv0zI04","AevYCM9Yrxy","v0fzCNO","ntC0tNnAvMLO","yKLUA0S","igfYCMf5yNu","zxjFCw9Zx2e","uMLQB1q","uwPiDLq","uKfvy2m","y29UBMvJDgK","tNbbA0W","wvzfwui","BMfTzq","B3nLrxzLBNq","t3bLBKv2zw4","AvzhrLu","t0HYrfm","DxnLCKLW","zxjWA3O","wxnAtKK","rLfhtwK","x2LZtwLUAvq","ihrPBwvVDxq","Ewfkyw0","C2vYDMLJzs0","CMvHC29U","AxPns0W","BvPAy0e","wK9MEee","CgDsquK","C3z5tw4","tfzeyKu","Cgf5Bg9Hzeu","CMvQzwn0","ChD3wLq","ueXcCwG","zxq9DxrMltG","AxnszwfKEq","vxnlCMS","zMXHBNu","Dfngug8","zg9Uzq","CMvHzfvjBNq","yNL0zuXLBMC","zwPVBNa","CLrutLi","wuX5zKS","Cvj6wha","EwP3DLa","ruLHwfa","AengBwi","zvPmzNa","x3nVy2TLDa","y29UBMvJDfm","whbgvgK","wwvjy3e","u0TVwvq","C0Xf","sfjvB3C","zNDZxZeUmc4","AwXK","AgDwshK","CuH5CvC","DwDpBKS","wfDnBgK","zwziBva","BfrPBwvVDxq","CMvKDwnL","rNDSCMm","DwHtyuW","ChbL","te1HwMe","uujbBwy","BgP5BKK","Ae9Wzw5fDMu","Cg9W","vLzsueq","qNrluNu","y2nhDfe","D0Hiwxu","sKvAAgK","DvD0BKO","yvjpvK8","zMX1C2HfEha","zvbmthO","s29cDuq","yvnxzLC","B3bLCNr5","y291BNq","y3vYC29Y","BMnLq2XVC2u","CNnVCL92ywW","yMPLAe4","tKHPshq","s1LntLi","rM52tK0","BK5PweS","q2LzBK8","ENfhA0m","AgfUz2u","svfoDeW","sKXkrK4","ChbgAK8","tNLpENi","zwPJyu8","D1bKzuK","Aw5KzxHpzG","z1DhEK0","Dxrjza","qKLSqMG","CLL4yMC","wMHHuKu","EKPXtfi","m3WXFdj8mhW","uuTqELm","yNHHt20","B3LSBNe","q2L1vwC","u3ztEfG","BxvIsNK","u0rgsey","qwjVCNrfCNi","y3vZDg9Tshq","rLvmy2G","AhPPy0S","Dw5ZAwDUzwq","DxjS","t2jrrMC","yNLL","tgHPD0K","swfosw8","y29UBMvJDeu","CKXes0u","DMfSDwvZ","x2fKzfDZtgK","DxrVuMvJB24","y1HXwhy","DgLTzw91DcW","yw5Hz2vY","EMzczum","vKPUsMO","Ef9MCM9UDgK","zhrMwxu","CNzby0u","uMvHzcbWyxm","ru9QAxu","ywXty29Wzq","Cw1TtNm","zw5HyMXLuw8","x1fVu01HBMe","B25tDgfYDfi","sNLezNO","B2jQzwn0u3q","BwvyvK4","CMvZzxrfBMq","Dg9cExrLC0W","ugjSqxe","u09vq1a","C3rYAw5N","D0TsrfK","Ee1MDe0","Cfb2uMy","C2v0q3vYC28","D3LMEwK","icSG","ywnRDxbfBMq","DKXos2i","wefeveO","z2v0qwXSs2u","y2vZC0HHBMq","Aw1LCYbPBIa","rfD0CMK","y2f0y2G","qw1VDw50","qw9Htva","u3DcA2S","zhDguLe","AK93zhO","qKHkufC","CgLUz0XVC3m","AxnrB1nnzxm","EvjLy29UBMu","rfDrAhG","B0vOALy","vgD0Exe","yxv0B21HDgK","q21AB0u","ywrKt25L","Cg1iyMO","C2v0zgi","wKL2rxa","tMfTzq","vLfTDM4","Ec1TC2CTCw8","BwvZ","tercvei","ChjVDg90Exa","CNL5BfK","venNwKW","BwLtCu4","BefdEhO","zgTjvwe","wufMqwW","vxPizfq","vMfhv2u","x2nSzwfYvgK","yw5Nzq","wwjRtM4","yxfkCuK","BvLpyuG","EwfurgC","q2fYzLe","AxnmB25N","rxbwr1y","wwT5y1y","yMLUza","ru96B24","thn0vgy","BMrLEa","mZm3nZftuvHrzKC","y2XVC2veqG","vLH4rxm","sMDtEvO","zvfRtwK","tuT0BMW","zKfWEu4","CLbmv1K","CMvXDwLYzwq","t0jkDKW","CfrHwxu","B3PZzfO","CMvUDevUzha","tg9Nsuq","yMLUyxj5vhK","t1zesxC","zcWGDw5RBM8","r0j0v28","C3rVCMu","zxjYtM8","DgvmB2Djre4","CMvZB2X2zq","ywXSq3vYC28","z2HYs0O","yvnfBMG","ihn1y2nLC3m","D3r1BMG","v2vIu29JA2u","u2nhCKW","tM5ov2K","CNjVCK1LC3m","sK1nEhC","CgfYC2u","CNzHBa","r3rPsgS","DhjHBNnHy3q","Aw50zwDLCIa","C2vYDMLJzq","r1DstMW","yuXUz1K","swXJD3O","tgnnsxK","Aw5KzxG","A2v5","wu5eBLi","t2DRA0G","s2PmAg4","sfLAv0W","Bu9hEMy","y2XVC2uSihC","vvbiu1e","yxnZAwDU","zNvUy3rPB24","zLfdr1i","DMnWqM0","ihrPBwvZ","CMvZDwX0","zw50tgLZDgu","yNvMzMvY","zw50zwqGDhK","vMfoyNu","x3DZ","D2rmA28","Cgu6ia","y0nzAva","txPrwgy","A291zeq","vgLWze4","y1PdCxi","zwrPyxrLBhK","CNzHBfzHBhu","ze1iquy","CgLUz0LUDgu","zvvYBa","rMnNqwW","DgHTAxm","De1HBMfNzxi","BwLUzW","rvjst1i","svjevMi","zMLN","DMTUtge","sNbXq2i","x3DHAxq","DMfSDwu","tKrxseG","CxPLqxu","s3newg4","ysbTDxn0igi","wfbLuKm","Dg9Y","EuHptuS","A0DNEMq","D3m6lY8","DhDVCMTdAge","s0jlEKy","tKfusvzfx0u","x2n1CNnVCK4","s0zsBM0","sxrRBgW","Cun6wKG","yuPjDeq","AxjLza","AM5kDhy","vvvjAeq","EfneB2S","zgf0yq","B25TzxnZywC","C3vJy2vZCW","uxD3ANe","sfzVzKW","DK53Awi","uwrnExG","BMDuAw1LCG","weT1BKu","nde5odDWA2rvywC","AuDVv2y","AxLPq0O","vNbsDMW","rLvSAfu","yKTsq2m","yxDrqMC","EhfZwxm","v0jnAKS","D0nPzvq","veXdzK0","suDuzM4","yxrHlcbKyxq","t3PUvha","yLnQCgO","x2jPBMfYEvq","AxnbCNjHEq","vMzAwMK","DgfIyxnL","swjYquS","ChvZAa","Dg9cExrLC0i","rwD6DgC","Dg5Tze8","ig1LC3nHz2u","uwf2AvK","ANnrtgK","suzmCei","Axf2Due","x2LZsw5PDa","Efb3sMy","nhWWFdj8m3W","DMfotK0","ru5mD24","sMjere4","Efrurw52","ihzHBgLKihm","vgPrEwS","vu1lD2q","CMfUzg9T","z3vpufG","vgfN","C3rVCcbPBw0","u2vXsuq","C2HPzNq","Bw9vuwm","z3fAqMu","wfLUtvC","C2DPza","s0npt0K","CM92AwrLigi","CLHys20","A2jzsha","tuvtu0fhrv8","mta5ntC2BwXxrMj1","x2DLBMvYyxq","vevQD0G","twPguKS","CMv0CNLdB3u","zw5JB2rPBMC","AwDHDg9Yt24","y3r4","DLL5zw8","Cerhq0m","tg9NsurozxC","Bxvqwfy","uLHrAMS","z2v0sxrLBq","zw50","DhfhC3q","vgngsNu","v0zYCfe","B2nRzxrtDwm","y29UDgLUDwu","tMniEuO","DgLTzw91Da","teTuEvq","zw1PDa","ELrNDhK","BxnN","yKj4A1y","zg9fA0S","D3PSqKq","y1vVrg8","Exb2BgK","Dev2zw50","u2vYDMLJzvC","zcbLCNjVCI4","Bwv0Ag9K","x2rPC3bHDgm","BgLUzw5V","CgLUz09Uy2u","BKLwEhy","zxjFDhrS","Eu1oCLC","Exnlz0m","Ec11C2uT","x29Ut3bLBG","uhzVwNy","ihrYEsbYzwm","m3WXFdj8nhW","ywDLu2HVDW","Dg9mB3DLCKm","uef1wxq","C3vIC3rYAw4","v0riBLG","vgLTzw91Da","B2z6uhO","wevyA1e","yxbWzw5Kq2G","D3jPDgvvAw4","s1PuB3O","z29PBMCGyxC","C1bJDhO","rMDvDvi","x2rYB3bhBg8","C29YDa","BNHwEue","zxjYB3i","B25mAw5L","BKL3A1K","Eg5hBuG","tM9gwui","x21PBMLoyxy","wgT6EwO","t1bftL9fuLi","B3bLCNr5tMe","x3jLywr5q2W","EMvNyLm","yNvMzMvYzwq","EeXkveC","BMCGDxjSoIa","tgjmC2O","ug1HAei","vvHdt1u","zfLsreW","x2LUAxq","B1bRCLO","y3vYCMvUDeu","CYbPBNn0yw4","zwn0","AuD4z2e","sMnwrhm","Cgf5Bg9Hza","wfDKrLe","BgvUz3rO","CLzHBhvLCW","zfvZCNe","qwTKuMe","vxjzEe8","ufblA3e","zgvSzxrL","D1zmyMG","vxDJvfq","u3zOzg4","C291AK0","Bu5gvwu","ENbVyxC","rgDsEgm","Axnby2TdBgu","x3jLy29UBMu","Dw14q3C","y2HnyxHuCMK","A2nRq3u","Dff6Beu","EhPeBKq","AezrrNO","vePRBxC","r0zNrfO","yw1Lu3bHy2u","C2vUDa","B3vUDa","rhPUDLK","BML0AwfSAxO","zM9qt0e","Aw9U","qvPqBfm","ue9QALy","DfL0zhO","zLLZz0C","suTjveu","qKLqDwq","x29WDgLVBNm","x2LZtM9Kzq","BgLZDgvUtMu","DfnmAeq","ywnR","qKD0vu4","yKL5s1a","u3bwEfe","uhvOug4","ywnRtxnNswq","zw5fDMvUDa","zwHerwO","Bg9N","wuzdB20","B2nRzxrgywK","EgHsv2G","BM9Uzv9UB24","vK1Ure8","CYbWyxjHBxm","x3bPBMDqB24","uvbQufy","C2XbzgG","yMfSrxzLBNq","wgPgwu0","zKDIAgy","qLv6rLy","D3vHy0C","BgnOsMS","yxbWBgLJyxq","te9tq0m","tw9KDwXL","t3Lsqxe","Eg5gEuS","zM9YrwfJAa","Avzize8","qwDgvKG","u2PHqNy","z2v0q3vYC28","CMvHzhDYAxq","ywnRpwzYB24","CMvWBgfJzq","zM9Yy2u","v1ftA3a","D3nIvKG","A0jvswm","Dw5KzwzPBMu","yKfdsxi","u1b0Evq","x2LUAxrhBg8","x2nVBM5Ly3q","Bg9Nsurhzw4","B2fK","vNLruvm","qxbNC08","B3v0sw50zxi","zw5NDgG","yNLhyKS","yufLBxy","x2n1CNnVCKy","DuffA0O","D2LQzM0","BhrPCgXLihq","C1DUAfa","rfHoywq","D0HctNe","B25VCgvU","CeLwuNi","Cw9Z","ChDvzLO","y2HLy2Tszwe","B25pCgvU","yxLbAvm","yw1LoIa","y3jLyxrLt3a","B0TRAfC","ndHJqvv0DKu","Dg9iyxnO","s09SBfm","C29Tzq","BNrbBMrvCgq","C0rWy3i","zcWG","rKLIvvG","tu5yCKu","BNrLCG","z2v0s2v5","r2rSCM8","CMvZzxruCMK","BwvY","y09Wzw4","y2XVC2u","BwLZzq","sw1SwKu","Du1Squq","ywrKrxzLBNq","CwfUCvO","EuXoq2i","x2rLC3rYB3K","BwfW","CgTLv1a","C1HVwg4","DNDuzu8","B3jLtMfTzxm","igzPzwXKoIa","zMLSzw5HBwu","y3vYDMfSDwu","DgLUzYbZzxi","zufeu00","EvbWB1O","ChjVDg9JB2W","C2Trv2y","v0v4DMi","yw9ztw4","qNPowKG","qNjPzgDL","y3ruAw1LB3u","q0LduNm","AKr0yxy","o2nOyxjZzxq","A2j3EKC","zMzLCG","CM11sei","DvjxvMS","t1bzANq","sMDNwgq","zufJAW","wMHVAva","uhbZsvm","BM5Ly3q","vengrfG","BhDUuMC","CIb0DhDjra","y0PMtNO","DgHLBG","qurxBu4","y3vYCMvUDeK","qKPlt0y","zwvet1K","B25tDg9Wsw0","v3j6q0C","Dg9VigXHCMC","ANHJtMe","zw1Ozu8","qxzfr2i","CfrxEeK","yxrwvgy","Bg93","Cuzowfu","u0n4tKy","BwvZC2fNzq","B25szwnLAxy","vwf2Agu","uLPIrxG","v2r1A3a","CgXLyxnLiha","y3jLyxrLrwW","Aw1MCum","B3jL","qMnnrei","zw5KCg9PBNq","C1zwB3m","x3DZsw5ZDge","zfDty1m","D1ntCLC","vw5PBxbSzw0","zvDRDMi","x3bYB3rVy28","id4G","vfLSEM0","C0LduLi","zxjFCw9Z","AeDlyLi","x2vUzhbVAw4","ChjVy2vZCW","B3bLBIa","B2XKvMvYC2K","weHLA2e","AhrlA3y","Afv3AMC","CgX0svG","reiGzMfPBgu","x3vYBa","te5Rrei","BgLUzq","zgvJB2rLzey","DwjSBg4","z2vY","DM5fvuO","DK1vCuW","yxGGCMv0CMK","uhnoBKK","rvDiAuO","q1L4AfK","C3rLBMvYCW","rLnOB0C","zNjHBwvuExa","C3rYAw5NAwy","BKXPBMu","wKvIwKy","y05zD0e","uhjPBwfYEuS","D1zhy0S","mNWX","uNPSrwG","mdaWma","q3vZDg9Trxi","C0r4reK","sg9Qrwy","Cu9Ku2i","x3bYzwzPEa","Cu5HB2u","ExfREhC","Dhr3Awq","y29TCgXLDgu","ze9lwwu","v3vbvKW","uMrZBwO","wwPVzNu","sxbWDuy","vMrPu24","teH0zMG","BMvLEwu","Chv0","DwP1ANK","z3HdueG","t0fTsLu","qKDQtvC","zw5JB2rLrNi","DfHXv2u","tgDtuwy","qxnjDwy","x2LUAxrqCM8","zw5HyMXLvhi","zwvKzwq","s09grvO","zwj4wve","zvrOsxK","EujMDMe","B3jpBMXPBMu","u2TPCcbWyxm","zeXOzKq","D2LSBfjLy28","tfnwr20","zxj2AwnL","BezZCwm","zxjYtxnN","vMTxwxG","zgnRrfi","txvpugS","wNHkvhe","B25ozxr3B3i","qvriwuu","C2fNzq","x2nSzwfYugK","ywXSB2nvBNm","vKzpCNm","vK5SCgu","y29Uy2f0","u2HHCMvKv28","EgnZwfy"];return to=function(){return t},to()}var M=K;(function(t,e){let r=K,s=t();for(;;)try{if(parseInt(r(550))/1*(-parseInt(r(973))/2)+-parseInt(r(1281))/3+parseInt(r(1450))/4*(-parseInt(r(1919))/5)+parseInt(r(533))/6+parseInt(r(1064))/7*(-parseInt(r(899))/8)+parseInt(r(485))/9*(parseInt(r(678))/10)+-parseInt(r(1396))/11*(parseInt(r(1653))/12)===e)break;s.push(s.shift())}catch{s.push(s.shift())}})(to,117073);var ly=Object[M(1889)+M(1149)],uy=Object[M(1005)+M(1522)+M(1256)],au=(t,e)=>function(){return t&&(e=(0,t[{pSlql:function(c,f){return c(f)}}[M(1030)](uy,t)[0]])(t=0)),e},xy=(t,e)=>{let r=M,s={xkuWC:function(c,f,l,x){return c(f,l,x)}};for(var a in e)s[r(803)](ly,t,a,{get:e[a],enumerable:!0})};function hy(){return nu||(nu=[IDBDatabase,IDBObjectStore,IDBIndex,IDBCursor,IDBTransaction])}function py(){let t=M;return ru||(ru=[IDBCursor[t(1258)+"e"].advance,IDBCursor[t(1258)+"e"].continue,IDBCursor.prototype["continue"+t(1778)+"ey"]])}function K(t,e){t=t-448;let r=to(),s=r[t];if(K.ypDkYT===void 0){var a=function(x){let h="abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789+/=",m="",E="";for(let C=0,_,y,v=0;y=x.charAt(v++);~y&&(_=C%4?_*64+y:y,C++%4)?m+=String.fromCharCode(255&_>>(-2*C&6)):0)y=h.indexOf(y);for(let C=0,_=m.length;C<_;C++)E+="%"+("00"+m.charCodeAt(C).toString(16)).slice(-2);return decodeURIComponent(E)};K.vobqiw=a,K.yrNQuf={},K.ypDkYT=!0}let c=r[0],f=t+c,l=K.yrNQuf[f];return l?s=l:(s=K.vobqiw(s),K.yrNQuf[f]=s),s}function gy(t){let e=M,r={VNlpe:function(a,c){return a(c)},FShoG:e(1514),wKRDY:e(1147),WrzCG:function(a){return a()},QDFKB:function(a,c){return a===c},MIClO:e(1644),SUjEt:"qzWuq",OuGFY:function(a,c){return a instanceof c}},s=new Promise((a,c)=>{let f=e,l={WQSkp:r[f(1772)],ejcaO:r[f(1221)],EPCNi:function(x,h){return r[f(1834)](x,h)},adBkC:function(x){return r[f(1717)](x)}};if(r[f(913)](r[f(1894)],r.SUjEt))this[f(1425)]=!0,this[f(1627)]();else{let x=()=>{let E=f;t[E(644)+E(1338)+E(474)](E(1389),h),t[E(644)+E(1338)+E(474)](l[E(1620)],m)},h=()=>{let E=f;if(l[E(1166)]===l[E(1166)])l.EPCNi(a,Dt(t.result)),l.adBkC(x);else return _0x241b98||(_0x4852e9=[_0x28fce1.prototype.advance,_0x91417b.prototype[E(1469)],_0x38de3a[E(1258)+"e"][E(1469)+E(1778)+"ey"]])},m=()=>{let E=f;r.VNlpe(c,t[E(1514)]),x()};t[f(1672)+f(948)](f(1389),h),t["addEvent"+f(948)](r[f(1772)],m)}});return s[e(1711)](a=>{let c=e;r.OuGFY(a,IDBCursor)&&Ac[c(717)](a,t)})[e(1234)](()=>{}),ro.set(s,t),s}function my(t){let e=M,r={SWpwS:function(a,c){return a(c)},rOSjF:e(1183)+"or",AapFL:function(a){return a()},TcmbD:"complete",JbDDN:e(554)};if(no[e(541)](t))return;let s=new Promise((a,c)=>{let f=e,l={pkeWP:r[f(979)],mjrhd:r[f(1430)],HBKGB:function(E){return r[f(453)](E)}},x=()=>{let E=f;t[E(644)+E(1338)+E(474)](l[E(1677)],h),t["removeEv"+E(1338)+"ner"](E(1514),m),t[E(644)+"entListe"+E(474)](l.mjrhd,m)},h=()=>{a(),l.HBKGB(x)},m=()=>{let E=f;r[E(629)](c,t[E(1514)]||new DOMException(E(1183)+"or",r.rOSjF)),r[E(453)](x)};t[f(1672)+f(948)](f(1791),h),t[f(1672)+f(948)](f(1514),m),t[f(1672)+"Listener"]("abort",m)});no[e(717)](t,s)}function wy(t){io={mBCMS:function(r,s){return r(s)}}.mBCMS(t,io)}function _y(t){let e=M,r={gPSnQ:function(s,a){return s(a)},dMHAF:function(s,a){return s!==a},VFOrs:function(s,a){return s===a},CKjLW:function(s,a){return s>>>a},FmicW:function(s,a){return s>>>a},zGEdc:function(s,a){return s===a},lzzxg:function(s,a){return s(a)},YAfAl:function(s,a){return s(a)},afape:e(1214)+e(1680),qCzZH:e(743),ZVTkk:e(1245),DNkvW:function(s){return s()}};return t===IDBDatabase.prototype[e(1316)+e(1571)]&&!(r[e(1903)]in IDBTransaction[e(1258)+"e"])?r[e(1381)]!==r[e(643)]?function(s,...a){let c=e,f=t[c(783)](r[c(921)](Ei,this),s,...a);return Ic[c(717)](f,s[c(1512)]?s[c(1512)]():[s]),r[c(921)](Dt,f)}:(_0x142100[e(1274)](_0x4f24f2)||(_0x102a00=_0x1452ce[e(1939)+"er"](_0x4eb9c4)),r[e(1352)](this.unsigned,_0x206806[e(1187)])&&r[e(1833)](r[e(1911)](this[e(780)],31),1)&&r[e(1833)](r[e(1040)](_0x1b2362[e(780)],31),1)?!1:r[e(1833)](this[e(780)],_0x4202eb.high)&&r[e(850)](this.low,_0x20aa81.low)):r[e(1909)](py)[e(640)](t)?function(...s){let a=e;return t[a(590)](r[a(921)](Ei,this),s),r[a(921)](Dt,Ac[a(904)](this))}:function(...s){let a=e;return r[a(464)](Dt,t[a(590)](r[a(1264)](Ei,this),s))}}function yy(t){let e=M,r={FgWHX:function(s,a){return s===a},ysKgC:e(1333),ADNZo:function(s,a){return s instanceof a},GtiHk:function(s,a){return s(a)},FQBZv:function(s,a,c){return s(a,c)}};return r[e(991)](typeof t,r[e(1491)])?_y(t):(r.ADNZo(t,IDBTransaction)&&r[e(1315)](my,t),r.FQBZv(cu,t,hy())?new Proxy(t,io):t)}function Dt(t){let e=M,r={oKriN:function(a,c){return a instanceof c},TYlzm:function(a,c){return a(c)},NvXKz:function(a,c){return a!==c}};if(r[e(723)](t,IDBRequest))return r[e(1746)](gy,t);if(Qs[e(541)](t))return Qs.get(t);let s=yy(t);return r.NvXKz(s,t)&&(Qs[e(717)](t,s),ro[e(717)](s,t)),s}var cu,nu,ru,Ac,no,Ic,Qs,ro,io,Ei,iu=au({"node_modules/idb/build/wrap-idb-value.js"(){let t=M,e={jqWQI:function(r,s){return r||s},tBxxT:function(r,s){return r===s},SVipb:t(1441),BJKOF:function(r,s){return r instanceof s},xOmnN:t(1214)+t(1680),CwrkN:function(r,s){return r===s},CiYnO:"store",wlpzL:function(r,s){return r(s)},TjQyk:function(r,s){return r!==s},vLNKb:t(1517)};cu=(r,s)=>s[t(1656)](a=>r instanceof a),Ac=new WeakMap,no=new WeakMap,Ic=new WeakMap,Qs=new WeakMap,ro=new WeakMap,io={get(r,s,a){let c=t,f={lwnRg:function(l,x){return e[K(845)](l,x)}};if(e[c(875)]("moUQc",e.SVipb)){if(e.BJKOF(r,IDBTransaction)){if(e[c(875)](s,c(1103)))return no.get(r);if(s===e[c(1878)])return r[c(1214)+c(1680)]||Ic[c(904)](r);if(e[c(1935)](s,e[c(1159)]))return a[c(1214)+"oreNames"][1]?void 0:a["objectSt"+c(1735)](a[c(1214)+"oreNames"][0])}return e.wlpzL(Dt,r[s])}else{let l=this[c(802)].getItem(this[c(1787)]);return _0x3437a9[c(1313)](f[c(1708)](l,"{}"))[_0x3134d7]}},set(r,s,a){return r[s]=a,!0},has(r,s){let a=t;return e[a(1433)](a(1517),e[a(1228)])?this[a(1342)]?this[a(1342)][a(1188)]:this._url:e[a(1714)](r,IDBTransaction)&&(s===a(1103)||e.CwrkN(s,e[a(1159)]))?!0:s in r}},Ei=r=>ro[t(904)](r)}}),du={};xy(du,{deleteDB:()=>by,openDB:()=>Ey,unwrap:()=>Ei,wrap:()=>Dt});function Ey(t,e,{blocked:r,upgrade:s,blocking:a,terminated:c}={}){let f=M,l={rFwPi:function(m,E){return m!=E},iVHdO:f(1220),nIwkY:function(m,E){return m instanceof E},VfZZi:function(m,E){return m instanceof E},aDDkt:function(m,E,C,_,y){return m(E,C,_,y)},XYnMW:function(m,E){return m(E)},eQkMi:f(1668),ofzPz:f(1918)+"hange",TbGxJ:function(m,E){return m!==E},JLJFN:f(1215),wmioX:"upgraden"+f(1811)},x=indexedDB[f(503)](t,e),h=l[f(1443)](Dt,x);if(s){if(l.TbGxJ(l[f(1163)],l[f(1163)]))return l[f(1044)](l.iVHdO,typeof _0x1c5442)&&(l[f(1516)](_0x252908,_0x4a01e8)||_0x4a2247[f(1339)]&&l[f(1413)](_0x573647[f(1339)],_0x14ad0e))||l[f(1044)](l[f(1612)],typeof _0x567732)?"":(_0x353862[f(1313)](_0x237f95),"applicat"+f(844));x[f(1672)+f(948)](l.wmioX,m=>{let E=f;l.aDDkt(s,l[E(1443)](Dt,x[E(1337)]),m[E(1753)+"on"],m[E(860)+"on"],l[E(1443)](Dt,x["transact"+E(1571)]))})}return r&&x[f(1672)+"Listener"](f(919),()=>r()),h[f(1711)](m=>{let E=f;c&&m[E(1672)+E(948)](l[E(1285)],()=>c()),a&&m[E(1672)+E(948)](l[E(1503)],()=>a())}).catch(()=>{}),h}function by(t,{blocked:e}={}){let r=M,s={emheO:r(919)},a=indexedDB["deleteDa"+r(1414)](t);return e&&a.addEventListener(s[r(1720)],()=>e()),Dt(a)[r(1711)](()=>{})}function su(t,e){let r=M,s={pmDSo:r(1566),DuViE:r(1616)+"e",wRziq:r(693),CJdPb:function(x,h){return x instanceof h},Wdukp:function(x,h){return x in h},QcXoS:function(x,h){return x===h},qRQxS:function(x,h){return x!==h},bVpiV:"mAyAc"};if(!(s.CJdPb(t,IDBDatabase)&&!s[r(1731)](e,t)&&s.QcXoS(typeof e,r(1220))))return;if(eo.get(e))return eo.get(e);let a=e.replace(/FromIndex$/,""),c=s[r(982)](e,a),f=lu.includes(a);if(!(a in(c?IDBIndex:IDBObjectStore)[r(1258)+"e"])||!(f||fu[r(640)](a)))if(s.bVpiV!==r(1039))this[r(1342)]&&this[r(1342)][r(754)](_0x9ae654),this[r(662)](s.pmDSo,_0x391dfd);else return;let l=async function(x,...h){let m=r,E=this[m(1316)+m(1571)](x,f?s.DuViE:s[m(983)]),C=E[m(1299)];return c&&(C=C[m(1323)](h[m(1440)]())),(await Promise[m(467)]([C[a](...h),f&&E[m(1103)]]))[0]};return eo[r(717)](e,l),l}var fu,lu,eo,Sy=au({"node_modules/idb/build/index.js"(){let t=M,e={rTTNR:"getAll",UJwgX:t(1230)+"ys",jDtav:t(1150),lGuJW:function(a){return a()},SvSxX:t(1800),ahiyf:t(1547),VTpwn:t(774),qqijR:function(a,c){return a(c)}},r="4|1|0|2|5|3"[t(906)]("|"),s=0;for(;;){switch(r[s++]){case"0":fu=[t(904),t(1663),e[t(1107)],e[t(607)],e[t(1695)]];continue;case"1":e[t(752)](iu);continue;case"2":lu=[e[t(1180)],"add",e.ahiyf,e[t(1924)]];continue;case"3":e[t(1025)](wy,a=>({...a,get:(c,f,l)=>su(c,f)||a.get(c,f,l),has:(c,f)=>!!su(c,f)||a[t(541)](c,f)}));continue;case"4":e.lGuJW(iu);continue;case"5":eo=new Map;continue}break}}}),vy={idb:function(t){let e=M;t[e(995)]=Promise[e(1302)]()[e(1711)](()=>(Sy(),du))[e(1711)](function(r){return r})}},ou={};function Tt(t){let e=M,r={ODQHg:e(763)+"1"},s=r[e(708)][e(906)]("|"),a=0;for(;;){switch(s[a++]){case"0":var c=ou[t];continue;case"1":return f[e(995)];case"2":vy[t](f,f.exports,Tt);continue;case"3":var f=ou[t]={exports:{}};continue;case"4":if(c!==void 0)return c[e(995)];continue}break}}Tt.d=(t,e)=>{let r=K;for(var s in e)Tt.o(e,s)&&!Tt.o(t,s)&&Object["definePr"+r(1149)](t,s,{enumerable:!0,get:e[s]})},(()=>{let t=M;Tt.o=(e,r)=>Object.prototype["hasOwnPr"+t(1149)].call(e,r)})(),(()=>{let t=M,e={MMOoq:function(r,s){return r!=s},dtfYu:t(1623)+"d",SmBKm:t(700)+"le"};Tt.r=r=>{let s=t;e.MMOoq(e[s(1204)],typeof Symbol)&&Symbol[s(1861)+s(1437)]&&Object[s(1889)+s(1149)](r,Symbol[s(1861)+s(1437)],{value:s(1608)}),Object[s(1889)+s(1149)](r,e[s(1884)],{value:!0})}})();var Ee={};(()=>{let t=M,e={hkTNa:function(o,n){return o(n)},smLRr:function(o,n){return o+n},ShlkU:function(o,n){return o*n},Uavhe:function(o,n){return o===n},quZta:t(724),erpkz:t(1328),skQWf:function(o,n){return o(n)},rmuHB:function(o,n,i){return o(n,i)},uaNnI:t(797),Fwlrc:function(o,n){return o+n},dUsrq:t(1782),pESpz:"ffff",AkdRa:function(o,n){return o||n},CmPSs:t(1623)+"d",zrrjJ:function(o,n){return o===n},JhCHU:"eBFwt",VsnoM:t(1009)+t(1009)+t(1009)+t(1009),TUcsJ:function(o,n){return o||n},WiuIA:function(o,n){return o>=n},byGbK:function(o,n){return o===n},TCFDX:function(o,n){return o-n},YNDnR:function(o,n){return o>n},BzNZH:"hdgav",IXypm:function(o,n){return o<n},uQpim:function(o,n){return o!==n},hNHEc:t(1916),JnPeo:function(o,n){return o!==n},RlVVN:function(o,n){return o===n},oMFzb:function(o,n){return o-n},BcGCW:function(o,n){return o!==n},jeTju:function(o,n,i){return o(n,i)},ZOfxA:function(o,n){return o!==n},zegbS:function(o,n,i){return o(n,i)},VXxEs:function(o,n){return o(n)},YkycV:function(o,n,i){return o(n,i)},FAdFm:function(o,n,i){return o(n,i)},SOUCP:function(o,n){return o&n},gSuqJ:t(621)+t(1289)+t(1681)+t(1365),BIlBh:function(o){return o()},AwqHY:function(o,n){return o(n)},cJfNz:function(o,n){return o+n},tnJaV:t(1514),BBDwR:function(o,n,i){return o(n,i)},NLLNm:function(o,n,i){return o(n,i)},wdLko:function(o,n,i){return o(n,i)},OTjzV:function(o,n){return o!==n},otaVa:function(o,n,i){return o(n,i)},TcFJu:function(o,n,i){return o(n,i)},SjaBv:function(o,n){return o(n)},AXdQa:function(o,n,i){return o(n,i)},MMaKE:function(o,n,i){return o(n,i)},yUhlX:function(o,n){return o!==n},vwTeO:function(o,n,i){return o(n,i)},KjLhn:function(o,n){return o!==n},uZiOq:"laorI",qRlzG:function(o,n,i){return o(n,i)},wVGcK:function(o,n,i){return o(n,i)},awQBg:function(o,n){return o!==n},zJqLR:t(600),WBMjK:function(o,n,i){return o(n,i)},uRWVk:function(o,n,i){return o(n,i)},vNwib:function(o,n){return o(n)},AsIuf:t(1389),xAQDB:"ping_once_timeout",Yajdm:function(o,n,i){return o(n,i)},MNXrE:t(744)+t(807)+"s",xRlxu:function(o,n){return o(n)},aJItD:t(1405),VaNbu:function(o,n){return o>>>n},SUQiM:function(o,n,i){return o(n,i)},mtYfj:function(o,n){return o(n)},pgRAI:function(o,n){return o(n)},NDWHH:function(o,n){return o(n)},uuooM:function(o,n,i){return o(n,i)},xcsXV:function(o,n){return o(n)},suzPo:function(o,n,i){return o(n,i)},dYRDL:function(o,n,i){return o(n,i)},qNaoe:function(o,n){return o(n)},ZIvEp:t(621)+t(1289)+t(1681)+t(1294),DWtri:function(o,n,i){return o(n,i)},UXCOU:t(1742)+t(1340)+t(1344),ZxJTq:function(o,n){return o!==n},bACIr:t(1548),sFxNm:t(1156),fKkoE:function(o,n){return o>>n},LDVlr:function(o,n){return o>=n},aznYR:t(1052),VKDIK:"qpjDG",bkNkE:function(o,n){return o===n},ezlgA:t(1817)+t(989),Yjofu:function(o,n){return o+n},pltIX:function(o,n){return o>n},IztIf:t(1206)+t(989),vcpBm:function(o,n){return o*n},pwwZT:function(o,n){return o>n},ZkwXd:function(o,n,i){return o(n,i)},hdmpf:t(1179),CecHZ:function(o,n){return o===n},AvEGb:function(o,n){return o&n},mSrNP:function(o,n){return o(n)},RijoT:function(o,n){return o===n},bCVet:function(o,n){return o&n},deVYN:function(o,n){return o+n},QNfVW:function(o,n){return o+n},auUOr:function(o,n){return o|n},DkPYG:function(o,n){return o<<n},bSjpj:function(o,n){return o&n},guOPX:function(o,n){return o&n},WEmha:function(o,n){return o==n},TfYQG:function(o,n){return o+n},HIjWr:"owKFN",ZYfhy:function(o,n){return o+n},mtYpV:function(o,n){return o!==n},yMNrW:function(o,n){return o&n},XWdFQ:function(o,n){return o|n},sICRR:function(o,n){return o<<n},htKkv:function(o,n){return o|n},AoaMP:function(o,n){return o<<n},Zneap:function(o,n){return o<n},hgVHy:function(o,n){return o<=n},ApgsO:function(o,n){return o&n},BwCiL:function(o,n){return o+n},PAuYt:function(o,n){return o+n},PsGLr:function(o,n){return o+n},efHmP:function(o,n){return o+n},NfcRC:function(o,n){return o!==n},oChGp:function(o,n){return o&n},KBKzF:function(o,n){return o|n},xUeIv:function(o,n){return o<<n},CWNQc:function(o,n){return o|n},sDpcr:function(o,n){return o<<n},SCxNF:function(o,n){return o&n},kBUIc:function(o,n){return o<<n},LVDbE:function(o,n){return o&n},aROVO:function(o,n){return o&n},efDCY:function(o,n){return o>n},ENLwn:function(o,n,i){return o(n,i)},Xkzyj:function(o,n){return o>>n},KucUh:function(o,n){return o+n},OPYjt:function(o,n){return o&n},TULYr:function(o,n,i,d){return o(n,i,d)},qanqZ:function(o,n){return o<n},ZLuzd:function(o,n){return o>=n},yjwvP:function(o,n){return o<=n},sXoXn:function(o,n){return o<n},neeye:function(o,n){return o<<n},NLfnF:function(o,n){return o<n},ycNgR:function(o,n){return o<n},DznvY:function(o,n,i){return o(n,i)},jxcNa:function(o,n){return o+n},QPjPV:function(o,n){return o+n},WmoDp:function(o,n){return o<<n},nCMxE:function(o,n){return o<n},rYxbg:function(o,n){return o|n},dmtff:"wCwtq",eADSM:function(o,n){return o>>n},TEjwH:function(o,n){return o>>n},bjehN:function(o,n){return o&n},SKoYT:function(o,n){return o|n},SlMBx:function(o,n){return o>>n},EKXqg:function(o,n){return o&n},POjjV:function(o,n){return o(n)},iiOWt:function(o,n,i){return o(n,i)},IRDVb:"XxUOZ",YixmS:function(o,n,i){return o(n,i)},syAVu:"YLyfK",gFJaU:function(o,n){return o&n},gZDWL:function(o,n){return o<<n},eZLfp:function(o,n){return o&n},imfqC:function(o,n){return o&n},qOdSb:function(o,n){return o&n},AkzVC:function(o,n){return o&n},wJpex:function(o,n){return o|n},QehWH:function(o,n,i){return o(n,i)},WmJbU:function(o,n){return o(n)},yBfva:function(o,n){return o&n},XADTJ:function(o,n){return o<<n},KeAFt:function(o,n){return o<<n},JJKeN:function(o,n){return o&n},vMCxl:function(o,n){return o(n)},YyNeh:function(o,n){return o&n},aDSZS:"penMt",AZPlS:t(497),nHNMk:function(o,n){return o(n)},IFLpB:t(1380),dckDR:function(o,n){return o(n)},fOlhq:function(o,n){return o&n},zJxrW:function(o,n){return o&n},FULch:function(o,n){return o&n},XrqEp:function(o,n){return o&n},tOIxe:function(o,n){return o|n},wPdeI:function(o,n){return o<<n},FIbUX:function(o,n){return o>>>n},anrCB:function(o,n){return o<<n},GWRNl:function(o,n){return o<n},RGEnB:function(o,n){return o<n},cXqXv:function(o,n){return o<n},vMUqL:function(o,n){return o<n},zWhOu:function(o,n){return o&n},cgXjV:function(o,n){return o>>>n},iGxga:function(o,n){return o+n},wuacG:function(o,n){return o|n},TzdeU:function(o,n){return o>>>n},yPpoZ:function(o,n){return o>>>n},VVRPD:function(o,n){return o+n},QjHvT:function(o,n){return o!==n},MmwEH:function(o,n){return o&n},cVEBl:function(o,n){return o+n},JyDfz:function(o,n){return o!==n},plopD:function(o,n){return o&n},eeDOY:function(o,n){return o+n},aqJqI:function(o,n){return o!==n},doEkK:function(o,n){return o&n},RsmSv:function(o,n){return o>>>n},tSLhD:function(o,n){return o|n},GEFQX:function(o,n){return o>>>n},hwqXp:function(o,n){return o+n},VKoSm:function(o,n){return o!==n},JdZIh:function(o,n){return o(n)},OgkkH:function(o,n){return o|n},WuNBZ:function(o,n){return o|n},ATHYE:function(o,n){return o===n},YSHvc:function(o,n){return o<<n},uAEkJ:function(o,n){return o<<n},LFame:function(o,n){return o<<n},wtaJv:function(o,n){return o|n},YNQyA:function(o,n){return o|n},xZaKH:function(o,n){return o|n},wSvPs:function(o,n){return o<<n},BbVgM:function(o,n){return o<<n},VMnDO:function(o,n){return o|n},XDlMH:function(o,n){return o|n},KYGht:function(o,n){return o<<n},Tgtyq:t(1146),BWTxC:function(o,n){return o>>>n},gceZM:function(o,n){return o|n},CNKoZ:function(o,n){return o|n},BtKRu:function(o,n){return o>>>n},NcHyJ:function(o,n){return o|n},oPAja:function(o,n){return o|n},oGewt:function(o,n){return o&n},bTlAG:function(o,n){return o>>>n},UMKwd:function(o,n){return o&n},elCww:function(o,n){return o>>>n},OsVOc:function(o,n){return o>>>n},liQzW:function(o,n){return o>>>n},kbYHp:function(o,n){return o<=n},cjwUs:function(o,n){return o%n},AImWq:function(o,n){return o/n},KLwDj:function(o,n){return o>>>n},FrkFc:function(o,n){return o&n},SPtyT:function(o,n){return o>>>n},OfFRt:function(o,n){return o>>>n},PFQKh:function(o,n){return o+n},BHJPW:function(o,n){return o>>>n},blzbL:function(o,n){return o+n},BDNhA:function(o,n){return o|n},GDybi:function(o,n){return o!==n},HVofL:function(o,n){return o===n},wSSrW:function(o,n){return o>>>n},vEMSq:function(o,n){return o===n},NUTXs:function(o,n){return o&n},LcMIy:function(o,n){return o&n},IsRYQ:function(o,n){return o&n},Yoobm:function(o,n){return o>>>n},QqWEY:function(o,n){return o===n},TJkmw:t(548),NRKRO:"KfNCO",HMjPf:function(o,n){return o&n},ypvli:function(o,n){return o&n},VaGWe:function(o,n){return o>>>n},kehIG:function(o,n){return o&n},wfpvK:function(o,n){return o>>>n},BBWmx:"NATIVE_E"+t(796),NzwWb:t(941)+t(510),jOzKC:"MAX_RETR"+t(770)+"R",XWMli:t(1449)+t(1359),rXEiq:t(1521)+"OR",DbEVc:"0|2|5|3|"+t(961),BYcIc:function(o,n){return o<n},UPHSQ:function(o,n){return o<<n},irRsz:function(o,n){return o===n},ghrKJ:function(o,n){return o===n},NnNWi:t(990),Diofp:"opUYK",TipdN:function(o,n){return o+n},Uiyjn:function(o,n){return o(n)},VFitz:function(o,n,i){return o(n,i)},bIaJa:function(o,n){return o===n},qfMmd:"UoCmx",IUDLP:t(1609),AqMHG:"Kfmoj",Sgyhv:function(o,n){return o===n},xSDok:function(o,n){return o===n},CfStu:function(o,n){return o==n},pPvRf:function(o,n){return o===n},QUqnU:t(1309),nZaMl:function(o,n,i){return o(n,i)},oKkhW:function(o,n,i){return o(n,i)},iMiFT:function(o,n){return o!==n},LKTyT:t(1839),aARwL:function(o,n){return o===n},xzDnD:function(o,n){return o instanceof n},ZMwNk:function(o,n){return o+n},sDxDI:t(1940)+t(1483),mYOaH:function(o,n){return o+n},oWKrC:function(o,n){return o===n},CNSug:function(o,n){return o===n},cDAkc:function(o,n){return o<n},YUXTf:function(o,n){return o|n},LhiwI:t(1427)+t(786),vYyeo:function(o,n){return o&n},HQPuq:function(o,n){return o|n},MzRUL:function(o,n){return o>>n},kolUf:function(o,n){return o&n},xtAaD:function(o,n){return o+n},XEXkQ:function(o,n){return o+n},WFrpQ:function(o,n){return o>>n},KGoPl:function(o,n){return o|n},VUmqr:function(o,n){return o&n},FUlhU:function(o,n){return o|n},qHyqW:function(o,n){return o===n},zTgty:"vrdEK",ZYSij:t(482),soujM:"Qkmcz",Gdlro:t(1668),bInkK:function(o,n){return o(n)},VUQiO:t(503),OZkvX:function(o,n,i){return o(n,i)},MiaWD:function(o,n){return o!==n},LNkDB:"tiFaJ",tHZnk:function(o,n,i){return o(n,i)},fpoHN:function(o,n){return o+n},Egztg:function(o,n,i){return o(n,i)},ORYGy:t(963),GidnM:t(1845),hzicK:function(o,n){return o===n},NpAkL:t(1574),RBwqi:function(o,n){return o||n},IKITE:function(o,n){return o!=n},zqGkC:function(o,n){return o!=n},LyKtZ:"next() c"+t(618)+t(1639)+t(1232)+t(1751),oDYyR:function(o,n){return o(n)},BZeKj:function(o,n){return o<n},wyAmG:function(o,n){return o&n},LOSCC:function(o,n,i){return o(n,i)},YuoEP:function(o,n){return o===n},KUASB:"GVFjb",gDKQZ:function(o,n){return o-n},AmLUj:t(1141),DWWzl:t(1372),LMaZa:function(o,n){return o>=n},IgXFO:function(o,n){return o<<n},OGKQN:function(o,n){return o&n},rPLWY:function(o,n){return o<n},IQNtL:function(o,n){return o|n},jaFhx:function(o,n){return o<<n},ecBYE:function(o,n){return o&n},gbzHS:function(o,n){return o>=n},eoAkE:function(o,n){return o-n},UrYxO:function(o,n){return o<<n},Ilcwz:function(o,n){return o&n},gfLsu:function(o,n){return o<<n},haImq:function(o,n){return o<<n},Olwvw:function(o,n){return o&n},CICRs:function(o,n){return o>>n},lchJk:function(o,n){return o|n},ublln:function(o,n){return o|n},AoAJL:function(o,n){return o&n},HJAFy:function(o,n){return o+n},RXQjk:"4|5|3|0|"+t(1780),NyOzr:function(o,n){return o|n},ibRQh:function(o,n){return o&n},yzmpQ:function(o,n){return o>>n},wFOAQ:function(o,n){return o+n},PblAq:function(o,n){return o+n},jOqeG:function(o,n){return o&n},MceEm:function(o,n){return o|n},gqZBe:function(o,n){return o>>n},NxHNu:function(o,n){return o|n},XrFNJ:function(o,n){return o|n},tnmdO:t(1220),SLegw:function(o,n){return o(n)},IbrAK:function(o,n,i,d){return o(n,i,d)},tqJCR:function(o,n){return o instanceof n},iqvuA:function(o,n){return o instanceof n},PLBqh:t(1606)+"ion/json",VyQQS:"text/plain;chars"+t(1098),GmYzF:t(778),LDBTB:t(593),ljynI:t(625)+t(1045),hyaLD:"&jscallb"+t(1617)+"tierJSONP",ljgWa:function(o,n){return o!==n},RIvQq:t(1478),XWKoY:t(568),ojyDZ:t(455),pmHbj:function(o,n){return o+n},BliQE:"http",dzbNZ:function(o,n){return o(n)},aIORl:t(645)+t(1087),FcgAl:t(1275),XuliF:t(1203)+t(1748),PvoZv:function(o,n,i,d){return o(n,i,d)},uYSRU:t(1203)+"er_ack_m"+t(1444),IaNIo:function(o,n){return o!==n},JEZhi:t(1826),NoFYB:function(o,n){return o||n},wsbVH:t(1261),ozsdZ:function(o,n){return o||n},jOwdz:t(835),tSFPo:function(o,n){return o||n},FQGMi:function(o,n,i,d){return o(n,i,d)},oAhzY:t(1789),CBMnB:function(o,n){return o||n},Rdsmj:"pagehide",ddGcB:t(449),pYFVt:t(687),OHrDS:t(1865),lkuKv:function(o,n){return o||n},eWkvb:t(463),xqHAu:function(o,n){return o||n},CarfQ:function(o,n){return o||n},tXqWe:t(454)+t(1758)+"d",yLNCb:t(1251),fGbhf:t(787),kGgzd:function(o,n,i){return o(n,i)},ruBcE:t(1645),zEPaM:t(555)+"id",YMiJT:function(o,n,i){return o(n,i)},DWQhx:function(o,n){return o===n},dOKYe:t(1177),EWHiJ:function(o,n,i){return o(n,i)},YIoVz:function(o,n,i){return o(n,i)},XjFYM:t(1034),IGMhB:function(o,n){return o(n)},LbLsj:function(o,n,i,d){return o(n,i,d)},HeHVQ:t(1203)+"er_qos_ack",uTNdG:"x_fronti"+t(903)+"k",XNMTV:function(o,n,i){return o(n,i)},KoWbS:t(918),ehDEj:t(740),hUwjg:function(o,n,i,d){return o(n,i,d)},KsDXn:"is_ack",xJanY:function(o,n){return o&&n},WYtxM:"ack_code",NzvWa:function(o,n){return o(n)},SDFHF:function(o,n){return o<n},CYxhY:function(o,n){return o!==n},ULIcK:"EsYTj",aSHcQ:t(1131),xhfwD:t(742),aSEnh:function(o,n,i){return o(n,i)},nIVxv:t(758)+t(777),cZCqr:t(748),xMftM:function(o,n){return o(n)},ayAiS:function(o,n){return o(n)},iRcVr:function(o,n){return o===n},biwvC:t(581),onqGj:"aDWXj",fulnS:function(o,n){return o instanceof n},thmis:t(1606)+"ion/json"+t(1696)+t(1061),Ahpnl:t(1594)+"e",mSAum:t(613),IutBJ:function(o,n){return o<n},YFCom:function(o,n){return o>n},KWNDc:function(o,n){return o||n},JMMxw:function(o,n){return o>>>n},lRAbP:function(o,n){return o+n},KuOkR:function(o,n){return o+n},jmxrD:function(o,n){return o+n},ODNWf:t(761)+t(1886)+"ge: ",mubJy:t(1226),prMyg:t(1317)+t(1718)+"e",nflcG:function(o,n){return o>=n},PcgCc:function(o,n){return o&n},QuWOS:function(o,n){return o+n},CIUEe:"aVcUk",YTTiY:"aFrFf",wVLIT:function(o,n){return o<n},iyiCJ:function(o,n){return o>>>n},UwcTT:function(o,n){return o<<n},NHiHt:t(1175)+"4",vSapy:function(o,n){return o+n},ZEbZF:function(o,n,i,d){return o(n,i,d)},OCZaO:function(o,n,i,d){return o(n,i,d)},sALBB:function(o,n){return o|n},RzlEh:function(o,n){return o|n},kqtOa:function(o,n){return o<<n},cCYiP:function(o,n){return o<<n},CmZoE:function(o,n){return o+n},rxkPE:function(o,n){return o|n},KwBZE:function(o,n){return o<<n},RdPyJ:function(o,n){return o>>>n},MzQXf:function(o,n){return o&n},nngwV:function(o,n){return o+n},vnEUJ:function(o,n){return o>>>n},qmmNs:function(o,n){return o+n},IfQRw:function(o,n){return o&n},AxVky:function(o,n){return o&n},pDGCC:function(o,n){return o+n},HRUow:function(o,n){return o+n},fGJQM:function(o,n){return o===n},JcVDs:"uYkZH",mbpBb:function(o,n){return o<n},mNFUe:function(o,n){return o&n},JgSyZ:function(o,n){return o<<n},EOjiu:function(o,n){return o>>>n},RAUcc:function(o,n){return o(n)},CFYfm:"header",iCnEi:t(1683),nnLtw:function(o,n,i,d){return o(n,i,d)},rLDKE:t(781)+"ervice",iGKFv:function(o,n){return o(n)},ZhaRE:function(o,n,i,d){return o(n,i,d)},VQmvn:function(o,n){return o+n},HjKGl:function(o,n,i){return o(n,i)},vYfHF:t(837)+t(1864),GFgDZ:t(718)+"_EXIST",LgSQf:t(1582),hCFmb:t(1189),MXFxP:function(o,n){return o!==n},OWNTD:"wHNfk",rmAZk:"NamzD",mOGzf:t(1303)+t(1542),atVTf:t(701),svyMn:t(682),NtVIK:function(o,n,i,d){return o(n,i,d)},ZOqjj:function(o,n,i){return o(n,i)},BcXRc:function(o,n){return o<n},BBSXh:function(o,n){return o||n},VkWYx:t(623),xnFyK:"reconnect",WuAVL:"start",TOYuS:function(o,n,i,d){return o(n,i,d)},iqWeF:t(1203)+"er_msgid",slAdh:function(o,n){return o(n)},yKxWt:function(o,n,i){return o(n,i)},MDmpL:t(1203)+t(1489),KZToz:t(1255)+"s",PuhPn:t(884)+t(1006)+"e",tqGst:function(o,n){return o(n)},IetEJ:t(884)+t(1153)+"ue",Qwwjq:function(o,n){return o>n},LjmBS:t(1426),StxzM:t(747),SqOZY:function(o){return o()},BdokJ:t(1020),sWnhP:function(o){return o()},YVEYB:function(o){return o()},PPKkq:function(o){return o()},OVDIw:function(o){return o()},yVBYt:function(o){return o()},UTpCh:function(o,n){return o&&n},jlUFE:function(o){return o()},EGHqL:function(o,n,i){return o(n,i)},Arrti:function(o){return o()},XKunE:function(o,n){return o(n)},EIaXP:function(o,n){return o(n)},ejonp:function(o){return o()},wtunh:function(o,n){return o>=n},PTOzA:function(o,n){return o>=n},kVxlo:function(o,n){return o|n},OznTp:function(o,n){return o%n},ZMyNT:function(o,n){return o/n},OWbZK:function(o){return o()},aUMVE:function(o,n){return o<n},cNYwA:t(1164),ZhoiP:t(1272),tgEvw:function(o,n){return o===n},FVAxP:function(o,n){return o!==n},skozm:function(o,n){return o!==n},jpuxX:"Hmfig",kDzjB:t(1642),hGKbR:function(o,n){return o!==n},pTaYu:"HqGeJ",XPeRC:function(o,n,i){return o(n,i)},pwUfZ:function(o,n,i){return o(n,i)},IGTfn:t(1190),wijfm:function(o,n){return o(n)},tUvVj:function(o,n,i){return o(n,i)},fDcAx:function(o,n){return o!==n},GwIXF:t(1134),bKRCc:function(o,n,i,d){return o(n,i,d)},qOkFM:function(o,n,i){return o(n,i)},Ivdld:function(o,n){return o===n},RWgAa:"always",UUIhD:function(o,n,i,d){return o(n,i,d)},qDdjW:function(o,n){return o!==n},NiKdx:t(1001)+t(458),VpRvl:t(512),ccGtQ:t(1732)+"rovide v"+t(694),LrKoz:function(o,n){return o===n},WAYrz:t(1725),khEeF:t(1438)+t(1350)+t(851)+"ct",tMFnC:function(o,n){return o===n},vaNNM:function(o,n){return o===n},wNmQz:function(o,n,i){return o(n,i)},KRszb:t(462),fYsgG:"UnPQi",rvAcE:t(477),kiFUy:"offline",cUoDo:function(o,n){return o===n},BmKyD:t(1798),KCOOI:"WbXRK",kHkxK:function(o,n){return o!==n},sVVos:t(1060),QaviY:"wss://",JggXd:t(577),DgRxc:t(1790),bRGPX:t(1732)+t(1446)+"ddID, de"+t(866)+t(1709),kultL:function(o,n){return o==n},VuGGP:function(o,n,i){return o(n,i)},YxtWf:t(1913),WExvb:t(1121)+"0",hFQFz:"xlEnX",ujujy:function(o,n){return o===n},OCKFx:t(660)+">",UsKrk:function(o,n){return o-n},RRkOO:function(o,n){return o+n},EpdgW:function(o,n){return o(n)},YcjoY:function(o,n){return o!==n},VRsjd:t(523),yHtAK:t(749),jsQLi:function(o,n,i){return o(n,i)},KXulR:"timeout",ENQlf:function(o,n){return o>>n},muPXV:t(1508)+"ay, try reconnec"+t(1684)+t(456),jxHMv:t(1199)+t(1495)+"onnecting",WkGjA:function(o,n){return o||n},YeIcq:function(o,n){return o==n},ULaxj:function(o,n){return o!==n},DcCdL:t(815),ZROcW:t(1237),DmHcF:"send_ack",auixb:"1|0|2|4|3",tZJcJ:"message",qNrya:t(909)+"1",YbkNn:t(1278),Ywxxx:function(o,n){return o===n},nQjKx:function(o,n){return o===n},sPctz:t(1158),FnvNM:function(o,n){return o===n},bBxkV:t(1403),ACJzR:function(o,n,i){return o(n,i)},uYKUn:t(1508)+t(788)+t(753)+t(574),wRsPd:function(o,n){return o===n},OBJvL:t(1085),tftpo:function(o,n){return o+n},YtmBj:function(o,n){return o>>>n},kmxIt:function(o,n){return o>>>n},YnEQE:function(o,n){return o>>>n},gdGhG:function(o,n){return o&n},NvgkF:function(o,n){return o&n},fkxpP:function(o,n){return o>>>n},mZZcA:function(o,n){return o===n},YIuGw:t(1533),uMlAD:function(o,n){return o===n},hpgTD:function(o,n){return o===n},zpoaw:t(1330)+"s alread"+t(610),XabYa:t(1026),yTjqd:t(1363),byKYA:"please provide a"+t(1872)+t(1408)+t(1369)+t(779)+"ng or an"+t(1066)+t(1698),YsZNI:function(o,n){return o==n},ZfhMu:"number",tQzlE:function(o,n){return o!=n},MjFRK:function(o,n){return o instanceof n},Svpfh:function(o,n){return o instanceof n},wuPhM:function(o,n){return o||n},VeaQC:t(1732)+t(1846)+t(1432)+t(1821),akwdK:function(o,n){return o instanceof n},TCgZL:"enqueue",xhRWh:function(o,n){return o==n},WDHnX:"eRvtg",jnJtv:t(1550),YwvYf:function(o,n){return o+n},gWGzM:function(o,n){return o&n},WDHwu:function(o,n){return o+n},umxCw:function(o,n){return o>>>n},pTWxI:function(o,n){return o&n},aAemv:function(o,n){return o===n},iSSSI:t(720),LstTf:function(o,n){return o!==n},xmskF:t(696),eThIy:"\0\0\0\0\0\0\0\0",VJnJj:function(o,n){return o/n},ugOnK:function(o,n){return o===n},XJwSJ:t(946),oiYXR:function(o,n){return o!=n},HVGch:function(o,n){return o===n},AhJeF:function(o,n){return o!=n},PmahB:function(o,n){return o!=n},BIPud:"Object",qjIvq:function(o,n){return o===n},ImlZE:t(632)+t(987)+"lobalScope",ZUOmI:function(o,n){return o==n},KIZMt:function(o,n){return o!=n},noomL:t(1836)+t(689)+t(1208),GDNSV:function(o,n){return o!=n},aLngY:function(o,n){return o!=n}};Tt.r(Ee),Tt.d(Ee,{FWS:()=>Fh,CustomErrorEvent:()=>h0,createCloseEvent:()=>at,ReconnectEvent:()=>x0,createErrorEvent:()=>et,decodedFrame:()=>qn,createOpenEvent:()=>y0,CustomCloseEvent:()=>p0,createReconnectEvent:()=>Po,FrontierMessageEvent:()=>m0,encodeFrame:()=>Ke,createMessageEvent:()=>_0,OpenEvent:()=>w0,ErrorCode:()=>Wt,Event:()=>jn,MessageEvent:()=>g0});let r="";function s(o=""){let n=t,i="02",d=""+Date[n(993)](),u=r||(r=e[n(535)](x,o)),p=Math[n(1435)]()[n(1861)](16).slice(-6);return e[n(513)](e.smLRr(e[n(513)](i,d),u),p)}function a(){let o=t;return e[o(513)](e[o(1922)](1e4,Date[o(993)]()),Math[o(707)](e[o(1922)](1e4,Math[o(1435)]())))}function c(o){let n=t,i={MgmPj:"blocked"};if(e[n(1729)](e[n(1840)],e[n(1080)])){let d=_0x32b944["deleteDa"+n(1414)](_0x56e3e5);return _0x571e60&&d.addEventListener(xceowS.MgmPj,()=>_0x37952f()),_0x2cf25c(d)[n(1711)](()=>{})}else return e[n(513)](e[n(1688)](Array,8)[n(641)]("0"),e[n(1699)](parseInt,o,10)[n(1861)](2)).slice(-8)}function f(o){let n=t,i={eboXM:function(d,u,p){return e[K(1699)](d,u,p)}};if(e[n(1729)](e[n(771)],e.uaNnI))return e.Fwlrc(Array(4)[n(641)]("0"),parseInt(o,2).toString(16))[n(956)](-4);{let d=i[n(647)](_0x2f9e8a,"error",{message:_0x1c35b1.message,code:_0x4d91fa[n(1449)+n(1359)],error:_0x1c666b});this[n(1485)+n(1062)+"ent"](d)}}function l(o){let n=t,i=o[n(906)](/\./)[n(1676)](p=>c(p)),d=[];return d[0]=e[n(535)](f,i[0]+i[1]),d[1]=f(e[n(1130)](i[2],i[3])),[e[n(1543)],e[n(1543)],e[n(1543)],n(1782),e[n(1543)],e.pESpz,d[0],d[1]][n(641)]("")}function x(o){let n=t;if(e[n(764)](e[n(1018)],n(924))){let i=/(25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?)(\.(25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?)){3}/[n(471)](o),d=/(([0-9a-fA-F]{1,4}:){7,7}[0-9a-fA-F]{1,4}|([0-9a-fA-F]{1,4}:){1,7}:|([0-9a-fA-F]{1,4}:){1,6}:[0-9a-fA-F]{1,4}|([0-9a-fA-F]{1,4}:){1,5}(:[0-9a-fA-F]{1,4}){1,2}|([0-9a-fA-F]{1,4}:){1,4}(:[0-9a-fA-F]{1,4}){1,3}|([0-9a-fA-F]{1,4}:){1,3}(:[0-9a-fA-F]{1,4}){1,4}|([0-9a-fA-F]{1,4}:){1,2}(:[0-9a-fA-F]{1,4}){1,5}|[0-9a-fA-F]{1,4}:((:[0-9a-fA-F]{1,4}){1,6})|:((:[0-9a-fA-F]{1,4}){1,7}|:)|fe80:(:[0-9a-fA-F]{0,4}){0,4}%[0-9a-zA-Z]{1,}|::(ffff(:0{1,4}){0,1}:){0,1}((25[0-5]|(2[0-4]|1{0,1}[0-9]){0,1}[0-9])\.){3,3}(25[0-5]|(2[0-4]|1{0,1}[0-9]){0,1}[0-9])|([0-9a-fA-F]{1,4}:){1,4}:((25[0-5]|(2[0-4]|1{0,1}[0-9]){0,1}[0-9])\.){3,3}(25[0-5]|(2[0-4]|1{0,1}[0-9]){0,1}[0-9]))/[n(471)](o);return i?e[n(535)](l,o):d?h(o):e.VsnoM}else{if(_0xc18fde)return new _0x8dca22(_0xe5a02d[n(1188)],_0x350cec[n(1687)]);if(_0xc6b8f3||_0x179b7f)return new _0x4bd497(_0x3164e0[n(1188)],_0x5ee63d.protocol,_0xef69e5[n(966)]);if(e[n(1544)](_0x514764,_0x57779d)&&e[n(782)]!=typeof _0x257270&&_0x57292e)return new _0x1281b8(_0x50f8a7.url,_0x3829f9[n(1687)+"s"])}}function h(o){let n=t,i="",d=[],u=0,p=0,S=!0,b="0000";if(e.YNDnR(o[n(1168)]("::"),-1))if(e[n(1691)]!==e[n(1691)]){let g=this._qosDB[n(1033)+n(706)+"nc"](this[n(1787)]),T=_0x9c1555[n(1313)](e[n(481)](g,"{}"));return _0x33a02a[n(829)](T)}else{let g=o[n(906)]("::");for(let P=0;e[n(959)](P,g.length);P++){if(e[n(1008)](e[n(984)],e.hNHEc))return!!(e[n(619)](this[n(1713)+n(1280)],this.endpoints[n(1541)])||e[n(1634)](this[n(1713)+n(1280)],e[n(1707)](this[n(1737)+"s"][n(1541)],1))&&e[n(764)](this[n(1534)+n(804)+"riesCount"],this[n(1862)+"es"]));{let B=g[P];if(B.indexOf(":")>0){let j=B[n(906)](":");S&&(u=j[n(1541)]),p+=j.length;for(let V=0;V<j.length;V++)if(e[n(612)](4,j[V][n(1541)])){let J=b[n(1500)+"g"](0,e[n(1707)](4,j[V].length)),He=J[n(1835)](j[V]);d[n(1416)](He)}else d.push(j[V]);S=!1}else{if(e[n(1008)](4,B[n(1541)])){let j=b.substring(0,e[n(1707)](4,B[n(1541)])),V=j.concat(B);d[n(1416)](V)}else d[n(1416)](B);S&&(u+=1),p+=1,S=!1}}}let T="";for(let P=0;e.IXypm(P,e.TCFDX(8,p));P++)T=T[n(1835)](b);for(let P=0;P<d[n(1541)];P++)e[n(814)](P,u)&&(i=i[n(1835)](T)),i=i[n(1835)](d[P]);return i}{let g=o[n(906)](":");for(let T=0;e[n(959)](T,g.length);T++){let P=g[T];if(e[n(1008)](4,g[T][n(1541)])){let B=b.substring(0,e[n(1036)](4,g[T][n(1541)])),j=B[n(1835)](P);i=i[n(1835)](j)}else i=i.concat(P)}return i}}function m(o,n){let i=t,d=o[i(1324)];e[i(532)](void 0,d)&&(e.rmuHB(Y,n,10),e[i(848)](Le,n,d));let u=o.value;e[i(1090)](void 0,u)&&(e.zegbS(Y,n,18),e[i(1699)](Le,n,u))}function E(o){let n=t,i={};e:for(;!e[n(1283)](N,o);){let d=e[n(535)](_e,o);switch(d>>>3){case 0:break e;case 1:i[n(1324)]=e[n(1276)](we,o,_e(o));break;case 2:i.value=e[n(1056)](we,o,e[n(1688)](_e,o));break;default:e[n(848)](R,o,e.SOUCP(7,d))}}if(e[n(1634)](void 0,i[n(1324)]))throw new Error(n(621)+n(1289)+n(1681)+"key");if(e[n(764)](void 0,i[n(1365)]))throw new Error(e[n(1890)]);return i}function C(o){let n=t,i=e.BIlBh(A);return e.zegbS(_,o,i),e[n(1875)](z,i)}function _(o,n){let i=t,d={bdSPq:e.tnJaV,DmMmf:function($e,je,ct){return e[K(1056)]($e,je,ct)},DNAFI:function($e,je){return $e-je}},u=o[i(1439)];u!==void 0&&(e[i(525)](Y,n,8),e[i(1844)](ge,n,u));let p=o.LogID;e[i(1090)](void 0,p)&&(e.FAdFm(Y,n,16),e[i(1343)](ge,n,p));let S=o.service;S!==void 0&&(e[i(1343)](Y,n,24),ge(n,L(S)));let b=o.method;e[i(812)](void 0,b)&&(e[i(1880)](Y,n,32),e[i(1343)](ge,n,e[i(1283)](L,b)));let g=o[i(966)];if(g!==void 0)for(let $e of g){e.TcFJu(Y,n,42);let je=e[i(1171)](A);m($e,je),e[i(848)](Y,n,je[i(880)]),e[i(1844)](ot,n,je),e.SjaBv(k,je)}let T=o["payloadE"+i(483)];e.JnPeo(void 0,T)&&(e[i(611)](Y,n,50),e.jeTju(Le,n,T));let P=o[i(679)+i(1012)];e[i(612)](void 0,P)&&(Y(n,58),e[i(1842)](Le,n,P));let B=o[i(1539)];e[i(703)](void 0,B)&&(Y(n,66),e[i(1679)](Y,n,B.length),fe(n,B));let j=o[i(1460)];if(e[i(1327)](void 0,j))if(e[i(764)](i(637),e.uZiOq)){let $e=_0x54a457[i(1339)][i(956)](_0x5022a8[i(1014)+"et"],e[i(1710)](_0x1a71b3.byteLength,_0x3a6ce8.byteOffset));this[i(1114)]&&this[i(1114)][i(754)]({data:$e,fail:je=>{let ct=i;this[ct(1473)](d[ct(894)],d[ct(960)](_0x10dccc,d[ct(894)],{message:this["_formatE"+ct(1311)+ct(1053)](je)}))}})}else e[i(592)](Y,n,74),e[i(1844)](Le,n,j);let V=o["serverTi"+i(1358)];e.BcGCW(void 0,V)&&(Y(n,82),e[i(1779)](Le,n,V));let J=o[i(511)];J!==void 0&&(Y(n,90),e.jeTju(Le,n,J));let He=o[i(1773)+"e"];if(e[i(1402)](void 0,He))if(e[i(1174)]===i(600))e[i(1404)](Y,n,96),e[i(1700)](ge,n,e[i(1392)](L,He));else{let $e=_0x120859[i(1500)+"g"](0,ZsoUVf.DNAFI(4,_0x43e30.length)),je=$e[i(1835)](_0x31f209);_0x1328f4[i(1416)](je)}}function y(o){return e[t(1614)](v,e.hkTNa(F,o))}function v(o){let n=t,i={izMKL:function(d,u){return e[K(561)](d,u)},HojEf:"timeout",BcMDB:e.MNXrE,hVSWf:e.xAQDB};if(e[n(1729)](e[n(1382)],n(1405))){let d={};e:for(;!e[n(1283)](N,o);){let u=e[n(1688)](_e,o);switch(e[n(1341)](u,3)){case 0:break e;case 1:d[n(1439)]=Un(o,!0);break;case 2:d[n(1294)]=e.SUQiM(Un,o,!0);break;case 3:d[n(1318)]=e[n(651)](_e,o);break;case 4:d[n(1484)]=_e(o);break;case 5:{let p=e[n(1091)](I,o);(d[n(966)]||(d[n(966)]=[]))[n(1416)](e.NDWHH(E,o)),o[n(880)]=p;break}case 6:d[n(1094)+n(483)]=e[n(608)](we,o,e[n(1837)](_e,o));break;case 7:d[n(679)+n(1012)]=e[n(1466)](we,o,e[n(651)](_e,o));break;case 8:d.payload=e[n(934)](se,o,_e(o));break;case 9:d.LogIDNew=e[n(1531)](we,o,_e(o));break;case 10:d[n(680)+n(1358)]=e[n(1779)](we,o,e.vNwib(_e,o));break;case 11:d.msgID=we(o,e[n(561)](_e,o));break;case 12:d[n(1773)+"e"]=e[n(1788)](_e,o);break;default:e.AXdQa(R,o,e.SOUCP(7,u))}}if(e[n(1634)](void 0,d[n(1439)]))throw new Error(n(621)+n(1289)+n(1681)+n(1439));if(e.RlVVN(void 0,d[n(1294)]))throw new Error(e[n(1252)]);if(e[n(1729)](void 0,d[n(1318)]))throw new Error(n(621)+n(1289)+n(1681)+n(1318));if(e[n(764)](void 0,d[n(1484)]))throw new Error(n(621)+n(1289)+n(1681)+n(1484));return d}else{let d={oylnq:function(S,b){return S(b)},bdrjb:e[n(1808)],AgFVH:n(744)+n(807)+"s",flanu:e[n(473)]};this[n(1831)+n(1394)](),this[n(1597)+n(887)+"Id"]=e.Yajdm(_0x4d0754,this[n(669)][n(1277)](this),this[n(1578)][n(1353)+n(1314)]);let u=()=>{let S=n;d[S(1178)](_0x248951,d.bdrjb),this[S(811)](d[S(1613)],u),this[S(811)](d[S(1101)],p)},p=()=>{let S=n;i[S(1088)](_0x273ae8,i[S(1785)]),this[S(811)](i[S(1736)],u),this[S(811)](i.hVSWf,p)};this.on(e[n(1661)],u),this.on(e[n(473)],p),this[n(669)]()}}function I(o){let n=t,i=e.xRlxu(_e,o),d=o[n(880)];return o[n(880)]=e[n(513)](o[n(883)],i),d}function R(o,n){let i=t;switch(n){case 0:for(;e[i(1219)](128,Ae(o)););break;case 2:O(o,e[i(1392)](_e,o));break;case 5:e[i(1233)](O,o,4);break;case 1:e[i(848)](O,o,8);break;default:throw new Error(e[i(1530)]+n)}}function L(o){let n=t;return e[n(1827)](e[n(1624)],e[n(562)])?(o|=0,{low:o,high:e[n(502)](o,31),unsigned:e[n(1050)](o,0)}):this._ws?this[n(1342)][n(931)+"ns"]:""}let w=[];function A(){let o=t,n=w[o(1137)]();return n?(n[o(883)]=n[o(880)]=0,n):{bytes:new Uint8Array(64),offset:0,limit:0}}function k(o){w.push(o)}function F(o){let n=t;return e.byGbK(e[n(971)],e[n(1891)])?!!this[n(802)]:{bytes:o,offset:0,limit:o[n(1541)]}}function z(o){let n=t,i=o[n(1017)],d=o.limit;return e[n(1869)](i[n(1541)],d)?i:i.subarray(0,d)}function O(o,n){let i=t;if(e[i(1325)](o.offset+n,o[i(880)]))throw new Error(e.ezlgA);o.offset+=n}function N(o){let n=t;return e[n(619)](o[n(883)],o.limit)}function U(o,n){let i=t,d=o[i(1017)],u=o[i(883)],p=o[i(880)],S=e[i(1795)](u,n);if(e[i(1757)](S,d[i(1541)])){let b=new Uint8Array(e[i(1922)](2,S));b.set(d),o[i(1017)]=b}return o[i(883)]=S,e[i(1325)](S,p)&&(o[i(880)]=S),u}function W(o,n){let i=t,d=o[i(883)];if(e[i(1757)](e.cJfNz(d,n),o[i(880)]))throw new Error(e.IztIf);return o[i(883)]+=n,d}function se(o,n){let i=t,d=W(o,n);return o[i(1017)].subarray(d,e[i(1795)](d,n))}function fe(o,n){let i=t,d=e[i(934)](U,o,n[i(1541)]);o[i(1017)].set(n,d)}function we(o,n){let i=t,d={MHiei:function(T,P){return e[K(513)](T,P)},KccMI:function(T,P){return T>P},KOllS:function(T,P){return e[K(1335)](T,P)},fJlbs:function(T,P){return e[K(1096)](T,P)}},u=e[i(726)](W,o,n),p=String[i(821)+i(737)],S=o[i(1017)],b="\uFFFD",g="";for(let T=0;e[i(959)](T,n);T++)if(e[i(1402)](i(1179),e[i(810)])){let P=_0x5442c4[i(1017)],B=_0x3ed492[i(883)],j=_0x3e235e.limit,V=uPrErn[i(634)](B,_0x329d64);if(uPrErn[i(728)](V,P.length)){let J=new _0x5c59ea(uPrErn[i(1655)](2,V));J[i(717)](P),_0x45581b[i(1017)]=J}return _0x123f14[i(883)]=V,uPrErn.fJlbs(V,j)&&(_0x5ef2cf[i(880)]=V),B}else{let P=S[e.cJfNz(T,u)],B,j,V,J;e[i(697)](e[i(1721)](128,P),0)?g+=e[i(834)](p,P):e[i(1068)](e[i(721)](224,P),192)?e[i(526)](T,1)>=n?g+=b:(B=S[e[i(1035)](e[i(526)](T,u),1)],e[i(1721)](192,B)!==128?g+=b:(J=e[i(825)](e[i(686)](e.bSjpj(31,P),6),e[i(1436)](63,B)),e[i(959)](J,128)?g+=b:(g+=p(J),T++))):e.WEmha(e[i(1436)](240,P),224)?e.LDVlr(e[i(1874)](T,2),n)?g+=b:i(1054)===e[i(459)]?(B=S[e[i(1795)](T,u)+1],j=S[e[i(1035)](e[i(698)](T,u),2)],e[i(791)](e[i(1490)](e[i(1540)](B,e[i(1747)](j,8)),49344),32896)?g+=b:(J=e.XWdFQ(e[i(1755)](e[i(1747)](15&P,12),e[i(1236)](63&B,6)),e[i(1219)](63,j)),e[i(499)](J,2048)||e[i(619)](J,55296)&&e.hgVHy(J,57343)?g+=b:(g+=p(J),T+=2))):this["currentE"+i(804)+"riesCount"]=0:e[i(1858)](e[i(1631)](248,P),240)?e[i(1050)](e[i(1710)](T,3),n)?g+=b:(B=S[e[i(998)](e[i(998)](T,u),1)],j=S[e[i(1499)](T,u)+2],V=S[e.PsGLr(e[i(1127)](T,u),3)],e[i(657)](e[i(1898)](e[i(1376)](B,e.xUeIv(j,8))|V<<16,12632256),8421504)?g+=b:(J=e[i(825)](e[i(589)](e.sDpcr(e[i(1726)](7,P),18),e[i(1622)](e[i(1093)](63,B),12)),e[i(686)](e[i(1144)](63,j),6))|63&V,J<65536||e.efDCY(J,1114111)?g+=b:(J-=65536,g+=e[i(1429)](p,e[i(1520)](J,10)+55296,e.KucUh(e[i(1701)](1023,J),56320)),T+=3))):g+=b}return g}function Le(o,n){let i=t,d={EOuef:function(g,T,P,B){return e[K(847)](g,T,P,B)},dLhfD:function(g,T,P){return e[K(1276)](g,T,P)},uDtdf:e[i(1059)]},u=n[i(1541)],p=0;for(let g=0;e[i(1673)](g,u);g++){let T=n[i(965)+"At"](g);e[i(765)](T,55296)&&e[i(1110)](T,56319)&&e[i(1678)](g+1,u)&&(T=e[i(1499)](e[i(1799)](T,10),n[i(965)+"At"](++g))-56613888),p+=e.NLfnF(T,128)?1:e[i(499)](T,2048)?2:e.ycNgR(T,65536)?3:4}Y(o,p);let S=e[i(1568)](U,o,p),b=o.bytes;for(let g=0;e.sXoXn(g,u);g++){let T=n.charCodeAt(g);if(e[i(619)](T,55296)&&e.yjwvP(T,56319)&&e[i(1673)](e[i(1719)](g,1),u)&&(T=e[i(1598)](e.WmoDp(T,10),n[i(965)+"At"](++g))-56613888),e.IXypm(T,128))b[S++]=T;else{if(e[i(584)](T,2048))b[S++]=e.rYxbg(e[i(1436)](e[i(1520)](T,6),31),192);else if(e[i(1008)](e.dmtff,e.dmtff))try{d[i(1855)](_0xf21916,this,_0x25b3b3,[_0x554eb3,_0xc9388c,_0x244c2e])}catch(P){let B=d[i(1818)](_0x1458fa,d[i(1051)],{message:P[i(1727)],code:_0x15ec3b.OPEN_ERROR,error:P});this[i(1485)+i(1062)+i(1464)](B)}else e.NLfnF(T,65536)?b[S++]=e.XWdFQ(e[i(1685)](T,12)&15,224):(b[S++]=e[i(1376)](e[i(1452)](T,18)&7,240),b[S++]=e.auUOr(e.bjehN(T>>12,63),128)),b[S++]=e[i(1118)](e[i(1410)](e[i(558)](T,6),63),128);b[S++]=e[i(614)](63,T)|128}}}function ot(o,n){let i=t,d=e[i(848)](U,o,n[i(880)]),u=o.bytes,p=n[i(1017)];for(let S=0,b=n.limit;e[i(1678)](S,b);S++)u[e[i(1035)](S,d)]=p[S]}function Ae(o){return o[t(1017)][e.MMaKE(W,o,1)]}function Gt(o,n){let i=t,d={FUsNM:function(u,p){return u===p},TJndd:i(1333),xEGsn:function(u,p){return u(p)},BGtUN:function(u,p){return e[i(1573)](u,p)},uWtnJ:function(u,p,S){return e[i(583)](u,p,S)},LdSmG:function(u){return u()}};if(e.awQBg(e[i(1360)],e.IRDVb))return ECijnD[i(1024)](typeof _0x16c1ad,ECijnD.TJndd)?ECijnD[i(498)](_0x43333c,_0x2f1029):(_0x42b90c instanceof _0x5e8c06&&ECijnD[i(1583)](_0x2b03b7,_0x5b6e15),ECijnD[i(1143)](_0x58df4f,_0x4a7af6,ECijnD[i(1883)](_0x5ec025))?new _0x5e5d87(_0x230036,_0x179208):_0x281d2a);{let u=e.YixmS(U,o,1);o.bytes[u]=n}}function _e(o){let n=t,i=0,d=0,u;do if(e[n(814)](n(1108),e.syAVu))u=e.xRlxu(Ae,o),e.nCMxE(i,32)&&(d|=e[n(1747)](e[n(947)](127,u),i)),i+=7;else return this[n(802)]?.[n(1099)];while(e[n(1721)](128,u));return d}function Y(o,n){let i=t;if(e[i(1729)](i(1813),"HWWLh")){let d=e[i(1707)](e[i(1755)](e.gZDWL(e[i(1113)](7,_0x2b1f95),18)|e.WmoDp(e[i(1113)](63,_0x5b941d[_0x513917++]),12),e.imfqC(63,_0x27e7ce[_0x3c7e1a++])<<6)|e[i(1786)](63,_0x1d13ec[_0x1757d4++]),65536);_0x3c2731+=_0x22cbd0["fromChar"+i(737)](e[i(671)](55296,e[i(1452)](d,10))),_0x274b9f+=_0x3b6104["fromChar"+i(737)](e[i(526)](56320,e[i(792)](1023,d)))}else{for(n>>>=0;n>=128;)Gt(o,e.wJpex(127&n,128)),n>>>=7;e.QehWH(Gt,o,n)}}function Un(o,n){let i=t,d={PCALI:function(g,T){return e.hkTNa(g,T)}},u=0,p=0,S=0,b;return b=e.WmJbU(Ae,o),u=e.SOUCP(127,b),e[i(1815)](128,b)&&(b=e[i(1091)](Ae,o),u|=e[i(1229)](127&b,7),e[i(1734)](128,b)&&(b=Ae(o),u|=e.KeAFt(127&b,14),e.JJKeN(128,b)&&(b=e[i(547)](Ae,o),u|=e.YyNeh(127,b)<<21,e.AvEGb(128,b)&&(e.aDSZS!==e[i(1572)]?(b=e[i(900)](Ae,o),p=e.AkzVC(127,b),128&b&&(e[i(764)](e[i(1423)],e[i(1423)])?(b=e[i(1825)](Ae,o),p|=e[i(977)](127,b)<<7,e.zJxrW(128,b)&&(b=Ae(o),p|=e[i(1185)](127,b)<<14,e[i(540)](128,b)&&(b=e[i(561)](Ae,o),p|=e[i(686)](127&b,21),128&b&&(b=Ae(o),S=e.SOUCP(127,b),e[i(614)](128,b)&&(b=e[i(1366)](Ae,o),S|=e[i(1786)](127,b)<<7))))):(this[i(936)+i(1567)]=_0x47a13f,this[i(1150)]=0))):_0x36868b(_0xd2cd5(_0xb3350b[i(1337)]),_0x42e88f[i(1753)+"on"],_0xf1a10d.newVersion,vsjSLt[i(940)](_0x39bf29,_0x35c9c1[i(1316)+i(1571)])))))),{low:e.tOIxe(u,e[i(1926)](p,28)),high:e[i(589)](p>>>4,e[i(1167)](S,24)),unsigned:n}}function ge(o,n){let i=t,d=e[i(1341)](n.low,0),u=e[i(1660)](e[i(1376)](n.low>>>28,e[i(857)](n.high,4)),0),p=n[i(780)]>>>24,S=e.CecHZ(0,p)?u===0?e[i(959)](d,16384)?e[i(1319)](d,128)?1:2:e[i(1003)](d,2097152)?3:4:u<16384?e[i(584)](u,128)?5:6:e[i(1198)](u,2097152)?7:8:e[i(1766)](p,128)?9:10,b=U(o,S),g=o[i(1017)];switch(S){case 10:g[e[i(671)](b,9)]=e.zWhOu(e[i(476)](p,7),1);case 9:g[e[i(1537)](b,8)]=e[i(1008)](9,S)?e[i(1604)](128,p):127&p;case 8:g[e.QPjPV(b,7)]=S!==8?e[i(1540)](e[i(466)](u,21),128):e[i(614)](e[i(1686)](u,21),127);case 7:g[e[i(1138)](b,6)]=e[i(1069)](7,S)?e.VaNbu(u,14)|128:e[i(1013)](e.VaNbu(u,14),127);case 6:g[e[i(813)](b,5)]=e.QjHvT(6,S)?e.wJpex(e[i(1341)](u,7),128):e[i(1410)](u>>>7,127);case 5:g[e.cVEBl(b,4)]=e.JyDfz(5,S)?128|u:e[i(916)](127,u);case 4:g[e[i(1715)](b,3)]=e[i(1270)](4,S)?e[i(1540)](e[i(476)](d,21),128):e[i(1477)](e.RsmSv(d,21),127);case 3:g[e[i(1537)](b,2)]=S!==3?e[i(1581)](e[i(852)](d,14),128):e[i(1219)](d>>>14,127);case 2:g[e.hwqXp(b,1)]=S!==2?e[i(1581)](e[i(1341)](d,7),128):e[i(1898)](e[i(466)](d,7),127);case 1:g[b]=e[i(751)](1,S)?e[i(1755)](128,d):e[i(1477)](127,d)}}function qn(o){return e.xcsXV(y,o)}function Ke(o){return e[t(729)](C,o)}let d0=65536,Zx=e[t(1814)],Hn=e[t(1335)](d0,d0),f0=Hn*Hn,l0=e[t(1202)](f0,2),Kt=String.prototype[t(965)+"At"];class oe{constructor(n,i,d){let u=t;this[u(1274)]=!0,this[u(1724)]=e[u(1326)](0,n),this[u(780)]=e.WuNBZ(0,i),this[u(1187)]=!!d}static[t(1274)](n){return n&&e.ATHYE(!0,n.isLong)}static[t(656)](n,i,d){return new oe(n,i,d)}static fromBytes(n,i,d){let u=t;return d?oe[u(910)+u(1119)](n,i):oe[u(910)+u(1879)](n,i)}static[t(910)+t(1119)](n,i){let d=t;return new oe(e[d(521)](e[d(981)](n[0],e[d(683)](n[1],8))|e[d(1637)](n[2],16),e[d(665)](n[3],24)),n[4]|e.LFame(n[5],8)|e[d(1229)](n[6],16)|e[d(857)](n[7],24),i)}static[t(910)+"sBE"](n,i){let d=t;return new oe(e[d(551)](e.YNQyA(e[d(951)](e.wSvPs(n[4],24),n[5]<<16),e.BbVgM(n[6],8)),n[7]),e[d(1595)](e.XDlMH(e[d(1540)](n[0]<<24,n[1]<<16),e.KYGht(n[2],8)),n[3]),i)}static[t(1895)](n){let i=t;return e[i(791)]("BbzNl",e[i(1246)])?e[i(1729)](n,Zx)?u0:new oe(e[i(648)](e[i(1581)](e[i(915)](e.CNKoZ(Kt[i(783)](n,0),Kt.call(n,1)<<8),e[i(665)](Kt[i(783)](n,2),16)),e[i(1658)](Kt[i(783)](n,3),24)),0),e[i(1139)](e[i(1470)](e[i(491)](Kt[i(783)](n,4),Kt[i(783)](n,5)<<8)|e[i(1236)](Kt[i(783)](n,6),16),e.KYGht(Kt[i(783)](n,7),24)),0),!0):new _0x206070(d=>{let u=i;_0x3cd1de(d,this["_getInte"+u(1351)+"e"](_0x2f4a28))})}[t(1654)](){let n=t;return String["fromChar"+n(737)](e.LVDbE(255,this[n(1724)]),e[n(1093)](e[n(1341)](this[n(1724)],8),255),e[n(670)](e.bTlAG(this[n(1724)],16),255),e.cgXjV(this[n(1724)],24),e[n(1434)](255,this.high),e[n(1154)](e[n(1920)](this[n(780)],8),255),e[n(1093)](e[n(690)](this[n(780)],16),255),e.liQzW(this[n(780)],24))}static[t(1939)+"er"](n,i=!0){let d=t;if(e[d(561)](isNaN,n))return i?Yx:u0;if(i){if(e[d(619)](n,f0))return Qx}else{if(e[d(1448)](n,-l0))return eh;if(e.efHmP(n,1)>=l0)return Xx}return oe[d(656)](e[d(1470)](e[d(762)](n,Hn),0),e[d(878)](e.AImWq(n,Hn),0),i)}toNumber(){let n=t;return this[n(1187)]?e.PsGLr(e[n(1922)](e[n(451)](this.high,0),Hn),this.low>>>0):e[n(1795)](e[n(1335)](this.high,Hn),e[n(712)](this[n(1724)],0))}isZero(){let n=t;return this[n(780)]===0&&this[n(1724)]===0}[t(1016)](n){let i=t;oe.isLong(n)||(n=oe.fromNumber(n));let d=e[i(1854)](this.high,16),u=65535&this.high,p=e.BWTxC(this[i(1724)],16),S=e[i(721)](65535,this.low),b=n.high>>>16,g=e[i(997)](65535,n[i(780)]),T=e[i(1625)](n[i(1724)],16),P=65535&n[i(1724)],B=0,j=0,V=0,J=0;return J+=S+P,V+=J>>>16,J&=65535,V+=e[i(1598)](p,T),j+=e.OfFRt(V,16),V&=65535,j+=e.PFQKh(u,g),B+=e[i(1240)](j,16),j&=65535,B+=e[i(715)](d,b),B&=65535,oe.fromBits(e[i(1172)](e[i(686)](V,16),J),e[i(805)](e.wPdeI(B,16),j),this[i(1187)])}equals(n){let i=t;return oe[i(1274)](n)||(n=oe.fromNumber(n)),e[i(585)](this.unsigned,n[i(1187)])&&e[i(1391)](e[i(852)](this[i(780)],31),1)&&e[i(814)](e[i(1741)](n[i(780)],31),1)?!1:this.high===n.high&&this[i(1724)]===n.low}[t(1249)](){let n=t;return this[n(1724)]===-1&&e[n(1869)](-1,this[n(780)])?oe[n(656)](0,0,this.unsigned):e[n(838)](-1,this[n(1724)])?oe[n(656)](0,this[n(780)]+1,this.unsigned):oe.fromBits(e[n(1710)](this[n(1724)],1),this[n(780)],this[n(1187)])}[t(685)](n){let i=t;return n?this[i(1217)+"E"]():this[i(1417)+"E"]()}[t(1217)+"E"](){let n=t,i=this[n(780)],d=this[n(1724)];return[e.NUTXs(255,d),e[n(1322)](e[n(451)](d,8),255),e[n(977)](e.BtKRu(d,16),255),e[n(466)](d,24),e[n(926)](255,i),e[n(1240)](i,8)&255,e.Yoobm(i,16)&255,e[n(1625)](i,24)]}toBytesBE(){let n=t;if(e[n(1838)](e[n(1563)],e[n(816)]))this._listeners={};else{let i=this[n(780)],d=this.low;return[e[n(1920)](i,24),e.HMjPf(e[n(712)](i,16),255),e[n(1480)](i>>>8,255),e[n(947)](255,i),e[n(1625)](d,24),e[n(1266)](d,16)&255,e[n(470)](e[n(668)](d,8),255),e[n(1185)](255,d)]}}}let u0=new oe(0,0,!1),Yx=new oe(0,0,!0),Xx=oe[t(656)](-1,2147483647,!1),Qx=oe[t(656)](-1,-1,!0),eh=oe.fromBits(0,-2147483648,!1);var Wt=(function(o){let n=t;return o[o[e[n(461)]]=5001]=e[n(461)],o[o[e[n(914)]]=5002]=e[n(914)],o[o[e[n(1892)]]=5003]=e[n(1892)],o[o["MESSAGE_"+n(1359)]=5004]=e[n(1126)],o[o[e[n(652)]]=5005]="OPEN_ERROR",o})({});class jn{constructor(n){this.type=n,this.target=null}}class x0 extends jn{constructor(n,i){let d=t;super(n),this[d(1727)]=i&&i.message||null}}class h0 extends jn{constructor(n,i){let d=t,u=e.DbEVc[d(906)]("|"),p=0;for(;;){switch(u[p++]){case"0":super(n);continue;case"1":this[d(1486)]=i&&i[d(1486)]||0;continue;case"2":this[d(1514)]=i&&i[d(1514)]||null;continue;case"3":this[d(1682)]=i&&i.filename||"";continue;case"4":this[d(898)]=i&&i[d(898)]||5001;continue;case"5":this[d(935)]=i&&i[d(935)]||0;continue;case"6":this[d(1727)]=i&&i[d(1727)]||"";continue}break}}}class p0 extends jn{constructor(n,i){let d=t;super(n),this[d(898)]=i&&i[d(898)]||0,this[d(1087)]=i&&i[d(1087)]||"",this[d(556)]=i&&i[d(556)]||!1,this[d(1819)+d(1706)]=i&&i["willReco"+d(1706)]||!1}}class g0 extends jn{constructor(n,i){let d=t;super(n),this[d(1387)]=i&&i[d(1387)]||null}}class m0 extends g0{constructor(n,i){let d=t;super(n),this[d(1387)]=i&&i.data||null,this[d(1727)]=i&&i[d(1727)]||null}}class w0 extends jn{constructor(n,i){let d=t;super(n),this[d(1387)]=i&&i.data||null}}function et(o,{message:n,code:i,error:d}){return new h0(o,{message:n,code:i,error:d})}function at(o,{code:n,reason:i,wasClean:d,willReconnect:u}){return new p0(o,{code:n,reason:i,wasClean:d,willReconnect:u})}function _0(o,{data:n,message:i}){let d=t,u={vknLa:function(p,S){return e[K(1123)](p,S)},FgUuR:function(p,S){return e[K(958)](p,S)},nxVyA:function(p,S){return p+S},vGaTl:function(p,S){return p-S},qBVSp:function(p,S){return e[K(1331)](p,S)}};if(e[d(1901)]("NCWJn",d(1929)))return new m0(o,{data:n,message:i});{let p=_0x3717f3[d(965)+"At"](_0x43a373);p>=55296&&BTkDKA[d(1362)](p,56319)&&BTkDKA[d(1510)](BTkDKA[d(1513)](_0x4c31f,1),_0x564409)&&(p=BTkDKA[d(633)](BTkDKA[d(1513)](BTkDKA[d(817)](p,10),_0x68f0da[d(965)+"At"](++_0x4672d6)),56613888)),_0x4f1dac+=p<128?1:BTkDKA[d(1510)](p,2048)?2:p<65536?3:4}}function y0(o,{data:n}){return new w0(o,{data:n})}function Po(o,{message:n}){return new x0(o,{message:n})}class E0{constructor(n,i){let d=t;this[d(1737)+"s"]=n,this[d(1862)+"es"]=i,this[d(1713)+d(1280)]=0,this[d(1534)+"ndpointT"+d(450)+"t"]=0}[t(1216)+"pointConfig"](){let n=t;this[n(1713)+"ndex"]=0,this[n(1534)+n(804)+n(450)+"t"]=0}[t(1665)+"es"](){let n=t;if(e[n(1304)](e[n(1310)],e[n(853)])){if(this[n(1578)]["disableA"+n(1197)+n(776)]||this[n(1523)+n(756)])return;this[n(890)+n(741)]()}else this["currentE"+n(804)+n(450)+"t"]=0}["getCurre"+t(508)+"nt"](){let n=t,i={qRmEt:function(d,u){return e[K(1348)](d,u)},SgTsg:function(d,u){return e.Uiyjn(d,u)},AqARN:function(d,u,p){return e.VFitz(d,u,p)}};return e[n(604)](e.qfMmd,e[n(628)])?LoPBWP[n(599)](LoPBWP[n(543)](_0x63bb13,8).join("0"),LoPBWP.AqARN(_0x30c8c8,_0x3f3f59,10)[n(1861)](2))[n(956)](-8):this[n(1737)+"s"][this["currentI"+n(1280)]]}[t(596)+t(508)+t(553)+t(1567)](){let n=t,i={lACxz:n(1668)};if(e[n(571)]!==n(1225))return this[n(1534)+n(804)+"riesCount"];if(this[n(1750)+n(1357)]?.[n(1647)+n(1558)+"es"]()){let u=this["_endpoin"+n(1357)]?.["getCurre"+n(508)+"nt"]();this[n(1485)+"hCloseEv"+n(1464)](_0x41f3ab("close",{code:1006,reason:n(836)+u+(" timeout"+n(892)+n(1022)+n(653)),wasClean:!0}))}else{let u=this[n(1578)][n(939)+n(579)+n(710)](_0x20e5f7,_0x15ccb0);this[n(1485)+n(1031)+n(1464)](_0x7b04ef(i[n(1262)],{code:_0x48aeec,reason:_0x35a4e4,wasClean:!0,willReconnect:u})),u&&this[n(1627)]()}}[t(1647)+"chMaxTries"](){let n=t;return!!(this["currentI"+n(1280)]>=this[n(1737)+"s"][n(1541)]||e[n(739)](this["currentI"+n(1280)],e[n(1707)](this[n(1737)+"s"][n(1541)],1))&&e[n(1386)](this["currentE"+n(804)+n(450)+"t"],this[n(1862)+"es"]))}[t(537)+t(1293)+t(626)+t(704)+"tries"](){let n=t;return e.CfStu(this[n(1713)+n(1280)],this[n(1737)+"s"][n(1541)])?!0:e[n(1096)](this[n(1534)+n(804)+"riesCount"],this[n(1862)+"es"])}["replaceB"+t(1227)+"pointAnd"+t(516)+t(504)](){let n=t;return this[n(1534)+n(804)+n(450)+"t"]=1,this[n(1713)+n(1280)]++,this[n(1737)+"s"][this.currentIndex]}[t(596)+t(508)+t(1657)+t(1848)](){let n=t;if(e[n(1223)](e[n(992)],e[n(992)]))return this[n(1534)+n(804)+n(450)+"t"]++,this[n(596)+n(508)+"nt"]();this["_miniNav"+n(1456)+n(1761)]=_0x5f3413,_0x3eaa0b?this["_handleO"+n(1775)]():this[n(798)+n(730)]()}}let Gn=(e[t(1160)](e[t(782)],typeof globalThis)&&e[t(1125)](e.XJwSJ,globalThis[t(557)+t(1371)][t(1074)])||e[t(1004)](e[t(782)],typeof window)&&e[t(636)](t(946),window[t(557)+t(1371)][t(1074)]))&&e[t(1917)](e.CmPSs,typeof document),_n=e[t(1529)](e.CmPSs,typeof globalThis)&&(e[t(1577)]===globalThis[t(557)+t(1371)][t(1074)]||e[t(925)](e[t(1670)],globalThis[t(557)+t(1371)][t(1074)]))&&e[t(1576)](e[t(782)],typeof tt),kr=(t(1623)+"d"!=typeof globalThis&&e[t(1577)]===globalThis[t(557)+t(1371)][t(1074)]||e.ZUOmI(e[t(782)],typeof globalThis)||e.KIZMt(e[t(782)],typeof globalThis)&&!!globalThis["WeixinJS"+t(1692)])&&e[t(1004)](e[t(782)],typeof wx),Or=typeof globalThis<"u"&&(e.ImlZE===globalThis["construc"+t(1371)][t(1074)]||e[t(702)]===globalThis[t(557)+"tor"][t(1074)]||e[t(1671)](t(1482)+t(1841)+t(565),globalThis[t(557)+"tor"][t(1074)]))&&e[t(1931)](e[t(782)],typeof self),th=e[t(782)]!=typeof globalThis&&e[t(1386)](e[t(1577)],globalThis[t(557)+t(1371)][t(1074)])&&e[t(782)]!=typeof global&&e[t(764)](e[t(1577)],global[t(557)+"tor"].name)&&e.CmPSs!=typeof process&&!!process[t(564)];class Lo{constructor(){let n=t;if(e[n(872)]("tZBou",e[n(1472)])){e[n(490)](_0x1f02da,_0x113e99,42);let i=e[n(1171)](_0x54c081);_0x2b16e1(_0x506b0c,i),e[n(1652)](_0x1050dd,_0x4aad30,i.limit),e[n(1844)](_0x4e68e1,_0x543257,i),_0x1beae6(i)}else this[n(996)+"rs"]={}}[t(1473)](n,...i){let d=t,u=this[d(996)+"rs"][n];if(u)u[d(956)]()[d(1611)](p=>p.fn[d(590)](p[d(1457)],i));else if(e.aARwL(e[d(1059)],n)&&!this.onerror){let p=i[d(1541)]&&i[0];if(e[d(1561)](p,Error))throw p;let S=new Error(e.ZMwNk(e[d(1784)],p?e[d(1271)](" ("+p[d(1727)],")"):""));throw S.context=p,p}return this}off(n,i){let d=t;if(e.oWKrC(void 0,n))this._listeners={};else if(e[d(908)](void 0,i))this._listeners[n]=null;else{let u=this[d(996)+"rs"][n];if(u)for(let p=0;e.nCMxE(p,u[d(1541)]);)u[p].fn===i?u.splice(p,1):++p}return this}on(n,i,d){let u=t;return(this._listeners[n]||(this[u(996)+"rs"][n]=[]))[u(1416)]({fn:i,ctx:d||this}),this}}class nh extends Lo{["_formatErrorMess"+t(1053)](n){let i=t;if(e[i(1124)](e[i(1474)],"vrdEK"))return n[i(1823)]||n[i(1300)]?(i(824)+" "+(n.errMsg||"")+i(822)+(n[i(1300)]||""))[i(1877)]():JSON.stringify(n);if(_0x5d9bdd=_0x23d787[i(965)+"At"](_0x830aaf),e.cDAkc(_0x4df9e8,128))_0x4d4293[_0x98f504++]=_0x31d2d8;else if(e.cXqXv(_0x35e65b,2048))_0x465dac[_0x16b0fb++]=e[i(981)](e.TEjwH(_0x2e64a2,6),192),_0x312548[_0x5c907d++]=e[i(920)](63&_0x1624e3,128);else if(e[i(1869)](e.fOlhq(64512,_0x29cd15),55296)&&e[i(838)](e.OPYjt(64512,_0x550787=_0xc41d28.charCodeAt(e.VVRPD(_0x53adfc,1))),56320)){let d=e[i(1191)][i(906)]("|"),u=0;for(;;){switch(d[u++]){case"0":++_0x5915c6;continue;case"1":_0x566fe8[_0x23ca52++]=e[i(1172)](e[i(1458)](63,_0x1e6489),128);continue;case"2":_0x3dcb3d[_0x1005ca++]=e.HQPuq(e.MzRUL(_0x5358ca,18),240);continue;case"3":_0x789bf8[_0xa86d13++]=e[i(551)](e[i(606)](_0x3f4f5d>>12,63),128);continue;case"4":_0x4d1261=e[i(869)](e[i(1504)](65536,(1023&_0x3f23b1)<<10),e.vYyeo(1023,_0x22ffa6));continue;case"5":_0x2e81d0[_0xdb2f3c++]=e.IsRYQ(e[i(1467)](_0x55a12f,6),63)|128;continue}break}}else _0x2bb314[_0x1ee605++]=e[i(502)](_0x550865,12)|224,_0xb7d8e[_0x5caceb++]=e[i(766)](e[i(1849)](_0x39ef4a>>6,63),128),_0x14521b[_0x257449++]=e[i(1400)](63&_0x3d7c6b,128)}constructor(n,i,d){let u=t;super(),this[u(1114)]=null,kr&&wx[u(1115)+u(515)]&&(this[u(1114)]=wx.connectSocket({url:n,protocols:i,header:d,fail:this[u(650)+u(1592)+u(1870)][u(1277)](this),success:this[u(650)+u(1468)+u(1231)+u(917)][u(1277)](this)})),_n&&tt["connectS"+u(515)]&&(this[u(1114)]=tt[u(1115)+u(515)]({url:n,protocols:i,header:d,fail:this[u(650)+u(1592)+u(1870)][u(1277)](this),success:this[u(650)+u(1468)+u(1231)+u(917)][u(1277)](this)}))}[t(650)+t(1468)+t(1231)+t(917)](){let n=t;Promise[n(1302)]().then(()=>{this["_addWsLi"+n(1771)]()})}[t(650)+t(1592)+t(1870)](n){let i=t,d={MKtnl:function(u,p){return u<<p},SZsex:function(u,p){return u<p},txUHB:function(u,p){return e[K(1065)](u,p)}};Promise[i(1302)]().then(()=>{let u=i;if(e[u(764)](e.ZYSij,e[u(1551)]))_0x848f1d=EVMSOm[u(1286)](31&_0x3d0d21,6)|63&_0x560db1,EVMSOm.SZsex(_0x3ade50,128)?_0x5945b1+=_0x38b315:(_0x2eec67+=EVMSOm[u(980)](_0x1fffa6,_0x593334),_0x1a0225++);else{let p=e[u(1699)](et,e[u(1059)],{message:this[u(896)+u(1311)+u(1053)](n)});this[u(1473)]("error",p);let S=at(e[u(1664)],{reason:this[u(896)+u(1311)+"age"](n)});this[u(1473)](e.Gdlro,S)}})}[t(1196)+t(1771)](){let n=t,i={WQuLO:function(d,u,p){return d(u,p)}};this[n(1114)][n(1648)](d=>{let u=n;this.emit(e.VUQiO,e.OZkvX(y0,e.VUQiO,{...d,data:d[u(1823)]||""}))}),this._socket.onClose(d=>{let u=n;e[u(819)](e.LNkDB,e[u(1760)])?(this[u(1713)+u(1280)]=0,this[u(1534)+"ndpointT"+u(450)+"t"]=0):this[u(1473)](e[u(1664)],e[u(1652)](at,e.Gdlro,{...d}))}),this[n(1114)][n(487)+"e"](d=>{let u=n;this[u(1473)](u(1727),i[u(862)](_0,u(1727),{...d}))}),this[n(1114)][n(539)](d=>{let u=n;this[u(1473)](e[u(1059)],et(e[u(1059)],{...d,message:d[u(1823)]||""}))})}[t(754)](n){let i=t,d={aoYMn:e.tnJaV};if(e[i(1561)](n,Uint8Array)){let u=n[i(1339)][i(956)](n.byteOffset,e.fpoHN(n[i(1105)+"th"],n[i(1014)+"et"]));this[i(1114)]&&this[i(1114)][i(754)]({data:u,fail:p=>{let S=i;this[S(1473)](e[S(1059)],e.tHZnk(et,e[S(1059)],{message:this[S(896)+"rrorMess"+S(1053)](p)}))}})}else this[i(1114)]&&this[i(1114)][i(754)]({data:n,fail:u=>{let p=i;this[p(1473)](d[p(1690)],et(d[p(1690)],{message:this["_formatE"+p(1311)+p(1053)](u)}))}})}[t(1668)](n,i){this[t(1114)]&&this._socket.close({code:n,reason:i})}[t(1672)+t(948)](n,i){this.on(n,i)}[t(644)+t(1338)+t(474)](n,i){this[t(811)](n,i)}get[t(849)+"te"](){let n=t,i={bZhlg:e[n(1661)],aqcCV:e[n(1808)],TNGFP:function(d,u,p){return e[n(1418)](d,u,p)}};if(e[n(1223)](n(963),e[n(861)]))return this[n(1114)][n(849)+"te"];this[n(1831)+n(1394)](),this.emit(i[n(1915)],i[n(524)]),this[n(1597)+n(887)+"Id"]=i.TNGFP(_0x264fdc,this[n(669)][n(1277)](this),_0x11d47e)}get[t(1295)+"pe"](){let n=t;return e.GidnM!==n(1845)?{bytes:_0x21b85d,offset:0,limit:_0x3ab7e0[n(1541)]}:this[n(1114)][n(1295)+"pe"]}set[t(1295)+"pe"](n){}get[t(1188)](){let n=t;return this[n(1114)][n(1188)]}get[t(1687)](){return this[t(1114)].protocol}get extensions(){let n=t;return this[n(1114)][n(931)+"ns"]}get[t(1525)+t(1235)](){let n=t;return e[n(1186)](n(978),e[n(1072)])?this[n(1114)][n(931)+"ns"]:0}}function rh(o,n){let i=t;if(n)return new n(o.url,o[i(1687)]);if(kr||_n)return new nh(o[i(1188)],o[i(1687)],o.headers);if(e.RBwqi(Gn,Or)&&e.IKITE(e[i(782)],typeof WebSocket)&&WebSocket)return new WebSocket(o[i(1188)],o[i(1687)+"s"])}function ih(o){let n=t,i=(n(1496)+"0")[n(906)]("|"),d=0;for(;;){switch(i[d++]){case"0":return!1;case"1":if(kr&&wx["connectS"+n(515)])return!0;continue;case"2":if(_n&&tt[n(1115)+n(515)])return!0;continue;case"3":if(o)return!0;continue;case"4":if(e.RBwqi(Gn,Or)&&e[n(1160)](e[n(782)],typeof WebSocket)&&WebSocket)return!0;continue}break}}function b0(o,n,i){let d=t,u={zsYZq:function(b,g){return b<=g},dkIUa:e[d(646)],KNXjz:function(b,g){return e[d(1869)](b,g)}},p=-1;async function S(b){let g=d;return u[g(840)](b,p)?Promise[g(1095)](new Error(u[g(1263)])):(p=b,u[g(719)](b,i[g(1541)])?Promise[g(1302)]():i[b][g(1277)](o)(n,S.bind(null,b+1)))}e.oDYyR(S,0)}function S0(o){let n=t,i=0,d=0;for(let u=0;e[n(959)](u,o[n(1541)]);++u)d=o[n(965)+"At"](u),e[n(959)](d,128)?i+=1:e.BZeKj(d,2048)?i+=2:(64512&d)===55296&&e.wyAmG(64512,o[n(965)+"At"](e[n(671)](u,1)))===56320?(++u,i+=4):i+=3;return i}function v0(o,n,i){let d=t;if(e.YuoEP(e.KUASB,d(1298))){let u=e[d(1607)](_0x29d5d9,_0x2ca510,1);_0x162051[d(1017)][u]=_0x377a3c}else{if(e[d(1673)](e[d(1e3)](i,n),1))return"";let u="";for(let p=n;p<i;)if(e[d(601)]===e[d(501)])_0x4d8baf(_0x387456,82),_0x1e4535(_0x265fdb,_0x273578);else{let S=o[p++];if(S<=127)u+=String.fromCharCode(S);else if(e[d(1133)](S,192)&&e[d(1003)](S,224))u+=String[d(821)+d(737)](e.NcHyJ(e[d(1863)](e[d(1734)](31,S),6),e[d(674)](63,o[p++])));else if(e[d(1133)](S,224)&&e[d(1288)](S,240))u+=String[d(821)+d(737)](e[d(1162)](e[d(1540)](e.jaFhx(e[d(933)](15,S),12),e[d(1631)](63,o[p++])<<6),e[d(591)](63,o[p++])));else if(e.gbzHS(S,240)){let b=e[d(1893)](e[d(825)](e[d(1470)](e[d(1545)](e[d(1321)](7,S),18),e.gfLsu(e[d(1113)](63,o[p++]),12)),e.haImq(e[d(1907)](63,o[p++]),6))|e[d(1721)](63,o[p++]),65536);u+=String[d(821)+d(737)](e.ZYfhy(55296,e[d(1694)](b,10))),u+=String[d(821)+"Code"](e.QPjPV(56320,e[d(1786)](1023,b)))}}return u}}function No(o,n,i){let d=t,u=i,p,S;for(let b=0;e[d(958)](b,o[d(1541)]);++b)if(p=o[d(965)+"At"](b),e[d(959)](p,128))n[i++]=p;else if(e[d(584)](p,2048))n[i++]=e[d(1605)](e[d(1467)](p,6),192),n[i++]=e[d(1763)](e[d(1898)](63,p),128);else if((64512&p)===55296&&e.vEMSq(e.AoAJL(64512,S=o.charCodeAt(e.HJAFy(b,1))),56320)){let g=e[d(1462)][d(906)]("|"),T=0;for(;;){switch(g[T++]){case"0":n[i++]=e[d(1165)](e[d(520)](p>>12,63),128);continue;case"1":n[i++]=e[d(589)](63&p,128);continue;case"2":n[i++]=e[d(1726)](e[d(1928)](p,6),63)|128;continue;case"3":n[i++]=p>>18|240;continue;case"4":p=e[d(576)](e[d(1218)](65536,e.IgXFO(e.jOqeG(1023,p),10)),1023&S);continue;case"5":++b;continue}break}}else n[i++]=e[d(976)](e[d(1442)](p,12),224),n[i++]=e.NxHNu(e.AvEGb(p>>6,63),128),n[i++]=e[d(975)](e[d(1815)](63,p),128);return e[d(1707)](i,u)}async function I0(o){let n=t;if(e[n(1858)](e[n(1419)],typeof o)){let i=new Uint8Array(e.SLegw(S0,o));return e[n(1415)](No,o,i,0),i}return e.tqJCR(o,ArrayBuffer)?new Uint8Array(o):new Uint8Array(o[n(1339)],o[n(1014)+"et"],o.byteLength)}function sh(o){let n=t;try{return e[n(1419)]!=typeof o&&(e[n(1859)](o,ArrayBuffer)||o[n(1339)]&&e[n(1424)](o[n(1339)],ArrayBuffer))||n(1220)!=typeof o?"":(JSON.parse(o),e[n(1097)])}catch{return e.CfStu(e[n(1419)],typeof o)?e[n(1630)]:""}}let oh=(o,n)=>{let i=t;switch(o){case e[i(865)]:case i(1132):return{[i(1492)+o]:1,"x-tt-env":n};default:return{}}};class ah{constructor(n){let i=t;this["maxLossC"+i(1567)]=n,this.count=0}addCount(){let n=t;this[n(1150)]++}[t(1647)+t(736)+"nt"](){let n=t;return e[n(765)](this[n(1150)],this[n(936)+n(1567)])}[t(484)+t(1662)](n=0){let i=t;this[i(936)+"ount"]=n,this.count=0}}async function ch(o){let n=t,i={koudD:function(d,u){return e[K(651)](d,u)},bIyKP:n(645)+n(1087),XHeka:e[n(1257)],sJeSn:e.ljynI,RWMFQ:function(d,u){return e[n(1933)](d,u)},pzLzF:e[n(972)],FACFk:function(d,u){return e[n(945)](d,u)},BUzFV:e[n(735)],ADWmN:n(1803),zwiGM:function(d,u){return e[n(569)](d,u)}};return new Promise(d=>{let u=n;if(!Gn)return d(i[u(1584)]);try{let p=document[u(1733)+u(889)](i[u(1754)]);window[u(1930)+u(806)]=S=>{let b=u;document[b(587)][b(799)+b(1122)](p),window[b(1930)+"JSONP"]=void 0,i[b(1347)](d,S&&S[b(1475)]||i[b(1584)])},p[u(457)]=i[u(950)],p.src=i.RWMFQ(o.replace(/^ws/,"http"),i[u(1937)]);try{if(i.FACFk(i[u(1603)],i[u(1712)]))document[u(587)][u(1505)+u(1122)](p);else{let S=(u(773)+"0")[u(906)]("|"),b=0;for(;;){switch(S[b++]){case"0":this[u(1627)]();continue;case"1":this[u(1523)+"osed"]=!1;continue;case"2":this[u(1425)]=!0;continue;case"3":this[u(573)+u(598)]?.[u(484)+u(1662)]();continue;case"4":this[u(1750)+u(1357)]?.[u(1216)+u(1923)+u(1361)]();continue}break}}}catch{document[u(587)][u(799)+u(1122)](p)}}catch{window["frontier"+u(806)]=void 0,i[u(534)](d,i[u(1584)])}})}function $t(o,n,i){let d=t;return!!o?.[d(895)](u=>u.key===n&&u[d(1365)]===i)}function Kn(o,n){let i=t;if(e[i(1223)](e.XWKoY,e[i(567)])){let d=_0x1c3189[i(1500)+"g"](0,4-_0x1b67be[_0x36a995][i(1541)]),u=d[i(1835)](_0x4507ab[_0x24ae02]);_0x21fbcc[i(1416)](u)}else return o?.[i(895)](d=>d[i(1324)]===n)?.[i(1365)]}let Mo=null;async function dh(){let o=t;return Mo||(Mo=Promise[o(1302)]()[o(1711)](Tt[o(1277)](Tt,"idb"))),Mo}class fh extends Lo{constructor(n,i){let d=t;super(),this[d(1904)]=n,this[d(638)]=i,this[d(802)]=void 0,this._initPromise=null}async openDB(){await this[t(1532)]()}async[t(1532)](){let n=t,i={qRzXp:function(d){return e[K(1171)](d)},iGoWf:function(d,u,p,S){return e[K(847)](d,u,p,S)}};if(!this[n(802)]){if(this[n(1809)+n(1669)])return this[n(1809)+n(1669)];try{let d=this[n(1904)],u=this._keyPath;this[n(1809)+n(1669)]=(async()=>{let p=n,{openDB:S}=await i[p(1109)](dh);this._qosDB=await i[p(1397)](S,"frontier_"+d,1,{upgrade(b){let g=p;b[g(509)+g(519)+"e"](d,{keyPath:u})}})})(),await this[n(1809)+"mise"]}catch(d){console[n(1590)](d)}finally{this["_initPro"+n(1669)]=null}}}async[t(904)](n){let i=t,d={yqSVS:function(u,p){return e[K(1852)](u,p)},fqXJo:e[i(522)]};try{return await this[i(1532)](),this[i(802)]?.get(this[i(1904)],n)}catch(u){if(e.pPvRf(e[i(1355)],"EpVGV"))console[i(1590)](u);else{let p=_0x551eb0[i(1733)+i(889)](e[i(1257)]);_0x3c474c[i(1930)+i(806)]=S=>{let b=i;_0x22ab97[b(587)].removeChild(p),_0x13086e[b(1930)+b(806)]=void 0,ZrDjCn[b(828)](_0x757dd,S&&S.msg||ZrDjCn[b(609)])},p.type=e[i(1135)],p.src=e[i(1250)](_0x138152.replace(/^ws/,e[i(907)]),e[i(972)]);try{_0x37e0dd.body["appendCh"+i(1122)](p)}catch{_0x16152d.body[i(799)+"ild"](p)}}}}async[t(717)](n,i){return await this._init(),this._qosDB?.put(this._dbName,n)}async[t(818)](n){let i=t;try{return await this[i(1532)](),this[i(802)]?.[i(1547)](this._dbName,n)}catch(d){console[i(1590)](d)}}async[t(774)](){let n=t,i={LSVGm:e[n(658)],rXXKm:"x_fronti"+n(1067)+"ck",zfBeC:function(d,u,p,S){return e[n(1494)](d,u,p,S)},foPOA:e[n(1897)]};if(e[n(1192)](n(1826),e[n(1142)])){let d=!!this[n(1578)][n(1210)+"S"];if(!d)return{enabled:d,isQoSMessage:!1,isQoSAck:!1,isAckCleanupMessage:!1,ackMsgIds:[]};let u=_0x5de3db(_0x44bf0f[n(1727)][n(966)],i[n(1820)],"2"),p=u&&_0x7b1b7(_0x1e27bf[n(1727)][n(966)],i[n(1447)],"1"),S=u&&i[n(1201)](_0x468f39,_0x309276[n(1727)][n(966)],n(1203)+n(903)+"k","1"),b=S?_0xe98eb4(_0x55e8be.message[n(966)],i[n(1570)])?.split(",").filter(_0x497ce1)||[]:[];return{enabled:d,isQoSMessage:u,isQoSAck:p,isAckCleanupMessage:S,ackMsgIds:b}}else try{return await this._init(),this._qosDB?.clear(this._dbName)}catch(d){console[n(1590)](d)}}async[t(829)](){let n=t;return await this[n(1532)](),this._qosDB?.getAllKeys(this[n(1904)])}async[t(969)](){let n=t;return await this[n(1532)](),this[n(802)]?.[n(969)](this[n(1904)])}async closeDB(){let n=t;try{if(n(1740)===e[n(1621)]){let i=this._qosDB[n(1463)](this[n(1787)]),d=_0x45b72a.parse(e[n(1518)](i,"{}"));return _0x14f109.values(d)}else this[n(802)]?.[n(1668)](),this[n(802)]=void 0}catch(i){console[n(1590)](i)}}get isReady(){try{return!!this._qosDB}catch(n){return console.log(n),!1}}}class lh{constructor(n,i){let d=t;this._DBName=n,this._pathKey=i,this[d(802)]=localStorage}async[t(826)](){}get[t(1787)](){return t(1930)+"_"+this._DBName}async[t(904)](n){let i=t,d=this[i(802)][i(1463)](this._prefix);return JSON[i(1313)](e[i(1292)](d,"{}"))[n]}async[t(717)](n,i){let d=t;if(d(835)===e[d(1239)]){let u=this._qosDB[d(1463)](this[d(1787)]),p=JSON[d(1313)](e.tSFPo(u,"{}"));return p[i||n[this._pathKey]]=n,this[d(802)][d(538)](this[d(1787)],JSON[d(1774)+"y"](p)),i||n[this[d(801)]]}else this[d(1473)](d(503),e[d(1847)](_0x5523be,d(503),{..._0x1b704d,data:_0x2cefd9[d(1823)]||""}))}async[t(818)](n){let i=t;if(e[i(697)](e[i(517)],e[i(517)])){let d=this[i(802)][i(1463)](this[i(1787)]),u=JSON[i(1313)](e[i(1905)](d,"{}"));return u[n]=void 0,this[i(802)][i(538)](this._prefix,JSON[i(1774)+"y"](u))}else e[i(1082)](_0x3392d4,this,_0x4c6a8c,[_0x2dd927,_0x126581,_0x114cf7])}async[t(774)](){return this[t(802)].clear()}async[t(829)](){let n=t,i=this._qosDB.getItem(this._prefix),d=JSON[n(1313)](i||"{}");return Object[n(829)](d)}async[t(969)](){let n=t,i=this[n(802)][n(1463)](this._prefix),d=JSON[n(1313)](e[n(1102)](i,"{}"));return Object[n(1195)](d)}[t(1282)](){return Promise[t(1302)]()}get isReady(){return!!this[t(802)]}}class uh{constructor(n,i){let d=t;e[d(1386)](e.pYFVt,"Sneug")?(this[d(552)]=n,this._pathKey=i,this._qosDB=_n?tt:kr?wx:null):(this[d(493)+"er"]&&_0x3108a6[d(644)+"entListe"+d(474)](e[d(1794)],this[d(800)+d(605)]),this[d(493)+"er"]&&_0x14a0ae[d(644)+d(1338)+d(474)](e[d(544)],this["_handleP"+d(1497)]),this[d(1668)]())}async[t(826)](){}get[t(1787)](){let n=t;return n(1930)+"_"+this[n(552)]}async[t(904)](n){let i=t;if(e[i(1078)]===e[i(1078)]){let d=this[i(802)].getStorageSync(this[i(1787)]);return JSON[i(1313)](d||"{}")[n]}else return _0x358ba5[i(1302)]()}async set(n,i){let d=t,u=this[d(802)][d(1033)+d(655)](this[d(1787)]),p=JSON[d(1313)](e.RBwqi(u,"{}"));return p[i||n[this[d(801)]]]=n,this._qosDB[d(842)+d(655)](this[d(1787)],JSON[d(1774)+"y"](p)),i||n[this[d(801)]]}async[t(818)](n){let i=t,d=this._qosDB[i(1033)+i(655)](this._prefix),u=JSON.parse(d||"{}");return u[n]=void 0,this[i(802)][i(842)+i(655)](this[i(1787)],JSON.stringify(u))}async[t(774)](){let n=t;return this._qosDB[n(854)+n(1850)]()}async keys(){let n=t,i=this[n(802)]["getStora"+n(706)+"nc"](this[n(1787)]),d=JSON[n(1313)](e.lkuKv(i,"{}"));return Object[n(829)](d)}async[t(969)](){let n=t;if(e[n(1213)]("auwgP",e[n(1743)]))this._qosDB?.[n(818)](_0x5bb160.message_id);else{let i=this[n(802)]["getStora"+n(706)+"nc"](this[n(1787)]),d=JSON.parse(i||"{}");return Object[n(1195)](d)}}closeDB(){return Promise[t(1302)]()}get[t(1099)](){return!!this[t(802)]}}function A0(o,n){let i=t;if(e[i(481)](_n,_n))return new uh(o,n);if(e[i(831)](Gn,Or)&&typeof indexedDB<"u")return new fh(o,n);if(e.CarfQ(Gn,Or)&&e[i(1576)]("undefined",typeof localStorage))return new lh(o,n);throw new Error(e[i(1806)])}class xh{constructor(){let n=t;if(n(1871)!==e[n(1602)])this[n(617)+n(1128)+"Id"]=null,this._interval=36e5,this[n(802)]=e[n(1373)](A0,e[n(974)],e[n(873)]);else return _0xa12055[n(1590)](e[n(1674)],_0x387b85,_0x20ed28,_0xabe5f7),this[n(802)][n(717)]({cursor_name:_0x1f3bc4,cursor:_0x304eb0,service:_0x597173})}async[t(617)+t(1032)](){let n=t;clearInterval(this[n(617)+n(1128)+"Id"]),this[n(617)+"lTimeoutId"]=e.YMiJT(setInterval,()=>{this["flushExp"+n(1383)]()},this._interval)}async[t(826)](){let n=t,i={fCZLA:n(530)};await this[n(802)][n(826)]()[n(1711)](()=>{let d=n;if(d(530)!==i.fCZLA){let{type:u}=_0x55c255;this[d(1473)](u,_0x4e8155)}else this[d(617)+d(1032)]()})}async[t(1145)+t(1383)](){let n=t;(await this._qosDB?.getAll()||[]).filter(({timestamp:u})=>u<Date[n(993)]()).forEach(u=>{let p=n,S={lyazv:function(b,g){return b||g}};if(e[p(1244)](e[p(1792)],"NuNDs")){let b=this[p(802)][p(1463)](this[p(1787)]),g=_0x5655e5[p(1313)](LmQzpm[p(1043)](b,"{}"));return g[_0x32b273||_0x4b15fc[this[p(801)]]]=_0x50665b,this[p(802)][p(538)](this._prefix,_0x365677[p(1774)+"y"](g)),_0x575158||_0x257883[this[p(801)]]}else this[p(802)]?.[p(818)](u[p(555)+"id"])})}async[t(818)](n){let i=t;return this[i(802)]?.[i(818)](n)}async[t(717)](n,i){let d=t;if(e.XjFYM!==e[d(1601)]){if(this[d(1831)+d(1394)](),this[d(1267)+"mer"](),this[d(620)+d(932)+"rs"](),this[d(1739)+"nceClose"](1e3,_0x2e11b7),this[d(1627)+d(1868)]=!1,_0x17018b&&this[d(479)+"orOnline"]()&&!this[d(1523)+d(756)]){if(this[d(1750)+d(1357)]?.[d(1647)+d(1558)+"es"]()){let p=this["_endpoin"+d(1357)]?.[d(596)+d(508)+"nt"]();this["_dispatc"+d(1031)+d(1464)](e[d(1769)](_0x1eacc5,e.Gdlro,{code:1006,reason:d(836)+p+(d(1084)+d(892)+d(1022)+d(653)),wasClean:!0}))}else{let p=this[d(1578)][d(939)+d(579)+d(710)](_0x11adc6,_0x8e3c75);this["_dispatc"+d(1031)+"ent"](e.YIoVz(_0x5b9113,e[d(1664)],{code:_0x5c2dc5,reason:_0xaa0dbf,wasClean:!0,willReconnect:p})),p&&this[d(1627)]()}return}this[d(479)+d(1816)]()||this[d(1523)+d(756)]?this[d(1485)+d(1031)+d(1464)](e[d(525)](_0x47f4a4,d(1668),{code:_0x221431,reason:"bye"})):this[d(1485)+"hCloseEv"+d(1464)](e.dYRDL(_0x95fd73,d(1668),{code:1006,reason:d(1508)+d(788)+d(753)+d(574)})),this._ws=null,this[d(1750)+d(1357)]?.[d(1216)+d(1923)+d(1361)](),this[d(573)+"sCounter"]?.[d(484)+d(1662)]()}else return this[d(802)]?.[d(717)]({message_id:n,timestamp:i})}async[t(904)](n){return this[t(802)]?.get(n)}async[t(1282)](){let n=t;e[n(1899)](clearInterval,this["_interva"+n(1128)+"Id"]),await this[n(802)]?.[n(1282)]()}get isReady(){let n=t;return this._qosDB?.[n(1099)]}}function Bo(o){let n=t,i=!!this[n(1578)][n(1210)+"S"];if(!i)return{enabled:i,isQoSMessage:!1,isQoSAck:!1,isAckCleanupMessage:!1,ackMsgIds:[]};let d=e[n(1082)]($t,o[n(1727)].headers,e[n(658)],"2"),u=d&&e[n(1528)]($t,o[n(1727)].headers,e[n(944)],"1"),p=d&&e[n(847)]($t,o.message[n(966)],e[n(1857)],"1"),S=p?e[n(943)](Kn,o[n(1727)][n(966)],e.uYSRU)?.[n(906)](",")[n(725)](Boolean)||[]:[];return{enabled:i,isQoSMessage:d,isQoSAck:u,isAckCleanupMessage:p,ackMsgIds:S}}async function C0(){let o=t;return this[o(1211)+o(1764)]||(this[o(1211)+o(1764)]=new xh),this[o(1211)+o(1764)].isReady||await this["_QoSMana"+o(1764)][o(826)](),this[o(1211)+"ger"]}async function hh(o,n){let i=t;if(e[i(1838)](i(918),e[i(486)])){let{enableAutoAck:d}=this._options,u=e[i(847)]($t,o[i(1727)].headers,e[i(1589)],"1"),p=e[i(1756)]($t,o[i(1727)][i(966)],e[i(1368)],"1"),S=Bo[i(783)](this,o);if(e[i(967)](d,u)){let{SeqID:b,LogID:g,service:T,LogIDNew:P,method:B}=o[i(1727)];this[i(494)]({SeqID:b,LogID:g,LogIDNew:P,service:T,method:B,headers:[{key:e[i(1368)],value:"1"},{key:i(927),value:P||""},{key:e.WYtxM,value:"0"}]})}p&&!S.isQoSAck&&this["_dispatc"+i(1042)+i(867)](o),e[i(1171)](n)}else return _0x42a20e?.find(d=>d[i(1324)]===_0x96d614)?.[i(1365)]}async function ph(o,n){let i=t;if(e[i(1770)](e.ULIcK,e.aSHcQ))this._debug(e.xhfwD,o.message),e[i(1171)](n);else{let d=0,u=0,p;do p=e.NzvWa(_0x451087,_0x31957b),e[i(1182)](d,32)&&(u|=(127&p)<<d),d+=7;while(128&p);return u}}async function gh(o,n){let i=t;if(e.ghrKJ(e[i(1349)],e[i(1349)])){let d=e[i(1222)](qn,await e[i(1649)](I0,o[i(1387)]));try{if(e.iRcVr(e.biwvC,e[i(1027)]))this[i(1378)+"ameSpace"]=_0x3a97e1,this[i(1636)+i(595)]=_0x1217b1,this[i(542)+i(630)]=_0x2af883,this._qosDB=e[i(1305)](_0x1fa512,this[i(1378)+i(1565)],e[i(1488)]);else if(e[i(500)](d[i(1539)],Uint8Array)){let u=this[i(1578)][i(1094)+i(483)]instanceof Object?{force:!!this._options[i(1094)+i(483)][i(1619)],encoding:this[i(1578)][i(1094)+i(483)][i(1455)]?this[i(1578)]["payloadE"+i(483)][i(1455)][i(1618)](/\s/g,"")[i(1498)+"ase"]():""}:{force:!1,encoding:this[i(1578)][i(1094)+"ncoding"]?this[i(1578)].payloadEncoding[i(1618)](/\s/g,"")["toLowerC"+i(858)]():""},p=d["payloadE"+i(483)]?d[i(1094)+i(483)][i(1618)](/\s/g,"")["toLowerC"+i(858)]():"",S=e[i(1561)](this[i(1578)]["payloadT"+i(1012)],Object)?{force:!!this[i(1578)]["payloadT"+i(1012)][i(1619)],type:this[i(1578)][i(679)+i(1012)][i(457)]?this._options[i(679)+i(1012)][i(457)][i(1618)](/\s/g,"")[i(1498)+i(858)]():""}:{force:!1,type:this[i(1578)]["payloadT"+i(1012)]?this[i(1578)][i(679)+i(1012)].replace(/\s/g,"")[i(1498)+i(858)]():""},b=d[i(679)+i(1012)]?d["payloadT"+i(1012)][i(1618)](/\s/g,"")["toLowerC"+i(858)]():"",g=S[i(1619)]?S[i(457)]:b||S[i(457)],T=u[i(1619)]?u[i(1455)]:p||u.encoding,P=[e.VyQQS,e.PLBqh,e[i(1356)],i(1220)],B=[e.Ahpnl,e[i(616)]];this[i(1578)][i(1810)+i(949)+i(716)+"ad"]&&P[i(640)](g)&&(!T||B[i(640)](T))?d[i(478)+i(1629)]=e.IbrAK(v0,d.payload,0,d[i(1539)].byteLength):d[i(478)+i(1629)]=""}else d[i(478)+i(1629)]=""}catch(u){d[i(478)+"oad"]="",console[i(1590)](u)}o[i(1727)]=d,n()}else _0x1743e=e[i(1788)](_0x5008a3,_0xc10e73),_0x54492f=0}function mh(o,n,i){let d=t,u={KOFEZ:function(T,P){return e[K(1888)](T,P)},JJygr:function(T,P){return e[K(1591)](T,P)},LiVAC:function(T,P){return e[K(526)](T,P)},vsLRn:function(T,P){return T(P)},cflJS:function(T,P){return T&P}},p=e.KWNDc(i,8192),S=e[d(1312)](p,1),b=null,g=p;return function(T){let P=d;if(u[P(1812)](T,1)||u.JJygr(T,S))return o(T);u.JJygr(u[P(468)](g,T),p)&&(b=u.vsLRn(o,p),g=0);let B=n.call(b,g,g+=T);return u[P(1908)](7,g)&&(g=(7|g)+1),B}}let wh=4294967295;function _h(o,n,i){let d=t,u={KuIkr:function(p,S){return e[K(492)](p,S)}};return e[d(1222)](RangeError,e[d(1348)](e[d(869)](e.KuOkR(e[d(1348)](e[d(789)](e[d(631)],o),e[d(1181)]),e.RBwqi(n,1)),d(1745)),i))}function yh(o,n,i){let d=t;if(e[d(1757)](i,wh))throw new Error(e.prMyg);let u=3;for(;e.nflcG(u,0);){let p=e.PcgCc(255,i);e[d(847)](Fo,p,o,e[d(560)](n,u)),i>>>=8,u--}return n+4}function Eh(o,n){let i=t,d={UzHdT:function(u,p,S){return u(p,S)}};if(e[i(612)](e[i(785)],e[i(495)])){let u=0,p=n,S=n+4;for(;e[i(602)](p,S);){let{value:b,offset:g}=e.WBMjK(zo,o,p);p=g,u=e[i(1398)](e[i(1549)](u,8),0),u+=b}return{value:u,offset:S}}else{let u=this[i(1750)+i(1357)]?.[i(596)+i(508)+"nt"]();this[i(1485)+i(1031)+i(1464)](d[i(1265)](_0x45a2f6,i(1668),{code:_0xa64268[i(898)],reason:i(1071)+i(759)+"d, unknown reason, hostn"+i(1650)+u})),this[i(1750)+i(1357)]?.["resetEnd"+i(1923)+i(1361)](),this[i(573)+i(598)]?.["resetCou"+i(1662)]();return}}function bh(o,n,i){let d=t,u=e[d(1155)][d(906)]("|"),p=0;for(;;){switch(u[p++]){case"0":if(n[d(1038)])return e[d(492)](n[d(1038)](o,i),i);continue;case"1":if(e[d(1319)](o[d(1541)],40))return e[d(877)](e[d(1776)](No,o,n,i),i);continue;case"2":if(n[d(1047)+"e"])return e.jmxrD(n[d(1047)+"e"](o,i),i);continue;case"3":if(!o)return i;continue;case"4":return e[d(942)](No,o,n,i)+i}break}}function Sh(o,n){let i=t,d=new oe(e.sALBB(e[i(1781)](e.gceZM(o[e[i(1499)](n,4)]<<24,e.kqtOa(o[n+5],16)),e[i(1345)](o[n+6],8)),o[e[i(1248)](n,7)]),e[i(953)](e[i(1021)](o[e[i(1925)](n,0)],24),o[n+1]<<16)|e[i(1851)](o[n+2],8)|o[e[i(1504)](n,3)],!0);return n+=8,{value:d,offset:n+8}}function vh(o,n,i){let d=t,u=o[d(1724)],p=o[d(780)];return n[i]=e.RdPyJ(p,24),n[e[d(526)](i,1)]=e[d(1346)](p>>>16,255),n[i+2]=e[d(916)](e[d(712)](p,8),255),n[i+3]=e[d(1113)](255,p),n[e.nngwV(i,4)]=e.vnEUJ(u,24),n[e[d(1209)](i,5)]=e[d(760)](e.BHJPW(u,16),255),n[i+6]=e[d(1765)](u,8)&255,n[i+7]=e[d(864)](255,u),i+=8,i}function zo(o,n){let i=t;return o[i(1104)+"8"]?{value:o[i(1104)+"8"](n),offset:e[i(1459)](n,1)}:{value:e[i(540)](255,o[n]),offset:e[i(1120)](n,1)}}function Fo(o,n,i){let d=t;return n.writeUint8?n[d(1506)+"t8"](o,i):n[i]=255&o,i+1}let Ih=function(o){let n=t;return e.fGJQM(e[n(1538)],"uYkZH")?new Uint8Array(o):new _0x3a5ad3(_0x502af1,_0x4ba9a5,_0x44249b)},Ah=e[t(1320)](e[t(782)],typeof Buffer)?Buffer[t(1832)+"afe"]:e.vwTeO(mh,Ih,Uint8Array[t(1258)+"e"][t(1900)]),Ch=16,Uo=32;function Th(o){let n=t,i=0,d={};for(let u=0;u<o[n(1541)];u++)d[o[u]["cursor_n"+n(777)]]=e[n(1070)](S0,o[u].cursor_name),i+=14+d[o[u]["cursor_n"+n(777)]];return[i,d]}function T0(o,n,i){let d=t,u={xeJOm:d(1037)+d(488)+"|5|2|6",Ysesq:e.CFYfm,kbwzG:function(T,P,B,j){return e.FQGMi(T,P,B,j)},lFsqc:d(1074),kckCu:e[d(1023)],gxCPH:function(T,P,B,j){return e.nnLtw(T,P,B,j)},dwFRQ:function(T,P,B,j){return T(P,B,j)},NUVgK:e[d(1194)],xeoTl:function(T,P,B,j){return e.FQGMi(T,P,B,j)}},[p,S]=Th(o),b=e[d(727)](Ah,p),g=0;return o[d(1611)](T=>{let P=d,B=u.xeJOm.split("|"),j=0;for(;;){switch(B[j++]){case"0":console[P(1590)](u.Ysesq,g);continue;case"1":console[P(1590)](P(1086)+P(1074),g);continue;case"2":g=u[P(1697)](vh,oe[P(1939)+"er"](T[P(1151)]||n),b,g);continue;case"3":g=u[P(1697)](Fo,0,b,g);continue;case"4":console[P(1590)](P(1318),g);continue;case"5":console[P(1590)](u[P(1822)],g);continue;case"6":console[P(1590)](u[P(1559)],g);continue;case"7":g=u[P(1802)](yh,b,g,T.service||0);continue;case"8":g=u[P(1238)](bh,T[P(758)+P(777)],b,g);continue;case"9":console.log(u[P(705)],T,T[P(1318)]);continue;case"10":g=u[P(928)](Fo,S[T[P(758)+P(777)]],b,g);continue}break}}),{frameType:Uo,headers:[{key:"cursor_f"+d(1864),value:i}],payload:b}}function Dh(o){let n=t,i=0,d=[];for(;i<o[n(1105)+"th"];){let{offset:u}=e.nZaMl(zo,o,i);i=u;let p={cursor_name:"",cursor:0,service:0},{value:S,offset:b}=e.MMaKE(Eh,o,i);p.service=S,i=b;let{value:g,offset:T}=e.MMaKE(zo,o,i);i=T,p[n(758)+n(777)]=e[n(1173)](v0,o,i,e[n(1254)](i,g)),i+=g;let{value:P,offset:B}=e[n(893)](Sh,o,i);p.cursor=P.toNumber(),i=B,d[n(1416)](p)}return d}function Rh(){let o=t;return{frameType:Uo,headers:[{key:e[o(859)],value:e[o(1564)]}],payload:void 0}}class kh{constructor(n,i,d){let u=t,p={RFAgB:e[u(1807)]};e[u(1112)]!==e.hCFmb?(this[u(1473)](p[u(549)],_0x31bcfc),this[u(1728)+"eAck"]&&this[u(1728)+u(1703)](_0x5832f1)):(this[u(1378)+u(1565)]=n,this[u(1636)+u(595)]=i,this[u(542)+u(630)]=d,this[u(802)]=e[u(1679)](A0,this[u(1378)+u(1565)],"cursor_name"))}async[t(826)](){let n=t;if(e.MXFxP(e.OWNTD,e[n(1860)]))return this[n(1114)][n(1188)];await this[n(802)][n(826)]()}async getCursors(){let n=t;if(e.zrrjJ("hQdfq",e.rmAZk))this[n(552)]=_0x3c8600,this._pathKey=_0x5ae70e,this[n(802)]=_0x364f70;else{if(!this[n(802)].isReady)return;let i=this["_message"+n(630)],d=await this._qosDB[n(969)]();switch(console[n(1590)](e[n(1329)],d),i){case e[n(1723)]:return d&&d.length?e[n(1494)](T0,d,0,this[n(1636)+n(595)]):void 0;case"INSTANT":return;case e[n(1092)]:return d&&d[n(1541)]?e[n(734)](T0,d,0,this[n(1636)+n(595)]):e[n(1171)](Rh)}}}async[t(717)](n,i,d){let u=t;return console[u(1590)](e[u(1674)],n,i,d),this[u(802)][u(717)]({cursor_name:n,cursor:i,service:d})}async[t(1224)+"rs"](n){let i=t,d=Dh(n);for(let u of d)console[i(1590)](i(1934)+"r",d),await this[i(802)].set(u)}async get(n){let i=t;return(await this[i(802)][i(904)](n))?.[i(1151)]}async[t(1282)](){let n=t;await this[n(802)][n(1282)]()}updateCursorFileName(n){let i=t;this[i(1636)+"ileName"]=n}get[t(1099)](){let n=t;return this[n(802)][n(1099)]}}let Oh="__x_msg_"+t(769);async function D0(o){let n=t,i={BGjMW:function(b,g,T){return e[K(1882)](b,g,T)},VdiSn:function(b,g){return e.BcXRc(b,g)},diXNq:function(b,g){return b+g}};if(!this[n(1578)][n(1210)+"S"])return null;let{aID:d,fpID:u,messageStrategy:p}=this._options,S=e.BBSXh(o,Oh);try{if(e[n(532)](e[n(1824)],e[n(1824)])){let b=gWQzow[n(1804)](_0x406ecc,_0xf5f422,_0x547717.limit),g=_0x4d07b6[n(1017)],T=_0x535c65[n(1017)];for(let P=0,B=_0x221881[n(880)];gWQzow[n(1797)](P,B);P++)g[gWQzow.diXNq(P,b)]=T[P]}else return this["_cursorM"+n(1200)]?o&&this[n(622)+n(1200)][n(1019)+"rsorFile"+n(1253)](o):this[n(622)+n(1200)]=new kh(u+"_"+d+"_"+S,S,p),this[n(622)+n(1200)][n(1099)]||await this[n(622)+n(1200)][n(826)](),this[n(622)+"anager"]}catch{return null}}async function Ph(o,n){let i=t,d=e[i(847)]($t,o[i(1727)].headers,i(898),"-1"),u=e[i(795)]($t,o[i(1727)][i(966)],e[i(1368)],"1"),p=e.YkycV(Kn,o[i(1727)][i(966)],e.iqWeF),S=e.slAdh(Number,e[i(793)](Kn,o[i(1727)][i(966)],e[i(709)]))||0,b=Bo[i(783)](this,o),g=$t(o[i(1727)][i(966)],e[i(1507)],"2"),T=Kn(o[i(1727)][i(966)],e[i(1586)]),P=e[i(1465)](Number,Kn(o[i(1727)][i(966)],e[i(911)]));if(b.isQoSAck)return e[i(1171)](n);let B=b.isQoSMessage?await C0[i(783)](this):null;if(e[i(1325)](o[i(1727)][i(1318)],0)&&u&&!d||e[i(1390)](o[i(1727)].service,0)){if(p&&b["isQoSMes"+i(1830)]&&B)if(e[i(738)]===e[i(659)]){let j=_0x217be2(e[i(1610)],{message:e[i(1793)]});this[i(1212)+"econnect"]&&this[i(1212)+i(741)](j)}else return!!!await B[i(904)](p)&&(this["_dispatc"+i(955)+"Event"](o),await B[i(717)](p,Date[i(993)]()+S)),e.SqOZY(n);if(g){let j=await D0[i(783)](this);if(!j)return e[i(570)]!==e[i(570)]?!!_0x53b0e4?.[i(895)](J=>J[i(1324)]===_0x38dff2&&J[i(1365)]===_0x3679e4):(this[i(1485)+"hMessage"+i(856)](o),e[i(1640)](n));let V=await j[i(904)](T)??-1;if(e[i(1678)](V,P))this[i(1485)+"hMessage"+i(856)](o),j[i(717)](T,P,o[i(1727)][i(1318)]);else throw new Error("recevied"+i(1420)+" cursor "+P+(" larger "+i(923)+i(1049)+"r ")+V);return e[i(1073)](n)}return this[i(1485)+i(955)+i(856)](o),e[i(1546)](n)}}async function Lh(o,n){let i=t,d=Bo[i(783)](this,o);if(!d[i(1242)+"sage"])return e[i(1296)](n);let u=await C0[i(783)](this);if(d[i(1555)+i(962)+"age"]&&d[i(1587)+"s"][i(1541)])for(let p of d.ackMsgIds)await u[i(818)](p);e.yVBYt(n)}async function Nh(o,n){let i=t,d=o[i(1727)][i(1773)+"e"]===Ch,u=e.zrrjJ(o[i(1727)][i(1773)+"e"],Uo);if(e.UTpCh(!d,!u))return e[i(667)](n);let p=e[i(929)](Kn,o[i(1727)][i(966)],e.vYfHF);if(!p)return e.Arrti(n);let S=await D0[i(783)](this,p);if(!S)return n();if(d){let b=await S[i(1615)+"rs"](),g={frameType:b?.["frameType"],SeqID:oe[i(1939)+"er"](this[i(545)]++),LogID:oe[i(1939)+"er"](this[i(1578)][i(1628)+i(930)]()),service:9e3,method:5,headers:b?.headers,payload:b?.[i(1539)]},T=e[i(1395)](C,g);this[i(1342)]&&this[i(1342)][i(849)+"te"]&&this._ws[i(754)](T)}if(u){let b=o[i(1727)][i(1539)];b&&S[i(1224)+"rs"](b)}}let Mh=async function(o,n){let i=t;this[i(1425)]=!1,e[i(1111)](clearTimeout,this["_connect"+i(711)+i(1170)]),e[i(1106)](n)},Bh=async function(o,n){let i=t;if(!this[i(1342)]||this[i(1342)][i(849)+"te"]!==this[i(874)])return e[i(768)](n);let{pingInterval:d}=this[i(1578)];this[i(1750)+i(1357)]?.[i(1216)+"pointCon"+i(1361)]();for(let p=0;e.aUMVE(p,this[i(542)+i(472)][i(1541)]);p++){if(e[i(1777)]===e[i(1704)])return this[i(802)]?.[i(818)](_0x5f47ca);{let S=this["_message"+i(472)][p];if(e.tgEvw(this._ws.readyState,this[i(874)])&&e[i(784)](null,S))if(e[i(639)](e[i(566)],e.kDzjB))this[i(1342)]&&this[i(1342)][i(754)](S),this[i(542)+i(472)][p]=null;else{if(e.iGKFv(_0x336678,_0x146a1e))return _0x7ed275?_0x5267dc:_0x10c16b;if(_0x4ed83c){if(e[i(1307)](_0x3f7901,_0x374ae0))return _0x3e3bfb}else{if(e[i(1123)](_0x3c92ff,-_0x29cba3))return _0xf8f0a4;if(e.PTOzA(_0x93cb0d+1,_0x44bc62))return _0x1bb7b7}return _0x5e8ffd[i(656)](e[i(675)](e[i(1409)](_0x52e66a,_0x1503ca),0),e[i(976)](e[i(902)](_0x39b79c,_0x435712),0),_0x403291)}else break}}this[i(542)+i(472)]=this[i(542)+i(472)][i(725)](p=>!!p),this[i(1597)+i(887)+"Id"]=setTimeout(()=>this[i(669)](),d),this[i(1485)+i(1136)+"nt"](o),this[i(493)+"er"]&&this[i(1342)]&&(this._ws[i(1295)+"pe"]=this["_binaryT"+i(1012)]);let u=this["_endpoin"+i(1357)]?.[i(596)+"ntEndpoint"]();this[i(662)](i(1752)+u+i(1306)),e[i(667)](n)},zh=async function(o,n){let i=t,d=this["_endpoin"+i(1357)]?.[i(596)+"ntEndpoint"]();this[i(662)](i(1752)+d),e[i(1902)](n)};class Fh extends Lo{constructor(n){let i=t,d={pmnVD:function(u,p,S,b){return e[K(1401)](u,p,S,b)},fApyN:function(u,p,S){return e[K(514)](u,p,S)},roSTr:e[i(1059)],vIMct:e[i(1664)],YKTlc:"versionc"+i(1161),xLJTG:function(u,p){return e[i(922)](u,p)},ekOQJ:e.RWgAa,CZXUn:i(512),zkqHn:function(u,p,S){return u(p,S)},xiqBV:function(u,p,S,b){return e[i(1385)](u,p,S,b)}};if(e[i(809)]("qzeAu",i(1367)))return _0x561524||(_0x1fa538=[_0x247215,_0x46c648,_0x4b7c10,_0x3838d9,_0x51c2c0]);{super(),this[i(1519)+i(1456)+i(1761)]=!0,this[i(493)+"er"]=Gn,this[i(1579)]=th,this[i(1083)+"T"]=_n,this[i(663)+"X"]=kr,this[i(586)+"r"]=Or,this[i(542)+i(472)]=[],this[i(1750)+"tManager"]=null,this["_readyCl"+i(756)]=!1,this["_binaryT"+i(1012)]=e[i(563)],this[i(1627)+"Lock"]=!1,this._connectionTimeoutId=null,this["_reconne"+i(1693)+i(507)]=null,this["_pingPon"+i(887)+"Id"]=null,this[i(545)]=0,this[i(1425)]=!1,this[i(1759)]="",this[i(1211)+"ger"]=null,this[i(622)+i(1200)]=null,this[i(573)+i(598)]=null,this[i(1744)+"ls"]="pbbp2",this[i(527)]=3,this[i(941)+"NG"]=0,this[i(874)]=1,this[i(666)]=2,this[i(1493)]=b=>{let g=i;try{d.pmnVD(b0,this,b,[Mh,Bh,zh])}catch(T){let P=d[g(1287)](et,d[g(952)],{message:T[g(1727)],code:Wt[g(1521)+"OR"],error:T});this["_dispatc"+g(1062)+"ent"](P)}},this[i(661)+"ge"]=async b=>{let g=i,T={ldSNv:d.vIMct,pbMwC:d.YKTlc},{pingInterval:P,pingFrequency:B}=this[g(1578)];if((b[g(1387)]==="hi"&&d.xLJTG(d.ekOQJ,B)||d[g(1526)](d.CZXUn,B))&&(this[g(1831)+"ngTimer"](),this[g(1473)](g(744)+"e_success",g(1389)),this[g(1597)+g(887)+"Id"]=d.zkqHn(setTimeout,this[g(669)][g(1277)](this),P)),b[g(1387)]!=="hi")try{d.xLJTG("tRxir",g(1705))?(_0x261624&&_0x4315a0[g(1672)+"Listener"](mGEkEo[g(1921)],()=>_0x214512()),_0x319f6b&&_0x13b53e[g(1672)+g(948)](mGEkEo[g(750)],()=>_0xa43e7f())):d[g(1876)](b0,this,b,[gh,hh,Lh,Nh,Ph,ph])}catch(j){let V=d[g(863)](et,d[g(952)],{message:j[g(1727)],code:Wt[g(1449)+g(1359)],error:j});this[g(1485)+g(1062)+g(1464)](V)}},this[i(506)]=b=>{let g=i,T=this[g(1750)+g(1357)]?.["checkRea"+g(1558)+"es"](),P=this[g(1750)+g(1357)]?.[g(596)+"ntEndpoint"]();if(T&&!b[g(1727)])if(e[g(1749)](e.pTaYu,e[g(1291)]))_0x58f32e[g(1302)]()[g(1711)](()=>{this._addWsListeners()});else{let B=g(836)+P+(g(649)+g(1767)+g(699)+"ed");this[g(1485)+g(1062)+g(1464)](e[g(1370)](et,e[g(1059)],{message:B,code:Wt[g(713)+g(770)+"R"],error:b}));return}this._ws&&this[g(1342)][g(849)+"te"]===this.OPEN&&this["_disconn"+g(1536)](),this[g(1485)+g(1062)+g(1464)](et(e[g(1059)],{message:b[g(1727)],code:Wt[g(1377)+g(796)],error:b}))},this[i(469)]=async b=>{let g=i;this[g(1267)+g(1666)](),this[g(1831)+g(1394)](),this["_removeW"+g(932)+"rs"](),this[g(1342)]=null,this[g(1627)+g(1868)]=!1;let T=this["_endpoin"+g(1357)]?.[g(1647)+g(1558)+"es"]();if(!T&&this[g(479)+"orOnline"]()&&!this[g(1523)+g(756)]){let P=this["_endpoin"+g(1357)]?.[g(596)+g(508)+"nt"](),B=this[g(1578)][g(939)+g(579)+"ptor"](b[g(898)],b.reason);this._dispatchCloseEvent(e[g(1652)](at,"close",{code:1006,reason:b[g(1087)]||g(1071)+g(759)+g(1297)+g(772)+g(691)+"ame: "+P,willReconnect:B})),B&&this[g(1627)]();return}if(b.code!==1e3&&this[g(1523)+g(756)]){this[g(1485)+g(1031)+g(1464)](e[g(1646)](at,e[g(1664)],{code:1e3,reason:e[g(1407)]})),this["_endpoin"+g(1357)]?.[g(1216)+g(1923)+g(1361)](),this["_pingLos"+g(598)]?.[g(484)+"nter"]();return}if(b[g(898)]!==1e3&&T){let P=this[g(1750)+g(1357)]?.[g(596)+g(508)+"nt"](),B=b.reason;B||(B=await e[g(1638)](ch,this[g(1759)])),B=g(1071)+g(759)+g(1659)+B+(g(654)+g(757))+P+(", max re"+g(1022)+g(653)),this[g(1485)+g(1031)+g(1464)](e.tUvVj(at,e[g(1664)],{code:b[g(898)],reason:B}));let j=g(836)+P+(g(649)+"ax retries reached");this[g(1485)+"hErrorEv"+g(1464)](et(e[g(1059)],{message:j,code:Wt[g(713)+g(770)+"R"]})),this[g(1750)+g(1357)]?.[g(1216)+g(1923)+g(1361)](),this[g(573)+"sCounter"]?.[g(484)+g(1662)]();return}if(e.uQpim(1e3,b.code)&&!b.reason)if(e.fDcAx(g(1134),e.GwIXF))this._initPromise=null;else{let P=this[g(1750)+"tManager"]?.[g(596)+"ntEndpoint"]();this[g(1485)+g(1031)+g(1464)](at(g(1668),{code:b[g(898)],reason:g(1071)+g(759)+"d, unkno"+g(772)+"n, hostn"+g(1650)+P})),this[g(1750)+g(1357)]?.[g(1216)+g(1923)+"fig"](),this[g(573)+g(598)]?.[g(484)+g(1662)]();return}this[g(1485)+g(1031)+g(1464)](b),this["_endpoin"+g(1357)]?.[g(1216)+"pointConfig"](),this[g(573)+g(598)]?.resetCounter()},this[i(888)]=null,this[i(905)]=null,this[i(1388)+"e"]=null,this[i(1643)]=null,this[i(1212)+i(741)]=null,this[i(1728)+i(1703)]=null,this[i(1716)+"mediatel"+i(1243)+"ct"]=null,this[i(798)+i(1775)]=this[i(798)+i(1775)].bind(this),this[i(798)+"ffLine"]=this[i(798)+i(730)][i(1277)](this),this[i(800)+i(605)]=this[i(800)+i(605)][i(1277)](this),this[i(800)+"ageShow"]=this[i(800)+i(1497)][i(1277)](this),this[i(1578)]={url:"",automaticOpen:!0,initReconnectInterval:1e3,maxReconnectInterval:1e4,reconnectIntervalGrowFactor:2,timeoutInterval:5e3,maxRetries:5,debug:!1,maxMessageQueueLength:e[i(452)](1,0),service:0,logIDGenerator:a,headers:void 0,payloadEncoding:"",payloadType:"",fpID:"",deviceID:"",accessKey:"",ttwID:"",bddID:"",aID:"",disableAutoReconnect:!1,customParams:{},pingInterval:15e3,pingTimeoutInterval:4e3,pingFrequency:e[i(1399)],pingLossCount:2,enableTransformTextPayload:!1,logIDNewConfig:{enableAutoGenerateLogIDNew:!1,userIp:""},miniProgramParams:{customHttpHeader:{}},enableAutoAck:!1,reconnectInterceptor:()=>!0,enableQoS:!1,QoSLevel:2,messageStrategy:e[i(1092)],env:{xTTEnv:"",xUseEnv:""},listenNetworkChanged:!0};let{url:u,ws:p}=n,S=Array[i(1412)](u)?u:e[i(529)](e.tnmdO,typeof u)?[u]:[];if(!S||S[i(1541)]===0)throw new Error(e[i(1140)]);if(!e[i(1599)](ih,p))throw new Error(i(1732)+i(722)+i(1596)+", WebSoc"+i(999)+i(597)+"is undef"+i(695));Object[i(1332)](this[i(1578)],n),this[i(1750)+"tManager"]=new E0(S,this[i(1578)][i(1862)+"es"]),this[i(573)+i(598)]=new ah(this[i(1578)][i(1241)+i(968)]),this[i(1578)][i(1247)+"cOpen"]&&(this[i(1425)]=!0,this[i(1627)]()),this[i(1578)][i(1580)+i(1375)+"nged"]&&(this[i(1083)+"T"]||this[i(663)+"X"]?this["_onPageN"+i(994)+i(1268)]():this[i(493)+"er"]&&this["_initGlo"+i(1600)+i(948)]())}}["_handleO"+t(1775)](){let n=t;this[n(1578)][n(775)+n(1197)+n(776)]||this[n(1523)+"osed"]||this[n(890)+n(741)]()}[t(798)+t(730)](){let n=t;if(e.LrKoz(e.WAYrz,e[n(1063)])){this[n(1675)+"WebSocket"]();let i=Po(e[n(1610)],{message:e.khEeF});this[n(1716)+n(937)+n(1243)+"ct"]&&this[n(1716)+"mediatel"+n(1243)+"ct"](i)}else return this[n(1342)]?this[n(1342)].binaryType:this[n(1411)+n(1012)]}[t(1626)+t(1600)+t(948)](){let n=t,i={bGbry:function(d,u){return e[K(1729)](d,u)},gyoLc:function(d,u){return e[K(876)](d,u)},XnNDG:"always",TLCfM:function(d,u){return e[K(1428)](d,u)},PsNnI:e[n(1661)],TNQZw:e[n(1808)],ikNZY:function(d,u,p){return e[n(588)](d,u,p)},QKPzS:function(d,u){return d===u},WnOEk:function(d,u,p,S){return e[n(847)](d,u,p,S)},IOaCg:e[n(1059)]};if(e.KjLhn(e[n(901)],e[n(1575)]))this._isBrowser&&window[n(1672)+n(948)](e[n(1205)],this[n(798)+n(1775)]),this[n(493)+"er"]&&window[n(1672)+n(948)](e[n(465)],this[n(798)+n(730)]),this[n(493)+"er"]&&window[n(1672)+n(948)](n(1927),this["_handleP"+n(605)]),this[n(493)+"er"]&&window[n(1672)+n(948)](n(449),this[n(800)+n(1497)]);else{let{pingInterval:d,pingFrequency:u}=this._options;if((JQBzcA[n(879)]("hi",_0x4a156[n(1387)])&&JQBzcA.gyoLc(JQBzcA[n(615)],u)||JQBzcA[n(1406)](n(512),u))&&(this[n(1831)+"ngTimer"](),this[n(1473)](JQBzcA[n(1768)],JQBzcA[n(676)]),this[n(1597)+n(887)+"Id"]=JQBzcA[n(448)](_0x2a1f61,this[n(669)][n(1277)](this),d)),JQBzcA[n(1176)]("hi",_0x426663[n(1387)]))return;try{JQBzcA.WnOEk(_0x5c5016,this,_0x2dc108,[_0x5c9e72,_0x3994f9,_0x1c3ffc,_0x2e935e,_0x461b8e,_0xf077b4])}catch(p){let S=_0x126a21(JQBzcA.IOaCg,{message:p[n(1727)],code:_0x11d1a6["MESSAGE_"+n(1359)],error:p});this[n(1485)+n(1062)+"ent"](S)}}}[t(1511)+t(1600)+t(948)](){let n=t;this._isBrowser&&window[n(644)+n(1338)+n(474)](e[n(1205)],this[n(798)+n(1775)]),this._isBrowser&&window[n(644)+n(1338)+"ner"](n(624),this[n(798)+n(730)]),this[n(493)+"er"]&&window["removeEv"+n(1338)+"ner"](e[n(1794)],this["_handleP"+n(605)]),this[n(493)+"er"]&&window["removeEv"+n(1338)+n(474)](e[n(544)],this[n(800)+n(1497)])}[t(800)+t(605)](n){let i=t;if(!n[i(673)+"d"]){if(e[i(1479)](e.BmKyD,e[i(1445)]))return;this[i(493)+"er"]&&window[i(644)+i(1338)+"ner"](e[i(1794)],this[i(800)+"ageHide"]),this[i(493)+"er"]&&window[i(644)+i(1338)+i(474)](e.ddGcB,this[i(800)+i(1497)]),this[i(1668)]()}this._isBrowser&&window[i(644)+"entListener"](e[i(1205)],this[i(798)+i(1775)]),this[i(493)+"er"]&&window["removeEv"+i(1338)+"ner"](i(624),this[i(798)+"ffLine"])}[t(800)+t(1497)](n){let i=t;n[i(673)+"d"]&&(this[i(479)+i(1816)]()&&(!this[i(1342)]||this[i(1342)][i(849)+"te"]!==this.OPEN||e.kHkxK(this[i(1342)][i(849)+"te"],this[i(941)+"NG"]))&&this[i(798)+i(1775)](),this[i(493)+"er"]&&window[i(1672)+i(948)](e.rvAcE,this[i(798)+i(1775)]),this[i(493)+"er"]&&window[i(1672)+i(948)](e[i(465)],this[i(798)+i(730)]))}async["_generat"+t(1354)](n){let i=t,{fpID:d,deviceID:u,bddID:p,ttwID:S,accessKey:b,aID:g,customParams:T={},enableAutoAck:P,enableQoS:B,QoSLevel:j,env:V}=this[i(1578)],J,He,$e;this[i(493)+"er"]||this[i(663)+"X"]||this[i(1083)+"T"]?(J=location&&e.WEmha(e[i(1738)],location.protocol)?i(1912):i(1374),He=n.replace(/((^ws)|(^http))((?:[s]*:\/\/))/,""),$e=/^wss(.*:\/\/)/[i(471)](n)?n:""+J+He):(J=e[i(1421)],He=n.replace(/(^http)((?:[s]*:\/\/))/,""),$e=/(^ws)((?:[s]*:\/\/))/[i(471)](He)?He:""+J+He);let je=p?e[i(1702)]:S?e[i(1554)]:"device_id",ct=p||S||u;if(e[i(831)](!ct,!je))throw new Error(e[i(1938)]);let R0=e.kultL(i(1333),typeof T)?await T():T,Uh=V?e[i(881)](oh,V[i(938)],V[i(1431)]):{},qo=Object.assign({device_platform:e.YxtWf,version_code:e[i(1689)],access_key:b,fpid:d,aid:g,[je]:ct,xsack:P?1:0,xaack:P?1:0,xsqos:B?1:0,qos_level:B?j:void 0,qos_sdk_version:2,...Uh},R0),qh=Object[i(829)](qo).reduce((Ho,jo)=>qo[jo]!==void 0?""+Ho+(Ho?"&":"?")+jo+"="+qo[jo]:Ho,"");return $e+i(531)+qh}async[t(1627)](){let n=t;if(!(this[n(1627)+n(1868)]||this[n(1523)+n(756)])){this["_connect"+n(1868)]=!0;try{let i=this[n(1750)+n(1357)]?.["checkCur"+n(1293)+n(626)+n(704)+n(1055)](),{timeoutInterval:d}=this._options;if(i){let p=this[n(1750)+n(1357)]?.[n(596)+n(508)+"nt"](),S=this[n(1750)+n(1357)]?.[n(1867)+n(1227)+n(1932)+"UpdateCo"+n(504)](),b=this[n(1750)+"tManager"]?.["getCurre"+n(508)+n(553)+"ount"]();if(S)if(e[n(1634)](n(1730),e[n(1562)])){let g=this[n(802)][n(1463)](this[n(1787)]),T=_0x39fe4a[n(1313)](e[n(1905)](g,"{}"));return _0x175be5[n(829)](T)}else{let g="connect "+p+(n(1084)+n(892)+n(1022)+"ached, w"+n(1853)+"backup e"+n(830))+S+(n(833)+"y"),T=e[n(608)](et,"error",{message:g,code:Wt[n(713)+n(770)+"R"]});this[n(662)](g),this[n(1485)+n(1062)+"ent"](T),this[n(1759)]=await this[n(1451)+n(1354)](S),this[n(662)]("connect "+S+" "+b+n(1336)),this[n(620)+"sListeners"]()}else if(e[n(1801)](n(1259),"ryylY")){let g=n(836)+p+(n(1084)+n(892)+n(1022)+"ached");this[n(662)](g),this[n(1485)+n(1062)+n(1464)](et(e[n(1059)],{message:g,code:Wt[n(713)+n(770)+"R"]}));return}else return this[n(1114)][n(1295)+"pe"]}else{let p=this["_endpoin"+n(1357)]?.[n(596)+n(508)+"ntAndUpdateCount"](),S=this[n(1750)+n(1357)]?.["getCurrentEndpoi"+n(553)+n(1567)]();this[n(1759)]=await this[n(1451)+n(1354)](e[n(1273)](p,"")),this[n(662)](n(836)+p+" "+S+n(1336)),this[n(620)+n(932)+"rs"]()}if(this._isInit)this[n(1425)]=!1;else{let p=e[n(1524)](Po,e[n(1610)],{message:e.WuAVL});this["onStartR"+n(741)]&&this.onStartReconnect(p)}let u=this["_endpoin"+n(1357)]?.[n(596)+n(508)+n(553)+n(1567)]()||0;u>1&&await this[n(1364)](e[n(1707)](u,1)),this[n(662)](n(1071)+n(1527)+this[n(1759)]+(" protoco"+n(855))+this._protocols),this._ws=e[n(881)](rh,{url:this._url,protocols:[this._protocols],headers:this._options[n(1002)+n(603)+"s"][n(1184)+n(868)]},this[n(1578)].ws),(this[n(493)+"er"]||this._isWorker)&&this._ws&&(this[n(1342)][n(1295)+"pe"]=this[n(1411)+n(1012)]),this["_addWsLi"+n(1771)](),this[n(1627)+"ionTimeo"+n(1170)]=e.SUQiM(setTimeout,this._onTimeout[n(1277)](this),d)}catch(i){throw this[n(1627)+"Lock"]=!1,i}}}[t(1267)+"mer"](){let n=t;e[n(1465)](clearTimeout,this["_connect"+n(711)+"utId"]),this[n(1627)+n(711)+n(1170)]=null}[t(1831)+t(1394)](){let n=t;e[n(727)](clearTimeout,this._pingPongTimeoutId),clearTimeout(this[n(1556)+"ctTimeoutId"]),this[n(1597)+n(887)+"Id"]=null,this[n(1556)+n(1693)+n(507)]=null}[t(662)](...n){let i=t;this[i(1578)][i(1887)]&&console[i(1590)][i(590)](console,[e.OCKFx,...n])}[t(882)+t(1351)+"e"](n){let i=t,{initReconnectInterval:d,maxReconnectInterval:u,reconnectIntervalGrowFactor:p}=this[i(1578)],S=d*Math[i(1029)](p,e[i(1100)](n,1));return e[i(1757)](S,u)?u:S}[t(669)](){let n=t;if(e[n(794)](e.VRsjd,"eCioG")){let i=_0x2e337f(_0x1ffc32),d=_0x32c287[n(880)];return _0x282bc2[n(880)]=e.RRkOO(_0x4c128b[n(883)],i),d}else{if(this[n(1342)]&&e.tgEvw(this[n(1342)].readyState,this[n(941)+"NG"]))if(e[n(627)]===n(749)){this[n(1831)+n(1394)](),this["_pingPon"+n(887)+"Id"]=e[n(475)](setTimeout,this._ping[n(1277)](this),this[n(1578)]["pingInte"+n(1314)]);return}else e[n(823)](_0x123378,this[n(1627)+"ionTimeo"+n(1170)]),this[n(1627)+n(711)+n(1170)]=null;if(!this[n(1342)]||e[n(657)](this[n(1342)][n(849)+"te"],this.OPEN))return void this[n(890)+n(741)]();this[n(1342)]&&this[n(1342)][n(754)]("hi"),this["_reconne"+n(1693)+n(507)]=e[n(1422)](setTimeout,this[n(890)+n(741)+n(1502)][n(1277)](this),this[n(1578)]["pingTime"+n(1632)+n(1843)])}}["_handleR"+t(741)+"Timeout"](){let n=t;this[n(573)+n(598)]?.[n(559)](),this.emit(n(744)+n(964)+"t",e[n(988)]),this[n(573)+n(598)]?.["checkRea"+n(736)+"nt"]()?this[n(890)+"econnect"]():this[n(669)]()}[t(479)+"orOnline"](){let n=t,i={UMhAN:function(d,u){return e[K(575)](d,u)},blsMR:function(d,u){return d>=u}};return e[n(1090)](n(528),n(985))?this[n(1083)+"T"]||this[n(663)+"X"]?this[n(1519)+n(1456)+n(1761)]:(this._isBrowser||this[n(586)+"r"])&&this._options[n(1580)+n(1375)+"nged"]?navigator[n(1515)]:!0:(_0xa3bd89|=0,{low:_0x54edf3,high:XRFjAJ.UMhAN(_0x2c2232,31),unsigned:XRFjAJ[n(839)](_0x12327b,0)})}[t(890)+t(741)](){let n=t;!this[n(479)+n(1816)]()||this[n(1523)+n(756)]||(this["_endpoin"+n(1357)]?.[n(1216)+n(1923)+n(1361)](),this[n(573)+n(598)]?.[n(484)+n(1662)](),this._ws?this[n(820)+n(1536)](1001,e[n(1461)],!0):this[n(1627)]())}["_onPageN"+t(994)+t(1268)](){let n=t;this[n(1083)+"T"]?tt["onNetwor"+n(832)+n(1161)](({isConnected:i})=>{let d=n;this[d(1519)+"igatorOn"+d(1761)]=i,i?this[d(798)+d(1775)]():this["_handleO"+d(730)]()}):this._isMiniWX&&wx[n(1828)+n(832)+n(1161)](({isConnected:i})=>{let d=n;this[d(1519)+d(1456)+d(1761)]=i,i?this[d(798)+d(1775)]():this[d(798)+d(730)]()})}[t(1364)](n){return new Promise(i=>{setTimeout(i,this[K(882)+"rvalValue"](n))})}[t(820)+t(1536)](n=1e3,i="",d=!1){let u=t;this[u(1342)]&&this[u(1675)+u(1308)+"t"](n,i,d)}[t(582)+"ut"](){let n=t,i=this[n(1750)+"tManager"]?.[n(596)+n(508)+"nt"]();this._debug("connect "+i+n(1084)),this["_disconn"+n(1536)](1001,e[n(1057)],!0)}[t(494)](n){let i=t,d={QdMyx:function(p,S){return e[K(885)](p,S)},sBneB:function(p,S){return e[K(1117)](p,S)},hpgGe:function(p,S){return e.ULaxj(p,S)}},u=Ke(n);if(this[i(1342)]&&this[i(1342)][i(849)+"te"]===this[i(874)])if(e.DcCdL!==e[i(1896)])this[i(1342)]&&this[i(1342)][i(754)](u),this._debug(e.DmHcF,n);else{let{url:p}=d[i(1393)](_0x40f4c5,{}),S=_0x342ff4[i(1412)](p)?p:d.sBneB(i(1220),typeof p)?[p]:[];_0xe48250&&_0x4dd1aa[i(1332)](this[i(1578)],_0x2aae33),S&&S[i(1541)]?this[i(1750)+"tManager"]=new _0x14e4d7(S,this._options.maxRetries):this[i(1750)+i(1357)]?.[i(1216)+i(1923)+i(1361)](),this[i(573)+i(598)]?.resetCounter(this[i(1578)][i(1241)+i(968)]),this[i(1523)+i(756)]=!1,this._ws&&d[i(688)](this[i(1342)][i(849)+"te"],this.CLOSED)?this[i(820)+"ect"](1e3,"manual r"+i(741)+i(1906),!0):(this[i(1425)]=!0,this[i(1627)]())}}["_removeW"+t(932)+"rs"](){let n=t,i=e[n(1028)].split("|"),d=0;for(;;){switch(i[d++]){case"0":this[n(1342)][n(644)+"entListe"+n(474)](e.VUQiO,this._onOpen);continue;case"1":if(!this[n(1342)])return;continue;case"2":this._ws[n(644)+"entListe"+n(474)](e.Gdlro,this[n(469)]);continue;case"3":this._ws[n(644)+n(1338)+n(474)](e.tnJaV,this._onError);continue;case"4":this[n(1342)][n(644)+n(1338)+n(474)](e[n(886)],this._onMessage);continue}break}}[t(1196)+t(1771)](){let n=t,i=e[n(1058)][n(906)]("|"),d=0;for(;;){switch(i[d++]){case"0":if(!this[n(1342)])return;continue;case"1":this[n(1342)]["addEvent"+n(948)](e[n(1059)],this[n(506)]);continue;case"2":this[n(1342)][n(1672)+"Listener"](e[n(677)],this[n(1493)]);continue;case"3":this._ws[n(1672)+n(948)](e[n(886)],this[n(661)+"ge"]);continue;case"4":this[n(1342)][n(1672)+n(948)](e[n(1664)],this._onClose);continue}break}}["_wsInsta"+t(1152)](n=1e3,i=""){let d=t;if(e[d(1269)]!==e[d(1269)])this[d(1150)]++;else try{if(e[d(808)](d(846),"fiDtR"))return this[d(1114)].protocol;this[d(1342)]&&this[d(1342)][d(1668)](n,i)}catch{}}[t(1675)+"WebSocket"](n=1e3,i="",d=!1){let u=t,p={KRdrX:function(S,b){return e[K(891)](S,b)},QdrwX:function(S,b){return S-b}};if(e[u(1046)](e[u(1509)],e[u(1509)])){if(this["_clearPi"+u(1394)](),this[u(1267)+u(1666)](),this[u(620)+u(932)+"rs"](),this[u(1739)+u(1152)](1e3,i),this["_connect"+u(1868)]=!1,d&&this[u(479)+u(1816)]()&&!this[u(1523)+u(756)])if(e[u(1157)](e[u(1476)],e[u(1476)])){if(this["_endpoin"+u(1357)]?.[u(1647)+u(1558)+"es"]()){let b=this["_endpoin"+u(1357)]?.[u(596)+"ntEndpoint"]();this[u(1485)+u(1031)+u(1464)](e[u(672)](at,e.Gdlro,{code:1006,reason:u(836)+b+(u(1084)+u(892)+u(1022)+u(653)),wasClean:!0}))}else{let b=this[u(1578)][u(939)+"tInterce"+u(710)](n,i);this["_dispatc"+u(1031)+u(1464)](e[u(745)](at,u(1668),{code:n,reason:i,wasClean:!0,willReconnect:b})),b&&this[u(1627)]()}return}else this.emit(e[u(1664)],_0xb94019(e[u(1664)],{..._0x581450}));this[u(479)+u(1816)]()||this[u(1523)+u(756)]?this[u(1485)+u(1031)+u(1464)](at(e[u(1664)],{code:n,reason:e[u(1407)]})):this[u(1485)+u(1031)+"ent"](e[u(1305)](at,e[u(1664)],{code:1006,reason:e[u(790)]})),this._ws=null,this._endpointManager?.[u(1216)+u(1923)+u(1361)](),this[u(573)+u(598)]?.[u(484)+"nter"]()}else{if(jMULre.KRdrX(4,_0x263b4f[u(1541)])){let S=_0x2a45c3[u(1500)+"g"](0,jMULre[u(1914)](4,_0x1a3824[u(1541)])),b=S[u(1835)](_0x1714fb);_0x3926df[u(1416)](b)}else _0x2253e9[u(1416)](_0x441c07);_0xcc9be9&&(_0x2e77f0+=1),_0x3abcce+=1,_0x494d8c=!1}}[t(1485)+"hOpenEvent"](n){let i=t;this[i(1473)](e[i(677)],n),this[i(1643)]&&this.onopen(n)}[t(1485)+t(955)+t(856)](n){let i=t;this[i(1473)](i(1727),n),this[i(1388)+"e"]&&this[i(1388)+"e"](n)}[t(1485)+t(1042)+t(867)](n){let i=t;if(e[i(732)](e[i(1290)],"yaJam"))this[i(1473)](e[i(1807)],n),this[i(1728)+i(1703)]&&this[i(1728)+i(1703)](n);else return this[i(1737)+"s"][this[i(1713)+i(1280)]]}[t(1485)+t(1062)+t(1464)](n){let i=t;this.emit(e[i(1059)],n),this[i(905)]&&this[i(905)](n)}[t(1485)+"hCloseEv"+t(1464)](n){let i=t;this[i(1473)](e[i(1664)],n),this[i(888)]&&this.onclose(n)}get[t(1295)+"pe"](){let n=t;return this[n(1342)]?this[n(1342)][n(1295)+"pe"]:this[n(1411)+n(1012)]}set[t(1295)+"pe"](n){let i=t;this["_binaryT"+i(1012)]=n,this[i(1342)]&&(this._ws[i(1295)+"pe"]=n)}get[t(1454)+"nt"](){let n=t;return this[n(1750)+n(1357)]?.[n(596)+n(508)+"ntTriesC"+n(1567)]()||0}get["buffered"+t(1235)](){let n=t;return this[n(542)+"Queue"].reduce((d,u)=>(d+=u&&u[n(1105)+"th"]||0,d),0)+(this._ws?this._ws[n(1525)+n(1235)]:0)}get extensions(){let n=t;return e.ULaxj(n(1048),n(1910))?this[n(1342)]?this[n(1342)][n(931)+"ns"]:"":this[n(1187)]?e.tftpo(e[n(1922)](e[n(505)](this.high,0),_0x239245),e[n(451)](this.low,0)):e.vcpBm(this[n(780)],_0x564c53)+e[n(692)](this.low,0)}get[t(1687)](){let n=t;return this._ws?this[n(1342)][n(1687)]:""}get readyState(){let n=t;return this[n(1342)]?this[n(1342)][n(849)+"te"]:this[n(1578)]["automati"+n(1667)]?this[n(941)+"NG"]:this[n(527)]}get[t(1188)](){let n=t;return this._ws?this[n(1342)][n(1188)]:this[n(1759)]}[t(1668)](n=1e3,i){let d=t;if(e[d(1089)](d(1007),e[d(578)])){let u=this[d(780)],p=this.low;return[255&p,e[d(746)](p,8)&255,e.gdGhG(e.JMMxw(p,16),255),p>>>24,e.NvgkF(255,u),e[d(1477)](e[d(712)](u,8),255),e.fkxpP(u,16)&255,e[d(712)](u,24)]}else{if(this[d(1523)+"osed"]=!0,this[d(1267)+d(1666)](),this["_clearPi"+d(1394)](),this["_dropGlo"+d(1600)+d(948)](),this[d(1211)+d(1764)]?.closeDB(),!this._ws)return void this._debug(d(1330)+d(1535)+d(1856)+d(1569)+"ed");if(e.uMlAD(this[d(1342)][d(849)+"te"],this[d(527)])||e[d(1866)](this[d(1342)].readyState,this.CLOSING))return void this[d(662)](e[d(1553)]);this[d(1675)+"WebSocket"](n,i)}}async[t(754)](n,i){let d=t,u={XpFTi:e.AsIuf,JkCZC:d(1514)};if(e[d(1829)](e.XabYa,e.yTjqd))_0x2b57b7[d(644)+d(1338)+"ner"](PyTOKT[d(1116)],_0x25985b),_0x2d56d4["removeEventListe"+d(474)](PyTOKT.JkCZC,_0x3375fd);else{if(n==null)throw new Error(e[d(841)]);e[d(1081)](e[d(1041)],typeof n)&&(n=JSON[d(1774)+"y"](n)),e[d(1560)](e[d(1419)],typeof n)&&!e[d(1453)](n,ArrayBuffer)&&!(n[d(1339)]&&e.Svpfh(n.buffer,ArrayBuffer))&&(n=JSON.stringify(n));let p=await I0(n),S=sh(n),{method:b=0,service:g=this._options[d(1318)],logID:T=this[d(1578)][d(1628)+d(930)](),headers:P=this._options[d(966)],payloadEncoding:B=this[d(1578)][d(1094)+"ncoding"],payloadType:j=this._options[d(679)+d(1012)],logIDNew:V=this[d(1578)].logIDNewConfig[d(489)+d(1885)+d(1301)+"ew"]?e.mSrNP(s,this[d(1578)][d(480)+d(580)][d(1079)]):""}=e[d(897)](i,{});if(!g)throw new Error(e[d(954)]);let J={SeqID:oe[d(1939)+"er"](this[d(545)]++),LogID:oe[d(1939)+"er"](T),service:g,method:b,headers:P,payloadEncoding:e[d(1010)](B,Object)?B[d(1455)]?B[d(1455)]:"":B,payloadType:j instanceof Object?j[d(457)]?j.type:S:j||S,payload:p,LogIDNew:V},He=Ke(J);return this[d(1342)]&&e[d(604)](this._ws.readyState,this[d(874)])?(this[d(1342)]&&this[d(1342)][d(754)](He),this[d(662)]("sent",J)):e[d(1182)](this._messageQueue.length,this[d(1578)][d(496)+"geQueueL"+d(1633)])?(this["_message"+d(472)][d(1416)](He),this[d(662)](e[d(1260)],J)):(this[d(542)+d(472)][d(1440)](),this[d(542)+d(472)][d(1416)](He)),{seqID:this[d(545)],logID:T,logIDNew:V}}}async[t(939)+"t"](n){let i=t,{url:d}=e[i(1292)](n,{}),u=Array.isArray(d)?d:e[i(1593)](e.tnmdO,typeof d)?[d]:[];n&&Object[i(1332)](this._options,n),u&&u[i(1541)]?this[i(1750)+i(1357)]=new E0(u,this[i(1578)][i(1862)+"es"]):this[i(1750)+i(1357)]?.[i(1216)+i(1923)+i(1361)](),this[i(573)+"sCounter"]?.[i(484)+i(1662)](this[i(1578)][i(1241)+i(968)]),this[i(1523)+i(756)]=!1,this[i(1342)]&&this[i(1342)].readyState!==this[i(527)]?this[i(820)+i(1536)](1e3,"manual r"+i(741)+i(1906),!0):e[i(1501)]===e[i(1384)]?_0x3bfb00.o=(p,S)=>_0x349d9e[i(1258)+"e"]["hasOwnPr"+i(1149)][i(783)](p,S):(this._isInit=!0,this._connect())}async[t(684)](){let n=t;!this["_connect"+n(1868)]&&(this["_endpoin"+n(1357)]?.[n(1216)+n(1923)+n(1361)](),this[n(573)+n(598)]?.[n(484)+n(1662)](),this[n(1523)+n(756)]=!1,this[n(1425)]=!0,this[n(1627)]())}[t(1672)+t(948)](n,i){let d=t;if(e[d(1635)](d(720),e[d(594)]))this.on(n,i);else{let u=_0x2f4f24[d(1724)],p=_0xedb2e7[d(780)];return _0x9b7d3e[_0xdf360e]=e[d(712)](p,24),_0x1a2b05[e[d(460)](_0x5de187,1)]=e[d(1169)](e.RsmSv(p,16),255),_0x507d2d[e[d(733)](_0x5bd5dc,2)]=e[d(1557)](p,8)&255,_0x2ccd24[_0x16860a+3]=255&p,_0xa6c626[e.CmZoE(_0x4a4d19,4)]=u>>>24,_0x2ad15b[e[d(1499)](_0x59688c,5)]=e[d(1722)](e[d(1686)](u,16),255),_0x38c4f6[_0x40a903+6]=e[d(947)](e[d(668)](u,8),255),_0x591328[_0x55f1f0+7]=e[d(1477)](255,u),_0x17e930+=8,_0x4a14e0}}[t(755)+t(856)](n){let i=t,{type:d}=n;this[i(1473)](d,n)}[t(644)+"entListe"+t(474)](n,i){this[t(811)](n,i)}[t(1487)](){let n=t,i={tdDze:e[n(1661)],uTeQE:e[n(473)]};return new Promise((d,u)=>{let p=n,S={uKwyt:function(b,g){return e[K(500)](b,g)},AlGvt:function(b,g){return e[K(729)](b,g)},IppuF:function(b,g){return b!==g},iVGFU:p(1389),IsblM:p(744)+p(807)+"s",SpVxQ:p(744)+p(964)+"t"};if(e[p(1279)](e.xmskF,e[p(714)])){if(XLksxp.uKwyt(_0x41d93a,_0x35b3c8))return _0x23b0cd(_0xc3fe1c);if(_0x1162e1[p(541)](_0x439b88))return _0x33f935[p(904)](_0x1fcd49);let b=XLksxp[p(871)](_0x2f3f03,_0xc7dc55);return XLksxp[p(1796)](b,_0x180fa1)&&(_0x29c26d[p(717)](_0x1101b9,b),_0x33a891[p(717)](b,_0x2da1c1)),b}else{this[p(1831)+p(1394)](),this[p(1597)+p(887)+"Id"]=setTimeout(this._ping[p(1277)](this),this._options.pingInterval);let b=()=>{let T=p;d(S[T(1077)]),this[T(811)](S[T(957)],b),this.off(S[T(1585)],g)},g=()=>{let T=p;u(T(1471)),this[T(811)](i.tdDze,b),this.off(i[T(572)],g)};this.on(p(744)+p(807)+"s",b),this.on(e.xAQDB,g),this[p(669)]()}})}}})(),ve[M(1873)+"oseEvent"]=Ee["CustomCl"+M(1075)],ve["CustomEr"+M(827)]=Ee[M(1783)+M(827)],ve.ErrorCode=Ee[M(767)+"e"],ve[M(856)]=Ee[M(856)],ve[M(731)]=Ee[M(731)],ve.FrontierMessageEvent=Ee[M(1881)+"MessageE"+M(536)],ve[M(870)+M(536)]=Ee[M(870)+"vent"],ve[M(1076)+"t"]=Ee[M(1076)+"t"],ve[M(681)+"tEvent"]=Ee[M(681)+M(1481)],ve[M(635)+"oseEvent"]=Ee[M(635)+M(1075)],ve[M(912)+"rorEvent"]=Ee["createEr"+M(827)],ve[M(1011)+M(518)+"nt"]=Ee["createMe"+M(518)+"nt"],ve[M(1651)+M(1588)]=Ee[M(1651)+M(1588)],ve["createRe"+M(1193)+M(536)]=Ee[M(664)+M(1193)+M(536)],ve[M(1762)+"rame"]=Ee[M(1762)+"rame"],ve[M(1805)+"ame"]=Ee[M(1805)+M(777)];for(Xs in Ee)[M(1873)+M(1075),M(1783)+M(827),M(767)+"e",M(856),M(731),M(1881)+M(870)+M(536),M(870)+M(536),M(1076)+"t",M(681)+M(1481),"createCl"+M(1075),M(912)+M(827),"createMessageEvent",M(1651)+M(1588),M(664)+M(1193)+M(536),"decodedFrame",M(1805)+M(777)][M(1168)](Xs)===-1&&(ve[Xs]=Ee[Xs]);var Xs;Object[M(1889)+M(1149)](ve,M(700)+"le",{value:!0})});var Ft=ne((OI,pu)=>{"use strict";var xu=["nodebuffer","arraybuffer","fragments"],hu=typeof Blob<"u";hu&&xu.push("blob");pu.exports={BINARY_TYPES:xu,CLOSE_TIMEOUT:3e4,EMPTY_BUFFER:Buffer.alloc(0),GUID:"258EAFA5-E914-47DA-95CA-C5AB0DC85B11",hasBlob:hu,kForOnEventAttribute:Symbol("kIsForOnEventAttribute"),kListener:Symbol("kListener"),kStatusCode:Symbol("status-code"),kWebSocket:Symbol("websocket"),NOOP:()=>{}}});var bi=ne((PI,so)=>{"use strict";var{EMPTY_BUFFER:Iy}=Ft(),Cc=Buffer[Symbol.species];function Ay(t,e){if(t.length===0)return Iy;if(t.length===1)return t[0];let r=Buffer.allocUnsafe(e),s=0;for(let a=0;a<t.length;a++){let c=t[a];r.set(c,s),s+=c.length}return s<e?new Cc(r.buffer,r.byteOffset,s):r}function gu(t,e,r,s,a){for(let c=0;c<a;c++)r[s+c]=t[c]^e[c&3]}function mu(t,e){for(let r=0;r<t.length;r++)t[r]^=e[r&3]}function Cy(t){return t.length===t.buffer.byteLength?t.buffer:t.buffer.slice(t.byteOffset,t.byteOffset+t.length)}function Tc(t){if(Tc.readOnly=!0,Buffer.isBuffer(t))return t;let e;return t instanceof ArrayBuffer?e=new Cc(t):ArrayBuffer.isView(t)?e=new Cc(t.buffer,t.byteOffset,t.byteLength):(e=Buffer.from(t),Tc.readOnly=!1),e}so.exports={concat:Ay,mask:gu,toArrayBuffer:Cy,toBuffer:Tc,unmask:mu};if(!process.env.WS_NO_BUFFER_UTIL)try{let t=ae("bufferutil");so.exports.mask=function(e,r,s,a,c){c<48?gu(e,r,s,a,c):t.mask(e,r,s,a,c)},so.exports.unmask=function(e,r){e.length<32?mu(e,r):t.unmask(e,r)}}catch{}});var yu=ne((LI,_u)=>{"use strict";var wu=Symbol("kDone"),Dc=Symbol("kRun"),Rc=class{constructor(e){this[wu]=()=>{this.pending--,this[Dc]()},this.concurrency=e||1/0,this.jobs=[],this.pending=0}add(e){this.jobs.push(e),this[Dc]()}[Dc](){if(this.pending!==this.concurrency&&this.jobs.length){let e=this.jobs.shift();this.pending++,e(this[wu])}}};_u.exports=Rc});var vr=ne((NI,vu)=>{"use strict";var Si=ae("zlib"),Eu=bi(),Ty=yu(),{kStatusCode:bu}=Ft(),Dy=Buffer[Symbol.species],Ry=Buffer.from([0,0,255,255]),ao=Symbol("permessage-deflate"),Ut=Symbol("total-length"),br=Symbol("callback"),mn=Symbol("buffers"),Sr=Symbol("error"),oo,kc=class{constructor(e){if(this._options=e||{},this._threshold=this._options.threshold!==void 0?this._options.threshold:1024,this._maxPayload=this._options.maxPayload|0,this._isServer=!!this._options.isServer,this._deflate=null,this._inflate=null,this.params=null,!oo){let r=this._options.concurrencyLimit!==void 0?this._options.concurrencyLimit:10;oo=new Ty(r)}}static get extensionName(){return"permessage-deflate"}offer(){let e={};return this._options.serverNoContextTakeover&&(e.server_no_context_takeover=!0),this._options.clientNoContextTakeover&&(e.client_no_context_takeover=!0),this._options.serverMaxWindowBits&&(e.server_max_window_bits=this._options.serverMaxWindowBits),this._options.clientMaxWindowBits?e.client_max_window_bits=this._options.clientMaxWindowBits:this._options.clientMaxWindowBits==null&&(e.client_max_window_bits=!0),e}accept(e){return e=this.normalizeParams(e),this.params=this._isServer?this.acceptAsServer(e):this.acceptAsClient(e),this.params}cleanup(){if(this._inflate&&(this._inflate.close(),this._inflate=null),this._deflate){let e=this._deflate[br];this._deflate.close(),this._deflate=null,e&&e(new Error("The deflate stream was closed while data was being processed"))}}acceptAsServer(e){let r=this._options,s=e.find(a=>!(r.serverNoContextTakeover===!1&&a.server_no_context_takeover||a.server_max_window_bits&&(r.serverMaxWindowBits===!1||typeof r.serverMaxWindowBits=="number"&&r.serverMaxWindowBits>a.server_max_window_bits)||typeof r.clientMaxWindowBits=="number"&&!a.client_max_window_bits));if(!s)throw new Error("None of the extension offers can be accepted");return r.serverNoContextTakeover&&(s.server_no_context_takeover=!0),r.clientNoContextTakeover&&(s.client_no_context_takeover=!0),typeof r.serverMaxWindowBits=="number"&&(s.server_max_window_bits=r.serverMaxWindowBits),typeof r.clientMaxWindowBits=="number"?s.client_max_window_bits=r.clientMaxWindowBits:(s.client_max_window_bits===!0||r.clientMaxWindowBits===!1)&&delete s.client_max_window_bits,s}acceptAsClient(e){let r=e[0];if(this._options.clientNoContextTakeover===!1&&r.client_no_context_takeover)throw new Error('Unexpected parameter "client_no_context_takeover"');if(!r.client_max_window_bits)typeof this._options.clientMaxWindowBits=="number"&&(r.client_max_window_bits=this._options.clientMaxWindowBits);else if(this._options.clientMaxWindowBits===!1||typeof this._options.clientMaxWindowBits=="number"&&r.client_max_window_bits>this._options.clientMaxWindowBits)throw new Error('Unexpected or invalid parameter "client_max_window_bits"');return r}normalizeParams(e){return e.forEach(r=>{Object.keys(r).forEach(s=>{let a=r[s];if(a.length>1)throw new Error(`Parameter "${s}" must have only a single value`);if(a=a[0],s==="client_max_window_bits"){if(a!==!0){let c=+a;if(!Number.isInteger(c)||c<8||c>15)throw new TypeError(`Invalid value for parameter "${s}": ${a}`);a=c}else if(!this._isServer)throw new TypeError(`Invalid value for parameter "${s}": ${a}`)}else if(s==="server_max_window_bits"){let c=+a;if(!Number.isInteger(c)||c<8||c>15)throw new TypeError(`Invalid value for parameter "${s}": ${a}`);a=c}else if(s==="client_no_context_takeover"||s==="server_no_context_takeover"){if(a!==!0)throw new TypeError(`Invalid value for parameter "${s}": ${a}`)}else throw new Error(`Unknown parameter "${s}"`);r[s]=a})}),e}decompress(e,r,s){oo.add(a=>{this._decompress(e,r,(c,f)=>{a(),s(c,f)})})}compress(e,r,s){oo.add(a=>{this._compress(e,r,(c,f)=>{a(),s(c,f)})})}_decompress(e,r,s){let a=this._isServer?"client":"server";if(!this._inflate){let c=`${a}_max_window_bits`,f=typeof this.params[c]!="number"?Si.Z_DEFAULT_WINDOWBITS:this.params[c];this._inflate=Si.createInflateRaw({...this._options.zlibInflateOptions,windowBits:f}),this._inflate[ao]=this,this._inflate[Ut]=0,this._inflate[mn]=[],this._inflate.on("error",Oy),this._inflate.on("data",Su)}this._inflate[br]=s,this._inflate.write(e),r&&this._inflate.write(Ry),this._inflate.flush(()=>{let c=this._inflate[Sr];if(c){this._inflate.close(),this._inflate=null,s(c);return}let f=Eu.concat(this._inflate[mn],this._inflate[Ut]);this._inflate._readableState.endEmitted?(this._inflate.close(),this._inflate=null):(this._inflate[Ut]=0,this._inflate[mn]=[],r&&this.params[`${a}_no_context_takeover`]&&this._inflate.reset()),s(null,f)})}_compress(e,r,s){let a=this._isServer?"server":"client";if(!this._deflate){let c=`${a}_max_window_bits`,f=typeof this.params[c]!="number"?Si.Z_DEFAULT_WINDOWBITS:this.params[c];this._deflate=Si.createDeflateRaw({...this._options.zlibDeflateOptions,windowBits:f}),this._deflate[Ut]=0,this._deflate[mn]=[],this._deflate.on("data",ky)}this._deflate[br]=s,this._deflate.write(e),this._deflate.flush(Si.Z_SYNC_FLUSH,()=>{if(!this._deflate)return;let c=Eu.concat(this._deflate[mn],this._deflate[Ut]);r&&(c=new Dy(c.buffer,c.byteOffset,c.length-4)),this._deflate[br]=null,this._deflate[Ut]=0,this._deflate[mn]=[],r&&this.params[`${a}_no_context_takeover`]&&this._deflate.reset(),s(null,c)})}};vu.exports=kc;function ky(t){this[mn].push(t),this[Ut]+=t.length}function Su(t){if(this[Ut]+=t.length,this[ao]._maxPayload<1||this[Ut]<=this[ao]._maxPayload){this[mn].push(t);return}this[Sr]=new RangeError("Max payload size exceeded"),this[Sr].code="WS_ERR_UNSUPPORTED_MESSAGE_LENGTH",this[Sr][bu]=1009,this.removeListener("data",Su),this.reset()}function Oy(t){if(this[ao]._inflate=null,this[Sr]){this[br](this[Sr]);return}t[bu]=1007,this[br](t)}});var Ir=ne((MI,co)=>{"use strict";var{isUtf8:Iu}=ae("buffer"),{hasBlob:Py}=Ft(),Ly=[0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,1,0,1,1,1,1,1,0,0,1,1,0,1,1,0,1,1,1,1,1,1,1,1,1,1,0,0,0,0,0,0,0,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,0,0,0,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,0,1,0,1,0];function Ny(t){return t>=1e3&&t<=1014&&t!==1004&&t!==1005&&t!==1006||t>=3e3&&t<=4999}function Oc(t){let e=t.length,r=0;for(;r<e;)if((t[r]&128)===0)r++;else if((t[r]&224)===192){if(r+1===e||(t[r+1]&192)!==128||(t[r]&254)===192)return!1;r+=2}else if((t[r]&240)===224){if(r+2>=e||(t[r+1]&192)!==128||(t[r+2]&192)!==128||t[r]===224&&(t[r+1]&224)===128||t[r]===237&&(t[r+1]&224)===160)return!1;r+=3}else if((t[r]&248)===240){if(r+3>=e||(t[r+1]&192)!==128||(t[r+2]&192)!==128||(t[r+3]&192)!==128||t[r]===240&&(t[r+1]&240)===128||t[r]===244&&t[r+1]>143||t[r]>244)return!1;r+=4}else return!1;return!0}function My(t){return Py&&typeof t=="object"&&typeof t.arrayBuffer=="function"&&typeof t.type=="string"&&typeof t.stream=="function"&&(t[Symbol.toStringTag]==="Blob"||t[Symbol.toStringTag]==="File")}co.exports={isBlob:My,isValidStatusCode:Ny,isValidUTF8:Oc,tokenChars:Ly};if(Iu)co.exports.isValidUTF8=function(t){return t.length<24?Oc(t):Iu(t)};else if(!process.env.WS_NO_UTF_8_VALIDATE)try{let t=ae("utf-8-validate");co.exports.isValidUTF8=function(e){return e.length<32?Oc(e):t(e)}}catch{}});var Bc=ne((BI,Ou)=>{"use strict";var{Writable:By}=ae("stream"),Au=vr(),{BINARY_TYPES:zy,EMPTY_BUFFER:Cu,kStatusCode:Fy,kWebSocket:Uy}=Ft(),{concat:Pc,toArrayBuffer:qy,unmask:Hy}=bi(),{isValidStatusCode:jy,isValidUTF8:Tu}=Ir(),fo=Buffer[Symbol.species],it=0,Du=1,Ru=2,ku=3,Lc=4,Nc=5,lo=6,Mc=class extends By{constructor(e={}){super(),this._allowSynchronousEvents=e.allowSynchronousEvents!==void 0?e.allowSynchronousEvents:!0,this._binaryType=e.binaryType||zy[0],this._extensions=e.extensions||{},this._isServer=!!e.isServer,this._maxPayload=e.maxPayload|0,this._skipUTF8Validation=!!e.skipUTF8Validation,this[Uy]=void 0,this._bufferedBytes=0,this._buffers=[],this._compressed=!1,this._payloadLength=0,this._mask=void 0,this._fragmented=0,this._masked=!1,this._fin=!1,this._opcode=0,this._totalPayloadLength=0,this._messageLength=0,this._fragments=[],this._errored=!1,this._loop=!1,this._state=it}_write(e,r,s){if(this._opcode===8&&this._state==it)return s();this._bufferedBytes+=e.length,this._buffers.push(e),this.startLoop(s)}consume(e){if(this._bufferedBytes-=e,e===this._buffers[0].length)return this._buffers.shift();if(e<this._buffers[0].length){let s=this._buffers[0];return this._buffers[0]=new fo(s.buffer,s.byteOffset+e,s.length-e),new fo(s.buffer,s.byteOffset,e)}let r=Buffer.allocUnsafe(e);do{let s=this._buffers[0],a=r.length-e;e>=s.length?r.set(this._buffers.shift(),a):(r.set(new Uint8Array(s.buffer,s.byteOffset,e),a),this._buffers[0]=new fo(s.buffer,s.byteOffset+e,s.length-e)),e-=s.length}while(e>0);return r}startLoop(e){this._loop=!0;do switch(this._state){case it:this.getInfo(e);break;case Du:this.getPayloadLength16(e);break;case Ru:this.getPayloadLength64(e);break;case ku:this.getMask();break;case Lc:this.getData(e);break;case Nc:case lo:this._loop=!1;return}while(this._loop);this._errored||e()}getInfo(e){if(this._bufferedBytes<2){this._loop=!1;return}let r=this.consume(2);if((r[0]&48)!==0){let a=this.createError(RangeError,"RSV2 and RSV3 must be clear",!0,1002,"WS_ERR_UNEXPECTED_RSV_2_3");e(a);return}let s=(r[0]&64)===64;if(s&&!this._extensions[Au.extensionName]){let a=this.createError(RangeError,"RSV1 must be clear",!0,1002,"WS_ERR_UNEXPECTED_RSV_1");e(a);return}if(this._fin=(r[0]&128)===128,this._opcode=r[0]&15,this._payloadLength=r[1]&127,this._opcode===0){if(s){let a=this.createError(RangeError,"RSV1 must be clear",!0,1002,"WS_ERR_UNEXPECTED_RSV_1");e(a);return}if(!this._fragmented){let a=this.createError(RangeError,"invalid opcode 0",!0,1002,"WS_ERR_INVALID_OPCODE");e(a);return}this._opcode=this._fragmented}else if(this._opcode===1||this._opcode===2){if(this._fragmented){let a=this.createError(RangeError,`invalid opcode ${this._opcode}`,!0,1002,"WS_ERR_INVALID_OPCODE");e(a);return}this._compressed=s}else if(this._opcode>7&&this._opcode<11){if(!this._fin){let a=this.createError(RangeError,"FIN must be set",!0,1002,"WS_ERR_EXPECTED_FIN");e(a);return}if(s){let a=this.createError(RangeError,"RSV1 must be clear",!0,1002,"WS_ERR_UNEXPECTED_RSV_1");e(a);return}if(this._payloadLength>125||this._opcode===8&&this._payloadLength===1){let a=this.createError(RangeError,`invalid payload length ${this._payloadLength}`,!0,1002,"WS_ERR_INVALID_CONTROL_PAYLOAD_LENGTH");e(a);return}}else{let a=this.createError(RangeError,`invalid opcode ${this._opcode}`,!0,1002,"WS_ERR_INVALID_OPCODE");e(a);return}if(!this._fin&&!this._fragmented&&(this._fragmented=this._opcode),this._masked=(r[1]&128)===128,this._isServer){if(!this._masked){let a=this.createError(RangeError,"MASK must be set",!0,1002,"WS_ERR_EXPECTED_MASK");e(a);return}}else if(this._masked){let a=this.createError(RangeError,"MASK must be clear",!0,1002,"WS_ERR_UNEXPECTED_MASK");e(a);return}this._payloadLength===126?this._state=Du:this._payloadLength===127?this._state=Ru:this.haveLength(e)}getPayloadLength16(e){if(this._bufferedBytes<2){this._loop=!1;return}this._payloadLength=this.consume(2).readUInt16BE(0),this.haveLength(e)}getPayloadLength64(e){if(this._bufferedBytes<8){this._loop=!1;return}let r=this.consume(8),s=r.readUInt32BE(0);if(s>Math.pow(2,21)-1){let a=this.createError(RangeError,"Unsupported WebSocket frame: payload length > 2^53 - 1",!1,1009,"WS_ERR_UNSUPPORTED_DATA_PAYLOAD_LENGTH");e(a);return}this._payloadLength=s*Math.pow(2,32)+r.readUInt32BE(4),this.haveLength(e)}haveLength(e){if(this._payloadLength&&this._opcode<8&&(this._totalPayloadLength+=this._payloadLength,this._totalPayloadLength>this._maxPayload&&this._maxPayload>0)){let r=this.createError(RangeError,"Max payload size exceeded",!1,1009,"WS_ERR_UNSUPPORTED_MESSAGE_LENGTH");e(r);return}this._masked?this._state=ku:this._state=Lc}getMask(){if(this._bufferedBytes<4){this._loop=!1;return}this._mask=this.consume(4),this._state=Lc}getData(e){let r=Cu;if(this._payloadLength){if(this._bufferedBytes<this._payloadLength){this._loop=!1;return}r=this.consume(this._payloadLength),this._masked&&(this._mask[0]|this._mask[1]|this._mask[2]|this._mask[3])!==0&&Hy(r,this._mask)}if(this._opcode>7){this.controlMessage(r,e);return}if(this._compressed){this._state=Nc,this.decompress(r,e);return}r.length&&(this._messageLength=this._totalPayloadLength,this._fragments.push(r)),this.dataMessage(e)}decompress(e,r){this._extensions[Au.extensionName].decompress(e,this._fin,(a,c)=>{if(a)return r(a);if(c.length){if(this._messageLength+=c.length,this._messageLength>this._maxPayload&&this._maxPayload>0){let f=this.createError(RangeError,"Max payload size exceeded",!1,1009,"WS_ERR_UNSUPPORTED_MESSAGE_LENGTH");r(f);return}this._fragments.push(c)}this.dataMessage(r),this._state===it&&this.startLoop(r)})}dataMessage(e){if(!this._fin){this._state=it;return}let r=this._messageLength,s=this._fragments;if(this._totalPayloadLength=0,this._messageLength=0,this._fragmented=0,this._fragments=[],this._opcode===2){let a;this._binaryType==="nodebuffer"?a=Pc(s,r):this._binaryType==="arraybuffer"?a=qy(Pc(s,r)):this._binaryType==="blob"?a=new Blob(s):a=s,this._allowSynchronousEvents?(this.emit("message",a,!0),this._state=it):(this._state=lo,setImmediate(()=>{this.emit("message",a,!0),this._state=it,this.startLoop(e)}))}else{let a=Pc(s,r);if(!this._skipUTF8Validation&&!Tu(a)){let c=this.createError(Error,"invalid UTF-8 sequence",!0,1007,"WS_ERR_INVALID_UTF8");e(c);return}this._state===Nc||this._allowSynchronousEvents?(this.emit("message",a,!1),this._state=it):(this._state=lo,setImmediate(()=>{this.emit("message",a,!1),this._state=it,this.startLoop(e)}))}}controlMessage(e,r){if(this._opcode===8){if(e.length===0)this._loop=!1,this.emit("conclude",1005,Cu),this.end();else{let s=e.readUInt16BE(0);if(!jy(s)){let c=this.createError(RangeError,`invalid status code ${s}`,!0,1002,"WS_ERR_INVALID_CLOSE_CODE");r(c);return}let a=new fo(e.buffer,e.byteOffset+2,e.length-2);if(!this._skipUTF8Validation&&!Tu(a)){let c=this.createError(Error,"invalid UTF-8 sequence",!0,1007,"WS_ERR_INVALID_UTF8");r(c);return}this._loop=!1,this.emit("conclude",s,a),this.end()}this._state=it;return}this._allowSynchronousEvents?(this.emit(this._opcode===9?"ping":"pong",e),this._state=it):(this._state=lo,setImmediate(()=>{this.emit(this._opcode===9?"ping":"pong",e),this._state=it,this.startLoop(r)}))}createError(e,r,s,a,c){this._loop=!1,this._errored=!0;let f=new e(s?`Invalid WebSocket frame: ${r}`:r);return Error.captureStackTrace(f,this.createError),f.code=c,f[Fy]=a,f}};Ou.exports=Mc});var Uc=ne((FI,Nu)=>{"use strict";var{Duplex:zI}=ae("stream"),{randomFillSync:Gy}=ae("crypto"),Pu=vr(),{EMPTY_BUFFER:Ky,kWebSocket:Wy,NOOP:$y}=Ft(),{isBlob:Ar,isValidStatusCode:Vy}=Ir(),{mask:Lu,toBuffer:Nn}=bi(),st=Symbol("kByteLength"),Jy=Buffer.alloc(4),uo=8*1024,Mn,Cr=uo,pt=0,Zy=1,Yy=2,zc=class t{constructor(e,r,s){this._extensions=r||{},s&&(this._generateMask=s,this._maskBuffer=Buffer.alloc(4)),this._socket=e,this._firstFragment=!0,this._compress=!1,this._bufferedBytes=0,this._queue=[],this._state=pt,this.onerror=$y,this[Wy]=void 0}static frame(e,r){let s,a=!1,c=2,f=!1;r.mask&&(s=r.maskBuffer||Jy,r.generateMask?r.generateMask(s):(Cr===uo&&(Mn===void 0&&(Mn=Buffer.alloc(uo)),Gy(Mn,0,uo),Cr=0),s[0]=Mn[Cr++],s[1]=Mn[Cr++],s[2]=Mn[Cr++],s[3]=Mn[Cr++]),f=(s[0]|s[1]|s[2]|s[3])===0,c=6);let l;typeof e=="string"?(!r.mask||f)&&r[st]!==void 0?l=r[st]:(e=Buffer.from(e),l=e.length):(l=e.length,a=r.mask&&r.readOnly&&!f);let x=l;l>=65536?(c+=8,x=127):l>125&&(c+=2,x=126);let h=Buffer.allocUnsafe(a?l+c:c);return h[0]=r.fin?r.opcode|128:r.opcode,r.rsv1&&(h[0]|=64),h[1]=x,x===126?h.writeUInt16BE(l,2):x===127&&(h[2]=h[3]=0,h.writeUIntBE(l,4,6)),r.mask?(h[1]|=128,h[c-4]=s[0],h[c-3]=s[1],h[c-2]=s[2],h[c-1]=s[3],f?[h,e]:a?(Lu(e,s,h,c,l),[h]):(Lu(e,s,e,0,l),[h,e])):[h,e]}close(e,r,s,a){let c;if(e===void 0)c=Ky;else{if(typeof e!="number"||!Vy(e))throw new TypeError("First argument must be a valid error code number");if(r===void 0||!r.length)c=Buffer.allocUnsafe(2),c.writeUInt16BE(e,0);else{let l=Buffer.byteLength(r);if(l>123)throw new RangeError("The message must not be greater than 123 bytes");c=Buffer.allocUnsafe(2+l),c.writeUInt16BE(e,0),typeof r=="string"?c.write(r,2):c.set(r,2)}}let f={[st]:c.length,fin:!0,generateMask:this._generateMask,mask:s,maskBuffer:this._maskBuffer,opcode:8,readOnly:!1,rsv1:!1};this._state!==pt?this.enqueue([this.dispatch,c,!1,f,a]):this.sendFrame(t.frame(c,f),a)}ping(e,r,s){let a,c;if(typeof e=="string"?(a=Buffer.byteLength(e),c=!1):Ar(e)?(a=e.size,c=!1):(e=Nn(e),a=e.length,c=Nn.readOnly),a>125)throw new RangeError("The data size must not be greater than 125 bytes");let f={[st]:a,fin:!0,generateMask:this._generateMask,mask:r,maskBuffer:this._maskBuffer,opcode:9,readOnly:c,rsv1:!1};Ar(e)?this._state!==pt?this.enqueue([this.getBlobData,e,!1,f,s]):this.getBlobData(e,!1,f,s):this._state!==pt?this.enqueue([this.dispatch,e,!1,f,s]):this.sendFrame(t.frame(e,f),s)}pong(e,r,s){let a,c;if(typeof e=="string"?(a=Buffer.byteLength(e),c=!1):Ar(e)?(a=e.size,c=!1):(e=Nn(e),a=e.length,c=Nn.readOnly),a>125)throw new RangeError("The data size must not be greater than 125 bytes");let f={[st]:a,fin:!0,generateMask:this._generateMask,mask:r,maskBuffer:this._maskBuffer,opcode:10,readOnly:c,rsv1:!1};Ar(e)?this._state!==pt?this.enqueue([this.getBlobData,e,!1,f,s]):this.getBlobData(e,!1,f,s):this._state!==pt?this.enqueue([this.dispatch,e,!1,f,s]):this.sendFrame(t.frame(e,f),s)}send(e,r,s){let a=this._extensions[Pu.extensionName],c=r.binary?2:1,f=r.compress,l,x;typeof e=="string"?(l=Buffer.byteLength(e),x=!1):Ar(e)?(l=e.size,x=!1):(e=Nn(e),l=e.length,x=Nn.readOnly),this._firstFragment?(this._firstFragment=!1,f&&a&&a.params[a._isServer?"server_no_context_takeover":"client_no_context_takeover"]&&(f=l>=a._threshold),this._compress=f):(f=!1,c=0),r.fin&&(this._firstFragment=!0);let h={[st]:l,fin:r.fin,generateMask:this._generateMask,mask:r.mask,maskBuffer:this._maskBuffer,opcode:c,readOnly:x,rsv1:f};Ar(e)?this._state!==pt?this.enqueue([this.getBlobData,e,this._compress,h,s]):this.getBlobData(e,this._compress,h,s):this._state!==pt?this.enqueue([this.dispatch,e,this._compress,h,s]):this.dispatch(e,this._compress,h,s)}getBlobData(e,r,s,a){this._bufferedBytes+=s[st],this._state=Yy,e.arrayBuffer().then(c=>{if(this._socket.destroyed){let l=new Error("The socket was closed while the blob was being read");process.nextTick(Fc,this,l,a);return}this._bufferedBytes-=s[st];let f=Nn(c);r?this.dispatch(f,r,s,a):(this._state=pt,this.sendFrame(t.frame(f,s),a),this.dequeue())}).catch(c=>{process.nextTick(Xy,this,c,a)})}dispatch(e,r,s,a){if(!r){this.sendFrame(t.frame(e,s),a);return}let c=this._extensions[Pu.extensionName];this._bufferedBytes+=s[st],this._state=Zy,c.compress(e,s.fin,(f,l)=>{if(this._socket.destroyed){let x=new Error("The socket was closed while data was being compressed");Fc(this,x,a);return}this._bufferedBytes-=s[st],this._state=pt,s.readOnly=!1,this.sendFrame(t.frame(l,s),a),this.dequeue()})}dequeue(){for(;this._state===pt&&this._queue.length;){let e=this._queue.shift();this._bufferedBytes-=e[3][st],Reflect.apply(e[0],this,e.slice(1))}}enqueue(e){this._bufferedBytes+=e[3][st],this._queue.push(e)}sendFrame(e,r){e.length===2?(this._socket.cork(),this._socket.write(e[0]),this._socket.write(e[1],r),this._socket.uncork()):this._socket.write(e[0],r)}};Nu.exports=zc;function Fc(t,e,r){typeof r=="function"&&r(e);for(let s=0;s<t._queue.length;s++){let a=t._queue[s],c=a[a.length-1];typeof c=="function"&&c(e)}}function Xy(t,e,r){Fc(t,e,r),t.onerror(e)}});var Gu=ne((UI,ju)=>{"use strict";var{kForOnEventAttribute:vi,kListener:qc}=Ft(),Mu=Symbol("kCode"),Bu=Symbol("kData"),zu=Symbol("kError"),Fu=Symbol("kMessage"),Uu=Symbol("kReason"),Tr=Symbol("kTarget"),qu=Symbol("kType"),Hu=Symbol("kWasClean"),qt=class{constructor(e){this[Tr]=null,this[qu]=e}get target(){return this[Tr]}get type(){return this[qu]}};Object.defineProperty(qt.prototype,"target",{enumerable:!0});Object.defineProperty(qt.prototype,"type",{enumerable:!0});var Bn=class extends qt{constructor(e,r={}){super(e),this[Mu]=r.code===void 0?0:r.code,this[Uu]=r.reason===void 0?"":r.reason,this[Hu]=r.wasClean===void 0?!1:r.wasClean}get code(){return this[Mu]}get reason(){return this[Uu]}get wasClean(){return this[Hu]}};Object.defineProperty(Bn.prototype,"code",{enumerable:!0});Object.defineProperty(Bn.prototype,"reason",{enumerable:!0});Object.defineProperty(Bn.prototype,"wasClean",{enumerable:!0});var Dr=class extends qt{constructor(e,r={}){super(e),this[zu]=r.error===void 0?null:r.error,this[Fu]=r.message===void 0?"":r.message}get error(){return this[zu]}get message(){return this[Fu]}};Object.defineProperty(Dr.prototype,"error",{enumerable:!0});Object.defineProperty(Dr.prototype,"message",{enumerable:!0});var Ii=class extends qt{constructor(e,r={}){super(e),this[Bu]=r.data===void 0?null:r.data}get data(){return this[Bu]}};Object.defineProperty(Ii.prototype,"data",{enumerable:!0});var Qy={addEventListener(t,e,r={}){for(let a of this.listeners(t))if(!r[vi]&&a[qc]===e&&!a[vi])return;let s;if(t==="message")s=function(c,f){let l=new Ii("message",{data:f?c:c.toString()});l[Tr]=this,xo(e,this,l)};else if(t==="close")s=function(c,f){let l=new Bn("close",{code:c,reason:f.toString(),wasClean:this._closeFrameReceived&&this._closeFrameSent});l[Tr]=this,xo(e,this,l)};else if(t==="error")s=function(c){let f=new Dr("error",{error:c,message:c.message});f[Tr]=this,xo(e,this,f)};else if(t==="open")s=function(){let c=new qt("open");c[Tr]=this,xo(e,this,c)};else return;s[vi]=!!r[vi],s[qc]=e,r.once?this.once(t,s):this.on(t,s)},removeEventListener(t,e){for(let r of this.listeners(t))if(r[qc]===e&&!r[vi]){this.removeListener(t,r);break}}};ju.exports={CloseEvent:Bn,ErrorEvent:Dr,Event:qt,EventTarget:Qy,MessageEvent:Ii};function xo(t,e,r){typeof t=="object"&&t.handleEvent?t.handleEvent.call(t,r):t.call(e,r)}});var ho=ne((qI,Ku)=>{"use strict";var{tokenChars:Ai}=Ir();function Rt(t,e,r){t[e]===void 0?t[e]=[r]:t[e].push(r)}function eE(t){let e=Object.create(null),r=Object.create(null),s=!1,a=!1,c=!1,f,l,x=-1,h=-1,m=-1,E=0;for(;E<t.length;E++)if(h=t.charCodeAt(E),f===void 0)if(m===-1&&Ai[h]===1)x===-1&&(x=E);else if(E!==0&&(h===32||h===9))m===-1&&x!==-1&&(m=E);else if(h===59||h===44){if(x===-1)throw new SyntaxError(`Unexpected character at index ${E}`);m===-1&&(m=E);let _=t.slice(x,m);h===44?(Rt(e,_,r),r=Object.create(null)):f=_,x=m=-1}else throw new SyntaxError(`Unexpected character at index ${E}`);else if(l===void 0)if(m===-1&&Ai[h]===1)x===-1&&(x=E);else if(h===32||h===9)m===-1&&x!==-1&&(m=E);else if(h===59||h===44){if(x===-1)throw new SyntaxError(`Unexpected character at index ${E}`);m===-1&&(m=E),Rt(r,t.slice(x,m),!0),h===44&&(Rt(e,f,r),r=Object.create(null),f=void 0),x=m=-1}else if(h===61&&x!==-1&&m===-1)l=t.slice(x,E),x=m=-1;else throw new SyntaxError(`Unexpected character at index ${E}`);else if(a){if(Ai[h]!==1)throw new SyntaxError(`Unexpected character at index ${E}`);x===-1?x=E:s||(s=!0),a=!1}else if(c)if(Ai[h]===1)x===-1&&(x=E);else if(h===34&&x!==-1)c=!1,m=E;else if(h===92)a=!0;else throw new SyntaxError(`Unexpected character at index ${E}`);else if(h===34&&t.charCodeAt(E-1)===61)c=!0;else if(m===-1&&Ai[h]===1)x===-1&&(x=E);else if(x!==-1&&(h===32||h===9))m===-1&&(m=E);else if(h===59||h===44){if(x===-1)throw new SyntaxError(`Unexpected character at index ${E}`);m===-1&&(m=E);let _=t.slice(x,m);s&&(_=_.replace(/\\/g,""),s=!1),Rt(r,l,_),h===44&&(Rt(e,f,r),r=Object.create(null),f=void 0),l=void 0,x=m=-1}else throw new SyntaxError(`Unexpected character at index ${E}`);if(x===-1||c||h===32||h===9)throw new SyntaxError("Unexpected end of input");m===-1&&(m=E);let C=t.slice(x,m);return f===void 0?Rt(e,C,r):(l===void 0?Rt(r,C,!0):s?Rt(r,l,C.replace(/\\/g,"")):Rt(r,l,C),Rt(e,f,r)),e}function tE(t){return Object.keys(t).map(e=>{let r=t[e];return Array.isArray(r)||(r=[r]),r.map(s=>[e].concat(Object.keys(s).map(a=>{let c=s[a];return Array.isArray(c)||(c=[c]),c.map(f=>f===!0?a:`${a}=${f}`).join("; ")})).join("; ")).join(", ")}).join(", ")}Ku.exports={format:tE,parse:eE}});var wo=ne((GI,rx)=>{"use strict";var nE=ae("events"),rE=ae("https"),iE=ae("http"),Vu=ae("net"),sE=ae("tls"),{randomBytes:oE,createHash:aE}=ae("crypto"),{Duplex:HI,Readable:jI}=ae("stream"),{URL:Hc}=ae("url"),wn=vr(),cE=Bc(),dE=Uc(),{isBlob:fE}=Ir(),{BINARY_TYPES:Wu,CLOSE_TIMEOUT:lE,EMPTY_BUFFER:po,GUID:uE,kForOnEventAttribute:jc,kListener:xE,kStatusCode:hE,kWebSocket:Pe,NOOP:Ju}=Ft(),{EventTarget:{addEventListener:pE,removeEventListener:gE}}=Gu(),{format:mE,parse:wE}=ho(),{toBuffer:_E}=bi(),Zu=Symbol("kAborted"),Gc=[8,13],Ht=["CONNECTING","OPEN","CLOSING","CLOSED"],yE=/^[!#$%&'*+\-.0-9A-Z^_`|a-z~]+$/,de=class t extends nE{constructor(e,r,s){super(),this._binaryType=Wu[0],this._closeCode=1006,this._closeFrameReceived=!1,this._closeFrameSent=!1,this._closeMessage=po,this._closeTimer=null,this._errorEmitted=!1,this._extensions={},this._paused=!1,this._protocol="",this._readyState=t.CONNECTING,this._receiver=null,this._sender=null,this._socket=null,e!==null?(this._bufferedAmount=0,this._isServer=!1,this._redirects=0,r===void 0?r=[]:Array.isArray(r)||(typeof r=="object"&&r!==null?(s=r,r=[]):r=[r]),Yu(this,e,r,s)):(this._autoPong=s.autoPong,this._closeTimeout=s.closeTimeout,this._isServer=!0)}get binaryType(){return this._binaryType}set binaryType(e){Wu.includes(e)&&(this._binaryType=e,this._receiver&&(this._receiver._binaryType=e))}get bufferedAmount(){return this._socket?this._socket._writableState.length+this._sender._bufferedBytes:this._bufferedAmount}get extensions(){return Object.keys(this._extensions).join()}get isPaused(){return this._paused}get onclose(){return null}get onerror(){return null}get onopen(){return null}get onmessage(){return null}get protocol(){return this._protocol}get readyState(){return this._readyState}get url(){return this._url}setSocket(e,r,s){let a=new cE({allowSynchronousEvents:s.allowSynchronousEvents,binaryType:this.binaryType,extensions:this._extensions,isServer:this._isServer,maxPayload:s.maxPayload,skipUTF8Validation:s.skipUTF8Validation}),c=new dE(e,this._extensions,s.generateMask);this._receiver=a,this._sender=c,this._socket=e,a[Pe]=this,c[Pe]=this,e[Pe]=this,a.on("conclude",SE),a.on("drain",vE),a.on("error",IE),a.on("message",AE),a.on("ping",CE),a.on("pong",TE),c.onerror=DE,e.setTimeout&&e.setTimeout(0),e.setNoDelay&&e.setNoDelay(),r.length>0&&e.unshift(r),e.on("close",ex),e.on("data",mo),e.on("end",tx),e.on("error",nx),this._readyState=t.OPEN,this.emit("open")}emitClose(){if(!this._socket){this._readyState=t.CLOSED,this.emit("close",this._closeCode,this._closeMessage);return}this._extensions[wn.extensionName]&&this._extensions[wn.extensionName].cleanup(),this._receiver.removeAllListeners(),this._readyState=t.CLOSED,this.emit("close",this._closeCode,this._closeMessage)}close(e,r){if(this.readyState!==t.CLOSED){if(this.readyState===t.CONNECTING){Qe(this,this._req,"WebSocket was closed before the connection was established");return}if(this.readyState===t.CLOSING){this._closeFrameSent&&(this._closeFrameReceived||this._receiver._writableState.errorEmitted)&&this._socket.end();return}this._readyState=t.CLOSING,this._sender.close(e,r,!this._isServer,s=>{s||(this._closeFrameSent=!0,(this._closeFrameReceived||this._receiver._writableState.errorEmitted)&&this._socket.end())}),Qu(this)}}pause(){this.readyState===t.CONNECTING||this.readyState===t.CLOSED||(this._paused=!0,this._socket.pause())}ping(e,r,s){if(this.readyState===t.CONNECTING)throw new Error("WebSocket is not open: readyState 0 (CONNECTING)");if(typeof e=="function"?(s=e,e=r=void 0):typeof r=="function"&&(s=r,r=void 0),typeof e=="number"&&(e=e.toString()),this.readyState!==t.OPEN){Kc(this,e,s);return}r===void 0&&(r=!this._isServer),this._sender.ping(e||po,r,s)}pong(e,r,s){if(this.readyState===t.CONNECTING)throw new Error("WebSocket is not open: readyState 0 (CONNECTING)");if(typeof e=="function"?(s=e,e=r=void 0):typeof r=="function"&&(s=r,r=void 0),typeof e=="number"&&(e=e.toString()),this.readyState!==t.OPEN){Kc(this,e,s);return}r===void 0&&(r=!this._isServer),this._sender.pong(e||po,r,s)}resume(){this.readyState===t.CONNECTING||this.readyState===t.CLOSED||(this._paused=!1,this._receiver._writableState.needDrain||this._socket.resume())}send(e,r,s){if(this.readyState===t.CONNECTING)throw new Error("WebSocket is not open: readyState 0 (CONNECTING)");if(typeof r=="function"&&(s=r,r={}),typeof e=="number"&&(e=e.toString()),this.readyState!==t.OPEN){Kc(this,e,s);return}let a={binary:typeof e!="string",mask:!this._isServer,compress:!0,fin:!0,...r};this._extensions[wn.extensionName]||(a.compress=!1),this._sender.send(e||po,a,s)}terminate(){if(this.readyState!==t.CLOSED){if(this.readyState===t.CONNECTING){Qe(this,this._req,"WebSocket was closed before the connection was established");return}this._socket&&(this._readyState=t.CLOSING,this._socket.destroy())}}};Object.defineProperty(de,"CONNECTING",{enumerable:!0,value:Ht.indexOf("CONNECTING")});Object.defineProperty(de.prototype,"CONNECTING",{enumerable:!0,value:Ht.indexOf("CONNECTING")});Object.defineProperty(de,"OPEN",{enumerable:!0,value:Ht.indexOf("OPEN")});Object.defineProperty(de.prototype,"OPEN",{enumerable:!0,value:Ht.indexOf("OPEN")});Object.defineProperty(de,"CLOSING",{enumerable:!0,value:Ht.indexOf("CLOSING")});Object.defineProperty(de.prototype,"CLOSING",{enumerable:!0,value:Ht.indexOf("CLOSING")});Object.defineProperty(de,"CLOSED",{enumerable:!0,value:Ht.indexOf("CLOSED")});Object.defineProperty(de.prototype,"CLOSED",{enumerable:!0,value:Ht.indexOf("CLOSED")});["binaryType","bufferedAmount","extensions","isPaused","protocol","readyState","url"].forEach(t=>{Object.defineProperty(de.prototype,t,{enumerable:!0})});["open","error","close","message"].forEach(t=>{Object.defineProperty(de.prototype,`on${t}`,{enumerable:!0,get(){for(let e of this.listeners(t))if(e[jc])return e[xE];return null},set(e){for(let r of this.listeners(t))if(r[jc]){this.removeListener(t,r);break}typeof e=="function"&&this.addEventListener(t,e,{[jc]:!0})}})});de.prototype.addEventListener=pE;de.prototype.removeEventListener=gE;rx.exports=de;function Yu(t,e,r,s){let a={allowSynchronousEvents:!0,autoPong:!0,closeTimeout:lE,protocolVersion:Gc[1],maxPayload:104857600,skipUTF8Validation:!1,perMessageDeflate:!0,followRedirects:!1,maxRedirects:10,...s,socketPath:void 0,hostname:void 0,protocol:void 0,timeout:void 0,method:"GET",host:void 0,path:void 0,port:void 0};if(t._autoPong=a.autoPong,t._closeTimeout=a.closeTimeout,!Gc.includes(a.protocolVersion))throw new RangeError(`Unsupported protocol version: ${a.protocolVersion} (supported versions: ${Gc.join(", ")})`);let c;if(e instanceof Hc)c=e;else try{c=new Hc(e)}catch{throw new SyntaxError(`Invalid URL: ${e}`)}c.protocol==="http:"?c.protocol="ws:":c.protocol==="https:"&&(c.protocol="wss:"),t._url=c.href;let f=c.protocol==="wss:",l=c.protocol==="ws+unix:",x;if(c.protocol!=="ws:"&&!f&&!l?x=`The URL's protocol must be one of "ws:", "wss:", "http:", "https:", or "ws+unix:"`:l&&!c.pathname?x="The URL's pathname is empty":c.hash&&(x="The URL contains a fragment identifier"),x){let v=new SyntaxError(x);if(t._redirects===0)throw v;go(t,v);return}let h=f?443:80,m=oE(16).toString("base64"),E=f?rE.request:iE.request,C=new Set,_;if(a.createConnection=a.createConnection||(f?bE:EE),a.defaultPort=a.defaultPort||h,a.port=c.port||h,a.host=c.hostname.startsWith("[")?c.hostname.slice(1,-1):c.hostname,a.headers={...a.headers,"Sec-WebSocket-Version":a.protocolVersion,"Sec-WebSocket-Key":m,Connection:"Upgrade",Upgrade:"websocket"},a.path=c.pathname+c.search,a.timeout=a.handshakeTimeout,a.perMessageDeflate&&(_=new wn({...a.perMessageDeflate,isServer:!1,maxPayload:a.maxPayload}),a.headers["Sec-WebSocket-Extensions"]=mE({[wn.extensionName]:_.offer()})),r.length){for(let v of r){if(typeof v!="string"||!yE.test(v)||C.has(v))throw new SyntaxError("An invalid or duplicated subprotocol was specified");C.add(v)}a.headers["Sec-WebSocket-Protocol"]=r.join(",")}if(a.origin&&(a.protocolVersion<13?a.headers["Sec-WebSocket-Origin"]=a.origin:a.headers.Origin=a.origin),(c.username||c.password)&&(a.auth=`${c.username}:${c.password}`),l){let v=a.path.split(":");a.socketPath=v[0],a.path=v[1]}let y;if(a.followRedirects){if(t._redirects===0){t._originalIpc=l,t._originalSecure=f,t._originalHostOrSocketPath=l?a.socketPath:c.host;let v=s&&s.headers;if(s={...s,headers:{}},v)for(let[I,R]of Object.entries(v))s.headers[I.toLowerCase()]=R}else if(t.listenerCount("redirect")===0){let v=l?t._originalIpc?a.socketPath===t._originalHostOrSocketPath:!1:t._originalIpc?!1:c.host===t._originalHostOrSocketPath;(!v||t._originalSecure&&!f)&&(delete a.headers.authorization,delete a.headers.cookie,v||delete a.headers.host,a.auth=void 0)}a.auth&&!s.headers.authorization&&(s.headers.authorization="Basic "+Buffer.from(a.auth).toString("base64")),y=t._req=E(a),t._redirects&&t.emit("redirect",t.url,y)}else y=t._req=E(a);a.timeout&&y.on("timeout",()=>{Qe(t,y,"Opening handshake has timed out")}),y.on("error",v=>{y===null||y[Zu]||(y=t._req=null,go(t,v))}),y.on("response",v=>{let I=v.headers.location,R=v.statusCode;if(I&&a.followRedirects&&R>=300&&R<400){if(++t._redirects>a.maxRedirects){Qe(t,y,"Maximum redirects exceeded");return}y.abort();let L;try{L=new Hc(I,e)}catch{let A=new SyntaxError(`Invalid URL: ${I}`);go(t,A);return}Yu(t,L,r,s)}else t.emit("unexpected-response",y,v)||Qe(t,y,`Unexpected server response: ${v.statusCode}`)}),y.on("upgrade",(v,I,R)=>{if(t.emit("upgrade",v),t.readyState!==de.CONNECTING)return;y=t._req=null;let L=v.headers.upgrade;if(L===void 0||L.toLowerCase()!=="websocket"){Qe(t,I,"Invalid Upgrade header");return}let w=aE("sha1").update(m+uE).digest("base64");if(v.headers["sec-websocket-accept"]!==w){Qe(t,I,"Invalid Sec-WebSocket-Accept header");return}let A=v.headers["sec-websocket-protocol"],k;if(A!==void 0?C.size?C.has(A)||(k="Server sent an invalid subprotocol"):k="Server sent a subprotocol but none was requested":C.size&&(k="Server sent no subprotocol"),k){Qe(t,I,k);return}A&&(t._protocol=A);let F=v.headers["sec-websocket-extensions"];if(F!==void 0){if(!_){Qe(t,I,"Server sent a Sec-WebSocket-Extensions header but no extension was requested");return}let z;try{z=wE(F)}catch{Qe(t,I,"Invalid Sec-WebSocket-Extensions header");return}let O=Object.keys(z);if(O.length!==1||O[0]!==wn.extensionName){Qe(t,I,"Server indicated an extension that was not requested");return}try{_.accept(z[wn.extensionName])}catch{Qe(t,I,"Invalid Sec-WebSocket-Extensions header");return}t._extensions[wn.extensionName]=_}t.setSocket(I,R,{allowSynchronousEvents:a.allowSynchronousEvents,generateMask:a.generateMask,maxPayload:a.maxPayload,skipUTF8Validation:a.skipUTF8Validation})}),a.finishRequest?a.finishRequest(y,t):y.end()}function go(t,e){t._readyState=de.CLOSING,t._errorEmitted=!0,t.emit("error",e),t.emitClose()}function EE(t){return t.path=t.socketPath,Vu.connect(t)}function bE(t){return t.path=void 0,!t.servername&&t.servername!==""&&(t.servername=Vu.isIP(t.host)?"":t.host),sE.connect(t)}function Qe(t,e,r){t._readyState=de.CLOSING;let s=new Error(r);Error.captureStackTrace(s,Qe),e.setHeader?(e[Zu]=!0,e.abort(),e.socket&&!e.socket.destroyed&&e.socket.destroy(),process.nextTick(go,t,s)):(e.destroy(s),e.once("error",t.emit.bind(t,"error")),e.once("close",t.emitClose.bind(t)))}function Kc(t,e,r){if(e){let s=fE(e)?e.size:_E(e).length;t._socket?t._sender._bufferedBytes+=s:t._bufferedAmount+=s}if(r){let s=new Error(`WebSocket is not open: readyState ${t.readyState} (${Ht[t.readyState]})`);process.nextTick(r,s)}}function SE(t,e){let r=this[Pe];r._closeFrameReceived=!0,r._closeMessage=e,r._closeCode=t,r._socket[Pe]!==void 0&&(r._socket.removeListener("data",mo),process.nextTick(Xu,r._socket),t===1005?r.close():r.close(t,e))}function vE(){let t=this[Pe];t.isPaused||t._socket.resume()}function IE(t){let e=this[Pe];e._socket[Pe]!==void 0&&(e._socket.removeListener("data",mo),process.nextTick(Xu,e._socket),e.close(t[hE])),e._errorEmitted||(e._errorEmitted=!0,e.emit("error",t))}function $u(){this[Pe].emitClose()}function AE(t,e){this[Pe].emit("message",t,e)}function CE(t){let e=this[Pe];e._autoPong&&e.pong(t,!this._isServer,Ju),e.emit("ping",t)}function TE(t){this[Pe].emit("pong",t)}function Xu(t){t.resume()}function DE(t){let e=this[Pe];e.readyState!==de.CLOSED&&(e.readyState===de.OPEN&&(e._readyState=de.CLOSING,Qu(e)),this._socket.end(),e._errorEmitted||(e._errorEmitted=!0,e.emit("error",t)))}function Qu(t){t._closeTimer=setTimeout(t._socket.destroy.bind(t._socket),t._closeTimeout)}function ex(){let t=this[Pe];if(this.removeListener("close",ex),this.removeListener("data",mo),this.removeListener("end",tx),t._readyState=de.CLOSING,!this._readableState.endEmitted&&!t._closeFrameReceived&&!t._receiver._writableState.errorEmitted&&this._readableState.length!==0){let e=this.read(this._readableState.length);t._receiver.write(e)}t._receiver.end(),this[Pe]=void 0,clearTimeout(t._closeTimer),t._receiver._writableState.finished||t._receiver._writableState.errorEmitted?t.emitClose():(t._receiver.on("error",$u),t._receiver.on("finish",$u))}function mo(t){this[Pe]._receiver.write(t)||this.pause()}function tx(){let t=this[Pe];t._readyState=de.CLOSING,t._receiver.end(),this.end()}function nx(){let t=this[Pe];this.removeListener("error",nx),this.on("error",Ju),t&&(t._readyState=de.CLOSING,this.destroy())}});var ax=ne((WI,ox)=>{"use strict";var KI=wo(),{Duplex:RE}=ae("stream");function ix(t){t.emit("close")}function kE(){!this.destroyed&&this._writableState.finished&&this.destroy()}function sx(t){this.removeListener("error",sx),this.destroy(),this.listenerCount("error")===0&&this.emit("error",t)}function OE(t,e){let r=!0,s=new RE({...e,autoDestroy:!1,emitClose:!1,objectMode:!1,writableObjectMode:!1});return t.on("message",function(c,f){let l=!f&&s._readableState.objectMode?c.toString():c;s.push(l)||t.pause()}),t.once("error",function(c){s.destroyed||(r=!1,s.destroy(c))}),t.once("close",function(){s.destroyed||s.push(null)}),s._destroy=function(a,c){if(t.readyState===t.CLOSED){c(a),process.nextTick(ix,s);return}let f=!1;t.once("error",function(x){f=!0,c(x)}),t.once("close",function(){f||c(a),process.nextTick(ix,s)}),r&&t.terminate()},s._final=function(a){if(t.readyState===t.CONNECTING){t.once("open",function(){s._final(a)});return}t._socket!==null&&(t._socket._writableState.finished?(a(),s._readableState.endEmitted&&s.destroy()):(t._socket.once("finish",function(){a()}),t.close()))},s._read=function(){t.isPaused&&t.resume()},s._write=function(a,c,f){if(t.readyState===t.CONNECTING){t.once("open",function(){s._write(a,c,f)});return}t.send(a,f)},s.on("end",kE),s.on("error",sx),s}ox.exports=OE});var Wc=ne(($I,cx)=>{"use strict";var{tokenChars:PE}=Ir();function LE(t){let e=new Set,r=-1,s=-1,a=0;for(a;a<t.length;a++){let f=t.charCodeAt(a);if(s===-1&&PE[f]===1)r===-1&&(r=a);else if(a!==0&&(f===32||f===9))s===-1&&r!==-1&&(s=a);else if(f===44){if(r===-1)throw new SyntaxError(`Unexpected character at index ${a}`);s===-1&&(s=a);let l=t.slice(r,s);if(e.has(l))throw new SyntaxError(`The "${l}" subprotocol is duplicated`);e.add(l),r=s=-1}else throw new SyntaxError(`Unexpected character at index ${a}`)}if(r===-1||s!==-1)throw new SyntaxError("Unexpected end of input");let c=t.slice(r,a);if(e.has(c))throw new SyntaxError(`The "${c}" subprotocol is duplicated`);return e.add(c),e}cx.exports={parse:LE}});var px=ne((JI,hx)=>{"use strict";var NE=ae("events"),_o=ae("http"),{Duplex:VI}=ae("stream"),{createHash:ME}=ae("crypto"),dx=ho(),zn=vr(),BE=Wc(),zE=wo(),{CLOSE_TIMEOUT:FE,GUID:UE,kWebSocket:qE}=Ft(),HE=/^[+/0-9A-Za-z]{22}==$/,fx=0,lx=1,xx=2,$c=class extends NE{constructor(e,r){if(super(),e={allowSynchronousEvents:!0,autoPong:!0,maxPayload:100*1024*1024,skipUTF8Validation:!1,perMessageDeflate:!1,handleProtocols:null,clientTracking:!0,closeTimeout:FE,verifyClient:null,noServer:!1,backlog:null,server:null,host:null,path:null,port:null,WebSocket:zE,...e},e.port==null&&!e.server&&!e.noServer||e.port!=null&&(e.server||e.noServer)||e.server&&e.noServer)throw new TypeError('One and only one of the "port", "server", or "noServer" options must be specified');if(e.port!=null?(this._server=_o.createServer((s,a)=>{let c=_o.STATUS_CODES[426];a.writeHead(426,{"Content-Length":c.length,"Content-Type":"text/plain"}),a.end(c)}),this._server.listen(e.port,e.host,e.backlog,r)):e.server&&(this._server=e.server),this._server){let s=this.emit.bind(this,"connection");this._removeListeners=jE(this._server,{listening:this.emit.bind(this,"listening"),error:this.emit.bind(this,"error"),upgrade:(a,c,f)=>{this.handleUpgrade(a,c,f,s)}})}e.perMessageDeflate===!0&&(e.perMessageDeflate={}),e.clientTracking&&(this.clients=new Set,this._shouldEmitClose=!1),this.options=e,this._state=fx}address(){if(this.options.noServer)throw new Error('The server is operating in "noServer" mode');return this._server?this._server.address():null}close(e){if(this._state===xx){e&&this.once("close",()=>{e(new Error("The server is not running"))}),process.nextTick(Ci,this);return}if(e&&this.once("close",e),this._state!==lx)if(this._state=lx,this.options.noServer||this.options.server)this._server&&(this._removeListeners(),this._removeListeners=this._server=null),this.clients?this.clients.size?this._shouldEmitClose=!0:process.nextTick(Ci,this):process.nextTick(Ci,this);else{let r=this._server;this._removeListeners(),this._removeListeners=this._server=null,r.close(()=>{Ci(this)})}}shouldHandle(e){if(this.options.path){let r=e.url.indexOf("?");if((r!==-1?e.url.slice(0,r):e.url)!==this.options.path)return!1}return!0}handleUpgrade(e,r,s,a){r.on("error",ux);let c=e.headers["sec-websocket-key"],f=e.headers.upgrade,l=+e.headers["sec-websocket-version"];if(e.method!=="GET"){Fn(this,e,r,405,"Invalid HTTP method");return}if(f===void 0||f.toLowerCase()!=="websocket"){Fn(this,e,r,400,"Invalid Upgrade header");return}if(c===void 0||!HE.test(c)){Fn(this,e,r,400,"Missing or invalid Sec-WebSocket-Key header");return}if(l!==13&&l!==8){Fn(this,e,r,400,"Missing or invalid Sec-WebSocket-Version header",{"Sec-WebSocket-Version":"13, 8"});return}if(!this.shouldHandle(e)){Ti(r,400);return}let x=e.headers["sec-websocket-protocol"],h=new Set;if(x!==void 0)try{h=BE.parse(x)}catch{Fn(this,e,r,400,"Invalid Sec-WebSocket-Protocol header");return}let m=e.headers["sec-websocket-extensions"],E={};if(this.options.perMessageDeflate&&m!==void 0){let C=new zn({...this.options.perMessageDeflate,isServer:!0,maxPayload:this.options.maxPayload});try{let _=dx.parse(m);_[zn.extensionName]&&(C.accept(_[zn.extensionName]),E[zn.extensionName]=C)}catch{Fn(this,e,r,400,"Invalid or unacceptable Sec-WebSocket-Extensions header");return}}if(this.options.verifyClient){let C={origin:e.headers[`${l===8?"sec-websocket-origin":"origin"}`],secure:!!(e.socket.authorized||e.socket.encrypted),req:e};if(this.options.verifyClient.length===2){this.options.verifyClient(C,(_,y,v,I)=>{if(!_)return Ti(r,y||401,v,I);this.completeUpgrade(E,c,h,e,r,s,a)});return}if(!this.options.verifyClient(C))return Ti(r,401)}this.completeUpgrade(E,c,h,e,r,s,a)}completeUpgrade(e,r,s,a,c,f,l){if(!c.readable||!c.writable)return c.destroy();if(c[qE])throw new Error("server.handleUpgrade() was called more than once with the same socket, possibly due to a misconfiguration");if(this._state>fx)return Ti(c,503);let h=["HTTP/1.1 101 Switching Protocols","Upgrade: websocket","Connection: Upgrade",`Sec-WebSocket-Accept: ${ME("sha1").update(r+UE).digest("base64")}`],m=new this.options.WebSocket(null,void 0,this.options);if(s.size){let E=this.options.handleProtocols?this.options.handleProtocols(s,a):s.values().next().value;E&&(h.push(`Sec-WebSocket-Protocol: ${E}`),m._protocol=E)}if(e[zn.extensionName]){let E=e[zn.extensionName].params,C=dx.format({[zn.extensionName]:[E]});h.push(`Sec-WebSocket-Extensions: ${C}`),m._extensions=e}this.emit("headers",h,a),c.write(h.concat(`\r
|
|
13
13
|
`).join(`\r
|
|
14
|
-
`)),c.removeListener("error",
|
|
14
|
+
`)),c.removeListener("error",ux),m.setSocket(c,f,{allowSynchronousEvents:this.options.allowSynchronousEvents,maxPayload:this.options.maxPayload,skipUTF8Validation:this.options.skipUTF8Validation}),this.clients&&(this.clients.add(m),m.on("close",()=>{this.clients.delete(m),this._shouldEmitClose&&!this.clients.size&&process.nextTick(Ci,this)})),l(m,a)}};hx.exports=$c;function jE(t,e){for(let r of Object.keys(e))t.on(r,e[r]);return function(){for(let s of Object.keys(e))t.removeListener(s,e[s])}}function Ci(t){t._state=xx,t.emit("close")}function ux(){this.destroy()}function Ti(t,e,r,s){r=r||_o.STATUS_CODES[e],s={Connection:"close","Content-Type":"text/html","Content-Length":Buffer.byteLength(r),...s},t.once("finish",t.destroy),t.end(`HTTP/1.1 ${e} ${_o.STATUS_CODES[e]}\r
|
|
15
15
|
`+Object.keys(s).map(a=>`${a}: ${s[a]}`).join(`\r
|
|
16
16
|
`)+`\r
|
|
17
17
|
\r
|
|
18
|
-
`+r)}function
|
|
18
|
+
`+r)}function Fn(t,e,r,s,a,c){if(t.listenerCount("wsClientError")){let f=new Error(a);Error.captureStackTrace(f,Fn),t.emit("wsClientError",f,r,e)}else Ti(r,s,a,c)}});import{existsSync as mb,openSync as wb}from"node:fs";import{mkdir as _b}from"node:fs/promises";import{dirname as yb}from"node:path";import{fileURLToPath as Eb}from"node:url";function Yc(t=te()){return mb(t.libEntry)?t.libEntry:Eb(new URL("../index.ts",import.meta.url))}async function Xc(t={}){let e=t.paths??te(),r=t.entryOverride??Yc(e);await _b(yb(e.logFile),{recursive:!0});let s=wb(e.logFile,"a"),c=r.endsWith(".ts")?["--import","tsx/esm",r,"--daemon"]:[r,"--daemon"],f=Vt(process.execPath,c,{detached:!0,stdio:["ignore",s,s],env:{...process.env,COZE_BRIDGE_DAEMON:"1"}});if(f.unref(),typeof f.pid!="number")throw new Error("failed to spawn daemon (no pid)");return bb.info("daemon spawned",{pid:f.pid,entry:r}),{pid:f.pid,entry:r}}var bb,Qc=dt(()=>{"use strict";Wn();ee();Me();bb=H("spawn-daemon")});import{spawn as Bb}from"node:child_process";import{mkdir as zb,unlink as Fb,writeFile as Ub}from"node:fs/promises";import{dirname as qb,join as Hb}from"node:path";function To(t){return t.replace(/&/g,"&").replace(/</g,"<").replace(/>/g,">").replace(/"/g,""")}function zx(t,e){return new Promise((r,s)=>{let a=Bb(t,e,{stdio:["ignore","pipe","pipe"]}),c="";a.stderr?.on("data",f=>{c+=f.toString("utf8")}),a.on("error",s),a.on("close",f=>{f===0?r():s(new Error(`${t} ${e.join(" ")} exited ${f}: ${c.trim()}`))})})}var Co,r0,i0,Fx=dt(()=>{"use strict";ee();Co=H("supervisor.launchd"),r0="ai.coze.bridge",i0={platform:"darwin",renderConfig(t){return`<?xml version="1.0" encoding="UTF-8"?>
|
|
19
19
|
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
|
|
20
20
|
<plist version="1.0">
|
|
21
21
|
<dict>
|
|
22
22
|
<key>Label</key>
|
|
23
|
-
<string>${
|
|
23
|
+
<string>${r0}</string>
|
|
24
24
|
<key>ProgramArguments</key>
|
|
25
25
|
<array>
|
|
26
|
-
<string>${
|
|
27
|
-
<string>${
|
|
26
|
+
<string>${To(t.nodeBin)}</string>
|
|
27
|
+
<string>${To(t.entry)}</string>
|
|
28
28
|
<string>--daemon</string>
|
|
29
29
|
</array>
|
|
30
30
|
<key>RunAtLoad</key>
|
|
@@ -34,12 +34,12 @@ ${t.stack??""}`:String(t);return hp.test(r)||pp.test(r)}function U0(t){if(t==nul
|
|
|
34
34
|
<key>ThrottleInterval</key>
|
|
35
35
|
<integer>10</integer>
|
|
36
36
|
<key>StandardOutPath</key>
|
|
37
|
-
<string>${
|
|
37
|
+
<string>${To(t.logFile)}</string>
|
|
38
38
|
<key>StandardErrorPath</key>
|
|
39
|
-
<string>${
|
|
39
|
+
<string>${To(t.logFile)}</string>
|
|
40
40
|
</dict>
|
|
41
41
|
</plist>
|
|
42
|
-
`},configPath(t){return
|
|
42
|
+
`},configPath(t){return Hb(t.homeDir,"Library","LaunchAgents",`${r0}.plist`)},async install(t){let e=this.configPath(t);await zb(qb(e),{recursive:!0}),await Ub(e,this.renderConfig(t),"utf8"),Co.info("plist written",{plistPath:e}),await zx("launchctl",["load","-w",e]),Co.info("launchd job loaded",{label:r0})},async uninstall(t){let e=this.configPath(t);await zx("launchctl",["unload","-w",e]).catch(r=>Co.warn("launchctl unload failed (ignored)",{err:String(r)})),await Fb(e).catch(r=>{if(r.code!=="ENOENT")throw r}),Co.info("launchd job removed",{plistPath:e})}}});import{spawn as jb}from"node:child_process";import{mkdir as Gb,unlink as Kb,writeFile as Wb}from"node:fs/promises";import{dirname as $b,join as Vb}from"node:path";function ko(t,e){return new Promise((r,s)=>{let a=jb(t,e,{stdio:["ignore","pipe","pipe"]}),c="";a.stderr?.on("data",f=>{c+=f.toString("utf8")}),a.on("error",s),a.on("close",f=>{f===0?r():s(new Error(`${t} ${e.join(" ")} exited ${f}: ${c.trim()}`))})})}var Do,Ro,s0,Ux=dt(()=>{"use strict";ee();Do=H("supervisor.systemd"),Ro="coze-bridge.service",s0={platform:"linux",renderConfig(t){return`[Unit]
|
|
43
43
|
Description=Coze Bridge daemon
|
|
44
44
|
After=network.target
|
|
45
45
|
|
|
@@ -53,7 +53,7 @@ StandardError=append:${t.logFile}
|
|
|
53
53
|
|
|
54
54
|
[Install]
|
|
55
55
|
WantedBy=default.target
|
|
56
|
-
`},configPath(t){return
|
|
56
|
+
`},configPath(t){return Vb(t.homeDir,".config","systemd","user",Ro)},async install(t){let e=this.configPath(t);await Gb($b(e),{recursive:!0}),await Wb(e,this.renderConfig(t),"utf8"),Do.info("systemd unit written",{unitPath:e}),await ko("systemctl",["--user","daemon-reload"]),await ko("systemctl",["--user","enable","--now",Ro]),Do.info("systemd unit enabled",{unitName:Ro})},async uninstall(t){let e=this.configPath(t);await ko("systemctl",["--user","disable","--now",Ro]).catch(r=>Do.warn("systemctl disable failed (ignored)",{err:String(r)})),await Kb(e).catch(r=>{if(r.code!=="ENOENT")throw r}),await ko("systemctl",["--user","daemon-reload"]).catch(()=>{}),Do.info("systemd unit removed",{unitPath:e})}}});import{spawn as Jb}from"node:child_process";import{join as Zb}from"node:path";function qx(t,e){return new Promise((r,s)=>{let a=Jb(t,e,{stdio:["ignore","pipe","pipe"],shell:!1}),c="";a.stderr?.on("data",f=>{c+=f.toString("utf8")}),a.on("error",s),a.on("close",f=>{f===0?r():s(new Error(`${t} ${e.join(" ")} exited ${f}: ${c.trim()}`))})})}var o0,Oo,a0,Hx=dt(()=>{"use strict";ee();o0=H("supervisor.taskscheduler"),Oo="CozeBridge",a0={platform:"win32",renderConfig(t){return`<?xml version="1.0" encoding="UTF-16"?>
|
|
57
57
|
<Task version="1.2" xmlns="http://schemas.microsoft.com/windows/2004/02/mit/task">
|
|
58
58
|
<RegistrationInfo>
|
|
59
59
|
<Description>Coze Bridge daemon</Description>
|
|
@@ -77,63 +77,29 @@ WantedBy=default.target
|
|
|
77
77
|
</Exec>
|
|
78
78
|
</Actions>
|
|
79
79
|
</Task>
|
|
80
|
-
`},configPath(t){return tv(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 jx("schtasks",["/Create","/SC","ONLOGON","/TN",Mo,"/TR",r,"/RU",t.userName,"/F"]),f0.info("task scheduler entry created",{task:Mo,logFile:t.logFile})},async uninstall(t){await jx("schtasks",["/Delete","/TN",Mo,"/F"]).catch(e=>f0.warn("schtasks /Delete failed (ignored)",{err:String(e)})),f0.info("task scheduler entry removed",{task:Mo})}}});var Wx={};Vo(Wx,{buildContext:()=>sv,getSupervisor:()=>iv,launchdSupervisor:()=>a0,systemdSupervisor:()=>c0,taskSchedulerSupervisor:()=>d0});import{homedir as nv,userInfo as rv}from"node:os";function iv(t=process.platform){switch(t){case"darwin":return a0;case"linux":return c0;case"win32":return d0;default:throw new Error(`unsupported platform for OS supervisor: ${t}`)}}function sv(){let t=se();return{nodeBin:process.execPath,entry:e0(t),logFile:t.logFile,homeDir:nv(),userName:rv().username}}var Kx=dt(()=>{"use strict";qe();n0();qx();Hx();Gx()});ie();Xt();var j0=$("acp-installer-warmup"),bp=["claude-code","codex"];async function G0(t={}){let e=t.ensure??bn,s=(await Promise.allSettled(bp.map(async a=>{let c=await e(a);j0.info("acp wrapper warmup ok",{framework:a,installed:!!c,path:c??""})}))).filter(a=>a.status==="rejected");s.length>0&&j0.warn("acp wrapper warmup partial failure (acp-installer negative cache 5min \u5185\u4E0D\u91CD\u8BD5)",{failedCount:s.length,reasons:s.map(a=>String(a.reason))})}Yt();ie();import{readdir as Np}from"node:fs/promises";import{mkdir as Z0,writeFile as X0}from"node:fs/promises";import{join as ea}from"node:path";var kp={"claude-code":"CLAUDE.md",codex:"AGENTS.md",openclaw:"SOUL.md"};async function Xn(t,e,r,s){await Z0(t,{recursive:!0});let a=kp[e],c=ea(t,a),d=Lp(e,r,s);return await X0(c,d,"utf8"),c}async function Y0(t){let e=ea(t,".claude");await Z0(e,{recursive:!0});let r=ea(e,"settings.local.json"),s=JSON.stringify({permissions:{defaultMode:"bypassPermissions"}},null,2);return await X0(r,s,"utf8"),r}function Lp(t,e,r){let s=`# Coze Agent: ${e}
|
|
81
|
-
|
|
82
|
-
> framework: \`${t}\`
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
`)?r:`${r}
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
${a}
|
|
90
|
-
${Op()}`}function Op(){let t=process.platform==="win32"?"coze-bridge.cmd":"coze-bridge";return Pp.replace(/\bcoze-bridge\b(?!\.cmd)/g,t)}var Pp=`## \u53D1\u9001\u6587\u4EF6 / \u56FE\u7247\u7ED9\u7528\u6237
|
|
91
|
-
|
|
92
|
-
\u6BCF\u6761\u7528\u6237\u6D88\u606F\u5F00\u5934\u4F1A\u6709\u4E91\u7AEF\u6CE8\u5165\u7684 \`<coze-context>\` \u5757, \u5F62\u5982:
|
|
93
|
-
|
|
94
|
-
<coze-context>
|
|
95
|
-
agentId: <\u4F60\u7684 agentId>
|
|
96
|
-
sessionId: <\u5F53\u524D\u5BF9\u8BDD sessionId>
|
|
97
|
-
</coze-context>
|
|
98
|
-
|
|
99
|
-
\u4ECE\u4E2D\u63D0\u53D6\u4E24\u4E2A ID, \u7528 bash tool \u8C03 \`coze-bridge\` (daemon \u5DF2\u628A\u5B83\u524D\u7F6E\u5230\u5B50\u8FDB\u7A0B PATH,
|
|
100
|
-
\u8DE8\u5E73\u53F0\u76F4\u63A5\u88F8\u547D\u4EE4\u8C03\u7528, \u65E0\u9700\u7EDD\u5BF9\u8DEF\u5F84):
|
|
101
|
-
|
|
102
|
-
coze-bridge send image <path> --agent-id <agentId> --session-id <sessionId> [--caption "\u8BF4\u660E\u6587\u5B57"]
|
|
103
|
-
coze-bridge send file <path> --agent-id <agentId> --session-id <sessionId> [--caption "..."] [--name "report.pdf"]
|
|
104
|
-
|
|
105
|
-
\u7EA6\u675F:
|
|
106
|
-
- path \u5FC5\u987B\u5728\u5F53\u524D workspace \u5B50\u6811\u4E0B (\u7EDD\u5BF9\u6216\u76F8\u5BF9\u7686\u53EF)
|
|
107
|
-
- \u5355\u6587\u4EF6 \u2264 50MB
|
|
108
|
-
- \u652F\u6301: image/png|jpeg|webp|gif, application/pdf, text/plain|markdown
|
|
109
|
-
- \u547D\u4EE4\u540C\u6B65\u7B49\u8FD4\u56DE (\u4E00\u822C 1-30s \u89C6\u6587\u4EF6\u5927\u5C0F), \u9000 0 \u5373\u5DF2\u9001\u8FBE
|
|
110
|
-
- \u5931\u8D25\u9519\u8BEF\u4FE1\u606F\u5728 stderr, \u770B\u5B8C\u518D\u8C03\u6574\u91CD\u8BD5
|
|
111
|
-
- \`sessionId\` \u5FC5\u987B\u7528\u4E91\u7AEF \`<coze-context>\` \u7ED9\u7684 ID, **\u4E0D\u8981**\u81EA\u5DF1\u7F16\u6216\u8005\u7528\u5176\u5B83\u6765\u6E90
|
|
112
|
-
|
|
113
|
-
\u26A0\uFE0F \u751F\u6210\u6587\u4EF6\u540E\u8BF7**\u7B49\u6587\u4EF6\u5B8C\u6574\u5199\u76D8**\u518D send (\u7528 \`&&\` \u4E32\u884C, \u4E0D\u8981 \`&\` \u540E\u53F0)\u3002
|
|
114
|
-
`;var Xe=$("agent-detail-sync"),Mp=6e4,Bp=5*6e4,Vi=class{constructor(e){this.opts=e}opts;retryQueue=new Map;async syncAll(e){let r=this.opts.paths.agentsRoot,s;try{s=await Np(r)}catch(a){Xe.info("agents dir not found, skip detail sync",{root:r,err:String(a)});return}Xe.info("starting detail sync",{reason:e,count:s.length}),await Promise.allSettled(s.map(async a=>{let c=await We(a,this.opts.paths).catch(()=>null);if(c){if(c.disconnectedAt){Xe.debug("detail sync: skip disconnected agent",{agentId:a});return}try{await this.syncOne(a,c)}catch(d){Xe.warn("detail sync failed for agent, skipping",{agentId:a,err:String(d)})}}})),Xe.info("detail sync done",{reason:e})}async retryPending(){if(this.retryQueue.size===0)return;let e=Date.now(),r=[];for(let[s,a]of this.retryQueue)e>=a.dueAt&&r.push(s);if(r.length!==0){Xe.info("retrying pending detail syncs",{count:r.length});for(let s of r)try{await this.syncOne(s)}catch(a){Xe.debug("detail sync retry still failing, will try again",{agentId:s,err:String(a)})}}}async syncOne(e,r){let s=r??await We(e,this.opts.paths);if(!s){Xe.info("detail sync: agent config missing, skip",{agentId:e});return}let a;try{a=await this.opts.sendDetail({_meta:{cozeAgentId:e}}),this.retryQueue.delete(e)}catch(u){Xe.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,Bp):Mp;this.retryQueue.set(e,{dueAt:Date.now()+p,currentDelay:p});return}if(a.agentId&&a.agentId!==e){Xe.warn("detail response agentId mismatch, ignoring",{agentId:e,responseAgentId:a.agentId});return}let c=!1,d=!1;if(a.agentName&&a.agentName!==s.agentName&&(s.agentName=a.agentName,c=!0),a.description!==void 0&&a.description!==s.description&&(s.description=a.description,c=!0),a.cozeIdentity&&a.cozeIdentity!==s.cozeIdentity&&(s.cozeIdentity=a.cozeIdentity,c=!0,d=!0),a.deployType&&Xe.info("detail.deployType",{agentId:e,deployType:a.deployType}),!c){Xe.debug("detail sync: no diff",{agentId:e});return}await Ze(s,this.opts.paths),Xe.info("detail sync: config updated",{agentId:e,identityChanged:d,agentName:s.agentName}),d&&(await Xn(s.workspace,s.framework,e,s.cozeIdentity),this.opts.handlers.reloadAgentSessionsPublic(e,"detail-sync"))}};var pu=mt(Lf(),1);import{lstat as xc,mkdir as hc,readFile as uu,readdir as fw,rm as dw,stat as uw,writeFile as pc}from"node:fs/promises";import{dirname as lw,join as Ct,normalize as xw,relative as wc,resolve as gc,sep as lu}from"node:path";import{Readable as xu}from"node:stream";import{pipeline as hu}from"node:stream/promises";import sg from"events";import Je from"fs";import{EventEmitter as Qa}from"node:events";import xd from"node:stream";import{StringDecoder as og}from"node:string_decoder";import gd from"node:path";import fr from"node:fs";import{dirname as _g,parse as yg}from"path";import{EventEmitter as Tg}from"events";import Pa from"assert";import{Buffer as Ln}from"buffer";import*as Bf from"zlib";import Dg from"zlib";import{posix as nr}from"node:path";import{basename as nm}from"node:path";import Cs from"fs";import bt from"fs";import Gf from"path";import{win32 as xm}from"node:path";import Xf from"path";import kd from"node:fs";import Rm from"node:assert";import{randomBytes as Ld}from"node:crypto";import ne from"node:fs";import De from"node:path";import Od from"fs";import Ns from"node:fs";import ri from"node:path";import et from"node:fs";import Bm from"node:fs/promises";import Ds from"node:path";import{join as Gd}from"node:path";import Qe from"node:fs";import $d from"node:path";var rg=Object.defineProperty,ig=(t,e)=>{for(var r in e)rg(t,r,{get:e[r],enumerable:!0})},Of=typeof process=="object"&&process?process:{stdout:null,stderr:null},ag=t=>!!t&&typeof t=="object"&&(t instanceof Nn||t instanceof xd||cg(t)||fg(t)),cg=t=>!!t&&typeof t=="object"&&t instanceof Qa&&typeof t.pipe=="function"&&t.pipe!==xd.Writable.prototype.pipe,fg=t=>!!t&&typeof t=="object"&&t instanceof Qa&&typeof t.write=="function"&&typeof t.end=="function",Ot=Symbol("EOF"),Pt=Symbol("maybeEmitEnd"),en=Symbol("emittedEnd"),Qi=Symbol("emittingEnd"),Ur=Symbol("emittedError"),es=Symbol("closed"),Pf=Symbol("read"),ts=Symbol("flush"),Nf=Symbol("flushChunk"),ut=Symbol("encoding"),tr=Symbol("decoder"),Le=Symbol("flowing"),qr=Symbol("paused"),or=Symbol("resume"),Oe=Symbol("buffer"),$e=Symbol("pipes"),Pe=Symbol("bufferLength"),oa=Symbol("bufferPush"),ns=Symbol("bufferShift"),Ke=Symbol("objectMode"),ve=Symbol("destroyed"),aa=Symbol("error"),ca=Symbol("emitData"),Mf=Symbol("emitEnd"),fa=Symbol("emitEnd2"),wt=Symbol("async"),da=Symbol("abort"),rs=Symbol("aborted"),Hr=Symbol("signal"),vn=Symbol("dataListeners"),Ye=Symbol("discarded"),jr=t=>Promise.resolve().then(t),dg=t=>t(),ug=t=>t==="end"||t==="finish"||t==="prefinish",lg=t=>t instanceof ArrayBuffer||!!t&&typeof t=="object"&&t.constructor&&t.constructor.name==="ArrayBuffer"&&t.byteLength>=0,xg=t=>!Buffer.isBuffer(t)&&ArrayBuffer.isView(t),hd=class{src;dest;opts;ondrain;constructor(t,e,r){this.src=t,this.dest=e,this.opts=r,this.ondrain=()=>t[or](),this.dest.on("drain",this.ondrain)}unpipe(){this.dest.removeListener("drain",this.ondrain)}proxyErrors(t){}end(){this.unpipe(),this.opts.end&&this.dest.end()}},hg=class extends hd{unpipe(){this.src.removeListener("error",this.proxyErrors),super.unpipe()}constructor(t,e,r){super(t,e,r),this.proxyErrors=s=>this.dest.emit("error",s),t.on("error",this.proxyErrors)}},pg=t=>!!t.objectMode,gg=t=>!t.objectMode&&!!t.encoding&&t.encoding!=="buffer",Nn=class extends Qa{[Le]=!1;[qr]=!1;[$e]=[];[Oe]=[];[Ke];[ut];[wt];[tr];[Ot]=!1;[en]=!1;[Qi]=!1;[es]=!1;[Ur]=null;[Pe]=0;[ve]=!1;[Hr];[rs]=!1;[vn]=0;[Ye]=!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");pg(e)?(this[Ke]=!0,this[ut]=null):gg(e)?(this[ut]=e.encoding,this[Ke]=!1):(this[Ke]=!1,this[ut]=null),this[wt]=!!e.async,this[tr]=this[ut]?new og(this[ut]):null,e&&e.debugExposeBuffer===!0&&Object.defineProperty(this,"buffer",{get:()=>this[Oe]}),e&&e.debugExposePipes===!0&&Object.defineProperty(this,"pipes",{get:()=>this[$e]});let{signal:r}=e;r&&(this[Hr]=r,r.aborted?this[da]():r.addEventListener("abort",()=>this[da]()))}get bufferLength(){return this[Pe]}get encoding(){return this[ut]}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[Ke]}set objectMode(t){throw new Error("objectMode must be set at instantiation time")}get async(){return this[wt]}set async(t){this[wt]=this[wt]||!!t}[da](){this[rs]=!0,this.emit("abort",this[Hr]?.reason),this.destroy(this[Hr]?.reason)}get aborted(){return this[rs]}set aborted(t){}write(t,e,r){if(this[rs])return!1;if(this[Ot])throw new Error("write after end");if(this[ve])return this.emit("error",Object.assign(new Error("Cannot call write after a stream was destroyed"),{code:"ERR_STREAM_DESTROYED"})),!0;typeof e=="function"&&(r=e,e="utf8"),e||(e="utf8");let s=this[wt]?jr:dg;if(!this[Ke]&&!Buffer.isBuffer(t)){if(xg(t))t=Buffer.from(t.buffer,t.byteOffset,t.byteLength);else if(lg(t))t=Buffer.from(t);else if(typeof t!="string")throw new Error("Non-contiguous data written to non-objectMode stream")}return this[Ke]?(this[Le]&&this[Pe]!==0&&this[ts](!0),this[Le]?this.emit("data",t):this[oa](t),this[Pe]!==0&&this.emit("readable"),r&&s(r),this[Le]):t.length?(typeof t=="string"&&!(e===this[ut]&&!this[tr]?.lastNeed)&&(t=Buffer.from(t,e)),Buffer.isBuffer(t)&&this[ut]&&(t=this[tr].write(t)),this[Le]&&this[Pe]!==0&&this[ts](!0),this[Le]?this.emit("data",t):this[oa](t),this[Pe]!==0&&this.emit("readable"),r&&s(r),this[Le]):(this[Pe]!==0&&this.emit("readable"),r&&s(r),this[Le])}read(t){if(this[ve])return null;if(this[Ye]=!1,this[Pe]===0||t===0||t&&t>this[Pe])return this[Pt](),null;this[Ke]&&(t=null),this[Oe].length>1&&!this[Ke]&&(this[Oe]=[this[ut]?this[Oe].join(""):Buffer.concat(this[Oe],this[Pe])]);let e=this[Pf](t||null,this[Oe][0]);return this[Pt](),e}[Pf](t,e){if(this[Ke])this[ns]();else{let r=e;t===r.length||t===null?this[ns]():typeof r=="string"?(this[Oe][0]=r.slice(t),e=r.slice(0,t),this[Pe]-=t):(this[Oe][0]=r.subarray(t),e=r.subarray(0,t),this[Pe]-=t)}return this.emit("data",e),!this[Oe].length&&!this[Ot]&&this.emit("drain"),e}end(t,e,r){return typeof t=="function"&&(r=t,t=void 0),typeof e=="function"&&(r=e,e="utf8"),t!==void 0&&this.write(t,e),r&&this.once("end",r),this[Ot]=!0,this.writable=!1,(this[Le]||!this[qr])&&this[Pt](),this}[or](){this[ve]||(!this[vn]&&!this[$e].length&&(this[Ye]=!0),this[qr]=!1,this[Le]=!0,this.emit("resume"),this[Oe].length?this[ts]():this[Ot]?this[Pt]():this.emit("drain"))}resume(){return this[or]()}pause(){this[Le]=!1,this[qr]=!0,this[Ye]=!1}get destroyed(){return this[ve]}get flowing(){return this[Le]}get paused(){return this[qr]}[oa](t){this[Ke]?this[Pe]+=1:this[Pe]+=t.length,this[Oe].push(t)}[ns](){return this[Ke]?this[Pe]-=1:this[Pe]-=this[Oe][0].length,this[Oe].shift()}[ts](t=!1){do;while(this[Nf](this[ns]())&&this[Oe].length);!t&&!this[Oe].length&&!this[Ot]&&this.emit("drain")}[Nf](t){return this.emit("data",t),this[Le]}pipe(t,e){if(this[ve])return t;this[Ye]=!1;let r=this[en];return e=e||{},t===Of.stdout||t===Of.stderr?e.end=!1:e.end=e.end!==!1,e.proxyErrors=!!e.proxyErrors,r?e.end&&t.end():(this[$e].push(e.proxyErrors?new hg(this,t,e):new hd(this,t,e)),this[wt]?jr(()=>this[or]()):this[or]()),t}unpipe(t){let e=this[$e].find(r=>r.dest===t);e&&(this[$e].length===1?(this[Le]&&this[vn]===0&&(this[Le]=!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[Ye]=!1,this[vn]++,!this[$e].length&&!this[Le]&&this[or]();else if(t==="readable"&&this[Pe]!==0)super.emit("readable");else if(ug(t)&&this[en])super.emit(t),this.removeAllListeners(t);else if(t==="error"&&this[Ur]){let s=e;this[wt]?jr(()=>s.call(this,this[Ur])):s.call(this,this[Ur])}return r}removeListener(t,e){return this.off(t,e)}off(t,e){let r=super.off(t,e);return t==="data"&&(this[vn]=this.listeners("data").length,this[vn]===0&&!this[Ye]&&!this[$e].length&&(this[Le]=!1)),r}removeAllListeners(t){let e=super.removeAllListeners(t);return(t==="data"||t===void 0)&&(this[vn]=0,!this[Ye]&&!this[$e].length&&(this[Le]=!1)),e}get emittedEnd(){return this[en]}[Pt](){!this[Qi]&&!this[en]&&!this[ve]&&this[Oe].length===0&&this[Ot]&&(this[Qi]=!0,this.emit("end"),this.emit("prefinish"),this.emit("finish"),this[es]&&this.emit("close"),this[Qi]=!1)}emit(t,...e){let r=e[0];if(t!=="error"&&t!=="close"&&t!==ve&&this[ve])return!1;if(t==="data")return!this[Ke]&&!r?!1:this[wt]?(jr(()=>this[ca](r)),!0):this[ca](r);if(t==="end")return this[Mf]();if(t==="close"){if(this[es]=!0,!this[en]&&!this[ve])return!1;let a=super.emit("close");return this.removeAllListeners("close"),a}else if(t==="error"){this[Ur]=r,super.emit(aa,r);let a=!this[Hr]||this.listeners("error").length?super.emit("error",r):!1;return this[Pt](),a}else if(t==="resume"){let a=super.emit("resume");return this[Pt](),a}else if(t==="finish"||t==="prefinish"){let a=super.emit(t);return this.removeAllListeners(t),a}let s=super.emit(t,...e);return this[Pt](),s}[ca](t){for(let r of this[$e])r.dest.write(t)===!1&&this.pause();let e=this[Ye]?!1:super.emit("data",t);return this[Pt](),e}[Mf](){return this[en]?!1:(this[en]=!0,this.readable=!1,this[wt]?(jr(()=>this[fa]()),!0):this[fa]())}[fa](){if(this[tr]){let e=this[tr].end();if(e){for(let r of this[$e])r.dest.write(e);this[Ye]||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[Ke]||(t.dataLength=0);let e=this.promise();return this.on("data",r=>{t.push(r),this[Ke]||(t.dataLength+=r.length)}),await e,t}async concat(){if(this[Ke])throw new Error("cannot concat in objectMode");let t=await this.collect();return this[ut]?t.join(""):Buffer.concat(t,t.dataLength)}async promise(){return new Promise((t,e)=>{this.on(ve,()=>e(new Error("stream destroyed"))),this.on("error",r=>e(r)),this.on("end",()=>t())})}[Symbol.asyncIterator](){this[Ye]=!1;let t=!1,e=async()=>(this.pause(),t=!0,{value:void 0,done:!0});return{next:()=>{if(t)return e();let r=this.read();if(r!==null)return Promise.resolve({done:!1,value:r});if(this[Ot])return e();let s,a,c=p=>{this.off("data",d),this.off("end",u),this.off(ve,x),e(),a(p)},d=p=>{this.off("error",c),this.off("end",u),this.off(ve,x),this.pause(),s({value:p,done:!!this[Ot]})},u=()=>{this.off("error",c),this.off("data",d),this.off(ve,x),e(),s({done:!0,value:void 0})},x=()=>c(new Error("stream destroyed"));return new Promise((p,_)=>{a=_,s=p,this.once(ve,x),this.once("error",c),this.once("end",u),this.once("data",d)})},throw:e,return:e,[Symbol.asyncIterator](){return this},[Symbol.asyncDispose]:async()=>{}}}[Symbol.iterator](){this[Ye]=!1;let t=!1,e=()=>(this.pause(),this.off(aa,e),this.off(ve,e),this.off("end",e),t=!0,{done:!0,value:void 0}),r=()=>{if(t)return e();let s=this.read();return s===null?e():{done:!1,value:s}};return this.once("end",e),this.once(aa,e),this.once(ve,e),{next:r,throw:e,return:e,[Symbol.iterator](){return this},[Symbol.dispose]:()=>{}}}destroy(t){if(this[ve])return t?this.emit("error",t):this.emit(ve),this;this[ve]=!0,this[Ye]=!0,this[Oe].length=0,this[Pe]=0;let e=this;return typeof e.close=="function"&&!this[es]&&e.close(),t?this.emit("error",t):this.emit(ve),this}static get isStream(){return ag}},mg=Je.writev,un=Symbol("_autoClose"),pt=Symbol("_close"),Gr=Symbol("_ended"),ce=Symbol("_fd"),ua=Symbol("_finished"),zt=Symbol("_flags"),la=Symbol("_flush"),La=Symbol("_handleChunk"),Oa=Symbol("_makeBuf"),ti=Symbol("_mode"),is=Symbol("_needDrain"),ur=Symbol("_onerror"),lr=Symbol("_onopen"),xa=Symbol("_onread"),ar=Symbol("_onwrite"),ln=Symbol("_open"),ht=Symbol("_path"),on=Symbol("_pos"),_t=Symbol("_queue"),cr=Symbol("_read"),ha=Symbol("_readSize"),Bt=Symbol("_reading"),Wr=Symbol("_remain"),pa=Symbol("_size"),hs=Symbol("_write"),Sn=Symbol("_writing"),ps=Symbol("_defaultFlag"),kn=Symbol("_errored"),ec=class extends Nn{[kn]=!1;[ce];[ht];[ha];[Bt]=!1;[pa];[Wr];[un];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[kn]=!1,this[ce]=typeof e.fd=="number"?e.fd:void 0,this[ht]=t,this[ha]=e.readSize||16*1024*1024,this[Bt]=!1,this[pa]=typeof e.size=="number"?e.size:1/0,this[Wr]=this[pa],this[un]=typeof e.autoClose=="boolean"?e.autoClose:!0,typeof this[ce]=="number"?this[cr]():this[ln]()}get fd(){return this[ce]}get path(){return this[ht]}write(){throw new TypeError("this is a readable stream")}end(){throw new TypeError("this is a readable stream")}[ln](){Je.open(this[ht],"r",(t,e)=>this[lr](t,e))}[lr](t,e){t?this[ur](t):(this[ce]=e,this.emit("open",e),this[cr]())}[Oa](){return Buffer.allocUnsafe(Math.min(this[ha],this[Wr]))}[cr](){if(!this[Bt]){this[Bt]=!0;let t=this[Oa]();if(t.length===0)return process.nextTick(()=>this[xa](null,0,t));Je.read(this[ce],t,0,t.length,null,(e,r,s)=>this[xa](e,r,s))}}[xa](t,e,r){this[Bt]=!1,t?this[ur](t):this[La](e,r)&&this[cr]()}[pt](){if(this[un]&&typeof this[ce]=="number"){let t=this[ce];this[ce]=void 0,Je.close(t,e=>e?this.emit("error",e):this.emit("close"))}}[ur](t){this[Bt]=!0,this[pt](),this.emit("error",t)}[La](t,e){let r=!1;return this[Wr]-=t,t>0&&(r=super.write(t<e.length?e.subarray(0,t):e)),(t===0||this[Wr]<=0)&&(r=!1,this[pt](),super.end()),r}emit(t,...e){switch(t){case"prefinish":case"finish":return!1;case"drain":return typeof this[ce]=="number"&&this[cr](),!1;case"error":return this[kn]?!1:(this[kn]=!0,super.emit(t,...e));default:return super.emit(t,...e)}}},wg=class extends ec{[ln](){let t=!0;try{this[lr](null,Je.openSync(this[ht],"r")),t=!1}finally{t&&this[pt]()}}[cr](){let t=!0;try{if(!this[Bt]){this[Bt]=!0;do{let e=this[Oa](),r=e.length===0?0:Je.readSync(this[ce],e,0,e.length,null);if(!this[La](r,e))break}while(!0);this[Bt]=!1}t=!1}finally{t&&this[pt]()}}[pt](){if(this[un]&&typeof this[ce]=="number"){let t=this[ce];this[ce]=void 0,Je.closeSync(t),this.emit("close")}}},Rs=class extends sg{readable=!1;writable=!0;[kn]=!1;[Sn]=!1;[Gr]=!1;[_t]=[];[is]=!1;[ht];[ti];[un];[ce];[ps];[zt];[ua]=!1;[on];constructor(t,e){e=e||{},super(e),this[ht]=t,this[ce]=typeof e.fd=="number"?e.fd:void 0,this[ti]=e.mode===void 0?438:e.mode,this[on]=typeof e.start=="number"?e.start:void 0,this[un]=typeof e.autoClose=="boolean"?e.autoClose:!0;let r=this[on]!==void 0?"r+":"w";this[ps]=e.flags===void 0,this[zt]=e.flags===void 0?r:e.flags,this[ce]===void 0&&this[ln]()}emit(t,...e){if(t==="error"){if(this[kn])return!1;this[kn]=!0}return super.emit(t,...e)}get fd(){return this[ce]}get path(){return this[ht]}[ur](t){this[pt](),this[Sn]=!0,this.emit("error",t)}[ln](){Je.open(this[ht],this[zt],this[ti],(t,e)=>this[lr](t,e))}[lr](t,e){this[ps]&&this[zt]==="r+"&&t&&t.code==="ENOENT"?(this[zt]="w",this[ln]()):t?this[ur](t):(this[ce]=e,this.emit("open",e),this[Sn]||this[la]())}end(t,e){return t&&this.write(t,e),this[Gr]=!0,!this[Sn]&&!this[_t].length&&typeof this[ce]=="number"&&this[ar](null,0),this}write(t,e){return typeof t=="string"&&(t=Buffer.from(t,e)),this[Gr]?(this.emit("error",new Error("write() after end()")),!1):this[ce]===void 0||this[Sn]||this[_t].length?(this[_t].push(t),this[is]=!0,!1):(this[Sn]=!0,this[hs](t),!0)}[hs](t){Je.write(this[ce],t,0,t.length,this[on],(e,r)=>this[ar](e,r))}[ar](t,e){t?this[ur](t):(this[on]!==void 0&&typeof e=="number"&&(this[on]+=e),this[_t].length?this[la]():(this[Sn]=!1,this[Gr]&&!this[ua]?(this[ua]=!0,this[pt](),this.emit("finish")):this[is]&&(this[is]=!1,this.emit("drain"))))}[la](){if(this[_t].length===0)this[Gr]&&this[ar](null,0);else if(this[_t].length===1)this[hs](this[_t].pop());else{let t=this[_t];this[_t]=[],mg(this[ce],t,this[on],(e,r)=>this[ar](e,r))}}[pt](){if(this[un]&&typeof this[ce]=="number"){let t=this[ce];this[ce]=void 0,Je.close(t,e=>e?this.emit("error",e):this.emit("close"))}}},pd=class extends Rs{[ln](){let t;if(this[ps]&&this[zt]==="r+")try{t=Je.openSync(this[ht],this[zt],this[ti])}catch(e){if(e?.code==="ENOENT")return this[zt]="w",this[ln]();throw e}else t=Je.openSync(this[ht],this[zt],this[ti]);this[lr](null,t)}[pt](){if(this[un]&&typeof this[ce]=="number"){let t=this[ce];this[ce]=void 0,Je.closeSync(t),this.emit("close")}}[hs](t){let e=!0;try{this[ar](null,Je.writeSync(this[ce],t,0,t.length,this[on])),e=!1}finally{if(e)try{this[pt]()}catch{}}}},bg=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"]]),Eg=t=>!!t.sync&&!!t.file,vg=t=>!t.sync&&!!t.file,Sg=t=>!!t.sync&&!t.file,Ig=t=>!t.sync&&!t.file,Cg=t=>!!t.file,Ag=t=>bg.get(t)||t,tc=(t={})=>{if(!t)return{};let e={};for(let[r,s]of Object.entries(t)){let a=Ag(r);e[a]=s}return e.chmod===void 0&&e.noChmod===!1&&(e.chmod=!0),delete e.noChmod,e},di=(t,e,r,s,a)=>Object.assign((c=[],d,u)=>{Array.isArray(c)&&(d=c,c={}),typeof d=="function"&&(u=d,d=void 0),d=d?Array.from(d):[];let x=tc(c);if(a?.(x,d),Eg(x)){if(typeof u=="function")throw new TypeError("callback not supported for sync tar functions");return t(x,d)}else if(vg(x)){let p=e(x,d);return u?p.then(()=>u(),u):p}else if(Sg(x)){if(typeof u=="function")throw new TypeError("callback not supported for sync tar functions");return r(x,d)}else if(Ig(x)){if(typeof u=="function")throw new TypeError("callback only supported with file option");return s(x,d)}throw new Error("impossible options??")},{syncFile:t,asyncFile:e,syncNoFile:r,asyncNoFile:s,validate:a}),Rg=Dg.constants||{ZLIB_VERNUM:4736},vt=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},Rg)),kg=Ln.concat,zf=Object.getOwnPropertyDescriptor(Ln,"concat"),Lg=t=>t,ga=zf?.writable===!0||zf?.set!==void 0?t=>{Ln.concat=t?Lg:kg}:t=>{},On=Symbol("_superWrite"),ss=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"}},ma=Symbol("flushFlag"),nc=class extends Nn{#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 Bf[e]!="function")throw new TypeError("Compression method not supported: "+e);try{this.#t=new Bf[e](t)}catch(r){throw new ss(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 ss(r))),this.once("end",()=>this.close)}close(){this.#t&&(this.#t.close(),this.#t=void 0,this.emit("close"))}reset(){if(!this.#e)return Pa(this.#t,"zlib binding closed"),this.#t.reset?.()}flush(t){this.ended||(typeof t!="number"&&(t=this.#i),this.write(Object.assign(Ln.alloc(0),{[ma]:t})))}end(t,e,r){return typeof t=="function"&&(r=t,e=void 0,t=void 0),typeof e=="function"&&(r=e,e=void 0),t&&(e?this.write(t,e):this.write(t)),this.flush(this.#s),this.#n=!0,super.end(r)}get ended(){return this.#n}[On](t){return super.write(t)}write(t,e,r){if(typeof e=="function"&&(r=e,e="utf8"),typeof t=="string"&&(t=Ln.from(t,e)),this.#e)return;Pa(this.#t,"zlib binding closed");let s=this.#t._handle,a=s.close;s.close=()=>{};let c=this.#t.close;this.#t.close=()=>{},ga(!0);let d;try{let x=typeof t[ma]=="number"?t[ma]:this.#r;d=this.#t._processChunk(t,x),ga(!1)}catch(x){ga(!1),this.#o(new ss(x,this.write))}finally{this.#t&&(this.#t._handle=s,s.close=a,this.#t.close=c,this.#t.removeAllListeners("error"))}this.#t&&this.#t.on("error",x=>this.#o(new ss(x,this.write)));let u;if(d)if(Array.isArray(d)&&d.length>0){let x=d[0];u=this[On](Ln.from(x));for(let p=1;p<d.length;p++)u=this[On](d[p])}else u=this[On](Ln.from(d));return r&&r(),u}},md=class extends nc{#e;#n;constructor(t,e){t=t||{},t.flush=t.flush||vt.Z_NO_FLUSH,t.finishFlush=t.finishFlush||vt.Z_FINISH,t.fullFlushFlag=vt.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(vt.Z_SYNC_FLUSH),Pa(this.handle,"zlib binding closed");let r=this.handle.flush;this.handle.flush=(s,a)=>{typeof s=="function"&&(a=s,s=this.flushFlag),this.flush(s),a?.()};try{this.handle.params(t,e)}finally{this.handle.flush=r}this.handle&&(this.#e=t,this.#n=e)}}}},Og=class extends md{#e;constructor(t){super(t,"Gzip"),this.#e=t&&!!t.portable}[On](t){return this.#e?(this.#e=!1,t[9]=255,super[On](t)):super[On](t)}},Pg=class extends md{constructor(t){super(t,"Unzip")}},wd=class extends nc{constructor(t,e){t=t||{},t.flush=t.flush||vt.BROTLI_OPERATION_PROCESS,t.finishFlush=t.finishFlush||vt.BROTLI_OPERATION_FINISH,t.fullFlushFlag=vt.BROTLI_OPERATION_FLUSH,super(t,e)}},Ng=class extends wd{constructor(t){super(t,"BrotliCompress")}},Mg=class extends wd{constructor(t){super(t,"BrotliDecompress")}},_d=class extends nc{constructor(t,e){t=t||{},t.flush=t.flush||vt.ZSTD_e_continue,t.finishFlush=t.finishFlush||vt.ZSTD_e_end,t.fullFlushFlag=vt.ZSTD_e_flush,super(t,e)}},Bg=class extends _d{constructor(t){super(t,"ZstdCompress")}},zg=class extends _d{constructor(t){super(t,"ZstdDecompress")}},Fg=(t,e)=>{if(Number.isSafeInteger(t))t<0?qg(t,e):Ug(t,e);else throw Error("cannot encode number outside of javascript safe integer range");return e},Ug=(t,e)=>{e[0]=128;for(var r=e.length;r>1;r--)e[r-1]=t&255,t=Math.floor(t/256)},qg=(t,e)=>{e[0]=255;var r=!1;t=t*-1;for(var s=e.length;s>1;s--){var a=t&255;t=Math.floor(t/256),r?e[s-1]=yd(a):a===0?e[s-1]=0:(r=!0,e[s-1]=bd(a))}},Hg=t=>{let e=t[0],r=e===128?Gg(t.subarray(1,t.length)):e===255?jg(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},jg=t=>{for(var e=t.length,r=0,s=!1,a=e-1;a>-1;a--){var c=Number(t[a]),d;s?d=yd(c):c===0?d=c:(s=!0,d=bd(c)),d!==0&&(r-=d*Math.pow(256,e-a-1))}return r},Gg=t=>{for(var e=t.length,r=0,s=e-1;s>-1;s--){var a=Number(t[s]);a!==0&&(r+=a*Math.pow(256,e-s-1))}return r},yd=t=>(255^t)&255,bd=t=>(255^t)+1&255,Wg={};ig(Wg,{code:()=>rc,isCode:()=>gs,isName:()=>Kg,name:()=>ks});var gs=t=>ks.has(t),Kg=t=>rc.has(t),ks=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"]]),rc=new Map(Array.from(ks).map(t=>[t[1],t[0]])),Pn=class{cksumValid=!1;needPax=!1;nullBlock=!1;block;path;mode;uid;gid;size;cksum;#e="Unsupported";linkpath;uname;gname;devmaj=0;devmin=0;atime;ctime;mtime;charset;comment;constructor(t,e=0,r,s){Buffer.isBuffer(t)?this.decode(t,e||0,r,s):t&&this.#n(t)}decode(t,e,r,s){if(e||(e=0),!t||!(t.length>=e+512))throw new Error("need 512 bytes for header");this.path=r?.path??In(t,e,100),this.mode=r?.mode??s?.mode??an(t,e+100,8),this.uid=r?.uid??s?.uid??an(t,e+108,8),this.gid=r?.gid??s?.gid??an(t,e+116,8),this.size=r?.size??s?.size??an(t,e+124,12),this.mtime=r?.mtime??s?.mtime??wa(t,e+136,12),this.cksum=an(t,e+148,12),s&&this.#n(s,!0),r&&this.#n(r);let a=In(t,e+156,1);if(gs(a)&&(this.#e=a||"0"),this.#e==="0"&&this.path.slice(-1)==="/"&&(this.#e="5"),this.#e==="5"&&(this.size=0),this.linkpath=In(t,e+157,100),t.subarray(e+257,e+265).toString()==="ustar\x0000")if(this.uname=r?.uname??s?.uname??In(t,e+265,32),this.gname=r?.gname??s?.gname??In(t,e+297,32),this.devmaj=r?.devmaj??s?.devmaj??an(t,e+329,8)??0,this.devmin=r?.devmin??s?.devmin??an(t,e+337,8)??0,t[e+475]!==0){let d=In(t,e+345,155);this.path=d+"/"+this.path}else{let d=In(t,e+345,130);d&&(this.path=d+"/"+this.path),this.atime=r?.atime??s?.atime??wa(t,e+476,12),this.ctime=r?.ctime??s?.ctime??wa(t,e+488,12)}let c=256;for(let d=e;d<e+148;d++)c+=t[d];for(let d=e+156;d<e+512;d++)c+=t[d];this.cksumValid=c===this.cksum,this.cksum===void 0&&c===256&&(this.nullBlock=!0)}#n(t,e=!1){Object.assign(this,Object.fromEntries(Object.entries(t).filter(([r,s])=>!(s==null||r==="path"&&e||r==="linkpath"&&e||r==="global"))))}encode(t,e=0){if(t||(t=this.block=Buffer.alloc(512)),this.#e==="Unsupported"&&(this.#e="0"),!(t.length>=e+512))throw new Error("need 512 bytes for header");let r=this.ctime||this.atime?130:155,s=$g(this.path||"",r),a=s[0],c=s[1];this.needPax=!!s[2],this.needPax=Cn(t,e,100,a)||this.needPax,this.needPax=cn(t,e+100,8,this.mode)||this.needPax,this.needPax=cn(t,e+108,8,this.uid)||this.needPax,this.needPax=cn(t,e+116,8,this.gid)||this.needPax,this.needPax=cn(t,e+124,12,this.size)||this.needPax,this.needPax=_a(t,e+136,12,this.mtime)||this.needPax,t[e+156]=Number(this.#e.codePointAt(0)),this.needPax=Cn(t,e+157,100,this.linkpath)||this.needPax,t.write("ustar\x0000",e+257,8),this.needPax=Cn(t,e+265,32,this.uname)||this.needPax,this.needPax=Cn(t,e+297,32,this.gname)||this.needPax,this.needPax=cn(t,e+329,8,this.devmaj)||this.needPax,this.needPax=cn(t,e+337,8,this.devmin)||this.needPax,this.needPax=Cn(t,e+345,r,c)||this.needPax,t[e+475]!==0?this.needPax=Cn(t,e+345,155,c)||this.needPax:(this.needPax=Cn(t,e+345,130,c)||this.needPax,this.needPax=_a(t,e+476,12,this.atime)||this.needPax,this.needPax=_a(t,e+488,12,this.ctime)||this.needPax);let d=256;for(let u=e;u<e+148;u++)d+=t[u];for(let u=e+156;u<e+512;u++)d+=t[u];return this.cksum=d,cn(t,e+148,8,this.cksum),this.cksumValid=!0,this.needPax}get type(){return this.#e==="Unsupported"?this.#e:ks.get(this.#e)}get typeKey(){return this.#e}set type(t){let e=String(rc.get(t));if(gs(e)||e==="Unsupported")this.#e=e;else if(gs(t))this.#e=t;else throw new TypeError("invalid entry type: "+t)}},$g=(t,e)=>{let r=t,s="",a,c=nr.parse(t).root||".";if(Buffer.byteLength(r)<100)a=[r,s,!1];else{s=nr.dirname(r),r=nr.basename(r);do Buffer.byteLength(r)<=100&&Buffer.byteLength(s)<=e?a=[r,s,!1]:Buffer.byteLength(r)>100&&Buffer.byteLength(s)<=e?a=[r.slice(0,99),s,!0]:(r=nr.join(nr.basename(s),r),s=nr.dirname(s));while(s!==c&&a===void 0);a||(a=[t.slice(0,99),"",!0])}return a},In=(t,e,r)=>t.subarray(e,e+r).toString("utf8").replace(/\0.*/,""),wa=(t,e,r)=>Vg(an(t,e,r)),Vg=t=>t===void 0?void 0:new Date(t*1e3),an=(t,e,r)=>Number(t[e])&128?Hg(t.subarray(e,e+r)):Zg(t,e,r),Jg=t=>isNaN(t)?void 0:t,Zg=(t,e,r)=>Jg(parseInt(t.subarray(e,e+r).toString("utf8").replace(/\0.*$/,"").trim(),8)),Xg={12:8589934591,8:2097151},cn=(t,e,r,s)=>s===void 0?!1:s>Xg[r]||s<0?(Fg(s,t.subarray(e,e+r)),!0):(Yg(t,e,r,s),!1),Yg=(t,e,r,s)=>t.write(Qg(s,r),e,r,"ascii"),Qg=(t,e)=>em(Math.floor(t).toString(8),e),em=(t,e)=>(t.length===e-1?t:new Array(e-t.length-1).join("0")+t+" ")+"\0",_a=(t,e,r,s)=>s===void 0?!1:cn(t,e,r,s.getTime()/1e3),tm=new Array(156).join("\0"),Cn=(t,e,r,s)=>s===void 0?!1:(t.write(s+tm,e,r,"utf8"),s.length!==Buffer.byteLength(s)||s.length>r),Is=class Ed{atime;mtime;ctime;charset;comment;gid;uid;gname;uname;linkpath;dev;ino;nlink;path;size;mode;global;constructor(e,r=!1){this.atime=e.atime,this.charset=e.charset,this.comment=e.comment,this.ctime=e.ctime,this.dev=e.dev,this.gid=e.gid,this.global=r,this.gname=e.gname,this.ino=e.ino,this.linkpath=e.linkpath,this.mtime=e.mtime,this.nlink=e.nlink,this.path=e.path,this.size=e.size,this.uid=e.uid,this.uname=e.uname}encode(){let e=this.encodeBody();if(e==="")return Buffer.allocUnsafe(0);let r=Buffer.byteLength(e),s=512*Math.ceil(1+r/512),a=Buffer.allocUnsafe(s);for(let c=0;c<512;c++)a[c]=0;new Pn({path:("PaxHeader/"+nm(this.path??"")).slice(0,99),mode:this.mode||420,uid:this.uid,gid:this.gid,size:r,mtime:this.mtime,type:this.global?"GlobalExtendedHeader":"ExtendedHeader",linkpath:"",uname:this.uname||"",gname:this.gname||"",devmaj:0,devmin:0,atime:this.atime,ctime:this.ctime}).encode(a),a.write(e,512,r,"utf8");for(let c=r+512;c<a.length;c++)a[c]=0;return a}encodeBody(){return this.encodeField("path")+this.encodeField("ctime")+this.encodeField("atime")+this.encodeField("dev")+this.encodeField("ino")+this.encodeField("nlink")+this.encodeField("charset")+this.encodeField("comment")+this.encodeField("gid")+this.encodeField("gname")+this.encodeField("linkpath")+this.encodeField("mtime")+this.encodeField("size")+this.encodeField("uid")+this.encodeField("uname")}encodeField(e){if(this[e]===void 0)return"";let r=this[e],s=r instanceof Date?r.getTime()/1e3:r,a=" "+(e==="dev"||e==="ino"||e==="nlink"?"SCHILY.":"")+e+"="+s+`
|
|
115
|
-
`,c=Buffer.byteLength(a),d=Math.floor(Math.log(c)/Math.log(10))+1;return c+d>=Math.pow(10,d)&&(d+=1),d+c+a}static parse(e,r,s=!1){return new Ed(rm(im(e),r),s)}},rm=(t,e)=>e?Object.assign({},e,t):t,im=t=>t.replace(/\n$/,"").split(`
|
|
116
|
-
`).reduce(sm,Object.create(null)),sm=(t,e)=>{let r=parseInt(e,10);if(r!==Buffer.byteLength(e)+1)return t;e=e.slice((r+" ").length);let s=e.split("="),a=s.shift();if(!a)return t;let c=a.replace(/^SCHILY\.(dev|ino|nlink)/,"$1"),d=s.join("=");return t[c]=/^([A-Z]+\.)?([mac]|birth|creation)time$/.test(c)?new Date(Number(d)*1e3):/^[0-9]+$/.test(d)?+d:d,t},om=process.env.TESTING_TAR_FAKE_PLATFORM||process.platform,Q=om!=="win32"?t=>t:t=>t&&t.replaceAll(/\\/g,"/"),vd=class extends Nn{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=Q(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?Q(t.linkpath):void 0,this.uname=t.uname,this.gname=t.gname,e&&this.#e(e),r&&this.#e(r,!0)}write(t){let e=t.length;if(e>this.blockRemain)throw new Error("writing more to entry than is appropriate");let r=this.remain,s=this.blockRemain;return this.remain=Math.max(0,r-e),this.blockRemain=Math.max(0,s-e),this.ignore?!0:r>=e?super.write(t):super.write(t.subarray(0,r))}#e(t,e=!1){t.path&&(t.path=Q(t.path)),t.linkpath&&(t.linkpath=Q(t.linkpath)),Object.assign(this,Object.fromEntries(Object.entries(t).filter(([r,s])=>!(s==null||r==="path"&&e))))}},Ls=(t,e,r,s={})=>{t.file&&(s.file=t.file),t.cwd&&(s.cwd=t.cwd),s.code=r instanceof Error&&r.code||e,s.tarCode=e,!t.strict&&s.recoverable!==!1?(r instanceof Error&&(s=Object.assign(r,s),r=r.message),t.emit("warn",e,r,s)):r instanceof Error?t.emit("error",Object.assign(r,s)):t.emit("error",Object.assign(new Error(`${e}: ${r}`),s))},am=1024*1024,Na=Buffer.from([31,139]),Ma=Buffer.from([40,181,47,253]),cm=Math.max(Na.length,Ma.length),it=Symbol("state"),An=Symbol("writeEntry"),Nt=Symbol("readEntry"),ya=Symbol("nextEntry"),Ff=Symbol("processEntry"),yt=Symbol("extendedHeader"),Kr=Symbol("globalExtendedHeader"),tn=Symbol("meta"),Uf=Symbol("emitMeta"),xe=Symbol("buffer"),Mt=Symbol("queue"),nn=Symbol("ended"),ba=Symbol("emittedEnd"),Tn=Symbol("emit"),Ce=Symbol("unzip"),os=Symbol("consumeChunk"),as=Symbol("consumeChunkSub"),Ea=Symbol("consumeBody"),qf=Symbol("consumeMeta"),Hf=Symbol("consumeHeader"),$r=Symbol("consuming"),va=Symbol("bufferConcat"),cs=Symbol("maybeEnd"),rr=Symbol("writing"),rn=Symbol("aborted"),fs=Symbol("onDone"),Dn=Symbol("sawValidEntry"),ds=Symbol("sawNullBlock"),us=Symbol("sawEOF"),jf=Symbol("closeStream"),fm=()=>!0,fi=class extends Tg{file;strict;maxMetaEntrySize;filter;brotli;zstd;writable=!0;readable=!1;[Mt]=[];[xe];[Nt];[An];[it]="begin";[tn]="";[yt];[Kr];[nn]=!1;[Ce];[rn]=!1;[Dn];[ds]=!1;[us]=!1;[rr]=!1;[$r]=!1;[ba]=!1;constructor(t={}){super(),this.file=t.file||"",this.on(fs,()=>{(this[it]==="begin"||this[Dn]===!1)&&this.warn("TAR_BAD_ARCHIVE","Unrecognized archive format")}),t.ondone?this.on(fs,t.ondone):this.on(fs,()=>{this.emit("prefinish"),this.emit("finish"),this.emit("end")}),this.strict=!!t.strict,this.maxMetaEntrySize=t.maxMetaEntrySize||am,this.filter=typeof t.filter=="function"?t.filter:fm;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[jf]()),typeof t.onwarn=="function"&&this.on("warn",t.onwarn),typeof t.onReadEntry=="function"&&this.on("entry",t.onReadEntry)}warn(t,e,r={}){Ls(this,t,e,r)}[Hf](t,e){this[Dn]===void 0&&(this[Dn]=!1);let r;try{r=new Pn(t,e,this[yt],this[Kr])}catch(s){return this.warn("TAR_ENTRY_INVALID",s)}if(r.nullBlock)this[ds]?(this[us]=!0,this[it]==="begin"&&(this[it]="header"),this[Tn]("eof")):(this[ds]=!0,this[Tn]("nullBlock"));else if(this[ds]=!1,!r.cksumValid)this.warn("TAR_ENTRY_INVALID","checksum failure",{header:r});else if(!r.path)this.warn("TAR_ENTRY_INVALID","path is required",{header:r});else{let s=r.type;if(/^(Symbolic)?Link$/.test(s)&&!r.linkpath)this.warn("TAR_ENTRY_INVALID","linkpath required",{header:r});else if(!/^(Symbolic)?Link$/.test(s)&&!/^(Global)?ExtendedHeader$/.test(s)&&r.linkpath)this.warn("TAR_ENTRY_INVALID","linkpath forbidden",{header:r});else{let a=this[An]=new vd(r,this[yt],this[Kr]);if(!this[Dn])if(a.remain){let c=()=>{a.invalid||(this[Dn]=!0)};a.on("end",c)}else this[Dn]=!0;a.meta?a.size>this.maxMetaEntrySize?(a.ignore=!0,this[Tn]("ignoredEntry",a),this[it]="ignore",a.resume()):a.size>0&&(this[tn]="",a.on("data",c=>this[tn]+=c),this[it]="meta"):(this[yt]=void 0,a.ignore=a.ignore||!this.filter(a.path,a),a.ignore?(this[Tn]("ignoredEntry",a),this[it]=a.remain?"ignore":"header",a.resume()):(a.remain?this[it]="body":(this[it]="header",a.end()),this[Nt]?this[Mt].push(a):(this[Mt].push(a),this[ya]())))}}}[jf](){queueMicrotask(()=>this.emit("close"))}[Ff](t){let e=!0;if(!t)this[Nt]=void 0,e=!1;else if(Array.isArray(t)){let[r,...s]=t;this.emit(r,...s)}else this[Nt]=t,this.emit("entry",t),t.emittedEnd||(t.on("end",()=>this[ya]()),e=!1);return e}[ya](){do;while(this[Ff](this[Mt].shift()));if(this[Mt].length===0){let t=this[Nt];!t||t.flowing||t.size===t.remain?this[rr]||this.emit("drain"):t.once("drain",()=>this.emit("drain"))}}[Ea](t,e){let r=this[An];if(!r)throw new Error("attempt to consume body without entry??");let s=r.blockRemain??0,a=s>=t.length&&e===0?t:t.subarray(e,e+s);return r.write(a),r.blockRemain||(this[it]="header",this[An]=void 0,r.end()),a.length}[qf](t,e){let r=this[An],s=this[Ea](t,e);return!this[An]&&r&&this[Uf](r),s}[Tn](t,e,r){this[Mt].length===0&&!this[Nt]?this.emit(t,e,r):this[Mt].push([t,e,r])}[Uf](t){switch(this[Tn]("meta",this[tn]),t.type){case"ExtendedHeader":case"OldExtendedHeader":this[yt]=Is.parse(this[tn],this[yt],!1);break;case"GlobalExtendedHeader":this[Kr]=Is.parse(this[tn],this[Kr],!0);break;case"NextFileHasLongPath":case"OldGnuLongPath":{let e=this[yt]??Object.create(null);this[yt]=e,e.path=this[tn].replace(/\0.*/,"");break}case"NextFileHasLongLinkpath":{let e=this[yt]||Object.create(null);this[yt]=e,e.linkpath=this[tn].replace(/\0.*/,"");break}default:throw new Error("unknown meta: "+t.type)}}abort(t){this[rn]=!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[rn])return r?.(),!1;if((this[Ce]===void 0||this.brotli===void 0&&this[Ce]===!1)&&t){if(this[xe]&&(t=Buffer.concat([this[xe],t]),this[xe]=void 0),t.length<cm)return this[xe]=t,r?.(),!0;for(let d=0;this[Ce]===void 0&&d<Na.length;d++)t[d]!==Na[d]&&(this[Ce]=!1);let a=!1;if(this[Ce]===!1&&this.zstd!==!1){a=!0;for(let d=0;d<Ma.length;d++)if(t[d]!==Ma[d]){a=!1;break}}let c=this.brotli===void 0&&!a;if(this[Ce]===!1&&c)if(t.length<512)if(this[nn])this.brotli=!0;else return this[xe]=t,r?.(),!0;else try{new Pn(t.subarray(0,512)),this.brotli=!1}catch{this.brotli=!0}if(this[Ce]===void 0||this[Ce]===!1&&(this.brotli||a)){let d=this[nn];this[nn]=!1,this[Ce]=this[Ce]===void 0?new Pg({}):a?new zg({}):new Mg({}),this[Ce].on("data",x=>this[os](x)),this[Ce].on("error",x=>this.abort(x)),this[Ce].on("end",()=>{this[nn]=!0,this[os]()}),this[rr]=!0;let u=!!this[Ce][d?"end":"write"](t);return this[rr]=!1,r?.(),u}}this[rr]=!0,this[Ce]?this[Ce].write(t):this[os](t),this[rr]=!1;let s=this[Mt].length>0?!1:this[Nt]?this[Nt].flowing:!0;return!s&&this[Mt].length===0&&this[Nt]?.once("drain",()=>this.emit("drain")),r?.(),s}[va](t){t&&!this[rn]&&(this[xe]=this[xe]?Buffer.concat([this[xe],t]):t)}[cs](){if(this[nn]&&!this[ba]&&!this[rn]&&!this[$r]){this[ba]=!0;let t=this[An];if(t&&t.blockRemain){let e=this[xe]?this[xe].length:0;this.warn("TAR_BAD_ARCHIVE",`Truncated input (needed ${t.blockRemain} more bytes, only ${e} available)`,{entry:t}),this[xe]&&t.write(this[xe]),t.end()}this[Tn](fs)}}[os](t){if(this[$r]&&t)this[va](t);else if(!t&&!this[xe])this[cs]();else if(t){if(this[$r]=!0,this[xe]){this[va](t);let e=this[xe];this[xe]=void 0,this[as](e)}else this[as](t);for(;this[xe]&&this[xe]?.length>=512&&!this[rn]&&!this[us];){let e=this[xe];this[xe]=void 0,this[as](e)}this[$r]=!1}(!this[xe]||this[nn])&&this[cs]()}[as](t){let e=0,r=t.length;for(;e+512<=r&&!this[rn]&&!this[us];)switch(this[it]){case"begin":case"header":this[Hf](t,e),e+=512;break;case"ignore":case"body":e+=this[Ea](t,e);break;case"meta":e+=this[qf](t,e);break;default:throw new Error("invalid state: "+this[it])}e<r&&(this[xe]=this[xe]?Buffer.concat([t.subarray(e),this[xe]]):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[rn]||(this[Ce]?(t&&this[Ce].write(t),this[Ce].end()):(this[nn]=!0,(this.brotli===void 0||this.zstd===void 0)&&(t=t||Buffer.alloc(0)),t&&this.write(t),this[cs]())),this}},ni=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)},dm=t=>{let e=t.onReadEntry;t.onReadEntry=e?r=>{e(r),r.resume()}:r=>r.resume()},Sd=(t,e)=>{let r=new Map(e.map(c=>[ni(c),!0])),s=t.filter,a=(c,d="")=>{let u=d||yg(c).root||".",x;if(c===u)x=!1;else{let p=r.get(c);x=p!==void 0?p:a(_g(c),u)}return r.set(c,x),x};t.filter=s?(c,d)=>s(c,d)&&a(ni(c)):c=>a(ni(c))},um=t=>{let e=new fi(t),r=t.file,s;try{s=fr.openSync(r,"r");let a=fr.fstatSync(s),c=t.maxReadSize||16*1024*1024;if(a.size<c){let d=Buffer.allocUnsafe(a.size),u=fr.readSync(s,d,0,a.size,0);e.end(u===d.byteLength?d:d.subarray(0,u))}else{let d=0,u=Buffer.allocUnsafe(c);for(;d<a.size;){let x=fr.readSync(s,u,0,c,d);if(x===0)break;d+=x,e.write(u.subarray(0,x))}e.end()}}finally{if(typeof s=="number")try{fr.closeSync(s)}catch{}}},lm=(t,e)=>{let r=new fi(t),s=t.maxReadSize||16*1024*1024,a=t.file;return new Promise((c,d)=>{r.on("error",d),r.on("end",c),fr.stat(a,(u,x)=>{if(u)d(u);else{let p=new ec(a,{readSize:s,size:x.size});p.on("error",d),p.pipe(r)}})})},xr=di(um,lm,t=>new fi(t),t=>new fi(t),(t,e)=>{e?.length&&Sd(t,e),t.noResume||dm(t)}),Id=(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:hm,parse:Wf}=xm,ic=t=>{let e="",r=Wf(t);for(;hm(t)||r.root;){let s=t.charAt(0)==="/"&&t.slice(0,4)!=="//?/"?"/":r.root;t=t.slice(s.length),e+=s,r=Wf(t)}return[e,t]},Os=["|","<",">","?",":"],sc=Os.map(t=>String.fromCodePoint(61440+Number(t.codePointAt(0)))),pm=new Map(Os.map((t,e)=>[t,sc[e]])),gm=new Map(sc.map((t,e)=>[t,Os[e]])),Kf=t=>Os.reduce((e,r)=>e.split(r).join(pm.get(r)),t),mm=t=>sc.reduce((e,r)=>e.split(r).join(gm.get(r)),t),Cd=(t,e)=>e?(t=Q(t).replace(/^\.(\/|$)/,""),ni(e)+"/"+t):Q(t),wm=16*1024*1024,$f=Symbol("process"),Vf=Symbol("file"),Jf=Symbol("directory"),Ba=Symbol("symlink"),Zf=Symbol("hardlink"),Vr=Symbol("header"),ms=Symbol("read"),za=Symbol("lstat"),ws=Symbol("onlstat"),Fa=Symbol("onread"),Ua=Symbol("onreadlink"),qa=Symbol("openfile"),Ha=Symbol("onopenfile"),fn=Symbol("close"),As=Symbol("mode"),ja=Symbol("awaitDrain"),Sa=Symbol("ondrain"),Et=Symbol("prefix"),Ad=class extends Nn{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=tc(e);super(),this.path=Q(t),this.portable=!!r.portable,this.maxReadSize=r.maxReadSize||wm,this.linkCache=r.linkCache||new Map,this.statCache=r.statCache||new Map,this.preservePaths=!!r.preservePaths,this.cwd=Q(r.cwd||process.cwd()),this.strict=!!r.strict,this.noPax=!!r.noPax,this.noMtime=!!r.noMtime,this.mtime=r.mtime,this.prefix=r.prefix?Q(r.prefix):void 0,this.onWriteEntry=r.onWriteEntry,typeof r.onwarn=="function"&&this.on("warn",r.onwarn);let s=!1;if(!this.preservePaths){let[c,d]=ic(this.path);c&&typeof d=="string"&&(this.path=d,s=c)}this.win32=!!r.win32||process.platform==="win32",this.win32&&(this.path=mm(this.path.replaceAll(/\\/g,"/")),t=t.replaceAll(/\\/g,"/")),this.absolute=Q(r.absolute||Gf.resolve(this.cwd,t)),this.path===""&&(this.path="./"),s&&this.warn("TAR_ENTRY_INFO",`stripping ${s} from absolute path`,{entry:this,path:s+this.path});let a=this.statCache.get(this.absolute);a?this[ws](a):this[za]()}warn(t,e,r={}){return Ls(this,t,e,r)}emit(t,...e){return t==="error"&&(this.#e=!0),super.emit(t,...e)}[za](){bt.lstat(this.absolute,(t,e)=>{if(t)return this.emit("error",t);this[ws](e)})}[ws](t){this.statCache.set(this.absolute,t),this.stat=t,t.isFile()||(t.size=0),this.type=bm(t),this.emit("stat",t),this[$f]()}[$f](){switch(this.type){case"File":return this[Vf]();case"Directory":return this[Jf]();case"SymbolicLink":return this[Ba]();default:return this.end()}}[As](t){return Id(t,this.type==="Directory",this.portable)}[Et](t){return Cd(t,this.prefix)}[Vr](){if(!this.stat)throw new Error("cannot write header before stat");this.type==="Directory"&&this.portable&&(this.noMtime=!0),this.onWriteEntry?.(this),this.header=new Pn({path:this[Et](this.path),linkpath:this.type==="Link"&&this.linkpath!==void 0?this[Et](this.linkpath):this.linkpath,mode:this[As](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 Is({atime:this.portable?void 0:this.header.atime,ctime:this.portable?void 0:this.header.ctime,gid:this.portable?void 0:this.header.gid,mtime:this.noMtime?void 0:this.mtime||this.header.mtime,path:this[Et](this.path),linkpath:this.type==="Link"&&this.linkpath!==void 0?this[Et](this.linkpath):this.linkpath,size:this.header.size,uid:this.portable?void 0:this.header.uid,uname:this.portable?void 0:this.header.uname,dev:this.portable?void 0:this.stat.dev,ino:this.portable?void 0:this.stat.ino,nlink:this.portable?void 0:this.stat.nlink}).encode());let t=this.header?.block;if(!t)throw new Error("failed to encode header");super.write(t)}[Jf](){if(!this.stat)throw new Error("cannot create directory entry without stat");this.path.slice(-1)!=="/"&&(this.path+="/"),this.stat.size=0,this[Vr](),this.end()}[Ba](){bt.readlink(this.absolute,(t,e)=>{if(t)return this.emit("error",t);this[Ua](e)})}[Ua](t){this.linkpath=Q(t),this[Vr](),this.end()}[Zf](t){if(!this.stat)throw new Error("cannot create link entry without stat");this.type="Link",this.linkpath=Q(Gf.relative(this.cwd,t)),this.stat.size=0,this[Vr](),this.end()}[Vf](){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[Zf](e);this.linkCache.set(t,this.absolute)}if(this[Vr](),this.stat.size===0)return this.end();this[qa]()}[qa](){bt.open(this.absolute,"r",(t,e)=>{if(t)return this.emit("error",t);this[Ha](e)})}[Ha](t){if(this.fd=t,this.#e)return this[fn]();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[ms]()}[ms](){let{fd:t,buf:e,offset:r,length:s,pos:a}=this;if(t===void 0||e===void 0)throw new Error("cannot read file without first opening");bt.read(t,e,r,s,a,(c,d)=>{if(c)return this[fn](()=>this.emit("error",c));this[Fa](d)})}[fn](t=()=>{}){this.fd!==void 0&&bt.close(this.fd,t)}[Fa](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[fn](()=>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[fn](()=>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[Sa]():this[ja](()=>this[Sa]())}[ja](t){this.once("drain",t)}write(t,e,r){if(typeof e=="function"&&(r=e,e=void 0),typeof t=="string"&&(t=Buffer.from(t,typeof e=="string"?e:"utf8")),this.blockRemain<t.length){let s=Object.assign(new Error("writing more data than expected"),{path:this.absolute});return this.emit("error",s)}return this.remain-=t.length,this.blockRemain-=t.length,this.pos+=t.length,this.offset+=t.length,super.write(t,null,r)}[Sa](){if(!this.remain)return this.blockRemain&&super.write(Buffer.alloc(this.blockRemain)),this[fn](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[ms]()}},_m=class extends Ad{sync=!0;[za](){this[ws](bt.lstatSync(this.absolute))}[Ba](){this[Ua](bt.readlinkSync(this.absolute))}[qa](){this[Ha](bt.openSync(this.absolute,"r"))}[ms](){let t=!0;try{let{fd:e,buf:r,offset:s,length:a,pos:c}=this;if(e===void 0||r===void 0)throw new Error("fd and buf must be set in READ method");let d=bt.readSync(e,r,s,a,c);this[Fa](d),t=!1}finally{if(t)try{this[fn](()=>{})}catch{}}}[ja](t){t()}[fn](t=()=>{}){this.fd!==void 0&&bt.closeSync(this.fd),t()}},ym=class extends Nn{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 Ls(this,t,e,r)}constructor(t,e={}){let r=tc(e);super(),this.preservePaths=!!r.preservePaths,this.portable=!!r.portable,this.strict=!!r.strict,this.noPax=!!r.noPax,this.noMtime=!!r.noMtime,this.onWriteEntry=r.onWriteEntry,this.readEntry=t;let{type:s}=t;if(s==="Unsupported")throw new Error("writing entry that should be ignored");this.type=s,this.type==="Directory"&&this.portable&&(this.noMtime=!0),this.prefix=r.prefix,this.path=Q(t.path),this.mode=t.mode!==void 0?this[As](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?Q(t.linkpath):void 0,typeof r.onwarn=="function"&&this.on("warn",r.onwarn);let a=!1;if(!this.preservePaths){let[d,u]=ic(this.path);d&&typeof u=="string"&&(this.path=u,a=d)}this.remain=t.size,this.blockRemain=t.startBlockSize,this.onWriteEntry?.(this),this.header=new Pn({path:this[Et](this.path),linkpath:this.type==="Link"&&this.linkpath!==void 0?this[Et](this.linkpath):this.linkpath,mode:this.mode,uid:this.portable?void 0:this.uid,gid:this.portable?void 0:this.gid,size:this.size,mtime:this.noMtime?void 0:this.mtime,type:this.type,uname:this.portable?void 0:this.uname,atime:this.portable?void 0:this.atime,ctime:this.portable?void 0:this.ctime}),a&&this.warn("TAR_ENTRY_INFO",`stripping ${a} from absolute path`,{entry:this,path:a+this.path}),this.header.encode()&&!this.noPax&&super.write(new Is({atime:this.portable?void 0:this.atime,ctime:this.portable?void 0:this.ctime,gid:this.portable?void 0:this.gid,mtime:this.noMtime?void 0:this.mtime,path:this[Et](this.path),linkpath:this.type==="Link"&&this.linkpath!==void 0?this[Et](this.linkpath):this.linkpath,size:this.size,uid:this.portable?void 0:this.uid,uname:this.portable?void 0:this.uname,dev:this.portable?void 0:this.readEntry.dev,ino:this.portable?void 0:this.readEntry.ino,nlink:this.portable?void 0:this.readEntry.nlink}).encode());let c=this.header?.block;if(!c)throw new Error("failed to encode header");super.write(c),t.pipe(this)}[Et](t){return Cd(t,this.prefix)}[As](t){return Id(t,this.type==="Directory",this.portable)}write(t,e,r){typeof e=="function"&&(r=e,e=void 0),typeof t=="string"&&(t=Buffer.from(t,typeof e=="string"?e:"utf8"));let s=t.length;if(s>this.blockRemain)throw new Error("writing more to entry than is appropriate");return this.blockRemain-=s,super.write(t,r)}end(t,e,r){return this.blockRemain&&super.write(Buffer.alloc(this.blockRemain)),typeof t=="function"&&(r=t,e=void 0,t=void 0),typeof e=="function"&&(r=e,e=void 0),typeof t=="string"&&(t=Buffer.from(t,e??"utf8")),r&&this.once("finish",r),t?super.end(t,r):super.end(r),this}},bm=t=>t.isFile()?"File":t.isDirectory()?"Directory":t.isSymbolicLink()?"SymbolicLink":"Unsupported",Em=class dr{tail;head;length=0;static create(e=[]){return new dr(e)}constructor(e=[]){for(let r of e)this.push(r)}*[Symbol.iterator](){for(let e=this.head;e;e=e.next)yield e.value}removeNode(e){if(e.list!==this)throw new Error("removing node which does not belong to this list");let r=e.next,s=e.prev;return r&&(r.prev=s),s&&(s.next=r),e===this.head&&(this.head=r),e===this.tail&&(this.tail=s),this.length--,e.next=void 0,e.prev=void 0,e.list=void 0,r}unshiftNode(e){if(e===this.head)return;e.list&&e.list.removeNode(e);let r=this.head;e.list=this,e.next=r,r&&(r.prev=e),this.head=e,this.tail||(this.tail=e),this.length++}pushNode(e){if(e===this.tail)return;e.list&&e.list.removeNode(e);let r=this.tail;e.list=this,e.prev=r,r&&(r.next=e),this.tail=e,this.head||(this.head=e),this.length++}push(...e){for(let r=0,s=e.length;r<s;r++)Sm(this,e[r]);return this.length}unshift(...e){for(var r=0,s=e.length;r<s;r++)Im(this,e[r]);return this.length}pop(){if(!this.tail)return;let e=this.tail.value,r=this.tail;return this.tail=this.tail.prev,this.tail?this.tail.next=void 0:this.head=void 0,r.list=void 0,this.length--,e}shift(){if(!this.head)return;let e=this.head.value,r=this.head;return this.head=this.head.next,this.head?this.head.prev=void 0:this.tail=void 0,r.list=void 0,this.length--,e}forEach(e,r){r=r||this;for(let s=this.head,a=0;s;a++)e.call(r,s.value,a,this),s=s.next}forEachReverse(e,r){r=r||this;for(let s=this.tail,a=this.length-1;s;a--)e.call(r,s.value,a,this),s=s.prev}get(e){let r=0,s=this.head;for(;s&&r<e;r++)s=s.next;if(r===e&&s)return s.value}getReverse(e){let r=0,s=this.tail;for(;s&&r<e;r++)s=s.prev;if(r===e&&s)return s.value}map(e,r){r=r||this;let s=new dr;for(let a=this.head;a;)s.push(e.call(r,a.value,this)),a=a.next;return s}mapReverse(e,r){r=r||this;var s=new dr;for(let a=this.tail;a;)s.push(e.call(r,a.value,this)),a=a.prev;return s}reduce(e,r){let s,a=this.head;if(arguments.length>1)s=r;else if(this.head)a=this.head.next,s=this.head.value;else throw new TypeError("Reduce of empty list with no initial value");for(var c=0;a;c++)s=e(s,a.value,c),a=a.next;return s}reduceReverse(e,r){let s,a=this.tail;if(arguments.length>1)s=r;else if(this.tail)a=this.tail.prev,s=this.tail.value;else throw new TypeError("Reduce of empty list with no initial value");for(let c=this.length-1;a;c--)s=e(s,a.value,c),a=a.prev;return s}toArray(){let e=new Array(this.length);for(let r=0,s=this.head;s;r++)e[r]=s.value,s=s.next;return e}toArrayReverse(){let e=new Array(this.length);for(let r=0,s=this.tail;s;r++)e[r]=s.value,s=s.prev;return e}slice(e=0,r=this.length){r<0&&(r+=this.length),e<0&&(e+=this.length);let s=new dr;if(r<e||r<0)return s;e<0&&(e=0),r>this.length&&(r=this.length);let a=this.head,c=0;for(c=0;a&&c<e;c++)a=a.next;for(;a&&c<r;c++,a=a.next)s.push(a.value);return s}sliceReverse(e=0,r=this.length){r<0&&(r+=this.length),e<0&&(e+=this.length);let s=new dr;if(r<e||r<0)return s;e<0&&(e=0),r>this.length&&(r=this.length);let a=this.length,c=this.tail;for(;c&&a>r;a--)c=c.prev;for(;c&&a>e;a--,c=c.prev)s.push(c.value);return s}splice(e,r=0,...s){e>this.length&&(e=this.length-1),e<0&&(e=this.length+e);let a=this.head;for(let d=0;a&&d<e;d++)a=a.next;let c=[];for(let d=0;a&&d<r;d++)c.push(a.value),a=this.removeNode(a);a?a!==this.tail&&(a=a.prev):a=this.tail;for(let d of s)a=vm(this,a,d);return c}reverse(){let e=this.head,r=this.tail;for(let s=e;s;s=s.prev){let a=s.prev;s.prev=s.next,s.next=a}return this.head=r,this.tail=e,this}};function vm(t,e,r){let s=e,a=e?e.next:t.head,c=new oc(r,s,a,t);return c.next===void 0&&(t.tail=c),c.prev===void 0&&(t.head=c),t.length++,c}function Sm(t,e){t.tail=new oc(e,t.tail,void 0,t),t.head||(t.head=t.tail),t.length++}function Im(t,e){t.head=new oc(e,void 0,t.head,t),t.tail||(t.tail=t.head),t.length++}var oc=class{list;next;prev;value;constructor(t,e,r,s){this.list=s,this.value=t,e?(e.next=this,this.prev=e):this.prev=void 0,r?(r.prev=this,this.next=r):this.next=void 0}},Yf=class{path;absolute;entry;stat;readdir;pending=!1;pendingLink=!1;ignore=!1;piped=!1;constructor(t,e){this.path=t||"./",this.absolute=e}},Qf=Buffer.alloc(1024),_s=Symbol("onStat"),Jr=Symbol("ended"),lt=Symbol("queue"),Zr=Symbol("queue"),sn=Symbol("current"),Rn=Symbol("process"),Xr=Symbol("processing"),ls=Symbol("processJob"),xt=Symbol("jobs"),Ia=Symbol("jobDone"),ys=Symbol("addFSEntry"),ed=Symbol("addTarEntry"),Ga=Symbol("stat"),Wa=Symbol("readdir"),bs=Symbol("onreaddir"),Es=Symbol("pipe"),td=Symbol("entry"),Ca=Symbol("entryOpt"),vs=Symbol("writeEntryClass"),Td=Symbol("write"),Aa=Symbol("ondrain"),Ps=class extends Nn{sync=!1;opt;cwd;maxReadSize;preservePaths;strict;noPax;prefix;linkCache;statCache;file;portable;zip;readdirCache;noDirRecurse;follow;noMtime;mtime;filter;jobs;[vs];onWriteEntry;[lt];[Zr]=new Map;[xt]=0;[Xr]=!1;[Jr]=!1;constructor(t={}){if(super(),this.opt=t,this.file=t.file||"",this.cwd=t.cwd||process.cwd(),this.maxReadSize=t.maxReadSize,this.preservePaths=!!t.preservePaths,this.strict=!!t.strict,this.noPax=!!t.noPax,this.prefix=Q(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[vs]=Ad,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 Og(t.gzip)),t.brotli&&(typeof t.brotli!="object"&&(t.brotli={}),this.zip=new Ng(t.brotli)),t.zstd&&(typeof t.zstd!="object"&&(t.zstd={}),this.zip=new Bg(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[Aa]()),this.on("resume",()=>e.resume())}else this.on("drain",this[Aa]);this.noDirRecurse=!!t.noDirRecurse,this.follow=!!t.follow,this.noMtime=!!t.noMtime,t.mtime&&(this.mtime=t.mtime),this.filter=typeof t.filter=="function"?t.filter:()=>!0,this[lt]=new Em,this[xt]=0,this.jobs=Number(t.jobs)||4,this[Xr]=!1,this[Jr]=!1}[Td](t){return super.write(t)}add(t){return this.write(t),this}end(t,e,r){return typeof t=="function"&&(r=t,t=void 0),typeof e=="function"&&(r=e,e=void 0),t&&this.add(t),this[Jr]=!0,this[Rn](),r&&r(),this}write(t){if(this[Jr])throw new Error("write after end");return t instanceof vd?this[ed](t):this[ys](t),this.flowing}[ed](t){let e=Q(Xf.resolve(this.cwd,t.path));if(!this.filter(t.path,t))t.resume();else{let r=new Yf(t.path,e);r.entry=new ym(t,this[Ca](r)),r.entry.on("end",()=>this[Ia](r)),this[xt]+=1,this[lt].push(r)}this[Rn]()}[ys](t){let e=Q(Xf.resolve(this.cwd,t));this[lt].push(new Yf(t,e)),this[Rn]()}[Ga](t){t.pending=!0,this[xt]+=1;let e=this.follow?"stat":"lstat";Cs[e](t.absolute,(r,s)=>{t.pending=!1,this[xt]-=1,r?this.emit("error",r):this[_s](t,s)})}[_s](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[sn])this[ls](t);else{let r=`${e.dev}:${e.ino}`,s=this[Zr].get(r);s?s.push(t):this[Zr].set(r,[t]),t.pendingLink=!0,t.pending=!0}this[Rn]()}[Wa](t){t.pending=!0,this[xt]+=1,Cs.readdir(t.absolute,(e,r)=>{if(t.pending=!1,this[xt]-=1,e)return this.emit("error",e);this[bs](t,r)})}[bs](t,e){this.readdirCache.set(t.absolute,e),t.readdir=e,this[Rn]()}[Rn](){if(!this[Xr]){this[Xr]=!0;for(let t=this[lt].head;t&&this[xt]<this.jobs;t=t.next)if(this[ls](t.value),t.value.ignore){let e=t.next;this[lt].removeNode(t),t.next=e}this[Xr]=!1,this[Jr]&&this[lt].length===0&&this[xt]===0&&(this.zip?this.zip.end(Qf):(super.write(Qf),super.end()))}}get[sn](){return this[lt]&&this[lt].head&&this[lt].head.value}[Ia](t){this[lt].shift(),this[xt]-=1;let{stat:e}=t;if(e&&e.isFile()&&e.nlink>1){let r=`${e.dev}:${e.ino}`,s=this[Zr].get(r);if(s){this[Zr].delete(r);for(let a of s)a.pending=!1,this[ls](a)}}this[Rn]()}[ls](t){if(t.pending&&t.pendingLink&&t===this[sn]&&(t.pending=!1,t.pendingLink=!1),!t.pending){if(t.entry){t===this[sn]&&!t.piped&&this[Es](t);return}if(!t.stat){let e=this.statCache.get(t.absolute);e?this[_s](t,e):this[Ga](t)}if(t.stat&&!t.ignore){if(!this.noDirRecurse&&t.stat.isDirectory()&&!t.readdir){let e=this.readdirCache.get(t.absolute);if(e?this[bs](t,e):this[Wa](t),!t.readdir)return}if(t.entry=this[td](t),!t.entry){t.ignore=!0;return}t===this[sn]&&!t.piped&&this[Es](t)}}}[Ca](t){return{onwarn:(e,r,s)=>this.warn(e,r,s),noPax:this.noPax,cwd:this.cwd,absolute:t.absolute,preservePaths:this.preservePaths,maxReadSize:this.maxReadSize,strict:this.strict,portable:this.portable,linkCache:this.linkCache,statCache:this.statCache,noMtime:this.noMtime,mtime:this.mtime,prefix:this.prefix,onWriteEntry:this.onWriteEntry}}[td](t){this[xt]+=1;try{return new this[vs](t.path,this[Ca](t)).on("end",()=>this[Ia](t)).on("error",e=>this.emit("error",e))}catch(e){this.emit("error",e)}}[Aa](){this[sn]&&this[sn].entry&&this[sn].entry.resume()}[Es](t){t.piped=!0,t.readdir&&t.readdir.forEach(s=>{let a=t.path,c=a==="./"?"":a.replace(/\/*$/,"/");this[ys](c+s)});let e=t.entry,r=this.zip;if(!e)throw new Error("cannot pipe without source");r?e.on("data",s=>{r.write(s)||e.pause()}):e.on("data",s=>{super.write(s)||e.pause()})}pause(){return this.zip&&this.zip.pause(),super.pause()}warn(t,e,r={}){Ls(this,t,e,r)}},ac=class extends Ps{sync=!0;constructor(t){super(t),this[vs]=_m}pause(){}resume(){}[Ga](t){let e=this.follow?"statSync":"lstatSync";this[_s](t,Cs[e](t.absolute))}[Wa](t){this[bs](t,Cs.readdirSync(t.absolute))}[Es](t){let e=t.entry,r=this.zip;if(t.readdir&&t.readdir.forEach(s=>{let a=t.path,c=a==="./"?"":a.replace(/\/*$/,"/");this[ys](c+s)}),!e)throw new Error("Cannot pipe without source");r?e.on("data",s=>{r.write(s)}):e.on("data",s=>{super[Td](s)})}},Cm=(t,e)=>{let r=new ac(t),s=new pd(t.file,{mode:t.mode||438});r.pipe(s),Dd(r,e)},Am=(t,e)=>{let r=new Ps(t),s=new Rs(t.file,{mode:t.mode||438});r.pipe(s);let a=new Promise((c,d)=>{s.on("error",d),s.on("close",c),r.on("error",d)});return Rd(r,e).catch(c=>r.emit("error",c)),a},Dd=(t,e)=>{e.forEach(r=>{r.charAt(0)==="@"?xr({file:gd.resolve(t.cwd,r.slice(1)),sync:!0,noResume:!0,onReadEntry:s=>t.add(s)}):t.add(r)}),t.end()},Rd=async(t,e)=>{for(let r of e)r.charAt(0)==="@"?await xr({file:gd.resolve(String(t.cwd),r.slice(1)),noResume:!0,onReadEntry:s=>{t.add(s)}}):t.add(r);t.end()},Tm=(t,e)=>{let r=new ac(t);return Dd(r,e),r},Dm=(t,e)=>{let r=new Ps(t);return Rd(r,e).catch(s=>r.emit("error",s)),r},L2=di(Cm,Am,Tm,Dm,(t,e)=>{if(!e?.length)throw new TypeError("no paths specified to add to archive")}),km=process.env.__FAKE_PLATFORM__||process.platform,Pd=km==="win32",{O_CREAT:Nd,O_NOFOLLOW:nd,O_TRUNC:Md,O_WRONLY:Bd}=Od.constants,zd=Number(process.env.__FAKE_FS_O_FILENAME__)||Od.constants.UV_FS_O_FILEMAP||0,Lm=Pd&&!!zd,Om=512*1024,Pm=zd|Md|Nd|Bd,rd=!Pd&&typeof nd=="number"?nd|Md|Nd|Bd:null,Fd=rd!==null?()=>rd:Lm?t=>t<Om?Pm:"w":()=>"w",Ka=(t,e,r)=>{try{return Ns.lchownSync(t,e,r)}catch(s){if(s?.code!=="ENOENT")throw s}},Ts=(t,e,r,s)=>{Ns.lchown(t,e,r,a=>{s(a&&a?.code!=="ENOENT"?a:null)})},Nm=(t,e,r,s,a)=>{if(e.isDirectory())Ud(ri.resolve(t,e.name),r,s,c=>{if(c)return a(c);let d=ri.resolve(t,e.name);Ts(d,r,s,a)});else{let c=ri.resolve(t,e.name);Ts(c,r,s,a)}},Ud=(t,e,r,s)=>{Ns.readdir(t,{withFileTypes:!0},(a,c)=>{if(a){if(a.code==="ENOENT")return s();if(a.code!=="ENOTDIR"&&a.code!=="ENOTSUP")return s(a)}if(a||!c.length)return Ts(t,e,r,s);let d=c.length,u=null,x=p=>{if(!u){if(p)return s(u=p);if(--d===0)return Ts(t,e,r,s)}};for(let p of c)Nm(t,p,e,r,x)})},Mm=(t,e,r,s)=>{e.isDirectory()&&qd(ri.resolve(t,e.name),r,s),Ka(ri.resolve(t,e.name),r,s)},qd=(t,e,r)=>{let s;try{s=Ns.readdirSync(t,{withFileTypes:!0})}catch(a){let c=a;if(c?.code==="ENOENT")return;if(c?.code==="ENOTDIR"||c?.code==="ENOTSUP")return Ka(t,e,r);throw c}for(let a of s)Mm(t,a,e,r);return Ka(t,e,r)},Hd=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"}},Ms=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"}},zm=(t,e)=>{et.stat(t,(r,s)=>{(r||!s.isDirectory())&&(r=new Hd(t,r?.code||"ENOTDIR")),e(r)})},Fm=(t,e,r)=>{t=Q(t);let s=e.umask??18,a=e.mode|448,c=(a&s)!==0,d=e.uid,u=e.gid,x=typeof d=="number"&&typeof u=="number"&&(d!==e.processUid||u!==e.processGid),p=e.preserve,_=e.unlink,w=Q(e.cwd),S=(E,v)=>{E?r(E):v&&x?Ud(v,d,u,C=>S(C)):c?et.chmod(t,a,r):r()};if(t===w)return zm(t,S);if(p)return Bm.mkdir(t,{mode:a,recursive:!0}).then(E=>S(null,E??void 0),S);let b=Q(Ds.relative(w,t)).split("/");$a(w,b,a,_,w,void 0,S)},$a=(t,e,r,s,a,c,d)=>{if(e.length===0)return d(null,c);let u=e.shift(),x=Q(Ds.resolve(t+"/"+u));et.mkdir(x,r,jd(x,e,r,s,a,c,d))},jd=(t,e,r,s,a,c,d)=>u=>{u?et.lstat(t,(x,p)=>{if(x)x.path=x.path&&Q(x.path),d(x);else if(p.isDirectory())$a(t,e,r,s,a,c,d);else if(s)et.unlink(t,_=>{if(_)return d(_);et.mkdir(t,r,jd(t,e,r,s,a,c,d))});else{if(p.isSymbolicLink())return d(new Ms(t,t+"/"+e.join("/")));d(u)}}):(c=c||t,$a(t,e,r,s,a,c,d))},Um=t=>{let e=!1,r;try{e=et.statSync(t).isDirectory()}catch(s){r=s?.code}finally{if(!e)throw new Hd(t,r??"ENOTDIR")}},qm=(t,e)=>{t=Q(t);let r=e.umask??18,s=e.mode|448,a=(s&r)!==0,c=e.uid,d=e.gid,u=typeof c=="number"&&typeof d=="number"&&(c!==e.processUid||d!==e.processGid),x=e.preserve,p=e.unlink,_=Q(e.cwd),w=E=>{E&&u&&qd(E,c,d),a&&et.chmodSync(t,s)};if(t===_)return Um(_),w();if(x)return w(et.mkdirSync(t,{mode:s,recursive:!0})??void 0);let S=Q(Ds.relative(_,t)).split("/"),b;for(let E=S.shift(),v=_;E&&(v+="/"+E);E=S.shift()){v=Q(Ds.resolve(v));try{et.mkdirSync(v,s),b=b||v}catch{let C=et.lstatSync(v);if(C.isDirectory())continue;if(p){et.unlinkSync(v),et.mkdirSync(v,s),b=b||v;continue}else if(C.isSymbolicLink())return new Ms(v,v+"/"+S.join("/"))}}return w(b)},Ta=Object.create(null),id=1e4,ir=new Set,Hm=t=>{ir.has(t)?ir.delete(t):Ta[t]=t.normalize("NFD").toLocaleLowerCase("en").toLocaleUpperCase("en"),ir.add(t);let e=Ta[t],r=ir.size-id;if(r>id/10){for(let s of ir)if(ir.delete(s),delete Ta[s],--r<=0)break}return e},jm=process.env.TESTING_TAR_FAKE_PLATFORM||process.platform,Gm=jm==="win32",Wm=t=>t.split("/").slice(0,-1).reduce((e,r)=>{let s=e.at(-1);return s!==void 0&&(r=Gd(s,r)),e.push(r||"/"),e},[]),Km=class{#e=new Map;#n=new Map;#r=new Set;reserve(t,e){t=Gm?["win32 parallelization disabled"]:t.map(s=>ni(Gd(Hm(s))));let r=new Set(t.map(s=>Wm(s)).reduce((s,a)=>s.concat(a)));this.#n.set(e,{dirs:r,paths:t});for(let s of t){let a=this.#e.get(s);a?a.push(e):this.#e.set(s,[e])}for(let s of r){let a=this.#e.get(s);if(!a)this.#e.set(s,[new Set([e])]);else{let c=a.at(-1);c instanceof Set?c.add(e):a.push(new Set([e]))}}return this.#i(e)}#s(t){let e=this.#n.get(t);if(!e)throw new Error("function does not have any path reservations");return{paths:e.paths.map(r=>this.#e.get(r)),dirs:[...e.dirs].map(r=>this.#e.get(r))}}check(t){let{paths:e,dirs:r}=this.#s(t);return e.every(s=>s&&s[0]===t)&&r.every(s=>s&&s[0]instanceof Set&&s[0].has(t))}#i(t){return this.#r.has(t)||!this.check(t)?!1:(this.#r.add(t),t(()=>this.#t(t)),!0)}#t(t){if(!this.#r.has(t))return!1;let e=this.#n.get(t);if(!e)throw new Error("invalid reservation");let{paths:r,dirs:s}=e,a=new Set;for(let c of r){let d=this.#e.get(c);if(!d||d?.[0]!==t)continue;let u=d[1];if(!u){this.#e.delete(c);continue}if(d.shift(),typeof u=="function")a.add(u);else for(let x of u)a.add(x)}for(let c of s){let d=this.#e.get(c),u=d?.[0];if(!(!d||!(u instanceof Set)))if(u.size===1&&d.length===1){this.#e.delete(c);continue}else if(u.size===1){d.shift();let x=d[0];typeof x=="function"&&a.add(x)}else u.delete(t)}return this.#r.delete(t),a.forEach(c=>this.#i(c)),!0}},$m=()=>process.umask(),sd=Symbol("onEntry"),Va=Symbol("checkFs"),od=Symbol("checkFs2"),Ja=Symbol("isReusable"),st=Symbol("makeFs"),Za=Symbol("file"),Xa=Symbol("directory"),Ss=Symbol("link"),ad=Symbol("symlink"),cd=Symbol("hardlink"),ei=Symbol("ensureNoSymlink"),fd=Symbol("unsupported"),dd=Symbol("checkPath"),Da=Symbol("stripAbsolutePath"),dn=Symbol("mkdir"),Ne=Symbol("onError"),xs=Symbol("pending"),ud=Symbol("pend"),sr=Symbol("unpend"),Ra=Symbol("ended"),ka=Symbol("maybeClose"),Ya=Symbol("skip"),ii=Symbol("doChown"),si=Symbol("uid"),oi=Symbol("gid"),ai=Symbol("checkedCwd"),Vm=process.env.TESTING_TAR_FAKE_PLATFORM||process.platform,ci=Vm==="win32",Jm=1024,Zm=(t,e)=>{if(!ci)return ne.unlink(t,e);let r=t+".DELETE."+Ld(16).toString("hex");ne.rename(t,r,s=>{if(s)return e(s);ne.unlink(r,e)})},Xm=t=>{if(!ci)return ne.unlinkSync(t);let e=t+".DELETE."+Ld(16).toString("hex");ne.renameSync(t,e),ne.unlinkSync(e)},ld=(t,e,r)=>t!==void 0&&t===t>>>0?t:e!==void 0&&e===e>>>0?e:r,cc=class extends fi{[Ra]=!1;[ai]=!1;[xs]=0;reservations=new Km;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[Ra]=!0,this[ka]()},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:Jm,this.forceChown=t.forceChown===!0,this.win32=!!t.win32||ci,this.newer=!!t.newer,this.keep=!!t.keep,this.noMtime=!!t.noMtime,this.preservePaths=!!t.preservePaths,this.unlink=!!t.unlink,this.cwd=Q(De.resolve(t.cwd||process.cwd())),this.strip=Number(t.strip)||0,this.processUmask=this.chmod?typeof t.processUmask=="number"?t.processUmask:$m():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[sd](e))}warn(t,e,r={}){return(t==="TAR_BAD_ARCHIVE"||t==="TAR_ABORT")&&(r.recoverable=!1),super.warn(t,e,r)}[ka](){this[Ra]&&this[xs]===0&&(this.emit("prefinish"),this.emit("finish"),this.emit("end"))}[Da](t,e){let r=t[e],{type:s}=t;if(!r||this.preservePaths)return!0;let[a,c]=ic(r),d=c.replaceAll(/\\/g,"/").split("/");if(d.includes("..")||ci&&/^[a-z]:\.\.$/i.test(d[0]??"")){if(e==="path"||s==="Link")return this.warn("TAR_ENTRY_ERROR",`${e} contains '..'`,{entry:t,[e]:r}),!1;let u=De.posix.dirname(t.path),x=De.posix.normalize(De.posix.join(u,d.join("/")));if(x.startsWith("../")||x==="..")return this.warn("TAR_ENTRY_ERROR",`${e} escapes extraction directory`,{entry:t,[e]:r}),!1}return a&&(t[e]=String(c),this.warn("TAR_ENTRY_INFO",`stripping ${a} from absolute ${e}`,{entry:t,[e]:r})),!0}[dd](t){let e=Q(t.path),r=e.split("/");if(this.strip){if(r.length<this.strip)return!1;if(t.type==="Link"){let s=Q(String(t.linkpath)).split("/");if(s.length>=this.strip)t.linkpath=s.slice(this.strip).join("/");else return!1}r.splice(0,this.strip),t.path=r.join("/")}if(isFinite(this.maxDepth)&&r.length>this.maxDepth)return this.warn("TAR_ENTRY_ERROR","path excessively deep",{entry:t,path:e,depth:r.length,maxDepth:this.maxDepth}),!1;if(!this[Da](t,"path")||!this[Da](t,"linkpath"))return!1;if(t.absolute=De.isAbsolute(t.path)?Q(De.resolve(t.path)):Q(De.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:Q(t.path),resolvedPath:t.absolute,cwd:this.cwd}),!1;if(t.absolute===this.cwd&&t.type!=="Directory"&&t.type!=="GNUDumpDir")return!1;if(this.win32){let{root:s}=De.win32.parse(String(t.absolute));t.absolute=s+Kf(String(t.absolute).slice(s.length));let{root:a}=De.win32.parse(t.path);t.path=a+Kf(t.path.slice(a.length))}return!0}[sd](t){if(!this[dd](t))return t.resume();switch(Rm.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[Va](t);default:return this[fd](t)}}[Ne](t,e){t.name==="CwdError"?this.emit("error",t):(this.warn("TAR_ENTRY_ERROR",t,{entry:e}),this[sr](),e.resume())}[dn](t,e,r){Fm(Q(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)}[ii](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}[si](t){return ld(this.uid,t.uid,this.processUid)}[oi](t){return ld(this.gid,t.gid,this.processGid)}[Za](t,e){let r=typeof t.mode=="number"?t.mode&4095:this.fmode,s=new Rs(String(t.absolute),{flags:Fd(t.size),mode:r,autoClose:!1});s.on("error",u=>{s.fd&&ne.close(s.fd,()=>{}),s.write=()=>!0,this[Ne](u,t),e()});let a=1,c=u=>{if(u){s.fd&&ne.close(s.fd,()=>{}),this[Ne](u,t),e();return}--a===0&&s.fd!==void 0&&ne.close(s.fd,x=>{x?this[Ne](x,t):this[sr](),e()})};s.on("finish",()=>{let u=String(t.absolute),x=s.fd;if(typeof x=="number"&&t.mtime&&!this.noMtime){a++;let p=t.atime||new Date,_=t.mtime;ne.futimes(x,p,_,w=>w?ne.utimes(u,p,_,S=>c(S&&w)):c())}if(typeof x=="number"&&this[ii](t)){a++;let p=this[si](t),_=this[oi](t);typeof p=="number"&&typeof _=="number"&&ne.fchown(x,p,_,w=>w?ne.chown(u,p,_,S=>c(S&&w)):c())}c()});let d=this.transform&&this.transform(t)||t;d!==t&&(d.on("error",u=>{this[Ne](u,t),e()}),t.pipe(d)),d.pipe(s)}[Xa](t,e){let r=typeof t.mode=="number"?t.mode&4095:this.dmode;this[dn](String(t.absolute),r,s=>{if(s){this[Ne](s,t),e();return}let a=1,c=()=>{--a===0&&(e(),this[sr](),t.resume())};t.mtime&&!this.noMtime&&(a++,ne.utimes(String(t.absolute),t.atime||new Date,t.mtime,c)),this[ii](t)&&(a++,ne.chown(String(t.absolute),Number(this[si](t)),Number(this[oi](t)),c)),c()})}[fd](t){t.unsupported=!0,this.warn("TAR_ENTRY_UNSUPPORTED",`unsupported entry type: ${t.type}`,{entry:t}),t.resume()}[ad](t,e){let r=Q(De.relative(this.cwd,De.resolve(De.dirname(String(t.absolute)),String(t.linkpath)))).split("/");this[ei](t,this.cwd,r,()=>this[Ss](t,String(t.linkpath),"symlink",e),s=>{this[Ne](s,t),e()})}[cd](t,e){let r=Q(De.resolve(this.cwd,String(t.linkpath))),s=Q(String(t.linkpath)).split("/");this[ei](t,this.cwd,s,()=>this[Ss](t,r,"link",e),a=>{this[Ne](a,t),e()})}[ei](t,e,r,s,a){let c=r.shift();if(this.preservePaths||c===void 0)return s();let d=De.resolve(e,c);ne.lstat(d,(u,x)=>{if(u)return s();if(x?.isSymbolicLink())return a(new Ms(d,De.resolve(d,r.join("/"))));this[ei](t,d,r,s,a)})}[ud](){this[xs]++}[sr](){this[xs]--,this[ka]()}[Ya](t){this[sr](),t.resume()}[Ja](t,e){return t.type==="File"&&!this.unlink&&e.isFile()&&e.nlink<=1&&!ci}[Va](t){this[ud]();let e=[t.path];t.linkpath&&e.push(t.linkpath),this.reservations.reserve(e,r=>this[od](t,r))}[od](t,e){let r=d=>{e(d)},s=()=>{this[dn](this.cwd,this.dmode,d=>{if(d){this[Ne](d,t),r();return}this[ai]=!0,a()})},a=()=>{if(t.absolute!==this.cwd){let d=Q(De.dirname(String(t.absolute)));if(d!==this.cwd)return this[dn](d,this.dmode,u=>{if(u){this[Ne](u,t),r();return}c()})}c()},c=()=>{ne.lstat(String(t.absolute),(d,u)=>{if(u&&(this.keep||this.newer&&u.mtime>(t.mtime??u.mtime))){this[Ya](t),r();return}if(d||this[Ja](t,u))return this[st](null,t,r);if(u.isDirectory()){if(t.type==="Directory"){let x=this.chmod&&t.mode&&(u.mode&4095)!==t.mode,p=_=>this[st](_??null,t,r);return x?ne.chmod(String(t.absolute),Number(t.mode),p):p()}if(t.absolute!==this.cwd)return ne.rmdir(String(t.absolute),x=>this[st](x??null,t,r))}if(t.absolute===this.cwd)return this[st](null,t,r);Zm(String(t.absolute),x=>this[st](x??null,t,r))})};this[ai]?a():s()}[st](t,e,r){if(t){this[Ne](t,e),r();return}switch(e.type){case"File":case"OldFile":case"ContiguousFile":return this[Za](e,r);case"Link":return this[cd](e,r);case"SymbolicLink":return this[ad](e,r);case"Directory":case"GNUDumpDir":return this[Xa](e,r)}}[Ss](t,e,r,s){ne[r](e,String(t.absolute),a=>{a?this[Ne](a,t):(this[sr](),t.resume()),s()})}},Yr=t=>{try{return[null,t()]}catch(e){return[e,null]}},Wd=class extends cc{sync=!0;[st](t,e){return super[st](t,e,()=>{})}[Va](t){if(!this[ai]){let a=this[dn](this.cwd,this.dmode);if(a)return this[Ne](a,t);this[ai]=!0}if(t.absolute!==this.cwd){let a=Q(De.dirname(String(t.absolute)));if(a!==this.cwd){let c=this[dn](a,this.dmode);if(c)return this[Ne](c,t)}}let[e,r]=Yr(()=>ne.lstatSync(String(t.absolute)));if(r&&(this.keep||this.newer&&r.mtime>(t.mtime??r.mtime)))return this[Ya](t);if(e||this[Ja](t,r))return this[st](null,t);if(r.isDirectory()){if(t.type==="Directory"){let c=this.chmod&&t.mode&&(r.mode&4095)!==t.mode,[d]=c?Yr(()=>{ne.chmodSync(String(t.absolute),Number(t.mode))}):[];return this[st](d,t)}let[a]=Yr(()=>ne.rmdirSync(String(t.absolute)));this[st](a,t)}let[s]=t.absolute===this.cwd?[]:Yr(()=>Xm(String(t.absolute)));this[st](s,t)}[Za](t,e){let r=typeof t.mode=="number"?t.mode&4095:this.fmode,s=d=>{let u;try{ne.closeSync(a)}catch(x){u=x}(d||u)&&this[Ne](d||u,t),e()},a;try{a=ne.openSync(String(t.absolute),Fd(t.size),r)}catch(d){return s(d)}let c=this.transform&&this.transform(t)||t;c!==t&&(c.on("error",d=>this[Ne](d,t)),t.pipe(c)),c.on("data",d=>{try{ne.writeSync(a,d,0,d.length)}catch(u){s(u)}}),c.on("end",()=>{let d=null;if(t.mtime&&!this.noMtime){let u=t.atime||new Date,x=t.mtime;try{ne.futimesSync(a,u,x)}catch(p){try{ne.utimesSync(String(t.absolute),u,x)}catch{d=p}}}if(this[ii](t)){let u=this[si](t),x=this[oi](t);try{ne.fchownSync(a,Number(u),Number(x))}catch(p){try{ne.chownSync(String(t.absolute),Number(u),Number(x))}catch{d=d||p}}}s(d)})}[Xa](t,e){let r=typeof t.mode=="number"?t.mode&4095:this.dmode,s=this[dn](String(t.absolute),r);if(s){this[Ne](s,t),e();return}if(t.mtime&&!this.noMtime)try{ne.utimesSync(String(t.absolute),t.atime||new Date,t.mtime)}catch{}if(this[ii](t))try{ne.chownSync(String(t.absolute),Number(this[si](t)),Number(this[oi](t)))}catch{}e(),t.resume()}[dn](t,e){try{return qm(Q(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}}[ei](t,e,r,s,a){if(this.preservePaths||r.length===0)return s();let c=e;for(let d of r){c=De.resolve(c,d);let[u,x]=Yr(()=>ne.lstatSync(c));if(u)return s();if(x.isSymbolicLink())return a(new Ms(c,De.resolve(e,r.join("/"))))}s()}[Ss](t,e,r,s){let a=`${r}Sync`;try{ne[a](e,String(t.absolute)),s(),t.resume()}catch(c){return this[Ne](c,t)}}},Ym=t=>{let e=new Wd(t),r=t.file,s=kd.statSync(r),a=t.maxReadSize||16*1024*1024;new wg(r,{readSize:a,size:s.size}).pipe(e)},Qm=(t,e)=>{let r=new cc(t),s=t.maxReadSize||16*1024*1024,a=t.file;return new Promise((c,d)=>{r.on("error",d),r.on("close",c),kd.stat(a,(u,x)=>{if(u)d(u);else{let p=new ec(a,{readSize:s,size:x.size});p.on("error",d),p.pipe(r)}})})},Kd=di(Ym,Qm,t=>new Wd(t),t=>new cc(t),(t,e)=>{e?.length&&Sd(t,e)}),ew=(t,e)=>{let r=new ac(t),s=!0,a,c;try{try{a=Qe.openSync(t.file,"r+")}catch(x){if(x?.code==="ENOENT")a=Qe.openSync(t.file,"w+");else throw x}let d=Qe.fstatSync(a),u=Buffer.alloc(512);e:for(c=0;c<d.size;c+=512){for(let _=0,w=0;_<512;_+=w){if(w=Qe.readSync(a,u,_,u.length-_,c+_),c===0&&u[0]===31&&u[1]===139)throw new Error("cannot append to compressed archives");if(!w)break e}let x=new Pn(u);if(!x.cksumValid)break;let p=512*Math.ceil((x.size||0)/512);if(c+p+512>d.size)break;c+=p,t.mtimeCache&&x.mtime&&t.mtimeCache.set(String(x.path),x.mtime)}s=!1,tw(t,r,c,a,e)}finally{if(s)try{Qe.closeSync(a)}catch{}}},tw=(t,e,r,s,a)=>{let c=new pd(t.file,{fd:s,start:r});e.pipe(c),rw(e,a)},nw=(t,e)=>{e=Array.from(e);let r=new Ps(t),s=(a,c,d)=>{let u=(S,b)=>{S?Qe.close(a,E=>d(S)):d(null,b)},x=0;if(c===0)return u(null,0);let p=0,_=Buffer.alloc(512),w=(S,b)=>{if(S||b===void 0)return u(S);if(p+=b,p<512&&b)return Qe.read(a,_,p,_.length-p,x+p,w);if(x===0&&_[0]===31&&_[1]===139)return u(new Error("cannot append to compressed archives"));if(p<512)return u(null,x);let E=new Pn(_);if(!E.cksumValid)return u(null,x);let v=512*Math.ceil((E.size??0)/512);if(x+v+512>c||(x+=v+512,x>=c))return u(null,x);t.mtimeCache&&E.mtime&&t.mtimeCache.set(String(E.path),E.mtime),p=0,Qe.read(a,_,0,512,x,w)};Qe.read(a,_,0,512,x,w)};return new Promise((a,c)=>{r.on("error",c);let d="r+",u=(x,p)=>{if(x&&x.code==="ENOENT"&&d==="r+")return d="w+",Qe.open(t.file,d,u);if(x||!p)return c(x);Qe.fstat(p,(_,w)=>{if(_)return Qe.close(p,()=>c(_));s(p,w.size,(S,b)=>{if(S)return c(S);let E=new Rs(t.file,{fd:p,start:b});r.pipe(E),E.on("error",c),E.on("close",a),iw(r,e)})})};Qe.open(t.file,d,u)})},rw=(t,e)=>{e.forEach(r=>{r.charAt(0)==="@"?xr({file:$d.resolve(t.cwd,r.slice(1)),sync:!0,noResume:!0,onReadEntry:s=>t.add(s)}):t.add(r)}),t.end()},iw=async(t,e)=>{for(let r of e)r.charAt(0)==="@"?await xr({file:$d.resolve(String(t.cwd),r.slice(1)),noResume:!0,onReadEntry:s=>t.add(s)}):t.add(r);t.end()},Qr=di(ew,nw,()=>{throw new TypeError("file is required")},()=>{throw new TypeError("file is required")},(t,e)=>{if(!Cg(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")}),$2=di(Qr.syncFile,Qr.asyncFile,Qr.syncNoFile,Qr.asyncNoFile,(t,e=[])=>{Qr.validate?.(t,e),sw(t)}),sw=t=>{let e=t.filter;t.mtimeCache||(t.mtimeCache=new Map),t.filter=e?(r,s)=>e(r,s)&&!((t.mtimeCache?.get(r)??s.mtime??0)>(s.mtime??0)):(r,s)=>!((t.mtimeCache?.get(r)??s.mtime??0)>(s.mtime??0))};Yt();var St={PAIR:"_agent/pair",CREATE:"_agent/create",HEALTH:"_agent/health",LIST_SKILLS:"_agent/listSkills",ADD_SKILLS:"_agent/addSkills",REMOVE_SKILLS:"_agent/removeSkills",GET_FILE_TREE:"_agent/getFileTree",GET_FILE_CONTENT:"_agent/getFileContent",DETAIL:"_agent/detail",UPDATE:"_agent/update",DISCONNECT:"_agent/disconnect",SWITCH_MODEL:"_agent/switchModel",GEN_MODEL_TOKEN:"_agent/genModelToken",RESET:"_agent/reset",REPAIR:"_agent/repair",DELETE:"_agent/delete"};function ui(t){return t?.cozeDeployType==="cloud"?"cloud":"local"}function Vd(t){let e=t?.cozeAccountId?.trim();if(!(!e||e==="0"))return e}function Jd(t){let e=t?.cozeGroupId?.trim();if(!(!e||e==="0"))return e}function Zd(t){let{_meta:e,...r}=t;return{stripped:r,meta:e}}function hr(t){if(!t?.cozeAgentId)throw new Error("missing _meta.cozeAgentId");return t.cozeAgentId}var T=class extends Error{code;retriable;cause;constructor(e,r,s){super(r),this.name="BridgeError",this.code=e,this.retriable=s?.retriable??!1,s?.cause!==void 0&&(this.cause=s.cause)}};ie();qe();function Ft(t,e){if(ui(t)!=="cloud")throw new T("OPERATION_NOT_ALLOWED_FOR_LOCAL",`${e} is not allowed for local agent`)}function Bs(t){return t.startsWith("http://")||t.startsWith("https://")}function zs(t){return t.endsWith("/")?t.slice(0,-1):t}ie();var Fs="1008033",Xd="1289";var Yd="pbbp2",Qd="https://www.coze.cn",eu="/api/coze_claw/resource/get_frontier_key",aw="https://www.coze.cn",cw="wss://frontier.coze.cn";function Us(t){return t??process.env.COZE_BRIDGE_HANDSHAKE_URL??aw}function tu(t){return t??process.env.COZE_BRIDGE_FRONTIER_URL??cw}function pr(t){let e={},r=t?.ttEnv??process.env.COZE_BRIDGE_TT_ENV,s=t?.usePpe??process.env.COZE_BRIDGE_USE_PPE;return r&&(e["x-tt-env"]=r),s&&(e["x-use-ppe"]=s),e}function xi(t){return t?t.startsWith("boe_")?{ttEnv:t}:{ttEnv:t,usePpe:"1"}:{}}var li=$("handshake");async function fc(t){let e=Us(t.endpoint),r=t.timeoutMs??1e4,s=`${zs(e)}${eu}?aid=${encodeURIComponent(Fs)}`,a={Authorization:`Bearer ${t.privatecode}`,Accept:"application/json",...pr(t.ppeOverride)},c=new AbortController,d=setTimeout(()=>c.abort(),r);li.info("frontier key handshake",{base:e});try{let u=await fetch(s,{method:"GET",headers:a,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 T("UPSTREAM_HANDSHAKE_FAILED",`handshake HTTP ${u.status} logid=${x}: ${E.slice(0,200)}`)}let _=await u.json();if(_.code!==void 0&&_.code!==0)throw new T("UPSTREAM_HANDSHAKE_FAILED",`handshake code=${_.code} msg=${_.msg??"-"} logid=${x}`);let w=_.data??{},S=typeof w.access_key=="string"&&w.access_key||typeof w.accessKey=="string"&&w.accessKey||void 0,b=typeof w.device_id=="string"&&w.device_id||typeof w.deviceId=="string"&&w.deviceId||void 0;if(!S||!b){let E=JSON.stringify(_).slice(0,500);throw new T("UPSTREAM_HANDSHAKE_FAILED",`handshake response missing access_key/device_id (also tried camelCase) logid=${x}: ${E}`)}return li.info("handshake ok",{remoteDeviceId:b,logid:x,traceId:p}),{accessKey:S,deviceId:b}}catch(u){if(u instanceof T)throw li.error("handshake failed (bridge error)",{base:e,message:u.message,code:u.code}),u;if(u.name==="AbortError")throw li.warn("handshake timeout",{base:e,timeoutMs:r}),new T("UPSTREAM_HANDSHAKE_FAILED",`handshake timeout (${r}ms)`,{cause:u});let x=u.cause;throw li.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 T("UPSTREAM_HANDSHAKE_FAILED",String(u),{cause:u})}finally{clearTimeout(d)}}var dc=process.env.COZE_BRIDGE_LLM_GATEWAY_URL?.trim()||"https://llm-gateway.coze.cn",It="auto";function nu(t){return{model:t.model??It,...t.modelToken?{modelToken:t.modelToken}:{}}}function ru(t){return!t||t===It}function iu(t){let e={};return t.modelToken?(e.ANTHROPIC_BASE_URL=dc,e.ANTHROPIC_AUTH_TOKEN=t.modelToken,e.ANTHROPIC_MODEL=t.model||It,t.modelInfo?.contextWindow&&(e.CLAUDE_CODE_MAX_CONTEXT_TOKENS=String(t.modelInfo.contextWindow))):ru(t.model)||(e.ANTHROPIC_MODEL=t.model),e}function su(t){let e=[];return t.modelToken?e.push("-c",`model="${t.model||It}"`):ru(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="${dc}/v1"`),e.push("-c",'model_providers.coze.env_key="OPENAI_API_KEY"'),e.push("-c",'model_providers.coze.wire_api="responses"'),e.push("-c","model_providers.coze.requires_openai_auth=false"),e.push("-c","model_providers.coze.supports_websockets=false"),e.push("-c",'model_provider="coze"'),t.modelInfo?.contextWindow&&e.push("-c",`model_context_window=${t.modelInfo.contextWindow}`)),e}function ou(t){return t.modelToken?{OPENAI_API_KEY:t.modelToken}:{}}function uc(t,e){let{ttEnv:r,usePpe:s}=xi(t),a={};return r&&(a["x-tt-env"]=r),s&&(a["x-use-ppe"]=s),e&&(a["x-mock-scenario"]=e),a}function au(t,e,r){if(!t.modelToken)return{};let s=uc(e,r);return Object.keys(s).length===0?{}:{ANTHROPIC_CUSTOM_HEADERS:Object.entries(s).map(([c,d])=>`${c}:${d}`).join(`
|
|
117
|
-
`)}}function lc(t){return`coze-session-${t.replace(/[^A-Za-z0-9_-]+/g,"-")}`}function cu(t,e,r){if(!t.modelToken)return null;let s=t.model||It,a=uc(e,r),c=["text"];t.modelInfo?.capabilities?.image===!0&&c.push("image");let d={baseUrl:`${dc}/v1`,api:"openai-completions",apiKey:t.modelToken,models:[{id:s,name:s,reasoning:!1,input:c,cost:{input:0,output:0,cacheRead:0,cacheWrite:0},contextWindow:t.modelInfo?.contextWindow??128e3,maxTokens:8192,api:"openai-completions"}]};return Object.keys(a).length>0&&(d.headers=a),d}function fu(t,e,r){if(!t.modelToken)return[];let s=uc(e,r),a=[];for(let[c,d]of Object.entries(s))a.push("-c",`model_providers.coze.http_headers.${c}="${d}"`);return a}var Me=$("agent-handlers"),du=5*1024*1024,hw=1,pw=6,gw=new Set(["node_modules",".git",".coze","dist","build",".next"]),qs=class{constructor(e){this.opts=e}opts;async listSkills(e){Ft(e._meta,"_agent/listSkills");let r=hr(e._meta),s=await this.loadAgentCfg(r),a=s?.workspace??Lt(r).workspace,c=s?.skills??[],d=[];for(let u of c){let x=Ct(a,u.relPath,"SKILL.md");await uw(x).then(_=>_.isFile()).catch(()=>!1)&&d.push(bw(u))}return{skills:d}}async addSkills(e){Ft(e._meta,"_agent/addSkills");let r=hr(e._meta),s=await this.requireAgentCfg(r),a=e.skills??[],c=[...s.skills??[]],d=new Map(c.map((x,p)=>[x.skillId,p])),u=[];for(let x of a){let p=await _c({agentId:r,workspace:s.workspace,framework:s.framework,skill:x});yc(c,d,p),u.push(x)}return await Ki(r,c),this.reloadAgentSessions(r,"skills-added"),{installedSkills:u}}async removeSkills(e){Ft(e._meta,"_agent/removeSkills");let r=hr(e._meta),s=await this.requireAgentCfg(r),a=new Set(e.skillIds??[]),c=s.skills??[],d=[];for(let u of c){if(!a.has(u.skillId)){d.push(u);continue}let x=Ct(s.workspace,u.relPath);await dw(x,{recursive:!0,force:!0}),Me.info("skill removed",{agentId:r,skillId:u.skillId,relPath:u.relPath})}return await Ki(r,d),this.reloadAgentSessions(r,"skills-removed"),{ok:!0}}reloadAgentSessionsPublic(e,r){this.reloadAgentSessions(e,r)}reloadAgentSessions(e,r){let s=this.opts.agents.get(e);if(s)for(let[a,c]of s.sessions){if(!c.downstream)continue;let d=c.acpSessionId;if(d&&s.activeTriggers.has(d)||this.isRuntimePendingPermission(c)){c.reloadAfterTurn=!0,Me.info("downstream busy, scheduling reload after turn",{reason:r,agentId:e,framework:s.framework,cloudId:a,acpId:d});continue}let x=c.downstream;c.downstream=void 0,Me.info("killing downstream for workspace reload (idle)",{reason:r,agentId:e,framework:s.framework,cloudId:a,acpId:d}),x.stop(r).catch(p=>Me.warn("downstream stop failed during reload (ignored)",{reason:r,agentId:e,cloudId:a,err:String(p)}))}}isRuntimePendingPermission(e){let r=this.opts.isRuntimePendingPermission;return!r||!e.downstream?!1:r(e.downstream)}async updateAgent(e){if(!e.cozeIdentity?.trim())return Me.info("_agent/update: empty cozeIdentity, noop",{agentId:e.agentId}),{ok:!0};let r=e.agentId,s=await We(r);if(!s)throw new T("AGENT_NOT_FOUND",`agent not found: ${r}`);if(s.cozeIdentity===e.cozeIdentity)return Me.info("_agent/update: cozeIdentity unchanged, noop",{agentId:r}),{ok:!0};try{await Xn(s.workspace,s.framework,r,e.cozeIdentity)}catch(a){throw Me.error("_agent/update: writeInstructionFile failed, aborting update",{agentId:r,framework:s.framework,workspace:s.workspace,err:String(a)}),new T("AGENT_PROTOCOL_ERROR",`failed to write instruction file for agent ${r}: ${String(a)}`,{cause:a})}return s.cozeIdentity=e.cozeIdentity,await Ze(s),Me.info("_agent/update: cozeIdentity rewritten",{agentId:r,framework:s.framework}),this.reloadAgentSessions(r,"identity-changed"),{ok:!0}}async disconnectAgent(e){let r=e.agentId;if(!r)throw new T("IPC_BAD_REQUEST","_agent/disconnect: missing agentId");let s=await We(r);return s?(s.disconnectedAt=Date.now(),s.disconnectReason=e.reason??"",await Ze(s),Me.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}):(Me.warn("_agent/disconnect: agent not found, ignoring",{agentId:r}),{ok:!0})}async switchModel(e){if(Ft(e._meta,"_agent/switchModel"),!e.agentId)throw new T("IPC_BAD_REQUEST","_agent/switchModel: missing agentId");let r=e.model?.trim()?e.model:It,s=await We(e.agentId);if(!s)throw new T("AGENT_NOT_FOUND",`agent not found: ${e.agentId}`);s.model=r,e.modelInfo&&(s.modelInfo=e.modelInfo),await Ze(s),Me.info("_agent/switchModel: model persisted",{agentId:e.agentId,model:r,reason:e.reason??""});let a=this.opts.agents.get(e.agentId);if(!a)return Me.info("_agent/switchModel: agent not running, config persisted only",{agentId:e.agentId}),{ok:!0};a.model=r,e.modelInfo&&a.setModelInfo(e.modelInfo),this.opts.cleanupOpenclawProviders&&await this.opts.cleanupOpenclawProviders(a).catch(d=>Me.warn("cleanupOpenclawProviders before switchModel failed (ignored)",{agentId:e.agentId,err:String(d)}));let c=[];for(let[d,u]of a.allSessionQueues())c.push(u.enqueue(async()=>{let x=a.sessions.get(d);x?.downstream&&(await x.downstream.stop(`switchModel: ${r}`).catch(()=>{}),x.downstream=void 0)}));return await Promise.all(c),Me.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(Ft(e._meta,St.RESET),!e.agentId)throw new T("IPC_BAD_REQUEST",`${St.RESET}: missing agentId`);return await this.runDetailSync(e.agentId,St.RESET,e.reason),{ok:!0}}async repairAgent(e){if(Ft(e._meta,St.REPAIR),!e.agentId)throw new T("IPC_BAD_REQUEST",`${St.REPAIR}: missing agentId`);let r=await this.loadAgentCfg(e.agentId);if(r&&r.framework!=="openclaw")throw new T("IPC_BAD_REQUEST",`${St.REPAIR} only allowed for openclaw, got ${r.framework}`);if(r&&this.opts.openclawRepair)try{await this.opts.openclawRepair(e.agentId,r.workspace)}catch(s){Me.warn("openclaw repair (delete+add) failed (ignored)",{agentId:e.agentId,reason:e.reason,err:String(s)})}return await this.runDetailSync(e.agentId,St.REPAIR,e.reason),{ok:!0}}async runDetailSync(e,r,s){if(!this.opts.detailSyncer){Me.warn("detailSyncer not wired, skipping sync",{method:r,agentId:e});return}try{await this.opts.detailSyncer(e)}catch(a){Me.warn("detail sync failed (ignored)",{method:r,agentId:e,reason:s,err:String(a)})}}async getFileTree(e){Ft(e._meta,"_agent/getFileTree");let r=e._meta,s=hr(r),a=await this.resolveWorkspace(s),c=e.filePath??"",d=this.safeJoin(a,c),u=await xc(d).catch(()=>null);if(!u)throw new T("IPC_BAD_REQUEST",`path not found: ${c}`);if(u.isSymbolicLink())throw new T("IPC_BAD_REQUEST",`symlink not allowed: ${c}`);if(!await zr(d,a))throw new T("IPC_BAD_REQUEST",`path escapes workspace: ${c}`);let x=Lw(e.depth);return u.isDirectory()?{tree:await kw(a,d,c,x)}:{tree:[{name:Ow(c),path:mu(c||"."),isDir:!1,size:u.size,modifiedAt:Math.floor(u.mtimeMs)}]}}async getFileContent(e){Ft(e._meta,"_agent/getFileContent");let r=hr(e._meta),s=await this.resolveWorkspace(r);if(!e.filePath)throw new T("IPC_BAD_REQUEST","filePath required");let a=this.safeJoin(s,e.filePath),c=await xc(a).catch(()=>null);if(!c||!c.isFile())throw new T("IPC_BAD_REQUEST",`not a file: ${e.filePath}`);if(c.isSymbolicLink())throw new T("IPC_BAD_REQUEST",`symlink not allowed: ${e.filePath}`);if(!await zr(a,s))throw new T("IPC_BAD_REQUEST",`path escapes workspace: ${e.filePath}`);if(c.size>du)throw new T("IPC_BAD_REQUEST",`file too large: ${c.size} bytes (max ${du})`);let d=await uu(a);return d.includes(0)?{content:d.toString("base64"),encoding:"base64",size:c.size}:{content:d.toString("utf8"),encoding:"utf-8",size:c.size}}async resolveWorkspace(e){let r=this.opts.agents.get(e);return r?r.workspace:(await We(e).catch(()=>null))?.workspace??Lt(e).workspace}safeJoin(e,r){let s=gc(e,r||"."),a=wc(e,s);if(a.startsWith("..")||a===".."||a.startsWith(`..${lu}`))throw new T("IPC_BAD_REQUEST",`path escapes workspace: ${r}`);return s}loadAgentCfg(e){return We(e)}async requireAgentCfg(e){let r=await this.loadAgentCfg(e);if(!r)throw new T("AGENT_NOT_FOUND",`no config for agent: ${e}`);return r}};function mw(t){let e=t.trim().replace(/[\x00-\x1f<>:"|?*/\\]+/g,"-").replace(/^[\s.-]+|[\s.-]+$/g,"").slice(0,64);if(!e||e==="."||e==="..")throw new T("IPC_BAD_REQUEST",`invalid skill name: ${t}`);if(/^(con|prn|aux|nul|com[1-9]|lpt[1-9])$/i.test(e))throw new T("IPC_BAD_REQUEST",`reserved windows filename: ${t}`);return e}function ww(t){return t==="claude-code"?Ct(".claude","skills"):Ct(".agents","skills")}var _w=3e4,yw=50*1024*1024,gr=3e4;async function _c(t){let{agentId:e,workspace:r,framework:s,skill:a}=t;if(!a.skillName)throw new T("IPC_BAD_REQUEST","skill missing skillName");let c=typeof a.content=="string"&&a.content.length>0,d=typeof a.downloadUrl=="string"&&a.downloadUrl.length>0;if(!c&&!d)throw new T("IPC_BAD_REQUEST",`skill ${a.skillId} missing both content and downloadUrl`);let u=mw(a.skillName),x=ww(s),p=Ct(x,u),_=Ct(r,p);if(await hc(_,{recursive:!0}),c){let S=Buffer.from(a.content,"utf8");hi(S.length),await pc(Ct(_,"SKILL.md"),S,"utf8")}else{let S=await Ew(a.downloadUrl);Sw(S)?await Tw(S,_):Iw(S)?await Cw(S,_):await pc(Ct(_,"SKILL.md"),S.toString("utf8"),"utf8")}let w={skillId:a.skillId,skillName:a.skillName,relPath:p,installedAt:Date.now(),...a.description?{description:a.description}:{},...a.icon?{icon:a.icon}:{},...a.version?{version:a.version}:{},...a.downloadUrl?{downloadUrl:a.downloadUrl}:{},...a.config?{config:a.config}:{},...a.builtin?{builtin:a.builtin}:{}};return Me.info("skill installed",{agentId:e,skillId:a.skillId,skillName:a.skillName,relPath:p,source:c?"content":"downloadUrl"}),w}function yc(t,e,r){let s=e.get(r.skillId);if(s!==void 0){t[s]=r;return}e.set(r.skillId,t.length),t.push(r)}function bw(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 Ew(t){if(!t)throw new T("IPC_BAD_REQUEST","skill missing downloadUrl");if(t.startsWith("data:")){let e=Math.floor(t.length*3/4);hi(e);let r=vw(t);return hi(r.length),r}if(t.startsWith("file:")){let e=new URL(t).pathname,r=await uu(e);return hi(r.length),r}if(Bs(t)){let e=new AbortController,r=setTimeout(()=>e.abort(),_w);try{let s=await fetch(t,{signal:e.signal});if(!s.ok)throw new T("IPC_BAD_REQUEST",`fetch skill failed HTTP ${s.status} ${t}`);let a=await s.arrayBuffer();return hi(a.byteLength),Buffer.from(a)}finally{clearTimeout(r)}}throw new T("IPC_BAD_REQUEST",`unsupported downloadUrl scheme (\u8981 https/data/file): ${t.slice(0,80)}`)}function hi(t){if(t>yw)throw new T("IPC_BAD_REQUEST",`skill too large: ${t} bytes`)}function vw(t){let e=/^data:([^,;]*)(;base64)?,(.*)$/s.exec(t);if(!e)throw new T("IPC_BAD_REQUEST","bad data URL");let r=!!e[2],s=e[3]??"";return r?Buffer.from(s,"base64"):Buffer.from(decodeURIComponent(s),"utf8")}function Sw(t){return t.length>=2&&t[0]===31&&t[1]===139}function Iw(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 mc(t){return t==="__MACOSX"||t.startsWith("__MACOSX/")}async function Cw(t,e){let r,s;try{r=new pu.default(t),s=r.getEntries()}catch(d){throw new T("IPC_BAD_REQUEST",`zip parse failed: ${d.message}`,{cause:d})}for(let d of s){let u=d.entryName;if(!u||mc(u))continue;if(u.startsWith("/")||/^[A-Za-z]:[\\/]/.test(u))throw new T("IPC_BAD_REQUEST",`zip entry absolute path: ${u}`);if(u.split(/[/\\]/).some(p=>p===".."))throw new T("IPC_BAD_REQUEST",`zip entry contains '..' (traversal): ${u}`);let x=d.header.attr>>>16&61440;if(x!==0&&x!==32768&&x!==16384)throw new T("IPC_BAD_REQUEST",`zip entry kind 0x${x.toString(16)} not allowed (symlink/hardlink/special): ${u}`)}let a=Aw(s),c=gc(e);for(let d of s){if(mc(d.entryName))continue;let u=d.entryName;if(a&&u.startsWith(a)&&(u=u.slice(a.length)),!u)continue;let x=gc(e,u),p=wc(c,x);if(p.startsWith("..")||p==="..")throw new T("IPC_BAD_REQUEST",`zip entry escapes destDir: ${u}`);if(d.isDirectory){await hc(x,{recursive:!0});continue}await hc(lw(x),{recursive:!0});let _;try{_=d.getData()}catch(w){throw new T("IPC_BAD_REQUEST",`zip entry getData failed (${d.entryName}): ${w.message}`,{cause:w})}await pc(x,_)}}function Aw(t){let e;for(let r of t){let s=r.entryName;if(!s||mc(s))continue;let a=s.indexOf("/");if(a<=0)return;let c=s.slice(0,a+1);if(e===void 0)e=c;else if(e!==c)return}return e}async function Tw(t,e){await Dw(t);let r=Kd({cwd:e,strip:1}),s=!1,a=setTimeout(()=>{s=!0,r.destroy(new T("IPC_BAD_REQUEST",`tar extract timeout (${gr}ms)`))},gr);try{await hu(xu.from(t),r)}catch(c){throw c instanceof T?c:s?new T("IPC_BAD_REQUEST",`tar extract timeout (${gr}ms)`):new T("IPC_BAD_REQUEST",`tar extract failed: ${c.message??String(c)}`,{cause:c})}finally{clearTimeout(a)}}async function Dw(t){let e=[],r=xr({onReadEntry:c=>{let d=c.path,u=c.type;if(u!=="File"&&u!=="Directory"){e.push(`tar entry kind '${u}' not allowed (symlink/hardlink/special): ${d.slice(0,100)}`);return}if(d.startsWith("/")||d.startsWith("\\")||/^[a-zA-Z]:[\\/]/.test(d)){e.push(`tar entry absolute path: ${d}`);return}d.split(/[/\\]/).some(p=>p==="..")&&e.push(`tar entry contains '..': ${d}`)}}),s=!1,a=setTimeout(()=>{s=!0,r.destroy(new T("IPC_BAD_REQUEST",`tar list timeout (${gr}ms)`))},gr);try{await hu(xu.from(t),r)}catch(c){throw s?new T("IPC_BAD_REQUEST",`tar list timeout (${gr}ms)`):new T("IPC_BAD_REQUEST",`tar list failed: ${c.message??String(c)}`,{cause:c})}finally{clearTimeout(a)}if(e.length>0)throw new T("IPC_BAD_REQUEST",e[0]??"tar entry validation failed")}var Rw=5e3;async function kw(t,e,r,s){return gu(t,e,r,s,{count:0})}async function gu(t,e,r,s,a){if(s<=0)return[];let c;try{c=await fw(e,{withFileTypes:!0})}catch{return[]}let d=[];for(let u of c){if(gw.has(u.name)||u.isSymbolicLink())continue;if(a.count>=Rw){d.push({name:"...",path:"...",isDir:!1,size:0,modifiedAt:0,hasMore:!0});break}let x=Ct(e,u.name),p=xw(Ct(r,u.name)),_=null;try{_=await xc(x)}catch{continue}if(_.isSymbolicLink())continue;a.count++;let w={name:u.name,path:mu(wc(t,x)),isDir:_.isDirectory(),size:_.size,modifiedAt:Math.floor(_.mtimeMs)};_.isDirectory()&&s>1&&(w.children=await gu(t,x,p,s-1,a)),d.push(w)}return d.sort((u,x)=>u.isDir!==x.isDir?u.isDir?-1:1:u.name.localeCompare(x.name)),d}function Lw(t){return!t||t<=0?hw:Math.min(t,pw)}function Ow(t){if(!t||t==="."||t==="/")return".";let e=t.split(/[/\\]/);return e[e.length-1]||"."}function mu(t){return t.split(lu).join("/")}ie();import{readFileSync as iS}from"node:fs";import{dirname as oS,join as aS}from"node:path";import{fileURLToPath as fS}from"node:url";var mr="0.1.80";var xn=$("agent-health-reporter"),Pw=1e4,pi=class{constructor(e){this.opts=e;this.intervalMs=e.intervalMs??Pw}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()}),xn.info("heartbeat started",{intervalMs:this.intervalMs}),this.tick())}stop(){this.timer&&(clearInterval(this.timer),this.timer=null,this.unsubscribeRegister&&(this.unsubscribeRegister(),this.unsubscribeRegister=null),xn.info("heartbeat stopped"))}async tick(){if(this.inFlight){xn.debug("previous tick still in-flight, skip");return}let e=this.opts.getDeviceId();if(!e){xn.debug("deviceId not available, skip tick (\u5C1A\u672A pair)");return}this.inFlight=!0;try{let r=[];for(let d of this.opts.core.agents.values()){let u=Nw(d);if(!u)continue;let x={agentId:d.agentId,status:u};d.patToken&&(x.patToken=d.patToken),d.accountId&&(x.accountId=d.accountId),r.push(x)}if(r.length===0)return;let s={agents:r,bridgeVersion:mr,_meta:{cozeDeviceId:e}},a;try{a=await this.opts.core.sendRequest("_agent/health",s,5e3)}catch(d){xn.warn("heartbeat batch send failed",{count:r.length,err:String(d)})}let c=a?.authFailures;if(c&&c.length>0&&(xn.warn("heartbeat received authFailures from cloud",{count:c.length,agentIds:c.map(d=>d.agentId)}),this.opts.onAuthFailures))try{await this.opts.onAuthFailures(c)}catch(d){xn.warn("onAuthFailures callback failed (ignored)",{err:String(d)})}}finally{this.inFlight=!1}if(this.opts.onTickEnd)try{await this.opts.onTickEnd()}catch(r){xn.warn("onTickEnd hook failed",{err:String(r)})}}};function Nw(t){return t.status==="error"?"error":t.activeTriggers.size>0?"busy":t.status==="ok"?"online":null}Yt();import{mkdir as vc,rm as h_}from"node:fs/promises";Xt();Xt();import{spawnSync as jw}from"node:child_process";function gi(t,e,r){return r===void 0?{jsonrpc:"2.0",id:t,method:e}:{jsonrpc:"2.0",id:t,method:e,params:r}}function mi(t,e){return e===void 0?{jsonrpc:"2.0",method:t}:{jsonrpc:"2.0",method:t,params:e}}function wr(t,e){return{jsonrpc:"2.0",id:t,result:e}}function hn(t,e){return{jsonrpc:"2.0",id:t,error:e}}var Hs=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)}},re={PARSE_ERROR:-32700,INVALID_REQUEST:-32600,METHOD_NOT_FOUND:-32601,INVALID_PARAMS:-32602,INTERNAL_ERROR:-32603,AGENT_NOT_FOUND:-32001,AGENT_BUSY:-32002,AGENT_TIMEOUT:-32003,AGENT_SPAWN_FAILED:-32004,OPERATION_NOT_ALLOWED_FOR_LOCAL:-32005,AGENT_DISCONNECTED:-32006,MODEL_TOKEN_GEN_FAILED:-32009,PATH_OUTSIDE_WORKSPACE:-32010,FILE_TOO_LARGE:-32011,UNSUPPORTED_MIME:-32012,UPLOAD_FAILED:-32013,UPSTREAM_NOT_READY:-32014,AGENT_FRAME_IDLE_TIMEOUT:-32016,MODEL_MODALITY_UNSUPPORTED:-32017};function wu(t){return"method"in t&&"id"in t&&t.id!==void 0}function _u(t){return"method"in t&&!("id"in t)}function js(t){return!("method"in t)&&"id"in t}var Mw={AGENT_NOT_FOUND:re.AGENT_NOT_FOUND,AGENT_BUSY:re.AGENT_BUSY,AGENT_DISCONNECTED:re.AGENT_DISCONNECTED,AGENT_TIMEOUT:re.AGENT_TIMEOUT,AGENT_FRAME_IDLE_TIMEOUT:re.AGENT_FRAME_IDLE_TIMEOUT,AGENT_SPAWN_FAILED:re.AGENT_SPAWN_FAILED,AGENT_PROTOCOL_ERROR:re.INTERNAL_ERROR,BRIDGE_CONFIG_INVALID:re.INTERNAL_ERROR,BRIDGE_INTERNAL:re.INTERNAL_ERROR,IPC_AUTH_FAILED:re.INTERNAL_ERROR,IPC_BAD_REQUEST:re.INVALID_REQUEST,MODEL_TOKEN_GEN_FAILED:re.MODEL_TOKEN_GEN_FAILED,MODEL_MODALITY_UNSUPPORTED:re.MODEL_MODALITY_UNSUPPORTED,OPERATION_NOT_ALLOWED_FOR_LOCAL:re.OPERATION_NOT_ALLOWED_FOR_LOCAL,UPSTREAM_DISCONNECTED:re.INTERNAL_ERROR,UPSTREAM_HANDSHAKE_FAILED:re.INTERNAL_ERROR,PATH_OUTSIDE_WORKSPACE:re.PATH_OUTSIDE_WORKSPACE,FILE_TOO_LARGE:re.FILE_TOO_LARGE,UNSUPPORTED_MIME:re.UNSUPPORTED_MIME,UPLOAD_FAILED:re.UPLOAD_FAILED,UPSTREAM_NOT_READY:re.UPSTREAM_NOT_READY,NPX_CACHE_CORRUPT:re.INTERNAL_ERROR};function Bw(t){if(t!=null)return t instanceof Error?{name:t.name,message:wi(t.message)}:typeof t=="string"?wi(t):typeof t=="object"?Fw(t):t}var zw=[[/\/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 wi(t){let e=t;for(let[r,s]of zw)e=e.replace(r,s);return e}function Fw(t){let e={};for(let[r,s]of Object.entries(t))typeof s=="string"?e[r]=wi(s):e[r]=s;return e}function _i(t){if(t instanceof T){let e=Bw(t.cause),r={bridgeCode:t.code,retriable:t.retriable};return e!==void 0&&(r.cause=e),{code:Mw[t.code]??re.INTERNAL_ERROR,message:wi(t.message),data:r}}return{code:re.INTERNAL_ERROR,message:wi(t instanceof Error?t.message:String(t))}}function yu(t){let e=t.data,r=e?.bridgeCode??"AGENT_PROTOCOL_ERROR",s=!!e&&typeof e.message=="string"&&!!e.message,a=s?e?.message:t.message,c=t.data;if(s&&e){let{message:d,...u}=e;c=u}return new T(r,a,{retriable:e?.retriable??!1,cause:c})}function Eu(t){return`${JSON.stringify(t)}
|
|
118
|
-
`}var bu=10*1024*1024,Gs=class{buffer="";onError;constructor(e={}){this.onError=e.onError}push(e){if(this.buffer+=typeof e=="string"?e:e.toString("utf8"),this.buffer.length>bu){let a=this.buffer.length;return this.buffer="",this.onError?.({line:`<buffer overflow: ${a} bytes, dropped>`,error:new Error(`LdjsonDecoder buffer exceeded ${bu} bytes`)}),[]}let r=this.buffer.split(`
|
|
119
|
-
`);this.buffer=r.pop()??"";let s=[];for(let a of r){let c=a.replace(/\r$/,"").trim();if(c)try{s.push(JSON.parse(c))}catch(d){this.onError?.({line:c,error:d})}}return s}flush(){if(!this.buffer)return[];let e=this.buffer.replace(/\r$/,"").trim();if(this.buffer="",!e)return[];try{return[JSON.parse(e)]}catch(r){return this.onError?.({line:e,error:r}),[]}}};var Su={"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"},yS=Object.fromEntries(Object.entries(Su).map(([t,e])=>[e,t])),Uw={"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:[]},_r=class{seq=0;next(e,r){this.seq+=1;let s=Su[e]??qw(e),a=Uw[s]??[],c=[s,String(this.seq)];if(a.length>0){let d=a.map(x=>vu(r?.[x]??"")),u=Hw(d).join(":");u&&c.push(u)}else r&&Object.values(r).some(d=>d)&&c.push(Object.values(r).filter(Boolean).map(d=>vu(String(d))).join(":"));return c.join("_")}reset(){this.seq=0}};function qw(t){return t.replace(/[\s/]+/g,".").replace(/_+/g,"-")}function vu(t){return t.replace(/[:_\s]+/g,"-")}function Hw(t){let e=t.length;for(;e>0&&!t[e-1];)e-=1;return t.slice(0,e)}$n();function pn(t,e){let r=process.env[t];if(!r)return e;let s=Number(r);return Number.isFinite(s)&&s>0?s:e}ie();var Gw=pn("COZE_BRIDGE_INITIALIZE_TIMEOUT_MS",3e4),Ww=200,Kw=/(ENOTEMPTY|EEXIST).*_npx[/\\]/;function bc(t){return t.some(e=>Kw.test(e))}var $w=pn("COZE_BRIDGE_SESSION_PROMPT_MAX_MS",3600*1e3),Vw=pn("COZE_BRIDGE_SESSION_PROMPT_FRAME_IDLE_MS",600*1e3),Iu=500;function Jw(t){try{let e=JSON.stringify(t);return e===void 0||e.length<=Iu?t:`${e.slice(0,Iu)}...<truncated, total ${e.length} chars>`}catch{return"<unserializable>"}}function Cu(t,e){if(!(typeof t!="number"||t<=0))try{if(process.platform==="win32"){let r=["/PID",String(t),"/T"];e==="SIGKILL"&&r.push("/F"),jw("taskkill",r,{stdio:"ignore",windowsHide:!0})}else process.kill(-t,e)}catch{}}var At=class{constructor(e){this.opts=e;this.log=$(`downstream.${this.constructor.name}`),this.decoder=new Gs({onError:r=>this.log.warn("decode line failed",{line:r.line})})}opts;child;decoder;pending=new Map;inflightAgentRequests=new Map;idAllocator=new _r;updateHandlers=[];agentRequestHandlers=[];exitHandlers=[];log;stopped=!1;stderrRing=[];sanitizeEnv(e){return e}async start(){if(this.child)throw new T("BRIDGE_INTERNAL","Downstream already started");let e=process.platform!=="win32",r=Jt(this.opts.command,this.opts.args,{cwd:this.opts.cwd,env:{...this.sanitizeEnv(process.env),...this.opts.env},stdio:["pipe","pipe","pipe"],detached:e});this.child=r,r.stdout?.setEncoding("utf8"),r.stdout?.on("data",s=>{try{for(let a of this.decoder.push(s))this.dispatch(a)}catch(a){this.log.warn("stdout dispatch threw, swallowed to keep daemon alive",{err:String(a)})}}),r.stderr?.setEncoding("utf8"),r.stderr?.on("data",s=>{let a=s.trimEnd();this.stderrRing.push(a),this.stderrRing.length>Ww&&this.stderrRing.shift(),this.log.debug("stderr",{text:a})}),r.stdin?.on("error",s=>{this.log.warn("child stdin error",{err:String(s)})}),r.stdout?.on("error",s=>{this.log.warn("child stdout error",{err:String(s)})}),r.stderr?.on("error",s=>{this.log.warn("child stderr error",{err:String(s)})}),r.on("exit",(s,a)=>{this.stopped=!0,(s!==0||a!==null)&&this.stderrRing.length>0&&(this.log.warn("downstream exited abnormally, recent stderr",{code:s,signal:a,recentStderr:[...this.stderrRing]}),(this.framework==="claude-code"||this.framework==="codex")&&bc(this.stderrRing)&&(this.log.warn("npx cache corruption detected, triggering global install fallback (D93)",{framework:this.framework}),bn(this.framework).catch(u=>{this.log.warn("D93 fallback install failed (will retry next spawn cycle)",{framework:this.framework,err:String(u)})})));try{for(let d of this.decoder.flush())this.dispatch(d)}catch(d){this.log.debug("decoder.flush on exit threw (ignored)",{err:String(d)})}this.failAllPending(new T("AGENT_PROTOCOL_ERROR",`agent exited (${s}/${a})`));for(let d of this.exitHandlers)d(s,a)}),r.on("error",s=>{this.log.error("child error",{err:String(s)}),this.failAllPending(new T("AGENT_SPAWN_FAILED",String(s),{cause:s}))}),this.log.info("downstream started",{command:this.opts.command,pid:r.pid,cwd:this.opts.cwd})}async stop(e){if(!this.child||this.stopped)return;this.stopped=!0,this.log.info("downstream stopping",{reason:e});let r=this.child,s=new Promise(c=>r.once("exit",()=>c()));Cu(r.pid,"SIGTERM");let a=setTimeout(()=>{r.killed||Cu(r.pid,"SIGKILL")},5e3);try{await s}finally{clearTimeout(a)}}pid(){return this.child?.pid}isAlive(){return!!this.child&&!this.stopped}getStderrTail(){return[...this.stderrRing]}initialize(e){return this.call("initialize",e)}sessionNew(e){return this.call("session/new",{mcpServers:[],...e})}sessionLoad(e){return this.call("session/load",{mcpServers:[],...e})}sessionPrompt(e,r=$w,s=Vw){return this.call("session/prompt",e,r,s)}async sessionCancel(e){!this.child||this.stopped||this.writeFrame(mi("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(wr(e,r))}catch(s){this.log.warn("respondAgentRequest write failed",{id:e,err:String(s)})}}respondAgentRequestError(e,r){if(this.inflightAgentRequests.delete(e),!(!this.child||this.stopped))try{this.writeFrame(hn(e,r))}catch(s){this.log.warn("respondAgentRequestError write failed",{id:e,err:String(s)})}}onExit(e){this.exitHandlers.push(e)}call(e,r,s=Gw,a=0){if(!this.child||this.stopped)return Promise.reject(new T("AGENT_PROTOCOL_ERROR","downstream not started"));let c=this.idAllocator.next(e),d=gi(c,e,r),u=(()=>{if(typeof r!="object"||r===null)return;let _=r.sessionId;return typeof _=="string"?_:void 0})(),x=s>0&&Number.isFinite(s),p=a>0&&Number.isFinite(a);return new Promise((_,w)=>{let S={resolve:_,reject:w,timer:null,frameIdleTimer:null,armFrameIdle:null,method:e};x&&(S.timer=setTimeout(()=>{this.pending.delete(c),S.frameIdleTimer&&clearTimeout(S.frameIdleTimer),this.log.warn("downstream call timeout",{id:c,method:e,timeoutMs:s,...u?{sessionId:u}:{}}),w(new T("AGENT_TIMEOUT",`${e} timed out after ${s}ms`))},s));let b=p?()=>{S.frameIdleTimer&&clearTimeout(S.frameIdleTimer),S.frameIdleTimer=setTimeout(()=>{if(this.inflightAgentRequests.size>0){this.log.debug("frame-idle fired but agent request inflight, re-arming",{id:c,method:e,inflight:this.inflightAgentRequests.size,...u?{sessionId:u}:{}}),b?.();return}S.timer&&clearTimeout(S.timer),this.pending.delete(c),this.log.warn("frame-idle timeout, rejecting pending call",{id:c,method:e,frameIdleMs:a,...u?{sessionId:u}:{}}),w(new T("AGENT_FRAME_IDLE_TIMEOUT",`${e} no session/update for ${a}ms (no inflight agent request)`))},a)}:null;S.armFrameIdle=b,this.pending.set(c,S),b?.();try{this.writeFrame(d)}catch(E){S.timer&&clearTimeout(S.timer),S.frameIdleTimer&&clearTimeout(S.frameIdleTimer),this.pending.delete(c),w(E)}})}writeFrame(e){if(!this.child?.stdin||this.child.stdin.destroyed)throw new T("AGENT_PROTOCOL_ERROR","downstream stdin not writable");this.child.stdin.write(Eu(e),r=>{r&&this.log.warn("stdin write callback err",{err:String(r)})})}dispatch(e){if(js(e)){let r=e.id!==null?this.pending.get(e.id):void 0;if(!r){this.log.warn("orphan response",{id:e.id});return}this.pending.delete(e.id),r.timer&&clearTimeout(r.timer),r.frameIdleTimer&&clearTimeout(r.frameIdleTimer),e.error?(this.log.warn("downstream returned error frame",{id:e.id,method:r.method,code:e.error.code,message:e.error.message,data:e.error.data}),r.reject(yu(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 T("AGENT_PROTOCOL_ERROR",`${r.method} response missing both result and error`))):(this.log.info("downstream returned result",{id:e.id,method:r.method,result:Jw(e.result)}),r.resolve(e.result));return}if(_u(e)){if(e.method==="session/update"){for(let r of this.pending.values())r.armFrameIdle?.();for(let r of this.updateHandlers)try{Promise.resolve(r(e.params)).catch(s=>this.log.warn("update handler failed (async)",{err:String(s)}))}catch(s){this.log.warn("update handler threw sync, swallowed",{err:String(s)})}}else this.log.info("unknown notification (drop, not forwarded)",{method:e.method});return}if(wu(e)){let r=e;try{this.handleAgentRequest(r).catch(s=>this.log.error("agent request handler failed (async)",{method:r.method,err:String(s)}))}catch(s){this.log.warn("handleAgentRequest threw sync, swallowed",{method:r.method,err:String(s)})}}}async handleAgentRequest(e){if(this.agentRequestHandlers.length===0){this.writeFrame(hn(e.id,{code:-32601,message:`method not handled by Bridge: ${e.method}`}));return}this.inflightAgentRequests.set(e.id,e.method);for(let r of this.agentRequestHandlers)try{await r(e)}catch(s){this.log.error("agentRequestHandler threw",{method:e.method,err:String(s)});try{this.writeFrame(hn(e.id,_i(s)))}catch{}this.inflightAgentRequests.delete(e.id)}}failAllPending(e){for(let r of this.pending.values())r.timer&&clearTimeout(r.timer),r.frameIdleTimer&&clearTimeout(r.frameIdleTimer),r.reject(e);this.pending.clear(),this.inflightAgentRequests.clear()}};var Zw=Br("claude-code")??"@agentclientprotocol/claude-agent-acp@^0.37";function Xw(t){let e={};for(let[r,s]of Object.entries(t))s!==void 0&&(r.startsWith("CLAUDE")||r==="AI_AGENT"||r==="BAGGAGE"||(e[r]=s));return e}var Ws=class extends At{framework="claude-code";constructor(e){let r=Zt("claude-code"),[s,a]=r?[r,[]]:["npx",["-y",Zw]],c=e.command??s,d=e.args??a,u={command:c,args:d,cwd:e.cwd,...e.env?{env:e.env}:{}};super(u)}sanitizeEnv(e){return Xw(e)}};Xt();import{mkdtempSync as Yw,rmSync as Qw}from"node:fs";import{tmpdir as e_}from"node:os";import{join as t_}from"node:path";var n_=Br("codex")??"@zed-industries/codex-acp@^0.15",Ks=class extends At{framework="codex";authMethodId;codexHomeDir;constructor(e){let r=Zt("codex"),[s,a]=r?[r,[]]:["npx",["-y",n_]],c=e.command??s,d=e.args??a,u=e.extraArgs?[...d,...e.extraArgs]:d,x=e.isolateCodexHome?Yw(t_(e_(),"coze-bridge-codex-home-")):void 0,p=x?{...e.env??{},CODEX_HOME:x}:e.env,_={command:c,args:u,cwd:e.cwd,...p?{env:p}:{}};super(_),this.authMethodId=e.authMethodId,this.codexHomeDir=x}async initialize(e){let r=await super.initialize(e);return this.authMethodId&&await this.call("authenticate",{methodId:this.authMethodId}),r}async stop(e){if(await super.stop(e),this.codexHomeDir)try{Qw(this.codexHomeDir,{recursive:!0,force:!0})}catch{}}};var r_=3e4,yr=class extends At{framework="openclaw";agentId;sessionName;slashModelOnStart;constructor(e){let r=e.sessionName??"default",s=["acp","--session",`agent:${e.agentId}:${r}`];e.gatewayToken&&s.push("--token",e.gatewayToken);let a={command:e.command,args:s,cwd:e.cwd,...e.env?{env:e.env}:{}};super(a),this.agentId=e.agentId,this.sessionName=r,this.slashModelOnStart=e.slashModelOnStart}async afterSessionEstablished(e){this.slashModelOnStart&&(this.log.info("switching session to per-session provider via /model",{agentId:this.agentId,sessionName:this.sessionName,slash:this.slashModelOnStart}),await this.sessionPrompt({sessionId:e,prompt:[{type:"text",text:`/model ${this.slashModelOnStart}`}]},r_))}get acpSessionName(){return this.sessionName}};ie();qe();function Ec(t){return t.replace(/[^A-Za-z0-9._-]+/g,"-")}Xt();var br=class{slots=[];running=!1;closed=!1;disposed=!1;enqueue(e){return this.disposed?Promise.reject(new Error("AsyncQueue disposed")):this.closed?Promise.reject(new Error("AsyncQueue closed")):new Promise((r,s)=>{this.slots.push({task:e,resolve:r,reject:s}),this.drain()})}close(){this.closed=!0}dispose(e=new Error("AsyncQueue disposed")){for(this.disposed=!0,this.closed=!0;this.slots.length>0;)this.slots.shift()?.reject(e)}get size(){return this.slots.length}get isRunning(){return this.running}get isDisposed(){return this.disposed}async drain(){if(!this.running){this.running=!0;try{for(;this.slots.length>0&&!this.disposed;){let e=this.slots.shift();if(!e)break;try{let r=await e.task();e.resolve(r)}catch(r){e.reject(r)}}}finally{this.running=!1}}}};var $s=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 br,this.sessionQueues.set(e,r)),r}allSessionQueues(){return this.sessionQueues.entries()}hasSessionQueue(e){let r=this.sessionQueues.get(e);return!!r&&!r.isDisposed}async dispose(e){this.status="stopped";let r=new Error(`AgentSession disposed${e?`: ${e}`:""}`);for(let s of this.sessionQueues.values())s.dispose(r);this.sessionQueues.clear(),await this.killAllRuntimes(e??"dispose")}async killAllRuntimes(e){let r=[];for(let[,s]of this.sessions)yi(s),s.downstream&&(r.push(s.downstream.stop(e).catch(()=>{})),s.downstream=void 0);await Promise.all(r),this.activeTriggers.clear(),this.activeGroupIds.clear()}};function yi(t){t.idleTimer&&(clearTimeout(t.idleTimer),t.idleTimer=void 0)}$n();ie();import{constants as Au,access as i_}from"node:fs/promises";import{delimiter as s_,join as o_}from"node:path";var gn=$("framework-detector"),Tu={"claude-code":"claude",codex:"codex",openclaw:"openclaw"},a_=[".exe",".cmd",".bat",".ps1"],mn=class{env;constructor(e={}){this.env={pathEnv:e.pathEnv??process.env.PATH??"",platform:e.platform??process.platform,spawn:e.spawn??Jt,access:e.access??i_}}async detect(e){let r=Tu[e],s=await this.which(r);if(!s)return gn.debug("framework binary not found",{framework:e,bin:r}),null;let a=e==="openclaw"?["--log-level","silent"]:[],[c,d]=await Promise.all([this.probeVersion(s,a),e==="openclaw"?this.probeOpenclawDefaultAgent(s):Promise.resolve(null)]),u={path:s,version:c};return d&&(u.defaultAgent=d),u}async detectAll(){let e=await Promise.all(Object.keys(Tu).map(async s=>[s,await this.detect(s)])),r={};for(let[s,a]of e)a&&(r[s]=a);return r}async which(e){let r=this.env.pathEnv.split(s_).filter(Boolean),s=this.env.platform==="win32"?["",...a_]:[""];for(let a of r)for(let c of s){let d=o_(a,e+c);if(await this.isExecutable(d))return d}return null}async isExecutable(e){try{let r=this.env.platform==="win32"?Au.F_OK:Au.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 gn.warn("openclaw default agent probe: runProbe returned null (spawn err / timeout)",{path:e}),null;if(r.code!==0)return gn.warn("openclaw default agent probe: non-zero exit",{path:e,code:r.code,stdoutHead:r.stdout.slice(0,200)}),null;let s=r.stdout.match(/\[\s*\{[\s\S]*\}\s*\]/);if(!s)return gn.warn("openclaw default agent probe: regex no match (no JSON array in stdout)",{path:e,stdoutHead:r.stdout.slice(0,200)}),null;try{let a=JSON.parse(s[0]);if(!Array.isArray(a))return gn.warn("openclaw default agent probe: JSON parsed but not an array",{path:e}),null;let c=a.find(d=>d?.isDefault===!0);return c?!c.id||!c.workspace?(gn.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}:(gn.info("openclaw default agent probe: no agent has isDefault=true",{path:e,agentCount:a.length}),null)}catch(a){return gn.warn("openclaw default agent probe: JSON.parse failed",{path:e,err:String(a),matchHead:s[0].slice(0,200)}),null}}async probeVersion(e,r=[]){let s=await this.runProbe(e,[...r,"--version"]);return s&&(f_(s.stdout).split(/\r?\n/)[0]??"").trim()||"unknown"}runProbe(e,r){return new Promise(s=>{let a="",c=!1,d,u=x=>{c||(c=!0,d&&clearTimeout(d),s(x))};try{let x=this.env.spawn(e,r,{stdio:["ignore","pipe","pipe"]});d=setTimeout(()=>{x.kill("SIGKILL"),u(null)},15e3),x.stdout?.on("data",p=>{a+=p.toString("utf8")}),x.on("error",()=>u(null)),x.on("close",p=>u({code:p,stdout:a}))}catch{u(null)}})}},c_=new RegExp("\x1B\\[[0-9;]*[A-Za-z]","g");function f_(t){return t.replace(c_,"")}import{spawn as d_}from"node:child_process";import{homedir as u_}from"node:os";import{join as l_}from"node:path";Gi();ie();async function ku(){let t=l_(u_(),".openclaw/openclaw.json");return(await Zn(t))?.gateway?.auth?.token??""}var Du=$("openclaw.config"),x_=[0,5e3,5e3],Ru="models.providers.",Vs="agents.defaults.models",Js=class{command;env;retryDelaysMs;queue=new br;constructor(e){this.command=e.command,this.env=e.env??process.env,this.retryDelaysMs=e.retryDelaysMs??x_}async withRetry(e,r){let s;for(let a=0;a<this.retryDelaysMs.length;a++){let c=this.retryDelaysMs[a]??0;c>0&&await new Promise(d=>setTimeout(d,c));try{return await r()}catch(d){s=d,Du.warn("openclaw cli failed, will retry",{label:e,attempt:a+1,err:String(d)})}}throw new T("AGENT_SPAWN_FAILED",`openclaw cli ${e} failed after ${this.retryDelaysMs.length} attempts: ${s?.message??"unknown"}`)}runCli(e){return new Promise((r,s)=>{let a=d_(this.command,e,{stdio:["ignore","pipe","pipe"],env:this.env}),c="";a.stderr?.on("data",d=>{c+=d.toString("utf8")}),a.on("error",s),a.on("close",d=>{d===0?r():s(new Error(`exit ${d}: ${c.trim().slice(0,500)}`))})})}async runCliTolerant(e,r){try{await this.runCli(e)}catch(s){let a=String(s);if(r.some(c=>a.includes(c)))return;throw s}}async bestEffortUnset(e,r){try{await this.queue.enqueue(()=>this.withRetry(e,()=>this.runCli(["config","unset",r])))}catch(s){Du.warn(`${e} failed (best-effort)`,{configPath:r,err:String(s)})}}ensureProvider(e,r){return this.queue.enqueue(()=>this.withRetry(`config set models.providers.${e}`,()=>this.runCli(["config","set",`${Ru}${e}`,JSON.stringify(r),"--strict-json","--merge"])))}removeProvider(e){return this.bestEffortUnset(`config unset models.providers.${e}`,`${Ru}${e}`)}addModelToAllowlist(e,r){let s={[e]:r?{alias:r}:{}};return this.queue.enqueue(()=>this.withRetry(`config set ${Vs}[${e}]`,()=>this.runCli(["config","set",Vs,JSON.stringify(s),"--strict-json","--merge"])))}removeModelFromAllowlist(e){return this.bestEffortUnset(`config unset ${Vs}[${e}]`,`${Vs}.${e}`)}ensureAgent(e,r,s){let a=["agents","add",e,"--workspace",r,"--non-interactive"];return s&&a.push("--model",s),this.queue.enqueue(()=>this.withRetry(`agents add ${e}`,()=>this.runCliTolerant(a,["already exists","already registered"])))}deleteAgent(e){return this.queue.enqueue(()=>this.withRetry(`agents delete ${e}`,()=>this.runCliTolerant(["agents","delete",e,"--force"],["not found","does not exist"])))}};var Be=$("agent-manager"),p_=(t,e,r,s,a,c,d,u,x)=>{switch(t){case"claude-code":{let p={...a?{...iu(a),...au(a,d,u)}:{},...x??{},IS_SANDBOX:"1"};return new Ws({cwd:r,env:p})}case"codex":{let _=[...a?[...su(a),...fu(a,d,u)]:[],"-c",'sandbox_mode="danger-full-access"',"-c",'approval_policy="never"'],w={...a?ou(a):{},...x??{}},S=!!a;return new Ks({cwd:r,..._.length>0?{extraArgs:_}:{},...Object.keys(w).length>0?{env:w}:{},...S?{authMethodId:"openai-api-key",isolateCodexHome:!0}:{}})}case"openclaw":return new yr({command:e,cwd:r,agentId:s,...c?{sessionName:Ec(c)}:{}})}};function Sc(t){return t==="claude-code"||t==="codex"}var g_={path:"",version:"cloud-deployed"},m_={protocolVersion:1,clientCapabilities:{fs:{readTextFile:!0,writeTextFile:!0}}},w_=6e4,__=pn("COZE_BRIDGE_SPAWN_AWAIT_INSTALL_MS",25e3),Zs=class{paths;config;registry;factory;createTimeoutMs;spawnAwaitInstallMs;openclawConfigCache;ensuredProviders=new Set;detectorFactory;constructor(e){this.paths=e.paths,this.config=e.config,this.registry=e.registry,this.factory=e.downstreamFactory??p_,this.createTimeoutMs=e.createTimeoutMs??w_,this.spawnAwaitInstallMs=e.spawnAwaitInstallMs??__,this.detectorFactory=e.detectorFactory??(()=>new mn)}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 T("AGENT_SPAWN_FAILED","openclaw binary not detected on this machine");this.openclawConfigCache=new Js({command:e.path})}return this.openclawConfigCache}async createAgent(e){if(!e.agentId)throw new T("IPC_BAD_REQUEST","agentId required");if(!e.framework)throw new T("IPC_BAD_REQUEST","framework required");let r=ui(e._meta)==="cloud";this.registry.reviveIfDisconnected?.(e.agentId);let s=this.registry.get(e.agentId);if(s){if(s.framework!==e.framework)throw new T("AGENT_BUSY",`agent ${e.agentId} exists with different framework (${s.framework})`);if(s.status==="error")Be.warn("existing agent in error state, rebuilding",{agentId:e.agentId}),await s.dispose("rebuild after error").catch(E=>Be.warn("dispose stale agent failed (ignored)",{err:String(E)})),this.registry.unregister(e.agentId);else{if(e.patToken&&e.patToken!==s.patToken){Be.info("updating agent patToken on re-create (reconnect with new PAT)",{agentId:e.agentId}),s.setPatToken(e.patToken);let E=await We(e.agentId,this.paths).catch(()=>null);E&&(E.patToken=e.patToken,await Ze(E,this.paths))}if(s.deployType==="cloud"&&e.modelInfo){Be.info("updating agent modelInfo on re-create",{agentId:e.agentId}),s.setModelInfo(e.modelInfo);let E=await We(e.agentId,this.paths).catch(()=>null);E&&(E.modelInfo=e.modelInfo,await Ze(E,this.paths))}return Be.info("agent already exists, return current",{agentId:e.agentId}),{ok:!0,agentId:s.agentId,workspace:s.workspace,framework:s.framework}}}if(!r&&!this.config.frameworksCache?.[e.framework])throw new T("AGENT_SPAWN_FAILED",`framework ${e.framework} not detected on this machine; rerun daemon to refresh frameworks_cache`);let c=Lt(e.agentId,this.paths),d=ui(e._meta),u=e.framework==="openclaw"&&d==="local",x=u?this.config.frameworksCache?.openclaw?.defaultAgent?.workspace:void 0,p=e.workspace??x??c.workspace,_=new AbortController,w=setTimeout(()=>_.abort(new T("AGENT_TIMEOUT",`_agent/create timed out after ${this.createTimeoutMs}ms`)),this.createTimeoutMs),S,b=!1;try{r&&Sc(e.framework)&&await bn(e.framework,_.signal);let E=()=>{if(_.signal.aborted)throw _.signal.reason instanceof Error?_.signal.reason:new T("AGENT_TIMEOUT","_agent/create aborted")};await vc(c.root,{recursive:!0}),await vc(p,{recursive:!0}),await vc(c.logs,{recursive:!0}),E(),u||await Xn(p,e.framework,e.agentId,e.cozeIdentity),e.framework==="claude-code"&&await Y0(p),E();let v=await We(e.agentId,this.paths).catch(()=>null),C=nu({model:e.model??v?.model}),D=Vd(e._meta)??v?.accountId,O=e.patToken??v?.patToken,y=d==="cloud"?e.modelInfo??v?.modelInfo:void 0;if(S=new $s({agentId:e.agentId,framework:e.framework,workspace:p,model:C.model??It,deployType:d,...D?{accountId:D}:{},...O?{patToken:O}:{},...y?{modelInfo:y}:{}}),S.status="ok",v?.sessions){for(let[z,k]of Object.entries(v.sessions))S.sessions.set(z,{acpSessionId:k.acpSessionId,modelToken:k.modelToken,tokenGeneratedAt:k.tokenGeneratedAt,lastActiveAt:Date.now(),loadingSession:!1,replySeq:0});let U=Object.keys(v.sessions).length;U>0&&Be.info("restored persisted session records (no spawn)",{agentId:e.agentId,count:U})}this.registry.register(S),b=!0;let A={agentId:e.agentId,framework:e.framework,workspace:p,cozeIdentity:e.cozeIdentity,createdAt:v?.createdAt??Date.now(),sessions:v?.sessions??{},model:C.model};d==="cloud"&&(A.deployType="cloud"),D&&(A.accountId=D),O&&(A.patToken=O),y&&(A.modelInfo=y),v?.skills&&(A.skills=v.skills),v?.agentName&&(A.agentName=v.agentName),v?.description&&(A.description=v.description),e.framework==="openclaw"&&d==="cloud"&&(this.config.frameworksCache?.openclaw?.path?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 R=e.initialSkills??[];if(R.length>0){let U=[...A.skills??[]],z=new Map(U.map((q,Z)=>[q.skillId,Z])),k=await Promise.allSettled(R.map(q=>_c({agentId:e.agentId,workspace:p,framework:e.framework,skill:q}))),N=0;for(let[q,Z]of k.entries()){let fe=R[q];fe&&(Z.status==="fulfilled"?(yc(U,z,Z.value),N++):Be.warn("initialSkill install failed (skipping)",{agentId:e.agentId,skillId:fe.skillId,skillName:fe.skillName,err:String(Z.reason)}))}N>0&&(A.skills=U,Be.info("initialSkills installed",{agentId:e.agentId,installed:N,requested:R.length}))}return await Ze(A,this.paths),Be.info("agent created (no spawn, lazy on first prompt)",{agentId:e.agentId,framework:e.framework,deployType:d}),{ok:!0,agentId:e.agentId,workspace:p,framework:e.framework}}catch(E){throw Be.error("agent create failed, rolling back",{agentId:e.agentId,err:String(E)}),b&&S&&(await S.dispose("rollback").catch(()=>{}),this.registry.unregister(e.agentId)),await h_(c.root,{recursive:!0,force:!0}).catch(v=>Be.warn("rm agent dir failed (ignored)",{err:String(v)})),E instanceof T?E:new T("AGENT_SPAWN_FAILED",String(E),{cause:E})}finally{clearTimeout(w)}}async spawnSessionDownstream(e,r,s,a,c){let u=this.config.frameworksCache?.[e.framework];if(!u)if(e.deployType==="cloud"&&Sc(e.framework))u=g_;else throw new T("AGENT_SPAWN_FAILED",`framework ${e.framework} not detected on this machine`);if(Sc(e.framework)&&!Zt(e.framework)){let _=Yo(e.framework);_&&(Be.info("spawn: awaiting in-flight acp install (D92)",{agentId:e.agentId,framework:e.framework}),await Promise.race([_.catch(()=>{}),new Promise(w=>setTimeout(w,this.spawnAwaitInstallMs))]))}let x=e.deployType==="cloud"?{model:e.model,modelToken:r,...e.modelInfo?{modelInfo:e.modelInfo}:{}}:void 0,p;e.framework==="openclaw"?p=await this.buildOpenclawDownstream({session:e,modelConfig:x,cloudSessionId:s,cozeEnv:a,mockScenario:c,command:u.path}):p=this.factory(e.framework,u.path,e.workspace,e.agentId,x,s,a,c,this.buildBinShimPathEnv());try{return await p.start(),await p.initialize(m_),p}catch(_){let w=p instanceof At?p.getStderrTail():[];w.length>0&&Be.warn("spawnSessionDownstream failed, recent stderr (D94)",{agentId:e.agentId,framework:e.framework,method:_ instanceof T?_.code:"unknown",recentStderr:w});let S=bc(w);await p.stop("spawnSessionDownstream failed").catch(()=>{});let b=S?new T("NPX_CACHE_CORRUPT","~/.npm/_npx \u76EE\u5F55\u635F\u574F (ENOTEMPTY)\u3002\u5EFA\u8BAE: rm -rf ~/.npm/_npx && npm i -g @zed-industries/codex-acp (\u6216\u5BF9\u5E94 @agentclientprotocol/claude-agent-acp)",{cause:_}):_;throw _ instanceof T?new T(_.code,_.message,{retriable:_.retriable,cause:b}):new T("AGENT_SPAWN_FAILED",_ instanceof Error?_.message:String(_),{cause:b})}}async buildOpenclawDownstream(e){let{session:r,modelConfig:s,cloudSessionId:a,cozeEnv:c,mockScenario:d,command:u}=e,x=Ec(a);if(r.deployType==="local"){let S=this.config.frameworksCache?.openclaw?.defaultAgent;if(!S?.id||!S.workspace){Be.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)Be.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,S=E.defaultAgent;else throw new T("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 yr({command:u,cwd:S.workspace,agentId:S.id,sessionName:x})}let p=await ku(),_=s?cu(s,c,d):null,w;if(_){let S=lc(a),E=_.models[0]?.id??It,v=`${S}/${E}`;if(!this.ensuredProviders.has(v)){let C=this.getOpenclawConfig();await C.ensureProvider(S,_),await C.addModelToAllowlist(v),this.ensuredProviders.add(v)}w=v}return new yr({command:u,cwd:r.workspace,agentId:r.agentId,sessionName:x,...p?{gatewayToken:p}:{},...w?{slashModelOnStart:w}:{}})}async openclawRepair(e,r){let s=this.getOpenclawConfig();await s.deleteAgent(e),await s.ensureAgent(e,r)}async cleanupOpenclawSessionProviders(e){if(e.framework!=="openclaw"||!this.openclawConfigCache)return;let r=this.openclawConfigCache;for(let s of e.sessions.keys()){let a=lc(s),c=`${a}/${e.model}`,d=!0;try{await r.removeProvider(a)}catch(u){d=!1,Be.warn("removeProvider failed, keeping ensuredProviders entry",{providerId:a,err:String(u)})}try{await r.removeModelFromAllowlist(c)}catch(u){d=!1,Be.warn("removeModelFromAllowlist failed, keeping ensuredProviders entry",{fullModelId:c,err:String(u)})}d&&this.ensuredProviders.delete(c)}}};import{randomUUID as Mu}from"node:crypto";import{promises as R_}from"node:fs";import{basename as Bu}from"node:path";import{promises as b_}from"node:fs";import{basename as E_}from"node:path";ie();var Lu=$("file-upload"),v_="/api/coze_claw/file/agent_upload",S_=6e4;async function Ou(t,e={}){let s=`${zs(Us(e.handshakeBase))}${v_}`,a=e.timeoutMs??S_,c=await b_.readFile(t.path),d=new FormData;d.append("agent_id",t.agentId),d.append("session_id",t.sessionId),d.append("file_name",t.name),d.append("file_content",new Blob([c],{type:t.mimeType}),t.name);let u={Authorization:`Bearer ${t.patToken}`,Accept:"application/json","x-coze-version":"3.0",...pr(e.ppeOverride),...t.accountId?{"x-coze-account":t.accountId}:{}},x=new AbortController,p=setTimeout(()=>x.abort(),a);Lu.info("file upload start",{url:s,agentId:t.agentId,sessionId:t.sessionId,name:t.name,bytes:t.sizeBytes,mime:t.mimeType});try{let _=await fetch(s,{method:"POST",headers:u,body:d,signal:x.signal}),w=_.headers.get("x-tt-logid")??"";if(!_.ok){let E=await _.text().catch(()=>"");throw new T("UPLOAD_FAILED",`upload HTTP ${_.status} logid=${w}: ${E.slice(0,200)}`)}let S=await _.json();if(S.code!==void 0&&S.code!==0)throw new T("UPLOAD_FAILED",`upload code=${S.code} msg=${S.msg??"-"} logid=${w}`);let b=S.data?.file?.file_url;if(!b)throw new T("UPLOAD_FAILED",`upload response missing data.file.file_url logid=${w}: ${JSON.stringify(S).slice(0,200)}`);return Lu.info("file upload ok",{uri:b,logid:w}),{uri:b}}catch(_){throw _ instanceof T?_:_.name==="AbortError"?new T("UPLOAD_FAILED",`upload timeout (${a}ms) for ${E_(t.path)}`):new T("UPLOAD_FAILED",String(_),{cause:_})}finally{clearTimeout(p)}}ie();import{promises as I_}from"node:fs";import{extname as C_}from"node:path";var A_=[{mime:"image/png",prefix:[137,80,78,71]},{mime:"image/jpeg",prefix:[255,216,255]},{mime:"image/gif",prefix:[71,73,70,56]},{mime:"application/pdf",prefix:[37,80,68,70]}];function T_(t){return t[0]===82&&t[1]===73&&t[2]===70&&t[3]===70&&t[8]===87&&t[9]===69&&t[10]===66&&t[11]===80}var D_={".txt":"text/plain",".md":"text/markdown",".svg":"image/svg+xml",".json":"application/json"};async function Pu(t){let e=await I_.open(t,"r");try{let r=Buffer.alloc(16);if(await e.read(r,0,16,0),T_(r))return"image/webp";for(let s of A_)if(s.prefix.every((a,c)=>r[c]===a))return s.mime}finally{await e.close()}return D_[C_(t).toLowerCase()]??"application/octet-stream"}qe();var Xs=$("agent-send"),Nu=50*1024*1024,k_=new Set(["image/png","image/jpeg","image/webp","image/gif","image/svg+xml","application/pdf","application/json","text/plain","text/markdown"]);function zu(t,e,r){let s=t.get(e);if(!s)throw new T("AGENT_NOT_FOUND",`agent=${e}`);if(t.disconnectedAgents.has(e))throw new T("AGENT_DISCONNECTED",`agent=${e} was disconnected by cloud`);let a=s.sessions.get(r);if(!a)throw new T("AGENT_NOT_FOUND",`session=${r} not active in agent=${e}`);return{session:s,runtime:a}}async function Fu(t,e,r,s,a,c){let u;for(let x=0;x<=2;x++)try{await t.core.sendAgentFileUpdate(e,r,s,a);return}catch(p){u=p,x<2&&(Xs.warn("sendAgentFileUpdate failed, retrying",{attempt:x+1,err:String(p)}),await new Promise(_=>setTimeout(_,5e3)))}throw new T("UPSTREAM_NOT_READY",`${c} after 3 attempts: ${String(u)}`,{cause:u})}async function Uu(t,e){let{session:r,runtime:s}=zu(e.core,t.agentId,t.sessionId);if(!await zr(t.path,r.workspace))throw new T("PATH_OUTSIDE_WORKSPACE",`path=${t.path} not under workspace=${r.workspace}`);let a=await R_.stat(t.path).catch(()=>null);if(!a||!a.isFile())throw new T("IPC_BAD_REQUEST",`path is not a regular file: ${t.path}`);if(a.size>Nu)throw new T("FILE_TOO_LARGE",`${a.size} bytes > limit ${Nu}`);let c=await Pu(t.path);if(!k_.has(c))throw new T("UNSUPPORTED_MIME",`mime=${c} not in whitelist`);if(t.kind==="image"&&!c.startsWith("image/"))throw new T("UNSUPPORTED_MIME",`kind=image but mime=${c}`);if(!e.core.upstream.isConnected())throw new T("UPSTREAM_NOT_READY","cloud WS not connected");let d=t.name??Bu(t.path),u;try{u=await Ou({patToken:r.patToken??e.patToken,agentId:t.agentId,sessionId:t.sessionId,path:t.path,mimeType:c,name:d,sizeBytes:a.size,...r.accountId?{accountId:r.accountId}:{}},{handshakeBase:e.handshakeBase,ppeOverride:e.ppeOverride})}catch(p){throw Xs.warn("agent file upload failed",{agentId:t.agentId,sessionId:t.sessionId,path:t.path,sizeBytes:a.size,mime:c,code:p instanceof T?p.code:"UNKNOWN",message:p instanceof Error?p.message:String(p)}),p}let x={sessionUpdate:"agent_file",messageId:Mu(),content:{type:t.kind==="image"?"image":"resource",uri:u.uri,mimeType:c,name:d,sizeBytes:a.size,...u.fileId!==void 0?{fileId:u.fileId}:{},...t.caption!==void 0?{caption:t.caption}:{}}};return await Fu(e,r,s,t.sessionId,x,"agent file uploaded to cloud but sendAgentFileUpdate failed"),Xs.info("agent file sent",{agentId:t.agentId,sessionId:t.sessionId,kind:t.kind,name:d,bytes:a.size,mime:c,uri:u.uri}),{ok:!0,uri:u.uri,bytes:a.size,mimeType:c,...u.fileId!==void 0?{fileId:u.fileId}:{}}}async function qu(t,e){let{session:r,runtime:s}=zu(e.core,t.agentId,t.sessionId);if(!t.mimeType)throw new T("IPC_BAD_REQUEST","group-file requires mimeType");if(!e.core.upstream.isConnected())throw new T("UPSTREAM_NOT_READY","cloud WS not connected");let a=t.name??Bu(t.path),c={sessionUpdate:"group_file",messageId:Mu(),content:{uri:t.path,name:a,mimeType:t.mimeType,...t.caption!==void 0?{caption:t.caption}:{}}};return await Fu(e,r,s,t.sessionId,c,"agent group file sendAgentFileUpdate failed"),Xs.info("agent group file sent",{agentId:t.agentId,sessionId:t.sessionId,uri:t.path,name:a,mime:t.mimeType}),{ok:!0,uri:t.path,bytes:0,mimeType:t.mimeType}}function Hu(t,e){let r=t.split(".").map(Number),s=e.split(".").map(Number),a=Math.max(r.length,s.length);for(let c=0;c<a;c++){let d=r[c]??0,u=s[c]??0;if(d<u)return!0;if(d>u)return!1}return!1}Xt();$n();ie();var Tt=$("coze-cli-installer"),ju="@coze/cli@latest",L_="coze",Gu="0.1.7",O_=5e3,P_=5e3,N_=9e4,Wu=1e4,bi=null,Ys=!1;async function Ic(t,e={}){if(Ys)return;if(bi)return bi;let r=e.exec??Fi;return bi=(async()=>{try{let s=await M_(L_,r),a=!1;if(s){let d=await B_(r);if(d===void 0)Tt.warn("coze-cli found but version unparseable, fall through to full install",{path:s});else if(Hu(d,Gu))Tt.info("coze-cli version too old, upgrade-only (preserve user config + auth)",{path:s,version:d,min:Gu}),a=!0;else{Tt.info("coze-cli already on PATH with sufficient version, skip",{path:s,version:d}),Ys=!0;return}}let c=a?"upgrade-only":"full";Tt.info("coze-cli install start",{package:ju,mode:c});try{await r("npm",["i","-g","--prefer-online",ju],{timeout:N_,maxBuffer:10*1024*1024}),Tt.info("coze-cli install ok")}catch(d){Tt.warn("coze-cli install failed (skip subsequent steps)",{err:String(d)});return}if(a){Ys=!0;return}if(t.env)try{await r("coze",["config","set","xTTEnv",t.env],{timeout:Wu}),Tt.info("coze config set xTTEnv ok",{env:t.env})}catch(d){Tt.warn("coze config set failed (continue to auth login)",{err:String(d)})}try{await r("coze",["auth","login","--token",t.patToken],{timeout:Wu}),Tt.info("coze auth login ok")}catch(d){Tt.warn("coze auth login failed",{err:String(d)});return}Ys=!0}finally{bi=null}})(),bi}async function M_(t,e){let r=process.platform==="win32"?"where":"which";try{let{stdout:s}=await e(r,[t],{timeout:O_});return Hi(s)}catch{return}}async function B_(t){try{let{stdout:e,stderr:r}=await t("coze",["--version"],{timeout:P_});return(e||r).match(/(\d+\.\d+\.\d+)/)?.[1]}catch{return}}Gi();qe();var z_=10*6e4;function Ku(t){let e=t?.sessionIdleTimeoutMs;return typeof e!="number"||!Number.isFinite(e)||e<=0?z_:e}function Qs(t){return Zn(t??se().configFile)}function Er(t,e){return ji(e??se().configFile,t)}import{randomBytes as ny}from"node:crypto";import{createReadStream as F_}from"node:fs";import{mkdir as U_,readFile as q_,realpath as H_,stat as j_,writeFile as G_}from"node:fs/promises";import{basename as W_,dirname as Cc,join as K_,relative as $_,resolve as $u,sep as V_}from"node:path";import{createInterface as J_}from"node:readline";ie();var Ju=$("fs-rpc"),Ei=pn("COZE_BRIDGE_FS_RPC_MAX_BYTES",20*1024*1024);async function Zu(t,e){let r=Buffer.byteLength(t.content,"utf8");if(r>Ei)throw new T("IPC_BAD_REQUEST",`fs/write_text_file content too large: ${r} bytes > limit ${Ei} bytes`);let s=await Yu(t.path,e);return await U_(Cc(s),{recursive:!0}),await G_(s,t.content,"utf8"),Ju.info("fs/write_text_file ok",{path:s,size:t.content.length}),null}async function Xu(t,e){let r=await Yu(t.path,e),s=await j_(r),a=typeof t.line=="number"||typeof t.limit=="number";if(s.size>Ei&&!a)throw new T("IPC_BAD_REQUEST",`fs/read_text_file too large without line/limit slicing: ${s.size} bytes > ${Ei} bytes`);let c;if(a&&s.size>Ei)c=await Z_(r,t.line??1,t.limit);else{let d=await q_(r,"utf8");if(a){let u=d.split(`
|
|
120
|
-
`),x=Math.max(0,(t.line??1)-1),p=typeof t.limit=="number"?x+t.limit:void 0;c=u.slice(x,p).join(`
|
|
121
|
-
`)}else c=d}return Ju.info("fs/read_text_file ok",{path:r,size:c.length}),{content:c}}async function Z_(t,e,r){let s=J_({input:F_(t,{encoding:"utf8"}),crlfDelay:Number.POSITIVE_INFINITY}),a=Math.max(0,e-1),c=typeof r=="number"?a+r:Number.POSITIVE_INFINITY,d=[],u=0;try{for await(let x of s)if(u>=a&&u<c&&d.push(x),u++,u>=c)break}finally{s.close()}return d.join(`
|
|
122
|
-
`)}async function Yu(t,e){if(typeof t!="string"||t.length===0)throw new T("IPC_BAD_REQUEST","path must be a non-empty string");let[r,s]=await Promise.all([Vu($u(e)),Vu($u(t))]),a=$_(r,s);if(a.startsWith("..")||a===".."||a.startsWith(`..${V_}`))throw new T("IPC_BAD_REQUEST",`path escapes workspace: ${t}`);return s}async function Vu(t){let e=[],r=t;for(;r!==Cc(r);)try{let s=await H_(r);return e.length?K_(s,...e.reverse()):s}catch{e.push(W_(r)),r=Cc(r)}return t}ie();var Qu=$("prompt-multimodal"),el=10*1024*1024,X_=15e3,Y_=6;async function tl(t){let e=new Array(t.length),r=0;async function s(){for(;r<t.length;){let c=r++,d=t[c];d!==void 0&&(e[c]=await Q_(d))}}let a=Array.from({length:Math.min(Y_,t.length)},()=>s());return await Promise.all(a),e}function nl(t){return t.some(e=>e.type==="image")}async function Q_(t){if(t.type!=="image")return t;let e=t;if(e.data||!e.uri||!Bs(e.uri))return t;try{let{buf:r,contentType:s}=await ty(e.uri),a=e.mimeType||ey(s)||"application/octet-stream";return Qu.info("image uri fetched and inlined",{uri:e.uri,bytes:r.length,mimeType:a}),{type:"image",data:r.toString("base64"),mimeType:a}}catch(r){return Qu.warn("image fetch failed, degrading to text block",{uri:e.uri,err:String(r)}),{type:"text",text:`[image load failed: ${e.uri}]`}}}function ey(t){if(!t)return;let e=t.indexOf(";");return(e===-1?t:t.slice(0,e)).trim()||void 0}async function ty(t){let e=new AbortController,r=setTimeout(()=>e.abort(),X_);try{let s=await fetch(t,{signal:e.signal});if(!s.ok)throw new Error(`HTTP ${s.status} ${s.statusText}`);let a=await s.arrayBuffer();if(a.byteLength>el)throw new Error(`image too large: ${a.byteLength} bytes (max ${el})`);return{buf:Buffer.from(a),contentType:s.headers.get("content-type")??void 0}}finally{clearTimeout(r)}}Yt();ie();var Y=$("core"),ry=3e4,iy=/^(boe|ppe)_[A-Za-z0-9_-]+$/,sy=3e4,eo=class{upstream;agents=new Map;disconnectedAgents=new Set;extensions;paths;sessionSpawner;sessionIdleTimeoutMs;upstreamIds=new _r;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=Ku(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(),Y.info("Core started",{extensions:Object.keys(this.extensions)})}async stop(e){Y.info("Core stopping",{reason:e}),await Promise.all([...this.agents.values()].map(r=>r.dispose(e))),this.agents.clear(),await this.upstream.stop(e)}get(e){return this.agents.get(e)}register(e){this.agents.set(e.agentId,e),Y.info("agent registered",{agentId:e.agentId,framework:e.framework});for(let r of this.registerHandlers)try{r(e.agentId)}catch(s){Y.warn("onAgentRegister handler threw (ignored)",{agentId:e.agentId,err:String(s)})}}onAgentRegister(e){return this.registerHandlers.add(e),()=>this.registerHandlers.delete(e)}registerHandlers=new Set;unregister(e){this.agents.delete(e)}reviveIfDisconnected(e){this.disconnectedAgents.delete(e)&&Y.info("agent revived from disconnect",{agentId:e})}attachRuntimeHooks(e,r,s){let a=s.downstream;a&&(a.onUpdate(c=>{s.loadingSession||this.forwardUpdate(e,c)}),a.onAgentRequest(c=>{this.handleAgentRequest(e,a,c)}),a.onExit((c,d)=>{Y.info("session runtime exited",{agentId:e.agentId,cloudId:r,code:c,signal:d}),yi(s),s.downstream=void 0,s.replySeq=0,s.acpSessionId&&e.activeTriggers.delete(s.acpSessionId),this.rejectPendingForDownstream(a,"downstream exited")}))}hasPendingPermissionFor(e){for(let r of this.pendingUpstream.values())if(r.downstream===e)return!0;return!1}rejectPendingForDownstream(e,r){let s=[];for(let[a,c]of this.pendingUpstream)c.downstream===e&&s.push(a);if(s.length!==0){Y.info("reject pendingUpstream entries (downstream gone)",{reason:r,count:s.length});for(let a of s){let c=this.pendingUpstream.get(a);if(c){this.pendingUpstream.delete(a),this.upstream.send(hn(a,{code:re.INTERNAL_ERROR,message:`bridge downstream gone: ${r}`})).catch(d=>Y.debug("send error response to upstream failed (ignored)",{err:String(d)}));try{c.downstream.respondAgentRequestError(c.agentRequestId,{code:re.INTERNAL_ERROR,message:`bridge: ${r}`})}catch{}}}}}rejectAllPendingOnReconnect(){let e=this.pendingUpstream.size,r=this.pendingBridge.size;if(!(e===0&&r===0)){Y.warn("upstream reconnected, rejecting stale pending requests",{pendingUpstream:e,pendingBridge:r});for(let[,s]of this.pendingUpstream)try{s.downstream.respondAgentRequestError(s.agentRequestId,{code:re.INTERNAL_ERROR,message:"upstream reconnected; please retry"})}catch{}this.pendingUpstream.clear();for(let[,s]of this.pendingBridge)clearTimeout(s.timer),s.reject(new T("UPSTREAM_DISCONNECTED",`${s.method} aborted: upstream reconnected`));this.pendingBridge.clear()}}async handleFrame(e){if(js(e)){this.handleUpstreamResponse(e);return}if(!("method"in e)||typeof e.method!="string")return;let r="id"in e&&e.id!==void 0?e.id:null,s=e.params?._meta?.cozeEnv;s&&iy.test(s)?this.currentCozeEnv=s:s&&Y.warn("rejecting cozeEnv with invalid shape, keeping previous",{rejected:s});try{if(e.method.startsWith("_agent/")){let a=this.extensions[e.method];if(!a){r!==null?await this.sendError(r,re.METHOD_NOT_FOUND,`extension not registered: ${e.method}`):Y.warn("drop notification: extension not registered",{method:e.method});return}let c=await a(e,this);r!==null&&await this.upstream.send(wr(r,c));return}if(e.method.startsWith("session/")){let a=await this.routeSessionMethod(e);r!==null&&await this.upstream.send(wr(r,a));return}if(e.method==="initialize"){r!==null&&await this.upstream.send(wr(r,{protocolVersion:1,agentCapabilities:{loadSession:!0}}));return}r!==null?await this.sendError(r,re.METHOD_NOT_FOUND,`method not implemented: ${e.method}`):Y.warn("drop unknown notification",{method:e.method})}catch(a){Y.error("handleFrame failed",{method:e.method,err:String(a)}),r!==null&&await this.upstream.send(hn(r,_i(a)))}}async routeSessionMethod(e){if(!e.params||typeof e.params!="object")throw new T("IPC_BAD_REQUEST",`${e.method} requires params`);let r=e.params,s=r._meta?.cozeAgentId;if(!s)throw new T("IPC_BAD_REQUEST",`${e.method}: missing _meta.cozeAgentId`);let a=this.agents.get(s);if(!a)throw this.disconnectedAgents.has(s)?new T("AGENT_DISCONNECTED",`agent ${s} has been disconnected; cloud must _agent/create to revive`):new T("AGENT_NOT_FOUND",`agent not found: ${s}`);let c=typeof r.sessionId=="string"?r.sessionId:void 0;if(e.method==="session/cancel"||e.method==="session/new"||!c)return this.dispatchSessionCall(a,e.method,r);let d=Date.now(),u=!1;try{let x=await a.getSessionQueue(c).enqueue(()=>this.dispatchSessionCall(a,e.method,r));return u=!0,x}finally{Y.info("session call done",{agentId:a.agentId,method:e.method,durationMs:Date.now()-d,ok:u})}}async dispatchSessionCall(e,r,s){e.lastActiveAt=Date.now();let{stripped:a}=Zd(s);switch(r){case"session/new":{let c=oy();return Y.info("session/new ack (lazy spawn)",{agentId:e.agentId,cloudId:c}),{sessionId:c}}case"session/load":{let c=a;return Y.info("session/load ack (lazy spawn)",{agentId:e.agentId,cloudId:c.sessionId}),{}}case"session/prompt":{let c=a,d=c.sessionId;if(!d)throw new T("IPC_BAD_REQUEST","session/prompt: missing sessionId");let u=await this.ensureRuntime(e,d);if(u.replySeq=0,await this.ensureDownstream(e,d,u),!u.downstream||!u.acpSessionId)throw new T("BRIDGE_INTERNAL","session runtime not ready after ensureDownstream");let x=s._meta?.cozeTriggerMsgId;x?e.activeTriggers.set(u.acpSessionId,x):e.activeTriggers.delete(u.acpSessionId);let p=Jd(s._meta);if(p?e.activeGroupIds.set(u.acpSessionId,p):e.activeGroupIds.delete(u.acpSessionId),e.deployType==="cloud"&&e.modelInfo?.capabilities?.image===!1&&nl(c.prompt))throw new T("MODEL_MODALITY_UNSUPPORTED",`model=${e.modelInfo.id??e.model} does not support image input`);let _=await tl(c.prompt);try{let w=await u.downstream.sessionPrompt({...c,sessionId:u.acpSessionId,prompt:_});return u.lastActiveAt=Date.now(),w}finally{if(e.activeTriggers.delete(u.acpSessionId),e.activeGroupIds.delete(u.acpSessionId),u.reloadAfterTurn){u.reloadAfterTurn=!1;let w=u.downstream;w&&(u.downstream=void 0,Y.info("reloadAfterTurn: stopping downstream",{agentId:e.agentId,cloudId:d,acpId:u.acpSessionId}),w.stop("reload-after-turn").catch(S=>Y.warn("reload-after-turn stop failed (ignored)",{agentId:e.agentId,cloudId:d,err:String(S)})))}else u.downstream?.isAlive()&&this.armIdleTimer(e,d,u)}}case"session/cancel":{let d=a.sessionId;if(!d)throw new T("IPC_BAD_REQUEST","session/cancel: missing sessionId");let u=e.sessions.get(d);if(e.hasSessionQueue(d)){let x=e.getSessionQueue(d);x.size>0&&(Y.info("session/cancel: draining queued tasks",{agentId:e.agentId,cloudId:d,queuedCount:x.size}),x.dispose(new T("AGENT_PROTOCOL_ERROR",`cancelled by session/cancel on ${d}`)))}return u?.downstream?.isAlive()&&u.acpSessionId&&await u.downstream.sessionCancel({sessionId:u.acpSessionId}),{ok:!0}}default:throw new T("IPC_BAD_REQUEST",`session method not supported: ${r}`)}}async ensureRuntime(e,r){let s=e.sessions.get(r);if(s)return s;let c={modelToken:e.deployType==="cloud"?await this.requestSessionToken(e.agentId,r):"",tokenGeneratedAt:Date.now(),lastActiveAt:Date.now(),loadingSession:!1,replySeq:0};return e.sessions.set(r,c),await this.persistSessionMapping(e),c}async requestSessionToken(e,r){let s={sessionId:r,_meta:{cozeAgentId:e}};try{let a=await this.sendRequest(St.GEN_MODEL_TOKEN,s,sy);if(!a?.modelToken)throw new T("MODEL_TOKEN_GEN_FAILED",`cloud returned empty modelToken (agentId=${e}, cloudSessionId=${r})`);return a.modelToken}catch(a){throw a instanceof T&&a.code==="MODEL_TOKEN_GEN_FAILED"?a:new T("MODEL_TOKEN_GEN_FAILED",a instanceof Error?a.message:String(a),{cause:a})}}async ensureDownstream(e,r,s){if(yi(s),s.downstream?.isAlive())return;if(!this.sessionSpawner)throw new T("AGENT_SPAWN_FAILED","sessionSpawner not wired (cannot spawn per-session downstream)");let a=3,c=3e4,d=s.spawnFailCount??0,u=s.spawnFailedAt??0;if(d>=a&&Date.now()-u<c)throw new T("AGENT_SPAWN_FAILED",`agent ${e.agentId} session ${r} spawn failed ${d} times in a row; please check framework binary / network and retry after ${Math.ceil((c-(Date.now()-u))/1e3)}s`);let x;try{x=await this.sessionSpawner(e,s.modelToken,r,this.currentCozeEnv,this.currentMockScenario)}catch(p){throw s.spawnFailCount=d+1,s.spawnFailedAt=Date.now(),s.spawnFailCount>=a&&s.acpSessionId&&(Y.warn("clearing stale acpSessionId after repeated spawn failures",{agentId:e.agentId,cloudId:r,staleAcpId:s.acpSessionId}),s.acpSessionId=void 0),p}if(s.spawnFailCount=0,s.spawnFailedAt=void 0,s.downstream=x,this.attachRuntimeHooks(e,r,s),s.acpSessionId){s.loadingSession=!0;try{await x.sessionLoad({sessionId:s.acpSessionId,cwd:e.workspace}),Y.info("session restored via session/load",{agentId:e.agentId,cloudId:r,acpId:s.acpSessionId})}catch(p){Y.warn("session/load failed, fallback to session/new",{agentId:e.agentId,cloudId:r,acpId:s.acpSessionId,err:String(p)}),s.acpSessionId=void 0;let _=await x.sessionNew({cwd:e.workspace});s.acpSessionId=_.sessionId,await this.persistSessionMapping(e)}finally{s.loadingSession=!1}}else{let p=await x.sessionNew({cwd:e.workspace});s.acpSessionId=p.sessionId,await this.persistSessionMapping(e)}x.afterSessionEstablished&&s.acpSessionId&&await x.afterSessionEstablished(s.acpSessionId)}armIdleTimer(e,r,s){if(yi(s),this.isRuntimeBusy(e,s)){Y.debug("skip idle timer: runtime busy (in-flight turn / pending permission)",{agentId:e.agentId,cloudId:r});return}s.idleTimer=setTimeout(()=>{if(s.idleTimer=void 0,this.isRuntimeBusy(e,s)){Y.info("idle reaper fired but runtime busy, re-arming",{agentId:e.agentId,cloudId:r}),this.armIdleTimer(e,r,s);return}Y.info("session runtime idle timeout, killing downstream",{agentId:e.agentId,cloudId:r});let a=s.downstream;s.downstream=void 0,s.acpSessionId&&e.activeTriggers.delete(s.acpSessionId),a&&a.stop("idle timeout").catch(c=>Y.warn("idle stop failed (ignored)",{agentId:e.agentId,cloudId:r,err:String(c)}))},this.sessionIdleTimeoutMs),s.idleTimer.unref?.()}isRuntimeBusy(e,r){if(r.acpSessionId&&e.activeTriggers.has(r.acpSessionId))return!0;let s=r.downstream;if(!s)return!1;for(let a of this.pendingUpstream.values())if(a.downstream===s)return!0;return!1}async sendAgentFileUpdate(e,r,s,a){let c={cozeAgentId:e.agentId,cozeReplySeqID:++r.replySeq};if(r.acpSessionId){let d=e.activeTriggers.get(r.acpSessionId);d&&(c.cozeTriggerMsgId=d);let u=e.activeGroupIds.get(r.acpSessionId);u&&(c.cozeGroupId=u)}await this.upstream.send(mi("session/update",{sessionId:s,update:a,_meta:c}))}forwardUpdate(e,r){let s=r.sessionId,a=this.reverseSessionId(e,s);if(!a){Y.debug("drop update for unknown session",{agentId:e.agentId,acpId:s});return}let c=e.sessions.get(a);if(!c){Y.debug("drop update: runtime gone",{agentId:e.agentId,cloudId:a});return}if(cy(r)){Y.debug("drop codex metadata-warn chunk",{agentId:e.agentId,acpId:s});return}let d={cozeAgentId:e.agentId,cozeReplySeqID:++c.replySeq},u=e.activeTriggers.get(s);u&&(d.cozeTriggerMsgId=u);let x=e.activeGroupIds.get(s);x&&(d.cozeGroupId=x),this.upstream.send(mi("session/update",{...r,sessionId:a,_meta:d})).catch(p=>Y.warn("forward update failed",{agentId:e.agentId,err:String(p)}))}handleAgentRequest(e,r,s){if(s.method==="session/request_permission"){this.forwardPermissionRequest(e,r,s);return}if(s.method==="fs/write_text_file"||s.method==="fs/read_text_file"){this.handleFsRpcRequest(e,r,s);return}Y.warn("unhandled agent request,returning method_not_found",{agentId:e.agentId,method:s.method}),r.respondAgentRequestError(s.id,{code:re.METHOD_NOT_FOUND,message:`method not handled by Bridge: ${s.method}`})}async handleFsRpcRequest(e,r,s){try{let a=e.workspace;if(s.method==="fs/write_text_file"){let c=s.params??{},d=await Zu(c,a);r.respondAgentRequest(s.id,d)}else{let c=s.params??{},d=await Xu(c,a);r.respondAgentRequest(s.id,d)}}catch(a){Y.warn("fs rpc handler failed",{agentId:e.agentId,method:s.method,err:String(a)}),r.respondAgentRequestError(s.id,_i(a))}}forwardPermissionRequest(e,r,s){let a=this.upstreamIds.next("session/request_permission"),c=s.params??{},u=c.sessionId,x=u?e.activeTriggers.get(u):void 0,p={cozeAgentId:e.agentId};x&&(p.cozeTriggerMsgId=x);let _=u?e.activeGroupIds.get(u):void 0;_&&(p.cozeGroupId=_);let w=u?this.reverseSessionId(e,u):void 0,S={...c,...w?{sessionId:w}:{},_meta:p};this.pendingUpstream.set(a,{agentRequestId:s.id,agentId:e.agentId,downstream:r,method:s.method}),Y.info("forward permission_request \u2192 upstream",{agentId:e.agentId,upstreamId:a,acpSessionId:u,cloudSessionId:w,toolCallId:c.toolCall?.toolCallId,options:c.options?.map(b=>({optionId:b.optionId,kind:b.kind,name:b.name}))}),this.upstream.send(gi(a,"session/request_permission",S)).catch(b=>{this.pendingUpstream.delete(a),Y.error("forward permission request failed",{agentId:e.agentId,err:String(b)}),r.respondAgentRequestError(s.id,{code:re.INTERNAL_ERROR,message:`upstream send failed: ${String(b)}`})})}handleUpstreamResponse(e){if(e.id===null)return;let r=this.lookupPending(this.pendingUpstream,e.id,"upstream");if(r){this.pendingUpstream.delete(r.key);let a=r.value;e.error?(Y.info("upstream \u2192 permission response (error)",{agentId:a.agentId,upstreamId:e.id,method:a.method,error:e.error}),a.downstream.respondAgentRequestError(a.agentRequestId,e.error)):(a.method==="session/request_permission"&&ay(e.result,a),Y.info("upstream \u2192 permission response (result)",{agentId:a.agentId,upstreamId:e.id,method:a.method,result:e.result}),a.downstream.respondAgentRequest(a.agentRequestId,e.result));return}let s=this.lookupPending(this.pendingBridge,e.id,"bridge");if(s){this.pendingBridge.delete(s.key),clearTimeout(s.value.timer),e.error?s.value.reject(new Hs(e.error)):s.value.resolve(e.result);return}Y.debug("orphan upstream response (no pending)",{id:e.id})}lookupPending(e,r,s){let a=e.get(r);if(a)return{value:a,key:r};if(typeof r=="number"){let c=String(r),d=e.get(c);if(d)return Y.warn(`${s} id type mismatch: number received but Bridge expected string`,{rawId:r,normalizedId:c}),{value:d,key:c}}}sendRequest(e,r,s=ry){let a=this.upstreamIds.next(e);return new Promise((c,d)=>{let u=setTimeout(()=>{this.pendingBridge.delete(a),d(new T("AGENT_TIMEOUT",`${e} timed out after ${s}ms`))},s);this.pendingBridge.set(a,{method:e,resolve:c,reject:d,timer:u}),this.upstream.send(gi(a,e,r)).catch(x=>{let p=this.pendingBridge.get(a);p&&(clearTimeout(p.timer),this.pendingBridge.delete(a)),d(x)})})}async persistSessionMapping(e){if(this.paths)try{let r=new Map;for(let[s,a]of e.sessions){let c={modelToken:a.modelToken,tokenGeneratedAt:a.tokenGeneratedAt};a.acpSessionId&&(c.acpSessionId=a.acpSessionId),r.set(s,c)}await Qo(e.agentId,r,this.paths)}catch(r){Y.warn("persist session mapping failed",{agentId:e.agentId,err:String(r)})}}reverseSessionId(e,r){for(let[s,a]of e.sessions.entries())if(a.acpSessionId===r)return s}sendError(e,r,s){return this.upstream.send(hn(e,{code:r,message:s,data:{bridgeVersion:mr}}))}};function oy(){return ny(16).toString("hex")}function ay(t,e){if(!t||typeof t!="object"){Y.warn("permission response: result not an object (suspicious)",{agentId:e.agentId,result:t});return}let r=t;if("kind"in r&&!("outcome"in r)){Y.warn('permission response: top-level "kind" field (D66 historical bug shape)',{agentId:e.agentId,result:t});return}let s=r.outcome;if(!s||typeof s!="object"){Y.warn("permission response: missing or non-object outcome field",{agentId:e.agentId,result:t});return}let c=s.outcome;(typeof c!="string"||c!=="selected"&&c!=="cancelled")&&Y.warn("permission response: unknown outcome discriminant",{agentId:e.agentId,outcomeValue:c,result:t})}function cy(t){let e=t.update;if(e?.sessionUpdate!=="agent_message_chunk")return!1;let r=e.content;if(!r||typeof r!="object")return!1;let s=r;return s.type!=="text"||typeof s.text!="string"?!1:s.text.startsWith("Model metadata for `")}ie();qe();import{randomBytes as fy}from"node:crypto";import{chmod as dy,mkdir as uy,writeFile as rl}from"node:fs/promises";import{createServer as ly}from"node:http";import{dirname as xy}from"node:path";var hy=1e6,Ac=$("ipc"),to=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??se()}async start(){this.token=fy(32).toString("hex");let e=ly((s,a)=>{this.dispatch(s,a)});this.server=e,await new Promise((s,a)=>{e.once("error",a),e.listen(0,"127.0.0.1",()=>s())});let r=e.address();if(!r||typeof r!="object")throw new Error("failed to obtain IPC port");return this.port=r.port,await this.persistAuthFiles(),Ac.info("IPC listening",{port:this.port}),{port:this.port,token:this.token}}async stop(){let e=this.server;e&&(await new Promise((r,s)=>{e.close(a=>a?s(a):r())}),this.server=null)}async persistAuthFiles(){await uy(xy(this.paths.portFile),{recursive:!0}),await rl(this.paths.portFile,String(this.port),"utf8"),await rl(this.paths.tokenFile,this.token,{encoding:"utf8",mode:384});try{await dy(this.paths.tokenFile,384)}catch(e){Ac.warn("chmod token file failed (non-POSIX?)",{err:String(e)})}}async dispatch(e,r){if(e.headers.authorization!==`Bearer ${this.token}`){vi(r,401,{error:"unauthorized"});return}let a=`${e.method} ${(e.url??"").split("?")[0]}`,c=this.routes.get(a);if(!c){vi(r,404,{error:"not found"});return}let d=null;if(e.method==="POST")try{d=await py(e)}catch(u){vi(r,400,{error:"invalid json",detail:String(u)});return}try{let u=await c.handler(d,e);vi(r,200,u??{ok:!0})}catch(u){Ac.error("IPC handler failed",{key:a,err:String(u)}),vi(r,500,{error:u instanceof Error?u.message:String(u)})}}};function vi(t,e,r){t.statusCode=e,t.setHeader("content-type","application/json"),t.end(JSON.stringify(r))}async function py(t){let e=[],r=0;for await(let a of t){let c=a;if(r+=c.length,r>hy)throw new Error("body too large");e.push(c)}let s=Buffer.concat(e).toString("utf8");return s?JSON.parse(s):null}var Cx=mt(hl(),1);var Jb=mt(fx(),1),Zb=mt(wo(),1),Xb=mt(Ir(),1),Yb=mt(Uc(),1),Qb=mt(jc(),1),eE=mt(Jc(),1),_x=mt(Eo(),1),tE=mt(mx(),1);var yx=_x.default;ie();var Re=$("upstream.frontier"),Ex="application/json",vx="none",rE=15e3,Li=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){Re.warn("start called on already-started FrontierUpstream; noop");return}let e={Authorization:`Bearer ${this.opts.privatecode}`,Origin:Qd,...pr(this.opts.ppeOverride)};class r extends yx{constructor(E){super(E,Yd,{headers:e})}send(E,...v){if(N0("debug"))try{let C;typeof E=="string"?C=Buffer.from(E,"utf8"):E instanceof Buffer?C=E:E instanceof ArrayBuffer?C=new Uint8Array(E):ArrayBuffer.isView(E)?C=new Uint8Array(E.buffer,E.byteOffset,E.byteLength):C=new Uint8Array(0);let D=Buffer.from(C.slice(0,128)).toString("hex");Re.debug("WS raw frame out",{bytes:C.byteLength,headHex:D})}catch(C){Re.warn("WS raw frame dump failed",{err:String(C)})}super.send(E,...v)}}let s=tu(this.opts.urlOverride),a={url:s,ws:r,fpID:Xd,aID:Fs,accessKey:this.opts.handshake.accessKey,deviceID:this.opts.handshake.deviceId,payloadType:{type:Ex,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 Cx.FWS(a),d=!1,u=null,x,p,_=new Promise((b,E)=>{x=b,p=E}),w=b=>{d||(d=!0,u&&(clearTimeout(u),u=null),b?p(b):x())};c.onopen=()=>{this.opened=!0,this.openCount+=1;let b=this.openCount===1;Re.info("frontier opened",{url:s,remoteDeviceId:this.opts.handshake.deviceId,initial:b,openCount:this.openCount}),b&&w();for(let E of this.connectHandlers)Promise.resolve(E({initial:b})).catch(v=>Re.warn("onConnect handler threw (ignored)",{err:String(v)}))},c.onclose=b=>{this.opened=!1,Re.info("frontier closed",{code:b.code,reason:b.reason,willReconnect:b.willReconnect})},c.onerror=b=>{Re.warn("frontier error",{code:b.code,msg:b.message}),w(new T("UPSTREAM_DISCONNECTED",`frontier connect error before open: code=${b.code} msg=${b.message??""}`))},c.onmessage=b=>this.handleMessage(b),this.fws=c;let S=this.opts.openTimeoutMs??rE;u=setTimeout(()=>{w(new T("UPSTREAM_DISCONNECTED",`frontier ws open timeout after ${S}ms (handshake or upgrade slow)`))},S),await c.connect();try{await _}catch(b){try{c.close(1e3,"open failed")}catch(E){Re.warn("fws close during start failure threw (ignored)",{err:String(E)})}throw this.fws=null,this.opened=!1,b}}async stop(e){let r=this.fws;if(r){this.fws=null,this.opened=!1;try{r.close(1e3,e??"bridge shutdown")}catch(s){Re.warn("frontier close threw (ignored)",{err:String(s)})}}}async send(e){let r=this.fws,s=e.method;if(!r)throw Re.warn("frontier send refused: upstream not started",{method:s}),new T("UPSTREAM_DISCONNECTED","frontier upstream not started");if(!this.isConnected()){let u=Date.now();throw u-this.lastSendRefusedLogAt>1e3?(Re.warn("frontier send refused: ws not open",{method:s,opened:this.opened,readyState:r.readyState,...this.sendRefusedSuppressed>0?{suppressedSinceLast:this.sendRefusedSuppressed}:{}}),this.lastSendRefusedLogAt=u,this.sendRefusedSuppressed=0):this.sendRefusedSuppressed+=1,new T("UPSTREAM_DISCONNECTED",`frontier ws not open (opened=${this.opened}, readyState=${r.readyState}); refusing to silently buffer`)}this.injectAgentPatToken(e);let a=JSON.stringify(e),c=e;Sx(c)||Re.info("frontier frame out",{method:c.method,jsonrpcId:c.id,size:a.length});try{await r.send(a,{service:33555712,method:1,payloadType:Ex,payloadEncoding:vx})}catch(u){throw Re.warn("frontier frame send failed",{method:c.method,jsonrpcId:c.id,err:String(u)}),new T("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 s=e.params?._meta;if(!s?.cozeAgentId)return;let a=r(s.cozeAgentId);a&&(s.cozePatToken=a)}handleMessage(e){let r=e.message?.service;if(r!==33555712){Re.debug("drop non-adapter frontier frame",{service:r});return}let s=oE(e);if(!s){Re.debug("frontier message without text payload, drop",{payloadType:e.message?.payloadType});return}if(!this.handler){Re.debug("frame received but no onFrame handler",{size:s.length});return}let a;try{a=JSON.parse(s)}catch(d){Re.warn("frontier message JSON parse failed",{err:String(d),head:s.slice(0,80)});return}let c=a;Sx(c)||Re.info("frontier frame in",{logid:sE(e.message?.LogID),logidNew:e.message?.LogIDNew,msgId:e.message?.msgID,jsonrpcId:c.id,method:c.method,body:iE(s)}),Promise.resolve(this.handler(a)).catch(d=>Re.warn("frontier frame handler threw",{err:String(d)}))}};function Sx(t){return t.method==="_agent/health"?!0:typeof t.id=="string"&&t.id.startsWith("agent.health_")}var Ix=2e3;function iE(t){return t.length<=Ix?t:`${t.slice(0,Ix)}...<truncated, total ${t.length} chars>`}function sE(t){return t?t.high===0?String(t.low>>>0):`${t.high.toString(16)}${(t.low>>>0).toString(16).padStart(8,"0")}`:""}function oE(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}}ie();var Xc=$("upstream.switchable"),So=class{inner;handler=null;connectHandlers=[];constructor(e){this.inner=e}async swap(e,r){if(this.inner===e)return;Xc.info("swap upstream",{reason:r});let s=this.inner;if(this.inner=e,this.handler&&e.onFrame(this.handler),e.onConnect)for(let a of this.connectHandlers)e.onConnect(a);try{await e.start()}catch(a){throw Xc.error("swap target start failed, reverting",{err:String(a)}),this.inner=s,a}await s.stop(r??"swapped").catch(a=>Xc.warn("previous upstream stop threw (ignored)",{err:String(a)}))}current(){return this.inner}start(){return this.inner.start()}stop(e){return this.inner.stop(e)}send(e){return this.inner.send(e)}onFrame(e){this.handler=e,this.inner.onFrame(e)}onConnect(e){this.connectHandlers.push(e),this.inner.onConnect?.(e)}isConnected(){return this.inner.isConnected()}};ie();var Yc=$("upstream"),kr=class{handler=null;async start(){Yc.info("NoopUpstream started (M1 skeleton; real Frontier wired in M4)")}async stop(e){Yc.info("NoopUpstream stopped",{reason:e})}async send(e){Yc.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)}};ie();ie();qe();import{promises as Qc}from"node:fs";import{dirname as aE}from"node:path";var cE=$("pat-token-store");async function Ax(t=se()){try{let r=(await Qc.readFile(t.patTokenFile,"utf8")).trim();return r.length>0?r:null}catch(e){let r=e?.code;return r!=="ENOENT"&&cE.warn("read pat-token failed (treating as missing)",{path:t.patTokenFile,code:r,message:e.message}),null}}async function Oi(t,e=se()){if(!t)throw new Error("writePatToken: empty patToken");await Qc.mkdir(aE(e.patTokenFile),{recursive:!0}),await Qc.writeFile(e.patTokenFile,t,{encoding:"utf8",mode:384})}qe();qe();import{promises as Io}from"node:fs";import{join as fE}from"node:path";function dE(t,e){return`#!/bin/sh
|
|
80
|
+
`},configPath(t){return Zb(t.homeDir,".coze","bridge","task.xml")},async install(t){let r=`cmd.exe /c ${[`^"${t.nodeBin}^"`,`^"${t.entry}^"`,"--daemon",`>> ^"${t.logFile}^" 2>&1`].join(" ")}`;await qx("schtasks",["/Create","/SC","ONLOGON","/TN",Oo,"/TR",r,"/RU",t.userName,"/F"]),o0.info("task scheduler entry created",{task:Oo,logFile:t.logFile})},async uninstall(t){await qx("schtasks",["/Delete","/TN",Oo,"/F"]).catch(e=>o0.warn("schtasks /Delete failed (ignored)",{err:String(e)})),o0.info("task scheduler entry removed",{task:Oo})}}});var jx={};Ko(jx,{buildContext:()=>e2,getSupervisor:()=>Qb,launchdSupervisor:()=>i0,systemdSupervisor:()=>s0,taskSchedulerSupervisor:()=>a0});import{homedir as Yb,userInfo as Xb}from"node:os";function Qb(t=process.platform){switch(t){case"darwin":return i0;case"linux":return s0;case"win32":return a0;default:throw new Error(`unsupported platform for OS supervisor: ${t}`)}}function e2(){let t=te();return{nodeBin:process.execPath,entry:Yc(t),logFile:t.logFile,homeDir:Yb(),userName:Xb().username}}var Gx=dt(()=>{"use strict";Me();Qc();Fx();Ux();Hx()});ee();Zt();var q0=H("acp-installer-warmup"),_p=["claude-code","codex"];async function H0(t={}){let e=t.ensure??yn,s=(await Promise.allSettled(_p.map(async a=>{let c=await e(a);q0.info("acp wrapper warmup ok",{framework:a,installed:!!c,path:c??""})}))).filter(a=>a.status==="rejected");s.length>0&&q0.warn("acp wrapper warmup partial failure (acp-installer negative cache 5min \u5185\u4E0D\u91CD\u8BD5)",{failedCount:s.length,reasons:s.map(a=>String(a.reason))})}Yt();ee();import{readdir as Rp}from"node:fs/promises";import{mkdir as V0,writeFile as J0}from"node:fs/promises";import{join as Yo}from"node:path";var Dp={"claude-code":"CLAUDE.md",codex:"AGENTS.md",openclaw:"SOUL.md"};async function Zn(t,e,r){await V0(t,{recursive:!0});let s=Dp[e],a=Yo(t,s);return await J0(a,r??"","utf8"),a}async function Z0(t){let e=Yo(t,".claude");await V0(e,{recursive:!0});let r=Yo(e,"settings.local.json"),s=JSON.stringify({permissions:{defaultMode:"bypassPermissions"}},null,2);return await J0(r,s,"utf8"),r}var Je=H("agent-detail-sync"),kp=6e4,Op=5*6e4,Gi=class{constructor(e){this.opts=e}opts;retryQueue=new Map;async syncAll(e){let r=this.opts.paths.agentsRoot,s;try{s=await Rp(r)}catch(a){Je.info("agents dir not found, skip detail sync",{root:r,err:String(a)});return}Je.info("starting detail sync",{reason:e,count:s.length}),await Promise.allSettled(s.map(async a=>{let c=await Ue(a,this.opts.paths).catch(()=>null);if(c){if(c.disconnectedAt){Je.debug("detail sync: skip disconnected agent",{agentId:a});return}try{await this.syncOne(a,c)}catch(f){Je.warn("detail sync failed for agent, skipping",{agentId:a,err:String(f)})}}})),Je.info("detail sync done",{reason:e})}async retryPending(){if(this.retryQueue.size===0)return;let e=Date.now(),r=[];for(let[s,a]of this.retryQueue)e>=a.dueAt&&r.push(s);if(r.length!==0){Je.info("retrying pending detail syncs",{count:r.length});for(let s of r)try{await this.syncOne(s)}catch(a){Je.debug("detail sync retry still failing, will try again",{agentId:s,err:String(a)})}}}async syncOne(e,r){let s=r??await Ue(e,this.opts.paths);if(!s){Je.info("detail sync: agent config missing, skip",{agentId:e});return}let a;try{a=await this.opts.sendDetail({_meta:{cozeAgentId:e}}),this.retryQueue.delete(e)}catch(l){Je.warn("detail RPC failed, using local data",{agentId:e,err:String(l)});let x=this.retryQueue.get(e),h=x?Math.min(x.currentDelay*2,Op):kp;this.retryQueue.set(e,{dueAt:Date.now()+h,currentDelay:h});return}if(a.agentId&&a.agentId!==e){Je.warn("detail response agentId mismatch, ignoring",{agentId:e,responseAgentId:a.agentId});return}let c=!1,f=!1;if(a.agentName&&a.agentName!==s.agentName&&(s.agentName=a.agentName,c=!0),a.description!==void 0&&a.description!==s.description&&(s.description=a.description,c=!0),a.cozeIdentity&&a.cozeIdentity!==s.cozeIdentity&&(s.cozeIdentity=a.cozeIdentity,c=!0,f=!0),a.deployType&&Je.info("detail.deployType",{agentId:e,deployType:a.deployType}),!c){Je.debug("detail sync: no diff",{agentId:e});return}await Ve(s,this.opts.paths),Je.info("detail sync: config updated",{agentId:e,identityChanged:f,agentName:s.agentName}),f&&(await Zn(s.workspace,s.framework,s.cozeIdentity),this.opts.handlers.reloadAgentSessionsPublic(e,"detail-sync"))}};var xl=gt(Dd(),1);import{lstat as fc,mkdir as lc,readFile as dl,readdir as iw,rm as sw,stat as ow,writeFile as uc}from"node:fs/promises";import{dirname as aw,join as It,normalize as cw,relative as pc,resolve as xc,sep as fl}from"node:path";import{Readable as ll}from"node:stream";import{pipeline as ul}from"node:stream/promises";import eg from"events";import We from"fs";import{EventEmitter as Za}from"node:events";import lf from"node:stream";import{StringDecoder as tg}from"node:string_decoder";import hf from"node:path";import cr from"node:fs";import{dirname as hg,parse as pg}from"path";import{EventEmitter as Sg}from"events";import ka from"assert";import{Buffer as kn}from"buffer";import*as Ld from"zlib";import vg from"zlib";import{posix as tr}from"node:path";import{basename as Yg}from"node:path";import bs from"fs";import yt from"fs";import qd from"path";import{win32 as cm}from"node:path";import Vd from"path";import Df from"node:fs";import Im from"node:assert";import{randomBytes as Rf}from"node:crypto";import X from"node:fs";import Se from"node:path";import kf from"fs";import ks from"node:fs";import ei from"node:path";import Xe from"node:fs";import Om from"node:fs/promises";import Is from"node:path";import{join as Hf}from"node:path";import Ye from"node:fs";import Kf from"node:path";var Xp=Object.defineProperty,Qp=(t,e)=>{for(var r in e)Xp(t,r,{get:e[r],enumerable:!0})},Rd=typeof process=="object"&&process?process:{stdout:null,stderr:null},ng=t=>!!t&&typeof t=="object"&&(t instanceof Ln||t instanceof lf||rg(t)||ig(t)),rg=t=>!!t&&typeof t=="object"&&t instanceof Za&&typeof t.pipe=="function"&&t.pipe!==lf.Writable.prototype.pipe,ig=t=>!!t&&typeof t=="object"&&t instanceof Za&&typeof t.write=="function"&&typeof t.end=="function",Ot=Symbol("EOF"),Pt=Symbol("maybeEmitEnd"),Qt=Symbol("emittedEnd"),Ji=Symbol("emittingEnd"),Br=Symbol("emittedError"),Zi=Symbol("closed"),kd=Symbol("read"),Yi=Symbol("flush"),Od=Symbol("flushChunk"),ft=Symbol("encoding"),er=Symbol("decoder"),Ce=Symbol("flowing"),zr=Symbol("paused"),sr=Symbol("resume"),Te=Symbol("buffer"),Ge=Symbol("pipes"),De=Symbol("bufferLength"),ra=Symbol("bufferPush"),Xi=Symbol("bufferShift"),qe=Symbol("objectMode"),me=Symbol("destroyed"),ia=Symbol("error"),sa=Symbol("emitData"),Pd=Symbol("emitEnd"),oa=Symbol("emitEnd2"),mt=Symbol("async"),aa=Symbol("abort"),Qi=Symbol("aborted"),Fr=Symbol("signal"),bn=Symbol("dataListeners"),Ze=Symbol("discarded"),Ur=t=>Promise.resolve().then(t),sg=t=>t(),og=t=>t==="end"||t==="finish"||t==="prefinish",ag=t=>t instanceof ArrayBuffer||!!t&&typeof t=="object"&&t.constructor&&t.constructor.name==="ArrayBuffer"&&t.byteLength>=0,cg=t=>!Buffer.isBuffer(t)&&ArrayBuffer.isView(t),uf=class{src;dest;opts;ondrain;constructor(t,e,r){this.src=t,this.dest=e,this.opts=r,this.ondrain=()=>t[sr](),this.dest.on("drain",this.ondrain)}unpipe(){this.dest.removeListener("drain",this.ondrain)}proxyErrors(t){}end(){this.unpipe(),this.opts.end&&this.dest.end()}},dg=class extends uf{unpipe(){this.src.removeListener("error",this.proxyErrors),super.unpipe()}constructor(t,e,r){super(t,e,r),this.proxyErrors=s=>this.dest.emit("error",s),t.on("error",this.proxyErrors)}},fg=t=>!!t.objectMode,lg=t=>!t.objectMode&&!!t.encoding&&t.encoding!=="buffer",Ln=class extends Za{[Ce]=!1;[zr]=!1;[Ge]=[];[Te]=[];[qe];[ft];[mt];[er];[Ot]=!1;[Qt]=!1;[Ji]=!1;[Zi]=!1;[Br]=null;[De]=0;[me]=!1;[Fr];[Qi]=!1;[bn]=0;[Ze]=!1;writable=!0;readable=!0;constructor(...t){let e=t[0]||{};if(super(),e.objectMode&&typeof e.encoding=="string")throw new TypeError("Encoding and objectMode may not be used together");fg(e)?(this[qe]=!0,this[ft]=null):lg(e)?(this[ft]=e.encoding,this[qe]=!1):(this[qe]=!1,this[ft]=null),this[mt]=!!e.async,this[er]=this[ft]?new tg(this[ft]):null,e&&e.debugExposeBuffer===!0&&Object.defineProperty(this,"buffer",{get:()=>this[Te]}),e&&e.debugExposePipes===!0&&Object.defineProperty(this,"pipes",{get:()=>this[Ge]});let{signal:r}=e;r&&(this[Fr]=r,r.aborted?this[aa]():r.addEventListener("abort",()=>this[aa]()))}get bufferLength(){return this[De]}get encoding(){return this[ft]}set encoding(t){throw new Error("Encoding must be set at instantiation time")}setEncoding(t){throw new Error("Encoding must be set at instantiation time")}get objectMode(){return this[qe]}set objectMode(t){throw new Error("objectMode must be set at instantiation time")}get async(){return this[mt]}set async(t){this[mt]=this[mt]||!!t}[aa](){this[Qi]=!0,this.emit("abort",this[Fr]?.reason),this.destroy(this[Fr]?.reason)}get aborted(){return this[Qi]}set aborted(t){}write(t,e,r){if(this[Qi])return!1;if(this[Ot])throw new Error("write after end");if(this[me])return this.emit("error",Object.assign(new Error("Cannot call write after a stream was destroyed"),{code:"ERR_STREAM_DESTROYED"})),!0;typeof e=="function"&&(r=e,e="utf8"),e||(e="utf8");let s=this[mt]?Ur:sg;if(!this[qe]&&!Buffer.isBuffer(t)){if(cg(t))t=Buffer.from(t.buffer,t.byteOffset,t.byteLength);else if(ag(t))t=Buffer.from(t);else if(typeof t!="string")throw new Error("Non-contiguous data written to non-objectMode stream")}return this[qe]?(this[Ce]&&this[De]!==0&&this[Yi](!0),this[Ce]?this.emit("data",t):this[ra](t),this[De]!==0&&this.emit("readable"),r&&s(r),this[Ce]):t.length?(typeof t=="string"&&!(e===this[ft]&&!this[er]?.lastNeed)&&(t=Buffer.from(t,e)),Buffer.isBuffer(t)&&this[ft]&&(t=this[er].write(t)),this[Ce]&&this[De]!==0&&this[Yi](!0),this[Ce]?this.emit("data",t):this[ra](t),this[De]!==0&&this.emit("readable"),r&&s(r),this[Ce]):(this[De]!==0&&this.emit("readable"),r&&s(r),this[Ce])}read(t){if(this[me])return null;if(this[Ze]=!1,this[De]===0||t===0||t&&t>this[De])return this[Pt](),null;this[qe]&&(t=null),this[Te].length>1&&!this[qe]&&(this[Te]=[this[ft]?this[Te].join(""):Buffer.concat(this[Te],this[De])]);let e=this[kd](t||null,this[Te][0]);return this[Pt](),e}[kd](t,e){if(this[qe])this[Xi]();else{let r=e;t===r.length||t===null?this[Xi]():typeof r=="string"?(this[Te][0]=r.slice(t),e=r.slice(0,t),this[De]-=t):(this[Te][0]=r.subarray(t),e=r.subarray(0,t),this[De]-=t)}return this.emit("data",e),!this[Te].length&&!this[Ot]&&this.emit("drain"),e}end(t,e,r){return typeof t=="function"&&(r=t,t=void 0),typeof e=="function"&&(r=e,e="utf8"),t!==void 0&&this.write(t,e),r&&this.once("end",r),this[Ot]=!0,this.writable=!1,(this[Ce]||!this[zr])&&this[Pt](),this}[sr](){this[me]||(!this[bn]&&!this[Ge].length&&(this[Ze]=!0),this[zr]=!1,this[Ce]=!0,this.emit("resume"),this[Te].length?this[Yi]():this[Ot]?this[Pt]():this.emit("drain"))}resume(){return this[sr]()}pause(){this[Ce]=!1,this[zr]=!0,this[Ze]=!1}get destroyed(){return this[me]}get flowing(){return this[Ce]}get paused(){return this[zr]}[ra](t){this[qe]?this[De]+=1:this[De]+=t.length,this[Te].push(t)}[Xi](){return this[qe]?this[De]-=1:this[De]-=this[Te][0].length,this[Te].shift()}[Yi](t=!1){do;while(this[Od](this[Xi]())&&this[Te].length);!t&&!this[Te].length&&!this[Ot]&&this.emit("drain")}[Od](t){return this.emit("data",t),this[Ce]}pipe(t,e){if(this[me])return t;this[Ze]=!1;let r=this[Qt];return e=e||{},t===Rd.stdout||t===Rd.stderr?e.end=!1:e.end=e.end!==!1,e.proxyErrors=!!e.proxyErrors,r?e.end&&t.end():(this[Ge].push(e.proxyErrors?new dg(this,t,e):new uf(this,t,e)),this[mt]?Ur(()=>this[sr]()):this[sr]()),t}unpipe(t){let e=this[Ge].find(r=>r.dest===t);e&&(this[Ge].length===1?(this[Ce]&&this[bn]===0&&(this[Ce]=!1),this[Ge]=[]):this[Ge].splice(this[Ge].indexOf(e),1),e.unpipe())}addListener(t,e){return this.on(t,e)}on(t,e){let r=super.on(t,e);if(t==="data")this[Ze]=!1,this[bn]++,!this[Ge].length&&!this[Ce]&&this[sr]();else if(t==="readable"&&this[De]!==0)super.emit("readable");else if(og(t)&&this[Qt])super.emit(t),this.removeAllListeners(t);else if(t==="error"&&this[Br]){let s=e;this[mt]?Ur(()=>s.call(this,this[Br])):s.call(this,this[Br])}return r}removeListener(t,e){return this.off(t,e)}off(t,e){let r=super.off(t,e);return t==="data"&&(this[bn]=this.listeners("data").length,this[bn]===0&&!this[Ze]&&!this[Ge].length&&(this[Ce]=!1)),r}removeAllListeners(t){let e=super.removeAllListeners(t);return(t==="data"||t===void 0)&&(this[bn]=0,!this[Ze]&&!this[Ge].length&&(this[Ce]=!1)),e}get emittedEnd(){return this[Qt]}[Pt](){!this[Ji]&&!this[Qt]&&!this[me]&&this[Te].length===0&&this[Ot]&&(this[Ji]=!0,this.emit("end"),this.emit("prefinish"),this.emit("finish"),this[Zi]&&this.emit("close"),this[Ji]=!1)}emit(t,...e){let r=e[0];if(t!=="error"&&t!=="close"&&t!==me&&this[me])return!1;if(t==="data")return!this[qe]&&!r?!1:this[mt]?(Ur(()=>this[sa](r)),!0):this[sa](r);if(t==="end")return this[Pd]();if(t==="close"){if(this[Zi]=!0,!this[Qt]&&!this[me])return!1;let a=super.emit("close");return this.removeAllListeners("close"),a}else if(t==="error"){this[Br]=r,super.emit(ia,r);let a=!this[Fr]||this.listeners("error").length?super.emit("error",r):!1;return this[Pt](),a}else if(t==="resume"){let a=super.emit("resume");return this[Pt](),a}else if(t==="finish"||t==="prefinish"){let a=super.emit(t);return this.removeAllListeners(t),a}let s=super.emit(t,...e);return this[Pt](),s}[sa](t){for(let r of this[Ge])r.dest.write(t)===!1&&this.pause();let e=this[Ze]?!1:super.emit("data",t);return this[Pt](),e}[Pd](){return this[Qt]?!1:(this[Qt]=!0,this.readable=!1,this[mt]?(Ur(()=>this[oa]()),!0):this[oa]())}[oa](){if(this[er]){let e=this[er].end();if(e){for(let r of this[Ge])r.dest.write(e);this[Ze]||super.emit("data",e)}}for(let e of this[Ge])e.end();let t=super.emit("end");return this.removeAllListeners("end"),t}async collect(){let t=Object.assign([],{dataLength:0});this[qe]||(t.dataLength=0);let e=this.promise();return this.on("data",r=>{t.push(r),this[qe]||(t.dataLength+=r.length)}),await e,t}async concat(){if(this[qe])throw new Error("cannot concat in objectMode");let t=await this.collect();return this[ft]?t.join(""):Buffer.concat(t,t.dataLength)}async promise(){return new Promise((t,e)=>{this.on(me,()=>e(new Error("stream destroyed"))),this.on("error",r=>e(r)),this.on("end",()=>t())})}[Symbol.asyncIterator](){this[Ze]=!1;let t=!1,e=async()=>(this.pause(),t=!0,{value:void 0,done:!0});return{next:()=>{if(t)return e();let r=this.read();if(r!==null)return Promise.resolve({done:!1,value:r});if(this[Ot])return e();let s,a,c=h=>{this.off("data",f),this.off("end",l),this.off(me,x),e(),a(h)},f=h=>{this.off("error",c),this.off("end",l),this.off(me,x),this.pause(),s({value:h,done:!!this[Ot]})},l=()=>{this.off("error",c),this.off("data",f),this.off(me,x),e(),s({done:!0,value:void 0})},x=()=>c(new Error("stream destroyed"));return new Promise((h,m)=>{a=m,s=h,this.once(me,x),this.once("error",c),this.once("end",l),this.once("data",f)})},throw:e,return:e,[Symbol.asyncIterator](){return this},[Symbol.asyncDispose]:async()=>{}}}[Symbol.iterator](){this[Ze]=!1;let t=!1,e=()=>(this.pause(),this.off(ia,e),this.off(me,e),this.off("end",e),t=!0,{done:!0,value:void 0}),r=()=>{if(t)return e();let s=this.read();return s===null?e():{done:!1,value:s}};return this.once("end",e),this.once(ia,e),this.once(me,e),{next:r,throw:e,return:e,[Symbol.iterator](){return this},[Symbol.dispose]:()=>{}}}destroy(t){if(this[me])return t?this.emit("error",t):this.emit(me),this;this[me]=!0,this[Ze]=!0,this[Te].length=0,this[De]=0;let e=this;return typeof e.close=="function"&&!this[Zi]&&e.close(),t?this.emit("error",t):this.emit(me),this}static get isStream(){return ng}},ug=We.writev,fn=Symbol("_autoClose"),ht=Symbol("_close"),qr=Symbol("_ended"),ie=Symbol("_fd"),ca=Symbol("_finished"),Bt=Symbol("_flags"),da=Symbol("_flush"),Da=Symbol("_handleChunk"),Ra=Symbol("_makeBuf"),Xr=Symbol("_mode"),es=Symbol("_needDrain"),fr=Symbol("_onerror"),lr=Symbol("_onopen"),fa=Symbol("_onread"),or=Symbol("_onwrite"),ln=Symbol("_open"),xt=Symbol("_path"),sn=Symbol("_pos"),wt=Symbol("_queue"),ar=Symbol("_read"),la=Symbol("_readSize"),Mt=Symbol("_reading"),Hr=Symbol("_remain"),ua=Symbol("_size"),fs=Symbol("_write"),Sn=Symbol("_writing"),ls=Symbol("_defaultFlag"),Rn=Symbol("_errored"),Ya=class extends Ln{[Rn]=!1;[ie];[xt];[la];[Mt]=!1;[ua];[Hr];[fn];constructor(t,e){if(e=e||{},super(e),this.readable=!0,this.writable=!1,typeof t!="string")throw new TypeError("path must be a string");this[Rn]=!1,this[ie]=typeof e.fd=="number"?e.fd:void 0,this[xt]=t,this[la]=e.readSize||16*1024*1024,this[Mt]=!1,this[ua]=typeof e.size=="number"?e.size:1/0,this[Hr]=this[ua],this[fn]=typeof e.autoClose=="boolean"?e.autoClose:!0,typeof this[ie]=="number"?this[ar]():this[ln]()}get fd(){return this[ie]}get path(){return this[xt]}write(){throw new TypeError("this is a readable stream")}end(){throw new TypeError("this is a readable stream")}[ln](){We.open(this[xt],"r",(t,e)=>this[lr](t,e))}[lr](t,e){t?this[fr](t):(this[ie]=e,this.emit("open",e),this[ar]())}[Ra](){return Buffer.allocUnsafe(Math.min(this[la],this[Hr]))}[ar](){if(!this[Mt]){this[Mt]=!0;let t=this[Ra]();if(t.length===0)return process.nextTick(()=>this[fa](null,0,t));We.read(this[ie],t,0,t.length,null,(e,r,s)=>this[fa](e,r,s))}}[fa](t,e,r){this[Mt]=!1,t?this[fr](t):this[Da](e,r)&&this[ar]()}[ht](){if(this[fn]&&typeof this[ie]=="number"){let t=this[ie];this[ie]=void 0,We.close(t,e=>e?this.emit("error",e):this.emit("close"))}}[fr](t){this[Mt]=!0,this[ht](),this.emit("error",t)}[Da](t,e){let r=!1;return this[Hr]-=t,t>0&&(r=super.write(t<e.length?e.subarray(0,t):e)),(t===0||this[Hr]<=0)&&(r=!1,this[ht](),super.end()),r}emit(t,...e){switch(t){case"prefinish":case"finish":return!1;case"drain":return typeof this[ie]=="number"&&this[ar](),!1;case"error":return this[Rn]?!1:(this[Rn]=!0,super.emit(t,...e));default:return super.emit(t,...e)}}},xg=class extends Ya{[ln](){let t=!0;try{this[lr](null,We.openSync(this[xt],"r")),t=!1}finally{t&&this[ht]()}}[ar](){let t=!0;try{if(!this[Mt]){this[Mt]=!0;do{let e=this[Ra](),r=e.length===0?0:We.readSync(this[ie],e,0,e.length,null);if(!this[Da](r,e))break}while(!0);this[Mt]=!1}t=!1}finally{t&&this[ht]()}}[ht](){if(this[fn]&&typeof this[ie]=="number"){let t=this[ie];this[ie]=void 0,We.closeSync(t),this.emit("close")}}},As=class extends eg{readable=!1;writable=!0;[Rn]=!1;[Sn]=!1;[qr]=!1;[wt]=[];[es]=!1;[xt];[Xr];[fn];[ie];[ls];[Bt];[ca]=!1;[sn];constructor(t,e){e=e||{},super(e),this[xt]=t,this[ie]=typeof e.fd=="number"?e.fd:void 0,this[Xr]=e.mode===void 0?438:e.mode,this[sn]=typeof e.start=="number"?e.start:void 0,this[fn]=typeof e.autoClose=="boolean"?e.autoClose:!0;let r=this[sn]!==void 0?"r+":"w";this[ls]=e.flags===void 0,this[Bt]=e.flags===void 0?r:e.flags,this[ie]===void 0&&this[ln]()}emit(t,...e){if(t==="error"){if(this[Rn])return!1;this[Rn]=!0}return super.emit(t,...e)}get fd(){return this[ie]}get path(){return this[xt]}[fr](t){this[ht](),this[Sn]=!0,this.emit("error",t)}[ln](){We.open(this[xt],this[Bt],this[Xr],(t,e)=>this[lr](t,e))}[lr](t,e){this[ls]&&this[Bt]==="r+"&&t&&t.code==="ENOENT"?(this[Bt]="w",this[ln]()):t?this[fr](t):(this[ie]=e,this.emit("open",e),this[Sn]||this[da]())}end(t,e){return t&&this.write(t,e),this[qr]=!0,!this[Sn]&&!this[wt].length&&typeof this[ie]=="number"&&this[or](null,0),this}write(t,e){return typeof t=="string"&&(t=Buffer.from(t,e)),this[qr]?(this.emit("error",new Error("write() after end()")),!1):this[ie]===void 0||this[Sn]||this[wt].length?(this[wt].push(t),this[es]=!0,!1):(this[Sn]=!0,this[fs](t),!0)}[fs](t){We.write(this[ie],t,0,t.length,this[sn],(e,r)=>this[or](e,r))}[or](t,e){t?this[fr](t):(this[sn]!==void 0&&typeof e=="number"&&(this[sn]+=e),this[wt].length?this[da]():(this[Sn]=!1,this[qr]&&!this[ca]?(this[ca]=!0,this[ht](),this.emit("finish")):this[es]&&(this[es]=!1,this.emit("drain"))))}[da](){if(this[wt].length===0)this[qr]&&this[or](null,0);else if(this[wt].length===1)this[fs](this[wt].pop());else{let t=this[wt];this[wt]=[],ug(this[ie],t,this[sn],(e,r)=>this[or](e,r))}}[ht](){if(this[fn]&&typeof this[ie]=="number"){let t=this[ie];this[ie]=void 0,We.close(t,e=>e?this.emit("error",e):this.emit("close"))}}},xf=class extends As{[ln](){let t;if(this[ls]&&this[Bt]==="r+")try{t=We.openSync(this[xt],this[Bt],this[Xr])}catch(e){if(e?.code==="ENOENT")return this[Bt]="w",this[ln]();throw e}else t=We.openSync(this[xt],this[Bt],this[Xr]);this[lr](null,t)}[ht](){if(this[fn]&&typeof this[ie]=="number"){let t=this[ie];this[ie]=void 0,We.closeSync(t),this.emit("close")}}[fs](t){let e=!0;try{this[or](null,We.writeSync(this[ie],t,0,t.length,this[sn])),e=!1}finally{if(e)try{this[ht]()}catch{}}}},gg=new Map([["C","cwd"],["f","file"],["z","gzip"],["P","preservePaths"],["U","unlink"],["strip-components","strip"],["stripComponents","strip"],["keep-newer","newer"],["keepNewer","newer"],["keep-newer-files","newer"],["keepNewerFiles","newer"],["k","keep"],["keep-existing","keep"],["keepExisting","keep"],["m","noMtime"],["no-mtime","noMtime"],["p","preserveOwner"],["L","follow"],["h","follow"],["onentry","onReadEntry"]]),mg=t=>!!t.sync&&!!t.file,wg=t=>!t.sync&&!!t.file,_g=t=>!!t.sync&&!t.file,yg=t=>!t.sync&&!t.file,Eg=t=>!!t.file,bg=t=>gg.get(t)||t,Xa=(t={})=>{if(!t)return{};let e={};for(let[r,s]of Object.entries(t)){let a=bg(r);e[a]=s}return e.chmod===void 0&&e.noChmod===!1&&(e.chmod=!0),delete e.noChmod,e},ai=(t,e,r,s,a)=>Object.assign((c=[],f,l)=>{Array.isArray(c)&&(f=c,c={}),typeof f=="function"&&(l=f,f=void 0),f=f?Array.from(f):[];let x=Xa(c);if(a?.(x,f),mg(x)){if(typeof l=="function")throw new TypeError("callback not supported for sync tar functions");return t(x,f)}else if(wg(x)){let h=e(x,f);return l?h.then(()=>l(),l):h}else if(_g(x)){if(typeof l=="function")throw new TypeError("callback not supported for sync tar functions");return r(x,f)}else if(yg(x)){if(typeof l=="function")throw new TypeError("callback only supported with file option");return s(x,f)}throw new Error("impossible options??")},{syncFile:t,asyncFile:e,syncNoFile:r,asyncNoFile:s,validate:a}),Ig=vg.constants||{ZLIB_VERNUM:4736},bt=Object.freeze(Object.assign(Object.create(null),{Z_NO_FLUSH:0,Z_PARTIAL_FLUSH:1,Z_SYNC_FLUSH:2,Z_FULL_FLUSH:3,Z_FINISH:4,Z_BLOCK:5,Z_OK:0,Z_STREAM_END:1,Z_NEED_DICT:2,Z_ERRNO:-1,Z_STREAM_ERROR:-2,Z_DATA_ERROR:-3,Z_MEM_ERROR:-4,Z_BUF_ERROR:-5,Z_VERSION_ERROR:-6,Z_NO_COMPRESSION:0,Z_BEST_SPEED:1,Z_BEST_COMPRESSION:9,Z_DEFAULT_COMPRESSION:-1,Z_FILTERED:1,Z_HUFFMAN_ONLY:2,Z_RLE:3,Z_FIXED:4,Z_DEFAULT_STRATEGY:0,DEFLATE:1,INFLATE:2,GZIP:3,GUNZIP:4,DEFLATERAW:5,INFLATERAW:6,UNZIP:7,BROTLI_DECODE:8,BROTLI_ENCODE:9,Z_MIN_WINDOWBITS:8,Z_MAX_WINDOWBITS:15,Z_DEFAULT_WINDOWBITS:15,Z_MIN_CHUNK:64,Z_MAX_CHUNK:1/0,Z_DEFAULT_CHUNK:16384,Z_MIN_MEMLEVEL:1,Z_MAX_MEMLEVEL:9,Z_DEFAULT_MEMLEVEL:8,Z_MIN_LEVEL:-1,Z_MAX_LEVEL:9,Z_DEFAULT_LEVEL:-1,BROTLI_OPERATION_PROCESS:0,BROTLI_OPERATION_FLUSH:1,BROTLI_OPERATION_FINISH:2,BROTLI_OPERATION_EMIT_METADATA:3,BROTLI_MODE_GENERIC:0,BROTLI_MODE_TEXT:1,BROTLI_MODE_FONT:2,BROTLI_DEFAULT_MODE:0,BROTLI_MIN_QUALITY:0,BROTLI_MAX_QUALITY:11,BROTLI_DEFAULT_QUALITY:11,BROTLI_MIN_WINDOW_BITS:10,BROTLI_MAX_WINDOW_BITS:24,BROTLI_LARGE_MAX_WINDOW_BITS:30,BROTLI_DEFAULT_WINDOW:22,BROTLI_MIN_INPUT_BLOCK_BITS:16,BROTLI_MAX_INPUT_BLOCK_BITS:24,BROTLI_PARAM_MODE:0,BROTLI_PARAM_QUALITY:1,BROTLI_PARAM_LGWIN:2,BROTLI_PARAM_LGBLOCK:3,BROTLI_PARAM_DISABLE_LITERAL_CONTEXT_MODELING:4,BROTLI_PARAM_SIZE_HINT:5,BROTLI_PARAM_LARGE_WINDOW:6,BROTLI_PARAM_NPOSTFIX:7,BROTLI_PARAM_NDIRECT:8,BROTLI_DECODER_RESULT_ERROR:0,BROTLI_DECODER_RESULT_SUCCESS:1,BROTLI_DECODER_RESULT_NEEDS_MORE_INPUT:2,BROTLI_DECODER_RESULT_NEEDS_MORE_OUTPUT:3,BROTLI_DECODER_PARAM_DISABLE_RING_BUFFER_REALLOCATION:0,BROTLI_DECODER_PARAM_LARGE_WINDOW:1,BROTLI_DECODER_NO_ERROR:0,BROTLI_DECODER_SUCCESS:1,BROTLI_DECODER_NEEDS_MORE_INPUT:2,BROTLI_DECODER_NEEDS_MORE_OUTPUT:3,BROTLI_DECODER_ERROR_FORMAT_EXUBERANT_NIBBLE:-1,BROTLI_DECODER_ERROR_FORMAT_RESERVED:-2,BROTLI_DECODER_ERROR_FORMAT_EXUBERANT_META_NIBBLE:-3,BROTLI_DECODER_ERROR_FORMAT_SIMPLE_HUFFMAN_ALPHABET:-4,BROTLI_DECODER_ERROR_FORMAT_SIMPLE_HUFFMAN_SAME:-5,BROTLI_DECODER_ERROR_FORMAT_CL_SPACE:-6,BROTLI_DECODER_ERROR_FORMAT_HUFFMAN_SPACE:-7,BROTLI_DECODER_ERROR_FORMAT_CONTEXT_MAP_REPEAT:-8,BROTLI_DECODER_ERROR_FORMAT_BLOCK_LENGTH_1:-9,BROTLI_DECODER_ERROR_FORMAT_BLOCK_LENGTH_2:-10,BROTLI_DECODER_ERROR_FORMAT_TRANSFORM:-11,BROTLI_DECODER_ERROR_FORMAT_DICTIONARY:-12,BROTLI_DECODER_ERROR_FORMAT_WINDOW_BITS:-13,BROTLI_DECODER_ERROR_FORMAT_PADDING_1:-14,BROTLI_DECODER_ERROR_FORMAT_PADDING_2:-15,BROTLI_DECODER_ERROR_FORMAT_DISTANCE:-16,BROTLI_DECODER_ERROR_DICTIONARY_NOT_SET:-19,BROTLI_DECODER_ERROR_INVALID_ARGUMENTS:-20,BROTLI_DECODER_ERROR_ALLOC_CONTEXT_MODES:-21,BROTLI_DECODER_ERROR_ALLOC_TREE_GROUPS:-22,BROTLI_DECODER_ERROR_ALLOC_CONTEXT_MAP:-25,BROTLI_DECODER_ERROR_ALLOC_RING_BUFFER_1:-26,BROTLI_DECODER_ERROR_ALLOC_RING_BUFFER_2:-27,BROTLI_DECODER_ERROR_ALLOC_BLOCK_TYPE_TREES:-30,BROTLI_DECODER_ERROR_UNREACHABLE:-31},Ig)),Ag=kn.concat,Nd=Object.getOwnPropertyDescriptor(kn,"concat"),Cg=t=>t,xa=Nd?.writable===!0||Nd?.set!==void 0?t=>{kn.concat=t?Cg:Ag}:t=>{},On=Symbol("_superWrite"),ts=class extends Error{code;errno;constructor(t,e){super("zlib: "+t.message,{cause:t}),this.code=t.code,this.errno=t.errno,this.code||(this.code="ZLIB_ERROR"),this.message="zlib: "+t.message,Error.captureStackTrace(this,e??this.constructor)}get name(){return"ZlibError"}},ha=Symbol("flushFlag"),Qa=class extends Ln{#e=!1;#n=!1;#r;#s;#i;#t;#o;get sawError(){return this.#e}get handle(){return this.#t}get flushFlag(){return this.#r}constructor(t,e){if(!t||typeof t!="object")throw new TypeError("invalid options for ZlibBase constructor");if(super(t),this.#r=t.flush??0,this.#s=t.finishFlush??0,this.#i=t.fullFlushFlag??0,typeof Ld[e]!="function")throw new TypeError("Compression method not supported: "+e);try{this.#t=new Ld[e](t)}catch(r){throw new ts(r,this.constructor)}this.#o=r=>{this.#e||(this.#e=!0,this.close(),this.emit("error",r))},this.#t?.on("error",r=>this.#o(new ts(r))),this.once("end",()=>this.close)}close(){this.#t&&(this.#t.close(),this.#t=void 0,this.emit("close"))}reset(){if(!this.#e)return ka(this.#t,"zlib binding closed"),this.#t.reset?.()}flush(t){this.ended||(typeof t!="number"&&(t=this.#i),this.write(Object.assign(kn.alloc(0),{[ha]:t})))}end(t,e,r){return typeof t=="function"&&(r=t,e=void 0,t=void 0),typeof e=="function"&&(r=e,e=void 0),t&&(e?this.write(t,e):this.write(t)),this.flush(this.#s),this.#n=!0,super.end(r)}get ended(){return this.#n}[On](t){return super.write(t)}write(t,e,r){if(typeof e=="function"&&(r=e,e="utf8"),typeof t=="string"&&(t=kn.from(t,e)),this.#e)return;ka(this.#t,"zlib binding closed");let s=this.#t._handle,a=s.close;s.close=()=>{};let c=this.#t.close;this.#t.close=()=>{},xa(!0);let f;try{let x=typeof t[ha]=="number"?t[ha]:this.#r;f=this.#t._processChunk(t,x),xa(!1)}catch(x){xa(!1),this.#o(new ts(x,this.write))}finally{this.#t&&(this.#t._handle=s,s.close=a,this.#t.close=c,this.#t.removeAllListeners("error"))}this.#t&&this.#t.on("error",x=>this.#o(new ts(x,this.write)));let l;if(f)if(Array.isArray(f)&&f.length>0){let x=f[0];l=this[On](kn.from(x));for(let h=1;h<f.length;h++)l=this[On](f[h])}else l=this[On](kn.from(f));return r&&r(),l}},pf=class extends Qa{#e;#n;constructor(t,e){t=t||{},t.flush=t.flush||bt.Z_NO_FLUSH,t.finishFlush=t.finishFlush||bt.Z_FINISH,t.fullFlushFlag=bt.Z_FULL_FLUSH,super(t,e),this.#e=t.level,this.#n=t.strategy}params(t,e){if(!this.sawError){if(!this.handle)throw new Error("cannot switch params when binding is closed");if(!this.handle.params)throw new Error("not supported in this implementation");if(this.#e!==t||this.#n!==e){this.flush(bt.Z_SYNC_FLUSH),ka(this.handle,"zlib binding closed");let r=this.handle.flush;this.handle.flush=(s,a)=>{typeof s=="function"&&(a=s,s=this.flushFlag),this.flush(s),a?.()};try{this.handle.params(t,e)}finally{this.handle.flush=r}this.handle&&(this.#e=t,this.#n=e)}}}},Tg=class extends pf{#e;constructor(t){super(t,"Gzip"),this.#e=t&&!!t.portable}[On](t){return this.#e?(this.#e=!1,t[9]=255,super[On](t)):super[On](t)}},Dg=class extends pf{constructor(t){super(t,"Unzip")}},gf=class extends Qa{constructor(t,e){t=t||{},t.flush=t.flush||bt.BROTLI_OPERATION_PROCESS,t.finishFlush=t.finishFlush||bt.BROTLI_OPERATION_FINISH,t.fullFlushFlag=bt.BROTLI_OPERATION_FLUSH,super(t,e)}},Rg=class extends gf{constructor(t){super(t,"BrotliCompress")}},kg=class extends gf{constructor(t){super(t,"BrotliDecompress")}},mf=class extends Qa{constructor(t,e){t=t||{},t.flush=t.flush||bt.ZSTD_e_continue,t.finishFlush=t.finishFlush||bt.ZSTD_e_end,t.fullFlushFlag=bt.ZSTD_e_flush,super(t,e)}},Og=class extends mf{constructor(t){super(t,"ZstdCompress")}},Pg=class extends mf{constructor(t){super(t,"ZstdDecompress")}},Lg=(t,e)=>{if(Number.isSafeInteger(t))t<0?Mg(t,e):Ng(t,e);else throw Error("cannot encode number outside of javascript safe integer range");return e},Ng=(t,e)=>{e[0]=128;for(var r=e.length;r>1;r--)e[r-1]=t&255,t=Math.floor(t/256)},Mg=(t,e)=>{e[0]=255;var r=!1;t=t*-1;for(var s=e.length;s>1;s--){var a=t&255;t=Math.floor(t/256),r?e[s-1]=wf(a):a===0?e[s-1]=0:(r=!0,e[s-1]=_f(a))}},Bg=t=>{let e=t[0],r=e===128?Fg(t.subarray(1,t.length)):e===255?zg(t):null;if(r===null)throw Error("invalid base256 encoding");if(!Number.isSafeInteger(r))throw Error("parsed number outside of javascript safe integer range");return r},zg=t=>{for(var e=t.length,r=0,s=!1,a=e-1;a>-1;a--){var c=Number(t[a]),f;s?f=wf(c):c===0?f=c:(s=!0,f=_f(c)),f!==0&&(r-=f*Math.pow(256,e-a-1))}return r},Fg=t=>{for(var e=t.length,r=0,s=e-1;s>-1;s--){var a=Number(t[s]);a!==0&&(r+=a*Math.pow(256,e-s-1))}return r},wf=t=>(255^t)&255,_f=t=>(255^t)+1&255,Ug={};Qp(Ug,{code:()=>ec,isCode:()=>us,isName:()=>qg,name:()=>Cs});var us=t=>Cs.has(t),qg=t=>ec.has(t),Cs=new Map([["0","File"],["","OldFile"],["1","Link"],["2","SymbolicLink"],["3","CharacterDevice"],["4","BlockDevice"],["5","Directory"],["6","FIFO"],["7","ContiguousFile"],["g","GlobalExtendedHeader"],["x","ExtendedHeader"],["A","SolarisACL"],["D","GNUDumpDir"],["I","Inode"],["K","NextFileHasLongLinkpath"],["L","NextFileHasLongPath"],["M","ContinuationFile"],["N","OldGnuLongPath"],["S","SparseFile"],["V","TapeVolumeHeader"],["X","OldExtendedHeader"]]),ec=new Map(Array.from(Cs).map(t=>[t[1],t[0]])),Pn=class{cksumValid=!1;needPax=!1;nullBlock=!1;block;path;mode;uid;gid;size;cksum;#e="Unsupported";linkpath;uname;gname;devmaj=0;devmin=0;atime;ctime;mtime;charset;comment;constructor(t,e=0,r,s){Buffer.isBuffer(t)?this.decode(t,e||0,r,s):t&&this.#n(t)}decode(t,e,r,s){if(e||(e=0),!t||!(t.length>=e+512))throw new Error("need 512 bytes for header");this.path=r?.path??vn(t,e,100),this.mode=r?.mode??s?.mode??on(t,e+100,8),this.uid=r?.uid??s?.uid??on(t,e+108,8),this.gid=r?.gid??s?.gid??on(t,e+116,8),this.size=r?.size??s?.size??on(t,e+124,12),this.mtime=r?.mtime??s?.mtime??pa(t,e+136,12),this.cksum=on(t,e+148,12),s&&this.#n(s,!0),r&&this.#n(r);let a=vn(t,e+156,1);if(us(a)&&(this.#e=a||"0"),this.#e==="0"&&this.path.slice(-1)==="/"&&(this.#e="5"),this.#e==="5"&&(this.size=0),this.linkpath=vn(t,e+157,100),t.subarray(e+257,e+265).toString()==="ustar\x0000")if(this.uname=r?.uname??s?.uname??vn(t,e+265,32),this.gname=r?.gname??s?.gname??vn(t,e+297,32),this.devmaj=r?.devmaj??s?.devmaj??on(t,e+329,8)??0,this.devmin=r?.devmin??s?.devmin??on(t,e+337,8)??0,t[e+475]!==0){let f=vn(t,e+345,155);this.path=f+"/"+this.path}else{let f=vn(t,e+345,130);f&&(this.path=f+"/"+this.path),this.atime=r?.atime??s?.atime??pa(t,e+476,12),this.ctime=r?.ctime??s?.ctime??pa(t,e+488,12)}let c=256;for(let f=e;f<e+148;f++)c+=t[f];for(let f=e+156;f<e+512;f++)c+=t[f];this.cksumValid=c===this.cksum,this.cksum===void 0&&c===256&&(this.nullBlock=!0)}#n(t,e=!1){Object.assign(this,Object.fromEntries(Object.entries(t).filter(([r,s])=>!(s==null||r==="path"&&e||r==="linkpath"&&e||r==="global"))))}encode(t,e=0){if(t||(t=this.block=Buffer.alloc(512)),this.#e==="Unsupported"&&(this.#e="0"),!(t.length>=e+512))throw new Error("need 512 bytes for header");let r=this.ctime||this.atime?130:155,s=Hg(this.path||"",r),a=s[0],c=s[1];this.needPax=!!s[2],this.needPax=In(t,e,100,a)||this.needPax,this.needPax=an(t,e+100,8,this.mode)||this.needPax,this.needPax=an(t,e+108,8,this.uid)||this.needPax,this.needPax=an(t,e+116,8,this.gid)||this.needPax,this.needPax=an(t,e+124,12,this.size)||this.needPax,this.needPax=ga(t,e+136,12,this.mtime)||this.needPax,t[e+156]=Number(this.#e.codePointAt(0)),this.needPax=In(t,e+157,100,this.linkpath)||this.needPax,t.write("ustar\x0000",e+257,8),this.needPax=In(t,e+265,32,this.uname)||this.needPax,this.needPax=In(t,e+297,32,this.gname)||this.needPax,this.needPax=an(t,e+329,8,this.devmaj)||this.needPax,this.needPax=an(t,e+337,8,this.devmin)||this.needPax,this.needPax=In(t,e+345,r,c)||this.needPax,t[e+475]!==0?this.needPax=In(t,e+345,155,c)||this.needPax:(this.needPax=In(t,e+345,130,c)||this.needPax,this.needPax=ga(t,e+476,12,this.atime)||this.needPax,this.needPax=ga(t,e+488,12,this.ctime)||this.needPax);let f=256;for(let l=e;l<e+148;l++)f+=t[l];for(let l=e+156;l<e+512;l++)f+=t[l];return this.cksum=f,an(t,e+148,8,this.cksum),this.cksumValid=!0,this.needPax}get type(){return this.#e==="Unsupported"?this.#e:Cs.get(this.#e)}get typeKey(){return this.#e}set type(t){let e=String(ec.get(t));if(us(e)||e==="Unsupported")this.#e=e;else if(us(t))this.#e=t;else throw new TypeError("invalid entry type: "+t)}},Hg=(t,e)=>{let r=t,s="",a,c=tr.parse(t).root||".";if(Buffer.byteLength(r)<100)a=[r,s,!1];else{s=tr.dirname(r),r=tr.basename(r);do Buffer.byteLength(r)<=100&&Buffer.byteLength(s)<=e?a=[r,s,!1]:Buffer.byteLength(r)>100&&Buffer.byteLength(s)<=e?a=[r.slice(0,99),s,!0]:(r=tr.join(tr.basename(s),r),s=tr.dirname(s));while(s!==c&&a===void 0);a||(a=[t.slice(0,99),"",!0])}return a},vn=(t,e,r)=>t.subarray(e,e+r).toString("utf8").replace(/\0.*/,""),pa=(t,e,r)=>jg(on(t,e,r)),jg=t=>t===void 0?void 0:new Date(t*1e3),on=(t,e,r)=>Number(t[e])&128?Bg(t.subarray(e,e+r)):Kg(t,e,r),Gg=t=>isNaN(t)?void 0:t,Kg=(t,e,r)=>Gg(parseInt(t.subarray(e,e+r).toString("utf8").replace(/\0.*$/,"").trim(),8)),Wg={12:8589934591,8:2097151},an=(t,e,r,s)=>s===void 0?!1:s>Wg[r]||s<0?(Lg(s,t.subarray(e,e+r)),!0):($g(t,e,r,s),!1),$g=(t,e,r,s)=>t.write(Vg(s,r),e,r,"ascii"),Vg=(t,e)=>Jg(Math.floor(t).toString(8),e),Jg=(t,e)=>(t.length===e-1?t:new Array(e-t.length-1).join("0")+t+" ")+"\0",ga=(t,e,r,s)=>s===void 0?!1:an(t,e,r,s.getTime()/1e3),Zg=new Array(156).join("\0"),In=(t,e,r,s)=>s===void 0?!1:(t.write(s+Zg,e,r,"utf8"),s.length!==Buffer.byteLength(s)||s.length>r),Es=class yf{atime;mtime;ctime;charset;comment;gid;uid;gname;uname;linkpath;dev;ino;nlink;path;size;mode;global;constructor(e,r=!1){this.atime=e.atime,this.charset=e.charset,this.comment=e.comment,this.ctime=e.ctime,this.dev=e.dev,this.gid=e.gid,this.global=r,this.gname=e.gname,this.ino=e.ino,this.linkpath=e.linkpath,this.mtime=e.mtime,this.nlink=e.nlink,this.path=e.path,this.size=e.size,this.uid=e.uid,this.uname=e.uname}encode(){let e=this.encodeBody();if(e==="")return Buffer.allocUnsafe(0);let r=Buffer.byteLength(e),s=512*Math.ceil(1+r/512),a=Buffer.allocUnsafe(s);for(let c=0;c<512;c++)a[c]=0;new Pn({path:("PaxHeader/"+Yg(this.path??"")).slice(0,99),mode:this.mode||420,uid:this.uid,gid:this.gid,size:r,mtime:this.mtime,type:this.global?"GlobalExtendedHeader":"ExtendedHeader",linkpath:"",uname:this.uname||"",gname:this.gname||"",devmaj:0,devmin:0,atime:this.atime,ctime:this.ctime}).encode(a),a.write(e,512,r,"utf8");for(let c=r+512;c<a.length;c++)a[c]=0;return a}encodeBody(){return this.encodeField("path")+this.encodeField("ctime")+this.encodeField("atime")+this.encodeField("dev")+this.encodeField("ino")+this.encodeField("nlink")+this.encodeField("charset")+this.encodeField("comment")+this.encodeField("gid")+this.encodeField("gname")+this.encodeField("linkpath")+this.encodeField("mtime")+this.encodeField("size")+this.encodeField("uid")+this.encodeField("uname")}encodeField(e){if(this[e]===void 0)return"";let r=this[e],s=r instanceof Date?r.getTime()/1e3:r,a=" "+(e==="dev"||e==="ino"||e==="nlink"?"SCHILY.":"")+e+"="+s+`
|
|
81
|
+
`,c=Buffer.byteLength(a),f=Math.floor(Math.log(c)/Math.log(10))+1;return c+f>=Math.pow(10,f)&&(f+=1),f+c+a}static parse(e,r,s=!1){return new yf(Xg(Qg(e),r),s)}},Xg=(t,e)=>e?Object.assign({},e,t):t,Qg=t=>t.replace(/\n$/,"").split(`
|
|
82
|
+
`).reduce(em,Object.create(null)),em=(t,e)=>{let r=parseInt(e,10);if(r!==Buffer.byteLength(e)+1)return t;e=e.slice((r+" ").length);let s=e.split("="),a=s.shift();if(!a)return t;let c=a.replace(/^SCHILY\.(dev|ino|nlink)/,"$1"),f=s.join("=");return t[c]=/^([A-Z]+\.)?([mac]|birth|creation)time$/.test(c)?new Date(Number(f)*1e3):/^[0-9]+$/.test(f)?+f:f,t},tm=process.env.TESTING_TAR_FAKE_PLATFORM||process.platform,Z=tm!=="win32"?t=>t:t=>t&&t.replaceAll(/\\/g,"/"),Ef=class extends Ln{extended;globalExtended;header;startBlockSize;blockRemain;remain;type;meta=!1;ignore=!1;path;mode;uid;gid;uname;gname;size=0;mtime;atime;ctime;linkpath;dev;ino;nlink;invalid=!1;absolute;unsupported=!1;constructor(t,e,r){switch(super({}),this.pause(),this.extended=e,this.globalExtended=r,this.header=t,this.remain=t.size??0,this.startBlockSize=512*Math.ceil(this.remain/512),this.blockRemain=this.startBlockSize,this.type=t.type,this.type){case"File":case"OldFile":case"Link":case"SymbolicLink":case"CharacterDevice":case"BlockDevice":case"Directory":case"FIFO":case"ContiguousFile":case"GNUDumpDir":break;case"NextFileHasLongLinkpath":case"NextFileHasLongPath":case"OldGnuLongPath":case"GlobalExtendedHeader":case"ExtendedHeader":case"OldExtendedHeader":this.meta=!0;break;default:this.ignore=!0}if(!t.path)throw new Error("no path provided for tar.ReadEntry");this.path=Z(t.path),this.mode=t.mode,this.mode&&(this.mode=this.mode&4095),this.uid=t.uid,this.gid=t.gid,this.uname=t.uname,this.gname=t.gname,this.size=this.remain,this.mtime=t.mtime,this.atime=t.atime,this.ctime=t.ctime,this.linkpath=t.linkpath?Z(t.linkpath):void 0,this.uname=t.uname,this.gname=t.gname,e&&this.#e(e),r&&this.#e(r,!0)}write(t){let e=t.length;if(e>this.blockRemain)throw new Error("writing more to entry than is appropriate");let r=this.remain,s=this.blockRemain;return this.remain=Math.max(0,r-e),this.blockRemain=Math.max(0,s-e),this.ignore?!0:r>=e?super.write(t):super.write(t.subarray(0,r))}#e(t,e=!1){t.path&&(t.path=Z(t.path)),t.linkpath&&(t.linkpath=Z(t.linkpath)),Object.assign(this,Object.fromEntries(Object.entries(t).filter(([r,s])=>!(s==null||r==="path"&&e))))}},Ts=(t,e,r,s={})=>{t.file&&(s.file=t.file),t.cwd&&(s.cwd=t.cwd),s.code=r instanceof Error&&r.code||e,s.tarCode=e,!t.strict&&s.recoverable!==!1?(r instanceof Error&&(s=Object.assign(r,s),r=r.message),t.emit("warn",e,r,s)):r instanceof Error?t.emit("error",Object.assign(r,s)):t.emit("error",Object.assign(new Error(`${e}: ${r}`),s))},nm=1024*1024,Oa=Buffer.from([31,139]),Pa=Buffer.from([40,181,47,253]),rm=Math.max(Oa.length,Pa.length),nt=Symbol("state"),An=Symbol("writeEntry"),Lt=Symbol("readEntry"),ma=Symbol("nextEntry"),Md=Symbol("processEntry"),_t=Symbol("extendedHeader"),jr=Symbol("globalExtendedHeader"),en=Symbol("meta"),Bd=Symbol("emitMeta"),ce=Symbol("buffer"),Nt=Symbol("queue"),tn=Symbol("ended"),wa=Symbol("emittedEnd"),Cn=Symbol("emit"),ye=Symbol("unzip"),ns=Symbol("consumeChunk"),rs=Symbol("consumeChunkSub"),_a=Symbol("consumeBody"),zd=Symbol("consumeMeta"),Fd=Symbol("consumeHeader"),Gr=Symbol("consuming"),ya=Symbol("bufferConcat"),is=Symbol("maybeEnd"),nr=Symbol("writing"),nn=Symbol("aborted"),ss=Symbol("onDone"),Tn=Symbol("sawValidEntry"),os=Symbol("sawNullBlock"),as=Symbol("sawEOF"),Ud=Symbol("closeStream"),im=()=>!0,oi=class extends Sg{file;strict;maxMetaEntrySize;filter;brotli;zstd;writable=!0;readable=!1;[Nt]=[];[ce];[Lt];[An];[nt]="begin";[en]="";[_t];[jr];[tn]=!1;[ye];[nn]=!1;[Tn];[os]=!1;[as]=!1;[nr]=!1;[Gr]=!1;[wa]=!1;constructor(t={}){super(),this.file=t.file||"",this.on(ss,()=>{(this[nt]==="begin"||this[Tn]===!1)&&this.warn("TAR_BAD_ARCHIVE","Unrecognized archive format")}),t.ondone?this.on(ss,t.ondone):this.on(ss,()=>{this.emit("prefinish"),this.emit("finish"),this.emit("end")}),this.strict=!!t.strict,this.maxMetaEntrySize=t.maxMetaEntrySize||nm,this.filter=typeof t.filter=="function"?t.filter:im;let e=t.file&&(t.file.endsWith(".tar.br")||t.file.endsWith(".tbr"));this.brotli=!(t.gzip||t.zstd)&&t.brotli!==void 0?t.brotli:e?void 0:!1;let r=t.file&&(t.file.endsWith(".tar.zst")||t.file.endsWith(".tzst"));this.zstd=!(t.gzip||t.brotli)&&t.zstd!==void 0?t.zstd:r?!0:void 0,this.on("end",()=>this[Ud]()),typeof t.onwarn=="function"&&this.on("warn",t.onwarn),typeof t.onReadEntry=="function"&&this.on("entry",t.onReadEntry)}warn(t,e,r={}){Ts(this,t,e,r)}[Fd](t,e){this[Tn]===void 0&&(this[Tn]=!1);let r;try{r=new Pn(t,e,this[_t],this[jr])}catch(s){return this.warn("TAR_ENTRY_INVALID",s)}if(r.nullBlock)this[os]?(this[as]=!0,this[nt]==="begin"&&(this[nt]="header"),this[Cn]("eof")):(this[os]=!0,this[Cn]("nullBlock"));else if(this[os]=!1,!r.cksumValid)this.warn("TAR_ENTRY_INVALID","checksum failure",{header:r});else if(!r.path)this.warn("TAR_ENTRY_INVALID","path is required",{header:r});else{let s=r.type;if(/^(Symbolic)?Link$/.test(s)&&!r.linkpath)this.warn("TAR_ENTRY_INVALID","linkpath required",{header:r});else if(!/^(Symbolic)?Link$/.test(s)&&!/^(Global)?ExtendedHeader$/.test(s)&&r.linkpath)this.warn("TAR_ENTRY_INVALID","linkpath forbidden",{header:r});else{let a=this[An]=new Ef(r,this[_t],this[jr]);if(!this[Tn])if(a.remain){let c=()=>{a.invalid||(this[Tn]=!0)};a.on("end",c)}else this[Tn]=!0;a.meta?a.size>this.maxMetaEntrySize?(a.ignore=!0,this[Cn]("ignoredEntry",a),this[nt]="ignore",a.resume()):a.size>0&&(this[en]="",a.on("data",c=>this[en]+=c),this[nt]="meta"):(this[_t]=void 0,a.ignore=a.ignore||!this.filter(a.path,a),a.ignore?(this[Cn]("ignoredEntry",a),this[nt]=a.remain?"ignore":"header",a.resume()):(a.remain?this[nt]="body":(this[nt]="header",a.end()),this[Lt]?this[Nt].push(a):(this[Nt].push(a),this[ma]())))}}}[Ud](){queueMicrotask(()=>this.emit("close"))}[Md](t){let e=!0;if(!t)this[Lt]=void 0,e=!1;else if(Array.isArray(t)){let[r,...s]=t;this.emit(r,...s)}else this[Lt]=t,this.emit("entry",t),t.emittedEnd||(t.on("end",()=>this[ma]()),e=!1);return e}[ma](){do;while(this[Md](this[Nt].shift()));if(this[Nt].length===0){let t=this[Lt];!t||t.flowing||t.size===t.remain?this[nr]||this.emit("drain"):t.once("drain",()=>this.emit("drain"))}}[_a](t,e){let r=this[An];if(!r)throw new Error("attempt to consume body without entry??");let s=r.blockRemain??0,a=s>=t.length&&e===0?t:t.subarray(e,e+s);return r.write(a),r.blockRemain||(this[nt]="header",this[An]=void 0,r.end()),a.length}[zd](t,e){let r=this[An],s=this[_a](t,e);return!this[An]&&r&&this[Bd](r),s}[Cn](t,e,r){this[Nt].length===0&&!this[Lt]?this.emit(t,e,r):this[Nt].push([t,e,r])}[Bd](t){switch(this[Cn]("meta",this[en]),t.type){case"ExtendedHeader":case"OldExtendedHeader":this[_t]=Es.parse(this[en],this[_t],!1);break;case"GlobalExtendedHeader":this[jr]=Es.parse(this[en],this[jr],!0);break;case"NextFileHasLongPath":case"OldGnuLongPath":{let e=this[_t]??Object.create(null);this[_t]=e,e.path=this[en].replace(/\0.*/,"");break}case"NextFileHasLongLinkpath":{let e=this[_t]||Object.create(null);this[_t]=e,e.linkpath=this[en].replace(/\0.*/,"");break}default:throw new Error("unknown meta: "+t.type)}}abort(t){this[nn]=!0,this.emit("abort",t),this.warn("TAR_ABORT",t,{recoverable:!1})}write(t,e,r){if(typeof e=="function"&&(r=e,e=void 0),typeof t=="string"&&(t=Buffer.from(t,typeof e=="string"?e:"utf8")),this[nn])return r?.(),!1;if((this[ye]===void 0||this.brotli===void 0&&this[ye]===!1)&&t){if(this[ce]&&(t=Buffer.concat([this[ce],t]),this[ce]=void 0),t.length<rm)return this[ce]=t,r?.(),!0;for(let f=0;this[ye]===void 0&&f<Oa.length;f++)t[f]!==Oa[f]&&(this[ye]=!1);let a=!1;if(this[ye]===!1&&this.zstd!==!1){a=!0;for(let f=0;f<Pa.length;f++)if(t[f]!==Pa[f]){a=!1;break}}let c=this.brotli===void 0&&!a;if(this[ye]===!1&&c)if(t.length<512)if(this[tn])this.brotli=!0;else return this[ce]=t,r?.(),!0;else try{new Pn(t.subarray(0,512)),this.brotli=!1}catch{this.brotli=!0}if(this[ye]===void 0||this[ye]===!1&&(this.brotli||a)){let f=this[tn];this[tn]=!1,this[ye]=this[ye]===void 0?new Dg({}):a?new Pg({}):new kg({}),this[ye].on("data",x=>this[ns](x)),this[ye].on("error",x=>this.abort(x)),this[ye].on("end",()=>{this[tn]=!0,this[ns]()}),this[nr]=!0;let l=!!this[ye][f?"end":"write"](t);return this[nr]=!1,r?.(),l}}this[nr]=!0,this[ye]?this[ye].write(t):this[ns](t),this[nr]=!1;let s=this[Nt].length>0?!1:this[Lt]?this[Lt].flowing:!0;return!s&&this[Nt].length===0&&this[Lt]?.once("drain",()=>this.emit("drain")),r?.(),s}[ya](t){t&&!this[nn]&&(this[ce]=this[ce]?Buffer.concat([this[ce],t]):t)}[is](){if(this[tn]&&!this[wa]&&!this[nn]&&!this[Gr]){this[wa]=!0;let t=this[An];if(t&&t.blockRemain){let e=this[ce]?this[ce].length:0;this.warn("TAR_BAD_ARCHIVE",`Truncated input (needed ${t.blockRemain} more bytes, only ${e} available)`,{entry:t}),this[ce]&&t.write(this[ce]),t.end()}this[Cn](ss)}}[ns](t){if(this[Gr]&&t)this[ya](t);else if(!t&&!this[ce])this[is]();else if(t){if(this[Gr]=!0,this[ce]){this[ya](t);let e=this[ce];this[ce]=void 0,this[rs](e)}else this[rs](t);for(;this[ce]&&this[ce]?.length>=512&&!this[nn]&&!this[as];){let e=this[ce];this[ce]=void 0,this[rs](e)}this[Gr]=!1}(!this[ce]||this[tn])&&this[is]()}[rs](t){let e=0,r=t.length;for(;e+512<=r&&!this[nn]&&!this[as];)switch(this[nt]){case"begin":case"header":this[Fd](t,e),e+=512;break;case"ignore":case"body":e+=this[_a](t,e);break;case"meta":e+=this[zd](t,e);break;default:throw new Error("invalid state: "+this[nt])}e<r&&(this[ce]=this[ce]?Buffer.concat([t.subarray(e),this[ce]]):t.subarray(e))}end(t,e,r){return typeof t=="function"&&(r=t,e=void 0,t=void 0),typeof e=="function"&&(r=e,e=void 0),typeof t=="string"&&(t=Buffer.from(t,e)),r&&this.once("finish",r),this[nn]||(this[ye]?(t&&this[ye].write(t),this[ye].end()):(this[tn]=!0,(this.brotli===void 0||this.zstd===void 0)&&(t=t||Buffer.alloc(0)),t&&this.write(t),this[is]())),this}},Qr=t=>{let e=t.length-1,r=-1;for(;e>-1&&t.charAt(e)==="/";)r=e,e--;return r===-1?t:t.slice(0,r)},sm=t=>{let e=t.onReadEntry;t.onReadEntry=e?r=>{e(r),r.resume()}:r=>r.resume()},bf=(t,e)=>{let r=new Map(e.map(c=>[Qr(c),!0])),s=t.filter,a=(c,f="")=>{let l=f||pg(c).root||".",x;if(c===l)x=!1;else{let h=r.get(c);x=h!==void 0?h:a(hg(c),l)}return r.set(c,x),x};t.filter=s?(c,f)=>s(c,f)&&a(Qr(c)):c=>a(Qr(c))},om=t=>{let e=new oi(t),r=t.file,s;try{s=cr.openSync(r,"r");let a=cr.fstatSync(s),c=t.maxReadSize||16*1024*1024;if(a.size<c){let f=Buffer.allocUnsafe(a.size),l=cr.readSync(s,f,0,a.size,0);e.end(l===f.byteLength?f:f.subarray(0,l))}else{let f=0,l=Buffer.allocUnsafe(c);for(;f<a.size;){let x=cr.readSync(s,l,0,c,f);if(x===0)break;f+=x,e.write(l.subarray(0,x))}e.end()}}finally{if(typeof s=="number")try{cr.closeSync(s)}catch{}}},am=(t,e)=>{let r=new oi(t),s=t.maxReadSize||16*1024*1024,a=t.file;return new Promise((c,f)=>{r.on("error",f),r.on("end",c),cr.stat(a,(l,x)=>{if(l)f(l);else{let h=new Ya(a,{readSize:s,size:x.size});h.on("error",f),h.pipe(r)}})})},ur=ai(om,am,t=>new oi(t),t=>new oi(t),(t,e)=>{e?.length&&bf(t,e),t.noResume||sm(t)}),Sf=(t,e,r)=>(t&=4095,r&&(t=(t|384)&-19),e&&(t&256&&(t|=64),t&32&&(t|=8),t&4&&(t|=1)),t),{isAbsolute:dm,parse:Hd}=cm,tc=t=>{let e="",r=Hd(t);for(;dm(t)||r.root;){let s=t.charAt(0)==="/"&&t.slice(0,4)!=="//?/"?"/":r.root;t=t.slice(s.length),e+=s,r=Hd(t)}return[e,t]},Ds=["|","<",">","?",":"],nc=Ds.map(t=>String.fromCodePoint(61440+Number(t.codePointAt(0)))),fm=new Map(Ds.map((t,e)=>[t,nc[e]])),lm=new Map(nc.map((t,e)=>[t,Ds[e]])),jd=t=>Ds.reduce((e,r)=>e.split(r).join(fm.get(r)),t),um=t=>nc.reduce((e,r)=>e.split(r).join(lm.get(r)),t),vf=(t,e)=>e?(t=Z(t).replace(/^\.(\/|$)/,""),Qr(e)+"/"+t):Z(t),xm=16*1024*1024,Gd=Symbol("process"),Kd=Symbol("file"),Wd=Symbol("directory"),La=Symbol("symlink"),$d=Symbol("hardlink"),Kr=Symbol("header"),xs=Symbol("read"),Na=Symbol("lstat"),hs=Symbol("onlstat"),Ma=Symbol("onread"),Ba=Symbol("onreadlink"),za=Symbol("openfile"),Fa=Symbol("onopenfile"),cn=Symbol("close"),Ss=Symbol("mode"),Ua=Symbol("awaitDrain"),Ea=Symbol("ondrain"),Et=Symbol("prefix"),If=class extends Ln{path;portable;myuid=process.getuid&&process.getuid()||0;myuser=process.env.USER||"";maxReadSize;linkCache;statCache;preservePaths;cwd;strict;mtime;noPax;noMtime;prefix;fd;blockLen=0;blockRemain=0;buf;pos=0;remain=0;length=0;offset=0;win32;absolute;header;type;linkpath;stat;onWriteEntry;#e=!1;constructor(t,e={}){let r=Xa(e);super(),this.path=Z(t),this.portable=!!r.portable,this.maxReadSize=r.maxReadSize||xm,this.linkCache=r.linkCache||new Map,this.statCache=r.statCache||new Map,this.preservePaths=!!r.preservePaths,this.cwd=Z(r.cwd||process.cwd()),this.strict=!!r.strict,this.noPax=!!r.noPax,this.noMtime=!!r.noMtime,this.mtime=r.mtime,this.prefix=r.prefix?Z(r.prefix):void 0,this.onWriteEntry=r.onWriteEntry,typeof r.onwarn=="function"&&this.on("warn",r.onwarn);let s=!1;if(!this.preservePaths){let[c,f]=tc(this.path);c&&typeof f=="string"&&(this.path=f,s=c)}this.win32=!!r.win32||process.platform==="win32",this.win32&&(this.path=um(this.path.replaceAll(/\\/g,"/")),t=t.replaceAll(/\\/g,"/")),this.absolute=Z(r.absolute||qd.resolve(this.cwd,t)),this.path===""&&(this.path="./"),s&&this.warn("TAR_ENTRY_INFO",`stripping ${s} from absolute path`,{entry:this,path:s+this.path});let a=this.statCache.get(this.absolute);a?this[hs](a):this[Na]()}warn(t,e,r={}){return Ts(this,t,e,r)}emit(t,...e){return t==="error"&&(this.#e=!0),super.emit(t,...e)}[Na](){yt.lstat(this.absolute,(t,e)=>{if(t)return this.emit("error",t);this[hs](e)})}[hs](t){this.statCache.set(this.absolute,t),this.stat=t,t.isFile()||(t.size=0),this.type=gm(t),this.emit("stat",t),this[Gd]()}[Gd](){switch(this.type){case"File":return this[Kd]();case"Directory":return this[Wd]();case"SymbolicLink":return this[La]();default:return this.end()}}[Ss](t){return Sf(t,this.type==="Directory",this.portable)}[Et](t){return vf(t,this.prefix)}[Kr](){if(!this.stat)throw new Error("cannot write header before stat");this.type==="Directory"&&this.portable&&(this.noMtime=!0),this.onWriteEntry?.(this),this.header=new Pn({path:this[Et](this.path),linkpath:this.type==="Link"&&this.linkpath!==void 0?this[Et](this.linkpath):this.linkpath,mode:this[Ss](this.stat.mode),uid:this.portable?void 0:this.stat.uid,gid:this.portable?void 0:this.stat.gid,size:this.stat.size,mtime:this.noMtime?void 0:this.mtime||this.stat.mtime,type:this.type==="Unsupported"?void 0:this.type,uname:this.portable?void 0:this.stat.uid===this.myuid?this.myuser:"",atime:this.portable?void 0:this.stat.atime,ctime:this.portable?void 0:this.stat.ctime}),this.header.encode()&&!this.noPax&&super.write(new Es({atime:this.portable?void 0:this.header.atime,ctime:this.portable?void 0:this.header.ctime,gid:this.portable?void 0:this.header.gid,mtime:this.noMtime?void 0:this.mtime||this.header.mtime,path:this[Et](this.path),linkpath:this.type==="Link"&&this.linkpath!==void 0?this[Et](this.linkpath):this.linkpath,size:this.header.size,uid:this.portable?void 0:this.header.uid,uname:this.portable?void 0:this.header.uname,dev:this.portable?void 0:this.stat.dev,ino:this.portable?void 0:this.stat.ino,nlink:this.portable?void 0:this.stat.nlink}).encode());let t=this.header?.block;if(!t)throw new Error("failed to encode header");super.write(t)}[Wd](){if(!this.stat)throw new Error("cannot create directory entry without stat");this.path.slice(-1)!=="/"&&(this.path+="/"),this.stat.size=0,this[Kr](),this.end()}[La](){yt.readlink(this.absolute,(t,e)=>{if(t)return this.emit("error",t);this[Ba](e)})}[Ba](t){this.linkpath=Z(t),this[Kr](),this.end()}[$d](t){if(!this.stat)throw new Error("cannot create link entry without stat");this.type="Link",this.linkpath=Z(qd.relative(this.cwd,t)),this.stat.size=0,this[Kr](),this.end()}[Kd](){if(!this.stat)throw new Error("cannot create file entry without stat");if(this.stat.nlink>1){let t=`${this.stat.dev}:${this.stat.ino}`,e=this.linkCache.get(t);if(e?.indexOf(this.cwd)===0)return this[$d](e);this.linkCache.set(t,this.absolute)}if(this[Kr](),this.stat.size===0)return this.end();this[za]()}[za](){yt.open(this.absolute,"r",(t,e)=>{if(t)return this.emit("error",t);this[Fa](e)})}[Fa](t){if(this.fd=t,this.#e)return this[cn]();if(!this.stat)throw new Error("should stat before calling onopenfile");this.blockLen=512*Math.ceil(this.stat.size/512),this.blockRemain=this.blockLen;let e=Math.min(this.blockLen,this.maxReadSize);this.buf=Buffer.allocUnsafe(e),this.offset=0,this.pos=0,this.remain=this.stat.size,this.length=this.buf.length,this[xs]()}[xs](){let{fd:t,buf:e,offset:r,length:s,pos:a}=this;if(t===void 0||e===void 0)throw new Error("cannot read file without first opening");yt.read(t,e,r,s,a,(c,f)=>{if(c)return this[cn](()=>this.emit("error",c));this[Ma](f)})}[cn](t=()=>{}){this.fd!==void 0&&yt.close(this.fd,t)}[Ma](t){if(t<=0&&this.remain>0){let r=Object.assign(new Error("encountered unexpected EOF"),{path:this.absolute,syscall:"read",code:"EOF"});return this[cn](()=>this.emit("error",r))}if(t>this.remain){let r=Object.assign(new Error("did not encounter expected EOF"),{path:this.absolute,syscall:"read",code:"EOF"});return this[cn](()=>this.emit("error",r))}if(!this.buf)throw new Error("should have created buffer prior to reading");if(t===this.remain)for(let r=t;r<this.length&&t<this.blockRemain;r++)this.buf[r+this.offset]=0,t++,this.remain++;let e=this.offset===0&&t===this.buf.length?this.buf:this.buf.subarray(this.offset,this.offset+t);this.write(e)?this[Ea]():this[Ua](()=>this[Ea]())}[Ua](t){this.once("drain",t)}write(t,e,r){if(typeof e=="function"&&(r=e,e=void 0),typeof t=="string"&&(t=Buffer.from(t,typeof e=="string"?e:"utf8")),this.blockRemain<t.length){let s=Object.assign(new Error("writing more data than expected"),{path:this.absolute});return this.emit("error",s)}return this.remain-=t.length,this.blockRemain-=t.length,this.pos+=t.length,this.offset+=t.length,super.write(t,null,r)}[Ea](){if(!this.remain)return this.blockRemain&&super.write(Buffer.alloc(this.blockRemain)),this[cn](t=>t?this.emit("error",t):this.end());if(!this.buf)throw new Error("buffer lost somehow in ONDRAIN");this.offset>=this.length&&(this.buf=Buffer.allocUnsafe(Math.min(this.blockRemain,this.buf.length)),this.offset=0),this.length=this.buf.length-this.offset,this[xs]()}},hm=class extends If{sync=!0;[Na](){this[hs](yt.lstatSync(this.absolute))}[La](){this[Ba](yt.readlinkSync(this.absolute))}[za](){this[Fa](yt.openSync(this.absolute,"r"))}[xs](){let t=!0;try{let{fd:e,buf:r,offset:s,length:a,pos:c}=this;if(e===void 0||r===void 0)throw new Error("fd and buf must be set in READ method");let f=yt.readSync(e,r,s,a,c);this[Ma](f),t=!1}finally{if(t)try{this[cn](()=>{})}catch{}}}[Ua](t){t()}[cn](t=()=>{}){this.fd!==void 0&&yt.closeSync(this.fd),t()}},pm=class extends Ln{blockLen=0;blockRemain=0;buf=0;pos=0;remain=0;length=0;preservePaths;portable;strict;noPax;noMtime;readEntry;type;prefix;path;mode;uid;gid;uname;gname;header;mtime;atime;ctime;linkpath;size;onWriteEntry;warn(t,e,r={}){return Ts(this,t,e,r)}constructor(t,e={}){let r=Xa(e);super(),this.preservePaths=!!r.preservePaths,this.portable=!!r.portable,this.strict=!!r.strict,this.noPax=!!r.noPax,this.noMtime=!!r.noMtime,this.onWriteEntry=r.onWriteEntry,this.readEntry=t;let{type:s}=t;if(s==="Unsupported")throw new Error("writing entry that should be ignored");this.type=s,this.type==="Directory"&&this.portable&&(this.noMtime=!0),this.prefix=r.prefix,this.path=Z(t.path),this.mode=t.mode!==void 0?this[Ss](t.mode):void 0,this.uid=this.portable?void 0:t.uid,this.gid=this.portable?void 0:t.gid,this.uname=this.portable?void 0:t.uname,this.gname=this.portable?void 0:t.gname,this.size=t.size,this.mtime=this.noMtime?void 0:r.mtime||t.mtime,this.atime=this.portable?void 0:t.atime,this.ctime=this.portable?void 0:t.ctime,this.linkpath=t.linkpath!==void 0?Z(t.linkpath):void 0,typeof r.onwarn=="function"&&this.on("warn",r.onwarn);let a=!1;if(!this.preservePaths){let[f,l]=tc(this.path);f&&typeof l=="string"&&(this.path=l,a=f)}this.remain=t.size,this.blockRemain=t.startBlockSize,this.onWriteEntry?.(this),this.header=new Pn({path:this[Et](this.path),linkpath:this.type==="Link"&&this.linkpath!==void 0?this[Et](this.linkpath):this.linkpath,mode:this.mode,uid:this.portable?void 0:this.uid,gid:this.portable?void 0:this.gid,size:this.size,mtime:this.noMtime?void 0:this.mtime,type:this.type,uname:this.portable?void 0:this.uname,atime:this.portable?void 0:this.atime,ctime:this.portable?void 0:this.ctime}),a&&this.warn("TAR_ENTRY_INFO",`stripping ${a} from absolute path`,{entry:this,path:a+this.path}),this.header.encode()&&!this.noPax&&super.write(new Es({atime:this.portable?void 0:this.atime,ctime:this.portable?void 0:this.ctime,gid:this.portable?void 0:this.gid,mtime:this.noMtime?void 0:this.mtime,path:this[Et](this.path),linkpath:this.type==="Link"&&this.linkpath!==void 0?this[Et](this.linkpath):this.linkpath,size:this.size,uid:this.portable?void 0:this.uid,uname:this.portable?void 0:this.uname,dev:this.portable?void 0:this.readEntry.dev,ino:this.portable?void 0:this.readEntry.ino,nlink:this.portable?void 0:this.readEntry.nlink}).encode());let c=this.header?.block;if(!c)throw new Error("failed to encode header");super.write(c),t.pipe(this)}[Et](t){return vf(t,this.prefix)}[Ss](t){return Sf(t,this.type==="Directory",this.portable)}write(t,e,r){typeof e=="function"&&(r=e,e=void 0),typeof t=="string"&&(t=Buffer.from(t,typeof e=="string"?e:"utf8"));let s=t.length;if(s>this.blockRemain)throw new Error("writing more to entry than is appropriate");return this.blockRemain-=s,super.write(t,r)}end(t,e,r){return this.blockRemain&&super.write(Buffer.alloc(this.blockRemain)),typeof t=="function"&&(r=t,e=void 0,t=void 0),typeof e=="function"&&(r=e,e=void 0),typeof t=="string"&&(t=Buffer.from(t,e??"utf8")),r&&this.once("finish",r),t?super.end(t,r):super.end(r),this}},gm=t=>t.isFile()?"File":t.isDirectory()?"Directory":t.isSymbolicLink()?"SymbolicLink":"Unsupported",mm=class dr{tail;head;length=0;static create(e=[]){return new dr(e)}constructor(e=[]){for(let r of e)this.push(r)}*[Symbol.iterator](){for(let e=this.head;e;e=e.next)yield e.value}removeNode(e){if(e.list!==this)throw new Error("removing node which does not belong to this list");let r=e.next,s=e.prev;return r&&(r.prev=s),s&&(s.next=r),e===this.head&&(this.head=r),e===this.tail&&(this.tail=s),this.length--,e.next=void 0,e.prev=void 0,e.list=void 0,r}unshiftNode(e){if(e===this.head)return;e.list&&e.list.removeNode(e);let r=this.head;e.list=this,e.next=r,r&&(r.prev=e),this.head=e,this.tail||(this.tail=e),this.length++}pushNode(e){if(e===this.tail)return;e.list&&e.list.removeNode(e);let r=this.tail;e.list=this,e.prev=r,r&&(r.next=e),this.tail=e,this.head||(this.head=e),this.length++}push(...e){for(let r=0,s=e.length;r<s;r++)_m(this,e[r]);return this.length}unshift(...e){for(var r=0,s=e.length;r<s;r++)ym(this,e[r]);return this.length}pop(){if(!this.tail)return;let e=this.tail.value,r=this.tail;return this.tail=this.tail.prev,this.tail?this.tail.next=void 0:this.head=void 0,r.list=void 0,this.length--,e}shift(){if(!this.head)return;let e=this.head.value,r=this.head;return this.head=this.head.next,this.head?this.head.prev=void 0:this.tail=void 0,r.list=void 0,this.length--,e}forEach(e,r){r=r||this;for(let s=this.head,a=0;s;a++)e.call(r,s.value,a,this),s=s.next}forEachReverse(e,r){r=r||this;for(let s=this.tail,a=this.length-1;s;a--)e.call(r,s.value,a,this),s=s.prev}get(e){let r=0,s=this.head;for(;s&&r<e;r++)s=s.next;if(r===e&&s)return s.value}getReverse(e){let r=0,s=this.tail;for(;s&&r<e;r++)s=s.prev;if(r===e&&s)return s.value}map(e,r){r=r||this;let s=new dr;for(let a=this.head;a;)s.push(e.call(r,a.value,this)),a=a.next;return s}mapReverse(e,r){r=r||this;var s=new dr;for(let a=this.tail;a;)s.push(e.call(r,a.value,this)),a=a.prev;return s}reduce(e,r){let s,a=this.head;if(arguments.length>1)s=r;else if(this.head)a=this.head.next,s=this.head.value;else throw new TypeError("Reduce of empty list with no initial value");for(var c=0;a;c++)s=e(s,a.value,c),a=a.next;return s}reduceReverse(e,r){let s,a=this.tail;if(arguments.length>1)s=r;else if(this.tail)a=this.tail.prev,s=this.tail.value;else throw new TypeError("Reduce of empty list with no initial value");for(let c=this.length-1;a;c--)s=e(s,a.value,c),a=a.prev;return s}toArray(){let e=new Array(this.length);for(let r=0,s=this.head;s;r++)e[r]=s.value,s=s.next;return e}toArrayReverse(){let e=new Array(this.length);for(let r=0,s=this.tail;s;r++)e[r]=s.value,s=s.prev;return e}slice(e=0,r=this.length){r<0&&(r+=this.length),e<0&&(e+=this.length);let s=new dr;if(r<e||r<0)return s;e<0&&(e=0),r>this.length&&(r=this.length);let a=this.head,c=0;for(c=0;a&&c<e;c++)a=a.next;for(;a&&c<r;c++,a=a.next)s.push(a.value);return s}sliceReverse(e=0,r=this.length){r<0&&(r+=this.length),e<0&&(e+=this.length);let s=new dr;if(r<e||r<0)return s;e<0&&(e=0),r>this.length&&(r=this.length);let a=this.length,c=this.tail;for(;c&&a>r;a--)c=c.prev;for(;c&&a>e;a--,c=c.prev)s.push(c.value);return s}splice(e,r=0,...s){e>this.length&&(e=this.length-1),e<0&&(e=this.length+e);let a=this.head;for(let f=0;a&&f<e;f++)a=a.next;let c=[];for(let f=0;a&&f<r;f++)c.push(a.value),a=this.removeNode(a);a?a!==this.tail&&(a=a.prev):a=this.tail;for(let f of s)a=wm(this,a,f);return c}reverse(){let e=this.head,r=this.tail;for(let s=e;s;s=s.prev){let a=s.prev;s.prev=s.next,s.next=a}return this.head=r,this.tail=e,this}};function wm(t,e,r){let s=e,a=e?e.next:t.head,c=new rc(r,s,a,t);return c.next===void 0&&(t.tail=c),c.prev===void 0&&(t.head=c),t.length++,c}function _m(t,e){t.tail=new rc(e,t.tail,void 0,t),t.head||(t.head=t.tail),t.length++}function ym(t,e){t.head=new rc(e,void 0,t.head,t),t.tail||(t.tail=t.head),t.length++}var rc=class{list;next;prev;value;constructor(t,e,r,s){this.list=s,this.value=t,e?(e.next=this,this.prev=e):this.prev=void 0,r?(r.prev=this,this.next=r):this.next=void 0}},Jd=class{path;absolute;entry;stat;readdir;pending=!1;pendingLink=!1;ignore=!1;piped=!1;constructor(t,e){this.path=t||"./",this.absolute=e}},Zd=Buffer.alloc(1024),ps=Symbol("onStat"),Wr=Symbol("ended"),lt=Symbol("queue"),$r=Symbol("queue"),rn=Symbol("current"),Dn=Symbol("process"),Vr=Symbol("processing"),cs=Symbol("processJob"),ut=Symbol("jobs"),ba=Symbol("jobDone"),gs=Symbol("addFSEntry"),Yd=Symbol("addTarEntry"),qa=Symbol("stat"),Ha=Symbol("readdir"),ms=Symbol("onreaddir"),ws=Symbol("pipe"),Xd=Symbol("entry"),Sa=Symbol("entryOpt"),_s=Symbol("writeEntryClass"),Af=Symbol("write"),va=Symbol("ondrain"),Rs=class extends Ln{sync=!1;opt;cwd;maxReadSize;preservePaths;strict;noPax;prefix;linkCache;statCache;file;portable;zip;readdirCache;noDirRecurse;follow;noMtime;mtime;filter;jobs;[_s];onWriteEntry;[lt];[$r]=new Map;[ut]=0;[Vr]=!1;[Wr]=!1;constructor(t={}){if(super(),this.opt=t,this.file=t.file||"",this.cwd=t.cwd||process.cwd(),this.maxReadSize=t.maxReadSize,this.preservePaths=!!t.preservePaths,this.strict=!!t.strict,this.noPax=!!t.noPax,this.prefix=Z(t.prefix||""),this.linkCache=t.linkCache||new Map,this.statCache=t.statCache||new Map,this.readdirCache=t.readdirCache||new Map,this.onWriteEntry=t.onWriteEntry,this[_s]=If,typeof t.onwarn=="function"&&this.on("warn",t.onwarn),this.portable=!!t.portable,t.gzip||t.brotli||t.zstd){if((t.gzip?1:0)+(t.brotli?1:0)+(t.zstd?1:0)>1)throw new TypeError("gzip, brotli, zstd are mutually exclusive");if(t.gzip&&(typeof t.gzip!="object"&&(t.gzip={}),this.portable&&(t.gzip.portable=!0),this.zip=new Tg(t.gzip)),t.brotli&&(typeof t.brotli!="object"&&(t.brotli={}),this.zip=new Rg(t.brotli)),t.zstd&&(typeof t.zstd!="object"&&(t.zstd={}),this.zip=new Og(t.zstd)),!this.zip)throw new Error("impossible");let e=this.zip;e.on("data",r=>super.write(r)),e.on("end",()=>super.end()),e.on("drain",()=>this[va]()),this.on("resume",()=>e.resume())}else this.on("drain",this[va]);this.noDirRecurse=!!t.noDirRecurse,this.follow=!!t.follow,this.noMtime=!!t.noMtime,t.mtime&&(this.mtime=t.mtime),this.filter=typeof t.filter=="function"?t.filter:()=>!0,this[lt]=new mm,this[ut]=0,this.jobs=Number(t.jobs)||4,this[Vr]=!1,this[Wr]=!1}[Af](t){return super.write(t)}add(t){return this.write(t),this}end(t,e,r){return typeof t=="function"&&(r=t,t=void 0),typeof e=="function"&&(r=e,e=void 0),t&&this.add(t),this[Wr]=!0,this[Dn](),r&&r(),this}write(t){if(this[Wr])throw new Error("write after end");return t instanceof Ef?this[Yd](t):this[gs](t),this.flowing}[Yd](t){let e=Z(Vd.resolve(this.cwd,t.path));if(!this.filter(t.path,t))t.resume();else{let r=new Jd(t.path,e);r.entry=new pm(t,this[Sa](r)),r.entry.on("end",()=>this[ba](r)),this[ut]+=1,this[lt].push(r)}this[Dn]()}[gs](t){let e=Z(Vd.resolve(this.cwd,t));this[lt].push(new Jd(t,e)),this[Dn]()}[qa](t){t.pending=!0,this[ut]+=1;let e=this.follow?"stat":"lstat";bs[e](t.absolute,(r,s)=>{t.pending=!1,this[ut]-=1,r?this.emit("error",r):this[ps](t,s)})}[ps](t,e){if(this.statCache.set(t.absolute,e),t.stat=e,!this.filter(t.path,e))t.ignore=!0;else if(e.isFile()&&e.nlink>1&&!this.linkCache.get(`${e.dev}:${e.ino}`)&&!this.sync)if(t===this[rn])this[cs](t);else{let r=`${e.dev}:${e.ino}`,s=this[$r].get(r);s?s.push(t):this[$r].set(r,[t]),t.pendingLink=!0,t.pending=!0}this[Dn]()}[Ha](t){t.pending=!0,this[ut]+=1,bs.readdir(t.absolute,(e,r)=>{if(t.pending=!1,this[ut]-=1,e)return this.emit("error",e);this[ms](t,r)})}[ms](t,e){this.readdirCache.set(t.absolute,e),t.readdir=e,this[Dn]()}[Dn](){if(!this[Vr]){this[Vr]=!0;for(let t=this[lt].head;t&&this[ut]<this.jobs;t=t.next)if(this[cs](t.value),t.value.ignore){let e=t.next;this[lt].removeNode(t),t.next=e}this[Vr]=!1,this[Wr]&&this[lt].length===0&&this[ut]===0&&(this.zip?this.zip.end(Zd):(super.write(Zd),super.end()))}}get[rn](){return this[lt]&&this[lt].head&&this[lt].head.value}[ba](t){this[lt].shift(),this[ut]-=1;let{stat:e}=t;if(e&&e.isFile()&&e.nlink>1){let r=`${e.dev}:${e.ino}`,s=this[$r].get(r);if(s){this[$r].delete(r);for(let a of s)a.pending=!1,this[cs](a)}}this[Dn]()}[cs](t){if(t.pending&&t.pendingLink&&t===this[rn]&&(t.pending=!1,t.pendingLink=!1),!t.pending){if(t.entry){t===this[rn]&&!t.piped&&this[ws](t);return}if(!t.stat){let e=this.statCache.get(t.absolute);e?this[ps](t,e):this[qa](t)}if(t.stat&&!t.ignore){if(!this.noDirRecurse&&t.stat.isDirectory()&&!t.readdir){let e=this.readdirCache.get(t.absolute);if(e?this[ms](t,e):this[Ha](t),!t.readdir)return}if(t.entry=this[Xd](t),!t.entry){t.ignore=!0;return}t===this[rn]&&!t.piped&&this[ws](t)}}}[Sa](t){return{onwarn:(e,r,s)=>this.warn(e,r,s),noPax:this.noPax,cwd:this.cwd,absolute:t.absolute,preservePaths:this.preservePaths,maxReadSize:this.maxReadSize,strict:this.strict,portable:this.portable,linkCache:this.linkCache,statCache:this.statCache,noMtime:this.noMtime,mtime:this.mtime,prefix:this.prefix,onWriteEntry:this.onWriteEntry}}[Xd](t){this[ut]+=1;try{return new this[_s](t.path,this[Sa](t)).on("end",()=>this[ba](t)).on("error",e=>this.emit("error",e))}catch(e){this.emit("error",e)}}[va](){this[rn]&&this[rn].entry&&this[rn].entry.resume()}[ws](t){t.piped=!0,t.readdir&&t.readdir.forEach(s=>{let a=t.path,c=a==="./"?"":a.replace(/\/*$/,"/");this[gs](c+s)});let e=t.entry,r=this.zip;if(!e)throw new Error("cannot pipe without source");r?e.on("data",s=>{r.write(s)||e.pause()}):e.on("data",s=>{super.write(s)||e.pause()})}pause(){return this.zip&&this.zip.pause(),super.pause()}warn(t,e,r={}){Ts(this,t,e,r)}},ic=class extends Rs{sync=!0;constructor(t){super(t),this[_s]=hm}pause(){}resume(){}[qa](t){let e=this.follow?"statSync":"lstatSync";this[ps](t,bs[e](t.absolute))}[Ha](t){this[ms](t,bs.readdirSync(t.absolute))}[ws](t){let e=t.entry,r=this.zip;if(t.readdir&&t.readdir.forEach(s=>{let a=t.path,c=a==="./"?"":a.replace(/\/*$/,"/");this[gs](c+s)}),!e)throw new Error("Cannot pipe without source");r?e.on("data",s=>{r.write(s)}):e.on("data",s=>{super[Af](s)})}},Em=(t,e)=>{let r=new ic(t),s=new xf(t.file,{mode:t.mode||438});r.pipe(s),Cf(r,e)},bm=(t,e)=>{let r=new Rs(t),s=new As(t.file,{mode:t.mode||438});r.pipe(s);let a=new Promise((c,f)=>{s.on("error",f),s.on("close",c),r.on("error",f)});return Tf(r,e).catch(c=>r.emit("error",c)),a},Cf=(t,e)=>{e.forEach(r=>{r.charAt(0)==="@"?ur({file:hf.resolve(t.cwd,r.slice(1)),sync:!0,noResume:!0,onReadEntry:s=>t.add(s)}):t.add(r)}),t.end()},Tf=async(t,e)=>{for(let r of e)r.charAt(0)==="@"?await ur({file:hf.resolve(String(t.cwd),r.slice(1)),noResume:!0,onReadEntry:s=>{t.add(s)}}):t.add(r);t.end()},Sm=(t,e)=>{let r=new ic(t);return Cf(r,e),r},vm=(t,e)=>{let r=new Rs(t);return Tf(r,e).catch(s=>r.emit("error",s)),r},AS=ai(Em,bm,Sm,vm,(t,e)=>{if(!e?.length)throw new TypeError("no paths specified to add to archive")}),Am=process.env.__FAKE_PLATFORM__||process.platform,Of=Am==="win32",{O_CREAT:Pf,O_NOFOLLOW:Qd,O_TRUNC:Lf,O_WRONLY:Nf}=kf.constants,Mf=Number(process.env.__FAKE_FS_O_FILENAME__)||kf.constants.UV_FS_O_FILEMAP||0,Cm=Of&&!!Mf,Tm=512*1024,Dm=Mf|Lf|Pf|Nf,ef=!Of&&typeof Qd=="number"?Qd|Lf|Pf|Nf:null,Bf=ef!==null?()=>ef:Cm?t=>t<Tm?Dm:"w":()=>"w",ja=(t,e,r)=>{try{return ks.lchownSync(t,e,r)}catch(s){if(s?.code!=="ENOENT")throw s}},vs=(t,e,r,s)=>{ks.lchown(t,e,r,a=>{s(a&&a?.code!=="ENOENT"?a:null)})},Rm=(t,e,r,s,a)=>{if(e.isDirectory())zf(ei.resolve(t,e.name),r,s,c=>{if(c)return a(c);let f=ei.resolve(t,e.name);vs(f,r,s,a)});else{let c=ei.resolve(t,e.name);vs(c,r,s,a)}},zf=(t,e,r,s)=>{ks.readdir(t,{withFileTypes:!0},(a,c)=>{if(a){if(a.code==="ENOENT")return s();if(a.code!=="ENOTDIR"&&a.code!=="ENOTSUP")return s(a)}if(a||!c.length)return vs(t,e,r,s);let f=c.length,l=null,x=h=>{if(!l){if(h)return s(l=h);if(--f===0)return vs(t,e,r,s)}};for(let h of c)Rm(t,h,e,r,x)})},km=(t,e,r,s)=>{e.isDirectory()&&Ff(ei.resolve(t,e.name),r,s),ja(ei.resolve(t,e.name),r,s)},Ff=(t,e,r)=>{let s;try{s=ks.readdirSync(t,{withFileTypes:!0})}catch(a){let c=a;if(c?.code==="ENOENT")return;if(c?.code==="ENOTDIR"||c?.code==="ENOTSUP")return ja(t,e,r);throw c}for(let a of s)km(t,a,e,r);return ja(t,e,r)},Uf=class extends Error{path;code;syscall="chdir";constructor(t,e){super(`${e}: Cannot cd into '${t}'`),this.path=t,this.code=e}get name(){return"CwdError"}},Os=class extends Error{path;symlink;syscall="symlink";code="TAR_SYMLINK_ERROR";constructor(t,e){super("TAR_SYMLINK_ERROR: Cannot extract through symbolic link"),this.symlink=t,this.path=e}get name(){return"SymlinkError"}},Pm=(t,e)=>{Xe.stat(t,(r,s)=>{(r||!s.isDirectory())&&(r=new Uf(t,r?.code||"ENOTDIR")),e(r)})},Lm=(t,e,r)=>{t=Z(t);let s=e.umask??18,a=e.mode|448,c=(a&s)!==0,f=e.uid,l=e.gid,x=typeof f=="number"&&typeof l=="number"&&(f!==e.processUid||l!==e.processGid),h=e.preserve,m=e.unlink,E=Z(e.cwd),C=(y,v)=>{y?r(y):v&&x?zf(v,f,l,I=>C(I)):c?Xe.chmod(t,a,r):r()};if(t===E)return Pm(t,C);if(h)return Om.mkdir(t,{mode:a,recursive:!0}).then(y=>C(null,y??void 0),C);let _=Z(Is.relative(E,t)).split("/");Ga(E,_,a,m,E,void 0,C)},Ga=(t,e,r,s,a,c,f)=>{if(e.length===0)return f(null,c);let l=e.shift(),x=Z(Is.resolve(t+"/"+l));Xe.mkdir(x,r,qf(x,e,r,s,a,c,f))},qf=(t,e,r,s,a,c,f)=>l=>{l?Xe.lstat(t,(x,h)=>{if(x)x.path=x.path&&Z(x.path),f(x);else if(h.isDirectory())Ga(t,e,r,s,a,c,f);else if(s)Xe.unlink(t,m=>{if(m)return f(m);Xe.mkdir(t,r,qf(t,e,r,s,a,c,f))});else{if(h.isSymbolicLink())return f(new Os(t,t+"/"+e.join("/")));f(l)}}):(c=c||t,Ga(t,e,r,s,a,c,f))},Nm=t=>{let e=!1,r;try{e=Xe.statSync(t).isDirectory()}catch(s){r=s?.code}finally{if(!e)throw new Uf(t,r??"ENOTDIR")}},Mm=(t,e)=>{t=Z(t);let r=e.umask??18,s=e.mode|448,a=(s&r)!==0,c=e.uid,f=e.gid,l=typeof c=="number"&&typeof f=="number"&&(c!==e.processUid||f!==e.processGid),x=e.preserve,h=e.unlink,m=Z(e.cwd),E=y=>{y&&l&&Ff(y,c,f),a&&Xe.chmodSync(t,s)};if(t===m)return Nm(m),E();if(x)return E(Xe.mkdirSync(t,{mode:s,recursive:!0})??void 0);let C=Z(Is.relative(m,t)).split("/"),_;for(let y=C.shift(),v=m;y&&(v+="/"+y);y=C.shift()){v=Z(Is.resolve(v));try{Xe.mkdirSync(v,s),_=_||v}catch{let I=Xe.lstatSync(v);if(I.isDirectory())continue;if(h){Xe.unlinkSync(v),Xe.mkdirSync(v,s),_=_||v;continue}else if(I.isSymbolicLink())return new Os(v,v+"/"+C.join("/"))}}return E(_)},Ia=Object.create(null),tf=1e4,rr=new Set,Bm=t=>{rr.has(t)?rr.delete(t):Ia[t]=t.normalize("NFD").toLocaleLowerCase("en").toLocaleUpperCase("en"),rr.add(t);let e=Ia[t],r=rr.size-tf;if(r>tf/10){for(let s of rr)if(rr.delete(s),delete Ia[s],--r<=0)break}return e},zm=process.env.TESTING_TAR_FAKE_PLATFORM||process.platform,Fm=zm==="win32",Um=t=>t.split("/").slice(0,-1).reduce((e,r)=>{let s=e.at(-1);return s!==void 0&&(r=Hf(s,r)),e.push(r||"/"),e},[]),qm=class{#e=new Map;#n=new Map;#r=new Set;reserve(t,e){t=Fm?["win32 parallelization disabled"]:t.map(s=>Qr(Hf(Bm(s))));let r=new Set(t.map(s=>Um(s)).reduce((s,a)=>s.concat(a)));this.#n.set(e,{dirs:r,paths:t});for(let s of t){let a=this.#e.get(s);a?a.push(e):this.#e.set(s,[e])}for(let s of r){let a=this.#e.get(s);if(!a)this.#e.set(s,[new Set([e])]);else{let c=a.at(-1);c instanceof Set?c.add(e):a.push(new Set([e]))}}return this.#i(e)}#s(t){let e=this.#n.get(t);if(!e)throw new Error("function does not have any path reservations");return{paths:e.paths.map(r=>this.#e.get(r)),dirs:[...e.dirs].map(r=>this.#e.get(r))}}check(t){let{paths:e,dirs:r}=this.#s(t);return e.every(s=>s&&s[0]===t)&&r.every(s=>s&&s[0]instanceof Set&&s[0].has(t))}#i(t){return this.#r.has(t)||!this.check(t)?!1:(this.#r.add(t),t(()=>this.#t(t)),!0)}#t(t){if(!this.#r.has(t))return!1;let e=this.#n.get(t);if(!e)throw new Error("invalid reservation");let{paths:r,dirs:s}=e,a=new Set;for(let c of r){let f=this.#e.get(c);if(!f||f?.[0]!==t)continue;let l=f[1];if(!l){this.#e.delete(c);continue}if(f.shift(),typeof l=="function")a.add(l);else for(let x of l)a.add(x)}for(let c of s){let f=this.#e.get(c),l=f?.[0];if(!(!f||!(l instanceof Set)))if(l.size===1&&f.length===1){this.#e.delete(c);continue}else if(l.size===1){f.shift();let x=f[0];typeof x=="function"&&a.add(x)}else l.delete(t)}return this.#r.delete(t),a.forEach(c=>this.#i(c)),!0}},Hm=()=>process.umask(),nf=Symbol("onEntry"),Ka=Symbol("checkFs"),rf=Symbol("checkFs2"),Wa=Symbol("isReusable"),rt=Symbol("makeFs"),$a=Symbol("file"),Va=Symbol("directory"),ys=Symbol("link"),sf=Symbol("symlink"),of=Symbol("hardlink"),Yr=Symbol("ensureNoSymlink"),af=Symbol("unsupported"),cf=Symbol("checkPath"),Aa=Symbol("stripAbsolutePath"),dn=Symbol("mkdir"),Re=Symbol("onError"),ds=Symbol("pending"),df=Symbol("pend"),ir=Symbol("unpend"),Ca=Symbol("ended"),Ta=Symbol("maybeClose"),Ja=Symbol("skip"),ti=Symbol("doChown"),ni=Symbol("uid"),ri=Symbol("gid"),ii=Symbol("checkedCwd"),jm=process.env.TESTING_TAR_FAKE_PLATFORM||process.platform,si=jm==="win32",Gm=1024,Km=(t,e)=>{if(!si)return X.unlink(t,e);let r=t+".DELETE."+Rf(16).toString("hex");X.rename(t,r,s=>{if(s)return e(s);X.unlink(r,e)})},Wm=t=>{if(!si)return X.unlinkSync(t);let e=t+".DELETE."+Rf(16).toString("hex");X.renameSync(t,e),X.unlinkSync(e)},ff=(t,e,r)=>t!==void 0&&t===t>>>0?t:e!==void 0&&e===e>>>0?e:r,sc=class extends oi{[Ca]=!1;[ii]=!1;[ds]=0;reservations=new qm;transform;writable=!0;readable=!1;uid;gid;setOwner;preserveOwner;processGid;processUid;maxDepth;forceChown;win32;newer;keep;noMtime;preservePaths;unlink;cwd;strip;processUmask;umask;dmode;fmode;chmod;constructor(t={}){if(t.ondone=()=>{this[Ca]=!0,this[Ta]()},super(t),this.transform=t.transform,this.chmod=!!t.chmod,typeof t.uid=="number"||typeof t.gid=="number"){if(typeof t.uid!="number"||typeof t.gid!="number")throw new TypeError("cannot set owner without number uid and gid");if(t.preserveOwner)throw new TypeError("cannot preserve owner in archive and also set owner explicitly");this.uid=t.uid,this.gid=t.gid,this.setOwner=!0}else this.uid=void 0,this.gid=void 0,this.setOwner=!1;this.preserveOwner=t.preserveOwner===void 0&&typeof t.uid!="number"?!!(process.getuid&&process.getuid()===0):!!t.preserveOwner,this.processUid=(this.preserveOwner||this.setOwner)&&process.getuid?process.getuid():void 0,this.processGid=(this.preserveOwner||this.setOwner)&&process.getgid?process.getgid():void 0,this.maxDepth=typeof t.maxDepth=="number"?t.maxDepth:Gm,this.forceChown=t.forceChown===!0,this.win32=!!t.win32||si,this.newer=!!t.newer,this.keep=!!t.keep,this.noMtime=!!t.noMtime,this.preservePaths=!!t.preservePaths,this.unlink=!!t.unlink,this.cwd=Z(Se.resolve(t.cwd||process.cwd())),this.strip=Number(t.strip)||0,this.processUmask=this.chmod?typeof t.processUmask=="number"?t.processUmask:Hm():0,this.umask=typeof t.umask=="number"?t.umask:this.processUmask,this.dmode=t.dmode||511&~this.umask,this.fmode=t.fmode||438&~this.umask,this.on("entry",e=>this[nf](e))}warn(t,e,r={}){return(t==="TAR_BAD_ARCHIVE"||t==="TAR_ABORT")&&(r.recoverable=!1),super.warn(t,e,r)}[Ta](){this[Ca]&&this[ds]===0&&(this.emit("prefinish"),this.emit("finish"),this.emit("end"))}[Aa](t,e){let r=t[e],{type:s}=t;if(!r||this.preservePaths)return!0;let[a,c]=tc(r),f=c.replaceAll(/\\/g,"/").split("/");if(f.includes("..")||si&&/^[a-z]:\.\.$/i.test(f[0]??"")){if(e==="path"||s==="Link")return this.warn("TAR_ENTRY_ERROR",`${e} contains '..'`,{entry:t,[e]:r}),!1;let l=Se.posix.dirname(t.path),x=Se.posix.normalize(Se.posix.join(l,f.join("/")));if(x.startsWith("../")||x==="..")return this.warn("TAR_ENTRY_ERROR",`${e} escapes extraction directory`,{entry:t,[e]:r}),!1}return a&&(t[e]=String(c),this.warn("TAR_ENTRY_INFO",`stripping ${a} from absolute ${e}`,{entry:t,[e]:r})),!0}[cf](t){let e=Z(t.path),r=e.split("/");if(this.strip){if(r.length<this.strip)return!1;if(t.type==="Link"){let s=Z(String(t.linkpath)).split("/");if(s.length>=this.strip)t.linkpath=s.slice(this.strip).join("/");else return!1}r.splice(0,this.strip),t.path=r.join("/")}if(isFinite(this.maxDepth)&&r.length>this.maxDepth)return this.warn("TAR_ENTRY_ERROR","path excessively deep",{entry:t,path:e,depth:r.length,maxDepth:this.maxDepth}),!1;if(!this[Aa](t,"path")||!this[Aa](t,"linkpath"))return!1;if(t.absolute=Se.isAbsolute(t.path)?Z(Se.resolve(t.path)):Z(Se.resolve(this.cwd,t.path)),!this.preservePaths&&typeof t.absolute=="string"&&t.absolute.indexOf(this.cwd+"/")!==0&&t.absolute!==this.cwd)return this.warn("TAR_ENTRY_ERROR","path escaped extraction target",{entry:t,path:Z(t.path),resolvedPath:t.absolute,cwd:this.cwd}),!1;if(t.absolute===this.cwd&&t.type!=="Directory"&&t.type!=="GNUDumpDir")return!1;if(this.win32){let{root:s}=Se.win32.parse(String(t.absolute));t.absolute=s+jd(String(t.absolute).slice(s.length));let{root:a}=Se.win32.parse(t.path);t.path=a+jd(t.path.slice(a.length))}return!0}[nf](t){if(!this[cf](t))return t.resume();switch(Im.equal(typeof t.absolute,"string"),t.type){case"Directory":case"GNUDumpDir":t.mode&&(t.mode=t.mode|448);case"File":case"OldFile":case"ContiguousFile":case"Link":case"SymbolicLink":return this[Ka](t);default:return this[af](t)}}[Re](t,e){t.name==="CwdError"?this.emit("error",t):(this.warn("TAR_ENTRY_ERROR",t,{entry:e}),this[ir](),e.resume())}[dn](t,e,r){Lm(Z(t),{uid:this.uid,gid:this.gid,processUid:this.processUid,processGid:this.processGid,umask:this.processUmask,preserve:this.preservePaths,unlink:this.unlink,cwd:this.cwd,mode:e},r)}[ti](t){return this.forceChown||this.preserveOwner&&(typeof t.uid=="number"&&t.uid!==this.processUid||typeof t.gid=="number"&&t.gid!==this.processGid)||typeof this.uid=="number"&&this.uid!==this.processUid||typeof this.gid=="number"&&this.gid!==this.processGid}[ni](t){return ff(this.uid,t.uid,this.processUid)}[ri](t){return ff(this.gid,t.gid,this.processGid)}[$a](t,e){let r=typeof t.mode=="number"?t.mode&4095:this.fmode,s=new As(String(t.absolute),{flags:Bf(t.size),mode:r,autoClose:!1});s.on("error",l=>{s.fd&&X.close(s.fd,()=>{}),s.write=()=>!0,this[Re](l,t),e()});let a=1,c=l=>{if(l){s.fd&&X.close(s.fd,()=>{}),this[Re](l,t),e();return}--a===0&&s.fd!==void 0&&X.close(s.fd,x=>{x?this[Re](x,t):this[ir](),e()})};s.on("finish",()=>{let l=String(t.absolute),x=s.fd;if(typeof x=="number"&&t.mtime&&!this.noMtime){a++;let h=t.atime||new Date,m=t.mtime;X.futimes(x,h,m,E=>E?X.utimes(l,h,m,C=>c(C&&E)):c())}if(typeof x=="number"&&this[ti](t)){a++;let h=this[ni](t),m=this[ri](t);typeof h=="number"&&typeof m=="number"&&X.fchown(x,h,m,E=>E?X.chown(l,h,m,C=>c(C&&E)):c())}c()});let f=this.transform&&this.transform(t)||t;f!==t&&(f.on("error",l=>{this[Re](l,t),e()}),t.pipe(f)),f.pipe(s)}[Va](t,e){let r=typeof t.mode=="number"?t.mode&4095:this.dmode;this[dn](String(t.absolute),r,s=>{if(s){this[Re](s,t),e();return}let a=1,c=()=>{--a===0&&(e(),this[ir](),t.resume())};t.mtime&&!this.noMtime&&(a++,X.utimes(String(t.absolute),t.atime||new Date,t.mtime,c)),this[ti](t)&&(a++,X.chown(String(t.absolute),Number(this[ni](t)),Number(this[ri](t)),c)),c()})}[af](t){t.unsupported=!0,this.warn("TAR_ENTRY_UNSUPPORTED",`unsupported entry type: ${t.type}`,{entry:t}),t.resume()}[sf](t,e){let r=Z(Se.relative(this.cwd,Se.resolve(Se.dirname(String(t.absolute)),String(t.linkpath)))).split("/");this[Yr](t,this.cwd,r,()=>this[ys](t,String(t.linkpath),"symlink",e),s=>{this[Re](s,t),e()})}[of](t,e){let r=Z(Se.resolve(this.cwd,String(t.linkpath))),s=Z(String(t.linkpath)).split("/");this[Yr](t,this.cwd,s,()=>this[ys](t,r,"link",e),a=>{this[Re](a,t),e()})}[Yr](t,e,r,s,a){let c=r.shift();if(this.preservePaths||c===void 0)return s();let f=Se.resolve(e,c);X.lstat(f,(l,x)=>{if(l)return s();if(x?.isSymbolicLink())return a(new Os(f,Se.resolve(f,r.join("/"))));this[Yr](t,f,r,s,a)})}[df](){this[ds]++}[ir](){this[ds]--,this[Ta]()}[Ja](t){this[ir](),t.resume()}[Wa](t,e){return t.type==="File"&&!this.unlink&&e.isFile()&&e.nlink<=1&&!si}[Ka](t){this[df]();let e=[t.path];t.linkpath&&e.push(t.linkpath),this.reservations.reserve(e,r=>this[rf](t,r))}[rf](t,e){let r=f=>{e(f)},s=()=>{this[dn](this.cwd,this.dmode,f=>{if(f){this[Re](f,t),r();return}this[ii]=!0,a()})},a=()=>{if(t.absolute!==this.cwd){let f=Z(Se.dirname(String(t.absolute)));if(f!==this.cwd)return this[dn](f,this.dmode,l=>{if(l){this[Re](l,t),r();return}c()})}c()},c=()=>{X.lstat(String(t.absolute),(f,l)=>{if(l&&(this.keep||this.newer&&l.mtime>(t.mtime??l.mtime))){this[Ja](t),r();return}if(f||this[Wa](t,l))return this[rt](null,t,r);if(l.isDirectory()){if(t.type==="Directory"){let x=this.chmod&&t.mode&&(l.mode&4095)!==t.mode,h=m=>this[rt](m??null,t,r);return x?X.chmod(String(t.absolute),Number(t.mode),h):h()}if(t.absolute!==this.cwd)return X.rmdir(String(t.absolute),x=>this[rt](x??null,t,r))}if(t.absolute===this.cwd)return this[rt](null,t,r);Km(String(t.absolute),x=>this[rt](x??null,t,r))})};this[ii]?a():s()}[rt](t,e,r){if(t){this[Re](t,e),r();return}switch(e.type){case"File":case"OldFile":case"ContiguousFile":return this[$a](e,r);case"Link":return this[of](e,r);case"SymbolicLink":return this[sf](e,r);case"Directory":case"GNUDumpDir":return this[Va](e,r)}}[ys](t,e,r,s){X[r](e,String(t.absolute),a=>{a?this[Re](a,t):(this[ir](),t.resume()),s()})}},Jr=t=>{try{return[null,t()]}catch(e){return[e,null]}},jf=class extends sc{sync=!0;[rt](t,e){return super[rt](t,e,()=>{})}[Ka](t){if(!this[ii]){let a=this[dn](this.cwd,this.dmode);if(a)return this[Re](a,t);this[ii]=!0}if(t.absolute!==this.cwd){let a=Z(Se.dirname(String(t.absolute)));if(a!==this.cwd){let c=this[dn](a,this.dmode);if(c)return this[Re](c,t)}}let[e,r]=Jr(()=>X.lstatSync(String(t.absolute)));if(r&&(this.keep||this.newer&&r.mtime>(t.mtime??r.mtime)))return this[Ja](t);if(e||this[Wa](t,r))return this[rt](null,t);if(r.isDirectory()){if(t.type==="Directory"){let c=this.chmod&&t.mode&&(r.mode&4095)!==t.mode,[f]=c?Jr(()=>{X.chmodSync(String(t.absolute),Number(t.mode))}):[];return this[rt](f,t)}let[a]=Jr(()=>X.rmdirSync(String(t.absolute)));this[rt](a,t)}let[s]=t.absolute===this.cwd?[]:Jr(()=>Wm(String(t.absolute)));this[rt](s,t)}[$a](t,e){let r=typeof t.mode=="number"?t.mode&4095:this.fmode,s=f=>{let l;try{X.closeSync(a)}catch(x){l=x}(f||l)&&this[Re](f||l,t),e()},a;try{a=X.openSync(String(t.absolute),Bf(t.size),r)}catch(f){return s(f)}let c=this.transform&&this.transform(t)||t;c!==t&&(c.on("error",f=>this[Re](f,t)),t.pipe(c)),c.on("data",f=>{try{X.writeSync(a,f,0,f.length)}catch(l){s(l)}}),c.on("end",()=>{let f=null;if(t.mtime&&!this.noMtime){let l=t.atime||new Date,x=t.mtime;try{X.futimesSync(a,l,x)}catch(h){try{X.utimesSync(String(t.absolute),l,x)}catch{f=h}}}if(this[ti](t)){let l=this[ni](t),x=this[ri](t);try{X.fchownSync(a,Number(l),Number(x))}catch(h){try{X.chownSync(String(t.absolute),Number(l),Number(x))}catch{f=f||h}}}s(f)})}[Va](t,e){let r=typeof t.mode=="number"?t.mode&4095:this.dmode,s=this[dn](String(t.absolute),r);if(s){this[Re](s,t),e();return}if(t.mtime&&!this.noMtime)try{X.utimesSync(String(t.absolute),t.atime||new Date,t.mtime)}catch{}if(this[ti](t))try{X.chownSync(String(t.absolute),Number(this[ni](t)),Number(this[ri](t)))}catch{}e(),t.resume()}[dn](t,e){try{return Mm(Z(t),{uid:this.uid,gid:this.gid,processUid:this.processUid,processGid:this.processGid,umask:this.processUmask,preserve:this.preservePaths,unlink:this.unlink,cwd:this.cwd,mode:e})}catch(r){return r}}[Yr](t,e,r,s,a){if(this.preservePaths||r.length===0)return s();let c=e;for(let f of r){c=Se.resolve(c,f);let[l,x]=Jr(()=>X.lstatSync(c));if(l)return s();if(x.isSymbolicLink())return a(new Os(c,Se.resolve(e,r.join("/"))))}s()}[ys](t,e,r,s){let a=`${r}Sync`;try{X[a](e,String(t.absolute)),s(),t.resume()}catch(c){return this[Re](c,t)}}},$m=t=>{let e=new jf(t),r=t.file,s=Df.statSync(r),a=t.maxReadSize||16*1024*1024;new xg(r,{readSize:a,size:s.size}).pipe(e)},Vm=(t,e)=>{let r=new sc(t),s=t.maxReadSize||16*1024*1024,a=t.file;return new Promise((c,f)=>{r.on("error",f),r.on("close",c),Df.stat(a,(l,x)=>{if(l)f(l);else{let h=new Ya(a,{readSize:s,size:x.size});h.on("error",f),h.pipe(r)}})})},Gf=ai($m,Vm,t=>new jf(t),t=>new sc(t),(t,e)=>{e?.length&&bf(t,e)}),Jm=(t,e)=>{let r=new ic(t),s=!0,a,c;try{try{a=Ye.openSync(t.file,"r+")}catch(x){if(x?.code==="ENOENT")a=Ye.openSync(t.file,"w+");else throw x}let f=Ye.fstatSync(a),l=Buffer.alloc(512);e:for(c=0;c<f.size;c+=512){for(let m=0,E=0;m<512;m+=E){if(E=Ye.readSync(a,l,m,l.length-m,c+m),c===0&&l[0]===31&&l[1]===139)throw new Error("cannot append to compressed archives");if(!E)break e}let x=new Pn(l);if(!x.cksumValid)break;let h=512*Math.ceil((x.size||0)/512);if(c+h+512>f.size)break;c+=h,t.mtimeCache&&x.mtime&&t.mtimeCache.set(String(x.path),x.mtime)}s=!1,Zm(t,r,c,a,e)}finally{if(s)try{Ye.closeSync(a)}catch{}}},Zm=(t,e,r,s,a)=>{let c=new xf(t.file,{fd:s,start:r});e.pipe(c),Xm(e,a)},Ym=(t,e)=>{e=Array.from(e);let r=new Rs(t),s=(a,c,f)=>{let l=(C,_)=>{C?Ye.close(a,y=>f(C)):f(null,_)},x=0;if(c===0)return l(null,0);let h=0,m=Buffer.alloc(512),E=(C,_)=>{if(C||_===void 0)return l(C);if(h+=_,h<512&&_)return Ye.read(a,m,h,m.length-h,x+h,E);if(x===0&&m[0]===31&&m[1]===139)return l(new Error("cannot append to compressed archives"));if(h<512)return l(null,x);let y=new Pn(m);if(!y.cksumValid)return l(null,x);let v=512*Math.ceil((y.size??0)/512);if(x+v+512>c||(x+=v+512,x>=c))return l(null,x);t.mtimeCache&&y.mtime&&t.mtimeCache.set(String(y.path),y.mtime),h=0,Ye.read(a,m,0,512,x,E)};Ye.read(a,m,0,512,x,E)};return new Promise((a,c)=>{r.on("error",c);let f="r+",l=(x,h)=>{if(x&&x.code==="ENOENT"&&f==="r+")return f="w+",Ye.open(t.file,f,l);if(x||!h)return c(x);Ye.fstat(h,(m,E)=>{if(m)return Ye.close(h,()=>c(m));s(h,E.size,(C,_)=>{if(C)return c(C);let y=new As(t.file,{fd:h,start:_});r.pipe(y),y.on("error",c),y.on("close",a),Qm(r,e)})})};Ye.open(t.file,f,l)})},Xm=(t,e)=>{e.forEach(r=>{r.charAt(0)==="@"?ur({file:Kf.resolve(t.cwd,r.slice(1)),sync:!0,noResume:!0,onReadEntry:s=>t.add(s)}):t.add(r)}),t.end()},Qm=async(t,e)=>{for(let r of e)r.charAt(0)==="@"?await ur({file:Kf.resolve(String(t.cwd),r.slice(1)),noResume:!0,onReadEntry:s=>t.add(s)}):t.add(r);t.end()},Zr=ai(Jm,Ym,()=>{throw new TypeError("file is required")},()=>{throw new TypeError("file is required")},(t,e)=>{if(!Eg(t))throw new TypeError("file is required");if(t.gzip||t.brotli||t.zstd||t.file.endsWith(".br")||t.file.endsWith(".tbr"))throw new TypeError("cannot append to compressed archives");if(!e?.length)throw new TypeError("no paths specified to add/replace")}),qS=ai(Zr.syncFile,Zr.asyncFile,Zr.syncNoFile,Zr.asyncNoFile,(t,e=[])=>{Zr.validate?.(t,e),ew(t)}),ew=t=>{let e=t.filter;t.mtimeCache||(t.mtimeCache=new Map),t.filter=e?(r,s)=>e(r,s)&&!((t.mtimeCache?.get(r)??s.mtime??0)>(s.mtime??0)):(r,s)=>!((t.mtimeCache?.get(r)??s.mtime??0)>(s.mtime??0))};Yt();var St={PAIR:"_agent/pair",CREATE:"_agent/create",HEALTH:"_agent/health",LIST_SKILLS:"_agent/listSkills",ADD_SKILLS:"_agent/addSkills",REMOVE_SKILLS:"_agent/removeSkills",GET_FILE_TREE:"_agent/getFileTree",GET_FILE_CONTENT:"_agent/getFileContent",DETAIL:"_agent/detail",UPDATE:"_agent/update",DISCONNECT:"_agent/disconnect",SWITCH_MODEL:"_agent/switchModel",GEN_MODEL_TOKEN:"_agent/genModelToken",RESET:"_agent/reset",REPAIR:"_agent/repair",DELETE:"_agent/delete"};function ci(t){return t?.cozeDeployType==="cloud"?"cloud":"local"}function Wf(t){let e=t?.cozeAccountId?.trim();if(!(!e||e==="0"))return e}function $f(t){let e=t?.cozeGroupId?.trim();if(!(!e||e==="0"))return e}function Vf(t){let{_meta:e,...r}=t;return{stripped:r,meta:e}}function xr(t){if(!t?.cozeAgentId)throw new Error("missing _meta.cozeAgentId");return t.cozeAgentId}var D=class extends Error{code;retriable;cause;constructor(e,r,s){super(r),this.name="BridgeError",this.code=e,this.retriable=s?.retriable??!1,s?.cause!==void 0&&(this.cause=s.cause)}};ee();Me();function zt(t,e){if(ci(t)!=="cloud")throw new D("OPERATION_NOT_ALLOWED_FOR_LOCAL",`${e} is not allowed for local agent`)}function Ps(t){return t.startsWith("http://")||t.startsWith("https://")}function Ls(t){return t.endsWith("/")?t.slice(0,-1):t}ee();var Ns="1008033",Jf="1289";var Zf="pbbp2",Yf="https://www.coze.cn",Xf="/api/coze_claw/resource/get_frontier_key",nw="https://www.coze.cn",rw="wss://frontier.coze.cn";function Ms(t){return t??process.env.COZE_BRIDGE_HANDSHAKE_URL??nw}function Qf(t){return t??process.env.COZE_BRIDGE_FRONTIER_URL??rw}function hr(t){let e={},r=t?.ttEnv??process.env.COZE_BRIDGE_TT_ENV,s=t?.usePpe??process.env.COZE_BRIDGE_USE_PPE;return r&&(e["x-tt-env"]=r),s&&(e["x-use-ppe"]=s),e}function fi(t){return t?t.startsWith("boe_")?{ttEnv:t}:{ttEnv:t,usePpe:"1"}:{}}var di=H("handshake");async function oc(t){let e=Ms(t.endpoint),r=t.timeoutMs??1e4,s=`${Ls(e)}${Xf}?aid=${encodeURIComponent(Ns)}`,a={Authorization:`Bearer ${t.privatecode}`,Accept:"application/json",...hr(t.ppeOverride)},c=new AbortController,f=setTimeout(()=>c.abort(),r);di.info("frontier key handshake",{base:e});try{let l=await fetch(s,{method:"GET",headers:a,signal:c.signal}),x=l.headers.get("x-tt-logid")??"",h=l.headers.get("x-tt-trace-id")??"";if(!l.ok){let y=await l.text().catch(()=>"");throw new D("UPSTREAM_HANDSHAKE_FAILED",`handshake HTTP ${l.status} logid=${x}: ${y.slice(0,200)}`)}let m=await l.json();if(m.code!==void 0&&m.code!==0)throw new D("UPSTREAM_HANDSHAKE_FAILED",`handshake code=${m.code} msg=${m.msg??"-"} logid=${x}`);let E=m.data??{},C=typeof E.access_key=="string"&&E.access_key||typeof E.accessKey=="string"&&E.accessKey||void 0,_=typeof E.device_id=="string"&&E.device_id||typeof E.deviceId=="string"&&E.deviceId||void 0;if(!C||!_){let y=JSON.stringify(m).slice(0,500);throw new D("UPSTREAM_HANDSHAKE_FAILED",`handshake response missing access_key/device_id (also tried camelCase) logid=${x}: ${y}`)}return di.info("handshake ok",{remoteDeviceId:_,logid:x,traceId:h}),{accessKey:C,deviceId:_}}catch(l){if(l instanceof D)throw di.error("handshake failed (bridge error)",{base:e,message:l.message,code:l.code}),l;if(l.name==="AbortError")throw di.warn("handshake timeout",{base:e,timeoutMs:r}),new D("UPSTREAM_HANDSHAKE_FAILED",`handshake timeout (${r}ms)`,{cause:l});let x=l.cause;throw di.error("handshake error",{base:e,message:l instanceof Error?l.message:String(l),errno:x?.code,syscall:x?.syscall,cause:String(l).slice(0,300)}),new D("UPSTREAM_HANDSHAKE_FAILED",String(l),{cause:l})}finally{clearTimeout(f)}}var ac=process.env.COZE_BRIDGE_LLM_GATEWAY_URL?.trim()||"https://llm-gateway.coze.cn",vt="auto";function el(t){return{model:t.model??vt,...t.modelToken?{modelToken:t.modelToken}:{}}}function tl(t){return!t||t===vt}function nl(t){let e={};return t.modelToken?(e.ANTHROPIC_BASE_URL=ac,e.ANTHROPIC_AUTH_TOKEN=t.modelToken,e.ANTHROPIC_MODEL=t.model||vt,t.modelInfo?.contextWindow&&(e.CLAUDE_CODE_MAX_CONTEXT_TOKENS=String(t.modelInfo.contextWindow))):tl(t.model)||(e.ANTHROPIC_MODEL=t.model),e}function rl(t){let e=[];return t.modelToken?e.push("-c",`model="${t.model||vt}"`):tl(t.model)||e.push("-c",`model="${t.model}"`),t.modelToken&&(e.push("-c",'model_providers.coze.name="coze"'),e.push("-c",`model_providers.coze.base_url="${ac}/v1"`),e.push("-c",'model_providers.coze.env_key="OPENAI_API_KEY"'),e.push("-c",'model_providers.coze.wire_api="responses"'),e.push("-c","model_providers.coze.requires_openai_auth=false"),e.push("-c","model_providers.coze.supports_websockets=false"),e.push("-c",'model_provider="coze"'),t.modelInfo?.contextWindow&&e.push("-c",`model_context_window=${t.modelInfo.contextWindow}`)),e}function il(t){return t.modelToken?{OPENAI_API_KEY:t.modelToken}:{}}function cc(t,e){let{ttEnv:r,usePpe:s}=fi(t),a={};return r&&(a["x-tt-env"]=r),s&&(a["x-use-ppe"]=s),e&&(a["x-mock-scenario"]=e),a}function sl(t,e,r){if(!t.modelToken)return{};let s=cc(e,r);return Object.keys(s).length===0?{}:{ANTHROPIC_CUSTOM_HEADERS:Object.entries(s).map(([c,f])=>`${c}:${f}`).join(`
|
|
83
|
+
`)}}function dc(t){return`coze-session-${t.replace(/[^A-Za-z0-9_-]+/g,"-")}`}function ol(t,e,r){if(!t.modelToken)return null;let s=t.model||vt,a=cc(e,r),c=["text"];t.modelInfo?.capabilities?.image===!0&&c.push("image");let f={baseUrl:`${ac}/v1`,api:"openai-completions",apiKey:t.modelToken,models:[{id:s,name:s,reasoning:!1,input:c,cost:{input:0,output:0,cacheRead:0,cacheWrite:0},contextWindow:t.modelInfo?.contextWindow??128e3,maxTokens:8192,api:"openai-completions"}]};return Object.keys(a).length>0&&(f.headers=a),f}function al(t,e,r){if(!t.modelToken)return[];let s=cc(e,r),a=[];for(let[c,f]of Object.entries(s))a.push("-c",`model_providers.coze.http_headers.${c}="${f}"`);return a}var ke=H("agent-handlers"),cl=5*1024*1024,dw=1,fw=6,lw=new Set(["node_modules",".git",".coze","dist","build",".next"]),Bs=class{constructor(e){this.opts=e}opts;async listSkills(e){zt(e._meta,"_agent/listSkills");let r=xr(e._meta),s=await this.loadAgentCfg(r),a=s?.workspace??kt(r).workspace,c=s?.skills??[],f=[];for(let l of c){let x=It(a,l.relPath,"SKILL.md");await ow(x).then(m=>m.isFile()).catch(()=>!1)&&f.push(gw(l))}return{skills:f}}async addSkills(e){zt(e._meta,"_agent/addSkills");let r=xr(e._meta),s=await this.requireAgentCfg(r),a=e.skills??[],c=[...s.skills??[]],f=new Map(c.map((x,h)=>[x.skillId,h])),l=[];for(let x of a){let h=await gc({agentId:r,workspace:s.workspace,framework:s.framework,skill:x});mc(c,f,h),l.push(x)}return await Hi(r,c),this.reloadAgentSessions(r,"skills-added"),{installedSkills:l}}async removeSkills(e){zt(e._meta,"_agent/removeSkills");let r=xr(e._meta),s=await this.requireAgentCfg(r),a=new Set(e.skillIds??[]),c=s.skills??[],f=[];for(let l of c){if(!a.has(l.skillId)){f.push(l);continue}let x=It(s.workspace,l.relPath);await sw(x,{recursive:!0,force:!0}),ke.info("skill removed",{agentId:r,skillId:l.skillId,relPath:l.relPath})}return await Hi(r,f),this.reloadAgentSessions(r,"skills-removed"),{ok:!0}}reloadAgentSessionsPublic(e,r){this.reloadAgentSessions(e,r)}reloadAgentSessions(e,r){let s=this.opts.agents.get(e);if(s)for(let[a,c]of s.sessions){if(!c.downstream)continue;let f=c.acpSessionId;if(f&&s.activeTriggers.has(f)||this.isRuntimePendingPermission(c)){c.reloadAfterTurn=!0,ke.info("downstream busy, scheduling reload after turn",{reason:r,agentId:e,framework:s.framework,cloudId:a,acpId:f});continue}let x=c.downstream;c.downstream=void 0,ke.info("killing downstream for workspace reload (idle)",{reason:r,agentId:e,framework:s.framework,cloudId:a,acpId:f}),x.stop(r).catch(h=>ke.warn("downstream stop failed during reload (ignored)",{reason:r,agentId:e,cloudId:a,err:String(h)}))}}isRuntimePendingPermission(e){let r=this.opts.isRuntimePendingPermission;return!r||!e.downstream?!1:r(e.downstream)}async updateAgent(e){if(!e.cozeIdentity?.trim())return ke.info("_agent/update: empty cozeIdentity, noop",{agentId:e.agentId}),{ok:!0};let r=e.agentId,s=await Ue(r);if(!s)throw new D("AGENT_NOT_FOUND",`agent not found: ${r}`);if(s.cozeIdentity===e.cozeIdentity)return ke.info("_agent/update: cozeIdentity unchanged, noop",{agentId:r}),{ok:!0};try{await Zn(s.workspace,s.framework,e.cozeIdentity)}catch(a){throw ke.error("_agent/update: writeInstructionFile failed, aborting update",{agentId:r,framework:s.framework,workspace:s.workspace,err:String(a)}),new D("AGENT_PROTOCOL_ERROR",`failed to write instruction file for agent ${r}: ${String(a)}`,{cause:a})}return s.cozeIdentity=e.cozeIdentity,await Ve(s),ke.info("_agent/update: cozeIdentity rewritten",{agentId:r,framework:s.framework}),this.reloadAgentSessions(r,"identity-changed"),{ok:!0}}async disconnectAgent(e){let r=e.agentId;if(!r)throw new D("IPC_BAD_REQUEST","_agent/disconnect: missing agentId");let s=await Ue(r);return s?(s.disconnectedAt=Date.now(),s.disconnectReason=e.reason??"",await Ve(s),ke.info("agent disconnected",{agentId:r,reason:e.reason??"",force:e.force??!1}),this.opts.disposeAndMarkDisconnected&&await this.opts.disposeAndMarkDisconnected(r,e.reason??"disconnect"),{ok:!0}):(ke.warn("_agent/disconnect: agent not found, ignoring",{agentId:r}),{ok:!0})}async switchModel(e){if(zt(e._meta,"_agent/switchModel"),!e.agentId)throw new D("IPC_BAD_REQUEST","_agent/switchModel: missing agentId");let r=e.model?.trim()?e.model:vt,s=await Ue(e.agentId);if(!s)throw new D("AGENT_NOT_FOUND",`agent not found: ${e.agentId}`);s.model=r,e.modelInfo&&(s.modelInfo=e.modelInfo),await Ve(s),ke.info("_agent/switchModel: model persisted",{agentId:e.agentId,model:r,reason:e.reason??""});let a=this.opts.agents.get(e.agentId);if(!a)return ke.info("_agent/switchModel: agent not running, config persisted only",{agentId:e.agentId}),{ok:!0};a.model=r,e.modelInfo&&a.setModelInfo(e.modelInfo),this.opts.cleanupOpenclawProviders&&await this.opts.cleanupOpenclawProviders(a).catch(f=>ke.warn("cleanupOpenclawProviders before switchModel failed (ignored)",{agentId:e.agentId,err:String(f)}));let c=[];for(let[f,l]of a.allSessionQueues())c.push(l.enqueue(async()=>{let x=a.sessions.get(f);x?.downstream&&(await x.downstream.stop(`switchModel: ${r}`).catch(()=>{}),x.downstream=void 0)}));return await Promise.all(c),ke.info("_agent/switchModel: all session runtimes killed, next prompt will respawn",{agentId:e.agentId,model:r,cloudSessions:c.length}),{ok:!0}}async resetAgent(e){if(zt(e._meta,St.RESET),!e.agentId)throw new D("IPC_BAD_REQUEST",`${St.RESET}: missing agentId`);return await this.runDetailSync(e.agentId,St.RESET,e.reason),{ok:!0}}async repairAgent(e){if(zt(e._meta,St.REPAIR),!e.agentId)throw new D("IPC_BAD_REQUEST",`${St.REPAIR}: missing agentId`);let r=await this.loadAgentCfg(e.agentId);if(r&&r.framework!=="openclaw")throw new D("IPC_BAD_REQUEST",`${St.REPAIR} only allowed for openclaw, got ${r.framework}`);if(r&&this.opts.openclawRepair)try{await this.opts.openclawRepair(e.agentId,r.workspace)}catch(s){ke.warn("openclaw repair (delete+add) failed (ignored)",{agentId:e.agentId,reason:e.reason,err:String(s)})}return await this.runDetailSync(e.agentId,St.REPAIR,e.reason),{ok:!0}}async runDetailSync(e,r,s){if(!this.opts.detailSyncer){ke.warn("detailSyncer not wired, skipping sync",{method:r,agentId:e});return}try{await this.opts.detailSyncer(e)}catch(a){ke.warn("detail sync failed (ignored)",{method:r,agentId:e,reason:s,err:String(a)})}}async getFileTree(e){zt(e._meta,"_agent/getFileTree");let r=e._meta,s=xr(r),a=await this.resolveWorkspace(s),c=e.filePath??"",f=this.safeJoin(a,c),l=await fc(f).catch(()=>null);if(!l)throw new D("IPC_BAD_REQUEST",`path not found: ${c}`);if(l.isSymbolicLink())throw new D("IPC_BAD_REQUEST",`symlink not allowed: ${c}`);if(!await Nr(f,a))throw new D("IPC_BAD_REQUEST",`path escapes workspace: ${c}`);let x=Cw(e.depth);return l.isDirectory()?{tree:await Aw(a,f,c,x)}:{tree:[{name:Tw(c),path:pl(c||"."),isDir:!1,size:l.size,modifiedAt:Math.floor(l.mtimeMs)}]}}async getFileContent(e){zt(e._meta,"_agent/getFileContent");let r=xr(e._meta),s=await this.resolveWorkspace(r);if(!e.filePath)throw new D("IPC_BAD_REQUEST","filePath required");let a=this.safeJoin(s,e.filePath),c=await fc(a).catch(()=>null);if(!c||!c.isFile())throw new D("IPC_BAD_REQUEST",`not a file: ${e.filePath}`);if(c.isSymbolicLink())throw new D("IPC_BAD_REQUEST",`symlink not allowed: ${e.filePath}`);if(!await Nr(a,s))throw new D("IPC_BAD_REQUEST",`path escapes workspace: ${e.filePath}`);if(c.size>cl)throw new D("IPC_BAD_REQUEST",`file too large: ${c.size} bytes (max ${cl})`);let f=await dl(a);return f.includes(0)?{content:f.toString("base64"),encoding:"base64",size:c.size}:{content:f.toString("utf8"),encoding:"utf-8",size:c.size}}async resolveWorkspace(e){let r=this.opts.agents.get(e);return r?r.workspace:(await Ue(e).catch(()=>null))?.workspace??kt(e).workspace}safeJoin(e,r){let s=xc(e,r||"."),a=pc(e,s);if(a.startsWith("..")||a===".."||a.startsWith(`..${fl}`))throw new D("IPC_BAD_REQUEST",`path escapes workspace: ${r}`);return s}loadAgentCfg(e){return Ue(e)}async requireAgentCfg(e){let r=await this.loadAgentCfg(e);if(!r)throw new D("AGENT_NOT_FOUND",`no config for agent: ${e}`);return r}};function uw(t){let e=t.trim().replace(/[\x00-\x1f<>:"|?*/\\]+/g,"-").replace(/^[\s.-]+|[\s.-]+$/g,"").slice(0,64);if(!e||e==="."||e==="..")throw new D("IPC_BAD_REQUEST",`invalid skill name: ${t}`);if(/^(con|prn|aux|nul|com[1-9]|lpt[1-9])$/i.test(e))throw new D("IPC_BAD_REQUEST",`reserved windows filename: ${t}`);return e}function xw(t){return t==="claude-code"?It(".claude","skills"):It(".agents","skills")}var hw=3e4,pw=50*1024*1024,pr=3e4;async function gc(t){let{agentId:e,workspace:r,framework:s,skill:a}=t;if(!a.skillName)throw new D("IPC_BAD_REQUEST","skill missing skillName");let c=typeof a.content=="string"&&a.content.length>0,f=typeof a.downloadUrl=="string"&&a.downloadUrl.length>0;if(!c&&!f)throw new D("IPC_BAD_REQUEST",`skill ${a.skillId} missing both content and downloadUrl`);let l=uw(a.skillName),x=xw(s),h=It(x,l),m=It(r,h);if(await lc(m,{recursive:!0}),c){let C=Buffer.from(a.content,"utf8");li(C.length),await uc(It(m,"SKILL.md"),C,"utf8")}else{let C=await mw(a.downloadUrl);_w(C)?await Sw(C,m):yw(C)?await Ew(C,m):await uc(It(m,"SKILL.md"),C.toString("utf8"),"utf8")}let E={skillId:a.skillId,skillName:a.skillName,relPath:h,installedAt:Date.now(),...a.description?{description:a.description}:{},...a.icon?{icon:a.icon}:{},...a.version?{version:a.version}:{},...a.downloadUrl?{downloadUrl:a.downloadUrl}:{},...a.config?{config:a.config}:{},...a.builtin?{builtin:a.builtin}:{}};return ke.info("skill installed",{agentId:e,skillId:a.skillId,skillName:a.skillName,relPath:h,source:c?"content":"downloadUrl"}),E}function mc(t,e,r){let s=e.get(r.skillId);if(s!==void 0){t[s]=r;return}e.set(r.skillId,t.length),t.push(r)}function gw(t){return{skillId:t.skillId,skillName:t.skillName,...t.description?{description:t.description}:{},...t.icon?{icon:t.icon}:{},...t.version?{version:t.version}:{},...t.config?{config:t.config}:{},...t.builtin?{builtin:t.builtin}:{}}}async function mw(t){if(!t)throw new D("IPC_BAD_REQUEST","skill missing downloadUrl");if(t.startsWith("data:")){let e=Math.floor(t.length*3/4);li(e);let r=ww(t);return li(r.length),r}if(t.startsWith("file:")){let e=new URL(t).pathname,r=await dl(e);return li(r.length),r}if(Ps(t)){let e=new AbortController,r=setTimeout(()=>e.abort(),hw);try{let s=await fetch(t,{signal:e.signal});if(!s.ok)throw new D("IPC_BAD_REQUEST",`fetch skill failed HTTP ${s.status} ${t}`);let a=await s.arrayBuffer();return li(a.byteLength),Buffer.from(a)}finally{clearTimeout(r)}}throw new D("IPC_BAD_REQUEST",`unsupported downloadUrl scheme (\u8981 https/data/file): ${t.slice(0,80)}`)}function li(t){if(t>pw)throw new D("IPC_BAD_REQUEST",`skill too large: ${t} bytes`)}function ww(t){let e=/^data:([^,;]*)(;base64)?,(.*)$/s.exec(t);if(!e)throw new D("IPC_BAD_REQUEST","bad data URL");let r=!!e[2],s=e[3]??"";return r?Buffer.from(s,"base64"):Buffer.from(decodeURIComponent(s),"utf8")}function _w(t){return t.length>=2&&t[0]===31&&t[1]===139}function yw(t){if(t.length<4||t[0]!==80||t[1]!==75)return!1;let e=t[2],r=t[3];return e===3&&r===4||e===5&&r===6}function hc(t){return t==="__MACOSX"||t.startsWith("__MACOSX/")}async function Ew(t,e){let r,s;try{r=new xl.default(t),s=r.getEntries()}catch(f){throw new D("IPC_BAD_REQUEST",`zip parse failed: ${f.message}`,{cause:f})}for(let f of s){let l=f.entryName;if(!l||hc(l))continue;if(l.startsWith("/")||/^[A-Za-z]:[\\/]/.test(l))throw new D("IPC_BAD_REQUEST",`zip entry absolute path: ${l}`);if(l.split(/[/\\]/).some(h=>h===".."))throw new D("IPC_BAD_REQUEST",`zip entry contains '..' (traversal): ${l}`);let x=f.header.attr>>>16&61440;if(x!==0&&x!==32768&&x!==16384)throw new D("IPC_BAD_REQUEST",`zip entry kind 0x${x.toString(16)} not allowed (symlink/hardlink/special): ${l}`)}let a=bw(s),c=xc(e);for(let f of s){if(hc(f.entryName))continue;let l=f.entryName;if(a&&l.startsWith(a)&&(l=l.slice(a.length)),!l)continue;let x=xc(e,l),h=pc(c,x);if(h.startsWith("..")||h==="..")throw new D("IPC_BAD_REQUEST",`zip entry escapes destDir: ${l}`);if(f.isDirectory){await lc(x,{recursive:!0});continue}await lc(aw(x),{recursive:!0});let m;try{m=f.getData()}catch(E){throw new D("IPC_BAD_REQUEST",`zip entry getData failed (${f.entryName}): ${E.message}`,{cause:E})}await uc(x,m)}}function bw(t){let e;for(let r of t){let s=r.entryName;if(!s||hc(s))continue;let a=s.indexOf("/");if(a<=0)return;let c=s.slice(0,a+1);if(e===void 0)e=c;else if(e!==c)return}return e}async function Sw(t,e){await vw(t);let r=Gf({cwd:e,strip:1}),s=!1,a=setTimeout(()=>{s=!0,r.destroy(new D("IPC_BAD_REQUEST",`tar extract timeout (${pr}ms)`))},pr);try{await ul(ll.from(t),r)}catch(c){throw c instanceof D?c:s?new D("IPC_BAD_REQUEST",`tar extract timeout (${pr}ms)`):new D("IPC_BAD_REQUEST",`tar extract failed: ${c.message??String(c)}`,{cause:c})}finally{clearTimeout(a)}}async function vw(t){let e=[],r=ur({onReadEntry:c=>{let f=c.path,l=c.type;if(l!=="File"&&l!=="Directory"){e.push(`tar entry kind '${l}' not allowed (symlink/hardlink/special): ${f.slice(0,100)}`);return}if(f.startsWith("/")||f.startsWith("\\")||/^[a-zA-Z]:[\\/]/.test(f)){e.push(`tar entry absolute path: ${f}`);return}f.split(/[/\\]/).some(h=>h==="..")&&e.push(`tar entry contains '..': ${f}`)}}),s=!1,a=setTimeout(()=>{s=!0,r.destroy(new D("IPC_BAD_REQUEST",`tar list timeout (${pr}ms)`))},pr);try{await ul(ll.from(t),r)}catch(c){throw s?new D("IPC_BAD_REQUEST",`tar list timeout (${pr}ms)`):new D("IPC_BAD_REQUEST",`tar list failed: ${c.message??String(c)}`,{cause:c})}finally{clearTimeout(a)}if(e.length>0)throw new D("IPC_BAD_REQUEST",e[0]??"tar entry validation failed")}var Iw=5e3;async function Aw(t,e,r,s){return hl(t,e,r,s,{count:0})}async function hl(t,e,r,s,a){if(s<=0)return[];let c;try{c=await iw(e,{withFileTypes:!0})}catch{return[]}let f=[];for(let l of c){if(lw.has(l.name)||l.isSymbolicLink())continue;if(a.count>=Iw){f.push({name:"...",path:"...",isDir:!1,size:0,modifiedAt:0,hasMore:!0});break}let x=It(e,l.name),h=cw(It(r,l.name)),m=null;try{m=await fc(x)}catch{continue}if(m.isSymbolicLink())continue;a.count++;let E={name:l.name,path:pl(pc(t,x)),isDir:m.isDirectory(),size:m.size,modifiedAt:Math.floor(m.mtimeMs)};m.isDirectory()&&s>1&&(E.children=await hl(t,x,h,s-1,a)),f.push(E)}return f.sort((l,x)=>l.isDir!==x.isDir?l.isDir?-1:1:l.name.localeCompare(x.name)),f}function Cw(t){return!t||t<=0?dw:Math.min(t,fw)}function Tw(t){if(!t||t==="."||t==="/")return".";let e=t.split(/[/\\]/);return e[e.length-1]||"."}function pl(t){return t.split(fl).join("/")}ee();import{readFileSync as Xv}from"node:fs";import{dirname as e1,join as t1}from"node:path";import{fileURLToPath as r1}from"node:url";var gr="0.1.82";var un=H("agent-health-reporter"),Dw=1e4,ui=class{constructor(e){this.opts=e;this.intervalMs=e.intervalMs??Dw}opts;timer=null;inFlight=!1;unsubscribeRegister=null;intervalMs;start(){this.timer||(this.timer=setInterval(()=>{this.tick()},this.intervalMs),this.timer.unref?.(),this.unsubscribeRegister=this.opts.core.onAgentRegister(()=>{this.tick()}),un.info("heartbeat started",{intervalMs:this.intervalMs}),this.tick())}stop(){this.timer&&(clearInterval(this.timer),this.timer=null,this.unsubscribeRegister&&(this.unsubscribeRegister(),this.unsubscribeRegister=null),un.info("heartbeat stopped"))}async tick(){if(this.inFlight){un.debug("previous tick still in-flight, skip");return}let e=this.opts.getDeviceId();if(!e){un.debug("deviceId not available, skip tick (\u5C1A\u672A pair)");return}this.inFlight=!0;try{let r=[];for(let f of this.opts.core.agents.values()){let l=Rw(f);if(!l)continue;let x={agentId:f.agentId,status:l};f.patToken&&(x.patToken=f.patToken),f.accountId&&(x.accountId=f.accountId),r.push(x)}if(r.length===0)return;let s={agents:r,bridgeVersion:gr,_meta:{cozeDeviceId:e}},a;try{a=await this.opts.core.sendRequest("_agent/health",s,5e3)}catch(f){un.warn("heartbeat batch send failed",{count:r.length,err:String(f)})}let c=a?.authFailures;if(c&&c.length>0&&(un.warn("heartbeat received authFailures from cloud",{count:c.length,agentIds:c.map(f=>f.agentId)}),this.opts.onAuthFailures))try{await this.opts.onAuthFailures(c)}catch(f){un.warn("onAuthFailures callback failed (ignored)",{err:String(f)})}}finally{this.inFlight=!1}if(this.opts.onTickEnd)try{await this.opts.onTickEnd()}catch(r){un.warn("onTickEnd hook failed",{err:String(r)})}}};function Rw(t){return t.status==="error"?"error":t.activeTriggers.size>0?"busy":t.status==="ok"?"online":null}Yt();import{mkdir as yc,rm as d_}from"node:fs/promises";Zt();Zt();import{spawnSync as zw}from"node:child_process";function xi(t,e,r){return r===void 0?{jsonrpc:"2.0",id:t,method:e}:{jsonrpc:"2.0",id:t,method:e,params:r}}function hi(t,e){return e===void 0?{jsonrpc:"2.0",method:t}:{jsonrpc:"2.0",method:t,params:e}}function mr(t,e){return{jsonrpc:"2.0",id:t,result:e}}function xn(t,e){return{jsonrpc:"2.0",id:t,error:e}}var zs=class extends Error{code;data;constructor(e){super(`JSON-RPC error code=${e.code} ${e.message}`),this.name="RemoteRpcError",this.code=e.code,e.data!==void 0&&(this.data=e.data)}},Q={PARSE_ERROR:-32700,INVALID_REQUEST:-32600,METHOD_NOT_FOUND:-32601,INVALID_PARAMS:-32602,INTERNAL_ERROR:-32603,AGENT_NOT_FOUND:-32001,AGENT_BUSY:-32002,AGENT_TIMEOUT:-32003,AGENT_SPAWN_FAILED:-32004,OPERATION_NOT_ALLOWED_FOR_LOCAL:-32005,AGENT_DISCONNECTED:-32006,MODEL_TOKEN_GEN_FAILED:-32009,PATH_OUTSIDE_WORKSPACE:-32010,FILE_TOO_LARGE:-32011,UNSUPPORTED_MIME:-32012,UPLOAD_FAILED:-32013,UPSTREAM_NOT_READY:-32014,AGENT_FRAME_IDLE_TIMEOUT:-32016,MODEL_MODALITY_UNSUPPORTED:-32017};function gl(t){return"method"in t&&"id"in t&&t.id!==void 0}function ml(t){return"method"in t&&!("id"in t)}function Fs(t){return!("method"in t)&&"id"in t}var kw={AGENT_NOT_FOUND:Q.AGENT_NOT_FOUND,AGENT_BUSY:Q.AGENT_BUSY,AGENT_DISCONNECTED:Q.AGENT_DISCONNECTED,AGENT_TIMEOUT:Q.AGENT_TIMEOUT,AGENT_FRAME_IDLE_TIMEOUT:Q.AGENT_FRAME_IDLE_TIMEOUT,AGENT_SPAWN_FAILED:Q.AGENT_SPAWN_FAILED,AGENT_PROTOCOL_ERROR:Q.INTERNAL_ERROR,BRIDGE_CONFIG_INVALID:Q.INTERNAL_ERROR,BRIDGE_INTERNAL:Q.INTERNAL_ERROR,IPC_AUTH_FAILED:Q.INTERNAL_ERROR,IPC_BAD_REQUEST:Q.INVALID_REQUEST,MODEL_TOKEN_GEN_FAILED:Q.MODEL_TOKEN_GEN_FAILED,MODEL_MODALITY_UNSUPPORTED:Q.MODEL_MODALITY_UNSUPPORTED,OPERATION_NOT_ALLOWED_FOR_LOCAL:Q.OPERATION_NOT_ALLOWED_FOR_LOCAL,UPSTREAM_DISCONNECTED:Q.INTERNAL_ERROR,UPSTREAM_HANDSHAKE_FAILED:Q.INTERNAL_ERROR,PATH_OUTSIDE_WORKSPACE:Q.PATH_OUTSIDE_WORKSPACE,FILE_TOO_LARGE:Q.FILE_TOO_LARGE,UNSUPPORTED_MIME:Q.UNSUPPORTED_MIME,UPLOAD_FAILED:Q.UPLOAD_FAILED,UPSTREAM_NOT_READY:Q.UPSTREAM_NOT_READY,NPX_CACHE_CORRUPT:Q.INTERNAL_ERROR};function Ow(t){if(t!=null)return t instanceof Error?{name:t.name,message:pi(t.message)}:typeof t=="string"?pi(t):typeof t=="object"?Lw(t):t}var Pw=[[/\/Users\/[^/\s'"`)]+/g,"/Users/<redacted>"],[/\/home\/[^/\s'"`)]+/g,"/home/<redacted>"],[/[A-Za-z]:\\Users\\[^\\\s'"`)]+/g,"C:\\Users\\<redacted>"],[/(Bearer|Token|Authorization:)\s+[\w._-]+/gi,"$1 <redacted>"],[/\b(sk|pat|ak)[-_][A-Za-z0-9_-]{20,}\b/g,"<redacted-key>"]];function pi(t){let e=t;for(let[r,s]of Pw)e=e.replace(r,s);return e}function Lw(t){let e={};for(let[r,s]of Object.entries(t))typeof s=="string"?e[r]=pi(s):e[r]=s;return e}function gi(t){if(t instanceof D){let e=Ow(t.cause),r={bridgeCode:t.code,retriable:t.retriable};return e!==void 0&&(r.cause=e),{code:kw[t.code]??Q.INTERNAL_ERROR,message:pi(t.message),data:r}}return{code:Q.INTERNAL_ERROR,message:pi(t instanceof Error?t.message:String(t))}}function wl(t){let e=t.data,r=e?.bridgeCode??"AGENT_PROTOCOL_ERROR",s=!!e&&typeof e.message=="string"&&!!e.message,a=s?e?.message:t.message,c=t.data;if(s&&e){let{message:f,...l}=e;c=l}return new D(r,a,{retriable:e?.retriable??!1,cause:c})}function yl(t){return`${JSON.stringify(t)}
|
|
84
|
+
`}var _l=10*1024*1024,Us=class{buffer="";onError;constructor(e={}){this.onError=e.onError}push(e){if(this.buffer+=typeof e=="string"?e:e.toString("utf8"),this.buffer.length>_l){let a=this.buffer.length;return this.buffer="",this.onError?.({line:`<buffer overflow: ${a} bytes, dropped>`,error:new Error(`LdjsonDecoder buffer exceeded ${_l} bytes`)}),[]}let r=this.buffer.split(`
|
|
85
|
+
`);this.buffer=r.pop()??"";let s=[];for(let a of r){let c=a.replace(/\r$/,"").trim();if(c)try{s.push(JSON.parse(c))}catch(f){this.onError?.({line:c,error:f})}}return s}flush(){if(!this.buffer)return[];let e=this.buffer.replace(/\r$/,"").trim();if(this.buffer="",!e)return[];try{return[JSON.parse(e)]}catch(r){return this.onError?.({line:e,error:r}),[]}}};var bl={"session/prompt":"session.prompt","session/cancel":"session.cancel","session/new":"session.new","session/load":"session.load","_agent/create":"agent.create","_agent/health":"agent.health","_agent/pair":"agent.pair","_agent/listSkills":"agent.listSkills","_agent/addSkills":"agent.addSkills","_agent/removeSkills":"agent.removeSkills","_agent/getFileTree":"agent.getFileTree","_agent/getFileContent":"agent.getFileContent","_agent/detail":"agent.detail","_agent/update":"agent.update","_agent/disconnect":"agent.disconnect","_agent/switchModel":"agent.switchModel","_agent/genModelToken":"agent.genModelToken","_agent/reset":"agent.reset","_agent/repair":"agent.repair","session/request_permission":"session.requestPermission",initialize:"initialize"},h1=Object.fromEntries(Object.entries(bl).map(([t,e])=>[e,t])),Nw={"session.prompt":["agentId","triggerMsgId","sessionId"],"session.cancel":["agentId","triggerMsgId","sessionId"],"session.new":["agentId"],"session.load":["agentId"],"agent.create":["agentId"],"agent.health":[],"agent.listSkills":["agentId"],"agent.addSkills":["agentId"],"agent.removeSkills":["agentId"],"agent.getFileTree":["agentId"],"agent.getFileContent":["agentId"],"agent.detail":["agentId"],"agent.update":["agentId"],"agent.disconnect":["agentId"],"agent.switchModel":["agentId"],"agent.genModelToken":["agentId","sessionId"],"agent.reset":["agentId"],"agent.repair":["agentId"],"session.requestPermission":["agentId","sessionId"],"agent.pair":[],initialize:[]},wr=class{seq=0;next(e,r){this.seq+=1;let s=bl[e]??Mw(e),a=Nw[s]??[],c=[s,String(this.seq)];if(a.length>0){let f=a.map(x=>El(r?.[x]??"")),l=Bw(f).join(":");l&&c.push(l)}else r&&Object.values(r).some(f=>f)&&c.push(Object.values(r).filter(Boolean).map(f=>El(String(f))).join(":"));return c.join("_")}reset(){this.seq=0}};function Mw(t){return t.replace(/[\s/]+/g,".").replace(/_+/g,"-")}function El(t){return t.replace(/[:_\s]+/g,"-")}function Bw(t){let e=t.length;for(;e>0&&!t[e-1];)e-=1;return t.slice(0,e)}Wn();function hn(t,e){let r=process.env[t];if(!r)return e;let s=Number(r);return Number.isFinite(s)&&s>0?s:e}ee();var Fw=hn("COZE_BRIDGE_INITIALIZE_TIMEOUT_MS",3e4),Uw=200,qw=/(ENOTEMPTY|EEXIST).*_npx[/\\]/;function wc(t){return t.some(e=>qw.test(e))}var Hw=hn("COZE_BRIDGE_SESSION_PROMPT_MAX_MS",3600*1e3),jw=hn("COZE_BRIDGE_SESSION_PROMPT_FRAME_IDLE_MS",600*1e3),Sl=500;function Gw(t){try{let e=JSON.stringify(t);return e===void 0||e.length<=Sl?t:`${e.slice(0,Sl)}...<truncated, total ${e.length} chars>`}catch{return"<unserializable>"}}function vl(t,e){if(!(typeof t!="number"||t<=0))try{if(process.platform==="win32"){let r=["/PID",String(t),"/T"];e==="SIGKILL"&&r.push("/F"),zw("taskkill",r,{stdio:"ignore",windowsHide:!0})}else process.kill(-t,e)}catch{}}var At=class{constructor(e){this.opts=e;this.log=H(`downstream.${this.constructor.name}`),this.decoder=new Us({onError:r=>this.log.warn("decode line failed",{line:r.line})})}opts;child;decoder;pending=new Map;inflightAgentRequests=new Map;idAllocator=new wr;updateHandlers=[];agentRequestHandlers=[];exitHandlers=[];log;stopped=!1;stderrRing=[];sanitizeEnv(e){return e}async start(){if(this.child)throw new D("BRIDGE_INTERNAL","Downstream already started");let e=process.platform!=="win32",r=Vt(this.opts.command,this.opts.args,{cwd:this.opts.cwd,env:{...this.sanitizeEnv(process.env),...this.opts.env},stdio:["pipe","pipe","pipe"],detached:e});this.child=r,r.stdout?.setEncoding("utf8"),r.stdout?.on("data",s=>{try{for(let a of this.decoder.push(s))this.dispatch(a)}catch(a){this.log.warn("stdout dispatch threw, swallowed to keep daemon alive",{err:String(a)})}}),r.stderr?.setEncoding("utf8"),r.stderr?.on("data",s=>{let a=s.trimEnd();this.stderrRing.push(a),this.stderrRing.length>Uw&&this.stderrRing.shift(),this.log.debug("stderr",{text:a})}),r.stdin?.on("error",s=>{this.log.warn("child stdin error",{err:String(s)})}),r.stdout?.on("error",s=>{this.log.warn("child stdout error",{err:String(s)})}),r.stderr?.on("error",s=>{this.log.warn("child stderr error",{err:String(s)})}),r.on("exit",(s,a)=>{this.stopped=!0,(s!==0||a!==null)&&this.stderrRing.length>0&&(this.log.warn("downstream exited abnormally, recent stderr",{code:s,signal:a,recentStderr:[...this.stderrRing]}),(this.framework==="claude-code"||this.framework==="codex")&&wc(this.stderrRing)&&(this.log.warn("npx cache corruption detected, triggering global install fallback (D93)",{framework:this.framework}),yn(this.framework).catch(l=>{this.log.warn("D93 fallback install failed (will retry next spawn cycle)",{framework:this.framework,err:String(l)})})));try{for(let f of this.decoder.flush())this.dispatch(f)}catch(f){this.log.debug("decoder.flush on exit threw (ignored)",{err:String(f)})}this.failAllPending(new D("AGENT_PROTOCOL_ERROR",`agent exited (${s}/${a})`));for(let f of this.exitHandlers)f(s,a)}),r.on("error",s=>{this.log.error("child error",{err:String(s)}),this.failAllPending(new D("AGENT_SPAWN_FAILED",String(s),{cause:s}))}),this.log.info("downstream started",{command:this.opts.command,pid:r.pid,cwd:this.opts.cwd})}async stop(e){if(!this.child||this.stopped)return;this.stopped=!0,this.log.info("downstream stopping",{reason:e});let r=this.child,s=new Promise(c=>r.once("exit",()=>c()));vl(r.pid,"SIGTERM");let a=setTimeout(()=>{r.killed||vl(r.pid,"SIGKILL")},5e3);try{await s}finally{clearTimeout(a)}}pid(){return this.child?.pid}isAlive(){return!!this.child&&!this.stopped}getStderrTail(){return[...this.stderrRing]}initialize(e){return this.call("initialize",e)}sessionNew(e){return this.call("session/new",{mcpServers:[],...e})}sessionLoad(e){return this.call("session/load",{mcpServers:[],...e})}sessionPrompt(e,r=Hw,s=jw){return this.call("session/prompt",e,r,s)}async sessionCancel(e){!this.child||this.stopped||this.writeFrame(hi("session/cancel",e))}onUpdate(e){this.updateHandlers.push(e)}onAgentRequest(e){this.agentRequestHandlers.push(e)}respondAgentRequest(e,r){if(this.inflightAgentRequests.delete(e),!(!this.child||this.stopped))try{this.writeFrame(mr(e,r))}catch(s){this.log.warn("respondAgentRequest write failed",{id:e,err:String(s)})}}respondAgentRequestError(e,r){if(this.inflightAgentRequests.delete(e),!(!this.child||this.stopped))try{this.writeFrame(xn(e,r))}catch(s){this.log.warn("respondAgentRequestError write failed",{id:e,err:String(s)})}}onExit(e){this.exitHandlers.push(e)}call(e,r,s=Fw,a=0){if(!this.child||this.stopped)return Promise.reject(new D("AGENT_PROTOCOL_ERROR","downstream not started"));let c=this.idAllocator.next(e),f=xi(c,e,r),l=(()=>{if(typeof r!="object"||r===null)return;let m=r.sessionId;return typeof m=="string"?m:void 0})(),x=s>0&&Number.isFinite(s),h=a>0&&Number.isFinite(a);return new Promise((m,E)=>{let C={resolve:m,reject:E,timer:null,frameIdleTimer:null,armFrameIdle:null,method:e};x&&(C.timer=setTimeout(()=>{this.pending.delete(c),C.frameIdleTimer&&clearTimeout(C.frameIdleTimer),this.log.warn("downstream call timeout",{id:c,method:e,timeoutMs:s,...l?{sessionId:l}:{}}),E(new D("AGENT_TIMEOUT",`${e} timed out after ${s}ms`))},s));let _=h?()=>{C.frameIdleTimer&&clearTimeout(C.frameIdleTimer),C.frameIdleTimer=setTimeout(()=>{if(this.inflightAgentRequests.size>0){this.log.debug("frame-idle fired but agent request inflight, re-arming",{id:c,method:e,inflight:this.inflightAgentRequests.size,...l?{sessionId:l}:{}}),_?.();return}C.timer&&clearTimeout(C.timer),this.pending.delete(c),this.log.warn("frame-idle timeout, rejecting pending call",{id:c,method:e,frameIdleMs:a,...l?{sessionId:l}:{}}),E(new D("AGENT_FRAME_IDLE_TIMEOUT",`${e} no session/update for ${a}ms (no inflight agent request)`))},a)}:null;C.armFrameIdle=_,this.pending.set(c,C),_?.();try{this.writeFrame(f)}catch(y){C.timer&&clearTimeout(C.timer),C.frameIdleTimer&&clearTimeout(C.frameIdleTimer),this.pending.delete(c),E(y)}})}writeFrame(e){if(!this.child?.stdin||this.child.stdin.destroyed)throw new D("AGENT_PROTOCOL_ERROR","downstream stdin not writable");this.child.stdin.write(yl(e),r=>{r&&this.log.warn("stdin write callback err",{err:String(r)})})}dispatch(e){if(Fs(e)){let r=e.id!==null?this.pending.get(e.id):void 0;if(!r){this.log.warn("orphan response",{id:e.id});return}this.pending.delete(e.id),r.timer&&clearTimeout(r.timer),r.frameIdleTimer&&clearTimeout(r.frameIdleTimer),e.error?(this.log.warn("downstream returned error frame",{id:e.id,method:r.method,code:e.error.code,message:e.error.message,data:e.error.data}),r.reject(wl(e.error))):e.result===void 0?(this.log.warn("downstream response missing both result and error",{id:e.id,method:r.method}),r.reject(new D("AGENT_PROTOCOL_ERROR",`${r.method} response missing both result and error`))):(this.log.info("downstream returned result",{id:e.id,method:r.method,result:Gw(e.result)}),r.resolve(e.result));return}if(ml(e)){if(e.method==="session/update"){for(let r of this.pending.values())r.armFrameIdle?.();for(let r of this.updateHandlers)try{Promise.resolve(r(e.params)).catch(s=>this.log.warn("update handler failed (async)",{err:String(s)}))}catch(s){this.log.warn("update handler threw sync, swallowed",{err:String(s)})}}else this.log.info("unknown notification (drop, not forwarded)",{method:e.method});return}if(gl(e)){let r=e;try{this.handleAgentRequest(r).catch(s=>this.log.error("agent request handler failed (async)",{method:r.method,err:String(s)}))}catch(s){this.log.warn("handleAgentRequest threw sync, swallowed",{method:r.method,err:String(s)})}}}async handleAgentRequest(e){if(this.agentRequestHandlers.length===0){this.writeFrame(xn(e.id,{code:-32601,message:`method not handled by Bridge: ${e.method}`}));return}this.inflightAgentRequests.set(e.id,e.method);for(let r of this.agentRequestHandlers)try{await r(e)}catch(s){this.log.error("agentRequestHandler threw",{method:e.method,err:String(s)});try{this.writeFrame(xn(e.id,gi(s)))}catch{}this.inflightAgentRequests.delete(e.id)}}failAllPending(e){for(let r of this.pending.values())r.timer&&clearTimeout(r.timer),r.frameIdleTimer&&clearTimeout(r.frameIdleTimer),r.reject(e);this.pending.clear(),this.inflightAgentRequests.clear()}};var Kw=Lr("claude-code")??"@agentclientprotocol/claude-agent-acp@^0.37";function Ww(t){let e={};for(let[r,s]of Object.entries(t))s!==void 0&&(r.startsWith("CLAUDE")||r==="AI_AGENT"||r==="BAGGAGE"||(e[r]=s));return e}var qs=class extends At{framework="claude-code";constructor(e){let r=Jt("claude-code"),[s,a]=r?[r,[]]:["npx",["-y",Kw]],c=e.command??s,f=e.args??a,l={command:c,args:f,cwd:e.cwd,...e.env?{env:e.env}:{}};super(l)}sanitizeEnv(e){return Ww(e)}};Zt();import{mkdtempSync as $w,rmSync as Vw}from"node:fs";import{tmpdir as Jw}from"node:os";import{join as Zw}from"node:path";var Yw=Lr("codex")??"@zed-industries/codex-acp@^0.15",Hs=class extends At{framework="codex";authMethodId;codexHomeDir;constructor(e){let r=Jt("codex"),[s,a]=r?[r,[]]:["npx",["-y",Yw]],c=e.command??s,f=e.args??a,l=e.extraArgs?[...f,...e.extraArgs]:f,x=e.isolateCodexHome?$w(Zw(Jw(),"coze-bridge-codex-home-")):void 0,h=x?{...e.env??{},CODEX_HOME:x}:e.env,m={command:c,args:l,cwd:e.cwd,...h?{env:h}:{}};super(m),this.authMethodId=e.authMethodId,this.codexHomeDir=x}async initialize(e){let r=await super.initialize(e);return this.authMethodId&&await this.call("authenticate",{methodId:this.authMethodId}),r}async stop(e){if(await super.stop(e),this.codexHomeDir)try{Vw(this.codexHomeDir,{recursive:!0,force:!0})}catch{}}};var Xw=3e4,_r=class extends At{framework="openclaw";agentId;sessionName;slashModelOnStart;constructor(e){let r=e.sessionName??"default",s=["acp","--session",`agent:${e.agentId}:${r}`];e.gatewayToken&&s.push("--token",e.gatewayToken);let a={command:e.command,args:s,cwd:e.cwd,...e.env?{env:e.env}:{}};super(a),this.agentId=e.agentId,this.sessionName=r,this.slashModelOnStart=e.slashModelOnStart}async afterSessionEstablished(e){this.slashModelOnStart&&(this.log.info("switching session to per-session provider via /model",{agentId:this.agentId,sessionName:this.sessionName,slash:this.slashModelOnStart}),await this.sessionPrompt({sessionId:e,prompt:[{type:"text",text:`/model ${this.slashModelOnStart}`}]},Xw))}get acpSessionName(){return this.sessionName}};ee();Me();function _c(t){return t.replace(/[^A-Za-z0-9._-]+/g,"-")}Zt();var yr=class{slots=[];running=!1;closed=!1;disposed=!1;enqueue(e){return this.disposed?Promise.reject(new Error("AsyncQueue disposed")):this.closed?Promise.reject(new Error("AsyncQueue closed")):new Promise((r,s)=>{this.slots.push({task:e,resolve:r,reject:s}),this.drain()})}close(){this.closed=!0}dispose(e=new Error("AsyncQueue disposed")){for(this.disposed=!0,this.closed=!0;this.slots.length>0;)this.slots.shift()?.reject(e)}get size(){return this.slots.length}get isRunning(){return this.running}get isDisposed(){return this.disposed}async drain(){if(!this.running){this.running=!0;try{for(;this.slots.length>0&&!this.disposed;){let e=this.slots.shift();if(!e)break;try{let r=await e.task();e.resolve(r)}catch(r){e.reject(r)}}}finally{this.running=!1}}}};var js=class{agentId;framework;workspace;deployType;accountId;patToken;modelInfo;sessions=new Map;sessionQueues=new Map;activeTriggers=new Map;activeGroupIds=new Map;status="ok";model;lastActiveAt=Date.now();constructor(e){this.agentId=e.agentId,this.framework=e.framework,this.workspace=e.workspace,this.model=e.model,this.deployType=e.deployType??"local",e.accountId&&(this.accountId=e.accountId),e.patToken&&(this.patToken=e.patToken),e.modelInfo&&(this.modelInfo=e.modelInfo)}setPatToken(e){this.patToken=e}setModelInfo(e){this.modelInfo=e}getSessionQueue(e){let r=this.sessionQueues.get(e);return(!r||r.isDisposed)&&(r=new yr,this.sessionQueues.set(e,r)),r}allSessionQueues(){return this.sessionQueues.entries()}hasSessionQueue(e){let r=this.sessionQueues.get(e);return!!r&&!r.isDisposed}async dispose(e){this.status="stopped";let r=new Error(`AgentSession disposed${e?`: ${e}`:""}`);for(let s of this.sessionQueues.values())s.dispose(r);this.sessionQueues.clear(),await this.killAllRuntimes(e??"dispose")}async killAllRuntimes(e){let r=[];for(let[,s]of this.sessions)mi(s),s.downstream&&(r.push(s.downstream.stop(e).catch(()=>{})),s.downstream=void 0);await Promise.all(r),this.activeTriggers.clear(),this.activeGroupIds.clear()}};function mi(t){t.idleTimer&&(clearTimeout(t.idleTimer),t.idleTimer=void 0)}Wn();ee();import{constants as Il,access as Qw}from"node:fs/promises";import{delimiter as e_,join as t_}from"node:path";var pn=H("framework-detector"),Al={"claude-code":"claude",codex:"codex",openclaw:"openclaw"},n_=[".exe",".cmd",".bat",".ps1"],gn=class{env;constructor(e={}){this.env={pathEnv:e.pathEnv??process.env.PATH??"",platform:e.platform??process.platform,spawn:e.spawn??Vt,access:e.access??Qw}}async detect(e){let r=Al[e],s=await this.which(r);if(!s)return pn.debug("framework binary not found",{framework:e,bin:r}),null;let a=e==="openclaw"?["--log-level","silent"]:[],[c,f]=await Promise.all([this.probeVersion(s,a),e==="openclaw"?this.probeOpenclawDefaultAgent(s):Promise.resolve(null)]),l={path:s,version:c};return f&&(l.defaultAgent=f),l}async detectAll(){let e=await Promise.all(Object.keys(Al).map(async s=>[s,await this.detect(s)])),r={};for(let[s,a]of e)a&&(r[s]=a);return r}async which(e){let r=this.env.pathEnv.split(e_).filter(Boolean),s=this.env.platform==="win32"?["",...n_]:[""];for(let a of r)for(let c of s){let f=t_(a,e+c);if(await this.isExecutable(f))return f}return null}async isExecutable(e){try{let r=this.env.platform==="win32"?Il.F_OK:Il.X_OK;return await this.env.access(e,r),!0}catch{return!1}}async probeOpenclawDefaultAgent(e){let r=await this.runProbe(e,["--log-level","silent","agents","list","--json"]);if(!r)return pn.warn("openclaw default agent probe: runProbe returned null (spawn err / timeout)",{path:e}),null;if(r.code!==0)return pn.warn("openclaw default agent probe: non-zero exit",{path:e,code:r.code,stdoutHead:r.stdout.slice(0,200)}),null;let s=r.stdout.match(/\[\s*\{[\s\S]*\}\s*\]/);if(!s)return pn.warn("openclaw default agent probe: regex no match (no JSON array in stdout)",{path:e,stdoutHead:r.stdout.slice(0,200)}),null;try{let a=JSON.parse(s[0]);if(!Array.isArray(a))return pn.warn("openclaw default agent probe: JSON parsed but not an array",{path:e}),null;let c=a.find(f=>f?.isDefault===!0);return c?!c.id||!c.workspace?(pn.warn("openclaw default agent probe: default agent missing id or workspace",{path:e,hasId:!!c.id,hasWorkspace:!!c.workspace}),null):{id:c.id,workspace:c.workspace}:(pn.info("openclaw default agent probe: no agent has isDefault=true",{path:e,agentCount:a.length}),null)}catch(a){return pn.warn("openclaw default agent probe: JSON.parse failed",{path:e,err:String(a),matchHead:s[0].slice(0,200)}),null}}async probeVersion(e,r=[]){let s=await this.runProbe(e,[...r,"--version"]);return s&&(i_(s.stdout).split(/\r?\n/)[0]??"").trim()||"unknown"}runProbe(e,r){return new Promise(s=>{let a="",c=!1,f,l=x=>{c||(c=!0,f&&clearTimeout(f),s(x))};try{let x=this.env.spawn(e,r,{stdio:["ignore","pipe","pipe"]});f=setTimeout(()=>{x.kill("SIGKILL"),l(null)},15e3),x.stdout?.on("data",h=>{a+=h.toString("utf8")}),x.on("error",()=>l(null)),x.on("close",h=>l({code:h,stdout:a}))}catch{l(null)}})}},r_=new RegExp("\x1B\\[[0-9;]*[A-Za-z]","g");function i_(t){return t.replace(r_,"")}import{spawn as s_}from"node:child_process";import{homedir as o_}from"node:os";import{join as a_}from"node:path";Ui();ee();async function Dl(){let t=a_(o_(),".openclaw/openclaw.json");return(await Jn(t))?.gateway?.auth?.token??""}var Cl=H("openclaw.config"),c_=[0,5e3,5e3],Tl="models.providers.",Gs="agents.defaults.models",Ks=class{command;env;retryDelaysMs;queue=new yr;constructor(e){this.command=e.command,this.env=e.env??process.env,this.retryDelaysMs=e.retryDelaysMs??c_}async withRetry(e,r){let s;for(let a=0;a<this.retryDelaysMs.length;a++){let c=this.retryDelaysMs[a]??0;c>0&&await new Promise(f=>setTimeout(f,c));try{return await r()}catch(f){s=f,Cl.warn("openclaw cli failed, will retry",{label:e,attempt:a+1,err:String(f)})}}throw new D("AGENT_SPAWN_FAILED",`openclaw cli ${e} failed after ${this.retryDelaysMs.length} attempts: ${s?.message??"unknown"}`)}runCli(e){return new Promise((r,s)=>{let a=s_(this.command,e,{stdio:["ignore","pipe","pipe"],env:this.env}),c="";a.stderr?.on("data",f=>{c+=f.toString("utf8")}),a.on("error",s),a.on("close",f=>{f===0?r():s(new Error(`exit ${f}: ${c.trim().slice(0,500)}`))})})}async runCliTolerant(e,r){try{await this.runCli(e)}catch(s){let a=String(s);if(r.some(c=>a.includes(c)))return;throw s}}async bestEffortUnset(e,r){try{await this.queue.enqueue(()=>this.withRetry(e,()=>this.runCli(["config","unset",r])))}catch(s){Cl.warn(`${e} failed (best-effort)`,{configPath:r,err:String(s)})}}ensureProvider(e,r){return this.queue.enqueue(()=>this.withRetry(`config set models.providers.${e}`,()=>this.runCli(["config","set",`${Tl}${e}`,JSON.stringify(r),"--strict-json","--merge"])))}removeProvider(e){return this.bestEffortUnset(`config unset models.providers.${e}`,`${Tl}${e}`)}addModelToAllowlist(e,r){let s={[e]:r?{alias:r}:{}};return this.queue.enqueue(()=>this.withRetry(`config set ${Gs}[${e}]`,()=>this.runCli(["config","set",Gs,JSON.stringify(s),"--strict-json","--merge"])))}removeModelFromAllowlist(e){return this.bestEffortUnset(`config unset ${Gs}[${e}]`,`${Gs}.${e}`)}ensureAgent(e,r,s){let a=["agents","add",e,"--workspace",r,"--non-interactive"];return s&&a.push("--model",s),this.queue.enqueue(()=>this.withRetry(`agents add ${e}`,()=>this.runCliTolerant(a,["already exists","already registered"])))}deleteAgent(e){return this.queue.enqueue(()=>this.withRetry(`agents delete ${e}`,()=>this.runCliTolerant(["agents","delete",e,"--force"],["not found","does not exist"])))}};var Oe=H("agent-manager"),f_=(t,e,r,s,a,c,f,l,x)=>{switch(t){case"claude-code":{let h={...a?{...nl(a),...sl(a,f,l)}:{},...x??{},IS_SANDBOX:"1"};return new qs({cwd:r,env:h})}case"codex":{let m=[...a?[...rl(a),...al(a,f,l)]:[],"-c",'sandbox_mode="danger-full-access"',"-c",'approval_policy="never"'],E={...a?il(a):{},...x??{}},C=!!a;return new Hs({cwd:r,...m.length>0?{extraArgs:m}:{},...Object.keys(E).length>0?{env:E}:{},...C?{authMethodId:"openai-api-key",isolateCodexHome:!0}:{}})}case"openclaw":return new _r({command:e,cwd:r,agentId:s,...c?{sessionName:_c(c)}:{}})}};function Ec(t){return t==="claude-code"||t==="codex"}var l_={path:"",version:"cloud-deployed"},u_={protocolVersion:1,clientCapabilities:{fs:{readTextFile:!0,writeTextFile:!0}}},x_=6e4,h_=hn("COZE_BRIDGE_SPAWN_AWAIT_INSTALL_MS",25e3),Ws=class{paths;config;registry;factory;createTimeoutMs;spawnAwaitInstallMs;openclawConfigCache;ensuredProviders=new Set;detectorFactory;constructor(e){this.paths=e.paths,this.config=e.config,this.registry=e.registry,this.factory=e.downstreamFactory??f_,this.createTimeoutMs=e.createTimeoutMs??x_,this.spawnAwaitInstallMs=e.spawnAwaitInstallMs??h_,this.detectorFactory=e.detectorFactory??(()=>new gn)}buildBinShimPathEnv(){let e=process.platform==="win32"?";":":";return{PATH:`${this.paths.binDir}${e}${process.env.PATH??""}`}}getOpenclawConfig(){if(!this.openclawConfigCache){let e=this.config.frameworksCache?.openclaw;if(!e?.path)throw new D("AGENT_SPAWN_FAILED","openclaw binary not detected on this machine");this.openclawConfigCache=new Ks({command:e.path})}return this.openclawConfigCache}async createAgent(e){if(!e.agentId)throw new D("IPC_BAD_REQUEST","agentId required");if(!e.framework)throw new D("IPC_BAD_REQUEST","framework required");let r=ci(e._meta)==="cloud";this.registry.reviveIfDisconnected?.(e.agentId);let s=this.registry.get(e.agentId);if(s){if(s.framework!==e.framework)throw new D("AGENT_BUSY",`agent ${e.agentId} exists with different framework (${s.framework})`);if(s.status==="error")Oe.warn("existing agent in error state, rebuilding",{agentId:e.agentId}),await s.dispose("rebuild after error").catch(y=>Oe.warn("dispose stale agent failed (ignored)",{err:String(y)})),this.registry.unregister(e.agentId);else{if(e.patToken&&e.patToken!==s.patToken){Oe.info("updating agent patToken on re-create (reconnect with new PAT)",{agentId:e.agentId}),s.setPatToken(e.patToken);let y=await Ue(e.agentId,this.paths).catch(()=>null);y&&(y.patToken=e.patToken,await Ve(y,this.paths))}if(s.deployType==="cloud"&&e.modelInfo){Oe.info("updating agent modelInfo on re-create",{agentId:e.agentId}),s.setModelInfo(e.modelInfo);let y=await Ue(e.agentId,this.paths).catch(()=>null);y&&(y.modelInfo=e.modelInfo,await Ve(y,this.paths))}return Oe.info("agent already exists, return current",{agentId:e.agentId}),{ok:!0,agentId:s.agentId,workspace:s.workspace,framework:s.framework}}}if(!r&&!this.config.frameworksCache?.[e.framework])throw new D("AGENT_SPAWN_FAILED",`framework ${e.framework} not detected on this machine; rerun daemon to refresh frameworks_cache`);let c=kt(e.agentId,this.paths),f=ci(e._meta),l=e.framework==="openclaw"&&f==="local",x=l?this.config.frameworksCache?.openclaw?.defaultAgent?.workspace:void 0,h=e.workspace??x??c.workspace,m=new AbortController,E=setTimeout(()=>m.abort(new D("AGENT_TIMEOUT",`_agent/create timed out after ${this.createTimeoutMs}ms`)),this.createTimeoutMs),C,_=!1;try{r&&Ec(e.framework)&&await yn(e.framework,m.signal);let y=()=>{if(m.signal.aborted)throw m.signal.reason instanceof Error?m.signal.reason:new D("AGENT_TIMEOUT","_agent/create aborted")};await yc(c.root,{recursive:!0}),await yc(h,{recursive:!0}),await yc(c.logs,{recursive:!0}),y(),l||await Zn(h,e.framework,e.cozeIdentity),e.framework==="claude-code"&&await Z0(h),y();let v=await Ue(e.agentId,this.paths).catch(()=>null),I=el({model:e.model??v?.model}),R=Wf(e._meta)??v?.accountId,L=e.patToken??v?.patToken,w=f==="cloud"?e.modelInfo??v?.modelInfo:void 0;if(C=new js({agentId:e.agentId,framework:e.framework,workspace:h,model:I.model??vt,deployType:f,...R?{accountId:R}:{},...L?{patToken:L}:{},...w?{modelInfo:w}:{}}),C.status="ok",v?.sessions){for(let[z,O]of Object.entries(v.sessions))C.sessions.set(z,{acpSessionId:O.acpSessionId,modelToken:O.modelToken,tokenGeneratedAt:O.tokenGeneratedAt,lastActiveAt:Date.now(),loadingSession:!1,replySeq:0});let F=Object.keys(v.sessions).length;F>0&&Oe.info("restored persisted session records (no spawn)",{agentId:e.agentId,count:F})}this.registry.register(C),_=!0;let A={agentId:e.agentId,framework:e.framework,workspace:h,cozeIdentity:e.cozeIdentity,createdAt:v?.createdAt??Date.now(),sessions:v?.sessions??{},model:I.model};f==="cloud"&&(A.deployType="cloud"),R&&(A.accountId=R),L&&(A.patToken=L),w&&(A.modelInfo=w),v?.skills&&(A.skills=v.skills),v?.agentName&&(A.agentName=v.agentName),v?.description&&(A.description=v.description),e.framework==="openclaw"&&f==="cloud"&&(this.config.frameworksCache?.openclaw?.path?await this.getOpenclawConfig().ensureAgent(e.agentId,h):Oe.warn("openclaw binary not on this machine, skip agents add (will fail at session/prompt)",{agentId:e.agentId}));let k=e.initialSkills??[];if(k.length>0){let F=[...A.skills??[]],z=new Map(F.map((U,W)=>[U.skillId,W])),O=await Promise.allSettled(k.map(U=>gc({agentId:e.agentId,workspace:h,framework:e.framework,skill:U}))),N=0;for(let[U,W]of O.entries()){let se=k[U];se&&(W.status==="fulfilled"?(mc(F,z,W.value),N++):Oe.warn("initialSkill install failed (skipping)",{agentId:e.agentId,skillId:se.skillId,skillName:se.skillName,err:String(W.reason)}))}N>0&&(A.skills=F,Oe.info("initialSkills installed",{agentId:e.agentId,installed:N,requested:k.length}))}return await Ve(A,this.paths),Oe.info("agent created (no spawn, lazy on first prompt)",{agentId:e.agentId,framework:e.framework,deployType:f}),{ok:!0,agentId:e.agentId,workspace:h,framework:e.framework}}catch(y){throw Oe.error("agent create failed, rolling back",{agentId:e.agentId,err:String(y)}),_&&C&&(await C.dispose("rollback").catch(()=>{}),this.registry.unregister(e.agentId)),await d_(c.root,{recursive:!0,force:!0}).catch(v=>Oe.warn("rm agent dir failed (ignored)",{err:String(v)})),y instanceof D?y:new D("AGENT_SPAWN_FAILED",String(y),{cause:y})}finally{clearTimeout(E)}}async spawnSessionDownstream(e,r,s,a,c){let l=this.config.frameworksCache?.[e.framework];if(!l)if(e.deployType==="cloud"&&Ec(e.framework))l=l_;else throw new D("AGENT_SPAWN_FAILED",`framework ${e.framework} not detected on this machine`);if(Ec(e.framework)&&!Jt(e.framework)){let m=Jo(e.framework);m&&(Oe.info("spawn: awaiting in-flight acp install (D92)",{agentId:e.agentId,framework:e.framework}),await Promise.race([m.catch(()=>{}),new Promise(E=>setTimeout(E,this.spawnAwaitInstallMs))]))}let x=e.deployType==="cloud"?{model:e.model,modelToken:r,...e.modelInfo?{modelInfo:e.modelInfo}:{}}:void 0,h;e.framework==="openclaw"?h=await this.buildOpenclawDownstream({session:e,modelConfig:x,cloudSessionId:s,cozeEnv:a,mockScenario:c,command:l.path}):h=this.factory(e.framework,l.path,e.workspace,e.agentId,x,s,a,c,this.buildBinShimPathEnv());try{return await h.start(),await h.initialize(u_),h}catch(m){let E=h instanceof At?h.getStderrTail():[];E.length>0&&Oe.warn("spawnSessionDownstream failed, recent stderr (D94)",{agentId:e.agentId,framework:e.framework,method:m instanceof D?m.code:"unknown",recentStderr:E});let C=wc(E);await h.stop("spawnSessionDownstream failed").catch(()=>{});let _=C?new D("NPX_CACHE_CORRUPT","~/.npm/_npx \u76EE\u5F55\u635F\u574F (ENOTEMPTY)\u3002\u5EFA\u8BAE: rm -rf ~/.npm/_npx && npm i -g @zed-industries/codex-acp (\u6216\u5BF9\u5E94 @agentclientprotocol/claude-agent-acp)",{cause:m}):m;throw m instanceof D?new D(m.code,m.message,{retriable:m.retriable,cause:_}):new D("AGENT_SPAWN_FAILED",m instanceof Error?m.message:String(m),{cause:_})}}async buildOpenclawDownstream(e){let{session:r,modelConfig:s,cloudSessionId:a,cozeEnv:c,mockScenario:f,command:l}=e,x=_c(a);if(r.deployType==="local"){let C=this.config.frameworksCache?.openclaw?.defaultAgent;if(!C?.id||!C.workspace){Oe.warn("openclaw default agent stale or missing, attempting lazy re-detect");let y=await this.detectorFactory().detect("openclaw");if(y?.defaultAgent?.id&&y?.defaultAgent?.workspace)Oe.info("openclaw lazy re-detect success",{agentId:y.defaultAgent.id,workspace:y.defaultAgent.workspace}),this.config.frameworksCache||(this.config.frameworksCache={}),this.config.frameworksCache.openclaw=y,C=y.defaultAgent;else throw new D("AGENT_SPAWN_FAILED","openclaw default agent \u672A\u63A2\u6D4B\u5230; \u8BF7\u5148\u8DD1 `openclaw setup` \u6216 `openclaw agents add` \u521B\u5EFA\u9ED8\u8BA4 agent")}return new _r({command:l,cwd:C.workspace,agentId:C.id,sessionName:x})}let h=await Dl(),m=s?ol(s,c,f):null,E;if(m){let C=dc(a),y=m.models[0]?.id??vt,v=`${C}/${y}`;if(!this.ensuredProviders.has(v)){let I=this.getOpenclawConfig();await I.ensureProvider(C,m),await I.addModelToAllowlist(v),this.ensuredProviders.add(v)}E=v}return new _r({command:l,cwd:r.workspace,agentId:r.agentId,sessionName:x,...h?{gatewayToken:h}:{},...E?{slashModelOnStart:E}:{}})}async openclawRepair(e,r){let s=this.getOpenclawConfig();await s.deleteAgent(e),await s.ensureAgent(e,r)}async cleanupOpenclawSessionProviders(e){if(e.framework!=="openclaw"||!this.openclawConfigCache)return;let r=this.openclawConfigCache;for(let s of e.sessions.keys()){let a=dc(s),c=`${a}/${e.model}`,f=!0;try{await r.removeProvider(a)}catch(l){f=!1,Oe.warn("removeProvider failed, keeping ensuredProviders entry",{providerId:a,err:String(l)})}try{await r.removeModelFromAllowlist(c)}catch(l){f=!1,Oe.warn("removeModelFromAllowlist failed, keeping ensuredProviders entry",{fullModelId:c,err:String(l)})}f&&this.ensuredProviders.delete(c)}}};import{randomUUID as Ll}from"node:crypto";import{promises as I_}from"node:fs";import{basename as Nl}from"node:path";import{promises as g_}from"node:fs";import{basename as m_}from"node:path";ee();var Rl=H("file-upload"),w_="/api/coze_claw/file/agent_upload",__=6e4;async function kl(t,e={}){let s=`${Ls(Ms(e.handshakeBase))}${w_}`,a=e.timeoutMs??__,c=await g_.readFile(t.path),f=new FormData;f.append("agent_id",t.agentId),f.append("session_id",t.sessionId),f.append("file_name",t.name),f.append("file_content",new Blob([c],{type:t.mimeType}),t.name);let l={Authorization:`Bearer ${t.patToken}`,Accept:"application/json","x-coze-version":"3.0",...hr(e.ppeOverride),...t.accountId?{"x-coze-account":t.accountId}:{}},x=new AbortController,h=setTimeout(()=>x.abort(),a);Rl.info("file upload start",{url:s,agentId:t.agentId,sessionId:t.sessionId,name:t.name,bytes:t.sizeBytes,mime:t.mimeType});try{let m=await fetch(s,{method:"POST",headers:l,body:f,signal:x.signal}),E=m.headers.get("x-tt-logid")??"";if(!m.ok){let y=await m.text().catch(()=>"");throw new D("UPLOAD_FAILED",`upload HTTP ${m.status} logid=${E}: ${y.slice(0,200)}`)}let C=await m.json();if(C.code!==void 0&&C.code!==0)throw new D("UPLOAD_FAILED",`upload code=${C.code} msg=${C.msg??"-"} logid=${E}`);let _=C.data?.file?.file_url;if(!_)throw new D("UPLOAD_FAILED",`upload response missing data.file.file_url logid=${E}: ${JSON.stringify(C).slice(0,200)}`);return Rl.info("file upload ok",{uri:_,logid:E}),{uri:_}}catch(m){throw m instanceof D?m:m.name==="AbortError"?new D("UPLOAD_FAILED",`upload timeout (${a}ms) for ${m_(t.path)}`):new D("UPLOAD_FAILED",String(m),{cause:m})}finally{clearTimeout(h)}}ee();import{promises as y_}from"node:fs";import{extname as E_}from"node:path";var b_=[{mime:"image/png",prefix:[137,80,78,71]},{mime:"image/jpeg",prefix:[255,216,255]},{mime:"image/gif",prefix:[71,73,70,56]},{mime:"application/pdf",prefix:[37,80,68,70]}];function S_(t){return t[0]===82&&t[1]===73&&t[2]===70&&t[3]===70&&t[8]===87&&t[9]===69&&t[10]===66&&t[11]===80}var v_={".txt":"text/plain",".md":"text/markdown",".svg":"image/svg+xml",".json":"application/json"};async function Ol(t){let e=await y_.open(t,"r");try{let r=Buffer.alloc(16);if(await e.read(r,0,16,0),S_(r))return"image/webp";for(let s of b_)if(s.prefix.every((a,c)=>r[c]===a))return s.mime}finally{await e.close()}return v_[E_(t).toLowerCase()]??"application/octet-stream"}Me();var $s=H("agent-send"),Pl=50*1024*1024,A_=new Set(["image/png","image/jpeg","image/webp","image/gif","image/svg+xml","application/pdf","application/json","text/plain","text/markdown"]);function Ml(t,e,r){let s=t.get(e);if(!s)throw new D("AGENT_NOT_FOUND",`agent=${e}`);if(t.disconnectedAgents.has(e))throw new D("AGENT_DISCONNECTED",`agent=${e} was disconnected by cloud`);let a=s.sessions.get(r);if(!a)throw new D("AGENT_NOT_FOUND",`session=${r} not active in agent=${e}`);return{session:s,runtime:a}}async function Bl(t,e,r,s,a,c){let l;for(let x=0;x<=2;x++)try{await t.core.sendAgentFileUpdate(e,r,s,a);return}catch(h){l=h,x<2&&($s.warn("sendAgentFileUpdate failed, retrying",{attempt:x+1,err:String(h)}),await new Promise(m=>setTimeout(m,5e3)))}throw new D("UPSTREAM_NOT_READY",`${c} after 3 attempts: ${String(l)}`,{cause:l})}async function zl(t,e){let{session:r,runtime:s}=Ml(e.core,t.agentId,t.sessionId);if(!await Nr(t.path,r.workspace))throw new D("PATH_OUTSIDE_WORKSPACE",`path=${t.path} not under workspace=${r.workspace}`);let a=await I_.stat(t.path).catch(()=>null);if(!a||!a.isFile())throw new D("IPC_BAD_REQUEST",`path is not a regular file: ${t.path}`);if(a.size>Pl)throw new D("FILE_TOO_LARGE",`${a.size} bytes > limit ${Pl}`);let c=await Ol(t.path);if(!A_.has(c))throw new D("UNSUPPORTED_MIME",`mime=${c} not in whitelist`);if(t.kind==="image"&&!c.startsWith("image/"))throw new D("UNSUPPORTED_MIME",`kind=image but mime=${c}`);if(!e.core.upstream.isConnected())throw new D("UPSTREAM_NOT_READY","cloud WS not connected");let f=t.name??Nl(t.path),l;try{l=await kl({patToken:r.patToken??e.patToken,agentId:t.agentId,sessionId:t.sessionId,path:t.path,mimeType:c,name:f,sizeBytes:a.size,...r.accountId?{accountId:r.accountId}:{}},{handshakeBase:e.handshakeBase,ppeOverride:e.ppeOverride})}catch(h){throw $s.warn("agent file upload failed",{agentId:t.agentId,sessionId:t.sessionId,path:t.path,sizeBytes:a.size,mime:c,code:h instanceof D?h.code:"UNKNOWN",message:h instanceof Error?h.message:String(h)}),h}let x={sessionUpdate:"agent_file",messageId:Ll(),content:{type:t.kind==="image"?"image":"resource",uri:l.uri,mimeType:c,name:f,sizeBytes:a.size,...l.fileId!==void 0?{fileId:l.fileId}:{},...t.caption!==void 0?{caption:t.caption}:{}}};return await Bl(e,r,s,t.sessionId,x,"agent file uploaded to cloud but sendAgentFileUpdate failed"),$s.info("agent file sent",{agentId:t.agentId,sessionId:t.sessionId,kind:t.kind,name:f,bytes:a.size,mime:c,uri:l.uri}),{ok:!0,uri:l.uri,bytes:a.size,mimeType:c,...l.fileId!==void 0?{fileId:l.fileId}:{}}}async function Fl(t,e){let{session:r,runtime:s}=Ml(e.core,t.agentId,t.sessionId);if(!t.mimeType)throw new D("IPC_BAD_REQUEST","group-file requires mimeType");if(!e.core.upstream.isConnected())throw new D("UPSTREAM_NOT_READY","cloud WS not connected");let a=t.name??Nl(t.path),c={sessionUpdate:"group_file",messageId:Ll(),content:{uri:t.path,name:a,mimeType:t.mimeType,...t.caption!==void 0?{caption:t.caption}:{}}};return await Bl(e,r,s,t.sessionId,c,"agent group file sendAgentFileUpdate failed"),$s.info("agent group file sent",{agentId:t.agentId,sessionId:t.sessionId,uri:t.path,name:a,mime:t.mimeType}),{ok:!0,uri:t.path,bytes:0,mimeType:t.mimeType}}function Ul(t,e){let r=t.split(".").map(Number),s=e.split(".").map(Number),a=Math.max(r.length,s.length);for(let c=0;c<a;c++){let f=r[c]??0,l=s[c]??0;if(f<l)return!0;if(f>l)return!1}return!1}Zt();Wn();ee();var Ct=H("coze-cli-installer"),ql="@coze/cli@latest",C_="coze",Hl="0.1.7",T_=5e3,D_=5e3,R_=9e4,jl=1e4,wi=null,Vs=!1;async function bc(t,e={}){if(Vs)return;if(wi)return wi;let r=e.exec??Ni;return wi=(async()=>{try{let s=await k_(C_,r),a=!1;if(s){let f=await O_(r);if(f===void 0)Ct.warn("coze-cli found but version unparseable, fall through to full install",{path:s});else if(Ul(f,Hl))Ct.info("coze-cli version too old, upgrade-only (preserve user config + auth)",{path:s,version:f,min:Hl}),a=!0;else{Ct.info("coze-cli already on PATH with sufficient version, skip",{path:s,version:f}),Vs=!0;return}}let c=a?"upgrade-only":"full";Ct.info("coze-cli install start",{package:ql,mode:c});try{await r("npm",["i","-g","--prefer-online",ql],{timeout:R_,maxBuffer:10*1024*1024}),Ct.info("coze-cli install ok")}catch(f){Ct.warn("coze-cli install failed (skip subsequent steps)",{err:String(f)});return}if(a){Vs=!0;return}if(t.env)try{await r("coze",["config","set","xTTEnv",t.env],{timeout:jl}),Ct.info("coze config set xTTEnv ok",{env:t.env})}catch(f){Ct.warn("coze config set failed (continue to auth login)",{err:String(f)})}try{await r("coze",["auth","login","--token",t.patToken],{timeout:jl}),Ct.info("coze auth login ok")}catch(f){Ct.warn("coze auth login failed",{err:String(f)});return}Vs=!0}finally{wi=null}})(),wi}async function k_(t,e){let r=process.platform==="win32"?"where":"which";try{let{stdout:s}=await e(r,[t],{timeout:T_});return zi(s)}catch{return}}async function O_(t){try{let{stdout:e,stderr:r}=await t("coze",["--version"],{timeout:D_});return(e||r).match(/(\d+\.\d+\.\d+)/)?.[1]}catch{return}}Ui();Me();var P_=10*6e4;function Gl(t){let e=t?.sessionIdleTimeoutMs;return typeof e!="number"||!Number.isFinite(e)||e<=0?P_:e}function Js(t){return Jn(t??te().configFile)}function Er(t,e){return Fi(e??te().configFile,t)}import{randomBytes as Y_}from"node:crypto";import{createReadStream as L_}from"node:fs";import{mkdir as N_,readFile as M_,realpath as B_,stat as z_,writeFile as F_}from"node:fs/promises";import{basename as U_,dirname as Sc,join as q_,relative as H_,resolve as Kl,sep as j_}from"node:path";import{createInterface as G_}from"node:readline";ee();var $l=H("fs-rpc"),_i=hn("COZE_BRIDGE_FS_RPC_MAX_BYTES",20*1024*1024);async function Vl(t,e){let r=Buffer.byteLength(t.content,"utf8");if(r>_i)throw new D("IPC_BAD_REQUEST",`fs/write_text_file content too large: ${r} bytes > limit ${_i} bytes`);let s=await Zl(t.path,e);return await N_(Sc(s),{recursive:!0}),await F_(s,t.content,"utf8"),$l.info("fs/write_text_file ok",{path:s,size:t.content.length}),null}async function Jl(t,e){let r=await Zl(t.path,e),s=await z_(r),a=typeof t.line=="number"||typeof t.limit=="number";if(s.size>_i&&!a)throw new D("IPC_BAD_REQUEST",`fs/read_text_file too large without line/limit slicing: ${s.size} bytes > ${_i} bytes`);let c;if(a&&s.size>_i)c=await K_(r,t.line??1,t.limit);else{let f=await M_(r,"utf8");if(a){let l=f.split(`
|
|
86
|
+
`),x=Math.max(0,(t.line??1)-1),h=typeof t.limit=="number"?x+t.limit:void 0;c=l.slice(x,h).join(`
|
|
87
|
+
`)}else c=f}return $l.info("fs/read_text_file ok",{path:r,size:c.length}),{content:c}}async function K_(t,e,r){let s=G_({input:L_(t,{encoding:"utf8"}),crlfDelay:Number.POSITIVE_INFINITY}),a=Math.max(0,e-1),c=typeof r=="number"?a+r:Number.POSITIVE_INFINITY,f=[],l=0;try{for await(let x of s)if(l>=a&&l<c&&f.push(x),l++,l>=c)break}finally{s.close()}return f.join(`
|
|
88
|
+
`)}async function Zl(t,e){if(typeof t!="string"||t.length===0)throw new D("IPC_BAD_REQUEST","path must be a non-empty string");let[r,s]=await Promise.all([Wl(Kl(e)),Wl(Kl(t))]),a=H_(r,s);if(a.startsWith("..")||a===".."||a.startsWith(`..${j_}`))throw new D("IPC_BAD_REQUEST",`path escapes workspace: ${t}`);return s}async function Wl(t){let e=[],r=t;for(;r!==Sc(r);)try{let s=await B_(r);return e.length?q_(s,...e.reverse()):s}catch{e.push(U_(r)),r=Sc(r)}return t}ee();var Yl=H("prompt-multimodal"),Xl=10*1024*1024,W_=15e3,$_=6;async function Ql(t){let e=new Array(t.length),r=0;async function s(){for(;r<t.length;){let c=r++,f=t[c];f!==void 0&&(e[c]=await V_(f))}}let a=Array.from({length:Math.min($_,t.length)},()=>s());return await Promise.all(a),e}function eu(t){return t.some(e=>e.type==="image")}async function V_(t){if(t.type!=="image")return t;let e=t;if(e.data||!e.uri||!Ps(e.uri))return t;try{let{buf:r,contentType:s}=await Z_(e.uri),a=e.mimeType||J_(s)||"application/octet-stream";return Yl.info("image uri fetched and inlined",{uri:e.uri,bytes:r.length,mimeType:a}),{type:"image",data:r.toString("base64"),mimeType:a}}catch(r){return Yl.warn("image fetch failed, degrading to text block",{uri:e.uri,err:String(r)}),{type:"text",text:`[image load failed: ${e.uri}]`}}}function J_(t){if(!t)return;let e=t.indexOf(";");return(e===-1?t:t.slice(0,e)).trim()||void 0}async function Z_(t){let e=new AbortController,r=setTimeout(()=>e.abort(),W_);try{let s=await fetch(t,{signal:e.signal});if(!s.ok)throw new Error(`HTTP ${s.status} ${s.statusText}`);let a=await s.arrayBuffer();if(a.byteLength>Xl)throw new Error(`image too large: ${a.byteLength} bytes (max ${Xl})`);return{buf:Buffer.from(a),contentType:s.headers.get("content-type")??void 0}}finally{clearTimeout(r)}}Yt();ee();var $=H("core"),X_=3e4,Q_=/^(boe|ppe)_[A-Za-z0-9_-]+$/,ey=3e4,Zs=class{upstream;agents=new Map;disconnectedAgents=new Set;extensions;paths;sessionSpawner;sessionIdleTimeoutMs;upstreamIds=new wr;pendingUpstream=new Map;pendingBridge=new Map;currentCozeEnv;currentMockScenario;constructor(e){this.upstream=e.upstream,this.extensions=e.extensions??{},this.paths=e.paths,this.sessionSpawner=e.sessionSpawner,this.sessionIdleTimeoutMs=Gl(e.bridgeConfig)}registerExtension(e,r){this.extensions[e]=r}getCozeEnv(){return this.currentCozeEnv}getMockScenario(){return this.currentMockScenario}setMockScenario(e){this.currentMockScenario=e&&e.length>0?e:void 0}async start(){this.upstream.onFrame(e=>this.handleFrame(e)),this.upstream.onConnect?.(({initial:e})=>{e||this.rejectAllPendingOnReconnect()}),await this.upstream.start(),$.info("Core started",{extensions:Object.keys(this.extensions)})}async stop(e){$.info("Core stopping",{reason:e}),await Promise.all([...this.agents.values()].map(r=>r.dispose(e))),this.agents.clear(),await this.upstream.stop(e)}get(e){return this.agents.get(e)}register(e){this.agents.set(e.agentId,e),$.info("agent registered",{agentId:e.agentId,framework:e.framework});for(let r of this.registerHandlers)try{r(e.agentId)}catch(s){$.warn("onAgentRegister handler threw (ignored)",{agentId:e.agentId,err:String(s)})}}onAgentRegister(e){return this.registerHandlers.add(e),()=>this.registerHandlers.delete(e)}registerHandlers=new Set;unregister(e){this.agents.delete(e)}reviveIfDisconnected(e){this.disconnectedAgents.delete(e)&&$.info("agent revived from disconnect",{agentId:e})}attachRuntimeHooks(e,r,s){let a=s.downstream;a&&(a.onUpdate(c=>{s.loadingSession||this.forwardUpdate(e,c)}),a.onAgentRequest(c=>{this.handleAgentRequest(e,a,c)}),a.onExit((c,f)=>{$.info("session runtime exited",{agentId:e.agentId,cloudId:r,code:c,signal:f}),mi(s),s.downstream=void 0,s.replySeq=0,s.acpSessionId&&e.activeTriggers.delete(s.acpSessionId),this.rejectPendingForDownstream(a,"downstream exited")}))}hasPendingPermissionFor(e){for(let r of this.pendingUpstream.values())if(r.downstream===e)return!0;return!1}rejectPendingForDownstream(e,r){let s=[];for(let[a,c]of this.pendingUpstream)c.downstream===e&&s.push(a);if(s.length!==0){$.info("reject pendingUpstream entries (downstream gone)",{reason:r,count:s.length});for(let a of s){let c=this.pendingUpstream.get(a);if(c){this.pendingUpstream.delete(a),this.upstream.send(xn(a,{code:Q.INTERNAL_ERROR,message:`bridge downstream gone: ${r}`})).catch(f=>$.debug("send error response to upstream failed (ignored)",{err:String(f)}));try{c.downstream.respondAgentRequestError(c.agentRequestId,{code:Q.INTERNAL_ERROR,message:`bridge: ${r}`})}catch{}}}}}rejectAllPendingOnReconnect(){let e=this.pendingUpstream.size,r=this.pendingBridge.size;if(!(e===0&&r===0)){$.warn("upstream reconnected, rejecting stale pending requests",{pendingUpstream:e,pendingBridge:r});for(let[,s]of this.pendingUpstream)try{s.downstream.respondAgentRequestError(s.agentRequestId,{code:Q.INTERNAL_ERROR,message:"upstream reconnected; please retry"})}catch{}this.pendingUpstream.clear();for(let[,s]of this.pendingBridge)clearTimeout(s.timer),s.reject(new D("UPSTREAM_DISCONNECTED",`${s.method} aborted: upstream reconnected`));this.pendingBridge.clear()}}async handleFrame(e){if(Fs(e)){this.handleUpstreamResponse(e);return}if(!("method"in e)||typeof e.method!="string")return;let r="id"in e&&e.id!==void 0?e.id:null,s=e.params?._meta?.cozeEnv;s&&Q_.test(s)?this.currentCozeEnv=s:s&&$.warn("rejecting cozeEnv with invalid shape, keeping previous",{rejected:s});try{if(e.method.startsWith("_agent/")){let a=this.extensions[e.method];if(!a){r!==null?await this.sendError(r,Q.METHOD_NOT_FOUND,`extension not registered: ${e.method}`):$.warn("drop notification: extension not registered",{method:e.method});return}let c=await a(e,this);r!==null&&await this.upstream.send(mr(r,c));return}if(e.method.startsWith("session/")){let a=await this.routeSessionMethod(e);r!==null&&await this.upstream.send(mr(r,a));return}if(e.method==="initialize"){r!==null&&await this.upstream.send(mr(r,{protocolVersion:1,agentCapabilities:{loadSession:!0}}));return}r!==null?await this.sendError(r,Q.METHOD_NOT_FOUND,`method not implemented: ${e.method}`):$.warn("drop unknown notification",{method:e.method})}catch(a){$.error("handleFrame failed",{method:e.method,err:String(a)}),r!==null&&await this.upstream.send(xn(r,gi(a)))}}async routeSessionMethod(e){if(!e.params||typeof e.params!="object")throw new D("IPC_BAD_REQUEST",`${e.method} requires params`);let r=e.params,s=r._meta?.cozeAgentId;if(!s)throw new D("IPC_BAD_REQUEST",`${e.method}: missing _meta.cozeAgentId`);let a=this.agents.get(s);if(!a)throw this.disconnectedAgents.has(s)?new D("AGENT_DISCONNECTED",`agent ${s} has been disconnected; cloud must _agent/create to revive`):new D("AGENT_NOT_FOUND",`agent not found: ${s}`);let c=typeof r.sessionId=="string"?r.sessionId:void 0;if(e.method==="session/cancel"||e.method==="session/new"||!c)return this.dispatchSessionCall(a,e.method,r);let f=Date.now(),l=!1;try{let x=await a.getSessionQueue(c).enqueue(()=>this.dispatchSessionCall(a,e.method,r));return l=!0,x}finally{$.info("session call done",{agentId:a.agentId,method:e.method,durationMs:Date.now()-f,ok:l})}}async dispatchSessionCall(e,r,s){e.lastActiveAt=Date.now();let{stripped:a}=Vf(s);switch(r){case"session/new":{let c=ty();return $.info("session/new ack (lazy spawn)",{agentId:e.agentId,cloudId:c}),{sessionId:c}}case"session/load":{let c=a;return $.info("session/load ack (lazy spawn)",{agentId:e.agentId,cloudId:c.sessionId}),{}}case"session/prompt":{let c=a,f=c.sessionId;if(!f)throw new D("IPC_BAD_REQUEST","session/prompt: missing sessionId");let l=await this.ensureRuntime(e,f);if(l.replySeq=0,await this.ensureDownstream(e,f,l),!l.downstream||!l.acpSessionId)throw new D("BRIDGE_INTERNAL","session runtime not ready after ensureDownstream");let x=s._meta?.cozeTriggerMsgId;x?e.activeTriggers.set(l.acpSessionId,x):e.activeTriggers.delete(l.acpSessionId);let h=$f(s._meta);if(h?e.activeGroupIds.set(l.acpSessionId,h):e.activeGroupIds.delete(l.acpSessionId),e.deployType==="cloud"&&e.modelInfo?.capabilities?.image===!1&&eu(c.prompt))throw new D("MODEL_MODALITY_UNSUPPORTED",`model=${e.modelInfo.id??e.model} does not support image input`);let m=await Ql(c.prompt);try{let E=await l.downstream.sessionPrompt({...c,sessionId:l.acpSessionId,prompt:m});return l.lastActiveAt=Date.now(),E}finally{if(e.activeTriggers.delete(l.acpSessionId),e.activeGroupIds.delete(l.acpSessionId),l.reloadAfterTurn){l.reloadAfterTurn=!1;let E=l.downstream;E&&(l.downstream=void 0,$.info("reloadAfterTurn: stopping downstream",{agentId:e.agentId,cloudId:f,acpId:l.acpSessionId}),E.stop("reload-after-turn").catch(C=>$.warn("reload-after-turn stop failed (ignored)",{agentId:e.agentId,cloudId:f,err:String(C)})))}else l.downstream?.isAlive()&&this.armIdleTimer(e,f,l)}}case"session/cancel":{let f=a.sessionId;if(!f)throw new D("IPC_BAD_REQUEST","session/cancel: missing sessionId");let l=e.sessions.get(f);if(e.hasSessionQueue(f)){let x=e.getSessionQueue(f);x.size>0&&($.info("session/cancel: draining queued tasks",{agentId:e.agentId,cloudId:f,queuedCount:x.size}),x.dispose(new D("AGENT_PROTOCOL_ERROR",`cancelled by session/cancel on ${f}`)))}return l?.downstream?.isAlive()&&l.acpSessionId&&await l.downstream.sessionCancel({sessionId:l.acpSessionId}),{ok:!0}}default:throw new D("IPC_BAD_REQUEST",`session method not supported: ${r}`)}}async ensureRuntime(e,r){let s=e.sessions.get(r);if(s)return s;let c={modelToken:e.deployType==="cloud"?await this.requestSessionToken(e.agentId,r):"",tokenGeneratedAt:Date.now(),lastActiveAt:Date.now(),loadingSession:!1,replySeq:0};return e.sessions.set(r,c),await this.persistSessionMapping(e),c}async requestSessionToken(e,r){let s={sessionId:r,_meta:{cozeAgentId:e}};try{let a=await this.sendRequest(St.GEN_MODEL_TOKEN,s,ey);if(!a?.modelToken)throw new D("MODEL_TOKEN_GEN_FAILED",`cloud returned empty modelToken (agentId=${e}, cloudSessionId=${r})`);return a.modelToken}catch(a){throw a instanceof D&&a.code==="MODEL_TOKEN_GEN_FAILED"?a:new D("MODEL_TOKEN_GEN_FAILED",a instanceof Error?a.message:String(a),{cause:a})}}async ensureDownstream(e,r,s){if(mi(s),s.downstream?.isAlive())return;if(!this.sessionSpawner)throw new D("AGENT_SPAWN_FAILED","sessionSpawner not wired (cannot spawn per-session downstream)");let a=3,c=3e4,f=s.spawnFailCount??0,l=s.spawnFailedAt??0;if(f>=a&&Date.now()-l<c)throw new D("AGENT_SPAWN_FAILED",`agent ${e.agentId} session ${r} spawn failed ${f} times in a row; please check framework binary / network and retry after ${Math.ceil((c-(Date.now()-l))/1e3)}s`);let x;try{x=await this.sessionSpawner(e,s.modelToken,r,this.currentCozeEnv,this.currentMockScenario)}catch(h){throw s.spawnFailCount=f+1,s.spawnFailedAt=Date.now(),s.spawnFailCount>=a&&s.acpSessionId&&($.warn("clearing stale acpSessionId after repeated spawn failures",{agentId:e.agentId,cloudId:r,staleAcpId:s.acpSessionId}),s.acpSessionId=void 0),h}if(s.spawnFailCount=0,s.spawnFailedAt=void 0,s.downstream=x,this.attachRuntimeHooks(e,r,s),s.acpSessionId){s.loadingSession=!0;try{await x.sessionLoad({sessionId:s.acpSessionId,cwd:e.workspace}),$.info("session restored via session/load",{agentId:e.agentId,cloudId:r,acpId:s.acpSessionId})}catch(h){$.warn("session/load failed, fallback to session/new",{agentId:e.agentId,cloudId:r,acpId:s.acpSessionId,err:String(h)}),s.acpSessionId=void 0;let m=await x.sessionNew({cwd:e.workspace});s.acpSessionId=m.sessionId,await this.persistSessionMapping(e)}finally{s.loadingSession=!1}}else{let h=await x.sessionNew({cwd:e.workspace});s.acpSessionId=h.sessionId,await this.persistSessionMapping(e)}x.afterSessionEstablished&&s.acpSessionId&&await x.afterSessionEstablished(s.acpSessionId)}armIdleTimer(e,r,s){if(mi(s),this.isRuntimeBusy(e,s)){$.debug("skip idle timer: runtime busy (in-flight turn / pending permission)",{agentId:e.agentId,cloudId:r});return}s.idleTimer=setTimeout(()=>{if(s.idleTimer=void 0,this.isRuntimeBusy(e,s)){$.info("idle reaper fired but runtime busy, re-arming",{agentId:e.agentId,cloudId:r}),this.armIdleTimer(e,r,s);return}$.info("session runtime idle timeout, killing downstream",{agentId:e.agentId,cloudId:r});let a=s.downstream;s.downstream=void 0,s.acpSessionId&&e.activeTriggers.delete(s.acpSessionId),a&&a.stop("idle timeout").catch(c=>$.warn("idle stop failed (ignored)",{agentId:e.agentId,cloudId:r,err:String(c)}))},this.sessionIdleTimeoutMs),s.idleTimer.unref?.()}isRuntimeBusy(e,r){if(r.acpSessionId&&e.activeTriggers.has(r.acpSessionId))return!0;let s=r.downstream;if(!s)return!1;for(let a of this.pendingUpstream.values())if(a.downstream===s)return!0;return!1}async sendAgentFileUpdate(e,r,s,a){let c={cozeAgentId:e.agentId,cozeReplySeqID:++r.replySeq};if(r.acpSessionId){let f=e.activeTriggers.get(r.acpSessionId);f&&(c.cozeTriggerMsgId=f);let l=e.activeGroupIds.get(r.acpSessionId);l&&(c.cozeGroupId=l)}await this.upstream.send(hi("session/update",{sessionId:s,update:a,_meta:c}))}forwardUpdate(e,r){let s=r.sessionId,a=this.reverseSessionId(e,s);if(!a){$.debug("drop update for unknown session",{agentId:e.agentId,acpId:s});return}let c=e.sessions.get(a);if(!c){$.debug("drop update: runtime gone",{agentId:e.agentId,cloudId:a});return}if(ry(r)){$.debug("drop codex metadata-warn chunk",{agentId:e.agentId,acpId:s});return}let f={cozeAgentId:e.agentId,cozeReplySeqID:++c.replySeq},l=e.activeTriggers.get(s);l&&(f.cozeTriggerMsgId=l);let x=e.activeGroupIds.get(s);x&&(f.cozeGroupId=x),this.upstream.send(hi("session/update",{...r,sessionId:a,_meta:f})).catch(h=>$.warn("forward update failed",{agentId:e.agentId,err:String(h)}))}handleAgentRequest(e,r,s){if(s.method==="session/request_permission"){this.forwardPermissionRequest(e,r,s);return}if(s.method==="fs/write_text_file"||s.method==="fs/read_text_file"){this.handleFsRpcRequest(e,r,s);return}$.warn("unhandled agent request,returning method_not_found",{agentId:e.agentId,method:s.method}),r.respondAgentRequestError(s.id,{code:Q.METHOD_NOT_FOUND,message:`method not handled by Bridge: ${s.method}`})}async handleFsRpcRequest(e,r,s){try{let a=e.workspace;if(s.method==="fs/write_text_file"){let c=s.params??{},f=await Vl(c,a);r.respondAgentRequest(s.id,f)}else{let c=s.params??{},f=await Jl(c,a);r.respondAgentRequest(s.id,f)}}catch(a){$.warn("fs rpc handler failed",{agentId:e.agentId,method:s.method,err:String(a)}),r.respondAgentRequestError(s.id,gi(a))}}forwardPermissionRequest(e,r,s){let a=this.upstreamIds.next("session/request_permission"),c=s.params??{},l=c.sessionId,x=l?e.activeTriggers.get(l):void 0,h={cozeAgentId:e.agentId};x&&(h.cozeTriggerMsgId=x);let m=l?e.activeGroupIds.get(l):void 0;m&&(h.cozeGroupId=m);let E=l?this.reverseSessionId(e,l):void 0,C={...c,...E?{sessionId:E}:{},_meta:h};this.pendingUpstream.set(a,{agentRequestId:s.id,agentId:e.agentId,downstream:r,method:s.method}),$.info("forward permission_request \u2192 upstream",{agentId:e.agentId,upstreamId:a,acpSessionId:l,cloudSessionId:E,toolCallId:c.toolCall?.toolCallId,options:c.options?.map(_=>({optionId:_.optionId,kind:_.kind,name:_.name}))}),this.upstream.send(xi(a,"session/request_permission",C)).catch(_=>{this.pendingUpstream.delete(a),$.error("forward permission request failed",{agentId:e.agentId,err:String(_)}),r.respondAgentRequestError(s.id,{code:Q.INTERNAL_ERROR,message:`upstream send failed: ${String(_)}`})})}handleUpstreamResponse(e){if(e.id===null)return;let r=this.lookupPending(this.pendingUpstream,e.id,"upstream");if(r){this.pendingUpstream.delete(r.key);let a=r.value;e.error?($.info("upstream \u2192 permission response (error)",{agentId:a.agentId,upstreamId:e.id,method:a.method,error:e.error}),a.downstream.respondAgentRequestError(a.agentRequestId,e.error)):(a.method==="session/request_permission"&&ny(e.result,a),$.info("upstream \u2192 permission response (result)",{agentId:a.agentId,upstreamId:e.id,method:a.method,result:e.result}),a.downstream.respondAgentRequest(a.agentRequestId,e.result));return}let s=this.lookupPending(this.pendingBridge,e.id,"bridge");if(s){this.pendingBridge.delete(s.key),clearTimeout(s.value.timer),e.error?s.value.reject(new zs(e.error)):s.value.resolve(e.result);return}$.debug("orphan upstream response (no pending)",{id:e.id})}lookupPending(e,r,s){let a=e.get(r);if(a)return{value:a,key:r};if(typeof r=="number"){let c=String(r),f=e.get(c);if(f)return $.warn(`${s} id type mismatch: number received but Bridge expected string`,{rawId:r,normalizedId:c}),{value:f,key:c}}}sendRequest(e,r,s=X_){let a=this.upstreamIds.next(e);return new Promise((c,f)=>{let l=setTimeout(()=>{this.pendingBridge.delete(a),f(new D("AGENT_TIMEOUT",`${e} timed out after ${s}ms`))},s);this.pendingBridge.set(a,{method:e,resolve:c,reject:f,timer:l}),this.upstream.send(xi(a,e,r)).catch(x=>{let h=this.pendingBridge.get(a);h&&(clearTimeout(h.timer),this.pendingBridge.delete(a)),f(x)})})}async persistSessionMapping(e){if(this.paths)try{let r=new Map;for(let[s,a]of e.sessions){let c={modelToken:a.modelToken,tokenGeneratedAt:a.tokenGeneratedAt};a.acpSessionId&&(c.acpSessionId=a.acpSessionId),r.set(s,c)}await Zo(e.agentId,r,this.paths)}catch(r){$.warn("persist session mapping failed",{agentId:e.agentId,err:String(r)})}}reverseSessionId(e,r){for(let[s,a]of e.sessions.entries())if(a.acpSessionId===r)return s}sendError(e,r,s){return this.upstream.send(xn(e,{code:r,message:s,data:{bridgeVersion:gr}}))}};function ty(){return Y_(16).toString("hex")}function ny(t,e){if(!t||typeof t!="object"){$.warn("permission response: result not an object (suspicious)",{agentId:e.agentId,result:t});return}let r=t;if("kind"in r&&!("outcome"in r)){$.warn('permission response: top-level "kind" field (D66 historical bug shape)',{agentId:e.agentId,result:t});return}let s=r.outcome;if(!s||typeof s!="object"){$.warn("permission response: missing or non-object outcome field",{agentId:e.agentId,result:t});return}let c=s.outcome;(typeof c!="string"||c!=="selected"&&c!=="cancelled")&&$.warn("permission response: unknown outcome discriminant",{agentId:e.agentId,outcomeValue:c,result:t})}function ry(t){let e=t.update;if(e?.sessionUpdate!=="agent_message_chunk")return!1;let r=e.content;if(!r||typeof r!="object")return!1;let s=r;return s.type!=="text"||typeof s.text!="string"?!1:s.text.startsWith("Model metadata for `")}ee();Me();import{randomBytes as iy}from"node:crypto";import{chmod as sy,mkdir as oy,writeFile as tu}from"node:fs/promises";import{createServer as ay}from"node:http";import{dirname as cy}from"node:path";var dy=1e6,vc=H("ipc"),Ys=class{server=null;port=0;token="";routes;paths;constructor(e){this.routes=new Map(e.routes.map(r=>[`${r.method} ${r.path}`,r])),this.paths=e.paths??te()}async start(){this.token=iy(32).toString("hex");let e=ay((s,a)=>{this.dispatch(s,a)});this.server=e,await new Promise((s,a)=>{e.once("error",a),e.listen(0,"127.0.0.1",()=>s())});let r=e.address();if(!r||typeof r!="object")throw new Error("failed to obtain IPC port");return this.port=r.port,await this.persistAuthFiles(),vc.info("IPC listening",{port:this.port}),{port:this.port,token:this.token}}async stop(){let e=this.server;e&&(await new Promise((r,s)=>{e.close(a=>a?s(a):r())}),this.server=null)}async persistAuthFiles(){await oy(cy(this.paths.portFile),{recursive:!0}),await tu(this.paths.portFile,String(this.port),"utf8"),await tu(this.paths.tokenFile,this.token,{encoding:"utf8",mode:384});try{await sy(this.paths.tokenFile,384)}catch(e){vc.warn("chmod token file failed (non-POSIX?)",{err:String(e)})}}async dispatch(e,r){if(e.headers.authorization!==`Bearer ${this.token}`){yi(r,401,{error:"unauthorized"});return}let a=`${e.method} ${(e.url??"").split("?")[0]}`,c=this.routes.get(a);if(!c){yi(r,404,{error:"not found"});return}let f=null;if(e.method==="POST")try{f=await fy(e)}catch(l){yi(r,400,{error:"invalid json",detail:String(l)});return}try{let l=await c.handler(f,e);yi(r,200,l??{ok:!0})}catch(l){vc.error("IPC handler failed",{key:a,err:String(l)}),yi(r,500,{error:l instanceof Error?l.message:String(l)})}}};function yi(t,e,r){t.statusCode=e,t.setHeader("content-type","application/json"),t.end(JSON.stringify(r))}async function fy(t){let e=[],r=0;for await(let a of t){let c=a;if(r+=c.length,r>dy)throw new Error("body too large");e.push(c)}let s=Buffer.concat(e).toString("utf8");return s?JSON.parse(s):null}var vx=gt(uu(),1);var GE=gt(ax(),1),KE=gt(ho(),1),WE=gt(vr(),1),$E=gt(Bc(),1),VE=gt(Uc(),1),JE=gt(Wc(),1),gx=gt(wo(),1),ZE=gt(px(),1);var mx=gx.default;ee();var Ie=H("upstream.frontier"),yx="application/json",Ex="none",XE=15e3,Di=class{constructor(e){this.opts=e}opts;fws=null;handler=null;connectHandlers=[];opened=!1;lastSendRefusedLogAt=0;sendRefusedSuppressed=0;openCount=0;async start(){if(this.fws){Ie.warn("start called on already-started FrontierUpstream; noop");return}let e={Authorization:`Bearer ${this.opts.privatecode}`,Origin:Yf,...hr(this.opts.ppeOverride)};class r extends mx{constructor(y){super(y,Zf,{headers:e})}send(y,...v){if(P0("debug"))try{let I;typeof y=="string"?I=Buffer.from(y,"utf8"):y instanceof Buffer?I=y:y instanceof ArrayBuffer?I=new Uint8Array(y):ArrayBuffer.isView(y)?I=new Uint8Array(y.buffer,y.byteOffset,y.byteLength):I=new Uint8Array(0);let R=Buffer.from(I.slice(0,128)).toString("hex");Ie.debug("WS raw frame out",{bytes:I.byteLength,headHex:R})}catch(I){Ie.warn("WS raw frame dump failed",{err:String(I)})}super.send(y,...v)}}let s=Qf(this.opts.urlOverride),a={url:s,ws:r,fpID:Jf,aID:Ns,accessKey:this.opts.handshake.accessKey,deviceID:this.opts.handshake.deviceId,payloadType:{type:yx,force:!0},payloadEncoding:{encoding:Ex,force:!0},enableTransformTextPayload:!0,enableQoS:!1,enableAutoAck:!1,automaticOpen:!1,maxRetries:Number.POSITIVE_INFINITY,debug:this.opts.debug??!1},c=new vx.FWS(a),f=!1,l=null,x,h,m=new Promise((_,y)=>{x=_,h=y}),E=_=>{f||(f=!0,l&&(clearTimeout(l),l=null),_?h(_):x())};c.onopen=()=>{this.opened=!0,this.openCount+=1;let _=this.openCount===1;Ie.info("frontier opened",{url:s,remoteDeviceId:this.opts.handshake.deviceId,initial:_,openCount:this.openCount}),_&&E();for(let y of this.connectHandlers)Promise.resolve(y({initial:_})).catch(v=>Ie.warn("onConnect handler threw (ignored)",{err:String(v)}))},c.onclose=_=>{this.opened=!1,Ie.info("frontier closed",{code:_.code,reason:_.reason,willReconnect:_.willReconnect})},c.onerror=_=>{Ie.warn("frontier error",{code:_.code,msg:_.message}),E(new D("UPSTREAM_DISCONNECTED",`frontier connect error before open: code=${_.code} msg=${_.message??""}`))},c.onmessage=_=>this.handleMessage(_),this.fws=c;let C=this.opts.openTimeoutMs??XE;l=setTimeout(()=>{E(new D("UPSTREAM_DISCONNECTED",`frontier ws open timeout after ${C}ms (handshake or upgrade slow)`))},C),await c.connect();try{await m}catch(_){try{c.close(1e3,"open failed")}catch(y){Ie.warn("fws close during start failure threw (ignored)",{err:String(y)})}throw this.fws=null,this.opened=!1,_}}async stop(e){let r=this.fws;if(r){this.fws=null,this.opened=!1;try{r.close(1e3,e??"bridge shutdown")}catch(s){Ie.warn("frontier close threw (ignored)",{err:String(s)})}}}async send(e){let r=this.fws,s=e.method;if(!r)throw Ie.warn("frontier send refused: upstream not started",{method:s}),new D("UPSTREAM_DISCONNECTED","frontier upstream not started");if(!this.isConnected()){let l=Date.now();throw l-this.lastSendRefusedLogAt>1e3?(Ie.warn("frontier send refused: ws not open",{method:s,opened:this.opened,readyState:r.readyState,...this.sendRefusedSuppressed>0?{suppressedSinceLast:this.sendRefusedSuppressed}:{}}),this.lastSendRefusedLogAt=l,this.sendRefusedSuppressed=0):this.sendRefusedSuppressed+=1,new D("UPSTREAM_DISCONNECTED",`frontier ws not open (opened=${this.opened}, readyState=${r.readyState}); refusing to silently buffer`)}this.injectAgentPatToken(e);let a=JSON.stringify(e),c=e;bx(c)||Ie.info("frontier frame out",{method:c.method,jsonrpcId:c.id,size:a.length});try{await r.send(a,{service:33555712,method:1,payloadType:yx,payloadEncoding:Ex})}catch(l){throw Ie.warn("frontier frame send failed",{method:c.method,jsonrpcId:c.id,err:String(l)}),new D("UPSTREAM_DISCONNECTED",`frontier send failed: ${String(l)}`,{cause:l})}}onFrame(e){this.handler=e}onConnect(e){this.connectHandlers.push(e)}isConnected(){return this.opened&&this.fws?.readyState===1}injectAgentPatToken(e){let r=this.opts.getPatTokenForAgent;if(!r)return;let s=e.params?._meta;if(!s?.cozeAgentId)return;let a=r(s.cozeAgentId);a&&(s.cozePatToken=a)}handleMessage(e){let r=e.message?.service;if(r!==33555712){Ie.debug("drop non-adapter frontier frame",{service:r});return}let s=tb(e);if(!s){Ie.debug("frontier message without text payload, drop",{payloadType:e.message?.payloadType});return}if(!this.handler){Ie.debug("frame received but no onFrame handler",{size:s.length});return}let a;try{a=JSON.parse(s)}catch(f){Ie.warn("frontier message JSON parse failed",{err:String(f),head:s.slice(0,80)});return}let c=a;bx(c)||Ie.info("frontier frame in",{logid:eb(e.message?.LogID),logidNew:e.message?.LogIDNew,msgId:e.message?.msgID,jsonrpcId:c.id,method:c.method,body:QE(s)}),Promise.resolve(this.handler(a)).catch(f=>Ie.warn("frontier frame handler threw",{err:String(f)}))}};function bx(t){return t.method==="_agent/health"?!0:typeof t.id=="string"&&t.id.startsWith("agent.health_")}var Sx=2e3;function QE(t){return t.length<=Sx?t:`${t.slice(0,Sx)}...<truncated, total ${t.length} chars>`}function eb(t){return t?t.high===0?String(t.low>>>0):`${t.high.toString(16)}${(t.low>>>0).toString(16).padStart(8,"0")}`:""}function tb(t){let e=t.message;if(e?.textPayload)return e.textPayload;let r=e?.payload;if(!r)return null;try{return Buffer.from(r).toString("utf8")}catch{return null}}ee();var Vc=H("upstream.switchable"),yo=class{inner;handler=null;connectHandlers=[];constructor(e){this.inner=e}async swap(e,r){if(this.inner===e)return;Vc.info("swap upstream",{reason:r});let s=this.inner;if(this.inner=e,this.handler&&e.onFrame(this.handler),e.onConnect)for(let a of this.connectHandlers)e.onConnect(a);try{await e.start()}catch(a){throw Vc.error("swap target start failed, reverting",{err:String(a)}),this.inner=s,a}await s.stop(r??"swapped").catch(a=>Vc.warn("previous upstream stop threw (ignored)",{err:String(a)}))}current(){return this.inner}start(){return this.inner.start()}stop(e){return this.inner.stop(e)}send(e){return this.inner.send(e)}onFrame(e){this.handler=e,this.inner.onFrame(e)}onConnect(e){this.connectHandlers.push(e),this.inner.onConnect?.(e)}isConnected(){return this.inner.isConnected()}};ee();var Jc=H("upstream"),Rr=class{handler=null;async start(){Jc.info("NoopUpstream started (M1 skeleton; real Frontier wired in M4)")}async stop(e){Jc.info("NoopUpstream stopped",{reason:e})}async send(e){Jc.debug("NoopUpstream.send (dropped)",{method:"method"in e?e.method:void 0})}onFrame(e){this.handler=e}isConnected(){return!1}async injectFrame(e){this.handler&&await this.handler(e)}};ee();ee();Me();import{promises as Zc}from"node:fs";import{dirname as nb}from"node:path";var rb=H("pat-token-store");async function Ix(t=te()){try{let r=(await Zc.readFile(t.patTokenFile,"utf8")).trim();return r.length>0?r:null}catch(e){let r=e?.code;return r!=="ENOENT"&&rb.warn("read pat-token failed (treating as missing)",{path:t.patTokenFile,code:r,message:e.message}),null}}async function Ri(t,e=te()){if(!t)throw new Error("writePatToken: empty patToken");await Zc.mkdir(nb(e.patTokenFile),{recursive:!0}),await Zc.writeFile(e.patTokenFile,t,{encoding:"utf8",mode:384})}Me();Me();import{promises as Eo}from"node:fs";import{join as ib}from"node:path";function sb(t,e){return`#!/bin/sh
|
|
123
89
|
exec ${JSON.stringify(e)} ${JSON.stringify(t)} "$@"
|
|
124
|
-
`}function
|
|
90
|
+
`}function ob(t,e){return`@echo off\r
|
|
125
91
|
"${e}" "${t}" %*\r
|
|
126
|
-
`}async function Tx(t,e=se()){let r=e.binDir;await Io.mkdir(r,{recursive:!0});let s=fE(r,process.platform==="win32"?"coze-bridge.cmd":"coze-bridge"),a=process.execPath,c=process.platform==="win32"?uE(t,a):dE(t,a);return await Io.readFile(s,"utf8").catch(()=>null)===c||(await Io.writeFile(s,c,"utf8"),process.platform!=="win32"&&await Io.chmod(s,493)),r}ie();qe();import{execSync as Rx}from"node:child_process";import{readFileSync as kx,unlinkSync as lE}from"node:fs";import{mkdir as xE,readFile as Lx,unlink as Ox,writeFile as hE}from"node:fs/promises";import{dirname as pE}from"node:path";function Dx(t){try{return process.kill(t,0),!0}catch(e){return e.code==="EPERM"}}var gE=$("single-instance"),Co=class{pidFile;acquired=!1;constructor(e={}){this.pidFile=e.pidFile??se().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&&(gE.warn("removing stale pid file",{stalePid:e}),await Ox(this.pidFile).catch(()=>{})),await xE(pE(this.pidFile),{recursive:!0}),await hE(this.pidFile,String(process.pid),"utf8"),this.acquired=!0,this.installCleanupHooks(),{kind:"acquired"})}async release(){if(this.acquired){try{(await Lx(this.pidFile,"utf8")).trim()===String(process.pid)&&await Ox(this.pidFile)}catch{}this.acquired=!1}}async readExistingPid(){try{let e=await Lx(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 Dx(e)?this.matchesDaemonTitle(e):!1}matchesDaemonTitle(e){if(process.platform==="win32")return this.matchesDaemonTitleWindows(e);try{let r=kx(`/proc/${e}/cmdline`,"utf8").replace(/\0/g," ");return!!(r.includes("coze-bridge-daemon")||r.includes("lib/index.js"))}catch{}try{let r=Rx(`ps -o command= -p ${e}`,{stdio:["ignore","pipe","ignore"],timeout:1e3}).toString();return r.trim()?r.includes("coze-bridge-daemon")||r.includes("lib/index.js"):!1}catch{return!0}}matchesDaemonTitleWindows(e){try{let s=Rx(`tasklist /FI "PID eq ${e}" /FO CSV /NH`,{stdio:["ignore","pipe","ignore"],timeout:2e3}).toString().trim();if(!s||/^(INFO|信息)[::]/.test(s))return!1;let a=s.split(",",1)[0]?.replace(/^"|"$/g,"").toLowerCase()??"";return a.includes("node")||a.includes("coze-bridge")}catch{return!0}}installCleanupHooks(){process.once("exit",()=>{if(this.acquired)try{kx(this.pidFile,"utf8").trim()===String(process.pid)&&lE(this.pidFile)}catch{}})}};var J=$("daemon"),mE="coze-bridge-daemon";async function Nx(){let t=new Co({processTitle:mE}),e=await t.acquire();if(e.kind==="already-running")throw new Error(`coze-bridge daemon already running (pid=${e.pid})`);let r=await Qs(),s=r??{};zi({pid:process.pid}),J.info(r?"loaded bridge config":"initialized bridge config");try{let k=new mn;s.frameworksCache=await k.detectAll(),J.info("refreshed frameworks_cache",{detected:Object.keys(s.frameworksCache)})}catch(k){J.warn("framework detection failed",{err:String(k)})}await Er(s);let a=new So(new kr),c=se(),d=null,u=new eo({upstream:a,paths:c,bridgeConfig:s,sessionSpawner:async(k,N,q,Z)=>{if(!d)throw new Error("agentManager not ready");return d.spawnSessionDownstream(k,N,q,Z)}});await _E(c,u);let x=new Zs({paths:c,config:s,registry:u});d=x;let p,_,w=null,S={},b,E=null;u.registerExtension("_agent/create",async k=>x.createAgent(k.params)),u.registerExtension("_agent/health",async()=>({ok:!0}));let v={},C=new qs({agents:u.agents,disposeAndMarkDisconnected:async(k,N)=>{let q=u.agents.get(k);if(q){await x.cleanupOpenclawSessionProviders(q).catch(fe=>J.warn("cleanup openclaw providers failed (ignored)",{agentId:k,err:String(fe)}));let Z=!0;try{await q.dispose(`disconnect: ${N}`)}catch(fe){Z=!1,J.error("dispose during disconnect FAILED, leaving agent in error state",{agentId:k,err:String(fe)}),q.status="error"}Z&&(q.status="disconnected",u.unregister(k),u.disconnectedAgents.add(k))}else u.disconnectedAgents.add(k)},detailSyncer:async k=>{if(!v.ref)throw new Error("agent-detail-sync not initialized yet");await v.ref.syncOne(k)},cleanupOpenclawProviders:async k=>{await x.cleanupOpenclawSessionProviders(k)},openclawRepair:async(k,N)=>{await x.openclawRepair(k,N)},isRuntimePendingPermission:k=>u.hasPendingPermissionFor(k)});u.registerExtension("_agent/listSkills",k=>C.listSkills(k.params)),u.registerExtension("_agent/addSkills",k=>C.addSkills(k.params)),u.registerExtension("_agent/removeSkills",k=>C.removeSkills(k.params)),u.registerExtension("_agent/getFileTree",k=>C.getFileTree(k.params)),u.registerExtension("_agent/getFileContent",k=>C.getFileContent(k.params)),u.registerExtension("_agent/update",k=>C.updateAgent(k.params)),u.registerExtension("_agent/disconnect",k=>C.disconnectAgent(k.params)),u.registerExtension("_agent/switchModel",k=>C.switchModel(k.params)),u.registerExtension("_agent/reset",k=>C.resetAgent(k.params)),u.registerExtension("_agent/repair",k=>C.repairAgent(k.params));let D=new Vi({paths:c,handlers:C,sendDetail:k=>u.sendRequest("_agent/detail",k)});v.ref=D;let O=async k=>{await Promise.allSettled(k.map(async N=>{try{await C.disconnectAgent({agentId:N.agentId,reason:`auth_failure: code=${N.code} ${N.message}`}),J.info("agent disconnected due to auth failure from heartbeat response",{agentId:N.agentId,code:N.code,message:N.message})}catch(q){J.warn("disconnect during authFailure handling failed (ignored)",{agentId:N.agentId,err:String(q)})}}))};a.onConnect(({initial:k})=>{J.info("frontier upstream connected, triggering detail sync",{initial:k}),D.syncAll(k?"initial-connect":"reconnect").catch(N=>J.warn("detail sync top-level error (ignored)",{err:String(N)}))});let y=new to({paths:c,routes:[{method:"GET",path:"/status",handler:async()=>{let k=u.getMockScenario();return{running:!0,pid:process.pid,agents:[...u.agents.keys()],deviceId:w??"",frameworksCache:s.frameworksCache??{},...k?{mockScenario:k}:{}}}},{method:"POST",path:"/pair",handler:async k=>{let N=k,q=N?.privatecode,Z=N?.pairing_code;if(!q||!Z)throw new T("IPC_BAD_REQUEST","/pair requires privatecode + pairing_code");let fe=xi(N.env),ge=N.handshake_url,Se=N.frontier_url,Fe=Px(N.env,ge,Se),ct=!!p&&p!==q,ke=_!==void 0&&_!==Fe,Wt=ct||ke,Ie=await fc({privatecode:q,...ge?{endpoint:ge}:{},ppeOverride:fe});if(Wt){J.warn("pair config switched, resetting agents",{pcChanged:ct,envChanged:ke,previousPc:p?Ao(p):"",nextPc:Ao(q),previousEnvKey:_??"",nextEnvKey:Fe});for(let Ee of[...u.agents.values()])await Ee.dispose("pair config switch").catch(()=>{}),u.agents.delete(Ee.agentId);u.disconnectedAgents.size>0&&(J.info("clearing disconnectedAgents set on pair config switch",{count:u.disconnectedAgents.size}),u.disconnectedAgents.clear()),await a.swap(new kr,"pair switch").catch(()=>{})}w=Ie.deviceId,zi({deviceId:w,pid:process.pid}),Ic({patToken:q,env:N.env}).catch(Ee=>J.warn("coze-cli setup error (ignored)",{err:String(Ee)}));let te=new Li({handshake:Ie,privatecode:q,...Se?{urlOverride:Se}:{},ppeOverride:fe,getPatTokenForAgent:Ee=>u.agents.get(Ee)?.patToken});await a.swap(te,"pair");try{let Ee=new mn;s.frameworksCache=await Ee.detectAll(),await Er(s),J.info("frameworks_cache refreshed before pair",{detected:Object.keys(s.frameworksCache)})}catch(Ee){J.warn("frameworks_cache refresh failed (ignored, using cached)",{err:String(Ee)})}let qn=Object.keys(s.frameworksCache??{});try{let Ee=await u.sendRequest("_agent/pair",{pairCode:Z,patToken:q,frameworks:qn,_meta:{cozeDeviceId:w}});J.info("_agent/pair ok",{pairResult:Ee}),p=q,_=Fe,S=fe,b=ge,N.mock_scenario!==void 0&&(u.setMockScenario(N.mock_scenario),J.info("mock scenario set",{scenario:N.mock_scenario})),Oi(q,c).catch(Ve=>J.warn("writePatToken after /pair failed (ignored)",{err:String(Ve)})),E||(E=new pi({core:u,getDeviceId:()=>w??"",onTickEnd:()=>D.retryPending().catch(Ve=>J.warn("detailSync.retryPending failed (ignored)",{err:String(Ve)})),onAuthFailures:O})),E.start(),Wt&&To(c,x).catch(Ve=>J.warn("post-pair-switch auto-revive error (ignored)",{err:String(Ve)}));let Hn;return N.agent_id&&(Hn=await yE(N.agent_id,c,x,Ve=>u.sendRequest("_agent/detail",Ve),q).catch(Ve=>(J.error("--agent-id ensureAgent failed",{agentId:N.agent_id,err:String(Ve)}),{ok:!1,agentId:N.agent_id??"",note:String(Ve)}))),{ok:!0,note:"paired with cloud",...Hn?{agent:Hn}:{}}}catch(Ee){return J.error("_agent/pair failed",{err:String(Ee)}),{ok:!1,note:`pair failed: ${String(Ee)}`}}}},{method:"POST",path:"/connect",handler:async k=>{let N=k,q=N?.privatecode;if(!q)throw new T("IPC_BAD_REQUEST","/connect requires privatecode");let Z=xi(N.env),fe=N.handshake_url,ge=N.frontier_url,Se=Px(N.env,fe,ge);if(p===q&&_===Se){let te=await wE(c);return u.agents.size===0&&te?(J.warn("/connect noop but core.agents empty with configs on disk; re-running auto-revive"),To(c,x).catch(qn=>J.warn("connect-noop auto-revive error (ignored)",{err:String(qn)}))):J.info("/connect: already connected with same PAT + env, noop"),{ok:!0,note:"already connected"}}let Fe=!!p&&p!==q,ct=_!==void 0&&_!==Se,ke=Fe||ct,Wt=await fc({privatecode:q,...fe?{endpoint:fe}:{},ppeOverride:Z});if(ke){J.warn("connect config switched, resetting agents",{pcChanged:Fe,envChanged:ct,previousPc:p?Ao(p):"",nextPc:Ao(q)});for(let te of[...u.agents.values()])await te.dispose("connect config switch").catch(()=>{}),u.agents.delete(te.agentId);u.disconnectedAgents.size>0&&(J.info("clearing disconnectedAgents set on connect config switch",{count:u.disconnectedAgents.size}),u.disconnectedAgents.clear()),await a.swap(new kr,"connect switch").catch(()=>{})}w=Wt.deviceId,zi({deviceId:w,pid:process.pid}),Ic({patToken:q,env:N.env}).catch(te=>J.warn("coze-cli setup error (ignored)",{err:String(te)}));let Ie=new Li({handshake:Wt,privatecode:q,...ge?{urlOverride:ge}:{},ppeOverride:Z,getPatTokenForAgent:te=>u.agents.get(te)?.patToken});return await a.swap(Ie,"connect"),p=q,_=Se,S=Z,b=fe,N.mock_scenario!==void 0&&(u.setMockScenario(N.mock_scenario),J.info("mock scenario set",{scenario:N.mock_scenario})),E||(E=new pi({core:u,getDeviceId:()=>w??"",onTickEnd:()=>D.retryPending().catch(te=>J.warn("detailSync.retryPending failed (ignored)",{err:String(te)})),onAuthFailures:O})),E.start(),ke&&To(c,x).catch(te=>J.warn("post-connect-switch auto-revive error (ignored)",{err:String(te)})),Oi(q,c).catch(te=>J.warn("writePatToken after /connect failed (ignored)",{err:String(te)})),J.info("/connect: WS established",{deviceId:w}),{ok:!0,note:"connected"}}},{method:"POST",path:"/_agent/create",handler:async k=>{let N=k;return{ok:!0,result:await x.createAgent(N)}}},{method:"POST",path:"/agent/send",handler:async k=>{let N=k;if(!N?.agentId||!N?.sessionId||!N?.kind||!N?.path)throw new T("IPC_BAD_REQUEST","/agent/send requires agentId, sessionId, kind, path");if(!p)throw new T("UPSTREAM_NOT_READY","daemon not yet paired with cloud (run --pair-code first)");try{let q=N;return await(q.groupFile?qu:Uu)(q,{core:u,patToken:p,handshakeBase:b,ppeOverride:S})}catch(q){if(q instanceof T)return{ok:!1,code:q.code,message:q.message};throw q}}},{method:"POST",path:"/refresh",handler:async()=>{J.info("IPC /refresh: re-detecting frameworks");let k=new mn;return s.frameworksCache=await k.detectAll(),await Er(s),{ok:!0,frameworks:s.frameworksCache}}},{method:"POST",path:"/shutdown",handler:async()=>(J.info("IPC /shutdown received"),setImmediate(()=>{z.shutdown("ipc /shutdown")}),{ok:!0})}]}),{port:A,token:R}=await y.start();try{await Tx(c.libEntry,c)}catch(k){J.warn("bin shim install failed (D72 send \u547D\u4EE4\u53EF\u80FD\u4E0D\u53EF\u7528)",{err:String(k)})}await u.start(),To(c,x).catch(k=>J.warn("auto-revive top-level error (ignored)",{err:String(k)})),G0().then(async()=>{let{probeAcpVersion:k}=await Promise.resolve().then(()=>(Xt(),H0));for(let N of["claude-code","codex"]){let q=await k(N);q&&J.info("acp wrapper version",{framework:N,version:q})}}).catch(k=>J.warn("acp wrapper warmup / probe top-level error (ignored)",{err:String(k)}));let U=null,z={port:A,token:R,core:u,ipc:y,shutdown(k){return U||(J.info("daemon shutdown",{reason:k}),U=(async()=>{E?.stop(),await u.stop(k),await y.stop(),await t.release()})(),U)}};for(let k of["SIGTERM","SIGINT"])process.on(k,()=>{z.shutdown(k).then(()=>process.exit(0))});return process.on("unhandledRejection",k=>{J.error("unhandledRejection",{reason:k instanceof Error?k.message:String(k),stack:k instanceof Error?k.stack:void 0})}),process.on("uncaughtException",k=>{J.error("uncaughtException (will exit, supervisor will restart)",{message:k.message,stack:k.stack,name:k.name}),process.exit(1)}),J.info("daemon ready",{port:A,pid:process.pid,nodeVersion:process.version,platform:process.platform,frameworks:Object.keys(s.frameworksCache??{}),libVersion:s.libVersion??"dev"}),z}async function wE(t){let{readdir:e}=await import("node:fs/promises");try{return(await e(t.agentsRoot)).length>0}catch{return!1}}function Ao(t){return t.length<=8?"***":`${t.slice(0,4)}***${t.slice(-4)}`}function Px(t,e,r){return`${t??""}|${e??""}|${r??""}`}async function _E(t,e){let{readdir:r}=await import("node:fs/promises"),s;try{s=await r(t.agentsRoot)}catch{return}let{loadAgentConfig:a,enforceAgentConfigMode:c}=await Promise.resolve().then(()=>(Yt(),$i));for(let d of s){await c(d,t).catch(u=>J.warn("enforceAgentConfigMode failed (ignored)",{agentId:d,err:String(u)}));try{let u=await a(d,t);u?.disconnectedAt&&(e.disconnectedAgents.add(d),J.info("agent marked disconnected on startup",{agentId:d,disconnectedAt:u.disconnectedAt,reason:u.disconnectReason??""}))}catch(u){J.warn("failed to load agent config on startup, skipping",{agentId:d,err:String(u)})}}}async function yE(t,e,r,s,a){let{loadAgentConfig:c}=await Promise.resolve().then(()=>(Yt(),$i)),d=await c(t,e);if(d){J.info("--agent-id: local config found, reconnecting",{agentId:t,framework:d.framework,hadDisconnect:!!d.disconnectedAt});let _={agentId:d.agentId,framework:d.framework,...d.cozeIdentity?{cozeIdentity:d.cozeIdentity}:{},...d.model?{model:d.model}:{},...a?{patToken:a}:{}};return await r.createAgent(_),{ok:!0,agentId:t,note:d.disconnectedAt?"revived from local config":"connected from local config"}}J.info("--agent-id: local config missing, pulling _agent/detail from cloud",{agentId:t});let u=await s({_meta:{cozeAgentId:t}});if(!u.framework)throw new T("AGENT_NOT_FOUND",`agent ${t} \u4E0D\u5728\u672C\u5730; \u4E91\u7AEF _agent/detail \u54CD\u5E94\u7F3A framework \u5B57\u6BB5 (D36 \u534F\u8BAE\u6269\u5C55\u672A\u751F\u6548), \u65E0\u6CD5\u5728\u672C\u673A\u65B0\u5EFA`);let x={agentId:u.agentId,framework:u.framework,...u.cozeIdentity?{cozeIdentity:u.cozeIdentity}:{},...u.model?{model:u.model}:{},...a?{patToken:a}:{},...u.deployType?{_meta:{cozeDeployType:u.deployType}}:{}};await r.createAgent(x);let p=u.deployType==="cloud"&&u.framework==="openclaw";return{ok:!0,agentId:t,note:p?"cloud agent acknowledged":"created from cloud detail"}}async function To(t,e){let{readdir:r}=await import("node:fs/promises"),s;try{s=await r(t.agentsRoot)}catch{return{revived:0,skipped:0,total:0}}if(s.length===0)return{revived:0,skipped:0,total:0};let{loadAgentConfig:a}=await Promise.resolve().then(()=>(Yt(),$i));J.info("auto-revive: scanning local agents on startup",{count:s.length});let c=0,d=0;for(let u of s){let x;try{x=await a(u,t)}catch(p){J.warn("auto-revive: load config failed (skipping)",{agentId:u,err:String(p)}),d+=1;continue}if(!x){d+=1;continue}if(x.disconnectedAt){J.info("auto-revive: skip disconnected agent",{agentId:u,disconnectedAt:x.disconnectedAt}),d+=1;continue}try{J.info("auto-revive: re-registering agent (D44 no spawn)",{agentId:u,framework:x.framework});let p=bE(x);await e.createAgent({agentId:x.agentId,framework:x.framework,...x.cozeIdentity?{cozeIdentity:x.cozeIdentity}:{},...x.model?{model:x.model}:{},...p?{_meta:p}:{}}),c+=1}catch(p){J.warn("auto-revive: createAgent failed (skipping)",{agentId:u,framework:x.framework,err:String(p)}),d+=1}}return J.info("auto-revive: done",{revived:c,skipped:d,total:s.length}),{revived:c,skipped:d,total:s.length}}function bE(t){let e={};return t.deployType&&(e.cozeDeployType=t.deployType),t.accountId&&(e.cozeAccountId=t.accountId),Object.keys(e).length>0?e:void 0}n0();qe();import{readFile as Mx}from"node:fs/promises";var Gt=class{paths;constructor(e){this.paths=e??se()}async probe(e=1e3){let r=await Do(this.paths);if(!r)return{kind:"not-running"};try{let s=await this.fetch(r,{method:"GET",path:"/status",timeoutMs:e});return s.status===200?{kind:"connected",...r}:{kind:"stale",reason:`unexpected status ${s.status}`}}catch(s){return{kind:"stale",reason:DE(s)}}}async request(e){let r=await Do(this.paths);if(!r)throw new Error("coze-bridge daemon not running (no port/token files)");return this.fetch(r,e)}async fetch(e,r){let s=r.body!==void 0,a={Authorization:`Bearer ${e.token}`};s&&(a["content-type"]="application/json");let c=new AbortController,d=setTimeout(()=>c.abort(),r.timeoutMs??5e3);try{let u=await fetch(`http://127.0.0.1:${e.port}${r.path}`,{method:r.method,headers:a,body:s?JSON.stringify(r.body):void 0,signal:c.signal}),x=await u.text();return{status:u.status,body:TE(x)}}finally{clearTimeout(d)}}};async function Do(t){try{let[e,r]=await Promise.all([Mx(t.portFile,"utf8"),Mx(t.tokenFile,"utf8")]),s=Number.parseInt(e.trim(),10),a=r.trim();return!Number.isFinite(s)||s<=0||!a?null:{port:s,token:a}}catch(e){if(e.code==="ENOENT")return null;throw e}}function TE(t){if(!t)return null;try{return JSON.parse(t)}catch{return t}}function DE(t){return t instanceof Error?t.message:String(t)}ie();qe();import{copyFile as Bx,mkdir as RE,readFile as r0,writeFile as kE}from"node:fs/promises";import{homedir as uA}from"node:os";import{dirname as LE,resolve as i0,sep as Ro}from"node:path";import{fileURLToPath as OE}from"node:url";ie();qe();var zx=$("dist-install");function PE(t){let e=OE(t),r=LE(e),s=`${Ro}src${Ro}`;if(r.includes(s)||r.endsWith(`${Ro}src${Ro}cli`))return null;let a=i0(r,"index.js"),c=i0(r,"..","package.json");return{dist:a,pkgJson:c}}async function s0(t={}){let e=t.paths??se(),r=PE(import.meta.url),s=t.sourceDist??r?.dist,a=t.sourcePackageJson??r?.pkgJson;if(!s||!a)return{kind:"dev-mode-skip",reason:"running from src/(tsx loader);no dist/ to install"};let c;try{c=JSON.parse(await r0(a,"utf8")).version??"unknown"}catch(w){return zx.warn("cannot read source package.json,skip dist install",{err:String(w)}),{kind:"dev-mode-skip",reason:`package.json read failed: ${String(w)}`}}let d=await Qs(e.configFile)??{},u=d.libVersion;if(u===c)try{return await r0(e.libEntry),{kind:"already-current",libVersion:c}}catch{}await RE(e.libDir,{recursive:!0}),await Bx(s,e.libEntry),await Bx(`${s}.map`,`${e.libEntry}.map`).catch(()=>{});let x=i0(e.libDir,"package.json"),p=`${JSON.stringify({type:"module"},null,2)}
|
|
127
|
-
`;return await
|
|
92
|
+
`}async function Ax(t,e=te()){let r=e.binDir;await Eo.mkdir(r,{recursive:!0});let s=ib(r,process.platform==="win32"?"coze-bridge.cmd":"coze-bridge"),a=process.execPath,c=process.platform==="win32"?ob(t,a):sb(t,a);return await Eo.readFile(s,"utf8").catch(()=>null)===c||(await Eo.writeFile(s,c,"utf8"),process.platform!=="win32"&&await Eo.chmod(s,493)),r}ee();Me();import{execSync as Tx}from"node:child_process";import{readFileSync as Dx,unlinkSync as ab}from"node:fs";import{mkdir as cb,readFile as Rx,unlink as kx,writeFile as db}from"node:fs/promises";import{dirname as fb}from"node:path";function Cx(t){try{return process.kill(t,0),!0}catch(e){return e.code==="EPERM"}}var lb=H("single-instance"),bo=class{pidFile;acquired=!1;constructor(e={}){this.pidFile=e.pidFile??te().pidFile,e.processTitle&&(process.title=e.processTitle)}async acquire(){let e=await this.readExistingPid();return e!==null&&this.isAlive(e)?{kind:"already-running",pid:e}:(e!==null&&(lb.warn("removing stale pid file",{stalePid:e}),await kx(this.pidFile).catch(()=>{})),await cb(fb(this.pidFile),{recursive:!0}),await db(this.pidFile,String(process.pid),"utf8"),this.acquired=!0,this.installCleanupHooks(),{kind:"acquired"})}async release(){if(this.acquired){try{(await Rx(this.pidFile,"utf8")).trim()===String(process.pid)&&await kx(this.pidFile)}catch{}this.acquired=!1}}async readExistingPid(){try{let e=await Rx(this.pidFile,"utf8"),r=Number.parseInt(e.trim(),10);return Number.isFinite(r)&&r>0?r:null}catch(e){if(e.code==="ENOENT")return null;throw e}}isAlive(e){return Cx(e)?this.matchesDaemonTitle(e):!1}matchesDaemonTitle(e){if(process.platform==="win32")return this.matchesDaemonTitleWindows(e);try{let r=Dx(`/proc/${e}/cmdline`,"utf8").replace(/\0/g," ");return!!(r.includes("coze-bridge-daemon")||r.includes("lib/index.js"))}catch{}try{let r=Tx(`ps -o command= -p ${e}`,{stdio:["ignore","pipe","ignore"],timeout:1e3}).toString();return r.trim()?r.includes("coze-bridge-daemon")||r.includes("lib/index.js"):!1}catch{return!0}}matchesDaemonTitleWindows(e){try{let s=Tx(`tasklist /FI "PID eq ${e}" /FO CSV /NH`,{stdio:["ignore","pipe","ignore"],timeout:2e3}).toString().trim();if(!s||/^(INFO|信息)[::]/.test(s))return!1;let a=s.split(",",1)[0]?.replace(/^"|"$/g,"").toLowerCase()??"";return a.includes("node")||a.includes("coze-bridge")}catch{return!0}}installCleanupHooks(){process.once("exit",()=>{if(this.acquired)try{Dx(this.pidFile,"utf8").trim()===String(process.pid)&&ab(this.pidFile)}catch{}})}};var G=H("daemon"),ub="coze-bridge-daemon";async function Px(){let t=new bo({processTitle:ub}),e=await t.acquire();if(e.kind==="already-running")throw new Error(`coze-bridge daemon already running (pid=${e.pid})`);let r=await Js(),s=r??{};Li({pid:process.pid}),G.info(r?"loaded bridge config":"initialized bridge config");try{let O=new gn;s.frameworksCache=await O.detectAll(),G.info("refreshed frameworks_cache",{detected:Object.keys(s.frameworksCache)})}catch(O){G.warn("framework detection failed",{err:String(O)})}await Er(s);let a=new yo(new Rr),c=te(),f=null,l=new Zs({upstream:a,paths:c,bridgeConfig:s,sessionSpawner:async(O,N,U,W)=>{if(!f)throw new Error("agentManager not ready");return f.spawnSessionDownstream(O,N,U,W)}});await hb(c,l);let x=new Ws({paths:c,config:s,registry:l});f=x;let h,m,E=null,C={},_,y=null;l.registerExtension("_agent/create",async O=>x.createAgent(O.params)),l.registerExtension("_agent/health",async()=>({ok:!0}));let v={},I=new Bs({agents:l.agents,disposeAndMarkDisconnected:async(O,N)=>{let U=l.agents.get(O);if(U){await x.cleanupOpenclawSessionProviders(U).catch(se=>G.warn("cleanup openclaw providers failed (ignored)",{agentId:O,err:String(se)}));let W=!0;try{await U.dispose(`disconnect: ${N}`)}catch(se){W=!1,G.error("dispose during disconnect FAILED, leaving agent in error state",{agentId:O,err:String(se)}),U.status="error"}W&&(U.status="disconnected",l.unregister(O),l.disconnectedAgents.add(O))}else l.disconnectedAgents.add(O)},detailSyncer:async O=>{if(!v.ref)throw new Error("agent-detail-sync not initialized yet");await v.ref.syncOne(O)},cleanupOpenclawProviders:async O=>{await x.cleanupOpenclawSessionProviders(O)},openclawRepair:async(O,N)=>{await x.openclawRepair(O,N)},isRuntimePendingPermission:O=>l.hasPendingPermissionFor(O)});l.registerExtension("_agent/listSkills",O=>I.listSkills(O.params)),l.registerExtension("_agent/addSkills",O=>I.addSkills(O.params)),l.registerExtension("_agent/removeSkills",O=>I.removeSkills(O.params)),l.registerExtension("_agent/getFileTree",O=>I.getFileTree(O.params)),l.registerExtension("_agent/getFileContent",O=>I.getFileContent(O.params)),l.registerExtension("_agent/update",O=>I.updateAgent(O.params)),l.registerExtension("_agent/disconnect",O=>I.disconnectAgent(O.params)),l.registerExtension("_agent/switchModel",O=>I.switchModel(O.params)),l.registerExtension("_agent/reset",O=>I.resetAgent(O.params)),l.registerExtension("_agent/repair",O=>I.repairAgent(O.params));let R=new Gi({paths:c,handlers:I,sendDetail:O=>l.sendRequest("_agent/detail",O)});v.ref=R;let L=async O=>{await Promise.allSettled(O.map(async N=>{try{await I.disconnectAgent({agentId:N.agentId,reason:`auth_failure: code=${N.code} ${N.message}`}),G.info("agent disconnected due to auth failure from heartbeat response",{agentId:N.agentId,code:N.code,message:N.message})}catch(U){G.warn("disconnect during authFailure handling failed (ignored)",{agentId:N.agentId,err:String(U)})}}))};a.onConnect(({initial:O})=>{G.info("frontier upstream connected, triggering detail sync",{initial:O}),R.syncAll(O?"initial-connect":"reconnect").catch(N=>G.warn("detail sync top-level error (ignored)",{err:String(N)}))});let w=new Ys({paths:c,routes:[{method:"GET",path:"/status",handler:async()=>{let O=l.getMockScenario();return{running:!0,pid:process.pid,agents:[...l.agents.keys()],deviceId:E??"",frameworksCache:s.frameworksCache??{},...O?{mockScenario:O}:{}}}},{method:"POST",path:"/pair",handler:async O=>{let N=O,U=N?.privatecode,W=N?.pairing_code;if(!U||!W)throw new D("IPC_BAD_REQUEST","/pair requires privatecode + pairing_code");let se=fi(N.env),fe=N.handshake_url,we=N.frontier_url,Le=Ox(N.env,fe,we),ot=!!h&&h!==U,Ae=m!==void 0&&m!==Le,Gt=ot||Ae,_e=await oc({privatecode:U,...fe?{endpoint:fe}:{},ppeOverride:se});if(Gt){G.warn("pair config switched, resetting agents",{pcChanged:ot,envChanged:Ae,previousPc:h?So(h):"",nextPc:So(U),previousEnvKey:m??"",nextEnvKey:Le});for(let ge of[...l.agents.values()])await ge.dispose("pair config switch").catch(()=>{}),l.agents.delete(ge.agentId);l.disconnectedAgents.size>0&&(G.info("clearing disconnectedAgents set on pair config switch",{count:l.disconnectedAgents.size}),l.disconnectedAgents.clear()),await a.swap(new Rr,"pair switch").catch(()=>{})}E=_e.deviceId,Li({deviceId:E,pid:process.pid}),bc({patToken:U,env:N.env}).catch(ge=>G.warn("coze-cli setup error (ignored)",{err:String(ge)}));let Y=new Di({handshake:_e,privatecode:U,...we?{urlOverride:we}:{},ppeOverride:se,getPatTokenForAgent:ge=>l.agents.get(ge)?.patToken});await a.swap(Y,"pair");try{let ge=new gn;s.frameworksCache=await ge.detectAll(),await Er(s),G.info("frameworks_cache refreshed before pair",{detected:Object.keys(s.frameworksCache)})}catch(ge){G.warn("frameworks_cache refresh failed (ignored, using cached)",{err:String(ge)})}let Un=Object.keys(s.frameworksCache??{});try{let ge=await l.sendRequest("_agent/pair",{pairCode:W,patToken:U,frameworks:Un,_meta:{cozeDeviceId:E}});G.info("_agent/pair ok",{pairResult:ge}),h=U,m=Le,C=se,_=fe,N.mock_scenario!==void 0&&(l.setMockScenario(N.mock_scenario),G.info("mock scenario set",{scenario:N.mock_scenario})),Ri(U,c).catch(Ke=>G.warn("writePatToken after /pair failed (ignored)",{err:String(Ke)})),y||(y=new ui({core:l,getDeviceId:()=>E??"",onTickEnd:()=>R.retryPending().catch(Ke=>G.warn("detailSync.retryPending failed (ignored)",{err:String(Ke)})),onAuthFailures:L})),y.start(),Gt&&vo(c,x).catch(Ke=>G.warn("post-pair-switch auto-revive error (ignored)",{err:String(Ke)}));let qn;return N.agent_id&&(qn=await pb(N.agent_id,c,x,Ke=>l.sendRequest("_agent/detail",Ke),U).catch(Ke=>(G.error("--agent-id ensureAgent failed",{agentId:N.agent_id,err:String(Ke)}),{ok:!1,agentId:N.agent_id??"",note:String(Ke)}))),{ok:!0,note:"paired with cloud",...qn?{agent:qn}:{}}}catch(ge){return G.error("_agent/pair failed",{err:String(ge)}),{ok:!1,note:`pair failed: ${String(ge)}`}}}},{method:"POST",path:"/connect",handler:async O=>{let N=O,U=N?.privatecode;if(!U)throw new D("IPC_BAD_REQUEST","/connect requires privatecode");let W=fi(N.env),se=N.handshake_url,fe=N.frontier_url,we=Ox(N.env,se,fe);if(h===U&&m===we){let Y=await xb(c);return l.agents.size===0&&Y?(G.warn("/connect noop but core.agents empty with configs on disk; re-running auto-revive"),vo(c,x).catch(Un=>G.warn("connect-noop auto-revive error (ignored)",{err:String(Un)}))):G.info("/connect: already connected with same PAT + env, noop"),{ok:!0,note:"already connected"}}let Le=!!h&&h!==U,ot=m!==void 0&&m!==we,Ae=Le||ot,Gt=await oc({privatecode:U,...se?{endpoint:se}:{},ppeOverride:W});if(Ae){G.warn("connect config switched, resetting agents",{pcChanged:Le,envChanged:ot,previousPc:h?So(h):"",nextPc:So(U)});for(let Y of[...l.agents.values()])await Y.dispose("connect config switch").catch(()=>{}),l.agents.delete(Y.agentId);l.disconnectedAgents.size>0&&(G.info("clearing disconnectedAgents set on connect config switch",{count:l.disconnectedAgents.size}),l.disconnectedAgents.clear()),await a.swap(new Rr,"connect switch").catch(()=>{})}E=Gt.deviceId,Li({deviceId:E,pid:process.pid}),bc({patToken:U,env:N.env}).catch(Y=>G.warn("coze-cli setup error (ignored)",{err:String(Y)}));let _e=new Di({handshake:Gt,privatecode:U,...fe?{urlOverride:fe}:{},ppeOverride:W,getPatTokenForAgent:Y=>l.agents.get(Y)?.patToken});return await a.swap(_e,"connect"),h=U,m=we,C=W,_=se,N.mock_scenario!==void 0&&(l.setMockScenario(N.mock_scenario),G.info("mock scenario set",{scenario:N.mock_scenario})),y||(y=new ui({core:l,getDeviceId:()=>E??"",onTickEnd:()=>R.retryPending().catch(Y=>G.warn("detailSync.retryPending failed (ignored)",{err:String(Y)})),onAuthFailures:L})),y.start(),Ae&&vo(c,x).catch(Y=>G.warn("post-connect-switch auto-revive error (ignored)",{err:String(Y)})),Ri(U,c).catch(Y=>G.warn("writePatToken after /connect failed (ignored)",{err:String(Y)})),G.info("/connect: WS established",{deviceId:E}),{ok:!0,note:"connected"}}},{method:"POST",path:"/_agent/create",handler:async O=>{let N=O;return{ok:!0,result:await x.createAgent(N)}}},{method:"POST",path:"/agent/send",handler:async O=>{let N=O;if(!N?.agentId||!N?.sessionId||!N?.kind||!N?.path)throw new D("IPC_BAD_REQUEST","/agent/send requires agentId, sessionId, kind, path");if(!h)throw new D("UPSTREAM_NOT_READY","daemon not yet paired with cloud (run --pair-code first)");try{let U=N;return await(U.groupFile?Fl:zl)(U,{core:l,patToken:h,handshakeBase:_,ppeOverride:C})}catch(U){if(U instanceof D)return{ok:!1,code:U.code,message:U.message};throw U}}},{method:"POST",path:"/refresh",handler:async()=>{G.info("IPC /refresh: re-detecting frameworks");let O=new gn;return s.frameworksCache=await O.detectAll(),await Er(s),{ok:!0,frameworks:s.frameworksCache}}},{method:"POST",path:"/shutdown",handler:async()=>(G.info("IPC /shutdown received"),setImmediate(()=>{z.shutdown("ipc /shutdown")}),{ok:!0})}]}),{port:A,token:k}=await w.start();try{await Ax(c.libEntry,c)}catch(O){G.warn("bin shim install failed (D72 send \u547D\u4EE4\u53EF\u80FD\u4E0D\u53EF\u7528)",{err:String(O)})}await l.start(),vo(c,x).catch(O=>G.warn("auto-revive top-level error (ignored)",{err:String(O)})),H0().then(async()=>{let{probeAcpVersion:O}=await Promise.resolve().then(()=>(Zt(),U0));for(let N of["claude-code","codex"]){let U=await O(N);U&&G.info("acp wrapper version",{framework:N,version:U})}}).catch(O=>G.warn("acp wrapper warmup / probe top-level error (ignored)",{err:String(O)}));let F=null,z={port:A,token:k,core:l,ipc:w,shutdown(O){return F||(G.info("daemon shutdown",{reason:O}),F=(async()=>{y?.stop(),await l.stop(O),await w.stop(),await t.release()})(),F)}};for(let O of["SIGTERM","SIGINT"])process.on(O,()=>{z.shutdown(O).then(()=>process.exit(0))});return process.on("unhandledRejection",O=>{G.error("unhandledRejection",{reason:O instanceof Error?O.message:String(O),stack:O instanceof Error?O.stack:void 0})}),process.on("uncaughtException",O=>{G.error("uncaughtException (will exit, supervisor will restart)",{message:O.message,stack:O.stack,name:O.name}),process.exit(1)}),G.info("daemon ready",{port:A,pid:process.pid,nodeVersion:process.version,platform:process.platform,frameworks:Object.keys(s.frameworksCache??{}),libVersion:s.libVersion??"dev"}),z}async function xb(t){let{readdir:e}=await import("node:fs/promises");try{return(await e(t.agentsRoot)).length>0}catch{return!1}}function So(t){return t.length<=8?"***":`${t.slice(0,4)}***${t.slice(-4)}`}function Ox(t,e,r){return`${t??""}|${e??""}|${r??""}`}async function hb(t,e){let{readdir:r}=await import("node:fs/promises"),s;try{s=await r(t.agentsRoot)}catch{return}let{loadAgentConfig:a,enforceAgentConfigMode:c}=await Promise.resolve().then(()=>(Yt(),ji));for(let f of s){await c(f,t).catch(l=>G.warn("enforceAgentConfigMode failed (ignored)",{agentId:f,err:String(l)}));try{let l=await a(f,t);l?.disconnectedAt&&(e.disconnectedAgents.add(f),G.info("agent marked disconnected on startup",{agentId:f,disconnectedAt:l.disconnectedAt,reason:l.disconnectReason??""}))}catch(l){G.warn("failed to load agent config on startup, skipping",{agentId:f,err:String(l)})}}}async function pb(t,e,r,s,a){let{loadAgentConfig:c}=await Promise.resolve().then(()=>(Yt(),ji)),f=await c(t,e);if(f){G.info("--agent-id: local config found, reconnecting",{agentId:t,framework:f.framework,hadDisconnect:!!f.disconnectedAt});let m={agentId:f.agentId,framework:f.framework,...f.cozeIdentity?{cozeIdentity:f.cozeIdentity}:{},...f.model?{model:f.model}:{},...a?{patToken:a}:{}};return await r.createAgent(m),{ok:!0,agentId:t,note:f.disconnectedAt?"revived from local config":"connected from local config"}}G.info("--agent-id: local config missing, pulling _agent/detail from cloud",{agentId:t});let l=await s({_meta:{cozeAgentId:t}});if(!l.framework)throw new D("AGENT_NOT_FOUND",`agent ${t} \u4E0D\u5728\u672C\u5730; \u4E91\u7AEF _agent/detail \u54CD\u5E94\u7F3A framework \u5B57\u6BB5 (D36 \u534F\u8BAE\u6269\u5C55\u672A\u751F\u6548), \u65E0\u6CD5\u5728\u672C\u673A\u65B0\u5EFA`);let x={agentId:l.agentId,framework:l.framework,...l.cozeIdentity?{cozeIdentity:l.cozeIdentity}:{},...l.model?{model:l.model}:{},...a?{patToken:a}:{},...l.deployType?{_meta:{cozeDeployType:l.deployType}}:{}};await r.createAgent(x);let h=l.deployType==="cloud"&&l.framework==="openclaw";return{ok:!0,agentId:t,note:h?"cloud agent acknowledged":"created from cloud detail"}}async function vo(t,e){let{readdir:r}=await import("node:fs/promises"),s;try{s=await r(t.agentsRoot)}catch{return{revived:0,skipped:0,total:0}}if(s.length===0)return{revived:0,skipped:0,total:0};let{loadAgentConfig:a}=await Promise.resolve().then(()=>(Yt(),ji));G.info("auto-revive: scanning local agents on startup",{count:s.length});let c=0,f=0;for(let l of s){let x;try{x=await a(l,t)}catch(h){G.warn("auto-revive: load config failed (skipping)",{agentId:l,err:String(h)}),f+=1;continue}if(!x){f+=1;continue}if(x.disconnectedAt){G.info("auto-revive: skip disconnected agent",{agentId:l,disconnectedAt:x.disconnectedAt}),f+=1;continue}try{G.info("auto-revive: re-registering agent (D44 no spawn)",{agentId:l,framework:x.framework});let h=gb(x);await e.createAgent({agentId:x.agentId,framework:x.framework,...x.cozeIdentity?{cozeIdentity:x.cozeIdentity}:{},...x.model?{model:x.model}:{},...h?{_meta:h}:{}}),c+=1}catch(h){G.warn("auto-revive: createAgent failed (skipping)",{agentId:l,framework:x.framework,err:String(h)}),f+=1}}return G.info("auto-revive: done",{revived:c,skipped:f,total:s.length}),{revived:c,skipped:f,total:s.length}}function gb(t){let e={};return t.deployType&&(e.cozeDeployType=t.deployType),t.accountId&&(e.cozeAccountId=t.accountId),Object.keys(e).length>0?e:void 0}Qc();Me();import{readFile as Lx}from"node:fs/promises";var jt=class{paths;constructor(e){this.paths=e??te()}async probe(e=1e3){let r=await Io(this.paths);if(!r)return{kind:"not-running"};try{let s=await this.fetch(r,{method:"GET",path:"/status",timeoutMs:e});return s.status===200?{kind:"connected",...r}:{kind:"stale",reason:`unexpected status ${s.status}`}}catch(s){return{kind:"stale",reason:vb(s)}}}async request(e){let r=await Io(this.paths);if(!r)throw new Error("coze-bridge daemon not running (no port/token files)");return this.fetch(r,e)}async fetch(e,r){let s=r.body!==void 0,a={Authorization:`Bearer ${e.token}`};s&&(a["content-type"]="application/json");let c=new AbortController,f=setTimeout(()=>c.abort(),r.timeoutMs??5e3);try{let l=await fetch(`http://127.0.0.1:${e.port}${r.path}`,{method:r.method,headers:a,body:s?JSON.stringify(r.body):void 0,signal:c.signal}),x=await l.text();return{status:l.status,body:Sb(x)}}finally{clearTimeout(f)}}};async function Io(t){try{let[e,r]=await Promise.all([Lx(t.portFile,"utf8"),Lx(t.tokenFile,"utf8")]),s=Number.parseInt(e.trim(),10),a=r.trim();return!Number.isFinite(s)||s<=0||!a?null:{port:s,token:a}}catch(e){if(e.code==="ENOENT")return null;throw e}}function Sb(t){if(!t)return null;try{return JSON.parse(t)}catch{return t}}function vb(t){return t instanceof Error?t.message:String(t)}ee();Me();import{copyFile as Nx,mkdir as Ib,readFile as e0,writeFile as Ab}from"node:fs/promises";import{homedir as s5}from"node:os";import{dirname as Cb,resolve as t0,sep as Ao}from"node:path";import{fileURLToPath as Tb}from"node:url";ee();Me();var Mx=H("dist-install");function Db(t){let e=Tb(t),r=Cb(e),s=`${Ao}src${Ao}`;if(r.includes(s)||r.endsWith(`${Ao}src${Ao}cli`))return null;let a=t0(r,"index.js"),c=t0(r,"..","package.json");return{dist:a,pkgJson:c}}async function n0(t={}){let e=t.paths??te(),r=Db(import.meta.url),s=t.sourceDist??r?.dist,a=t.sourcePackageJson??r?.pkgJson;if(!s||!a)return{kind:"dev-mode-skip",reason:"running from src/(tsx loader);no dist/ to install"};let c;try{c=JSON.parse(await e0(a,"utf8")).version??"unknown"}catch(E){return Mx.warn("cannot read source package.json,skip dist install",{err:String(E)}),{kind:"dev-mode-skip",reason:`package.json read failed: ${String(E)}`}}let f=await Js(e.configFile)??{},l=f.libVersion;if(l===c)try{return await e0(e.libEntry),{kind:"already-current",libVersion:c}}catch{}await Ib(e.libDir,{recursive:!0}),await Nx(s,e.libEntry),await Nx(`${s}.map`,`${e.libEntry}.map`).catch(()=>{});let x=t0(e.libDir,"package.json"),h=`${JSON.stringify({type:"module"},null,2)}
|
|
93
|
+
`;return await e0(x,"utf8").catch(()=>null)!==h&&await Ab(x,h),f.libVersion=c,await Er(f,e.configFile),Mx.info("dist installed",{libEntry:e.libEntry,fromVersion:l,toVersion:c}),l?{kind:"version-changed",fromVersion:l,toVersion:c,libEntry:e.libEntry}:{kind:"first-install",libVersion:c,libEntry:e.libEntry}}import{basename as Rb,resolve as kb}from"node:path";Me();var Ob=9e4,Pb={PATH_OUTSIDE_WORKSPACE:3,FILE_TOO_LARGE:3,UNSUPPORTED_MIME:3,MODEL_MODALITY_UNSUPPORTED:3,IPC_BAD_REQUEST:3,AGENT_NOT_FOUND:4,IPC_AUTH_FAILED:4,AGENT_DISCONNECTED:5,UPLOAD_FAILED:5,UPSTREAM_NOT_READY:5,UPSTREAM_DISCONNECTED:5,UPSTREAM_HANDSHAKE_FAILED:5,AGENT_BUSY:1,AGENT_SPAWN_FAILED:1,AGENT_TIMEOUT:1,AGENT_FRAME_IDLE_TIMEOUT:1,AGENT_PROTOCOL_ERROR:1,BRIDGE_CONFIG_INVALID:1,BRIDGE_INTERNAL:1,MODEL_TOKEN_GEN_FAILED:1,OPERATION_NOT_ALLOWED_FOR_LOCAL:1,NPX_CACHE_CORRUPT:1};function Lb(t){return Pb[t]??1}async function Bx(t,e={}){let r=e.paths??te();if(!t.agentId||!t.sessionId)return process.stderr.write(`Error: missing --agent-id and/or --session-id. These IDs come from the <coze-context> block injected at the top of each prompt \u2014 extract agentId and sessionId from there and pass them as flags. Example: coze-bridge send image x.png --agent-id <id> --session-id <id>
|
|
128
94
|
`),4;if(t.groupFile&&!t.mimeType)return process.stderr.write(`Error: --group-file requires --mime <mimeType> (e.g. application/pdf, image/png). No local file is read in group-file mode, mime cannot be auto-detected.
|
|
129
|
-
`),3;let s=await
|
|
130
|
-
`),4;let a={agentId:t.agentId,sessionId:t.sessionId,kind:t.kind,path:t.groupFile?t.path:
|
|
95
|
+
`),3;let s=await Io(r).catch(()=>null);if(!s)return process.stderr.write(`Error: coze-bridge daemon not running (cannot read ${r.portFile} / ${r.tokenFile}). Make sure you are inside an agent session spawned by the daemon.
|
|
96
|
+
`),4;let a={agentId:t.agentId,sessionId:t.sessionId,kind:t.kind,path:t.groupFile?t.path:kb(process.cwd(),t.path),...t.caption?{caption:t.caption}:{},...t.name?{name:t.name}:{},...t.groupFile?{groupFile:!0}:{},...t.mimeType?{mimeType:t.mimeType}:{}},c;try{c=await Nb(s,"/agent/send",a,Ob)}catch(f){return process.stderr.write(`Error: daemon IPC failed: ${f instanceof Error?f.message:String(f)}
|
|
131
97
|
`),4}if(!c.ok)return process.stderr.write(`Error: ${c.code}: ${c.message}
|
|
132
|
-
`),
|
|
133
|
-
`);else{let
|
|
134
|
-
`)}else process.stdout.write(`Sent ${t.kind} ${
|
|
135
|
-
`)}return 0}async function
|
|
136
|
-
`)}function
|
|
98
|
+
`),Lb(c.code);if(t.json)process.stdout.write(`${JSON.stringify(c)}
|
|
99
|
+
`);else{let f=t.name??Rb(a.path);if(t.groupFile){let l=c.uri.length>60?`${c.uri.slice(0,57)}...`:c.uri;process.stdout.write(`Sent group file ${f} (uri=${l})
|
|
100
|
+
`)}else process.stdout.write(`Sent ${t.kind} ${f} (${Mb(c.bytes)})
|
|
101
|
+
`)}return 0}async function Nb(t,e,r,s){let a=new AbortController,c=setTimeout(()=>a.abort(),s);try{let f=await fetch(`http://127.0.0.1:${t.port}${e}`,{method:"POST",headers:{Authorization:`Bearer ${t.token}`,"content-type":"application/json"},body:JSON.stringify(r),signal:a.signal}),l=await f.text(),x=l?JSON.parse(l):null;return x&&typeof x=="object"&&"ok"in x?x:{ok:!1,code:"BRIDGE_INTERNAL",message:`unexpected daemon response (status=${f.status}): ${l.slice(0,200)}`}}finally{clearTimeout(c)}}function Mb(t){return t<1024?`${t}B`:t<1024*1024?`${(t/1024).toFixed(1)}KB`:`${(t/1024/1024).toFixed(1)}MB`}var Kx=H("cli");function ze(t,e){let r=[],s;for(let a=0;a<t.length;a++){let c=t[a];if(c===e){s=t[a+1],a+=1;continue}if(c.startsWith(`${e}=`)){s=c.slice(e.length+1);continue}r.push(c)}return{value:s,rest:r}}function ki(t,e){process.stderr.write(`[deprecated] '${t}' will be removed in a future release, use '${e}' instead
|
|
102
|
+
`)}function t2(t){let e=t.slice(2);if(e.includes("--version")||e.includes("-v"))return{mode:"version"};if(e.includes("--daemon"))return{mode:"daemon"};if(e[0]==="status")return{mode:"status"};if(e[0]==="stop")return{mode:"stop"};if(e[0]==="refresh")return{mode:"refresh"};if(e[0]==="purge")return{mode:"purge"};if(e[0]==="service")return e[1]==="install"?{mode:"service-install"}:e[1]==="uninstall"?{mode:"service-uninstall"}:{mode:"help"};if(e[0]==="send")return n2(e.slice(1));if(e[0]==="connect")return r2(e.slice(1));if(e.includes("--status"))return ki("--status","coze-bridge status"),{mode:"status"};if(e.includes("--stop"))return ki("--stop","coze-bridge stop"),{mode:"stop"};if(e.includes("--refresh"))return ki("--refresh","coze-bridge refresh"),{mode:"refresh"};if(e.includes("--uninstall"))return ki("--uninstall","coze-bridge purge"),{mode:"purge"};if(e.includes("--install-service"))return ki("--install-service","coze-bridge service install"),{mode:"service-install"};if(e.includes("--help")||e.includes("-h")||e.length===0)return{mode:"help"};let r=e,{value:s,rest:a}=ze(r,"--pat-token");r=a;let{value:c,rest:f}=ze(r,"--pair-code");r=f;let{value:l,rest:x}=ze(r,"--env");r=x;let{value:h,rest:m}=ze(r,"--handshake-url");r=m;let{value:E,rest:C}=ze(r,"--frontier-url");r=C;let{value:_,rest:y}=ze(r,"--mock-scenario");r=y;let{value:v}=ze(r,"--agent-id");if(!s||!c)return{mode:"help"};let I={mode:"pair",privatecode:s,pairingCode:c};return l&&(I.env=l),h&&(I.handshakeUrl=h),E&&(I.frontierUrl=E),_&&(I.mockScenario=_),v&&(I.agentId=v),I}function n2(t){let e=t[0],r=t[1];if(e!=="image"&&e!=="file")return{mode:"help"};if(!r||r.startsWith("--"))return{mode:"help"};let s=t.slice(2),{value:a,rest:c}=ze(s,"--caption");s=c;let{value:f,rest:l}=ze(s,"--name");s=l;let{value:x,rest:h}=ze(s,"--agent-id");s=h;let{value:m,rest:E}=ze(s,"--session-id");s=E;let{value:C,rest:_}=ze(s,"--mime");s=_;let y=s.includes("--group-file");s=s.filter(R=>R!=="--group-file");let v=s.includes("--json"),I={mode:"send",kind:e,path:r,json:v};return a&&(I.caption=a),f&&(I.name=f),x&&(I.agentId=x),m&&(I.sessionId=m),y&&(I.groupFile=!0),C&&(I.mimeType=C),I}function r2(t){let e=t,{value:r,rest:s}=ze(e,"--pat-token");e=s;let{value:a,rest:c}=ze(e,"--env");e=c;let{value:f,rest:l}=ze(e,"--handshake-url");e=l;let{value:x,rest:h}=ze(e,"--frontier-url");e=h;let{value:m,rest:E}=ze(e,"--mock-scenario");e=E;let C={mode:"connect"};return r&&(C.privatecode=r),a&&(C.env=a),f&&(C.handshakeUrl=f),x&&(C.frontierUrl=x),m&&(C.mockScenario=m),C}var i2=`
|
|
137
103
|
coze-bridge - local bridge daemon for cloud Agent Service
|
|
138
104
|
|
|
139
105
|
Pair (paste from cloud UI; start/reuse daemon and deliver pair-code):
|
|
@@ -200,46 +166,46 @@ Deprecated flags (still work, but emit a warning; will be removed in a future re
|
|
|
200
166
|
|
|
201
167
|
Internal:
|
|
202
168
|
<node> <entry> --daemon daemon mode (OS supervisor only)
|
|
203
|
-
`.trimStart();async function
|
|
204
|
-
`),0;case"daemon":{try{await
|
|
205
|
-
`),1;if(s.kind==="stale")return await
|
|
169
|
+
`.trimStart();async function Wx(t=process.argv,e={}){let r=t2(t);switch(r.mode){case"help":return process.stdout.write(i2),0;case"version":return process.stdout.write(`${gr}
|
|
170
|
+
`),0;case"daemon":{try{await Px()}catch(s){return Kx.error("daemon start failed",{err:String(s)}),1}return new Promise(()=>{})}case"status":return s2(e);case"stop":return o2(e);case"refresh":return a2(e);case"purge":return c2(e);case"service-install":return d2(e);case"service-uninstall":return f2(e);case"pair":{let s={};return r.env&&(s.env=r.env),r.handshakeUrl&&(s.handshakeUrl=r.handshakeUrl),r.frontierUrl&&(s.frontierUrl=r.frontierUrl),r.mockScenario&&(s.mockScenario=r.mockScenario),l2(r.privatecode,r.pairingCode,e,s,r.agentId)}case"connect":{let s={};return r.env&&(s.env=r.env),r.handshakeUrl&&(s.handshakeUrl=r.handshakeUrl),r.frontierUrl&&(s.frontierUrl=r.frontierUrl),r.mockScenario&&(s.mockScenario=r.mockScenario),u2(r.privatecode,e,s)}case"send":return Bx({kind:r.kind,path:r.path,...r.agentId?{agentId:r.agentId}:{},...r.sessionId?{sessionId:r.sessionId}:{},...r.caption?{caption:r.caption}:{},...r.name?{name:r.name}:{},...r.groupFile?{groupFile:!0}:{},...r.mimeType?{mimeType:r.mimeType}:{},json:r.json},e)}}async function $x(t){let{unlink:e}=await import("node:fs/promises");await Promise.all([e(t.pidFile).catch(()=>{}),e(t.portFile).catch(()=>{}),e(t.tokenFile).catch(()=>{})])}async function s2(t){let e=t.paths??te(),r=new jt(e),s=await r.probe();if(s.kind==="not-running")return process.stdout.write(`coze-bridge: not running
|
|
171
|
+
`),1;if(s.kind==="stale")return await $x(e),process.stdout.write(`coze-bridge: not running (cleaned stale state)
|
|
206
172
|
`),1;let a=await r.request({method:"GET",path:"/status"});return process.stdout.write(`coze-bridge: running
|
|
207
173
|
${JSON.stringify(a.body,null,2)}
|
|
208
|
-
`),0}async function
|
|
209
|
-
`),0;if(s.kind==="stale")return await
|
|
174
|
+
`),0}async function o2(t){let e=t.paths??te(),r=new jt(e),s=await r.probe();if(s.kind==="not-running")return process.stdout.write(`coze-bridge: not running
|
|
175
|
+
`),0;if(s.kind==="stale")return await $x(e),process.stdout.write(`coze-bridge: not running (cleaned stale state)
|
|
210
176
|
`),0;try{return await r.request({method:"POST",path:"/shutdown"}),process.stdout.write(`coze-bridge: stopped
|
|
211
177
|
`),0}catch(a){return process.stdout.write(`coze-bridge: stop failed: ${String(a)}
|
|
212
|
-
`),1}}async function
|
|
178
|
+
`),1}}async function a2(t){let e=new jt(t.paths);if((await e.probe()).kind==="not-running")return process.stdout.write(`coze-bridge: not running (start daemon first)
|
|
213
179
|
`),1;try{let s=await e.request({method:"POST",path:"/refresh",timeoutMs:35e3});return s.status===200?(process.stdout.write(`coze-bridge: refreshed
|
|
214
180
|
${JSON.stringify(s.body,null,2)}
|
|
215
181
|
`),0):(process.stderr.write(`coze-bridge: refresh failed: ${JSON.stringify(s.body)}
|
|
216
182
|
`),1)}catch(s){return process.stderr.write(`coze-bridge: refresh failed: ${String(s)}
|
|
217
|
-
`),1}}async function
|
|
218
|
-
`);try{await e.request({method:"POST",path:"/shutdown"})}catch(
|
|
219
|
-
`)}await new Promise(
|
|
220
|
-
`)}catch(
|
|
221
|
-
`)}let a=t.paths??
|
|
222
|
-
`)}catch(
|
|
183
|
+
`),1}}async function c0(t){if(t.supervisor){let c=t.supervisor,f={nodeBin:"",entry:"",logFile:"",homeDir:"",userName:""};return{platform:c.platform,install:()=>c.install(f),uninstall:()=>c.uninstall(f)}}if(t.skipSupervisor)return;let{getSupervisor:e,buildContext:r}=await Promise.resolve().then(()=>(Gx(),jx)),s=e(),a=r();return{platform:s.platform,install:()=>s.install(a),uninstall:()=>s.uninstall(a)}}async function c2(t){let e=new jt(t.paths);if((await e.probe()).kind==="connected"){process.stdout.write(`coze-bridge: stopping daemon...
|
|
184
|
+
`);try{await e.request({method:"POST",path:"/shutdown"})}catch(f){process.stderr.write(`coze-bridge: stop failed (continuing): ${String(f)}
|
|
185
|
+
`)}await new Promise(f=>setTimeout(f,500))}let s=await c0(t);if(s)try{await s.uninstall(),process.stdout.write(`coze-bridge: ${s.platform} supervisor unregistered
|
|
186
|
+
`)}catch(f){process.stderr.write(`coze-bridge: supervisor uninstall failed (continuing): ${String(f)}
|
|
187
|
+
`)}let a=t.paths??te(),{rm:c}=await import("node:fs/promises");try{await c(a.bridgeRoot,{recursive:!0,force:!0}),process.stdout.write(`coze-bridge: removed ${a.bridgeRoot}
|
|
188
|
+
`)}catch(f){return process.stderr.write(`coze-bridge: remove failed: ${String(f)}
|
|
223
189
|
`),1}return process.stdout.write(`coze-bridge: purged (agents workspaces preserved under ~/.coze/agents)
|
|
224
|
-
`),0}async function
|
|
190
|
+
`),0}async function d2(t){let e=await c0(t);if(!e)return 0;try{return process.stdout.write(`coze-bridge: installing ${e.platform} supervisor...
|
|
225
191
|
`),await e.install(),process.stdout.write(`coze-bridge: supervisor installed (daemon will auto-start on login)
|
|
226
192
|
`),0}catch(r){return process.stderr.write(`coze-bridge: service install failed: ${String(r)}
|
|
227
|
-
`),1}}async function
|
|
193
|
+
`),1}}async function f2(t){let e=await c0(t);if(!e)return 0;try{return await e.uninstall(),process.stdout.write(`coze-bridge: ${e.platform} supervisor unregistered
|
|
228
194
|
`),0}catch(r){return process.stderr.write(`coze-bridge: service uninstall failed: ${String(r)}
|
|
229
|
-
`),1}}async function
|
|
230
|
-
`),(await c.probe()).kind==="connected"&&(await c.request({method:"POST",path:"/shutdown"}).catch(()=>{}),await new Promise(
|
|
231
|
-
`)}let
|
|
232
|
-
`),await
|
|
233
|
-
`),1;let x={privatecode:t,pairing_code:e};s.env&&(x.env=s.env),s.handshakeUrl&&(x.handshake_url=s.handshakeUrl),s.frontierUrl&&(x.frontier_url=s.frontierUrl),s.mockScenario&&(x.mock_scenario=s.mockScenario),a&&(x.agent_id=a);try{let
|
|
195
|
+
`),1}}async function l2(t,e,r,s={},a){let c=new jt(r.paths),f=r.spawnDaemon??Xc;if(!r.skipDistInstall){let h=await n0({paths:r.paths});h.kind==="version-changed"?(process.stdout.write(`coze-bridge: upgraded ${h.fromVersion} \u2192 ${h.toVersion}
|
|
196
|
+
`),(await c.probe()).kind==="connected"&&(await c.request({method:"POST",path:"/shutdown"}).catch(()=>{}),await new Promise(E=>setTimeout(E,500)))):h.kind==="first-install"&&process.stdout.write(`coze-bridge: installed ${h.libVersion}
|
|
197
|
+
`)}let l=await c.probe();if(l.kind!=="connected"&&(process.stdout.write(`coze-bridge: starting daemon...
|
|
198
|
+
`),await f({paths:r.paths}),l=await Vx(c,r.waitTimeoutMs??1e4,r.sleep??Jx),l.kind!=="connected"))return process.stderr.write(`coze-bridge: daemon did not come up: ${l.kind}
|
|
199
|
+
`),1;let x={privatecode:t,pairing_code:e};s.env&&(x.env=s.env),s.handshakeUrl&&(x.handshake_url=s.handshakeUrl),s.frontierUrl&&(x.frontier_url=s.frontierUrl),s.mockScenario&&(x.mock_scenario=s.mockScenario),a&&(x.agent_id=a);try{let h=await c.request({method:"POST",path:"/pair",body:x,timeoutMs:35e3});if(h.status===200&&h.body?.ok){let m=h.body.agent;return m&&!m.ok?(process.stderr.write(`coze-bridge: paired but agent ensure failed (agentId=${m.agentId}): ${m.note}
|
|
234
200
|
`),1):(process.stdout.write(`\u5DF2\u914D\u5BF9\u8FDE\u63A5\u5B8C\u6210\uFF0C\u8BF7\u8FD4\u56DE\u5230 coze \u5E73\u53F0\u4E0A\u70B9\u51FB "\u6211\u5DF2\u6267\u884C"
|
|
235
|
-
`),0)}return process.stderr.write(`coze-bridge: pair failed: ${JSON.stringify(
|
|
236
|
-
`),1}catch(
|
|
237
|
-
`),1}}async function
|
|
238
|
-
`),(await c.probe()).kind==="connected"&&(await c.request({method:"POST",path:"/shutdown"}).catch(()=>{}),await new Promise(
|
|
239
|
-
`)}let
|
|
240
|
-
`),await
|
|
241
|
-
`),1;let x={privatecode:a};r.env&&(x.env=r.env),r.handshakeUrl&&(x.handshake_url=r.handshakeUrl),r.frontierUrl&&(x.frontier_url=r.frontierUrl),r.mockScenario&&(x.mock_scenario=r.mockScenario);try{let
|
|
242
|
-
`),await
|
|
243
|
-
`),1)}catch(
|
|
244
|
-
`),1}}async function
|
|
201
|
+
`),0)}return process.stderr.write(`coze-bridge: pair failed: ${JSON.stringify(h.body)}
|
|
202
|
+
`),1}catch(h){return process.stderr.write(`coze-bridge: pair failed: ${String(h)}
|
|
203
|
+
`),1}}async function u2(t,e,r={}){let s=e.paths??te(),a=t??await Ix(s);if(!a)return process.stderr.write("coze-bridge: \u627E\u4E0D\u5230 patToken \u2014 \u5148\u8DD1\u4E00\u6B21 `coze-bridge --pat-token=<sat_xxx> --pair-code=<xxx>` \u914D\u5BF9, \u6216\u672C\u6B21\u7528 `--pat-token` \u6307\u5B9A\n"),1;let c=new jt(e.paths),f=e.spawnDaemon??Xc;if(!e.skipDistInstall){let h=await n0({paths:e.paths});h.kind==="version-changed"?(process.stdout.write(`coze-bridge: upgraded ${h.fromVersion} \u2192 ${h.toVersion}
|
|
204
|
+
`),(await c.probe()).kind==="connected"&&(await c.request({method:"POST",path:"/shutdown"}).catch(()=>{}),await new Promise(E=>setTimeout(E,500)))):h.kind==="first-install"&&process.stdout.write(`coze-bridge: installed ${h.libVersion}
|
|
205
|
+
`)}let l=await c.probe();if(l.kind!=="connected"&&(process.stdout.write(`coze-bridge: starting daemon...
|
|
206
|
+
`),await f({paths:e.paths}),l=await Vx(c,e.waitTimeoutMs??1e4,e.sleep??Jx),l.kind!=="connected"))return process.stderr.write(`coze-bridge: daemon did not come up: ${l.kind}
|
|
207
|
+
`),1;let x={privatecode:a};r.env&&(x.env=r.env),r.handshakeUrl&&(x.handshake_url=r.handshakeUrl),r.frontierUrl&&(x.frontier_url=r.frontierUrl),r.mockScenario&&(x.mock_scenario=r.mockScenario);try{let h=await c.request({method:"POST",path:"/connect",body:x,timeoutMs:35e3});return h.status===200&&h.body?.ok?(process.stdout.write(`coze-bridge: connected (${h.body.note??"ok"})
|
|
208
|
+
`),await Ri(a,s).catch(m=>Kx.warn("writePatToken after connect failed (ignored)",{err:String(m)})),0):(process.stderr.write(`coze-bridge: connect failed: ${JSON.stringify(h.body)}
|
|
209
|
+
`),1)}catch(h){return process.stderr.write(`coze-bridge: connect failed: ${String(h)}
|
|
210
|
+
`),1}}async function Vx(t,e,r){let s=Date.now()+e;for(;Date.now()<s;){let a=await t.probe(500);if(a.kind==="connected")return a;await r(200)}return t.probe(500)}function Jx(t){return new Promise(e=>setTimeout(e,t))}ee();!process.argv.includes("--daemon")&&!process.env.COZE_BRIDGE_LOG_LEVEL&&O0("warn");Wx(process.argv).then(t=>process.exit(t),t=>{process.stderr.write(`fatal: ${t instanceof Error?t.stack??t.message:String(t)}
|
|
245
211
|
`),process.exit(1)});
|