coze-bridge 0.1.99 → 0.1.100-alpha.1
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 +72 -72
- package/package.json +1 -1
package/dist/index.js
CHANGED
|
@@ -5,30 +5,30 @@ 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
|
|
8
|
+
var Up=Object.create;var pa=Object.defineProperty;var Gp=Object.getOwnPropertyDescriptor;var qp=Object.getOwnPropertyNames;var Hp=Object.getPrototypeOf,jp=Object.prototype.hasOwnProperty;var ue=(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 Je=(t,e)=>()=>(t&&(e=t(t=0)),e);var ae=(t,e)=>()=>(e||t((e={exports:{}}).exports,e),e.exports),ga=(t,e)=>{for(var r in e)pa(t,r,{get:e[r],enumerable:!0})},Wp=(t,e,r,i)=>{if(e&&typeof e=="object"||typeof e=="function")for(let o of qp(e))!jp.call(t,o)&&o!==r&&pa(t,o,{get:()=>e[o],enumerable:!(i=Gp(e,o))||i.enumerable});return t};var At=(t,e,r)=>(r=t!=null?Up(Hp(t)):{},Wp(e||!t||!t.__esModule?pa(r,"default",{value:t,enumerable:!0}):r,t));function Ye(t,e){let r=process.env[t];if(!r)return e;let i=Number(r);return Number.isFinite(i)&&i>0?i:e}var Wr=Je(()=>{"use strict"});import{createWriteStream as Kp,mkdirSync as $p,readdirSync as Vp,unlinkSync as Zp}from"node:fs";import{join as nl}from"node:path";function An(t){let e=r=>String(r).padStart(2,"0");return`${t.getFullYear()}-${e(t.getMonth()+1)}-${e(t.getDate())}`}function Xn(t,e){return`${t}-${e}.log`}function ma(t,e){let r=t.match(/^(.+)-(\d{4}-\d{2}-\d{2})\.log$/);return!r||r[1]!==e?null:r[2]??null}function Jp(t,e,r){let i=c=>{let[l,u,h]=c.split("-").map(Number);return Date.UTC(l??0,(u??1)-1,h??1)};return Math.floor((i(e)-i(t))/864e5)>r}function es(t,e,r,i){let o;try{o=Vp(t)}catch{return}for(let c of o){let l=ma(c,e);if(l&&Jp(l,r,i))try{Zp(nl(t,c))}catch{}}}var Kr,wa=Je(()=>{"use strict";Kr=class{constructor(e,r,i){this.dir=e;this.prefix=r;this.opts=i;this.clock=i.clock??(()=>An(new Date))}dir;prefix;opts;currentDate;stream;clock;write(e){let r=this.clock();r!==this.currentDate&&this.rotate(r),this.stream?.write(e)}rotate(e){this.stream?.end();try{$p(this.dir,{recursive:!0});let r=Kp(nl(this.dir,Xn(this.prefix,e)),{flags:"a"});r.on("error",i=>process.stderr.write(`[log-sink] stream error: ${String(i)}
|
|
9
9
|
`)),this.stream=r}catch(r){process.stderr.write(`[log-sink] rotate failed: ${String(r)}
|
|
10
|
-
`),this.stream=void 0;return}this.currentDate!==void 0&&
|
|
11
|
-
`;
|
|
12
|
-
`;if(
|
|
13
|
-
`),{cause:o})}}async function
|
|
14
|
-
`,o=`${t}.tmp-${process.pid}-${Math.random().toString(36).slice(2,10)}`;try{r?.mode!==void 0?await yl(o,i,{encoding:"utf8",mode:r.mode}):await yl(o,i,"utf8"),await _l(o,t),r?.mode!==void 0&&await hg(t,r.mode)}catch(c){await _l(o,o).catch(()=>{});let{rm:l}=await import("node:fs/promises");throw await l(o,{force:!0}).catch(()=>{}),c}}var Qr=Ye(()=>{"use strict"});import{promises as bl,readdirSync as wg}from"node:fs";import{homedir as _g}from"node:os";import{sep as yg,join as Ie,resolve as El}from"node:path";function X(t){let e=t??_g(),r=Ie(e,".coze"),i=Ie(r,"bridge"),o=Ie(i,"lib"),c=Ie(i,"logs");return{cozeRoot:r,bridgeRoot:i,libDir:o,libEntry:Ie(o,"index.js"),binDir:Ie(i,"bin"),pidFile:Ie(i,"bridge.pid"),portFile:Ie(i,"bridge.port"),tokenFile:Ie(i,"bridge.token"),patTokenFile:Ie(i,"pat-token"),agentEnvFile:Ie(i,"agent-env.json"),logFile:Ie(i,"bridge.log"),bridgeLogsDir:c,daemonStdioLog:Ie(c,"daemon-stdio.log"),installLock:Ie(i,"install.lock"),configFile:Ie(i,"config.json"),agentsRoot:Ie(r,"agents")}}function Ze(t,e=X()){let r=Ie(e.agentsRoot,t);return{root:r,config:Ie(r,"config.json"),workspace:Ie(r,"workspace"),logs:Ie(r,"logs")}}function ds(t=X()){try{return wg(t.agentsRoot,{withFileTypes:!0}).filter(e=>e.isDirectory()).map(e=>e.name)}catch{return[]}}async function ei(t,e){let r=await bl.realpath(El(t)).catch(()=>null);if(!r)return!1;let i=await bl.realpath(El(e)).catch(()=>null);if(!i)return!1;let o=process.platform==="win32"?r.toLowerCase():r,c=process.platform==="win32"?i.toLowerCase():i;return o===c||o.startsWith(c+yg)}var ke=Ye(()=>{"use strict"});var us={};ba(us,{AGENT_CONFIG_FILE_MODE:()=>ls,enforceAgentConfigMode:()=>vg,loadAgentConfig:()=>He,persistAgentSessions:()=>ti,persistAgentSkills:()=>fs,saveAgentConfig:()=>Xe});import{chmod as bg,stat as Eg}from"node:fs/promises";function He(t,e){return tr(Ze(t,e).config)}function Xe(t,e){return nr(Ze(t.agentId,e).config,t,{mode:ls})}async function vg(t,e){if(process.platform==="win32")return;let r=Ze(t,e).config;try{let i=await Eg(r);if(!i.isFile())return;let o=i.mode&511;o!==ls&&(await bg(r,ls),vl.warn("agent config mode auto-corrected to 0600",{path:r,from:o.toString(8)}))}catch(i){if(i.code==="ENOENT")return;vl.warn("enforceAgentConfigMode: chmod failed (ignored)",{path:r,err:String(i)})}}async function ti(t,e,r){let i=await He(t,r);i&&(i.sessions=Object.fromEntries(e),await Xe(i,r))}async function fs(t,e,r){let i=await He(t,r);i&&(i.skills=e,await Xe(i,r))}var vl,ls,rn=Ye(()=>{"use strict";Qr();ne();ke();vl=j("agent-config"),ls=384});var Ra=oe((J1,Tl)=>{Tl.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 hs=oe(Rl=>{var Cl={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 Cg(t){return function(...e){return e.length&&(t=t.replace(/\{(\d)\}/g,(r,i)=>e[i]||"")),new Error("ADM-ZIP: "+t)}}for(let t of Object.keys(Cl))Rl[t]=Cg(Cl[t])});var Nl=oe((X1,Pl)=>{var Rg=le("fs"),Oe=le("path"),Dl=Ra(),Dg=hs(),kg=typeof process=="object"&&process.platform==="win32",kl=t=>typeof t=="object"&&t!==null,Ol=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 Ee(t){this.sep=Oe.sep,this.fs=Rg,kl(t)&&kl(t.fs)&&typeof t.fs.statSync=="function"&&(this.fs=t.fs)}Pl.exports=Ee;Ee.prototype.makeDir=function(t){let e=this;function r(i){let o=i.split(e.sep)[0];i.split(e.sep).forEach(function(c){if(!(!c||c.substr(-1,1)===":")){o+=e.sep+c;var l;try{l=e.fs.statSync(o)}catch(f){if(f.message&&f.message.startsWith("ENOENT"))e.fs.mkdirSync(o);else throw f}if(l&&l.isFile())throw Dg.FILE_IN_THE_WAY(`"${o}"`)}})}r(t)};Ee.prototype.writeFileTo=function(t,e,r,i){let o=this;if(o.fs.existsSync(t)){if(!r)return!1;var c=o.fs.statSync(t);if(c.isDirectory())return!1}var l=Oe.dirname(t);o.fs.existsSync(l)||o.makeDir(l);var f;try{f=o.fs.openSync(t,"w",438)}catch{o.fs.chmodSync(t,438),f=o.fs.openSync(t,"w",438)}if(f)try{o.fs.writeSync(f,e,0,e.length,0)}finally{o.fs.closeSync(f)}return o.fs.chmodSync(t,i||438),!0};Ee.prototype.writeFileToAsync=function(t,e,r,i,o){typeof i=="function"&&(o=i,i=void 0);let c=this;c.fs.exists(t,function(l){if(l&&!r)return o(!1);c.fs.stat(t,function(f,x){if(l&&x.isDirectory())return o(!1);var h=Oe.dirname(t);c.fs.exists(h,function(_){_||c.makeDir(h),c.fs.open(t,"w",438,function(w,S){w?c.fs.chmod(t,438,function(){c.fs.open(t,"w",438,function(b,v){c.fs.write(v,e,0,e.length,0,function(){c.fs.close(v,function(){c.fs.chmod(t,i||438,function(){o(!0)})})})})}):S?c.fs.write(S,e,0,e.length,0,function(){c.fs.close(S,function(){c.fs.chmod(t,i||438,function(){o(!0)})})}):c.fs.chmod(t,i||438,function(){o(!0)})})})})})};Ee.prototype.findFiles=function(t){let e=this;function r(i,o,c){typeof o=="boolean"&&(c=o,o=void 0);let l=[];return e.fs.readdirSync(i).forEach(function(f){let x=Oe.join(i,f),h=e.fs.statSync(x);(!o||o.test(x))&&l.push(Oe.normalize(x)+(h.isDirectory()?e.sep:"")),h.isDirectory()&&c&&(l=l.concat(r(x,o,c)))}),l}return r(t,void 0,!0)};Ee.prototype.findFilesAsync=function(t,e){let r=this,i=[];r.fs.readdir(t,function(o,c){if(o)return e(o);let l=c.length;if(!l)return e(null,i);c.forEach(function(f){f=Oe.join(t,f),r.fs.stat(f,function(x,h){if(x)return e(x);h&&(i.push(Oe.normalize(f)+(h.isDirectory()?r.sep:"")),h.isDirectory()?r.findFilesAsync(f,function(_,w){if(_)return e(_);i=i.concat(w),--l||e(null,i)}):--l||e(null,i))})})})};Ee.prototype.getAttributes=function(){};Ee.prototype.setAttributes=function(){};Ee.crc32update=function(t,e){return Ol[(t^e)&255]^t>>>8};Ee.crc32=function(t){typeof t=="string"&&(t=Buffer.from(t,"utf8"));let e=t.length,r=-1;for(let i=0;i<e;)r=Ee.crc32update(r,t[i++]);return~r>>>0};Ee.methodToString=function(t){switch(t){case Dl.STORED:return"STORED ("+t+")";case Dl.DEFLATED:return"DEFLATED ("+t+")";default:return"UNSUPPORTED ("+t+")"}};Ee.canonical=function(t){if(!t)return"";let e=Oe.posix.normalize("/"+t.split("\\").join("/"));return Oe.join(".",e)};Ee.zipnamefix=function(t){if(!t)return"";let e=Oe.posix.normalize("/"+t.split("\\").join("/"));return Oe.posix.join(".",e)};Ee.findLast=function(t,e){if(!Array.isArray(t))throw new TypeError("arr is not array");let r=t.length>>>0;for(let i=r-1;i>=0;i--)if(e(t[i],i,t))return t[i]};Ee.sanitize=function(t,e){t=Oe.resolve(Oe.normalize(t));for(var r=e.split("/"),i=0,o=r.length;i<o;i++){var c=Oe.normalize(Oe.join(t,r.slice(i,o).join(Oe.sep)));if(c.indexOf(t)===0)return c}return Oe.normalize(Oe.join(t,Oe.basename(e)))};Ee.toBuffer=function(e,r){return Buffer.isBuffer(e)?e:e instanceof Uint8Array?Buffer.from(e):typeof e=="string"?r(e):Buffer.alloc(0)};Ee.readBigUInt64LE=function(t,e){let r=t.readUInt32LE(e);return t.readUInt32LE(e+4)*4294967296+r};Ee.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)};Ee.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};Ee.isWin=kg;Ee.crcTable=Ol});var Ml=oe((Q1,Ll)=>{var Og=le("path");Ll.exports=function(t,{fs:e}){var r=t||"",i=c(),o=null;function c(){return{directory:!1,readonly:!1,hidden:!1,executable:!1,mtime:0,atime:0}}return r&&e.existsSync(r)?(o=e.statSync(r),i.directory=o.isDirectory(),i.mtime=o.mtime,i.atime=o.atime,i.executable=(73&o.mode)!==0,i.readonly=(128&o.mode)===0,i.hidden=Og.basename(r)[0]==="."):console.warn("Invalid path: "+r),{get directory(){return i.directory},get readOnly(){return i.readonly},get hidden(){return i.hidden},get mtime(){return i.mtime},get atime(){return i.atime},get executable(){return i.executable},decodeAttributes:function(){},encodeAttributes:function(){},toJSON:function(){return{path:r,isDirectory:i.directory,isReadOnly:i.readonly,isHidden:i.hidden,isExecutable:i.executable,mTime:i.mtime,aTime:i.atime}},toString:function(){return JSON.stringify(this.toJSON(),null," ")}}}});var Fl=oe((e2,Bl)=>{Bl.exports={efs:!0,encode:t=>Buffer.from(t,"utf8"),decode:t=>t.toString("utf8")}});var sr=oe((t2,ir)=>{ir.exports=Nl();ir.exports.Constants=Ra();ir.exports.Errors=hs();ir.exports.FileAttr=Ml();ir.exports.decoder=Fl()});var Ul=oe((n2,zl)=>{var sn=sr(),q=sn.Constants;zl.exports=function(){var t=20,e=10,r=0,i=0,o=0,c=0,l=0,f=0,x=0,h=0,_=0,w=0,S=0,b=0,v=0;t|=sn.isWin?2560:768,r|=q.FLG_EFS;let I={extraLen:0},A=y=>Math.max(0,y)>>>0,C=y=>Math.max(0,y)&65535,P=y=>Math.max(0,y)&255;return o=sn.fromDate2DOS(new Date),{get made(){return t},set made(y){t=y},get version(){return e},set version(y){e=y},get flags(){return r},set flags(y){r=y},get flags_efs(){return(r&q.FLG_EFS)>0},set flags_efs(y){y?r|=q.FLG_EFS:r&=~q.FLG_EFS},get flags_desc(){return(r&q.FLG_DESC)>0},set flags_desc(y){y?r|=q.FLG_DESC:r&=~q.FLG_DESC},get method(){return i},set method(y){switch(y){case q.STORED:this.version=10;case q.DEFLATED:default:this.version=20}i=y},get time(){return sn.fromDOS2Date(this.timeval)},set time(y){y=new Date(y),this.timeval=sn.fromDate2DOS(y)},get timeval(){return o},set timeval(y){o=A(y)},get timeHighByte(){return P(o>>>8)},get crc(){return c},set crc(y){c=A(y)},get compressedSize(){return l},set compressedSize(y){l=A(y)},get size(){return f},set size(y){f=A(y)},get fileNameLength(){return x},set fileNameLength(y){x=y},get extraLength(){return h},set extraLength(y){h=y},get extraLocalLength(){return I.extraLen},set extraLocalLength(y){I.extraLen=y},get commentLength(){return _},set commentLength(y){_=y},get diskNumStart(){return w},set diskNumStart(y){w=A(y)},get inAttr(){return S},set inAttr(y){S=A(y)},get attr(){return b},set attr(y){b=A(y)},get fileAttr(){return(b||0)>>16&4095},get offset(){return v},set offset(y){v=A(y)},get encrypted(){return(r&q.FLG_ENC)===q.FLG_ENC},get centralHeaderSize(){return q.CENHDR+x+h+_},get realDataOffset(){return v+q.LOCHDR+I.fnameLen+I.extraLen},get localHeader(){return I},loadLocalHeaderFromBinary:function(y){var R=y.slice(v,v+q.LOCHDR);if(R.readUInt32LE(0)!==q.LOCSIG)throw sn.Errors.INVALID_LOC();I.version=R.readUInt16LE(q.LOCVER),I.flags=R.readUInt16LE(q.LOCFLG),I.flags_desc=(I.flags&q.FLG_DESC)>0,I.method=R.readUInt16LE(q.LOCHOW),I.time=R.readUInt32LE(q.LOCTIM),I.crc=R.readUInt32LE(q.LOCCRC),I.compressedSize=R.readUInt32LE(q.LOCSIZ),I.size=R.readUInt32LE(q.LOCLEN),I.fnameLen=R.readUInt16LE(q.LOCNAM),I.extraLen=R.readUInt16LE(q.LOCEXT);let D=v+q.LOCHDR+I.fnameLen,B=D+I.extraLen;return y.slice(D,B)},loadFromBinary:function(y){if(y.length!==q.CENHDR||y.readUInt32LE(0)!==q.CENSIG)throw sn.Errors.INVALID_CEN();t=y.readUInt16LE(q.CENVEM),e=y.readUInt16LE(q.CENVER),r=y.readUInt16LE(q.CENFLG),i=y.readUInt16LE(q.CENHOW),o=y.readUInt32LE(q.CENTIM),c=y.readUInt32LE(q.CENCRC),l=y.readUInt32LE(q.CENSIZ),f=y.readUInt32LE(q.CENLEN),x=y.readUInt16LE(q.CENNAM),h=y.readUInt16LE(q.CENEXT),_=y.readUInt16LE(q.CENCOM),w=y.readUInt16LE(q.CENDSK),S=y.readUInt16LE(q.CENATT),b=y.readUInt32LE(q.CENATX),v=y.readUInt32LE(q.CENOFF)},localHeaderToBinary:function(){var y=Buffer.alloc(q.LOCHDR);return y.writeUInt32LE(q.LOCSIG,0),y.writeUInt16LE(e,q.LOCVER),y.writeUInt16LE(r,q.LOCFLG),y.writeUInt16LE(i,q.LOCHOW),y.writeUInt32LE(o,q.LOCTIM),y.writeUInt32LE(c,q.LOCCRC),y.writeUInt32LE(l,q.LOCSIZ),y.writeUInt32LE(f,q.LOCLEN),y.writeUInt16LE(x,q.LOCNAM),y.writeUInt16LE(I.extraLen,q.LOCEXT),y},centralHeaderToBinary:function(){var y=Buffer.alloc(q.CENHDR+x+h+_);return y.writeUInt32LE(q.CENSIG,0),y.writeUInt16LE(t,q.CENVEM),y.writeUInt16LE(e,q.CENVER),y.writeUInt16LE(r,q.CENFLG),y.writeUInt16LE(i,q.CENHOW),y.writeUInt32LE(o,q.CENTIM),y.writeUInt32LE(c,q.CENCRC),y.writeUInt32LE(l,q.CENSIZ),y.writeUInt32LE(f,q.CENLEN),y.writeUInt16LE(x,q.CENNAM),y.writeUInt16LE(h,q.CENEXT),y.writeUInt16LE(_,q.CENCOM),y.writeUInt16LE(w,q.CENDSK),y.writeUInt16LE(S,q.CENATT),y.writeUInt32LE(b,q.CENATX),y.writeUInt32LE(v,q.CENOFF),y},toJSON:function(){let y=function(R){return R+" bytes"};return{made:t,version:e,flags:r,method:sn.methodToString(i),time:this.time,crc:"0x"+c.toString(16).toUpperCase(),compressedSize:y(l),size:y(f),fileNameLength:y(x),extraLength:y(h),commentLength:y(_),diskNumStart:w,inAttr:S,attr:b,offset:v,centralHeaderSize:y(q.CENHDR+x+h+_)}},toString:function(){return JSON.stringify(this.toJSON(),null," ")}}}});var ql=oe((r2,Gl)=>{var or=sr(),we=or.Constants;Gl.exports=function(){var t=0,e=0,r=0,i=0,o=0;return{get diskEntries(){return t},set diskEntries(c){t=e=c},get totalEntries(){return e},set totalEntries(c){e=t=c},get size(){return r},set size(c){r=c},get offset(){return i},set offset(c){i=c},get commentLength(){return o},set commentLength(c){o=c},get mainHeaderSize(){return we.ENDHDR+o},loadFromBinary:function(c){if((c.length!==we.ENDHDR||c.readUInt32LE(0)!==we.ENDSIG)&&(c.length<we.ZIP64HDR||c.readUInt32LE(0)!==we.ZIP64SIG))throw or.Errors.INVALID_END();c.readUInt32LE(0)===we.ENDSIG?(t=c.readUInt16LE(we.ENDSUB),e=c.readUInt16LE(we.ENDTOT),r=c.readUInt32LE(we.ENDSIZ),i=c.readUInt32LE(we.ENDOFF),o=c.readUInt16LE(we.ENDCOM)):(t=or.readBigUInt64LE(c,we.ZIP64SUB),e=or.readBigUInt64LE(c,we.ZIP64TOT),r=or.readBigUInt64LE(c,we.ZIP64SIZE),i=or.readBigUInt64LE(c,we.ZIP64OFF),o=0)},toBinary:function(){var c=Buffer.alloc(we.ENDHDR+o);return c.writeUInt32LE(we.ENDSIG,0),c.writeUInt32LE(0,4),c.writeUInt16LE(t,we.ENDSUB),c.writeUInt16LE(e,we.ENDTOT),c.writeUInt32LE(r,we.ENDSIZ),c.writeUInt32LE(i,we.ENDOFF),c.writeUInt16LE(o,we.ENDCOM),c.fill(" ",we.ENDHDR),c},toJSON:function(){let c=function(l,f){let x=l.toString(16).toUpperCase();for(;x.length<f;)x="0"+x;return"0x"+x};return{diskEntries:t,totalEntries:e,size:r+" bytes",offset:c(i,4),commentLength:o}},toString:function(){return JSON.stringify(this.toJSON(),null," ")}}}});var ka=oe(Da=>{Da.EntryHeader=Ul();Da.MainHeader=ql()});var jl=oe((s2,Hl)=>{Hl.exports=function(t){var e=le("zlib"),r={chunkSize:(parseInt(t.length/1024)+1)*1024};return{deflate:function(){return e.deflateRawSync(t,r)},deflateAsync:function(i){var o=e.createDeflateRaw(r),c=[],l=0;o.on("data",function(f){c.push(f),l+=f.length}),o.on("end",function(){var f=Buffer.alloc(l),x=0;f.fill(0);for(var h=0;h<c.length;h++){var _=c[h];_.copy(f,x),x+=_.length}i&&i(f)}),o.end(t)}}}});var Kl=oe((o2,Wl)=>{var Pg=+(process.versions?process.versions.node:"").split(".")[0]||0;Wl.exports=function(t,e){var r=le("zlib");let i=Pg>=15&&e>0?{maxOutputLength:e}:{};return{inflate:function(){return r.inflateRawSync(t,i)},inflateAsync:function(o){var c=r.createInflateRaw(i),l=[],f=0;c.on("data",function(x){l.push(x),f+=x.length}),c.on("end",function(){var x=Buffer.alloc(f),h=0;x.fill(0);for(var _=0;_<l.length;_++){var w=l[_];w.copy(x,h),h+=w.length}o&&o(x)}),c.end(t)}}}});var Zl=oe((a2,Jl)=>{"use strict";var{randomFillSync:$l}=le("crypto"),Ng=hs(),Lg=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}),Yl=(t,e)=>Math.imul(t,e)>>>0,Vl=(t,e)=>Lg[(t^e)&255]^t>>>8,ni=()=>typeof $l=="function"?$l(Buffer.alloc(12)):ni.node();ni.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 ps={genSalt:ni};function gs(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])}gs.prototype.updateKeys=function(t){let e=this.keys;return e[0]=Vl(e[0],t),e[1]+=e[0]&255,e[1]=Yl(e[1],134775813)+1,e[2]=Vl(e[2],e[1]>>>24),t};gs.prototype.next=function(){let t=(this.keys[2]|2)>>>0;return Yl(t,t^1)>>8&255};function Mg(t){let e=new gs(t);return function(r){let i=Buffer.alloc(r.length),o=0;for(let c of r)i[o++]=e.updateKeys(c^e.next());return i}}function Bg(t){let e=new gs(t);return function(r,i,o=0){i||(i=Buffer.alloc(r.length));for(let c of r){let l=e.next();i[o++]=c^l,e.updateKeys(c)}return i}}function Fg(t,e,r){if(!t||!Buffer.isBuffer(t)||t.length<12)return Buffer.alloc(0);let i=Mg(r),o=i(t.slice(0,12)),c=(e.flags&8)===8?e.timeHighByte:e.crc>>>24;if(o[11]!==c)throw Ng.WRONG_PASSWORD();return i(t.slice(12))}function zg(t){Buffer.isBuffer(t)&&t.length>=12?ps.genSalt=function(){return t.slice(0,12)}:t==="node"?ps.genSalt=ni.node:ps.genSalt=ni}function Ug(t,e,r,i=!1){t==null&&(t=Buffer.alloc(0)),Buffer.isBuffer(t)||(t=Buffer.from(t.toString()));let o=Bg(r),c=ps.genSalt();c[11]=e.crc>>>24&255,i&&(c[10]=e.crc>>>16&255);let l=Buffer.alloc(t.length+12);return o(c,l),o(t,l,12)}Jl.exports={decrypt:Fg,encrypt:Ug,_salter:zg}});var Xl=oe(ms=>{ms.Deflater=jl();ms.Inflater=Kl();ms.ZipCrypto=Zl()});var Pa=oe((d2,Ql)=>{var ae=sr(),Gg=ka(),ve=ae.Constants,Oa=Xl();Ql.exports=function(t,e){var r=new Gg.EntryHeader,i=Buffer.alloc(0),o=Buffer.alloc(0),c=!1,l=null,f=Buffer.alloc(0),x=Buffer.alloc(0),h=!0;let _=t,w=typeof _.decoder=="object"?_.decoder:ae.decoder;h=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 R={},D=r.realDataOffset+r.compressedSize;if(e.readUInt32LE(D)==ve.LOCSIG||e.readUInt32LE(D)==ve.CENSIG)throw ae.Errors.DESCRIPTOR_NOT_EXIST();if(e.readUInt32LE(D)==ve.EXTSIG)R.crc=e.readUInt32LE(D+ve.EXTCRC),R.compressedSize=e.readUInt32LE(D+ve.EXTSIZ),R.size=e.readUInt32LE(D+ve.EXTLEN);else if(e.readUInt16LE(D+12)===19280)R.crc=e.readUInt32LE(D+ve.EXTCRC-4),R.compressedSize=e.readUInt32LE(D+ve.EXTSIZ-4),R.size=e.readUInt32LE(D+ve.EXTLEN-4);else throw ae.Errors.DESCRIPTOR_UNKNOWN();if(R.compressedSize!==r.compressedSize||R.size!==r.size||R.crc!==r.crc)throw ae.Errors.DESCRIPTOR_FAULTY();if(ae.crc32(y)!==R.crc)return!1}return!0}function v(y,R,D){if(typeof R>"u"&&typeof y=="string"&&(D=y,y=void 0),c)return y&&R&&R(Buffer.alloc(0),ae.Errors.DIRECTORY_CONTENT_ERROR()),Buffer.alloc(0);var B=S();if(B.length===0)return y&&R&&R(B),B;if(r.encrypted){if(typeof D!="string"&&!Buffer.isBuffer(D))throw ae.Errors.INVALID_PASS_PARAM();B=Oa.ZipCrypto.decrypt(B,r,D)}var G=Buffer.alloc(r.size);switch(r.method){case ae.Constants.STORED:if(B.copy(G),b(G))return y&&R&&R(G),G;throw y&&R&&R(G,ae.Errors.BAD_CRC()),ae.Errors.BAD_CRC();case ae.Constants.DEFLATED:var Y=new Oa.Inflater(B,r.size);if(y)Y.inflateAsync(function(J){J.copy(J,0),R&&(b(J)?R(J):R(J,ae.Errors.BAD_CRC()))});else{if(Y.inflate(G).copy(G,0),!b(G))throw ae.Errors.BAD_CRC(`"${w.decode(i)}"`);return G}break;default:throw y&&R&&R(Buffer.alloc(0),ae.Errors.UNKNOWN_METHOD()),ae.Errors.UNKNOWN_METHOD()}}function I(y,R){if((!l||!l.length)&&Buffer.isBuffer(e))return y&&R&&R(S()),S();if(l.length&&!c){var D;switch(r.method){case ae.Constants.STORED:return r.compressedSize=r.size,D=Buffer.alloc(l.length),l.copy(D),y&&R&&R(D),D;default:case ae.Constants.DEFLATED:var B=new Oa.Deflater(l);if(y)B.deflateAsync(function(Y){D=Buffer.alloc(Y.length),r.compressedSize=Y.length,Y.copy(D),R&&R(D)});else{var G=B.deflate();return r.compressedSize=G.length,G}B=null;break}}else if(y&&R)R(Buffer.alloc(0));else return Buffer.alloc(0)}function A(y,R){return ae.readBigUInt64LE(y,R)}function C(y){try{for(var R=0,D,B,G;R+4<y.length;)D=y.readUInt16LE(R),R+=2,B=y.readUInt16LE(R),R+=2,G=y.slice(R,R+B),R+=B,ve.ID_ZIP64===D&&P(G)}catch{throw ae.Errors.EXTRA_FIELD_PARSE_ERROR()}}function P(y){var R,D,B,G;y.length>=ve.EF_ZIP64_SCOMP&&(R=A(y,ve.EF_ZIP64_SUNCOMP),r.size===ve.EF_ZIP64_OR_32&&(r.size=R)),y.length>=ve.EF_ZIP64_RHO&&(D=A(y,ve.EF_ZIP64_SCOMP),r.compressedSize===ve.EF_ZIP64_OR_32&&(r.compressedSize=D)),y.length>=ve.EF_ZIP64_DSN&&(B=A(y,ve.EF_ZIP64_RHO),r.offset===ve.EF_ZIP64_OR_32&&(r.offset=B)),y.length>=ve.EF_ZIP64_DSN+4&&(G=y.readUInt32LE(ve.EF_ZIP64_DSN),r.diskNumStart===ve.EF_ZIP64_OR_16&&(r.diskNumStart=G))}return{get entryName(){return w.decode(i)},get rawEntryName(){return i},set entryName(y){i=ae.toBuffer(y,w.encode);var R=i[i.length-1];c=R===47||R===92,r.fileNameLength=i.length},get efs(){return typeof h=="function"?h(this.entryName):h},get extra(){return f},set extra(y){f=y,r.extraLength=y.length,C(y)},get comment(){return w.decode(o)},set comment(y){if(o=ae.toBuffer(y,w.encode),r.commentLength=o.length,o.length>65535)throw ae.Errors.COMMENT_TOO_LONG()},get name(){var y=w.decode(i);return c?y.substr(y.length-1).split("/").pop():y.split("/").pop()},get isDirectory(){return c},getCompressedData:function(){return I(!1,null)},getCompressedDataAsync:function(y){I(!0,y)},setData:function(y){l=ae.toBuffer(y,ae.decoder.encode),!c&&l.length?(r.size=l.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?l:v(!1,null,y)},getDataAsync:function(y,R){r.changed?y(l):v(!0,y,R)},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=f.length;var y=r.centralHeaderToBinary(),R=ae.Constants.CENHDR;return i.copy(y,R),R+=i.length,f.copy(y,R),R+=r.extraLength,o.copy(y,R),y},packLocalHeader:function(){let y=0;r.flags_efs=this.efs,r.extraLocalLength=x.length;let R=r.localHeaderToBinary(),D=Buffer.alloc(R.length+i.length+r.extraLocalLength);return R.copy(D,y),y+=R.length,i.copy(D,y),y+=i.length,x.copy(D,y),y+=x.length,D},toJSON:function(){let y=function(R){return"<"+(R&&R.length+" bytes buffer"||"null")+">"};return{entryName:this.entryName,name:this.name,comment:this.comment,isDirectory:this.isDirectory,header:r.toJSON(),compressedData:y(e),data:y(l)}},toString:function(){return JSON.stringify(this.toJSON(),null," ")}}}});var nf=oe((l2,tf)=>{var ef=Pa(),qg=ka(),je=sr();tf.exports=function(t,e){var r=[],i={},o=Buffer.alloc(0),c=new qg.MainHeader,l=!1,f=null;let x=new Set,h=e,{noSort:_,decoder:w}=h;t?v(h.readEntries):l=!0;function S(){let A=new Set;for(let C of Object.keys(i)){let P=C.split("/");if(P.pop(),!!P.length)for(let y=0;y<P.length;y++){let R=P.slice(0,y+1).join("/")+"/";A.add(R)}}for(let C of A)if(!(C in i)){let P=new ef(h);P.entryName=C,P.attr=16,P.temporary=!0,r.push(P),i[P.entryName]=P,x.add(P)}}function b(){if(l=!0,i={},c.diskEntries>(t.length-c.offset)/je.Constants.CENHDR)throw je.Errors.DISK_ENTRY_TOO_LARGE();r=new Array(c.diskEntries);for(var A=c.offset,C=0;C<r.length;C++){var P=A,y=new ef(h,t);y.header=t.slice(P,P+=je.Constants.CENHDR),y.entryName=t.slice(P,P+=y.header.fileNameLength),y.header.extraLength&&(y.extra=t.slice(P,P+=y.header.extraLength)),y.header.commentLength&&(y.comment=t.slice(P,P+y.header.commentLength)),A+=y.header.centralHeaderSize,r[C]=y,i[y.entryName]=y}x.clear(),S()}function v(A){var C=t.length-je.Constants.ENDHDR,P=Math.max(0,C-65535),y=P,R=t.length,D=-1,B=0;for(typeof h.trailingSpace=="boolean"&&h.trailingSpace&&(P=0),C;C>=y;C--)if(t[C]===80){if(t.readUInt32LE(C)===je.Constants.ENDSIG){D=C,B=C,R=C+je.Constants.ENDHDR,y=C-je.Constants.END64HDR;continue}if(t.readUInt32LE(C)===je.Constants.END64SIG){y=P;continue}if(t.readUInt32LE(C)===je.Constants.ZIP64SIG){D=C,R=C+je.readBigUInt64LE(t,C+je.Constants.ZIP64SIZE)+je.Constants.ZIP64LEAD;break}}if(D==-1)throw je.Errors.INVALID_FORMAT();c.loadFromBinary(t.slice(D,R)),c.commentLength&&(o=t.slice(B+je.Constants.ENDHDR)),A&&b()}function I(){r.length>1&&!_&&r.sort((A,C)=>A.entryName.toLowerCase().localeCompare(C.entryName.toLowerCase()))}return{get entries(){return l||b(),r.filter(A=>!x.has(A))},get comment(){return w.decode(o)},set comment(A){o=je.toBuffer(A,w.encode),c.commentLength=o.length},getEntryCount:function(){return l?r.length:c.diskEntries},forEach:function(A){this.entries.forEach(A)},getEntry:function(A){return l||b(),i[A]||null},setEntry:function(A){l||b(),r.push(A),i[A.entryName]=A,c.totalEntries=r.length},deleteFile:function(A,C=!0){l||b();let P=i[A];this.getEntryChildren(P,C).map(R=>R.entryName).forEach(this.deleteEntry)},deleteEntry:function(A){l||b();let C=i[A],P=r.indexOf(C);P>=0&&(r.splice(P,1),delete i[A],c.totalEntries=r.length)},getEntryChildren:function(A,C=!0){if(l||b(),typeof A=="object")if(A.isDirectory&&C){let P=[],y=A.entryName;for(let R of r)R.entryName.startsWith(y)&&P.push(R);return P}else return[A];return[]},getChildCount:function(A){if(A&&A.isDirectory){let C=this.getEntryChildren(A);return C.includes(A)?C.length-1:C.length}return 0},compressToBuffer:function(){l||b(),I();let A=[],C=[],P=0,y=0;c.size=0,c.offset=0;let R=0;for(let G of this.entries){let Y=G.getCompressedData();G.header.offset=y;let J=G.packLocalHeader(),te=J.length+Y.length;y+=te,A.push(J),A.push(Y);let Q=G.packCentralHeader();C.push(Q),c.size+=Q.length,P+=te+Q.length,R++}P+=c.mainHeaderSize,c.offset=y,c.totalEntries=R,y=0;let D=Buffer.alloc(P);for(let G of A)G.copy(D,y),y+=G.length;for(let G of C)G.copy(D,y),y+=G.length;let B=c.toBinary();return o&&o.copy(B,je.Constants.ENDHDR),B.copy(D,y),t=D,l=!1,D},toAsyncBuffer:function(A,C,P,y){try{l||b(),I();let R=[],D=[],B=0,G=0,Y=0;c.size=0,c.offset=0;let J=function(te){if(te.length>0){let Q=te.shift(),be=Q.entryName+Q.extra.toString();P&&P(be),Q.getCompressedDataAsync(function(he){y&&y(be),Q.header.offset=G;let O=Q.packLocalHeader(),W=O.length+he.length;G+=W,R.push(O),R.push(he);let $=Q.packCentralHeader();D.push($),c.size+=$.length,B+=W+$.length,Y++,J(te)})}else{B+=c.mainHeaderSize,c.offset=G,c.totalEntries=Y,G=0;let Q=Buffer.alloc(B);R.forEach(function(he){he.copy(Q,G),G+=he.length}),D.forEach(function(he){he.copy(Q,G),G+=he.length});let be=c.toBinary();o&&o.copy(be,je.Constants.ENDHDR),be.copy(Q,G),t=Q,l=!1,A(Q)}};J(Array.from(this.entries))}catch(R){C(R)}}}}});var of=oe((f2,sf)=>{var ye=sr(),_e=le("path"),Hg=Pa(),jg=nf(),Tn=(...t)=>ye.findLast(t,e=>typeof e=="boolean"),rf=(...t)=>ye.findLast(t,e=>typeof e=="string"),Wg=(...t)=>ye.findLast(t,e=>typeof e=="function"),Kg={noSort:!1,readEntries:!1,method:ye.Constants.NONE,fs:null};sf.exports=function(t,e){let r=null,i=Object.assign(Object.create(null),Kg);t&&typeof t=="object"&&(t instanceof Uint8Array||(Object.assign(i,t),t=i.input?i.input:void 0,i.input&&delete i.input),Buffer.isBuffer(t)&&(r=t,i.method=ye.Constants.BUFFER,t=void 0)),Object.assign(i,e);let o=new ye(i);if((typeof i.decoder!="object"||typeof i.decoder.encode!="function"||typeof i.decoder.decode!="function")&&(i.decoder=ye.decoder),t&&typeof t=="string")if(o.fs.existsSync(t))i.method=ye.Constants.FILE,i.filename=t,r=o.fs.readFileSync(t);else throw ye.Errors.INVALID_FILENAME();let c=new jg(r,i),{canonical:l,sanitize:f,zipnamefix:x}=ye;function h(b){if(b&&c){var v;if(typeof b=="string"&&(v=c.getEntry(_e.posix.normalize(b))),typeof b=="object"&&typeof b.entryName<"u"&&typeof b.header<"u"&&(v=c.getEntry(b.entryName)),v)return v}return null}function _(b){let{join:v,normalize:I,sep:A}=_e.posix;return v(_e.isAbsolute(b)?"/":".",I(A+b.split("\\").join(A)+A))}function w(b){return b instanceof RegExp?(function(v){return function(I){return v.test(I)}})(b):typeof b!="function"?()=>!0:b}let S=(b,v)=>{let I=v.slice(-1);return I=I===o.sep?o.sep:"",_e.relative(b,v)+I};return{readFile:function(b,v){var I=h(b);return I&&I.getData(v)||null},childCount:function(b){let v=h(b);if(v)return c.getChildCount(v)},readFileAsync:function(b,v){var I=h(b);I?I.getDataAsync(v):v(null,"getEntry failed for:"+b)},readAsText:function(b,v){var I=h(b);if(I){var A=I.getData();if(A&&A.length)return A.toString(v||"utf8")}return""},readAsTextAsync:function(b,v,I){var A=h(b);A?A.getDataAsync(function(C,P){if(P){v(C,P);return}C&&C.length?v(C.toString(I||"utf8")):v("")}):v("")},deleteFile:function(b,v=!0){var I=h(b);I&&c.deleteFile(I.entryName,v)},deleteEntry:function(b){var v=h(b);v&&c.deleteEntry(v.entryName)},addZipComment:function(b){c.comment=b},getZipComment:function(){return c.comment||""},addZipEntryComment:function(b,v){var I=h(b);I&&(I.comment=v)},getZipEntryComment:function(b){var v=h(b);return v&&v.comment||""},updateFile:function(b,v){var I=h(b);I&&I.setData(v)},addLocalFile:function(b,v,I,A){if(o.fs.existsSync(b)){v=v?_(v):"";let C=_e.win32.basename(_e.win32.normalize(b));v+=I||C;let P=o.fs.statSync(b),y=P.isFile()?o.fs.readFileSync(b):Buffer.alloc(0);P.isDirectory()&&(v+=o.sep),this.addFile(v,y,A,P)}else throw ye.Errors.FILE_NOT_FOUND(b)},addLocalFileAsync:function(b,v){b=typeof b=="object"?b:{localPath:b};let I=_e.resolve(b.localPath),{comment:A}=b,{zipPath:C,zipName:P}=b,y=this;o.fs.stat(I,function(R,D){if(R)return v(R,!1);C=C?_(C):"";let B=_e.win32.basename(_e.win32.normalize(I));if(C+=P||B,D.isFile())o.fs.readFile(I,function(G,Y){return G?v(G,!1):(y.addFile(C,Y,A,D),setImmediate(v,void 0,!0))});else if(D.isDirectory())return C+=o.sep,y.addFile(C,Buffer.alloc(0),A,D),setImmediate(v,void 0,!0)})},addLocalFolder:function(b,v,I){if(I=w(I),v=v?_(v):"",b=_e.normalize(b),o.fs.existsSync(b)){let A=o.findFiles(b),C=this;if(A.length)for(let P of A){let y=_e.join(v,S(b,P));I(y)&&C.addLocalFile(P,_e.dirname(y))}}else throw ye.Errors.FILE_NOT_FOUND(b)},addLocalFolderAsync:function(b,v,I,A){A=w(A),I=I?_(I):"",b=_e.normalize(b);var C=this;o.fs.open(b,"r",function(P){if(P&&P.code==="ENOENT")v(void 0,ye.Errors.FILE_NOT_FOUND(b));else if(P)v(void 0,P);else{var y=o.findFiles(b),R=-1,D=function(){if(R+=1,R<y.length){var B=y[R],G=S(b,B).split("\\").join("/");G=G.normalize("NFD").replace(/[\u0300-\u036f]/g,"").replace(/[^\x20-\x7E]/g,""),A(G)?o.fs.stat(B,function(Y,J){Y&&v(void 0,Y),J.isFile()?o.fs.readFile(B,function(te,Q){te?v(void 0,te):(C.addFile(I+G,Q,"",J),D())}):(C.addFile(I+G+"/",Buffer.alloc(0),"",J),D())}):process.nextTick(()=>{D()})}else v(!0,void 0)};D()}})},addLocalFolderAsync2:function(b,v){let I=this;b=typeof b=="object"?b:{localPath:b},localPath=_e.resolve(_(b.localPath));let{zipPath:A,filter:C,namefix:P}=b;C instanceof RegExp?C=(function(D){return function(B){return D.test(B)}})(C):typeof C!="function"&&(C=function(){return!0}),A=A?_(A):"",P=="latin1"&&(P=D=>D.normalize("NFD").replace(/[\u0300-\u036f]/g,"").replace(/[^\x20-\x7E]/g,"")),typeof P!="function"&&(P=D=>D);let y=D=>_e.join(A,P(S(localPath,D))),R=D=>_e.win32.basename(_e.win32.normalize(P(D)));o.fs.open(localPath,"r",function(D){D&&D.code==="ENOENT"?v(void 0,ye.Errors.FILE_NOT_FOUND(localPath)):D?v(void 0,D):o.findFilesAsync(localPath,function(B,G){if(B)return v(B);G=G.filter(Y=>C(y(Y))),G.length||v(void 0,!1),setImmediate(G.reverse().reduce(function(Y,J){return function(te,Q){if(te||Q===!1)return setImmediate(Y,te,!1);I.addLocalFileAsync({localPath:J,zipPath:_e.dirname(y(J)),zipName:R(J)},Y)}},v))})})},addLocalFolderPromise:function(b,v){return new Promise((I,A)=>{this.addLocalFolderAsync2(Object.assign({localPath:b},v),(C,P)=>{C&&A(C),P&&I(this)})})},addFile:function(b,v,I,A){b=x(b);let C=h(b),P=C!=null;P||(C=new Hg(i),C.entryName=b),C.comment=I||"";let y=typeof A=="object"&&A instanceof o.fs.Stats;y&&(C.header.time=A.mtime);var R=C.isDirectory?16:0;let D=C.isDirectory?16384:32768;return y?D|=4095&A.mode:typeof A=="number"?D|=4095&A:D|=C.isDirectory?493:420,R=(R|D<<16)>>>0,C.attr=R,C.setData(v),P||c.setEntry(C),C},getEntries:function(b){return c.password=b,c?c.entries:[]},getEntry:function(b){return h(b)},getEntryCount:function(){return c.getEntryCount()},forEach:function(b){return c.forEach(b)},extractEntryTo:function(b,v,I,A,C,P){A=Tn(!1,A),C=Tn(!1,C),I=Tn(!0,I),P=rf(C,P);var y=h(b);if(!y)throw ye.Errors.NO_ENTRY();var R=l(y.entryName),D=f(v,P&&!y.isDirectory?P:I?R:_e.basename(R));if(y.isDirectory){var B=c.getEntryChildren(y);return B.forEach(function(J){if(J.isDirectory)return;var te=J.getData();if(!te)throw ye.Errors.CANT_EXTRACT_FILE();var Q=l(J.entryName),be=f(v,I?Q:_e.basename(Q));let he=C?J.header.fileAttr:void 0;o.writeFileTo(be,te,A,he)}),!0}var G=y.getData(c.password);if(!G)throw ye.Errors.CANT_EXTRACT_FILE();if(o.fs.existsSync(D)&&!A)throw ye.Errors.CANT_OVERRIDE();let Y=C?b.header.fileAttr:void 0;return o.writeFileTo(D,G,A,Y),!0},test:function(b){if(!c)return!1;for(var v in c.entries)try{if(v.isDirectory)continue;var I=c.entries[v].getData(b);if(!I)return!1}catch{return!1}return!0},extractAllTo:function(b,v,I,A){if(I=Tn(!1,I),A=rf(I,A),v=Tn(!1,v),!c)throw ye.Errors.NO_ZIP();c.entries.forEach(function(C){var P=f(b,l(C.entryName));if(C.isDirectory){o.makeDir(P);return}var y=C.getData(A);if(!y)throw ye.Errors.CANT_EXTRACT_FILE();let R=I?C.header.fileAttr:void 0;o.writeFileTo(P,y,v,R);try{o.fs.utimesSync(P,C.header.time,C.header.time)}catch{throw ye.Errors.CANT_EXTRACT_FILE()}})},extractAllToAsync:function(b,v,I,A){if(A=Wg(v,I,A),I=Tn(!1,I),v=Tn(!1,v),!A)return new Promise((D,B)=>{this.extractAllToAsync(b,v,I,function(G){G?B(G):D(this)})});if(!c){A(ye.Errors.NO_ZIP());return}b=_e.resolve(b);let C=D=>f(b,_e.normalize(l(D.entryName))),P=(D,B)=>new Error(D+': "'+B+'"'),y=[],R=[];c.entries.forEach(D=>{D.isDirectory?y.push(D):R.push(D)});for(let D of y){let B=C(D),G=I?D.header.fileAttr:void 0;try{o.makeDir(B),G&&o.fs.chmodSync(B,G),o.fs.utimesSync(B,D.header.time,D.header.time)}catch{A(P("Unable to create folder",B))}}R.reverse().reduce(function(D,B){return function(G){if(G)D(G);else{let Y=_e.normalize(l(B.entryName)),J=f(b,Y);B.getDataAsync(function(te,Q){if(Q)D(Q);else if(!te)D(ye.Errors.CANT_EXTRACT_FILE());else{let be=I?B.header.fileAttr:void 0;o.writeFileToAsync(J,te,v,be,function(he){he||D(P("Unable to write file",J)),o.fs.utimes(J,B.header.time,B.header.time,function(O){O?D(P("Unable to set times",J)):D()})})}})}}},A)()},writeZip:function(b,v){if(arguments.length===1&&typeof b=="function"&&(v=b,b=""),!b&&i.filename&&(b=i.filename),!!b){var I=c.compressToBuffer();if(I){var A=o.writeFileTo(b,I,!0);typeof v=="function"&&v(A?null:new Error("failed"),"")}}},writeZipPromise:function(b,v){let{overwrite:I,perm:A}=Object.assign({overwrite:!0},v);return new Promise((C,P)=>{!b&&i.filename&&(b=i.filename),b||P("ADM-ZIP: ZIP File Name Missing"),this.toBufferPromise().then(y=>{let R=D=>D?C(D):P("ADM-ZIP: Wasn't able to write zip file");o.writeFileToAsync(b,y,I,A,R)},P)})},toBufferPromise:function(){return new Promise((b,v)=>{c.toAsyncBuffer(b,v)})},toBuffer:function(b,v,I,A){return typeof b=="function"?(c.toAsyncBuffer(b,v,I,A),null):c.compressToBuffer()}}}});import{execFile as M_,spawn as B_,spawnSync as SI}from"node:child_process";import{promisify as F_}from"node:util";function U_(t){if(process.platform!=="win32")return!1;if(eu.test(t))return!0;let r=(t.split(/[/\\]/).pop()??t).replace(eu,"").toLowerCase();return z_.has(r)}function tu(t,e){if(process.platform!=="win32")return e??{};let r={...e??{}};return U_(t)&&r.shell===void 0&&(r.shell=!0),r.windowsHide===void 0&&(r.windowsHide=!0),r}function dt(t,e=[],r={}){return B_(t,e,tu(t,r))}function nu(t,e=[],r={}){return G_(t,e,tu(t,r))}var z_,eu,G_,yn=Ye(()=>{"use strict";z_=new Set(["npm","npx","yarn","pnpm","coze","tsx","claude-agent-acp","codex-acp","openclaw"]),eu=/\.(cmd|bat|ps1)$/i;G_=F_(M_)});var rx=oe(Le=>{"use strict";function U(t,e){t=t-372;let r=ko(),i=r[t];if(U.mFjAnp===void 0){var o=function(x){let h="abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789+/=",_="",w="";for(let S=0,b,v,I=0;v=x.charAt(I++);~v&&(b=S%4?b*64+v:v,S++%4)?_+=String.fromCharCode(255&b>>(-2*S&6)):0)v=h.indexOf(v);for(let S=0,b=_.length;S<b;S++)w+="%"+("00"+_.charCodeAt(S).toString(16)).slice(-2);return decodeURIComponent(w)};U.OhGtth=o,U.sUydiK={},U.mFjAnp=!0}let c=r[0],l=t+c,f=U.sUydiK[l];return f?i=f:(i=U.OhGtth(i),U.sUydiK[l]=i),i}var M=U;(function(t,e){let r=U,i=t();for(;;)try{if(-parseInt(r(803))/1*(parseInt(r(770))/2)+parseInt(r(998))/3*(-parseInt(r(958))/4)+-parseInt(r(922))/5*(-parseInt(r(1842))/6)+parseInt(r(1570))/7*(parseInt(r(579))/8)+parseInt(r(1227))/9+parseInt(r(1514))/10+-parseInt(r(651))/11*(parseInt(r(409))/12)===e)break;i.push(i.shift())}catch{i.push(i.shift())}})(ko,387093);var kb=Object[M(1243)+M(1814)],Ob=Object[M(1391)+M(1520)+"mes"],Xu=(t,e)=>function(){return t&&(e=(0,t[{XVqgJ:function(c,l){return c(l)}}[M(411)](Ob,t)[0]])(t=0)),e},Pb=(t,e)=>{let r={wvemE:function(o,c,l,f){return o(c,l,f)}};for(var i in e)r.wvemE(kb,t,i,{get:e[i],enumerable:!0})};function Nb(){return $u||($u=[IDBDatabase,IDBObjectStore,IDBIndex,IDBCursor,IDBTransaction])}function Lb(){let t=M;return Vu||(Vu=[IDBCursor[t(1135)+"e"][t(677)],IDBCursor[t(1135)+"e"][t(708)],IDBCursor[t(1135)+"e"][t(708)+t(899)+"ey"]])}function Mb(t){let e=M,r={wyLbv:e(945),MBegR:"error",huYJT:function(o,c,l){return o(c,l)},exIUB:function(o,c){return o===c},FKrSX:e(675),Gqoiz:function(o){return o()},OlsuO:function(o,c){return o(c)},lCgnq:function(o,c){return o instanceof c},YRWzJ:function(o,c){return o!==c}},i=new Promise((o,c)=>{let l=e,f={irmYm:r[l(1512)],iWVyY:r[l(1699)],mwmQW:function(w,S,b){return r[l(1256)](w,S,b)},RtgET:function(w,S){return r.exIUB(w,S)},KHuaQ:r.FKrSX,qerKh:function(w,S){return w(S)},DDyLb:function(w){return r.Gqoiz(w)},vXqpQ:function(w,S){return r[l(432)](w,S)}},x=()=>{let w=l;t[w(1827)+w(457)+w(1004)](f.irmYm,h),t[w(1827)+w(457)+w(1004)](f[w(1714)],_)},h=()=>{let w=l;f[w(685)](f[w(1438)],"ixAfr")?(f.qerKh(o,Lt(t[w(915)])),f[w(1285)](x)):(_0x3775db(_0x1a671b,10),f[w(1064)](_0x4c7455,_0x21af2a,_0x39e3b4))},_=()=>{let w=l;f.vXqpQ(c,t.error),f[w(1285)](x)};t[l(888)+l(1477)](l(945),h),t[l(888)+l(1477)](r[l(1699)],_)});return i.then(o=>{let c=e;if(r.lCgnq(o,IDBCursor))if(r[c(1871)](c(1376),"vZTue"))od[c(1705)](o,t);else return!!this._qosDB}).catch(()=>{}),Ro.set(i,t),i}function Bb(t){let e=M,r={HCzAG:function(o,c){return o!==c},BKoPx:"RhUDq",mtsBL:e(631),eUUAA:function(o){return o()},cLesx:function(o,c){return o||c},iVqgR:function(o,c){return o(c)},wNORi:function(o){return o()},rpkVk:e(1290),lgtld:e(1382)};if(Co.has(t))return;let i=new Promise((o,c)=>{let l=e,f={zuYlz:function(w,S){return r[U(486)](w,S)},samGN:function(w,S){return r.iVqgR(w,S)},UgYEB:l(943)+"or",RBvDX:function(w){return r.wNORi(w)}},x=()=>{let w=l;if(r.HCzAG(r[w(687)],w(1831))){let S=this[w(1259)][w(518)+w(563)+"nc"](this[w(1022)]),b=_0x3f8cc5[w(1030)](f[w(829)](S,"{}"));return _0x39b1a1[w(1809)](b)}else t[w(1827)+w(457)+"ner"](r[w(1288)],h),t["removeEv"+w(457)+w(1004)](w(1290),_),t[w(1827)+"entListe"+w(1004)](w(1382),_)},h=()=>{r.eUUAA(o),x()},_=()=>{let w=l;f[w(576)](c,t[w(1290)]||new DOMException(f[w(1494)],w(943)+"or")),f[w(754)](x)};t[l(888)+l(1477)](r[l(1288)],h),t[l(888)+"Listener"](r.rpkVk,_),t[l(888)+l(1477)](r[l(878)],_)});Co[e(1705)](t,i)}function Fb(t){Do=t(Do)}function zb(t){let e=M,r={WFWPd:function(i,o){return i(o)},vXBDl:function(i,o){return i!==o},tzKkm:e(584),cgAfX:function(i,o){return i(o)},vlMSs:function(i,o,c){return i(o,c)},hGHYr:e(1290),nJMaK:"00000000"+e(1219)+e(1219)+e(1219),Rjiko:function(i,o){return i===o},Daxkp:e(1044),VCLiQ:function(i,o){return i(o)},dfGnX:function(i,o){return i===o},ugcuX:function(i,o){return i in o},hEdTb:e(1267)+e(665),EAkaQ:function(i){return i()},CfJgt:"Mdydh"};if(r[e(1296)](t,IDBDatabase[e(1135)+"e"][e(1673)+e(1334)])&&!r[e(877)](r[e(597)],IDBTransaction[e(1135)+"e"]))return function(i,...o){let c=e,l=t[c(461)](r.WFWPd(Gi,this),i,...o);return sd.set(l,i[c(455)]?i[c(455)]():[i]),Lt(l)};if(r[e(559)](Lb)[e(658)](t)){if(r[e(845)](r.CfJgt,e(1450)))return function(...i){let o=e,c={vAUnC:function(l,f,x){return l(f,x)},Hvbfe:o(1290)};if(r[o(845)](r[o(581)],o(584))){let l=o(1622)+_0x5e9dca+(o(1753)+o(882)+o(412)+"ed");this["_dispatc"+o(1563)+o(1464)](c[o(1888)](_0x34b6e3,c.Hvbfe,{message:l,code:_0x3f978d[o(692)+o(1657)+"R"],error:_0x5353ab}));return}else return t.apply(r[o(995)](Gi,this),i),Lt(od[o(1309)](this))};this[e(714)]("error",r.vlMSs(_0xfb1b75,r[e(1087)],{..._0x1c987a,message:_0x2af033[e(1752)]||""}))}return function(...i){let o=e,c={UsikT:function(l,f){return l(f)},rxDoe:r.nJMaK};if(r.Rjiko("qHjVU",r[o(591)])){let l=/(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(_0x41434a),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]))/[o(1605)](_0x2df013);return l?_0x1e90cf(_0x4a1fe8):f?c[o(863)](_0xcc555b,_0x3c1ddc):c[o(1442)]}else return r[o(995)](Lt,t[o(1110)](r[o(1482)](Gi,this),i))}}function Ub(t){let e=M,r={qDOao:function(i,o){return i===o},PCWch:e(1518),SmObk:function(i,o){return i(o)},BfJLX:function(i,o){return i instanceof o},svvEZ:function(i,o,c){return i(o,c)},UGFWH:function(i){return i()}};return r.qDOao(typeof t,r[e(1348)])?r[e(1273)](zb,t):(r[e(1161)](t,IDBTransaction)&&r[e(1273)](Bb,t),r[e(645)](Qu,t,r[e(1138)](Nb))?new Proxy(t,Do):t)}function Lt(t){let e=M,r={jHxtE:function(o,c){return o(c)},TOmIz:function(o,c){return o!==c}};if(t instanceof IDBRequest)return r.jHxtE(Mb,t);if(Io.has(t))return Io.get(t);let i=r[e(884)](Ub,t);return r[e(686)](i,t)&&(Io.set(t,i),Ro.set(i,t)),i}var Qu,$u,Vu,od,Co,sd,Io,Ro,Do,Gi,Yu=Xu({"node_modules/idb/build/wrap-idb-value.js"(){let t=M,e={MaelP:function(r,i,o,c){return r(i,o,c)},cYCYu:t(1388),MwSYw:function(r,i){return r instanceof i},cKdLd:function(r,i){return r===i},rRQHV:t(893),GuuCT:function(r,i){return r===i},pTVhS:t(1267)+t(665),rZbVh:function(r,i){return r===i},tLvuZ:t(1695),rjRYR:function(r,i){return r(i)},LDUAX:function(r,i){return r>=i},nHEon:t(788),MXotQ:function(r,i){return r in i}};Qu=(r,i)=>i[t(1863)](o=>r instanceof o),od=new WeakMap,Co=new WeakMap,sd=new WeakMap,Io=new WeakMap,Ro=new WeakMap,Do={get(r,i,o){let c=t;if(e.cYCYu==="KnXNC")e[c(678)](_0x3a824e,this,_0x96a6c,[_0x2a6025,_0x1503a3,_0x4344ea,_0x150410,_0x2279cc,_0x1264c6]);else{if(e.MwSYw(r,IDBTransaction)){if(e[c(1662)](i,e.rRQHV))return Co[c(1309)](r);if(e.GuuCT(i,e[c(484)]))return r[c(1267)+c(665)]||sd[c(1309)](r);if(e[c(861)](i,e[c(1284)]))return o[c(1267)+c(665)][1]?void 0:o[c(1267)+c(799)](o["objectSt"+c(665)][0])}return e[c(1199)](Lt,r[i])}},set(r,i,o){return r[i]=o,!0},has(r,i){let o=t,c={nYLLw:function(l,f){return e[U(1669)](l,f)},XjdhD:function(l,f){return e[U(1123)](l,f)}};return e[o(861)](o(788),e[o(1765)])?r instanceof IDBTransaction&&(e.GuuCT(i,o(893))||i===e[o(1284)])?!0:e[o(937)](i,r):!!(c.nYLLw(this[o(864)+"ndex"],this[o(793)+"s"].length)||c[o(1631)](this[o(864)+"ndex"],this.endpoints[o(614)]-1)&&c.XjdhD(this[o(533)+o(926)+"riesCount"],this[o(660)+"es"]))}},Gi=r=>Ro[t(1309)](r)}}),ex={};Pb(ex,{deleteDB:()=>qb,openDB:()=>Gb,unwrap:()=>Gi,wrap:()=>Lt});function ko(){let t=["wenisfu","s3DPuhu","DgTbBwS","y29UC3rYDwm","rwLKEMq","rMvUs1O","B2fYDKW","BfrPBwvVDxq","zw5JB2rLrNi","DefyywG","ywnR","Bw5KsuG","x21LC3nHz2u","AhDTCM0","r3bbDxa","C2vYDMLJzq","weHLBMS","ALv0zge","EwL2D1q","BgLUzq","AgvHzgvYCW","t2PZz2i","sgHSy1q","rgjhtvO","y3vZDg9Tshq","n3WWFdn8mNW","wKrWzLe","Aw9Ul2PZB24","y29Uy2f0","s0H1yve","ywXSq3vYC28","y1PRDu0","DNL5yxq","CNHeB2u","ru5hy2e","AvnguuS","A1DYDxy","DNrMtgS","mNWWFdm","x19LC01Vzhu","q291BNq","AeLfDfO","yNL0zu9MzNm","DgLTzw91DcW","zeT2vNO","sfvHDLm","DKjdr00","BeHAqwq","yKjOz1i","txn3uMi","wLDnqwm","wvnLtgO","wNHer0u","zv90Aw1LB3u","rNrXtxG","zw50","vKzUENC","wgrJvLy","rvLsEgm","Aw5PDcbrB1m","A3nrrLy","vxL6rKy","ywrK","x29UugfNzu4","Dw5PBey","B3jpBMXPBMu","ihn1y2nLC3m","zfn0twS","tgLZDgvUzxi","Cwznqui","shL3DKe","wePvwxm","ug1Avhu","vKnmAve","CYbWyxjHBxm","EeLpDMK","B2nRzxq","Axr0vxi","sNHQCMS","sgvpDhe","x2jPBMfYEvq","CM92AwrLigi","shnfuNe","t2LfreG","x3nVy2TLDa","vwDzrui","z1zHu08","zMLSzw5HBwu","DwTMu08","uvfLrKu","EuXwwfy","v2vIu29JA2u","BunVzNi","qKjJsfC","B25nzxnZywC","ihjLy29UBMu","uxvLDwu","vNf4zMi","A21qAvO","tgLMsgC","sNfrtLq","zeHuEMS","svvTA3u","D3LmyNy","ywXSB2nvBNm","ndm5nti1mhHtuMfWDq","t2jLyw0","wuXRyKq","r29bzfa","zNvUy3rPB24","B3nLza","B3bLCNr5tMe","BMnVzgLUzW","CMvZzxrfBMq","qNneEMW","DKLVzvm","ug9myLu","vhvLDhe","l3DZl3yY","y2HnyxHuCMK","CMvTB3zLq2G","s2TyAeC","Ew5Ztg0","nhWWFdj8m3W","zgzVEw0","y2HHCKnVzgu","BxnN","ExbL","yw5ZzM9YBvq","tgPSuuK","s1DwCfq","CgjICdi","Aw47y2HHCNm","x3bPBMDmB3m","Egjwz2S","CNjVCK1LC3m","Ahr0Chm6","Dg9tDhjPBMC","C3rYAw5NAwy","uMvJB25Uzwm","B3rKyuS","yM5Jtxq","y1LrExi","y2XVC2veqG","rezHtMO","yw55ru8","CMfTugfYyw0","B3rUywW","vKPPr0e","wgTtvLe","yu5TDNm","AvfJBeW","s0DcB1a","yurOrMS","AevYCM9Yrxy","qNjwyKy","CNnWq00","Dvz3Cxq","ve9NDe8","rhrvB2i","CgvYC2LZDgu","ntaXowTsC0HUsq","zxjFDhrS","EgLqr1a","rwz5ue8","tfLzBNm","uLjpuG","De1rCuS","C2nYAxb0","zMvY","C2v0sxrLBq","BvfQsge","y29UBMvJDeu","BwvZC2fNztO","ihzHBgLKigq","x2LUAxrhBg8","ChjVDg9JB2W","sMX2zNG","DxrMofDYAxq","A1LzAgm","z1vWr2C","AxzuBgO","A3PPwMW","rLztsMK","CM92AwrLige","zfziqNy","Cw5fu2W","C2vYDMvYvgK","x2HHBMrSzvi","rxvTqu4","Dxrjza","q1vzEeu","uMrSvMG","zw5HyMXLuw8","DvfsrhO","DLLArgC","DgvZDa","pxv0zI04","BxztBum","AgfZ","B2zMBgLUzq","C2XPy2u","D3jPDgu","yu5Kreu","CLzHBhvLCW","Dg9cExrLCW","DgLUzYbZzxi","zefTChu","q0rZr2O","rLHNqvm","EuzUq1a","B3nLrxzLBNq","Ee9uAxi","y29UBMvJDca","x3vYBa","wgr0reW","BKrxt3K","zgv5q1K","yw51Ce1LC3m","vxfHwgK","EeXAzLe","x2n1CNnVCKy","wgPKAeq","AxrpDMm","B25szwnLAxy","x2LZv29YA2u","Axnby2TdBgu","x3bPBMC","CMvHzg9UBhK","z25yzhm","x21PBMLoyxy","Ag5Rrei","Bgzjvwm","zKPtvKu","r1PzD1G","AxnmB25N","zMX1C2HfEha","zgvSzxrL","y3PmtLi","ANbSCuG","DhbizwfKzxi","wKLQqKC","rLvYvLa","q21JvNm","EeLjDhi","CMvHzhLtDge","y2XVC2u","uuPfBKi","suvtx0vsuK8","DurlC3u","s2fqq20","zNjVBu51Bwi","wM1kthu","y0TKtgq","DfzPuLG","su1oq2O","B0vAt3u","tgr1r2e","s0TZswC","D0f5wfq","tervqvG","rLzoweC","yxDbzeW","AefJA01LC3m","DhjHBNnHy3q","C2vtyMm","x2LZtwLUAvC","ihrPBwvZ","twDzveW","Aw5KzxHpzG","CMvUDevUzha","AKz3swC","ANDpyu4","rLjptLrjrvi","y3vYC29Yx2y","AgP0Aui","uhH3Awq","ENrcywK","C3nHz2vfDMu","DKPrywC","nhWYFdb8mxW","y01Yzwe","BwvZC2fNzv8","x194x21Zz18","D2LSBfjLy28","x2DLBMvYyxq","C3rVCMu","vhrvrhm","rvLqswO","ywf2Exu","tujLz1i","ELbXse4","yxbWzw5Kq2G","Bwu6ia","zMjdthi","s3zkv0u","C2v0","u3DUq3m","A09TtKC","y2TjDMu","ANDwAwi","z2v0q3vYCMu","t3rPqNq","Bg9Nsurhzw4","CMvHzhDYAxq","AvDwEvK","tLv0vwG","yM1VueO","sgnAD2y","DvPSzuG","zw1LBNq","qxHnA0m","Dgrmy0i","r29Vy0O","yMLUyxj5vhK","BwvY","B0LWCw4","Dw9Kqum","CMvXDwLYzwq","C3rVCcbPBw0","r0fkwfG","BK5Xt1e","AuHRv2K","tunpzNe","AxnFywnR","y2XTqMu","zv9ZDwnJzxm","B25mAw5L","z2XMue8","y1PJDvy","u1PjAgG","Bg9N","CeXhugy","v3nLyxm","ywXSzwqGBxu","DgfIyxnL","uhHWy1m","B0DjBNO","yNH2reS","y3vYC29Yx24","ihrPBwvVDxq","rxzLBNq","shHVruG","zxjYtxnN","igzHAwWSig0","EwvWwwK","Dg9VigXHCMC","BKHUu1y","ywnRx2nVzgu","Dg9hzw5LCMe","CLrAzLK","BwvZC2fNzq","tfnXwhq","C3bSAwnL","zev0r2y","CMLLC0nVDw4","BKHfB24","tw1swwO","m3WXFdb8mNW","u09SvNi","DhDVCMTdAge","AKTmsMK","rfjHuve","yNPivxy","EvjLy29UBMu","sgHXuLe","wK1HtNa","ufnAquS","y29UBMvJDfm","BvzXCfu","Dxnju2q","tfDHAgC","zw5JB2rPBMC","CgLUz0XVC3m","ywDLsgLKzq","v3f3Dgy","Bu9OELm","z1jjy3a","wxbMzKy","ugrTBKS","C050yva","Bu9UBhq","AxnQyLO","y0XJD3G","vwHUD3a","AufPDgi","ufbttw4","AenSB3nLrxy","sfHhu0G","Cg5bsgS","r1PKzNe","Ec1TC2CTCw8","vKTyBeK","s0flzKW","EvDhzKO","vxbKyxrLq28","CwXhAxK","yNvMzMvY","C2fNzq","lcbxzwjtB2m","A2v5CW","BgLUzw5V","CNrbBxu","AuPXuKi","tNb4rLa","B3bLCNr5","C3vIyxjYyxK","x2rLyNvN","AxnAzxjV","s2Hwv2O","DMnlzg4","zKPsEeO","DLPQwhq","zhDNChO","rxbhwvy","wwP0thq","sMr4uuO","Aw9UvgLTzw8","CMvTB3zLrxy","Cgf5Bg9Hza","BgLTAxq","rw1mte4","uMHvrhe","AMvJDfn0B3i","uhPQCLm","EfvZzuvUDG","rgffDw0","tunsqNm","CwffEgS","yxjIAw0","yxKSihrYEsa","swzpExy","AgfUz2u","mJq0mJbbvM52DuG","sLnptLa","s05mree","sMznvLG","q3vZDg9Trxi","zxjFAxnFywm","Dg9mB3DLCKm","DgfNEgi","Chv0","C2vYDMLJzs0","lcbOB3n0BMe","BMnLq2XVC2u","DxHwDeW","AuTtsuG","y3vYC29YlNm","vgfN","wgrMCue","tLLMCMW","C0jf","yw5Hz2vY","zxjFCw9Z","C29Tzq","A1LSyuS","nxW0Fdf8nNW","yuj1z1q","yxPPzfy","CKziAum","BwLZzq","ruLMBMG","wvjxEKO","A01vueK","r2f3sem","zKPNuu8","qLjxv0i","yw55rhq","CgfNzwHPzgu","t0jtuhC","yMfJA3vWigu","BMnqtMy","yM9KEq","Cgf5Bg9Hzeu","zufJAW","DMfSDwu","zgrjrcWGzgu","ywDL","DgvmB2Djre4","DKfvBKm","ChvZAa","r0vjrMy","y3ruAw1LB3u","AgXmEMm","r01sDei","t3frBLq","zxj2AwnL","wu1Nr3y","BxL0ENu","mdaWma","nNWXFdv8na","qvvove8","D2fZq2XLyw4","ywjyt3m","uKPfBKm","A29zq3m","uNPWrMS","BLPpChm","CM92AwrLihy","CMXevwS","CNnVCKzPBgu","uKvIwge","x2HHBMrSzu8","v0jQsKW","zKLPAxy","q2LHthK","yxnJCMLWDa","ywnOzwq","y2HnyxHdB3u","yKPfBNq","uwPQzK8","qLv5uge","ChvpwvC","shbkDhC","t3bLBKv2zw4","D0DwAui","vgLTzw91Da","AhzYrfG","wLzguuq","yxnL","r0r4yLC","mJK5nZCYExPUC3jc","DhvWDKO","wfzXz0O","zxmGCMvHy2G","x3DHAxq","yNHfquq","r1LOAK0","y3jLyxrLt3a","AvH2DNi","EKL5D0i","sMz3tNa","C0nVDw50zxi","y2XLyxi","qwv0BeW","Dgv4Dc9Qyxy","Dgv0yNu","y291BNq","zxDut2y","v2PiDhy","BLLXq1O","ugDiru8","DKn0Cg8","AM9PBG","t2XZDu8","EKDyv0W","Cu1OCMC","AMv0CKS","B1fuAuW","ANLMA1e","BM5Ly3q","qwr6u20","z0rjqMm","zKHnzum","y05OAwO","ENn6DNy","u0H1ufu","yw1Lu3bHy2u","Dvrzr2K","u2vXsuq","seXyu2C","BhrPCgXLihq","CxjQrMm","t1HhA2m","vuPmAhu","vxnlELi","u3z6sMK","C29YDa","CM9YrxzLBNq","zw50tgLZDgu","sMjNqMu","CMvWBgfJzq","BMCGB3iGyw4","y2fSBa","EK1nvhG","r3PAwLK","AxnbCNjHEq","z2v0qwXSs2u","yLPfs3O","B3v0sw50zxi","Eg1cqMS","zw5HyMXLvhi","tNbfC2e","vNrJEKe","z1rPBwvVDxq","Be1ewwe","vLvNvLO","Bg9NsurozxC","wfHwuLq","uffyqM4","ihrYEsbYzwm","y3jLyxrLtwu","C2v0u3rVCMe","x3nLBMrby2S","B25VCgvU","B25ozxr3B3i","CfrwAfm","EwD2zvy","y0XLC3G","z0v6zKC","yNbWsu0","sw9wy2i","AwDQAMW","qNnhuwK","ELfxCfe","AfHjthG","CKrmvfm","A1n0yxr1C0m","DMfS","igzPzwXKoIa","BuLlvwe","D3nZoI8V","zergtge","Bhzyvem","zfzHDLi","CMvJzxzPzwq","y3jLyxrLrxi","D0rcALi","Exnwr3i","CMfTzq","yNL0zuXLBMC","CKnMte8","tKfusvzfx0u","B3jRig9MzMW","BNrLCG","zgf0yq","uvLiq0O","zgvIDwC","su5tvefova","AxnSEgu","z2v0u3rVCMe","wNbnvvO","y0LwA2G","wvngDxu","u2j0rKe","wvPQwKS","wgTgz2m","y21nqw4","BMv4DcGPigm","z2v0s2v5","yujiAMm","D1LtzNi","wejctfq","x3bYB3rVy28","sLz6rM0","y3vYCMvUDeu","DMHpzwS","AxnrB1nnzxm","tMfTzq","DLL3Bfq","B25tDgfYDfi","ugr5Ag4","B3jRzxjhBg8","Bgrfuu0","ExbrqMC","twzmq0q","x2LZtM9Kzq","CM16De8","y2uGBM90igK","zMXTve0","wxj6z0G","yxrHlcbKyxq","zuP0Au4","s1zyzNK","B2zM","Bwf4twvZC2e","x2nSzwfYvgK","ugTjrg8","De1HBMfNzxi","wgrsChy","C2Ptyue","rufRyve","rNjVBNrPzxi","BMnRwwO","u1Peuxm","z2vjBMzVu3K","s1rsBvq","zKXhqNa","ugHXu0K","swfcwfm","EhHMCvK","vLzIDgu","s2vHrwO","wKHJEKq","ywLfyum","rePqDeW","x29WDgLVBNm","BM9Uzv9UB24","C2fTr04","BeHHBMrSzxi","B25LCNjVCG","nta5nLz6B2TyyG","x2n1CNnVCK0","DhPlA20","DhjPzxmGCMu","t2jQzwn0","q3DhvLi","AxjLza","BhvUqvi","vMXQuM4","Dg9oDw1Izxi","zxjTr2i","uvPUqKy","rgf4A3a","qw1VDw50","zwnVBM5Ly3q","y1Hnuem","u3rYyxrLz3K","Be9jCxG","AevKvgi","wvHzquK","Dg9cExrLC0i","t05nEKe","tMP3y08","BgfYzK8","tLLOuMy","Ef9MCM9UDgK","x2LUAxq","BNn1vge","q3HRDNu","y3vYC29Y","t1PMzg0","CvHcEfK","ywnRDxbfBMq","zfDVCMTLCKC","zw9yufu","BgvUz3rO","B0zJBwu","CwjdBNq","AwXK","ENrQvxi","BwLUAvbYB2C","thnZDe0","txn1Dui","AhP5zxa","A2v5","se5XsgK","B2jpuem","BeTVr1u","B3vUDa","uhHpug0","tNHfCuC","DMfSDwvZ","y29TCgXLDgu","AgXzu2W","DxnLCKLW","x3bHDgHlzxK","AhztEfa","AK9QCgq","EgrWr3O","t1bbEu8","yxvNthC","ChjVy2vZCW","ENHTv3i","x2LUAxrqCM8","y3jLyxrLt2i","B0ftBK0","C3z2rvO","DeLK","uMvHzcbWyxm","AgvKtwf4uMu","EvPMAuK","CeDPz3y","mZnKrwrPCuC","rMfUvMy","zMLSDgvY","BKXPBMu","EKH5vLm","u2TPCcbWyxm","D0HvuMm","Aw5JBhvKzxm","ihrVihjLDhi","Bwf4uMv0CMK","DwHOqMe","zgD6rMe","Cw9Zx18","ru51r2u","B3jLtMfTzxm","m3WYFdf8nhW","q3jowxC","BvriCg4","x3bPBMDqB24","zerkq0S","swHnu2W","zxHWB3j0CW","DK9eDMS","CfbTvu8","AxHbzNi","x29UrxjYB3i","ywr2yw5Jzq","twfLBfa","q2nXALC","sePKtfO","rLn2zM4","veLnu0G","DgLLCKPtt04","tMfJtuO","uNrNrvq","ve9TsxO","qKTVuhG","vvDxrvC","te5QDgi","yMXVy2TLza","x2rPC2nVBM4","tufyx1jfvfi","vKnsq0O","Bg9IywXty28","ruPiu1G","uuPAB2W","BhbMvfG","Cg5eDKy","BMrLEa","tuLYzxC","Cw9KEfG","txLWB00","CKDyEKi","y29UBMvJDgK","C3jJ","DwXTCeS","uMPrBeG","y29UDgLUDwu","Bwv0Ag9K","z01SALy","EgHQyNG","vKfYA1a","sgr3tvm","zw1PDa","uvD6wwi","AfPQqMu","x2rItMfTzq","AxnszwfKEq","C2HPzNq","ufPRCuS","mhWZ","yw5Nzq","BMv3vMvYC2K","AMHtvhq","zvvYBa","rNjhywW","C3vIC3rYAw4","vMLIv0G","zw5NDgG","wKz4v04","Dg9cExrLC0W","wNrVvvi","BfvnChG","tg9Nsuq","rwrewLe","D0zIEfO","v0zrwKu","tuzqAxi","uez1DMi","wM1cDM4","z0voCeq","C21Yq0m","zxjFywnRx20","yMLUza","AwXLtMfTzq","r1HjEhC","C0Xf","t2PjA28","y3jLyxrLq2W","x3jLywr5q2W","zgv2AwnLx2K","wu9UwK0","x2HHBMrSzva","uKj2rfG","sfnbCMW","D2jpAwC","q2HoEKW","Cg9PBNrdB24","tK1Wy28","yvHgEwq","zM9Yy2u","se5kzgu","tLjJuu0","CNzls2m","yNvMzMvYzwq","q3zeq24","A3fSBvu","ww5VDfq","s2zOuw4","nte0mZrMq2T2v2y","zgvS","A1rnEuW","ugn2tuu","s3jADey","s2TwDuO","y2f0y2G","vMTmtMG","s0Tsy2m","v0Tjwe4","BeLLrMC","B2zMC2v0","tgz6sKK","x2DLDeLUDgu","v3bkEvy","y1vLCfy","Bg5TBxa","DMP4C3C","uNHMtw4","v2rdrNy","BgHYtxG","DfvgCKy","Bwf4tg9ZC0m","zw5KCg9PBNq","y09Wzw4","zwrhzge","jMPZy2fSBgi","z3DiDNC","v2LqB3e","B3jL","rxjYB3jdB2q","zw5HyMXLqxu","Cgf5Bg9Hzfq","mJn5r0z0vuy","txvrsha","x2n1CNnVCK4","x2nSzwfYugK","x2LZqNjVD3m","tg9JAW","ywnRpwzYB24","yu5dsfm","tMvzyKm","q29Kzq","x2TLEvbHDgG","BNbguNy","ignVzgu6ia","CgjdrNa","A0nJu2y","qNbACxG","s01wve8","Cu9mtMO","x0rctMfTzq","EKXHtNa","wujgsw4","twvZC2fNzuu","sfnvuLy","x2LZtwLUAvq","q21uq1i","revOrui","ENvzBhO","C3rLBMvYCW","r2HjtLy","A0jWy3q","u3PPyNa","q3vZDg9Tq2W","EKjVD1C","EKj1rwq","yKzhEfi","zNjVBunOyxi","ExHpBKS","DhLWzq","BMCGDxjSoIa","ruXvqMu","ywrKq291BNq","zxH0zw5ZAw8","DLHcrgW","EevzsLK","v2LUzg93","zMzmAw5L","x2nYzwf0zvm","vu9uy3K","ywrKt25L","ugfizMu","BgLrshK","shL5vhe","B1jTA3q","x1fVu01HBMe","B25TzxnZywC","z0DfA00","zNjHBwvuExa","y3jLyxrLrwW","CLPIvMG","rNHOs1y","vxnPA1q","y3vYCMvUDeK","zNjVBujPDhm","B3bLBKrc","v3j0rNy","Dg9JD3q","twTeB2C","r0ziB3i","sNfosw4","C1bPqwi","AxvPAgW","BNb1quq","B25tDg9Wsw0","BxDHAgq","DwDJDvG","BgD0Bgq","CgLUz09Uy2u","yMfSrxzLBNq","zw5XDwv1zq","yxGGCMv0CMK","z0D1vgi","AKH4Deu","zw5fDMvUDa","t0Hjt1q","wLfgrLK","ywrKrxzLBNq","Dgv4DfbHEwW","v2zZrNe","DhjHA1i","BMDLza","zg9Uzq","z2vY","BM93","zNDZxZeUmc4","rKrOvey","zuPkzey","uhjPBwfYEuS","Efrurw52","BNruCMLLC0m","yKvNtMi","wfbXyMe","BNzSv2W","id4G","x3DZsw5ZDge","r29yzKu","AgTHsLu","zvvrDwW","wLvvA0O","CgLUz19VBMm","wNnitfi","Dev2zw50","EK9wDNK","CMvZDwX0","ugHbzMW","AwDHDg9Yt24","EhHMtgu","CKjUC1q","reLywuS","z0nRzK8","nJK1sLfqq1Lg","x2fKzfDZtgK","uvvhDgm","DgLTzw91Da","BMrWB2LUDfq","CLL0DKy","zNfjseC","A0HTreu","CfDSzK8","wxLLtNC","sNDPufi","icSG","tu1ZDuu","txnhChy","AwvsuKO","tvHVDfe","CfH2rw4","t3zkzwG","BMDuAw1LCG","lcbTyxGGCMu","t1bftL9fuLi","qwjVCNrfCNi","wuDHALy","C3vJy2vZCW","twLZC2LUzYa","q2foD08","B3LUvMu","ENHOyuG","AwPZrMW","AvLJuLu","CgXLyxnLiha","yw1LoIa","yNvmsLq","y05rD0O","v0PJquW","yxnZAwDU","nZi1nJC2uenfufbb","u3zjAwC","AxzTq0W","wKvbvgi","ChrVCG","CvvWrwy","r3LhuLC","z2POtxe","BfvJzKW","ru9OzKe","BgvY","vunfAvK","tKDFrvjst1i","wLnIqvK","t0HIwvK","AuLnwKW","uujpq3e","CMfNzvn5BMm","tMToue0","t3HnD1a","zxjYtM8","qNjPzgDL","rMzLAfi","B2XKvMvYC2K","zsbHihn0CMK","ELLmALa","AxjzsvG","wfDADxu","ywDLu2HVDW","Axvzyxm","rKLmrv9ot1q","CKvuzg0","sMzhCui","wvzSqKS","q0Xpu0ve","CgLUz0LUDgu","BKvxuLa","y2DbzLG","CgfNzxnOB3C","Cgu6ia","mtjewujItMS","yKzSELu","CMvJB25Uzwm","rfvyD3K","yMvvywm","y29UDgv4Da","BMvY","tLjwy2m","quvgCfi","CenQAhC","qunQBfq","C2v0q3vYC28","z0z6zum","tw9KDwXL","tLPytuO","DxnNteS","r3bMrvq","BLnsD2W","z2v0sxrLBq","yxrLq291BNq","sKTRzxi","txbewwu","svjzt0m","DfHAr2S","x3bYzwzPEa","AgLNAa","DMjHvvC","tNPYr2S","z0jzA0K","zKXlv1q","C3rYAw5N","yMjAC2i","CgfYC2u","ign1CNnVCIa","zfb1seS","BgHhtM0","CMvZzxrdB3u","uNvTENO","Eervrui","x0vysvnu","EuPLt0O","zLHQENm","B3bLBIa","B3HMCgW","y29KEKO","Aw5KzxG","rfrjq0O","z2v0q3vYC28","svnlruO","DhfZqwi","DcbSAw1PDa","x2LZsw5PDa","BNrfBMrWB2K","AwXLx25HBwu","zcbLCNjVCI4","DxbKyxrLq3u","yNLL","C2DPza","r0f2uLu","CfDeq0u","q0Ltuem","uLPzuuy","rNfptNq","uKz1s3O","ELbOtMi","r0LqrKO","BxDTuvC","EfPKAwS","CLnitLi","zMzMzG","D1jXuxu","tg9NsurozxC","x3nLCuLK","Bg93","yxb0EeS","z0v4u0S","uNvyq2u","x2nVBM5Ly3q","wwXoswK","Dw5KzwzPBMu","zwvKzwq","x2zVCM1HDeu","wvLxChi","wNjLqK4","BezSDxnO","A1HrDfe","BIWGAg9ZDg4","uNfvEvC","x2LUDgvYDMe","AeDiwxi","Dw5ZAwDUzwq","z2v0qwXS","CMfUzg9T","Buv1Agu","CNzHBa","tuvtu0fhrv8","wePlEuO","nhW1","Dhj1y3rVCIa","zKnSu2y","sLjrvwK","BwvKAwf0zwW","q29UzMLN","refSsuy","vgPtsxu","DgTlDei","x29Uq2XVC2u","vufIuw4","v2L2Du4","zwreqM0","AgDprui","ugDjsgG","yxbWBhK","CMvHC29U","CNzHBfzHBhu","x2rYB3bhBg8","vuXiEwq","Ec11C2uT","CuzpvvC","D3jPDgvvAw4","B0rjrxe","D3fwCfm","zK9VyLq","vw5PBxbSzw0","u2jXwvy","r3v1q1q","yKzcA04","DND1sM8","x25HDMLNyxq","qu96CKG","y3jLyxrLuMu","uwH6v3i","DMvY","zMXhvg0","B3vNEue","vu1NzuW","vwr3quC","ChjVDg90Exa","r21Qzg8","x3jLBw92zvC","vuDgv0G","quXm","Dg9Y","CNnVCL92ywW","ywDLrxzLBNq","q0Pbvxi","CKL5t3y","wvb4CLi","AgXurey","CM92AwrLihC","sfDYqwO","q0Xpu0LorW","B25SAw5L","AK1cyKm","y2XVC2uSihC","AhP3B0m","AxnrB1nby2S","vu9sD24","svfxA2i","zw50zwqGDhK","wLrVu2C","s3HzwK4","CMvQzwn0","qMzktfG","CuHTq3K","t0njq2C","r29Kvhe","tNHUCge","CLbKB1C","uNPLyKq","B2LUDfjLywm","Avrcu3e","rgjqtxq","werREu0","x3jLy29UBMu","ve9oC0S","yxjYyxLIDwy","DMfbuxu","CgXyAgS","zxjHDg9Y","B0ncwLG","thHmuMq","ENrXBLC","zwn0","CuHZree","ELHRCNO","qMXtzNq","z29PBMCGyxC","y2HLy2Tszwe","qxzfrhe","B2nRzxrtDwm","C2v0zgi","C0ToAKK","v2D5De4","quXcr2y","C3bSAxq","Cg9PBNrbBMq","DxjS","x3DZ","zhncv3i","yxv0BW","CMPswvi","qMzbwMW","uNzIC2S","tKHXrum","BK9kALy","v2vPEgLUsLm","Ae1LC3nHz2u","t0HqtvO","qKf2AfG","B2fK","y29UBMvJDa","DgPiCe8","wgDHzuG","yNL0zxm","qLr2t3q","AxHpAMi","DMvYC2LVBMm","vu9eteS","DMvUDa","D29MuNi","mdaWmdaWmda","sfn1uNu","yMzRCvK","vuPzs2W","z0v5qLm","ywWGy3vYC28","ihzHBgLKihm","uvvyvK4","mJG1ndK3mvfRueTdyq","x29UtwvZC2e","ruDhrNa","zg1dv04","wvLxsNy","C2vUza","swXYy3K","ExnOEKq","rwfOEw4","B2fYCfu","AxjZsxC","x2rPC3bHDgm","CMvJzwL2zwq","zxrxB3jRq2G","CMvZB2X2zq","zMLN","zgvMAw5Luhi","zgvJB2rLzey","q09otKvdveK","z0vvu1a","CNnVCL9Uyw0","igXHCMDLCIa","Aw5N","AwPLvgu","BgLZDgvUtMu","Efbgvui","ywX3yxLZ","rhPtrhO","sgDbwM0","AhvzsLq","EhD3r3G","rLrnBwy","x3fVC0rc","yMLUyxj5","zMzLCG","AgfZt3DUuhi","yMPxAwi","x2XPC3rLBMu","ihbYB3rVy28","q2rdB3O","B2jQzwn0u3q","rxzTEue","Ec1TC2CTy3u","x2vUzhbVAw4","wLP5CeW","sKjfBva","u21pyMS","B3LXs1O","u0jbwKq","v3vfsuW","AhDKwhy","D24GCMvHC28","zeDJBMK","rgToCfi","BK5mEMe","A092quy","Eevltei","DeX2DvO","rer5tgi","qwDzvLC","DfvXChe","BxrZqKW","zNjVBuHHC2G","zxjYB3i","wM1XvwS","uMHsB3y","rvjst1i","rgvKAwnHDgu","txPVAK0","zgzhBLG","zMLUza","AeDpCxO","DcbVzIbYyw4","vLnpyxm","yM54CeC","z3Dlr2W","rg53sxm","sgLiDe0","t1bftG","v2vMBNG","vfr0yK0","C3rHCNq","z2v0","CMvKDwnL","Cuz4y0O","Aw5IBhe","D2vI","Bwjnweu","Be9Ssxm","Ae9Wzw5fDMu","uNbrCu0","CM5tufy","BxnNsuq","yuDAtLK","D056uNC","zxH0ugf5Bg8","CMvWBgfJzui","BNrbBMrvCgq","tgT2z3C","B3bLBG","BMfTzq","BMCGzMfPBgu","C0XPC3rLBMu","mNWXFdr8mhW","C0vNC3i","DgHLBG","tKrtzhG","Aw9U","vMLbAMO","CMvHzfvjBNq","vLHdv2i","yw1L","u2HHCMvKv28","quTNzhi","wuvmz2S","Cg93","q2PPwuS","uwf6su0","rKT5wwS","B25JBg9Zzq","BNvTyMvY","uenxy2G","ANL5DLK","ChbL","CeLrufG","EKj6uwW","mhW0Fdj8m3W","DKDeCNy","uKn3Aha","CgPzAvy","r3rbzey","t3LMDue","x2rLC3rYB3K","z2vtEw5J","swHZvw0","zwrPyxrLBhK","u2LfyMW","x29Ut3bLBG","CenIzvK","ywnRtxnNswq","suXosuK","r1jJEeq","DeLUDgvYy2u","EKDPt3m","CMTLCKDSB2i","rLjUDfe","rMHiqLi","Cw9Z","C3j5Afm","rwLXD3y","AKXHzhq","y1nLD2q","rLDt","r2Tevfm","zNjVBNrPzxi","ywjVCNq","zxvdyMS","wK1oBxC","C2v0y3vYC28","DNDbv2y","BwLUzW","wwXnBK0","zNjVBuj5Dgu","Cxrbueu","z2v0t3DUuhi","B25fCNjVCG","uLfLBNi","rfrNq1C","yNLrCe4","Cg9W","EfHXzfG","A1f5wg0","x29UvgLTzw8","y29Kzq","vuH2qxO","C2vUDa","uKHMr2W","qK1wChi","yvngrwO","BhPOD3e","zcWG","qwX2yxy"];return ko=function(){return t},ko()}function Gb(t,e,{blocked:r,upgrade:i,blocking:o,terminated:c}={}){let l=M,f={rkHid:function(_,w){return _(w)},gEUSP:function(_,w){return _(w)},CDsGj:l(1655),cLcwx:function(_,w){return _(w)},cDoig:"upgraden"+l(1078)},x=indexedDB[l(1326)](t,e),h=f[l(1792)](Lt,x);return i&&x[l(888)+"Listener"](f.cDoig,_=>{let w=l;i(f.rkHid(Lt,x[w(915)]),_[w(981)+"on"],_[w(723)+"on"],f[w(1246)](Lt,x[w(1673)+w(1334)]))}),r&&x[l(888)+"Listener"](l(690),()=>r()),h[l(1332)](_=>{let w=l;c&&_[w(888)+"Listener"](f[w(1617)],()=>c()),o&&_[w(888)+w(1477)](w(1215)+w(1841),()=>o())})[l(776)](()=>{}),h}function qb(t,{blocked:e}={}){let r=M,i={fbCLr:r(690)},o=indexedDB["deleteDa"+r(1744)](t);return e&&o[r(888)+r(1477)](i[r(1703)],()=>e()),Lt(o)[r(1332)](()=>{})}function Ju(t,e){let r=M,i={oRmkt:r(1637),lfIUc:function(x,h){return x in h},rBnsT:function(x,h){return x===h},COoPb:r(1028),fJRxJ:function(x,h){return x!==h}};if(!(t instanceof IDBDatabase&&!i[r(1641)](e,t)&&i[r(919)](typeof e,i.COoPb)))return;if(To[r(1309)](e))return To[r(1309)](e);let o=e[r(459)](/FromIndex$/,""),c=i[r(1820)](e,o),l=nx.includes(o);if(!i[r(1641)](o,(c?IDBIndex:IDBObjectStore).prototype)||!(l||tx[r(658)](o)))return;let f=async function(x,...h){let _=r,w=this["transact"+_(1334)](x,l?_(1713)+"e":i[_(855)]),S=w.store;return c&&(S=S[_(1043)](h[_(719)]())),(await Promise.all([S[o](...h),l&&w[_(893)]]))[0]};return To.set(e,f),f}var tx,nx,To,Hb=Xu({"node_modules/idb/build/index.js"(){let t=M,e={DJPtL:"5|2|1|4|"+t(721),UzlYA:t(1309),FrGal:t(527),jyfkQ:t(1089),YSFuu:"getAllKeys",QZnBF:function(o){return o()},lzhwq:function(o,c){return o(c)},tPcqP:t(1471),NYhRf:t(1646),pXvEn:"clear"},r=e[t(573)].split("|"),i=0;for(;;){switch(r[i++]){case"0":To=new Map;continue;case"1":tx=[e.UzlYA,e[t(726)],e[t(437)],e[t(521)],t(425)];continue;case"2":e[t(590)](Yu);continue;case"3":e[t(1406)](Fb,o=>({...o,get:(c,l,f)=>Ju(c,l)||o[t(1309)](c,l,f),has:(c,l)=>!!Ju(c,l)||o[t(1608)](c,l)}));continue;case"4":nx=[t(1850),e.tPcqP,e[t(603)],e[t(938)]];continue;case"5":Yu();continue}break}}}),jb={idb:function(t){let e=M;t[e(672)]=Promise.resolve().then(()=>(Hb(),ex))[e(1332)](function(r){return r})}},Zu={};function Nt(t){let e=M,r={nckYj:e(1353)+"1",KXjpZ:function(f,x){return f!==x}},i=r[e(561)][e(1193)]("|"),o=0;for(;;){switch(i[o++]){case"0":var c=Zu[t];continue;case"1":return l[e(672)];case"2":var l=Zu[t]={exports:{}};continue;case"3":jb[t](l,l[e(672)],Nt);continue;case"4":if(r.KXjpZ(void 0,c))return c[e(672)];continue}break}}Nt.d=(t,e)=>{let r=U;for(var i in e)Nt.o(e,i)&&!Nt.o(t,i)&&Object[r(1243)+"operty"](t,i,{enumerable:!0,get:e[i]})},(()=>{let t=M;Nt.o=(e,r)=>Object[t(1135)+"e"][t(1262)+"operty"][t(461)](e,r)})(),(()=>{let t=M,e={jetrK:function(r,i){return r!=i},edGda:t(1077)+"d",FenKZ:t(1011),hccAi:"__esModule"};Nt.r=r=>{let i=t;e[i(435)](e[i(795)],typeof Symbol)&&Symbol[i(1546)+i(1857)]&&Object[i(1243)+i(1814)](r,Symbol["toString"+i(1857)],{value:e[i(1414)]}),Object[i(1243)+i(1814)](r,e.hccAi,{value:!0})}})();var Ce={};(()=>{let t=M,e={JqQNT:function(a,n){return a(n)},qHsDA:function(a,n){return a+n},FRntQ:function(a,n){return a+n},xIItr:t(1435),BsDzl:t(555),rmztO:function(a,n){return a*n},pPmUO:function(a,n){return a*n},plXhk:function(a,n){return a(n)},NDSdx:function(a,n,s){return a(n,s)},ijsFl:function(a,n){return a+n},UCEiY:function(a,n){return a+n},UHvAz:t(377),VibWH:function(a,n){return a(n)},TSXra:"00000000"+t(1219)+t(1219)+t(1219),crQhO:t(1767)+t(1095),tUqpq:t(692)+t(1657)+"R",mTHpn:t(510)+t(1575),FSvfn:"OPEN_ERROR",FqONt:function(a,n){return a>n},aavyu:function(a,n){return a!==n},dPuHK:function(a,n){return a<n},PFuvb:function(a,n){return a<n},DaEum:function(a,n){return a!==n},xxfLe:function(a,n){return a-n},SZDQs:function(a,n){return a<n},wofRr:function(a,n){return a===n},mEuhe:function(a,n){return a<n},yWGfJ:function(a,n){return a||n},CqVNW:"vcNrA",WgytN:function(a,n){return a!==n},cXMPC:function(a,n){return a(n)},vjxsw:function(a,n){return a>>>n},nYqCZ:function(a,n,s){return a(n,s)},hlYSl:function(a,n,s){return a(n,s)},DtUob:t(946)+t(1727)+t(497)+t(623),RqUyW:t(946)+"required"+t(497)+t(1884),aGZNY:t(874),JdxQJ:function(a){return a()},NxEqG:function(a,n,s){return a(n,s)},CaNwO:t(1748)+"ame",OvWnk:function(a,n,s,d,u){return a(n,s,d,u)},UJYKl:t(1206),tkKtB:function(a,n,s){return a(n,s)},anyDt:function(a,n){return a!==n},qaExk:function(a,n){return a===n},FfehR:t(1838),PmZTu:function(a,n,s){return a(n,s)},cSewd:function(a,n){return a(n)},Szibp:function(a,n){return a!==n},gDIBc:function(a,n,s){return a(n,s)},GzZZY:function(a,n,s){return a(n,s)},vJQag:function(a,n){return a(n)},oarvL:function(a,n,s){return a(n,s)},ijeTe:function(a,n,s){return a(n,s)},AxMkC:function(a,n){return a!==n},eJJdF:function(a,n){return a===n},buLJT:t(1681),ztqnW:function(a,n,s){return a(n,s)},ynsLm:function(a,n,s){return a(n,s)},kTMyL:function(a,n){return a!==n},larfO:function(a,n,s){return a(n,s)},bxEAD:function(a,n){return a!==n},VkLNh:function(a,n){return a!==n},GFHor:t(1836),pLGPf:function(a,n,s,d){return a(n,s,d)},VJiGA:t(789),tocwt:function(a,n,s){return a(n,s)},CvDCn:t(1453),HEXzc:t(489),PdmnK:function(a,n,s){return a(n,s)},cMrea:function(a,n){return a(n)},GRcxD:function(a,n,s){return a(n,s)},UyzFF:function(a,n){return a&n},PxpcS:function(a,n){return a===n},bEgNb:t(946)+t(1727)+t(497)+t(447),dVavR:t(946)+t(1727)+t(497)+t(734),tqsAb:function(a,n){return a===n},ONMzA:t(946)+t(1727)+t(497)+t(1424),XkSVQ:function(a,n){return a===n},KjVCC:t(946)+t(1727)+t(497)+t(709),yxOnK:function(a,n){return a(n)},vcKdn:function(a,n){return a&n},FUrVP:function(a,n,s){return a(n,s)},wDBjR:function(a,n){return a>>n},wHURc:function(a,n){return a>=n},VtczA:function(a,n){return a!==n},nWXey:t(762),EvmyA:t(656)+t(1048),ieRRJ:"send_ack",uDKsu:t(1725),hXILx:t(713),GAJXX:t(647)+t(1048),rETdm:function(a,n){return a===n},hnkDB:"UnyMs",JfMVX:"abxLb",flGTm:function(a,n){return a&n},qnESl:function(a,n){return a+n},zxhaH:function(a,n){return a>>>n},ZIjBG:function(a,n){return a<<n},wYSfr:function(a,n){return a<n},wNzRw:function(a,n){return a===n},oGInz:function(a,n){return a+n},OqQnT:function(a,n){return a!==n},JVzFm:function(a,n){return a&n},puOYW:function(a,n){return a|n},yZfiI:function(a,n){return a<<n},mVqpU:function(a,n){return a<n},cUepV:function(a,n){return a==n},kHmDE:function(a,n){return a>=n},EIfnh:"QRVDX",lOIqx:t(1576),ypQBg:function(a,n){return a<<n},PQXBn:function(a,n){return a|n},KVXfy:function(a,n){return a<<n},codzJ:function(a,n){return a&n},vwuJo:function(a,n){return a&n},EOhfA:function(a,n){return a<=n},OXGkc:function(a,n){return a==n},qFOUW:function(a,n){return a>=n},XlGIy:function(a,n){return a+n},UJLhu:function(a,n){return a+n},YBFIn:function(a,n){return a+n},HiHtM:function(a,n){return a+n},itOvc:function(a,n){return a!==n},HxoEH:function(a,n){return a|n},pCbeY:function(a,n){return a|n},bnxpG:function(a,n){return a<<n},dVHBv:function(a,n){return a<<n},mKwDe:function(a,n){return a<<n},aDhFk:function(a,n){return a&n},smrCC:function(a,n){return a&n},OBSPw:function(a,n){return a+n},dAmpu:function(a,n){return a&n},Obeam:function(a,n){return a!=n},seSbc:t(1077)+"d",xxfqY:t(1468)+"DB failed",jFwIg:function(a,n){return a<n},ougyA:t(519),kMUPI:function(a,n){return a<n},vYwlT:function(a,n){return a+n},WivuN:function(a,n){return a<n},RzpFk:function(a,n){return a<n},WMDTR:function(a,n,s){return a(n,s)},iYcRU:function(a,n){return a>=n},VVbte:function(a,n){return a-n},GpfET:function(a,n){return a<n},mytzu:function(a,n){return a&n},gwKGl:function(a,n){return a|n},sryhS:function(a,n){return a&n},PcvME:function(a,n){return a&n},uxVtL:function(a,n){return a|n},ZQFFY:function(a,n){return a&n},ZMaNp:function(a,n){return a>>n},ittUr:function(a,n){return a|n},kYlaK:function(a,n){return a&n},BUyPa:t(1664),Czscv:"Ydbxp",NpEsa:function(a,n){return a<n},Nxnpa:function(a){return a()},gBYkI:t(886),GawHC:function(a,n){return a(n)},YPxrR:function(a,n){return a&n},FanVf:function(a,n){return a&n},VXCWb:function(a,n){return a(n)},NzUyA:function(a,n){return a<<n},beUac:function(a,n){return a&n},GtAdF:t(1012),PZkqK:function(a,n){return a(n)},lHZAd:function(a,n){return a<n},Wseas:function(a,n){return a&n},EpGYV:function(a,n){return a>=n},cZkuM:function(a,n){return a|n},eoXPU:function(a,n){return a&n},DFaNj:function(a,n,s){return a(n,s)},PSZAK:t(1452)+t(478)+"onnecting",ENuGe:function(a,n){return a<n},gVaSO:function(a,n){return a+n},LduGa:function(a,n){return a|n},bmoPJ:function(a,n){return a>>>n},gTxhG:function(a,n){return a(n)},UORwn:function(a,n){return a&n},zszvv:function(a,n){return a(n)},eJtiN:function(a,n){return a<<n},SBAZD:function(a,n){return a&n},jyyvY:t(1739),aUCDk:function(a,n){return a&n},xEKLB:function(a,n){return a(n)},rspCM:function(a,n){return a&n},wGViB:function(a,n){return a&n},edDBm:function(a,n){return a&n},xIOvi:function(a,n){return a(n)},MzojM:function(a,n){return a<<n},FaaUm:function(a,n){return a&n},zxmWr:function(a,n){return a(n)},zBzQl:function(a,n){return a&n},ZsHLR:function(a,n){return a&n},augLw:function(a,n){return a<<n},mOnlt:function(a,n){return a&n},WpJyV:function(a,n){return a|n},nHnSV:function(a,n){return a<<n},lUcfL:function(a,n){return a>>>n},RHfGl:function(a,n){return a===n},FTMmf:function(a,n){return a<n},lpfTX:function(a,n){return a+n},gExSK:function(a,n){return a>>>n},Rvbsk:function(a,n){return a>>>n},ENGca:function(a,n){return a&n},fJgQO:function(a,n){return a>>>n},unilF:function(a,n){return a&n},gwHvw:function(a,n){return a>>>n},jKLJi:function(a,n){return a!==n},lIeFg:function(a,n){return a|n},lKoGU:function(a,n){return a&n},ggPhB:function(a,n){return a&n},VCRCJ:function(a,n){return a>>>n},UAbQn:function(a,n){return a!==n},ISKEJ:function(a,n){return a|n},pCjhw:function(a,n){return a|n},dDJCK:function(a,n){return a&n},VljRn:function(a,n){return a|n},KkVuJ:function(a,n){return a===n},gjhMq:function(a,n){return a|n},KhVWj:function(a,n){return a|n},GIPFJ:function(a,n){return a<<n},GpAup:function(a,n){return a<<n},hvrDX:function(a,n){return a<<n},HWrAj:function(a,n){return a<<n},REbXa:function(a,n){return a>>>n},dmCWN:function(a,n){return a|n},lUMpx:function(a,n){return a<<n},ZPUnO:function(a,n){return a|n},JqNIn:function(a,n){return a<<n},QQeFE:function(a,n){return a&n},zQWpQ:function(a,n){return a>>>n},ulmpK:function(a,n){return a>>>n},tLnXR:function(a,n){return a>>>n},kWruv:function(a,n){return a>>>n},Lkvgw:t(1559),kmPiZ:t(948),hAFZC:function(a,n){return a(n)},SvIig:function(a,n){return a>=n},yepYi:function(a,n){return a+n},lhGNm:function(a,n){return a%n},hRxYb:function(a,n){return a*n},KwiPu:function(a,n){return a*n},KxYZN:function(a,n,s){return a(n,s)},hwdXv:t(1290),IUmku:t(1207),SClaC:"QSFUz",ChNzL:function(a,n){return a===n},rPdoW:function(a,n){return a>>>n},isjbZ:function(a,n){return a+n},YZjZK:function(a,n){return a<<n},nZOps:function(a,n){return a===n},Vqxfb:function(a,n){return a>>>n},qUpEf:function(a,n){return a===n},EYPIj:function(a,n){return a===n},FVSJi:function(a,n){return a+n},abXOs:function(a,n){return a===n},GoXfE:"AwkGc",vIoeS:t(566),MsGpv:function(a,n){return a&n},rvKKc:function(a,n){return a&n},YELgk:function(a,n){return a>>>n},WbnrG:function(a,n){return a&n},gUpGg:function(a,n){return a>>>n},uZleH:function(a,n){return a>>>n},RjQlH:function(a,n){return a&n},kqlmU:function(a,n){return a>>>n},xZdik:function(a,n){return a&n},Pdyhn:function(a,n){return a&n},iuYas:function(a,n){return a>>>n},cNQwJ:"CONNECTI"+t(970),zXkrz:t(1093)+"ERROR",qRiqm:"kOmNG",qodxX:function(a,n){return a||n},OvJeh:function(a,n){return a!==n},bLKnI:t(393),DUXwy:t(1865)+t(1447),yDjVP:function(a,n){return a(n)},xmBBk:function(a,n){return a<<n},dfoym:function(a,n){return a&n},vwAWf:"jWvCs",TjSIu:t(424),bJEnt:t(1574),xLZfQ:"tqqkN",gEzfG:function(a,n){return a||n},dqOVY:t(1271),eIriI:function(a,n){return a===n},oOtPT:t(1233),gEyBS:t(429),Gmjdo:function(a,n){return a||n},VKXlI:"string",VSOas:"manual r"+t(593)+t(1249),rFHiC:function(a,n){return a===n},nOJjV:"jsWpE",xDUEB:function(a,n){return a===n},islxe:function(a,n){return a===n},RQenr:t(1671),oASnM:"Unhandle"+t(1052),obOPC:function(a,n){return a===n},BMVpr:function(a,n){return a<n},lunAR:function(a,n){return a===n},vCtpo:function(a,n,s){return a(n,s)},MFPir:t(1655),DIXYK:t(1326),AOzrH:t(1156),gMljV:"message",hlLzc:function(a,n){return a!==n},YIQAh:function(a,n,s){return a(n,s)},CdCoz:function(a,n){return a+n},deyCY:function(a,n){return a+n},RpQqM:function(a,n){return a<<n},ZEATb:function(a,n){return a&n},DbGMZ:function(a,n){return a&n},MIrew:function(a,n){return a<n},QDmpC:function(a,n){return a+n},WBoVW:function(a,n){return a+n},kXQtQ:t(689),rGXzB:function(a,n){return a instanceof n},SiEbl:"idb",RqJYe:t(1311),nDWOy:function(a,n){return a||n},GoAdP:function(a,n){return a|n},ZToSg:function(a,n){return a+n},oFcme:"4|1|0|2|5|3",WthrA:function(a,n){return a|n},cNhij:function(a,n){return a+n},hzwoC:function(a,n){return a+n},NUtUh:function(a,n){return a|n},inblq:function(a,n){return a&n},GEIFf:function(a,n){return a|n},vyyat:function(a,n){return a&n},MmLPe:function(a,n){return a>>n},GhINV:function(a,n){return a|n},DWZqM:t(1466),zOVvy:t(1532)+"1",JEwqz:function(a,n){return a||n},MpDYe:function(a,n){return a+n},xhjbx:function(a,n,s){return a(n,s)},JwiPR:function(a,n){return a<n},YhNhq:function(a,n){return a<=n},qrjFc:function(a,n){return a>=n},nsuTa:function(a,n){return a<<n},PNzcg:function(a,n){return a&n},ermGb:function(a,n){return a&n},CISPC:function(a,n){return a&n},TTtbM:function(a,n){return a-n},eUQul:function(a,n){return a<<n},jFeOs:function(a,n){return a&n},fLGBp:function(a,n){return a&n},lhrMx:function(a,n){return a+n},ZreBN:t(1150),eBgJn:t(1390),WFQZE:function(a,n){return a<n},LfzJI:function(a,n){return a>>n},jplqH:function(a,n){return a&n},rCfLO:function(a,n){return a&n},mCofr:function(a,n){return a+n},BfAZl:function(a,n){return a+n},IrDcX:function(a,n){return a<<n},KWVpT:function(a,n){return a&n},PzjrS:function(a,n){return a|n},XPqba:function(a,n){return a>>n},DZxsc:function(a,n){return a|n},rKjSa:function(a,n){return a>>n},BsOxa:function(a,n){return a&n},sOXEJ:function(a,n){return a|n},YIOGD:function(a,n){return a&n},JfGqB:function(a,n){return a|n},bFGxR:function(a,n){return a&n},DBDPv:"applicat"+t(1436),WrtFv:"text/pla"+t(1541)+"et=utf-8",klRlM:t(1350),tjHpO:t(1499),uVwqt:function(a,n){return a(n)},HXGSH:"unknown "+t(1111),tUFrF:function(a,n,s){return a(n,s)},rlDUk:function(a,n){return a!==n},dOSaE:t(488),GDxbW:t(423)+t(394),bxvDK:"http",aXFyd:t(796)+t(809)+t(683)+"P",IfOyv:function(a,n){return a(n)},SOlVr:function(a,n){return a!==n},yIJwB:t(1866),MuQHp:t(490),MsuuB:t(526)+"alled mu"+t(449)+"imes in process",DTgCW:function(a,n){return a===n},ztBai:t(401),skHqH:function(a){return a()},VNEWD:function(a,n){return a===n},ldEQM:t(925),pWDCE:t(911)+t(1462)+"t",tXZGk:function(a,n){return a(n)},GMRtB:t(1849),vtfLk:t(1855),VFnzw:"KSaVO",fVaKr:"KmlZW",QUXVN:t(631),xdpGz:function(a){return a()},LNtvX:function(a,n){return a(n)},OyfuA:"nfGzD",JbgBe:t(1497),LSqXt:function(a,n){return a+n},mBlKJ:function(a,n){return a+n},IRYOC:function(a,n){return a===n},jwVib:t(1039),TtUDs:t(883),AEFpR:"script",GZYwX:t(1551),XJKyJ:function(a,n){return a||n},fLKWT:function(a,n,s){return a(n,s)},ALBGf:function(a,n){return a(n)},UsKzR:t(1164),YnotT:t(679),xbVgk:function(a,n){return a||n},Alqkr:function(a,n){return a||n},DiIDL:function(a,n,s){return a(n,s)},HLXSg:"XeZOR",RFuKz:function(a,n){return a||n},tdLcB:function(a,n){return a||n},BBcHW:function(a,n){return a||n},vNdTn:"message_id",ixOjb:function(a,n,s){return a(n,s)},dwgpz:function(a,n){return a(n)},GyyRW:function(a){return a()},bbZsb:function(a,n){return a===n},Uhnwp:t(1598),Alvav:function(a,n){return a|n},TONsK:function(a,n){return a|n},XqtGU:function(a,n){return a&n},YavIP:function(a,n){return a+n},zPhNb:function(a,n){return a>>n},QWzYb:t(934),ksQFV:"x_fronti"+t(1862),rIyOv:"x_frontier_qos_ack",HSArl:function(a,n,s,d){return a(n,s,d)},NupEv:t(604)+t(1847)+"k",LFtIx:t(604)+t(743)+t(1055),QJEnB:function(a,n,s,d){return a(n,s,d)},cmMAn:function(a,n,s,d){return a(n,s,d)},XdfqA:t(1733),SvzJi:"jpdGr",kQyXm:"LtNey",bzHUv:"ack_id",TOgtO:t(1757),Eidzd:function(a){return a()},zzWtH:t(1239),QazIM:function(a,n){return a(n)},DzSDz:function(a,n){return a(n)},TIMSH:function(a,n){return a instanceof n},tKlRj:"applicat"+t(1436)+";charset"+t(1606),AgYVW:t(575)+"e",qfORZ:t(1260),KrZtF:function(a){return a()},YpffF:function(a,n){return a>n},uTYGi:function(a,n){return a(n)},xmaje:function(a,n){return a(n)},aNCHS:function(a,n){return a&n},bFBkN:function(a,n){return a+n},Wefnx:t(476),IaBXS:function(a,n){return a+n},BRWWB:function(a,n){return a+n},lMDYa:function(a,n){return a+n},BXUrN:"index ou"+t(1299)+"ge: ",mSFSi:"LeEiR",PPSMn:t(1252),ykRba:t(1549),NpxFP:"ckkcI",aptxK:function(a,n){return a+n},xXqdX:function(a,n){return a<<n},dgzFa:"KwQXG",KojAK:function(a,n){return a+n},AetlL:function(a,n,s,d){return a(n,s,d)},zBowW:function(a,n){return a|n},qHmCy:function(a,n){return a<<n},ivmCL:function(a,n){return a|n},zGXWL:function(a,n){return a<<n},oCBZX:function(a,n){return a+n},kCcSf:function(a,n){return a>>>n},ivTlj:function(a,n){return a+n},czLNR:function(a,n){return a&n},WJwIF:function(a,n){return a+n},RCwhp:function(a,n){return a&n},iGnZa:function(a,n){return a+n},xiPGP:function(a,n){return a&n},PhAfl:function(a,n){return a+n},fHMeC:t(1794),YFgSV:"dRKAm",DnwIs:function(a,n){return a<n},UhmKM:function(a,n){return a&n},ZHczD:function(a,n){return a|n},LsstM:function(a,n){return a<<n},NYfrl:function(a,n){return a|n},OCICg:function(a,n){return a&n},HNqHi:function(a,n){return a|n},mwahd:function(a){return a()},zEZyP:function(a,n){return a<n},iHkWi:"ondTX",QRBqj:t(1856)+t(374),PZffk:"header",DRaQQ:t(1327),WlfUk:"curvalue",ztjUr:function(a,n){return a(n)},JCQxQ:function(a,n){return a(n)},iQclL:t(1683)+"ile_name",SbqYV:function(a,n,s){return a(n,s)},koYCs:function(a,n,s,d){return a(n,s,d)},mndIH:t(988)+"_EXIST",bURKq:t(516),WKIXN:"CONTINUE",iuihl:function(a,n,s,d){return a(n,s,d)},FVNXG:function(a,n){return a===n},ZtoUR:t(921),vbaUW:t(1189),xEYJY:function(a,n){return a+n},anyEO:t(1487),HUavS:t(1385)+"r",HhlcT:function(a,n){return a===n},WBjJL:t(1220),HhqRQ:t(1763),oDIEq:t(816),AKgdr:t(690),FKyYk:function(a,n){return a&n},wzVNx:function(a,n){return a>>>n},nNqOQ:function(a,n){return a>>>n},FxhKV:function(a,n){return a&n},otnal:function(a,n){return a>>>n},OPAyO:function(a,n){return a!==n},EGGFp:function(a,n,s){return a(n,s)},Rumzz:function(a,n){return a!==n},UdwAG:function(a,n,s){return a(n,s)},ILNII:function(a,n,s,d){return a(n,s,d)},WMQsA:t(1400),HsERq:function(a,n,s,d){return a(n,s,d)},hjtiB:t(604)+t(1571),rYtvF:t(1800)+"s",OYpLH:t(1269)+t(1247)+"e",IFVRv:function(a,n){return a(n)},pjYiV:function(a,n,s){return a(n,s)},hlTDF:"x-msg-cu"+t(1141)+"ue",yFnCP:function(a){return a()},DEhEB:function(a,n){return a>n},KKsIg:t(1351),hzyep:"OLiLP",DAlIF:function(a){return a()},pWlfO:"gEbqG",vpbri:"bVCZv",YlNIi:function(a){return a()},wAyXT:function(a,n){return a===n},fOobT:t(1867),nEWRP:"eElks",YYWpr:function(a){return a()},qOLNj:function(a){return a()},fOpmW:t(1143),rSHNR:function(a,n){return a===n},hZjBe:function(a,n){return a&&n},wqVpS:function(a){return a()},VwmEj:function(a,n,s){return a(n,s)},LSQkk:function(a){return a()},fYEFL:function(a,n){return a(n)},ZUUkJ:function(a){return a()},GYhjM:function(a,n){return a<n},HJdLZ:function(a,n){return a!==n},ypGHM:t(1586),pnuLo:function(a,n,s){return a(n,s)},cIVkh:function(a,n,s){return a(n,s)},PaHfe:function(a,n){return a|n},Cxkvu:function(a,n){return a|n},vZjXt:function(a,n){return a&n},JKker:function(a,n){return a>n},CUYxE:function(a,n){return a&n},vaAQu:function(a,n,s){return a(n,s)},QhzWr:function(a,n){return a&n},ZFxWN:function(a,n){return a===n},akRaW:function(a,n){return a===n},UqaXi:function(a,n){return a!==n},BpZqx:function(a,n){return a===n},mvSmC:t(858),rtAmu:function(a,n){return a!==n},KeaEj:"ZUZqM",IzeYd:function(a,n,s){return a(n,s)},FDhTF:t(418),WfsFq:t(1054),euCbk:t(1174)+t(1578),aNdDE:t(1540),AdzSm:function(a,n){return a/n},Tuetq:t(1198),jLadt:function(a,n){return a==n},sPiAb:function(a,n){return a===n},jNiem:t(952)+t(386)+"alid url",YYWJv:function(a,n){return a(n)},UMgeL:function(a,n){return a===n},JRQUi:t(769),roQDR:function(a,n){return a&n},Ojsgb:t(1561),qbCnt:t(1728)+t(1362)+t(1504)+"ct",dsBWr:t(1609),QjjfO:"pageshow",PHJke:function(a,n){return a===n},LjlQI:"YLkbD",Pxwid:t(499),SbtFA:"QmPco",cZcuV:t(1488),KkXhG:"pagehide",VArkP:function(a,n){return a!==n},OiEDH:function(a,n){return a==n},fJSVE:"ws://",NMpco:"OPzsB",UODLK:t(1318),yshzD:"bd_did",bncMt:"ttwid",jOjpd:t(952)+t(1490)+t(1885)+"viceID or ttwID",WnXOS:t(1518),glfPO:t(1313),KaPCm:t(896)+"0",IbvCg:function(a,n,s){return a(n,s)},ZMNmw:function(a,n){return a||n},vYZDg:t(1e3)+"t",fqIHG:function(a,n){return a(n)},jMBbC:t(1682)+">",hkaJU:function(a,n){return a*n},GoocJ:function(a,n){return a-n},mIKUa:t(1074),wMyla:function(a,n,s){return a(n,s)},ZmqUk:t(1185)+t(1839)+"reconnec"+t(1615)+t(1130),tViRX:function(a,n){return a&n},sNtaP:function(a,n){return a&n},MgYTL:function(a,n){return a>>>n},tKpjk:function(a,n){return a&n},XCHHU:function(a,n){return a>>>n},bjWib:function(a,n){return a>>>n},qYdYT:function(a,n){return a!==n},qXBxY:t(1038),irsIw:"pBmPX",qfMAB:"3|0|2|1|4",OtiBt:t(601),fClSf:function(a,n,s){return a(n,s)},JfwNp:t(1419),BsGQi:t(746),FtqMx:function(a,n){return a+n},LxLRd:t(1109),irYIX:"rSxWx",ZVFQD:t(1434)+t(378),UGPKD:t(1152)+"s already closed",VDGAb:t(952)+t(1593)+t(1583)+t(549)+"a must b"+t(982)+t(460)+" arraybu"+t(1261),HTnZI:t(1347),cwINr:t(952)+t(1593)+t(1225)+t(374),oEZOu:function(a,n){return a(n)},usISd:t(1402),Wqwtf:function(a,n){return a<n},kYYhc:t(881),NacMJ:function(a,n){return a==n},flmTM:t(1708),sjSaA:"DypFc",ncPNf:t(945),aBHjc:t(911)+t(1735)+"s",kOvAF:"\0\0\0\0\0\0\0\0",BTmln:function(a,n){return a*n},LWahg:function(a,n){return a!=n},HgAZm:t(847),mBDIp:function(a,n){return a===n},ZmJLu:t(583),iXvvr:function(a,n){return a===n},lKhQJ:function(a,n){return a!=n},ygveV:t(1294)+t(612)+t(694)+"pe",YSeLj:function(a,n){return a===n},GDhSc:t(1339)+t(1371)+"alScope",dGcni:"ServiceW"+t(540)+"balScope",nvlWl:function(a,n){return a!=n},ysVGr:function(a,n){return a!=n},FKXUp:function(a,n,s){return a(n,s)},uKqag:t(1692)+t(663)};Nt.r(Ce),Nt.d(Ce,{FWS:()=>Up,CustomErrorEvent:()=>jd,createCloseEvent:()=>xt,ReconnectEvent:()=>Hd,createErrorEvent:()=>ot,decodedFrame:()=>Zt,createOpenEvent:()=>Jd,CustomCloseEvent:()=>Wd,createReconnectEvent:()=>da,FrontierMessageEvent:()=>$d,encodeFrame:()=>Bt,createMessageEvent:()=>Yd,OpenEvent:()=>Vd,ErrorCode:()=>Qt,Event:()=>Yn,MessageEvent:()=>Kd});let r="";function i(a=""){let n=t,s="02",d=""+Date[n(895)](),u=r||(r=e[n(1509)](x,a)),p=Math[n(1090)]()[n(1546)](16)[n(1610)](-6);return e[n(1182)](e[n(1372)](s,d)+u,p)}function o(){let a=t;if(e[a(1653)]===e[a(1523)])_0x4afe6d[a(889)+"oad"]="",_0x55dd07[a(1740)](_0x103c84);else return e[a(545)](1e4,Date[a(895)]())+Math.floor(e.pPmUO(1e4,Math[a(1090)]()))}function c(a){let n=t;return e[n(1372)](e.plXhk(Array,8)[n(431)]("0"),e[n(1333)](parseInt,a,10)[n(1546)](2))[n(1610)](-8)}function l(a){let n=t;return e[n(950)](e[n(1509)](Array,4)[n(431)]("0"),e[n(1333)](parseInt,a,2)[n(1546)](16))[n(1610)](-4)}function f(a){let n=t,s=a.split(/\./).map(p=>c(p)),d=[];return d[0]=e[n(1509)](l,e[n(969)](s[0],s[1])),d[1]=e[n(1176)](l,e[n(969)](s[2],s[3])),[n(377),e[n(1401)],n(377),e[n(1401)],n(377),n(1067),d[0],d[1]][n(431)]("")}function x(a){let n=t,s=/(25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?)(\.(25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?)){3}/.test(a),d=/(([0-9a-fA-F]{1,4}:){7,7}[0-9a-fA-F]{1,4}|([0-9a-fA-F]{1,4}:){1,7}:|([0-9a-fA-F]{1,4}:){1,6}:[0-9a-fA-F]{1,4}|([0-9a-fA-F]{1,4}:){1,5}(:[0-9a-fA-F]{1,4}){1,2}|([0-9a-fA-F]{1,4}:){1,4}(:[0-9a-fA-F]{1,4}){1,3}|([0-9a-fA-F]{1,4}:){1,3}(:[0-9a-fA-F]{1,4}){1,4}|([0-9a-fA-F]{1,4}:){1,2}(:[0-9a-fA-F]{1,4}){1,5}|[0-9a-fA-F]{1,4}:((:[0-9a-fA-F]{1,4}){1,6})|:((:[0-9a-fA-F]{1,4}){1,7}|:)|fe80:(:[0-9a-fA-F]{0,4}){0,4}%[0-9a-zA-Z]{1,}|::(ffff(:0{1,4}){0,1}:){0,1}((25[0-5]|(2[0-4]|1{0,1}[0-9]){0,1}[0-9])\.){3,3}(25[0-5]|(2[0-4]|1{0,1}[0-9]){0,1}[0-9])|([0-9a-fA-F]{1,4}:){1,4}:((25[0-5]|(2[0-4]|1{0,1}[0-9]){0,1}[0-9])\.){3,3}(25[0-5]|(2[0-4]|1{0,1}[0-9]){0,1}[0-9]))/.test(a);return s?e[n(728)](f,a):d?e[n(1509)](h,a):e.TSXra}function h(a){let n=t,s={ViAjj:e.crQhO,UWWEW:e[n(1287)],QYHCJ:n(1093)+"ERROR",wFbxZ:e[n(668)],AvEDq:e[n(681)]},d="",u=[],p=0,m=0,E=!0,g=e[n(1401)];if(e[n(1060)](a[n(1678)]("::"),-1))if(e.aavyu(n(1005),n(1005))){let k=s[n(1335)][n(1193)]("|"),N=0;for(;;){switch(k[N++]){case"0":_0x5211e0[_0x4f7af3[s[n(688)]]=5003]=s[n(688)];continue;case"1":_0x41f9c5[_0x199d53["CONNECTI"+n(970)]=5002]=n(1245)+n(970);continue;case"2":_0x35973c[_0xa32aa1[s[n(514)]]=5004]=s[n(514)];continue;case"3":_0x545c75[_0x76ebcd[s.wFbxZ]=5001]=s[n(736)];continue;case"4":_0x4065b2[_0x50303a[s[n(1187)]]=5005]=s.AvEDq;continue;case"5":return _0x2aeb87}break}}else{let k=a.split("::");for(let z=0;e[n(1032)](z,k[n(614)]);z++){let H=k[z];if(H[n(1678)](":")>0){let L=H[n(1193)](":");E&&(p=L.length),m+=L.length;for(let F=0;e[n(739)](F,L[n(614)]);F++)if(e[n(1835)](4,L[F][n(614)])){let se=g.substring(0,e[n(918)](4,L[F][n(614)])),qe=se[n(1437)](L[F]);u[n(1889)](qe)}else u[n(1889)](L[F]);E=!1}else{if(e[n(1835)](4,H[n(614)])){let L=g[n(727)+"g"](0,e[n(918)](4,H[n(614)])),F=L[n(1437)](H);u[n(1889)](F)}else u[n(1889)](H);E&&(p+=1),m+=1,E=!1}}let N="";for(let z=0;e[n(1032)](z,8-m);z++)N=N[n(1437)](g);for(let z=0;e[n(562)](z,u.length);z++)e[n(1218)](z,p)?(d=d.concat(N),d=d[n(1437)](u[z])):d=d.concat(u[z]);return d}{let k=a[n(1193)](":");for(let N=0;e.mEuhe(N,k.length);N++){let z=k[N];if(e[n(1698)](4,k[N][n(614)])){let H=g[n(727)+"g"](0,e[n(918)](4,k[N][n(614)])),L=H[n(1437)](z);d=d[n(1437)](L)}else d=d.concat(z)}return d}}function _(a,n){let s=t;if(e[s(1698)]("VivBp",e.CqVNW)){let d=a[s(623)];e.WgytN(void 0,d)&&(e[s(1333)](ue,n,10),e[s(1333)](W,n,d));let u=a[s(1884)];e[s(1191)](void 0,u)&&(e.NDSdx(ue,n,18),W(n,u))}else{let d=this[s(1259)][s(1016)](this[s(1022)]),u=_0x2ee41f[s(1030)](e[s(1803)](d,"{}"));return _0x4f6fec[s(630)](u)}}function w(a){let n=t,s={};e:for(;!e.cXMPC(J,a);){let d=e[n(594)](fe,a);switch(e.vjxsw(d,3)){case 0:break e;case 1:s[n(623)]=O(a,e[n(728)](fe,a));break;case 2:s[n(1884)]=e[n(428)](O,a,fe(a));break;default:e[n(632)](C,a,7&d)}}if(e[n(1218)](void 0,s[n(623)]))throw new Error(e[n(1568)]);if(s[n(1884)]===void 0)throw new Error(e[n(1085)]);return s}function S(a){let n=t;if(e[n(1698)](e[n(1320)],e[n(1320)]))_0x115d13.body[n(1529)+n(617)](_0x3534af);else{let s=e.JdxQJ(R);return e.NDSdx(b,a,s),e.cXMPC(G,s)}}function b(a,n){let s=t,d=a[s(447)];d!==void 0&&(e[s(1191)](e[s(1222)],"tzERI")?(e[s(629)](ue,n,8),e[s(1103)](ut,n,d)):(this[s(864)+s(699)]=0,this[s(533)+s(926)+"riesCount"]=0));let u=a[s(734)];e[s(1876)](void 0,u)&&(e.qaExk(s(1838),e[s(980)])?(e[s(1103)](ue,n,16),e.NDSdx(ut,n,u)):(this[s(1639)+s(917)+s(1428)]=_0x1bd535,_0x258b88?this[s(390)+s(654)]():this["_handleO"+s(848)]()));let p=a[s(1424)];e[s(1835)](void 0,p)&&(e.PmZTu(ue,n,24),e[s(1481)](ut,n,e[s(1378)](P,p)));let m=a[s(709)];e[s(833)](void 0,m)&&(e.gDIBc(ue,n,32),e[s(463)](ut,n,e[s(1688)](P,m)));let E=a[s(1429)];if(e[s(1698)](void 0,E))for(let se of E){e[s(1415)](ue,n,42);let qe=e[s(1825)](R);e[s(1250)](_,se,qe),ue(n,qe[s(1829)]),e[s(629)]($,n,qe),e[s(1509)](D,qe)}let g=a[s(1882)+s(1521)];e[s(1720)](void 0,g)&&(e[s(898)](e[s(954)],e[s(954)])?(e.PmZTu(ue,n,50),e[s(1180)](W,n,g)):(this[s(805)+"ameSpace"]=_0x13c17a,this[s(1630)+s(745)]=_0x34863a,this[s(1421)+"Strategy"]=_0x3e6ba6,this._qosDB=e[s(629)](_0x3d1622,this[s(805)+s(445)],e[s(947)])));let k=a[s(802)+"ype"];e[s(1835)](void 0,k)&&(e.gDIBc(ue,n,58),W(n,k));let N=a[s(1828)];if(N!==void 0){if(e[s(898)]("hGnCJ",s(1190)))return this[s(1259)]?.[s(718)];e[s(1333)](ue,n,66),e[s(1531)](ue,n,N.length),e[s(1481)](he,n,N)}let z=a[s(1069)];e[s(772)](void 0,z)&&(e[s(1180)](ue,n,74),e[s(602)](W,n,z));let H=a[s(1596)+s(1387)];e[s(414)](void 0,H)&&(ue(n,82),e[s(1333)](W,n,H));let L=a[s(1319)];e[s(777)](void 0,L)&&(ue(n,90),e.gDIBc(W,n,L));let F=a.frameType;e[s(414)](void 0,F)&&(e[s(898)](e[s(870)],e[s(870)])?(e[s(1333)](ue,n,96),ut(n,P(F))):wZsIRl.OvWnk(_0x5b3cb1,_0x258949(_0x43121b.result),_0x33bbd1.oldVersion,_0x1e6d2e[s(723)+"on"],wZsIRl[s(1509)](_0x4b7015,_0x154286[s(1673)+s(1334)])))}function v(a){let n=t;return e.vJQag(I,e[n(1509)](B,a))}function I(a){let n=t,s={GCkKq:function(u,p,m,E){return e[U(1741)](u,p,m,E)}};if(e[n(1557)]!=="YxaOr"){let u={};e:for(;!e[n(1378)](J,a);){let p=fe(a);switch(e[n(787)](p,3)){case 0:break e;case 1:u[n(447)]=e[n(868)](vt,a,!0);break;case 2:u[n(734)]=e[n(868)](vt,a,!0);break;case 3:u[n(1424)]=e[n(594)](fe,a);break;case 4:u[n(709)]=fe(a);break;case 5:if(e[n(1835)](e[n(766)],e.HEXzc)){let m=e[n(1176)](A,a);(u.headers||(u[n(1429)]=[]))[n(1889)](w(a)),a[n(1829)]=m;break}else this[n(533)+n(926)+n(1764)+"t"]=0;case 6:u[n(1882)+"ncoding"]=e[n(1788)](O,a,e[n(1690)](fe,a));break;case 7:u["payloadT"+n(1536)]=e.nYqCZ(O,a,fe(a));break;case 8:u[n(1828)]=e.PmZTu(be,a,fe(a));break;case 9:u.LogIDNew=e[n(1333)](O,a,e[n(1176)](fe,a));break;case 10:u["serverTi"+n(1387)]=O(a,fe(a));break;case 11:u.msgID=e[n(1368)](O,a,e[n(1176)](fe,a));break;case 12:u[n(859)+"e"]=e[n(1176)](fe,a);break;default:C(a,e[n(1470)](7,p))}}if(e[n(1745)](void 0,u[n(447)]))throw new Error(e[n(902)]);if(u[n(734)]===void 0)throw new Error(e[n(502)]);if(e[n(1047)](void 0,u[n(1424)]))throw new Error(e[n(600)]);if(e[n(1558)](void 0,u[n(709)]))throw new Error(e.KjVCC);return u}else for(var d in _0x485432)OGVHhA.GCkKq(_0x59a760,_0x218196,d,{get:_0x5a1e1b[d],enumerable:!0})}function A(a){let n=t,s=e.yxOnK(fe,a),d=a.limit;return a[n(1829)]=e[n(1372)](a.offset,s),d}function C(a,n){let s=t;switch(n){case 0:for(;e.vcKdn(128,e[s(1690)](ie,a)););break;case 2:e[s(1651)](Y,a,fe(a));break;case 5:Y(a,4);break;case 1:e[s(428)](Y,a,8);break;default:throw new Error(e.ijsFl(s(1121)+s(1157)+s(997),n))}}function P(a){let n=t;return a|=0,{low:a,high:e[n(505)](a,31),unsigned:e[n(657)](a,0)}}let y=[];function R(){let a=t,n=y[a(1396)]();return n?(n.offset=n[a(1829)]=0,n):{bytes:new Uint8Array(64),offset:0,limit:0}}function D(a){let n=t;e.VtczA("WNDaH",e.nWXey)?y[n(1889)](a):this.on(_0x18d05d,_0x48f3c0)}function B(a){return{bytes:a,offset:0,limit:a.length}}function G(a){let n=t,s=a[n(1212)],d=a[n(1829)];return e[n(1745)](s[n(614)],d)?s:s[n(1815)](0,d)}function Y(a,n){let s=t;if(e[s(1372)](a[s(781)],n)>a[s(1829)])throw new Error(e[s(1268)]);a.offset+=n}function J(a){let n=t;return a[n(781)]>=a[n(1829)]}function te(a,n){let s=t,d=a[s(1212)],u=a.offset,p=a[s(1829)],m=e[s(950)](u,n);if(e[s(1060)](m,d[s(614)])){let E=new Uint8Array(2*m);E.set(d),a.bytes=E}return a[s(781)]=m,m>p&&(a[s(1829)]=m),u}function Q(a,n){let s=t,d={IhsUm:function(u,p){return e.XkSVQ(u,p)},pqtXw:e[s(936)]};if(e[s(1558)](e[s(1658)],e[s(493)])){let u=_0x3d62ad(_0x408cce);this[s(1196)]&&d[s(1361)](this[s(1196)][s(1654)+"te"],this.OPEN)&&(this._ws&&this[s(1196)][s(1232)](u),this._debug(d.pqtXw,_0x53b560))}else{let u=a[s(781)];if(e.ijsFl(u,n)>a[s(1829)])throw new Error(e[s(1729)]);return a[s(781)]+=n,u}}function be(a,n){let s=t;if(e.rETdm(e[s(1640)],e[s(1845)]))return this._ws?this[s(1196)][s(1723)+"pe"]:this[s(1489)+s(1536)];{let d=e[s(1368)](Q,a,n);return a[s(1212)][s(1815)](d,e[s(1182)](d,n))}}function he(a,n){let s=t,d=te(a,n[s(614)]);a[s(1212)][s(1705)](n,d)}function O(a,n){let s=t,d={aiEaC:function(k,N){return e[U(787)](k,N)},EfyPO:function(k,N){return e.flGTm(k,N)},vGDrv:function(k,N){return e[U(787)](k,N)},XOiZy:function(k,N){return e[U(1595)](k,N)},MswRb:function(k,N){return e[U(949)](k,N)},GAvRU:function(k,N){return k|N},cnJCO:function(k,N){return k<<N},YjtLt:function(k,N){return e[U(1650)](k,N)}},u=e[s(1368)](Q,a,n),p=String[s(838)+s(812)],m=a[s(1212)],E="\uFFFD",g="";for(let k=0;e[s(529)](k,n);k++){let N=m[e[s(950)](k,u)],z,H,L,F;if(e.wofRr(e[s(1131)](128,N),0))g+=p(N);else if(e[s(1321)](e.UyzFF(224,N),192))k+1>=n?g+=E:(z=m[e[s(1746)](e[s(969)](k,u),1)],e[s(373)](e[s(532)](192,z),128)?g+=E:(F=e[s(400)](e[s(649)](e[s(1819)](31,N),6),e[s(1819)](63,z)),e[s(1778)](F,128)?g+=E:(g+=e[s(1690)](p,F),k++)));else if(e[s(785)](240&N,224))if(e[s(929)](e[s(1182)](k,2),n))g+=E;else if(e[s(989)](e[s(1870)],e[s(596)])){_0x215aad[s(1644)](_0x2aea5f)||(_0x47add0=_0x586120[s(1660)+"er"](_0x1e6065));let se=d[s(572)](this[s(1023)],16),qe=65535&this.high,ts=this[s(1071)]>>>16,ns=d.EfyPO(65535,this[s(1071)]),ma=d[s(1354)](_0x29aa98[s(1023)],16),wa=d[s(1573)](65535,_0x3aa5e3[s(1023)]),Wr=d.vGDrv(_0x548c4f[s(1071)],16),_a=65535&_0x13e952.low,tn=0,Ft=0,Kr=0,rs=0;return rs+=ns+_a,Kr+=rs>>>16,rs&=65535,Kr+=ts+Wr,Ft+=Kr>>>16,Kr&=65535,Ft+=d.XOiZy(qe,wa),tn+=d[s(1458)](Ft,16),Ft&=65535,tn+=se+ma,tn&=65535,_0x547c62[s(865)](d[s(1056)](d.cnJCO(Kr,16),rs),d.GAvRU(d[s(1824)](tn,16),Ft),this[s(1088)])}else z=m[k+u+1],H=m[e[s(1182)](e[s(1746)](k,u),2)],e[s(772)](e[s(532)](e[s(400)](z,e.ypQBg(H,8)),49344),32896)?g+=E:(F=e.puOYW(e[s(477)](e[s(551)](e.codzJ(15,N),12),e[s(1125)](63,z)<<6),e[s(1125)](63,H)),e[s(529)](F,2048)||F>=55296&&e[s(967)](F,57343)?g+=E:(g+=e[s(1688)](p,F),k+=2));else e.OXGkc(e[s(1042)](248,N),240)?e[s(1116)](k+3,n)?g+=E:(z=m[e.XlGIy(k,u)+1],H=m[e[s(452)](e[s(823)](k,u),2)],L=m[e[s(1304)](e[s(969)](k,u),3)],e[s(1632)](e[s(1751)](e[s(1365)](z,e[s(1301)](H,8)),e[s(1594)](L,16))&12632256,8421504)?g+=E:(F=e.PQXBn(e[s(400)](e.pCbeY(e.mKwDe(e[s(1562)](7,N),18),e[s(1650)](e[s(532)](63,z),12)),e[s(742)](63,H)<<6),63&L),e[s(1778)](F,65536)||F>1114111?g+=E:(F-=65536,g+=e[s(632)](p,e[s(950)](F>>10,55296),e[s(1878)](e[s(1616)](1023,F),56320)),k+=3))):g+=E}return g}function W(a,n){let s=t,d=n[s(614)],u=0;for(let E=0;e[s(1680)](E,d);E++)if(e[s(1132)]===e[s(1132)]){let g=n[s(1534)+"At"](E);e[s(929)](g,55296)&&g<=56319&&e[s(1872)](e[s(537)](E,1),d)&&(g=e[s(918)](e[s(452)](e[s(1301)](g,10),n[s(1534)+"At"](++E)),56613888)),u+=e[s(1106)](g,128)?1:e[s(384)](g,2048)?2:g<65536?3:4}else{if(e[s(1803)](_0x1e4e8d,_0x473717))return new _0x2fe50b(_0x52472f,_0x1df4bd);if(e[s(1803)](_0x44aadd,_0x625b15)&&e.Obeam(e[s(1674)],typeof _0x1bedd9))return new _0x592605(_0x4c094d,_0x4e15f1);if(e.yWGfJ(_0x31029a,_0x5d118d)&&e.seSbc!=typeof _0x3cf812)return new _0x4776da(_0x47c200,_0x654fe8);throw new _0xf45025(e.xxfqY)}e[s(632)](ue,a,u);let p=e.WMDTR(te,a,u),m=a[s(1212)];for(let E=0;e.RzpFk(E,d);E++){let g=n.charCodeAt(E);e[s(951)](g,55296)&&g<=56319&&e[s(739)](E+1,d)&&(g=e.VVbte(e[s(823)](g<<10,n[s(1534)+"At"](++E)),56613888)),e[s(1014)](g,128)?m[p++]=g:(e.wYSfr(g,2048)?m[p++]=e[s(376)](g>>6,31)|192:(e[s(1872)](g,65536)?m[p++]=e[s(1302)](e[s(1375)](e[s(505)](g,12),15),224):(m[p++]=e.PcvME(e[s(505)](g,18),7)|240,m[p++]=e[s(1302)](e.wDBjR(g,12)&63,128)),m[p++]=e[s(1854)](e[s(887)](e[s(1775)](g,6),63),128)),m[p++]=e[s(1486)](e[s(1864)](63,g),128))}}function $(a,n){let s=t;if(e[s(399)]===e.Czscv)return this[s(1196)]?this[s(1196)][s(844)+"ns"]:"";{let d=e[s(1651)](te,a,n[s(1829)]),u=a[s(1212)],p=n.bytes;for(let m=0,E=n[s(1829)];e[s(470)](m,E);m++)u[e[s(1372)](m,d)]=p[m]}}function ie(a){let n=t;return a[n(1212)][e[n(463)](Q,a,1)]}function Ve(a,n){let s=t;if(e[s(1321)](e[s(1026)],e[s(1026)])){let d=te(a,1);a.bytes[d]=n}else wZsIRl[s(1688)](_0x24ff5d,_0x55a239[s(1290)]),wZsIRl[s(1165)](_0x3c40b0)}function fe(a){let n=t,s={wjIrE:function(d,u){return e[U(1873)](d,u)},YyeNw:function(d,u){return e[U(1145)](d,u)},MKXRW:function(d,u){return e[U(652)](d,u)},fIiiv:function(d,u){return e[U(1337)](d,u)},usgLK:function(d,u){return e.NzUyA(d,u)},oxfpl:function(d,u){return e.beUac(d,u)}};if(n(1012)===e[n(1357)]){let d=0,u=0,p;do p=e[n(720)](ie,a),e[n(1456)](d,32)&&(u|=e[n(649)](e.Wseas(127,p),d)),d+=7;while(e[n(532)](128,p));return u}else _0x39a2ec=s.wjIrE(_0x4e4022,_0x34226b),_0x3cd338=s[n(931)](127,_0x4888ef),s.MKXRW(128,_0x3264ff)&&(_0x2ad7e2=s[n(392)](_0x2af7a1,_0x439f2e),_0x5afb99|=s[n(1013)](s[n(1041)](127,_0x251acb),7))}function ue(a,n){let s=t;for(n>>>=0;e[s(1823)](n,128);)Ve(a,e.cZkuM(e[s(613)](127,n),128)),n>>>=7;e[s(1553)](Ve,a,n)}function vt(a,n){let s=t,d=0,u=0,p=0,m;if(m=e.gTxhG(ie,a),d=e[s(1155)](127,m),e[s(773)](128,m)&&(m=e[s(443)](ie,a),d|=e[s(542)](127&m,7),128&m))if(e.VtczA(s(1638),s(1830))){if(m=e[s(1509)](ie,a),d|=e[s(550)](e[s(613)](127,m),14),e[s(613)](128,m)&&(m=e[s(443)](ie,a),d|=e.yZfiI(127&m,21),e.SBAZD(128,m)))if(e[s(1349)]!==e[s(1349)]){let E=this[s(1270)+s(556)]?.getCurrentEndpoint();this[s(1816)]("connect "+E+s(1749)),this[s(691)+s(1181)](1001,e[s(1776)],!0)}else m=ie(a),u=e.aUCDk(127,m),e.sryhS(128,m)&&(m=e.xEKLB(ie,a),u|=e[s(550)](e[s(1565)](127,m),7),e[s(403)](128,m)&&(m=ie(a),u|=e[s(1650)](e[s(1375)](127,m),14),e[s(1107)](128,m)&&(m=e[s(1484)](ie,a),u|=e[s(1295)](e.FaaUm(127,m),21),e[s(1275)](128,m)&&(m=e[s(641)](ie,a),p=e[s(1352)](127,m),e.ZsHLR(128,m)&&(m=e.PZkqK(ie,a),p|=e[s(639)](e[s(1790)](127,m),7))))))}else{let E={CmcVs:function(H,L){return e.ENuGe(H,L)},zMMTx:function(H,L){return H>L},RJEnC:function(H,L){return e[s(1873)](H,L)},XdRpv:function(H,L){return e[s(1495)](H,L)},iTBSq:function(H,L){return e.GawHC(H,L)},XkFgc:function(H,L){return e[s(1666)](H,L)}},g=e[s(1803)](_0x5a377e,8192),k=e.bmoPJ(g,1),N=null,z=g;return function(H){let L=s;if(E[L(1652)](H,1)||E[L(462)](H,k))return E[L(382)](_0x3657ef,H);E[L(462)](E[L(557)](z,H),g)&&(N=E[L(1169)](_0x4cf1b9,g),z=0);let F=_0x3e8213[L(461)](N,z,z+=H);return 7&z&&(z=E[L(524)](7,z)+1),F}}return{low:e[s(784)](d,e.yZfiI(u,28)),high:e.ittUr(e[s(1716)](u,4),e.nHnSV(p,24)),unsigned:n}}function ut(a,n){let s=t,d=e[s(1716)](n[s(1071)],0),u=e[s(966)](e.zxhaH(n.low,28)|e[s(1650)](n[s(1023)],4),0),p=n[s(1023)]>>>24,m=p===0?e[s(1403)](0,u)?e[s(1258)](d,16384)?d<128?1:2:e[s(1032)](d,2097152)?3:4:e[s(529)](u,16384)?e.jFwIg(u,128)?5:6:u<2097152?7:8:e.mEuhe(p,128)?9:10,E=e[s(428)](te,a,m),g=a[s(1212)];switch(m){case 10:g[e[s(697)](E,9)]=e[s(1155)](e.gExSK(p,7),1);case 9:g[e[s(823)](E,8)]=m!==9?e[s(1302)](128,p):e[s(912)](127,p);case 8:g[E+7]=e[s(471)](8,m)?e[s(1201)](u,21)|128:e[s(1443)](e[s(1874)](u,21),127);case 7:g[e.gVaSO(E,6)]=e.VkLNh(7,m)?e[s(1201)](u,14)|128:e.unilF(u>>>14,127);case 6:g[E+5]=m!==6?e[s(797)](u,7)|128:e[s(966)](u,7)&127;case 5:g[E+4]=e[s(1770)](5,m)?e[s(780)](128,u):e[s(626)](127,u);case 4:g[E+3]=e.WgytN(4,m)?e.vjxsw(d,21)|128:e.ggPhB(e[s(693)](d,21),127);case 3:g[E+2]=e[s(1105)](3,m)?d>>>14|128:e[s(797)](d,14)&127;case 2:g[E+1]=e[s(1835)](2,m)?e[s(1046)](d>>>7,128):e[s(652)](e[s(1201)](d,7),127);case 1:g[E]=e[s(777)](1,m)?e[s(1007)](128,d):e.dDJCK(127,d)}}function Zt(a){return v(a)}function Bt(a){return e.PZkqK(S,a)}let Xt=65536,qr=e[t(1282)],me=e.BTmln(Xt,Xt),Ae=e[t(674)](me,me),Vn=e.AdzSm(Ae,2),De=String[t(1135)+"e"][t(1534)+"At"];class de{constructor(n,s,d){let u=t;this[u(1644)]=!0,this[u(1071)]=e[u(587)](0,n),this.high=e[u(1751)](0,s),this.unsigned=!!d}static[t(1644)](n){let s=t;return n&&e[s(775)](!0,n[s(1644)])}static fromBits(n,s,d){return new de(n,s,d)}static[t(1389)+"s"](n,s,d){let u=t;return d?de[u(1389)+u(747)](n,s):de[u(1389)+"sBE"](n,s)}static[t(1389)+t(747)](n,s){let d=t;return new de(e[d(965)](e.KhVWj(n[0],n[1]<<8),n[2]<<16)|n[3]<<24,e[d(1302)](e.puOYW(n[4]|n[5]<<8,e.GIPFJ(n[6],16)),e[d(542)](n[7],24)),s)}static[t(1389)+t(1860)](n,s){let d=t;return new de(e.WpJyV(e[d(1818)](e[d(1756)](n[4],24),e[d(1295)](n[5],16)),e[d(1423)](n[6],8))|n[7],e[d(1046)](e[d(1854)](e[d(1046)](e[d(405)](n[0],24),e[d(1148)](n[1],16)),e.MzojM(n[2],8)),n[3]),s)}static[t(1289)](n){let s=t;return e[s(1837)](n,qr)?qd:new de(e[s(389)](e[s(780)](e[s(1230)](e.gwKGl(De.call(n,0),e[s(733)](De.call(n,1),8)),e[s(1063)](De[s(461)](n,2),16)),e[s(1295)](De[s(461)](n,3),24)),0),e[s(949)](e[s(400)](e.ZPUnO(e.ZPUnO(De[s(461)](n,4),e[s(1063)](De[s(461)](n,5),8)),e.NzUyA(De.call(n,6),16)),e[s(871)](De[s(461)](n,7),24)),0),!0)}toHash(){let n=t;return String[n(838)+"Code"](e[n(1498)](255,this[n(1071)]),e[n(1125)](this[n(1071)]>>>8,255),e.zQWpQ(this[n(1071)],16)&255,this.low>>>24,255&this[n(1023)],e[n(1443)](e.ulmpK(this[n(1023)],8),255),e.tLnXR(this[n(1023)],16)&255,e[n(1445)](this[n(1023)],24))}static fromNumber(n,s=!0){let d=t,u={iGJmC:function(p,m,E){return e[U(440)](p,m,E)}};if(e[d(898)](e[d(1325)],e[d(1507)]))return _0xc57398[d(1212)][YWFtNb.iGJmC(_0xba346d,_0x1199e8,1)];if(e.hAFZC(isNaN,n))return s?Xh:qd;if(s){if(n>=Ae)return ep}else{if(e.EOhfA(n,-Vn))return tp;if(e[d(959)](e[d(1754)](n,1),Vn))return Qh}return de[d(865)](e[d(1033)](n,me)|0,e[d(780)](n/me,0),s)}[t(588)](){let n=t;return this[n(1088)]?e.qnESl(e.hRxYb(this.high>>>0,me),this[n(1071)]>>>0):e[n(1182)](e[n(1410)](this.high,me),this[n(1071)]>>>0)}[t(1817)](){let n=t,s={YXYAI:function(d,u,p){return e[U(1159)](d,u,p)},byQpN:e[n(1277)],dStMk:function(d,u){return e[n(1558)](d,u)}};if(e[n(775)](e[n(1511)],e.SClaC)){let d=this["_endpoin"+n(556)]?.["checkRea"+n(1528)+"es"](),u=this[n(1270)+n(556)]?.[n(1710)+"ntEndpoint"]();if(d&&!_0x484138[n(1760)]){let p=n(1622)+u+(" fail, m"+n(882)+"es reached");this["_dispatc"+n(1563)+n(1464)](s[n(598)](_0x50e51b,s[n(1395)],{message:p,code:_0x50791a[n(692)+n(1657)+"R"],error:_0x11223}));return}this._ws&&s[n(1476)](this[n(1196)][n(1654)+"te"],this.OPEN)&&this[n(691)+n(1181)](),this["_dispatchErrorEv"+n(1464)](_0x53c6fd(s[n(1395)],{message:_0x36c2fb[n(1760)],code:_0x3fb926["NATIVE_E"+n(1575)],error:_0xa335aa}))}else return this.high===0&&e[n(757)](0,this[n(1071)])}[t(1471)](n){let s=t;de[s(1644)](n)||(n=de.fromNumber(n));let d=this[s(1023)]>>>16,u=65535&this.high,p=e[s(1166)](this[s(1071)],16),m=e[s(1042)](65535,this[s(1071)]),E=n[s(1023)]>>>16,g=65535&n.high,k=e[s(389)](n[s(1071)],16),N=65535&n.low,z=0,H=0,L=0,F=0;return F+=m+N,L+=e[s(1201)](F,16),F&=65535,L+=p+k,H+=L>>>16,L&=65535,H+=e[s(1791)](u,g),z+=e[s(706)](H,16),H&=65535,z+=e[s(1754)](d,E),z&=65535,de.fromBits(L<<16|F,e[s(1666)](e[s(523)](z,16),H),this[s(1088)])}equals(n){let s=t;return de[s(1644)](n)||(n=de.fromNumber(n)),e[s(1698)](this[s(1088)],n[s(1088)])&&e.KkVuJ(this[s(1023)]>>>31,1)&&e.nZOps(e[s(1506)](n[s(1023)],31),1)?!1:this[s(1023)]===n.high&&e[s(963)](this.low,n[s(1071)])}[t(851)](){let n=t;return e.qUpEf(-1,this[n(1071)])&&e[n(1697)](-1,this[n(1023)])?de.fromBits(0,0,this.unsigned):e[n(757)](-1,this.low)?de.fromBits(0,e[n(1592)](this[n(1023)],1),this[n(1088)]):de.fromBits(e[n(452)](this[n(1071)],1),this[n(1023)],this[n(1088)])}[t(1614)](n){let s=t;return n?this[s(731)+"E"]():this[s(599)+"E"]()}[t(731)+"E"](){let n=t,s={FXgAS:function(d,u,p){return d(u,p)},KTRmT:e[n(1277)]};if(e[n(381)](e[n(907)],e[n(1524)])){let d=s[n(1618)](_0x346478,s[n(564)],{message:_0x1a2ca3[n(1760)],code:_0x21c16f[n(942)+"OR"],error:_0x34a873});this[n(1238)+n(1563)+n(1464)](d)}else{let d=this.high,u=this.low;return[e[n(935)](255,u),e.UyzFF(e[n(1073)](u,8),255),e[n(1742)](e[n(1874)](u,16),255),e.tLnXR(u,24),e[n(764)](255,d),e.lKoGU(e[n(1341)](d,8),255),e.WbnrG(e[n(1341)](d,16),255),e[n(1589)](d,24)]}}[t(599)+"E"](){let n=t,s=this.high,d=this[n(1071)];return[s>>>24,e[n(1498)](e[n(1718)](s,16),255),e.RjQlH(e[n(767)](s,8),255),e[n(1065)](255,s),d>>>24,e[n(539)](e[n(987)](d,16),255),e[n(1473)](d>>>8,255),e.lKoGU(255,d)]}}let qd=new de(0,0,!1),Xh=new de(0,0,!0),Qh=de[t(865)](-1,2147483647,!1),ep=de[t(865)](-1,-1,!0),tp=de[t(865)](0,-2147483648,!1);var Qt=(function(a){let n=t,s=(n(666)+"0|5").split("|"),d=0;for(;;){switch(s[d++]){case"0":a[a[e[n(681)]]=5005]=e[n(681)];continue;case"1":a[a[e[n(1287)]]=5003]=e[n(1287)];continue;case"2":a[a[e[n(955)]]=5002]=e[n(955)];continue;case"3":a[a[n(510)+"RROR"]=5001]=n(510)+n(1575);continue;case"4":a[a[e[n(1183)]]=5004]=n(1093)+n(1293);continue;case"5":return a}break}})({});class Yn{constructor(n){let s=t,d={wbOig:function(u,p){return e[U(1688)](u,p)}};e[s(414)](e.qRiqm,s(1707))?(d[s(756)](_0x37add6,this[s(669)+"gTimeoutId"]),d[s(756)](_0xaee4e4,this[s(1172)+s(1891)+s(646)]),this._pingPongTimeoutId=null,this["_reconnectTimeou"+s(646)]=null):(this[s(840)]=n,this.target=null)}}class Hd extends Yn{constructor(n,s){let d=t;if(e.OvJeh(e.bLKnI,"CiaLy")){if(_0x57b4b6)return new _0x11088a(_0x4ff0c2.url,_0xa70973.protocol);if(e.qodxX(_0x9b3656,_0x7dbc00))return new _0x3c60ce(_0x4bc263.url,_0x3b86bf[d(1585)],_0x26ca40.headers);if(e[d(1803)](_0x358243,_0x376358)&&e.Obeam(d(1077)+"d",typeof _0x12c9c3)&&_0x366426)return new _0x1e3da5(_0x1516de[d(1195)],_0x58bf0a[d(1585)+"s"])}else super(n),this[d(1760)]=s&&s[d(1760)]||null}}class jd extends Yn{constructor(n,s){let d=t,u=e[d(1001)].split("|"),p=0;for(;;){switch(u[p++]){case"0":this.message=s&&s[d(1760)]||"";continue;case"1":this.colno=s&&s.colno||0;continue;case"2":this.lineno=s&&s[d(1810)]||0;continue;case"3":this[d(1400)]=s&&s[d(1400)]||5001;continue;case"4":this[d(1290)]=s&&s[d(1290)]||null;continue;case"5":super(n);continue;case"6":this[d(1496)]=s&&s[d(1496)]||"";continue}break}}}class Wd extends Yn{constructor(n,s){let d=t;super(n),this.code=s&&s.code||0,this[d(1111)]=s&&s.reason||"",this.wasClean=s&&s[d(380)]||!1,this["willReco"+d(438)]=s&&s[d(1693)+"nnect"]||!1}}class Kd extends Yn{constructor(n,s){let d=t;super(n),this.data=s&&s[d(513)]||null}}class $d extends Kd{constructor(n,s){let d=t;super(n),this[d(513)]=s&&s[d(513)]||null,this[d(1760)]=s&&s[d(1760)]||null}}class Vd extends Yn{constructor(n,s){let d=t;super(n),this[d(513)]=s&&s[d(513)]||null}}function ot(a,{message:n,code:s,error:d}){return new jd(a,{message:n,code:s,error:d})}function xt(a,{code:n,reason:s,wasClean:d,willReconnect:u}){return new Wd(a,{code:n,reason:s,wasClean:d,willReconnect:u})}function Yd(a,{data:n,message:s}){return new $d(a,{data:n,message:s})}function Jd(a,{data:n}){return new Vd(a,{data:n})}function da(a,{message:n}){return new Hd(a,{message:n})}class Zd{constructor(n,s){let d=t,u={yxmcu:function(p,m){return e.yDjVP(p,m)},BTvOt:function(p,m){return e[U(468)](p,m)},uodAC:function(p,m){return e[U(1533)](p,m)}};e[d(1218)](e[d(1386)],e[d(1102)])?(_0x2f2a4a=nCGrfE.yxmcu(_0x5d5262,_0x56cf56),_0x2d58a9|=nCGrfE[d(1213)](nCGrfE[d(1726)](127,_0x27e3d5),7)):(this.endpoints=n,this[d(660)+"es"]=s,this[d(864)+d(699)]=0,this[d(533)+d(926)+d(1764)+"t"]=0)}[t(1522)+t(758)+t(1242)](){let n=t;if(e[n(471)](e[n(397)],e[n(1629)]))this[n(864)+n(699)]=0,this[n(533)+n(926)+n(1764)+"t"]=0;else for(var s in _0x37ff32)_0x394917.o(_0x11e693,s)&&!_0x3b6b97.o(_0x29c17e,s)&&_0xf905a9[n(1243)+n(1814)](_0x1df17b,s,{enumerable:!0,get:_0x3f31d3[s]})}resetTries(){let n=t,s={tupvJ:function(d,u){return e[U(487)](d,u)}};if(n(1455)===e.dqOVY){let d=this[n(1259)].getStorageSync(this[n(1022)]),u=_0x1762a2[n(1030)](s[n(410)](d,"{}"));return u[_0x14ad88||_0x4c86a7[this[n(634)]]]=_0x9ed9fa,this._qosDB[n(480)+"geSync"](this[n(1022)],_0x320964[n(1547)+"y"](u)),_0x4500cd||_0x2dcb6f[this[n(634)]]}else this["currentE"+n(926)+"riesCount"]=0}[t(1710)+t(1050)+"nt"](){let n=t;return this[n(793)+"s"][this[n(864)+n(699)]]}[t(1710)+t(1050)+t(901)+"ount"](){let n=t;return this[n(533)+n(926)+n(1764)+"t"]}[t(1186)+t(1528)+"es"](){let n=t,s={ewTOf:function(d){return e.Nxnpa(d)}};if(e.eIriI(e.oOtPT,e[n(1223)]))IhoSLz[n(426)](_0x1a9918),_0x27fc65();else return!!(e[n(1116)](this[n(864)+"ndex"],this[n(793)+"s"][n(614)])||this[n(864)+n(699)]===this[n(793)+"s"][n(614)]-1&&e.rETdm(this["currentE"+n(926)+n(1764)+"t"],this[n(660)+"es"]))}["checkCur"+t(1679)+"ointReac"+t(648)+"tries"](){let n=t;if(e[n(1868)](e[n(1203)],e[n(1203)]))return e[n(451)](this[n(864)+n(699)],this[n(793)+"s"].length)?!0:e[n(1060)](this[n(533)+"ndpointT"+n(1764)+"t"],this.maxRetries);{let{url:s}=e[n(1136)](_0x33d559,{}),d=_0x45bb24.isArray(s)?s:e[n(451)](e[n(1801)],typeof s)?[s]:[];_0x2f75c5&&_0x2ccb62[n(957)](this[n(574)],_0x3ae301),d&&d.length?this[n(1270)+n(556)]=new _0x2e2e94(d,this[n(574)].maxRetries):this[n(1270)+"tManager"]?.["resetEnd"+n(758)+n(1242)](),this[n(1542)+n(420)]?.[n(1034)+n(512)](this[n(574)][n(1782)+n(1449)]),this[n(750)+n(1519)]=!1,this[n(1196)]&&e[n(772)](this._ws[n(1654)+"te"],this[n(992)])?this[n(691)+n(1181)](1e3,e.VSOas,!0):(this[n(1049)]=!0,this._connect())}}[t(1323)+t(611)+"pointAnd"+t(1804)+"unt"](){let n=t;return this[n(533)+n(926)+n(1764)+"t"]=1,this[n(864)+n(699)]++,this[n(793)+"s"][this[n(864)+n(699)]]}["getCurre"+t(1050)+"ntAndUpd"+t(1017)](){let n=t;return this[n(533)+n(926)+n(1764)+"t"]++,this[n(1710)+n(1050)+"nt"]()}}let Jn=(e[t(1780)](e[t(1674)],typeof globalThis)&&e.HgAZm===globalThis[t(1412)+t(1140)].name||e[t(1780)]("undefined",typeof window)&&e.mBDIp(e[t(1255)],window["construc"+t(1140)][t(1327)]))&&e[t(1674)]!=typeof document,An=e[t(1780)](e[t(1674)],typeof globalThis)&&(e.ZmJLu===globalThis[t(1412)+t(1140)][t(1327)]||e[t(417)](t(1294)+"dWorkerGlobalScope",globalThis[t(1412)+"tor"][t(1327)]))&&e.seSbc!=typeof tt,Hr=(e[t(1780)](e[t(1674)],typeof globalThis)&&e[t(898)](t(583),globalThis["construc"+t(1140)].name)||e.NacMJ(e[t(1674)],typeof globalThis)||e[t(1674)]!=typeof globalThis&&!!globalThis[t(1204)+t(979)])&&e[t(1515)](e.seSbc,typeof wx),jr=e.lKhQJ(e.seSbc,typeof globalThis)&&(e[t(1431)](e[t(485)],globalThis[t(1412)+"tor"][t(1327)])||e[t(1460)](e.GDhSc,globalThis[t(1412)+t(1140)][t(1327)])||e[t(517)](e[t(1279)],globalThis[t(1412)+t(1140)][t(1327)]))&&e.LWahg(e.seSbc,typeof self),np=e[t(1674)]!=typeof globalThis&&e[t(1661)]===globalThis[t(1412)+"tor"].name&&e[t(904)](e[t(1674)],typeof global)&&e[t(1460)](t(583),global[t(1412)+"tor"].name)&&t(1077)+"d"!=typeof process&&!!process.version;class la{constructor(){this._listeners={}}[t(714)](n,...s){let d=t,u=this[d(1264)+"rs"][n];if(u)u[d(1610)]().forEach(p=>p.fn[d(1110)](p.ctx,s));else if(e[d(1036)](d(1290),n)&&!this[d(578)])if(e[d(517)](e[d(1393)],e[d(1393)])){let p=s.length&&s[0];if(p instanceof Error)throw p;let m=new Error(e[d(1495)](e[d(644)],p?" ("+p[d(1760)]+")":""));throw m[d(1003)]=p,p}else e[d(463)](_0x5d2c9b,_0x123d79,18),e[d(1103)](_0x54432b,_0x122288,_0x5d3f03);return this}[t(552)](n,s){let d=t;if(e[d(625)](void 0,n))this[d(1264)+"rs"]={};else if(e[d(1745)](void 0,s))this._listeners[n]=null;else{let u=this._listeners[n];if(u)for(let p=0;e[d(1404)](p,u[d(614)]);)e[d(586)](u[p].fn,s)?u[d(1762)](p,1):++p}return this}on(n,s,d){let u=t;return(this[u(1264)+"rs"][n]||(this._listeners[n]=[]))[u(1889)]({fn:s,ctx:d||this}),this}}class rp extends la{[t(1079)+t(1544)+t(1886)](n){let s=t;return n[s(1752)]||n[s(978)]?(s(1582)+" "+(n[s(1752)]||"")+s(815)+(n[s(978)]||"")).trim():JSON[s(1547)+"y"](n)}constructor(n,s,d){let u=t;super(),this._socket=null,Hr&&wx[u(1777)+"ocket"]&&(this[u(1493)]=wx[u(1777)+u(1485)]({url:n,protocols:s,header:d,fail:this[u(849)+"ocketFai"+u(577)][u(744)](this),success:this[u(849)+u(1188)+"cessHand"+u(968)][u(744)](this)})),An&&tt["connectS"+u(1485)]&&(this._socket=tt[u(1777)+u(1485)]({url:n,protocols:s,header:d,fail:this["_createSocketFai"+u(577)][u(744)](this),success:this[u(849)+u(1188)+"cessHand"+u(968)][u(744)](this)}))}[t(849)+t(1188)+"cessHand"+t(968)](){let n=t;Promise[n(1241)]()[n(1332)](()=>{this[n(923)+"steners"]()})}[t(849)+"ocketFai"+t(577)](n){let s=t,d={MmRYj:function(u,p,m){return e[U(1788)](u,p,m)},MypoM:"error",PxOPm:function(u,p,m){return e[U(430)](u,p,m)},OxMwP:e[s(738)]};Promise.resolve()[s(1332)](()=>{let u=s,p=d[u(1766)](ot,d[u(702)],{message:this["_formatE"+u(1544)+u(1886)](n)});this[u(714)](d.MypoM,p);let m=d[u(628)](xt,"close",{reason:this["_formatE"+u(1544)+u(1886)](n)});this.emit(d[u(977)],m)})}["_addWsLi"+t(830)](){let n=t,s={rDLTS:function(d,u){return e[U(1892)](d,u)},Eahyn:function(d,u){return e.xxfLe(d,u)},CrNYw:e[n(1277)]};this._socket.onOpen(d=>{let u=n;this.emit(e.DIXYK,Jd(e.DIXYK,{...d,data:d[u(1752)]||""}))}),this[n(1493)].onClose(d=>{let u=n;this.emit(e[u(738)],xt(e.MFPir,{...d}))}),this[n(1493)][n(1503)+"e"](d=>{let u=n;if(e.obOPC(e[u(1127)],e.AOzrH))this[u(714)](e[u(710)],Yd(u(1760),{...d}));else{if(wQiLKs[u(494)](4,_0xd53629[u(614)])){let p=_0x2f3eee.substring(0,wQiLKs[u(1235)](4,_0x2e7a57.length)),m=p[u(1437)](_0x1fd81d);_0x49acce.push(m)}else _0x8dd642[u(1889)](_0x580190);_0x1d75e2&&(_0x10362f+=1),_0x2e7b92+=1,_0x5d535b=!1}}),this[n(1493)][n(1392)](d=>{let u=n;this[u(714)]("error",ot(s[u(667)],{...d,message:d[u(1752)]||""}))})}[t(1232)](n){let s=t,d={AUNTO:function(u,p){return e[U(1266)](u,p)},rTZfY:function(u,p){return e[U(1626)](u,p)},Eopxp:function(u,p){return u!==p},HcZwf:function(u,p){return e[U(1864)](u,p)},WJcAL:function(u,p){return e[U(784)](u,p)},KMVTO:function(u,p){return e[U(1317)](u,p)},OHbYY:function(u,p){return u|p},uQRDz:function(u,p){return e.ZEATb(u,p)},CjwZw:function(u,p){return e[U(1432)](u,p)},kziZl:function(u,p){return u<<p},yivwT:function(u,p){return u&p},zPqHN:function(u,p){return u&p},NRcQM:function(u,p){return e[U(700)](u,p)},XdtDL:function(u,p){return e.QDmpC(u,p)},tAXah:function(u,p){return e.WBoVW(u,p)},iIMZL:function(u,p){return e[U(1036)](u,p)},SwnCs:e[s(1083)],mbMXE:e.hwdXv};if(e[s(703)](n,Uint8Array)){let u=n[s(1806)][s(1610)](n[s(1451)+"et"],e[s(1791)](n[s(508)+"th"],n.byteOffset));this[s(1493)]&&this[s(1493)][s(1232)]({data:u,fail:p=>{let m=s;this[m(714)](m(1290),e.YIQAh(ot,e[m(1277)],{message:this[m(1079)+"rrorMess"+m(1886)](p)}))}})}else this[s(1493)]&&this[s(1493)].send({data:n,fail:u=>{let p=s;d[p(973)](d[p(1706)],d.SwnCs)?this[p(714)](d[p(1314)],ot(d[p(1314)],{message:this[p(1079)+"rrorMess"+p(1886)](u)})):(_0xaef953=_0x5bc895[ZMfjhm[p(379)](ZMfjhm[p(379)](_0x597ea4,_0x15df0c),1)],_0x553598=_0x33a60c[ZMfjhm[p(1759)](_0x28df30,_0x3b363c)+2],_0x24b7f4=_0x4524b7[ZMfjhm[p(1759)](_0x4e4f6a,_0x50a96d)+3],ZMfjhm.Eopxp(ZMfjhm[p(1717)](ZMfjhm[p(956)](ZMfjhm[p(956)](_0x5d442a,_0x309bc3<<8),ZMfjhm[p(819)](_0x5738bf,16)),12632256),8421504)?_0x1c2bbf+=_0x6a2c7c:(_0x55e1ab=ZMfjhm[p(956)](ZMfjhm[p(972)](ZMfjhm[p(956)](ZMfjhm[p(819)](ZMfjhm[p(1603)](7,_0xa73ae0),18),ZMfjhm.KMVTO(ZMfjhm.CjwZw(63,_0x46413a),12)),ZMfjhm[p(1591)](ZMfjhm[p(1427)](63,_0x1e9cea),6)),ZMfjhm[p(1700)](63,_0x292500)),ZMfjhm[p(763)](_0x56a844,65536)||_0x7cf82c>1114111?_0x449846+=_0x29f58f:(_0xc21555-=65536,_0x466b06+=_0x277227(ZMfjhm[p(1624)](_0x59f6f3>>10,55296),ZMfjhm[p(1418)](1023&_0x2039c0,56320)),_0x16c5fc+=3)))}})}[t(1655)](n,s){this[t(1493)]&&this._socket.close({code:n,reason:s})}[t(888)+t(1477)](n,s){this.on(n,s)}[t(1827)+"entListe"+t(1004)](n,s){this[t(552)](n,s)}get[t(1654)+"te"](){let n=t;return this._socket[n(1654)+"te"]}get[t(1723)+"pe"](){return this._socket.binaryType}set[t(1723)+"pe"](n){}get[t(1195)](){let n=t;return this[n(1493)][n(1195)]}get protocol(){return this._socket.protocol}get[t(844)+"ns"](){let n=t;return this[n(1493)][n(844)+"ns"]}get[t(765)+t(592)](){let n=t,s={XIdxB:e[n(1363)]};return e.UAbQn(e.RqJYe,"XYLXc")?0:(_0x39425f||(_0x1e18c9=_0x41c49f[n(1241)]()[n(1332)](_0x19db38.bind(_0x1cacd6,s.XIdxB))),_0x3239da)}}function ip(a,n){let s=t;if(n)return new n(a.url,a[s(1585)]);if(e.nDWOy(Hr,An))return new rp(a[s(1195)],a[s(1585)],a[s(1429)]);if(e[s(701)](Jn,jr)&&e.Obeam(e[s(1674)],typeof WebSocket)&&WebSocket)return new WebSocket(a[s(1195)],a[s(1585)+"s"])}function sp(a){let n=t;if(e[n(772)](e.DWZqM,"cjGxJ")){let s=e[n(914)][n(1193)]("|"),d=0;for(;;){switch(s[d++]){case"0":if(Hr&&wx["connectS"+n(1485)])return!0;continue;case"1":return!1;case"2":if(An&&tt[n(1777)+n(1485)])return!0;continue;case"3":if(e.JEwqz(Jn,jr)&&e[n(1515)](e[n(1674)],typeof WebSocket)&&WebSocket)return!0;continue;case"4":if(a)return!0;continue}break}}else if(_0x5ad4e9=_0x1bee44[n(1534)+"At"](_0x550ca2),_0x45a443<128)_0x3a9829[_0x2f348d++]=_0x2ad173;else if(_0x1e8273<2048)_0x5e6ba1[_0x864a0++]=e[n(1517)](_0x3a1518>>6,192),_0x53e372[_0x1ca38a++]=e[n(539)](63,_0x288e53)|128;else if((64512&_0x38b053)===55296&&e[n(385)](e[n(707)](64512,_0x4645d6=_0x2c8f8b[n(1534)+"At"](e[n(1158)](_0x358b27,1))),56320)){let s=e[n(615)][n(1193)]("|"),d=0;for(;;){switch(s[d++]){case"0":_0x112876[_0x5ea576++]=e.ZMaNp(_0x369ae1,18)|240;continue;case"1":++_0x9ce67;continue;case"2":_0xdd6901[_0x4e9813++]=e.WthrA(e[n(1775)](_0x4157ed,12)&63,128);continue;case"3":_0x50e5bc[_0x531e31++]=e[n(1854)](e[n(376)](63,_0x3cb488),128);continue;case"4":_0x523a0e=e[n(442)](e[n(1153)](65536,e.dfoym(1023,_0x33c1e9)<<10),1023&_0x365951);continue;case"5":_0x28e3c2[_0xc9cec3++]=e[n(1715)](e[n(1312)](_0x472edf>>6,63),128);continue}break}}else _0x3a40f3[_0x5aac01++]=_0x2942c1>>12|224,_0x1b541b[_0x188237++]=e[n(1890)](e[n(1441)](e.MmLPe(_0x483cf6,6),63),128),_0x9ade4f[_0x18666b++]=e[n(831)](63&_0xe0f268,128)}function Xd(a,n,s){let d=t,u={FhHBR:function(E,g){return e.EOhfA(E,g)},YhfOR:d(526)+d(1743)+d(449)+"imes in "+d(640),EYRxc:function(E,g){return e[d(1321)](E,g)}},p=-1;async function m(E){let g=d;return u[g(1373)](E,p)?Promise[g(1160)](new Error(u.YhfOR)):(p=E,u[g(1467)](E,s[g(614)])?Promise.resolve():s[E][g(744)](a)(n,m[g(744)](null,E+1)))}m(0)}function Qd(a){let n=t,s={Jpzfp:function(d,u){return e[U(1019)](d,u)},PoLbU:function(d,u){return e[U(839)](d,u)},bBhgR:function(d,u,p){return e[U(711)](d,u,p)}};if(e[n(1835)](n(543),n(543)))return jpuVxC.Jpzfp(jpuVxC[n(1525)](_0x5a5f67,4).join("0"),jpuVxC[n(1457)](_0x3d62e0,_0x4a6cd4,2).toString(16))[n(1610)](-4);{let d=0,u=0;for(let p=0;e[n(1456)](p,a[n(614)]);++p)u=a[n(1534)+"At"](p),e.JwiPR(u,128)?d+=1:u<2048?d+=2:e[n(1047)](e[n(961)](64512,u),55296)&&e[n(532)](64512,a.charCodeAt(e[n(1595)](p,1)))===56320?(++p,d+=4):d+=3;return d}}function el(a,n,s){let d=t;if(e[d(932)](e[d(569)](s,n),1))return"";let u="";for(let p=n;e[d(1091)](p,s);){let m=a[p++];if(e.YhNhq(m,127))u+=String["fromChar"+d(812)](m);else if(e[d(450)](m,192)&&e[d(562)](m,224))u+=String[d(838)+d(812)](e[d(606)](e.PNzcg(31,m),6)|e[d(589)](63,a[p++]));else if(e[d(951)](m,224)&&e.GpfET(m,240))u+=String["fromChar"+d(812)](e[d(1715)](e[d(965)](e[d(1058)](15,m)<<12,e[d(1063)](e[d(613)](63,a[p++]),6)),e[d(887)](63,a[p++])));else if(e.wHURc(m,240)){let E=e[d(1307)](e[d(1486)](e[d(1365)](e[d(477)](e[d(909)](e.jFeOs(7,m),18),(63&a[p++])<<12),e[d(639)](e.fLGBp(63,a[p++]),6)),e[d(376)](63,a[p++])),65536);u+=String["fromChar"+d(812)](e.lhrMx(55296,E>>10)),u+=String["fromChar"+d(812)](56320+(1023&E))}}return u}function fa(a,n,s){let d=t,u={fJHkA:function(p,m){return e[U(1835)](p,m)},iJqRB:e[d(1081)],zBuEd:d(1609)};if(e.eBgJn!==d(1704)){let p=s,m,E;for(let g=0;g<a[d(614)];++g)m=a[d(1534)+"At"](g),m<128?n[s++]=m:e[d(737)](m,2048)?(n[s++]=e[d(782)](m,6)|192,n[s++]=e[d(1007)](e[d(1648)](63,m),128)):e[d(509)](64512,m)===55296&&e[d(898)](64512&(E=a[d(1534)+"At"](e[d(1501)](g,1))),56320)?(m=e[d(1200)](65536,e.IrDcX(1023&m,10))+e.KWVpT(1023,E),++g,n[s++]=e[d(1833)](e[d(903)](m,18),240),n[s++]=e[d(400)](e.WbnrG(e[d(505)](m,12),63),128),n[s++]=e.DZxsc(e[d(1441)](e.rKjSa(m,6),63),128),n[s++]=e[d(1890)](e.BsOxa(63,m),128)):(n[s++]=e.sOXEJ(m>>12,224),n[s++]=e.YIOGD(e[d(1775)](m,6),63)|128,n[s++]=e[d(990)](e[d(837)](63,m),128));return s-p}else _0x2e5e49[d(1569)+"d"]&&(this[d(1126)+d(1474)]()&&(!this[d(1196)]||this[d(1196)][d(1654)+"te"]!==this[d(1305)]||u.fJHkA(this._ws[d(1654)+"te"],this[d(1245)+"NG"]))&&this["_handleO"+d(654)](),this[d(807)+"er"]&&_0x5efdb6[d(888)+d(1477)](u[d(1812)],this["_handleO"+d(654)]),this[d(807)+"er"]&&_0x15c9ef[d(888)+d(1477)](u[d(836)],this[d(390)+d(848)]))}async function tl(a){let n=t;if(e[n(1801)]==typeof a){let s=new Uint8Array(Qd(a));return e.pLGPf(fa,a,s,0),s}return e[n(703)](a,ArrayBuffer)?new Uint8Array(a):new Uint8Array(a[n(1806)],a[n(1451)+"et"],a.byteLength)}function op(a){let n=t;try{return e[n(1515)](e.VKXlI,typeof a)&&(e.rGXzB(a,ArrayBuffer)||a[n(1806)]&&e[n(703)](a[n(1806)],ArrayBuffer))||e.VKXlI!=typeof a?"":(JSON[n(1030)](a),e.DBDPv)}catch{return n(1028)==typeof a?e[n(867)]:""}}let ap=(a,n)=>{let s=t;switch(a){case"boe":case e.klRlM:return{[s(1115)+a]:1,"x-tt-env":n};default:return{}}};class cp{constructor(n){let s=t;this[s(792)+"ount"]=n,this[s(425)]=0}[t(843)](){let n=t;this[n(425)]++}["checkRea"+t(396)+"nt"](){let n=t;return e.aavyu(e[n(1210)],n(1499))?"frontier_"+this._DBName:e.qrjFc(this[n(425)],this[n(792)+n(627)])}["resetCou"+t(512)](n=0){let s=t;this[s(792)+"ount"]=n,this[s(425)]=0}}async function dp(a){let n=t,s={KAKfL:function(d,u){return e[U(1566)](d,u)},XgaeH:e[n(1797)],WuEIL:function(d,u,p){return d(u,p)},uhhBa:function(d,u,p){return e[n(791)](d,u,p)},bfkqY:function(d,u){return e[n(387)](d,u)},oarpU:e.dOSaE,liQHy:n(1577),oyqKZ:e[n(408)],NTKfO:e.bxvDK,KVBRi:e[n(760)],zYLjP:function(d,u){return e[n(1840)](d,u)}};return new Promise(d=>{let u=n,p={lvXTC:function(m,E,g){return s[U(1276)](m,E,g)},EcNOy:function(m,E,g){return s[U(661)](m,E,g)}};if(s[u(1221)](u(444),s[u(1236)])){if(!Jn)return s.KAKfL(d,s.XgaeH);try{let m=document["createEl"+u(1719)](s[u(853)]);window[u(1381)+u(1843)]=E=>{let g=u;document[g(1881)][g(1529)+"ild"](m),window[g(1381)+g(1843)]=void 0,s[g(1802)](d,E&&E[g(1535)]||s.XgaeH)},m[u(840)]=s[u(1274)],m[u(705)]=a.replace(/^ws/,s.NTKfO)+s.KVBRi;try{document[u(1881)]["appendCh"+u(617)](m)}catch{document[u(1881)][u(1529)+u(617)](m)}}catch{window[u(1381)+u(1843)]=void 0,s[u(983)](d,s[u(1211)])}}else gIwURW[u(501)](_0x22630c,_0x5bfc4f,74),gIwURW.EcNOy(_0x541221,_0x42efea,_0x541b09)})}function en(a,n,s){let d=t;return e[d(1768)](e.yIJwB,e[d(804)])?!!a?.find(u=>u[d(623)]===n&&u[d(1884)]===s):(this[d(533)+"ndpointT"+d(1764)+"t"]=1,this["currentI"+d(699)]++,this[d(793)+"s"][this["currentI"+d(699)]])}function Zn(a,n){let s=t;return a?.[s(1297)](d=>d[s(623)]===n)?.[s(1884)]}let ua=null;async function lp(){return ua||(ua=Promise[t(1241)]().then(Nt.bind(Nt,e.SiEbl))),ua}class fp extends la{constructor(n,s){let d=t;super(),this[d(717)]=n,this[d(813)]=s,this[d(1259)]=void 0,this[d(642)+d(1869)]=null}async openDB(){let n=t,s={VXjlU:function(d,u){return e.YhNhq(d,u)},xOTir:e[n(621)],YVlBK:function(d,u){return e[n(1394)](d,u)},UOTcy:function(d,u){return e.lhrMx(d,u)}};if(e[n(1697)](e[n(1686)],e[n(1686)]))await this[n(605)]();else return yfsYRu.VXjlU(_0x4d91d4,_0x484ca0)?_0x1a8ec8[n(1160)](new _0xb2438d(yfsYRu[n(1621)])):(_0x130797=_0x27613e,yfsYRu[n(991)](_0x5104c1,_0x5b954d[n(614)])?_0x305489[n(1241)]():_0x4765e5[_0x3b489f][n(744)](_0x1de131)(_0x5a061f,_0x39df39[n(744)](null,yfsYRu[n(850)](_0x336b8b,1))))}async[t(605)](){let n=t,s={IhMSl:function(d,u){return e.VNEWD(d,u)},PCZnB:n(944),gRIcp:function(d,u){return d(u)},OZfdm:e[n(541)],MCOfq:n(911)+n(1735)+"s",clmBe:e[n(1057)],oJYlx:function(d,u){return e[n(1021)](d,u)},dDFLa:function(d,u,p){return e[n(629)](d,u,p)}};if(e.obOPC(e.GMRtB,e[n(372)])){if(this[n(1259)])return;if(this[n(642)+n(1869)])return this[n(642)+n(1869)];try{let d=this[n(717)],u=this[n(813)];this[n(642)+n(1869)]=(async()=>{let p=n,{openDB:m}=await e.skHqH(lp);this._qosDB=await m(p(1381)+"_"+d,1,{upgrade(E){let g=p;if(s[g(671)](g(944),s.PCZnB))E[g(643)+g(1832)+"e"](d,{keyPath:u});else{let{type:k}=_0x845cea;this[g(714)](k,_0x268f1a)}}})})(),await this[n(642)+n(1869)]}catch(d){e[n(387)](e[n(1446)],e[n(1446)])?this[n(642)+n(1869)]=null:console[n(1740)](d)}finally{this["_initPro"+n(1869)]=null}}else{let d={zLaNp:function(m,E){return s.oJYlx(m,E)},qMhrg:n(945),npFRv:s[n(1732)],iSFQK:s[n(1734)]};this[n(806)+n(940)](),this[n(669)+n(472)+"Id"]=s[n(500)](_0x283b08,this[n(1636)][n(744)](this),this[n(574)][n(993)+n(1092)]);let u=()=>{let m=n;d[m(822)](_0x258279,d[m(434)]),this[m(552)](d[m(814)],u),this.off(d[m(1444)],p)},p=()=>{let m=n;s[m(1786)](_0x67cbf3,s[m(609)]),this[m(552)](s[m(1732)],u),this[m(552)](s[m(1734)],p)};this.on(s.MCOfq,u),this.on("ping_onc"+n(1462)+"t",p),this._ping()}}async get(n){let s=t;try{if(e[s(1465)]===e.fVaKr){let d=_0x5c1da1[s(1760)][s(1828)];d&&_0x560181.setCursors(d)}else return await this._init(),this[s(1259)]?.[s(1309)](this._dbName,n)}catch(d){console[s(1740)](d)}}async[t(1705)](n,s){let d=t;return await this[d(605)](),this[d(1259)]?.put(this[d(717)],n)}async[t(771)](n){let s=t;try{return await this._init(),this._qosDB?.[s(1646)](this[s(717)],n)}catch(d){console[s(1740)](d)}}async[t(421)](){let n=t,s={ULHyd:e[n(1226)],hLgpS:e.hwdXv,GyGRW:n(1382),pMojm:function(d){return e[n(637)](d)},CjiYK:function(d,u){return e.LNtvX(d,u)},QJZol:n(943)+"or",pGigv:function(d){return e[n(1165)](d)}};try{return await this._init(),this[n(1259)]?.[n(421)](this._dbName)}catch(d){if(e[n(1403)](e[n(1358)],e[n(458)])){let u=()=>{let E=n;_0x390f1e["removeEv"+E(457)+E(1004)](dQxxJQ[E(1114)],p),_0x59087c[E(1827)+"entListe"+E(1004)](dQxxJQ.hLgpS,m),_0x2f1803[E(1827)+E(457)+"ner"](dQxxJQ[E(964)],m)},p=()=>{_0x15c6e1(),dQxxJQ.pMojm(u)},m=()=>{let E=n;dQxxJQ[E(1343)](_0x26bed9,_0x2bf9e9[E(1290)]||new _0x1ef303(dQxxJQ[E(696)],dQxxJQ.QJZol)),dQxxJQ[E(650)](u)};_0x4018f5["addEvent"+n(1477)](n(631),p),_0xe9f975[n(888)+n(1477)](n(1290),m),_0x1bb93a["addEvent"+n(1477)](n(1382),m)}else console.log(d)}}async[t(1809)](){let n=t;return await this[n(605)](),this[n(1259)]?.[n(465)+"ys"](this[n(717)])}async[t(1089)](){let n=t;if(e[n(1020)](e[n(1709)],n(1039)))return await this[n(605)](),this[n(1259)]?.[n(1089)](this[n(717)]);{let s=_0x4c7f7f[n(614)]&&_0x2fdd0f[0];if(e[n(703)](s,_0x564a11))throw s;let d=new _0x1d3088(e[n(1761)](e[n(644)],s?e[n(1746)](e.mBlKJ(" (",s[n(1760)]),")"):""));throw d.context=s,s}}async closeDB(){let n=t;try{if(e[n(1696)]!==e[n(1696)])return _0x49349d||(_0x50ce97=[_0x8769b,_0x5baf70,_0x3b1911,_0x1bdc4f,_0x16eebd]);this[n(1259)]?.[n(1655)](),this[n(1259)]=void 0}catch(s){console.log(s)}}get[t(718)](){let n=t;try{return!!this[n(1259)]}catch(s){return console[n(1740)](s),!1}}}class up{constructor(n,s){let d=t;this[d(821)]=n,this[d(634)]=s,this[d(1259)]=localStorage}async openDB(){}get[t(1022)](){let n=t;return n(1381)+"_"+this[n(821)]}async get(n){let s=t,d=this[s(1259)].getItem(this[s(1022)]);return JSON[s(1030)](d||"{}")[n]}async set(n,s){let d=t,u=this[d(1259)][d(1016)](this[d(1022)]),p=JSON.parse(u||"{}");return p[s||n[this[d(634)]]]=n,this[d(1259)][d(1579)](this[d(1022)],JSON.stringify(p)),s||n[this._pathKey]}async[t(771)](n){let s=t,d={vMeni:function(u,p){return e[U(1021)](u,p)},ICYpq:e[s(1797)],WjHtv:e[s(1006)],ZWMAc:s(423)+s(394),GkDTS:function(u,p){return u+p},zKwjK:e[s(1747)],RzebD:e.aXFyd};if(e.abXOs(e.GZYwX,e[s(1643)])){let u=this[s(1259)][s(1016)](this._prefix),p=JSON.parse(u||"{}");return p[n]=void 0,this[s(1259)][s(1579)](this[s(1022)],JSON[s(1547)+"y"](p))}else{let u=_0xa5c877[s(860)+s(1719)](oNfrrG[s(427)]);_0x4ac798[s(1381)+"JSONP"]=p=>{let m=s;_0x4ef266[m(1881)]["removeCh"+m(617)](u),_0x56bdc4[m(1381)+m(1843)]=void 0,oNfrrG.vMeni(_0x88f085,p&&p.msg||oNfrrG.ICYpq)},u[s(840)]=oNfrrG[s(1459)],u[s(705)]=oNfrrG[s(1380)](_0x4e5307[s(459)](/^ws/,oNfrrG.zKwjK),oNfrrG[s(1167)]);try{_0x19f031[s(1881)][s(1701)+s(617)](u)}catch{_0x462142[s(1881)][s(1529)+s(617)](u)}}}async clear(){let n=t;return this[n(1259)][n(421)]()}async[t(1809)](){let n=t,s=this._qosDB[n(1016)](this._prefix),d=JSON[n(1030)](e.JEwqz(s,"{}"));return Object[n(1809)](d)}async[t(1089)](){let n=t,s=this[n(1259)][n(1016)](this[n(1022)]),d=JSON[n(1030)](e[n(1094)](s,"{}"));return Object[n(630)](d)}closeDB(){return Promise.resolve()}get[t(718)](){return!!this[t(1259)]}}class xp{constructor(n,s){let d=t;this[d(821)]=n,this._pathKey=s,this[d(1259)]=An?tt:Hr?wx:null}async[t(866)](){}get[t(1022)](){let n=t,s={HSURV:function(d,u,p){return e[U(1027)](d,u,p)},sPmHT:function(d,u){return e[U(1192)](d,u)}};if(e[n(453)]!==e[n(768)])return"frontier_"+this._DBName;nEfbNZ[n(825)](_0xe7eaa4,_0x56cb02,96),nEfbNZ.HSURV(_0x35a841,_0x3fd633,nEfbNZ.sPmHT(_0x5f4055,_0x54f986))}async[t(1309)](n){let s=t,d=this[s(1259)]["getStora"+s(1360)](this[s(1022)]);return JSON.parse(e[s(701)](d,"{}"))[n]}async[t(1705)](n,s){let d=t,u=this[d(1259)].getStorageSync(this[d(1022)]),p=JSON.parse(e[d(1543)](u,"{}"));return p[s||n[this._pathKey]]=n,this._qosDB[d(480)+"geSync"](this[d(1022)],JSON.stringify(p)),s||n[this[d(634)]]}async[t(771)](n){let s=t,d=this[s(1259)].getStorageSync(this[s(1022)]),u=JSON[s(1030)](e.Alqkr(d,"{}"));return u[n]=void 0,this._qosDB[s(480)+s(1360)](this[s(1022)],JSON[s(1547)+"y"](u))}async[t(421)](){let n=t;return this[n(1259)]["clearSto"+n(975)]()}async[t(1809)](){let n=t,s={EdDZQ:function(d,u,p){return e.DiIDL(d,u,p)}};if(e[n(1837)](e[n(448)],e.HLXSg)){let d=this._qosDB[n(518)+n(563)+"nc"](this[n(1022)]),u=JSON[n(1030)](e[n(1061)](d,"{}"));return Object[n(1809)](u)}else s[n(735)](_0xaf388,_0x59121e,this[n(783)+"rvalValue"](_0x255cb8))}async getAll(){let n=t,s=this[n(1259)][n(518)+n(563)+"nc"](this[n(1022)]),d=JSON.parse(e.tdLcB(s,"{}"));return Object.values(d)}[t(1552)](){return Promise.resolve()}get[t(718)](){return!!this[t(1259)]}}function nl(a,n){let s=t;if(e[s(1721)](An,An))return new xp(a,n);if(e[s(1625)](Jn,jr)&&e.Obeam(e[s(1674)],typeof indexedDB))return new fp(a,n);if(e[s(1502)](Jn,jr)&&e[s(1674)]!=typeof localStorage)return new up(a,n);throw new Error(e[s(568)])}class hp{constructor(){let n=t;this[n(1086)+n(1416)+"Id"]=null,this._interval=36e5,this[n(1259)]=e[n(1250)](nl,n(1374),e.vNdTn)}async[t(1086)+t(1082)](){let n=t;e.IfOyv(clearInterval,this[n(1086)+"lTimeoutId"]),this[n(1086)+n(1416)+"Id"]=e[n(1214)](setInterval,()=>{let s=n;this[s(1645)+s(585)]()},this[n(1086)+"l"])}async[t(866)](){let n=t;await this[n(1259)][n(866)]()[n(1332)](()=>{this["_interva"+n(1082)]()})}async[t(1645)+t(585)](){let n=t;e[n(1029)](n(1598),e[n(1793)])?(await this._qosDB?.[n(1089)]()||[])[n(653)](({timestamp:u})=>u<Date[n(895)]()).forEach(u=>{let p=n;this[p(1259)]?.[p(771)](u[p(1691)+"id"])}):(this[n(1049)]=!1,e[n(1822)](_0x33a32f,this[n(1075)+n(1826)+n(1599)]),e.GyyRW(_0x11a96a))}async[t(771)](n){let s=t;return this._qosDB?.[s(771)](n)}async[t(1705)](n,s){let d=t;if(e[d(715)]===d(934))return this._qosDB?.[d(1705)]({message_id:n,timestamp:s});{let u=e[d(918)](e[d(1408)](e[d(831)](e[d(1173)]((7&_0x5c1798)<<18,e.XqtGU(63,_0x5a0b81[_0x399781++])<<12),e[d(1148)](63&_0x4ec611[_0xa88f60++],6)),63&_0x26a56f[_0x3d93bb++]),65536);_0x3e8a7a+=_0x3880f0[d(838)+d(812)](e.YavIP(55296,e[d(1062)](u,10))),_0xdbcd7+=_0x552aca["fromChar"+d(812)](e[d(1182)](56320,e.ENGca(1023,u)))}}async[t(1309)](n){let s=t;return this[s(1259)]?.[s(1309)](n)}async closeDB(){let n=t;clearInterval(this[n(1086)+n(1416)+"Id"]),await this[n(1259)]?.[n(1552)]()}get[t(718)](){let n=t;return this[n(1259)]?.[n(718)]}}function xa(a){let n=t,s=!!this[n(574)][n(1602)+"S"];if(!s)return{enabled:s,isQoSMessage:!1,isQoSAck:!1,isAckCleanupMessage:!1,ackMsgIds:[]};let d=e[n(1741)](en,a.message[n(1429)],e[n(1469)],"2"),u=d&&en(a[n(1760)][n(1429)],e[n(1144)],"1"),p=d&&e[n(755)](en,a.message.headers,e.NupEv,"1"),m=p?Zn(a[n(1760)][n(1429)],e.LFtIx)?.[n(1193)](",").filter(Boolean)||[]:[];return{enabled:s,isQoSMessage:d,isQoSAck:u,isAckCleanupMessage:p,ackMsgIds:m}}async function rl(){let a=t;return this["_QoSMana"+a(894)]||(this[a(856)+a(894)]=new hp),this[a(856)+"ger"][a(718)]||await this[a(856)+"ger"][a(866)](),this[a(856)+a(894)]}async function pp(a,n){let s=t,d={nSRwl:function(g,k){return g(k)}},{enableAutoAck:u}=this[s(574)],p=e[s(1656)](en,a[s(1760)].headers,"need_ack","1"),m=e[s(525)](en,a[s(1760)][s(1429)],e[s(1858)],"1"),E=xa[s(461)](this,a);if(u&&p)if(e.IRYOC(e[s(454)],e[s(1398)]))_0x47c533+=WipwvE[s(1015)](_0x5da921,_0x1f3d72),_0x19f88a+=2;else{let{SeqID:g,LogID:k,service:N,LogIDNew:z,method:H}=a[s(1760)];this._sendAck({SeqID:g,LogID:k,LogIDNew:z,service:N,method:H,headers:[{key:e[s(1858)],value:"1"},{key:e[s(1772)],value:z||""},{key:e[s(1567)],value:"0"}]})}m&&!E[s(1154)]&&this._dispatchAckMessageEvent(a),e[s(1413)](n)}async function gp(a,n){let s=t;this._debug(e.zzWtH,a[s(1760)]),n()}async function mp(a,n){let s=t,d=e[s(1344)](Zt,await e[s(1254)](tl,a.data));try{if(e[s(682)](d[s(1828)],Uint8Array)){let u=e[s(703)](this[s(574)][s(1882)+s(1521)],Object)?{force:!!this[s(574)][s(1882)+s(1521)].force,encoding:this[s(574)][s(1882)+s(1521)][s(1781)]?this[s(574)][s(1882)+"ncoding"][s(1781)].replace(/\s/g,"")[s(1848)+"ase"]():""}:{force:!1,encoding:this._options[s(1882)+"ncoding"]?this._options[s(1882)+s(1521)].replace(/\s/g,"")[s(1848)+"ase"]():""},p=d[s(1882)+"ncoding"]?d["payloadE"+s(1521)][s(459)](/\s/g,"")[s(1848)+s(407)]():"",m=this._options[s(802)+s(1536)]instanceof Object?{force:!!this[s(574)].payloadType[s(761)],type:this[s(574)]["payloadT"+s(1536)][s(840)]?this[s(574)][s(802)+"ype"][s(840)].replace(/\s/g,"")[s(1848)+"ase"]():""}:{force:!1,type:this[s(574)]["payloadT"+s(1536)]?this[s(574)][s(802)+s(1536)][s(459)](/\s/g,"")[s(1848)+s(407)]():""},E=d[s(802)+s(1536)]?d[s(802)+s(1536)][s(459)](/\s/g,"")[s(1848)+"ase"]():"",g=m.force?m[s(840)]:E||m[s(840)],k=u[s(761)]?u[s(1781)]:p||u.encoding,N=[e[s(867)],e.DBDPv,e.tKlRj,e[s(1801)]],z=[e[s(1286)],e.qfORZ];this[s(574)][s(469)+s(1537)+s(1322)+"ad"]&&N.includes(g)&&(!k||z[s(658)](k))?d[s(889)+s(1208)]=e[s(755)](el,d.payload,0,d[s(1828)][s(508)+"th"]):d["textPayl"+s(1208)]=""}else d[s(889)+s(1208)]=""}catch(u){d[s(889)+s(1208)]="",console.log(u)}a[s(1760)]=d,e[s(774)](n)}function wp(a,n,s){let d=t;if(e[d(1306)]!=="aYNcc"){let u=e.nDWOy(s,8192),p=u>>>1,m=null,E=u;return function(g){let k=d;if(g<1||e[k(1787)](g,p))return e[k(446)](a,g);e[k(1787)](e[k(1626)](E,g),u)&&(m=e.xmaje(a,u),E=0);let N=n[k(461)](m,E,E+=g);return e[k(810)](7,E)&&(E=e[k(1124)](e[k(477)](7,E),1)),N}}else{let u=_0x338375[d(727)+"g"](0,4-_0xb7f837[d(614)]),p=u.concat(_0x311454);_0x1bbea3[d(1889)](p)}}let _p=4294967295;function yp(a,n,s){let d=t;return e[d(1378)](RangeError,e[d(567)](e[d(1875)](e.CdCoz(e[d(473)](e.BXUrN,a),d(933))+e.tdLcB(n,1),d(905)),s))}function bp(a,n,s){let d=t,u={RSrdR:function(p,m){return p>m},bZEKz:e[d(1268)]};if(e.OqQnT(e.mSFSi,e[d(1795)])){if(e[d(1060)](s,_p))throw new Error("integer "+d(1755)+"e");let p=3;for(;p>=0;)if(e[d(1876)](e.ykRba,e[d(1813)])){let m=e[d(1002)](255,s);e[d(755)](pa,m,a,e[d(442)](n,p)),s>>>=8,p--}else return _0x4db209[d(1740)](_0x3e81ff),!1;return e[d(1072)](n,4)}else{if(xNaruv.RSrdR(_0x514fbd[d(781)]+_0x1292e6,_0x2a9a47.limit))throw new _0x4ae5e1(xNaruv[d(466)]);_0x3acf56[d(781)]+=_0x11b817}}function Ep(a,n){let s=t,d=0,u=n,p=e.deyCY(n,4);for(;u<p;){let{value:m,offset:E}=e[s(440)](ha,a,u);u=E,d=e[s(797)](e[s(1397)](d,8),0),d+=m}return{value:d,offset:p}}function vp(a,n,s){let d=t;if(d(924)!==e[d(662)]){let u=(d(1689)+"3")[d(1193)]("|"),p=0;for(;;){switch(u[p++]){case"0":if(n[d(1587)+"e"])return e[d(1595)](n[d(1587)+"e"](a,s),s);continue;case"1":if(n[d(1611)])return e[d(1153)](n[d(1611)](a,s),s);continue;case"2":if(e[d(664)](a[d(614)],40))return fa(a,n,s)+s;continue;case"3":return e.KojAK(e[d(422)](fa,a,n,s),s);case"4":if(!a)return s;continue}break}}else{if(!this[d(1196)])return;this[d(1359)+d(1500)+"t"](_0x5c32ec,_0x48f99f,_0x532cad)}}function Sp(a,n){let s=t,d=new de(e[s(835)](e.KVXfy(a[n+4],24),e[s(1162)](a[n+5],16))|e[s(542)](a[n+6],8)|a[n+7],e[s(1715)](e[s(960)](a[n+0]<<24,e[s(1162)](a[e.FRntQ(n,1)],16))|e[s(433)](a[e[s(1178)](n,2)],8),a[e.BRWWB(n,3)]),!0);return n+=8,{value:d,offset:e[s(1878)](n,8)}}function Ap(a,n,s){let d=t,u=a[d(1071)],p=a[d(1023)];return n[s]=e[d(817)](p,24),n[e[d(1590)](s,1)]=e[d(1647)](e[d(1589)](p,16),255),n[e.WJwIF(s,2)]=e[d(1355)](p>>>8,255),n[s+3]=e.CISPC(255,p),n[e.iGnZa(s,4)]=e[d(492)](u,24),n[e[d(1592)](s,5)]=u>>>16&255,n[e[d(473)](s,6)]=e[d(539)](e[d(966)](u,8),255),n[s+7]=e[d(1572)](255,u),s+=8,s}function ha(a,n){let s=t;return a[s(1336)+"8"]?{value:a[s(1336)+"8"](n),offset:n+1}:{value:255&a[n],offset:e[s(916)](n,1)}}function pa(a,n,s){let d=t,u={zNWSe:e[d(1277)],ZmBvn:function(p,m,E){return e[d(1214)](p,m,E)}};if(e[d(471)](e[d(441)],e.YFgSV))return n[d(1117)+"t8"]?n.writeUint8(a,s):n[s]=e[d(565)](255,a),e[d(1595)](s,1);this[d(714)](VOJWmk.zNWSe,VOJWmk[d(740)](_0x195dfa,VOJWmk.zNWSe,{message:this[d(1079)+d(1544)+d(1886)](_0xb68291)}))}let Ip=function(a){return new Uint8Array(a)},Tp=e[t(506)](e[t(1674)],typeof Buffer)?Buffer[t(1513)+"afe"]:e.FKXUp(wp,Ip,Uint8Array[t(1135)+"e"].subarray);(()=>{let a=t,n={MVsrQ:function(d,u){return d<=u},lOlIs:function(d,u){return d<u},iKYIG:function(d,u){return e[U(1307)](d,u)},hGOqz:function(d,u){return e[U(1106)](d,u)},tkAmk:function(d,u){return d&u},mQOyR:function(d,u){return e[U(1303)](d,u)},BlSft:function(d,u){return e[U(831)](d,u)},qlGiy:function(d,u){return e[U(903)](d,u)},RhRov:function(d,u){return d>>u},lnmmp:function(d,u){return e[U(1440)](d,u)},OjIko:function(d,u){return e.UhmKM(d,u)},WiPoq:function(d,u){return e[U(1302)](d,u)},txyPd:function(d,u){return d&u},jUtda:function(d,u){return e[U(571)](d,u)},EyjPc:function(d,u){return e[U(1432)](d,u)},hwmrm:function(d,u){return e[U(587)](d,u)},XHenk:function(d,u){return e[U(492)](d,u)},Hzhfh:function(d,u){return d|u},aSFEj:function(d,u){return e[U(620)](d,u)},XJUYs:function(d,u){return e[U(1517)](d,u)},pnAHk:function(d,u){return e[U(693)](d,u)},rmtxi:function(d,u){return d<u},CTnfz:function(d,u){return e[U(1517)](d,u)},zGiOs:function(d,u){return e[U(670)](d,u)},XBBLT:function(d,u){return e[U(1859)](d,u)},IFYug:function(d,u){return d|u},ACjlT:function(d,u){return d<<u},LifHg:function(d,u){return e[U(1163)](d,u)},mQjHa:function(d,u){return e[U(1060)](d,u)},XWZuu:function(d,u){return d===u},kyJTX:a(1799),mOhzS:function(d,u){return e[a(624)](d,u)}},s=4294967295;return function(d,u,p=!0){let m=a;if(s=n.EyjPc(127,d[u])>>>0,n[m(1315)](d[u++],128))return{value:p?s:n[m(1422)](0,s),offset:u};if(s=n[m(1425)](n.Hzhfh(s,n[m(1405)](n[m(1411)](127,d[u]),7)),0),d[u++]<128)return{value:p?s:n[m(1480)](0,s),offset:u};if(s=n[m(1798)](n.lnmmp(s,(127&d[u])<<14),0),n.rmtxi(d[u++],128))return{value:p?s:n.CTnfz(0,s),offset:u};if(s=n[m(1425)](n[m(1422)](s,n[m(1370)](127,d[u])<<21),0),n.hGOqz(d[u++],128))return{value:p?s:n[m(530)](0,s),offset:u};if(s=n[m(1425)](n.IFYug(s,n[m(1008)](n[m(1508)](15,d[u]),28)),0),n.hGOqz(d[u++],128))return{value:p?s:n[m(786)](0,s),offset:u};if(n[m(1580)](u+=5,d[m(614)])){if(n[m(985)](n.kyJTX,"GZdfq"))throw u=d[m(614)],yp(u,10,d[m(614)]);{let E=_0x2bd553[m(1534)+"At"](_0x4bcc0b);E>=55296&&cpmlQB.MVsrQ(E,56319)&&cpmlQB[m(1315)](_0x16ec16+1,_0x1b9508)&&(E=cpmlQB.iKYIG((E<<10)+_0x2cac11[m(1534)+"At"](++_0xfa3729),56613888)),cpmlQB[m(1298)](E,128)?_0x568ee0[_0x20f3a7++]=E:(cpmlQB[m(1315)](E,2048)?_0xcbfcd[_0x47c301++]=cpmlQB[m(1411)](E>>6,31)|192:(cpmlQB.mQOyR(E,65536)?_0x9c3718[_0xfe5743++]=cpmlQB[m(1184)](cpmlQB.tkAmk(cpmlQB[m(1805)](E,12),15),224):(_0x3fd2cd[_0x3cce89++]=cpmlQB[m(1184)](cpmlQB[m(1411)](cpmlQB[m(1292)](E,18),7),240),_0x395586[_0xd292d1++]=cpmlQB[m(786)](cpmlQB[m(748)](E>>12,63),128)),_0x309a15[_0x33cc6f++]=cpmlQB[m(798)](cpmlQB.txyPd(cpmlQB.RhRov(E,6),63),128)),_0x559f32[_0x550227++]=cpmlQB[m(1426)](cpmlQB[m(748)](63,E),128))}}return{value:p?s:n[m(1785)](0,s),offset:u}}})();let Cp=16,ga=32;function Rp(a){let n=t,s={CmTCR:function(p){return e[U(876)](p)}},d=0,u={};for(let p=0;e.zEZyP(p,a[n(614)]);p++)if(e[n(757)]("vfWuM",e[n(1731)])){let m=this[n(1270)+n(556)]?.[n(1710)+n(1050)+"nt"]();this[n(1816)](n(1040)+m),s[n(827)](_0x1d1725)}else u[a[p][n(1748)+n(1338)]]=Qd(a[p][n(1748)+n(1338)]),d+=e.vYwlT(14,u[a[p]["cursor_n"+n(1338)]]);return[d,u]}function il(a,n,s){let d=t,u={DbPMt:e.QRBqj,YrzgH:function(k,N,z,H){return k(N,z,H)},AQSOH:e.PZffk,phMMy:d(1851)+"name",KKRcc:e[d(1771)],YMgGv:function(k,N,z,H){return e[d(755)](k,N,z,H)},jhSTt:e.WlfUk},[p,m]=e[d(618)](Rp,a),E=e.JCQxQ(Tp,p),g=0;return a.forEach(k=>{let N=d;console[N(1740)](u[N(1170)],k,k[N(1424)]),g=u.YrzgH(pa,0,E,g),console[N(1740)](u.AQSOH,g),g=bp(E,g,k[N(1424)]||0),console[N(1740)](N(1424),g),g=u[N(548)](pa,m[k[N(1748)+N(1338)]],E,g),console[N(1740)](u.phMMy,g),g=u[N(548)](vp,k[N(1748)+N(1338)],E,g),console[N(1740)](u[N(778)],g),g=u[N(375)](Ap,de[N(1660)+"er"](k[N(608)]||n),E,g),console.log(u[N(724)],g)}),{frameType:ga,headers:[{key:e[d(1560)],value:s}],payload:E}}function Dp(a){let n=t,s=0,d=[];for(;e[n(1032)](s,a[n(508)+"th"]);){let{offset:u}=e[n(1553)](ha,a,s);s=u;let p={cursor_name:"",cursor:0,service:0},{value:m,offset:E}=Ep(a,s);p[n(1424)]=m,s=E;let{value:g,offset:k}=e[n(1122)](ha,a,s);s=k,p[n(1748)+"ame"]=e[n(383)](el,a,s,e[n(790)](s,g)),s+=g;let{value:N,offset:z}=Sp(a,s);p[n(608)]=N[n(588)](),s=z,d[n(1889)](p)}return d}function kp(){let a=t;return{frameType:ga,headers:[{key:e.iQclL,value:e[a(1420)]}],payload:void 0}}class Op{constructor(n,s,d){let u=t;this["_cursorN"+u(445)]=n,this[u(1630)+u(745)]=s,this[u(1421)+u(595)]=d,this[u(1259)]=nl(this[u(805)+"ameSpace"],e.CaNwO)}async[t(866)](){let n=t;await this[n(1259)][n(866)]()}async[t(1045)+"rs"](){let n=t;if(!this[n(1259)][n(718)])return;let s=this[n(1421)+n(595)],d=await this._qosDB[n(1089)]();switch(console[n(1740)](n(1439)+n(1613),d),s){case n(1139):return d&&d[n(614)]?e[n(1656)](il,d,0,this[n(1630)+"ileName"]):void 0;case e.bURKq:return;case e.WKIXN:return d&&d[n(614)]?e[n(873)](il,d,0,this[n(1630)+n(745)]):kp()}}async[t(1705)](n,s,d){let u=t;return e[u(1670)](u(921),e[u(732)])?(console[u(1740)](e[u(1024)],n,s,d),this[u(1259)].set({cursor_name:n,cursor:s,service:d})):this[u(1421)+"Queue"][u(1310)]((m,E)=>(m+=E&&E[u(508)+"th"]||0,m),0)+(this[u(1196)]?this._ws[u(765)+u(592)]:0)}async[t(1009)+"rs"](n){let s=t,d={kBpct:function(p,m){return e[U(505)](p,m)},trakR:function(p,m){return e[U(846)](p,m)},hgOEB:function(p,m){return e.MsGpv(p,m)}},u=e[s(594)](Dp,n);for(let p of u)e.hlLzc(e[s(1554)],e[s(1554)])?(_0x4941de-=65536,_0x33f6f9+=_0x3bad7b(XplnYR[s(832)](_0x3fd3a9,10)+55296,XplnYR[s(891)](XplnYR[s(1108)](1023,_0xa9495b),56320)),_0xc155c4+=3):(console.log(e[s(1454)],u),await this._qosDB[s(1705)](p))}async[t(1309)](n){let s=t;return e[s(1431)](e[s(391)],e[s(1774)])?null:(await this[s(1259)].get(n))?.[s(608)]}async[t(1552)](){let n=t;if(e[n(1118)]===e[n(1118)])await this[n(1259)][n(1552)]();else return new _0x3ee06c(_0x3e28b8,{code:_0x5d13f2,reason:_0x45ad2a,wasClean:_0x296dd9,willReconnect:_0x368e7d})}["updateCu"+t(388)+"Name"](n){let s=t;this[s(1630)+s(745)]=n}get[t(718)](){let n=t;return this[n(1259)][n(718)]}}let Pp=e.uKqag;async function sl(a){let n=t;if(!this[n(574)][n(1602)+"S"])return null;let{aID:s,fpID:d,messageStrategy:u}=this[n(574)],p=e.XJKyJ(a,Pp);try{return this[n(580)+n(1861)]?a&&this["_cursorM"+n(1861)][n(1053)+n(388)+n(536)](a):this["_cursorM"+n(1861)]=new Op(d+"_"+s+"_"+p,p,u),this[n(580)+n(1861)][n(718)]||await this[n(580)+n(1861)].openDB(),this[n(580)+n(1861)]}catch{return null}}async function Np(a,n){let s=t,d={bFlzU:function(L,F){return e[U(965)](L,F)},wRqQu:function(L,F){return L<<F},HDXWi:function(L,F){return e[U(1859)](L,F)},boyxn:function(L,F){return L<<F},IRKGf:function(L,F){return L<<F},xwwGx:function(L,F){return e[U(638)](L,F)},NkNPM:function(L,F,se){return e[U(1229)](L,F,se)},NHqEC:function(L,F){return e[U(1035)](L,F)},NeYbC:function(L,F,se){return e.UdwAG(L,F,se)},JBEmP:function(L,F,se){return e[U(602)](L,F,se)}},u=e[s(1367)](en,a.message[s(1429)],e.WMQsA,"-1"),p=e[s(1491)](en,a[s(1760)][s(1429)],s(1733),"1"),m=e[s(632)](Zn,a[s(1760)].headers,s(604)+"er_msgid"),E=e[s(1509)](Number,e[s(1103)](Zn,a[s(1760)][s(1429)],e[s(1684)]))||0,g=xa[s(461)](this,a),k=e.HsERq(en,a.message[s(1429)],e[s(927)],"2"),N=Zn(a[s(1760)][s(1429)],e.OYpLH),z=e.IFVRv(Number,e[s(1356)](Zn,a.message.headers,e[s(1146)]));if(g[s(1154)])return e[s(1619)](n);let H=g[s(535)+s(1807)]?await rl[s(461)](this):null;if(e[s(828)](a.message[s(1424)],0)&&p&&!u||e[s(1060)](a[s(1760)][s(1424)],0))if(e[s(1394)](s(1280),e[s(1667)])){let L=_0xc930ca["deleteDa"+s(1744)](_0x4a70ec);return _0x5115e4&&L["addEvent"+s(1477)](wZsIRl[s(1340)],()=>_0x5836ad()),_0x171e1f(L)[s(1332)](()=>{})}else{if(m&&g[s(535)+s(1807)]&&H){if(!!!await H.get(m))if(e[s(622)]===e[s(622)])this[s(1238)+"hMessage"+s(1750)](a),await H[s(1705)](m,e.WBoVW(Date[s(895)](),E));else{let F=this[s(1023)],se=this.low;return[F>>>24,e[s(1470)](e[s(1874)](F,16),255),e[s(1345)](e.wzVNx(F,8),255),e[s(1002)](255,F),e[s(706)](se,24),e[s(961)](e[s(1730)](se,16),255),e[s(862)](e[s(1556)](se,8),255),e.sryhS(255,se)]}return e[s(1101)](n)}if(k){if(e[s(757)](e[s(930)],e.vpbri))return new _0x2c91f7(FmStYk[s(999)](FmStYk[s(999)](_0x1763e3[0]|FmStYk[s(1068)](_0x3208e6[1],8),_0x2828da[2]<<16),FmStYk[s(1068)](_0x29a23b[3],24)),FmStYk.HDXWi(_0x203e09[4]|FmStYk.boyxn(_0x3c9fb8[5],8)|_0x3edd33[6]<<16,FmStYk.IRKGf(_0x562eb1[7],24)),_0x1c5cc6);{let L=await sl.call(this);if(!L)return this[s(1238)+s(1205)+s(1750)](a),e[s(1076)](n);let F=await L[s(1309)](N)??-1;if(e[s(1680)](F,z))if(e[s(1668)](e[s(1120)],e[s(994)])){let se=_0x3abcfa[s(623)];FmStYk[s(1257)](void 0,se)&&(_0x3118d6(_0x1273d3,10),FmStYk[s(976)](_0x171412,_0x41429b,se));let qe=_0x1b21b1[s(1884)];FmStYk[s(1202)](void 0,qe)&&(FmStYk[s(811)](_0x5b7a92,_0x1533c8,18),FmStYk[s(1272)](_0xfc13e8,_0x3e977e,qe))}else this[s(1238)+"hMessageEvent"](a),L[s(1705)](N,z,a[s(1760)].service);else throw new Error(s(503)+" message"+s(1031)+z+(s(1248)+"than loc"+s(1224)+"r ")+F);return e[s(1080)](n)}}return this[s(1238)+s(1205)+s(1750)](a),e[s(1076)](n)}}async function Lp(a,n){let s=t,d=xa[s(461)](this,a);if(!d[s(535)+"sage"])return e[s(820)](n);let u=await rl[s(461)](this);if(d[s(1635)+s(1627)+s(1886)]&&d[s(1366)+"s"][s(614)])for(let p of d[s(1366)+"s"])await u[s(771)](p);n()}async function Mp(a,n){let s=t;if(e.fOpmW!==s(1143))this._DBName=_0x370918,this[s(634)]=_0x520da9,this._qosDB=_0x49c734?_0x8fbf8:_0x2c3c45?_0x2d81b3:null;else{let d=e[s(1066)](a[s(1760)][s(859)+"e"],Cp),u=a[s(1760)][s(859)+"e"]===ga;if(e[s(716)](!d,!u))return e[s(1119)](n);let p=e.VwmEj(Zn,a.message[s(1429)],e[s(1560)]);if(!p)return e[s(1076)](n);let m=await sl[s(461)](this,p);if(!m)return e.LSQkk(n);if(d){let E=await m[s(1045)+"rs"](),g={frameType:E?.["frameType"],SeqID:de[s(1660)+"er"](this._seqId++),LogID:de[s(1660)+"er"](this._options["logIDGen"+s(1177)]()),service:9e3,method:5,headers:E?.[s(1429)],payload:E?.[s(1828)]},k=e.fYEFL(S,g);this[s(1196)]&&this._ws.readyState&&this._ws[s(1232)](k)}if(u){let E=a[s(1760)][s(1828)];E&&m[s(1009)+"rs"](E)}}}let Bp=async function(a,n){let s=t,d={pnDvF:s(1683)+s(1051),QXKma:"FILE_NOT"+s(1037)};if(s(854)!==s(854))return{frameType:_0x4eee2e,headers:[{key:qlEVlQ[s(698)],value:qlEVlQ.QXKma}],payload:void 0};this[s(1049)]=!1,clearTimeout(this[s(1075)+s(1826)+s(1599)]),e[s(910)](n)},Fp=async function(a,n){let s=t;if(!this[s(1196)]||e[s(1632)](this[s(1196)].readyState,this[s(1305)]))return n();let{pingInterval:d}=this[s(574)];this[s(1270)+s(556)]?.[s(1522)+s(758)+s(1242)]();for(let p=0;e[s(415)](p,this[s(1421)+s(1505)][s(614)]);p++){let m=this[s(1421)+s(1505)][p];if(e[s(757)](this._ws[s(1654)+"te"],this[s(1305)])&&e.aavyu(null,m))this[s(1196)]&&this[s(1196)][s(1232)](m),this[s(1421)+s(1505)][p]=null;else break}this["_message"+s(1505)]=this[s(1421)+"Queue"][s(653)](p=>!!p),this["_pingPon"+s(472)+"Id"]=e[s(1229)](setTimeout,()=>this[s(1636)](),d),this[s(1238)+s(1316)+"nt"](a),this._isBrowser&&this[s(1196)]&&(this[s(1196)][s(1723)+"pe"]=this["_binaryT"+s(1536)]);let u=this._endpointManager?.["getCurre"+s(1050)+"nt"]();this[s(1816)]("open "+u+s(1475)),n()},zp=async function(a,n){let s=t;if(e[s(680)](e.ypGHM,e.ypGHM))_0x418911[s(1881)][s(1701)+"ild"](_0x3b81b4);else{let d=this[s(1270)+s(556)]?.[s(1710)+s(1050)+"nt"]();this._debug(s(1040)+d),e[s(637)](n)}};class Up extends la{constructor(n){let s=t,d={MkDog:function(E,g){return e[U(1200)](E,g)},vODvk:function(E,g,k){return e[U(1175)](E,g,k)},nNLza:function(E,g){return e[U(1129)](E,g)},RdlVh:s(1290),mSZqG:function(E,g){return e[s(730)](E,g)},hvSxP:s(1253),gFzeC:function(E,g){return e.akRaW(E,g)},NzrGk:function(E,g){return e[s(1628)](E,g)},gENpD:s(1461),QBOCq:"mBugs",HywvA:function(E,g){return e[s(818)](E,g)},ELUBe:e[s(1607)],zHyVS:function(E,g,k,N){return E(g,k,N)},YKiaA:function(E,g){return e[s(1811)](E,g)},OFnIS:e[s(570)],ZYUCv:function(E,g,k){return e.IzeYd(E,g,k)},RZYQF:e[s(897)],dHTzk:e[s(738)],BrVbF:e[s(890)],EJHSX:function(E,g){return e.tXZGk(E,g)},KNLDA:function(E,g,k){return E(g,k)}};super(),this[s(1639)+s(917)+s(1428)]=!0,this[s(807)+"er"]=Jn,this[s(544)]=np,this[s(826)+"T"]=An,this[s(1675)+"X"]=Hr,this[s(1634)+"r"]=jr,this[s(1421)+s(1505)]=[],this[s(1270)+s(556)]=null,this[s(750)+"osed"]=!1,this[s(1489)+s(1536)]=e[s(1383)],this[s(1075)+s(808)]=!1,this[s(1075)+"ionTimeoutId"]=null,this[s(1172)+"ctTimeou"+s(646)]=null,this["_pingPon"+s(472)+"Id"]=null,this[s(1070)]=0,this[s(1049)]=!1,this[s(1623)]="",this["_QoSMana"+s(894)]=null,this[s(580)+s(1861)]=null,this[s(1542)+s(420)]=null,this._protocols=e[s(1612)],this[s(992)]=3,this.CONNECTING=0,this[s(1305)]=1,this[s(1149)]=2,this._onOpen=E=>{let g=s;try{e[g(873)](Xd,this,E,[Bp,Fp,zp])}catch(k){let N=e[g(1553)](ot,g(1290),{message:k[g(1760)],code:Qt.OPEN_ERROR,error:k});this[g(1238)+"hErrorEvent"](N)}},this._onMessage=async E=>{let g=s,k={YOnZM:function(H,L,F){return H(L,F)},AvfVy:d[g(1601)]},{pingInterval:N,pingFrequency:z}=this[g(574)];if((E.data==="hi"&&d.mSZqG(d[g(635)],z)||d[g(1010)]("auto",z))&&(d[g(1025)](d[g(741)],d[g(974)])?(this[g(806)+"ngTimer"](),this[g(714)](g(911)+"e_success",g(945)),this[g(669)+"gTimeoutId"]=setTimeout(this[g(1636)][g(744)](this),N)):_0x4d5943.d=(H,L)=>{for(var F in L)_0x3ddc93.o(L,F)&&!_0x4f20a1.o(H,F)&&_0x185abf.defineProperty(H,F,{enumerable:!0,get:L[F]})}),!d[g(1479)]("hi",E.data))try{if(d[g(842)]!==g(858)){let H=_0x34de8d[g(1806)].slice(_0x3d1cbd.byteOffset,pqDlRn[g(869)](_0xacf7e2[g(508)+"th"],_0x41581e.byteOffset));this[g(1493)]&&this[g(1493)][g(1232)]({data:H,fail:L=>{let F=g;this[F(714)](F(1290),jMUpDd[F(752)](_0x1299d9,jMUpDd.AvfVy,{message:this["_formatE"+F(1544)+F(1886)](L)}))}})}else d[g(655)](Xd,this,E,[mp,pp,Lp,Mp,Np,gp])}catch(H){if(d.YKiaA(d.OFnIS,d.OFnIS)){for(_0x2758cc>>>=0;_0x344f09>=128;)pqDlRn.vODvk(_0x263944,_0x201352,pqDlRn[g(1281)](127,_0x4ff3c7)|128),_0x411bc6>>>=7;_0x2f21db(_0x1d9ef0,_0x316982)}else{let L=d.ZYUCv(ot,d[g(1601)],{message:H[g(1760)],code:Qt[g(1093)+g(1293)],error:H});this["_dispatc"+g(1563)+g(1464)](L)}}},this._onError=E=>{let g=s,k=this["_endpoin"+g(556)]?.["checkRea"+g(1528)+"es"](),N=this["_endpoin"+g(556)]?.getCurrentEndpoint();if(k&&!E[g(1760)]){let z=g(1622)+N+(g(1753)+"ax retri"+g(412)+"ed");this[g(1238)+"hErrorEv"+g(1464)](e.pnuLo(ot,e[g(1277)],{message:z,code:Qt[g(692)+"IES_ERROR"],error:E}));return}this._ws&&e[g(1403)](this._ws[g(1654)+"te"],this[g(1305)])&&this[g(691)+g(1181)](),this["_dispatc"+g(1563)+g(1464)](e[g(520)](ot,"error",{message:E.message,code:Qt[g(510)+g(1575)],error:E}))},this[s(1104)]=async E=>{let g=s;if(d.RZYQF!==d[g(1059)])return this[g(1259)]?.[g(1309)](_0x436f8c);{this["_clearTi"+g(1724)](),this[g(806)+"ngTimer"](),this[g(1137)+"sListeners"](),this[g(1196)]=null,this[g(1075)+"Lock"]=!1;let k=this[g(1270)+g(556)]?.[g(1186)+g(1528)+"es"]();if(!k&&this[g(1126)+g(1474)]()&&!this[g(750)+g(1519)]){let N=this[g(1270)+g(556)]?.getCurrentEndpoint(),z=this._options["reconnec"+g(1369)+g(962)](E[g(1400)],E[g(1111)]);this[g(1238)+"hCloseEv"+g(1464)](d[g(673)](xt,d[g(1510)],{code:1006,reason:E[g(1111)]||g(704)+g(1328)+"d, unknown reaso"+g(1084)+g(953)+N,willReconnect:z})),z&&this[g(1075)]();return}if(d.YKiaA(1e3,E[g(1400)])&&this[g(750)+g(1519)]){this[g(1238)+"hCloseEv"+g(1464)](d.vODvk(xt,d[g(1510)],{code:1e3,reason:d[g(1564)]})),this[g(1270)+"tManager"]?.[g(1522)+g(758)+g(1242)](),this[g(1542)+g(420)]?.[g(1034)+g(512)]();return}if(E[g(1400)]!==1e3&&k){let N=this[g(1270)+"tManager"]?.[g(1710)+"ntEndpoint"](),z=E[g(1111)];z||(z=await d[g(695)](dp,this[g(1623)])),z=g(704)+g(1328)+g(1407)+z+(g(1852)+g(1702))+N+(g(941)+g(582)+"ached"),this["_dispatchCloseEv"+g(1464)](d[g(1844)](xt,g(1655),{code:E[g(1400)],reason:z}));let H=g(1622)+N+(g(1753)+g(882)+g(412)+"ed");this[g(1238)+g(1563)+"ent"](ot(d.RdlVh,{message:H,code:Qt[g(692)+g(1657)+"R"]})),this[g(1270)+g(556)]?.["resetEnd"+g(758)+g(1242)](),this._pingLossCounter?.[g(1034)+g(512)]();return}if(E[g(1400)]!==1e3&&!E[g(1111)]){let N=this[g(1270)+g(556)]?.[g(1710)+"ntEndpoint"]();this["_dispatc"+g(1796)+"ent"](xt("close",{code:E[g(1400)],reason:"connecti"+g(1328)+"d, unkno"+g(1278)+g(1084)+g(953)+N})),this["_endpoin"+g(556)]?.[g(1522)+"pointCon"+g(1242)](),this[g(1542)+g(420)]?.[g(1034)+g(512)]();return}this[g(1238)+g(1796)+g(1464)](E),this[g(1270)+g(556)]?.[g(1522)+g(758)+g(1242)](),this[g(1542)+g(420)]?.["resetCou"+g(512)]()}},this.onclose=null,this[s(578)]=null,this[s(857)+"e"]=null,this.onopen=null,this[s(538)+"econnect"]=null,this[s(1633)+s(1883)]=null,this["onStopImmediatel"+s(1773)+"ct"]=null,this[s(390)+s(654)]=this._handleOnLine[s(744)](this),this[s(390)+s(848)]=this["_handleO"+s(848)].bind(this),this[s(753)+"ageHide"]=this[s(753)+s(1783)].bind(this),this[s(753)+s(986)]=this["_handleP"+s(986)][s(744)](this),this[s(574)]={url:"",automaticOpen:!0,initReconnectInterval:1e3,maxReconnectInterval:1e4,reconnectIntervalGrowFactor:2,timeoutInterval:5e3,maxRetries:5,debug:!1,maxMessageQueueLength:e[s(439)](1,0),service:0,logIDGenerator:o,headers:void 0,payloadEncoding:"",payloadType:"",fpID:"",deviceID:"",accessKey:"",ttwID:"",bddID:"",aID:"",disableAutoReconnect:!1,customParams:{},pingInterval:15e3,pingTimeoutInterval:4e3,pingFrequency:e[s(1526)],pingLossCount:2,enableTransformTextPayload:!1,logIDNewConfig:{enableAutoGenerateLogIDNew:!1,userIp:""},miniProgramParams:{customHttpHeader:{}},enableAutoAck:!1,reconnectInterceptor:()=>!0,enableQoS:!1,QoSLevel:2,messageStrategy:e[s(779)],env:{xTTEnv:"",xUseEnv:""},listenNetworkChanged:!0};let{url:u,ws:p}=n,m=Array[s(464)](u)?u:e.jLadt(e[s(1801)],typeof u)?[u]:[];if(!m||e[s(872)](0,m[s(614)]))throw new Error(e.jNiem);if(!e[s(1231)](sp,p))throw new Error("please p"+s(1147)+s(1483)+s(1808)+"ket cons"+s(1096)+"is undefined");Object[s(957)](this[s(574)],n),this[s(1270)+s(556)]=new Zd(m,this[s(574)][s(660)+"es"]),this[s(1542)+s(420)]=new cp(this[s(574)]["pingLoss"+s(1449)]),this[s(574)]["automati"+s(794)]&&(e[s(1133)](e[s(1098)],s(1171))?(_0x36f29b=e.GoAdP(e[s(852)](e[s(607)](e[s(1301)](e[s(1821)](7,_0x330b97),18),e.vwuJo(63,_0x25bac3)<<12),e[s(1539)](63,_0x240b00)<<6),63&_0x375a13),e.dPuHK(_0x33cda7,65536)||e[s(1018)](_0x6e0fe5,1114111)?_0x18a6ba+=_0x57c35e:(_0x579177-=65536,_0x45924f+=_0x248c9b(e[s(1266)](_0x54f905>>10,55296),e[s(790)](e[s(1600)](1023,_0x1770f1),56320)),_0x5ca3d7+=3)):(this[s(1049)]=!0,this[s(1075)]())),this[s(574)][s(1251)+s(1769)+s(892)]&&(this[s(826)+"T"]||this[s(1675)+"X"]?this[s(1472)+s(1240)+s(722)]():this[s(807)+"er"]&&this["_initGlo"+s(880)+s(1477)]())}[t(390)+t(654)](){let n=t;if(e[n(1035)](e[n(1430)],n(1561)))_0x542d0c=e[n(1650)](e.roQDR(31,_0x13812f),6)|63&_0x424a1d,_0xff54e4<128?_0x4684dc+=_0x4a6d18:(_0x39cdf4+=e[n(1484)](_0x2002ed,_0x500cdb),_0x2fb522++);else{if(this[n(574)].disableAutoReconnect||this[n(750)+n(1519)])return;this[n(1597)+"econnect"]()}}["_handleO"+t(848)](){let n=t;this[n(1359)+n(1500)+"t"]();let s=e[n(632)](da,n(1e3)+"t",{message:e[n(616)]});this[n(875)+"mediatelyReconnect"]&&this[n(875)+n(1099)+n(1773)+"ct"](s)}["_initGlo"+t(880)+t(1477)](){let n=t;this[n(807)+"er"]&&window[n(888)+n(1477)](e[n(1081)],this[n(390)+n(654)]),this[n(807)+"er"]&&window[n(888)+n(1477)](e[n(1197)],this[n(390)+n(848)]),this[n(807)+"er"]&&window[n(888)+"Listener"]("pagehide",this._handlePageHide),this._isBrowser&&window[n(888)+n(1477)](e[n(398)],this[n(753)+n(986)])}["_dropGlo"+t(880)+t(1477)](){let n=t;if(e.PHJke(e[n(1538)],n(1516)))this._isBrowser&&window[n(1827)+n(457)+n(1004)]("online",this[n(390)+n(654)]),this[n(807)+"er"]&&window[n(1827)+n(457)+n(1004)](n(1609),this._handleOffLine),this[n(807)+"er"]&&window[n(1827)+n(457)+"ner"](n(1877),this[n(753)+n(1783)]),this[n(807)+"er"]&&window[n(1827)+n(457)+n(1004)](n(996),this[n(753)+n(986)]);else return this[n(1259)][n(421)]()}[t(753)+"ageHide"](n){let s=t;!n.persisted&&(e[s(939)](e[s(522)],e[s(1738)])?(this._isBrowser&&window[s(1827)+s(457)+"ner"](e[s(1530)],this["_handleP"+s(1783)]),this._isBrowser&&window[s(1827)+s(457)+"ner"](s(996),this[s(753)+s(986)]),this[s(1655)]()):(_0x5e620b=e[s(1685)],_0x48c12c=_0x365ff5.replace(/(^http)((?:[s]*:\/\/))/,""),_0x5ae2c7=/(^ws)((?:[s]*:\/\/))/[s(1605)](_0x197d4a)?_0x185e07:""+_0x456f06+_0x5f1539)),this[s(807)+"er"]&&window[s(1827)+s(457)+s(1004)](s(1150),this[s(390)+s(654)]),this._isBrowser&&window[s(1827)+s(457)+"ner"](s(1609),this["_handleO"+s(848)])}[t(753)+t(986)](n){let s=t;n.persisted&&(this["_navigat"+s(1474)]()&&(!this._ws||e[s(712)](this[s(1196)][s(1654)+"te"],this[s(1305)])||e[s(1191)](this._ws[s(1654)+"te"],this.CONNECTING))&&this["_handleO"+s(654)](),this[s(807)+"er"]&&window[s(888)+s(1477)](s(1150),this[s(390)+s(654)]),this[s(807)+"er"]&&window[s(888)+"Listener"](e.dsBWr,this[s(390)+"ffLine"]))}async[t(1694)+t(725)](n){let s=t,{fpID:d,deviceID:u,bddID:p,ttwID:m,accessKey:E,aID:g,customParams:k={},enableAutoAck:N,enableQoS:z,QoSLevel:H,env:L}=this._options,F,se,qe;this[s(807)+"er"]||this._isMiniWX||this[s(826)+"T"]?(F=location&&e[s(1492)](s(1545),location.protocol)?e[s(1685)]:e[s(1642)],se=n.replace(/((^ws)|(^http))((?:[s]*:\/\/))/,""),qe=/^wss(.*:\/\/)/[s(1605)](n)?n:""+F+se):e[s(759)]===e[s(1216)]?(_0x573eb5=_0xfefac6[s(1437)](_0x8de639),_0x340f31=_0x59a896.concat(_0x427476[_0x3c0e2e])):(F=s(499),se=n[s(459)](/(^http)((?:[s]*:\/\/))/,""),qe=/(^ws)((?:[s]*:\/\/))/[s(1605)](se)?se:""+F+se);let ts=p?e[s(1234)]:m?e[s(1550)]:s(751)+"d",ns=p||m||u;if(!ns||!ts)throw new Error(e[s(636)]);let ma=e[s(451)](e.WnXOS,typeof k)?await k():k,wa=L?ap(L[s(1834)],L[s(900)]):{},Wr=Object[s(957)]({device_platform:e[s(1737)],version_code:e[s(1659)],access_key:E,fpid:d,aid:g,[ts]:ns,xsack:N?1:0,xaack:N?1:0,xsqos:z?1:0,qos_level:z?H:void 0,qos_sdk_version:2,...wa},ma),_a=Object[s(1809)](Wr)[s(1310)]((tn,Ft)=>Wr[Ft]!==void 0?""+tn+(tn?"&":"?")+Ft+"="+Wr[Ft]:tn,"");return qe+s(1527)+_a}async[t(1075)](){let n=t;if(!(this[n(1075)+n(808)]||this[n(750)+n(1519)])){this[n(1075)+n(808)]=!0;try{let s=this[n(1270)+n(556)]?.["checkCur"+n(1679)+n(1168)+"hedMaxRetries"](),{timeoutInterval:d}=this[n(574)];if(s){let p=this[n(1270)+n(556)]?.[n(1710)+"ntEndpoint"](),m=this[n(1270)+n(556)]?.["replaceB"+n(611)+n(1194)+n(1804)+"unt"](),E=this[n(1270)+"tManager"]?.["getCurre"+n(1050)+n(901)+"ount"]();if(m){let g=n(1622)+p+(" timeout, max re"+n(582)+"ached, will use "+n(1879)+"ndpoint ")+m+(n(659)+"y"),k=e.GzZZY(ot,n(1290),{message:g,code:Qt[n(692)+"IES_ERROR"]});this[n(1816)](g),this[n(1238)+"hErrorEvent"](k),this._url=await this["_generat"+n(725)](m),this[n(1816)](n(1622)+m+" "+E+n(1676)),this[n(1137)+n(1329)+"rs"]()}else{let g=n(1622)+p+(n(1749)+", max re"+n(582)+n(395));this._debug(g),this[n(1238)+n(1563)+n(1464)](e.IbvCg(ot,n(1290),{message:g,code:Qt[n(692)+n(1657)+"R"]}));return}}else{let p=this[n(1270)+n(556)]?.[n(1710)+n(1050)+n(1324)+n(1017)](),m=this[n(1270)+n(556)]?.[n(1710)+"ntEndpoi"+n(901)+"ount"]();this._url=await this[n(1694)+n(725)](e[n(1384)](p,"")),this[n(1816)](n(1622)+p+" "+m+n(1676)),this[n(1137)+"sListeners"]()}if(this[n(1049)])this._isInit=!1;else{let p=e[n(711)](da,e[n(1604)],{message:n(1308)});this[n(538)+"econnect"]&&this[n(538)+"econnect"](p)}let u=this._endpointManager?.[n(1710)+"ntEndpointTriesC"+n(627)]()||0;e[n(1018)](u,1)&&await this._wait(e[n(569)](u,1)),this[n(1816)](n(704)+n(841)+this._url+(n(1265)+"ls: ")+this[n(531)+"ls"]),this[n(1196)]=e[n(1134)](ip,{url:this[n(1623)],protocols:[this[n(531)+"ls"]],headers:this[n(574)][n(619)+n(1555)+"s"][n(1433)+n(1649)]},this[n(574)].ws),(this[n(807)+"er"]||this[n(1634)+"r"])&&this[n(1196)]&&(this[n(1196)].binaryType=this["_binaryT"+n(1536)]),this[n(923)+n(830)](),this[n(1075)+n(1826)+"utId"]=setTimeout(this[n(1399)+"ut"][n(744)](this),d)}catch(s){throw this[n(1075)+n(808)]=!1,s}}}[t(554)+"mer"](){let n=t;e[n(928)](clearTimeout,this[n(1075)+n(1826)+n(1599)]),this[n(1075)+n(1826)+n(1599)]=null}[t(806)+"ngTimer"](){let n=t;clearTimeout(this["_pingPon"+n(472)+"Id"]),clearTimeout(this[n(1172)+n(1891)+n(646)]),this[n(669)+n(472)+"Id"]=null,this[n(1172)+n(1891)+n(646)]=null}[t(1816)](...n){let s=t;this[s(574)][s(515)]&&console[s(1740)][s(1110)](console,[e[s(1151)],...n])}[t(783)+"rvalValue"](n){let s=t,{initReconnectInterval:d,maxReconnectInterval:u,reconnectIntervalGrowFactor:p}=this[s(574)],m=e[s(908)](d,Math[s(1342)](p,e[s(1722)](n,1)));return m>u?u:m}_ping(){let n=t,s={ZSbAY:e[n(1797)]};if(this._ws&&this[n(1196)][n(1654)+"te"]===this.CONNECTING)if(e.aavyu("RuXCe",e[n(498)]))_0x8bc7b[n(1881)]["removeCh"+n(617)](_0x5bef62),_0x4a3cdc[n(1381)+"JSONP"]=void 0,_0x7d62b3(_0x343ee0&&_0x38d3f2[n(1535)]||NejjPF[n(971)]);else{this[n(806)+n(940)](),this[n(669)+n(472)+"Id"]=e.wMyla(setTimeout,this._ping[n(744)](this),this[n(574)]["pingInte"+n(1092)]);return}if(!this[n(1196)]||this._ws.readyState!==this.OPEN)return void this["_handleR"+n(593)]();this._ws&&this[n(1196)][n(1232)]("hi"),this[n(1172)+"ctTimeoutId"]=e[n(602)](setTimeout,this[n(1597)+"econnect"+n(404)][n(744)](this),this[n(574)]["pingTime"+n(467)+n(496)])}[t(1597)+t(593)+"Timeout"](){let n=t;this[n(1542)+"sCounter"]?.addCount(),this[n(714)](e.pWDCE,n(925)),this[n(1542)+n(420)]?.["checkRea"+n(396)+"nt"]()?this._handleReconnect():this[n(1636)]()}[t(1126)+"orOnline"](){let n=t;return this[n(826)+"T"]||this[n(1675)+"X"]?this[n(1639)+"igatorOn"+n(1428)]:(this[n(807)+"er"]||this._isWorker)&&this[n(574)][n(1251)+"tworkCha"+n(892)]?navigator[n(1736)]:!0}[t(1597)+"econnect"](){let n=t;!this[n(1126)+"orOnline"]()||this[n(750)+"osed"]||(this[n(1270)+n(556)]?.[n(1522)+n(758)+n(1242)](),this["_pingLos"+n(420)]?.[n(1034)+n(512)](),this._ws?this["_disconn"+n(1181)](1001,e[n(1291)],!0):this._connect())}["_onPageN"+t(1240)+t(722)](){let n=t;this._isMiniTT?tt[n(483)+n(495)+n(1841)](({isConnected:s})=>{let d=n;this[d(1639)+"igatorOn"+d(1428)]=s,s?this[d(390)+"nLine"]():this[d(390)+d(848)]()}):this._isMiniWX&&wx["onNetwor"+n(495)+n(1841)](({isConnected:s})=>{let d=n;this[d(1639)+d(917)+d(1428)]=s,s?this[d(390)+"nLine"]():this[d(390)+d(848)]()})}[t(413)](n){let s={bbymH:function(d,u,p){return e.fLKWT(d,u,p)}};return new Promise(d=>{let u=U;s.bbymH(setTimeout,d,this[u(783)+u(1112)+"e"](n))})}["_disconn"+t(1181)](n=1e3,s="",d=!1){let u=t;this[u(1196)]&&this[u(1359)+u(1500)+"t"](n,s,d)}[t(1399)+"ut"](){let n=t,s=this["_endpoin"+n(556)]?.[n(1710)+"ntEndpoint"]();this[n(1816)]("connect "+s+n(1749)),this[n(691)+n(1181)](1001,e[n(1776)],!0)}[t(481)](n){let s=t,d=e[s(1283)](Bt,n);this[s(1196)]&&this[s(1196)][s(1654)+"te"]===this[s(1305)]&&(this[s(1196)]&&this[s(1196)][s(1232)](d),this[s(1816)](e[s(936)],n))}[t(1137)+t(1329)+"rs"](){let n=t;this[n(1196)]&&(this[n(1196)]["removeEv"+n(457)+n(1004)](e[n(920)],this._onOpen),this[n(1196)][n(1827)+n(457)+n(1004)]("close",this[n(1104)]),this[n(1196)]["removeEv"+n(457)+n(1004)](e.gMljV,this[n(1228)+"ge"]),this[n(1196)][n(1827)+n(457)+n(1004)](e.hwdXv,this[n(676)]))}_addWsListeners(){let n=t;if(e.qYdYT(e[n(610)],e[n(1237)])){let s=e[n(1478)].split("|"),d=0;for(;;){switch(s[d++]){case"0":this[n(1196)][n(888)+n(1477)](n(1326),this[n(1364)]);continue;case"1":this._ws[n(888)+n(1477)](e[n(710)],this[n(1228)+"ge"]);continue;case"2":this[n(1196)][n(888)+n(1477)](n(1655),this[n(1104)]);continue;case"3":if(!this[n(1196)])return;continue;case"4":this[n(1196)][n(888)+n(1477)](e[n(1277)],this[n(676)]);continue}break}}else return _0x3759aa["fromChar"+n(812)](e[n(1663)](255,this.low),e[n(1789)](e[n(1677)](this[n(1071)],8),255),e.tKpjk(e[n(1409)](this[n(1071)],16),255),e.wzVNx(this.low,24),255&this[n(1023)],e[n(1263)](this[n(1023)],8)&255,e[n(1125)](e[n(1073)](this[n(1023)],16),255),e[n(1556)](this[n(1023)],24))}[t(906)+"nceClose"](n=1e3,s=""){let d=t;try{if(e[d(1632)]("NjwcO",e[d(1711)]))return{bytes:_0xb0623,offset:0,limit:_0x23121c[d(614)]};this[d(1196)]&&this._ws[d(1655)](n,s)}catch{}}["_destroy"+t(1500)+"t"](n=1e3,s="",d=!1){let u=t;if(this[u(806)+u(940)](),this._clearTimer(),this[u(1137)+u(1329)+"rs"](),this[u(906)+u(1853)](1e3,s),this[u(1075)+u(808)]=!1,d&&this[u(1126)+u(1474)]()&&!this[u(750)+"osed"]){if(this[u(1270)+"tManager"]?.[u(1186)+u(1528)+"es"]()){let m=this[u(1270)+"tManager"]?.[u(1710)+u(1050)+"nt"]();this[u(1238)+u(1796)+u(1464)](xt(e.MFPir,{code:1006,reason:u(1622)+m+(u(1749)+u(941)+u(582)+u(395)),wasClean:!0}))}else{let m=this[u(574)][u(1e3)+u(1369)+u(962)](n,s);this[u(1238)+"hCloseEvent"](xt(e.MFPir,{code:n,reason:s,wasClean:!0,willReconnect:m})),m&&this[u(1075)]()}return}this[u(1126)+u(1474)]()||this["_readyCl"+u(1519)]?this["_dispatc"+u(1796)+u(1464)](xt(u(1655),{code:n,reason:e[u(890)]})):this[u(1238)+u(1796)+u(1464)](e[u(1097)](xt,e.MFPir,{code:1006,reason:u(1185)+"ay, netw"+u(511)+"ine"})),this[u(1196)]=null,this[u(1270)+u(556)]?.["resetEnd"+u(758)+u(1242)](),this["_pingLos"+u(420)]?.[u(1034)+u(512)]()}[t(1238)+t(1316)+"nt"](n){let s=t;this[s(714)](e[s(920)],n),this.onopen&&this[s(482)](n)}["_dispatchMessage"+t(1750)](n){this[t(714)](e.gMljV,n),this.onmessage&&this.onmessage(n)}[t(1238)+t(1672)+t(1142)](n){let s=t;this[s(714)](e[s(419)],n),this[s(1633)+"eAck"]&&this[s(1633)+s(1883)](n)}[t(1238)+t(1563)+t(1464)](n){let s=t;this[s(714)](e[s(1277)],n),this.onerror&&this[s(578)](n)}[t(1238)+t(1796)+t(1464)](n){let s=t;this.emit(s(1655),n),this.onclose&&this[s(1346)](n)}get[t(1723)+"pe"](){let n=t;return this[n(1196)]?this[n(1196)][n(1723)+"pe"]:this[n(1489)+n(1536)]}set[t(1723)+"pe"](n){let s=t;this["_binaryT"+s(1536)]=n,this._ws&&(this[s(1196)][s(1723)+"pe"]=n)}get retryCount(){let n=t;return this[n(1270)+n(556)]?.["getCurre"+n(1050)+"ntTriesCount"]()||0}get[t(765)+t(592)](){let n=t;if(e[n(491)]!==n(746))this[n(826)+"T"]||this._isMiniWX?this[n(1472)+n(1240)+"ange"]():this[n(807)+"er"]&&this[n(1584)+n(880)+"Listener"]();else{let s=this["_message"+n(1505)].reduce((d,u)=>(d+=u&&u[n(508)+"th"]||0,d),0);return e[n(1463)](s,this[n(1196)]?this[n(1196)][n(765)+n(592)]:0)}}get[t(844)+"ns"](){let n=t;return this[n(1196)]?this[n(1196)][n(844)+"ns"]:""}get[t(1585)](){let n=t;return this[n(1196)]?this[n(1196)].protocol:""}get[t(1654)+"te"](){let n=t;return this[n(1196)]?this[n(1196)][n(1654)+"te"]:this[n(574)]["automati"+n(794)]?this[n(1245)+"NG"]:this[n(992)]}get[t(1195)](){let n=t,s={QPDGl:function(d,u){return e[U(470)](d,u)}};if(e[n(1179)]===e[n(984)]){let d=0,u={};for(let p=0;rkYkrG.QPDGl(p,_0x3918d3.length);p++)u[_0x500a74[p]["cursor_n"+n(1338)]]=_0x48e0fe(_0x486da3[p]["cursor_n"+n(1338)]),d+=14+u[_0x2b68d4[p][n(1748)+n(1338)]];return[d,u]}else return this[n(1196)]?this[n(1196)].url:this[n(1623)]}[t(1655)](n=1e3,s){let d=t,u=e[d(406)][d(1193)]("|"),p=0;for(;;){switch(u[p++]){case"0":this[d(554)+d(1724)]();continue;case"1":if(!this[d(1196)])return void this[d(1816)](d(1152)+"s instan"+d(546)+"nitialized");continue;case"2":this[d(1113)+d(880)+d(1477)]();continue;case"3":this[d(806)+d(940)]();continue;case"4":this[d(1359)+"WebSocket"](n,s);continue;case"5":if(e.tqsAb(this[d(1196)].readyState,this[d(992)])||e[d(1697)](this[d(1196)][d(1654)+"te"],this.CLOSING))return void this[d(1816)](e.UGPKD);continue;case"6":this[d(856)+d(894)]?.[d(1552)]();continue;case"7":this[d(750)+d(1519)]=!0;continue}break}}async[t(1232)](n,s){let d=t;if(e[d(451)](null,n))throw new Error(e.VDGAb);e[d(1377)](e.HTnZI,typeof n)&&(n=JSON[d(1547)+"y"](n)),e[d(1515)](e[d(1801)],typeof n)&&!e[d(682)](n,ArrayBuffer)&&!(n.buffer&&e[d(703)](n[d(1806)],ArrayBuffer))&&(n=JSON.stringify(n));let u=await tl(n),p=op(n),{method:m=0,service:E=this[d(574)][d(1424)],logID:g=this[d(574)][d(1712)+d(1177)](),headers:k=this[d(574)][d(1429)],payloadEncoding:N=this[d(574)][d(1882)+"ncoding"],payloadType:z=this._options[d(802)+d(1536)],logIDNew:H=this[d(574)][d(475)+d(1100)][d(801)+d(1758)+d(1887)+"ew"]?i(this[d(574)]["logIDNew"+d(1100)][d(633)]):""}=e.yWGfJ(s,{});if(!E)throw new Error(e.cwINr);let L={SeqID:de.fromNumber(this[d(1070)]++),LogID:de[d(1660)+"er"](g),service:E,method:m,headers:k,payloadEncoding:e[d(682)](N,Object)?N[d(1781)]?N[d(1781)]:"":N,payloadType:z instanceof Object?z.type?z[d(840)]:p:z||p,payload:u,LogIDNew:H},F=e[d(1665)](Bt,L);return this._ws&&this[d(1196)][d(1654)+"te"]===this[d(1305)]?(this._ws&&this[d(1196)][d(1232)](F),this[d(1816)](e[d(1779)],L)):e[d(1784)](this[d(1421)+d(1505)][d(614)],this[d(574)][d(553)+"geQueueL"+d(729)])?(this["_message"+d(1505)].push(F),this[d(1816)](e[d(1588)],L)):(this[d(1421)+"Queue"][d(719)](),this[d(1421)+d(1505)][d(1889)](F)),{seqID:this[d(1070)],logID:g,logIDNew:H}}async[t(1e3)+"t"](n){let s=t,{url:d}=n||{},u=Array[s(464)](d)?d:e[s(684)](s(1028),typeof d)?[d]:[];n&&Object[s(957)](this[s(574)],n),u&&u[s(614)]?this[s(1270)+s(556)]=new Zd(u,this[s(574)][s(660)+"es"]):this[s(1270)+s(556)]?.[s(1522)+s(758)+s(1242)](),this[s(1542)+s(420)]?.[s(1034)+s(512)](this._options[s(1782)+s(1449)]),this[s(750)+s(1519)]=!1,this._ws&&e.itOvc(this[s(1196)][s(1654)+"te"],this[s(992)])?this[s(691)+s(1181)](1e3,e[s(1300)],!0):(this[s(1049)]=!0,this._connect())}async[t(1209)](){let n=t;if(!this[n(1075)+n(808)]){let s=(n(1330)+"3")[n(1193)]("|"),d=0;for(;;){switch(s[d++]){case"0":this[n(1049)]=!0;continue;case"1":this[n(1542)+n(420)]?.resetCounter();continue;case"2":this[n(1270)+n(556)]?.[n(1522)+"pointCon"+n(1242)]();continue;case"3":this[n(1075)]();continue;case"4":this._readyClosed=!1;continue}break}}}[t(888)+"Listener"](n,s){this.on(n,s)}dispatchEvent(n){let{type:s}=n;this.emit(s,n)}["removeEv"+t(457)+t(1004)](n,s){let d=t;if(e[d(1020)](e[d(547)],e[d(558)]))return this[d(1259)]?.set({message_id:_0x4fac01,timestamp:_0x1ac25a});this[d(552)](n,s)}[t(879)](){return new Promise((n,s)=>{let d=U,u={sEgsr:function(E,g){return E(g)},oQTiL:e[d(1880)],vhOek:e[d(528)],VUgVZ:e[d(1057)]};this[d(806)+"ngTimer"](),this[d(669)+"gTimeoutId"]=e[d(1159)](setTimeout,this[d(1636)].bind(this),this[d(574)][d(993)+d(1092)]);let p=()=>{let E=d;u[E(1331)](n,u[E(436)]),this[E(552)](u[E(534)],p),this[E(552)](u[E(474)],m)},m=()=>{let E=d;u[E(1331)](s,E(925)),this.off(u[E(534)],p),this.off(u[E(474)],m)};this.on(e[d(528)],p),this.on(e[d(1057)],m),this._ping()})}}})(),Le[M(834)+M(1620)]=Ce[M(834)+M(1620)],Le[M(1846)+M(456)]=Ce.CustomErrorEvent,Le[M(800)+"e"]=Ce[M(800)+"e"],Le[M(1750)]=Ce[M(1750)],Le[M(1379)]=Ce[M(1379)],Le[M(560)+"MessageE"+M(1217)]=Ce["Frontier"+M(824)+M(1217)],Le[M(824)+M(1217)]=Ce[M(824)+"vent"],Le[M(402)+"t"]=Ce[M(402)+"t"],Le[M(1548)+"tEvent"]=Ce[M(1548)+M(913)],Le[M(749)+M(1620)]=Ce[M(749)+M(1620)],Le.createErrorEvent=Ce[M(504)+M(456)],Le[M(479)+M(1687)+"nt"]=Ce[M(479)+M(1687)+"nt"],Le[M(416)+M(885)]=Ce["createOp"+M(885)],Le["createRe"+M(1581)+M(1217)]=Ce[M(1128)+M(1581)+M(1217)],Le[M(1244)+M(507)]=Ce["decodedF"+M(507)],Le[M(1417)+"ame"]=Ce["encodeFr"+M(1338)];for(Ao in Ce)[M(834)+"oseEvent",M(1846)+M(456),"ErrorCode",M(1750),"FWS",M(560)+"MessageEvent",M(824)+M(1217),M(402)+"t",M(1548)+M(913),M(749)+M(1620),M(504)+M(456),M(479)+"ssageEvent",M(416)+M(885),"createRe"+M(1581)+M(1217),"decodedFrame",M(1417)+M(1338)][M(1678)](Ao)===-1&&(Le[Ao]=Ce[Ao]);var Ao;Object.defineProperty(Le,M(1448)+"le",{value:!0})});var Kt=oe((tC,ox)=>{"use strict";var ix=["nodebuffer","arraybuffer","fragments"],sx=typeof Blob<"u";sx&&ix.push("blob");ox.exports={BINARY_TYPES:ix,CLOSE_TIMEOUT:3e4,EMPTY_BUFFER:Buffer.alloc(0),GUID:"258EAFA5-E914-47DA-95CA-C5AB0DC85B11",hasBlob:sx,kForOnEventAttribute:Symbol("kIsForOnEventAttribute"),kListener:Symbol("kListener"),kStatusCode:Symbol("status-code"),kWebSocket:Symbol("websocket"),NOOP:()=>{}}});var qi=oe((nC,Oo)=>{"use strict";var{EMPTY_BUFFER:Wb}=Kt(),ad=Buffer[Symbol.species];function Kb(t,e){if(t.length===0)return Wb;if(t.length===1)return t[0];let r=Buffer.allocUnsafe(e),i=0;for(let o=0;o<t.length;o++){let c=t[o];r.set(c,i),i+=c.length}return i<e?new ad(r.buffer,r.byteOffset,i):r}function ax(t,e,r,i,o){for(let c=0;c<o;c++)r[i+c]=t[c]^e[c&3]}function cx(t,e){for(let r=0;r<t.length;r++)t[r]^=e[r&3]}function $b(t){return t.length===t.buffer.byteLength?t.buffer:t.buffer.slice(t.byteOffset,t.byteOffset+t.length)}function cd(t){if(cd.readOnly=!0,Buffer.isBuffer(t))return t;let e;return t instanceof ArrayBuffer?e=new ad(t):ArrayBuffer.isView(t)?e=new ad(t.buffer,t.byteOffset,t.byteLength):(e=Buffer.from(t),cd.readOnly=!1),e}Oo.exports={concat:Kb,mask:ax,toArrayBuffer:$b,toBuffer:cd,unmask:cx};if(!process.env.WS_NO_BUFFER_UTIL)try{let t=le("bufferutil");Oo.exports.mask=function(e,r,i,o,c){c<48?ax(e,r,i,o,c):t.mask(e,r,i,o,c)},Oo.exports.unmask=function(e,r){e.length<32?cx(e,r):t.unmask(e,r)}}catch{}});var fx=oe((rC,lx)=>{"use strict";var dx=Symbol("kDone"),dd=Symbol("kRun"),ld=class{constructor(e){this[dx]=()=>{this.pending--,this[dd]()},this.concurrency=e||1/0,this.jobs=[],this.pending=0}add(e){this.jobs.push(e),this[dd]()}[dd](){if(this.pending!==this.concurrency&&this.jobs.length){let e=this.jobs.shift();this.pending++,e(this[dx])}}};lx.exports=ld});var kr=oe((iC,px)=>{"use strict";var Hi=le("zlib"),ux=qi(),Vb=fx(),{kStatusCode:xx}=Kt(),Yb=Buffer[Symbol.species],Jb=Buffer.from([0,0,255,255]),No=Symbol("permessage-deflate"),$t=Symbol("total-length"),Rr=Symbol("callback"),En=Symbol("buffers"),Dr=Symbol("error"),Po,fd=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,!Po){let r=this._options.concurrencyLimit!==void 0?this._options.concurrencyLimit:10;Po=new Vb(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[Rr];this._deflate.close(),this._deflate=null,e&&e(new Error("The deflate stream was closed while data was being processed"))}}acceptAsServer(e){let r=this._options,i=e.find(o=>!(r.serverNoContextTakeover===!1&&o.server_no_context_takeover||o.server_max_window_bits&&(r.serverMaxWindowBits===!1||typeof r.serverMaxWindowBits=="number"&&r.serverMaxWindowBits>o.server_max_window_bits)||typeof r.clientMaxWindowBits=="number"&&!o.client_max_window_bits));if(!i)throw new Error("None of the extension offers can be accepted");return r.serverNoContextTakeover&&(i.server_no_context_takeover=!0),r.clientNoContextTakeover&&(i.client_no_context_takeover=!0),typeof r.serverMaxWindowBits=="number"&&(i.server_max_window_bits=r.serverMaxWindowBits),typeof r.clientMaxWindowBits=="number"?i.client_max_window_bits=r.clientMaxWindowBits:(i.client_max_window_bits===!0||r.clientMaxWindowBits===!1)&&delete i.client_max_window_bits,i}acceptAsClient(e){let r=e[0];if(this._options.clientNoContextTakeover===!1&&r.client_no_context_takeover)throw new Error('Unexpected parameter "client_no_context_takeover"');if(!r.client_max_window_bits)typeof this._options.clientMaxWindowBits=="number"&&(r.client_max_window_bits=this._options.clientMaxWindowBits);else if(this._options.clientMaxWindowBits===!1||typeof this._options.clientMaxWindowBits=="number"&&r.client_max_window_bits>this._options.clientMaxWindowBits)throw new Error('Unexpected or invalid parameter "client_max_window_bits"');return r}normalizeParams(e){return e.forEach(r=>{Object.keys(r).forEach(i=>{let o=r[i];if(o.length>1)throw new Error(`Parameter "${i}" must have only a single value`);if(o=o[0],i==="client_max_window_bits"){if(o!==!0){let c=+o;if(!Number.isInteger(c)||c<8||c>15)throw new TypeError(`Invalid value for parameter "${i}": ${o}`);o=c}else if(!this._isServer)throw new TypeError(`Invalid value for parameter "${i}": ${o}`)}else if(i==="server_max_window_bits"){let c=+o;if(!Number.isInteger(c)||c<8||c>15)throw new TypeError(`Invalid value for parameter "${i}": ${o}`);o=c}else if(i==="client_no_context_takeover"||i==="server_no_context_takeover"){if(o!==!0)throw new TypeError(`Invalid value for parameter "${i}": ${o}`)}else throw new Error(`Unknown parameter "${i}"`);r[i]=o})}),e}decompress(e,r,i){Po.add(o=>{this._decompress(e,r,(c,l)=>{o(),i(c,l)})})}compress(e,r,i){Po.add(o=>{this._compress(e,r,(c,l)=>{o(),i(c,l)})})}_decompress(e,r,i){let o=this._isServer?"client":"server";if(!this._inflate){let c=`${o}_max_window_bits`,l=typeof this.params[c]!="number"?Hi.Z_DEFAULT_WINDOWBITS:this.params[c];this._inflate=Hi.createInflateRaw({...this._options.zlibInflateOptions,windowBits:l}),this._inflate[No]=this,this._inflate[$t]=0,this._inflate[En]=[],this._inflate.on("error",Xb),this._inflate.on("data",hx)}this._inflate[Rr]=i,this._inflate.write(e),r&&this._inflate.write(Jb),this._inflate.flush(()=>{let c=this._inflate[Dr];if(c){this._inflate.close(),this._inflate=null,i(c);return}let l=ux.concat(this._inflate[En],this._inflate[$t]);this._inflate._readableState.endEmitted?(this._inflate.close(),this._inflate=null):(this._inflate[$t]=0,this._inflate[En]=[],r&&this.params[`${o}_no_context_takeover`]&&this._inflate.reset()),i(null,l)})}_compress(e,r,i){let o=this._isServer?"server":"client";if(!this._deflate){let c=`${o}_max_window_bits`,l=typeof this.params[c]!="number"?Hi.Z_DEFAULT_WINDOWBITS:this.params[c];this._deflate=Hi.createDeflateRaw({...this._options.zlibDeflateOptions,windowBits:l}),this._deflate[$t]=0,this._deflate[En]=[],this._deflate.on("data",Zb)}this._deflate[Rr]=i,this._deflate.write(e),this._deflate.flush(Hi.Z_SYNC_FLUSH,()=>{if(!this._deflate)return;let c=ux.concat(this._deflate[En],this._deflate[$t]);r&&(c=new Yb(c.buffer,c.byteOffset,c.length-4)),this._deflate[Rr]=null,this._deflate[$t]=0,this._deflate[En]=[],r&&this.params[`${o}_no_context_takeover`]&&this._deflate.reset(),i(null,c)})}};px.exports=fd;function Zb(t){this[En].push(t),this[$t]+=t.length}function hx(t){if(this[$t]+=t.length,this[No]._maxPayload<1||this[$t]<=this[No]._maxPayload){this[En].push(t);return}this[Dr]=new RangeError("Max payload size exceeded"),this[Dr].code="WS_ERR_UNSUPPORTED_MESSAGE_LENGTH",this[Dr][xx]=1009,this.removeListener("data",hx),this.reset()}function Xb(t){if(this[No]._inflate=null,this[Dr]){this[Rr](this[Dr]);return}t[xx]=1007,this[Rr](t)}});var Or=oe((sC,Lo)=>{"use strict";var{isUtf8:gx}=le("buffer"),{hasBlob:Qb}=Kt(),eE=[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 tE(t){return t>=1e3&&t<=1014&&t!==1004&&t!==1005&&t!==1006||t>=3e3&&t<=4999}function ud(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 nE(t){return Qb&&typeof t=="object"&&typeof t.arrayBuffer=="function"&&typeof t.type=="string"&&typeof t.stream=="function"&&(t[Symbol.toStringTag]==="Blob"||t[Symbol.toStringTag]==="File")}Lo.exports={isBlob:nE,isValidStatusCode:tE,isValidUTF8:ud,tokenChars:eE};if(gx)Lo.exports.isValidUTF8=function(t){return t.length<24?ud(t):gx(t)};else if(!process.env.WS_NO_UTF_8_VALIDATE)try{let t=le("utf-8-validate");Lo.exports.isValidUTF8=function(e){return e.length<32?ud(e):t(e)}}catch{}});var md=oe((oC,Sx)=>{"use strict";var{Writable:rE}=le("stream"),mx=kr(),{BINARY_TYPES:iE,EMPTY_BUFFER:_x,kStatusCode:sE,kWebSocket:oE}=Kt(),{concat:xd,toArrayBuffer:aE,unmask:cE}=qi(),{isValidStatusCode:dE,isValidUTF8:yx}=Or(),Mo=Buffer[Symbol.species],lt=0,bx=1,Ex=2,vx=3,hd=4,pd=5,Bo=6,gd=class extends rE{constructor(e={}){super(),this._allowSynchronousEvents=e.allowSynchronousEvents!==void 0?e.allowSynchronousEvents:!0,this._binaryType=e.binaryType||iE[0],this._extensions=e.extensions||{},this._isServer=!!e.isServer,this._maxPayload=e.maxPayload|0,this._skipUTF8Validation=!!e.skipUTF8Validation,this[oE]=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=lt}_write(e,r,i){if(this._opcode===8&&this._state==lt)return i();this._bufferedBytes+=e.length,this._buffers.push(e),this.startLoop(i)}consume(e){if(this._bufferedBytes-=e,e===this._buffers[0].length)return this._buffers.shift();if(e<this._buffers[0].length){let i=this._buffers[0];return this._buffers[0]=new Mo(i.buffer,i.byteOffset+e,i.length-e),new Mo(i.buffer,i.byteOffset,e)}let r=Buffer.allocUnsafe(e);do{let i=this._buffers[0],o=r.length-e;e>=i.length?r.set(this._buffers.shift(),o):(r.set(new Uint8Array(i.buffer,i.byteOffset,e),o),this._buffers[0]=new Mo(i.buffer,i.byteOffset+e,i.length-e)),e-=i.length}while(e>0);return r}startLoop(e){this._loop=!0;do switch(this._state){case lt:this.getInfo(e);break;case bx:this.getPayloadLength16(e);break;case Ex:this.getPayloadLength64(e);break;case vx:this.getMask();break;case hd:this.getData(e);break;case pd:case Bo:this._loop=!1;return}while(this._loop);this._errored||e()}getInfo(e){if(this._bufferedBytes<2){this._loop=!1;return}let r=this.consume(2);if((r[0]&48)!==0){let o=this.createError(RangeError,"RSV2 and RSV3 must be clear",!0,1002,"WS_ERR_UNEXPECTED_RSV_2_3");e(o);return}let i=(r[0]&64)===64;if(i&&!this._extensions[mx.extensionName]){let o=this.createError(RangeError,"RSV1 must be clear",!0,1002,"WS_ERR_UNEXPECTED_RSV_1");e(o);return}if(this._fin=(r[0]&128)===128,this._opcode=r[0]&15,this._payloadLength=r[1]&127,this._opcode===0){if(i){let o=this.createError(RangeError,"RSV1 must be clear",!0,1002,"WS_ERR_UNEXPECTED_RSV_1");e(o);return}if(!this._fragmented){let o=this.createError(RangeError,"invalid opcode 0",!0,1002,"WS_ERR_INVALID_OPCODE");e(o);return}this._opcode=this._fragmented}else if(this._opcode===1||this._opcode===2){if(this._fragmented){let o=this.createError(RangeError,`invalid opcode ${this._opcode}`,!0,1002,"WS_ERR_INVALID_OPCODE");e(o);return}this._compressed=i}else if(this._opcode>7&&this._opcode<11){if(!this._fin){let o=this.createError(RangeError,"FIN must be set",!0,1002,"WS_ERR_EXPECTED_FIN");e(o);return}if(i){let o=this.createError(RangeError,"RSV1 must be clear",!0,1002,"WS_ERR_UNEXPECTED_RSV_1");e(o);return}if(this._payloadLength>125||this._opcode===8&&this._payloadLength===1){let o=this.createError(RangeError,`invalid payload length ${this._payloadLength}`,!0,1002,"WS_ERR_INVALID_CONTROL_PAYLOAD_LENGTH");e(o);return}}else{let o=this.createError(RangeError,`invalid opcode ${this._opcode}`,!0,1002,"WS_ERR_INVALID_OPCODE");e(o);return}if(!this._fin&&!this._fragmented&&(this._fragmented=this._opcode),this._masked=(r[1]&128)===128,this._isServer){if(!this._masked){let o=this.createError(RangeError,"MASK must be set",!0,1002,"WS_ERR_EXPECTED_MASK");e(o);return}}else if(this._masked){let o=this.createError(RangeError,"MASK must be clear",!0,1002,"WS_ERR_UNEXPECTED_MASK");e(o);return}this._payloadLength===126?this._state=bx:this._payloadLength===127?this._state=Ex:this.haveLength(e)}getPayloadLength16(e){if(this._bufferedBytes<2){this._loop=!1;return}this._payloadLength=this.consume(2).readUInt16BE(0),this.haveLength(e)}getPayloadLength64(e){if(this._bufferedBytes<8){this._loop=!1;return}let r=this.consume(8),i=r.readUInt32BE(0);if(i>Math.pow(2,21)-1){let o=this.createError(RangeError,"Unsupported WebSocket frame: payload length > 2^53 - 1",!1,1009,"WS_ERR_UNSUPPORTED_DATA_PAYLOAD_LENGTH");e(o);return}this._payloadLength=i*Math.pow(2,32)+r.readUInt32BE(4),this.haveLength(e)}haveLength(e){if(this._payloadLength&&this._opcode<8&&(this._totalPayloadLength+=this._payloadLength,this._totalPayloadLength>this._maxPayload&&this._maxPayload>0)){let r=this.createError(RangeError,"Max payload size exceeded",!1,1009,"WS_ERR_UNSUPPORTED_MESSAGE_LENGTH");e(r);return}this._masked?this._state=vx:this._state=hd}getMask(){if(this._bufferedBytes<4){this._loop=!1;return}this._mask=this.consume(4),this._state=hd}getData(e){let r=_x;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&&cE(r,this._mask)}if(this._opcode>7){this.controlMessage(r,e);return}if(this._compressed){this._state=pd,this.decompress(r,e);return}r.length&&(this._messageLength=this._totalPayloadLength,this._fragments.push(r)),this.dataMessage(e)}decompress(e,r){this._extensions[mx.extensionName].decompress(e,this._fin,(o,c)=>{if(o)return r(o);if(c.length){if(this._messageLength+=c.length,this._messageLength>this._maxPayload&&this._maxPayload>0){let l=this.createError(RangeError,"Max payload size exceeded",!1,1009,"WS_ERR_UNSUPPORTED_MESSAGE_LENGTH");r(l);return}this._fragments.push(c)}this.dataMessage(r),this._state===lt&&this.startLoop(r)})}dataMessage(e){if(!this._fin){this._state=lt;return}let r=this._messageLength,i=this._fragments;if(this._totalPayloadLength=0,this._messageLength=0,this._fragmented=0,this._fragments=[],this._opcode===2){let o;this._binaryType==="nodebuffer"?o=xd(i,r):this._binaryType==="arraybuffer"?o=aE(xd(i,r)):this._binaryType==="blob"?o=new Blob(i):o=i,this._allowSynchronousEvents?(this.emit("message",o,!0),this._state=lt):(this._state=Bo,setImmediate(()=>{this.emit("message",o,!0),this._state=lt,this.startLoop(e)}))}else{let o=xd(i,r);if(!this._skipUTF8Validation&&!yx(o)){let c=this.createError(Error,"invalid UTF-8 sequence",!0,1007,"WS_ERR_INVALID_UTF8");e(c);return}this._state===pd||this._allowSynchronousEvents?(this.emit("message",o,!1),this._state=lt):(this._state=Bo,setImmediate(()=>{this.emit("message",o,!1),this._state=lt,this.startLoop(e)}))}}controlMessage(e,r){if(this._opcode===8){if(e.length===0)this._loop=!1,this.emit("conclude",1005,_x),this.end();else{let i=e.readUInt16BE(0);if(!dE(i)){let c=this.createError(RangeError,`invalid status code ${i}`,!0,1002,"WS_ERR_INVALID_CLOSE_CODE");r(c);return}let o=new Mo(e.buffer,e.byteOffset+2,e.length-2);if(!this._skipUTF8Validation&&!yx(o)){let c=this.createError(Error,"invalid UTF-8 sequence",!0,1007,"WS_ERR_INVALID_UTF8");r(c);return}this._loop=!1,this.emit("conclude",i,o),this.end()}this._state=lt;return}this._allowSynchronousEvents?(this.emit(this._opcode===9?"ping":"pong",e),this._state=lt):(this._state=Bo,setImmediate(()=>{this.emit(this._opcode===9?"ping":"pong",e),this._state=lt,this.startLoop(r)}))}createError(e,r,i,o,c){this._loop=!1,this._errored=!0;let l=new e(i?`Invalid WebSocket frame: ${r}`:r);return Error.captureStackTrace(l,this.createError),l.code=c,l[sE]=o,l}};Sx.exports=gd});var yd=oe((cC,Tx)=>{"use strict";var{Duplex:aC}=le("stream"),{randomFillSync:lE}=le("crypto"),Ax=kr(),{EMPTY_BUFFER:fE,kWebSocket:uE,NOOP:xE}=Kt(),{isBlob:Pr,isValidStatusCode:hE}=Or(),{mask:Ix,toBuffer:qn}=qi(),ft=Symbol("kByteLength"),pE=Buffer.alloc(4),Fo=8*1024,Hn,Nr=Fo,Et=0,gE=1,mE=2,wd=class t{constructor(e,r,i){this._extensions=r||{},i&&(this._generateMask=i,this._maskBuffer=Buffer.alloc(4)),this._socket=e,this._firstFragment=!0,this._compress=!1,this._bufferedBytes=0,this._queue=[],this._state=Et,this.onerror=xE,this[uE]=void 0}static frame(e,r){let i,o=!1,c=2,l=!1;r.mask&&(i=r.maskBuffer||pE,r.generateMask?r.generateMask(i):(Nr===Fo&&(Hn===void 0&&(Hn=Buffer.alloc(Fo)),lE(Hn,0,Fo),Nr=0),i[0]=Hn[Nr++],i[1]=Hn[Nr++],i[2]=Hn[Nr++],i[3]=Hn[Nr++]),l=(i[0]|i[1]|i[2]|i[3])===0,c=6);let f;typeof e=="string"?(!r.mask||l)&&r[ft]!==void 0?f=r[ft]:(e=Buffer.from(e),f=e.length):(f=e.length,o=r.mask&&r.readOnly&&!l);let x=f;f>=65536?(c+=8,x=127):f>125&&(c+=2,x=126);let h=Buffer.allocUnsafe(o?f+c:c);return h[0]=r.fin?r.opcode|128:r.opcode,r.rsv1&&(h[0]|=64),h[1]=x,x===126?h.writeUInt16BE(f,2):x===127&&(h[2]=h[3]=0,h.writeUIntBE(f,4,6)),r.mask?(h[1]|=128,h[c-4]=i[0],h[c-3]=i[1],h[c-2]=i[2],h[c-1]=i[3],l?[h,e]:o?(Ix(e,i,h,c,f),[h]):(Ix(e,i,e,0,f),[h,e])):[h,e]}close(e,r,i,o){let c;if(e===void 0)c=fE;else{if(typeof e!="number"||!hE(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 f=Buffer.byteLength(r);if(f>123)throw new RangeError("The message must not be greater than 123 bytes");c=Buffer.allocUnsafe(2+f),c.writeUInt16BE(e,0),typeof r=="string"?c.write(r,2):c.set(r,2)}}let l={[ft]:c.length,fin:!0,generateMask:this._generateMask,mask:i,maskBuffer:this._maskBuffer,opcode:8,readOnly:!1,rsv1:!1};this._state!==Et?this.enqueue([this.dispatch,c,!1,l,o]):this.sendFrame(t.frame(c,l),o)}ping(e,r,i){let o,c;if(typeof e=="string"?(o=Buffer.byteLength(e),c=!1):Pr(e)?(o=e.size,c=!1):(e=qn(e),o=e.length,c=qn.readOnly),o>125)throw new RangeError("The data size must not be greater than 125 bytes");let l={[ft]:o,fin:!0,generateMask:this._generateMask,mask:r,maskBuffer:this._maskBuffer,opcode:9,readOnly:c,rsv1:!1};Pr(e)?this._state!==Et?this.enqueue([this.getBlobData,e,!1,l,i]):this.getBlobData(e,!1,l,i):this._state!==Et?this.enqueue([this.dispatch,e,!1,l,i]):this.sendFrame(t.frame(e,l),i)}pong(e,r,i){let o,c;if(typeof e=="string"?(o=Buffer.byteLength(e),c=!1):Pr(e)?(o=e.size,c=!1):(e=qn(e),o=e.length,c=qn.readOnly),o>125)throw new RangeError("The data size must not be greater than 125 bytes");let l={[ft]:o,fin:!0,generateMask:this._generateMask,mask:r,maskBuffer:this._maskBuffer,opcode:10,readOnly:c,rsv1:!1};Pr(e)?this._state!==Et?this.enqueue([this.getBlobData,e,!1,l,i]):this.getBlobData(e,!1,l,i):this._state!==Et?this.enqueue([this.dispatch,e,!1,l,i]):this.sendFrame(t.frame(e,l),i)}send(e,r,i){let o=this._extensions[Ax.extensionName],c=r.binary?2:1,l=r.compress,f,x;typeof e=="string"?(f=Buffer.byteLength(e),x=!1):Pr(e)?(f=e.size,x=!1):(e=qn(e),f=e.length,x=qn.readOnly),this._firstFragment?(this._firstFragment=!1,l&&o&&o.params[o._isServer?"server_no_context_takeover":"client_no_context_takeover"]&&(l=f>=o._threshold),this._compress=l):(l=!1,c=0),r.fin&&(this._firstFragment=!0);let h={[ft]:f,fin:r.fin,generateMask:this._generateMask,mask:r.mask,maskBuffer:this._maskBuffer,opcode:c,readOnly:x,rsv1:l};Pr(e)?this._state!==Et?this.enqueue([this.getBlobData,e,this._compress,h,i]):this.getBlobData(e,this._compress,h,i):this._state!==Et?this.enqueue([this.dispatch,e,this._compress,h,i]):this.dispatch(e,this._compress,h,i)}getBlobData(e,r,i,o){this._bufferedBytes+=i[ft],this._state=mE,e.arrayBuffer().then(c=>{if(this._socket.destroyed){let f=new Error("The socket was closed while the blob was being read");process.nextTick(_d,this,f,o);return}this._bufferedBytes-=i[ft];let l=qn(c);r?this.dispatch(l,r,i,o):(this._state=Et,this.sendFrame(t.frame(l,i),o),this.dequeue())}).catch(c=>{process.nextTick(wE,this,c,o)})}dispatch(e,r,i,o){if(!r){this.sendFrame(t.frame(e,i),o);return}let c=this._extensions[Ax.extensionName];this._bufferedBytes+=i[ft],this._state=gE,c.compress(e,i.fin,(l,f)=>{if(this._socket.destroyed){let x=new Error("The socket was closed while data was being compressed");_d(this,x,o);return}this._bufferedBytes-=i[ft],this._state=Et,i.readOnly=!1,this.sendFrame(t.frame(f,i),o),this.dequeue()})}dequeue(){for(;this._state===Et&&this._queue.length;){let e=this._queue.shift();this._bufferedBytes-=e[3][ft],Reflect.apply(e[0],this,e.slice(1))}}enqueue(e){this._bufferedBytes+=e[3][ft],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)}};Tx.exports=wd;function _d(t,e,r){typeof r=="function"&&r(e);for(let i=0;i<t._queue.length;i++){let o=t._queue[i],c=o[o.length-1];typeof c=="function"&&c(e)}}function wE(t,e,r){_d(t,e,r),t.onerror(e)}});var Mx=oe((dC,Lx)=>{"use strict";var{kForOnEventAttribute:ji,kListener:bd}=Kt(),Cx=Symbol("kCode"),Rx=Symbol("kData"),Dx=Symbol("kError"),kx=Symbol("kMessage"),Ox=Symbol("kReason"),Lr=Symbol("kTarget"),Px=Symbol("kType"),Nx=Symbol("kWasClean"),Vt=class{constructor(e){this[Lr]=null,this[Px]=e}get target(){return this[Lr]}get type(){return this[Px]}};Object.defineProperty(Vt.prototype,"target",{enumerable:!0});Object.defineProperty(Vt.prototype,"type",{enumerable:!0});var jn=class extends Vt{constructor(e,r={}){super(e),this[Cx]=r.code===void 0?0:r.code,this[Ox]=r.reason===void 0?"":r.reason,this[Nx]=r.wasClean===void 0?!1:r.wasClean}get code(){return this[Cx]}get reason(){return this[Ox]}get wasClean(){return this[Nx]}};Object.defineProperty(jn.prototype,"code",{enumerable:!0});Object.defineProperty(jn.prototype,"reason",{enumerable:!0});Object.defineProperty(jn.prototype,"wasClean",{enumerable:!0});var Mr=class extends Vt{constructor(e,r={}){super(e),this[Dx]=r.error===void 0?null:r.error,this[kx]=r.message===void 0?"":r.message}get error(){return this[Dx]}get message(){return this[kx]}};Object.defineProperty(Mr.prototype,"error",{enumerable:!0});Object.defineProperty(Mr.prototype,"message",{enumerable:!0});var Wi=class extends Vt{constructor(e,r={}){super(e),this[Rx]=r.data===void 0?null:r.data}get data(){return this[Rx]}};Object.defineProperty(Wi.prototype,"data",{enumerable:!0});var _E={addEventListener(t,e,r={}){for(let o of this.listeners(t))if(!r[ji]&&o[bd]===e&&!o[ji])return;let i;if(t==="message")i=function(c,l){let f=new Wi("message",{data:l?c:c.toString()});f[Lr]=this,zo(e,this,f)};else if(t==="close")i=function(c,l){let f=new jn("close",{code:c,reason:l.toString(),wasClean:this._closeFrameReceived&&this._closeFrameSent});f[Lr]=this,zo(e,this,f)};else if(t==="error")i=function(c){let l=new Mr("error",{error:c,message:c.message});l[Lr]=this,zo(e,this,l)};else if(t==="open")i=function(){let c=new Vt("open");c[Lr]=this,zo(e,this,c)};else return;i[ji]=!!r[ji],i[bd]=e,r.once?this.once(t,i):this.on(t,i)},removeEventListener(t,e){for(let r of this.listeners(t))if(r[bd]===e&&!r[ji]){this.removeListener(t,r);break}}};Lx.exports={CloseEvent:jn,ErrorEvent:Mr,Event:Vt,EventTarget:_E,MessageEvent:Wi};function zo(t,e,r){typeof t=="object"&&t.handleEvent?t.handleEvent.call(t,r):t.call(e,r)}});var Uo=oe((lC,Bx)=>{"use strict";var{tokenChars:Ki}=Or();function Mt(t,e,r){t[e]===void 0?t[e]=[r]:t[e].push(r)}function yE(t){let e=Object.create(null),r=Object.create(null),i=!1,o=!1,c=!1,l,f,x=-1,h=-1,_=-1,w=0;for(;w<t.length;w++)if(h=t.charCodeAt(w),l===void 0)if(_===-1&&Ki[h]===1)x===-1&&(x=w);else if(w!==0&&(h===32||h===9))_===-1&&x!==-1&&(_=w);else if(h===59||h===44){if(x===-1)throw new SyntaxError(`Unexpected character at index ${w}`);_===-1&&(_=w);let b=t.slice(x,_);h===44?(Mt(e,b,r),r=Object.create(null)):l=b,x=_=-1}else throw new SyntaxError(`Unexpected character at index ${w}`);else if(f===void 0)if(_===-1&&Ki[h]===1)x===-1&&(x=w);else if(h===32||h===9)_===-1&&x!==-1&&(_=w);else if(h===59||h===44){if(x===-1)throw new SyntaxError(`Unexpected character at index ${w}`);_===-1&&(_=w),Mt(r,t.slice(x,_),!0),h===44&&(Mt(e,l,r),r=Object.create(null),l=void 0),x=_=-1}else if(h===61&&x!==-1&&_===-1)f=t.slice(x,w),x=_=-1;else throw new SyntaxError(`Unexpected character at index ${w}`);else if(o){if(Ki[h]!==1)throw new SyntaxError(`Unexpected character at index ${w}`);x===-1?x=w:i||(i=!0),o=!1}else if(c)if(Ki[h]===1)x===-1&&(x=w);else if(h===34&&x!==-1)c=!1,_=w;else if(h===92)o=!0;else throw new SyntaxError(`Unexpected character at index ${w}`);else if(h===34&&t.charCodeAt(w-1)===61)c=!0;else if(_===-1&&Ki[h]===1)x===-1&&(x=w);else if(x!==-1&&(h===32||h===9))_===-1&&(_=w);else if(h===59||h===44){if(x===-1)throw new SyntaxError(`Unexpected character at index ${w}`);_===-1&&(_=w);let b=t.slice(x,_);i&&(b=b.replace(/\\/g,""),i=!1),Mt(r,f,b),h===44&&(Mt(e,l,r),r=Object.create(null),l=void 0),f=void 0,x=_=-1}else throw new SyntaxError(`Unexpected character at index ${w}`);if(x===-1||c||h===32||h===9)throw new SyntaxError("Unexpected end of input");_===-1&&(_=w);let S=t.slice(x,_);return l===void 0?Mt(e,S,r):(f===void 0?Mt(r,S,!0):i?Mt(r,f,S.replace(/\\/g,"")):Mt(r,f,S),Mt(e,l,r)),e}function bE(t){return Object.keys(t).map(e=>{let r=t[e];return Array.isArray(r)||(r=[r]),r.map(i=>[e].concat(Object.keys(i).map(o=>{let c=i[o];return Array.isArray(c)||(c=[c]),c.map(l=>l===!0?o:`${o}=${l}`).join("; ")})).join("; ")).join(", ")}).join(", ")}Bx.exports={format:bE,parse:yE}});var jo=oe((xC,Yx)=>{"use strict";var EE=le("events"),vE=le("https"),SE=le("http"),Ux=le("net"),AE=le("tls"),{randomBytes:IE,createHash:TE}=le("crypto"),{Duplex:fC,Readable:uC}=le("stream"),{URL:Ed}=le("url"),vn=kr(),CE=md(),RE=yd(),{isBlob:DE}=Or(),{BINARY_TYPES:Fx,CLOSE_TIMEOUT:kE,EMPTY_BUFFER:Go,GUID:OE,kForOnEventAttribute:vd,kListener:PE,kStatusCode:NE,kWebSocket:Ue,NOOP:Gx}=Kt(),{EventTarget:{addEventListener:LE,removeEventListener:ME}}=Mx(),{format:BE,parse:FE}=Uo(),{toBuffer:zE}=qi(),qx=Symbol("kAborted"),Sd=[8,13],Yt=["CONNECTING","OPEN","CLOSING","CLOSED"],UE=/^[!#$%&'*+\-.0-9A-Z^_`|a-z~]+$/,ge=class t extends EE{constructor(e,r,i){super(),this._binaryType=Fx[0],this._closeCode=1006,this._closeFrameReceived=!1,this._closeFrameSent=!1,this._closeMessage=Go,this._closeTimer=null,this._errorEmitted=!1,this._extensions={},this._paused=!1,this._protocol="",this._readyState=t.CONNECTING,this._receiver=null,this._sender=null,this._socket=null,e!==null?(this._bufferedAmount=0,this._isServer=!1,this._redirects=0,r===void 0?r=[]:Array.isArray(r)||(typeof r=="object"&&r!==null?(i=r,r=[]):r=[r]),Hx(this,e,r,i)):(this._autoPong=i.autoPong,this._closeTimeout=i.closeTimeout,this._isServer=!0)}get binaryType(){return this._binaryType}set binaryType(e){Fx.includes(e)&&(this._binaryType=e,this._receiver&&(this._receiver._binaryType=e))}get bufferedAmount(){return this._socket?this._socket._writableState.length+this._sender._bufferedBytes:this._bufferedAmount}get extensions(){return Object.keys(this._extensions).join()}get isPaused(){return this._paused}get onclose(){return null}get onerror(){return null}get onopen(){return null}get onmessage(){return null}get protocol(){return this._protocol}get readyState(){return this._readyState}get url(){return this._url}setSocket(e,r,i){let o=new CE({allowSynchronousEvents:i.allowSynchronousEvents,binaryType:this.binaryType,extensions:this._extensions,isServer:this._isServer,maxPayload:i.maxPayload,skipUTF8Validation:i.skipUTF8Validation}),c=new RE(e,this._extensions,i.generateMask);this._receiver=o,this._sender=c,this._socket=e,o[Ue]=this,c[Ue]=this,e[Ue]=this,o.on("conclude",HE),o.on("drain",jE),o.on("error",WE),o.on("message",KE),o.on("ping",$E),o.on("pong",VE),c.onerror=YE,e.setTimeout&&e.setTimeout(0),e.setNoDelay&&e.setNoDelay(),r.length>0&&e.unshift(r),e.on("close",Kx),e.on("data",Ho),e.on("end",$x),e.on("error",Vx),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[vn.extensionName]&&this._extensions[vn.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){st(this,this._req,"WebSocket was closed before the connection was established");return}if(this.readyState===t.CLOSING){this._closeFrameSent&&(this._closeFrameReceived||this._receiver._writableState.errorEmitted)&&this._socket.end();return}this._readyState=t.CLOSING,this._sender.close(e,r,!this._isServer,i=>{i||(this._closeFrameSent=!0,(this._closeFrameReceived||this._receiver._writableState.errorEmitted)&&this._socket.end())}),Wx(this)}}pause(){this.readyState===t.CONNECTING||this.readyState===t.CLOSED||(this._paused=!0,this._socket.pause())}ping(e,r,i){if(this.readyState===t.CONNECTING)throw new Error("WebSocket is not open: readyState 0 (CONNECTING)");if(typeof e=="function"?(i=e,e=r=void 0):typeof r=="function"&&(i=r,r=void 0),typeof e=="number"&&(e=e.toString()),this.readyState!==t.OPEN){Ad(this,e,i);return}r===void 0&&(r=!this._isServer),this._sender.ping(e||Go,r,i)}pong(e,r,i){if(this.readyState===t.CONNECTING)throw new Error("WebSocket is not open: readyState 0 (CONNECTING)");if(typeof e=="function"?(i=e,e=r=void 0):typeof r=="function"&&(i=r,r=void 0),typeof e=="number"&&(e=e.toString()),this.readyState!==t.OPEN){Ad(this,e,i);return}r===void 0&&(r=!this._isServer),this._sender.pong(e||Go,r,i)}resume(){this.readyState===t.CONNECTING||this.readyState===t.CLOSED||(this._paused=!1,this._receiver._writableState.needDrain||this._socket.resume())}send(e,r,i){if(this.readyState===t.CONNECTING)throw new Error("WebSocket is not open: readyState 0 (CONNECTING)");if(typeof r=="function"&&(i=r,r={}),typeof e=="number"&&(e=e.toString()),this.readyState!==t.OPEN){Ad(this,e,i);return}let o={binary:typeof e!="string",mask:!this._isServer,compress:!0,fin:!0,...r};this._extensions[vn.extensionName]||(o.compress=!1),this._sender.send(e||Go,o,i)}terminate(){if(this.readyState!==t.CLOSED){if(this.readyState===t.CONNECTING){st(this,this._req,"WebSocket was closed before the connection was established");return}this._socket&&(this._readyState=t.CLOSING,this._socket.destroy())}}};Object.defineProperty(ge,"CONNECTING",{enumerable:!0,value:Yt.indexOf("CONNECTING")});Object.defineProperty(ge.prototype,"CONNECTING",{enumerable:!0,value:Yt.indexOf("CONNECTING")});Object.defineProperty(ge,"OPEN",{enumerable:!0,value:Yt.indexOf("OPEN")});Object.defineProperty(ge.prototype,"OPEN",{enumerable:!0,value:Yt.indexOf("OPEN")});Object.defineProperty(ge,"CLOSING",{enumerable:!0,value:Yt.indexOf("CLOSING")});Object.defineProperty(ge.prototype,"CLOSING",{enumerable:!0,value:Yt.indexOf("CLOSING")});Object.defineProperty(ge,"CLOSED",{enumerable:!0,value:Yt.indexOf("CLOSED")});Object.defineProperty(ge.prototype,"CLOSED",{enumerable:!0,value:Yt.indexOf("CLOSED")});["binaryType","bufferedAmount","extensions","isPaused","protocol","readyState","url"].forEach(t=>{Object.defineProperty(ge.prototype,t,{enumerable:!0})});["open","error","close","message"].forEach(t=>{Object.defineProperty(ge.prototype,`on${t}`,{enumerable:!0,get(){for(let e of this.listeners(t))if(e[vd])return e[PE];return null},set(e){for(let r of this.listeners(t))if(r[vd]){this.removeListener(t,r);break}typeof e=="function"&&this.addEventListener(t,e,{[vd]:!0})}})});ge.prototype.addEventListener=LE;ge.prototype.removeEventListener=ME;Yx.exports=ge;function Hx(t,e,r,i){let o={allowSynchronousEvents:!0,autoPong:!0,closeTimeout:kE,protocolVersion:Sd[1],maxPayload:104857600,skipUTF8Validation:!1,perMessageDeflate:!0,followRedirects:!1,maxRedirects:10,...i,socketPath:void 0,hostname:void 0,protocol:void 0,timeout:void 0,method:"GET",host:void 0,path:void 0,port:void 0};if(t._autoPong=o.autoPong,t._closeTimeout=o.closeTimeout,!Sd.includes(o.protocolVersion))throw new RangeError(`Unsupported protocol version: ${o.protocolVersion} (supported versions: ${Sd.join(", ")})`);let c;if(e instanceof Ed)c=e;else try{c=new Ed(e)}catch{throw new SyntaxError(`Invalid URL: ${e}`)}c.protocol==="http:"?c.protocol="ws:":c.protocol==="https:"&&(c.protocol="wss:"),t._url=c.href;let l=c.protocol==="wss:",f=c.protocol==="ws+unix:",x;if(c.protocol!=="ws:"&&!l&&!f?x=`The URL's protocol must be one of "ws:", "wss:", "http:", "https:", or "ws+unix:"`:f&&!c.pathname?x="The URL's pathname is empty":c.hash&&(x="The URL contains a fragment identifier"),x){let I=new SyntaxError(x);if(t._redirects===0)throw I;qo(t,I);return}let h=l?443:80,_=IE(16).toString("base64"),w=l?vE.request:SE.request,S=new Set,b;if(o.createConnection=o.createConnection||(l?qE:GE),o.defaultPort=o.defaultPort||h,o.port=c.port||h,o.host=c.hostname.startsWith("[")?c.hostname.slice(1,-1):c.hostname,o.headers={...o.headers,"Sec-WebSocket-Version":o.protocolVersion,"Sec-WebSocket-Key":_,Connection:"Upgrade",Upgrade:"websocket"},o.path=c.pathname+c.search,o.timeout=o.handshakeTimeout,o.perMessageDeflate&&(b=new vn({...o.perMessageDeflate,isServer:!1,maxPayload:o.maxPayload}),o.headers["Sec-WebSocket-Extensions"]=BE({[vn.extensionName]:b.offer()})),r.length){for(let I of r){if(typeof I!="string"||!UE.test(I)||S.has(I))throw new SyntaxError("An invalid or duplicated subprotocol was specified");S.add(I)}o.headers["Sec-WebSocket-Protocol"]=r.join(",")}if(o.origin&&(o.protocolVersion<13?o.headers["Sec-WebSocket-Origin"]=o.origin:o.headers.Origin=o.origin),(c.username||c.password)&&(o.auth=`${c.username}:${c.password}`),f){let I=o.path.split(":");o.socketPath=I[0],o.path=I[1]}let v;if(o.followRedirects){if(t._redirects===0){t._originalIpc=f,t._originalSecure=l,t._originalHostOrSocketPath=f?o.socketPath:c.host;let I=i&&i.headers;if(i={...i,headers:{}},I)for(let[A,C]of Object.entries(I))i.headers[A.toLowerCase()]=C}else if(t.listenerCount("redirect")===0){let I=f?t._originalIpc?o.socketPath===t._originalHostOrSocketPath:!1:t._originalIpc?!1:c.host===t._originalHostOrSocketPath;(!I||t._originalSecure&&!l)&&(delete o.headers.authorization,delete o.headers.cookie,I||delete o.headers.host,o.auth=void 0)}o.auth&&!i.headers.authorization&&(i.headers.authorization="Basic "+Buffer.from(o.auth).toString("base64")),v=t._req=w(o),t._redirects&&t.emit("redirect",t.url,v)}else v=t._req=w(o);o.timeout&&v.on("timeout",()=>{st(t,v,"Opening handshake has timed out")}),v.on("error",I=>{v===null||v[qx]||(v=t._req=null,qo(t,I))}),v.on("response",I=>{let A=I.headers.location,C=I.statusCode;if(A&&o.followRedirects&&C>=300&&C<400){if(++t._redirects>o.maxRedirects){st(t,v,"Maximum redirects exceeded");return}v.abort();let P;try{P=new Ed(A,e)}catch{let R=new SyntaxError(`Invalid URL: ${A}`);qo(t,R);return}Hx(t,P,r,i)}else t.emit("unexpected-response",v,I)||st(t,v,`Unexpected server response: ${I.statusCode}`)}),v.on("upgrade",(I,A,C)=>{if(t.emit("upgrade",I),t.readyState!==ge.CONNECTING)return;v=t._req=null;let P=I.headers.upgrade;if(P===void 0||P.toLowerCase()!=="websocket"){st(t,A,"Invalid Upgrade header");return}let y=TE("sha1").update(_+OE).digest("base64");if(I.headers["sec-websocket-accept"]!==y){st(t,A,"Invalid Sec-WebSocket-Accept header");return}let R=I.headers["sec-websocket-protocol"],D;if(R!==void 0?S.size?S.has(R)||(D="Server sent an invalid subprotocol"):D="Server sent a subprotocol but none was requested":S.size&&(D="Server sent no subprotocol"),D){st(t,A,D);return}R&&(t._protocol=R);let B=I.headers["sec-websocket-extensions"];if(B!==void 0){if(!b){st(t,A,"Server sent a Sec-WebSocket-Extensions header but no extension was requested");return}let G;try{G=FE(B)}catch{st(t,A,"Invalid Sec-WebSocket-Extensions header");return}let Y=Object.keys(G);if(Y.length!==1||Y[0]!==vn.extensionName){st(t,A,"Server indicated an extension that was not requested");return}try{b.accept(G[vn.extensionName])}catch{st(t,A,"Invalid Sec-WebSocket-Extensions header");return}t._extensions[vn.extensionName]=b}t.setSocket(A,C,{allowSynchronousEvents:o.allowSynchronousEvents,generateMask:o.generateMask,maxPayload:o.maxPayload,skipUTF8Validation:o.skipUTF8Validation})}),o.finishRequest?o.finishRequest(v,t):v.end()}function qo(t,e){t._readyState=ge.CLOSING,t._errorEmitted=!0,t.emit("error",e),t.emitClose()}function GE(t){return t.path=t.socketPath,Ux.connect(t)}function qE(t){return t.path=void 0,!t.servername&&t.servername!==""&&(t.servername=Ux.isIP(t.host)?"":t.host),AE.connect(t)}function st(t,e,r){t._readyState=ge.CLOSING;let i=new Error(r);Error.captureStackTrace(i,st),e.setHeader?(e[qx]=!0,e.abort(),e.socket&&!e.socket.destroyed&&e.socket.destroy(),process.nextTick(qo,t,i)):(e.destroy(i),e.once("error",t.emit.bind(t,"error")),e.once("close",t.emitClose.bind(t)))}function Ad(t,e,r){if(e){let i=DE(e)?e.size:zE(e).length;t._socket?t._sender._bufferedBytes+=i:t._bufferedAmount+=i}if(r){let i=new Error(`WebSocket is not open: readyState ${t.readyState} (${Yt[t.readyState]})`);process.nextTick(r,i)}}function HE(t,e){let r=this[Ue];r._closeFrameReceived=!0,r._closeMessage=e,r._closeCode=t,r._socket[Ue]!==void 0&&(r._socket.removeListener("data",Ho),process.nextTick(jx,r._socket),t===1005?r.close():r.close(t,e))}function jE(){let t=this[Ue];t.isPaused||t._socket.resume()}function WE(t){let e=this[Ue];e._socket[Ue]!==void 0&&(e._socket.removeListener("data",Ho),process.nextTick(jx,e._socket),e.close(t[NE])),e._errorEmitted||(e._errorEmitted=!0,e.emit("error",t))}function zx(){this[Ue].emitClose()}function KE(t,e){this[Ue].emit("message",t,e)}function $E(t){let e=this[Ue];e._autoPong&&e.pong(t,!this._isServer,Gx),e.emit("ping",t)}function VE(t){this[Ue].emit("pong",t)}function jx(t){t.resume()}function YE(t){let e=this[Ue];e.readyState!==ge.CLOSED&&(e.readyState===ge.OPEN&&(e._readyState=ge.CLOSING,Wx(e)),this._socket.end(),e._errorEmitted||(e._errorEmitted=!0,e.emit("error",t)))}function Wx(t){t._closeTimer=setTimeout(t._socket.destroy.bind(t._socket),t._closeTimeout)}function Kx(){let t=this[Ue];if(this.removeListener("close",Kx),this.removeListener("data",Ho),this.removeListener("end",$x),t._readyState=ge.CLOSING,!this._readableState.endEmitted&&!t._closeFrameReceived&&!t._receiver._writableState.errorEmitted&&this._readableState.length!==0){let e=this.read(this._readableState.length);t._receiver.write(e)}t._receiver.end(),this[Ue]=void 0,clearTimeout(t._closeTimer),t._receiver._writableState.finished||t._receiver._writableState.errorEmitted?t.emitClose():(t._receiver.on("error",zx),t._receiver.on("finish",zx))}function Ho(t){this[Ue]._receiver.write(t)||this.pause()}function $x(){let t=this[Ue];t._readyState=ge.CLOSING,t._receiver.end(),this.end()}function Vx(){let t=this[Ue];this.removeListener("error",Vx),this.on("error",Gx),t&&(t._readyState=ge.CLOSING,this.destroy())}});var Qx=oe((pC,Xx)=>{"use strict";var hC=jo(),{Duplex:JE}=le("stream");function Jx(t){t.emit("close")}function ZE(){!this.destroyed&&this._writableState.finished&&this.destroy()}function Zx(t){this.removeListener("error",Zx),this.destroy(),this.listenerCount("error")===0&&this.emit("error",t)}function XE(t,e){let r=!0,i=new JE({...e,autoDestroy:!1,emitClose:!1,objectMode:!1,writableObjectMode:!1});return t.on("message",function(c,l){let f=!l&&i._readableState.objectMode?c.toString():c;i.push(f)||t.pause()}),t.once("error",function(c){i.destroyed||(r=!1,i.destroy(c))}),t.once("close",function(){i.destroyed||i.push(null)}),i._destroy=function(o,c){if(t.readyState===t.CLOSED){c(o),process.nextTick(Jx,i);return}let l=!1;t.once("error",function(x){l=!0,c(x)}),t.once("close",function(){l||c(o),process.nextTick(Jx,i)}),r&&t.terminate()},i._final=function(o){if(t.readyState===t.CONNECTING){t.once("open",function(){i._final(o)});return}t._socket!==null&&(t._socket._writableState.finished?(o(),i._readableState.endEmitted&&i.destroy()):(t._socket.once("finish",function(){o()}),t.close()))},i._read=function(){t.isPaused&&t.resume()},i._write=function(o,c,l){if(t.readyState===t.CONNECTING){t.once("open",function(){i._write(o,c,l)});return}t.send(o,l)},i.on("end",ZE),i.on("error",Zx),i}Xx.exports=XE});var Id=oe((gC,eh)=>{"use strict";var{tokenChars:QE}=Or();function ev(t){let e=new Set,r=-1,i=-1,o=0;for(o;o<t.length;o++){let l=t.charCodeAt(o);if(i===-1&&QE[l]===1)r===-1&&(r=o);else if(o!==0&&(l===32||l===9))i===-1&&r!==-1&&(i=o);else if(l===44){if(r===-1)throw new SyntaxError(`Unexpected character at index ${o}`);i===-1&&(i=o);let f=t.slice(r,i);if(e.has(f))throw new SyntaxError(`The "${f}" subprotocol is duplicated`);e.add(f),r=i=-1}else throw new SyntaxError(`Unexpected character at index ${o}`)}if(r===-1||i!==-1)throw new SyntaxError("Unexpected end of input");let c=t.slice(r,o);if(e.has(c))throw new SyntaxError(`The "${c}" subprotocol is duplicated`);return e.add(c),e}eh.exports={parse:ev}});var ah=oe((wC,oh)=>{"use strict";var tv=le("events"),Wo=le("http"),{Duplex:mC}=le("stream"),{createHash:nv}=le("crypto"),th=Uo(),Wn=kr(),rv=Id(),iv=jo(),{CLOSE_TIMEOUT:sv,GUID:ov,kWebSocket:av}=Kt(),cv=/^[+/0-9A-Za-z]{22}==$/,nh=0,rh=1,sh=2,Td=class extends tv{constructor(e,r){if(super(),e={allowSynchronousEvents:!0,autoPong:!0,maxPayload:100*1024*1024,skipUTF8Validation:!1,perMessageDeflate:!1,handleProtocols:null,clientTracking:!0,closeTimeout:sv,verifyClient:null,noServer:!1,backlog:null,server:null,host:null,path:null,port:null,WebSocket:iv,...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=Wo.createServer((i,o)=>{let c=Wo.STATUS_CODES[426];o.writeHead(426,{"Content-Length":c.length,"Content-Type":"text/plain"}),o.end(c)}),this._server.listen(e.port,e.host,e.backlog,r)):e.server&&(this._server=e.server),this._server){let i=this.emit.bind(this,"connection");this._removeListeners=dv(this._server,{listening:this.emit.bind(this,"listening"),error:this.emit.bind(this,"error"),upgrade:(o,c,l)=>{this.handleUpgrade(o,c,l,i)}})}e.perMessageDeflate===!0&&(e.perMessageDeflate={}),e.clientTracking&&(this.clients=new Set,this._shouldEmitClose=!1),this.options=e,this._state=nh}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===sh){e&&this.once("close",()=>{e(new Error("The server is not running"))}),process.nextTick($i,this);return}if(e&&this.once("close",e),this._state!==rh)if(this._state=rh,this.options.noServer||this.options.server)this._server&&(this._removeListeners(),this._removeListeners=this._server=null),this.clients?this.clients.size?this._shouldEmitClose=!0:process.nextTick($i,this):process.nextTick($i,this);else{let r=this._server;this._removeListeners(),this._removeListeners=this._server=null,r.close(()=>{$i(this)})}}shouldHandle(e){if(this.options.path){let r=e.url.indexOf("?");if((r!==-1?e.url.slice(0,r):e.url)!==this.options.path)return!1}return!0}handleUpgrade(e,r,i,o){r.on("error",ih);let c=e.headers["sec-websocket-key"],l=e.headers.upgrade,f=+e.headers["sec-websocket-version"];if(e.method!=="GET"){Kn(this,e,r,405,"Invalid HTTP method");return}if(l===void 0||l.toLowerCase()!=="websocket"){Kn(this,e,r,400,"Invalid Upgrade header");return}if(c===void 0||!cv.test(c)){Kn(this,e,r,400,"Missing or invalid Sec-WebSocket-Key header");return}if(f!==13&&f!==8){Kn(this,e,r,400,"Missing or invalid Sec-WebSocket-Version header",{"Sec-WebSocket-Version":"13, 8"});return}if(!this.shouldHandle(e)){Vi(r,400);return}let x=e.headers["sec-websocket-protocol"],h=new Set;if(x!==void 0)try{h=rv.parse(x)}catch{Kn(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 Wn({...this.options.perMessageDeflate,isServer:!0,maxPayload:this.options.maxPayload});try{let b=th.parse(_);b[Wn.extensionName]&&(S.accept(b[Wn.extensionName]),w[Wn.extensionName]=S)}catch{Kn(this,e,r,400,"Invalid or unacceptable Sec-WebSocket-Extensions header");return}}if(this.options.verifyClient){let S={origin:e.headers[`${f===8?"sec-websocket-origin":"origin"}`],secure:!!(e.socket.authorized||e.socket.encrypted),req:e};if(this.options.verifyClient.length===2){this.options.verifyClient(S,(b,v,I,A)=>{if(!b)return Vi(r,v||401,I,A);this.completeUpgrade(w,c,h,e,r,i,o)});return}if(!this.options.verifyClient(S))return Vi(r,401)}this.completeUpgrade(w,c,h,e,r,i,o)}completeUpgrade(e,r,i,o,c,l,f){if(!c.readable||!c.writable)return c.destroy();if(c[av])throw new Error("server.handleUpgrade() was called more than once with the same socket, possibly due to a misconfiguration");if(this._state>nh)return Vi(c,503);let h=["HTTP/1.1 101 Switching Protocols","Upgrade: websocket","Connection: Upgrade",`Sec-WebSocket-Accept: ${nv("sha1").update(r+ov).digest("base64")}`],_=new this.options.WebSocket(null,void 0,this.options);if(i.size){let w=this.options.handleProtocols?this.options.handleProtocols(i,o):i.values().next().value;w&&(h.push(`Sec-WebSocket-Protocol: ${w}`),_._protocol=w)}if(e[Wn.extensionName]){let w=e[Wn.extensionName].params,S=th.format({[Wn.extensionName]:[w]});h.push(`Sec-WebSocket-Extensions: ${S}`),_._extensions=e}this.emit("headers",h,o),c.write(h.concat(`\r
|
|
10
|
+
`),this.stream=void 0;return}this.currentDate!==void 0&&es(this.dir,this.prefix,e,this.opts.retentionDays),this.currentDate=e}close(){this.stream?.end(),this.stream=void 0,this.currentDate=void 0}}});import{appendFileSync as Yp,mkdirSync as Xp}from"node:fs";import{join as Qp}from"node:path";function il(t){let e=t.retentionDays??ng,r=t.clock??(()=>An(new Date));ns={bridgeSink:new Kr(t.bridgeLogsDir,"bridge",{retentionDays:e,clock:r}),agentSinks:new Map,makeAgentSink:o=>new Kr(t.agentLogsDir(o),"agent",{retentionDays:e,clock:r})};let i=r();es(t.bridgeLogsDir,"bridge",i,e);for(let o of t.listAgentIds?.()??[])es(t.agentLogsDir(o),"agent",i,e)}function rg(t,e){let r=t.agentSinks.get(e);return r||(r=t.makeAgentSink(e),t.agentSinks.set(e,r)),r}function sl(t){_a=t}function ol(t){return Qn[_a]<=Qn[t]}function al(t,e){let r=Qn[t];return r===void 0?!0:r>=Qn[e]}function rs(t){rl={...t}}function cl(t){let e=(u,h=2)=>String(u).padStart(h,"0"),r=-t.getTimezoneOffset(),i=r>=0?"+":"-",o=Math.abs(r),c=e(Math.floor(o/60)),l=e(o%60);return`${An(t)}T${e(t.getHours())}:${e(t.getMinutes())}:${e(t.getSeconds())}.${e(t.getMilliseconds(),3)}${i}${c}:${l}`}function $r(t,e,r,i,o){try{let c=`${JSON.stringify({ts:cl(new Date),level:e,module:r,msg:i,...o})}
|
|
11
|
+
`;Xp(t,{recursive:!0}),Yp(Qp(t,Xn("bridge",An(new Date))),c)}catch{}}function ig(t,e){if(t)return t;let r=e?.agentId;return typeof r=="string"&&r.length>0?r:void 0}function ts(t,e,r,i,o){if(Qn[t]<Qn[_a])return;let c=`${JSON.stringify({ts:cl(new Date),level:t,module:e,msg:r,...rl,...i})}
|
|
12
|
+
`;if(ns){let l=ig(o,i),u=l?rg(ns,l):ns.bridgeSink;try{u.write(c)}catch{process.stderr.write(c)}return}t==="error"||t==="warn"?tg.write(c):eg.write(c)}function G(t,e){return{debug:(r,i)=>ts("debug",t,r,i,e),info:(r,i)=>ts("info",t,r,i,e),warn:(r,i)=>ts("warn",t,r,i,e),error:(r,i)=>ts("error",t,r,i,e),child:r=>G(`${t}.${r}`,e),forAgent:r=>G(t,r)}}var Qn,_a,eg,tg,rl,ng,ns,ne=Je(()=>{"use strict";Wr();wa();Qn={debug:10,info:20,warn:30,error:40},_a=(()=>{let t=process.env.COZE_BRIDGE_LOG_LEVEL;return t==="debug"||t==="info"||t==="warn"||t==="error"?t:"info"})(),eg=process.stdout,tg=process.stderr,rl={},ng=Ye("COZE_BRIDGE_LOG_RETENTION_DAYS",30),ns=null});var T,Ke=Je(()=>{"use strict";T=class extends Error{code;retriable;cause;constructor(e,r,i){super(r),this.name="BridgeError",this.code=e,this.retriable=i?.retriable??!1,i?.cause!==void 0&&(this.cause=i.cause)}}});var fl={};ga(fl,{ACP_WRAPPER_NPM_PACKAGES:()=>Zr,_resetAcpInstallerForTests:()=>lg,_setBinaryPathCacheForTests:()=>ug,buildAcpSpawn:()=>Jr,ensureAcpInstalled:()=>er,getAcpBinaryPath:()=>is,pickWhichLine:()=>Ea,probeAcpVersion:()=>dg,resolveAcpCommand:()=>ul});import{readFileSync as dl}from"node:fs";import{createRequire as sg}from"node:module";import{dirname as og,resolve as ag}from"node:path";function Ea(t){let e=t.split(/\r?\n/).map(i=>i.trim()).filter(Boolean);if(e.length===0)return;if(process.platform!=="win32")return e[0];let r=i=>e.find(o=>o.toLowerCase().endsWith(i));return r(".cmd")??r(".exe")??r(".bat")??r(".ps1")??e[0]}function cg(t){let e=ll.resolve(`${t.npmPackage}/package.json`),r=og(e),i=JSON.parse(dl(e,"utf8")),o=typeof i.bin=="string"?i.bin:i.bin?.[t.binary];if(!o)throw new Error(`${t.npmPackage} package.json \u7F3A bin[${t.binary}]`);return ag(r,o)}async function er(t,e){let r=ba[t];if(!r)throw new T("BRIDGE_INTERNAL",`ensureAcpInstalled called for non-npm framework: ${t}`);let i=Vr.get(t);if(i)return i;try{let o=cg(r);return Vr.set(t,o),ya.info("acp wrapper resolved",{framework:t,binary:r.binary,path:o}),o}catch(o){throw ya.warn("acp wrapper \u89E3\u6790\u5931\u8D25 (\u672A\u968F\u5305\u56FA\u5316\u5230 lib/node_modules?)",{framework:t,npmPackage:r.npmPackage,err:String(o)}),new T("AGENT_DEPENDENCY_INSTALL_FAILED",[`ACP wrapper \u672A\u5C31\u7EEA: ${r.npmPackage} (framework=${t})`,"\u8BE5 wrapper \u968F coze-bridge \u4E00\u8D77\u5B89\u88C5 (\u56FA\u5316\u5230 ~/.coze/bridge/lib/node_modules)\u3002","\u8BF7\u91CD\u8DD1 `coze-bridge pair` / `connect` \u89E6\u53D1\u56FA\u5316\u5B89\u88C5; \u82E5\u4ECD\u5931\u8D25, \u68C0\u67E5\u7F51\u7EDC / npm \u7F13\u5B58\u3002"].join(`
|
|
13
|
+
`),{cause:o})}}async function dg(t){let e=ba[t];if(e)try{let r=ll.resolve(`${e.npmPackage}/package.json`),i=JSON.parse(dl(r,"utf8"));return typeof i.version=="string"&&i.version.length>0?i.version:void 0}catch(r){ya.warn("acp wrapper probe: \u89E3\u6790 package.json \u5931\u8D25",{framework:t,npmPackage:e.npmPackage,err:String(r)});return}}function is(t){return Vr.get(t)}function ul(t,e){if(e)return e;let r=is(t);if(!r)throw new T("BRIDGE_INTERNAL",`${t} ACP wrapper \u8DEF\u5F84\u672A\u89E3\u6790 (ensureAcpInstalled \u672A\u5728\u6784\u9020\u524D\u8DD1\u901A)`);return r}function Jr(t,e,r){if(e)return{command:e,args:[...r]};let i=ul(t);return{command:process.execPath,args:[i,...r]}}function lg(){Vr.clear()}function ug(t,e){Vr.set(t,e)}var ya,ba,Zr,ll,Vr,nn=Je(()=>{"use strict";Ke();ne();ya=G("agents.acp-installer"),ba={"claude-code":{npmPackage:"@agentclientprotocol/claude-agent-acp",binary:"claude-agent-acp"},codex:{npmPackage:"@zed-industries/codex-acp",binary:"codex-acp"}},Zr=Object.values(ba).filter(t=>t!==void 0).map(t=>t.npmPackage),ll=sg(import.meta.url),Vr=new Map});import{chmod as hg,mkdir as xg,readFile as pg,rename as pl,writeFile as gl}from"node:fs/promises";import{dirname as gg}from"node:path";async function tr(t){try{let e=await pg(t,"utf8");return JSON.parse(e)}catch(e){if(e.code==="ENOENT")return null;throw e}}async function nr(t,e,r){await xg(gg(t),{recursive:!0});let i=`${JSON.stringify(e,null,2)}
|
|
14
|
+
`,o=`${t}.tmp-${process.pid}-${Math.random().toString(36).slice(2,10)}`;try{r?.mode!==void 0?await gl(o,i,{encoding:"utf8",mode:r.mode}):await gl(o,i,"utf8"),await pl(o,t),r?.mode!==void 0&&await hg(t,r.mode)}catch(c){await pl(o,o).catch(()=>{});let{rm:l}=await import("node:fs/promises");throw await l(o,{force:!0}).catch(()=>{}),c}}var Yr=Je(()=>{"use strict"});import{promises as ml,readdirSync as mg}from"node:fs";import{homedir as wg}from"node:os";import{sep as _g,join as Re,resolve as wl}from"node:path";function Y(t){let e=t??wg(),r=Re(e,".coze"),i=Re(r,"bridge"),o=Re(i,"lib"),c=Re(i,"logs");return{cozeRoot:r,bridgeRoot:i,libDir:o,libEntry:Re(o,"index.js"),binDir:Re(i,"bin"),pidFile:Re(i,"bridge.pid"),portFile:Re(i,"bridge.port"),tokenFile:Re(i,"bridge.token"),patTokenFile:Re(i,"pat-token"),agentEnvFile:Re(i,"agent-env.json"),logFile:Re(i,"bridge.log"),bridgeLogsDir:c,daemonStdioLog:Re(c,"daemon-stdio.log"),installLock:Re(i,"install.lock"),configFile:Re(i,"config.json"),agentsRoot:Re(r,"agents")}}function Xe(t,e=Y()){let r=Re(e.agentsRoot,t);return{root:r,config:Re(r,"config.json"),workspace:Re(r,"workspace"),logs:Re(r,"logs")}}function ss(t=Y()){try{return mg(t.agentsRoot,{withFileTypes:!0}).filter(e=>e.isDirectory()).map(e=>e.name)}catch{return[]}}async function Xr(t,e){let r=await ml.realpath(wl(t)).catch(()=>null);if(!r)return!1;let i=await ml.realpath(wl(e)).catch(()=>null);if(!i)return!1;let o=process.platform==="win32"?r.toLowerCase():r,c=process.platform==="win32"?i.toLowerCase():i;return o===c||o.startsWith(c+_g)}var Le=Je(()=>{"use strict"});var cs={};ga(cs,{AGENT_CONFIG_FILE_MODE:()=>os,enforceAgentConfigMode:()=>Eg,loadAgentConfig:()=>Be,persistAgentSessions:()=>Qr,persistAgentSkills:()=>as,saveAgentConfig:()=>Qe});import{chmod as yg,stat as bg}from"node:fs/promises";function Be(t,e){return tr(Xe(t,e).config)}function Qe(t,e){return nr(Xe(t.agentId,e).config,t,{mode:os})}async function Eg(t,e){if(process.platform==="win32")return;let r=Xe(t,e).config;try{let i=await bg(r);if(!i.isFile())return;let o=i.mode&511;o!==os&&(await yg(r,os),_l.warn("agent config mode auto-corrected to 0600",{path:r,from:o.toString(8)}))}catch(i){if(i.code==="ENOENT")return;_l.warn("enforceAgentConfigMode: chmod failed (ignored)",{path:r,err:String(i)})}}async function Qr(t,e,r){let i=await Be(t,r);i&&(i.sessions=Object.fromEntries(e),await Qe(i,r))}async function as(t,e,r){let i=await Be(t,r);i&&(i.skills=e,await Qe(i,r))}var _l,os,rn=Je(()=>{"use strict";Yr();ne();Le();_l=G("agent-config"),os=384});var Sa=ae((e2,vl)=>{vl.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 ls=ae(Il=>{var Sl={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 Tg(t){return function(...e){return e.length&&(t=t.replace(/\{(\d)\}/g,(r,i)=>e[i]||"")),new Error("ADM-ZIP: "+t)}}for(let t of Object.keys(Sl))Il[t]=Tg(Sl[t])});var Dl=ae((n2,Cl)=>{var Rg=ue("fs"),Oe=ue("path"),Al=Sa(),Cg=ls(),Dg=typeof process=="object"&&process.platform==="win32",Tl=t=>typeof t=="object"&&t!==null,Rl=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 ve(t){this.sep=Oe.sep,this.fs=Rg,Tl(t)&&Tl(t.fs)&&typeof t.fs.statSync=="function"&&(this.fs=t.fs)}Cl.exports=ve;ve.prototype.makeDir=function(t){let e=this;function r(i){let o=i.split(e.sep)[0];i.split(e.sep).forEach(function(c){if(!(!c||c.substr(-1,1)===":")){o+=e.sep+c;var l;try{l=e.fs.statSync(o)}catch(u){if(u.message&&u.message.startsWith("ENOENT"))e.fs.mkdirSync(o);else throw u}if(l&&l.isFile())throw Cg.FILE_IN_THE_WAY(`"${o}"`)}})}r(t)};ve.prototype.writeFileTo=function(t,e,r,i){let o=this;if(o.fs.existsSync(t)){if(!r)return!1;var c=o.fs.statSync(t);if(c.isDirectory())return!1}var l=Oe.dirname(t);o.fs.existsSync(l)||o.makeDir(l);var u;try{u=o.fs.openSync(t,"w",438)}catch{o.fs.chmodSync(t,438),u=o.fs.openSync(t,"w",438)}if(u)try{o.fs.writeSync(u,e,0,e.length,0)}finally{o.fs.closeSync(u)}return o.fs.chmodSync(t,i||438),!0};ve.prototype.writeFileToAsync=function(t,e,r,i,o){typeof i=="function"&&(o=i,i=void 0);let c=this;c.fs.exists(t,function(l){if(l&&!r)return o(!1);c.fs.stat(t,function(u,h){if(l&&h.isDirectory())return o(!1);var x=Oe.dirname(t);c.fs.exists(x,function(w){w||c.makeDir(x),c.fs.open(t,"w",438,function(E,I){E?c.fs.chmod(t,438,function(){c.fs.open(t,"w",438,function(b,v){c.fs.write(v,e,0,e.length,0,function(){c.fs.close(v,function(){c.fs.chmod(t,i||438,function(){o(!0)})})})})}):I?c.fs.write(I,e,0,e.length,0,function(){c.fs.close(I,function(){c.fs.chmod(t,i||438,function(){o(!0)})})}):c.fs.chmod(t,i||438,function(){o(!0)})})})})})};ve.prototype.findFiles=function(t){let e=this;function r(i,o,c){typeof o=="boolean"&&(c=o,o=void 0);let l=[];return e.fs.readdirSync(i).forEach(function(u){let h=Oe.join(i,u),x=e.fs.statSync(h);(!o||o.test(h))&&l.push(Oe.normalize(h)+(x.isDirectory()?e.sep:"")),x.isDirectory()&&c&&(l=l.concat(r(h,o,c)))}),l}return r(t,void 0,!0)};ve.prototype.findFilesAsync=function(t,e){let r=this,i=[];r.fs.readdir(t,function(o,c){if(o)return e(o);let l=c.length;if(!l)return e(null,i);c.forEach(function(u){u=Oe.join(t,u),r.fs.stat(u,function(h,x){if(h)return e(h);x&&(i.push(Oe.normalize(u)+(x.isDirectory()?r.sep:"")),x.isDirectory()?r.findFilesAsync(u,function(w,E){if(w)return e(w);i=i.concat(E),--l||e(null,i)}):--l||e(null,i))})})})};ve.prototype.getAttributes=function(){};ve.prototype.setAttributes=function(){};ve.crc32update=function(t,e){return Rl[(t^e)&255]^t>>>8};ve.crc32=function(t){typeof t=="string"&&(t=Buffer.from(t,"utf8"));let e=t.length,r=-1;for(let i=0;i<e;)r=ve.crc32update(r,t[i++]);return~r>>>0};ve.methodToString=function(t){switch(t){case Al.STORED:return"STORED ("+t+")";case Al.DEFLATED:return"DEFLATED ("+t+")";default:return"UNSUPPORTED ("+t+")"}};ve.canonical=function(t){if(!t)return"";let e=Oe.posix.normalize("/"+t.split("\\").join("/"));return Oe.join(".",e)};ve.zipnamefix=function(t){if(!t)return"";let e=Oe.posix.normalize("/"+t.split("\\").join("/"));return Oe.posix.join(".",e)};ve.findLast=function(t,e){if(!Array.isArray(t))throw new TypeError("arr is not array");let r=t.length>>>0;for(let i=r-1;i>=0;i--)if(e(t[i],i,t))return t[i]};ve.sanitize=function(t,e){t=Oe.resolve(Oe.normalize(t));for(var r=e.split("/"),i=0,o=r.length;i<o;i++){var c=Oe.normalize(Oe.join(t,r.slice(i,o).join(Oe.sep)));if(c.indexOf(t)===0)return c}return Oe.normalize(Oe.join(t,Oe.basename(e)))};ve.toBuffer=function(e,r){return Buffer.isBuffer(e)?e:e instanceof Uint8Array?Buffer.from(e):typeof e=="string"?r(e):Buffer.alloc(0)};ve.readBigUInt64LE=function(t,e){let r=t.readUInt32LE(e);return t.readUInt32LE(e+4)*4294967296+r};ve.fromDOS2Date=function(t){return new Date((t>>25&127)+1980,Math.max((t>>21&15)-1,0),Math.max(t>>16&31,1),t>>11&31,t>>5&63,(t&31)<<1)};ve.fromDate2DOS=function(t){let e=0,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};ve.isWin=Dg;ve.crcTable=Rl});var Pl=ae((r2,kl)=>{var kg=ue("path");kl.exports=function(t,{fs:e}){var r=t||"",i=c(),o=null;function c(){return{directory:!1,readonly:!1,hidden:!1,executable:!1,mtime:0,atime:0}}return r&&e.existsSync(r)?(o=e.statSync(r),i.directory=o.isDirectory(),i.mtime=o.mtime,i.atime=o.atime,i.executable=(73&o.mode)!==0,i.readonly=(128&o.mode)===0,i.hidden=kg.basename(r)[0]==="."):console.warn("Invalid path: "+r),{get directory(){return i.directory},get readOnly(){return i.readonly},get hidden(){return i.hidden},get mtime(){return i.mtime},get atime(){return i.atime},get executable(){return i.executable},decodeAttributes:function(){},encodeAttributes:function(){},toJSON:function(){return{path:r,isDirectory:i.directory,isReadOnly:i.readonly,isHidden:i.hidden,isExecutable:i.executable,mTime:i.mtime,aTime:i.atime}},toString:function(){return JSON.stringify(this.toJSON(),null," ")}}}});var Ol=ae((i2,Ll)=>{Ll.exports={efs:!0,encode:t=>Buffer.from(t,"utf8"),decode:t=>t.toString("utf8")}});var sr=ae((s2,ir)=>{ir.exports=Dl();ir.exports.Constants=Sa();ir.exports.Errors=ls();ir.exports.FileAttr=Pl();ir.exports.decoder=Ol()});var Ml=ae((o2,Nl)=>{var sn=sr(),U=sn.Constants;Nl.exports=function(){var t=20,e=10,r=0,i=0,o=0,c=0,l=0,u=0,h=0,x=0,w=0,E=0,I=0,b=0,v=0;t|=sn.isWin?2560:768,r|=U.FLG_EFS;let A={extraLen:0},S=_=>Math.max(0,_)>>>0,R=_=>Math.max(0,_)&65535,O=_=>Math.max(0,_)&255;return o=sn.fromDate2DOS(new Date),{get made(){return t},set made(_){t=_},get version(){return e},set version(_){e=_},get flags(){return r},set flags(_){r=_},get flags_efs(){return(r&U.FLG_EFS)>0},set flags_efs(_){_?r|=U.FLG_EFS:r&=~U.FLG_EFS},get flags_desc(){return(r&U.FLG_DESC)>0},set flags_desc(_){_?r|=U.FLG_DESC:r&=~U.FLG_DESC},get method(){return i},set method(_){switch(_){case U.STORED:this.version=10;case U.DEFLATED:default:this.version=20}i=_},get time(){return sn.fromDOS2Date(this.timeval)},set time(_){_=new Date(_),this.timeval=sn.fromDate2DOS(_)},get timeval(){return o},set timeval(_){o=S(_)},get timeHighByte(){return O(o>>>8)},get crc(){return c},set crc(_){c=S(_)},get compressedSize(){return l},set compressedSize(_){l=S(_)},get size(){return u},set size(_){u=S(_)},get fileNameLength(){return h},set fileNameLength(_){h=_},get extraLength(){return x},set extraLength(_){x=_},get extraLocalLength(){return A.extraLen},set extraLocalLength(_){A.extraLen=_},get commentLength(){return w},set commentLength(_){w=_},get diskNumStart(){return E},set diskNumStart(_){E=S(_)},get inAttr(){return I},set inAttr(_){I=S(_)},get attr(){return b},set attr(_){b=S(_)},get fileAttr(){return(b||0)>>16&4095},get offset(){return v},set offset(_){v=S(_)},get encrypted(){return(r&U.FLG_ENC)===U.FLG_ENC},get centralHeaderSize(){return U.CENHDR+h+x+w},get realDataOffset(){return v+U.LOCHDR+A.fnameLen+A.extraLen},get localHeader(){return A},loadLocalHeaderFromBinary:function(_){var C=_.slice(v,v+U.LOCHDR);if(C.readUInt32LE(0)!==U.LOCSIG)throw sn.Errors.INVALID_LOC();A.version=C.readUInt16LE(U.LOCVER),A.flags=C.readUInt16LE(U.LOCFLG),A.flags_desc=(A.flags&U.FLG_DESC)>0,A.method=C.readUInt16LE(U.LOCHOW),A.time=C.readUInt32LE(U.LOCTIM),A.crc=C.readUInt32LE(U.LOCCRC),A.compressedSize=C.readUInt32LE(U.LOCSIZ),A.size=C.readUInt32LE(U.LOCLEN),A.fnameLen=C.readUInt16LE(U.LOCNAM),A.extraLen=C.readUInt16LE(U.LOCEXT);let D=v+U.LOCHDR+A.fnameLen,M=D+A.extraLen;return _.slice(D,M)},loadFromBinary:function(_){if(_.length!==U.CENHDR||_.readUInt32LE(0)!==U.CENSIG)throw sn.Errors.INVALID_CEN();t=_.readUInt16LE(U.CENVEM),e=_.readUInt16LE(U.CENVER),r=_.readUInt16LE(U.CENFLG),i=_.readUInt16LE(U.CENHOW),o=_.readUInt32LE(U.CENTIM),c=_.readUInt32LE(U.CENCRC),l=_.readUInt32LE(U.CENSIZ),u=_.readUInt32LE(U.CENLEN),h=_.readUInt16LE(U.CENNAM),x=_.readUInt16LE(U.CENEXT),w=_.readUInt16LE(U.CENCOM),E=_.readUInt16LE(U.CENDSK),I=_.readUInt16LE(U.CENATT),b=_.readUInt32LE(U.CENATX),v=_.readUInt32LE(U.CENOFF)},localHeaderToBinary:function(){var _=Buffer.alloc(U.LOCHDR);return _.writeUInt32LE(U.LOCSIG,0),_.writeUInt16LE(e,U.LOCVER),_.writeUInt16LE(r,U.LOCFLG),_.writeUInt16LE(i,U.LOCHOW),_.writeUInt32LE(o,U.LOCTIM),_.writeUInt32LE(c,U.LOCCRC),_.writeUInt32LE(l,U.LOCSIZ),_.writeUInt32LE(u,U.LOCLEN),_.writeUInt16LE(h,U.LOCNAM),_.writeUInt16LE(A.extraLen,U.LOCEXT),_},centralHeaderToBinary:function(){var _=Buffer.alloc(U.CENHDR+h+x+w);return _.writeUInt32LE(U.CENSIG,0),_.writeUInt16LE(t,U.CENVEM),_.writeUInt16LE(e,U.CENVER),_.writeUInt16LE(r,U.CENFLG),_.writeUInt16LE(i,U.CENHOW),_.writeUInt32LE(o,U.CENTIM),_.writeUInt32LE(c,U.CENCRC),_.writeUInt32LE(l,U.CENSIZ),_.writeUInt32LE(u,U.CENLEN),_.writeUInt16LE(h,U.CENNAM),_.writeUInt16LE(x,U.CENEXT),_.writeUInt16LE(w,U.CENCOM),_.writeUInt16LE(E,U.CENDSK),_.writeUInt16LE(I,U.CENATT),_.writeUInt32LE(b,U.CENATX),_.writeUInt32LE(v,U.CENOFF),_},toJSON:function(){let _=function(C){return C+" bytes"};return{made:t,version:e,flags:r,method:sn.methodToString(i),time:this.time,crc:"0x"+c.toString(16).toUpperCase(),compressedSize:_(l),size:_(u),fileNameLength:_(h),extraLength:_(x),commentLength:_(w),diskNumStart:E,inAttr:I,attr:b,offset:v,centralHeaderSize:_(U.CENHDR+h+x+w)}},toString:function(){return JSON.stringify(this.toJSON(),null," ")}}}});var zl=ae((a2,Bl)=>{var or=sr(),_e=or.Constants;Bl.exports=function(){var t=0,e=0,r=0,i=0,o=0;return{get diskEntries(){return t},set diskEntries(c){t=e=c},get totalEntries(){return e},set totalEntries(c){e=t=c},get size(){return r},set size(c){r=c},get offset(){return i},set offset(c){i=c},get commentLength(){return o},set commentLength(c){o=c},get mainHeaderSize(){return _e.ENDHDR+o},loadFromBinary:function(c){if((c.length!==_e.ENDHDR||c.readUInt32LE(0)!==_e.ENDSIG)&&(c.length<_e.ZIP64HDR||c.readUInt32LE(0)!==_e.ZIP64SIG))throw or.Errors.INVALID_END();c.readUInt32LE(0)===_e.ENDSIG?(t=c.readUInt16LE(_e.ENDSUB),e=c.readUInt16LE(_e.ENDTOT),r=c.readUInt32LE(_e.ENDSIZ),i=c.readUInt32LE(_e.ENDOFF),o=c.readUInt16LE(_e.ENDCOM)):(t=or.readBigUInt64LE(c,_e.ZIP64SUB),e=or.readBigUInt64LE(c,_e.ZIP64TOT),r=or.readBigUInt64LE(c,_e.ZIP64SIZE),i=or.readBigUInt64LE(c,_e.ZIP64OFF),o=0)},toBinary:function(){var c=Buffer.alloc(_e.ENDHDR+o);return c.writeUInt32LE(_e.ENDSIG,0),c.writeUInt32LE(0,4),c.writeUInt16LE(t,_e.ENDSUB),c.writeUInt16LE(e,_e.ENDTOT),c.writeUInt32LE(r,_e.ENDSIZ),c.writeUInt32LE(i,_e.ENDOFF),c.writeUInt16LE(o,_e.ENDCOM),c.fill(" ",_e.ENDHDR),c},toJSON:function(){let c=function(l,u){let h=l.toString(16).toUpperCase();for(;h.length<u;)h="0"+h;return"0x"+h};return{diskEntries:t,totalEntries:e,size:r+" bytes",offset:c(i,4),commentLength:o}},toString:function(){return JSON.stringify(this.toJSON(),null," ")}}}});var Aa=ae(Ia=>{Ia.EntryHeader=Ml();Ia.MainHeader=zl()});var Ul=ae((d2,Fl)=>{Fl.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(i){var o=e.createDeflateRaw(r),c=[],l=0;o.on("data",function(u){c.push(u),l+=u.length}),o.on("end",function(){var u=Buffer.alloc(l),h=0;u.fill(0);for(var x=0;x<c.length;x++){var w=c[x];w.copy(u,h),h+=w.length}i&&i(u)}),o.end(t)}}}});var ql=ae((l2,Gl)=>{var Pg=+(process.versions?process.versions.node:"").split(".")[0]||0;Gl.exports=function(t,e){var r=ue("zlib");let i=Pg>=15&&e>0?{maxOutputLength:e}:{};return{inflate:function(){return r.inflateRawSync(t,i)},inflateAsync:function(o){var c=r.createInflateRaw(i),l=[],u=0;c.on("data",function(h){l.push(h),u+=h.length}),c.on("end",function(){var h=Buffer.alloc(u),x=0;h.fill(0);for(var w=0;w<l.length;w++){var E=l[w];E.copy(h,x),x+=E.length}o&&o(h)}),c.end(t)}}}});var $l=ae((u2,Kl)=>{"use strict";var{randomFillSync:Hl}=ue("crypto"),Lg=ls(),Og=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}),Wl=(t,e)=>Math.imul(t,e)>>>0,jl=(t,e)=>Og[(t^e)&255]^t>>>8,ei=()=>typeof Hl=="function"?Hl(Buffer.alloc(12)):ei.node();ei.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 us={genSalt:ei};function fs(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])}fs.prototype.updateKeys=function(t){let e=this.keys;return e[0]=jl(e[0],t),e[1]+=e[0]&255,e[1]=Wl(e[1],134775813)+1,e[2]=jl(e[2],e[1]>>>24),t};fs.prototype.next=function(){let t=(this.keys[2]|2)>>>0;return Wl(t,t^1)>>8&255};function Ng(t){let e=new fs(t);return function(r){let i=Buffer.alloc(r.length),o=0;for(let c of r)i[o++]=e.updateKeys(c^e.next());return i}}function Mg(t){let e=new fs(t);return function(r,i,o=0){i||(i=Buffer.alloc(r.length));for(let c of r){let l=e.next();i[o++]=c^l,e.updateKeys(c)}return i}}function Bg(t,e,r){if(!t||!Buffer.isBuffer(t)||t.length<12)return Buffer.alloc(0);let i=Ng(r),o=i(t.slice(0,12)),c=(e.flags&8)===8?e.timeHighByte:e.crc>>>24;if(o[11]!==c)throw Lg.WRONG_PASSWORD();return i(t.slice(12))}function zg(t){Buffer.isBuffer(t)&&t.length>=12?us.genSalt=function(){return t.slice(0,12)}:t==="node"?us.genSalt=ei.node:us.genSalt=ei}function Fg(t,e,r,i=!1){t==null&&(t=Buffer.alloc(0)),Buffer.isBuffer(t)||(t=Buffer.from(t.toString()));let o=Mg(r),c=us.genSalt();c[11]=e.crc>>>24&255,i&&(c[10]=e.crc>>>16&255);let l=Buffer.alloc(t.length+12);return o(c,l),o(t,l,12)}Kl.exports={decrypt:Bg,encrypt:Fg,_salter:zg}});var Vl=ae(hs=>{hs.Deflater=Ul();hs.Inflater=ql();hs.ZipCrypto=$l()});var Ra=ae((h2,Zl)=>{var ce=sr(),Ug=Aa(),Se=ce.Constants,Ta=Vl();Zl.exports=function(t,e){var r=new Ug.EntryHeader,i=Buffer.alloc(0),o=Buffer.alloc(0),c=!1,l=null,u=Buffer.alloc(0),h=Buffer.alloc(0),x=!0;let w=t,E=typeof w.decoder=="object"?w.decoder:ce.decoder;x=E.hasOwnProperty("efs")?E.efs:!1;function I(){return!e||!(e instanceof Uint8Array)?Buffer.alloc(0):(h=r.loadLocalHeaderFromBinary(e),e.slice(r.realDataOffset,r.realDataOffset+r.compressedSize))}function b(_){if(!r.flags_desc&&!r.localHeader.flags_desc){if(ce.crc32(_)!==r.localHeader.crc)return!1}else{let C={},D=r.realDataOffset+r.compressedSize;if(e.readUInt32LE(D)==Se.LOCSIG||e.readUInt32LE(D)==Se.CENSIG)throw ce.Errors.DESCRIPTOR_NOT_EXIST();if(e.readUInt32LE(D)==Se.EXTSIG)C.crc=e.readUInt32LE(D+Se.EXTCRC),C.compressedSize=e.readUInt32LE(D+Se.EXTSIZ),C.size=e.readUInt32LE(D+Se.EXTLEN);else if(e.readUInt16LE(D+12)===19280)C.crc=e.readUInt32LE(D+Se.EXTCRC-4),C.compressedSize=e.readUInt32LE(D+Se.EXTSIZ-4),C.size=e.readUInt32LE(D+Se.EXTLEN-4);else throw ce.Errors.DESCRIPTOR_UNKNOWN();if(C.compressedSize!==r.compressedSize||C.size!==r.size||C.crc!==r.crc)throw ce.Errors.DESCRIPTOR_FAULTY();if(ce.crc32(_)!==C.crc)return!1}return!0}function v(_,C,D){if(typeof C>"u"&&typeof _=="string"&&(D=_,_=void 0),c)return _&&C&&C(Buffer.alloc(0),ce.Errors.DIRECTORY_CONTENT_ERROR()),Buffer.alloc(0);var M=I();if(M.length===0)return _&&C&&C(M),M;if(r.encrypted){if(typeof D!="string"&&!Buffer.isBuffer(D))throw ce.Errors.INVALID_PASS_PARAM();M=Ta.ZipCrypto.decrypt(M,r,D)}var B=Buffer.alloc(r.size);switch(r.method){case ce.Constants.STORED:if(M.copy(B),b(B))return _&&C&&C(B),B;throw _&&C&&C(B,ce.Errors.BAD_CRC()),ce.Errors.BAD_CRC();case ce.Constants.DEFLATED:var V=new Ta.Inflater(M,r.size);if(_)V.inflateAsync(function(Z){Z.copy(Z,0),C&&(b(Z)?C(Z):C(Z,ce.Errors.BAD_CRC()))});else{if(V.inflate(B).copy(B,0),!b(B))throw ce.Errors.BAD_CRC(`"${E.decode(i)}"`);return B}break;default:throw _&&C&&C(Buffer.alloc(0),ce.Errors.UNKNOWN_METHOD()),ce.Errors.UNKNOWN_METHOD()}}function A(_,C){if((!l||!l.length)&&Buffer.isBuffer(e))return _&&C&&C(I()),I();if(l.length&&!c){var D;switch(r.method){case ce.Constants.STORED:return r.compressedSize=r.size,D=Buffer.alloc(l.length),l.copy(D),_&&C&&C(D),D;default:case ce.Constants.DEFLATED:var M=new Ta.Deflater(l);if(_)M.deflateAsync(function(V){D=Buffer.alloc(V.length),r.compressedSize=V.length,V.copy(D),C&&C(D)});else{var B=M.deflate();return r.compressedSize=B.length,B}M=null;break}}else if(_&&C)C(Buffer.alloc(0));else return Buffer.alloc(0)}function S(_,C){return ce.readBigUInt64LE(_,C)}function R(_){try{for(var C=0,D,M,B;C+4<_.length;)D=_.readUInt16LE(C),C+=2,M=_.readUInt16LE(C),C+=2,B=_.slice(C,C+M),C+=M,Se.ID_ZIP64===D&&O(B)}catch{throw ce.Errors.EXTRA_FIELD_PARSE_ERROR()}}function O(_){var C,D,M,B;_.length>=Se.EF_ZIP64_SCOMP&&(C=S(_,Se.EF_ZIP64_SUNCOMP),r.size===Se.EF_ZIP64_OR_32&&(r.size=C)),_.length>=Se.EF_ZIP64_RHO&&(D=S(_,Se.EF_ZIP64_SCOMP),r.compressedSize===Se.EF_ZIP64_OR_32&&(r.compressedSize=D)),_.length>=Se.EF_ZIP64_DSN&&(M=S(_,Se.EF_ZIP64_RHO),r.offset===Se.EF_ZIP64_OR_32&&(r.offset=M)),_.length>=Se.EF_ZIP64_DSN+4&&(B=_.readUInt32LE(Se.EF_ZIP64_DSN),r.diskNumStart===Se.EF_ZIP64_OR_16&&(r.diskNumStart=B))}return{get entryName(){return E.decode(i)},get rawEntryName(){return i},set entryName(_){i=ce.toBuffer(_,E.encode);var C=i[i.length-1];c=C===47||C===92,r.fileNameLength=i.length},get efs(){return typeof x=="function"?x(this.entryName):x},get extra(){return u},set extra(_){u=_,r.extraLength=_.length,R(_)},get comment(){return E.decode(o)},set comment(_){if(o=ce.toBuffer(_,E.encode),r.commentLength=o.length,o.length>65535)throw ce.Errors.COMMENT_TOO_LONG()},get name(){var _=E.decode(i);return c?_.substr(_.length-1).split("/").pop():_.split("/").pop()},get isDirectory(){return c},getCompressedData:function(){return A(!1,null)},getCompressedDataAsync:function(_){A(!0,_)},setData:function(_){l=ce.toBuffer(_,ce.decoder.encode),!c&&l.length?(r.size=l.length,r.method=ce.Constants.DEFLATED,r.crc=ce.crc32(_),r.changed=!0):r.method=ce.Constants.STORED},getData:function(_){return r.changed?l:v(!1,null,_)},getDataAsync:function(_,C){r.changed?_(l):v(!0,_,C)},set attr(_){r.attr=_},get attr(){return r.attr},set header(_){r.loadFromBinary(_)},get header(){return r},packCentralHeader:function(){r.flags_efs=this.efs,r.extraLength=u.length;var _=r.centralHeaderToBinary(),C=ce.Constants.CENHDR;return i.copy(_,C),C+=i.length,u.copy(_,C),C+=r.extraLength,o.copy(_,C),_},packLocalHeader:function(){let _=0;r.flags_efs=this.efs,r.extraLocalLength=h.length;let C=r.localHeaderToBinary(),D=Buffer.alloc(C.length+i.length+r.extraLocalLength);return C.copy(D,_),_+=C.length,i.copy(D,_),_+=i.length,h.copy(D,_),_+=h.length,D},toJSON:function(){let _=function(C){return"<"+(C&&C.length+" bytes buffer"||"null")+">"};return{entryName:this.entryName,name:this.name,comment:this.comment,isDirectory:this.isDirectory,header:r.toJSON(),compressedData:_(e),data:_(l)}},toString:function(){return JSON.stringify(this.toJSON(),null," ")}}}});var Xl=ae((x2,Yl)=>{var Jl=Ra(),Gg=Aa(),je=sr();Yl.exports=function(t,e){var r=[],i={},o=Buffer.alloc(0),c=new Gg.MainHeader,l=!1,u=null;let h=new Set,x=e,{noSort:w,decoder:E}=x;t?v(x.readEntries):l=!0;function I(){let S=new Set;for(let R of Object.keys(i)){let O=R.split("/");if(O.pop(),!!O.length)for(let _=0;_<O.length;_++){let C=O.slice(0,_+1).join("/")+"/";S.add(C)}}for(let R of S)if(!(R in i)){let O=new Jl(x);O.entryName=R,O.attr=16,O.temporary=!0,r.push(O),i[O.entryName]=O,h.add(O)}}function b(){if(l=!0,i={},c.diskEntries>(t.length-c.offset)/je.Constants.CENHDR)throw je.Errors.DISK_ENTRY_TOO_LARGE();r=new Array(c.diskEntries);for(var S=c.offset,R=0;R<r.length;R++){var O=S,_=new Jl(x,t);_.header=t.slice(O,O+=je.Constants.CENHDR),_.entryName=t.slice(O,O+=_.header.fileNameLength),_.header.extraLength&&(_.extra=t.slice(O,O+=_.header.extraLength)),_.header.commentLength&&(_.comment=t.slice(O,O+_.header.commentLength)),S+=_.header.centralHeaderSize,r[R]=_,i[_.entryName]=_}h.clear(),I()}function v(S){var R=t.length-je.Constants.ENDHDR,O=Math.max(0,R-65535),_=O,C=t.length,D=-1,M=0;for(typeof x.trailingSpace=="boolean"&&x.trailingSpace&&(O=0),R;R>=_;R--)if(t[R]===80){if(t.readUInt32LE(R)===je.Constants.ENDSIG){D=R,M=R,C=R+je.Constants.ENDHDR,_=R-je.Constants.END64HDR;continue}if(t.readUInt32LE(R)===je.Constants.END64SIG){_=O;continue}if(t.readUInt32LE(R)===je.Constants.ZIP64SIG){D=R,C=R+je.readBigUInt64LE(t,R+je.Constants.ZIP64SIZE)+je.Constants.ZIP64LEAD;break}}if(D==-1)throw je.Errors.INVALID_FORMAT();c.loadFromBinary(t.slice(D,C)),c.commentLength&&(o=t.slice(M+je.Constants.ENDHDR)),S&&b()}function A(){r.length>1&&!w&&r.sort((S,R)=>S.entryName.toLowerCase().localeCompare(R.entryName.toLowerCase()))}return{get entries(){return l||b(),r.filter(S=>!h.has(S))},get comment(){return E.decode(o)},set comment(S){o=je.toBuffer(S,E.encode),c.commentLength=o.length},getEntryCount:function(){return l?r.length:c.diskEntries},forEach:function(S){this.entries.forEach(S)},getEntry:function(S){return l||b(),i[S]||null},setEntry:function(S){l||b(),r.push(S),i[S.entryName]=S,c.totalEntries=r.length},deleteFile:function(S,R=!0){l||b();let O=i[S];this.getEntryChildren(O,R).map(C=>C.entryName).forEach(this.deleteEntry)},deleteEntry:function(S){l||b();let R=i[S],O=r.indexOf(R);O>=0&&(r.splice(O,1),delete i[S],c.totalEntries=r.length)},getEntryChildren:function(S,R=!0){if(l||b(),typeof S=="object")if(S.isDirectory&&R){let O=[],_=S.entryName;for(let C of r)C.entryName.startsWith(_)&&O.push(C);return O}else return[S];return[]},getChildCount:function(S){if(S&&S.isDirectory){let R=this.getEntryChildren(S);return R.includes(S)?R.length-1:R.length}return 0},compressToBuffer:function(){l||b(),A();let S=[],R=[],O=0,_=0;c.size=0,c.offset=0;let C=0;for(let B of this.entries){let V=B.getCompressedData();B.header.offset=_;let Z=B.packLocalHeader(),ee=Z.length+V.length;_+=ee,S.push(Z),S.push(V);let X=B.packCentralHeader();R.push(X),c.size+=X.length,O+=ee+X.length,C++}O+=c.mainHeaderSize,c.offset=_,c.totalEntries=C,_=0;let D=Buffer.alloc(O);for(let B of S)B.copy(D,_),_+=B.length;for(let B of R)B.copy(D,_),_+=B.length;let M=c.toBinary();return o&&o.copy(M,je.Constants.ENDHDR),M.copy(D,_),t=D,l=!1,D},toAsyncBuffer:function(S,R,O,_){try{l||b(),A();let C=[],D=[],M=0,B=0,V=0;c.size=0,c.offset=0;let Z=function(ee){if(ee.length>0){let X=ee.shift(),Ee=X.entryName+X.extra.toString();O&&O(Ee),X.getCompressedDataAsync(function(pe){_&&_(Ee),X.header.offset=B;let P=X.packLocalHeader(),H=P.length+pe.length;B+=H,C.push(P),C.push(pe);let W=X.packCentralHeader();D.push(W),c.size+=W.length,M+=H+W.length,V++,Z(ee)})}else{M+=c.mainHeaderSize,c.offset=B,c.totalEntries=V,B=0;let X=Buffer.alloc(M);C.forEach(function(pe){pe.copy(X,B),B+=pe.length}),D.forEach(function(pe){pe.copy(X,B),B+=pe.length});let Ee=c.toBinary();o&&o.copy(Ee,je.Constants.ENDHDR),Ee.copy(X,B),t=X,l=!1,S(X)}};Z(Array.from(this.entries))}catch(C){R(C)}}}}});var tu=ae((p2,eu)=>{var be=sr(),ye=ue("path"),qg=Ra(),Hg=Xl(),Tn=(...t)=>be.findLast(t,e=>typeof e=="boolean"),Ql=(...t)=>be.findLast(t,e=>typeof e=="string"),jg=(...t)=>be.findLast(t,e=>typeof e=="function"),Wg={noSort:!1,readEntries:!1,method:be.Constants.NONE,fs:null};eu.exports=function(t,e){let r=null,i=Object.assign(Object.create(null),Wg);t&&typeof t=="object"&&(t instanceof Uint8Array||(Object.assign(i,t),t=i.input?i.input:void 0,i.input&&delete i.input),Buffer.isBuffer(t)&&(r=t,i.method=be.Constants.BUFFER,t=void 0)),Object.assign(i,e);let o=new be(i);if((typeof i.decoder!="object"||typeof i.decoder.encode!="function"||typeof i.decoder.decode!="function")&&(i.decoder=be.decoder),t&&typeof t=="string")if(o.fs.existsSync(t))i.method=be.Constants.FILE,i.filename=t,r=o.fs.readFileSync(t);else throw be.Errors.INVALID_FILENAME();let c=new Hg(r,i),{canonical:l,sanitize:u,zipnamefix:h}=be;function x(b){if(b&&c){var v;if(typeof b=="string"&&(v=c.getEntry(ye.posix.normalize(b))),typeof b=="object"&&typeof b.entryName<"u"&&typeof b.header<"u"&&(v=c.getEntry(b.entryName)),v)return v}return null}function w(b){let{join:v,normalize:A,sep:S}=ye.posix;return v(ye.isAbsolute(b)?"/":".",A(S+b.split("\\").join(S)+S))}function E(b){return b instanceof RegExp?(function(v){return function(A){return v.test(A)}})(b):typeof b!="function"?()=>!0:b}let I=(b,v)=>{let A=v.slice(-1);return A=A===o.sep?o.sep:"",ye.relative(b,v)+A};return{readFile:function(b,v){var A=x(b);return A&&A.getData(v)||null},childCount:function(b){let v=x(b);if(v)return c.getChildCount(v)},readFileAsync:function(b,v){var A=x(b);A?A.getDataAsync(v):v(null,"getEntry failed for:"+b)},readAsText:function(b,v){var A=x(b);if(A){var S=A.getData();if(S&&S.length)return S.toString(v||"utf8")}return""},readAsTextAsync:function(b,v,A){var S=x(b);S?S.getDataAsync(function(R,O){if(O){v(R,O);return}R&&R.length?v(R.toString(A||"utf8")):v("")}):v("")},deleteFile:function(b,v=!0){var A=x(b);A&&c.deleteFile(A.entryName,v)},deleteEntry:function(b){var v=x(b);v&&c.deleteEntry(v.entryName)},addZipComment:function(b){c.comment=b},getZipComment:function(){return c.comment||""},addZipEntryComment:function(b,v){var A=x(b);A&&(A.comment=v)},getZipEntryComment:function(b){var v=x(b);return v&&v.comment||""},updateFile:function(b,v){var A=x(b);A&&A.setData(v)},addLocalFile:function(b,v,A,S){if(o.fs.existsSync(b)){v=v?w(v):"";let R=ye.win32.basename(ye.win32.normalize(b));v+=A||R;let O=o.fs.statSync(b),_=O.isFile()?o.fs.readFileSync(b):Buffer.alloc(0);O.isDirectory()&&(v+=o.sep),this.addFile(v,_,S,O)}else throw be.Errors.FILE_NOT_FOUND(b)},addLocalFileAsync:function(b,v){b=typeof b=="object"?b:{localPath:b};let A=ye.resolve(b.localPath),{comment:S}=b,{zipPath:R,zipName:O}=b,_=this;o.fs.stat(A,function(C,D){if(C)return v(C,!1);R=R?w(R):"";let M=ye.win32.basename(ye.win32.normalize(A));if(R+=O||M,D.isFile())o.fs.readFile(A,function(B,V){return B?v(B,!1):(_.addFile(R,V,S,D),setImmediate(v,void 0,!0))});else if(D.isDirectory())return R+=o.sep,_.addFile(R,Buffer.alloc(0),S,D),setImmediate(v,void 0,!0)})},addLocalFolder:function(b,v,A){if(A=E(A),v=v?w(v):"",b=ye.normalize(b),o.fs.existsSync(b)){let S=o.findFiles(b),R=this;if(S.length)for(let O of S){let _=ye.join(v,I(b,O));A(_)&&R.addLocalFile(O,ye.dirname(_))}}else throw be.Errors.FILE_NOT_FOUND(b)},addLocalFolderAsync:function(b,v,A,S){S=E(S),A=A?w(A):"",b=ye.normalize(b);var R=this;o.fs.open(b,"r",function(O){if(O&&O.code==="ENOENT")v(void 0,be.Errors.FILE_NOT_FOUND(b));else if(O)v(void 0,O);else{var _=o.findFiles(b),C=-1,D=function(){if(C+=1,C<_.length){var M=_[C],B=I(b,M).split("\\").join("/");B=B.normalize("NFD").replace(/[\u0300-\u036f]/g,"").replace(/[^\x20-\x7E]/g,""),S(B)?o.fs.stat(M,function(V,Z){V&&v(void 0,V),Z.isFile()?o.fs.readFile(M,function(ee,X){ee?v(void 0,ee):(R.addFile(A+B,X,"",Z),D())}):(R.addFile(A+B+"/",Buffer.alloc(0),"",Z),D())}):process.nextTick(()=>{D()})}else v(!0,void 0)};D()}})},addLocalFolderAsync2:function(b,v){let A=this;b=typeof b=="object"?b:{localPath:b},localPath=ye.resolve(w(b.localPath));let{zipPath:S,filter:R,namefix:O}=b;R instanceof RegExp?R=(function(D){return function(M){return D.test(M)}})(R):typeof R!="function"&&(R=function(){return!0}),S=S?w(S):"",O=="latin1"&&(O=D=>D.normalize("NFD").replace(/[\u0300-\u036f]/g,"").replace(/[^\x20-\x7E]/g,"")),typeof O!="function"&&(O=D=>D);let _=D=>ye.join(S,O(I(localPath,D))),C=D=>ye.win32.basename(ye.win32.normalize(O(D)));o.fs.open(localPath,"r",function(D){D&&D.code==="ENOENT"?v(void 0,be.Errors.FILE_NOT_FOUND(localPath)):D?v(void 0,D):o.findFilesAsync(localPath,function(M,B){if(M)return v(M);B=B.filter(V=>R(_(V))),B.length||v(void 0,!1),setImmediate(B.reverse().reduce(function(V,Z){return function(ee,X){if(ee||X===!1)return setImmediate(V,ee,!1);A.addLocalFileAsync({localPath:Z,zipPath:ye.dirname(_(Z)),zipName:C(Z)},V)}},v))})})},addLocalFolderPromise:function(b,v){return new Promise((A,S)=>{this.addLocalFolderAsync2(Object.assign({localPath:b},v),(R,O)=>{R&&S(R),O&&A(this)})})},addFile:function(b,v,A,S){b=h(b);let R=x(b),O=R!=null;O||(R=new qg(i),R.entryName=b),R.comment=A||"";let _=typeof S=="object"&&S instanceof o.fs.Stats;_&&(R.header.time=S.mtime);var C=R.isDirectory?16:0;let D=R.isDirectory?16384:32768;return _?D|=4095&S.mode:typeof S=="number"?D|=4095&S:D|=R.isDirectory?493:420,C=(C|D<<16)>>>0,R.attr=C,R.setData(v),O||c.setEntry(R),R},getEntries:function(b){return c.password=b,c?c.entries:[]},getEntry:function(b){return x(b)},getEntryCount:function(){return c.getEntryCount()},forEach:function(b){return c.forEach(b)},extractEntryTo:function(b,v,A,S,R,O){S=Tn(!1,S),R=Tn(!1,R),A=Tn(!0,A),O=Ql(R,O);var _=x(b);if(!_)throw be.Errors.NO_ENTRY();var C=l(_.entryName),D=u(v,O&&!_.isDirectory?O:A?C:ye.basename(C));if(_.isDirectory){var M=c.getEntryChildren(_);return M.forEach(function(Z){if(Z.isDirectory)return;var ee=Z.getData();if(!ee)throw be.Errors.CANT_EXTRACT_FILE();var X=l(Z.entryName),Ee=u(v,A?X:ye.basename(X));let pe=R?Z.header.fileAttr:void 0;o.writeFileTo(Ee,ee,S,pe)}),!0}var B=_.getData(c.password);if(!B)throw be.Errors.CANT_EXTRACT_FILE();if(o.fs.existsSync(D)&&!S)throw be.Errors.CANT_OVERRIDE();let V=R?b.header.fileAttr:void 0;return o.writeFileTo(D,B,S,V),!0},test:function(b){if(!c)return!1;for(var v in c.entries)try{if(v.isDirectory)continue;var A=c.entries[v].getData(b);if(!A)return!1}catch{return!1}return!0},extractAllTo:function(b,v,A,S){if(A=Tn(!1,A),S=Ql(A,S),v=Tn(!1,v),!c)throw be.Errors.NO_ZIP();c.entries.forEach(function(R){var O=u(b,l(R.entryName));if(R.isDirectory){o.makeDir(O);return}var _=R.getData(S);if(!_)throw be.Errors.CANT_EXTRACT_FILE();let C=A?R.header.fileAttr:void 0;o.writeFileTo(O,_,v,C);try{o.fs.utimesSync(O,R.header.time,R.header.time)}catch{throw be.Errors.CANT_EXTRACT_FILE()}})},extractAllToAsync:function(b,v,A,S){if(S=jg(v,A,S),A=Tn(!1,A),v=Tn(!1,v),!S)return new Promise((D,M)=>{this.extractAllToAsync(b,v,A,function(B){B?M(B):D(this)})});if(!c){S(be.Errors.NO_ZIP());return}b=ye.resolve(b);let R=D=>u(b,ye.normalize(l(D.entryName))),O=(D,M)=>new Error(D+': "'+M+'"'),_=[],C=[];c.entries.forEach(D=>{D.isDirectory?_.push(D):C.push(D)});for(let D of _){let M=R(D),B=A?D.header.fileAttr:void 0;try{o.makeDir(M),B&&o.fs.chmodSync(M,B),o.fs.utimesSync(M,D.header.time,D.header.time)}catch{S(O("Unable to create folder",M))}}C.reverse().reduce(function(D,M){return function(B){if(B)D(B);else{let V=ye.normalize(l(M.entryName)),Z=u(b,V);M.getDataAsync(function(ee,X){if(X)D(X);else if(!ee)D(be.Errors.CANT_EXTRACT_FILE());else{let Ee=A?M.header.fileAttr:void 0;o.writeFileToAsync(Z,ee,v,Ee,function(pe){pe||D(O("Unable to write file",Z)),o.fs.utimes(Z,M.header.time,M.header.time,function(P){P?D(O("Unable to set times",Z)):D()})})}})}}},S)()},writeZip:function(b,v){if(arguments.length===1&&typeof b=="function"&&(v=b,b=""),!b&&i.filename&&(b=i.filename),!!b){var A=c.compressToBuffer();if(A){var S=o.writeFileTo(b,A,!0);typeof v=="function"&&v(S?null:new Error("failed"),"")}}},writeZipPromise:function(b,v){let{overwrite:A,perm:S}=Object.assign({overwrite:!0},v);return new Promise((R,O)=>{!b&&i.filename&&(b=i.filename),b||O("ADM-ZIP: ZIP File Name Missing"),this.toBufferPromise().then(_=>{let C=D=>D?R(D):O("ADM-ZIP: Wasn't able to write zip file");o.writeFileToAsync(b,_,A,S,C)},O)})},toBufferPromise:function(){return new Promise((b,v)=>{c.toAsyncBuffer(b,v)})},toBuffer:function(b,v,A,S){return typeof b=="function"?(c.toAsyncBuffer(b,v,A,S),null):c.compressToBuffer()}}}});import{execFile as Jw,spawn as Yw,spawnSync as LI}from"node:child_process";import{promisify as Xw}from"node:util";function e_(t){if(process.platform!=="win32")return!1;if(yf.test(t))return!0;let r=(t.split(/[/\\]/).pop()??t).replace(yf,"").toLowerCase();return Qw.has(r)}function bf(t,e){if(process.platform!=="win32")return e??{};let r={...e??{}};return e_(t)&&r.shell===void 0&&(r.shell=!0),r.windowsHide===void 0&&(r.windowsHide=!0),r}function nt(t,e=[],r={}){return Yw(t,e,bf(t,r))}function Ef(t,e=[],r={}){return t_(t,e,bf(t,r))}var Qw,yf,t_,Kt=Je(()=>{"use strict";Qw=new Set(["npm","npx","yarn","pnpm","coze","tsx","claude-agent-acp","codex-acp","openclaw"]),yf=/\.(cmd|bat|ps1)$/i;t_=Xw(Jw)});var Q0=ae(Me=>{"use strict";var N=F;(function(t,e){let r=F,i=t();for(;;)try{if(-parseInt(r(1075))/1+-parseInt(r(1116))/2*(-parseInt(r(430))/3)+-parseInt(r(1197))/4*(parseInt(r(543))/5)+parseInt(r(1632))/6*(parseInt(r(736))/7)+parseInt(r(1728))/8*(parseInt(r(1001))/9)+-parseInt(r(997))/10+parseInt(r(816))/11*(parseInt(r(1437))/12)===e)break;i.push(i.shift())}catch{i.push(i.shift())}})(vo,923083);function vo(){let t=["r01zvu8","BfzWB2S","zfDVCMTLCKC","AxnmB25N","s1rTyKy","ENrtzha","rg9UDhG","wwzyEvi","yNfgy0S","Bg9NsurozxC","D0zVqum","uMnAyw8","x2XPC3rLBMu","zunftgO","ihrVihjLDhi","tNvgywm","yNvMzMvYzwq","DgHHBIbSB2m","BLbIzeS","ohWWFdr8n3W","m3W5FdD8mxW","EevLChK","x2nSzwfYvgK","AwrtzwW","CwXKD2u","CM1QDu8","BhbnreG","yMXVy2TLza","z1Pnr0u","Au1mCw0","C2nYAxb0","uMvHzcbWyxm","y3jLyxrLuMu","AwDHDg9Yt24","s1nZshG","ChjVy2vZCW","x3nVy2TLDa","y3vYC29Y","vwHWwhu","twvZC2fNzuu","u1nMAfa","Bg9IywXty28","vgjbtum","s0DMzKC","x2rPC2nVBM4","x29WDgLVBNm","sgfqsKK","D1n6tKi","AwXK","yMfgCKK","tu5TzKG","tMfTzq","BMCGzMfPBgu","EfvZzuvUDG","Cg9W","DKDTq2u","qKjJs2u","DhjPzxmGCMu","Dw5RBM93BIa","AwXLtMfTzq","B1zPq3a","vMfZv2G","C2H5r1m","rLHtDMW","BNHkDe4","B2LUDfjLywm","B25Uzwn0Aw4","uvnrDKK","x2jPBMfYEvq","s2XgD0K","zfbwCw8","wenevNO","BhDRuLG","rNvRsgG","yMfJA3vWigu","BhPltvC","DKTTwLG","zvjfyKS","rwzQt1i","CvfPCfi","DfrhzhC","ywXSzwqGBxu","zg52uNO","q3H1ze4","teD2t0i","ALDuuMS","C1Lky1u","txDxAgO","txz3tw8","EvHLBfi","D012uLK","y2XVC2veqG","B1rgveO","Bg9wr0K","v3ziAuy","Bwv0Ag9K","B3bLCNr5tMe","DMjqvKi","tNv4rfq","DLHnwhm","v1L6uxy","u0XHsvu","AgfZ","uxnOBe8","tuvtu0fhrv8","r3D2CvK","zxjFywnRx20","D3nZoI8V","t3DPrva","rMTcCK4","zcWG","qKLctfK","zv90Aw1LB3u","CM92AwrLigi","zgLZywjSzue","uLzAufK","zxj2AwnL","B3bLBIa","x2nYzwf0zvm","B3nLrxzLBNq","DxrKvfy","vuDdCgW","z2v0","Cg9PBNrbBMq","zNjVBNrPzxi","yLbIueq","veX4rwG","B2fK","yw5Nzq","A2TTvwe","C2Hqv1u","C0Xf","AxnAzxjV","y3jLyxrLt3a","CgvYC2LZDgu","CMfUzg9T","z2v0s2v5","tvLdufO","Buz2t1y","igzPzwXKoIa","mZa2nJCZntzJAxjdAgW","AM9xA2W","wNbrywe","B0L5yvy","BhruANK","zhzVDeG","qujHzM0","BhfLtM4","tfD6Eee","DxjODLm","Ce9Zu2W","r09luwq","ihjLy29UBMu","ELjezK0","u2rtthG","CYbPBNn0yw4","yMfSrxzLBNq","AgfwtNm","Cw9Zx18","Dgv4Dc9WBge","q291BNq","ENrsvfO","zvnvEKq","BwT1zKi","x3nLBMrby2S","y29UBMvJDfm","icSG","x2HHBMrSzva","AxnrB1nby2S","u2vXsuq","AgjNCwC","B3vUDa","D24GCMvHC28","vvfoue4","C0vAte4","yxbWBgLJyxq","DhLWzq","mxWZFdj8nxW","B0zjvfK","Ae9Wzw5fDMu","x2LZtM9Kzq","CNzHBfzHBhu","z3fxtM4","CMvWBgfJzui","C2v0","z2v0q3vYC28","z2X1zuu","CMvHC29U","r0Dzvhq","DLPiCw4","AxnszwfKEq","rLvQuvi","igXHCMDLCIa","y3DUtKi","ExbL","CLzozgu","AKzZCve","D1jmB3y","zMX1q0m","Dw5ZAwDUzwq","x3bPBMDqB24","CxP6CNq","wMnjv0u","x2fKzfDZtgK","s0Xzug8","vLrprg4","q1HzDvq","AgXmyMu","zMzmAw5L","vKnyCve","BhrPCgXLihq","y29UDgv4Da","BgLTAxq","zwjlzhG","ChjVDg9JB2W","wwrpCMS","rfDvsM0","qNzLrfa","sfDUwKq","v2viuNO","AuH4r2q","t255seC","zw5HyMXLvhi","D2fZq2XLyw4","tKLkvLy","wK5rDgq","BMrWB2LUDfq","zLfXu1q","t1vqyKe","DKTKCLC","x2DLDeLUDgu","DMXNELC","ChvZAa","sfDywgq","EfbRy3i","vNLZBLm","vLDNBNa","Dev2zw50","y2XVC2u","B25szwnLAxy","vxzNDvy","yxv0BW","Dgvhr2q","BeHrCNK","y09mu1m","DgLUzYbZzxi","BK9Vsuy","Dg9cExrLC0W","CNzHBa","D3fxExu","sLzgC2i","EMv6rgi","DgvZDa","Cw1grfq","y3vYC29Yx24","yM9L","BMDuAw1LCG","y3vYC29Yx2y","AwrI","yuXKrgC","zgLZCgf0y2G","zxjYB3i","zw50","D3jPDgvvAw4","sKrKzfm","CgfYC2u","B25LCNjVCG","zgf5whO","qK1rA2S","Au5Ut3e","tMrOA3a","v3bswKG","DhfeDu0","CMvTB3zLq2G","AgfZt3DUuhi","y29UBMvJDgK","r0HWC2G","z2vtEw5J","A29msMm","AxvJCwS","y09cz08","vg1wsKO","tNfdAMC","AhvxsgC","s25uD1u","zNDZxZeUmc4","vgPTswy","CMvJzxzPzwq","qM1yzNe","DNHws1O","AefJA01LC3m","BM9Uzv9UB24","DunqDxi","r3PkDxC","s1LhA1C","y3vZDg9Tshq","vLb2uw4","vgLitNe","y2HnyxHuCMK","zxjYtM8","tufyx1jfvfi","vufVEvq","zwvKzwq","zcbLCNjVCI4","zxjFCw9Zx2e","s2DNt0O","yNLL","EfzjuMm","u2PNEMO","x0vysvnu","uuPtu0u","z0n6rgq","wMXNqMe","B25mAw5L","txr3sw4","Dg1Xz0e","q3bit0y","yKj5swq","pxv0zI04","r05hwe8","BMj0Evm","C0nVDw50zxi","Bg93","vvrbAwe","Afn6rLy","z3DvExy","rfDhyNu","s0LdugW","zgf0yq","z2vjBMzVu3K","AevYCM9Yrxy","swfZvwS","ihzHBgLKihm","r2rHzfm","BM93","nNDkvxLOsa","Aw5N","wgfSDNa","y3vYDMfSDwu","uhLctxu","EM9uAfm","x2rPC3bHDgm","B29xtuC","BNjOChG","wgnrEhe","BMv4DcGPigm","yxKSig5LDhC","yKDbtxy","B3v0sw50zxi","rNvozK8","t21vCwy","mhWZFdj8mxW","EsbJBg9Zzwq","B3jLtMfTzxm","y3jLyxrLrwW","AxzrEwK","y2vZC0HHBMq","zgvIDwC","vMPYDxi","Aw5Lza","EvjLy29UBMu","qMXjrNi","rxjYB3jdB2q","Cw9rBM0","r1P6Cve","qxzOtLy","C3rLBMvYCW","z25UAuW","C29Tzq","CvzJCu0","B3jL","D2DosKu","zw5KCg9PBNq","yuDpufy","CgThtLq","Ec11C2uT","BMvY","Cujtzvu","ywDLsgLKzq","twLZC2LUzYa","x2n1CNnVCK0","B2jQzwn0u3q","CxPNtK0","Au1RsLO","s3H4DgW","D2vI","vxDvtwW","zNjVBuHHC2G","wMj3BLC","CNnVCL92ywW","BhbJqwG","zNjVBunOyxi","BfftBMm","yxKSihrYEsa","o2nOyxjZzxq","tvf0t00","Ahr0Chm6","nxW0","ugXkEwS","Ag1suwO","uezQz1C","r09jreW","uvvkrfO","zw1LBNq","AxHpywO","BNrbBMrvCgq","C3reC3e","s2XZBvC","uvbsDuK","Dg9tDhjPBMC","tMf3yLu","tunmy2C","BLnPBwu","zMX1C2HfEha","DMvYC2LVBG","ug50wNa","C2vYDMLJzq","x2TLEvbHDgG","CLbRy0u","DKrur0W","uMXnBKO","EevSAg8","DM9hChO","Du15zgG","ELzdsu4","zxq9DxrMltG","BNruCMLLC0m","mNW0Fdn8mxW","ywnRpwzYB24","ChjVDg90Exa","DhjPBq","mZi4mdG4EgPLAuv0","zhnVueW","Ec1TC2CTy3u","EvfXvMW","x19LC01Vzhu","vKntsMi","DufbBLi","qvvwwhm","Ec1TC2CTCw8","Dhj1y3rVCIa","z2v0qwXS","vgThr0O","wgvOvhu","seXuCuy","uNjNu0W","qNnKrfa","Ae1LC3nHz2u","s2nNC0m","vufkDg4","uvj5yxm","sLnptLa","sgT2DK8","C2vUDa","y29Kzq","zuXHDfu","zw5JB2rLrNi","yvvurxe","D1bfrMO","rxzLBNq","sLzjyKS","CLPqCfy","BNzmC3u","qKrquKy","y3ruAw1LB3u","BgvUz3rO","txbnqK4","CKHkCKi","uujnreG","yxnZAwDU","zcWGDw5RBM8","wgTKsuK","sKXWAuO","CM92AwrLihC","tfDOu0C","C3rVCMu","EKTYtM0","zNjVBujPDhm","x29Uq2XVC2u","D1zkBuq","BwXpEgy","v01Os3C","wu9ss2W","we9hreG","DxrMofDYAxq","A1jkvxu","s1jQzfi","Dw5KzwzPBMu","ywjVCNq","x0rctMfTzq","C3vIC3rYAw4","BfnTv2O","uxPJBNi","qMLYDMG","x29UvgLTzw8","CNnVCKzPBgu","x3DHAxq","z2Xls2e","yxbWzw5Kq2G","CMvZzxrdB3u","t3zSuK8","uuXitfm","rfbSAu4","EfjeEMC","uvvyyLK","t1b0zKi","zM9Yy2u","u3Pgyvu","wwjotvO","AhvvtLq","yw51Ce1LC3m","rNnkCva","ufviCLi","ywnOzwq","nNW0Fdj8ohW","svPgtKK","qNjPzgDL","Aw5PDcbrB1m","wxvlAw0","whrYzLC","qLn1zee","qxHICwe","yuHyExa","rwLeywK","shPhDg8","Aw9Ul2PZB24","rvrNCeW","z2zmthi","sfDIyKq","Dg9sy24","vLn5Dg0","Dw1LD0m","B0fjugG","u3vlu0e","zsbHihn0CMK","uvHRuuS","DhDTBxa","AxnFywnR","CMvKDwnL","DKzyyMW","twTVrgO","wwvpqLC","zw5JB2rPBMC","DxnLCKLW","DKzbwxG","DhbizwfKzxi","DMLJzuLeig8","svbWExy","ywrKq291BNq","EKXgCgG","B3HwEvu","zxjFAxnFywm","C0nztwi","ywnRDxbfBMq","wfzUrMu","AKjfDKS","DwD5vfa","ExfvD0i","vwv2Cw4","vu5NAfy","rNPTufi","u2HHCMvKv28","BwvZ","qNL6v1m","DfHfugS","uLDbt3i","DMfS","Auz6tMG","qwPdyvG","x2rLyNvN","y2HHCKnVzgu","AxnbCNjHEq","ihzHBgLKigq","DhDjwKG","t052A3q","lcbTyxGGCMu","vwP1zKC","u3PXC2O","zxrxB3jRq2G","zLzrrMW","DxjS","x3bPBMDmB3m","zxH0ugf5Bg8","Dw50","qxDbvMO","C2v0zgi","ugPMAM8","zNjVBu51Bwi","v3nVr1e","AgvHzgvYCW","t2XpDwS","thnJs3e","vufus1e","x2nSzwfYugK","y1z5ve4","x2LZtwLUAvC","zwn0","BhnMz00","BgLZDgvUtMu","x21PBMLoyxy","DvvAvhG","ugHkDwK","q29UzMLN","AuLutw8","uxvLDwu","CYbWyxjHBxm","CLLhrvK","wgHwu0y","ue93y2m","ywXSB2nvBNm","x2LUAxrqCM8","Cgf5Bg9Hzfq","zuPSBfe","x2LZqNjVD3m","uM1wvNu","BeHHBMrSzxi","revUzNi","vgfJAfq","DxbNCMfKzw4","y1P6CeO","AfH1tMC","tgLZDgvUzxi","Aw5KzxHpzG","mJfAvhfjBLK","Aw1LCYbPBIa","yNvMzMvY","Dhrwq2K","B25pCgvU","vfDgA2q","DhjHBNnHy3q","zuX0wfm","BLjpEgC","wfbuB08","x3jLy29UBMu","sgTfuNi","Bvn4D1e","z2v0q3vYCMu","zgv2AwnLx2K","q0zfq2G","revKDLq","zw50tgLZDgu","B1jVsKu","ywnOzwqSihC","rMPgz1G","zhz0zvO","qLfWugq","zxjFDhrS","z2joDNq","uhvdtxm","DxrVuMvJB24","zw1byvu","tuvxCuy","ChbL","Dg9cExrLCW","zhLwwgi","v2LUzg93","zM1kzg8","DwfAr2i","AMH5Awe","C3bSAxq","z2Les0W","yM9KEq","z0nArxa","vxz5D0K","ywDLu2HVDW","v2vIu29JA2u","zw5fDMvUDa","ihrPBwvVDxq","quvbzxe","qLjAvMi","BLfvv1G","svLMCNC","y2XVC2uSihC","wwTIC1O","Bg9N","Ee1fs2y","B012EMy","shD5v00","uMLesMe","weDTD3C","zgrjrcWGzgu","zgvSzxrL","uK9iq04","AM9PBG","C0XPC3rLBMu","B2nRzxq","yMfSu2nVCgu","t29PvfC","y2HLy2Tszwe","swHKBfa","zMvY","igzHAwWSig0","swXtvw4","Bg9Nsurhzw4","y2fSBa","D1rxzNu","Dxrjza","rM1qEvu","C3nHz2vfDMu","vLjOyvm","x3DZ","DgfSCLu","zKvIBNe","B25TzxnZywC","BMnVzgLUzW","Bxjwtg4","tK9Rtei","DgLTzw91Da","rKLmrv9ot1q","x2vUzhbVAw4","B3bLCNr5","wwnQyvO","rhvMruO","vuH4txy","Aw9UvgLTzw8","qLrmq1O","vgLTzw91Da","CMvXDwLYzwq","BfHyDM4","t3jxzeC","y29TCgXLDgu","tgfKww8","runrB1e","u1DODK4","CMfTzq","te1wr1K","v3PLCve","CgLUz19VBMm","r1PeyLe","tujlwLu","y0PXwhy","ufjZywC","yxv0B21HDgK","BLfeDeO","Ew9Xsxm","Cgf5Bg9Hzeu","nw1fsMPSza","yw1L","yNPOwLu","CgXLyxnLiha","zMLN","C3jJ","qLnMB1y","ve1pBNG","yNL0zxm","AKvcv3m","x2DLBMvYyxq","thHxuvi","C2fNzq","De5bvxO","x2LUDgvYDMe","ywXPzcb1CMW","rfLrBvG","D2jSAw4","tg9NsurozxC","AMzUELu","ywWGy3vYC28","vNjkBe4","reLiuxe","CgrSwNq","D0f6ueq","y3vYCMvUDeK","v21UrvO","yLvOt1C","q29vDwK","yuXtrM4","zxjKs2y","u3zrrg8","zMXVB3i","ANf0wgK","x2nVBM5Ly3q","ywnR","zw16EMq","B25tDgfYDfi","wvjKq0C","ELvPAuq","DMfSDwu","zK1zCgW","Bwf4uMv0CMK","x29Ut3bLBG","AwPfvLe","DNj3s00","ywDL","t3bLBKv2zw4","lcbxzwjtB2m","vujhCM0","BxnN","DKvKDNK","Dgv4DfbHEwW","B2zM","Cgf5Bg9Hza","z29PBMCGyxC","wNL1yLO","id4G","zwnfrfG","CfLLt2u","wxvRzwu","zwLUtg0","x2LZv29YA2u","x2HHBMrSzvi","q290rui","rwfluKy","Cgfbvey","Avn1Dve","yNL0zu9MzNm","y2uGBM90igK","BKfqDem","AvjbwfO","C3rHCNq","ywX3yxLZ","s2v5AxC","uvjKCNi","yNP5BKu","y2Tjy1y","B2H1DfO","q05ztMK","ANPJDNa","yMLUyxj5vhK","v1jTsLG","yMLUza","zgvMAw5Luhi","zg9Uzq","mxW1","Chb4DeW","rMnowvy","z2vrDwv1zuW","EhjeB0y","txD3B2m","qw1VDw50","DhvgCM8","wwLlq3i","zLDIsem","tKDFrvjst1i","s3DXswW","yMLUyxj5","twXIsuG","BfrPBwvVDxq","tKT6vgy","y2HnyxHdB3u","EePTs1a","x3vYBa","y2f0y2G","CfHJDuG","DhjPzxm","yvfsExe","EwD4ugy","B2zMC2v0","y3jLyxrLrxi","x2zVCM1HDeu","z2v0sxrLBq","tunSqKi","rePfC2S","A2HYAvK","x29UtwvZC2e","zMLSDgvY","t2fkuKK","wMP1y0O","AwXLx25HBwu","nhWXFdj8nW","C3byq2q","wxfbDfi","zwnVBM5Ly3q","EgD5zwm","yNL0zuXLBMC","mtb8mhW1","x29UrxjYB3i","B25fCNjVCG","zwrwywu","t1DNBLK","rvjst1i","C0LWsee","EurrqMu","yxbWBhK","r3vRrui","y1nxs3K","AMHtEMG","CgfnCKC","BuzdCw0","qxzhChy","tg9JAW","A3LcywG","u2TPCcbWyxm","y3r4","reDQrwW","tMXPDem","tfj0uKy","AxmGDw5Kzwy","quXQyMG","z2u6ia","AeXQweG","ywDLrxzLBNq","DMvYC2LVBMm","y3jLyxrLt2i","C29YDa","Ce1wy20","Cfn6CeK","yuviBNi","q0Xpu0ve","r2nnuLG","vLLvvNu","uuD6Ava","BezSDxnO","y29Uy2f0","x21LC3nHz2u","mdaWma","y29UC3rYDwm","x3jLBw92zvC","CYbHBhjLywq","zxf1ywXZ","rMzTEK0","Berrzw0","EMPbywG","yxrLq291BNq","tKTsB1a","AenSB3nLrxy","Dgzpyvi","Cg9hBLO","C2XPy2u","x3DZsw5ZDge","CNjVCK1LC3m","z2v0t3DUuhi","zufJAW","B3n4uMK","z2vY","zxjYtxnN","D3HeEuC","vLPhqLq","q09otKvdveK","tNrNEwK","nJK0mZK1ofntrLjpyq","sMXLrui","AKTAu2G","B25SAw5L","vgjZqxu","CgLUz1rPBwu","r2rluNm","qKr6CxO","q0T1DeG","D25MEe0","AMvJDfn0B3i","uM51sxi","y2Liy2S","zgPtDMS","C0LoqKq","B3jpBMXPBMu","CMLLC0nVDw4","uLjpuG","zw50zwqGDhK","zuzuque","y0fdvvq","runIs0C","CMvUDevUzha","EK1NwLy","BMrLEa","zgrLEwu","rhbbz04","v3z5t1G","DKrhD1G","A0jhEvK","CMvZB2X2zq","ihn1y2nLC3m","D1nuzhG","Dg9mB3DLCKm","EKnNwge","AwXSihvZzsa","BwvKAwf0zwW","ANLnD0G","EhfsDMO","C0jmuwO","DgnezMO","BwvY","CMvQzwn0","y2HLy2TdDxi","CM92AwrLige","qu9JBwe","nNWWFdj8mxW","wMHQD2C","ihrPBwvZ","wezysu0","q1jctfi","y0LnrLe","q3vZDg9Tq2W","tg1QELK","s05wrvi","s0f1u2u","CMvHzhLtDge","qNLxyvG","uvjJtgu","qu5QBuG","C3HWyxC","AMXAA2G","s1DxrLy","zMLUza","AxLrug0","B2zMBgLUzq","Au9IBfe","q1b6uxK","A0TTt3O","qxnmEeW","u3bmvM8","B3nLza","BeXzD0C","vwHTweq","m3W1Fdb8nNW","rfjYzMO","q3LmAeO","zw1PDa","C2HPzNq","q0Xpu0LorW","mtfwrKLlyum","rNjVBNrPzxi","Chv0","DLL5zKe","x2n1CNnVCKy","zwrPyxrLBhK","vK9brvK","u2nuwKi","ugjdsKm","qNryAgS","ysbTDxn0igi","DcbSAw1PDa","CLzHBhvLCW","ywrKt25L","zw5XDwv1zq","D3L1uw4","EMPjuhy","zM9YrwfJAa","BgLUzw5V","mhWYFdr8m3W","AxfHzuq","ihbYB3rVy28","rLbOzKi","C2vUza","zNzUBNO","qLvSBK0","tvnZANq","yMzRq04","C3vJy2vZCW","u1z0Bw0","vxfRz0W","t1bftG","A3DJCNm","Ahr0Ca","BgLUzq","yM9su0i","zuj0z3m","BMfTzq","Axf4Ceu","C3rVCcbPBw0","EgDOBNG","rMHqyMy","zgDluhu","tKfusvzfx0u","wMvxEKm","ue9IANi","uKj6vNq","CgfNzxnOB3C","nxW2Fdn8mxW","y2XLyxjtDg8","v3PXrha","zNjVBuj5Dgu","B3bLBG","AhDJsLK","y3DLENa","tg9Nsuq","Dwrcy3q","BIWGAg9ZDg4","vefPt2W","zg1szhK","CMvTB3zLrxy","wu5VsuS","zLDjvu0","EKH3vva","AwTbzvu","BezHs20","q3nksLm","vhjXDeG","x3jLywr5q2W","z1rPBwvVDxq","thHKzuu","zMzMzG","A2TLweC","ChrVCG","Aw5KzxG","v2vituK","sxD3AgW","B2nRzxrtDwm","jMPZy2fSBgi","A05cveG","CgLUz0LUDgu","Dg9Y","DMfSDwvZ","Evb1Bu0","swrezLO","BgvY","zxmGCMvHy2G","ywrK","mhWX","teTWs00","rKTXq2S","u1jXD0q","EwrbruS","zMH4uum","wNPisMy","A1nAuMO","De1HBMfNzxi","AeLctNK","y3jLyxrLq2W","vMrOrgO","x3bYzwzPEa","CwnTtw8","C01Mrvu","CujstK4","BxncEfe","D25MtLi","vwzsB20","zNvUy3rPB24","Aw5KzxGGB3u","AMPXrfq","zLrUyvu","CMvJzwL2zwq","zhvmvuG","DwvNu2S","D2jvEfu","y1LmvMy","Bwr2txC","vM5VBu0","q0DSuKq","wK1OBxO","u1DvAuy","yw5Hz2vY","rLLouKm","uNPODeu","vwnmCxC","uKfty1i","su5oEKO","x2n1CNnVCK4","AgLNAa","ELzStgq","zxHWB3j0CW","DevrCgu","q3vZDg9Trxi","AvnkBgW","DKzAzwu","vKnuDM4","D29LyxO","x2HHBMrSzu8","qwnsB1G","zLjiAxi","DcbVzIbYyw4","u0TOExu","DMvUDa","z0jvtvy","y29UBMvJDeu","uenozva","shjqAw4","DMnfyue","Cw9oB2S","Eej3r1u","DML0AuK","ywnRtxnNswq","BuXJvha","BujJzvu","qwLstxq","wKDHufG","q3fMAui","zLj6qNC","ywrTBeW","ywrKrxzLBNq","rLjptLrjrvi","qLvQD00","zgvSzxrLrge","uhDfBuK","BML0AwfSAxO","q1vzqNO","ufPiwuK","zND4zgm","t2jQzwn0","Ef9MCM9UDgK","x1fVu01HBMe","yvzNBhy","sMnNEKq","q29Kzq","y1LxzwG","sgnMzLi","BLHYse8","DMDqvMC","Aw47y2HHCNm","wMvPseS","uwHxtei","mtuXmdCYmdbbuejdzLG","yxnJCMLWDa","r3bNAhO","x3bYB3rVy28","mtuZuw9dqufc","CKvqEuK","v3PmyMy","CLPTq0m","yw1LoIa","B25nzxnZywC","uvjLtNO","BKnJrKm","B1buBfq","rvnxr0K","BMDLza","Dg9oDw1Izxi","DgvmB2Djre4","ruHvruS","u3DevwG","z0LhDxm","A1n0yxr1C0m","mxWZFdj8nNW","uuDMseC","y291BNq","y0Hcq3G","CLPRrMi","vNfLwMq","sLvfDwu","Cg9PBNrdB24","aaaaaaaaaaa","vu95wMO","ELvAt3K","t2LHyMm","DMPgrwO","AxnrB1nnzxm","uenQEg4","sNPjBeO","D3jPDgu","qLjkvwK","B3bLBKrc","y09Wzw4","sNbjsNu","x3fVC0rc","z0P1CvG","qKriy2O","AffvD3C","x2LZsw5PDa","B0XTsu4","y29UBMvJDa","BwLUzW","DejjEeS","r0vouei","BwLZzq","EefvtfC","ug9yDeO","ywr2yw5Jzq","AgvHzgvY","su5tvefova","CMvJB25Uzwm","BwzXte8","Aw5JBhvKzxm","CwHkDu8","Dg9cExrLC0i","Bwf1rhC","y0nvDLK","tNrmv04","BfHlC3C","B1r5vwG","wwjksvq","BfvSvKW","v2vPEgLUsLm","uMvJB25Uzwm","vvHwugS","CMvHzhDYAxq","DhjlDfa","D2fVrfe","zvLYyu0","vgfN","mtm5ndi0n3DkEvfOtW","B2vkyLC","tLrruLi","zgvS","rxHuse0","x3nLCuLK","C2vYDMLJzs0","y2XLyxi","BwvZC2fNzv8","r2PwtxK","BKXPBMu","t3nSrhm","tw1gwxm","BwvZC2fNzq","vvLIy0S","u2vYDMLJzvC","D2nsvKq","uuPqD0O","CgPZs2y","vxbKyxrLq28","y3vYC29YlNm","zxH0zw5ZAw8","y3jLyxrLtwu","Dfjluhy","zgvJB2rLzey","CMvWBgfJzq","BNrLCG","yKfxu2O","BNvTyMvY","zKrIEge","DgHLBG","swHPwxa","wNjvwvC","tw9KDwXL","vwrSz24","A2v0ignVBNm","sfrkz3u","C2vUzf9Hy2S","D0XsuwW","yxGGCMv0CMK","x2rYB3bhBg8","mZy3ndiYz2HNz2z2","DNHZuNi","BwvZC2fNztO","z0Dlt0O","tg9SEgS","zvnpChe","CKjxtuK","zNjHBwvuExa","D3m6lY8","C3rYAw5NAwy","sNHQseq","B25VCgvU","y29SBM8","DNnAu3e","BuLAv1y","rvnUBw4","ywnRx2LK","A2nWrve","BwXkC3q","z2nPzhC","wLHfuKK","C1z6tfG","q3ngA0G","CKvvBM0","uM5WC2G","BKrxCuS","y29UDgLUDwu","z2v0qwXSs2u","ChnKAeS","sw1QA04","zvvYBa","B2XKvMvYC2K","CMvZzxrfBMq","tMvdBfq","yMrFzgLK","yvr0D0S","rgvKAwnHDgu","zMLSzw5HBwu","Dg9iyxnO","B25JBg9Zzq","uerNs2i","qwDxDvm","ywnYwKy","u3rYyxrLz3K","uePHvMC","zejvCuy","yxrHlcbKyxq","u3jjrgC","Aw9U","zLjyDMu","wNHws1O","CMv0CNLdB3u","DhfytKu","x29UugfNzu4","igfYCMf5yNu","B25tDg9Wsw0","twzfqui","zgfbAw4","z2v1r0e","BefqChm","C3rYAw5N","CgjICdi","C3btENG","yuvOCeG","mNWXFdb8m3W","CgLUz0XVC3m","ruvfz3q","tu9OCuO","qw9rqwq","txPys2m","A2v5CW","BhHlsva","Axnby2TdBgu","suvtx0vsuK8","r2TQDeu","sxzJDfO","vNn4qwu","yvHuu00","AwHZtLC","AgvKtwf4uMu","x2LUAxrhBg8","nJGXmdG4ngfvA3L4tG","Dg5Lv1K","y294s1a","zxjHDg9Y","C0jf","D2LSBfjLy28","svj5BwG","Cwr2B28","DeLK","Efrurw52","zxjFBxnNAwq","tgvxy0W","y3vYCMvUDeu","z2v0u3rVCMe","qwjVCNrfCNi","wenwwxy","wfrJseS","rxjsBhC","zw5HyMXLqxu","swnWwfa","teTqCuy","zv9ZDwnJzxm","C2v0q3vYC28","BMnLq2XVC2u","su1OEgW","EhrbCwi","uurks3O","mdaWmdaWmda","q3bmswy","zurRzuC","CM9YrxzLBNq","x25HDMLNyxq","vwHcwhe","q3DkB2i","DNnbCwK","z1rvC2u","BeznreK","yxjYyxLIDwy","DvHTyuy","BxH4vfG","yw1Lu3bHy2u","zMzLCG","D1nUteu","AhrqyNy","BwfW","svPqBMu","y29UBMvJDca","wxfsrw4","x2LUAxq","uNn0q1K","B3jRzxjhBg8","vxDKrgW","zMfwyuC","tKPeANO","ignVzgu6ia","C2v0y3vYC28","t0Hmzfm","BgjYB2W","C2v0sxrLBq","t1bftL9fuLi","Bwf4tg9ZC0m","twPVzuq","BNrfBMrWB2K","C2vYDMvYvgK","x3bPBMC","DgzuuKq","A2v5","tvHzz2W","AxjLza","wejvAvu","sKDOEMC","yvPvDKW","yxnL","x2LZtwLUAvq","C3vIyxjYyxK","AgfUz2u","x3bHDgHlzxK","BMCGB3iGyw4","C2Xfq28","z0vZyMS","EK5uBeO","tNPXvK0","tMTjwxO","x2rItMfTzq","DKjQswO","tfDKBhm","CMvZDwX0","rxvuA0i","zw5HyMXLuw8","DfLTq0O","rLDt","uvrrzxi","tMDozeG","yxzTrwe","rKHnz0G","DeLUDgvYy2u","q1jXz3C","s1zYrue","BMvJDa","B3jRig9MzMW"];return vo=function(){return t},vo()}var Nb=Object[N(627)+"operty"],Mb=Object[N(727)+N(1393)+N(369)],V0=(t,e)=>function(){return t&&(e=(0,t[{eDkeG:function(c,l){return c(l)}}[N(1226)](Mb,t)[0]])(t=0)),e},Bb=(t,e)=>{for(var r in e)Nb(t,r,{get:e[r],enumerable:!0})};function zb(){return H0||(H0=[IDBDatabase,IDBObjectStore,IDBIndex,IDBCursor,IDBTransaction])}function Fb(){let t=N;return j0||(j0=[IDBCursor.prototype[t(1052)],IDBCursor[t(1726)+"e"][t(1142)],IDBCursor.prototype[t(1142)+"PrimaryKey"]])}function Ub(t){let e=N,r={TrqtH:e(844),ALjbh:e(1558),wVJmD:function(o){return o()},iMkJZ:e(1190)},i=new Promise((o,c)=>{let l=e,u={daAin:function(E,I){return E(I)},QnANi:function(E){return r[F(286)](E)},MXYgl:function(E,I){return E(I)},baFrI:function(E){return E()}},h=()=>{let E=F;t[E(876)+E(447)+E(1673)](r[E(883)],x),t[E(876)+E(447)+E(1673)](r[E(694)],w)},x=()=>{let E=F;u[E(1173)](o,Bt(t[E(1283)])),u.QnANi(h)},w=()=>{let E=F;u[E(1264)](c,t[E(1558)]),u[E(1346)](h)};t[l(975)+l(428)](r[l(883)],x),t[l(975)+l(428)](r.ALjbh,w)});return i[e(1105)](o=>{let c=e;if(o instanceof IDBCursor)if(c(1190)===r[c(1680)])td[c(1481)](o,t);else return _0x4c3559[_0x29c5c4]=_0x37f304,!0})[e(648)](()=>{}),Io.set(i,t),i}function Gb(t){let e=N,r={UbpuI:"complete",Udlgn:e(1558),vxsRr:function(o){return o()},EGOuW:e(1211)+"or",dsoPL:function(o){return o()}};if(So.has(t))return;let i=new Promise((o,c)=>{let l=e,u=()=>{let w=F;t[w(876)+w(447)+"ner"](r.UbpuI,h),t[w(876)+w(447)+"ner"](r[w(1109)],x),t[w(876)+"entListener"]("abort",x)},h=()=>{let w=F;r[w(1117)](o),r[w(1117)](u)},x=()=>{let w=F;c(t[w(1558)]||new DOMException(r.EGOuW,r.EGOuW)),r[w(1729)](u)};t.addEventListener(r.UbpuI,h),t["addEvent"+l(428)](r.Udlgn,x),t[l(975)+l(428)](l(295),x)});So[e(1481)](t,i)}function qb(t){Ao={OrWdG:function(i,o){return i(o)}}[N(526)](t,Ao)}function Hb(t){let e=N,r={TbAMC:function(i,o){return i(o)},qoNok:e(1558),SXRGr:function(i,o){return i===o},UVRjz:e(623),HqUla:e(1383),FjFgX:function(i,o){return i===o},lAPps:function(i,o){return i in o},RmVVu:e(1678)+e(1650)};return r[e(450)](t,IDBDatabase.prototype[e(436)+e(1164)])&&!r[e(1175)](r[e(421)],IDBTransaction[e(1726)+"e"])?function(i,...o){let c=e,l=t[c(501)](r[c(1339)](Ui,this),i,...o);return ed[c(1481)](l,i.sort?i[c(700)]():[i]),r[c(1339)](Bt,l)}:Fb().includes(t)?function(...i){let o=e;return t.apply(Ui(this),i),r[o(1339)](Bt,td[o(1419)](this))}:function(...i){let o=e;if(r.SXRGr(r.UVRjz,r.HqUla))_0x33eaa0[o(876)+o(447)+o(1673)]("success",_0x3afeee),_0x2ed8e4[o(876)+"entListe"+o(1673)](WRgniM[o(964)],_0x35e0ad);else return Bt(t[o(679)](r[o(1339)](Ui,this),i))}}function F(t,e){t=t-281;let r=vo(),i=r[t];if(F.HbBgHb===void 0){var o=function(h){let x="abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789+/=",w="",E="";for(let I=0,b,v,A=0;v=h.charAt(A++);~v&&(b=I%4?b*64+v:v,I++%4)?w+=String.fromCharCode(255&b>>(-2*I&6)):0)v=x.indexOf(v);for(let I=0,b=w.length;I<b;I++)E+="%"+("00"+w.charCodeAt(I).toString(16)).slice(-2);return decodeURIComponent(E)};F.XjnIEi=o,F.HJGVYX={},F.HbBgHb=!0}let c=r[0],l=t+c,u=F.HJGVYX[l];return u?i=u:(i=F.XjnIEi(i),F.HJGVYX[l]=i),i}function jb(t){let e=N,r={aYMfP:function(i,o){return i===o},iVbhb:function(i,o){return i(o)},ydAEK:function(i,o,c){return i(o,c)},wPEFj:function(i){return i()}};return r.aYMfP(typeof t,e(923))?Hb(t):(t instanceof IDBTransaction&&r.iVbhb(Gb,t),r[e(908)](Z0,t,r[e(1755)](zb))?new Proxy(t,Ao):t)}function Bt(t){let e=N,r={tTGdw:function(o,c){return o instanceof c},qvcsj:function(o,c){return o(c)},ciHck:function(o,c){return o(c)}};if(r[e(1377)](t,IDBRequest))return r.qvcsj(Ub,t);if(bo[e(1399)](t))return bo[e(1419)](t);let i=r[e(748)](jb,t);return i!==t&&(bo[e(1481)](t,i),Io.set(i,t)),i}var Z0,H0,j0,td,So,ed,bo,Io,Ao,Ui,W0=V0({"node_modules/idb/build/wrap-idb-value.js"(){let t=N,e={oPTlT:function(r,i){return r<<i},HWXXd:function(r,i){return r+i},iRAXZ:function(r,i){return r+i},FUjQR:function(r,i){return r===i},gsMsx:"xyQfh",MFUSg:function(r,i){return r instanceof i},Ndhkp:function(r,i){return r===i},teGGd:t(628),FcNYV:t(1678)+t(1650),eJllQ:function(r,i){return r(i)},lpMDH:t(282)};Z0=(r,i)=>i[t(1665)](o=>r instanceof o),td=new WeakMap,So=new WeakMap,ed=new WeakMap,bo=new WeakMap,Io=new WeakMap,Ao={get(r,i,o){let c=t,l={glKKa:function(u,h){return u|h},NgNdH:function(u,h){return e[F(1009)](u,h)},MlbIH:function(u,h){return e[F(1530)](u,h)},gCZEp:function(u,h){return e[F(1009)](u,h)},YbJIT:function(u,h){return e[F(1009)](u,h)},LWhSG:function(u,h){return e[F(614)](u,h)}};if(e[c(1488)](e.gsMsx,c(1569))){let u=new _0x2c58ce(l[c(304)](l[c(304)](l[c(1289)](_0x792a1d[l[c(642)](_0x3777bb,4)],24),_0x208fba[l[c(642)](_0x42841c,5)]<<16),l.gCZEp(_0x572654[l.MlbIH(_0x1f0dda,6)],8))|_0xdef73f[_0x463d9c+7],l.glKKa(l.glKKa(l[c(469)](_0x185e4a[l[c(642)](_0x4d344c,0)],24),l[c(1065)](_0x56dcc9[l[c(642)](_0x45a892,1)],16)),l[c(1289)](_0x4512a7[l[c(281)](_0x298a7a,2)],8))|_0x10c4ed[l.LWhSG(_0x450d5f,3)],!0);return _0x5bc5ac+=8,{value:u,offset:l[c(642)](_0x50c8cd,8)}}else{if(e.MFUSg(r,IDBTransaction)){if(e[c(1567)](i,e[c(1539)]))return So[c(1419)](r);if(e[c(1567)](i,e[c(631)]))return r.objectStoreNames||ed.get(r);if(i===c(282))return o[c(1678)+c(1650)][1]?void 0:o[c(1678)+c(1667)](o[c(1678)+c(1650)][0])}return e[c(419)](Bt,r[i])}},set(r,i,o){return r[i]=o,!0},has(r,i){let o=t;return r instanceof IDBTransaction&&(e[o(1567)](i,e.teGGd)||e[o(1488)](i,e[o(1323)]))?!0:i in r}},Ui=r=>Io.get(r)}}),J0={};Bb(J0,{deleteDB:()=>Kb,openDB:()=>Wb,unwrap:()=>Ui,wrap:()=>Bt});function Wb(t,e,{blocked:r,upgrade:i,blocking:o,terminated:c}={}){let l=N,u={sVmkf:function(w,E,I,b,v){return w(E,I,b,v)},ZeYxa:function(w,E){return w(E)},rmjuO:function(w,E){return w(E)},lBXvd:l(1535),xgyec:l(425)+l(1599),SvQDo:l(1324)},h=indexedDB[l(868)](t,e),x=u[l(1322)](Bt,h);return i&&h[l(975)+l(428)](u[l(669)],w=>{let E=l;u.sVmkf(i,u.ZeYxa(Bt,h[E(1283)]),w[E(1147)+"on"],w.newVersion,u[E(1322)](Bt,h[E(436)+E(1164)]))}),r&&h[l(975)+"Listener"](u[l(574)],()=>r()),x[l(1105)](w=>{let E=l;c&&w[E(975)+E(428)](u.lBXvd,()=>c()),o&&w[E(975)+E(428)](E(698)+"hange",()=>o())})[l(648)](()=>{}),x}function Kb(t,{blocked:e}={}){let r=N,i={BidGc:r(1324),vKmZX:function(c,l){return c(l)}},o=indexedDB[r(978)+"tabase"](t);return e&&o["addEvent"+r(428)](i.BidGc,()=>e()),i[r(1373)](Bt,o).then(()=>{})}function K0(t,e){let r=N,i={kkmUa:function(h,x){return h(x)},ugyTP:function(h,x){return h===x},HaPJI:"dZfIh",djSvk:r(1070)+"e",lLYwG:"readonly",nbtyS:function(h,x){return h in x},sEZLN:r(1176),UYbcK:function(h,x){return h!==x},cwezp:"WglKk",eSUzD:function(h,x){return h!==x},XwLVg:r(1093)};if(!(t instanceof IDBDatabase&&!i.nbtyS(e,t)&&i.ugyTP(typeof e,i[r(1471)])))if(i[r(1089)](i.cwezp,i[r(870)]))_0x1f2938.o=(h,x)=>_0x463b25[r(1726)+"e"][r(1571)+r(517)].call(h,x);else return;if(Eo[r(1419)](e))return Eo[r(1419)](e);let o=e.replace(/FromIndex$/,""),c=i[r(1459)](e,o),l=X0[r(1057)](o);if(!i[r(1617)](o,(c?IDBIndex:IDBObjectStore)[r(1726)+"e"])||!(l||Y0[r(1057)](o)))return i[r(1089)](i.XwLVg,r(1093))?new _0x26e8b9(_0xbf4e77):void 0;let u=async function(h,...x){let w=r,E={tfOaR:function(I,b){return i[F(1426)](I,b)}};if(i[w(363)](i[w(1343)],i[w(1343)])){let I=this[w(436)+w(1164)](h,l?i[w(749)]:i[w(808)]),b=I[w(282)];return c&&(b=b[w(890)](x[w(814)]())),(await Promise.all([b[o](...x),l&&I[w(628)]]))[0]}else _0x5dc094+=E[w(722)](_0x3a5d53,_0x12476f),_0x564837++};return Eo[r(1481)](e,u),u}var Y0,X0,Eo,$b=V0({"node_modules/idb/build/index.js"(){let t=N,e={UATKQ:function(r){return r()},RnuIr:t(1433),YcjaZ:t(1738),ztSdp:t(1143)+"ys",autSg:t(818),gqWNn:t(488)};e.UATKQ(W0),e[t(399)](W0),Y0=["get",e[t(747)],e[t(518)],e[t(1302)],"count"],X0=[e.autSg,"add",e[t(1479)],t(1082)],Eo=new Map,qb(r=>({...r,get:(i,o,c)=>K0(i,o)||r.get(i,o,c),has:(i,o)=>!!K0(i,o)||r.has(i,o)}))}}),Vb={idb:function(t){let e=N,r={hubfG:"close",AvhNV:e(716)};t[e(946)]=Promise[e(766)]()[e(1105)](()=>($b(),J0))[e(1105)](function(i){let o=e,c={iReqG:r.hubfG};if(r[o(1662)]!==r[o(1662)])this[o(813)](c.iReqG,_0x56598b(c.iReqG,{..._0x2ca43c}));else return i})}},$0={};function Mt(t){let e=N;var r=$0[t];if(r!==void 0)return r.exports;var i=$0[t]={exports:{}};return Vb[t](i,i[e(946)],Mt),i.exports}Mt.d=(t,e)=>{let r=F;for(var i in e)Mt.o(e,i)&&!Mt.o(t,i)&&Object["definePr"+r(517)](t,i,{enumerable:!0,get:e[i]})},(()=>{let t=N;Mt.o=(e,r)=>Object.prototype.hasOwnProperty[t(501)](e,r)})(),(()=>{let t=N,e={MkoDj:"undefined",fEbnq:t(1108),iyQPm:t(1732)+"le"};Mt.r=r=>{let i=t;e[i(347)]!=typeof Symbol&&Symbol[i(1706)+i(1074)]&&Object[i(627)+i(517)](r,Symbol["toString"+i(1074)],{value:e[i(509)]}),Object["definePr"+i(517)](r,e[i(800)],{value:!0})}})();var De={};(()=>{let t=N,e={IPpyv:function(a,n){return a(n)},gwUyv:function(a,n){return a+n},oxVyU:function(a,n){return a+n},UwdDl:function(a,n){return a+n},RzhtE:function(a,n){return a*n},UvywI:function(a,n){return a(n)},cZzpJ:function(a,n,s){return a(n,s)},wAzPD:function(a,n){return a(n)},dgKPu:function(a,n){return a+n},xrDoF:"0000",lxKIP:t(887),zUZOy:t(1224)+t(1224)+t(1224)+t(1224),DEdvT:t(504),VCXqQ:t(1503),VnomM:function(a,n){return a>n},sCYMb:function(a,n){return a<n},TbsAu:function(a,n){return a-n},CqfiB:function(a,n){return a!==n},jKZSh:function(a,n){return a-n},NkIYz:function(a,n){return a<n},bzynE:function(a,n){return a-n},DWUJm:function(a,n){return a<n},ZrUYW:function(a,n){return a(n)},xBwGU:function(a,n){return a&n},nOoIF:function(a,n){return a+n},tuFro:function(a,n){return a|n},hXuNg:function(a,n,s){return a(n,s)},coxKP:function(a,n){return a===n},waoDQ:t(1532),QHmDL:function(a,n,s){return a(n,s)},emAaU:function(a,n){return a>>>n},aVTZB:"Missing required field: "+t(1263),NJDjz:function(a){return a()},LKPqF:function(a,n,s){return a(n,s)},ttVCi:function(a,n,s){return a(n,s)},mrVLn:t(1558),wSzNB:function(a,n){return a&n},ivQyi:function(a,n){return a>>>n},giDKL:function(a,n,s){return a(n,s)},YqREn:function(a,n,s){return a(n,s)},twIZH:function(a,n,s){return a(n,s)},NTQRR:function(a,n){return a!==n},imQJZ:function(a,n,s){return a(n,s)},toRcn:function(a,n){return a!==n},ygxPf:function(a,n,s){return a(n,s)},JUEue:function(a,n,s){return a(n,s)},xghnx:function(a,n){return a(n)},TWFkd:function(a){return a()},NzqVM:function(a,n,s){return a(n,s)},ECbKG:function(a,n,s){return a(n,s)},nQDtJ:function(a,n,s){return a(n,s)},rBWMI:function(a,n){return a!==n},IIGWo:t(882),vBjIj:function(a,n){return a!==n},hmRQj:function(a,n,s){return a(n,s)},zRDfM:t(1191),iqaeD:"pgXgB",ikAeU:function(a,n,s){return a(n,s)},EuqVA:function(a,n,s){return a(n,s)},kcpEQ:function(a,n){return a!==n},AEAeq:function(a,n,s){return a(n,s)},pSzpI:function(a,n){return a!==n},CwJob:function(a,n){return a<=n},qoQnm:function(a,n){return a>=n},mlOxf:function(a,n){return a+n},QUXbY:function(a,n){return a(n)},dayXz:t(851),VrJlN:function(a,n){return a(n)},zCgXa:function(a,n){return a(n)},YeDYy:function(a,n,s){return a(n,s)},iMLqm:function(a,n){return a(n)},RrgSL:function(a,n){return a(n)},KGffG:function(a,n){return a(n)},VTODn:function(a,n){return a===n},vGmCe:t(1676)+t(524)+t(1436)+"SeqID",iOblQ:function(a,n){return a===n},UHxMv:"Missing "+t(524)+t(1436)+"LogID",bUhOW:t(1676)+t(524)+t(1436)+t(1713),LRtRF:t(1676)+t(524)+t(1436)+t(1392),mFvOV:function(a,n){return a+n},sxpaw:function(a,n,s){return a(n,s)},SSfhP:function(a,n){return a>>n},MzXKc:function(a,n){return a===n},lXXvn:function(a,n){return a+n},sonkQ:t(688)+t(827),WpRZH:function(a,n){return a===n},HvZdz:"OGaRZ",qzgNM:function(a,n){return a>n},wFoAC:function(a,n){return a!==n},jWTRk:t(677),ByWaX:function(a,n){return a>=n},QJSSE:function(a,n){return a<=n},gJuqX:function(a,n){return a+n},pYeOe:function(a,n){return a<<n},CKutH:function(a,n){return a>>n},ORMqS:function(a,n){return a<n},wMvRY:function(a,n){return a|n},zjIPv:function(a,n){return a&n},zcCNS:function(a,n){return a>>n},TachT:function(a,n){return a|n},YfXyR:function(a,n){return a>>n},MQtOM:function(a,n){return a&n},AiRMt:function(a,n){return a>>n},vrwKM:function(a,n){return a>>n},MSsjt:function(a,n){return a&n},rYGEY:function(a,n){return a===n},kNBTH:t(1754),emzzd:t(1556),jyMwH:function(a,n,s){return a(n,s)},uXmaF:function(a,n){return a<n},KnTwU:t(774),fWIUM:"CQdxE",iSuuQ:function(a,n){return a&n},hbgqg:function(a,n){return a(n)},LGvOB:function(a,n){return a===n},EaKRF:function(a,n){return a+n},OaJRI:function(a,n){return a!==n},lqeNn:t(1485),ZyubZ:t(1671),LmjzY:function(a,n){return a+n},rZkFb:function(a,n){return a+n},CUYBz:function(a,n){return a&n},Zhjwg:function(a,n){return a<<n},yoqIs:function(a,n){return a<n},VKvLO:function(a,n){return a(n)},qldwe:function(a,n){return a==n},uegSk:function(a,n){return a&n},OmUqf:function(a,n){return a+n},VRhaS:function(a,n){return a|n},OWgnY:function(a,n){return a<<n},CpLIf:function(a,n){return a&n},IZFNI:function(a,n){return a&n},iHxGd:function(a,n){return a<=n},PJaVg:function(a,n){return a===n},mkufB:t(761),hlLbe:function(a,n){return a+n},QSQvI:function(a,n){return a+n},DEnfr:function(a,n){return a<<n},BmXfq:function(a,n){return a|n},ppxtL:function(a,n){return a<<n},AoQAd:function(a,n){return a&n},UfRom:function(a,n){return a&n},QRdrr:function(a,n){return a<n},Ntgyi:function(a,n,s){return a(n,s)},XtrfW:function(a,n){return a+n},KSsHx:function(a,n,s){return a(n,s)},Qniek:t(1602),wSnLE:function(a,n){return a<n},KlFwI:function(a,n){return a+n},rHJrB:function(a,n){return a<<n},bPbPD:function(a,n){return a<n},RiDJa:function(a,n){return a>=n},lQSnc:function(a,n){return a<n},RVZPY:function(a,n){return a+n},HkERr:function(a,n){return a<n},WzLbf:function(a,n){return a|n},zoThS:function(a,n){return a>>n},yQqVl:function(a,n){return a<n},huUNT:function(a,n){return a|n},cCUvY:function(a,n){return a|n},qzdEg:function(a,n){return a>>n},LMVGY:function(a,n){return a|n},CRBLR:function(a,n){return a&n},UTAia:function(a,n){return a>>n},IhiYp:function(a,n){return a|n},BSfoV:function(a,n){return a|n},vlgzW:function(a,n,s){return a(n,s)},lVpok:function(a,n){return a<n},QGfHG:function(a,n,s){return a(n,s)},fVQFl:"adiar",TiHNq:function(a,n){return a&n},ZlgBa:t(1642)+t(1378)+t(1507)+t(431)+t(1332),TkGGJ:function(a,n){return a===n},dmRdy:function(a,n){return a!==n},fvnnz:t(1232),eIDUq:"pjVfF",joWkl:function(a,n){return a>=n},ZeWzC:function(a,n){return a|n},khriY:function(a,n){return a===n},KcgsC:function(a,n){return a===n},ZfAKW:t(616),jEBWs:t(1538),edVae:t(534)+t(1218)+"s",Mwwoc:t(844),UXVPk:function(a,n,s){return a(n,s)},JVIbK:function(a,n,s,d){return a(n,s,d)},bGAMv:function(a,n,s){return a(n,s)},zezDb:function(a,n){return a(n)},aTtwK:function(a,n){return a(n)},cJqXv:"YDtxW",psdhK:function(a,n){return a(n)},msBxQ:function(a,n){return a&n},ijEVQ:function(a,n){return a&n},PCjxn:function(a,n){return a<<n},nXrHO:function(a,n){return a(n)},MBKZU:function(a,n){return a&n},GiQAM:t(1076),VZGBT:function(a,n){return a(n)},jIluF:function(a,n){return a<<n},BQpPd:function(a,n){return a&n},IRymh:function(a,n){return a&n},UcLqw:function(a,n){return a(n)},eFTAA:function(a,n){return a(n)},ZxVKZ:function(a,n){return a<<n},spSzx:function(a,n){return a&n},mfqLO:function(a,n){return a|n},DGjEl:function(a,n){return a<<n},hwcJY:function(a,n){return a<<n},SRqwD:function(a,n){return a<<n},DRrfj:t(1023),BTLCZ:function(a,n){return a>>>n},ZNQtd:function(a,n){return a>>>n},QRcLe:function(a,n){return a===n},mIZWV:function(a,n){return a<n},DPliN:function(a,n){return a&n},LxdeE:function(a,n){return a|n},jhyia:function(a,n){return a+n},uUZTx:function(a,n){return a>>>n},HrPin:function(a,n){return a&n},QKyci:function(a,n){return a!==n},QReNz:function(a,n){return a>>>n},LxWQR:function(a,n){return a+n},trKtP:function(a,n){return a!==n},IMhxl:function(a,n){return a|n},PRsag:function(a,n){return a+n},AUVXs:function(a,n){return a+n},AOcma:function(a,n){return a>>>n},nDWqK:function(a,n){return a&n},WueVR:function(a,n){return a!==n},fRzBw:function(a,n){return a|n},lsfgM:function(a,n){return a&n},qcmMo:t(1282),GZDbQ:function(a,n){return a===n},EDvfq:t(1704),iFzNh:function(a,n){return a|n},aEhpH:function(a,n){return a<<n},hIBNy:function(a,n){return a|n},Axbqa:function(a,n){return a<<n},FsJqP:function(a,n){return a<<n},SdSLx:function(a,n){return a|n},NtLWN:function(a,n){return a<<n},mauDw:function(a,n){return a<<n},stDsq:function(a,n){return a<<n},HzGto:function(a,n){return a>>>n},vFXbl:function(a,n){return a|n},JxjHD:function(a,n){return a<<n},vitiI:function(a,n){return a>>>n},umewC:function(a,n){return a|n},UhpXu:function(a,n){return a|n},FYNRC:function(a,n){return a<<n},yXelR:function(a,n){return a&n},NKzTf:function(a,n){return a>>>n},lUlVL:function(a,n){return a&n},IZPne:function(a,n){return a>>>n},WsoGQ:function(a,n){return a>>>n},MNmfH:function(a,n){return a<=n},RAScR:function(a,n){return a%n},VboRL:function(a,n){return a|n},Yukee:function(a,n){return a/n},sINBD:function(a,n){return a+n},MYCPZ:function(a,n){return a*n},rEPyI:function(a,n){return a===n},kBGyY:function(a,n){return a===n},YuKim:t(1308),ebKdx:function(a,n){return a&n},wnfNR:function(a,n){return a>>>n},wSmGg:function(a,n){return a<<n},Sjgzj:function(a,n){return a|n},QshlO:function(a,n){return a!==n},PuCMs:function(a,n){return a>>>n},sMfEU:"pagehide",dBUqF:t(863),iSJll:t(1145),osxRi:function(a,n){return a===n},OvlRO:function(a,n){return a+n},CotEB:function(a,n){return a&n},Keyiw:function(a,n){return a>>>n},uCPur:function(a,n){return a>>>n},LGAle:function(a,n){return a>>>n},PZHYI:t(1098),Oiabc:function(a,n){return a>>>n},KICPl:function(a,n){return a>>>n},WzeqQ:t(859)+"RROR",vFZee:"MESSAGE_"+t(676),UjufG:"MAX_RETR"+t(1189)+"R",udBct:t(734)+t(639),cYWeh:t(1256)+"OR",XPToO:t(864)+"2|0|4",oViCp:t(392),pOsSl:"ynikK",TAiOl:function(a,n,s){return a(n,s)},tEQpe:function(a,n,s){return a(n,s)},PUpVR:t(696),XBUiU:t(414),BsdDP:function(a,n){return a===n},zjAah:t(911),KRjdR:function(a,n){return a+n},ByzWS:function(a,n){return a===n},wLRQl:t(868),ZjucJ:function(a,n){return a!==n},MjoeD:t(1253),XFXIM:function(a,n){return a===n},JleEB:t(775),aZUvL:function(a,n,s){return a(n,s)},kyBah:"close",QJPwJ:t(1088),bAWSj:function(a,n){return a===n},bUcId:"yyMwZ",LWzxA:function(a,n){return a instanceof n},YdOrk:t(1547),rZmCC:function(a,n){return a<n},GZzqQ:function(a,n){return a(n)},nyaNr:t(1156),oAIPh:function(a,n){return a!==n},WmnEZ:"TjmIf",tXEPk:function(a,n,s,d){return a(n,s,d)},QXkQK:"service",QGziP:t(1081)+t(853),BUjwM:function(a,n,s,d){return a(n,s,d)},zOvzp:t(1053),BdixF:t(1095)+"ervice",YqAtR:t(1554)+t(664),sEmgW:function(a,n){return a!==n},vsAqi:t(1586),vEdvy:function(a,n){return a||n},oIyaV:function(a,n){return a!=n},nAPtC:t(294)+"d",eYraM:function(a,n){return a<=n},PyBMu:function(a,n){return a===n},UOyZj:function(a,n){return a-n},WMhKw:function(a,n){return a&n},fluCC:function(a,n){return a&n},FXSvl:function(a,n){return a|n},nxJtN:function(a,n){return a|n},paMrG:function(a,n){return a<<n},GHpsh:function(a,n){return a<<n},DWGbu:function(a,n){return a>>n},cwnNB:function(a,n){return a+n},RrANU:function(a,n){return a<n},HWbbD:"fEoAM",mlJst:t(1741),Vjrur:function(a,n){return a|n},xJmKP:function(a,n){return a>>n},zKrNm:function(a,n){return a===n},OTgqg:function(a,n){return a===n},CPzQy:t(310),GOKQd:t(835)+t(629),PhJui:function(a,n){return a&n},Xalvp:function(a,n){return a&n},NuxDT:function(a,n){return a>>n},kkeXG:function(a,n){return a|n},erdKf:function(a,n){return a>>n},FYXqZ:function(a,n){return a&n},tqXNE:function(a,n){return a-n},wqWyu:t(362),PlJyk:"string",UhmXD:function(a,n){return a!==n},mFCqm:t(720),vDGwX:function(a,n){return a instanceof n},poGnZ:function(a,n,s){return a(n,s)},tcDfj:function(a,n,s){return a(n,s)},VYUVu:t(598)+t(1643)+t(1296)+"ine",CpHOF:function(a,n){return a===n},fTnaU:t(1290),IlSUn:t(979),mxxTX:function(a,n){return a==n},zHwUP:t(1456)+t(994)+t(1722),dbxzK:function(a,n){return a<<n},ESnmn:function(a,n){return a===n},VCTvn:t(1276),qVcqM:t(1552),FPhfB:t(459),fDbxa:function(a,n){return a>>>n},BtXhk:function(a,n){return a(n)},rPkcE:function(a,n){return a!==n},HkvvO:t(1310),MEWqF:t(1355)+"reason",gCzDd:t(759),kKmOz:t(476),cHBCx:t(1327),eDvCR:"text/jav"+t(998),nROxg:t(849),qBSeU:t(894)+t(1725)+"tierJSONP",ROHCN:t(1555),wxDyG:function(a){return a()},wSTdx:function(a,n){return a===n},pXicR:t(372),mSxwQ:function(a,n){return a===n},zVlLd:"KlCQy",AsLxL:t(1499),LscKq:t(351),oLmIN:t(963),RstCY:function(a,n){return a||n},OQVzd:t(527),YkbsZ:"KqmMG",NltlH:"TSwwI",eREbK:function(a,n){return a!==n},vgPVg:"MmjPw",lXKsw:t(502),wgNJE:function(a,n){return a||n},MHNOF:t(717),PLhXm:function(a,n){return a||n},oFITY:t(1286),inwfG:"aBPHp",BRJUi:t(324)+"DB failed",uMydh:function(a,n,s){return a(n,s)},iITMo:"qos",XVnFe:t(1083)+"id",qhJuO:function(a,n,s){return a(n,s)},OoiTW:t(367),QDJKz:t(1193),qmFDT:function(a,n){return a(n)},GjVMy:function(a,n,s,d){return a(n,s,d)},BIBLY:t(985)+t(358)+"k",ZZyXC:t(985)+t(1403)+"sgid",fmJdo:function(a,n){return a+n},IMnGi:function(a,n){return a+n},lpcAh:t(600),fMYpl:t(333),VdhDj:"need_ack",cVyTN:t(344),GuFVg:t(1132),GwvqY:function(a,n){return a||n},NawbU:"ack_code",gGKOJ:function(a,n){return a(n)},MtwIn:function(a,n){return a(n)},idSel:function(a,n){return a instanceof n},OPtfB:t(1472)+t(332),sjrxB:t(1472)+"ion/json"+t(1691)+t(1615),mBceU:t(1588)+"e",AruCE:t(641),geuGA:t(649),bzhZU:function(a,n){return a>n},HcffR:function(a,n){return a(n)},UTmzZ:function(a,n){return a>n},ZeiHK:function(a,n){return a(n)},gcidw:function(a,n){return a&n},XoERq:function(a,n){return a|n},aQRyq:function(a,n){return a||n},lFaKm:t(1222),BDHcj:function(a,n){return a(n)},EiDai:function(a,n){return a+n},ooWMG:function(a,n){return a+n},KOHGV:t(1463),WYzQv:function(a,n){return a||n},QPRuI:"integer too large",glueE:function(a,n){return a&n},jqtXi:function(a,n){return a+n},MwWhj:function(a,n){return a<n},IQdcw:t(910),slECo:t(550),fFDgI:function(a,n,s){return a(n,s)},uViMc:function(a,n){return a>>>n},CRqgw:function(a,n){return a<<n},SVtmm:function(a,n){return a!==n},JLoEO:t(1216),gIGus:function(a,n){return a+n},LKpKM:function(a,n){return a+n},INNzJ:function(a,n){return a+n},kivIm:function(a,n){return a+n},EfjOR:function(a,n){return a|n},IasUk:function(a,n){return a+n},GdadS:function(a,n){return a<<n},KQsDR:function(a,n){return a|n},xElho:function(a,n){return a<<n},xPkcr:function(a,n){return a+n},HqMLa:function(a,n){return a+n},admlL:function(a,n){return a+n},ScTZB:function(a,n){return a+n},YeOBW:function(a,n){return a>>>n},AjCaX:function(a,n){return a&n},UAJtn:function(a,n){return a+n},jFsqQ:function(a,n){return a>>>n},iqxpE:function(a,n){return a+n},hmhHW:function(a,n){return a&n},tiyaS:function(a,n){return a+n},ixOaj:"8|11|10|4|5|7|9|"+t(782)+"3",ltTjy:function(a,n){return a|n},dDaSY:function(a,n){return a<<n},ihsNW:function(a,n){return a|n},ZXERI:function(a,n){return a>>>n},vsZSq:function(a,n){return a<<n},EHUEK:function(a,n){return a<n},ABafm:"curvalue",HWnZD:t(853),BpuVN:function(a,n){return a+n},cOLSS:function(a,n,s){return a(n,s)},cZskx:t(515)+t(1606),vKdrW:function(a,n){return a!==n},QTQer:"raSuD",RBzVt:"allCurso"+t(828),yDQBe:"ALL",uQSfh:t(1054),EuTkB:"CONTINUE",rcYJK:t(1252)+"r",EEEgt:t(1521),OpqEP:function(a,n){return a*n},eLtXS:function(a,n){return a||n},acrZF:function(a,n){return a===n},vbPVB:t(1446),bqFcK:t(1751),lqgfq:t(985)+t(453),OEANE:t(1730)+"rsor_name",VSytm:function(a,n){return a(n)},dmqLW:function(a,n,s){return a(n,s)},ECQoQ:function(a){return a()},XkdII:function(a,n){return a>n},tBIxK:function(a,n){return a>n},nQUWX:t(1318),buWXq:function(a,n){return a+n},eLatU:function(a){return a()},jjqDT:function(a){return a()},VZkeZ:t(1165),ANjmH:function(a){return a()},WRmJX:function(a){return a()},JWlPH:function(a,n){return a&&n},WeHRz:function(a){return a()},Pjfjo:function(a){return a()},kRJUu:function(a){return a()},XCDVz:function(a,n){return a!==n},ohutZ:function(a){return a()},UGCpl:function(a,n){return a<n},Dontx:t(315),CyLhJ:t(971),AcRoX:function(a){return a()},ExTHM:function(a,n){return a===n},SrIDg:t(513),xVHrD:t(1765),mpdhV:function(a,n){return a===n},aLSFn:function(a,n){return a===n},DpAgN:function(a,n,s,d){return a(n,s,d)},SwDUh:function(a,n,s){return a(n,s)},haVNs:function(a,n){return a!==n},uaZGb:function(a,n){return a!==n},LeWcL:function(a,n){return a(n)},rVNde:function(a,n){return a===n},OlOuk:t(1760),BMQkk:function(a,n){return a>>>n},lFMDI:function(a,n){return a>>>n},AKuVp:function(a,n){return a&n},wyuQn:function(a,n){return a+n},OslDs:function(a,n){return a+n},woeaz:function(a,n){return a>>>n},spXCd:function(a,n){return a|n},JDqja:function(a,n){return a<<n},Xtvjm:function(a,n){return a|n},eBtgs:function(a,n){return a<<n},QRyas:function(a,n,s){return a(n,s)},einLm:function(a,n,s){return a(n,s)},uoexz:t(1177),fQqST:function(a,n){return a/n},OnyHG:t(546)+"rovide v"+t(558),NuFac:"tNAUz",JLpiJ:t(1055)+"t",JcgzD:t(855)+t(821)+t(1449)+"ct",GdKRs:t(801),oTyUh:function(a,n){return a|n},qzzrt:function(a,n){return a<n},xtohh:function(a,n){return a<n},oWkLQ:function(a,n){return a<<n},MfEAB:function(a,n){return a!==n},WeHMI:t(478),dyVXb:t(739),vZHqn:function(a,n){return a<<n},Hqmxq:function(a,n){return a&n},MvwMo:t(601),LNmsP:t(841),RfhbC:t(571),WzqDp:function(a,n){return a==n},KTmbF:t(1124),vYyfA:t(1404),eBPCJ:t(1150),lbrol:"ttwid",talrU:t(444)+"d",voGpz:t(546)+t(1410)+t(487)+t(353)+"r ttwID",MynjE:function(a){return a()},jbbMz:t(1682),zVCIN:t(1582)+"0",QefVT:function(a,n){return a===n},SKhyu:function(a,n,s){return a(n,s)},Iwwhl:function(a,n,s){return a(n,s)},gZMGE:t(615),RZHfp:function(a,n){return a(n)},paATF:function(a,n){return a(n)},GukEB:"UNghV",tfTRD:function(a,n){return a===n},cOBgO:function(a,n,s){return a(n,s)},OUFGa:function(a,n){return a!==n},Uevqn:t(514),KYGkW:t(598)+t(1690)+t(1055)+t(1542)+"ver",POwcc:function(a,n){return a!==n},KwqIl:"SWUiF",rZPpV:"timeout, try rec"+t(1363)+"g",vDTGL:"3|0|4|2|1",tUoCH:function(a,n){return a(n)},SzFaU:function(a,n){return a!==n},GcMRX:"jOzQv",iGTod:t(955),nrhpx:"0|4|2|1|3",XPmWh:t(1603),Gpghz:t(578),qBRNN:function(a,n){return a!==n},IdmQc:t(1140),cIMFQ:function(a,n){return a instanceof n},tmqgA:function(a,n){return a instanceof n},EDZkk:function(a,n){return a!==n},fhxQC:t(1214),YNoIK:t(810)+t(665),ZbwnW:t(479)+t(714)+t(1649),sVzLX:t(546)+t(780)+t(379)+t(1162)+t(826)+t(341)+t(1274)+t(1170)+t(1238),lgkaU:function(a,n){return a==n},fWbHC:t(1103),EeIcC:function(a,n){return a instanceof n},vFXMf:function(a,n){return a instanceof n},dnvRz:function(a,n){return a(n)},GNGXO:function(a,n){return a(n)},PoXtJ:function(a,n){return a||n},oTFTJ:t(546)+t(780)+t(1629)+t(1413),aGOPV:function(a,n){return a===n},UBGrm:t(830),cACUT:function(a,n){return a||n},lwkRX:function(a,n){return a+n},NqCjg:function(a,n,s){return a(n,s)},YQgKn:t(534)+t(1409)+"t",Uqcje:function(a,n){return a!==n},aHXyp:t(1590),THVLi:t(1026),GMYUO:function(a,n){return a*n},zPDYO:function(a,n){return a*n},dvotH:function(a,n){return a/n},DYQmX:function(a,n){return a!=n},CGlRD:function(a,n){return a===n},FKqCk:t(462),knaut:function(a,n){return a!=n},QLHLS:function(a,n){return a===n},mLcTp:function(a,n){return a===n},SLaIU:t(984),ztRTZ:function(a,n){return a===n},FkBrN:function(a,n){return a!=n},FukHh:function(a,n){return a!=n},KpGaC:function(a,n){return a===n},ESWGI:t(1152)+t(1299)+t(1338)+"pe",wIjUr:function(a,n){return a===n},Cimyo:function(a,n){return a===n},nCcFC:t(1090)+t(1247)+t(493),MCLcg:function(a,n){return a!=n},eXScs:function(a,n){return a===n},ONvkt:function(a,n,s){return a(n,s)}};Mt.r(De),Mt.d(De,{FWS:()=>Mp,CustomErrorEvent:()=>Fd,createCloseEvent:()=>pt,ReconnectEvent:()=>zd,createErrorEvent:()=>dt,decodedFrame:()=>Xt,createOpenEvent:()=>Wd,CustomCloseEvent:()=>Ud,createReconnectEvent:()=>ia,FrontierMessageEvent:()=>qd,encodeFrame:()=>Ft,createMessageEvent:()=>jd,OpenEvent:()=>Hd,ErrorCode:()=>en,Event:()=>Zn,MessageEvent:()=>Gd});let r="";function i(a=""){let n=t,s="02",d=""+Date[n(1631)](),f=r||(r=e[n(354)](h,a)),g=Math[n(1432)]()[n(1706)](16)[n(724)](-6);return e[n(1622)](e[n(357)](e.UwdDl(s,d),f),g)}function o(){let a=t;return e[a(357)](1e4*Date[a(1631)](),Math[a(575)](e[a(939)](1e4,Math[a(1432)]())))}function c(a){let n=t;return(e[n(354)](Array,8).join("0")+parseInt(a,10).toString(2))[n(724)](-8)}function l(a){let n=t;return e.gwUyv(e[n(470)](Array,4)[n(490)]("0"),e[n(426)](parseInt,a,2)[n(1706)](16))[n(724)](-4)}function u(a){let n=t,s=a[n(466)](/\./)[n(1241)](g=>c(g)),d=[];return d[0]=e[n(567)](l,e.dgKPu(s[0],s[1])),d[1]=e[n(354)](l,s[2]+s[3]),[n(711),e[n(633)],e[n(633)],e.xrDoF,e[n(633)],e[n(1187)],d[0],d[1]][n(490)]("")}function h(a){let n=t,s=/(25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?)(\.(25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?)){3}/[n(1549)](a),d=/(([0-9a-fA-F]{1,4}:){7,7}[0-9a-fA-F]{1,4}|([0-9a-fA-F]{1,4}:){1,7}:|([0-9a-fA-F]{1,4}:){1,6}:[0-9a-fA-F]{1,4}|([0-9a-fA-F]{1,4}:){1,5}(:[0-9a-fA-F]{1,4}){1,2}|([0-9a-fA-F]{1,4}:){1,4}(:[0-9a-fA-F]{1,4}){1,3}|([0-9a-fA-F]{1,4}:){1,3}(:[0-9a-fA-F]{1,4}){1,4}|([0-9a-fA-F]{1,4}:){1,2}(:[0-9a-fA-F]{1,4}){1,5}|[0-9a-fA-F]{1,4}:((:[0-9a-fA-F]{1,4}){1,6})|:((:[0-9a-fA-F]{1,4}){1,7}|:)|fe80:(:[0-9a-fA-F]{0,4}){0,4}%[0-9a-zA-Z]{1,}|::(ffff(:0{1,4}){0,1}:){0,1}((25[0-5]|(2[0-4]|1{0,1}[0-9]){0,1}[0-9])\.){3,3}(25[0-5]|(2[0-4]|1{0,1}[0-9]){0,1}[0-9])|([0-9a-fA-F]{1,4}:){1,4}:((25[0-5]|(2[0-4]|1{0,1}[0-9]){0,1}[0-9])\.){3,3}(25[0-5]|(2[0-4]|1{0,1}[0-9]){0,1}[0-9]))/[n(1549)](a);return s?u(a):d?e[n(567)](x,a):e[n(1028)]}function x(a){let n=t,s="",d=[],f=0,g=0,m=!0,y=e[n(633)];if(a[n(429)]("::")>-1)if(e[n(446)]!==e[n(1506)]){let p=a[n(466)]("::");for(let L=0;L<p[n(1762)];L++){let z=p[L];if(e[n(933)](z.indexOf(":"),0)){let q=z.split(":");m&&(f=q[n(1762)]),g+=q[n(1762)];for(let K=0;e[n(359)](K,q.length);K++)if(q[K][n(1762)]!==4){let te=y[n(297)+"g"](0,e[n(740)](4,q[K][n(1762)])),Ze=te.concat(q[K]);d[n(1529)](Ze)}else d.push(q[K]);m=!1}else{if(e[n(972)](4,z[n(1762)])){let q=y.substring(0,e[n(738)](4,z[n(1762)])),K=q[n(709)](z);d[n(1529)](K)}else d[n(1529)](z);m&&(f+=1),g+=1,m=!1}}let k="";for(let L=0;e[n(359)](L,e[n(740)](8,g));L++)k=k.concat(y);for(let L=0;e[n(1279)](L,d[n(1762)]);L++)L===f&&(s=s.concat(k)),s=s[n(709)](d[L]);return s}else this[n(417)+n(1049)]=null;{let p=a[n(466)](":");for(let k=0;k<p[n(1762)];k++){let L=p[k];if(p[k].length!==4){let z=y[n(297)+"g"](0,e.bzynE(4,p[k][n(1762)])),q=z[n(709)](L);s=s[n(709)](q)}else s=s[n(709)](L)}return s}}function w(a,n){let s=t,d={CNYNi:function(m,y){return e[F(1513)](m,y)},hyyAN:function(m,y){return e[F(1107)](m,y)},yGhGl:function(m,y){return m>y},tZXBd:function(m,y){return e.wAzPD(m,y)},UQNPN:function(m,y){return e[F(965)](m,y)},MrvGU:function(m,y){return e[F(1543)](m,y)},aMEUE:function(m,y){return e.tuFro(m,y)}},f=a[s(1263)];e[s(972)](void 0,f)&&(he(n,10),e[s(427)](H,n,f));let g=a[s(583)];if(e[s(972)](void 0,g))if(e[s(1199)](e[s(1072)],e[s(1072)]))e.QHmDL(he,n,18),H(n,g);else{let m=_0x28636e||8192,y=m>>>1,p=null,k=m;return function(L){let z=s;if(d[z(622)](L,1)||L>y)return d.hyyAN(_0x136bdf,L);d.yGhGl(k+L,m)&&(p=d.tZXBd(_0x5a8745,m),k=0);let q=_0x1ca2de[z(501)](p,k,k+=L);return d[z(1470)](7,k)&&(k=d.MrvGU(d.aMEUE(7,k),1)),q}}}function E(a){let n=t,s={};e:for(;!e.UvywI(Z,a);){let d=e[n(1107)](fe,a);switch(e.emAaU(d,3)){case 0:break e;case 1:s[n(1263)]=e.hXuNg(P,a,e.UvywI(fe,a));break;case 2:s[n(583)]=e.QHmDL(P,a,fe(a));break;default:e[n(427)](R,a,e[n(965)](7,d))}}if(e.coxKP(void 0,s.key))throw new Error(e.aVTZB);if(e[n(1199)](void 0,s[n(583)]))throw new Error(n(1676)+n(524)+" field: "+n(583));return s}function I(a){let n=t,s=e[n(1250)](C);return e[n(1217)](b,a,s),e[n(567)](B,s)}function b(a,n){let s=t,d={iNnOq:function(se,oe){return e[F(965)](se,oe)},KVrEA:function(se,oe){return e[F(457)](se,oe)},vVqGx:function(se,oe){return se>>>oe},nSime:function(se,oe){return e[F(1344)](se,oe)},vSFba:function(se,oe){return e[F(1652)](se,oe)}},f=a.SeqID;f!==void 0&&(e[s(467)](he,n,8),xt(n,f));let g=a.LogID;e.CqfiB(void 0,g)&&(e[s(1244)](he,n,16),e[s(380)](xt,n,g));let m=a[s(1713)];e[s(1077)](void 0,m)&&(he(n,24),e.imQJZ(xt,n,O(m)));let y=a[s(1392)];e[s(336)](void 0,y)&&(e[s(652)](he,n,32),e[s(1024)](xt,n,e[s(856)](O,y)));let p=a[s(396)];if(p!==void 0)for(let se of p){e[s(427)](he,n,42);let oe=e[s(435)](C);e[s(1278)](w,se,oe),e[s(757)](he,n,oe[s(1509)]),e[s(540)](W,n,oe),D(oe)}let k=a["payloadE"+s(511)];e[s(1077)](void 0,k)&&(he(n,50),H(n,k));let L=a["payloadT"+s(1491)];if(e[s(1122)](void 0,L))if(s(935)!==e.IIGWo)he(n,58),e[s(1244)](H,n,L);else{let se=this[s(944)],oe=this[s(1619)];return[255&oe,d[s(1566)](d[s(1294)](oe,8),255),oe>>>16&255,d.vVqGx(oe,24),d[s(1566)](255,se),d[s(1709)](se>>>8,255),d[s(1709)](se>>>16,255),d.vSFba(se,24)]}let z=a[s(597)];e[s(1281)](void 0,z)&&(e[s(757)](he,n,66),e[s(1696)](he,n,z[s(1762)]),pe(n,z));let q=a[s(561)];if(q!==void 0)if(e[s(1199)](e[s(1450)],e[s(836)])){let se=this[s(516)+"tManager"]?.["checkRea"+s(1595)+"es"](),oe=this[s(516)+"tManager"]?.[s(443)+"ntEndpoint"]();if(se&&!_0x2d0d25[s(1088)]){let rt=s(1243)+oe+(s(498)+"ax retri"+s(902)+"ed");this["_dispatc"+s(1627)+"ent"](e[s(433)](_0x4475d5,e[s(512)],{message:rt,code:_0x1ec604[s(1597)+s(1189)+"R"],error:_0x339bec}));return}this[s(507)]&&this[s(507)][s(792)+"te"]===this[s(847)]&&this["_disconn"+s(403)](),this[s(1638)+s(1627)+s(1559)](e[s(426)](_0xc6d179,e.mrVLn,{message:_0x34ffa1.message,code:_0x488cfc[s(859)+s(753)],error:_0x2b5adc}))}else e[s(880)](he,n,74),e.EuqVA(H,n,q);let K=a[s(1260)+s(1046)];e[s(1133)](void 0,K)&&(he(n,82),e.AEAeq(H,n,K));let te=a.msgID;te!==void 0&&(e.ttVCi(he,n,90),e[s(433)](H,n,te));let Ze=a[s(1123)+"e"];e[s(702)](void 0,Ze)&&(he(n,96),e.ECbKG(xt,n,e.UvywI(O,Ze)))}function v(a){return e[t(567)](A,M(a))}function A(a){let n=t,s={};e:for(;!e.QUXbY(Z,a);)if(e[n(1564)]===e[n(1564)]){let d=e[n(564)](fe,a);switch(e.ivQyi(d,3)){case 0:break e;case 1:s.SeqID=e.twIZH(It,a,!0);break;case 2:s[n(871)]=It(a,!0);break;case 3:s[n(1713)]=e[n(770)](fe,a);break;case 4:s[n(1392)]=e.QUXbY(fe,a);break;case 5:{let f=S(a);(s[n(396)]||(s.headers=[]))[n(1529)](e.VrJlN(E,a)),a[n(1509)]=f;break}case 6:s[n(542)+n(511)]=e[n(1278)](P,a,fe(a));break;case 7:s[n(418)+"ype"]=e.hmRQj(P,a,fe(a));break;case 8:s[n(597)]=e.YeDYy(Ee,a,e[n(1326)](fe,a));break;case 9:s[n(561)]=e[n(652)](P,a,e[n(1742)](fe,a));break;case 10:s[n(1260)+"ming"]=e.YqREn(P,a,fe(a));break;case 11:s.msgID=P(a,e[n(1340)](fe,a));break;case 12:s.frameType=e[n(354)](fe,a);break;default:e[n(1024)](R,a,e[n(1344)](7,d))}}else{if(e[n(1230)](_0x500de5,-_0x150702))return _0x2876bb;if(e[n(1660)](e[n(287)](_0x47cb03,1),_0x47d4ba))return _0x424fa8}if(e[n(1502)](void 0,s[n(1466)]))throw new Error(e[n(1352)]);if(e[n(802)](void 0,s.LogID))throw new Error(e[n(520)]);if(s[n(1713)]===void 0)throw new Error(e[n(570)]);if(s[n(1392)]===void 0)throw new Error(e[n(692)]);return s}function S(a){let n=t,s=fe(a),d=a[n(1509)];return a[n(1509)]=e[n(1435)](a[n(653)],s),d}function R(a,n){let s=t;switch(n){case 0:for(;e[s(965)](128,e.wAzPD(ie,a)););break;case 2:V(a,fe(a));break;case 5:e[s(433)](V,a,4);break;case 1:e[s(796)](V,a,8);break;default:throw new Error(e[s(1622)]("Unimplem"+s(754)+"pe: ",n))}}function O(a){return a|=0,{low:a,high:e.SSfhP(a,31),unsigned:e.qoQnm(a,0)}}let _=[];function C(){let a=t,n=_[a(1351)]();return n?(n[a(653)]=n[a(1509)]=0,n):{bytes:new Uint8Array(64),offset:0,limit:0}}function D(a){_[t(1529)](a)}function M(a){return{bytes:a,offset:0,limit:a[t(1762)]}}function B(a){let n=t,s=a[n(551)],d=a.limit;return e[n(1185)](s[n(1762)],d)?s:s[n(1271)](0,d)}function V(a,n){let s=t;if(e[s(933)](e.lXXvn(a[s(653)],n),a[s(1509)]))throw new Error(e.sonkQ);a[s(653)]+=n}function Z(a){let n=t;if(e[n(1568)](e.HvZdz,n(1501)))this[n(507)]&&this._ws[n(1535)](_0x1eb466,_0x436b42);else return e.qoQnm(a[n(653)],a[n(1509)])}function ee(a,n){let s=t,d=a[s(551)],f=a[s(653)],g=a[s(1509)],m=e[s(1435)](f,n);if(e[s(1679)](m,d[s(1762)]))if(e[s(1307)](s(677),e[s(1382)]))_0x5de466[s(481)](_0x4a8a81);else{let y=new Uint8Array(e[s(939)](2,m));y[s(1481)](d),a[s(551)]=y}return a[s(653)]=m,e[s(1679)](m,g)&&(a[s(1509)]=m),f}function X(a,n){let s=t,d=a.offset;if(e[s(933)](e[s(1622)](d,n),a.limit))throw new Error(s(1328)+s(827));return a[s(653)]+=n,d}function Ee(a,n){let s=t,d=X(a,n);return a.bytes[s(1271)](d,d+n)}function pe(a,n){let s=t,d=ee(a,n.length);a.bytes[s(1481)](n,d)}function P(a,n){let s=t;if(e.rYGEY(e[s(895)],e[s(579)]))return{bytes:_0x5cd6f2,offset:0,limit:_0x1ad2c2[s(1762)]};{let d=e[s(773)](X,a,n),f=String[s(1688)+"Code"],g=a.bytes,m="\uFFFD",y="";for(let p=0;e[s(1235)](p,n);p++)if(e[s(1581)]!==e[s(878)]){let k=g[e.gwUyv(p,d)],L,z,q,K;if(e[s(1502)](e[s(610)](128,k),0))y+=e[s(1467)](f,k);else if(e.LGvOB(224&k,192))if(e[s(1660)](e[s(608)](p,1),n))y+=m;else if(e.OaJRI(e[s(1444)],e[s(599)]))L=g[e.LmjzY(e[s(1022)](p,d),1)],e[s(981)](192,L)!==128?y+=m:(K=e.wMvRY(e[s(783)](e[s(610)](31,k),6),63&L),e[s(541)](K,128)?y+=m:(y+=e.VKvLO(f,K),p++));else return this[s(1333)].protocol;else if(e.qldwe(e.uegSk(240,k),224))if(e[s(1040)](p,2)>=n)y+=m;else if(L=g[e[s(608)](p+d,1)],z=g[e[s(1248)](e[s(1647)](p,d),2)],e[s(662)]((L|z<<8)&49344,32896))y+=m;else if(K=e.VRhaS(e[s(506)](e[s(675)](e.MQtOM(15,k),12),e.CpLIf(63,L)<<6),e[s(322)](63,z)),e.sCYMb(K,2048)||K>=55296&&e[s(1517)](K,57343))y+=m;else if(e[s(1160)](s(1698),e[s(1460)])){let te=_0xe177a6[s(377)+"At"](_0x2f8461);e[s(793)](te,55296)&&e[s(1607)](te,56319)&&e[s(359)](e.gJuqX(_0x5d0370,1),_0x25ba64)&&(te=e[s(602)](te,10)+_0x45bac0[s(377)+"At"](++_0x39e220)-56613888),te<128?_0x24e1f5[_0x1e674e++]=te:(te<2048?_0x54434e[_0x41159f++]=e[s(636)](e.xBwGU(e[s(744)](te,6),31),192):(e.ORMqS(te,65536)?_0x3c410a[_0x3e98b3++]=e[s(1387)](e[s(832)](e.zcCNS(te,12),15),224):(_0x1fb84b[_0x429632++]=e[s(424)](e[s(1304)](te,18)&7,240),_0x2c44e[_0x156438++]=e[s(424)](e[s(1692)](e[s(970)](te,12),63),128)),_0x5b55bc[_0x235b91++]=e[s(588)](te,6)&63|128),_0x4820ec[_0x28649a++]=e[s(842)](63,te)|128)}else y+=e.ZrUYW(f,K),p+=2;else e[s(1321)](248&k,240)?p+3>=n?y+=m:(L=g[e[s(789)](e[s(1504)](p,d),1)],z=g[e[s(1248)](p,d)+2],q=g[e[s(1364)](e.mFvOV(p,d),3)],e[s(1281)]((e[s(636)](L,e[s(423)](z,8))|q<<16)&12632256,8421504)?y+=m:(K=e.wMvRY(e[s(1585)](e[s(630)](e.xBwGU(7,k),18)|e[s(602)](e[s(929)](63,L),12),e[s(1184)](63,z)<<6),e[s(922)](63,q)),e[s(618)](K,65536)||K>1114111?y+=m:(K-=65536,y+=e[s(735)](f,e[s(1364)](e[s(970)](K,10),55296),e[s(326)](1023&K,56320)),p+=3))):y+=m}else this["_miniNav"+s(1330)+s(850)]=_0x21fed5,_0x2a9e2a?this[s(953)+s(1085)]():this[s(953)+s(1505)]();return y}}function H(a,n){let s=t;if(e[s(1122)](e.Qniek,s(581))){let d=n[s(1762)],f=0;for(let y=0;e[s(1513)](y,d);y++){let p=n[s(377)+"At"](y);e[s(1660)](p,55296)&&e[s(1607)](p,56319)&&e[s(1239)](e[s(1366)](y,1),d)&&(p=e[s(619)](e[s(1248)](e[s(1764)](p,10),n[s(377)+"At"](++y)),56613888)),f+=p<128?1:e[s(1422)](p,2048)?2:e[s(359)](p,65536)?3:4}e[s(773)](he,a,f);let g=e[s(880)](ee,a,f),m=a[s(551)];for(let y=0;y<d;y++){let p=n[s(377)+"At"](y);e[s(485)](p,55296)&&e[s(1607)](p,56319)&&e.lQSnc(e.OmUqf(y,1),d)&&(p=e[s(738)](e[s(1412)](p<<10,n[s(377)+"At"](++y)),56613888)),e.DWUJm(p,128)?m[g++]=p:(e[s(441)](p,2048)?m[g++]=e.WzLbf(e.IZFNI(e[s(1637)](p,6),31),192):(e[s(1731)](p,65536)?m[g++]=e.huUNT(p>>12&15,224):(m[g++]=e[s(1061)](e[s(842)](e.qzdEg(p,18),7),240),m[g++]=e[s(532)](e[s(786)](e[s(1620)](p,12),63),128)),m[g++]=e[s(1106)](e[s(832)](p>>6,63),128)),m[g++]=e[s(549)](63&p,128))}}else this._cursorNameSpace=_0x44f8bf,this[s(820)+"ileName"]=_0x3f6c20,this[s(710)+s(1159)]=_0x49480b,this[s(1039)]=e[s(1331)](_0x23fe7d,this[s(943)+s(1237)],s(1551)+"ame")}function W(a,n){let s=t,d=e[s(1528)](ee,a,n.limit),f=a.bytes,g=n[s(551)];for(let m=0,y=n[s(1509)];e[s(1298)](m,y);m++)f[e[s(525)](m,d)]=g[m]}function ie(a){let n=t;return a[n(551)][e[n(475)](X,a,1)]}function Ve(a,n){let s=t,d=e[s(1019)](ee,a,1);a[s(551)][d]=n}function fe(a){let n=t,s=0,d=0,f;do e[n(1307)](e.fVQFl,e[n(386)])?(_0x2a064b(_0x31e2af,50),_0x4a3837(_0x568a60,_0x345f7e)):(f=ie(a),s<32&&(d|=e[n(675)](e[n(981)](127,f),s)),s+=7);while(e[n(1594)](128,f));return d}function he(a,n){let s=t,d={FuNfO:e[s(1609)],DufEJ:function(f,g){return e.TkGGJ(f,g)},OHXxJ:function(f,g){return f+g}};if(e[s(875)](e[s(840)],e.eIDUq)){for(n>>>=0;e[s(1438)](n,128);)Ve(a,e[s(860)](e.MSsjt(127,n),128)),n>>>=7;Ve(a,n)}else return _0x319729<=_0x4bb066?_0x403936.reject(new _0x2826e1(d[s(1646)])):(_0x2bdd6a=_0xda85c8,d[s(519)](_0x1f26ff,_0x33e201[s(1762)])?_0x4cd40b[s(766)]():_0x1363e6[_0x4fc1f6].bind(_0x4379fd)(_0x5bd30c,_0x3309f8[s(626)](null,d.OHXxJ(_0x574df9,1))))}function It(a,n){let s=t;if(e[s(537)]!==e[s(537)]){let{pingInterval:d,pingFrequency:f}=this[s(1342)];if((e.khriY("hi",_0x3e482c[s(1625)])&&e[s(1745)](e.ZfAKW,f)||e[s(659)](e[s(552)],f))&&(this[s(400)+s(1553)](),this.emit(e[s(674)],e.Mwwoc),this[s(1497)+s(885)+"Id"]=e[s(1069)](_0x54f89d,this._ping.bind(this),d)),e[s(1160)]("hi",_0x1847b5.data))return;try{e.JVIbK(_0x209b54,this,_0x4c17a1,[_0x2f3121,_0x3a61b3,_0x329868,_0x4c2436,_0x107424,_0x39bcce])}catch(g){let m=e[s(1644)](_0x524c8a,s(1558),{message:g.message,code:_0x81f0cb[s(1401)+s(676)],error:g});this[s(1638)+s(1627)+"ent"](m)}}else{let d=0,f=0,g=0,m;return m=ie(a),d=127&m,e[s(1594)](128,m)&&(m=e[s(1144)](ie,a),d|=e[s(423)](e[s(920)](127,m),7),e[s(587)](128,m)&&(m=e[s(311)](ie,a),d|=e[s(675)](127&m,14),e[s(587)](128,m)&&(m=e[s(354)](ie,a),d|=e.PCjxn(e.CRBLR(127,m),21),e.CUYBz(128,m)&&(m=e[s(992)](ie,a),f=e[s(929)](127,m),e[s(536)](128,m)&&(m=e[s(564)](ie,a),f|=(127&m)<<7,128&m&&(e.GiQAM===e.GiQAM?(m=e.VZGBT(ie,a),f|=e.jIluF(e[s(452)](127,m),14),e[s(1203)](128,m)&&(m=e.zezDb(ie,a),f|=e[s(675)](127&m,21),e[s(832)](128,m)&&(m=e[s(940)](ie,a),g=e[s(610)](127,m),e[s(965)](128,m)&&(m=e[s(755)](ie,a),g|=e[s(1166)](e[s(1178)](127,m),7))))):(WldZmd[s(1548)](_0x2b8163,WldZmd.aTtwK(_0x2620f2,_0x4552e1[s(1283)])),WldZmd[s(1250)](_0xf6fd00)))))))),{low:e[s(1056)](d,e[s(690)](f,28)),high:e[s(1003)](e[s(1652)](f,4),e[s(1166)](g,24)),unsigned:n}}}function xt(a,n){let s=t,d={GENPB:function(f,g){return e[F(1003)](f,g)},kwcrs:function(f,g){return e[F(316)](f,g)},NlitC:function(f,g){return e[F(675)](f,g)},CYoLf:function(f,g){return e[F(869)](f,g)},AgxGZ:function(f,g){return f|g},dvteZ:function(f,g){return e[F(860)](f,g)},CFECh:function(f,g){return e[F(907)](f,g)}};if(e.wFoAC(e[s(811)],e[s(811)]))return new _0x56e3fc(d[s(1048)](d[s(848)](_0x539f7[0],d[s(691)](_0x2fb294[1],8))|d.CYoLf(_0x1d226a[2],16),_0x3dd761[3]<<24),d[s(848)](d.AgxGZ(d[s(451)](_0x15ee94[4],d[s(445)](_0x2fac1a[5],8)),d[s(691)](_0x4827b9[6],16)),_0x21ff7b[7]<<24),_0x45c89b);{let f=e.BTLCZ(n[s(1619)],0),g=e[s(522)](e.TachT(e.ZNQtd(n[s(1619)],28),e.Zhjwg(n[s(944)],4)),0),m=e[s(1652)](n[s(944)],24),y=m===0?e[s(794)](0,g)?e[s(1513)](f,16384)?e[s(1731)](f,128)?1:2:e.bPbPD(f,2097152)?3:4:e[s(1513)](g,16384)?e[s(1298)](g,128)?5:6:g<2097152?7:8:e[s(1130)](m,128)?9:10,p=ee(a,y),k=a.bytes;switch(y){case 10:k[p+9]=e[s(309)](m>>>7,1);case 9:k[e[s(1435)](p,8)]=e[s(1281)](9,y)?e[s(886)](128,m):e.iSuuQ(127,m);case 8:k[e[s(465)](p,7)]=e[s(1122)](8,y)?e[s(1056)](e.uUZTx(g,21),128):e[s(962)](e[s(457)](g,21),127);case 7:k[e[s(1412)](p,6)]=e.QKyci(7,y)?e[s(1007)](g,14)|128:e.uUZTx(g,14)&127;case 6:k[e[s(554)](p,5)]=e[s(1071)](6,y)?e[s(1221)](e[s(407)](g,7),128):e.msBxQ(e[s(1652)](g,7),127);case 5:k[e[s(538)](p,4)]=e[s(875)](5,y)?e.cCUvY(128,g):127&g;case 4:k[e[s(1735)](p,3)]=e.toRcn(4,y)?e[s(424)](f>>>21,128):e[s(1692)](f>>>21,127);case 3:k[e[s(1735)](p,2)]=e[s(972)](3,y)?e[s(781)](f,14)|128:e[s(1141)](e[s(522)](f,14),127);case 2:k[p+1]=e.WueVR(2,y)?e.ZNQtd(f,7)|128:e[s(981)](f>>>7,127);case 1:k[p]=e[s(702)](1,y)?e[s(973)](128,f):e[s(404)](127,f)}}}function Xt(a){let n=t;if(e[n(1381)](e.qcmMo,e[n(917)]))return e.UcLqw(v,a);_0x4fe26d[n(481)](_0x22cbf3)}function Ft(a){let n=t;return e[n(535)]("THcDC",e.EDvfq)?function(...s){let d=n;return _0x3f50e9[d(679)](_0x538a96(this),s),_0x582110(_0x1e5889[d(1419)](this))}:I(a)}let Qt=65536,qr=e.THVLi,we=e[t(1297)](Qt,Qt),Te=e.zPDYO(we,we),Vn=e[t(1442)](Te,2),Pe=String[t(1726)+"e"].charCodeAt;class le{constructor(n,s,d){let f=t;this[f(1300)]=!0,this[f(1619)]=e.IMhxl(0,n),this[f(944)]=e[f(860)](0,s),this[f(1496)]=!!d}static[t(1300)](n){return n&&n[t(1300)]===!0}static[t(284)](n,s,d){return new le(n,s,d)}static[t(867)+"s"](n,s,d){let f=t;return d?le["fromByte"+f(1428)](n,s):le[f(867)+f(1201)](n,s)}static[t(867)+"sLE"](n,s){let d=t;return new le(e[d(374)](e[d(1221)](n[0],e[d(1179)](n[1],8))|e[d(869)](n[2],16),e.ZxVKZ(n[3],24)),e[d(1056)](e[d(913)](n[4],e[d(328)](n[5],8))|n[6]<<16,e[d(318)](n[7],24)),s)}static[t(867)+"sBE"](n,s){let d=t;return new le(e.tuFro(e[d(1451)](e[d(549)](e[d(1062)](n[4],24),e[d(1060)](n[5],16)),n[6]<<8),n[7]),e[d(1106)](e[d(913)](e[d(1166)](n[0],24),e[d(1703)](n[1],16))|e[d(1703)](n[2],8),n[3]),s)}static[t(1684)](n){let s=t;return e[s(794)](n,qr)?Bd:new le(e[s(331)](e[s(860)](e[s(346)](Pe[s(501)](n,0)|e[s(1126)](Pe.call(n,1),8),Pe.call(n,2)<<16),e[s(423)](Pe[s(501)](n,3),24)),0),e[s(966)](e.fRzBw(e[s(338)](e[s(1335)](Pe[s(501)](n,4),e[s(1032)](Pe.call(n,5),8)),e[s(938)](Pe[s(501)](n,6),16)),Pe.call(n,7)<<24),0),!0)}[t(1154)](){let n=t;return String[n(1688)+n(989)](e[n(1386)](255,this[n(1619)]),e[n(1692)](e[n(644)](this[n(1619)],8),255),e[n(1066)](e[n(1242)](this[n(1619)],16),255),e[n(395)](this[n(1619)],24),255&this[n(944)],e[n(1522)](this[n(944)],8)&255,e.QReNz(this[n(944)],16)&255,this[n(944)]>>>24)}static[t(394)+"er"](n,s=!0){let d=t;if(e.zCgXa(isNaN,n))return s?Vx:Bd;if(s){if(n>=Te)return Jx}else{if(e[d(1347)](n,-Vn))return Yx;if(e.RVZPY(n,1)>=Vn)return Zx}return le.fromBits(e.BSfoV(e[d(941)](n,we),0),e.VboRL(e[d(603)](n,we),0),s)}toNumber(){let n=t;return this[n(1496)]?e[n(750)]((this[n(944)]>>>0)*we,this[n(1619)]>>>0):e[n(538)](e[n(1434)](this.high,we),this[n(1619)]>>>0)}[t(1429)](){let n=t;return e[n(1002)](0,this[n(944)])&&e.kBGyY(0,this[n(1619)])}[t(903)](n){let s=t;if(e.WueVR(e.YuKim,e[s(325)]))return this[s(1039)]?.[s(1078)](_0x5a092a);{le.isLong(n)||(n=le[s(394)+"er"](n));let d=this[s(944)]>>>16,f=e[s(1344)](65535,this.high),g=e[s(395)](this[s(1619)],16),m=65535&this[s(1619)],y=e[s(781)](n[s(944)],16),p=65535&n[s(944)],k=e[s(1242)](n[s(1619)],16),L=e[s(1510)](65535,n.low),z=0,q=0,K=0,te=0;return te+=e[s(858)](m,L),K+=e[s(921)](te,16),te&=65535,K+=g+k,q+=e[s(395)](K,16),K&=65535,q+=f+p,z+=q>>>16,q&=65535,z+=e[s(525)](d,y),z&=65535,le[s(284)](e.SdSLx(e.wSmGg(K,16),te),e[s(1605)](e.FsJqP(z,16),q),this[s(1496)])}}[t(715)](n){let s=t;return le[s(1300)](n)||(n=le[s(394)+"er"](n)),e[s(1400)](this[s(1496)],n[s(1496)])&&e[s(455)](this[s(944)],31)===1&&e[s(659)](e[s(407)](n[s(944)],31),1)?!1:e[s(413)](this[s(944)],n.high)&&e[s(765)](this.low,n[s(1619)])}[t(829)](){let n=t;if(e[n(1568)](e[n(949)],e[n(949)]))return e[n(1739)](-1,this[n(1619)])&&e.osxRi(-1,this.high)?le[n(284)](0,0,this[n(1496)]):this[n(1619)]===-1?le[n(284)](0,e[n(307)](this.high,1),this.unsigned):le[n(284)](this[n(1619)]+1,this.high,this[n(1496)]);this[n(420)+"er"]&&_0x5b1af6["removeEv"+n(447)+"ner"](e.sMfEU,this._handlePageHide),this._isBrowser&&_0xead444[n(876)+n(447)+"ner"](e[n(1161)],this[n(1464)+n(471)]),this.close()}[t(460)](n){let s=t;if(e[s(875)](s(1391),s(1391)))this[s(1309)+"rs"]={};else return n?this.toBytesLE():this.toBytesBE()}[t(1544)+"E"](){let n=t,s=this[n(944)],d=this.low;return[e.CotEB(255,d),e[n(617)](d,8)&255,e[n(1692)](d>>>16,255),e[n(1589)](d,24),255&s,s>>>8&255,s>>>16&255,e.LGAle(s,24)]}[t(1059)+"E"](){let n=t;if(e[n(729)](e[n(982)],e[n(982)])){let s=this[n(944)],d=this[n(1619)];return[e[n(1029)](s,24),e.uUZTx(s,16)&255,e[n(1066)](e[n(407)](s,8),255),255&s,e[n(1522)](d,24),e.nDWqK(e[n(407)](d,16),255),e[n(404)](e[n(1624)](d,8),255),255&d]}else return n(1421)+"_"+this[n(296)]}}let Bd=new le(0,0,!1),Vx=new le(0,0,!0),Zx=le[t(284)](-1,2147483647,!1),Jx=le.fromBits(-1,-1,!0),Yx=le.fromBits(0,-2147483648,!1);var en=(function(a){let n=t,s=(n(1648)+n(1694))[n(466)]("|"),d=0;for(;;){switch(s[d++]){case"0":a[a[e[n(533)]]=5001]=n(859)+n(753);continue;case"1":a[a[e[n(950)]]=5004]=e.vFZee;continue;case"2":a[a[n(1597)+n(1189)+"R"]=5003]=e[n(383)];continue;case"3":a[a[e.udBct]=5002]=e[n(872)];continue;case"4":return a;case"5":a[a[e.cYWeh]=5005]=e.cYWeh;continue}break}})({});class Zn{constructor(n){this.type=n,this.target=null}}class zd extends Zn{constructor(n,s){let d=t;super(n),this.message=s&&s[d(1088)]||null}}class Fd extends Zn{constructor(n,s){let d=t,f=e[d(439)][d(466)]("|"),g=0;for(;;){switch(f[g++]){case"0":this[d(1088)]=s&&s[d(1088)]||"";continue;case"1":this.filename=s&&s[d(1153)]||"";continue;case"2":this[d(834)]=s&&s[d(834)]||0;continue;case"3":this[d(1128)]=s&&s[d(1128)]||0;continue;case"4":this[d(1751)]=s&&s[d(1751)]||5001;continue;case"5":super(n);continue;case"6":this[d(1558)]=s&&s[d(1558)]||null;continue}break}}}class Ud extends Zn{constructor(n,s){let d=t,f=(d(1180)+"4").split("|"),g=0;for(;;){switch(f[g++]){case"0":this[d(1484)]=s&&s.reason||"";continue;case"1":this[d(1751)]=s&&s[d(1751)]||0;continue;case"2":super(n);continue;case"3":this[d(1520)]=s&&s.wasClean||!1;continue;case"4":this[d(1202)+"nnect"]=s&&s[d(1202)+"nnect"]||!1;continue}break}}}class Gd extends Zn{constructor(n,s){let d=t;super(n),this[d(1625)]=s&&s[d(1625)]||null}}class qd extends Gd{constructor(n,s){let d=t;super(n),this[d(1625)]=s&&s.data||null,this[d(1088)]=s&&s[d(1088)]||null}}class Hd extends Zn{constructor(n,s){let d=t;if(e.rEPyI(e[d(1447)],e[d(1447)]))super(n),this[d(1625)]=s&&s[d(1625)]||null;else return _0x32cffc[d(481)](e[d(1357)],_0x57c482,_0x3368d8,_0x1e43a6),this[d(1039)].set({cursor_name:_0x251d3a,cursor:_0x36f781,service:_0x523879})}}function dt(a,{message:n,code:s,error:d}){return new Fd(a,{message:n,code:s,error:d})}function pt(a,{code:n,reason:s,wasClean:d,willReconnect:f}){return new Ud(a,{code:n,reason:s,wasClean:d,willReconnect:f})}function jd(a,{data:n,message:s}){return new qd(a,{data:n,message:s})}function Wd(a,{data:n}){return new Hd(a,{data:n})}function ia(a,{message:n}){return new zd(a,{message:n})}class Kd{constructor(n,s){let d=t;e[d(1745)](e.PUpVR,d(1593))?(e[d(874)](_0x197660,_0x3e4c29,8),e[d(947)](_0xbdf0c7,_0x287dfc,_0x2684c9)):(this[d(1669)+"s"]=n,this.maxRetries=s,this[d(568)+d(760)]=0,this["currentEndpointT"+d(752)+"t"]=0)}[t(1148)+t(1025)+t(547)](){let n=t;this[n(568)+n(760)]=0,this[n(1209)+n(1523)+n(752)+"t"]=0}resetTries(){let n=t;this[n(1209)+"ndpointT"+n(752)+"t"]=0}[t(443)+"ntEndpoint"](){let n=t;return this[n(1669)+"s"][this[n(568)+"ndex"]]}[t(443)+t(1259)+t(1723)+t(1468)](){let n=t;return this[n(1209)+n(1523)+n(752)+"t"]}[t(495)+t(1595)+"es"](){let n=t;return!!(e[n(793)](this[n(568)+n(760)],this[n(1669)+"s"][n(1762)])||this["currentI"+n(760)]===this[n(1669)+"s"][n(1762)]-1&&this[n(1209)+n(1523)+n(752)+"t"]===this[n(585)+"es"])}[t(779)+t(758)+t(1362)+t(1195)+t(650)](){let n=t;return e[n(1321)](this[n(568)+n(760)],this.endpoints[n(1762)])?!0:e[n(933)](this[n(1209)+"ndpointT"+n(752)+"t"],this.maxRetries)}[t(1480)+t(360)+t(1420)+t(1094)+t(390)](){let n=t;return this[n(1209)+n(1523)+n(752)+"t"]=1,this[n(568)+n(760)]++,this[n(1669)+"s"][this[n(568)+n(760)]]}[t(443)+t(1259)+"ntAndUpdateCount"](){let n=t;return this[n(1209)+n(1523)+n(752)+"t"]++,this[n(443)+n(1259)+"nt"]()}}let Jn=(e.DYQmX(t(294)+"d",typeof globalThis)&&e[t(934)](e[t(906)],globalThis[t(712)+t(897)][t(853)])||e.knaut(e[t(613)],typeof window)&&e[t(308)](e.FKqCk,window[t(712)+t(897)][t(853)]))&&e[t(1440)](e[t(613)],typeof document),In=e[t(1440)](e[t(613)],typeof globalThis)&&(e[t(968)](e[t(1398)],globalThis[t(712)+t(897)][t(853)])||e[t(1458)]("Dedicate"+t(1299)+t(1338)+"pe",globalThis[t(712)+"tor"][t(853)]))&&e[t(1406)](e[t(613)],typeof tt),Hr=(e[t(1440)](e[t(613)],typeof globalThis)&&e[t(572)](e[t(1398)],globalThis[t(712)+"tor"][t(853)])||e[t(866)](e[t(613)],typeof globalThis)||e[t(613)]!=typeof globalThis&&!!globalThis[t(1067)+t(323)])&&t(294)+"d"!=typeof wx,jr=e[t(1370)](e.nAPtC,typeof globalThis)&&(e.KpGaC(e[t(1010)],globalThis[t(712)+t(897)][t(853)])||e.wIjUr(t(368)+"rkerGlobalScope",globalThis[t(712)+t(897)].name)||e.Cimyo(e[t(1008)],globalThis[t(712)+t(897)][t(853)]))&&e[t(1440)](e[t(613)],typeof self),Xx=e[t(559)](e[t(613)],typeof globalThis)&&e.MzXKc(t(984),globalThis[t(712)+t(897)][t(853)])&&e[t(1708)]("undefined",typeof global)&&e.eXScs(e[t(1398)],global[t(712)+t(897)][t(853)])&&e[t(559)](e[t(613)],typeof process)&&!!process[t(1711)];class sa{constructor(){let n=t;this[n(1309)+"rs"]={}}[t(813)](n,...s){let d=t,f={olpSv:function(g){return g()}};if(d(414)===e[d(1266)]){let g=this[d(1309)+"rs"][n];if(g)g[d(724)]()[d(833)](m=>m.fn[d(679)](m[d(689)],s));else if(e.khriY(e[d(512)],n)&&!this[d(1563)]){if(e[d(1743)](e[d(718)],d(1712)))return _0xafeab3[d(731)]||_0x11d66a[d(1596)]?(d(1118)+" "+(_0x5ac717[d(731)]||"")+d(1251)+(_0x4f44f9[d(1596)]||"")).trim():_0x1b548c[d(1125)+"y"](_0x1b6088);{let m=s.length&&s[0];if(m instanceof Error)throw m;let y=new Error(e[d(293)]("Unhandle"+d(1600),m?e[d(1543)](" (",m[d(1088)])+")":""));throw y[d(1508)]=m,m}}return this}else VwTHcB.olpSv(_0x4e1c55),_0x2b14c8()}[t(596)](n,s){let d=t;if(e[d(659)](void 0,n))this[d(1309)+"rs"]={};else if(e[d(370)](void 0,s))this._listeners[n]=null;else{let f=this[d(1309)+"rs"][n];if(f)for(let g=0;e[d(1235)](g,f[d(1762)]);)f[g].fn===s?f.splice(g,1):++g}return this}on(n,s,d){let f=t;return(this[f(1309)+"rs"][n]||(this[f(1309)+"rs"][n]=[])).push({fn:s,ctx:d||this}),this}}class Qx extends sa{[t(655)+t(726)+t(589)](n){let s=t;return n[s(731)]||n[s(1596)]?(s(1118)+" "+(n.errMsg||"")+s(1251)+(n[s(1596)]||""))[s(1727)]():JSON[s(1125)+"y"](n)}constructor(n,s,d){let f=t,g={ioBtY:e[f(1113)]};e[f(663)](e[f(1258)],"zhIHS")?(super(),this._socket=null,Hr&&wx[f(1462)+f(492)]&&(this._socket=wx[f(1462)+"ocket"]({url:n,protocols:s,header:d,fail:this["_createSocketFai"+f(422)][f(626)](this),success:this[f(1415)+f(893)+"cessHand"+f(901)][f(626)](this)})),In&&tt["connectS"+f(492)]&&(this._socket=tt["connectS"+f(492)]({url:n,protocols:s,header:d,fail:this[f(1415)+"ocketFai"+f(422)][f(626)](this),success:this[f(1415)+f(893)+f(1653)+f(901)][f(626)](this)}))):(this.emit(g.ioBtY,_0x4052d0),this[f(1127)]&&this.onopen(_0xb8e757))}[t(1415)+t(893)+t(1653)+t(901)](){let n=t;if(e[n(785)](e[n(737)],"sBLQj"))Promise[n(766)]()[n(1105)](()=>{let s=n;this[s(1500)+s(1663)]()});else return _0x56f060(_0x3f5d54.apply(WldZmd[n(564)](_0x821348,this),_0x4119c6))}[t(1415)+"ocketFai"+t(422)](n){let s=t,d={IdDfZ:function(f,g,m){return e[F(1268)](f,g,m)},yqUwB:s(1558),rEUnm:e.kyBah};Promise[s(766)]()[s(1105)](()=>{let f=s,g=d.IdDfZ(dt,d[f(364)],{message:this["_formatE"+f(726)+f(589)](n)});this[f(813)]("error",g);let m=d[f(900)](pt,d[f(1139)],{reason:this[f(655)+"rrorMess"+f(589)](n)});this.emit(d[f(1139)],m)})}[t(1500)+t(1663)](){let n=t,s={RlMnJ:e[n(687)],RgMEE:function(d,f,g){return e.KSsHx(d,f,g)},BLLAO:function(d,f,g){return d(f,g)},MmFYs:e[n(512)]};this[n(1333)][n(434)](d=>{let f=n;this[f(813)](f(868),e.TAiOl(Wd,e[f(1113)],{...d,data:d[f(731)]||""}))}),this[n(1333)].onClose(d=>{let f=n;this[f(813)](s.RlMnJ,s.RgMEE(pt,s[f(1717)],{...d}))}),this[n(1333)][n(1006)+"e"](d=>{let f=n;this[f(813)](f(1088),e[f(874)](jd,e[f(1092)],{...d}))}),this._socket[n(673)](d=>{let f=n;this[f(813)](f(1558),s.BLLAO(dt,s[f(1087)],{...d,message:d.errMsg||""}))})}[t(839)](n){let s=t,d={SpLVo:e[s(512)],htPbv:function(f,g,m){return e.twIZH(f,g,m)},gbNvt:function(f,g){return e[s(1445)](f,g)}};if(n instanceof Uint8Array)if(e.YdOrk===e[s(1512)]){let f=n[s(432)][s(724)](n[s(611)+"et"],e.EaKRF(n[s(670)+"th"],n[s(611)+"et"]));this[s(1333)]&&this._socket[s(839)]({data:f,fail:g=>{let m=s;this[m(813)](d[m(806)],d[m(1240)](dt,d[m(806)],{message:this["_formatE"+m(726)+m(589)](g)}))}})}else return this[s(1209)+s(1523)+s(752)+"t"]++,this["getCurre"+s(1259)+"nt"]();else this[s(1333)]&&this[s(1333)][s(839)]({data:n,fail:f=>{let g=s;e[g(1102)](g(1030),e.bUcId)?dvHqfg[g(454)](_0x57a0ee,_0x1f44f0)&&_0x31e124[g(1481)](_0x4a7709,_0x374906):this.emit(e[g(512)],e[g(1528)](dt,g(1558),{message:this["_formatE"+g(726)+"age"](f)}))}})}[t(1535)](n,s){let d=t;this[d(1333)]&&this[d(1333)][d(1535)]({code:n,reason:s})}[t(975)+"Listener"](n,s){let d=t;e[d(1568)](e.nyaNr,d(327))?(_0x42d920=e.AoQAd(31,_0x2fa037)<<6|e[d(607)](63,_0x3689e3),e[d(1004)](_0x5434ee,128)?_0x5d363c+=_0x57d25f:(_0xe38cd2+=e.GZzqQ(_0x2b06,_0x146c89),_0x57374++)):this.on(n,s)}[t(876)+t(447)+t(1673)](n,s){this.off(n,s)}get[t(792)+"te"](){let n=t;return this[n(1333)][n(792)+"te"]}get[t(624)+"pe"](){let n=t;return this[n(1333)][n(624)+"pe"]}set[t(624)+"pe"](n){}get url(){let n=t;return e.oAIPh(n(1583),e[n(569)])?_0x4254c4[n(766)]():this[n(1333)][n(387)]}get[t(1511)](){let n=t;return this[n(1333)][n(1511)]}get[t(1096)+"ns"](){let n=t;if(e.sEmgW(n(1586),e[n(1231)])){let s={wRLov:function(y,p,k,L){return e.tXEPk(y,p,k,L)},CxudN:e.QXkQK,jlZkh:e[n(707)],zSxBc:function(y,p,k,L){return e[n(977)](y,p,k,L)},Qzcnr:e.zOvzp,QhWLB:function(y,p,k,L){return y(p,k,L)},VCSJb:e.BdixF,SWhvN:n(853),ckIcV:n(1635)},[d,f]=_0x1ffaf3(_0x195b9b),g=e.IPpyv(_0x101732,d),m=0;return _0x2cd132[n(833)](y=>{let p=n,k=(p(1316)+p(1018)+"9|5|10")[p(466)]("|"),L=0;for(;;){switch(k[L++]){case"0":m=s[p(1494)](_0x660027,0,g,m);continue;case"1":_0x221a19[p(481)](s[p(1380)],m);continue;case"2":_0x17e544[p(481)](s[p(797)],m);continue;case"3":m=s.zSxBc(_0x979be2,f[y[p(1551)+p(544)]],g,m);continue;case"4":_0x623f05.log(s[p(299)],m);continue;case"5":m=s.zSxBc(_0x2fbcd6,_0x5a5c67[p(394)+"er"](y[p(1334)]||_0x2c9b8d),g,m);continue;case"6":m=_0x2c0ad3(y[p(1551)+p(544)],g,m);continue;case"7":m=s[p(996)](_0x2f4ab5,g,m,y[p(1713)]||0);continue;case"8":_0x4b7a65[p(481)](s[p(1733)],y,y[p(1713)]);continue;case"9":_0x48a08e[p(481)](s[p(530)],m);continue;case"10":_0xca165d[p(481)](s[p(620)],m);continue}break}}),{frameType:_0x2db9b7,headers:[{key:e[n(667)],value:_0x57024a}],payload:g}}else return this[n(1333)][n(1096)+"ns"]}get["buffered"+t(635)](){return 0}}function ep(a,n){let s=t;if(n)return new n(a[s(387)],a[s(1511)]);if(e[s(594)](Hr,In))return new Qx(a[s(387)],a[s(1511)],a.headers);if(e[s(594)](Jn,jr)&&e[s(1440)](e[s(613)],typeof WebSocket)&&WebSocket)return new WebSocket(a.url,a.protocols)}function tp(a){let n=t;return!!(a||Hr&&wx[n(1462)+"ocket"]||In&&tt[n(1462)+"ocket"]||e[n(594)](Jn,jr)&&e[n(1440)](e.nAPtC,typeof WebSocket)&&WebSocket)}function $d(a,n,s){let d=-1;async function f(g){let m=F;return e[m(1073)](g,d)?Promise[m(778)](new Error(e[m(1609)])):(d=g,e.rEPyI(g,s[m(1762)])?Promise[m(766)]():s[g][m(626)](a)(n,f[m(626)](null,e[m(1022)](g,1))))}f(0)}function Vd(a){let n=t,s=0,d=0;for(let f=0;f<a[n(1762)];++f)d=a[n(377)+"At"](f),e.yQqVl(d,128)?s+=1:e[n(441)](d,2048)?s+=2:e[n(309)](64512,d)===55296&&e[n(1636)](e[n(1344)](64512,a[n(377)+"At"](e[n(1366)](f,1))),56320)?(++f,s+=4):s+=3;return s}function Zd(a,n,s){let d=t;if(e[d(1027)](s,n)<1)return"";let f="";for(let g=n;e[d(359)](g,s);){let m=a[g++];if(e[d(1073)](m,127))f+=String.fromCharCode(m);else if(m>=192&&e[d(1298)](m,224))f+=String["fromChar"+d(989)](e[d(374)](e[d(288)](31,m)<<6,e[d(1495)](63,a[g++])));else if(e[d(793)](m,224)&&e[d(1422)](m,240))f+=String[d(1688)+d(989)](e[d(1360)](e[d(602)](e[d(1141)](15,m),12),e[d(1126)](e[d(922)](63,a[g++]),6))|e[d(832)](63,a[g++]));else if(e[d(1438)](m,240)){let y=e.UOyZj(e[d(1361)](e.hIBNy(e[d(683)](e[d(452)](7,m),18),e.FYNRC(63&a[g++],12)),e[d(1573)](e[d(832)](63,a[g++]),6))|e.CpLIf(63,a[g++]),65536);f+=String[d(1688)+"Code"](e[d(750)](55296,e[d(1623)](y,10))),f+=String[d(1688)+d(989)](e.cwnNB(56320,e[d(1510)](1023,y)))}}return f}function oa(a,n,s){let d=t,f={FfJJR:function(p,k,L,z){return e.tXEPk(p,k,L,z)}},g=s,m,y;for(let p=0;p<a.length;++p)if(m=a[d(377)+"At"](p),e.RrANU(m,128))n[s++]=m;else if(e[d(541)](m,2048))e[d(335)]===e[d(1134)]?f.FfJJR(_0x5dbef4,this,_0x5abf22,[_0x1b3a1f,_0x5b8bcc,_0x37ef86,_0x595425,_0x54cd9b,_0x245836]):(n[s++]=e[d(1655)](e[d(646)](m,6),192),n[s++]=e[d(965)](63,m)|128);else if(e[d(283)](e[d(1495)](64512,m),55296)&&e[d(785)](64512&(y=a.charCodeAt(e.UwdDl(p,1))),56320)){if(e.OTgqg("PWZqm",e[d(803)]))return _0xc2d158|=0,{low:_0x4a29eb,high:e.SSfhP(_0x58fae2,31),unsigned:_0x5a97d4>=0};{let k=e[d(1448)][d(466)]("|"),L=0;for(;;){switch(k[L++]){case"0":m=e[d(326)](e.OmUqf(65536,e.NtLWN(1023&m,10)),e[d(408)](1023,y));continue;case"1":n[s++]=e[d(636)](e[d(1225)](e.CKutH(m,6),63),128);continue;case"2":++p;continue;case"3":n[s++]=e[d(1634)](e[d(1395)](m,12),63)|128;continue;case"4":n[s++]=e[d(888)](e[d(573)](m,18),240);continue;case"5":n[s++]=e.spSzx(63,m)|128;continue}break}}}else n[s++]=e[d(1360)](e[d(1304)](m,12),224),n[s++]=e.FYXqZ(m>>6,63)|128,n[s++]=e[d(1655)](63&m,128);return e[d(1168)](s,g)}async function Jd(a){let n=t;if(n(1614)!==e[n(1546)]){if(e[n(1695)]==typeof a)if(e.UhmXD(e[n(684)],e[n(684)])){var s=_0x2975d6[_0x1cec8b];if(WldZmd[n(1307)](void 0,s))return s[n(946)];var d=_0x3458ff[_0x12bf25]={exports:{}};return _0x4a09f7[_0x43073f](d,d[n(946)],_0x5f04c),d.exports}else{let f=new Uint8Array(Vd(a));return e[n(371)](oa,a,f,0),f}return e[n(764)](a,ArrayBuffer)?new Uint8Array(a):new Uint8Array(a[n(432)],a[n(611)+"et"],a[n(670)+"th"])}else _0x1cdd42=_0x3439ef(_0x56609d),_0x4cb166=0}function np(a){let n=t,s={BlIFr:e[n(990)],dPVqo:n(859)+n(753),wbUxU:e.udBct,gnniL:e[n(950)],YvLEC:n(1597)+n(1189)+"R"};if(e[n(1613)](e[n(926)],e[n(926)]))try{return e.oIyaV(n(1176),typeof a)&&(a instanceof ArrayBuffer||a.buffer&&e[n(1445)](a[n(432)],ArrayBuffer))||e[n(1695)]!=typeof a?"":(JSON[n(1562)](a),n(1472)+"ion/json")}catch{if(e[n(499)]!==e[n(499)]){let d=("2|3|5|4|"+n(904))[n(466)]("|"),f=0;for(;;){switch(d[f++]){case"0":_0x32831d[_0x54e1bb[oyfsVu[n(1658)]]=5005]=n(1256)+"OR";continue;case"1":return _0x52e50d;case"2":_0x1399f3[_0x159d66["NATIVE_E"+n(753)]=5001]=oyfsVu[n(1367)];continue;case"3":_0x111d28[_0x4643e3[oyfsVu[n(930)]]=5002]=n(734)+n(639);continue;case"4":_0x54ed41[_0x33cde7[n(1401)+n(676)]=5004]=oyfsVu[n(1664)];continue;case"5":_0x5f4e7d[_0x716be4[oyfsVu.YvLEC]=5003]=n(1597)+n(1189)+"R";continue}break}}else return e[n(1236)](n(1176),typeof a)?e[n(879)]:""}else{if(this["_clearPi"+n(1553)](),this[n(1319)+n(777)](),this[n(713)+n(491)+"rs"](),this[n(725)+n(1220)](1e3,_0x1c4c82),this[n(577)+n(686)]=!1,_0x4f518a&&this[n(1228)+n(751)]()&&!this["_readyCl"+n(807)]){if(this[n(516)+n(912)]?.["checkRea"+n(1595)+"es"]()){let f=this[n(516)+n(912)]?.["getCurre"+n(1259)+"nt"]();this[n(1638)+n(721)+n(1559)](e[n(723)](_0x439f58,e.kyBah,{code:1006,reason:n(1243)+f+(n(474)+n(382)+"tries re"+n(320)),wasClean:!0}))}else{let f=this[n(1342)][n(1055)+n(1292)+n(889)](_0x512a83,_0x5c3c92);this[n(1638)+n(721)+"ent"](_0x1245eb(e[n(687)],{code:_0x16b6c4,reason:_0x205431,wasClean:!0,willReconnect:f})),f&&this._connect()}return}this._navigatorOnline()||this[n(884)+n(807)]?this["_dispatc"+n(721)+"ent"](e[n(1024)](_0x553215,e.kyBah,{code:_0x3f0969,reason:n(1603)})):this[n(1638)+n(721)+n(1559)](e[n(776)](_0x2148f5,e[n(687)],{code:1006,reason:e.VYUVu})),this[n(507)]=null,this[n(516)+"tManager"]?.[n(1148)+n(1025)+n(547)](),this._pingLossCounter?.[n(306)+n(1101)]()}}let rp=(a,n)=>{let s=t;if(e[s(1131)](s(1276),e[s(951)]))switch(a){case e[s(1666)]:case e[s(838)]:return{[s(1672)+a]:1,"x-tt-env":n};default:return{}}else _0x37dbc6=e[s(733)](_0x33ce62,_0x31b41d),_0x112da9|=e.dbxzK(e[s(922)](127,_0x3f6b4e),7)};class ip{constructor(n){let s=t;this[s(1257)+s(1468)]=n,this[s(1020)]=0}[t(355)](){let n=t;this[n(1020)]++}["checkRea"+t(645)+"nt"](){let n=t;return e.RiDJa(this[n(1020)],this["maxLossC"+n(1468)])}["resetCou"+t(1101)](n=0){let s=t;this[s(1257)+"ount"]=n,this[s(1020)]=0}}async function sp(a){let n=t,s={qHiGU:e[n(1092)]};return new Promise(d=>{let f=n,g={PLSjr:function(m,y){return m!==y},mdvMw:function(m,y){return e[F(331)](m,y)},nvLsu:function(m,y){return e[F(1104)](m,y)},AgWuS:function(m,y){return m===y},wblin:function(m,y){return e.BsdDP(m,y)},XTcHK:function(m,y){return e[F(825)](m,y)}};if(e[f(1715)](e[f(1749)],e.HkvvO))return _0x5a04e0[f(1300)](_0x1b8096)||(_0x2810f5=_0x377d5d[f(394)+"er"](_0x5e3f03)),iIybNv.PLSjr(this.unsigned,_0x59b446[f(1496)])&&iIybNv[f(932)](this[f(944)],31)===1&&iIybNv[f(1759)](_0x5d2e8f[f(944)],31)===1?!1:iIybNv[f(1157)](this[f(944)],_0x116233[f(944)])&&iIybNv[f(560)](this[f(1619)],_0x23c345[f(1619)]);if(!Jn)return e[f(1326)](d,e[f(458)]);try{if(e[f(1122)](e[f(1608)],e[f(804)])){let m=document[f(1651)+f(1700)](e[f(1021)]);window[f(1421)+f(1748)]=y=>{let p=f;document[p(468)][p(1570)+p(1345)](m),window[p(1421)+p(1748)]=void 0,g[p(1213)](d,y&&y[p(593)]||p(1355)+p(1484))},m.type=e.eDvCR,m[f(548)]=a[f(1100)](/^ws/,e[f(438)])+e[f(1674)];try{document[f(468)][f(305)+f(1345)](m)}catch{document.body[f(1570)+"ild"](m)}}else this[f(813)](s.qHiGU,_0x1a625e),this[f(510)+"e"]&&this[f(510)+"e"](_0x569534)}catch{window[f(1421)+f(1748)]=void 0,e[f(856)](d,e[f(458)])}})}function tn(a,n,s){let d=t;return!!a?.find(f=>f[d(1263)]===n&&f.value===s)}function Yn(a,n){let s=t;return a?.[s(799)](d=>d[s(1263)]===n)?.[s(583)]}let aa=null;async function op(){let a=t;return aa||(aa=Promise[a(766)]()[a(1105)](Mt[a(626)](Mt,e[a(489)]))),aa}class ap extends sa{constructor(n,s){let d=t;super(),this[d(1280)]=n,this._keyPath=s,this[d(1039)]=void 0,this[d(417)+d(1049)]=null}async[t(1036)](){await this[t(1245)]()}async _init(){let n=t,s={vXMXs:function(d){return e[F(732)](d)}};if(!this[n(1039)]){if(this[n(417)+n(1049)])return this[n(417)+n(1049)];try{let d=this[n(1280)],f=this[n(1714)];this[n(417)+n(1049)]=(async()=>{let g=n,{openDB:m}=await s[g(1396)](op);this[g(1039)]=await m(g(1421)+"_"+d,1,{upgrade(y){let p=g;y[p(699)+p(746)+"e"](d,{keyPath:f})}})})(),await this[n(417)+n(1049)]}catch(d){console[n(481)](d)}finally{e[n(768)](n(372),e.pXicR)?this[n(417)+n(1049)]=null:(this.isLong=!0,this.low=0|_0x23d5cd,this[n(944)]=0|_0x186b8e,this[n(1496)]=!!_0x27291c)}}}async[t(1419)](n){let s=t;try{return await this[s(1245)](),this[s(1039)]?.get(this[s(1280)],n)}catch(d){console[s(481)](d)}}async set(n,s){let d=t;return await this[d(1245)](),this[d(1039)]?.put(this[d(1280)],n)}async[t(1078)](n){let s=t;try{return await this._init(),this[s(1039)]?.delete(this[s(1280)],n)}catch(d){console[s(481)](d)}}async[t(1082)](){let n=t;if(e[n(442)](e[n(945)],"KlCQy"))try{return await this[n(1245)](),this._qosDB?.clear(this[n(1280)])}catch(s){console[n(481)](s)}else this._ws&&this[n(507)][n(839)](_0x38661e),this[n(710)+"Queue"][_0xac3bd8]=null}async[t(1186)](){let n=t;return await this[n(1245)](),this[n(1039)]?.[n(1143)+"ys"](this[n(1280)])}async getAll(){let n=t;return await this[n(1245)](),this[n(1039)]?.getAll(this[n(1280)])}async[t(1388)](){let n=t;try{this[n(1039)]?.[n(1535)](),this[n(1039)]=void 0}catch(s){console[n(481)](s)}}get[t(1487)](){let n=t;if(e[n(805)]===e[n(398)])try{this[n(1039)]?.[n(1535)](),this[n(1039)]=void 0}catch(s){_0x2c06e5[n(481)](s)}else try{return!!this[n(1039)]}catch(s){if(e.rEPyI(n(1598),e[n(1044)]))this[n(813)](n(1558),_0x862c6b),this[n(1563)]&&this[n(1563)](_0x109de0);else return console[n(481)](s),!1}}}class cp{constructor(n,s){let d=t;this[d(296)]=n,this[d(1273)]=s,this[d(1039)]=localStorage}async[t(1036)](){}get[t(916)](){return t(1421)+"_"+this._DBName}async[t(1419)](n){let s=t,d=this[s(1039)][s(656)](this[s(916)]);return JSON.parse(e[s(594)](d,"{}"))[n]}async[t(1481)](n,s){let d=t,f=this[d(1039)][d(656)](this[d(916)]),g=JSON[d(1562)](e[d(1246)](f,"{}"));return g[s||n[this._pathKey]]=n,this[d(1039)].setItem(this[d(916)],JSON[d(1125)+"y"](g)),s||n[this._pathKey]}async[t(1078)](n){let s=t,d=this[s(1039)].getItem(this[s(916)]),f=JSON[s(1562)](e[s(594)](d,"{}"));return f[n]=void 0,this._qosDB[s(1255)](this[s(916)],JSON[s(1125)+"y"](f))}async[t(1082)](){let n=t,s={MaVAr:e.OQVzd,LEVbo:e[n(512)]};if(e[n(480)]!==e.NltlH)return this[n(1039)][n(1082)]();_0x565ef8[n(876)+n(447)+n(1673)](LISLzS.MaVAr,_0x409bef),_0x3ce95c[n(876)+n(447)+n(1673)](LISLzS.LEVbo,_0x28d6da),_0x17f5aa[n(876)+n(447)+n(1673)](n(295),_0x33bfeb)}async keys(){let n=t;if(e.eREbK(e[n(993)],e[n(1063)])){let s=this._qosDB[n(656)](this[n(916)]),d=JSON.parse(e.RstCY(s,"{}"));return Object.keys(d)}else{let s=this[n(516)+n(912)]?.getCurrentEndpoint();this[n(1638)+n(721)+"ent"](e.ygxPf(_0x3cfdbb,n(1535),{code:_0x22858e.code,reason:n(1572)+n(1349)+n(1767)+n(1469)+"n, hostn"+n(1005)+s})),this[n(516)+n(912)]?.[n(1148)+n(1025)+"fig"](),this[n(388)+n(1618)]?.[n(306)+n(1101)]();return}}async[t(1738)](){let n=t,s=this[n(1039)][n(656)](this[n(916)]),d=JSON[n(1562)](e[n(1668)](s,"{}"));return Object[n(898)](d)}closeDB(){return Promise[t(766)]()}get[t(1487)](){return!!this[t(1039)]}}class dp{constructor(n,s){this._DBName=n,this._pathKey=s,this._qosDB=In?tt:Hr?wx:null}async openDB(){}get _prefix(){return t(1421)+"_"+this._DBName}async[t(1419)](n){let s=t,d={XcQxq:function(f,g,m){return f(g,m)}};if(e[s(1185)](e.MHNOF,s(717))){let f=this._qosDB.getStorageSync(this[s(916)]);return JSON[s(1562)](f||"{}")[n]}else return _0x221898[s(551)][FdzCRh[s(1641)](_0x476154,_0x3f0643,1)]}async[t(1481)](n,s){let d=t,f=this[d(1039)][d(1210)+d(1574)](this[d(916)]),g=JSON.parse(e[d(1668)](f,"{}"));return g[s||n[this[d(1273)]]]=n,this[d(1039)]["setStora"+d(1574)](this[d(916)],JSON[d(1125)+"y"](g)),s||n[this[d(1273)]]}async[t(1078)](n){let s=t;if(s(300)===s(300)){let d=this[s(1039)][s(1210)+"geSync"](this._prefix),f=JSON[s(1562)](e.vEdvy(d,"{}"));return f[n]=void 0,this[s(1039)]["setStora"+s(1574)](this._prefix,JSON[s(1125)+"y"](f))}else{let d=s(1243)+_0x8921cc+(s(498)+s(1114)+s(902)+"ed");this[s(1638)+s(1627)+s(1559)](e[s(1268)](_0xeed6ad,"error",{message:d,code:_0x2a0a4e[s(1597)+s(1189)+"R"],error:_0x338ea1}));return}}async[t(1082)](){let n=t;return this[n(1039)][n(865)+"rageSync"]()}async keys(){let n=t,s=this[n(1039)][n(1210)+n(1626)+"nc"](this[n(916)]),d=JSON.parse(e.PLhXm(s,"{}"));return Object.keys(d)}async getAll(){let n=t,s=this[n(1039)]["getStora"+n(1626)+"nc"](this[n(916)]),d=JSON[n(1562)](s||"{}");return Object[n(898)](d)}[t(1388)](){return Promise[t(766)]()}get isReady(){let n=t;if(e.ZjucJ(e[n(1475)],e.inwfG))return!!this._qosDB;_0x54efb3.log(_0x2b515f)}}function Yd(a,n){let s=t;if(In||In)return new dp(a,n);if((Jn||jr)&&e.nAPtC!=typeof indexedDB)return new ap(a,n);if((Jn||jr)&&e.oIyaV(e.nAPtC,typeof localStorage))return new cp(a,n);throw new Error(e[s(1035)])}class lp{constructor(){let n=t;this[n(557)+n(643)+"Id"]=null,this[n(557)+"l"]=36e5,this._qosDB=e[n(1720)](Yd,e[n(410)],e[n(361)])}async[t(557)+t(708)](){let n=t,s={PCNeP:function(d,f){return e.QRcLe(d,f)},Urats:function(d,f){return e[F(1104)](d,f)},zUiiD:function(d,f){return d|f},AvGpv:function(d,f){return e.wSmGg(d,f)},OUPbA:function(d,f){return e[F(809)](d,f)},gBUMV:"RsBvn"};clearInterval(this[n(557)+n(643)+"Id"]),this[n(557)+"lTimeoutId"]=e[n(776)](setInterval,()=>{let d=n,f={hSzFV:function(g,m){return s[F(961)](g,m)},IhdlP:function(g,m){return s.Urats(g,m)},BDzqz:function(g,m){return s[F(582)](g,m)},MOhqJ:function(g,m){return s[F(685)](g,m)},pMVcm:function(g,m){return g>>>m},FHMgH:function(g,m){return s.AvGpv(g,m)},zNTlJ:function(g,m){return g<<m}};if(s[d(1525)](d(899),s[d(959)]))this[d(1710)+d(1265)]();else return fbshGy[d(1621)](_0x47ae34,_0x3db95c)?_0x526ac6:new _0x126e3c(fbshGy[d(496)](fbshGy.BDzqz(_0x4d0618[d(501)](_0x301110,0)|fbshGy[d(1183)](_0x45811b.call(_0x2e3eb1,1),8)|_0x478088[d(501)](_0x4bd71e,2)<<16,_0x3b2851[d(501)](_0x55adef,3)<<24),0),fbshGy[d(701)](fbshGy.BDzqz(fbshGy[d(743)](_0x40cef2[d(501)](_0x232145,4)|fbshGy[d(1291)](_0x41f4e7[d(501)](_0x2dcd51,5),8),fbshGy[d(1291)](_0x354e13[d(501)](_0xf6389e,6),16)),fbshGy[d(1277)](_0x462a40.call(_0x40f354,7),24)),0),!0)},this[n(557)+"l"])}async[t(1036)](){let n=t,s={ftAaU:function(d,f,g){return e[F(1058)](d,f,g)},gfLLr:e[n(410)],LadYo:e[n(361)],OGnBs:function(d,f){return e[n(809)](d,f)},aEHnr:e[n(494)]};await this[n(1039)].openDB()[n(1105)](()=>{let d=n;s.OGnBs(s.aEHnr,s[d(703)])?(this[d(557)+d(643)+"Id"]=null,this[d(557)+"l"]=36e5,this[d(1039)]=TqmTBn.ftAaU(_0x2ecadb,TqmTBn[d(334)],TqmTBn[d(528)])):this[d(557)+d(708)]()})}async[t(1710)+t(1265)](){let n=t;(await this._qosDB?.getAll()||[])[n(661)](({timestamp:f})=>f<Date[n(1631)]())[n(833)](f=>{let g=n;this[g(1039)]?.del(f[g(1083)+"id"])})}async[t(1078)](n){let s=t;if(e[s(1374)](e[s(1223)],s(1193)))_0x5d0703(this[s(577)+s(521)+s(503)]),this[s(577)+s(521)+s(503)]=null;else return this[s(1039)]?.del(n)}async[t(1481)](n,s){return this._qosDB?.set({message_id:n,timestamp:s})}async get(n){let s=t;return this[s(1039)]?.[s(1419)](n)}async[t(1388)](){let n=t;e[n(1550)](clearInterval,this[n(557)+"lTimeoutId"]),await this[n(1039)]?.[n(1388)]()}get[t(1487)](){let n=t;return this[n(1039)]?.[n(1487)]}}function ca(a){let n=t,s=!!this._options[n(1285)+"S"];if(!s)return{enabled:s,isQoSMessage:!1,isQoSAck:!1,isAckCleanupMessage:!1,ackMsgIds:[]};let d=tn(a[n(1088)][n(396)],n(985)+"er_qos","2"),f=d&&e.BUjwM(tn,a[n(1088)][n(396)],n(985)+n(1601)+"ck","1"),g=d&&e[n(1084)](tn,a[n(1088)].headers,e[n(1408)],"1"),m=g?Yn(a[n(1088)][n(396)],e.ZZyXC)?.[n(466)](",")[n(661)](Boolean)||[]:[];return{enabled:s,isQoSMessage:d,isQoSAck:f,isAckCleanupMessage:g,ackMsgIds:m}}async function Xd(){let a=t;return this[a(986)+"ger"]||(this[a(986)+a(730)]=new lp),this[a(986)+a(730)][a(1487)]||await this[a(986)+a(730)][a(1036)](),this[a(986)+a(730)]}async function up(a,n){let s=t,d={qQipR:function(f,g){return e[F(1742)](f,g)},AwAVj:function(f,g){return e[F(463)](f,g)},XOGDH:function(f,g){return e[F(463)](f,g)},cSWKy:function(f,g){return e.IMnGi(f,g)},TmVJJ:s(1463),bfkCN:e.lpcAh};if(e[s(535)](s(333),e[s(584)])){let{enableAutoAck:f}=this._options,g=e[s(371)](tn,a.message[s(396)],e[s(915)],"1"),m=e.tXEPk(tn,a[s(1088)].headers,s(344),"1"),y=ca.call(this,a);if(f&&g){let{SeqID:p,LogID:k,service:L,LogIDNew:z,method:q}=a.message;this[s(1461)]({SeqID:p,LogID:k,LogIDNew:z,service:L,method:q,headers:[{key:e[s(401)],value:"1"},{key:e.GuFVg,value:e[s(1402)](z,"")},{key:e[s(1707)],value:"0"}]})}m&&!y[s(1465)]&&this["_dispatchAckMess"+s(697)](a),e[s(732)](n)}else return d[s(1376)](_0x4b424f,d[s(391)](d.AwAVj(d[s(290)](d[s(681)](d[s(681)](s(924)+s(956)+s(695),_0x2fe389),d[s(1578)]),_0x4b097c||1),d[s(843)]),_0x244e38))}async function fp(a,n){let s=t;this[s(376)](s(927),a[s(1088)]),e.TWFkd(n)}async function hp(a,n){let s=t,d=e[s(1119)](Xt,await e[s(1611)](Jd,a.data));try{if(e.LWzxA(d[s(597)],Uint8Array)){let f=e[s(1320)](this[s(1342)]["payloadE"+s(511)],Object)?{force:!!this[s(1342)][s(542)+s(511)].force,encoding:this._options[s(542)+s(511)][s(349)]?this[s(1342)][s(542)+"ncoding"][s(349)][s(1100)](/\s/g,"")[s(769)+s(1269)]():""}:{force:!1,encoding:this._options[s(542)+s(511)]?this[s(1342)][s(542)+s(511)][s(1100)](/\s/g,"")[s(769)+s(1269)]():""},g=d.payloadEncoding?d[s(542)+"ncoding"][s(1100)](/\s/g,"")[s(769)+s(1269)]():"",m=e.LWzxA(this._options["payloadT"+s(1491)],Object)?{force:!!this[s(1342)]["payloadT"+s(1491)][s(313)],type:this._options["payloadT"+s(1491)].type?this[s(1342)][s(418)+s(1491)].type.replace(/\s/g,"")["toLowerC"+s(1269)]():""}:{force:!1,type:this[s(1342)][s(418)+s(1491)]?this[s(1342)][s(418)+s(1491)][s(1100)](/\s/g,"")[s(769)+s(1269)]():""},y=d[s(418)+s(1491)]?d[s(418)+s(1491)][s(1100)](/\s/g,"")[s(769)+s(1269)]():"",p=m.force?m.type:y||m.type,k=f.force?f[s(349)]:g||f.encoding,L=[e[s(879)],e[s(312)],e.sjrxB,e[s(1695)]],z=[e[s(969)],e.AruCE];this[s(1342)][s(1519)+"ansformT"+s(389)+"ad"]&&L.includes(p)&&(!k||z[s(1057)](k))?d[s(595)+s(1424)]=e[s(371)](Zd,d[s(597)],0,d.payload.byteLength):d["textPayl"+s(1424)]=""}else d.textPayload=""}catch(f){d[s(595)+s(1424)]="",console[s(481)](f)}a[s(1088)]=d,e[s(732)](n)}function xp(a,n,s){let d=t,f=e[d(651)](s,8192),g=e[d(455)](f,1),m=null,y=f;return function(p){let k=d;if(e[k(1133)](e[k(1174)],e[k(1174)]))this[k(813)](k(578),_0x423fb1),this[k(1536)+k(728)]&&this[k(1536)+k(728)](_0x27c53a);else{if(e[k(1689)](p,1)||e[k(545)](p,g))return e[k(991)](a,p);e.UTmzZ(e[k(1622)](y,p),f)&&(m=e[k(995)](a,f),y=0);let L=n.call(m,y,y+=p);return e[k(1135)](7,y)&&(y=e[k(525)](e.XoERq(7,y),1)),L}}}let pp=4294967295;function gp(a,n,s){let d=t;return d(1358)===e[d(881)]?_0x11f93d?_0x46a400[d(867)+d(1428)](_0x228e33,_0x3e7e7a):_0x55b198[d(867)+d(1201)](_0x4edb77,_0x590b73):e[d(1041)](RangeError,e[d(330)](e[d(1639)](e[d(293)](e[d(538)]("index ou"+d(956)+d(695)+a,e.KOHGV),e[d(1397)](n,1)),e[d(1687)]),s))}function mp(a,n,s){let d=t;if(s>pp)throw new Error(e[d(1705)]);let f=3;for(;e[d(793)](f,0);){let g=e[d(1483)](255,s);e[d(371)](la,g,a,e[d(576)](n,f)),s>>>=8,f--}return e.OmUqf(n,4)}function wp(a,n){let s=t,d=0,f=n,g=n+4;for(;e[s(1384)](f,g);){if(e.KcgsC(e.IQdcw,e[s(1275)]))return this._isMiniTT||this._isMiniWX?this[s(406)+s(1330)+s(850)]:(this._isBrowser||this[s(605)+"r"])&&this[s(1342)][s(405)+"tworkCha"+s(1011)]?_0x1fb54b[s(1610)]:!0;{let{value:m,offset:y}=e.fFDgI(da,a,f);f=y,d=e.uViMc(e[s(1293)](d,8),0),d+=m}}return{value:d,offset:g}}function _p(a,n,s){let d=t;if(e[d(845)](d(1216),e.JLoEO))this[d(400)+d(1553)](),this[d(813)]("ping_onc"+d(1218)+"s",d(844)),this[d(1497)+d(885)+"Id"]=_0xb21e01(this[d(1261)][d(626)](this),_0x1f5361);else{let f=(d(1724)+"0")[d(466)]("|"),g=0;for(;;){switch(f[g++]){case"0":return e[d(1016)](oa(a,n,s),s);case"1":if(n[d(1034)])return e[d(905)](n[d(1034)](a,s),s);continue;case"2":if(!a)return s;continue;case"3":if(n[d(291)+"e"])return e[d(942)](n[d(291)+"e"](a,s),s);continue;case"4":if(a[d(1762)]<40)return e.kivIm(e[d(1084)](oa,a,n,s),s);continue}break}}}function yp(a,n){let s=t,d=new le(e.EfjOR(e.LMVGY(e[s(316)](a[e[s(1628)](n,4)]<<24,e[s(1630)](a[e.rZkFb(n,5)],16)),e[s(869)](a[e[s(1490)](n,6)],8)),a[e.jqtXi(n,7)]),e.KQsDR(a[e.dgKPu(n,0)]<<24|a[n+1]<<16,e[s(1718)](a[e[s(942)](n,2)],8))|a[e[s(1531)](n,3)],!0);return n+=8,{value:d,offset:e.HqMLa(n,8)}}function bp(a,n,s){let d=t,f=a[d(1619)],g=a[d(944)];return n[s]=g>>>24,n[e[d(974)](s,1)]=e[d(1104)](g,16)&255,n[e[d(823)](s,2)]=e[d(348)](g,8)&255,n[s+3]=e[d(375)](255,g),n[e[d(608)](s,4)]=f>>>24,n[e[d(1746)](s,5)]=e[d(1066)](e[d(455)](f,16),255),n[s+6]=e[d(1141)](e.jFsqQ(f,8),255),n[e[d(854)](s,7)]=e[d(536)](255,f),s+=8,s}function da(a,n){let s=t;return a.readUInt8?{value:a.readUInt8(n),offset:n+1}:{value:e.ebKdx(255,a[n]),offset:e[s(1543)](n,1)}}function la(a,n,s){let d=t;return n[d(1560)+"t8"]?n[d(1560)+"t8"](a,s):n[s]=e.hmhHW(255,a),e.tiyaS(s,1)}let Ep=function(a){return new Uint8Array(a)},vp=e[t(613)]!=typeof Buffer?Buffer[t(416)+"afe"]:e[t(381)](xp,Ep,Uint8Array[t(1726)+"e"][t(1271)]);(()=>{let a=t,n={pmhjf:e[a(1701)],VWgnp:function(d,f){return e[a(617)](d,f)},UwUMl:function(d,f){return e[a(1441)](d,f)},BBcKe:function(d,f){return e.dDaSY(d,f)},jfnzU:function(d,f){return d<f},YiKCr:function(d,f){return e[a(1194)](d,f)},aVglv:function(d,f){return e[a(1136)](d,f)},iucqk:function(d,f){return e[a(359)](d,f)},ZpQaa:function(d,f){return e.LGAle(d,f)},VOAEY:function(d,f){return e[a(1344)](d,f)},wbsTN:function(d,f){return d&f},JpIJu:function(d,f){return e[a(1375)](d,f)},jhSzh:function(d,f){return e[a(1129)](d,f)}},s=4294967295;return function(d,f,g=!0){let m=a,y=n.pmhjf[m(466)]("|"),p=0;for(;;){switch(y[p++]){case"0":s=n[m(1533)](n[m(1683)](s,n[m(1353)](15&d[f],28)),0);continue;case"1":if((f+=5)>d[m(1762)])throw f=d[m(1762)],gp(f,10,d[m(1762)]);continue;case"2":if(n[m(562)](d[f++],128))return{value:g?s:n[m(1683)](0,s),offset:f};continue;case"3":return{value:g?s:n.UwUMl(0,s),offset:f};case"4":if(n[m(562)](d[f++],128))return{value:g?s:n[m(637)](0,s),offset:f};continue;case"5":s=n.aVglv(n[m(1683)](s,(127&d[f])<<14),0);continue;case"6":if(d[f++]<128)return{value:g?s:n[m(1683)](0,s),offset:f};continue;case"7":if(n[m(1576)](d[f++],128))return{value:g?s:n[m(1683)](0,s),offset:f};continue;case"8":s=n[m(1439)](n[m(822)](127,d[f]),0);continue;case"9":s=n[m(987)](n[m(1683)](s,n.wbsTN(127,d[f])<<21),0);continue;case"10":s=n[m(1533)](n[m(1038)](s,n[m(682)](127&d[f],7)),0);continue;case"11":if(d[f++]<128)return{value:g?s:n[m(1038)](0,s),offset:f};continue}break}}})();let Sp=16,ua=32;function Ip(a){let n=t,s=0,d={};for(let f=0;e.EHUEK(f,a[n(1762)]);f++)d[a[f][n(1551)+n(544)]]=Vd(a[f][n(1551)+n(544)]),s+=e[n(854)](14,d[a[f][n(1551)+n(544)]]);return[s,d]}function Qd(a,n,s){let d=t,f={xMEKf:d(321)+d(1317)+d(671),YORKl:function(k,L,z,q){return k(L,z,q)},HTJgu:d(1053),FhPbf:e[d(342)],JGhzg:e[d(1443)],wnfxM:function(k,L,z,q){return e[d(1757)](k,L,z,q)},WvyOX:e[d(1515)]},[g,m]=e[d(770)](Ip,a),y=e[d(995)](vp,g),p=0;return a[d(833)](k=>{let L=d,z=f[L(482)][L(466)]("|"),q=0;for(;;){switch(z[q++]){case"0":p=bp(le[L(394)+"er"](k[L(1334)]||n),y,p);continue;case"1":p=f[L(289)](_p,k[L(1551)+L(544)],y,p);continue;case"2":console[L(481)](f[L(1111)],p);continue;case"3":console[L(481)](f[L(857)],p);continue;case"4":p=la(0,y,p);continue;case"5":console[L(481)](f[L(1267)],p);continue;case"6":console[L(481)]("cursor.service",k,k.service);continue;case"7":console.log(L(1081)+L(853),p);continue;case"8":p=f[L(745)](mp,y,p,k[L(1713)]||0);continue;case"9":p=f.YORKl(la,m[k[L(1551)+L(544)]],y,p);continue;case"10":console.log(f[L(763)],p);continue}break}}),{frameType:ua,headers:[{key:e[d(667)],value:s}],payload:y}}function Ap(a){let n=t,s=0,d=[];for(;s<a[n(670)+"th"];){let{offset:f}=e[n(1268)](da,a,s);s=f;let g={cursor_name:"",cursor:0,service:0},{value:m,offset:y}=e.QHmDL(wp,a,s);g[n(1713)]=m,s=y;let{value:p,offset:k}=e.tcDfj(da,a,s);s=k,g[n(1551)+n(544)]=e[n(977)](Zd,a,s,e.BpuVN(s,p)),s+=p;let{value:L,offset:z}=e[n(1541)](yp,a,s);g[n(1334)]=L.toNumber(),s=z,d[n(1529)](g)}return d}function Tp(){return{frameType:ua,headers:[{key:e[t(667)],value:e.cZskx}],payload:void 0}}class Rp{constructor(n,s,d){let f=t,g={DJEsk:function(m,y){return e[F(770)](m,y)},JzIlJ:function(m,y,p){return e[F(1217)](m,y,p)}};if(e[f(1526)](e[f(1288)],f(1681)))this[f(943)+f(1237)]=n,this._cursorFileName=s,this._messageStrategy=d,this[f(1039)]=e[f(1541)](Yd,this[f(943)+f(1237)],f(1551)+f(544));else return(TcbTPh[f(658)](_0x43f477,8)[f(490)]("0")+TcbTPh[f(1033)](_0x489aaf,_0x563c42,10).toString(2))[f(724)](-8)}async[t(1036)](){let n=t;await this[n(1039)][n(1036)]()}async[t(1482)+"rs"](){let n=t;if(!this[n(1039)].isReady)return;let s=this["_message"+n(1159)],d=await this._qosDB.getAll();switch(console.log(e[n(862)],d),s){case e[n(678)]:return d&&d[n(1762)]?e[n(1757)](Qd,d,0,this[n(820)+n(1356)]):void 0;case e.uQSfh:return;case e[n(1284)]:return d&&d[n(1762)]?e[n(371)](Qd,d,0,this[n(820)+n(1356)]):Tp()}}async set(n,s,d){return console[t(481)](e.oViCp,n,s,d),this._qosDB.set({cursor_name:n,cursor:s,service:d})}async setCursors(n){let s=t,d=Ap(n);for(let f of d)console[s(481)](e.rcYJK,d),await this[s(1039)][s(1481)](f)}async[t(1419)](n){let s=t;return(await this[s(1039)][s(1419)](n))?.[s(1334)]}async[t(1388)](){let n=t;await this[n(1039)][n(1388)]()}["updateCu"+t(302)+t(1348)](n){let s=t;e[s(1122)](e[s(1182)],e.EEEgt)?(_0x4bf4fb=_0x1e510e[s(709)](_0x2f4904),_0x5ca130=_0x1402ac[s(709)](_0x102329[_0x25fe21])):this[s(820)+s(1356)]=n}get[t(1487)](){let n=t;return this._qosDB[n(1487)]}}let Cp="__x_msg_"+t(1455);async function el(a){let n=t,s={twmmp:function(y,p){return y+p},VsxAe:function(y,p){return e[F(1434)](y,p)},HwyWM:function(y,p){return e[F(457)](y,p)},utdTV:function(y,p){return e.OpqEP(y,p)}};if(!this[n(1342)][n(1285)+"S"])return null;let{aID:d,fpID:f,messageStrategy:g}=this[n(1342)],m=e[n(437)](a,Cp);try{if(this[n(1677)+n(937)])if(e[n(1158)](e[n(1394)],e[n(1394)]))a&&this[n(1677)+n(937)]["updateCu"+n(302)+n(1348)](a);else return this.unsigned?tAnndd[n(343)](tAnndd[n(1192)](tAnndd[n(484)](this.high,0),_0x266ba8),tAnndd[n(484)](this[n(1619)],0)):tAnndd[n(343)](tAnndd[n(1417)](this[n(944)],_0x358c10),tAnndd.HwyWM(this[n(1619)],0));else this[n(1677)+n(937)]=new Rp(f+"_"+d+"_"+m,m,g);return this[n(1677)+n(937)][n(1487)]||await this[n(1677)+n(937)][n(1036)](),this[n(1677)+n(937)]}catch{return null}}async function Dp(a,n){let s=t,d=e[s(1757)](tn,a[s(1088)][s(396)],e[s(1305)],"-1"),f=e[s(371)](tn,a[s(1088)].headers,s(344),"1"),g=Yn(a.message.headers,"x_fronti"+s(1207)),m=e[s(470)](Number,e[s(1069)](Yn,a[s(1088)].headers,e.lqgfq))||0,y=ca[s(501)](this,a),p=e[s(1084)](tn,a[s(1088)].headers,s(1736)+"s","2"),k=Yn(a[s(1088)][s(396)],e.OEANE),L=e[s(337)](Number,e.dmqLW(Yn,a[s(1088)][s(396)],s(1730)+s(1686)+"ue"));if(y[s(1465)])return e[s(529)](n);let z=y[s(1031)+"sage"]?await Xd.call(this):null;if(e.XkdII(a[s(1088)][s(1713)],0)&&f&&!d||e[s(1047)](a[s(1088)][s(1713)],0)){if(g&&y["isQoSMes"+s(555)]&&z){if(e.KcgsC(e[s(477)],e.nQUWX))return!!!await z[s(1419)](g)&&(this[s(1638)+s(1744)+"Event"](a),await z[s(1481)](g,e.buWXq(Date[s(1631)](),m))),e.wxDyG(n);_0x32fdaf[s(595)+s(1424)]="",_0x2493dc.log(_0x55fe83)}if(p){let q=await el[s(501)](this);if(!q)return this[s(1638)+s(1744)+s(1756)](a),e.wxDyG(n);let K=await q[s(1419)](k)??-1;if(e[s(1014)](K,L))this["_dispatchMessage"+s(1756)](a),q[s(1481)](k,L,a[s(1088)].service);else throw new Error(s(1584)+" message cursor "+L+(s(1489)+s(1314)+s(563)+"r ")+K);return e[s(1752)](n)}return this[s(1638)+"hMessage"+s(1756)](a),e[s(925)](n)}}async function kp(a,n){let s=t;if(e.VZkeZ!==s(1165))return!!this._qosDB;{let d=ca[s(501)](this,a);if(!d[s(1031)+s(555)])return e[s(795)](n);let f=await Xd.call(this);if(d[s(1188)+s(317)+s(589)]&&d[s(967)+"s"][s(1762)])for(let g of d[s(967)+"s"])await f[s(1078)](g);e[s(625)](n)}}async function Pp(a,n){let s=t,d=a.message[s(1123)+"e"]===Sp,f=e.khriY(a[s(1088)][s(1123)+"e"],ua);if(e.JWlPH(!d,!f))return e[s(1516)](n);let g=Yn(a[s(1088)][s(396)],e.YqAtR);if(!g)return e[s(393)](n);let m=await el[s(501)](this,g);if(!m)return e[s(292)](n);if(d){let y=await m[s(1482)+"rs"](),p={frameType:y?.[s(1123)+"e"],SeqID:le[s(394)+"er"](this[s(1080)]++),LogID:le[s(394)+"er"](this[s(1342)][s(500)+s(1200)]()),service:9e3,method:5,headers:y?.[s(396)],payload:y?.[s(597)]},k=I(p);this[s(507)]&&this[s(507)].readyState&&this[s(507)].send(k)}if(f){let y=a.message[s(597)];y&&m[s(1219)+"rs"](y)}}let Lp=async function(a,n){let s=t;this[s(1043)]=!1,clearTimeout(this[s(577)+s(521)+s(503)]),n()},Op=async function(a,n){let s=t;if(!this[s(507)]||e[s(1368)](this[s(507)][s(792)+"te"],this.OPEN))return e[s(621)](n);let{pingInterval:d}=this._options;this[s(516)+s(912)]?.["resetEnd"+s(1025)+s(547)]();for(let g=0;e[s(1418)](g,this[s(710)+"Queue"][s(1762)]);g++){let m=this[s(710)+s(411)][g];if(e[s(659)](this[s(507)][s(792)+"te"],this[s(847)])&&e[s(339)](null,m))e[s(1160)](e[s(1303)],e[s(812)])?(this[s(1257)+s(1468)]=_0x2aa648,this[s(1020)]=0):(this._ws&&this[s(507)][s(839)](m),this[s(710)+s(411)][g]=null);else break}this["_message"+s(411)]=this[s(710)+"Queue"][s(661)](g=>!!g),this[s(1497)+s(885)+"Id"]=e[s(380)](setTimeout,()=>this._ping(),d),this[s(1638)+s(1476)+"nt"](a),this[s(420)+"er"]&&this[s(507)]&&(this._ws[s(624)+"pe"]=this[s(1365)+s(1491)]);let f=this[s(516)+"tManager"]?.[s(443)+s(1259)+"nt"]();this[s(376)](s(1414)+f+s(767)),n()},Np=async function(a,n){let s=t,d=this[s(516)+s(912)]?.[s(443)+s(1259)+"nt"]();this[s(376)](s(1414)+d),e[s(954)](n)};class Mp extends sa{constructor(n){let s=t,d={BIlHT:function(y,p,k){return e[F(1747)](y,p,k)},SuKSA:e[s(512)],UvguV:function(y,p){return y===p},huWHg:function(y,p,k){return e[s(604)](y,p,k)}};super(),this[s(406)+"igatorOn"+s(850)]=!0,this._isBrowser=Jn,this[s(1477)]=Xx,this._isMiniTT=In,this[s(402)+"X"]=Hr,this[s(605)+"r"]=jr,this[s(710)+s(411)]=[],this[s(516)+s(912)]=null,this[s(884)+"osed"]=!1,this._binaryType=s(1234)+s(497),this[s(577)+"Lock"]=!1,this[s(577)+s(521)+s(503)]=null,this[s(440)+s(1761)+s(1205)]=null,this[s(1497)+s(885)+"Id"]=null,this[s(1080)]=0,this[s(1043)]=!1,this[s(647)]="",this[s(986)+"ger"]=null,this["_cursorM"+s(937)]=null,this[s(388)+s(1618)]=null,this[s(1e3)+"ls"]=e.uoexz,this[s(704)]=3,this[s(734)+"NG"]=0,this[s(847)]=1,this[s(815)]=2,this._onOpen=y=>{let p=s,k={hQUww:function(L,z){return e[F(1661)](L,z)}};try{$d(this,y,[Lp,Op,Np])}catch(L){if(e[p(1079)](e[p(1163)],e.xVHrD))return _0x5ca72e[p(679)](KneTuj[p(1042)](_0x8e0b1,this),_0x294f77),_0x542807(_0x27e6e5[p(1419)](this));{let z=e[p(433)](dt,e[p(512)],{message:L[p(1088)],code:en[p(1256)+"OR"],error:L});this[p(1638)+p(1627)+p(1559)](z)}}},this[s(660)+"ge"]=async y=>{let p=s,{pingInterval:k,pingFrequency:L}=this[p(1342)];if((e.mpdhV("hi",y.data)&&e[p(370)](e.ZfAKW,L)||e[p(1199)](p(1538),L))&&(this[p(400)+p(1553)](),this[p(813)](e[p(674)],e[p(634)]),this[p(1497)+p(885)+"Id"]=setTimeout(this[p(1261)][p(626)](this),k)),!e[p(572)]("hi",y[p(1625)]))try{e[p(762)]($d,this,y,[hp,up,kp,Pp,Dp,fp])}catch(z){let q=e[p(1015)](dt,e[p(512)],{message:z.message,code:en[p(1401)+p(676)],error:z});this[p(1638)+p(1627)+p(1559)](q)}},this[s(672)]=y=>{let p=s,k=this[p(516)+p(912)]?.["checkRea"+p(1595)+"es"](),L=this["_endpoin"+p(912)]?.[p(443)+"ntEndpoint"]();if(k&&!y[p(1088)]){let z=p(1243)+L+(" fail, m"+p(1114)+"es reached");this[p(1638)+p(1627)+"ent"](d.BIlHT(dt,d[p(340)],{message:z,code:en[p(1597)+p(1189)+"R"],error:y}));return}this._ws&&d[p(1537)](this[p(507)][p(792)+"te"],this[p(847)])&&this[p(1341)+p(403)](),this[p(1638)+p(1627)+p(1559)](d[p(1580)](dt,d[p(340)],{message:y[p(1088)],code:en[p(859)+p(753)],error:y}))},this[s(285)]=async y=>{let p=s,k={XehTu:function(z,q){return e[F(1454)](z,q)}};this["_clearTi"+p(777)](),this[p(400)+p(1553)](),this[p(713)+"sListeners"](),this[p(507)]=null,this["_connect"+p(686)]=!1;let L=this[p(516)+p(912)]?.[p(495)+p(1595)+"es"]();if(!L&&this[p(1228)+"orOnline"]()&&!this[p(884)+"osed"]){let z=this["_endpoin"+p(912)]?.["getCurre"+p(1259)+"nt"](),q=this[p(1342)][p(1055)+"tInterce"+p(889)](y[p(1751)],y[p(1484)]);this[p(1638)+"hCloseEv"+p(1559)](e[p(796)](pt,p(1535),{code:1006,reason:y[p(1484)]||"connecti"+p(1349)+p(1767)+p(1469)+p(873)+p(1005)+z,willReconnect:q})),q&&this[p(577)]();return}if(e[p(464)](1e3,y.code)&&this[p(884)+p(807)]){this[p(1638)+"hCloseEv"+p(1559)](pt(e.kyBah,{code:1e3,reason:"bye"})),this[p(516)+p(912)]?.[p(1148)+"pointCon"+p(547)](),this[p(388)+p(1618)]?.["resetCou"+p(1101)]();return}if(e[p(875)](1e3,y.code)&&L){let z=this[p(516)+p(912)]?.[p(443)+"ntEndpoint"](),q=y[p(1484)];q||(q=await e[p(1208)](sp,this[p(647)])),q=p(1572)+p(1349)+p(1407)+q+", hostname: "+z+(p(382)+p(1354)+"ached"),this[p(1638)+p(721)+p(1559)](pt(p(1535),{code:y[p(1751)],reason:q}));let K=p(1243)+z+(p(498)+"ax retri"+p(902)+"ed");this[p(1638)+p(1627)+p(1559)](e[p(1644)](dt,e[p(512)],{message:K,code:en["MAX_RETR"+p(1189)+"R"]})),this[p(516)+p(912)]?.[p(1148)+"pointConfig"](),this[p(388)+p(1618)]?.["resetCou"+p(1101)]();return}if(y[p(1751)]!==1e3&&!y[p(1484)])if(e[p(1492)](e[p(397)],e[p(397)])){let z=this[p(516)+"tManager"]?.[p(443)+"ntEndpoint"]();this["_dispatchCloseEv"+p(1559)](pt(e[p(687)],{code:y.code,reason:p(1572)+p(1349)+p(1767)+"wn reaso"+p(873)+p(1005)+z})),this["_endpoin"+p(912)]?.["resetEnd"+p(1025)+"fig"](),this[p(388)+p(1618)]?.[p(306)+"nter"]();return}else{if(dqVLfk[p(1740)](4,_0x780ed2[p(1762)])){let z=_0x338d0c.substring(0,4-_0x84ae30[p(1762)]),q=z[p(709)](_0x1ef0a3);_0x17a19d[p(1529)](q)}else _0xbe956c[p(1529)](_0x4341bd);_0x241a1c&&(_0x507146+=1),_0x1906ee+=1,_0xca96cb=!1}this[p(1638)+"hCloseEv"+p(1559)](y),this[p(516)+p(912)]?.["resetEnd"+p(1025)+p(547)](),this[p(388)+p(1618)]?.[p(306)+p(1101)]()},this[s(1155)]=null,this[s(1563)]=null,this[s(510)+"e"]=null,this[s(1127)]=null,this[s(580)+s(668)]=null,this[s(1536)+s(728)]=null,this["onStopIm"+s(772)+s(1657)+"ct"]=null,this[s(953)+s(1085)]=this["_handleO"+s(1085)].bind(this),this["_handleO"+s(1505)]=this._handleOffLine[s(626)](this),this[s(1464)+s(1675)]=this[s(1464)+s(1675)][s(626)](this),this["_handleP"+s(471)]=this._handlePageShow[s(626)](this),this[s(1342)]={url:"",automaticOpen:!0,initReconnectInterval:1e3,maxReconnectInterval:1e4,reconnectIntervalGrowFactor:2,timeoutInterval:5e3,maxRetries:5,debug:!1,maxMessageQueueLength:e[s(1524)](1,0),service:0,logIDGenerator:o,headers:void 0,payloadEncoding:"",payloadType:"",fpID:"",deviceID:"",accessKey:"",ttwID:"",bddID:"",aID:"",disableAutoReconnect:!1,customParams:{},pingInterval:15e3,pingTimeoutInterval:4e3,pingFrequency:e.jEBWs,pingLossCount:2,enableTransformTextPayload:!1,logIDNewConfig:{enableAutoGenerateLogIDNew:!1,userIp:""},miniProgramParams:{customHttpHeader:{}},enableAutoAck:!1,reconnectInterceptor:()=>!0,enableQoS:!1,QoSLevel:2,messageStrategy:e.EuTkB,env:{xTTEnv:"",xUseEnv:""},listenNetworkChanged:!0};let{url:f,ws:g}=n,m=Array[s(378)](f)?f:e[s(1695)]==typeof f?[f]:[];if(!m||e[s(1160)](0,m[s(1762)]))throw new Error(e[s(1518)]);if(!e[s(755)](tp,g))throw new Error(s(546)+s(1770)+s(412)+s(591)+s(1110)+s(1737)+s(693)+s(1656));if(Object[s(1766)](this._options,n),this[s(516)+s(912)]=new Kd(m,this._options[s(585)+"es"]),this[s(388)+s(1618)]=new ip(this[s(1342)][s(1181)+s(1457)]),this[s(1342)][s(539)+s(1037)]&&(this[s(1043)]=!0,this[s(577)]()),this[s(1342)][s(405)+"tworkCha"+s(1011)])if(s(1423)!==s(1699))this[s(1270)+"T"]||this[s(402)+"X"]?this[s(1169)+s(385)+s(1425)]():this[s(420)+"er"]&&this["_initGlo"+s(1453)+s(428)]();else{_0x493c5b[s(1300)](_0x2030eb)||(_0x576acb=_0x12211b.fromNumber(_0x21895b));let y=e[s(1565)](this[s(944)],16),p=e[s(1344)](65535,this[s(944)]),k=e[s(1233)](this[s(1619)],16),L=e.AKuVp(65535,this[s(1619)]),z=e.NKzTf(_0x264477[s(944)],16),q=65535&_0x29d0c7[s(944)],K=e[s(395)](_0x368b6e[s(1619)],16),te=e[s(309)](65535,_0x392554[s(1619)]),Ze=0,se=0,oe=0,rt=0;return rt+=e[s(831)](L,te),oe+=e[s(1493)](rt,16),rt&=65535,oe+=e[s(1086)](k,K),se+=e[s(952)](oe,16),oe&=65535,se+=e[s(1639)](p,q),Ze+=se>>>16,se&=65535,Ze+=e.QSQvI(y,z),Ze&=65535,_0x23bf3f[s(284)](e.spXCd(e.JDqja(oe,16),rt),e.Xtvjm(e[s(852)](Ze,16),se),this[s(1496)])}}[t(953)+t(1085)](){let n=t;if(e.rYGEY(n(556),e[n(1312)])){if(this._options[n(1411)+n(456)+n(1295)]||this[n(884)+"osed"])return;this[n(606)+n(668)]()}else{let s=this[n(1039)][n(1210)+n(1574)](this._prefix);return _0xbfbe04[n(1562)](s||"{}")[_0x160070]}}[t(953)+t(1505)](){let n=t;this._destroyWebSocket();let s=e[n(467)](ia,e[n(1769)],{message:e[n(988)]});this[n(1171)+"mediatel"+n(1657)+"ct"]&&this[n(1171)+"mediatel"+n(1657)+"ct"](s)}[t(1196)+t(1453)+"Listener"](){let n=t;this[n(420)+"er"]&&window[n(975)+n(428)](n(739),this[n(953)+n(1085)]),this[n(420)+"er"]&&window[n(975)+n(428)](e.GdKRs,this._handleOffLine),this[n(420)+"er"]&&window["addEvent"+n(428)](e[n(918)],this["_handleP"+n(1675)]),this[n(420)+"er"]&&window[n(975)+n(428)](e.dBUqF,this["_handleP"+n(471)])}[t(1115)+"balEvent"+t(428)](){let n=t,s={lzKMW:function(d,f){return e[F(1064)](d,f)},KAuSe:function(d,f){return e[F(457)](d,f)},KWWFV:function(d,f){return e[F(408)](d,f)},eSOpq:function(d,f){return e[F(644)](d,f)},YfMTx:function(d,f){return e.GHpsh(d,f)},pdlZt:function(d,f){return e[F(1498)](d,f)},DIHQq:function(d,f){return e.xtohh(d,f)},PbCJC:function(d,f){return e[F(886)](d,f)},UqkgL:function(d,f){return e[F(457)](d,f)},PFjgW:function(d,f){return e.oWkLQ(d,f)},KkutW:function(d,f){return e[F(666)](d,f)},wcRVD:function(d,f){return d>f},shyGS:function(d,f,g,m){return d(f,g,m)},shPWU:function(d,f){return d|f},oMvzf:function(d,f){return d<<f},ukCml:function(d,f){return e.WMhKw(d,f)},faVaG:function(d,f){return e.uViMc(d,f)},GWEHF:function(d,f){return e[F(1178)](d,f)}};if(e[n(1172)](e[n(891)],e[n(891)])){let d=4294967295;return function(f,g,m=!0){let y=n,p=(y(1474)+"11|9|6|4|10|7|8|0")[y(466)]("|"),k=0;for(;;){switch(p[k++]){case"0":return{value:m?d:NLcLPZ[y(1372)](0,d),offset:g};case"1":d=NLcLPZ[y(791)](NLcLPZ[y(798)](127,f[g]),0);continue;case"2":d=NLcLPZ[y(1121)](NLcLPZ[y(1372)](d,NLcLPZ.YfMTx(127&f[g],7)),0);continue;case"3":if(NLcLPZ[y(566)](f[g++],128))return{value:m?d:0|d,offset:g};continue;case"4":if(NLcLPZ[y(565)](f[g++],128))return{value:m?d:NLcLPZ.lzKMW(0,d),offset:g};continue;case"5":if(NLcLPZ.DIHQq(f[g++],128))return{value:m?d:NLcLPZ[y(824)](0,d),offset:g};continue;case"6":d=NLcLPZ[y(846)](d|NLcLPZ[y(1697)](NLcLPZ[y(798)](127,f[g]),21),0);continue;case"7":if(NLcLPZ[y(566)](f[g++],128))return{value:m?d:NLcLPZ.KkutW(0,d),offset:g};continue;case"8":if(NLcLPZ[y(1091)](g+=5,f[y(1762)]))throw g=f[y(1762)],NLcLPZ[y(1359)](_0x3b04b6,g,10,f[y(1762)]);continue;case"9":if(NLcLPZ[y(566)](f[g++],128))return{value:m?d:NLcLPZ[y(1372)](0,d),offset:g};continue;case"10":d=NLcLPZ[y(1427)](d,NLcLPZ[y(483)](NLcLPZ.ukCml(15,f[g]),28))>>>0;continue;case"11":d=NLcLPZ[y(1249)](NLcLPZ.KkutW(d,NLcLPZ[y(1697)](NLcLPZ.GWEHF(127,f[g]),14)),0);continue}break}}}else this._isBrowser&&window["removeEv"+n(447)+"ner"](e[n(461)],this[n(953)+n(1085)]),this[n(420)+"er"]&&window[n(876)+n(447)+"ner"](e[n(742)],this[n(953)+n(1505)]),this[n(420)+"er"]&&window[n(876)+n(447)+n(1673)](e[n(918)],this[n(1464)+n(1675)]),this._isBrowser&&window[n(876)+n(447)+n(1673)](e[n(1161)],this._handlePageShow)}[t(1464)+t(1675)](n){let s=t,d={nPbdK:function(f,g){return e.ihsNW(f,g)},fwxdc:function(f,g){return f|g},UhBXq:function(f,g){return e.mfqLO(f,g)},koLJc:function(f,g){return f<<g},uAAnR:function(f,g){return e[F(1135)](f,g)},MClBB:function(f,g){return f&g},JPZmZ:function(f,g){return e[F(1486)](f,g)},JDddS:function(f,g){return e.lsfgM(f,g)},NcxXT:function(f,g){return e[F(1014)](f,g)},CsFkH:function(f,g){return e[F(1768)](f,g)},zLFph:function(f,g,m){return e[F(735)](f,g,m)},yiaoj:function(f,g){return f+g},duLUH:function(f,g){return e[F(1337)](f,g)},Lolxk:function(f,g){return e.Hqmxq(f,g)}};e.ByzWS(e[s(1385)],e.LNmsP)?(_0x592d69=uwMaqg[s(1315)](uwMaqg[s(983)](uwMaqg[s(1229)](uwMaqg[s(1575)](uwMaqg[s(1734)](7,_0x23a7ae),18),uwMaqg[s(657)](63,_0x1cd6b8)<<12),uwMaqg.JPZmZ(63&_0x461fc5,6)),uwMaqg[s(1561)](63,_0x3f36ef)),uwMaqg.NcxXT(_0xf2594f,65536)||uwMaqg[s(1138)](_0x3f7a98,1114111)?_0xd57677+=_0xc58f44:(_0x3bbc55-=65536,_0x1cbe0f+=uwMaqg[s(356)](_0x309da0,uwMaqg.yiaoj(uwMaqg[s(928)](_0x520c75,10),55296),uwMaqg[s(1120)](1023,_0xa199d9)+56320),_0x560281+=3)):(!n.persisted&&(this._isBrowser&&window["removeEv"+s(447)+s(1673)](e[s(918)],this[s(1464)+"ageHide"]),this[s(420)+"er"]&&window[s(876)+"entListe"+s(1673)]("pageshow",this[s(1464)+s(471)]),this[s(1535)]()),this[s(420)+"er"]&&window[s(876)+"entListe"+s(1673)](e[s(461)],this[s(953)+"nLine"]),this[s(420)+"er"]&&window.removeEventListener(e[s(742)],this._handleOffLine))}[t(1464)+t(471)](n){let s=t;n[s(1431)+"d"]&&(this["_navigat"+s(751)]()&&(!this._ws||e[s(1122)](this[s(507)][s(792)+"te"],this[s(847)])||e[s(662)](this[s(507)][s(792)+"te"],this[s(734)+"NG"]))&&this[s(953)+"nLine"](),this[s(420)+"er"]&&window[s(975)+"Listener"](e[s(461)],this[s(953)+s(1085)]),this._isBrowser&&window["addEvent"+s(428)](e.GdKRs,this[s(953)+"ffLine"]))}async[t(553)+t(1146)](n){let s=t,d={loVGI:function(f,g,m){return e[F(1528)](f,g,m)},NeClT:e[s(687)]};if(e.RfhbC===e.RfhbC){let{fpID:f,deviceID:g,bddID:m,ttwID:y,accessKey:p,aID:k,customParams:L={},enableAutoAck:z,enableQoS:q,QoSLevel:K,env:te}=this[s(1342)],Ze,se,oe;this[s(420)+"er"]||this._isMiniWX||this[s(1270)+"T"]?(Ze=location&&e[s(866)](s(1693),location.protocol)?s(1404):e[s(1301)],se=n[s(1100)](/((^ws)|(^http))((?:[s]*:\/\/))/,""),oe=/^wss(.*:\/\/)/[s(1549)](n)?n:""+Ze+se):(Ze=e[s(819)],se=n.replace(/(^http)((?:[s]*:\/\/))/,""),oe=/(^ws)((?:[s]*:\/\/))/[s(1549)](se)?se:""+Ze+se);let rt=m?e.eBPCJ:y?e[s(1254)]:e[s(508)],tl=m||y||g;if(e.eLtXS(!tl,!rt))throw new Error(e[s(1719)]);let Bp=e.qldwe(s(923),typeof L)?await e.MynjE(L):L,zp=te?e[s(947)](rp,te[s(1350)],te[s(1206)]):{},fa=Object[s(1766)]({device_platform:e.jbbMz,version_code:e[s(1721)],access_key:p,fpid:f,aid:k,[rt]:tl,xsack:z?1:0,xaack:z?1:0,xsqos:q?1:0,qos_level:q?K:void 0,qos_sdk_version:2,...zp},Bp),Fp=Object[s(1186)](fa)[s(345)]((ha,xa)=>fa[xa]!==void 0?""+ha+(ha?"&":"?")+xa+"="+fa[xa]:ha,"");return oe+"/ws/v2"+Fp}else{let f=this["_endpoin"+s(912)]?.[s(443)+s(1259)+"nt"]();this["_dispatchCloseEv"+s(1559)](d[s(1390)](_0x1b7baf,d[s(1149)],{code:1006,reason:s(1243)+f+(s(474)+", max re"+s(1354)+s(320)),wasClean:!0}))}}async _connect(){let n=t,s={cYLVf:function(d,f,g){return d(f,g)},xAULW:function(d,f,g){return d(f,g)},BkPQN:function(d,f,g,m){return e[F(762)](d,f,g,m)}};if(!(this["_connect"+n(686)]||this["_readyCl"+n(807)])){this[n(577)+n(686)]=!0;try{if(e.QefVT(n(298),n(1198))){let{offset:d}=tHZyLh[n(931)](_0x113fc7,_0x563927,_0x480169);_0xb239aa=d;let f={cursor_name:"",cursor:0,service:0},{value:g,offset:m}=tHZyLh.xAULW(_0x532442,_0x5c2004,_0xd25ac4);f.service=g,_0x34aeb9=m;let{value:y,offset:p}=_0x5098d3(_0x956486,_0x5cfa4a);_0x4e2a4a=p,f.cursor_name=tHZyLh.BkPQN(_0x144acd,_0x5319c6,_0x54f981,_0x3c5c03+y),_0x1f4130+=y;let{value:k,offset:L}=tHZyLh[n(1050)](_0x3beed6,_0x591d89,_0x39900f);f[n(1334)]=k[n(1012)](),_0x25855b=L,_0x15c201[n(1529)](f)}else{let d=this[n(516)+n(912)]?.["checkCurrentEndp"+n(1362)+n(1195)+n(650)](),{timeoutInterval:f}=this._options;if(d){let m=this[n(516)+n(912)]?.[n(443)+n(1259)+"nt"](),y=this[n(516)+"tManager"]?.[n(1480)+"ackupEndpointAnd"+n(1094)+"unt"](),p=this._endpointManager?.[n(443)+n(1259)+"ntTriesC"+n(1468)]();if(y){let k=n(1243)+m+(n(474)+n(382)+"tries re"+n(449)+n(771)+n(1371)+"ndpoint ")+y+(n(1311)+"y"),L=dt(e[n(512)],{message:k,code:en[n(1597)+n(1189)+"R"]});this[n(376)](k),this[n(1638)+n(1627)+n(1559)](L),this[n(647)]=await this[n(553)+n(1146)](y),this[n(376)](n(1243)+y+" "+p+n(784)),this[n(713)+n(491)+"rs"]()}else{let k=n(1243)+m+(n(474)+n(382)+"tries re"+n(320));this[n(376)](k),this[n(1638)+n(1627)+"ent"](e[n(957)](dt,e.mrVLn,{message:k,code:en[n(1597)+"IES_ERROR"]}));return}}else{let m=this[n(516)+n(912)]?.[n(443)+n(1259)+n(1702)+n(719)](),y=this._endpointManager?.[n(443)+n(1259)+n(1723)+n(1468)]();this._url=await this["_generat"+n(1146)](e[n(594)](m,"")),this[n(376)](n(1243)+m+" "+y+n(784)),this[n(713)+n(491)+"rs"]()}if(this[n(1043)])this[n(1043)]=!1;else{let m=e[n(892)](ia,e[n(1769)],{message:e[n(1325)]});this[n(580)+n(668)]&&this[n(580)+n(668)](m)}let g=this[n(516)+n(912)]?.["getCurre"+n(1259)+n(1723)+n(1468)]()||0;e.tBIxK(g,1)&&await this._wait(e[n(738)](g,1)),this[n(376)](n(1572)+"ng url: "+this[n(647)]+(n(837)+"ls: ")+this._protocols),this[n(507)]=ep({url:this._url,protocols:[this[n(1e3)+"ls"]],headers:this[n(1342)].miniProgramParams[n(1592)+n(352)]},this._options.ws),(this[n(420)+"er"]||this[n(605)+"r"])&&this[n(507)]&&(this[n(507)].binaryType=this[n(1365)+n(1491)]),this[n(1500)+"steners"](),this["_connect"+n(521)+n(503)]=e[n(540)](setTimeout,this._onTimeout[n(626)](this),f)}}catch(d){throw this._connectLock=!1,d}}}[t(1319)+t(777)](){let n=t;e.RZHfp(clearTimeout,this[n(577)+n(521)+n(503)]),this[n(577)+n(521)+"utId"]=null}[t(400)+t(1553)](){let n=t;e.QUXbY(clearTimeout,this[n(1497)+n(885)+"Id"]),e.paATF(clearTimeout,this[n(440)+n(1761)+n(1205)]),this["_pingPon"+n(885)+"Id"]=null,this["_reconne"+n(1761)+n(1205)]=null}[t(376)](...n){let s=t;this[s(1342)][s(1654)]&&console[s(481)][s(679)](console,[s(976)+">",...n])}[t(1527)+t(1478)+"e"](n){let s=t;if(e[s(662)](s(366),e[s(680)])){let d=this[s(1039)][s(656)](this[s(916)]),f=_0x4282bc.parse(d||"{}");return f[_0x324b6d]=void 0,this[s(1039)][s(1255)](this[s(916)],_0x5a6139[s(1125)+"y"](f))}else{let{initReconnectInterval:d,maxReconnectInterval:f,reconnectIntervalGrowFactor:g}=this._options,m=d*Math.pow(g,e[s(1168)](n,1));return e[s(1047)](m,f)?f:m}}[t(1261)](){let n=t;if(this[n(507)]&&e[n(1262)](this._ws.readyState,this[n(734)+"NG"])){this[n(400)+n(1553)](),this[n(1497)+n(885)+"Id"]=e[n(1577)](setTimeout,this[n(1261)][n(626)](this),this[n(1342)][n(896)+n(1545)]);return}if(!this[n(507)]||e.OUFGa(this[n(507)][n(792)+"te"],this[n(847)]))return void this["_handleR"+n(668)]();this[n(507)]&&this[n(507)][n(839)]("hi"),this[n(440)+n(1761)+n(1205)]=setTimeout(this[n(606)+n(668)+"Timeout"][n(626)](this),this[n(1342)][n(741)+n(1645)+n(373)])}[t(606)+t(668)+t(523)](){let n=t;this[n(388)+n(1618)]?.addCount(),this[n(813)](n(534)+n(1409)+"t",e[n(365)]),this[n(388)+n(1618)]?.["checkRea"+n(645)+"nt"]()?this["_handleR"+n(668)]():this[n(1261)]()}[t(1228)+"orOnline"](){let n=t;return this[n(1270)+"T"]||this[n(402)+"X"]?this[n(406)+n(1330)+n(850)]:(this[n(420)+"er"]||this[n(605)+"r"])&&this[n(1342)][n(405)+"tworkCha"+n(1011)]?navigator[n(1610)]:!0}["_handleR"+t(668)](){let n=t;!this[n(1228)+n(751)]()||this[n(884)+n(807)]||(this[n(516)+n(912)]?.[n(1148)+n(1025)+n(547)](),this[n(388)+n(1618)]?.["resetCou"+n(1101)](),this._ws?this[n(1341)+n(403)](1001,e[n(1591)],!0):this[n(577)]())}["_onPageN"+t(385)+"ange"](){let n=t;e[n(415)](e[n(640)],n(936))?(this[n(388)+n(1618)]?.addCount(),this.emit("ping_onc"+n(1409)+"t",n(514)),this["_pingLos"+n(1618)]?.["checkRea"+n(645)+"nt"]()?this[n(606)+n(668)]():this[n(1261)]()):this[n(1270)+"T"]?tt["onNetwor"+n(1017)+n(1272)](({isConnected:s})=>{let d=n;this["_miniNav"+d(1330)+d(850)]=s,s?this[d(953)+d(1085)]():this["_handleO"+d(1505)]()}):this[n(402)+"X"]&&wx["onNetwor"+n(1017)+n(1272)](({isConnected:s})=>{let d=n;this[d(406)+"igatorOn"+d(850)]=s,s?this[d(953)+d(1085)]():this[d(953)+d(1505)]()})}[t(303)](n){return new Promise(s=>{let d=F;setTimeout(s,this[d(1527)+d(1478)+"e"](n))})}["_disconn"+t(403)](n=1e3,s="",d=!1){let f=t;this[f(507)]&&this["_destroy"+f(472)+"t"](n,s,d)}[t(301)+"ut"](){let n=t,s=this[n(516)+n(912)]?.[n(443)+n(1259)+"nt"]();this[n(376)](n(1243)+s+n(474)),this._disconnect(1001,e[n(1758)],!0)}[t(1461)](n){let s=t,d={rSyqc:e[s(1716)],Szqsj:e[s(512)],PObjr:s(1088),xVIRc:e[s(687)]},f=e.tUoCH(Ft,n);if(this[s(507)]&&e.kBGyY(this._ws[s(792)+"te"],this[s(847)]))if(e[s(314)](e[s(705)],e.iGTod))this[s(507)]&&this[s(507)][s(839)](f),this._debug(s(1112),n);else{let g=d.rSyqc[s(466)]("|"),m=0;for(;;){switch(g[m++]){case"0":this[s(507)][s(975)+s(428)](s(868),this[s(586)]);continue;case"1":this[s(507)][s(975)+s(428)](d[s(384)],this[s(672)]);continue;case"2":this[s(507)][s(975)+s(428)](d[s(861)],this._onMessage);continue;case"3":if(!this._ws)return;continue;case"4":this._ws["addEvent"+s(428)](d[s(1604)],this[s(285)]);continue}break}}}["_removeW"+t(491)+"rs"](){let n=t;this[n(507)]&&(this._ws[n(876)+n(447)+n(1673)](e[n(1113)],this[n(586)]),this[n(507)][n(876)+"entListener"](e[n(687)],this[n(285)]),this[n(507)][n(876)+n(447)+"ner"](e[n(1092)],this[n(660)+"ge"]),this[n(507)][n(876)+n(447)+"ner"](e[n(512)],this[n(672)]))}["_addWsLi"+t(1663)](){let n=t,s=e[n(1640)].split("|"),d=0;for(;;){switch(s[d++]){case"0":if(!this[n(507)])return;continue;case"1":this[n(507)][n(975)+"Listener"](e[n(1092)],this._onMessage);continue;case"2":this[n(507)]["addEvent"+n(428)]("close",this[n(285)]);continue;case"3":this[n(507)][n(975)+n(428)](e[n(512)],this[n(672)]);continue;case"4":this[n(507)][n(975)+"Listener"](e.wLRQl,this[n(586)]);continue}break}}[t(725)+t(1220)](n=1e3,s=""){let d=t;try{this[d(507)]&&this._ws[d(1535)](n,s)}catch{}}_destroyWebSocket(n=1e3,s="",d=!1){let f=t;if(this[f(400)+"ngTimer"](),this[f(1319)+f(777)](),this[f(713)+f(491)+"rs"](),this[f(725)+f(1220)](1e3,s),this[f(577)+"Lock"]=!1,d&&this[f(1228)+f(751)]()&&!this["_readyCl"+f(807)]){if(this[f(516)+f(912)]?.["checkRea"+f(1595)+"es"]()){let m=this[f(516)+f(912)]?.[f(443)+f(1259)+"nt"]();this[f(1638)+f(721)+f(1559)](e[f(1058)](pt,e.kyBah,{code:1006,reason:f(1243)+m+(f(474)+", max retries reached"),wasClean:!0}))}else{let m=this[f(1342)][f(1055)+f(1292)+"ptor"](n,s);this[f(1638)+f(721)+f(1559)](e.LKPqF(pt,e[f(687)],{code:n,reason:s,wasClean:!0,willReconnect:m})),m&&this[f(577)]()}return}this[f(1228)+f(751)]()||this["_readyCl"+f(807)]?this[f(1638)+f(721)+"ent"](pt(e[f(687)],{code:n,reason:e.XPmWh})):this[f(1638)+"hCloseEvent"](pt(f(1535),{code:1006,reason:e[f(706)]})),this[f(507)]=null,this["_endpoin"+f(912)]?.["resetEndpointCon"+f(547)](),this[f(388)+"sCounter"]?.[f(306)+f(1101)]()}["_dispatc"+t(1476)+"nt"](n){let s=t;this.emit(e.wLRQl,n),this[s(1127)]&&this[s(1127)](n)}["_dispatc"+t(1744)+"Event"](n){let s=t;this[s(813)](e[s(1092)],n),this[s(510)+"e"]&&this[s(510)+"e"](n)}[t(1638)+t(1587)+"ageEvent"](n){let s=t;this[s(813)](e[s(999)],n),this[s(1536)+s(728)]&&this.onReceiveAck(n)}[t(1638)+"hErrorEvent"](n){let s=t;this[s(813)](e.mrVLn,n),this[s(1563)]&&this.onerror(n)}[t(1638)+t(721)+t(1559)](n){let s=t;this[s(813)](e.kyBah,n),this.onclose&&this[s(1155)](n)}get[t(624)+"pe"](){let n=t;if(e[n(919)](e.IdmQc,e.IdmQc)){let s=_0x58209d[_0x1c0072];if(_0x5c0cc1[_0x5ebac9][n(1762)]!==4){let d=_0x5e7972[n(297)+"g"](0,4-_0x569fcf[_0x5adefb][n(1762)]),f=d[n(709)](s);_0x9dc44b=_0x5b5756[n(709)](f)}else _0x130374=_0x5a74ee.concat(s)}else return this._ws?this[n(507)].binaryType:this[n(1365)+"ype"]}set binaryType(n){let s=t;this["_binaryT"+s(1491)]=n,this[s(507)]&&(this[s(507)].binaryType=n)}get[t(1167)+"nt"](){let n=t;return this._endpointManager?.[n(443)+n(1259)+n(1723)+n(1468)]()||0}get["buffered"+t(635)](){let n=t,s=this[n(710)+n(411)][n(345)]((d,f)=>{let g=n,m={lHQry:function(y,p){return e[F(1440)](y,p)},KNVER:g(1176),NsgWl:function(y,p){return e[g(787)](y,p)},XGmww:function(y,p){return e[g(1612)](y,p)},XCVYv:"application/json"};return e.EDZkk(g(1514),e[g(909)])?(d+=f&&f.byteLength||0,d):wiZtpF[g(1540)](wiZtpF[g(790)],typeof _0x2cd90d)&&(wiZtpF.NsgWl(_0x56930f,_0x14b0c1)||_0x20b67d[g(432)]&&wiZtpF[g(486)](_0x5cb65b[g(432)],_0x245a00))||wiZtpF[g(1540)]("string",typeof _0x45d46b)?"":(_0x54ffcc[g(1562)](_0x178512),wiZtpF[g(1212)])},0);return e[n(750)](s,this._ws?this._ws[n(1313)+n(635)]:0)}get extensions(){let n=t;return this[n(507)]?this[n(507)][n(1096)+"ns"]:""}get[t(1511)](){let n=t;return this[n(507)]?this._ws[n(1511)]:""}get[t(792)+"te"](){let n=t;return this[n(507)]?this[n(507)][n(792)+"te"]:this[n(1342)][n(539)+n(1037)]?this[n(734)+"NG"]:this.CLOSED}get[t(387)](){let n=t;return this._ws?this[n(507)][n(387)]:this[n(647)]}[t(1535)](n=1e3,s){let d=t,f=e[d(877)][d(466)]("|"),g=0;for(;;){switch(f[g++]){case"0":this[d(400)+d(1553)]();continue;case"1":if(!this[d(507)])return void this._debug(d(479)+d(1452)+d(612)+d(980)+"ed");continue;case"2":if(e.acrZF(this[d(507)][d(792)+"te"],this[d(704)])||this[d(507)][d(792)+"te"]===this.CLOSING)return void this[d(376)](e[d(1685)]);continue;case"3":this[d(884)+d(807)]=!0;continue;case"4":this["_QoSMana"+d(730)]?.[d(1388)]();continue;case"5":this[d(1319)+d(777)]();continue;case"6":this[d(1115)+"balEventListener"]();continue;case"7":this["_destroy"+d(472)+"t"](n,s);continue}break}}async send(n,s){let d=t;if(e[d(1321)](null,n))throw new Error(e[d(1137)]);e.lgkaU(e[d(638)],typeof n)&&(n=JSON[d(1125)+"y"](n)),e.oIyaV(e[d(1695)],typeof n)&&!e.EeIcC(n,ArrayBuffer)&&!(n[d(432)]&&e.vFXMf(n[d(432)],ArrayBuffer))&&(n=JSON[d(1125)+"y"](n));let f=await e[d(337)](Jd,n),g=e[d(1379)](np,n),{method:m=0,service:y=this._options[d(1713)],logID:p=this[d(1342)][d(500)+d(1200)](),headers:k=this._options[d(396)],payloadEncoding:L=this[d(1342)][d(542)+d(511)],payloadType:z=this[d(1342)][d(418)+d(1491)],logIDNew:q=this[d(1342)][d(1306)+d(409)][d(1215)+"toGenera"+d(1013)+"ew"]?e[d(1616)](i,this[d(1342)][d(1306)+d(409)][d(350)]):""}=e[d(1051)](s,{});if(!y)throw new Error(e[d(1389)]);let K={SeqID:le[d(394)+"er"](this[d(1080)]++),LogID:le[d(394)+"er"](p),service:y,method:m,headers:k,payloadEncoding:L instanceof Object?L[d(349)]?L.encoding:"":L,payloadType:e[d(1612)](z,Object)?z.type?z[d(1473)]:g:z||g,payload:f,LogIDNew:q},te=e[d(1742)](Ft,K);return this[d(507)]&&e[d(1670)](this[d(507)][d(792)+"te"],this[d(847)])?(this[d(507)]&&this[d(507)].send(te),this[d(376)](d(1750),K)):this[d(710)+"Queue"][d(1762)]<this[d(1342)]["maxMessa"+d(632)+"ength"]?(this[d(710)+d(411)][d(1529)](te),this[d(376)](e[d(592)],K)):(this[d(710)+d(411)][d(814)](),this[d(710)+d(411)][d(1529)](te)),{seqID:this._seqId,logID:p,logIDNew:q}}async[t(1055)+"t"](n){let s=t,{url:d}=e[s(756)](n,{}),f=Array[s(378)](d)?d:s(1176)==typeof d?[d]:[];n&&Object.assign(this[s(1342)],n),f&&f.length?this[s(516)+s(912)]=new Kd(f,this._options[s(585)+"es"]):this[s(516)+s(912)]?.[s(1148)+s(1025)+s(547)](),this[s(388)+s(1618)]?.resetCounter(this._options[s(1181)+"Count"]),this[s(884)+s(807)]=!1,this._ws&&this[s(507)][s(792)+"te"]!==this[s(704)]?this["_disconn"+s(403)](1e3,"manual r"+s(668)+s(1633),!0):(this[s(1043)]=!0,this[s(577)]())}async[t(1045)](){let n=t;if(!this[n(577)+n(686)]){let s="4|0|2|1|3"[n(466)]("|"),d=0;for(;;){switch(s[d++]){case"0":this[n(388)+"sCounter"]?.[n(306)+"nter"]();continue;case"1":this[n(1043)]=!0;continue;case"2":this["_readyCl"+n(807)]=!1;continue;case"3":this._connect();continue;case"4":this[n(516)+"tManager"]?.[n(1148)+n(1025)+n(547)]();continue}break}}}[t(975)+t(428)](n,s){this.on(n,s)}[t(1557)+"Event"](n){let{type:s}=n;this.emit(s,n)}[t(876)+t(447)+t(1673)](n,s){this[t(596)](n,s)}pingOnce(){let n=t,s={OwiEP:function(d,f){return e.VSytm(d,f)},MpMBN:"success",Drzuu:e[n(674)],PUHrR:function(d,f){return e[n(1151)](d,f)},oRoJE:n(514),qdvoo:n(534)+n(1409)+"t"};return e.Uqcje(e[n(329)],e[n(329)])?e[n(1369)](e[n(609)](_0x475e98,4).join("0"),e[n(1579)](_0xcc47f3,_0x14c9d6,2).toString(16))[n(724)](-4):new Promise((d,f)=>{let g=n;this[g(400)+"ngTimer"](),this["_pingPon"+g(885)+"Id"]=e.JUEue(setTimeout,this[g(1261)].bind(this),this._options[g(896)+g(1545)]);let m=()=>{let p=g;s[p(1405)](d,s[p(1763)]),this[p(596)](s.Drzuu,m),this[p(596)](p(534)+p(1409)+"t",y)},y=()=>{let p=g;s[p(319)](f,s[p(448)]),this[p(596)]("ping_onc"+p(1218)+"s",m),this[p(596)](s[p(1204)],y)};this.on(e.edVae,m),this.on(e.YQgKn,y),this._ping()})}}})(),Me[N(788)+N(1416)]=De[N(788)+N(1416)],Me["CustomEr"+N(1227)]=De[N(948)+"rorEvent"],Me[N(1659)+"e"]=De.ErrorCode,Me[N(1756)]=De[N(1756)],Me[N(1287)]=De[N(1287)],Me[N(817)+N(1336)+N(958)]=De["Frontier"+N(1336)+N(958)],Me[N(1336)+N(958)]=De[N(1336)+N(958)],Me[N(590)+"t"]=De[N(590)+"t"],Me.ReconnectEvent=De[N(1068)+"tEvent"],Me["createCl"+N(1416)]=De[N(914)+"oseEvent"],Me["createEr"+N(1227)]=De["createEr"+N(1227)],Me[N(1097)+N(505)+"nt"]=De[N(1097)+"ssageEvent"],Me.createOpenEvent=De[N(1430)+N(473)],Me["createRe"+N(960)+"vent"]=De[N(1329)+N(960)+"vent"],Me["decodedF"+N(531)]=De[N(1099)+N(531)],Me[N(1753)+N(544)]=De[N(1753)+N(544)];for(yo in De)["CustomCl"+N(1416),"CustomEr"+N(1227),N(1659)+"e",N(1756),N(1287),N(817)+"MessageEvent",N(1336)+"vent",N(590)+"t",N(1068)+N(1534),N(914)+"oseEvent",N(654)+N(1227),N(1097)+N(505)+"nt",N(1430)+N(473),N(1329)+N(960)+"vent",N(1099)+"rame",N(1753)+N(544)].indexOf(yo)===-1&&(Me[yo]=De[yo]);var yo;Object[N(627)+N(517)](Me,N(1732)+"le",{value:!0})});var $t=ae((oR,nh)=>{"use strict";var eh=["nodebuffer","arraybuffer","fragments"],th=typeof Blob<"u";th&&eh.push("blob");nh.exports={BINARY_TYPES:eh,CLOSE_TIMEOUT:3e4,EMPTY_BUFFER:Buffer.alloc(0),GUID:"258EAFA5-E914-47DA-95CA-C5AB0DC85B11",hasBlob:th,kForOnEventAttribute:Symbol("kIsForOnEventAttribute"),kListener:Symbol("kListener"),kStatusCode:Symbol("status-code"),kWebSocket:Symbol("websocket"),NOOP:()=>{}}});var Gi=ae((aR,To)=>{"use strict";var{EMPTY_BUFFER:Zb}=$t(),nd=Buffer[Symbol.species];function Jb(t,e){if(t.length===0)return Zb;if(t.length===1)return t[0];let r=Buffer.allocUnsafe(e),i=0;for(let o=0;o<t.length;o++){let c=t[o];r.set(c,i),i+=c.length}return i<e?new nd(r.buffer,r.byteOffset,i):r}function rh(t,e,r,i,o){for(let c=0;c<o;c++)r[i+c]=t[c]^e[c&3]}function ih(t,e){for(let r=0;r<t.length;r++)t[r]^=e[r&3]}function Yb(t){return t.length===t.buffer.byteLength?t.buffer:t.buffer.slice(t.byteOffset,t.byteOffset+t.length)}function rd(t){if(rd.readOnly=!0,Buffer.isBuffer(t))return t;let e;return t instanceof ArrayBuffer?e=new nd(t):ArrayBuffer.isView(t)?e=new nd(t.buffer,t.byteOffset,t.byteLength):(e=Buffer.from(t),rd.readOnly=!1),e}To.exports={concat:Jb,mask:rh,toArrayBuffer:Yb,toBuffer:rd,unmask:ih};if(!process.env.WS_NO_BUFFER_UTIL)try{let t=ue("bufferutil");To.exports.mask=function(e,r,i,o,c){c<48?rh(e,r,i,o,c):t.mask(e,r,i,o,c)},To.exports.unmask=function(e,r){e.length<32?ih(e,r):t.unmask(e,r)}}catch{}});var ah=ae((cR,oh)=>{"use strict";var sh=Symbol("kDone"),id=Symbol("kRun"),sd=class{constructor(e){this[sh]=()=>{this.pending--,this[id]()},this.concurrency=e||1/0,this.jobs=[],this.pending=0}add(e){this.jobs.push(e),this[id]()}[id](){if(this.pending!==this.concurrency&&this.jobs.length){let e=this.jobs.shift();this.pending++,e(this[sh])}}};oh.exports=sd});var kr=ae((dR,uh)=>{"use strict";var qi=ue("zlib"),ch=Gi(),Xb=ah(),{kStatusCode:dh}=$t(),Qb=Buffer[Symbol.species],eE=Buffer.from([0,0,255,255]),Co=Symbol("permessage-deflate"),Vt=Symbol("total-length"),Cr=Symbol("callback"),En=Symbol("buffers"),Dr=Symbol("error"),Ro,od=class{constructor(e){if(this._options=e||{},this._threshold=this._options.threshold!==void 0?this._options.threshold:1024,this._maxPayload=this._options.maxPayload|0,this._isServer=!!this._options.isServer,this._deflate=null,this._inflate=null,this.params=null,!Ro){let r=this._options.concurrencyLimit!==void 0?this._options.concurrencyLimit:10;Ro=new Xb(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[Cr];this._deflate.close(),this._deflate=null,e&&e(new Error("The deflate stream was closed while data was being processed"))}}acceptAsServer(e){let r=this._options,i=e.find(o=>!(r.serverNoContextTakeover===!1&&o.server_no_context_takeover||o.server_max_window_bits&&(r.serverMaxWindowBits===!1||typeof r.serverMaxWindowBits=="number"&&r.serverMaxWindowBits>o.server_max_window_bits)||typeof r.clientMaxWindowBits=="number"&&!o.client_max_window_bits));if(!i)throw new Error("None of the extension offers can be accepted");return r.serverNoContextTakeover&&(i.server_no_context_takeover=!0),r.clientNoContextTakeover&&(i.client_no_context_takeover=!0),typeof r.serverMaxWindowBits=="number"&&(i.server_max_window_bits=r.serverMaxWindowBits),typeof r.clientMaxWindowBits=="number"?i.client_max_window_bits=r.clientMaxWindowBits:(i.client_max_window_bits===!0||r.clientMaxWindowBits===!1)&&delete i.client_max_window_bits,i}acceptAsClient(e){let r=e[0];if(this._options.clientNoContextTakeover===!1&&r.client_no_context_takeover)throw new Error('Unexpected parameter "client_no_context_takeover"');if(!r.client_max_window_bits)typeof this._options.clientMaxWindowBits=="number"&&(r.client_max_window_bits=this._options.clientMaxWindowBits);else if(this._options.clientMaxWindowBits===!1||typeof this._options.clientMaxWindowBits=="number"&&r.client_max_window_bits>this._options.clientMaxWindowBits)throw new Error('Unexpected or invalid parameter "client_max_window_bits"');return r}normalizeParams(e){return e.forEach(r=>{Object.keys(r).forEach(i=>{let o=r[i];if(o.length>1)throw new Error(`Parameter "${i}" must have only a single value`);if(o=o[0],i==="client_max_window_bits"){if(o!==!0){let c=+o;if(!Number.isInteger(c)||c<8||c>15)throw new TypeError(`Invalid value for parameter "${i}": ${o}`);o=c}else if(!this._isServer)throw new TypeError(`Invalid value for parameter "${i}": ${o}`)}else if(i==="server_max_window_bits"){let c=+o;if(!Number.isInteger(c)||c<8||c>15)throw new TypeError(`Invalid value for parameter "${i}": ${o}`);o=c}else if(i==="client_no_context_takeover"||i==="server_no_context_takeover"){if(o!==!0)throw new TypeError(`Invalid value for parameter "${i}": ${o}`)}else throw new Error(`Unknown parameter "${i}"`);r[i]=o})}),e}decompress(e,r,i){Ro.add(o=>{this._decompress(e,r,(c,l)=>{o(),i(c,l)})})}compress(e,r,i){Ro.add(o=>{this._compress(e,r,(c,l)=>{o(),i(c,l)})})}_decompress(e,r,i){let o=this._isServer?"client":"server";if(!this._inflate){let c=`${o}_max_window_bits`,l=typeof this.params[c]!="number"?qi.Z_DEFAULT_WINDOWBITS:this.params[c];this._inflate=qi.createInflateRaw({...this._options.zlibInflateOptions,windowBits:l}),this._inflate[Co]=this,this._inflate[Vt]=0,this._inflate[En]=[],this._inflate.on("error",nE),this._inflate.on("data",lh)}this._inflate[Cr]=i,this._inflate.write(e),r&&this._inflate.write(eE),this._inflate.flush(()=>{let c=this._inflate[Dr];if(c){this._inflate.close(),this._inflate=null,i(c);return}let l=ch.concat(this._inflate[En],this._inflate[Vt]);this._inflate._readableState.endEmitted?(this._inflate.close(),this._inflate=null):(this._inflate[Vt]=0,this._inflate[En]=[],r&&this.params[`${o}_no_context_takeover`]&&this._inflate.reset()),i(null,l)})}_compress(e,r,i){let o=this._isServer?"server":"client";if(!this._deflate){let c=`${o}_max_window_bits`,l=typeof this.params[c]!="number"?qi.Z_DEFAULT_WINDOWBITS:this.params[c];this._deflate=qi.createDeflateRaw({...this._options.zlibDeflateOptions,windowBits:l}),this._deflate[Vt]=0,this._deflate[En]=[],this._deflate.on("data",tE)}this._deflate[Cr]=i,this._deflate.write(e),this._deflate.flush(qi.Z_SYNC_FLUSH,()=>{if(!this._deflate)return;let c=ch.concat(this._deflate[En],this._deflate[Vt]);r&&(c=new Qb(c.buffer,c.byteOffset,c.length-4)),this._deflate[Cr]=null,this._deflate[Vt]=0,this._deflate[En]=[],r&&this.params[`${o}_no_context_takeover`]&&this._deflate.reset(),i(null,c)})}};uh.exports=od;function tE(t){this[En].push(t),this[Vt]+=t.length}function lh(t){if(this[Vt]+=t.length,this[Co]._maxPayload<1||this[Vt]<=this[Co]._maxPayload){this[En].push(t);return}this[Dr]=new RangeError("Max payload size exceeded"),this[Dr].code="WS_ERR_UNSUPPORTED_MESSAGE_LENGTH",this[Dr][dh]=1009,this.removeListener("data",lh),this.reset()}function nE(t){if(this[Co]._inflate=null,this[Dr]){this[Cr](this[Dr]);return}t[dh]=1007,this[Cr](t)}});var Pr=ae((lR,Do)=>{"use strict";var{isUtf8:fh}=ue("buffer"),{hasBlob:rE}=$t(),iE=[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 sE(t){return t>=1e3&&t<=1014&&t!==1004&&t!==1005&&t!==1006||t>=3e3&&t<=4999}function ad(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 oE(t){return rE&&typeof t=="object"&&typeof t.arrayBuffer=="function"&&typeof t.type=="string"&&typeof t.stream=="function"&&(t[Symbol.toStringTag]==="Blob"||t[Symbol.toStringTag]==="File")}Do.exports={isBlob:oE,isValidStatusCode:sE,isValidUTF8:ad,tokenChars:iE};if(fh)Do.exports.isValidUTF8=function(t){return t.length<24?ad(t):fh(t)};else if(!process.env.WS_NO_UTF_8_VALIDATE)try{let t=ue("utf-8-validate");Do.exports.isValidUTF8=function(e){return e.length<32?ad(e):t(e)}}catch{}});var fd=ae((uR,_h)=>{"use strict";var{Writable:aE}=ue("stream"),hh=kr(),{BINARY_TYPES:cE,EMPTY_BUFFER:xh,kStatusCode:dE,kWebSocket:lE}=$t(),{concat:cd,toArrayBuffer:uE,unmask:fE}=Gi(),{isValidStatusCode:hE,isValidUTF8:ph}=Pr(),ko=Buffer[Symbol.species],ft=0,gh=1,mh=2,wh=3,dd=4,ld=5,Po=6,ud=class extends aE{constructor(e={}){super(),this._allowSynchronousEvents=e.allowSynchronousEvents!==void 0?e.allowSynchronousEvents:!0,this._binaryType=e.binaryType||cE[0],this._extensions=e.extensions||{},this._isServer=!!e.isServer,this._maxPayload=e.maxPayload|0,this._skipUTF8Validation=!!e.skipUTF8Validation,this[lE]=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=ft}_write(e,r,i){if(this._opcode===8&&this._state==ft)return i();this._bufferedBytes+=e.length,this._buffers.push(e),this.startLoop(i)}consume(e){if(this._bufferedBytes-=e,e===this._buffers[0].length)return this._buffers.shift();if(e<this._buffers[0].length){let i=this._buffers[0];return this._buffers[0]=new ko(i.buffer,i.byteOffset+e,i.length-e),new ko(i.buffer,i.byteOffset,e)}let r=Buffer.allocUnsafe(e);do{let i=this._buffers[0],o=r.length-e;e>=i.length?r.set(this._buffers.shift(),o):(r.set(new Uint8Array(i.buffer,i.byteOffset,e),o),this._buffers[0]=new ko(i.buffer,i.byteOffset+e,i.length-e)),e-=i.length}while(e>0);return r}startLoop(e){this._loop=!0;do switch(this._state){case ft:this.getInfo(e);break;case gh:this.getPayloadLength16(e);break;case mh:this.getPayloadLength64(e);break;case wh:this.getMask();break;case dd:this.getData(e);break;case ld:case Po:this._loop=!1;return}while(this._loop);this._errored||e()}getInfo(e){if(this._bufferedBytes<2){this._loop=!1;return}let r=this.consume(2);if((r[0]&48)!==0){let o=this.createError(RangeError,"RSV2 and RSV3 must be clear",!0,1002,"WS_ERR_UNEXPECTED_RSV_2_3");e(o);return}let i=(r[0]&64)===64;if(i&&!this._extensions[hh.extensionName]){let o=this.createError(RangeError,"RSV1 must be clear",!0,1002,"WS_ERR_UNEXPECTED_RSV_1");e(o);return}if(this._fin=(r[0]&128)===128,this._opcode=r[0]&15,this._payloadLength=r[1]&127,this._opcode===0){if(i){let o=this.createError(RangeError,"RSV1 must be clear",!0,1002,"WS_ERR_UNEXPECTED_RSV_1");e(o);return}if(!this._fragmented){let o=this.createError(RangeError,"invalid opcode 0",!0,1002,"WS_ERR_INVALID_OPCODE");e(o);return}this._opcode=this._fragmented}else if(this._opcode===1||this._opcode===2){if(this._fragmented){let o=this.createError(RangeError,`invalid opcode ${this._opcode}`,!0,1002,"WS_ERR_INVALID_OPCODE");e(o);return}this._compressed=i}else if(this._opcode>7&&this._opcode<11){if(!this._fin){let o=this.createError(RangeError,"FIN must be set",!0,1002,"WS_ERR_EXPECTED_FIN");e(o);return}if(i){let o=this.createError(RangeError,"RSV1 must be clear",!0,1002,"WS_ERR_UNEXPECTED_RSV_1");e(o);return}if(this._payloadLength>125||this._opcode===8&&this._payloadLength===1){let o=this.createError(RangeError,`invalid payload length ${this._payloadLength}`,!0,1002,"WS_ERR_INVALID_CONTROL_PAYLOAD_LENGTH");e(o);return}}else{let o=this.createError(RangeError,`invalid opcode ${this._opcode}`,!0,1002,"WS_ERR_INVALID_OPCODE");e(o);return}if(!this._fin&&!this._fragmented&&(this._fragmented=this._opcode),this._masked=(r[1]&128)===128,this._isServer){if(!this._masked){let o=this.createError(RangeError,"MASK must be set",!0,1002,"WS_ERR_EXPECTED_MASK");e(o);return}}else if(this._masked){let o=this.createError(RangeError,"MASK must be clear",!0,1002,"WS_ERR_UNEXPECTED_MASK");e(o);return}this._payloadLength===126?this._state=gh:this._payloadLength===127?this._state=mh:this.haveLength(e)}getPayloadLength16(e){if(this._bufferedBytes<2){this._loop=!1;return}this._payloadLength=this.consume(2).readUInt16BE(0),this.haveLength(e)}getPayloadLength64(e){if(this._bufferedBytes<8){this._loop=!1;return}let r=this.consume(8),i=r.readUInt32BE(0);if(i>Math.pow(2,21)-1){let o=this.createError(RangeError,"Unsupported WebSocket frame: payload length > 2^53 - 1",!1,1009,"WS_ERR_UNSUPPORTED_DATA_PAYLOAD_LENGTH");e(o);return}this._payloadLength=i*Math.pow(2,32)+r.readUInt32BE(4),this.haveLength(e)}haveLength(e){if(this._payloadLength&&this._opcode<8&&(this._totalPayloadLength+=this._payloadLength,this._totalPayloadLength>this._maxPayload&&this._maxPayload>0)){let r=this.createError(RangeError,"Max payload size exceeded",!1,1009,"WS_ERR_UNSUPPORTED_MESSAGE_LENGTH");e(r);return}this._masked?this._state=wh:this._state=dd}getMask(){if(this._bufferedBytes<4){this._loop=!1;return}this._mask=this.consume(4),this._state=dd}getData(e){let r=xh;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&&fE(r,this._mask)}if(this._opcode>7){this.controlMessage(r,e);return}if(this._compressed){this._state=ld,this.decompress(r,e);return}r.length&&(this._messageLength=this._totalPayloadLength,this._fragments.push(r)),this.dataMessage(e)}decompress(e,r){this._extensions[hh.extensionName].decompress(e,this._fin,(o,c)=>{if(o)return r(o);if(c.length){if(this._messageLength+=c.length,this._messageLength>this._maxPayload&&this._maxPayload>0){let l=this.createError(RangeError,"Max payload size exceeded",!1,1009,"WS_ERR_UNSUPPORTED_MESSAGE_LENGTH");r(l);return}this._fragments.push(c)}this.dataMessage(r),this._state===ft&&this.startLoop(r)})}dataMessage(e){if(!this._fin){this._state=ft;return}let r=this._messageLength,i=this._fragments;if(this._totalPayloadLength=0,this._messageLength=0,this._fragmented=0,this._fragments=[],this._opcode===2){let o;this._binaryType==="nodebuffer"?o=cd(i,r):this._binaryType==="arraybuffer"?o=uE(cd(i,r)):this._binaryType==="blob"?o=new Blob(i):o=i,this._allowSynchronousEvents?(this.emit("message",o,!0),this._state=ft):(this._state=Po,setImmediate(()=>{this.emit("message",o,!0),this._state=ft,this.startLoop(e)}))}else{let o=cd(i,r);if(!this._skipUTF8Validation&&!ph(o)){let c=this.createError(Error,"invalid UTF-8 sequence",!0,1007,"WS_ERR_INVALID_UTF8");e(c);return}this._state===ld||this._allowSynchronousEvents?(this.emit("message",o,!1),this._state=ft):(this._state=Po,setImmediate(()=>{this.emit("message",o,!1),this._state=ft,this.startLoop(e)}))}}controlMessage(e,r){if(this._opcode===8){if(e.length===0)this._loop=!1,this.emit("conclude",1005,xh),this.end();else{let i=e.readUInt16BE(0);if(!hE(i)){let c=this.createError(RangeError,`invalid status code ${i}`,!0,1002,"WS_ERR_INVALID_CLOSE_CODE");r(c);return}let o=new ko(e.buffer,e.byteOffset+2,e.length-2);if(!this._skipUTF8Validation&&!ph(o)){let c=this.createError(Error,"invalid UTF-8 sequence",!0,1007,"WS_ERR_INVALID_UTF8");r(c);return}this._loop=!1,this.emit("conclude",i,o),this.end()}this._state=ft;return}this._allowSynchronousEvents?(this.emit(this._opcode===9?"ping":"pong",e),this._state=ft):(this._state=Po,setImmediate(()=>{this.emit(this._opcode===9?"ping":"pong",e),this._state=ft,this.startLoop(r)}))}createError(e,r,i,o,c){this._loop=!1,this._errored=!0;let l=new e(i?`Invalid WebSocket frame: ${r}`:r);return Error.captureStackTrace(l,this.createError),l.code=c,l[dE]=o,l}};_h.exports=ud});var pd=ae((hR,Eh)=>{"use strict";var{Duplex:fR}=ue("stream"),{randomFillSync:xE}=ue("crypto"),yh=kr(),{EMPTY_BUFFER:pE,kWebSocket:gE,NOOP:mE}=$t(),{isBlob:Lr,isValidStatusCode:wE}=Pr(),{mask:bh,toBuffer:qn}=Gi(),ht=Symbol("kByteLength"),_E=Buffer.alloc(4),Lo=8*1024,Hn,Or=Lo,St=0,yE=1,bE=2,hd=class t{constructor(e,r,i){this._extensions=r||{},i&&(this._generateMask=i,this._maskBuffer=Buffer.alloc(4)),this._socket=e,this._firstFragment=!0,this._compress=!1,this._bufferedBytes=0,this._queue=[],this._state=St,this.onerror=mE,this[gE]=void 0}static frame(e,r){let i,o=!1,c=2,l=!1;r.mask&&(i=r.maskBuffer||_E,r.generateMask?r.generateMask(i):(Or===Lo&&(Hn===void 0&&(Hn=Buffer.alloc(Lo)),xE(Hn,0,Lo),Or=0),i[0]=Hn[Or++],i[1]=Hn[Or++],i[2]=Hn[Or++],i[3]=Hn[Or++]),l=(i[0]|i[1]|i[2]|i[3])===0,c=6);let u;typeof e=="string"?(!r.mask||l)&&r[ht]!==void 0?u=r[ht]:(e=Buffer.from(e),u=e.length):(u=e.length,o=r.mask&&r.readOnly&&!l);let h=u;u>=65536?(c+=8,h=127):u>125&&(c+=2,h=126);let x=Buffer.allocUnsafe(o?u+c:c);return x[0]=r.fin?r.opcode|128:r.opcode,r.rsv1&&(x[0]|=64),x[1]=h,h===126?x.writeUInt16BE(u,2):h===127&&(x[2]=x[3]=0,x.writeUIntBE(u,4,6)),r.mask?(x[1]|=128,x[c-4]=i[0],x[c-3]=i[1],x[c-2]=i[2],x[c-1]=i[3],l?[x,e]:o?(bh(e,i,x,c,u),[x]):(bh(e,i,e,0,u),[x,e])):[x,e]}close(e,r,i,o){let c;if(e===void 0)c=pE;else{if(typeof e!="number"||!wE(e))throw new TypeError("First argument must be a valid error code number");if(r===void 0||!r.length)c=Buffer.allocUnsafe(2),c.writeUInt16BE(e,0);else{let u=Buffer.byteLength(r);if(u>123)throw new RangeError("The message must not be greater than 123 bytes");c=Buffer.allocUnsafe(2+u),c.writeUInt16BE(e,0),typeof r=="string"?c.write(r,2):c.set(r,2)}}let l={[ht]:c.length,fin:!0,generateMask:this._generateMask,mask:i,maskBuffer:this._maskBuffer,opcode:8,readOnly:!1,rsv1:!1};this._state!==St?this.enqueue([this.dispatch,c,!1,l,o]):this.sendFrame(t.frame(c,l),o)}ping(e,r,i){let o,c;if(typeof e=="string"?(o=Buffer.byteLength(e),c=!1):Lr(e)?(o=e.size,c=!1):(e=qn(e),o=e.length,c=qn.readOnly),o>125)throw new RangeError("The data size must not be greater than 125 bytes");let l={[ht]:o,fin:!0,generateMask:this._generateMask,mask:r,maskBuffer:this._maskBuffer,opcode:9,readOnly:c,rsv1:!1};Lr(e)?this._state!==St?this.enqueue([this.getBlobData,e,!1,l,i]):this.getBlobData(e,!1,l,i):this._state!==St?this.enqueue([this.dispatch,e,!1,l,i]):this.sendFrame(t.frame(e,l),i)}pong(e,r,i){let o,c;if(typeof e=="string"?(o=Buffer.byteLength(e),c=!1):Lr(e)?(o=e.size,c=!1):(e=qn(e),o=e.length,c=qn.readOnly),o>125)throw new RangeError("The data size must not be greater than 125 bytes");let l={[ht]:o,fin:!0,generateMask:this._generateMask,mask:r,maskBuffer:this._maskBuffer,opcode:10,readOnly:c,rsv1:!1};Lr(e)?this._state!==St?this.enqueue([this.getBlobData,e,!1,l,i]):this.getBlobData(e,!1,l,i):this._state!==St?this.enqueue([this.dispatch,e,!1,l,i]):this.sendFrame(t.frame(e,l),i)}send(e,r,i){let o=this._extensions[yh.extensionName],c=r.binary?2:1,l=r.compress,u,h;typeof e=="string"?(u=Buffer.byteLength(e),h=!1):Lr(e)?(u=e.size,h=!1):(e=qn(e),u=e.length,h=qn.readOnly),this._firstFragment?(this._firstFragment=!1,l&&o&&o.params[o._isServer?"server_no_context_takeover":"client_no_context_takeover"]&&(l=u>=o._threshold),this._compress=l):(l=!1,c=0),r.fin&&(this._firstFragment=!0);let x={[ht]:u,fin:r.fin,generateMask:this._generateMask,mask:r.mask,maskBuffer:this._maskBuffer,opcode:c,readOnly:h,rsv1:l};Lr(e)?this._state!==St?this.enqueue([this.getBlobData,e,this._compress,x,i]):this.getBlobData(e,this._compress,x,i):this._state!==St?this.enqueue([this.dispatch,e,this._compress,x,i]):this.dispatch(e,this._compress,x,i)}getBlobData(e,r,i,o){this._bufferedBytes+=i[ht],this._state=bE,e.arrayBuffer().then(c=>{if(this._socket.destroyed){let u=new Error("The socket was closed while the blob was being read");process.nextTick(xd,this,u,o);return}this._bufferedBytes-=i[ht];let l=qn(c);r?this.dispatch(l,r,i,o):(this._state=St,this.sendFrame(t.frame(l,i),o),this.dequeue())}).catch(c=>{process.nextTick(EE,this,c,o)})}dispatch(e,r,i,o){if(!r){this.sendFrame(t.frame(e,i),o);return}let c=this._extensions[yh.extensionName];this._bufferedBytes+=i[ht],this._state=yE,c.compress(e,i.fin,(l,u)=>{if(this._socket.destroyed){let h=new Error("The socket was closed while data was being compressed");xd(this,h,o);return}this._bufferedBytes-=i[ht],this._state=St,i.readOnly=!1,this.sendFrame(t.frame(u,i),o),this.dequeue()})}dequeue(){for(;this._state===St&&this._queue.length;){let e=this._queue.shift();this._bufferedBytes-=e[3][ht],Reflect.apply(e[0],this,e.slice(1))}}enqueue(e){this._bufferedBytes+=e[3][ht],this._queue.push(e)}sendFrame(e,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)}};Eh.exports=hd;function xd(t,e,r){typeof r=="function"&&r(e);for(let i=0;i<t._queue.length;i++){let o=t._queue[i],c=o[o.length-1];typeof c=="function"&&c(e)}}function EE(t,e,r){xd(t,e,r),t.onerror(e)}});var kh=ae((xR,Dh)=>{"use strict";var{kForOnEventAttribute:Hi,kListener:gd}=$t(),vh=Symbol("kCode"),Sh=Symbol("kData"),Ih=Symbol("kError"),Ah=Symbol("kMessage"),Th=Symbol("kReason"),Nr=Symbol("kTarget"),Rh=Symbol("kType"),Ch=Symbol("kWasClean"),Zt=class{constructor(e){this[Nr]=null,this[Rh]=e}get target(){return this[Nr]}get type(){return this[Rh]}};Object.defineProperty(Zt.prototype,"target",{enumerable:!0});Object.defineProperty(Zt.prototype,"type",{enumerable:!0});var jn=class extends Zt{constructor(e,r={}){super(e),this[vh]=r.code===void 0?0:r.code,this[Th]=r.reason===void 0?"":r.reason,this[Ch]=r.wasClean===void 0?!1:r.wasClean}get code(){return this[vh]}get reason(){return this[Th]}get wasClean(){return this[Ch]}};Object.defineProperty(jn.prototype,"code",{enumerable:!0});Object.defineProperty(jn.prototype,"reason",{enumerable:!0});Object.defineProperty(jn.prototype,"wasClean",{enumerable:!0});var Mr=class extends Zt{constructor(e,r={}){super(e),this[Ih]=r.error===void 0?null:r.error,this[Ah]=r.message===void 0?"":r.message}get error(){return this[Ih]}get message(){return this[Ah]}};Object.defineProperty(Mr.prototype,"error",{enumerable:!0});Object.defineProperty(Mr.prototype,"message",{enumerable:!0});var ji=class extends Zt{constructor(e,r={}){super(e),this[Sh]=r.data===void 0?null:r.data}get data(){return this[Sh]}};Object.defineProperty(ji.prototype,"data",{enumerable:!0});var vE={addEventListener(t,e,r={}){for(let o of this.listeners(t))if(!r[Hi]&&o[gd]===e&&!o[Hi])return;let i;if(t==="message")i=function(c,l){let u=new ji("message",{data:l?c:c.toString()});u[Nr]=this,Oo(e,this,u)};else if(t==="close")i=function(c,l){let u=new jn("close",{code:c,reason:l.toString(),wasClean:this._closeFrameReceived&&this._closeFrameSent});u[Nr]=this,Oo(e,this,u)};else if(t==="error")i=function(c){let l=new Mr("error",{error:c,message:c.message});l[Nr]=this,Oo(e,this,l)};else if(t==="open")i=function(){let c=new Zt("open");c[Nr]=this,Oo(e,this,c)};else return;i[Hi]=!!r[Hi],i[gd]=e,r.once?this.once(t,i):this.on(t,i)},removeEventListener(t,e){for(let r of this.listeners(t))if(r[gd]===e&&!r[Hi]){this.removeListener(t,r);break}}};Dh.exports={CloseEvent:jn,ErrorEvent:Mr,Event:Zt,EventTarget:vE,MessageEvent:ji};function Oo(t,e,r){typeof t=="object"&&t.handleEvent?t.handleEvent.call(t,r):t.call(e,r)}});var No=ae((pR,Ph)=>{"use strict";var{tokenChars:Wi}=Pr();function zt(t,e,r){t[e]===void 0?t[e]=[r]:t[e].push(r)}function SE(t){let e=Object.create(null),r=Object.create(null),i=!1,o=!1,c=!1,l,u,h=-1,x=-1,w=-1,E=0;for(;E<t.length;E++)if(x=t.charCodeAt(E),l===void 0)if(w===-1&&Wi[x]===1)h===-1&&(h=E);else if(E!==0&&(x===32||x===9))w===-1&&h!==-1&&(w=E);else if(x===59||x===44){if(h===-1)throw new SyntaxError(`Unexpected character at index ${E}`);w===-1&&(w=E);let b=t.slice(h,w);x===44?(zt(e,b,r),r=Object.create(null)):l=b,h=w=-1}else throw new SyntaxError(`Unexpected character at index ${E}`);else if(u===void 0)if(w===-1&&Wi[x]===1)h===-1&&(h=E);else if(x===32||x===9)w===-1&&h!==-1&&(w=E);else if(x===59||x===44){if(h===-1)throw new SyntaxError(`Unexpected character at index ${E}`);w===-1&&(w=E),zt(r,t.slice(h,w),!0),x===44&&(zt(e,l,r),r=Object.create(null),l=void 0),h=w=-1}else if(x===61&&h!==-1&&w===-1)u=t.slice(h,E),h=w=-1;else throw new SyntaxError(`Unexpected character at index ${E}`);else if(o){if(Wi[x]!==1)throw new SyntaxError(`Unexpected character at index ${E}`);h===-1?h=E:i||(i=!0),o=!1}else if(c)if(Wi[x]===1)h===-1&&(h=E);else if(x===34&&h!==-1)c=!1,w=E;else if(x===92)o=!0;else throw new SyntaxError(`Unexpected character at index ${E}`);else if(x===34&&t.charCodeAt(E-1)===61)c=!0;else if(w===-1&&Wi[x]===1)h===-1&&(h=E);else if(h!==-1&&(x===32||x===9))w===-1&&(w=E);else if(x===59||x===44){if(h===-1)throw new SyntaxError(`Unexpected character at index ${E}`);w===-1&&(w=E);let b=t.slice(h,w);i&&(b=b.replace(/\\/g,""),i=!1),zt(r,u,b),x===44&&(zt(e,l,r),r=Object.create(null),l=void 0),u=void 0,h=w=-1}else throw new SyntaxError(`Unexpected character at index ${E}`);if(h===-1||c||x===32||x===9)throw new SyntaxError("Unexpected end of input");w===-1&&(w=E);let I=t.slice(h,w);return l===void 0?zt(e,I,r):(u===void 0?zt(r,I,!0):i?zt(r,u,I.replace(/\\/g,"")):zt(r,u,I),zt(e,l,r)),e}function IE(t){return Object.keys(t).map(e=>{let r=t[e];return Array.isArray(r)||(r=[r]),r.map(i=>[e].concat(Object.keys(i).map(o=>{let c=i[o];return Array.isArray(c)||(c=[c]),c.map(l=>l===!0?o:`${o}=${l}`).join("; ")})).join("; ")).join(", ")}).join(", ")}Ph.exports={format:IE,parse:SE}});var Fo=ae((wR,jh)=>{"use strict";var AE=ue("events"),TE=ue("https"),RE=ue("http"),Nh=ue("net"),CE=ue("tls"),{randomBytes:DE,createHash:kE}=ue("crypto"),{Duplex:gR,Readable:mR}=ue("stream"),{URL:md}=ue("url"),vn=kr(),PE=fd(),LE=pd(),{isBlob:OE}=Pr(),{BINARY_TYPES:Lh,CLOSE_TIMEOUT:NE,EMPTY_BUFFER:Mo,GUID:ME,kForOnEventAttribute:wd,kListener:BE,kStatusCode:zE,kWebSocket:qe,NOOP:Mh}=$t(),{EventTarget:{addEventListener:FE,removeEventListener:UE}}=kh(),{format:GE,parse:qE}=No(),{toBuffer:HE}=Gi(),Bh=Symbol("kAborted"),_d=[8,13],Jt=["CONNECTING","OPEN","CLOSING","CLOSED"],jE=/^[!#$%&'*+\-.0-9A-Z^_`|a-z~]+$/,me=class t extends AE{constructor(e,r,i){super(),this._binaryType=Lh[0],this._closeCode=1006,this._closeFrameReceived=!1,this._closeFrameSent=!1,this._closeMessage=Mo,this._closeTimer=null,this._errorEmitted=!1,this._extensions={},this._paused=!1,this._protocol="",this._readyState=t.CONNECTING,this._receiver=null,this._sender=null,this._socket=null,e!==null?(this._bufferedAmount=0,this._isServer=!1,this._redirects=0,r===void 0?r=[]:Array.isArray(r)||(typeof r=="object"&&r!==null?(i=r,r=[]):r=[r]),zh(this,e,r,i)):(this._autoPong=i.autoPong,this._closeTimeout=i.closeTimeout,this._isServer=!0)}get binaryType(){return this._binaryType}set binaryType(e){Lh.includes(e)&&(this._binaryType=e,this._receiver&&(this._receiver._binaryType=e))}get bufferedAmount(){return this._socket?this._socket._writableState.length+this._sender._bufferedBytes:this._bufferedAmount}get extensions(){return Object.keys(this._extensions).join()}get isPaused(){return this._paused}get onclose(){return null}get onerror(){return null}get onopen(){return null}get onmessage(){return null}get protocol(){return this._protocol}get readyState(){return this._readyState}get url(){return this._url}setSocket(e,r,i){let o=new PE({allowSynchronousEvents:i.allowSynchronousEvents,binaryType:this.binaryType,extensions:this._extensions,isServer:this._isServer,maxPayload:i.maxPayload,skipUTF8Validation:i.skipUTF8Validation}),c=new LE(e,this._extensions,i.generateMask);this._receiver=o,this._sender=c,this._socket=e,o[qe]=this,c[qe]=this,e[qe]=this,o.on("conclude",$E),o.on("drain",VE),o.on("error",ZE),o.on("message",JE),o.on("ping",YE),o.on("pong",XE),c.onerror=QE,e.setTimeout&&e.setTimeout(0),e.setNoDelay&&e.setNoDelay(),r.length>0&&e.unshift(r),e.on("close",Gh),e.on("data",zo),e.on("end",qh),e.on("error",Hh),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[vn.extensionName]&&this._extensions[vn.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){ct(this,this._req,"WebSocket was closed before the connection was established");return}if(this.readyState===t.CLOSING){this._closeFrameSent&&(this._closeFrameReceived||this._receiver._writableState.errorEmitted)&&this._socket.end();return}this._readyState=t.CLOSING,this._sender.close(e,r,!this._isServer,i=>{i||(this._closeFrameSent=!0,(this._closeFrameReceived||this._receiver._writableState.errorEmitted)&&this._socket.end())}),Uh(this)}}pause(){this.readyState===t.CONNECTING||this.readyState===t.CLOSED||(this._paused=!0,this._socket.pause())}ping(e,r,i){if(this.readyState===t.CONNECTING)throw new Error("WebSocket is not open: readyState 0 (CONNECTING)");if(typeof e=="function"?(i=e,e=r=void 0):typeof r=="function"&&(i=r,r=void 0),typeof e=="number"&&(e=e.toString()),this.readyState!==t.OPEN){yd(this,e,i);return}r===void 0&&(r=!this._isServer),this._sender.ping(e||Mo,r,i)}pong(e,r,i){if(this.readyState===t.CONNECTING)throw new Error("WebSocket is not open: readyState 0 (CONNECTING)");if(typeof e=="function"?(i=e,e=r=void 0):typeof r=="function"&&(i=r,r=void 0),typeof e=="number"&&(e=e.toString()),this.readyState!==t.OPEN){yd(this,e,i);return}r===void 0&&(r=!this._isServer),this._sender.pong(e||Mo,r,i)}resume(){this.readyState===t.CONNECTING||this.readyState===t.CLOSED||(this._paused=!1,this._receiver._writableState.needDrain||this._socket.resume())}send(e,r,i){if(this.readyState===t.CONNECTING)throw new Error("WebSocket is not open: readyState 0 (CONNECTING)");if(typeof r=="function"&&(i=r,r={}),typeof e=="number"&&(e=e.toString()),this.readyState!==t.OPEN){yd(this,e,i);return}let o={binary:typeof e!="string",mask:!this._isServer,compress:!0,fin:!0,...r};this._extensions[vn.extensionName]||(o.compress=!1),this._sender.send(e||Mo,o,i)}terminate(){if(this.readyState!==t.CLOSED){if(this.readyState===t.CONNECTING){ct(this,this._req,"WebSocket was closed before the connection was established");return}this._socket&&(this._readyState=t.CLOSING,this._socket.destroy())}}};Object.defineProperty(me,"CONNECTING",{enumerable:!0,value:Jt.indexOf("CONNECTING")});Object.defineProperty(me.prototype,"CONNECTING",{enumerable:!0,value:Jt.indexOf("CONNECTING")});Object.defineProperty(me,"OPEN",{enumerable:!0,value:Jt.indexOf("OPEN")});Object.defineProperty(me.prototype,"OPEN",{enumerable:!0,value:Jt.indexOf("OPEN")});Object.defineProperty(me,"CLOSING",{enumerable:!0,value:Jt.indexOf("CLOSING")});Object.defineProperty(me.prototype,"CLOSING",{enumerable:!0,value:Jt.indexOf("CLOSING")});Object.defineProperty(me,"CLOSED",{enumerable:!0,value:Jt.indexOf("CLOSED")});Object.defineProperty(me.prototype,"CLOSED",{enumerable:!0,value:Jt.indexOf("CLOSED")});["binaryType","bufferedAmount","extensions","isPaused","protocol","readyState","url"].forEach(t=>{Object.defineProperty(me.prototype,t,{enumerable:!0})});["open","error","close","message"].forEach(t=>{Object.defineProperty(me.prototype,`on${t}`,{enumerable:!0,get(){for(let e of this.listeners(t))if(e[wd])return e[BE];return null},set(e){for(let r of this.listeners(t))if(r[wd]){this.removeListener(t,r);break}typeof e=="function"&&this.addEventListener(t,e,{[wd]:!0})}})});me.prototype.addEventListener=FE;me.prototype.removeEventListener=UE;jh.exports=me;function zh(t,e,r,i){let o={allowSynchronousEvents:!0,autoPong:!0,closeTimeout:NE,protocolVersion:_d[1],maxPayload:104857600,skipUTF8Validation:!1,perMessageDeflate:!0,followRedirects:!1,maxRedirects:10,...i,socketPath:void 0,hostname:void 0,protocol:void 0,timeout:void 0,method:"GET",host:void 0,path:void 0,port:void 0};if(t._autoPong=o.autoPong,t._closeTimeout=o.closeTimeout,!_d.includes(o.protocolVersion))throw new RangeError(`Unsupported protocol version: ${o.protocolVersion} (supported versions: ${_d.join(", ")})`);let c;if(e instanceof md)c=e;else try{c=new md(e)}catch{throw new SyntaxError(`Invalid URL: ${e}`)}c.protocol==="http:"?c.protocol="ws:":c.protocol==="https:"&&(c.protocol="wss:"),t._url=c.href;let l=c.protocol==="wss:",u=c.protocol==="ws+unix:",h;if(c.protocol!=="ws:"&&!l&&!u?h=`The URL's protocol must be one of "ws:", "wss:", "http:", "https:", or "ws+unix:"`:u&&!c.pathname?h="The URL's pathname is empty":c.hash&&(h="The URL contains a fragment identifier"),h){let A=new SyntaxError(h);if(t._redirects===0)throw A;Bo(t,A);return}let x=l?443:80,w=DE(16).toString("base64"),E=l?TE.request:RE.request,I=new Set,b;if(o.createConnection=o.createConnection||(l?KE:WE),o.defaultPort=o.defaultPort||x,o.port=c.port||x,o.host=c.hostname.startsWith("[")?c.hostname.slice(1,-1):c.hostname,o.headers={...o.headers,"Sec-WebSocket-Version":o.protocolVersion,"Sec-WebSocket-Key":w,Connection:"Upgrade",Upgrade:"websocket"},o.path=c.pathname+c.search,o.timeout=o.handshakeTimeout,o.perMessageDeflate&&(b=new vn({...o.perMessageDeflate,isServer:!1,maxPayload:o.maxPayload}),o.headers["Sec-WebSocket-Extensions"]=GE({[vn.extensionName]:b.offer()})),r.length){for(let A of r){if(typeof A!="string"||!jE.test(A)||I.has(A))throw new SyntaxError("An invalid or duplicated subprotocol was specified");I.add(A)}o.headers["Sec-WebSocket-Protocol"]=r.join(",")}if(o.origin&&(o.protocolVersion<13?o.headers["Sec-WebSocket-Origin"]=o.origin:o.headers.Origin=o.origin),(c.username||c.password)&&(o.auth=`${c.username}:${c.password}`),u){let A=o.path.split(":");o.socketPath=A[0],o.path=A[1]}let v;if(o.followRedirects){if(t._redirects===0){t._originalIpc=u,t._originalSecure=l,t._originalHostOrSocketPath=u?o.socketPath:c.host;let A=i&&i.headers;if(i={...i,headers:{}},A)for(let[S,R]of Object.entries(A))i.headers[S.toLowerCase()]=R}else if(t.listenerCount("redirect")===0){let A=u?t._originalIpc?o.socketPath===t._originalHostOrSocketPath:!1:t._originalIpc?!1:c.host===t._originalHostOrSocketPath;(!A||t._originalSecure&&!l)&&(delete o.headers.authorization,delete o.headers.cookie,A||delete o.headers.host,o.auth=void 0)}o.auth&&!i.headers.authorization&&(i.headers.authorization="Basic "+Buffer.from(o.auth).toString("base64")),v=t._req=E(o),t._redirects&&t.emit("redirect",t.url,v)}else v=t._req=E(o);o.timeout&&v.on("timeout",()=>{ct(t,v,"Opening handshake has timed out")}),v.on("error",A=>{v===null||v[Bh]||(v=t._req=null,Bo(t,A))}),v.on("response",A=>{let S=A.headers.location,R=A.statusCode;if(S&&o.followRedirects&&R>=300&&R<400){if(++t._redirects>o.maxRedirects){ct(t,v,"Maximum redirects exceeded");return}v.abort();let O;try{O=new md(S,e)}catch{let C=new SyntaxError(`Invalid URL: ${S}`);Bo(t,C);return}zh(t,O,r,i)}else t.emit("unexpected-response",v,A)||ct(t,v,`Unexpected server response: ${A.statusCode}`)}),v.on("upgrade",(A,S,R)=>{if(t.emit("upgrade",A),t.readyState!==me.CONNECTING)return;v=t._req=null;let O=A.headers.upgrade;if(O===void 0||O.toLowerCase()!=="websocket"){ct(t,S,"Invalid Upgrade header");return}let _=kE("sha1").update(w+ME).digest("base64");if(A.headers["sec-websocket-accept"]!==_){ct(t,S,"Invalid Sec-WebSocket-Accept header");return}let C=A.headers["sec-websocket-protocol"],D;if(C!==void 0?I.size?I.has(C)||(D="Server sent an invalid subprotocol"):D="Server sent a subprotocol but none was requested":I.size&&(D="Server sent no subprotocol"),D){ct(t,S,D);return}C&&(t._protocol=C);let M=A.headers["sec-websocket-extensions"];if(M!==void 0){if(!b){ct(t,S,"Server sent a Sec-WebSocket-Extensions header but no extension was requested");return}let B;try{B=qE(M)}catch{ct(t,S,"Invalid Sec-WebSocket-Extensions header");return}let V=Object.keys(B);if(V.length!==1||V[0]!==vn.extensionName){ct(t,S,"Server indicated an extension that was not requested");return}try{b.accept(B[vn.extensionName])}catch{ct(t,S,"Invalid Sec-WebSocket-Extensions header");return}t._extensions[vn.extensionName]=b}t.setSocket(S,R,{allowSynchronousEvents:o.allowSynchronousEvents,generateMask:o.generateMask,maxPayload:o.maxPayload,skipUTF8Validation:o.skipUTF8Validation})}),o.finishRequest?o.finishRequest(v,t):v.end()}function Bo(t,e){t._readyState=me.CLOSING,t._errorEmitted=!0,t.emit("error",e),t.emitClose()}function WE(t){return t.path=t.socketPath,Nh.connect(t)}function KE(t){return t.path=void 0,!t.servername&&t.servername!==""&&(t.servername=Nh.isIP(t.host)?"":t.host),CE.connect(t)}function ct(t,e,r){t._readyState=me.CLOSING;let i=new Error(r);Error.captureStackTrace(i,ct),e.setHeader?(e[Bh]=!0,e.abort(),e.socket&&!e.socket.destroyed&&e.socket.destroy(),process.nextTick(Bo,t,i)):(e.destroy(i),e.once("error",t.emit.bind(t,"error")),e.once("close",t.emitClose.bind(t)))}function yd(t,e,r){if(e){let i=OE(e)?e.size:HE(e).length;t._socket?t._sender._bufferedBytes+=i:t._bufferedAmount+=i}if(r){let i=new Error(`WebSocket is not open: readyState ${t.readyState} (${Jt[t.readyState]})`);process.nextTick(r,i)}}function $E(t,e){let r=this[qe];r._closeFrameReceived=!0,r._closeMessage=e,r._closeCode=t,r._socket[qe]!==void 0&&(r._socket.removeListener("data",zo),process.nextTick(Fh,r._socket),t===1005?r.close():r.close(t,e))}function VE(){let t=this[qe];t.isPaused||t._socket.resume()}function ZE(t){let e=this[qe];e._socket[qe]!==void 0&&(e._socket.removeListener("data",zo),process.nextTick(Fh,e._socket),e.close(t[zE])),e._errorEmitted||(e._errorEmitted=!0,e.emit("error",t))}function Oh(){this[qe].emitClose()}function JE(t,e){this[qe].emit("message",t,e)}function YE(t){let e=this[qe];e._autoPong&&e.pong(t,!this._isServer,Mh),e.emit("ping",t)}function XE(t){this[qe].emit("pong",t)}function Fh(t){t.resume()}function QE(t){let e=this[qe];e.readyState!==me.CLOSED&&(e.readyState===me.OPEN&&(e._readyState=me.CLOSING,Uh(e)),this._socket.end(),e._errorEmitted||(e._errorEmitted=!0,e.emit("error",t)))}function Uh(t){t._closeTimer=setTimeout(t._socket.destroy.bind(t._socket),t._closeTimeout)}function Gh(){let t=this[qe];if(this.removeListener("close",Gh),this.removeListener("data",zo),this.removeListener("end",qh),t._readyState=me.CLOSING,!this._readableState.endEmitted&&!t._closeFrameReceived&&!t._receiver._writableState.errorEmitted&&this._readableState.length!==0){let e=this.read(this._readableState.length);t._receiver.write(e)}t._receiver.end(),this[qe]=void 0,clearTimeout(t._closeTimer),t._receiver._writableState.finished||t._receiver._writableState.errorEmitted?t.emitClose():(t._receiver.on("error",Oh),t._receiver.on("finish",Oh))}function zo(t){this[qe]._receiver.write(t)||this.pause()}function qh(){let t=this[qe];t._readyState=me.CLOSING,t._receiver.end(),this.end()}function Hh(){let t=this[qe];this.removeListener("error",Hh),this.on("error",Mh),t&&(t._readyState=me.CLOSING,this.destroy())}});var Vh=ae((yR,$h)=>{"use strict";var _R=Fo(),{Duplex:ev}=ue("stream");function Wh(t){t.emit("close")}function tv(){!this.destroyed&&this._writableState.finished&&this.destroy()}function Kh(t){this.removeListener("error",Kh),this.destroy(),this.listenerCount("error")===0&&this.emit("error",t)}function nv(t,e){let r=!0,i=new ev({...e,autoDestroy:!1,emitClose:!1,objectMode:!1,writableObjectMode:!1});return t.on("message",function(c,l){let u=!l&&i._readableState.objectMode?c.toString():c;i.push(u)||t.pause()}),t.once("error",function(c){i.destroyed||(r=!1,i.destroy(c))}),t.once("close",function(){i.destroyed||i.push(null)}),i._destroy=function(o,c){if(t.readyState===t.CLOSED){c(o),process.nextTick(Wh,i);return}let l=!1;t.once("error",function(h){l=!0,c(h)}),t.once("close",function(){l||c(o),process.nextTick(Wh,i)}),r&&t.terminate()},i._final=function(o){if(t.readyState===t.CONNECTING){t.once("open",function(){i._final(o)});return}t._socket!==null&&(t._socket._writableState.finished?(o(),i._readableState.endEmitted&&i.destroy()):(t._socket.once("finish",function(){o()}),t.close()))},i._read=function(){t.isPaused&&t.resume()},i._write=function(o,c,l){if(t.readyState===t.CONNECTING){t.once("open",function(){i._write(o,c,l)});return}t.send(o,l)},i.on("end",tv),i.on("error",Kh),i}$h.exports=nv});var bd=ae((bR,Zh)=>{"use strict";var{tokenChars:rv}=Pr();function iv(t){let e=new Set,r=-1,i=-1,o=0;for(o;o<t.length;o++){let l=t.charCodeAt(o);if(i===-1&&rv[l]===1)r===-1&&(r=o);else if(o!==0&&(l===32||l===9))i===-1&&r!==-1&&(i=o);else if(l===44){if(r===-1)throw new SyntaxError(`Unexpected character at index ${o}`);i===-1&&(i=o);let u=t.slice(r,i);if(e.has(u))throw new SyntaxError(`The "${u}" subprotocol is duplicated`);e.add(u),r=i=-1}else throw new SyntaxError(`Unexpected character at index ${o}`)}if(r===-1||i!==-1)throw new SyntaxError("Unexpected end of input");let c=t.slice(r,o);if(e.has(c))throw new SyntaxError(`The "${c}" subprotocol is duplicated`);return e.add(c),e}Zh.exports={parse:iv}});var nx=ae((vR,tx)=>{"use strict";var sv=ue("events"),Uo=ue("http"),{Duplex:ER}=ue("stream"),{createHash:ov}=ue("crypto"),Jh=No(),Wn=kr(),av=bd(),cv=Fo(),{CLOSE_TIMEOUT:dv,GUID:lv,kWebSocket:uv}=$t(),fv=/^[+/0-9A-Za-z]{22}==$/,Yh=0,Xh=1,ex=2,Ed=class extends sv{constructor(e,r){if(super(),e={allowSynchronousEvents:!0,autoPong:!0,maxPayload:100*1024*1024,skipUTF8Validation:!1,perMessageDeflate:!1,handleProtocols:null,clientTracking:!0,closeTimeout:dv,verifyClient:null,noServer:!1,backlog:null,server:null,host:null,path:null,port:null,WebSocket:cv,...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=Uo.createServer((i,o)=>{let c=Uo.STATUS_CODES[426];o.writeHead(426,{"Content-Length":c.length,"Content-Type":"text/plain"}),o.end(c)}),this._server.listen(e.port,e.host,e.backlog,r)):e.server&&(this._server=e.server),this._server){let i=this.emit.bind(this,"connection");this._removeListeners=hv(this._server,{listening:this.emit.bind(this,"listening"),error:this.emit.bind(this,"error"),upgrade:(o,c,l)=>{this.handleUpgrade(o,c,l,i)}})}e.perMessageDeflate===!0&&(e.perMessageDeflate={}),e.clientTracking&&(this.clients=new Set,this._shouldEmitClose=!1),this.options=e,this._state=Yh}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===ex){e&&this.once("close",()=>{e(new Error("The server is not running"))}),process.nextTick(Ki,this);return}if(e&&this.once("close",e),this._state!==Xh)if(this._state=Xh,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(Ki,this):process.nextTick(Ki,this);else{let r=this._server;this._removeListeners(),this._removeListeners=this._server=null,r.close(()=>{Ki(this)})}}shouldHandle(e){if(this.options.path){let r=e.url.indexOf("?");if((r!==-1?e.url.slice(0,r):e.url)!==this.options.path)return!1}return!0}handleUpgrade(e,r,i,o){r.on("error",Qh);let c=e.headers["sec-websocket-key"],l=e.headers.upgrade,u=+e.headers["sec-websocket-version"];if(e.method!=="GET"){Kn(this,e,r,405,"Invalid HTTP method");return}if(l===void 0||l.toLowerCase()!=="websocket"){Kn(this,e,r,400,"Invalid Upgrade header");return}if(c===void 0||!fv.test(c)){Kn(this,e,r,400,"Missing or invalid Sec-WebSocket-Key header");return}if(u!==13&&u!==8){Kn(this,e,r,400,"Missing or invalid Sec-WebSocket-Version header",{"Sec-WebSocket-Version":"13, 8"});return}if(!this.shouldHandle(e)){$i(r,400);return}let h=e.headers["sec-websocket-protocol"],x=new Set;if(h!==void 0)try{x=av.parse(h)}catch{Kn(this,e,r,400,"Invalid Sec-WebSocket-Protocol header");return}let w=e.headers["sec-websocket-extensions"],E={};if(this.options.perMessageDeflate&&w!==void 0){let I=new Wn({...this.options.perMessageDeflate,isServer:!0,maxPayload:this.options.maxPayload});try{let b=Jh.parse(w);b[Wn.extensionName]&&(I.accept(b[Wn.extensionName]),E[Wn.extensionName]=I)}catch{Kn(this,e,r,400,"Invalid or unacceptable Sec-WebSocket-Extensions header");return}}if(this.options.verifyClient){let I={origin:e.headers[`${u===8?"sec-websocket-origin":"origin"}`],secure:!!(e.socket.authorized||e.socket.encrypted),req:e};if(this.options.verifyClient.length===2){this.options.verifyClient(I,(b,v,A,S)=>{if(!b)return $i(r,v||401,A,S);this.completeUpgrade(E,c,x,e,r,i,o)});return}if(!this.options.verifyClient(I))return $i(r,401)}this.completeUpgrade(E,c,x,e,r,i,o)}completeUpgrade(e,r,i,o,c,l,u){if(!c.readable||!c.writable)return c.destroy();if(c[uv])throw new Error("server.handleUpgrade() was called more than once with the same socket, possibly due to a misconfiguration");if(this._state>Yh)return $i(c,503);let x=["HTTP/1.1 101 Switching Protocols","Upgrade: websocket","Connection: Upgrade",`Sec-WebSocket-Accept: ${ov("sha1").update(r+lv).digest("base64")}`],w=new this.options.WebSocket(null,void 0,this.options);if(i.size){let E=this.options.handleProtocols?this.options.handleProtocols(i,o):i.values().next().value;E&&(x.push(`Sec-WebSocket-Protocol: ${E}`),w._protocol=E)}if(e[Wn.extensionName]){let E=e[Wn.extensionName].params,I=Jh.format({[Wn.extensionName]:[E]});x.push(`Sec-WebSocket-Extensions: ${I}`),w._extensions=e}this.emit("headers",x,o),c.write(x.concat(`\r
|
|
15
15
|
`).join(`\r
|
|
16
|
-
`)),c.removeListener("error",
|
|
16
|
+
`)),c.removeListener("error",Qh),w.setSocket(c,l,{allowSynchronousEvents:this.options.allowSynchronousEvents,maxPayload:this.options.maxPayload,skipUTF8Validation:this.options.skipUTF8Validation}),this.clients&&(this.clients.add(w),w.on("close",()=>{this.clients.delete(w),this._shouldEmitClose&&!this.clients.size&&process.nextTick(Ki,this)})),u(w,o)}};tx.exports=Ed;function hv(t,e){for(let r of Object.keys(e))t.on(r,e[r]);return function(){for(let i of Object.keys(e))t.removeListener(i,e[i])}}function Ki(t){t._state=ex,t.emit("close")}function Qh(){this.destroy()}function $i(t,e,r,i){r=r||Uo.STATUS_CODES[e],i={Connection:"close","Content-Type":"text/html","Content-Length":Buffer.byteLength(r),...i},t.once("finish",t.destroy),t.end(`HTTP/1.1 ${e} ${Uo.STATUS_CODES[e]}\r
|
|
17
17
|
`+Object.keys(i).map(o=>`${o}: ${i[o]}`).join(`\r
|
|
18
18
|
`)+`\r
|
|
19
19
|
\r
|
|
20
|
-
`+r)}function Kn(t,e,r,i,o,c){if(t.listenerCount("wsClientError")){let l=new Error(o);Error.captureStackTrace(l,Kn),t.emit("wsClientError",l,r,e)}else
|
|
20
|
+
`+r)}function Kn(t,e,r,i,o,c){if(t.listenerCount("wsClientError")){let l=new Error(o);Error.captureStackTrace(l,Kn),t.emit("wsClientError",l,r,e)}else $i(r,i,o,c)}});import{existsSync as Bv,openSync as zv}from"node:fs";import{mkdir as Fv}from"node:fs/promises";import{dirname as Uv}from"node:path";import{fileURLToPath as Gv}from"node:url";function Hv(t,e){return e==="legacy"?t.logFile:t.daemonStdioLog}function Ad(t=Y()){return Bv(t.libEntry)?t.libEntry:Gv(new URL("../index.ts",import.meta.url))}async function gx(t={}){let e=t.paths??Y(),r=t.entryOverride??Ad(e),i=Hv(e,process.env.COZE_BRIDGE_LOG_MODE);await Fv(Uv(i),{recursive:!0});let o=zv(i,"a"),l=r.endsWith(".ts")?["--import","tsx/esm",r,"--daemon"]:[r,"--daemon"],u=nt(process.execPath,l,{detached:!0,stdio:["ignore",o,o],env:{...process.env,[Ji]:"1"}});if(u.unref(),typeof u.pid!="number")throw new Error("failed to spawn daemon (no pid)");return qv.info("daemon spawned",{pid:u.pid,entry:r}),{pid:u.pid,entry:r}}var qv,Ji,Wo=Je(()=>{"use strict";Kt();ne();Le();qv=G("spawn-daemon"),Ji="COZE_BRIDGE_DAEMON"});import{spawn as k1}from"node:child_process";import{mkdir as P1,unlink as L1,writeFile as O1}from"node:fs/promises";import{dirname as N1,join as M1}from"node:path";function Ur(t){return t.replace(/&/g,"&").replace(/</g,"<").replace(/>/g,">").replace(/"/g,""")}function B1(t){if(!t)return"";let e=Object.entries(t).map(([r,i])=>` <key>${Ur(r)}</key>
|
|
21
21
|
<string>${Ur(i)}</string>`).join(`
|
|
22
22
|
`);return e?`
|
|
23
23
|
<key>EnvironmentVariables</key>
|
|
24
24
|
<dict>
|
|
25
25
|
${e}
|
|
26
|
-
</dict>`:""}function
|
|
26
|
+
</dict>`:""}function z1(t,e){return new Promise((r,i)=>{let o=k1(t,e,{stdio:["ignore","pipe","pipe"]}),c="";o.stderr?.on("data",l=>{c+=l.toString("utf8")}),o.on("error",i),o.on("close",l=>{l===0?r():i(new Error(`${t} ${e.join(" ")} exited ${l}: ${c.trim()}`))})})}var Fr,Xi,Xo,Ld,Ox=Je(()=>{"use strict";ne();Fr=G("supervisor.launchd"),Xi="ai.coze.bridge",Xo=z1,Ld={platform:"darwin",renderConfig(t){return`<?xml version="1.0" encoding="UTF-8"?>
|
|
27
27
|
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
|
|
28
28
|
<plist version="1.0">
|
|
29
29
|
<dict>
|
|
30
30
|
<key>Label</key>
|
|
31
|
-
<string>${
|
|
31
|
+
<string>${Xi}</string>
|
|
32
32
|
<key>ProgramArguments</key>
|
|
33
33
|
<array>
|
|
34
34
|
<string>${Ur(t.nodeBin)}</string>
|
|
@@ -44,11 +44,11 @@ ${e}
|
|
|
44
44
|
<key>StandardOutPath</key>
|
|
45
45
|
<string>${Ur(t.logFile)}</string>
|
|
46
46
|
<key>StandardErrorPath</key>
|
|
47
|
-
<string>${Ur(t.logFile)}</string>${
|
|
47
|
+
<string>${Ur(t.logFile)}</string>${B1(t.env)}
|
|
48
48
|
</dict>
|
|
49
49
|
</plist>
|
|
50
|
-
`},configPath(t){return
|
|
51
|
-
`):""}function
|
|
50
|
+
`},configPath(t){return M1(t.homeDir,"Library","LaunchAgents",`${Xi}.plist`)},async install(t,e){let r=e?.activate!==!1,i=this.configPath(t);if(await P1(N1(i),{recursive:!0}),await O1(i,this.renderConfig(t),"utf8"),Fr.info("plist written",{plistPath:i,activate:r}),!r)return;await Xo("launchctl",["unload","-w",i]).catch(c=>Fr.info("launchctl unload before load (ignored, likely not loaded yet)",{err:String(c)})),await Xo("launchctl",["load","-w",i]),Fr.info("launchd job loaded",{label:Xi});let o=process.getuid?.()??0;await Xo("launchctl",["kickstart","-k",`gui/${o}/${Xi}`]),Fr.info("launchd job kickstarted",{label:Xi,uid:o})},async uninstall(t){let e=this.configPath(t);await Xo("launchctl",["unload","-w",e]).catch(r=>Fr.warn("launchctl unload failed (ignored)",{err:String(r)})),await L1(e).catch(r=>{if(r.code!=="ENOENT")throw r}),Fr.info("launchd job removed",{plistPath:e})}}});import{spawn as F1}from"node:child_process";import{mkdir as U1,unlink as G1,writeFile as q1}from"node:fs/promises";import{dirname as H1,join as Nx}from"node:path";function ea(t,e){return t.isRoot?e:["--user",...e]}function W1(t){return t?Object.entries(t).map(([e,r])=>{let i=r.replace(/\\/g,"\\\\").replace(/"/g,'\\"');return`Environment="${e}=${i}"`}).join(`
|
|
51
|
+
`):""}function ta(t,e){return new Promise((r,i)=>{let o=F1(t,e,{stdio:["ignore","pipe","pipe"]}),c="";o.stderr?.on("data",l=>{c+=l.toString("utf8")}),o.on("error",i),o.on("close",l=>{l===0?r():i(new Error(`${t} ${e.join(" ")} exited ${l}: ${c.trim()}`))})})}var Qo,Gr,j1,Od,Mx=Je(()=>{"use strict";ne();Qo=G("supervisor.systemd"),Gr="coze-bridge.service",j1="/etc/systemd/system";Od={platform:"linux",renderConfig(t){let e=t.isRoot?"multi-user.target":"default.target";return`[Unit]
|
|
52
52
|
Description=Coze Bridge daemon
|
|
53
53
|
After=network.target
|
|
54
54
|
|
|
@@ -59,10 +59,10 @@ Restart=always
|
|
|
59
59
|
RestartSec=3
|
|
60
60
|
StandardOutput=append:${t.logFile}
|
|
61
61
|
StandardError=append:${t.logFile}
|
|
62
|
-
${
|
|
62
|
+
${W1(t.env)}
|
|
63
63
|
[Install]
|
|
64
64
|
WantedBy=${e}
|
|
65
|
-
`},configPath(t){return t.isRoot?
|
|
65
|
+
`},configPath(t){return t.isRoot?Nx(j1,Gr):Nx(t.homeDir,".config","systemd","user",Gr)},async install(t,e){let r=e?.activate!==!1,i=this.configPath(t),o=t.isRoot?"system":"user";await U1(H1(i),{recursive:!0}),await q1(i,this.renderConfig(t),"utf8"),Qo.info("systemd unit written",{unitPath:i,mode:o,activate:r}),await ta("systemctl",ea(t,["daemon-reload"])),await ta("systemctl",ea(t,r?["enable","--now",Gr]:["enable",Gr])),Qo.info("systemd unit enabled",{unitName:Gr,mode:o,activate:r})},async uninstall(t){let e=this.configPath(t);await ta("systemctl",ea(t,["disable","--now",Gr])).catch(r=>Qo.warn("systemctl disable failed (ignored)",{err:String(r)})),await G1(e).catch(r=>{if(r.code!=="ENOENT")throw r}),await ta("systemctl",ea(t,["daemon-reload"])).catch(()=>{}),Qo.info("systemd unit removed",{unitPath:e})}}});import{spawn as K1}from"node:child_process";import{join as $1}from"node:path";function Bx(t,e){return new Promise((r,i)=>{let o=K1(t,e,{stdio:["ignore","pipe","pipe"],shell:!1}),c="";o.stderr?.on("data",l=>{c+=l.toString("utf8")}),o.on("error",i),o.on("close",l=>{l===0?r():i(new Error(`${t} ${e.join(" ")} exited ${l}: ${c.trim()}`))})})}var Nd,na,Md,zx=Je(()=>{"use strict";ne();Nd=G("supervisor.taskscheduler"),na="CozeBridge",Md={platform:"win32",renderConfig(t){return`<?xml version="1.0" encoding="UTF-16"?>
|
|
66
66
|
<Task version="1.2" xmlns="http://schemas.microsoft.com/windows/2004/02/mit/task">
|
|
67
67
|
<RegistrationInfo>
|
|
68
68
|
<Description>Coze Bridge daemon</Description>
|
|
@@ -86,43 +86,43 @@ WantedBy=${e}
|
|
|
86
86
|
</Exec>
|
|
87
87
|
</Actions>
|
|
88
88
|
</Task>
|
|
89
|
-
`},configPath(t){return HS(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 Gh("schtasks",["/Create","/SC","ONLOGON","/TN",aa,"/TR",r,"/RU",t.userName,"/F"]),Ud.info("task scheduler entry created",{task:aa,logFile:t.logFile})},async uninstall(t){await Gh("schtasks",["/Delete","/TN",aa,"/F"]).catch(e=>Ud.warn("schtasks /Delete failed (ignored)",{err:String(e)})),Ud.info("task scheduler entry removed",{task:aa})}}});var Hh={};ba(Hh,{buildContext:()=>YS,getSupervisor:()=>KS,launchdSupervisor:()=>Fd,systemdSupervisor:()=>zd,taskSchedulerSupervisor:()=>Gd});import{homedir as jS,userInfo as WS}from"node:os";function KS(t=process.platform){switch(t){case"darwin":return Fd;case"linux":return zd;case"win32":return Gd;default:throw new Error(`unsupported platform for OS supervisor: ${t}`)}}function VS(){let t={};for(let e of $S){let r=process.env[e];r&&(t[e]=r)}return t}function YS(){let t=X();return{nodeBin:process.execPath,entry:kd(t),logFile:t.logFile,homeDir:jS(),userName:WS().username,isRoot:process.getuid?.()===0,env:VS()}}var $S,jh=Ye(()=>{"use strict";ke();Jo();Fh();Uh();qh();$S=["PATH","HOME","HTTP_PROXY","HTTPS_PROXY","NO_PROXY","ALL_PROXY","http_proxy","https_proxy","no_proxy","all_proxy","NODE_EXTRA_CA_CERTS"]});ne();nn();var ml=j("acp-installer-warmup"),xg=["claude-code","codex"];async function wl(t={}){let e=t.ensure??er,i=(await Promise.allSettled(xg.map(async o=>{let c=await e(o);ml.info("acp wrapper warmup ok",{framework:o,path:c})}))).filter(o=>o.status==="rejected");i.length>0&&ml.warn("acp wrapper warmup partial failure (\u5C06\u5728\u4E0B\u6B21 createAgent \u65F6\u91CD\u8BD5\u5E76\u629B\u9519\u7ED9\u7528\u6237)",{failedCount:i.length,reasons:i.map(o=>o.reason instanceof Error?o.reason.message:String(o.reason))})}rn();ne();import{readdir as Ag}from"node:fs/promises";import{mkdir as Sl,writeFile as Al}from"node:fs/promises";import{join as Ca}from"node:path";var Sg={"claude-code":"CLAUDE.md",codex:"AGENTS.md",openclaw:"SOUL.md"};async function rr(t,e,r){await Sl(t,{recursive:!0});let i=Sg[e],o=Ca(t,i);return await Al(o,r??"","utf8"),o}async function Il(t,e){let r=Ca(t,".claude");await Sl(r,{recursive:!0});let i=Ca(r,"settings.local.json"),o={permissions:{defaultMode:"bypassPermissions"}};e==="cloud"&&(o.autoCompactWindow=15e4);let c=JSON.stringify(o,null,2);return await Al(i,c,"utf8"),i}var et=j("agent-detail-sync"),Ig=6e4,Tg=5*6e4,xs=class{constructor(e){this.opts=e}opts;retryQueue=new Map;async syncAll(e){let r=this.opts.paths.agentsRoot,i;try{i=await Ag(r)}catch(o){et.info("agents dir not found, skip detail sync",{root:r,err:String(o)});return}et.info("starting detail sync",{reason:e,count:i.length}),await Promise.allSettled(i.map(async o=>{let c=await He(o,this.opts.paths).catch(()=>null);if(c){if(c.disconnectedAt){et.debug("detail sync: skip disconnected agent",{agentId:o});return}try{await this.syncOne(o,c)}catch(l){et.warn("detail sync failed for agent, skipping",{agentId:o,err:String(l)})}}})),et.info("detail sync done",{reason:e})}async retryPending(){if(this.retryQueue.size===0)return;let e=Date.now(),r=[];for(let[i,o]of this.retryQueue)e>=o.dueAt&&r.push(i);if(r.length!==0){et.info("retrying pending detail syncs",{count:r.length});for(let i of r)try{await this.syncOne(i)}catch(o){et.debug("detail sync retry still failing, will try again",{agentId:i,err:String(o)})}}}async syncOne(e,r){let i=r??await He(e,this.opts.paths);if(!i){et.info("detail sync: agent config missing, skip",{agentId:e});return}let o;try{o=await this.opts.sendDetail({_meta:{cozeAgentId:e}}),this.retryQueue.delete(e)}catch(f){et.warn("detail RPC failed, using local data",{agentId:e,err:String(f)});let x=this.retryQueue.get(e),h=x?Math.min(x.currentDelay*2,Tg):Ig;this.retryQueue.set(e,{dueAt:Date.now()+h,currentDelay:h});return}if(o.agentId&&o.agentId!==e){et.warn("detail response agentId mismatch, ignoring",{agentId:e,responseAgentId:o.agentId});return}let c=!1,l=!1;if(o.agentName&&o.agentName!==i.agentName&&(i.agentName=o.agentName,c=!0),o.description!==void 0&&o.description!==i.description&&(i.description=o.description,c=!0),o.cozeIdentity&&o.cozeIdentity!==i.cozeIdentity&&(i.cozeIdentity=o.cozeIdentity,c=!0,l=!0),o.deployType&&et.info("detail.deployType",{agentId:e,deployType:o.deployType}),!c){et.debug("detail sync: no diff",{agentId:e});return}await Xe(i,this.opts.paths),et.info("detail sync: config updated",{agentId:e,identityChanged:l,agentName:i.agentName}),l&&(await rr(i.workspace,i.framework,i.cozeIdentity),this.opts.handlers.reloadAgentSessionsPublic(e,"detail-sync"))}};var H0=St(of(),1);import{lstat as Hc,mkdir as jc,readFile as z0,readdir as e_,rm as t_,stat as n_,writeFile as Wc}from"node:fs/promises";import{dirname as r_,join as kt,normalize as i_,relative as Vc,resolve as Kc,sep as U0}from"node:path";import{Readable as G0}from"node:stream";import{pipeline as q0}from"node:stream/promises";import Yg from"events";import Qe from"fs";import{EventEmitter as Tc}from"node:events";import Gf from"node:stream";import{StringDecoder as Jg}from"node:string_decoder";import jf from"node:path";import pr from"node:fs";import{dirname as dm,parse as lm}from"path";import{EventEmitter as wm}from"events";import cc from"assert";import{Buffer as Bn}from"buffer";import*as ff from"zlib";import _m from"zlib";import{posix as cr}from"node:path";import{basename as Km}from"node:path";import Ws from"fs";import Ct from"fs";import wf from"path";import{win32 as rw}from"node:path";import Af from"path";import s0 from"node:fs";import yw from"node:assert";import{randomBytes as o0}from"node:crypto";import re from"node:fs";import Pe from"node:path";import a0 from"fs";import eo from"node:fs";import yi from"node:path";import it from"node:fs";import Tw from"node:fs/promises";import Vs from"node:path";import{join as w0}from"node:path";import rt from"node:fs";import b0 from"node:path";var $g=Object.defineProperty,Vg=(t,e)=>{for(var r in e)$g(t,r,{get:e[r],enumerable:!0})},af=typeof process=="object"&&process?process:{stdout:null,stderr:null},Zg=t=>!!t&&typeof t=="object"&&(t instanceof Un||t instanceof Gf||Xg(t)||Qg(t)),Xg=t=>!!t&&typeof t=="object"&&t instanceof Tc&&typeof t.pipe=="function"&&t.pipe!==Gf.Writable.prototype.pipe,Qg=t=>!!t&&typeof t=="object"&&t instanceof Tc&&typeof t.write=="function"&&typeof t.end=="function",zt=Symbol("EOF"),Ut=Symbol("maybeEmitEnd"),on=Symbol("emittedEnd"),ws=Symbol("emittingEnd"),ri=Symbol("emittedError"),_s=Symbol("closed"),cf=Symbol("read"),ys=Symbol("flush"),df=Symbol("flushChunk"),ht=Symbol("encoding"),ar=Symbol("decoder"),Me=Symbol("flowing"),ii=Symbol("paused"),ur=Symbol("resume"),Be=Symbol("buffer"),$e=Symbol("pipes"),Fe=Symbol("bufferLength"),Na=Symbol("bufferPush"),bs=Symbol("bufferShift"),We=Symbol("objectMode"),Se=Symbol("destroyed"),La=Symbol("error"),Ma=Symbol("emitData"),lf=Symbol("emitEnd"),Ba=Symbol("emitEnd2"),At=Symbol("async"),Fa=Symbol("abort"),Es=Symbol("aborted"),si=Symbol("signal"),Cn=Symbol("dataListeners"),nt=Symbol("discarded"),oi=t=>Promise.resolve().then(t),em=t=>t(),tm=t=>t==="end"||t==="finish"||t==="prefinish",nm=t=>t instanceof ArrayBuffer||!!t&&typeof t=="object"&&t.constructor&&t.constructor.name==="ArrayBuffer"&&t.byteLength>=0,rm=t=>!Buffer.isBuffer(t)&&ArrayBuffer.isView(t),qf=class{src;dest;opts;ondrain;constructor(t,e,r){this.src=t,this.dest=e,this.opts=r,this.ondrain=()=>t[ur](),this.dest.on("drain",this.ondrain)}unpipe(){this.dest.removeListener("drain",this.ondrain)}proxyErrors(t){}end(){this.unpipe(),this.opts.end&&this.dest.end()}},im=class extends qf{unpipe(){this.src.removeListener("error",this.proxyErrors),super.unpipe()}constructor(t,e,r){super(t,e,r),this.proxyErrors=i=>this.dest.emit("error",i),t.on("error",this.proxyErrors)}},sm=t=>!!t.objectMode,om=t=>!t.objectMode&&!!t.encoding&&t.encoding!=="buffer",Un=class extends Tc{[Me]=!1;[ii]=!1;[$e]=[];[Be]=[];[We];[ht];[At];[ar];[zt]=!1;[on]=!1;[ws]=!1;[_s]=!1;[ri]=null;[Fe]=0;[Se]=!1;[si];[Es]=!1;[Cn]=0;[nt]=!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");sm(e)?(this[We]=!0,this[ht]=null):om(e)?(this[ht]=e.encoding,this[We]=!1):(this[We]=!1,this[ht]=null),this[At]=!!e.async,this[ar]=this[ht]?new Jg(this[ht]):null,e&&e.debugExposeBuffer===!0&&Object.defineProperty(this,"buffer",{get:()=>this[Be]}),e&&e.debugExposePipes===!0&&Object.defineProperty(this,"pipes",{get:()=>this[$e]});let{signal:r}=e;r&&(this[si]=r,r.aborted?this[Fa]():r.addEventListener("abort",()=>this[Fa]()))}get bufferLength(){return this[Fe]}get encoding(){return this[ht]}set encoding(t){throw new Error("Encoding must be set at instantiation time")}setEncoding(t){throw new Error("Encoding must be set at instantiation time")}get objectMode(){return this[We]}set objectMode(t){throw new Error("objectMode must be set at instantiation time")}get async(){return this[At]}set async(t){this[At]=this[At]||!!t}[Fa](){this[Es]=!0,this.emit("abort",this[si]?.reason),this.destroy(this[si]?.reason)}get aborted(){return this[Es]}set aborted(t){}write(t,e,r){if(this[Es])return!1;if(this[zt])throw new Error("write after end");if(this[Se])return this.emit("error",Object.assign(new Error("Cannot call write after a stream was destroyed"),{code:"ERR_STREAM_DESTROYED"})),!0;typeof e=="function"&&(r=e,e="utf8"),e||(e="utf8");let i=this[At]?oi:em;if(!this[We]&&!Buffer.isBuffer(t)){if(rm(t))t=Buffer.from(t.buffer,t.byteOffset,t.byteLength);else if(nm(t))t=Buffer.from(t);else if(typeof t!="string")throw new Error("Non-contiguous data written to non-objectMode stream")}return this[We]?(this[Me]&&this[Fe]!==0&&this[ys](!0),this[Me]?this.emit("data",t):this[Na](t),this[Fe]!==0&&this.emit("readable"),r&&i(r),this[Me]):t.length?(typeof t=="string"&&!(e===this[ht]&&!this[ar]?.lastNeed)&&(t=Buffer.from(t,e)),Buffer.isBuffer(t)&&this[ht]&&(t=this[ar].write(t)),this[Me]&&this[Fe]!==0&&this[ys](!0),this[Me]?this.emit("data",t):this[Na](t),this[Fe]!==0&&this.emit("readable"),r&&i(r),this[Me]):(this[Fe]!==0&&this.emit("readable"),r&&i(r),this[Me])}read(t){if(this[Se])return null;if(this[nt]=!1,this[Fe]===0||t===0||t&&t>this[Fe])return this[Ut](),null;this[We]&&(t=null),this[Be].length>1&&!this[We]&&(this[Be]=[this[ht]?this[Be].join(""):Buffer.concat(this[Be],this[Fe])]);let e=this[cf](t||null,this[Be][0]);return this[Ut](),e}[cf](t,e){if(this[We])this[bs]();else{let r=e;t===r.length||t===null?this[bs]():typeof r=="string"?(this[Be][0]=r.slice(t),e=r.slice(0,t),this[Fe]-=t):(this[Be][0]=r.subarray(t),e=r.subarray(0,t),this[Fe]-=t)}return this.emit("data",e),!this[Be].length&&!this[zt]&&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[zt]=!0,this.writable=!1,(this[Me]||!this[ii])&&this[Ut](),this}[ur](){this[Se]||(!this[Cn]&&!this[$e].length&&(this[nt]=!0),this[ii]=!1,this[Me]=!0,this.emit("resume"),this[Be].length?this[ys]():this[zt]?this[Ut]():this.emit("drain"))}resume(){return this[ur]()}pause(){this[Me]=!1,this[ii]=!0,this[nt]=!1}get destroyed(){return this[Se]}get flowing(){return this[Me]}get paused(){return this[ii]}[Na](t){this[We]?this[Fe]+=1:this[Fe]+=t.length,this[Be].push(t)}[bs](){return this[We]?this[Fe]-=1:this[Fe]-=this[Be][0].length,this[Be].shift()}[ys](t=!1){do;while(this[df](this[bs]())&&this[Be].length);!t&&!this[Be].length&&!this[zt]&&this.emit("drain")}[df](t){return this.emit("data",t),this[Me]}pipe(t,e){if(this[Se])return t;this[nt]=!1;let r=this[on];return e=e||{},t===af.stdout||t===af.stderr?e.end=!1:e.end=e.end!==!1,e.proxyErrors=!!e.proxyErrors,r?e.end&&t.end():(this[$e].push(e.proxyErrors?new im(this,t,e):new qf(this,t,e)),this[At]?oi(()=>this[ur]()):this[ur]()),t}unpipe(t){let e=this[$e].find(r=>r.dest===t);e&&(this[$e].length===1?(this[Me]&&this[Cn]===0&&(this[Me]=!1),this[$e]=[]):this[$e].splice(this[$e].indexOf(e),1),e.unpipe())}addListener(t,e){return this.on(t,e)}on(t,e){let r=super.on(t,e);if(t==="data")this[nt]=!1,this[Cn]++,!this[$e].length&&!this[Me]&&this[ur]();else if(t==="readable"&&this[Fe]!==0)super.emit("readable");else if(tm(t)&&this[on])super.emit(t),this.removeAllListeners(t);else if(t==="error"&&this[ri]){let i=e;this[At]?oi(()=>i.call(this,this[ri])):i.call(this,this[ri])}return r}removeListener(t,e){return this.off(t,e)}off(t,e){let r=super.off(t,e);return t==="data"&&(this[Cn]=this.listeners("data").length,this[Cn]===0&&!this[nt]&&!this[$e].length&&(this[Me]=!1)),r}removeAllListeners(t){let e=super.removeAllListeners(t);return(t==="data"||t===void 0)&&(this[Cn]=0,!this[nt]&&!this[$e].length&&(this[Me]=!1)),e}get emittedEnd(){return this[on]}[Ut](){!this[ws]&&!this[on]&&!this[Se]&&this[Be].length===0&&this[zt]&&(this[ws]=!0,this.emit("end"),this.emit("prefinish"),this.emit("finish"),this[_s]&&this.emit("close"),this[ws]=!1)}emit(t,...e){let r=e[0];if(t!=="error"&&t!=="close"&&t!==Se&&this[Se])return!1;if(t==="data")return!this[We]&&!r?!1:this[At]?(oi(()=>this[Ma](r)),!0):this[Ma](r);if(t==="end")return this[lf]();if(t==="close"){if(this[_s]=!0,!this[on]&&!this[Se])return!1;let o=super.emit("close");return this.removeAllListeners("close"),o}else if(t==="error"){this[ri]=r,super.emit(La,r);let o=!this[si]||this.listeners("error").length?super.emit("error",r):!1;return this[Ut](),o}else if(t==="resume"){let o=super.emit("resume");return this[Ut](),o}else if(t==="finish"||t==="prefinish"){let o=super.emit(t);return this.removeAllListeners(t),o}let i=super.emit(t,...e);return this[Ut](),i}[Ma](t){for(let r of this[$e])r.dest.write(t)===!1&&this.pause();let e=this[nt]?!1:super.emit("data",t);return this[Ut](),e}[lf](){return this[on]?!1:(this[on]=!0,this.readable=!1,this[At]?(oi(()=>this[Ba]()),!0):this[Ba]())}[Ba](){if(this[ar]){let e=this[ar].end();if(e){for(let r of this[$e])r.dest.write(e);this[nt]||super.emit("data",e)}}for(let e of this[$e])e.end();let t=super.emit("end");return this.removeAllListeners("end"),t}async collect(){let t=Object.assign([],{dataLength:0});this[We]||(t.dataLength=0);let e=this.promise();return this.on("data",r=>{t.push(r),this[We]||(t.dataLength+=r.length)}),await e,t}async concat(){if(this[We])throw new Error("cannot concat in objectMode");let t=await this.collect();return this[ht]?t.join(""):Buffer.concat(t,t.dataLength)}async promise(){return new Promise((t,e)=>{this.on(Se,()=>e(new Error("stream destroyed"))),this.on("error",r=>e(r)),this.on("end",()=>t())})}[Symbol.asyncIterator](){this[nt]=!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[zt])return e();let i,o,c=h=>{this.off("data",l),this.off("end",f),this.off(Se,x),e(),o(h)},l=h=>{this.off("error",c),this.off("end",f),this.off(Se,x),this.pause(),i({value:h,done:!!this[zt]})},f=()=>{this.off("error",c),this.off("data",l),this.off(Se,x),e(),i({done:!0,value:void 0})},x=()=>c(new Error("stream destroyed"));return new Promise((h,_)=>{o=_,i=h,this.once(Se,x),this.once("error",c),this.once("end",f),this.once("data",l)})},throw:e,return:e,[Symbol.asyncIterator](){return this},[Symbol.asyncDispose]:async()=>{}}}[Symbol.iterator](){this[nt]=!1;let t=!1,e=()=>(this.pause(),this.off(La,e),this.off(Se,e),this.off("end",e),t=!0,{done:!0,value:void 0}),r=()=>{if(t)return e();let i=this.read();return i===null?e():{done:!1,value:i}};return this.once("end",e),this.once(La,e),this.once(Se,e),{next:r,throw:e,return:e,[Symbol.iterator](){return this},[Symbol.dispose]:()=>{}}}destroy(t){if(this[Se])return t?this.emit("error",t):this.emit(Se),this;this[Se]=!0,this[nt]=!0,this[Be].length=0,this[Fe]=0;let e=this;return typeof e.close=="function"&&!this[_s]&&e.close(),t?this.emit("error",t):this.emit(Se),this}static get isStream(){return Zg}},am=Qe.writev,gn=Symbol("_autoClose"),wt=Symbol("_close"),ai=Symbol("_ended"),ce=Symbol("_fd"),za=Symbol("_finished"),jt=Symbol("_flags"),Ua=Symbol("_flush"),oc=Symbol("_handleChunk"),ac=Symbol("_makeBuf"),wi=Symbol("_mode"),vs=Symbol("_needDrain"),mr=Symbol("_onerror"),wr=Symbol("_onopen"),Ga=Symbol("_onread"),xr=Symbol("_onwrite"),mn=Symbol("_open"),mt=Symbol("_path"),fn=Symbol("_pos"),It=Symbol("_queue"),hr=Symbol("_read"),qa=Symbol("_readSize"),Ht=Symbol("_reading"),ci=Symbol("_remain"),Ha=Symbol("_size"),Ps=Symbol("_write"),Rn=Symbol("_writing"),Ns=Symbol("_defaultFlag"),Mn=Symbol("_errored"),Cc=class extends Un{[Mn]=!1;[ce];[mt];[qa];[Ht]=!1;[Ha];[ci];[gn];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[Mn]=!1,this[ce]=typeof e.fd=="number"?e.fd:void 0,this[mt]=t,this[qa]=e.readSize||16*1024*1024,this[Ht]=!1,this[Ha]=typeof e.size=="number"?e.size:1/0,this[ci]=this[Ha],this[gn]=typeof e.autoClose=="boolean"?e.autoClose:!0,typeof this[ce]=="number"?this[hr]():this[mn]()}get fd(){return this[ce]}get path(){return this[mt]}write(){throw new TypeError("this is a readable stream")}end(){throw new TypeError("this is a readable stream")}[mn](){Qe.open(this[mt],"r",(t,e)=>this[wr](t,e))}[wr](t,e){t?this[mr](t):(this[ce]=e,this.emit("open",e),this[hr]())}[ac](){return Buffer.allocUnsafe(Math.min(this[qa],this[ci]))}[hr](){if(!this[Ht]){this[Ht]=!0;let t=this[ac]();if(t.length===0)return process.nextTick(()=>this[Ga](null,0,t));Qe.read(this[ce],t,0,t.length,null,(e,r,i)=>this[Ga](e,r,i))}}[Ga](t,e,r){this[Ht]=!1,t?this[mr](t):this[oc](e,r)&&this[hr]()}[wt](){if(this[gn]&&typeof this[ce]=="number"){let t=this[ce];this[ce]=void 0,Qe.close(t,e=>e?this.emit("error",e):this.emit("close"))}}[mr](t){this[Ht]=!0,this[wt](),this.emit("error",t)}[oc](t,e){let r=!1;return this[ci]-=t,t>0&&(r=super.write(t<e.length?e.subarray(0,t):e)),(t===0||this[ci]<=0)&&(r=!1,this[wt](),super.end()),r}emit(t,...e){switch(t){case"prefinish":case"finish":return!1;case"drain":return typeof this[ce]=="number"&&this[hr](),!1;case"error":return this[Mn]?!1:(this[Mn]=!0,super.emit(t,...e));default:return super.emit(t,...e)}}},cm=class extends Cc{[mn](){let t=!0;try{this[wr](null,Qe.openSync(this[mt],"r")),t=!1}finally{t&&this[wt]()}}[hr](){let t=!0;try{if(!this[Ht]){this[Ht]=!0;do{let e=this[ac](),r=e.length===0?0:Qe.readSync(this[ce],e,0,e.length,null);if(!this[oc](r,e))break}while(!0);this[Ht]=!1}t=!1}finally{t&&this[wt]()}}[wt](){if(this[gn]&&typeof this[ce]=="number"){let t=this[ce];this[ce]=void 0,Qe.closeSync(t),this.emit("close")}}},Ys=class extends Yg{readable=!1;writable=!0;[Mn]=!1;[Rn]=!1;[ai]=!1;[It]=[];[vs]=!1;[mt];[wi];[gn];[ce];[Ns];[jt];[za]=!1;[fn];constructor(t,e){e=e||{},super(e),this[mt]=t,this[ce]=typeof e.fd=="number"?e.fd:void 0,this[wi]=e.mode===void 0?438:e.mode,this[fn]=typeof e.start=="number"?e.start:void 0,this[gn]=typeof e.autoClose=="boolean"?e.autoClose:!0;let r=this[fn]!==void 0?"r+":"w";this[Ns]=e.flags===void 0,this[jt]=e.flags===void 0?r:e.flags,this[ce]===void 0&&this[mn]()}emit(t,...e){if(t==="error"){if(this[Mn])return!1;this[Mn]=!0}return super.emit(t,...e)}get fd(){return this[ce]}get path(){return this[mt]}[mr](t){this[wt](),this[Rn]=!0,this.emit("error",t)}[mn](){Qe.open(this[mt],this[jt],this[wi],(t,e)=>this[wr](t,e))}[wr](t,e){this[Ns]&&this[jt]==="r+"&&t&&t.code==="ENOENT"?(this[jt]="w",this[mn]()):t?this[mr](t):(this[ce]=e,this.emit("open",e),this[Rn]||this[Ua]())}end(t,e){return t&&this.write(t,e),this[ai]=!0,!this[Rn]&&!this[It].length&&typeof this[ce]=="number"&&this[xr](null,0),this}write(t,e){return typeof t=="string"&&(t=Buffer.from(t,e)),this[ai]?(this.emit("error",new Error("write() after end()")),!1):this[ce]===void 0||this[Rn]||this[It].length?(this[It].push(t),this[vs]=!0,!1):(this[Rn]=!0,this[Ps](t),!0)}[Ps](t){Qe.write(this[ce],t,0,t.length,this[fn],(e,r)=>this[xr](e,r))}[xr](t,e){t?this[mr](t):(this[fn]!==void 0&&typeof e=="number"&&(this[fn]+=e),this[It].length?this[Ua]():(this[Rn]=!1,this[ai]&&!this[za]?(this[za]=!0,this[wt](),this.emit("finish")):this[vs]&&(this[vs]=!1,this.emit("drain"))))}[Ua](){if(this[It].length===0)this[ai]&&this[xr](null,0);else if(this[It].length===1)this[Ps](this[It].pop());else{let t=this[It];this[It]=[],am(this[ce],t,this[fn],(e,r)=>this[xr](e,r))}}[wt](){if(this[gn]&&typeof this[ce]=="number"){let t=this[ce];this[ce]=void 0,Qe.close(t,e=>e?this.emit("error",e):this.emit("close"))}}},Hf=class extends Ys{[mn](){let t;if(this[Ns]&&this[jt]==="r+")try{t=Qe.openSync(this[mt],this[jt],this[wi])}catch(e){if(e?.code==="ENOENT")return this[jt]="w",this[mn]();throw e}else t=Qe.openSync(this[mt],this[jt],this[wi]);this[wr](null,t)}[wt](){if(this[gn]&&typeof this[ce]=="number"){let t=this[ce];this[ce]=void 0,Qe.closeSync(t),this.emit("close")}}[Ps](t){let e=!0;try{this[xr](null,Qe.writeSync(this[ce],t,0,t.length,this[fn])),e=!1}finally{if(e)try{this[wt]()}catch{}}}},fm=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"]]),um=t=>!!t.sync&&!!t.file,xm=t=>!t.sync&&!!t.file,hm=t=>!!t.sync&&!t.file,pm=t=>!t.sync&&!t.file,gm=t=>!!t.file,mm=t=>fm.get(t)||t,Rc=(t={})=>{if(!t)return{};let e={};for(let[r,i]of Object.entries(t)){let o=mm(r);e[o]=i}return e.chmod===void 0&&e.noChmod===!1&&(e.chmod=!0),delete e.noChmod,e},Ti=(t,e,r,i,o)=>Object.assign((c=[],l,f)=>{Array.isArray(c)&&(l=c,c={}),typeof l=="function"&&(f=l,l=void 0),l=l?Array.from(l):[];let x=Rc(c);if(o?.(x,l),um(x)){if(typeof f=="function")throw new TypeError("callback not supported for sync tar functions");return t(x,l)}else if(xm(x)){let h=e(x,l);return f?h.then(()=>f(),f):h}else if(hm(x)){if(typeof f=="function")throw new TypeError("callback not supported for sync tar functions");return r(x,l)}else if(pm(x)){if(typeof f=="function")throw new TypeError("callback only supported with file option");return i(x,l)}throw new Error("impossible options??")},{syncFile:t,asyncFile:e,syncNoFile:r,asyncNoFile:i,validate:o}),ym=_m.constants||{ZLIB_VERNUM:4736},Dt=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},ym)),bm=Bn.concat,uf=Object.getOwnPropertyDescriptor(Bn,"concat"),Em=t=>t,ja=uf?.writable===!0||uf?.set!==void 0?t=>{Bn.concat=t?Em:bm}:t=>{},Fn=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"}},Wa=Symbol("flushFlag"),Dc=class extends Un{#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 ff[e]!="function")throw new TypeError("Compression method not supported: "+e);try{this.#t=new ff[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 cc(this.#t,"zlib binding closed"),this.#t.reset?.()}flush(t){this.ended||(typeof t!="number"&&(t=this.#i),this.write(Object.assign(Bn.alloc(0),{[Wa]: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}[Fn](t){return super.write(t)}write(t,e,r){if(typeof e=="function"&&(r=e,e="utf8"),typeof t=="string"&&(t=Bn.from(t,e)),this.#e)return;cc(this.#t,"zlib binding closed");let i=this.#t._handle,o=i.close;i.close=()=>{};let c=this.#t.close;this.#t.close=()=>{},ja(!0);let l;try{let x=typeof t[Wa]=="number"?t[Wa]:this.#r;l=this.#t._processChunk(t,x),ja(!1)}catch(x){ja(!1),this.#o(new Ss(x,this.write))}finally{this.#t&&(this.#t._handle=i,i.close=o,this.#t.close=c,this.#t.removeAllListeners("error"))}this.#t&&this.#t.on("error",x=>this.#o(new Ss(x,this.write)));let f;if(l)if(Array.isArray(l)&&l.length>0){let x=l[0];f=this[Fn](Bn.from(x));for(let h=1;h<l.length;h++)f=this[Fn](l[h])}else f=this[Fn](Bn.from(l));return r&&r(),f}},Wf=class extends Dc{#e;#n;constructor(t,e){t=t||{},t.flush=t.flush||Dt.Z_NO_FLUSH,t.finishFlush=t.finishFlush||Dt.Z_FINISH,t.fullFlushFlag=Dt.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(Dt.Z_SYNC_FLUSH),cc(this.handle,"zlib binding closed");let r=this.handle.flush;this.handle.flush=(i,o)=>{typeof i=="function"&&(o=i,i=this.flushFlag),this.flush(i),o?.()};try{this.handle.params(t,e)}finally{this.handle.flush=r}this.handle&&(this.#e=t,this.#n=e)}}}},vm=class extends Wf{#e;constructor(t){super(t,"Gzip"),this.#e=t&&!!t.portable}[Fn](t){return this.#e?(this.#e=!1,t[9]=255,super[Fn](t)):super[Fn](t)}},Sm=class extends Wf{constructor(t){super(t,"Unzip")}},Kf=class extends Dc{constructor(t,e){t=t||{},t.flush=t.flush||Dt.BROTLI_OPERATION_PROCESS,t.finishFlush=t.finishFlush||Dt.BROTLI_OPERATION_FINISH,t.fullFlushFlag=Dt.BROTLI_OPERATION_FLUSH,super(t,e)}},Am=class extends Kf{constructor(t){super(t,"BrotliCompress")}},Im=class extends Kf{constructor(t){super(t,"BrotliDecompress")}},$f=class extends Dc{constructor(t,e){t=t||{},t.flush=t.flush||Dt.ZSTD_e_continue,t.finishFlush=t.finishFlush||Dt.ZSTD_e_end,t.fullFlushFlag=Dt.ZSTD_e_flush,super(t,e)}},Tm=class extends $f{constructor(t){super(t,"ZstdCompress")}},Cm=class extends $f{constructor(t){super(t,"ZstdDecompress")}},Rm=(t,e)=>{if(Number.isSafeInteger(t))t<0?km(t,e):Dm(t,e);else throw Error("cannot encode number outside of javascript safe integer range");return e},Dm=(t,e)=>{e[0]=128;for(var r=e.length;r>1;r--)e[r-1]=t&255,t=Math.floor(t/256)},km=(t,e)=>{e[0]=255;var r=!1;t=t*-1;for(var i=e.length;i>1;i--){var o=t&255;t=Math.floor(t/256),r?e[i-1]=Vf(o):o===0?e[i-1]=0:(r=!0,e[i-1]=Yf(o))}},Om=t=>{let e=t[0],r=e===128?Nm(t.subarray(1,t.length)):e===255?Pm(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},Pm=t=>{for(var e=t.length,r=0,i=!1,o=e-1;o>-1;o--){var c=Number(t[o]),l;i?l=Vf(c):c===0?l=c:(i=!0,l=Yf(c)),l!==0&&(r-=l*Math.pow(256,e-o-1))}return r},Nm=t=>{for(var e=t.length,r=0,i=e-1;i>-1;i--){var o=Number(t[i]);o!==0&&(r+=o*Math.pow(256,e-i-1))}return r},Vf=t=>(255^t)&255,Yf=t=>(255^t)+1&255,Lm={};Vg(Lm,{code:()=>kc,isCode:()=>Ls,isName:()=>Mm,name:()=>Js});var Ls=t=>Js.has(t),Mm=t=>kc.has(t),Js=new Map([["0","File"],["","OldFile"],["1","Link"],["2","SymbolicLink"],["3","CharacterDevice"],["4","BlockDevice"],["5","Directory"],["6","FIFO"],["7","ContiguousFile"],["g","GlobalExtendedHeader"],["x","ExtendedHeader"],["A","SolarisACL"],["D","GNUDumpDir"],["I","Inode"],["K","NextFileHasLongLinkpath"],["L","NextFileHasLongPath"],["M","ContinuationFile"],["N","OldGnuLongPath"],["S","SparseFile"],["V","TapeVolumeHeader"],["X","OldExtendedHeader"]]),kc=new Map(Array.from(Js).map(t=>[t[1],t[0]])),zn=class{cksumValid=!1;needPax=!1;nullBlock=!1;block;path;mode;uid;gid;size;cksum;#e="Unsupported";linkpath;uname;gname;devmaj=0;devmin=0;atime;ctime;mtime;charset;comment;constructor(t,e=0,r,i){Buffer.isBuffer(t)?this.decode(t,e||0,r,i):t&&this.#n(t)}decode(t,e,r,i){if(e||(e=0),!t||!(t.length>=e+512))throw new Error("need 512 bytes for header");this.path=r?.path??Dn(t,e,100),this.mode=r?.mode??i?.mode??un(t,e+100,8),this.uid=r?.uid??i?.uid??un(t,e+108,8),this.gid=r?.gid??i?.gid??un(t,e+116,8),this.size=r?.size??i?.size??un(t,e+124,12),this.mtime=r?.mtime??i?.mtime??Ka(t,e+136,12),this.cksum=un(t,e+148,12),i&&this.#n(i,!0),r&&this.#n(r);let o=Dn(t,e+156,1);if(Ls(o)&&(this.#e=o||"0"),this.#e==="0"&&this.path.slice(-1)==="/"&&(this.#e="5"),this.#e==="5"&&(this.size=0),this.linkpath=Dn(t,e+157,100),t.subarray(e+257,e+265).toString()==="ustar\x0000")if(this.uname=r?.uname??i?.uname??Dn(t,e+265,32),this.gname=r?.gname??i?.gname??Dn(t,e+297,32),this.devmaj=r?.devmaj??i?.devmaj??un(t,e+329,8)??0,this.devmin=r?.devmin??i?.devmin??un(t,e+337,8)??0,t[e+475]!==0){let l=Dn(t,e+345,155);this.path=l+"/"+this.path}else{let l=Dn(t,e+345,130);l&&(this.path=l+"/"+this.path),this.atime=r?.atime??i?.atime??Ka(t,e+476,12),this.ctime=r?.ctime??i?.ctime??Ka(t,e+488,12)}let c=256;for(let l=e;l<e+148;l++)c+=t[l];for(let l=e+156;l<e+512;l++)c+=t[l];this.cksumValid=c===this.cksum,this.cksum===void 0&&c===256&&(this.nullBlock=!0)}#n(t,e=!1){Object.assign(this,Object.fromEntries(Object.entries(t).filter(([r,i])=>!(i==null||r==="path"&&e||r==="linkpath"&&e||r==="global"))))}encode(t,e=0){if(t||(t=this.block=Buffer.alloc(512)),this.#e==="Unsupported"&&(this.#e="0"),!(t.length>=e+512))throw new Error("need 512 bytes for header");let r=this.ctime||this.atime?130:155,i=Bm(this.path||"",r),o=i[0],c=i[1];this.needPax=!!i[2],this.needPax=kn(t,e,100,o)||this.needPax,this.needPax=xn(t,e+100,8,this.mode)||this.needPax,this.needPax=xn(t,e+108,8,this.uid)||this.needPax,this.needPax=xn(t,e+116,8,this.gid)||this.needPax,this.needPax=xn(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=kn(t,e+157,100,this.linkpath)||this.needPax,t.write("ustar\x0000",e+257,8),this.needPax=kn(t,e+265,32,this.uname)||this.needPax,this.needPax=kn(t,e+297,32,this.gname)||this.needPax,this.needPax=xn(t,e+329,8,this.devmaj)||this.needPax,this.needPax=xn(t,e+337,8,this.devmin)||this.needPax,this.needPax=kn(t,e+345,r,c)||this.needPax,t[e+475]!==0?this.needPax=kn(t,e+345,155,c)||this.needPax:(this.needPax=kn(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 l=256;for(let f=e;f<e+148;f++)l+=t[f];for(let f=e+156;f<e+512;f++)l+=t[f];return this.cksum=l,xn(t,e+148,8,this.cksum),this.cksumValid=!0,this.needPax}get type(){return this.#e==="Unsupported"?this.#e:Js.get(this.#e)}get typeKey(){return this.#e}set type(t){let e=String(kc.get(t));if(Ls(e)||e==="Unsupported")this.#e=e;else if(Ls(t))this.#e=t;else throw new TypeError("invalid entry type: "+t)}},Bm=(t,e)=>{let r=t,i="",o,c=cr.parse(t).root||".";if(Buffer.byteLength(r)<100)o=[r,i,!1];else{i=cr.dirname(r),r=cr.basename(r);do Buffer.byteLength(r)<=100&&Buffer.byteLength(i)<=e?o=[r,i,!1]:Buffer.byteLength(r)>100&&Buffer.byteLength(i)<=e?o=[r.slice(0,99),i,!0]:(r=cr.join(cr.basename(i),r),i=cr.dirname(i));while(i!==c&&o===void 0);o||(o=[t.slice(0,99),"",!0])}return o},Dn=(t,e,r)=>t.subarray(e,e+r).toString("utf8").replace(/\0.*/,""),Ka=(t,e,r)=>Fm(un(t,e,r)),Fm=t=>t===void 0?void 0:new Date(t*1e3),un=(t,e,r)=>Number(t[e])&128?Om(t.subarray(e,e+r)):Um(t,e,r),zm=t=>isNaN(t)?void 0:t,Um=(t,e,r)=>zm(parseInt(t.subarray(e,e+r).toString("utf8").replace(/\0.*$/,"").trim(),8)),Gm={12:8589934591,8:2097151},xn=(t,e,r,i)=>i===void 0?!1:i>Gm[r]||i<0?(Rm(i,t.subarray(e,e+r)),!0):(qm(t,e,r,i),!1),qm=(t,e,r,i)=>t.write(Hm(i,r),e,r,"ascii"),Hm=(t,e)=>jm(Math.floor(t).toString(8),e),jm=(t,e)=>(t.length===e-1?t:new Array(e-t.length-1).join("0")+t+" ")+"\0",$a=(t,e,r,i)=>i===void 0?!1:xn(t,e,r,i.getTime()/1e3),Wm=new Array(156).join("\0"),kn=(t,e,r,i)=>i===void 0?!1:(t.write(i+Wm,e,r,"utf8"),i.length!==Buffer.byteLength(i)||i.length>r),js=class Jf{atime;mtime;ctime;charset;comment;gid;uid;gname;uname;linkpath;dev;ino;nlink;path;size;mode;global;constructor(e,r=!1){this.atime=e.atime,this.charset=e.charset,this.comment=e.comment,this.ctime=e.ctime,this.dev=e.dev,this.gid=e.gid,this.global=r,this.gname=e.gname,this.ino=e.ino,this.linkpath=e.linkpath,this.mtime=e.mtime,this.nlink=e.nlink,this.path=e.path,this.size=e.size,this.uid=e.uid,this.uname=e.uname}encode(){let e=this.encodeBody();if(e==="")return Buffer.allocUnsafe(0);let r=Buffer.byteLength(e),i=512*Math.ceil(1+r/512),o=Buffer.allocUnsafe(i);for(let c=0;c<512;c++)o[c]=0;new zn({path:("PaxHeader/"+Km(this.path??"")).slice(0,99),mode:this.mode||420,uid:this.uid,gid:this.gid,size:r,mtime:this.mtime,type:this.global?"GlobalExtendedHeader":"ExtendedHeader",linkpath:"",uname:this.uname||"",gname:this.gname||"",devmaj:0,devmin:0,atime:this.atime,ctime:this.ctime}).encode(o),o.write(e,512,r,"utf8");for(let c=r+512;c<o.length;c++)o[c]=0;return o}encodeBody(){return this.encodeField("path")+this.encodeField("ctime")+this.encodeField("atime")+this.encodeField("dev")+this.encodeField("ino")+this.encodeField("nlink")+this.encodeField("charset")+this.encodeField("comment")+this.encodeField("gid")+this.encodeField("gname")+this.encodeField("linkpath")+this.encodeField("mtime")+this.encodeField("size")+this.encodeField("uid")+this.encodeField("uname")}encodeField(e){if(this[e]===void 0)return"";let r=this[e],i=r instanceof Date?r.getTime()/1e3:r,o=" "+(e==="dev"||e==="ino"||e==="nlink"?"SCHILY.":"")+e+"="+i+`
|
|
90
|
-
`,c=Buffer.byteLength(o),l=Math.floor(Math.log(c)/Math.log(10))+1;return c+l>=Math.pow(10,l)&&(l+=1),l+c+o}static parse(e,r,i=!1){return new
|
|
91
|
-
`).reduce(Ym,Object.create(null)),Ym=(t,e)=>{let r=parseInt(e,10);if(r!==Buffer.byteLength(e)+1)return t;e=e.slice((r+" ").length);let i=e.split("="),o=i.shift();if(!o)return t;let c=o.replace(/^SCHILY\.(dev|ino|nlink)/,"$1"),l=i.join("=");return t[c]=/^([A-Z]+\.)?([mac]|birth|creation)time$/.test(c)?new Date(Number(l)*1e3):/^[0-9]+$/.test(l)?+l:l,t},Jm=process.env.TESTING_TAR_FAKE_PLATFORM||process.platform,Z=Jm!=="win32"?t=>t:t=>t&&t.replaceAll(/\\/g,"/"),Zf=class extends Un{extended;globalExtended;header;startBlockSize;blockRemain;remain;type;meta=!1;ignore=!1;path;mode;uid;gid;uname;gname;size=0;mtime;atime;ctime;linkpath;dev;ino;nlink;invalid=!1;absolute;unsupported=!1;constructor(t,e,r){switch(super({}),this.pause(),this.extended=e,this.globalExtended=r,this.header=t,this.remain=t.size??0,this.startBlockSize=512*Math.ceil(this.remain/512),this.blockRemain=this.startBlockSize,this.type=t.type,this.type){case"File":case"OldFile":case"Link":case"SymbolicLink":case"CharacterDevice":case"BlockDevice":case"Directory":case"FIFO":case"ContiguousFile":case"GNUDumpDir":break;case"NextFileHasLongLinkpath":case"NextFileHasLongPath":case"OldGnuLongPath":case"GlobalExtendedHeader":case"ExtendedHeader":case"OldExtendedHeader":this.meta=!0;break;default:this.ignore=!0}if(!t.path)throw new Error("no path provided for tar.ReadEntry");this.path=Z(t.path),this.mode=t.mode,this.mode&&(this.mode=this.mode&4095),this.uid=t.uid,this.gid=t.gid,this.uname=t.uname,this.gname=t.gname,this.size=this.remain,this.mtime=t.mtime,this.atime=t.atime,this.ctime=t.ctime,this.linkpath=t.linkpath?Z(t.linkpath):void 0,this.uname=t.uname,this.gname=t.gname,e&&this.#e(e),r&&this.#e(r,!0)}write(t){let e=t.length;if(e>this.blockRemain)throw new Error("writing more to entry than is appropriate");let r=this.remain,i=this.blockRemain;return this.remain=Math.max(0,r-e),this.blockRemain=Math.max(0,i-e),this.ignore?!0:r>=e?super.write(t):super.write(t.subarray(0,r))}#e(t,e=!1){t.path&&(t.path=Z(t.path)),t.linkpath&&(t.linkpath=Z(t.linkpath)),Object.assign(this,Object.fromEntries(Object.entries(t).filter(([r,i])=>!(i==null||r==="path"&&e))))}},Zs=(t,e,r,i={})=>{t.file&&(i.file=t.file),t.cwd&&(i.cwd=t.cwd),i.code=r instanceof Error&&r.code||e,i.tarCode=e,!t.strict&&i.recoverable!==!1?(r instanceof Error&&(i=Object.assign(r,i),r=r.message),t.emit("warn",e,r,i)):r instanceof Error?t.emit("error",Object.assign(r,i)):t.emit("error",Object.assign(new Error(`${e}: ${r}`),i))},Zm=1024*1024,dc=Buffer.from([31,139]),lc=Buffer.from([40,181,47,253]),Xm=Math.max(dc.length,lc.length),at=Symbol("state"),On=Symbol("writeEntry"),Gt=Symbol("readEntry"),Va=Symbol("nextEntry"),xf=Symbol("processEntry"),Tt=Symbol("extendedHeader"),di=Symbol("globalExtendedHeader"),an=Symbol("meta"),hf=Symbol("emitMeta"),xe=Symbol("buffer"),qt=Symbol("queue"),cn=Symbol("ended"),Ya=Symbol("emittedEnd"),Pn=Symbol("emit"),Te=Symbol("unzip"),As=Symbol("consumeChunk"),Is=Symbol("consumeChunkSub"),Ja=Symbol("consumeBody"),pf=Symbol("consumeMeta"),gf=Symbol("consumeHeader"),li=Symbol("consuming"),Za=Symbol("bufferConcat"),Ts=Symbol("maybeEnd"),dr=Symbol("writing"),dn=Symbol("aborted"),Cs=Symbol("onDone"),Nn=Symbol("sawValidEntry"),Rs=Symbol("sawNullBlock"),Ds=Symbol("sawEOF"),mf=Symbol("closeStream"),Qm=()=>!0,Ii=class extends wm{file;strict;maxMetaEntrySize;filter;brotli;zstd;writable=!0;readable=!1;[qt]=[];[xe];[Gt];[On];[at]="begin";[an]="";[Tt];[di];[cn]=!1;[Te];[dn]=!1;[Nn];[Rs]=!1;[Ds]=!1;[dr]=!1;[li]=!1;[Ya]=!1;constructor(t={}){super(),this.file=t.file||"",this.on(Cs,()=>{(this[at]==="begin"||this[Nn]===!1)&&this.warn("TAR_BAD_ARCHIVE","Unrecognized archive format")}),t.ondone?this.on(Cs,t.ondone):this.on(Cs,()=>{this.emit("prefinish"),this.emit("finish"),this.emit("end")}),this.strict=!!t.strict,this.maxMetaEntrySize=t.maxMetaEntrySize||Zm,this.filter=typeof t.filter=="function"?t.filter:Qm;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[mf]()),typeof t.onwarn=="function"&&this.on("warn",t.onwarn),typeof t.onReadEntry=="function"&&this.on("entry",t.onReadEntry)}warn(t,e,r={}){Zs(this,t,e,r)}[gf](t,e){this[Nn]===void 0&&(this[Nn]=!1);let r;try{r=new zn(t,e,this[Tt],this[di])}catch(i){return this.warn("TAR_ENTRY_INVALID",i)}if(r.nullBlock)this[Rs]?(this[Ds]=!0,this[at]==="begin"&&(this[at]="header"),this[Pn]("eof")):(this[Rs]=!0,this[Pn]("nullBlock"));else if(this[Rs]=!1,!r.cksumValid)this.warn("TAR_ENTRY_INVALID","checksum failure",{header:r});else if(!r.path)this.warn("TAR_ENTRY_INVALID","path is required",{header:r});else{let i=r.type;if(/^(Symbolic)?Link$/.test(i)&&!r.linkpath)this.warn("TAR_ENTRY_INVALID","linkpath required",{header:r});else if(!/^(Symbolic)?Link$/.test(i)&&!/^(Global)?ExtendedHeader$/.test(i)&&r.linkpath)this.warn("TAR_ENTRY_INVALID","linkpath forbidden",{header:r});else{let o=this[On]=new Zf(r,this[Tt],this[di]);if(!this[Nn])if(o.remain){let c=()=>{o.invalid||(this[Nn]=!0)};o.on("end",c)}else this[Nn]=!0;o.meta?o.size>this.maxMetaEntrySize?(o.ignore=!0,this[Pn]("ignoredEntry",o),this[at]="ignore",o.resume()):o.size>0&&(this[an]="",o.on("data",c=>this[an]+=c),this[at]="meta"):(this[Tt]=void 0,o.ignore=o.ignore||!this.filter(o.path,o),o.ignore?(this[Pn]("ignoredEntry",o),this[at]=o.remain?"ignore":"header",o.resume()):(o.remain?this[at]="body":(this[at]="header",o.end()),this[Gt]?this[qt].push(o):(this[qt].push(o),this[Va]())))}}}[mf](){queueMicrotask(()=>this.emit("close"))}[xf](t){let e=!0;if(!t)this[Gt]=void 0,e=!1;else if(Array.isArray(t)){let[r,...i]=t;this.emit(r,...i)}else this[Gt]=t,this.emit("entry",t),t.emittedEnd||(t.on("end",()=>this[Va]()),e=!1);return e}[Va](){do;while(this[xf](this[qt].shift()));if(this[qt].length===0){let t=this[Gt];!t||t.flowing||t.size===t.remain?this[dr]||this.emit("drain"):t.once("drain",()=>this.emit("drain"))}}[Ja](t,e){let r=this[On];if(!r)throw new Error("attempt to consume body without entry??");let i=r.blockRemain??0,o=i>=t.length&&e===0?t:t.subarray(e,e+i);return r.write(o),r.blockRemain||(this[at]="header",this[On]=void 0,r.end()),o.length}[pf](t,e){let r=this[On],i=this[Ja](t,e);return!this[On]&&r&&this[hf](r),i}[Pn](t,e,r){this[qt].length===0&&!this[Gt]?this.emit(t,e,r):this[qt].push([t,e,r])}[hf](t){switch(this[Pn]("meta",this[an]),t.type){case"ExtendedHeader":case"OldExtendedHeader":this[Tt]=js.parse(this[an],this[Tt],!1);break;case"GlobalExtendedHeader":this[di]=js.parse(this[an],this[di],!0);break;case"NextFileHasLongPath":case"OldGnuLongPath":{let e=this[Tt]??Object.create(null);this[Tt]=e,e.path=this[an].replace(/\0.*/,"");break}case"NextFileHasLongLinkpath":{let e=this[Tt]||Object.create(null);this[Tt]=e,e.linkpath=this[an].replace(/\0.*/,"");break}default:throw new Error("unknown meta: "+t.type)}}abort(t){this[dn]=!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[dn])return r?.(),!1;if((this[Te]===void 0||this.brotli===void 0&&this[Te]===!1)&&t){if(this[xe]&&(t=Buffer.concat([this[xe],t]),this[xe]=void 0),t.length<Xm)return this[xe]=t,r?.(),!0;for(let l=0;this[Te]===void 0&&l<dc.length;l++)t[l]!==dc[l]&&(this[Te]=!1);let o=!1;if(this[Te]===!1&&this.zstd!==!1){o=!0;for(let l=0;l<lc.length;l++)if(t[l]!==lc[l]){o=!1;break}}let c=this.brotli===void 0&&!o;if(this[Te]===!1&&c)if(t.length<512)if(this[cn])this.brotli=!0;else return this[xe]=t,r?.(),!0;else try{new zn(t.subarray(0,512)),this.brotli=!1}catch{this.brotli=!0}if(this[Te]===void 0||this[Te]===!1&&(this.brotli||o)){let l=this[cn];this[cn]=!1,this[Te]=this[Te]===void 0?new Sm({}):o?new Cm({}):new Im({}),this[Te].on("data",x=>this[As](x)),this[Te].on("error",x=>this.abort(x)),this[Te].on("end",()=>{this[cn]=!0,this[As]()}),this[dr]=!0;let f=!!this[Te][l?"end":"write"](t);return this[dr]=!1,r?.(),f}}this[dr]=!0,this[Te]?this[Te].write(t):this[As](t),this[dr]=!1;let i=this[qt].length>0?!1:this[Gt]?this[Gt].flowing:!0;return!i&&this[qt].length===0&&this[Gt]?.once("drain",()=>this.emit("drain")),r?.(),i}[Za](t){t&&!this[dn]&&(this[xe]=this[xe]?Buffer.concat([this[xe],t]):t)}[Ts](){if(this[cn]&&!this[Ya]&&!this[dn]&&!this[li]){this[Ya]=!0;let t=this[On];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[Pn](Cs)}}[As](t){if(this[li]&&t)this[Za](t);else if(!t&&!this[xe])this[Ts]();else if(t){if(this[li]=!0,this[xe]){this[Za](t);let e=this[xe];this[xe]=void 0,this[Is](e)}else this[Is](t);for(;this[xe]&&this[xe]?.length>=512&&!this[dn]&&!this[Ds];){let e=this[xe];this[xe]=void 0,this[Is](e)}this[li]=!1}(!this[xe]||this[cn])&&this[Ts]()}[Is](t){let e=0,r=t.length;for(;e+512<=r&&!this[dn]&&!this[Ds];)switch(this[at]){case"begin":case"header":this[gf](t,e),e+=512;break;case"ignore":case"body":e+=this[Ja](t,e);break;case"meta":e+=this[pf](t,e);break;default:throw new Error("invalid state: "+this[at])}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[dn]||(this[Te]?(t&&this[Te].write(t),this[Te].end()):(this[cn]=!0,(this.brotli===void 0||this.zstd===void 0)&&(t=t||Buffer.alloc(0)),t&&this.write(t),this[Ts]())),this}},_i=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)},ew=t=>{let e=t.onReadEntry;t.onReadEntry=e?r=>{e(r),r.resume()}:r=>r.resume()},Xf=(t,e)=>{let r=new Map(e.map(c=>[_i(c),!0])),i=t.filter,o=(c,l="")=>{let f=l||lm(c).root||".",x;if(c===f)x=!1;else{let h=r.get(c);x=h!==void 0?h:o(dm(c),f)}return r.set(c,x),x};t.filter=i?(c,l)=>i(c,l)&&o(_i(c)):c=>o(_i(c))},tw=t=>{let e=new Ii(t),r=t.file,i;try{i=pr.openSync(r,"r");let o=pr.fstatSync(i),c=t.maxReadSize||16*1024*1024;if(o.size<c){let l=Buffer.allocUnsafe(o.size),f=pr.readSync(i,l,0,o.size,0);e.end(f===l.byteLength?l:l.subarray(0,f))}else{let l=0,f=Buffer.allocUnsafe(c);for(;l<o.size;){let x=pr.readSync(i,f,0,c,l);if(x===0)break;l+=x,e.write(f.subarray(0,x))}e.end()}}finally{if(typeof i=="number")try{pr.closeSync(i)}catch{}}},nw=(t,e)=>{let r=new Ii(t),i=t.maxReadSize||16*1024*1024,o=t.file;return new Promise((c,l)=>{r.on("error",l),r.on("end",c),pr.stat(o,(f,x)=>{if(f)l(f);else{let h=new Cc(o,{readSize:i,size:x.size});h.on("error",l),h.pipe(r)}})})},_r=Ti(tw,nw,t=>new Ii(t),t=>new Ii(t),(t,e)=>{e?.length&&Xf(t,e),t.noResume||ew(t)}),Qf=(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:iw,parse:_f}=rw,Oc=t=>{let e="",r=_f(t);for(;iw(t)||r.root;){let i=t.charAt(0)==="/"&&t.slice(0,4)!=="//?/"?"/":r.root;t=t.slice(i.length),e+=i,r=_f(t)}return[e,t]},Xs=["|","<",">","?",":"],Pc=Xs.map(t=>String.fromCodePoint(61440+Number(t.codePointAt(0)))),sw=new Map(Xs.map((t,e)=>[t,Pc[e]])),ow=new Map(Pc.map((t,e)=>[t,Xs[e]])),yf=t=>Xs.reduce((e,r)=>e.split(r).join(sw.get(r)),t),aw=t=>Pc.reduce((e,r)=>e.split(r).join(ow.get(r)),t),e0=(t,e)=>e?(t=Z(t).replace(/^\.(\/|$)/,""),_i(e)+"/"+t):Z(t),cw=16*1024*1024,bf=Symbol("process"),Ef=Symbol("file"),vf=Symbol("directory"),fc=Symbol("symlink"),Sf=Symbol("hardlink"),fi=Symbol("header"),Ms=Symbol("read"),uc=Symbol("lstat"),Bs=Symbol("onlstat"),xc=Symbol("onread"),hc=Symbol("onreadlink"),pc=Symbol("openfile"),gc=Symbol("onopenfile"),hn=Symbol("close"),Ks=Symbol("mode"),mc=Symbol("awaitDrain"),Xa=Symbol("ondrain"),Rt=Symbol("prefix"),t0=class extends Un{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=Rc(e);super(),this.path=Z(t),this.portable=!!r.portable,this.maxReadSize=r.maxReadSize||cw,this.linkCache=r.linkCache||new Map,this.statCache=r.statCache||new Map,this.preservePaths=!!r.preservePaths,this.cwd=Z(r.cwd||process.cwd()),this.strict=!!r.strict,this.noPax=!!r.noPax,this.noMtime=!!r.noMtime,this.mtime=r.mtime,this.prefix=r.prefix?Z(r.prefix):void 0,this.onWriteEntry=r.onWriteEntry,typeof r.onwarn=="function"&&this.on("warn",r.onwarn);let i=!1;if(!this.preservePaths){let[c,l]=Oc(this.path);c&&typeof l=="string"&&(this.path=l,i=c)}this.win32=!!r.win32||process.platform==="win32",this.win32&&(this.path=aw(this.path.replaceAll(/\\/g,"/")),t=t.replaceAll(/\\/g,"/")),this.absolute=Z(r.absolute||wf.resolve(this.cwd,t)),this.path===""&&(this.path="./"),i&&this.warn("TAR_ENTRY_INFO",`stripping ${i} from absolute path`,{entry:this,path:i+this.path});let o=this.statCache.get(this.absolute);o?this[Bs](o):this[uc]()}warn(t,e,r={}){return Zs(this,t,e,r)}emit(t,...e){return t==="error"&&(this.#e=!0),super.emit(t,...e)}[uc](){Ct.lstat(this.absolute,(t,e)=>{if(t)return this.emit("error",t);this[Bs](e)})}[Bs](t){this.statCache.set(this.absolute,t),this.stat=t,t.isFile()||(t.size=0),this.type=fw(t),this.emit("stat",t),this[bf]()}[bf](){switch(this.type){case"File":return this[Ef]();case"Directory":return this[vf]();case"SymbolicLink":return this[fc]();default:return this.end()}}[Ks](t){return Qf(t,this.type==="Directory",this.portable)}[Rt](t){return e0(t,this.prefix)}[fi](){if(!this.stat)throw new Error("cannot write header before stat");this.type==="Directory"&&this.portable&&(this.noMtime=!0),this.onWriteEntry?.(this),this.header=new zn({path:this[Rt](this.path),linkpath:this.type==="Link"&&this.linkpath!==void 0?this[Rt](this.linkpath):this.linkpath,mode:this[Ks](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 js({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[Rt](this.path),linkpath:this.type==="Link"&&this.linkpath!==void 0?this[Rt](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)}[vf](){if(!this.stat)throw new Error("cannot create directory entry without stat");this.path.slice(-1)!=="/"&&(this.path+="/"),this.stat.size=0,this[fi](),this.end()}[fc](){Ct.readlink(this.absolute,(t,e)=>{if(t)return this.emit("error",t);this[hc](e)})}[hc](t){this.linkpath=Z(t),this[fi](),this.end()}[Sf](t){if(!this.stat)throw new Error("cannot create link entry without stat");this.type="Link",this.linkpath=Z(wf.relative(this.cwd,t)),this.stat.size=0,this[fi](),this.end()}[Ef](){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[Sf](e);this.linkCache.set(t,this.absolute)}if(this[fi](),this.stat.size===0)return this.end();this[pc]()}[pc](){Ct.open(this.absolute,"r",(t,e)=>{if(t)return this.emit("error",t);this[gc](e)})}[gc](t){if(this.fd=t,this.#e)return this[hn]();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:i,pos:o}=this;if(t===void 0||e===void 0)throw new Error("cannot read file without first opening");Ct.read(t,e,r,i,o,(c,l)=>{if(c)return this[hn](()=>this.emit("error",c));this[xc](l)})}[hn](t=()=>{}){this.fd!==void 0&&Ct.close(this.fd,t)}[xc](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[hn](()=>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[hn](()=>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[Xa]():this[mc](()=>this[Xa]())}[mc](t){this.once("drain",t)}write(t,e,r){if(typeof e=="function"&&(r=e,e=void 0),typeof t=="string"&&(t=Buffer.from(t,typeof e=="string"?e:"utf8")),this.blockRemain<t.length){let i=Object.assign(new Error("writing more data than expected"),{path:this.absolute});return this.emit("error",i)}return this.remain-=t.length,this.blockRemain-=t.length,this.pos+=t.length,this.offset+=t.length,super.write(t,null,r)}[Xa](){if(!this.remain)return this.blockRemain&&super.write(Buffer.alloc(this.blockRemain)),this[hn](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]()}},dw=class extends t0{sync=!0;[uc](){this[Bs](Ct.lstatSync(this.absolute))}[fc](){this[hc](Ct.readlinkSync(this.absolute))}[pc](){this[gc](Ct.openSync(this.absolute,"r"))}[Ms](){let t=!0;try{let{fd:e,buf:r,offset:i,length:o,pos:c}=this;if(e===void 0||r===void 0)throw new Error("fd and buf must be set in READ method");let l=Ct.readSync(e,r,i,o,c);this[xc](l),t=!1}finally{if(t)try{this[hn](()=>{})}catch{}}}[mc](t){t()}[hn](t=()=>{}){this.fd!==void 0&&Ct.closeSync(this.fd),t()}},lw=class extends Un{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 Zs(this,t,e,r)}constructor(t,e={}){let r=Rc(e);super(),this.preservePaths=!!r.preservePaths,this.portable=!!r.portable,this.strict=!!r.strict,this.noPax=!!r.noPax,this.noMtime=!!r.noMtime,this.onWriteEntry=r.onWriteEntry,this.readEntry=t;let{type:i}=t;if(i==="Unsupported")throw new Error("writing entry that should be ignored");this.type=i,this.type==="Directory"&&this.portable&&(this.noMtime=!0),this.prefix=r.prefix,this.path=Z(t.path),this.mode=t.mode!==void 0?this[Ks](t.mode):void 0,this.uid=this.portable?void 0:t.uid,this.gid=this.portable?void 0:t.gid,this.uname=this.portable?void 0:t.uname,this.gname=this.portable?void 0:t.gname,this.size=t.size,this.mtime=this.noMtime?void 0:r.mtime||t.mtime,this.atime=this.portable?void 0:t.atime,this.ctime=this.portable?void 0:t.ctime,this.linkpath=t.linkpath!==void 0?Z(t.linkpath):void 0,typeof r.onwarn=="function"&&this.on("warn",r.onwarn);let o=!1;if(!this.preservePaths){let[l,f]=Oc(this.path);l&&typeof f=="string"&&(this.path=f,o=l)}this.remain=t.size,this.blockRemain=t.startBlockSize,this.onWriteEntry?.(this),this.header=new zn({path:this[Rt](this.path),linkpath:this.type==="Link"&&this.linkpath!==void 0?this[Rt](this.linkpath):this.linkpath,mode:this.mode,uid:this.portable?void 0:this.uid,gid:this.portable?void 0:this.gid,size:this.size,mtime:this.noMtime?void 0:this.mtime,type:this.type,uname:this.portable?void 0:this.uname,atime:this.portable?void 0:this.atime,ctime:this.portable?void 0:this.ctime}),o&&this.warn("TAR_ENTRY_INFO",`stripping ${o} from absolute path`,{entry:this,path:o+this.path}),this.header.encode()&&!this.noPax&&super.write(new js({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[Rt](this.path),linkpath:this.type==="Link"&&this.linkpath!==void 0?this[Rt](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)}[Rt](t){return e0(t,this.prefix)}[Ks](t){return Qf(t,this.type==="Directory",this.portable)}write(t,e,r){typeof e=="function"&&(r=e,e=void 0),typeof t=="string"&&(t=Buffer.from(t,typeof e=="string"?e:"utf8"));let i=t.length;if(i>this.blockRemain)throw new Error("writing more to entry than is appropriate");return this.blockRemain-=i,super.write(t,r)}end(t,e,r){return this.blockRemain&&super.write(Buffer.alloc(this.blockRemain)),typeof t=="function"&&(r=t,e=void 0,t=void 0),typeof e=="function"&&(r=e,e=void 0),typeof t=="string"&&(t=Buffer.from(t,e??"utf8")),r&&this.once("finish",r),t?super.end(t,r):super.end(r),this}},fw=t=>t.isFile()?"File":t.isDirectory()?"Directory":t.isSymbolicLink()?"SymbolicLink":"Unsupported",uw=class gr{tail;head;length=0;static create(e=[]){return new gr(e)}constructor(e=[]){for(let r of e)this.push(r)}*[Symbol.iterator](){for(let e=this.head;e;e=e.next)yield e.value}removeNode(e){if(e.list!==this)throw new Error("removing node which does not belong to this list");let r=e.next,i=e.prev;return r&&(r.prev=i),i&&(i.next=r),e===this.head&&(this.head=r),e===this.tail&&(this.tail=i),this.length--,e.next=void 0,e.prev=void 0,e.list=void 0,r}unshiftNode(e){if(e===this.head)return;e.list&&e.list.removeNode(e);let r=this.head;e.list=this,e.next=r,r&&(r.prev=e),this.head=e,this.tail||(this.tail=e),this.length++}pushNode(e){if(e===this.tail)return;e.list&&e.list.removeNode(e);let r=this.tail;e.list=this,e.prev=r,r&&(r.next=e),this.tail=e,this.head||(this.head=e),this.length++}push(...e){for(let r=0,i=e.length;r<i;r++)hw(this,e[r]);return this.length}unshift(...e){for(var r=0,i=e.length;r<i;r++)pw(this,e[r]);return this.length}pop(){if(!this.tail)return;let e=this.tail.value,r=this.tail;return this.tail=this.tail.prev,this.tail?this.tail.next=void 0:this.head=void 0,r.list=void 0,this.length--,e}shift(){if(!this.head)return;let e=this.head.value,r=this.head;return this.head=this.head.next,this.head?this.head.prev=void 0:this.tail=void 0,r.list=void 0,this.length--,e}forEach(e,r){r=r||this;for(let i=this.head,o=0;i;o++)e.call(r,i.value,o,this),i=i.next}forEachReverse(e,r){r=r||this;for(let i=this.tail,o=this.length-1;i;o--)e.call(r,i.value,o,this),i=i.prev}get(e){let r=0,i=this.head;for(;i&&r<e;r++)i=i.next;if(r===e&&i)return i.value}getReverse(e){let r=0,i=this.tail;for(;i&&r<e;r++)i=i.prev;if(r===e&&i)return i.value}map(e,r){r=r||this;let i=new gr;for(let o=this.head;o;)i.push(e.call(r,o.value,this)),o=o.next;return i}mapReverse(e,r){r=r||this;var i=new gr;for(let o=this.tail;o;)i.push(e.call(r,o.value,this)),o=o.prev;return i}reduce(e,r){let i,o=this.head;if(arguments.length>1)i=r;else if(this.head)o=this.head.next,i=this.head.value;else throw new TypeError("Reduce of empty list with no initial value");for(var c=0;o;c++)i=e(i,o.value,c),o=o.next;return i}reduceReverse(e,r){let i,o=this.tail;if(arguments.length>1)i=r;else if(this.tail)o=this.tail.prev,i=this.tail.value;else throw new TypeError("Reduce of empty list with no initial value");for(let c=this.length-1;o;c--)i=e(i,o.value,c),o=o.prev;return i}toArray(){let e=new Array(this.length);for(let r=0,i=this.head;i;r++)e[r]=i.value,i=i.next;return e}toArrayReverse(){let e=new Array(this.length);for(let r=0,i=this.tail;i;r++)e[r]=i.value,i=i.prev;return e}slice(e=0,r=this.length){r<0&&(r+=this.length),e<0&&(e+=this.length);let i=new gr;if(r<e||r<0)return i;e<0&&(e=0),r>this.length&&(r=this.length);let o=this.head,c=0;for(c=0;o&&c<e;c++)o=o.next;for(;o&&c<r;c++,o=o.next)i.push(o.value);return i}sliceReverse(e=0,r=this.length){r<0&&(r+=this.length),e<0&&(e+=this.length);let i=new gr;if(r<e||r<0)return i;e<0&&(e=0),r>this.length&&(r=this.length);let o=this.length,c=this.tail;for(;c&&o>r;o--)c=c.prev;for(;c&&o>e;o--,c=c.prev)i.push(c.value);return i}splice(e,r=0,...i){e>this.length&&(e=this.length-1),e<0&&(e=this.length+e);let o=this.head;for(let l=0;o&&l<e;l++)o=o.next;let c=[];for(let l=0;o&&l<r;l++)c.push(o.value),o=this.removeNode(o);o?o!==this.tail&&(o=o.prev):o=this.tail;for(let l of i)o=xw(this,o,l);return c}reverse(){let e=this.head,r=this.tail;for(let i=e;i;i=i.prev){let o=i.prev;i.prev=i.next,i.next=o}return this.head=r,this.tail=e,this}};function xw(t,e,r){let i=e,o=e?e.next:t.head,c=new Nc(r,i,o,t);return c.next===void 0&&(t.tail=c),c.prev===void 0&&(t.head=c),t.length++,c}function hw(t,e){t.tail=new Nc(e,t.tail,void 0,t),t.head||(t.head=t.tail),t.length++}function pw(t,e){t.head=new Nc(e,void 0,t.head,t),t.tail||(t.tail=t.head),t.length++}var Nc=class{list;next;prev;value;constructor(t,e,r,i){this.list=i,this.value=t,e?(e.next=this,this.prev=e):this.prev=void 0,r?(r.prev=this,this.next=r):this.next=void 0}},If=class{path;absolute;entry;stat;readdir;pending=!1;pendingLink=!1;ignore=!1;piped=!1;constructor(t,e){this.path=t||"./",this.absolute=e}},Tf=Buffer.alloc(1024),Fs=Symbol("onStat"),ui=Symbol("ended"),pt=Symbol("queue"),xi=Symbol("queue"),ln=Symbol("current"),Ln=Symbol("process"),hi=Symbol("processing"),ks=Symbol("processJob"),gt=Symbol("jobs"),Qa=Symbol("jobDone"),zs=Symbol("addFSEntry"),Cf=Symbol("addTarEntry"),wc=Symbol("stat"),_c=Symbol("readdir"),Us=Symbol("onreaddir"),Gs=Symbol("pipe"),Rf=Symbol("entry"),ec=Symbol("entryOpt"),qs=Symbol("writeEntryClass"),n0=Symbol("write"),tc=Symbol("ondrain"),Qs=class extends Un{sync=!1;opt;cwd;maxReadSize;preservePaths;strict;noPax;prefix;linkCache;statCache;file;portable;zip;readdirCache;noDirRecurse;follow;noMtime;mtime;filter;jobs;[qs];onWriteEntry;[pt];[xi]=new Map;[gt]=0;[hi]=!1;[ui]=!1;constructor(t={}){if(super(),this.opt=t,this.file=t.file||"",this.cwd=t.cwd||process.cwd(),this.maxReadSize=t.maxReadSize,this.preservePaths=!!t.preservePaths,this.strict=!!t.strict,this.noPax=!!t.noPax,this.prefix=Z(t.prefix||""),this.linkCache=t.linkCache||new Map,this.statCache=t.statCache||new Map,this.readdirCache=t.readdirCache||new Map,this.onWriteEntry=t.onWriteEntry,this[qs]=t0,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 vm(t.gzip)),t.brotli&&(typeof t.brotli!="object"&&(t.brotli={}),this.zip=new Am(t.brotli)),t.zstd&&(typeof t.zstd!="object"&&(t.zstd={}),this.zip=new Tm(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[tc]()),this.on("resume",()=>e.resume())}else this.on("drain",this[tc]);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[pt]=new uw,this[gt]=0,this.jobs=Number(t.jobs)||4,this[hi]=!1,this[ui]=!1}[n0](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[ui]=!0,this[Ln](),r&&r(),this}write(t){if(this[ui])throw new Error("write after end");return t instanceof Zf?this[Cf](t):this[zs](t),this.flowing}[Cf](t){let e=Z(Af.resolve(this.cwd,t.path));if(!this.filter(t.path,t))t.resume();else{let r=new If(t.path,e);r.entry=new lw(t,this[ec](r)),r.entry.on("end",()=>this[Qa](r)),this[gt]+=1,this[pt].push(r)}this[Ln]()}[zs](t){let e=Z(Af.resolve(this.cwd,t));this[pt].push(new If(t,e)),this[Ln]()}[wc](t){t.pending=!0,this[gt]+=1;let e=this.follow?"stat":"lstat";Ws[e](t.absolute,(r,i)=>{t.pending=!1,this[gt]-=1,r?this.emit("error",r):this[Fs](t,i)})}[Fs](t,e){if(this.statCache.set(t.absolute,e),t.stat=e,!this.filter(t.path,e))t.ignore=!0;else if(e.isFile()&&e.nlink>1&&!this.linkCache.get(`${e.dev}:${e.ino}`)&&!this.sync)if(t===this[ln])this[ks](t);else{let r=`${e.dev}:${e.ino}`,i=this[xi].get(r);i?i.push(t):this[xi].set(r,[t]),t.pendingLink=!0,t.pending=!0}this[Ln]()}[_c](t){t.pending=!0,this[gt]+=1,Ws.readdir(t.absolute,(e,r)=>{if(t.pending=!1,this[gt]-=1,e)return this.emit("error",e);this[Us](t,r)})}[Us](t,e){this.readdirCache.set(t.absolute,e),t.readdir=e,this[Ln]()}[Ln](){if(!this[hi]){this[hi]=!0;for(let t=this[pt].head;t&&this[gt]<this.jobs;t=t.next)if(this[ks](t.value),t.value.ignore){let e=t.next;this[pt].removeNode(t),t.next=e}this[hi]=!1,this[ui]&&this[pt].length===0&&this[gt]===0&&(this.zip?this.zip.end(Tf):(super.write(Tf),super.end()))}}get[ln](){return this[pt]&&this[pt].head&&this[pt].head.value}[Qa](t){this[pt].shift(),this[gt]-=1;let{stat:e}=t;if(e&&e.isFile()&&e.nlink>1){let r=`${e.dev}:${e.ino}`,i=this[xi].get(r);if(i){this[xi].delete(r);for(let o of i)o.pending=!1,this[ks](o)}}this[Ln]()}[ks](t){if(t.pending&&t.pendingLink&&t===this[ln]&&(t.pending=!1,t.pendingLink=!1),!t.pending){if(t.entry){t===this[ln]&&!t.piped&&this[Gs](t);return}if(!t.stat){let e=this.statCache.get(t.absolute);e?this[Fs](t,e):this[wc](t)}if(t.stat&&!t.ignore){if(!this.noDirRecurse&&t.stat.isDirectory()&&!t.readdir){let e=this.readdirCache.get(t.absolute);if(e?this[Us](t,e):this[_c](t),!t.readdir)return}if(t.entry=this[Rf](t),!t.entry){t.ignore=!0;return}t===this[ln]&&!t.piped&&this[Gs](t)}}}[ec](t){return{onwarn:(e,r,i)=>this.warn(e,r,i),noPax:this.noPax,cwd:this.cwd,absolute:t.absolute,preservePaths:this.preservePaths,maxReadSize:this.maxReadSize,strict:this.strict,portable:this.portable,linkCache:this.linkCache,statCache:this.statCache,noMtime:this.noMtime,mtime:this.mtime,prefix:this.prefix,onWriteEntry:this.onWriteEntry}}[Rf](t){this[gt]+=1;try{return new this[qs](t.path,this[ec](t)).on("end",()=>this[Qa](t)).on("error",e=>this.emit("error",e))}catch(e){this.emit("error",e)}}[tc](){this[ln]&&this[ln].entry&&this[ln].entry.resume()}[Gs](t){t.piped=!0,t.readdir&&t.readdir.forEach(i=>{let o=t.path,c=o==="./"?"":o.replace(/\/*$/,"/");this[zs](c+i)});let e=t.entry,r=this.zip;if(!e)throw new Error("cannot pipe without source");r?e.on("data",i=>{r.write(i)||e.pause()}):e.on("data",i=>{super.write(i)||e.pause()})}pause(){return this.zip&&this.zip.pause(),super.pause()}warn(t,e,r={}){Zs(this,t,e,r)}},Lc=class extends Qs{sync=!0;constructor(t){super(t),this[qs]=dw}pause(){}resume(){}[wc](t){let e=this.follow?"statSync":"lstatSync";this[Fs](t,Ws[e](t.absolute))}[_c](t){this[Us](t,Ws.readdirSync(t.absolute))}[Gs](t){let e=t.entry,r=this.zip;if(t.readdir&&t.readdir.forEach(i=>{let o=t.path,c=o==="./"?"":o.replace(/\/*$/,"/");this[zs](c+i)}),!e)throw new Error("Cannot pipe without source");r?e.on("data",i=>{r.write(i)}):e.on("data",i=>{super[n0](i)})}},gw=(t,e)=>{let r=new Lc(t),i=new Hf(t.file,{mode:t.mode||438});r.pipe(i),r0(r,e)},mw=(t,e)=>{let r=new Qs(t),i=new Ys(t.file,{mode:t.mode||438});r.pipe(i);let o=new Promise((c,l)=>{i.on("error",l),i.on("close",c),r.on("error",l)});return i0(r,e).catch(c=>r.emit("error",c)),o},r0=(t,e)=>{e.forEach(r=>{r.charAt(0)==="@"?_r({file:jf.resolve(t.cwd,r.slice(1)),sync:!0,noResume:!0,onReadEntry:i=>t.add(i)}):t.add(r)}),t.end()},i0=async(t,e)=>{for(let r of e)r.charAt(0)==="@"?await _r({file:jf.resolve(String(t.cwd),r.slice(1)),noResume:!0,onReadEntry:i=>{t.add(i)}}):t.add(r);t.end()},ww=(t,e)=>{let r=new Lc(t);return r0(r,e),r},_w=(t,e)=>{let r=new Qs(t);return i0(r,e).catch(i=>r.emit("error",i)),r},k2=Ti(gw,mw,ww,_w,(t,e)=>{if(!e?.length)throw new TypeError("no paths specified to add to archive")}),bw=process.env.__FAKE_PLATFORM__||process.platform,c0=bw==="win32",{O_CREAT:d0,O_NOFOLLOW:Df,O_TRUNC:l0,O_WRONLY:f0}=a0.constants,u0=Number(process.env.__FAKE_FS_O_FILENAME__)||a0.constants.UV_FS_O_FILEMAP||0,Ew=c0&&!!u0,vw=512*1024,Sw=u0|l0|d0|f0,kf=!c0&&typeof Df=="number"?Df|l0|d0|f0:null,x0=kf!==null?()=>kf:Ew?t=>t<vw?Sw:"w":()=>"w",yc=(t,e,r)=>{try{return eo.lchownSync(t,e,r)}catch(i){if(i?.code!=="ENOENT")throw i}},$s=(t,e,r,i)=>{eo.lchown(t,e,r,o=>{i(o&&o?.code!=="ENOENT"?o:null)})},Aw=(t,e,r,i,o)=>{if(e.isDirectory())h0(yi.resolve(t,e.name),r,i,c=>{if(c)return o(c);let l=yi.resolve(t,e.name);$s(l,r,i,o)});else{let c=yi.resolve(t,e.name);$s(c,r,i,o)}},h0=(t,e,r,i)=>{eo.readdir(t,{withFileTypes:!0},(o,c)=>{if(o){if(o.code==="ENOENT")return i();if(o.code!=="ENOTDIR"&&o.code!=="ENOTSUP")return i(o)}if(o||!c.length)return $s(t,e,r,i);let l=c.length,f=null,x=h=>{if(!f){if(h)return i(f=h);if(--l===0)return $s(t,e,r,i)}};for(let h of c)Aw(t,h,e,r,x)})},Iw=(t,e,r,i)=>{e.isDirectory()&&p0(yi.resolve(t,e.name),r,i),yc(yi.resolve(t,e.name),r,i)},p0=(t,e,r)=>{let i;try{i=eo.readdirSync(t,{withFileTypes:!0})}catch(o){let c=o;if(c?.code==="ENOENT")return;if(c?.code==="ENOTDIR"||c?.code==="ENOTSUP")return yc(t,e,r);throw c}for(let o of i)Iw(t,o,e,r);return yc(t,e,r)},g0=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"}},to=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"}},Cw=(t,e)=>{it.stat(t,(r,i)=>{(r||!i.isDirectory())&&(r=new g0(t,r?.code||"ENOTDIR")),e(r)})},Rw=(t,e,r)=>{t=Z(t);let i=e.umask??18,o=e.mode|448,c=(o&i)!==0,l=e.uid,f=e.gid,x=typeof l=="number"&&typeof f=="number"&&(l!==e.processUid||f!==e.processGid),h=e.preserve,_=e.unlink,w=Z(e.cwd),S=(v,I)=>{v?r(v):I&&x?h0(I,l,f,A=>S(A)):c?it.chmod(t,o,r):r()};if(t===w)return Cw(t,S);if(h)return Tw.mkdir(t,{mode:o,recursive:!0}).then(v=>S(null,v??void 0),S);let b=Z(Vs.relative(w,t)).split("/");bc(w,b,o,_,w,void 0,S)},bc=(t,e,r,i,o,c,l)=>{if(e.length===0)return l(null,c);let f=e.shift(),x=Z(Vs.resolve(t+"/"+f));it.mkdir(x,r,m0(x,e,r,i,o,c,l))},m0=(t,e,r,i,o,c,l)=>f=>{f?it.lstat(t,(x,h)=>{if(x)x.path=x.path&&Z(x.path),l(x);else if(h.isDirectory())bc(t,e,r,i,o,c,l);else if(i)it.unlink(t,_=>{if(_)return l(_);it.mkdir(t,r,m0(t,e,r,i,o,c,l))});else{if(h.isSymbolicLink())return l(new to(t,t+"/"+e.join("/")));l(f)}}):(c=c||t,bc(t,e,r,i,o,c,l))},Dw=t=>{let e=!1,r;try{e=it.statSync(t).isDirectory()}catch(i){r=i?.code}finally{if(!e)throw new g0(t,r??"ENOTDIR")}},kw=(t,e)=>{t=Z(t);let r=e.umask??18,i=e.mode|448,o=(i&r)!==0,c=e.uid,l=e.gid,f=typeof c=="number"&&typeof l=="number"&&(c!==e.processUid||l!==e.processGid),x=e.preserve,h=e.unlink,_=Z(e.cwd),w=v=>{v&&f&&p0(v,c,l),o&&it.chmodSync(t,i)};if(t===_)return Dw(_),w();if(x)return w(it.mkdirSync(t,{mode:i,recursive:!0})??void 0);let S=Z(Vs.relative(_,t)).split("/"),b;for(let v=S.shift(),I=_;v&&(I+="/"+v);v=S.shift()){I=Z(Vs.resolve(I));try{it.mkdirSync(I,i),b=b||I}catch{let A=it.lstatSync(I);if(A.isDirectory())continue;if(h){it.unlinkSync(I),it.mkdirSync(I,i),b=b||I;continue}else if(A.isSymbolicLink())return new to(I,I+"/"+S.join("/"))}}return w(b)},nc=Object.create(null),Of=1e4,lr=new Set,Ow=t=>{lr.has(t)?lr.delete(t):nc[t]=t.normalize("NFD").toLocaleLowerCase("en").toLocaleUpperCase("en"),lr.add(t);let e=nc[t],r=lr.size-Of;if(r>Of/10){for(let i of lr)if(lr.delete(i),delete nc[i],--r<=0)break}return e},Pw=process.env.TESTING_TAR_FAKE_PLATFORM||process.platform,Nw=Pw==="win32",Lw=t=>t.split("/").slice(0,-1).reduce((e,r)=>{let i=e.at(-1);return i!==void 0&&(r=w0(i,r)),e.push(r||"/"),e},[]),Mw=class{#e=new Map;#n=new Map;#r=new Set;reserve(t,e){t=Nw?["win32 parallelization disabled"]:t.map(i=>_i(w0(Ow(i))));let r=new Set(t.map(i=>Lw(i)).reduce((i,o)=>i.concat(o)));this.#n.set(e,{dirs:r,paths:t});for(let i of t){let o=this.#e.get(i);o?o.push(e):this.#e.set(i,[e])}for(let i of r){let o=this.#e.get(i);if(!o)this.#e.set(i,[new Set([e])]);else{let c=o.at(-1);c instanceof Set?c.add(e):o.push(new Set([e]))}}return this.#i(e)}#s(t){let e=this.#n.get(t);if(!e)throw new Error("function does not have any path reservations");return{paths:e.paths.map(r=>this.#e.get(r)),dirs:[...e.dirs].map(r=>this.#e.get(r))}}check(t){let{paths:e,dirs:r}=this.#s(t);return e.every(i=>i&&i[0]===t)&&r.every(i=>i&&i[0]instanceof Set&&i[0].has(t))}#i(t){return this.#r.has(t)||!this.check(t)?!1:(this.#r.add(t),t(()=>this.#t(t)),!0)}#t(t){if(!this.#r.has(t))return!1;let e=this.#n.get(t);if(!e)throw new Error("invalid reservation");let{paths:r,dirs:i}=e,o=new Set;for(let c of r){let l=this.#e.get(c);if(!l||l?.[0]!==t)continue;let f=l[1];if(!f){this.#e.delete(c);continue}if(l.shift(),typeof f=="function")o.add(f);else for(let x of f)o.add(x)}for(let c of i){let l=this.#e.get(c),f=l?.[0];if(!(!l||!(f instanceof Set)))if(f.size===1&&l.length===1){this.#e.delete(c);continue}else if(f.size===1){l.shift();let x=l[0];typeof x=="function"&&o.add(x)}else f.delete(t)}return this.#r.delete(t),o.forEach(c=>this.#i(c)),!0}},Bw=()=>process.umask(),Pf=Symbol("onEntry"),Ec=Symbol("checkFs"),Nf=Symbol("checkFs2"),vc=Symbol("isReusable"),ct=Symbol("makeFs"),Sc=Symbol("file"),Ac=Symbol("directory"),Hs=Symbol("link"),Lf=Symbol("symlink"),Mf=Symbol("hardlink"),mi=Symbol("ensureNoSymlink"),Bf=Symbol("unsupported"),Ff=Symbol("checkPath"),rc=Symbol("stripAbsolutePath"),pn=Symbol("mkdir"),ze=Symbol("onError"),Os=Symbol("pending"),zf=Symbol("pend"),fr=Symbol("unpend"),ic=Symbol("ended"),sc=Symbol("maybeClose"),Ic=Symbol("skip"),bi=Symbol("doChown"),Ei=Symbol("uid"),vi=Symbol("gid"),Si=Symbol("checkedCwd"),Fw=process.env.TESTING_TAR_FAKE_PLATFORM||process.platform,Ai=Fw==="win32",zw=1024,Uw=(t,e)=>{if(!Ai)return re.unlink(t,e);let r=t+".DELETE."+o0(16).toString("hex");re.rename(t,r,i=>{if(i)return e(i);re.unlink(r,e)})},Gw=t=>{if(!Ai)return re.unlinkSync(t);let e=t+".DELETE."+o0(16).toString("hex");re.renameSync(t,e),re.unlinkSync(e)},Uf=(t,e,r)=>t!==void 0&&t===t>>>0?t:e!==void 0&&e===e>>>0?e:r,Mc=class extends Ii{[ic]=!1;[Si]=!1;[Os]=0;reservations=new Mw;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[ic]=!0,this[sc]()},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:zw,this.forceChown=t.forceChown===!0,this.win32=!!t.win32||Ai,this.newer=!!t.newer,this.keep=!!t.keep,this.noMtime=!!t.noMtime,this.preservePaths=!!t.preservePaths,this.unlink=!!t.unlink,this.cwd=Z(Pe.resolve(t.cwd||process.cwd())),this.strip=Number(t.strip)||0,this.processUmask=this.chmod?typeof t.processUmask=="number"?t.processUmask:Bw():0,this.umask=typeof t.umask=="number"?t.umask:this.processUmask,this.dmode=t.dmode||511&~this.umask,this.fmode=t.fmode||438&~this.umask,this.on("entry",e=>this[Pf](e))}warn(t,e,r={}){return(t==="TAR_BAD_ARCHIVE"||t==="TAR_ABORT")&&(r.recoverable=!1),super.warn(t,e,r)}[sc](){this[ic]&&this[Os]===0&&(this.emit("prefinish"),this.emit("finish"),this.emit("end"))}[rc](t,e){let r=t[e],{type:i}=t;if(!r||this.preservePaths)return!0;let[o,c]=Oc(r),l=c.replaceAll(/\\/g,"/").split("/");if(l.includes("..")||Ai&&/^[a-z]:\.\.$/i.test(l[0]??"")){if(e==="path"||i==="Link")return this.warn("TAR_ENTRY_ERROR",`${e} contains '..'`,{entry:t,[e]:r}),!1;let f=Pe.posix.dirname(t.path),x=Pe.posix.normalize(Pe.posix.join(f,l.join("/")));if(x.startsWith("../")||x==="..")return this.warn("TAR_ENTRY_ERROR",`${e} escapes extraction directory`,{entry:t,[e]:r}),!1}return o&&(t[e]=String(c),this.warn("TAR_ENTRY_INFO",`stripping ${o} from absolute ${e}`,{entry:t,[e]:r})),!0}[Ff](t){let e=Z(t.path),r=e.split("/");if(this.strip){if(r.length<this.strip)return!1;if(t.type==="Link"){let i=Z(String(t.linkpath)).split("/");if(i.length>=this.strip)t.linkpath=i.slice(this.strip).join("/");else return!1}r.splice(0,this.strip),t.path=r.join("/")}if(isFinite(this.maxDepth)&&r.length>this.maxDepth)return this.warn("TAR_ENTRY_ERROR","path excessively deep",{entry:t,path:e,depth:r.length,maxDepth:this.maxDepth}),!1;if(!this[rc](t,"path")||!this[rc](t,"linkpath"))return!1;if(t.absolute=Pe.isAbsolute(t.path)?Z(Pe.resolve(t.path)):Z(Pe.resolve(this.cwd,t.path)),!this.preservePaths&&typeof t.absolute=="string"&&t.absolute.indexOf(this.cwd+"/")!==0&&t.absolute!==this.cwd)return this.warn("TAR_ENTRY_ERROR","path escaped extraction target",{entry:t,path:Z(t.path),resolvedPath:t.absolute,cwd:this.cwd}),!1;if(t.absolute===this.cwd&&t.type!=="Directory"&&t.type!=="GNUDumpDir")return!1;if(this.win32){let{root:i}=Pe.win32.parse(String(t.absolute));t.absolute=i+yf(String(t.absolute).slice(i.length));let{root:o}=Pe.win32.parse(t.path);t.path=o+yf(t.path.slice(o.length))}return!0}[Pf](t){if(!this[Ff](t))return t.resume();switch(yw.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[Ec](t);default:return this[Bf](t)}}[ze](t,e){t.name==="CwdError"?this.emit("error",t):(this.warn("TAR_ENTRY_ERROR",t,{entry:e}),this[fr](),e.resume())}[pn](t,e,r){Rw(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)}[bi](t){return this.forceChown||this.preserveOwner&&(typeof t.uid=="number"&&t.uid!==this.processUid||typeof t.gid=="number"&&t.gid!==this.processGid)||typeof this.uid=="number"&&this.uid!==this.processUid||typeof this.gid=="number"&&this.gid!==this.processGid}[Ei](t){return Uf(this.uid,t.uid,this.processUid)}[vi](t){return Uf(this.gid,t.gid,this.processGid)}[Sc](t,e){let r=typeof t.mode=="number"?t.mode&4095:this.fmode,i=new Ys(String(t.absolute),{flags:x0(t.size),mode:r,autoClose:!1});i.on("error",f=>{i.fd&&re.close(i.fd,()=>{}),i.write=()=>!0,this[ze](f,t),e()});let o=1,c=f=>{if(f){i.fd&&re.close(i.fd,()=>{}),this[ze](f,t),e();return}--o===0&&i.fd!==void 0&&re.close(i.fd,x=>{x?this[ze](x,t):this[fr](),e()})};i.on("finish",()=>{let f=String(t.absolute),x=i.fd;if(typeof x=="number"&&t.mtime&&!this.noMtime){o++;let h=t.atime||new Date,_=t.mtime;re.futimes(x,h,_,w=>w?re.utimes(f,h,_,S=>c(S&&w)):c())}if(typeof x=="number"&&this[bi](t)){o++;let h=this[Ei](t),_=this[vi](t);typeof h=="number"&&typeof _=="number"&&re.fchown(x,h,_,w=>w?re.chown(f,h,_,S=>c(S&&w)):c())}c()});let l=this.transform&&this.transform(t)||t;l!==t&&(l.on("error",f=>{this[ze](f,t),e()}),t.pipe(l)),l.pipe(i)}[Ac](t,e){let r=typeof t.mode=="number"?t.mode&4095:this.dmode;this[pn](String(t.absolute),r,i=>{if(i){this[ze](i,t),e();return}let o=1,c=()=>{--o===0&&(e(),this[fr](),t.resume())};t.mtime&&!this.noMtime&&(o++,re.utimes(String(t.absolute),t.atime||new Date,t.mtime,c)),this[bi](t)&&(o++,re.chown(String(t.absolute),Number(this[Ei](t)),Number(this[vi](t)),c)),c()})}[Bf](t){t.unsupported=!0,this.warn("TAR_ENTRY_UNSUPPORTED",`unsupported entry type: ${t.type}`,{entry:t}),t.resume()}[Lf](t,e){let r=Z(Pe.relative(this.cwd,Pe.resolve(Pe.dirname(String(t.absolute)),String(t.linkpath)))).split("/");this[mi](t,this.cwd,r,()=>this[Hs](t,String(t.linkpath),"symlink",e),i=>{this[ze](i,t),e()})}[Mf](t,e){let r=Z(Pe.resolve(this.cwd,String(t.linkpath))),i=Z(String(t.linkpath)).split("/");this[mi](t,this.cwd,i,()=>this[Hs](t,r,"link",e),o=>{this[ze](o,t),e()})}[mi](t,e,r,i,o){let c=r.shift();if(this.preservePaths||c===void 0)return i();let l=Pe.resolve(e,c);re.lstat(l,(f,x)=>{if(f)return i();if(x?.isSymbolicLink())return o(new to(l,Pe.resolve(l,r.join("/"))));this[mi](t,l,r,i,o)})}[zf](){this[Os]++}[fr](){this[Os]--,this[sc]()}[Ic](t){this[fr](),t.resume()}[vc](t,e){return t.type==="File"&&!this.unlink&&e.isFile()&&e.nlink<=1&&!Ai}[Ec](t){this[zf]();let e=[t.path];t.linkpath&&e.push(t.linkpath),this.reservations.reserve(e,r=>this[Nf](t,r))}[Nf](t,e){let r=l=>{e(l)},i=()=>{this[pn](this.cwd,this.dmode,l=>{if(l){this[ze](l,t),r();return}this[Si]=!0,o()})},o=()=>{if(t.absolute!==this.cwd){let l=Z(Pe.dirname(String(t.absolute)));if(l!==this.cwd)return this[pn](l,this.dmode,f=>{if(f){this[ze](f,t),r();return}c()})}c()},c=()=>{re.lstat(String(t.absolute),(l,f)=>{if(f&&(this.keep||this.newer&&f.mtime>(t.mtime??f.mtime))){this[Ic](t),r();return}if(l||this[vc](t,f))return this[ct](null,t,r);if(f.isDirectory()){if(t.type==="Directory"){let x=this.chmod&&t.mode&&(f.mode&4095)!==t.mode,h=_=>this[ct](_??null,t,r);return x?re.chmod(String(t.absolute),Number(t.mode),h):h()}if(t.absolute!==this.cwd)return re.rmdir(String(t.absolute),x=>this[ct](x??null,t,r))}if(t.absolute===this.cwd)return this[ct](null,t,r);Uw(String(t.absolute),x=>this[ct](x??null,t,r))})};this[Si]?o():i()}[ct](t,e,r){if(t){this[ze](t,e),r();return}switch(e.type){case"File":case"OldFile":case"ContiguousFile":return this[Sc](e,r);case"Link":return this[Mf](e,r);case"SymbolicLink":return this[Lf](e,r);case"Directory":case"GNUDumpDir":return this[Ac](e,r)}}[Hs](t,e,r,i){re[r](e,String(t.absolute),o=>{o?this[ze](o,t):(this[fr](),t.resume()),i()})}},pi=t=>{try{return[null,t()]}catch(e){return[e,null]}},_0=class extends Mc{sync=!0;[ct](t,e){return super[ct](t,e,()=>{})}[Ec](t){if(!this[Si]){let o=this[pn](this.cwd,this.dmode);if(o)return this[ze](o,t);this[Si]=!0}if(t.absolute!==this.cwd){let o=Z(Pe.dirname(String(t.absolute)));if(o!==this.cwd){let c=this[pn](o,this.dmode);if(c)return this[ze](c,t)}}let[e,r]=pi(()=>re.lstatSync(String(t.absolute)));if(r&&(this.keep||this.newer&&r.mtime>(t.mtime??r.mtime)))return this[Ic](t);if(e||this[vc](t,r))return this[ct](null,t);if(r.isDirectory()){if(t.type==="Directory"){let c=this.chmod&&t.mode&&(r.mode&4095)!==t.mode,[l]=c?pi(()=>{re.chmodSync(String(t.absolute),Number(t.mode))}):[];return this[ct](l,t)}let[o]=pi(()=>re.rmdirSync(String(t.absolute)));this[ct](o,t)}let[i]=t.absolute===this.cwd?[]:pi(()=>Gw(String(t.absolute)));this[ct](i,t)}[Sc](t,e){let r=typeof t.mode=="number"?t.mode&4095:this.fmode,i=l=>{let f;try{re.closeSync(o)}catch(x){f=x}(l||f)&&this[ze](l||f,t),e()},o;try{o=re.openSync(String(t.absolute),x0(t.size),r)}catch(l){return i(l)}let c=this.transform&&this.transform(t)||t;c!==t&&(c.on("error",l=>this[ze](l,t)),t.pipe(c)),c.on("data",l=>{try{re.writeSync(o,l,0,l.length)}catch(f){i(f)}}),c.on("end",()=>{let l=null;if(t.mtime&&!this.noMtime){let f=t.atime||new Date,x=t.mtime;try{re.futimesSync(o,f,x)}catch(h){try{re.utimesSync(String(t.absolute),f,x)}catch{l=h}}}if(this[bi](t)){let f=this[Ei](t),x=this[vi](t);try{re.fchownSync(o,Number(f),Number(x))}catch(h){try{re.chownSync(String(t.absolute),Number(f),Number(x))}catch{l=l||h}}}i(l)})}[Ac](t,e){let r=typeof t.mode=="number"?t.mode&4095:this.dmode,i=this[pn](String(t.absolute),r);if(i){this[ze](i,t),e();return}if(t.mtime&&!this.noMtime)try{re.utimesSync(String(t.absolute),t.atime||new Date,t.mtime)}catch{}if(this[bi](t))try{re.chownSync(String(t.absolute),Number(this[Ei](t)),Number(this[vi](t)))}catch{}e(),t.resume()}[pn](t,e){try{return kw(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}}[mi](t,e,r,i,o){if(this.preservePaths||r.length===0)return i();let c=e;for(let l of r){c=Pe.resolve(c,l);let[f,x]=pi(()=>re.lstatSync(c));if(f)return i();if(x.isSymbolicLink())return o(new to(c,Pe.resolve(e,r.join("/"))))}i()}[Hs](t,e,r,i){let o=`${r}Sync`;try{re[o](e,String(t.absolute)),i(),t.resume()}catch(c){return this[ze](c,t)}}},qw=t=>{let e=new _0(t),r=t.file,i=s0.statSync(r),o=t.maxReadSize||16*1024*1024;new cm(r,{readSize:o,size:i.size}).pipe(e)},Hw=(t,e)=>{let r=new Mc(t),i=t.maxReadSize||16*1024*1024,o=t.file;return new Promise((c,l)=>{r.on("error",l),r.on("close",c),s0.stat(o,(f,x)=>{if(f)l(f);else{let h=new Cc(o,{readSize:i,size:x.size});h.on("error",l),h.pipe(r)}})})},y0=Ti(qw,Hw,t=>new _0(t),t=>new Mc(t),(t,e)=>{e?.length&&Xf(t,e)}),jw=(t,e)=>{let r=new Lc(t),i=!0,o,c;try{try{o=rt.openSync(t.file,"r+")}catch(x){if(x?.code==="ENOENT")o=rt.openSync(t.file,"w+");else throw x}let l=rt.fstatSync(o),f=Buffer.alloc(512);e:for(c=0;c<l.size;c+=512){for(let _=0,w=0;_<512;_+=w){if(w=rt.readSync(o,f,_,f.length-_,c+_),c===0&&f[0]===31&&f[1]===139)throw new Error("cannot append to compressed archives");if(!w)break e}let x=new zn(f);if(!x.cksumValid)break;let h=512*Math.ceil((x.size||0)/512);if(c+h+512>l.size)break;c+=h,t.mtimeCache&&x.mtime&&t.mtimeCache.set(String(x.path),x.mtime)}i=!1,Ww(t,r,c,o,e)}finally{if(i)try{rt.closeSync(o)}catch{}}},Ww=(t,e,r,i,o)=>{let c=new Hf(t.file,{fd:i,start:r});e.pipe(c),$w(e,o)},Kw=(t,e)=>{e=Array.from(e);let r=new Qs(t),i=(o,c,l)=>{let f=(S,b)=>{S?rt.close(o,v=>l(S)):l(null,b)},x=0;if(c===0)return f(null,0);let h=0,_=Buffer.alloc(512),w=(S,b)=>{if(S||b===void 0)return f(S);if(h+=b,h<512&&b)return rt.read(o,_,h,_.length-h,x+h,w);if(x===0&&_[0]===31&&_[1]===139)return f(new Error("cannot append to compressed archives"));if(h<512)return f(null,x);let v=new zn(_);if(!v.cksumValid)return f(null,x);let I=512*Math.ceil((v.size??0)/512);if(x+I+512>c||(x+=I+512,x>=c))return f(null,x);t.mtimeCache&&v.mtime&&t.mtimeCache.set(String(v.path),v.mtime),h=0,rt.read(o,_,0,512,x,w)};rt.read(o,_,0,512,x,w)};return new Promise((o,c)=>{r.on("error",c);let l="r+",f=(x,h)=>{if(x&&x.code==="ENOENT"&&l==="r+")return l="w+",rt.open(t.file,l,f);if(x||!h)return c(x);rt.fstat(h,(_,w)=>{if(_)return rt.close(h,()=>c(_));i(h,w.size,(S,b)=>{if(S)return c(S);let v=new Ys(t.file,{fd:h,start:b});r.pipe(v),v.on("error",c),v.on("close",o),Vw(r,e)})})};rt.open(t.file,l,f)})},$w=(t,e)=>{e.forEach(r=>{r.charAt(0)==="@"?_r({file:b0.resolve(t.cwd,r.slice(1)),sync:!0,noResume:!0,onReadEntry:i=>t.add(i)}):t.add(r)}),t.end()},Vw=async(t,e)=>{for(let r of e)r.charAt(0)==="@"?await _r({file:b0.resolve(String(t.cwd),r.slice(1)),noResume:!0,onReadEntry:i=>t.add(i)}):t.add(r);t.end()},gi=Ti(jw,Kw,()=>{throw new TypeError("file is required")},()=>{throw new TypeError("file is required")},(t,e)=>{if(!gm(t))throw new TypeError("file is required");if(t.gzip||t.brotli||t.zstd||t.file.endsWith(".br")||t.file.endsWith(".tbr"))throw new TypeError("cannot append to compressed archives");if(!e?.length)throw new TypeError("no paths specified to add/replace")}),K2=Ti(gi.syncFile,gi.asyncFile,gi.syncNoFile,gi.asyncNoFile,(t,e=[])=>{gi.validate?.(t,e),Yw(t)}),Yw=t=>{let e=t.filter;t.mtimeCache||(t.mtimeCache=new Map),t.filter=e?(r,i)=>e(r,i)&&!((t.mtimeCache?.get(r)??i.mtime??0)>(i.mtime??0)):(r,i)=>!((t.mtimeCache?.get(r)??i.mtime??0)>(i.mtime??0))};rn();var _t={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 E0(t){let e=t?.cozeAccountId?.trim();if(!(!e||e==="0"))return e}function Bc(t){let e=t?.cozeGroupId?.trim();if(!(!e||e==="0"))return e}function v0(t){let{_meta:e,...r}=t;return{stripped:r,meta:e}}function yr(t){if(!t?.cozeAgentId)throw new Error("missing _meta.cozeAgentId");return t.cozeAgentId}Ke();ne();ke();Ke();function Wt(t,e){if(Ci(t)!=="cloud")throw new T("OPERATION_NOT_ALLOWED_FOR_LOCAL",`${e} is not allowed for local agent`)}function no(t){return t.startsWith("http://")||t.startsWith("https://")}function ro(t){return t.endsWith("/")?t.slice(0,-1):t}Ke();ne();var io="1008033",S0="1289";var A0="pbbp2",I0="https://www.coze.cn",T0="/api/coze_claw/resource/get_frontier_key",Zw="https://www.coze.cn",Xw="wss://frontier.coze.cn";function so(t){return t??process.env.COZE_BRIDGE_HANDSHAKE_URL??Zw}function C0(t){return t??process.env.COZE_BRIDGE_FRONTIER_URL??Xw}function br(t){let e={},r=t?.ttEnv??process.env.COZE_BRIDGE_TT_ENV,i=t?.usePpe??process.env.COZE_BRIDGE_USE_PPE;return r&&(e["x-tt-env"]=r),i&&(e["x-use-ppe"]=i),e}function Di(t){return t?t.startsWith("boe_")?{ttEnv:t}:{ttEnv:t,usePpe:"1"}:{}}var Ri=j("handshake");async function Fc(t){let e=so(t.endpoint),r=t.timeoutMs??1e4,i=`${ro(e)}${T0}?aid=${encodeURIComponent(io)}`,o={Authorization:`Bearer ${t.privatecode}`,Accept:"application/json",...br(t.ppeOverride)},c=new AbortController,l=setTimeout(()=>c.abort(),r);Ri.info("frontier key handshake",{base:e});try{let f=await fetch(i,{method:"GET",headers:o,signal:c.signal}),x=f.headers.get("x-tt-logid")??"",h=f.headers.get("x-tt-trace-id")??"";if(!f.ok){let v=await f.text().catch(()=>"");throw new T("UPSTREAM_HANDSHAKE_FAILED",`handshake HTTP ${f.status} logid=${x}: ${v.slice(0,200)}`)}let _=await f.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 v=JSON.stringify(_).slice(0,500);throw new T("UPSTREAM_HANDSHAKE_FAILED",`handshake response missing access_key/device_id (also tried camelCase) logid=${x}: ${v}`)}return Ri.info("handshake ok",{remoteDeviceId:b,logid:x,traceId:h}),{accessKey:S,deviceId:b}}catch(f){if(f instanceof T)throw Ri.error("handshake failed (bridge error)",{base:e,message:f.message,code:f.code}),f;if(f.name==="AbortError")throw Ri.warn("handshake timeout",{base:e,timeoutMs:r}),new T("UPSTREAM_HANDSHAKE_FAILED",`handshake timeout (${r}ms)`,{cause:f});let x=f.cause;throw Ri.error("handshake error",{base:e,message:f instanceof Error?f.message:String(f),errno:x?.code,syscall:x?.syscall,cause:String(f).slice(0,300)}),new T("UPSTREAM_HANDSHAKE_FAILED",String(f),{cause:f})}finally{clearTimeout(l)}}var zc=process.env.COZE_BRIDGE_LLM_GATEWAY_URL?.trim()||"https://llm-gateway.coze.cn",yt="auto",R0=15e4;function D0(t){return{model:Uc(t.model)??yt,...t.modelToken?{modelToken:t.modelToken}:{}}}function k0(t){return!t||t===yt}var Qw=new Set(["auto","\u81EA\u52A8"]);function Uc(t){let e=t?.trim();if(e)return Qw.has(e.toLowerCase())?yt:e}function O0(t){let e={};if(t.modelToken){e.ANTHROPIC_BASE_URL=zc,e.ANTHROPIC_AUTH_TOKEN=t.modelToken;let r=t.model||yt;e.ANTHROPIC_MODEL=r,e.ANTHROPIC_SMALL_FAST_MODEL=r,e.ANTHROPIC_DEFAULT_HAIKU_MODEL=r,e.ANTHROPIC_DEFAULT_OPUS_MODEL=r,e.ANTHROPIC_DEFAULT_SONNET_MODEL=r,e.CLAUDE_CODE_SUBAGENT_MODEL=r,t.modelInfo?.contextWindow&&(e.CLAUDE_CODE_MAX_CONTEXT_TOKENS=String(t.modelInfo.contextWindow))}else k0(t.model)||(e.ANTHROPIC_MODEL=t.model);return e}function P0(t){let e=[];if(t.modelToken?e.push("-c",`model="${t.model||yt}"`):k0(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="${zc}/v1"`),e.push("-c",'model_providers.coze.env_key="OPENAI_API_KEY"'),e.push("-c",'model_providers.coze.wire_api="responses"'),e.push("-c","model_providers.coze.requires_openai_auth=false"),e.push("-c","model_providers.coze.supports_websockets=false"),e.push("-c",'model_provider="coze"');let r=t.modelInfo?.contextWindow??R0;e.push("-c",`model_context_window=${r}`)}return e}function N0(t){return t.modelToken?{OPENAI_API_KEY:t.modelToken}:{}}function Gc(t,e){let{ttEnv:r,usePpe:i}=Di(t),o={};return r&&(o["x-tt-env"]=r),i&&(o["x-use-ppe"]=i),e&&(o["x-mock-scenario"]=e),o}function L0(t,e,r){if(!t.modelToken)return{};let i=Gc(e,r);return Object.keys(i).length===0?{}:{ANTHROPIC_CUSTOM_HEADERS:Object.entries(i).map(([c,l])=>`${c}:${l}`).join(`
|
|
92
|
-
`)}}function qc(t){return`coze-session-${t.replace(/[^A-Za-z0-9_-]+/g,"-")}`}function M0(t,e,r){if(!t.modelToken)return null;let i=t.model||yt,o=Gc(e,r),c=["text"];t.modelInfo?.capabilities?.image===!0&&c.push("image");let l={baseUrl:`${zc}/v1`,api:"openai-completions",apiKey:t.modelToken,models:[{id:i,name:i,reasoning:!1,input:c,cost:{input:0,output:0,cacheRead:0,cacheWrite:0},contextWindow:t.modelInfo?.contextWindow??R0,maxTokens:8192,api:"openai-completions"}]};return Object.keys(o).length>0&&(l.headers=o),l}function B0(t,e,r){if(!t.modelToken)return[];let i=Gc(e,r),o=[];for(let[c,l]of Object.entries(i))o.push("-c",`model_providers.coze.http_headers.${c}="${l}"`);return o}var Ne=j("agent-handlers"),F0=5*1024*1024,s_=1,o_=6,a_=new Set(["node_modules",".git",".coze","dist","build",".next"]),oo=class{constructor(e){this.opts=e}opts;async listSkills(e){Wt(e._meta,"_agent/listSkills");let r=yr(e._meta),i=await this.loadAgentCfg(r),o=i?.workspace??Ze(r).workspace,c=i?.skills??[],l=[];for(let f of c){let x=kt(o,f.relPath,"SKILL.md");await n_(x).then(_=>_.isFile()).catch(()=>!1)&&l.push(u_(f))}return{skills:l}}async addSkills(e){Wt(e._meta,"_agent/addSkills");let r=yr(e._meta),i=await this.requireAgentCfg(r),o=e.skills??[],c=[...i.skills??[]],l=new Map(c.map((x,h)=>[x.skillId,h])),f=[];for(let x of o){let h=await Yc({agentId:r,workspace:i.workspace,framework:i.framework,skill:x});Jc(c,l,h),f.push(x)}return await fs(r,c),this.reloadAgentSessions(r,"skills-added"),{installedSkills:f}}async removeSkills(e){Wt(e._meta,"_agent/removeSkills");let r=yr(e._meta),i=await this.requireAgentCfg(r),o=new Set(e.skillIds??[]),c=i.skills??[],l=[];for(let f of c){if(!o.has(f.skillId)){l.push(f);continue}let x=kt(i.workspace,f.relPath);await t_(x,{recursive:!0,force:!0}),Ne.info("skill removed",{agentId:r,skillId:f.skillId,relPath:f.relPath})}return await fs(r,l),this.reloadAgentSessions(r,"skills-removed"),{ok:!0}}reloadAgentSessionsPublic(e,r){this.reloadAgentSessions(e,r)}reloadAgentSessions(e,r){let i=this.opts.agents.get(e);if(i)for(let[o,c]of i.sessions){if(!c.downstream)continue;let l=c.acpSessionId;if(l&&i.activeTriggers.has(l)||this.isRuntimePendingPermission(c)){c.reloadAfterTurn=!0,Ne.info("downstream busy, scheduling reload after turn",{reason:r,agentId:e,framework:i.framework,cloudId:o,acpId:l});continue}let x=c.downstream;c.downstream=void 0,Ne.info("killing downstream for workspace reload (idle)",{reason:r,agentId:e,framework:i.framework,cloudId:o,acpId:l}),x.stop(r).catch(h=>Ne.warn("downstream stop failed during reload (ignored)",{reason:r,agentId:e,cloudId:o,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 Ne.info("_agent/update: empty cozeIdentity, noop",{agentId:e.agentId}),{ok:!0};let r=e.agentId,i=await He(r);if(!i)throw new T("AGENT_NOT_FOUND",`agent not found: ${r}`);if(i.cozeIdentity===e.cozeIdentity)return Ne.info("_agent/update: cozeIdentity unchanged, noop",{agentId:r}),{ok:!0};try{await rr(i.workspace,i.framework,e.cozeIdentity)}catch(o){throw Ne.error("_agent/update: writeInstructionFile failed, aborting update",{agentId:r,framework:i.framework,workspace:i.workspace,err:String(o)}),new T("AGENT_PROTOCOL_ERROR",`failed to write instruction file for agent ${r}: ${String(o)}`,{cause:o})}return i.cozeIdentity=e.cozeIdentity,await Xe(i),Ne.info("_agent/update: cozeIdentity rewritten",{agentId:r,framework:i.framework}),this.reloadAgentSessions(r,"identity-changed"),{ok:!0}}async disconnectAgent(e){let r=e.agentId;if(!r)throw new T("IPC_BAD_REQUEST","_agent/disconnect: missing agentId");let i=await He(r);return i?(i.disconnectedAt=Date.now(),i.disconnectReason=e.reason??"",await Xe(i),Ne.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}):(Ne.warn("_agent/disconnect: agent not found, ignoring",{agentId:r}),{ok:!0})}async switchModel(e){if(Wt(e._meta,"_agent/switchModel"),!e.agentId)throw new T("IPC_BAD_REQUEST","_agent/switchModel: missing agentId");let r=Uc(e.model)??yt,i=await He(e.agentId);if(!i)throw new T("AGENT_NOT_FOUND",`agent not found: ${e.agentId}`);i.model=r,e.modelInfo&&(i.modelInfo=e.modelInfo),await Xe(i),Ne.info("_agent/switchModel: model persisted",{agentId:e.agentId,model:r,reason:e.reason??""});let o=this.opts.agents.get(e.agentId);if(!o)return Ne.info("_agent/switchModel: agent not running, config persisted only",{agentId:e.agentId}),{ok:!0};o.model=r,e.modelInfo&&o.setModelInfo(e.modelInfo),this.opts.cleanupOpenclawProviders&&await this.opts.cleanupOpenclawProviders(o).catch(l=>Ne.warn("cleanupOpenclawProviders before switchModel failed (ignored)",{agentId:e.agentId,err:String(l)}));let c=[];for(let[l,f]of o.allSessionQueues())c.push(f.enqueue(async()=>{let x=o.sessions.get(l);x?.downstream&&(await x.downstream.stop(`switchModel: ${r}`).catch(()=>{}),x.downstream=void 0)}));return await Promise.all(c),Ne.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(Wt(e._meta,_t.RESET),!e.agentId)throw new T("IPC_BAD_REQUEST",`${_t.RESET}: missing agentId`);return await this.clearSessionMappings(e.agentId,_t.RESET),await this.runDetailSync(e.agentId,_t.RESET,e.reason),{ok:!0}}async clearSessionMappings(e,r){let i=this.opts.agents.get(e);if(!i){await this.clearPersistedAcpSessionIds(e),Ne.info("reset: agent not in memory, cleared persisted acpSessionIds only",{agentId:e});return}await i.killAllRuntimes(r);for(let c of i.sessions.values())c.acpSessionId=void 0,c.replySeq=0,c.loadingSession=!1,c.spawnFailCount=void 0,c.spawnFailedAt=void 0;let o=new Map;for(let[c,l]of i.sessions)o.set(c,{modelToken:l.modelToken,tokenGeneratedAt:l.tokenGeneratedAt});await ti(e,o)}async clearPersistedAcpSessionIds(e){let r=await He(e).catch(()=>null);if(!r?.sessions)return;let i=!1;for(let o of Object.values(r.sessions))o.acpSessionId&&(o.acpSessionId=void 0,i=!0);i&&await Xe(r)}async repairAgent(e){if(Wt(e._meta,_t.REPAIR),!e.agentId)throw new T("IPC_BAD_REQUEST",`${_t.REPAIR}: missing agentId`);let r=await this.loadAgentCfg(e.agentId);if(r&&r.framework!=="openclaw")throw new T("IPC_BAD_REQUEST",`${_t.REPAIR} only allowed for openclaw, got ${r.framework}`);if(r&&this.opts.openclawRepair)try{await this.opts.openclawRepair(e.agentId,r.workspace)}catch(i){Ne.warn("openclaw repair (delete+add) failed (ignored)",{agentId:e.agentId,reason:e.reason,err:String(i)})}return await this.runDetailSync(e.agentId,_t.REPAIR,e.reason),{ok:!0}}async runDetailSync(e,r,i){if(!this.opts.detailSyncer){Ne.warn("detailSyncer not wired, skipping sync",{method:r,agentId:e});return}try{await this.opts.detailSyncer(e)}catch(o){Ne.warn("detail sync failed (ignored)",{method:r,agentId:e,reason:i,err:String(o)})}}async getFileTree(e){Wt(e._meta,"_agent/getFileTree");let r=e._meta,i=yr(r),o=await this.resolveWorkspace(i),c=e.filePath??"",l=this.safeJoin(o,c),f=await Hc(l).catch(()=>null);if(!f)throw new T("IPC_BAD_REQUEST",`path not found: ${c}`);if(f.isSymbolicLink())throw new T("IPC_BAD_REQUEST",`symlink not allowed: ${c}`);if(!await ei(l,o))throw new T("IPC_BAD_REQUEST",`path escapes workspace: ${c}`);let x=v_(e.depth);return f.isDirectory()?{tree:await E_(o,l,c,x)}:{tree:[{name:S_(c),path:W0(c||"."),isDir:!1,size:f.size,modifiedAt:Math.floor(f.mtimeMs)}]}}async getFileContent(e){Wt(e._meta,"_agent/getFileContent");let r=yr(e._meta),i=await this.resolveWorkspace(r);if(!e.filePath)throw new T("IPC_BAD_REQUEST","filePath required");let o=this.safeJoin(i,e.filePath),c=await Hc(o).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 ei(o,i))throw new T("IPC_BAD_REQUEST",`path escapes workspace: ${e.filePath}`);if(c.size>F0)throw new T("IPC_BAD_REQUEST",`file too large: ${c.size} bytes (max ${F0})`);let l=await z0(o);return l.includes(0)?{content:l.toString("base64"),encoding:"base64",size:c.size}:{content:l.toString("utf8"),encoding:"utf-8",size:c.size}}async resolveWorkspace(e){let r=this.opts.agents.get(e);return r?r.workspace:(await He(e).catch(()=>null))?.workspace??Ze(e).workspace}safeJoin(e,r){let i=Kc(e,r||"."),o=Vc(e,i);if(o.startsWith("..")||o===".."||o.startsWith(`..${U0}`))throw new T("IPC_BAD_REQUEST",`path escapes workspace: ${r}`);return i}loadAgentCfg(e){return He(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 c_(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 d_(t){return t==="claude-code"?kt(".claude","skills"):kt(".agents","skills")}var l_=3e4,f_=50*1024*1024,Er=3e4;async function Yc(t){let{agentId:e,workspace:r,framework:i,skill:o}=t;if(!o.skillName)throw new T("IPC_BAD_REQUEST","skill missing skillName");let c=typeof o.content=="string"&&o.content.length>0,l=typeof o.downloadUrl=="string"&&o.downloadUrl.length>0;if(!c&&!l)throw new T("IPC_BAD_REQUEST",`skill ${o.skillId} missing both content and downloadUrl`);let f=c_(o.skillName),x=d_(i),h=kt(x,f),_=kt(r,h);if(await jc(_,{recursive:!0}),c){let S=Buffer.from(o.content,"utf8");ki(S.length),await Wc(kt(_,"SKILL.md"),S,"utf8")}else{let S=await x_(o.downloadUrl);p_(S)?await __(S,_):g_(S)?await m_(S,_):await Wc(kt(_,"SKILL.md"),S.toString("utf8"),"utf8")}let w={skillId:o.skillId,skillName:o.skillName,relPath:h,installedAt:Date.now(),...o.description?{description:o.description}:{},...o.icon?{icon:o.icon}:{},...o.version?{version:o.version}:{},...o.downloadUrl?{downloadUrl:o.downloadUrl}:{},...o.config?{config:o.config}:{},...o.builtin?{builtin:o.builtin}:{}};return Ne.info("skill installed",{agentId:e,skillId:o.skillId,skillName:o.skillName,relPath:h,source:c?"content":"downloadUrl"}),w}function Jc(t,e,r){let i=e.get(r.skillId);if(i!==void 0){t[i]=r;return}e.set(r.skillId,t.length),t.push(r)}function u_(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 x_(t){if(!t)throw new T("IPC_BAD_REQUEST","skill missing downloadUrl");if(t.startsWith("data:")){let e=Math.floor(t.length*3/4);ki(e);let r=h_(t);return ki(r.length),r}if(t.startsWith("file:")){let e=new URL(t).pathname,r=await z0(e);return ki(r.length),r}if(no(t)){let e=new AbortController,r=setTimeout(()=>e.abort(),l_);try{let i=await fetch(t,{signal:e.signal});if(!i.ok)throw new T("IPC_BAD_REQUEST",`fetch skill failed HTTP ${i.status} ${t}`);let o=await i.arrayBuffer();return ki(o.byteLength),Buffer.from(o)}finally{clearTimeout(r)}}throw new T("IPC_BAD_REQUEST",`unsupported downloadUrl scheme (\u8981 https/data/file): ${t.slice(0,80)}`)}function ki(t){if(t>f_)throw new T("IPC_BAD_REQUEST",`skill too large: ${t} bytes`)}function h_(t){let e=/^data:([^,;]*)(;base64)?,(.*)$/s.exec(t);if(!e)throw new T("IPC_BAD_REQUEST","bad data URL");let r=!!e[2],i=e[3]??"";return r?Buffer.from(i,"base64"):Buffer.from(decodeURIComponent(i),"utf8")}function p_(t){return t.length>=2&&t[0]===31&&t[1]===139}function g_(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 $c(t){return t==="__MACOSX"||t.startsWith("__MACOSX/")}async function m_(t,e){let r,i;try{r=new H0.default(t),i=r.getEntries()}catch(l){throw new T("IPC_BAD_REQUEST",`zip parse failed: ${l.message}`,{cause:l})}for(let l of i){let f=l.entryName;if(!f||$c(f))continue;if(f.startsWith("/")||/^[A-Za-z]:[\\/]/.test(f))throw new T("IPC_BAD_REQUEST",`zip entry absolute path: ${f}`);if(f.split(/[/\\]/).some(h=>h===".."))throw new T("IPC_BAD_REQUEST",`zip entry contains '..' (traversal): ${f}`);let x=l.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): ${f}`)}let o=w_(i),c=Kc(e);for(let l of i){if($c(l.entryName))continue;let f=l.entryName;if(o&&f.startsWith(o)&&(f=f.slice(o.length)),!f)continue;let x=Kc(e,f),h=Vc(c,x);if(h.startsWith("..")||h==="..")throw new T("IPC_BAD_REQUEST",`zip entry escapes destDir: ${f}`);if(l.isDirectory){await jc(x,{recursive:!0});continue}await jc(r_(x),{recursive:!0});let _;try{_=l.getData()}catch(w){throw new T("IPC_BAD_REQUEST",`zip entry getData failed (${l.entryName}): ${w.message}`,{cause:w})}await Wc(x,_)}}function w_(t){let e;for(let r of t){let i=r.entryName;if(!i||$c(i))continue;let o=i.indexOf("/");if(o<=0)return;let c=i.slice(0,o+1);if(e===void 0)e=c;else if(e!==c)return}return e}async function __(t,e){await y_(t);let r=y0({cwd:e,strip:1}),i=!1,o=setTimeout(()=>{i=!0,r.destroy(new T("IPC_BAD_REQUEST",`tar extract timeout (${Er}ms)`))},Er);try{await q0(G0.from(t),r)}catch(c){throw c instanceof T?c:i?new T("IPC_BAD_REQUEST",`tar extract timeout (${Er}ms)`):new T("IPC_BAD_REQUEST",`tar extract failed: ${c.message??String(c)}`,{cause:c})}finally{clearTimeout(o)}}async function y_(t){let e=[],r=_r({onReadEntry:c=>{let l=c.path,f=c.type;if(f!=="File"&&f!=="Directory"){e.push(`tar entry kind '${f}' not allowed (symlink/hardlink/special): ${l.slice(0,100)}`);return}if(l.startsWith("/")||l.startsWith("\\")||/^[a-zA-Z]:[\\/]/.test(l)){e.push(`tar entry absolute path: ${l}`);return}l.split(/[/\\]/).some(h=>h==="..")&&e.push(`tar entry contains '..': ${l}`)}}),i=!1,o=setTimeout(()=>{i=!0,r.destroy(new T("IPC_BAD_REQUEST",`tar list timeout (${Er}ms)`))},Er);try{await q0(G0.from(t),r)}catch(c){throw i?new T("IPC_BAD_REQUEST",`tar list timeout (${Er}ms)`):new T("IPC_BAD_REQUEST",`tar list failed: ${c.message??String(c)}`,{cause:c})}finally{clearTimeout(o)}if(e.length>0)throw new T("IPC_BAD_REQUEST",e[0]??"tar entry validation failed")}var b_=5e3;async function E_(t,e,r,i){return j0(t,e,r,i,{count:0})}async function j0(t,e,r,i,o){if(i<=0)return[];let c;try{c=await e_(e,{withFileTypes:!0})}catch{return[]}let l=[];for(let f of c){if(a_.has(f.name)||f.isSymbolicLink())continue;if(o.count>=b_){l.push({name:"...",path:"...",isDir:!1,size:0,modifiedAt:0,hasMore:!0});break}let x=kt(e,f.name),h=i_(kt(r,f.name)),_=null;try{_=await Hc(x)}catch{continue}if(_.isSymbolicLink())continue;o.count++;let w={name:f.name,path:W0(Vc(t,x)),isDir:_.isDirectory(),size:_.size,modifiedAt:Math.floor(_.mtimeMs)};_.isDirectory()&&i>1&&(w.children=await j0(t,x,h,i-1,o)),l.push(w)}return l.sort((f,x)=>f.isDir!==x.isDir?f.isDir?-1:1:f.name.localeCompare(x.name)),l}function v_(t){return!t||t<=0?s_:Math.min(t,o_)}function S_(t){if(!t||t==="."||t==="/")return".";let e=t.split(/[/\\]/);return e[e.length-1]||"."}function W0(t){return t.split(U0).join("/")}ne();import{readFileSync as nI}from"node:fs";import{dirname as iI,join as sI}from"node:path";import{fileURLToPath as aI}from"node:url";var vr="0.1.99";var wn=j("agent-health-reporter"),A_=1e4,Oi=class{constructor(e){this.opts=e;this.intervalMs=e.intervalMs??A_}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()}),wn.info("heartbeat started",{intervalMs:this.intervalMs}),this.tick())}stop(){this.timer&&(clearInterval(this.timer),this.timer=null,this.unsubscribeRegister&&(this.unsubscribeRegister(),this.unsubscribeRegister=null),wn.info("heartbeat stopped"))}async tick(){if(this.inFlight){wn.debug("previous tick still in-flight, skip");return}let e=this.opts.getDeviceId();if(!e){wn.debug("deviceId not available, skip tick (\u5C1A\u672A pair)");return}this.inFlight=!0;try{let r=[];for(let l of this.opts.core.agents.values()){let f=I_(l);if(!f)continue;let x={agentId:l.agentId,status:f};l.patToken&&(x.patToken=l.patToken),l.accountId&&(x.accountId=l.accountId),r.push(x)}if(r.length===0)return;let i={agents:r,bridgeVersion:vr,_meta:{cozeDeviceId:e}},o;try{o=await this.opts.core.sendRequest("_agent/health",i,5e3)}catch(l){wn.warn("heartbeat batch send failed",{count:r.length,err:String(l)})}let c=o?.authFailures;if(c&&c.length>0&&(wn.warn("heartbeat received authFailures from cloud",{count:c.length,agentIds:c.map(l=>l.agentId)}),this.opts.onAuthFailures))try{await this.opts.onAuthFailures(c)}catch(l){wn.warn("onAuthFailures callback failed (ignored)",{err:String(l)})}}finally{this.inFlight=!1}if(this.opts.onTickEnd)try{await this.opts.onTickEnd()}catch(r){wn.warn("onTickEnd hook failed",{err:String(r)})}}};function I_(t){return t.status==="error"?"error":t.activeTriggers.size>0?"busy":t.status==="ok"?"online":null}rn();import{chmod as Ey,mkdir as wo,rm as vy,stat as Sy,writeFile as Ay}from"node:fs/promises";import{homedir as Iy}from"node:os";import{join as wu}from"node:path";nn();import{existsSync as j_}from"node:fs";import{release as W_}from"node:os";import{basename as K_,isAbsolute as $_}from"node:path";function Pi(t,e,r){return r===void 0?{jsonrpc:"2.0",id:t,method:e}:{jsonrpc:"2.0",id:t,method:e,params:r}}function Sr(t,e){return e===void 0?{jsonrpc:"2.0",method:t}:{jsonrpc:"2.0",method:t,params:e}}function Ar(t,e){return{jsonrpc:"2.0",id:t,result:e}}function _n(t,e){return{jsonrpc:"2.0",id:t,error:e}}Ke();var ao=class extends Error{code;data;constructor(e){super(`JSON-RPC error code=${e.code} ${e.message}`),this.name="RemoteRpcError",this.code=e.code,e.data!==void 0&&(this.data=e.data)}},ee={PARSE_ERROR:-32700,INVALID_REQUEST:-32600,METHOD_NOT_FOUND:-32601,INVALID_PARAMS:-32602,INTERNAL_ERROR:-32603,AGENT_NOT_FOUND:-32001,AGENT_BUSY:-32002,AGENT_TIMEOUT:-32003,AGENT_SPAWN_FAILED:-32004,OPERATION_NOT_ALLOWED_FOR_LOCAL:-32005,AGENT_DISCONNECTED:-32006,MODEL_TOKEN_GEN_FAILED:-32009,PATH_OUTSIDE_WORKSPACE:-32010,FILE_TOO_LARGE:-32011,UNSUPPORTED_MIME:-32012,UPLOAD_FAILED:-32013,UPSTREAM_NOT_READY:-32014,AGENT_FRAME_IDLE_TIMEOUT:-32016,MODEL_MODALITY_UNSUPPORTED:-32017,AGENT_DEPENDENCY_INSTALL_FAILED:-32018,AGENT_APPROVAL_TIMEOUT:-32019,AGENT_TURN_ABORTED:-32020,AGENT_ENV_NOT_READY:-32021};function K0(t){return"method"in t&&"id"in t&&t.id!==void 0}function $0(t){return"method"in t&&!("id"in t)}function co(t){return!("method"in t)&&"id"in t}var T_={AGENT_NOT_FOUND:ee.AGENT_NOT_FOUND,AGENT_BUSY:ee.AGENT_BUSY,AGENT_DISCONNECTED:ee.AGENT_DISCONNECTED,AGENT_TIMEOUT:ee.AGENT_TIMEOUT,AGENT_FRAME_IDLE_TIMEOUT:ee.AGENT_FRAME_IDLE_TIMEOUT,AGENT_SPAWN_FAILED:ee.AGENT_SPAWN_FAILED,AGENT_PROTOCOL_ERROR:ee.INTERNAL_ERROR,BRIDGE_CONFIG_INVALID:ee.INTERNAL_ERROR,BRIDGE_INTERNAL:ee.INTERNAL_ERROR,IPC_AUTH_FAILED:ee.INTERNAL_ERROR,IPC_BAD_REQUEST:ee.INVALID_REQUEST,MODEL_TOKEN_GEN_FAILED:ee.MODEL_TOKEN_GEN_FAILED,MODEL_MODALITY_UNSUPPORTED:ee.MODEL_MODALITY_UNSUPPORTED,OPERATION_NOT_ALLOWED_FOR_LOCAL:ee.OPERATION_NOT_ALLOWED_FOR_LOCAL,UPSTREAM_DISCONNECTED:ee.INTERNAL_ERROR,UPSTREAM_HANDSHAKE_FAILED:ee.INTERNAL_ERROR,PATH_OUTSIDE_WORKSPACE:ee.PATH_OUTSIDE_WORKSPACE,FILE_TOO_LARGE:ee.FILE_TOO_LARGE,UNSUPPORTED_MIME:ee.UNSUPPORTED_MIME,UPLOAD_FAILED:ee.UPLOAD_FAILED,UPSTREAM_NOT_READY:ee.UPSTREAM_NOT_READY,AGENT_DEPENDENCY_INSTALL_FAILED:ee.AGENT_DEPENDENCY_INSTALL_FAILED,AGENT_APPROVAL_TIMEOUT:ee.AGENT_APPROVAL_TIMEOUT,AGENT_TURN_ABORTED:ee.AGENT_TURN_ABORTED,AGENT_ENV_NOT_READY:ee.AGENT_ENV_NOT_READY};function C_(t){if(t!=null)return t instanceof Error?{name:t.name,message:Ni(t.message)}:typeof t=="string"?Ni(t):typeof t=="object"?D_(t):t}var R_=[[/\/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 Ni(t){let e=t;for(let[r,i]of R_)e=e.replace(r,i);return e}function D_(t){let e={};for(let[r,i]of Object.entries(t))typeof i=="string"?e[r]=Ni(i):e[r]=i;return e}function Li(t){if(t instanceof T){let e=C_(t.cause),r={bridgeCode:t.code,retriable:t.retriable};return e!==void 0&&(r.cause=e),e&&typeof e=="object"&&"reason"in e&&typeof e.reason=="string"&&(r.reason=e.reason),{code:T_[t.code]??ee.INTERNAL_ERROR,message:Ni(t.message),data:r}}return{code:ee.INTERNAL_ERROR,message:Ni(t instanceof Error?t.message:String(t))}}function V0(t){let e=t.data,r=e?.bridgeCode??"AGENT_PROTOCOL_ERROR",i=!!e&&typeof e.message=="string"&&!!e.message,o=i?e?.message:t.message,c=t.data;if(i&&e){let{message:l,...f}=e;c=f}return new T(r,o,{retriable:e?.retriable??!1,cause:c})}function J0(t){return`${JSON.stringify(t)}
|
|
93
|
-
`}var
|
|
94
|
-
`);this.buffer=r.pop()??"";let i=[];for(let o of r){let c=o.replace(/\r$/,"").trim();if(c)try{i.push(JSON.parse(c))}catch(l){this.onError?.({line:c,error:l})}}return i}flush(){if(!this.buffer)return[];let e=this.buffer.replace(/\r$/,"").trim();if(this.buffer="",!e)return[];try{return[JSON.parse(e)]}catch(r){return this.onError?.({line:e,error:r}),[]}}};var X0={"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"},wI=Object.fromEntries(Object.entries(X0).map(([t,e])=>[e,t])),k_={"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:[]},Ir=class{seq=0;next(e,r){this.seq+=1;let i=X0[e]??O_(e),o=k_[i]??[],c=[i,String(this.seq)];if(o.length>0){let l=o.map(x=>Z0(r?.[x]??"")),f=P_(l).join(":");f&&c.push(f)}else r&&Object.values(r).some(l=>l)&&c.push(Object.values(r).filter(Boolean).map(l=>Z0(String(l))).join(":"));return c.join("_")}reset(){this.seq=0}};function O_(t){return t.replace(/[\s/]+/g,".").replace(/_+/g,"-")}function Z0(t){return t.replace(/[:_\s]+/g,"-")}function P_(t){let e=t.length;for(;e>0&&!t[e-1];)e-=1;return t.slice(0,e)}Qr();import{readFileSync as N_}from"node:fs";var L_=384;async function Zc(t,e=process.env){let r={};for(let[i,o]of Object.entries(e))typeof o=="string"&&(r[i]=o);await nr(t.agentEnvFile,r,{mode:L_})}function Xc(t){try{let e=JSON.parse(N_(t,"utf8"));return e&&typeof e=="object"&&!Array.isArray(e)?e:{}}catch{return{}}}function Q0(t,e,r={},i=o=>o){return{...i({...t,...Xc(e)}),...r}}yn();$r();Ke();ne();ke();import{spawnSync as q_}from"node:child_process";function fo(t){try{return process.kill(t,0),!0}catch(e){return e.code==="EPERM"}}function uo(t,e){if(!(typeof t!="number"||t<=0))try{if(process.platform==="win32"){let r=["/PID",String(t),"/T"];e==="SIGKILL"&&r.push("/F"),q_("taskkill",r,{stdio:"ignore",windowsHide:!0})}else process.kill(-t,e)}catch{}}var Qc=new Set;function ru(t){typeof t=="number"&&t>0&&Qc.add(t)}function iu(t){typeof t=="number"&&Qc.delete(t)}function su(){for(let t of Qc)uo(t,"SIGKILL")}var H_=[{reason:"openclaw_scope_approval_pending",bridgeCode:"AGENT_ENV_NOT_READY",frameworks:["openclaw"],match:/scope upgrade pending approval/i,message:"openclaw \u9700\u8981\u4F60\u5728\u672C\u673A\u6279\u51C6\u4E00\u6B21\u6743\u9650\u5347\u7EA7 (scope upgrade)\uFF0C\u8BF7\u5728\u672C\u673A openclaw \u5B8C\u6210\u6388\u6743\u540E\u91CD\u8BD5"},{reason:"openclaw_pairing_required",bridgeCode:"AGENT_ENV_NOT_READY",frameworks:["openclaw"],match:/pairing required/i,message:"openclaw \u5C1A\u672A\u5B8C\u6210\u914D\u5BF9\uFF0C\u8BF7\u5148\u5728\u672C\u673A\u5B8C\u6210 openclaw \u914D\u5BF9\u540E\u91CD\u8BD5"},{reason:"openclaw_gateway_token_unavailable",bridgeCode:"AGENT_ENV_NOT_READY",frameworks:["openclaw"],match:/gateway\.auth\.token.*(unavailable|secret reference)/i,message:"openclaw gateway token \u914D\u7F6E\u4E0D\u53EF\u7528 (\u914D\u6210\u4E86 secret \u5F15\u7528\u4F46\u5F53\u524D\u8DEF\u5F84\u53D6\u4E0D\u5230)\uFF0C\u8BF7\u68C0\u67E5\u672C\u673A openclaw \u7684 gateway.auth.token \u914D\u7F6E"},{reason:"openclaw_version_mismatch",bridgeCode:"AGENT_ENV_NOT_READY",frameworks:["openclaw"],match:/protocol mismatch/i,message:"openclaw \u7248\u672C\u4E0E\u672C\u673A gateway \u4E0D\u517C\u5BB9 (protocol mismatch)\uFF0C\u8BF7\u5347\u7EA7\u672C\u673A openclaw \u5230\u6700\u65B0\u7248\u540E\u91CD\u8BD5"},{reason:"openclaw_gateway_not_ready",bridgeCode:"AGENT_ENV_NOT_READY",frameworks:["openclaw"],match:/gateway closed (before ready|\(\d+\))/i,message:"openclaw gateway \u672A\u5C31\u7EEA (\u53EF\u80FD\u6B63\u5728\u542F\u52A8)\uFF0C\u8BF7\u7A0D\u540E\u91CD\u8BD5"},{reason:"openclaw_config_invalid",bridgeCode:"AGENT_ENV_NOT_READY",frameworks:["openclaw"],match:/OpenClaw config is invalid|Config invalid|Invalid config at|config was written by version/i,message:"\u4F60\u7684\u672C\u673A openclaw \u914D\u7F6E\u975E\u6CD5 (~/.openclaw/openclaw.json)\uFF0C\u8BF7\u8FD0\u884C `openclaw doctor --fix` \u6216 `openclaw config validate` \u4FEE\u590D\u540E\u91CD\u8BD5"},{reason:"openclaw_tls_self_signed",bridgeCode:"AGENT_ENV_NOT_READY",frameworks:["openclaw"],match:/self-signed certificate/i,message:"openclaw \u8FDE\u63A5\u88AB\u81EA\u7B7E\u8BC1\u4E66/\u4F01\u4E1A\u4EE3\u7406\u62E6\u622A (self-signed certificate)\uFF0C\u8BF7\u68C0\u67E5\u672C\u673A\u7F51\u7EDC/\u4EE3\u7406\u6216\u8BC1\u4E66\u914D\u7F6E\u540E\u91CD\u8BD5"},{reason:"openclaw_node_binary_not_found",bridgeCode:"AGENT_ENV_NOT_READY",frameworks:["openclaw"],match:/\[qclaw-cli\] Error: Node binary not found/i,message:"\u672C\u673A\u627E\u4E0D\u5230 node \u4E8C\u8FDB\u5236 (qclaw \u542F\u52A8\u5931\u8D25)\uFF0C\u8BF7\u68C0\u67E5\u672C\u673A Node \u5B89\u88C5\u4E0E PATH \u540E\u91CD\u8BD5"},{reason:"openclaw_gateway_unavailable",bridgeCode:"AGENT_ENV_NOT_READY",frameworks:["openclaw"],match:/ECONNREFUSED|\[object ErrorEvent\]|gateway connect failed|gateway (not connected|disconnected)/i,message:"openclaw gateway \u672A\u8FD0\u884C/\u672A\u8FDE\u63A5 (\u8FDE\u63A5\u672C\u673A gateway \u88AB\u62D2\u6216\u4F1A\u8BDD\u671F\u95F4\u65AD\u5F00)\uFF0C\u8BF7\u5728\u672C\u673A\u542F\u52A8 openclaw gateway \u540E\u91CD\u8BD5"},{reason:"openclaw_shim_bug",bridgeCode:"AGENT_SPAWN_FAILED",frameworks:["openclaw"],match:/openclaw-shim\/bin\/openclaw.*unbound variable/i,message:"openclaw \u542F\u52A8 shim \u811A\u672C\u5F02\u5E38 (unbound variable)\uFF0C\u8BF7\u53CD\u9988\u73AF\u5883\u7EF4\u62A4\u65B9\u4FEE\u590D shim"},{reason:"codex_user_config_invalid",bridgeCode:"AGENT_ENV_NOT_READY",frameworks:["codex"],match:/error loading config:.*config\.toml|model_catalog_json|wire_api/i,message:"\u4F60\u7684\u672C\u673A ~/.codex/config.toml \u914D\u7F6E\u6709\u8BEF\uFF0C\u8BF7\u6309 codex \u62A5\u9519\u63D0\u793A\u4FEE\u6B63\u540E\u91CD\u8BD5"},{reason:"codex_provider_invalid",bridgeCode:"AGENT_ENV_NOT_READY",frameworks:["codex"],match:/error loading config: Model provider .* not found/i,message:"\u4F60\u7684\u672C\u673A codex \u914D\u7F6E\u5F15\u7528\u4E86\u4E0D\u5B58\u5728\u7684 model provider\uFF0C\u8BF7\u4FEE\u6B63 ~/.codex \u914D\u7F6E\u540E\u91CD\u8BD5"},{reason:"codex_path_update_failed",bridgeCode:"AGENT_ENV_NOT_READY",frameworks:["codex"],match:/could not update PATH[\s\S]*Operation not permitted/i,message:"codex \u56E0\u672C\u673A\u6743\u9650\u9650\u5236\u65E0\u6CD5\u66F4\u65B0 PATH/\u8BFB\u53D6\u914D\u7F6E (Operation not permitted)\uFF0C\u8BF7\u68C0\u67E5 ~/.codex \u76EE\u5F55\u6743\u9650\u6216\u91CD\u65B0\u6388\u4E88\u7EC8\u7AEF\u5B8C\u5168\u78C1\u76D8\u8BBF\u95EE\u540E\u91CD\u8BD5"},{reason:"codex_acp_exec_failed",bridgeCode:"AGENT_SPAWN_FAILED",frameworks:["codex"],match:/Failed to execute[\s\S]*codex-acp|spawnSync[\s\S]*codex-acp/i,message:"codex ACP \u4E8C\u8FDB\u5236\u6267\u884C\u5931\u8D25\uFF0C\u8BF7\u91CD\u65B0\u6267\u884C pair/connect \u89E6\u53D1\u4F9D\u8D56\u5B89\u88C5"},{reason:"codex_platform_binary_missing",bridgeCode:"AGENT_SPAWN_FAILED",frameworks:["codex"],match:/Failed to locate @zed-industries\/codex-acp|optional dependency was not installed|\.resolve is not a function/i,message:"codex ACP \u4F9D\u8D56\u7684\u5E73\u53F0\u4E8C\u8FDB\u5236\u7F3A\u5931\uFF0C\u8BF7\u91CD\u65B0\u6267\u884C pair/connect \u89E6\u53D1\u4F9D\u8D56\u5B89\u88C5"},{reason:"node_version_too_old",bridgeCode:"AGENT_ENV_NOT_READY",frameworks:["claude-code","openclaw"],match:/import .* with \{ type: ["']json["'] \}|import assertion|import attribute|openclaw\.mjs[\s\S]*Unexpected token '\.'/i,message:"\u672C\u673A Node \u7248\u672C\u8FC7\u4F4E (ACP \u9700\u8981\u8F83\u65B0 Node \u624D\u652F\u6301 import attributes / \u53EF\u9009\u94FE)\uFF0C\u8BF7\u5347\u7EA7 Node \u5230 \u2265 20.10 \u540E\u91CD\u8BD5"},{reason:"acp_cmd_misexec",bridgeCode:"AGENT_SPAWN_FAILED",frameworks:["claude-code"],match:/claude-agent-acp\.cmd.*@ECHO off|\.cmd:\d+/i,message:"claude ACP wrapper \u542F\u52A8\u65B9\u5F0F\u5F02\u5E38 (Windows .cmd \u88AB\u8BEF\u5F53\u811A\u672C\u6267\u884C)\uFF0C\u8BF7\u91CD\u65B0\u6267\u884C pair/connect"}];function ou(t,e){if(!e)return null;for(let r of H_)if(!(r.frameworks&&!r.frameworks.includes(t))&&r.match.test(e))return{bridgeCode:r.bridgeCode,reason:r.reason,message:r.message};return null}function au(t,e){return ou(t,e)}function cu(t,e){return ou(t,e)}function Tr(t,e,r){return!e&&r.firstUpdateMs>0&&t<r.firstUpdateMs?Math.max(1,r.firstUpdateMs-t):t<r.phase2GateMs?Math.max(1,r.phase2GateMs-t):Math.max(1,r.livenessWindowMs)}function du(t,e,r){let o=r-t.armedAt-t.expectedIntervalMs;if(o>e.suspendThresholdMs){let h=t.suspendedMs+o,_=r-t.startedAt-h;return{action:"suspend",suspendedDeltaMs:o,rearmMs:Tr(_,t.firstFrameSeen,e)}}let c=r-t.startedAt-t.suspendedMs,l=t.awaitingApproval?e.approvalMaxMs:e.absoluteMaxMs;return c>=l?{action:"reject-backstop",awaitingApproval:t.awaitingApproval}:t.firstFrameSeen?c<e.phase2GateMs?{action:"continue",rearmMs:Tr(c,!0,e)}:r-t.lastActivityAt<e.livenessWindowMs||t.hasActiveTool||t.awaitingApproval?{action:"continue",rearmMs:Tr(c,!0,e)}:{action:"reject-idle"}:e.firstUpdateMs>0&&c>=e.firstUpdateMs&&!t.awaitingApproval?{action:"reject-idle"}:{action:"continue",rearmMs:Tr(c,!1,e)}}var lu=Je("COZE_BRIDGE_INITIALIZE_TIMEOUT_MS",3e4),V_=200,Y_=40,J_=Je("COZE_BRIDGE_SESSION_PROMPT_MAX_MS",3600*1e3),Z_=Je("COZE_BRIDGE_SESSION_PROMPT_IDLE_MS",600*1e3),X_=Je("COZE_BRIDGE_SESSION_PROMPT_ABSOLUTE_MAX_MS",7200*1e3),Q_=Je("COZE_BRIDGE_SUSPEND_THRESHOLD_MS",60*1e3),ey=Je("COZE_BRIDGE_SESSION_PROMPT_FIRST_UPDATE_MS",600*1e3),ty=Je("COZE_BRIDGE_SESSION_PROMPT_APPROVAL_MAX_MS",1440*60*1e3),fu=500;function ny(t){try{let e=JSON.stringify(t);return e===void 0||e.length<=fu?t:`${e.slice(0,fu)}...<truncated, total ${e.length} chars>`}catch{return"<unserializable>"}}function ry(t){let e=[];typeof t.message=="string"&&e.push(t.message);let{data:r}=t;if(typeof r=="string")e.push(r);else if(r&&typeof r=="object")try{e.push(JSON.stringify(r))}catch{}return e.join(" ")}function uu(t){try{return j_(t)}catch{return}}function iy(t,e){return{platform:process.platform,osRelease:W_(),code:t.code,errno:t.errno,syscall:t.syscall,errPath:t.path,command:e.command,commandExists:$_(e.command)?uu(e.command):void 0,cwd:e.cwd,cwdExists:uu(e.cwd),envKeys:e.envKeys}}function sy(t,e){return`${t.message} [diag: platform=${e.platform} os=${e.osRelease} code=${e.code} errno=${e.errno} syscall=${e.syscall} cmd=${K_(e.command)} cmdExists=${e.commandExists} cwdExists=${e.cwdExists} envKeys=${e.envKeys}]`}var Ot=class{constructor(e){this.opts=e;this.log=j(`downstream.${this.constructor.name}`,this.opts.agentId),this.decoder=new lo({onError:r=>this.log.warn("decode line failed",{line:r.line})})}opts;child;decoder;pending=new Map;inflightAgentRequests=new Map;idAllocator=new Ir;updateHandlers=[];agentRequestHandlers=[];exitHandlers=[];log;stopped=!1;stopReason;stderrRing=[];now=Date.now;sanitizeEnv(e){return e}async start(){if(this.child)throw new T("BRIDGE_INTERNAL","Downstream already started");let e=process.platform!=="win32",r=Q0(process.env,this.opts.agentEnvFile??X().agentEnvFile,this.opts.env,o=>this.sanitizeEnv(o)),i=dt(this.opts.command,this.opts.args,{cwd:this.opts.cwd,env:r,stdio:["pipe","pipe","pipe"],detached:e});this.child=i,ru(i.pid),i.stdout?.setEncoding("utf8"),i.stdout?.on("data",o=>{try{for(let c of this.decoder.push(o))this.dispatch(c)}catch(c){this.log.warn("stdout dispatch threw, swallowed to keep daemon alive",{err:String(c)})}}),i.stderr?.setEncoding("utf8"),i.stderr?.on("data",o=>{let c=o.trimEnd();this.stderrRing.push(c),this.stderrRing.length>V_&&this.stderrRing.shift(),this.log.debug("stderr",{text:c})}),i.stdin?.on("error",o=>{this.log.warn("child stdin error",{err:String(o)})}),i.stdout?.on("error",o=>{this.log.warn("child stdout error",{err:String(o)})}),i.stderr?.on("error",o=>{this.log.warn("child stderr error",{err:String(o)})}),i.on("exit",(o,c)=>{this.stopped=!0,iu(i.pid),(o!==0||c!==null)&&this.stderrRing.length>0&&this.log.warn("downstream exited abnormally, recent stderr",{code:o,signal:c,recentStderr:[...this.stderrRing]});try{for(let f of this.decoder.flush())this.dispatch(f)}catch(f){this.log.debug("decoder.flush on exit threw (ignored)",{err:String(f)})}this.failAllPending(this.buildExitError(o,c));for(let f of this.exitHandlers)f(o,c)}),i.on("error",o=>{let c=o,l=iy(c,{command:this.opts.command,cwd:this.opts.cwd,envKeys:Object.keys(r).length});this.log.error("child error",{err:String(o),diag:l}),this.failAllPending(new T("AGENT_SPAWN_FAILED",sy(c,l),{cause:l}))}),this.log.info("downstream started",{command:this.opts.command,pid:i.pid,cwd:this.opts.cwd})}async stop(e){if(!this.child||this.stopped)return;this.stopped=!0,this.stopReason=e??"stopped",this.log.info("downstream stopping",{reason:e});let r=this.child,i=new Promise(c=>r.once("exit",()=>c()));uo(r.pid,"SIGTERM");let o=setTimeout(()=>{r.killed||uo(r.pid,"SIGKILL")},5e3);try{await i}finally{clearTimeout(o)}}pid(){return this.child?.pid}isAlive(){return!!this.child&&!this.stopped}getStderrTail(e){return e===void 0?[...this.stderrRing]:this.stderrRing.slice(-e)}initialize(e){return this.call("initialize",e)}sessionNew(e){return this.call("session/new",{mcpServers:[],...e})}sessionLoad(e){return this.call("session/load",{mcpServers:[],...e})}sessionPrompt(e,r){let i={firstUpdateMs:ey,phase2GateMs:J_,livenessWindowMs:Z_,absoluteMaxMs:X_,approvalMaxMs:ty,suspendThresholdMs:Q_,...r};return this.call("session/prompt",e,lu,i)}async sessionCancel(e){!this.child||this.stopped||this.writeFrame(Sr("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(Ar(e,r))}catch(i){this.log.warn("respondAgentRequest write failed",{id:e,err:String(i)})}}respondAgentRequestError(e,r){if(this.inflightAgentRequests.delete(e),!(!this.child||this.stopped))try{this.writeFrame(_n(e,r))}catch(i){this.log.warn("respondAgentRequestError write failed",{id:e,err:String(i)})}}onExit(e){this.exitHandlers.push(e)}call(e,r,i=lu,o){if(!this.child||this.stopped)return Promise.reject(new T("AGENT_PROTOCOL_ERROR","downstream not started"));let c=this.idAllocator.next(e),l=Pi(c,e,r),f=(()=>{if(typeof r!="object"||r===null)return;let x=r.sessionId;return typeof x=="string"?x:void 0})();return new Promise((x,h)=>{let _={resolve:x,reject:h,timer:null,method:e,promptTimeout:null};if(o){let w=this.now(),S={cfg:o,startedAt:w,lastActivityAt:w,firstFrameSeen:!1,activeToolCalls:new Set,suspendedMs:0,armedAt:w,expectedIntervalMs:Tr(0,!1,o),sessionId:f};_.promptTimeout=S;let b=()=>{let v={startedAt:S.startedAt,lastActivityAt:S.lastActivityAt,firstFrameSeen:S.firstFrameSeen,hasActiveTool:S.activeToolCalls.size>0,awaitingApproval:this.inflightAgentRequests.size>0,suspendedMs:S.suspendedMs,armedAt:S.armedAt,expectedIntervalMs:S.expectedIntervalMs},I=this.now(),A=du(v,S.cfg,I),C=P=>{S.armedAt=I,S.expectedIntervalMs=P,_.timer=setTimeout(b,P)};if(A.action==="suspend"){S.suspendedMs+=A.suspendedDeltaMs,S.lastActivityAt=I,this.log.warn("downstream prompt timer: suspend detected",{id:c,method:e,gapMs:A.suspendedDeltaMs,suspendedMs:S.suspendedMs,...S.sessionId?{sessionId:S.sessionId}:{}}),C(A.rearmMs);return}if(A.action==="continue"){C(A.rearmMs);return}this.pending.delete(c),A.action==="reject-backstop"?(this.log.warn("downstream prompt absolute timeout",{id:c,method:e,awaitingApproval:A.awaitingApproval,...S.sessionId?{sessionId:S.sessionId}:{}}),h(A.awaitingApproval?new T("AGENT_APPROVAL_TIMEOUT",`${e} awaiting permission timed out after ${S.cfg.approvalMaxMs}ms`):new T("AGENT_TIMEOUT",`${e} timed out after ${S.cfg.absoluteMaxMs}ms`))):(this.log.warn("downstream prompt idle timeout",{id:c,method:e,...S.sessionId?{sessionId:S.sessionId}:{}}),h(new T("AGENT_FRAME_IDLE_TIMEOUT",`${e} no progress within ${S.cfg.livenessWindowMs}ms`)))};_.timer=setTimeout(b,S.expectedIntervalMs)}else i>0&&Number.isFinite(i)&&(_.timer=setTimeout(()=>{this.pending.delete(c),this.log.warn("downstream call timeout",{id:c,method:e,timeoutMs:i}),h(new T("AGENT_TIMEOUT",`${e} timed out after ${i}ms`))},i));this.pending.set(c,_);try{this.writeFrame(l)}catch(w){_.timer&&clearTimeout(_.timer),this.pending.delete(c),h(w)}})}writeFrame(e){if(!this.child?.stdin||this.child.stdin.destroyed)throw new T("AGENT_PROTOCOL_ERROR","downstream stdin not writable");this.child.stdin.write(J0(e),r=>{r&&this.log.warn("stdin write callback err",{err:String(r)})})}dispatch(e){if(co(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),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(this.wireErrorToBridge(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:ny(e.result)}),r.resolve(e.result));return}if($0(e)){if(e.method==="session/update"){let r=e.params;for(let i of this.pending.values()){let o=i.promptTimeout;o&&(o.firstFrameSeen=!0,o.lastActivityAt=this.now(),this.trackToolCall(o,r))}for(let i of this.updateHandlers)try{Promise.resolve(i(r)).catch(o=>this.log.warn("update handler failed (async)",{err:String(o)}))}catch(o){this.log.warn("update handler threw sync, swallowed",{err:String(o)})}}else this.log.info("unknown notification (drop, not forwarded)",{method:e.method});return}if(K0(e)){let r=e;try{this.handleAgentRequest(r).catch(i=>this.log.error("agent request handler failed (async)",{method:r.method,err:String(i)}))}catch(i){this.log.warn("handleAgentRequest threw sync, swallowed",{method:r.method,err:String(i)})}}}trackToolCall(e,r){let i=r.update,o=i?.sessionUpdate;if(o!=="tool_call"&&o!=="tool_call_update")return;let c=typeof i.toolCallId=="string"?i.toolCallId:void 0;if(!c)return;let l=typeof i.status=="string"?i.status:void 0,f=l==="completed"||l==="failed"||l==="cancelled";o==="tool_call"&&!f?e.activeToolCalls.add(c):f&&e.activeToolCalls.delete(c)}async handleAgentRequest(e){if(this.agentRequestHandlers.length===0){this.writeFrame(_n(e.id,{code:-32601,message:`method not handled by Bridge: ${e.method}`}));return}this.inflightAgentRequests.set(e.id,e.method);for(let r of this.agentRequestHandlers)try{await r(e)}catch(i){this.log.error("agentRequestHandler threw",{method:e.method,err:String(i)});try{this.writeFrame(_n(e.id,Li(i)))}catch{}this.inflightAgentRequests.delete(e.id)}}wireErrorToBridge(e){let r=V0(e);if(r.code!=="AGENT_PROTOCOL_ERROR")return r;let i=cu(this.framework,ry(e));return i?new T(i.bridgeCode,i.message,{cause:{reason:i.reason,wireCode:e.code,wireMessage:e.message,wireData:e.data}}):r}buildExitError(e,r){if(this.stopReason!==void 0)return new T("AGENT_TURN_ABORTED",`turn aborted: ${this.stopReason}`,{cause:{reason:this.stopReason}});let i=this.getStderrTail(Y_).join(`
|
|
95
|
-
`),o=au(this.framework,i);return o?new T(o.bridgeCode,o.message,{cause:{reason:o.reason,code:e,signal:r,stderrTail:i}}):new T("AGENT_PROTOCOL_ERROR",`agent exited (${e}/${r})`,{cause:{code:e,signal:r,stderrTail:i}})}failAllPending(e){for(let r of this.pending.values())r.timer&&clearTimeout(r.timer),r.reject(e);this.pending.clear(),this.inflightAgentRequests.clear()}};function oy(t){let e={};for(let[r,i]of Object.entries(t))i!==void 0&&(r.startsWith("CLAUDE")||r==="AI_AGENT"||r==="BAGGAGE"||(e[r]=i));return e}var xo=class extends Ot{framework="claude-code";constructor(e){let{command:r,args:i}=Xr("claude-code",e.command,e.args??[]),o={command:r,args:i,cwd:e.cwd,agentId:e.agentId,...e.env?{env:e.env}:{}};super(o)}sanitizeEnv(e){return oy(e)}};nn();import{mkdtempSync as ay,rmSync as cy}from"node:fs";import{tmpdir as dy}from"node:os";import{join as ly}from"node:path";var ho=class extends Ot{framework="codex";authMethodId;codexHomeDir;constructor(e){let r=e.args??[],i=e.extraArgs?[...r,...e.extraArgs]:r,{command:o,args:c}=Xr("codex",e.command,i),l=e.isolateCodexHome?ay(ly(dy(),"coze-bridge-codex-home-")):void 0,f=l?{...e.env??{},CODEX_HOME:l}:e.env,x={command:o,args:c,cwd:e.cwd,agentId:e.agentId,...f?{env:f}:{}};super(x),this.authMethodId=e.authMethodId,this.codexHomeDir=l}async initialize(e){let 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{cy(this.codexHomeDir,{recursive:!0,force:!0})}catch{}}};var fy=3e4,Cr=class extends Ot{framework="openclaw";agentId;sessionName;slashModelOnStart;constructor(e){let r=e.sessionName??"default",i=["acp","--session",`agent:${e.agentId}:${r}`];e.gatewayToken&&i.push("--token",e.gatewayToken);let o={command:e.command,args:i,cwd:e.cwd,agentId:e.agentId,...e.env?{env:e.env}:{}};super(o),this.agentId=e.agentId,this.sessionName=r,this.slashModelOnStart=e.slashModelOnStart}async afterSessionEstablished(e){this.slashModelOnStart&&(this.log.info("switching session to per-session provider via /model",{agentId:this.agentId,sessionName:this.sessionName,slash:this.slashModelOnStart}),await this.call("session/prompt",{sessionId:e,prompt:[{type:"text",text:`/model ${this.slashModelOnStart}`}]},fy))}get acpSessionName(){return this.sessionName}};Ke();ne();ke();function ed(t){return t.replace(/[^A-Za-z0-9._-]+/g,"-")}nn();var bn=class{slots=[];running=!1;closed=!1;disposed=!1;enqueue(e){return this.disposed?Promise.reject(new Error("AsyncQueue disposed")):this.closed?Promise.reject(new Error("AsyncQueue closed")):new Promise((r,i)=>{this.slots.push({task:e,resolve:r,reject:i}),this.drain()})}close(){this.closed=!0}dispose(e=new Error("AsyncQueue disposed")){for(this.disposed=!0,this.closed=!0;this.slots.length>0;)this.slots.shift()?.reject(e)}get size(){return this.slots.length}get isRunning(){return this.running}get isDisposed(){return this.disposed}async drain(){if(!this.running){this.running=!0;try{for(;this.slots.length>0&&!this.disposed;){let e=this.slots.shift();if(!e)break;try{let r=await e.task();e.resolve(r)}catch(r){e.reject(r)}}}finally{this.running=!1}}}};var po=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 bn,this.sessionQueues.set(e,r)),r}allSessionQueues(){return this.sessionQueues.entries()}hasSessionQueue(e){let r=this.sessionQueues.get(e);return!!r&&!r.isDisposed}async dispose(e){this.status="stopped";let r=new Error(`AgentSession disposed${e?`: ${e}`:""}`);for(let i of this.sessionQueues.values())i.dispose(r);this.sessionQueues.clear(),await this.killAllRuntimes(e??"dispose")}async killAllRuntimes(e){let r=[];for(let[,i]of this.sessions)Mi(i),i.downstream&&(r.push(i.downstream.stop(e).catch(()=>{})),i.downstream=void 0);await Promise.all(r),this.activeTriggers.clear(),this.activeGroupIds.clear()}};function Mi(t){t.idleTimer&&(clearTimeout(t.idleTimer),t.idleTimer=void 0)}yn();ne();import{constants as xu}from"node:fs";import{access as uy}from"node:fs/promises";import{delimiter as xy,join as hy}from"node:path";var bt=j("framework-detector"),hu={"claude-code":"claude",codex:"codex",openclaw:"openclaw"},py=[".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??dt,access:e.access??uy}}async detect(e){let r=hu[e],i=await this.which(r);if(!i)return bt.debug("framework binary not found",{framework:e,bin:r}),null;let o=e==="openclaw"?["--log-level","silent"]:[],[c,l]=await Promise.all([this.probeVersion(i,o),e==="openclaw"?this.probeOpenclawDefaultAgent(i):Promise.resolve(null)]),f={path:i,version:c};return l&&(f.defaultAgent=l),f}async detectAll(){let e=await Promise.all(Object.keys(hu).map(async i=>[i,await this.detect(i)])),r={};for(let[i,o]of e)o&&(r[i]=o);return r}async which(e){let r=this.env.pathEnv.split(xy).filter(Boolean),i=this.env.platform==="win32"?["",...py]:[""];for(let o of r)for(let c of i){let l=hy(o,e+c);if(await this.isExecutable(l))return l}return null}async isExecutable(e){try{let r=this.env.platform==="win32"?xu.F_OK:xu.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 bt.warn("openclaw default agent probe: runProbe returned null (spawn err / timeout)",{path:e}),null;if(r.code!==0)return bt.warn("openclaw default agent probe: non-zero exit",{path:e,code:r.code,stdoutHead:r.stdout.slice(0,200)}),null;let i=r.stdout.match(/\[\s*\{[\s\S]*\}\s*\]/);if(!i)return bt.warn("openclaw default agent probe: regex no match (no JSON array in stdout)",{path:e,stdoutHead:r.stdout.slice(0,200)}),null;try{let o=JSON.parse(i[0]);if(!Array.isArray(o))return bt.warn("openclaw default agent probe: JSON parsed but not an array",{path:e}),null;let c=o.find(l=>l?.isDefault===!0);return c?!c.id||!c.workspace?(bt.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}:(bt.info("openclaw default agent probe: no agent has isDefault=true",{path:e,agentCount:o.length}),null)}catch(o){return bt.warn("openclaw default agent probe: JSON.parse failed",{path:e,err:String(o),matchHead:i[0].slice(0,200)}),null}}async probeOpenclawGateway(e){let r=await this.runProbe(e,["--log-level","silent","gateway","status","--json","--require-rpc","--timeout","5000"]);if(!r)return bt.warn("openclaw gateway probe: runProbe returned null (spawn err / timeout)",{path:e}),{reachable:!1};let i=r.code===0;i||bt.warn("openclaw gateway probe: non-zero exit (gateway unreachable)",{path:e,code:r.code,stdoutHead:r.stdout.slice(0,200)});let o={reachable:i},c=r.stdout.match(/\{[\s\S]*\}/);if(c)try{let l=JSON.parse(c[0]);typeof l.gateway?.port=="number"&&(o.port=l.gateway.port),typeof l.service?.runtime?.status=="string"&&(o.runtime=l.service.runtime.status),!i&&typeof l.rpc?.error=="string"&&(o.detail=l.rpc.error)}catch(l){bt.warn("openclaw gateway probe: JSON.parse failed (detail omitted, gate by exit code)",{path:e,err:String(l)})}return o}async probeVersion(e,r=[]){let i=await this.runProbe(e,[...r,"--version"]);return i&&(my(i.stdout).split(/\r?\n/)[0]??"").trim()||"unknown"}runProbe(e,r){return new Promise(i=>{let o="",c=!1,l,f=x=>{c||(c=!0,l&&clearTimeout(l),i(x))};try{let x=this.env.spawn(e,r,{stdio:["ignore","pipe","pipe"]});l=setTimeout(()=>{x.kill("SIGKILL"),f(null)},15e3),x.stdout?.on("data",h=>{o+=h.toString("utf8")}),x.on("error",()=>f(null)),x.on("close",h=>f({code:h,stdout:o}))}catch{f(null)}})}},gy=new RegExp("\x1B\\[[0-9;]*[A-Za-z]","g");function my(t){return t.replace(gy,"")}import{homedir as wy}from"node:os";import{join as _y}from"node:path";yn();$r();Ke();Qr();ne();async function mu(){let t=_y(wy(),".openclaw/openclaw.json");return(await tr(t))?.gateway?.auth?.token??""}var pu=j("openclaw.config"),yy=[0,5e3,5e3],by=Je("COZE_BRIDGE_OPENCLAW_CLI_TIMEOUT_MS",15e3),gu="models.providers.",go="agents.defaults.models",mo=class{command;env;retryDelaysMs;cliTimeoutMs;queue=new bn;constructor(e){this.command=e.command,this.env=e.env??process.env,this.retryDelaysMs=e.retryDelaysMs??yy,this.cliTimeoutMs=e.cliTimeoutMs??by}async withRetry(e,r){let i;for(let o=0;o<this.retryDelaysMs.length;o++){let c=this.retryDelaysMs[o]??0;c>0&&await new Promise(l=>setTimeout(l,c));try{return await r()}catch(l){i=l,pu.warn("openclaw cli failed, will retry",{label:e,attempt:o+1,err:String(l)})}}throw new T("AGENT_SPAWN_FAILED",`openclaw cli ${e} failed after ${this.retryDelaysMs.length} attempts: ${i?.message??"unknown"}`)}runCli(e){return new Promise((r,i)=>{let o=dt(this.command,e,{stdio:["ignore","ignore","pipe"],env:this.env}),c="",l=!1,f=h=>{l||(l=!0,clearTimeout(x),h())};o.stderr?.on("data",h=>{c+=h.toString("utf8")});let x=setTimeout(()=>{f(()=>{o.kill("SIGTERM"),setTimeout(()=>o.kill("SIGKILL"),250).unref(),i(new Error(`timeout after ${this.cliTimeoutMs}ms: ${e.join(" ")}`))})},this.cliTimeoutMs);x.unref(),o.on("error",h=>f(()=>i(h))),o.on("close",h=>f(()=>{h===0?r():i(new Error(`exit ${h}: ${c.trim().slice(0,500)}`))}))})}async runCliTolerant(e,r){try{await this.runCli(e)}catch(i){let o=String(i);if(r.some(c=>o.includes(c)))return;throw i}}async bestEffortUnset(e,r){try{await this.queue.enqueue(()=>this.withRetry(e,()=>this.runCli(["config","unset",r])))}catch(i){pu.warn(`${e} failed (best-effort)`,{configPath:r,err:String(i)})}}ensureProvider(e,r){return this.queue.enqueue(()=>this.withRetry(`config set models.providers.${e}`,()=>this.runCli(["config","set",`${gu}${e}`,JSON.stringify(r),"--strict-json","--merge"])))}removeProvider(e){return this.bestEffortUnset(`config unset models.providers.${e}`,`${gu}${e}`)}addModelToAllowlist(e,r){let i={[e]:r?{alias:r}:{}};return this.queue.enqueue(()=>this.withRetry(`config set ${go}[${e}]`,()=>this.runCli(["config","set",go,JSON.stringify(i),"--strict-json","--merge"])))}removeModelFromAllowlist(e){return this.bestEffortUnset(`config unset ${go}[${e}]`,`${go}.${e}`)}ensureAgent(e,r,i){let o=["agents","add",e,"--workspace",r,"--non-interactive"];return i&&o.push("--model",i),this.queue.enqueue(()=>this.withRetry(`agents add ${e}`,()=>this.runCliTolerant(o,["already exists","already registered"])))}restartGateway(){return this.queue.enqueue(()=>this.withRetry("gateway restart",()=>this.runCli(["gateway","restart"])))}deleteAgent(e){return this.queue.enqueue(()=>this.withRetry(`agents delete ${e}`,()=>this.runCliTolerant(["agents","delete",e,"--force"],["not found","does not exist"])))}};var pe=j("agent-manager"),Ty=(t,e,r,i,o,c,l,f,x)=>{switch(t){case"claude-code":{let h={...o?{...O0(o),...L0(o,l,f)}:{},...x??{},IS_SANDBOX:"1"};return new xo({cwd:r,env:h,agentId:i})}case"codex":{let _=[...o?[...P0(o),...B0(o,l,f)]:[],"-c",'sandbox_mode="danger-full-access"',"-c",'approval_policy="never"'],w={...o?N0(o):{},...x??{}},S=!!o;return new ho({cwd:r,agentId:i,..._.length>0?{extraArgs:_}:{},...Object.keys(w).length>0?{env:w}:{},...S?{authMethodId:"openai-api-key",isolateCodexHome:!0}:{}})}case"openclaw":return new Cr({command:e,cwd:r,agentId:i,...c?{sessionName:ed(c)}:{}})}};function td(t){return t==="claude-code"||t==="codex"}function Cy(t){let e=[],r=Object.keys(t).sort();for(let i of r){let o=t[i];o!==void 0&&(Ry(o)||e.push(`${i}=${o}`))}return e.length===0?"":`${e.join(`
|
|
89
|
+
`},configPath(t){return $1(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 Bx("schtasks",["/Create","/SC","ONLOGON","/TN",na,"/TR",r,"/RU",t.userName,"/F"]),Nd.info("task scheduler entry created",{task:na,logFile:t.logFile})},async uninstall(t){await Bx("schtasks",["/Delete","/TN",na,"/F"]).catch(e=>Nd.warn("schtasks /Delete failed (ignored)",{err:String(e)})),Nd.info("task scheduler entry removed",{task:na})}}});var Fx={};ga(Fx,{buildContext:()=>Q1,getSupervisor:()=>J1,launchdSupervisor:()=>Ld,systemdSupervisor:()=>Od,taskSchedulerSupervisor:()=>Md});import{homedir as V1,userInfo as Z1}from"node:os";function J1(t=process.platform){switch(t){case"darwin":return Ld;case"linux":return Od;case"win32":return Md;default:throw new Error(`unsupported platform for OS supervisor: ${t}`)}}function X1(){let t={};for(let e of Y1){let r=process.env[e];r&&(t[e]=r)}return t}function Q1(){let t=Y();return{nodeBin:process.execPath,entry:Ad(t),logFile:t.logFile,homeDir:V1(),userName:Z1().username,isRoot:process.getuid?.()===0,env:X1()}}var Y1,Ux=Je(()=>{"use strict";Le();Wo();Ox();Mx();zx();Y1=["PATH","HOME","HTTP_PROXY","HTTPS_PROXY","NO_PROXY","ALL_PROXY","http_proxy","https_proxy","no_proxy","all_proxy","NODE_EXTRA_CA_CERTS"]});ne();nn();var hl=G("acp-installer-warmup"),fg=["claude-code","codex"];async function xl(t={}){let e=t.ensure??er,i=(await Promise.allSettled(fg.map(async o=>{let c=await e(o);hl.info("acp wrapper warmup ok",{framework:o,path:c})}))).filter(o=>o.status==="rejected");i.length>0&&hl.warn("acp wrapper warmup partial failure (\u5C06\u5728\u4E0B\u6B21 createAgent \u65F6\u91CD\u8BD5\u5E76\u629B\u9519\u7ED9\u7528\u6237)",{failedCount:i.length,reasons:i.map(o=>o.reason instanceof Error?o.reason.message:String(o.reason))})}rn();ne();import{readdir as Sg}from"node:fs/promises";import{mkdir as yl,writeFile as bl}from"node:fs/promises";import{join as va}from"node:path";var vg={"claude-code":"CLAUDE.md",codex:"AGENTS.md",openclaw:"SOUL.md"};async function rr(t,e,r){await yl(t,{recursive:!0});let i=vg[e],o=va(t,i);return await bl(o,r??"","utf8"),o}async function El(t,e){let r=va(t,".claude");await yl(r,{recursive:!0});let i=va(r,"settings.local.json"),o={permissions:{defaultMode:"bypassPermissions"}};e==="cloud"&&(o.autoCompactWindow=15e4);let c=JSON.stringify(o,null,2);return await bl(i,c,"utf8"),i}var it=G("agent-detail-sync"),Ig=6e4,Ag=5*6e4,ds=class{constructor(e){this.opts=e}opts;retryQueue=new Map;async syncAll(e){let r=this.opts.paths.agentsRoot,i;try{i=await Sg(r)}catch(o){it.info("agents dir not found, skip detail sync",{root:r,err:String(o)});return}it.info("starting detail sync",{reason:e,count:i.length}),await Promise.allSettled(i.map(async o=>{let c=await Be(o,this.opts.paths).catch(()=>null);if(c){if(c.disconnectedAt){it.debug("detail sync: skip disconnected agent",{agentId:o});return}try{await this.syncOne(o,c)}catch(l){it.warn("detail sync failed for agent, skipping",{agentId:o,err:String(l)})}}})),it.info("detail sync done",{reason:e})}async retryPending(){if(this.retryQueue.size===0)return;let e=Date.now(),r=[];for(let[i,o]of this.retryQueue)e>=o.dueAt&&r.push(i);if(r.length!==0){it.info("retrying pending detail syncs",{count:r.length});for(let i of r)try{await this.syncOne(i)}catch(o){it.debug("detail sync retry still failing, will try again",{agentId:i,err:String(o)})}}}async syncOne(e,r){let i=r??await Be(e,this.opts.paths);if(!i){it.info("detail sync: agent config missing, skip",{agentId:e});return}let o;try{o=await this.opts.sendDetail({_meta:{cozeAgentId:e}}),this.retryQueue.delete(e)}catch(u){it.warn("detail RPC failed, using local data",{agentId:e,err:String(u)});let h=this.retryQueue.get(e),x=h?Math.min(h.currentDelay*2,Ag):Ig;this.retryQueue.set(e,{dueAt:Date.now()+x,currentDelay:x});return}if(o.agentId&&o.agentId!==e){it.warn("detail response agentId mismatch, ignoring",{agentId:e,responseAgentId:o.agentId});return}let c=!1,l=!1;if(o.agentName&&o.agentName!==i.agentName&&(i.agentName=o.agentName,c=!0),o.description!==void 0&&o.description!==i.description&&(i.description=o.description,c=!0),o.cozeIdentity&&o.cozeIdentity!==i.cozeIdentity&&(i.cozeIdentity=o.cozeIdentity,c=!0,l=!0),o.deployType&&it.info("detail.deployType",{agentId:e,deployType:o.deployType}),!c){it.debug("detail sync: no diff",{agentId:e});return}await Qe(i,this.opts.paths),it.info("detail sync: config updated",{agentId:e,identityChanged:l,agentName:i.agentName}),l&&(await rr(i.workspace,i.framework,i.cozeIdentity),this.opts.handlers.reloadAgentSessionsPublic(e,"detail-sync"))}};var qf=At(tu(),1);import{lstat as zc,mkdir as Fc,readFile as zf,readdir as s_,rm as o_,stat as a_,writeFile as Uc}from"node:fs/promises";import{dirname as c_,join as Lt,normalize as d_,relative as Hc,resolve as Gc,sep as Ff}from"node:path";import{Readable as Uf}from"node:stream";import{pipeline as Gf}from"node:stream/promises";import Vg from"events";import et from"fs";import{EventEmitter as Ec}from"node:events";import Mu from"node:stream";import{StringDecoder as Zg}from"node:string_decoder";import Fu from"node:path";import pr from"node:fs";import{dirname as cm,parse as dm}from"path";import{EventEmitter as mm}from"events";import rc from"assert";import{Buffer as Bn}from"buffer";import*as ou from"zlib";import wm from"zlib";import{posix as cr}from"node:path";import{basename as Wm}from"node:path";import Gs from"fs";import Dt from"fs";import hu from"path";import{win32 as nw}from"node:path";import yu from"path";import ef from"node:fs";import _w from"node:assert";import{randomBytes as tf}from"node:crypto";import re from"node:fs";import Ne from"node:path";import nf from"fs";import Js from"node:fs";import wi from"node:path";import at from"node:fs";import Aw from"node:fs/promises";import js from"node:path";import{join as xf}from"node:path";import ot from"node:fs";import mf from"node:path";var Kg=Object.defineProperty,$g=(t,e)=>{for(var r in e)Kg(t,r,{get:e[r],enumerable:!0})},nu=typeof process=="object"&&process?process:{stdout:null,stderr:null},Jg=t=>!!t&&typeof t=="object"&&(t instanceof Un||t instanceof Mu||Yg(t)||Xg(t)),Yg=t=>!!t&&typeof t=="object"&&t instanceof Ec&&typeof t.pipe=="function"&&t.pipe!==Mu.Writable.prototype.pipe,Xg=t=>!!t&&typeof t=="object"&&t instanceof Ec&&typeof t.write=="function"&&typeof t.end=="function",Ut=Symbol("EOF"),Gt=Symbol("maybeEmitEnd"),on=Symbol("emittedEnd"),xs=Symbol("emittingEnd"),ti=Symbol("emittedError"),ps=Symbol("closed"),ru=Symbol("read"),gs=Symbol("flush"),iu=Symbol("flushChunk"),gt=Symbol("encoding"),ar=Symbol("decoder"),ze=Symbol("flowing"),ni=Symbol("paused"),fr=Symbol("resume"),Fe=Symbol("buffer"),$e=Symbol("pipes"),Ue=Symbol("bufferLength"),Ca=Symbol("bufferPush"),ms=Symbol("bufferShift"),We=Symbol("objectMode"),Ie=Symbol("destroyed"),Da=Symbol("error"),ka=Symbol("emitData"),su=Symbol("emitEnd"),Pa=Symbol("emitEnd2"),Tt=Symbol("async"),La=Symbol("abort"),ws=Symbol("aborted"),ri=Symbol("signal"),Rn=Symbol("dataListeners"),st=Symbol("discarded"),ii=t=>Promise.resolve().then(t),Qg=t=>t(),em=t=>t==="end"||t==="finish"||t==="prefinish",tm=t=>t instanceof ArrayBuffer||!!t&&typeof t=="object"&&t.constructor&&t.constructor.name==="ArrayBuffer"&&t.byteLength>=0,nm=t=>!Buffer.isBuffer(t)&&ArrayBuffer.isView(t),Bu=class{src;dest;opts;ondrain;constructor(t,e,r){this.src=t,this.dest=e,this.opts=r,this.ondrain=()=>t[fr](),this.dest.on("drain",this.ondrain)}unpipe(){this.dest.removeListener("drain",this.ondrain)}proxyErrors(t){}end(){this.unpipe(),this.opts.end&&this.dest.end()}},rm=class extends Bu{unpipe(){this.src.removeListener("error",this.proxyErrors),super.unpipe()}constructor(t,e,r){super(t,e,r),this.proxyErrors=i=>this.dest.emit("error",i),t.on("error",this.proxyErrors)}},im=t=>!!t.objectMode,sm=t=>!t.objectMode&&!!t.encoding&&t.encoding!=="buffer",Un=class extends Ec{[ze]=!1;[ni]=!1;[$e]=[];[Fe]=[];[We];[gt];[Tt];[ar];[Ut]=!1;[on]=!1;[xs]=!1;[ps]=!1;[ti]=null;[Ue]=0;[Ie]=!1;[ri];[ws]=!1;[Rn]=0;[st]=!1;writable=!0;readable=!0;constructor(...t){let e=t[0]||{};if(super(),e.objectMode&&typeof e.encoding=="string")throw new TypeError("Encoding and objectMode may not be used together");im(e)?(this[We]=!0,this[gt]=null):sm(e)?(this[gt]=e.encoding,this[We]=!1):(this[We]=!1,this[gt]=null),this[Tt]=!!e.async,this[ar]=this[gt]?new Zg(this[gt]):null,e&&e.debugExposeBuffer===!0&&Object.defineProperty(this,"buffer",{get:()=>this[Fe]}),e&&e.debugExposePipes===!0&&Object.defineProperty(this,"pipes",{get:()=>this[$e]});let{signal:r}=e;r&&(this[ri]=r,r.aborted?this[La]():r.addEventListener("abort",()=>this[La]()))}get bufferLength(){return this[Ue]}get encoding(){return this[gt]}set encoding(t){throw new Error("Encoding must be set at instantiation time")}setEncoding(t){throw new Error("Encoding must be set at instantiation time")}get objectMode(){return this[We]}set objectMode(t){throw new Error("objectMode must be set at instantiation time")}get async(){return this[Tt]}set async(t){this[Tt]=this[Tt]||!!t}[La](){this[ws]=!0,this.emit("abort",this[ri]?.reason),this.destroy(this[ri]?.reason)}get aborted(){return this[ws]}set aborted(t){}write(t,e,r){if(this[ws])return!1;if(this[Ut])throw new Error("write after end");if(this[Ie])return this.emit("error",Object.assign(new Error("Cannot call write after a stream was destroyed"),{code:"ERR_STREAM_DESTROYED"})),!0;typeof e=="function"&&(r=e,e="utf8"),e||(e="utf8");let i=this[Tt]?ii:Qg;if(!this[We]&&!Buffer.isBuffer(t)){if(nm(t))t=Buffer.from(t.buffer,t.byteOffset,t.byteLength);else if(tm(t))t=Buffer.from(t);else if(typeof t!="string")throw new Error("Non-contiguous data written to non-objectMode stream")}return this[We]?(this[ze]&&this[Ue]!==0&&this[gs](!0),this[ze]?this.emit("data",t):this[Ca](t),this[Ue]!==0&&this.emit("readable"),r&&i(r),this[ze]):t.length?(typeof t=="string"&&!(e===this[gt]&&!this[ar]?.lastNeed)&&(t=Buffer.from(t,e)),Buffer.isBuffer(t)&&this[gt]&&(t=this[ar].write(t)),this[ze]&&this[Ue]!==0&&this[gs](!0),this[ze]?this.emit("data",t):this[Ca](t),this[Ue]!==0&&this.emit("readable"),r&&i(r),this[ze]):(this[Ue]!==0&&this.emit("readable"),r&&i(r),this[ze])}read(t){if(this[Ie])return null;if(this[st]=!1,this[Ue]===0||t===0||t&&t>this[Ue])return this[Gt](),null;this[We]&&(t=null),this[Fe].length>1&&!this[We]&&(this[Fe]=[this[gt]?this[Fe].join(""):Buffer.concat(this[Fe],this[Ue])]);let e=this[ru](t||null,this[Fe][0]);return this[Gt](),e}[ru](t,e){if(this[We])this[ms]();else{let r=e;t===r.length||t===null?this[ms]():typeof r=="string"?(this[Fe][0]=r.slice(t),e=r.slice(0,t),this[Ue]-=t):(this[Fe][0]=r.subarray(t),e=r.subarray(0,t),this[Ue]-=t)}return this.emit("data",e),!this[Fe].length&&!this[Ut]&&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[Ut]=!0,this.writable=!1,(this[ze]||!this[ni])&&this[Gt](),this}[fr](){this[Ie]||(!this[Rn]&&!this[$e].length&&(this[st]=!0),this[ni]=!1,this[ze]=!0,this.emit("resume"),this[Fe].length?this[gs]():this[Ut]?this[Gt]():this.emit("drain"))}resume(){return this[fr]()}pause(){this[ze]=!1,this[ni]=!0,this[st]=!1}get destroyed(){return this[Ie]}get flowing(){return this[ze]}get paused(){return this[ni]}[Ca](t){this[We]?this[Ue]+=1:this[Ue]+=t.length,this[Fe].push(t)}[ms](){return this[We]?this[Ue]-=1:this[Ue]-=this[Fe][0].length,this[Fe].shift()}[gs](t=!1){do;while(this[iu](this[ms]())&&this[Fe].length);!t&&!this[Fe].length&&!this[Ut]&&this.emit("drain")}[iu](t){return this.emit("data",t),this[ze]}pipe(t,e){if(this[Ie])return t;this[st]=!1;let r=this[on];return e=e||{},t===nu.stdout||t===nu.stderr?e.end=!1:e.end=e.end!==!1,e.proxyErrors=!!e.proxyErrors,r?e.end&&t.end():(this[$e].push(e.proxyErrors?new rm(this,t,e):new Bu(this,t,e)),this[Tt]?ii(()=>this[fr]()):this[fr]()),t}unpipe(t){let e=this[$e].find(r=>r.dest===t);e&&(this[$e].length===1?(this[ze]&&this[Rn]===0&&(this[ze]=!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[st]=!1,this[Rn]++,!this[$e].length&&!this[ze]&&this[fr]();else if(t==="readable"&&this[Ue]!==0)super.emit("readable");else if(em(t)&&this[on])super.emit(t),this.removeAllListeners(t);else if(t==="error"&&this[ti]){let i=e;this[Tt]?ii(()=>i.call(this,this[ti])):i.call(this,this[ti])}return r}removeListener(t,e){return this.off(t,e)}off(t,e){let r=super.off(t,e);return t==="data"&&(this[Rn]=this.listeners("data").length,this[Rn]===0&&!this[st]&&!this[$e].length&&(this[ze]=!1)),r}removeAllListeners(t){let e=super.removeAllListeners(t);return(t==="data"||t===void 0)&&(this[Rn]=0,!this[st]&&!this[$e].length&&(this[ze]=!1)),e}get emittedEnd(){return this[on]}[Gt](){!this[xs]&&!this[on]&&!this[Ie]&&this[Fe].length===0&&this[Ut]&&(this[xs]=!0,this.emit("end"),this.emit("prefinish"),this.emit("finish"),this[ps]&&this.emit("close"),this[xs]=!1)}emit(t,...e){let r=e[0];if(t!=="error"&&t!=="close"&&t!==Ie&&this[Ie])return!1;if(t==="data")return!this[We]&&!r?!1:this[Tt]?(ii(()=>this[ka](r)),!0):this[ka](r);if(t==="end")return this[su]();if(t==="close"){if(this[ps]=!0,!this[on]&&!this[Ie])return!1;let o=super.emit("close");return this.removeAllListeners("close"),o}else if(t==="error"){this[ti]=r,super.emit(Da,r);let o=!this[ri]||this.listeners("error").length?super.emit("error",r):!1;return this[Gt](),o}else if(t==="resume"){let o=super.emit("resume");return this[Gt](),o}else if(t==="finish"||t==="prefinish"){let o=super.emit(t);return this.removeAllListeners(t),o}let i=super.emit(t,...e);return this[Gt](),i}[ka](t){for(let r of this[$e])r.dest.write(t)===!1&&this.pause();let e=this[st]?!1:super.emit("data",t);return this[Gt](),e}[su](){return this[on]?!1:(this[on]=!0,this.readable=!1,this[Tt]?(ii(()=>this[Pa]()),!0):this[Pa]())}[Pa](){if(this[ar]){let e=this[ar].end();if(e){for(let r of this[$e])r.dest.write(e);this[st]||super.emit("data",e)}}for(let e of this[$e])e.end();let t=super.emit("end");return this.removeAllListeners("end"),t}async collect(){let t=Object.assign([],{dataLength:0});this[We]||(t.dataLength=0);let e=this.promise();return this.on("data",r=>{t.push(r),this[We]||(t.dataLength+=r.length)}),await e,t}async concat(){if(this[We])throw new Error("cannot concat in objectMode");let t=await this.collect();return this[gt]?t.join(""):Buffer.concat(t,t.dataLength)}async promise(){return new Promise((t,e)=>{this.on(Ie,()=>e(new Error("stream destroyed"))),this.on("error",r=>e(r)),this.on("end",()=>t())})}[Symbol.asyncIterator](){this[st]=!1;let t=!1,e=async()=>(this.pause(),t=!0,{value:void 0,done:!0});return{next:()=>{if(t)return e();let r=this.read();if(r!==null)return Promise.resolve({done:!1,value:r});if(this[Ut])return e();let i,o,c=x=>{this.off("data",l),this.off("end",u),this.off(Ie,h),e(),o(x)},l=x=>{this.off("error",c),this.off("end",u),this.off(Ie,h),this.pause(),i({value:x,done:!!this[Ut]})},u=()=>{this.off("error",c),this.off("data",l),this.off(Ie,h),e(),i({done:!0,value:void 0})},h=()=>c(new Error("stream destroyed"));return new Promise((x,w)=>{o=w,i=x,this.once(Ie,h),this.once("error",c),this.once("end",u),this.once("data",l)})},throw:e,return:e,[Symbol.asyncIterator](){return this},[Symbol.asyncDispose]:async()=>{}}}[Symbol.iterator](){this[st]=!1;let t=!1,e=()=>(this.pause(),this.off(Da,e),this.off(Ie,e),this.off("end",e),t=!0,{done:!0,value:void 0}),r=()=>{if(t)return e();let i=this.read();return i===null?e():{done:!1,value:i}};return this.once("end",e),this.once(Da,e),this.once(Ie,e),{next:r,throw:e,return:e,[Symbol.iterator](){return this},[Symbol.dispose]:()=>{}}}destroy(t){if(this[Ie])return t?this.emit("error",t):this.emit(Ie),this;this[Ie]=!0,this[st]=!0,this[Fe].length=0,this[Ue]=0;let e=this;return typeof e.close=="function"&&!this[ps]&&e.close(),t?this.emit("error",t):this.emit(Ie),this}static get isStream(){return Jg}},om=et.writev,gn=Symbol("_autoClose"),yt=Symbol("_close"),si=Symbol("_ended"),de=Symbol("_fd"),Oa=Symbol("_finished"),Wt=Symbol("_flags"),Na=Symbol("_flush"),tc=Symbol("_handleChunk"),nc=Symbol("_makeBuf"),gi=Symbol("_mode"),_s=Symbol("_needDrain"),mr=Symbol("_onerror"),wr=Symbol("_onopen"),Ma=Symbol("_onread"),hr=Symbol("_onwrite"),mn=Symbol("_open"),_t=Symbol("_path"),un=Symbol("_pos"),Rt=Symbol("_queue"),xr=Symbol("_read"),Ba=Symbol("_readSize"),jt=Symbol("_reading"),oi=Symbol("_remain"),za=Symbol("_size"),Cs=Symbol("_write"),Cn=Symbol("_writing"),Ds=Symbol("_defaultFlag"),Mn=Symbol("_errored"),vc=class extends Un{[Mn]=!1;[de];[_t];[Ba];[jt]=!1;[za];[oi];[gn];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[Mn]=!1,this[de]=typeof e.fd=="number"?e.fd:void 0,this[_t]=t,this[Ba]=e.readSize||16*1024*1024,this[jt]=!1,this[za]=typeof e.size=="number"?e.size:1/0,this[oi]=this[za],this[gn]=typeof e.autoClose=="boolean"?e.autoClose:!0,typeof this[de]=="number"?this[xr]():this[mn]()}get fd(){return this[de]}get path(){return this[_t]}write(){throw new TypeError("this is a readable stream")}end(){throw new TypeError("this is a readable stream")}[mn](){et.open(this[_t],"r",(t,e)=>this[wr](t,e))}[wr](t,e){t?this[mr](t):(this[de]=e,this.emit("open",e),this[xr]())}[nc](){return Buffer.allocUnsafe(Math.min(this[Ba],this[oi]))}[xr](){if(!this[jt]){this[jt]=!0;let t=this[nc]();if(t.length===0)return process.nextTick(()=>this[Ma](null,0,t));et.read(this[de],t,0,t.length,null,(e,r,i)=>this[Ma](e,r,i))}}[Ma](t,e,r){this[jt]=!1,t?this[mr](t):this[tc](e,r)&&this[xr]()}[yt](){if(this[gn]&&typeof this[de]=="number"){let t=this[de];this[de]=void 0,et.close(t,e=>e?this.emit("error",e):this.emit("close"))}}[mr](t){this[jt]=!0,this[yt](),this.emit("error",t)}[tc](t,e){let r=!1;return this[oi]-=t,t>0&&(r=super.write(t<e.length?e.subarray(0,t):e)),(t===0||this[oi]<=0)&&(r=!1,this[yt](),super.end()),r}emit(t,...e){switch(t){case"prefinish":case"finish":return!1;case"drain":return typeof this[de]=="number"&&this[xr](),!1;case"error":return this[Mn]?!1:(this[Mn]=!0,super.emit(t,...e));default:return super.emit(t,...e)}}},am=class extends vc{[mn](){let t=!0;try{this[wr](null,et.openSync(this[_t],"r")),t=!1}finally{t&&this[yt]()}}[xr](){let t=!0;try{if(!this[jt]){this[jt]=!0;do{let e=this[nc](),r=e.length===0?0:et.readSync(this[de],e,0,e.length,null);if(!this[tc](r,e))break}while(!0);this[jt]=!1}t=!1}finally{t&&this[yt]()}}[yt](){if(this[gn]&&typeof this[de]=="number"){let t=this[de];this[de]=void 0,et.closeSync(t),this.emit("close")}}},Ws=class extends Vg{readable=!1;writable=!0;[Mn]=!1;[Cn]=!1;[si]=!1;[Rt]=[];[_s]=!1;[_t];[gi];[gn];[de];[Ds];[Wt];[Oa]=!1;[un];constructor(t,e){e=e||{},super(e),this[_t]=t,this[de]=typeof e.fd=="number"?e.fd:void 0,this[gi]=e.mode===void 0?438:e.mode,this[un]=typeof e.start=="number"?e.start:void 0,this[gn]=typeof e.autoClose=="boolean"?e.autoClose:!0;let r=this[un]!==void 0?"r+":"w";this[Ds]=e.flags===void 0,this[Wt]=e.flags===void 0?r:e.flags,this[de]===void 0&&this[mn]()}emit(t,...e){if(t==="error"){if(this[Mn])return!1;this[Mn]=!0}return super.emit(t,...e)}get fd(){return this[de]}get path(){return this[_t]}[mr](t){this[yt](),this[Cn]=!0,this.emit("error",t)}[mn](){et.open(this[_t],this[Wt],this[gi],(t,e)=>this[wr](t,e))}[wr](t,e){this[Ds]&&this[Wt]==="r+"&&t&&t.code==="ENOENT"?(this[Wt]="w",this[mn]()):t?this[mr](t):(this[de]=e,this.emit("open",e),this[Cn]||this[Na]())}end(t,e){return t&&this.write(t,e),this[si]=!0,!this[Cn]&&!this[Rt].length&&typeof this[de]=="number"&&this[hr](null,0),this}write(t,e){return typeof t=="string"&&(t=Buffer.from(t,e)),this[si]?(this.emit("error",new Error("write() after end()")),!1):this[de]===void 0||this[Cn]||this[Rt].length?(this[Rt].push(t),this[_s]=!0,!1):(this[Cn]=!0,this[Cs](t),!0)}[Cs](t){et.write(this[de],t,0,t.length,this[un],(e,r)=>this[hr](e,r))}[hr](t,e){t?this[mr](t):(this[un]!==void 0&&typeof e=="number"&&(this[un]+=e),this[Rt].length?this[Na]():(this[Cn]=!1,this[si]&&!this[Oa]?(this[Oa]=!0,this[yt](),this.emit("finish")):this[_s]&&(this[_s]=!1,this.emit("drain"))))}[Na](){if(this[Rt].length===0)this[si]&&this[hr](null,0);else if(this[Rt].length===1)this[Cs](this[Rt].pop());else{let t=this[Rt];this[Rt]=[],om(this[de],t,this[un],(e,r)=>this[hr](e,r))}}[yt](){if(this[gn]&&typeof this[de]=="number"){let t=this[de];this[de]=void 0,et.close(t,e=>e?this.emit("error",e):this.emit("close"))}}},zu=class extends Ws{[mn](){let t;if(this[Ds]&&this[Wt]==="r+")try{t=et.openSync(this[_t],this[Wt],this[gi])}catch(e){if(e?.code==="ENOENT")return this[Wt]="w",this[mn]();throw e}else t=et.openSync(this[_t],this[Wt],this[gi]);this[wr](null,t)}[yt](){if(this[gn]&&typeof this[de]=="number"){let t=this[de];this[de]=void 0,et.closeSync(t),this.emit("close")}}[Cs](t){let e=!0;try{this[hr](null,et.writeSync(this[de],t,0,t.length,this[un])),e=!1}finally{if(e)try{this[yt]()}catch{}}}},lm=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"]]),um=t=>!!t.sync&&!!t.file,fm=t=>!t.sync&&!!t.file,hm=t=>!!t.sync&&!t.file,xm=t=>!t.sync&&!t.file,pm=t=>!!t.file,gm=t=>lm.get(t)||t,Sc=(t={})=>{if(!t)return{};let e={};for(let[r,i]of Object.entries(t)){let o=gm(r);e[o]=i}return e.chmod===void 0&&e.noChmod===!1&&(e.chmod=!0),delete e.noChmod,e},Ii=(t,e,r,i,o)=>Object.assign((c=[],l,u)=>{Array.isArray(c)&&(l=c,c={}),typeof l=="function"&&(u=l,l=void 0),l=l?Array.from(l):[];let h=Sc(c);if(o?.(h,l),um(h)){if(typeof u=="function")throw new TypeError("callback not supported for sync tar functions");return t(h,l)}else if(fm(h)){let x=e(h,l);return u?x.then(()=>u(),u):x}else if(hm(h)){if(typeof u=="function")throw new TypeError("callback not supported for sync tar functions");return r(h,l)}else if(xm(h)){if(typeof u=="function")throw new TypeError("callback only supported with file option");return i(h,l)}throw new Error("impossible options??")},{syncFile:t,asyncFile:e,syncNoFile:r,asyncNoFile:i,validate:o}),_m=wm.constants||{ZLIB_VERNUM:4736},Pt=Object.freeze(Object.assign(Object.create(null),{Z_NO_FLUSH:0,Z_PARTIAL_FLUSH:1,Z_SYNC_FLUSH:2,Z_FULL_FLUSH:3,Z_FINISH:4,Z_BLOCK:5,Z_OK:0,Z_STREAM_END:1,Z_NEED_DICT:2,Z_ERRNO:-1,Z_STREAM_ERROR:-2,Z_DATA_ERROR:-3,Z_MEM_ERROR:-4,Z_BUF_ERROR:-5,Z_VERSION_ERROR:-6,Z_NO_COMPRESSION:0,Z_BEST_SPEED:1,Z_BEST_COMPRESSION:9,Z_DEFAULT_COMPRESSION:-1,Z_FILTERED:1,Z_HUFFMAN_ONLY:2,Z_RLE:3,Z_FIXED:4,Z_DEFAULT_STRATEGY:0,DEFLATE:1,INFLATE:2,GZIP:3,GUNZIP:4,DEFLATERAW:5,INFLATERAW:6,UNZIP:7,BROTLI_DECODE:8,BROTLI_ENCODE:9,Z_MIN_WINDOWBITS:8,Z_MAX_WINDOWBITS:15,Z_DEFAULT_WINDOWBITS:15,Z_MIN_CHUNK:64,Z_MAX_CHUNK:1/0,Z_DEFAULT_CHUNK:16384,Z_MIN_MEMLEVEL:1,Z_MAX_MEMLEVEL:9,Z_DEFAULT_MEMLEVEL:8,Z_MIN_LEVEL:-1,Z_MAX_LEVEL:9,Z_DEFAULT_LEVEL:-1,BROTLI_OPERATION_PROCESS:0,BROTLI_OPERATION_FLUSH:1,BROTLI_OPERATION_FINISH:2,BROTLI_OPERATION_EMIT_METADATA:3,BROTLI_MODE_GENERIC:0,BROTLI_MODE_TEXT:1,BROTLI_MODE_FONT:2,BROTLI_DEFAULT_MODE:0,BROTLI_MIN_QUALITY:0,BROTLI_MAX_QUALITY:11,BROTLI_DEFAULT_QUALITY:11,BROTLI_MIN_WINDOW_BITS:10,BROTLI_MAX_WINDOW_BITS:24,BROTLI_LARGE_MAX_WINDOW_BITS:30,BROTLI_DEFAULT_WINDOW:22,BROTLI_MIN_INPUT_BLOCK_BITS:16,BROTLI_MAX_INPUT_BLOCK_BITS:24,BROTLI_PARAM_MODE:0,BROTLI_PARAM_QUALITY:1,BROTLI_PARAM_LGWIN:2,BROTLI_PARAM_LGBLOCK:3,BROTLI_PARAM_DISABLE_LITERAL_CONTEXT_MODELING:4,BROTLI_PARAM_SIZE_HINT:5,BROTLI_PARAM_LARGE_WINDOW:6,BROTLI_PARAM_NPOSTFIX:7,BROTLI_PARAM_NDIRECT:8,BROTLI_DECODER_RESULT_ERROR:0,BROTLI_DECODER_RESULT_SUCCESS:1,BROTLI_DECODER_RESULT_NEEDS_MORE_INPUT:2,BROTLI_DECODER_RESULT_NEEDS_MORE_OUTPUT:3,BROTLI_DECODER_PARAM_DISABLE_RING_BUFFER_REALLOCATION:0,BROTLI_DECODER_PARAM_LARGE_WINDOW:1,BROTLI_DECODER_NO_ERROR:0,BROTLI_DECODER_SUCCESS:1,BROTLI_DECODER_NEEDS_MORE_INPUT:2,BROTLI_DECODER_NEEDS_MORE_OUTPUT:3,BROTLI_DECODER_ERROR_FORMAT_EXUBERANT_NIBBLE:-1,BROTLI_DECODER_ERROR_FORMAT_RESERVED:-2,BROTLI_DECODER_ERROR_FORMAT_EXUBERANT_META_NIBBLE:-3,BROTLI_DECODER_ERROR_FORMAT_SIMPLE_HUFFMAN_ALPHABET:-4,BROTLI_DECODER_ERROR_FORMAT_SIMPLE_HUFFMAN_SAME:-5,BROTLI_DECODER_ERROR_FORMAT_CL_SPACE:-6,BROTLI_DECODER_ERROR_FORMAT_HUFFMAN_SPACE:-7,BROTLI_DECODER_ERROR_FORMAT_CONTEXT_MAP_REPEAT:-8,BROTLI_DECODER_ERROR_FORMAT_BLOCK_LENGTH_1:-9,BROTLI_DECODER_ERROR_FORMAT_BLOCK_LENGTH_2:-10,BROTLI_DECODER_ERROR_FORMAT_TRANSFORM:-11,BROTLI_DECODER_ERROR_FORMAT_DICTIONARY:-12,BROTLI_DECODER_ERROR_FORMAT_WINDOW_BITS:-13,BROTLI_DECODER_ERROR_FORMAT_PADDING_1:-14,BROTLI_DECODER_ERROR_FORMAT_PADDING_2:-15,BROTLI_DECODER_ERROR_FORMAT_DISTANCE:-16,BROTLI_DECODER_ERROR_DICTIONARY_NOT_SET:-19,BROTLI_DECODER_ERROR_INVALID_ARGUMENTS:-20,BROTLI_DECODER_ERROR_ALLOC_CONTEXT_MODES:-21,BROTLI_DECODER_ERROR_ALLOC_TREE_GROUPS:-22,BROTLI_DECODER_ERROR_ALLOC_CONTEXT_MAP:-25,BROTLI_DECODER_ERROR_ALLOC_RING_BUFFER_1:-26,BROTLI_DECODER_ERROR_ALLOC_RING_BUFFER_2:-27,BROTLI_DECODER_ERROR_ALLOC_BLOCK_TYPE_TREES:-30,BROTLI_DECODER_ERROR_UNREACHABLE:-31},_m)),ym=Bn.concat,au=Object.getOwnPropertyDescriptor(Bn,"concat"),bm=t=>t,Fa=au?.writable===!0||au?.set!==void 0?t=>{Bn.concat=t?bm:ym}:t=>{},zn=Symbol("_superWrite"),ys=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"}},Ua=Symbol("flushFlag"),Ic=class extends Un{#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 ou[e]!="function")throw new TypeError("Compression method not supported: "+e);try{this.#t=new ou[e](t)}catch(r){throw new ys(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 ys(r))),this.once("end",()=>this.close)}close(){this.#t&&(this.#t.close(),this.#t=void 0,this.emit("close"))}reset(){if(!this.#e)return rc(this.#t,"zlib binding closed"),this.#t.reset?.()}flush(t){this.ended||(typeof t!="number"&&(t=this.#i),this.write(Object.assign(Bn.alloc(0),{[Ua]: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}[zn](t){return super.write(t)}write(t,e,r){if(typeof e=="function"&&(r=e,e="utf8"),typeof t=="string"&&(t=Bn.from(t,e)),this.#e)return;rc(this.#t,"zlib binding closed");let i=this.#t._handle,o=i.close;i.close=()=>{};let c=this.#t.close;this.#t.close=()=>{},Fa(!0);let l;try{let h=typeof t[Ua]=="number"?t[Ua]:this.#r;l=this.#t._processChunk(t,h),Fa(!1)}catch(h){Fa(!1),this.#o(new ys(h,this.write))}finally{this.#t&&(this.#t._handle=i,i.close=o,this.#t.close=c,this.#t.removeAllListeners("error"))}this.#t&&this.#t.on("error",h=>this.#o(new ys(h,this.write)));let u;if(l)if(Array.isArray(l)&&l.length>0){let h=l[0];u=this[zn](Bn.from(h));for(let x=1;x<l.length;x++)u=this[zn](l[x])}else u=this[zn](Bn.from(l));return r&&r(),u}},Uu=class extends Ic{#e;#n;constructor(t,e){t=t||{},t.flush=t.flush||Pt.Z_NO_FLUSH,t.finishFlush=t.finishFlush||Pt.Z_FINISH,t.fullFlushFlag=Pt.Z_FULL_FLUSH,super(t,e),this.#e=t.level,this.#n=t.strategy}params(t,e){if(!this.sawError){if(!this.handle)throw new Error("cannot switch params when binding is closed");if(!this.handle.params)throw new Error("not supported in this implementation");if(this.#e!==t||this.#n!==e){this.flush(Pt.Z_SYNC_FLUSH),rc(this.handle,"zlib binding closed");let r=this.handle.flush;this.handle.flush=(i,o)=>{typeof i=="function"&&(o=i,i=this.flushFlag),this.flush(i),o?.()};try{this.handle.params(t,e)}finally{this.handle.flush=r}this.handle&&(this.#e=t,this.#n=e)}}}},Em=class extends Uu{#e;constructor(t){super(t,"Gzip"),this.#e=t&&!!t.portable}[zn](t){return this.#e?(this.#e=!1,t[9]=255,super[zn](t)):super[zn](t)}},vm=class extends Uu{constructor(t){super(t,"Unzip")}},Gu=class extends Ic{constructor(t,e){t=t||{},t.flush=t.flush||Pt.BROTLI_OPERATION_PROCESS,t.finishFlush=t.finishFlush||Pt.BROTLI_OPERATION_FINISH,t.fullFlushFlag=Pt.BROTLI_OPERATION_FLUSH,super(t,e)}},Sm=class extends Gu{constructor(t){super(t,"BrotliCompress")}},Im=class extends Gu{constructor(t){super(t,"BrotliDecompress")}},qu=class extends Ic{constructor(t,e){t=t||{},t.flush=t.flush||Pt.ZSTD_e_continue,t.finishFlush=t.finishFlush||Pt.ZSTD_e_end,t.fullFlushFlag=Pt.ZSTD_e_flush,super(t,e)}},Am=class extends qu{constructor(t){super(t,"ZstdCompress")}},Tm=class extends qu{constructor(t){super(t,"ZstdDecompress")}},Rm=(t,e)=>{if(Number.isSafeInteger(t))t<0?Dm(t,e):Cm(t,e);else throw Error("cannot encode number outside of javascript safe integer range");return e},Cm=(t,e)=>{e[0]=128;for(var r=e.length;r>1;r--)e[r-1]=t&255,t=Math.floor(t/256)},Dm=(t,e)=>{e[0]=255;var r=!1;t=t*-1;for(var i=e.length;i>1;i--){var o=t&255;t=Math.floor(t/256),r?e[i-1]=Hu(o):o===0?e[i-1]=0:(r=!0,e[i-1]=ju(o))}},km=t=>{let e=t[0],r=e===128?Lm(t.subarray(1,t.length)):e===255?Pm(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},Pm=t=>{for(var e=t.length,r=0,i=!1,o=e-1;o>-1;o--){var c=Number(t[o]),l;i?l=Hu(c):c===0?l=c:(i=!0,l=ju(c)),l!==0&&(r-=l*Math.pow(256,e-o-1))}return r},Lm=t=>{for(var e=t.length,r=0,i=e-1;i>-1;i--){var o=Number(t[i]);o!==0&&(r+=o*Math.pow(256,e-i-1))}return r},Hu=t=>(255^t)&255,ju=t=>(255^t)+1&255,Om={};$g(Om,{code:()=>Ac,isCode:()=>ks,isName:()=>Nm,name:()=>Ks});var ks=t=>Ks.has(t),Nm=t=>Ac.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"]]),Ac=new Map(Array.from(Ks).map(t=>[t[1],t[0]])),Fn=class{cksumValid=!1;needPax=!1;nullBlock=!1;block;path;mode;uid;gid;size;cksum;#e="Unsupported";linkpath;uname;gname;devmaj=0;devmin=0;atime;ctime;mtime;charset;comment;constructor(t,e=0,r,i){Buffer.isBuffer(t)?this.decode(t,e||0,r,i):t&&this.#n(t)}decode(t,e,r,i){if(e||(e=0),!t||!(t.length>=e+512))throw new Error("need 512 bytes for header");this.path=r?.path??Dn(t,e,100),this.mode=r?.mode??i?.mode??fn(t,e+100,8),this.uid=r?.uid??i?.uid??fn(t,e+108,8),this.gid=r?.gid??i?.gid??fn(t,e+116,8),this.size=r?.size??i?.size??fn(t,e+124,12),this.mtime=r?.mtime??i?.mtime??Ga(t,e+136,12),this.cksum=fn(t,e+148,12),i&&this.#n(i,!0),r&&this.#n(r);let o=Dn(t,e+156,1);if(ks(o)&&(this.#e=o||"0"),this.#e==="0"&&this.path.slice(-1)==="/"&&(this.#e="5"),this.#e==="5"&&(this.size=0),this.linkpath=Dn(t,e+157,100),t.subarray(e+257,e+265).toString()==="ustar\x0000")if(this.uname=r?.uname??i?.uname??Dn(t,e+265,32),this.gname=r?.gname??i?.gname??Dn(t,e+297,32),this.devmaj=r?.devmaj??i?.devmaj??fn(t,e+329,8)??0,this.devmin=r?.devmin??i?.devmin??fn(t,e+337,8)??0,t[e+475]!==0){let l=Dn(t,e+345,155);this.path=l+"/"+this.path}else{let l=Dn(t,e+345,130);l&&(this.path=l+"/"+this.path),this.atime=r?.atime??i?.atime??Ga(t,e+476,12),this.ctime=r?.ctime??i?.ctime??Ga(t,e+488,12)}let c=256;for(let l=e;l<e+148;l++)c+=t[l];for(let l=e+156;l<e+512;l++)c+=t[l];this.cksumValid=c===this.cksum,this.cksum===void 0&&c===256&&(this.nullBlock=!0)}#n(t,e=!1){Object.assign(this,Object.fromEntries(Object.entries(t).filter(([r,i])=>!(i==null||r==="path"&&e||r==="linkpath"&&e||r==="global"))))}encode(t,e=0){if(t||(t=this.block=Buffer.alloc(512)),this.#e==="Unsupported"&&(this.#e="0"),!(t.length>=e+512))throw new Error("need 512 bytes for header");let r=this.ctime||this.atime?130:155,i=Mm(this.path||"",r),o=i[0],c=i[1];this.needPax=!!i[2],this.needPax=kn(t,e,100,o)||this.needPax,this.needPax=hn(t,e+100,8,this.mode)||this.needPax,this.needPax=hn(t,e+108,8,this.uid)||this.needPax,this.needPax=hn(t,e+116,8,this.gid)||this.needPax,this.needPax=hn(t,e+124,12,this.size)||this.needPax,this.needPax=qa(t,e+136,12,this.mtime)||this.needPax,t[e+156]=Number(this.#e.codePointAt(0)),this.needPax=kn(t,e+157,100,this.linkpath)||this.needPax,t.write("ustar\x0000",e+257,8),this.needPax=kn(t,e+265,32,this.uname)||this.needPax,this.needPax=kn(t,e+297,32,this.gname)||this.needPax,this.needPax=hn(t,e+329,8,this.devmaj)||this.needPax,this.needPax=hn(t,e+337,8,this.devmin)||this.needPax,this.needPax=kn(t,e+345,r,c)||this.needPax,t[e+475]!==0?this.needPax=kn(t,e+345,155,c)||this.needPax:(this.needPax=kn(t,e+345,130,c)||this.needPax,this.needPax=qa(t,e+476,12,this.atime)||this.needPax,this.needPax=qa(t,e+488,12,this.ctime)||this.needPax);let l=256;for(let u=e;u<e+148;u++)l+=t[u];for(let u=e+156;u<e+512;u++)l+=t[u];return this.cksum=l,hn(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(Ac.get(t));if(ks(e)||e==="Unsupported")this.#e=e;else if(ks(t))this.#e=t;else throw new TypeError("invalid entry type: "+t)}},Mm=(t,e)=>{let r=t,i="",o,c=cr.parse(t).root||".";if(Buffer.byteLength(r)<100)o=[r,i,!1];else{i=cr.dirname(r),r=cr.basename(r);do Buffer.byteLength(r)<=100&&Buffer.byteLength(i)<=e?o=[r,i,!1]:Buffer.byteLength(r)>100&&Buffer.byteLength(i)<=e?o=[r.slice(0,99),i,!0]:(r=cr.join(cr.basename(i),r),i=cr.dirname(i));while(i!==c&&o===void 0);o||(o=[t.slice(0,99),"",!0])}return o},Dn=(t,e,r)=>t.subarray(e,e+r).toString("utf8").replace(/\0.*/,""),Ga=(t,e,r)=>Bm(fn(t,e,r)),Bm=t=>t===void 0?void 0:new Date(t*1e3),fn=(t,e,r)=>Number(t[e])&128?km(t.subarray(e,e+r)):Fm(t,e,r),zm=t=>isNaN(t)?void 0:t,Fm=(t,e,r)=>zm(parseInt(t.subarray(e,e+r).toString("utf8").replace(/\0.*$/,"").trim(),8)),Um={12:8589934591,8:2097151},hn=(t,e,r,i)=>i===void 0?!1:i>Um[r]||i<0?(Rm(i,t.subarray(e,e+r)),!0):(Gm(t,e,r,i),!1),Gm=(t,e,r,i)=>t.write(qm(i,r),e,r,"ascii"),qm=(t,e)=>Hm(Math.floor(t).toString(8),e),Hm=(t,e)=>(t.length===e-1?t:new Array(e-t.length-1).join("0")+t+" ")+"\0",qa=(t,e,r,i)=>i===void 0?!1:hn(t,e,r,i.getTime()/1e3),jm=new Array(156).join("\0"),kn=(t,e,r,i)=>i===void 0?!1:(t.write(i+jm,e,r,"utf8"),i.length!==Buffer.byteLength(i)||i.length>r),Us=class Wu{atime;mtime;ctime;charset;comment;gid;uid;gname;uname;linkpath;dev;ino;nlink;path;size;mode;global;constructor(e,r=!1){this.atime=e.atime,this.charset=e.charset,this.comment=e.comment,this.ctime=e.ctime,this.dev=e.dev,this.gid=e.gid,this.global=r,this.gname=e.gname,this.ino=e.ino,this.linkpath=e.linkpath,this.mtime=e.mtime,this.nlink=e.nlink,this.path=e.path,this.size=e.size,this.uid=e.uid,this.uname=e.uname}encode(){let e=this.encodeBody();if(e==="")return Buffer.allocUnsafe(0);let r=Buffer.byteLength(e),i=512*Math.ceil(1+r/512),o=Buffer.allocUnsafe(i);for(let c=0;c<512;c++)o[c]=0;new Fn({path:("PaxHeader/"+Wm(this.path??"")).slice(0,99),mode:this.mode||420,uid:this.uid,gid:this.gid,size:r,mtime:this.mtime,type:this.global?"GlobalExtendedHeader":"ExtendedHeader",linkpath:"",uname:this.uname||"",gname:this.gname||"",devmaj:0,devmin:0,atime:this.atime,ctime:this.ctime}).encode(o),o.write(e,512,r,"utf8");for(let c=r+512;c<o.length;c++)o[c]=0;return o}encodeBody(){return this.encodeField("path")+this.encodeField("ctime")+this.encodeField("atime")+this.encodeField("dev")+this.encodeField("ino")+this.encodeField("nlink")+this.encodeField("charset")+this.encodeField("comment")+this.encodeField("gid")+this.encodeField("gname")+this.encodeField("linkpath")+this.encodeField("mtime")+this.encodeField("size")+this.encodeField("uid")+this.encodeField("uname")}encodeField(e){if(this[e]===void 0)return"";let r=this[e],i=r instanceof Date?r.getTime()/1e3:r,o=" "+(e==="dev"||e==="ino"||e==="nlink"?"SCHILY.":"")+e+"="+i+`
|
|
90
|
+
`,c=Buffer.byteLength(o),l=Math.floor(Math.log(c)/Math.log(10))+1;return c+l>=Math.pow(10,l)&&(l+=1),l+c+o}static parse(e,r,i=!1){return new Wu(Km($m(e),r),i)}},Km=(t,e)=>e?Object.assign({},e,t):t,$m=t=>t.replace(/\n$/,"").split(`
|
|
91
|
+
`).reduce(Vm,Object.create(null)),Vm=(t,e)=>{let r=parseInt(e,10);if(r!==Buffer.byteLength(e)+1)return t;e=e.slice((r+" ").length);let i=e.split("="),o=i.shift();if(!o)return t;let c=o.replace(/^SCHILY\.(dev|ino|nlink)/,"$1"),l=i.join("=");return t[c]=/^([A-Z]+\.)?([mac]|birth|creation)time$/.test(c)?new Date(Number(l)*1e3):/^[0-9]+$/.test(l)?+l:l,t},Zm=process.env.TESTING_TAR_FAKE_PLATFORM||process.platform,J=Zm!=="win32"?t=>t:t=>t&&t.replaceAll(/\\/g,"/"),Ku=class extends Un{extended;globalExtended;header;startBlockSize;blockRemain;remain;type;meta=!1;ignore=!1;path;mode;uid;gid;uname;gname;size=0;mtime;atime;ctime;linkpath;dev;ino;nlink;invalid=!1;absolute;unsupported=!1;constructor(t,e,r){switch(super({}),this.pause(),this.extended=e,this.globalExtended=r,this.header=t,this.remain=t.size??0,this.startBlockSize=512*Math.ceil(this.remain/512),this.blockRemain=this.startBlockSize,this.type=t.type,this.type){case"File":case"OldFile":case"Link":case"SymbolicLink":case"CharacterDevice":case"BlockDevice":case"Directory":case"FIFO":case"ContiguousFile":case"GNUDumpDir":break;case"NextFileHasLongLinkpath":case"NextFileHasLongPath":case"OldGnuLongPath":case"GlobalExtendedHeader":case"ExtendedHeader":case"OldExtendedHeader":this.meta=!0;break;default:this.ignore=!0}if(!t.path)throw new Error("no path provided for tar.ReadEntry");this.path=J(t.path),this.mode=t.mode,this.mode&&(this.mode=this.mode&4095),this.uid=t.uid,this.gid=t.gid,this.uname=t.uname,this.gname=t.gname,this.size=this.remain,this.mtime=t.mtime,this.atime=t.atime,this.ctime=t.ctime,this.linkpath=t.linkpath?J(t.linkpath):void 0,this.uname=t.uname,this.gname=t.gname,e&&this.#e(e),r&&this.#e(r,!0)}write(t){let e=t.length;if(e>this.blockRemain)throw new Error("writing more to entry than is appropriate");let r=this.remain,i=this.blockRemain;return this.remain=Math.max(0,r-e),this.blockRemain=Math.max(0,i-e),this.ignore?!0:r>=e?super.write(t):super.write(t.subarray(0,r))}#e(t,e=!1){t.path&&(t.path=J(t.path)),t.linkpath&&(t.linkpath=J(t.linkpath)),Object.assign(this,Object.fromEntries(Object.entries(t).filter(([r,i])=>!(i==null||r==="path"&&e))))}},$s=(t,e,r,i={})=>{t.file&&(i.file=t.file),t.cwd&&(i.cwd=t.cwd),i.code=r instanceof Error&&r.code||e,i.tarCode=e,!t.strict&&i.recoverable!==!1?(r instanceof Error&&(i=Object.assign(r,i),r=r.message),t.emit("warn",e,r,i)):r instanceof Error?t.emit("error",Object.assign(r,i)):t.emit("error",Object.assign(new Error(`${e}: ${r}`),i))},Jm=1024*1024,ic=Buffer.from([31,139]),sc=Buffer.from([40,181,47,253]),Ym=Math.max(ic.length,sc.length),lt=Symbol("state"),Pn=Symbol("writeEntry"),qt=Symbol("readEntry"),Ha=Symbol("nextEntry"),cu=Symbol("processEntry"),Ct=Symbol("extendedHeader"),ai=Symbol("globalExtendedHeader"),an=Symbol("meta"),du=Symbol("emitMeta"),xe=Symbol("buffer"),Ht=Symbol("queue"),cn=Symbol("ended"),ja=Symbol("emittedEnd"),Ln=Symbol("emit"),Ce=Symbol("unzip"),bs=Symbol("consumeChunk"),Es=Symbol("consumeChunkSub"),Wa=Symbol("consumeBody"),lu=Symbol("consumeMeta"),uu=Symbol("consumeHeader"),ci=Symbol("consuming"),Ka=Symbol("bufferConcat"),vs=Symbol("maybeEnd"),dr=Symbol("writing"),dn=Symbol("aborted"),Ss=Symbol("onDone"),On=Symbol("sawValidEntry"),Is=Symbol("sawNullBlock"),As=Symbol("sawEOF"),fu=Symbol("closeStream"),Xm=()=>!0,Si=class extends mm{file;strict;maxMetaEntrySize;filter;brotli;zstd;writable=!0;readable=!1;[Ht]=[];[xe];[qt];[Pn];[lt]="begin";[an]="";[Ct];[ai];[cn]=!1;[Ce];[dn]=!1;[On];[Is]=!1;[As]=!1;[dr]=!1;[ci]=!1;[ja]=!1;constructor(t={}){super(),this.file=t.file||"",this.on(Ss,()=>{(this[lt]==="begin"||this[On]===!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||Jm,this.filter=typeof t.filter=="function"?t.filter:Xm;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[fu]()),typeof t.onwarn=="function"&&this.on("warn",t.onwarn),typeof t.onReadEntry=="function"&&this.on("entry",t.onReadEntry)}warn(t,e,r={}){$s(this,t,e,r)}[uu](t,e){this[On]===void 0&&(this[On]=!1);let r;try{r=new Fn(t,e,this[Ct],this[ai])}catch(i){return this.warn("TAR_ENTRY_INVALID",i)}if(r.nullBlock)this[Is]?(this[As]=!0,this[lt]==="begin"&&(this[lt]="header"),this[Ln]("eof")):(this[Is]=!0,this[Ln]("nullBlock"));else if(this[Is]=!1,!r.cksumValid)this.warn("TAR_ENTRY_INVALID","checksum failure",{header:r});else if(!r.path)this.warn("TAR_ENTRY_INVALID","path is required",{header:r});else{let i=r.type;if(/^(Symbolic)?Link$/.test(i)&&!r.linkpath)this.warn("TAR_ENTRY_INVALID","linkpath required",{header:r});else if(!/^(Symbolic)?Link$/.test(i)&&!/^(Global)?ExtendedHeader$/.test(i)&&r.linkpath)this.warn("TAR_ENTRY_INVALID","linkpath forbidden",{header:r});else{let o=this[Pn]=new Ku(r,this[Ct],this[ai]);if(!this[On])if(o.remain){let c=()=>{o.invalid||(this[On]=!0)};o.on("end",c)}else this[On]=!0;o.meta?o.size>this.maxMetaEntrySize?(o.ignore=!0,this[Ln]("ignoredEntry",o),this[lt]="ignore",o.resume()):o.size>0&&(this[an]="",o.on("data",c=>this[an]+=c),this[lt]="meta"):(this[Ct]=void 0,o.ignore=o.ignore||!this.filter(o.path,o),o.ignore?(this[Ln]("ignoredEntry",o),this[lt]=o.remain?"ignore":"header",o.resume()):(o.remain?this[lt]="body":(this[lt]="header",o.end()),this[qt]?this[Ht].push(o):(this[Ht].push(o),this[Ha]())))}}}[fu](){queueMicrotask(()=>this.emit("close"))}[cu](t){let e=!0;if(!t)this[qt]=void 0,e=!1;else if(Array.isArray(t)){let[r,...i]=t;this.emit(r,...i)}else this[qt]=t,this.emit("entry",t),t.emittedEnd||(t.on("end",()=>this[Ha]()),e=!1);return e}[Ha](){do;while(this[cu](this[Ht].shift()));if(this[Ht].length===0){let t=this[qt];!t||t.flowing||t.size===t.remain?this[dr]||this.emit("drain"):t.once("drain",()=>this.emit("drain"))}}[Wa](t,e){let r=this[Pn];if(!r)throw new Error("attempt to consume body without entry??");let i=r.blockRemain??0,o=i>=t.length&&e===0?t:t.subarray(e,e+i);return r.write(o),r.blockRemain||(this[lt]="header",this[Pn]=void 0,r.end()),o.length}[lu](t,e){let r=this[Pn],i=this[Wa](t,e);return!this[Pn]&&r&&this[du](r),i}[Ln](t,e,r){this[Ht].length===0&&!this[qt]?this.emit(t,e,r):this[Ht].push([t,e,r])}[du](t){switch(this[Ln]("meta",this[an]),t.type){case"ExtendedHeader":case"OldExtendedHeader":this[Ct]=Us.parse(this[an],this[Ct],!1);break;case"GlobalExtendedHeader":this[ai]=Us.parse(this[an],this[ai],!0);break;case"NextFileHasLongPath":case"OldGnuLongPath":{let e=this[Ct]??Object.create(null);this[Ct]=e,e.path=this[an].replace(/\0.*/,"");break}case"NextFileHasLongLinkpath":{let e=this[Ct]||Object.create(null);this[Ct]=e,e.linkpath=this[an].replace(/\0.*/,"");break}default:throw new Error("unknown meta: "+t.type)}}abort(t){this[dn]=!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[dn])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<Ym)return this[xe]=t,r?.(),!0;for(let l=0;this[Ce]===void 0&&l<ic.length;l++)t[l]!==ic[l]&&(this[Ce]=!1);let o=!1;if(this[Ce]===!1&&this.zstd!==!1){o=!0;for(let l=0;l<sc.length;l++)if(t[l]!==sc[l]){o=!1;break}}let c=this.brotli===void 0&&!o;if(this[Ce]===!1&&c)if(t.length<512)if(this[cn])this.brotli=!0;else return this[xe]=t,r?.(),!0;else try{new Fn(t.subarray(0,512)),this.brotli=!1}catch{this.brotli=!0}if(this[Ce]===void 0||this[Ce]===!1&&(this.brotli||o)){let l=this[cn];this[cn]=!1,this[Ce]=this[Ce]===void 0?new vm({}):o?new Tm({}):new Im({}),this[Ce].on("data",h=>this[bs](h)),this[Ce].on("error",h=>this.abort(h)),this[Ce].on("end",()=>{this[cn]=!0,this[bs]()}),this[dr]=!0;let u=!!this[Ce][l?"end":"write"](t);return this[dr]=!1,r?.(),u}}this[dr]=!0,this[Ce]?this[Ce].write(t):this[bs](t),this[dr]=!1;let i=this[Ht].length>0?!1:this[qt]?this[qt].flowing:!0;return!i&&this[Ht].length===0&&this[qt]?.once("drain",()=>this.emit("drain")),r?.(),i}[Ka](t){t&&!this[dn]&&(this[xe]=this[xe]?Buffer.concat([this[xe],t]):t)}[vs](){if(this[cn]&&!this[ja]&&!this[dn]&&!this[ci]){this[ja]=!0;let t=this[Pn];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[Ln](Ss)}}[bs](t){if(this[ci]&&t)this[Ka](t);else if(!t&&!this[xe])this[vs]();else if(t){if(this[ci]=!0,this[xe]){this[Ka](t);let e=this[xe];this[xe]=void 0,this[Es](e)}else this[Es](t);for(;this[xe]&&this[xe]?.length>=512&&!this[dn]&&!this[As];){let e=this[xe];this[xe]=void 0,this[Es](e)}this[ci]=!1}(!this[xe]||this[cn])&&this[vs]()}[Es](t){let e=0,r=t.length;for(;e+512<=r&&!this[dn]&&!this[As];)switch(this[lt]){case"begin":case"header":this[uu](t,e),e+=512;break;case"ignore":case"body":e+=this[Wa](t,e);break;case"meta":e+=this[lu](t,e);break;default:throw new Error("invalid state: "+this[lt])}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[dn]||(this[Ce]?(t&&this[Ce].write(t),this[Ce].end()):(this[cn]=!0,(this.brotli===void 0||this.zstd===void 0)&&(t=t||Buffer.alloc(0)),t&&this.write(t),this[vs]())),this}},mi=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)},Qm=t=>{let e=t.onReadEntry;t.onReadEntry=e?r=>{e(r),r.resume()}:r=>r.resume()},$u=(t,e)=>{let r=new Map(e.map(c=>[mi(c),!0])),i=t.filter,o=(c,l="")=>{let u=l||dm(c).root||".",h;if(c===u)h=!1;else{let x=r.get(c);h=x!==void 0?x:o(cm(c),u)}return r.set(c,h),h};t.filter=i?(c,l)=>i(c,l)&&o(mi(c)):c=>o(mi(c))},ew=t=>{let e=new Si(t),r=t.file,i;try{i=pr.openSync(r,"r");let o=pr.fstatSync(i),c=t.maxReadSize||16*1024*1024;if(o.size<c){let l=Buffer.allocUnsafe(o.size),u=pr.readSync(i,l,0,o.size,0);e.end(u===l.byteLength?l:l.subarray(0,u))}else{let l=0,u=Buffer.allocUnsafe(c);for(;l<o.size;){let h=pr.readSync(i,u,0,c,l);if(h===0)break;l+=h,e.write(u.subarray(0,h))}e.end()}}finally{if(typeof i=="number")try{pr.closeSync(i)}catch{}}},tw=(t,e)=>{let r=new Si(t),i=t.maxReadSize||16*1024*1024,o=t.file;return new Promise((c,l)=>{r.on("error",l),r.on("end",c),pr.stat(o,(u,h)=>{if(u)l(u);else{let x=new vc(o,{readSize:i,size:h.size});x.on("error",l),x.pipe(r)}})})},_r=Ii(ew,tw,t=>new Si(t),t=>new Si(t),(t,e)=>{e?.length&&$u(t,e),t.noResume||Qm(t)}),Vu=(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:rw,parse:xu}=nw,Tc=t=>{let e="",r=xu(t);for(;rw(t)||r.root;){let i=t.charAt(0)==="/"&&t.slice(0,4)!=="//?/"?"/":r.root;t=t.slice(i.length),e+=i,r=xu(t)}return[e,t]},Vs=["|","<",">","?",":"],Rc=Vs.map(t=>String.fromCodePoint(61440+Number(t.codePointAt(0)))),iw=new Map(Vs.map((t,e)=>[t,Rc[e]])),sw=new Map(Rc.map((t,e)=>[t,Vs[e]])),pu=t=>Vs.reduce((e,r)=>e.split(r).join(iw.get(r)),t),ow=t=>Rc.reduce((e,r)=>e.split(r).join(sw.get(r)),t),Zu=(t,e)=>e?(t=J(t).replace(/^\.(\/|$)/,""),mi(e)+"/"+t):J(t),aw=16*1024*1024,gu=Symbol("process"),mu=Symbol("file"),wu=Symbol("directory"),oc=Symbol("symlink"),_u=Symbol("hardlink"),di=Symbol("header"),Ps=Symbol("read"),ac=Symbol("lstat"),Ls=Symbol("onlstat"),cc=Symbol("onread"),dc=Symbol("onreadlink"),lc=Symbol("openfile"),uc=Symbol("onopenfile"),xn=Symbol("close"),qs=Symbol("mode"),fc=Symbol("awaitDrain"),$a=Symbol("ondrain"),kt=Symbol("prefix"),Ju=class extends Un{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=Sc(e);super(),this.path=J(t),this.portable=!!r.portable,this.maxReadSize=r.maxReadSize||aw,this.linkCache=r.linkCache||new Map,this.statCache=r.statCache||new Map,this.preservePaths=!!r.preservePaths,this.cwd=J(r.cwd||process.cwd()),this.strict=!!r.strict,this.noPax=!!r.noPax,this.noMtime=!!r.noMtime,this.mtime=r.mtime,this.prefix=r.prefix?J(r.prefix):void 0,this.onWriteEntry=r.onWriteEntry,typeof r.onwarn=="function"&&this.on("warn",r.onwarn);let i=!1;if(!this.preservePaths){let[c,l]=Tc(this.path);c&&typeof l=="string"&&(this.path=l,i=c)}this.win32=!!r.win32||process.platform==="win32",this.win32&&(this.path=ow(this.path.replaceAll(/\\/g,"/")),t=t.replaceAll(/\\/g,"/")),this.absolute=J(r.absolute||hu.resolve(this.cwd,t)),this.path===""&&(this.path="./"),i&&this.warn("TAR_ENTRY_INFO",`stripping ${i} from absolute path`,{entry:this,path:i+this.path});let o=this.statCache.get(this.absolute);o?this[Ls](o):this[ac]()}warn(t,e,r={}){return $s(this,t,e,r)}emit(t,...e){return t==="error"&&(this.#e=!0),super.emit(t,...e)}[ac](){Dt.lstat(this.absolute,(t,e)=>{if(t)return this.emit("error",t);this[Ls](e)})}[Ls](t){this.statCache.set(this.absolute,t),this.stat=t,t.isFile()||(t.size=0),this.type=lw(t),this.emit("stat",t),this[gu]()}[gu](){switch(this.type){case"File":return this[mu]();case"Directory":return this[wu]();case"SymbolicLink":return this[oc]();default:return this.end()}}[qs](t){return Vu(t,this.type==="Directory",this.portable)}[kt](t){return Zu(t,this.prefix)}[di](){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 Fn({path:this[kt](this.path),linkpath:this.type==="Link"&&this.linkpath!==void 0?this[kt](this.linkpath):this.linkpath,mode:this[qs](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 Us({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[kt](this.path),linkpath:this.type==="Link"&&this.linkpath!==void 0?this[kt](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)}[wu](){if(!this.stat)throw new Error("cannot create directory entry without stat");this.path.slice(-1)!=="/"&&(this.path+="/"),this.stat.size=0,this[di](),this.end()}[oc](){Dt.readlink(this.absolute,(t,e)=>{if(t)return this.emit("error",t);this[dc](e)})}[dc](t){this.linkpath=J(t),this[di](),this.end()}[_u](t){if(!this.stat)throw new Error("cannot create link entry without stat");this.type="Link",this.linkpath=J(hu.relative(this.cwd,t)),this.stat.size=0,this[di](),this.end()}[mu](){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[_u](e);this.linkCache.set(t,this.absolute)}if(this[di](),this.stat.size===0)return this.end();this[lc]()}[lc](){Dt.open(this.absolute,"r",(t,e)=>{if(t)return this.emit("error",t);this[uc](e)})}[uc](t){if(this.fd=t,this.#e)return this[xn]();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[Ps]()}[Ps](){let{fd:t,buf:e,offset:r,length:i,pos:o}=this;if(t===void 0||e===void 0)throw new Error("cannot read file without first opening");Dt.read(t,e,r,i,o,(c,l)=>{if(c)return this[xn](()=>this.emit("error",c));this[cc](l)})}[xn](t=()=>{}){this.fd!==void 0&&Dt.close(this.fd,t)}[cc](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[xn](()=>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[xn](()=>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[$a]():this[fc](()=>this[$a]())}[fc](t){this.once("drain",t)}write(t,e,r){if(typeof e=="function"&&(r=e,e=void 0),typeof t=="string"&&(t=Buffer.from(t,typeof e=="string"?e:"utf8")),this.blockRemain<t.length){let i=Object.assign(new Error("writing more data than expected"),{path:this.absolute});return this.emit("error",i)}return this.remain-=t.length,this.blockRemain-=t.length,this.pos+=t.length,this.offset+=t.length,super.write(t,null,r)}[$a](){if(!this.remain)return this.blockRemain&&super.write(Buffer.alloc(this.blockRemain)),this[xn](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[Ps]()}},cw=class extends Ju{sync=!0;[ac](){this[Ls](Dt.lstatSync(this.absolute))}[oc](){this[dc](Dt.readlinkSync(this.absolute))}[lc](){this[uc](Dt.openSync(this.absolute,"r"))}[Ps](){let t=!0;try{let{fd:e,buf:r,offset:i,length:o,pos:c}=this;if(e===void 0||r===void 0)throw new Error("fd and buf must be set in READ method");let l=Dt.readSync(e,r,i,o,c);this[cc](l),t=!1}finally{if(t)try{this[xn](()=>{})}catch{}}}[fc](t){t()}[xn](t=()=>{}){this.fd!==void 0&&Dt.closeSync(this.fd),t()}},dw=class extends Un{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 $s(this,t,e,r)}constructor(t,e={}){let r=Sc(e);super(),this.preservePaths=!!r.preservePaths,this.portable=!!r.portable,this.strict=!!r.strict,this.noPax=!!r.noPax,this.noMtime=!!r.noMtime,this.onWriteEntry=r.onWriteEntry,this.readEntry=t;let{type:i}=t;if(i==="Unsupported")throw new Error("writing entry that should be ignored");this.type=i,this.type==="Directory"&&this.portable&&(this.noMtime=!0),this.prefix=r.prefix,this.path=J(t.path),this.mode=t.mode!==void 0?this[qs](t.mode):void 0,this.uid=this.portable?void 0:t.uid,this.gid=this.portable?void 0:t.gid,this.uname=this.portable?void 0:t.uname,this.gname=this.portable?void 0:t.gname,this.size=t.size,this.mtime=this.noMtime?void 0:r.mtime||t.mtime,this.atime=this.portable?void 0:t.atime,this.ctime=this.portable?void 0:t.ctime,this.linkpath=t.linkpath!==void 0?J(t.linkpath):void 0,typeof r.onwarn=="function"&&this.on("warn",r.onwarn);let o=!1;if(!this.preservePaths){let[l,u]=Tc(this.path);l&&typeof u=="string"&&(this.path=u,o=l)}this.remain=t.size,this.blockRemain=t.startBlockSize,this.onWriteEntry?.(this),this.header=new Fn({path:this[kt](this.path),linkpath:this.type==="Link"&&this.linkpath!==void 0?this[kt](this.linkpath):this.linkpath,mode:this.mode,uid:this.portable?void 0:this.uid,gid:this.portable?void 0:this.gid,size:this.size,mtime:this.noMtime?void 0:this.mtime,type:this.type,uname:this.portable?void 0:this.uname,atime:this.portable?void 0:this.atime,ctime:this.portable?void 0:this.ctime}),o&&this.warn("TAR_ENTRY_INFO",`stripping ${o} from absolute path`,{entry:this,path:o+this.path}),this.header.encode()&&!this.noPax&&super.write(new Us({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[kt](this.path),linkpath:this.type==="Link"&&this.linkpath!==void 0?this[kt](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)}[kt](t){return Zu(t,this.prefix)}[qs](t){return Vu(t,this.type==="Directory",this.portable)}write(t,e,r){typeof e=="function"&&(r=e,e=void 0),typeof t=="string"&&(t=Buffer.from(t,typeof e=="string"?e:"utf8"));let i=t.length;if(i>this.blockRemain)throw new Error("writing more to entry than is appropriate");return this.blockRemain-=i,super.write(t,r)}end(t,e,r){return this.blockRemain&&super.write(Buffer.alloc(this.blockRemain)),typeof t=="function"&&(r=t,e=void 0,t=void 0),typeof e=="function"&&(r=e,e=void 0),typeof t=="string"&&(t=Buffer.from(t,e??"utf8")),r&&this.once("finish",r),t?super.end(t,r):super.end(r),this}},lw=t=>t.isFile()?"File":t.isDirectory()?"Directory":t.isSymbolicLink()?"SymbolicLink":"Unsupported",uw=class gr{tail;head;length=0;static create(e=[]){return new gr(e)}constructor(e=[]){for(let r of e)this.push(r)}*[Symbol.iterator](){for(let e=this.head;e;e=e.next)yield e.value}removeNode(e){if(e.list!==this)throw new Error("removing node which does not belong to this list");let r=e.next,i=e.prev;return r&&(r.prev=i),i&&(i.next=r),e===this.head&&(this.head=r),e===this.tail&&(this.tail=i),this.length--,e.next=void 0,e.prev=void 0,e.list=void 0,r}unshiftNode(e){if(e===this.head)return;e.list&&e.list.removeNode(e);let r=this.head;e.list=this,e.next=r,r&&(r.prev=e),this.head=e,this.tail||(this.tail=e),this.length++}pushNode(e){if(e===this.tail)return;e.list&&e.list.removeNode(e);let r=this.tail;e.list=this,e.prev=r,r&&(r.next=e),this.tail=e,this.head||(this.head=e),this.length++}push(...e){for(let r=0,i=e.length;r<i;r++)hw(this,e[r]);return this.length}unshift(...e){for(var r=0,i=e.length;r<i;r++)xw(this,e[r]);return this.length}pop(){if(!this.tail)return;let e=this.tail.value,r=this.tail;return this.tail=this.tail.prev,this.tail?this.tail.next=void 0:this.head=void 0,r.list=void 0,this.length--,e}shift(){if(!this.head)return;let e=this.head.value,r=this.head;return this.head=this.head.next,this.head?this.head.prev=void 0:this.tail=void 0,r.list=void 0,this.length--,e}forEach(e,r){r=r||this;for(let i=this.head,o=0;i;o++)e.call(r,i.value,o,this),i=i.next}forEachReverse(e,r){r=r||this;for(let i=this.tail,o=this.length-1;i;o--)e.call(r,i.value,o,this),i=i.prev}get(e){let r=0,i=this.head;for(;i&&r<e;r++)i=i.next;if(r===e&&i)return i.value}getReverse(e){let r=0,i=this.tail;for(;i&&r<e;r++)i=i.prev;if(r===e&&i)return i.value}map(e,r){r=r||this;let i=new gr;for(let o=this.head;o;)i.push(e.call(r,o.value,this)),o=o.next;return i}mapReverse(e,r){r=r||this;var i=new gr;for(let o=this.tail;o;)i.push(e.call(r,o.value,this)),o=o.prev;return i}reduce(e,r){let i,o=this.head;if(arguments.length>1)i=r;else if(this.head)o=this.head.next,i=this.head.value;else throw new TypeError("Reduce of empty list with no initial value");for(var c=0;o;c++)i=e(i,o.value,c),o=o.next;return i}reduceReverse(e,r){let i,o=this.tail;if(arguments.length>1)i=r;else if(this.tail)o=this.tail.prev,i=this.tail.value;else throw new TypeError("Reduce of empty list with no initial value");for(let c=this.length-1;o;c--)i=e(i,o.value,c),o=o.prev;return i}toArray(){let e=new Array(this.length);for(let r=0,i=this.head;i;r++)e[r]=i.value,i=i.next;return e}toArrayReverse(){let e=new Array(this.length);for(let r=0,i=this.tail;i;r++)e[r]=i.value,i=i.prev;return e}slice(e=0,r=this.length){r<0&&(r+=this.length),e<0&&(e+=this.length);let i=new gr;if(r<e||r<0)return i;e<0&&(e=0),r>this.length&&(r=this.length);let o=this.head,c=0;for(c=0;o&&c<e;c++)o=o.next;for(;o&&c<r;c++,o=o.next)i.push(o.value);return i}sliceReverse(e=0,r=this.length){r<0&&(r+=this.length),e<0&&(e+=this.length);let i=new gr;if(r<e||r<0)return i;e<0&&(e=0),r>this.length&&(r=this.length);let o=this.length,c=this.tail;for(;c&&o>r;o--)c=c.prev;for(;c&&o>e;o--,c=c.prev)i.push(c.value);return i}splice(e,r=0,...i){e>this.length&&(e=this.length-1),e<0&&(e=this.length+e);let o=this.head;for(let l=0;o&&l<e;l++)o=o.next;let c=[];for(let l=0;o&&l<r;l++)c.push(o.value),o=this.removeNode(o);o?o!==this.tail&&(o=o.prev):o=this.tail;for(let l of i)o=fw(this,o,l);return c}reverse(){let e=this.head,r=this.tail;for(let i=e;i;i=i.prev){let o=i.prev;i.prev=i.next,i.next=o}return this.head=r,this.tail=e,this}};function fw(t,e,r){let i=e,o=e?e.next:t.head,c=new Cc(r,i,o,t);return c.next===void 0&&(t.tail=c),c.prev===void 0&&(t.head=c),t.length++,c}function hw(t,e){t.tail=new Cc(e,t.tail,void 0,t),t.head||(t.head=t.tail),t.length++}function xw(t,e){t.head=new Cc(e,void 0,t.head,t),t.tail||(t.tail=t.head),t.length++}var Cc=class{list;next;prev;value;constructor(t,e,r,i){this.list=i,this.value=t,e?(e.next=this,this.prev=e):this.prev=void 0,r?(r.prev=this,this.next=r):this.next=void 0}},bu=class{path;absolute;entry;stat;readdir;pending=!1;pendingLink=!1;ignore=!1;piped=!1;constructor(t,e){this.path=t||"./",this.absolute=e}},Eu=Buffer.alloc(1024),Os=Symbol("onStat"),li=Symbol("ended"),mt=Symbol("queue"),ui=Symbol("queue"),ln=Symbol("current"),Nn=Symbol("process"),fi=Symbol("processing"),Ts=Symbol("processJob"),wt=Symbol("jobs"),Va=Symbol("jobDone"),Ns=Symbol("addFSEntry"),vu=Symbol("addTarEntry"),hc=Symbol("stat"),xc=Symbol("readdir"),Ms=Symbol("onreaddir"),Bs=Symbol("pipe"),Su=Symbol("entry"),Za=Symbol("entryOpt"),zs=Symbol("writeEntryClass"),Yu=Symbol("write"),Ja=Symbol("ondrain"),Zs=class extends Un{sync=!1;opt;cwd;maxReadSize;preservePaths;strict;noPax;prefix;linkCache;statCache;file;portable;zip;readdirCache;noDirRecurse;follow;noMtime;mtime;filter;jobs;[zs];onWriteEntry;[mt];[ui]=new Map;[wt]=0;[fi]=!1;[li]=!1;constructor(t={}){if(super(),this.opt=t,this.file=t.file||"",this.cwd=t.cwd||process.cwd(),this.maxReadSize=t.maxReadSize,this.preservePaths=!!t.preservePaths,this.strict=!!t.strict,this.noPax=!!t.noPax,this.prefix=J(t.prefix||""),this.linkCache=t.linkCache||new Map,this.statCache=t.statCache||new Map,this.readdirCache=t.readdirCache||new Map,this.onWriteEntry=t.onWriteEntry,this[zs]=Ju,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 Em(t.gzip)),t.brotli&&(typeof t.brotli!="object"&&(t.brotli={}),this.zip=new Sm(t.brotli)),t.zstd&&(typeof t.zstd!="object"&&(t.zstd={}),this.zip=new Am(t.zstd)),!this.zip)throw new Error("impossible");let e=this.zip;e.on("data",r=>super.write(r)),e.on("end",()=>super.end()),e.on("drain",()=>this[Ja]()),this.on("resume",()=>e.resume())}else this.on("drain",this[Ja]);this.noDirRecurse=!!t.noDirRecurse,this.follow=!!t.follow,this.noMtime=!!t.noMtime,t.mtime&&(this.mtime=t.mtime),this.filter=typeof t.filter=="function"?t.filter:()=>!0,this[mt]=new uw,this[wt]=0,this.jobs=Number(t.jobs)||4,this[fi]=!1,this[li]=!1}[Yu](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[li]=!0,this[Nn](),r&&r(),this}write(t){if(this[li])throw new Error("write after end");return t instanceof Ku?this[vu](t):this[Ns](t),this.flowing}[vu](t){let e=J(yu.resolve(this.cwd,t.path));if(!this.filter(t.path,t))t.resume();else{let r=new bu(t.path,e);r.entry=new dw(t,this[Za](r)),r.entry.on("end",()=>this[Va](r)),this[wt]+=1,this[mt].push(r)}this[Nn]()}[Ns](t){let e=J(yu.resolve(this.cwd,t));this[mt].push(new bu(t,e)),this[Nn]()}[hc](t){t.pending=!0,this[wt]+=1;let e=this.follow?"stat":"lstat";Gs[e](t.absolute,(r,i)=>{t.pending=!1,this[wt]-=1,r?this.emit("error",r):this[Os](t,i)})}[Os](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[ln])this[Ts](t);else{let r=`${e.dev}:${e.ino}`,i=this[ui].get(r);i?i.push(t):this[ui].set(r,[t]),t.pendingLink=!0,t.pending=!0}this[Nn]()}[xc](t){t.pending=!0,this[wt]+=1,Gs.readdir(t.absolute,(e,r)=>{if(t.pending=!1,this[wt]-=1,e)return this.emit("error",e);this[Ms](t,r)})}[Ms](t,e){this.readdirCache.set(t.absolute,e),t.readdir=e,this[Nn]()}[Nn](){if(!this[fi]){this[fi]=!0;for(let t=this[mt].head;t&&this[wt]<this.jobs;t=t.next)if(this[Ts](t.value),t.value.ignore){let e=t.next;this[mt].removeNode(t),t.next=e}this[fi]=!1,this[li]&&this[mt].length===0&&this[wt]===0&&(this.zip?this.zip.end(Eu):(super.write(Eu),super.end()))}}get[ln](){return this[mt]&&this[mt].head&&this[mt].head.value}[Va](t){this[mt].shift(),this[wt]-=1;let{stat:e}=t;if(e&&e.isFile()&&e.nlink>1){let r=`${e.dev}:${e.ino}`,i=this[ui].get(r);if(i){this[ui].delete(r);for(let o of i)o.pending=!1,this[Ts](o)}}this[Nn]()}[Ts](t){if(t.pending&&t.pendingLink&&t===this[ln]&&(t.pending=!1,t.pendingLink=!1),!t.pending){if(t.entry){t===this[ln]&&!t.piped&&this[Bs](t);return}if(!t.stat){let e=this.statCache.get(t.absolute);e?this[Os](t,e):this[hc](t)}if(t.stat&&!t.ignore){if(!this.noDirRecurse&&t.stat.isDirectory()&&!t.readdir){let e=this.readdirCache.get(t.absolute);if(e?this[Ms](t,e):this[xc](t),!t.readdir)return}if(t.entry=this[Su](t),!t.entry){t.ignore=!0;return}t===this[ln]&&!t.piped&&this[Bs](t)}}}[Za](t){return{onwarn:(e,r,i)=>this.warn(e,r,i),noPax:this.noPax,cwd:this.cwd,absolute:t.absolute,preservePaths:this.preservePaths,maxReadSize:this.maxReadSize,strict:this.strict,portable:this.portable,linkCache:this.linkCache,statCache:this.statCache,noMtime:this.noMtime,mtime:this.mtime,prefix:this.prefix,onWriteEntry:this.onWriteEntry}}[Su](t){this[wt]+=1;try{return new this[zs](t.path,this[Za](t)).on("end",()=>this[Va](t)).on("error",e=>this.emit("error",e))}catch(e){this.emit("error",e)}}[Ja](){this[ln]&&this[ln].entry&&this[ln].entry.resume()}[Bs](t){t.piped=!0,t.readdir&&t.readdir.forEach(i=>{let o=t.path,c=o==="./"?"":o.replace(/\/*$/,"/");this[Ns](c+i)});let e=t.entry,r=this.zip;if(!e)throw new Error("cannot pipe without source");r?e.on("data",i=>{r.write(i)||e.pause()}):e.on("data",i=>{super.write(i)||e.pause()})}pause(){return this.zip&&this.zip.pause(),super.pause()}warn(t,e,r={}){$s(this,t,e,r)}},Dc=class extends Zs{sync=!0;constructor(t){super(t),this[zs]=cw}pause(){}resume(){}[hc](t){let e=this.follow?"statSync":"lstatSync";this[Os](t,Gs[e](t.absolute))}[xc](t){this[Ms](t,Gs.readdirSync(t.absolute))}[Bs](t){let e=t.entry,r=this.zip;if(t.readdir&&t.readdir.forEach(i=>{let o=t.path,c=o==="./"?"":o.replace(/\/*$/,"/");this[Ns](c+i)}),!e)throw new Error("Cannot pipe without source");r?e.on("data",i=>{r.write(i)}):e.on("data",i=>{super[Yu](i)})}},pw=(t,e)=>{let r=new Dc(t),i=new zu(t.file,{mode:t.mode||438});r.pipe(i),Xu(r,e)},gw=(t,e)=>{let r=new Zs(t),i=new Ws(t.file,{mode:t.mode||438});r.pipe(i);let o=new Promise((c,l)=>{i.on("error",l),i.on("close",c),r.on("error",l)});return Qu(r,e).catch(c=>r.emit("error",c)),o},Xu=(t,e)=>{e.forEach(r=>{r.charAt(0)==="@"?_r({file:Fu.resolve(t.cwd,r.slice(1)),sync:!0,noResume:!0,onReadEntry:i=>t.add(i)}):t.add(r)}),t.end()},Qu=async(t,e)=>{for(let r of e)r.charAt(0)==="@"?await _r({file:Fu.resolve(String(t.cwd),r.slice(1)),noResume:!0,onReadEntry:i=>{t.add(i)}}):t.add(r);t.end()},mw=(t,e)=>{let r=new Dc(t);return Xu(r,e),r},ww=(t,e)=>{let r=new Zs(t);return Qu(r,e).catch(i=>r.emit("error",i)),r},N2=Ii(pw,gw,mw,ww,(t,e)=>{if(!e?.length)throw new TypeError("no paths specified to add to archive")}),yw=process.env.__FAKE_PLATFORM__||process.platform,rf=yw==="win32",{O_CREAT:sf,O_NOFOLLOW:Iu,O_TRUNC:of,O_WRONLY:af}=nf.constants,cf=Number(process.env.__FAKE_FS_O_FILENAME__)||nf.constants.UV_FS_O_FILEMAP||0,bw=rf&&!!cf,Ew=512*1024,vw=cf|of|sf|af,Au=!rf&&typeof Iu=="number"?Iu|of|sf|af:null,df=Au!==null?()=>Au:bw?t=>t<Ew?vw:"w":()=>"w",pc=(t,e,r)=>{try{return Js.lchownSync(t,e,r)}catch(i){if(i?.code!=="ENOENT")throw i}},Hs=(t,e,r,i)=>{Js.lchown(t,e,r,o=>{i(o&&o?.code!=="ENOENT"?o:null)})},Sw=(t,e,r,i,o)=>{if(e.isDirectory())lf(wi.resolve(t,e.name),r,i,c=>{if(c)return o(c);let l=wi.resolve(t,e.name);Hs(l,r,i,o)});else{let c=wi.resolve(t,e.name);Hs(c,r,i,o)}},lf=(t,e,r,i)=>{Js.readdir(t,{withFileTypes:!0},(o,c)=>{if(o){if(o.code==="ENOENT")return i();if(o.code!=="ENOTDIR"&&o.code!=="ENOTSUP")return i(o)}if(o||!c.length)return Hs(t,e,r,i);let l=c.length,u=null,h=x=>{if(!u){if(x)return i(u=x);if(--l===0)return Hs(t,e,r,i)}};for(let x of c)Sw(t,x,e,r,h)})},Iw=(t,e,r,i)=>{e.isDirectory()&&uf(wi.resolve(t,e.name),r,i),pc(wi.resolve(t,e.name),r,i)},uf=(t,e,r)=>{let i;try{i=Js.readdirSync(t,{withFileTypes:!0})}catch(o){let c=o;if(c?.code==="ENOENT")return;if(c?.code==="ENOTDIR"||c?.code==="ENOTSUP")return pc(t,e,r);throw c}for(let o of i)Iw(t,o,e,r);return pc(t,e,r)},ff=class extends Error{path;code;syscall="chdir";constructor(t,e){super(`${e}: Cannot cd into '${t}'`),this.path=t,this.code=e}get name(){return"CwdError"}},Ys=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"}},Tw=(t,e)=>{at.stat(t,(r,i)=>{(r||!i.isDirectory())&&(r=new ff(t,r?.code||"ENOTDIR")),e(r)})},Rw=(t,e,r)=>{t=J(t);let i=e.umask??18,o=e.mode|448,c=(o&i)!==0,l=e.uid,u=e.gid,h=typeof l=="number"&&typeof u=="number"&&(l!==e.processUid||u!==e.processGid),x=e.preserve,w=e.unlink,E=J(e.cwd),I=(v,A)=>{v?r(v):A&&h?lf(A,l,u,S=>I(S)):c?at.chmod(t,o,r):r()};if(t===E)return Tw(t,I);if(x)return Aw.mkdir(t,{mode:o,recursive:!0}).then(v=>I(null,v??void 0),I);let b=J(js.relative(E,t)).split("/");gc(E,b,o,w,E,void 0,I)},gc=(t,e,r,i,o,c,l)=>{if(e.length===0)return l(null,c);let u=e.shift(),h=J(js.resolve(t+"/"+u));at.mkdir(h,r,hf(h,e,r,i,o,c,l))},hf=(t,e,r,i,o,c,l)=>u=>{u?at.lstat(t,(h,x)=>{if(h)h.path=h.path&&J(h.path),l(h);else if(x.isDirectory())gc(t,e,r,i,o,c,l);else if(i)at.unlink(t,w=>{if(w)return l(w);at.mkdir(t,r,hf(t,e,r,i,o,c,l))});else{if(x.isSymbolicLink())return l(new Ys(t,t+"/"+e.join("/")));l(u)}}):(c=c||t,gc(t,e,r,i,o,c,l))},Cw=t=>{let e=!1,r;try{e=at.statSync(t).isDirectory()}catch(i){r=i?.code}finally{if(!e)throw new ff(t,r??"ENOTDIR")}},Dw=(t,e)=>{t=J(t);let r=e.umask??18,i=e.mode|448,o=(i&r)!==0,c=e.uid,l=e.gid,u=typeof c=="number"&&typeof l=="number"&&(c!==e.processUid||l!==e.processGid),h=e.preserve,x=e.unlink,w=J(e.cwd),E=v=>{v&&u&&uf(v,c,l),o&&at.chmodSync(t,i)};if(t===w)return Cw(w),E();if(h)return E(at.mkdirSync(t,{mode:i,recursive:!0})??void 0);let I=J(js.relative(w,t)).split("/"),b;for(let v=I.shift(),A=w;v&&(A+="/"+v);v=I.shift()){A=J(js.resolve(A));try{at.mkdirSync(A,i),b=b||A}catch{let S=at.lstatSync(A);if(S.isDirectory())continue;if(x){at.unlinkSync(A),at.mkdirSync(A,i),b=b||A;continue}else if(S.isSymbolicLink())return new Ys(A,A+"/"+I.join("/"))}}return E(b)},Ya=Object.create(null),Tu=1e4,lr=new Set,kw=t=>{lr.has(t)?lr.delete(t):Ya[t]=t.normalize("NFD").toLocaleLowerCase("en").toLocaleUpperCase("en"),lr.add(t);let e=Ya[t],r=lr.size-Tu;if(r>Tu/10){for(let i of lr)if(lr.delete(i),delete Ya[i],--r<=0)break}return e},Pw=process.env.TESTING_TAR_FAKE_PLATFORM||process.platform,Lw=Pw==="win32",Ow=t=>t.split("/").slice(0,-1).reduce((e,r)=>{let i=e.at(-1);return i!==void 0&&(r=xf(i,r)),e.push(r||"/"),e},[]),Nw=class{#e=new Map;#n=new Map;#r=new Set;reserve(t,e){t=Lw?["win32 parallelization disabled"]:t.map(i=>mi(xf(kw(i))));let r=new Set(t.map(i=>Ow(i)).reduce((i,o)=>i.concat(o)));this.#n.set(e,{dirs:r,paths:t});for(let i of t){let o=this.#e.get(i);o?o.push(e):this.#e.set(i,[e])}for(let i of r){let o=this.#e.get(i);if(!o)this.#e.set(i,[new Set([e])]);else{let c=o.at(-1);c instanceof Set?c.add(e):o.push(new Set([e]))}}return this.#i(e)}#s(t){let e=this.#n.get(t);if(!e)throw new Error("function does not have any path reservations");return{paths:e.paths.map(r=>this.#e.get(r)),dirs:[...e.dirs].map(r=>this.#e.get(r))}}check(t){let{paths:e,dirs:r}=this.#s(t);return e.every(i=>i&&i[0]===t)&&r.every(i=>i&&i[0]instanceof Set&&i[0].has(t))}#i(t){return this.#r.has(t)||!this.check(t)?!1:(this.#r.add(t),t(()=>this.#t(t)),!0)}#t(t){if(!this.#r.has(t))return!1;let e=this.#n.get(t);if(!e)throw new Error("invalid reservation");let{paths:r,dirs:i}=e,o=new Set;for(let c of r){let l=this.#e.get(c);if(!l||l?.[0]!==t)continue;let u=l[1];if(!u){this.#e.delete(c);continue}if(l.shift(),typeof u=="function")o.add(u);else for(let h of u)o.add(h)}for(let c of i){let l=this.#e.get(c),u=l?.[0];if(!(!l||!(u instanceof Set)))if(u.size===1&&l.length===1){this.#e.delete(c);continue}else if(u.size===1){l.shift();let h=l[0];typeof h=="function"&&o.add(h)}else u.delete(t)}return this.#r.delete(t),o.forEach(c=>this.#i(c)),!0}},Mw=()=>process.umask(),Ru=Symbol("onEntry"),mc=Symbol("checkFs"),Cu=Symbol("checkFs2"),wc=Symbol("isReusable"),ut=Symbol("makeFs"),_c=Symbol("file"),yc=Symbol("directory"),Fs=Symbol("link"),Du=Symbol("symlink"),ku=Symbol("hardlink"),pi=Symbol("ensureNoSymlink"),Pu=Symbol("unsupported"),Lu=Symbol("checkPath"),Xa=Symbol("stripAbsolutePath"),pn=Symbol("mkdir"),Ge=Symbol("onError"),Rs=Symbol("pending"),Ou=Symbol("pend"),ur=Symbol("unpend"),Qa=Symbol("ended"),ec=Symbol("maybeClose"),bc=Symbol("skip"),_i=Symbol("doChown"),yi=Symbol("uid"),bi=Symbol("gid"),Ei=Symbol("checkedCwd"),Bw=process.env.TESTING_TAR_FAKE_PLATFORM||process.platform,vi=Bw==="win32",zw=1024,Fw=(t,e)=>{if(!vi)return re.unlink(t,e);let r=t+".DELETE."+tf(16).toString("hex");re.rename(t,r,i=>{if(i)return e(i);re.unlink(r,e)})},Uw=t=>{if(!vi)return re.unlinkSync(t);let e=t+".DELETE."+tf(16).toString("hex");re.renameSync(t,e),re.unlinkSync(e)},Nu=(t,e,r)=>t!==void 0&&t===t>>>0?t:e!==void 0&&e===e>>>0?e:r,kc=class extends Si{[Qa]=!1;[Ei]=!1;[Rs]=0;reservations=new Nw;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[Qa]=!0,this[ec]()},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:zw,this.forceChown=t.forceChown===!0,this.win32=!!t.win32||vi,this.newer=!!t.newer,this.keep=!!t.keep,this.noMtime=!!t.noMtime,this.preservePaths=!!t.preservePaths,this.unlink=!!t.unlink,this.cwd=J(Ne.resolve(t.cwd||process.cwd())),this.strip=Number(t.strip)||0,this.processUmask=this.chmod?typeof t.processUmask=="number"?t.processUmask:Mw():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[Ru](e))}warn(t,e,r={}){return(t==="TAR_BAD_ARCHIVE"||t==="TAR_ABORT")&&(r.recoverable=!1),super.warn(t,e,r)}[ec](){this[Qa]&&this[Rs]===0&&(this.emit("prefinish"),this.emit("finish"),this.emit("end"))}[Xa](t,e){let r=t[e],{type:i}=t;if(!r||this.preservePaths)return!0;let[o,c]=Tc(r),l=c.replaceAll(/\\/g,"/").split("/");if(l.includes("..")||vi&&/^[a-z]:\.\.$/i.test(l[0]??"")){if(e==="path"||i==="Link")return this.warn("TAR_ENTRY_ERROR",`${e} contains '..'`,{entry:t,[e]:r}),!1;let u=Ne.posix.dirname(t.path),h=Ne.posix.normalize(Ne.posix.join(u,l.join("/")));if(h.startsWith("../")||h==="..")return this.warn("TAR_ENTRY_ERROR",`${e} escapes extraction directory`,{entry:t,[e]:r}),!1}return o&&(t[e]=String(c),this.warn("TAR_ENTRY_INFO",`stripping ${o} from absolute ${e}`,{entry:t,[e]:r})),!0}[Lu](t){let e=J(t.path),r=e.split("/");if(this.strip){if(r.length<this.strip)return!1;if(t.type==="Link"){let i=J(String(t.linkpath)).split("/");if(i.length>=this.strip)t.linkpath=i.slice(this.strip).join("/");else return!1}r.splice(0,this.strip),t.path=r.join("/")}if(isFinite(this.maxDepth)&&r.length>this.maxDepth)return this.warn("TAR_ENTRY_ERROR","path excessively deep",{entry:t,path:e,depth:r.length,maxDepth:this.maxDepth}),!1;if(!this[Xa](t,"path")||!this[Xa](t,"linkpath"))return!1;if(t.absolute=Ne.isAbsolute(t.path)?J(Ne.resolve(t.path)):J(Ne.resolve(this.cwd,t.path)),!this.preservePaths&&typeof t.absolute=="string"&&t.absolute.indexOf(this.cwd+"/")!==0&&t.absolute!==this.cwd)return this.warn("TAR_ENTRY_ERROR","path escaped extraction target",{entry:t,path:J(t.path),resolvedPath:t.absolute,cwd:this.cwd}),!1;if(t.absolute===this.cwd&&t.type!=="Directory"&&t.type!=="GNUDumpDir")return!1;if(this.win32){let{root:i}=Ne.win32.parse(String(t.absolute));t.absolute=i+pu(String(t.absolute).slice(i.length));let{root:o}=Ne.win32.parse(t.path);t.path=o+pu(t.path.slice(o.length))}return!0}[Ru](t){if(!this[Lu](t))return t.resume();switch(_w.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[mc](t);default:return this[Pu](t)}}[Ge](t,e){t.name==="CwdError"?this.emit("error",t):(this.warn("TAR_ENTRY_ERROR",t,{entry:e}),this[ur](),e.resume())}[pn](t,e,r){Rw(J(t),{uid:this.uid,gid:this.gid,processUid:this.processUid,processGid:this.processGid,umask:this.processUmask,preserve:this.preservePaths,unlink:this.unlink,cwd:this.cwd,mode:e},r)}[_i](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}[yi](t){return Nu(this.uid,t.uid,this.processUid)}[bi](t){return Nu(this.gid,t.gid,this.processGid)}[_c](t,e){let r=typeof t.mode=="number"?t.mode&4095:this.fmode,i=new Ws(String(t.absolute),{flags:df(t.size),mode:r,autoClose:!1});i.on("error",u=>{i.fd&&re.close(i.fd,()=>{}),i.write=()=>!0,this[Ge](u,t),e()});let o=1,c=u=>{if(u){i.fd&&re.close(i.fd,()=>{}),this[Ge](u,t),e();return}--o===0&&i.fd!==void 0&&re.close(i.fd,h=>{h?this[Ge](h,t):this[ur](),e()})};i.on("finish",()=>{let u=String(t.absolute),h=i.fd;if(typeof h=="number"&&t.mtime&&!this.noMtime){o++;let x=t.atime||new Date,w=t.mtime;re.futimes(h,x,w,E=>E?re.utimes(u,x,w,I=>c(I&&E)):c())}if(typeof h=="number"&&this[_i](t)){o++;let x=this[yi](t),w=this[bi](t);typeof x=="number"&&typeof w=="number"&&re.fchown(h,x,w,E=>E?re.chown(u,x,w,I=>c(I&&E)):c())}c()});let l=this.transform&&this.transform(t)||t;l!==t&&(l.on("error",u=>{this[Ge](u,t),e()}),t.pipe(l)),l.pipe(i)}[yc](t,e){let r=typeof t.mode=="number"?t.mode&4095:this.dmode;this[pn](String(t.absolute),r,i=>{if(i){this[Ge](i,t),e();return}let o=1,c=()=>{--o===0&&(e(),this[ur](),t.resume())};t.mtime&&!this.noMtime&&(o++,re.utimes(String(t.absolute),t.atime||new Date,t.mtime,c)),this[_i](t)&&(o++,re.chown(String(t.absolute),Number(this[yi](t)),Number(this[bi](t)),c)),c()})}[Pu](t){t.unsupported=!0,this.warn("TAR_ENTRY_UNSUPPORTED",`unsupported entry type: ${t.type}`,{entry:t}),t.resume()}[Du](t,e){let r=J(Ne.relative(this.cwd,Ne.resolve(Ne.dirname(String(t.absolute)),String(t.linkpath)))).split("/");this[pi](t,this.cwd,r,()=>this[Fs](t,String(t.linkpath),"symlink",e),i=>{this[Ge](i,t),e()})}[ku](t,e){let r=J(Ne.resolve(this.cwd,String(t.linkpath))),i=J(String(t.linkpath)).split("/");this[pi](t,this.cwd,i,()=>this[Fs](t,r,"link",e),o=>{this[Ge](o,t),e()})}[pi](t,e,r,i,o){let c=r.shift();if(this.preservePaths||c===void 0)return i();let l=Ne.resolve(e,c);re.lstat(l,(u,h)=>{if(u)return i();if(h?.isSymbolicLink())return o(new Ys(l,Ne.resolve(l,r.join("/"))));this[pi](t,l,r,i,o)})}[Ou](){this[Rs]++}[ur](){this[Rs]--,this[ec]()}[bc](t){this[ur](),t.resume()}[wc](t,e){return t.type==="File"&&!this.unlink&&e.isFile()&&e.nlink<=1&&!vi}[mc](t){this[Ou]();let e=[t.path];t.linkpath&&e.push(t.linkpath),this.reservations.reserve(e,r=>this[Cu](t,r))}[Cu](t,e){let r=l=>{e(l)},i=()=>{this[pn](this.cwd,this.dmode,l=>{if(l){this[Ge](l,t),r();return}this[Ei]=!0,o()})},o=()=>{if(t.absolute!==this.cwd){let l=J(Ne.dirname(String(t.absolute)));if(l!==this.cwd)return this[pn](l,this.dmode,u=>{if(u){this[Ge](u,t),r();return}c()})}c()},c=()=>{re.lstat(String(t.absolute),(l,u)=>{if(u&&(this.keep||this.newer&&u.mtime>(t.mtime??u.mtime))){this[bc](t),r();return}if(l||this[wc](t,u))return this[ut](null,t,r);if(u.isDirectory()){if(t.type==="Directory"){let h=this.chmod&&t.mode&&(u.mode&4095)!==t.mode,x=w=>this[ut](w??null,t,r);return h?re.chmod(String(t.absolute),Number(t.mode),x):x()}if(t.absolute!==this.cwd)return re.rmdir(String(t.absolute),h=>this[ut](h??null,t,r))}if(t.absolute===this.cwd)return this[ut](null,t,r);Fw(String(t.absolute),h=>this[ut](h??null,t,r))})};this[Ei]?o():i()}[ut](t,e,r){if(t){this[Ge](t,e),r();return}switch(e.type){case"File":case"OldFile":case"ContiguousFile":return this[_c](e,r);case"Link":return this[ku](e,r);case"SymbolicLink":return this[Du](e,r);case"Directory":case"GNUDumpDir":return this[yc](e,r)}}[Fs](t,e,r,i){re[r](e,String(t.absolute),o=>{o?this[Ge](o,t):(this[ur](),t.resume()),i()})}},hi=t=>{try{return[null,t()]}catch(e){return[e,null]}},pf=class extends kc{sync=!0;[ut](t,e){return super[ut](t,e,()=>{})}[mc](t){if(!this[Ei]){let o=this[pn](this.cwd,this.dmode);if(o)return this[Ge](o,t);this[Ei]=!0}if(t.absolute!==this.cwd){let o=J(Ne.dirname(String(t.absolute)));if(o!==this.cwd){let c=this[pn](o,this.dmode);if(c)return this[Ge](c,t)}}let[e,r]=hi(()=>re.lstatSync(String(t.absolute)));if(r&&(this.keep||this.newer&&r.mtime>(t.mtime??r.mtime)))return this[bc](t);if(e||this[wc](t,r))return this[ut](null,t);if(r.isDirectory()){if(t.type==="Directory"){let c=this.chmod&&t.mode&&(r.mode&4095)!==t.mode,[l]=c?hi(()=>{re.chmodSync(String(t.absolute),Number(t.mode))}):[];return this[ut](l,t)}let[o]=hi(()=>re.rmdirSync(String(t.absolute)));this[ut](o,t)}let[i]=t.absolute===this.cwd?[]:hi(()=>Uw(String(t.absolute)));this[ut](i,t)}[_c](t,e){let r=typeof t.mode=="number"?t.mode&4095:this.fmode,i=l=>{let u;try{re.closeSync(o)}catch(h){u=h}(l||u)&&this[Ge](l||u,t),e()},o;try{o=re.openSync(String(t.absolute),df(t.size),r)}catch(l){return i(l)}let c=this.transform&&this.transform(t)||t;c!==t&&(c.on("error",l=>this[Ge](l,t)),t.pipe(c)),c.on("data",l=>{try{re.writeSync(o,l,0,l.length)}catch(u){i(u)}}),c.on("end",()=>{let l=null;if(t.mtime&&!this.noMtime){let u=t.atime||new Date,h=t.mtime;try{re.futimesSync(o,u,h)}catch(x){try{re.utimesSync(String(t.absolute),u,h)}catch{l=x}}}if(this[_i](t)){let u=this[yi](t),h=this[bi](t);try{re.fchownSync(o,Number(u),Number(h))}catch(x){try{re.chownSync(String(t.absolute),Number(u),Number(h))}catch{l=l||x}}}i(l)})}[yc](t,e){let r=typeof t.mode=="number"?t.mode&4095:this.dmode,i=this[pn](String(t.absolute),r);if(i){this[Ge](i,t),e();return}if(t.mtime&&!this.noMtime)try{re.utimesSync(String(t.absolute),t.atime||new Date,t.mtime)}catch{}if(this[_i](t))try{re.chownSync(String(t.absolute),Number(this[yi](t)),Number(this[bi](t)))}catch{}e(),t.resume()}[pn](t,e){try{return Dw(J(t),{uid:this.uid,gid:this.gid,processUid:this.processUid,processGid:this.processGid,umask:this.processUmask,preserve:this.preservePaths,unlink:this.unlink,cwd:this.cwd,mode:e})}catch(r){return r}}[pi](t,e,r,i,o){if(this.preservePaths||r.length===0)return i();let c=e;for(let l of r){c=Ne.resolve(c,l);let[u,h]=hi(()=>re.lstatSync(c));if(u)return i();if(h.isSymbolicLink())return o(new Ys(c,Ne.resolve(e,r.join("/"))))}i()}[Fs](t,e,r,i){let o=`${r}Sync`;try{re[o](e,String(t.absolute)),i(),t.resume()}catch(c){return this[Ge](c,t)}}},Gw=t=>{let e=new pf(t),r=t.file,i=ef.statSync(r),o=t.maxReadSize||16*1024*1024;new am(r,{readSize:o,size:i.size}).pipe(e)},qw=(t,e)=>{let r=new kc(t),i=t.maxReadSize||16*1024*1024,o=t.file;return new Promise((c,l)=>{r.on("error",l),r.on("close",c),ef.stat(o,(u,h)=>{if(u)l(u);else{let x=new vc(o,{readSize:i,size:h.size});x.on("error",l),x.pipe(r)}})})},gf=Ii(Gw,qw,t=>new pf(t),t=>new kc(t),(t,e)=>{e?.length&&$u(t,e)}),Hw=(t,e)=>{let r=new Dc(t),i=!0,o,c;try{try{o=ot.openSync(t.file,"r+")}catch(h){if(h?.code==="ENOENT")o=ot.openSync(t.file,"w+");else throw h}let l=ot.fstatSync(o),u=Buffer.alloc(512);e:for(c=0;c<l.size;c+=512){for(let w=0,E=0;w<512;w+=E){if(E=ot.readSync(o,u,w,u.length-w,c+w),c===0&&u[0]===31&&u[1]===139)throw new Error("cannot append to compressed archives");if(!E)break e}let h=new Fn(u);if(!h.cksumValid)break;let x=512*Math.ceil((h.size||0)/512);if(c+x+512>l.size)break;c+=x,t.mtimeCache&&h.mtime&&t.mtimeCache.set(String(h.path),h.mtime)}i=!1,jw(t,r,c,o,e)}finally{if(i)try{ot.closeSync(o)}catch{}}},jw=(t,e,r,i,o)=>{let c=new zu(t.file,{fd:i,start:r});e.pipe(c),Kw(e,o)},Ww=(t,e)=>{e=Array.from(e);let r=new Zs(t),i=(o,c,l)=>{let u=(I,b)=>{I?ot.close(o,v=>l(I)):l(null,b)},h=0;if(c===0)return u(null,0);let x=0,w=Buffer.alloc(512),E=(I,b)=>{if(I||b===void 0)return u(I);if(x+=b,x<512&&b)return ot.read(o,w,x,w.length-x,h+x,E);if(h===0&&w[0]===31&&w[1]===139)return u(new Error("cannot append to compressed archives"));if(x<512)return u(null,h);let v=new Fn(w);if(!v.cksumValid)return u(null,h);let A=512*Math.ceil((v.size??0)/512);if(h+A+512>c||(h+=A+512,h>=c))return u(null,h);t.mtimeCache&&v.mtime&&t.mtimeCache.set(String(v.path),v.mtime),x=0,ot.read(o,w,0,512,h,E)};ot.read(o,w,0,512,h,E)};return new Promise((o,c)=>{r.on("error",c);let l="r+",u=(h,x)=>{if(h&&h.code==="ENOENT"&&l==="r+")return l="w+",ot.open(t.file,l,u);if(h||!x)return c(h);ot.fstat(x,(w,E)=>{if(w)return ot.close(x,()=>c(w));i(x,E.size,(I,b)=>{if(I)return c(I);let v=new Ws(t.file,{fd:x,start:b});r.pipe(v),v.on("error",c),v.on("close",o),$w(r,e)})})};ot.open(t.file,l,u)})},Kw=(t,e)=>{e.forEach(r=>{r.charAt(0)==="@"?_r({file:mf.resolve(t.cwd,r.slice(1)),sync:!0,noResume:!0,onReadEntry:i=>t.add(i)}):t.add(r)}),t.end()},$w=async(t,e)=>{for(let r of e)r.charAt(0)==="@"?await _r({file:mf.resolve(String(t.cwd),r.slice(1)),noResume:!0,onReadEntry:i=>t.add(i)}):t.add(r);t.end()},xi=Ii(Hw,Ww,()=>{throw new TypeError("file is required")},()=>{throw new TypeError("file is required")},(t,e)=>{if(!pm(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")}),J2=Ii(xi.syncFile,xi.asyncFile,xi.syncNoFile,xi.asyncNoFile,(t,e=[])=>{xi.validate?.(t,e),Vw(t)}),Vw=t=>{let e=t.filter;t.mtimeCache||(t.mtimeCache=new Map),t.filter=e?(r,i)=>e(r,i)&&!((t.mtimeCache?.get(r)??i.mtime??0)>(i.mtime??0)):(r,i)=>!((t.mtimeCache?.get(r)??i.mtime??0)>(i.mtime??0))};rn();var bt={PAIR:"_agent/pair",CREATE:"_agent/create",HEALTH:"_agent/health",LIST_SKILLS:"_agent/listSkills",ADD_SKILLS:"_agent/addSkills",REMOVE_SKILLS:"_agent/removeSkills",GET_FILE_TREE:"_agent/getFileTree",GET_FILE_CONTENT:"_agent/getFileContent",DETAIL:"_agent/detail",UPDATE:"_agent/update",DISCONNECT:"_agent/disconnect",SWITCH_MODEL:"_agent/switchModel",GEN_MODEL_TOKEN:"_agent/genModelToken",RESET:"_agent/reset",REPAIR:"_agent/repair",UPGRADE:"_agent/upgrade",DELETE:"_agent/delete"};function Ai(t){return t?.cozeDeployType==="cloud"?"cloud":"local"}function wf(t){let e=t?.cozeAccountId?.trim();if(!(!e||e==="0"))return e}function Pc(t){let e=t?.cozeGroupId?.trim();if(!(!e||e==="0"))return e}function _f(t){let{_meta:e,...r}=t;return{stripped:r,meta:e}}function yr(t){if(!t?.cozeAgentId)throw new Error("missing _meta.cozeAgentId");return t.cozeAgentId}Kt();Ke();ne();Le();Ke();function wn(t,e){if(Ai(t)!=="cloud")throw new T("OPERATION_NOT_ALLOWED_FOR_LOCAL",`${e} is not allowed for local agent`)}function Ti(t){return t.startsWith("http://")||t.startsWith("https://")}function Xs(t){return t.endsWith("/")?t.slice(0,-1):t}Ke();ne();var Qs="1008033",vf="1289";var Sf="pbbp2",If="https://www.coze.cn",Af="/api/coze_claw/resource/get_frontier_key",n_="https://www.coze.cn",r_="wss://frontier.coze.cn";function eo(t){return t??process.env.COZE_BRIDGE_HANDSHAKE_URL??n_}function Tf(t){return t??process.env.COZE_BRIDGE_FRONTIER_URL??r_}function br(t){let e={},r=t?.ttEnv??process.env.COZE_BRIDGE_TT_ENV,i=t?.usePpe??process.env.COZE_BRIDGE_USE_PPE;return r&&(e["x-tt-env"]=r),i&&(e["x-use-ppe"]=i),e}function Ci(t){return t?t.startsWith("boe_")?{ttEnv:t}:{ttEnv:t,usePpe:"1"}:{}}var Ri=G("handshake");async function Lc(t){let e=eo(t.endpoint),r=t.timeoutMs??1e4,i=`${Xs(e)}${Af}?aid=${encodeURIComponent(Qs)}`,o={Authorization:`Bearer ${t.privatecode}`,Accept:"application/json",...br(t.ppeOverride)},c=new AbortController,l=setTimeout(()=>c.abort(),r);Ri.info("frontier key handshake",{base:e});try{let u=await fetch(i,{method:"GET",headers:o,signal:c.signal}),h=u.headers.get("x-tt-logid")??"",x=u.headers.get("x-tt-trace-id")??"";if(!u.ok){let v=await u.text().catch(()=>"");throw new T("UPSTREAM_HANDSHAKE_FAILED",`handshake HTTP ${u.status} logid=${h}: ${v.slice(0,200)}`)}let w=await u.json();if(w.code!==void 0&&w.code!==0)throw new T("UPSTREAM_HANDSHAKE_FAILED",`handshake code=${w.code} msg=${w.msg??"-"} logid=${h}`);let E=w.data??{},I=typeof E.access_key=="string"&&E.access_key||typeof E.accessKey=="string"&&E.accessKey||void 0,b=typeof E.device_id=="string"&&E.device_id||typeof E.deviceId=="string"&&E.deviceId||void 0;if(!I||!b){let v=JSON.stringify(w).slice(0,500);throw new T("UPSTREAM_HANDSHAKE_FAILED",`handshake response missing access_key/device_id (also tried camelCase) logid=${h}: ${v}`)}return Ri.info("handshake ok",{remoteDeviceId:b,logid:h,traceId:x}),{accessKey:I,deviceId:b}}catch(u){if(u instanceof T)throw Ri.error("handshake failed (bridge error)",{base:e,message:u.message,code:u.code}),u;if(u.name==="AbortError")throw Ri.warn("handshake timeout",{base:e,timeoutMs:r}),new T("UPSTREAM_HANDSHAKE_FAILED",`handshake timeout (${r}ms)`,{cause:u});let h=u.cause;throw Ri.error("handshake error",{base:e,message:u instanceof Error?u.message:String(u),errno:h?.code,syscall:h?.syscall,cause:String(u).slice(0,300)}),new T("UPSTREAM_HANDSHAKE_FAILED",String(u),{cause:u})}finally{clearTimeout(l)}}var Oc=process.env.COZE_BRIDGE_LLM_GATEWAY_URL?.trim()||"https://llm-gateway.coze.cn",Et="auto",Rf=15e4;function Cf(t){return{model:Nc(t.model)??Et,...t.modelToken?{modelToken:t.modelToken}:{}}}function Df(t){return!t||t===Et}var i_=new Set(["auto","\u81EA\u52A8"]);function Nc(t){let e=t?.trim();if(e)return i_.has(e.toLowerCase())?Et:e}function kf(t){let e={};if(t.modelToken){e.ANTHROPIC_BASE_URL=Oc,e.ANTHROPIC_AUTH_TOKEN=t.modelToken;let r=t.model||Et;e.ANTHROPIC_MODEL=r,e.ANTHROPIC_SMALL_FAST_MODEL=r,e.ANTHROPIC_DEFAULT_HAIKU_MODEL=r,e.ANTHROPIC_DEFAULT_OPUS_MODEL=r,e.ANTHROPIC_DEFAULT_SONNET_MODEL=r,e.CLAUDE_CODE_SUBAGENT_MODEL=r,t.modelInfo?.contextWindow&&(e.CLAUDE_CODE_MAX_CONTEXT_TOKENS=String(t.modelInfo.contextWindow))}else Df(t.model)||(e.ANTHROPIC_MODEL=t.model);return e}function Pf(t){let e=[];if(t.modelToken?e.push("-c",`model="${t.model||Et}"`):Df(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="${Oc}/v1"`),e.push("-c",'model_providers.coze.env_key="OPENAI_API_KEY"'),e.push("-c",'model_providers.coze.wire_api="responses"'),e.push("-c","model_providers.coze.requires_openai_auth=false"),e.push("-c","model_providers.coze.supports_websockets=false"),e.push("-c",'model_provider="coze"');let r=t.modelInfo?.contextWindow??Rf;e.push("-c",`model_context_window=${r}`)}return e}function Lf(t){return t.modelToken?{OPENAI_API_KEY:t.modelToken}:{}}function Mc(t,e){let{ttEnv:r,usePpe:i}=Ci(t),o={};return r&&(o["x-tt-env"]=r),i&&(o["x-use-ppe"]=i),e&&(o["x-mock-scenario"]=e),o}function Of(t,e,r){if(!t.modelToken)return{};let i=Mc(e,r);return Object.keys(i).length===0?{}:{ANTHROPIC_CUSTOM_HEADERS:Object.entries(i).map(([c,l])=>`${c}:${l}`).join(`
|
|
92
|
+
`)}}function Bc(t){return`coze-session-${t.replace(/[^A-Za-z0-9_-]+/g,"-")}`}function Nf(t,e,r){if(!t.modelToken)return null;let i=t.model||Et,o=Mc(e,r),c=["text"];t.modelInfo?.capabilities?.image===!0&&c.push("image");let l={baseUrl:`${Oc}/v1`,api:"openai-completions",apiKey:t.modelToken,models:[{id:i,name:i,reasoning:!1,input:c,cost:{input:0,output:0,cacheRead:0,cacheWrite:0},contextWindow:t.modelInfo?.contextWindow??Rf,maxTokens:8192,api:"openai-completions"}]};return Object.keys(o).length>0&&(l.headers=o),l}function Mf(t,e,r){if(!t.modelToken)return[];let i=Mc(e,r),o=[];for(let[c,l]of Object.entries(i))o.push("-c",`model_providers.coze.http_headers.${c}="${l}"`);return o}var Ae=G("agent-handlers"),Bf=5*1024*1024,l_=1,u_=6,f_=new Set(["node_modules",".git",".coze","dist","build",".next"]),h_=/^(ppe|boe)_[A-Za-z0-9_-]{1,120}$/,x_=/^[A-Za-z][A-Za-z0-9._-]{0,63}$/,p_=/^\d+\.\d+\.\d+(?:-[0-9A-Za-z][0-9A-Za-z.-]*)?(?:\+[0-9A-Za-z][0-9A-Za-z.-]*)?$/;function g_(t){let e=t?.trim();return e?p_.test(e)||x_.test(e)?e:(Ae.warn("_agent/upgrade: invalid targetVersion, fallback to latest",{targetVersion:t}),"latest"):"latest"}function m_(t){return new Promise((e,r)=>{let i=nt("npx",t,{detached:!0,stdio:"ignore",windowsHide:!0}),o=!1,c=l=>{o||(o=!0,l?r(l):e(i.pid??0))};i.once("spawn",()=>{i.unref(),c()}),i.once("error",l=>c(l))})}var to=class{constructor(e){this.opts=e}opts;async listSkills(e){wn(e._meta,"_agent/listSkills");let r=yr(e._meta),i=await this.loadAgentCfg(r),o=i?.workspace??Xe(r).workspace,c=i?.skills??[],l=[];for(let u of c){let h=Lt(o,u.relPath,"SKILL.md");await a_(h).then(w=>w.isFile()).catch(()=>!1)&&l.push(E_(u))}return{skills:l}}async addSkills(e){let r=yr(e._meta),i=await this.requireAgentCfg(r),o=e.skills??[],c=[...i.skills??[]],l=new Map(c.map((h,x)=>[h.skillId,x])),u=[];for(let h of o){let x=await jc({agentId:r,workspace:i.workspace,framework:i.framework,skill:h});Wc(c,l,x),u.push(h)}return await as(r,c),this.reloadAgentSessions(r,"skills-added"),{installedSkills:u}}async removeSkills(e){wn(e._meta,"_agent/removeSkills");let r=yr(e._meta),i=await this.requireAgentCfg(r),o=new Set(e.skillIds??[]),c=i.skills??[],l=[];for(let u of c){if(!o.has(u.skillId)){l.push(u);continue}let h=Lt(i.workspace,u.relPath);await o_(h,{recursive:!0,force:!0}),Ae.info("skill removed",{agentId:r,skillId:u.skillId,relPath:u.relPath})}return await as(r,l),this.reloadAgentSessions(r,"skills-removed"),{ok:!0}}reloadAgentSessionsPublic(e,r){this.reloadAgentSessions(e,r)}reloadAgentSessions(e,r){let i=this.opts.agents.get(e);if(i)for(let[o,c]of i.sessions){if(!c.downstream)continue;let l=c.acpSessionId;if(l&&i.activeTriggers.has(l)||this.isRuntimePendingPermission(c)){c.reloadAfterTurn=!0,Ae.info("downstream busy, scheduling reload after turn",{reason:r,agentId:e,framework:i.framework,cloudId:o,acpId:l});continue}let h=c.downstream;c.downstream=void 0,Ae.info("killing downstream for workspace reload (idle)",{reason:r,agentId:e,framework:i.framework,cloudId:o,acpId:l}),h.stop(r).catch(x=>Ae.warn("downstream stop failed during reload (ignored)",{reason:r,agentId:e,cloudId:o,err:String(x)}))}}isRuntimePendingPermission(e){let r=this.opts.isRuntimePendingPermission;return!r||!e.downstream?!1:r(e.downstream)}async updateAgent(e){if(!e.cozeIdentity?.trim())return Ae.info("_agent/update: empty cozeIdentity, noop",{agentId:e.agentId}),{ok:!0};let r=e.agentId,i=await Be(r);if(!i)throw new T("AGENT_NOT_FOUND",`agent not found: ${r}`);if(i.cozeIdentity===e.cozeIdentity)return Ae.info("_agent/update: cozeIdentity unchanged, noop",{agentId:r}),{ok:!0};try{await rr(i.workspace,i.framework,e.cozeIdentity)}catch(o){throw Ae.error("_agent/update: writeInstructionFile failed, aborting update",{agentId:r,framework:i.framework,workspace:i.workspace,err:String(o)}),new T("AGENT_PROTOCOL_ERROR",`failed to write instruction file for agent ${r}: ${String(o)}`,{cause:o})}return i.cozeIdentity=e.cozeIdentity,await Qe(i),Ae.info("_agent/update: cozeIdentity rewritten",{agentId:r,framework:i.framework}),this.reloadAgentSessions(r,"identity-changed"),{ok:!0}}async upgradeBridge(e){let r=e.agentId||e._meta?.cozeAgentId;if(!r)throw new T("IPC_BAD_REQUEST","_agent/upgrade: missing agentId");if(!await Be(r))throw new T("AGENT_NOT_FOUND",`agent not found: ${r}`);let o=["-y"];e.registry&&Ti(e.registry)&&o.push(`--registry=${e.registry}`);let c=g_(e.targetVersion);o.push("--ignore-existing",`coze-bridge@${c}`,"connect");let l=e._meta?.cozeEnv;l&&h_.test(l)&&o.push("--env",l);let u=await m_(o);return Ae.info("_agent/upgrade: spawned bridge upgrade process",{agentId:r,pid:u,targetVersion:c,currentVersion:e.currentVersion??"",reason:e.reason??""}),{ok:!0,accepted:!0,pid:u,message:"bridge upgrade started"}}async disconnectAgent(e){let r=e.agentId;if(!r)throw new T("IPC_BAD_REQUEST","_agent/disconnect: missing agentId");let i=await Be(r);return i?(i.disconnectedAt=Date.now(),i.disconnectReason=e.reason??"",await Qe(i),Ae.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}):(Ae.warn("_agent/disconnect: agent not found, ignoring",{agentId:r}),{ok:!0})}async switchModel(e){if(wn(e._meta,"_agent/switchModel"),!e.agentId)throw new T("IPC_BAD_REQUEST","_agent/switchModel: missing agentId");let r=Nc(e.model)??Et,i=await Be(e.agentId);if(!i)throw new T("AGENT_NOT_FOUND",`agent not found: ${e.agentId}`);i.model=r,e.modelInfo&&(i.modelInfo=e.modelInfo),await Qe(i),Ae.info("_agent/switchModel: model persisted",{agentId:e.agentId,model:r,reason:e.reason??""});let o=this.opts.agents.get(e.agentId);if(!o)return Ae.info("_agent/switchModel: agent not running, config persisted only",{agentId:e.agentId}),{ok:!0};o.model=r,e.modelInfo&&o.setModelInfo(e.modelInfo),this.opts.cleanupOpenclawProviders&&await this.opts.cleanupOpenclawProviders(o).catch(l=>Ae.warn("cleanupOpenclawProviders before switchModel failed (ignored)",{agentId:e.agentId,err:String(l)}));let c=[];for(let[l,u]of o.allSessionQueues())c.push(u.enqueue(async()=>{let h=o.sessions.get(l);h?.downstream&&(await h.downstream.stop(`switchModel: ${r}`).catch(()=>{}),h.downstream=void 0)}));return await Promise.all(c),Ae.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(wn(e._meta,bt.RESET),!e.agentId)throw new T("IPC_BAD_REQUEST",`${bt.RESET}: missing agentId`);return await this.clearSessionMappings(e.agentId,bt.RESET),await this.runDetailSync(e.agentId,bt.RESET,e.reason),{ok:!0}}async clearSessionMappings(e,r){let i=this.opts.agents.get(e);if(!i){await this.clearPersistedAcpSessionIds(e),Ae.info("reset: agent not in memory, cleared persisted acpSessionIds only",{agentId:e});return}await i.killAllRuntimes(r);for(let c of i.sessions.values())c.acpSessionId=void 0,c.replySeq=0,c.loadingSession=!1,c.spawnFailCount=void 0,c.spawnFailedAt=void 0;let o=new Map;for(let[c,l]of i.sessions)o.set(c,{modelToken:l.modelToken,tokenGeneratedAt:l.tokenGeneratedAt});await Qr(e,o)}async clearPersistedAcpSessionIds(e){let r=await Be(e).catch(()=>null);if(!r?.sessions)return;let i=!1;for(let o of Object.values(r.sessions))o.acpSessionId&&(o.acpSessionId=void 0,i=!0);i&&await Qe(r)}async repairAgent(e){if(wn(e._meta,bt.REPAIR),!e.agentId)throw new T("IPC_BAD_REQUEST",`${bt.REPAIR}: missing agentId`);let r=await this.loadAgentCfg(e.agentId);if(r&&r.framework!=="openclaw")throw new T("IPC_BAD_REQUEST",`${bt.REPAIR} only allowed for openclaw, got ${r.framework}`);if(r&&this.opts.openclawRepair)try{await this.opts.openclawRepair(e.agentId,r.workspace)}catch(i){Ae.warn("openclaw repair (delete+add) failed (ignored)",{agentId:e.agentId,reason:e.reason,err:String(i)})}return await this.runDetailSync(e.agentId,bt.REPAIR,e.reason),{ok:!0}}async runDetailSync(e,r,i){if(!this.opts.detailSyncer){Ae.warn("detailSyncer not wired, skipping sync",{method:r,agentId:e});return}try{await this.opts.detailSyncer(e)}catch(o){Ae.warn("detail sync failed (ignored)",{method:r,agentId:e,reason:i,err:String(o)})}}async getFileTree(e){wn(e._meta,"_agent/getFileTree");let r=e._meta,i=yr(r),o=await this.resolveWorkspace(i),c=e.filePath??"",l=this.safeJoin(o,c),u=await zc(l).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 Xr(l,o))throw new T("IPC_BAD_REQUEST",`path escapes workspace: ${c}`);let h=L_(e.depth);return u.isDirectory()?{tree:await P_(o,l,c,h)}:{tree:[{name:O_(c),path:jf(c||"."),isDir:!1,size:u.size,modifiedAt:Math.floor(u.mtimeMs)}]}}async getFileContent(e){wn(e._meta,"_agent/getFileContent");let r=yr(e._meta),i=await this.resolveWorkspace(r);if(!e.filePath)throw new T("IPC_BAD_REQUEST","filePath required");let o=this.safeJoin(i,e.filePath),c=await zc(o).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 Xr(o,i))throw new T("IPC_BAD_REQUEST",`path escapes workspace: ${e.filePath}`);if(c.size>Bf)throw new T("IPC_BAD_REQUEST",`file too large: ${c.size} bytes (max ${Bf})`);let l=await zf(o);return l.includes(0)?{content:l.toString("base64"),encoding:"base64",size:c.size}:{content:l.toString("utf8"),encoding:"utf-8",size:c.size}}async resolveWorkspace(e){let r=this.opts.agents.get(e);return r?r.workspace:(await Be(e).catch(()=>null))?.workspace??Xe(e).workspace}safeJoin(e,r){let i=Gc(e,r||"."),o=Hc(e,i);if(o.startsWith("..")||o===".."||o.startsWith(`..${Ff}`))throw new T("IPC_BAD_REQUEST",`path escapes workspace: ${r}`);return i}loadAgentCfg(e){return Be(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 w_(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 __(t){return t==="claude-code"?Lt(".claude","skills"):Lt(".agents","skills")}var y_=3e4,b_=50*1024*1024,Er=3e4;async function jc(t){let{agentId:e,workspace:r,framework:i,skill:o}=t;if(!o.skillName)throw new T("IPC_BAD_REQUEST","skill missing skillName");let c=typeof o.content=="string"&&o.content.length>0,l=typeof o.downloadUrl=="string"&&o.downloadUrl.length>0;if(!c&&!l)throw new T("IPC_BAD_REQUEST",`skill ${o.skillId} missing both content and downloadUrl`);let u=w_(o.skillName),h=__(i),x=Lt(h,u),w=Lt(r,x);if(await Fc(w,{recursive:!0}),c){let I=Buffer.from(o.content,"utf8");Di(I.length),await Uc(Lt(w,"SKILL.md"),I,"utf8")}else{let I=await v_(o.downloadUrl);I_(I)?await C_(I,w):A_(I)?await T_(I,w):await Uc(Lt(w,"SKILL.md"),I.toString("utf8"),"utf8")}let E={skillId:o.skillId,skillName:o.skillName,relPath:x,installedAt:Date.now(),...o.description?{description:o.description}:{},...o.icon?{icon:o.icon}:{},...o.version?{version:o.version}:{},...o.downloadUrl?{downloadUrl:o.downloadUrl}:{},...o.config?{config:o.config}:{},...o.builtin?{builtin:o.builtin}:{}};return Ae.info("skill installed",{agentId:e,skillId:o.skillId,skillName:o.skillName,relPath:x,source:c?"content":"downloadUrl"}),E}function Wc(t,e,r){let i=e.get(r.skillId);if(i!==void 0){t[i]=r;return}e.set(r.skillId,t.length),t.push(r)}function E_(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 v_(t){if(!t)throw new T("IPC_BAD_REQUEST","skill missing downloadUrl");if(t.startsWith("data:")){let e=Math.floor(t.length*3/4);Di(e);let r=S_(t);return Di(r.length),r}if(t.startsWith("file:")){let e=new URL(t).pathname,r=await zf(e);return Di(r.length),r}if(Ti(t)){let e=new AbortController,r=setTimeout(()=>e.abort(),y_);try{let i=await fetch(t,{signal:e.signal});if(!i.ok)throw new T("IPC_BAD_REQUEST",`fetch skill failed HTTP ${i.status} ${t}`);let o=await i.arrayBuffer();return Di(o.byteLength),Buffer.from(o)}finally{clearTimeout(r)}}throw new T("IPC_BAD_REQUEST",`unsupported downloadUrl scheme (\u8981 https/data/file): ${t.slice(0,80)}`)}function Di(t){if(t>b_)throw new T("IPC_BAD_REQUEST",`skill too large: ${t} bytes`)}function S_(t){let e=/^data:([^,;]*)(;base64)?,(.*)$/s.exec(t);if(!e)throw new T("IPC_BAD_REQUEST","bad data URL");let r=!!e[2],i=e[3]??"";return r?Buffer.from(i,"base64"):Buffer.from(decodeURIComponent(i),"utf8")}function I_(t){return t.length>=2&&t[0]===31&&t[1]===139}function A_(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 qc(t){return t==="__MACOSX"||t.startsWith("__MACOSX/")}async function T_(t,e){let r,i;try{r=new qf.default(t),i=r.getEntries()}catch(l){throw new T("IPC_BAD_REQUEST",`zip parse failed: ${l.message}`,{cause:l})}for(let l of i){let u=l.entryName;if(!u||qc(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(x=>x===".."))throw new T("IPC_BAD_REQUEST",`zip entry contains '..' (traversal): ${u}`);let h=l.header.attr>>>16&61440;if(h!==0&&h!==32768&&h!==16384)throw new T("IPC_BAD_REQUEST",`zip entry kind 0x${h.toString(16)} not allowed (symlink/hardlink/special): ${u}`)}let o=R_(i),c=Gc(e);for(let l of i){if(qc(l.entryName))continue;let u=l.entryName;if(o&&u.startsWith(o)&&(u=u.slice(o.length)),!u)continue;let h=Gc(e,u),x=Hc(c,h);if(x.startsWith("..")||x==="..")throw new T("IPC_BAD_REQUEST",`zip entry escapes destDir: ${u}`);if(l.isDirectory){await Fc(h,{recursive:!0});continue}await Fc(c_(h),{recursive:!0});let w;try{w=l.getData()}catch(E){throw new T("IPC_BAD_REQUEST",`zip entry getData failed (${l.entryName}): ${E.message}`,{cause:E})}await Uc(h,w)}}function R_(t){let e;for(let r of t){let i=r.entryName;if(!i||qc(i))continue;let o=i.indexOf("/");if(o<=0)return;let c=i.slice(0,o+1);if(e===void 0)e=c;else if(e!==c)return}return e}async function C_(t,e){await D_(t);let r=gf({cwd:e,strip:1}),i=!1,o=setTimeout(()=>{i=!0,r.destroy(new T("IPC_BAD_REQUEST",`tar extract timeout (${Er}ms)`))},Er);try{await Gf(Uf.from(t),r)}catch(c){throw c instanceof T?c:i?new T("IPC_BAD_REQUEST",`tar extract timeout (${Er}ms)`):new T("IPC_BAD_REQUEST",`tar extract failed: ${c.message??String(c)}`,{cause:c})}finally{clearTimeout(o)}}async function D_(t){let e=[],r=_r({onReadEntry:c=>{let l=c.path,u=c.type;if(u!=="File"&&u!=="Directory"){e.push(`tar entry kind '${u}' not allowed (symlink/hardlink/special): ${l.slice(0,100)}`);return}if(l.startsWith("/")||l.startsWith("\\")||/^[a-zA-Z]:[\\/]/.test(l)){e.push(`tar entry absolute path: ${l}`);return}l.split(/[/\\]/).some(x=>x==="..")&&e.push(`tar entry contains '..': ${l}`)}}),i=!1,o=setTimeout(()=>{i=!0,r.destroy(new T("IPC_BAD_REQUEST",`tar list timeout (${Er}ms)`))},Er);try{await Gf(Uf.from(t),r)}catch(c){throw i?new T("IPC_BAD_REQUEST",`tar list timeout (${Er}ms)`):new T("IPC_BAD_REQUEST",`tar list failed: ${c.message??String(c)}`,{cause:c})}finally{clearTimeout(o)}if(e.length>0)throw new T("IPC_BAD_REQUEST",e[0]??"tar entry validation failed")}var k_=5e3;async function P_(t,e,r,i){return Hf(t,e,r,i,{count:0})}async function Hf(t,e,r,i,o){if(i<=0)return[];let c;try{c=await s_(e,{withFileTypes:!0})}catch{return[]}let l=[];for(let u of c){if(f_.has(u.name)||u.isSymbolicLink())continue;if(o.count>=k_){l.push({name:"...",path:"...",isDir:!1,size:0,modifiedAt:0,hasMore:!0});break}let h=Lt(e,u.name),x=d_(Lt(r,u.name)),w=null;try{w=await zc(h)}catch{continue}if(w.isSymbolicLink())continue;o.count++;let E={name:u.name,path:jf(Hc(t,h)),isDir:w.isDirectory(),size:w.size,modifiedAt:Math.floor(w.mtimeMs)};w.isDirectory()&&i>1&&(E.children=await Hf(t,h,x,i-1,o)),l.push(E)}return l.sort((u,h)=>u.isDir!==h.isDir?u.isDir?-1:1:u.name.localeCompare(h.name)),l}function L_(t){return!t||t<=0?l_:Math.min(t,u_)}function O_(t){if(!t||t==="."||t==="/")return".";let e=t.split(/[/\\]/);return e[e.length-1]||"."}function jf(t){return t.split(Ff).join("/")}ne();import{readFileSync as uA}from"node:fs";import{dirname as hA,join as xA}from"node:path";import{fileURLToPath as gA}from"node:url";var vr="0.1.100-alpha.1";var _n=G("agent-health-reporter"),N_=1e4,ki=class{constructor(e){this.opts=e;this.intervalMs=e.intervalMs??N_}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()}),_n.info("heartbeat started",{intervalMs:this.intervalMs}),this.tick())}stop(){this.timer&&(clearInterval(this.timer),this.timer=null,this.unsubscribeRegister&&(this.unsubscribeRegister(),this.unsubscribeRegister=null),_n.info("heartbeat stopped"))}async tick(){if(this.inFlight){_n.debug("previous tick still in-flight, skip");return}let e=this.opts.getDeviceId();if(!e){_n.debug("deviceId not available, skip tick (\u5C1A\u672A pair)");return}this.inFlight=!0;try{let r=[];for(let l of this.opts.core.agents.values()){let u=M_(l);if(!u)continue;let h={agentId:l.agentId,status:u};l.patToken&&(h.patToken=l.patToken),l.accountId&&(h.accountId=l.accountId),r.push(h)}if(r.length===0)return;let i={agents:r,bridgeVersion:vr,_meta:{cozeDeviceId:e}},o;try{o=await this.opts.core.sendRequest("_agent/health",i,5e3)}catch(l){_n.warn("heartbeat batch send failed",{count:r.length,err:String(l)})}let c=o?.authFailures;if(c&&c.length>0&&(_n.warn("heartbeat received authFailures from cloud",{count:c.length,agentIds:c.map(l=>l.agentId)}),this.opts.onAuthFailures))try{await this.opts.onAuthFailures(c)}catch(l){_n.warn("onAuthFailures callback failed (ignored)",{err:String(l)})}}finally{this.inFlight=!1}if(this.opts.onTickEnd)try{await this.opts.onTickEnd()}catch(r){_n.warn("onTickEnd hook failed",{err:String(r)})}}};function M_(t){return t.status==="error"?"error":t.activeTriggers.size>0?"busy":t.status==="ok"?"online":null}rn();import{chmod as Ay,mkdir as ho,rm as Ty,stat as Ry,writeFile as Cy}from"node:fs/promises";import{homedir as Dy}from"node:os";import{join as x0}from"node:path";nn();import{existsSync as V_}from"node:fs";import{release as Z_}from"node:os";import{basename as J_,isAbsolute as Y_}from"node:path";function Pi(t,e,r){return r===void 0?{jsonrpc:"2.0",id:t,method:e}:{jsonrpc:"2.0",id:t,method:e,params:r}}function Sr(t,e){return e===void 0?{jsonrpc:"2.0",method:t}:{jsonrpc:"2.0",method:t,params:e}}function Ir(t,e){return{jsonrpc:"2.0",id:t,result:e}}function yn(t,e){return{jsonrpc:"2.0",id:t,error:e}}Ke();var no=class extends Error{code;data;constructor(e){super(`JSON-RPC error code=${e.code} ${e.message}`),this.name="RemoteRpcError",this.code=e.code,e.data!==void 0&&(this.data=e.data)}},Q={PARSE_ERROR:-32700,INVALID_REQUEST:-32600,METHOD_NOT_FOUND:-32601,INVALID_PARAMS:-32602,INTERNAL_ERROR:-32603,AGENT_NOT_FOUND:-32001,AGENT_BUSY:-32002,AGENT_TIMEOUT:-32003,AGENT_SPAWN_FAILED:-32004,OPERATION_NOT_ALLOWED_FOR_LOCAL:-32005,AGENT_DISCONNECTED:-32006,MODEL_TOKEN_GEN_FAILED:-32009,PATH_OUTSIDE_WORKSPACE:-32010,FILE_TOO_LARGE:-32011,UNSUPPORTED_MIME:-32012,UPLOAD_FAILED:-32013,UPSTREAM_NOT_READY:-32014,AGENT_FRAME_IDLE_TIMEOUT:-32016,MODEL_MODALITY_UNSUPPORTED:-32017,AGENT_DEPENDENCY_INSTALL_FAILED:-32018,AGENT_APPROVAL_TIMEOUT:-32019,AGENT_TURN_ABORTED:-32020,AGENT_ENV_NOT_READY:-32021};function Wf(t){return"method"in t&&"id"in t&&t.id!==void 0}function Kf(t){return"method"in t&&!("id"in t)}function ro(t){return!("method"in t)&&"id"in t}var B_={AGENT_NOT_FOUND:Q.AGENT_NOT_FOUND,AGENT_BUSY:Q.AGENT_BUSY,AGENT_DISCONNECTED:Q.AGENT_DISCONNECTED,AGENT_TIMEOUT:Q.AGENT_TIMEOUT,AGENT_FRAME_IDLE_TIMEOUT:Q.AGENT_FRAME_IDLE_TIMEOUT,AGENT_SPAWN_FAILED:Q.AGENT_SPAWN_FAILED,AGENT_PROTOCOL_ERROR:Q.INTERNAL_ERROR,BRIDGE_CONFIG_INVALID:Q.INTERNAL_ERROR,BRIDGE_INTERNAL:Q.INTERNAL_ERROR,IPC_AUTH_FAILED:Q.INTERNAL_ERROR,IPC_BAD_REQUEST:Q.INVALID_REQUEST,MODEL_TOKEN_GEN_FAILED:Q.MODEL_TOKEN_GEN_FAILED,MODEL_MODALITY_UNSUPPORTED:Q.MODEL_MODALITY_UNSUPPORTED,OPERATION_NOT_ALLOWED_FOR_LOCAL:Q.OPERATION_NOT_ALLOWED_FOR_LOCAL,UPSTREAM_DISCONNECTED:Q.INTERNAL_ERROR,UPSTREAM_HANDSHAKE_FAILED:Q.INTERNAL_ERROR,PATH_OUTSIDE_WORKSPACE:Q.PATH_OUTSIDE_WORKSPACE,FILE_TOO_LARGE:Q.FILE_TOO_LARGE,UNSUPPORTED_MIME:Q.UNSUPPORTED_MIME,UPLOAD_FAILED:Q.UPLOAD_FAILED,UPSTREAM_NOT_READY:Q.UPSTREAM_NOT_READY,AGENT_DEPENDENCY_INSTALL_FAILED:Q.AGENT_DEPENDENCY_INSTALL_FAILED,AGENT_APPROVAL_TIMEOUT:Q.AGENT_APPROVAL_TIMEOUT,AGENT_TURN_ABORTED:Q.AGENT_TURN_ABORTED,AGENT_ENV_NOT_READY:Q.AGENT_ENV_NOT_READY};function z_(t){if(t!=null)return t instanceof Error?{name:t.name,message:Li(t.message)}:typeof t=="string"?Li(t):typeof t=="object"?U_(t):t}var F_=[[/\/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 Li(t){let e=t;for(let[r,i]of F_)e=e.replace(r,i);return e}function U_(t){let e={};for(let[r,i]of Object.entries(t))typeof i=="string"?e[r]=Li(i):e[r]=i;return e}function Oi(t){if(t instanceof T){let e=z_(t.cause),r={bridgeCode:t.code,retriable:t.retriable};return e!==void 0&&(r.cause=e),e&&typeof e=="object"&&"reason"in e&&typeof e.reason=="string"&&(r.reason=e.reason),{code:B_[t.code]??Q.INTERNAL_ERROR,message:Li(t.message),data:r}}return{code:Q.INTERNAL_ERROR,message:Li(t instanceof Error?t.message:String(t))}}function $f(t){let e=t.data,r=e?.bridgeCode??"AGENT_PROTOCOL_ERROR",i=!!e&&typeof e.message=="string"&&!!e.message,o=i?e?.message:t.message,c=t.data;if(i&&e){let{message:l,...u}=e;c=u}return new T(r,o,{retriable:e?.retriable??!1,cause:c})}function Zf(t){return`${JSON.stringify(t)}
|
|
93
|
+
`}var Vf=10*1024*1024,io=class{buffer="";onError;constructor(e={}){this.onError=e.onError}push(e){if(this.buffer+=typeof e=="string"?e:e.toString("utf8"),this.buffer.length>Vf){let o=this.buffer.length;return this.buffer="",this.onError?.({line:`<buffer overflow: ${o} bytes, dropped>`,error:new Error(`LdjsonDecoder buffer exceeded ${Vf} bytes`)}),[]}let r=this.buffer.split(`
|
|
94
|
+
`);this.buffer=r.pop()??"";let i=[];for(let o of r){let c=o.replace(/\r$/,"").trim();if(c)try{i.push(JSON.parse(c))}catch(l){this.onError?.({line:c,error:l})}}return i}flush(){if(!this.buffer)return[];let e=this.buffer.replace(/\r$/,"").trim();if(this.buffer="",!e)return[];try{return[JSON.parse(e)]}catch(r){return this.onError?.({line:e,error:r}),[]}}};var Yf={"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"},TA=Object.fromEntries(Object.entries(Yf).map(([t,e])=>[e,t])),G_={"session.prompt":["agentId","triggerMsgId","sessionId"],"session.cancel":["agentId","triggerMsgId","sessionId"],"session.new":["agentId"],"session.load":["agentId"],"agent.create":["agentId"],"agent.health":[],"agent.listSkills":["agentId"],"agent.addSkills":["agentId"],"agent.removeSkills":["agentId"],"agent.getFileTree":["agentId"],"agent.getFileContent":["agentId"],"agent.detail":["agentId"],"agent.update":["agentId"],"agent.disconnect":["agentId"],"agent.switchModel":["agentId"],"agent.genModelToken":["agentId","sessionId"],"agent.reset":["agentId"],"agent.repair":["agentId"],"session.requestPermission":["agentId","sessionId"],"agent.pair":[],initialize:[]},Ar=class{seq=0;next(e,r){this.seq+=1;let i=Yf[e]??q_(e),o=G_[i]??[],c=[i,String(this.seq)];if(o.length>0){let l=o.map(h=>Jf(r?.[h]??"")),u=H_(l).join(":");u&&c.push(u)}else r&&Object.values(r).some(l=>l)&&c.push(Object.values(r).filter(Boolean).map(l=>Jf(String(l))).join(":"));return c.join("_")}reset(){this.seq=0}};function q_(t){return t.replace(/[\s/]+/g,".").replace(/_+/g,"-")}function Jf(t){return t.replace(/[:_\s]+/g,"-")}function H_(t){let e=t.length;for(;e>0&&!t[e-1];)e-=1;return t.slice(0,e)}Yr();import{readFileSync as j_}from"node:fs";var W_=384;async function Kc(t,e=process.env){let r={};for(let[i,o]of Object.entries(e))typeof o=="string"&&(r[i]=o);await nr(t.agentEnvFile,r,{mode:W_})}function $c(t){try{let e=JSON.parse(j_(t,"utf8"));return e&&typeof e=="object"&&!Array.isArray(e)?e:{}}catch{return{}}}function Xf(t,e,r={},i=o=>o){return{...i({...t,...$c(e)}),...r}}Kt();Wr();Ke();ne();Le();import{spawnSync as K_}from"node:child_process";function so(t){try{return process.kill(t,0),!0}catch(e){return e.code==="EPERM"}}function oo(t,e){if(!(typeof t!="number"||t<=0))try{if(process.platform==="win32"){let r=["/PID",String(t),"/T"];e==="SIGKILL"&&r.push("/F"),K_("taskkill",r,{stdio:"ignore",windowsHide:!0})}else process.kill(-t,e)}catch{}}var Vc=new Set;function Qf(t){typeof t=="number"&&t>0&&Vc.add(t)}function e0(t){typeof t=="number"&&Vc.delete(t)}function t0(){for(let t of Vc)oo(t,"SIGKILL")}var $_=[{reason:"openclaw_scope_approval_pending",bridgeCode:"AGENT_ENV_NOT_READY",frameworks:["openclaw"],match:/scope upgrade pending approval/i,message:"openclaw \u9700\u8981\u4F60\u5728\u672C\u673A\u6279\u51C6\u4E00\u6B21\u6743\u9650\u5347\u7EA7 (scope upgrade)\uFF0C\u8BF7\u5728\u672C\u673A openclaw \u5B8C\u6210\u6388\u6743\u540E\u91CD\u8BD5"},{reason:"openclaw_pairing_required",bridgeCode:"AGENT_ENV_NOT_READY",frameworks:["openclaw"],match:/pairing required/i,message:"openclaw \u5C1A\u672A\u5B8C\u6210\u914D\u5BF9\uFF0C\u8BF7\u5148\u5728\u672C\u673A\u5B8C\u6210 openclaw \u914D\u5BF9\u540E\u91CD\u8BD5"},{reason:"openclaw_gateway_token_unavailable",bridgeCode:"AGENT_ENV_NOT_READY",frameworks:["openclaw"],match:/gateway\.auth\.token.*(unavailable|secret reference)/i,message:"openclaw gateway token \u914D\u7F6E\u4E0D\u53EF\u7528 (\u914D\u6210\u4E86 secret \u5F15\u7528\u4F46\u5F53\u524D\u8DEF\u5F84\u53D6\u4E0D\u5230)\uFF0C\u8BF7\u68C0\u67E5\u672C\u673A openclaw \u7684 gateway.auth.token \u914D\u7F6E"},{reason:"openclaw_version_mismatch",bridgeCode:"AGENT_ENV_NOT_READY",frameworks:["openclaw"],match:/protocol mismatch/i,message:"openclaw \u7248\u672C\u4E0E\u672C\u673A gateway \u4E0D\u517C\u5BB9 (protocol mismatch)\uFF0C\u8BF7\u5347\u7EA7\u672C\u673A openclaw \u5230\u6700\u65B0\u7248\u540E\u91CD\u8BD5"},{reason:"openclaw_gateway_not_ready",bridgeCode:"AGENT_ENV_NOT_READY",frameworks:["openclaw"],match:/gateway closed (before ready|\(\d+\))/i,message:"openclaw gateway \u672A\u5C31\u7EEA (\u53EF\u80FD\u6B63\u5728\u542F\u52A8)\uFF0C\u8BF7\u7A0D\u540E\u91CD\u8BD5"},{reason:"openclaw_config_invalid",bridgeCode:"AGENT_ENV_NOT_READY",frameworks:["openclaw"],match:/OpenClaw config is invalid|Config invalid|Invalid config at|config was written by version/i,message:"\u4F60\u7684\u672C\u673A openclaw \u914D\u7F6E\u975E\u6CD5 (~/.openclaw/openclaw.json)\uFF0C\u8BF7\u8FD0\u884C `openclaw doctor --fix` \u6216 `openclaw config validate` \u4FEE\u590D\u540E\u91CD\u8BD5"},{reason:"openclaw_tls_self_signed",bridgeCode:"AGENT_ENV_NOT_READY",frameworks:["openclaw"],match:/self-signed certificate/i,message:"openclaw \u8FDE\u63A5\u88AB\u81EA\u7B7E\u8BC1\u4E66/\u4F01\u4E1A\u4EE3\u7406\u62E6\u622A (self-signed certificate)\uFF0C\u8BF7\u68C0\u67E5\u672C\u673A\u7F51\u7EDC/\u4EE3\u7406\u6216\u8BC1\u4E66\u914D\u7F6E\u540E\u91CD\u8BD5"},{reason:"openclaw_node_binary_not_found",bridgeCode:"AGENT_ENV_NOT_READY",frameworks:["openclaw"],match:/\[qclaw-cli\] Error: Node binary not found/i,message:"\u672C\u673A\u627E\u4E0D\u5230 node \u4E8C\u8FDB\u5236 (qclaw \u542F\u52A8\u5931\u8D25)\uFF0C\u8BF7\u68C0\u67E5\u672C\u673A Node \u5B89\u88C5\u4E0E PATH \u540E\u91CD\u8BD5"},{reason:"openclaw_gateway_unavailable",bridgeCode:"AGENT_ENV_NOT_READY",frameworks:["openclaw"],match:/ECONNREFUSED|\[object ErrorEvent\]|gateway connect failed|gateway (not connected|disconnected)/i,message:"openclaw gateway \u672A\u8FD0\u884C/\u672A\u8FDE\u63A5 (\u8FDE\u63A5\u672C\u673A gateway \u88AB\u62D2\u6216\u4F1A\u8BDD\u671F\u95F4\u65AD\u5F00)\uFF0C\u8BF7\u5728\u672C\u673A\u542F\u52A8 openclaw gateway \u540E\u91CD\u8BD5"},{reason:"openclaw_shim_bug",bridgeCode:"AGENT_SPAWN_FAILED",frameworks:["openclaw"],match:/openclaw-shim\/bin\/openclaw.*unbound variable/i,message:"openclaw \u542F\u52A8 shim \u811A\u672C\u5F02\u5E38 (unbound variable)\uFF0C\u8BF7\u53CD\u9988\u73AF\u5883\u7EF4\u62A4\u65B9\u4FEE\u590D shim"},{reason:"codex_user_config_invalid",bridgeCode:"AGENT_ENV_NOT_READY",frameworks:["codex"],match:/error loading config:.*config\.toml|model_catalog_json|wire_api/i,message:"\u4F60\u7684\u672C\u673A ~/.codex/config.toml \u914D\u7F6E\u6709\u8BEF\uFF0C\u8BF7\u6309 codex \u62A5\u9519\u63D0\u793A\u4FEE\u6B63\u540E\u91CD\u8BD5"},{reason:"codex_provider_invalid",bridgeCode:"AGENT_ENV_NOT_READY",frameworks:["codex"],match:/error loading config: Model provider .* not found/i,message:"\u4F60\u7684\u672C\u673A codex \u914D\u7F6E\u5F15\u7528\u4E86\u4E0D\u5B58\u5728\u7684 model provider\uFF0C\u8BF7\u4FEE\u6B63 ~/.codex \u914D\u7F6E\u540E\u91CD\u8BD5"},{reason:"codex_path_update_failed",bridgeCode:"AGENT_ENV_NOT_READY",frameworks:["codex"],match:/could not update PATH[\s\S]*Operation not permitted/i,message:"codex \u56E0\u672C\u673A\u6743\u9650\u9650\u5236\u65E0\u6CD5\u66F4\u65B0 PATH/\u8BFB\u53D6\u914D\u7F6E (Operation not permitted)\uFF0C\u8BF7\u68C0\u67E5 ~/.codex \u76EE\u5F55\u6743\u9650\u6216\u91CD\u65B0\u6388\u4E88\u7EC8\u7AEF\u5B8C\u5168\u78C1\u76D8\u8BBF\u95EE\u540E\u91CD\u8BD5"},{reason:"codex_acp_exec_failed",bridgeCode:"AGENT_SPAWN_FAILED",frameworks:["codex"],match:/Failed to execute[\s\S]*codex-acp|spawnSync[\s\S]*codex-acp/i,message:"codex ACP \u4E8C\u8FDB\u5236\u6267\u884C\u5931\u8D25\uFF0C\u8BF7\u91CD\u65B0\u6267\u884C pair/connect \u89E6\u53D1\u4F9D\u8D56\u5B89\u88C5"},{reason:"codex_platform_binary_missing",bridgeCode:"AGENT_SPAWN_FAILED",frameworks:["codex"],match:/Failed to locate @zed-industries\/codex-acp|optional dependency was not installed|\.resolve is not a function/i,message:"codex ACP \u4F9D\u8D56\u7684\u5E73\u53F0\u4E8C\u8FDB\u5236\u7F3A\u5931\uFF0C\u8BF7\u91CD\u65B0\u6267\u884C pair/connect \u89E6\u53D1\u4F9D\u8D56\u5B89\u88C5"},{reason:"node_version_too_old",bridgeCode:"AGENT_ENV_NOT_READY",frameworks:["claude-code","openclaw"],match:/import .* with \{ type: ["']json["'] \}|import assertion|import attribute|openclaw\.mjs[\s\S]*Unexpected token '\.'/i,message:"\u672C\u673A Node \u7248\u672C\u8FC7\u4F4E (ACP \u9700\u8981\u8F83\u65B0 Node \u624D\u652F\u6301 import attributes / \u53EF\u9009\u94FE)\uFF0C\u8BF7\u5347\u7EA7 Node \u5230 \u2265 20.10 \u540E\u91CD\u8BD5"},{reason:"acp_cmd_misexec",bridgeCode:"AGENT_SPAWN_FAILED",frameworks:["claude-code"],match:/claude-agent-acp\.cmd.*@ECHO off|\.cmd:\d+/i,message:"claude ACP wrapper \u542F\u52A8\u65B9\u5F0F\u5F02\u5E38 (Windows .cmd \u88AB\u8BEF\u5F53\u811A\u672C\u6267\u884C)\uFF0C\u8BF7\u91CD\u65B0\u6267\u884C pair/connect"}];function n0(t,e){if(!e)return null;for(let r of $_)if(!(r.frameworks&&!r.frameworks.includes(t))&&r.match.test(e))return{bridgeCode:r.bridgeCode,reason:r.reason,message:r.message};return null}function r0(t,e){return n0(t,e)}function i0(t,e){return n0(t,e)}function Tr(t,e,r){return!e&&r.firstUpdateMs>0&&t<r.firstUpdateMs?Math.max(1,r.firstUpdateMs-t):t<r.phase2GateMs?Math.max(1,r.phase2GateMs-t):Math.max(1,r.livenessWindowMs)}function s0(t,e,r){let o=r-t.armedAt-t.expectedIntervalMs;if(o>e.suspendThresholdMs){let x=t.suspendedMs+o,w=r-t.startedAt-x;return{action:"suspend",suspendedDeltaMs:o,rearmMs:Tr(w,t.firstFrameSeen,e)}}let c=r-t.startedAt-t.suspendedMs,l=t.awaitingApproval?e.approvalMaxMs:e.absoluteMaxMs;return c>=l?{action:"reject-backstop",awaitingApproval:t.awaitingApproval}:t.firstFrameSeen?c<e.phase2GateMs?{action:"continue",rearmMs:Tr(c,!0,e)}:r-t.lastActivityAt<e.livenessWindowMs||t.hasActiveTool||t.awaitingApproval?{action:"continue",rearmMs:Tr(c,!0,e)}:{action:"reject-idle"}:e.firstUpdateMs>0&&c>=e.firstUpdateMs&&!t.awaitingApproval?{action:"reject-idle"}:{action:"continue",rearmMs:Tr(c,!1,e)}}var o0=Ye("COZE_BRIDGE_INITIALIZE_TIMEOUT_MS",3e4),X_=200,Q_=40,ey=Ye("COZE_BRIDGE_SESSION_PROMPT_MAX_MS",3600*1e3),ty=Ye("COZE_BRIDGE_SESSION_PROMPT_IDLE_MS",600*1e3),ny=Ye("COZE_BRIDGE_SESSION_PROMPT_ABSOLUTE_MAX_MS",7200*1e3),ry=Ye("COZE_BRIDGE_SUSPEND_THRESHOLD_MS",60*1e3),iy=Ye("COZE_BRIDGE_SESSION_PROMPT_FIRST_UPDATE_MS",600*1e3),sy=Ye("COZE_BRIDGE_SESSION_PROMPT_APPROVAL_MAX_MS",1440*60*1e3),a0=500;function oy(t){try{let e=JSON.stringify(t);return e===void 0||e.length<=a0?t:`${e.slice(0,a0)}...<truncated, total ${e.length} chars>`}catch{return"<unserializable>"}}function ay(t){let e=[];typeof t.message=="string"&&e.push(t.message);let{data:r}=t;if(typeof r=="string")e.push(r);else if(r&&typeof r=="object")try{e.push(JSON.stringify(r))}catch{}return e.join(" ")}function c0(t){try{return V_(t)}catch{return}}function cy(t,e){return{platform:process.platform,osRelease:Z_(),code:t.code,errno:t.errno,syscall:t.syscall,errPath:t.path,command:e.command,commandExists:Y_(e.command)?c0(e.command):void 0,cwd:e.cwd,cwdExists:c0(e.cwd),envKeys:e.envKeys}}function dy(t,e){return`${t.message} [diag: platform=${e.platform} os=${e.osRelease} code=${e.code} errno=${e.errno} syscall=${e.syscall} cmd=${J_(e.command)} cmdExists=${e.commandExists} cwdExists=${e.cwdExists} envKeys=${e.envKeys}]`}var Ot=class{constructor(e){this.opts=e;this.log=G(`downstream.${this.constructor.name}`,this.opts.agentId),this.decoder=new io({onError:r=>this.log.warn("decode line failed",{line:r.line})})}opts;child;decoder;pending=new Map;inflightAgentRequests=new Map;idAllocator=new Ar;updateHandlers=[];agentRequestHandlers=[];exitHandlers=[];log;stopped=!1;stopReason;stderrRing=[];now=Date.now;sanitizeEnv(e){return e}async start(){if(this.child)throw new T("BRIDGE_INTERNAL","Downstream already started");let e=process.platform!=="win32",r=Xf(process.env,this.opts.agentEnvFile??Y().agentEnvFile,this.opts.env,o=>this.sanitizeEnv(o)),i=nt(this.opts.command,this.opts.args,{cwd:this.opts.cwd,env:r,stdio:["pipe","pipe","pipe"],detached:e});this.child=i,Qf(i.pid),i.stdout?.setEncoding("utf8"),i.stdout?.on("data",o=>{try{for(let c of this.decoder.push(o))this.dispatch(c)}catch(c){this.log.warn("stdout dispatch threw, swallowed to keep daemon alive",{err:String(c)})}}),i.stderr?.setEncoding("utf8"),i.stderr?.on("data",o=>{let c=o.trimEnd();this.stderrRing.push(c),this.stderrRing.length>X_&&this.stderrRing.shift(),this.log.debug("stderr",{text:c})}),i.stdin?.on("error",o=>{this.log.warn("child stdin error",{err:String(o)})}),i.stdout?.on("error",o=>{this.log.warn("child stdout error",{err:String(o)})}),i.stderr?.on("error",o=>{this.log.warn("child stderr error",{err:String(o)})}),i.on("exit",(o,c)=>{this.stopped=!0,e0(i.pid),(o!==0||c!==null)&&this.stderrRing.length>0&&this.log.warn("downstream exited abnormally, recent stderr",{code:o,signal:c,recentStderr:[...this.stderrRing]});try{for(let u of this.decoder.flush())this.dispatch(u)}catch(u){this.log.debug("decoder.flush on exit threw (ignored)",{err:String(u)})}this.failAllPending(this.buildExitError(o,c));for(let u of this.exitHandlers)u(o,c)}),i.on("error",o=>{let c=o,l=cy(c,{command:this.opts.command,cwd:this.opts.cwd,envKeys:Object.keys(r).length});this.log.error("child error",{err:String(o),diag:l}),this.failAllPending(new T("AGENT_SPAWN_FAILED",dy(c,l),{cause:l}))}),this.log.info("downstream started",{command:this.opts.command,pid:i.pid,cwd:this.opts.cwd})}async stop(e){if(!this.child||this.stopped)return;this.stopped=!0,this.stopReason=e??"stopped",this.log.info("downstream stopping",{reason:e});let r=this.child,i=new Promise(c=>r.once("exit",()=>c()));oo(r.pid,"SIGTERM");let o=setTimeout(()=>{r.killed||oo(r.pid,"SIGKILL")},5e3);try{await i}finally{clearTimeout(o)}}pid(){return this.child?.pid}isAlive(){return!!this.child&&!this.stopped}getStderrTail(e){return e===void 0?[...this.stderrRing]:this.stderrRing.slice(-e)}initialize(e){return this.call("initialize",e)}sessionNew(e){return this.call("session/new",{mcpServers:[],...e})}sessionLoad(e){return this.call("session/load",{mcpServers:[],...e})}sessionPrompt(e,r){let i={firstUpdateMs:iy,phase2GateMs:ey,livenessWindowMs:ty,absoluteMaxMs:ny,approvalMaxMs:sy,suspendThresholdMs:ry,...r};return this.call("session/prompt",e,o0,i)}async sessionCancel(e){!this.child||this.stopped||this.writeFrame(Sr("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(Ir(e,r))}catch(i){this.log.warn("respondAgentRequest write failed",{id:e,err:String(i)})}}respondAgentRequestError(e,r){if(this.inflightAgentRequests.delete(e),!(!this.child||this.stopped))try{this.writeFrame(yn(e,r))}catch(i){this.log.warn("respondAgentRequestError write failed",{id:e,err:String(i)})}}onExit(e){this.exitHandlers.push(e)}call(e,r,i=o0,o){if(!this.child||this.stopped)return Promise.reject(new T("AGENT_PROTOCOL_ERROR","downstream not started"));let c=this.idAllocator.next(e),l=Pi(c,e,r),u=(()=>{if(typeof r!="object"||r===null)return;let h=r.sessionId;return typeof h=="string"?h:void 0})();return new Promise((h,x)=>{let w={resolve:h,reject:x,timer:null,method:e,promptTimeout:null};if(o){let E=this.now(),I={cfg:o,startedAt:E,lastActivityAt:E,firstFrameSeen:!1,activeToolCalls:new Set,suspendedMs:0,armedAt:E,expectedIntervalMs:Tr(0,!1,o),sessionId:u};w.promptTimeout=I;let b=()=>{let v={startedAt:I.startedAt,lastActivityAt:I.lastActivityAt,firstFrameSeen:I.firstFrameSeen,hasActiveTool:I.activeToolCalls.size>0,awaitingApproval:this.inflightAgentRequests.size>0,suspendedMs:I.suspendedMs,armedAt:I.armedAt,expectedIntervalMs:I.expectedIntervalMs},A=this.now(),S=s0(v,I.cfg,A),R=O=>{I.armedAt=A,I.expectedIntervalMs=O,w.timer=setTimeout(b,O)};if(S.action==="suspend"){I.suspendedMs+=S.suspendedDeltaMs,I.lastActivityAt=A,this.log.warn("downstream prompt timer: suspend detected",{id:c,method:e,gapMs:S.suspendedDeltaMs,suspendedMs:I.suspendedMs,...I.sessionId?{sessionId:I.sessionId}:{}}),R(S.rearmMs);return}if(S.action==="continue"){R(S.rearmMs);return}this.pending.delete(c),S.action==="reject-backstop"?(this.log.warn("downstream prompt absolute timeout",{id:c,method:e,awaitingApproval:S.awaitingApproval,...I.sessionId?{sessionId:I.sessionId}:{}}),x(S.awaitingApproval?new T("AGENT_APPROVAL_TIMEOUT",`${e} awaiting permission timed out after ${I.cfg.approvalMaxMs}ms`):new T("AGENT_TIMEOUT",`${e} timed out after ${I.cfg.absoluteMaxMs}ms`))):(this.log.warn("downstream prompt idle timeout",{id:c,method:e,...I.sessionId?{sessionId:I.sessionId}:{}}),x(new T("AGENT_FRAME_IDLE_TIMEOUT",`${e} no progress within ${I.cfg.livenessWindowMs}ms`)))};w.timer=setTimeout(b,I.expectedIntervalMs)}else i>0&&Number.isFinite(i)&&(w.timer=setTimeout(()=>{this.pending.delete(c),this.log.warn("downstream call timeout",{id:c,method:e,timeoutMs:i}),x(new T("AGENT_TIMEOUT",`${e} timed out after ${i}ms`))},i));this.pending.set(c,w);try{this.writeFrame(l)}catch(E){w.timer&&clearTimeout(w.timer),this.pending.delete(c),x(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(Zf(e),r=>{r&&this.log.warn("stdin write callback err",{err:String(r)})})}dispatch(e){if(ro(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),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(this.wireErrorToBridge(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:oy(e.result)}),r.resolve(e.result));return}if(Kf(e)){if(e.method==="session/update"){let r=e.params;for(let i of this.pending.values()){let o=i.promptTimeout;o&&(o.firstFrameSeen=!0,o.lastActivityAt=this.now(),this.trackToolCall(o,r))}for(let i of this.updateHandlers)try{Promise.resolve(i(r)).catch(o=>this.log.warn("update handler failed (async)",{err:String(o)}))}catch(o){this.log.warn("update handler threw sync, swallowed",{err:String(o)})}}else this.log.info("unknown notification (drop, not forwarded)",{method:e.method});return}if(Wf(e)){let r=e;try{this.handleAgentRequest(r).catch(i=>this.log.error("agent request handler failed (async)",{method:r.method,err:String(i)}))}catch(i){this.log.warn("handleAgentRequest threw sync, swallowed",{method:r.method,err:String(i)})}}}trackToolCall(e,r){let i=r.update,o=i?.sessionUpdate;if(o!=="tool_call"&&o!=="tool_call_update")return;let c=typeof i.toolCallId=="string"?i.toolCallId:void 0;if(!c)return;let l=typeof i.status=="string"?i.status:void 0,u=l==="completed"||l==="failed"||l==="cancelled";o==="tool_call"&&!u?e.activeToolCalls.add(c):u&&e.activeToolCalls.delete(c)}async handleAgentRequest(e){if(this.agentRequestHandlers.length===0){this.writeFrame(yn(e.id,{code:-32601,message:`method not handled by Bridge: ${e.method}`}));return}this.inflightAgentRequests.set(e.id,e.method);for(let r of this.agentRequestHandlers)try{await r(e)}catch(i){this.log.error("agentRequestHandler threw",{method:e.method,err:String(i)});try{this.writeFrame(yn(e.id,Oi(i)))}catch{}this.inflightAgentRequests.delete(e.id)}}wireErrorToBridge(e){let r=$f(e);if(r.code!=="AGENT_PROTOCOL_ERROR")return r;let i=i0(this.framework,ay(e));return i?new T(i.bridgeCode,i.message,{cause:{reason:i.reason,wireCode:e.code,wireMessage:e.message,wireData:e.data}}):r}buildExitError(e,r){if(this.stopReason!==void 0)return new T("AGENT_TURN_ABORTED",`turn aborted: ${this.stopReason}`,{cause:{reason:this.stopReason}});let i=this.getStderrTail(Q_).join(`
|
|
95
|
+
`),o=r0(this.framework,i);return o?new T(o.bridgeCode,o.message,{cause:{reason:o.reason,code:e,signal:r,stderrTail:i}}):new T("AGENT_PROTOCOL_ERROR",`agent exited (${e}/${r})`,{cause:{code:e,signal:r,stderrTail:i}})}failAllPending(e){for(let r of this.pending.values())r.timer&&clearTimeout(r.timer),r.reject(e);this.pending.clear(),this.inflightAgentRequests.clear()}};function ly(t){let e={};for(let[r,i]of Object.entries(t))i!==void 0&&(r.startsWith("CLAUDE")||r==="AI_AGENT"||r==="BAGGAGE"||(e[r]=i));return e}var ao=class extends Ot{framework="claude-code";constructor(e){let{command:r,args:i}=Jr("claude-code",e.command,e.args??[]),o={command:r,args:i,cwd:e.cwd,agentId:e.agentId,...e.env?{env:e.env}:{}};super(o)}sanitizeEnv(e){return ly(e)}};nn();import{mkdtempSync as uy,rmSync as fy}from"node:fs";import{tmpdir as hy}from"node:os";import{join as xy}from"node:path";var co=class extends Ot{framework="codex";authMethodId;codexHomeDir;constructor(e){let r=e.args??[],i=e.extraArgs?[...r,...e.extraArgs]:r,{command:o,args:c}=Jr("codex",e.command,i),l=e.isolateCodexHome?uy(xy(hy(),"coze-bridge-codex-home-")):void 0,u=l?{...e.env??{},CODEX_HOME:l}:e.env,h={command:o,args:c,cwd:e.cwd,agentId:e.agentId,...u?{env:u}:{}};super(h),this.authMethodId=e.authMethodId,this.codexHomeDir=l}async initialize(e){let r=await super.initialize(e);return this.authMethodId&&await this.call("authenticate",{methodId:this.authMethodId}),r}async stop(e){if(await super.stop(e),this.codexHomeDir)try{fy(this.codexHomeDir,{recursive:!0,force:!0})}catch{}}};var py=3e4,Rr=class extends Ot{framework="openclaw";agentId;sessionName;slashModelOnStart;constructor(e){let r=e.sessionName??"default",i=["acp","--session",`agent:${e.agentId}:${r}`];e.gatewayToken&&i.push("--token",e.gatewayToken);let o={command:e.command,args:i,cwd:e.cwd,agentId:e.agentId,...e.env?{env:e.env}:{}};super(o),this.agentId=e.agentId,this.sessionName=r,this.slashModelOnStart=e.slashModelOnStart}async afterSessionEstablished(e){this.slashModelOnStart&&(this.log.info("switching session to per-session provider via /model",{agentId:this.agentId,sessionName:this.sessionName,slash:this.slashModelOnStart}),await this.call("session/prompt",{sessionId:e,prompt:[{type:"text",text:`/model ${this.slashModelOnStart}`}]},py))}get acpSessionName(){return this.sessionName}};Ke();ne();Le();function Zc(t){return t.replace(/[^A-Za-z0-9._-]+/g,"-")}nn();var bn=class{slots=[];running=!1;closed=!1;disposed=!1;enqueue(e){return this.disposed?Promise.reject(new Error("AsyncQueue disposed")):this.closed?Promise.reject(new Error("AsyncQueue closed")):new Promise((r,i)=>{this.slots.push({task:e,resolve:r,reject:i}),this.drain()})}close(){this.closed=!0}dispose(e=new Error("AsyncQueue disposed")){for(this.disposed=!0,this.closed=!0;this.slots.length>0;)this.slots.shift()?.reject(e)}get size(){return this.slots.length}get isRunning(){return this.running}get isDisposed(){return this.disposed}async drain(){if(!this.running){this.running=!0;try{for(;this.slots.length>0&&!this.disposed;){let e=this.slots.shift();if(!e)break;try{let r=await e.task();e.resolve(r)}catch(r){e.reject(r)}}}finally{this.running=!1}}}};var lo=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 bn,this.sessionQueues.set(e,r)),r}allSessionQueues(){return this.sessionQueues.entries()}hasSessionQueue(e){let r=this.sessionQueues.get(e);return!!r&&!r.isDisposed}async dispose(e){this.status="stopped";let r=new Error(`AgentSession disposed${e?`: ${e}`:""}`);for(let i of this.sessionQueues.values())i.dispose(r);this.sessionQueues.clear(),await this.killAllRuntimes(e??"dispose")}async killAllRuntimes(e){let r=[];for(let[,i]of this.sessions)Ni(i),i.downstream&&(r.push(i.downstream.stop(e).catch(()=>{})),i.downstream=void 0);await Promise.all(r),this.activeTriggers.clear(),this.activeGroupIds.clear()}};function Ni(t){t.idleTimer&&(clearTimeout(t.idleTimer),t.idleTimer=void 0)}Kt();ne();import{constants as d0}from"node:fs";import{access as gy}from"node:fs/promises";import{delimiter as my,join as wy}from"node:path";var vt=G("framework-detector"),l0={"claude-code":"claude",codex:"codex",openclaw:"openclaw"},_y=[".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??nt,access:e.access??gy}}async detect(e){let r=l0[e],i=await this.which(r);if(!i)return vt.debug("framework binary not found",{framework:e,bin:r}),null;let o=e==="openclaw"?["--log-level","silent"]:[],[c,l]=await Promise.all([this.probeVersion(i,o),e==="openclaw"?this.probeOpenclawDefaultAgent(i):Promise.resolve(null)]),u={path:i,version:c};return l&&(u.defaultAgent=l),u}async detectAll(){let e=await Promise.all(Object.keys(l0).map(async i=>[i,await this.detect(i)])),r={};for(let[i,o]of e)o&&(r[i]=o);return r}async which(e){let r=this.env.pathEnv.split(my).filter(Boolean),i=this.env.platform==="win32"?["",..._y]:[""];for(let o of r)for(let c of i){let l=wy(o,e+c);if(await this.isExecutable(l))return l}return null}async isExecutable(e){try{let r=this.env.platform==="win32"?d0.F_OK:d0.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 vt.warn("openclaw default agent probe: runProbe returned null (spawn err / timeout)",{path:e}),null;if(r.code!==0)return vt.warn("openclaw default agent probe: non-zero exit",{path:e,code:r.code,stdoutHead:r.stdout.slice(0,200)}),null;let i=r.stdout.match(/\[\s*\{[\s\S]*\}\s*\]/);if(!i)return vt.warn("openclaw default agent probe: regex no match (no JSON array in stdout)",{path:e,stdoutHead:r.stdout.slice(0,200)}),null;try{let o=JSON.parse(i[0]);if(!Array.isArray(o))return vt.warn("openclaw default agent probe: JSON parsed but not an array",{path:e}),null;let c=o.find(l=>l?.isDefault===!0);return c?!c.id||!c.workspace?(vt.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}:(vt.info("openclaw default agent probe: no agent has isDefault=true",{path:e,agentCount:o.length}),null)}catch(o){return vt.warn("openclaw default agent probe: JSON.parse failed",{path:e,err:String(o),matchHead:i[0].slice(0,200)}),null}}async probeOpenclawGateway(e){let r=await this.runProbe(e,["--log-level","silent","gateway","status","--json","--require-rpc","--timeout","5000"]);if(!r)return vt.warn("openclaw gateway probe: runProbe returned null (spawn err / timeout)",{path:e}),{reachable:!1};let i=r.code===0;i||vt.warn("openclaw gateway probe: non-zero exit (gateway unreachable)",{path:e,code:r.code,stdoutHead:r.stdout.slice(0,200)});let o={reachable:i},c=r.stdout.match(/\{[\s\S]*\}/);if(c)try{let l=JSON.parse(c[0]);typeof l.gateway?.port=="number"&&(o.port=l.gateway.port),typeof l.service?.runtime?.status=="string"&&(o.runtime=l.service.runtime.status),!i&&typeof l.rpc?.error=="string"&&(o.detail=l.rpc.error)}catch(l){vt.warn("openclaw gateway probe: JSON.parse failed (detail omitted, gate by exit code)",{path:e,err:String(l)})}return o}async probeVersion(e,r=[]){let i=await this.runProbe(e,[...r,"--version"]);return i&&(by(i.stdout).split(/\r?\n/)[0]??"").trim()||"unknown"}runProbe(e,r){return new Promise(i=>{let o="",c=!1,l,u=h=>{c||(c=!0,l&&clearTimeout(l),i(h))};try{let h=this.env.spawn(e,r,{stdio:["ignore","pipe","pipe"]});l=setTimeout(()=>{h.kill("SIGKILL"),u(null)},15e3),h.stdout?.on("data",x=>{o+=x.toString("utf8")}),h.on("error",()=>u(null)),h.on("close",x=>u({code:x,stdout:o}))}catch{u(null)}})}},yy=new RegExp("\x1B\\[[0-9;]*[A-Za-z]","g");function by(t){return t.replace(yy,"")}import{homedir as Ey}from"node:os";import{join as vy}from"node:path";Kt();Wr();Ke();Yr();ne();async function h0(){let t=vy(Ey(),".openclaw/openclaw.json");return(await tr(t))?.gateway?.auth?.token??""}var u0=G("openclaw.config"),Sy=[0,5e3,5e3],Iy=Ye("COZE_BRIDGE_OPENCLAW_CLI_TIMEOUT_MS",15e3),f0="models.providers.",uo="agents.defaults.models",fo=class{command;env;retryDelaysMs;cliTimeoutMs;queue=new bn;constructor(e){this.command=e.command,this.env=e.env??process.env,this.retryDelaysMs=e.retryDelaysMs??Sy,this.cliTimeoutMs=e.cliTimeoutMs??Iy}async withRetry(e,r){let i;for(let o=0;o<this.retryDelaysMs.length;o++){let c=this.retryDelaysMs[o]??0;c>0&&await new Promise(l=>setTimeout(l,c));try{return await r()}catch(l){i=l,u0.warn("openclaw cli failed, will retry",{label:e,attempt:o+1,err:String(l)})}}throw new T("AGENT_SPAWN_FAILED",`openclaw cli ${e} failed after ${this.retryDelaysMs.length} attempts: ${i?.message??"unknown"}`)}runCli(e){return new Promise((r,i)=>{let o=nt(this.command,e,{stdio:["ignore","ignore","pipe"],env:this.env}),c="",l=!1,u=x=>{l||(l=!0,clearTimeout(h),x())};o.stderr?.on("data",x=>{c+=x.toString("utf8")});let h=setTimeout(()=>{u(()=>{o.kill("SIGTERM"),setTimeout(()=>o.kill("SIGKILL"),250).unref(),i(new Error(`timeout after ${this.cliTimeoutMs}ms: ${e.join(" ")}`))})},this.cliTimeoutMs);h.unref(),o.on("error",x=>u(()=>i(x))),o.on("close",x=>u(()=>{x===0?r():i(new Error(`exit ${x}: ${c.trim().slice(0,500)}`))}))})}async runCliTolerant(e,r){try{await this.runCli(e)}catch(i){let o=String(i);if(r.some(c=>o.includes(c)))return;throw i}}async bestEffortUnset(e,r){try{await this.queue.enqueue(()=>this.withRetry(e,()=>this.runCli(["config","unset",r])))}catch(i){u0.warn(`${e} failed (best-effort)`,{configPath:r,err:String(i)})}}ensureProvider(e,r){return this.queue.enqueue(()=>this.withRetry(`config set models.providers.${e}`,()=>this.runCli(["config","set",`${f0}${e}`,JSON.stringify(r),"--strict-json","--merge"])))}removeProvider(e){return this.bestEffortUnset(`config unset models.providers.${e}`,`${f0}${e}`)}addModelToAllowlist(e,r){let i={[e]:r?{alias:r}:{}};return this.queue.enqueue(()=>this.withRetry(`config set ${uo}[${e}]`,()=>this.runCli(["config","set",uo,JSON.stringify(i),"--strict-json","--merge"])))}removeModelFromAllowlist(e){return this.bestEffortUnset(`config unset ${uo}[${e}]`,`${uo}.${e}`)}ensureAgent(e,r,i){let o=["agents","add",e,"--workspace",r,"--non-interactive"];return i&&o.push("--model",i),this.queue.enqueue(()=>this.withRetry(`agents add ${e}`,()=>this.runCliTolerant(o,["already exists","already registered"])))}restartGateway(){return this.queue.enqueue(()=>this.withRetry("gateway restart",()=>this.runCli(["gateway","restart"])))}deleteAgent(e){return this.queue.enqueue(()=>this.withRetry(`agents delete ${e}`,()=>this.runCliTolerant(["agents","delete",e,"--force"],["not found","does not exist"])))}};var ge=G("agent-manager"),ky=(t,e,r,i,o,c,l,u,h)=>{switch(t){case"claude-code":{let x={...o?{...kf(o),...Of(o,l,u)}:{},...h??{},IS_SANDBOX:"1"};return new ao({cwd:r,env:x,agentId:i})}case"codex":{let w=[...o?[...Pf(o),...Mf(o,l,u)]:[],"-c",'sandbox_mode="danger-full-access"',"-c",'approval_policy="never"'],E={...o?Lf(o):{},...h??{}},I=!!o;return new co({cwd:r,agentId:i,...w.length>0?{extraArgs:w}:{},...Object.keys(E).length>0?{env:E}:{},...I?{authMethodId:"openai-api-key",isolateCodexHome:!0}:{}})}case"openclaw":return new Rr({command:e,cwd:r,agentId:i,...c?{sessionName:Zc(c)}:{}})}};function Jc(t){return t==="claude-code"||t==="codex"}function Py(t){let e=[],r=Object.keys(t).sort();for(let i of r){let o=t[i];o!==void 0&&(Ly(o)||e.push(`${i}=${o}`))}return e.length===0?"":`${e.join(`
|
|
96
96
|
`)}
|
|
97
|
-
`}function
|
|
98
|
-
`)||t.includes("\r")||t.includes("$")||t.includes("#"))return!0;let e=t[0];return e==="'"||e==='"'}var Dy={path:"",version:"cloud-deployed"},_u="openclaw_gateway_unavailable",ky="openclaw_default_agent_missing";function yu(t){let e=[t.port!==void 0?`port=${t.port}`:"",t.runtime?`runtime=${t.runtime}`:"",t.detail??""].filter(Boolean).join(", ");return`openclaw gateway \u672A\u8FD0\u884C/\u4E0D\u53EF\u8FBE${e?` (${e})`:""}; \u8BF7\u542F\u52A8 openclaw gateway`}var Oy={protocolVersion:1,clientCapabilities:{fs:{readTextFile:!0,writeTextFile:!0}}},Py=6e4,_o=class{paths;config;registry;factory;createTimeoutMs;openclawConfigCache;ensuredProviders=new Set;detectorFactory;openclawEnvBootstrapPromise;openclawConfigFactory;openclawConfigDir;constructor(e){this.paths=e.paths,this.config=e.config,this.registry=e.registry,this.factory=e.downstreamFactory??Ty,this.createTimeoutMs=e.createTimeoutMs??Py,this.detectorFactory=e.detectorFactory??(()=>new Gn),this.openclawConfigFactory=e.openclawConfigFactory??(r=>new mo({command:r})),this.openclawConfigDir=e.openclawConfigDir??wu(Iy(),".openclaw")}buildBinShimPathEnv(){let e=process.platform==="win32"?";":":";return{PATH:`${this.paths.binDir}${e}${process.env.PATH??""}`}}getOpenclawConfig(){if(!this.openclawConfigCache){let e=this.config.frameworksCache?.openclaw;if(!e?.path)throw new T("AGENT_SPAWN_FAILED","openclaw binary not detected on this machine");this.openclawConfigCache=this.openclawConfigFactory(e.path)}return this.openclawConfigCache}bootstrapOpenclawEnvIfNeeded(){return this.openclawEnvBootstrapPromise?this.openclawEnvBootstrapPromise:(this.openclawEnvBootstrapPromise=this.doBootstrapOpenclawEnv().catch(e=>{pe.warn("openclaw env bootstrap failed (ignored)",{err:String(e)}),this.openclawEnvBootstrapPromise=void 0}),this.openclawEnvBootstrapPromise)}async doBootstrapOpenclawEnv(){let e=this.openclawConfigDir,r=wu(e,".env");if(await Sy(r).then(c=>c.isFile()).catch(()=>!1)){pe.debug("openclaw .env exists, skip bootstrap",{envFile:r});return}await wo(e,{recursive:!0});let o=Cy({...process.env,...Xc(this.paths.agentEnvFile)});if(await Ay(r,o,"utf8"),process.platform!=="win32")try{await Ey(r,384)}catch(c){pe.warn("chmod ~/.openclaw/.env to 0600 failed (ignored)",{err:String(c)})}pe.info("openclaw .env bootstrapped",{envFile:r,bytes:o.length}),await this.getOpenclawConfig().restartGateway(),pe.info("openclaw gateway restarted after env bootstrap")}async createAgent(e,r){if(!e.agentId)throw new T("IPC_BAD_REQUEST","agentId required");if(!e.framework)throw new T("IPC_BAD_REQUEST","framework required");let i=Ci(e._meta)==="cloud";this.registry.reviveIfDisconnected?.(e.agentId);let o=this.registry.get(e.agentId);if(o){if(o.framework!==e.framework)throw new T("AGENT_BUSY",`agent ${e.agentId} exists with different framework (${o.framework})`);if(o.status==="error")pe.warn("existing agent in error state, rebuilding",{agentId:e.agentId}),await o.dispose("rebuild after error").catch(A=>pe.warn("dispose stale agent failed (ignored)",{err:String(A)})),this.registry.unregister(e.agentId);else{if(e.patToken&&e.patToken!==o.patToken){pe.info("updating agent patToken on re-create (reconnect with new PAT)",{agentId:e.agentId}),o.setPatToken(e.patToken);let A=await He(e.agentId,this.paths).catch(()=>null);A&&(A.patToken=e.patToken,await Xe(A,this.paths))}if(o.deployType==="cloud"&&e.modelInfo){pe.info("updating agent modelInfo on re-create",{agentId:e.agentId}),o.setModelInfo(e.modelInfo);let A=await He(e.agentId,this.paths).catch(()=>null);A&&(A.modelInfo=e.modelInfo,await Xe(A,this.paths))}return pe.info("agent already exists, return current",{agentId:e.agentId}),{ok:!0,agentId:o.agentId,workspace:o.workspace,framework:o.framework}}}if(!i&&!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 l=Ze(e.agentId,this.paths),f=Ci(e._meta),x=e.framework==="openclaw"&&f==="local",h;x&&!r?.revive&&(h=(await this.ensureOpenclawDefaultAgent()).workspace,await this.ensureOpenclawGatewayReachable());let _=h??(x?this.config.frameworksCache?.openclaw?.defaultAgent?.workspace:void 0),w=e.workspace??_??l.workspace,S=new AbortController,b=setTimeout(()=>S.abort(new T("AGENT_TIMEOUT",`_agent/create timed out after ${this.createTimeoutMs}ms`)),this.createTimeoutMs),v,I=!1;try{i&&td(e.framework)&&await er(e.framework,S.signal);let A=()=>{if(S.signal.aborted)throw S.signal.reason instanceof Error?S.signal.reason:new T("AGENT_TIMEOUT","_agent/create aborted")};await wo(l.root,{recursive:!0}),await wo(w,{recursive:!0}),await wo(l.logs,{recursive:!0}),A(),x||await rr(w,e.framework,e.cozeIdentity),e.framework==="claude-code"&&await Il(w,f),A();let C=await He(e.agentId,this.paths).catch(()=>null),P=D0({model:e.model??C?.model}),y=E0(e._meta)??C?.accountId,R=e.patToken??C?.patToken,D=f==="cloud"?e.modelInfo??C?.modelInfo:void 0;if(v=new po({agentId:e.agentId,framework:e.framework,workspace:w,model:P.model??yt,deployType:f,...y?{accountId:y}:{},...R?{patToken:R}:{},...D?{modelInfo:D}:{}}),v.status="ok",C?.sessions){for(let[J,te]of Object.entries(C.sessions))v.sessions.set(J,{acpSessionId:te.acpSessionId,modelToken:te.modelToken,tokenGeneratedAt:te.tokenGeneratedAt,lastActiveAt:Date.now(),loadingSession:!1,replySeq:0});let Y=Object.keys(C.sessions).length;Y>0&&pe.info("restored persisted session records (no spawn)",{agentId:e.agentId,count:Y})}this.registry.register(v),I=!0;let B={agentId:e.agentId,framework:e.framework,workspace:w,cozeIdentity:e.cozeIdentity,createdAt:C?.createdAt??Date.now(),sessions:C?.sessions??{},model:P.model};f==="cloud"&&(B.deployType="cloud"),y&&(B.accountId=y),R&&(B.patToken=R),D&&(B.modelInfo=D),C?.skills&&(B.skills=C.skills),C?.agentName&&(B.agentName=C.agentName),C?.description&&(B.description=C.description),e.framework==="openclaw"&&f==="cloud"&&(this.config.frameworksCache?.openclaw?.path?(await this.bootstrapOpenclawEnvIfNeeded(),await this.getOpenclawConfig().ensureAgent(e.agentId,w)):pe.warn("openclaw binary not on this machine, skip agents add (will fail at session/prompt)",{agentId:e.agentId}));let G=e.initialSkills??[];if(G.length>0){let Y=[...B.skills??[]],J=new Map(Y.map((be,he)=>[be.skillId,he])),te=await Promise.allSettled(G.map(be=>Yc({agentId:e.agentId,workspace:w,framework:e.framework,skill:be}))),Q=0;for(let[be,he]of te.entries()){let O=G[be];O&&(he.status==="fulfilled"?(Jc(Y,J,he.value),Q++):pe.warn("initialSkill install failed (skipping)",{agentId:e.agentId,skillId:O.skillId,skillName:O.skillName,err:String(he.reason)}))}Q>0&&(B.skills=Y,pe.info("initialSkills installed",{agentId:e.agentId,installed:Q,requested:G.length}))}return await Xe(B,this.paths),pe.info("agent created (no spawn, lazy on first prompt)",{agentId:e.agentId,framework:e.framework,deployType:f}),{ok:!0,agentId:e.agentId,workspace:w,framework:e.framework}}catch(A){throw pe.error("agent create failed, rolling back",{agentId:e.agentId,err:String(A)}),I&&v&&(await v.dispose("rollback").catch(()=>{}),this.registry.unregister(e.agentId)),await vy(l.root,{recursive:!0,force:!0}).catch(C=>pe.warn("rm agent dir failed (ignored)",{err:String(C)})),A instanceof T?A:new T("AGENT_SPAWN_FAILED",String(A),{cause:A})}finally{clearTimeout(b)}}async spawnSessionDownstream(e,r,i,o,c){let f=this.config.frameworksCache?.[e.framework];if(!f)if(e.deployType==="cloud"&&td(e.framework))f=Dy;else throw new T("AGENT_SPAWN_FAILED",`framework ${e.framework} not detected on this machine`);td(e.framework)&&!cs(e.framework)&&(pe.info("spawn: resolving acp wrapper",{agentId:e.agentId,framework:e.framework}),await er(e.framework));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:i,cozeEnv:o,mockScenario:c,command:f.path}):h=this.factory(e.framework,f.path,e.workspace,e.agentId,x,i,o,c,this.buildBinShimPathEnv());try{return await h.start(),await h.initialize(Oy),h}catch(_){let w=h instanceof Ot?h.getStderrTail():[];throw w.length>0&&pe.warn("spawnSessionDownstream failed, recent stderr (D94)",{agentId:e.agentId,framework:e.framework,method:_ instanceof T?_.code:"unknown",recentStderr:w}),await h.stop("spawnSessionDownstream failed").catch(()=>{}),await this.resolveSpawnFailure(e,f.path,_)}}async resolveSpawnFailure(e,r,i){if(e.framework==="openclaw"&&e.deployType==="local"&&r)try{let o=await this.detectorFactory().probeOpenclawGateway(r);if(!o.reachable)return new T("AGENT_ENV_NOT_READY",yu(o),{cause:{reason:_u}})}catch(o){pe.warn("openclaw gateway diagnose failed (ignored, fall through to original error)",{agentId:e.agentId,err:String(o)})}return i instanceof T?new T(i.code,i.message,{retriable:i.retriable,cause:i.cause??i}):new T("AGENT_SPAWN_FAILED",i instanceof Error?i.message:String(i),{cause:i})}async ensureOpenclawDefaultAgent(){let e=this.config.frameworksCache?.openclaw?.defaultAgent;if(e?.id&&e.workspace)return{id:e.id,workspace:e.workspace};pe.warn("openclaw default agent stale or missing, attempting lazy re-detect");let r=await this.detectorFactory().detect("openclaw");if(r?.defaultAgent?.id&&r.defaultAgent.workspace)return pe.info("openclaw lazy re-detect success",{agentId:r.defaultAgent.id,workspace:r.defaultAgent.workspace}),this.config.frameworksCache||(this.config.frameworksCache={}),this.config.frameworksCache.openclaw=r,{id:r.defaultAgent.id,workspace:r.defaultAgent.workspace};throw new T("AGENT_ENV_NOT_READY","openclaw default agent \u672A\u63A2\u6D4B\u5230; \u8BF7\u5148\u8DD1 `openclaw setup` \u6216 `openclaw agents add` \u521B\u5EFA\u9ED8\u8BA4 agent",{cause:{reason:ky}})}async ensureOpenclawGatewayReachable(){let e=this.config.frameworksCache?.openclaw?.path;if(!e)throw new T("AGENT_SPAWN_FAILED","openclaw binary not detected on this machine");let r=await this.detectorFactory().probeOpenclawGateway(e);if(!r.reachable)throw new T("AGENT_ENV_NOT_READY",yu(r),{cause:{reason:_u}})}async buildOpenclawDownstream(e){let{session:r,modelConfig:i,cloudSessionId:o,cozeEnv:c,mockScenario:l,command:f}=e,x=ed(o);if(r.deployType==="local"){let S=await this.ensureOpenclawDefaultAgent();return new Cr({command:f,cwd:S.workspace,agentId:S.id,sessionName:x})}let h=await mu(),_=i?M0(i,c,l):null,w;if(_){let S=qc(o),v=_.models[0]?.id??yt,I=`${S}/${v}`;if(!this.ensuredProviders.has(I)){let A=this.getOpenclawConfig();await A.ensureProvider(S,_),await A.addModelToAllowlist(I),this.ensuredProviders.add(I)}w=I}return new Cr({command:f,cwd:r.workspace,agentId:r.agentId,sessionName:x,...h?{gatewayToken:h}:{},...w?{slashModelOnStart:w}:{}})}async openclawRepair(e,r){let i=this.getOpenclawConfig();await i.deleteAgent(e),await i.ensureAgent(e,r)}async cleanupOpenclawSessionProviders(e){if(e.framework!=="openclaw"||!this.openclawConfigCache)return;let r=this.openclawConfigCache;for(let i of e.sessions.keys()){let o=qc(i),c=`${o}/${e.model}`,l=!0;try{await r.removeProvider(o)}catch(f){l=!1,pe.warn("removeProvider failed, keeping ensuredProviders entry",{providerId:o,err:String(f)})}try{await r.removeModelFromAllowlist(c)}catch(f){l=!1,pe.warn("removeModelFromAllowlist failed, keeping ensuredProviders entry",{fullModelId:c,err:String(f)})}l&&this.ensuredProviders.delete(c)}}};import{randomUUID as Au}from"node:crypto";import{promises as Gy}from"node:fs";import{basename as Iu}from"node:path";Ke();ne();import{promises as Ly}from"node:fs";import{basename as My}from"node:path";var bu=j("file-upload"),By="/api/coze_claw/file/agent_upload",Fy=6e4;async function Eu(t,e={}){let i=`${ro(so(e.handshakeBase))}${By}`,o=e.timeoutMs??Fy,c=await Ly.readFile(t.path),l=new FormData;l.append("agent_id",t.agentId),l.append("session_id",t.sessionId),l.append("file_name",t.name),l.append("file_content",new Blob([c],{type:t.mimeType}),t.name);let f={Authorization:`Bearer ${t.patToken}`,Accept:"application/json","x-coze-version":"3.0",...br(e.ppeOverride),...t.accountId?{"x-coze-account":t.accountId}:{}},x=new AbortController,h=setTimeout(()=>x.abort(),o);bu.info("file upload start",{url:i,agentId:t.agentId,sessionId:t.sessionId,name:t.name,bytes:t.sizeBytes,mime:t.mimeType});try{let _=await fetch(i,{method:"POST",headers:f,body:l,signal:x.signal}),w=_.headers.get("x-tt-logid")??"";if(!_.ok){let v=await _.text().catch(()=>"");throw new T("UPLOAD_FAILED",`upload HTTP ${_.status} logid=${w}: ${v.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 bu.info("file upload ok",{uri:b,logid:w}),{uri:b}}catch(_){throw _ instanceof T?_:_.name==="AbortError"?new T("UPLOAD_FAILED",`upload timeout (${o}ms) for ${My(t.path)}`):new T("UPLOAD_FAILED",String(_),{cause:_})}finally{clearTimeout(h)}}Ke();ne();import{extname as zy}from"node:path";var Uy={".png":"image/png",".jpg":"image/jpeg",".jpeg":"image/jpeg",".gif":"image/gif",".webp":"image/webp",".svg":"image/svg+xml",".bmp":"image/bmp",".ico":"image/x-icon",".heic":"image/heic",".heif":"image/heif",".pdf":"application/pdf",".doc":"application/msword",".docx":"application/vnd.openxmlformats-officedocument.wordprocessingml.document",".xls":"application/vnd.ms-excel",".xlsx":"application/vnd.openxmlformats-officedocument.spreadsheetml.sheet",".ppt":"application/vnd.ms-powerpoint",".pptx":"application/vnd.openxmlformats-officedocument.presentationml.presentation",".txt":"text/plain",".md":"text/markdown",".markdown":"text/markdown",".json":"application/json",".yaml":"text/yaml",".yml":"text/yaml",".csv":"text/csv",".html":"text/html",".htm":"text/html",".xml":"application/xml",".log":"text/plain",".zip":"application/zip",".tar":"application/x-tar",".gz":"application/gzip",".tgz":"application/gzip",".mp3":"audio/mpeg",".wav":"audio/wav",".mp4":"video/mp4",".mov":"video/quicktime",".webm":"video/webm"};async function vu(t){let e=zy(t).toLowerCase();return Uy[e]??"application/octet-stream"}ke();var yo=j("agent-send"),Su=50*1024*1024;function Tu(t,e,r){let i=t.get(e);if(!i)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 o=i.sessions.get(r);if(!o)throw new T("AGENT_NOT_FOUND",`session=${r} not active in agent=${e}`);return{session:i,runtime:o}}async function Cu(t,e,r,i,o,c){let f;for(let x=0;x<=2;x++)try{await t.core.sendAgentFileUpdate(e,r,i,o);return}catch(h){f=h,x<2&&(yo.warn("sendAgentFileUpdate failed, retrying",{attempt:x+1,err:String(h)}),await new Promise(_=>setTimeout(_,5e3)))}throw new T("UPSTREAM_NOT_READY",`${c} after 3 attempts: ${String(f)}`,{cause:f})}async function Ru(t,e){let{session:r,runtime:i}=Tu(e.core,t.agentId,t.sessionId);if(!await ei(t.path,r.workspace))throw new T("PATH_OUTSIDE_WORKSPACE",`path=${t.path} not under workspace=${r.workspace}`);let o=await Gy.stat(t.path).catch(()=>null);if(!o||!o.isFile())throw new T("IPC_BAD_REQUEST",`path is not a regular file: ${t.path}`);if(o.size>Su)throw new T("FILE_TOO_LARGE",`${o.size} bytes > limit ${Su}`);let c=await vu(t.path);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 l=t.name??Iu(t.path),f;try{f=await Eu({patToken:r.patToken??e.patToken,agentId:t.agentId,sessionId:t.sessionId,path:t.path,mimeType:c,name:l,sizeBytes:o.size,...r.accountId?{accountId:r.accountId}:{}},{handshakeBase:e.handshakeBase,ppeOverride:e.ppeOverride})}catch(h){throw yo.warn("agent file upload failed",{agentId:t.agentId,sessionId:t.sessionId,path:t.path,sizeBytes:o.size,mime:c,code:h instanceof T?h.code:"UNKNOWN",message:h instanceof Error?h.message:String(h)}),h}let x={sessionUpdate:"agent_file",messageId:Au(),content:{type:t.kind==="image"?"image":"resource",uri:f.uri,mimeType:c,name:l,sizeBytes:o.size,...f.fileId!==void 0?{fileId:f.fileId}:{},...t.caption!==void 0?{caption:t.caption}:{}}};return await Cu(e,r,i,t.sessionId,x,"agent file uploaded to cloud but sendAgentFileUpdate failed"),yo.info("agent file sent",{agentId:t.agentId,sessionId:t.sessionId,kind:t.kind,name:l,bytes:o.size,mime:c,uri:f.uri}),{ok:!0,uri:f.uri,bytes:o.size,mimeType:c,...f.fileId!==void 0?{fileId:f.fileId}:{}}}async function Du(t,e){let{session:r,runtime:i}=Tu(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 o=t.name??Iu(t.path),c={sessionUpdate:"group_file",messageId:Au(),content:{uri:t.path,name:o,mimeType:t.mimeType,...t.caption!==void 0?{caption:t.caption}:{}}};return await Cu(e,r,i,t.sessionId,c,"agent group file sendAgentFileUpdate failed"),yo.info("agent group file sent",{agentId:t.agentId,sessionId:t.sessionId,uri:t.path,name:o,mime:t.mimeType}),{ok:!0,uri:t.path,bytes:0,mimeType:t.mimeType}}function ku(t,e){let r=t.split(".").map(Number),i=e.split(".").map(Number),o=Math.max(r.length,i.length);for(let c=0;c<o;c++){let l=r[c]??0,f=i[c]??0;if(l<f)return!0;if(l>f)return!1}return!1}nn();yn();ne();var Pt=j("coze-cli-installer"),Ou="@coze/cli@latest",qy="coze",Pu="0.1.8",Hy=5e3,jy=5e3,Wy=9e4,Nu=1e4,Bi=null,bo=!1;async function nd(t,e={}){if(bo)return;if(Bi)return Bi;let r=e.exec??nu;return Bi=(async()=>{try{let i=await Ky(qy,r),o=!1;if(i){let l=await $y(r);if(l===void 0)Pt.warn("coze-cli found but version unparseable, fall through to full install",{path:i});else if(ku(l,Pu))Pt.info("coze-cli version too old, upgrade-only (preserve user config + auth)",{path:i,version:l,min:Pu}),o=!0;else{Pt.info("coze-cli already on PATH with sufficient version, skip",{path:i,version:l}),bo=!0;return}}let c=o?"upgrade-only":"full";Pt.info("coze-cli install start",{package:Ou,mode:c});try{await r("npm",["i","-g","--prefer-online",Ou],{timeout:Wy,maxBuffer:10*1024*1024}),Pt.info("coze-cli install ok")}catch(l){Pt.warn("coze-cli install failed (skip subsequent steps)",{err:String(l)});return}if(o){bo=!0;return}if(t.env)try{await r("coze",["config","set","xTTEnv",t.env],{timeout:Nu}),Pt.info("coze config set xTTEnv ok",{env:t.env})}catch(l){Pt.warn("coze config set failed (continue to auth login)",{err:String(l)})}try{await r("coze",["auth","login","--token",t.patToken],{timeout:Nu}),Pt.info("coze auth login ok")}catch(l){Pt.warn("coze auth login failed",{err:String(l)});return}bo=!0}finally{Bi=null}})(),Bi}async function Ky(t,e){let r=process.platform==="win32"?"where":"which";try{let{stdout:i}=await e(r,[t],{timeout:Hy});return Ta(i)}catch{return}}async function $y(t){try{let{stdout:e,stderr:r}=await t("coze",["--version"],{timeout:jy});return(e||r).match(/(\d+\.\d+\.\d+)/)?.[1]}catch{return}}Qr();ke();var Vy=10*6e4;function Lu(t){let e=t?.sessionIdleTimeoutMs;return typeof e!="number"||!Number.isFinite(e)||e<=0?Vy:e}function Eo(t){return tr(t??X().configFile)}function Fi(t,e){return nr(e??X().configFile,t)}import{randomBytes as hb}from"node:crypto";$r();Ke();ne();import{createReadStream as Yy}from"node:fs";import{mkdir as Jy,readFile as Zy,realpath as Xy,stat as Qy,writeFile as eb}from"node:fs/promises";import{basename as tb,dirname as rd,isAbsolute as nb,join as rb,relative as ib,resolve as Mu,sep as sb}from"node:path";import{createInterface as ob}from"node:readline";var Fu=j("fs-rpc"),zi=Je("COZE_BRIDGE_FS_RPC_MAX_BYTES",20*1024*1024);async function zu(t,e){let r=Buffer.byteLength(t.content,"utf8");if(r>zi)throw new T("IPC_BAD_REQUEST",`fs/write_text_file content too large: ${r} bytes > limit ${zi} bytes`);let i=await Gu(t.path,e);return await Jy(rd(i),{recursive:!0}),await eb(i,t.content,"utf8"),Fu.info("fs/write_text_file ok",{path:i,size:t.content.length}),null}async function Uu(t,e){let r=await Gu(t.path,e),i=await Qy(r),o=typeof t.line=="number"||typeof t.limit=="number";if(i.size>zi&&!o)throw new T("IPC_BAD_REQUEST",`fs/read_text_file too large without line/limit slicing: ${i.size} bytes > ${zi} bytes`);let c;if(o&&i.size>zi)c=await ab(r,t.line??1,t.limit);else{let l=await Zy(r,"utf8");if(o){let f=l.split(`
|
|
99
|
-
`),
|
|
100
|
-
`)}else c=l}return
|
|
101
|
-
`)}async function Gu(t,e){if(typeof t!="string"||t.length===0)throw new T("IPC_BAD_REQUEST","path must be a non-empty string");let[r,i]=await Promise.all([Bu(Mu(e)),Bu(Mu(t))]),o=ib(r,i);if(cb(o,sb,nb(o)))throw new T("IPC_BAD_REQUEST",`path escapes workspace: ${t}`);return i}function cb(t,e,r){return t===""?!1:r?!0:t===".."||t.startsWith(`..${e}`)}async function Bu(t){let e=[],r=t;for(;r!==rd(r);)try{let i=await Xy(r);return e.length?rb(i,...e.reverse()):i}catch{e.push(tb(r)),r=rd(r)}return t}ne();var qu=j("prompt-multimodal"),Hu=10*1024*1024,db=15e3,lb=6;async function ju(t){let e=new Array(t.length),r=0;async function i(){for(;r<t.length;){let c=r++,l=t[c];l!==void 0&&(e[c]=await fb(l))}}let o=Array.from({length:Math.min(lb,t.length)},()=>i());return await Promise.all(o),e}function Wu(t){return t.some(e=>e.type==="image")}async function fb(t){if(t.type!=="image")return t;let e=t;if(e.data||!e.uri||!no(e.uri))return t;try{let{buf:r,contentType:i}=await xb(e.uri),o=e.mimeType||ub(i)||"application/octet-stream";return qu.info("image uri fetched and inlined",{uri:e.uri,bytes:r.length,mimeType:o}),{type:"image",data:r.toString("base64"),mimeType:o}}catch(r){return qu.warn("image fetch failed, degrading to text block",{uri:e.uri,err:String(r)}),{type:"text",text:`[image load failed: ${e.uri}]`}}}function ub(t){if(!t)return;let e=t.indexOf(";");return(e===-1?t:t.slice(0,e)).trim()||void 0}async function xb(t){let e=new AbortController,r=setTimeout(()=>e.abort(),db);try{let i=await fetch(t,{signal:e.signal});if(!i.ok)throw new Error(`HTTP ${i.status} ${i.statusText}`);let o=await i.arrayBuffer();if(o.byteLength>Hu)throw new Error(`image too large: ${o.byteLength} bytes (max ${Hu})`);return{buf:Buffer.from(o),contentType:i.headers.get("content-type")??void 0}}finally{clearTimeout(r)}}rn();Ke();ne();var V=j("core"),pb=3e4,gb=/^(boe|ppe)_[A-Za-z0-9_-]+$/,mb="\u6211\u6B63\u5728\u7B49\u5F85\u5BA1\u6279\uFF0C\u8BF7\u7A0D\u540E\u518D\u8054\u7CFB\u6211",wb="\u5BA1\u6279\u5DF2\u8D85\u65F6",_b=3e4,vo=class{upstream;agents=new Map;disconnectedAgents=new Set;extensions;paths;sessionSpawner;sessionIdleTimeoutMs;upstreamIds=new Ir;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=Lu(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(),V.info("Core started",{extensions:Object.keys(this.extensions)})}async stop(e){V.info("Core stopping",{reason:e}),await Promise.all([...this.agents.values()].map(r=>r.dispose(e))),this.agents.clear(),await this.upstream.stop(e)}async reloadAgents(e){let r=e?this.agents.has(e)?[e]:[]:[...this.agents.keys()];for(let i of r)await this.agents.get(i)?.killAllRuntimes("reload");return r}get(e){return this.agents.get(e)}register(e){this.agents.set(e.agentId,e),V.info("agent registered",{agentId:e.agentId,framework:e.framework});for(let r of this.registerHandlers)try{r(e.agentId)}catch(i){V.warn("onAgentRegister handler threw (ignored)",{agentId:e.agentId,err:String(i)})}}onAgentRegister(e){return this.registerHandlers.add(e),()=>this.registerHandlers.delete(e)}registerHandlers=new Set;unregister(e){this.agents.delete(e)}reviveIfDisconnected(e){this.disconnectedAgents.delete(e)&&V.info("agent revived from disconnect",{agentId:e})}attachRuntimeHooks(e,r,i){let o=i.downstream;o&&(o.onUpdate(c=>{i.loadingSession||this.forwardUpdate(e,c)}),o.onAgentRequest(c=>{this.handleAgentRequest(e,o,c)}),o.onExit((c,l)=>{V.info("session runtime exited",{agentId:e.agentId,cloudId:r,code:c,signal:l}),Mi(i),i.downstream=void 0,i.replySeq=0,i.acpSessionId&&e.activeTriggers.delete(i.acpSessionId),this.rejectPendingForDownstream(o,"downstream exited")}))}hasPendingPermissionFor(e){for(let r of this.pendingUpstream.values())if(r.downstream===e)return!0;return!1}rejectPendingForDownstream(e,r){let i=[];for(let[o,c]of this.pendingUpstream)c.downstream===e&&i.push(o);if(i.length!==0){V.info("reject pendingUpstream entries (downstream gone)",{reason:r,count:i.length});for(let o of i){let c=this.pendingUpstream.get(o);if(c){this.pendingUpstream.delete(o),this.upstream.send(_n(o,{code:ee.INTERNAL_ERROR,message:`bridge downstream gone: ${r}`})).catch(l=>V.debug("send error response to upstream failed (ignored)",{err:String(l)}));try{c.downstream.respondAgentRequestError(c.agentRequestId,{code:ee.INTERNAL_ERROR,message:`bridge: ${r}`})}catch{}}}}}rejectAllPendingOnReconnect(){let e=this.pendingUpstream.size,r=this.pendingBridge.size;if(!(e===0&&r===0)){V.warn("upstream reconnected, rejecting stale pending requests",{pendingUpstream:e,pendingBridge:r});for(let[,i]of this.pendingUpstream){try{i.downstream.respondAgentRequestError(i.agentRequestId,{code:ee.INTERNAL_ERROR,message:"upstream reconnected; please retry"})}catch{}this.clearPendingPermissionFor(i)}this.pendingUpstream.clear();for(let[,i]of this.pendingBridge)clearTimeout(i.timer),i.reject(new T("UPSTREAM_DISCONNECTED",`${i.method} aborted: upstream reconnected`));this.pendingBridge.clear()}}async handleFrame(e){if(co(e)){this.handleUpstreamResponse(e);return}if(!("method"in e)||typeof e.method!="string")return;let r="id"in e&&e.id!==void 0?e.id:null,i=e.params?._meta?.cozeEnv;i&&gb.test(i)?this.currentCozeEnv=i:i&&V.warn("rejecting cozeEnv with invalid shape, keeping previous",{rejected:i});try{if(e.method.startsWith("_agent/")){let o=this.extensions[e.method];if(!o){r!==null?await this.sendError(r,ee.METHOD_NOT_FOUND,`extension not registered: ${e.method}`):V.warn("drop notification: extension not registered",{method:e.method});return}let c=await o(e,this);r!==null&&await this.upstream.send(Ar(r,c));return}if(e.method.startsWith("session/")){let o=await this.routeSessionMethod(e);r!==null&&await this.upstream.send(Ar(r,o));return}if(e.method==="initialize"){r!==null&&await this.upstream.send(Ar(r,{protocolVersion:1,agentCapabilities:{loadSession:!0}}));return}r!==null?await this.sendError(r,ee.METHOD_NOT_FOUND,`method not implemented: ${e.method}`):V.warn("drop unknown notification",{method:e.method})}catch(o){V.error("handleFrame failed",{method:e.method,err:String(o)}),r!==null&&await this.upstream.send(_n(r,Li(o)))}}async routeSessionMethod(e){if(!e.params||typeof e.params!="object")throw new T("IPC_BAD_REQUEST",`${e.method} requires params`);let r=e.params,i=r._meta?.cozeAgentId;if(!i)throw new T("IPC_BAD_REQUEST",`${e.method}: missing _meta.cozeAgentId`);let o=this.agents.get(i);if(!o)throw this.disconnectedAgents.has(i)?new T("AGENT_DISCONNECTED",`agent ${i} has been disconnected; cloud must _agent/create to revive`):new T("AGENT_NOT_FOUND",`agent not found: ${i}`);let c=typeof r.sessionId=="string"?r.sessionId:void 0;if(e.method==="session/cancel"||e.method==="session/new"||!c)return this.dispatchSessionCall(o,e.method,r);if(e.method==="session/prompt"){let x=o.sessions.get(c);if(x?.pendingPermission){let h=r._meta?.cozeTriggerMsgId,_=Bc(r._meta);return V.info("session in pendingPermission, bouncing new prompt",{agentId:o.agentId,cloudSessionId:c}),this.synthesizePromptReply(o,x,c,mb,h,_)}}let l=Date.now(),f=!1;try{let x=await o.getSessionQueue(c).enqueue(()=>this.dispatchSessionCall(o,e.method,r));return f=!0,x}finally{V.info("session call done",{agentId:o.agentId,method:e.method,durationMs:Date.now()-l,ok:f})}}async dispatchSessionCall(e,r,i){e.lastActiveAt=Date.now();let{stripped:o}=v0(i);switch(r){case"session/new":{let c=yb();return V.info("session/new ack (lazy spawn)",{agentId:e.agentId,cloudId:c}),{sessionId:c}}case"session/load":{let c=o;return V.info("session/load ack (lazy spawn)",{agentId:e.agentId,cloudId:c.sessionId}),{}}case"session/prompt":{let c=o,l=c.sessionId;if(!l)throw new T("IPC_BAD_REQUEST","session/prompt: missing sessionId");let f=await this.ensureRuntime(e,l);if(f.replySeq=0,await this.ensureDownstream(e,l,f),!f.downstream||!f.acpSessionId)throw new T("BRIDGE_INTERNAL","session runtime not ready after ensureDownstream");let x=i._meta?.cozeTriggerMsgId;x?e.activeTriggers.set(f.acpSessionId,x):e.activeTriggers.delete(f.acpSessionId);let h=Bc(i._meta);if(h?e.activeGroupIds.set(f.acpSessionId,h):e.activeGroupIds.delete(f.acpSessionId),e.deployType==="cloud"&&e.modelInfo?.capabilities?.image===!1&&Wu(c.prompt))throw new T("MODEL_MODALITY_UNSUPPORTED",`model=${e.modelInfo.id??e.model} does not support image input`);let _=await ju(c.prompt);try{let w=await f.downstream.sessionPrompt({...c,sessionId:f.acpSessionId,prompt:_});return f.lastActiveAt=Date.now(),w}catch(w){if(w instanceof T&&w.code==="AGENT_APPROVAL_TIMEOUT"){let S=f.pendingPermission;S&&(S.downstream.respondAgentRequest(S.agentRequestId,{outcome:{outcome:"cancelled"}}),this.pendingUpstream.delete(S.upstreamId),f.pendingPermission=void 0);let b=f.acpSessionId,v=b?e.activeTriggers.get(b):void 0,I=b?e.activeGroupIds.get(b):void 0;return V.warn("approval timed out, synthesizing \u5BA1\u6279\u5DF2\u8D85\u65F6 reply + recovering session",{agentId:e.agentId,cloudId:l}),await this.synthesizePromptReply(e,f,l,wb,v,I)}throw w}finally{if(e.activeTriggers.delete(f.acpSessionId),e.activeGroupIds.delete(f.acpSessionId),f.pendingPermission=void 0,f.reloadAfterTurn){f.reloadAfterTurn=!1;let w=f.downstream;w&&(f.downstream=void 0,V.info("reloadAfterTurn: stopping downstream",{agentId:e.agentId,cloudId:l,acpId:f.acpSessionId}),w.stop("reload-after-turn").catch(S=>V.warn("reload-after-turn stop failed (ignored)",{agentId:e.agentId,cloudId:l,err:String(S)})))}else f.downstream?.isAlive()&&this.armIdleTimer(e,l,f)}}case"session/cancel":{let l=o.sessionId;if(!l)throw new T("IPC_BAD_REQUEST","session/cancel: missing sessionId");let f=e.sessions.get(l);if(e.hasSessionQueue(l)){let x=e.getSessionQueue(l);x.size>0&&(V.info("session/cancel: draining queued tasks",{agentId:e.agentId,cloudId:l,queuedCount:x.size}),x.dispose(new T("AGENT_PROTOCOL_ERROR",`cancelled by session/cancel on ${l}`)))}return f?.downstream?.isAlive()&&f.acpSessionId&&await f.downstream.sessionCancel({sessionId:f.acpSessionId}),{ok:!0}}default:throw new T("IPC_BAD_REQUEST",`session method not supported: ${r}`)}}async ensureRuntime(e,r){let i=e.sessions.get(r);if(i)return i;let c={modelToken:e.deployType==="cloud"?await this.requestSessionToken(e.agentId,r):"",tokenGeneratedAt:Date.now(),lastActiveAt:Date.now(),loadingSession:!1,replySeq:0};return e.sessions.set(r,c),await this.persistSessionMapping(e),c}async requestSessionToken(e,r){let i={sessionId:r,_meta:{cozeAgentId:e}};try{let o=await this.sendRequest(_t.GEN_MODEL_TOKEN,i,_b);if(!o?.modelToken)throw new T("MODEL_TOKEN_GEN_FAILED",`cloud returned empty modelToken (agentId=${e}, cloudSessionId=${r})`);return o.modelToken}catch(o){throw o instanceof T&&o.code==="MODEL_TOKEN_GEN_FAILED"?o:new T("MODEL_TOKEN_GEN_FAILED",o instanceof Error?o.message:String(o),{cause:o})}}async ensureDownstream(e,r,i){if(Mi(i),i.downstream?.isAlive())return;if(!this.sessionSpawner)throw new T("AGENT_SPAWN_FAILED","sessionSpawner not wired (cannot spawn per-session downstream)");let o=3,c=3e4,l=i.spawnFailCount??0,f=i.spawnFailedAt??0;if(l>=o&&Date.now()-f<c)throw new T("AGENT_SPAWN_FAILED",`agent ${e.agentId} session ${r} spawn failed ${l} times in a row; please check framework binary / network and retry after ${Math.ceil((c-(Date.now()-f))/1e3)}s`);let x;try{x=await this.sessionSpawner(e,i.modelToken,r,this.currentCozeEnv,this.currentMockScenario)}catch(h){throw i.spawnFailCount=l+1,i.spawnFailedAt=Date.now(),i.spawnFailCount>=o&&i.acpSessionId&&(V.warn("clearing stale acpSessionId after repeated spawn failures",{agentId:e.agentId,cloudId:r,staleAcpId:i.acpSessionId}),i.acpSessionId=void 0),h}i.spawnFailCount=0,i.spawnFailedAt=void 0,i.downstream=x,this.attachRuntimeHooks(e,r,i);try{if(i.acpSessionId){i.loadingSession=!0;try{await x.sessionLoad({sessionId:i.acpSessionId,cwd:e.workspace}),V.info("session restored via session/load",{agentId:e.agentId,cloudId:r,acpId:i.acpSessionId})}catch(h){V.warn("session/load failed, fallback to session/new",{agentId:e.agentId,cloudId:r,acpId:i.acpSessionId,err:String(h)}),i.acpSessionId=void 0;let _=await x.sessionNew({cwd:e.workspace});i.acpSessionId=_.sessionId,await this.persistSessionMapping(e)}finally{i.loadingSession=!1}}else{let h=await x.sessionNew({cwd:e.workspace});i.acpSessionId=h.sessionId,await this.persistSessionMapping(e)}}catch(h){throw V.warn("session init failed after spawn, tearing down half-spawned runtime",{agentId:e.agentId,cloudId:r,acpId:i.acpSessionId,err:String(h)}),await x.stop("session-init-failed").catch(()=>{}),i.downstream=void 0,i.acpSessionId=void 0,h}x.afterSessionEstablished&&i.acpSessionId&&await x.afterSessionEstablished(i.acpSessionId)}armIdleTimer(e,r,i){if(Mi(i),this.isRuntimeBusy(e,i)){V.debug("skip idle timer: runtime busy (in-flight turn / pending permission)",{agentId:e.agentId,cloudId:r});return}i.idleTimer=setTimeout(()=>{if(i.idleTimer=void 0,this.isRuntimeBusy(e,i)){V.info("idle reaper fired but runtime busy, re-arming",{agentId:e.agentId,cloudId:r}),this.armIdleTimer(e,r,i);return}V.info("session runtime idle timeout, killing downstream",{agentId:e.agentId,cloudId:r});let o=i.downstream;i.downstream=void 0,i.acpSessionId&&e.activeTriggers.delete(i.acpSessionId),o&&o.stop("idle timeout").catch(c=>V.warn("idle stop failed (ignored)",{agentId:e.agentId,cloudId:r,err:String(c)}))},this.sessionIdleTimeoutMs),i.idleTimer.unref?.()}isRuntimeBusy(e,r){if(r.acpSessionId&&e.activeTriggers.has(r.acpSessionId))return!0;let i=r.downstream;if(!i)return!1;for(let o of this.pendingUpstream.values())if(o.downstream===i)return!0;return!1}async sendAgentFileUpdate(e,r,i,o){let c={cozeAgentId:e.agentId,cozeReplySeqID:++r.replySeq};if(r.acpSessionId){let l=e.activeTriggers.get(r.acpSessionId);l&&(c.cozeTriggerMsgId=l);let f=e.activeGroupIds.get(r.acpSessionId);f&&(c.cozeGroupId=f)}await this.upstream.send(Sr("session/update",{sessionId:i,update:o,_meta:c}))}async synthesizePromptReply(e,r,i,o,c,l){let f={cozeAgentId:e.agentId,cozeReplySeqID:++r.replySeq};return c&&(f.cozeTriggerMsgId=c),l&&(f.cozeGroupId=l),await this.upstream.send(Sr("session/update",{sessionId:i,update:{sessionUpdate:"agent_message_chunk",content:{type:"text",text:o}},_meta:f})).catch(x=>V.warn("synthesizePromptReply update send failed (ignored)",{err:String(x)})),{stopReason:"end_turn"}}forwardUpdate(e,r){let i=r.sessionId,o=this.reverseSessionId(e,i);if(!o){V.debug("drop update for unknown session",{agentId:e.agentId,acpId:i});return}let c=e.sessions.get(o);if(!c){V.debug("drop update: runtime gone",{agentId:e.agentId,cloudId:o});return}if(vb(r)){V.debug("drop codex noise chunk",{agentId:e.agentId,acpId:i});return}let l={cozeAgentId:e.agentId,cozeReplySeqID:++c.replySeq},f=e.activeTriggers.get(i);f&&(l.cozeTriggerMsgId=f);let x=e.activeGroupIds.get(i);x&&(l.cozeGroupId=x),this.upstream.send(Sr("session/update",{...r,sessionId:o,_meta:l})).catch(h=>V.warn("forward update failed",{agentId:e.agentId,err:String(h)}))}handleAgentRequest(e,r,i){if(i.method==="session/request_permission"){this.forwardPermissionRequest(e,r,i);return}if(i.method==="fs/write_text_file"||i.method==="fs/read_text_file"){this.handleFsRpcRequest(e,r,i);return}V.warn("unhandled agent request,returning method_not_found",{agentId:e.agentId,method:i.method}),r.respondAgentRequestError(i.id,{code:ee.METHOD_NOT_FOUND,message:`method not handled by Bridge: ${i.method}`})}async handleFsRpcRequest(e,r,i){try{let o=e.workspace;if(i.method==="fs/write_text_file"){let c=i.params??{},l=await zu(c,o);r.respondAgentRequest(i.id,l)}else{let c=i.params??{},l=await Uu(c,o);r.respondAgentRequest(i.id,l)}}catch(o){V.warn("fs rpc handler failed",{agentId:e.agentId,method:i.method,err:String(o)}),r.respondAgentRequestError(i.id,Li(o))}}clearPendingPermissionFor(e){if(e.method!=="session/request_permission"||!e.cloudSessionId)return;let r=this.agents.get(e.agentId)?.sessions.get(e.cloudSessionId);r&&(r.pendingPermission=void 0)}forwardPermissionRequest(e,r,i){let o=this.upstreamIds.next("session/request_permission"),c=i.params??{},f=c.sessionId,x=f?e.activeTriggers.get(f):void 0,h={cozeAgentId:e.agentId};x&&(h.cozeTriggerMsgId=x);let _=f?e.activeGroupIds.get(f):void 0;_&&(h.cozeGroupId=_);let w=f?this.reverseSessionId(e,f):void 0,S=w?e.sessions.get(w):void 0;S&&(S.pendingPermission={downstream:r,agentRequestId:i.id,upstreamId:o});let b={...c,...w?{sessionId:w}:{},_meta:h};this.pendingUpstream.set(o,{agentRequestId:i.id,agentId:e.agentId,downstream:r,method:i.method,cloudSessionId:w}),V.info("forward permission_request \u2192 upstream",{agentId:e.agentId,upstreamId:o,acpSessionId:f,cloudSessionId:w,toolCallId:c.toolCall?.toolCallId,options:c.options?.map(v=>({optionId:v.optionId,kind:v.kind,name:v.name}))}),this.upstream.send(Pi(o,"session/request_permission",b)).catch(v=>{this.pendingUpstream.delete(o),V.error("forward permission request failed",{agentId:e.agentId,err:String(v)}),r.respondAgentRequestError(i.id,{code:ee.INTERNAL_ERROR,message:`upstream send failed: ${String(v)}`})})}handleUpstreamResponse(e){if(e.id===null)return;let r=this.lookupPending(this.pendingUpstream,e.id,"upstream");if(r){this.pendingUpstream.delete(r.key);let o=r.value;this.clearPendingPermissionFor(o),e.error?(V.info("upstream \u2192 permission response (error)",{agentId:o.agentId,upstreamId:e.id,method:o.method,error:e.error}),o.downstream.respondAgentRequestError(o.agentRequestId,e.error)):(o.method==="session/request_permission"&&bb(e.result,o),V.info("upstream \u2192 permission response (result)",{agentId:o.agentId,upstreamId:e.id,method:o.method,result:e.result}),o.downstream.respondAgentRequest(o.agentRequestId,e.result));return}let i=this.lookupPending(this.pendingBridge,e.id,"bridge");if(i){this.pendingBridge.delete(i.key),clearTimeout(i.value.timer),e.error?i.value.reject(new ao(e.error)):i.value.resolve(e.result);return}V.debug("orphan upstream response (no pending)",{id:e.id})}lookupPending(e,r,i){let o=e.get(r);if(o)return{value:o,key:r};if(typeof r=="number"){let c=String(r),l=e.get(c);if(l)return V.warn(`${i} id type mismatch: number received but Bridge expected string`,{rawId:r,normalizedId:c}),{value:l,key:c}}}sendRequest(e,r,i=pb){let o=this.upstreamIds.next(e);return new Promise((c,l)=>{let f=setTimeout(()=>{this.pendingBridge.delete(o),l(new T("AGENT_TIMEOUT",`${e} timed out after ${i}ms`))},i);this.pendingBridge.set(o,{method:e,resolve:c,reject:l,timer:f}),this.upstream.send(Pi(o,e,r)).catch(x=>{let h=this.pendingBridge.get(o);h&&(clearTimeout(h.timer),this.pendingBridge.delete(o)),l(x)})})}async persistSessionMapping(e){if(this.paths)try{let r=new Map;for(let[i,o]of e.sessions){let c={modelToken:o.modelToken,tokenGeneratedAt:o.tokenGeneratedAt};o.acpSessionId&&(c.acpSessionId=o.acpSessionId),r.set(i,c)}await ti(e.agentId,r,this.paths)}catch(r){V.warn("persist session mapping failed",{agentId:e.agentId,err:String(r)})}}reverseSessionId(e,r){for(let[i,o]of e.sessions.entries())if(o.acpSessionId===r)return i}sendError(e,r,i){return this.upstream.send(_n(e,{code:r,message:i,data:{bridgeVersion:vr}}))}};function yb(){return hb(16).toString("hex")}function bb(t,e){if(!t||typeof t!="object"){V.warn("permission response: result not an object (suspicious)",{agentId:e.agentId,result:t});return}let r=t;if("kind"in r&&!("outcome"in r)){V.warn('permission response: top-level "kind" field (D66 historical bug shape)',{agentId:e.agentId,result:t});return}let i=r.outcome;if(!i||typeof i!="object"){V.warn("permission response: missing or non-object outcome field",{agentId:e.agentId,result:t});return}let c=i.outcome;(typeof c!="string"||c!=="selected"&&c!=="cancelled")&&V.warn("permission response: unknown outcome discriminant",{agentId:e.agentId,outcomeValue:c,result:t})}var Eb=["Model metadata for `","Falling back from WebSockets to HTTPS transport.","Heads up: Long threads and multiple compactions can cause the model to be less accurate."];function vb(t){let e=t.update;if(e?.sessionUpdate!=="agent_message_chunk")return!1;let r=e.content;if(!r||typeof r!="object")return!1;let i=r;if(i.type!=="text"||typeof i.text!="string")return!1;let{text:o}=i;return Eb.some(c=>o.startsWith(c))}ne();ke();import{randomBytes as Sb}from"node:crypto";import{chmod as Ab,mkdir as Ib,writeFile as Ku}from"node:fs/promises";import{createServer as Tb}from"node:http";import{dirname as Cb}from"node:path";var Rb=1e6,id=j("ipc"),So=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??X()}async start(){this.token=Sb(32).toString("hex");let e=Tb((i,o)=>{this.dispatch(i,o)});this.server=e,await new Promise((i,o)=>{e.once("error",o),e.listen(0,"127.0.0.1",()=>i())});let r=e.address();if(!r||typeof r!="object")throw new Error("failed to obtain IPC port");return this.port=r.port,await this.persistAuthFiles(),id.info("IPC listening",{port:this.port}),{port:this.port,token:this.token}}async stop(){let e=this.server;e&&(await new Promise((r,i)=>{e.close(o=>o?i(o):r())}),this.server=null)}async persistAuthFiles(){await Ib(Cb(this.paths.portFile),{recursive:!0}),await Ku(this.paths.portFile,String(this.port),"utf8"),await Ku(this.paths.tokenFile,this.token,{encoding:"utf8",mode:384});try{await Ab(this.paths.tokenFile,384)}catch(e){id.warn("chmod token file failed (non-POSIX?)",{err:String(e)})}}async dispatch(e,r){if(e.headers.authorization!==`Bearer ${this.token}`){Ui(r,401,{error:"unauthorized"});return}let o=`${e.method} ${(e.url??"").split("?")[0]}`,c=this.routes.get(o);if(!c){Ui(r,404,{error:"not found"});return}let l=null;if(e.method==="POST")try{l=await Db(e)}catch(f){Ui(r,400,{error:"invalid json",detail:String(f)});return}try{let f=await c.handler(l,e);Ui(r,200,f??{ok:!0})}catch(f){id.error("IPC handler failed",{key:o,err:String(f)}),Ui(r,500,{error:f instanceof Error?f.message:String(f)})}}};function Ui(t,e,r){t.statusCode=e,t.setHeader("content-type","application/json"),t.end(JSON.stringify(r))}async function Db(t){let e=[],r=0;for await(let o of t){let c=o;if(r+=c.length,r>Rb)throw new Error("body too large");e.push(c)}let i=Buffer.concat(e).toString("utf8");return i?JSON.parse(i):null}var ph=St(rx(),1);var lv=St(Qx(),1),fv=St(Uo(),1),uv=St(kr(),1),xv=St(md(),1),hv=St(yd(),1),pv=St(Id(),1),ch=St(jo(),1),gv=St(ah(),1);var dh=ch.default;Ke();ne();var Re=j("upstream.frontier"),fh="application/json",uh="none",wv=15e3;function _v(t){class e extends dh{constructor(i){super(i,A0,{headers:t})}guardTeardown(){this.listenerCount("error")===0&&this.on("error",i=>Re.warn("frontier ws error during teardown (handled, prevents daemon crash)",{err:i instanceof Error?i.message:String(i)}))}close(i,o){this.guardTeardown(),super.close(i,o)}terminate(){this.guardTeardown(),super.terminate()}send(i,...o){if(ll("debug"))try{let c;typeof i=="string"?c=Buffer.from(i,"utf8"):i instanceof Buffer?c=i:i instanceof ArrayBuffer?c=new Uint8Array(i):ArrayBuffer.isView(i)?c=new Uint8Array(i.buffer,i.byteOffset,i.byteLength):c=new Uint8Array(0);let l=Buffer.from(c.slice(0,128)).toString("hex");Re.debug("WS raw frame out",{bytes:c.byteLength,headHex:l})}catch(c){Re.warn("WS raw frame dump failed",{err:String(c)})}super.send(i,...o)}}return e}var Yi=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:I0,...br(this.opts.ppeOverride)},r=_v(e),i=C0(this.opts.urlOverride),o={url:i,ws:r,fpID:S0,aID:io,accessKey:this.opts.handshake.accessKey,deviceID:this.opts.handshake.deviceId,payloadType:{type:fh,force:!0},payloadEncoding:{encoding:uh,force:!0},enableTransformTextPayload:!0,enableQoS:!1,enableAutoAck:!1,automaticOpen:!1,maxRetries:Number.POSITIVE_INFINITY,debug:this.opts.debug??!1},c=new ph.FWS(o),l=!1,f=null,x,h,_=new Promise((b,v)=>{x=b,h=v}),w=b=>{l||(l=!0,f&&(clearTimeout(f),f=null),b?h(b):x())};c.onopen=()=>{this.opened=!0,this.openCount+=1;let b=this.openCount===1;Re.info("frontier opened",{url:i,remoteDeviceId:this.opts.handshake.deviceId,initial:b,openCount:this.openCount}),b&&w();for(let v of this.connectHandlers)Promise.resolve(v({initial:b})).catch(I=>Re.warn("onConnect handler threw (ignored)",{err:String(I)}))},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??wv;f=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(v){Re.warn("fws close during start failure threw (ignored)",{err:String(v)})}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(i){Re.warn("frontier close threw (ignored)",{err:String(i)})}}}async send(e){let r=this.fws,i=e.method;if(!r)throw Re.warn("frontier send refused: upstream not started",{method:i}),new T("UPSTREAM_DISCONNECTED","frontier upstream not started");if(!this.isConnected()){let f=Date.now();throw f-this.lastSendRefusedLogAt>1e3?(Re.warn("frontier send refused: ws not open",{method:i,opened:this.opened,readyState:r.readyState,...this.sendRefusedSuppressed>0?{suppressedSinceLast:this.sendRefusedSuppressed}:{}}),this.lastSendRefusedLogAt=f,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 o=JSON.stringify(e),c=e;xh(c)||Re.info("frontier frame out",{method:c.method,jsonrpcId:c.id,size:o.length});try{await r.send(o,{service:33555712,method:1,payloadType:fh,payloadEncoding:uh})}catch(f){throw Re.warn("frontier frame send failed",{method:c.method,jsonrpcId:c.id,err:String(f)}),new T("UPSTREAM_DISCONNECTED",`frontier send failed: ${String(f)}`,{cause:f})}}onFrame(e){this.handler=e}onConnect(e){this.connectHandlers.push(e)}isConnected(){return this.opened&&this.fws?.readyState===1}injectAgentPatToken(e){let r=this.opts.getPatTokenForAgent;if(!r)return;let i=e.params?._meta;if(!i?.cozeAgentId)return;let o=r(i.cozeAgentId);o&&(i.cozePatToken=o)}handleMessage(e){let r=e.message?.service;if(r!==33555712){Re.debug("drop non-adapter frontier frame",{service:r});return}let i=Ev(e);if(!i){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:i.length});return}let o;try{o=JSON.parse(i)}catch(l){Re.warn("frontier message JSON parse failed",{err:String(l),head:i.slice(0,80)});return}let c=o;xh(c)||Re.info("frontier frame in",{logid:bv(e.message?.LogID),logidNew:e.message?.LogIDNew,msgId:e.message?.msgID,jsonrpcId:c.id,method:c.method,body:yv(i)}),Promise.resolve(this.handler(o)).catch(l=>Re.warn("frontier frame handler threw",{err:String(l)}))}};function xh(t){return t.method==="_agent/health"?!0:typeof t.id=="string"&&t.id.startsWith("agent.health_")}var hh=2e3;function yv(t){return t.length<=hh?t:`${t.slice(0,hh)}...<truncated, total ${t.length} chars>`}function bv(t){return t?t.high===0?String(t.low>>>0):`${t.high.toString(16)}${(t.low>>>0).toString(16).padStart(8,"0")}`:""}function Ev(t){let e=t.message;if(e?.textPayload)return e.textPayload;let r=e?.payload;if(!r)return null;try{return Buffer.from(r).toString("utf8")}catch{return null}}ne();var Cd=j("upstream.switchable"),Ko=class{inner;handler=null;connectHandlers=[];constructor(e){this.inner=e}async swap(e,r){if(this.inner===e)return;Cd.info("swap upstream",{reason:r});let i=this.inner;if(this.inner=e,this.handler&&e.onFrame(this.handler),e.onConnect)for(let o of this.connectHandlers)e.onConnect(o);try{await e.start()}catch(o){throw Cd.error("swap target start failed, reverting",{err:String(o)}),this.inner=i,o}await i.stop(r??"swapped").catch(o=>Cd.warn("previous upstream stop threw (ignored)",{err:String(o)}))}current(){return this.inner}start(){return this.inner.start()}stop(e){return this.inner.stop(e)}send(e){return this.inner.send(e)}onFrame(e){this.handler=e,this.inner.onFrame(e)}onConnect(e){this.connectHandlers.push(e),this.inner.onConnect?.(e)}isConnected(){return this.inner.isConnected()}};ne();var Rd=j("upstream"),Br=class{handler=null;async start(){Rd.info("NoopUpstream started (M1 skeleton; real Frontier wired in M4)")}async stop(e){Rd.info("NoopUpstream stopped",{reason:e})}async send(e){Rd.debug("NoopUpstream.send (dropped)",{method:"method"in e?e.method:void 0})}onFrame(e){this.handler=e}isConnected(){return!1}async injectFrame(e){this.handler&&await this.handler(e)}};Ke();ne();ne();ke();import{promises as Dd}from"node:fs";import{dirname as vv}from"node:path";var Sv=j("pat-token-store");async function $o(t=X()){try{let r=(await Dd.readFile(t.patTokenFile,"utf8")).trim();return r.length>0?r:null}catch(e){let r=e?.code;return r!=="ENOENT"&&Sv.warn("read pat-token failed (treating as missing)",{path:t.patTokenFile,code:r,message:e.message}),null}}async function Ji(t,e=X()){if(!t)throw new Error("writePatToken: empty patToken");await Dd.mkdir(vv(e.patTokenFile),{recursive:!0}),await Dd.writeFile(e.patTokenFile,t,{encoding:"utf8",mode:384})}ke();ke();import{promises as Vo}from"node:fs";import{join as Av}from"node:path";function Iv(t,e){return`#!/bin/sh
|
|
97
|
+
`}function Ly(t){if(t.includes(`
|
|
98
|
+
`)||t.includes("\r")||t.includes("$")||t.includes("#"))return!0;let e=t[0];return e==="'"||e==='"'}var Oy={path:"",version:"cloud-deployed"},p0="openclaw_gateway_unavailable",Ny="openclaw_default_agent_missing";function g0(t){let e=[t.port!==void 0?`port=${t.port}`:"",t.runtime?`runtime=${t.runtime}`:"",t.detail??""].filter(Boolean).join(", ");return`openclaw gateway \u672A\u8FD0\u884C/\u4E0D\u53EF\u8FBE${e?` (${e})`:""}; \u8BF7\u542F\u52A8 openclaw gateway`}var My={protocolVersion:1,clientCapabilities:{fs:{readTextFile:!0,writeTextFile:!0}}},By=6e4,xo=class{paths;config;registry;factory;createTimeoutMs;openclawConfigCache;ensuredProviders=new Set;detectorFactory;openclawEnvBootstrapPromise;openclawConfigFactory;openclawConfigDir;constructor(e){this.paths=e.paths,this.config=e.config,this.registry=e.registry,this.factory=e.downstreamFactory??ky,this.createTimeoutMs=e.createTimeoutMs??By,this.detectorFactory=e.detectorFactory??(()=>new Gn),this.openclawConfigFactory=e.openclawConfigFactory??(r=>new fo({command:r})),this.openclawConfigDir=e.openclawConfigDir??x0(Dy(),".openclaw")}buildBinShimPathEnv(){let e=process.platform==="win32"?";":":";return{PATH:`${this.paths.binDir}${e}${process.env.PATH??""}`}}getOpenclawConfig(){if(!this.openclawConfigCache){let e=this.config.frameworksCache?.openclaw;if(!e?.path)throw new T("AGENT_SPAWN_FAILED","openclaw binary not detected on this machine");this.openclawConfigCache=this.openclawConfigFactory(e.path)}return this.openclawConfigCache}bootstrapOpenclawEnvIfNeeded(){return this.openclawEnvBootstrapPromise?this.openclawEnvBootstrapPromise:(this.openclawEnvBootstrapPromise=this.doBootstrapOpenclawEnv().catch(e=>{ge.warn("openclaw env bootstrap failed (ignored)",{err:String(e)}),this.openclawEnvBootstrapPromise=void 0}),this.openclawEnvBootstrapPromise)}async doBootstrapOpenclawEnv(){let e=this.openclawConfigDir,r=x0(e,".env");if(await Ry(r).then(c=>c.isFile()).catch(()=>!1)){ge.debug("openclaw .env exists, skip bootstrap",{envFile:r});return}await ho(e,{recursive:!0});let o=Py({...process.env,...$c(this.paths.agentEnvFile)});if(await Cy(r,o,"utf8"),process.platform!=="win32")try{await Ay(r,384)}catch(c){ge.warn("chmod ~/.openclaw/.env to 0600 failed (ignored)",{err:String(c)})}ge.info("openclaw .env bootstrapped",{envFile:r,bytes:o.length}),await this.getOpenclawConfig().restartGateway(),ge.info("openclaw gateway restarted after env bootstrap")}async createAgent(e,r){if(!e.agentId)throw new T("IPC_BAD_REQUEST","agentId required");if(!e.framework)throw new T("IPC_BAD_REQUEST","framework required");let i=Ai(e._meta)==="cloud";this.registry.reviveIfDisconnected?.(e.agentId);let o=this.registry.get(e.agentId);if(o){if(o.framework!==e.framework)throw new T("AGENT_BUSY",`agent ${e.agentId} exists with different framework (${o.framework})`);if(o.status==="error")ge.warn("existing agent in error state, rebuilding",{agentId:e.agentId}),await o.dispose("rebuild after error").catch(S=>ge.warn("dispose stale agent failed (ignored)",{err:String(S)})),this.registry.unregister(e.agentId);else{if(e.patToken&&e.patToken!==o.patToken){ge.info("updating agent patToken on re-create (reconnect with new PAT)",{agentId:e.agentId}),o.setPatToken(e.patToken);let S=await Be(e.agentId,this.paths).catch(()=>null);S&&(S.patToken=e.patToken,await Qe(S,this.paths))}if(o.deployType==="cloud"&&e.modelInfo){ge.info("updating agent modelInfo on re-create",{agentId:e.agentId}),o.setModelInfo(e.modelInfo);let S=await Be(e.agentId,this.paths).catch(()=>null);S&&(S.modelInfo=e.modelInfo,await Qe(S,this.paths))}return ge.info("agent already exists, return current",{agentId:e.agentId}),{ok:!0,agentId:o.agentId,workspace:o.workspace,framework:o.framework}}}if(!i&&!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 l=Xe(e.agentId,this.paths),u=Ai(e._meta),h=e.framework==="openclaw"&&u==="local",x;h&&!r?.revive&&(x=(await this.ensureOpenclawDefaultAgent()).workspace,await this.ensureOpenclawGatewayReachable());let w=x??(h?this.config.frameworksCache?.openclaw?.defaultAgent?.workspace:void 0),E=e.workspace??w??l.workspace,I=new AbortController,b=setTimeout(()=>I.abort(new T("AGENT_TIMEOUT",`_agent/create timed out after ${this.createTimeoutMs}ms`)),this.createTimeoutMs),v,A=!1;try{i&&Jc(e.framework)&&await er(e.framework,I.signal);let S=()=>{if(I.signal.aborted)throw I.signal.reason instanceof Error?I.signal.reason:new T("AGENT_TIMEOUT","_agent/create aborted")};await ho(l.root,{recursive:!0}),await ho(E,{recursive:!0}),await ho(l.logs,{recursive:!0}),S(),h||await rr(E,e.framework,e.cozeIdentity),e.framework==="claude-code"&&await El(E,u),S();let R=await Be(e.agentId,this.paths).catch(()=>null),O=Cf({model:e.model??R?.model}),_=wf(e._meta)??R?.accountId,C=e.patToken??R?.patToken,D=u==="cloud"?e.modelInfo??R?.modelInfo:void 0;if(v=new lo({agentId:e.agentId,framework:e.framework,workspace:E,model:O.model??Et,deployType:u,..._?{accountId:_}:{},...C?{patToken:C}:{},...D?{modelInfo:D}:{}}),v.status="ok",R?.sessions){for(let[Z,ee]of Object.entries(R.sessions))v.sessions.set(Z,{acpSessionId:ee.acpSessionId,modelToken:ee.modelToken,tokenGeneratedAt:ee.tokenGeneratedAt,lastActiveAt:Date.now(),loadingSession:!1,replySeq:0});let V=Object.keys(R.sessions).length;V>0&&ge.info("restored persisted session records (no spawn)",{agentId:e.agentId,count:V})}this.registry.register(v),A=!0;let M={agentId:e.agentId,framework:e.framework,workspace:E,cozeIdentity:e.cozeIdentity,createdAt:R?.createdAt??Date.now(),sessions:R?.sessions??{},model:O.model};u==="cloud"&&(M.deployType="cloud"),_&&(M.accountId=_),C&&(M.patToken=C),D&&(M.modelInfo=D),R?.skills&&(M.skills=R.skills),R?.agentName&&(M.agentName=R.agentName),R?.description&&(M.description=R.description),e.framework==="openclaw"&&u==="cloud"&&(this.config.frameworksCache?.openclaw?.path?(await this.bootstrapOpenclawEnvIfNeeded(),await this.getOpenclawConfig().ensureAgent(e.agentId,E)):ge.warn("openclaw binary not on this machine, skip agents add (will fail at session/prompt)",{agentId:e.agentId}));let B=e.initialSkills??[];if(B.length>0){let V=[...M.skills??[]],Z=new Map(V.map((Ee,pe)=>[Ee.skillId,pe])),ee=await Promise.allSettled(B.map(Ee=>jc({agentId:e.agentId,workspace:E,framework:e.framework,skill:Ee}))),X=0;for(let[Ee,pe]of ee.entries()){let P=B[Ee];P&&(pe.status==="fulfilled"?(Wc(V,Z,pe.value),X++):ge.warn("initialSkill install failed (skipping)",{agentId:e.agentId,skillId:P.skillId,skillName:P.skillName,err:String(pe.reason)}))}X>0&&(M.skills=V,ge.info("initialSkills installed",{agentId:e.agentId,installed:X,requested:B.length}))}return await Qe(M,this.paths),ge.info("agent created (no spawn, lazy on first prompt)",{agentId:e.agentId,framework:e.framework,deployType:u}),{ok:!0,agentId:e.agentId,workspace:E,framework:e.framework}}catch(S){throw ge.error("agent create failed, rolling back",{agentId:e.agentId,err:String(S)}),A&&v&&(await v.dispose("rollback").catch(()=>{}),this.registry.unregister(e.agentId)),await Ty(l.root,{recursive:!0,force:!0}).catch(R=>ge.warn("rm agent dir failed (ignored)",{err:String(R)})),S instanceof T?S:new T("AGENT_SPAWN_FAILED",String(S),{cause:S})}finally{clearTimeout(b)}}async spawnSessionDownstream(e,r,i,o,c){let u=this.config.frameworksCache?.[e.framework];if(!u)if(e.deployType==="cloud"&&Jc(e.framework))u=Oy;else throw new T("AGENT_SPAWN_FAILED",`framework ${e.framework} not detected on this machine`);Jc(e.framework)&&!is(e.framework)&&(ge.info("spawn: resolving acp wrapper",{agentId:e.agentId,framework:e.framework}),await er(e.framework));let h=e.deployType==="cloud"?{model:e.model,modelToken:r,...e.modelInfo?{modelInfo:e.modelInfo}:{}}:void 0,x;e.framework==="openclaw"?x=await this.buildOpenclawDownstream({session:e,modelConfig:h,cloudSessionId:i,cozeEnv:o,mockScenario:c,command:u.path}):x=this.factory(e.framework,u.path,e.workspace,e.agentId,h,i,o,c,this.buildBinShimPathEnv());try{return await x.start(),await x.initialize(My),x}catch(w){let E=x instanceof Ot?x.getStderrTail():[];throw E.length>0&&ge.warn("spawnSessionDownstream failed, recent stderr (D94)",{agentId:e.agentId,framework:e.framework,method:w instanceof T?w.code:"unknown",recentStderr:E}),await x.stop("spawnSessionDownstream failed").catch(()=>{}),await this.resolveSpawnFailure(e,u.path,w)}}async resolveSpawnFailure(e,r,i){if(e.framework==="openclaw"&&e.deployType==="local"&&r)try{let o=await this.detectorFactory().probeOpenclawGateway(r);if(!o.reachable)return new T("AGENT_ENV_NOT_READY",g0(o),{cause:{reason:p0}})}catch(o){ge.warn("openclaw gateway diagnose failed (ignored, fall through to original error)",{agentId:e.agentId,err:String(o)})}return i instanceof T?new T(i.code,i.message,{retriable:i.retriable,cause:i.cause??i}):new T("AGENT_SPAWN_FAILED",i instanceof Error?i.message:String(i),{cause:i})}async ensureOpenclawDefaultAgent(){let e=this.config.frameworksCache?.openclaw?.defaultAgent;if(e?.id&&e.workspace)return{id:e.id,workspace:e.workspace};ge.warn("openclaw default agent stale or missing, attempting lazy re-detect");let r=await this.detectorFactory().detect("openclaw");if(r?.defaultAgent?.id&&r.defaultAgent.workspace)return ge.info("openclaw lazy re-detect success",{agentId:r.defaultAgent.id,workspace:r.defaultAgent.workspace}),this.config.frameworksCache||(this.config.frameworksCache={}),this.config.frameworksCache.openclaw=r,{id:r.defaultAgent.id,workspace:r.defaultAgent.workspace};throw new T("AGENT_ENV_NOT_READY","openclaw default agent \u672A\u63A2\u6D4B\u5230; \u8BF7\u5148\u8DD1 `openclaw setup` \u6216 `openclaw agents add` \u521B\u5EFA\u9ED8\u8BA4 agent",{cause:{reason:Ny}})}async ensureOpenclawGatewayReachable(){let e=this.config.frameworksCache?.openclaw?.path;if(!e)throw new T("AGENT_SPAWN_FAILED","openclaw binary not detected on this machine");let r=await this.detectorFactory().probeOpenclawGateway(e);if(!r.reachable)throw new T("AGENT_ENV_NOT_READY",g0(r),{cause:{reason:p0}})}async buildOpenclawDownstream(e){let{session:r,modelConfig:i,cloudSessionId:o,cozeEnv:c,mockScenario:l,command:u}=e,h=Zc(o);if(r.deployType==="local"){let I=await this.ensureOpenclawDefaultAgent();return new Rr({command:u,cwd:I.workspace,agentId:I.id,sessionName:h})}let x=await h0(),w=i?Nf(i,c,l):null,E;if(w){let I=Bc(o),v=w.models[0]?.id??Et,A=`${I}/${v}`;if(!this.ensuredProviders.has(A)){let S=this.getOpenclawConfig();await S.ensureProvider(I,w),await S.addModelToAllowlist(A),this.ensuredProviders.add(A)}E=A}return new Rr({command:u,cwd:r.workspace,agentId:r.agentId,sessionName:h,...x?{gatewayToken:x}:{},...E?{slashModelOnStart:E}:{}})}async openclawRepair(e,r){let i=this.getOpenclawConfig();await i.deleteAgent(e),await i.ensureAgent(e,r)}async cleanupOpenclawSessionProviders(e){if(e.framework!=="openclaw"||!this.openclawConfigCache)return;let r=this.openclawConfigCache;for(let i of e.sessions.keys()){let o=Bc(i),c=`${o}/${e.model}`,l=!0;try{await r.removeProvider(o)}catch(u){l=!1,ge.warn("removeProvider failed, keeping ensuredProviders entry",{providerId:o,err:String(u)})}try{await r.removeModelFromAllowlist(c)}catch(u){l=!1,ge.warn("removeModelFromAllowlist failed, keeping ensuredProviders entry",{fullModelId:c,err:String(u)})}l&&this.ensuredProviders.delete(c)}}};import{randomUUID as b0}from"node:crypto";import{promises as Wy}from"node:fs";import{basename as E0}from"node:path";Ke();ne();import{promises as Fy}from"node:fs";import{basename as Uy}from"node:path";var m0=G("file-upload"),Gy="/api/coze_claw/file/agent_upload",qy=6e4;async function w0(t,e={}){let i=`${Xs(eo(e.handshakeBase))}${Gy}`,o=e.timeoutMs??qy,c=await Fy.readFile(t.path),l=new FormData;l.append("agent_id",t.agentId),l.append("session_id",t.sessionId),l.append("file_name",t.name),l.append("file_content",new Blob([c],{type:t.mimeType}),t.name);let u={Authorization:`Bearer ${t.patToken}`,Accept:"application/json","x-coze-version":"3.0",...br(e.ppeOverride),...t.accountId?{"x-coze-account":t.accountId}:{}},h=new AbortController,x=setTimeout(()=>h.abort(),o);m0.info("file upload start",{url:i,agentId:t.agentId,sessionId:t.sessionId,name:t.name,bytes:t.sizeBytes,mime:t.mimeType});try{let w=await fetch(i,{method:"POST",headers:u,body:l,signal:h.signal}),E=w.headers.get("x-tt-logid")??"";if(!w.ok){let v=await w.text().catch(()=>"");throw new T("UPLOAD_FAILED",`upload HTTP ${w.status} logid=${E}: ${v.slice(0,200)}`)}let I=await w.json();if(I.code!==void 0&&I.code!==0)throw new T("UPLOAD_FAILED",`upload code=${I.code} msg=${I.msg??"-"} logid=${E}`);let b=I.data?.file?.file_url;if(!b)throw new T("UPLOAD_FAILED",`upload response missing data.file.file_url logid=${E}: ${JSON.stringify(I).slice(0,200)}`);return m0.info("file upload ok",{uri:b,logid:E}),{uri:b}}catch(w){throw w instanceof T?w:w.name==="AbortError"?new T("UPLOAD_FAILED",`upload timeout (${o}ms) for ${Uy(t.path)}`):new T("UPLOAD_FAILED",String(w),{cause:w})}finally{clearTimeout(x)}}Ke();ne();import{extname as Hy}from"node:path";var jy={".png":"image/png",".jpg":"image/jpeg",".jpeg":"image/jpeg",".gif":"image/gif",".webp":"image/webp",".svg":"image/svg+xml",".bmp":"image/bmp",".ico":"image/x-icon",".heic":"image/heic",".heif":"image/heif",".pdf":"application/pdf",".doc":"application/msword",".docx":"application/vnd.openxmlformats-officedocument.wordprocessingml.document",".xls":"application/vnd.ms-excel",".xlsx":"application/vnd.openxmlformats-officedocument.spreadsheetml.sheet",".ppt":"application/vnd.ms-powerpoint",".pptx":"application/vnd.openxmlformats-officedocument.presentationml.presentation",".txt":"text/plain",".md":"text/markdown",".markdown":"text/markdown",".json":"application/json",".yaml":"text/yaml",".yml":"text/yaml",".csv":"text/csv",".html":"text/html",".htm":"text/html",".xml":"application/xml",".log":"text/plain",".zip":"application/zip",".tar":"application/x-tar",".gz":"application/gzip",".tgz":"application/gzip",".mp3":"audio/mpeg",".wav":"audio/wav",".mp4":"video/mp4",".mov":"video/quicktime",".webm":"video/webm"};async function _0(t){let e=Hy(t).toLowerCase();return jy[e]??"application/octet-stream"}Le();var po=G("agent-send"),y0=50*1024*1024;function v0(t,e,r){let i=t.get(e);if(!i)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 o=i.sessions.get(r);if(!o)throw new T("AGENT_NOT_FOUND",`session=${r} not active in agent=${e}`);return{session:i,runtime:o}}async function S0(t,e,r,i,o,c){let u;for(let h=0;h<=2;h++)try{await t.core.sendAgentFileUpdate(e,r,i,o);return}catch(x){u=x,h<2&&(po.warn("sendAgentFileUpdate failed, retrying",{attempt:h+1,err:String(x)}),await new Promise(w=>setTimeout(w,5e3)))}throw new T("UPSTREAM_NOT_READY",`${c} after 3 attempts: ${String(u)}`,{cause:u})}async function I0(t,e){let{session:r,runtime:i}=v0(e.core,t.agentId,t.sessionId);if(!await Xr(t.path,r.workspace))throw new T("PATH_OUTSIDE_WORKSPACE",`path=${t.path} not under workspace=${r.workspace}`);let o=await Wy.stat(t.path).catch(()=>null);if(!o||!o.isFile())throw new T("IPC_BAD_REQUEST",`path is not a regular file: ${t.path}`);if(o.size>y0)throw new T("FILE_TOO_LARGE",`${o.size} bytes > limit ${y0}`);let c=await _0(t.path);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 l=t.name??E0(t.path),u;try{u=await w0({patToken:r.patToken??e.patToken,agentId:t.agentId,sessionId:t.sessionId,path:t.path,mimeType:c,name:l,sizeBytes:o.size,...r.accountId?{accountId:r.accountId}:{}},{handshakeBase:e.handshakeBase,ppeOverride:e.ppeOverride})}catch(x){throw po.warn("agent file upload failed",{agentId:t.agentId,sessionId:t.sessionId,path:t.path,sizeBytes:o.size,mime:c,code:x instanceof T?x.code:"UNKNOWN",message:x instanceof Error?x.message:String(x)}),x}let h={sessionUpdate:"agent_file",messageId:b0(),content:{type:t.kind==="image"?"image":"resource",uri:u.uri,mimeType:c,name:l,sizeBytes:o.size,...u.fileId!==void 0?{fileId:u.fileId}:{},...t.caption!==void 0?{caption:t.caption}:{}}};return await S0(e,r,i,t.sessionId,h,"agent file uploaded to cloud but sendAgentFileUpdate failed"),po.info("agent file sent",{agentId:t.agentId,sessionId:t.sessionId,kind:t.kind,name:l,bytes:o.size,mime:c,uri:u.uri}),{ok:!0,uri:u.uri,bytes:o.size,mimeType:c,...u.fileId!==void 0?{fileId:u.fileId}:{}}}async function A0(t,e){let{session:r,runtime:i}=v0(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 o=t.name??E0(t.path),c={sessionUpdate:"group_file",messageId:b0(),content:{uri:t.path,name:o,mimeType:t.mimeType,...t.caption!==void 0?{caption:t.caption}:{}}};return await S0(e,r,i,t.sessionId,c,"agent group file sendAgentFileUpdate failed"),po.info("agent group file sent",{agentId:t.agentId,sessionId:t.sessionId,uri:t.path,name:o,mime:t.mimeType}),{ok:!0,uri:t.path,bytes:0,mimeType:t.mimeType}}function T0(t,e){let r=t.split(".").map(Number),i=e.split(".").map(Number),o=Math.max(r.length,i.length);for(let c=0;c<o;c++){let l=r[c]??0,u=i[c]??0;if(l<u)return!0;if(l>u)return!1}return!1}nn();Kt();ne();var Nt=G("coze-cli-installer"),R0="@coze/cli@latest",Ky="coze",C0="0.1.8",$y=5e3,Vy=5e3,Zy=9e4,D0=1e4,Mi=null,go=!1;async function Yc(t,e={}){if(go)return;if(Mi)return Mi;let r=e.exec??Ef;return Mi=(async()=>{try{let i=await Jy(Ky,r),o=!1;if(i){let l=await Yy(r);if(l===void 0)Nt.warn("coze-cli found but version unparseable, fall through to full install",{path:i});else if(T0(l,C0))Nt.info("coze-cli version too old, upgrade-only (preserve user config + auth)",{path:i,version:l,min:C0}),o=!0;else{Nt.info("coze-cli already on PATH with sufficient version, skip",{path:i,version:l}),go=!0;return}}let c=o?"upgrade-only":"full";Nt.info("coze-cli install start",{package:R0,mode:c});try{await r("npm",["i","-g","--prefer-online",R0],{timeout:Zy,maxBuffer:10*1024*1024}),Nt.info("coze-cli install ok")}catch(l){Nt.warn("coze-cli install failed (skip subsequent steps)",{err:String(l)});return}if(o){go=!0;return}if(t.env)try{await r("coze",["config","set","xTTEnv",t.env],{timeout:D0}),Nt.info("coze config set xTTEnv ok",{env:t.env})}catch(l){Nt.warn("coze config set failed (continue to auth login)",{err:String(l)})}try{await r("coze",["auth","login","--token",t.patToken],{timeout:D0}),Nt.info("coze auth login ok")}catch(l){Nt.warn("coze auth login failed",{err:String(l)});return}go=!0}finally{Mi=null}})(),Mi}async function Jy(t,e){let r=process.platform==="win32"?"where":"which";try{let{stdout:i}=await e(r,[t],{timeout:$y});return Ea(i)}catch{return}}async function Yy(t){try{let{stdout:e,stderr:r}=await t("coze",["--version"],{timeout:Vy});return(e||r).match(/(\d+\.\d+\.\d+)/)?.[1]}catch{return}}Yr();Le();var Xy=10*6e4;function k0(t){let e=t?.sessionIdleTimeoutMs;return typeof e!="number"||!Number.isFinite(e)||e<=0?Xy:e}function mo(t){return tr(t??Y().configFile)}function Bi(t,e){return nr(e??Y().configFile,t)}import{randomBytes as wb}from"node:crypto";Wr();Ke();ne();import{createReadStream as Qy}from"node:fs";import{mkdir as eb,readFile as tb,realpath as nb,stat as rb,writeFile as ib}from"node:fs/promises";import{basename as sb,dirname as Xc,isAbsolute as ob,join as ab,relative as cb,resolve as P0,sep as db}from"node:path";import{createInterface as lb}from"node:readline";var O0=G("fs-rpc"),zi=Ye("COZE_BRIDGE_FS_RPC_MAX_BYTES",20*1024*1024);async function N0(t,e){let r=Buffer.byteLength(t.content,"utf8");if(r>zi)throw new T("IPC_BAD_REQUEST",`fs/write_text_file content too large: ${r} bytes > limit ${zi} bytes`);let i=await B0(t.path,e);return await eb(Xc(i),{recursive:!0}),await ib(i,t.content,"utf8"),O0.info("fs/write_text_file ok",{path:i,size:t.content.length}),null}async function M0(t,e){let r=await B0(t.path,e),i=await rb(r),o=typeof t.line=="number"||typeof t.limit=="number";if(i.size>zi&&!o)throw new T("IPC_BAD_REQUEST",`fs/read_text_file too large without line/limit slicing: ${i.size} bytes > ${zi} bytes`);let c;if(o&&i.size>zi)c=await ub(r,t.line??1,t.limit);else{let l=await tb(r,"utf8");if(o){let u=l.split(`
|
|
99
|
+
`),h=Math.max(0,(t.line??1)-1),x=typeof t.limit=="number"?h+t.limit:void 0;c=u.slice(h,x).join(`
|
|
100
|
+
`)}else c=l}return O0.info("fs/read_text_file ok",{path:r,size:c.length}),{content:c}}async function ub(t,e,r){let i=lb({input:Qy(t,{encoding:"utf8"}),crlfDelay:Number.POSITIVE_INFINITY}),o=Math.max(0,e-1),c=typeof r=="number"?o+r:Number.POSITIVE_INFINITY,l=[],u=0;try{for await(let h of i)if(u>=o&&u<c&&l.push(h),u++,u>=c)break}finally{i.close()}return l.join(`
|
|
101
|
+
`)}async function B0(t,e){if(typeof t!="string"||t.length===0)throw new T("IPC_BAD_REQUEST","path must be a non-empty string");let[r,i]=await Promise.all([L0(P0(e)),L0(P0(t))]),o=cb(r,i);if(fb(o,db,ob(o)))throw new T("IPC_BAD_REQUEST",`path escapes workspace: ${t}`);return i}function fb(t,e,r){return t===""?!1:r?!0:t===".."||t.startsWith(`..${e}`)}async function L0(t){let e=[],r=t;for(;r!==Xc(r);)try{let i=await nb(r);return e.length?ab(i,...e.reverse()):i}catch{e.push(sb(r)),r=Xc(r)}return t}ne();var z0=G("prompt-multimodal"),F0=10*1024*1024,hb=15e3,xb=6;async function U0(t){let e=new Array(t.length),r=0;async function i(){for(;r<t.length;){let c=r++,l=t[c];l!==void 0&&(e[c]=await pb(l))}}let o=Array.from({length:Math.min(xb,t.length)},()=>i());return await Promise.all(o),e}function G0(t){return t.some(e=>e.type==="image")}async function pb(t){if(t.type!=="image")return t;let e=t;if(e.data||!e.uri||!Ti(e.uri))return t;try{let{buf:r,contentType:i}=await mb(e.uri),o=e.mimeType||gb(i)||"application/octet-stream";return z0.info("image uri fetched and inlined",{uri:e.uri,bytes:r.length,mimeType:o}),{type:"image",data:r.toString("base64"),mimeType:o}}catch(r){return z0.warn("image fetch failed, degrading to text block",{uri:e.uri,err:String(r)}),{type:"text",text:`[image load failed: ${e.uri}]`}}}function gb(t){if(!t)return;let e=t.indexOf(";");return(e===-1?t:t.slice(0,e)).trim()||void 0}async function mb(t){let e=new AbortController,r=setTimeout(()=>e.abort(),hb);try{let i=await fetch(t,{signal:e.signal});if(!i.ok)throw new Error(`HTTP ${i.status} ${i.statusText}`);let o=await i.arrayBuffer();if(o.byteLength>F0)throw new Error(`image too large: ${o.byteLength} bytes (max ${F0})`);return{buf:Buffer.from(o),contentType:i.headers.get("content-type")??void 0}}finally{clearTimeout(r)}}rn();Ke();ne();var $=G("core"),_b=3e4,yb=/^(boe|ppe)_[A-Za-z0-9_-]+$/,bb="\u6211\u6B63\u5728\u7B49\u5F85\u5BA1\u6279\uFF0C\u8BF7\u7A0D\u540E\u518D\u8054\u7CFB\u6211",Eb="\u5BA1\u6279\u5DF2\u8D85\u65F6",vb=3e4,wo=class{upstream;agents=new Map;disconnectedAgents=new Set;extensions;paths;sessionSpawner;sessionIdleTimeoutMs;upstreamIds=new Ar;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=k0(e.bridgeConfig)}registerExtension(e,r){this.extensions[e]=r}getCozeEnv(){return this.currentCozeEnv}getMockScenario(){return this.currentMockScenario}setMockScenario(e){this.currentMockScenario=e&&e.length>0?e:void 0}async start(){this.upstream.onFrame(e=>this.handleFrame(e)),this.upstream.onConnect?.(({initial:e})=>{e||this.rejectAllPendingOnReconnect()}),await this.upstream.start(),$.info("Core started",{extensions:Object.keys(this.extensions)})}async stop(e){$.info("Core stopping",{reason:e}),await Promise.all([...this.agents.values()].map(r=>r.dispose(e))),this.agents.clear(),await this.upstream.stop(e)}async reloadAgents(e){let r=e?this.agents.has(e)?[e]:[]:[...this.agents.keys()];for(let i of r)await this.agents.get(i)?.killAllRuntimes("reload");return r}get(e){return this.agents.get(e)}register(e){this.agents.set(e.agentId,e),$.info("agent registered",{agentId:e.agentId,framework:e.framework});for(let r of this.registerHandlers)try{r(e.agentId)}catch(i){$.warn("onAgentRegister handler threw (ignored)",{agentId:e.agentId,err:String(i)})}}onAgentRegister(e){return this.registerHandlers.add(e),()=>this.registerHandlers.delete(e)}registerHandlers=new Set;unregister(e){this.agents.delete(e)}reviveIfDisconnected(e){this.disconnectedAgents.delete(e)&&$.info("agent revived from disconnect",{agentId:e})}attachRuntimeHooks(e,r,i){let o=i.downstream;o&&(o.onUpdate(c=>{i.loadingSession||this.forwardUpdate(e,c)}),o.onAgentRequest(c=>{this.handleAgentRequest(e,o,c)}),o.onExit((c,l)=>{$.info("session runtime exited",{agentId:e.agentId,cloudId:r,code:c,signal:l}),Ni(i),i.downstream=void 0,i.replySeq=0,i.acpSessionId&&e.activeTriggers.delete(i.acpSessionId),this.rejectPendingForDownstream(o,"downstream exited")}))}hasPendingPermissionFor(e){for(let r of this.pendingUpstream.values())if(r.downstream===e)return!0;return!1}rejectPendingForDownstream(e,r){let i=[];for(let[o,c]of this.pendingUpstream)c.downstream===e&&i.push(o);if(i.length!==0){$.info("reject pendingUpstream entries (downstream gone)",{reason:r,count:i.length});for(let o of i){let c=this.pendingUpstream.get(o);if(c){this.pendingUpstream.delete(o),this.upstream.send(yn(o,{code:Q.INTERNAL_ERROR,message:`bridge downstream gone: ${r}`})).catch(l=>$.debug("send error response to upstream failed (ignored)",{err:String(l)}));try{c.downstream.respondAgentRequestError(c.agentRequestId,{code: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[,i]of this.pendingUpstream){try{i.downstream.respondAgentRequestError(i.agentRequestId,{code:Q.INTERNAL_ERROR,message:"upstream reconnected; please retry"})}catch{}this.clearPendingPermissionFor(i)}this.pendingUpstream.clear();for(let[,i]of this.pendingBridge)clearTimeout(i.timer),i.reject(new T("UPSTREAM_DISCONNECTED",`${i.method} aborted: upstream reconnected`));this.pendingBridge.clear()}}async handleFrame(e){if(ro(e)){this.handleUpstreamResponse(e);return}if(!("method"in e)||typeof e.method!="string")return;let r="id"in e&&e.id!==void 0?e.id:null,i=e.params?._meta?.cozeEnv;i&&yb.test(i)?this.currentCozeEnv=i:i&&$.warn("rejecting cozeEnv with invalid shape, keeping previous",{rejected:i});try{if(e.method.startsWith("_agent/")){let o=this.extensions[e.method];if(!o){r!==null?await this.sendError(r,Q.METHOD_NOT_FOUND,`extension not registered: ${e.method}`):$.warn("drop notification: extension not registered",{method:e.method});return}let c=await o(e,this);r!==null&&await this.upstream.send(Ir(r,c));return}if(e.method.startsWith("session/")){let o=await this.routeSessionMethod(e);r!==null&&await this.upstream.send(Ir(r,o));return}if(e.method==="initialize"){r!==null&&await this.upstream.send(Ir(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(o){$.error("handleFrame failed",{method:e.method,err:String(o)}),r!==null&&await this.upstream.send(yn(r,Oi(o)))}}async routeSessionMethod(e){if(!e.params||typeof e.params!="object")throw new T("IPC_BAD_REQUEST",`${e.method} requires params`);let r=e.params,i=r._meta?.cozeAgentId;if(!i)throw new T("IPC_BAD_REQUEST",`${e.method}: missing _meta.cozeAgentId`);let o=this.agents.get(i);if(!o)throw this.disconnectedAgents.has(i)?new T("AGENT_DISCONNECTED",`agent ${i} has been disconnected; cloud must _agent/create to revive`):new T("AGENT_NOT_FOUND",`agent not found: ${i}`);let c=typeof r.sessionId=="string"?r.sessionId:void 0;if(e.method==="session/cancel"||e.method==="session/new"||!c)return this.dispatchSessionCall(o,e.method,r);if(e.method==="session/prompt"){let h=o.sessions.get(c);if(h?.pendingPermission){let x=r._meta?.cozeTriggerMsgId,w=Pc(r._meta);return $.info("session in pendingPermission, bouncing new prompt",{agentId:o.agentId,cloudSessionId:c}),this.synthesizePromptReply(o,h,c,bb,x,w)}}let l=Date.now(),u=!1;try{let h=await o.getSessionQueue(c).enqueue(()=>this.dispatchSessionCall(o,e.method,r));return u=!0,h}finally{$.info("session call done",{agentId:o.agentId,method:e.method,durationMs:Date.now()-l,ok:u})}}async dispatchSessionCall(e,r,i){e.lastActiveAt=Date.now();let{stripped:o}=_f(i);switch(r){case"session/new":{let c=Sb();return $.info("session/new ack (lazy spawn)",{agentId:e.agentId,cloudId:c}),{sessionId:c}}case"session/load":{let c=o;return $.info("session/load ack (lazy spawn)",{agentId:e.agentId,cloudId:c.sessionId}),{}}case"session/prompt":{let c=o,l=c.sessionId;if(!l)throw new T("IPC_BAD_REQUEST","session/prompt: missing sessionId");let u=await this.ensureRuntime(e,l);if(u.replySeq=0,await this.ensureDownstream(e,l,u),!u.downstream||!u.acpSessionId)throw new T("BRIDGE_INTERNAL","session runtime not ready after ensureDownstream");let h=i._meta?.cozeTriggerMsgId;h?e.activeTriggers.set(u.acpSessionId,h):e.activeTriggers.delete(u.acpSessionId);let x=Pc(i._meta);if(x?e.activeGroupIds.set(u.acpSessionId,x):e.activeGroupIds.delete(u.acpSessionId),e.deployType==="cloud"&&e.modelInfo?.capabilities?.image===!1&&G0(c.prompt))throw new T("MODEL_MODALITY_UNSUPPORTED",`model=${e.modelInfo.id??e.model} does not support image input`);let w=await U0(c.prompt);try{let E=await u.downstream.sessionPrompt({...c,sessionId:u.acpSessionId,prompt:w});return u.lastActiveAt=Date.now(),E}catch(E){if(E instanceof T&&E.code==="AGENT_APPROVAL_TIMEOUT"){let I=u.pendingPermission;I&&(I.downstream.respondAgentRequest(I.agentRequestId,{outcome:{outcome:"cancelled"}}),this.pendingUpstream.delete(I.upstreamId),u.pendingPermission=void 0);let b=u.acpSessionId,v=b?e.activeTriggers.get(b):void 0,A=b?e.activeGroupIds.get(b):void 0;return $.warn("approval timed out, synthesizing \u5BA1\u6279\u5DF2\u8D85\u65F6 reply + recovering session",{agentId:e.agentId,cloudId:l}),await this.synthesizePromptReply(e,u,l,Eb,v,A)}throw E}finally{if(e.activeTriggers.delete(u.acpSessionId),e.activeGroupIds.delete(u.acpSessionId),u.pendingPermission=void 0,u.reloadAfterTurn){u.reloadAfterTurn=!1;let E=u.downstream;E&&(u.downstream=void 0,$.info("reloadAfterTurn: stopping downstream",{agentId:e.agentId,cloudId:l,acpId:u.acpSessionId}),E.stop("reload-after-turn").catch(I=>$.warn("reload-after-turn stop failed (ignored)",{agentId:e.agentId,cloudId:l,err:String(I)})))}else u.downstream?.isAlive()&&this.armIdleTimer(e,l,u)}}case"session/cancel":{let l=o.sessionId;if(!l)throw new T("IPC_BAD_REQUEST","session/cancel: missing sessionId");let u=e.sessions.get(l);if(e.hasSessionQueue(l)){let h=e.getSessionQueue(l);h.size>0&&($.info("session/cancel: draining queued tasks",{agentId:e.agentId,cloudId:l,queuedCount:h.size}),h.dispose(new T("AGENT_PROTOCOL_ERROR",`cancelled by session/cancel on ${l}`)))}return u?.downstream?.isAlive()&&u.acpSessionId&&await u.downstream.sessionCancel({sessionId:u.acpSessionId}),{ok:!0}}default:throw new T("IPC_BAD_REQUEST",`session method not supported: ${r}`)}}async ensureRuntime(e,r){let i=e.sessions.get(r);if(i)return i;let c={modelToken:e.deployType==="cloud"?await this.requestSessionToken(e.agentId,r):"",tokenGeneratedAt:Date.now(),lastActiveAt:Date.now(),loadingSession:!1,replySeq:0};return e.sessions.set(r,c),await this.persistSessionMapping(e),c}async requestSessionToken(e,r){let i={sessionId:r,_meta:{cozeAgentId:e}};try{let o=await this.sendRequest(bt.GEN_MODEL_TOKEN,i,vb);if(!o?.modelToken)throw new T("MODEL_TOKEN_GEN_FAILED",`cloud returned empty modelToken (agentId=${e}, cloudSessionId=${r})`);return o.modelToken}catch(o){throw o instanceof T&&o.code==="MODEL_TOKEN_GEN_FAILED"?o:new T("MODEL_TOKEN_GEN_FAILED",o instanceof Error?o.message:String(o),{cause:o})}}async ensureDownstream(e,r,i){if(Ni(i),i.downstream?.isAlive())return;if(!this.sessionSpawner)throw new T("AGENT_SPAWN_FAILED","sessionSpawner not wired (cannot spawn per-session downstream)");let o=3,c=3e4,l=i.spawnFailCount??0,u=i.spawnFailedAt??0;if(l>=o&&Date.now()-u<c)throw new T("AGENT_SPAWN_FAILED",`agent ${e.agentId} session ${r} spawn failed ${l} times in a row; please check framework binary / network and retry after ${Math.ceil((c-(Date.now()-u))/1e3)}s`);let h;try{h=await this.sessionSpawner(e,i.modelToken,r,this.currentCozeEnv,this.currentMockScenario)}catch(x){throw i.spawnFailCount=l+1,i.spawnFailedAt=Date.now(),i.spawnFailCount>=o&&i.acpSessionId&&($.warn("clearing stale acpSessionId after repeated spawn failures",{agentId:e.agentId,cloudId:r,staleAcpId:i.acpSessionId}),i.acpSessionId=void 0),x}i.spawnFailCount=0,i.spawnFailedAt=void 0,i.downstream=h,this.attachRuntimeHooks(e,r,i);try{if(i.acpSessionId){i.loadingSession=!0;try{await h.sessionLoad({sessionId:i.acpSessionId,cwd:e.workspace}),$.info("session restored via session/load",{agentId:e.agentId,cloudId:r,acpId:i.acpSessionId})}catch(x){$.warn("session/load failed, fallback to session/new",{agentId:e.agentId,cloudId:r,acpId:i.acpSessionId,err:String(x)}),i.acpSessionId=void 0;let w=await h.sessionNew({cwd:e.workspace});i.acpSessionId=w.sessionId,await this.persistSessionMapping(e)}finally{i.loadingSession=!1}}else{let x=await h.sessionNew({cwd:e.workspace});i.acpSessionId=x.sessionId,await this.persistSessionMapping(e)}}catch(x){throw $.warn("session init failed after spawn, tearing down half-spawned runtime",{agentId:e.agentId,cloudId:r,acpId:i.acpSessionId,err:String(x)}),await h.stop("session-init-failed").catch(()=>{}),i.downstream=void 0,i.acpSessionId=void 0,x}h.afterSessionEstablished&&i.acpSessionId&&await h.afterSessionEstablished(i.acpSessionId)}armIdleTimer(e,r,i){if(Ni(i),this.isRuntimeBusy(e,i)){$.debug("skip idle timer: runtime busy (in-flight turn / pending permission)",{agentId:e.agentId,cloudId:r});return}i.idleTimer=setTimeout(()=>{if(i.idleTimer=void 0,this.isRuntimeBusy(e,i)){$.info("idle reaper fired but runtime busy, re-arming",{agentId:e.agentId,cloudId:r}),this.armIdleTimer(e,r,i);return}$.info("session runtime idle timeout, killing downstream",{agentId:e.agentId,cloudId:r});let o=i.downstream;i.downstream=void 0,i.acpSessionId&&e.activeTriggers.delete(i.acpSessionId),o&&o.stop("idle timeout").catch(c=>$.warn("idle stop failed (ignored)",{agentId:e.agentId,cloudId:r,err:String(c)}))},this.sessionIdleTimeoutMs),i.idleTimer.unref?.()}isRuntimeBusy(e,r){if(r.acpSessionId&&e.activeTriggers.has(r.acpSessionId))return!0;let i=r.downstream;if(!i)return!1;for(let o of this.pendingUpstream.values())if(o.downstream===i)return!0;return!1}async sendAgentFileUpdate(e,r,i,o){let c={cozeAgentId:e.agentId,cozeReplySeqID:++r.replySeq};if(r.acpSessionId){let l=e.activeTriggers.get(r.acpSessionId);l&&(c.cozeTriggerMsgId=l);let u=e.activeGroupIds.get(r.acpSessionId);u&&(c.cozeGroupId=u)}await this.upstream.send(Sr("session/update",{sessionId:i,update:o,_meta:c}))}async synthesizePromptReply(e,r,i,o,c,l){let u={cozeAgentId:e.agentId,cozeReplySeqID:++r.replySeq};return c&&(u.cozeTriggerMsgId=c),l&&(u.cozeGroupId=l),await this.upstream.send(Sr("session/update",{sessionId:i,update:{sessionUpdate:"agent_message_chunk",content:{type:"text",text:o}},_meta:u})).catch(h=>$.warn("synthesizePromptReply update send failed (ignored)",{err:String(h)})),{stopReason:"end_turn"}}forwardUpdate(e,r){let i=r.sessionId,o=this.reverseSessionId(e,i);if(!o){$.debug("drop update for unknown session",{agentId:e.agentId,acpId:i});return}let c=e.sessions.get(o);if(!c){$.debug("drop update: runtime gone",{agentId:e.agentId,cloudId:o});return}if(Tb(r)){$.debug("drop codex noise chunk",{agentId:e.agentId,acpId:i});return}let l={cozeAgentId:e.agentId,cozeReplySeqID:++c.replySeq},u=e.activeTriggers.get(i);u&&(l.cozeTriggerMsgId=u);let h=e.activeGroupIds.get(i);h&&(l.cozeGroupId=h),this.upstream.send(Sr("session/update",{...r,sessionId:o,_meta:l})).catch(x=>$.warn("forward update failed",{agentId:e.agentId,err:String(x)}))}handleAgentRequest(e,r,i){if(i.method==="session/request_permission"){this.forwardPermissionRequest(e,r,i);return}if(i.method==="fs/write_text_file"||i.method==="fs/read_text_file"){this.handleFsRpcRequest(e,r,i);return}$.warn("unhandled agent request,returning method_not_found",{agentId:e.agentId,method:i.method}),r.respondAgentRequestError(i.id,{code:Q.METHOD_NOT_FOUND,message:`method not handled by Bridge: ${i.method}`})}async handleFsRpcRequest(e,r,i){try{let o=e.workspace;if(i.method==="fs/write_text_file"){let c=i.params??{},l=await N0(c,o);r.respondAgentRequest(i.id,l)}else{let c=i.params??{},l=await M0(c,o);r.respondAgentRequest(i.id,l)}}catch(o){$.warn("fs rpc handler failed",{agentId:e.agentId,method:i.method,err:String(o)}),r.respondAgentRequestError(i.id,Oi(o))}}clearPendingPermissionFor(e){if(e.method!=="session/request_permission"||!e.cloudSessionId)return;let r=this.agents.get(e.agentId)?.sessions.get(e.cloudSessionId);r&&(r.pendingPermission=void 0)}forwardPermissionRequest(e,r,i){let o=this.upstreamIds.next("session/request_permission"),c=i.params??{},u=c.sessionId,h=u?e.activeTriggers.get(u):void 0,x={cozeAgentId:e.agentId};h&&(x.cozeTriggerMsgId=h);let w=u?e.activeGroupIds.get(u):void 0;w&&(x.cozeGroupId=w);let E=u?this.reverseSessionId(e,u):void 0,I=E?e.sessions.get(E):void 0;I&&(I.pendingPermission={downstream:r,agentRequestId:i.id,upstreamId:o});let b={...c,...E?{sessionId:E}:{},_meta:x};this.pendingUpstream.set(o,{agentRequestId:i.id,agentId:e.agentId,downstream:r,method:i.method,cloudSessionId:E}),$.info("forward permission_request \u2192 upstream",{agentId:e.agentId,upstreamId:o,acpSessionId:u,cloudSessionId:E,toolCallId:c.toolCall?.toolCallId,options:c.options?.map(v=>({optionId:v.optionId,kind:v.kind,name:v.name}))}),this.upstream.send(Pi(o,"session/request_permission",b)).catch(v=>{this.pendingUpstream.delete(o),$.error("forward permission request failed",{agentId:e.agentId,err:String(v)}),r.respondAgentRequestError(i.id,{code:Q.INTERNAL_ERROR,message:`upstream send failed: ${String(v)}`})})}handleUpstreamResponse(e){if(e.id===null)return;let r=this.lookupPending(this.pendingUpstream,e.id,"upstream");if(r){this.pendingUpstream.delete(r.key);let o=r.value;this.clearPendingPermissionFor(o),e.error?($.info("upstream \u2192 permission response (error)",{agentId:o.agentId,upstreamId:e.id,method:o.method,error:e.error}),o.downstream.respondAgentRequestError(o.agentRequestId,e.error)):(o.method==="session/request_permission"&&Ib(e.result,o),$.info("upstream \u2192 permission response (result)",{agentId:o.agentId,upstreamId:e.id,method:o.method,result:e.result}),o.downstream.respondAgentRequest(o.agentRequestId,e.result));return}let i=this.lookupPending(this.pendingBridge,e.id,"bridge");if(i){this.pendingBridge.delete(i.key),clearTimeout(i.value.timer),e.error?i.value.reject(new no(e.error)):i.value.resolve(e.result);return}$.debug("orphan upstream response (no pending)",{id:e.id})}lookupPending(e,r,i){let o=e.get(r);if(o)return{value:o,key:r};if(typeof r=="number"){let c=String(r),l=e.get(c);if(l)return $.warn(`${i} id type mismatch: number received but Bridge expected string`,{rawId:r,normalizedId:c}),{value:l,key:c}}}sendRequest(e,r,i=_b){let o=this.upstreamIds.next(e);return new Promise((c,l)=>{let u=setTimeout(()=>{this.pendingBridge.delete(o),l(new T("AGENT_TIMEOUT",`${e} timed out after ${i}ms`))},i);this.pendingBridge.set(o,{method:e,resolve:c,reject:l,timer:u}),this.upstream.send(Pi(o,e,r)).catch(h=>{let x=this.pendingBridge.get(o);x&&(clearTimeout(x.timer),this.pendingBridge.delete(o)),l(h)})})}async persistSessionMapping(e){if(this.paths)try{let r=new Map;for(let[i,o]of e.sessions){let c={modelToken:o.modelToken,tokenGeneratedAt:o.tokenGeneratedAt};o.acpSessionId&&(c.acpSessionId=o.acpSessionId),r.set(i,c)}await Qr(e.agentId,r,this.paths)}catch(r){$.warn("persist session mapping failed",{agentId:e.agentId,err:String(r)})}}reverseSessionId(e,r){for(let[i,o]of e.sessions.entries())if(o.acpSessionId===r)return i}sendError(e,r,i){return this.upstream.send(yn(e,{code:r,message:i,data:{bridgeVersion:vr}}))}};function Sb(){return wb(16).toString("hex")}function Ib(t,e){if(!t||typeof t!="object"){$.warn("permission response: result not an object (suspicious)",{agentId:e.agentId,result:t});return}let r=t;if("kind"in r&&!("outcome"in r)){$.warn('permission response: top-level "kind" field (D66 historical bug shape)',{agentId:e.agentId,result:t});return}let i=r.outcome;if(!i||typeof i!="object"){$.warn("permission response: missing or non-object outcome field",{agentId:e.agentId,result:t});return}let c=i.outcome;(typeof c!="string"||c!=="selected"&&c!=="cancelled")&&$.warn("permission response: unknown outcome discriminant",{agentId:e.agentId,outcomeValue:c,result:t})}var Ab=["Model metadata for `","Falling back from WebSockets to HTTPS transport.","Heads up: Long threads and multiple compactions can cause the model to be less accurate."];function Tb(t){let e=t.update;if(e?.sessionUpdate!=="agent_message_chunk")return!1;let r=e.content;if(!r||typeof r!="object")return!1;let i=r;if(i.type!=="text"||typeof i.text!="string")return!1;let{text:o}=i;return Ab.some(c=>o.startsWith(c))}ne();Le();import{randomBytes as Rb}from"node:crypto";import{chmod as Cb,mkdir as Db,writeFile as q0}from"node:fs/promises";import{createServer as kb}from"node:http";import{dirname as Pb}from"node:path";var Lb=1e6,Qc=G("ipc"),_o=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??Y()}async start(){this.token=Rb(32).toString("hex");let e=kb((i,o)=>{this.dispatch(i,o)});this.server=e,await new Promise((i,o)=>{e.once("error",o),e.listen(0,"127.0.0.1",()=>i())});let r=e.address();if(!r||typeof r!="object")throw new Error("failed to obtain IPC port");return this.port=r.port,await this.persistAuthFiles(),Qc.info("IPC listening",{port:this.port}),{port:this.port,token:this.token}}async stop(){let e=this.server;e&&(await new Promise((r,i)=>{e.close(o=>o?i(o):r())}),this.server=null)}async persistAuthFiles(){await Db(Pb(this.paths.portFile),{recursive:!0}),await q0(this.paths.portFile,String(this.port),"utf8"),await q0(this.paths.tokenFile,this.token,{encoding:"utf8",mode:384});try{await Cb(this.paths.tokenFile,384)}catch(e){Qc.warn("chmod token file failed (non-POSIX?)",{err:String(e)})}}async dispatch(e,r){if(e.headers.authorization!==`Bearer ${this.token}`){Fi(r,401,{error:"unauthorized"});return}let o=`${e.method} ${(e.url??"").split("?")[0]}`,c=this.routes.get(o);if(!c){Fi(r,404,{error:"not found"});return}let l=null;if(e.method==="POST")try{l=await Ob(e)}catch(u){Fi(r,400,{error:"invalid json",detail:String(u)});return}try{let u=await c.handler(l,e);Fi(r,200,u??{ok:!0})}catch(u){Qc.error("IPC handler failed",{key:o,err:String(u)}),Fi(r,500,{error:u instanceof Error?u.message:String(u)})}}};function Fi(t,e,r){t.statusCode=e,t.setHeader("content-type","application/json"),t.end(JSON.stringify(r))}async function Ob(t){let e=[],r=0;for await(let o of t){let c=o;if(r+=c.length,r>Lb)throw new Error("body too large");e.push(c)}let i=Buffer.concat(e).toString("utf8");return i?JSON.parse(i):null}var lx=At(Q0(),1);var xv=At(Vh(),1),pv=At(No(),1),gv=At(kr(),1),mv=At(fd(),1),wv=At(pd(),1),_v=At(bd(),1),rx=At(Fo(),1),yv=At(nx(),1);var ix=rx.default;Ke();ne();var ke=G("upstream.frontier"),ox="application/json",ax="none",Ev=15e3;function vv(t){class e extends ix{constructor(i){super(i,Sf,{headers:t})}guardTeardown(){this.listenerCount("error")===0&&this.on("error",i=>ke.warn("frontier ws error during teardown (handled, prevents daemon crash)",{err:i instanceof Error?i.message:String(i)}))}close(i,o){this.guardTeardown(),super.close(i,o)}terminate(){this.guardTeardown(),super.terminate()}send(i,...o){if(ol("debug"))try{let c;typeof i=="string"?c=Buffer.from(i,"utf8"):i instanceof Buffer?c=i:i instanceof ArrayBuffer?c=new Uint8Array(i):ArrayBuffer.isView(i)?c=new Uint8Array(i.buffer,i.byteOffset,i.byteLength):c=new Uint8Array(0);let l=Buffer.from(c.slice(0,128)).toString("hex");ke.debug("WS raw frame out",{bytes:c.byteLength,headHex:l})}catch(c){ke.warn("WS raw frame dump failed",{err:String(c)})}super.send(i,...o)}}return e}var Vi=class{constructor(e){this.opts=e}opts;fws=null;handler=null;connectHandlers=[];opened=!1;lastSendRefusedLogAt=0;sendRefusedSuppressed=0;openCount=0;async start(){if(this.fws){ke.warn("start called on already-started FrontierUpstream; noop");return}let e={Authorization:`Bearer ${this.opts.privatecode}`,Origin:If,...br(this.opts.ppeOverride)},r=vv(e),i=Tf(this.opts.urlOverride),o={url:i,ws:r,fpID:vf,aID:Qs,accessKey:this.opts.handshake.accessKey,deviceID:this.opts.handshake.deviceId,payloadType:{type:ox,force:!0},payloadEncoding:{encoding:ax,force:!0},enableTransformTextPayload:!0,enableQoS:!1,enableAutoAck:!1,automaticOpen:!1,maxRetries:Number.POSITIVE_INFINITY,debug:this.opts.debug??!1},c=new lx.FWS(o),l=!1,u=null,h,x,w=new Promise((b,v)=>{h=b,x=v}),E=b=>{l||(l=!0,u&&(clearTimeout(u),u=null),b?x(b):h())};c.onopen=()=>{this.opened=!0,this.openCount+=1;let b=this.openCount===1;ke.info("frontier opened",{url:i,remoteDeviceId:this.opts.handshake.deviceId,initial:b,openCount:this.openCount}),b&&E();for(let v of this.connectHandlers)Promise.resolve(v({initial:b})).catch(A=>ke.warn("onConnect handler threw (ignored)",{err:String(A)}))},c.onclose=b=>{this.opened=!1,ke.info("frontier closed",{code:b.code,reason:b.reason,willReconnect:b.willReconnect})},c.onerror=b=>{ke.warn("frontier error",{code:b.code,msg:b.message}),E(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 I=this.opts.openTimeoutMs??Ev;u=setTimeout(()=>{E(new T("UPSTREAM_DISCONNECTED",`frontier ws open timeout after ${I}ms (handshake or upgrade slow)`))},I),await c.connect();try{await w}catch(b){try{c.close(1e3,"open failed")}catch(v){ke.warn("fws close during start failure threw (ignored)",{err:String(v)})}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(i){ke.warn("frontier close threw (ignored)",{err:String(i)})}}}async send(e){let r=this.fws,i=e.method;if(!r)throw ke.warn("frontier send refused: upstream not started",{method:i}),new T("UPSTREAM_DISCONNECTED","frontier upstream not started");if(!this.isConnected()){let u=Date.now();throw u-this.lastSendRefusedLogAt>1e3?(ke.warn("frontier send refused: ws not open",{method:i,opened:this.opened,readyState:r.readyState,...this.sendRefusedSuppressed>0?{suppressedSinceLast:this.sendRefusedSuppressed}:{}}),this.lastSendRefusedLogAt=u,this.sendRefusedSuppressed=0):this.sendRefusedSuppressed+=1,new T("UPSTREAM_DISCONNECTED",`frontier ws not open (opened=${this.opened}, readyState=${r.readyState}); refusing to silently buffer`)}this.injectAgentPatToken(e);let o=JSON.stringify(e),c=e;cx(c)||ke.info("frontier frame out",{method:c.method,jsonrpcId:c.id,size:o.length});try{await r.send(o,{service:33555712,method:1,payloadType:ox,payloadEncoding:ax})}catch(u){throw ke.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 i=e.params?._meta;if(!i?.cozeAgentId)return;let o=r(i.cozeAgentId);o&&(i.cozePatToken=o)}handleMessage(e){let r=e.message?.service;if(r!==33555712){ke.debug("drop non-adapter frontier frame",{service:r});return}let i=Av(e);if(!i){ke.debug("frontier message without text payload, drop",{payloadType:e.message?.payloadType});return}if(!this.handler){ke.debug("frame received but no onFrame handler",{size:i.length});return}let o;try{o=JSON.parse(i)}catch(l){ke.warn("frontier message JSON parse failed",{err:String(l),head:i.slice(0,80)});return}let c=o;cx(c)||ke.info("frontier frame in",{logid:Iv(e.message?.LogID),logidNew:e.message?.LogIDNew,msgId:e.message?.msgID,jsonrpcId:c.id,method:c.method,body:Sv(i)}),Promise.resolve(this.handler(o)).catch(l=>ke.warn("frontier frame handler threw",{err:String(l)}))}};function cx(t){return t.method==="_agent/health"?!0:typeof t.id=="string"&&t.id.startsWith("agent.health_")}var dx=2e3;function Sv(t){return t.length<=dx?t:`${t.slice(0,dx)}...<truncated, total ${t.length} chars>`}function Iv(t){return t?t.high===0?String(t.low>>>0):`${t.high.toString(16)}${(t.low>>>0).toString(16).padStart(8,"0")}`:""}function Av(t){let e=t.message;if(e?.textPayload)return e.textPayload;let r=e?.payload;if(!r)return null;try{return Buffer.from(r).toString("utf8")}catch{return null}}ne();var vd=G("upstream.switchable"),Go=class{inner;handler=null;connectHandlers=[];constructor(e){this.inner=e}async swap(e,r){if(this.inner===e)return;vd.info("swap upstream",{reason:r});let i=this.inner;if(this.inner=e,this.handler&&e.onFrame(this.handler),e.onConnect)for(let o of this.connectHandlers)e.onConnect(o);try{await e.start()}catch(o){throw vd.error("swap target start failed, reverting",{err:String(o)}),this.inner=i,o}await i.stop(r??"swapped").catch(o=>vd.warn("previous upstream stop threw (ignored)",{err:String(o)}))}current(){return this.inner}start(){return this.inner.start()}stop(e){return this.inner.stop(e)}send(e){return this.inner.send(e)}onFrame(e){this.handler=e,this.inner.onFrame(e)}onConnect(e){this.connectHandlers.push(e),this.inner.onConnect?.(e)}isConnected(){return this.inner.isConnected()}};ne();var Sd=G("upstream"),Br=class{handler=null;async start(){Sd.info("NoopUpstream started (M1 skeleton; real Frontier wired in M4)")}async stop(e){Sd.info("NoopUpstream stopped",{reason:e})}async send(e){Sd.debug("NoopUpstream.send (dropped)",{method:"method"in e?e.method:void 0})}onFrame(e){this.handler=e}isConnected(){return!1}async injectFrame(e){this.handler&&await this.handler(e)}};Ke();ne();ne();Le();import{promises as Id}from"node:fs";import{dirname as Tv}from"node:path";var Rv=G("pat-token-store");async function qo(t=Y()){try{let r=(await Id.readFile(t.patTokenFile,"utf8")).trim();return r.length>0?r:null}catch(e){let r=e?.code;return r!=="ENOENT"&&Rv.warn("read pat-token failed (treating as missing)",{path:t.patTokenFile,code:r,message:e.message}),null}}async function Zi(t,e=Y()){if(!t)throw new Error("writePatToken: empty patToken");await Id.mkdir(Tv(e.patTokenFile),{recursive:!0}),await Id.writeFile(e.patTokenFile,t,{encoding:"utf8",mode:384})}Le();Le();import{promises as Ho}from"node:fs";import{join as Cv}from"node:path";function Dv(t,e){return`#!/bin/sh
|
|
102
102
|
exec ${JSON.stringify(e)} ${JSON.stringify(t)} "$@"
|
|
103
|
-
`}function
|
|
103
|
+
`}function kv(t,e){return`@echo off\r
|
|
104
104
|
"${e}" "${t}" %*\r
|
|
105
|
-
`}async function gh(t,e=X()){let r=e.binDir;await Vo.mkdir(r,{recursive:!0});let i=Av(r,process.platform==="win32"?"coze-bridge.cmd":"coze-bridge"),o=process.execPath,c=process.platform==="win32"?Tv(t,o):Iv(t,o);return await Vo.readFile(i,"utf8").catch(()=>null)===c||(await Vo.writeFile(i,c,"utf8"),process.platform!=="win32"&&await Vo.chmod(i,493)),r}ne();ke();import{execSync as mh}from"node:child_process";import{readFileSync as wh,unlinkSync as Cv}from"node:fs";import{mkdir as Rv,readFile as _h,unlink as yh,writeFile as Dv}from"node:fs/promises";import{dirname as kv}from"node:path";var Ov=j("single-instance"),Yo=class{pidFile;acquired=!1;constructor(e={}){this.pidFile=e.pidFile??X().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&&(Ov.warn("removing stale pid file",{stalePid:e}),await yh(this.pidFile).catch(()=>{})),await Rv(kv(this.pidFile),{recursive:!0}),await Dv(this.pidFile,String(process.pid),"utf8"),this.acquired=!0,this.installCleanupHooks(),{kind:"acquired"})}async release(){if(this.acquired){try{(await _h(this.pidFile,"utf8")).trim()===String(process.pid)&&await yh(this.pidFile)}catch{}this.acquired=!1}}async readExistingPid(){try{let e=await _h(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 fo(e)?this.matchesDaemonTitle(e):!1}matchesDaemonTitle(e){if(process.platform==="win32")return this.matchesDaemonTitleWindows(e);try{let r=wh(`/proc/${e}/cmdline`,"utf8").replace(/\0/g," ");return!!(r.includes("coze-bridge-daemon")||r.includes("lib/index.js"))}catch{}try{let r=mh(`ps -o command= -p ${e}`,{stdio:["ignore","pipe","ignore"],timeout:1e3}).toString();return r.trim()?r.includes("coze-bridge-daemon")||r.includes("lib/index.js"):!1}catch{return!0}}matchesDaemonTitleWindows(e){try{let i=mh(`tasklist /FI "PID eq ${e}" /FO CSV /NH`,{stdio:["ignore","pipe","ignore"],timeout:2e3}).toString().trim();if(!i||/^(INFO|信息)[::]/.test(i))return!1;let o=i.split(",",1)[0]?.replace(/^"|"$/g,"").toLowerCase()??"";return o.includes("node")||o.includes("coze-bridge")}catch{return!0}}installCleanupHooks(){process.once("exit",()=>{if(this.acquired)try{wh(this.pidFile,"utf8").trim()===String(process.pid)&&Cv(this.pidFile)}catch{}})}};Jo();ne();var $n=j("daemon.upstream-watchdog"),Uv=12e4,Gv=9e5,qv=3e4;function Od(t,e){let r=process.env[t];if(!r)return e;let i=Number(r);return Number.isFinite(i)&&i>0?i:e}var Zo=class{constructor(e){this.opts=e;this.softMs=e.softMs??Od("COZE_BRIDGE_UPSTREAM_WATCHDOG_SOFT_MS",Uv),this.hardMs=e.hardMs??Od("COZE_BRIDGE_UPSTREAM_WATCHDOG_HARD_MS",Gv),this.intervalMs=e.intervalMs??Od("COZE_BRIDGE_UPSTREAM_WATCHDOG_INTERVAL_MS",qv),this.now=e.now??Date.now}opts;softMs;hardMs;intervalMs;now;timer=null;downSince=null;forcedAt=null;forcing=!1;lastTickAt=null;start(){this.timer||(this.timer=setInterval(()=>this.tick(),this.intervalMs),this.timer.unref?.(),$n.info("upstream watchdog started",{softMs:this.softMs,hardMs:this.hardMs,intervalMs:this.intervalMs}))}stop(){this.timer&&(clearInterval(this.timer),this.timer=null),this.downSince=null,this.forcedAt=null,this.lastTickAt=null}tick(){let e=this.now();if(this.lastTickAt!==null&&e-this.lastTickAt>this.intervalMs*3&&(this.downSince!==null&&$n.warn("upstream watchdog: large tick gap (likely sleep/suspend), resetting downSince",{gapMs:e-this.lastTickAt}),this.downSince=null,this.forcedAt=null),this.lastTickAt=e,this.opts.isConnected()){this.downSince!==null&&$n.info("upstream watchdog: reconnected, reset",{downMs:this.now()-this.downSince}),this.downSince=null,this.forcedAt=null;return}if(this.downSince===null){this.downSince=e,$n.warn("upstream watchdog: disconnect detected, arming",{softMs:this.softMs,hardMs:this.hardMs});return}let r=e-this.downSince;if(r>=this.hardMs){$n.error("upstream watchdog: disconnected too long, exiting for supervisor restart",{downMs:r,hardMs:this.hardMs}),this.opts.onFatal(r);return}r>=this.softMs&&this.shouldForceNow(e)&&(this.forcedAt=e,this.forcing=!0,$n.warn("upstream watchdog: forcing reconnect",{downMs:r,softMs:this.softMs}),Promise.resolve().then(()=>this.opts.forceReconnect()).catch(i=>$n.warn("upstream watchdog: forceReconnect error (ignored)",{err:String(i)})).finally(()=>{this.forcing=!1}))}shouldForceNow(e){return!(this.forcing||this.forcedAt!==null&&e-this.forcedAt<this.softMs)}};var K=j("daemon"),Hv="coze-bridge-daemon";async function vh(){let t=X();process.env.COZE_BRIDGE_LOG_MODE!=="legacy"&&cl({bridgeLogsDir:t.bridgeLogsDir,agentLogsDir:O=>Ze(O,t).logs,listAgentIds:()=>ds(t)});let e=new Yo({processTitle:Hv}),r=await e.acquire();if(r.kind==="already-running")throw new Error(`coze-bridge daemon already running (pid=${r.pid})`);let i=await Eo(),o=i??{};as({pid:process.pid}),K.info(i?"loaded bridge config":"initialized bridge config");try{let O=new Gn;o.frameworksCache=await O.detectAll(),K.info("refreshed frameworks_cache",{detected:Object.keys(o.frameworksCache)})}catch(O){K.warn("framework detection failed",{err:String(O)})}await Fi(o);let c=new Ko(new Br),l=null,f=new vo({upstream:c,paths:t,bridgeConfig:o,sessionSpawner:async(O,W,$,ie)=>{if(!l)throw new Error("agentManager not ready");return l.spawnSessionDownstream(O,W,$,ie)}});await Wv(t,f);let x=new _o({paths:t,config:o,registry:f});l=x;let h,_,w=null,S={},b,v=null,I=null,A=null,C=new bn;function P(O,W){return C.enqueue(()=>R(O,W))}function y(){I||(I=new Zo({isConnected:()=>c.isConnected(),forceReconnect:()=>A?P(A,{force:!0}):void 0,onFatal:O=>{if(process.env[Zi]==="1"){K.error("upstream watchdog fatal, but daemon is unmanaged (CLI-spawned) \u2014 staying alive for soft-reconnect instead of exiting",{downMs:O});return}K.error("upstream watchdog fatal: exiting for supervisor restart",{downMs:O}),process.exit(1)}})),I.start()}async function R(O,W){let $=O,ie=$?.privatecode;if(!ie)throw new T("IPC_BAD_REQUEST","/connect requires privatecode");let Ve=Di($.env),fe=$.handshake_url,ue=$.frontier_url,vt=Eh($.env,fe,ue);if(A=$,!W?.force&&h===ie&&_===vt){let me=await jv(t);return f.agents.size===0&&me?(K.warn("/connect noop but core.agents empty with configs on disk; re-running auto-revive"),Qo(t,x).catch(Ae=>K.warn("connect-noop auto-revive error (ignored)",{err:String(Ae)}))):K.info("/connect: already connected with same PAT + env, noop"),{ok:!0,note:"already connected"}}let ut=!!h&&h!==ie,Zt=_!==void 0&&_!==vt,Bt=ut||Zt,Xt=await Fc({privatecode:ie,...fe?{endpoint:fe}:{},ppeOverride:Ve});if(Bt){K.warn("connect config switched, resetting agents",{pcChanged:ut,envChanged:Zt,previousPc:h?Xo(h):"",nextPc:Xo(ie)});for(let me of[...f.agents.values()])await me.dispose("connect config switch").catch(()=>{}),f.agents.delete(me.agentId);f.disconnectedAgents.size>0&&(K.info("clearing disconnectedAgents set on connect config switch",{count:f.disconnectedAgents.size}),f.disconnectedAgents.clear()),await c.swap(new Br,"connect switch").catch(()=>{})}w=Xt.deviceId,as({deviceId:w,pid:process.pid}),nd({patToken:ie,env:$.env}).catch(me=>K.warn("coze-cli setup error (ignored)",{err:String(me)}));let qr=new Yi({handshake:Xt,privatecode:ie,...ue?{urlOverride:ue}:{},ppeOverride:Ve,getPatTokenForAgent:me=>f.agents.get(me)?.patToken});return await c.swap(qr,"connect"),h=ie,_=vt,S=Ve,b=fe,$.mock_scenario!==void 0&&(f.setMockScenario($.mock_scenario),K.info("mock scenario set",{scenario:$.mock_scenario})),v||(v=new Oi({core:f,getDeviceId:()=>w??"",onTickEnd:()=>G.retryPending().catch(me=>K.warn("detailSync.retryPending failed (ignored)",{err:String(me)})),onAuthFailures:Y})),v.start(),y(),Bt&&Qo(t,x).catch(me=>K.warn("post-connect-switch auto-revive error (ignored)",{err:String(me)})),Ji(ie,t).catch(me=>K.warn("writePatToken after /connect failed (ignored)",{err:String(me)})),K.info("/connect: WS established",{deviceId:w}),{ok:!0,note:"connected"}}f.registerExtension("_agent/create",async O=>x.createAgent(O.params)),f.registerExtension("_agent/health",async()=>({ok:!0}));let D={},B=new oo({agents:f.agents,disposeAndMarkDisconnected:async(O,W)=>{let $=f.agents.get(O);if($){await x.cleanupOpenclawSessionProviders($).catch(Ve=>K.warn("cleanup openclaw providers failed (ignored)",{agentId:O,err:String(Ve)}));let ie=!0;try{await $.dispose(`disconnect: ${W}`)}catch(Ve){ie=!1,K.error("dispose during disconnect FAILED, leaving agent in error state",{agentId:O,err:String(Ve)}),$.status="error"}ie&&($.status="disconnected",f.unregister(O),f.disconnectedAgents.add(O))}else f.disconnectedAgents.add(O)},detailSyncer:async O=>{if(!D.ref)throw new Error("agent-detail-sync not initialized yet");await D.ref.syncOne(O)},cleanupOpenclawProviders:async O=>{await x.cleanupOpenclawSessionProviders(O)},openclawRepair:async(O,W)=>{await x.openclawRepair(O,W)},isRuntimePendingPermission:O=>f.hasPendingPermissionFor(O)});f.registerExtension("_agent/listSkills",O=>B.listSkills(O.params)),f.registerExtension("_agent/addSkills",O=>B.addSkills(O.params)),f.registerExtension("_agent/removeSkills",O=>B.removeSkills(O.params)),f.registerExtension("_agent/getFileTree",O=>B.getFileTree(O.params)),f.registerExtension("_agent/getFileContent",O=>B.getFileContent(O.params)),f.registerExtension("_agent/update",O=>B.updateAgent(O.params)),f.registerExtension("_agent/disconnect",O=>B.disconnectAgent(O.params)),f.registerExtension("_agent/switchModel",O=>B.switchModel(O.params)),f.registerExtension("_agent/reset",O=>B.resetAgent(O.params)),f.registerExtension("_agent/repair",O=>B.repairAgent(O.params));let G=new xs({paths:t,handlers:B,sendDetail:O=>f.sendRequest("_agent/detail",O)});D.ref=G;let Y=async O=>{await Promise.allSettled(O.map(async W=>{try{await B.disconnectAgent({agentId:W.agentId,reason:`auth_failure: code=${W.code} ${W.message}`}),K.info("agent disconnected due to auth failure from heartbeat response",{agentId:W.agentId,code:W.code,message:W.message})}catch($){K.warn("disconnect during authFailure handling failed (ignored)",{agentId:W.agentId,err:String($)})}}))};c.onConnect(({initial:O})=>{K.info("frontier upstream connected, triggering detail sync",{initial:O}),G.syncAll(O?"initial-connect":"reconnect").catch(W=>K.warn("detail sync top-level error (ignored)",{err:String(W)}))});let J=new So({paths:t,routes:[{method:"GET",path:"/status",handler:async()=>{let O=f.getMockScenario();return{running:!0,pid:process.pid,spawnedBy:process.env[Zi]==="1"?"manual":"supervisor",agents:[...f.agents.keys()],deviceId:w??"",frameworksCache:o.frameworksCache??{},...O?{mockScenario:O}:{}}}},{method:"POST",path:"/pair",handler:async O=>{let W=O,$=W?.privatecode,ie=W?.pairing_code;if(!$||!ie)throw new T("IPC_BAD_REQUEST","/pair requires privatecode + pairing_code");let Ve=Di(W.env),fe=W.handshake_url,ue=W.frontier_url,vt=Eh(W.env,fe,ue),ut=!!h&&h!==$,Zt=_!==void 0&&_!==vt,Bt=ut||Zt,Xt=await Fc({privatecode:$,...fe?{endpoint:fe}:{},ppeOverride:Ve});if(Bt){K.warn("pair config switched, resetting agents",{pcChanged:ut,envChanged:Zt,previousPc:h?Xo(h):"",nextPc:Xo($),previousEnvKey:_??"",nextEnvKey:vt});for(let Ae of[...f.agents.values()])await Ae.dispose("pair config switch").catch(()=>{}),f.agents.delete(Ae.agentId);f.disconnectedAgents.size>0&&(K.info("clearing disconnectedAgents set on pair config switch",{count:f.disconnectedAgents.size}),f.disconnectedAgents.clear()),await c.swap(new Br,"pair switch").catch(()=>{})}w=Xt.deviceId,as({deviceId:w,pid:process.pid}),nd({patToken:$,env:W.env}).catch(Ae=>K.warn("coze-cli setup error (ignored)",{err:String(Ae)}));let qr=new Yi({handshake:Xt,privatecode:$,...ue?{urlOverride:ue}:{},ppeOverride:Ve,getPatTokenForAgent:Ae=>f.agents.get(Ae)?.patToken});await c.swap(qr,"pair");try{let Ae=new Gn;o.frameworksCache=await Ae.detectAll(),await Fi(o),K.info("frameworks_cache refreshed before pair",{detected:Object.keys(o.frameworksCache)})}catch(Ae){K.warn("frameworks_cache refresh failed (ignored, using cached)",{err:String(Ae)})}let me=Object.keys(o.frameworksCache??{});try{let Ae=await f.sendRequest("_agent/pair",{pairCode:ie,patToken:$,frameworks:me,_meta:{cozeDeviceId:w}});K.info("_agent/pair ok",{pairResult:Ae}),h=$,_=vt,S=Ve,b=fe,W.mock_scenario!==void 0&&(f.setMockScenario(W.mock_scenario),K.info("mock scenario set",{scenario:W.mock_scenario})),Ji($,t).catch(De=>K.warn("writePatToken after /pair failed (ignored)",{err:String(De)})),v||(v=new Oi({core:f,getDeviceId:()=>w??"",onTickEnd:()=>G.retryPending().catch(De=>K.warn("detailSync.retryPending failed (ignored)",{err:String(De)})),onAuthFailures:Y})),v.start(),y(),Bt&&Qo(t,x).catch(De=>K.warn("post-pair-switch auto-revive error (ignored)",{err:String(De)}));let Vn;return W.agent_id&&(Vn=await Kv(W.agent_id,t,x,De=>f.sendRequest("_agent/detail",De),$).catch(De=>(K.error("--agent-id ensureAgent failed",{agentId:W.agent_id,err:String(De)}),{ok:!1,agentId:W.agent_id??"",note:String(De)}))),{ok:!0,note:"paired with cloud",...Vn?{agent:Vn}:{}}}catch(Ae){return K.error("_agent/pair failed",{err:String(Ae)}),{ok:!1,note:`pair failed: ${String(Ae)}`}}}},{method:"POST",path:"/connect",handler:O=>P(O)},{method:"POST",path:"/_agent/create",handler:async O=>{let W=O;return{ok:!0,result:await x.createAgent(W)}}},{method:"POST",path:"/agent/send",handler:async O=>{let W=O;if(!W?.agentId||!W?.sessionId||!W?.kind||!W?.path)throw new T("IPC_BAD_REQUEST","/agent/send requires agentId, sessionId, kind, path");if(!h)throw new T("UPSTREAM_NOT_READY","daemon not yet paired with cloud (run --pair-code first)");try{let $=W;return await($.groupFile?Du:Ru)($,{core:f,patToken:h,handshakeBase:b,ppeOverride:S})}catch($){if($ instanceof T)return{ok:!1,code:$.code,message:$.message};throw $}}},{method:"POST",path:"/reload",handler:async O=>{let W=O?.agent_id,$=await f.reloadAgents(W);return K.info("IPC /reload: recycled agent subprocesses",{agentId:W??"(all)",recycled:$}),{ok:!0,recycled:$}}},{method:"POST",path:"/shutdown",handler:async()=>(K.info("IPC /shutdown received"),setImmediate(()=>{he.shutdown("ipc /shutdown")}),{ok:!0})}]}),{port:te,token:Q}=await J.start();try{await gh(t.libEntry,t)}catch(O){K.warn("bin shim install failed (D72 send \u547D\u4EE4\u53EF\u80FD\u4E0D\u53EF\u7528)",{err:String(O)})}await f.start(),Qo(t,x).catch(O=>K.warn("auto-revive top-level error (ignored)",{err:String(O)})),wl().then(async()=>{let{probeAcpVersion:O}=await Promise.resolve().then(()=>(nn(),gl));for(let W of["claude-code","codex"]){let $=await O(W);$&&K.info("acp wrapper version",{framework:W,version:$})}}).catch(O=>K.warn("acp wrapper warmup / probe top-level error (ignored)",{err:String(O)}));let be=null,he={port:te,token:Q,core:f,ipc:J,shutdown(O){return be||(K.info("daemon shutdown",{reason:O}),be=(async()=>{v?.stop(),I?.stop(),await f.stop(O),await J.stop(),await e.release()})(),be)}};for(let O of["SIGTERM","SIGINT"])process.on(O,()=>{he.shutdown(O).then(()=>process.exit(0))});return process.on("exit",()=>su()),process.on("unhandledRejection",O=>{K.error("unhandledRejection",{reason:O instanceof Error?O.message:String(O),stack:O instanceof Error?O.stack:void 0})}),process.on("uncaughtException",O=>{K.error("uncaughtException (will exit, supervisor will restart)",{message:O.message,stack:O.stack,name:O.name});try{process.stderr.write(`FATAL uncaughtException: ${O.stack??O.message}
|
|
106
|
-
`)}catch{}process.exit(1)}),
|
|
107
|
-
`;await
|
|
108
|
-
`).filter(l=>l.length>0).filter(l=>
|
|
109
|
-
`)}async function
|
|
110
|
-
`),1;for(let
|
|
111
|
-
`);return 0}let o=t.date??
|
|
105
|
+
`}async function ux(t,e=Y()){let r=e.binDir;await Ho.mkdir(r,{recursive:!0});let i=Cv(r,process.platform==="win32"?"coze-bridge.cmd":"coze-bridge"),o=process.execPath,c=process.platform==="win32"?kv(t,o):Dv(t,o);return await Ho.readFile(i,"utf8").catch(()=>null)===c||(await Ho.writeFile(i,c,"utf8"),process.platform!=="win32"&&await Ho.chmod(i,493)),r}ne();Le();import{execSync as fx}from"node:child_process";import{readFileSync as hx,unlinkSync as Pv}from"node:fs";import{mkdir as Lv,readFile as xx,unlink as px,writeFile as Ov}from"node:fs/promises";import{dirname as Nv}from"node:path";var Mv=G("single-instance"),jo=class{pidFile;acquired=!1;constructor(e={}){this.pidFile=e.pidFile??Y().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&&(Mv.warn("removing stale pid file",{stalePid:e}),await px(this.pidFile).catch(()=>{})),await Lv(Nv(this.pidFile),{recursive:!0}),await Ov(this.pidFile,String(process.pid),"utf8"),this.acquired=!0,this.installCleanupHooks(),{kind:"acquired"})}async release(){if(this.acquired){try{(await xx(this.pidFile,"utf8")).trim()===String(process.pid)&&await px(this.pidFile)}catch{}this.acquired=!1}}async readExistingPid(){try{let e=await xx(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 so(e)?this.matchesDaemonTitle(e):!1}matchesDaemonTitle(e){if(process.platform==="win32")return this.matchesDaemonTitleWindows(e);try{let r=hx(`/proc/${e}/cmdline`,"utf8").replace(/\0/g," ");return!!(r.includes("coze-bridge-daemon")||r.includes("lib/index.js"))}catch{}try{let r=fx(`ps -o command= -p ${e}`,{stdio:["ignore","pipe","ignore"],timeout:1e3}).toString();return r.trim()?r.includes("coze-bridge-daemon")||r.includes("lib/index.js"):!1}catch{return!0}}matchesDaemonTitleWindows(e){try{let i=fx(`tasklist /FI "PID eq ${e}" /FO CSV /NH`,{stdio:["ignore","pipe","ignore"],timeout:2e3}).toString().trim();if(!i||/^(INFO|信息)[::]/.test(i))return!1;let o=i.split(",",1)[0]?.replace(/^"|"$/g,"").toLowerCase()??"";return o.includes("node")||o.includes("coze-bridge")}catch{return!0}}installCleanupHooks(){process.once("exit",()=>{if(this.acquired)try{hx(this.pidFile,"utf8").trim()===String(process.pid)&&Pv(this.pidFile)}catch{}})}};Wo();ne();var $n=G("daemon.upstream-watchdog"),jv=12e4,Wv=9e5,Kv=3e4;function Td(t,e){let r=process.env[t];if(!r)return e;let i=Number(r);return Number.isFinite(i)&&i>0?i:e}var Ko=class{constructor(e){this.opts=e;this.softMs=e.softMs??Td("COZE_BRIDGE_UPSTREAM_WATCHDOG_SOFT_MS",jv),this.hardMs=e.hardMs??Td("COZE_BRIDGE_UPSTREAM_WATCHDOG_HARD_MS",Wv),this.intervalMs=e.intervalMs??Td("COZE_BRIDGE_UPSTREAM_WATCHDOG_INTERVAL_MS",Kv),this.now=e.now??Date.now}opts;softMs;hardMs;intervalMs;now;timer=null;downSince=null;forcedAt=null;forcing=!1;lastTickAt=null;start(){this.timer||(this.timer=setInterval(()=>this.tick(),this.intervalMs),this.timer.unref?.(),$n.info("upstream watchdog started",{softMs:this.softMs,hardMs:this.hardMs,intervalMs:this.intervalMs}))}stop(){this.timer&&(clearInterval(this.timer),this.timer=null),this.downSince=null,this.forcedAt=null,this.lastTickAt=null}tick(){let e=this.now();if(this.lastTickAt!==null&&e-this.lastTickAt>this.intervalMs*3&&(this.downSince!==null&&$n.warn("upstream watchdog: large tick gap (likely sleep/suspend), resetting downSince",{gapMs:e-this.lastTickAt}),this.downSince=null,this.forcedAt=null),this.lastTickAt=e,this.opts.isConnected()){this.downSince!==null&&$n.info("upstream watchdog: reconnected, reset",{downMs:this.now()-this.downSince}),this.downSince=null,this.forcedAt=null;return}if(this.downSince===null){this.downSince=e,$n.warn("upstream watchdog: disconnect detected, arming",{softMs:this.softMs,hardMs:this.hardMs});return}let r=e-this.downSince;if(r>=this.hardMs){$n.error("upstream watchdog: disconnected too long, exiting for supervisor restart",{downMs:r,hardMs:this.hardMs}),this.opts.onFatal(r);return}r>=this.softMs&&this.shouldForceNow(e)&&(this.forcedAt=e,this.forcing=!0,$n.warn("upstream watchdog: forcing reconnect",{downMs:r,softMs:this.softMs}),Promise.resolve().then(()=>this.opts.forceReconnect()).catch(i=>$n.warn("upstream watchdog: forceReconnect error (ignored)",{err:String(i)})).finally(()=>{this.forcing=!1}))}shouldForceNow(e){return!(this.forcing||this.forcedAt!==null&&e-this.forcedAt<this.softMs)}};var j=G("daemon"),$v="coze-bridge-daemon";async function _x(){let t=Y();process.env.COZE_BRIDGE_LOG_MODE!=="legacy"&&il({bridgeLogsDir:t.bridgeLogsDir,agentLogsDir:P=>Xe(P,t).logs,listAgentIds:()=>ss(t)});let e=new jo({processTitle:$v}),r=await e.acquire();if(r.kind==="already-running")throw new Error(`coze-bridge daemon already running (pid=${r.pid})`);let i=await mo(),o=i??{};rs({pid:process.pid}),j.info(i?"loaded bridge config":"initialized bridge config");try{let P=new Gn;o.frameworksCache=await P.detectAll(),j.info("refreshed frameworks_cache",{detected:Object.keys(o.frameworksCache)})}catch(P){j.warn("framework detection failed",{err:String(P)})}await Bi(o);let c=new Go(new Br),l=null,u=new wo({upstream:c,paths:t,bridgeConfig:o,sessionSpawner:async(P,H,W,ie)=>{if(!l)throw new Error("agentManager not ready");return l.spawnSessionDownstream(P,H,W,ie)}});await Zv(t,u);let h=new xo({paths:t,config:o,registry:u});l=h;let x,w,E=null,I={},b,v=null,A=null,S=null,R=new bn;function O(P,H){return R.enqueue(()=>C(P,H))}function _(){A||(A=new Ko({isConnected:()=>c.isConnected(),forceReconnect:()=>S?O(S,{force:!0}):void 0,onFatal:P=>{if(process.env[Ji]==="1"){j.error("upstream watchdog fatal, but daemon is unmanaged (CLI-spawned) \u2014 staying alive for soft-reconnect instead of exiting",{downMs:P});return}j.error("upstream watchdog fatal: exiting for supervisor restart",{downMs:P}),process.exit(1)}})),A.start()}async function C(P,H){let W=P,ie=W?.privatecode;if(!ie)throw new T("IPC_BAD_REQUEST","/connect requires privatecode");let Ve=Ci(W.env),fe=W.handshake_url,he=W.frontier_url,It=mx(W.env,fe,he);if(S=W,!H?.force&&x===ie&&w===It){let we=await Vv(t);return u.agents.size===0&&we?(j.warn("/connect noop but core.agents empty with configs on disk; re-running auto-revive"),Vo(t,h).catch(Te=>j.warn("connect-noop auto-revive error (ignored)",{err:String(Te)}))):j.info("/connect: already connected with same PAT + env, noop"),{ok:!0,note:"already connected"}}let xt=!!x&&x!==ie,Xt=w!==void 0&&w!==It,Ft=xt||Xt,Qt=await Lc({privatecode:ie,...fe?{endpoint:fe}:{},ppeOverride:Ve});if(Ft){j.warn("connect config switched, resetting agents",{pcChanged:xt,envChanged:Xt,previousPc:x?$o(x):"",nextPc:$o(ie)});for(let we of[...u.agents.values()])await we.dispose("connect config switch").catch(()=>{}),u.agents.delete(we.agentId);u.disconnectedAgents.size>0&&(j.info("clearing disconnectedAgents set on connect config switch",{count:u.disconnectedAgents.size}),u.disconnectedAgents.clear()),await c.swap(new Br,"connect switch").catch(()=>{})}E=Qt.deviceId,rs({deviceId:E,pid:process.pid}),Yc({patToken:ie,env:W.env}).catch(we=>j.warn("coze-cli setup error (ignored)",{err:String(we)}));let qr=new Vi({handshake:Qt,privatecode:ie,...he?{urlOverride:he}:{},ppeOverride:Ve,getPatTokenForAgent:we=>u.agents.get(we)?.patToken});return await c.swap(qr,"connect"),x=ie,w=It,I=Ve,b=fe,W.mock_scenario!==void 0&&(u.setMockScenario(W.mock_scenario),j.info("mock scenario set",{scenario:W.mock_scenario})),v||(v=new ki({core:u,getDeviceId:()=>E??"",onTickEnd:()=>B.retryPending().catch(we=>j.warn("detailSync.retryPending failed (ignored)",{err:String(we)})),onAuthFailures:V})),v.start(),_(),Ft&&Vo(t,h).catch(we=>j.warn("post-connect-switch auto-revive error (ignored)",{err:String(we)})),Zi(ie,t).catch(we=>j.warn("writePatToken after /connect failed (ignored)",{err:String(we)})),j.info("/connect: WS established",{deviceId:E}),{ok:!0,note:"connected"}}u.registerExtension("_agent/create",async P=>h.createAgent(P.params)),u.registerExtension("_agent/health",async()=>({ok:!0}));let D={},M=new to({agents:u.agents,disposeAndMarkDisconnected:async(P,H)=>{let W=u.agents.get(P);if(W){await h.cleanupOpenclawSessionProviders(W).catch(Ve=>j.warn("cleanup openclaw providers failed (ignored)",{agentId:P,err:String(Ve)}));let ie=!0;try{await W.dispose(`disconnect: ${H}`)}catch(Ve){ie=!1,j.error("dispose during disconnect FAILED, leaving agent in error state",{agentId:P,err:String(Ve)}),W.status="error"}ie&&(W.status="disconnected",u.unregister(P),u.disconnectedAgents.add(P))}else u.disconnectedAgents.add(P)},detailSyncer:async P=>{if(!D.ref)throw new Error("agent-detail-sync not initialized yet");await D.ref.syncOne(P)},cleanupOpenclawProviders:async P=>{await h.cleanupOpenclawSessionProviders(P)},openclawRepair:async(P,H)=>{await h.openclawRepair(P,H)},isRuntimePendingPermission:P=>u.hasPendingPermissionFor(P)});u.registerExtension("_agent/listSkills",P=>M.listSkills(P.params)),u.registerExtension("_agent/addSkills",P=>M.addSkills(P.params)),u.registerExtension("_agent/removeSkills",P=>M.removeSkills(P.params)),u.registerExtension("_agent/getFileTree",P=>M.getFileTree(P.params)),u.registerExtension("_agent/getFileContent",P=>M.getFileContent(P.params)),u.registerExtension("_agent/update",P=>M.updateAgent(P.params)),u.registerExtension("_agent/disconnect",P=>M.disconnectAgent(P.params)),u.registerExtension("_agent/switchModel",P=>M.switchModel(P.params)),u.registerExtension("_agent/reset",P=>M.resetAgent(P.params)),u.registerExtension("_agent/repair",P=>M.repairAgent(P.params)),u.registerExtension("_agent/upgrade",P=>M.upgradeBridge(P.params));let B=new ds({paths:t,handlers:M,sendDetail:P=>u.sendRequest("_agent/detail",P)});D.ref=B;let V=async P=>{await Promise.allSettled(P.map(async H=>{try{await M.disconnectAgent({agentId:H.agentId,reason:`auth_failure: code=${H.code} ${H.message}`}),j.info("agent disconnected due to auth failure from heartbeat response",{agentId:H.agentId,code:H.code,message:H.message})}catch(W){j.warn("disconnect during authFailure handling failed (ignored)",{agentId:H.agentId,err:String(W)})}}))};c.onConnect(({initial:P})=>{j.info("frontier upstream connected, triggering detail sync",{initial:P}),B.syncAll(P?"initial-connect":"reconnect").catch(H=>j.warn("detail sync top-level error (ignored)",{err:String(H)}))});let Z=new _o({paths:t,routes:[{method:"GET",path:"/status",handler:async()=>{let P=u.getMockScenario();return{running:!0,pid:process.pid,spawnedBy:process.env[Ji]==="1"?"manual":"supervisor",agents:[...u.agents.keys()],deviceId:E??"",frameworksCache:o.frameworksCache??{},...P?{mockScenario:P}:{}}}},{method:"POST",path:"/pair",handler:async P=>{let H=P,W=H?.privatecode,ie=H?.pairing_code;if(!W||!ie)throw new T("IPC_BAD_REQUEST","/pair requires privatecode + pairing_code");let Ve=Ci(H.env),fe=H.handshake_url,he=H.frontier_url,It=mx(H.env,fe,he),xt=!!x&&x!==W,Xt=w!==void 0&&w!==It,Ft=xt||Xt,Qt=await Lc({privatecode:W,...fe?{endpoint:fe}:{},ppeOverride:Ve});if(Ft){j.warn("pair config switched, resetting agents",{pcChanged:xt,envChanged:Xt,previousPc:x?$o(x):"",nextPc:$o(W),previousEnvKey:w??"",nextEnvKey:It});for(let Te of[...u.agents.values()])await Te.dispose("pair config switch").catch(()=>{}),u.agents.delete(Te.agentId);u.disconnectedAgents.size>0&&(j.info("clearing disconnectedAgents set on pair config switch",{count:u.disconnectedAgents.size}),u.disconnectedAgents.clear()),await c.swap(new Br,"pair switch").catch(()=>{})}E=Qt.deviceId,rs({deviceId:E,pid:process.pid}),Yc({patToken:W,env:H.env}).catch(Te=>j.warn("coze-cli setup error (ignored)",{err:String(Te)}));let qr=new Vi({handshake:Qt,privatecode:W,...he?{urlOverride:he}:{},ppeOverride:Ve,getPatTokenForAgent:Te=>u.agents.get(Te)?.patToken});await c.swap(qr,"pair");try{let Te=new Gn;o.frameworksCache=await Te.detectAll(),await Bi(o),j.info("frameworks_cache refreshed before pair",{detected:Object.keys(o.frameworksCache)})}catch(Te){j.warn("frameworks_cache refresh failed (ignored, using cached)",{err:String(Te)})}let we=Object.keys(o.frameworksCache??{});try{let Te=await u.sendRequest("_agent/pair",{pairCode:ie,patToken:W,frameworks:we,_meta:{cozeDeviceId:E}});j.info("_agent/pair ok",{pairResult:Te}),x=W,w=It,I=Ve,b=fe,H.mock_scenario!==void 0&&(u.setMockScenario(H.mock_scenario),j.info("mock scenario set",{scenario:H.mock_scenario})),Zi(W,t).catch(Pe=>j.warn("writePatToken after /pair failed (ignored)",{err:String(Pe)})),v||(v=new ki({core:u,getDeviceId:()=>E??"",onTickEnd:()=>B.retryPending().catch(Pe=>j.warn("detailSync.retryPending failed (ignored)",{err:String(Pe)})),onAuthFailures:V})),v.start(),_(),Ft&&Vo(t,h).catch(Pe=>j.warn("post-pair-switch auto-revive error (ignored)",{err:String(Pe)}));let Vn;return H.agent_id&&(Vn=await Jv(H.agent_id,t,h,Pe=>u.sendRequest("_agent/detail",Pe),W).catch(Pe=>(j.error("--agent-id ensureAgent failed",{agentId:H.agent_id,err:String(Pe)}),{ok:!1,agentId:H.agent_id??"",note:String(Pe)}))),{ok:!0,note:"paired with cloud",...Vn?{agent:Vn}:{}}}catch(Te){return j.error("_agent/pair failed",{err:String(Te)}),{ok:!1,note:`pair failed: ${String(Te)}`}}}},{method:"POST",path:"/connect",handler:P=>O(P)},{method:"POST",path:"/_agent/create",handler:async P=>{let H=P;return{ok:!0,result:await h.createAgent(H)}}},{method:"POST",path:"/agent/send",handler:async P=>{let H=P;if(!H?.agentId||!H?.sessionId||!H?.kind||!H?.path)throw new T("IPC_BAD_REQUEST","/agent/send requires agentId, sessionId, kind, path");if(!x)throw new T("UPSTREAM_NOT_READY","daemon not yet paired with cloud (run --pair-code first)");try{let W=H;return await(W.groupFile?A0:I0)(W,{core:u,patToken:x,handshakeBase:b,ppeOverride:I})}catch(W){if(W instanceof T)return{ok:!1,code:W.code,message:W.message};throw W}}},{method:"POST",path:"/reload",handler:async P=>{let H=P?.agent_id,W=await u.reloadAgents(H);return j.info("IPC /reload: recycled agent subprocesses",{agentId:H??"(all)",recycled:W}),{ok:!0,recycled:W}}},{method:"POST",path:"/shutdown",handler:async()=>(j.info("IPC /shutdown received"),setImmediate(()=>{pe.shutdown("ipc /shutdown")}),{ok:!0})}]}),{port:ee,token:X}=await Z.start();try{await ux(t.libEntry,t)}catch(P){j.warn("bin shim install failed (D72 send \u547D\u4EE4\u53EF\u80FD\u4E0D\u53EF\u7528)",{err:String(P)})}await u.start(),Vo(t,h).catch(P=>j.warn("auto-revive top-level error (ignored)",{err:String(P)})),xl().then(async()=>{let{probeAcpVersion:P}=await Promise.resolve().then(()=>(nn(),fl));for(let H of["claude-code","codex"]){let W=await P(H);W&&j.info("acp wrapper version",{framework:H,version:W})}}).catch(P=>j.warn("acp wrapper warmup / probe top-level error (ignored)",{err:String(P)}));let Ee=null,pe={port:ee,token:X,core:u,ipc:Z,shutdown(P){return Ee||(j.info("daemon shutdown",{reason:P}),Ee=(async()=>{v?.stop(),A?.stop(),await u.stop(P),await Z.stop(),await e.release()})(),Ee)}};for(let P of["SIGTERM","SIGINT"])process.on(P,()=>{pe.shutdown(P).then(()=>process.exit(0))});return process.on("exit",()=>t0()),process.on("unhandledRejection",P=>{j.error("unhandledRejection",{reason:P instanceof Error?P.message:String(P),stack:P instanceof Error?P.stack:void 0})}),process.on("uncaughtException",P=>{j.error("uncaughtException (will exit, supervisor will restart)",{message:P.message,stack:P.stack,name:P.name});try{process.stderr.write(`FATAL uncaughtException: ${P.stack??P.message}
|
|
106
|
+
`)}catch{}process.exit(1)}),j.info("daemon ready",{port:ee,pid:process.pid,nodeVersion:process.version,platform:process.platform,frameworks:Object.keys(o.frameworksCache??{}),libVersion:o.libVersion??"dev"}),Yv({cliSpawned:process.env[Ji]==="1",readPatToken:()=>qo(t),connect:O}).catch(P=>j.warn("maybeAutoConnectOnStartup error (ignored)",{err:String(P)})),pe}async function Vv(t){return ss(t).length>0}function $o(t){return t.length<=8?"***":`${t.slice(0,4)}***${t.slice(-4)}`}function mx(t,e,r){return`${t??""}|${e??""}|${r??""}`}async function Zv(t,e){let r=ss(t);if(r.length===0)return;let{loadAgentConfig:i,enforceAgentConfigMode:o}=await Promise.resolve().then(()=>(rn(),cs));for(let c of r){await o(c,t).catch(l=>j.warn("enforceAgentConfigMode failed (ignored)",{agentId:c,err:String(l)}));try{let l=await i(c,t);l?.disconnectedAt&&(e.disconnectedAgents.add(c),j.info("agent marked disconnected on startup",{agentId:c,disconnectedAt:l.disconnectedAt,reason:l.disconnectReason??""}))}catch(l){j.warn("failed to load agent config on startup, skipping",{agentId:c,err:String(l)})}}}async function Jv(t,e,r,i,o){let{loadAgentConfig:c}=await Promise.resolve().then(()=>(rn(),cs)),l=await c(t,e);if(l){j.info("--agent-id: local config found, reconnecting",{agentId:t,framework:l.framework,hadDisconnect:!!l.disconnectedAt});let w={agentId:l.agentId,framework:l.framework,...l.cozeIdentity?{cozeIdentity:l.cozeIdentity}:{},...l.model?{model:l.model}:{},...o?{patToken:o}:{}};return await r.createAgent(w),{ok:!0,agentId:t,note:l.disconnectedAt?"revived from local config":"connected from local config"}}j.info("--agent-id: local config missing, pulling _agent/detail from cloud",{agentId:t});let u=await i({_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 h={agentId:u.agentId,framework:u.framework,...u.cozeIdentity?{cozeIdentity:u.cozeIdentity}:{},...u.model?{model:u.model}:{},...o?{patToken:o}:{},...u.deployType?{_meta:{cozeDeployType:u.deployType}}:{}};await r.createAgent(h);let x=u.deployType==="cloud"&&u.framework==="openclaw";return{ok:!0,agentId:t,note:x?"cloud agent acknowledged":"created from cloud detail"}}async function Vo(t,e){let{readdir:r}=await import("node:fs/promises"),i;try{i=await r(t.agentsRoot)}catch{return{revived:0,skipped:0,total:0}}if(i.length===0)return{revived:0,skipped:0,total:0};let{loadAgentConfig:o}=await Promise.resolve().then(()=>(rn(),cs));j.info("auto-revive: scanning local agents on startup",{count:i.length});let c=0,l=0;for(let u of i){let h;try{h=await o(u,t)}catch(x){j.warn("auto-revive: load config failed (skipping)",{agentId:u,err:String(x)}),l+=1;continue}if(!h){l+=1;continue}if(h.disconnectedAt){j.info("auto-revive: skip disconnected agent",{agentId:u,disconnectedAt:h.disconnectedAt}),l+=1;continue}try{j.info("auto-revive: re-registering agent (D44 no spawn)",{agentId:u,framework:h.framework});let x=Xv(h);await e.createAgent({agentId:h.agentId,framework:h.framework,...h.cozeIdentity?{cozeIdentity:h.cozeIdentity}:{},...h.model?{model:h.model}:{},...x?{_meta:x}:{}},{revive:!0}),c+=1}catch(x){j.warn("auto-revive: createAgent failed (skipping)",{agentId:u,framework:h.framework,err:String(x)}),l+=1}}return j.info("auto-revive: done",{revived:c,skipped:l,total:i.length}),{revived:c,skipped:l,total:i.length}}async function Yv(t){let e=t.logger??j;if(t.cliSpawned)return"skipped-cli";let r=await t.readPatToken();return r?(e.info("supervisor-spawned daemon, auto-connecting with stored PAT"),t.connect({privatecode:r}).catch(i=>e.warn("startup auto-connect failed (staying idle)",{err:String(i)})),"connecting"):(e.info("no stored PAT, skip startup auto-connect"),"skipped-no-pat")}function Xv(t){let e={};return t.deployType&&(e.cozeDeployType=t.deployType),t.accountId&&(e.cozeAccountId=t.accountId),Object.keys(e).length>0?e:void 0}Wo();Le();import{readFile as yx}from"node:fs/promises";var Yt=class{paths;constructor(e){this.paths=e??Y()}async probe(e=1e3){let r=await Zo(this.paths);if(!r)return{kind:"not-running"};try{let i=await this.fetch(r,{method:"GET",path:"/status",timeoutMs:e});return i.status===200?{kind:"connected",...r}:{kind:"stale",reason:`unexpected status ${i.status}`}}catch(i){return{kind:"stale",reason:e1(i)}}}async request(e){let r=await Zo(this.paths);if(!r)throw new Error("coze-bridge daemon not running (no port/token files)");return this.fetch(r,e)}async fetch(e,r){let i=r.body!==void 0,o={Authorization:`Bearer ${e.token}`};i&&(o["content-type"]="application/json");let c=new AbortController,l=setTimeout(()=>c.abort(),r.timeoutMs??5e3);try{let u=await fetch(`http://127.0.0.1:${e.port}${r.path}`,{method:r.method,headers:o,body:i?JSON.stringify(r.body):void 0,signal:c.signal}),h=await u.text();return{status:u.status,body:Qv(h)}}finally{clearTimeout(l)}}};async function Zo(t){try{let[e,r]=await Promise.all([yx(t.portFile,"utf8"),yx(t.tokenFile,"utf8")]),i=Number.parseInt(e.trim(),10),o=r.trim();return!Number.isFinite(i)||i<=0||!o?null:{port:i,token:o}}catch(e){if(e.code==="ENOENT")return null;throw e}}function Qv(t){if(!t)return null;try{return JSON.parse(t)}catch{return t}}function e1(t){return t instanceof Error?t.message:String(t)}Kt();ne();Le();function Sn(t,...e){let r=[],i;for(let o=0;o<t.length;o++){let c=t[o],l=!1;for(let u of e){if(c===u){i=t[o+1],o+=1,l=!0;break}if(c.startsWith(`${u}=`)){i=c.slice(u.length+1),l=!0;break}}l||r.push(c)}return{value:i,rest:r}}nn();import{chmod as t1,copyFile as bx,mkdir as vx,readFile as Jo,rename as Ex,rm as Rd,stat as Sx,writeFile as n1}from"node:fs/promises";import{homedir as FC}from"node:os";import{dirname as r1,join as zr,resolve as Cd,sep as Yi}from"node:path";import{fileURLToPath as i1}from"node:url";Kt();ne();Le();var Dd=G("dist-install");function s1(t){let e=i1(t),r=r1(e),i=`${Yi}src${Yi}`;if(r.includes(i)||r.endsWith(`${Yi}src${Yi}cli`))return null;let o=Cd(r,"index.js"),c=Cd(r,"..","package.json");return{dist:o,pkgJson:c}}async function Pd(t={}){let e=t.paths??Y(),r=s1(import.meta.url),i=t.sourceDist??r?.dist,o=t.sourcePackageJson??r?.pkgJson;if(!i||!o)return{kind:"dev-mode-skip",reason:"running from src/(tsx loader);no dist/ to install"};if(i===e.libEntry)return{kind:"dev-mode-skip",reason:"running from installed lib path; no re-install needed"};let c,l;try{let I=JSON.parse(await Jo(o,"utf8"));c=I.version??"unknown",l=I.dependencies??{}}catch(I){return Dd.warn("cannot read source package.json,skip dist install",{err:String(I)}),{kind:"dev-mode-skip",reason:`package.json read failed: ${String(I)}`}}let u=Zr.map(I=>`${I}@${l[I]??"latest"}`),h=await mo(e.configFile)??{},x=h.libVersion,w=await Jo(e.libEntry).then(()=>!0).catch(()=>!1),E=x===c;if(E&&w&&await kd(e))return{kind:"already-current",libVersion:c};if(!E||!w){await vx(e.libDir,{recursive:!0}),await bx(i,e.libEntry),await bx(`${i}.map`,`${e.libEntry}.map`).catch(()=>{});let I=Cd(e.libDir,"package.json"),b=`${JSON.stringify({type:"module"},null,2)}
|
|
107
|
+
`;await Jo(I,"utf8").catch(()=>null)!==b&&await n1(I,b)}return(!E||!await kd(e))&&await(t.installWrappers??o1)(e,u),h.libVersion=c,await Bi(h,e.configFile),Dd.info("dist installed",{libEntry:e.libEntry,fromVersion:x,toVersion:c}),E&&w?{kind:"already-current",libVersion:c}:x?{kind:"version-changed",fromVersion:x,toVersion:c,libEntry:e.libEntry}:{kind:"first-install",libVersion:c,libEntry:e.libEntry}}async function kd(t){for(let e of Zr){let r=zr(t.libDir,"node_modules",...e.split("/"),"package.json");if(!await Sx(r).then(o=>o.isFile()).catch(()=>!1))return!1}return!0}async function o1(t,e){await d1(t.installLock,async()=>{if(await kd(t))return;let r=Math.random().toString(36).slice(2,10),i=`${t.libDir}${Yi}.staging-${process.pid}-${r}`,o=zr(i,"node_modules"),c=zr(t.libDir,"node_modules");try{await vx(i,{recursive:!0}),await a1(e,i),await c1(o);let l=`${c}.trash-${r}`;await Ex(c,l).catch(()=>{}),await Ex(o,c),await Rd(l,{recursive:!0,force:!0}).catch(()=>{}),Dd.info("wrapper closure installed",{liveNm:c,specs:e})}finally{await Rd(i,{recursive:!0,force:!0}).catch(()=>{})}})}function a1(t,e){let r=["install",...t,"--prefix",e,"--omit=dev","--prefer-offline","--no-audit","--no-fund"];return new Promise((i,o)=>{let c=nt("npm",r,{stdio:["ignore","pipe","pipe"]}),l="";c.stderr?.on("data",h=>{l.length<8192&&(l+=h.toString("utf8"))});let u=setTimeout(()=>c.kill("SIGKILL"),18e4);c.once("error",h=>{clearTimeout(u),o(new Error(`spawn npm failed: ${String(h)}`))}),c.once("close",h=>{clearTimeout(u),h===0?i():o(new Error(`npm install \u9000\u51FA\u7801 ${h}: ${l.trim().slice(0,2e3)}`))})})}async function c1(t){for(let e of Zr){let r=zr(t,...e.split("/")),i=JSON.parse(await Jo(zr(r,"package.json"),"utf8"));if(!i.version)throw new Error(`${e}: package.json \u7F3A version`);let o=typeof i.bin=="string"?e.split("/").pop():Object.keys(i.bin??{})[0];if(!o)throw new Error(`${e}: package.json \u7F3A bin`);let c=zr(t,".bin",o),l=await Sx(c);process.platform!=="win32"&&!(l.mode&73)&&await t1(c,l.mode|73).catch(()=>{})}}async function d1(t,e){let{open:r}=await import("node:fs/promises"),i=!1;for(let o=0;o<60&&!i;o++)try{await(await r(t,"wx")).close(),i=!0}catch{await new Promise(c=>setTimeout(c,500))}try{return await e()}finally{i&&await Rd(t,{force:!0}).catch(()=>{})}}wa();ne();Le();import{closeSync as Ax,fstatSync as Tx,openSync as Rx,readFileSync as l1,readSync as u1,readdirSync as f1,statSync as h1}from"node:fs";import{join as Yo}from"node:path";var x1=new Set(["debug","info","warn","error"]);function Cx(t){let e=t,r=Sn(e,"--agent-id");e=r.rest;let i=Sn(e,"--date");e=i.rest;let o=Sn(e,"-n","--lines");e=o.rest;let c=Sn(e,"--level");e=c.rest;let l=Sn(e,"--grep");e=l.rest;let u=o.value===void 0?200:Number(o.value),h=Number.isInteger(u)&&u>=0?u:200,x=c.value&&x1.has(c.value)?c.value:void 0,w={lines:h,follow:e.includes("-f")||e.includes("--follow"),raw:e.includes("--raw"),list:e.includes("--list")};return r.value&&(w.agentId=r.value),i.value&&(w.date=i.value),x&&(w.level=x),l.value&&(w.grep=l.value),w}function p1(t,e){return t.agentId?Yo(Xe(t.agentId,e).logs,Xn("agent",t.date)):Yo(e.bridgeLogsDir,Xn("bridge",t.date))}function g1(t,e){return e<=0||e>=t.length?t:t.slice(t.length-e)}function m1(t,e){let r;try{r=f1(t)}catch{return[]}let i=[];for(let o of r){let c=ma(o,e);if(!c)continue;let l=0;try{l=h1(Yo(t,o)).size}catch{}i.push({file:Yo(t,o),date:c,size:l})}return i.sort((o,c)=>c.date.localeCompare(o.date)),i}function Dx(t,e){if(e.grep&&!t.includes(e.grep))return!1;if(e.level){let r;try{r=JSON.parse(t).level}catch{return!0}if(typeof r=="string"&&!al(r,e.level))return!1}return!0}var Ix={debug:"90",info:"36",warn:"33",error:"31"},w1=new Set(["ts","level","module","msg"]);function _1(t){if(typeof t!="string")return"";let e=t.split("T")[1];return e?e.slice(0,12):""}function kx(t,e){if(e.raw)return t;let r;try{r=JSON.parse(t)}catch{return t}let i=_1(r.ts),o=typeof r.level=="string"?r.level:"",c=o.toUpperCase().padEnd(5);e.color&&Ix[o]&&(c=`\x1B[${Ix[o]}m${c}\x1B[0m`);let l=typeof r.module=="string"?r.module:"",u=typeof r.msg=="string"?r.msg:"",h=Object.entries(r).filter(([x])=>!w1.has(x)).map(([x,w])=>` ${x}=${typeof w=="string"?w:JSON.stringify(w)}`).join("");return`${i} ${c} ${l} ${u}${h}`}function y1(t,e,r){let c=l1(t,"utf8").split(`
|
|
108
|
+
`).filter(l=>l.length>0).filter(l=>Dx(l,{level:e.level,grep:e.grep}));for(let l of g1(c,e.lines))process.stdout.write(`${kx(l,{raw:e.raw,color:r})}
|
|
109
|
+
`)}async function Px(t,e){let r=e.paths??Y(),i=process.stdout.isTTY===!0;if(t.list){let l=t.agentId?Xe(t.agentId,r).logs:r.bridgeLogsDir,u=t.agentId?"agent":"bridge",h=m1(l,u);if(h.length===0)return process.stderr.write(`coze-bridge log: \u65E0\u65E5\u5FD7\u6587\u4EF6\u4E8E ${l}
|
|
110
|
+
`),1;for(let x of h)process.stdout.write(`${x.date} ${(x.size/1024).toFixed(1)}KB ${x.file}
|
|
111
|
+
`);return 0}let o=t.date??An(new Date),c=p1({agentId:t.agentId,date:o},r);try{y1(c,t,i)}catch{return process.stderr.write(`coze-bridge log: \u627E\u4E0D\u5230\u65E5\u5FD7 ${c}
|
|
112
112
|
\u7528 'coze-bridge log${t.agentId?` --agent-id ${t.agentId}`:""} --list' \u770B\u6709\u54EA\u4E9B\u65E5\u671F\u3002
|
|
113
113
|
(legacy \u6A21\u5F0F\u65E0 dated \u6587\u4EF6, \u89C1 ${r.logFile})
|
|
114
|
-
`),1}return t.follow&&await
|
|
115
|
-
`);o=
|
|
116
|
-
`)}await new Promise(
|
|
114
|
+
`),1}return t.follow&&await v1(c,t,i),0}var b1=500;function E1(t){try{let e=Rx(t,"r");try{return Tx(e).size}finally{Ax(e)}}catch{return 0}}async function v1(t,e,r){let i=E1(t),o="",c=!1,l=()=>{c=!0};process.on("SIGINT",l);try{for(;!c;){let u="";try{let h=Rx(t,"r");try{let x=Tx(h).size;if(x>i){let w=Buffer.allocUnsafe(x-i),E=u1(h,w,0,w.length,i);u=w.subarray(0,E).toString("utf8"),i+=E}}finally{Ax(h)}}catch{}if(u){let h=(o+u).split(`
|
|
115
|
+
`);o=h.pop()??"";for(let x of h)x.length>0&&Dx(x,{level:e.level,grep:e.grep})&&process.stdout.write(`${kx(x,{raw:e.raw,color:r})}
|
|
116
|
+
`)}await new Promise(h=>setTimeout(h,b1))}}finally{process.off("SIGINT",l)}}import{basename as S1,resolve as I1}from"node:path";Le();var A1=9e4,T1={PATH_OUTSIDE_WORKSPACE:3,FILE_TOO_LARGE:3,UNSUPPORTED_MIME:3,MODEL_MODALITY_UNSUPPORTED:3,IPC_BAD_REQUEST:3,AGENT_NOT_FOUND:4,IPC_AUTH_FAILED:4,AGENT_DISCONNECTED:5,UPLOAD_FAILED:5,UPSTREAM_NOT_READY:5,UPSTREAM_DISCONNECTED:5,UPSTREAM_HANDSHAKE_FAILED:5,AGENT_BUSY:1,AGENT_SPAWN_FAILED:1,AGENT_TIMEOUT:1,AGENT_FRAME_IDLE_TIMEOUT:1,AGENT_PROTOCOL_ERROR:1,AGENT_TURN_ABORTED:1,BRIDGE_CONFIG_INVALID:1,BRIDGE_INTERNAL:1,MODEL_TOKEN_GEN_FAILED:1,OPERATION_NOT_ALLOWED_FOR_LOCAL:1,AGENT_DEPENDENCY_INSTALL_FAILED:1,AGENT_APPROVAL_TIMEOUT:1,AGENT_ENV_NOT_READY:1};function R1(t){return T1[t]??1}async function Lx(t,e={}){let r=e.paths??Y();if(!t.agentId||!t.sessionId)return process.stderr.write(`Error: missing --agent-id and/or --session-id. These IDs come from the <coze-context> block injected at the top of each prompt \u2014 extract agentId and sessionId from there and pass them as flags. Example: coze-bridge send image x.png --agent-id <id> --session-id <id>
|
|
117
117
|
`),4;if(t.groupFile&&!t.mimeType)return process.stderr.write(`Error: --group-file requires --mime <mimeType> (e.g. application/pdf, image/png). No local file is read in group-file mode, mime cannot be auto-detected.
|
|
118
|
-
`),3;let i=await
|
|
119
|
-
`),4;let o={agentId:t.agentId,sessionId:t.sessionId,kind:t.kind,path:t.groupFile?t.path:
|
|
118
|
+
`),3;let i=await Zo(r).catch(()=>null);if(!i)return process.stderr.write(`Error: coze-bridge daemon not running (cannot read ${r.portFile} / ${r.tokenFile}). Make sure you are inside an agent session spawned by the daemon.
|
|
119
|
+
`),4;let o={agentId:t.agentId,sessionId:t.sessionId,kind:t.kind,path:t.groupFile?t.path:I1(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 C1(i,"/agent/send",o,A1)}catch(l){return process.stderr.write(`Error: daemon IPC failed: ${l instanceof Error?l.message:String(l)}
|
|
120
120
|
`),4}if(!c.ok)return process.stderr.write(`Error: ${c.code}: ${c.message}
|
|
121
|
-
`),
|
|
122
|
-
`);else{let l=t.name??
|
|
123
|
-
`)}else process.stdout.write(`Sent ${t.kind} ${l} (${
|
|
124
|
-
`)}return 0}async function
|
|
125
|
-
`)}function
|
|
121
|
+
`),R1(c.code);if(t.json)process.stdout.write(`${JSON.stringify(c)}
|
|
122
|
+
`);else{let l=t.name??S1(o.path);if(t.groupFile){let u=c.uri.length>60?`${c.uri.slice(0,57)}...`:c.uri;process.stdout.write(`Sent group file ${l} (uri=${u})
|
|
123
|
+
`)}else process.stdout.write(`Sent ${t.kind} ${l} (${D1(c.bytes)})
|
|
124
|
+
`)}return 0}async function C1(t,e,r,i){let o=new AbortController,c=setTimeout(()=>o.abort(),i);try{let l=await fetch(`http://127.0.0.1:${t.port}${e}`,{method:"POST",headers:{Authorization:`Bearer ${t.token}`,"content-type":"application/json"},body:JSON.stringify(r),signal:o.signal}),u=await l.text(),h=u?JSON.parse(u):null;return h&&typeof h=="object"&&"ok"in h?h:{ok:!1,code:"BRIDGE_INTERNAL",message:`unexpected daemon response (status=${l.status}): ${u.slice(0,200)}`}}finally{clearTimeout(c)}}function D1(t){return t<1024?`${t}B`:t<1024*1024?`${(t/1024).toFixed(1)}KB`:`${(t/1024/1024).toFixed(1)}MB`}var qx=G("cli");function He(t,e){let{value:r,rest:i}=Sn(t,e);return{value:r,rest:i}}function ra(t,e){process.stderr.write(`[deprecated] '${t}' will be removed in a future release, use '${e}' instead
|
|
125
|
+
`)}function eS(t){let e=t.slice(2);if(e.includes("--version")||e.includes("-v"))return{mode:"version"};if(e.includes("--daemon"))return{mode:"daemon"};if(e[0]==="status")return{mode:"status"};if(e[0]==="stop")return{mode:"stop"};if(e[0]==="reload"){let{value:R}=He(e.slice(1),"--agent-id");return R?{mode:"reload",agentId:R}:{mode:"reload"}}if(e[0]==="update")return{mode:"update"};if(e[0]==="purge")return{mode:"purge"};if(e[0]==="service")return e[1]==="install"?{mode:"service-install"}:e[1]==="uninstall"?{mode:"service-uninstall"}:{mode:"help"};if(e[0]==="send")return tS(e.slice(1));if(e[0]==="log")return{mode:"log",...Cx(e.slice(1))};if(e[0]==="connect")return nS(e.slice(1));if(e.includes("--status"))return ra("--status","coze-bridge status"),{mode:"status"};if(e.includes("--stop"))return ra("--stop","coze-bridge stop"),{mode:"stop"};if(e.includes("--uninstall"))return ra("--uninstall","coze-bridge purge"),{mode:"purge"};if(e.includes("--install-service"))return ra("--install-service","coze-bridge service install"),{mode:"service-install"};if(e.includes("--help")||e.includes("-h")||e.length===0)return{mode:"help"};let r=e,{value:i,rest:o}=He(r,"--pat-token");r=o;let{value:c,rest:l}=He(r,"--pair-code");r=l;let{value:u,rest:h}=He(r,"--env");r=h;let{value:x,rest:w}=He(r,"--handshake-url");r=w;let{value:E,rest:I}=He(r,"--frontier-url");r=I;let{value:b,rest:v}=He(r,"--mock-scenario");r=v;let{value:A}=He(r,"--agent-id");if(!i||!c)return{mode:"help"};let S={mode:"pair",privatecode:i,pairingCode:c};return u&&(S.env=u),x&&(S.handshakeUrl=x),E&&(S.frontierUrl=E),b&&(S.mockScenario=b),A&&(S.agentId=A),S}function tS(t){let e=t[0],r=t[1];if(e!=="image"&&e!=="file")return{mode:"help"};if(!r||r.startsWith("--"))return{mode:"help"};let i=t.slice(2),{value:o,rest:c}=He(i,"--caption");i=c;let{value:l,rest:u}=He(i,"--name");i=u;let{value:h,rest:x}=He(i,"--agent-id");i=x;let{value:w,rest:E}=He(i,"--session-id");i=E;let{value:I,rest:b}=He(i,"--mime");i=b;let v=i.includes("--group-file");i=i.filter(R=>R!=="--group-file");let A=i.includes("--json"),S={mode:"send",kind:e,path:r,json:A};return o&&(S.caption=o),l&&(S.name=l),h&&(S.agentId=h),w&&(S.sessionId=w),v&&(S.groupFile=!0),I&&(S.mimeType=I),S}function nS(t){let e=t,{value:r,rest:i}=He(e,"--pat-token");e=i;let{value:o,rest:c}=He(e,"--env");e=c;let{value:l,rest:u}=He(e,"--handshake-url");e=u;let{value:h,rest:x}=He(e,"--frontier-url");e=x;let{value:w,rest:E}=He(e,"--mock-scenario");e=E;let I={mode:"connect"};return r&&(I.privatecode=r),o&&(I.env=o),l&&(I.handshakeUrl=l),h&&(I.frontierUrl=h),w&&(I.mockScenario=w),I}var rS=`
|
|
126
126
|
coze-bridge - local bridge daemon for cloud Agent Service
|
|
127
127
|
|
|
128
128
|
Pair (paste from cloud UI; start/reuse daemon and deliver pair-code):
|
|
@@ -201,56 +201,56 @@ Deprecated flags (still work, but emit a warning; will be removed in a future re
|
|
|
201
201
|
|
|
202
202
|
Internal:
|
|
203
203
|
<node> <entry> --daemon daemon mode (OS supervisor only)
|
|
204
|
-
`.trimStart();async function
|
|
205
|
-
`),0;case"daemon":{try{await
|
|
206
|
-
`),1;if(i.kind==="stale")return await
|
|
204
|
+
`.trimStart();async function Hx(t=process.argv,e={}){let r=eS(t);switch(r.mode){case"help":return process.stdout.write(rS),0;case"version":return process.stdout.write(`${vr}
|
|
205
|
+
`),0;case"daemon":{try{await _x()}catch(i){return qx.error("daemon start failed",{err:String(i)}),1}return new Promise(()=>{})}case"status":return iS(e);case"stop":return Wx(e);case"reload":return aS(r.agentId,e);case"log":return Px(r,e);case"update":return sS(e);case"purge":return cS(e);case"service-install":return dS(e);case"service-uninstall":return lS(e);case"pair":{let i={};return r.env&&(i.env=r.env),r.handshakeUrl&&(i.handshakeUrl=r.handshakeUrl),r.frontierUrl&&(i.frontierUrl=r.frontierUrl),r.mockScenario&&(i.mockScenario=r.mockScenario),uS(r.privatecode,r.pairingCode,e,i,r.agentId)}case"connect":{let i={};return r.env&&(i.env=r.env),r.handshakeUrl&&(i.handshakeUrl=r.handshakeUrl),r.frontierUrl&&(i.frontierUrl=r.frontierUrl),r.mockScenario&&(i.mockScenario=r.mockScenario),fS(r.privatecode,e,i)}case"send":return Lx({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 jx(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 iS(t){let e=t.paths??Y(),r=new Yt(e),i=await r.probe();if(i.kind==="not-running")return process.stdout.write(`coze-bridge: not running
|
|
206
|
+
`),1;if(i.kind==="stale")return await jx(e),process.stdout.write(`coze-bridge: not running (cleaned stale state)
|
|
207
207
|
`),1;let o=await r.request({method:"GET",path:"/status"});return process.stdout.write(`coze-bridge: running
|
|
208
208
|
${JSON.stringify(o.body,null,2)}
|
|
209
|
-
`),0}async function
|
|
209
|
+
`),0}async function Wx(t){let e=t.paths??Y(),r=new Yt(e),i=await Qi(t),o=!1;if(i)try{await i.uninstall(),o=!0}catch(l){process.stderr.write(`coze-bridge: supervisor uninstall failed (continuing): ${String(l)}
|
|
210
210
|
`)}let c=await r.probe();if(c.kind==="not-running")return process.stdout.write(o?`coze-bridge: stopped
|
|
211
211
|
`:`coze-bridge: not running
|
|
212
|
-
`),0;if(c.kind==="stale")return await
|
|
212
|
+
`),0;if(c.kind==="stale")return await jx(e),process.stdout.write(`coze-bridge: not running (cleaned stale state)
|
|
213
213
|
`),0;try{return await r.request({method:"POST",path:"/shutdown"}),process.stdout.write(`coze-bridge: stopped
|
|
214
214
|
`),0}catch(l){return(await r.probe()).kind!=="connected"?(process.stdout.write(`coze-bridge: stopped
|
|
215
215
|
`),0):(process.stdout.write(`coze-bridge: stop failed: ${String(l)}
|
|
216
|
-
`),1)}}async function
|
|
217
|
-
`),e(1)})})}async function
|
|
216
|
+
`),1)}}async function sS(t){return await Wx(t),(t.spawnNpx??oS)(["-y","--ignore-existing","coze-bridge@latest","connect"])}function oS(t){return new Promise(e=>{let r=nt("npx",t,{stdio:"inherit"});r.on("exit",i=>e(i??1)),r.on("error",i=>{process.stderr.write(`coze-bridge: spawn npx failed: ${String(i)}
|
|
217
|
+
`),e(1)})})}async function aS(t,e){let r=new Yt(e.paths);if((await r.probe()).kind==="not-running")return process.stdout.write(`coze-bridge: not running (start daemon first)
|
|
218
218
|
`),1;try{let o=await r.request({method:"POST",path:"/reload",body:t?{agent_id:t}:{},timeoutMs:35e3});if(o.status===200&&o.body?.ok){let c=o.body.recycled??[];return t&&c.length===0?process.stdout.write(`coze-bridge: agent ${t} \u65E0\u8FD0\u884C\u4E2D\u5B50\u8FDB\u7A0B\u53EF\u56DE\u6536 (\u672A\u6CE8\u518C / \u5DF2 idle)
|
|
219
219
|
`):process.stdout.write(`coze-bridge: reloaded ${c.length} agent(s): ${c.join(", ")||"(none)"}
|
|
220
220
|
`),0}return process.stderr.write(`coze-bridge: reload failed: ${JSON.stringify(o.body)}
|
|
221
221
|
`),1}catch(o){return process.stderr.write(`coze-bridge: reload failed: ${String(o)}
|
|
222
|
-
`),1}}async function
|
|
222
|
+
`),1}}async function Qi(t){if(t.supervisor){let c=t.supervisor,l={nodeBin:"",entry:"",logFile:"",homeDir:"",userName:""};return{platform:c.platform,install:u=>c.install(l,u),uninstall:()=>c.uninstall(l)}}if(t.skipSupervisor)return;let{getSupervisor:e,buildContext:r}=await Promise.resolve().then(()=>(Ux(),Fx)),i=e(),o=r();return{platform:i.platform,install:c=>i.install(o,c),uninstall:()=>i.uninstall(o)}}async function Kx(t,e){let r=await e.probe();if(r.kind==="connected")return r;let i=t.spawnDaemon??gx,o=t.waitTimeoutMs??15e3,c=t.sleep??xS,l=t.paths??Y(),u=await Qi(t);if(u&&(u.platform==="darwin"||u.platform==="linux")){try{await u.install({activate:!0});let h=await Gx(e,o,c);if(h.kind==="connected")return h;$r(l.bridgeLogsDir,"warn","cli","supervisor \u8D77 daemon \u8D85\u65F6, \u56DE\u9000\u624B\u52A8 spawn (\u672C\u6B21\u65E0\u5D29\u6E83\u4FDD\u6D3B)",{waitMs:o})}catch(h){$r(l.bridgeLogsDir,"warn","cli","supervisor \u63A5\u7BA1\u5931\u8D25, \u56DE\u9000\u624B\u52A8 spawn",{err:String(h)})}await u.uninstall().catch(()=>{}),await hS(l.pidFile,c)}else u&&await u.install({activate:!1}).catch(h=>process.stderr.write(`coze-bridge: \u81EA\u542F\u6CE8\u518C\u5931\u8D25(\u4E0D\u5F71\u54CD\u672C\u6B21): ${String(h)}
|
|
223
223
|
`));return process.stdout.write(`coze-bridge: starting daemon...
|
|
224
|
-
`),await i({paths:t.paths}),
|
|
224
|
+
`),await i({paths:t.paths}),Gx(e,o,c)}async function cS(t){let e=new Yt(t.paths);if((await e.probe()).kind==="connected"){process.stdout.write(`coze-bridge: stopping daemon...
|
|
225
225
|
`);try{await e.request({method:"POST",path:"/shutdown"})}catch(l){process.stderr.write(`coze-bridge: stop failed (continuing): ${String(l)}
|
|
226
|
-
`)}await new Promise(l=>setTimeout(l,500))}let i=await
|
|
226
|
+
`)}await new Promise(l=>setTimeout(l,500))}let i=await Qi(t);if(i)try{await i.uninstall(),process.stdout.write(`coze-bridge: ${i.platform} supervisor unregistered
|
|
227
227
|
`)}catch(l){process.stderr.write(`coze-bridge: supervisor uninstall failed (continuing): ${String(l)}
|
|
228
|
-
`)}let o=t.paths??
|
|
228
|
+
`)}let o=t.paths??Y(),{rm:c}=await import("node:fs/promises");try{await c(o.bridgeRoot,{recursive:!0,force:!0}),process.stdout.write(`coze-bridge: removed ${o.bridgeRoot}
|
|
229
229
|
`)}catch(l){return process.stderr.write(`coze-bridge: remove failed: ${String(l)}
|
|
230
230
|
`),1}return process.stdout.write(`coze-bridge: purged (agents workspaces preserved under ~/.coze/agents)
|
|
231
|
-
`),0}async function
|
|
231
|
+
`),0}async function dS(t){let e=await Qi(t);if(!e)return 0;try{return process.stdout.write(`coze-bridge: installing ${e.platform} supervisor...
|
|
232
232
|
`),await e.install(),process.stdout.write(`coze-bridge: supervisor installed (daemon will auto-start on login)
|
|
233
233
|
`),0}catch(r){return process.stderr.write(`coze-bridge: service install failed: ${String(r)}
|
|
234
|
-
`),1}}async function
|
|
234
|
+
`),1}}async function lS(t){let e=await Qi(t);if(!e)return 0;try{return await e.uninstall(),process.stdout.write(`coze-bridge: ${e.platform} supervisor unregistered
|
|
235
235
|
`),0}catch(r){return process.stderr.write(`coze-bridge: service uninstall failed: ${String(r)}
|
|
236
|
-
`),1}}async function
|
|
237
|
-
`),(await c.probe()).kind==="connected"&&(await c.request({method:"POST",path:"/shutdown"}).catch(()=>{}),await new Promise(
|
|
238
|
-
`)}let
|
|
239
|
-
`),1;let
|
|
236
|
+
`),1}}async function uS(t,e,r,i={},o){let c=new Yt(r.paths),l=r.paths??Y();if(await Kc(l).catch(x=>$r(l.bridgeLogsDir,"warn","cli","writeAgentEnv failed (ignored)",{err:String(x)})),!r.skipDistInstall){let x=await Pd({paths:r.paths});x.kind==="version-changed"?(process.stdout.write(`coze-bridge: upgraded ${x.fromVersion} \u2192 ${x.toVersion}
|
|
237
|
+
`),(await c.probe()).kind==="connected"&&(await c.request({method:"POST",path:"/shutdown"}).catch(()=>{}),await new Promise(E=>setTimeout(E,500)))):x.kind==="first-install"&&process.stdout.write(`coze-bridge: installed ${x.libVersion}
|
|
238
|
+
`)}let u=await Kx(r,c);if(u.kind!=="connected")return process.stderr.write(`coze-bridge: daemon did not come up: ${u.kind}
|
|
239
|
+
`),1;let h={privatecode:t,pairing_code:e};i.env&&(h.env=i.env),i.handshakeUrl&&(h.handshake_url=i.handshakeUrl),i.frontierUrl&&(h.frontier_url=i.frontierUrl),i.mockScenario&&(h.mock_scenario=i.mockScenario),o&&(h.agent_id=o);try{let x=await c.request({method:"POST",path:"/pair",body:h,timeoutMs:35e3});if(x.status===200&&x.body?.ok){let w=x.body.agent;return w&&!w.ok?(process.stderr.write(`coze-bridge: paired but agent ensure failed (agentId=${w.agentId}): ${w.note}
|
|
240
240
|
`),1):(process.stdout.write(`\u5DF2\u914D\u5BF9\u8FDE\u63A5\u5B8C\u6210\uFF0C\u8BF7\u8FD4\u56DE\u5230 coze \u5E73\u53F0\u4E0A\u70B9\u51FB "\u6211\u5DF2\u6267\u884C"
|
|
241
|
-
`),0)}return process.stderr.write(`coze-bridge: pair failed: ${JSON.stringify(
|
|
242
|
-
`),1}catch(
|
|
243
|
-
`),1}}async function
|
|
244
|
-
`),(await c.probe()).kind==="connected"&&(await c.request({method:"POST",path:"/shutdown"}).catch(()=>{}),await new Promise(
|
|
245
|
-
`)}let l=await
|
|
246
|
-
`),1;let
|
|
247
|
-
`),await
|
|
248
|
-
`),1)}catch(
|
|
249
|
-
`),1}}async function
|
|
241
|
+
`),0)}return process.stderr.write(`coze-bridge: pair failed: ${JSON.stringify(x.body)}
|
|
242
|
+
`),1}catch(x){return process.stderr.write(`coze-bridge: pair failed: ${String(x)}
|
|
243
|
+
`),1}}async function fS(t,e,r={}){let i=e.paths??Y(),o=t??await qo(i);if(!o)return process.stderr.write("coze-bridge: \u627E\u4E0D\u5230 patToken \u2014 \u5148\u8DD1\u4E00\u6B21 `coze-bridge --pat-token=<sat_xxx> --pair-code=<xxx>` \u914D\u5BF9, \u6216\u672C\u6B21\u7528 `--pat-token` \u6307\u5B9A\n"),1;let c=new Yt(e.paths);if(await Kc(i).catch(h=>$r(i.bridgeLogsDir,"warn","cli","writeAgentEnv failed (ignored)",{err:String(h)})),!e.skipDistInstall){let h=await Pd({paths:e.paths});h.kind==="version-changed"?(process.stdout.write(`coze-bridge: upgraded ${h.fromVersion} \u2192 ${h.toVersion}
|
|
244
|
+
`),(await c.probe()).kind==="connected"&&(await c.request({method:"POST",path:"/shutdown"}).catch(()=>{}),await new Promise(w=>setTimeout(w,500)))):h.kind==="first-install"&&process.stdout.write(`coze-bridge: installed ${h.libVersion}
|
|
245
|
+
`)}let l=await Kx(e,c);if(l.kind!=="connected")return process.stderr.write(`coze-bridge: daemon did not come up: ${l.kind}
|
|
246
|
+
`),1;let u={privatecode:o};r.env&&(u.env=r.env),r.handshakeUrl&&(u.handshake_url=r.handshakeUrl),r.frontierUrl&&(u.frontier_url=r.frontierUrl),r.mockScenario&&(u.mock_scenario=r.mockScenario);try{let h=await c.request({method:"POST",path:"/connect",body:u,timeoutMs:35e3});return h.status===200&&h.body?.ok?(process.stdout.write(`coze-bridge: connected (${h.body.note??"ok"})
|
|
247
|
+
`),await Zi(o,i).catch(x=>qx.warn("writePatToken after connect failed (ignored)",{err:String(x)})),0):(process.stderr.write(`coze-bridge: connect failed: ${JSON.stringify(h.body)}
|
|
248
|
+
`),1)}catch(h){return process.stderr.write(`coze-bridge: connect failed: ${String(h)}
|
|
249
|
+
`),1}}async function Gx(t,e,r){let i=Date.now()+e;for(;Date.now()<i;){let o=await t.probe(500);if(o.kind==="connected")return o;await r(200)}return t.probe(500)}async function hS(t,e,r=60,i=200){let{readFile:o}=await import("node:fs/promises");for(let c=0;c<r;c++){let l;try{l=await o(t,"utf8")}catch{return}let u=Number.parseInt(l.trim(),10);if(!Number.isFinite(u)||u<=0||!so(u))return;await e(i)}}function xS(t){return new Promise(e=>setTimeout(e,t))}ne();function pS(t){let e=/^v?(\d+)(?:\.(\d+))?/.exec(t.trim());if(!e)return"ok";let r=Number(e[1]),i=Number(e[2]??0);return r<18||r===18&&i<4?"fatal":r<20?"warn":"ok"}function $x(t=process.versions.node,e=i=>{process.stderr.write(i)},r=i=>process.exit(i)){let i=pS(t);if(i==="ok")return;let o=t.replace(/^v/,"");i==="fatal"?(e(`[coze-bridge] \u5F53\u524D Node.js \u7248\u672C v${o} \u8FC7\u4F4E,\u65E0\u6CD5\u8FD0\u884C(\u6700\u4F4E v18.4.0,\u63A8\u8350 v20+)\u3002\u8BF7\u5347\u7EA7\u540E\u91CD\u8BD5:https://nodejs.org(\u6216\u7528 nvm/fnm)\u3002
|
|
250
250
|
`),r(1)):e(`[coze-bridge] \u68C0\u6D4B\u5230 Node.js v${o},\u672C\u9879\u76EE\u63A8\u8350 v20+,\u4F4E\u4E8E v20 \u540E\u7EED\u5347\u7EA7\u53EF\u80FD\u6709\u517C\u5BB9\u95EE\u9898,\u5EFA\u8BAE\u5347\u7EA7\u3002
|
|
251
251
|
\u5347\u7EA7\u5B8C\u540E\u9700\u8981\u6267\u884C\u4EE5\u4E0B\u547D\u4EE4\u91CD\u65B0\u8FDE\u63A5:
|
|
252
252
|
npx -y coze-bridge@latest stop
|
|
253
253
|
npx -y coze-bridge@latest connect
|
|
254
254
|
|
|
255
|
-
`)}
|
|
255
|
+
`)}$x();!process.argv.includes("--daemon")&&!process.env.COZE_BRIDGE_LOG_LEVEL&&sl("warn");Hx(process.argv).then(t=>process.exit(t),t=>{process.stderr.write(`fatal: ${t instanceof Error?t.stack??t.message:String(t)}
|
|
256
256
|
`),process.exit(1)});
|